summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format2
-rw-r--r--.clang-tidy44
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md11
-rw-r--r--.github/ISSUE_TEMPLATE/config.yml14
-rw-r--r--.github/ISSUE_TEMPLATE/feature---enhancement-request.md19
-rw-r--r--.gitignore11
-rw-r--r--.travis.yml6
-rw-r--r--AUTHORS.md1
-rw-r--r--CONTRIBUTING.md16
-rw-r--r--COPYRIGHT.txt12
-rw-r--r--DONORS.md87
-rw-r--r--SConstruct249
-rw-r--r--core/SCsub1
-rw-r--r--core/array.cpp78
-rw-r--r--core/array.h1
-rw-r--r--core/bind/core_bind.cpp883
-rw-r--r--core/bind/core_bind.h139
-rw-r--r--core/callable.cpp27
-rw-r--r--core/callable.h11
-rw-r--r--core/callable_method_pointer.cpp1
-rw-r--r--core/callable_method_pointer.h44
-rw-r--r--core/class_db.cpp274
-rw-r--r--core/class_db.h34
-rw-r--r--core/color.cpp86
-rw-r--r--core/color.h31
-rw-r--r--core/color_names.inc3
-rw-r--r--core/command_queue_mt.cpp25
-rw-r--r--core/command_queue_mt.h44
-rw-r--r--core/compressed_translation.cpp38
-rw-r--r--core/compressed_translation.h10
-rw-r--r--core/container_type_validate.h2
-rw-r--r--core/core_string_names.h1
-rw-r--r--core/cowdata.h69
-rw-r--r--core/crypto/crypto.cpp49
-rw-r--r--core/crypto/crypto.h13
-rw-r--r--core/crypto/crypto_core.h5
-rw-r--r--core/crypto/hashing_context.cpp8
-rw-r--r--core/crypto/hashing_context.h4
-rw-r--r--core/debugger/debugger_marshalls.cpp3
-rw-r--r--core/debugger/debugger_marshalls.h32
-rw-r--r--core/debugger/engine_debugger.cpp25
-rw-r--r--core/debugger/local_debugger.cpp55
-rw-r--r--core/debugger/local_debugger.h1
-rw-r--r--core/debugger/remote_debugger.cpp100
-rw-r--r--core/debugger/remote_debugger_peer.cpp24
-rw-r--r--core/debugger/script_debugger.cpp27
-rw-r--r--core/debugger/script_debugger.h1
-rw-r--r--core/dictionary.cpp60
-rw-r--r--core/dictionary.h1
-rw-r--r--core/engine.cpp44
-rw-r--r--core/engine.h33
-rw-r--r--core/error_macros.cpp12
-rw-r--r--core/error_macros.h58
-rw-r--r--core/func_ref.cpp14
-rw-r--r--core/func_ref.h4
-rw-r--r--core/global_constants.cpp7
-rw-r--r--core/hash_map.h153
-rw-r--r--core/hashfuncs.h20
-rw-r--r--core/image.cpp620
-rw-r--r--core/image.h15
-rw-r--r--core/input/gamecontrollerdb.txt57
-rw-r--r--core/input/input.cpp178
-rw-r--r--core/input/input.h49
-rw-r--r--core/input/input_event.cpp362
-rw-r--r--core/input/input_event.h120
-rw-r--r--core/input/input_map.cpp58
-rw-r--r--core/input/input_map.h5
-rw-r--r--core/io/compression.cpp19
-rw-r--r--core/io/compression.h3
-rw-r--r--core/io/config_file.cpp56
-rw-r--r--core/io/config_file.h1
-rw-r--r--core/io/dtls_server.cpp11
-rw-r--r--core/io/dtls_server.h2
-rw-r--r--core/io/file_access_buffered.cpp26
-rw-r--r--core/io/file_access_buffered.h11
-rw-r--r--core/io/file_access_buffered_fa.h42
-rw-r--r--core/io/file_access_compressed.cpp87
-rw-r--r--core/io/file_access_compressed.h37
-rw-r--r--core/io/file_access_encrypted.cpp68
-rw-r--r--core/io/file_access_encrypted.h12
-rw-r--r--core/io/file_access_memory.cpp33
-rw-r--r--core/io/file_access_memory.h5
-rw-r--r--core/io/file_access_network.cpp73
-rw-r--r--core/io/file_access_network.h33
-rw-r--r--core/io/file_access_pack.cpp112
-rw-r--r--core/io/file_access_pack.h35
-rw-r--r--core/io/file_access_zip.cpp58
-rw-r--r--core/io/file_access_zip.h12
-rw-r--r--core/io/http_client.cpp102
-rw-r--r--core/io/http_client.h33
-rw-r--r--core/io/image_loader.cpp31
-rw-r--r--core/io/image_loader.h1
-rw-r--r--core/io/ip.cpp39
-rw-r--r--core/io/ip_address.cpp71
-rw-r--r--core/io/ip_address.h26
-rw-r--r--core/io/json.cpp105
-rw-r--r--core/io/json.h2
-rw-r--r--core/io/logger.cpp12
-rw-r--r--core/io/logger.h7
-rw-r--r--core/io/marshalls.cpp274
-rw-r--r--core/io/marshalls.h28
-rw-r--r--core/io/multiplayer_api.cpp109
-rw-r--r--core/io/multiplayer_api.h7
-rw-r--r--core/io/net_socket.cpp4
-rw-r--r--core/io/net_socket.h1
-rw-r--r--core/io/networked_multiplayer_peer.cpp4
-rw-r--r--core/io/networked_multiplayer_peer.h3
-rw-r--r--core/io/packet_peer.cpp73
-rw-r--r--core/io/packet_peer.h8
-rw-r--r--core/io/packet_peer_dtls.cpp10
-rw-r--r--core/io/packet_peer_dtls.h2
-rw-r--r--core/io/packet_peer_udp.cpp58
-rw-r--r--core/io/packet_peer_udp.h12
-rw-r--r--core/io/pck_packer.cpp59
-rw-r--r--core/io/pck_packer.h6
-rw-r--r--core/io/resource_format_binary.cpp258
-rw-r--r--core/io/resource_format_binary.h21
-rw-r--r--core/io/resource_importer.cpp53
-rw-r--r--core/io/resource_importer.h2
-rw-r--r--core/io/resource_loader.cpp179
-rw-r--r--core/io/resource_loader.h8
-rw-r--r--core/io/resource_saver.cpp44
-rw-r--r--core/io/resource_saver.h1
-rw-r--r--core/io/stream_peer.cpp93
-rw-r--r--core/io/stream_peer.h9
-rw-r--r--core/io/stream_peer_ssl.cpp9
-rw-r--r--core/io/stream_peer_ssl.h4
-rw-r--r--core/io/stream_peer_tcp.cpp46
-rw-r--r--core/io/stream_peer_tcp.h7
-rw-r--r--core/io/tcp_server.cpp16
-rw-r--r--core/io/tcp_server.h1
-rw-r--r--core/io/translation_loader_po.cpp49
-rw-r--r--core/io/translation_loader_po.h2
-rw-r--r--core/io/udp_server.cpp15
-rw-r--r--core/io/xml_parser.cpp136
-rw-r--r--core/io/xml_parser.h13
-rw-r--r--core/io/zip_io.cpp17
-rw-r--r--core/list.h212
-rw-r--r--core/local_vector.h22
-rw-r--r--core/make_binders.py6
-rw-r--r--core/map.h221
-rw-r--r--core/math/a_star.cpp112
-rw-r--r--core/math/a_star.h30
-rw-r--r--core/math/aabb.cpp74
-rw-r--r--core/math/aabb.h115
-rw-r--r--core/math/audio_frame.h2
-rw-r--r--core/math/basis.cpp279
-rw-r--r--core/math/basis.h32
-rw-r--r--core/math/camera_matrix.cpp74
-rw-r--r--core/math/camera_matrix.h3
-rw-r--r--core/math/delaunay_2d.h15
-rw-r--r--core/math/delaunay_3d.h55
-rw-r--r--core/math/disjoint_set.h5
-rw-r--r--core/math/expression.cpp313
-rw-r--r--core/math/expression.h39
-rw-r--r--core/math/face3.cpp79
-rw-r--r--core/math/face3.h34
-rw-r--r--core/math/geometry_2d.cpp384
-rw-r--r--core/math/geometry_2d.h398
-rw-r--r--core/math/geometry_3d.cpp (renamed from core/math/geometry.cpp)608
-rw-r--r--core/math/geometry_3d.h (renamed from core/math/geometry.h)634
-rw-r--r--core/math/math_fieldwise.cpp1
-rw-r--r--core/math/math_funcs.cpp16
-rw-r--r--core/math/math_funcs.h18
-rw-r--r--core/math/octree.h333
-rw-r--r--core/math/plane.cpp21
-rw-r--r--core/math/plane.h19
-rw-r--r--core/math/quat.cpp12
-rw-r--r--core/math/quat.h15
-rw-r--r--core/math/quick_hull.cpp87
-rw-r--r--core/math/quick_hull.h23
-rw-r--r--core/math/random_number_generator.cpp2
-rw-r--r--core/math/random_number_generator.h7
-rw-r--r--core/math/rect2.cpp80
-rw-r--r--core/math/rect2.h118
-rw-r--r--core/math/transform.cpp23
-rw-r--r--core/math/transform.h13
-rw-r--r--core/math/transform_2d.cpp33
-rw-r--r--core/math/transform_2d.h13
-rw-r--r--core/math/triangle_mesh.cpp132
-rw-r--r--core/math/triangle_mesh.h9
-rw-r--r--core/math/triangulate.cpp38
-rw-r--r--core/math/vector2.cpp50
-rw-r--r--core/math/vector2.h53
-rw-r--r--core/math/vector3.cpp21
-rw-r--r--core/math/vector3.h69
-rw-r--r--core/math/vector3i.cpp6
-rw-r--r--core/math/vector3i.h52
-rw-r--r--core/message_queue.cpp78
-rw-r--r--core/message_queue.h9
-rw-r--r--core/method_bind.cpp20
-rw-r--r--core/method_bind.h49
-rw-r--r--core/method_ptrcall.h8
-rw-r--r--core/node_path.cpp199
-rw-r--r--core/node_path.h9
-rw-r--r--core/oa_hash_map.h103
-rw-r--r--core/object.cpp452
-rw-r--r--core/object.h128
-rw-r--r--core/ordered_hash_map.h37
-rw-r--r--core/os/dir_access.cpp84
-rw-r--r--core/os/dir_access.h25
-rw-r--r--core/os/file_access.cpp174
-rw-r--r--core/os/file_access.h19
-rw-r--r--core/os/keyboard.cpp11
-rw-r--r--core/os/main_loop.cpp26
-rw-r--r--core/os/main_loop.h5
-rw-r--r--core/os/memory.cpp13
-rw-r--r--core/os/memory.h33
-rw-r--r--core/os/midi_driver.cpp5
-rw-r--r--core/os/midi_driver.h1
-rw-r--r--core/os/mutex.h3
-rw-r--r--core/os/os.cpp130
-rw-r--r--core/os/os.h38
-rw-r--r--core/os/rw_lock.cpp4
-rw-r--r--core/os/rw_lock.h16
-rw-r--r--core/os/semaphore.cpp31
-rw-r--r--core/os/semaphore.h3
-rw-r--r--core/os/thread.cpp20
-rw-r--r--core/os/thread.h5
-rw-r--r--core/os/thread_dummy.cpp8
-rw-r--r--core/os/thread_dummy.h2
-rw-r--r--core/os/threaded_array_processor.h6
-rw-r--r--core/packed_data_container.cpp88
-rw-r--r--core/packed_data_container.h7
-rw-r--r--core/pair.h2
-rw-r--r--core/path_remap.cpp31
-rw-r--r--core/pool_allocator.cpp95
-rw-r--r--core/pool_allocator.h15
-rw-r--r--core/print_string.cpp20
-rw-r--r--core/print_string.h13
-rw-r--r--core/project_settings.cpp269
-rw-r--r--core/project_settings.h36
-rw-r--r--core/reference.cpp23
-rw-r--r--core/reference.h58
-rw-r--r--core/register_core_types.cpp25
-rw-r--r--core/resource.cpp125
-rw-r--r--core/resource.h11
-rw-r--r--core/rid.h11
-rw-r--r--core/rid_owner.h27
-rw-r--r--core/ring_buffer.h70
-rw-r--r--core/safe_refcount.cpp40
-rw-r--r--core/safe_refcount.h32
-rw-r--r--core/script_language.cpp100
-rw-r--r--core/script_language.h12
-rw-r--r--core/self_list.h31
-rw-r--r--core/set.h196
-rw-r--r--core/simple_type.h3
-rw-r--r--core/sort_array.h94
-rw-r--r--core/spin_lock.h1
-rw-r--r--core/string_buffer.h10
-rw-r--r--core/string_builder.cpp10
-rw-r--r--core/string_builder.h8
-rw-r--r--core/string_name.cpp78
-rw-r--r--core/string_name.h53
-rw-r--r--core/thread_work_pool.cpp4
-rw-r--r--core/thread_work_pool.h5
-rw-r--r--core/translation.cpp71
-rw-r--r--core/translation.h10
-rw-r--r--core/type_info.h7
-rw-r--r--core/typed_array.cpp31
-rw-r--r--core/typed_array.h5
-rw-r--r--core/typedefs.h3
-rw-r--r--core/ucaps.h2
-rw-r--r--core/undo_redo.cpp129
-rw-r--r--core/undo_redo.h28
-rw-r--r--core/ustring.cpp1168
-rw-r--r--core/ustring.h29
-rw-r--r--core/variant.cpp892
-rw-r--r--core/variant.h20
-rw-r--r--core/variant_call.cpp212
-rw-r--r--core/variant_op.cpp494
-rw-r--r--core/variant_parser.cpp468
-rw-r--r--core/variant_parser.h19
-rw-r--r--core/vector.h27
-rw-r--r--core/vmap.h36
-rw-r--r--core/vset.h27
-rw-r--r--doc/classes/@GlobalScope.xml11
-rw-r--r--doc/classes/AStar.xml3
-rw-r--r--doc/classes/AStar2D.xml3
-rw-r--r--doc/classes/AnimationTree.xml4
-rw-r--r--doc/classes/Array.xml12
-rw-r--r--doc/classes/AudioEffectRecord.xml1
-rw-r--r--doc/classes/BitmapFont.xml11
-rw-r--r--doc/classes/Camera3D.xml1
-rw-r--r--doc/classes/CanvasItem.xml8
-rw-r--r--doc/classes/ConvexPolygonShape2D.xml2
-rw-r--r--doc/classes/Dictionary.xml9
-rw-r--r--doc/classes/DirectionalLight3D.xml8
-rw-r--r--doc/classes/DisplayServer.xml70
-rw-r--r--doc/classes/DynamicFontData.xml2
-rw-r--r--doc/classes/EditorInterface.xml12
-rw-r--r--doc/classes/File.xml35
-rw-r--r--doc/classes/FileDialog.xml8
-rw-r--r--doc/classes/Font.xml11
-rw-r--r--doc/classes/Geometry2D.xml (renamed from doc/classes/Geometry.xml)232
-rw-r--r--doc/classes/Geometry3D.xml194
-rw-r--r--doc/classes/Image.xml15
-rw-r--r--doc/classes/ImageTextureLayered.xml31
-rw-r--r--doc/classes/InputMap.xml2
-rw-r--r--doc/classes/KinematicBody2D.xml2
-rw-r--r--doc/classes/KinematicBody3D.xml16
-rw-r--r--doc/classes/Label.xml2
-rw-r--r--doc/classes/Light3D.xml18
-rw-r--r--doc/classes/Lightmapper.xml13
-rw-r--r--doc/classes/LineEdit.xml20
-rw-r--r--doc/classes/Material.xml2
-rw-r--r--doc/classes/Node.xml17
-rw-r--r--doc/classes/OS.xml23
-rw-r--r--doc/classes/Object.xml3
-rw-r--r--doc/classes/OmniLight3D.xml2
-rw-r--r--doc/classes/PhysicalSkyMaterial.xml3
-rw-r--r--doc/classes/PhysicsMaterial.xml2
-rw-r--r--doc/classes/PhysicsServer2D.xml18
-rw-r--r--doc/classes/PopupMenu.xml2
-rw-r--r--doc/classes/ProjectSettings.xml32
-rw-r--r--doc/classes/Rect2i.xml122
-rw-r--r--doc/classes/RenderingServer.xml5
-rw-r--r--doc/classes/RichTextLabel.xml4
-rw-r--r--doc/classes/RigidBody2D.xml7
-rw-r--r--doc/classes/RigidBody3D.xml7
-rw-r--r--doc/classes/Shape2D.xml11
-rw-r--r--doc/classes/Skeleton3D.xml51
-rw-r--r--doc/classes/SpotLight3D.xml2
-rw-r--r--doc/classes/String.xml14
-rw-r--r--doc/classes/SubViewportContainer.xml1
-rw-r--r--doc/classes/TabContainer.xml4
-rw-r--r--doc/classes/TextEdit.xml16
-rw-r--r--doc/classes/TileSet.xml2
-rw-r--r--doc/classes/Vector2i.xml29
-rw-r--r--doc/classes/Vector3i.xml32
-rwxr-xr-xdoc/tools/makerst.py72
-rw-r--r--doc/translations/classes.pot2
-rw-r--r--doc/translations/fr.po2
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp44
-rw-r--r--drivers/alsa/audio_driver_alsa.h13
-rw-r--r--drivers/alsamidi/midi_driver_alsamidi.cpp13
-rw-r--r--drivers/alsamidi/midi_driver_alsamidi.h1
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp36
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h21
-rw-r--r--drivers/coremidi/midi_driver_coremidi.cpp8
-rw-r--r--drivers/coremidi/midi_driver_coremidi.h3
-rw-r--r--drivers/dummy/rasterizer_dummy.h8
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp71
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.h1
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp16
-rw-r--r--drivers/gles2/rasterizer_gles2.h1
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp119
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h6
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp260
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h26
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp50
-rw-r--r--drivers/gles2/shader_compiler_gles2.h5
-rw-r--r--drivers/gles2/shader_gles2.cpp24
-rw-r--r--drivers/gles2/shader_gles2.h10
-rw-r--r--drivers/gles2/shaders/blend_shape.glsl2
-rw-r--r--drivers/gles2/shaders/canvas.glsl5
-rw-r--r--drivers/gles2/shaders/canvas_shadow.glsl2
-rw-r--r--drivers/gles2/shaders/copy.glsl3
-rw-r--r--drivers/gles2/shaders/cube_to_dp.glsl2
-rw-r--r--drivers/gles2/shaders/cubemap_filter.glsl4
-rw-r--r--drivers/gles2/shaders/effect_blur.glsl4
-rw-r--r--drivers/gles2/shaders/exposure.glsl2
-rw-r--r--drivers/gles2/shaders/lens_distorted.glsl1
-rw-r--r--drivers/gles2/shaders/particles.glsl7
-rw-r--r--drivers/gles2/shaders/resolve.glsl2
-rw-r--r--drivers/gles2/shaders/scene.glsl23
-rw-r--r--drivers/gles2/shaders/screen_space_reflection.glsl5
-rw-r--r--drivers/gles2/shaders/ssao.glsl2
-rw-r--r--drivers/gles2/shaders/ssao_blur.glsl3
-rw-r--r--drivers/gles2/shaders/ssao_minify.glsl2
-rw-r--r--drivers/gles2/shaders/subsurf_scattering.glsl3
-rw-r--r--drivers/png/image_loader_png.cpp6
-rw-r--r--drivers/png/png_driver_common.cpp8
-rw-r--r--drivers/png/resource_saver_png.cpp6
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp62
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h37
-rw-r--r--drivers/register_driver_types.cpp5
-rw-r--r--drivers/unix/dir_access_unix.cpp73
-rw-r--r--drivers/unix/dir_access_unix.h1
-rw-r--r--drivers/unix/file_access_unix.cpp59
-rw-r--r--drivers/unix/file_access_unix.h9
-rw-r--r--drivers/unix/ip_unix.cpp22
-rw-r--r--drivers/unix/net_socket_posix.cpp67
-rw-r--r--drivers/unix/net_socket_posix.h7
-rw-r--r--drivers/unix/os_unix.cpp96
-rw-r--r--drivers/unix/os_unix.h5
-rw-r--r--drivers/unix/rw_lock_posix.cpp9
-rw-r--r--drivers/unix/rw_lock_posix.h1
-rw-r--r--drivers/unix/syslog_logger.cpp5
-rw-r--r--drivers/unix/thread_posix.cpp14
-rw-r--r--drivers/unix/thread_posix.h1
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp150
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h176
-rw-r--r--drivers/vulkan/vulkan_context.cpp21
-rw-r--r--drivers/vulkan/vulkan_context.h32
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp49
-rw-r--r--drivers/wasapi/audio_driver_wasapi.h52
-rw-r--r--drivers/windows/dir_access_windows.cpp33
-rw-r--r--drivers/windows/dir_access_windows.h1
-rw-r--r--drivers/windows/file_access_windows.cpp38
-rw-r--r--drivers/windows/file_access_windows.h16
-rw-r--r--drivers/windows/rw_lock_windows.cpp8
-rw-r--r--drivers/windows/rw_lock_windows.h1
-rw-r--r--drivers/windows/thread_windows.cpp16
-rw-r--r--drivers/windows/thread_windows.h7
-rw-r--r--drivers/winmidi/midi_driver_winmidi.cpp5
-rw-r--r--drivers/winmidi/midi_driver_winmidi.h1
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp26
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.h10
-rw-r--r--editor/SCsub26
-rw-r--r--editor/animation_bezier_editor.cpp118
-rw-r--r--editor/animation_bezier_editor.h2
-rw-r--r--editor/animation_track_editor.cpp717
-rw-r--r--editor/animation_track_editor.h4
-rw-r--r--editor/animation_track_editor_plugins.cpp156
-rw-r--r--editor/array_property_edit.cpp40
-rw-r--r--editor/array_property_edit.h1
-rw-r--r--editor/audio_stream_preview.cpp18
-rw-r--r--editor/code_editor.cpp178
-rw-r--r--editor/code_editor.h3
-rw-r--r--editor/connections_dialog.cpp133
-rw-r--r--editor/connections_dialog.h3
-rw-r--r--editor/create_dialog.cpp205
-rw-r--r--editor/create_dialog.h1
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp33
-rw-r--r--editor/debugger/editor_debugger_inspector.h5
-rw-r--r--editor/debugger/editor_debugger_node.cpp74
-rw-r--r--editor/debugger/editor_debugger_node.h6
-rw-r--r--editor/debugger/editor_debugger_server.cpp1
-rw-r--r--editor/debugger/editor_debugger_server.h1
-rw-r--r--editor/debugger/editor_debugger_tree.cpp26
-rw-r--r--editor/debugger/editor_debugger_tree.h1
-rw-r--r--editor/debugger/editor_network_profiler.cpp7
-rw-r--r--editor/debugger/editor_network_profiler.h1
-rw-r--r--editor/debugger/editor_profiler.cpp90
-rw-r--r--editor/debugger/editor_profiler.h4
-rw-r--r--editor/debugger/editor_visual_profiler.cpp70
-rw-r--r--editor/debugger/editor_visual_profiler.h2
-rw-r--r--editor/debugger/script_editor_debugger.cpp202
-rw-r--r--editor/debugger/script_editor_debugger.h1
-rw-r--r--editor/dependency_editor.cpp87
-rw-r--r--editor/dictionary_property_edit.cpp24
-rw-r--r--editor/doc_data.cpp289
-rw-r--r--editor/doc_data.h30
-rw-r--r--editor/editor_about.cpp14
-rw-r--r--editor/editor_about.h1
-rw-r--r--editor/editor_asset_installer.cpp28
-rw-r--r--editor/editor_asset_installer.h1
-rw-r--r--editor/editor_atlas_packer.cpp24
-rw-r--r--editor/editor_audio_buses.cpp160
-rw-r--r--editor/editor_audio_buses.h13
-rw-r--r--editor/editor_autoload_settings.cpp108
-rw-r--r--editor/editor_autoload_settings.h1
-rw-r--r--editor/editor_data.cpp281
-rw-r--r--editor/editor_data.h11
-rw-r--r--editor/editor_dir_dialog.cpp25
-rw-r--r--editor/editor_export.cpp270
-rw-r--r--editor/editor_export.h22
-rw-r--r--editor/editor_feature_profile.cpp81
-rw-r--r--editor/editor_feature_profile.h4
-rw-r--r--editor/editor_file_dialog.cpp246
-rw-r--r--editor/editor_file_dialog.h1
-rw-r--r--editor/editor_file_system.cpp273
-rw-r--r--editor/editor_file_system.h5
-rw-r--r--editor/editor_folding.cpp17
-rw-r--r--editor/editor_folding.h1
-rw-r--r--editor/editor_help.cpp327
-rw-r--r--editor/editor_help.h2
-rw-r--r--editor/editor_help_search.cpp187
-rw-r--r--editor/editor_help_search.h3
-rw-r--r--editor/editor_inspector.cpp335
-rw-r--r--editor/editor_inspector.h1
-rw-r--r--editor/editor_layouts_dialog.cpp19
-rw-r--r--editor/editor_layouts_dialog.h1
-rw-r--r--editor/editor_log.cpp16
-rw-r--r--editor/editor_log.h1
-rw-r--r--editor/editor_node.cpp786
-rw-r--r--editor/editor_node.h13
-rw-r--r--editor/editor_path.cpp53
-rw-r--r--editor/editor_path.h1
-rw-r--r--editor/editor_plugin.cpp106
-rw-r--r--editor/editor_plugin.h14
-rw-r--r--editor/editor_plugin_settings.cpp13
-rw-r--r--editor/editor_plugin_settings.h1
-rw-r--r--editor/editor_properties.cpp445
-rw-r--r--editor/editor_properties.h3
-rw-r--r--editor/editor_properties_array_dict.cpp72
-rw-r--r--editor/editor_properties_array_dict.h2
-rw-r--r--editor/editor_resource_preview.cpp43
-rw-r--r--editor/editor_resource_preview.h2
-rw-r--r--editor/editor_run.cpp15
-rw-r--r--editor/editor_run_native.cpp26
-rw-r--r--editor/editor_run_native.h1
-rw-r--r--editor/editor_run_script.cpp8
-rw-r--r--editor/editor_run_script.h1
-rw-r--r--editor/editor_scale.cpp3
-rw-r--r--editor/editor_sectioned_inspector.cpp80
-rw-r--r--editor/editor_sectioned_inspector.h3
-rw-r--r--editor/editor_settings.cpp179
-rw-r--r--editor/editor_settings.h33
-rw-r--r--editor/editor_spin_slider.cpp39
-rw-r--r--editor/editor_sub_scene.cpp31
-rw-r--r--editor/editor_sub_scene.h1
-rw-r--r--editor/editor_themes.cpp3
-rw-r--r--editor/editor_vcs_interface.cpp26
-rw-r--r--editor/editor_vcs_interface.h1
-rw-r--r--editor/export_template_manager.cpp24
-rw-r--r--editor/fileserver/editor_file_server.cpp19
-rw-r--r--editor/fileserver/editor_file_server.h2
-rw-r--r--editor/filesystem_dock.cpp150
-rw-r--r--editor/filesystem_dock.h6
-rw-r--r--editor/find_in_files.cpp68
-rw-r--r--editor/groups_editor.cpp34
-rw-r--r--editor/groups_editor.h2
-rw-r--r--editor/icons/CameraEffects.svg1
-rw-r--r--editor/icons/Cubemap.svg (renamed from editor/icons/CubeMap.svg)0
-rw-r--r--editor/icons/CubemapArray.svg1
-rw-r--r--editor/icons/LightmapProbe.svg1
-rw-r--r--editor/icons/PanoramaSky.svg1
-rw-r--r--editor/icons/PanoramaSkyMaterial.svg1
-rw-r--r--editor/icons/PhysicalSkyMaterial.svg1
-rw-r--r--editor/icons/ProceduralSky.svg1
-rw-r--r--editor/icons/ProceduralSkyMaterial.svg1
-rw-r--r--editor/icons/RootMotionView.svg1
-rw-r--r--editor/icons/SCsub9
-rw-r--r--editor/icons/ShaderGlobalsOverride.svg1
-rw-r--r--editor/import/collada.cpp611
-rw-r--r--editor/import/collada.h237
-rw-r--r--editor/import/editor_import_collada.cpp306
-rw-r--r--editor/import/editor_import_collada.h1
-rw-r--r--editor/import/editor_import_plugin.cpp3
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp381
-rw-r--r--editor/import/editor_scene_importer_gltf.h150
-rw-r--r--editor/import/resource_importer_bitmask.cpp15
-rw-r--r--editor/import/resource_importer_csv.cpp8
-rw-r--r--editor/import/resource_importer_csv_translation.cpp13
-rw-r--r--editor/import/resource_importer_image.cpp9
-rw-r--r--editor/import/resource_importer_layered_texture.cpp26
-rw-r--r--editor/import/resource_importer_obj.cpp41
-rw-r--r--editor/import/resource_importer_obj.h1
-rw-r--r--editor/import/resource_importer_scene.cpp278
-rw-r--r--editor/import/resource_importer_scene.h2
-rw-r--r--editor/import/resource_importer_shader_file.cpp10
-rw-r--r--editor/import/resource_importer_texture.cpp58
-rw-r--r--editor/import/resource_importer_texture.h2
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp31
-rw-r--r--editor/import/resource_importer_wav.cpp37
-rw-r--r--editor/import/resource_importer_wav.h20
-rw-r--r--editor/import_dock.cpp45
-rw-r--r--editor/inspector_dock.cpp45
-rw-r--r--editor/inspector_dock.h1
-rw-r--r--editor/multi_node_edit.cpp41
-rw-r--r--editor/multi_node_edit.h1
-rw-r--r--editor/node_3d_editor_gizmos.cpp493
-rw-r--r--editor/node_3d_editor_gizmos.h23
-rw-r--r--editor/node_dock.cpp11
-rw-r--r--editor/node_dock.h1
-rw-r--r--editor/pane_drag.cpp15
-rw-r--r--editor/pane_drag.h1
-rw-r--r--editor/plugin_config_dialog.cpp4
-rw-r--r--editor/plugin_config_dialog.h1
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp184
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.h25
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp30
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.h1
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp59
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.h1
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp61
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h1
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp268
-rw-r--r--editor/plugins/animation_player_editor_plugin.h3
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp92
-rw-r--r--editor/plugins/animation_state_machine_editor.h1
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp24
-rw-r--r--editor/plugins/animation_tree_editor_plugin.h2
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp103
-rw-r--r--editor/plugins/asset_library_editor_plugin.h5
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp23
-rw-r--r--editor/plugins/audio_stream_editor_plugin.h2
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.cpp12
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.h1
-rw-r--r--editor/plugins/camera_3d_editor_plugin.cpp14
-rw-r--r--editor/plugins/camera_3d_editor_plugin.h2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp522
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h29
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.h2
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.cpp93
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.h2
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp27
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp26
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.h1
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.cpp13
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.h2
-rw-r--r--editor/plugins/curve_editor_plugin.cpp78
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp34
-rw-r--r--editor/plugins/debugger_editor_plugin.h1
-rw-r--r--editor/plugins/editor_preview_plugins.cpp91
-rw-r--r--editor/plugins/editor_preview_plugins.h4
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp12
-rw-r--r--editor/plugins/gi_probe_editor_plugin.h1
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.cpp42
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.h1
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp65
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.h3
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp9
-rw-r--r--editor/plugins/gradient_editor_plugin.h1
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp103
-rw-r--r--editor/plugins/item_list_editor_plugin.h6
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp30
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.h2
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/line_2d_editor_plugin.h2
-rw-r--r--editor/plugins/material_editor_plugin.cpp44
-rw-r--r--editor/plugins/material_editor_plugin.h2
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp16
-rw-r--r--editor/plugins/mesh_editor_plugin.h2
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.cpp53
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.h2
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp61
-rw-r--r--editor/plugins/mesh_library_editor_plugin.h2
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp44
-rw-r--r--editor/plugins/multimesh_editor_plugin.h2
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp25
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h2
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp1176
-rw-r--r--editor/plugins/node_3d_editor_plugin.h17
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp88
-rw-r--r--editor/plugins/path_2d_editor_plugin.h2
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp117
-rw-r--r--editor/plugins/path_3d_editor_plugin.h3
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.cpp11
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.h6
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp166
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h2
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp66
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h2
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp18
-rw-r--r--editor/plugins/script_editor_plugin.cpp423
-rw-r--r--editor/plugins/script_editor_plugin.h5
-rw-r--r--editor/plugins/script_text_editor.cpp253
-rw-r--r--editor/plugins/script_text_editor.h2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp77
-rw-r--r--editor/plugins/shader_editor_plugin.h3
-rw-r--r--editor/plugins/shader_file_editor_plugin.cpp17
-rw-r--r--editor/plugins/shader_file_editor_plugin.h2
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.cpp10
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.h2
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp561
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h154
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.cpp19
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.h1
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.cpp56
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.h2
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp162
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h2
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp10
-rw-r--r--editor/plugins/style_box_editor_plugin.h2
-rw-r--r--editor/plugins/text_editor.cpp64
-rw-r--r--editor/plugins/text_editor.h1
-rw-r--r--editor/plugins/texture_editor_plugin.cpp26
-rw-r--r--editor/plugins/texture_editor_plugin.h2
-rw-r--r--editor/plugins/texture_layered_editor_plugin.cpp28
-rw-r--r--editor/plugins/texture_layered_editor_plugin.h8
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp208
-rw-r--r--editor/plugins/texture_region_editor_plugin.h1
-rw-r--r--editor/plugins/theme_editor_plugin.cpp67
-rw-r--r--editor/plugins/theme_editor_plugin.h2
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp373
-rw-r--r--editor/plugins/tile_map_editor_plugin.h32
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp296
-rw-r--r--editor/plugins/tile_set_editor_plugin.h4
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp58
-rw-r--r--editor/plugins/version_control_editor_plugin.h1
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp203
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h5
-rw-r--r--editor/progress_dialog.cpp37
-rw-r--r--editor/progress_dialog.h4
-rw-r--r--editor/project_export.cpp194
-rw-r--r--editor/project_export.h1
-rw-r--r--editor/project_manager.cpp176
-rw-r--r--editor/project_manager.h2
-rw-r--r--editor/project_settings_editor.cpp244
-rw-r--r--editor/project_settings_editor.h1
-rw-r--r--editor/property_editor.cpp342
-rw-r--r--editor/property_editor.h4
-rw-r--r--editor/property_selector.cpp99
-rw-r--r--editor/pvrtc_compress.cpp13
-rw-r--r--editor/quick_open.cpp51
-rw-r--r--editor/quick_open.h1
-rw-r--r--editor/rename_dialog.cpp28
-rw-r--r--editor/rename_dialog.h5
-rw-r--r--editor/reparent_dialog.cpp10
-rw-r--r--editor/reparent_dialog.h1
-rw-r--r--editor/run_settings_dialog.cpp14
-rw-r--r--editor/run_settings_dialog.h1
-rw-r--r--editor/scene_tree_dock.cpp486
-rw-r--r--editor/scene_tree_dock.h1
-rw-r--r--editor/scene_tree_editor.cpp273
-rw-r--r--editor/scene_tree_editor.h2
-rw-r--r--editor/script_create_dialog.cpp76
-rw-r--r--editor/settings_config_dialog.cpp52
-rw-r--r--editor/settings_config_dialog.h1
-rw-r--r--editor/shader_globals_editor.cpp7
-rw-r--r--editor/shader_globals_editor.h1
-rw-r--r--editor/translations/af.po110
-rw-r--r--editor/translations/ar.po842
-rw-r--r--editor/translations/bg.po111
-rw-r--r--editor/translations/bn.po129
-rw-r--r--editor/translations/ca.po370
-rw-r--r--editor/translations/cs.po208
-rw-r--r--editor/translations/da.po119
-rw-r--r--editor/translations/de.po319
-rw-r--r--editor/translations/de_CH.po12956
-rw-r--r--editor/translations/editor.pot93
-rw-r--r--editor/translations/el.po142
-rw-r--r--editor/translations/eo.po129
-rw-r--r--editor/translations/es.po183
-rw-r--r--editor/translations/es_AR.po158
-rw-r--r--editor/translations/et.po572
-rw-r--r--editor/translations/eu.po739
-rw-r--r--editor/translations/fa.po115
-rw-r--r--editor/translations/fi.po165
-rw-r--r--editor/translations/fil.po93
-rw-r--r--editor/translations/fr.po333
-rw-r--r--editor/translations/ga.po104
-rw-r--r--editor/translations/he.po211
-rw-r--r--editor/translations/hi.po119
-rw-r--r--editor/translations/hr.po99
-rw-r--r--editor/translations/hu.po128
-rw-r--r--editor/translations/id.po182
-rw-r--r--editor/translations/is.po93
-rw-r--r--editor/translations/it.po404
-rw-r--r--editor/translations/ja.po172
-rw-r--r--editor/translations/ka.po105
-rw-r--r--editor/translations/ko.po154
-rw-r--r--editor/translations/lt.po105
-rw-r--r--editor/translations/lv.po1025
-rw-r--r--editor/translations/mi.po93
-rw-r--r--editor/translations/ml.po93
-rw-r--r--editor/translations/mr.po93
-rw-r--r--editor/translations/ms.po93
-rw-r--r--editor/translations/nb.po156
-rw-r--r--editor/translations/nl.po147
-rw-r--r--editor/translations/or.po93
-rw-r--r--editor/translations/pl.po148
-rw-r--r--editor/translations/pr.po104
-rw-r--r--editor/translations/pt_BR.po206
-rw-r--r--editor/translations/pt_PT.po170
-rw-r--r--editor/translations/ro.po121
-rw-r--r--editor/translations/ru.po184
-rw-r--r--editor/translations/si.po96
-rw-r--r--editor/translations/sk.po751
-rw-r--r--editor/translations/sl.po127
-rw-r--r--editor/translations/sq.po117
-rw-r--r--editor/translations/sr_Cyrl.po3470
-rw-r--r--editor/translations/sr_Latn.po100
-rw-r--r--editor/translations/sv.po268
-rw-r--r--editor/translations/ta.po93
-rw-r--r--editor/translations/te.po93
-rw-r--r--editor/translations/th.po206
-rw-r--r--editor/translations/tr.po219
-rw-r--r--editor/translations/uk.po211
-rw-r--r--editor/translations/ur_PK.po107
-rw-r--r--editor/translations/vi.po115
-rw-r--r--editor/translations/zh_CN.po222
-rw-r--r--editor/translations/zh_HK.po115
-rw-r--r--editor/translations/zh_TW.po5883
-rw-r--r--gles_builders.py10
-rw-r--r--main/main.cpp300
-rw-r--r--main/main.h1
-rw-r--r--main/main_timer_sync.cpp26
-rw-r--r--main/main_timer_sync.h10
-rw-r--r--main/performance.cpp9
-rw-r--r--main/performance.h1
-rw-r--r--main/tests/test_astar.cpp79
-rw-r--r--main/tests/test_basis.cpp325
-rw-r--r--main/tests/test_basis.h (renamed from core/path_remap.h)14
-rw-r--r--main/tests/test_class_db.cpp882
-rw-r--r--main/tests/test_class_db.h (renamed from core/math/audio_frame.cpp)15
-rw-r--r--main/tests/test_gdscript.cpp201
-rw-r--r--main/tests/test_gui.cpp5
-rw-r--r--main/tests/test_main.cpp30
-rw-r--r--main/tests/test_math.cpp41
-rw-r--r--main/tests/test_oa_hash_map.cpp150
-rw-r--r--main/tests/test_ordered_hash_map.cpp10
-rw-r--r--main/tests/test_physics_2d.cpp35
-rw-r--r--main/tests/test_physics_3d.cpp44
-rw-r--r--main/tests/test_render.cpp18
-rw-r--r--main/tests/test_shader_lang.cpp39
-rw-r--r--main/tests/test_string.cpp128
-rw-r--r--methods.py228
-rw-r--r--misc/scons/compilation_db.py (renamed from misc/scons/site_tools/compilation_db.py)0
-rw-r--r--modules/SCsub13
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp40
-rw-r--r--modules/assimp/import_state.h4
-rw-r--r--modules/assimp/import_utils.h2
-rw-r--r--modules/assimp/register_types.cpp1
-rw-r--r--modules/basis_universal/register_types.cpp8
-rw-r--r--modules/bmp/image_loader_bmp.cpp11
-rw-r--r--modules/bullet/area_bullet.cpp33
-rw-r--r--modules/bullet/area_bullet.h34
-rw-r--r--modules/bullet/btRayShape.cpp8
-rw-r--r--modules/bullet/btRayShape.h1
-rw-r--r--modules/bullet/bullet_physics_server.cpp49
-rw-r--r--modules/bullet/bullet_physics_server.h5
-rw-r--r--modules/bullet/collision_object_bullet.cpp43
-rw-r--r--modules/bullet/collision_object_bullet.h38
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp2
-rw-r--r--modules/bullet/constraint_bullet.cpp5
-rw-r--r--modules/bullet/constraint_bullet.h7
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp1
-rw-r--r--modules/bullet/godot_collision_configuration.cpp22
-rw-r--r--modules/bullet/godot_motion_state.h1
-rw-r--r--modules/bullet/godot_ray_world_algorithm.cpp12
-rw-r--r--modules/bullet/godot_ray_world_algorithm.h8
-rw-r--r--modules/bullet/godot_result_callbacks.cpp67
-rw-r--r--modules/bullet/godot_result_callbacks.h39
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp5
-rw-r--r--modules/bullet/joint_bullet.h1
-rw-r--r--modules/bullet/pin_joint_bullet.cpp1
-rw-r--r--modules/bullet/rigid_body_bullet.cpp105
-rw-r--r--modules/bullet/rigid_body_bullet.h43
-rw-r--r--modules/bullet/shape_bullet.cpp33
-rw-r--r--modules/bullet/shape_bullet.h19
-rw-r--r--modules/bullet/slider_joint_bullet.cpp3
-rw-r--r--modules/bullet/soft_body_bullet.cpp42
-rw-r--r--modules/bullet/soft_body_bullet.h23
-rw-r--r--modules/bullet/space_bullet.cpp94
-rw-r--r--modules/bullet/space_bullet.h57
-rw-r--r--modules/camera/camera_win.cpp16
-rw-r--r--modules/camera/camera_win.h2
-rw-r--r--modules/csg/csg.cpp256
-rw-r--r--modules/csg/csg.h4
-rw-r--r--modules/csg/csg_gizmos.cpp62
-rw-r--r--modules/csg/csg_gizmos.h1
-rw-r--r--modules/csg/csg_shape.cpp192
-rw-r--r--modules/csg/csg_shape.h5
-rw-r--r--modules/csg/register_types.cpp1
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp18
-rw-r--r--modules/cvtt/register_types.cpp1
-rw-r--r--modules/dds/register_types.cpp2
-rw-r--r--modules/dds/texture_loader_dds.cpp88
-rw-r--r--modules/denoise/config.py8
-rw-r--r--modules/denoise/denoise_wrapper.cpp30
-rw-r--r--modules/denoise/denoise_wrapper.h30
-rw-r--r--modules/denoise/lightmap_denoiser.cpp1
-rw-r--r--modules/denoise/lightmap_denoiser.h1
-rw-r--r--modules/denoise/register_types.cpp1
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp100
-rw-r--r--modules/enet/networked_multiplayer_enet.h2
-rw-r--r--modules/enet/register_types.cpp5
-rw-r--r--modules/etc/image_etc.cpp11
-rw-r--r--modules/etc/register_types.cpp2
-rw-r--r--modules/etc/texture_loader_pkm.cpp19
-rw-r--r--modules/gdnative/gdnative.cpp23
-rw-r--r--modules/gdnative/gdnative/aabb.cpp2
-rw-r--r--modules/gdnative/gdnative/array.cpp34
-rw-r--r--modules/gdnative/gdnative/basis.cpp2
-rw-r--r--modules/gdnative/gdnative/callable.cpp252
-rw-r--r--modules/gdnative/gdnative/color.cpp4
-rw-r--r--modules/gdnative/gdnative/dictionary.cpp2
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp15
-rw-r--r--modules/gdnative/gdnative/node_path.cpp2
-rw-r--r--modules/gdnative/gdnative/packed_arrays.cpp (renamed from modules/gdnative/gdnative/pool_arrays.cpp)416
-rw-r--r--modules/gdnative/gdnative/plane.cpp3
-rw-r--r--modules/gdnative/gdnative/quat.cpp3
-rw-r--r--modules/gdnative/gdnative/rect2.cpp156
-rw-r--r--modules/gdnative/gdnative/rid.cpp2
-rw-r--r--modules/gdnative/gdnative/string.cpp5
-rw-r--r--modules/gdnative/gdnative/string_name.cpp2
-rw-r--r--modules/gdnative/gdnative/transform.cpp2
-rw-r--r--modules/gdnative/gdnative/transform2d.cpp2
-rw-r--r--modules/gdnative/gdnative/variant.cpp133
-rw-r--r--modules/gdnative/gdnative/vector2.cpp152
-rw-r--r--modules/gdnative/gdnative/vector3.cpp147
-rw-r--r--modules/gdnative/gdnative_api.json5981
-rw-r--r--modules/gdnative/gdnative_builders.py11
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp39
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.h2
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.cpp18
-rw-r--r--modules/gdnative/include/gdnative/array.h8
-rw-r--r--modules/gdnative/include/gdnative/callable.h126
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h18
-rw-r--r--modules/gdnative/include/gdnative/packed_arrays.h (renamed from modules/gdnative/include/gdnative/pool_arrays.h)207
-rw-r--r--modules/gdnative/include/gdnative/rect2.h54
-rw-r--r--modules/gdnative/include/gdnative/rid.h2
-rw-r--r--modules/gdnative/include/gdnative/variant.h40
-rw-r--r--modules/gdnative/include/gdnative/vector2.h55
-rw-r--r--modules/gdnative/include/gdnative/vector3.h53
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h81
-rw-r--r--modules/gdnative/include/net/godot_net.h1
-rw-r--r--modules/gdnative/include/videodecoder/godot_videodecoder.h2
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp7
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp32
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp205
-rw-r--r--modules/gdnative/nativescript/nativescript.h45
-rw-r--r--modules/gdnative/nativescript/register_types.cpp1
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp1
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.cpp1
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.h1
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.cpp11
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp43
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h11
-rw-r--r--modules/gdnative/register_types.cpp10
-rw-r--r--modules/gdnative/videodecoder/register_types.cpp2
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp43
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h47
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.cpp8
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp10
-rw-r--r--modules/gdnavigation/gd_navigation_server.h2
-rw-r--r--modules/gdnavigation/nav_map.cpp59
-rw-r--r--modules/gdnavigation/nav_map.h19
-rw-r--r--modules/gdnavigation/nav_region.cpp13
-rw-r--r--modules/gdnavigation/nav_region.h6
-rw-r--r--modules/gdnavigation/nav_utils.h46
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.cpp14
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.h1
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp63
-rw-r--r--modules/gdnavigation/rvo_agent.cpp3
-rw-r--r--modules/gdnavigation/rvo_agent.h2
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp9
-rw-r--r--modules/gdscript/gdscript.cpp318
-rw-r--r--modules/gdscript/gdscript.h39
-rw-r--r--modules/gdscript/gdscript_compiler.cpp403
-rw-r--r--modules/gdscript/gdscript_compiler.h13
-rw-r--r--modules/gdscript/gdscript_editor.cpp162
-rw-r--r--modules/gdscript/gdscript_function.cpp176
-rw-r--r--modules/gdscript/gdscript_function.h22
-rw-r--r--modules/gdscript/gdscript_functions.cpp128
-rw-r--r--modules/gdscript/gdscript_parser.cpp687
-rw-r--r--modules/gdscript/gdscript_parser.h149
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp131
-rw-r--r--modules/gdscript/gdscript_tokenizer.h4
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.cpp34
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.h1
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp28
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.h6
-rw-r--r--modules/gdscript/language_server/gdscript_language_server.cpp2
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp18
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp43
-rw-r--r--modules/gdscript/language_server/lsp.hpp50
-rw-r--r--modules/gdscript/register_types.cpp27
-rw-r--r--modules/glslang/register_types.cpp22
-rw-r--r--modules/gridmap/grid_map.cpp160
-rw-r--r--modules/gridmap/grid_map.h9
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp228
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h5
-rw-r--r--modules/gridmap/register_types.cpp1
-rw-r--r--modules/hdr/image_loader_hdr.cpp13
-rw-r--r--modules/hdr/image_loader_hdr.h1
-rw-r--r--modules/hdr/register_types.cpp2
-rw-r--r--modules/jpg/image_loader_jpegd.cpp18
-rw-r--r--modules/jpg/image_loader_jpegd.h1
-rw-r--r--modules/jpg/register_types.cpp2
-rw-r--r--modules/jsonrpc/jsonrpc.cpp6
-rw-r--r--modules/lightmapper_rd/lightmapper_rd.cpp88
-rw-r--r--modules/lightmapper_rd/lightmapper_rd.h31
-rw-r--r--modules/lightmapper_rd/lm_blendseams.glsl55
-rw-r--r--modules/lightmapper_rd/lm_compute.glsl27
-rw-r--r--modules/lightmapper_rd/lm_raster.glsl23
-rw-r--r--modules/lightmapper_rd/register_types.cpp1
-rw-r--r--modules/mbedtls/crypto_mbedtls.cpp1
-rw-r--r--modules/mbedtls/crypto_mbedtls.h3
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.cpp2
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.h1
-rw-r--r--modules/mbedtls/packet_peer_mbed_dtls.cpp31
-rw-r--r--[-rwxr-xr-x]modules/mbedtls/register_types.cpp2
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.cpp19
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.h2
-rw-r--r--modules/mbedtls/stream_peer_mbedtls.cpp32
-rw-r--r--modules/mobile_vr/mobile_vr_interface.cpp24
-rw-r--r--modules/mobile_vr/mobile_vr_interface.h2
-rw-r--r--modules/mono/SCsub2
-rw-r--r--modules/mono/build_scripts/godot_tools_build.py4
-rw-r--r--modules/mono/build_scripts/mono_configure.py11
-rw-r--r--modules/mono/class_db_api_json.cpp6
-rw-r--r--modules/mono/config.py1
-rw-r--r--modules/mono/csharp_script.cpp192
-rw-r--r--modules/mono/csharp_script.h22
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs23
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs48
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Requests/Requests.cs13
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj12
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs270
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs15
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.sln6
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs35
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs11
-rw-r--r--modules/mono/editor/bindings_generator.cpp524
-rw-r--r--modules/mono/editor/bindings_generator.h234
-rw-r--r--modules/mono/editor/csharp_project.cpp1
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp1
-rw-r--r--modules/mono/editor/godotsharp_export.cpp2
-rw-r--r--modules/mono/editor/script_class_parser.cpp9
-rw-r--r--modules/mono/editor/script_class_parser.h1
-rw-r--r--modules/mono/glue/arguments_vector.h1
-rw-r--r--modules/mono/glue/gd_glue.cpp1
-rw-r--r--modules/mono/godotsharp_dirs.cpp1
-rw-r--r--modules/mono/mono_gc_handle.cpp2
-rw-r--r--modules/mono/mono_gc_handle.h10
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp48
-rw-r--r--modules/mono/mono_gd/gd_mono.h23
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.cpp25
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.h11
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_class.cpp23
-rw-r--r--modules/mono/mono_gd/gd_mono_field.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp9
-rw-r--r--modules/mono/mono_gd/gd_mono_log.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono_method.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono_method.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_method_thunk.h28
-rw-r--r--modules/mono/mono_gd/gd_mono_property.h1
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h3
-rw-r--r--modules/mono/mono_gd/managed_type.h9
-rw-r--r--[-rwxr-xr-x]modules/mono/mono_gd/support/android_support.cpp0
-rw-r--r--[-rwxr-xr-x]modules/mono/mono_gd/support/ios_support.mm0
-rw-r--r--modules/mono/signal_awaiter_utils.cpp1
-rw-r--r--modules/mono/utils/mono_reg_utils.cpp8
-rw-r--r--modules/mono/utils/mono_reg_utils.h1
-rw-r--r--modules/mono/utils/osx_utils.cpp1
-rw-r--r--modules/mono/utils/string_utils.cpp2
-rw-r--r--modules/opensimplex/noise_texture.cpp35
-rw-r--r--modules/opensimplex/open_simplex_noise.cpp26
-rw-r--r--modules/opensimplex/register_types.cpp1
-rw-r--r--modules/opus/config.py2
-rw-r--r--modules/pvr/register_types.cpp2
-rw-r--r--modules/pvr/texture_loader_pvr.cpp88
-rw-r--r--modules/regex/SCsub2
-rw-r--r--modules/regex/doc_classes/RegEx.xml3
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml2
-rw-r--r--modules/regex/regex.cpp99
-rw-r--r--modules/regex/regex.h2
-rw-r--r--modules/regex/register_types.cpp1
-rw-r--r--modules/squish/image_compress_squish.cpp17
-rw-r--r--modules/squish/register_types.cpp1
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp25
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h2
-rw-r--r--modules/stb_vorbis/register_types.cpp1
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp10
-rw-r--r--modules/svg/image_loader_svg.cpp8
-rw-r--r--modules/svg/image_loader_svg.h1
-rw-r--r--modules/svg/register_types.cpp2
-rw-r--r--modules/tga/image_loader_tga.cpp15
-rw-r--r--modules/tga/register_types.cpp2
-rw-r--r--modules/theora/config.py2
-rw-r--r--modules/theora/register_types.cpp2
-rw-r--r--modules/theora/video_stream_theora.cpp83
-rw-r--r--modules/theora/video_stream_theora.h4
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp10
-rw-r--r--modules/tinyexr/image_loader_tinyexr.h1
-rw-r--r--modules/tinyexr/image_saver_tinyexr.cpp5
-rw-r--r--modules/tinyexr/register_types.cpp2
-rw-r--r--modules/upnp/register_types.cpp1
-rw-r--r--modules/upnp/upnp.h1
-rw-r--r--modules/upnp/upnp_device.h1
-rw-r--r--modules/vhacd/register_types.cpp1
-rw-r--r--modules/visual_script/register_types.cpp5
-rw-r--r--modules/visual_script/visual_script.cpp402
-rw-r--r--modules/visual_script/visual_script.h35
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp256
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h1
-rw-r--r--modules/visual_script/visual_script_editor.cpp515
-rw-r--r--modules/visual_script/visual_script_editor.h1
-rw-r--r--modules/visual_script/visual_script_expression.cpp184
-rw-r--r--modules/visual_script/visual_script_expression.h12
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp187
-rw-r--r--modules/visual_script/visual_script_flow_control.h7
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp448
-rw-r--r--modules/visual_script/visual_script_func_nodes.h4
-rw-r--r--modules/visual_script/visual_script_nodes.cpp693
-rw-r--r--modules/visual_script/visual_script_nodes.h28
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp98
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp136
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h2
-rw-r--r--modules/vorbis/config.py2
-rw-r--r--modules/webm/config.py5
-rw-r--r--modules/webm/register_types.cpp2
-rw-r--r--modules/webm/video_stream_webm.cpp148
-rw-r--r--modules/webm/video_stream_webm.h30
-rw-r--r--modules/webp/image_loader_webp.cpp14
-rw-r--r--modules/webp/image_loader_webp.h1
-rw-r--r--modules/webp/register_types.cpp2
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnection.xml2
-rw-r--r--modules/webrtc/webrtc_data_channel_js.cpp1
-rw-r--r--modules/webrtc/webrtc_multiplayer.cpp34
-rw-r--r--modules/webrtc/webrtc_multiplayer.h5
-rw-r--r--modules/webrtc/webrtc_peer_connection.cpp5
-rw-r--r--modules/webrtc/webrtc_peer_connection_gdnative.cpp1
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.h1
-rw-r--r--modules/websocket/editor_debugger_server_websocket.cpp11
-rw-r--r--modules/websocket/editor_debugger_server_websocket.h7
-rw-r--r--modules/websocket/emws_client.cpp7
-rw-r--r--modules/websocket/emws_client.h1
-rw-r--r--modules/websocket/emws_peer.cpp12
-rw-r--r--modules/websocket/emws_peer.h1
-rw-r--r--modules/websocket/emws_server.cpp3
-rw-r--r--modules/websocket/emws_server.h1
-rw-r--r--modules/websocket/packet_buffer.h1
-rw-r--r--modules/websocket/register_types.cpp9
-rw-r--r--modules/websocket/remote_debugger_peer_websocket.cpp15
-rw-r--r--modules/websocket/remote_debugger_peer_websocket.h7
-rw-r--r--modules/websocket/websocket_client.cpp14
-rw-r--r--modules/websocket/websocket_client.h1
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp50
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h1
-rw-r--r--modules/websocket/websocket_peer.h1
-rw-r--r--modules/websocket/websocket_server.cpp9
-rw-r--r--modules/websocket/websocket_server.h1
-rw-r--r--modules/websocket/wsl_client.cpp34
-rw-r--r--modules/websocket/wsl_client.h1
-rw-r--r--modules/websocket/wsl_peer.cpp32
-rw-r--r--modules/websocket/wsl_peer.h1
-rw-r--r--modules/websocket/wsl_server.cpp46
-rw-r--r--modules/websocket/wsl_server.h2
-rw-r--r--modules/xatlas_unwrap/register_types.cpp4
-rw-r--r--platform/android/android_keys_utils.cpp2
-rw-r--r--platform/android/android_keys_utils.h1
-rw-r--r--platform/android/api/api.cpp3
-rw-r--r--platform/android/api/java_class_wrapper.h6
-rw-r--r--platform/android/api/jni_singleton.h19
-rw-r--r--platform/android/audio_driver_jandroid.cpp20
-rw-r--r--platform/android/audio_driver_jandroid.h1
-rw-r--r--platform/android/audio_driver_opensl.cpp19
-rw-r--r--platform/android/audio_driver_opensl.h1
-rw-r--r--platform/android/dir_access_jandroid.cpp20
-rw-r--r--platform/android/dir_access_jandroid.h1
-rw-r--r--platform/android/display_server_android.cpp29
-rw-r--r--platform/android/display_server_android.h5
-rw-r--r--platform/android/export/export.cpp383
-rw-r--r--platform/android/file_access_android.cpp16
-rw-r--r--platform/android/file_access_android.h1
-rw-r--r--platform/android/file_access_jandroid.cpp17
-rw-r--r--platform/android/file_access_jandroid.h1
-rw-r--r--platform/android/java/app/AndroidManifest.xml7
-rw-r--r--platform/android/java/app/build.gradle34
-rw-r--r--platform/android/java/app/config.gradle78
-rw-r--r--platform/android/java/build.gradle5
-rw-r--r--platform/android/java/gradle.properties3
-rw-r--r--platform/android/java/lib/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java4
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Dictionary.java6
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.java31
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java3
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotIO.java39
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotLib.java12
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java3
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java39
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java4
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java10
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java25
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java16
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/plugin/SignalInfo.java4
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java4
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt11
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrConfigChooser.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrContextFactory.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrWindowSurfaceFactory.java1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularConfigChooser.java3
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java1
-rw-r--r--platform/android/java/plugins/godotpayment/build.gradle2
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl281
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ConsumeTask.java118
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java313
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/HandlePurchaseTask.java94
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsCache.java71
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsManager.java408
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PurchaseTask.java119
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ReleaseAllConsumablesTask.java144
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ValidateTask.java144
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/CustomSSLSocketFactory.java72
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java66
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/HttpRequester.java231
-rw-r--r--platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/RequestParams.java85
-rw-r--r--platform/android/java_class_wrapper.cpp94
-rw-r--r--platform/android/java_godot_io_wrapper.cpp6
-rw-r--r--platform/android/java_godot_io_wrapper.h2
-rw-r--r--platform/android/java_godot_lib_jni.cpp37
-rw-r--r--platform/android/java_godot_lib_jni.h6
-rw-r--r--platform/android/jni_utils.cpp34
-rw-r--r--platform/android/jni_utils.h1
-rw-r--r--platform/android/net_socket_android.cpp6
-rw-r--r--platform/android/net_socket_android.h7
-rw-r--r--platform/android/os_android.cpp17
-rw-r--r--platform/android/plugin/godot_plugin_config.h267
-rw-r--r--platform/android/plugin/godot_plugin_jni.cpp15
-rw-r--r--platform/android/thread_jandroid.cpp11
-rw-r--r--platform/android/thread_jandroid.h1
-rw-r--r--platform/android/vulkan/vulkan_context_android.h1
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp4
-rw-r--r--platform/haiku/key_mapping_haiku.h2
-rw-r--r--platform/haiku/os_haiku.cpp4
-rw-r--r--platform/iphone/app_delegate.mm4
-rw-r--r--platform/iphone/export/export.cpp57
-rw-r--r--platform/iphone/game_center.h1
-rw-r--r--platform/iphone/game_center.mm15
-rw-r--r--platform/iphone/gl_view.mm21
-rw-r--r--platform/iphone/godot_iphone.cpp2
-rw-r--r--platform/iphone/icloud.h1
-rw-r--r--platform/iphone/icloud.mm6
-rw-r--r--platform/iphone/in_app_store.h1
-rw-r--r--platform/iphone/in_app_store.mm17
-rw-r--r--platform/iphone/ios.h1
-rw-r--r--platform/iphone/ios.mm3
-rw-r--r--platform/iphone/os_iphone.cpp44
-rw-r--r--platform/iphone/os_iphone.h4
-rw-r--r--platform/iphone/view_controller.mm4
-rw-r--r--platform/iphone/vulkan_context_iphone.h1
-rw-r--r--platform/iphone/vulkan_context_iphone.mm1
-rw-r--r--platform/javascript/api/api.cpp6
-rw-r--r--platform/javascript/audio_driver_javascript.cpp62
-rw-r--r--platform/javascript/audio_driver_javascript.h2
-rw-r--r--platform/javascript/display_server_javascript.cpp76
-rw-r--r--platform/javascript/display_server_javascript.h1
-rw-r--r--platform/javascript/dom_keys.inc588
-rw-r--r--platform/javascript/export/export.cpp49
-rw-r--r--platform/javascript/http_client.h.inc16
-rw-r--r--platform/javascript/http_client_javascript.cpp32
-rw-r--r--platform/javascript/javascript_eval.cpp2
-rw-r--r--platform/javascript/javascript_main.cpp15
-rw-r--r--platform/javascript/os_javascript.cpp27
-rw-r--r--platform/javascript/os_javascript.h1
-rw-r--r--platform/linuxbsd/context_gl_x11.cpp10
-rw-r--r--platform/linuxbsd/context_gl_x11.h1
-rw-r--r--platform/linuxbsd/crash_handler_linuxbsd.cpp9
-rw-r--r--platform/linuxbsd/crash_handler_linuxbsd.h1
-rw-r--r--platform/linuxbsd/display_server_x11.cpp398
-rw-r--r--platform/linuxbsd/display_server_x11.h6
-rw-r--r--platform/linuxbsd/export/export.cpp3
-rw-r--r--platform/linuxbsd/godot_linuxbsd.cpp4
-rw-r--r--platform/linuxbsd/joypad_linux.cpp58
-rw-r--r--platform/linuxbsd/key_mapping_x11.cpp58
-rw-r--r--platform/linuxbsd/key_mapping_x11.h2
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp46
-rw-r--r--platform/linuxbsd/os_linuxbsd.h1
-rw-r--r--platform/linuxbsd/vulkan_context_x11.cpp1
-rw-r--r--platform/linuxbsd/vulkan_context_x11.h1
-rw-r--r--platform/osx/context_gl_osx.h1
-rw-r--r--platform/osx/context_gl_osx.mm11
-rw-r--r--platform/osx/crash_handler_osx.h1
-rw-r--r--platform/osx/dir_access_osx.mm1
-rw-r--r--platform/osx/display_server_osx.h6
-rw-r--r--platform/osx/display_server_osx.mm206
-rw-r--r--platform/osx/export/export.cpp478
-rw-r--r--platform/osx/godot_main_osx.mm1
-rw-r--r--platform/osx/joypad_osx.cpp18
-rw-r--r--platform/osx/joypad_osx.h1
-rw-r--r--platform/osx/os_osx.mm3
-rw-r--r--platform/osx/vulkan_context_osx.h1
-rw-r--r--platform/osx/vulkan_context_osx.mm1
-rw-r--r--platform/server/godot_server.cpp1
-rw-r--r--platform/server/os_server.cpp33
-rw-r--r--platform/server/os_server.h1
-rw-r--r--platform/uwp/app.cpp36
-rw-r--r--platform/uwp/app.h16
-rw-r--r--platform/uwp/context_egl_uwp.cpp10
-rw-r--r--platform/uwp/context_egl_uwp.h1
-rw-r--r--platform/uwp/export/export.cpp167
-rw-r--r--platform/uwp/joypad_uwp.cpp13
-rw-r--r--platform/uwp/joypad_uwp.h2
-rw-r--r--platform/uwp/os_uwp.cpp102
-rw-r--r--platform/uwp/os_uwp.h4
-rw-r--r--platform/uwp/thread_uwp.cpp12
-rw-r--r--platform/uwp/thread_uwp.h9
-rw-r--r--platform/windows/context_gl_windows.cpp11
-rw-r--r--platform/windows/context_gl_windows.h1
-rw-r--r--platform/windows/crash_handler_windows.h1
-rw-r--r--platform/windows/display_server_windows.cpp449
-rw-r--r--platform/windows/display_server_windows.h22
-rw-r--r--platform/windows/export/export.cpp4
-rw-r--r--platform/windows/godot_windows.cpp1
-rw-r--r--platform/windows/joypad_windows.cpp87
-rw-r--r--platform/windows/joypad_windows.h2
-rw-r--r--platform/windows/key_mapping_windows.cpp17
-rw-r--r--platform/windows/key_mapping_windows.h4
-rw-r--r--platform/windows/os_windows.cpp228
-rw-r--r--platform/windows/os_windows.h16
-rw-r--r--platform/windows/vulkan_context_win.cpp1
-rw-r--r--platform/windows/vulkan_context_win.h1
-rw-r--r--platform/windows/windows_terminal_logger.cpp1
-rw-r--r--scene/2d/animated_sprite_2d.cpp167
-rw-r--r--scene/2d/animated_sprite_2d.h18
-rw-r--r--scene/2d/area_2d.cpp131
-rw-r--r--scene/2d/area_2d.h15
-rw-r--r--scene/2d/audio_stream_player_2d.cpp71
-rw-r--r--scene/2d/audio_stream_player_2d.h2
-rw-r--r--scene/2d/back_buffer_copy.cpp14
-rw-r--r--scene/2d/camera_2d.cpp130
-rw-r--r--scene/2d/camera_2d.h1
-rw-r--r--scene/2d/canvas_modulate.cpp12
-rw-r--r--scene/2d/canvas_modulate.h1
-rw-r--r--scene/2d/collision_object_2d.cpp85
-rw-r--r--scene/2d/collision_object_2d.h2
-rw-r--r--scene/2d/collision_polygon_2d.cpp42
-rw-r--r--scene/2d/collision_polygon_2d.h1
-rw-r--r--scene/2d/collision_shape_2d.cpp30
-rw-r--r--scene/2d/collision_shape_2d.h1
-rw-r--r--scene/2d/cpu_particles_2d.cpp150
-rw-r--r--scene/2d/cpu_particles_2d.h1
-rw-r--r--scene/2d/gpu_particles_2d.cpp73
-rw-r--r--scene/2d/joints_2d.cpp105
-rw-r--r--scene/2d/joints_2d.h4
-rw-r--r--scene/2d/light_2d.cpp67
-rw-r--r--scene/2d/light_2d.h1
-rw-r--r--scene/2d/light_occluder_2d.cpp63
-rw-r--r--scene/2d/light_occluder_2d.h1
-rw-r--r--scene/2d/line_2d.cpp25
-rw-r--r--scene/2d/line_2d.h1
-rw-r--r--scene/2d/line_builder.cpp51
-rw-r--r--scene/2d/mesh_instance_2d.cpp12
-rw-r--r--scene/2d/multimesh_instance_2d.cpp12
-rw-r--r--scene/2d/navigation_2d.cpp2
-rw-r--r--scene/2d/navigation_2d.h1
-rw-r--r--scene/2d/navigation_agent_2d.cpp37
-rw-r--r--scene/2d/navigation_agent_2d.h14
-rw-r--r--scene/2d/navigation_obstacle_2d.cpp17
-rw-r--r--scene/2d/navigation_obstacle_2d.h2
-rw-r--r--scene/2d/navigation_region_2d.cpp110
-rw-r--r--scene/2d/navigation_region_2d.h12
-rw-r--r--scene/2d/node_2d.cpp112
-rw-r--r--scene/2d/node_2d.h1
-rw-r--r--scene/2d/parallax_background.cpp47
-rw-r--r--scene/2d/parallax_background.h1
-rw-r--r--scene/2d/parallax_layer.cpp29
-rw-r--r--scene/2d/parallax_layer.h1
-rw-r--r--scene/2d/path_2d.cpp79
-rw-r--r--scene/2d/path_2d.h4
-rw-r--r--scene/2d/physics_body_2d.cpp220
-rw-r--r--scene/2d/physics_body_2d.h12
-rw-r--r--scene/2d/polygon_2d.cpp95
-rw-r--r--scene/2d/polygon_2d.h1
-rw-r--r--scene/2d/position_2d.cpp12
-rw-r--r--scene/2d/position_2d.h1
-rw-r--r--scene/2d/ray_cast_2d.cpp95
-rw-r--r--scene/2d/ray_cast_2d.h1
-rw-r--r--scene/2d/remote_transform_2d.cpp50
-rw-r--r--scene/2d/remote_transform_2d.h1
-rw-r--r--scene/2d/skeleton_2d.cpp47
-rw-r--r--scene/2d/sprite_2d.cpp97
-rw-r--r--scene/2d/sprite_2d.h1
-rw-r--r--scene/2d/tile_map.cpp294
-rw-r--r--scene/2d/tile_map.h4
-rw-r--r--scene/2d/touch_screen_button.cpp105
-rw-r--r--scene/2d/touch_screen_button.h1
-rw-r--r--scene/2d/visibility_notifier_2d.cpp79
-rw-r--r--scene/2d/visibility_notifier_2d.h2
-rw-r--r--scene/2d/y_sort.cpp4
-rw-r--r--scene/3d/area_3d.cpp143
-rw-r--r--scene/3d/area_3d.h15
-rw-r--r--scene/3d/audio_stream_player_3d.cpp115
-rw-r--r--scene/3d/audio_stream_player_3d.h2
-rw-r--r--scene/3d/baked_lightmap.cpp68
-rw-r--r--scene/3d/baked_lightmap.h1
-rw-r--r--scene/3d/bone_attachment_3d.cpp23
-rw-r--r--scene/3d/bone_attachment_3d.h1
-rw-r--r--scene/3d/camera_3d.cpp143
-rw-r--r--scene/3d/camera_3d.h2
-rw-r--r--scene/3d/collision_object_3d.cpp61
-rw-r--r--scene/3d/collision_object_3d.h2
-rw-r--r--scene/3d/collision_polygon_3d.cpp31
-rw-r--r--scene/3d/collision_polygon_3d.h1
-rw-r--r--scene/3d/collision_shape_3d.cpp29
-rw-r--r--scene/3d/collision_shape_3d.h1
-rw-r--r--scene/3d/cpu_particles_3d.cpp148
-rw-r--r--scene/3d/cpu_particles_3d.h1
-rw-r--r--scene/3d/decal.cpp16
-rw-r--r--scene/3d/gi_probe.cpp39
-rw-r--r--scene/3d/gi_probe.h1
-rw-r--r--scene/3d/gpu_particles_3d.cpp82
-rw-r--r--scene/3d/immediate_geometry_3d.cpp20
-rw-r--r--scene/3d/immediate_geometry_3d.h1
-rw-r--r--scene/3d/light_3d.cpp55
-rw-r--r--scene/3d/light_3d.h4
-rw-r--r--scene/3d/lightmap_probe.cpp30
-rw-r--r--scene/3d/lightmap_probe.h30
-rw-r--r--scene/3d/lightmapper.cpp30
-rw-r--r--scene/3d/lightmapper.h30
-rw-r--r--scene/3d/listener_3d.cpp35
-rw-r--r--scene/3d/listener_3d.h1
-rw-r--r--scene/3d/mesh_instance_3d.cpp88
-rw-r--r--scene/3d/mesh_instance_3d.h2
-rw-r--r--scene/3d/multimesh_instance_3d.cpp15
-rw-r--r--scene/3d/navigation_3d.cpp6
-rw-r--r--scene/3d/navigation_3d.h1
-rw-r--r--scene/3d/navigation_agent_3d.cpp37
-rw-r--r--scene/3d/navigation_agent_3d.h16
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp19
-rw-r--r--scene/3d/navigation_obstacle_3d.h2
-rw-r--r--scene/3d/navigation_region_3d.cpp44
-rw-r--r--scene/3d/navigation_region_3d.h9
-rw-r--r--scene/3d/node_3d.cpp154
-rw-r--r--scene/3d/node_3d.h3
-rw-r--r--scene/3d/path_3d.cpp74
-rw-r--r--scene/3d/path_3d.h4
-rw-r--r--scene/3d/physics_body_3d.cpp416
-rw-r--r--scene/3d/physics_body_3d.h182
-rw-r--r--scene/3d/physics_joint_3d.cpp157
-rw-r--r--scene/3d/physics_joint_3d.h8
-rw-r--r--scene/3d/position_3d.h1
-rw-r--r--scene/3d/proximity_group_3d.cpp35
-rw-r--r--scene/3d/proximity_group_3d.h11
-rw-r--r--scene/3d/ray_cast_3d.cpp117
-rw-r--r--scene/3d/ray_cast_3d.h1
-rw-r--r--scene/3d/reflection_probe.cpp34
-rw-r--r--scene/3d/remote_transform_3d.cpp38
-rw-r--r--scene/3d/skeleton_3d.cpp193
-rw-r--r--scene/3d/skeleton_3d.h19
-rw-r--r--scene/3d/skeleton_ik_3d.cpp76
-rw-r--r--scene/3d/skeleton_ik_3d.h54
-rw-r--r--scene/3d/soft_body_3d.cpp90
-rw-r--r--scene/3d/soft_body_3d.h17
-rw-r--r--scene/3d/spring_arm_3d.cpp13
-rw-r--r--scene/3d/spring_arm_3d.h12
-rw-r--r--scene/3d/sprite_3d.cpp222
-rw-r--r--scene/3d/sprite_3d.h3
-rw-r--r--scene/3d/vehicle_body_3d.cpp96
-rw-r--r--scene/3d/vehicle_body_3d.h2
-rw-r--r--scene/3d/velocity_tracker_3d.cpp11
-rw-r--r--scene/3d/visibility_notifier_3d.cpp58
-rw-r--r--scene/3d/visibility_notifier_3d.h2
-rw-r--r--scene/3d/visual_instance_3d.cpp41
-rw-r--r--scene/3d/visual_instance_3d.h2
-rw-r--r--scene/3d/voxelizer.cpp96
-rw-r--r--scene/3d/voxelizer.h1
-rw-r--r--scene/3d/world_environment.cpp12
-rw-r--r--scene/3d/world_environment.h1
-rw-r--r--scene/3d/xr_nodes.cpp60
-rw-r--r--scene/3d/xr_nodes.h43
-rw-r--r--scene/animation/animation_blend_space_1d.cpp6
-rw-r--r--scene/animation/animation_blend_space_2d.cpp63
-rw-r--r--scene/animation/animation_blend_tree.cpp125
-rw-r--r--scene/animation/animation_blend_tree.h2
-rw-r--r--scene/animation/animation_cache.cpp64
-rw-r--r--scene/animation/animation_cache.h2
-rw-r--r--scene/animation/animation_node_state_machine.cpp69
-rw-r--r--scene/animation/animation_node_state_machine.h2
-rw-r--r--scene/animation/animation_player.cpp314
-rw-r--r--scene/animation/animation_player.h83
-rw-r--r--scene/animation/animation_tree.cpp118
-rw-r--r--scene/animation/animation_tree.h9
-rw-r--r--scene/animation/root_motion_view.cpp7
-rw-r--r--scene/animation/tween.cpp214
-rw-r--r--scene/animation/tween.h1
-rw-r--r--scene/audio/audio_stream_player.cpp48
-rw-r--r--scene/audio/audio_stream_player.h1
-rw-r--r--scene/debugger/scene_debugger.cpp250
-rw-r--r--scene/debugger/scene_debugger.h6
-rw-r--r--scene/gui/base_button.cpp77
-rw-r--r--scene/gui/base_button.h3
-rw-r--r--scene/gui/box_container.cpp61
-rw-r--r--scene/gui/box_container.h3
-rw-r--r--scene/gui/button.cpp96
-rw-r--r--scene/gui/button.h1
-rw-r--r--scene/gui/center_container.cpp27
-rw-r--r--scene/gui/center_container.h1
-rw-r--r--scene/gui/check_box.cpp22
-rw-r--r--scene/gui/check_box.h1
-rw-r--r--scene/gui/check_button.cpp20
-rw-r--r--scene/gui/check_button.h1
-rw-r--r--scene/gui/color_picker.cpp153
-rw-r--r--scene/gui/color_picker.h2
-rw-r--r--scene/gui/color_rect.cpp5
-rw-r--r--scene/gui/container.cpp40
-rw-r--r--scene/gui/container.h1
-rw-r--r--scene/gui/control.cpp458
-rw-r--r--scene/gui/control.h6
-rw-r--r--scene/gui/dialogs.cpp48
-rw-r--r--scene/gui/dialogs.h2
-rw-r--r--scene/gui/file_dialog.cpp182
-rw-r--r--scene/gui/file_dialog.h1
-rw-r--r--scene/gui/gradient_edit.cpp57
-rw-r--r--scene/gui/gradient_edit.h1
-rw-r--r--scene/gui/graph_edit.cpp234
-rw-r--r--scene/gui/graph_edit.h4
-rw-r--r--scene/gui/graph_node.cpp195
-rw-r--r--scene/gui/graph_node.h1
-rw-r--r--scene/gui/grid_container.cpp47
-rw-r--r--scene/gui/grid_container.h1
-rw-r--r--scene/gui/item_list.cpp223
-rw-r--r--scene/gui/item_list.h2
-rw-r--r--scene/gui/label.cpp138
-rw-r--r--scene/gui/label.h45
-rw-r--r--scene/gui/line_edit.cpp302
-rw-r--r--scene/gui/line_edit.h2
-rw-r--r--scene/gui/link_button.cpp19
-rw-r--r--scene/gui/link_button.h1
-rw-r--r--scene/gui/margin_container.cpp27
-rw-r--r--scene/gui/menu_button.cpp23
-rw-r--r--scene/gui/menu_button.h1
-rw-r--r--scene/gui/nine_patch_rect.cpp25
-rw-r--r--scene/gui/nine_patch_rect.h1
-rw-r--r--scene/gui/option_button.cpp80
-rw-r--r--scene/gui/option_button.h1
-rw-r--r--scene/gui/panel.cpp3
-rw-r--r--scene/gui/panel.h1
-rw-r--r--scene/gui/panel_container.cpp36
-rw-r--r--scene/gui/panel_container.h1
-rw-r--r--scene/gui/popup.cpp26
-rw-r--r--scene/gui/popup.h2
-rw-r--r--scene/gui/popup_menu.cpp284
-rw-r--r--scene/gui/popup_menu.h1
-rw-r--r--scene/gui/progress_bar.cpp8
-rw-r--r--scene/gui/progress_bar.h1
-rw-r--r--scene/gui/range.cpp67
-rw-r--r--scene/gui/range.h1
-rw-r--r--scene/gui/reference_rect.cpp8
-rw-r--r--scene/gui/reference_rect.h1
-rw-r--r--scene/gui/rich_text_effect.cpp1
-rw-r--r--scene/gui/rich_text_label.cpp777
-rw-r--r--scene/gui/rich_text_label.h8
-rw-r--r--scene/gui/scroll_bar.cpp140
-rw-r--r--scene/gui/scroll_bar.h26
-rw-r--r--scene/gui/scroll_container.cpp120
-rw-r--r--scene/gui/scroll_container.h1
-rw-r--r--scene/gui/separator.cpp8
-rw-r--r--scene/gui/separator.h3
-rw-r--r--scene/gui/shortcut.cpp11
-rw-r--r--scene/gui/shortcut.h1
-rw-r--r--scene/gui/slider.cpp61
-rw-r--r--scene/gui/slider.h3
-rw-r--r--scene/gui/spin_box.cpp42
-rw-r--r--scene/gui/spin_box.h1
-rw-r--r--scene/gui/split_container.cpp98
-rw-r--r--scene/gui/split_container.h3
-rw-r--r--scene/gui/subviewport_container.cpp69
-rw-r--r--scene/gui/subviewport_container.h1
-rw-r--r--scene/gui/tab_container.cpp260
-rw-r--r--scene/gui/tab_container.h2
-rw-r--r--scene/gui/tabs.cpp155
-rw-r--r--scene/gui/tabs.h2
-rw-r--r--scene/gui/text_edit.cpp1071
-rw-r--r--scene/gui/text_edit.h15
-rw-r--r--scene/gui/texture_button.cpp71
-rw-r--r--scene/gui/texture_button.h1
-rw-r--r--scene/gui/texture_progress.cpp76
-rw-r--r--scene/gui/texture_progress.h1
-rw-r--r--scene/gui/texture_rect.cpp16
-rw-r--r--scene/gui/texture_rect.h1
-rw-r--r--scene/gui/tree.cpp803
-rw-r--r--scene/gui/tree.h8
-rw-r--r--scene/gui/video_player.cpp108
-rw-r--r--scene/gui/video_player.h2
-rw-r--r--scene/main/canvas_item.cpp245
-rw-r--r--scene/main/canvas_item.h18
-rw-r--r--scene/main/canvas_layer.cpp68
-rw-r--r--scene/main/canvas_layer.h1
-rw-r--r--scene/main/http_request.cpp60
-rw-r--r--scene/main/http_request.h1
-rw-r--r--scene/main/instance_placeholder.cpp28
-rw-r--r--scene/main/instance_placeholder.h1
-rw-r--r--scene/main/node.cpp720
-rw-r--r--scene/main/node.h8
-rw-r--r--scene/main/resource_preloader.cpp18
-rw-r--r--scene/main/resource_preloader.h1
-rw-r--r--scene/main/scene_tree.cpp300
-rw-r--r--scene/main/scene_tree.h3
-rw-r--r--scene/main/shader_globals_override.cpp14
-rw-r--r--scene/main/shader_globals_override.h1
-rw-r--r--scene/main/timer.cpp41
-rw-r--r--scene/main/timer.h1
-rw-r--r--scene/main/viewport.cpp556
-rw-r--r--scene/main/viewport.h4
-rw-r--r--scene/main/window.cpp97
-rw-r--r--scene/register_scene_types.cpp5
-rw-r--r--scene/resources/animation.cpp644
-rw-r--r--scene/resources/animation.h16
-rw-r--r--scene/resources/audio_stream_sample.cpp103
-rw-r--r--scene/resources/audio_stream_sample.h2
-rw-r--r--scene/resources/bit_map.cpp73
-rw-r--r--scene/resources/bit_map.h1
-rw-r--r--scene/resources/box_shape_3d.cpp6
-rw-r--r--scene/resources/box_shape_3d.h1
-rw-r--r--scene/resources/capsule_shape_2d.cpp20
-rw-r--r--scene/resources/capsule_shape_3d.cpp10
-rw-r--r--scene/resources/capsule_shape_3d.h1
-rw-r--r--scene/resources/circle_shape_2d.cpp8
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp26
-rw-r--r--scene/resources/concave_polygon_shape_3d.cpp8
-rw-r--r--scene/resources/concave_polygon_shape_3d.h7
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp21
-rw-r--r--scene/resources/convex_polygon_shape_3d.cpp8
-rw-r--r--scene/resources/convex_polygon_shape_3d.h1
-rw-r--r--scene/resources/curve.cpp293
-rw-r--r--scene/resources/curve.h7
-rw-r--r--scene/resources/cylinder_shape_3d.cpp10
-rw-r--r--scene/resources/cylinder_shape_3d.h1
-rw-r--r--scene/resources/default_theme/default_theme.cpp51
-rw-r--r--scene/resources/default_theme/icon_file.pngbin0 -> 183 bytes
-rw-r--r--scene/resources/default_theme/theme_data.h4
-rw-r--r--scene/resources/dynamic_font.cpp182
-rw-r--r--scene/resources/dynamic_font.h5
-rw-r--r--scene/resources/environment.cpp216
-rw-r--r--scene/resources/environment.h12
-rw-r--r--scene/resources/font.cpp168
-rw-r--r--scene/resources/font.h4
-rw-r--r--scene/resources/gradient.cpp10
-rw-r--r--scene/resources/gradient.h14
-rw-r--r--scene/resources/height_map_shape_3d.cpp9
-rw-r--r--scene/resources/line_shape_2d.cpp18
-rw-r--r--scene/resources/material.cpp260
-rw-r--r--scene/resources/material.h5
-rw-r--r--scene/resources/mesh.cpp182
-rw-r--r--scene/resources/mesh.h1
-rw-r--r--scene/resources/mesh_data_tool.cpp139
-rw-r--r--scene/resources/mesh_data_tool.h3
-rw-r--r--scene/resources/mesh_library.cpp72
-rw-r--r--scene/resources/mesh_library.h1
-rw-r--r--scene/resources/multimesh.cpp80
-rw-r--r--scene/resources/multimesh.h1
-rw-r--r--scene/resources/navigation_mesh.cpp40
-rw-r--r--scene/resources/navigation_mesh.h2
-rw-r--r--scene/resources/packed_scene.cpp226
-rw-r--r--scene/resources/packed_scene.h5
-rw-r--r--scene/resources/particles_material.cpp186
-rw-r--r--scene/resources/particles_material.h3
-rw-r--r--scene/resources/physics_material.cpp7
-rw-r--r--scene/resources/physics_material.h17
-rw-r--r--scene/resources/polygon_path_finder.cpp89
-rw-r--r--scene/resources/polygon_path_finder.h9
-rw-r--r--scene/resources/primitive_meshes.cpp20
-rw-r--r--scene/resources/primitive_meshes.h8
-rw-r--r--scene/resources/ray_shape_2d.cpp105
-rw-r--r--scene/resources/ray_shape_2d.h (renamed from core/math/disjoint_set.cpp)34
-rw-r--r--scene/resources/ray_shape_3d.cpp7
-rw-r--r--scene/resources/ray_shape_3d.h1
-rw-r--r--scene/resources/rectangle_shape_2d.cpp7
-rw-r--r--scene/resources/resource_format_text.cpp179
-rw-r--r--scene/resources/resource_format_text.h3
-rw-r--r--scene/resources/segment_shape_2d.cpp95
-rw-r--r--scene/resources/segment_shape_2d.h25
-rw-r--r--scene/resources/shader.cpp43
-rw-r--r--scene/resources/shader.h7
-rw-r--r--scene/resources/shape_2d.cpp16
-rw-r--r--scene/resources/shape_3d.cpp20
-rw-r--r--scene/resources/shape_3d.h3
-rw-r--r--scene/resources/skin.cpp4
-rw-r--r--scene/resources/sky.cpp7
-rw-r--r--scene/resources/sky_material.cpp88
-rw-r--r--scene/resources/sky_material.h5
-rw-r--r--scene/resources/sphere_shape_3d.cpp7
-rw-r--r--scene/resources/sphere_shape_3d.h1
-rw-r--r--scene/resources/style_box.cpp112
-rw-r--r--scene/resources/style_box.h5
-rw-r--r--scene/resources/surface_tool.cpp164
-rw-r--r--scene/resources/surface_tool.h2
-rw-r--r--scene/resources/text_file.cpp1
-rw-r--r--scene/resources/text_file.h1
-rw-r--r--scene/resources/texture.cpp366
-rw-r--r--scene/resources/texture.h18
-rw-r--r--scene/resources/theme.cpp154
-rw-r--r--scene/resources/theme.h3
-rw-r--r--scene/resources/tile_set.cpp273
-rw-r--r--scene/resources/tile_set.h40
-rw-r--r--scene/resources/video_stream.h2
-rw-r--r--scene/resources/visual_shader.cpp132
-rw-r--r--scene/resources/visual_shader.h1
-rw-r--r--scene/resources/visual_shader_nodes.cpp229
-rw-r--r--scene/resources/world_2d.cpp70
-rw-r--r--scene/resources/world_2d.h1
-rw-r--r--scene/resources/world_3d.cpp63
-rw-r--r--scene/resources/world_margin_shape_3d.cpp6
-rw-r--r--scene/resources/world_margin_shape_3d.h1
-rw-r--r--scene/scene_string_names.cpp4
-rw-r--r--scene/scene_string_names.h3
-rw-r--r--servers/audio/audio_driver_dummy.cpp32
-rw-r--r--servers/audio/audio_driver_dummy.h7
-rw-r--r--servers/audio/audio_filter_sw.cpp46
-rw-r--r--servers/audio/audio_filter_sw.h3
-rw-r--r--servers/audio/audio_rb_resampler.cpp30
-rw-r--r--servers/audio/audio_rb_resampler.h10
-rw-r--r--servers/audio/audio_stream.cpp21
-rw-r--r--servers/audio/audio_stream.h7
-rw-r--r--servers/audio/effects/audio_effect_amplify.cpp3
-rw-r--r--servers/audio/effects/audio_effect_chorus.cpp36
-rw-r--r--servers/audio/effects/audio_effect_chorus.h2
-rw-r--r--servers/audio/effects/audio_effect_compressor.cpp34
-rw-r--r--servers/audio/effects/audio_effect_delay.cpp46
-rw-r--r--servers/audio/effects/audio_effect_distortion.cpp27
-rw-r--r--servers/audio/effects/audio_effect_eq.cpp10
-rw-r--r--servers/audio/effects/audio_effect_filter.cpp32
-rw-r--r--servers/audio/effects/audio_effect_filter.h9
-rw-r--r--servers/audio/effects/audio_effect_limiter.cpp14
-rw-r--r--servers/audio/effects/audio_effect_panner.cpp4
-rw-r--r--servers/audio/effects/audio_effect_phaser.cpp16
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.cpp32
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.h1
-rw-r--r--servers/audio/effects/audio_effect_record.cpp3
-rw-r--r--servers/audio/effects/audio_effect_record.h5
-rw-r--r--servers/audio/effects/audio_effect_reverb.cpp32
-rw-r--r--servers/audio/effects/audio_effect_spectrum_analyzer.cpp11
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.cpp14
-rw-r--r--servers/audio/effects/audio_stream_generator.cpp16
-rw-r--r--servers/audio/effects/audio_stream_generator.h1
-rw-r--r--servers/audio/effects/eq.cpp31
-rw-r--r--servers/audio/effects/eq.h3
-rw-r--r--servers/audio/effects/reverb.cpp90
-rw-r--r--servers/audio/effects/reverb.h45
-rw-r--r--servers/audio_server.cpp189
-rw-r--r--servers/audio_server.h13
-rw-r--r--servers/display_server.cpp66
-rw-r--r--servers/display_server.h19
-rw-r--r--servers/navigation_server_2d.cpp11
-rw-r--r--servers/navigation_server_3d.cpp1
-rw-r--r--servers/physics_2d/area_2d_sw.cpp55
-rw-r--r--servers/physics_2d/area_2d_sw.h30
-rw-r--r--servers/physics_2d/area_pair_2d_sw.cpp53
-rw-r--r--servers/physics_2d/area_pair_2d_sw.h2
-rw-r--r--servers/physics_2d/body_2d_sw.cpp150
-rw-r--r--servers/physics_2d/body_2d_sw.h28
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp68
-rw-r--r--servers/physics_2d/body_pair_2d_sw.h2
-rw-r--r--servers/physics_2d/broad_phase_2d_basic.cpp46
-rw-r--r--servers/physics_2d/broad_phase_2d_basic.h3
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp191
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.h7
-rw-r--r--servers/physics_2d/broad_phase_2d_sw.h1
-rw-r--r--servers/physics_2d/collision_object_2d_sw.cpp47
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h2
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp422
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp50
-rw-r--r--servers/physics_2d/constraint_2d_sw.h1
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp80
-rw-r--r--servers/physics_2d/joints_2d_sw.h8
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp213
-rw-r--r--servers/physics_2d/physics_server_2d_sw.h8
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.cpp22
-rw-r--r--servers/physics_2d/physics_server_2d_wrap_mt.h20
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp174
-rw-r--r--servers/physics_2d/shape_2d_sw.h46
-rw-r--r--servers/physics_2d/space_2d_sw.cpp250
-rw-r--r--servers/physics_2d/space_2d_sw.h5
-rw-r--r--servers/physics_2d/step_2d_sw.cpp36
-rw-r--r--servers/physics_2d/step_2d_sw.h1
-rw-r--r--servers/physics_3d/area_3d_sw.cpp55
-rw-r--r--servers/physics_3d/area_3d_sw.h30
-rw-r--r--servers/physics_3d/area_pair_3d_sw.cpp53
-rw-r--r--servers/physics_3d/area_pair_3d_sw.h2
-rw-r--r--servers/physics_3d/body_3d_sw.cpp142
-rw-r--r--servers/physics_3d/body_3d_sw.h35
-rw-r--r--servers/physics_3d/body_pair_3d_sw.cpp41
-rw-r--r--servers/physics_3d/body_pair_3d_sw.h1
-rw-r--r--servers/physics_3d/broad_phase_3d_basic.cpp55
-rw-r--r--servers/physics_3d/broad_phase_3d_basic.h3
-rw-r--r--servers/physics_3d/broad_phase_3d_sw.h1
-rw-r--r--servers/physics_3d/broad_phase_octree.cpp25
-rw-r--r--servers/physics_3d/broad_phase_octree.h1
-rw-r--r--servers/physics_3d/collision_object_3d_sw.cpp35
-rw-r--r--servers/physics_3d/collision_object_3d_sw.h4
-rw-r--r--servers/physics_3d/collision_solver_3d_sat.cpp384
-rw-r--r--servers/physics_3d/collision_solver_3d_sw.cpp75
-rw-r--r--servers/physics_3d/constraint_3d_sw.h1
-rw-r--r--servers/physics_3d/gjk_epa.cpp104
-rw-r--r--servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp15
-rw-r--r--servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp61
-rw-r--r--servers/physics_3d/joints/generic_6dof_joint_3d_sw.h2
-rw-r--r--servers/physics_3d/joints/hinge_joint_3d_sw.cpp14
-rw-r--r--servers/physics_3d/joints/hinge_joint_3d_sw.h1
-rw-r--r--servers/physics_3d/joints/jacobian_entry_3d_sw.h2
-rw-r--r--servers/physics_3d/joints/pin_joint_3d_sw.cpp11
-rw-r--r--servers/physics_3d/joints/pin_joint_3d_sw.h1
-rw-r--r--servers/physics_3d/joints/slider_joint_3d_sw.cpp15
-rw-r--r--servers/physics_3d/joints/slider_joint_3d_sw.h10
-rw-r--r--servers/physics_3d/joints_3d_sw.h1
-rw-r--r--servers/physics_3d/physics_server_3d_sw.cpp222
-rw-r--r--servers/physics_3d/physics_server_3d_sw.h8
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp311
-rw-r--r--servers/physics_3d/shape_3d_sw.h23
-rw-r--r--servers/physics_3d/space_3d_sw.cpp224
-rw-r--r--servers/physics_3d/space_3d_sw.h5
-rw-r--r--servers/physics_3d/step_3d_sw.cpp35
-rw-r--r--servers/physics_3d/step_3d_sw.h1
-rw-r--r--servers/physics_server_2d.cpp119
-rw-r--r--servers/physics_server_2d.h31
-rw-r--r--servers/physics_server_3d.cpp72
-rw-r--r--servers/physics_server_3d.h16
-rw-r--r--servers/register_server_types.cpp4
-rw-r--r--servers/rendering/rasterizer.cpp3
-rw-r--r--servers/rendering/rasterizer.h43
-rw-r--r--servers/rendering/rasterizer_rd/light_cluster_builder.cpp8
-rw-r--r--servers/rendering/rasterizer_rd/light_cluster_builder.h3
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp78
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h9
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp40
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_effects_rd.h21
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_rd.cpp4
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp104
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h22
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp158
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_scene_rd.h31
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp380
-rw-r--r--servers/rendering/rasterizer_rd/rasterizer_storage_rd.h19
-rw-r--r--servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp2
-rw-r--r--servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h1
-rw-r--r--servers/rendering/rasterizer_rd/shader_compiler_rd.cpp108
-rw-r--r--servers/rendering/rasterizer_rd/shader_compiler_rd.h5
-rw-r--r--servers/rendering/rasterizer_rd/shader_rd.cpp19
-rw-r--r--servers/rendering/rasterizer_rd/shader_rd.h1
-rw-r--r--servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl9
-rw-r--r--servers/rendering/rasterizer_rd/shaders/canvas.glsl19
-rw-r--r--servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl11
-rw-r--r--servers/rendering/rasterizer_rd/shaders/copy.glsl9
-rw-r--r--servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl17
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cube_to_dp.glsl5
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl9
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl4
-rw-r--r--servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl7
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe.glsl22
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl11
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl12
-rw-r--r--servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl20
-rw-r--r--servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl7
-rw-r--r--servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl9
-rw-r--r--servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl66
-rw-r--r--servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl3
-rw-r--r--servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl12
-rw-r--r--servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl12
-rw-r--r--servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl11
-rw-r--r--servers/rendering/rasterizer_rd/shaders/sky.glsl11
-rw-r--r--servers/rendering/rasterizer_rd/shaders/specular_merge.glsl10
-rw-r--r--servers/rendering/rasterizer_rd/shaders/ssao.glsl5
-rw-r--r--servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl6
-rw-r--r--servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl5
-rw-r--r--servers/rendering/rasterizer_rd/shaders/subsurface_scattering.glsl11
-rw-r--r--servers/rendering/rasterizer_rd/shaders/tonemap.glsl17
-rw-r--r--servers/rendering/rendering_device.cpp11
-rw-r--r--servers/rendering/rendering_device.h3
-rw-r--r--servers/rendering/rendering_device_binds.cpp33
-rw-r--r--servers/rendering/rendering_device_binds.h3
-rw-r--r--servers/rendering/rendering_server_canvas.cpp213
-rw-r--r--servers/rendering/rendering_server_canvas.h17
-rw-r--r--servers/rendering/rendering_server_raster.cpp40
-rw-r--r--servers/rendering/rendering_server_raster.h2
-rw-r--r--servers/rendering/rendering_server_scene.cpp310
-rw-r--r--servers/rendering/rendering_server_scene.h24
-rw-r--r--servers/rendering/rendering_server_viewport.cpp69
-rw-r--r--servers/rendering/rendering_server_viewport.h8
-rw-r--r--servers/rendering/rendering_server_wrap_mt.cpp20
-rw-r--r--servers/rendering/rendering_server_wrap_mt.h1
-rw-r--r--servers/rendering/shader_language.cpp439
-rw-r--r--servers/rendering/shader_language.h189
-rw-r--r--servers/rendering/shader_types.cpp3
-rw-r--r--servers/rendering/shader_types.h2
-rw-r--r--servers/rendering_server.cpp219
-rw-r--r--servers/rendering_server.h10
-rw-r--r--servers/xr/xr_interface.cpp6
-rw-r--r--servers/xr/xr_positional_tracker.cpp4
-rw-r--r--servers/xr/xr_positional_tracker.h2
-rw-r--r--servers/xr_server.cpp7
-rw-r--r--thirdparty/README.md32
-rw-r--r--thirdparty/jpeg-compressor/patches/fix-msvc-sse2-detection.patch44
-rw-r--r--thirdparty/jpeg-compressor/patches/fix-msvc2017-build.patch31
-rw-r--r--thirdparty/misc/cubemap_coeffs.h4
-rw-r--r--thirdparty/misc/hq2x.cpp2636
-rw-r--r--thirdparty/misc/hq2x.h19
-rw-r--r--thirdparty/misc/r128.h14
-rw-r--r--thirdparty/oidn/common/platform.h2
-rw-r--r--thirdparty/oidn/core/autoencoder.cpp26
-rw-r--r--thirdparty/oidn/core/autoencoder.h4
-rw-r--r--thirdparty/oidn/core/common.h3
-rw-r--r--thirdparty/oidn/core/device.cpp39
-rw-r--r--thirdparty/oidn/core/device.h26
-rw-r--r--thirdparty/oidn/core/network.cpp4
-rw-r--r--thirdparty/oidn/core/transfer_function.cpp13
-rw-r--r--thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp2
-rw-r--r--thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp6
-rw-r--r--thirdparty/oidn/patches/godot-changes-c58c5216.patch307
-rw-r--r--thirdparty/oidn/patches/mkl-dnn-fix-vs2017-build.patch45
-rw-r--r--thirdparty/oidn/weights/LICENSE.txt202
-rw-r--r--thirdparty/xatlas/LICENSE2
-rw-r--r--thirdparty/xatlas/xatlas.cpp6479
-rw-r--r--thirdparty/xatlas/xatlas.h63
1888 files changed, 60861 insertions, 86368 deletions
diff --git a/.clang-format b/.clang-format
index 75715a3173..1c26421a7f 100644
--- a/.clang-format
+++ b/.clang-format
@@ -76,7 +76,7 @@ IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
-# KeepEmptyLinesAtTheStartOfBlocks: true
+KeepEmptyLinesAtTheStartOfBlocks: false
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000000..59d0facb96
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,44 @@
+---
+Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-nullptr,readability-braces-around-statements'
+WarningsAsErrors: ''
+HeaderFilterRegex: '.*'
+AnalyzeTemporaryDtors: false
+FormatStyle: none
+CheckOptions:
+CheckOptions:
+ - key: cert-dcl16-c.NewSuffixes
+ value: 'L;LL;LU;LLU'
+ - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
+ value: '0'
+ - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
+ value: '1'
+ - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
+ value: '1'
+ - key: google-readability-function-size.StatementThreshold
+ value: '800'
+ - key: google-readability-namespace-comments.ShortNamespaceLines
+ value: '10'
+ - key: google-readability-namespace-comments.SpacesBeforeComments
+ value: '2'
+ - key: modernize-loop-convert.MaxCopySize
+ value: '16'
+ - key: modernize-loop-convert.MinConfidence
+ value: reasonable
+ - key: modernize-loop-convert.NamingStyle
+ value: CamelCase
+ - key: modernize-pass-by-value.IncludeStyle
+ value: llvm
+ - key: modernize-replace-auto-ptr.IncludeStyle
+ value: llvm
+ - key: modernize-use-bool-literals.IgnoreMacros
+ value: '0'
+ - key: modernize-use-default-member-init.IgnoreMacros
+ value: '0'
+ - key: modernize-use-default-member-init.UseAssignment
+ value: '1'
+ - key: modernize-use-nullptr.NullMacros
+ value: 'NULL'
+ - key: readability-braces-around-statements.ShortStatementLines
+ value: '0'
+...
+
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 91528465c0..7e8c5fd740 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -6,13 +6,24 @@ labels: ''
assignees: ''
---
+<!-- Please search existing issues for potential duplicates before filing yours:
+https://github.com/godotengine/godot/issues?q=is%3Aissue
+-->
**Godot version:**
+<!-- Specify commit hash if using non-official build. -->
+
**OS/device including version:**
+<!-- Specify GPU model, drivers, and the backend (GLES2, GLES3, Vulkan) if graphics-related. -->
+
**Issue description:**
+<!-- What happened, and what was expected. -->
+
**Steps to reproduce:**
+
**Minimal reproduction project:**
+<!-- A small Godot project which reproduces the issue. Drag and drop a zip archive to upload it. -->
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000..f787bec00e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,14 @@
+blank_issues_enabled: false
+
+contact_links:
+ - name: Godot proposals
+ url: https://github.com/godotengine/godot-proposals
+ about: Please submit feature proposals on the Godot proposals repository, not here.
+
+ - name: Godot documentation repository
+ url: https://github.com/godotengine/godot-docs
+ about: Please report issues with documentation on the Godot documentation repository, not here.
+
+ - name: Godot community channels
+ url: https://godotengine.org/community
+ about: Please ask for technical support on one of the other community channels, not here.
diff --git a/.github/ISSUE_TEMPLATE/feature---enhancement-request.md b/.github/ISSUE_TEMPLATE/feature---enhancement-request.md
deleted file mode 100644
index 496e0197ca..0000000000
--- a/.github/ISSUE_TEMPLATE/feature---enhancement-request.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-name: Feature / Enhancement Request
-about: Adding new features or improving existing ones.
-title: 'IMPORTANT: This repository no longer accepts feature / enhancement requests.'
-labels: ''
-assignees: ''
-
----
-
-**IMPORTANT, PLEASE READ**
-
-Feature / Enhancement requests are no longer accepted in the main Godot repository.
-Please open an item by filling the relevant fields in the *Proposals* repository:
-
-https://github.com/godotengine/godot-proposals/issues/new/choose
-
-Do not submit to this repository or your issue will be closed.
-
-**IMPORTANT, PLEASE READ**
diff --git a/.gitignore b/.gitignore
index 19490b9878..d9537edbf2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,6 +55,11 @@ gmon.out
*.cflags
*.cxxflags
+# Code::Blocks files
+*.cbp
+*.layout
+*.depend
+
# Eclipse CDT files
.cproject
.settings/
@@ -89,6 +94,9 @@ logs/
*.sln
*.vcxproj*
+# Custom SCons configuration override
+/custom.py
+
# Build results
[Dd]ebug/
[Dd]ebugPublic/
@@ -337,6 +345,9 @@ platform/windows/godot_res.res
# Visual Studio Code workspace file
*.code-workspace
+# Scons construction environment dump
+.scons_env.json
+
# Scons progress indicator
.scons_node_count
diff --git a/.travis.yml b/.travis.yml
index 8878935e52..58c3733d22 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -69,7 +69,7 @@ matrix:
stage: build
env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes"
os: osx
- osx_image: xcode11.3
+ osx_image: xcode11.5
compiler: clang
addons:
homebrew:
@@ -83,7 +83,7 @@ matrix:
# stage: build
# env: PLATFORM=iphone TOOLS=no TARGET=debug CACHE_NAME=${PLATFORM}-clang
# os: osx
-# osx_image: xcode11.3
+# osx_image: xcode11.5
# compiler: clang
# addons:
# homebrew:
@@ -128,7 +128,7 @@ install:
- if [ "$PLATFORM" = "javascript" ]; then
git clone --depth 1 "https://github.com/emscripten-core/emsdk.git";
./emsdk/emsdk install latest;
- ./emsdk/emsdk activate latest;
+ ./emsdk/emsdk activate --no-embedded latest;
fi
- if [ "$STATIC_CHECKS" = "yes" ]; then
unset SCONS_CACHE;
diff --git a/AUTHORS.md b/AUTHORS.md
index 0f002cfaed..e8bb91d4bb 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -95,6 +95,7 @@ name is available.
Indah Sylvia (ISylvox)
J08nY
Jakub Grzesik (kubecz3k)
+ James Buck (jbuck3)
Jérôme Gully (Nutriz)
Joan Fons Sanchez (JFonS)
Johan Manuel (29jm)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ba04008680..c28692c34f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -119,6 +119,22 @@ for an introduction to developing on Godot.
The [Contributing docs](https://docs.godotengine.org/en/latest/community/contributing/index.html)
also have important information on the PR workflow and the code style we use.
+### Document your changes
+
+If your pull request adds methods, properties or signals that are exposed to
+scripting APIs, you **must** update the class reference to document those.
+This is to ensure the documentation coverage doesn't decrease as contributions
+are merged.
+
+[Update the documentation template](https://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html#updating-the-documentation-template)
+using your compiled binary, then fill in the descriptions.
+Follow the style guide described in the
+[Docs writing guidelines](https://docs.godotengine.org/en/latest/community/contributing/docs_writing_guidelines.html).
+
+If your pull request modifies parts of the code in a non-obvious way, make sure
+to add comments in the code as well. This helps other people understand the
+change without having to look at `git blame`.
+
### Be nice to the Git history
Try to make simple PRs that handle one specific topic. Just like for reporting
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt
index 443e6fee97..fc3079c361 100644
--- a/COPYRIGHT.txt
+++ b/COPYRIGHT.txt
@@ -257,12 +257,6 @@ Comment: FastLZ
Copyright: 2005-2020, Ariya Hidayat
License: Expat
-Files: ./thirdparty/misc/hq2x.cpp
- ./thirdparty/misc/hq2x.h
-Comment: hq2x implementation
-Copyright: 2016, Bruno Ribeiro
-License: Apache-2.0
-
Files: ./thirdparty/misc/ifaddrs-android.cc
./thirdparty/misc/ifaddrs-android.h
Comment: libjingle
@@ -305,7 +299,7 @@ License: Zlib
Files: ./thirdparty/oidn/
Comment: Intel Open Image Denoise
-Copyright: 2009-2020, Intel Corporation
+Copyright: 2009-2019, Intel Corporation
License: Apache-2.0
Files: ./thirdparty/opus/
@@ -334,7 +328,7 @@ License: Zlib
Files: ./thirdparty/rvo2/
Comment: RVO2
-Copyright: 2016, University of North Carolina at Chapel Hill
+Copyright: 2016, University of North Carolina at Chapel Hill
License: Apache 2.0
Files: ./thirdparty/squish/
@@ -374,7 +368,7 @@ License: Expat
Files: ./thirdparty/xatlas/
Comment: xatlas
-Copyright: 2018, Jonathan Young
+Copyright: 2018-2020, Jonathan Young
2013, Thekla, Inc
2006, NVIDIA Corporation, Ignacio Castano
License: Expat
diff --git a/DONORS.md b/DONORS.md
index 134dc0484b..2988cc94f4 100644
--- a/DONORS.md
+++ b/DONORS.md
@@ -24,11 +24,12 @@ generous deed immortalized in the next stable release of Godot Engine.
AD Ford
Alan Beauchamp
- Anand Mallik
+ albinaask
Andrew Dunai
Brandon Lamb
Christian Baune
Christopher Montesano
+ Darius Pranskus
Darkhan Baimyrza
Darrin Massena
Dov Zimring
@@ -41,15 +42,18 @@ generous deed immortalized in the next stable release of Godot Engine.
Jasper Brooks
Javary Co.
Jeffery Chiu
+ John Benard (Linuxydable)
Justin Arnold
Justo Delgado Baudí
Kyle Szklenski
+ Marcel Kräml
Matthieu Huvé
Maxim Karsten
Mike King
Nathan Warden
Neal Gompa (Conan Kudo)
Péter Magyar
+ Ronnie Cheng
Slobodan Milnovic
Stephan Lanfermann
Steve
@@ -58,12 +62,14 @@ generous deed immortalized in the next stable release of Godot Engine.
## Gold donors
+ Bjarke
David Gehrig
David Graham
David Snopek
Ed Morley
Florian Rämisch
Jakub Grzesik
+ HardRound
Manuele Finocchiaro
Officine Pixel S.n.c.
Ronan Zeegers
@@ -92,10 +98,10 @@ generous deed immortalized in the next stable release of Godot Engine.
Maciej Pendolski
Matthew Hillier
Mohamed Ikbel Boulabiar
- Mored4u
Rene
Retro Village
Rob Messick
+ Roland Fredenhagen
Ryan Badour
Sandro Jenny
Scott Wadden
@@ -108,16 +114,19 @@ generous deed immortalized in the next stable release of Godot Engine.
Alex Khayrullin
alice gambrell
+ Barugon
Chris Goddard
Chris Serino
Christian Padilla
Conrad Curry
Craig Smith
Darrian Little
+ Hoai Nam Tran
Horváth Péter
- Ivan Trombley
+ Jamal Aboudrar
Joan Fons
Joshua Flores
+ Leo Fidel R Liban
Petr Malac
Rami
Rob
@@ -149,20 +158,20 @@ generous deed immortalized in the next stable release of Godot Engine.
Christoph Schröder
Codee Leaf
Cody Parker
- Coldragon
Craig Ostrin
+ curtis Kramer
D
Easypete
+ Edgar Sun
Eric Monson
Eugenio Hugo Salgüero Jáñez
- Fain
flesk
Gary Hulst
gavlig
GGGames.org
Guilherme Felipe de C. G. da Silva
- Halom Vered
Heath Hayes
+ Hu Hund
Isaac Clausman
Jared White
Jeff Nyte
@@ -171,18 +180,21 @@ generous deed immortalized in the next stable release of Godot Engine.
Jose Malheiro
Joshua Lesperance
Juan Velandia
+ Julian Todd
Juraj Móza
Kelteseth
kickmaniac
kinfox
Lain Ballard
Marcelo Dornbusch Lopes
+ Marcelo Henrique Gonçalves
Markus Fehr
Markus Wiesner
Martin Eigel
Matt Eunson
m kaersten
MuffinManKen
+ Nick Abousselam
Oliver Dick
Oscar Campos
Patrick Ting
@@ -197,14 +209,16 @@ generous deed immortalized in the next stable release of Godot Engine.
Samuel Judd
Scott Pilet
Sean Morgan
+ Sean Robertson
+ Sébastien
Serban Serafimescu
- Sindre Sømme
SleepCircle
spilldata
Stoned Xander
TheLevelOfDetail .
Thomas Kurz
Tobias Bocanegra
+ Trent Fehl
Urho
William Foster
Zhou Tuizhi
@@ -214,6 +228,7 @@ generous deed immortalized in the next stable release of Godot Engine.
## Silver donors
1D_Inc
+ Aaron Winter
Abraham Haskins
Acheron
Adam
@@ -229,7 +244,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Agustinus Arya
Aidan O'Flannagain
Aki Mimoto
- Alan Mervitz
Alan Stice
Albin Jonasson Svärdsby
Alder Stefano
@@ -237,14 +251,17 @@ generous deed immortalized in the next stable release of Godot Engine.
Alessandro Senese
Alexander Erlemann
alex clavelle
+ Alfred Reinold Baudisch
Allan Davis
Allen Schade
- Andreas Evers
Andreas Krampitz
+ Andres Hernandez
André Simões
+ andrew james morris
+ Andrew Mansuetti
Andrew Thomas
+ Ano Nim
Anthony Avina
- Anthony Staunton
AP Condomines
Arda Erol
Armin Preiml
@@ -252,10 +269,11 @@ generous deed immortalized in the next stable release of Godot Engine.
Arthur S. Muszynski
Asger
Ashley Claymore
+ Ashton Scott Snapp
Aubrey Falconer
- Avencherus
B A
Balázs Batári
+ Bartosz Bielecki
Benedikt
Ben Vercammen
Bernd Jänichen
@@ -265,10 +283,8 @@ generous deed immortalized in the next stable release of Godot Engine.
Bobby CC Wong
Bram
brian
- bugcaptor
Burney Waring
Cameron Meyer
- Carlo Sitaro
Carl van der Geest
Carwyn Edwards
Cas Brugman
@@ -289,7 +305,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Daniel Tebbutt
David May
David Woodard
- DiCola Jamn
+ Dimitri Stanojevic
Dominic Cooney
Dominik Wetzel
Donn Eddy
@@ -301,24 +317,25 @@ generous deed immortalized in the next stable release of Godot Engine.
Eduardo Teixeira
Edward Herbert
Edward Swartz
+ Eelco F Hillenius
Egon Elbre
Elgenzay
Elias Nykrem
- Elmeri '- Duy Kevin Nguyen
Ephemeral
Eric Ellingson
- Eric Rogers
Eric Williams
Erkki Seppälä
Evan Rose
+ Fain
+ Faisal Alkubaisi
Fancy Ants Studios
Fekinox
Felix Bohmann
Felix Kollmann
Flaredown
Forty Doubleu
- fox
FuDiggity
+ Frank
Gadzhi Kharkharov
gamedev by Celio
Gary Thomas
@@ -328,16 +345,17 @@ generous deed immortalized in the next stable release of Godot Engine.
Greyson Richey
Grid
Guillaume Audirac
+ Guillaume Pham Ngoc
Guldoman
Hal A
Heribert Hirth
Hunter Jones
Hylpher
- Ichiro Dohi
Iiari
iKlem
IndustrialRobot
Ivan Nikolaev
+ Jackson Harmer
Jacob
Jaiden Gerig
Jaime Ruiz-Borau Vizárraga
@@ -346,9 +364,11 @@ generous deed immortalized in the next stable release of Godot Engine.
Janders
Jannik Gröger
JARKKO PARVIAINEN
+ Jean-Baptiste LEPESME
Jeff Hungerford
Jennifer Graves
Jesse Dubay
+ Joe Alden
Joel Fivat
Joel Höglund
Joel Setterberg
@@ -363,14 +383,18 @@ generous deed immortalized in the next stable release of Godot Engine.
Jonathan G
Jon Bonazza
Jon Sully
+ Jordy Goodridge
+ Jorge Antunes
Jorge Caballero
Jose Aleman
Jose C. Rubio
Joseph Catrambone
Josh Mitchell
+ Joshua Southerland
Juanfran
Judd
Julian Murgia
+ June Little
JungleRobba
Justin Hamilton
Justin Spedding
@@ -382,7 +406,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Kent Jofur
Kevin McPhillips
Kiri Jolly
- Kiyohiro Kawamura (kyorohiro)
Kjetil Haugland
Klagsam
KsyTek Games
@@ -390,26 +413,24 @@ generous deed immortalized in the next stable release of Godot Engine.
kycho
Kyle Appelgate
Laurent Tréguier
+ Leonard Meagher
Leonardo Dimano
Levi Lindsey
Lin Chear
Linus Lind Lundgren
Lionel Gaillard
- Lukáš Rendvanský
Luigi Renna
LunaticInAHat
Lurkars
Major Haul
Malcolm
- Malik Ahmed
- Malik Nejer
+ Marco Lardelli
Markus Michael Egger
Martin Holas
Martin Liška
Marvin
- Mathieu Rimelen
+ Mathieu
Matt Edwards
- Matthew Little
Mauro Pellegrini
Max Fiedler
Maxime Blade
@@ -426,7 +447,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Mikayla
Mike Birkhead
Mike Cunningham
- Mitchell J. Wagner
+ Molinghu
MoM
Mored4u
Nathan Fish
@@ -435,8 +456,10 @@ generous deed immortalized in the next stable release of Godot Engine.
Neil Blakey-Milner
Neil Wang
Nerdforge
+ Nerdyninja
Nicholas
Nicholas Girga
+ Nick Allen
Nick Macholl
Niclas Eriksen
Nicolás Montaña
@@ -453,11 +476,12 @@ generous deed immortalized in the next stable release of Godot Engine.
Paweł Kowal
Pedro Assuncao
Penguin
+ Peter
Philip Cohoe
Point08
+ pwab
Rad Cat
Rafa Laguna
- rainerLinux
Remi Rampin
Rémi Verschelde
Ricardo Alcantara
@@ -470,6 +494,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Roman Tinkov
Ronald Ho Hip (CrimsonZA)
Ronan
+ Ronny Mühle
Ryan Groom
Ryan Hentz
Sam Edson
@@ -483,6 +508,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Shane
Shane Sicienski
Shane Spoor
+ Shiomi '- Duy Kevin Nguyen
Siim Raidma
Simon Jonas Larsen
Simon Wenner
@@ -490,17 +516,21 @@ generous deed immortalized in the next stable release of Godot Engine.
SK
smbe19
smo1704
+ soft circles
+ Squirrel
Stefano Caronia
Steve Cloete
Svenne Krap
Taylor Fahlman
Terry
tezuvholovdr
+ TheVoiceInMyHead
thomas
Thomas Bechtold
Thomas Detoy
Thomas Kelly
Tim Drumheller
+ Tim Erskine
Timothy B. MacDonald
Title Plinsut
Tobbun
@@ -516,6 +546,7 @@ generous deed immortalized in the next stable release of Godot Engine.
Tyler Compton
Tyler Stafos
UltyX
+ Valentí Gàmez
Vaughan Ling
Victor
Vigilant Watch
@@ -525,10 +556,12 @@ generous deed immortalized in the next stable release of Godot Engine.
werner mendizabal
Wiley Thompson
Will
- William Hogben
Wyatt Goodin
Yegor
+ Yuri LaPointe
Yuri Sizov
+ Zgegnesh Hemomancer
+ éƒæ™¨ç…œ
## Bronze donors
diff --git a/SConstruct b/SConstruct
index 86014b8160..9496595a26 100644
--- a/SConstruct
+++ b/SConstruct
@@ -8,6 +8,7 @@ import glob
import os
import pickle
import sys
+from collections import OrderedDict
# Local
import methods
@@ -50,8 +51,6 @@ for x in sorted(glob.glob("platform/*")):
sys.path.remove(tmppath)
sys.modules.pop("detect")
-module_list = methods.detect_modules()
-
methods.save_active_platforms(active_platforms, active_platform_ids)
custom_tools = ["default"]
@@ -87,6 +86,7 @@ env_base.__class__.add_library = methods.add_library
env_base.__class__.add_program = methods.add_program
env_base.__class__.CommandNoCache = methods.CommandNoCache
env_base.__class__.disable_warnings = methods.disable_warnings
+env_base.__class__.module_check_dependencies = methods.module_check_dependencies
env_base["x86_libtheora_opt_gcc"] = False
env_base["x86_libtheora_opt_vc"] = False
@@ -123,6 +123,7 @@ opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise e
opts.Add(BoolVariable("deprecated", "Enable deprecated features", True))
opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True))
opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver", False))
+opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "")
# Advanced options
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
@@ -181,21 +182,49 @@ for k in platform_opts.keys():
for o in opt_list:
opts.Add(o)
-for x in module_list:
- module_enabled = True
- tmppath = "./modules/" + x
- sys.path.insert(0, tmppath)
+# Update the environment now as the "custom_modules" option may be
+# defined in a file rather than specified via the command line.
+opts.Update(env_base)
+
+# Detect modules.
+modules_detected = OrderedDict()
+module_search_paths = ["modules"] # Built-in path.
+
+if env_base["custom_modules"]:
+ paths = env_base["custom_modules"].split(",")
+ for p in paths:
+ try:
+ module_search_paths.append(methods.convert_custom_modules_path(p))
+ except ValueError as e:
+ print(e)
+ Exit(255)
+
+for path in module_search_paths:
+ # Note: custom modules can override built-in ones.
+ modules_detected.update(methods.detect_modules(path))
+ include_path = os.path.dirname(path)
+ if include_path:
+ env_base.Prepend(CPPPATH=[include_path])
+
+# Add module options.
+for name, path in modules_detected.items():
+ enabled = True
+ sys.path.insert(0, path)
import config
- enabled_attr = getattr(config, "is_enabled", None)
- if callable(enabled_attr) and not config.is_enabled():
- module_enabled = False
- sys.path.remove(tmppath)
+ try:
+ enabled = config.is_enabled()
+ except AttributeError:
+ pass
+ sys.path.remove(path)
sys.modules.pop("config")
- opts.Add(BoolVariable("module_" + x + "_enabled", "Enable module '%s'" % (x,), module_enabled))
+ opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled))
-opts.Update(env_base) # update environment
-Help(opts.GenerateHelpText(env_base)) # generate help
+methods.write_modules(modules_detected)
+
+# Update the environment again after all the module options are added.
+opts.Update(env_base)
+Help(opts.GenerateHelpText(env_base))
# add default include paths
@@ -272,14 +301,13 @@ if selected_platform in platform_list:
else:
env = env_base.Clone()
- # Custom tools are loaded automatically by SCons from site_scons/site_tools,
- # but we want to use a different folder, so we register it manually.
- from SCons.Script.Main import _load_site_scons_dir
-
- _load_site_scons_dir(".", "misc/scons")
+ # Compilation DB requires SCons 3.1.1+.
+ from SCons import __version__ as scons_raw_version
- env.Tool("compilation_db")
- env.Alias("compiledb", env.CompilationDatabase("compile_commands.json"))
+ scons_ver = env._get_major_minor_revision(scons_raw_version)
+ if scons_ver >= (3, 1, 1):
+ env.Tool("compilation_db", toolpath=["misc/scons"])
+ env.Alias("compiledb", env.CompilationDatabase("compile_commands.json"))
if env["dev"]:
env["verbose"] = True
@@ -371,7 +399,7 @@ if selected_platform in platform_list:
'newer GCC version, or Clang 6 or later by passing "use_llvm=yes" '
"to the SCons command line."
)
- sys.exit(255)
+ Exit(255)
elif cc_version_major < 7:
print(
"Detected GCC version older than 7, which does not fully support "
@@ -379,7 +407,7 @@ if selected_platform in platform_list:
'version, or Clang 6 or later by passing "use_llvm=yes" to the '
"SCons command line."
)
- sys.exit(255)
+ Exit(255)
elif methods.using_clang(env):
# Apple LLVM versions differ from upstream LLVM version \o/, compare
# in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
@@ -390,19 +418,19 @@ if selected_platform in platform_list:
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
- sys.exit(255)
+ Exit(255)
elif not vanilla and cc_version_major < 10:
print(
"Detected Apple Clang version older than 10, which does not fully "
"support C++17. Supported versions are Apple Clang 10 and later."
)
- sys.exit(255)
+ Exit(255)
elif cc_version_major < 6:
print(
"Detected Clang version older than 6, which does not fully support "
"C++17. Supported versions are Clang 6 and later."
)
- sys.exit(255)
+ Exit(255)
# Configure compiler warnings
if env.msvc:
@@ -475,7 +503,7 @@ if selected_platform in platform_list:
if env["target"] == "release":
if env["tools"]:
print("Tools can only be built with targets 'debug' and 'release_debug'.")
- sys.exit(255)
+ Exit(255)
suffix += ".opt"
env.Append(CPPDEFINES=["NDEBUG"])
@@ -502,41 +530,41 @@ if selected_platform in platform_list:
sys.path.remove(tmppath)
sys.modules.pop("detect")
- env.module_list = []
+ modules_enabled = OrderedDict()
env.module_icons_paths = []
env.doc_class_path = {}
- for x in sorted(module_list):
- if not env["module_" + x + "_enabled"]:
+ for name, path in modules_detected.items():
+ if not env["module_" + name + "_enabled"]:
continue
- tmppath = "./modules/" + x
- sys.path.insert(0, tmppath)
- env.current_module = x
+ sys.path.insert(0, path)
+ env.current_module = name
import config
if config.can_build(env, selected_platform):
config.configure(env)
- env.module_list.append(x)
-
# Get doc classes paths (if present)
try:
doc_classes = config.get_doc_classes()
doc_path = config.get_doc_path()
for c in doc_classes:
- env.doc_class_path[c] = "modules/" + x + "/" + doc_path
+ env.doc_class_path[c] = path + "/" + doc_path
except:
pass
# Get icon paths (if present)
try:
icons_path = config.get_icons_path()
- env.module_icons_paths.append("modules/" + x + "/" + icons_path)
+ env.module_icons_paths.append(path + "/" + icons_path)
except:
# Default path for module icons
- env.module_icons_paths.append("modules/" + x + "/" + "icons")
+ env.module_icons_paths.append(path + "/" + "icons")
+ modules_enabled[name] = path
- sys.path.remove(tmppath)
+ sys.path.remove(path)
sys.modules.pop("config")
+ env.module_list = modules_enabled
+
methods.update_version(env.module_version_string)
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"]
@@ -564,7 +592,7 @@ if selected_platform in platform_list:
"Build option 'disable_3d=yes' cannot be used with 'tools=yes' (editor), "
"only with 'tools=no' (export template)."
)
- sys.exit(255)
+ Exit(255)
else:
env.Append(CPPDEFINES=["_3D_DISABLED"])
if env["disable_advanced_gui"]:
@@ -573,21 +601,19 @@ if selected_platform in platform_list:
"Build option 'disable_advanced_gui=yes' cannot be used with 'tools=yes' (editor), "
"only with 'tools=no' (export template)."
)
- sys.exit(255)
+ Exit(255)
else:
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
if env["minizip"]:
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
editor_module_list = ["regex"]
- for x in editor_module_list:
- if not env["module_" + x + "_enabled"]:
- if env["tools"]:
- print(
- "Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), "
- "only with 'tools=no' (export template)."
- )
- sys.exit(255)
+ if env["tools"] and not env.module_check_dependencies("tools", editor_module_list):
+ print(
+ "Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), "
+ "only with 'tools=no' (export template)."
+ )
+ Exit(255)
if not env["verbose"]:
methods.no_verbose(sys, env)
@@ -663,126 +689,13 @@ elif selected_platform != "":
if selected_platform == "list":
# Exit early to suppress the rest of the built-in SCons messages
- sys.exit(0)
+ Exit()
else:
- sys.exit(255)
+ Exit(255)
-# The following only makes sense when the env is defined, and assumes it is
+# The following only makes sense when the 'env' is defined, and assumes it is.
if "env" in locals():
- screen = sys.stdout
- # Progress reporting is not available in non-TTY environments since it
- # messes with the output (for example, when writing to a file)
- show_progress = env["progress"] and sys.stdout.isatty()
- node_count = 0
- node_count_max = 0
- node_count_interval = 1
- node_count_fname = str(env.Dir("#")) + "/.scons_node_count"
-
- import time, math
-
- class cache_progress:
- # The default is 1 GB cache and 12 hours half life
- def __init__(self, path=None, limit=1073741824, half_life=43200):
- self.path = path
- self.limit = limit
- self.exponent_scale = math.log(2) / half_life
- if env["verbose"] and path != None:
- screen.write(
- "Current cache limit is {} (used: {})\n".format(
- self.convert_size(limit), self.convert_size(self.get_size(path))
- )
- )
- self.delete(self.file_list())
-
- def __call__(self, node, *args, **kw):
- global node_count, node_count_max, node_count_interval, node_count_fname, show_progress
- if show_progress:
- # Print the progress percentage
- node_count += node_count_interval
- if node_count_max > 0 and node_count <= node_count_max:
- screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max))
- screen.flush()
- elif node_count_max > 0 and node_count > node_count_max:
- screen.write("\r[100%] ")
- screen.flush()
- else:
- screen.write("\r[Initial build] ")
- screen.flush()
-
- def delete(self, files):
- if len(files) == 0:
- return
- if env["verbose"]:
- # Utter something
- screen.write("\rPurging %d %s from cache...\n" % (len(files), len(files) > 1 and "files" or "file"))
- [os.remove(f) for f in files]
-
- def file_list(self):
- if self.path is None:
- # Nothing to do
- return []
- # Gather a list of (filename, (size, atime)) within the
- # cache directory
- file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, "*", "*"))]
- if file_stat == []:
- # Nothing to do
- return []
- # Weight the cache files by size (assumed to be roughly
- # proportional to the recompilation time) times an exponential
- # decay since the ctime, and return a list with the entries
- # (filename, size, weight).
- current_time = time.time()
- file_stat = [(x[0], x[1][0], (current_time - x[1][1])) for x in file_stat]
- # Sort by the most recently accessed files (most sensible to keep) first
- file_stat.sort(key=lambda x: x[2])
- # Search for the first entry where the storage limit is
- # reached
- sum, mark = 0, None
- for i, x in enumerate(file_stat):
- sum += x[1]
- if sum > self.limit:
- mark = i
- break
- if mark is None:
- return []
- else:
- return [x[0] for x in file_stat[mark:]]
-
- def convert_size(self, size_bytes):
- if size_bytes == 0:
- return "0 bytes"
- size_name = ("bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
- i = int(math.floor(math.log(size_bytes, 1024)))
- p = math.pow(1024, i)
- s = round(size_bytes / p, 2)
- return "%s %s" % (int(s) if i == 0 else s, size_name[i])
-
- def get_size(self, start_path="."):
- total_size = 0
- for dirpath, dirnames, filenames in os.walk(start_path):
- for f in filenames:
- fp = os.path.join(dirpath, f)
- total_size += os.path.getsize(fp)
- return total_size
-
- def progress_finish(target, source, env):
- global node_count, progressor
- with open(node_count_fname, "w") as f:
- f.write("%d\n" % node_count)
- progressor.delete(progressor.file_list())
-
- try:
- with open(node_count_fname) as f:
- node_count_max = int(f.readline())
- except:
- pass
-
- cache_directory = os.environ.get("SCONS_CACHE")
- # Simple cache pruning, attached to SCons' progress callback. Trim the
- # cache directory to a size not larger than cache_limit.
- cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
- progressor = cache_progress(cache_directory, cache_limit)
- Progress(progressor, interval=node_count_interval)
-
- progress_finish_command = Command("progress_finish", [], progress_finish)
- AlwaysBuild(progress_finish_command)
+ methods.show_progress(env)
+ # TODO: replace this with `env.Dump(format="json")`
+ # once we start requiring SCons 4.0 as min version.
+ methods.dump(env)
diff --git a/core/SCsub b/core/SCsub
index d53988fae7..80a5f6b623 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -52,7 +52,6 @@ thirdparty_misc_sources = [
"r128.c",
"smaz.c",
# C++ sources
- "hq2x.cpp",
"pcg.cpp",
"triangulator.cpp",
"clipper.cpp",
diff --git a/core/array.cpp b/core/array.cpp
index 7c0129ffde..d1c0688e63 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -46,13 +46,13 @@ public:
};
void Array::_ref(const Array &p_from) const {
-
ArrayPrivate *_fp = p_from._p;
ERR_FAIL_COND(!_fp); // should NOT happen.
- if (_fp == _p)
+ if (_fp == _p) {
return; // whatever it is, nothing to do here move along
+ }
bool success = _fp->refcount.ref();
@@ -64,9 +64,9 @@ void Array::_ref(const Array &p_from) const {
}
void Array::_unref() const {
-
- if (!_p)
+ if (!_p) {
return;
+ }
if (_p->refcount.unref()) {
memdelete(_p);
@@ -75,46 +75,39 @@ void Array::_unref() const {
}
Variant &Array::operator[](int p_idx) {
-
return _p->array.write[p_idx];
}
const Variant &Array::operator[](int p_idx) const {
-
return _p->array[p_idx];
}
int Array::size() const {
-
return _p->array.size();
}
-bool Array::empty() const {
+bool Array::empty() const {
return _p->array.empty();
}
-void Array::clear() {
+void Array::clear() {
_p->array.clear();
}
bool Array::operator==(const Array &p_array) const {
-
return _p == p_array._p;
}
uint32_t Array::hash() const {
-
uint32_t h = hash_djb2_one_32(0);
for (int i = 0; i < _p->array.size(); i++) {
-
h = hash_djb2_one_32(_p->array[i].hash(), h);
}
return h;
}
void Array::_assign(const Array &p_array) {
-
if (_p->typed.type != Variant::OBJECT && _p->typed.type == p_array._p->typed.type) {
//same type or untyped, just reference, shuold be fine
_ref(p_array);
@@ -162,25 +155,22 @@ void Array::_assign(const Array &p_array) {
void Array::operator=(const Array &p_array) {
_assign(p_array);
}
-void Array::push_back(const Variant &p_value) {
+void Array::push_back(const Variant &p_value) {
ERR_FAIL_COND(!_p->typed.validate(p_value, "push_back"));
_p->array.push_back(p_value);
}
Error Array::resize(int p_new_size) {
-
return _p->array.resize(p_new_size);
}
void Array::insert(int p_pos, const Variant &p_value) {
-
ERR_FAIL_COND(!_p->typed.validate(p_value, "insert"));
_p->array.insert(p_pos, p_value);
}
void Array::erase(const Variant &p_value) {
-
ERR_FAIL_COND(!_p->typed.validate(p_value, "erase"));
_p->array.erase(p_value);
}
@@ -196,15 +186,14 @@ Variant Array::back() const {
}
int Array::find(const Variant &p_value, int p_from) const {
-
ERR_FAIL_COND_V(!_p->typed.validate(p_value, "find"), -1);
return _p->array.find(p_value, p_from);
}
int Array::rfind(const Variant &p_value, int p_from) const {
-
- if (_p->array.size() == 0)
+ if (_p->array.size() == 0) {
return -1;
+ }
ERR_FAIL_COND_V(!_p->typed.validate(p_value, "rfind"), -1);
if (p_from < 0) {
@@ -217,7 +206,6 @@ int Array::rfind(const Variant &p_value, int p_from) const {
}
for (int i = p_from; i >= 0; i--) {
-
if (_p->array[i] == p_value) {
return i;
}
@@ -227,20 +215,18 @@ int Array::rfind(const Variant &p_value, int p_from) const {
}
int Array::find_last(const Variant &p_value) const {
-
ERR_FAIL_COND_V(!_p->typed.validate(p_value, "find_last"), -1);
return rfind(p_value);
}
int Array::count(const Variant &p_value) const {
-
ERR_FAIL_COND_V(!_p->typed.validate(p_value, "count"), 0);
- if (_p->array.size() == 0)
+ if (_p->array.size() == 0) {
return 0;
+ }
int amount = 0;
for (int i = 0; i < _p->array.size(); i++) {
-
if (_p->array[i] == p_value) {
amount++;
}
@@ -256,24 +242,20 @@ bool Array::has(const Variant &p_value) const {
}
void Array::remove(int p_pos) {
-
_p->array.remove(p_pos);
}
void Array::set(int p_idx, const Variant &p_value) {
-
ERR_FAIL_COND(!_p->typed.validate(p_value, "set"));
operator[](p_idx) = p_value;
}
const Variant &Array::get(int p_idx) const {
-
return operator[](p_idx);
}
Array Array::duplicate(bool p_deep) const {
-
Array new_arr;
int element_count = size();
new_arr.resize(element_count);
@@ -286,7 +268,6 @@ Array Array::duplicate(bool p_deep) const {
}
int Array::_clamp_slice_index(int p_index) const {
-
int arr_size = size();
int fixed_index = CLAMP(p_index, -arr_size, arr_size - 1);
if (fixed_index < 0) {
@@ -301,14 +282,17 @@ Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // l
ERR_FAIL_COND_V_MSG(p_step == 0, new_arr, "Array slice step size cannot be zero.");
- if (empty()) // Don't try to slice empty arrays.
+ if (empty()) { // Don't try to slice empty arrays.
return new_arr;
+ }
if (p_step > 0) {
- if (p_begin >= size() || p_end < -size())
+ if (p_begin >= size() || p_end < -size()) {
return new_arr;
+ }
} else { // p_step < 0
- if (p_begin < -size() || p_end >= size())
+ if (p_begin < -size() || p_end >= size()) {
return new_arr;
+ }
}
int begin = _clamp_slice_index(p_begin);
@@ -335,40 +319,37 @@ Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // l
}
struct _ArrayVariantSort {
-
_FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const {
bool valid = false;
Variant res;
Variant::evaluate(Variant::OP_LESS, p_l, p_r, res, valid);
- if (!valid)
+ if (!valid) {
res = false;
+ }
return res;
}
};
Array &Array::sort() {
-
_p->array.sort_custom<_ArrayVariantSort>();
return *this;
}
struct _ArrayVariantSortCustom {
-
Object *obj;
StringName func;
_FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const {
-
const Variant *args[2] = { &p_l, &p_r };
Callable::CallError err;
bool res = obj->call(func, args, 2, err);
- if (err.error != Callable::CallError::CALL_OK)
+ if (err.error != Callable::CallError::CALL_OK) {
res = false;
+ }
return res;
}
};
Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
-
ERR_FAIL_NULL_V(p_obj, *this);
SortArray<Variant, _ArrayVariantSortCustom, true> avs;
@@ -379,10 +360,10 @@ Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
}
void Array::shuffle() {
-
const int n = _p->array.size();
- if (n < 2)
+ if (n < 2) {
return;
+ }
Variant *data = _p->array.ptrw();
for (int i = n - 1; i >= 1; i--) {
const int j = Math::rand() % (i + 1);
@@ -394,7 +375,6 @@ void Array::shuffle() {
template <typename Less>
_FORCE_INLINE_ int bisect(const Vector<Variant> &p_array, const Variant &p_value, bool p_before, const Less &p_less) {
-
int lo = 0;
int hi = p_array.size();
if (p_before) {
@@ -420,13 +400,11 @@ _FORCE_INLINE_ int bisect(const Vector<Variant> &p_array, const Variant &p_value
}
int Array::bsearch(const Variant &p_value, bool p_before) {
-
ERR_FAIL_COND_V(!_p->typed.validate(p_value, "binary search"), -1);
return bisect(_p->array, p_value, p_before, _ArrayVariantSort());
}
int Array::bsearch_custom(const Variant &p_value, Object *p_obj, const StringName &p_function, bool p_before) {
-
ERR_FAIL_COND_V(!_p->typed.validate(p_value, "custom binary search"), -1);
ERR_FAIL_NULL_V(p_obj, 0);
@@ -438,19 +416,16 @@ int Array::bsearch_custom(const Variant &p_value, Object *p_obj, const StringNam
}
Array &Array::invert() {
-
_p->array.invert();
return *this;
}
void Array::push_front(const Variant &p_value) {
-
ERR_FAIL_COND(!_p->typed.validate(p_value, "push_front"));
_p->array.insert(0, p_value);
}
Variant Array::pop_back() {
-
if (!_p->array.empty()) {
int n = _p->array.size() - 1;
Variant ret = _p->array.get(n);
@@ -461,7 +436,6 @@ Variant Array::pop_back() {
}
Variant Array::pop_front() {
-
if (!_p->array.empty()) {
Variant ret = _p->array.get(0);
_p->array.remove(0);
@@ -471,7 +445,6 @@ Variant Array::pop_front() {
}
Variant Array::min() const {
-
Variant minval;
for (int i = 0; i < size(); i++) {
if (i == 0) {
@@ -494,7 +467,6 @@ Variant Array::min() const {
}
Variant Array::max() const {
-
Variant maxval;
for (int i = 0; i < size(); i++) {
if (i == 0) {
@@ -542,17 +514,15 @@ void Array::set_typed(uint32_t p_type, const StringName &p_class_name, const Var
}
Array::Array(const Array &p_from) {
-
_p = nullptr;
_ref(p_from);
}
Array::Array() {
-
_p = memnew(ArrayPrivate);
_p->refcount.init();
}
-Array::~Array() {
+Array::~Array() {
_unref();
}
diff --git a/core/array.h b/core/array.h
index 14db57f15f..d2e0537ad5 100644
--- a/core/array.h
+++ b/core/array.h
@@ -39,7 +39,6 @@ class Object;
class StringName;
class Array {
-
mutable ArrayPrivate *_p;
void _ref(const Array &p_from) const;
void _unref() const;
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index e2774deb3c..267391c4d6 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -35,7 +35,8 @@
#include "core/io/file_access_encrypted.h"
#include "core/io/json.h"
#include "core/io/marshalls.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
+#include "core/math/geometry_3d.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@@ -62,12 +63,14 @@ static const unsigned int MONTH_DAYS_TABLE[2][12] = {
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
+////// _ResourceLoader //////
+
_ResourceLoader *_ResourceLoader::singleton = nullptr;
Error _ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads) {
-
return ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads);
}
+
_ResourceLoader::ThreadLoadStatus _ResourceLoader::load_threaded_get_status(const String &p_path, Array r_progress) {
float progress = 0;
ResourceLoader::ThreadLoadStatus tls = ResourceLoader::load_threaded_get_status(p_path, &progress);
@@ -75,6 +78,7 @@ _ResourceLoader::ThreadLoadStatus _ResourceLoader::load_threaded_get_status(cons
r_progress[0] = progress;
return (ThreadLoadStatus)tls;
}
+
RES _ResourceLoader::load_threaded_get(const String &p_path) {
Error error;
RES res = ResourceLoader::load_threaded_get(p_path, &error);
@@ -82,7 +86,6 @@ RES _ResourceLoader::load_threaded_get(const String &p_path) {
}
RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache) {
-
Error err = OK;
RES ret = ResourceLoader::load(p_path, p_type_hint, p_no_cache, &err);
@@ -91,12 +94,10 @@ RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool
}
Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String &p_type) {
-
List<String> exts;
ResourceLoader::get_recognized_extensions_for_type(p_type, &exts);
Vector<String> ret;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
@@ -104,12 +105,10 @@ Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String
}
void _ResourceLoader::set_abort_on_missing_resources(bool p_abort) {
-
ResourceLoader::set_abort_on_missing_resources(p_abort);
}
PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) {
-
List<String> deps;
ResourceLoader::get_dependencies(p_path, &deps);
@@ -119,10 +118,9 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) {
}
return ret;
-};
+}
bool _ResourceLoader::has_cached(const String &p_path) {
-
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
}
@@ -132,7 +130,6 @@ bool _ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
}
void _ResourceLoader::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("load_threaded_request", "path", "type_hint", "use_sub_threads"), &_ResourceLoader::load_threaded_request, DEFVAL(""), DEFVAL(false));
ClassDB::bind_method(D_METHOD("load_threaded_get_status", "path", "progress"), &_ResourceLoader::load_threaded_get_status, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("load_threaded_get", "path"), &_ResourceLoader::load_threaded_get);
@@ -150,10 +147,7 @@ void _ResourceLoader::_bind_methods() {
BIND_ENUM_CONSTANT(THREAD_LOAD_LOADED);
}
-_ResourceLoader::_ResourceLoader() {
-
- singleton = this;
-}
+////// _ResourceSaver //////
Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'.");
@@ -161,13 +155,11 @@ Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFla
}
Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) {
-
ERR_FAIL_COND_V_MSG(p_resource.is_null(), Vector<String>(), "It's not a reference to a valid Resource object.");
List<String> exts;
ResourceSaver::get_recognized_extensions(p_resource, &exts);
Vector<String> ret;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
return ret;
@@ -176,7 +168,6 @@ Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource)
_ResourceSaver *_ResourceSaver::singleton = nullptr;
void _ResourceSaver::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &_ResourceSaver::save, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &_ResourceSaver::get_recognized_extensions);
@@ -189,10 +180,7 @@ void _ResourceSaver::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS);
}
-_ResourceSaver::_ResourceSaver() {
-
- singleton = this;
-}
+////// _OS //////
PackedStringArray _OS::get_connected_midi_inputs() {
return OS::get_singleton()->get_connected_midi_inputs();
@@ -207,92 +195,82 @@ void _OS::close_midi_inputs() {
}
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
-
FileAccess::set_backup_save(p_enable);
}
void _OS::set_low_processor_usage_mode(bool p_enabled) {
-
OS::get_singleton()->set_low_processor_usage_mode(p_enabled);
}
-bool _OS::is_in_low_processor_usage_mode() const {
+bool _OS::is_in_low_processor_usage_mode() const {
return OS::get_singleton()->is_in_low_processor_usage_mode();
}
void _OS::set_low_processor_usage_mode_sleep_usec(int p_usec) {
-
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(p_usec);
}
int _OS::get_low_processor_usage_mode_sleep_usec() const {
-
return OS::get_singleton()->get_low_processor_usage_mode_sleep_usec();
}
String _OS::get_executable_path() const {
-
return OS::get_singleton()->get_executable_path();
}
Error _OS::shell_open(String p_uri) {
-
if (p_uri.begins_with("res://")) {
WARN_PRINT("Attempting to open an URL with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`.");
} else if (p_uri.begins_with("user://")) {
WARN_PRINT("Attempting to open an URL with the \"user://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`.");
}
return OS::get_singleton()->shell_open(p_uri);
-};
+}
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output, bool p_read_stderr) {
-
OS::ProcessID pid = -2;
int exitcode = 0;
List<String> args;
- for (int i = 0; i < p_arguments.size(); i++)
+ for (int i = 0; i < p_arguments.size(); i++) {
args.push_back(p_arguments[i]);
+ }
String pipe;
Error err = OS::get_singleton()->execute(p_path, args, p_blocking, &pid, &pipe, &exitcode, p_read_stderr);
p_output.clear();
p_output.push_back(pipe);
- if (err != OK)
+ if (err != OK) {
return -1;
- else if (p_blocking)
+ } else if (p_blocking) {
return exitcode;
- else
+ } else {
return pid;
+ }
}
Error _OS::kill(int p_pid) {
-
return OS::get_singleton()->kill(p_pid);
}
int _OS::get_process_id() const {
-
return OS::get_singleton()->get_process_id();
-};
+}
bool _OS::has_environment(const String &p_var) const {
-
return OS::get_singleton()->has_environment(p_var);
}
-String _OS::get_environment(const String &p_var) const {
+String _OS::get_environment(const String &p_var) const {
return OS::get_singleton()->get_environment(p_var);
}
String _OS::get_name() const {
-
return OS::get_singleton()->get_name();
}
-Vector<String> _OS::get_cmdline_args() {
+Vector<String> _OS::get_cmdline_args() {
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
Vector<String> cmdlinev;
for (List<String>::Element *E = cmdline.front(); E; E = E->next()) {
-
cmdlinev.push_back(E->get());
}
@@ -300,86 +278,34 @@ Vector<String> _OS::get_cmdline_args() {
}
String _OS::get_locale() const {
-
return OS::get_singleton()->get_locale();
}
String _OS::get_model_name() const {
-
return OS::get_singleton()->get_model_name();
}
Error _OS::set_thread_name(const String &p_name) {
-
return Thread::set_name(p_name);
-};
+}
bool _OS::has_feature(const String &p_feature) const {
-
return OS::get_singleton()->has_feature(p_feature);
}
-/*
-enum Weekday {
- DAY_SUNDAY,
- DAY_MONDAY,
- DAY_TUESDAY,
- DAY_WEDNESDAY,
- DAY_THURSDAY,
- DAY_FRIDAY,
- DAY_SATURDAY
-};
-
-enum Month {
- MONTH_JANUARY,
- MONTH_FEBRUARY,
- MONTH_MARCH,
- MONTH_APRIL,
- MONTH_MAY,
- MONTH_JUNE,
- MONTH_JULY,
- MONTH_AUGUST,
- MONTH_SEPTEMBER,
- MONTH_OCTOBER,
- MONTH_NOVEMBER,
- MONTH_DECEMBER
-};
-*/
-/*
-struct Date {
-
- int year;
- Month month;
- int day;
- Weekday weekday;
- bool dst;
-};
-
-struct Time {
-
- int hour;
- int min;
- int sec;
-};
-*/
-
uint64_t _OS::get_static_memory_usage() const {
-
return OS::get_singleton()->get_static_memory_usage();
}
uint64_t _OS::get_static_memory_peak_usage() const {
-
return OS::get_singleton()->get_static_memory_peak_usage();
}
int _OS::get_exit_code() const {
-
return OS::get_singleton()->get_exit_code();
}
void _OS::set_exit_code(int p_code) {
-
if (p_code < 0 || p_code > 125) {
WARN_PRINT("For portability reasons, the exit code should be set between 0 and 125 (inclusive).");
}
@@ -392,7 +318,6 @@ void _OS::set_exit_code(int p_code) {
* dst
*/
Dictionary _OS::get_datetime(bool utc) const {
-
Dictionary dated = get_date(utc);
Dictionary timed = get_time(utc);
@@ -407,7 +332,6 @@ Dictionary _OS::get_datetime(bool utc) const {
}
Dictionary _OS::get_date(bool utc) const {
-
OS::Date date = OS::get_singleton()->get_date(utc);
Dictionary dated;
dated[YEAR_KEY] = date.year;
@@ -419,7 +343,6 @@ Dictionary _OS::get_date(bool utc) const {
}
Dictionary _OS::get_time(bool utc) const {
-
OS::Time time = OS::get_singleton()->get_time(utc);
Dictionary timed;
timed[HOUR_KEY] = time.hour;
@@ -441,7 +364,6 @@ Dictionary _OS::get_time(bool utc) const {
* @return epoch calculated
*/
int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
-
// Bunch of conversion constants
static const unsigned int SECONDS_PER_MINUTE = 60;
static const unsigned int MINUTES_PER_HOUR = 60;
@@ -514,7 +436,6 @@ int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
* @return dictionary of date and time values
*/
Dictionary _OS::get_datetime_from_unix_time(int64_t unix_time_val) const {
-
OS::Date date;
OS::Time time;
@@ -577,71 +498,51 @@ Dictionary _OS::get_time_zone_info() const {
return infod;
}
-uint64_t _OS::get_unix_time() const {
-
+double _OS::get_unix_time() const {
return OS::get_singleton()->get_unix_time();
}
-uint64_t _OS::get_system_time_secs() const {
- return OS::get_singleton()->get_system_time_secs();
-}
-
-uint64_t _OS::get_system_time_msecs() const {
- return OS::get_singleton()->get_system_time_msecs();
-}
-
void _OS::delay_usec(uint32_t p_usec) const {
-
OS::get_singleton()->delay_usec(p_usec);
}
void _OS::delay_msec(uint32_t p_msec) const {
-
OS::get_singleton()->delay_usec(int64_t(p_msec) * 1000);
}
uint32_t _OS::get_ticks_msec() const {
-
return OS::get_singleton()->get_ticks_msec();
}
uint64_t _OS::get_ticks_usec() const {
-
return OS::get_singleton()->get_ticks_usec();
}
uint32_t _OS::get_splash_tick_msec() const {
-
return OS::get_singleton()->get_splash_tick_msec();
}
bool _OS::can_use_threads() const {
-
return OS::get_singleton()->can_use_threads();
}
bool _OS::is_userfs_persistent() const {
-
return OS::get_singleton()->is_userfs_persistent();
}
int _OS::get_processor_count() const {
-
return OS::get_singleton()->get_processor_count();
}
bool _OS::is_stdout_verbose() const {
-
return OS::get_singleton()->is_stdout_verbose();
}
void _OS::dump_memory_to_file(const String &p_file) {
-
OS::get_singleton()->dump_memory_to_file(p_file.utf8().get_data());
}
struct _OSCoreBindImg {
-
String path;
Size2 size;
int fmt;
@@ -651,7 +552,6 @@ struct _OSCoreBindImg {
};
void _OS::print_all_textures_by_size() {
-
List<_OSCoreBindImg> imgs;
int total = 0;
{
@@ -659,9 +559,9 @@ void _OS::print_all_textures_by_size() {
ResourceCache::get_cached_resources(&rsrc);
for (List<Ref<Resource>>::Element *E = rsrc.front(); E; E = E->next()) {
-
- if (!E->get()->is_class("ImageTexture"))
+ if (!E->get()->is_class("ImageTexture")) {
continue;
+ }
Size2 size = E->get()->call("get_size");
int fmt = E->get()->call("get_format");
@@ -680,13 +580,11 @@ void _OS::print_all_textures_by_size() {
imgs.sort();
for (List<_OSCoreBindImg>::Element *E = imgs.front(); E; E = E->next()) {
-
total -= E->get().vram;
}
}
void _OS::print_resources_by_type(const Vector<String> &p_types) {
-
Map<String, int> type_count;
List<Ref<Resource>> resources;
@@ -696,17 +594,18 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) {
ResourceCache::get_cached_resources(&rsrc);
for (List<Ref<Resource>>::Element *E = rsrc.front(); E; E = E->next()) {
-
Ref<Resource> r = E->get();
bool found = false;
for (int i = 0; i < p_types.size(); i++) {
- if (r->is_class(p_types[i]))
+ if (r->is_class(p_types[i])) {
found = true;
+ }
}
- if (!found)
+ if (!found) {
continue;
+ }
if (!type_count.has(r->get_class())) {
type_count[r->get_class()] = 0;
@@ -714,30 +613,25 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) {
type_count[r->get_class()]++;
}
-};
+}
void _OS::print_all_resources(const String &p_to_file) {
-
OS::get_singleton()->print_all_resources(p_to_file);
}
void _OS::print_resources_in_use(bool p_short) {
-
OS::get_singleton()->print_resources_in_use(p_short);
}
void _OS::dump_resources_to_file(const String &p_file) {
-
OS::get_singleton()->dump_resources_to_file(p_file.utf8().get_data());
}
String _OS::get_user_data_dir() const {
-
return OS::get_singleton()->get_user_data_dir();
-};
+}
bool _OS::is_debug_build() const {
-
#ifdef DEBUG_ENABLED
return true;
#else
@@ -746,47 +640,56 @@ bool _OS::is_debug_build() const {
}
String _OS::get_system_dir(SystemDir p_dir) const {
-
return OS::get_singleton()->get_system_dir(OS::SystemDir(p_dir));
}
String _OS::get_keycode_string(uint32_t p_code) const {
-
return keycode_get_string(p_code);
}
bool _OS::is_keycode_unicode(uint32_t p_unicode) const {
-
return keycode_has_unicode(p_unicode);
}
int _OS::find_keycode_from_string(const String &p_code) const {
-
return find_keycode(p_code);
}
bool _OS::request_permission(const String &p_name) {
-
return OS::get_singleton()->request_permission(p_name);
}
bool _OS::request_permissions() {
-
return OS::get_singleton()->request_permissions();
}
Vector<String> _OS::get_granted_permissions() const {
-
return OS::get_singleton()->get_granted_permissions();
}
String _OS::get_unique_id() const {
return OS::get_singleton()->get_unique_id();
}
+
+int _OS::get_tablet_driver_count() const {
+ return OS::get_singleton()->get_tablet_driver_count();
+}
+
+String _OS::get_tablet_driver_name(int p_driver) const {
+ return OS::get_singleton()->get_tablet_driver_name(p_driver);
+}
+
+String _OS::get_current_tablet_driver() const {
+ return OS::get_singleton()->get_current_tablet_driver();
+}
+
+void _OS::set_current_tablet_driver(const String &p_driver) {
+ OS::get_singleton()->set_current_tablet_driver(p_driver);
+}
+
_OS *_OS::singleton = nullptr;
void _OS::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs);
ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs);
@@ -818,8 +721,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_unix_time"), &_OS::get_unix_time);
ClassDB::bind_method(D_METHOD("get_datetime_from_unix_time", "unix_time_val"), &_OS::get_datetime_from_unix_time);
ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime", "datetime"), &_OS::get_unix_time_from_datetime);
- ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
- ClassDB::bind_method(D_METHOD("get_system_time_msecs"), &_OS::get_system_time_msecs);
ClassDB::bind_method(D_METHOD("get_exit_code"), &_OS::get_exit_code);
ClassDB::bind_method(D_METHOD("set_exit_code", "code"), &_OS::set_exit_code);
@@ -839,8 +740,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_debug_build"), &_OS::is_debug_build);
- //ClassDB::bind_method(D_METHOD("get_mouse_button_state"),&_OS::get_mouse_button_state);
-
ClassDB::bind_method(D_METHOD("dump_memory_to_file", "file"), &_OS::dump_memory_to_file);
ClassDB::bind_method(D_METHOD("dump_resources_to_file", "file"), &_OS::dump_resources_to_file);
ClassDB::bind_method(D_METHOD("print_resources_in_use", "short"), &_OS::print_resources_in_use, DEFVAL(false));
@@ -870,9 +769,15 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("request_permissions"), &_OS::request_permissions);
ClassDB::bind_method(D_METHOD("get_granted_permissions"), &_OS::get_granted_permissions);
+ ClassDB::bind_method(D_METHOD("get_tablet_driver_count"), &_OS::get_tablet_driver_count);
+ ClassDB::bind_method(D_METHOD("get_tablet_driver_name", "idx"), &_OS::get_tablet_driver_name);
+ ClassDB::bind_method(D_METHOD("get_current_tablet_driver"), &_OS::get_current_tablet_driver);
+ ClassDB::bind_method(D_METHOD("set_current_tablet_driver", "name"), &_OS::set_current_tablet_driver);
+
ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "tablet_driver"), "set_current_tablet_driver", "get_current_tablet_driver");
// Those default values need to be specified for the docs generator,
// to avoid using values from the documentation writer's own OS instance.
@@ -914,69 +819,43 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES);
}
-_OS::_OS() {
-
- singleton = this;
-}
-
-///////////////////// GEOMETRY
+////// _Geometry2D //////
-_Geometry *_Geometry::singleton = nullptr;
-
-_Geometry *_Geometry::get_singleton() {
+_Geometry2D *_Geometry2D::singleton = nullptr;
+_Geometry2D *_Geometry2D::get_singleton() {
return singleton;
}
-Vector<Plane> _Geometry::build_box_planes(const Vector3 &p_extents) {
-
- return Geometry::build_box_planes(p_extents);
-}
-
-Vector<Plane> _Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
-
- return Geometry::build_cylinder_planes(p_radius, p_height, p_sides, p_axis);
-}
-Vector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
-
- return Geometry::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
+bool _Geometry2D::is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+ return Geometry2D::is_point_in_circle(p_point, p_circle_pos, p_circle_radius);
}
-bool _Geometry::is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
-
- return Geometry::is_point_in_circle(p_point, p_circle_pos, p_circle_radius);
+real_t _Geometry2D::segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+ return Geometry2D::segment_intersects_circle(p_from, p_to, p_circle_pos, p_circle_radius);
}
-real_t _Geometry::segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
-
- return Geometry::segment_intersects_circle(p_from, p_to, p_circle_pos, p_circle_radius);
-}
-
-Variant _Geometry::segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b) {
-
+Variant _Geometry2D::segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b) {
Vector2 result;
- if (Geometry::segment_intersects_segment_2d(p_from_a, p_to_a, p_from_b, p_to_b, &result)) {
-
+ if (Geometry2D::segment_intersects_segment(p_from_a, p_to_a, p_from_b, p_to_b, &result)) {
return result;
} else {
return Variant();
- };
-};
-
-Variant _Geometry::line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b) {
+ }
+}
+Variant _Geometry2D::line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b) {
Vector2 result;
- if (Geometry::line_intersects_line_2d(p_from_a, p_dir_a, p_from_b, p_dir_b, result)) {
+ if (Geometry2D::line_intersects_line(p_from_a, p_dir_a, p_from_b, p_dir_b, result)) {
return result;
} else {
return Variant();
}
}
-Vector<Vector2> _Geometry::get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
-
+Vector<Vector2> _Geometry2D::get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
Vector2 r1, r2;
- Geometry::get_closest_points_between_segments(p1, q1, p2, q2, r1, r2);
+ Geometry2D::get_closest_points_between_segments(p1, q1, p2, q2, r1, r2);
Vector<Vector2> r;
r.resize(2);
r.set(0, r1);
@@ -984,128 +863,42 @@ Vector<Vector2> _Geometry::get_closest_points_between_segments_2d(const Vector2
return r;
}
-Vector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {
-
- Vector3 r1, r2;
- Geometry::get_closest_points_between_segments(p1, p2, q1, q2, r1, r2);
- Vector<Vector3> r;
- r.resize(2);
- r.set(0, r1);
- r.set(1, r2);
- return r;
-}
-Vector2 _Geometry::get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
-
+Vector2 _Geometry2D::get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
Vector2 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment_2d(p_point, s);
-}
-Vector3 _Geometry::get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
-
- Vector3 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment(p_point, s);
+ return Geometry2D::get_closest_point_to_segment(p_point, s);
}
-Vector2 _Geometry::get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
+Vector2 _Geometry2D::get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
Vector2 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment_uncapped_2d(p_point, s);
-}
-Vector3 _Geometry::get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
-
- Vector3 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment_uncapped(p_point, s);
-}
-Variant _Geometry::ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
-
- Vector3 res;
- if (Geometry::ray_intersects_triangle(p_from, p_dir, p_v0, p_v1, p_v2, &res))
- return res;
- else
- return Variant();
-}
-Variant _Geometry::segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
-
- Vector3 res;
- if (Geometry::segment_intersects_triangle(p_from, p_to, p_v0, p_v1, p_v2, &res))
- return res;
- else
- return Variant();
-}
-
-bool _Geometry::point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const {
-
- return Geometry::is_point_in_triangle(s, a, b, c);
-}
-
-Vector<Vector3> _Geometry::segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius) {
-
- Vector<Vector3> r;
- Vector3 res, norm;
- if (!Geometry::segment_intersects_sphere(p_from, p_to, p_sphere_pos, p_sphere_radius, &res, &norm))
- return r;
-
- r.resize(2);
- r.set(0, res);
- r.set(1, norm);
- return r;
-}
-Vector<Vector3> _Geometry::segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius) {
-
- Vector<Vector3> r;
- Vector3 res, norm;
- if (!Geometry::segment_intersects_cylinder(p_from, p_to, p_height, p_radius, &res, &norm))
- return r;
-
- r.resize(2);
- r.set(0, res);
- r.set(1, norm);
- return r;
-}
-Vector<Vector3> _Geometry::segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes) {
-
- Vector<Vector3> r;
- Vector3 res, norm;
- if (!Geometry::segment_intersects_convex(p_from, p_to, p_planes.ptr(), p_planes.size(), &res, &norm))
- return r;
-
- r.resize(2);
- r.set(0, res);
- r.set(1, norm);
- return r;
+ return Geometry2D::get_closest_point_to_segment_uncapped(p_point, s);
}
-bool _Geometry::is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
-
- return Geometry::is_polygon_clockwise(p_polygon);
+bool _Geometry2D::point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const {
+ return Geometry2D::is_point_in_triangle(s, a, b, c);
}
-bool _Geometry::is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon) {
-
- return Geometry::is_point_in_polygon(p_point, p_polygon);
+bool _Geometry2D::is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
+ return Geometry2D::is_polygon_clockwise(p_polygon);
}
-Vector<int> _Geometry::triangulate_polygon(const Vector<Vector2> &p_polygon) {
-
- return Geometry::triangulate_polygon(p_polygon);
+bool _Geometry2D::is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon) {
+ return Geometry2D::is_point_in_polygon(p_point, p_polygon);
}
-Vector<int> _Geometry::triangulate_delaunay_2d(const Vector<Vector2> &p_points) {
-
- return Geometry::triangulate_delaunay_2d(p_points);
+Vector<int> _Geometry2D::triangulate_polygon(const Vector<Vector2> &p_polygon) {
+ return Geometry2D::triangulate_polygon(p_polygon);
}
-Vector<Point2> _Geometry::convex_hull_2d(const Vector<Point2> &p_points) {
-
- return Geometry::convex_hull_2d(p_points);
+Vector<int> _Geometry2D::triangulate_delaunay(const Vector<Vector2> &p_points) {
+ return Geometry2D::triangulate_delaunay(p_points);
}
-Vector<Vector3> _Geometry::clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane) {
-
- return Geometry::clip_polygon(p_points, p_plane);
+Vector<Point2> _Geometry2D::convex_hull(const Vector<Point2> &p_points) {
+ return Geometry2D::convex_hull(p_points);
}
-Array _Geometry::merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2>> polys = Geometry::merge_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::merge_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1115,9 +908,8 @@ Array _Geometry::merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vec
return ret;
}
-Array _Geometry::clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2>> polys = Geometry::clip_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::clip_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1127,9 +919,8 @@ Array _Geometry::clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vect
return ret;
}
-Array _Geometry::intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2>> polys = Geometry::intersect_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::intersect_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1139,9 +930,8 @@ Array _Geometry::intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const
return ret;
}
-Array _Geometry::exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2>> polys = Geometry::exclude_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::exclude_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1151,9 +941,8 @@ Array _Geometry::exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const V
return ret;
}
-Array _Geometry::clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
-
- Vector<Vector<Point2>> polys = Geometry::clip_polyline_with_polygon_2d(p_polyline, p_polygon);
+Array _Geometry2D::clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
+ Vector<Vector<Point2>> polys = Geometry2D::clip_polyline_with_polygon(p_polyline, p_polygon);
Array ret;
@@ -1163,9 +952,8 @@ Array _Geometry::clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline
return ret;
}
-Array _Geometry::intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
-
- Vector<Vector<Point2>> polys = Geometry::intersect_polyline_with_polygon_2d(p_polyline, p_polygon);
+Array _Geometry2D::intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
+ Vector<Vector<Point2>> polys = Geometry2D::intersect_polyline_with_polygon(p_polyline, p_polygon);
Array ret;
@@ -1175,9 +963,8 @@ Array _Geometry::intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_pol
return ret;
}
-Array _Geometry::offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
-
- Vector<Vector<Point2>> polys = Geometry::offset_polygon_2d(p_polygon, p_delta, Geometry::PolyJoinType(p_join_type));
+Array _Geometry2D::offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
+ Vector<Vector<Point2>> polys = Geometry2D::offset_polygon(p_polygon, p_delta, Geometry2D::PolyJoinType(p_join_type));
Array ret;
@@ -1187,9 +974,8 @@ Array _Geometry::offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_de
return ret;
}
-Array _Geometry::offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
-
- Vector<Vector<Point2>> polys = Geometry::offset_polyline_2d(p_polygon, p_delta, Geometry::PolyJoinType(p_join_type), Geometry::PolyEndType(p_end_type));
+Array _Geometry2D::offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
+ Vector<Vector<Point2>> polys = Geometry2D::offset_polyline(p_polygon, p_delta, Geometry2D::PolyJoinType(p_join_type), Geometry2D::PolyEndType(p_end_type));
Array ret;
@@ -1199,86 +985,62 @@ Array _Geometry::offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_d
return ret;
}
-Dictionary _Geometry::make_atlas(const Vector<Size2> &p_rects) {
-
+Dictionary _Geometry2D::make_atlas(const Vector<Size2> &p_rects) {
Dictionary ret;
Vector<Size2i> rects;
for (int i = 0; i < p_rects.size(); i++) {
-
rects.push_back(p_rects[i]);
- };
+ }
Vector<Point2i> result;
Size2i size;
- Geometry::make_atlas(rects, result, size);
+ Geometry2D::make_atlas(rects, result, size);
Size2 r_size = size;
Vector<Point2> r_result;
for (int i = 0; i < result.size(); i++) {
-
r_result.push_back(result[i]);
- };
+ }
ret["points"] = r_result;
ret["size"] = r_size;
return ret;
-};
-
-int _Geometry::get_uv84_normal_bit(const Vector3 &p_vector) {
-
- return Geometry::get_uv84_normal_bit(p_vector);
}
-void _Geometry::_bind_methods() {
+void _Geometry2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("is_point_in_circle", "point", "circle_position", "circle_radius"), &_Geometry2D::is_point_in_circle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_segment", "from_a", "to_a", "from_b", "to_b"), &_Geometry2D::segment_intersects_segment);
+ ClassDB::bind_method(D_METHOD("line_intersects_line", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry2D::line_intersects_line);
- ClassDB::bind_method(D_METHOD("build_box_planes", "extents"), &_Geometry::build_box_planes);
- ClassDB::bind_method(D_METHOD("build_cylinder_planes", "radius", "height", "sides", "axis"), &_Geometry::build_cylinder_planes, DEFVAL(Vector3::AXIS_Z));
- ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
- ClassDB::bind_method(D_METHOD("is_point_in_circle", "point", "circle_position", "circle_radius"), &_Geometry::is_point_in_circle);
- ClassDB::bind_method(D_METHOD("segment_intersects_circle", "segment_from", "segment_to", "circle_position", "circle_radius"), &_Geometry::segment_intersects_circle);
- ClassDB::bind_method(D_METHOD("segment_intersects_segment_2d", "from_a", "to_a", "from_b", "to_b"), &_Geometry::segment_intersects_segment_2d);
- ClassDB::bind_method(D_METHOD("line_intersects_line_2d", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry::line_intersects_line_2d);
+ ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "q1", "p2", "q2"), &_Geometry2D::get_closest_points_between_segments);
- ClassDB::bind_method(D_METHOD("get_closest_points_between_segments_2d", "p1", "q1", "p2", "q2"), &_Geometry::get_closest_points_between_segments_2d);
- ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "p2", "q1", "q2"), &_Geometry::get_closest_points_between_segments);
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "point", "s1", "s2"), &_Geometry2D::get_closest_point_to_segment);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_2d", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment_2d);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment);
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped", "point", "s1", "s2"), &_Geometry2D::get_closest_point_to_segment_uncapped);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped_2d", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment_uncapped_2d);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment_uncapped);
+ ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry2D::point_is_inside_triangle);
- ClassDB::bind_method(D_METHOD("get_uv84_normal_bit", "normal"), &_Geometry::get_uv84_normal_bit);
+ ClassDB::bind_method(D_METHOD("is_polygon_clockwise", "polygon"), &_Geometry2D::is_polygon_clockwise);
+ ClassDB::bind_method(D_METHOD("is_point_in_polygon", "point", "polygon"), &_Geometry2D::is_point_in_polygon);
+ ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry2D::triangulate_polygon);
+ ClassDB::bind_method(D_METHOD("triangulate_delaunay", "points"), &_Geometry2D::triangulate_delaunay);
+ ClassDB::bind_method(D_METHOD("convex_hull", "points"), &_Geometry2D::convex_hull);
- ClassDB::bind_method(D_METHOD("ray_intersects_triangle", "from", "dir", "a", "b", "c"), &_Geometry::ray_intersects_triangle);
- ClassDB::bind_method(D_METHOD("segment_intersects_triangle", "from", "to", "a", "b", "c"), &_Geometry::segment_intersects_triangle);
- ClassDB::bind_method(D_METHOD("segment_intersects_sphere", "from", "to", "sphere_position", "sphere_radius"), &_Geometry::segment_intersects_sphere);
- ClassDB::bind_method(D_METHOD("segment_intersects_cylinder", "from", "to", "height", "radius"), &_Geometry::segment_intersects_cylinder);
- ClassDB::bind_method(D_METHOD("segment_intersects_convex", "from", "to", "planes"), &_Geometry::segment_intersects_convex);
- ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry::point_is_inside_triangle);
+ ClassDB::bind_method(D_METHOD("merge_polygons", "polygon_a", "polygon_b"), &_Geometry2D::merge_polygons);
+ ClassDB::bind_method(D_METHOD("clip_polygons", "polygon_a", "polygon_b"), &_Geometry2D::clip_polygons);
+ ClassDB::bind_method(D_METHOD("intersect_polygons", "polygon_a", "polygon_b"), &_Geometry2D::intersect_polygons);
+ ClassDB::bind_method(D_METHOD("exclude_polygons", "polygon_a", "polygon_b"), &_Geometry2D::exclude_polygons);
- ClassDB::bind_method(D_METHOD("is_polygon_clockwise", "polygon"), &_Geometry::is_polygon_clockwise);
- ClassDB::bind_method(D_METHOD("is_point_in_polygon", "point", "polygon"), &_Geometry::is_point_in_polygon);
- ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry::triangulate_polygon);
- ClassDB::bind_method(D_METHOD("triangulate_delaunay_2d", "points"), &_Geometry::triangulate_delaunay_2d);
- ClassDB::bind_method(D_METHOD("convex_hull_2d", "points"), &_Geometry::convex_hull_2d);
- ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry::clip_polygon);
+ ClassDB::bind_method(D_METHOD("clip_polyline_with_polygon", "polyline", "polygon"), &_Geometry2D::clip_polyline_with_polygon);
+ ClassDB::bind_method(D_METHOD("intersect_polyline_with_polygon", "polyline", "polygon"), &_Geometry2D::intersect_polyline_with_polygon);
- ClassDB::bind_method(D_METHOD("merge_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::merge_polygons_2d);
- ClassDB::bind_method(D_METHOD("clip_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::clip_polygons_2d);
- ClassDB::bind_method(D_METHOD("intersect_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::intersect_polygons_2d);
- ClassDB::bind_method(D_METHOD("exclude_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::exclude_polygons_2d);
+ ClassDB::bind_method(D_METHOD("offset_polygon", "polygon", "delta", "join_type"), &_Geometry2D::offset_polygon, DEFVAL(JOIN_SQUARE));
+ ClassDB::bind_method(D_METHOD("offset_polyline", "polyline", "delta", "join_type", "end_type"), &_Geometry2D::offset_polyline, DEFVAL(JOIN_SQUARE), DEFVAL(END_SQUARE));
- ClassDB::bind_method(D_METHOD("clip_polyline_with_polygon_2d", "polyline", "polygon"), &_Geometry::clip_polyline_with_polygon_2d);
- ClassDB::bind_method(D_METHOD("intersect_polyline_with_polygon_2d", "polyline", "polygon"), &_Geometry::intersect_polyline_with_polygon_2d);
-
- ClassDB::bind_method(D_METHOD("offset_polygon_2d", "polygon", "delta", "join_type"), &_Geometry::offset_polygon_2d, DEFVAL(JOIN_SQUARE));
- ClassDB::bind_method(D_METHOD("offset_polyline_2d", "polyline", "delta", "join_type", "end_type"), &_Geometry::offset_polyline_2d, DEFVAL(JOIN_SQUARE), DEFVAL(END_SQUARE));
-
- ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry::make_atlas);
+ ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry2D::make_atlas);
BIND_ENUM_CONSTANT(OPERATION_UNION);
BIND_ENUM_CONSTANT(OPERATION_DIFFERENCE);
@@ -1296,17 +1058,140 @@ void _Geometry::_bind_methods() {
BIND_ENUM_CONSTANT(END_ROUND);
}
-_Geometry::_Geometry() {
- singleton = this;
+////// _Geometry3D //////
+
+_Geometry3D *_Geometry3D::singleton = nullptr;
+
+_Geometry3D *_Geometry3D::get_singleton() {
+ return singleton;
}
-///////////////////////// FILE
+Vector<Plane> _Geometry3D::build_box_planes(const Vector3 &p_extents) {
+ return Geometry3D::build_box_planes(p_extents);
+}
-Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {
+Vector<Plane> _Geometry3D::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
+ return Geometry3D::build_cylinder_planes(p_radius, p_height, p_sides, p_axis);
+}
+
+Vector<Plane> _Geometry3D::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+ return Geometry3D::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
+}
+
+Vector<Vector3> _Geometry3D::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {
+ Vector3 r1, r2;
+ Geometry3D::get_closest_points_between_segments(p1, p2, q1, q2, r1, r2);
+ Vector<Vector3> r;
+ r.resize(2);
+ r.set(0, r1);
+ r.set(1, r2);
+ return r;
+}
+
+Vector3 _Geometry3D::get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
+ Vector3 s[2] = { p_a, p_b };
+ return Geometry3D::get_closest_point_to_segment(p_point, s);
+}
+
+Vector3 _Geometry3D::get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
+ Vector3 s[2] = { p_a, p_b };
+ return Geometry3D::get_closest_point_to_segment_uncapped(p_point, s);
+}
+
+Variant _Geometry3D::ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
+ Vector3 res;
+ if (Geometry3D::ray_intersects_triangle(p_from, p_dir, p_v0, p_v1, p_v2, &res)) {
+ return res;
+ } else {
+ return Variant();
+ }
+}
+Variant _Geometry3D::segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
+ Vector3 res;
+ if (Geometry3D::segment_intersects_triangle(p_from, p_to, p_v0, p_v1, p_v2, &res)) {
+ return res;
+ } else {
+ return Variant();
+ }
+}
+
+Vector<Vector3> _Geometry3D::segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius) {
+ Vector<Vector3> r;
+ Vector3 res, norm;
+ if (!Geometry3D::segment_intersects_sphere(p_from, p_to, p_sphere_pos, p_sphere_radius, &res, &norm)) {
+ return r;
+ }
+
+ r.resize(2);
+ r.set(0, res);
+ r.set(1, norm);
+ return r;
+}
+
+Vector<Vector3> _Geometry3D::segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius) {
+ Vector<Vector3> r;
+ Vector3 res, norm;
+ if (!Geometry3D::segment_intersects_cylinder(p_from, p_to, p_height, p_radius, &res, &norm)) {
+ return r;
+ }
+
+ r.resize(2);
+ r.set(0, res);
+ r.set(1, norm);
+ return r;
+}
+
+Vector<Vector3> _Geometry3D::segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes) {
+ Vector<Vector3> r;
+ Vector3 res, norm;
+ if (!Geometry3D::segment_intersects_convex(p_from, p_to, p_planes.ptr(), p_planes.size(), &res, &norm)) {
+ return r;
+ }
+
+ r.resize(2);
+ r.set(0, res);
+ r.set(1, norm);
+ return r;
+}
+
+Vector<Vector3> _Geometry3D::clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane) {
+ return Geometry3D::clip_polygon(p_points, p_plane);
+}
+
+int _Geometry3D::get_uv84_normal_bit(const Vector3 &p_vector) {
+ return Geometry3D::get_uv84_normal_bit(p_vector);
+}
+
+void _Geometry3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("build_box_planes", "extents"), &_Geometry3D::build_box_planes);
+ ClassDB::bind_method(D_METHOD("build_cylinder_planes", "radius", "height", "sides", "axis"), &_Geometry3D::build_cylinder_planes, DEFVAL(Vector3::AXIS_Z));
+ ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry3D::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
+
+ ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "p2", "q1", "q2"), &_Geometry3D::get_closest_points_between_segments);
+
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "point", "s1", "s2"), &_Geometry3D::get_closest_point_to_segment);
+
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped", "point", "s1", "s2"), &_Geometry3D::get_closest_point_to_segment_uncapped);
+
+ ClassDB::bind_method(D_METHOD("get_uv84_normal_bit", "normal"), &_Geometry3D::get_uv84_normal_bit);
+
+ ClassDB::bind_method(D_METHOD("ray_intersects_triangle", "from", "dir", "a", "b", "c"), &_Geometry3D::ray_intersects_triangle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_triangle", "from", "to", "a", "b", "c"), &_Geometry3D::segment_intersects_triangle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_sphere", "from", "to", "sphere_position", "sphere_radius"), &_Geometry3D::segment_intersects_sphere);
+ ClassDB::bind_method(D_METHOD("segment_intersects_cylinder", "from", "to", "height", "radius"), &_Geometry3D::segment_intersects_cylinder);
+ ClassDB::bind_method(D_METHOD("segment_intersects_convex", "from", "to", "planes"), &_Geometry3D::segment_intersects_convex);
+
+ ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry3D::clip_polygon);
+}
+
+////// _File //////
+
+Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {
Error err = open(p_path, p_mode_flags);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse(f, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
@@ -1320,10 +1205,10 @@ Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const
}
Error _File::open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass) {
-
Error err = open(p_path, p_mode_flags);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse_password(f, p_pass, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
@@ -1338,7 +1223,6 @@ Error _File::open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, c
}
Error _File::open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode) {
-
FileAccessCompressed *fac = memnew(FileAccessCompressed);
fac->configure("GCPF", (Compression::Mode)p_compress_mode);
@@ -1355,110 +1239,104 @@ Error _File::open_compressed(const String &p_path, ModeFlags p_mode_flags, Compr
}
Error _File::open(const String &p_path, ModeFlags p_mode_flags) {
-
close();
Error err;
f = FileAccess::open(p_path, p_mode_flags, &err);
- if (f)
+ if (f) {
f->set_endian_swap(eswap);
+ }
return err;
}
void _File::close() {
-
- if (f)
+ if (f) {
memdelete(f);
+ }
f = nullptr;
}
-bool _File::is_open() const {
+bool _File::is_open() const {
return f != nullptr;
}
-String _File::get_path() const {
+String _File::get_path() const {
ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_path();
}
String _File::get_path_absolute() const {
-
ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_path_absolute();
}
void _File::seek(int64_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->seek(p_position);
}
-void _File::seek_end(int64_t p_position) {
+void _File::seek_end(int64_t p_position) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->seek_end(p_position);
}
-int64_t _File::get_position() const {
+int64_t _File::get_position() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_position();
}
int64_t _File::get_len() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_len();
}
bool _File::eof_reached() const {
-
ERR_FAIL_COND_V_MSG(!f, false, "File must be opened before use.");
return f->eof_reached();
}
uint8_t _File::get_8() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_8();
}
-uint16_t _File::get_16() const {
+uint16_t _File::get_16() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_16();
}
-uint32_t _File::get_32() const {
+uint32_t _File::get_32() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_32();
}
-uint64_t _File::get_64() const {
+uint64_t _File::get_64() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_64();
}
float _File::get_float() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_float();
}
-double _File::get_double() const {
+double _File::get_double() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_double();
}
-real_t _File::get_real() const {
+real_t _File::get_real() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_real();
}
Vector<uint8_t> _File::get_buffer(int p_length) const {
-
Vector<uint8_t> data;
ERR_FAIL_COND_V_MSG(!f, data, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(p_length < 0, data, "Length of buffer cannot be smaller than 0.");
- if (p_length == 0)
+ if (p_length == 0) {
return data;
+ }
Error err = data.resize(p_length);
ERR_FAIL_COND_V_MSG(err != OK, data, "Can't resize data to " + itos(p_length) + " elements.");
@@ -1467,14 +1345,14 @@ Vector<uint8_t> _File::get_buffer(int p_length) const {
int len = f->get_buffer(&w[0], p_length);
ERR_FAIL_COND_V(len < 0, Vector<uint8_t>());
- if (len < p_length)
+ if (len < p_length) {
data.resize(p_length);
+ }
return data;
}
String _File::get_as_text() const {
-
ERR_FAIL_COND_V_MSG(!f, String(), "File must be opened before use.");
String text;
@@ -1494,17 +1372,14 @@ String _File::get_as_text() const {
}
String _File::get_md5(const String &p_path) const {
-
return FileAccess::get_md5(p_path);
}
String _File::get_sha256(const String &p_path) const {
-
return FileAccess::get_sha256(p_path);
}
String _File::get_line() const {
-
ERR_FAIL_COND_V_MSG(!f, String(), "File must be opened before use.");
return f->get_line();
}
@@ -1520,90 +1395,84 @@ Vector<String> _File::get_csv_line(const String &p_delim) const {
*/
void _File::set_endian_swap(bool p_swap) {
-
eswap = p_swap;
- if (f)
+ if (f) {
f->set_endian_swap(p_swap);
+ }
}
-bool _File::get_endian_swap() {
+bool _File::get_endian_swap() {
return eswap;
}
Error _File::get_error() const {
-
- if (!f)
+ if (!f) {
return ERR_UNCONFIGURED;
+ }
return f->get_error();
}
void _File::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_8(p_dest);
}
-void _File::store_16(uint16_t p_dest) {
+void _File::store_16(uint16_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_16(p_dest);
}
-void _File::store_32(uint32_t p_dest) {
+void _File::store_32(uint32_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_32(p_dest);
}
-void _File::store_64(uint64_t p_dest) {
+void _File::store_64(uint64_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_64(p_dest);
}
void _File::store_float(float p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_float(p_dest);
}
-void _File::store_double(double p_dest) {
+void _File::store_double(double p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_double(p_dest);
}
-void _File::store_real(real_t p_real) {
+void _File::store_real(real_t p_real) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_real(p_real);
}
void _File::store_string(const String &p_string) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_string(p_string);
}
void _File::store_pascal_string(const String &p_string) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_pascal_string(p_string);
-};
+}
String _File::get_pascal_string() {
-
ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_pascal_string();
-};
+}
void _File::store_line(const String &p_string) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_line(p_string);
}
@@ -1614,12 +1483,12 @@ void _File::store_csv_line(const Vector<String> &p_values, const String &p_delim
}
void _File::store_buffer(const Vector<uint8_t> &p_buffer) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
int len = p_buffer.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
const uint8_t *r = p_buffer.ptr();
@@ -1627,12 +1496,10 @@ void _File::store_buffer(const Vector<uint8_t> &p_buffer) {
}
bool _File::file_exists(const String &p_name) const {
-
return FileAccess::exists(p_name);
}
void _File::store_var(const Variant &p_var, bool p_full_objects) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
int len;
Error err = encode_variant(p_var, nullptr, len, p_full_objects);
@@ -1650,7 +1517,6 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
}
Variant _File::get_var(bool p_allow_objects) const {
-
ERR_FAIL_COND_V_MSG(!f, Variant(), "File must be opened before use.");
uint32_t len = get_32();
Vector<uint8_t> buff = get_buffer(len);
@@ -1666,12 +1532,10 @@ Variant _File::get_var(bool p_allow_objects) const {
}
uint64_t _File::get_modified_time(const String &p_file) const {
-
return FileAccess::get_modified_time(p_file);
}
void _File::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("open_encrypted", "path", "mode_flags", "key"), &_File::open_encrypted);
ClassDB::bind_method(D_METHOD("open_encrypted_with_pass", "path", "mode_flags", "pass"), &_File::open_encrypted_pass);
ClassDB::bind_method(D_METHOD("open_compressed", "path", "mode_flags", "compression_mode"), &_File::open_compressed, DEFVAL(0));
@@ -1736,35 +1600,30 @@ void _File::_bind_methods() {
BIND_ENUM_CONSTANT(COMPRESSION_GZIP);
}
-_File::_File() {
-
- f = nullptr;
- eswap = false;
-}
-
_File::~_File() {
-
- if (f)
+ if (f) {
memdelete(f);
+ }
}
-///////////////////////////////////////////////////////
+////// _Directory //////
Error _Directory::open(const String &p_path) {
Error err;
DirAccess *alt = DirAccess::open(p_path, &err);
- if (!alt)
+ if (!alt) {
return err;
- if (d)
+ }
+ if (d) {
memdelete(d);
+ }
d = alt;
return OK;
}
Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
-
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
_list_skip_navigational = p_skip_navigational;
@@ -1774,55 +1633,51 @@ Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
}
String _Directory::get_next() {
-
ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
String next = d->get_next();
while (next != "" && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) {
-
next = d->get_next();
}
return next;
}
-bool _Directory::current_is_dir() const {
+bool _Directory::current_is_dir() const {
ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
return d->current_is_dir();
}
void _Directory::list_dir_end() {
-
ERR_FAIL_COND_MSG(!d, "Directory must be opened before use.");
d->list_dir_end();
}
int _Directory::get_drive_count() {
-
ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
return d->get_drive_count();
}
-String _Directory::get_drive(int p_drive) {
+String _Directory::get_drive(int p_drive) {
ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
return d->get_drive(p_drive);
}
+
int _Directory::get_current_drive() {
ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
return d->get_current_drive();
}
Error _Directory::change_dir(String p_dir) {
-
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
return d->change_dir(p_dir);
}
-String _Directory::get_current_dir() {
+String _Directory::get_current_dir() {
ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
return d->get_current_dir();
}
-Error _Directory::make_dir(String p_dir) {
+Error _Directory::make_dir(String p_dir) {
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir);
@@ -1832,8 +1687,8 @@ Error _Directory::make_dir(String p_dir) {
}
return d->make_dir(p_dir);
}
-Error _Directory::make_dir_recursive(String p_dir) {
+Error _Directory::make_dir_recursive(String p_dir) {
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir);
@@ -1845,7 +1700,6 @@ Error _Directory::make_dir_recursive(String p_dir) {
}
bool _Directory::file_exists(String p_file) {
-
ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
if (!p_file.is_rel_path()) {
@@ -1858,7 +1712,6 @@ bool _Directory::file_exists(String p_file) {
bool _Directory::dir_exists(String p_dir) {
ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
if (!p_dir.is_rel_path()) {
-
DirAccess *d = DirAccess::create_for_path(p_dir);
bool exists = d->dir_exists(p_dir);
memdelete(d);
@@ -1870,18 +1723,16 @@ bool _Directory::dir_exists(String p_dir) {
}
int _Directory::get_space_left() {
-
ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
return d->get_space_left() / 1024 * 1024; //return value in megabytes, given binding is int
}
Error _Directory::copy(String p_from, String p_to) {
-
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
return d->copy(p_from, p_to);
}
-Error _Directory::rename(String p_from, String p_to) {
+Error _Directory::rename(String p_from, String p_to) {
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_from.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_from);
@@ -1892,8 +1743,8 @@ Error _Directory::rename(String p_from, String p_to) {
return d->rename(p_from, p_to);
}
-Error _Directory::remove(String p_name) {
+Error _Directory::remove(String p_name) {
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_name.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_name);
@@ -1906,7 +1757,6 @@ Error _Directory::remove(String p_name) {
}
void _Directory::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("open", "path"), &_Directory::open);
ClassDB::bind_method(D_METHOD("list_dir_begin", "skip_navigational", "skip_hidden"), &_Directory::list_dir_begin, DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_next"), &_Directory::get_next);
@@ -1929,16 +1779,17 @@ void _Directory::_bind_methods() {
}
_Directory::_Directory() {
-
d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
}
_Directory::~_Directory() {
-
- if (d)
+ if (d) {
memdelete(d);
+ }
}
+////// _Marshalls //////
+
_Marshalls *_Marshalls::singleton = nullptr;
_Marshalls *_Marshalls::get_singleton() {
@@ -1946,7 +1797,6 @@ _Marshalls *_Marshalls::get_singleton() {
}
String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects) {
-
int len;
Error err = encode_variant(p_var, nullptr, len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
@@ -1962,10 +1812,9 @@ String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects)
ERR_FAIL_COND_V(ret == "", ret);
return ret;
-};
+}
Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects) {
-
int strlen = p_str.length();
CharString cstr = p_str.ascii();
@@ -1981,17 +1830,15 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant.");
return v;
-};
+}
String _Marshalls::raw_to_base64(const Vector<uint8_t> &p_arr) {
-
String ret = CryptoCore::b64_encode_str(p_arr.ptr(), p_arr.size());
ERR_FAIL_COND_V(ret == "", ret);
return ret;
-};
+}
Vector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
-
int strlen = p_str.length();
CharString cstr = p_str.ascii();
@@ -2006,18 +1853,16 @@ Vector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
buf.resize(arr_len);
return buf;
-};
+}
String _Marshalls::utf8_to_base64(const String &p_str) {
-
CharString cstr = p_str.utf8();
String ret = CryptoCore::b64_encode_str((unsigned char *)cstr.get_data(), cstr.length());
ERR_FAIL_COND_V(ret == "", ret);
return ret;
-};
+}
String _Marshalls::base64_to_utf8(const String &p_str) {
-
int strlen = p_str.length();
CharString cstr = p_str.ascii();
@@ -2032,10 +1877,9 @@ String _Marshalls::base64_to_utf8(const String &p_str) {
String ret = String::utf8((char *)&w[0]);
return ret;
-};
+}
void _Marshalls::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("variant_to_base64", "variant", "full_objects"), &_Marshalls::variant_to_base64, DEFVAL(false));
ClassDB::bind_method(D_METHOD("base64_to_variant", "base64_str", "allow_objects"), &_Marshalls::base64_to_variant, DEFVAL(false));
@@ -2044,60 +1888,51 @@ void _Marshalls::_bind_methods() {
ClassDB::bind_method(D_METHOD("utf8_to_base64", "utf8_str"), &_Marshalls::utf8_to_base64);
ClassDB::bind_method(D_METHOD("base64_to_utf8", "base64_str"), &_Marshalls::base64_to_utf8);
-};
+}
-////////////////
+////// _Semaphore //////
void _Semaphore::wait() {
-
semaphore.wait();
}
Error _Semaphore::try_wait() {
-
return semaphore.try_wait() ? OK : ERR_BUSY;
}
void _Semaphore::post() {
-
semaphore.post();
}
void _Semaphore::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("wait"), &_Semaphore::wait);
ClassDB::bind_method(D_METHOD("try_wait"), &_Semaphore::try_wait);
ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}
-///////////////
+////// _Mutex //////
void _Mutex::lock() {
-
mutex.lock();
}
Error _Mutex::try_lock() {
-
return mutex.try_lock();
}
void _Mutex::unlock() {
-
mutex.unlock();
}
void _Mutex::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("lock"), &_Mutex::lock);
ClassDB::bind_method(D_METHOD("try_lock"), &_Mutex::try_lock);
ClassDB::bind_method(D_METHOD("unlock"), &_Mutex::unlock);
}
-///////////////
+////// _Thread //////
void _Thread::_start_func(void *ud) {
-
Ref<_Thread> *tud = (Ref<_Thread> *)ud;
Ref<_Thread> t = *tud;
memdelete(tud);
@@ -2108,23 +1943,18 @@ void _Thread::_start_func(void *ud) {
t->ret = t->target_instance->call(t->target_method, arg, 1, ce);
if (ce.error != Callable::CallError::CALL_OK) {
-
String reason;
switch (ce.error) {
case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
-
reason = "Invalid Argument #" + itos(ce.argument);
} break;
case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
-
reason = "Too Many Arguments";
} break;
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
-
reason = "Too Few Arguments";
} break;
case Callable::CallError::CALL_ERROR_INVALID_METHOD: {
-
reason = "Method Not Found";
} break;
default: {
@@ -2136,7 +1966,6 @@ void _Thread::_start_func(void *ud) {
}
Error _Thread::start(Object *p_instance, const StringName &p_method, const Variant &p_userdata, Priority p_priority) {
-
ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "Thread already started.");
ERR_FAIL_COND_V(!p_instance, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_method == StringName(), ERR_INVALID_PARAMETER);
@@ -2165,19 +1994,18 @@ Error _Thread::start(Object *p_instance, const StringName &p_method, const Varia
}
String _Thread::get_id() const {
-
- if (!thread)
+ if (!thread) {
return String();
+ }
return itos(thread->get_id());
}
bool _Thread::is_active() const {
-
return active;
}
-Variant _Thread::wait_to_finish() {
+Variant _Thread::wait_to_finish() {
ERR_FAIL_COND_V_MSG(!thread, Variant(), "Thread must exist to wait for its completion.");
ERR_FAIL_COND_V_MSG(!active, Variant(), "Thread must be active to wait for its completion.");
Thread::wait_to_finish(thread);
@@ -2186,15 +2014,15 @@ Variant _Thread::wait_to_finish() {
target_method = StringName();
target_instance = nullptr;
userdata = Variant();
- if (thread)
+ if (thread) {
memdelete(thread);
+ }
thread = nullptr;
return r;
}
void _Thread::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("start", "instance", "method", "userdata", "priority"), &_Thread::start, DEFVAL(Variant()), DEFVAL(PRIORITY_NORMAL));
ClassDB::bind_method(D_METHOD("get_id"), &_Thread::get_id);
ClassDB::bind_method(D_METHOD("is_active"), &_Thread::is_active);
@@ -2204,22 +2032,14 @@ void _Thread::_bind_methods() {
BIND_ENUM_CONSTANT(PRIORITY_NORMAL);
BIND_ENUM_CONSTANT(PRIORITY_HIGH);
}
-_Thread::_Thread() {
-
- active = false;
- thread = nullptr;
- target_instance = nullptr;
-}
_Thread::~_Thread() {
-
ERR_FAIL_COND_MSG(active, "Reference to a Thread object was lost while the thread is still running...");
}
-/////////////////////////////////////
+////// _ClassDB //////
PackedStringArray _ClassDB::get_class_list() const {
-
List<StringName> classes;
ClassDB::get_class_list(&classes);
@@ -2232,8 +2052,8 @@ PackedStringArray _ClassDB::get_class_list() const {
return ret;
}
-PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) const {
+PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) const {
List<StringName> classes;
ClassDB::get_inheriters_from_class(p_class, &classes);
@@ -2246,27 +2066,28 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class)
return ret;
}
-StringName _ClassDB::get_parent_class(const StringName &p_class) const {
+StringName _ClassDB::get_parent_class(const StringName &p_class) const {
return ClassDB::get_parent_class(p_class);
}
-bool _ClassDB::class_exists(const StringName &p_class) const {
+bool _ClassDB::class_exists(const StringName &p_class) const {
return ClassDB::class_exists(p_class);
}
-bool _ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) const {
+bool _ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) const {
return ClassDB::is_parent_class(p_class, p_inherits);
}
-bool _ClassDB::can_instance(const StringName &p_class) const {
+bool _ClassDB::can_instance(const StringName &p_class) const {
return ClassDB::can_instance(p_class);
}
-Variant _ClassDB::instance(const StringName &p_class) const {
+Variant _ClassDB::instance(const StringName &p_class) const {
Object *obj = ClassDB::instance(p_class);
- if (!obj)
+ if (!obj) {
return Variant();
+ }
Reference *r = Object::cast_to<Reference>(obj);
if (r) {
@@ -2277,11 +2098,10 @@ Variant _ClassDB::instance(const StringName &p_class) const {
}
bool _ClassDB::has_signal(StringName p_class, StringName p_signal) const {
-
return ClassDB::has_signal(p_class, p_signal);
}
-Dictionary _ClassDB::get_signal(StringName p_class, StringName p_signal) const {
+Dictionary _ClassDB::get_signal(StringName p_class, StringName p_signal) const {
MethodInfo signal;
if (ClassDB::get_signal(p_class, p_signal, &signal)) {
return signal.operator Dictionary();
@@ -2289,8 +2109,8 @@ Dictionary _ClassDB::get_signal(StringName p_class, StringName p_signal) const {
return Dictionary();
}
}
-Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const {
+Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const {
List<MethodInfo> signals;
ClassDB::get_signal_list(p_class, &signals, p_no_inheritance);
Array ret;
@@ -2303,7 +2123,6 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const
}
Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) const {
-
List<PropertyInfo> plist;
ClassDB::get_property_list(p_class, &plist, p_no_inheritance);
Array ret;
@@ -2332,12 +2151,10 @@ Error _ClassDB::set_property(Object *p_object, const StringName &p_property, con
}
bool _ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inheritance) const {
-
return ClassDB::has_method(p_class, p_method, p_no_inheritance);
}
Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const {
-
List<MethodInfo> methods;
ClassDB::get_method_list(p_class, &methods, p_no_inheritance);
Array ret;
@@ -2356,7 +2173,6 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const
}
PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
-
List<String> constants;
ClassDB::get_integer_constant_list(p_class, &constants, p_no_inheritance);
@@ -2371,31 +2187,27 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class,
}
bool _ClassDB::has_integer_constant(const StringName &p_class, const StringName &p_name) const {
-
bool success;
ClassDB::get_integer_constant(p_class, p_name, &success);
return success;
}
int _ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name) const {
-
bool found;
int c = ClassDB::get_integer_constant(p_class, p_name, &found);
ERR_FAIL_COND_V(!found, 0);
return c;
}
-StringName _ClassDB::get_category(const StringName &p_node) const {
+StringName _ClassDB::get_category(const StringName &p_node) const {
return ClassDB::get_category(p_node);
}
bool _ClassDB::is_class_enabled(StringName p_class) const {
-
return ClassDB::is_class_enabled(p_class);
}
void _ClassDB::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_class_list"), &_ClassDB::get_class_list);
ClassDB::bind_method(D_METHOD("get_inheriters_from_class", "class"), &_ClassDB::get_inheriters_from_class);
ClassDB::bind_method(D_METHOD("get_parent_class", "class"), &_ClassDB::get_parent_class);
@@ -2425,18 +2237,13 @@ void _ClassDB::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_class_enabled", "class"), &_ClassDB::is_class_enabled);
}
-_ClassDB::_ClassDB() {
-}
-_ClassDB::~_ClassDB() {
-}
-///////////////////////////////
+////// _Engine //////
void _Engine::set_iterations_per_second(int p_ips) {
-
Engine::get_singleton()->set_iterations_per_second(p_ips);
}
-int _Engine::get_iterations_per_second() const {
+int _Engine::get_iterations_per_second() const {
return Engine::get_singleton()->get_iterations_per_second();
}
@@ -2461,17 +2268,14 @@ int _Engine::get_target_fps() const {
}
float _Engine::get_frames_per_second() const {
-
return Engine::get_singleton()->get_frames_per_second();
}
uint64_t _Engine::get_physics_frames() const {
-
return Engine::get_singleton()->get_physics_frames();
}
uint64_t _Engine::get_idle_frames() const {
-
return Engine::get_singleton()->get_idle_frames();
}
@@ -2480,23 +2284,19 @@ void _Engine::set_time_scale(float p_scale) {
}
float _Engine::get_time_scale() {
-
return Engine::get_singleton()->get_time_scale();
}
int _Engine::get_frames_drawn() {
-
return Engine::get_singleton()->get_frames_drawn();
}
MainLoop *_Engine::get_main_loop() const {
-
//needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here
return OS::get_singleton()->get_main_loop();
}
Dictionary _Engine::get_version_info() const {
-
return Engine::get_singleton()->get_version_info();
}
@@ -2525,27 +2325,22 @@ bool _Engine::is_in_physics_frame() const {
}
bool _Engine::has_singleton(const String &p_name) const {
-
return Engine::get_singleton()->has_singleton(p_name);
}
Object *_Engine::get_singleton_object(const String &p_name) const {
-
return Engine::get_singleton()->get_singleton_object(p_name);
}
void _Engine::set_editor_hint(bool p_enabled) {
-
Engine::get_singleton()->set_editor_hint(p_enabled);
}
bool _Engine::is_editor_hint() const {
-
return Engine::get_singleton()->is_editor_hint();
}
void _Engine::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second);
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
ClassDB::bind_method(D_METHOD("set_physics_jitter_fix", "physics_jitter_fix"), &_Engine::set_physics_jitter_fix);
@@ -2588,9 +2383,7 @@ void _Engine::_bind_methods() {
_Engine *_Engine::singleton = nullptr;
-_Engine::_Engine() {
- singleton = this;
-}
+////// _JSON //////
void JSONParseResult::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error);
@@ -2663,7 +2456,3 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) {
}
_JSON *_JSON::singleton = nullptr;
-
-_JSON::_JSON() {
- singleton = this;
-}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index d5f44cdc44..f9f5a4e7d7 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -69,7 +69,7 @@ public:
bool has_cached(const String &p_path);
bool exists(const String &p_path, const String &p_type_hint = "");
- _ResourceLoader();
+ _ResourceLoader() { singleton = this; }
};
VARIANT_ENUM_CAST(_ResourceLoader::ThreadLoadStatus);
@@ -98,7 +98,7 @@ public:
Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
Vector<String> get_recognized_extensions(const RES &p_resource);
- _ResourceSaver();
+ _ResourceSaver() { singleton = this; }
};
VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags);
@@ -199,9 +199,7 @@ public:
Dictionary get_datetime_from_unix_time(int64_t unix_time_val) const;
int64_t get_unix_time_from_datetime(Dictionary datetime) const;
Dictionary get_time_zone_info() const;
- uint64_t get_unix_time() const;
- uint64_t get_system_time_secs() const;
- uint64_t get_system_time_msecs() const;
+ double get_unix_time() const;
uint64_t get_static_memory_usage() const;
uint64_t get_static_memory_peak_usage() const;
@@ -243,9 +241,14 @@ public:
bool request_permissions();
Vector<String> get_granted_permissions() const;
+ int get_tablet_driver_count() const;
+ String get_tablet_driver_name(int p_driver) const;
+ String get_current_tablet_driver() const;
+ void set_current_tablet_driver(const String &p_driver);
+
static _OS *get_singleton() { return singleton; }
- _OS();
+ _OS() { singleton = this; }
};
VARIANT_ENUM_CAST(_OS::VideoDriver);
@@ -253,45 +256,31 @@ VARIANT_ENUM_CAST(_OS::Weekday);
VARIANT_ENUM_CAST(_OS::Month);
VARIANT_ENUM_CAST(_OS::SystemDir);
-class _Geometry : public Object {
-
- GDCLASS(_Geometry, Object);
+class _Geometry2D : public Object {
+ GDCLASS(_Geometry2D, Object);
- static _Geometry *singleton;
+ static _Geometry2D *singleton;
protected:
static void _bind_methods();
public:
- static _Geometry *get_singleton();
- Vector<Plane> build_box_planes(const Vector3 &p_extents);
- Vector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
- Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
- Variant segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
- Variant line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
- Vector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
- Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
- Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
- Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
- Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
- Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
- Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
- Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
+ static _Geometry2D *get_singleton();
+ Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
+ Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
+ Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
+ Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
+ Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
- Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
- Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
- Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
- int get_uv84_normal_bit(const Vector3 &p_vector);
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
- Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points);
- Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
- Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
+ Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
+ Vector<Point2> convex_hull(const Vector<Point2> &p_points);
enum PolyBooleanOperation {
OPERATION_UNION,
@@ -300,14 +289,14 @@ public:
OPERATION_XOR
};
// 2D polygon boolean operations.
- Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
- Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
- Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
- Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
+ Array merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
+ Array clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
+ Array intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
+ Array exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
// 2D polyline vs polygon operations.
- Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
- Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
+ Array clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
+ Array intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
// 2D offset polygons/polylines.
enum PolyJoinType {
@@ -322,23 +311,52 @@ public:
END_SQUARE,
END_ROUND
};
- Array offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
- Array offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
+ Array offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
+ Array offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
Dictionary make_atlas(const Vector<Size2> &p_rects);
- _Geometry();
+ _Geometry2D() { singleton = this; }
};
-VARIANT_ENUM_CAST(_Geometry::PolyBooleanOperation);
-VARIANT_ENUM_CAST(_Geometry::PolyJoinType);
-VARIANT_ENUM_CAST(_Geometry::PolyEndType);
+VARIANT_ENUM_CAST(_Geometry2D::PolyBooleanOperation);
+VARIANT_ENUM_CAST(_Geometry2D::PolyJoinType);
+VARIANT_ENUM_CAST(_Geometry2D::PolyEndType);
-class _File : public Reference {
+class _Geometry3D : public Object {
+ GDCLASS(_Geometry3D, Object);
+
+ static _Geometry3D *singleton;
+
+protected:
+ static void _bind_methods();
+public:
+ static _Geometry3D *get_singleton();
+ Vector<Plane> build_box_planes(const Vector3 &p_extents);
+ Vector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
+ Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
+ Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
+ Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
+ Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
+
+ Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
+ Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
+ Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
+ int get_uv84_normal_bit(const Vector3 &p_vector);
+
+ Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
+
+ _Geometry3D() { singleton = this; }
+};
+
+class _File : public Reference {
GDCLASS(_File, Reference);
- FileAccess *f;
- bool eswap;
+
+ FileAccess *f = nullptr;
+ bool eswap = false;
protected:
static void _bind_methods();
@@ -429,7 +447,7 @@ public:
uint64_t get_modified_time(const String &p_file) const;
- _File();
+ _File() {}
virtual ~_File();
};
@@ -437,7 +455,6 @@ VARIANT_ENUM_CAST(_File::ModeFlags);
VARIANT_ENUM_CAST(_File::CompressionMode);
class _Directory : public Reference {
-
GDCLASS(_Directory, Reference);
DirAccess *d;
@@ -481,7 +498,6 @@ private:
};
class _Marshalls : public Object {
-
GDCLASS(_Marshalls, Object);
static _Marshalls *singleton;
@@ -506,7 +522,6 @@ public:
};
class _Mutex : public Reference {
-
GDCLASS(_Mutex, Reference);
Mutex mutex;
@@ -519,7 +534,6 @@ public:
};
class _Semaphore : public Reference {
-
GDCLASS(_Semaphore, Reference);
Semaphore semaphore;
@@ -532,16 +546,15 @@ public:
};
class _Thread : public Reference {
-
GDCLASS(_Thread, Reference);
protected:
Variant ret;
Variant userdata;
- volatile bool active;
- Object *target_instance;
+ volatile bool active = false;
+ Object *target_instance = nullptr;
StringName target_method;
- Thread *thread;
+ Thread *thread = nullptr;
static void _bind_methods();
static void _start_func(void *ud);
@@ -559,14 +572,13 @@ public:
bool is_active() const;
Variant wait_to_finish();
- _Thread();
+ _Thread() {}
~_Thread();
};
VARIANT_ENUM_CAST(_Thread::Priority);
class _ClassDB : public Object {
-
GDCLASS(_ClassDB, Object);
protected:
@@ -600,8 +612,8 @@ public:
bool is_class_enabled(StringName p_class) const;
- _ClassDB();
- ~_ClassDB();
+ _ClassDB() {}
+ ~_ClassDB() {}
};
class _Engine : public Object {
@@ -649,7 +661,7 @@ public:
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
- _Engine();
+ _Engine() { singleton = this; }
};
class _JSON;
@@ -661,7 +673,7 @@ class JSONParseResult : public Reference {
Error error;
String error_string;
- int error_line;
+ int error_line = -1;
Variant result;
@@ -681,8 +693,7 @@ public:
void set_result(const Variant &p_result);
Variant get_result() const;
- JSONParseResult() :
- error_line(-1) {}
+ JSONParseResult() {}
};
class _JSON : public Object {
@@ -698,7 +709,7 @@ public:
String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false);
Ref<JSONParseResult> parse(const String &p_json);
- _JSON();
+ _JSON() { singleton = this; }
};
#endif // CORE_BIND_H
diff --git a/core/callable.cpp b/core/callable.cpp
index 6a5dc151e5..b7bdc715f8 100644
--- a/core/callable.cpp
+++ b/core/callable.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "callable.h"
+
#include "core/script_language.h"
#include "message_queue.h"
#include "object.h"
@@ -39,7 +40,6 @@ void Callable::call_deferred(const Variant **p_arguments, int p_argcount) const
}
void Callable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, CallError &r_call_error) const {
-
if (is_null()) {
r_call_error.error = CallError::CALL_ERROR_INSTANCE_IS_NULL;
r_call_error.argument = 0;
@@ -72,6 +72,7 @@ ObjectID Callable::get_object_id() const {
return ObjectID(object);
}
}
+
StringName Callable::get_method() const {
ERR_FAIL_COND_V_MSG(is_custom(), StringName(),
vformat("Can't get method on CallableCustom \"%s\".", operator String()));
@@ -117,9 +118,11 @@ bool Callable::operator==(const Callable &p_callable) const {
return false;
}
}
+
bool Callable::operator!=(const Callable &p_callable) const {
return !(*this == p_callable);
}
+
bool Callable::operator<(const Callable &p_callable) const {
bool custom_a = is_custom();
bool custom_b = p_callable.is_custom();
@@ -178,7 +181,6 @@ void Callable::operator=(const Callable &p_callable) {
}
Callable::operator String() const {
-
if (is_custom()) {
return custom->get_as_text();
} else {
@@ -191,7 +193,6 @@ Callable::operator String() const {
String class_name = base->get_class();
Ref<Script> script = base->get_script();
if (script.is_valid() && script->get_path().is_resource_file()) {
-
class_name += "(" + script->get_path().get_file() + ")";
}
return class_name + "::" + String(method);
@@ -224,6 +225,7 @@ Callable::Callable(ObjectID p_object, const StringName &p_method) {
object = p_object;
method = p_method;
}
+
Callable::Callable(CallableCustom *p_custom) {
if (p_custom->referenced) {
object = 0;
@@ -233,6 +235,7 @@ Callable::Callable(CallableCustom *p_custom) {
object = 0; //ensure object is all zero, since pointer may be 32 bits
custom = p_custom;
}
+
Callable::Callable(const Callable &p_callable) {
if (p_callable.is_custom()) {
if (!p_callable.custom->ref_count.ref()) {
@@ -255,12 +258,7 @@ Callable::~Callable() {
}
}
-Callable::Callable() {
- object = 0;
-}
-
CallableCustom::CallableCustom() {
- referenced = false;
ref_count.init();
}
@@ -269,9 +267,11 @@ CallableCustom::CallableCustom() {
Object *Signal::get_object() const {
return ObjectDB::get_instance(object);
}
+
ObjectID Signal::get_object_id() const {
return object;
}
+
StringName Signal::get_name() const {
return name;
}
@@ -298,7 +298,6 @@ Signal::operator String() const {
String class_name = base->get_class();
Ref<Script> script = base->get_script();
if (script.is_valid() && script->get_path().is_resource_file()) {
-
class_name += "(" + script->get_path().get_file() + ")";
}
return class_name + "::[signal]" + String(name);
@@ -315,18 +314,20 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const {
return obj->emit_signal(name, p_arguments, p_argcount);
}
-Error Signal::connect(const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
+Error Signal::connect(const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
Object *object = get_object();
ERR_FAIL_COND_V(!object, ERR_UNCONFIGURED);
return object->connect(name, p_callable, p_binds, p_flags);
}
+
void Signal::disconnect(const Callable &p_callable) {
Object *object = get_object();
ERR_FAIL_COND(!object);
object->disconnect(name, p_callable);
}
+
bool Signal::is_connected(const Callable &p_callable) const {
Object *object = get_object();
ERR_FAIL_COND_V(!object, false);
@@ -349,17 +350,15 @@ Array Signal::get_connections() const {
}
return arr;
}
-Signal::Signal(const Object *p_object, const StringName &p_name) {
+Signal::Signal(const Object *p_object, const StringName &p_name) {
ERR_FAIL_COND_MSG(p_object == nullptr, "Object argument to Signal constructor must be non-null");
object = p_object->get_instance_id();
name = p_name;
}
-Signal::Signal(ObjectID p_object, const StringName &p_name) {
+Signal::Signal(ObjectID p_object, const StringName &p_name) {
object = p_object;
name = p_name;
}
-Signal::Signal() {
-}
diff --git a/core/callable.h b/core/callable.h
index 7fa024dccd..7fd6b54cf7 100644
--- a/core/callable.h
+++ b/core/callable.h
@@ -45,11 +45,10 @@ class CallableCustom;
// but can be optimized or customized.
class Callable {
-
//needs to be max 16 bytes in 64 bits
StringName method;
union {
- uint64_t object;
+ uint64_t object = 0;
CallableCustom *custom;
};
@@ -75,7 +74,7 @@ public:
return method == StringName() && object == 0;
}
_FORCE_INLINE_ bool is_custom() const {
- return method == StringName() && custom != 0;
+ return method == StringName() && custom != nullptr;
}
_FORCE_INLINE_ bool is_standard() const {
return method != StringName();
@@ -100,14 +99,14 @@ public:
Callable(ObjectID p_object, const StringName &p_method);
Callable(CallableCustom *p_custom);
Callable(const Callable &p_callable);
- Callable();
+ Callable() {}
~Callable();
};
class CallableCustom {
friend class Callable;
SafeRefCount ref_count;
- bool referenced;
+ bool referenced = false;
public:
typedef bool (*CompareEqualFunc)(const CallableCustom *p_a, const CallableCustom *p_b);
@@ -156,7 +155,7 @@ public:
Array get_connections() const;
Signal(const Object *p_object, const StringName &p_name);
Signal(ObjectID p_object, const StringName &p_name);
- Signal();
+ Signal() {}
};
#endif // CALLABLE_H
diff --git a/core/callable_method_pointer.cpp b/core/callable_method_pointer.cpp
index 8774af6add..21a917cbd7 100644
--- a/core/callable_method_pointer.cpp
+++ b/core/callable_method_pointer.cpp
@@ -48,7 +48,6 @@ bool CallableCustomMethodPointerBase::compare_equal(const CallableCustom *p_a, c
}
bool CallableCustomMethodPointerBase::compare_less(const CallableCustom *p_a, const CallableCustom *p_b) {
-
const CallableCustomMethodPointerBase *a = static_cast<const CallableCustomMethodPointerBase *>(p_a);
const CallableCustomMethodPointerBase *b = static_cast<const CallableCustomMethodPointerBase *>(p_b);
diff --git a/core/callable_method_pointer.h b/core/callable_method_pointer.h
index fb809c2b44..22db7d1c82 100644
--- a/core/callable_method_pointer.h
+++ b/core/callable_method_pointer.h
@@ -38,7 +38,6 @@
#include "core/simple_type.h"
class CallableCustomMethodPointerBase : public CallableCustom {
-
uint32_t *comp_ptr;
uint32_t comp_size;
uint32_t h;
@@ -74,7 +73,6 @@ public:
template <class T>
struct VariantCasterAndValidate {
-
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) {
Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE;
if (!Variant::can_convert_strict(p_args[p_arg_idx]->get_type(), argtype)) {
@@ -89,7 +87,6 @@ struct VariantCasterAndValidate {
template <class T>
struct VariantCasterAndValidate<T &> {
-
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) {
Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE;
if (!Variant::can_convert_strict(p_args[p_arg_idx]->get_type(), argtype)) {
@@ -104,7 +101,6 @@ struct VariantCasterAndValidate<T &> {
template <class T>
struct VariantCasterAndValidate<const T &> {
-
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, Callable::CallError &r_error) {
Variant::Type argtype = GetTypeInfo<T>::VARIANT_TYPE;
if (!Variant::can_convert_strict(p_args[p_arg_idx]->get_type(), argtype)) {
@@ -163,23 +159,37 @@ void call_with_variant_args(T *p_instance, void (T::*p_method)(P...), const Vari
template <class T, class... P>
class CallableCustomMethodPointer : public CallableCustomMethodPointerBase {
-
struct Data {
T *instance;
+#ifdef DEBUG_ENABLED
+ uint64_t object_id;
+#endif
void (T::*method)(P...);
} data;
public:
- virtual ObjectID get_object() const { return data.instance->get_instance_id(); }
+ virtual ObjectID get_object() const {
+#ifdef DEBUG_ENABLED
+ if (ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr) {
+ return ObjectID();
+ }
+#endif
+ return data.instance->get_instance_id();
+ }
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
-
+#ifdef DEBUG_ENABLED
+ ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
+#endif
call_with_variant_args(data.instance, data.method, p_arguments, p_argcount, r_call_error);
}
CallableCustomMethodPointer(T *p_instance, void (T::*p_method)(P...)) {
zeromem(&data, sizeof(Data)); // Clear beforehand, may have padding bytes.
data.instance = p_instance;
+#ifdef DEBUG_ENABLED
+ data.object_id = p_instance->get_instance_id();
+#endif
data.method = p_method;
_setup((uint32_t *)&data, sizeof(Data));
}
@@ -246,24 +256,38 @@ void call_with_variant_args_ret(T *p_instance, R (T::*p_method)(P...), const Var
template <class T, class R, class... P>
class CallableCustomMethodPointerRet : public CallableCustomMethodPointerBase {
-
struct Data {
T *instance;
+#ifdef DEBUG_ENABLED
+ uint64_t object_id;
+#endif
R(T::*method)
(P...);
} data;
public:
- virtual ObjectID get_object() const { return data.instance->get_instance_id(); }
+ virtual ObjectID get_object() const {
+#ifdef DEBUG_ENABLED
+ if (ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr) {
+ return ObjectID();
+ }
+#endif
+ return data.instance->get_instance_id();
+ }
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
-
+#ifdef DEBUG_ENABLED
+ ERR_FAIL_COND_MSG(ObjectDB::get_instance(ObjectID(data.object_id)) == nullptr, "Invalid Object id '" + uitos(data.object_id) + "', can't call method.");
+#endif
call_with_variant_args_ret(data.instance, data.method, p_arguments, p_argcount, r_return_value, r_call_error);
}
CallableCustomMethodPointerRet(T *p_instance, R (T::*p_method)(P...)) {
zeromem(&data, sizeof(Data)); // Clear beforehand, may have padding bytes.
data.instance = p_instance;
+#ifdef DEBUG_ENABLED
+ data.object_id = p_instance->get_instance_id();
+#endif
data.method = p_method;
_setup((uint32_t *)&data, sizeof(Data));
}
diff --git a/core/class_db.cpp b/core/class_db.cpp
index ee93ac73ae..05c9850c39 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -40,14 +40,12 @@
#ifdef DEBUG_METHODS_ENABLED
MethodDefinition D_METHOD(const char *p_name) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
return md;
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.push_back(StaticCString::create(p_arg1));
@@ -55,7 +53,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1) {
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(2);
@@ -65,7 +62,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(3);
@@ -76,7 +72,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(4);
@@ -88,7 +83,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(5);
@@ -101,7 +95,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(6);
@@ -115,7 +108,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(7);
@@ -130,7 +122,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(8);
@@ -146,7 +137,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(9);
@@ -163,7 +153,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(10);
@@ -181,7 +170,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(11);
@@ -200,7 +188,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11, const char *p_arg12) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(12);
@@ -220,7 +207,6 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
}
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11, const char *p_arg12, const char *p_arg13) {
-
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(13);
@@ -245,12 +231,10 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
ClassDB::APIType ClassDB::current_api = API_CORE;
void ClassDB::set_current_api(APIType p_api) {
-
current_api = p_api;
}
ClassDB::APIType ClassDB::get_current_api() {
-
return current_api;
}
@@ -258,42 +242,27 @@ HashMap<StringName, ClassDB::ClassInfo> ClassDB::classes;
HashMap<StringName, StringName> ClassDB::resource_base_extensions;
HashMap<StringName, StringName> ClassDB::compat_classes;
-ClassDB::ClassInfo::ClassInfo() {
-
- api = API_NONE;
- class_ptr = nullptr;
- creation_func = nullptr;
- inherits_ptr = nullptr;
- disabled = false;
- exposed = false;
-}
-
-ClassDB::ClassInfo::~ClassInfo() {
-}
-
bool ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) {
-
OBJTYPE_RLOCK;
StringName inherits = p_class;
while (inherits.operator String().length()) {
-
- if (inherits == p_inherits)
+ if (inherits == p_inherits) {
return true;
+ }
inherits = get_parent_class(inherits);
}
return false;
}
-void ClassDB::get_class_list(List<StringName> *p_classes) {
+void ClassDB::get_class_list(List<StringName> *p_classes) {
OBJTYPE_RLOCK;
const StringName *k = nullptr;
while ((k = classes.next(k))) {
-
p_classes->push_back(*k);
}
@@ -301,43 +270,40 @@ void ClassDB::get_class_list(List<StringName> *p_classes) {
}
void ClassDB::get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes) {
-
OBJTYPE_RLOCK;
const StringName *k = nullptr;
while ((k = classes.next(k))) {
-
- if (*k != p_class && is_parent_class(*k, p_class))
+ if (*k != p_class && is_parent_class(*k, p_class)) {
p_classes->push_back(*k);
+ }
}
}
void ClassDB::get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes) {
-
OBJTYPE_RLOCK;
const StringName *k = nullptr;
while ((k = classes.next(k))) {
-
- if (*k != p_class && get_parent_class(*k) == p_class)
+ if (*k != p_class && get_parent_class(*k) == p_class) {
p_classes->push_back(*k);
+ }
}
}
StringName ClassDB::get_parent_class_nocheck(const StringName &p_class) {
-
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
- if (!ti)
+ if (!ti) {
return StringName();
+ }
return ti->inherits;
}
StringName ClassDB::get_compatibility_remapped_class(const StringName &p_class) {
-
if (classes.has(p_class)) {
return p_class;
}
@@ -350,7 +316,6 @@ StringName ClassDB::get_compatibility_remapped_class(const StringName &p_class)
}
StringName ClassDB::get_parent_class(const StringName &p_class) {
-
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
@@ -359,7 +324,6 @@ StringName ClassDB::get_parent_class(const StringName &p_class) {
}
ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
-
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
@@ -369,7 +333,6 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
}
uint64_t ClassDB::get_api_hash(APIType p_api) {
-
OBJTYPE_RLOCK;
#ifdef DEBUG_METHODS_ENABLED
@@ -380,18 +343,17 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
const StringName *k = nullptr;
while ((k = classes.next(k))) {
-
names.push_back(*k);
}
//must be alphabetically sorted for hash to compute
names.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
ClassInfo *t = classes.getptr(E->get());
ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E->get()) + "'.");
- if (t->api != p_api || !t->exposed)
+ if (t->api != p_api || !t->exposed) {
continue;
+ }
hash = hash_djb2_one_64(t->name.hash(), hash);
hash = hash_djb2_one_64(t->inherits.hash(), hash);
@@ -402,13 +364,13 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
k = nullptr;
while ((k = t->method_map.next(k))) {
-
String name = k->operator String();
ERR_CONTINUE(name.empty());
- if (name[0] == '_')
+ if (name[0] == '_') {
continue; // Ignore non-virtual methods that start with an underscore
+ }
snames.push_back(*k);
}
@@ -416,7 +378,6 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
snames.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
-
MethodBind *mb = t->method_map[F->get()];
hash = hash_djb2_one_64(mb->get_name().hash(), hash);
hash = hash_djb2_one_64(mb->get_argument_count(), hash);
@@ -449,14 +410,12 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
k = nullptr;
while ((k = t->constant_map.next(k))) {
-
snames.push_back(*k);
}
snames.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
-
hash = hash_djb2_one_64(F->get().hash(), hash);
hash = hash_djb2_one_64(t->constant_map[F->get()], hash);
}
@@ -469,14 +428,12 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
k = nullptr;
while ((k = t->signal_map.next(k))) {
-
snames.push_back(*k);
}
snames.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
-
MethodInfo &mi = t->signal_map[F->get()];
hash = hash_djb2_one_64(F->get().hash(), hash);
for (int i = 0; i < mi.arguments.size(); i++) {
@@ -492,14 +449,12 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
k = nullptr;
while ((k = t->property_setget.next(k))) {
-
snames.push_back(*k);
}
snames.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
-
PropertySetGet *psg = t->property_setget.getptr(F->get());
ERR_FAIL_COND_V(!psg, 0);
@@ -511,7 +466,6 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
//property list
for (List<PropertyInfo>::Element *F = t->property_list.front(); F; F = F->next()) {
-
hash = hash_djb2_one_64(F->get().name.hash(), hash);
hash = hash_djb2_one_64(F->get().type, hash);
hash = hash_djb2_one_64(F->get().hint, hash);
@@ -527,19 +481,16 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
}
bool ClassDB::class_exists(const StringName &p_class) {
-
OBJTYPE_RLOCK;
return classes.has(p_class);
}
void ClassDB::add_compatibility_class(const StringName &p_class, const StringName &p_fallback) {
-
OBJTYPE_WLOCK;
compat_classes[p_class] = p_fallback;
}
Object *ClassDB::instance(const StringName &p_class) {
-
ClassInfo *ti;
{
OBJTYPE_RLOCK;
@@ -561,8 +512,8 @@ Object *ClassDB::instance(const StringName &p_class) {
#endif
return ti->creation_func();
}
-bool ClassDB::can_instance(const StringName &p_class) {
+bool ClassDB::can_instance(const StringName &p_class) {
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
@@ -576,7 +527,6 @@ bool ClassDB::can_instance(const StringName &p_class) {
}
void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherits) {
-
OBJTYPE_WLOCK;
const StringName &name = p_class;
@@ -590,7 +540,6 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit
ti.api = current_api;
if (ti.inherits) {
-
ERR_FAIL_COND(!classes.has(ti.inherits)); //it MUST be registered.
ti.inherits_ptr = &classes[ti.inherits];
@@ -600,17 +549,15 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit
}
void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
if (type->disabled) {
-
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
type = type->inherits_ptr;
continue;
@@ -619,22 +566,20 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
#ifdef DEBUG_METHODS_ENABLED
for (List<MethodInfo>::Element *E = type->virtual_methods.front(); E; E = E->next()) {
-
p_methods->push_back(E->get());
}
for (List<StringName>::Element *E = type->method_order.front(); E; E = E->next()) {
-
MethodBind *method = type->method_map.get(E->get());
MethodInfo minfo;
minfo.name = E->get();
minfo.id = method->get_method_id();
- if (p_exclude_from_properties && type->methods_in_properties.has(minfo.name))
+ if (p_exclude_from_properties && type->methods_in_properties.has(minfo.name)) {
continue;
+ }
for (int i = 0; i < method->get_argument_count(); i++) {
-
//Variant::Type t=method->get_argument_type(i);
minfo.arguments.push_back(method->get_argument_info(i));
@@ -644,8 +589,9 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
minfo.flags = method->get_hint_flags();
for (int i = 0; i < method->get_argument_count(); i++) {
- if (method->has_default_argument(i))
+ if (method->has_default_argument(i)) {
minfo.default_arguments.push_back(method->get_default_argument(i));
+ }
}
p_methods->push_back(minfo);
@@ -656,7 +602,6 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
const StringName *K = nullptr;
while ((K = type->method_map.next(K))) {
-
MethodBind *m = type->method_map[*K];
MethodInfo mi;
mi.name = m->get_name();
@@ -665,31 +610,30 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
#endif
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
type = type->inherits_ptr;
}
}
MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
MethodBind **method = type->method_map.getptr(p_name);
- if (method && *method)
+ if (method && *method) {
return *method;
+ }
type = type->inherits_ptr;
}
return nullptr;
}
void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant) {
-
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
@@ -697,7 +641,6 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
ERR_FAIL_COND(!type);
if (type->constant_map.has(p_name)) {
-
ERR_FAIL();
}
@@ -726,16 +669,15 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
}
void ClassDB::get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
#ifdef DEBUG_METHODS_ENABLED
- for (List<StringName>::Element *E = type->constant_order.front(); E; E = E->next())
+ for (List<StringName>::Element *E = type->constant_order.front(); E; E = E->next()) {
p_constants->push_back(E->get());
+ }
#else
const StringName *K = nullptr;
@@ -744,57 +686,56 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
}
#endif
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
type = type->inherits_ptr;
}
}
int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
int *constant = type->constant_map.getptr(p_name);
if (constant) {
-
- if (p_success)
+ if (p_success) {
*p_success = true;
+ }
return *constant;
}
type = type->inherits_ptr;
}
- if (p_success)
+ if (p_success) {
*p_success = false;
+ }
return 0;
}
StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
const StringName *k = nullptr;
while ((k = type->enum_map.next(k))) {
-
List<StringName> &constants_list = type->enum_map.get(*k);
const List<StringName>::Element *found = constants_list.find(p_name);
- if (found)
+ if (found) {
return *k;
+ }
}
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
type = type->inherits_ptr;
}
@@ -803,33 +744,30 @@ StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const S
}
void ClassDB::get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
const StringName *k = nullptr;
while ((k = type->enum_map.next(k))) {
p_enums->push_back(*k);
}
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
type = type->inherits_ptr;
}
}
void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
-
const List<StringName> *constants = type->enum_map.getptr(p_enum);
if (constants) {
@@ -838,15 +776,15 @@ void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_
}
}
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
type = type->inherits_ptr;
}
}
void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
-
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
@@ -866,7 +804,6 @@ void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
}
void ClassDB::get_signal_list(StringName p_class, List<MethodInfo> *p_signals, bool p_no_inheritance) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
@@ -875,28 +812,27 @@ void ClassDB::get_signal_list(StringName p_class, List<MethodInfo> *p_signals, b
ClassInfo *check = type;
while (check) {
-
const StringName *S = nullptr;
while ((S = check->signal_map.next(S))) {
-
p_signals->push_back(check->signal_map[*S]);
}
- if (p_no_inheritance)
+ if (p_no_inheritance) {
return;
+ }
check = check->inherits_ptr;
}
}
bool ClassDB::has_signal(StringName p_class, StringName p_signal) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- if (check->signal_map.has(p_signal))
+ if (check->signal_map.has(p_signal)) {
return true;
+ }
check = check->inherits_ptr;
}
@@ -904,7 +840,6 @@ bool ClassDB::has_signal(StringName p_class, StringName p_signal) {
}
bool ClassDB::get_signal(StringName p_class, StringName p_signal, MethodInfo *r_signal) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
@@ -922,7 +857,6 @@ bool ClassDB::get_signal(StringName p_class, StringName p_signal, MethodInfo *r_
}
void ClassDB::add_property_group(StringName p_class, const String &p_name, const String &p_prefix) {
-
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
ERR_FAIL_COND(!type);
@@ -931,7 +865,6 @@ void ClassDB::add_property_group(StringName p_class, const String &p_name, const
}
void ClassDB::add_property_subgroup(StringName p_class, const String &p_name, const String &p_prefix) {
-
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
ERR_FAIL_COND(!type);
@@ -940,7 +873,6 @@ void ClassDB::add_property_subgroup(StringName p_class, const String &p_name, co
}
void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index) {
-
lock->read_lock();
ClassInfo *type = classes.getptr(p_class);
lock->read_unlock();
@@ -961,7 +893,6 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
MethodBind *mb_get = nullptr;
if (p_getter) {
-
mb_get = get_method(p_class, p_getter);
#ifdef DEBUG_METHODS_ENABLED
@@ -1006,15 +937,12 @@ void ClassDB::set_property_default_value(StringName p_class, const StringName &p
}
void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance, const Object *p_validator) {
-
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
-
for (List<PropertyInfo>::Element *E = check->property_list.front(); E; E = E->next()) {
-
if (p_validator) {
PropertyInfo pi = E->get();
p_validator->_validate_property(pi);
@@ -1024,22 +952,23 @@ void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list,
}
}
- if (p_no_inheritance)
+ if (p_no_inheritance) {
return;
+ }
check = check->inherits_ptr;
}
}
-bool ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid) {
+bool ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid) {
ClassInfo *type = classes.getptr(p_object->get_class_name());
ClassInfo *check = type;
while (check) {
const PropertySetGet *psg = check->property_setget.getptr(p_property);
if (psg) {
-
if (!psg->setter) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return true; //return true but do nothing
}
@@ -1064,8 +993,9 @@ bool ClassDB::set_property(Object *p_object, const StringName &p_property, const
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = ce.error == Callable::CallError::CALL_OK;
+ }
return true;
}
@@ -1075,15 +1005,16 @@ bool ClassDB::set_property(Object *p_object, const StringName &p_property, const
return false;
}
-bool ClassDB::get_property(Object *p_object, const StringName &p_property, Variant &r_value) {
+bool ClassDB::get_property(Object *p_object, const StringName &p_property, Variant &r_value) {
ClassInfo *type = classes.getptr(p_object->get_class_name());
ClassInfo *check = type;
while (check) {
const PropertySetGet *psg = check->property_setget.getptr(p_property);
if (psg) {
- if (!psg->getter)
+ if (!psg->getter) {
return true; //return true but do nothing
+ }
if (psg->index >= 0) {
Variant index = psg->index;
@@ -1092,10 +1023,8 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
r_value = p_object->call(psg->getter, arg, 1, ce);
} else {
-
Callable::CallError ce;
if (psg->_getptr) {
-
r_value = psg->_getptr->call(p_object, nullptr, 0, ce);
} else {
r_value = p_object->call(psg->getter, nullptr, 0, ce);
@@ -1106,7 +1035,6 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
const int *c = check->constant_map.getptr(p_property); //constants count
if (c) {
-
r_value = *c;
return true;
}
@@ -1128,57 +1056,55 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
}
int ClassDB::get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
-
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
const PropertySetGet *psg = check->property_setget.getptr(p_property);
if (psg) {
-
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = true;
+ }
return psg->index;
}
check = check->inherits_ptr;
}
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = false;
+ }
return -1;
}
Variant::Type ClassDB::get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
-
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
const PropertySetGet *psg = check->property_setget.getptr(p_property);
if (psg) {
-
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = true;
+ }
return psg->type;
}
check = check->inherits_ptr;
}
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = false;
+ }
return Variant::NIL;
}
StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_property) {
-
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
const PropertySetGet *psg = check->property_setget.getptr(p_property);
if (psg) {
-
return psg->setter;
}
@@ -1189,13 +1115,11 @@ StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_
}
StringName ClassDB::get_property_getter(StringName p_class, const StringName &p_property) {
-
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
const PropertySetGet *psg = check->property_setget.getptr(p_property);
if (psg) {
-
return psg->getter;
}
@@ -1206,15 +1130,16 @@ StringName ClassDB::get_property_getter(StringName p_class, const StringName &p_
}
bool ClassDB::has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance) {
-
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- if (check->property_setget.has(p_property))
+ if (check->property_setget.has(p_property)) {
return true;
+ }
- if (p_no_inheritance)
+ if (p_no_inheritance) {
break;
+ }
check = check->inherits_ptr;
}
@@ -1222,7 +1147,6 @@ bool ClassDB::has_property(const StringName &p_class, const StringName &p_proper
}
void ClassDB::set_method_flags(StringName p_class, StringName p_method, int p_flags) {
-
OBJTYPE_WLOCK;
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
@@ -1232,14 +1156,15 @@ void ClassDB::set_method_flags(StringName p_class, StringName p_method, int p_fl
}
bool ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inheritance) {
-
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
- if (check->method_map.has(p_method))
+ if (check->method_map.has(p_method)) {
return true;
- if (p_no_inheritance)
+ }
+ if (p_no_inheritance) {
return false;
+ }
check = check->inherits_ptr;
}
@@ -1295,7 +1220,6 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
defvals.resize(p_defcount);
for (int i = 0; i < p_defcount; i++) {
-
defvals.write[i] = *p_defs[p_defcount - i - 1];
}
@@ -1311,15 +1235,15 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
#ifdef DEBUG_METHODS_ENABLED
MethodInfo mi = p_method;
- if (p_virtual)
+ if (p_virtual) {
mi.flags |= METHOD_FLAG_VIRTUAL;
+ }
classes[p_class].virtual_methods.push_back(mi);
#endif
}
void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance) {
-
ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
#ifdef DEBUG_METHODS_ENABLED
@@ -1327,13 +1251,13 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
-
for (List<MethodInfo>::Element *E = check->virtual_methods.front(); E; E = E->next()) {
p_methods->push_back(E->get());
}
- if (p_no_inheritance)
+ if (p_no_inheritance) {
return;
+ }
check = check->inherits_ptr;
}
@@ -1341,7 +1265,6 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p
}
void ClassDB::set_class_enabled(StringName p_class, bool p_enable) {
-
OBJTYPE_WLOCK;
ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
@@ -1349,7 +1272,6 @@ void ClassDB::set_class_enabled(StringName p_class, bool p_enable) {
}
bool ClassDB::is_class_enabled(StringName p_class) {
-
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
@@ -1364,7 +1286,6 @@ bool ClassDB::is_class_enabled(StringName p_class) {
}
bool ClassDB::is_class_exposed(StringName p_class) {
-
OBJTYPE_RLOCK;
ClassInfo *ti = classes.getptr(p_class);
@@ -1373,7 +1294,6 @@ bool ClassDB::is_class_exposed(StringName p_class) {
}
StringName ClassDB::get_category(const StringName &p_node) {
-
ERR_FAIL_COND_V(!classes.has(p_node), StringName());
#ifdef DEBUG_ENABLED
return classes[p_node].category;
@@ -1383,31 +1303,29 @@ StringName ClassDB::get_category(const StringName &p_node) {
}
void ClassDB::add_resource_base_extension(const StringName &p_extension, const StringName &p_class) {
-
- if (resource_base_extensions.has(p_extension))
+ if (resource_base_extensions.has(p_extension)) {
return;
+ }
resource_base_extensions[p_extension] = p_class;
}
void ClassDB::get_resource_base_extensions(List<String> *p_extensions) {
-
const StringName *K = nullptr;
while ((K = resource_base_extensions.next(K))) {
-
p_extensions->push_back(*K);
}
}
void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p_extensions) {
-
const StringName *K = nullptr;
while ((K = resource_base_extensions.next(K))) {
StringName cmp = resource_base_extensions[*K];
- if (is_parent_class(p_class, cmp) || is_parent_class(cmp, p_class))
+ if (is_parent_class(p_class, cmp) || is_parent_class(cmp, p_class)) {
p_extensions->push_back(*K);
+ }
}
}
@@ -1415,9 +1333,7 @@ HashMap<StringName, HashMap<StringName, Variant>> ClassDB::default_values;
Set<StringName> ClassDB::default_values_cached;
Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid) {
-
if (!default_values_cached.has(p_class)) {
-
if (!default_values.has(p_class)) {
default_values[p_class] = HashMap<StringName, Variant>();
}
@@ -1434,12 +1350,10 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
}
if (c) {
-
List<PropertyInfo> plist;
c->get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) {
-
if (!default_values[p_class].has(E->get().name)) {
Variant v = c->get(E->get().name);
default_values[p_class][E->get().name] = v;
@@ -1456,48 +1370,62 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
}
if (!default_values.has(p_class)) {
- if (r_valid != nullptr)
+ if (r_valid != nullptr) {
*r_valid = false;
+ }
return Variant();
}
if (!default_values[p_class].has(p_property)) {
- if (r_valid != nullptr)
+ if (r_valid != nullptr) {
*r_valid = false;
+ }
return Variant();
}
- if (r_valid != nullptr)
+ if (r_valid != nullptr) {
*r_valid = true;
- return default_values[p_class][p_property];
+ }
+
+ Variant var = default_values[p_class][p_property];
+
+#ifdef DEBUG_ENABLED
+ // Some properties may have an instantiated Object as default value,
+ // (like Path2D's `curve` used to have), but that's not a good practice.
+ // Instead, those properties should use PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT
+ // to be auto-instantiated when created in the editor.
+ if (var.get_type() == Variant::OBJECT) {
+ Object *obj = var.get_validated_object();
+ if (obj) {
+ WARN_PRINT(vformat("Instantiated %s used as default value for %s's \"%s\" property.", obj->get_class(), p_class, p_property));
+ }
+ }
+#endif
+
+ return var;
}
RWLock *ClassDB::lock = nullptr;
void ClassDB::init() {
-
lock = RWLock::create();
}
void ClassDB::cleanup_defaults() {
-
default_values.clear();
default_values_cached.clear();
}
void ClassDB::cleanup() {
-
//OBJTYPE_LOCK; hah not here
const StringName *k = nullptr;
while ((k = classes.next(k))) {
-
ClassInfo &ti = classes[*k];
const StringName *m = nullptr;
while ((m = ti.method_map.next(m))) {
-
memdelete(ti.method_map[*m]);
}
}
diff --git a/core/class_db.h b/core/class_db.h
index f760aa1738..eae2a9afd4 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -48,7 +48,6 @@
#ifdef DEBUG_METHODS_ENABLED
struct MethodDefinition {
-
StringName name;
Vector<StringName> args;
MethodDefinition() {}
@@ -103,7 +102,6 @@ public:
public:
struct PropertySetGet {
-
int index;
StringName setter;
StringName getter;
@@ -113,10 +111,10 @@ public:
};
struct ClassInfo {
+ APIType api = API_NONE;
+ ClassInfo *inherits_ptr = nullptr;
+ void *class_ptr = nullptr;
- APIType api;
- ClassInfo *inherits_ptr;
- void *class_ptr;
HashMap<StringName, MethodBind *> method_map;
HashMap<StringName, int> constant_map;
HashMap<StringName, List<StringName>> enum_map;
@@ -133,11 +131,12 @@ public:
StringName inherits;
StringName name;
- bool disabled;
- bool exposed;
- Object *(*creation_func)();
- ClassInfo();
- ~ClassInfo();
+ bool disabled = false;
+ bool exposed = false;
+ Object *(*creation_func)() = nullptr;
+
+ ClassInfo() {}
+ ~ClassInfo() {}
};
template <class T>
@@ -167,13 +166,11 @@ public:
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
template <class T>
static void _add_class() {
-
_add_class2(T::get_class_static(), T::get_parent_class_static());
}
template <class T>
static void register_class() {
-
GLOBAL_LOCK_FUNCTION;
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
@@ -186,7 +183,6 @@ public:
template <class T>
static void register_virtual_class() {
-
GLOBAL_LOCK_FUNCTION;
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
@@ -198,13 +194,11 @@ public:
template <class T>
static Object *_create_ptr_func() {
-
return T::create();
}
template <class T>
static void register_custom_instance_class() {
-
GLOBAL_LOCK_FUNCTION;
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
@@ -231,7 +225,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method) {
-
MethodBind *bind = create_method_bind(p_method);
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, nullptr, 0); //use static function, much smaller binary usage
@@ -239,7 +232,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[1] = { &p_def1 };
@@ -248,7 +240,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[2] = { &p_def1, &p_def2 };
@@ -257,7 +248,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[3] = { &p_def1, &p_def2, &p_def3 };
@@ -266,7 +256,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[4] = { &p_def1, &p_def2, &p_def3, &p_def4 };
@@ -275,7 +264,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[5] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5 };
@@ -284,7 +272,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[6] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6 };
@@ -293,7 +280,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[7] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7 };
@@ -302,7 +288,6 @@ public:
template <class N, class M>
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7, const Variant &p_def8) {
-
MethodBind *bind = create_method_bind(p_method);
const Variant *ptr[8] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7, &p_def8 };
@@ -311,7 +296,6 @@ public:
template <class M>
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
-
GLOBAL_LOCK_FUNCTION;
MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant);
diff --git a/core/color.cpp b/core/color.cpp
index 79b9f70a99..27a2d0af5c 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -36,7 +36,6 @@
#include "core/print_string.h"
uint32_t Color::to_argb32() const {
-
uint32_t c = (uint8_t)Math::round(a * 255);
c <<= 8;
c |= (uint8_t)Math::round(r * 255);
@@ -49,7 +48,6 @@ uint32_t Color::to_argb32() const {
}
uint32_t Color::to_abgr32() const {
-
uint32_t c = (uint8_t)Math::round(a * 255);
c <<= 8;
c |= (uint8_t)Math::round(b * 255);
@@ -62,7 +60,6 @@ uint32_t Color::to_abgr32() const {
}
uint32_t Color::to_rgba32() const {
-
uint32_t c = (uint8_t)Math::round(r * 255);
c <<= 8;
c |= (uint8_t)Math::round(g * 255);
@@ -75,7 +72,6 @@ uint32_t Color::to_rgba32() const {
}
uint64_t Color::to_abgr64() const {
-
uint64_t c = (uint16_t)Math::round(a * 65535);
c <<= 16;
c |= (uint16_t)Math::round(b * 65535);
@@ -88,7 +84,6 @@ uint64_t Color::to_abgr64() const {
}
uint64_t Color::to_argb64() const {
-
uint64_t c = (uint16_t)Math::round(a * 65535);
c <<= 16;
c |= (uint16_t)Math::round(r * 65535);
@@ -101,7 +96,6 @@ uint64_t Color::to_argb64() const {
}
uint64_t Color::to_rgba64() const {
-
uint64_t c = (uint16_t)Math::round(r * 65535);
c <<= 16;
c |= (uint16_t)Math::round(g * 65535);
@@ -114,7 +108,6 @@ uint64_t Color::to_rgba64() const {
}
float Color::get_h() const {
-
float min = MIN(r, g);
min = MIN(min, b);
float max = MAX(r, g);
@@ -122,26 +115,28 @@ float Color::get_h() const {
float delta = max - min;
- if (delta == 0)
+ if (delta == 0) {
return 0;
+ }
float h;
- if (r == max)
+ if (r == max) {
h = (g - b) / delta; // between yellow & magenta
- else if (g == max)
+ } else if (g == max) {
h = 2 + (b - r) / delta; // between cyan & yellow
- else
+ } else {
h = 4 + (r - g) / delta; // between magenta & cyan
+ }
h /= 6.0;
- if (h < 0)
+ if (h < 0) {
h += 1.0;
+ }
return h;
}
float Color::get_s() const {
-
float min = MIN(r, g);
min = MIN(min, b);
float max = MAX(r, g);
@@ -153,14 +148,12 @@ float Color::get_s() const {
}
float Color::get_v() const {
-
float max = MAX(r, g);
max = MAX(max, b);
return max;
}
void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
-
int i;
float f, p, q, t;
a = p_alpha;
@@ -215,25 +208,22 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
}
bool Color::is_equal_approx(const Color &p_color) const {
-
return Math::is_equal_approx(r, p_color.r) && Math::is_equal_approx(g, p_color.g) && Math::is_equal_approx(b, p_color.b) && Math::is_equal_approx(a, p_color.a);
}
void Color::invert() {
-
r = 1.0 - r;
g = 1.0 - g;
b = 1.0 - b;
}
-void Color::contrast() {
+void Color::contrast() {
r = Math::fmod(r + 0.5, 1.0);
g = Math::fmod(g + 0.5, 1.0);
b = Math::fmod(b + 0.5, 1.0);
}
Color Color::hex(uint32_t p_hex) {
-
float a = (p_hex & 0xFF) / 255.0;
p_hex >>= 8;
float b = (p_hex & 0xFF) / 255.0;
@@ -246,7 +236,6 @@ Color Color::hex(uint32_t p_hex) {
}
Color Color::hex64(uint64_t p_hex) {
-
float a = (p_hex & 0xFFFF) / 65535.0;
p_hex >>= 16;
float b = (p_hex & 0xFFFF) / 65535.0;
@@ -259,7 +248,6 @@ Color Color::hex64(uint64_t p_hex) {
}
Color Color::from_rgbe9995(uint32_t p_rgbe) {
-
float r = p_rgbe & 0x1ff;
float g = (p_rgbe >> 9) & 0x1ff;
float b = (p_rgbe >> 18) & 0x1ff;
@@ -274,11 +262,9 @@ Color Color::from_rgbe9995(uint32_t p_rgbe) {
}
static float _parse_col(const String &p_str, int p_ofs) {
-
int ig = 0;
for (int i = 0; i < 2; i++) {
-
int c = p_str[i + p_ofs];
int v = 0;
@@ -294,36 +280,36 @@ static float _parse_col(const String &p_str, int p_ofs) {
return -1;
}
- if (i == 0)
+ if (i == 0) {
ig += v * 16;
- else
+ } else {
ig += v;
+ }
}
return ig;
}
Color Color::inverted() const {
-
Color c = *this;
c.invert();
return c;
}
Color Color::contrasted() const {
-
Color c = *this;
c.contrast();
return c;
}
Color Color::html(const String &p_color) {
-
String color = p_color;
- if (color.length() == 0)
+ if (color.length() == 0) {
return Color();
- if (color[0] == '#')
+ }
+ if (color[0] == '#') {
color = color.substr(1, color.length() - 1);
+ }
if (color.length() == 3 || color.length() == 4) {
String exp_color;
for (int i = 0; i < color.length(); i++) {
@@ -362,13 +348,14 @@ Color Color::html(const String &p_color) {
}
bool Color::html_is_valid(const String &p_color) {
-
String color = p_color;
- if (color.length() == 0)
+ if (color.length() == 0) {
return false;
- if (color[0] == '#')
+ }
+ if (color[0] == '#') {
color = color.substr(1, color.length() - 1);
+ }
bool alpha = false;
@@ -406,8 +393,9 @@ bool Color::html_is_valid(const String &p_color) {
}
Color Color::named(const String &p_name) {
- if (_named_colors.empty())
+ if (_named_colors.empty()) {
_populate_named_colors(); // from color_names.inc
+ }
String name = p_name;
// Normalize name
name = name.replace(" ", "");
@@ -423,19 +411,18 @@ Color Color::named(const String &p_name) {
}
String _to_hex(float p_val) {
-
int v = Math::round(p_val * 255);
v = CLAMP(v, 0, 255);
String ret;
for (int i = 0; i < 2; i++) {
-
CharType c[2] = { 0, 0 };
int lv = v & 0xF;
- if (lv < 10)
+ if (lv < 10) {
c[0] = '0' + lv;
- else
+ } else {
c[0] = 'a' + lv - 10;
+ }
v >>= 4;
String cs = (const CharType *)c;
@@ -446,21 +433,21 @@ String _to_hex(float p_val) {
}
String Color::to_html(bool p_alpha) const {
-
String txt;
txt += _to_hex(r);
txt += _to_hex(g);
txt += _to_hex(b);
- if (p_alpha)
+ if (p_alpha) {
txt = _to_hex(a) + txt;
+ }
return txt;
}
Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const {
-
p_h = Math::fmod(p_h * 360.0f, 360.0f);
- if (p_h < 0.0)
+ if (p_h < 0.0) {
p_h += 360.0f;
+ }
const float h_ = p_h / 60.0f;
const float c = p_v * p_s;
@@ -510,12 +497,10 @@ Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const {
}
Color::operator String() const {
-
return rtos(r) + ", " + rtos(g) + ", " + rtos(b) + ", " + rtos(a);
}
Color Color::operator+(const Color &p_color) const {
-
return Color(
r + p_color.r,
g + p_color.g,
@@ -524,7 +509,6 @@ Color Color::operator+(const Color &p_color) const {
}
Color Color::operator-(const Color &p_color) const {
-
return Color(
r - p_color.r,
g - p_color.g,
@@ -533,7 +517,6 @@ Color Color::operator-(const Color &p_color) const {
}
void Color::operator-=(const Color &p_color) {
-
r = r - p_color.r;
g = g - p_color.g;
b = b - p_color.b;
@@ -541,7 +524,6 @@ void Color::operator-=(const Color &p_color) {
}
Color Color::operator*(const Color &p_color) const {
-
return Color(
r * p_color.r,
g * p_color.g,
@@ -550,7 +532,6 @@ Color Color::operator*(const Color &p_color) const {
}
Color Color::operator*(const real_t &rvalue) const {
-
return Color(
r * rvalue,
g * rvalue,
@@ -559,7 +540,6 @@ Color Color::operator*(const real_t &rvalue) const {
}
void Color::operator*=(const Color &p_color) {
-
r = r * p_color.r;
g = g * p_color.g;
b = b * p_color.b;
@@ -567,7 +547,6 @@ void Color::operator*=(const Color &p_color) {
}
void Color::operator*=(const real_t &rvalue) {
-
r = r * rvalue;
g = g * rvalue;
b = b * rvalue;
@@ -575,7 +554,6 @@ void Color::operator*=(const real_t &rvalue) {
}
Color Color::operator/(const Color &p_color) const {
-
return Color(
r / p_color.r,
g / p_color.g,
@@ -584,7 +562,6 @@ Color Color::operator/(const Color &p_color) const {
}
Color Color::operator/(const real_t &rvalue) const {
-
return Color(
r / rvalue,
g / rvalue,
@@ -593,7 +570,6 @@ Color Color::operator/(const real_t &rvalue) const {
}
void Color::operator/=(const Color &p_color) {
-
r = r / p_color.r;
g = g / p_color.g;
b = b / p_color.b;
@@ -601,7 +577,6 @@ void Color::operator/=(const Color &p_color) {
}
void Color::operator/=(const real_t &rvalue) {
-
if (rvalue == 0) {
r = 1.0;
g = 1.0;
@@ -613,10 +588,9 @@ void Color::operator/=(const real_t &rvalue) {
b = b / rvalue;
a = a / rvalue;
}
-};
+}
Color Color::operator-() const {
-
return Color(
1.0 - r,
1.0 - g,
diff --git a/core/color.h b/core/color.h
index 8b689fdde1..258965fd16 100644
--- a/core/color.h
+++ b/core/color.h
@@ -35,16 +35,14 @@
#include "core/ustring.h"
struct Color {
-
union {
-
struct {
float r;
float g;
float b;
float a;
};
- float components[4];
+ float components[4] = { 0, 0, 0, 1.0 };
};
bool operator==(const Color &p_color) const { return (r == p_color.r && g == p_color.g && b == p_color.b && a == p_color.a); }
@@ -98,7 +96,6 @@ struct Color {
Color contrasted() const;
_FORCE_INLINE_ Color lerp(const Color &p_b, float p_t) const {
-
Color res = *this;
res.r += (p_t * (p_b.r - r));
@@ -110,7 +107,6 @@ struct Color {
}
_FORCE_INLINE_ Color darkened(float p_amount) const {
-
Color res = *this;
res.r = res.r * (1.0f - p_amount);
res.g = res.g * (1.0f - p_amount);
@@ -119,7 +115,6 @@ struct Color {
}
_FORCE_INLINE_ Color lightened(float p_amount) const {
-
Color res = *this;
res.r = res.r + (1.0f - res.r) * p_amount;
res.g = res.g + (1.0f - res.g) * p_amount;
@@ -128,7 +123,6 @@ struct Color {
}
_FORCE_INLINE_ uint32_t to_rgbe9995() const {
-
const float pow2to9 = 512.0f;
const float B = 15.0f;
//const float Emax = 31.0f;
@@ -162,7 +156,6 @@ struct Color {
}
_FORCE_INLINE_ Color blend(const Color &p_over) const {
-
Color res;
float sa = 1.0 - p_over.a;
res.a = a * sa + p_over.a;
@@ -177,7 +170,6 @@ struct Color {
}
_FORCE_INLINE_ Color to_linear() const {
-
return Color(
r < 0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
g < 0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
@@ -185,7 +177,6 @@ struct Color {
a);
}
_FORCE_INLINE_ Color to_srgb() const {
-
return Color(
r < 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math::pow(r, 1.0f / 2.4f) - 0.055,
g < 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math::pow(g, 1.0f / 2.4f) - 0.055,
@@ -204,15 +195,7 @@ struct Color {
_FORCE_INLINE_ bool operator<(const Color &p_color) const; //used in set keys
operator String() const;
- /**
- * No construct parameters, r=0, g=0, b=0. a=1
- */
- _FORCE_INLINE_ Color() {
- r = 0;
- g = 0;
- b = 0;
- a = 1.0;
- }
+ _FORCE_INLINE_ Color() {}
/**
* RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0
@@ -236,17 +219,19 @@ struct Color {
};
bool Color::operator<(const Color &p_color) const {
-
if (r == p_color.r) {
if (g == p_color.g) {
if (b == p_color.b) {
return (a < p_color.a);
- } else
+ } else {
return (b < p_color.b);
- } else
+ }
+ } else {
return g < p_color.g;
- } else
+ }
+ } else {
return r < p_color.r;
+ }
}
#endif // COLOR_H
diff --git a/core/color_names.inc b/core/color_names.inc
index f249ee9868..2b50d88b02 100644
--- a/core/color_names.inc
+++ b/core/color_names.inc
@@ -3,8 +3,9 @@
static Map<String, Color> _named_colors;
static void _populate_named_colors() {
- if (!_named_colors.empty())
+ if (!_named_colors.empty()) {
return;
+ }
_named_colors.insert("aliceblue", Color(0.94, 0.97, 1.00));
_named_colors.insert("antiquewhite", Color(0.98, 0.92, 0.84));
_named_colors.insert("aqua", Color(0.00, 1.00, 1.00));
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp
index 3ce769c72c..ace210ca2c 100644
--- a/core/command_queue_mt.cpp
+++ b/core/command_queue_mt.cpp
@@ -33,30 +33,24 @@
#include "core/os/os.h"
void CommandQueueMT::lock() {
-
mutex.lock();
}
void CommandQueueMT::unlock() {
-
mutex.unlock();
}
void CommandQueueMT::wait_for_flush() {
-
// wait one millisecond for a flush to happen
OS::get_singleton()->delay_usec(1000);
}
CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
-
int idx = -1;
while (true) {
-
lock();
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
-
if (!sync_sems[i].in_use) {
sync_sems[i].in_use = true;
idx = i;
@@ -100,25 +94,14 @@ tryagain:
}
CommandQueueMT::CommandQueueMT(bool p_sync) {
-
- read_ptr = 0;
- write_ptr = 0;
- dealloc_ptr = 0;
- command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE);
-
- for (int i = 0; i < SYNC_SEMAPHORES; i++) {
-
- sync_sems[i].in_use = false;
- }
- if (p_sync)
+ if (p_sync) {
sync = memnew(Semaphore);
- else
- sync = nullptr;
+ }
}
CommandQueueMT::~CommandQueueMT() {
-
- if (sync)
+ if (sync) {
memdelete(sync);
+ }
memfree(command_mem);
}
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 2f2b3b783c..d7a6a5bc43 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -297,22 +297,18 @@
#define MAX_CMD_PARAMS 15
class CommandQueueMT {
-
struct SyncSemaphore {
-
Semaphore sem;
- bool in_use;
+ bool in_use = false;
};
struct CommandBase {
-
virtual void call() = 0;
- virtual void post(){};
- virtual ~CommandBase(){};
+ virtual void post() {}
+ virtual ~CommandBase() {}
};
struct SyncCommand : public CommandBase {
-
SyncSemaphore *sync_sem;
virtual void post() {
@@ -339,17 +335,16 @@ class CommandQueueMT {
SYNC_SEMAPHORES = 8
};
- uint8_t *command_mem;
- uint32_t read_ptr;
- uint32_t write_ptr;
- uint32_t dealloc_ptr;
+ uint8_t *command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE);
+ uint32_t read_ptr = 0;
+ uint32_t write_ptr = 0;
+ uint32_t dealloc_ptr = 0;
SyncSemaphore sync_sems[SYNC_SEMAPHORES];
Mutex mutex;
- Semaphore *sync;
+ Semaphore *sync = nullptr;
template <class T>
T *allocate() {
-
// alloc size is size+T+safeguard
uint32_t alloc_size = ((sizeof(T) + 8 - 1) & ~(8 - 1)) + 8;
@@ -358,7 +353,6 @@ class CommandQueueMT {
if (write_ptr < dealloc_ptr) {
// behind dealloc_ptr, check that there is room
if ((dealloc_ptr - write_ptr) <= alloc_size) {
-
// There is no more room, try to deallocate something
if (dealloc_one()) {
goto tryagain;
@@ -405,12 +399,10 @@ class CommandQueueMT {
template <class T>
T *allocate_and_lock() {
-
lock();
T *ret;
while ((ret = allocate<T>()) == nullptr) {
-
unlock();
// sleep a little until fetch happened and some room is made
wait_for_flush();
@@ -421,14 +413,16 @@ class CommandQueueMT {
}
bool flush_one(bool p_lock = true) {
- if (p_lock)
+ if (p_lock) {
lock();
+ }
tryagain:
// tried to read an empty queue
if (read_ptr == write_ptr) {
- if (p_lock)
+ if (p_lock) {
unlock();
+ }
return false;
}
@@ -447,18 +441,21 @@ class CommandQueueMT {
read_ptr += size;
- if (p_lock)
+ if (p_lock) {
unlock();
+ }
cmd->call();
- if (p_lock)
+ if (p_lock) {
lock();
+ }
cmd->post();
cmd->~CommandBase();
*(uint32_t *)&command_mem[size_ptr] &= ~1;
- if (p_lock)
+ if (p_lock) {
unlock();
+ }
return true;
}
@@ -488,11 +485,10 @@ public:
}
void flush_all() {
-
//ERR_FAIL_COND(sync);
lock();
- while (flush_one(false))
- ;
+ while (flush_one(false)) {
+ }
unlock();
}
diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp
index 0225524bc8..a66997aa52 100644
--- a/core/compressed_translation.cpp
+++ b/core/compressed_translation.cpp
@@ -37,7 +37,6 @@ extern "C" {
}
struct _PHashTranslationCmp {
-
int orig_len;
CharString compressed;
int offset;
@@ -65,7 +64,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int total_string_size = 0;
for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
-
//hash string
CharString cs = E->get().operator String().utf8();
uint32_t h = hash(0, cs.get_data());
@@ -108,21 +106,19 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int bucket_table_size = 0;
for (int i = 0; i < size; i++) {
-
const Vector<Pair<int, CharString>> &b = buckets[i];
Map<uint32_t, int> &t = table.write[i];
- if (b.size() == 0)
+ if (b.size() == 0) {
continue;
+ }
int d = 1;
int item = 0;
while (item < b.size()) {
-
uint32_t slot = hash(d, b[item].second.get_data());
if (t.has(slot)) {
-
item = 0;
d++;
t.clear();
@@ -151,7 +147,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int collisions = 0;
for (int i = 0; i < size; i++) {
-
const Map<uint32_t, int> &t = table[i];
if (t.size() == 0) {
htw[i] = 0xFFFFFFFF; //nothing
@@ -165,7 +160,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
btw[btindex++] = hfunc_table[i];
for (Map<uint32_t, int>::Element *E = t.front(); E; E = E->next()) {
-
btw[btindex++] = E->key();
btw[btindex++] = compressed[E->get()].offset;
btw[btindex++] = compressed[E->get()].compressed.size();
@@ -187,7 +181,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
}
bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name.operator String();
if (name == "hash_table") {
hash_table = p_value;
@@ -197,33 +190,34 @@ bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) {
strings = p_value;
} else if (name == "load_from") {
generate(p_value);
- } else
+ } else {
return false;
+ }
return true;
}
bool PHashTranslation::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name.operator String();
- if (name == "hash_table")
+ if (name == "hash_table") {
r_ret = hash_table;
- else if (name == "bucket_table")
+ } else if (name == "bucket_table") {
r_ret = bucket_table;
- else if (name == "strings")
+ } else if (name == "strings") {
r_ret = strings;
- else
+ } else {
return false;
+ }
return true;
}
StringName PHashTranslation::get_message(const StringName &p_src_text) const {
-
int htsize = hash_table.size();
- if (htsize == 0)
+ if (htsize == 0) {
return StringName();
+ }
CharString str = p_src_text.operator String().utf8();
uint32_t h = hash(0, str.get_data());
@@ -248,9 +242,7 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
int idx = -1;
for (int i = 0; i < bucket.size; i++) {
-
if (bucket.elem[i].key == h) {
-
idx = i;
break;
}
@@ -261,13 +253,11 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
}
if (bucket.elem[idx].comp_size == bucket.elem[idx].uncomp_size) {
-
String rstr;
rstr.parse_utf8(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].uncomp_size);
return rstr;
} else {
-
CharString uncomp;
uncomp.resize(bucket.elem[idx].uncomp_size + 1);
smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size);
@@ -278,16 +268,12 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
}
void PHashTranslation::_get_property_list(List<PropertyInfo> *p_list) const {
-
p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "hash_table"));
p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "bucket_table"));
p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "strings"));
p_list->push_back(PropertyInfo(Variant::OBJECT, "load_from", PROPERTY_HINT_RESOURCE_TYPE, "Translation", PROPERTY_USAGE_EDITOR));
}
-void PHashTranslation::_bind_methods() {
+void PHashTranslation::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate", "from"), &PHashTranslation::generate);
}
-
-PHashTranslation::PHashTranslation() {
-}
diff --git a/core/compressed_translation.h b/core/compressed_translation.h
index d599240dfe..3c029bdf58 100644
--- a/core/compressed_translation.h
+++ b/core/compressed_translation.h
@@ -34,7 +34,6 @@
#include "core/translation.h"
class PHashTranslation : public Translation {
-
GDCLASS(PHashTranslation, Translation);
//this translation uses a sort of modified perfect hash algorithm
@@ -48,12 +47,10 @@ class PHashTranslation : public Translation {
Vector<uint8_t> strings;
struct Bucket {
-
int size;
uint32_t func;
struct Elem {
-
uint32_t key;
uint32_t str_offset;
uint32_t comp_size;
@@ -64,11 +61,10 @@ class PHashTranslation : public Translation {
};
_FORCE_INLINE_ uint32_t hash(uint32_t d, const char *p_str) const {
-
- if (d == 0)
+ if (d == 0) {
d = 0x1000193;
+ }
while (*p_str) {
-
d = (d * 0x1000193) ^ uint32_t(*p_str);
p_str++;
}
@@ -86,7 +82,7 @@ public:
virtual StringName get_message(const StringName &p_src_text) const; //overridable for other implementations
void generate(const Ref<Translation> &p_from);
- PHashTranslation();
+ PHashTranslation() {}
};
#endif // COMPRESSED_TRANSLATION_H
diff --git a/core/container_type_validate.h b/core/container_type_validate.h
index 7809e5f385..f2724e884d 100644
--- a/core/container_type_validate.h
+++ b/core/container_type_validate.h
@@ -35,7 +35,6 @@
#include "core/variant.h"
struct ContainerTypeValidate {
-
Variant::Type type = Variant::NIL;
StringName class_name;
Ref<Script> script;
@@ -76,7 +75,6 @@ struct ContainerTypeValidate {
}
_FORCE_INLINE_ bool validate(const Variant &p_variant, const char *p_operation = "use") {
-
if (type == Variant::NIL) {
return true;
}
diff --git a/core/core_string_names.h b/core/core_string_names.h
index 2ade44f4e0..1a18c84572 100644
--- a/core/core_string_names.h
+++ b/core/core_string_names.h
@@ -34,7 +34,6 @@
#include "core/string_name.h"
class CoreStringNames {
-
friend void register_core_types();
friend void unregister_core_types();
diff --git a/core/cowdata.h b/core/cowdata.h
index 975a572906..82daefb5bd 100644
--- a/core/cowdata.h
+++ b/core/cowdata.h
@@ -54,30 +54,30 @@ class CowData {
friend class VMap;
private:
- mutable T *_ptr;
+ mutable T *_ptr = nullptr;
// internal helpers
_FORCE_INLINE_ uint32_t *_get_refcount() const {
-
- if (!_ptr)
+ if (!_ptr) {
return nullptr;
+ }
return reinterpret_cast<uint32_t *>(_ptr) - 2;
}
_FORCE_INLINE_ uint32_t *_get_size() const {
-
- if (!_ptr)
+ if (!_ptr) {
return nullptr;
+ }
return reinterpret_cast<uint32_t *>(_ptr) - 1;
}
_FORCE_INLINE_ T *_get_data() const {
-
- if (!_ptr)
+ if (!_ptr) {
return nullptr;
+ }
return reinterpret_cast<T *>(_ptr);
}
@@ -125,31 +125,29 @@ public:
_FORCE_INLINE_ int size() const {
uint32_t *size = (uint32_t *)_get_size();
- if (size)
+ if (size) {
return *size;
- else
+ } else {
return 0;
+ }
}
_FORCE_INLINE_ void clear() { resize(0); }
- _FORCE_INLINE_ bool empty() const { return _ptr == 0; }
+ _FORCE_INLINE_ bool empty() const { return _ptr == nullptr; }
_FORCE_INLINE_ void set(int p_index, const T &p_elem) {
-
CRASH_BAD_INDEX(p_index, size());
_copy_on_write();
_get_data()[p_index] = p_elem;
}
_FORCE_INLINE_ T &get_m(int p_index) {
-
CRASH_BAD_INDEX(p_index, size());
_copy_on_write();
return _get_data()[p_index];
}
_FORCE_INLINE_ const T &get(int p_index) const {
-
CRASH_BAD_INDEX(p_index, size());
return _get_data()[p_index];
@@ -158,46 +156,45 @@ public:
Error resize(int p_size);
_FORCE_INLINE_ void remove(int p_index) {
-
ERR_FAIL_INDEX(p_index, size());
T *p = ptrw();
int len = size();
for (int i = p_index; i < len - 1; i++) {
-
p[i] = p[i + 1];
- };
+ }
resize(len - 1);
- };
+ }
Error insert(int p_pos, const T &p_val) {
-
ERR_FAIL_INDEX_V(p_pos, size() + 1, ERR_INVALID_PARAMETER);
resize(size() + 1);
- for (int i = (size() - 1); i > p_pos; i--)
+ for (int i = (size() - 1); i > p_pos; i--) {
set(i, get(i - 1));
+ }
set(p_pos, p_val);
return OK;
- };
+ }
int find(const T &p_val, int p_from = 0) const;
- _FORCE_INLINE_ CowData();
+ _FORCE_INLINE_ CowData() {}
_FORCE_INLINE_ ~CowData();
_FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); };
};
template <class T>
void CowData<T>::_unref(void *p_data) {
-
- if (!p_data)
+ if (!p_data) {
return;
+ }
uint32_t *refc = _get_refcount();
- if (atomic_decrement(refc) > 0)
+ if (atomic_decrement(refc) > 0) {
return; // still in use
+ }
// clean up
if (!__has_trivial_destructor(T)) {
@@ -216,9 +213,9 @@ void CowData<T>::_unref(void *p_data) {
template <class T>
void CowData<T>::_copy_on_write() {
-
- if (!_ptr)
+ if (!_ptr) {
return;
+ }
uint32_t *refc = _get_refcount();
@@ -250,13 +247,13 @@ void CowData<T>::_copy_on_write() {
template <class T>
Error CowData<T>::resize(int p_size) {
-
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
int current_size = size();
- if (p_size == current_size)
+ if (p_size == current_size) {
return OK;
+ }
if (p_size == 0) {
// wants to clean up
@@ -273,7 +270,6 @@ Error CowData<T>::resize(int p_size) {
ERR_FAIL_COND_V(!_get_alloc_size_checked(p_size, &alloc_size), ERR_OUT_OF_MEMORY);
if (p_size > current_size) {
-
if (alloc_size != current_alloc_size) {
if (current_size == 0) {
// alloc from scratch
@@ -304,7 +300,6 @@ Error CowData<T>::resize(int p_size) {
*_get_size() = p_size;
} else if (p_size < current_size) {
-
if (!__has_trivial_destructor(T)) {
// deinitialize no longer needed elements
for (uint32_t i = p_size; i < *_get_size(); i++) {
@@ -351,15 +346,16 @@ void CowData<T>::_ref(const CowData *p_from) {
template <class T>
void CowData<T>::_ref(const CowData &p_from) {
-
- if (_ptr == p_from._ptr)
+ if (_ptr == p_from._ptr) {
return; // self assign, do nothing.
+ }
_unref(_ptr);
_ptr = nullptr;
- if (!p_from._ptr)
+ if (!p_from._ptr) {
return; //nothing to do
+ }
if (atomic_conditional_increment(p_from._get_refcount()) > 0) { // could reference
_ptr = p_from._ptr;
@@ -367,14 +363,7 @@ void CowData<T>::_ref(const CowData &p_from) {
}
template <class T>
-CowData<T>::CowData() {
-
- _ptr = nullptr;
-}
-
-template <class T>
CowData<T>::~CowData() {
-
_unref(_ptr);
}
diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp
index 233f62bd15..a9a7cabee9 100644
--- a/core/crypto/crypto.cpp
+++ b/core/crypto/crypto.cpp
@@ -38,8 +38,9 @@
CryptoKey *(*CryptoKey::_create)() = nullptr;
CryptoKey *CryptoKey::create() {
- if (_create)
+ if (_create) {
return _create();
+ }
return nullptr;
}
@@ -50,8 +51,9 @@ void CryptoKey::_bind_methods() {
X509Certificate *(*X509Certificate::_create)() = nullptr;
X509Certificate *X509Certificate::create() {
- if (_create)
+ if (_create) {
return _create();
+ }
return nullptr;
}
@@ -65,15 +67,16 @@ void X509Certificate::_bind_methods() {
void (*Crypto::_load_default_certificates)(String p_path) = nullptr;
Crypto *(*Crypto::_create)() = nullptr;
Crypto *Crypto::create() {
- if (_create)
+ if (_create) {
return _create();
- return memnew(Crypto);
+ }
+ ERR_FAIL_V_MSG(nullptr, "Crypto is not available when the mbedtls module is disabled.");
}
void Crypto::load_default_certificates(String p_path) {
-
- if (_load_default_certificates)
+ if (_load_default_certificates) {
_load_default_certificates(p_path);
+ }
}
void Crypto::_bind_methods() {
@@ -82,63 +85,46 @@ void Crypto::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_self_signed_certificate", "key", "issuer_name", "not_before", "not_after"), &Crypto::generate_self_signed_certificate, DEFVAL("CN=myserver,O=myorganisation,C=IT"), DEFVAL("20140101000000"), DEFVAL("20340101000000"));
}
-PackedByteArray Crypto::generate_random_bytes(int p_bytes) {
- ERR_FAIL_V_MSG(PackedByteArray(), "generate_random_bytes is not available when mbedtls module is disabled.");
-}
-
-Ref<CryptoKey> Crypto::generate_rsa(int p_bytes) {
- ERR_FAIL_V_MSG(nullptr, "generate_rsa is not available when mbedtls module is disabled.");
-}
-
-Ref<X509Certificate> Crypto::generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) {
- ERR_FAIL_V_MSG(nullptr, "generate_self_signed_certificate is not available when mbedtls module is disabled.");
-}
-
-Crypto::Crypto() {
-}
-
/// Resource loader/saver
RES ResourceFormatLoaderCrypto::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) {
-
String el = p_path.get_extension().to_lower();
if (el == "crt") {
X509Certificate *cert = X509Certificate::create();
- if (cert)
+ if (cert) {
cert->load(p_path);
+ }
return cert;
} else if (el == "key") {
CryptoKey *key = CryptoKey::create();
- if (key)
+ if (key) {
key->load(p_path);
+ }
return key;
}
return nullptr;
}
void ResourceFormatLoaderCrypto::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("crt");
p_extensions->push_back("key");
}
bool ResourceFormatLoaderCrypto::handles_type(const String &p_type) const {
-
return p_type == "X509Certificate" || p_type == "CryptoKey";
}
String ResourceFormatLoaderCrypto::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "crt")
+ if (el == "crt") {
return "X509Certificate";
- else if (el == "key")
+ } else if (el == "key") {
return "CryptoKey";
+ }
return "";
}
Error ResourceFormatSaverCrypto::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Error err;
Ref<X509Certificate> cert = p_resource;
Ref<CryptoKey> key = p_resource;
@@ -154,7 +140,6 @@ Error ResourceFormatSaverCrypto::save(const String &p_path, const RES &p_resourc
}
void ResourceFormatSaverCrypto::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
const X509Certificate *cert = Object::cast_to<X509Certificate>(*p_resource);
const CryptoKey *key = Object::cast_to<CryptoKey>(*p_resource);
if (cert) {
@@ -164,7 +149,7 @@ void ResourceFormatSaverCrypto::get_recognized_extensions(const RES &p_resource,
p_extensions->push_back("key");
}
}
-bool ResourceFormatSaverCrypto::recognize(const RES &p_resource) const {
+bool ResourceFormatSaverCrypto::recognize(const RES &p_resource) const {
return Object::cast_to<X509Certificate>(*p_resource) || Object::cast_to<CryptoKey>(*p_resource);
}
diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h
index d9becab958..6cc5f46164 100644
--- a/core/crypto/crypto.h
+++ b/core/crypto/crypto.h
@@ -31,11 +31,10 @@
#ifndef CRYPTO_H
#define CRYPTO_H
-#include "core/reference.h"
-#include "core/resource.h"
-
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
+#include "core/reference.h"
+#include "core/resource.h"
class CryptoKey : public Resource {
GDCLASS(CryptoKey, Resource);
@@ -76,11 +75,11 @@ public:
static Crypto *create();
static void load_default_certificates(String p_path);
- virtual PackedByteArray generate_random_bytes(int p_bytes);
- virtual Ref<CryptoKey> generate_rsa(int p_bytes);
- virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after);
+ virtual PackedByteArray generate_random_bytes(int p_bytes) = 0;
+ virtual Ref<CryptoKey> generate_rsa(int p_bytes) = 0;
+ virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) = 0;
- Crypto();
+ Crypto() {}
};
class ResourceFormatLoaderCrypto : public ResourceFormatLoader {
diff --git a/core/crypto/crypto_core.h b/core/crypto/crypto_core.h
index b3be58e8ee..36d8ace723 100644
--- a/core/crypto/crypto_core.h
+++ b/core/crypto/crypto_core.h
@@ -34,10 +34,8 @@
#include "core/reference.h"
class CryptoCore {
-
public:
class MD5Context {
-
private:
void *ctx; // To include, or not to include...
@@ -51,7 +49,6 @@ public:
};
class SHA1Context {
-
private:
void *ctx; // To include, or not to include...
@@ -65,7 +62,6 @@ public:
};
class SHA256Context {
-
private:
void *ctx; // To include, or not to include...
@@ -79,7 +75,6 @@ public:
};
class AESContext {
-
private:
void *ctx; // To include, or not to include...
diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp
index af43bc9bad..fb0dadfbab 100644
--- a/core/crypto/hashing_context.cpp
+++ b/core/crypto/hashing_context.cpp
@@ -104,7 +104,6 @@ void HashingContext::_create_ctx(HashType p_type) {
}
void HashingContext::_delete_ctx() {
-
switch (type) {
case HASH_MD5:
memdelete((CryptoCore::MD5Context *)ctx);
@@ -128,11 +127,8 @@ void HashingContext::_bind_methods() {
BIND_ENUM_CONSTANT(HASH_SHA256);
}
-HashingContext::HashingContext() {
- ctx = nullptr;
-}
-
HashingContext::~HashingContext() {
- if (ctx != nullptr)
+ if (ctx != nullptr) {
_delete_ctx();
+ }
}
diff --git a/core/crypto/hashing_context.h b/core/crypto/hashing_context.h
index 230ba7ee85..f9454fa891 100644
--- a/core/crypto/hashing_context.h
+++ b/core/crypto/hashing_context.h
@@ -44,7 +44,7 @@ public:
};
private:
- void *ctx;
+ void *ctx = nullptr;
HashType type;
protected:
@@ -57,7 +57,7 @@ public:
Error update(PackedByteArray p_chunk);
PackedByteArray finish();
- HashingContext();
+ HashingContext() {}
~HashingContext();
};
diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp
index 410c55129d..3f949b0ae1 100644
--- a/core/debugger/debugger_marshalls.cpp
+++ b/core/debugger/debugger_marshalls.cpp
@@ -228,8 +228,9 @@ Array DebuggerMarshalls::ScriptStackVariable::serialize(int max_size) {
int len = 0;
Error err = encode_variant(var, nullptr, len, true);
- if (err != OK)
+ if (err != OK) {
ERR_PRINT("Failed to encode variant.");
+ }
if (len > max_size) {
arr.push_back(Variant());
diff --git a/core/debugger/debugger_marshalls.h b/core/debugger/debugger_marshalls.h
index 04229c0afc..7b7f4ac4b5 100644
--- a/core/debugger/debugger_marshalls.h
+++ b/core/debugger/debugger_marshalls.h
@@ -35,18 +35,14 @@
#include "servers/rendering_server.h"
struct DebuggerMarshalls {
-
// Memory usage
struct ResourceInfo {
String path;
String format;
String type;
RID id;
- int vram;
+ int vram = 0;
bool operator<(const ResourceInfo &p_img) const { return vram == p_img.vram ? id < p_img.id : vram > p_img.vram; }
- ResourceInfo() {
- vram = 0;
- }
};
struct ResourceUsage {
@@ -119,10 +115,7 @@ struct DebuggerMarshalls {
struct ScriptStackVariable {
String name;
Variant value;
- int type;
- ScriptStackVariable() {
- type = -1;
- }
+ int type = -1;
Array serialize(int max_size = 1 << 20); // 1 MiB default.
bool deserialize(const Array &p_arr);
@@ -137,27 +130,18 @@ struct DebuggerMarshalls {
};
struct OutputError {
- int hr;
- int min;
- int sec;
- int msec;
+ int hr = -1;
+ int min = -1;
+ int sec = -1;
+ int msec = -1;
String source_file;
String source_func;
- int source_line;
+ int source_line = -1;
String error;
String error_descr;
- bool warning;
+ bool warning = false;
Vector<ScriptLanguage::StackInfo> callstack;
- OutputError() {
- hr = -1;
- min = -1;
- sec = -1;
- msec = -1;
- source_line = -1;
- warning = false;
- }
-
Array serialize();
bool deserialize(const Array &p_arr);
};
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp
index 04eba84b30..5c9fb67de4 100644
--- a/core/debugger/engine_debugger.cpp
+++ b/core/debugger/engine_debugger.cpp
@@ -111,8 +111,9 @@ Error EngineDebugger::capture_parse(const StringName &p_name, const String &p_ms
void EngineDebugger::line_poll() {
// The purpose of this is just processing events every now and then when the script might get too busy otherwise bugs like infinite loops can't be caught
- if (poll_every % 2048 == 0)
+ if (poll_every % 2048 == 0) {
poll_events(false);
+ }
poll_every++;
}
@@ -124,8 +125,9 @@ void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_idle_ticks, ui
// Notify tick to running profilers
for (Map<StringName, Profiler>::Element *E = profilers.front(); E; E = E->next()) {
Profiler &p = E->get();
- if (!p.active || !p.tick)
+ if (!p.active || !p.tick) {
continue;
+ }
p.tick(p.data, frame_time, idle_time, physics_time, physics_frame_time);
}
singleton->poll_events(true);
@@ -133,8 +135,9 @@ void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_idle_ticks, ui
void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Vector<String> p_breakpoints) {
register_uri_handler("tcp://", RemoteDebuggerPeerTCP::create); // TCP is the default protocol. Platforms/modules can add more.
- if (p_uri.empty())
+ if (p_uri.empty()) {
return;
+ }
if (p_uri == "local://") {
singleton = memnew(LocalDebugger);
script_debugger = memnew(ScriptDebugger);
@@ -142,11 +145,13 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Ve
OS::get_singleton()->initialize_debugging();
} else if (p_uri.find("://") >= 0) {
const String proto = p_uri.substr(0, p_uri.find("://") + 3);
- if (!protocols.has(proto))
+ if (!protocols.has(proto)) {
return;
+ }
RemoteDebuggerPeer *peer = protocols[proto](p_uri);
- if (!peer)
+ if (!peer) {
return;
+ }
singleton = memnew(RemoteDebugger(Ref<RemoteDebuggerPeer>(peer)));
script_debugger = memnew(ScriptDebugger);
// Notify editor of our pid (to allow focus stealing).
@@ -154,15 +159,15 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Ve
msg.push_back(OS::get_singleton()->get_process_id());
singleton->send_message("set_pid", msg);
}
- if (!singleton)
+ if (!singleton) {
return;
+ }
// There is a debugger, parse breakpoints.
ScriptDebugger *singleton_script_debugger = singleton->get_script_debugger();
singleton_script_debugger->set_skip_breakpoints(p_skip_breakpoints);
for (int i = 0; i < p_breakpoints.size(); i++) {
-
String bp = p_breakpoints[i];
int sp = bp.find_last(":");
ERR_CONTINUE_MSG(sp == -1, "Invalid breakpoint: '" + bp + "', expected file:line format.");
@@ -175,8 +180,9 @@ void EngineDebugger::deinitialize() {
if (singleton) {
// Stop all profilers
for (Map<StringName, Profiler>::Element *E = profilers.front(); E; E = E->next()) {
- if (E->get().active)
+ if (E->get().active) {
singleton->profiler_enable(E->key(), false);
+ }
}
// Flush any remaining message
@@ -193,8 +199,9 @@ void EngineDebugger::deinitialize() {
}
EngineDebugger::~EngineDebugger() {
- if (script_debugger)
+ if (script_debugger) {
memdelete(script_debugger);
+ }
script_debugger = nullptr;
singleton = nullptr;
}
diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp
index 6d88ceb2c1..876be79418 100644
--- a/core/debugger/local_debugger.cpp
+++ b/core/debugger/local_debugger.cpp
@@ -36,7 +36,6 @@
struct LocalDebugger::ScriptsProfiler {
struct ProfileInfoSort {
-
bool operator()(const ScriptLanguage::ProfilingInfo &A, const ScriptLanguage::ProfilingInfo &B) const {
return A.total_time > B.total_time;
}
@@ -70,17 +69,19 @@ struct LocalDebugger::ScriptsProfiler {
void _print_frame_data(bool p_accumulated) {
uint64_t diff = OS::get_singleton()->get_ticks_usec() - idle_accum;
- if (!p_accumulated && diff < 1000000) //show every one second
+ if (!p_accumulated && diff < 1000000) { //show every one second
return;
+ }
idle_accum = OS::get_singleton()->get_ticks_usec();
int ofs = 0;
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- if (p_accumulated)
+ if (p_accumulated) {
ofs += ScriptServer::get_language(i)->profiling_get_accumulated_data(&pinfo.write[ofs], pinfo.size() - ofs);
- else
+ } else {
ofs += ScriptServer::get_language(i)->profiling_get_frame_data(&pinfo.write[ofs], pinfo.size() - ofs);
+ }
}
SortArray<ScriptLanguage::ProfilingInfo, ProfileInfoSort> sort;
@@ -89,7 +90,6 @@ struct LocalDebugger::ScriptsProfiler {
// compute total script frame time
uint64_t script_time_us = 0;
for (int i = 0; i < ofs; i++) {
-
script_time_us += pinfo[i].self_time;
}
float script_time = USEC_TO_SEC(script_time_us);
@@ -102,7 +102,6 @@ struct LocalDebugger::ScriptsProfiler {
}
for (int i = 0; i < ofs; i++) {
-
print_line(itos(i) + ":" + pinfo[i].signature);
float tt = USEC_TO_SEC(pinfo[i].total_time);
float st = USEC_TO_SEC(pinfo[i].self_time);
@@ -116,7 +115,6 @@ struct LocalDebugger::ScriptsProfiler {
};
void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
-
ScriptLanguage *script_lang = script_debugger->get_break_language();
if (!target_function.empty()) {
@@ -135,7 +133,6 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
int current_frame = 0;
int total_frames = script_lang->debug_get_stack_level_count();
while (true) {
-
OS::get_singleton()->print("debug> ");
String line = OS::get_singleton()->get_stdin_string().strip_edges();
@@ -146,18 +143,15 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
print_line("\nDebugger Break, Reason: '" + script_lang->debug_get_error() + "'");
print_line("*Frame " + itos(current_frame) + " - " + script_lang->debug_get_stack_level_source(current_frame) + ":" + itos(script_lang->debug_get_stack_level_line(current_frame)) + " in function '" + script_lang->debug_get_stack_level_function(current_frame) + "'");
print_line("Enter \"help\" for assistance.");
- } else if (line == "c" || line == "continue")
+ } else if (line == "c" || line == "continue") {
break;
- else if (line == "bt" || line == "breakpoint") {
-
+ } else if (line == "bt" || line == "breakpoint") {
for (int i = 0; i < total_frames; i++) {
-
String cfi = (current_frame == i) ? "*" : " "; //current frame indicator
print_line(cfi + "Frame " + itos(i) + " - " + script_lang->debug_get_stack_level_source(i) + ":" + itos(script_lang->debug_get_stack_level_line(i)) + " in function '" + script_lang->debug_get_stack_level_function(i) + "'");
}
} else if (line.begins_with("fr") || line.begins_with("frame")) {
-
if (line.get_slice_count(" ") == 1) {
print_line("*Frame " + itos(current_frame) + " - " + script_lang->debug_get_stack_level_source(current_frame) + ":" + itos(script_lang->debug_get_stack_level_line(current_frame)) + " in function '" + script_lang->debug_get_stack_level_function(current_frame) + "'");
} else {
@@ -171,9 +165,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
} else if (line.begins_with("set")) {
-
if (line.get_slice_count(" ") == 1) {
-
for (Map<String, String>::Element *E = options.front(); E; E = E->next()) {
print_line("\t" + E->key() + "=" + E->value());
}
@@ -185,13 +177,11 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
if (value_pos < 0) {
print_line("Error: Invalid set format. Use: set key=value");
} else {
-
String key = key_value.left(value_pos);
if (!options.has(key)) {
print_line("Error: Unknown option " + key);
} else {
-
// Allow explicit tab character
String value = key_value.right(value_pos + 1).replace("\\t", "\t");
@@ -201,49 +191,41 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
} else if (line == "lv" || line == "locals") {
-
List<String> locals;
List<Variant> values;
script_lang->debug_get_stack_level_locals(current_frame, &locals, &values);
print_variables(locals, values, variable_prefix);
} else if (line == "gv" || line == "globals") {
-
List<String> globals;
List<Variant> values;
script_lang->debug_get_globals(&globals, &values);
print_variables(globals, values, variable_prefix);
} else if (line == "mv" || line == "members") {
-
List<String> members;
List<Variant> values;
script_lang->debug_get_stack_level_members(current_frame, &members, &values);
print_variables(members, values, variable_prefix);
} else if (line.begins_with("p") || line.begins_with("print")) {
-
if (line.get_slice_count(" ") <= 1) {
print_line("Usage: print <expre>");
} else {
-
String expr = line.get_slicec(' ', 2);
String res = script_lang->debug_parse_stack_level_expression(current_frame, expr);
print_line(res);
}
} else if (line == "s" || line == "step") {
-
script_debugger->set_depth(-1);
script_debugger->set_lines_left(1);
break;
} else if (line == "n" || line == "next") {
-
script_debugger->set_depth(0);
script_debugger->set_lines_left(1);
break;
} else if (line == "fin" || line == "finish") {
-
String current_function = script_lang->debug_get_stack_level_function(0);
for (int i = 0; i < total_frames; i++) {
@@ -259,9 +241,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
target_function = "";
} else if (line.begins_with("br") || line.begins_with("break")) {
-
if (line.get_slice_count(" ") <= 1) {
-
const Map<int, Set<StringName>> &breakpoints = script_debugger->get_breakpoints();
if (breakpoints.size() == 0) {
print_line("No Breakpoints.");
@@ -274,14 +254,14 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
} else {
-
Pair<String, int> breakpoint = to_breakpoint(line);
String source = breakpoint.first;
int linenr = breakpoint.second;
- if (source.empty())
+ if (source.empty()) {
continue;
+ }
script_debugger->insert_breakpoint(linenr, source);
@@ -289,7 +269,6 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
} else if (line == "q" || line == "quit") {
-
// Do not stop again on quit
script_debugger->clear_breakpoints();
script_debugger->set_depth(-1);
@@ -298,18 +277,17 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
SceneTree::get_singleton()->quit();
break;
} else if (line.begins_with("delete")) {
-
if (line.get_slice_count(" ") <= 1) {
script_debugger->clear_breakpoints();
} else {
-
Pair<String, int> breakpoint = to_breakpoint(line);
String source = breakpoint.first;
int linenr = breakpoint.second;
- if (source.empty())
+ if (source.empty()) {
continue;
+ }
script_debugger->remove_breakpoint(linenr, source);
@@ -317,7 +295,6 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
} else if (line == "h" || line == "help") {
-
print_line("Built-In Debugger command list:\n");
print_line("\tc,continue\t\t Continue execution.");
print_line("\tbt,backtrace\t\t Show stack trace (frames).");
@@ -340,18 +317,15 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
}
void LocalDebugger::print_variables(const List<String> &names, const List<Variant> &values, const String &variable_prefix) {
-
String value;
Vector<String> value_lines;
const List<Variant>::Element *V = values.front();
for (const List<String>::Element *E = names.front(); E; E = E->next()) {
-
value = String(V->get());
if (variable_prefix.empty()) {
print_line(E->get() + ": " + String(V->get()));
} else {
-
print_line(E->get() + ":");
value_lines = value.split("\n");
for (int i = 0; i < value_lines.size(); ++i) {
@@ -364,7 +338,6 @@ void LocalDebugger::print_variables(const List<String> &names, const List<Varian
}
Pair<String, int> LocalDebugger::to_breakpoint(const String &p_line) {
-
String breakpoint_part = p_line.get_slicec(' ', 1);
Pair<String, int> breakpoint;
@@ -381,18 +354,15 @@ Pair<String, int> LocalDebugger::to_breakpoint(const String &p_line) {
}
void LocalDebugger::send_message(const String &p_message, const Array &p_args) {
-
// This needs to be cleaned up entirely.
// print_line("MESSAGE: '" + p_message + "' - " + String(Variant(p_args)));
}
void LocalDebugger::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type) {
-
print_line("ERROR: '" + (p_descr.empty() ? p_err : p_descr) + "'");
}
LocalDebugger::LocalDebugger() {
-
options["variable_prefix"] = "";
// Bind scripts profiler.
@@ -411,6 +381,7 @@ LocalDebugger::LocalDebugger() {
LocalDebugger::~LocalDebugger() {
unregister_profiler("scripts");
- if (scripts_profiler)
+ if (scripts_profiler) {
memdelete(scripts_profiler);
+ }
}
diff --git a/core/debugger/local_debugger.h b/core/debugger/local_debugger.h
index 2c4302f4da..d342da6d44 100644
--- a/core/debugger/local_debugger.h
+++ b/core/debugger/local_debugger.h
@@ -36,7 +36,6 @@
#include "core/script_language.h"
class LocalDebugger : public EngineDebugger {
-
private:
struct ScriptsProfiler;
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp
index 18c9602eb2..62f600c5e5 100644
--- a/core/debugger/remote_debugger.cpp
+++ b/core/debugger/remote_debugger.cpp
@@ -57,7 +57,6 @@ void RemoteDebugger::_bind_profiler(const String &p_name, T *p_prof) {
}
struct RemoteDebugger::NetworkProfiler {
-
public:
typedef DebuggerMarshalls::MultiplayerNodeInfo NodeInfo;
struct BandwidthFrame {
@@ -97,8 +96,9 @@ public:
}
void init_node(const ObjectID p_node) {
- if (multiplayer_node_data.has(p_node))
+ if (multiplayer_node_data.has(p_node)) {
return;
+ }
multiplayer_node_data.insert(p_node, DebuggerMarshalls::MultiplayerNodeInfo());
multiplayer_node_data[p_node].node = p_node;
multiplayer_node_data[p_node].node_path = Object::cast_to<Node>(ObjectDB::get_instance(p_node))->get_path();
@@ -191,7 +191,6 @@ struct RemoteDebugger::ScriptsProfiler {
typedef DebuggerMarshalls::ScriptFunctionSignature FunctionSignature;
typedef DebuggerMarshalls::ScriptFunctionInfo FunctionInfo;
struct ProfileInfoSort {
-
bool operator()(ScriptLanguage::ProfilingInfo *A, ScriptLanguage::ProfilingInfo *B) const {
return A->total_time < B->total_time;
}
@@ -220,10 +219,11 @@ struct RemoteDebugger::ScriptsProfiler {
void write_frame_data(Vector<FunctionInfo> &r_funcs, uint64_t &r_total, bool p_accumulated) {
int ofs = 0;
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- if (p_accumulated)
+ if (p_accumulated) {
ofs += ScriptServer::get_language(i)->profiling_get_accumulated_data(&info.write[ofs], info.size() - ofs);
- else
+ } else {
ofs += ScriptServer::get_language(i)->profiling_get_frame_data(&info.write[ofs], info.size() - ofs);
+ }
}
for (int i = 0; i < ofs; i++) {
@@ -270,7 +270,6 @@ struct RemoteDebugger::ScriptsProfiler {
};
struct RemoteDebugger::ServersProfiler {
-
bool skip_profile_frame = false;
typedef DebuggerMarshalls::ServerInfo ServerInfo;
typedef DebuggerMarshalls::ServerFunctionInfo ServerFunctionInfo;
@@ -347,7 +346,6 @@ struct RemoteDebugger::ServersProfiler {
};
struct RemoteDebugger::VisualProfiler {
-
typedef DebuggerMarshalls::ServerInfo ServerInfo;
typedef DebuggerMarshalls::ServerFunctionInfo ServerFunctionInfo;
@@ -362,8 +360,9 @@ struct RemoteDebugger::VisualProfiler {
void tick(float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time) {
Vector<RS::FrameProfileArea> profile_areas = RS::get_singleton()->get_frame_profile();
DebuggerMarshalls::VisualProfilerFrame frame;
- if (!profile_areas.size())
+ if (!profile_areas.size()) {
return;
+ }
frame.frame_number = RS::get_singleton()->get_frame_profile_frame();
frame.areas.append_array(profile_areas);
@@ -372,19 +371,20 @@ struct RemoteDebugger::VisualProfiler {
};
struct RemoteDebugger::PerformanceProfiler {
-
Object *performance = nullptr;
int last_perf_time = 0;
void toggle(bool p_enable, const Array &p_opts) {}
void add(const Array &p_data) {}
void tick(float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time) {
- if (!performance)
+ if (!performance) {
return;
+ }
uint64_t pt = OS::get_singleton()->get_ticks_msec();
- if (pt - last_perf_time < 1000)
+ if (pt - last_perf_time < 1000) {
return;
+ }
last_perf_time = pt;
int max = performance->get("MONITOR_MAX");
Array arr;
@@ -401,14 +401,12 @@ struct RemoteDebugger::PerformanceProfiler {
};
void RemoteDebugger::_send_resource_usage() {
-
DebuggerMarshalls::ResourceUsage usage;
List<RS::TextureInfo> tinfo;
RS::get_singleton()->texture_debug_usage(&tinfo);
for (List<RS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) {
-
DebuggerMarshalls::ResourceInfo info;
info.path = E->get().path;
info.vram = E->get().bytes;
@@ -430,26 +428,29 @@ Error RemoteDebugger::_put_msg(String p_message, Array p_data) {
msg.push_back(p_message);
msg.push_back(p_data);
Error err = peer->put_message(msg);
- if (err != OK)
+ if (err != OK) {
n_messages_dropped++;
+ }
return err;
}
void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char *p_file, int p_line, const char *p_err, const char *p_descr, ErrorHandlerType p_type) {
-
- if (p_type == ERR_HANDLER_SCRIPT)
+ if (p_type == ERR_HANDLER_SCRIPT) {
return; //ignore script errors, those go through debugger
+ }
RemoteDebugger *rd = (RemoteDebugger *)p_this;
- if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) // Can't handle recursive errors during flush.
+ if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive errors during flush.
return;
+ }
Vector<ScriptLanguage::StackInfo> si;
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
si = ScriptServer::get_language(i)->debug_get_current_stack_info();
- if (si.size())
+ if (si.size()) {
break;
+ }
}
// send_error will lock internally.
@@ -457,17 +458,18 @@ void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char *
}
void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p_error) {
-
RemoteDebugger *rd = (RemoteDebugger *)p_this;
- if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) // Can't handle recursive prints during flush.
+ if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive prints during flush.
return;
+ }
String s = p_string;
int allowed_chars = MIN(MAX(rd->max_chars_per_second - rd->char_count, 0), s.length());
- if (allowed_chars == 0 && s.length() > 0)
+ if (allowed_chars == 0 && s.length() > 0) {
return;
+ }
if (allowed_chars < s.length()) {
s = s.substr(0, allowed_chars);
@@ -478,8 +480,9 @@ void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p
rd->char_count += allowed_chars;
bool overflowed = rd->char_count >= rd->max_chars_per_second;
if (rd->is_peer_connected()) {
- if (overflowed)
+ if (overflowed) {
s += "[...]";
+ }
OutputString output_string;
output_string.message = s;
@@ -511,17 +514,18 @@ void RemoteDebugger::flush_output() {
flush_thread = Thread::get_caller_id();
flushing = true;
MutexLock lock(mutex);
- if (!is_peer_connected())
+ if (!is_peer_connected()) {
return;
+ }
if (n_messages_dropped > 0) {
ErrorMessage err_msg = _create_overflow_error("TOO_MANY_MESSAGES", "Too many messages! " + String::num_int64(n_messages_dropped) + " messages were dropped. Profiling might misbheave, try raising 'network/limits/debugger/max_queued_messages' in project setting.");
- if (_put_msg("error", err_msg.serialize()) == OK)
+ if (_put_msg("error", err_msg.serialize()) == OK) {
n_messages_dropped = 0;
+ }
}
if (output_strings.size()) {
-
// Join output strings so we generate less messages.
Vector<String> joined_log_strings;
Vector<String> strings;
@@ -574,7 +578,6 @@ void RemoteDebugger::flush_output() {
}
void RemoteDebugger::send_message(const String &p_message, const Array &p_args) {
-
MutexLock lock(mutex);
if (is_peer_connected()) {
_put_msg(p_message, p_args);
@@ -582,7 +585,6 @@ void RemoteDebugger::send_message(const String &p_message, const Array &p_args)
}
void RemoteDebugger::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type) {
-
ErrorMessage oe;
oe.error = p_err;
oe.error_descr = p_descr;
@@ -597,8 +599,9 @@ void RemoteDebugger::send_error(const String &p_func, const String &p_file, int
oe.msec = time % 1000;
oe.callstack.append_array(script_debugger->get_error_stack_info());
- if (flushing && Thread::get_caller_id() == flush_thread) // Can't handle recursive errors during flush.
+ if (flushing && Thread::get_caller_id() == flush_thread) { // Can't handle recursive errors during flush.
return;
+ }
MutexLock lock(mutex);
@@ -609,7 +612,6 @@ void RemoteDebugger::send_error(const String &p_func, const String &p_file, int
}
if (is_peer_connected()) {
-
if (oe.warning) {
if (warn_count > max_warnings_per_second) {
n_warnings_dropped++;
@@ -657,24 +659,26 @@ Error RemoteDebugger::_try_capture(const String &p_msg, const Array &p_data, boo
return OK;
}
const String cap = p_msg.substr(0, idx);
- if (!has_capture(cap))
+ if (!has_capture(cap)) {
return ERR_UNAVAILABLE; // Unknown message...
+ }
const String msg = p_msg.substr(idx + 1);
return capture_parse(cap, msg, p_data, r_captured);
}
void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
-
//this function is called when there is a debugger break (bug on script)
//or when execution is paused from editor
- if (script_debugger->is_skipping_breakpoints() && !p_is_error_breakpoint)
+ if (script_debugger->is_skipping_breakpoints() && !p_is_error_breakpoint) {
return;
+ }
ERR_FAIL_COND_MSG(!is_peer_connected(), "Script Debugger failed to connect, but being used anyway.");
- if (!peer->can_block())
+ if (!peer->can_block()) {
return; // Peer does not support blocking IO. We could at least send the error though.
+ }
ScriptLanguage *script_lang = script_debugger->get_break_language();
const String error_str = script_lang ? script_lang->debug_get_error() : "";
@@ -686,8 +690,9 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
servers_profiler->skip_profile_frame = true; // Avoid frame time spike in debug.
Input::MouseMode mouse_mode = Input::get_singleton()->get_mouse_mode();
- if (mouse_mode != Input::MOUSE_MODE_VISIBLE)
+ if (mouse_mode != Input::MOUSE_MODE_VISIBLE) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+ }
uint64_t loop_begin_usec = 0;
uint64_t loop_time_sec = 0;
@@ -698,7 +703,6 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
peer->poll();
if (peer->has_message()) {
-
Array cmd = peer->get_message();
ERR_CONTINUE(cmd.size() != 2);
@@ -776,10 +780,11 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
} else if (command == "breakpoint") {
ERR_FAIL_COND(data.size() < 3);
bool set = data[2];
- if (set)
+ if (set) {
script_debugger->insert_breakpoint(data[1], data[0]);
- else
+ } else {
script_debugger->remove_breakpoint(data[1], data[0]);
+ }
} else if (command == "set_skip_breakpoints") {
ERR_FAIL_COND(data.size() < 1);
@@ -787,8 +792,9 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
} else {
bool captured = false;
ERR_CONTINUE(_try_capture(command, data, captured) != OK);
- if (!captured)
+ if (!captured) {
WARN_PRINT("Unknown message received from debugger: " + command);
+ }
}
} else {
OS::get_singleton()->delay_usec(10000);
@@ -805,18 +811,19 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
send_message("debug_exit", Array());
- if (mouse_mode != Input::MOUSE_MODE_VISIBLE)
+ if (mouse_mode != Input::MOUSE_MODE_VISIBLE) {
Input::get_singleton()->set_mouse_mode(mouse_mode);
+ }
}
void RemoteDebugger::poll_events(bool p_is_idle) {
- if (peer.is_null())
+ if (peer.is_null()) {
return;
+ }
flush_output();
peer->poll();
while (peer->has_message()) {
-
Array arr = peer->get_message();
ERR_CONTINUE(arr.size() != 2);
@@ -832,8 +839,9 @@ void RemoteDebugger::poll_events(bool p_is_idle) {
}
const String cap = cmd.substr(0, idx);
- if (!has_capture(cap))
+ if (!has_capture(cap)) {
continue; // Unknown message...
+ }
const String msg = cmd.substr(idx + 1);
capture_parse(cap, msg, arr[1], parsed);
@@ -856,10 +864,11 @@ Error RemoteDebugger::_core_capture(const String &p_cmd, const Array &p_data, bo
} else if (p_cmd == "breakpoint") {
ERR_FAIL_COND_V(p_data.size() < 3, ERR_INVALID_DATA);
bool set = p_data[2];
- if (set)
+ if (set) {
script_debugger->insert_breakpoint(p_data[1], p_data[0]);
- else
+ } else {
script_debugger->remove_breakpoint(p_data[1], p_data[0]);
+ }
} else if (p_cmd == "set_skip_breakpoints") {
ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_DATA);
@@ -950,6 +959,7 @@ RemoteDebugger::~RemoteDebugger() {
memdelete(servers_profiler);
memdelete(network_profiler);
memdelete(visual_profiler);
- if (performance_profiler)
+ if (performance_profiler) {
memdelete(performance_profiler);
+ }
}
diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp
index 458c46df93..faa3a75fda 100644
--- a/core/debugger/remote_debugger_peer.cpp
+++ b/core/debugger/remote_debugger_peer.cpp
@@ -52,8 +52,9 @@ Array RemoteDebuggerPeerTCP::get_message() {
Error RemoteDebuggerPeerTCP::put_message(const Array &p_arr) {
MutexLock lock(mutex);
- if (out_queue.size() >= max_queued_messages)
+ if (out_queue.size() >= max_queued_messages) {
return ERR_OUT_OF_MEMORY;
+ }
out_queue.push_back(p_arr);
return OK;
@@ -99,8 +100,9 @@ void RemoteDebuggerPeerTCP::_write_out() {
while (tcp_client->poll(NetSocket::POLL_TYPE_OUT) == OK) {
uint8_t *buf = out_buf.ptrw();
if (out_left <= 0) {
- if (out_queue.size() == 0)
+ if (out_queue.size() == 0) {
break; // Nothing left to send
+ }
mutex.lock();
Variant var = out_queue[0];
out_queue.pop_front();
@@ -154,12 +156,12 @@ void RemoteDebuggerPeerTCP::_read_in() {
}
Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_port) {
-
IP_Address ip;
- if (p_host.is_valid_ip_address())
+ if (p_host.is_valid_ip_address()) {
ip = p_host;
- else
+ } else {
ip = IP::get_singleton()->resolve_hostname(p_host);
+ }
int port = p_port;
@@ -169,23 +171,20 @@ Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_po
tcp_client->connect_to_host(ip, port);
for (int i = 0; i < tries; i++) {
-
if (tcp_client->get_status() == StreamPeerTCP::STATUS_CONNECTED) {
print_verbose("Remote Debugger: Connected!");
break;
} else {
-
const int ms = waits[i];
OS::get_singleton()->delay_usec(ms * 1000);
print_verbose("Remote Debugger: Connection failed with status: '" + String::num(tcp_client->get_status()) + "', retrying in " + String::num(ms) + " msec.");
- };
- };
+ }
+ }
if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
-
ERR_PRINT("Remote Debugger: Unable to connect. Status: " + String::num(tcp_client->get_status()) + ".");
return FAILED;
- };
+ }
connected = true;
#ifndef NO_THREADS
running = true;
@@ -198,8 +197,9 @@ void RemoteDebuggerPeerTCP::_thread_func(void *p_ud) {
RemoteDebuggerPeerTCP *peer = (RemoteDebuggerPeerTCP *)p_ud;
while (peer->running && peer->is_peer_connected()) {
peer->_poll();
- if (!peer->is_peer_connected())
+ if (!peer->is_peer_connected()) {
break;
+ }
peer->tcp_client->poll(NetSocket::POLL_TYPE_IN_OUT, 1);
}
}
diff --git a/core/debugger/script_debugger.cpp b/core/debugger/script_debugger.cpp
index 935ad01d80..0cd3238efb 100644
--- a/core/debugger/script_debugger.cpp
+++ b/core/debugger/script_debugger.cpp
@@ -33,69 +33,63 @@
#include "core/debugger/engine_debugger.h"
void ScriptDebugger::set_lines_left(int p_left) {
-
lines_left = p_left;
}
int ScriptDebugger::get_lines_left() const {
-
return lines_left;
}
void ScriptDebugger::set_depth(int p_depth) {
-
depth = p_depth;
}
int ScriptDebugger::get_depth() const {
-
return depth;
}
void ScriptDebugger::insert_breakpoint(int p_line, const StringName &p_source) {
-
- if (!breakpoints.has(p_line))
+ if (!breakpoints.has(p_line)) {
breakpoints[p_line] = Set<StringName>();
+ }
breakpoints[p_line].insert(p_source);
}
void ScriptDebugger::remove_breakpoint(int p_line, const StringName &p_source) {
-
- if (!breakpoints.has(p_line))
+ if (!breakpoints.has(p_line)) {
return;
+ }
breakpoints[p_line].erase(p_source);
- if (breakpoints[p_line].size() == 0)
+ if (breakpoints[p_line].size() == 0) {
breakpoints.erase(p_line);
+ }
}
-bool ScriptDebugger::is_breakpoint(int p_line, const StringName &p_source) const {
- if (!breakpoints.has(p_line))
+bool ScriptDebugger::is_breakpoint(int p_line, const StringName &p_source) const {
+ if (!breakpoints.has(p_line)) {
return false;
+ }
return breakpoints[p_line].has(p_source);
}
-bool ScriptDebugger::is_breakpoint_line(int p_line) const {
+bool ScriptDebugger::is_breakpoint_line(int p_line) const {
return breakpoints.has(p_line);
}
String ScriptDebugger::breakpoint_find_source(const String &p_source) const {
-
return p_source;
}
void ScriptDebugger::clear_breakpoints() {
-
breakpoints.clear();
}
void ScriptDebugger::set_skip_breakpoints(bool p_skip_breakpoints) {
-
skip_breakpoints = p_skip_breakpoints;
}
bool ScriptDebugger::is_skipping_breakpoints() {
-
return skip_breakpoints;
}
@@ -118,6 +112,5 @@ Vector<ScriptLanguage::StackInfo> ScriptDebugger::get_error_stack_info() const {
}
ScriptLanguage *ScriptDebugger::get_break_language() const {
-
return break_lang;
}
diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h
index e5066273d2..0068691825 100644
--- a/core/debugger/script_debugger.h
+++ b/core/debugger/script_debugger.h
@@ -38,7 +38,6 @@
#include "core/vector.h"
class ScriptDebugger {
-
typedef ScriptLanguage::StackInfo StackInfo;
int lines_left = -1;
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index bc3b792bd5..052e1bdae1 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -35,15 +35,14 @@
#include "core/variant.h"
struct DictionaryPrivate {
-
SafeRefCount refcount;
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> variant_map;
};
void Dictionary::get_key_list(List<Variant> *p_keys) const {
-
- if (_p->variant_map.empty())
+ if (_p->variant_map.empty()) {
return;
+ }
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
p_keys->push_back(E.key());
@@ -51,7 +50,6 @@ void Dictionary::get_key_list(List<Variant> *p_keys) const {
}
Variant Dictionary::get_key_at_index(int p_index) const {
-
int index = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
if (index == p_index) {
@@ -64,7 +62,6 @@ Variant Dictionary::get_key_at_index(int p_index) const {
}
Variant Dictionary::get_value_at_index(int p_index) const {
-
int index = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
if (index == p_index) {
@@ -77,38 +74,37 @@ Variant Dictionary::get_value_at_index(int p_index) const {
}
Variant &Dictionary::operator[](const Variant &p_key) {
-
return _p->variant_map[p_key];
}
const Variant &Dictionary::operator[](const Variant &p_key) const {
-
return _p->variant_map[p_key];
}
-const Variant *Dictionary::getptr(const Variant &p_key) const {
+const Variant *Dictionary::getptr(const Variant &p_key) const {
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key);
- if (!E)
+ if (!E) {
return nullptr;
+ }
return &E.get();
}
Variant *Dictionary::getptr(const Variant &p_key) {
-
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.find(p_key);
- if (!E)
+ if (!E) {
return nullptr;
+ }
return &E.get();
}
Variant Dictionary::get_valid(const Variant &p_key) const {
-
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key);
- if (!E)
+ if (!E) {
return Variant();
+ }
return E.get();
}
@@ -122,16 +118,14 @@ Variant Dictionary::get(const Variant &p_key, const Variant &p_default) const {
}
int Dictionary::size() const {
-
return _p->variant_map.size();
}
-bool Dictionary::empty() const {
+bool Dictionary::empty() const {
return !_p->variant_map.size();
}
bool Dictionary::has(const Variant &p_key) const {
-
return _p->variant_map.has(p_key);
}
@@ -145,51 +139,47 @@ bool Dictionary::has_all(const Array &p_keys) const {
}
bool Dictionary::erase(const Variant &p_key) {
-
return _p->variant_map.erase(p_key);
}
bool Dictionary::operator==(const Dictionary &p_dictionary) const {
-
return _p == p_dictionary._p;
}
bool Dictionary::operator!=(const Dictionary &p_dictionary) const {
-
return _p != p_dictionary._p;
}
void Dictionary::_ref(const Dictionary &p_from) const {
-
//make a copy first (thread safe)
- if (!p_from._p->refcount.ref())
+ if (!p_from._p->refcount.ref()) {
return; // couldn't copy
+ }
//if this is the same, unreference the other one
if (p_from._p == _p) {
_p->refcount.unref();
return;
}
- if (_p)
+ if (_p) {
_unref();
+ }
_p = p_from._p;
}
void Dictionary::clear() {
-
_p->variant_map.clear();
}
void Dictionary::_unref() const {
-
ERR_FAIL_COND(!_p);
if (_p->refcount.unref()) {
memdelete(_p);
}
_p = nullptr;
}
-uint32_t Dictionary::hash() const {
+uint32_t Dictionary::hash() const {
uint32_t h = hash_djb2_one_32(Variant::DICTIONARY);
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
@@ -201,10 +191,10 @@ uint32_t Dictionary::hash() const {
}
Array Dictionary::keys() const {
-
Array varr;
- if (_p->variant_map.empty())
+ if (_p->variant_map.empty()) {
return varr;
+ }
varr.resize(size());
@@ -218,10 +208,10 @@ Array Dictionary::keys() const {
}
Array Dictionary::values() const {
-
Array varr;
- if (_p->variant_map.empty())
+ if (_p->variant_map.empty()) {
return varr;
+ }
varr.resize(size());
@@ -235,22 +225,22 @@ Array Dictionary::values() const {
}
const Variant *Dictionary::next(const Variant *p_key) const {
-
if (p_key == nullptr) {
// caller wants to get the first element
- if (_p->variant_map.front())
+ if (_p->variant_map.front()) {
return &_p->variant_map.front().key();
+ }
return nullptr;
}
OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.find(*p_key);
- if (E && E.next())
+ if (E && E.next()) {
return &E.next().key();
+ }
return nullptr;
}
Dictionary Dictionary::duplicate(bool p_deep) const {
-
Dictionary n;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
@@ -261,7 +251,6 @@ Dictionary Dictionary::duplicate(bool p_deep) const {
}
void Dictionary::operator=(const Dictionary &p_dictionary) {
-
_ref(p_dictionary);
}
@@ -275,11 +264,10 @@ Dictionary::Dictionary(const Dictionary &p_from) {
}
Dictionary::Dictionary() {
-
_p = memnew(DictionaryPrivate);
_p->refcount.init();
}
-Dictionary::~Dictionary() {
+Dictionary::~Dictionary() {
_unref();
}
diff --git a/core/dictionary.h b/core/dictionary.h
index c6cbacc144..a01d96ba01 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -40,7 +40,6 @@ class Variant;
struct DictionaryPrivate;
class Dictionary {
-
mutable DictionaryPrivate *_p;
void _ref(const Dictionary &p_from) const;
diff --git a/core/engine.cpp b/core/engine.cpp
index 5361e09a8a..c8bfffd020 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -37,18 +37,18 @@
#include "core/version_hash.gen.h"
void Engine::set_iterations_per_second(int p_ips) {
-
ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0.");
ips = p_ips;
}
-int Engine::get_iterations_per_second() const {
+int Engine::get_iterations_per_second() const {
return ips;
}
void Engine::set_physics_jitter_fix(float p_threshold) {
- if (p_threshold < 0)
+ if (p_threshold < 0) {
p_threshold = 0;
+ }
physics_jitter_fix = p_threshold;
}
@@ -65,32 +65,26 @@ int Engine::get_target_fps() const {
}
uint64_t Engine::get_frames_drawn() {
-
return frames_drawn;
}
void Engine::set_frame_delay(uint32_t p_msec) {
-
_frame_delay = p_msec;
}
uint32_t Engine::get_frame_delay() const {
-
return _frame_delay;
}
void Engine::set_time_scale(float p_scale) {
-
_time_scale = p_scale;
}
float Engine::get_time_scale() const {
-
return _time_scale;
}
Dictionary Engine::get_version_info() const {
-
Dictionary dict;
dict["major"] = VERSION_MAJOR;
dict["minor"] = VERSION_MINOR;
@@ -104,8 +98,9 @@ Dictionary Engine::get_version_info() const {
dict["hash"] = hash.length() == 0 ? String("unknown") : hash;
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
- if ((int)dict["patch"] != 0)
+ if ((int)dict["patch"] != 0) {
stringver += "." + String(dict["patch"]);
+ }
stringver += "-" + String(dict["status"]) + " (" + String(dict["build"]) + ")";
dict["string"] = stringver;
@@ -185,27 +180,24 @@ String Engine::get_license_text() const {
}
void Engine::add_singleton(const Singleton &p_singleton) {
-
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
}
Object *Engine::get_singleton_object(const String &p_name) const {
-
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
ERR_FAIL_COND_V_MSG(!E, nullptr, "Failed to retrieve non-existent singleton '" + p_name + "'.");
return E->get();
-};
+}
bool Engine::has_singleton(const String &p_name) const {
-
return singleton_ptrs.has(p_name);
-};
+}
void Engine::get_singletons(List<Singleton> *p_singletons) {
-
- for (List<Singleton>::Element *E = singletons.front(); E; E = E->next())
+ for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) {
p_singletons->push_back(E->get());
+ }
}
Engine *Engine::singleton = nullptr;
@@ -217,23 +209,7 @@ Engine *Engine::get_singleton() {
bool Engine::is_abort_on_gpu_errors_enabled() const {
return abort_on_gpu_errors;
}
-Engine::Engine() {
+Engine::Engine() {
singleton = this;
- frames_drawn = 0;
- ips = 60;
- physics_jitter_fix = 0.5;
- _physics_interpolation_fraction = 0.0f;
- _frame_delay = 0;
- _fps = 1;
- _target_fps = 0;
- _time_scale = 1.0;
- _pixel_snap = false;
- _physics_frames = 0;
- _idle_frames = 0;
- _in_physics = false;
- _frame_ticks = 0;
- _frame_step = 0;
- editor_hint = false;
- abort_on_gpu_errors = false;
}
diff --git a/core/engine.h b/core/engine.h
index 8512779d4c..fef330c0c1 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -37,7 +37,6 @@
#include "core/vector.h"
class Engine {
-
public:
struct Singleton {
StringName name;
@@ -51,28 +50,28 @@ public:
private:
friend class Main;
- uint64_t frames_drawn;
- uint32_t _frame_delay;
- uint64_t _frame_ticks;
- float _frame_step;
+ uint64_t frames_drawn = 0;
+ uint32_t _frame_delay = 0;
+ uint64_t _frame_ticks = 0;
+ float _frame_step = 0;
- int ips;
- float physics_jitter_fix;
- float _fps;
- int _target_fps;
- float _time_scale;
- bool _pixel_snap;
- uint64_t _physics_frames;
- float _physics_interpolation_fraction;
- bool abort_on_gpu_errors;
+ int ips = 60;
+ float physics_jitter_fix = 0.5;
+ float _fps = 1;
+ int _target_fps = 0;
+ float _time_scale = 1.0;
+ bool _pixel_snap = false;
+ uint64_t _physics_frames = 0;
+ float _physics_interpolation_fraction = 0.0f;
+ bool abort_on_gpu_errors = false;
- uint64_t _idle_frames;
- bool _in_physics;
+ uint64_t _idle_frames = 0;
+ bool _in_physics = false;
List<Singleton> singletons;
Map<StringName, Object *> singleton_ptrs;
- bool editor_hint;
+ bool editor_hint = false;
static Engine *singleton;
diff --git a/core/error_macros.cpp b/core/error_macros.cpp
index 5de070844a..2fae939965 100644
--- a/core/error_macros.cpp
+++ b/core/error_macros.cpp
@@ -37,7 +37,6 @@
static ErrorHandlerList *error_handler_list = nullptr;
void add_error_handler(ErrorHandlerList *p_handler) {
-
_global_lock();
p_handler->next = error_handler_list;
error_handler_list = p_handler;
@@ -45,20 +44,18 @@ void add_error_handler(ErrorHandlerList *p_handler) {
}
void remove_error_handler(ErrorHandlerList *p_handler) {
-
_global_lock();
ErrorHandlerList *prev = nullptr;
ErrorHandlerList *l = error_handler_list;
while (l) {
-
if (l == p_handler) {
-
- if (prev)
+ if (prev) {
prev->next = l->next;
- else
+ } else {
error_handler_list = l->next;
+ }
break;
}
prev = l;
@@ -77,13 +74,11 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
}
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, ErrorHandlerType p_type) {
-
OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, (Logger::ErrorType)p_type);
_global_lock();
ErrorHandlerList *l = error_handler_list;
while (l) {
-
l->errfunc(l->userdata, p_function, p_file, p_line, p_error, p_message, p_type);
l = l->next;
}
@@ -104,7 +99,6 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
}
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool fatal) {
-
String fstr(fatal ? "FATAL: " : "");
String err(fstr + "Index " + p_index_str + " = " + itos(p_index) + " is out of bounds (" + p_size_str + " = " + itos(p_size) + ").");
_err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message);
diff --git a/core/error_macros.h b/core/error_macros.h
index 83f92129a5..d7366be453 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -47,17 +47,12 @@ enum ErrorHandlerType {
typedef void (*ErrorHandlerFunc)(void *, const char *, const char *, int p_line, const char *, const char *, ErrorHandlerType p_type);
struct ErrorHandlerList {
+ ErrorHandlerFunc errfunc = nullptr;
+ void *userdata = nullptr;
- ErrorHandlerFunc errfunc;
- void *userdata;
+ ErrorHandlerList *next = nullptr;
- ErrorHandlerList *next;
-
- ErrorHandlerList() {
- errfunc = 0;
- next = 0;
- userdata = 0;
- }
+ ErrorHandlerList() {}
};
void add_error_handler(ErrorHandlerList *p_handler);
@@ -108,6 +103,11 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* running application to fail or crash.
* Always try to return processable data, so the engine can keep running well.
* Use the _MSG versions to print a meaningful message to help with debugging.
+ *
+ * The `((void)0)` no-op statement is used as a trick to force us to put a semicolon after
+ * those macros, making them look like proper statements.
+ * The if wrappers are used to ensure that the macro replacement does not trigger unexpected
+ * issues when expanded e.g. after an `if (cond) ERR_FAIL();` without braces.
*/
// Index out of bounds error macros.
@@ -285,7 +285,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* If it is null, the current function returns.
*/
#define ERR_FAIL_NULL(m_param) \
- if (unlikely(!m_param)) { \
+ if (unlikely(m_param == nullptr)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
return; \
} else \
@@ -296,7 +296,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* If it is null, prints `m_msg` and the current function returns.
*/
#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
- if (unlikely(!m_param)) { \
+ if (unlikely(m_param == nullptr)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
return; \
} else \
@@ -310,7 +310,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* If it is null, the current function returns `m_retval`.
*/
#define ERR_FAIL_NULL_V(m_param, m_retval) \
- if (unlikely(!m_param)) { \
+ if (unlikely(m_param == nullptr)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
return m_retval; \
} else \
@@ -321,7 +321,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* If it is null, prints `m_msg` and the current function returns `m_retval`.
*/
#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
- if (unlikely(!m_param)) { \
+ if (unlikely(m_param == nullptr)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
return m_retval; \
} else \
@@ -366,11 +366,11 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* Ensures `m_cond` is false.
* If `m_cond` is true, the current function returns `m_retval`.
*/
-#define ERR_FAIL_COND_V(m_cond, m_retval) \
- if (unlikely(m_cond)) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. returned: " _STR(m_retval)); \
- return m_retval; \
- } else \
+#define ERR_FAIL_COND_V(m_cond, m_retval) \
+ if (unlikely(m_cond)) { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returning: " _STR(m_retval)); \
+ return m_retval; \
+ } else \
((void)0)
/**
@@ -380,11 +380,11 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
* If checking for null use ERR_FAIL_NULL_V_MSG instead.
* If checking index bounds use ERR_FAIL_INDEX_V_MSG instead.
*/
-#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
- if (unlikely(m_cond)) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. returned: " _STR(m_retval), DEBUG_STR(m_msg)); \
- return m_retval; \
- } else \
+#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
+ if (unlikely(m_cond)) { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returning: " _STR(m_retval), DEBUG_STR(m_msg)); \
+ return m_retval; \
+ } else \
((void)0)
/**
@@ -477,7 +477,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
*/
#define ERR_FAIL() \
if (1) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed."); \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed."); \
return; \
} else \
((void)0)
@@ -490,7 +490,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
*/
#define ERR_FAIL_MSG(m_msg) \
if (1) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed.", DEBUG_STR(m_msg)); \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed.", DEBUG_STR(m_msg)); \
return; \
} else \
((void)0)
@@ -504,7 +504,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
*/
#define ERR_FAIL_V(m_retval) \
if (1) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " _STR(m_retval)); \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed. Returning: " _STR(m_retval)); \
return m_retval; \
} else \
((void)0)
@@ -517,7 +517,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
*/
#define ERR_FAIL_V_MSG(m_retval, m_msg) \
if (1) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " _STR(m_retval), DEBUG_STR(m_msg)); \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed. Returning: " _STR(m_retval), DEBUG_STR(m_msg)); \
return m_retval; \
} else \
((void)0)
@@ -606,7 +606,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
*/
#define CRASH_NOW() \
if (1) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed."); \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/function failed."); \
GENERATE_TRAP(); \
} else \
((void)0)
@@ -618,7 +618,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
*/
#define CRASH_NOW_MSG(m_msg) \
if (1) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed.", DEBUG_STR(m_msg)); \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/function failed.", DEBUG_STR(m_msg)); \
GENERATE_TRAP(); \
} else \
((void)0)
diff --git a/core/func_ref.cpp b/core/func_ref.cpp
index 338c17946b..4427d94d2a 100644
--- a/core/func_ref.cpp
+++ b/core/func_ref.cpp
@@ -31,7 +31,6 @@
#include "func_ref.h"
Variant FuncRef::call_func(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (id.is_null()) {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
@@ -47,7 +46,6 @@ Variant FuncRef::call_func(const Variant **p_args, int p_argcount, Callable::Cal
}
Variant FuncRef::call_funcv(const Array &p_args) {
-
ERR_FAIL_COND_V(id.is_null(), Variant());
Object *obj = ObjectDB::get_instance(id);
@@ -58,29 +56,28 @@ Variant FuncRef::call_funcv(const Array &p_args) {
}
void FuncRef::set_instance(Object *p_obj) {
-
ERR_FAIL_NULL(p_obj);
id = p_obj->get_instance_id();
}
void FuncRef::set_function(const StringName &p_func) {
-
function = p_func;
}
bool FuncRef::is_valid() const {
- if (id.is_null())
+ if (id.is_null()) {
return false;
+ }
Object *obj = ObjectDB::get_instance(id);
- if (!obj)
+ if (!obj) {
return false;
+ }
return obj->has_method(function);
}
void FuncRef::_bind_methods() {
-
{
MethodInfo mi;
mi.name = "call_func";
@@ -94,6 +91,3 @@ void FuncRef::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_function", "name"), &FuncRef::set_function);
ClassDB::bind_method(D_METHOD("is_valid"), &FuncRef::is_valid);
}
-
-FuncRef::FuncRef() {
-}
diff --git a/core/func_ref.h b/core/func_ref.h
index 8cb3be6e61..6b0b22bab5 100644
--- a/core/func_ref.h
+++ b/core/func_ref.h
@@ -34,7 +34,6 @@
#include "core/reference.h"
class FuncRef : public Reference {
-
GDCLASS(FuncRef, Reference);
ObjectID id;
StringName function;
@@ -48,7 +47,8 @@ public:
void set_instance(Object *p_obj);
void set_function(const StringName &p_func);
bool is_valid() const;
- FuncRef();
+
+ FuncRef() {}
};
#endif // FUNC_REF_H
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 4f415a2056..6281e56395 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -36,7 +36,6 @@
#include "core/variant.h"
struct _GlobalConstant {
-
#ifdef DEBUG_METHODS_ENABLED
StringName enum_name;
#endif
@@ -638,33 +637,27 @@ void register_global_constants() {
}
void unregister_global_constants() {
-
_global_constants.clear();
}
int GlobalConstants::get_global_constant_count() {
-
return _global_constants.size();
}
#ifdef DEBUG_METHODS_ENABLED
StringName GlobalConstants::get_global_constant_enum(int p_idx) {
-
return _global_constants[p_idx].enum_name;
}
#else
StringName GlobalConstants::get_global_constant_enum(int p_idx) {
-
return StringName();
}
#endif
const char *GlobalConstants::get_global_constant_name(int p_idx) {
-
return _global_constants[p_idx].name;
}
int GlobalConstants::get_global_constant_value(int p_idx) {
-
return _global_constants[p_idx].value;
}
diff --git a/core/hash_map.h b/core/hash_map.h
index f27a86cc02..843430d082 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -59,7 +59,6 @@ template <class TKey, class TData, class Hasher = HashMapHasherDefault, class Co
class HashMap {
public:
struct Pair {
-
TKey key;
TData data;
@@ -75,8 +74,8 @@ public:
friend class HashMap;
uint32_t hash;
- Element *next;
- Element() { next = 0; }
+ Element *next = nullptr;
+ Element() {}
Pair pair;
public:
@@ -94,34 +93,32 @@ public:
};
private:
- Element **hash_table;
- uint8_t hash_table_power;
- uint32_t elements;
+ Element **hash_table = nullptr;
+ uint8_t hash_table_power = 0;
+ uint32_t elements = 0;
void make_hash_table() {
-
ERR_FAIL_COND(hash_table);
hash_table = memnew_arr(Element *, (1 << MIN_HASH_TABLE_POWER));
hash_table_power = MIN_HASH_TABLE_POWER;
elements = 0;
- for (int i = 0; i < (1 << MIN_HASH_TABLE_POWER); i++)
- hash_table[i] = 0;
+ for (int i = 0; i < (1 << MIN_HASH_TABLE_POWER); i++) {
+ hash_table[i] = nullptr;
+ }
}
void erase_hash_table() {
-
ERR_FAIL_COND_MSG(elements, "Cannot erase hash table if there are still elements inside.");
memdelete_arr(hash_table);
- hash_table = 0;
+ hash_table = nullptr;
hash_table_power = 0;
elements = 0;
}
void check_hash_table() {
-
int new_hash_table_power = -1;
if ((int)elements > ((1 << hash_table_power) * RELATIONSHIP)) {
@@ -129,40 +126,36 @@ private:
new_hash_table_power = hash_table_power + 1;
while ((int)elements > ((1 << new_hash_table_power) * RELATIONSHIP)) {
-
new_hash_table_power++;
}
} else if ((hash_table_power > (int)MIN_HASH_TABLE_POWER) && ((int)elements < ((1 << (hash_table_power - 1)) * RELATIONSHIP))) {
-
/* rehash down */
new_hash_table_power = hash_table_power - 1;
while ((int)elements < ((1 << (new_hash_table_power - 1)) * RELATIONSHIP)) {
-
new_hash_table_power--;
}
- if (new_hash_table_power < (int)MIN_HASH_TABLE_POWER)
+ if (new_hash_table_power < (int)MIN_HASH_TABLE_POWER) {
new_hash_table_power = MIN_HASH_TABLE_POWER;
+ }
}
- if (new_hash_table_power == -1)
+ if (new_hash_table_power == -1) {
return;
+ }
Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power));
ERR_FAIL_COND_MSG(!new_hash_table, "Out of memory.");
for (int i = 0; i < (1 << new_hash_table_power); i++) {
-
- new_hash_table[i] = 0;
+ new_hash_table[i] = nullptr;
}
if (hash_table) {
for (int i = 0; i < (1 << hash_table_power); i++) {
-
while (hash_table[i]) {
-
Element *se = hash_table[i];
hash_table[i] = se->next;
int new_pos = se->hash & ((1 << new_hash_table_power) - 1);
@@ -179,17 +172,14 @@ private:
/* I want to have only one function.. */
_FORCE_INLINE_ const Element *get_element(const TKey &p_key) const {
-
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
Element *e = hash_table[index];
while (e) {
-
/* checking hash first avoids comparing key, which may take longer */
if (e->hash == hash && Comparator::compare(e->pair.key, p_key)) {
-
/* the pair exists in this hashtable, so just update data */
return e;
}
@@ -201,7 +191,6 @@ private:
}
Element *create_element(const TKey &p_key) {
-
/* if element doesn't exist, create it */
Element *e = memnew(Element);
ERR_FAIL_COND_V_MSG(!e, nullptr, "Out of memory.");
@@ -219,27 +208,26 @@ private:
}
void copy_from(const HashMap &p_t) {
-
- if (&p_t == this)
+ if (&p_t == this) {
return; /* much less bother with that */
+ }
clear();
- if (!p_t.hash_table || p_t.hash_table_power == 0)
+ if (!p_t.hash_table || p_t.hash_table_power == 0) {
return; /* not copying from empty table */
+ }
hash_table = memnew_arr(Element *, (uint64_t)1 << p_t.hash_table_power);
hash_table_power = p_t.hash_table_power;
elements = p_t.elements;
for (int i = 0; i < (1 << p_t.hash_table_power); i++) {
-
hash_table[i] = nullptr;
const Element *e = p_t.hash_table[i];
while (e) {
-
Element *le = memnew(Element); /* local element */
*le = *e; /* copy data */
@@ -259,20 +247,20 @@ public:
}
Element *set(const Pair &p_pair) {
-
Element *e = nullptr;
- if (!hash_table)
+ if (!hash_table) {
make_hash_table(); // if no table, make one
- else
+ } else {
e = const_cast<Element *>(get_element(p_pair.key));
+ }
/* if we made it up to here, the pair doesn't exist, create and assign */
if (!e) {
-
e = create_element(p_pair.key);
- if (!e)
+ if (!e) {
return nullptr;
+ }
check_hash_table(); // perform mantenience routine
}
@@ -281,7 +269,6 @@ public:
}
bool has(const TKey &p_key) const {
-
return getptr(p_key) != nullptr;
}
@@ -292,14 +279,12 @@ public:
*/
const TData &get(const TKey &p_key) const {
-
const TData *res = getptr(p_key);
ERR_FAIL_COND_V(!res, *res);
return *res;
}
TData &get(const TKey &p_key) {
-
TData *res = getptr(p_key);
ERR_FAIL_COND_V(!res, *res);
return *res;
@@ -311,27 +296,29 @@ public:
*/
_FORCE_INLINE_ TData *getptr(const TKey &p_key) {
-
- if (unlikely(!hash_table))
+ if (unlikely(!hash_table)) {
return nullptr;
+ }
Element *e = const_cast<Element *>(get_element(p_key));
- if (e)
+ if (e) {
return &e->pair.data;
+ }
return nullptr;
}
_FORCE_INLINE_ const TData *getptr(const TKey &p_key) const {
-
- if (unlikely(!hash_table))
+ if (unlikely(!hash_table)) {
return nullptr;
+ }
const Element *e = const_cast<Element *>(get_element(p_key));
- if (e)
+ if (e) {
return &e->pair.data;
+ }
return nullptr;
}
@@ -343,9 +330,9 @@ public:
template <class C>
_FORCE_INLINE_ TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) {
-
- if (unlikely(!hash_table))
+ if (unlikely(!hash_table)) {
return nullptr;
+ }
uint32_t hash = p_custom_hash;
uint32_t index = hash & ((1 << hash_table_power) - 1);
@@ -353,10 +340,8 @@ public:
Element *e = hash_table[index];
while (e) {
-
/* checking hash first avoids comparing key, which may take longer */
if (e->hash == hash && Comparator::compare(e->pair.key, p_custom_key)) {
-
/* the pair exists in this hashtable, so just update data */
return &e->pair.data;
}
@@ -369,9 +354,9 @@ public:
template <class C>
_FORCE_INLINE_ const TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) const {
-
- if (unlikely(!hash_table))
+ if (unlikely(!hash_table)) {
return nullptr;
+ }
uint32_t hash = p_custom_hash;
uint32_t index = hash & ((1 << hash_table_power) - 1);
@@ -379,10 +364,8 @@ public:
const Element *e = hash_table[index];
while (e) {
-
/* checking hash first avoids comparing key, which may take longer */
if (e->hash == hash && Comparator::compare(e->pair.key, p_custom_key)) {
-
/* the pair exists in this hashtable, so just update data */
return &e->pair.data;
}
@@ -398,9 +381,9 @@ public:
*/
bool erase(const TKey &p_key) {
-
- if (unlikely(!hash_table))
+ if (unlikely(!hash_table)) {
return false;
+ }
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
@@ -408,12 +391,9 @@ public:
Element *e = hash_table[index];
Element *p = nullptr;
while (e) {
-
/* checking hash first avoids comparing key, which may take longer */
if (e->hash == hash && Comparator::compare(e->pair.key, p_key)) {
-
if (p) {
-
p->next = e->next;
} else {
//begin of list
@@ -423,10 +403,11 @@ public:
memdelete(e);
elements--;
- if (elements == 0)
+ if (elements == 0) {
erase_hash_table();
- else
+ } else {
check_hash_table();
+ }
return true;
}
@@ -444,14 +425,14 @@ public:
inline TData &operator[](const TKey &p_key) { //assignment
Element *e = nullptr;
- if (!hash_table)
+ if (!hash_table) {
make_hash_table(); // if no table, make one
- else
+ } else {
e = const_cast<Element *>(get_element(p_key));
+ }
/* if we made it up to here, the pair doesn't exist, create */
if (!e) {
-
e = create_element(p_key);
CRASH_COND(!e);
check_hash_table(); // perform mantenience routine
@@ -476,14 +457,13 @@ public:
*
*/
const TKey *next(const TKey *p_key) const {
-
- if (unlikely(!hash_table))
+ if (unlikely(!hash_table)) {
return nullptr;
+ }
if (!p_key) { /* get the first key */
for (int i = 0; i < (1 << hash_table_power); i++) {
-
if (hash_table[i]) {
return &hash_table[i]->pair.key;
}
@@ -501,7 +481,6 @@ public:
uint32_t index = e->hash & ((1 << hash_table_power) - 1);
index++;
for (int i = index; i < (1 << hash_table_power); i++) {
-
if (hash_table[i]) {
return &hash_table[i]->pair.key;
}
@@ -515,23 +494,18 @@ public:
}
inline unsigned int size() const {
-
return elements;
}
inline bool empty() const {
-
return elements == 0;
}
void clear() {
-
/* clean up */
if (hash_table) {
for (int i = 0; i < (1 << hash_table_power); i++) {
-
while (hash_table[i]) {
-
Element *e = hash_table[i];
hash_table[i] = e->next;
memdelete(e);
@@ -541,60 +515,35 @@ public:
memdelete_arr(hash_table);
}
- hash_table = 0;
+ hash_table = nullptr;
hash_table_power = 0;
elements = 0;
}
void operator=(const HashMap &p_table) {
-
copy_from(p_table);
}
- HashMap() {
- hash_table = nullptr;
- elements = 0;
- hash_table_power = 0;
- }
-
- void get_key_value_ptr_array(const Pair **p_pairs) const {
- if (unlikely(!hash_table))
+ void get_key_list(List<TKey> *r_keys) const {
+ if (unlikely(!hash_table)) {
return;
- for (int i = 0; i < (1 << hash_table_power); i++) {
-
- Element *e = hash_table[i];
- while (e) {
- *p_pairs = &e->pair;
- p_pairs++;
- e = e->next;
- }
}
- }
-
- void get_key_list(List<TKey> *p_keys) const {
- if (unlikely(!hash_table))
- return;
for (int i = 0; i < (1 << hash_table_power); i++) {
-
Element *e = hash_table[i];
while (e) {
- p_keys->push_back(e->pair.key);
+ r_keys->push_back(e->pair.key);
e = e->next;
}
}
}
- HashMap(const HashMap &p_table) {
-
- hash_table = nullptr;
- elements = 0;
- hash_table_power = 0;
+ HashMap() {}
+ HashMap(const HashMap &p_table) {
copy_from(p_table);
}
~HashMap() {
-
clear();
}
};
diff --git a/core/hashfuncs.h b/core/hashfuncs.h
index a41a034843..d984f6c524 100644
--- a/core/hashfuncs.h
+++ b/core/hashfuncs.h
@@ -49,29 +49,28 @@
* @return 32-bits hashcode
*/
static inline uint32_t hash_djb2(const char *p_cstr) {
-
const unsigned char *chr = (const unsigned char *)p_cstr;
uint32_t hash = 5381;
uint32_t c;
- while ((c = *chr++))
+ while ((c = *chr++)) {
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
+ }
return hash;
}
static inline uint32_t hash_djb2_buffer(const uint8_t *p_buff, int p_len, uint32_t p_prev = 5381) {
-
uint32_t hash = p_prev;
- for (int i = 0; i < p_len; i++)
+ for (int i = 0; i < p_len; i++) {
hash = ((hash << 5) + hash) + p_buff[i]; /* hash * 33 + c */
+ }
return hash;
}
static inline uint32_t hash_djb2_one_32(uint32_t p_in, uint32_t p_prev = 5381) {
-
return ((p_prev << 5) + p_prev) + p_in;
}
@@ -93,19 +92,19 @@ static inline uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev = 5381)
} u;
// Normalize +/- 0.0 and NaN values so they hash the same.
- if (p_in == 0.0f)
+ if (p_in == 0.0f) {
u.d = 0.0;
- else if (Math::is_nan(p_in))
+ } else if (Math::is_nan(p_in)) {
u.d = Math_NAN;
- else
+ } else {
u.d = p_in;
+ }
return ((p_prev << 5) + p_prev) + hash_one_uint64(u.i);
}
template <class T>
static inline uint32_t make_uint32_t(T p_in) {
-
union {
T t;
uint32_t _u32;
@@ -116,13 +115,11 @@ static inline uint32_t make_uint32_t(T p_in) {
}
static inline uint64_t hash_djb2_one_64(uint64_t p_in, uint64_t p_prev = 5381) {
-
return ((p_prev << 5) + p_prev) + p_in;
}
template <class T>
static inline uint64_t make_uint64_t(T p_in) {
-
union {
T t;
uint64_t _u64;
@@ -134,7 +131,6 @@ static inline uint64_t make_uint64_t(T p_in) {
}
struct HashMapHasherDefault {
-
static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); }
static _FORCE_INLINE_ uint32_t hash(const char *p_cstr) { return hash_djb2(p_cstr); }
static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { return hash_one_uint64(p_int); }
diff --git a/core/image.cpp b/core/image.cpp
index ff8acc54af..0f15574053 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -37,8 +37,6 @@
#include "core/os/copymem.h"
#include "core/print_string.h"
-#include "thirdparty/misc/hq2x.h"
-
#include <stdio.h>
const char *Image::format_names[Image::FORMAT_MAX] = {
@@ -90,7 +88,6 @@ SaveEXRFunc Image::save_exr_func = nullptr;
SavePNGBufferFunc Image::save_png_buffer_func = nullptr;
void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel) {
-
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
for (uint32_t i = 0; i < p_pixelsize; i++) {
@@ -99,7 +96,6 @@ void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data,
}
void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_data, uint8_t *p_pixel) {
-
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
for (uint32_t i = 0; i < p_pixelsize; i++) {
@@ -108,7 +104,6 @@ void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p
}
int Image::get_format_pixel_size(Format p_format) {
-
switch (p_format) {
case FORMAT_L8:
return 1; //luminance
@@ -195,7 +190,6 @@ int Image::get_format_pixel_size(Format p_format) {
}
void Image::get_format_min_pixel_size(Format p_format, int &r_w, int &r_h) {
-
switch (p_format) {
case FORMAT_DXT1: //s3tc bc1
case FORMAT_DXT3: //bc2
@@ -208,25 +202,21 @@ void Image::get_format_min_pixel_size(Format p_format, int &r_w, int &r_h) {
} break;
case FORMAT_PVRTC2:
case FORMAT_PVRTC2A: {
-
r_w = 16;
r_h = 8;
} break;
case FORMAT_PVRTC4A:
case FORMAT_PVRTC4: {
-
r_w = 8;
r_h = 8;
} break;
case FORMAT_ETC: {
-
r_w = 4;
r_h = 4;
} break;
case FORMAT_BPTC_RGBA:
case FORMAT_BPTC_RGBF:
case FORMAT_BPTC_RGBFU: {
-
r_w = 4;
r_h = 4;
} break;
@@ -239,7 +229,6 @@ void Image::get_format_min_pixel_size(Format p_format, int &r_w, int &r_h) {
case FORMAT_ETC2_RGB8A1:
case FORMAT_ETC2_RA_AS_RG:
case FORMAT_DXT5_RA_AS_RG: {
-
r_w = 4;
r_h = 4;
@@ -253,17 +242,16 @@ void Image::get_format_min_pixel_size(Format p_format, int &r_w, int &r_h) {
}
int Image::get_format_pixel_rshift(Format p_format) {
-
- if (p_format == FORMAT_DXT1 || p_format == FORMAT_RGTC_R || p_format == FORMAT_PVRTC4 || p_format == FORMAT_PVRTC4A || p_format == FORMAT_ETC || p_format == FORMAT_ETC2_R11 || p_format == FORMAT_ETC2_R11S || p_format == FORMAT_ETC2_RGB8 || p_format == FORMAT_ETC2_RGB8A1)
+ if (p_format == FORMAT_DXT1 || p_format == FORMAT_RGTC_R || p_format == FORMAT_PVRTC4 || p_format == FORMAT_PVRTC4A || p_format == FORMAT_ETC || p_format == FORMAT_ETC2_R11 || p_format == FORMAT_ETC2_R11S || p_format == FORMAT_ETC2_RGB8 || p_format == FORMAT_ETC2_RGB8A1) {
return 1;
- else if (p_format == FORMAT_PVRTC2 || p_format == FORMAT_PVRTC2A)
+ } else if (p_format == FORMAT_PVRTC2 || p_format == FORMAT_PVRTC2A) {
return 2;
- else
+ } else {
return 0;
+ }
}
int Image::get_format_block_size(Format p_format) {
-
switch (p_format) {
case FORMAT_DXT1: //s3tc bc1
case FORMAT_DXT3: //bc2
@@ -275,22 +263,18 @@ int Image::get_format_block_size(Format p_format) {
}
case FORMAT_PVRTC2:
case FORMAT_PVRTC2A: {
-
return 4;
}
case FORMAT_PVRTC4A:
case FORMAT_PVRTC4: {
-
return 4;
}
case FORMAT_ETC: {
-
return 4;
}
case FORMAT_BPTC_RGBA:
case FORMAT_BPTC_RGBF:
case FORMAT_BPTC_RGBFU: {
-
return 4;
}
case FORMAT_ETC2_R11: //etc2
@@ -304,7 +288,6 @@ int Image::get_format_block_size(Format p_format) {
case FORMAT_DXT5_RA_AS_RG: //used to make basis universal happy
{
-
return 4;
}
default: {
@@ -315,7 +298,6 @@ int Image::get_format_block_size(Format p_format) {
}
void Image::_get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_width, int &r_height) const {
-
int w = width;
int h = height;
int ofs = 0;
@@ -345,7 +327,6 @@ void Image::_get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_widt
}
int Image::get_mipmap_offset(int p_mipmap) const {
-
ERR_FAIL_INDEX_V(p_mipmap, get_mipmap_count() + 1, -1);
int ofs, w, h;
@@ -354,7 +335,6 @@ int Image::get_mipmap_offset(int p_mipmap) const {
}
int Image::get_mipmap_byte_size(int p_mipmap) const {
-
ERR_FAIL_INDEX_V(p_mipmap, get_mipmap_count() + 1, -1);
int ofs, w, h;
@@ -365,7 +345,6 @@ int Image::get_mipmap_byte_size(int p_mipmap) const {
}
void Image::get_mipmap_offset_and_size(int p_mipmap, int &r_ofs, int &r_size) const {
-
int ofs, w, h;
_get_mipmap_offset_and_size(p_mipmap, ofs, w, h);
int ofs2;
@@ -375,7 +354,6 @@ void Image::get_mipmap_offset_and_size(int p_mipmap, int &r_ofs, int &r_size) co
}
void Image::get_mipmap_offset_size_and_dimensions(int p_mipmap, int &r_ofs, int &r_size, int &w, int &h) const {
-
int ofs;
_get_mipmap_offset_and_size(p_mipmap, ofs, w, h);
int ofs2, w2, h2;
@@ -385,42 +363,36 @@ void Image::get_mipmap_offset_size_and_dimensions(int p_mipmap, int &r_ofs, int
}
int Image::get_width() const {
-
return width;
}
int Image::get_height() const {
-
return height;
}
Vector2 Image::get_size() const {
-
return Vector2(width, height);
}
bool Image::has_mipmaps() const {
-
return mipmaps;
}
int Image::get_mipmap_count() const {
-
- if (mipmaps)
+ if (mipmaps) {
return get_image_required_mipmaps(width, height, format);
- else
+ } else {
return 0;
+ }
}
//using template generates perfectly optimized code due to constant expression reduction and unused variable removal present in all compilers
template <uint32_t read_bytes, bool read_alpha, uint32_t write_bytes, bool write_alpha, bool read_gray, bool write_gray>
static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p_dst) {
-
uint32_t max_bytes = MAX(read_bytes, write_bytes);
for (int y = 0; y < p_height; y++) {
for (int x = 0; x < p_width; x++) {
-
const uint8_t *rofs = &p_src[((y * p_width) + x) * (read_bytes + (read_alpha ? 1 : 0))];
uint8_t *wofs = &p_dst[((y * p_width) + x) * (write_bytes + (write_alpha ? 1 : 0))];
@@ -431,9 +403,7 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p
rgba[1] = rofs[0];
rgba[2] = rofs[0];
} else {
-
for (uint32_t i = 0; i < max_bytes; i++) {
-
rgba[i] = (i < read_bytes) ? rofs[i] : 0;
}
}
@@ -447,7 +417,6 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p
wofs[0] = uint8_t((uint16_t(rofs[0]) + uint16_t(rofs[1]) + uint16_t(rofs[2])) / 3);
} else {
for (uint32_t i = 0; i < write_bytes; i++) {
-
wofs[i] = rgba[i];
}
}
@@ -460,25 +429,23 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p
}
void Image::convert(Format p_new_format) {
-
- if (data.size() == 0)
+ if (data.size() == 0) {
return;
+ }
- if (p_new_format == format)
+ if (p_new_format == format) {
return;
+ }
if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) {
-
ERR_FAIL_MSG("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead.");
} else if (format > FORMAT_RGBA8 || p_new_format > FORMAT_RGBA8) {
-
//use put/set pixel which is slower but works with non byte formats
- Image new_img(width, height, 0, p_new_format);
+ Image new_img(width, height, false, p_new_format);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
-
new_img.set_pixel(i, j, get_pixel(i, j));
}
}
@@ -492,7 +459,7 @@ void Image::convert(Format p_new_format) {
return;
}
- Image new_img(width, height, 0, p_new_format);
+ Image new_img(width, height, false, p_new_format);
const uint8_t *rptr = data.ptr();
uint8_t *wptr = new_img.data.ptrw();
@@ -500,7 +467,6 @@ void Image::convert(Format p_new_format) {
int conversion_type = format | p_new_format << 8;
switch (conversion_type) {
-
case FORMAT_L8 | (FORMAT_LA8 << 8):
_convert<1, false, 1, true, true, true>(width, height, rptr, wptr);
break;
@@ -597,32 +563,31 @@ void Image::convert(Format p_new_format) {
_copy_internals_from(new_img);
- if (gen_mipmaps)
+ if (gen_mipmaps) {
generate_mipmaps();
+ }
}
Image::Format Image::get_format() const {
-
return format;
}
static double _bicubic_interp_kernel(double x) {
-
x = ABS(x);
double bc = 0;
- if (x <= 1)
+ if (x <= 1) {
bc = (1.5 * x - 2.5) * x * x + 1;
- else if (x < 2)
+ } else if (x < 2) {
bc = ((-0.5 * x + 2.5) * x - 4) * x + 2;
+ }
return bc;
}
template <int CC, class T>
static void _scale_cubic(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
-
// get source image size
int width = p_src_width;
int height = p_src_height;
@@ -663,20 +628,24 @@ static void _scale_cubic(const uint8_t *__restrict p_src, uint8_t *__restrict p_
k1 = _bicubic_interp_kernel(dy - (double)n);
oy2 = oy1 + n;
- if (oy2 < 0)
+ if (oy2 < 0) {
oy2 = 0;
- if (oy2 > ymax)
+ }
+ if (oy2 > ymax) {
oy2 = ymax;
+ }
for (int m = -1; m < 3; m++) {
// get X coefficient
k2 = k1 * _bicubic_interp_kernel((double)m - dx);
ox2 = ox1 + m;
- if (ox2 < 0)
+ if (ox2 < 0) {
ox2 = 0;
- if (ox2 > xmax)
+ }
+ if (ox2 > xmax) {
ox2 = xmax;
+ }
// get pixel of original image
const T *__restrict p = ((T *)p_src) + (oy2 * p_src_width + ox2) * CC;
@@ -706,7 +675,6 @@ static void _scale_cubic(const uint8_t *__restrict p_src, uint8_t *__restrict p_
template <int CC, class T>
static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
-
enum {
FRAC_BITS = 8,
FRAC_LEN = (1 << FRAC_BITS),
@@ -715,14 +683,14 @@ static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict
};
for (uint32_t i = 0; i < p_dst_height; i++) {
-
uint32_t src_yofs_up_fp = (i * p_src_height * FRAC_LEN / p_dst_height);
uint32_t src_yofs_frac = src_yofs_up_fp & FRAC_MASK;
uint32_t src_yofs_up = src_yofs_up_fp >> FRAC_BITS;
uint32_t src_yofs_down = (i + 1) * p_src_height / p_dst_height;
- if (src_yofs_down >= p_src_height)
+ if (src_yofs_down >= p_src_height) {
src_yofs_down = p_src_height - 1;
+ }
//src_yofs_up*=CC;
//src_yofs_down*=CC;
@@ -731,19 +699,18 @@ static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict
uint32_t y_ofs_down = src_yofs_down * p_src_width * CC;
for (uint32_t j = 0; j < p_dst_width; j++) {
-
uint32_t src_xofs_left_fp = (j * p_src_width * FRAC_LEN / p_dst_width);
uint32_t src_xofs_frac = src_xofs_left_fp & FRAC_MASK;
uint32_t src_xofs_left = src_xofs_left_fp >> FRAC_BITS;
uint32_t src_xofs_right = (j + 1) * p_src_width / p_dst_width;
- if (src_xofs_right >= p_src_width)
+ if (src_xofs_right >= p_src_width) {
src_xofs_right = p_src_width - 1;
+ }
src_xofs_left *= CC;
src_xofs_right *= CC;
for (uint32_t l = 0; l < CC; l++) {
-
if (sizeof(T) == 1) { //uint8
uint32_t p00 = p_src[y_ofs_up + src_xofs_left + l] << FRAC_BITS;
uint32_t p10 = p_src[y_ofs_up + src_xofs_right + l] << FRAC_BITS;
@@ -797,19 +764,15 @@ static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict
template <int CC, class T>
static void _scale_nearest(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
-
for (uint32_t i = 0; i < p_dst_height; i++) {
-
uint32_t src_yofs = i * p_src_height / p_dst_height;
uint32_t y_ofs = src_yofs * p_src_width * CC;
for (uint32_t j = 0; j < p_dst_width; j++) {
-
uint32_t src_xofs = j * p_src_width / p_dst_width;
src_xofs *= CC;
for (uint32_t l = 0; l < CC; l++) {
-
const T *src = ((const T *)p_src);
T *dst = ((T *)p_dst);
@@ -828,7 +791,6 @@ static float _lanczos(float p_x) {
template <int CC, class T>
static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
-
int32_t src_width = p_src_width;
int32_t src_height = p_src_height;
int32_t dst_height = p_dst_height;
@@ -847,40 +809,40 @@ static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict
float *kernel = memnew_arr(float, half_kernel * 2);
for (int32_t buffer_x = 0; buffer_x < dst_width; buffer_x++) {
-
// The corresponding point on the source image
float src_x = (buffer_x + 0.5f) * x_scale; // Offset by 0.5 so it uses the pixel's center
int32_t start_x = MAX(0, int32_t(src_x) - half_kernel + 1);
int32_t end_x = MIN(src_width - 1, int32_t(src_x) + half_kernel);
// Create the kernel used by all the pixels of the column
- for (int32_t target_x = start_x; target_x <= end_x; target_x++)
+ for (int32_t target_x = start_x; target_x <= end_x; target_x++) {
kernel[target_x - start_x] = _lanczos((target_x + 0.5f - src_x) / scale_factor);
+ }
for (int32_t buffer_y = 0; buffer_y < src_height; buffer_y++) {
-
float pixel[CC] = { 0 };
float weight = 0;
for (int32_t target_x = start_x; target_x <= end_x; target_x++) {
-
float lanczos_val = kernel[target_x - start_x];
weight += lanczos_val;
const T *__restrict src_data = ((const T *)p_src) + (buffer_y * src_width + target_x) * CC;
for (uint32_t i = 0; i < CC; i++) {
- if (sizeof(T) == 2) //half float
+ if (sizeof(T) == 2) { //half float
pixel[i] += Math::half_to_float(src_data[i]) * lanczos_val;
- else
+ } else {
pixel[i] += src_data[i] * lanczos_val;
+ }
}
}
float *dst_data = ((float *)buffer) + (buffer_y * dst_width + buffer_x) * CC;
- for (uint32_t i = 0; i < CC; i++)
+ for (uint32_t i = 0; i < CC; i++) {
dst_data[i] = pixel[i] / weight; // Normalize the sum of all the samples
+ }
}
}
@@ -897,28 +859,27 @@ static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict
float *kernel = memnew_arr(float, half_kernel * 2);
for (int32_t dst_y = 0; dst_y < dst_height; dst_y++) {
-
float buffer_y = (dst_y + 0.5f) * y_scale;
int32_t start_y = MAX(0, int32_t(buffer_y) - half_kernel + 1);
int32_t end_y = MIN(src_height - 1, int32_t(buffer_y) + half_kernel);
- for (int32_t target_y = start_y; target_y <= end_y; target_y++)
+ for (int32_t target_y = start_y; target_y <= end_y; target_y++) {
kernel[target_y - start_y] = _lanczos((target_y + 0.5f - buffer_y) / scale_factor);
+ }
for (int32_t dst_x = 0; dst_x < dst_width; dst_x++) {
-
float pixel[CC] = { 0 };
float weight = 0;
for (int32_t target_y = start_y; target_y <= end_y; target_y++) {
-
float lanczos_val = kernel[target_y - start_y];
weight += lanczos_val;
float *buffer_data = ((float *)buffer) + (target_y * dst_width + dst_x) * CC;
- for (uint32_t i = 0; i < CC; i++)
+ for (uint32_t i = 0; i < CC; i++) {
pixel[i] += buffer_data[i] * lanczos_val;
+ }
}
T *dst_data = ((T *)p_dst) + (dst_y * dst_width + dst_x) * CC;
@@ -926,12 +887,13 @@ static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict
for (uint32_t i = 0; i < CC; i++) {
pixel[i] /= weight;
- if (sizeof(T) == 1) //byte
+ if (sizeof(T) == 1) { //byte
dst_data[i] = CLAMP(Math::fast_ftoi(pixel[i]), 0, 255);
- else if (sizeof(T) == 2) //half float
+ } else if (sizeof(T) == 2) { //half float
dst_data[i] = Math::make_half_float(pixel[i]);
- else // float
+ } else { // float
dst_data[i] = pixel[i];
+ }
}
}
}
@@ -943,11 +905,9 @@ static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict
}
static void _overlay(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, float p_alpha, uint32_t p_width, uint32_t p_height, uint32_t p_pixel_size) {
-
uint16_t alpha = MIN((uint16_t)(p_alpha * 256.0f), 256);
for (uint32_t i = 0; i < p_width * p_height * p_pixel_size; i++) {
-
p_dst[i] = (p_dst[i] * (256 - alpha) + p_src[i] * alpha) >> 8;
}
}
@@ -957,7 +917,6 @@ bool Image::is_size_po2() const {
}
void Image::resize_to_po2(bool p_square) {
-
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats.");
int w = next_power_of_2(width);
@@ -967,16 +926,15 @@ void Image::resize_to_po2(bool p_square) {
}
if (w == width && h == height) {
-
- if (!p_square || w == h)
+ if (!p_square || w == h) {
return; //nothing to do
+ }
}
resize(w, h);
}
void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
-
ERR_FAIL_COND_MSG(data.size() == 0, "Cannot resize image before creating it, use create() or create_from_data() first.");
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats.");
@@ -988,10 +946,11 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
- if (p_width == width && p_height == height)
+ if (p_width == width && p_height == height) {
return;
+ }
- Image dst(p_width, p_height, 0, format);
+ Image dst(p_width, p_height, false, format);
// Setup mipmap-aware scaling
Image dst2;
@@ -1011,7 +970,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
}
bool interpolate_mipmaps = mipmap_aware && mip1 != mip2;
if (interpolate_mipmaps) {
- dst2.create(p_width, p_height, 0, format);
+ dst2.create(p_width, p_height, false, format);
}
bool had_mipmaps = mipmaps;
@@ -1027,9 +986,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
unsigned char *w_ptr = w;
switch (p_interpolation) {
-
case INTERPOLATE_NEAREST: {
-
if (format >= FORMAT_L8 && format <= FORMAT_RGBA8) {
switch (get_format_pixel_size(format)) {
case 1:
@@ -1081,7 +1038,6 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
} break;
case INTERPOLATE_BILINEAR:
case INTERPOLATE_TRILINEAR: {
-
for (int i = 0; i < 2; ++i) {
int src_width;
int src_height;
@@ -1174,7 +1130,6 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
} break;
case INTERPOLATE_CUBIC: {
-
if (format >= FORMAT_L8 && format <= FORMAT_RGBA8) {
switch (get_format_pixel_size(format)) {
case 1:
@@ -1223,7 +1178,6 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
}
} break;
case INTERPOLATE_LANCZOS: {
-
if (format >= FORMAT_L8 && format <= FORMAT_RGBA8) {
switch (get_format_pixel_size(format)) {
case 1:
@@ -1277,14 +1231,14 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
dst._copy_internals_from(dst2);
}
- if (had_mipmaps)
+ if (had_mipmaps) {
dst.generate_mipmaps();
+ }
_copy_internals_from(dst);
}
void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
-
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in compressed or custom image formats.");
ERR_FAIL_COND_MSG(p_x < 0, "Start x position cannot be smaller than 0.");
@@ -1298,13 +1252,14 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
will most likely either not be used much, or in critical areas, for now it won't, because
it's a waste of time. */
- if (p_width == width && p_height == height && p_x == 0 && p_y == 0)
+ if (p_width == width && p_height == height && p_x == 0 && p_y == 0) {
return;
+ }
uint8_t pdata[16]; //largest is 16
uint32_t pixel_size = get_format_pixel_size(format);
- Image dst(p_width, p_height, 0, format);
+ Image dst(p_width, p_height, false, format);
{
const uint8_t *r = data.ptr();
@@ -1313,12 +1268,11 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
int m_h = p_y + p_height;
int m_w = p_x + p_width;
for (int y = p_y; y < m_h; y++) {
-
for (int x = p_x; x < m_w; x++) {
-
if ((x >= width || y >= height)) {
- for (uint32_t i = 0; i < pixel_size; i++)
+ for (uint32_t i = 0; i < pixel_size; i++) {
pdata[i] = 0;
+ }
} else {
_get_pixelb(x, y, pixel_size, r, pdata);
}
@@ -1328,18 +1282,17 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
}
}
- if (has_mipmaps())
+ if (has_mipmaps()) {
dst.generate_mipmaps();
+ }
_copy_internals_from(dst);
}
void Image::crop(int p_width, int p_height) {
-
crop_from_point(0, 0, p_width, p_height);
}
void Image::flip_y() {
-
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot flip_y in compressed or custom image formats.");
bool used_mipmaps = has_mipmaps();
@@ -1354,9 +1307,7 @@ void Image::flip_y() {
uint32_t pixel_size = get_format_pixel_size(format);
for (int y = 0; y < height / 2; y++) {
-
for (int x = 0; x < width; x++) {
-
_get_pixelb(x, y, pixel_size, w, up);
_get_pixelb(x, height - y - 1, pixel_size, w, down);
@@ -1372,7 +1323,6 @@ void Image::flip_y() {
}
void Image::flip_x() {
-
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot flip_x in compressed or custom image formats.");
bool used_mipmaps = has_mipmaps();
@@ -1387,9 +1337,7 @@ void Image::flip_x() {
uint32_t pixel_size = get_format_pixel_size(format);
for (int y = 0; y < height; y++) {
-
for (int x = 0; x < width / 2; x++) {
-
_get_pixelb(x, y, pixel_size, w, up);
_get_pixelb(width - x - 1, y, pixel_size, w, down);
@@ -1405,7 +1353,6 @@ void Image::flip_x() {
}
int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps, int *r_mm_width, int *r_mm_height) {
-
int size = 0;
int w = p_width;
int h = p_height;
@@ -1420,7 +1367,6 @@ int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &
int minw = 1, minh = 1;
while (true) {
-
int bw = w % block != 0 ? w + (block - w % block) : w;
int bh = h % block != 0 ? h + (block - h % block) : h;
@@ -1438,28 +1384,28 @@ int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &
*r_mm_height = bh;
}
- if (p_mipmaps >= 0 && mm == p_mipmaps)
+ if (p_mipmaps >= 0 && mm == p_mipmaps) {
break;
+ }
if (p_mipmaps >= 0) {
-
w = MAX(minw, w >> 1);
h = MAX(minh, h >> 1);
} else {
- if (w == minw && h == minh)
+ if (w == minw && h == minh) {
break;
+ }
w = MAX(minw, w >> 1);
h = MAX(minh, h >> 1);
}
mm++;
- };
+ }
r_mipmaps = mm;
return size;
}
bool Image::_can_modify(Format p_format) const {
-
return p_format <= FORMAT_RGBE9995;
}
@@ -1467,7 +1413,6 @@ template <class Component, int CC, bool renormalize,
void (*average_func)(Component &, const Component &, const Component &, const Component &, const Component &),
void (*renormalize_func)(Component *)>
static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint32_t p_width, uint32_t p_height) {
-
//fast power of 2 mipmap generation
uint32_t dst_w = MAX(p_width >> 1, 1);
uint32_t dst_h = MAX(p_height >> 1, 1);
@@ -1476,7 +1421,6 @@ static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint3
int down_step = (p_height == 1) ? 0 : (p_width * CC);
for (uint32_t i = 0; i < dst_h; i++) {
-
const Component *rup_ptr = &p_src[i * 2 * down_step];
const Component *rdown_ptr = rup_ptr + down_step;
Component *dst_ptr = &p_dst[i * dst_w * CC];
@@ -1499,52 +1443,10 @@ static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint3
}
}
-void Image::expand_x2_hq2x() {
-
- ERR_FAIL_COND(!_can_modify(format));
-
- bool used_mipmaps = has_mipmaps();
- if (used_mipmaps) {
- clear_mipmaps();
- }
-
- Format current = format;
-
- if (current != FORMAT_RGBA8)
- convert(FORMAT_RGBA8);
-
- Vector<uint8_t> dest;
- dest.resize(width * 2 * height * 2 * 4);
-
- {
- const uint8_t *r = data.ptr();
- uint8_t *w = dest.ptrw();
-
- ERR_FAIL_COND(!r);
-
- hq2x_resize((const uint32_t *)r, width, height, (uint32_t *)w);
- }
-
- width *= 2;
- height *= 2;
- data = dest;
-
- if (current != FORMAT_RGBA8)
- convert(current);
-
- // FIXME: This is likely meant to use "used_mipmaps" as defined above, but if we do,
- // we end up with a regression: GH-22747
- if (mipmaps) {
- generate_mipmaps();
- }
-}
-
void Image::shrink_x2() {
-
ERR_FAIL_COND(data.size() == 0);
if (mipmaps) {
-
//just use the lower mipmap as base and copy all
Vector<uint8_t> new_img;
@@ -1566,7 +1468,6 @@ void Image::shrink_x2() {
data = new_img;
} else {
-
Vector<uint8_t> new_img;
ERR_FAIL_COND(!_can_modify(format));
@@ -1580,7 +1481,6 @@ void Image::shrink_x2() {
const uint8_t *r = data.ptr();
switch (format) {
-
case FORMAT_L8:
case FORMAT_R8:
_generate_po2_mipmap<uint8_t, 1, false, Image::average_4_uint8, Image::renormalize_uint8>(r, w, width, height);
@@ -1639,16 +1539,13 @@ void Image::shrink_x2() {
}
void Image::normalize() {
-
bool used_mipmaps = has_mipmaps();
if (used_mipmaps) {
clear_mipmaps();
}
for (int y = 0; y < height; y++) {
-
for (int x = 0; x < width; x++) {
-
Color c = get_pixel(x, y);
Vector3 v(c.r * 2.0 - 1.0, c.g * 2.0 - 1.0, c.b * 2.0 - 1.0);
v.normalize();
@@ -1665,7 +1562,6 @@ void Image::normalize() {
}
Error Image::generate_mipmaps(bool p_renormalize) {
-
ERR_FAIL_COND_V_MSG(!_can_modify(format), ERR_UNAVAILABLE, "Cannot generate mipmaps in compressed or custom image formats.");
ERR_FAIL_COND_V_MSG(format == FORMAT_RGBA4444, ERR_UNAVAILABLE, "Cannot generate mipmaps from RGBA4444 format.");
@@ -1685,12 +1581,10 @@ Error Image::generate_mipmaps(bool p_renormalize) {
int prev_w = width;
for (int i = 1; i <= mmcount; i++) {
-
int ofs, w, h;
_get_mipmap_offset_and_size(i, ofs, w, h);
switch (format) {
-
case FORMAT_L8:
case FORMAT_R8:
_generate_po2_mipmap<uint8_t, 1, false, Image::average_4_uint8, Image::renormalize_uint8>(&wp[prev_ofs], &wp[ofs], prev_w, prev_h);
@@ -1700,17 +1594,19 @@ Error Image::generate_mipmaps(bool p_renormalize) {
_generate_po2_mipmap<uint8_t, 2, false, Image::average_4_uint8, Image::renormalize_uint8>(&wp[prev_ofs], &wp[ofs], prev_w, prev_h);
break;
case FORMAT_RGB8:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<uint8_t, 3, true, Image::average_4_uint8, Image::renormalize_uint8>(&wp[prev_ofs], &wp[ofs], prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<uint8_t, 3, false, Image::average_4_uint8, Image::renormalize_uint8>(&wp[prev_ofs], &wp[ofs], prev_w, prev_h);
+ }
break;
case FORMAT_RGBA8:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<uint8_t, 4, true, Image::average_4_uint8, Image::renormalize_uint8>(&wp[prev_ofs], &wp[ofs], prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<uint8_t, 4, false, Image::average_4_uint8, Image::renormalize_uint8>(&wp[prev_ofs], &wp[ofs], prev_w, prev_h);
+ }
break;
case FORMAT_RF:
_generate_po2_mipmap<float, 1, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(&wp[prev_ofs]), reinterpret_cast<float *>(&wp[ofs]), prev_w, prev_h);
@@ -1719,17 +1615,19 @@ Error Image::generate_mipmaps(bool p_renormalize) {
_generate_po2_mipmap<float, 2, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(&wp[prev_ofs]), reinterpret_cast<float *>(&wp[ofs]), prev_w, prev_h);
break;
case FORMAT_RGBF:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<float, 3, true, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(&wp[prev_ofs]), reinterpret_cast<float *>(&wp[ofs]), prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<float, 3, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(&wp[prev_ofs]), reinterpret_cast<float *>(&wp[ofs]), prev_w, prev_h);
+ }
break;
case FORMAT_RGBAF:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<float, 4, true, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(&wp[prev_ofs]), reinterpret_cast<float *>(&wp[ofs]), prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<float, 4, false, Image::average_4_float, Image::renormalize_float>(reinterpret_cast<const float *>(&wp[prev_ofs]), reinterpret_cast<float *>(&wp[ofs]), prev_w, prev_h);
+ }
break;
case FORMAT_RH:
@@ -1739,24 +1637,27 @@ Error Image::generate_mipmaps(bool p_renormalize) {
_generate_po2_mipmap<uint16_t, 2, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(&wp[prev_ofs]), reinterpret_cast<uint16_t *>(&wp[ofs]), prev_w, prev_h);
break;
case FORMAT_RGBH:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<uint16_t, 3, true, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(&wp[prev_ofs]), reinterpret_cast<uint16_t *>(&wp[ofs]), prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<uint16_t, 3, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(&wp[prev_ofs]), reinterpret_cast<uint16_t *>(&wp[ofs]), prev_w, prev_h);
+ }
break;
case FORMAT_RGBAH:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<uint16_t, 4, true, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(&wp[prev_ofs]), reinterpret_cast<uint16_t *>(&wp[ofs]), prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<uint16_t, 4, false, Image::average_4_half, Image::renormalize_half>(reinterpret_cast<const uint16_t *>(&wp[prev_ofs]), reinterpret_cast<uint16_t *>(&wp[ofs]), prev_w, prev_h);
+ }
break;
case FORMAT_RGBE9995:
- if (p_renormalize)
+ if (p_renormalize) {
_generate_po2_mipmap<uint32_t, 1, true, Image::average_4_rgbe9995, Image::renormalize_rgbe9995>(reinterpret_cast<const uint32_t *>(&wp[prev_ofs]), reinterpret_cast<uint32_t *>(&wp[ofs]), prev_w, prev_h);
- else
+ } else {
_generate_po2_mipmap<uint32_t, 1, false, Image::average_4_rgbe9995, Image::renormalize_rgbe9995>(reinterpret_cast<const uint32_t *>(&wp[prev_ofs]), reinterpret_cast<uint32_t *>(&wp[ofs]), prev_w, prev_h);
+ }
break;
default: {
@@ -1774,7 +1675,6 @@ Error Image::generate_mipmaps(bool p_renormalize) {
}
Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, const Ref<Image> &p_normal_map) {
-
Vector<double> normal_sat_vec; //summed area table
double *normal_sat = nullptr; //summed area table for normalmap
int normal_w = 0, normal_h = 0;
@@ -1839,7 +1739,6 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
uint8_t *base_ptr = data.ptrw();
for (int i = 1; i <= mmcount; i++) {
-
int ofs, w, h;
_get_mipmap_offset_and_size(i, ofs, w, h);
uint8_t *ptr = &base_ptr[ofs];
@@ -1970,12 +1869,13 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
}
void Image::clear_mipmaps() {
-
- if (!mipmaps)
+ if (!mipmaps) {
return;
+ }
- if (empty())
+ if (empty()) {
return;
+ }
int ofs, w, h;
_get_mipmap_offset_and_size(1, ofs, w, h);
@@ -1985,17 +1885,14 @@ void Image::clear_mipmaps() {
}
bool Image::empty() const {
-
return (data.size() == 0);
}
Vector<uint8_t> Image::get_data() const {
-
return data;
}
void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
-
ERR_FAIL_INDEX(p_width - 1, MAX_WIDTH);
ERR_FAIL_INDEX(p_height - 1, MAX_HEIGHT);
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
@@ -2016,7 +1913,6 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
}
void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
-
ERR_FAIL_INDEX(p_width - 1, MAX_WIDTH);
ERR_FAIL_INDEX(p_height - 1, MAX_HEIGHT);
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
@@ -2035,7 +1931,6 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
}
void Image::create(const char **p_xpm) {
-
int size_width = 0;
int size_height = 0;
int pixelchars = 0;
@@ -2055,16 +1950,13 @@ void Image::create(const char **p_xpm) {
HashMap<String, Color> colormap;
int colormap_size = 0;
uint32_t pixel_size = 0;
- uint8_t *w;
+ uint8_t *data_write = nullptr;
while (status != DONE) {
-
const char *line_ptr = p_xpm[line];
switch (status) {
-
case READING_HEADER: {
-
String line_str = line_ptr;
line_str.replace("\t", " ");
@@ -2079,25 +1971,24 @@ void Image::create(const char **p_xpm) {
status = READING_COLORS;
} break;
case READING_COLORS: {
-
String colorstring;
for (int i = 0; i < pixelchars; i++) {
-
colorstring += *line_ptr;
line_ptr++;
}
//skip spaces
while (*line_ptr == ' ' || *line_ptr == '\t' || *line_ptr == 0) {
- if (*line_ptr == 0)
+ if (*line_ptr == 0) {
break;
+ }
line_ptr++;
}
if (*line_ptr == 'c') {
-
line_ptr++;
while (*line_ptr == ' ' || *line_ptr == '\t' || *line_ptr == 0) {
- if (*line_ptr == 0)
+ if (*line_ptr == 0) {
break;
+ }
line_ptr++;
}
@@ -2109,17 +2000,17 @@ void Image::create(const char **p_xpm) {
//uint8_t col_a=255;
for (int i = 0; i < 6; i++) {
-
char v = line_ptr[i];
- if (v >= '0' && v <= '9')
+ if (v >= '0' && v <= '9') {
v -= '0';
- else if (v >= 'A' && v <= 'F')
+ } else if (v >= 'A' && v <= 'F') {
v = (v - 'A') + 10;
- else if (v >= 'a' && v <= 'f')
+ } else if (v >= 'a' && v <= 'f') {
v = (v - 'a') + 10;
- else
+ } else {
break;
+ }
switch (i) {
case 0:
@@ -2140,36 +2031,32 @@ void Image::create(const char **p_xpm) {
case 5:
col_b |= v;
break;
- };
+ }
}
// magenta mask
if (col_r == 255 && col_g == 0 && col_b == 255) {
-
colormap[colorstring] = Color(0, 0, 0, 0);
has_alpha = true;
} else {
-
colormap[colorstring] = Color(col_r / 255.0, col_g / 255.0, col_b / 255.0, 1.0);
}
}
}
if (line == colormap_size) {
-
status = READING_PIXELS;
- create(size_width, size_height, 0, has_alpha ? FORMAT_RGBA8 : FORMAT_RGB8);
- w = data.ptrw();
+ create(size_width, size_height, false, has_alpha ? FORMAT_RGBA8 : FORMAT_RGB8);
+ data_write = data.ptrw();
pixel_size = has_alpha ? 4 : 3;
}
} break;
case READING_PIXELS: {
-
int y = line - colormap_size - 1;
for (int x = 0; x < size_width; x++) {
-
char pixelstr[6] = { 0, 0, 0, 0, 0, 0 };
- for (int i = 0; i < pixelchars; i++)
+ for (int i = 0; i < pixelchars; i++) {
pixelstr[i] = line_ptr[x * pixelchars + i];
+ }
Color *colorptr = colormap.getptr(pixelstr);
ERR_FAIL_COND(!colorptr);
@@ -2177,11 +2064,12 @@ void Image::create(const char **p_xpm) {
for (uint32_t i = 0; i < pixel_size; i++) {
pixel[i] = CLAMP((*colorptr)[i] * 255, 0, 255);
}
- _put_pixelb(x, y, pixel_size, w, pixel);
+ _put_pixelb(x, y, pixel_size, data_write, pixel);
}
- if (y == (size_height - 1))
+ if (y == (size_height - 1)) {
status = DONE;
+ }
} break;
default: {
}
@@ -2199,7 +2087,6 @@ void Image::create(const char **p_xpm) {
if (value < DETECT_ALPHA_MIN_THRESHOLD) \
bit = true; \
else if (value < DETECT_ALPHA_MAX_THRESHOLD) { \
- \
detected = true; \
break; \
} \
@@ -2209,22 +2096,22 @@ void Image::create(const char **p_xpm) {
{ \
uint8_t value = m_value; \
if (value > 0) { \
- \
detected = true; \
break; \
} \
}
bool Image::is_invisible() const {
-
if (format == FORMAT_L8 ||
- format == FORMAT_RGB8 || format == FORMAT_RG8)
+ format == FORMAT_RGB8 || format == FORMAT_RG8) {
return false;
+ }
int len = data.size();
- if (len == 0)
+ if (len == 0) {
return true;
+ }
int w, h;
_get_mipmap_offset_and_size(1, len, w, h);
@@ -2235,16 +2122,13 @@ bool Image::is_invisible() const {
bool detected = false;
switch (format) {
-
case FORMAT_LA8: {
-
for (int i = 0; i < (len >> 1); i++) {
DETECT_NON_ALPHA(data_ptr[(i << 1) + 1]);
}
} break;
case FORMAT_RGBA8: {
-
for (int i = 0; i < (len >> 2); i++) {
DETECT_NON_ALPHA(data_ptr[(i << 2) + 3])
}
@@ -2265,11 +2149,11 @@ bool Image::is_invisible() const {
}
Image::AlphaMode Image::detect_alpha() const {
-
int len = data.size();
- if (len == 0)
+ if (len == 0) {
return ALPHA_NONE;
+ }
int w, h;
_get_mipmap_offset_and_size(1, len, w, h);
@@ -2281,16 +2165,13 @@ Image::AlphaMode Image::detect_alpha() const {
bool detected = false;
switch (format) {
-
case FORMAT_LA8: {
-
for (int i = 0; i < (len >> 1); i++) {
DETECT_ALPHA(data_ptr[(i << 1) + 1]);
}
} break;
case FORMAT_RGBA8: {
-
for (int i = 0; i < (len >> 2); i++) {
DETECT_ALPHA(data_ptr[(i << 2) + 3])
}
@@ -2306,12 +2187,13 @@ Image::AlphaMode Image::detect_alpha() const {
}
}
- if (detected)
+ if (detected) {
return ALPHA_BLEND;
- else if (bit)
+ } else if (bit) {
return ALPHA_BIT;
- else
+ } else {
return ALPHA_NONE;
+ }
}
Error Image::load(const String &p_path) {
@@ -2324,9 +2206,9 @@ Error Image::load(const String &p_path) {
}
Error Image::save_png(const String &p_path) const {
-
- if (save_png_func == nullptr)
+ if (save_png_func == nullptr) {
return ERR_UNAVAILABLE;
+ }
return save_png_func(p_path, Ref<Image>((Image *)this));
}
@@ -2340,21 +2222,19 @@ Vector<uint8_t> Image::save_png_to_buffer() const {
}
Error Image::save_exr(const String &p_path, bool p_grayscale) const {
-
- if (save_exr_func == nullptr)
+ if (save_exr_func == nullptr) {
return ERR_UNAVAILABLE;
+ }
return save_exr_func(p_path, Ref<Image>((Image *)this), p_grayscale);
}
int Image::get_image_data_size(int p_width, int p_height, Format p_format, bool p_mipmaps) {
-
int mm;
return _get_dst_image_size(p_width, p_height, p_format, mm, p_mipmaps ? -1 : 0);
}
int Image::get_image_required_mipmaps(int p_width, int p_height, Format p_format) {
-
int mm;
_get_dst_image_size(p_width, p_height, p_format, mm, -1);
return mm;
@@ -2368,7 +2248,6 @@ Size2i Image::get_image_mipmap_size(int p_width, int p_height, Format p_format,
}
int Image::get_image_mipmap_offset(int p_width, int p_height, Format p_format, int p_mipmap) {
-
if (p_mipmap <= 0) {
return 0;
}
@@ -2377,7 +2256,6 @@ int Image::get_image_mipmap_offset(int p_width, int p_height, Format p_format, i
}
int Image::get_image_mipmap_offset_and_dimensions(int p_width, int p_height, Format p_format, int p_mipmap, int &r_w, int &r_h) {
-
if (p_mipmap <= 0) {
r_w = p_width;
r_h = p_height;
@@ -2392,57 +2270,49 @@ bool Image::is_compressed() const {
}
Error Image::decompress() {
-
- if (((format >= FORMAT_DXT1 && format <= FORMAT_RGTC_RG) || (format == FORMAT_DXT5_RA_AS_RG)) && _image_decompress_bc)
+ if (((format >= FORMAT_DXT1 && format <= FORMAT_RGTC_RG) || (format == FORMAT_DXT5_RA_AS_RG)) && _image_decompress_bc) {
_image_decompress_bc(this);
- else if (format >= FORMAT_BPTC_RGBA && format <= FORMAT_BPTC_RGBFU && _image_decompress_bptc)
+ } else if (format >= FORMAT_BPTC_RGBA && format <= FORMAT_BPTC_RGBFU && _image_decompress_bptc) {
_image_decompress_bptc(this);
- else if (format >= FORMAT_PVRTC2 && format <= FORMAT_PVRTC4A && _image_decompress_pvrtc)
+ } else if (format >= FORMAT_PVRTC2 && format <= FORMAT_PVRTC4A && _image_decompress_pvrtc) {
_image_decompress_pvrtc(this);
- else if (format == FORMAT_ETC && _image_decompress_etc1)
+ } else if (format == FORMAT_ETC && _image_decompress_etc1) {
_image_decompress_etc1(this);
- else if (format >= FORMAT_ETC2_R11 && format <= FORMAT_ETC2_RA_AS_RG && _image_decompress_etc2)
+ } else if (format >= FORMAT_ETC2_R11 && format <= FORMAT_ETC2_RA_AS_RG && _image_decompress_etc2) {
_image_decompress_etc2(this);
- else
+ } else {
return ERR_UNAVAILABLE;
+ }
return OK;
}
Error Image::compress(CompressMode p_mode, CompressSource p_source, float p_lossy_quality) {
-
return compress_from_channels(p_mode, detect_used_channels(p_source), p_lossy_quality);
}
-Error Image::compress_from_channels(CompressMode p_mode, UsedChannels p_channels, float p_lossy_quality) {
+Error Image::compress_from_channels(CompressMode p_mode, UsedChannels p_channels, float p_lossy_quality) {
switch (p_mode) {
-
case COMPRESS_S3TC: {
-
ERR_FAIL_COND_V(!_image_compress_bc_func, ERR_UNAVAILABLE);
_image_compress_bc_func(this, p_lossy_quality, p_channels);
} break;
case COMPRESS_PVRTC2: {
-
ERR_FAIL_COND_V(!_image_compress_pvrtc2_func, ERR_UNAVAILABLE);
_image_compress_pvrtc2_func(this);
} break;
case COMPRESS_PVRTC4: {
-
ERR_FAIL_COND_V(!_image_compress_pvrtc4_func, ERR_UNAVAILABLE);
_image_compress_pvrtc4_func(this);
} break;
case COMPRESS_ETC: {
-
ERR_FAIL_COND_V(!_image_compress_etc1_func, ERR_UNAVAILABLE);
_image_compress_etc1_func(this, p_lossy_quality);
} break;
case COMPRESS_ETC2: {
-
ERR_FAIL_COND_V(!_image_compress_etc2_func, ERR_UNAVAILABLE);
_image_compress_etc2_func(this, p_lossy_quality, p_channels);
} break;
case COMPRESS_BPTC: {
-
ERR_FAIL_COND_V(!_image_compress_bptc_func, ERR_UNAVAILABLE);
_image_compress_bptc_func(this, p_lossy_quality, p_channels);
} break;
@@ -2452,7 +2322,6 @@ Error Image::compress_from_channels(CompressMode p_mode, UsedChannels p_channels
}
Image::Image(const char **p_xpm) {
-
width = 0;
height = 0;
mipmaps = false;
@@ -2462,7 +2331,6 @@ Image::Image(const char **p_xpm) {
}
Image::Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
-
width = 0;
height = 0;
mipmaps = p_use_mipmaps;
@@ -2472,7 +2340,6 @@ Image::Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
}
Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
-
width = 0;
height = 0;
mipmaps = p_mipmaps;
@@ -2482,48 +2349,52 @@ Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const V
}
Rect2 Image::get_used_rect() const {
-
- if (format != FORMAT_LA8 && format != FORMAT_RGBA8 && format != FORMAT_RGBAF && format != FORMAT_RGBAH && format != FORMAT_RGBA4444 && format != FORMAT_RGB565)
+ if (format != FORMAT_LA8 && format != FORMAT_RGBA8 && format != FORMAT_RGBAF && format != FORMAT_RGBAH && format != FORMAT_RGBA4444 && format != FORMAT_RGB565) {
return Rect2(Point2(), Size2(width, height));
+ }
int len = data.size();
- if (len == 0)
+ if (len == 0) {
return Rect2();
+ }
int minx = 0xFFFFFF, miny = 0xFFFFFFF;
int maxx = -1, maxy = -1;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
-
- if (!(get_pixel(i, j).a > 0))
+ if (!(get_pixel(i, j).a > 0)) {
continue;
- if (i > maxx)
+ }
+ if (i > maxx) {
maxx = i;
- if (j > maxy)
+ }
+ if (j > maxy) {
maxy = j;
- if (i < minx)
+ }
+ if (i < minx) {
minx = i;
- if (j < miny)
+ }
+ if (j < miny) {
miny = j;
+ }
}
}
- if (maxx == -1)
+ if (maxx == -1) {
return Rect2();
- else
+ } else {
return Rect2(minx, miny, maxx - minx + 1, maxy - miny + 1);
+ }
}
Ref<Image> Image::get_rect(const Rect2 &p_area) const {
-
Ref<Image> img = memnew(Image(p_area.size.x, p_area.size.y, mipmaps, format));
img->blit_rect(Ref<Image>((Image *)this), p_area, Point2(0, 0));
return img;
}
void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) {
-
ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size();
int srcdsize = p_src->data.size();
@@ -2534,13 +2405,16 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po
Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect);
- if (p_dest.x < 0)
+ if (p_dest.x < 0) {
clipped_src_rect.position.x = ABS(p_dest.x);
- if (p_dest.y < 0)
+ }
+ if (p_dest.y < 0) {
clipped_src_rect.position.y = ABS(p_dest.y);
+ }
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0)
+ if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
return;
+ }
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
@@ -2554,9 +2428,7 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po
int pixel_size = get_format_pixel_size(format);
for (int i = 0; i < dest_rect.size.y; i++) {
-
for (int j = 0; j < dest_rect.size.x; j++) {
-
int src_x = clipped_src_rect.position.x + j;
int src_y = clipped_src_rect.position.y + i;
@@ -2574,7 +2446,6 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po
}
void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
-
ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
ERR_FAIL_COND_MSG(p_mask.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size();
@@ -2589,13 +2460,16 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect);
- if (p_dest.x < 0)
+ if (p_dest.x < 0) {
clipped_src_rect.position.x = ABS(p_dest.x);
- if (p_dest.y < 0)
+ }
+ if (p_dest.y < 0) {
clipped_src_rect.position.y = ABS(p_dest.y);
+ }
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0)
+ if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
return;
+ }
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
@@ -2611,14 +2485,11 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
Ref<Image> msk = p_mask;
for (int i = 0; i < dest_rect.size.y; i++) {
-
for (int j = 0; j < dest_rect.size.x; j++) {
-
int src_x = clipped_src_rect.position.x + j;
int src_y = clipped_src_rect.position.y + i;
if (msk->get_pixel(src_x, src_y).a != 0) {
-
int dst_x = dest_rect.position.x + j;
int dst_y = dest_rect.position.y + i;
@@ -2634,7 +2505,6 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co
}
void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) {
-
ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size();
int srcdsize = p_src->data.size();
@@ -2644,13 +2514,16 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect);
- if (p_dest.x < 0)
+ if (p_dest.x < 0) {
clipped_src_rect.position.x = ABS(p_dest.x);
- if (p_dest.y < 0)
+ }
+ if (p_dest.y < 0) {
clipped_src_rect.position.y = ABS(p_dest.y);
+ }
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0)
+ if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
return;
+ }
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
@@ -2658,9 +2531,7 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
Ref<Image> img = p_src;
for (int i = 0; i < dest_rect.size.y; i++) {
-
for (int j = 0; j < dest_rect.size.x; j++) {
-
int src_x = clipped_src_rect.position.x + j;
int src_y = clipped_src_rect.position.y + i;
@@ -2668,18 +2539,16 @@ void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const P
int dst_y = dest_rect.position.y + i;
Color sc = img->get_pixel(src_x, src_y);
- Color dc = get_pixel(dst_x, dst_y);
- dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
- dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
- dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
- dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
- set_pixel(dst_x, dst_y, dc);
+ if (sc.a != 0) {
+ Color dc = get_pixel(dst_x, dst_y);
+ dc = dc.blend(sc);
+ set_pixel(dst_x, dst_y, dc);
+ }
}
}
}
void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) {
-
ERR_FAIL_COND_MSG(p_src.is_null(), "It's not a reference to a valid Image object.");
ERR_FAIL_COND_MSG(p_mask.is_null(), "It's not a reference to a valid Image object.");
int dsize = data.size();
@@ -2694,13 +2563,16 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect);
- if (p_dest.x < 0)
+ if (p_dest.x < 0) {
clipped_src_rect.position.x = ABS(p_dest.x);
- if (p_dest.y < 0)
+ }
+ if (p_dest.y < 0) {
clipped_src_rect.position.y = ABS(p_dest.y);
+ }
- if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0)
+ if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) {
return;
+ }
Point2 src_underscan = Point2(MIN(0, p_src_rect.position.x), MIN(0, p_src_rect.position.y));
Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest - src_underscan, clipped_src_rect.size));
@@ -2709,9 +2581,7 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
Ref<Image> msk = p_mask;
for (int i = 0; i < dest_rect.size.y; i++) {
-
for (int j = 0; j < dest_rect.size.x; j++) {
-
int src_x = clipped_src_rect.position.x + j;
int src_y = clipped_src_rect.position.y + i;
@@ -2719,17 +2589,15 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c
//Color c = msk->get_pixel(src_x, src_y);
//if (c.a == 0) continue;
if (msk->get_pixel(src_x, src_y).a != 0) {
-
int dst_x = dest_rect.position.x + j;
int dst_y = dest_rect.position.y + i;
Color sc = img->get_pixel(src_x, src_y);
- Color dc = get_pixel(dst_x, dst_y);
- dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
- dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
- dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
- dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
- set_pixel(dst_x, dst_y, dc);
+ if (sc.a != 0) {
+ Color dc = get_pixel(dst_x, dst_y);
+ dc = dc.blend(sc);
+ set_pixel(dst_x, dst_y, dc);
+ }
}
}
}
@@ -2747,9 +2615,7 @@ void Image::fill(const Color &c) {
set_pixel(0, 0, c);
for (int y = 0; y < height; y++) {
-
for (int x = 0; x < width; x++) {
-
uint8_t *dst = &dst_data_ptr[(y * width + x) * pixel_size];
for (int k = 0; k < pixel_size; k++) {
@@ -2783,7 +2649,6 @@ Vector<uint8_t> (*Image::basis_universal_packer)(const Ref<Image> &, Image::Used
Ref<Image> (*Image::basis_universal_unpacker)(const Vector<uint8_t> &) = nullptr;
void Image::_set_data(const Dictionary &p_data) {
-
ERR_FAIL_COND(!p_data.has("width"));
ERR_FAIL_COND(!p_data.has("height"));
ERR_FAIL_COND(!p_data.has("format"));
@@ -2809,7 +2674,6 @@ void Image::_set_data(const Dictionary &p_data) {
}
Dictionary Image::_get_data() const {
-
Dictionary d;
d["width"] = width;
d["height"] = height;
@@ -2824,7 +2688,6 @@ Color Image::get_pixelv(const Point2 &p_src) const {
}
Color Image::_get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const {
-
switch (format) {
case FORMAT_L8: {
float l = ptr[ofs] / 255.0;
@@ -2836,12 +2699,10 @@ Color Image::_get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const {
return Color(l, l, l, a);
}
case FORMAT_R8: {
-
float r = ptr[ofs] / 255.0;
return Color(r, 0, 0, 1);
}
case FORMAT_RG8: {
-
float r = ptr[ofs * 2 + 0] / 255.0;
float g = ptr[ofs * 2 + 1] / 255.0;
return Color(r, g, 0, 1);
@@ -2868,7 +2729,6 @@ Color Image::_get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const {
return Color(r, g, b, a);
}
case FORMAT_RGB565: {
-
uint16_t u = ((uint16_t *)ptr)[ofs];
float r = (u & 0x1F) / 31.0;
float g = ((u >> 5) & 0x3F) / 63.0;
@@ -2876,25 +2736,21 @@ Color Image::_get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const {
return Color(r, g, b, 1.0);
}
case FORMAT_RF: {
-
float r = ((float *)ptr)[ofs];
return Color(r, 0, 0, 1);
}
case FORMAT_RGF: {
-
float r = ((float *)ptr)[ofs * 2 + 0];
float g = ((float *)ptr)[ofs * 2 + 1];
return Color(r, g, 0, 1);
}
case FORMAT_RGBF: {
-
float r = ((float *)ptr)[ofs * 3 + 0];
float g = ((float *)ptr)[ofs * 3 + 1];
float b = ((float *)ptr)[ofs * 3 + 2];
return Color(r, g, b, 1);
}
case FORMAT_RGBAF: {
-
float r = ((float *)ptr)[ofs * 4 + 0];
float g = ((float *)ptr)[ofs * 4 + 1];
float b = ((float *)ptr)[ofs * 4 + 2];
@@ -2902,25 +2758,21 @@ Color Image::_get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const {
return Color(r, g, b, a);
}
case FORMAT_RH: {
-
uint16_t r = ((uint16_t *)ptr)[ofs];
return Color(Math::half_to_float(r), 0, 0, 1);
}
case FORMAT_RGH: {
-
uint16_t r = ((uint16_t *)ptr)[ofs * 2 + 0];
uint16_t g = ((uint16_t *)ptr)[ofs * 2 + 1];
return Color(Math::half_to_float(r), Math::half_to_float(g), 0, 1);
}
case FORMAT_RGBH: {
-
uint16_t r = ((uint16_t *)ptr)[ofs * 3 + 0];
uint16_t g = ((uint16_t *)ptr)[ofs * 3 + 1];
uint16_t b = ((uint16_t *)ptr)[ofs * 3 + 2];
return Color(Math::half_to_float(r), Math::half_to_float(g), Math::half_to_float(b), 1);
}
case FORMAT_RGBAH: {
-
uint16_t r = ((uint16_t *)ptr)[ofs * 4 + 0];
uint16_t g = ((uint16_t *)ptr)[ofs * 4 + 1];
uint16_t b = ((uint16_t *)ptr)[ofs * 4 + 2];
@@ -2946,11 +2798,9 @@ void Image::_set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color)
ptr[ofs * 2 + 1] = uint8_t(CLAMP(p_color.a * 255.0, 0, 255));
} break;
case FORMAT_R8: {
-
ptr[ofs] = uint8_t(CLAMP(p_color.r * 255.0, 0, 255));
} break;
case FORMAT_RG8: {
-
ptr[ofs * 2 + 0] = uint8_t(CLAMP(p_color.r * 255.0, 0, 255));
ptr[ofs * 2 + 1] = uint8_t(CLAMP(p_color.g * 255.0, 0, 255));
} break;
@@ -2967,7 +2817,6 @@ void Image::_set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color)
} break;
case FORMAT_RGBA4444: {
-
uint16_t rgba = 0;
rgba = uint16_t(CLAMP(p_color.r * 15.0, 0, 15)) << 12;
@@ -2979,7 +2828,6 @@ void Image::_set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color)
} break;
case FORMAT_RGB565: {
-
uint16_t rgba = 0;
rgba = uint16_t(CLAMP(p_color.r * 31.0, 0, 31));
@@ -2990,51 +2838,42 @@ void Image::_set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color)
} break;
case FORMAT_RF: {
-
((float *)ptr)[ofs] = p_color.r;
} break;
case FORMAT_RGF: {
-
((float *)ptr)[ofs * 2 + 0] = p_color.r;
((float *)ptr)[ofs * 2 + 1] = p_color.g;
} break;
case FORMAT_RGBF: {
-
((float *)ptr)[ofs * 3 + 0] = p_color.r;
((float *)ptr)[ofs * 3 + 1] = p_color.g;
((float *)ptr)[ofs * 3 + 2] = p_color.b;
} break;
case FORMAT_RGBAF: {
-
((float *)ptr)[ofs * 4 + 0] = p_color.r;
((float *)ptr)[ofs * 4 + 1] = p_color.g;
((float *)ptr)[ofs * 4 + 2] = p_color.b;
((float *)ptr)[ofs * 4 + 3] = p_color.a;
} break;
case FORMAT_RH: {
-
((uint16_t *)ptr)[ofs] = Math::make_half_float(p_color.r);
} break;
case FORMAT_RGH: {
-
((uint16_t *)ptr)[ofs * 2 + 0] = Math::make_half_float(p_color.r);
((uint16_t *)ptr)[ofs * 2 + 1] = Math::make_half_float(p_color.g);
} break;
case FORMAT_RGBH: {
-
((uint16_t *)ptr)[ofs * 3 + 0] = Math::make_half_float(p_color.r);
((uint16_t *)ptr)[ofs * 3 + 1] = Math::make_half_float(p_color.g);
((uint16_t *)ptr)[ofs * 3 + 2] = Math::make_half_float(p_color.b);
} break;
case FORMAT_RGBAH: {
-
((uint16_t *)ptr)[ofs * 4 + 0] = Math::make_half_float(p_color.r);
((uint16_t *)ptr)[ofs * 4 + 1] = Math::make_half_float(p_color.g);
((uint16_t *)ptr)[ofs * 4 + 2] = Math::make_half_float(p_color.b);
((uint16_t *)ptr)[ofs * 4 + 3] = Math::make_half_float(p_color.a);
} break;
case FORMAT_RGBE9995: {
-
((uint32_t *)ptr)[ofs] = p_color.to_rgbe9995();
} break;
@@ -3069,24 +2908,26 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
}
Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
-
ERR_FAIL_COND_V(data.size() == 0, USED_CHANNELS_RGBA);
ERR_FAIL_COND_V(is_compressed(), USED_CHANNELS_RGBA);
bool r = false, g = false, b = false, a = false, c = false;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
-
Color col = get_pixel(i, j);
- if (col.r > 0.001)
+ if (col.r > 0.001) {
r = true;
- if (col.g > 0.001)
+ }
+ if (col.g > 0.001) {
g = true;
- if (col.b > 0.001)
+ }
+ if (col.b > 0.001) {
b = true;
- if (col.a < 0.999)
+ }
+ if (col.a < 0.999) {
a = true;
+ }
if (col.r != col.b || col.r != col.g || col.b != col.g) {
c = true;
@@ -3096,18 +2937,19 @@ Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
UsedChannels used_channels;
- if (!c && !a)
+ if (!c && !a) {
used_channels = USED_CHANNELS_L;
- else if (!c && a)
+ } else if (!c && a) {
used_channels = USED_CHANNELS_LA;
- else if (r && !g && !b && !a)
+ } else if (r && !g && !b && !a) {
used_channels = USED_CHANNELS_R;
- else if (r && g && !b && !a)
+ } else if (r && g && !b && !a) {
used_channels = USED_CHANNELS_RG;
- else if (r && g && b && !a)
+ } else if (r && g && b && !a) {
used_channels = USED_CHANNELS_RGB;
- else
+ } else {
used_channels = USED_CHANNELS_RGBA;
+ }
if (p_source == COMPRESS_SOURCE_SRGB && (used_channels == USED_CHANNELS_R || used_channels == USED_CHANNELS_RG)) {
//R and RG do not support SRGB
@@ -3146,7 +2988,6 @@ void Image::optimize_channels() {
}
void Image::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_width"), &Image::get_width);
ClassDB::bind_method(D_METHOD("get_height"), &Image::get_height);
ClassDB::bind_method(D_METHOD("get_size"), &Image::get_size);
@@ -3161,7 +3002,6 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("resize_to_po2", "square"), &Image::resize_to_po2, DEFVAL(false));
ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2);
- ClassDB::bind_method(D_METHOD("expand_x2_hq2x"), &Image::expand_x2_hq2x);
ClassDB::bind_method(D_METHOD("crop", "width", "height"), &Image::crop);
ClassDB::bind_method(D_METHOD("flip_x"), &Image::flip_x);
@@ -3176,6 +3016,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("load", "path"), &Image::load);
ClassDB::bind_method(D_METHOD("save_png", "path"), &Image::save_png);
+ ClassDB::bind_method(D_METHOD("save_png_to_buffer"), &Image::save_png_to_buffer);
ClassDB::bind_method(D_METHOD("save_exr", "path", "grayscale"), &Image::save_exr, DEFVAL(false));
ClassDB::bind_method(D_METHOD("detect_alpha"), &Image::detect_alpha);
@@ -3292,17 +3133,14 @@ void Image::_bind_methods() {
}
void Image::set_compress_bc_func(void (*p_compress_func)(Image *, float, UsedChannels)) {
-
_image_compress_bc_func = p_compress_func;
}
void Image::set_compress_bptc_func(void (*p_compress_func)(Image *, float, UsedChannels)) {
-
_image_compress_bptc_func = p_compress_func;
}
void Image::normalmap_to_xy() {
-
convert(Image::FORMAT_RGBA8);
{
@@ -3310,7 +3148,6 @@ void Image::normalmap_to_xy() {
uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < len; i++) {
-
data_ptr[(i << 2) + 3] = data_ptr[(i << 2) + 0]; //x to w
data_ptr[(i << 2) + 0] = data_ptr[(i << 2) + 1]; //y to xz
data_ptr[(i << 2) + 2] = data_ptr[(i << 2) + 1];
@@ -3321,15 +3158,15 @@ void Image::normalmap_to_xy() {
}
Ref<Image> Image::rgbe_to_srgb() {
-
- if (data.size() == 0)
+ if (data.size() == 0) {
return Ref<Image>();
+ }
ERR_FAIL_COND_V(format != FORMAT_RGBE9995, Ref<Image>());
Ref<Image> new_image;
new_image.instance();
- new_image->create(width, height, 0, Image::FORMAT_RGB8);
+ new_image->create(width, height, false, Image::FORMAT_RGB8);
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
@@ -3345,7 +3182,6 @@ Ref<Image> Image::rgbe_to_srgb() {
}
Ref<Image> Image::get_image_from_mipmap(int p_mipamp) const {
-
int ofs, size, w, h;
get_mipmap_offset_size_and_dimensions(p_mipamp, ofs, size, w, h);
@@ -3387,13 +3223,15 @@ void Image::bumpmap_to_normalmap(float bump_scale) {
for (int ty = 0; ty < height; ty++) {
int py = ty + 1;
- if (py >= height)
+ if (py >= height) {
py -= height;
+ }
for (int tx = 0; tx < width; tx++) {
int px = tx + 1;
- if (px >= width)
+ if (px >= width) {
px -= width;
+ }
float here = read_ptr[ty * width + tx];
float to_right = read_ptr[ty * width + px];
float above = read_ptr[py * width + tx];
@@ -3415,33 +3253,29 @@ void Image::bumpmap_to_normalmap(float bump_scale) {
}
void Image::srgb_to_linear() {
-
- if (data.size() == 0)
+ if (data.size() == 0) {
return;
+ }
static const uint8_t srgb2lin[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159, 160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188, 190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220, 222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255 };
ERR_FAIL_COND(format != FORMAT_RGB8 && format != FORMAT_RGBA8);
if (format == FORMAT_RGBA8) {
-
int len = data.size() / 4;
uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < len; i++) {
-
data_ptr[(i << 2) + 0] = srgb2lin[data_ptr[(i << 2) + 0]];
data_ptr[(i << 2) + 1] = srgb2lin[data_ptr[(i << 2) + 1]];
data_ptr[(i << 2) + 2] = srgb2lin[data_ptr[(i << 2) + 2]];
}
} else if (format == FORMAT_RGB8) {
-
int len = data.size() / 3;
uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < len; i++) {
-
data_ptr[(i * 3) + 0] = srgb2lin[data_ptr[(i * 3) + 0]];
data_ptr[(i * 3) + 1] = srgb2lin[data_ptr[(i * 3) + 1]];
data_ptr[(i * 3) + 2] = srgb2lin[data_ptr[(i * 3) + 2]];
@@ -3450,18 +3284,18 @@ void Image::srgb_to_linear() {
}
void Image::premultiply_alpha() {
-
- if (data.size() == 0)
+ if (data.size() == 0) {
return;
+ }
- if (format != FORMAT_RGBA8)
+ if (format != FORMAT_RGBA8) {
return; //not needed
+ }
uint8_t *data_ptr = data.ptrw();
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
-
uint8_t *ptr = &data_ptr[(i * width + j) * 4];
ptr[0] = (uint16_t(ptr[0]) * uint16_t(ptr[3])) >> 8;
@@ -3472,12 +3306,13 @@ void Image::premultiply_alpha() {
}
void Image::fix_alpha_edges() {
-
- if (data.size() == 0)
+ if (data.size() == 0) {
return;
+ }
- if (format != FORMAT_RGBA8)
+ if (format != FORMAT_RGBA8) {
return; //not needed
+ }
Vector<uint8_t> dcopy = data;
const uint8_t *srcptr = dcopy.ptr();
@@ -3490,12 +3325,12 @@ void Image::fix_alpha_edges() {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
-
const uint8_t *rptr = &srcptr[(i * width + j) * 4];
uint8_t *wptr = &data_ptr[(i * width + j) * 4];
- if (rptr[3] >= alpha_threshold)
+ if (rptr[3] >= alpha_threshold) {
continue;
+ }
int closest_dist = max_dist;
uint8_t closest_color[3];
@@ -3507,17 +3342,18 @@ void Image::fix_alpha_edges() {
for (int k = from_y; k <= to_y; k++) {
for (int l = from_x; l <= to_x; l++) {
-
int dy = i - k;
int dx = j - l;
int dist = dy * dy + dx * dx;
- if (dist >= closest_dist)
+ if (dist >= closest_dist) {
continue;
+ }
const uint8_t *rp2 = &srcptr[(k * width + l) << 2];
- if (rp2[3] < alpha_threshold)
+ if (rp2[3] < alpha_threshold) {
continue;
+ }
closest_dist = dist;
closest_color[0] = rp2[0];
@@ -3527,7 +3363,6 @@ void Image::fix_alpha_edges() {
}
if (closest_dist != max_dist) {
-
wptr[0] = closest_color[0];
wptr[1] = closest_color[1];
wptr[2] = closest_color[2];
@@ -3537,7 +3372,6 @@ void Image::fix_alpha_edges() {
}
String Image::get_format_name(Format p_format) {
-
ERR_FAIL_INDEX_V(p_format, FORMAT_MAX, String());
return format_names[p_format];
}
@@ -3566,6 +3400,7 @@ void Image::convert_rg_to_ra_rgba8() {
w[i + 2] = 0;
}
}
+
void Image::convert_ra_rgba8_to_rg() {
ERR_FAIL_COND(format != FORMAT_RGBA8);
ERR_FAIL_COND(!data.size());
@@ -3645,7 +3480,6 @@ void Image::renormalize_rgbe9995(uint32_t *p_rgb) {
}
Image::Image(const uint8_t *p_mem_png_jpg, int p_len) {
-
width = 0;
height = 0;
mipmaps = false;
@@ -3661,7 +3495,6 @@ Image::Image(const uint8_t *p_mem_png_jpg, int p_len) {
}
Ref<Resource> Image::duplicate(bool p_subresources) const {
-
Ref<Image> copy;
copy.instance();
copy->_copy_internals_from(*this);
@@ -3671,14 +3504,3 @@ Ref<Resource> Image::duplicate(bool p_subresources) const {
void Image::set_as_black() {
zeromem(data.ptrw(), data.size());
}
-
-Image::Image() {
-
- width = 0;
- height = 0;
- mipmaps = false;
- format = FORMAT_L8;
-}
-
-Image::~Image() {
-}
diff --git a/core/image.h b/core/image.h
index 07b4f49751..53c203998e 100644
--- a/core/image.h
+++ b/core/image.h
@@ -33,7 +33,6 @@
#include "core/color.h"
#include "core/math/rect2.h"
-
#include "core/resource.h"
/**
@@ -172,10 +171,11 @@ private:
create(p_width, p_height, p_use_mipmaps, p_format, p_data);
}
- Format format;
+ Format format = FORMAT_L8;
Vector<uint8_t> data;
- int width, height;
- bool mipmaps;
+ int width = 0;
+ int height = 0;
+ bool mipmaps = false;
void _copy_internals_from(const Image &p_image) {
format = p_image.format;
@@ -235,7 +235,6 @@ public:
void resize_to_po2(bool p_square = false);
void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
void shrink_x2();
- void expand_x2_hq2x();
bool is_size_po2() const;
/**
* Crop the image to a specific size, if larger, then the image is filled by black
@@ -286,7 +285,7 @@ public:
/**
* create an empty image
*/
- Image();
+ Image() {}
/**
* create an empty image of a specific size and format
*/
@@ -296,6 +295,8 @@ public:
*/
Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const Vector<uint8_t> &p_data);
+ ~Image() {}
+
enum AlphaMode {
ALPHA_NONE,
ALPHA_BIT,
@@ -386,8 +387,6 @@ public:
mipmaps = p_image->mipmaps;
data = p_image->data;
}
-
- ~Image();
};
VARIANT_ENUM_CAST(Image::Format)
diff --git a/core/input/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt
index 90d309c1c8..7b5abdd61b 100644
--- a/core/input/gamecontrollerdb.txt
+++ b/core/input/gamecontrollerdb.txt
@@ -4,37 +4,38 @@
# Windows
03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,
03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,
03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,
03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,
-03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00015900000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00065280000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d000021ab000000000000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000351000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00006228000000000000,8BitDo SN30 GP,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
-03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00006228000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,
+03000000c82d00003032000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,
030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,
03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
@@ -73,6 +74,7 @@
03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows,
03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
+030000007d0400000840000000000000,Destroyer Tiltpad,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b1,b:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,x:b0,y:b3,platform:Windows,
03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,
030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
@@ -88,7 +90,6 @@
030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,
030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,
-03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows,
03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,
@@ -98,6 +99,7 @@
03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
030000006f0e00000102000000007801,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
+030000009b2800003200000000000000,GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,
030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
@@ -146,6 +148,8 @@
030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,
030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,
03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows,
+03000000242f00002d00000000000000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
+03000000242f00008a00000000000000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,
03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,
030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
@@ -302,6 +306,7 @@
03000000790000001a18000000000000,Venom,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
030000006f0e00000302000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
+0300000034120000adbe000000000000,vJoy Device,a:b0,b:b1,back:b15,dpdown:b6,dpleft:b7,dpright:b8,dpup:b5,guide:b16,leftshoulder:b9,leftstick:b13,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b14,righttrigger:b12,rightx:+a3,righty:+a4,start:b4,x:b2,y:b3,platform:Windows,
030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
@@ -310,7 +315,7 @@
03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
-03000000c82d00003032000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,
+030000009b2800006000000000000000,GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,
# Mac OS X
030000008f0e00000300000009010000,2In1 USB Joystick,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,
@@ -330,7 +335,6 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,
03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,
-03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,
03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
@@ -351,6 +355,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,
030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Mac OS X,
030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Mac OS X,
+03000000242f00002d00000007010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,
030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
@@ -406,6 +411,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X,
030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,
+03000000d11800000094000000010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,
030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X,
03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,
@@ -455,12 +461,13 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000c82d00000160000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,
03000000c82d00001290000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,
-05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
+05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
05000000c82d00006228000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
03000000c82d00000260000011010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
05000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
030000005e0400008e02000020010000,8BitDo Wireless Adapter,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
03000000c82d00000031000011010000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
+05000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,
05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,
030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
@@ -499,6 +506,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux,
03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
+03000000632500002605000010010000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux,
030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
030000000d0f0000c100000011010000,HORI CO. LTD. HORIPAD S,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
@@ -529,6 +537,8 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,
030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,
050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,
+03000000242f00002d00000011010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
+03000000242f00008a00000011010000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,
030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
@@ -581,6 +591,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Linux,
+060000007e0500000820000000000000,Nintendo Combined Joy-Cons (joycond),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,
+050000007e0500000920000001800000,Nintendo Switch Pro Controller (joycond),a:b0,b:b1,x:b3,y:b2,back:b9,guide:b11,start:b10,leftstick:b12,rightstick:b13,leftshoulder:b5,rightshoulder:b6,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b7,righttrigger:b8,platform:Linux,
+030000007e0500000920000011810000,Nintendo Switch Pro Controller Wired (joycond),a:b0,b:b1,x:b3,y:b2,back:b9,guide:b11,start:b10,leftstick:b12,rightstick:b13,leftshoulder:b5,rightshoulder:b6,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b7,righttrigger:b8,platform:Linux,
030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux,
050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,
@@ -593,9 +606,11 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,
05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,
+03000000830500005020000010010000,Padix Co. Ltd. Rockfire PSX/USB Bridge,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b2,y:b3,platform:Linux,
03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
030000006f0e00003101000000010000,PDP EA Sports Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
+030000006f0e0000c802000012010000,PDP Kingdom Hearts Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
@@ -629,6 +644,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,
+030000009b2800003200000001010000,Raphnet Technologies GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,
030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux,
030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
@@ -650,9 +666,10 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
+03000000a30600001005000000010000,Saitek Saitek P150,platform:Linux,a:b0,b:b1,y:b4,x:b3,leftshoulder:b7,rightshoulder:b2,dpup:-a1,dpleft:-a0,dpdown:+a1,dpright:+a0,lefttrigger:b6,righttrigger:b5,
03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,
03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux,
-03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a1,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
+03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,
03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux,
03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
@@ -667,6 +684,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
+03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
@@ -679,16 +697,21 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
05000000110100001914000009010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
+030000003b07000004a1000000010000,Suncom SFX Plus for USB,a:b0,b:b2,x:b1,y:b3,back:b7,start:b8,leftshoulder:b6,rightshoulder:b9,leftx:a0,lefty:a1,lefttrigger:b4,righttrigger:b5,platform:Linux,
03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,
+03000000457500002211000010010000,SZMY-POWER CO. LTD. GAMEPAD,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
+030000008f0e00000d31000010010000,SZMY-POWER CO. LTD. GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
+03000000b50700000399000000010000,Thrustmaster Firestorm Digital 2,a:b2,b:b4,x:b3,y:b5,back:b11,start:b1,leftstick:b10,rightstick:b0,leftshoulder:b6,rightshoulder:b8,leftx:a0,lefty:a1,lefttrigger:b7,righttrigger:b9,platform:Linux,
030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux,
030000004f04000026b3000002040000,Thrustmaster Gamepad GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
03000000c6240000025b000002020000,Thrustmaster GPX Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
+030000004f04000007d0000000010000,Thrustmaster T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
030000004f04000012b3000010010000,Thrustmaster vibrating gamepad,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,
03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux,
@@ -721,8 +744,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,
03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,
xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
-05000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,
03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
+030000005e0400008e02000000010000,xbox360 Wireless EasySMX,a:b0,b:b1,x:b2,y:b3,back:b6,guide:b8,start:b7,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,
+030000009b2800006000000001010000,Raphnet Technologies GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,
# Android
05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
@@ -748,6 +772,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,
050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android,
34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android,
+7573622067616d657061642020202020,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Android,
# iOS
05000000ac0500000100000000006d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 91ff676211..4d152c1ac4 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -129,7 +129,6 @@ Input::CursorShape (*Input::get_current_cursor_shape_func)() = nullptr;
void (*Input::set_custom_mouse_cursor_func)(const RES &, Input::CursorShape, const Vector2 &) = nullptr;
Input *Input::get_singleton() {
-
return singleton;
}
@@ -139,12 +138,10 @@ void Input::set_mouse_mode(MouseMode p_mode) {
}
Input::MouseMode Input::get_mouse_mode() const {
-
return get_mouse_mode_func();
}
void Input::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed);
ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed);
ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed);
@@ -219,15 +216,15 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
String pf = p_function;
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
-
List<PropertyInfo> pinfo;
ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
- if (!pi.name.begins_with("input/"))
+ if (!pi.name.begins_with("input/")) {
continue;
+ }
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
r_options->push_back(quote_style + name + quote_style);
@@ -237,7 +234,6 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
}
void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
-
uint64_t tick = OS::get_singleton()->get_ticks_usec();
uint32_t tdiff = tick - last_tick;
float delta_t = tdiff / 1000000.0;
@@ -246,11 +242,11 @@ void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
accum += p_delta_p;
accum_t += delta_t;
- if (accum_t > max_ref_frame * 10)
+ if (accum_t > max_ref_frame * 10) {
accum_t = max_ref_frame * 10;
+ }
while (accum_t >= min_ref_frame) {
-
float slice_t = min_ref_frame / accum_t;
Vector2 slice = accum * slice_t;
accum = accum - slice;
@@ -267,45 +263,39 @@ void Input::SpeedTrack::reset() {
}
Input::SpeedTrack::SpeedTrack() {
-
min_ref_frame = 0.1;
max_ref_frame = 0.3;
reset();
}
bool Input::is_key_pressed(int p_keycode) const {
-
_THREAD_SAFE_METHOD_
return keys_pressed.has(p_keycode);
}
bool Input::is_mouse_button_pressed(int p_button) const {
-
_THREAD_SAFE_METHOD_
return (mouse_button_mask & (1 << (p_button - 1))) != 0;
}
static int _combine_device(int p_value, int p_device) {
-
return p_value | (p_device << 20);
}
bool Input::is_joy_button_pressed(int p_device, int p_button) const {
-
_THREAD_SAFE_METHOD_
return joy_buttons_pressed.has(_combine_device(p_button, p_device));
}
bool Input::is_action_pressed(const StringName &p_action) const {
-
return action_state.has(p_action) && action_state[p_action].pressed;
}
bool Input::is_action_just_pressed(const StringName &p_action) const {
-
const Map<StringName, Action>::Element *E = action_state.find(p_action);
- if (!E)
+ if (!E) {
return false;
+ }
if (Engine::get_singleton()->is_in_physics_frame()) {
return E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames();
@@ -315,10 +305,10 @@ bool Input::is_action_just_pressed(const StringName &p_action) const {
}
bool Input::is_action_just_released(const StringName &p_action) const {
-
const Map<StringName, Action>::Element *E = action_state.find(p_action);
- if (!E)
+ if (!E) {
return false;
+ }
if (Engine::get_singleton()->is_in_physics_frame()) {
return !E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames();
@@ -329,14 +319,14 @@ bool Input::is_action_just_released(const StringName &p_action) const {
float Input::get_action_strength(const StringName &p_action) const {
const Map<StringName, Action>::Element *E = action_state.find(p_action);
- if (!E)
+ if (!E) {
return 0.0f;
+ }
return E->get().strength;
}
float Input::get_joy_axis(int p_device, int p_axis) const {
-
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
if (_joy_axis.has(c)) {
@@ -347,10 +337,9 @@ float Input::get_joy_axis(int p_device, int p_axis) const {
}
String Input::get_joy_name(int p_idx) {
-
_THREAD_SAFE_METHOD_
return joy_names[p_idx].name;
-};
+}
Vector2 Input::get_joy_vibration_strength(int p_device) {
if (joy_vibration.has(p_device)) {
@@ -377,7 +366,6 @@ float Input::get_joy_vibration_duration(int p_device) {
}
static String _hex_str(uint8_t p_byte) {
-
static const char *dict = "0123456789abcdef";
char ret[3];
ret[2] = 0;
@@ -386,24 +374,22 @@ static String _hex_str(uint8_t p_byte) {
ret[1] = dict[p_byte & 0xf];
return ret;
-};
+}
void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
-
_THREAD_SAFE_METHOD_
Joypad js;
js.name = p_connected ? p_name : "";
js.uid = p_connected ? p_guid : "";
if (p_connected) {
-
String uidname = p_guid;
if (p_guid == "") {
int uidlen = MIN(p_name.length(), 16);
for (int i = 0; i < uidlen; i++) {
uidname = uidname + _hex_str(p_name[i]);
- };
- };
+ }
+ }
js.uid = uidname;
js.connected = true;
int mapping = fallback_mapping;
@@ -411,8 +397,8 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S
if (js.uid == map_db[i].uid) {
mapping = i;
js.name = map_db[i].name;
- };
- };
+ }
+ }
js.mapping = mapping;
} else {
js.connected = false;
@@ -423,43 +409,37 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, String p_name, S
for (int i = 0; i < JOY_AXIS_MAX; i++) {
set_joy_axis(p_idx, i, 0.0f);
}
- };
+ }
joy_names[p_idx] = js;
emit_signal("joy_connection_changed", p_idx, p_connected);
-};
+}
Vector3 Input::get_gravity() const {
-
_THREAD_SAFE_METHOD_
return gravity;
}
Vector3 Input::get_accelerometer() const {
-
_THREAD_SAFE_METHOD_
return accelerometer;
}
Vector3 Input::get_magnetometer() const {
-
_THREAD_SAFE_METHOD_
return magnetometer;
}
Vector3 Input::get_gyroscope() const {
-
_THREAD_SAFE_METHOD_
return gyroscope;
}
void Input::parse_input_event(const Ref<InputEvent> &p_event) {
-
_parse_input_event_impl(p_event, false);
}
void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated) {
-
// Notes on mouse-touch emulation:
// - Emulated mouse events are parsed, that is, re-routed to this method, so they make the same effects
// as true mouse events. The only difference is the situation is flagged as emulated so they are not
@@ -471,16 +451,16 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventKey> k = p_event;
if (k.is_valid() && !k->is_echo() && k->get_keycode() != 0) {
- if (k->is_pressed())
+ if (k->is_pressed()) {
keys_pressed.insert(k->get_keycode());
- else
+ } else {
keys_pressed.erase(k->get_keycode());
+ }
}
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->is_pressed()) {
mouse_button_mask |= (1 << (mb->get_button_index() - 1));
} else {
@@ -504,7 +484,6 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
Point2 pos = mm->get_global_position();
if (mouse_pos != pos) {
set_mouse_position(pos);
@@ -525,7 +504,6 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventScreenTouch> st = p_event;
if (st.is_valid()) {
-
if (st->is_pressed()) {
SpeedTrack &track = touch_speed_track[st->get_index()];
track.reset();
@@ -536,7 +514,6 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
}
if (emulate_mouse_from_touch) {
-
bool translate = false;
if (st->is_pressed()) {
if (mouse_from_touch_index == -1) {
@@ -573,13 +550,11 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventScreenDrag> sd = p_event;
if (sd.is_valid()) {
-
SpeedTrack &track = touch_speed_track[sd->get_index()];
track.update(sd->get_relative());
sd->set_speed(track.speed);
if (emulate_mouse_from_touch && sd->get_index() == mouse_from_touch_index) {
-
Ref<InputEventMouseMotion> motion_event;
motion_event.instance();
@@ -597,13 +572,13 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventJoypadButton> jb = p_event;
if (jb.is_valid()) {
-
int c = _combine_device(jb->get_button_index(), jb->get_device());
- if (jb->is_pressed())
+ if (jb->is_pressed()) {
joy_buttons_pressed.insert(c);
- else
+ } else {
joy_buttons_pressed.erase(c);
+ }
}
Ref<InputEventJoypadMotion> jm = p_event;
@@ -615,7 +590,6 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
Ref<InputEventGesture> ge = p_event;
if (ge.is_valid()) {
-
if (event_dispatch_function) {
event_dispatch_function(ge);
}
@@ -623,7 +597,6 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
for (const Map<StringName, InputMap::Action>::Element *E = InputMap::get_singleton()->get_action_map().front(); E; E = E->next()) {
if (InputMap::get_singleton()->event_is_action(p_event, E->key())) {
-
// Save the action's state
if (!p_event->is_echo() && is_action_pressed(E->key()) != p_event->is_action_pressed(E->key())) {
Action action;
@@ -637,12 +610,12 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
}
}
- if (event_dispatch_function)
+ if (event_dispatch_function) {
event_dispatch_function(p_event);
+ }
}
void Input::set_joy_axis(int p_device, int p_axis, float p_value) {
-
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
_joy_axis[c] = p_value;
@@ -676,50 +649,43 @@ void Input::vibrate_handheld(int p_duration_ms) {
}
void Input::set_gravity(const Vector3 &p_gravity) {
-
_THREAD_SAFE_METHOD_
gravity = p_gravity;
}
void Input::set_accelerometer(const Vector3 &p_accel) {
-
_THREAD_SAFE_METHOD_
accelerometer = p_accel;
}
void Input::set_magnetometer(const Vector3 &p_magnetometer) {
-
_THREAD_SAFE_METHOD_
magnetometer = p_magnetometer;
}
void Input::set_gyroscope(const Vector3 &p_gyroscope) {
-
_THREAD_SAFE_METHOD_
gyroscope = p_gyroscope;
}
void Input::set_mouse_position(const Point2 &p_posf) {
-
mouse_speed_track.update(p_posf - mouse_pos);
mouse_pos = p_posf;
}
Point2 Input::get_mouse_position() const {
-
return mouse_pos;
}
-Point2 Input::get_last_mouse_speed() const {
+Point2 Input::get_last_mouse_speed() const {
return mouse_speed_track.speed;
}
int Input::get_mouse_button_mask() const {
-
return mouse_button_mask; // do not trust OS implementation, should remove it - OS::get_singleton()->get_mouse_button_state();
}
@@ -728,7 +694,6 @@ void Input::warp_mouse_position(const Vector2 &p_to) {
}
Point2i Input::warp_mouse_motion(const Ref<InputEventMouseMotion> &p_motion, const Rect2 &p_rect) {
-
// The relative distance reported for the next event after a warp is in the boundaries of the
// size of the rect on that axis, but it may be greater, in which case there's not problem as fmod()
// will warp it, but if the pointer has moved in the opposite direction between the pointer relocation
@@ -757,7 +722,6 @@ void Input::iteration(float p_step) {
}
void Input::action_press(const StringName &p_action, float p_strength) {
-
Action action;
action.physics_frame = Engine::get_singleton()->get_physics_frames();
@@ -769,7 +733,6 @@ void Input::action_press(const StringName &p_action, float p_strength) {
}
void Input::action_release(const StringName &p_action) {
-
Action action;
action.physics_frame = Engine::get_singleton()->get_physics_frames();
@@ -781,19 +744,16 @@ void Input::action_release(const StringName &p_action) {
}
void Input::set_emulate_touch_from_mouse(bool p_emulate) {
-
emulate_touch_from_mouse = p_emulate;
}
bool Input::is_emulating_touch_from_mouse() const {
-
return emulate_touch_from_mouse;
}
// Calling this whenever the game window is focused helps unstucking the "touch mouse"
// if the OS or its abstraction class hasn't properly reported that touch pointers raised
void Input::ensure_touch_mouse_raised() {
-
if (mouse_from_touch_index != -1) {
mouse_from_touch_index = -1;
@@ -812,24 +772,21 @@ void Input::ensure_touch_mouse_raised() {
}
void Input::set_emulate_mouse_from_touch(bool p_emulate) {
-
emulate_mouse_from_touch = p_emulate;
}
bool Input::is_emulating_mouse_from_touch() const {
-
return emulate_mouse_from_touch;
}
Input::CursorShape Input::get_default_cursor_shape() const {
-
return default_shape;
}
void Input::set_default_cursor_shape(CursorShape p_shape) {
-
- if (default_shape == p_shape)
+ if (default_shape == p_shape) {
return;
+ }
default_shape = p_shape;
// The default shape is set in Viewport::_gui_input_event. To instantly
@@ -842,13 +799,13 @@ void Input::set_default_cursor_shape(CursorShape p_shape) {
}
Input::CursorShape Input::get_current_cursor_shape() const {
-
return get_current_cursor_shape_func();
}
void Input::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
set_custom_mouse_cursor_func(p_cursor, p_shape, p_hotspot);
}
@@ -866,8 +823,8 @@ void Input::accumulate_input_event(const Ref<InputEvent> &p_event) {
accumulated_events.push_back(p_event);
}
-void Input::flush_accumulated_events() {
+void Input::flush_accumulated_events() {
while (accumulated_events.front()) {
parse_input_event(accumulated_events.front()->get());
accumulated_events.pop_front();
@@ -875,12 +832,10 @@ void Input::flush_accumulated_events() {
}
void Input::set_use_accumulated_input(bool p_enable) {
-
use_accumulated_input = p_enable;
}
void Input::release_pressed_events() {
-
flush_accumulated_events(); // this is needed to release actions strengths
keys_pressed.clear();
@@ -888,8 +843,9 @@ void Input::release_pressed_events() {
_joy_axis.clear();
for (Map<StringName, Input::Action>::Element *E = action_state.front(); E; E = E->next()) {
- if (E->get().pressed)
+ if (E->get().pressed) {
action_release(E->key());
+ }
}
}
@@ -898,7 +854,6 @@ void Input::set_event_dispatch_function(EventDispatchFunc p_function) {
}
void Input::joy_button(int p_device, int p_button, bool p_pressed) {
-
_THREAD_SAFE_METHOD_;
Joypad &joy = joy_names[p_device];
//printf("got button %i, mapping is %i\n", p_button, joy.mapping);
@@ -925,7 +880,6 @@ void Input::joy_button(int p_device, int p_button, bool p_pressed) {
}
void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
-
_THREAD_SAFE_METHOD_;
ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
@@ -937,13 +891,10 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
}
if (p_value.value > joy.last_axis[p_axis]) {
-
if (p_value.value < joy.last_axis[p_axis] + joy.filter) {
-
return;
}
} else if (p_value.value > joy.last_axis[p_axis] - joy.filter) {
-
return;
}
@@ -967,12 +918,11 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
if (joy.mapping == -1) {
_axis_event(p_device, p_axis, val);
return;
- };
+ }
JoyEvent map = _get_mapped_axis_event(map_db[joy.mapping], p_axis, p_value);
if (map.type == TYPE_BUTTON) {
-
if (map.index == JOY_BUTTON_DPAD_UP || map.index == JOY_BUTTON_DPAD_DOWN) {
bool pressed = p_value.value != 0.0f;
int button = p_value.value < 0 ? JOY_BUTTON_DPAD_UP : JOY_BUTTON_DPAD_DOWN;
@@ -1023,7 +973,6 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
}
if (map.type == TYPE_AXIS) {
-
_axis_event(p_device, map.index, map.value);
return;
}
@@ -1031,7 +980,6 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
}
void Input::joy_hat(int p_device, int p_val) {
-
_THREAD_SAFE_METHOD_;
const Joypad &joy = joy_names[p_device];
@@ -1055,7 +1003,7 @@ void Input::joy_hat(int p_device, int p_val) {
if (joy.mapping != -1) {
_get_mapped_hat_events(map_db[joy.mapping], 0, map);
- };
+ }
int cur_val = joy_names[p_device].hat_current;
@@ -1077,7 +1025,6 @@ void Input::joy_hat(int p_device, int p_val) {
}
void Input::_button_event(int p_device, int p_index, bool p_pressed) {
-
Ref<InputEventJoypadButton> ievent;
ievent.instance();
ievent->set_device(p_device);
@@ -1088,7 +1035,6 @@ void Input::_button_event(int p_device, int p_index, bool p_pressed) {
}
void Input::_axis_event(int p_device, int p_axis, float p_value) {
-
Ref<InputEventJoypadMotion> ievent;
ievent.instance();
ievent->set_device(p_device);
@@ -1096,10 +1042,9 @@ void Input::_axis_event(int p_device, int p_axis, float p_value) {
ievent->set_axis_value(p_value);
parse_input_event(ievent);
-};
+}
Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button) {
-
JoyEvent event;
event.type = TYPE_MAX;
@@ -1123,7 +1068,6 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping,
}
Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, const JoyAxis &p_value) {
-
JoyEvent event;
event.type = TYPE_MAX;
@@ -1131,8 +1075,9 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, i
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_AXIS && binding.input.axis.axis == p_axis) {
float value = p_value.value;
- if (binding.input.axis.invert)
+ if (binding.input.axis.invert) {
value = -value;
+ }
if (binding.input.axis.range == FULL_AXIS ||
(binding.input.axis.range == POSITIVE_HALF_AXIS && value > 0) ||
(binding.input.axis.range == NEGATIVE_HALF_AXIS && value < 0)) {
@@ -1180,11 +1125,9 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, i
}
void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[]) {
-
for (int i = 0; i < mapping.bindings.size(); i++) {
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
-
int index;
switch (binding.input.hat.hat_mask) {
case HAT_MASK_UP:
@@ -1220,25 +1163,24 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, J
}
JoyButtonList Input::_get_output_button(String output) {
-
for (int i = 0; _joy_buttons[i]; i++) {
- if (output == _joy_buttons[i])
+ if (output == _joy_buttons[i]) {
return JoyButtonList(i);
+ }
}
return JoyButtonList::JOY_INVALID_BUTTON;
}
JoyAxisList Input::_get_output_axis(String output) {
-
for (int i = 0; _joy_axes[i]; i++) {
- if (output == _joy_axes[i])
+ if (output == _joy_axes[i]) {
return JoyAxisList(i);
+ }
}
return JoyAxisList::JOY_INVALID_AXIS;
}
void Input::parse_mapping(String p_mapping) {
-
_THREAD_SAFE_METHOD_;
JoyDeviceMapping mapping;
@@ -1255,26 +1197,28 @@ void Input::parse_mapping(String p_mapping) {
int idx = 1;
while (++idx < entry.size()) {
-
- if (entry[idx] == "")
+ if (entry[idx] == "") {
continue;
+ }
String output = entry[idx].get_slice(":", 0).replace(" ", "");
String input = entry[idx].get_slice(":", 1).replace(" ", "");
ERR_CONTINUE_MSG(output.length() < 1 || input.length() < 2,
String(entry[idx] + "\nInvalid device mapping entry: " + entry[idx]));
- if (output == "platform")
+ if (output == "platform") {
continue;
+ }
JoyAxisRange output_range = FULL_AXIS;
if (output[0] == '+' || output[0] == '-') {
ERR_CONTINUE_MSG(output.length() < 2, String(entry[idx] + "\nInvalid output: " + entry[idx]));
output = output.right(1);
- if (output[0] == '+')
+ if (output[0] == '+') {
output_range = POSITIVE_HALF_AXIS;
- else if (output[0] == '-')
+ } else if (output[0] == '-') {
output_range = NEGATIVE_HALF_AXIS;
+ }
}
JoyAxisRange input_range = FULL_AXIS;
@@ -1286,8 +1230,9 @@ void Input::parse_mapping(String p_mapping) {
input = input.right(1);
}
bool invert_axis = false;
- if (input[input.length() - 1] == '~')
+ if (input[input.length() - 1] == '~') {
invert_axis = true;
+ }
JoyButtonList output_button = _get_output_button(output);
JoyAxisList output_axis = _get_output_axis(output);
@@ -1329,10 +1274,10 @@ void Input::parse_mapping(String p_mapping) {
}
mapping.bindings.push_back(binding);
- };
+ }
map_db.push_back(mapping);
-};
+}
void Input::add_joy_mapping(String p_mapping, bool p_update_existing) {
parse_mapping(p_mapping);
@@ -1361,7 +1306,6 @@ void Input::remove_joy_mapping(String p_guid) {
}
void Input::set_fallback_mapping(String p_guid) {
-
for (int i = 0; i < map_db.size(); i++) {
if (map_db[i].uid == p_guid) {
fallback_mapping = i;
@@ -1431,18 +1375,7 @@ int Input::get_joy_axis_index_from_string(String p_axis) {
}
Input::Input() {
-
singleton = this;
- use_accumulated_input = true;
- mouse_button_mask = 0;
- mouse_window = 0;
- emulate_touch_from_mouse = false;
- emulate_mouse_from_touch = false;
- mouse_from_touch_index = -1;
- event_dispatch_function = nullptr;
- default_shape = CURSOR_ARROW;
-
- fallback_mapping = -1;
// Parse default mappings.
{
@@ -1457,8 +1390,9 @@ Input::Input() {
if (env_mapping != "") {
Vector<String> entries = env_mapping.split("\n");
for (int i = 0; i < entries.size(); i++) {
- if (entries[i] == "")
+ if (entries[i] == "") {
continue;
+ }
parse_mapping(entries[i]);
}
}
diff --git a/core/input/input.h b/core/input/input.h
index 9accf14a4f..91e3b83b95 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -36,7 +36,6 @@
#include "core/os/thread_safe.h"
class Input : public Object {
-
GDCLASS(Input, Object);
_THREAD_SAFE_CLASS_
@@ -100,7 +99,7 @@ public:
typedef void (*EventDispatchFunc)(const Ref<InputEvent> &p_event);
private:
- int mouse_button_mask;
+ int mouse_button_mask = 0;
Set<int> keys_pressed;
Set<int> joy_buttons_pressed;
@@ -111,7 +110,7 @@ private:
Vector3 magnetometer;
Vector3 gyroscope;
Vector2 mouse_pos;
- int64_t mouse_window;
+ int64_t mouse_window = 0;
struct Action {
uint64_t physics_frame;
@@ -122,13 +121,13 @@ private:
Map<StringName, Action> action_state;
- bool emulate_touch_from_mouse;
- bool emulate_mouse_from_touch;
+ bool emulate_touch_from_mouse = false;
+ bool emulate_mouse_from_touch = false;
+ bool use_accumulated_input = false;
- int mouse_from_touch_index;
+ int mouse_from_touch_index = -1;
struct SpeedTrack {
-
uint64_t last_tick;
Vector2 speed;
Vector2 accum;
@@ -144,35 +143,21 @@ private:
struct Joypad {
StringName name;
StringName uid;
- bool connected;
- bool last_buttons[JOY_BUTTON_MAX];
- float last_axis[JOY_AXIS_MAX];
- float filter;
- int last_hat;
- int mapping;
- int hat_current;
-
- Joypad() {
- for (int i = 0; i < JOY_AXIS_MAX; i++) {
- last_axis[i] = 0.0f;
- }
- for (int i = 0; i < JOY_BUTTON_MAX; i++) {
- last_buttons[i] = false;
- }
- connected = false;
- last_hat = HAT_MASK_CENTER;
- filter = 0.01f;
- mapping = -1;
- hat_current = 0;
- }
+ bool connected = false;
+ bool last_buttons[JOY_BUTTON_MAX] = { false };
+ float last_axis[JOY_AXIS_MAX] = { 0.0f };
+ float filter = 0.01f;
+ int last_hat = HAT_MASK_CENTER;
+ int mapping = -1;
+ int hat_current = 0;
};
SpeedTrack mouse_speed_track;
Map<int, SpeedTrack> touch_speed_track;
Map<int, Joypad> joy_names;
- int fallback_mapping;
+ int fallback_mapping = -1;
- CursorShape default_shape;
+ CursorShape default_shape = CURSOR_ARROW;
enum JoyType {
TYPE_BUTTON,
@@ -243,7 +228,7 @@ private:
void _parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_emulated);
List<Ref<InputEvent>> accumulated_events;
- bool use_accumulated_input;
+
friend class DisplayServer;
static void (*set_mouse_mode_func)(MouseMode);
@@ -253,7 +238,7 @@ private:
static CursorShape (*get_current_cursor_shape_func)();
static void (*set_custom_mouse_cursor_func)(const RES &, CursorShape, const Vector2 &);
- EventDispatchFunc event_dispatch_function;
+ EventDispatchFunc event_dispatch_function = nullptr;
protected:
struct VibrationInfo {
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 4b8c104f39..6ba082f86f 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -45,26 +45,22 @@ int InputEvent::get_device() const {
}
bool InputEvent::is_action(const StringName &p_action) const {
-
return InputMap::get_singleton()->event_is_action(Ref<InputEvent>((InputEvent *)this), p_action);
}
bool InputEvent::is_action_pressed(const StringName &p_action, bool p_allow_echo) const {
-
bool pressed;
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
return valid && pressed && (p_allow_echo || !is_echo());
}
bool InputEvent::is_action_released(const StringName &p_action) const {
-
bool pressed;
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
return valid && !pressed;
}
float InputEvent::get_action_strength(const StringName &p_action) const {
-
bool pressed;
float strength;
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed, &strength);
@@ -72,42 +68,34 @@ float InputEvent::get_action_strength(const StringName &p_action) const {
}
bool InputEvent::is_pressed() const {
-
return false;
}
bool InputEvent::is_echo() const {
-
return false;
}
Ref<InputEvent> InputEvent::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
return Ref<InputEvent>((InputEvent *)this);
}
String InputEvent::as_text() const {
-
return String();
}
bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
return false;
}
bool InputEvent::shortcut_match(const Ref<InputEvent> &p_event) const {
-
return false;
}
bool InputEvent::is_action_type() const {
-
return false;
}
void InputEvent::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_device", "device"), &InputEvent::set_device);
ClassDB::bind_method(D_METHOD("get_device"), &InputEvent::get_device);
@@ -132,14 +120,9 @@ void InputEvent::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device");
}
-InputEvent::InputEvent() {
-
- device = 0;
-}
-////////////////
+///////////////////////////////////
void InputEventFromWindow::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_window_id", "id"), &InputEventFromWindow::set_window_id);
ClassDB::bind_method(D_METHOD("get_window_id"), &InputEventFromWindow::get_window_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "window_id"), "set_window_id", "get_window_id");
@@ -148,64 +131,54 @@ void InputEventFromWindow::_bind_methods() {
void InputEventFromWindow::set_window_id(int64_t p_id) {
window_id = p_id;
}
+
int64_t InputEventFromWindow::get_window_id() const {
return window_id;
}
-InputEventFromWindow::InputEventFromWindow() {
- window_id = 0;
-}
-
-//////////////////
+///////////////////////////////////
void InputEventWithModifiers::set_shift(bool p_enabled) {
-
shift = p_enabled;
}
bool InputEventWithModifiers::get_shift() const {
-
return shift;
}
void InputEventWithModifiers::set_alt(bool p_enabled) {
-
alt = p_enabled;
}
-bool InputEventWithModifiers::get_alt() const {
+bool InputEventWithModifiers::get_alt() const {
return alt;
}
void InputEventWithModifiers::set_control(bool p_enabled) {
-
control = p_enabled;
}
-bool InputEventWithModifiers::get_control() const {
+bool InputEventWithModifiers::get_control() const {
return control;
}
void InputEventWithModifiers::set_metakey(bool p_enabled) {
-
meta = p_enabled;
}
-bool InputEventWithModifiers::get_metakey() const {
+bool InputEventWithModifiers::get_metakey() const {
return meta;
}
void InputEventWithModifiers::set_command(bool p_enabled) {
-
command = p_enabled;
}
-bool InputEventWithModifiers::get_command() const {
+bool InputEventWithModifiers::get_command() const {
return command;
}
void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModifiers *event) {
-
set_alt(event->get_alt());
set_shift(event->get_shift());
set_control(event->get_control());
@@ -213,7 +186,6 @@ void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModif
}
void InputEventWithModifiers::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_alt", "enable"), &InputEventWithModifiers::set_alt);
ClassDB::bind_method(D_METHOD("get_alt"), &InputEventWithModifiers::get_alt);
@@ -236,101 +208,89 @@ void InputEventWithModifiers::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command"), "set_command", "get_command");
}
-InputEventWithModifiers::InputEventWithModifiers() {
-
- alt = false;
- shift = false;
- control = false;
- meta = false;
-}
-
-//////////////////////////////////
+///////////////////////////////////
void InputEventKey::set_pressed(bool p_pressed) {
-
pressed = p_pressed;
}
bool InputEventKey::is_pressed() const {
-
return pressed;
}
void InputEventKey::set_keycode(uint32_t p_keycode) {
-
keycode = p_keycode;
}
uint32_t InputEventKey::get_keycode() const {
-
return keycode;
}
void InputEventKey::set_physical_keycode(uint32_t p_keycode) {
-
physical_keycode = p_keycode;
}
uint32_t InputEventKey::get_physical_keycode() const {
-
return physical_keycode;
}
void InputEventKey::set_unicode(uint32_t p_unicode) {
-
unicode = p_unicode;
}
uint32_t InputEventKey::get_unicode() const {
-
return unicode;
}
void InputEventKey::set_echo(bool p_enable) {
-
echo = p_enable;
}
bool InputEventKey::is_echo() const {
-
return echo;
}
uint32_t InputEventKey::get_keycode_with_modifiers() const {
-
uint32_t sc = keycode;
- if (get_control())
+ if (get_control()) {
sc |= KEY_MASK_CTRL;
- if (get_alt())
+ }
+ if (get_alt()) {
sc |= KEY_MASK_ALT;
- if (get_shift())
+ }
+ if (get_shift()) {
sc |= KEY_MASK_SHIFT;
- if (get_metakey())
+ }
+ if (get_metakey()) {
sc |= KEY_MASK_META;
+ }
return sc;
}
uint32_t InputEventKey::get_physical_keycode_with_modifiers() const {
-
uint32_t sc = physical_keycode;
- if (get_control())
+ if (get_control()) {
sc |= KEY_MASK_CTRL;
- if (get_alt())
+ }
+ if (get_alt()) {
sc |= KEY_MASK_ALT;
- if (get_shift())
+ }
+ if (get_shift()) {
sc |= KEY_MASK_SHIFT;
- if (get_metakey())
+ }
+ if (get_metakey()) {
sc |= KEY_MASK_META;
+ }
return sc;
}
String InputEventKey::as_text() const {
-
String kc = keycode_get_string(keycode);
- if (kc == String())
+ if (kc == String()) {
return kc;
+ }
if (get_metakey()) {
kc = find_keycode_name(KEY_META) + ("+" + kc);
@@ -348,10 +308,10 @@ String InputEventKey::as_text() const {
}
bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
Ref<InputEventKey> key = p_event;
- if (key.is_null())
+ if (key.is_null()) {
return false;
+ }
bool match = false;
if (get_keycode() == 0) {
@@ -366,19 +326,21 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed
match = get_keycode() == key->get_keycode() && (!key->is_pressed() || (code & event_code) == code);
}
if (match) {
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = key->is_pressed();
- if (p_strength != nullptr)
+ }
+ if (p_strength != nullptr) {
*p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f;
+ }
}
return match;
}
bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
-
Ref<InputEventKey> key = p_event;
- if (key.is_null())
+ if (key.is_null()) {
return false;
+ }
uint32_t code = get_keycode_with_modifiers();
uint32_t event_code = key->get_keycode_with_modifiers();
@@ -387,7 +349,6 @@ bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
}
void InputEventKey::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventKey::set_pressed);
ClassDB::bind_method(D_METHOD("set_keycode", "keycode"), &InputEventKey::set_keycode);
@@ -411,46 +372,33 @@ void InputEventKey::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo");
}
-InputEventKey::InputEventKey() {
-
- pressed = false;
- keycode = 0;
- physical_keycode = 0;
- unicode = 0; ///unicode
- echo = false;
-}
-
-////////////////////////////////////////
+///////////////////////////////////
void InputEventMouse::set_button_mask(int p_mask) {
-
button_mask = p_mask;
}
-int InputEventMouse::get_button_mask() const {
+int InputEventMouse::get_button_mask() const {
return button_mask;
}
void InputEventMouse::set_position(const Vector2 &p_pos) {
-
pos = p_pos;
}
-Vector2 InputEventMouse::get_position() const {
+Vector2 InputEventMouse::get_position() const {
return pos;
}
void InputEventMouse::set_global_position(const Vector2 &p_global_pos) {
-
global_pos = p_global_pos;
}
-Vector2 InputEventMouse::get_global_position() const {
+Vector2 InputEventMouse::get_global_position() const {
return global_pos;
}
void InputEventMouse::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_button_mask", "button_mask"), &InputEventMouse::set_button_mask);
ClassDB::bind_method(D_METHOD("get_button_mask"), &InputEventMouse::get_button_mask);
@@ -465,52 +413,41 @@ void InputEventMouse::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position"), "set_global_position", "get_global_position");
}
-InputEventMouse::InputEventMouse() {
-
- button_mask = 0;
-}
-
-///////////////////////////////////////
+///////////////////////////////////
void InputEventMouseButton::set_factor(float p_factor) {
-
factor = p_factor;
}
float InputEventMouseButton::get_factor() const {
-
return factor;
}
void InputEventMouseButton::set_button_index(int p_index) {
-
button_index = p_index;
}
-int InputEventMouseButton::get_button_index() const {
+int InputEventMouseButton::get_button_index() const {
return button_index;
}
void InputEventMouseButton::set_pressed(bool p_pressed) {
-
pressed = p_pressed;
}
-bool InputEventMouseButton::is_pressed() const {
+bool InputEventMouseButton::is_pressed() const {
return pressed;
}
void InputEventMouseButton::set_doubleclick(bool p_doubleclick) {
-
doubleclick = p_doubleclick;
}
-bool InputEventMouseButton::is_doubleclick() const {
+bool InputEventMouseButton::is_doubleclick() const {
return doubleclick;
}
Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
Vector2 g = get_global_position();
Vector2 l = p_xform.xform(get_position() + p_local_ofs);
@@ -534,24 +471,25 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
}
bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_null())
+ if (mb.is_null()) {
return false;
+ }
bool match = mb->button_index == button_index;
if (match) {
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = mb->is_pressed();
- if (p_strength != nullptr)
+ }
+ if (p_strength != nullptr) {
*p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f;
+ }
}
return match;
}
String InputEventMouseButton::as_text() const {
-
String button_index_string = "";
switch (get_button_index()) {
case BUTTON_LEFT:
@@ -589,7 +527,6 @@ String InputEventMouseButton::as_text() const {
}
void InputEventMouseButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMouseButton::set_factor);
ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMouseButton::get_factor);
@@ -608,58 +545,41 @@ void InputEventMouseButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick");
}
-InputEventMouseButton::InputEventMouseButton() {
-
- factor = 1;
- button_index = 0;
- pressed = false;
- doubleclick = false;
-}
-
-////////////////////////////////////////////
+///////////////////////////////////
void InputEventMouseMotion::set_tilt(const Vector2 &p_tilt) {
-
tilt = p_tilt;
}
Vector2 InputEventMouseMotion::get_tilt() const {
-
return tilt;
}
void InputEventMouseMotion::set_pressure(float p_pressure) {
-
pressure = p_pressure;
}
float InputEventMouseMotion::get_pressure() const {
-
return pressure;
}
void InputEventMouseMotion::set_relative(const Vector2 &p_relative) {
-
relative = p_relative;
}
Vector2 InputEventMouseMotion::get_relative() const {
-
return relative;
}
void InputEventMouseMotion::set_speed(const Vector2 &p_speed) {
-
speed = p_speed;
}
Vector2 InputEventMouseMotion::get_speed() const {
-
return speed;
}
Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
Vector2 g = get_global_position();
Vector2 l = p_xform.xform(get_position() + p_local_ofs);
Vector2 r = p_xform.basis_xform(get_relative());
@@ -686,7 +606,6 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
}
String InputEventMouseMotion::as_text() const {
-
String button_mask_string = "";
switch (get_button_mask()) {
case BUTTON_MASK_LEFT:
@@ -712,10 +631,10 @@ String InputEventMouseMotion::as_text() const {
}
bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseMotion> motion = p_event;
- if (motion.is_null())
+ if (motion.is_null()) {
return false;
+ }
if (get_window_id() != motion->get_window_id()) {
return false;
@@ -754,7 +673,6 @@ bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
}
void InputEventMouseMotion::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_tilt", "tilt"), &InputEventMouseMotion::set_tilt);
ClassDB::bind_method(D_METHOD("get_tilt"), &InputEventMouseMotion::get_tilt);
@@ -773,50 +691,41 @@ void InputEventMouseMotion::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
}
-InputEventMouseMotion::InputEventMouseMotion() {
-
- pressure = 0;
-}
-
-////////////////////////////////////////
+///////////////////////////////////
void InputEventJoypadMotion::set_axis(int p_axis) {
-
axis = p_axis;
}
int InputEventJoypadMotion::get_axis() const {
-
return axis;
}
void InputEventJoypadMotion::set_axis_value(float p_value) {
-
axis_value = p_value;
}
float InputEventJoypadMotion::get_axis_value() const {
-
return axis_value;
}
bool InputEventJoypadMotion::is_pressed() const {
-
return Math::abs(axis_value) >= 0.5f;
}
bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
Ref<InputEventJoypadMotion> jm = p_event;
- if (jm.is_null())
+ if (jm.is_null()) {
return false;
+ }
bool match = (axis == jm->axis); // Matches even if not in the same direction, but returns a "not pressed" event.
if (match) {
bool same_direction = (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0);
bool pressed = same_direction ? Math::abs(jm->get_axis_value()) >= p_deadzone : false;
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = pressed;
+ }
if (p_strength != nullptr) {
if (pressed) {
if (p_deadzone == 1.0f) {
@@ -833,12 +742,10 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *
}
String InputEventJoypadMotion::as_text() const {
-
return "InputEventJoypadMotion : axis=" + itos(axis) + ", axis_value=" + String(Variant(axis_value));
}
void InputEventJoypadMotion::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis);
ClassDB::bind_method(D_METHOD("get_axis"), &InputEventJoypadMotion::get_axis);
@@ -849,74 +756,65 @@ void InputEventJoypadMotion::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "axis_value"), "set_axis_value", "get_axis_value");
}
-InputEventJoypadMotion::InputEventJoypadMotion() {
-
- axis = 0;
- axis_value = 0;
-}
-/////////////////////////////////
+///////////////////////////////////
void InputEventJoypadButton::set_button_index(int p_index) {
-
button_index = p_index;
}
int InputEventJoypadButton::get_button_index() const {
-
return button_index;
}
void InputEventJoypadButton::set_pressed(bool p_pressed) {
-
pressed = p_pressed;
}
-bool InputEventJoypadButton::is_pressed() const {
+bool InputEventJoypadButton::is_pressed() const {
return pressed;
}
void InputEventJoypadButton::set_pressure(float p_pressure) {
-
pressure = p_pressure;
}
-float InputEventJoypadButton::get_pressure() const {
+float InputEventJoypadButton::get_pressure() const {
return pressure;
}
bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
Ref<InputEventJoypadButton> jb = p_event;
- if (jb.is_null())
+ if (jb.is_null()) {
return false;
+ }
bool match = button_index == jb->button_index;
if (match) {
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = jb->is_pressed();
- if (p_strength != nullptr)
+ }
+ if (p_strength != nullptr) {
*p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f;
+ }
}
return match;
}
bool InputEventJoypadButton::shortcut_match(const Ref<InputEvent> &p_event) const {
-
Ref<InputEventJoypadButton> button = p_event;
- if (button.is_null())
+ if (button.is_null()) {
return false;
+ }
return button_index == button->button_index;
}
String InputEventJoypadButton::as_text() const {
-
return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure));
}
void InputEventJoypadButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index);
ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventJoypadButton::get_button_index);
@@ -931,44 +829,33 @@ void InputEventJoypadButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
}
-InputEventJoypadButton::InputEventJoypadButton() {
-
- button_index = 0;
- pressure = 0;
- pressed = false;
-}
-
-//////////////////////////////////////////////
+///////////////////////////////////
void InputEventScreenTouch::set_index(int p_index) {
-
index = p_index;
}
-int InputEventScreenTouch::get_index() const {
+int InputEventScreenTouch::get_index() const {
return index;
}
void InputEventScreenTouch::set_position(const Vector2 &p_pos) {
-
pos = p_pos;
}
-Vector2 InputEventScreenTouch::get_position() const {
+Vector2 InputEventScreenTouch::get_position() const {
return pos;
}
void InputEventScreenTouch::set_pressed(bool p_pressed) {
-
pressed = p_pressed;
}
-bool InputEventScreenTouch::is_pressed() const {
+bool InputEventScreenTouch::is_pressed() const {
return pressed;
}
Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
Ref<InputEventScreenTouch> st;
st.instance();
st->set_device(get_device());
@@ -981,12 +868,10 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co
}
String InputEventScreenTouch::as_text() const {
-
return "InputEventScreenTouch : index=" + itos(index) + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + ")";
}
void InputEventScreenTouch::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenTouch::set_index);
ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenTouch::get_index);
@@ -1001,53 +886,41 @@ void InputEventScreenTouch::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
}
-InputEventScreenTouch::InputEventScreenTouch() {
-
- index = 0;
- pressed = false;
-}
-
-/////////////////////////////
+///////////////////////////////////
void InputEventScreenDrag::set_index(int p_index) {
-
index = p_index;
}
int InputEventScreenDrag::get_index() const {
-
return index;
}
void InputEventScreenDrag::set_position(const Vector2 &p_pos) {
-
pos = p_pos;
}
-Vector2 InputEventScreenDrag::get_position() const {
+Vector2 InputEventScreenDrag::get_position() const {
return pos;
}
void InputEventScreenDrag::set_relative(const Vector2 &p_relative) {
-
relative = p_relative;
}
-Vector2 InputEventScreenDrag::get_relative() const {
+Vector2 InputEventScreenDrag::get_relative() const {
return relative;
}
void InputEventScreenDrag::set_speed(const Vector2 &p_speed) {
-
speed = p_speed;
}
-Vector2 InputEventScreenDrag::get_speed() const {
+Vector2 InputEventScreenDrag::get_speed() const {
return speed;
}
Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
Ref<InputEventScreenDrag> sd;
sd.instance();
@@ -1064,12 +937,10 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
}
String InputEventScreenDrag::as_text() const {
-
return "InputEventScreenDrag : index=" + itos(index) + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
}
void InputEventScreenDrag::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index);
ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenDrag::get_index);
@@ -1088,27 +959,21 @@ void InputEventScreenDrag::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
}
-InputEventScreenDrag::InputEventScreenDrag() {
-
- index = 0;
-}
-/////////////////////////////
+///////////////////////////////////
void InputEventAction::set_action(const StringName &p_action) {
-
action = p_action;
}
-StringName InputEventAction::get_action() const {
+StringName InputEventAction::get_action() const {
return action;
}
void InputEventAction::set_pressed(bool p_pressed) {
-
pressed = p_pressed;
}
-bool InputEventAction::is_pressed() const {
+bool InputEventAction::is_pressed() const {
return pressed;
}
@@ -1121,40 +986,40 @@ float InputEventAction::get_strength() const {
}
bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
- if (p_event.is_null())
+ if (p_event.is_null()) {
return false;
+ }
return p_event->is_action(action);
}
bool InputEventAction::is_action(const StringName &p_action) const {
-
return action == p_action;
}
bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
-
Ref<InputEventAction> act = p_event;
- if (act.is_null())
+ if (act.is_null()) {
return false;
+ }
bool match = action == act->action;
if (match) {
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = act->pressed;
- if (p_strength != nullptr)
+ }
+ if (p_strength != nullptr) {
*p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f;
+ }
}
return match;
}
String InputEventAction::as_text() const {
-
return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
}
void InputEventAction::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_action", "action"), &InputEventAction::set_action);
ClassDB::bind_method(D_METHOD("get_action"), &InputEventAction::get_action);
@@ -1171,19 +1036,13 @@ void InputEventAction::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength");
}
-InputEventAction::InputEventAction() {
- pressed = false;
- strength = 1.0f;
-}
-/////////////////////////////
+///////////////////////////////////
void InputEventGesture::set_position(const Vector2 &p_pos) {
-
pos = p_pos;
}
void InputEventGesture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventGesture::set_position);
ClassDB::bind_method(D_METHOD("get_position"), &InputEventGesture::get_position);
@@ -1191,23 +1050,20 @@ void InputEventGesture::_bind_methods() {
}
Vector2 InputEventGesture::get_position() const {
-
return pos;
}
-/////////////////////////////
-void InputEventMagnifyGesture::set_factor(real_t p_factor) {
+///////////////////////////////////
+void InputEventMagnifyGesture::set_factor(real_t p_factor) {
factor = p_factor;
}
real_t InputEventMagnifyGesture::get_factor() const {
-
return factor;
}
Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
Ref<InputEventMagnifyGesture> ev;
ev.instance();
@@ -1223,26 +1079,19 @@ Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform,
}
String InputEventMagnifyGesture::as_text() const {
-
return "InputEventMagnifyGesture : factor=" + rtos(get_factor()) + ", position=(" + String(get_position()) + ")";
}
void InputEventMagnifyGesture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor);
ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor");
}
-InputEventMagnifyGesture::InputEventMagnifyGesture() {
-
- factor = 1.0;
-}
-/////////////////////////////
+///////////////////////////////////
void InputEventPanGesture::set_delta(const Vector2 &p_delta) {
-
delta = p_delta;
}
@@ -1251,7 +1100,6 @@ Vector2 InputEventPanGesture::get_delta() const {
}
Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
-
Ref<InputEventPanGesture> ev;
ev.instance();
@@ -1267,26 +1115,19 @@ Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, con
}
String InputEventPanGesture::as_text() const {
-
return "InputEventPanGesture : delta=(" + String(get_delta()) + "), position=(" + String(get_position()) + ")";
}
void InputEventPanGesture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta);
ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta");
}
-InputEventPanGesture::InputEventPanGesture() {
-
- delta = Vector2(0, 0);
-}
-/////////////////////////////
+///////////////////////////////////
void InputEventMIDI::set_channel(const int p_channel) {
-
channel = p_channel;
}
@@ -1295,7 +1136,6 @@ int InputEventMIDI::get_channel() const {
}
void InputEventMIDI::set_message(const int p_message) {
-
message = p_message;
}
@@ -1304,7 +1144,6 @@ int InputEventMIDI::get_message() const {
}
void InputEventMIDI::set_pitch(const int p_pitch) {
-
pitch = p_pitch;
}
@@ -1313,7 +1152,6 @@ int InputEventMIDI::get_pitch() const {
}
void InputEventMIDI::set_velocity(const int p_velocity) {
-
velocity = p_velocity;
}
@@ -1322,7 +1160,6 @@ int InputEventMIDI::get_velocity() const {
}
void InputEventMIDI::set_instrument(const int p_instrument) {
-
instrument = p_instrument;
}
@@ -1331,7 +1168,6 @@ int InputEventMIDI::get_instrument() const {
}
void InputEventMIDI::set_pressure(const int p_pressure) {
-
pressure = p_pressure;
}
@@ -1340,7 +1176,6 @@ int InputEventMIDI::get_pressure() const {
}
void InputEventMIDI::set_controller_number(const int p_controller_number) {
-
controller_number = p_controller_number;
}
@@ -1349,7 +1184,6 @@ int InputEventMIDI::get_controller_number() const {
}
void InputEventMIDI::set_controller_value(const int p_controller_value) {
-
controller_value = p_controller_value;
}
@@ -1358,12 +1192,10 @@ int InputEventMIDI::get_controller_value() const {
}
String InputEventMIDI::as_text() const {
-
return "InputEventMIDI : channel=(" + itos(get_channel()) + "), message=(" + itos(get_message()) + ")";
}
void InputEventMIDI::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_channel", "channel"), &InputEventMIDI::set_channel);
ClassDB::bind_method(D_METHOD("get_channel"), &InputEventMIDI::get_channel);
ClassDB::bind_method(D_METHOD("set_message", "message"), &InputEventMIDI::set_message);
@@ -1390,15 +1222,3 @@ void InputEventMIDI::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_number"), "set_controller_number", "get_controller_number");
ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_value"), "set_controller_value", "get_controller_value");
}
-
-InputEventMIDI::InputEventMIDI() {
-
- channel = 0;
- message = 0;
- pitch = 0;
- velocity = 0;
- instrument = 0;
- pressure = 0;
- controller_number = 0;
- controller_value = 0;
-}
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 99ea2efee9..dd1cc11982 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -157,7 +157,7 @@ enum MidiMessageList {
class InputEvent : public Resource {
GDCLASS(InputEvent, Resource);
- int device;
+ int device = 0;
protected:
static void _bind_methods();
@@ -177,7 +177,6 @@ public:
// To be removed someday, since they do not make sense for all events
virtual bool is_pressed() const;
virtual bool is_echo() const;
- // ...-.
virtual String as_text() const;
@@ -188,14 +187,14 @@ public:
virtual bool is_action_type() const;
virtual bool accumulate(const Ref<InputEvent> &p_event) { return false; }
- InputEvent();
+
+ InputEvent() {}
};
class InputEventFromWindow : public InputEvent {
-
GDCLASS(InputEventFromWindow, InputEvent);
- int64_t window_id;
+ int64_t window_id = 0;
protected:
static void _bind_methods();
@@ -204,28 +203,27 @@ public:
void set_window_id(int64_t p_id);
int64_t get_window_id() const;
- InputEventFromWindow();
+ InputEventFromWindow() {}
};
class InputEventWithModifiers : public InputEventFromWindow {
GDCLASS(InputEventWithModifiers, InputEventFromWindow);
- bool shift;
- bool alt;
+ bool shift = false;
+ bool alt = false;
#ifdef APPLE_STYLE_KEYS
union {
bool command;
- bool meta; //< windows/mac key
+ bool meta = false; //< windows/mac key
};
- bool control;
+ bool control = false;
#else
union {
bool command; //< windows/mac key
- bool control;
+ bool control = false;
};
- bool meta; //< windows/mac key
-
+ bool meta = false; //< windows/mac key
#endif
protected:
@@ -249,20 +247,19 @@ public:
void set_modifiers_from_event(const InputEventWithModifiers *event);
- InputEventWithModifiers();
+ InputEventWithModifiers() {}
};
class InputEventKey : public InputEventWithModifiers {
-
GDCLASS(InputEventKey, InputEventWithModifiers);
- bool pressed; /// otherwise release
+ bool pressed = false; /// otherwise release
- uint32_t keycode; ///< check keyboard.h , KeyCode enum, without modifier masks
- uint32_t physical_keycode;
- uint32_t unicode; ///unicode
+ uint32_t keycode = 0; ///< check keyboard.h , KeyCode enum, without modifier masks
+ uint32_t physical_keycode = 0;
+ uint32_t unicode = 0; ///unicode
- bool echo; /// true if this is an echo key
+ bool echo = false; /// true if this is an echo key
protected:
static void _bind_methods();
@@ -293,14 +290,13 @@ public:
virtual String as_text() const;
- InputEventKey();
+ InputEventKey() {}
};
class InputEventMouse : public InputEventWithModifiers {
-
GDCLASS(InputEventMouse, InputEventWithModifiers);
- int button_mask;
+ int button_mask = 0;
Vector2 pos;
Vector2 global_pos;
@@ -318,17 +314,16 @@ public:
void set_global_position(const Vector2 &p_global_pos);
Vector2 get_global_position() const;
- InputEventMouse();
+ InputEventMouse() {}
};
class InputEventMouseButton : public InputEventMouse {
-
GDCLASS(InputEventMouseButton, InputEventMouse);
- float factor;
- int button_index;
- bool pressed; //otherwise released
- bool doubleclick; //last even less than doubleclick time
+ float factor = 1;
+ int button_index = 0;
+ bool pressed = false; //otherwise released
+ bool doubleclick = false; //last even less than doubleclick time
protected:
static void _bind_methods();
@@ -352,15 +347,14 @@ public:
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
- InputEventMouseButton();
+ InputEventMouseButton() {}
};
class InputEventMouseMotion : public InputEventMouse {
-
GDCLASS(InputEventMouseMotion, InputEventMouse);
Vector2 tilt;
- float pressure;
+ float pressure = 0;
Vector2 relative;
Vector2 speed;
@@ -385,14 +379,13 @@ public:
virtual bool accumulate(const Ref<InputEvent> &p_event);
- InputEventMouseMotion();
+ InputEventMouseMotion() {}
};
class InputEventJoypadMotion : public InputEvent {
-
GDCLASS(InputEventJoypadMotion, InputEvent);
- int axis; ///< Joypad axis
- float axis_value; ///< -1 to 1
+ int axis = 0; ///< Joypad axis
+ float axis_value = 0; ///< -1 to 1
protected:
static void _bind_methods();
@@ -411,15 +404,15 @@ public:
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
- InputEventJoypadMotion();
+ InputEventJoypadMotion() {}
};
class InputEventJoypadButton : public InputEvent {
GDCLASS(InputEventJoypadButton, InputEvent);
- int button_index;
- bool pressed;
- float pressure; //0 to 1
+ int button_index = 0;
+ bool pressed = false;
+ float pressure = 0; //0 to 1
protected:
static void _bind_methods();
@@ -439,14 +432,14 @@ public:
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
- InputEventJoypadButton();
+ InputEventJoypadButton() {}
};
class InputEventScreenTouch : public InputEventFromWindow {
GDCLASS(InputEventScreenTouch, InputEventFromWindow);
- int index;
+ int index = 0;
Vector2 pos;
- bool pressed;
+ bool pressed = false;
protected:
static void _bind_methods();
@@ -464,13 +457,12 @@ public:
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
virtual String as_text() const;
- InputEventScreenTouch();
+ InputEventScreenTouch() {}
};
class InputEventScreenDrag : public InputEventFromWindow {
-
GDCLASS(InputEventScreenDrag, InputEventFromWindow);
- int index;
+ int index = 0;
Vector2 pos;
Vector2 relative;
Vector2 speed;
@@ -494,16 +486,15 @@ public:
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
virtual String as_text() const;
- InputEventScreenDrag();
+ InputEventScreenDrag() {}
};
class InputEventAction : public InputEvent {
-
GDCLASS(InputEventAction, InputEvent);
StringName action;
- bool pressed;
- float strength;
+ bool pressed = false;
+ float strength = 1.0f;
protected:
static void _bind_methods();
@@ -526,11 +517,10 @@ public:
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
- InputEventAction();
+ InputEventAction() {}
};
class InputEventGesture : public InputEventWithModifiers {
-
GDCLASS(InputEventGesture, InputEventWithModifiers);
Vector2 pos;
@@ -544,9 +534,8 @@ public:
};
class InputEventMagnifyGesture : public InputEventGesture {
-
GDCLASS(InputEventMagnifyGesture, InputEventGesture);
- real_t factor;
+ real_t factor = 1.0;
protected:
static void _bind_methods();
@@ -558,11 +547,10 @@ public:
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
virtual String as_text() const;
- InputEventMagnifyGesture();
+ InputEventMagnifyGesture() {}
};
class InputEventPanGesture : public InputEventGesture {
-
GDCLASS(InputEventPanGesture, InputEventGesture);
Vector2 delta;
@@ -576,20 +564,20 @@ public:
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
virtual String as_text() const;
- InputEventPanGesture();
+ InputEventPanGesture() {}
};
class InputEventMIDI : public InputEvent {
GDCLASS(InputEventMIDI, InputEvent);
- int channel;
- int message;
- int pitch;
- int velocity;
- int instrument;
- int pressure;
- int controller_number;
- int controller_value;
+ int channel = 0;
+ int message = 0;
+ int pitch = 0;
+ int velocity = 0;
+ int instrument = 0;
+ int pressure = 0;
+ int controller_number = 0;
+ int controller_value = 0;
protected:
static void _bind_methods();
@@ -621,7 +609,7 @@ public:
virtual String as_text() const;
- InputEventMIDI();
+ InputEventMIDI() {}
};
#endif // INPUT_EVENT_H
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 6b6acf062d..ac032b7d10 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -38,7 +38,6 @@ InputMap *InputMap::singleton = nullptr;
int InputMap::ALL_DEVICES = -1;
void InputMap::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.5f));
@@ -49,13 +48,12 @@ void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("action_has_event", "action", "event"), &InputMap::action_has_event);
ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
ClassDB::bind_method(D_METHOD("action_erase_events", "action"), &InputMap::action_erase_events);
- ClassDB::bind_method(D_METHOD("get_action_list", "action"), &InputMap::_get_action_list);
+ ClassDB::bind_method(D_METHOD("action_get_events", "action"), &InputMap::_action_get_events);
ClassDB::bind_method(D_METHOD("event_is_action", "event", "action"), &InputMap::event_is_action);
ClassDB::bind_method(D_METHOD("load_from_globals"), &InputMap::load_from_globals);
}
void InputMap::add_action(const StringName &p_action, float p_deadzone) {
-
ERR_FAIL_COND_MSG(input_map.has(p_action), "InputMap already has action '" + String(p_action) + "'.");
input_map[p_action] = Action();
static int last_id = 1;
@@ -65,20 +63,18 @@ void InputMap::add_action(const StringName &p_action, float p_deadzone) {
}
void InputMap::erase_action(const StringName &p_action) {
-
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
input_map.erase(p_action);
}
Array InputMap::_get_actions() {
-
Array ret;
List<StringName> actions = get_actions();
- if (actions.empty())
+ if (actions.empty()) {
return ret;
+ }
for (const List<StringName>::Element *E = actions.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
@@ -86,7 +82,6 @@ Array InputMap::_get_actions() {
}
List<StringName> InputMap::get_actions() const {
-
List<StringName> actions = List<StringName>();
if (input_map.empty()) {
return actions;
@@ -100,9 +95,7 @@ List<StringName> InputMap::get_actions() const {
}
List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength) const {
-
for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) {
-
const Ref<InputEvent> e = E->get();
//if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here?
@@ -120,56 +113,50 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re
}
bool InputMap::has_action(const StringName &p_action) const {
-
return input_map.has(p_action);
}
void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
-
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
input_map[p_action].deadzone = p_deadzone;
}
void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
-
ERR_FAIL_COND_MSG(p_event.is_null(), "It's not a reference to a valid InputEvent object.");
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
- if (_find_event(input_map[p_action], p_event))
+ if (_find_event(input_map[p_action], p_event)) {
return; //already gots
+ }
input_map[p_action].inputs.push_back(p_event);
}
bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
-
ERR_FAIL_COND_V_MSG(!input_map.has(p_action), false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
return (_find_event(input_map[p_action], p_event) != nullptr);
}
void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
-
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
List<Ref<InputEvent>>::Element *E = _find_event(input_map[p_action], p_event);
- if (E)
+ if (E) {
input_map[p_action].inputs.erase(E);
+ }
}
void InputMap::action_erase_events(const StringName &p_action) {
-
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
input_map[p_action].inputs.clear();
}
-Array InputMap::_get_action_list(const StringName &p_action) {
-
+Array InputMap::_action_get_events(const StringName &p_action) {
Array ret;
- const List<Ref<InputEvent>> *al = get_action_list(p_action);
+ const List<Ref<InputEvent>> *al = action_get_events(p_action);
if (al) {
for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
}
@@ -177,11 +164,11 @@ Array InputMap::_get_action_list(const StringName &p_action) {
return ret;
}
-const List<Ref<InputEvent>> *InputMap::get_action_list(const StringName &p_action) {
-
+const List<Ref<InputEvent>> *InputMap::action_get_events(const StringName &p_action) {
const Map<StringName, Action>::Element *E = input_map.find(p_action);
- if (!E)
+ if (!E) {
return nullptr;
+ }
return &E->get().inputs;
}
@@ -196,10 +183,12 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
Ref<InputEventAction> input_event_action = p_event;
if (input_event_action.is_valid()) {
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = input_event_action->is_pressed();
- if (p_strength != nullptr)
+ }
+ if (p_strength != nullptr) {
*p_strength = (p_pressed != nullptr && *p_pressed) ? input_event_action->get_strength() : 0.0f;
+ }
return input_event_action->get_action() == p_action;
}
@@ -207,10 +196,12 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
float strength;
List<Ref<InputEvent>>::Element *event = _find_event(E->get(), p_event, &pressed, &strength);
if (event != nullptr) {
- if (p_pressed != nullptr)
+ if (p_pressed != nullptr) {
*p_pressed = pressed;
- if (p_strength != nullptr)
+ }
+ if (p_strength != nullptr) {
*p_strength = strength;
+ }
return true;
} else {
return false;
@@ -222,7 +213,6 @@ const Map<StringName, InputMap::Action> &InputMap::get_action_map() const {
}
void InputMap::load_from_globals() {
-
input_map.clear();
List<PropertyInfo> pinfo;
@@ -231,8 +221,9 @@ void InputMap::load_from_globals() {
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
- if (!pi.name.begins_with("input/"))
+ if (!pi.name.begins_with("input/")) {
continue;
+ }
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
@@ -243,15 +234,15 @@ void InputMap::load_from_globals() {
add_action(name, deadzone);
for (int i = 0; i < events.size(); i++) {
Ref<InputEvent> event = events[i];
- if (event.is_null())
+ if (event.is_null()) {
continue;
+ }
action_add_event(name, event);
}
}
}
void InputMap::load_default() {
-
Ref<InputEventKey> key;
add_action("ui_accept");
@@ -332,7 +323,6 @@ void InputMap::load_default() {
}
InputMap::InputMap() {
-
ERR_FAIL_COND_MSG(singleton, "Singleton in InputMap already exist.");
singleton = this;
}
diff --git a/core/input/input_map.h b/core/input/input_map.h
index e03bc5fd4f..548553ed31 100644
--- a/core/input/input_map.h
+++ b/core/input/input_map.h
@@ -35,7 +35,6 @@
#include "core/object.h"
class InputMap : public Object {
-
GDCLASS(InputMap, Object);
public:
@@ -57,7 +56,7 @@ private:
List<Ref<InputEvent>>::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed = nullptr, float *p_strength = nullptr) const;
- Array _get_action_list(const StringName &p_action);
+ Array _action_get_events(const StringName &p_action);
Array _get_actions();
protected:
@@ -77,7 +76,7 @@ public:
void action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event);
void action_erase_events(const StringName &p_action);
- const List<Ref<InputEvent>> *get_action_list(const StringName &p_action);
+ const List<Ref<InputEvent>> *action_get_events(const StringName &p_action);
bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const;
bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed = nullptr, float *p_strength = nullptr) const;
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index 20c9fdca6f..99ca8107e4 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -40,10 +40,8 @@
#include <zstd.h>
int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode) {
-
switch (p_mode) {
case MODE_FASTLZ: {
-
if (p_src_size < 16) {
uint8_t src[16];
zeromem(&src[p_src_size], 16 - p_src_size);
@@ -56,7 +54,6 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
} break;
case MODE_DEFLATE:
case MODE_GZIP: {
-
int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
z_stream strm;
@@ -65,8 +62,9 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
strm.opaque = Z_NULL;
int level = p_mode == MODE_DEFLATE ? zlib_level : gzip_level;
int err = deflateInit2(&strm, level, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY);
- if (err != Z_OK)
+ if (err != Z_OK) {
return -1;
+ }
strm.avail_in = p_src_size;
int aout = deflateBound(&strm, p_src_size);
@@ -97,19 +95,17 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
}
int Compression::get_max_compressed_buffer_size(int p_src_size, Mode p_mode) {
-
switch (p_mode) {
case MODE_FASTLZ: {
-
int ss = p_src_size + p_src_size * 6 / 100;
- if (ss < 66)
+ if (ss < 66) {
ss = 66;
+ }
return ss;
} break;
case MODE_DEFLATE:
case MODE_GZIP: {
-
int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
z_stream strm;
@@ -117,14 +113,14 @@ int Compression::get_max_compressed_buffer_size(int p_src_size, Mode p_mode) {
strm.zfree = zipio_free;
strm.opaque = Z_NULL;
int err = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY);
- if (err != Z_OK)
+ if (err != Z_OK) {
return -1;
+ }
int aout = deflateBound(&strm, p_src_size);
deflateEnd(&strm);
return aout;
} break;
case MODE_ZSTD: {
-
return ZSTD_compressBound(p_src_size);
} break;
}
@@ -133,10 +129,8 @@ int Compression::get_max_compressed_buffer_size(int p_src_size, Mode p_mode) {
}
int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size, Mode p_mode) {
-
switch (p_mode) {
case MODE_FASTLZ: {
-
int ret_size = 0;
if (p_dst_max_size < 16) {
@@ -150,7 +144,6 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
} break;
case MODE_DEFLATE:
case MODE_GZIP: {
-
int window_bits = p_mode == MODE_DEFLATE ? 15 : 15 + 16;
z_stream strm;
diff --git a/core/io/compression.h b/core/io/compression.h
index 8354b581fa..f195f96ba5 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -34,7 +34,6 @@
#include "core/typedefs.h"
class Compression {
-
public:
static int zlib_level;
static int gzip_level;
@@ -53,7 +52,7 @@ public:
static int get_max_compressed_buffer_size(int p_src_size, Mode p_mode = MODE_ZSTD);
static int decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size, Mode p_mode = MODE_ZSTD);
- Compression();
+ Compression() {}
};
#endif // COMPRESSION_H
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 73230e3a3c..1af9142317 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -35,14 +35,12 @@
#include "core/variant_parser.h"
PackedStringArray ConfigFile::_get_sections() const {
-
List<String> s;
get_sections(&s);
PackedStringArray arr;
arr.resize(s.size());
int idx = 0;
for (const List<String>::Element *E = s.front(); E; E = E->next()) {
-
arr.set(idx++, E->get());
}
@@ -50,14 +48,12 @@ PackedStringArray ConfigFile::_get_sections() const {
}
PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const {
-
List<String> s;
get_section_keys(p_section, &s);
PackedStringArray arr;
arr.resize(s.size());
int idx = 0;
for (const List<String>::Element *E = s.front(); E; E = E->next()) {
-
arr.set(idx++, E->get());
}
@@ -65,11 +61,11 @@ PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const {
}
void ConfigFile::set_value(const String &p_section, const String &p_key, const Variant &p_value) {
-
if (p_value.get_type() == Variant::NIL) {
//erase
- if (!values.has(p_section))
+ if (!values.has(p_section)) {
return; // ?
+ }
values[p_section].erase(p_key);
if (values[p_section].empty()) {
values.erase(p_section);
@@ -83,8 +79,8 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V
values[p_section][p_key] = p_value;
}
}
-Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const {
+Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const {
if (!values.has(p_section) || !values[p_section].has(p_key)) {
ERR_FAIL_COND_V_MSG(p_default.get_type() == Variant::NIL, Variant(),
vformat("Couldn't find the given section \"%s\" and key \"%s\", and no default was given.", p_section, p_key));
@@ -95,24 +91,23 @@ Variant ConfigFile::get_value(const String &p_section, const String &p_key, Vari
}
bool ConfigFile::has_section(const String &p_section) const {
-
return values.has(p_section);
}
-bool ConfigFile::has_section_key(const String &p_section, const String &p_key) const {
- if (!values.has(p_section))
+bool ConfigFile::has_section_key(const String &p_section, const String &p_key) const {
+ if (!values.has(p_section)) {
return false;
+ }
return values[p_section].has(p_key);
}
void ConfigFile::get_sections(List<String> *r_sections) const {
-
for (OrderedHashMap<String, OrderedHashMap<String, Variant>>::ConstElement E = values.front(); E; E = E.next()) {
r_sections->push_back(E.key());
}
}
-void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const {
+void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const {
ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot get keys from nonexistent section \"%s\".", p_section));
for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) {
@@ -121,13 +116,11 @@ void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys)
}
void ConfigFile::erase_section(const String &p_section) {
-
ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot erase nonexistent section \"%s\".", p_section));
values.erase(p_section);
}
void ConfigFile::erase_section_key(const String &p_section, const String &p_key) {
-
ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot erase key \"%s\" from nonexistent section \"%s\".", p_key, p_section));
ERR_FAIL_COND_MSG(!values[p_section].has(p_key), vformat("Cannot erase nonexistent key \"%s\" from section \"%s\".", p_key, p_section));
@@ -135,13 +128,13 @@ void ConfigFile::erase_section_key(const String &p_section, const String &p_key)
}
Error ConfigFile::save(const String &p_path) {
-
Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
if (err) {
- if (file)
+ if (file) {
memdelete(file);
+ }
return err;
}
@@ -149,12 +142,12 @@ Error ConfigFile::save(const String &p_path) {
}
Error ConfigFile::save_encrypted(const String &p_path, const Vector<uint8_t> &p_key) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse(f, p_key, FileAccessEncrypted::MODE_WRITE_AES256);
@@ -167,12 +160,12 @@ Error ConfigFile::save_encrypted(const String &p_path, const Vector<uint8_t> &p_
}
Error ConfigFile::save_encrypted_pass(const String &p_path, const String &p_pass) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse_password(f, p_pass, FileAccessEncrypted::MODE_WRITE_AES256);
@@ -186,15 +179,13 @@ Error ConfigFile::save_encrypted_pass(const String &p_path, const String &p_pass
}
Error ConfigFile::_internal_save(FileAccess *file) {
-
for (OrderedHashMap<String, OrderedHashMap<String, Variant>>::Element E = values.front(); E; E = E.next()) {
-
- if (E != values.front())
+ if (E != values.front()) {
file->store_string("\n");
+ }
file->store_string("[" + E.key() + "]\n\n");
for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) {
-
String vstr;
VariantWriter::write_to_string(F.get(), vstr);
file->store_string(F.key() + "=" + vstr + "\n");
@@ -207,23 +198,23 @@ Error ConfigFile::_internal_save(FileAccess *file) {
}
Error ConfigFile::load(const String &p_path) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (!f)
+ if (!f) {
return err;
+ }
return _internal_load(p_path, f);
}
Error ConfigFile::load_encrypted(const String &p_path, const Vector<uint8_t> &p_key) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse(f, p_key, FileAccessEncrypted::MODE_READ);
@@ -236,12 +227,12 @@ Error ConfigFile::load_encrypted(const String &p_path, const Vector<uint8_t> &p_
}
Error ConfigFile::load_encrypted_pass(const String &p_path, const String &p_pass) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse_password(f, p_pass, FileAccessEncrypted::MODE_READ);
@@ -255,7 +246,6 @@ Error ConfigFile::load_encrypted_pass(const String &p_path, const String &p_pass
}
Error ConfigFile::_internal_load(const String &p_path, FileAccess *f) {
-
VariantParser::StreamFile stream;
stream.f = f;
@@ -267,14 +257,12 @@ Error ConfigFile::_internal_load(const String &p_path, FileAccess *f) {
}
Error ConfigFile::parse(const String &p_data) {
-
VariantParser::StreamString stream;
stream.s = p_data;
return _parse("<string>", &stream);
}
Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream) {
-
String assign;
Variant value;
VariantParser::Tag next_tag;
@@ -285,7 +273,6 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream)
String section;
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -309,7 +296,6 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream)
}
void ConfigFile::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_value", "section", "key", "value"), &ConfigFile::set_value);
ClassDB::bind_method(D_METHOD("get_value", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
diff --git a/core/io/config_file.h b/core/io/config_file.h
index 39fc2ab412..ae06960f02 100644
--- a/core/io/config_file.h
+++ b/core/io/config_file.h
@@ -37,7 +37,6 @@
#include "core/variant_parser.h"
class ConfigFile : public Reference {
-
GDCLASS(ConfigFile, Reference);
OrderedHashMap<String, OrderedHashMap<String, Variant>> values;
diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp
index 5bda06e5b9..e43b1f5385 100644
--- a/core/io/dtls_server.cpp
+++ b/core/io/dtls_server.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "dtls_server.h"
+
#include "core/os/file_access.h"
#include "core/project_settings.h"
@@ -36,8 +37,10 @@ DTLSServer *(*DTLSServer::_create)() = nullptr;
bool DTLSServer::available = false;
DTLSServer *DTLSServer::create() {
-
- return _create();
+ if (_create) {
+ return _create();
+ }
+ return nullptr;
}
bool DTLSServer::is_available() {
@@ -45,10 +48,6 @@ bool DTLSServer::is_available() {
}
void DTLSServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("setup", "key", "certificate", "chain"), &DTLSServer::setup, DEFVAL(Ref<X509Certificate>()));
ClassDB::bind_method(D_METHOD("take_connection", "udp_peer"), &DTLSServer::take_connection);
}
-
-DTLSServer::DTLSServer() {
-}
diff --git a/core/io/dtls_server.h b/core/io/dtls_server.h
index 7b08138f7f..ae1d3bcd98 100644
--- a/core/io/dtls_server.h
+++ b/core/io/dtls_server.h
@@ -51,7 +51,7 @@ public:
virtual void stop() = 0;
virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer) = 0;
- DTLSServer();
+ DTLSServer() {}
};
#endif // DTLS_SERVER_H
diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp
index ab0fb3943c..6208f3a4d1 100644
--- a/core/io/file_access_buffered.cpp
+++ b/core/io/file_access_buffered.cpp
@@ -33,28 +33,23 @@
#include "core/error_macros.h"
Error FileAccessBuffered::set_error(Error p_error) const {
-
return (last_error = p_error);
}
void FileAccessBuffered::set_cache_size(int p_size) {
-
cache_size = p_size;
}
int FileAccessBuffered::get_cache_size() {
-
return cache_size;
}
int FileAccessBuffered::cache_data_left() const {
-
if (file.offset >= file.size) {
return 0;
}
if (cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size()) {
-
return read_data_block(file.offset, cache_size);
}
@@ -62,37 +57,30 @@ int FileAccessBuffered::cache_data_left() const {
}
void FileAccessBuffered::seek(size_t p_position) {
-
file.offset = p_position;
}
void FileAccessBuffered::seek_end(int64_t p_position) {
-
file.offset = file.size + p_position;
}
size_t FileAccessBuffered::get_position() const {
-
return file.offset;
}
size_t FileAccessBuffered::get_len() const {
-
return file.size;
}
bool FileAccessBuffered::eof_reached() const {
-
return file.offset > file.size;
}
uint8_t FileAccessBuffered::get_8() const {
-
ERR_FAIL_COND_V_MSG(!file.open, 0, "Can't get data, when file is not opened.");
uint8_t byte = 0;
if (cache_data_left() >= 1) {
-
byte = cache.buffer[file.offset - cache.offset];
}
@@ -102,15 +90,12 @@ uint8_t FileAccessBuffered::get_8() const {
}
int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
-
ERR_FAIL_COND_V_MSG(!file.open, -1, "Can't get buffer, when file is not opened.");
if (p_length > cache_size) {
-
int total_read = 0;
if (!(cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size())) {
-
int size = (cache.buffer.size() - (file.offset - cache.offset));
size = size - (size % 4);
//const uint8_t* read = cache.buffer.ptr();
@@ -134,7 +119,6 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
int to_read = p_length;
int total_read = 0;
while (to_read > 0) {
-
int left = cache_data_left();
if (left == 0) {
file.offset += to_read;
@@ -158,19 +142,9 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
}
bool FileAccessBuffered::is_open() const {
-
return file.open;
}
Error FileAccessBuffered::get_error() const {
-
return last_error;
}
-
-FileAccessBuffered::FileAccessBuffered() {
-
- cache_size = DEFAULT_CACHE_SIZE;
-}
-
-FileAccessBuffered::~FileAccessBuffered() {
-}
diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h
index a6177c20be..61c0fa7489 100644
--- a/core/io/file_access_buffered.h
+++ b/core/io/file_access_buffered.h
@@ -36,14 +36,13 @@
#include "core/ustring.h"
class FileAccessBuffered : public FileAccess {
-
public:
enum {
DEFAULT_CACHE_SIZE = 128 * 1024,
};
private:
- int cache_size;
+ int cache_size = DEFAULT_CACHE_SIZE;
int cache_data_left() const;
mutable Error last_error;
@@ -52,7 +51,6 @@ protected:
Error set_error(Error p_error) const;
mutable struct File {
-
bool open;
int size;
int offset;
@@ -61,12 +59,11 @@ protected:
} file;
mutable struct Cache {
-
Vector<uint8_t> buffer;
int offset;
} cache;
- virtual int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const = 0;
+ virtual int read_data_block(int p_offset, int p_size, uint8_t *p_dest = nullptr) const = 0;
void set_cache_size(int p_size);
int get_cache_size();
@@ -87,8 +84,8 @@ public:
virtual Error get_error() const;
- FileAccessBuffered();
- virtual ~FileAccessBuffered();
+ FileAccessBuffered() {}
+ virtual ~FileAccessBuffered() {}
};
#endif
diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h
index 6ec77d503b..f22e54e154 100644
--- a/core/io/file_access_buffered_fa.h
+++ b/core/io/file_access_buffered_fa.h
@@ -35,22 +35,18 @@
template <class T>
class FileAccessBufferedFA : public FileAccessBuffered {
-
T f;
int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const {
-
ERR_FAIL_COND_V_MSG(!f.is_open(), -1, "Can't read data block when file is not opened.");
((T *)&f)->seek(p_offset);
if (p_dest) {
-
f.get_buffer(p_dest, p_size);
return p_size;
} else {
-
cache.offset = p_offset;
cache.buffer.resize(p_size);
@@ -62,43 +58,37 @@ class FileAccessBufferedFA : public FileAccessBuffered {
f.get_buffer(cache.buffer.ptrw(), p_size);
return p_size;
- };
- };
+ }
+ }
static FileAccess *create() {
-
return memnew(FileAccessBufferedFA<T>());
- };
+ }
protected:
virtual void _set_access_type(AccessType p_access) {
f._set_access_type(p_access);
FileAccessBuffered::_set_access_type(p_access);
- };
+ }
public:
void flush() {
-
f.flush();
- };
+ }
void store_8(uint8_t p_dest) {
-
f.store_8(p_dest);
- };
+ }
void store_buffer(const uint8_t *p_src, int p_length) {
-
f.store_buffer(p_src, p_length);
- };
+ }
bool file_exists(const String &p_name) {
-
return f.file_exists(p_name);
- };
+ }
Error _open(const String &p_path, int p_mode_flags) {
-
close();
Error ret = f._open(p_path, p_mode_flags);
@@ -116,10 +106,9 @@ public:
cache.offset = 0;
return set_error(OK);
- };
+ }
void close() {
-
f.close();
file.offset = 0;
@@ -130,16 +119,9 @@ public:
cache.buffer.resize(0);
cache.offset = 0;
set_error(OK);
- };
-
- /*
- static void make_default() {
- FileAccess::create_func = FileAccessBufferedFA<T>::create;
- };
- */
+ }
virtual uint64_t _get_modified_time(const String &p_file) {
-
return f._get_modified_time(p_file);
}
@@ -151,9 +133,7 @@ public:
return f._set_unix_permissions(p_file, p_permissions);
}
- FileAccessBufferedFA(){
-
- };
+ FileAccessBufferedFA() {}
};
#endif // FILE_ACCESS_BUFFERED_FA_H
diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp
index c76142d22d..7817ccb773 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -33,13 +33,13 @@
#include "core/print_string.h"
void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_mode, int p_block_size) {
-
magic = p_magic.ascii().get_data();
- if (magic.length() > 4)
+ if (magic.length() > 4) {
magic = magic.substr(0, 4);
- else {
- while (magic.length() < 4)
+ } else {
+ while (magic.length() < 4) {
magic += " ";
+ }
}
cmode = p_mode;
@@ -59,7 +59,6 @@ void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_
}
Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
-
f = p_base;
cmode = (Compression::Mode)f->get_32();
block_size = f->get_32();
@@ -72,7 +71,6 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
int acc_ofs = f->get_position() + bc * 4;
int max_bs = 0;
for (int i = 0; i < bc; i++) {
-
ReadBlock rb;
rb.offset = acc_ofs;
rb.csize = f->get_32();
@@ -98,11 +96,11 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
}
Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) {
-
ERR_FAIL_COND_V(p_mode_flags == READ_WRITE, ERR_UNAVAILABLE);
- if (f)
+ if (f) {
close();
+ }
Error err;
f = FileAccess::open(p_path, p_mode_flags, &err);
@@ -114,7 +112,6 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) {
}
if (p_mode_flags & WRITE) {
-
buffer.clear();
writing = true;
write_pos = 0;
@@ -125,7 +122,6 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) {
//don't store anything else unless it's done saving!
} else {
-
char rmagic[5];
f->get_buffer((uint8_t *)rmagic, 4);
rmagic[4] = 0;
@@ -138,10 +134,11 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) {
return OK;
}
-void FileAccessCompressed::close() {
- if (!f)
+void FileAccessCompressed::close() {
+ if (!f) {
return;
+ }
if (writing) {
//save block table and all compressed blocks
@@ -159,7 +156,6 @@ void FileAccessCompressed::close() {
Vector<int> block_sizes;
for (int i = 0; i < bc; i++) {
-
int bl = i == (bc - 1) ? write_max % block_size : block_size;
uint8_t *bp = &write_ptr[i * block_size];
@@ -172,15 +168,15 @@ void FileAccessCompressed::close() {
}
f->seek(16); //ok write block sizes
- for (int i = 0; i < bc; i++)
+ for (int i = 0; i < bc; i++) {
f->store_32(block_sizes[i]);
+ }
f->seek_end();
f->store_buffer((const uint8_t *)mgc.get_data(), mgc.length()); //magic at the end too
buffer.clear();
} else {
-
comp_buffer.clear();
buffer.clear();
read_blocks.clear();
@@ -191,21 +187,17 @@ void FileAccessCompressed::close() {
}
bool FileAccessCompressed::is_open() const {
-
return f != nullptr;
}
void FileAccessCompressed::seek(size_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (writing) {
-
ERR_FAIL_COND(p_position > write_max);
write_pos = p_position;
} else {
-
ERR_FAIL_COND(p_position > read_total);
if (p_position == read_total) {
at_end = true;
@@ -214,7 +206,6 @@ void FileAccessCompressed::seek(size_t p_position) {
read_eof = false;
int block_idx = p_position / block_size;
if (block_idx != read_block) {
-
read_block = block_idx;
f->seek(read_blocks[read_block].offset);
f->get_buffer(comp_buffer.ptrw(), read_blocks[read_block].csize);
@@ -228,32 +219,26 @@ void FileAccessCompressed::seek(size_t p_position) {
}
void FileAccessCompressed::seek_end(int64_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (writing) {
-
seek(write_max + p_position);
} else {
-
seek(read_total + p_position);
}
}
-size_t FileAccessCompressed::get_position() const {
+size_t FileAccessCompressed::get_position() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
if (writing) {
-
return write_pos;
} else {
-
return read_block * block_size + read_pos;
}
}
-size_t FileAccessCompressed::get_len() const {
+size_t FileAccessCompressed::get_len() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
if (writing) {
-
return write_max;
} else {
return read_total;
@@ -261,7 +246,6 @@ size_t FileAccessCompressed::get_len() const {
}
bool FileAccessCompressed::eof_reached() const {
-
ERR_FAIL_COND_V_MSG(!f, false, "File must be opened before use.");
if (writing) {
return false;
@@ -271,7 +255,6 @@ bool FileAccessCompressed::eof_reached() const {
}
uint8_t FileAccessCompressed::get_8() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
@@ -301,8 +284,8 @@ uint8_t FileAccessCompressed::get_8() const {
return ret;
}
-int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
+int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
@@ -312,7 +295,6 @@ int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
}
for (int i = 0; i < p_length; i++) {
-
p_dst[i] = read_ptr[read_pos];
read_pos++;
if (read_pos >= read_block_size) {
@@ -328,8 +310,9 @@ int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
} else {
read_block--;
at_end = true;
- if (i < p_length - 1)
+ if (i < p_length - 1) {
read_eof = true;
+ }
return i;
}
}
@@ -339,7 +322,6 @@ int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessCompressed::get_error() const {
-
return read_eof ? ERR_FILE_EOF : OK;
}
@@ -351,7 +333,6 @@ void FileAccessCompressed::flush() {
}
void FileAccessCompressed::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
@@ -360,25 +341,26 @@ void FileAccessCompressed::store_8(uint8_t p_dest) {
}
bool FileAccessCompressed::file_exists(const String &p_name) {
-
FileAccess *fa = FileAccess::open(p_name, FileAccess::READ);
- if (!fa)
+ if (!fa) {
return false;
+ }
memdelete(fa);
return true;
}
uint64_t FileAccessCompressed::_get_modified_time(const String &p_file) {
-
- if (f)
+ if (f) {
return f->get_modified_time(p_file);
- else
+ } else {
return 0;
+ }
}
uint32_t FileAccessCompressed::_get_unix_permissions(const String &p_file) {
- if (f)
+ if (f) {
return f->_get_unix_permissions(p_file);
+ }
return 0;
}
@@ -389,27 +371,8 @@ Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t
return FAILED;
}
-FileAccessCompressed::FileAccessCompressed() :
- cmode(Compression::MODE_ZSTD),
- writing(false),
- write_ptr(nullptr),
- write_buffer_size(0),
- write_max(0),
- block_size(0),
- read_eof(false),
- at_end(false),
- read_ptr(nullptr),
- read_block(0),
- read_block_count(0),
- read_block_size(0),
- read_pos(0),
- read_total(0),
- magic("GCMP"),
- f(nullptr) {
-}
-
FileAccessCompressed::~FileAccessCompressed() {
-
- if (f)
+ if (f) {
close();
+ }
}
diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h
index 0bb311faa8..52284b347e 100644
--- a/core/io/file_access_compressed.h
+++ b/core/io/file_access_compressed.h
@@ -35,16 +35,15 @@
#include "core/os/file_access.h"
class FileAccessCompressed : public FileAccess {
-
- Compression::Mode cmode;
- bool writing;
- uint32_t write_pos;
- uint8_t *write_ptr;
- uint32_t write_buffer_size;
- uint32_t write_max;
- uint32_t block_size;
- mutable bool read_eof;
- mutable bool at_end;
+ Compression::Mode cmode = Compression::MODE_ZSTD;
+ bool writing = false;
+ uint32_t write_pos = 0;
+ uint8_t *write_ptr = nullptr;
+ uint32_t write_buffer_size = 0;
+ uint32_t write_max = 0;
+ uint32_t block_size = 0;
+ mutable bool read_eof = false;
+ mutable bool at_end = false;
struct ReadBlock {
int csize;
@@ -52,17 +51,17 @@ class FileAccessCompressed : public FileAccess {
};
mutable Vector<uint8_t> comp_buffer;
- uint8_t *read_ptr;
- mutable int read_block;
- int read_block_count;
- mutable int read_block_size;
- mutable int read_pos;
+ uint8_t *read_ptr = nullptr;
+ mutable int read_block = 0;
+ int read_block_count = 0;
+ mutable int read_block_size = 0;
+ mutable int read_pos = 0;
Vector<ReadBlock> read_blocks;
- uint32_t read_total;
+ uint32_t read_total = 0;
- String magic;
+ String magic = "GCMP";
mutable Vector<uint8_t> buffer;
- FileAccess *f;
+ FileAccess *f = nullptr;
public:
void configure(const String &p_magic, Compression::Mode p_mode = Compression::MODE_ZSTD, int p_block_size = 4096);
@@ -94,7 +93,7 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file);
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
- FileAccessCompressed();
+ FileAccessCompressed() {}
virtual ~FileAccessCompressed();
};
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index a5b3807789..5938914cb0 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -40,7 +40,6 @@
#define COMP_MAGIC 0x43454447
Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) {
-
ERR_FAIL_COND_V_MSG(file != nullptr, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open.");
ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER);
@@ -48,7 +47,6 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
eofed = false;
if (p_mode == MODE_WRITE_AES256) {
-
data.clear();
writing = true;
file = p_base;
@@ -56,7 +54,6 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
key = p_key;
} else if (p_mode == MODE_READ) {
-
writing = false;
key = p_key;
uint32_t magic = p_base->get_32();
@@ -85,7 +82,6 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
ctx.set_decode_key(key.ptrw(), 256);
for (size_t i = 0; i < ds; i += 16) {
-
ctx.decrypt_ecb(&data.write[i], &data.write[i]);
}
@@ -103,13 +99,11 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
}
Error FileAccessEncrypted::open_and_parse_password(FileAccess *p_base, const String &p_key, Mode p_mode) {
-
String cs = p_key.md5_text();
ERR_FAIL_COND_V(cs.length() != 32, ERR_INVALID_PARAMETER);
Vector<uint8_t> key;
key.resize(32);
for (int i = 0; i < 32; i++) {
-
key.write[i] = cs[i];
}
@@ -117,16 +111,15 @@ Error FileAccessEncrypted::open_and_parse_password(FileAccess *p_base, const Str
}
Error FileAccessEncrypted::_open(const String &p_path, int p_mode_flags) {
-
return OK;
}
-void FileAccessEncrypted::close() {
- if (!file)
+void FileAccessEncrypted::close() {
+ if (!file) {
return;
+ }
if (writing) {
-
Vector<uint8_t> compressed;
size_t len = data.size();
if (len % 16) {
@@ -146,7 +139,6 @@ void FileAccessEncrypted::close() {
ctx.set_encode_key(key.ptrw(), 256);
for (size_t i = 0; i < len; i += 16) {
-
ctx.encrypt_ecb(&compressed.write[i], &compressed.write[i]);
}
@@ -163,7 +155,6 @@ void FileAccessEncrypted::close() {
data.clear();
} else {
-
file->close();
memdelete(file);
data.clear();
@@ -172,55 +163,51 @@ void FileAccessEncrypted::close() {
}
bool FileAccessEncrypted::is_open() const {
-
return file != nullptr;
}
String FileAccessEncrypted::get_path() const {
-
- if (file)
+ if (file) {
return file->get_path();
- else
+ } else {
return "";
+ }
}
String FileAccessEncrypted::get_path_absolute() const {
-
- if (file)
+ if (file) {
return file->get_path_absolute();
- else
+ } else {
return "";
+ }
}
void FileAccessEncrypted::seek(size_t p_position) {
-
- if (p_position > (size_t)data.size())
+ if (p_position > (size_t)data.size()) {
p_position = data.size();
+ }
pos = p_position;
eofed = false;
}
void FileAccessEncrypted::seek_end(int64_t p_position) {
-
seek(data.size() + p_position);
}
-size_t FileAccessEncrypted::get_position() const {
+size_t FileAccessEncrypted::get_position() const {
return pos;
}
-size_t FileAccessEncrypted::get_len() const {
+size_t FileAccessEncrypted::get_len() const {
return data.size();
}
bool FileAccessEncrypted::eof_reached() const {
-
return eofed;
}
uint8_t FileAccessEncrypted::get_8() const {
-
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
if (pos >= data.size()) {
eofed = true;
@@ -231,13 +218,12 @@ uint8_t FileAccessEncrypted::get_8() const {
pos++;
return b;
}
-int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
+int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
int to_copy = MIN(p_length, data.size() - pos);
for (int i = 0; i < to_copy; i++) {
-
p_dst[i] = data[pos++];
}
@@ -249,25 +235,19 @@ int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessEncrypted::get_error() const {
-
return eofed ? ERR_FILE_EOF : OK;
}
void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
-
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
if (pos < data.size()) {
-
for (int i = 0; i < p_length; i++) {
-
store_8(p_src[i]);
}
} else if (pos == data.size()) {
-
data.resize(pos + p_length);
for (int i = 0; i < p_length; i++) {
-
data.write[pos + i] = p_src[i];
}
pos += p_length;
@@ -281,7 +261,6 @@ void FileAccessEncrypted::flush() {
}
void FileAccessEncrypted::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
if (pos < data.size()) {
@@ -294,21 +273,19 @@ void FileAccessEncrypted::store_8(uint8_t p_dest) {
}
bool FileAccessEncrypted::file_exists(const String &p_name) {
-
FileAccess *fa = FileAccess::open(p_name, FileAccess::READ);
- if (!fa)
+ if (!fa) {
return false;
+ }
memdelete(fa);
return true;
}
uint64_t FileAccessEncrypted::_get_modified_time(const String &p_file) {
-
return 0;
}
uint32_t FileAccessEncrypted::_get_unix_permissions(const String &p_file) {
-
return 0;
}
@@ -317,17 +294,8 @@ Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t
return ERR_UNAVAILABLE;
}
-FileAccessEncrypted::FileAccessEncrypted() {
-
- file = nullptr;
- pos = 0;
- eofed = false;
- mode = MODE_MAX;
- writing = false;
-}
-
FileAccessEncrypted::~FileAccessEncrypted() {
-
- if (file)
+ if (file) {
close();
+ }
}
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index 7a9f4ecdd8..e269c1e30c 100644
--- a/core/io/file_access_encrypted.h
+++ b/core/io/file_access_encrypted.h
@@ -42,15 +42,15 @@ public:
};
private:
- Mode mode;
+ Mode mode = MODE_MAX;
Vector<uint8_t> key;
- bool writing;
- FileAccess *file;
+ bool writing = false;
+ FileAccess *file = nullptr;
size_t base;
size_t length;
Vector<uint8_t> data;
- mutable int pos;
- mutable bool eofed;
+ mutable int pos = 0;
+ mutable bool eofed = false;
public:
Error open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode);
@@ -85,7 +85,7 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file);
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
- FileAccessEncrypted();
+ FileAccessEncrypted() {}
~FileAccessEncrypted();
};
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index a2379ce88f..a65ff92a89 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -38,36 +38,34 @@
static Map<String, Vector<uint8_t>> *files = nullptr;
void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
-
if (!files) {
files = memnew((Map<String, Vector<uint8_t>>));
}
String name;
- if (ProjectSettings::get_singleton())
+ if (ProjectSettings::get_singleton()) {
name = ProjectSettings::get_singleton()->globalize_path(p_name);
- else
+ } else {
name = p_name;
+ }
//name = DirAccess::normalize_path(name);
(*files)[name] = p_data;
}
void FileAccessMemory::cleanup() {
-
- if (!files)
+ if (!files) {
return;
+ }
memdelete(files);
}
FileAccess *FileAccessMemory::create() {
-
return memnew(FileAccessMemory);
}
bool FileAccessMemory::file_exists(const String &p_name) {
-
String name = fix_path(p_name);
//name = DirAccess::normalize_path(name);
@@ -75,7 +73,6 @@ bool FileAccessMemory::file_exists(const String &p_name) {
}
Error FileAccessMemory::open_custom(const uint8_t *p_data, int p_len) {
-
data = (uint8_t *)p_data;
length = p_len;
pos = 0;
@@ -83,7 +80,6 @@ Error FileAccessMemory::open_custom(const uint8_t *p_data, int p_len) {
}
Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) {
-
ERR_FAIL_COND_V(!files, ERR_FILE_NOT_FOUND);
String name = fix_path(p_path);
@@ -100,46 +96,38 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessMemory::close() {
-
data = nullptr;
}
bool FileAccessMemory::is_open() const {
-
return data != nullptr;
}
void FileAccessMemory::seek(size_t p_position) {
-
ERR_FAIL_COND(!data);
pos = p_position;
}
void FileAccessMemory::seek_end(int64_t p_position) {
-
ERR_FAIL_COND(!data);
pos = length + p_position;
}
size_t FileAccessMemory::get_position() const {
-
ERR_FAIL_COND_V(!data, 0);
return pos;
}
size_t FileAccessMemory::get_len() const {
-
ERR_FAIL_COND_V(!data, 0);
return length;
}
bool FileAccessMemory::eof_reached() const {
-
return pos > length;
}
uint8_t FileAccessMemory::get_8() const {
-
uint8_t ret = 0;
if (pos < length) {
ret = data[pos];
@@ -150,7 +138,6 @@ uint8_t FileAccessMemory::get_8() const {
}
int FileAccessMemory::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V(!data, -1);
int left = length - pos;
@@ -158,7 +145,7 @@ int FileAccessMemory::get_buffer(uint8_t *p_dst, int p_length) const {
if (read < p_length) {
WARN_PRINT("Reading less data than requested");
- };
+ }
copymem(p_dst, &data[pos], read);
pos += p_length;
@@ -167,7 +154,6 @@ int FileAccessMemory::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessMemory::get_error() const {
-
return pos >= length ? ERR_FILE_EOF : OK;
}
@@ -176,14 +162,12 @@ void FileAccessMemory::flush() {
}
void FileAccessMemory::store_8(uint8_t p_byte) {
-
ERR_FAIL_COND(!data);
ERR_FAIL_COND(pos >= length);
data[pos++] = p_byte;
}
void FileAccessMemory::store_buffer(const uint8_t *p_src, int p_length) {
-
int left = length - pos;
int write = MIN(p_length, left);
if (write < p_length) {
@@ -193,8 +177,3 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, int p_length) {
copymem(&data[pos], p_src, write);
pos += p_length;
}
-
-FileAccessMemory::FileAccessMemory() {
-
- data = nullptr;
-}
diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h
index 2db14db265..1a9bd3fbbb 100644
--- a/core/io/file_access_memory.h
+++ b/core/io/file_access_memory.h
@@ -34,8 +34,7 @@
#include "core/os/file_access.h"
class FileAccessMemory : public FileAccess {
-
- uint8_t *data;
+ uint8_t *data = nullptr;
int length;
mutable int pos;
@@ -73,7 +72,7 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; }
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; }
- FileAccessMemory();
+ FileAccessMemory() {}
};
#endif // FILE_ACCESS_MEMORY_H
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index a3f307393f..6890740d90 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -41,19 +41,16 @@
#define DEBUG_TIME(m_what)
void FileAccessNetworkClient::lock_mutex() {
-
mutex.lock();
lockcount++;
}
void FileAccessNetworkClient::unlock_mutex() {
-
lockcount--;
mutex.unlock();
}
void FileAccessNetworkClient::put_32(int p_32) {
-
uint8_t buf[4];
encode_uint32(p_32, buf);
client->put_data(buf, 4);
@@ -61,7 +58,6 @@ void FileAccessNetworkClient::put_32(int p_32) {
}
void FileAccessNetworkClient::put_64(int64_t p_64) {
-
uint8_t buf[8];
encode_uint64(p_64, buf);
client->put_data(buf, 8);
@@ -69,24 +65,20 @@ void FileAccessNetworkClient::put_64(int64_t p_64) {
}
int FileAccessNetworkClient::get_32() {
-
uint8_t buf[4];
client->get_data(buf, 4);
return decode_uint32(buf);
}
int64_t FileAccessNetworkClient::get_64() {
-
uint8_t buf[8];
client->get_data(buf, 8);
return decode_uint64(buf);
}
void FileAccessNetworkClient::_thread_func() {
-
client->set_no_delay(true);
while (!quit) {
-
DEBUG_PRINT("SEM WAIT - " + itos(sem->get()));
sem.wait();
DEBUG_TIME("sem_unlock");
@@ -123,13 +115,12 @@ void FileAccessNetworkClient::_thread_func() {
}
}
- if (accesses.has(id))
+ if (accesses.has(id)) {
fa = accesses[id];
+ }
switch (response) {
-
case FileAccessNetwork::RESPONSE_OPEN: {
-
DEBUG_TIME("sem_open");
int status = get_32();
if (status != OK) {
@@ -143,7 +134,6 @@ void FileAccessNetworkClient::_thread_func() {
} break;
case FileAccessNetwork::RESPONSE_DATA: {
-
int64_t offset = get_64();
uint32_t len = get_32();
@@ -151,19 +141,18 @@ void FileAccessNetworkClient::_thread_func() {
block.resize(len);
client->get_data(block.ptrw(), len);
- if (fa) //may have been queued
+ if (fa) { //may have been queued
fa->_set_block(offset, block);
+ }
} break;
case FileAccessNetwork::RESPONSE_FILE_EXISTS: {
-
int status = get_32();
fa->exists_modtime = status != 0;
fa->sem.post();
} break;
case FileAccessNetwork::RESPONSE_GET_MODTIME: {
-
uint64_t status = get_64();
fa->exists_modtime = status;
fa->sem.post();
@@ -176,14 +165,12 @@ void FileAccessNetworkClient::_thread_func() {
}
void FileAccessNetworkClient::_thread_func(void *s) {
-
FileAccessNetworkClient *self = (FileAccessNetworkClient *)s;
self->_thread_func();
}
Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const String &p_password) {
-
IP_Address ip;
if (p_host.is_valid_ip_address()) {
@@ -222,17 +209,11 @@ Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const S
FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr;
FileAccessNetworkClient::FileAccessNetworkClient() {
-
- thread = nullptr;
- quit = false;
singleton = this;
- last_id = 0;
client.instance();
- lockcount = 0;
}
FileAccessNetworkClient::~FileAccessNetworkClient() {
-
if (thread) {
quit = true;
sem.post();
@@ -242,7 +223,6 @@ FileAccessNetworkClient::~FileAccessNetworkClient() {
}
void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block) {
-
int page = p_offset / page_size;
ERR_FAIL_INDEX(page, pages.size());
if (page < pages.size() - 1) {
@@ -264,11 +244,11 @@ void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block)
}
void FileAccessNetwork::_respond(size_t p_len, Error p_status) {
-
DEBUG_PRINT("GOT RESPONSE - len: " + itos(p_len) + " status: " + itos(p_status));
response = p_status;
- if (response != OK)
+ if (response != OK) {
return;
+ }
opened = true;
total_size = p_len;
int pc = ((total_size - 1) / page_size) + 1;
@@ -276,10 +256,10 @@ void FileAccessNetwork::_respond(size_t p_len, Error p_status) {
}
Error FileAccessNetwork::_open(const String &p_path, int p_mode_flags) {
-
ERR_FAIL_COND_V(p_mode_flags != READ, ERR_UNAVAILABLE);
- if (opened)
+ if (opened) {
close();
+ }
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
DEBUG_PRINT("open: " + p_path);
@@ -311,9 +291,9 @@ Error FileAccessNetwork::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessNetwork::close() {
-
- if (!opened)
+ if (!opened) {
return;
+ }
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
@@ -325,13 +305,12 @@ void FileAccessNetwork::close() {
opened = false;
nc->unlock_mutex();
}
-bool FileAccessNetwork::is_open() const {
+bool FileAccessNetwork::is_open() const {
return opened;
}
void FileAccessNetwork::seek(size_t p_position) {
-
ERR_FAIL_COND_MSG(!opened, "File must be opened before use.");
eof_flag = p_position > total_size;
@@ -343,39 +322,35 @@ void FileAccessNetwork::seek(size_t p_position) {
}
void FileAccessNetwork::seek_end(int64_t p_position) {
-
seek(total_size + p_position);
}
-size_t FileAccessNetwork::get_position() const {
+size_t FileAccessNetwork::get_position() const {
ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use.");
return pos;
}
-size_t FileAccessNetwork::get_len() const {
+size_t FileAccessNetwork::get_len() const {
ERR_FAIL_COND_V_MSG(!opened, 0, "File must be opened before use.");
return total_size;
}
bool FileAccessNetwork::eof_reached() const {
-
ERR_FAIL_COND_V_MSG(!opened, false, "File must be opened before use.");
return eof_flag;
}
uint8_t FileAccessNetwork::get_8() const {
-
uint8_t v;
get_buffer(&v, 1);
return v;
}
void FileAccessNetwork::_queue_page(int p_page) const {
-
- if (p_page >= pages.size())
+ if (p_page >= pages.size()) {
return;
+ }
if (pages[p_page].buffer.empty() && !pages[p_page].queued) {
-
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
{
MutexLock lock(nc->blockrequest_mutex);
@@ -394,7 +369,6 @@ void FileAccessNetwork::_queue_page(int p_page) const {
}
int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
-
//bool eof=false;
if (pos + p_length > total_size) {
eof_flag = true;
@@ -408,7 +382,6 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
uint8_t *buff = last_page_buff;
for (int i = 0; i < p_length; i++) {
-
int page = pos / page_size;
if (page != last_page) {
@@ -416,7 +389,6 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
if (pages[page].buffer.empty()) {
waiting_on_page = page;
for (int j = 0; j < read_ahead; j++) {
-
_queue_page(page + j);
}
buffer_mutex.unlock();
@@ -424,9 +396,7 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
page_sem.wait();
DEBUG_PRINT("done");
} else {
-
for (int j = 0; j < read_ahead; j++) {
-
_queue_page(page + j);
}
//queue pages
@@ -446,7 +416,6 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessNetwork::get_error() const {
-
return pos == total_size ? ERR_FILE_EOF : OK;
}
@@ -455,12 +424,10 @@ void FileAccessNetwork::flush() {
}
void FileAccessNetwork::store_8(uint8_t p_dest) {
-
ERR_FAIL();
}
bool FileAccessNetwork::file_exists(const String &p_path) {
-
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
nc->lock_mutex();
nc->put_32(id);
@@ -477,7 +444,6 @@ bool FileAccessNetwork::file_exists(const String &p_path) {
}
uint64_t FileAccessNetwork::_get_modified_time(const String &p_file) {
-
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
nc->lock_mutex();
nc->put_32(id);
@@ -504,7 +470,6 @@ Error FileAccessNetwork::_set_unix_permissions(const String &p_file, uint32_t p_
}
void FileAccessNetwork::configure() {
-
GLOBAL_DEF("network/remote_fs/page_size", 65536);
ProjectSettings::get_singleton()->set_custom_property_info("network/remote_fs/page_size", PropertyInfo(Variant::INT, "network/remote_fs/page_size", PROPERTY_HINT_RANGE, "1,65536,1,or_greater")); //is used as denominator and can't be zero
GLOBAL_DEF("network/remote_fs/page_read_ahead", 4);
@@ -512,10 +477,6 @@ void FileAccessNetwork::configure() {
}
FileAccessNetwork::FileAccessNetwork() {
-
- eof_flag = false;
- opened = false;
- pos = 0;
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
nc->lock_mutex();
id = nc->last_id++;
@@ -523,13 +484,9 @@ FileAccessNetwork::FileAccessNetwork() {
nc->unlock_mutex();
page_size = GLOBAL_GET("network/remote_fs/page_size");
read_ahead = GLOBAL_GET("network/remote_fs/page_read_ahead");
- last_activity_val = 0;
- waiting_on_page = -1;
- last_page = -1;
}
FileAccessNetwork::~FileAccessNetwork() {
-
close();
FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h
index 7f664b46f7..dc5ce1e883 100644
--- a/core/io/file_access_network.h
+++ b/core/io/file_access_network.h
@@ -39,9 +39,7 @@
class FileAccessNetwork;
class FileAccessNetworkClient {
-
struct BlockRequest {
-
int id;
uint64_t offset;
int size;
@@ -50,13 +48,14 @@ class FileAccessNetworkClient {
List<BlockRequest> block_requests;
Semaphore sem;
- Thread *thread;
- bool quit;
+ Thread *thread = nullptr;
+ bool quit = false;
Mutex mutex;
Mutex blockrequest_mutex;
Map<int, FileAccessNetwork *> accesses;
Ref<StreamPeerTCP> client;
- int last_id;
+ int last_id = 0;
+ int lockcount = 0;
Vector<uint8_t> block;
@@ -67,7 +66,6 @@ class FileAccessNetworkClient {
void put_64(int64_t p_64);
int get_32();
int64_t get_64();
- int lockcount;
void lock_mutex();
void unlock_mutex();
@@ -84,31 +82,26 @@ public:
};
class FileAccessNetwork : public FileAccess {
-
Semaphore sem;
Semaphore page_sem;
Mutex buffer_mutex;
- bool opened;
+ bool opened = false;
size_t total_size;
- mutable size_t pos;
+ mutable size_t pos = 0;
int id;
- mutable bool eof_flag;
- mutable int last_page;
- mutable uint8_t *last_page_buff;
+ mutable bool eof_flag = false;
+ mutable int last_page = -1;
+ mutable uint8_t *last_page_buff = nullptr;
int page_size;
int read_ahead;
- mutable int waiting_on_page;
- mutable int last_activity_val;
+ mutable int waiting_on_page = -1;
+
struct Page {
- int activity;
- bool queued;
+ int activity = 0;
+ bool queued = false;
Vector<uint8_t> buffer;
- Page() {
- activity = 0;
- queued = false;
- }
};
mutable Vector<Page> pages;
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index fd9b83eaf9..37240f234a 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -35,20 +35,16 @@
#include <stdio.h>
Error PackedData::add_pack(const String &p_path, bool p_replace_files) {
-
for (int i = 0; i < sources.size(); i++) {
-
if (sources[i]->try_open_pack(p_path, p_replace_files)) {
-
return OK;
- };
- };
+ }
+ }
return ERR_FILE_UNRECOGNIZED;
-};
+}
void PackedData::add_path(const String &pkg_path, const String &path, uint64_t ofs, uint64_t size, const uint8_t *p_md5, PackSource *p_src, bool p_replace_files) {
-
PathMD5 pmd5(path.md5_buffer());
//printf("adding path %ls, %lli, %lli\n", path.c_str(), pmd5.a, pmd5.b);
@@ -58,12 +54,14 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o
pf.pack = pkg_path;
pf.offset = ofs;
pf.size = size;
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
pf.md5[i] = p_md5[i];
+ }
pf.src = p_src;
- if (!exists || p_replace_files)
+ if (!exists || p_replace_files) {
files[pmd5] = pf;
+ }
if (!exists) {
//search for dir
@@ -75,9 +73,7 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o
Vector<String> ds = p.get_base_dir().split("/");
for (int j = 0; j < ds.size(); j++) {
-
if (!cd->subdirs.has(ds[j])) {
-
PackedDir *pd = memnew(PackedDir);
pd->name = ds[j];
pd->parent = cd;
@@ -97,33 +93,28 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o
}
void PackedData::add_pack_source(PackSource *p_source) {
-
if (p_source != nullptr) {
sources.push_back(p_source);
}
-};
+}
PackedData *PackedData::singleton = nullptr;
PackedData::PackedData() {
-
singleton = this;
root = memnew(PackedDir);
- root->parent = nullptr;
- disabled = false;
add_pack_source(memnew(PackedSourcePCK));
}
void PackedData::_free_packed_dirs(PackedDir *p_dir) {
-
- for (Map<String, PackedDir *>::Element *E = p_dir->subdirs.front(); E; E = E->next())
+ for (Map<String, PackedDir *>::Element *E = p_dir->subdirs.front(); E; E = E->next()) {
_free_packed_dirs(E->get());
+ }
memdelete(p_dir);
}
PackedData::~PackedData() {
-
for (int i = 0; i < sources.size(); i++) {
memdelete(sources[i]);
}
@@ -133,10 +124,10 @@ PackedData::~PackedData() {
//////////////////////////////////////////////////////////////////
bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
- if (!f)
+ if (!f) {
return false;
+ }
uint32_t magic = f->get_32();
@@ -146,7 +137,6 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
f->seek(f->get_position() - 4);
magic = f->get_32();
if (magic != PACK_HEADER_MAGIC) {
-
f->close();
memdelete(f);
return false;
@@ -158,7 +148,6 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
magic = f->get_32();
if (magic != PACK_HEADER_MAGIC) {
-
f->close();
memdelete(f);
return false;
@@ -189,7 +178,6 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
int file_count = f->get_32();
for (int i = 0; i < file_count; i++) {
-
uint32_t sl = f->get_32();
CharString cs;
cs.resize(sl + 1);
@@ -204,38 +192,33 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
uint8_t md5[16];
f->get_buffer(md5, 16);
PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5, this, p_replace_files);
- };
+ }
f->close();
memdelete(f);
return true;
-};
+}
FileAccess *PackedSourcePCK::get_file(const String &p_path, PackedData::PackedFile *p_file) {
-
return memnew(FileAccessPack(p_path, *p_file));
-};
+}
//////////////////////////////////////////////////////////////////
Error FileAccessPack::_open(const String &p_path, int p_mode_flags) {
-
ERR_FAIL_V(ERR_UNAVAILABLE);
return ERR_UNAVAILABLE;
}
void FileAccessPack::close() {
-
f->close();
}
bool FileAccessPack::is_open() const {
-
return f->is_open();
}
void FileAccessPack::seek(size_t p_position) {
-
if (p_position > pf.size) {
eof = true;
} else {
@@ -245,26 +228,24 @@ void FileAccessPack::seek(size_t p_position) {
f->seek(pf.offset + p_position);
pos = p_position;
}
-void FileAccessPack::seek_end(int64_t p_position) {
+void FileAccessPack::seek_end(int64_t p_position) {
seek(pf.size + p_position);
}
-size_t FileAccessPack::get_position() const {
+size_t FileAccessPack::get_position() const {
return pos;
}
-size_t FileAccessPack::get_len() const {
+size_t FileAccessPack::get_len() const {
return pf.size;
}
bool FileAccessPack::eof_reached() const {
-
return eof;
}
uint8_t FileAccessPack::get_8() const {
-
if (pos >= pf.size) {
eof = true;
return 0;
@@ -275,9 +256,9 @@ uint8_t FileAccessPack::get_8() const {
}
int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
-
- if (eof)
+ if (eof) {
return 0;
+ }
uint64_t to_read = p_length;
if (to_read + pos > pf.size) {
@@ -287,8 +268,9 @@ int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
pos += p_length;
- if (to_read <= 0)
+ if (to_read <= 0) {
return 0;
+ }
f->get_buffer(p_dst, to_read);
return to_read;
@@ -300,36 +282,31 @@ void FileAccessPack::set_endian_swap(bool p_swap) {
}
Error FileAccessPack::get_error() const {
-
- if (eof)
+ if (eof) {
return ERR_FILE_EOF;
+ }
return OK;
}
void FileAccessPack::flush() {
-
ERR_FAIL();
}
void FileAccessPack::store_8(uint8_t p_dest) {
-
ERR_FAIL();
}
void FileAccessPack::store_buffer(const uint8_t *p_src, int p_length) {
-
ERR_FAIL();
}
bool FileAccessPack::file_exists(const String &p_name) {
-
return false;
}
FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) :
pf(p_file),
f(FileAccess::open(pf.pack, FileAccess::READ)) {
-
ERR_FAIL_COND_MSG(!f, "Can't open pack-referenced file '" + String(pf.pack) + "'.");
f->seek(pf.offset);
@@ -338,8 +315,9 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
}
FileAccessPack::~FileAccessPack() {
- if (f)
+ if (f) {
memdelete(f);
+ }
}
//////////////////////////////////////////////////////////////////////////////////
@@ -347,17 +325,14 @@ FileAccessPack::~FileAccessPack() {
//////////////////////////////////////////////////////////////////////////////////
Error DirAccessPack::list_dir_begin() {
-
list_dirs.clear();
list_files.clear();
for (Map<String, PackedData::PackedDir *>::Element *E = current->subdirs.front(); E; E = E->next()) {
-
list_dirs.push_back(E->key());
}
for (Set<String>::Element *E = current->files.front(); E; E = E->next()) {
-
list_files.push_back(E->get());
}
@@ -365,7 +340,6 @@ Error DirAccessPack::list_dir_begin() {
}
String DirAccessPack::get_next() {
-
if (list_dirs.size()) {
cdir = true;
String d = list_dirs.front()->get();
@@ -380,31 +354,29 @@ String DirAccessPack::get_next() {
return String();
}
}
-bool DirAccessPack::current_is_dir() const {
+bool DirAccessPack::current_is_dir() const {
return cdir;
}
-bool DirAccessPack::current_is_hidden() const {
+bool DirAccessPack::current_is_hidden() const {
return false;
}
-void DirAccessPack::list_dir_end() {
+void DirAccessPack::list_dir_end() {
list_dirs.clear();
list_files.clear();
}
int DirAccessPack::get_drive_count() {
-
return 0;
}
-String DirAccessPack::get_drive(int p_drive) {
+String DirAccessPack::get_drive(int p_drive) {
return "";
}
Error DirAccessPack::change_dir(String p_dir) {
-
String nd = p_dir.replace("\\", "/");
bool absolute = false;
if (nd.begins_with("res://")) {
@@ -414,8 +386,9 @@ Error DirAccessPack::change_dir(String p_dir) {
nd = nd.simplify_path();
- if (nd == "")
+ if (nd == "") {
nd = ".";
+ }
if (nd.begins_with("/")) {
nd = nd.replace_first("/", "");
@@ -426,13 +399,13 @@ Error DirAccessPack::change_dir(String p_dir) {
PackedData::PackedDir *pd;
- if (absolute)
+ if (absolute) {
pd = PackedData::get_singleton()->root;
- else
+ } else {
pd = current;
+ }
for (int i = 0; i < paths.size(); i++) {
-
String p = paths[i];
if (p == ".") {
continue;
@@ -441,11 +414,9 @@ Error DirAccessPack::change_dir(String p_dir) {
pd = pd->parent;
}
} else if (pd->subdirs.has(p)) {
-
pd = pd->subdirs[p];
} else {
-
return ERR_INVALID_PARAMETER;
}
}
@@ -456,7 +427,6 @@ Error DirAccessPack::change_dir(String p_dir) {
}
String DirAccessPack::get_current_dir(bool p_include_drive) {
-
PackedData::PackedDir *pd = current;
String p = current->name;
@@ -469,35 +439,30 @@ String DirAccessPack::get_current_dir(bool p_include_drive) {
}
bool DirAccessPack::file_exists(String p_file) {
-
p_file = fix_path(p_file);
return current->files.has(p_file);
}
bool DirAccessPack::dir_exists(String p_dir) {
-
p_dir = fix_path(p_dir);
return current->subdirs.has(p_dir);
}
Error DirAccessPack::make_dir(String p_dir) {
-
return ERR_UNAVAILABLE;
}
Error DirAccessPack::rename(String p_from, String p_to) {
-
return ERR_UNAVAILABLE;
}
-Error DirAccessPack::remove(String p_name) {
+Error DirAccessPack::remove(String p_name) {
return ERR_UNAVAILABLE;
}
size_t DirAccessPack::get_space_left() {
-
return 0;
}
@@ -506,10 +471,5 @@ String DirAccessPack::get_filesystem_type() const {
}
DirAccessPack::DirAccessPack() {
-
current = PackedData::get_singleton()->root;
- cdir = false;
-}
-
-DirAccessPack::~DirAccessPack() {
}
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index 8df6826ac9..348bc0c450 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -51,7 +51,6 @@ class PackedData {
public:
struct PackedFile {
-
String pack;
uint64_t offset; //if offset is ZERO, the file was ERASED
uint64_t size;
@@ -61,17 +60,16 @@ public:
private:
struct PackedDir {
- PackedDir *parent;
+ PackedDir *parent = nullptr;
String name;
Map<String, PackedDir *> subdirs;
Set<String> files;
};
struct PathMD5 {
- uint64_t a;
- uint64_t b;
+ uint64_t a = 0;
+ uint64_t b = 0;
bool operator<(const PathMD5 &p_md5) const {
-
if (p_md5.a == a) {
return b < p_md5.b;
} else {
@@ -81,16 +79,14 @@ private:
bool operator==(const PathMD5 &p_md5) const {
return a == p_md5.a && b == p_md5.b;
- };
+ }
- PathMD5() {
- a = b = 0;
- };
+ PathMD5() {}
PathMD5(const Vector<uint8_t> p_buf) {
a = *((uint64_t *)&p_buf[0]);
b = *((uint64_t *)&p_buf[8]);
- };
+ }
};
Map<PathMD5, PackedFile> files;
@@ -98,10 +94,9 @@ private:
Vector<PackSource *> sources;
PackedDir *root;
- //Map<String,PackedDir*> dirs;
static PackedData *singleton;
- bool disabled;
+ bool disabled = false;
void _free_packed_dirs(PackedDir *p_dir);
@@ -123,7 +118,6 @@ public:
};
class PackSource {
-
public:
virtual bool try_open_pack(const String &p_path, bool p_replace_files) = 0;
virtual FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file) = 0;
@@ -131,14 +125,12 @@ public:
};
class PackedSourcePCK : public PackSource {
-
public:
virtual bool try_open_pack(const String &p_path, bool p_replace_files);
virtual FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file);
};
class FileAccessPack : public FileAccess {
-
PackedData::PackedFile pf;
mutable size_t pos;
@@ -181,29 +173,28 @@ public:
};
FileAccess *PackedData::try_open_path(const String &p_path) {
-
PathMD5 pmd5(p_path.md5_buffer());
Map<PathMD5, PackedFile>::Element *E = files.find(pmd5);
- if (!E)
+ if (!E) {
return nullptr; //not found
- if (E->get().offset == 0)
+ }
+ if (E->get().offset == 0) {
return nullptr; //was erased
+ }
return E->get().src->get_file(p_path, &E->get());
}
bool PackedData::has_path(const String &p_path) {
-
return files.has(PathMD5(p_path.md5_buffer()));
}
class DirAccessPack : public DirAccess {
-
PackedData::PackedDir *current;
List<String> list_dirs;
List<String> list_files;
- bool cdir;
+ bool cdir = false;
public:
virtual Error list_dir_begin();
@@ -231,7 +222,7 @@ public:
virtual String get_filesystem_type() const;
DirAccessPack();
- ~DirAccessPack();
+ ~DirAccessPack() {}
};
#endif // FILE_ACCESS_PACK_H
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index 57de66afaf..c3a62706c7 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -40,7 +40,6 @@ ZipArchive *ZipArchive::instance = nullptr;
extern "C" {
static void *godot_open(void *data, const char *p_fname, int mode) {
-
if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
return nullptr;
}
@@ -52,30 +51,25 @@ static void *godot_open(void *data, const char *p_fname, int mode) {
}
static uLong godot_read(void *data, void *fdata, void *buf, uLong size) {
-
FileAccess *f = (FileAccess *)data;
f->get_buffer((uint8_t *)buf, size);
return size;
}
static uLong godot_write(voidpf opaque, voidpf stream, const void *buf, uLong size) {
-
return 0;
}
static long godot_tell(voidpf opaque, voidpf stream) {
-
FileAccess *f = (FileAccess *)opaque;
return f->get_position();
}
static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
-
FileAccess *f = (FileAccess *)opaque;
int pos = offset;
switch (origin) {
-
case ZLIB_FILEFUNC_SEEK_CUR:
pos = f->get_position() + offset;
break;
@@ -91,32 +85,27 @@ static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
}
static int godot_close(voidpf opaque, voidpf stream) {
-
FileAccess *f = (FileAccess *)opaque;
f->close();
return 0;
}
static int godot_testerror(voidpf opaque, voidpf stream) {
-
FileAccess *f = (FileAccess *)opaque;
return f->get_error() != OK ? 1 : 0;
}
static voidpf godot_alloc(voidpf opaque, uInt items, uInt size) {
-
return memalloc(items * size);
}
static void godot_free(voidpf opaque, voidpf address) {
-
memfree(address);
}
} // extern "C"
void ZipArchive::close_handle(unzFile p_file) const {
-
ERR_FAIL_COND_MSG(!p_file, "Cannot close a file if none is open.");
FileAccess *f = (FileAccess *)unzGetOpaque(p_file);
unzCloseCurrentFile(p_file);
@@ -125,7 +114,6 @@ void ZipArchive::close_handle(unzFile p_file) const {
}
unzFile ZipArchive::get_file_handle(String p_file) const {
-
ERR_FAIL_COND_V_MSG(!file_exists(p_file), nullptr, "File '" + p_file + " doesn't exist.");
File file = files[p_file];
@@ -152,7 +140,6 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
ERR_FAIL_COND_V(!pkg, nullptr);
int unz_err = unzGoToFilePos(pkg, &file.file_pos);
if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) {
-
unzClose(pkg);
ERR_FAIL_V(nullptr);
}
@@ -161,16 +148,17 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
}
bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
-
//printf("opening zip pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
- if (p_path.get_extension().nocasecmp_to("zip") != 0 && p_path.get_extension().nocasecmp_to("pcz") != 0)
+ if (p_path.get_extension().nocasecmp_to("zip") != 0 && p_path.get_extension().nocasecmp_to("pcz") != 0) {
return false;
+ }
zlib_filefunc_def io;
FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
- if (!fa)
+ if (!fa) {
return false;
+ }
io.opaque = fa;
io.zopen_file = godot_open;
io.zread_file = godot_read;
@@ -195,7 +183,6 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
int pkg_num = packages.size() - 1;
for (uint64_t i = 0; i < gi.number_entry; i++) {
-
char filename_inzip[256];
unz_file_info64 file_info;
@@ -222,17 +209,14 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) {
}
bool ZipArchive::file_exists(String p_name) const {
-
return files.has(p_name);
}
FileAccess *ZipArchive::get_file(const String &p_path, PackedData::PackedFile *p_file) {
-
return memnew(FileAccessZip(p_path, *p_file));
}
ZipArchive *ZipArchive::get_singleton() {
-
if (instance == nullptr) {
instance = memnew(ZipArchive);
}
@@ -241,15 +225,11 @@ ZipArchive *ZipArchive::get_singleton() {
}
ZipArchive::ZipArchive() {
-
instance = this;
- //fa_create_func = FileAccess::get_create_func();
}
ZipArchive::~ZipArchive() {
-
for (int i = 0; i < packages.size(); i++) {
-
FileAccess *f = (FileAccess *)unzGetOpaque(packages[i].zfile);
unzClose(packages[i].zfile);
memdelete(f);
@@ -259,7 +239,6 @@ ZipArchive::~ZipArchive() {
}
Error FileAccessZip::_open(const String &p_path, int p_mode_flags) {
-
close();
ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, FAILED);
@@ -275,9 +254,9 @@ Error FileAccessZip::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessZip::close() {
-
- if (!zfile)
+ if (!zfile) {
return;
+ }
ZipArchive *arch = ZipArchive::get_singleton();
ERR_FAIL_COND(!arch);
@@ -286,65 +265,57 @@ void FileAccessZip::close() {
}
bool FileAccessZip::is_open() const {
-
return zfile != nullptr;
}
void FileAccessZip::seek(size_t p_position) {
-
ERR_FAIL_COND(!zfile);
unzSeekCurrentFile(zfile, p_position);
}
void FileAccessZip::seek_end(int64_t p_position) {
-
ERR_FAIL_COND(!zfile);
unzSeekCurrentFile(zfile, get_len() + p_position);
}
size_t FileAccessZip::get_position() const {
-
ERR_FAIL_COND_V(!zfile, 0);
return unztell(zfile);
}
size_t FileAccessZip::get_len() const {
-
ERR_FAIL_COND_V(!zfile, 0);
return file_info.uncompressed_size;
}
bool FileAccessZip::eof_reached() const {
-
ERR_FAIL_COND_V(!zfile, true);
return at_eof;
}
uint8_t FileAccessZip::get_8() const {
-
uint8_t ret = 0;
get_buffer(&ret, 1);
return ret;
}
int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V(!zfile, -1);
at_eof = unzeof(zfile);
- if (at_eof)
+ if (at_eof) {
return 0;
+ }
int read = unzReadCurrentFile(zfile, p_dst, p_length);
ERR_FAIL_COND_V(read < 0, read);
- if (read < p_length)
+ if (read < p_length) {
at_eof = true;
+ }
return read;
}
Error FileAccessZip::get_error() const {
-
if (!zfile) {
-
return ERR_UNCONFIGURED;
}
if (eof_reached()) {
@@ -355,28 +326,23 @@ Error FileAccessZip::get_error() const {
}
void FileAccessZip::flush() {
-
ERR_FAIL();
}
void FileAccessZip::store_8(uint8_t p_dest) {
-
ERR_FAIL();
}
bool FileAccessZip::file_exists(const String &p_name) {
-
return false;
}
-FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) :
- zfile(nullptr) {
+FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) {
_open(p_path, FileAccess::READ);
}
FileAccessZip::~FileAccessZip() {
-
close();
}
-#endif
+#endif // MINIZIP_ENABLED
diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h
index d5ce7d7a8d..776e830f36 100644
--- a/core/io/file_access_zip.h
+++ b/core/io/file_access_zip.h
@@ -41,22 +41,17 @@
#include <stdlib.h>
class ZipArchive : public PackSource {
-
public:
struct File {
-
- int package;
+ int package = -1;
unz_file_pos file_pos;
- File() {
-
- package = -1;
- };
+ File() {}
};
private:
struct Package {
String filename;
- unzFile zfile;
+ unzFile zfile = nullptr;
};
Vector<Package> packages;
@@ -84,7 +79,6 @@ public:
};
class FileAccessZip : public FileAccess {
-
unzFile zfile;
unz_file_info64 file_info;
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 56f8f1ff91..40debae9e5 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -47,7 +47,6 @@ const char *HTTPClient::_methods[METHOD_MAX] = {
#ifndef JAVASCRIPT_ENABLED
Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
-
close();
conn_port = p_port;
@@ -58,10 +57,8 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
String host_lower = conn_host.to_lower();
if (host_lower.begins_with("http://")) {
-
conn_host = conn_host.substr(7, conn_host.length() - 7);
} else if (host_lower.begins_with("https://")) {
-
ssl = true;
conn_host = conn_host.substr(8, conn_host.length() - 8);
}
@@ -97,7 +94,6 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
}
void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
-
ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
close();
@@ -106,12 +102,10 @@ void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
}
Ref<StreamPeer> HTTPClient::get_connection() const {
-
return connection;
}
Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
-
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
@@ -179,7 +173,6 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
}
Error HTTPClient::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) {
-
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
@@ -235,27 +228,23 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str
}
bool HTTPClient::has_response() const {
-
return response_headers.size() != 0;
}
bool HTTPClient::is_response_chunked() const {
-
return chunked;
}
int HTTPClient::get_response_code() const {
-
return response_num;
}
Error HTTPClient::get_response_headers(List<String> *r_response) {
-
- if (!response_headers.size())
+ if (!response_headers.size()) {
return ERR_INVALID_PARAMETER;
+ }
for (int i = 0; i < response_headers.size(); i++) {
-
r_response->push_back(response_headers[i]);
}
@@ -265,15 +254,14 @@ Error HTTPClient::get_response_headers(List<String> *r_response) {
}
void HTTPClient::close() {
-
- if (tcp_connection->get_status() != StreamPeerTCP::STATUS_NONE)
+ if (tcp_connection->get_status() != StreamPeerTCP::STATUS_NONE) {
tcp_connection->disconnect_from_host();
+ }
connection.unref();
status = STATUS_DISCONNECTED;
head_request = false;
if (resolving != IP::RESOLVER_INVALID_ID) {
-
IP::get_singleton()->erase_resolve_item(resolving);
resolving = IP::RESOLVER_INVALID_ID;
}
@@ -283,16 +271,14 @@ void HTTPClient::close() {
body_size = -1;
body_left = 0;
chunk_left = 0;
- chunk_trailer_part = 0;
+ chunk_trailer_part = false;
read_until_eof = false;
response_num = 0;
handshaking = false;
}
Error HTTPClient::poll() {
-
switch (status) {
-
case STATUS_RESOLVING: {
ERR_FAIL_COND_V(resolving == IP::RESOLVER_INVALID_ID, ERR_BUG);
@@ -302,7 +288,6 @@ Error HTTPClient::poll() {
return OK; // Still resolving
case IP::RESOLVER_STATUS_DONE: {
-
IP_Address host = IP::get_singleton()->get_resolve_item_address(resolving);
Error err = tcp_connection->connect_to_host(host, conn_port);
IP::get_singleton()->erase_resolve_item(resolving);
@@ -316,7 +301,6 @@ Error HTTPClient::poll() {
} break;
case IP::RESOLVER_STATUS_NONE:
case IP::RESOLVER_STATUS_ERROR: {
-
IP::get_singleton()->erase_resolve_item(resolving);
resolving = IP::RESOLVER_INVALID_ID;
close();
@@ -326,10 +310,8 @@ Error HTTPClient::poll() {
}
} break;
case STATUS_CONNECTING: {
-
StreamPeerTCP::Status s = tcp_connection->get_status();
switch (s) {
-
case StreamPeerTCP::STATUS_CONNECTING: {
return OK;
} break;
@@ -379,7 +361,6 @@ Error HTTPClient::poll() {
} break;
case StreamPeerTCP::STATUS_ERROR:
case StreamPeerTCP::STATUS_NONE: {
-
close();
status = STATUS_CANT_CONNECT;
return ERR_CANT_CONNECT;
@@ -404,7 +385,6 @@ Error HTTPClient::poll() {
return OK;
} break;
case STATUS_REQUESTING: {
-
while (true) {
uint8_t byte;
int rec = 0;
@@ -415,15 +395,15 @@ Error HTTPClient::poll() {
return ERR_CONNECTION_ERROR;
}
- if (rec == 0)
+ if (rec == 0) {
return OK; // Still requesting, keep trying!
+ }
response_str.push_back(byte);
int rs = response_str.size();
if (
(rs >= 2 && response_str[rs - 2] == '\n' && response_str[rs - 1] == '\n') ||
(rs >= 4 && response_str[rs - 4] == '\r' && response_str[rs - 3] == '\n' && response_str[rs - 2] == '\r' && response_str[rs - 1] == '\n')) {
-
// End of response, parse.
response_str.push_back(0);
String response;
@@ -445,11 +425,11 @@ Error HTTPClient::poll() {
bool keep_alive = true;
for (int i = 0; i < responses.size(); i++) {
-
String header = responses[i].strip_edges();
String s = header.to_lower();
- if (s.length() == 0)
+ if (s.length() == 0) {
continue;
+ }
if (s.begins_with("content-length:")) {
body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int();
body_left = body_size;
@@ -464,11 +444,9 @@ Error HTTPClient::poll() {
}
if (i == 0 && responses[i].begins_with("HTTP")) {
-
String num = responses[i].get_slicec(' ', 1);
response_num = num.to_int();
} else {
-
response_headers.push_back(header);
}
}
@@ -480,14 +458,11 @@ Error HTTPClient::poll() {
}
if (body_size != -1 || chunked) {
-
status = STATUS_BODY;
} else if (!keep_alive) {
-
read_until_eof = true;
status = STATUS_BODY;
} else {
-
status = STATUS_CONNECTED;
}
return OK;
@@ -513,29 +488,26 @@ Error HTTPClient::poll() {
}
int HTTPClient::get_response_body_length() const {
-
return body_size;
}
PackedByteArray HTTPClient::read_response_body_chunk() {
-
ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
PackedByteArray ret;
Error err = OK;
if (chunked) {
-
while (true) {
-
if (chunk_trailer_part) {
// We need to consume the trailer part too or keep-alive will break
uint8_t b;
int rec = 0;
err = _get_http_data(&b, 1, rec);
- if (rec == 0)
+ if (rec == 0) {
break;
+ }
chunk.push_back(b);
int cs = chunk.size();
@@ -557,8 +529,9 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
int rec = 0;
err = _get_http_data(&b, 1, rec);
- if (rec == 0)
+ if (rec == 0) {
break;
+ }
chunk.push_back(b);
@@ -569,18 +542,17 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
}
if (chunk.size() > 2 && chunk[chunk.size() - 2] == '\r' && chunk[chunk.size() - 1] == '\n') {
-
int len = 0;
for (int i = 0; i < chunk.size() - 2; i++) {
char c = chunk[i];
int v = 0;
- if (c >= '0' && c <= '9')
+ if (c >= '0' && c <= '9') {
v = c - '0';
- else if (c >= 'a' && c <= 'f')
+ } else if (c >= 'a' && c <= 'f') {
v = c - 'a' + 10;
- else if (c >= 'A' && c <= 'F')
+ } else if (c >= 'A' && c <= 'F') {
v = c - 'A' + 10;
- else {
+ } else {
ERR_PRINT("HTTP Chunk len not in hex!!");
status = STATUS_CONNECTION_ERROR;
break;
@@ -605,7 +577,6 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
chunk.resize(chunk_left);
}
} else {
-
int rec = 0;
err = _get_http_data(&chunk.write[chunk.size() - chunk_left], chunk_left, rec);
if (rec == 0) {
@@ -614,7 +585,6 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
chunk_left -= rec;
if (chunk_left == 0) {
-
if (chunk[chunk.size() - 2] != '\r' || chunk[chunk.size() - 1] != '\n') {
ERR_PRINT("HTTP Invalid chunk terminator (not \\r\\n)");
status = STATUS_CONNECTION_ERROR;
@@ -632,7 +602,6 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
}
} else {
-
int to_read = !read_until_eof ? MIN(body_left, read_chunk_size) : read_chunk_size;
ret.resize(to_read);
int _offset = 0;
@@ -652,24 +621,21 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
body_left -= rec;
}
}
- if (err != OK)
+ if (err != OK) {
break;
+ }
}
}
if (err != OK) {
-
close();
if (err == ERR_FILE_EOF) {
-
status = STATUS_DISCONNECTED; // Server disconnected
} else {
-
status = STATUS_CONNECTION_ERROR;
}
} else if (body_left == 0 && !chunked && !read_until_eof) {
-
status = STATUS_CONNECTED;
}
@@ -677,24 +643,19 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
}
HTTPClient::Status HTTPClient::get_status() const {
-
return status;
}
void HTTPClient::set_blocking_mode(bool p_enable) {
-
blocking = p_enable;
}
bool HTTPClient::is_blocking_mode_enabled() const {
-
return blocking;
}
Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
if (blocking) {
-
// We can't use StreamPeer.get_data, since when reaching EOF we will get an
// error without knowing how many bytes we received.
Error err = ERR_FILE_EOF;
@@ -729,27 +690,10 @@ int HTTPClient::get_read_chunk_size() const {
}
HTTPClient::HTTPClient() {
-
tcp_connection.instance();
- resolving = IP::RESOLVER_INVALID_ID;
- status = STATUS_DISCONNECTED;
- head_request = false;
- conn_port = -1;
- body_size = -1;
- chunked = false;
- body_left = 0;
- read_until_eof = false;
- chunk_left = 0;
- chunk_trailer_part = false;
- response_num = 0;
- ssl = false;
- blocking = false;
- handshaking = false;
- read_chunk_size = 4096;
}
-HTTPClient::~HTTPClient() {
-}
+HTTPClient::~HTTPClient() {}
#endif // #ifndef JAVASCRIPT_ENABLED
@@ -784,15 +728,15 @@ String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
}
Dictionary HTTPClient::_get_response_headers_as_dictionary() {
-
List<String> rh;
get_response_headers(&rh);
Dictionary ret;
for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
const String &s = E->get();
int sp = s.find(":");
- if (sp == -1)
+ if (sp == -1) {
continue;
+ }
String key = s.substr(0, sp).strip_edges();
String value = s.substr(sp + 1, s.length()).strip_edges();
ret[key] = value;
@@ -802,7 +746,6 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() {
}
PackedStringArray HTTPClient::_get_response_headers() {
-
List<String> rh;
get_response_headers(&rh);
PackedStringArray ret;
@@ -816,7 +759,6 @@ PackedStringArray HTTPClient::_get_response_headers() {
}
void HTTPClient::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(-1), DEFVAL(false), DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_connection", "connection"), &HTTPClient::set_connection);
ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection);
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 03ba20f8dd..1dc1f3d76a 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -37,7 +37,6 @@
#include "core/reference.h"
class HTTPClient : public Reference {
-
GDCLASS(HTTPClient, Reference);
public:
@@ -158,32 +157,32 @@ private:
};
#ifndef JAVASCRIPT_ENABLED
- Status status;
- IP::ResolverID resolving;
- int conn_port;
+ Status status = STATUS_DISCONNECTED;
+ IP::ResolverID resolving = IP::RESOLVER_INVALID_ID;
+ int conn_port = -1;
String conn_host;
- bool ssl;
- bool ssl_verify_host;
- bool blocking;
- bool handshaking;
- bool head_request;
+ bool ssl = false;
+ bool ssl_verify_host = false;
+ bool blocking = false;
+ bool handshaking = false;
+ bool head_request = false;
Vector<uint8_t> response_str;
- bool chunked;
+ bool chunked = false;
Vector<uint8_t> chunk;
- int chunk_left;
- bool chunk_trailer_part;
- int body_size;
- int body_left;
- bool read_until_eof;
+ int chunk_left = 0;
+ bool chunk_trailer_part = false;
+ int body_size = -1;
+ int body_left = 0;
+ bool read_until_eof = false;
Ref<StreamPeerTCP> tcp_connection;
Ref<StreamPeer> connection;
- int response_num;
+ int response_num = 0;
Vector<String> response_headers;
- int read_chunk_size;
+ int read_chunk_size = 4096;
Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index 01e6bb5618..b1e92eb87f 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -33,13 +33,12 @@
#include "core/print_string.h"
bool ImageFormatLoader::recognize(const String &p_extension) const {
-
List<String> extensions;
get_recognized_extensions(&extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
- if (E->get().nocasecmp_to(p_extension) == 0)
+ if (E->get().nocasecmp_to(p_extension) == 0) {
return true;
+ }
}
return false;
@@ -61,43 +60,41 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
String extension = p_file.get_extension();
for (int i = 0; i < loader.size(); i++) {
-
- if (!loader[i]->recognize(extension))
+ if (!loader[i]->recognize(extension)) {
continue;
+ }
Error err = loader[i]->load_image(p_image, f, p_force_linear, p_scale);
if (err != OK) {
ERR_PRINT("Error loading image: " + p_file);
}
if (err != ERR_FILE_UNRECOGNIZED) {
-
- if (!p_custom)
+ if (!p_custom) {
memdelete(f);
+ }
return err;
}
}
- if (!p_custom)
+ if (!p_custom) {
memdelete(f);
+ }
return ERR_FILE_UNRECOGNIZED;
}
void ImageLoader::get_recognized_extensions(List<String> *p_extensions) {
-
for (int i = 0; i < loader.size(); i++) {
-
loader[i]->get_recognized_extensions(p_extensions);
}
}
ImageFormatLoader *ImageLoader::recognize(const String &p_extension) {
-
for (int i = 0; i < loader.size(); i++) {
-
- if (loader[i]->recognize(p_extension))
+ if (loader[i]->recognize(p_extension)) {
return loader[i];
+ }
}
return nullptr;
@@ -106,22 +103,18 @@ ImageFormatLoader *ImageLoader::recognize(const String &p_extension) {
Vector<ImageFormatLoader *> ImageLoader::loader;
void ImageLoader::add_image_format_loader(ImageFormatLoader *p_loader) {
-
loader.push_back(p_loader);
}
void ImageLoader::remove_image_format_loader(ImageFormatLoader *p_loader) {
-
loader.erase(p_loader);
}
const Vector<ImageFormatLoader *> &ImageLoader::get_image_format_loaders() {
-
return loader;
}
void ImageLoader::cleanup() {
-
while (loader.size()) {
remove_image_format_loader(loader[0]);
}
@@ -130,7 +123,6 @@ void ImageLoader::cleanup() {
/////////////////
RES ResourceFormatLoaderImage::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) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
if (r_error) {
@@ -192,16 +184,13 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_origin
}
void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("image");
}
bool ResourceFormatLoaderImage::handles_type(const String &p_type) const {
-
return p_type == "Image";
}
String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const {
-
return p_path.get_extension().to_lower() == "image" ? "Image" : String();
}
diff --git a/core/io/image_loader.h b/core/io/image_loader.h
index 15ce6031d7..9682f144c7 100644
--- a/core/io/image_loader.h
+++ b/core/io/image_loader.h
@@ -53,7 +53,6 @@ public:
};
class ImageLoader {
-
static Vector<ImageFormatLoader *> loader;
friend class ResourceFormatLoaderImage;
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 5de7fb7186..24b8ec7cc1 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -39,9 +39,7 @@ VARIANT_ENUM_CAST(IP::ResolverStatus);
/************* RESOLVER ******************/
struct _IP_ResolverPrivate {
-
struct QueueItem {
-
volatile IP::ResolverStatus status;
IP_Address response;
String hostname;
@@ -56,16 +54,16 @@ struct _IP_ResolverPrivate {
QueueItem() {
clear();
- };
+ }
};
QueueItem queue[IP::RESOLVER_MAX_QUERIES];
IP::ResolverID find_empty_id() const {
-
for (int i = 0; i < IP::RESOLVER_MAX_QUERIES; i++) {
- if (queue[i].status == IP::RESOLVER_STATUS_NONE)
+ if (queue[i].status == IP::RESOLVER_STATUS_NONE) {
return i;
+ }
}
return IP::RESOLVER_INVALID_ID;
}
@@ -78,26 +76,24 @@ struct _IP_ResolverPrivate {
bool thread_abort;
void resolve_queues() {
-
for (int i = 0; i < IP::RESOLVER_MAX_QUERIES; i++) {
-
- if (queue[i].status != IP::RESOLVER_STATUS_WAITING)
+ if (queue[i].status != IP::RESOLVER_STATUS_WAITING) {
continue;
+ }
queue[i].response = IP::get_singleton()->resolve_hostname(queue[i].hostname, queue[i].type);
- if (!queue[i].response.is_valid())
+ if (!queue[i].response.is_valid()) {
queue[i].status = IP::RESOLVER_STATUS_ERROR;
- else
+ } else {
queue[i].status = IP::RESOLVER_STATUS_DONE;
+ }
}
}
static void _thread_function(void *self) {
-
_IP_ResolverPrivate *ipr = (_IP_ResolverPrivate *)self;
while (!ipr->thread_abort) {
-
ipr->sem.wait();
MutexLock lock(ipr->mutex);
@@ -113,7 +109,6 @@ struct _IP_ResolverPrivate {
};
IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
-
MutexLock lock(resolver->mutex);
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
@@ -128,7 +123,6 @@ IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
}
IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Type p_type) {
-
MutexLock lock(resolver->mutex);
ResolverID id = resolver->find_empty_id();
@@ -147,17 +141,17 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
} else {
resolver->queue[id].response = IP_Address();
resolver->queue[id].status = IP::RESOLVER_STATUS_WAITING;
- if (resolver->thread)
+ if (resolver->thread) {
resolver->sem.post();
- else
+ } else {
resolver->resolve_queues();
+ }
}
return id;
}
IP::ResolverStatus IP::get_resolve_item_status(ResolverID p_id) const {
-
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP::RESOLVER_STATUS_NONE);
MutexLock lock(resolver->mutex);
@@ -171,7 +165,6 @@ IP::ResolverStatus IP::get_resolve_item_status(ResolverID p_id) const {
}
IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
-
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP_Address());
MutexLock lock(resolver->mutex);
@@ -186,7 +179,6 @@ IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
}
void IP::erase_resolve_item(ResolverID p_id) {
-
ERR_FAIL_INDEX(p_id, IP::RESOLVER_MAX_QUERIES);
MutexLock lock(resolver->mutex);
@@ -195,7 +187,6 @@ void IP::erase_resolve_item(ResolverID p_id) {
}
void IP::clear_cache(const String &p_hostname) {
-
MutexLock lock(resolver->mutex);
if (p_hostname.empty()) {
@@ -209,7 +200,6 @@ void IP::clear_cache(const String &p_hostname) {
}
Array IP::_get_local_addresses() const {
-
Array addresses;
List<IP_Address> ip_addresses;
get_local_addresses(&ip_addresses);
@@ -221,7 +211,6 @@ Array IP::_get_local_addresses() const {
}
Array IP::_get_local_interfaces() const {
-
Array results;
Map<String, Interface_Info> interfaces;
get_local_interfaces(&interfaces);
@@ -245,7 +234,6 @@ Array IP::_get_local_interfaces() const {
}
void IP::get_local_addresses(List<IP_Address> *r_addresses) const {
-
Map<String, Interface_Info> interfaces;
get_local_interfaces(&interfaces);
for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) {
@@ -256,7 +244,6 @@ void IP::get_local_addresses(List<IP_Address> *r_addresses) const {
}
void IP::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("resolve_hostname", "host", "ip_type"), &IP::resolve_hostname, DEFVAL(IP::TYPE_ANY));
ClassDB::bind_method(D_METHOD("resolve_hostname_queue_item", "host", "ip_type"), &IP::resolve_hostname_queue_item, DEFVAL(IP::TYPE_ANY));
ClassDB::bind_method(D_METHOD("get_resolve_item_status", "id"), &IP::get_resolve_item_status);
@@ -283,21 +270,18 @@ void IP::_bind_methods() {
IP *IP::singleton = nullptr;
IP *IP::get_singleton() {
-
return singleton;
}
IP *(*IP::_create)() = nullptr;
IP *IP::create() {
-
ERR_FAIL_COND_V_MSG(singleton, nullptr, "IP singleton already exist.");
ERR_FAIL_COND_V(!_create, nullptr);
return _create();
}
IP::IP() {
-
singleton = this;
resolver = memnew(_IP_ResolverPrivate);
@@ -312,7 +296,6 @@ IP::IP() {
}
IP::~IP() {
-
#ifndef NO_THREADS
if (resolver->thread) {
resolver->thread_abort = true;
diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp
index f5fd8ae205..c7a0ae5605 100644
--- a/core/io/ip_address.cpp
+++ b/core/io/ip_address.cpp
@@ -39,40 +39,40 @@ IP_Address::operator Variant() const {
#include <string.h>
IP_Address::operator String() const {
-
- if (wildcard)
+ if (wildcard) {
return "*";
+ }
- if (!valid)
+ if (!valid) {
return "";
+ }
- if (is_ipv4())
+ if (is_ipv4()) {
// IPv4 address mapped to IPv6
return itos(field8[12]) + "." + itos(field8[13]) + "." + itos(field8[14]) + "." + itos(field8[15]);
+ }
String ret;
for (int i = 0; i < 8; i++) {
- if (i > 0)
+ if (i > 0) {
ret = ret + ":";
+ }
uint16_t num = (field8[i * 2] << 8) + field8[i * 2 + 1];
ret = ret + String::num_int64(num, 16);
- };
+ }
return ret;
}
static void _parse_hex(const String &p_string, int p_start, uint8_t *p_dst) {
-
uint16_t ret = 0;
for (int i = p_start; i < p_start + 4; i++) {
-
if (i >= p_string.length()) {
break;
- };
+ }
int n = 0;
CharType c = p_string[i];
if (c >= '0' && c <= '9') {
-
n = c - '0';
} else if (c >= 'a' && c <= 'f') {
n = 10 + (c - 'a');
@@ -82,17 +82,16 @@ static void _parse_hex(const String &p_string, int p_start, uint8_t *p_dst) {
break;
} else {
ERR_FAIL_MSG("Invalid character in IPv6 address: " + p_string + ".");
- };
+ }
ret = ret << 4;
ret += n;
- };
+ }
p_dst[0] = ret >> 8;
p_dst[1] = ret & 0xff;
-};
+}
void IP_Address::_parse_ipv6(const String &p_string) {
-
static const int parts_total = 8;
int parts[parts_total] = { 0 };
int parts_count = 0;
@@ -102,20 +101,17 @@ void IP_Address::_parse_ipv6(const String &p_string) {
int parts_idx = 0;
for (int i = 0; i < p_string.length(); i++) {
-
CharType c = p_string[i];
if (c == ':') {
-
if (i == 0) {
continue; // next must be a ":"
- };
+ }
if (!part_found) {
part_skip = true;
parts[parts_idx++] = -1;
- };
+ }
part_found = false;
} else if (c == '.') {
-
part_ipv4 = true;
} else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
@@ -123,58 +119,54 @@ void IP_Address::_parse_ipv6(const String &p_string) {
parts[parts_idx++] = i;
part_found = true;
++parts_count;
- };
+ }
} else {
ERR_FAIL_MSG("Invalid character in IPv6 address: " + p_string + ".");
- };
- };
+ }
+ }
int parts_extra = 0;
if (part_skip) {
parts_extra = parts_total - parts_count;
- };
+ }
int idx = 0;
for (int i = 0; i < parts_idx; i++) {
-
if (parts[i] == -1) {
-
for (int j = 0; j < parts_extra; j++) {
field16[idx++] = 0;
- };
+ }
continue;
- };
+ }
if (part_ipv4 && i == parts_idx - 1) {
_parse_ipv4(p_string, parts[i], (uint8_t *)&field16[idx]); // should be the last one
} else {
_parse_hex(p_string, parts[i], (uint8_t *)&(field16[idx++]));
- };
- };
-};
+ }
+ }
+}
void IP_Address::_parse_ipv4(const String &p_string, int p_start, uint8_t *p_ret) {
-
String ip;
if (p_start != 0) {
ip = p_string.substr(p_start, p_string.length() - p_start);
} else {
ip = p_string;
- };
+ }
int slices = ip.get_slice_count(".");
ERR_FAIL_COND_MSG(slices != 4, "Invalid IP address string: " + ip + ".");
for (int i = 0; i < 4; i++) {
p_ret[i] = ip.get_slicec('.', i).to_int();
}
-};
+}
void IP_Address::clear() {
-
memset(&field8[0], 0, sizeof(field8));
valid = false;
wildcard = false;
-};
+}
bool IP_Address::is_ipv4() const {
return (field32[0] == 0 && field32[1] == 0 && field16[4] == 0 && field16[5] == 0xffff);
@@ -199,12 +191,12 @@ const uint8_t *IP_Address::get_ipv6() const {
void IP_Address::set_ipv6(const uint8_t *p_buf) {
clear();
valid = true;
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
field8[i] = p_buf[i];
+ }
}
IP_Address::IP_Address(const String &p_string) {
-
clear();
if (p_string == "*") {
@@ -228,15 +220,13 @@ IP_Address::IP_Address(const String &p_string) {
}
_FORCE_INLINE_ static void _32_to_buf(uint8_t *p_dst, uint32_t p_n) {
-
p_dst[0] = (p_n >> 24) & 0xff;
p_dst[1] = (p_n >> 16) & 0xff;
p_dst[2] = (p_n >> 8) & 0xff;
p_dst[3] = (p_n >> 0) & 0xff;
-};
+}
IP_Address::IP_Address(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, bool is_v6) {
-
clear();
valid = true;
if (!is_v6) {
@@ -247,7 +237,6 @@ IP_Address::IP_Address(uint32_t p_a, uint32_t p_b, uint32_t p_c, uint32_t p_d, b
field8[14] = p_c;
field8[15] = p_d;
} else {
-
_32_to_buf(&field8[0], p_a);
_32_to_buf(&field8[4], p_b);
_32_to_buf(&field8[8], p_c);
diff --git a/core/io/ip_address.h b/core/io/ip_address.h
index a59178063d..2f8f83503e 100644
--- a/core/io/ip_address.h
+++ b/core/io/ip_address.h
@@ -34,7 +34,6 @@
#include "core/ustring.h"
struct IP_Address {
-
private:
union {
uint8_t field8[16];
@@ -52,23 +51,32 @@ protected:
public:
//operator Variant() const;
bool operator==(const IP_Address &p_ip) const {
- if (p_ip.valid != valid)
+ if (p_ip.valid != valid) {
return false;
- if (!valid)
+ }
+ if (!valid) {
return false;
- for (int i = 0; i < 4; i++)
- if (field32[i] != p_ip.field32[i])
+ }
+ for (int i = 0; i < 4; i++) {
+ if (field32[i] != p_ip.field32[i]) {
return false;
+ }
+ }
return true;
}
+
bool operator!=(const IP_Address &p_ip) const {
- if (p_ip.valid != valid)
+ if (p_ip.valid != valid) {
return true;
- if (!valid)
+ }
+ if (!valid) {
return true;
- for (int i = 0; i < 4; i++)
- if (field32[i] != p_ip.field32[i])
+ }
+ for (int i = 0; i < 4; i++) {
+ if (field32[i] != p_ip.field32[i]) {
return true;
+ }
+ }
return false;
}
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 0186547dd2..1c603865ad 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -46,17 +46,16 @@ const char *JSON::tk_name[TK_MAX] = {
};
static String _make_indent(const String &p_indent, int p_size) {
-
String indent_text = "";
if (!p_indent.empty()) {
- for (int i = 0; i < p_size; i++)
+ for (int i = 0; i < p_size; i++) {
indent_text += p_indent;
+ }
}
return indent_text;
}
String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys) {
-
String colon = ":";
String end_statement = "";
@@ -66,7 +65,6 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
}
switch (p_var.get_type()) {
-
case Variant::NIL:
return "null";
case Variant::BOOL:
@@ -81,7 +79,6 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::ARRAY: {
-
String s = "[";
s += end_statement;
Array a = p_var;
@@ -94,20 +91,19 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
}
s += end_statement + _make_indent(p_indent, p_cur_indent) + "]";
return s;
- };
+ }
case Variant::DICTIONARY: {
-
String s = "{";
s += end_statement;
Dictionary d = p_var;
List<Variant> keys;
d.get_key_list(&keys);
- if (p_sort_keys)
+ if (p_sort_keys) {
keys.sort();
+ }
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
if (E != keys.front()) {
s += ",";
s += end_statement;
@@ -119,70 +115,59 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_
s += end_statement + _make_indent(p_indent, p_cur_indent) + "}";
return s;
- };
+ }
default:
return "\"" + String(p_var).json_escape() + "\"";
}
}
String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys) {
-
return _print_var(p_var, p_indent, 0, p_sort_keys);
}
Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) {
-
while (p_len > 0) {
switch (p_str[index]) {
-
case '\n': {
-
line++;
index++;
break;
- };
+ }
case 0: {
r_token.type = TK_EOF;
return OK;
} break;
case '{': {
-
r_token.type = TK_CURLY_BRACKET_OPEN;
index++;
return OK;
- };
+ }
case '}': {
-
r_token.type = TK_CURLY_BRACKET_CLOSE;
index++;
return OK;
- };
+ }
case '[': {
-
r_token.type = TK_BRACKET_OPEN;
index++;
return OK;
- };
+ }
case ']': {
-
r_token.type = TK_BRACKET_CLOSE;
index++;
return OK;
- };
+ }
case ':': {
-
r_token.type = TK_COLON;
index++;
return OK;
- };
+ }
case ',': {
-
r_token.type = TK_COMMA;
index++;
return OK;
- };
+ }
case '"': {
-
index++;
String str;
while (true) {
@@ -203,7 +188,6 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
CharType res = 0;
switch (next) {
-
case 'b':
res = 8;
break;
@@ -228,7 +212,6 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
return ERR_PARSE_ERROR;
}
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
-
r_err_str = "Malformed hex constant in string";
return ERR_PARSE_ERROR;
}
@@ -260,8 +243,9 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
str += res;
} else {
- if (p_str[index] == '\n')
+ if (p_str[index] == '\n') {
line++;
+ }
str += p_str[index];
}
index++;
@@ -273,7 +257,6 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
} break;
default: {
-
if (p_str[index] <= 32) {
index++;
break;
@@ -289,11 +272,9 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
return OK;
} else if ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
-
String id;
while ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
-
id += p_str[index];
index++;
}
@@ -313,45 +294,41 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
}
Error JSON::_parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str) {
-
if (token.type == TK_CURLY_BRACKET_OPEN) {
-
Dictionary d;
Error err = _parse_object(d, p_str, index, p_len, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
value = d;
return OK;
} else if (token.type == TK_BRACKET_OPEN) {
-
Array a;
Error err = _parse_array(a, p_str, index, p_len, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
value = a;
return OK;
} else if (token.type == TK_IDENTIFIER) {
-
String id = token.value;
- if (id == "true")
+ if (id == "true") {
value = true;
- else if (id == "false")
+ } else if (id == "false") {
value = false;
- else if (id == "null")
+ } else if (id == "null") {
value = Variant();
- else {
+ } else {
r_err_str = "Expected 'true','false' or 'null', got '" + id + "'.";
return ERR_PARSE_ERROR;
}
return OK;
} else if (token.type == TK_NUMBER) {
-
value = token.value;
return OK;
} else if (token.type == TK_STRING) {
-
value = token.value;
return OK;
} else {
@@ -361,25 +338,21 @@ Error JSON::_parse_value(Variant &value, Token &token, const CharType *p_str, in
}
Error JSON::_parse_array(Array &array, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str) {
-
Token token;
bool need_comma = false;
while (index < p_len) {
-
Error err = _get_token(p_str, index, p_len, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token.type == TK_BRACKET_CLOSE) {
-
return OK;
}
if (need_comma) {
-
if (token.type != TK_COMMA) {
-
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
} else {
@@ -390,8 +363,9 @@ Error JSON::_parse_array(Array &array, const CharType *p_str, int &index, int p_
Variant v;
err = _parse_value(v, token, p_str, index, p_len, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
array.push_back(v);
need_comma = true;
@@ -401,29 +375,24 @@ Error JSON::_parse_array(Array &array, const CharType *p_str, int &index, int p_
}
Error JSON::_parse_object(Dictionary &object, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str) {
-
bool at_key = true;
String key;
Token token;
bool need_comma = false;
while (index < p_len) {
-
if (at_key) {
-
Error err = _get_token(p_str, index, p_len, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token.type == TK_CURLY_BRACKET_CLOSE) {
-
return OK;
}
if (need_comma) {
-
if (token.type != TK_COMMA) {
-
r_err_str = "Expected '}' or ','";
return ERR_PARSE_ERROR;
} else {
@@ -433,31 +402,31 @@ Error JSON::_parse_object(Dictionary &object, const CharType *p_str, int &index,
}
if (token.type != TK_STRING) {
-
r_err_str = "Expected key";
return ERR_PARSE_ERROR;
}
key = token.value;
err = _get_token(p_str, index, p_len, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token.type != TK_COLON) {
-
r_err_str = "Expected ':'";
return ERR_PARSE_ERROR;
}
at_key = false;
} else {
-
Error err = _get_token(p_str, index, p_len, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
Variant v;
err = _parse_value(v, token, p_str, index, p_len, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
object[key] = v;
need_comma = true;
at_key = true;
@@ -468,7 +437,6 @@ Error JSON::_parse_object(Dictionary &object, const CharType *p_str, int &index,
}
Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line) {
-
const CharType *str = p_json.ptr();
int idx = 0;
int len = p_json.length();
@@ -477,8 +445,9 @@ Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int &
String aux_key;
Error err = _get_token(str, idx, len, token, r_err_line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
err = _parse_value(r_ret, token, str, idx, len, r_err_line, r_err_str);
diff --git a/core/io/json.h b/core/io/json.h
index 2e851afcf4..4fc5630a93 100644
--- a/core/io/json.h
+++ b/core/io/json.h
@@ -34,7 +34,6 @@
#include "core/variant.h"
class JSON {
-
enum TokenType {
TK_CURLY_BRACKET_OPEN,
TK_CURLY_BRACKET_CLOSE,
@@ -58,7 +57,6 @@ class JSON {
};
struct Token {
-
TokenType type;
Variant value;
};
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index 02cc78538e..ef78b1194e 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -67,10 +67,11 @@ void Logger::log_error(const char *p_function, const char *p_file, int p_line, c
}
const char *err_details;
- if (p_rationale && *p_rationale)
+ if (p_rationale && *p_rationale) {
err_details = p_rationale;
- else
+ } else {
err_details = p_code;
+ }
logf_error("%s: %s\n", err_type, err_details);
logf_error(" at: %s (%s:%i) - %s\n", p_function, p_file, p_line, p_code);
@@ -102,8 +103,6 @@ void Logger::logf_error(const char *p_format, ...) {
va_end(argp);
}
-Logger::~Logger() {}
-
void RotatedFileLogger::close_file() {
if (file) {
memdelete(file);
@@ -180,8 +179,7 @@ void RotatedFileLogger::rotate_file() {
RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) :
base_path(p_base_path.simplify_path()),
- max_files(p_max_files > 0 ? p_max_files : 1),
- file(nullptr) {
+ max_files(p_max_files > 0 ? p_max_files : 1) {
rotate_file();
}
@@ -236,8 +234,6 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) {
}
}
-StdLogger::~StdLogger() {}
-
CompositeLogger::CompositeLogger(Vector<Logger *> p_loggers) :
loggers(p_loggers) {
}
diff --git a/core/io/logger.h b/core/io/logger.h
index 7028551185..277be9ed35 100644
--- a/core/io/logger.h
+++ b/core/io/logger.h
@@ -55,17 +55,16 @@ public:
void logf(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
void logf_error(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
- virtual ~Logger();
+ virtual ~Logger() {}
};
/**
* Writes messages to stdout/stderr.
*/
class StdLogger : public Logger {
-
public:
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
- virtual ~StdLogger();
+ virtual ~StdLogger() {}
};
/**
@@ -78,7 +77,7 @@ class RotatedFileLogger : public Logger {
String base_path;
int max_files;
- FileAccess *file;
+ FileAccess *file = nullptr;
void rotate_file_without_closing();
void close_file();
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 81bc45b2f7..eb39b1433f 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -49,13 +49,9 @@ void EncodedObjectAsID::set_object_id(ObjectID p_id) {
}
ObjectID EncodedObjectAsID::get_object_id() const {
-
return id;
}
-EncodedObjectAsID::EncodedObjectAsID() {
-}
-
#define _S(a) ((int32_t)a)
#define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(_S(b) < 0 || _S(a) < 0 || _S(a) > INT_MAX - _S(b), err)
#define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(_S(a) < 0 || _S(b) <= 0 || _S(a) > INT_MAX / _S(b), err)
@@ -100,7 +96,6 @@ static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r
}
Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len, bool p_allow_objects) {
-
const uint8_t *buf = p_buffer;
int len = p_len;
@@ -112,95 +107,95 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
buf += 4;
len -= 4;
- if (r_len)
+ if (r_len) {
*r_len = 4;
+ }
switch (type & ENCODE_MASK) {
-
case Variant::NIL: {
-
r_variant = Variant();
} break;
case Variant::BOOL: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
bool val = decode_uint32(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4;
+ }
} break;
case Variant::INT: {
-
if (type & ENCODE_FLAG_64) {
ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
int64_t val = decode_uint64(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 8;
+ }
} else {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t val = decode_uint32(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4;
+ }
}
} break;
case Variant::FLOAT: {
-
if (type & ENCODE_FLAG_64) {
ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
double val = decode_double(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 8;
+ }
} else {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
float val = decode_float(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4;
+ }
}
} break;
case Variant::STRING: {
-
String str;
Error err = _decode_string(buf, len, r_len, str);
- if (err)
+ if (err) {
return err;
+ }
r_variant = str;
} break;
// math types
case Variant::VECTOR2: {
-
ERR_FAIL_COND_V(len < 4 * 2, ERR_INVALID_DATA);
Vector2 val;
val.x = decode_float(&buf[0]);
val.y = decode_float(&buf[4]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 2;
+ }
} break;
case Variant::VECTOR2I: {
-
ERR_FAIL_COND_V(len < 4 * 2, ERR_INVALID_DATA);
Vector2i val;
val.x = decode_uint32(&buf[0]);
val.y = decode_uint32(&buf[4]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 2;
+ }
} break;
case Variant::RECT2: {
-
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Rect2 val;
val.position.x = decode_float(&buf[0]);
@@ -209,12 +204,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.size.y = decode_float(&buf[12]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 4;
+ }
} break;
case Variant::RECT2I: {
-
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Rect2i val;
val.position.x = decode_uint32(&buf[0]);
@@ -223,12 +218,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.size.y = decode_uint32(&buf[12]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 4;
+ }
} break;
case Variant::VECTOR3: {
-
ERR_FAIL_COND_V(len < 4 * 3, ERR_INVALID_DATA);
Vector3 val;
val.x = decode_float(&buf[0]);
@@ -236,12 +231,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.z = decode_float(&buf[8]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 3;
+ }
} break;
case Variant::VECTOR3I: {
-
ERR_FAIL_COND_V(len < 4 * 3, ERR_INVALID_DATA);
Vector3i val;
val.x = decode_uint32(&buf[0]);
@@ -249,29 +244,28 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.z = decode_uint32(&buf[8]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 3;
+ }
} break;
case Variant::TRANSFORM2D: {
-
ERR_FAIL_COND_V(len < 4 * 6, ERR_INVALID_DATA);
Transform2D val;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
-
val.elements[i][j] = decode_float(&buf[(i * 2 + j) * 4]);
}
}
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 6;
+ }
} break;
case Variant::PLANE: {
-
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Plane val;
val.normal.x = decode_float(&buf[0]);
@@ -280,12 +274,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.d = decode_float(&buf[12]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 4;
+ }
} break;
case Variant::QUAT: {
-
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Quat val;
val.x = decode_float(&buf[0]);
@@ -294,12 +288,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.w = decode_float(&buf[12]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 4;
+ }
} break;
case Variant::AABB: {
-
ERR_FAIL_COND_V(len < 4 * 6, ERR_INVALID_DATA);
AABB val;
val.position.x = decode_float(&buf[0]);
@@ -310,34 +304,32 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.size.z = decode_float(&buf[20]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 6;
+ }
} break;
case Variant::BASIS: {
-
ERR_FAIL_COND_V(len < 4 * 9, ERR_INVALID_DATA);
Basis val;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
val.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]);
}
}
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 9;
+ }
} break;
case Variant::TRANSFORM: {
-
ERR_FAIL_COND_V(len < 4 * 12, ERR_INVALID_DATA);
Transform val;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]);
}
}
@@ -347,14 +339,14 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 12;
+ }
} break;
// misc types
case Variant::COLOR: {
-
ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA);
Color val;
val.r = decode_float(&buf[0]);
@@ -363,22 +355,22 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
val.a = decode_float(&buf[12]);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4 * 4;
+ }
} break;
case Variant::STRING_NAME: {
-
String str;
Error err = _decode_string(buf, len, r_len, str);
- if (err)
+ if (err) {
return err;
+ }
r_variant = StringName(str);
} break;
case Variant::NODE_PATH: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t strlen = decode_uint32(buf);
@@ -395,25 +387,28 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 12;
buf += 12;
- if (flags & 2) // Obsolete format with property separate from subpath
+ if (flags & 2) { // Obsolete format with property separate from subpath
subnamecount++;
+ }
uint32_t total = namecount + subnamecount;
- if (r_len)
+ if (r_len) {
(*r_len) += 12;
+ }
for (uint32_t i = 0; i < total; i++) {
-
String str;
Error err = _decode_string(buf, len, r_len, str);
- if (err)
+ if (err) {
return err;
+ }
- if (i < namecount)
+ if (i < namecount) {
names.push_back(str);
- else
+ } else {
subnames.push_back(str);
+ }
}
r_variant = NodePath(names, subnames, flags & 1);
@@ -426,17 +421,16 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::_RID: {
-
r_variant = RID();
} break;
case Variant::OBJECT: {
-
if (type & ENCODE_FLAG_OBJECT_AS_ID) {
//this _is_ allowed
ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
ObjectID val = ObjectID(decode_uint64(buf));
- if (r_len)
+ if (r_len) {
(*r_len) += 8;
+ }
if (val.is_null()) {
r_variant = (Object *)nullptr;
@@ -453,13 +447,13 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
String str;
Error err = _decode_string(buf, len, r_len, str);
- if (err)
+ if (err) {
return err;
+ }
if (str == String()) {
r_variant = (Object *)nullptr;
} else {
-
Object *obj = ClassDB::instance(str);
ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
@@ -473,17 +467,18 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
for (int i = 0; i < count; i++) {
-
str = String();
err = _decode_string(buf, len, r_len, str);
- if (err)
+ if (err) {
return err;
+ }
Variant value;
int used;
err = decode_variant(value, buf, len, &used, p_allow_objects);
- if (err)
+ if (err) {
return err;
+ }
buf += used;
len -= used;
@@ -505,16 +500,13 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::CALLABLE: {
-
r_variant = Callable();
} break;
case Variant::SIGNAL: {
-
r_variant = Signal();
} break;
case Variant::DICTIONARY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
// bool shared = count&0x80000000;
@@ -530,7 +522,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Dictionary d;
for (int i = 0; i < count; i++) {
-
Variant key, value;
int used;
@@ -559,7 +550,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
// bool shared = count&0x80000000;
@@ -575,7 +565,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Array varr;
for (int i = 0; i < count; i++) {
-
int used = 0;
Variant v;
Error err = decode_variant(v, buf, len, &used, p_allow_objects);
@@ -594,7 +583,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
// arrays
case Variant::PACKED_BYTE_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
buf += 4;
@@ -607,7 +595,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
data.resize(count);
uint8_t *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
-
w[i] = buf[i];
}
}
@@ -615,14 +602,14 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = data;
if (r_len) {
- if (count % 4)
+ if (count % 4) {
(*r_len) += 4 - count % 4;
+ }
(*r_len) += 4 + count;
}
} break;
case Variant::PACKED_INT32_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
buf += 4;
@@ -637,7 +624,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
data.resize(count);
int32_t *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
-
w[i] = decode_uint32(&buf[i * 4]);
}
}
@@ -648,7 +634,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::PACKED_INT64_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int64_t count = decode_uint64(buf);
buf += 4;
@@ -663,7 +648,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
data.resize(count);
int64_t *w = data.ptrw();
for (int64_t i = 0; i < count; i++) {
-
w[i] = decode_uint64(&buf[i * 8]);
}
}
@@ -674,7 +658,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
buf += 4;
@@ -689,7 +672,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
data.resize(count);
float *w = data.ptrw();
for (int32_t i = 0; i < count; i++) {
-
w[i] = decode_float(&buf[i * 4]);
}
}
@@ -701,7 +683,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int64_t count = decode_uint64(buf);
buf += 4;
@@ -716,7 +697,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
data.resize(count);
double *w = data.ptrw();
for (int64_t i = 0; i < count; i++) {
-
w[i] = decode_double(&buf[i * 8]);
}
}
@@ -728,7 +708,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::PACKED_STRING_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
@@ -736,16 +715,17 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
buf += 4;
len -= 4;
- if (r_len)
+ if (r_len) {
(*r_len) += 4;
+ }
//printf("string count: %i\n",count);
for (int32_t i = 0; i < count; i++) {
-
String str;
Error err = _decode_string(buf, len, r_len, str);
- if (err)
+ if (err) {
return err;
+ }
strings.push_back(str);
}
@@ -754,7 +734,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
buf += 4;
@@ -773,22 +752,21 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Vector2 *w = varray.ptrw();
for (int32_t i = 0; i < count; i++) {
-
w[i].x = decode_float(buf + i * 4 * 2 + 4 * 0);
w[i].y = decode_float(buf + i * 4 * 2 + 4 * 1);
}
int adv = 4 * 2 * count;
- if (r_len)
+ if (r_len) {
(*r_len) += adv;
+ }
}
r_variant = varray;
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
buf += 4;
@@ -808,7 +786,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Vector3 *w = varray.ptrw();
for (int32_t i = 0; i < count; i++) {
-
w[i].x = decode_float(buf + i * 4 * 3 + 4 * 0);
w[i].y = decode_float(buf + i * 4 * 3 + 4 * 1);
w[i].z = decode_float(buf + i * 4 * 3 + 4 * 2);
@@ -816,15 +793,15 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
int adv = 4 * 3 * count;
- if (r_len)
+ if (r_len) {
(*r_len) += adv;
+ }
}
r_variant = varray;
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t count = decode_uint32(buf);
buf += 4;
@@ -844,7 +821,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Color *w = carray.ptrw();
for (int32_t i = 0; i < count; i++) {
-
w[i].r = decode_float(buf + i * 4 * 4 + 4 * 0);
w[i].g = decode_float(buf + i * 4 * 4 + 4 * 1);
w[i].b = decode_float(buf + i * 4 * 4 + 4 * 2);
@@ -853,8 +829,9 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
int adv = 4 * 4 * count;
- if (r_len)
+ if (r_len) {
(*r_len) += adv;
+ }
}
r_variant = carray;
@@ -869,7 +846,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
}
static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
-
CharString utf8 = p_string.utf8();
if (buf) {
@@ -889,7 +865,6 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
}
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects) {
-
uint8_t *buf = r_buffer;
r_len = 0;
@@ -897,7 +872,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
uint32_t flags = 0;
switch (p_variant.get_type()) {
-
case Variant::INT: {
int64_t val = p_variant;
if (val > (int64_t)INT_MAX || val < (int64_t)INT_MIN) {
@@ -905,7 +879,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
case Variant::FLOAT: {
-
double d = p_variant;
float f = d;
if (double(f) != d) {
@@ -913,7 +886,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
case Variant::OBJECT: {
-
// Test for potential wrong values sent by the debugger when it breaks.
Object *obj = p_variant.get_validated_object();
if (!obj) {
@@ -940,13 +912,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
switch (p_variant.get_type()) {
-
case Variant::NIL: {
-
//nothing to do
} break;
case Variant::BOOL: {
-
if (buf) {
encode_uint32(p_variant.operator bool(), buf);
}
@@ -955,7 +924,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::INT: {
-
if (flags & ENCODE_FLAG_64) {
//64 bits
if (buf) {
@@ -972,7 +940,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
case Variant::FLOAT: {
-
if (flags & ENCODE_FLAG_64) {
if (buf) {
encode_double(p_variant.operator double(), buf);
@@ -981,7 +948,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 8;
} else {
-
if (buf) {
encode_float(p_variant.operator float(), buf);
}
@@ -991,14 +957,14 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::NODE_PATH: {
-
NodePath np = p_variant;
if (buf) {
encode_uint32(uint32_t(np.get_name_count()) | 0x80000000, buf); //for compatibility with the old format
encode_uint32(np.get_subname_count(), buf + 4);
uint32_t np_flags = 0;
- if (np.is_absolute())
+ if (np.is_absolute()) {
np_flags |= 1;
+ }
encode_uint32(np_flags, buf + 8);
@@ -1010,20 +976,21 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
int total = np.get_name_count() + np.get_subname_count();
for (int i = 0; i < total; i++) {
-
String str;
- if (i < np.get_name_count())
+ if (i < np.get_name_count()) {
str = np.get_name(i);
- else
+ } else {
str = np.get_subname(i - np.get_name_count());
+ }
CharString utf8 = str.utf8();
int pad = 0;
- if (utf8.length() % 4)
+ if (utf8.length() % 4) {
pad = 4 - utf8.length() % 4;
+ }
if (buf) {
encode_uint32(utf8.length(), buf);
@@ -1037,19 +1004,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::STRING: {
-
_encode_string(p_variant, buf, r_len);
} break;
case Variant::STRING_NAME: {
-
_encode_string(p_variant, buf, r_len);
} break;
// math types
case Variant::VECTOR2: {
-
if (buf) {
Vector2 v2 = p_variant;
encode_float(v2.x, &buf[0]);
@@ -1060,7 +1024,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::VECTOR2I: {
-
if (buf) {
Vector2i v2 = p_variant;
encode_uint32(v2.x, &buf[0]);
@@ -1071,7 +1034,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::RECT2: {
-
if (buf) {
Rect2 r2 = p_variant;
encode_float(r2.position.x, &buf[0]);
@@ -1083,7 +1045,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::RECT2I: {
-
if (buf) {
Rect2i r2 = p_variant;
encode_uint32(r2.position.x, &buf[0]);
@@ -1095,7 +1056,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::VECTOR3: {
-
if (buf) {
Vector3 v3 = p_variant;
encode_float(v3.x, &buf[0]);
@@ -1107,7 +1067,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::VECTOR3I: {
-
if (buf) {
Vector3i v3 = p_variant;
encode_uint32(v3.x, &buf[0]);
@@ -1119,12 +1078,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::TRANSFORM2D: {
-
if (buf) {
Transform2D val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
-
copymem(&buf[(i * 2 + j) * 4], &val.elements[i][j], sizeof(float));
}
}
@@ -1134,7 +1091,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::PLANE: {
-
if (buf) {
Plane p = p_variant;
encode_float(p.normal.x, &buf[0]);
@@ -1147,7 +1103,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::QUAT: {
-
if (buf) {
Quat q = p_variant;
encode_float(q.x, &buf[0]);
@@ -1160,7 +1115,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::AABB: {
-
if (buf) {
AABB aabb = p_variant;
encode_float(aabb.position.x, &buf[0]);
@@ -1175,12 +1129,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::BASIS: {
-
if (buf) {
Basis val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
copymem(&buf[(i * 3 + j) * 4], &val.elements[i][j], sizeof(float));
}
}
@@ -1190,12 +1142,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::TRANSFORM: {
-
if (buf) {
Transform val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
copymem(&buf[(i * 3 + j) * 4], &val.basis.elements[i][j], sizeof(float));
}
}
@@ -1211,7 +1161,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
// misc types
case Variant::COLOR: {
-
if (buf) {
Color c = p_variant;
encode_float(c.r, &buf[0]);
@@ -1224,18 +1173,13 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::_RID: {
-
} break;
case Variant::CALLABLE: {
-
} break;
case Variant::SIGNAL: {
-
} break;
case Variant::OBJECT: {
-
if (p_full_objects) {
-
Object *obj = p_variant;
if (!obj) {
if (buf) {
@@ -1251,9 +1195,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
int pc = 0;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
pc++;
}
@@ -1265,25 +1209,26 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
_encode_string(E->get().name, buf, r_len);
int len;
Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects);
- if (err)
+ if (err) {
return err;
+ }
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
- if (buf)
+ if (buf) {
buf += len;
+ }
}
}
} else {
if (buf) {
-
Object *obj = p_variant.get_validated_object();
ObjectID id;
if (obj) {
@@ -1298,7 +1243,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::DICTIONARY: {
-
Dictionary d = p_variant;
if (buf) {
@@ -1311,7 +1255,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
d.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
/*
CharString utf8 = E->->utf8();
@@ -1329,20 +1272,21 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_variant(E->get(), buf, len, p_full_objects);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
- if (buf)
+ if (buf) {
buf += len;
+ }
Variant *v = d.getptr(E->get());
ERR_FAIL_COND_V(!v, ERR_BUG);
encode_variant(*v, buf, len, p_full_objects);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
- if (buf)
+ if (buf) {
buf += len;
+ }
}
} break;
case Variant::ARRAY: {
-
Array v = p_variant;
if (buf) {
@@ -1353,19 +1297,18 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
for (int i = 0; i < v.size(); i++) {
-
int len;
encode_variant(v.get(i), buf, len, p_full_objects);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
- if (buf)
+ if (buf) {
buf += len;
+ }
}
} break;
// arrays
case Variant::PACKED_BYTE_ARRAY: {
-
Vector<uint8_t> data = p_variant;
int datalen = data.size();
int datasize = sizeof(uint8_t);
@@ -1381,13 +1324,13 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 + datalen * datasize;
while (r_len % 4) {
r_len++;
- if (buf)
+ if (buf) {
*(buf++) = 0;
+ }
}
} break;
case Variant::PACKED_INT32_ARRAY: {
-
Vector<int32_t> data = p_variant;
int datalen = data.size();
int datasize = sizeof(int32_t);
@@ -1396,15 +1339,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_uint32(datalen, buf);
buf += 4;
const int32_t *r = data.ptr();
- for (int32_t i = 0; i < datalen; i++)
+ for (int32_t i = 0; i < datalen; i++) {
encode_uint32(r[i], &buf[i * datasize]);
+ }
}
r_len += 4 + datalen * datasize;
} break;
case Variant::PACKED_INT64_ARRAY: {
-
Vector<int64_t> data = p_variant;
int datalen = data.size();
int datasize = sizeof(int64_t);
@@ -1413,15 +1356,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_uint64(datalen, buf);
buf += 4;
const int64_t *r = data.ptr();
- for (int64_t i = 0; i < datalen; i++)
+ for (int64_t i = 0; i < datalen; i++) {
encode_uint64(r[i], &buf[i * datasize]);
+ }
}
r_len += 4 + datalen * datasize;
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
Vector<float> data = p_variant;
int datalen = data.size();
int datasize = sizeof(float);
@@ -1430,15 +1373,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_uint32(datalen, buf);
buf += 4;
const float *r = data.ptr();
- for (int i = 0; i < datalen; i++)
+ for (int i = 0; i < datalen; i++) {
encode_float(r[i], &buf[i * datasize]);
+ }
}
r_len += 4 + datalen * datasize;
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
Vector<double> data = p_variant;
int datalen = data.size();
int datasize = sizeof(double);
@@ -1447,15 +1390,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_uint32(datalen, buf);
buf += 4;
const double *r = data.ptr();
- for (int i = 0; i < datalen; i++)
+ for (int i = 0; i < datalen; i++) {
encode_double(r[i], &buf[i * datasize]);
+ }
}
r_len += 4 + datalen * datasize;
} break;
case Variant::PACKED_STRING_ARRAY: {
-
Vector<String> data = p_variant;
int len = data.size();
@@ -1467,7 +1410,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
for (int i = 0; i < len; i++) {
-
CharString utf8 = data.get(i).utf8();
if (buf) {
@@ -1480,14 +1422,14 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 + utf8.length() + 1;
while (r_len % 4) {
r_len++; //pad
- if (buf)
+ if (buf) {
*(buf++) = 0;
+ }
}
}
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
-
Vector<Vector2> data = p_variant;
int len = data.size();
@@ -1499,9 +1441,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
if (buf) {
-
for (int i = 0; i < len; i++) {
-
Vector2 v = data.get(i);
encode_float(v.x, &buf[0]);
@@ -1514,7 +1454,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
Vector<Vector3> data = p_variant;
int len = data.size();
@@ -1526,9 +1465,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
if (buf) {
-
for (int i = 0; i < len; i++) {
-
Vector3 v = data.get(i);
encode_float(v.x, &buf[0]);
@@ -1542,7 +1479,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
Vector<Color> data = p_variant;
int len = data.size();
@@ -1554,9 +1490,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4;
if (buf) {
-
for (int i = 0; i < len; i++) {
-
Color c = data.get(i);
encode_float(c.r, &buf[0]);
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index 650c95364a..c8ed497528 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -41,21 +41,17 @@
*/
union MarshallFloat {
-
uint32_t i; ///< int
float f; ///< float
};
union MarshallDouble {
-
uint64_t l; ///< long long
double d; ///< double
};
static inline unsigned int encode_uint16(uint16_t p_uint, uint8_t *p_arr) {
-
for (int i = 0; i < 2; i++) {
-
*p_arr = p_uint & 0xFF;
p_arr++;
p_uint >>= 8;
@@ -65,9 +61,7 @@ static inline unsigned int encode_uint16(uint16_t p_uint, uint8_t *p_arr) {
}
static inline unsigned int encode_uint32(uint32_t p_uint, uint8_t *p_arr) {
-
for (int i = 0; i < 4; i++) {
-
*p_arr = p_uint & 0xFF;
p_arr++;
p_uint >>= 8;
@@ -77,7 +71,6 @@ static inline unsigned int encode_uint32(uint32_t p_uint, uint8_t *p_arr) {
}
static inline unsigned int encode_float(float p_float, uint8_t *p_arr) {
-
MarshallFloat mf;
mf.f = p_float;
encode_uint32(mf.i, p_arr);
@@ -86,9 +79,7 @@ static inline unsigned int encode_float(float p_float, uint8_t *p_arr) {
}
static inline unsigned int encode_uint64(uint64_t p_uint, uint8_t *p_arr) {
-
for (int i = 0; i < 8; i++) {
-
*p_arr = p_uint & 0xFF;
p_arr++;
p_uint >>= 8;
@@ -98,7 +89,6 @@ static inline unsigned int encode_uint64(uint64_t p_uint, uint8_t *p_arr) {
}
static inline unsigned int encode_double(double p_double, uint8_t *p_arr) {
-
MarshallDouble md;
md.d = p_double;
encode_uint64(md.l, p_arr);
@@ -107,31 +97,27 @@ static inline unsigned int encode_double(double p_double, uint8_t *p_arr) {
}
static inline int encode_cstring(const char *p_string, uint8_t *p_data) {
-
int len = 0;
while (*p_string) {
-
if (p_data) {
-
*p_data = (uint8_t)*p_string;
p_data++;
}
p_string++;
len++;
- };
+ }
- if (p_data)
+ if (p_data) {
*p_data = 0;
+ }
return len + 1;
}
static inline uint16_t decode_uint16(const uint8_t *p_arr) {
-
uint16_t u = 0;
for (int i = 0; i < 2; i++) {
-
uint16_t b = *p_arr;
b <<= (i * 8);
u |= b;
@@ -142,11 +128,9 @@ static inline uint16_t decode_uint16(const uint8_t *p_arr) {
}
static inline uint32_t decode_uint32(const uint8_t *p_arr) {
-
uint32_t u = 0;
for (int i = 0; i < 4; i++) {
-
uint32_t b = *p_arr;
b <<= (i * 8);
u |= b;
@@ -157,18 +141,15 @@ static inline uint32_t decode_uint32(const uint8_t *p_arr) {
}
static inline float decode_float(const uint8_t *p_arr) {
-
MarshallFloat mf;
mf.i = decode_uint32(p_arr);
return mf.f;
}
static inline uint64_t decode_uint64(const uint8_t *p_arr) {
-
uint64_t u = 0;
for (int i = 0; i < 8; i++) {
-
uint64_t b = (*p_arr) & 0xFF;
b <<= (i * 8);
u |= b;
@@ -179,7 +160,6 @@ static inline uint64_t decode_uint64(const uint8_t *p_arr) {
}
static inline double decode_double(const uint8_t *p_arr) {
-
MarshallDouble md;
md.l = decode_uint64(p_arr);
return md.d;
@@ -197,7 +177,7 @@ public:
void set_object_id(ObjectID p_id);
ObjectID get_object_id() const;
- EncodedObjectAsID();
+ EncodedObjectAsID() {}
};
Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false);
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 94e2fdb72c..2f17d9e746 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -33,6 +33,7 @@
#include "core/debugger/engine_debugger.h"
#include "core/io/marshalls.h"
#include "scene/main/node.h"
+
#include <stdint.h>
#define NODE_ID_COMPRESSION_SHIFT 3
@@ -44,9 +45,7 @@
#endif
_FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_master, bool &r_skip_rpc) {
-
switch (mode) {
-
case MultiplayerAPI::RPC_MODE_DISABLED: {
// Do nothing.
} break;
@@ -54,8 +53,9 @@ _FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_mas
// Do nothing also. Remote cannot produce a local call.
} break;
case MultiplayerAPI::RPC_MODE_MASTERSYNC: {
- if (is_master)
+ if (is_master) {
r_skip_rpc = true; // I am the master, so skip remote call.
+ }
[[fallthrough]];
}
case MultiplayerAPI::RPC_MODE_REMOTESYNC:
@@ -64,8 +64,9 @@ _FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_mas
return true;
} break;
case MultiplayerAPI::RPC_MODE_MASTER: {
- if (is_master)
+ if (is_master) {
r_skip_rpc = true; // I am the master, so skip remote call.
+ }
return is_master;
} break;
case MultiplayerAPI::RPC_MODE_PUPPET: {
@@ -77,7 +78,6 @@ _FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_mas
_FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, int p_remote_id) {
switch (mode) {
-
case MultiplayerAPI::RPC_MODE_DISABLED: {
return false;
} break;
@@ -99,17 +99,17 @@ _FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, i
}
void MultiplayerAPI::poll() {
-
- if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED)
+ if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) {
return;
+ }
network_peer->poll();
- if (!network_peer.is_valid()) // It's possible that polling might have resulted in a disconnection, so check here.
+ if (!network_peer.is_valid()) { // It's possible that polling might have resulted in a disconnection, so check here.
return;
+ }
while (network_peer->get_available_packet_count()) {
-
int sender = network_peer->get_packet_peer();
const uint8_t *packet;
int len;
@@ -143,9 +143,9 @@ void MultiplayerAPI::set_root_node(Node *p_node) {
}
void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) {
-
- if (p_peer == network_peer)
+ if (p_peer == network_peer) {
return; // Nothing to do
+ }
ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED,
"Supplied NetworkedMultiplayerPeer must be connecting or connected.");
@@ -184,6 +184,7 @@ void _profile_node_data(const String &p_what, ObjectID p_id) {
EngineDebugger::profiler_add_frame_data("multiplayer", values);
}
}
+
void _profile_bandwidth_data(const String &p_inout, int p_size) {
if (EngineDebugger::is_profiling("multiplayer")) {
Array values;
@@ -207,7 +208,6 @@ int get_packet_len(uint32_t p_node_target, int p_packet_len) {
}
void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) {
-
ERR_FAIL_COND_MSG(root_node == nullptr, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it.");
ERR_FAIL_COND_MSG(p_packet_len < 1, "Invalid packet received. Size too small.");
@@ -219,20 +219,16 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
uint8_t packet_type = p_packet[0] & 7;
switch (packet_type) {
-
case NETWORK_COMMAND_SIMPLIFY_PATH: {
-
_process_simplify_path(p_from, p_packet, p_packet_len);
} break;
case NETWORK_COMMAND_CONFIRM_PATH: {
-
_process_confirm_path(p_from, p_packet, p_packet_len);
} break;
case NETWORK_COMMAND_REMOTE_CALL:
case NETWORK_COMMAND_REMOTE_SET: {
-
// Extract packet meta
int packet_min_size = 1;
int name_id_offset = 1;
@@ -303,25 +299,21 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_
const int packet_len = get_packet_len(node_target, p_packet_len);
if (packet_type == NETWORK_COMMAND_REMOTE_CALL) {
-
_process_rpc(node, name_id, p_from, p_packet, packet_len, packet_min_size);
} else {
-
_process_rset(node, name_id, p_from, p_packet, packet_len, packet_min_size);
}
} break;
case NETWORK_COMMAND_RAW: {
-
_process_raw(p_from, p_packet, p_packet_len);
} break;
}
}
Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uint32_t p_node_target, int p_packet_len) {
-
Node *node = nullptr;
if (p_node_target & 0x80000000) {
@@ -338,8 +330,9 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uin
node = root_node->get_node(np);
- if (!node)
+ if (!node) {
ERR_PRINT("Failed to get path from RPC: " + String(np) + ".");
+ }
} else {
// Use cached path.
int id = p_node_target;
@@ -354,14 +347,14 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uin
// Do proper caching later.
node = root_node->get_node(ni->path);
- if (!node)
+ if (!node) {
ERR_PRINT("Failed to get cached path from RPC: " + String(ni->path) + ".");
+ }
}
return node;
}
void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
-
ERR_FAIL_COND_MSG(p_offset > p_packet_len, "Invalid packet received. Size too small.");
// Check that remote can call the RPC on this node.
@@ -414,7 +407,6 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id,
p_offset += len;
} else {
for (int i = 0; i < argc; i++) {
-
ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
int vlen;
@@ -437,7 +429,6 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id,
}
void MultiplayerAPI::_process_rset(Node *p_node, const uint16_t p_rpc_property_id, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
-
ERR_FAIL_COND_MSG(p_offset >= p_packet_len, "Invalid packet received. Size too small.");
// Check that remote can call the RSET on this node.
@@ -471,7 +462,6 @@ void MultiplayerAPI::_process_rset(Node *p_node, const uint16_t p_rpc_property_i
}
void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
-
ERR_FAIL_COND_MSG(p_packet_len < 38, "Invalid packet received. Size too small.");
int ofs = 1;
@@ -520,7 +510,6 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet,
}
void MultiplayerAPI::_process_confirm_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
-
ERR_FAIL_COND_MSG(p_packet_len < 3, "Invalid packet received. Size too small.");
const bool valid_rpc_checksum = p_packet[1];
@@ -547,12 +536,13 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC
List<int> peers_to_add; // If one is missing, take note to add it.
for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {
-
- if (p_target < 0 && E->get() == -p_target)
+ if (p_target < 0 && E->get() == -p_target) {
continue; // Continue, excluded.
+ }
- if (p_target > 0 && E->get() != p_target)
+ if (p_target > 0 && E->get() != p_target) {
continue; // Continue, not for this peer.
+ }
Map<int, bool>::Element *F = psc->confirmed_peers.find(E->get());
@@ -568,7 +558,6 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC
}
if (peers_to_add.size() > 0) {
-
// Those that need to be added, send a message for this.
// Encode function name.
@@ -593,7 +582,6 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC
ofs += encode_cstring(path.get_data(), &packet.write[ofs]);
for (List<int>::Element *E = peers_to_add.front(); E; E = E->next()) {
-
network_peer->set_target_peer(E->get()); // To all of you.
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
network_peer->put_packet(packet.ptr(), packet.size());
@@ -618,7 +606,6 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC
#define ENCODE_32 2 << 5
#define ENCODE_64 3 << 5
Error MultiplayerAPI::_encode_and_compress_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
-
// Unreachable because `VARIANT_MAX` == 27 and `ENCODE_VARIANT_MASK` == 31
CRASH_COND(p_variant.get_type() > VARIANT_META_TYPE_MASK);
@@ -680,8 +667,9 @@ Error MultiplayerAPI::_encode_and_compress_variant(const Variant &p_variant, uin
default:
// Any other case is not yet compressed.
Error err = encode_variant(p_variant, r_buffer, r_len, allow_object_decoding);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (r_buffer) {
// The first byte is not used by the marshaling, so store the type
// so we know how to decompress and decode this variant.
@@ -691,8 +679,8 @@ Error MultiplayerAPI::_encode_and_compress_variant(const Variant &p_variant, uin
return OK;
}
-Error MultiplayerAPI::_decode_and_decompress_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len) {
+Error MultiplayerAPI::_decode_and_decompress_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len) {
const uint8_t *buf = p_buffer;
int len = p_len;
@@ -706,55 +694,61 @@ Error MultiplayerAPI::_decode_and_decompress_variant(Variant &r_variant, const u
case Variant::BOOL: {
bool val = (buf[0] & VARIANT_META_BOOL_MASK) > 0;
r_variant = val;
- if (r_len)
+ if (r_len) {
*r_len = 1;
+ }
} break;
case Variant::INT: {
buf += 1;
len -= 1;
- if (r_len)
+ if (r_len) {
*r_len = 1;
+ }
if (encode_mode == ENCODE_8) {
// 8 bits.
ERR_FAIL_COND_V(len < 1, ERR_INVALID_DATA);
int8_t val = buf[0];
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 1;
+ }
} else if (encode_mode == ENCODE_16) {
// 16 bits.
ERR_FAIL_COND_V(len < 2, ERR_INVALID_DATA);
int16_t val = decode_uint16(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 2;
+ }
} else if (encode_mode == ENCODE_32) {
// 32 bits.
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
int32_t val = decode_uint32(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 4;
+ }
} else {
// 64 bits.
ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA);
int64_t val = decode_uint64(buf);
r_variant = val;
- if (r_len)
+ if (r_len) {
(*r_len) += 8;
+ }
}
} break;
default:
Error err = decode_variant(r_variant, p_buffer, p_len, r_len, allow_object_decoding);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
}
return OK;
}
void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount) {
-
ERR_FAIL_COND_MSG(network_peer.is_null(), "Attempt to remote call/set when networking is not active in SceneTree.");
ERR_FAIL_COND_MSG(network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_CONNECTING, "Attempt to remote call/set when networking is not connected yet in SceneTree.");
@@ -840,7 +834,6 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
}
if (p_set) {
-
// Take the rpc property ID
uint16_t property_id = p_from->get_node_rset_property_id(p_name);
if (property_id == UINT16_MAX && p_from->get_script_instance()) {
@@ -933,7 +926,6 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
network_peer->set_transfer_mode(p_unreliable ? NetworkedMultiplayerPeer::TRANSFER_MODE_UNRELIABLE : NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
if (has_all_peers) {
-
// They all have verified paths, so send fast.
network_peer->set_target_peer(p_to); // To all of you.
network_peer->put_packet(packet_cache.ptr(), ofs); // A message with love.
@@ -950,12 +942,13 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
encode_cstring(pname.get_data(), &(packet_cache.write[ofs]));
for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {
-
- if (p_to < 0 && E->get() == -p_to)
+ if (p_to < 0 && E->get() == -p_to) {
continue; // Continue, excluded.
+ }
- if (p_to > 0 && E->get() != p_to)
+ if (p_to > 0 && E->get() != p_to) {
continue; // Continue, not for this peer.
+ }
Map<int, bool>::Element *F = psc->confirmed_peers.find(E->get());
ERR_CONTINUE(!F); // Should never happen.
@@ -997,22 +990,18 @@ void MultiplayerAPI::_del_peer(int p_id) {
}
void MultiplayerAPI::_connected_to_server() {
-
emit_signal("connected_to_server");
}
void MultiplayerAPI::_connection_failed() {
-
emit_signal("connection_failed");
}
void MultiplayerAPI::_server_disconnected() {
-
emit_signal("server_disconnected");
}
void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
-
ERR_FAIL_COND_MSG(!network_peer.is_valid(), "Trying to call an RPC while no network peer is active.");
ERR_FAIL_COND_MSG(!p_node->is_inside_tree(), "Trying to call an RPC on a node which is not inside SceneTree.");
ERR_FAIL_COND_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, "Trying to call an RPC via a network peer which is not connected.");
@@ -1039,7 +1028,6 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
}
if (!skip_rpc) {
-
#ifdef DEBUG_ENABLED
_profile_node_data("out_rpc", p_node->get_instance_id());
#endif
@@ -1080,7 +1068,6 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
}
void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value) {
-
ERR_FAIL_COND_MSG(!network_peer.is_valid(), "Trying to RSET while no network peer is active.");
ERR_FAIL_COND_MSG(!p_node->is_inside_tree(), "Trying to RSET on a node which is not inside SceneTree.");
ERR_FAIL_COND_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, "Trying to send an RSET via a network peer which is not connected.");
@@ -1145,7 +1132,6 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
}
Error MultiplayerAPI::send_bytes(Vector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
-
ERR_FAIL_COND_V_MSG(p_data.size() < 1, ERR_INVALID_DATA, "Trying to send an empty raw packet.");
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), ERR_UNCONFIGURED, "Trying to send a raw packet while no network peer is active.");
ERR_FAIL_COND_V_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a network peer which is not connected.");
@@ -1162,7 +1148,6 @@ Error MultiplayerAPI::send_bytes(Vector<uint8_t> p_data, int p_to, NetworkedMult
}
void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_packet_len) {
-
ERR_FAIL_COND_MSG(p_packet_len < 2, "Invalid packet received. Size too small.");
Vector<uint8_t> out;
@@ -1176,32 +1161,27 @@ void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_pac
}
int MultiplayerAPI::get_network_unique_id() const {
-
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), 0, "No network peer is assigned. Unable to get unique network ID.");
return network_peer->get_unique_id();
}
bool MultiplayerAPI::is_network_server() const {
-
// XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier?
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. I can't be a server.");
return network_peer->is_server();
}
void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) {
-
ERR_FAIL_COND_MSG(!network_peer.is_valid(), "No network peer is assigned. Unable to set 'refuse_new_connections'.");
network_peer->set_refuse_new_connections(p_refuse);
}
bool MultiplayerAPI::is_refusing_new_network_connections() const {
-
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), false, "No network peer is assigned. Unable to get 'refuse_new_connections'.");
return network_peer->is_refusing_new_connections();
}
Vector<int> MultiplayerAPI::get_network_connected_peers() const {
-
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), Vector<int>(), "No network peer is assigned. Assume no peers are connected.");
Vector<int> ret;
@@ -1213,12 +1193,10 @@ Vector<int> MultiplayerAPI::get_network_connected_peers() const {
}
void MultiplayerAPI::set_allow_object_decoding(bool p_enable) {
-
allow_object_decoding = p_enable;
}
bool MultiplayerAPI::is_object_decoding_allowed() const {
-
return allow_object_decoding;
}
@@ -1261,10 +1239,7 @@ void MultiplayerAPI::_bind_methods() {
BIND_ENUM_CONSTANT(RPC_MODE_PUPPETSYNC);
}
-MultiplayerAPI::MultiplayerAPI() :
- allow_object_decoding(false) {
- rpc_sender_id = 0;
- root_node = nullptr;
+MultiplayerAPI::MultiplayerAPI() {
clear();
}
diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h
index 4eb4a53e99..06eab7796c 100644
--- a/core/io/multiplayer_api.h
+++ b/core/io/multiplayer_api.h
@@ -35,7 +35,6 @@
#include "core/reference.h"
class MultiplayerAPI : public Reference {
-
GDCLASS(MultiplayerAPI, Reference);
private:
@@ -56,14 +55,14 @@ private:
};
Ref<NetworkedMultiplayerPeer> network_peer;
- int rpc_sender_id;
+ int rpc_sender_id = 0;
Set<int> connected_peers;
HashMap<NodePath, PathSentCache> path_send_cache;
Map<int, PathGetCache> path_get_cache;
int last_send_cache_id;
Vector<uint8_t> packet_cache;
- Node *root_node;
- bool allow_object_decoding;
+ Node *root_node = nullptr;
+ bool allow_object_decoding = false;
protected:
static void _bind_methods();
diff --git a/core/io/net_socket.cpp b/core/io/net_socket.cpp
index 838c674cec..130a2e245e 100644
--- a/core/io/net_socket.cpp
+++ b/core/io/net_socket.cpp
@@ -33,9 +33,9 @@
NetSocket *(*NetSocket::_create)() = nullptr;
NetSocket *NetSocket::create() {
-
- if (_create)
+ if (_create) {
return _create();
+ }
ERR_PRINT("Unable to create network socket, platform not supported");
return nullptr;
diff --git a/core/io/net_socket.h b/core/io/net_socket.h
index 376fd87a27..746945eced 100644
--- a/core/io/net_socket.h
+++ b/core/io/net_socket.h
@@ -35,7 +35,6 @@
#include "core/reference.h"
class NetSocket : public Reference {
-
protected:
static NetSocket *(*_create)();
diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp
index b2f810d212..f521f2bb79 100644
--- a/core/io/networked_multiplayer_peer.cpp
+++ b/core/io/networked_multiplayer_peer.cpp
@@ -31,7 +31,6 @@
#include "networked_multiplayer_peer.h"
void NetworkedMultiplayerPeer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_transfer_mode", "mode"), &NetworkedMultiplayerPeer::set_transfer_mode);
ClassDB::bind_method(D_METHOD("get_transfer_mode"), &NetworkedMultiplayerPeer::get_transfer_mode);
ClassDB::bind_method(D_METHOD("set_target_peer", "id"), &NetworkedMultiplayerPeer::set_target_peer);
@@ -66,6 +65,3 @@ void NetworkedMultiplayerPeer::_bind_methods() {
ADD_SIGNAL(MethodInfo("connection_succeeded"));
ADD_SIGNAL(MethodInfo("connection_failed"));
}
-
-NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() {
-}
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
index c1f1924051..dc76237f45 100644
--- a/core/io/networked_multiplayer_peer.h
+++ b/core/io/networked_multiplayer_peer.h
@@ -34,7 +34,6 @@
#include "core/io/packet_peer.h"
class NetworkedMultiplayerPeer : public PacketPeer {
-
GDCLASS(NetworkedMultiplayerPeer, PacketPeer);
protected:
@@ -74,7 +73,7 @@ public:
virtual ConnectionStatus get_connection_status() const = 0;
- NetworkedMultiplayerPeer();
+ NetworkedMultiplayerPeer() {}
};
VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode)
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 38abb5c0d6..dacd548a3e 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -35,13 +35,7 @@
/* helpers / binders */
-PacketPeer::PacketPeer() :
- last_get_error(OK),
- encode_buffer_max_size(8 * 1024 * 1024) {
-}
-
void PacketPeer::set_encode_buffer_max_size(int p_max_size) {
-
ERR_FAIL_COND_MSG(p_max_size < 1024, "Max encode buffer must be at least 1024 bytes");
ERR_FAIL_COND_MSG(p_max_size > 256 * 1024 * 1024, "Max encode buffer cannot exceed 256 MiB");
encode_buffer_max_size = next_power_of_2(p_max_size);
@@ -49,59 +43,61 @@ void PacketPeer::set_encode_buffer_max_size(int p_max_size) {
}
int PacketPeer::get_encode_buffer_max_size() const {
-
return encode_buffer_max_size;
}
Error PacketPeer::get_packet_buffer(Vector<uint8_t> &r_buffer) {
-
const uint8_t *buffer;
int buffer_size;
Error err = get_packet(&buffer, buffer_size);
- if (err)
+ if (err) {
return err;
+ }
r_buffer.resize(buffer_size);
- if (buffer_size == 0)
+ if (buffer_size == 0) {
return OK;
+ }
uint8_t *w = r_buffer.ptrw();
- for (int i = 0; i < buffer_size; i++)
+ for (int i = 0; i < buffer_size; i++) {
w[i] = buffer[i];
+ }
return OK;
}
Error PacketPeer::put_packet_buffer(const Vector<uint8_t> &p_buffer) {
-
int len = p_buffer.size();
- if (len == 0)
+ if (len == 0) {
return OK;
+ }
const uint8_t *r = p_buffer.ptr();
return put_packet(&r[0], len);
}
Error PacketPeer::get_var(Variant &r_variant, bool p_allow_objects) {
-
const uint8_t *buffer;
int buffer_size;
Error err = get_packet(&buffer, buffer_size);
- if (err)
+ if (err) {
return err;
+ }
return decode_variant(r_variant, buffer, buffer_size, nullptr, p_allow_objects);
}
Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) {
-
int len;
Error err = encode_variant(p_packet, nullptr, len, p_full_objects); // compute len first
- if (err)
+ if (err) {
return err;
+ }
- if (len == 0)
+ if (len == 0) {
return OK;
+ }
ERR_FAIL_COND_V_MSG(len > encode_buffer_max_size, ERR_OUT_OF_MEMORY, "Failed to encode variant, encode size is bigger then encode_buffer_max_size. Consider raising it via 'set_encode_buffer_max_size'.");
@@ -128,20 +124,18 @@ Variant PacketPeer::_bnd_get_var(bool p_allow_objects) {
Error PacketPeer::_put_packet(const Vector<uint8_t> &p_buffer) {
return put_packet_buffer(p_buffer);
}
-Vector<uint8_t> PacketPeer::_get_packet() {
+Vector<uint8_t> PacketPeer::_get_packet() {
Vector<uint8_t> raw;
last_get_error = get_packet_buffer(raw);
return raw;
}
Error PacketPeer::_get_packet_error() const {
-
return last_get_error;
}
void PacketPeer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_var", "allow_objects"), &PacketPeer::_bnd_get_var, DEFVAL(false));
ClassDB::bind_method(D_METHOD("put_var", "var", "full_objects"), &PacketPeer::put_var, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_packet"), &PacketPeer::_get_packet);
@@ -153,18 +147,16 @@ void PacketPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_encode_buffer_max_size", "max_size"), &PacketPeer::set_encode_buffer_max_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "encode_buffer_max_size"), "set_encode_buffer_max_size", "get_encode_buffer_max_size");
-};
+}
/***************/
void PacketPeerStream::_set_stream_peer(REF p_peer) {
-
ERR_FAIL_COND_MSG(p_peer.is_null(), "It's not a reference to a valid Resource object.");
set_stream_peer(p_peer);
}
void PacketPeerStream::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::set_stream_peer);
ClassDB::bind_method(D_METHOD("get_stream_peer"), &PacketPeerStream::get_stream_peer);
ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
@@ -178,16 +170,17 @@ void PacketPeerStream::_bind_methods() {
}
Error PacketPeerStream::_poll_buffer() const {
-
ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED);
int read = 0;
ERR_FAIL_COND_V(input_buffer.size() < ring_buffer.space_left(), ERR_UNAVAILABLE);
Error err = peer->get_partial_data(input_buffer.ptrw(), ring_buffer.space_left(), read);
- if (err)
+ if (err) {
return err;
- if (read == 0)
+ }
+ if (read == 0) {
return OK;
+ }
int w = ring_buffer.write(&input_buffer[0], read);
ERR_FAIL_COND_V(w != read, ERR_BUG);
@@ -196,7 +189,6 @@ Error PacketPeerStream::_poll_buffer() const {
}
int PacketPeerStream::get_available_packet_count() const {
-
_poll_buffer();
uint32_t remaining = ring_buffer.data_left();
@@ -205,14 +197,14 @@ int PacketPeerStream::get_available_packet_count() const {
int count = 0;
while (remaining >= 4) {
-
uint8_t lbuf[4];
ring_buffer.copy(lbuf, ofs, 4);
uint32_t len = decode_uint32(lbuf);
remaining -= 4;
ofs += 4;
- if (len > remaining)
+ if (len > remaining) {
break;
+ }
remaining -= len;
ofs += len;
count++;
@@ -222,7 +214,6 @@ int PacketPeerStream::get_available_packet_count() const {
}
Error PacketPeerStream::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
-
ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED);
_poll_buffer();
@@ -244,50 +235,48 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer, int &r_buffer_size)
}
Error PacketPeerStream::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
-
ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED);
Error err = _poll_buffer(); //won't hurt to poll here too
- if (err)
+ if (err) {
return err;
+ }
- if (p_buffer_size == 0)
+ if (p_buffer_size == 0) {
return OK;
+ }
ERR_FAIL_COND_V(p_buffer_size < 0, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_buffer_size + 4 > output_buffer.size(), ERR_INVALID_PARAMETER);
encode_uint32(p_buffer_size, output_buffer.ptrw());
uint8_t *dst = &output_buffer.write[4];
- for (int i = 0; i < p_buffer_size; i++)
+ for (int i = 0; i < p_buffer_size; i++) {
dst[i] = p_buffer[i];
+ }
return peer->put_data(&output_buffer[0], p_buffer_size + 4);
}
int PacketPeerStream::get_max_packet_size() const {
-
return output_buffer.size();
}
void PacketPeerStream::set_stream_peer(const Ref<StreamPeer> &p_peer) {
-
//ERR_FAIL_COND(p_peer.is_null());
if (p_peer.ptr() != peer.ptr()) {
ring_buffer.advance_read(ring_buffer.data_left()); // reset the ring buffer
- };
+ }
peer = p_peer;
}
Ref<StreamPeer> PacketPeerStream::get_stream_peer() const {
-
return peer;
}
void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
-
ERR_FAIL_COND_MSG(p_max_size < 0, "Max size of input buffer size cannot be smaller than 0.");
//warning may lose packets
ERR_FAIL_COND_MSG(ring_buffer.data_left(), "Buffer in use, resizing would cause loss of data.");
@@ -296,22 +285,18 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
}
int PacketPeerStream::get_input_buffer_max_size() const {
-
return input_buffer.size() - 4;
}
void PacketPeerStream::set_output_buffer_max_size(int p_max_size) {
-
output_buffer.resize(next_power_of_2(p_max_size + 4));
}
int PacketPeerStream::get_output_buffer_max_size() const {
-
return output_buffer.size() - 4;
}
PacketPeerStream::PacketPeerStream() {
-
int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2");
ring_buffer.resize(rbsize);
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 62144259cc..f0ba50087f 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -36,7 +36,6 @@
#include "core/ring_buffer.h"
class PacketPeer : public Reference {
-
GDCLASS(PacketPeer, Reference);
Variant _bnd_get_var(bool p_allow_objects = false);
@@ -47,9 +46,9 @@ class PacketPeer : public Reference {
Vector<uint8_t> _get_packet();
Error _get_packet_error() const;
- mutable Error last_get_error;
+ mutable Error last_get_error = OK;
- int encode_buffer_max_size;
+ int encode_buffer_max_size = 8 * 1024 * 1024;
Vector<uint8_t> encode_buffer;
public:
@@ -70,12 +69,11 @@ public:
void set_encode_buffer_max_size(int p_max_size);
int get_encode_buffer_max_size() const;
- PacketPeer();
+ PacketPeer() {}
~PacketPeer() {}
};
class PacketPeerStream : public PacketPeer {
-
GDCLASS(PacketPeerStream, PacketPeer);
//the way the buffers work sucks, will change later
diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp
index 6da115eed2..632f86a9f6 100644
--- a/core/io/packet_peer_dtls.cpp
+++ b/core/io/packet_peer_dtls.cpp
@@ -36,8 +36,10 @@ PacketPeerDTLS *(*PacketPeerDTLS::_create)() = nullptr;
bool PacketPeerDTLS::available = false;
PacketPeerDTLS *PacketPeerDTLS::create() {
-
- return _create();
+ if (_create) {
+ return _create();
+ }
+ return nullptr;
}
bool PacketPeerDTLS::is_available() {
@@ -45,7 +47,6 @@ bool PacketPeerDTLS::is_available() {
}
void PacketPeerDTLS::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("poll"), &PacketPeerDTLS::poll);
ClassDB::bind_method(D_METHOD("connect_to_peer", "packet_peer", "validate_certs", "for_hostname", "valid_certificate"), &PacketPeerDTLS::connect_to_peer, DEFVAL(true), DEFVAL(String()), DEFVAL(Ref<X509Certificate>()));
ClassDB::bind_method(D_METHOD("get_status"), &PacketPeerDTLS::get_status);
@@ -57,6 +58,3 @@ void PacketPeerDTLS::_bind_methods() {
BIND_ENUM_CONSTANT(STATUS_ERROR);
BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH);
}
-
-PacketPeerDTLS::PacketPeerDTLS() {
-}
diff --git a/core/io/packet_peer_dtls.h b/core/io/packet_peer_dtls.h
index 4f9f4535bc..c2ff4e1a7f 100644
--- a/core/io/packet_peer_dtls.h
+++ b/core/io/packet_peer_dtls.h
@@ -60,7 +60,7 @@ public:
static PacketPeerDTLS *create();
static bool is_available();
- PacketPeerDTLS();
+ PacketPeerDTLS() {}
};
VARIANT_ENUM_CAST(PacketPeerDTLS::Status);
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index f800ffc3db..862fca96fc 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -33,18 +33,17 @@
#include "core/io/ip.h"
void PacketPeerUDP::set_blocking_mode(bool p_enable) {
-
blocking = p_enable;
}
void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) {
broadcast = p_enabled;
- if (_sock.is_valid() && _sock->is_open())
+ if (_sock.is_valid() && _sock->is_open()) {
_sock->set_broadcasting_enabled(p_enabled);
+ }
}
Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_if_name) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!p_multi_address.is_valid(), ERR_INVALID_PARAMETER);
@@ -59,26 +58,24 @@ Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_i
}
Error PacketPeerUDP::leave_multicast_group(IP_Address p_multi_address, String p_if_name) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!_sock->is_open(), ERR_UNCONFIGURED);
return _sock->leave_multicast_group(p_multi_address, p_if_name);
}
String PacketPeerUDP::_get_packet_ip() const {
-
return get_packet_address();
}
Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {
-
IP_Address ip;
if (p_address.is_valid_ip_address()) {
ip = p_address;
} else {
ip = IP::get_singleton()->resolve_hostname(p_address);
- if (!ip.is_valid())
+ if (!ip.is_valid()) {
return ERR_CANT_RESOLVE;
+ }
}
set_dest_address(ip, p_port);
@@ -86,22 +83,23 @@ Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {
}
int PacketPeerUDP::get_available_packet_count() const {
-
// TODO we should deprecate this, and expose poll instead!
Error err = const_cast<PacketPeerUDP *>(this)->_poll();
- if (err != OK)
+ if (err != OK) {
return -1;
+ }
return queue_count;
}
Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
-
Error err = _poll();
- if (err != OK)
+ if (err != OK) {
return err;
- if (queue_count == 0)
+ }
+ if (queue_count == 0) {
return ERR_UNAVAILABLE;
+ }
uint32_t size = 0;
uint8_t ipv6[16];
@@ -117,7 +115,6 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
}
Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!peer_addr.is_valid(), ERR_UNCONFIGURED);
@@ -139,10 +136,11 @@ Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
err = _sock->sendto(p_buffer, p_buffer_size, sent, peer_addr, peer_port);
}
if (err != OK) {
- if (err != ERR_BUSY)
+ if (err != ERR_BUSY) {
return FAILED;
- else if (!blocking)
+ } else if (!blocking) {
return ERR_BUSY;
+ }
// Keep trying to send full packet
continue;
}
@@ -154,12 +152,10 @@ Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
}
int PacketPeerUDP::get_max_packet_size() const {
-
return 512; // uhm maybe not
}
Error PacketPeerUDP::listen(int p_port, const IP_Address &p_bind_address, int p_recv_buffer_size) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
@@ -167,13 +163,15 @@ Error PacketPeerUDP::listen(int p_port, const IP_Address &p_bind_address, int p_
Error err;
IP::Type ip_type = IP::TYPE_ANY;
- if (p_bind_address.is_valid())
+ if (p_bind_address.is_valid()) {
ip_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+ }
err = _sock->open(NetSocket::TYPE_UDP, ip_type);
- if (err != OK)
+ if (err != OK) {
return ERR_CANT_CREATE;
+ }
_sock->set_blocking_enabled(false);
_sock->set_reuse_address_enabled(true);
@@ -245,22 +243,20 @@ bool PacketPeerUDP::is_connected_to_host() const {
}
void PacketPeerUDP::close() {
-
- if (_sock.is_valid())
+ if (_sock.is_valid()) {
_sock->close();
+ }
rb.resize(16);
queue_count = 0;
connected = false;
}
Error PacketPeerUDP::wait() {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
return _sock->poll(NetSocket::POLL_TYPE_IN, -1);
}
Error PacketPeerUDP::_poll() {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
if (!_sock->is_open()) {
@@ -282,8 +278,9 @@ Error PacketPeerUDP::_poll() {
}
if (err != OK) {
- if (err == ERR_BUSY)
+ if (err == ERR_BUSY) {
break;
+ }
return FAILED;
}
@@ -304,30 +301,26 @@ Error PacketPeerUDP::_poll() {
return OK;
}
-bool PacketPeerUDP::is_listening() const {
+bool PacketPeerUDP::is_listening() const {
return _sock.is_valid() && _sock->is_open();
}
IP_Address PacketPeerUDP::get_packet_address() const {
-
return packet_ip;
}
int PacketPeerUDP::get_packet_port() const {
-
return packet_port;
}
void PacketPeerUDP::set_dest_address(const IP_Address &p_address, int p_port) {
-
ERR_FAIL_COND_MSG(connected, "Destination address cannot be set for connected sockets");
peer_addr = p_address;
peer_port = p_port;
}
void PacketPeerUDP::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
ClassDB::bind_method(D_METHOD("close"), &PacketPeerUDP::close);
ClassDB::bind_method(D_METHOD("wait"), &PacketPeerUDP::wait);
@@ -343,17 +336,10 @@ void PacketPeerUDP::_bind_methods() {
}
PacketPeerUDP::PacketPeerUDP() :
- packet_port(0),
- queue_count(0),
- peer_port(0),
- connected(false),
- blocking(true),
- broadcast(false),
_sock(Ref<NetSocket>(NetSocket::create())) {
rb.resize(16);
}
PacketPeerUDP::~PacketPeerUDP() {
-
close();
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index b5a9fc9ec3..23fc5460a6 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -47,14 +47,14 @@ protected:
uint8_t recv_buffer[PACKET_BUFFER_SIZE];
uint8_t packet_buffer[PACKET_BUFFER_SIZE];
IP_Address packet_ip;
- int packet_port;
- int queue_count;
+ int packet_port = 0;
+ int queue_count = 0;
IP_Address peer_addr;
- int peer_port;
- bool connected;
- bool blocking;
- bool broadcast;
+ int peer_port = 0;
+ bool connected = false;
+ bool blocking = true;
+ bool broadcast = false;
Ref<NetSocket> _sock;
static void _bind_methods();
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp
index 5c4b3379ee..374b2a5e07 100644
--- a/core/io/pck_packer.cpp
+++ b/core/io/pck_packer.cpp
@@ -35,34 +35,31 @@
#include "core/version.h"
static uint64_t _align(uint64_t p_n, int p_alignment) {
-
- if (p_alignment == 0)
+ if (p_alignment == 0) {
return p_n;
+ }
uint64_t rest = p_n % p_alignment;
- if (rest == 0)
+ if (rest == 0) {
return p_n;
- else
+ } else {
return p_n + (p_alignment - rest);
-};
+ }
+}
static void _pad(FileAccess *p_file, int p_bytes) {
-
for (int i = 0; i < p_bytes; i++) {
-
p_file->store_8(0);
- };
-};
+ }
+}
void PCKPacker::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("pck_start", "pck_name", "alignment"), &PCKPacker::pck_start, DEFVAL(0));
ClassDB::bind_method(D_METHOD("add_file", "pck_path", "source_path"), &PCKPacker::add_file);
ClassDB::bind_method(D_METHOD("flush", "verbose"), &PCKPacker::flush, DEFVAL(false));
-};
+}
Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
-
if (file != nullptr) {
memdelete(file);
}
@@ -80,21 +77,19 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
file->store_32(VERSION_PATCH);
for (int i = 0; i < 16; i++) {
-
file->store_32(0); // reserved
- };
+ }
files.clear();
return OK;
-};
+}
Error PCKPacker::add_file(const String &p_file, const String &p_src) {
-
FileAccess *f = FileAccess::open(p_src, FileAccess::READ);
if (!f) {
return ERR_FILE_CANT_OPEN;
- };
+ }
File pf;
pf.path = p_file;
@@ -108,10 +103,9 @@ Error PCKPacker::add_file(const String &p_file, const String &p_src) {
memdelete(f);
return OK;
-};
+}
Error PCKPacker::flush(bool p_verbose) {
-
ERR_FAIL_COND_V_MSG(!file, ERR_INVALID_PARAMETER, "File must be opened before use.");
// write the index
@@ -119,7 +113,6 @@ Error PCKPacker::flush(bool p_verbose) {
file->store_32(files.size());
for (int i = 0; i < files.size(); i++) {
-
file->store_pascal_string(files[i].path);
files.write[i].offset_offset = file->get_position();
file->store_64(0); // offset
@@ -130,7 +123,7 @@ Error PCKPacker::flush(bool p_verbose) {
file->store_32(0);
file->store_32(0);
file->store_32(0);
- };
+ }
uint64_t ofs = file->get_position();
ofs = _align(ofs, alignment);
@@ -142,15 +135,13 @@ Error PCKPacker::flush(bool p_verbose) {
int count = 0;
for (int i = 0; i < files.size(); i++) {
-
FileAccess *src = FileAccess::open(files[i].src_path, FileAccess::READ);
uint64_t to_write = files[i].size;
while (to_write > 0) {
-
int read = src->get_buffer(buf, MIN(to_write, buf_max));
file->store_buffer(buf, read);
to_write -= read;
- };
+ }
uint64_t pos = file->get_position();
file->seek(files[i].offset_offset); // go back to store the file's offset
@@ -167,27 +158,23 @@ Error PCKPacker::flush(bool p_verbose) {
if (count % 100 == 0) {
printf("%i/%i (%.2f)\r", count, files.size(), float(count) / files.size() * 100);
fflush(stdout);
- };
- };
- };
+ }
+ }
+ }
- if (p_verbose)
+ if (p_verbose) {
printf("\n");
+ }
file->close();
memdelete_arr(buf);
return OK;
-};
-
-PCKPacker::PCKPacker() {
-
- file = nullptr;
-};
+}
PCKPacker::~PCKPacker() {
if (file != nullptr) {
memdelete(file);
- };
+ }
file = nullptr;
-};
+}
diff --git a/core/io/pck_packer.h b/core/io/pck_packer.h
index 6058de8345..2929967a68 100644
--- a/core/io/pck_packer.h
+++ b/core/io/pck_packer.h
@@ -36,16 +36,14 @@
class FileAccess;
class PCKPacker : public Reference {
-
GDCLASS(PCKPacker, Reference);
- FileAccess *file;
+ FileAccess *file = nullptr;
int alignment;
static void _bind_methods();
struct File {
-
String path;
String src_path;
int size;
@@ -58,7 +56,7 @@ public:
Error add_file(const String &p_file, const String &p_src);
Error flush(bool p_verbose = false);
- PCKPacker();
+ PCKPacker() {}
~PCKPacker();
};
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index e0fea143bb..5097f6d98b 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -94,24 +94,24 @@ enum {
};
void ResourceLoaderBinary::_advance_padding(uint32_t p_len) {
-
uint32_t extra = 4 - (p_len % 4);
if (extra < 4) {
- for (uint32_t i = 0; i < extra; i++)
+ for (uint32_t i = 0; i < extra; i++) {
f->get_8(); //pad to 32
+ }
}
}
StringName ResourceLoaderBinary::_get_string() {
-
uint32_t id = f->get_32();
if (id & 0x80000000) {
uint32_t len = id & 0x7FFFFFFF;
if ((int)len > str_buf.size()) {
str_buf.resize(len);
}
- if (len == 0)
+ if (len == 0) {
return StringName();
+ }
f->get_buffer((uint8_t *)&str_buf[0], len);
String s;
s.parse_utf8(&str_buf[0]);
@@ -122,42 +122,32 @@ StringName ResourceLoaderBinary::_get_string() {
}
Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
-
uint32_t type = f->get_32();
print_bl("find property of type: " + itos(type));
switch (type) {
-
case VARIANT_NIL: {
-
r_v = Variant();
} break;
case VARIANT_BOOL: {
-
r_v = bool(f->get_32());
} break;
case VARIANT_INT: {
-
r_v = int(f->get_32());
} break;
case VARIANT_INT64: {
-
r_v = int64_t(f->get_64());
} break;
case VARIANT_FLOAT: {
-
r_v = f->get_real();
} break;
case VARIANT_DOUBLE: {
-
r_v = f->get_double();
} break;
case VARIANT_STRING: {
-
r_v = get_unicode_string();
} break;
case VARIANT_VECTOR2: {
-
Vector2 v;
v.x = f->get_real();
v.y = f->get_real();
@@ -165,7 +155,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_VECTOR2I: {
-
Vector2i v;
v.x = f->get_32();
v.y = f->get_32();
@@ -173,7 +162,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_RECT2: {
-
Rect2 v;
v.position.x = f->get_real();
v.position.y = f->get_real();
@@ -183,7 +171,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_RECT2I: {
-
Rect2i v;
v.position.x = f->get_32();
v.position.y = f->get_32();
@@ -193,7 +180,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_VECTOR3: {
-
Vector3 v;
v.x = f->get_real();
v.y = f->get_real();
@@ -201,7 +187,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = v;
} break;
case VARIANT_VECTOR3I: {
-
Vector3i v;
v.x = f->get_32();
v.y = f->get_32();
@@ -209,7 +194,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = v;
} break;
case VARIANT_PLANE: {
-
Plane v;
v.normal.x = f->get_real();
v.normal.y = f->get_real();
@@ -227,7 +211,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_AABB: {
-
AABB v;
v.position.x = f->get_real();
v.position.y = f->get_real();
@@ -239,7 +222,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_MATRIX32: {
-
Transform2D v;
v.elements[0].x = f->get_real();
v.elements[0].y = f->get_real();
@@ -251,7 +233,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_MATRIX3: {
-
Basis v;
v.elements[0].x = f->get_real();
v.elements[0].y = f->get_real();
@@ -266,7 +247,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_TRANSFORM: {
-
Transform v;
v.basis.elements[0].x = f->get_real();
v.basis.elements[0].y = f->get_real();
@@ -283,7 +263,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = v;
} break;
case VARIANT_COLOR: {
-
Color v;
v.r = f->get_real();
v.g = f->get_real();
@@ -293,12 +272,10 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_STRING_NAME: {
-
r_v = StringName(get_unicode_string());
} break;
case VARIANT_NODE_PATH: {
-
Vector<StringName> names;
Vector<StringName> subnames;
bool absolute;
@@ -311,10 +288,12 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
subname_count += 1; // has a property field, so we should count it as well
}
- for (int i = 0; i < name_count; i++)
+ for (int i = 0; i < name_count; i++) {
names.push_back(_get_string());
- for (uint32_t i = 0; i < subname_count; i++)
+ }
+ for (uint32_t i = 0; i < subname_count; i++) {
subnames.push_back(_get_string());
+ }
NodePath np = NodePath(names, subnames, absolute);
@@ -322,15 +301,12 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_RID: {
-
r_v = f->get_32();
} break;
case VARIANT_OBJECT: {
-
uint32_t objtype = f->get_32();
switch (objtype) {
-
case OBJECT_EMPTY: {
//do none
@@ -384,7 +360,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
WARN_PRINT("Broken external resource! (index out of size)");
r_v = Variant();
} else {
-
if (external_resources[erindex].cache.is_null()) {
//cache not here yet, wait for it?
if (use_sub_threads) {
@@ -393,10 +368,8 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
if (err != OK || external_resources[erindex].cache.is_null()) {
if (!ResourceLoader::get_abort_on_missing_resources()) {
-
ResourceLoader::notify_dependency_error(local_path, external_resources[erindex].path, external_resources[erindex].type);
} else {
-
error = ERR_FILE_MISSING_DEPENDENCIES;
ERR_FAIL_V_MSG(error, "Can't load dependency: " + external_resources[erindex].path + ".");
}
@@ -409,23 +382,19 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
default: {
-
ERR_FAIL_V(ERR_FILE_CORRUPT);
} break;
}
} break;
case VARIANT_CALLABLE: {
-
r_v = Callable();
} break;
case VARIANT_SIGNAL: {
-
r_v = Signal();
} break;
case VARIANT_DICTIONARY: {
-
uint32_t len = f->get_32();
Dictionary d; //last bit means shared
len &= 0x7FFFFFFF;
@@ -441,7 +410,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = d;
} break;
case VARIANT_ARRAY: {
-
uint32_t len = f->get_32();
Array a; //last bit means shared
len &= 0x7FFFFFFF;
@@ -456,7 +424,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_RAW_ARRAY: {
-
uint32_t len = f->get_32();
Vector<uint8_t> array;
@@ -469,7 +436,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_INT32_ARRAY: {
-
uint32_t len = f->get_32();
Vector<int32_t> array;
@@ -480,7 +446,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len; i++) {
-
ptr[i] = BSWAP32(ptr[i]);
}
}
@@ -490,7 +455,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
case VARIANT_INT64_ARRAY: {
-
uint32_t len = f->get_32();
Vector<int64_t> array;
@@ -501,7 +465,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint64_t *ptr = (uint64_t *)w.ptr();
for (int i = 0; i < len; i++) {
-
ptr[i] = BSWAP64(ptr[i]);
}
}
@@ -511,7 +474,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
case VARIANT_FLOAT32_ARRAY: {
-
uint32_t len = f->get_32();
Vector<float> array;
@@ -522,7 +484,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len; i++) {
-
ptr[i] = BSWAP32(ptr[i]);
}
}
@@ -532,7 +493,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
case VARIANT_FLOAT64_ARRAY: {
-
uint32_t len = f->get_32();
Vector<double> array;
@@ -543,7 +503,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint64_t *ptr = (uint64_t *)w.ptr();
for (int i = 0; i < len; i++) {
-
ptr[i] = BSWAP64(ptr[i]);
}
}
@@ -553,19 +512,18 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
r_v = array;
} break;
case VARIANT_STRING_ARRAY: {
-
uint32_t len = f->get_32();
Vector<String> array;
array.resize(len);
String *w = array.ptrw();
- for (uint32_t i = 0; i < len; i++)
+ for (uint32_t i = 0; i < len; i++) {
w[i] = get_unicode_string();
+ }
r_v = array;
} break;
case VARIANT_VECTOR2_ARRAY: {
-
uint32_t len = f->get_32();
Vector<Vector2> array;
@@ -577,7 +535,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len * 2; i++) {
-
ptr[i] = BSWAP32(ptr[i]);
}
}
@@ -592,7 +549,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_VECTOR3_ARRAY: {
-
uint32_t len = f->get_32();
Vector<Vector3> array;
@@ -604,7 +560,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len * 3; i++) {
-
ptr[i] = BSWAP32(ptr[i]);
}
}
@@ -619,7 +574,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_COLOR_ARRAY: {
-
uint32_t len = f->get_32();
Vector<Color> array;
@@ -631,7 +585,6 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
{
uint32_t *ptr = (uint32_t *)w.ptr();
for (int i = 0; i < len * 4; i++) {
-
ptr[i] = BSWAP32(ptr[i]);
}
}
@@ -653,23 +606,21 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
}
void ResourceLoaderBinary::set_local_path(const String &p_local_path) {
-
res_path = p_local_path;
}
Ref<Resource> ResourceLoaderBinary::get_resource() {
-
return resource;
}
-Error ResourceLoaderBinary::load() {
- if (error != OK)
+Error ResourceLoaderBinary::load() {
+ if (error != OK) {
return error;
+ }
int stage = 0;
for (int i = 0; i < external_resources.size(); i++) {
-
String path = external_resources[i].path;
if (remaps.has(path)) {
@@ -688,10 +639,8 @@ Error ResourceLoaderBinary::load() {
if (external_resources[i].cache.is_null()) {
if (!ResourceLoader::get_abort_on_missing_resources()) {
-
ResourceLoader::notify_dependency_error(local_path, path, external_resources[i].type);
} else {
-
error = ERR_FILE_MISSING_DEPENDENCIES;
ERR_FAIL_V_MSG(error, "Can't load dependency: " + path + ".");
}
@@ -701,10 +650,8 @@ Error ResourceLoaderBinary::load() {
Error err = ResourceLoader::load_threaded_request(path, external_resources[i].type, use_sub_threads, local_path);
if (err != OK) {
if (!ResourceLoader::get_abort_on_missing_resources()) {
-
ResourceLoader::notify_dependency_error(local_path, path, external_resources[i].type);
} else {
-
error = ERR_FILE_MISSING_DEPENDENCIES;
ERR_FAIL_V_MSG(error, "Can't load dependency: " + path + ".");
}
@@ -715,7 +662,6 @@ Error ResourceLoaderBinary::load() {
}
for (int i = 0; i < internal_resources.size(); i++) {
-
bool main = i == (internal_resources.size() - 1);
//maybe it is loaded already
@@ -723,7 +669,6 @@ Error ResourceLoaderBinary::load() {
int subindex = 0;
if (!main) {
-
path = internal_resources[i].path;
if (path.begins_with("local://")) {
@@ -733,7 +678,6 @@ Error ResourceLoaderBinary::load() {
}
if (!use_nocache) {
-
if (ResourceCache::has(path)) {
//already loaded, don't do anything
stage++;
@@ -742,9 +686,9 @@ Error ResourceLoaderBinary::load() {
}
}
} else {
-
- if (!use_nocache && !ResourceCache::has(res_path))
+ if (!use_nocache && !ResourceCache::has(res_path)) {
path = res_path;
+ }
}
uint64_t offset = internal_resources[i].offset;
@@ -783,7 +727,6 @@ Error ResourceLoaderBinary::load() {
//set properties
for (int j = 0; j < pc; j++) {
-
StringName name = _get_string();
if (name == StringName()) {
@@ -794,8 +737,9 @@ Error ResourceLoaderBinary::load() {
Variant value;
error = parse_variant(value);
- if (error)
+ if (error) {
return error;
+ }
res->set(name, value);
}
@@ -811,7 +755,6 @@ Error ResourceLoaderBinary::load() {
resource_cache.push_back(res);
if (main) {
-
f->close();
resource = res;
resource->set_as_translation_remapped(translation_remapped);
@@ -824,19 +767,16 @@ Error ResourceLoaderBinary::load() {
}
void ResourceLoaderBinary::set_translation_remapped(bool p_remapped) {
-
translation_remapped = p_remapped;
}
static void save_ustring(FileAccess *f, const String &p_string) {
-
CharString utf8 = p_string.utf8();
f->store_32(utf8.length() + 1);
f->store_buffer((const uint8_t *)utf8.get_data(), utf8.length() + 1);
}
static String get_ustring(FileAccess *f) {
-
int len = f->get_32();
Vector<char> str_buf;
str_buf.resize(len);
@@ -847,13 +787,13 @@ static String get_ustring(FileAccess *f) {
}
String ResourceLoaderBinary::get_unicode_string() {
-
int len = f->get_32();
if (len > str_buf.size()) {
str_buf.resize(len);
}
- if (len == 0)
+ if (len == 0) {
return String();
+ }
f->get_buffer((uint8_t *)&str_buf[0], len);
String s;
s.parse_utf8(&str_buf[0]);
@@ -861,13 +801,12 @@ String ResourceLoaderBinary::get_unicode_string() {
}
void ResourceLoaderBinary::get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types) {
-
open(p_f);
- if (error)
+ if (error) {
return;
+ }
for (int i = 0; i < external_resources.size(); i++) {
-
String dep = external_resources[i].path;
if (p_add_types && external_resources[i].type != String()) {
@@ -879,7 +818,6 @@ void ResourceLoaderBinary::get_dependencies(FileAccess *p_f, List<String> *p_dep
}
void ResourceLoaderBinary::open(FileAccess *p_f) {
-
error = OK;
f = p_f;
@@ -924,7 +862,6 @@ void ResourceLoaderBinary::open(FileAccess *p_f) {
print_bl("format: " + itos(ver_format));
if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
-
f->close();
ERR_FAIL_MSG("File format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path + ".");
}
@@ -934,13 +871,13 @@ void ResourceLoaderBinary::open(FileAccess *p_f) {
print_bl("type: " + type);
importmd_ofs = f->get_64();
- for (int i = 0; i < 14; i++)
+ for (int i = 0; i < 14; i++) {
f->get_32(); //skip a few reserved fields
+ }
uint32_t string_table_size = f->get_32();
string_map.resize(string_table_size);
for (uint32_t i = 0; i < string_table_size; i++) {
-
StringName s = get_unicode_string();
string_map.write[i] = s;
}
@@ -949,7 +886,6 @@ void ResourceLoaderBinary::open(FileAccess *p_f) {
uint32_t ext_resources_size = f->get_32();
for (uint32_t i = 0; i < ext_resources_size; i++) {
-
ExtResource er;
er.type = get_unicode_string();
@@ -962,7 +898,6 @@ void ResourceLoaderBinary::open(FileAccess *p_f) {
uint32_t int_resources_size = f->get_32();
for (uint32_t i = 0; i < int_resources_size; i++) {
-
IntResource ir;
ir.path = get_unicode_string();
ir.offset = f->get_64();
@@ -972,7 +907,6 @@ void ResourceLoaderBinary::open(FileAccess *p_f) {
print_bl("int resources: " + itos(int_resources_size));
if (f->eof_reached()) {
-
error = ERR_FILE_CORRUPT;
f->close();
ERR_FAIL_MSG("Premature end of file (EOF): " + local_path + ".");
@@ -980,7 +914,6 @@ void ResourceLoaderBinary::open(FileAccess *p_f) {
}
String ResourceLoaderBinary::recognize(FileAccess *p_f) {
-
error = OK;
f = p_f;
@@ -1014,7 +947,6 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) {
uint32_t ver_format = f->get_32();
if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
-
f->close();
return "";
}
@@ -1024,28 +956,16 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) {
return type;
}
-ResourceLoaderBinary::ResourceLoaderBinary() :
- translation_remapped(false),
- ver_format(0),
- f(nullptr),
- importmd_ofs(0),
- error(OK) {
-
- use_nocache = false;
- progress = nullptr;
- use_sub_threads = false;
-}
-
ResourceLoaderBinary::~ResourceLoaderBinary() {
-
- if (f)
+ if (f) {
memdelete(f);
+ }
}
RES ResourceFormatLoaderBinary::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)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -1075,7 +995,6 @@ RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_origi
}
void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
-
if (p_type == "") {
get_recognized_extensions(p_extensions);
return;
@@ -1091,8 +1010,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String
p_extensions->push_back(ext);
}
}
-void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_extensions) const {
List<String> extensions;
ClassDB::get_resource_base_extensions(&extensions);
extensions.sort();
@@ -1104,12 +1023,10 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten
}
bool ResourceFormatLoaderBinary::handles_type(const String &p_type) const {
-
return true; //handles all
}
void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_MSG(!f, "Cannot open file '" + p_path + "'.");
@@ -1121,7 +1038,6 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<Str
}
Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
//Error error=OK;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
@@ -1187,7 +1103,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
uint32_t ver_format = f->get_32();
if (ver_format < FORMAT_VERSION_CAN_RENAME_DEPS) {
-
memdelete(f);
memdelete(fw);
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -1219,7 +1134,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
}
if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
-
memdelete(f);
memdelete(fw);
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "File format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path + ".");
@@ -1248,7 +1162,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
fw->store_32(string_table_size);
for (uint32_t i = 0; i < string_table_size; i++) {
-
String s = get_ustring(f);
save_ustring(fw, s);
}
@@ -1257,7 +1170,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
uint32_t ext_resources_size = f->get_32();
fw->store_32(ext_resources_size);
for (uint32_t i = 0; i < ext_resources_size; i++) {
-
String type = get_ustring(f);
String path = get_ustring(f);
@@ -1288,7 +1200,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
fw->store_32(int_resources_size);
for (uint32_t i = 0; i < int_resources_size; i++) {
-
String path = get_ustring(f);
uint64_t offset = f->get_64();
save_ustring(fw, path);
@@ -1322,7 +1233,6 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
}
String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
return ""; //could not rwead
@@ -1341,36 +1251,30 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const
///////////////////////////////////////////////////////////
void ResourceFormatSaverBinaryInstance::_pad_buffer(FileAccess *f, int p_bytes) {
-
int extra = 4 - (p_bytes % 4);
if (extra < 4) {
- for (int i = 0; i < extra; i++)
+ for (int i = 0; i < extra; i++) {
f->store_8(0); //pad to 32
+ }
}
}
void ResourceFormatSaverBinaryInstance::_write_variant(const Variant &p_property, const PropertyInfo &p_hint) {
-
write_variant(f, p_property, resource_set, external_resources, string_map, p_hint);
}
void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Variant &p_property, Set<RES> &resource_set, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint) {
-
switch (p_property.get_type()) {
-
case Variant::NIL: {
-
f->store_32(VARIANT_NIL);
// don't store anything
} break;
case Variant::BOOL: {
-
f->store_32(VARIANT_BOOL);
bool val = p_property;
f->store_32(val);
} break;
case Variant::INT: {
-
int64_t val = p_property;
if (val > 0x7FFFFFFF || val < -(int64_t)0x80000000) {
f->store_32(VARIANT_INT64);
@@ -1383,28 +1287,24 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::FLOAT: {
-
double d = p_property;
float fl = d;
if (double(fl) != d) {
f->store_32(VARIANT_DOUBLE);
f->store_double(d);
} else {
-
f->store_32(VARIANT_FLOAT);
f->store_real(fl);
}
} break;
case Variant::STRING: {
-
f->store_32(VARIANT_STRING);
String val = p_property;
save_unicode_string(f, val);
} break;
case Variant::VECTOR2: {
-
f->store_32(VARIANT_VECTOR2);
Vector2 val = p_property;
f->store_real(val.x);
@@ -1412,7 +1312,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::VECTOR2I: {
-
f->store_32(VARIANT_VECTOR2I);
Vector2i val = p_property;
f->store_32(val.x);
@@ -1420,7 +1319,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::RECT2: {
-
f->store_32(VARIANT_RECT2);
Rect2 val = p_property;
f->store_real(val.position.x);
@@ -1430,7 +1328,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::RECT2I: {
-
f->store_32(VARIANT_RECT2I);
Rect2i val = p_property;
f->store_32(val.position.x);
@@ -1440,7 +1337,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::VECTOR3: {
-
f->store_32(VARIANT_VECTOR3);
Vector3 val = p_property;
f->store_real(val.x);
@@ -1449,7 +1345,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::VECTOR3I: {
-
f->store_32(VARIANT_VECTOR3I);
Vector3i val = p_property;
f->store_32(val.x);
@@ -1458,7 +1353,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PLANE: {
-
f->store_32(VARIANT_PLANE);
Plane val = p_property;
f->store_real(val.normal.x);
@@ -1468,7 +1362,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::QUAT: {
-
f->store_32(VARIANT_QUAT);
Quat val = p_property;
f->store_real(val.x);
@@ -1478,7 +1371,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::AABB: {
-
f->store_32(VARIANT_AABB);
AABB val = p_property;
f->store_real(val.position.x);
@@ -1490,7 +1382,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::TRANSFORM2D: {
-
f->store_32(VARIANT_MATRIX32);
Transform2D val = p_property;
f->store_real(val.elements[0].x);
@@ -1502,7 +1393,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::BASIS: {
-
f->store_32(VARIANT_MATRIX3);
Basis val = p_property;
f->store_real(val.elements[0].x);
@@ -1517,7 +1407,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::TRANSFORM: {
-
f->store_32(VARIANT_TRANSFORM);
Transform val = p_property;
f->store_real(val.basis.elements[0].x);
@@ -1535,7 +1424,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::COLOR: {
-
f->store_32(VARIANT_COLOR);
Color val = p_property;
f->store_real(val.r);
@@ -1545,7 +1433,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::STRING_NAME: {
-
f->store_32(VARIANT_STRING_NAME);
String val = p_property;
save_unicode_string(f, val);
@@ -1557,8 +1444,9 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
NodePath np = p_property;
f->store_16(np.get_name_count());
uint16_t snc = np.get_subname_count();
- if (np.is_absolute())
+ if (np.is_absolute()) {
snc |= 0x8000;
+ }
f->store_16(snc);
for (int i = 0; i < np.get_name_count(); i++) {
if (string_map.has(np.get_name(i))) {
@@ -1577,14 +1465,12 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::_RID: {
-
f->store_32(VARIANT_RID);
WARN_PRINT("Can't save RIDs.");
RID val = p_property;
f->store_32(val.get_id());
} break;
case Variant::OBJECT: {
-
f->store_32(VARIANT_OBJECT);
RES res = p_property;
if (res.is_null()) {
@@ -1596,7 +1482,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
f->store_32(OBJECT_EXTERNAL_RESOURCE_INDEX);
f->store_32(external_resources[res]);
} else {
-
if (!resource_set.has(res)) {
f->store_32(OBJECT_EMPTY);
ERR_FAIL_MSG("Resource was not pre cached for the resource section, most likely due to circular reference.");
@@ -1609,18 +1494,15 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::CALLABLE: {
-
f->store_32(VARIANT_CALLABLE);
WARN_PRINT("Can't save Callables.");
} break;
case Variant::SIGNAL: {
-
f->store_32(VARIANT_SIGNAL);
WARN_PRINT("Can't save Signals.");
} break;
case Variant::DICTIONARY: {
-
f->store_32(VARIANT_DICTIONARY);
Dictionary d = p_property;
f->store_32(uint32_t(d.size()));
@@ -1629,7 +1511,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
d.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
/*
if (!_check_type(dict[E->get()]))
continue;
@@ -1641,18 +1522,15 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::ARRAY: {
-
f->store_32(VARIANT_ARRAY);
Array a = p_property;
f->store_32(uint32_t(a.size()));
for (int i = 0; i < a.size(); i++) {
-
write_variant(f, a[i], resource_set, external_resources, string_map);
}
} break;
case Variant::PACKED_BYTE_ARRAY: {
-
f->store_32(VARIANT_RAW_ARRAY);
Vector<uint8_t> arr = p_property;
int len = arr.size();
@@ -1663,29 +1541,28 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PACKED_INT32_ARRAY: {
-
f->store_32(VARIANT_INT32_ARRAY);
Vector<int32_t> arr = p_property;
int len = arr.size();
f->store_32(len);
const int32_t *r = arr.ptr();
- for (int i = 0; i < len; i++)
+ for (int i = 0; i < len; i++) {
f->store_32(r[i]);
+ }
} break;
case Variant::PACKED_INT64_ARRAY: {
-
f->store_32(VARIANT_INT64_ARRAY);
Vector<int64_t> arr = p_property;
int len = arr.size();
f->store_32(len);
const int64_t *r = arr.ptr();
- for (int i = 0; i < len; i++)
+ for (int i = 0; i < len; i++) {
f->store_64(r[i]);
+ }
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
f->store_32(VARIANT_FLOAT32_ARRAY);
Vector<float> arr = p_property;
int len = arr.size();
@@ -1697,7 +1574,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
f->store_32(VARIANT_FLOAT64_ARRAY);
Vector<double> arr = p_property;
int len = arr.size();
@@ -1709,7 +1585,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PACKED_STRING_ARRAY: {
-
f->store_32(VARIANT_STRING_ARRAY);
Vector<String> arr = p_property;
int len = arr.size();
@@ -1721,7 +1596,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
f->store_32(VARIANT_VECTOR3_ARRAY);
Vector<Vector3> arr = p_property;
int len = arr.size();
@@ -1735,7 +1609,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
-
f->store_32(VARIANT_VECTOR2_ARRAY);
Vector<Vector2> arr = p_property;
int len = arr.size();
@@ -1748,7 +1621,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
f->store_32(VARIANT_COLOR_ARRAY);
Vector<Color> arr = p_property;
int len = arr.size();
@@ -1763,21 +1635,19 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
} break;
default: {
-
ERR_FAIL_MSG("Invalid variant.");
}
}
}
void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant, bool p_main) {
-
switch (p_variant.get_type()) {
case Variant::OBJECT: {
-
RES res = p_variant;
- if (res.is_null() || external_resources.has(res))
+ if (res.is_null() || external_resources.has(res)) {
return;
+ }
if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) {
if (res->get_path() == path) {
@@ -1789,17 +1659,16 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
return;
}
- if (resource_set.has(res))
+ if (resource_set.has(res)) {
return;
+ }
List<PropertyInfo> property_list;
res->get_property_list(&property_list);
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_STORAGE) {
-
Variant value = res->get(E->get().name);
if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
RES sres = value;
@@ -1823,11 +1692,9 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
} break;
case Variant::ARRAY: {
-
Array varray = p_variant;
int len = varray.size();
for (int i = 0; i < len; i++) {
-
const Variant &v = varray.get(i);
_find_resources(v);
}
@@ -1835,12 +1702,10 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
} break;
case Variant::DICTIONARY: {
-
Dictionary d = p_variant;
List<Variant> keys;
d.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
_find_resources(E->get());
Variant v = d[E->get()];
_find_resources(v);
@@ -1849,10 +1714,12 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
case Variant::NODE_PATH: {
//take the chance and save node path strings
NodePath np = p_variant;
- for (int i = 0; i < np.get_name_count(); i++)
+ for (int i = 0; i < np.get_name_count(); i++) {
get_string_index(np.get_name(i));
- for (int i = 0; i < np.get_subname_count(); i++)
+ }
+ for (int i = 0; i < np.get_subname_count(); i++) {
get_string_index(np.get_subname(i));
+ }
} break;
default: {
@@ -1861,7 +1728,6 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
}
void ResourceFormatSaverBinaryInstance::save_unicode_string(FileAccess *f, const String &p_string, bool p_bit_on_len) {
-
CharString utf8 = p_string.utf8();
if (p_bit_on_len) {
f->store_32((utf8.length() + 1) | 0x80000000);
@@ -1872,10 +1738,10 @@ void ResourceFormatSaverBinaryInstance::save_unicode_string(FileAccess *f, const
}
int ResourceFormatSaverBinaryInstance::get_string_index(const String &p_string) {
-
StringName s = p_string;
- if (string_map.has(s))
+ if (string_map.has(s)) {
return string_map[s];
+ }
string_map[s] = strings.size();
strings.push_back(s);
@@ -1883,15 +1749,15 @@ int ResourceFormatSaverBinaryInstance::get_string_index(const String &p_string)
}
Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Error err;
if (p_flags & ResourceSaver::FLAG_COMPRESS) {
FileAccessCompressed *fac = memnew(FileAccessCompressed);
fac->configure("RSCC");
f = fac;
err = fac->_open(p_path, FileAccess::WRITE);
- if (err)
+ if (err) {
memdelete(f);
+ }
} else {
f = FileAccess::open(p_path, FileAccess::WRITE, &err);
@@ -1905,8 +1771,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
big_endian = p_flags & ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
takeover_paths = p_flags & ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
- if (!p_path.begins_with("res://"))
+ if (!p_path.begins_with("res://")) {
takeover_paths = false;
+ }
local_path = p_path.get_base_dir();
path = ProjectSettings::get_singleton()->localize_path(p_path);
@@ -1922,8 +1789,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
if (big_endian) {
f->store_32(1);
f->set_endian_swap(true);
- } else
+ } else {
f->store_32(0);
+ }
f->store_32(0); //64 bits file, false for now
f->store_32(VERSION_MAJOR);
@@ -1938,15 +1806,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
save_unicode_string(f, p_resource->get_class());
f->store_64(0); //offset to import metadata
- for (int i = 0; i < 14; i++)
+ for (int i = 0; i < 14; i++) {
f->store_32(0); // reserved
+ }
List<ResourceData> resources;
{
-
for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
-
ResourceData &rd = resources.push_back(ResourceData())->get();
rd.type = E->get()->get_class();
@@ -1954,9 +1821,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
E->get()->get_property_list(&property_list);
for (List<PropertyInfo>::Element *F = property_list.front(); F; F = F->next()) {
-
- if (skip_editor && F->get().name.begins_with("__editor"))
+ if (skip_editor && F->get().name.begins_with("__editor")) {
continue;
+ }
if ((F->get().usage & PROPERTY_USAGE_STORAGE)) {
Property p;
p.name_idx = get_string_index(F->get().name);
@@ -2001,7 +1868,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
for (int i = 0; i < save_order.size(); i++) {
-
save_unicode_string(f, save_order[i]->get_save_class());
String path = save_order[i]->get_path();
path = relative_paths ? local_path.path_to_file(path) : path;
@@ -2013,10 +1879,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Set<int> used_indices;
for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
-
RES r = E->get();
if (r->get_path() == "" || r->get_path().find("::") != -1) {
-
if (r->get_subindex() != 0) {
if (used_indices.has(r->get_subindex())) {
r->set_subindex(0); //repeated
@@ -2028,7 +1892,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
-
RES r = E->get();
if (r->get_path() == "" || r->get_path().find("::") != -1) {
if (r->get_subindex() == 0) {
@@ -2059,7 +1922,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
//now actually save the resources
for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) {
-
ResourceData &rd = E->get();
ofs_table.push_back(f->get_position());
@@ -2067,7 +1929,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
f->store_32(rd.properties.size());
for (List<Property>::Element *F = rd.properties.front(); F; F = F->next()) {
-
Property &p = F->get();
f->store_32(p.name_idx);
_write_variant(p.value, F->get().pi);
@@ -2096,28 +1957,25 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
Error ResourceFormatSaverBinary::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ResourceFormatSaverBinaryInstance saver;
return saver.save(local_path, p_resource, p_flags);
}
bool ResourceFormatSaverBinary::recognize(const RES &p_resource) const {
-
return true; //all recognized
}
void ResourceFormatSaverBinary::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
String base = p_resource->get_base_extension().to_lower();
p_extensions->push_back(base);
- if (base != "res")
+ if (base != "res") {
p_extensions->push_back("res");
+ }
}
ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = nullptr;
ResourceFormatSaverBinary::ResourceFormatSaverBinary() {
-
singleton = this;
}
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 3c8d916c0a..54cddca49e 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -36,17 +36,16 @@
#include "core/os/file_access.h"
class ResourceLoaderBinary {
-
- bool translation_remapped;
+ bool translation_remapped = false;
String local_path;
String res_path;
String type;
Ref<Resource> resource;
- uint32_t ver_format;
+ uint32_t ver_format = 0;
- FileAccess *f;
+ FileAccess *f = nullptr;
- uint64_t importmd_ofs;
+ uint64_t importmd_ofs = 0;
Vector<char> str_buf;
List<RES> resource_cache;
@@ -61,8 +60,8 @@ class ResourceLoaderBinary {
RES cache;
};
- bool use_sub_threads;
- float *progress;
+ bool use_sub_threads = false;
+ float *progress = nullptr;
Vector<ExtResource> external_resources;
struct IntResource {
@@ -77,9 +76,9 @@ class ResourceLoaderBinary {
void _advance_padding(uint32_t p_len);
Map<String, String> remaps;
- Error error;
+ Error error = OK;
- bool use_nocache;
+ bool use_nocache = false;
friend class ResourceFormatLoaderBinary;
@@ -98,7 +97,7 @@ public:
String recognize(FileAccess *p_f);
void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types);
- ResourceLoaderBinary();
+ ResourceLoaderBinary() {}
~ResourceLoaderBinary();
};
@@ -114,7 +113,6 @@ public:
};
class ResourceFormatSaverBinaryInstance {
-
String local_path;
String path;
@@ -147,7 +145,6 @@ class ResourceFormatSaverBinaryInstance {
};
struct ResourceData {
-
String type;
List<Property> properties;
};
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index 9e22bdced7..9ed159bd20 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -38,7 +38,6 @@ bool ResourceFormatImporter::SortImporterByName::operator()(const Ref<ResourceIm
}
Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid) const {
-
Error err;
FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);
@@ -64,7 +63,6 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
String error_text;
bool path_found = false; //first match must have priority
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -118,14 +116,13 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
}
RES ResourceFormatImporter::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) {
-
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);
if (err != OK) {
-
- if (r_error)
+ if (r_error) {
*r_error = err;
+ }
return RES();
}
@@ -143,7 +140,6 @@ RES ResourceFormatImporter::load(const String &p_path, const String &p_original_
}
void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extensions) const {
-
Set<String> found;
for (int i = 0; i < importers.size(); i++) {
@@ -159,7 +155,6 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension
}
void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
-
if (p_type == "") {
get_recognized_extensions(p_extensions);
return;
@@ -169,11 +164,13 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_
for (int i = 0; i < importers.size(); i++) {
String res_type = importers[i]->get_resource_type();
- if (res_type == String())
+ if (res_type == String()) {
continue;
+ }
- if (!ClassDB::is_parent_class(res_type, p_type))
+ if (!ClassDB::is_parent_class(res_type, p_type)) {
continue;
+ }
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
@@ -187,26 +184,21 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_
}
bool ResourceFormatImporter::exists(const String &p_path) const {
-
return FileAccess::exists(p_path + ".import");
}
bool ResourceFormatImporter::recognize_path(const String &p_path, const String &p_for_type) const {
-
return FileAccess::exists(p_path + ".import");
}
bool ResourceFormatImporter::can_be_imported(const String &p_path) const {
-
return ResourceFormatLoader::recognize_path(p_path);
}
int ResourceFormatImporter::get_import_order(const String &p_path) const {
-
Ref<ResourceImporter> importer;
if (FileAccess::exists(p_path + ".import")) {
-
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);
@@ -214,37 +206,35 @@ int ResourceFormatImporter::get_import_order(const String &p_path) const {
importer = get_importer_by_name(pat.importer);
}
} else {
-
importer = get_importer_by_extension(p_path.get_extension().to_lower());
}
- if (importer.is_valid())
+ if (importer.is_valid()) {
return importer->get_import_order();
+ }
return 0;
}
bool ResourceFormatImporter::handles_type(const String &p_type) const {
-
for (int i = 0; i < importers.size(); i++) {
-
String res_type = importers[i]->get_resource_type();
- if (res_type == String())
+ if (res_type == String()) {
continue;
- if (ClassDB::is_parent_class(res_type, p_type))
+ }
+ if (ClassDB::is_parent_class(res_type, p_type)) {
return true;
+ }
}
return true;
}
String ResourceFormatImporter::get_internal_resource_path(const String &p_path) const {
-
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);
if (err != OK) {
-
return String();
}
@@ -252,12 +242,12 @@ String ResourceFormatImporter::get_internal_resource_path(const String &p_path)
}
void ResourceFormatImporter::get_internal_resource_path_list(const String &p_path, List<String> *r_paths) {
-
Error err;
FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);
- if (!f)
+ if (!f) {
return;
+ }
VariantParser::StreamFile stream;
stream.f = f;
@@ -269,7 +259,6 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat
int lines = 0;
String error_text;
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -298,7 +287,6 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat
}
String ResourceFormatImporter::get_import_group_file(const String &p_path) const {
-
bool valid = true;
PathAndType pat;
_get_path_and_type(p_path, pat, &valid);
@@ -306,7 +294,6 @@ String ResourceFormatImporter::get_import_group_file(const String &p_path) const
}
bool ResourceFormatImporter::is_import_valid(const String &p_path) const {
-
bool valid = true;
PathAndType pat;
_get_path_and_type(p_path, pat, &valid);
@@ -314,12 +301,10 @@ bool ResourceFormatImporter::is_import_valid(const String &p_path) const {
}
String ResourceFormatImporter::get_resource_type(const String &p_path) const {
-
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);
if (err != OK) {
-
return "";
}
@@ -331,7 +316,6 @@ Variant ResourceFormatImporter::get_resource_metadata(const String &p_path) cons
Error err = _get_path_and_type(p_path, pat);
if (err != OK) {
-
return Variant();
}
@@ -339,12 +323,10 @@ Variant ResourceFormatImporter::get_resource_metadata(const String &p_path) cons
}
void ResourceFormatImporter::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);
if (err != OK) {
-
return;
}
@@ -352,7 +334,6 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String>
}
Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const {
-
for (int i = 0; i < importers.size(); i++) {
if (importers[i]->get_importer_name() == p_name) {
return importers[i];
@@ -363,7 +344,6 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String
}
void ResourceFormatImporter::get_importers_for_extension(const String &p_extension, List<Ref<ResourceImporter>> *r_importers) {
-
for (int i = 0; i < importers.size(); i++) {
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
@@ -376,12 +356,10 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi
}
Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const String &p_extension) const {
-
Ref<ResourceImporter> importer;
float priority = 0;
for (int i = 0; i < importers.size(); i++) {
-
List<String> local_exts;
importers[i]->get_recognized_extensions(&local_exts);
for (List<String>::Element *F = local_exts.front(); F; F = F->next()) {
@@ -396,12 +374,10 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St
}
String ResourceFormatImporter::get_import_base_path(const String &p_for_file) const {
-
return "res://.import/" + p_for_file.get_file() + "-" + p_for_file.md5_text();
}
bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const {
-
bool valid = true;
PathAndType pat;
_get_path_and_type(p_path, pat, &valid);
@@ -422,7 +398,6 @@ bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) con
}
String ResourceFormatImporter::get_import_settings_hash() const {
-
Vector<Ref<ResourceImporter>> sorted_importers = importers;
sorted_importers.sort_custom<SortImporterByName>();
diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h
index 6b76912494..d31a9a0194 100644
--- a/core/io/resource_importer.h
+++ b/core/io/resource_importer.h
@@ -36,7 +36,6 @@
class ResourceImporter;
class ResourceFormatImporter : public ResourceFormatLoader {
-
struct PathAndType {
String path;
String type;
@@ -93,7 +92,6 @@ public:
};
class ResourceImporter : public Reference {
-
GDCLASS(ResourceImporter, Reference);
public:
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index d90802d7e2..f9d2c9067c 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -33,7 +33,6 @@
#include "core/io/resource_importer.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
-#include "core/path_remap.h"
#include "core/print_string.h"
#include "core/project_settings.h"
#include "core/translation.h"
@@ -50,7 +49,6 @@ Ref<ResourceFormatLoader> ResourceLoader::loader[ResourceLoader::MAX_LOADERS];
int ResourceLoader::loader_count = 0;
bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_for_type) const {
-
String extension = p_path.get_extension();
List<String> extensions;
@@ -61,16 +59,15 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
}
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
- if (E->get().nocasecmp_to(extension) == 0)
+ if (E->get().nocasecmp_to(extension) == 0) {
return true;
+ }
}
return false;
}
bool ResourceFormatLoader::handles_type(const String &p_type) const {
-
if (get_script_instance() && get_script_instance()->has_method("handles_type")) {
// I guess custom loaders for custom resources should use "Resource"
return get_script_instance()->call("handles_type", p_type);
@@ -80,7 +77,6 @@ bool ResourceFormatLoader::handles_type(const String &p_type) const {
}
String ResourceFormatLoader::get_resource_type(const String &p_path) const {
-
if (get_script_instance() && get_script_instance()->has_method("get_resource_type")) {
return get_script_instance()->call("get_resource_type", p_path);
}
@@ -89,13 +85,12 @@ String ResourceFormatLoader::get_resource_type(const String &p_path) const {
}
void ResourceFormatLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
-
- if (p_type == "" || handles_type(p_type))
+ if (p_type == "" || handles_type(p_type)) {
get_recognized_extensions(p_extensions);
+ }
}
void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) {
-
for (int i = 0; i < loader_count; i++) {
loader[i]->get_recognized_extensions_for_type(p_type, p_extensions);
}
@@ -106,7 +101,6 @@ bool ResourceFormatLoader::exists(const String &p_path) const {
}
void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions) const {
-
if (get_script_instance() && get_script_instance()->has_method("get_recognized_extensions")) {
PackedStringArray exts = get_script_instance()->call("get_recognized_extensions");
@@ -120,19 +114,18 @@ void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions)
}
RES ResourceFormatLoader::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 (get_script_instance() && get_script_instance()->has_method("load")) {
Variant res = get_script_instance()->call("load", p_path, p_original_path, p_use_sub_threads);
if (res.get_type() == Variant::INT) {
-
- if (r_error)
+ if (r_error) {
*r_error = (Error)res.operator int64_t();
+ }
} else {
-
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return res;
}
@@ -143,7 +136,6 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
}
void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
if (get_script_instance() && get_script_instance()->has_method("get_dependencies")) {
PackedStringArray deps = get_script_instance()->call("get_dependencies", p_path, p_add_types);
@@ -157,9 +149,7 @@ void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *
}
Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
if (get_script_instance() && get_script_instance()->has_method("rename_dependencies")) {
-
Dictionary deps_dict;
for (Map<String, String>::Element *E = p_map.front(); E; E = E->next()) {
deps_dict[E->key()] = E->value();
@@ -173,7 +163,6 @@ Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map<
}
void ResourceFormatLoader::_bind_methods() {
-
{
MethodInfo info = MethodInfo(Variant::NIL, "load", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "original_path"));
info.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
@@ -190,12 +179,10 @@ void ResourceFormatLoader::_bind_methods() {
///////////////////////////////////
RES ResourceLoader::_load(const String &p_path, const String &p_original_path, const String &p_type_hint, bool p_no_cache, Error *r_error, bool p_use_sub_threads, float *r_progress) {
-
bool found = false;
// Try all loaders and pick the first match for the type hint
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(p_path, p_type_hint)) {
continue;
}
@@ -219,7 +206,6 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c
}
void ResourceLoader::_thread_load_function(void *p_userdata) {
-
ThreadLoadTask &load_task = *(ThreadLoadTask *)p_userdata;
load_task.loader_id = Thread::get_caller_id();
@@ -238,7 +224,6 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
load_task.status = THREAD_LOAD_LOADED;
}
if (load_task.semaphore) {
-
if (load_task.start_next && thread_waiting_count > 0) {
thread_waiting_count--;
//thread loading count remains constant, this ends but another one begins
@@ -259,8 +244,9 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
if (load_task.resource.is_valid()) {
load_task.resource->set_path(load_task.local_path);
- if (load_task.xl_remapped)
+ if (load_task.xl_remapped) {
load_task.resource->set_as_translation_remapped(true);
+ }
#ifdef TOOLS_ENABLED
@@ -279,13 +265,14 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
thread_load_mutex->unlock();
}
-Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, const String &p_source_resource) {
+Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, const String &p_source_resource) {
String local_path;
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
local_path = "res://" + p_path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ }
thread_load_mutex->lock();
@@ -388,7 +375,6 @@ Error ResourceLoader::load_threaded_request(const String &p_path, const String &
}
float ResourceLoader::_dependency_get_progress(const String &p_path) {
-
if (thread_load_tasks.has(p_path)) {
ThreadLoadTask &load_task = thread_load_tasks[p_path];
int dep_count = load_task.sub_tasks.size();
@@ -411,12 +397,12 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) {
}
ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, float *r_progress) {
-
String local_path;
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
local_path = "res://" + p_path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ }
thread_load_mutex->lock();
if (!thread_load_tasks.has(local_path)) {
@@ -434,13 +420,14 @@ ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const
return status;
}
-RES ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) {
+RES ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) {
String local_path;
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
local_path = "res://" + p_path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ }
thread_load_mutex->lock();
if (!thread_load_tasks.has(local_path)) {
@@ -517,18 +504,18 @@ RES ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) {
}
RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache, Error *r_error) {
-
- if (r_error)
+ if (r_error) {
*r_error = ERR_CANT_OPEN;
+ }
String local_path;
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
local_path = "res://" + p_path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ }
if (!p_no_cache) {
-
thread_load_mutex->lock();
//Is it already being loaded? poll until done
@@ -593,7 +580,6 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
return load_threaded_get(p_path, r_error);
} else {
-
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -610,8 +596,9 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
return RES();
}
- if (xl_remapped)
+ if (xl_remapped) {
res->set_as_translation_remapped(true);
+ }
#ifdef TOOLS_ENABLED
@@ -628,15 +615,14 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
}
bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
-
String local_path;
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
local_path = "res://" + p_path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ }
if (ResourceCache::has(local_path)) {
-
return true; // If cached, it probably exists
}
@@ -645,20 +631,19 @@ bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
// Try all loaders and pick the first match for the type hint
for (int i = 0; i < loader_count; i++) {
-
if (!loader[i]->recognize_path(path, p_type_hint)) {
continue;
}
- if (loader[i]->exists(path))
+ if (loader[i]->exists(path)) {
return true;
+ }
}
return false;
}
void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {
-
ERR_FAIL_COND(p_format_loader.is_null());
ERR_FAIL_COND(loader_count >= MAX_LOADERS);
@@ -674,14 +659,14 @@ void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_form
}
void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader) {
-
ERR_FAIL_COND(p_format_loader.is_null());
// Find loader
int i = 0;
for (; i < loader_count; ++i) {
- if (loader[i] == p_format_loader)
+ if (loader[i] == p_format_loader) {
break;
+ }
}
ERR_FAIL_COND(i >= loader_count); // Not found
@@ -695,19 +680,19 @@ void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_f
}
int ResourceLoader::get_import_order(const String &p_path) {
-
String path = _path_remap(p_path);
String local_path;
- if (path.is_rel_path())
+ if (path.is_rel_path()) {
local_path = "res://" + path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(path);
+ }
for (int i = 0; i < loader_count; i++) {
-
- if (!loader[i]->recognize_path(local_path))
+ if (!loader[i]->recognize_path(local_path)) {
continue;
+ }
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
@@ -723,15 +708,16 @@ String ResourceLoader::get_import_group_file(const String &p_path) {
String path = _path_remap(p_path);
String local_path;
- if (path.is_rel_path())
+ if (path.is_rel_path()) {
local_path = "res://" + path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(path);
+ }
for (int i = 0; i < loader_count; i++) {
-
- if (!loader[i]->recognize_path(local_path))
+ if (!loader[i]->recognize_path(local_path)) {
continue;
+ }
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
@@ -744,19 +730,19 @@ String ResourceLoader::get_import_group_file(const String &p_path) {
}
bool ResourceLoader::is_import_valid(const String &p_path) {
-
String path = _path_remap(p_path);
String local_path;
- if (path.is_rel_path())
+ if (path.is_rel_path()) {
local_path = "res://" + path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(path);
+ }
for (int i = 0; i < loader_count; i++) {
-
- if (!loader[i]->recognize_path(local_path))
+ if (!loader[i]->recognize_path(local_path)) {
continue;
+ }
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
@@ -769,19 +755,19 @@ bool ResourceLoader::is_import_valid(const String &p_path) {
}
bool ResourceLoader::is_imported(const String &p_path) {
-
String path = _path_remap(p_path);
String local_path;
- if (path.is_rel_path())
+ if (path.is_rel_path()) {
local_path = "res://" + path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(path);
+ }
for (int i = 0; i < loader_count; i++) {
-
- if (!loader[i]->recognize_path(local_path))
+ if (!loader[i]->recognize_path(local_path)) {
continue;
+ }
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
@@ -794,19 +780,19 @@ bool ResourceLoader::is_imported(const String &p_path) {
}
void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
String path = _path_remap(p_path);
String local_path;
- if (path.is_rel_path())
+ if (path.is_rel_path()) {
local_path = "res://" + path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(path);
+ }
for (int i = 0; i < loader_count; i++) {
-
- if (!loader[i]->recognize_path(local_path))
+ if (!loader[i]->recognize_path(local_path)) {
continue;
+ }
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
@@ -817,19 +803,19 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
}
Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
String path = _path_remap(p_path);
String local_path;
- if (path.is_rel_path())
+ if (path.is_rel_path()) {
local_path = "res://" + path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(path);
+ }
for (int i = 0; i < loader_count; i++) {
-
- if (!loader[i]->recognize_path(local_path))
+ if (!loader[i]->recognize_path(local_path)) {
continue;
+ }
/*
if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
@@ -842,15 +828,14 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
}
String ResourceLoader::get_resource_type(const String &p_path) {
-
String local_path;
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
local_path = "res://" + p_path;
- else
+ } else {
local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ }
for (int i = 0; i < loader_count; i++) {
-
String result = loader[i]->get_resource_type(local_path);
if (result != "") {
return result;
@@ -861,7 +846,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
}
String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_remapped) {
-
String new_path = p_path;
if (translation_remaps.has(p_path)) {
@@ -920,7 +904,6 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
FileAccess *f = FileAccess::open(p_path + ".remap", FileAccess::READ, &err);
if (f) {
-
VariantParser::StreamFile stream;
stream.f = f;
@@ -931,7 +914,6 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
int lines = 0;
String error_text;
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -960,9 +942,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
}
String ResourceLoader::import_remap(const String &p_path) {
-
if (ResourceFormatImporter::get_singleton()->recognize_path(p_path)) {
-
return ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_path);
}
@@ -974,7 +954,6 @@ String ResourceLoader::path_remap(const String &p_path) {
}
void ResourceLoader::reload_translation_remaps() {
-
if (ResourceCache::lock) {
ResourceCache::lock->read_lock();
}
@@ -999,15 +978,14 @@ void ResourceLoader::reload_translation_remaps() {
}
void ResourceLoader::load_translation_remaps() {
-
- if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
return;
+ }
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
Array langs = remaps[E->get()];
Vector<String> lang_remaps;
lang_remaps.resize(langs.size());
@@ -1024,9 +1002,9 @@ void ResourceLoader::clear_translation_remaps() {
}
void ResourceLoader::load_path_remaps() {
-
- if (!ProjectSettings::get_singleton()->has_setting("path_remap/remapped_paths"))
+ if (!ProjectSettings::get_singleton()->has_setting("path_remap/remapped_paths")) {
return;
+ }
Vector<String> remaps = ProjectSettings::get_singleton()->get("path_remap/remapped_paths");
int rc = remaps.size();
@@ -1034,13 +1012,11 @@ void ResourceLoader::load_path_remaps() {
const String *r = remaps.ptr();
for (int i = 0; i < rc; i += 2) {
-
path_remaps[r[i]] = r[i + 1];
}
}
void ResourceLoader::clear_path_remaps() {
-
path_remaps.clear();
}
@@ -1060,9 +1036,9 @@ Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(St
}
bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
-
- if (_find_custom_resource_format_loader(script_path).is_valid())
+ if (_find_custom_resource_format_loader(script_path).is_valid()) {
return false;
+ }
Ref<Resource> res = ResourceLoader::load(script_path);
ERR_FAIL_COND_V(res.is_null(), false);
@@ -1085,10 +1061,10 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) {
}
void ResourceLoader::remove_custom_resource_format_loader(String script_path) {
-
Ref<ResourceFormatLoader> custom_loader = _find_custom_resource_format_loader(script_path);
- if (custom_loader.is_valid())
+ if (custom_loader.is_valid()) {
remove_resource_format_loader(custom_loader);
+ }
}
void ResourceLoader::add_custom_loaders() {
@@ -1100,7 +1076,6 @@ void ResourceLoader::add_custom_loaders() {
ScriptServer::get_global_class_list(&global_classes);
for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) {
-
StringName class_name = E->get();
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
@@ -1112,7 +1087,6 @@ void ResourceLoader::add_custom_loaders() {
}
void ResourceLoader::remove_custom_loaders() {
-
Vector<Ref<ResourceFormatLoader>> custom_loaders;
for (int i = 0; i < loader_count; ++i) {
if (loader[i]->get_script_instance()) {
@@ -1135,7 +1109,6 @@ void ResourceLoader::initialize() {
}
void ResourceLoader::finalize() {
-
memdelete(thread_load_mutex);
memdelete(thread_load_semaphore);
}
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index b10c08d693..9322b5273a 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -36,7 +36,6 @@
#include "core/resource.h"
class ResourceFormatLoader : public Reference {
-
GDCLASS(ResourceFormatLoader, Reference);
protected:
@@ -67,7 +66,6 @@ typedef Error (*ResourceLoaderImport)(const String &p_path);
typedef void (*ResourceLoadedCallback)(RES p_resource, const String &p_path);
class ResourceLoader {
-
enum {
MAX_LOADERS = 64
};
@@ -160,8 +158,9 @@ public:
static bool get_timestamp_on_load() { return timestamp_on_load; }
static void notify_load_error(const String &p_err) {
- if (err_notify)
+ if (err_notify) {
err_notify(err_notify_ud, p_err);
+ }
}
static void set_error_notify_func(void *p_ud, ResourceLoadErrorNotify p_err_notify) {
err_notify = p_err_notify;
@@ -169,8 +168,9 @@ public:
}
static void notify_dependency_error(const String &p_path, const String &p_dependency, const String &p_type) {
- if (dep_err_notify)
+ if (dep_err_notify) {
dep_err_notify(dep_err_notify_ud, p_path, p_dependency, p_type);
+ }
}
static void set_dependency_error_notify_func(void *p_ud, DependencyErrorNotify p_err_notify) {
dep_err_notify = p_err_notify;
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 09128adb50..a8da215b61 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -41,7 +41,6 @@ bool ResourceSaver::timestamp_on_save = false;
ResourceSavedCallback ResourceSaver::save_callback = nullptr;
Error ResourceFormatSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
if (get_script_instance() && get_script_instance()->has_method("save")) {
return (Error)get_script_instance()->call("save", p_path, p_resource, p_flags).operator int64_t();
}
@@ -50,7 +49,6 @@ Error ResourceFormatSaver::save(const String &p_path, const RES &p_resource, uin
}
bool ResourceFormatSaver::recognize(const RES &p_resource) const {
-
if (get_script_instance() && get_script_instance()->has_method("recognize")) {
return get_script_instance()->call("recognize", p_resource);
}
@@ -59,7 +57,6 @@ bool ResourceFormatSaver::recognize(const RES &p_resource) const {
}
void ResourceFormatSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (get_script_instance() && get_script_instance()->has_method("get_recognized_extensions")) {
PackedStringArray exts = get_script_instance()->call("get_recognized_extensions", p_resource);
@@ -73,7 +70,6 @@ void ResourceFormatSaver::get_recognized_extensions(const RES &p_resource, List<
}
void ResourceFormatSaver::_bind_methods() {
-
{
PropertyInfo arg0 = PropertyInfo(Variant::STRING, "path");
PropertyInfo arg1 = PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource");
@@ -86,40 +82,40 @@ void ResourceFormatSaver::_bind_methods() {
}
Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
String extension = p_path.get_extension();
Error err = ERR_FILE_UNRECOGNIZED;
for (int i = 0; i < saver_count; i++) {
-
- if (!saver[i]->recognize(p_resource))
+ if (!saver[i]->recognize(p_resource)) {
continue;
+ }
List<String> extensions;
bool recognized = false;
saver[i]->get_recognized_extensions(p_resource, &extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
- if (E->get().nocasecmp_to(extension) == 0)
+ if (E->get().nocasecmp_to(extension) == 0) {
recognized = true;
+ }
}
- if (!recognized)
+ if (!recognized) {
continue;
+ }
String old_path = p_resource->get_path();
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
RES rwcopy = p_resource;
- if (p_flags & FLAG_CHANGE_PATH)
+ if (p_flags & FLAG_CHANGE_PATH) {
rwcopy->set_path(local_path);
+ }
err = saver[i]->save(p_path, p_resource, p_flags);
if (err == OK) {
-
#ifdef TOOLS_ENABLED
((Resource *)p_resource.ptr())->set_edited(false);
@@ -130,11 +126,13 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
}
#endif
- if (p_flags & FLAG_CHANGE_PATH)
+ if (p_flags & FLAG_CHANGE_PATH) {
rwcopy->set_path(old_path);
+ }
- if (save_callback && p_path.begins_with("res://"))
+ if (save_callback && p_path.begins_with("res://")) {
save_callback(p_resource, p_path);
+ }
return OK;
}
@@ -144,20 +142,16 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
}
void ResourceSaver::set_save_callback(ResourceSavedCallback p_callback) {
-
save_callback = p_callback;
}
void ResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) {
-
for (int i = 0; i < saver_count; i++) {
-
saver[i]->get_recognized_extensions(p_resource, p_extensions);
}
}
void ResourceSaver::add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front) {
-
ERR_FAIL_COND_MSG(p_format_saver.is_null(), "It's not a reference to a valid ResourceFormatSaver object.");
ERR_FAIL_COND(saver_count >= MAX_SAVERS);
@@ -173,14 +167,14 @@ void ResourceSaver::add_resource_format_saver(Ref<ResourceFormatSaver> p_format_
}
void ResourceSaver::remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver) {
-
ERR_FAIL_COND_MSG(p_format_saver.is_null(), "It's not a reference to a valid ResourceFormatSaver object.");
// Find saver
int i = 0;
for (; i < saver_count; ++i) {
- if (saver[i] == p_format_saver)
+ if (saver[i] == p_format_saver) {
break;
+ }
}
ERR_FAIL_COND(i >= saver_count); // Not found
@@ -203,9 +197,9 @@ Ref<ResourceFormatSaver> ResourceSaver::_find_custom_resource_format_saver(Strin
}
bool ResourceSaver::add_custom_resource_format_saver(String script_path) {
-
- if (_find_custom_resource_format_saver(script_path).is_valid())
+ if (_find_custom_resource_format_saver(script_path).is_valid()) {
return false;
+ }
Ref<Resource> res = ResourceLoader::load(script_path);
ERR_FAIL_COND_V(res.is_null(), false);
@@ -228,10 +222,10 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) {
}
void ResourceSaver::remove_custom_resource_format_saver(String script_path) {
-
Ref<ResourceFormatSaver> custom_saver = _find_custom_resource_format_saver(script_path);
- if (custom_saver.is_valid())
+ if (custom_saver.is_valid()) {
remove_resource_format_saver(custom_saver);
+ }
}
void ResourceSaver::add_custom_savers() {
@@ -243,7 +237,6 @@ void ResourceSaver::add_custom_savers() {
ScriptServer::get_global_class_list(&global_classes);
for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) {
-
StringName class_name = E->get();
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
@@ -255,7 +248,6 @@ void ResourceSaver::add_custom_savers() {
}
void ResourceSaver::remove_custom_savers() {
-
Vector<Ref<ResourceFormatSaver>> custom_savers;
for (int i = 0; i < saver_count; ++i) {
if (saver[i]->get_script_instance()) {
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index 2ddebf0581..8b4cdd86f8 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -50,7 +50,6 @@ public:
typedef void (*ResourceSavedCallback)(Ref<Resource> p_resource, const String &p_path);
class ResourceSaver {
-
enum {
MAX_SAVERS = 64
};
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index b28b17aa95..403f61bb24 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -33,16 +33,15 @@
#include "core/io/marshalls.h"
Error StreamPeer::_put_data(const Vector<uint8_t> &p_data) {
-
int len = p_data.size();
- if (len == 0)
+ if (len == 0) {
return OK;
+ }
const uint8_t *r = p_data.ptr();
return put_data(&r[0], len);
}
Array StreamPeer::_put_partial_data(const Vector<uint8_t> &p_data) {
-
Array ret;
int len = p_data.size();
@@ -65,13 +64,11 @@ Array StreamPeer::_put_partial_data(const Vector<uint8_t> &p_data) {
}
Array StreamPeer::_get_data(int p_bytes) {
-
Array ret;
Vector<uint8_t> data;
data.resize(p_bytes);
if (data.size() != p_bytes) {
-
ret.push_back(ERR_OUT_OF_MEMORY);
ret.push_back(Vector<uint8_t>());
return ret;
@@ -86,13 +83,11 @@ Array StreamPeer::_get_data(int p_bytes) {
}
Array StreamPeer::_get_partial_data(int p_bytes) {
-
Array ret;
Vector<uint8_t> data;
data.resize(p_bytes);
if (data.size() != p_bytes) {
-
ret.push_back(ERR_OUT_OF_MEMORY);
ret.push_back(Vector<uint8_t>());
return ret;
@@ -105,7 +100,6 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
if (err != OK) {
data.resize(0);
} else if (received != data.size()) {
-
data.resize(received);
}
@@ -115,12 +109,10 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
}
void StreamPeer::set_big_endian(bool p_enable) {
-
big_endian = p_enable;
}
bool StreamPeer::is_big_endian_enabled() const {
-
return big_endian;
}
@@ -129,11 +121,10 @@ void StreamPeer::put_u8(uint8_t p_val) {
}
void StreamPeer::put_8(int8_t p_val) {
-
put_data((const uint8_t *)&p_val, 1);
}
-void StreamPeer::put_u16(uint16_t p_val) {
+void StreamPeer::put_u16(uint16_t p_val) {
if (big_endian) {
p_val = BSWAP16(p_val);
}
@@ -141,8 +132,8 @@ void StreamPeer::put_u16(uint16_t p_val) {
encode_uint16(p_val, buf);
put_data(buf, 2);
}
-void StreamPeer::put_16(int16_t p_val) {
+void StreamPeer::put_16(int16_t p_val) {
if (big_endian) {
p_val = BSWAP16(p_val);
}
@@ -150,8 +141,8 @@ void StreamPeer::put_16(int16_t p_val) {
encode_uint16(p_val, buf);
put_data(buf, 2);
}
-void StreamPeer::put_u32(uint32_t p_val) {
+void StreamPeer::put_u32(uint32_t p_val) {
if (big_endian) {
p_val = BSWAP32(p_val);
}
@@ -159,8 +150,8 @@ void StreamPeer::put_u32(uint32_t p_val) {
encode_uint32(p_val, buf);
put_data(buf, 4);
}
-void StreamPeer::put_32(int32_t p_val) {
+void StreamPeer::put_32(int32_t p_val) {
if (big_endian) {
p_val = BSWAP32(p_val);
}
@@ -168,8 +159,8 @@ void StreamPeer::put_32(int32_t p_val) {
encode_uint32(p_val, buf);
put_data(buf, 4);
}
-void StreamPeer::put_u64(uint64_t p_val) {
+void StreamPeer::put_u64(uint64_t p_val) {
if (big_endian) {
p_val = BSWAP64(p_val);
}
@@ -177,8 +168,8 @@ void StreamPeer::put_u64(uint64_t p_val) {
encode_uint64(p_val, buf);
put_data(buf, 8);
}
-void StreamPeer::put_64(int64_t p_val) {
+void StreamPeer::put_64(int64_t p_val) {
if (big_endian) {
p_val = BSWAP64(p_val);
}
@@ -186,8 +177,8 @@ void StreamPeer::put_64(int64_t p_val) {
encode_uint64(p_val, buf);
put_data(buf, 8);
}
-void StreamPeer::put_float(float p_val) {
+void StreamPeer::put_float(float p_val) {
uint8_t buf[4];
encode_float(p_val, buf);
@@ -198,8 +189,8 @@ void StreamPeer::put_float(float p_val) {
put_data(buf, 4);
}
-void StreamPeer::put_double(double p_val) {
+void StreamPeer::put_double(double p_val) {
uint8_t buf[8];
encode_double(p_val, buf);
if (big_endian) {
@@ -208,20 +199,20 @@ void StreamPeer::put_double(double p_val) {
}
put_data(buf, 8);
}
-void StreamPeer::put_string(const String &p_string) {
+void StreamPeer::put_string(const String &p_string) {
CharString cs = p_string.ascii();
put_u32(cs.length());
put_data((const uint8_t *)cs.get_data(), cs.length());
}
-void StreamPeer::put_utf8_string(const String &p_string) {
+void StreamPeer::put_utf8_string(const String &p_string) {
CharString cs = p_string.utf8();
put_u32(cs.length());
put_data((const uint8_t *)cs.get_data(), cs.length());
}
-void StreamPeer::put_var(const Variant &p_variant, bool p_full_objects) {
+void StreamPeer::put_var(const Variant &p_variant, bool p_full_objects) {
int len = 0;
Vector<uint8_t> buf;
encode_variant(p_variant, nullptr, len, p_full_objects);
@@ -232,19 +223,18 @@ void StreamPeer::put_var(const Variant &p_variant, bool p_full_objects) {
}
uint8_t StreamPeer::get_u8() {
-
uint8_t buf[1];
get_data(buf, 1);
return buf[0];
}
-int8_t StreamPeer::get_8() {
+int8_t StreamPeer::get_8() {
uint8_t buf[1];
get_data(buf, 1);
return buf[0];
}
-uint16_t StreamPeer::get_u16() {
+uint16_t StreamPeer::get_u16() {
uint8_t buf[2];
get_data(buf, 2);
uint16_t r = decode_uint16(buf);
@@ -253,8 +243,8 @@ uint16_t StreamPeer::get_u16() {
}
return r;
}
-int16_t StreamPeer::get_16() {
+int16_t StreamPeer::get_16() {
uint8_t buf[2];
get_data(buf, 2);
uint16_t r = decode_uint16(buf);
@@ -263,8 +253,8 @@ int16_t StreamPeer::get_16() {
}
return r;
}
-uint32_t StreamPeer::get_u32() {
+uint32_t StreamPeer::get_u32() {
uint8_t buf[4];
get_data(buf, 4);
uint32_t r = decode_uint32(buf);
@@ -273,8 +263,8 @@ uint32_t StreamPeer::get_u32() {
}
return r;
}
-int32_t StreamPeer::get_32() {
+int32_t StreamPeer::get_32() {
uint8_t buf[4];
get_data(buf, 4);
uint32_t r = decode_uint32(buf);
@@ -283,8 +273,8 @@ int32_t StreamPeer::get_32() {
}
return r;
}
-uint64_t StreamPeer::get_u64() {
+uint64_t StreamPeer::get_u64() {
uint8_t buf[8];
get_data(buf, 8);
uint64_t r = decode_uint64(buf);
@@ -293,8 +283,8 @@ uint64_t StreamPeer::get_u64() {
}
return r;
}
-int64_t StreamPeer::get_64() {
+int64_t StreamPeer::get_64() {
uint8_t buf[8];
get_data(buf, 8);
uint64_t r = decode_uint64(buf);
@@ -303,8 +293,8 @@ int64_t StreamPeer::get_64() {
}
return r;
}
-float StreamPeer::get_float() {
+float StreamPeer::get_float() {
uint8_t buf[4];
get_data(buf, 4);
@@ -317,7 +307,6 @@ float StreamPeer::get_float() {
}
double StreamPeer::get_double() {
-
uint8_t buf[8];
get_data(buf, 8);
@@ -328,10 +317,11 @@ double StreamPeer::get_double() {
return decode_double(buf);
}
-String StreamPeer::get_string(int p_bytes) {
- if (p_bytes < 0)
+String StreamPeer::get_string(int p_bytes) {
+ if (p_bytes < 0) {
p_bytes = get_u32();
+ }
ERR_FAIL_COND_V(p_bytes < 0, String());
Vector<char> buf;
@@ -342,10 +332,11 @@ String StreamPeer::get_string(int p_bytes) {
buf.write[p_bytes] = 0;
return buf.ptr();
}
-String StreamPeer::get_utf8_string(int p_bytes) {
- if (p_bytes < 0)
+String StreamPeer::get_utf8_string(int p_bytes) {
+ if (p_bytes < 0) {
p_bytes = get_u32();
+ }
ERR_FAIL_COND_V(p_bytes < 0, String());
Vector<uint8_t> buf;
@@ -358,8 +349,8 @@ String StreamPeer::get_utf8_string(int p_bytes) {
ret.parse_utf8((const char *)buf.ptr(), buf.size());
return ret;
}
-Variant StreamPeer::get_var(bool p_allow_objects) {
+Variant StreamPeer::get_var(bool p_allow_objects) {
int len = get_32();
Vector<uint8_t> var;
Error err = var.resize(len);
@@ -375,7 +366,6 @@ Variant StreamPeer::get_var(bool p_allow_objects) {
}
void StreamPeer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("put_data", "data"), &StreamPeer::_put_data);
ClassDB::bind_method(D_METHOD("put_partial_data", "data"), &StreamPeer::_put_partial_data);
@@ -417,10 +407,10 @@ void StreamPeer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "big_endian"), "set_big_endian", "is_big_endian_enabled");
}
+
////////////////////////////////
void StreamPeerBuffer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("seek", "position"), &StreamPeerBuffer::seek);
ClassDB::bind_method(D_METHOD("get_size"), &StreamPeerBuffer::get_size);
ClassDB::bind_method(D_METHOD("get_position"), &StreamPeerBuffer::get_position);
@@ -434,9 +424,9 @@ void StreamPeerBuffer::_bind_methods() {
}
Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
-
- if (p_bytes <= 0)
+ if (p_bytes <= 0) {
return OK;
+ }
if (pointer + p_bytes > data.size()) {
data.resize(pointer + p_bytes);
@@ -450,23 +440,21 @@ Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
}
Error StreamPeerBuffer::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
-
r_sent = p_bytes;
return put_data(p_data, p_bytes);
}
Error StreamPeerBuffer::get_data(uint8_t *p_buffer, int p_bytes) {
-
int recv;
get_partial_data(p_buffer, p_bytes, recv);
- if (recv != p_bytes)
+ if (recv != p_bytes) {
return ERR_INVALID_PARAMETER;
+ }
return OK;
}
Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
if (pointer + p_bytes > data.size()) {
r_received = data.size() - pointer;
if (r_received <= 0) {
@@ -487,57 +475,44 @@ Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_
}
int StreamPeerBuffer::get_available_bytes() const {
-
return data.size() - pointer;
}
void StreamPeerBuffer::seek(int p_pos) {
-
ERR_FAIL_COND(p_pos < 0);
ERR_FAIL_COND(p_pos > data.size());
pointer = p_pos;
}
-int StreamPeerBuffer::get_size() const {
+int StreamPeerBuffer::get_size() const {
return data.size();
}
int StreamPeerBuffer::get_position() const {
-
return pointer;
}
void StreamPeerBuffer::resize(int p_size) {
-
data.resize(p_size);
}
void StreamPeerBuffer::set_data_array(const Vector<uint8_t> &p_data) {
-
data = p_data;
pointer = 0;
}
Vector<uint8_t> StreamPeerBuffer::get_data_array() const {
-
return data;
}
void StreamPeerBuffer::clear() {
-
data.resize(0);
pointer = 0;
}
Ref<StreamPeerBuffer> StreamPeerBuffer::duplicate() const {
-
Ref<StreamPeerBuffer> spb;
spb.instance();
spb->data = data;
return spb;
}
-
-StreamPeerBuffer::StreamPeerBuffer() {
-
- pointer = 0;
-}
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index 9358a2c07c..ec0b989ed8 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -47,7 +47,7 @@ protected:
Array _get_data(int p_bytes);
Array _get_partial_data(int p_bytes);
- bool big_endian;
+ bool big_endian = false;
public:
virtual Error put_data(const uint8_t *p_data, int p_bytes) = 0; ///< put a whole chunk of data, blocking until it sent
@@ -89,15 +89,14 @@ public:
String get_utf8_string(int p_bytes = -1);
Variant get_var(bool p_allow_objects = false);
- StreamPeer() { big_endian = false; }
+ StreamPeer() {}
};
class StreamPeerBuffer : public StreamPeer {
-
GDCLASS(StreamPeerBuffer, StreamPeer);
Vector<uint8_t> data;
- int pointer;
+ int pointer = 0;
protected:
static void _bind_methods();
@@ -123,7 +122,7 @@ public:
Ref<StreamPeerBuffer> duplicate() const;
- StreamPeerBuffer();
+ StreamPeerBuffer() {}
};
#endif // STREAM_PEER_H
diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index d98935f77c..3dc31c6769 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -35,9 +35,9 @@
StreamPeerSSL *(*StreamPeerSSL::_create)() = nullptr;
StreamPeerSSL *StreamPeerSSL::create() {
-
- if (_create)
+ if (_create) {
return _create();
+ }
return nullptr;
}
@@ -56,7 +56,6 @@ bool StreamPeerSSL::is_blocking_handshake_enabled() const {
}
void StreamPeerSSL::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("poll"), &StreamPeerSSL::poll);
ClassDB::bind_method(D_METHOD("accept_stream", "stream", "private_key", "certificate", "chain"), &StreamPeerSSL::accept_stream, DEFVAL(Ref<X509Certificate>()));
ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname", "valid_certificate"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()), DEFVAL(Ref<X509Certificate>()));
@@ -73,7 +72,3 @@ void StreamPeerSSL::_bind_methods() {
BIND_ENUM_CONSTANT(STATUS_ERROR);
BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH);
}
-
-StreamPeerSSL::StreamPeerSSL() {
- blocking_handshake = true;
-}
diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h
index de3cb09c60..81b95b856d 100644
--- a/core/io/stream_peer_ssl.h
+++ b/core/io/stream_peer_ssl.h
@@ -43,7 +43,7 @@ protected:
static bool available;
- bool blocking_handshake;
+ bool blocking_handshake = true;
public:
enum Status {
@@ -68,7 +68,7 @@ public:
static bool is_available();
- StreamPeerSSL();
+ StreamPeerSSL() {}
};
VARIANT_ENUM_CAST(StreamPeerSSL::Status);
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index f0c5816d73..cce728c30a 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -33,7 +33,6 @@
#include "core/project_settings.h"
Error StreamPeerTCP::_poll_connection() {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTING || !_sock.is_valid() || !_sock->is_open(), FAILED);
Error err = _sock->connect_to_host(peer_host, peer_port);
@@ -58,7 +57,6 @@ Error StreamPeerTCP::_poll_connection() {
}
void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint16_t p_port) {
-
_sock = p_sock;
_sock->set_blocking_enabled(false);
@@ -70,7 +68,6 @@ void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint
}
Error StreamPeerTCP::connect_to_host(const IP_Address &p_host, uint16_t p_port) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER);
@@ -103,18 +100,14 @@ Error StreamPeerTCP::connect_to_host(const IP_Address &p_host, uint16_t p_port)
}
Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool p_block) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
if (status == STATUS_NONE || status == STATUS_ERROR) {
-
return FAILED;
}
if (status != STATUS_CONNECTED) {
-
if (_poll_connection() != OK) {
-
return FAILED;
}
@@ -124,8 +117,9 @@ Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool
}
}
- if (!_sock->is_open())
+ if (!_sock->is_open()) {
return FAILED;
+ }
Error err;
int data_to_send = p_bytes;
@@ -133,12 +127,10 @@ Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool
int total_sent = 0;
while (data_to_send) {
-
int sent_amount = 0;
err = _sock->send(offset, data_to_send, sent_amount);
if (err != OK) {
-
if (err != ERR_BUSY) {
disconnect_from_host();
return FAILED;
@@ -156,7 +148,6 @@ Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool
return FAILED;
}
} else {
-
data_to_send -= sent_amount;
offset += sent_amount;
total_sent += sent_amount;
@@ -169,16 +160,12 @@ Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool
}
Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool p_block) {
-
if (!is_connected_to_host()) {
-
return FAILED;
}
if (status == STATUS_CONNECTING) {
-
if (_poll_connection() != OK) {
-
return FAILED;
}
@@ -194,12 +181,10 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool
r_received = 0;
while (to_read) {
-
int read = 0;
err = _sock->recv(p_buffer + total_read, to_read, read);
if (err != OK) {
-
if (err != ERR_BUSY) {
disconnect_from_host();
return FAILED;
@@ -218,13 +203,11 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool
}
} else if (read == 0) {
-
disconnect_from_host();
r_received = total_read;
return ERR_FILE_EOF;
} else {
-
to_read -= read;
total_read += read;
@@ -241,18 +224,15 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool
}
void StreamPeerTCP::set_no_delay(bool p_enabled) {
-
ERR_FAIL_COND(!is_connected_to_host());
_sock->set_tcp_no_delay_enabled(p_enabled);
}
bool StreamPeerTCP::is_connected_to_host() const {
-
return _sock.is_valid() && _sock->is_open() && (status == STATUS_CONNECTED || status == STATUS_CONNECTING);
}
StreamPeerTCP::Status StreamPeerTCP::get_status() {
-
if (status == STATUS_CONNECTING) {
_poll_connection();
} else if (status == STATUS_CONNECTED) {
@@ -278,9 +258,9 @@ StreamPeerTCP::Status StreamPeerTCP::get_status() {
}
void StreamPeerTCP::disconnect_from_host() {
-
- if (_sock.is_valid() && _sock->is_open())
+ if (_sock.is_valid() && _sock->is_open()) {
_sock->close();
+ }
timeout = 0;
status = STATUS_NONE;
@@ -294,59 +274,51 @@ Error StreamPeerTCP::poll(NetSocket::PollType p_type, int timeout) {
}
Error StreamPeerTCP::put_data(const uint8_t *p_data, int p_bytes) {
-
int total;
return write(p_data, p_bytes, total, true);
}
Error StreamPeerTCP::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
-
return write(p_data, p_bytes, r_sent, false);
}
Error StreamPeerTCP::get_data(uint8_t *p_buffer, int p_bytes) {
-
int total;
return read(p_buffer, p_bytes, total, true);
}
Error StreamPeerTCP::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
return read(p_buffer, p_bytes, r_received, false);
}
int StreamPeerTCP::get_available_bytes() const {
-
ERR_FAIL_COND_V(!_sock.is_valid(), -1);
return _sock->get_available_bytes();
}
IP_Address StreamPeerTCP::get_connected_host() const {
-
return peer_host;
}
uint16_t StreamPeerTCP::get_connected_port() const {
-
return peer_port;
}
Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
-
IP_Address ip;
if (p_address.is_valid_ip_address()) {
ip = p_address;
} else {
ip = IP::get_singleton()->resolve_hostname(p_address);
- if (!ip.is_valid())
+ if (!ip.is_valid()) {
return ERR_CANT_RESOLVE;
+ }
}
return connect_to_host(ip, p_port);
}
void StreamPeerTCP::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port"), &StreamPeerTCP::_connect);
ClassDB::bind_method(D_METHOD("is_connected_to_host"), &StreamPeerTCP::is_connected_to_host);
ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerTCP::get_status);
@@ -362,13 +334,9 @@ void StreamPeerTCP::_bind_methods() {
}
StreamPeerTCP::StreamPeerTCP() :
- _sock(Ref<NetSocket>(NetSocket::create())),
- timeout(0),
- status(STATUS_NONE),
- peer_port(0) {
+ _sock(Ref<NetSocket>(NetSocket::create())) {
}
StreamPeerTCP::~StreamPeerTCP() {
-
disconnect_from_host();
}
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 86df9ab8cf..ab98d494d6 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -37,7 +37,6 @@
#include "core/io/stream_peer.h"
class StreamPeerTCP : public StreamPeer {
-
GDCLASS(StreamPeerTCP, StreamPeer);
OBJ_CATEGORY("Networking");
@@ -52,10 +51,10 @@ public:
protected:
Ref<NetSocket> _sock;
- uint64_t timeout;
- Status status;
+ uint64_t timeout = 0;
+ Status status = STATUS_NONE;
IP_Address peer_host;
- uint16_t peer_port;
+ uint16_t peer_port = 0;
Error _connect(const String &p_address, int p_port);
Error _poll_connection();
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 69c2ba7943..d7061b6bf4 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -31,7 +31,6 @@
#include "tcp_server.h"
void TCP_Server::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available);
ClassDB::bind_method(D_METHOD("is_listening"), &TCP_Server::is_listening);
@@ -40,7 +39,6 @@ void TCP_Server::_bind_methods() {
}
Error TCP_Server::listen(uint16_t p_port, const IP_Address &p_bind_address) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
@@ -49,8 +47,9 @@ Error TCP_Server::listen(uint16_t p_port, const IP_Address &p_bind_address) {
IP::Type ip_type = IP::TYPE_ANY;
// If the bind address is valid use its type as the socket type
- if (p_bind_address.is_valid())
+ if (p_bind_address.is_valid()) {
ip_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+ }
err = _sock->open(NetSocket::TYPE_TCP, ip_type);
@@ -62,7 +61,6 @@ Error TCP_Server::listen(uint16_t p_port, const IP_Address &p_bind_address) {
err = _sock->bind(p_bind_address, p_port);
if (err != OK) {
-
_sock->close();
return ERR_ALREADY_IN_USE;
}
@@ -83,18 +81,17 @@ bool TCP_Server::is_listening() const {
}
bool TCP_Server::is_connection_available() const {
-
ERR_FAIL_COND_V(!_sock.is_valid(), false);
- if (!_sock->is_open())
+ if (!_sock->is_open()) {
return false;
+ }
Error err = _sock->poll(NetSocket::POLL_TYPE_IN, 0);
return (err == OK);
}
Ref<StreamPeerTCP> TCP_Server::take_connection() {
-
Ref<StreamPeerTCP> conn;
if (!is_connection_available()) {
return conn;
@@ -104,8 +101,9 @@ Ref<StreamPeerTCP> TCP_Server::take_connection() {
IP_Address ip;
uint16_t port = 0;
ns = _sock->accept(ip, port);
- if (!ns.is_valid())
+ if (!ns.is_valid()) {
return conn;
+ }
conn = Ref<StreamPeerTCP>(memnew(StreamPeerTCP));
conn->accept_socket(ns, ip, port);
@@ -113,7 +111,6 @@ Ref<StreamPeerTCP> TCP_Server::take_connection() {
}
void TCP_Server::stop() {
-
if (_sock.is_valid()) {
_sock->close();
}
@@ -124,6 +121,5 @@ TCP_Server::TCP_Server() :
}
TCP_Server::~TCP_Server() {
-
stop();
}
diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h
index ca52b13ba1..eb715a745c 100644
--- a/core/io/tcp_server.h
+++ b/core/io/tcp_server.h
@@ -37,7 +37,6 @@
#include "core/io/stream_peer_tcp.h"
class TCP_Server : public Reference {
-
GDCLASS(TCP_Server, Reference);
protected:
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index bce5361c76..0e0a948953 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -34,7 +34,6 @@
#include "core/translation.h"
RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
-
enum Status {
STATUS_NONE,
@@ -48,8 +47,9 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
String msg_str;
String config;
- if (r_error)
+ if (r_error) {
*r_error = ERR_FILE_CORRUPT;
+ }
Ref<Translation> translation = Ref<Translation>(memnew(Translation));
int line = 1;
@@ -58,13 +58,11 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
bool is_eof = false;
while (!is_eof) {
-
String l = f->get_line().strip_edges();
is_eof = f->eof_reached();
// If we reached last line and it's not a content line, break, otherwise let processing that last loop
if (is_eof && l.empty()) {
-
if (status == STATUS_READING_ID) {
memdelete(f);
ERR_FAIL_V_MSG(RES(), f->get_path() + ":" + itos(line) + " Unexpected EOF while reading 'msgid' at file: ");
@@ -74,18 +72,18 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
}
if (l.begins_with("msgid")) {
-
if (status == STATUS_READING_ID) {
-
memdelete(f);
ERR_FAIL_V_MSG(RES(), f->get_path() + ":" + itos(line) + " Unexpected 'msgid', was expecting 'msgstr' while parsing: ");
}
if (msg_id != "") {
- if (!skip_this)
+ if (!skip_this) {
translation->add_message(msg_id, msg_str);
- } else if (config == "")
+ }
+ } else if (config == "") {
config = msg_str;
+ }
l = l.substr(5, l.length()).strip_edges();
status = STATUS_READING_ID;
@@ -96,9 +94,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
}
if (l.begins_with("msgstr")) {
-
if (status != STATUS_READING_ID) {
-
memdelete(f);
ERR_FAIL_V_MSG(RES(), f->get_path() + ":" + itos(line) + " Unexpected 'msgstr', was expecting 'msgid' while parsing: ");
}
@@ -142,10 +138,11 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
l = l.substr(0, end_pos);
l = l.c_unescape();
- if (status == STATUS_READING_ID)
+ if (status == STATUS_READING_ID) {
msg_id += l;
- else
+ } else {
msg_str += l;
+ }
line++;
}
@@ -154,23 +151,24 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
memdelete(f);
if (status == STATUS_READING_STRING) {
-
if (msg_id != "") {
- if (!skip_this)
+ if (!skip_this) {
translation->add_message(msg_id, msg_str);
- } else if (config == "")
+ }
+ } else if (config == "") {
config = msg_str;
+ }
}
ERR_FAIL_COND_V_MSG(config == "", RES(), "No config found in file: " + f->get_path() + ".");
Vector<String> configs = config.split("\n");
for (int i = 0; i < configs.size(); i++) {
-
String c = configs[i].strip_edges();
int p = c.find(":");
- if (p == -1)
+ if (p == -1) {
continue;
+ }
String prop = c.substr(0, p).strip_edges();
String value = c.substr(p + 1, c.length()).strip_edges();
@@ -179,16 +177,17 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) {
}
}
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return translation;
}
RES TranslationLoaderPO::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)
+ if (r_error) {
*r_error = ERR_CANT_OPEN;
+ }
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, RES(), "Cannot open file '" + p_path + "'.");
@@ -197,21 +196,17 @@ RES TranslationLoaderPO::load(const String &p_path, const String &p_original_pat
}
void TranslationLoaderPO::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("po");
//p_extensions->push_back("mo"); //mo in the future...
}
-bool TranslationLoaderPO::handles_type(const String &p_type) const {
+bool TranslationLoaderPO::handles_type(const String &p_type) const {
return (p_type == "Translation");
}
String TranslationLoaderPO::get_resource_type(const String &p_path) const {
-
- if (p_path.get_extension().to_lower() == "po")
+ if (p_path.get_extension().to_lower() == "po") {
return "Translation";
+ }
return "";
}
-
-TranslationLoaderPO::TranslationLoaderPO() {
-}
diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h
index 137dfd1768..a196a37dc0 100644
--- a/core/io/translation_loader_po.h
+++ b/core/io/translation_loader_po.h
@@ -43,7 +43,7 @@ public:
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
- TranslationLoaderPO();
+ TranslationLoaderPO() {}
};
#endif // TRANSLATION_LOADER_PO_H
diff --git a/core/io/udp_server.cpp b/core/io/udp_server.cpp
index 16b7863cdd..1d329daf8b 100644
--- a/core/io/udp_server.cpp
+++ b/core/io/udp_server.cpp
@@ -31,7 +31,6 @@
#include "udp_server.h"
void UDPServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &UDPServer::listen, DEFVAL("*"));
ClassDB::bind_method(D_METHOD("is_connection_available"), &UDPServer::is_connection_available);
ClassDB::bind_method(D_METHOD("is_listening"), &UDPServer::is_listening);
@@ -40,7 +39,6 @@ void UDPServer::_bind_methods() {
}
Error UDPServer::listen(uint16_t p_port, const IP_Address &p_bind_address) {
-
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
@@ -48,13 +46,15 @@ Error UDPServer::listen(uint16_t p_port, const IP_Address &p_bind_address) {
Error err;
IP::Type ip_type = IP::TYPE_ANY;
- if (p_bind_address.is_valid())
+ if (p_bind_address.is_valid()) {
ip_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+ }
err = _sock->open(NetSocket::TYPE_UDP, ip_type);
- if (err != OK)
+ if (err != OK) {
return ERR_CANT_CREATE;
+ }
_sock->set_blocking_enabled(false);
_sock->set_reuse_address_enabled(true);
@@ -76,18 +76,17 @@ bool UDPServer::is_listening() const {
}
bool UDPServer::is_connection_available() const {
-
ERR_FAIL_COND_V(!_sock.is_valid(), false);
- if (!_sock->is_open())
+ if (!_sock->is_open()) {
return false;
+ }
Error err = _sock->poll(NetSocket::POLL_TYPE_IN, 0);
return (err == OK);
}
Ref<PacketPeerUDP> UDPServer::take_connection() {
-
Ref<PacketPeerUDP> conn;
if (!is_connection_available()) {
return conn;
@@ -101,7 +100,6 @@ Ref<PacketPeerUDP> UDPServer::take_connection() {
}
void UDPServer::stop() {
-
if (_sock.is_valid()) {
_sock->close();
}
@@ -114,6 +112,5 @@ UDPServer::UDPServer() :
}
UDPServer::~UDPServer() {
-
stop();
}
diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp
index 9613ad3f10..b11267b60f 100644
--- a/core/io/xml_parser.cpp
+++ b/core/io/xml_parser.cpp
@@ -38,9 +38,11 @@ VARIANT_ENUM_CAST(XMLParser::NodeType);
static bool _equalsn(const CharType *str1, const CharType *str2, int len) {
int i;
- for (i = 0; i < len && str1[i] && str2[i]; ++i)
- if (str1[i] != str2[i])
+ for (i = 0; i < len && str1[i] && str2[i]; ++i) {
+ if (str1[i] != str2[i]) {
return false;
+ }
+ }
// if one (or both) of the strings was smaller then they
// are only equal if they have the same length
@@ -48,12 +50,12 @@ static bool _equalsn(const CharType *str1, const CharType *str2, int len) {
}
String XMLParser::_replace_special_characters(const String &origstr) {
-
int pos = origstr.find("&");
int oldPos = 0;
- if (pos == -1)
+ if (pos == -1) {
return origstr;
+ }
String newstr;
@@ -84,8 +86,9 @@ String XMLParser::_replace_special_characters(const String &origstr) {
pos = origstr.find("&", pos);
}
- if (oldPos < origstr.length() - 1)
+ if (oldPos < origstr.length() - 1) {
newstr += (origstr.substr(oldPos, origstr.length() - oldPos));
+ }
return newstr;
}
@@ -100,12 +103,15 @@ bool XMLParser::_set_text(char *start, char *end) {
// only white space, so that this text won't be reported
if (end - start < 3) {
char *p = start;
- for (; p != end; ++p)
- if (!_is_white_space(*p))
+ for (; p != end; ++p) {
+ if (!_is_white_space(*p)) {
break;
+ }
+ }
- if (p == end)
+ if (p == end) {
return false;
+ }
}
// set current text to the parsed text, and replace xml special characters
@@ -126,8 +132,9 @@ void XMLParser::_parse_closing_xml_element() {
++P;
const char *pBeginClose = P;
- while (*P != '>')
+ while (*P != '>') {
++P;
+ }
node_name = String::utf8(pBeginClose, (int)(P - pBeginClose));
#ifdef DEBUG_XML
@@ -141,16 +148,17 @@ void XMLParser::_ignore_definition() {
char *F = P;
// move until end marked with '>' reached
- while (*P != '>')
+ while (*P != '>') {
++P;
+ }
node_name.parse_utf8(F, P - F);
++P;
}
bool XMLParser::_parse_cdata() {
-
- if (*(P + 1) != '[')
+ if (*(P + 1) != '[') {
return false;
+ }
node_type = NODE_CDATA;
@@ -161,8 +169,9 @@ bool XMLParser::_parse_cdata() {
++count;
}
- if (!*P)
+ if (!*P) {
return true;
+ }
char *cDataBegin = P;
char *cDataEnd = nullptr;
@@ -178,10 +187,11 @@ bool XMLParser::_parse_cdata() {
++P;
}
- if (cDataEnd)
+ if (cDataEnd) {
node_name = String::utf8(cDataBegin, (int)(cDataEnd - cDataBegin));
- else
+ } else {
node_name = "";
+ }
#ifdef DEBUG_XML
print_line("XML CDATA: " + node_name);
#endif
@@ -190,7 +200,6 @@ bool XMLParser::_parse_cdata() {
}
void XMLParser::_parse_comment() {
-
node_type = NODE_COMMENT;
P += 1;
@@ -200,10 +209,11 @@ void XMLParser::_parse_comment() {
// move until end of comment reached
while (count) {
- if (*P == '>')
+ if (*P == '>') {
--count;
- else if (*P == '<')
+ } else if (*P == '<') {
++count;
+ }
++P;
}
@@ -217,7 +227,6 @@ void XMLParser::_parse_comment() {
}
void XMLParser::_parse_opening_xml_element() {
-
node_type = NODE_ELEMENT;
node_empty = false;
attributes.clear();
@@ -226,46 +235,52 @@ void XMLParser::_parse_opening_xml_element() {
const char *startName = P;
// find end of element
- while (*P != '>' && !_is_white_space(*P))
+ while (*P != '>' && !_is_white_space(*P)) {
++P;
+ }
const char *endName = P;
// find attributes
while (*P != '>') {
- if (_is_white_space(*P))
+ if (_is_white_space(*P)) {
++P;
- else {
+ } else {
if (*P != '/') {
// we've got an attribute
// read the attribute names
const char *attributeNameBegin = P;
- while (!_is_white_space(*P) && *P != '=')
+ while (!_is_white_space(*P) && *P != '=') {
++P;
+ }
const char *attributeNameEnd = P;
++P;
// read the attribute value
// check for quotes and single quotes, thx to murphy
- while ((*P != '\"') && (*P != '\'') && *P)
+ while ((*P != '\"') && (*P != '\'') && *P) {
++P;
+ }
- if (!*P) // malformatted xml file
+ if (!*P) { // malformatted xml file
return;
+ }
const char attributeQuoteChar = *P;
++P;
const char *attributeValueBegin = P;
- while (*P != attributeQuoteChar && *P)
+ while (*P != attributeQuoteChar && *P) {
++P;
+ }
- if (!*P) // malformatted xml file
+ if (!*P) { // malformatted xml file
return;
+ }
const char *attributeValueEnd = P;
++P;
@@ -304,21 +319,23 @@ void XMLParser::_parse_opening_xml_element() {
}
void XMLParser::_parse_current_node() {
-
char *start = P;
node_offset = P - data;
// more forward until '<' found
- while (*P != '<' && *P)
+ while (*P != '<' && *P) {
++P;
+ }
- if (!*P)
+ if (!*P) {
return;
+ }
if (P - start > 0) {
// we found some text, store it
- if (_set_text(start, P))
+ if (_set_text(start, P)) {
return;
+ }
}
++P;
@@ -332,8 +349,9 @@ void XMLParser::_parse_current_node() {
_ignore_definition();
break;
case '!':
- if (!_parse_cdata())
+ if (!_parse_cdata()) {
_parse_comment();
+ }
break;
default:
_parse_opening_xml_element();
@@ -342,22 +360,19 @@ void XMLParser::_parse_current_node() {
}
uint64_t XMLParser::get_node_offset() const {
-
return node_offset;
-};
+}
Error XMLParser::seek(uint64_t p_pos) {
-
ERR_FAIL_COND_V(!data, ERR_FILE_EOF);
ERR_FAIL_COND_V(p_pos >= length, ERR_FILE_EOF);
P = data + p_pos;
return read();
-};
+}
void XMLParser::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("read"), &XMLParser::read);
ClassDB::bind_method(D_METHOD("get_node_type"), &XMLParser::get_node_type);
ClassDB::bind_method(D_METHOD("get_node_name"), &XMLParser::get_node_name);
@@ -383,10 +398,9 @@ void XMLParser::_bind_methods() {
BIND_ENUM_CONSTANT(NODE_COMMENT);
BIND_ENUM_CONSTANT(NODE_CDATA);
BIND_ENUM_CONSTANT(NODE_UNKNOWN);
-};
+}
Error XMLParser::read() {
-
// if not end reached, parse the node
if (P && (P - data) < (int64_t)length - 1 && *P != 0) {
_parse_current_node();
@@ -397,11 +411,10 @@ Error XMLParser::read() {
}
XMLParser::NodeType XMLParser::get_node_type() {
-
return node_type;
}
-String XMLParser::get_node_data() const {
+String XMLParser::get_node_data() const {
ERR_FAIL_COND_V(node_type != NODE_TEXT, "");
return node_name;
}
@@ -410,31 +423,32 @@ String XMLParser::get_node_name() const {
ERR_FAIL_COND_V(node_type == NODE_TEXT, "");
return node_name;
}
-int XMLParser::get_attribute_count() const {
+int XMLParser::get_attribute_count() const {
return attributes.size();
}
-String XMLParser::get_attribute_name(int p_idx) const {
+String XMLParser::get_attribute_name(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, attributes.size(), "");
return attributes[p_idx].name;
}
-String XMLParser::get_attribute_value(int p_idx) const {
+String XMLParser::get_attribute_value(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, attributes.size(), "");
return attributes[p_idx].value;
}
-bool XMLParser::has_attribute(const String &p_name) const {
+bool XMLParser::has_attribute(const String &p_name) const {
for (int i = 0; i < attributes.size(); i++) {
- if (attributes[i].name == p_name)
+ if (attributes[i].name == p_name) {
return true;
+ }
}
return false;
}
-String XMLParser::get_attribute_value(const String &p_name) const {
+String XMLParser::get_attribute_value(const String &p_name) const {
int idx = -1;
for (int i = 0; i < attributes.size(); i++) {
if (attributes[i].name == p_name) {
@@ -449,7 +463,6 @@ String XMLParser::get_attribute_value(const String &p_name) const {
}
String XMLParser::get_attribute_value_safe(const String &p_name) const {
-
int idx = -1;
for (int i = 0; i < attributes.size(); i++) {
if (attributes[i].name == p_name) {
@@ -458,17 +471,17 @@ String XMLParser::get_attribute_value_safe(const String &p_name) const {
}
}
- if (idx < 0)
+ if (idx < 0) {
return "";
+ }
return attributes[idx].value;
}
-bool XMLParser::is_empty() const {
+bool XMLParser::is_empty() const {
return node_empty;
}
Error XMLParser::open_buffer(const Vector<uint8_t> &p_buffer) {
-
ERR_FAIL_COND_V(p_buffer.size() == 0, ERR_INVALID_DATA);
if (data) {
@@ -484,7 +497,6 @@ Error XMLParser::open_buffer(const Vector<uint8_t> &p_buffer) {
}
Error XMLParser::open(const String &p_path) {
-
Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -508,10 +520,10 @@ Error XMLParser::open(const String &p_path) {
}
void XMLParser::skip_section() {
-
// skip if this element is empty anyway.
- if (is_empty())
+ if (is_empty()) {
return;
+ }
// read until we've reached the last element in this section
int tagcount = 1;
@@ -520,15 +532,16 @@ void XMLParser::skip_section() {
if (get_node_type() == XMLParser::NODE_ELEMENT &&
!is_empty()) {
++tagcount;
- } else if (get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (get_node_type() == XMLParser::NODE_ELEMENT_END) {
--tagcount;
+ }
}
}
void XMLParser::close() {
-
- if (data)
+ if (data) {
memdelete_arr(data);
+ }
data = nullptr;
length = 0;
P = nullptr;
@@ -538,22 +551,19 @@ void XMLParser::close() {
}
int XMLParser::get_current_line() const {
-
return 0;
}
XMLParser::XMLParser() {
-
- data = nullptr;
- close();
special_characters.push_back("&amp;");
special_characters.push_back("<lt;");
special_characters.push_back(">gt;");
special_characters.push_back("\"quot;");
special_characters.push_back("'apos;");
}
-XMLParser::~XMLParser() {
- if (data)
+XMLParser::~XMLParser() {
+ if (data) {
memdelete_arr(data);
+ }
}
diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h
index 26c3e6802f..ee2174d52c 100644
--- a/core/io/xml_parser.h
+++ b/core/io/xml_parser.h
@@ -41,7 +41,6 @@
*/
class XMLParser : public Reference {
-
GDCLASS(XMLParser, Reference);
public:
@@ -66,15 +65,15 @@ public:
};
private:
- char *data;
- char *P;
- uint64_t length;
+ char *data = nullptr;
+ char *P = nullptr;
+ uint64_t length = 0;
void unescape(String &p_str);
Vector<String> special_characters;
String node_name;
- bool node_empty;
- NodeType node_type;
- uint64_t node_offset;
+ bool node_empty = false;
+ NodeType node_type = NODE_NONE;
+ uint64_t node_offset = 0;
struct Attribute {
String name;
diff --git a/core/io/zip_io.cpp b/core/io/zip_io.cpp
index 3a2a207d22..b8e7fd34d0 100644
--- a/core/io/zip_io.cpp
+++ b/core/io/zip_io.cpp
@@ -33,7 +33,6 @@
#include "core/os/copymem.h"
void *zipio_open(void *data, const char *p_fname, int mode) {
-
FileAccess *&f = *(FileAccess **)data;
String fname;
@@ -42,42 +41,37 @@ void *zipio_open(void *data, const char *p_fname, int mode) {
if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
f = FileAccess::open(fname, FileAccess::WRITE);
} else {
-
f = FileAccess::open(fname, FileAccess::READ);
}
- if (!f)
+ if (!f) {
return nullptr;
+ }
return data;
}
uLong zipio_read(void *data, void *fdata, void *buf, uLong size) {
-
FileAccess *f = *(FileAccess **)data;
return f->get_buffer((uint8_t *)buf, size);
}
uLong zipio_write(voidpf opaque, voidpf stream, const void *buf, uLong size) {
-
FileAccess *f = *(FileAccess **)opaque;
f->store_buffer((uint8_t *)buf, size);
return size;
}
long zipio_tell(voidpf opaque, voidpf stream) {
-
FileAccess *f = *(FileAccess **)opaque;
return f->get_position();
}
long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
-
FileAccess *f = *(FileAccess **)opaque;
int pos = offset;
switch (origin) {
-
case ZLIB_FILEFUNC_SEEK_CUR:
pos = f->get_position() + offset;
break;
@@ -86,14 +80,13 @@ long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
break;
default:
break;
- };
+ }
f->seek(pos);
return 0;
}
int zipio_close(voidpf opaque, voidpf stream) {
-
FileAccess *&f = *(FileAccess **)opaque;
if (f) {
f->close();
@@ -104,25 +97,21 @@ int zipio_close(voidpf opaque, voidpf stream) {
}
int zipio_testerror(voidpf opaque, voidpf stream) {
-
FileAccess *f = *(FileAccess **)opaque;
return (f && f->get_error() != OK) ? 1 : 0;
}
voidpf zipio_alloc(voidpf opaque, uInt items, uInt size) {
-
voidpf ptr = memalloc(items * size);
zeromem(ptr, items * size);
return ptr;
}
void zipio_free(voidpf opaque, voidpf address) {
-
memfree(address);
}
zlib_filefunc_def zipio_create_io_from_file(FileAccess **p_file) {
-
zlib_filefunc_def io;
io.opaque = p_file;
io.zopen_file = zipio_open;
diff --git a/core/list.h b/core/list.h
index 65d45ffdfc..6052a619fb 100644
--- a/core/list.h
+++ b/core/list.h
@@ -49,127 +49,117 @@ class List {
public:
class Element {
-
private:
friend class List<T, A>;
T value;
- Element *next_ptr;
- Element *prev_ptr;
- _Data *data;
+ Element *next_ptr = nullptr;
+ Element *prev_ptr = nullptr;
+ _Data *data = nullptr;
public:
/**
* Get NEXT Element iterator, for constant lists.
*/
_FORCE_INLINE_ const Element *next() const {
-
return next_ptr;
- };
+ }
/**
* Get NEXT Element iterator,
*/
_FORCE_INLINE_ Element *next() {
-
return next_ptr;
- };
+ }
/**
* Get PREV Element iterator, for constant lists.
*/
_FORCE_INLINE_ const Element *prev() const {
-
return prev_ptr;
- };
+ }
/**
* Get PREV Element iterator,
*/
_FORCE_INLINE_ Element *prev() {
-
return prev_ptr;
- };
+ }
/**
* * operator, for using as *iterator, when iterators are defined on stack.
*/
_FORCE_INLINE_ const T &operator*() const {
return value;
- };
+ }
/**
* operator->, for using as iterator->, when iterators are defined on stack, for constant lists.
*/
_FORCE_INLINE_ const T *operator->() const {
-
return &value;
- };
+ }
/**
* * operator, for using as *iterator, when iterators are defined on stack,
*/
_FORCE_INLINE_ T &operator*() {
return value;
- };
+ }
/**
* operator->, for using as iterator->, when iterators are defined on stack, for constant lists.
*/
_FORCE_INLINE_ T *operator->() {
return &value;
- };
+ }
/**
* get the value stored in this element.
*/
_FORCE_INLINE_ T &get() {
return value;
- };
+ }
/**
* get the value stored in this element, for constant lists
*/
_FORCE_INLINE_ const T &get() const {
return value;
- };
+ }
/**
* set the value stored in this element.
*/
_FORCE_INLINE_ void set(const T &p_value) {
value = (T &)p_value;
- };
+ }
void erase() {
-
data->erase(this);
}
- _FORCE_INLINE_ Element() {
- next_ptr = 0;
- prev_ptr = 0;
- data = nullptr;
- };
+ _FORCE_INLINE_ Element() {}
};
private:
struct _Data {
-
Element *first;
Element *last;
int size_cache;
bool erase(const Element *p_I) {
-
ERR_FAIL_COND_V(!p_I, false);
ERR_FAIL_COND_V(p_I->data != this, false);
if (first == p_I) {
first = p_I->next_ptr;
- };
+ }
- if (last == p_I)
+ if (last == p_I) {
last = p_I->prev_ptr;
+ }
- if (p_I->prev_ptr)
+ if (p_I->prev_ptr) {
p_I->prev_ptr->next_ptr = p_I->next_ptr;
+ }
- if (p_I->next_ptr)
+ if (p_I->next_ptr) {
p_I->next_ptr->prev_ptr = p_I->prev_ptr;
+ }
memdelete_allocator<Element, A>(const_cast<Element *>(p_I));
size_cache--;
@@ -178,47 +168,42 @@ private:
}
};
- _Data *_data;
+ _Data *_data = nullptr;
public:
/**
* return a const iterator to the beginning of the list.
*/
_FORCE_INLINE_ const Element *front() const {
-
- return _data ? _data->first : 0;
- };
+ return _data ? _data->first : nullptr;
+ }
/**
* return an iterator to the beginning of the list.
*/
_FORCE_INLINE_ Element *front() {
- return _data ? _data->first : 0;
- };
+ return _data ? _data->first : nullptr;
+ }
/**
* return a const iterator to the last member of the list.
*/
_FORCE_INLINE_ const Element *back() const {
-
- return _data ? _data->last : 0;
- };
+ return _data ? _data->last : nullptr;
+ }
/**
* return an iterator to the last member of the list.
*/
_FORCE_INLINE_ Element *back() {
-
- return _data ? _data->last : 0;
- };
+ return _data ? _data->last : nullptr;
+ }
/**
* store a new element at the end of the list
*/
Element *push_back(const T &value) {
-
if (!_data) {
-
_data = memnew_allocator(_Data, A);
_data->first = nullptr;
_data->last = nullptr;
@@ -229,37 +214,35 @@ public:
n->value = (T &)value;
n->prev_ptr = _data->last;
- n->next_ptr = 0;
+ n->next_ptr = nullptr;
n->data = _data;
if (_data->last) {
-
_data->last->next_ptr = n;
}
_data->last = n;
- if (!_data->first)
+ if (!_data->first) {
_data->first = n;
+ }
_data->size_cache++;
return n;
- };
+ }
void pop_back() {
-
- if (_data && _data->last)
+ if (_data && _data->last) {
erase(_data->last);
+ }
}
/**
* store a new element at the beginning of the list
*/
Element *push_front(const T &value) {
-
if (!_data) {
-
_data = memnew_allocator(_Data, A);
_data->first = nullptr;
_data->last = nullptr;
@@ -268,29 +251,29 @@ public:
Element *n = memnew_allocator(Element, A);
n->value = (T &)value;
- n->prev_ptr = 0;
+ n->prev_ptr = nullptr;
n->next_ptr = _data->first;
n->data = _data;
if (_data->first) {
-
_data->first->prev_ptr = n;
}
_data->first = n;
- if (!_data->last)
+ if (!_data->last) {
_data->last = n;
+ }
_data->size_cache++;
return n;
- };
+ }
void pop_front() {
-
- if (_data && _data->first)
+ if (_data && _data->first) {
erase(_data->first);
+ }
}
Element *insert_after(Element *p_element, const T &p_value) {
@@ -350,22 +333,21 @@ public:
*/
template <class T_v>
Element *find(const T_v &p_val) {
-
Element *it = front();
while (it) {
- if (it->value == p_val)
+ if (it->value == p_val) {
return it;
+ }
it = it->next();
- };
+ }
return nullptr;
- };
+ }
/**
* erase an element in the list, by iterator pointing to it. Return true if it was found/erased.
*/
bool erase(const Element *p_I) {
-
if (_data) {
bool ret = _data->erase(p_I);
@@ -378,22 +360,20 @@ public:
}
return false;
- };
+ }
/**
* erase the first element in the list, that contains value
*/
bool erase(const T &value) {
-
Element *I = find(value);
return erase(I);
- };
+ }
/**
* return whether the list is empty
*/
_FORCE_INLINE_ bool empty() const {
-
return (!_data || !_data->size_cache);
}
@@ -401,19 +381,16 @@ public:
* clear the list
*/
void clear() {
-
while (front()) {
erase(front());
- };
- };
+ }
+ }
_FORCE_INLINE_ int size() const {
-
return _data ? _data->size_cache : 0;
}
void swap(Element *p_A, Element *p_B) {
-
ERR_FAIL_COND(!p_A || !p_B);
ERR_FAIL_COND(p_A->data != _data);
ERR_FAIL_COND(p_B->data != _data);
@@ -427,32 +404,33 @@ public:
p_B->next_ptr = A_next;
p_B->prev_ptr = A_prev;
- if (p_A->prev_ptr)
+ if (p_A->prev_ptr) {
p_A->prev_ptr->next_ptr = p_A;
- if (p_A->next_ptr)
+ }
+ if (p_A->next_ptr) {
p_A->next_ptr->prev_ptr = p_A;
+ }
- if (p_B->prev_ptr)
+ if (p_B->prev_ptr) {
p_B->prev_ptr->next_ptr = p_B;
- if (p_B->next_ptr)
+ }
+ if (p_B->next_ptr) {
p_B->next_ptr->prev_ptr = p_B;
+ }
}
/**
* copy the list
*/
void operator=(const List &p_list) {
-
clear();
const Element *it = p_list.front();
while (it) {
-
push_back(it->get());
it = it->next();
}
}
T &operator[](int p_index) {
-
CRASH_BAD_INDEX(p_index, size());
Element *I = front();
@@ -466,7 +444,6 @@ public:
}
const T &operator[](int p_index) const {
-
CRASH_BAD_INDEX(p_index, size());
const Element *I = front();
@@ -480,20 +457,22 @@ public:
}
void move_to_back(Element *p_I) {
-
ERR_FAIL_COND(p_I->data != _data);
- if (!p_I->next_ptr)
+ if (!p_I->next_ptr) {
return;
+ }
if (_data->first == p_I) {
_data->first = p_I->next_ptr;
- };
+ }
- if (_data->last == p_I)
+ if (_data->last == p_I) {
_data->last = p_I->prev_ptr;
+ }
- if (p_I->prev_ptr)
+ if (p_I->prev_ptr) {
p_I->prev_ptr->next_ptr = p_I->next_ptr;
+ }
p_I->next_ptr->prev_ptr = p_I->prev_ptr;
@@ -504,12 +483,10 @@ public:
}
void invert() {
-
int s = size() / 2;
Element *F = front();
Element *B = back();
for (int i = 0; i < s; i++) {
-
SWAP(F->value, B->value);
F = F->next();
B = B->prev();
@@ -517,22 +494,24 @@ public:
}
void move_to_front(Element *p_I) {
-
ERR_FAIL_COND(p_I->data != _data);
- if (!p_I->prev_ptr)
+ if (!p_I->prev_ptr) {
return;
+ }
if (_data->first == p_I) {
_data->first = p_I->next_ptr;
- };
+ }
- if (_data->last == p_I)
+ if (_data->last == p_I) {
_data->last = p_I->prev_ptr;
+ }
p_I->prev_ptr->next_ptr = p_I->next_ptr;
- if (p_I->next_ptr)
+ if (p_I->next_ptr) {
p_I->next_ptr->prev_ptr = p_I->prev_ptr;
+ }
_data->first->prev_ptr = p_I;
p_I->next_ptr = _data->first;
@@ -541,7 +520,6 @@ public:
}
void move_before(Element *value, Element *where) {
-
if (value->prev_ptr) {
value->prev_ptr->next_ptr = value->next_ptr;
} else {
@@ -558,7 +536,7 @@ public:
value->prev_ptr = _data->last;
_data->last = value;
return;
- };
+ }
value->prev_ptr = where->prev_ptr;
@@ -566,59 +544,56 @@ public:
where->prev_ptr->next_ptr = value;
} else {
_data->first = value;
- };
+ }
where->prev_ptr = value;
- };
+ }
/**
* simple insertion sort
*/
void sort() {
-
sort_custom<Comparator<T>>();
}
template <class C>
void sort_custom_inplace() {
-
- if (size() < 2)
+ if (size() < 2) {
return;
+ }
Element *from = front();
Element *current = from;
Element *to = from;
while (current) {
-
Element *next = current->next_ptr;
if (from != current) {
-
current->prev_ptr = nullptr;
current->next_ptr = from;
Element *find = from;
C less;
while (find && less(find->value, current->value)) {
-
current->prev_ptr = find;
current->next_ptr = find->next_ptr;
find = find->next_ptr;
}
- if (current->prev_ptr)
+ if (current->prev_ptr) {
current->prev_ptr->next_ptr = current;
- else
+ } else {
from = current;
+ }
- if (current->next_ptr)
+ if (current->next_ptr) {
current->next_ptr->prev_ptr = current;
- else
+ } else {
to = current;
+ }
} else {
-
current->prev_ptr = nullptr;
current->next_ptr = nullptr;
}
@@ -631,29 +606,26 @@ public:
template <class C>
struct AuxiliaryComparator {
-
C compare;
_FORCE_INLINE_ bool operator()(const Element *a, const Element *b) const {
-
return compare(a->value, b->value);
}
};
template <class C>
void sort_custom() {
-
//this version uses auxiliary memory for speed.
//if you don't want to use auxiliary memory, use the in_place version
int s = size();
- if (s < 2)
+ if (s < 2) {
return;
+ }
Element **aux_buffer = memnew_arr(Element *, s);
int idx = 0;
for (Element *E = front(); E; E = E->next_ptr) {
-
aux_buffer[idx] = E;
idx++;
}
@@ -670,7 +642,6 @@ public:
aux_buffer[s - 1]->next_ptr = nullptr;
for (int i = 1; i < s - 1; i++) {
-
aux_buffer[i]->prev_ptr = aux_buffer[i - 1];
aux_buffer[i]->next_ptr = aux_buffer[i + 1];
}
@@ -686,27 +657,22 @@ public:
* copy constructor for the list
*/
List(const List &p_list) {
-
- _data = nullptr;
const Element *it = p_list.front();
while (it) {
-
push_back(it->get());
it = it->next();
}
}
- List() {
- _data = nullptr;
- };
+ List() {}
+
~List() {
clear();
if (_data) {
-
ERR_FAIL_COND(_data->size_cache);
memdelete_allocator<_Data, A>(_data);
}
- };
+ }
};
#endif // LIST_H
diff --git a/core/local_vector.h b/core/local_vector.h
index 0b0ef6dfdc..7f96b25f8b 100644
--- a/core/local_vector.h
+++ b/core/local_vector.h
@@ -75,13 +75,13 @@ public:
}
void erase(const T &p_val) {
- U idx = find(p_val);
- if (idx >= 0)
+ int64_t idx = find(p_val);
+ if (idx >= 0) {
remove(idx);
+ }
}
void invert() {
-
for (U i = 0; i < count / 2; i++) {
SWAP(data[i], data[count - i - 1]);
}
@@ -108,9 +108,7 @@ public:
_FORCE_INLINE_ U size() const { return count; }
void resize(U p_size) {
-
if (p_size < count) {
-
if (!__has_trivial_destructor(T) && !force_trivial) {
for (U i = p_size; i < count; i++) {
data[i].~T();
@@ -118,7 +116,6 @@ public:
}
count = p_size;
} else if (p_size > count) {
-
if (unlikely(p_size > capacity)) {
if (capacity == 0) {
capacity = 1;
@@ -160,7 +157,6 @@ public:
}
int64_t find(const T &p_val, U p_from = 0) const {
-
for (U i = 0; i < count; i++) {
if (data[i] == p_val) {
return int64_t(i);
@@ -171,29 +167,26 @@ public:
template <class C>
void sort_custom() {
-
U len = count;
- if (len == 0)
+ if (len == 0) {
return;
+ }
SortArray<T, C> sorter;
sorter.sort(data, len);
}
void sort() {
-
sort_custom<_DefaultComparator<T>>();
}
void ordered_insert(T p_val) {
-
U i;
for (i = 0; i < count; i++) {
-
if (p_val < data[i]) {
break;
- };
- };
+ }
+ }
insert(i, p_val);
}
@@ -236,7 +229,6 @@ public:
}
_FORCE_INLINE_ ~LocalVector() {
-
if (data) {
reset();
}
diff --git a/core/make_binders.py b/core/make_binders.py
index 94bee95bfb..7d0d08cde6 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -75,7 +75,7 @@ public:
#endif
$ifret _set_returns(true); $
- };
+ }
};
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
@@ -170,7 +170,7 @@ public:
$ifret _set_returns(true); $
- };
+ }
};
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
@@ -266,7 +266,7 @@ public:
#endif
$ifret _set_returns(true); $
- };
+ }
};
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
diff --git a/core/map.h b/core/map.h
index 6b9dff51de..fd4f500556 100644
--- a/core/map.h
+++ b/core/map.h
@@ -39,7 +39,6 @@
template <class K, class V, class C = Comparator<K>, class A = DefaultAllocator>
class Map {
-
enum Color {
RED,
BLACK
@@ -48,67 +47,54 @@ class Map {
public:
class Element {
-
private:
friend class Map<K, V, C, A>;
- int color;
- Element *right;
- Element *left;
- Element *parent;
- Element *_next;
- Element *_prev;
+ int color = RED;
+ Element *right = nullptr;
+ Element *left = nullptr;
+ Element *parent = nullptr;
+ Element *_next = nullptr;
+ Element *_prev = nullptr;
K _key;
V _value;
//_Data *data;
public:
const Element *next() const {
-
return _next;
}
Element *next() {
-
return _next;
}
const Element *prev() const {
-
return _prev;
}
Element *prev() {
-
return _prev;
}
const K &key() const {
return _key;
- };
+ }
V &value() {
return _value;
- };
+ }
const V &value() const {
return _value;
- };
+ }
V &get() {
return _value;
- };
+ }
const V &get() const {
return _value;
- };
- Element() {
- color = RED;
- right = nullptr;
- left = nullptr;
- parent = nullptr;
- _next = nullptr;
- _prev = nullptr;
- };
+ }
+ Element() {}
};
private:
struct _Data {
-
- Element *_root;
+ Element *_root = nullptr;
Element *_nil;
- int size_cache;
+ int size_cache = 0;
_FORCE_INLINE_ _Data() {
#ifdef GLOBALNIL_DISABLED
@@ -118,19 +104,15 @@ private:
#else
_nil = (Element *)&_GlobalNilClass::_nil;
#endif
- _root = nullptr;
- size_cache = 0;
}
void _create_root() {
-
_root = memnew_allocator(Element, A);
_root->parent = _root->left = _root->right = _nil;
_root->color = BLACK;
}
void _free_root() {
-
if (_root) {
memdelete_allocator<Element, A>(_root);
_root = nullptr;
@@ -138,7 +120,6 @@ private:
}
~_Data() {
-
_free_root();
#ifdef GLOBALNIL_DISABLED
@@ -150,62 +131,61 @@ private:
_Data _data;
inline void _set_color(Element *p_node, int p_color) {
-
ERR_FAIL_COND(p_node == _data._nil && p_color == RED);
p_node->color = p_color;
}
inline void _rotate_left(Element *p_node) {
-
Element *r = p_node->right;
p_node->right = r->left;
- if (r->left != _data._nil)
+ if (r->left != _data._nil) {
r->left->parent = p_node;
+ }
r->parent = p_node->parent;
- if (p_node == p_node->parent->left)
+ if (p_node == p_node->parent->left) {
p_node->parent->left = r;
- else
+ } else {
p_node->parent->right = r;
+ }
r->left = p_node;
p_node->parent = r;
}
inline void _rotate_right(Element *p_node) {
-
Element *l = p_node->left;
p_node->left = l->right;
- if (l->right != _data._nil)
+ if (l->right != _data._nil) {
l->right->parent = p_node;
+ }
l->parent = p_node->parent;
- if (p_node == p_node->parent->right)
+ if (p_node == p_node->parent->right) {
p_node->parent->right = l;
- else
+ } else {
p_node->parent->left = l;
+ }
l->right = p_node;
p_node->parent = l;
}
inline Element *_successor(Element *p_node) const {
-
Element *node = p_node;
if (node->right != _data._nil) {
-
node = node->right;
while (node->left != _data._nil) { /* returns the minimum of the right subtree of node */
node = node->left;
}
return node;
} else {
-
while (node == node->parent->right) {
node = node->parent;
}
- if (node->parent == _data._root)
+ if (node->parent == _data._root) {
return nullptr; // No successor, as p_node = last node
+ }
return node->parent;
}
}
@@ -214,43 +194,41 @@ private:
Element *node = p_node;
if (node->left != _data._nil) {
-
node = node->left;
while (node->right != _data._nil) { /* returns the minimum of the left subtree of node */
node = node->right;
}
return node;
} else {
-
while (node == node->parent->left) {
node = node->parent;
}
- if (node == _data._root)
+ if (node == _data._root) {
return nullptr; // No predecessor, as p_node = first node
+ }
return node->parent;
}
}
Element *_find(const K &p_key) const {
-
Element *node = _data._root->left;
C less;
while (node != _data._nil) {
- if (less(p_key, node->_key))
+ if (less(p_key, node->_key)) {
node = node->left;
- else if (less(node->_key, p_key))
+ } else if (less(node->_key, p_key)) {
node = node->right;
- else
+ } else {
return node; // found
+ }
}
return nullptr;
}
Element *_find_closest(const K &p_key) const {
-
Element *node = _data._root->left;
Element *prev = nullptr;
C less;
@@ -258,25 +236,27 @@ private:
while (node != _data._nil) {
prev = node;
- if (less(p_key, node->_key))
+ if (less(p_key, node->_key)) {
node = node->left;
- else if (less(node->_key, p_key))
+ } else if (less(node->_key, p_key)) {
node = node->right;
- else
+ } else {
return node; // found
+ }
}
- if (prev == nullptr)
+ if (prev == nullptr) {
return nullptr; // tree empty
+ }
- if (less(p_key, prev->_key))
+ if (less(p_key, prev->_key)) {
prev = prev->_prev;
+ }
return prev;
}
void _insert_rb_fix(Element *p_new_node) {
-
Element *node = p_new_node;
Element *nparent = node->parent;
Element *ngrand_parent;
@@ -325,20 +305,18 @@ private:
}
Element *_insert(const K &p_key, const V &p_value) {
-
Element *new_parent = _data._root;
Element *node = _data._root->left;
C less;
while (node != _data._nil) {
-
new_parent = node;
- if (less(p_key, node->_key))
+ if (less(p_key, node->_key)) {
node = node->left;
- else if (less(node->_key, p_key))
+ } else if (less(node->_key, p_key)) {
node = node->right;
- else {
+ } else {
node->_value = p_value;
return node; // Return existing node with new value
}
@@ -360,10 +338,12 @@ private:
new_node->_next = _successor(new_node);
new_node->_prev = _predecessor(new_node);
- if (new_node->_next)
+ if (new_node->_next) {
new_node->_next->_prev = new_node;
- if (new_node->_prev)
+ }
+ if (new_node->_prev) {
new_node->_prev->_next = new_node;
+ }
_data.size_cache++;
_insert_rb_fix(new_node);
@@ -371,7 +351,6 @@ private:
}
void _erase_fix_rb(Element *p_node) {
-
Element *root = _data._root->left;
Element *node = _data._nil;
Element *sibling = p_node;
@@ -433,7 +412,6 @@ private:
}
void _erase(Element *p_node) {
-
Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next;
Element *node = (rp->left == _data._nil) ? rp->right : rp->left;
@@ -454,17 +432,18 @@ private:
}
if (rp != p_node) {
-
ERR_FAIL_COND(rp == _data._nil);
rp->left = p_node->left;
rp->right = p_node->right;
rp->parent = p_node->parent;
rp->color = p_node->color;
- if (p_node->left != _data._nil)
+ if (p_node->left != _data._nil) {
p_node->left->parent = rp;
- if (p_node->right != _data._nil)
+ }
+ if (p_node->right != _data._nil) {
p_node->right->parent = rp;
+ }
if (p_node == p_node->parent->left) {
p_node->parent->left = rp;
@@ -473,10 +452,12 @@ private:
}
}
- if (p_node->_next)
+ if (p_node->_next) {
p_node->_next->_prev = p_node->_prev;
- if (p_node->_prev)
+ }
+ if (p_node->_prev) {
p_node->_prev->_next = p_node->_next;
+ }
memdelete_allocator<Element, A>(p_node);
_data.size_cache--;
@@ -484,21 +465,22 @@ private:
}
void _calculate_depth(Element *p_element, int &max_d, int d) const {
-
- if (p_element == _data._nil)
+ if (p_element == _data._nil) {
return;
+ }
_calculate_depth(p_element->left, max_d, d + 1);
_calculate_depth(p_element->right, max_d, d + 1);
- if (d > max_d)
+ if (d > max_d) {
max_d = d;
+ }
}
void _cleanup_tree(Element *p_element) {
-
- if (p_element == _data._nil)
+ if (p_element == _data._nil) {
return;
+ }
_cleanup_tree(p_element->left);
_cleanup_tree(p_element->right);
@@ -506,91 +488,90 @@ private:
}
void _copy_from(const Map &p_map) {
-
clear();
// not the fastest way, but safeset to write.
for (Element *I = p_map.front(); I; I = I->next()) {
-
insert(I->key(), I->value());
}
}
public:
const Element *find(const K &p_key) const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
const Element *res = _find(p_key);
return res;
}
Element *find(const K &p_key) {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *res = _find(p_key);
return res;
}
const Element *find_closest(const K &p_key) const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
const Element *res = _find_closest(p_key);
return res;
}
Element *find_closest(const K &p_key) {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *res = _find_closest(p_key);
return res;
}
bool has(const K &p_key) const {
-
return find(p_key) != nullptr;
}
Element *insert(const K &p_key, const V &p_value) {
-
- if (!_data._root)
+ if (!_data._root) {
_data._create_root();
+ }
return _insert(p_key, p_value);
}
void erase(Element *p_element) {
-
- if (!_data._root || !p_element)
+ if (!_data._root || !p_element) {
return;
+ }
_erase(p_element);
- if (_data.size_cache == 0 && _data._root)
+ if (_data.size_cache == 0 && _data._root) {
_data._free_root();
+ }
}
bool erase(const K &p_key) {
-
- if (!_data._root)
+ if (!_data._root) {
return false;
+ }
Element *e = find(p_key);
- if (!e)
+ if (!e) {
return false;
+ }
_erase(e);
- if (_data.size_cache == 0 && _data._root)
+ if (_data.size_cache == 0 && _data._root) {
_data._free_root();
+ }
return true;
}
const V &operator[](const K &p_key) const {
-
CRASH_COND(!_data._root);
const Element *e = find(p_key);
CRASH_COND(!e);
@@ -598,43 +579,48 @@ public:
}
V &operator[](const K &p_key) {
-
- if (!_data._root)
+ if (!_data._root) {
_data._create_root();
+ }
Element *e = find(p_key);
- if (!e)
+ if (!e) {
e = insert(p_key, V());
+ }
return e->_value;
}
Element *front() const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *e = _data._root->left;
- if (e == _data._nil)
+ if (e == _data._nil) {
return nullptr;
+ }
- while (e->left != _data._nil)
+ while (e->left != _data._nil) {
e = e->left;
+ }
return e;
}
Element *back() const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *e = _data._root->left;
- if (e == _data._nil)
+ if (e == _data._nil) {
return nullptr;
+ }
- while (e->right != _data._nil)
+ while (e->right != _data._nil) {
e = e->right;
+ }
return e;
}
@@ -644,8 +630,9 @@ public:
int calculate_depth() const {
// used for debug mostly
- if (!_data._root)
+ if (!_data._root) {
return 0;
+ }
int max_d = 0;
_calculate_depth(_data._root->left, max_d, 0);
@@ -653,9 +640,9 @@ public:
}
void clear() {
-
- if (!_data._root)
+ if (!_data._root) {
return;
+ }
_cleanup_tree(_data._root->left);
_data._root->left = _data._nil;
@@ -664,20 +651,16 @@ public:
}
void operator=(const Map &p_map) {
-
_copy_from(p_map);
}
Map(const Map &p_map) {
-
_copy_from(p_map);
}
- _FORCE_INLINE_ Map() {
- }
+ _FORCE_INLINE_ Map() {}
~Map() {
-
clear();
}
};
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 3aba753f51..30f712b2c3 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -30,12 +30,11 @@
#include "a_star.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/script_language.h"
#include "scene/scene_string_names.h"
int AStar::get_available_point_id() const {
-
if (points.empty()) {
return 1;
}
@@ -54,7 +53,6 @@ int AStar::get_available_point_id() const {
}
void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) {
-
ERR_FAIL_COND(p_id < 0);
ERR_FAIL_COND(p_weight_scale < 1);
@@ -78,7 +76,6 @@ void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) {
}
Vector3 AStar::get_point_position(int p_id) const {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND_V(!p_exists, Vector3());
@@ -87,7 +84,6 @@ Vector3 AStar::get_point_position(int p_id) const {
}
void AStar::set_point_position(int p_id, const Vector3 &p_pos) {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND(!p_exists);
@@ -96,7 +92,6 @@ void AStar::set_point_position(int p_id, const Vector3 &p_pos) {
}
real_t AStar::get_point_weight_scale(int p_id) const {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND_V(!p_exists, 0);
@@ -105,7 +100,6 @@ real_t AStar::get_point_weight_scale(int p_id) const {
}
void AStar::set_point_weight_scale(int p_id, real_t p_weight_scale) {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND(!p_exists);
@@ -115,13 +109,11 @@ void AStar::set_point_weight_scale(int p_id, real_t p_weight_scale) {
}
void AStar::remove_point(int p_id) {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND(!p_exists);
for (OAHashMap<int, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) {
-
Segment s(p_id, (*it.key));
segments.erase(s);
@@ -130,7 +122,6 @@ void AStar::remove_point(int p_id) {
}
for (OAHashMap<int, Point *>::Iterator it = p->unlinked_neighbours.iter(); it.valid; it = p->unlinked_neighbours.next_iter(it)) {
-
Segment s(p_id, (*it.key));
segments.erase(s);
@@ -144,7 +135,6 @@ void AStar::remove_point(int p_id) {
}
void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
-
ERR_FAIL_COND(p_id == p_with_id);
Point *a;
@@ -164,8 +154,9 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
}
Segment s(p_id, p_with_id);
- if (bidirectional)
+ if (bidirectional) {
s.direction = Segment::BIDIRECTIONAL;
+ }
Set<Segment>::Element *element = segments.find(s);
if (element != nullptr) {
@@ -182,7 +173,6 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
}
void AStar::disconnect_points(int p_id, int p_with_id, bool bidirectional) {
-
Point *a;
bool a_exists = points.lookup(p_id, a);
ERR_FAIL_COND(!a_exists);
@@ -208,25 +198,25 @@ void AStar::disconnect_points(int p_id, int p_with_id, bool bidirectional) {
b->unlinked_neighbours.remove(a->id);
}
} else {
- if (s.direction == Segment::NONE)
+ if (s.direction == Segment::NONE) {
b->unlinked_neighbours.remove(a->id);
- else
+ } else {
a->unlinked_neighbours.set(b->id, b);
+ }
}
segments.erase(element);
- if (s.direction != Segment::NONE)
+ if (s.direction != Segment::NONE) {
segments.insert(s);
+ }
}
}
bool AStar::has_point(int p_id) const {
-
return points.has(p_id);
}
Array AStar::get_points() {
-
Array point_list;
for (OAHashMap<int, Point *>::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) {
@@ -237,7 +227,6 @@ Array AStar::get_points() {
}
Vector<int> AStar::get_point_connections(int p_id) {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND_V(!p_exists, Vector<int>());
@@ -252,7 +241,6 @@ Vector<int> AStar::get_point_connections(int p_id) {
}
bool AStar::are_points_connected(int p_id, int p_with_id, bool bidirectional) const {
-
Segment s(p_id, p_with_id);
const Set<Segment>::Element *element = segments.find(s);
@@ -261,7 +249,6 @@ bool AStar::are_points_connected(int p_id, int p_with_id, bool bidirectional) co
}
void AStar::clear() {
-
last_free_id = 0;
for (OAHashMap<int, Point *>::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) {
memdelete(*(it.value));
@@ -285,19 +272,24 @@ void AStar::reserve_space(int p_num_nodes) {
}
int AStar::get_closest_point(const Vector3 &p_point, bool p_include_disabled) const {
-
int closest_id = -1;
real_t closest_dist = 1e20;
for (OAHashMap<int, Point *>::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) {
-
- if (!p_include_disabled && !(*it.value)->enabled)
+ if (!p_include_disabled && !(*it.value)->enabled) {
continue; // Disabled points should not be considered.
+ }
+ // Keep the closest point's ID, and in case of multiple closest IDs,
+ // the smallest one (makes it deterministic).
real_t d = p_point.distance_squared_to((*it.value)->pos);
- if (closest_id < 0 || d < closest_dist) {
+ int id = *(it.key);
+ if (d <= closest_dist) {
+ if (d == closest_dist && id > closest_id) { // Keep lowest ID.
+ continue;
+ }
closest_dist = d;
- closest_id = *(it.key);
+ closest_id = id;
}
}
@@ -305,13 +297,10 @@ int AStar::get_closest_point(const Vector3 &p_point, bool p_include_disabled) co
}
Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const {
-
- bool found = false;
real_t closest_dist = 1e20;
Vector3 closest_point;
for (const Set<Segment>::Element *E = segments.front(); E; E = E->next()) {
-
Point *from_point = nullptr, *to_point = nullptr;
points.lookup(E->get().u, from_point);
points.lookup(E->get().v, to_point);
@@ -325,13 +314,11 @@ Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const {
to_point->pos,
};
- Vector3 p = Geometry::get_closest_point_to_segment(p_point, segment);
+ Vector3 p = Geometry3D::get_closest_point_to_segment(p_point, segment);
real_t d = p_point.distance_squared_to(p);
- if (!found || d < closest_dist) {
-
+ if (d < closest_dist) {
closest_point = p;
closest_dist = d;
- found = true;
}
}
@@ -339,11 +326,11 @@ Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const {
}
bool AStar::_solve(Point *begin_point, Point *end_point) {
-
pass++;
- if (!end_point->enabled)
+ if (!end_point->enabled) {
return false;
+ }
bool found_route = false;
@@ -355,7 +342,6 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
open_list.push_back(begin_point);
while (!open_list.empty()) {
-
Point *p = open_list[0]; // The currently processed point
if (p == end_point) {
@@ -368,7 +354,6 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
p->closed_pass = pass; // Mark the point as closed
for (OAHashMap<int, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) {
-
Point *e = *(it.value); // The neighbour point
if (!e->enabled || e->closed_pass == pass) {
@@ -403,9 +388,9 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
}
real_t AStar::_estimate_cost(int p_from_id, int p_to_id) {
-
- if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_estimate_cost))
+ if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_estimate_cost)) {
return get_script_instance()->call(SceneStringNames::get_singleton()->_estimate_cost, p_from_id, p_to_id);
+ }
Point *from_point;
bool from_exists = points.lookup(p_from_id, from_point);
@@ -419,9 +404,9 @@ real_t AStar::_estimate_cost(int p_from_id, int p_to_id) {
}
real_t AStar::_compute_cost(int p_from_id, int p_to_id) {
-
- if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_compute_cost))
+ if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_compute_cost)) {
return get_script_instance()->call(SceneStringNames::get_singleton()->_compute_cost, p_from_id, p_to_id);
+ }
Point *from_point;
bool from_exists = points.lookup(p_from_id, from_point);
@@ -435,7 +420,6 @@ real_t AStar::_compute_cost(int p_from_id, int p_to_id) {
}
Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
-
Point *a;
bool from_exists = points.lookup(p_from_id, a);
ERR_FAIL_COND_V(!from_exists, Vector<Vector3>());
@@ -454,8 +438,9 @@ Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route)
+ if (!found_route) {
return Vector<Vector3>();
+ }
Point *p = end_point;
int pc = 1; // Begin point
@@ -484,7 +469,6 @@ Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
}
Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
-
Point *a;
bool from_exists = points.lookup(p_from_id, a);
ERR_FAIL_COND_V(!from_exists, Vector<int>());
@@ -503,8 +487,9 @@ Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route)
+ if (!found_route) {
return Vector<int>();
+ }
Point *p = end_point;
int pc = 1; // Begin point
@@ -533,7 +518,6 @@ Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
}
void AStar::set_point_disabled(int p_id, bool p_disabled) {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND(!p_exists);
@@ -542,7 +526,6 @@ void AStar::set_point_disabled(int p_id, bool p_disabled) {
}
bool AStar::is_point_disabled(int p_id) const {
-
Point *p;
bool p_exists = points.lookup(p_id, p);
ERR_FAIL_COND_V(!p_exists, false);
@@ -551,7 +534,6 @@ bool AStar::is_point_disabled(int p_id) const {
}
void AStar::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_available_point_id"), &AStar::get_available_point_id);
ClassDB::bind_method(D_METHOD("add_point", "id", "position", "weight_scale"), &AStar::add_point, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("get_point_position", "id"), &AStar::get_point_position);
@@ -585,11 +567,6 @@ void AStar::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
}
-AStar::AStar() {
- last_free_id = 0;
- pass = 1;
-}
-
AStar::~AStar() {
clear();
}
@@ -683,9 +660,9 @@ Vector2 AStar2D::get_closest_position_in_segment(const Vector2 &p_point) const {
}
real_t AStar2D::_estimate_cost(int p_from_id, int p_to_id) {
-
- if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_estimate_cost))
+ if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_estimate_cost)) {
return get_script_instance()->call(SceneStringNames::get_singleton()->_estimate_cost, p_from_id, p_to_id);
+ }
AStar::Point *from_point;
bool from_exists = astar.points.lookup(p_from_id, from_point);
@@ -699,9 +676,9 @@ real_t AStar2D::_estimate_cost(int p_from_id, int p_to_id) {
}
real_t AStar2D::_compute_cost(int p_from_id, int p_to_id) {
-
- if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_compute_cost))
+ if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_compute_cost)) {
return get_script_instance()->call(SceneStringNames::get_singleton()->_compute_cost, p_from_id, p_to_id);
+ }
AStar::Point *from_point;
bool from_exists = astar.points.lookup(p_from_id, from_point);
@@ -715,7 +692,6 @@ real_t AStar2D::_compute_cost(int p_from_id, int p_to_id) {
}
Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
-
AStar::Point *a;
bool from_exists = astar.points.lookup(p_from_id, a);
ERR_FAIL_COND_V(!from_exists, Vector<Vector2>());
@@ -734,8 +710,9 @@ Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
AStar::Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route)
+ if (!found_route) {
return Vector<Vector2>();
+ }
AStar::Point *p = end_point;
int pc = 1; // Begin point
@@ -764,7 +741,6 @@ Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
}
Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
-
AStar::Point *a;
bool from_exists = astar.points.lookup(p_from_id, a);
ERR_FAIL_COND_V(!from_exists, Vector<int>());
@@ -783,8 +759,9 @@ Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
AStar::Point *end_point = b;
bool found_route = _solve(begin_point, end_point);
- if (!found_route)
+ if (!found_route) {
return Vector<int>();
+ }
AStar::Point *p = end_point;
int pc = 1; // Begin point
@@ -813,11 +790,11 @@ Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
}
bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) {
-
astar.pass++;
- if (!end_point->enabled)
+ if (!end_point->enabled) {
return false;
+ }
bool found_route = false;
@@ -829,7 +806,6 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) {
open_list.push_back(begin_point);
while (!open_list.empty()) {
-
AStar::Point *p = open_list[0]; // The currently processed point
if (p == end_point) {
@@ -842,7 +818,6 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) {
p->closed_pass = astar.pass; // Mark the point as closed
for (OAHashMap<int, AStar::Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) {
-
AStar::Point *e = *(it.value); // The neighbour point
if (!e->enabled || e->closed_pass == astar.pass) {
@@ -877,7 +852,6 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) {
}
void AStar2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_available_point_id"), &AStar2D::get_available_point_id);
ClassDB::bind_method(D_METHOD("add_point", "id", "position", "weight_scale"), &AStar2D::add_point, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("get_point_position", "id"), &AStar2D::get_point_position);
@@ -910,9 +884,3 @@ void AStar2D::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id")));
}
-
-AStar2D::AStar2D() {
-}
-
-AStar2D::~AStar2D() {
-}
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 8c10ace33c..ba1c3033b8 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -41,23 +41,19 @@
*/
class AStar : public Reference {
-
GDCLASS(AStar, Reference);
friend class AStar2D;
struct Point {
-
- Point() :
- neighbours(4u),
- unlinked_neighbours(4u) {}
+ Point() {}
int id;
Vector3 pos;
real_t weight_scale;
bool enabled;
- OAHashMap<int, Point *> neighbours;
- OAHashMap<int, Point *> unlinked_neighbours;
+ OAHashMap<int, Point *> neighbours = 4u;
+ OAHashMap<int, Point *> unlinked_neighbours = 4u;
// Used for pathfinding.
Point *prev_point;
@@ -85,7 +81,7 @@ class AStar : public Reference {
int32_t u;
int32_t v;
};
- uint64_t key;
+ uint64_t key = 0;
};
enum {
@@ -94,13 +90,11 @@ class AStar : public Reference {
BACKWARD = 2,
BIDIRECTIONAL = FORWARD | BACKWARD
};
- unsigned char direction;
+ unsigned char direction = NONE;
bool operator<(const Segment &p_s) const { return key < p_s.key; }
- Segment() {
- key = 0;
- direction = NONE;
- }
+
+ Segment() {}
Segment(int p_from, int p_to) {
if (p_from < p_to) {
u = p_from;
@@ -114,8 +108,8 @@ class AStar : public Reference {
}
};
- int last_free_id;
- uint64_t pass;
+ int last_free_id = 0;
+ uint64_t pass = 1;
OAHashMap<int, Point *> points;
Set<Segment> segments;
@@ -159,7 +153,7 @@ public:
Vector<Vector3> get_point_path(int p_from_id, int p_to_id);
Vector<int> get_id_path(int p_from_id, int p_to_id);
- AStar();
+ AStar() {}
~AStar();
};
@@ -206,8 +200,8 @@ public:
Vector<Vector2> get_point_path(int p_from_id, int p_to_id);
Vector<int> get_id_path(int p_from_id, int p_to_id);
- AStar2D();
- ~AStar2D();
+ AStar2D() {}
+ ~AStar2D() {}
};
#endif // A_STAR_H
diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp
index 19d60fea72..f5c667dab0 100644
--- a/core/math/aabb.cpp
+++ b/core/math/aabb.cpp
@@ -33,21 +33,18 @@
#include "core/print_string.h"
real_t AABB::get_area() const {
-
return size.x * size.y * size.z;
}
bool AABB::operator==(const AABB &p_rval) const {
-
return ((position == p_rval.position) && (size == p_rval.size));
}
-bool AABB::operator!=(const AABB &p_rval) const {
+bool AABB::operator!=(const AABB &p_rval) const {
return ((position != p_rval.position) || (size != p_rval.size));
}
void AABB::merge_with(const AABB &p_aabb) {
-
Vector3 beg_1, beg_2;
Vector3 end_1, end_2;
Vector3 min, max;
@@ -70,12 +67,10 @@ void AABB::merge_with(const AABB &p_aabb) {
}
bool AABB::is_equal_approx(const AABB &p_aabb) const {
-
return position.is_equal_approx(p_aabb.position) && size.is_equal_approx(p_aabb.size);
}
AABB AABB::intersection(const AABB &p_aabb) const {
-
Vector3 src_min = position;
Vector3 src_max = position + size;
Vector3 dst_min = p_aabb.position;
@@ -83,26 +78,23 @@ AABB AABB::intersection(const AABB &p_aabb) const {
Vector3 min, max;
- if (src_min.x > dst_max.x || src_max.x < dst_min.x)
+ if (src_min.x > dst_max.x || src_max.x < dst_min.x) {
return AABB();
- else {
-
+ } else {
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x;
}
- if (src_min.y > dst_max.y || src_max.y < dst_min.y)
+ if (src_min.y > dst_max.y || src_max.y < dst_min.y) {
return AABB();
- else {
-
+ } else {
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y;
}
- if (src_min.z > dst_max.z || src_max.z < dst_min.z)
+ if (src_min.z > dst_max.z || src_max.z < dst_min.z) {
return AABB();
- else {
-
+ } else {
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
}
@@ -111,7 +103,6 @@ AABB AABB::intersection(const AABB &p_aabb) const {
}
bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
-
Vector3 c1, c2;
Vector3 end = position + size;
real_t near = -1e20;
@@ -143,8 +134,9 @@ bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *
}
}
- if (r_clip)
+ if (r_clip) {
*r_clip = c1;
+ }
if (r_normal) {
*r_normal = Vector3();
(*r_normal)[axis] = p_dir[axis] ? -1 : 1;
@@ -154,7 +146,6 @@ bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *
}
bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
-
real_t min = 0, max = 1;
int axis = 0;
real_t sign = 0;
@@ -168,18 +159,18 @@ bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector
real_t csign;
if (seg_from < seg_to) {
-
- if (seg_from > box_end || seg_to < box_begin)
+ if (seg_from > box_end || seg_to < box_begin) {
return false;
+ }
real_t length = seg_to - seg_from;
cmin = (seg_from < box_begin) ? ((box_begin - seg_from) / length) : 0;
cmax = (seg_to > box_end) ? ((box_end - seg_from) / length) : 1;
csign = -1.0;
} else {
-
- if (seg_to > box_end || seg_from < box_begin)
+ if (seg_to > box_end || seg_from < box_begin) {
return false;
+ }
real_t length = seg_to - seg_from;
cmin = (seg_from > box_end) ? (box_end - seg_from) / length : 0;
cmax = (seg_to < box_begin) ? (box_begin - seg_from) / length : 1;
@@ -191,10 +182,12 @@ bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector
axis = i;
sign = csign;
}
- if (cmax < max)
+ if (cmax < max) {
max = cmax;
- if (max < min)
+ }
+ if (max < min) {
return false;
+ }
}
Vector3 rel = p_to - p_from;
@@ -205,14 +198,14 @@ bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector
*r_normal = normal;
}
- if (r_clip)
+ if (r_clip) {
*r_clip = p_from + rel * min;
+ }
return true;
}
bool AABB::intersects_plane(const Plane &p_plane) const {
-
Vector3 points[8] = {
Vector3(position.x, position.y, position.z),
Vector3(position.x, position.y, position.z + size.z),
@@ -228,18 +221,17 @@ bool AABB::intersects_plane(const Plane &p_plane) const {
bool under = false;
for (int i = 0; i < 8; i++) {
-
- if (p_plane.distance_to(points[i]) > 0)
+ if (p_plane.distance_to(points[i]) > 0) {
over = true;
- else
+ } else {
under = true;
+ }
}
return under && over;
}
Vector3 AABB::get_longest_axis() const {
-
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -254,8 +246,8 @@ Vector3 AABB::get_longest_axis() const {
return axis;
}
-int AABB::get_longest_axis_index() const {
+int AABB::get_longest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -272,7 +264,6 @@ int AABB::get_longest_axis_index() const {
}
Vector3 AABB::get_shortest_axis() const {
-
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -287,8 +278,8 @@ Vector3 AABB::get_shortest_axis() const {
return axis;
}
-int AABB::get_shortest_axis_index() const {
+int AABB::get_shortest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -305,35 +296,31 @@ int AABB::get_shortest_axis_index() const {
}
AABB AABB::merge(const AABB &p_with) const {
-
AABB aabb = *this;
aabb.merge_with(p_with);
return aabb;
}
+
AABB AABB::expand(const Vector3 &p_vector) const {
AABB aabb = *this;
aabb.expand_to(p_vector);
return aabb;
}
-AABB AABB::grow(real_t p_by) const {
+AABB AABB::grow(real_t p_by) const {
AABB aabb = *this;
aabb.grow_by(p_by);
return aabb;
}
void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
-
ERR_FAIL_INDEX(p_edge, 12);
switch (p_edge) {
-
case 0: {
-
r_from = Vector3(position.x + size.x, position.y, position.z);
r_to = Vector3(position.x, position.y, position.z);
} break;
case 1: {
-
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
r_to = Vector3(position.x + size.x, position.y, position.z);
} break;
@@ -343,18 +330,15 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
} break;
case 3: {
-
r_from = Vector3(position.x, position.y, position.z);
r_to = Vector3(position.x, position.y, position.z + size.z);
} break;
case 4: {
-
r_from = Vector3(position.x, position.y + size.y, position.z);
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
} break;
case 5: {
-
r_from = Vector3(position.x + size.x, position.y + size.y, position.z);
r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
} break;
@@ -364,31 +348,26 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
} break;
case 7: {
-
r_from = Vector3(position.x, position.y + size.y, position.z + size.z);
r_to = Vector3(position.x, position.y + size.y, position.z);
} break;
case 8: {
-
r_from = Vector3(position.x, position.y, position.z + size.z);
r_to = Vector3(position.x, position.y + size.y, position.z + size.z);
} break;
case 9: {
-
r_from = Vector3(position.x, position.y, position.z);
r_to = Vector3(position.x, position.y + size.y, position.z);
} break;
case 10: {
-
r_from = Vector3(position.x + size.x, position.y, position.z);
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
} break;
case 11: {
-
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
@@ -397,6 +376,5 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
}
AABB::operator String() const {
-
return String() + position + " - " + size;
}
diff --git a/core/math/aabb.h b/core/math/aabb.h
index f87fced12d..4106fbb93c 100644
--- a/core/math/aabb.h
+++ b/core/math/aabb.h
@@ -47,12 +47,10 @@ public:
real_t get_area() const; /// get area
_FORCE_INLINE_ bool has_no_area() const {
-
return (size.x <= 0 || size.y <= 0 || size.z <= 0);
}
_FORCE_INLINE_ bool has_no_surface() const {
-
return (size.x <= 0 && size.y <= 0 && size.z <= 0);
}
@@ -111,43 +109,52 @@ public:
};
inline bool AABB::intersects(const AABB &p_aabb) const {
-
- if (position.x >= (p_aabb.position.x + p_aabb.size.x))
+ if (position.x >= (p_aabb.position.x + p_aabb.size.x)) {
return false;
- if ((position.x + size.x) <= p_aabb.position.x)
+ }
+ if ((position.x + size.x) <= p_aabb.position.x) {
return false;
- if (position.y >= (p_aabb.position.y + p_aabb.size.y))
+ }
+ if (position.y >= (p_aabb.position.y + p_aabb.size.y)) {
return false;
- if ((position.y + size.y) <= p_aabb.position.y)
+ }
+ if ((position.y + size.y) <= p_aabb.position.y) {
return false;
- if (position.z >= (p_aabb.position.z + p_aabb.size.z))
+ }
+ if (position.z >= (p_aabb.position.z + p_aabb.size.z)) {
return false;
- if ((position.z + size.z) <= p_aabb.position.z)
+ }
+ if ((position.z + size.z) <= p_aabb.position.z) {
return false;
+ }
return true;
}
inline bool AABB::intersects_inclusive(const AABB &p_aabb) const {
-
- if (position.x > (p_aabb.position.x + p_aabb.size.x))
+ if (position.x > (p_aabb.position.x + p_aabb.size.x)) {
return false;
- if ((position.x + size.x) < p_aabb.position.x)
+ }
+ if ((position.x + size.x) < p_aabb.position.x) {
return false;
- if (position.y > (p_aabb.position.y + p_aabb.size.y))
+ }
+ if (position.y > (p_aabb.position.y + p_aabb.size.y)) {
return false;
- if ((position.y + size.y) < p_aabb.position.y)
+ }
+ if ((position.y + size.y) < p_aabb.position.y) {
return false;
- if (position.z > (p_aabb.position.z + p_aabb.size.z))
+ }
+ if (position.z > (p_aabb.position.z + p_aabb.size.z)) {
return false;
- if ((position.z + size.z) < p_aabb.position.z)
+ }
+ if ((position.z + size.z) < p_aabb.position.z) {
return false;
+ }
return true;
}
inline bool AABB::encloses(const AABB &p_aabb) const {
-
Vector3 src_min = position;
Vector3 src_max = position + size;
Vector3 dst_min = p_aabb.position;
@@ -163,7 +170,6 @@ inline bool AABB::encloses(const AABB &p_aabb) const {
}
Vector3 AABB::get_support(const Vector3 &p_normal) const {
-
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -175,7 +181,6 @@ Vector3 AABB::get_support(const Vector3 &p_normal) const {
}
Vector3 AABB::get_endpoint(int p_point) const {
-
switch (p_point) {
case 0:
return Vector3(position.x, position.y, position.z);
@@ -193,13 +198,12 @@ Vector3 AABB::get_endpoint(int p_point) const {
return Vector3(position.x + size.x, position.y + size.y, position.z);
case 7:
return Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
- };
+ }
ERR_FAIL_V(Vector3());
}
bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count, const Vector3 *p_points, int p_point_count) const {
-
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -210,8 +214,9 @@ bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count, con
(p.normal.y > 0) ? -half_extents.y : half_extents.y,
(p.normal.z > 0) ? -half_extents.z : half_extents.z);
point += ofs;
- if (p.is_point_over(point))
+ if (p.is_point_over(point)) {
return false;
+ }
}
// Make sure all points in the shape aren't fully separated from the AABB on
@@ -220,7 +225,6 @@ bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count, con
int bad_point_counts_negative[3] = { 0 };
for (int k = 0; k < 3; k++) {
-
for (int i = 0; i < p_point_count; i++) {
if (p_points[i].coord[k] > ofs.coord[k] + half_extents.coord[k]) {
bad_point_counts_positive[k]++;
@@ -242,7 +246,6 @@ bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count, con
}
bool AABB::inside_convex_shape(const Plane *p_planes, int p_plane_count) const {
-
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -253,56 +256,66 @@ bool AABB::inside_convex_shape(const Plane *p_planes, int p_plane_count) const {
(p.normal.y < 0) ? -half_extents.y : half_extents.y,
(p.normal.z < 0) ? -half_extents.z : half_extents.z);
point += ofs;
- if (p.is_point_over(point))
+ if (p.is_point_over(point)) {
return false;
+ }
}
return true;
}
bool AABB::has_point(const Vector3 &p_point) const {
-
- if (p_point.x < position.x)
+ if (p_point.x < position.x) {
return false;
- if (p_point.y < position.y)
+ }
+ if (p_point.y < position.y) {
return false;
- if (p_point.z < position.z)
+ }
+ if (p_point.z < position.z) {
return false;
- if (p_point.x > position.x + size.x)
+ }
+ if (p_point.x > position.x + size.x) {
return false;
- if (p_point.y > position.y + size.y)
+ }
+ if (p_point.y > position.y + size.y) {
return false;
- if (p_point.z > position.z + size.z)
+ }
+ if (p_point.z > position.z + size.z) {
return false;
+ }
return true;
}
inline void AABB::expand_to(const Vector3 &p_vector) {
-
Vector3 begin = position;
Vector3 end = position + size;
- if (p_vector.x < begin.x)
+ if (p_vector.x < begin.x) {
begin.x = p_vector.x;
- if (p_vector.y < begin.y)
+ }
+ if (p_vector.y < begin.y) {
begin.y = p_vector.y;
- if (p_vector.z < begin.z)
+ }
+ if (p_vector.z < begin.z) {
begin.z = p_vector.z;
+ }
- if (p_vector.x > end.x)
+ if (p_vector.x > end.x) {
end.x = p_vector.x;
- if (p_vector.y > end.y)
+ }
+ if (p_vector.y > end.y) {
end.y = p_vector.y;
- if (p_vector.z > end.z)
+ }
+ if (p_vector.z > end.z) {
end.z = p_vector.z;
+ }
position = begin;
size = end - begin;
}
void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
-
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
@@ -313,7 +326,6 @@ void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r
}
inline real_t AABB::get_longest_axis_size() const {
-
real_t max_size = size.x;
if (size.y > max_size) {
@@ -328,7 +340,6 @@ inline real_t AABB::get_longest_axis_size() const {
}
inline real_t AABB::get_shortest_axis_size() const {
-
real_t max_size = size.x;
if (size.y < max_size) {
@@ -343,7 +354,6 @@ inline real_t AABB::get_shortest_axis_size() const {
}
bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
-
real_t divx = 1.0 / p_dir.x;
real_t divy = 1.0 / p_dir.y;
real_t divz = 1.0 / p_dir.z;
@@ -364,12 +374,15 @@ bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real
tymin = (upbound.y - p_from.y) * divy;
tymax = (position.y - p_from.y) * divy;
}
- if ((tmin > tymax) || (tymin > tmax))
+ if ((tmin > tymax) || (tymin > tmax)) {
return false;
- if (tymin > tmin)
+ }
+ if (tymin > tmin) {
tmin = tymin;
- if (tymax < tmax)
+ }
+ if (tymax < tmax) {
tmax = tymax;
+ }
if (p_dir.z >= 0) {
tzmin = (position.z - p_from.z) * divz;
tzmax = (upbound.z - p_from.z) * divz;
@@ -377,17 +390,19 @@ bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real
tzmin = (upbound.z - p_from.z) * divz;
tzmax = (position.z - p_from.z) * divz;
}
- if ((tmin > tzmax) || (tzmin > tmax))
+ if ((tmin > tzmax) || (tzmin > tmax)) {
return false;
- if (tzmin > tmin)
+ }
+ if (tzmin > tmin) {
tmin = tzmin;
- if (tzmax < tmax)
+ }
+ if (tzmax < tmax) {
tmax = tzmax;
+ }
return ((tmin < t1) && (tmax > t0));
}
void AABB::grow_by(real_t p_amount) {
-
position.x -= p_amount;
position.y -= p_amount;
position.z -= p_amount;
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
index 4665311059..91f533eafb 100644
--- a/core/math/audio_frame.h
+++ b/core/math/audio_frame.h
@@ -48,7 +48,6 @@ static inline float undenormalise(volatile float f) {
}
struct AudioFrame {
-
//left and right samples
float l, r;
@@ -105,7 +104,6 @@ struct AudioFrame {
}
_FORCE_INLINE_ AudioFrame lerp(const AudioFrame &p_b, float p_t) const {
-
AudioFrame res = *this;
res.l += (p_t * (p_b.l - l));
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index 6218b7e248..df5199b0f9 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -38,16 +38,13 @@
(elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1])
void Basis::from_z(const Vector3 &p_z) {
-
if (Math::abs(p_z.z) > Math_SQRT12) {
-
// choose p in y-z plane
real_t a = p_z[1] * p_z[1] + p_z[2] * p_z[2];
real_t k = 1.0 / Math::sqrt(a);
elements[0] = Vector3(0, -p_z[2] * k, p_z[1] * k);
elements[1] = Vector3(a * k, -p_z[0] * elements[0][2], p_z[0] * elements[0][1]);
} else {
-
// choose p in x-y plane
real_t a = p_z.x * p_z.x + p_z.y * p_z.y;
real_t k = 1.0 / Math::sqrt(a);
@@ -58,7 +55,6 @@ void Basis::from_z(const Vector3 &p_z) {
}
void Basis::invert() {
-
real_t co[3] = {
cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)
};
@@ -76,7 +72,6 @@ void Basis::invert() {
}
void Basis::orthonormalize() {
-
// Gram-Schmidt Process
Vector3 x = get_axis(0);
@@ -95,7 +90,6 @@ void Basis::orthonormalize() {
}
Basis Basis::orthonormalized() const {
-
Basis c = *this;
c.orthonormalize();
return c;
@@ -120,19 +114,20 @@ bool Basis::is_rotation() const {
}
bool Basis::is_symmetric() const {
-
- if (!Math::is_equal_approx_ratio(elements[0][1], elements[1][0], UNIT_EPSILON))
+ if (!Math::is_equal_approx_ratio(elements[0][1], elements[1][0], UNIT_EPSILON)) {
return false;
- if (!Math::is_equal_approx_ratio(elements[0][2], elements[2][0], UNIT_EPSILON))
+ }
+ if (!Math::is_equal_approx_ratio(elements[0][2], elements[2][0], UNIT_EPSILON)) {
return false;
- if (!Math::is_equal_approx_ratio(elements[1][2], elements[2][1], UNIT_EPSILON))
+ }
+ if (!Math::is_equal_approx_ratio(elements[1][2], elements[2][1], UNIT_EPSILON)) {
return false;
+ }
return true;
}
Basis Basis::diagonalize() {
-
//NOTE: only implemented for symmetric matrices
//with the Jacobi iterative method method
#ifdef MATH_CHECKS
@@ -193,21 +188,18 @@ Basis Basis::diagonalize() {
}
Basis Basis::inverse() const {
-
Basis inv = *this;
inv.invert();
return inv;
}
void Basis::transpose() {
-
SWAP(elements[0][1], elements[1][0]);
SWAP(elements[0][2], elements[2][0]);
SWAP(elements[1][2], elements[2][1]);
}
Basis Basis::transposed() const {
-
Basis tr = *this;
tr.transpose();
return tr;
@@ -216,7 +208,6 @@ Basis Basis::transposed() const {
// Multiplies the matrix from left by the scaling matrix: M -> S.M
// See the comment for Basis::rotated for further explanation.
void Basis::scale(const Vector3 &p_scale) {
-
elements[0][0] *= p_scale.x;
elements[0][1] *= p_scale.x;
elements[0][2] *= p_scale.x;
@@ -260,7 +251,6 @@ Basis Basis::scaled_local(const Vector3 &p_scale) const {
}
Vector3 Basis::get_scale_abs() const {
-
return Vector3(
Vector3(elements[0][0], elements[1][0], elements[2][0]).length(),
Vector3(elements[0][1], elements[1][1], elements[2][1]).length(),
@@ -340,8 +330,8 @@ void Basis::rotate_local(const Vector3 &p_axis, real_t p_phi) {
// M -> (M.R.Minv).M = M.R.
*this = rotated_local(p_axis, p_phi);
}
-Basis Basis::rotated_local(const Vector3 &p_axis, real_t p_phi) const {
+Basis Basis::rotated_local(const Vector3 &p_axis, real_t p_phi) const {
return (*this) * Basis(p_axis, p_phi);
}
@@ -430,7 +420,6 @@ void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) cons
// the angles in the decomposition R = X(a1).Y(a2).Z(a3) where Z(a) rotates
// around the z-axis by a and so on.
Vector3 Basis::get_euler_xyz() const {
-
// Euler angles in XYZ convention.
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
//
@@ -439,12 +428,9 @@ Vector3 Basis::get_euler_xyz() const {
// -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy
Vector3 euler;
-#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(!is_rotation(), euler);
-#endif
real_t sy = elements[0][2];
- if (sy < 1.0) {
- if (sy > -1.0) {
+ if (sy < (1.0 - CMP_EPSILON)) {
+ if (sy > -(1.0 - CMP_EPSILON)) {
// is this a pure Y rotation?
if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) {
// return the simplest form (human friendlier in editor and scripts)
@@ -457,12 +443,12 @@ Vector3 Basis::get_euler_xyz() const {
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
}
} else {
- euler.x = -Math::atan2(elements[0][1], elements[1][1]);
+ euler.x = Math::atan2(elements[2][1], elements[1][1]);
euler.y = -Math_PI / 2.0;
euler.z = 0.0;
}
} else {
- euler.x = Math::atan2(elements[0][1], elements[1][1]);
+ euler.x = Math::atan2(elements[2][1], elements[1][1]);
euler.y = Math_PI / 2.0;
euler.z = 0.0;
}
@@ -474,7 +460,6 @@ Vector3 Basis::get_euler_xyz() const {
// and similar for other axes.
// The current implementation uses XYZ convention (Z is the first rotation).
void Basis::set_euler_xyz(const Vector3 &p_euler) {
-
real_t c, s;
c = Math::cos(p_euler.x);
@@ -493,16 +478,106 @@ void Basis::set_euler_xyz(const Vector3 &p_euler) {
*this = xmat * (ymat * zmat);
}
+Vector3 Basis::get_euler_xzy() const {
+ // Euler angles in XZY convention.
+ // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
+ //
+ // rot = cz*cy -sz cz*sy
+ // sx*sy+cx*cy*sz cx*cz cx*sz*sy-cy*sx
+ // cy*sx*sz cz*sx cx*cy+sx*sz*sy
+
+ Vector3 euler;
+ real_t sz = elements[0][1];
+ if (sz < (1.0 - CMP_EPSILON)) {
+ if (sz > -(1.0 - CMP_EPSILON)) {
+ euler.x = Math::atan2(elements[2][1], elements[1][1]);
+ euler.y = Math::atan2(elements[0][2], elements[0][0]);
+ euler.z = Math::asin(-sz);
+ } else {
+ // It's -1
+ euler.x = -Math::atan2(elements[1][2], elements[2][2]);
+ euler.y = 0.0;
+ euler.z = Math_PI / 2.0;
+ }
+ } else {
+ // It's 1
+ euler.x = -Math::atan2(elements[1][2], elements[2][2]);
+ euler.y = 0.0;
+ euler.z = -Math_PI / 2.0;
+ }
+ return euler;
+}
+
+void Basis::set_euler_xzy(const Vector3 &p_euler) {
+ real_t c, s;
+
+ c = Math::cos(p_euler.x);
+ s = Math::sin(p_euler.x);
+ Basis xmat(1.0, 0.0, 0.0, 0.0, c, -s, 0.0, s, c);
+
+ c = Math::cos(p_euler.y);
+ s = Math::sin(p_euler.y);
+ Basis ymat(c, 0.0, s, 0.0, 1.0, 0.0, -s, 0.0, c);
+
+ c = Math::cos(p_euler.z);
+ s = Math::sin(p_euler.z);
+ Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
+
+ *this = xmat * zmat * ymat;
+}
+
+Vector3 Basis::get_euler_yzx() const {
+ // Euler angles in YZX convention.
+ // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
+ //
+ // rot = cy*cz sy*sx-cy*cx*sz cx*sy+cy*sz*sx
+ // sz cz*cx -cz*sx
+ // -cz*sy cy*sx+cx*sy*sz cy*cx-sy*sz*sx
+
+ Vector3 euler;
+ real_t sz = elements[1][0];
+ if (sz < (1.0 - CMP_EPSILON)) {
+ if (sz > -(1.0 - CMP_EPSILON)) {
+ euler.x = Math::atan2(-elements[1][2], elements[1][1]);
+ euler.y = Math::atan2(-elements[2][0], elements[0][0]);
+ euler.z = Math::asin(sz);
+ } else {
+ // It's -1
+ euler.x = Math::atan2(elements[2][1], elements[2][2]);
+ euler.y = 0.0;
+ euler.z = -Math_PI / 2.0;
+ }
+ } else {
+ // It's 1
+ euler.x = Math::atan2(elements[2][1], elements[2][2]);
+ euler.y = 0.0;
+ euler.z = Math_PI / 2.0;
+ }
+ return euler;
+}
+
+void Basis::set_euler_yzx(const Vector3 &p_euler) {
+ real_t c, s;
+
+ c = Math::cos(p_euler.x);
+ s = Math::sin(p_euler.x);
+ Basis xmat(1.0, 0.0, 0.0, 0.0, c, -s, 0.0, s, c);
+
+ c = Math::cos(p_euler.y);
+ s = Math::sin(p_euler.y);
+ Basis ymat(c, 0.0, s, 0.0, 1.0, 0.0, -s, 0.0, c);
+
+ c = Math::cos(p_euler.z);
+ s = Math::sin(p_euler.z);
+ Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
+
+ *this = ymat * zmat * xmat;
+}
+
// get_euler_yxz returns a vector containing the Euler angles in the YXZ convention,
// as in first-Z, then-X, last-Y. The angles for X, Y, and Z rotations are returned
// as the x, y, and z components of a Vector3 respectively.
Vector3 Basis::get_euler_yxz() const {
-
- /* checking this is a bad idea, because obtaining from scaled transform is a valid use case
-#ifdef MATH_CHECKS
- ERR_FAIL_COND(!is_rotation());
-#endif
-*/
// Euler angles in YXZ convention.
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
//
@@ -514,8 +589,8 @@ Vector3 Basis::get_euler_yxz() const {
real_t m12 = elements[1][2];
- if (m12 < 1) {
- if (m12 > -1) {
+ if (m12 < (1 - CMP_EPSILON)) {
+ if (m12 > -(1 - CMP_EPSILON)) {
// is this a pure X rotation?
if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) {
// return the simplest form (human friendlier in editor and scripts)
@@ -529,12 +604,12 @@ Vector3 Basis::get_euler_yxz() const {
}
} else { // m12 == -1
euler.x = Math_PI * 0.5;
- euler.y = -atan2(-elements[0][1], elements[0][0]);
+ euler.y = atan2(elements[0][1], elements[0][0]);
euler.z = 0;
}
} else { // m12 == 1
euler.x = -Math_PI * 0.5;
- euler.y = -atan2(-elements[0][1], elements[0][0]);
+ euler.y = -atan2(elements[0][1], elements[0][0]);
euler.z = 0;
}
@@ -546,7 +621,6 @@ Vector3 Basis::get_euler_yxz() const {
// and similar for other axes.
// The current implementation uses YXZ convention (Z is the first rotation).
void Basis::set_euler_yxz(const Vector3 &p_euler) {
-
real_t c, s;
c = Math::cos(p_euler.x);
@@ -565,17 +639,110 @@ void Basis::set_euler_yxz(const Vector3 &p_euler) {
*this = ymat * xmat * zmat;
}
-bool Basis::is_equal_approx(const Basis &p_basis) const {
+Vector3 Basis::get_euler_zxy() const {
+ // Euler angles in ZXY convention.
+ // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
+ //
+ // rot = cz*cy-sz*sx*sy -cx*sz cz*sy+cy*sz*sx
+ // cy*sz+cz*sx*sy cz*cx sz*sy-cz*cy*sx
+ // -cx*sy sx cx*cy
+ Vector3 euler;
+ real_t sx = elements[2][1];
+ if (sx < (1.0 - CMP_EPSILON)) {
+ if (sx > -(1.0 - CMP_EPSILON)) {
+ euler.x = Math::asin(sx);
+ euler.y = Math::atan2(-elements[2][0], elements[2][2]);
+ euler.z = Math::atan2(-elements[0][1], elements[1][1]);
+ } else {
+ // It's -1
+ euler.x = -Math_PI / 2.0;
+ euler.y = Math::atan2(elements[0][2], elements[0][0]);
+ euler.z = 0;
+ }
+ } else {
+ // It's 1
+ euler.x = Math_PI / 2.0;
+ euler.y = Math::atan2(elements[0][2], elements[0][0]);
+ euler.z = 0;
+ }
+ return euler;
+}
+
+void Basis::set_euler_zxy(const Vector3 &p_euler) {
+ real_t c, s;
+
+ c = Math::cos(p_euler.x);
+ s = Math::sin(p_euler.x);
+ Basis xmat(1.0, 0.0, 0.0, 0.0, c, -s, 0.0, s, c);
+
+ c = Math::cos(p_euler.y);
+ s = Math::sin(p_euler.y);
+ Basis ymat(c, 0.0, s, 0.0, 1.0, 0.0, -s, 0.0, c);
+
+ c = Math::cos(p_euler.z);
+ s = Math::sin(p_euler.z);
+ Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
+
+ *this = zmat * xmat * ymat;
+}
+Vector3 Basis::get_euler_zyx() const {
+ // Euler angles in ZYX convention.
+ // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
+ //
+ // rot = cz*cy cz*sy*sx-cx*sz sz*sx+cz*cx*cy
+ // cy*sz cz*cx+sz*sy*sx cx*sz*sy-cz*sx
+ // -sy cy*sx cy*cx
+ Vector3 euler;
+ real_t sy = elements[2][0];
+ if (sy < (1.0 - CMP_EPSILON)) {
+ if (sy > -(1.0 - CMP_EPSILON)) {
+ euler.x = Math::atan2(elements[2][1], elements[2][2]);
+ euler.y = Math::asin(-sy);
+ euler.z = Math::atan2(elements[1][0], elements[0][0]);
+ } else {
+ // It's -1
+ euler.x = 0;
+ euler.y = Math_PI / 2.0;
+ euler.z = -Math::atan2(elements[0][1], elements[1][1]);
+ }
+ } else {
+ // It's 1
+ euler.x = 0;
+ euler.y = -Math_PI / 2.0;
+ euler.z = -Math::atan2(elements[0][1], elements[1][1]);
+ }
+ return euler;
+}
+
+void Basis::set_euler_zyx(const Vector3 &p_euler) {
+ real_t c, s;
+
+ c = Math::cos(p_euler.x);
+ s = Math::sin(p_euler.x);
+ Basis xmat(1.0, 0.0, 0.0, 0.0, c, -s, 0.0, s, c);
+
+ c = Math::cos(p_euler.y);
+ s = Math::sin(p_euler.y);
+ Basis ymat(c, 0.0, s, 0.0, 1.0, 0.0, -s, 0.0, c);
+
+ c = Math::cos(p_euler.z);
+ s = Math::sin(p_euler.z);
+ Basis zmat(c, -s, 0.0, s, c, 0.0, 0.0, 0.0, 1.0);
+
+ *this = zmat * ymat * xmat;
+}
+
+bool Basis::is_equal_approx(const Basis &p_basis) const {
return elements[0].is_equal_approx(p_basis.elements[0]) && elements[1].is_equal_approx(p_basis.elements[1]) && elements[2].is_equal_approx(p_basis.elements[2]);
}
bool Basis::is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsilon) const {
-
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- if (!Math::is_equal_approx_ratio(a.elements[i][j], b.elements[i][j], p_epsilon))
+ if (!Math::is_equal_approx_ratio(a.elements[i][j], b.elements[i][j], p_epsilon)) {
return false;
+ }
}
}
@@ -583,11 +750,11 @@ bool Basis::is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsil
}
bool Basis::operator==(const Basis &p_matrix) const {
-
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- if (elements[i][j] != p_matrix.elements[i][j])
+ if (elements[i][j] != p_matrix.elements[i][j]) {
return false;
+ }
}
}
@@ -595,19 +762,16 @@ bool Basis::operator==(const Basis &p_matrix) const {
}
bool Basis::operator!=(const Basis &p_matrix) const {
-
return (!(*this == p_matrix));
}
Basis::operator String() const {
-
String mtx;
for (int i = 0; i < 3; i++) {
-
for (int j = 0; j < 3; j++) {
-
- if (i != 0 || j != 0)
+ if (i != 0 || j != 0) {
mtx += ", ";
+ }
mtx += rtos(elements[i][j]);
}
@@ -617,7 +781,6 @@ Basis::operator String() const {
}
Quat Basis::get_quat() const {
-
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!is_rotation(), Quat(), "Basis must be normalized in order to be casted to a Quaternion. Use get_rotation_quat() or call orthonormalized() instead.");
#endif
@@ -681,35 +844,33 @@ static const Basis _ortho_bases[24] = {
};
int Basis::get_orthogonal_index() const {
-
//could be sped up if i come up with a way
Basis orth = *this;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
real_t v = orth[i][j];
- if (v > 0.5)
+ if (v > 0.5) {
v = 1.0;
- else if (v < -0.5)
+ } else if (v < -0.5) {
v = -1.0;
- else
+ } else {
v = 0;
+ }
orth[i][j] = v;
}
}
for (int i = 0; i < 24; i++) {
-
- if (_ortho_bases[i] == orth)
+ if (_ortho_bases[i] == orth) {
return i;
+ }
}
return 0;
}
void Basis::set_orthogonal_index(int p_index) {
-
//there only exist 24 orthogonal bases in r3
ERR_FAIL_INDEX(p_index, 24);
@@ -783,8 +944,9 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
real_t s = Math::sqrt((elements[1][2] - elements[2][1]) * (elements[1][2] - elements[2][1]) + (elements[2][0] - elements[0][2]) * (elements[2][0] - elements[0][2]) + (elements[0][1] - elements[1][0]) * (elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise
angle = Math::acos((elements[0][0] + elements[1][1] + elements[2][2] - 1) / 2);
- if (angle < 0)
+ if (angle < 0) {
s = -s;
+ }
x = (elements[2][1] - elements[1][2]) / s;
y = (elements[0][2] - elements[2][0]) / s;
z = (elements[1][0] - elements[0][1]) / s;
@@ -794,7 +956,6 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
}
void Basis::set_quat(const Quat &p_quat) {
-
real_t d = p_quat.length_squared();
real_t s = 2.0 / d;
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
@@ -866,7 +1027,6 @@ void Basis::set_diagonal(const Vector3 &p_diag) {
}
Basis Basis::slerp(const Basis &target, const real_t &t) const {
-
//consider scale
Quat from(*this);
Quat to(target);
@@ -880,7 +1040,6 @@ Basis Basis::slerp(const Basis &target, const real_t &t) const {
}
void Basis::rotate_sh(real_t *p_values) {
-
// code by John Hable
// http://filmicworlds.com/blog/simple-and-fast-spherical-harmonic-rotation/
// this code is Public Domain
diff --git a/core/math/basis.h b/core/math/basis.h
index 2924a0ddbd..985fb0e44f 100644
--- a/core/math/basis.h
+++ b/core/math/basis.h
@@ -39,11 +39,9 @@ public:
Vector3 elements[3];
_FORCE_INLINE_ const Vector3 &operator[](int axis) const {
-
return elements[axis];
}
_FORCE_INLINE_ Vector3 &operator[](int axis) {
-
return elements[axis];
}
@@ -90,9 +88,22 @@ public:
Vector3 get_euler_xyz() const;
void set_euler_xyz(const Vector3 &p_euler);
+
+ Vector3 get_euler_xzy() const;
+ void set_euler_xzy(const Vector3 &p_euler);
+
+ Vector3 get_euler_yzx() const;
+ void set_euler_yzx(const Vector3 &p_euler);
+
Vector3 get_euler_yxz() const;
void set_euler_yxz(const Vector3 &p_euler);
+ Vector3 get_euler_zxy() const;
+ void set_euler_zxy(const Vector3 &p_euler);
+
+ Vector3 get_euler_zyx() const;
+ void set_euler_zyx(const Vector3 &p_euler);
+
Quat get_quat() const;
void set_quat(const Quat &p_quat);
@@ -166,7 +177,6 @@ public:
/* create / set */
_FORCE_INLINE_ void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
-
elements[0][0] = xx;
elements[0][1] = xy;
elements[0][2] = xz;
@@ -178,18 +188,15 @@ public:
elements[2][2] = zz;
}
_FORCE_INLINE_ void set(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) {
-
set_axis(0, p_x);
set_axis(1, p_y);
set_axis(2, p_z);
}
_FORCE_INLINE_ Vector3 get_column(int i) const {
-
return Vector3(elements[0][i], elements[1][i], elements[2][i]);
}
_FORCE_INLINE_ Vector3 get_row(int i) const {
-
return Vector3(elements[i][0], elements[i][1], elements[i][2]);
}
_FORCE_INLINE_ Vector3 get_main_diagonal() const {
@@ -221,7 +228,6 @@ public:
elements[0].z * m[0].z + elements[1].z * m[1].z + elements[2].z * m[2].z);
}
Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
-
set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
}
@@ -249,7 +255,6 @@ public:
}
_FORCE_INLINE_ Basis() {
-
elements[0][0] = 1;
elements[0][1] = 0;
elements[0][2] = 0;
@@ -263,7 +268,6 @@ public:
};
_FORCE_INLINE_ void Basis::operator*=(const Basis &p_matrix) {
-
set(
p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]),
p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]),
@@ -271,7 +275,6 @@ _FORCE_INLINE_ void Basis::operator*=(const Basis &p_matrix) {
}
_FORCE_INLINE_ Basis Basis::operator*(const Basis &p_matrix) const {
-
return Basis(
p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]),
p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]),
@@ -279,49 +282,42 @@ _FORCE_INLINE_ Basis Basis::operator*(const Basis &p_matrix) const {
}
_FORCE_INLINE_ void Basis::operator+=(const Basis &p_matrix) {
-
elements[0] += p_matrix.elements[0];
elements[1] += p_matrix.elements[1];
elements[2] += p_matrix.elements[2];
}
_FORCE_INLINE_ Basis Basis::operator+(const Basis &p_matrix) const {
-
Basis ret(*this);
ret += p_matrix;
return ret;
}
_FORCE_INLINE_ void Basis::operator-=(const Basis &p_matrix) {
-
elements[0] -= p_matrix.elements[0];
elements[1] -= p_matrix.elements[1];
elements[2] -= p_matrix.elements[2];
}
_FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const {
-
Basis ret(*this);
ret -= p_matrix;
return ret;
}
_FORCE_INLINE_ void Basis::operator*=(real_t p_val) {
-
elements[0] *= p_val;
elements[1] *= p_val;
elements[2] *= p_val;
}
_FORCE_INLINE_ Basis Basis::operator*(real_t p_val) const {
-
Basis ret(*this);
ret *= p_val;
return ret;
}
Vector3 Basis::xform(const Vector3 &p_vector) const {
-
return Vector3(
elements[0].dot(p_vector),
elements[1].dot(p_vector),
@@ -329,7 +325,6 @@ Vector3 Basis::xform(const Vector3 &p_vector) const {
}
Vector3 Basis::xform_inv(const Vector3 &p_vector) const {
-
return Vector3(
(elements[0][0] * p_vector.x) + (elements[1][0] * p_vector.y) + (elements[2][0] * p_vector.z),
(elements[0][1] * p_vector.x) + (elements[1][1] * p_vector.y) + (elements[2][1] * p_vector.z),
@@ -337,7 +332,6 @@ Vector3 Basis::xform_inv(const Vector3 &p_vector) const {
}
real_t Basis::determinant() const {
-
return elements[0][0] * (elements[1][1] * elements[2][2] - elements[2][1] * elements[1][2]) -
elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) +
elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]);
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 5d3ebc9f6d..22ab83f358 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -34,7 +34,6 @@
#include "core/print_string.h"
float CameraMatrix::determinant() const {
-
return matrix[0][3] * matrix[1][2] * matrix[2][1] * matrix[3][0] - matrix[0][2] * matrix[1][3] * matrix[2][1] * matrix[3][0] -
matrix[0][3] * matrix[1][1] * matrix[2][2] * matrix[3][0] + matrix[0][1] * matrix[1][3] * matrix[2][2] * matrix[3][0] +
matrix[0][2] * matrix[1][1] * matrix[2][3] * matrix[3][0] - matrix[0][1] * matrix[1][2] * matrix[2][3] * matrix[3][0] -
@@ -50,29 +49,22 @@ float CameraMatrix::determinant() const {
}
void CameraMatrix::set_identity() {
-
for (int i = 0; i < 4; i++) {
-
for (int j = 0; j < 4; j++) {
-
matrix[i][j] = (i == j) ? 1 : 0;
}
}
}
void CameraMatrix::set_zero() {
-
for (int i = 0; i < 4; i++) {
-
for (int j = 0; j < 4; j++) {
-
matrix[i][j] = 0;
}
}
}
Plane CameraMatrix::xform4(const Plane &p_vec4) const {
-
Plane ret;
ret.normal.x = matrix[0][0] * p_vec4.normal.x + matrix[1][0] * p_vec4.normal.y + matrix[2][0] * p_vec4.normal.z + matrix[3][0] * p_vec4.d;
@@ -83,7 +75,6 @@ Plane CameraMatrix::xform4(const Plane &p_vec4) const {
}
void CameraMatrix::set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov) {
-
if (p_flip_fov) {
p_fovy_degrees = get_fovy(p_fovy_degrees, 1.0 / p_aspect);
}
@@ -125,18 +116,18 @@ void CameraMatrix::set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_
left = -xmax + frustumshift;
right = xmax + frustumshift;
modeltranslation = p_intraocular_dist / 2.0;
- }; break;
+ } break;
case 2: { // right eye
left = -xmax - frustumshift;
right = xmax - frustumshift;
modeltranslation = -p_intraocular_dist / 2.0;
- }; break;
+ } break;
default: { // mono, should give the same result as set_perspective(p_fovy_degrees,p_aspect,p_z_near,p_z_far,p_flip_fov)
left = -xmax;
right = xmax;
modeltranslation = 0.0;
- }; break;
- };
+ } break;
+ }
set_frustum(left, right, -ymax, ymax, p_z_near, p_z_far);
@@ -166,17 +157,16 @@ void CameraMatrix::set_for_hmd(int p_eye, real_t p_aspect, real_t p_intraocular_
switch (p_eye) {
case 1: { // left eye
set_frustum(-f2 * p_z_near, f1 * p_z_near, -f3 * p_z_near, f3 * p_z_near, p_z_near, p_z_far);
- }; break;
+ } break;
case 2: { // right eye
set_frustum(-f1 * p_z_near, f2 * p_z_near, -f3 * p_z_near, f3 * p_z_near, p_z_near, p_z_far);
- }; break;
+ } break;
default: { // mono, does not apply here!
- }; break;
- };
-};
+ } break;
+ }
+}
void CameraMatrix::set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar) {
-
set_identity();
matrix[0][0] = 2.0 / (p_right - p_left);
@@ -189,7 +179,6 @@ void CameraMatrix::set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom
}
void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar, bool p_flip_fov) {
-
if (!p_flip_fov) {
p_size *= p_aspect;
}
@@ -198,7 +187,6 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear
}
void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) {
-
ERR_FAIL_COND(p_right <= p_left);
ERR_FAIL_COND(p_top <= p_bottom);
ERR_FAIL_COND(p_far <= p_near);
@@ -239,7 +227,6 @@ void CameraMatrix::set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset,
}
real_t CameraMatrix::get_z_far() const {
-
const real_t *matrix = (const real_t *)this->matrix;
Plane new_plane = Plane(matrix[3] - matrix[2],
matrix[7] - matrix[6],
@@ -251,8 +238,8 @@ real_t CameraMatrix::get_z_far() const {
return new_plane.d;
}
-real_t CameraMatrix::get_z_near() const {
+real_t CameraMatrix::get_z_near() const {
const real_t *matrix = (const real_t *)this->matrix;
Plane new_plane = Plane(matrix[3] + matrix[2],
matrix[7] + matrix[6],
@@ -264,7 +251,6 @@ real_t CameraMatrix::get_z_near() const {
}
Vector2 CameraMatrix::get_viewport_half_extents() const {
-
const real_t *matrix = (const real_t *)this->matrix;
///////--- Near Plane ---///////
Plane near_plane = Plane(matrix[3] + matrix[2],
@@ -293,7 +279,6 @@ Vector2 CameraMatrix::get_viewport_half_extents() const {
}
void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const {
-
const real_t *matrix = (const real_t *)this->matrix;
///////--- Far Plane ---///////
Plane far_plane = Plane(matrix[3] - matrix[2],
@@ -323,7 +308,6 @@ void CameraMatrix::get_far_plane_size(real_t &r_width, real_t &r_height) const {
}
bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const {
-
Vector<Plane> planes = get_projection_planes(Transform());
const Planes intersections[8][3] = {
{ PLANE_FAR, PLANE_LEFT, PLANE_TOP },
@@ -337,7 +321,6 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
};
for (int i = 0; i < 8; i++) {
-
Vector3 point;
bool res = planes[intersections[i][0]].intersect_3(planes[intersections[i][1]], planes[intersections[i][2]], &point);
ERR_FAIL_COND_V(!res, false);
@@ -348,7 +331,6 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
}
Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform) const {
-
/** Fast Plane Extraction from combined modelview/projection matrices.
* References:
* https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
@@ -431,14 +413,12 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform)
}
CameraMatrix CameraMatrix::inverse() const {
-
CameraMatrix cm = *this;
cm.invert();
return cm;
}
void CameraMatrix::invert() {
-
int i, j, k;
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
real_t pvt_val; /* Value of current pivot element */
@@ -489,23 +469,26 @@ void CameraMatrix::invert() {
/** Divide column by minus pivot value **/
for (i = 0; i < 4; i++) {
- if (i != k)
+ if (i != k) {
matrix[i][k] /= (-pvt_val);
+ }
}
/** Reduce the matrix **/
for (i = 0; i < 4; i++) {
hold = matrix[i][k];
for (j = 0; j < 4; j++) {
- if (i != k && j != k)
+ if (i != k && j != k) {
matrix[i][j] += hold * matrix[k][j];
+ }
}
}
/** Divide row by pivot **/
for (j = 0; j < 4; j++) {
- if (j != k)
+ if (j != k) {
matrix[k][j] /= pvt_val;
+ }
}
/** Replace pivot by reciprocal (at last we can touch it). **/
@@ -525,12 +508,13 @@ void CameraMatrix::invert() {
}
j = pvt_i[k]; /* Columns to swap correspond to pivot ROW */
- if (j != k) /* If columns are different */
+ if (j != k) { /* If columns are different */
for (i = 0; i < 4; i++) {
hold = matrix[i][k];
matrix[i][k] = -matrix[i][j];
matrix[i][j] = hold;
}
+ }
}
}
@@ -541,19 +525,18 @@ void CameraMatrix::flip_y() {
}
CameraMatrix::CameraMatrix() {
-
set_identity();
}
CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
-
CameraMatrix new_matrix;
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
real_t ab = 0;
- for (int k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++) {
ab += matrix[k][i] * p_matrix.matrix[j][k];
+ }
new_matrix.matrix[j][i] = ab;
}
}
@@ -562,7 +545,6 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
}
void CameraMatrix::set_depth_correction(bool p_flip_y) {
-
real_t *m = &matrix[0][0];
m[0] = 1;
@@ -584,7 +566,6 @@ void CameraMatrix::set_depth_correction(bool p_flip_y) {
}
void CameraMatrix::set_light_bias() {
-
real_t *m = &matrix[0][0];
m[0] = 0.5;
@@ -606,7 +587,6 @@ void CameraMatrix::set_light_bias() {
}
void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
-
real_t *m = &matrix[0][0];
m[0] = p_rect.size.width;
@@ -628,30 +608,28 @@ void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
}
CameraMatrix::operator String() const {
-
String str;
- for (int i = 0; i < 4; i++)
- for (int j = 0; j < 4; j++)
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
str += String((j > 0) ? ", " : "\n") + rtos(matrix[i][j]);
+ }
+ }
return str;
}
real_t CameraMatrix::get_aspect() const {
-
Vector2 vp_he = get_viewport_half_extents();
return vp_he.x / vp_he.y;
}
int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
-
Vector3 result = xform(Vector3(1, 0, -1));
return int((result.x * 0.5 + 0.5) * p_for_pixel_width);
}
bool CameraMatrix::is_orthogonal() const {
-
return matrix[3][3] == 1.0;
}
@@ -679,7 +657,6 @@ real_t CameraMatrix::get_fov() const {
}
void CameraMatrix::make_scale(const Vector3 &p_scale) {
-
set_identity();
matrix[0][0] = p_scale.x;
matrix[1][1] = p_scale.y;
@@ -687,7 +664,6 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
}
void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
-
Vector3 min = p_aabb.position;
Vector3 max = p_aabb.position + p_aabb.size;
@@ -713,7 +689,6 @@ void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
}
CameraMatrix::operator Transform() const {
-
Transform tr;
const real_t *m = &matrix[0][0];
@@ -737,7 +712,6 @@ CameraMatrix::operator Transform() const {
}
CameraMatrix::CameraMatrix(const Transform &p_transform) {
-
const Transform &tr = p_transform;
real_t *m = &matrix[0][0];
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 5420fa2984..49fdecae02 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -35,7 +35,6 @@
#include "core/math/transform.h"
struct CameraMatrix {
-
enum Planes {
PLANE_NEAR,
PLANE_FAR,
@@ -62,7 +61,6 @@ struct CameraMatrix {
void set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov = false);
static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
-
return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0);
}
@@ -116,7 +114,6 @@ struct CameraMatrix {
};
Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const {
-
Vector3 ret;
ret.x = matrix[0][0] * p_vec3.x + matrix[1][0] * p_vec3.y + matrix[2][0] * p_vec3.z + matrix[3][0];
ret.y = matrix[0][1] * p_vec3.x + matrix[1][1] * p_vec3.y + matrix[2][1] * p_vec3.z + matrix[3][1];
diff --git a/core/math/delaunay_2d.h b/core/math/delaunay_2d.h
index b8252e9d16..d637671686 100644
--- a/core/math/delaunay_2d.h
+++ b/core/math/delaunay_2d.h
@@ -36,31 +36,27 @@
class Delaunay2D {
public:
struct Triangle {
-
int points[3];
- bool bad;
- Triangle() { bad = false; }
+ bool bad = false;
+ Triangle() {}
Triangle(int p_a, int p_b, int p_c) {
points[0] = p_a;
points[1] = p_b;
points[2] = p_c;
- bad = false;
}
};
struct Edge {
int edge[2];
- bool bad;
- Edge() { bad = false; }
+ bool bad = false;
+ Edge() {}
Edge(int p_a, int p_b) {
- bad = false;
edge[0] = p_a;
edge[1] = p_b;
}
};
static bool circum_circle_contains(const Vector<Vector2> &p_vertices, const Triangle &p_triangle, int p_vertex) {
-
Vector2 p1 = p_vertices[p_triangle.points[0]];
Vector2 p2 = p_vertices[p_triangle.points[1]];
Vector2 p3 = p_vertices[p_triangle.points[2]];
@@ -92,7 +88,6 @@ public:
}
static Vector<Triangle> triangulate(const Vector<Vector2> &p_points) {
-
Vector<Vector2> points = p_points;
Vector<Triangle> triangles;
@@ -115,7 +110,6 @@ public:
triangles.push_back(Triangle(p_points.size() + 0, p_points.size() + 1, p_points.size() + 2));
for (int i = 0; i < p_points.size(); i++) {
-
Vector<Edge> polygon;
for (int j = 0; j < triangles.size(); j++) {
@@ -144,7 +138,6 @@ public:
}
for (int j = 0; j < polygon.size(); j++) {
-
if (polygon[j].bad) {
continue;
}
diff --git a/core/math/delaunay_3d.h b/core/math/delaunay_3d.h
index 57f3a78d35..014b4c4621 100644
--- a/core/math/delaunay_3d.h
+++ b/core/math/delaunay_3d.h
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* delaunay_3d.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 DELAUNAY_3D_H
#define DELAUNAY_3D_H
@@ -25,7 +55,6 @@ class Delaunay3D {
};
struct Simplex {
-
uint32_t points[4];
R128 circum_center_x;
R128 circum_center_y;
@@ -45,21 +74,23 @@ class Delaunay3D {
struct Triangle {
uint32_t triangle[3];
- bool bad;
+ bool bad = false;
_FORCE_INLINE_ bool operator==(const Triangle &p_triangle) const {
return triangle[0] == p_triangle.triangle[0] && triangle[1] == p_triangle.triangle[1] && triangle[2] == p_triangle.triangle[2];
}
- _FORCE_INLINE_ Triangle() { bad = false; }
+ _FORCE_INLINE_ Triangle() {}
_FORCE_INLINE_ Triangle(uint32_t p_a, uint32_t p_b, uint32_t p_c) {
- if (p_a > p_b)
+ if (p_a > p_b) {
SWAP(p_a, p_b);
- if (p_b > p_c)
+ }
+ if (p_b > p_c) {
SWAP(p_b, p_c);
- if (p_a > p_b)
+ }
+ if (p_a > p_b) {
SWAP(p_a, p_b);
+ }
- bad = false;
triangle[0] = p_a;
triangle[1] = p_b;
triangle[2] = p_c;
@@ -74,11 +105,7 @@ class Delaunay3D {
}
};
- struct FPVal {
- };
-
_FORCE_INLINE_ static void circum_sphere_compute(const Vector3 *p_points, Simplex *p_simplex) {
-
// the only part in the algorithm where there may be precision errors is this one, so ensure that
// we do it as maximum precision as possible
@@ -138,7 +165,6 @@ class Delaunay3D {
}
_FORCE_INLINE_ static bool simplex_contains(const Vector3 *p_points, const Simplex &p_simplex, uint32_t p_vertex) {
-
R128 v_x = p_points[p_vertex].x;
R128 v_y = p_points[p_vertex].y;
R128 v_z = p_points[p_vertex].z;
@@ -153,7 +179,6 @@ class Delaunay3D {
}
static bool simplex_is_coplanar(const Vector3 *p_points, const Simplex &p_simplex) {
-
Plane p(p_points[p_simplex.points[0]], p_points[p_simplex.points[1]], p_points[p_simplex.points[2]]);
if (ABS(p.distance_to(p_points[p_simplex.points[3]])) < CMP_EPSILON) {
return true;
@@ -190,7 +215,6 @@ public:
};
static Vector<OutputSimplex> tetrahedralize(const Vector<Vector3> &p_points) {
-
uint32_t point_count = p_points.size();
Vector3 *points = (Vector3 *)memalloc(sizeof(Vector3) * (point_count + 4));
@@ -247,7 +271,6 @@ public:
LocalVector<Triangle> triangles;
for (uint32_t i = 0; i < point_count; i++) {
-
bool unique = true;
for (uint32_t j = i + 1; j < point_count; j++) {
if (points[i].is_equal_approx(points[j])) {
@@ -270,7 +293,6 @@ public:
Simplex *simplex = E->get();
if (simplex_contains(points, *simplex, i)) {
-
static const uint32_t triangle_order[4][3] = {
{ 0, 1, 2 },
{ 0, 1, 3 },
@@ -303,7 +325,6 @@ public:
uint32_t good_triangles = 0;
for (uint32_t j = 0; j < triangles.size(); j++) {
-
if (triangles[j].bad) {
continue;
}
diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h
index 32b9875e4c..198f46e111 100644
--- a/core/math/disjoint_set.h
+++ b/core/math/disjoint_set.h
@@ -41,7 +41,6 @@
/* This DisjointSet class uses Find with path compression and Union by rank */
template <typename T, class C = Comparator<T>, class AL = DefaultAllocator>
class DisjointSet {
-
struct Element {
T object;
Element *parent = nullptr;
@@ -103,7 +102,6 @@ typename DisjointSet<T, C, AL>::Element *DisjointSet<T, C, AL>::insert_or_get(T
template <typename T, class C, class AL>
void DisjointSet<T, C, AL>::create_union(T a, T b) {
-
Element *x = insert_or_get(a);
Element *y = insert_or_get(b);
@@ -111,8 +109,9 @@ void DisjointSet<T, C, AL>::create_union(T a, T b) {
Element *y_root = get_parent(y);
// Already in the same set
- if (x_root == y_root)
+ if (x_root == y_root) {
return;
+ }
// Not in the same set, merge
if (x_root->rank < y_root->rank) {
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index f7a124eae3..6421606ca2 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -110,25 +110,22 @@ const char *Expression::func_name[Expression::FUNC_MAX] = {
};
Expression::BuiltinFunc Expression::find_function(const String &p_string) {
-
for (int i = 0; i < FUNC_MAX; i++) {
- if (p_string == func_name[i])
+ if (p_string == func_name[i]) {
return BuiltinFunc(i);
+ }
}
return FUNC_MAX;
}
String Expression::get_func_name(BuiltinFunc p_func) {
-
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, String());
return func_name[p_func];
}
int Expression::get_func_argument_count(BuiltinFunc p_func) {
-
switch (p_func) {
-
case MATH_RANDOMIZE:
case MATH_RAND:
case MATH_RANDF:
@@ -220,194 +217,157 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
r_error.error = Callable::CallError::CALL_OK;
switch (p_func) {
case MATH_SIN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::sin((double)*p_inputs[0]);
} break;
case MATH_COS: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::cos((double)*p_inputs[0]);
} break;
case MATH_TAN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::tan((double)*p_inputs[0]);
} break;
case MATH_SINH: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::sinh((double)*p_inputs[0]);
} break;
case MATH_COSH: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::cosh((double)*p_inputs[0]);
} break;
case MATH_TANH: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::tanh((double)*p_inputs[0]);
} break;
case MATH_ASIN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::asin((double)*p_inputs[0]);
} break;
case MATH_ACOS: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::acos((double)*p_inputs[0]);
} break;
case MATH_ATAN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::atan((double)*p_inputs[0]);
} break;
case MATH_ATAN2: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::atan2((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_SQRT: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::sqrt((double)*p_inputs[0]);
} break;
case MATH_FMOD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::fmod((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_FPOSMOD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::fposmod((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_POSMOD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::posmod((int)*p_inputs[0], (int)*p_inputs[1]);
} break;
case MATH_FLOOR: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::floor((double)*p_inputs[0]);
} break;
case MATH_CEIL: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::ceil((double)*p_inputs[0]);
} break;
case MATH_ROUND: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::round((double)*p_inputs[0]);
} break;
case MATH_ABS: {
-
if (p_inputs[0]->get_type() == Variant::INT) {
-
int64_t i = *p_inputs[0];
*r_return = ABS(i);
} else if (p_inputs[0]->get_type() == Variant::FLOAT) {
-
real_t r = *p_inputs[0];
*r_return = Math::abs(r);
} else {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::FLOAT;
}
} break;
case MATH_SIGN: {
-
if (p_inputs[0]->get_type() == Variant::INT) {
-
int64_t i = *p_inputs[0];
*r_return = i < 0 ? -1 : (i > 0 ? +1 : 0);
} else if (p_inputs[0]->get_type() == Variant::FLOAT) {
-
real_t r = *p_inputs[0];
*r_return = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
} else {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::FLOAT;
}
} break;
case MATH_POW: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::pow((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_LOG: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::log((double)*p_inputs[0]);
} break;
case MATH_EXP: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::exp((double)*p_inputs[0]);
} break;
case MATH_ISNAN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::is_nan((double)*p_inputs[0]);
} break;
case MATH_ISINF: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::is_inf((double)*p_inputs[0]);
} break;
case MATH_EASE: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::ease((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_STEP_DECIMALS: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::step_decimals((double)*p_inputs[0]);
} break;
case MATH_STEPIFY: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::stepify((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_LERP: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::lerp((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case MATH_LERP_ANGLE: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::lerp_angle((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case MATH_INVERSE_LERP: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::inverse_lerp((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case MATH_RANGE_LERP: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
@@ -422,14 +382,12 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
*r_return = Math::smoothstep((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case MATH_MOVE_TOWARD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::move_toward((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case MATH_DECTIME: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
@@ -446,20 +404,17 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
*r_return = Math::randf();
} break;
case MATH_RANDOM: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::random((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case MATH_SEED: {
-
VALIDATE_ARG_NUM(0);
uint64_t seed = *p_inputs[0];
Math::seed(seed);
} break;
case MATH_RANDSEED: {
-
VALIDATE_ARG_NUM(0);
uint64_t seed = *p_inputs[0];
int ret = Math::rand_from_seed(&seed);
@@ -470,22 +425,18 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case MATH_DEG2RAD: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::deg2rad((double)*p_inputs[0]);
} break;
case MATH_RAD2DEG: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::rad2deg((double)*p_inputs[0]);
} break;
case MATH_LINEAR2DB: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::linear2db((double)*p_inputs[0]);
} break;
case MATH_DB2LINEAR: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::db2linear((double)*p_inputs[0]);
} break;
@@ -516,9 +467,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
*r_return = Math::wrapf((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case LOGIC_MAX: {
-
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT) {
-
int64_t a = *p_inputs[0];
int64_t b = *p_inputs[1];
*r_return = MAX(a, b);
@@ -534,9 +483,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case LOGIC_MIN: {
-
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT) {
-
int64_t a = *p_inputs[0];
int64_t b = *p_inputs[1];
*r_return = MIN(a, b);
@@ -551,9 +498,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
}
} break;
case LOGIC_CLAMP: {
-
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT && p_inputs[2]->get_type() == Variant::INT) {
-
int64_t a = *p_inputs[0];
int64_t b = *p_inputs[1];
int64_t c = *p_inputs[2];
@@ -571,15 +516,12 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
}
} break;
case LOGIC_NEAREST_PO2: {
-
VALIDATE_ARG_NUM(0);
int64_t num = *p_inputs[0];
*r_return = next_power_of_2(num);
} break;
case OBJ_WEAKREF: {
-
if (p_inputs[0]->get_type() != Variant::OBJECT) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -588,10 +530,8 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
}
if (p_inputs[0]->is_ref()) {
-
REF r = *p_inputs[0];
if (!r.is_valid()) {
-
return;
}
@@ -601,7 +541,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} else {
Object *obj = *p_inputs[0];
if (!obj) {
-
return;
}
Ref<WeakRef> wref = memnew(WeakRef);
@@ -611,9 +550,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case FUNC_FUNCREF: {
-
if (p_inputs[0]->get_type() != Variant::OBJECT) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -621,7 +558,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
return;
}
if (p_inputs[1]->get_type() != Variant::STRING && p_inputs[1]->get_type() != Variant::NODE_PATH) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
@@ -638,11 +574,9 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case TYPE_CONVERT: {
-
VALIDATE_ARG_NUM(1);
int type = *p_inputs[1];
if (type < 0 || type >= Variant::VARIANT_MAX) {
-
r_error_str = RTR("Invalid type argument to convert(), use TYPE_* constants.");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -650,31 +584,25 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
return;
} else {
-
*r_return = Variant::construct(Variant::Type(type), p_inputs, 1, r_error);
}
} break;
case TYPE_OF: {
-
*r_return = p_inputs[0]->get_type();
} break;
case TYPE_EXISTS: {
-
*r_return = ClassDB::class_exists(*p_inputs[0]);
} break;
case TEXT_CHAR: {
-
CharType result[2] = { *p_inputs[0], 0 };
*r_return = String(result);
} break;
case TEXT_ORD: {
-
if (p_inputs[0]->get_type() != Variant::STRING) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
@@ -685,7 +613,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
String str = *p_inputs[0];
if (str.length() != 1) {
-
r_error_str = RTR("Expected a string of length 1 (a character).");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -698,39 +625,33 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case TEXT_STR: {
-
String str = *p_inputs[0];
*r_return = str;
} break;
case TEXT_PRINT: {
-
String str = *p_inputs[0];
print_line(str);
} break;
case TEXT_PRINTERR: {
-
String str = *p_inputs[0];
print_error(str);
} break;
case TEXT_PRINTRAW: {
-
String str = *p_inputs[0];
OS::get_singleton()->print("%s", str.utf8().get_data());
} break;
case VAR_TO_STR: {
-
String vars;
VariantWriter::write_to_string(*p_inputs[0], vars);
*r_return = vars;
} break;
case STR_TO_VAR: {
-
if (p_inputs[0]->get_type() != Variant::STRING) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -756,7 +677,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case VAR_TO_BYTES: {
-
PackedByteArray barr;
bool full_objects = *p_inputs[1];
int len;
@@ -777,7 +697,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
*r_return = barr;
} break;
case BYTES_TO_VAR: {
-
if (p_inputs[0]->get_type() != Variant::PACKED_BYTE_ARRAY) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -805,7 +724,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
} break;
case COLORN: {
-
VALIDATE_ARG_NUM(1);
Color color = Color::named(*p_inputs[0]);
@@ -826,60 +744,49 @@ static bool _is_number(CharType c) {
}
Error Expression::_get_token(Token &r_token) {
-
while (true) {
#define GET_CHAR() (str_ofs >= expression.length() ? 0 : expression[str_ofs++])
CharType cchar = GET_CHAR();
switch (cchar) {
-
case 0: {
r_token.type = TK_EOF;
return OK;
- };
+ }
case '{': {
-
r_token.type = TK_CURLY_BRACKET_OPEN;
return OK;
- };
+ }
case '}': {
-
r_token.type = TK_CURLY_BRACKET_CLOSE;
return OK;
- };
+ }
case '[': {
-
r_token.type = TK_BRACKET_OPEN;
return OK;
- };
+ }
case ']': {
-
r_token.type = TK_BRACKET_CLOSE;
return OK;
- };
+ }
case '(': {
-
r_token.type = TK_PARENTHESIS_OPEN;
return OK;
- };
+ }
case ')': {
-
r_token.type = TK_PARENTHESIS_CLOSE;
return OK;
- };
+ }
case ',': {
-
r_token.type = TK_COMMA;
return OK;
- };
+ }
case ':': {
-
r_token.type = TK_COLON;
return OK;
- };
+ }
case '$': {
-
r_token.type = TK_INPUT;
int index = 0;
do {
@@ -896,9 +803,8 @@ Error Expression::_get_token(Token &r_token) {
r_token.value = index;
return OK;
- };
+ }
case '=': {
-
cchar = GET_CHAR();
if (cchar == '=') {
r_token.type = TK_OP_EQUAL;
@@ -908,9 +814,8 @@ Error Expression::_get_token(Token &r_token) {
return ERR_PARSE_ERROR;
}
return OK;
- };
+ }
case '!': {
-
if (expression[str_ofs] == '=') {
r_token.type = TK_OP_NOT_EQUAL;
str_ofs++;
@@ -918,9 +823,8 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_OP_NOT;
}
return OK;
- };
+ }
case '>': {
-
if (expression[str_ofs] == '=') {
r_token.type = TK_OP_GREATER_EQUAL;
str_ofs++;
@@ -931,9 +835,8 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_OP_GREATER;
}
return OK;
- };
+ }
case '<': {
-
if (expression[str_ofs] == '=') {
r_token.type = TK_OP_LESS_EQUAL;
str_ofs++;
@@ -944,29 +847,28 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_OP_LESS;
}
return OK;
- };
+ }
case '+': {
r_token.type = TK_OP_ADD;
return OK;
- };
+ }
case '-': {
r_token.type = TK_OP_SUB;
return OK;
- };
+ }
case '/': {
r_token.type = TK_OP_DIV;
return OK;
- };
+ }
case '*': {
r_token.type = TK_OP_MUL;
return OK;
- };
+ }
case '%': {
r_token.type = TK_OP_MOD;
return OK;
- };
+ }
case '&': {
-
if (expression[str_ofs] == '&') {
r_token.type = TK_OP_AND;
str_ofs++;
@@ -974,9 +876,8 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_OP_BIT_AND;
}
return OK;
- };
+ }
case '|': {
-
if (expression[str_ofs] == '|') {
r_token.type = TK_OP_OR;
str_ofs++;
@@ -984,31 +885,29 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_OP_BIT_OR;
}
return OK;
- };
+ }
case '^': {
-
r_token.type = TK_OP_BIT_XOR;
return OK;
- };
+ }
case '~': {
-
r_token.type = TK_OP_BIT_INVERT;
return OK;
- };
+ }
+ case '\'':
case '"': {
-
String str;
while (true) {
-
CharType ch = GET_CHAR();
if (ch == 0) {
_set_error("Unterminated String");
r_token.type = TK_ERROR;
return ERR_PARSE_ERROR;
- } else if (ch == '"') {
+ } else if (ch == cchar) {
+ // cchar contain a corresponding quote symbol
break;
} else if (ch == '\\') {
//escaped characters...
@@ -1022,7 +921,6 @@ Error Expression::_get_token(Token &r_token) {
CharType res = 0;
switch (next) {
-
case 'b':
res = 8;
break;
@@ -1049,7 +947,6 @@ Error Expression::_get_token(Token &r_token) {
return ERR_PARSE_ERROR;
}
if (!(_is_number(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
-
_set_error("Malformed hex constant in string");
r_token.type = TK_ERROR;
return ERR_PARSE_ERROR;
@@ -1091,7 +988,6 @@ Error Expression::_get_token(Token &r_token) {
} break;
default: {
-
if (cchar <= 32) {
break;
}
@@ -1114,10 +1010,8 @@ Error Expression::_get_token(Token &r_token) {
bool is_float = false;
while (true) {
-
switch (reading) {
case READING_INT: {
-
if (_is_number(c)) {
//pass
} else if (c == '.') {
@@ -1131,9 +1025,7 @@ Error Expression::_get_token(Token &r_token) {
} break;
case READING_DEC: {
-
if (_is_number(c)) {
-
} else if (c == 'e') {
reading = READING_EXP;
@@ -1143,13 +1035,13 @@ Error Expression::_get_token(Token &r_token) {
} break;
case READING_EXP: {
-
if (_is_number(c)) {
exp_beg = true;
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
- if (c == '-')
+ if (c == '-') {
is_float = true;
+ }
exp_sign = true;
} else {
@@ -1158,8 +1050,9 @@ Error Expression::_get_token(Token &r_token) {
} break;
}
- if (reading == READING_DONE)
+ if (reading == READING_DONE) {
break;
+ }
num += String::chr(c);
c = GET_CHAR();
}
@@ -1168,19 +1061,18 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_CONSTANT;
- if (is_float)
+ if (is_float) {
r_token.value = num.to_double();
- else
+ } else {
r_token.value = num.to_int64();
+ }
return OK;
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
-
String id;
bool first = true;
while ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_' || (!first && _is_number(cchar))) {
-
id += String::chr(cchar);
cchar = GET_CHAR();
first = false;
@@ -1220,7 +1112,6 @@ Error Expression::_get_token(Token &r_token) {
} else if (id == "self") {
r_token.type = TK_SELF;
} else {
-
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (id == Variant::get_type_name(Variant::Type(i))) {
r_token.type = TK_BASIC_TYPE;
@@ -1303,7 +1194,6 @@ const char *Expression::token_name[TK_MAX] = {
};
Expression::ENode *Expression::_parse_expression() {
-
Vector<ExpressionNode> expression;
while (true) {
@@ -1312,8 +1202,9 @@ Expression::ENode *Expression::_parse_expression() {
Token tk;
_get_token(tk);
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
switch (tk.type) {
case TK_CURLY_BRACKET_OPEN: {
@@ -1321,7 +1212,6 @@ Expression::ENode *Expression::_parse_expression() {
DictionaryNode *dn = alloc_node<DictionaryNode>();
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_CURLY_BRACKET_CLOSE) {
@@ -1330,8 +1220,9 @@ Expression::ENode *Expression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
dn->dict.push_back(subexpr);
_get_token(tk);
@@ -1341,8 +1232,9 @@ Expression::ENode *Expression::_parse_expression() {
}
subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
dn->dict.push_back(subexpr);
@@ -1365,7 +1257,6 @@ Expression::ENode *Expression::_parse_expression() {
ArrayNode *an = alloc_node<ArrayNode>();
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_BRACKET_CLOSE) {
@@ -1374,8 +1265,9 @@ Expression::ENode *Expression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
an->array.push_back(subexpr);
cofs = str_ofs;
@@ -1394,8 +1286,9 @@ Expression::ENode *Expression::_parse_expression() {
case TK_PARENTHESIS_OPEN: {
//a suexpression
ENode *e = _parse_expression();
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
_get_token(tk);
if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')'");
@@ -1406,7 +1299,6 @@ Expression::ENode *Expression::_parse_expression() {
} break;
case TK_IDENTIFIER: {
-
String identifier = tk.value;
int cofs = str_ofs;
@@ -1419,7 +1311,6 @@ Expression::ENode *Expression::_parse_expression() {
func_call->base = self_node;
while (true) {
-
int cofs2 = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -1428,8 +1319,9 @@ Expression::ENode *Expression::_parse_expression() {
str_ofs = cofs2; //revert
//parse an expression
ENode *subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
func_call->arguments.push_back(subexpr);
@@ -1462,7 +1354,6 @@ Expression::ENode *Expression::_parse_expression() {
input->index = input_index;
expr = input;
} else {
-
NamedIndexNode *index = alloc_node<NamedIndexNode>();
SelfNode *self_node = alloc_node<SelfNode>();
index->base = self_node;
@@ -1472,13 +1363,11 @@ Expression::ENode *Expression::_parse_expression() {
}
} break;
case TK_INPUT: {
-
InputNode *input = alloc_node<InputNode>();
input->index = tk.value;
expr = input;
} break;
case TK_SELF: {
-
SelfNode *self = alloc_node<SelfNode>();
expr = self;
} break;
@@ -1501,7 +1390,6 @@ Expression::ENode *Expression::_parse_expression() {
constructor->data_type = bt;
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -1510,8 +1398,9 @@ Expression::ENode *Expression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
constructor->arguments.push_back(subexpr);
@@ -1542,7 +1431,6 @@ Expression::ENode *Expression::_parse_expression() {
bifunc->func = BuiltinFunc(int(tk.value));
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -1551,8 +1439,9 @@ Expression::ENode *Expression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
bifunc->arguments.push_back(subexpr);
@@ -1576,7 +1465,6 @@ Expression::ENode *Expression::_parse_expression() {
} break;
case TK_OP_SUB: {
-
ExpressionNode e;
e.is_op = true;
e.op = Variant::OP_NEGATE;
@@ -1584,7 +1472,6 @@ Expression::ENode *Expression::_parse_expression() {
continue;
} break;
case TK_OP_NOT: {
-
ExpressionNode e;
e.is_op = true;
e.op = Variant::OP_NOT;
@@ -1603,8 +1490,9 @@ Expression::ENode *Expression::_parse_expression() {
while (true) {
int cofs2 = str_ofs;
_get_token(tk);
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
bool done = false;
@@ -1616,8 +1504,9 @@ Expression::ENode *Expression::_parse_expression() {
index->base = expr;
ENode *what = _parse_expression();
- if (!what)
+ if (!what) {
return nullptr;
+ }
index->index = what;
@@ -1648,7 +1537,6 @@ Expression::ENode *Expression::_parse_expression() {
func_call->base = expr;
while (true) {
-
int cofs3 = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -1657,8 +1545,9 @@ Expression::ENode *Expression::_parse_expression() {
str_ofs = cofs3; //revert
//parse an expression
ENode *subexpr = _parse_expression();
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
func_call->arguments.push_back(subexpr);
@@ -1691,8 +1580,9 @@ Expression::ENode *Expression::_parse_expression() {
} break;
}
- if (done)
+ if (done) {
break;
+ }
}
//push expression
@@ -1707,8 +1597,9 @@ Expression::ENode *Expression::_parse_expression() {
int cofs = str_ofs;
_get_token(tk);
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
Variant::Operator op = Variant::OP_MAX;
@@ -1777,7 +1668,7 @@ Expression::ENode *Expression::_parse_expression() {
op = Variant::OP_BIT_NEGATE;
break;
default: {
- };
+ }
}
if (op == Variant::OP_MAX) { //stop appending stuff
@@ -1797,15 +1688,12 @@ Expression::ENode *Expression::_parse_expression() {
/* Reduce the set set of expressions and place them in an operator tree, respecting precedence */
while (expression.size() > 1) {
-
int next_op = -1;
int min_priority = 0xFFFFF;
bool is_unary = false;
for (int i = 0; i < expression.size(); i++) {
-
if (!expression[i].is_op) {
-
continue;
}
@@ -1814,7 +1702,6 @@ Expression::ENode *Expression::_parse_expression() {
bool unary = false;
switch (expression[i].op) {
-
case Variant::OP_BIT_NEGATE:
priority = 0;
unary = true;
@@ -1910,17 +1797,14 @@ Expression::ENode *Expression::_parse_expression() {
}
if (next_op == -1) {
-
_set_error("Yet another parser bug....");
ERR_FAIL_V(nullptr);
}
// OK! create operator..
if (is_unary) {
-
int expr_pos = next_op;
while (expression[expr_pos].is_op) {
-
expr_pos++;
if (expr_pos == expression.size()) {
//can happen..
@@ -1931,7 +1815,6 @@ Expression::ENode *Expression::_parse_expression() {
//consecutively do unary operators
for (int i = expr_pos - 1; i >= next_op; i--) {
-
OperatorNode *op = alloc_node<OperatorNode>();
op->op = expression[i].op;
op->nodes[0] = expression[i + 1].node;
@@ -1942,7 +1825,6 @@ Expression::ENode *Expression::_parse_expression() {
}
} else {
-
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
@@ -1952,7 +1834,6 @@ Expression::ENode *Expression::_parse_expression() {
op->op = expression[next_op].op;
if (expression[next_op - 1].is_op) {
-
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
}
@@ -1981,9 +1862,9 @@ Expression::ENode *Expression::_parse_expression() {
}
bool Expression::_compile_expression() {
-
- if (!expression_dirty)
+ if (!expression_dirty) {
return error_set;
+ }
if (nodes) {
memdelete(nodes);
@@ -2011,10 +1892,8 @@ bool Expression::_compile_expression() {
}
bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression::ENode *p_node, Variant &r_ret, String &r_error_str) {
-
switch (p_node->type) {
case Expression::ENode::TYPE_INPUT: {
-
const Expression::InputNode *in = static_cast<const Expression::InputNode *>(p_node);
if (in->index < 0 || in->index >= p_inputs.size()) {
r_error_str = vformat(RTR("Invalid input %i (not passed) in expression"), in->index);
@@ -2023,13 +1902,11 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
r_ret = p_inputs[in->index];
} break;
case Expression::ENode::TYPE_CONSTANT: {
-
const Expression::ConstantNode *c = static_cast<const Expression::ConstantNode *>(p_node);
r_ret = c->value;
} break;
case Expression::ENode::TYPE_SELF: {
-
if (!p_instance) {
r_error_str = RTR("self can't be used because instance is null (not passed)");
return true;
@@ -2037,20 +1914,21 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
r_ret = p_instance;
} break;
case Expression::ENode::TYPE_OPERATOR: {
-
const Expression::OperatorNode *op = static_cast<const Expression::OperatorNode *>(p_node);
Variant a;
bool ret = _execute(p_inputs, p_instance, op->nodes[0], a, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
Variant b;
if (op->nodes[1]) {
ret = _execute(p_inputs, p_instance, op->nodes[1], b, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
}
bool valid = true;
@@ -2062,19 +1940,20 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
} break;
case Expression::ENode::TYPE_INDEX: {
-
const Expression::IndexNode *index = static_cast<const Expression::IndexNode *>(p_node);
Variant base;
bool ret = _execute(p_inputs, p_instance, index->base, base, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
Variant idx;
ret = _execute(p_inputs, p_instance, index->index, idx, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
bool valid;
r_ret = base.get(idx, &valid);
@@ -2085,13 +1964,13 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
} break;
case Expression::ENode::TYPE_NAMED_INDEX: {
-
const Expression::NamedIndexNode *index = static_cast<const Expression::NamedIndexNode *>(p_node);
Variant base;
bool ret = _execute(p_inputs, p_instance, index->base, base, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
bool valid;
r_ret = base.get_named(index->name, &valid);
@@ -2107,12 +1986,12 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
Array arr;
arr.resize(array->array.size());
for (int i = 0; i < array->array.size(); i++) {
-
Variant value;
bool ret = _execute(p_inputs, p_instance, array->array[i], value, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
arr[i] = value;
}
@@ -2124,17 +2003,18 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
Dictionary d;
for (int i = 0; i < dictionary->dict.size(); i += 2) {
-
Variant key;
bool ret = _execute(p_inputs, p_instance, dictionary->dict[i + 0], key, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
Variant value;
ret = _execute(p_inputs, p_instance, dictionary->dict[i + 1], value, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
d[key] = value;
}
@@ -2142,7 +2022,6 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
r_ret = d;
} break;
case Expression::ENode::TYPE_CONSTRUCTOR: {
-
const Expression::ConstructorNode *constructor = static_cast<const Expression::ConstructorNode *>(p_node);
Vector<Variant> arr;
@@ -2151,12 +2030,12 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
argp.resize(constructor->arguments.size());
for (int i = 0; i < constructor->arguments.size(); i++) {
-
Variant value;
bool ret = _execute(p_inputs, p_instance, constructor->arguments[i], value, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
arr.write[i] = value;
argp.write[i] = &arr[i];
}
@@ -2171,7 +2050,6 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
} break;
case Expression::ENode::TYPE_BUILTIN_FUNC: {
-
const Expression::BuiltinFuncNode *bifunc = static_cast<const Expression::BuiltinFuncNode *>(p_node);
Vector<Variant> arr;
@@ -2180,11 +2058,11 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
argp.resize(bifunc->arguments.size());
for (int i = 0; i < bifunc->arguments.size(); i++) {
-
Variant value;
bool ret = _execute(p_inputs, p_instance, bifunc->arguments[i], value, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
arr.write[i] = value;
argp.write[i] = &arr[i];
}
@@ -2199,14 +2077,14 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
} break;
case Expression::ENode::TYPE_CALL: {
-
const Expression::CallNode *call = static_cast<const Expression::CallNode *>(p_node);
Variant base;
bool ret = _execute(p_inputs, p_instance, call->base, base, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
Vector<Variant> arr;
Vector<const Variant *> argp;
@@ -2214,12 +2092,12 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
argp.resize(call->arguments.size());
for (int i = 0; i < call->arguments.size(); i++) {
-
Variant value;
ret = _execute(p_inputs, p_instance, call->arguments[i], value, r_error_str);
- if (ret)
+ if (ret) {
return true;
+ }
arr.write[i] = value;
argp.write[i] = &arr[i];
}
@@ -2238,7 +2116,6 @@ bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression:
}
Error Expression::parse(const String &p_expression, const Vector<String> &p_input_names) {
-
if (nodes) {
memdelete(nodes);
nodes = nullptr;
@@ -2266,7 +2143,6 @@ Error Expression::parse(const String &p_expression, const Vector<String> &p_inpu
}
Variant Expression::execute(Array p_inputs, Object *p_base, bool p_show_error) {
-
ERR_FAIL_COND_V_MSG(error_set, Variant(), "There was previously a parse error: " + error_str + ".");
execution_error = false;
@@ -2291,26 +2167,13 @@ String Expression::get_error_text() const {
}
void Expression::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("parse", "expression", "input_names"), &Expression::parse, DEFVAL(Vector<String>()));
ClassDB::bind_method(D_METHOD("execute", "inputs", "base_instance", "show_error"), &Expression::execute, DEFVAL(Array()), DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("has_execute_failed"), &Expression::has_execute_failed);
ClassDB::bind_method(D_METHOD("get_error_text"), &Expression::get_error_text);
}
-Expression::Expression() :
- output_type(Variant::NIL),
- sequenced(false),
- error_set(true),
- root(nullptr),
- nodes(nullptr),
- execution_error(false) {
- str_ofs = 0;
- expression_dirty = false;
-}
-
Expression::~Expression() {
-
if (nodes) {
memdelete(nodes);
}
diff --git a/core/math/expression.h b/core/math/expression.h
index 78de225ebf..59a9a2f4ed 100644
--- a/core/math/expression.h
+++ b/core/math/expression.h
@@ -118,23 +118,20 @@ private:
static const char *func_name[FUNC_MAX];
struct Input {
-
- Variant::Type type;
+ Variant::Type type = Variant::NIL;
String name;
- Input() :
- type(Variant::NIL) {
- }
+ Input() {}
};
Vector<Input> inputs;
- Variant::Type output_type;
+ Variant::Type output_type = Variant::NIL;
String expression;
- bool sequenced;
- int str_ofs;
- bool expression_dirty;
+ bool sequenced = false;
+ int str_ofs = 0;
+ bool expression_dirty = false;
bool _compile_expression();
@@ -182,14 +179,14 @@ private:
static const char *token_name[TK_MAX];
struct Token {
-
TokenType type;
Variant value;
};
void _set_error(const String &p_err) {
- if (error_set)
+ if (error_set) {
return;
+ }
error_str = p_err;
error_set = true;
}
@@ -197,10 +194,9 @@ private:
Error _get_token(Token &r_token);
String error_str;
- bool error_set;
+ bool error_set = true;
struct ENode {
-
enum Type {
TYPE_INPUT,
TYPE_CONSTANT,
@@ -215,11 +211,11 @@ private:
TYPE_CALL
};
- ENode *next;
+ ENode *next = nullptr;
Type type;
- ENode() { next = nullptr; }
+ ENode() {}
virtual ~ENode() {
if (next) {
memdelete(next);
@@ -228,7 +224,6 @@ private:
};
struct ExpressionNode {
-
bool is_op;
union {
Variant::Operator op;
@@ -239,7 +234,6 @@ private:
ENode *_parse_expression();
struct InputNode : public ENode {
-
int index;
InputNode() {
type = TYPE_INPUT;
@@ -247,7 +241,6 @@ private:
};
struct ConstantNode : public ENode {
-
Variant value;
ConstantNode() {
type = TYPE_CONSTANT;
@@ -255,7 +248,6 @@ private:
};
struct OperatorNode : public ENode {
-
Variant::Operator op;
ENode *nodes[2];
@@ -266,7 +258,6 @@ private:
};
struct SelfNode : public ENode {
-
SelfNode() {
type = TYPE_SELF;
}
@@ -339,12 +330,12 @@ private:
return node;
}
- ENode *root;
- ENode *nodes;
+ ENode *root = nullptr;
+ ENode *nodes = nullptr;
Vector<String> input_names;
- bool execution_error;
+ bool execution_error = false;
bool _execute(const Array &p_inputs, Object *p_instance, Expression::ENode *p_node, Variant &r_ret, String &r_error_str);
protected:
@@ -356,7 +347,7 @@ public:
bool has_execute_failed() const;
String get_error_text() const;
- Expression();
+ Expression() {}
~Expression();
};
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 74331b391f..db2bfaa58b 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -30,10 +30,9 @@
#include "face3.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_over[3]) const {
-
ERR_FAIL_COND_V(is_degenerate(), 0);
Vector3 above[4];
@@ -43,7 +42,6 @@ int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_
int below_count = 0;
for (int i = 0; i < 3; i++) {
-
if (p_plane.has_point(vertex[i], CMP_EPSILON)) { // point is in plane
ERR_FAIL_COND_V(above_count >= 4, 0);
@@ -52,7 +50,6 @@ int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_
below[below_count++] = vertex[i];
} else {
-
if (p_plane.is_point_over(vertex[i])) {
//Point is over
ERR_FAIL_COND_V(above_count >= 4, 0);
@@ -67,8 +64,9 @@ int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_
/* Check for Intersection between this and the next vertex*/
Vector3 inters;
- if (!p_plane.intersects_segment(vertex[i], vertex[(i + 1) % 3], &inters))
+ if (!p_plane.intersects_segment(vertex[i], vertex[(i + 1) % 3], &inters)) {
continue;
+ }
/* Intersection goes to both */
ERR_FAIL_COND_V(above_count >= 4, 0);
@@ -83,13 +81,11 @@ int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_
ERR_FAIL_COND_V(above_count >= 4 && below_count >= 4, 0); //bug in the algo
if (above_count >= 3) {
-
p_res[polygons_created] = Face3(above[0], above[1], above[2]);
p_is_point_over[polygons_created] = true;
polygons_created++;
if (above_count == 4) {
-
p_res[polygons_created] = Face3(above[2], above[3], above[0]);
p_is_point_over[polygons_created] = true;
polygons_created++;
@@ -97,13 +93,11 @@ int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_
}
if (below_count >= 3) {
-
p_res[polygons_created] = Face3(below[0], below[1], below[2]);
p_is_point_over[polygons_created] = false;
polygons_created++;
if (below_count == 4) {
-
p_res[polygons_created] = Face3(below[2], below[3], below[0]);
p_is_point_over[polygons_created] = false;
polygons_created++;
@@ -114,52 +108,49 @@ int Face3::split_by_plane(const Plane &p_plane, Face3 p_res[3], bool p_is_point_
}
bool Face3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const {
-
- return Geometry::ray_intersects_triangle(p_from, p_dir, vertex[0], vertex[1], vertex[2], p_intersection);
+ return Geometry3D::ray_intersects_triangle(p_from, p_dir, vertex[0], vertex[1], vertex[2], p_intersection);
}
bool Face3::intersects_segment(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const {
-
- return Geometry::segment_intersects_triangle(p_from, p_dir, vertex[0], vertex[1], vertex[2], p_intersection);
+ return Geometry3D::segment_intersects_triangle(p_from, p_dir, vertex[0], vertex[1], vertex[2], p_intersection);
}
bool Face3::is_degenerate() const {
-
Vector3 normal = vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]);
return (normal.length_squared() < CMP_EPSILON2);
}
Face3::Side Face3::get_side_of(const Face3 &p_face, ClockDirection p_clock_dir) const {
-
int over = 0, under = 0;
Plane plane = get_plane(p_clock_dir);
for (int i = 0; i < 3; i++) {
-
const Vector3 &v = p_face.vertex[i];
- if (plane.has_point(v)) //coplanar, don't bother
+ if (plane.has_point(v)) { //coplanar, don't bother
continue;
+ }
- if (plane.is_point_over(v))
+ if (plane.is_point_over(v)) {
over++;
- else
+ } else {
under++;
+ }
}
- if (over > 0 && under == 0)
+ if (over > 0 && under == 0) {
return SIDE_OVER;
- else if (under > 0 && over == 0)
+ } else if (under > 0 && over == 0) {
return SIDE_UNDER;
- else if (under == 0 && over == 0)
+ } else if (under == 0 && over == 0) {
return SIDE_COPLANAR;
- else
+ } else {
return SIDE_SPANNING;
+ }
}
Vector3 Face3::get_random_point_inside() const {
-
real_t a = Math::random(0, 1);
real_t b = Math::random(0, 1);
if (a > b) {
@@ -170,32 +161,28 @@ Vector3 Face3::get_random_point_inside() const {
}
Plane Face3::get_plane(ClockDirection p_dir) const {
-
return Plane(vertex[0], vertex[1], vertex[2], p_dir);
}
Vector3 Face3::get_median_point() const {
-
return (vertex[0] + vertex[1] + vertex[2]) / 3.0;
}
real_t Face3::get_area() const {
-
return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length();
}
ClockDirection Face3::get_clock_dir() const {
-
Vector3 normal = vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]);
//printf("normal is %g,%g,%g x %g,%g,%g- wtfu is %g\n",tofloat(normal.x),tofloat(normal.y),tofloat(normal.z),tofloat(vertex[0].x),tofloat(vertex[0].y),tofloat(vertex[0].z),tofloat( normal.dot( vertex[0] ) ) );
return (normal.dot(vertex[0]) >= 0) ? CLOCKWISE : COUNTERCLOCKWISE;
}
bool Face3::intersects_aabb(const AABB &p_aabb) const {
-
/** TEST PLANE **/
- if (!p_aabb.intersects_plane(get_plane()))
+ if (!p_aabb.intersects_plane(get_plane())) {
return false;
+ }
#define TEST_AXIS(m_ax) \
/** TEST FACE AXIS */ \
@@ -228,7 +215,6 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const {
};
for (int i = 0; i < 12; i++) {
-
Vector3 from, to;
p_aabb.get_edge(i, from, to);
Vector3 e1 = from - to;
@@ -237,58 +223,57 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const {
Vector3 axis = vec3_cross(e1, e2);
- if (axis.length_squared() < 0.0001)
+ if (axis.length_squared() < 0.0001) {
continue; // coplanar
+ }
axis.normalize();
real_t minA, maxA, minB, maxB;
p_aabb.project_range_in_plane(Plane(axis, 0), minA, maxA);
project_range(axis, Transform(), minB, maxB);
- if (maxA < minB || maxB < minA)
+ if (maxA < minB || maxB < minA) {
return false;
+ }
}
}
return true;
}
Face3::operator String() const {
-
return String() + vertex[0] + ", " + vertex[1] + ", " + vertex[2];
}
void Face3::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
for (int i = 0; i < 3; i++) {
-
Vector3 v = p_transform.xform(vertex[i]);
real_t d = p_normal.dot(v);
- if (i == 0 || d > r_max)
+ if (i == 0 || d > r_max) {
r_max = d;
+ }
- if (i == 0 || d < r_min)
+ if (i == 0 || d < r_min) {
r_min = d;
+ }
}
}
void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const {
-
#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.98
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.05
- if (p_max <= 0)
+ if (p_max <= 0) {
return;
+ }
Vector3 n = p_transform.basis.xform_inv(p_normal);
/** TEST FACE AS SUPPORT **/
if (get_plane().normal.dot(n) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
-
*p_count = MIN(3, p_max);
for (int i = 0; i < *p_count; i++) {
-
p_vertices[i] = p_transform.xform(vertex[i]);
}
@@ -301,7 +286,6 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
real_t support_max = 0;
for (int i = 0; i < 3; i++) {
-
real_t d = n.dot(vertex[i]);
if (i == 0 || d > support_max) {
@@ -313,19 +297,19 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
/** TEST EDGES AS SUPPORT **/
for (int i = 0; i < 3; i++) {
-
- if (i != vert_support_idx && i + 1 != vert_support_idx)
+ if (i != vert_support_idx && i + 1 != vert_support_idx) {
continue;
+ }
// check if edge is valid as a support
real_t dot = (vertex[i] - vertex[(i + 1) % 3]).normalized().dot(n);
dot = ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
-
*p_count = MIN(2, p_max);
- for (int j = 0; j < *p_count; j++)
+ for (int j = 0; j < *p_count; j++) {
p_vertices[j] = p_transform.xform(vertex[(j + i) % 3]);
+ }
return;
}
@@ -336,7 +320,6 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
}
Vector3 Face3::get_closest_point_to(const Vector3 &p_point) const {
-
Vector3 edge0 = vertex[1] - vertex[0];
Vector3 edge1 = vertex[2] - vertex[0];
Vector3 v0 = vertex[0] - p_point;
diff --git a/core/math/face3.h b/core/math/face3.h
index f4b8721caa..fb40e8ab9e 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -69,8 +69,8 @@ public:
Vector3 get_median_point() const;
Vector3 get_closest_point_to(const Vector3 &p_point) const;
- bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = 0) const;
- bool intersects_segment(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = 0) const;
+ bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = nullptr) const;
+ bool intersects_segment(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection = nullptr) const;
ClockDirection get_clock_dir() const; ///< todo, test if this is returning the proper clockwisity
@@ -78,7 +78,6 @@ public:
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
AABB get_aabb() const {
-
AABB aabb(vertex[0], Vector3());
aabb.expand_to(vertex[1]);
aabb.expand_to(vertex[2]);
@@ -98,7 +97,6 @@ public:
};
bool Face3::intersects_aabb2(const AABB &p_aabb) const {
-
Vector3 perp = (vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]);
Vector3 half_extents = p_aabb.size * 0.5;
@@ -113,8 +111,9 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const {
real_t dist_a = perp.dot(ofs + sup) - d;
real_t dist_b = perp.dot(ofs - sup) - d;
- if (dist_a * dist_b > 0)
+ if (dist_a * dist_b > 0) {
return false; //does not intersect the plane
+ }
#define TEST_AXIS(m_ax) \
{ \
@@ -145,17 +144,13 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const {
};
for (int i = 0; i < 12; i++) {
-
Vector3 from, to;
switch (i) {
-
case 0: {
-
from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z);
to = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z);
} break;
case 1: {
-
from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z);
} break;
@@ -165,18 +160,15 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const {
} break;
case 3: {
-
from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z);
to = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 4: {
-
from = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 5: {
-
from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
} break;
@@ -186,31 +178,26 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const {
} break;
case 7: {
-
from = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 8: {
-
from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
} break;
case 9: {
-
from = Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z);
to = Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 10: {
-
from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z);
to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z);
} break;
case 11: {
-
from = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z);
to = Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z);
@@ -223,8 +210,9 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const {
Vector3 axis = vec3_cross(e1, e2);
- if (axis.length_squared() < 0.0001)
+ if (axis.length_squared() < 0.0001) {
continue; // coplanar
+ }
//axis.normalize();
Vector3 sup2 = Vector3(
@@ -240,18 +228,20 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const {
real_t minT = 1e20, maxT = -1e20;
for (int k = 0; k < 3; k++) {
-
real_t vert_d = axis.dot(vertex[k]);
- if (vert_d > maxT)
+ if (vert_d > maxT) {
maxT = vert_d;
+ }
- if (vert_d < minT)
+ if (vert_d < minT) {
minT = vert_d;
+ }
}
- if (maxB < minT || maxT < minB)
+ if (maxB < minT || maxT < minB) {
return false;
+ }
}
}
return true;
diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp
new file mode 100644
index 0000000000..7d8fde8bcc
--- /dev/null
+++ b/core/math/geometry_2d.cpp
@@ -0,0 +1,384 @@
+/*************************************************************************/
+/* geometry.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 "geometry_2d.h"
+
+#include "thirdparty/misc/clipper.hpp"
+#include "thirdparty/misc/triangulator.h"
+#define STB_RECT_PACK_IMPLEMENTATION
+#include "thirdparty/misc/stb_rect_pack.h"
+
+#define SCALE_FACTOR 100000.0 // Based on CMP_EPSILON.
+
+Vector<Vector<Vector2>> Geometry2D::decompose_polygon_in_convex(Vector<Point2> polygon) {
+ Vector<Vector<Vector2>> decomp;
+ List<TriangulatorPoly> in_poly, out_poly;
+
+ TriangulatorPoly inp;
+ inp.Init(polygon.size());
+ for (int i = 0; i < polygon.size(); i++) {
+ inp.GetPoint(i) = polygon[i];
+ }
+ inp.SetOrientation(TRIANGULATOR_CCW);
+ in_poly.push_back(inp);
+ TriangulatorPartition tpart;
+ if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { // Failed.
+ ERR_PRINT("Convex decomposing failed!");
+ return decomp;
+ }
+
+ decomp.resize(out_poly.size());
+ int idx = 0;
+ for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
+ TriangulatorPoly &tp = I->get();
+
+ decomp.write[idx].resize(tp.GetNumPoints());
+
+ for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
+ decomp.write[idx].write[i] = tp.GetPoint(i);
+ }
+
+ idx++;
+ }
+
+ return decomp;
+}
+
+struct _AtlasWorkRect {
+ Size2i s;
+ Point2i p;
+ int idx;
+ _FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; };
+};
+
+struct _AtlasWorkRectResult {
+ Vector<_AtlasWorkRect> result;
+ int max_w;
+ int max_h;
+};
+
+void Geometry2D::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) {
+ // Super simple, almost brute force scanline stacking fitter.
+ // It's pretty basic for now, but it tries to make sure that the aspect ratio of the
+ // resulting atlas is somehow square. This is necessary because video cards have limits.
+ // On texture size (usually 2048 or 4096), so the more square a texture, the more chances.
+ // It will work in every hardware.
+ // For example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
+ // 256x8192 atlas (won't work anywhere).
+
+ ERR_FAIL_COND(p_rects.size() == 0);
+
+ Vector<_AtlasWorkRect> wrects;
+ wrects.resize(p_rects.size());
+ for (int i = 0; i < p_rects.size(); i++) {
+ wrects.write[i].s = p_rects[i];
+ wrects.write[i].idx = i;
+ }
+ wrects.sort();
+ int widest = wrects[0].s.width;
+
+ Vector<_AtlasWorkRectResult> results;
+
+ for (int i = 0; i <= 12; i++) {
+ int w = 1 << i;
+ int max_h = 0;
+ int max_w = 0;
+ if (w < widest) {
+ continue;
+ }
+
+ Vector<int> hmax;
+ hmax.resize(w);
+ for (int j = 0; j < w; j++) {
+ hmax.write[j] = 0;
+ }
+
+ // Place them.
+ int ofs = 0;
+ int limit_h = 0;
+ for (int j = 0; j < wrects.size(); j++) {
+ if (ofs + wrects[j].s.width > w) {
+ ofs = 0;
+ }
+
+ int from_y = 0;
+ for (int k = 0; k < wrects[j].s.width; k++) {
+ if (hmax[ofs + k] > from_y) {
+ from_y = hmax[ofs + k];
+ }
+ }
+
+ wrects.write[j].p.x = ofs;
+ wrects.write[j].p.y = from_y;
+ int end_h = from_y + wrects[j].s.height;
+ int end_w = ofs + wrects[j].s.width;
+ if (ofs == 0) {
+ limit_h = end_h;
+ }
+
+ for (int k = 0; k < wrects[j].s.width; k++) {
+ hmax.write[ofs + k] = end_h;
+ }
+
+ if (end_h > max_h) {
+ max_h = end_h;
+ }
+
+ if (end_w > max_w) {
+ max_w = end_w;
+ }
+
+ if (ofs == 0 || end_h > limit_h) { // While h limit not reached, keep stacking.
+ ofs += wrects[j].s.width;
+ }
+ }
+
+ _AtlasWorkRectResult result;
+ result.result = wrects;
+ result.max_h = max_h;
+ result.max_w = max_w;
+ results.push_back(result);
+ }
+
+ // Find the result with the best aspect ratio.
+
+ int best = -1;
+ real_t best_aspect = 1e20;
+
+ for (int i = 0; i < results.size(); i++) {
+ real_t h = next_power_of_2(results[i].max_h);
+ real_t w = next_power_of_2(results[i].max_w);
+ real_t aspect = h > w ? h / w : w / h;
+ if (aspect < best_aspect) {
+ best = i;
+ best_aspect = aspect;
+ }
+ }
+
+ r_result.resize(p_rects.size());
+
+ for (int i = 0; i < p_rects.size(); i++) {
+ r_result.write[results[best].result[i].idx] = results[best].result[i].p;
+ }
+
+ r_size = Size2(results[best].max_w, results[best].max_h);
+}
+
+Vector<Vector<Point2>> Geometry2D::_polypaths_do_operation(PolyBooleanOperation p_op, const Vector<Point2> &p_polypath_a, const Vector<Point2> &p_polypath_b, bool is_a_open) {
+ using namespace ClipperLib;
+
+ ClipType op = ctUnion;
+
+ switch (p_op) {
+ case OPERATION_UNION:
+ op = ctUnion;
+ break;
+ case OPERATION_DIFFERENCE:
+ op = ctDifference;
+ break;
+ case OPERATION_INTERSECTION:
+ op = ctIntersection;
+ break;
+ case OPERATION_XOR:
+ op = ctXor;
+ break;
+ }
+ Path path_a, path_b;
+
+ // Need to scale points (Clipper's requirement for robust computation).
+ for (int i = 0; i != p_polypath_a.size(); ++i) {
+ path_a << IntPoint(p_polypath_a[i].x * SCALE_FACTOR, p_polypath_a[i].y * SCALE_FACTOR);
+ }
+ for (int i = 0; i != p_polypath_b.size(); ++i) {
+ path_b << IntPoint(p_polypath_b[i].x * SCALE_FACTOR, p_polypath_b[i].y * SCALE_FACTOR);
+ }
+ Clipper clp;
+ clp.AddPath(path_a, ptSubject, !is_a_open); // Forward compatible with Clipper 10.0.0.
+ clp.AddPath(path_b, ptClip, true); // Polylines cannot be set as clip.
+
+ Paths paths;
+
+ if (is_a_open) {
+ PolyTree tree; // Needed to populate polylines.
+ clp.Execute(op, tree);
+ OpenPathsFromPolyTree(tree, paths);
+ } else {
+ clp.Execute(op, paths); // Works on closed polygons only.
+ }
+ // Have to scale points down now.
+ Vector<Vector<Point2>> polypaths;
+
+ for (Paths::size_type i = 0; i < paths.size(); ++i) {
+ Vector<Vector2> polypath;
+
+ const Path &scaled_path = paths[i];
+
+ for (Paths::size_type j = 0; j < scaled_path.size(); ++j) {
+ polypath.push_back(Point2(
+ static_cast<real_t>(scaled_path[j].X) / SCALE_FACTOR,
+ static_cast<real_t>(scaled_path[j].Y) / SCALE_FACTOR));
+ }
+ polypaths.push_back(polypath);
+ }
+ return polypaths;
+}
+
+Vector<Vector<Point2>> Geometry2D::_polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
+ using namespace ClipperLib;
+
+ JoinType jt = jtSquare;
+
+ switch (p_join_type) {
+ case JOIN_SQUARE:
+ jt = jtSquare;
+ break;
+ case JOIN_ROUND:
+ jt = jtRound;
+ break;
+ case JOIN_MITER:
+ jt = jtMiter;
+ break;
+ }
+
+ EndType et = etClosedPolygon;
+
+ switch (p_end_type) {
+ case END_POLYGON:
+ et = etClosedPolygon;
+ break;
+ case END_JOINED:
+ et = etClosedLine;
+ break;
+ case END_BUTT:
+ et = etOpenButt;
+ break;
+ case END_SQUARE:
+ et = etOpenSquare;
+ break;
+ case END_ROUND:
+ et = etOpenRound;
+ break;
+ }
+ ClipperOffset co(2.0, 0.25 * SCALE_FACTOR); // Defaults from ClipperOffset.
+ Path path;
+
+ // Need to scale points (Clipper's requirement for robust computation).
+ for (int i = 0; i != p_polypath.size(); ++i) {
+ path << IntPoint(p_polypath[i].x * SCALE_FACTOR, p_polypath[i].y * SCALE_FACTOR);
+ }
+ co.AddPath(path, jt, et);
+
+ Paths paths;
+ co.Execute(paths, p_delta * SCALE_FACTOR); // Inflate/deflate.
+
+ // Have to scale points down now.
+ Vector<Vector<Point2>> polypaths;
+
+ for (Paths::size_type i = 0; i < paths.size(); ++i) {
+ Vector<Vector2> polypath;
+
+ const Path &scaled_path = paths[i];
+
+ for (Paths::size_type j = 0; j < scaled_path.size(); ++j) {
+ polypath.push_back(Point2(
+ static_cast<real_t>(scaled_path[j].X) / SCALE_FACTOR,
+ static_cast<real_t>(scaled_path[j].Y) / SCALE_FACTOR));
+ }
+ polypaths.push_back(polypath);
+ }
+ return polypaths;
+}
+
+Vector<Point2i> Geometry2D::pack_rects(const Vector<Size2i> &p_sizes, const Size2i &p_atlas_size) {
+ Vector<stbrp_node> nodes;
+ nodes.resize(p_atlas_size.width);
+
+ stbrp_context context;
+ stbrp_init_target(&context, p_atlas_size.width, p_atlas_size.height, nodes.ptrw(), p_atlas_size.width);
+
+ Vector<stbrp_rect> rects;
+ rects.resize(p_sizes.size());
+
+ for (int i = 0; i < p_sizes.size(); i++) {
+ rects.write[i].id = 0;
+ rects.write[i].w = p_sizes[i].width;
+ rects.write[i].h = p_sizes[i].height;
+ rects.write[i].x = 0;
+ rects.write[i].y = 0;
+ rects.write[i].was_packed = 0;
+ }
+
+ int res = stbrp_pack_rects(&context, rects.ptrw(), rects.size());
+ if (res == 0) { //pack failed
+ return Vector<Point2i>();
+ }
+
+ Vector<Point2i> ret;
+ ret.resize(p_sizes.size());
+
+ for (int i = 0; i < p_sizes.size(); i++) {
+ Point2i r(rects[i].x, rects[i].y);
+ ret.write[i] = r;
+ }
+
+ return ret;
+}
+
+Vector<Vector3i> Geometry2D::partial_pack_rects(const Vector<Vector2i> &p_sizes, const Size2i &p_atlas_size) {
+ Vector<stbrp_node> nodes;
+ nodes.resize(p_atlas_size.width);
+ zeromem(nodes.ptrw(), sizeof(stbrp_node) * nodes.size());
+
+ stbrp_context context;
+ stbrp_init_target(&context, p_atlas_size.width, p_atlas_size.height, nodes.ptrw(), p_atlas_size.width);
+
+ Vector<stbrp_rect> rects;
+ rects.resize(p_sizes.size());
+
+ for (int i = 0; i < p_sizes.size(); i++) {
+ rects.write[i].id = i;
+ rects.write[i].w = p_sizes[i].width;
+ rects.write[i].h = p_sizes[i].height;
+ rects.write[i].x = 0;
+ rects.write[i].y = 0;
+ rects.write[i].was_packed = 0;
+ }
+
+ stbrp_pack_rects(&context, rects.ptrw(), rects.size());
+
+ Vector<Vector3i> ret;
+ ret.resize(p_sizes.size());
+
+ for (int i = 0; i < p_sizes.size(); i++) {
+ ret.write[rects[i].id] = Vector3i(rects[i].x, rects[i].y, rects[i].was_packed != 0 ? 1 : 0);
+ }
+
+ return ret;
+}
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
new file mode 100644
index 0000000000..cfd7abfacb
--- /dev/null
+++ b/core/math/geometry_2d.h
@@ -0,0 +1,398 @@
+/*************************************************************************/
+/* geometry_2d.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 GEOMETRY_2D_H
+#define GEOMETRY_2D_H
+
+#include "core/math/delaunay_2d.h"
+#include "core/math/rect2.h"
+#include "core/math/triangulate.h"
+#include "core/object.h"
+#include "core/vector.h"
+
+class Geometry2D {
+ Geometry2D();
+
+public:
+ static real_t get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2, Vector2 &c1, Vector2 &c2) {
+ Vector2 d1 = q1 - p1; // Direction vector of segment S1.
+ Vector2 d2 = q2 - p2; // Direction vector of segment S2.
+ Vector2 r = p1 - p2;
+ real_t a = d1.dot(d1); // Squared length of segment S1, always nonnegative.
+ real_t e = d2.dot(d2); // Squared length of segment S2, always nonnegative.
+ real_t f = d2.dot(r);
+ real_t s, t;
+ // Check if either or both segments degenerate into points.
+ if (a <= CMP_EPSILON && e <= CMP_EPSILON) {
+ // Both segments degenerate into points.
+ c1 = p1;
+ c2 = p2;
+ return Math::sqrt((c1 - c2).dot(c1 - c2));
+ }
+ if (a <= CMP_EPSILON) {
+ // First segment degenerates into a point.
+ s = 0.0;
+ t = f / e; // s = 0 => t = (b*s + f) / e = f / e
+ t = CLAMP(t, 0.0, 1.0);
+ } else {
+ real_t c = d1.dot(r);
+ if (e <= CMP_EPSILON) {
+ // Second segment degenerates into a point.
+ t = 0.0;
+ s = CLAMP(-c / a, 0.0, 1.0); // t = 0 => s = (b*t - c) / a = -c / a
+ } else {
+ // The general nondegenerate case starts here.
+ real_t b = d1.dot(d2);
+ real_t denom = a * e - b * b; // Always nonnegative.
+ // If segments not parallel, compute closest point on L1 to L2 and
+ // clamp to segment S1. Else pick arbitrary s (here 0).
+ if (denom != 0.0) {
+ s = CLAMP((b * f - c * e) / denom, 0.0, 1.0);
+ } else {
+ s = 0.0;
+ }
+ // Compute point on L2 closest to S1(s) using
+ // t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
+ t = (b * s + f) / e;
+
+ //If t in [0,1] done. Else clamp t, recompute s for the new value
+ // of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
+ // and clamp s to [0, 1].
+ if (t < 0.0) {
+ t = 0.0;
+ s = CLAMP(-c / a, 0.0, 1.0);
+ } else if (t > 1.0) {
+ t = 1.0;
+ s = CLAMP((b - c) / a, 0.0, 1.0);
+ }
+ }
+ }
+ c1 = p1 + d1 * s;
+ c2 = p2 + d2 * t;
+ return Math::sqrt((c1 - c2).dot(c1 - c2));
+ }
+
+ static Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 *p_segment) {
+ Vector2 p = p_point - p_segment[0];
+ Vector2 n = p_segment[1] - p_segment[0];
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20) {
+ return p_segment[0]; // Both points are the same, just give any.
+ }
+
+ real_t d = n.dot(p) / l2;
+
+ if (d <= 0.0) {
+ return p_segment[0]; // Before first point.
+ } else if (d >= 1.0) {
+ return p_segment[1]; // After first point.
+ } else {
+ return p_segment[0] + n * d; // Inside.
+ }
+ }
+
+ static bool is_point_in_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) {
+ Vector2 an = a - s;
+ Vector2 bn = b - s;
+ Vector2 cn = c - s;
+
+ bool orientation = an.cross(bn) > 0;
+
+ if ((bn.cross(cn) > 0) != orientation) {
+ return false;
+ }
+
+ return (cn.cross(an) > 0) == orientation;
+ }
+
+ static Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 *p_segment) {
+ Vector2 p = p_point - p_segment[0];
+ Vector2 n = p_segment[1] - p_segment[0];
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20) {
+ return p_segment[0]; // Both points are the same, just give any.
+ }
+
+ real_t d = n.dot(p) / l2;
+
+ return p_segment[0] + n * d; // Inside.
+ }
+
+ static bool line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b, Vector2 &r_result) {
+ // See http://paulbourke.net/geometry/pointlineplane/
+
+ const real_t denom = p_dir_b.y * p_dir_a.x - p_dir_b.x * p_dir_a.y;
+ if (Math::is_zero_approx(denom)) { // Parallel?
+ return false;
+ }
+
+ const Vector2 v = p_from_a - p_from_b;
+ const real_t t = (p_dir_b.x * v.y - p_dir_b.y * v.x) / denom;
+ r_result = p_from_a + t * p_dir_a;
+ return true;
+ }
+
+ static bool segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b, Vector2 *r_result) {
+ Vector2 B = p_to_a - p_from_a;
+ Vector2 C = p_from_b - p_from_a;
+ Vector2 D = p_to_b - p_from_a;
+
+ real_t ABlen = B.dot(B);
+ if (ABlen <= 0) {
+ return false;
+ }
+ Vector2 Bn = B / ABlen;
+ C = Vector2(C.x * Bn.x + C.y * Bn.y, C.y * Bn.x - C.x * Bn.y);
+ D = Vector2(D.x * Bn.x + D.y * Bn.y, D.y * Bn.x - D.x * Bn.y);
+
+ if ((C.y < 0 && D.y < 0) || (C.y >= 0 && D.y >= 0)) {
+ return false;
+ }
+
+ real_t ABpos = D.x + (C.x - D.x) * D.y / (D.y - C.y);
+
+ // Fail if segment C-D crosses line A-B outside of segment A-B.
+ if (ABpos < 0 || ABpos > 1.0) {
+ return false;
+ }
+
+ // (4) Apply the discovered position to line A-B in the original coordinate system.
+ if (r_result) {
+ *r_result = p_from_a + B * ABpos;
+ }
+
+ return true;
+ }
+
+ static inline bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+ return p_point.distance_squared_to(p_circle_pos) <= p_circle_radius * p_circle_radius;
+ }
+
+ static real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+ Vector2 line_vec = p_to - p_from;
+ Vector2 vec_to_line = p_from - p_circle_pos;
+
+ // Create a quadratic formula of the form ax^2 + bx + c = 0
+ real_t a, b, c;
+
+ a = line_vec.dot(line_vec);
+ b = 2 * vec_to_line.dot(line_vec);
+ c = vec_to_line.dot(vec_to_line) - p_circle_radius * p_circle_radius;
+
+ // Solve for t.
+ real_t sqrtterm = b * b - 4 * a * c;
+
+ // If the term we intend to square root is less than 0 then the answer won't be real,
+ // so it definitely won't be t in the range 0 to 1.
+ if (sqrtterm < 0) {
+ return -1;
+ }
+
+ // If we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection)
+ // then the following can be skipped and we can just return the equivalent of res1.
+ sqrtterm = Math::sqrt(sqrtterm);
+ real_t res1 = (-b - sqrtterm) / (2 * a);
+ real_t res2 = (-b + sqrtterm) / (2 * a);
+
+ if (res1 >= 0 && res1 <= 1) {
+ return res1;
+ }
+ if (res2 >= 0 && res2 <= 1) {
+ return res2;
+ }
+ return -1;
+ }
+
+ enum PolyBooleanOperation {
+ OPERATION_UNION,
+ OPERATION_DIFFERENCE,
+ OPERATION_INTERSECTION,
+ OPERATION_XOR
+ };
+ enum PolyJoinType {
+ JOIN_SQUARE,
+ JOIN_ROUND,
+ JOIN_MITER
+ };
+ enum PolyEndType {
+ END_POLYGON,
+ END_JOINED,
+ END_BUTT,
+ END_SQUARE,
+ END_ROUND
+ };
+
+ static Vector<Vector<Point2>> merge_polygons(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
+ return _polypaths_do_operation(OPERATION_UNION, p_polygon_a, p_polygon_b);
+ }
+
+ static Vector<Vector<Point2>> clip_polygons(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
+ return _polypaths_do_operation(OPERATION_DIFFERENCE, p_polygon_a, p_polygon_b);
+ }
+
+ static Vector<Vector<Point2>> intersect_polygons(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
+ return _polypaths_do_operation(OPERATION_INTERSECTION, p_polygon_a, p_polygon_b);
+ }
+
+ static Vector<Vector<Point2>> exclude_polygons(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
+ return _polypaths_do_operation(OPERATION_XOR, p_polygon_a, p_polygon_b);
+ }
+
+ static Vector<Vector<Point2>> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
+ return _polypaths_do_operation(OPERATION_DIFFERENCE, p_polyline, p_polygon, true);
+ }
+
+ static Vector<Vector<Point2>> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
+ return _polypaths_do_operation(OPERATION_INTERSECTION, p_polyline, p_polygon, true);
+ }
+
+ static Vector<Vector<Point2>> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
+ return _polypath_offset(p_polygon, p_delta, p_join_type, END_POLYGON);
+ }
+
+ static Vector<Vector<Point2>> offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
+ ERR_FAIL_COND_V_MSG(p_end_type == END_POLYGON, Vector<Vector<Point2>>(), "Attempt to offset a polyline like a polygon (use offset_polygon instead).");
+
+ return _polypath_offset(p_polygon, p_delta, p_join_type, p_end_type);
+ }
+
+ static Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points) {
+ Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(p_points);
+ Vector<int> triangles;
+
+ for (int i = 0; i < tr.size(); i++) {
+ triangles.push_back(tr[i].points[0]);
+ triangles.push_back(tr[i].points[1]);
+ triangles.push_back(tr[i].points[2]);
+ }
+ return triangles;
+ }
+
+ static Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon) {
+ Vector<int> triangles;
+ if (!Triangulate::triangulate(p_polygon, triangles)) {
+ return Vector<int>(); //fail
+ }
+ return triangles;
+ }
+
+ static bool is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
+ int c = p_polygon.size();
+ if (c < 3) {
+ return false;
+ }
+ const Vector2 *p = p_polygon.ptr();
+ real_t sum = 0;
+ for (int i = 0; i < c; i++) {
+ const Vector2 &v1 = p[i];
+ const Vector2 &v2 = p[(i + 1) % c];
+ sum += (v2.x - v1.x) * (v2.y + v1.y);
+ }
+
+ return sum > 0.0f;
+ }
+
+ // Alternate implementation that should be faster.
+ static bool is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) {
+ int c = p_polygon.size();
+ if (c < 3) {
+ return false;
+ }
+ const Vector2 *p = p_polygon.ptr();
+ Vector2 further_away(-1e20, -1e20);
+ Vector2 further_away_opposite(1e20, 1e20);
+
+ for (int i = 0; i < c; i++) {
+ further_away.x = MAX(p[i].x, further_away.x);
+ further_away.y = MAX(p[i].y, further_away.y);
+ further_away_opposite.x = MIN(p[i].x, further_away_opposite.x);
+ further_away_opposite.y = MIN(p[i].y, further_away_opposite.y);
+ }
+
+ // Make point outside that won't intersect with points in segment from p_point.
+ further_away += (further_away - further_away_opposite) * Vector2(1.221313, 1.512312);
+
+ int intersections = 0;
+ for (int i = 0; i < c; i++) {
+ const Vector2 &v1 = p[i];
+ const Vector2 &v2 = p[(i + 1) % c];
+ if (segment_intersects_segment(v1, v2, p_point, further_away, nullptr)) {
+ intersections++;
+ }
+ }
+
+ return (intersections & 1);
+ }
+
+ static real_t vec2_cross(const Point2 &O, const Point2 &A, const Point2 &B) {
+ return (real_t)(A.x - O.x) * (B.y - O.y) - (real_t)(A.y - O.y) * (B.x - O.x);
+ }
+
+ // Returns a list of points on the convex hull in counter-clockwise order.
+ // Note: the last point in the returned list is the same as the first one.
+ static Vector<Point2> convex_hull(Vector<Point2> P) {
+ int n = P.size(), k = 0;
+ Vector<Point2> H;
+ H.resize(2 * n);
+
+ // Sort points lexicographically.
+ P.sort();
+
+ // Build lower hull.
+ for (int i = 0; i < n; ++i) {
+ while (k >= 2 && vec2_cross(H[k - 2], H[k - 1], P[i]) <= 0) {
+ k--;
+ }
+ H.write[k++] = P[i];
+ }
+
+ // Build upper hull.
+ for (int i = n - 2, t = k + 1; i >= 0; i--) {
+ while (k >= t && vec2_cross(H[k - 2], H[k - 1], P[i]) <= 0) {
+ k--;
+ }
+ H.write[k++] = P[i];
+ }
+
+ H.resize(k);
+ return H;
+ }
+ static Vector<Vector<Vector2>> decompose_polygon_in_convex(Vector<Point2> polygon);
+
+ static void make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size);
+ static Vector<Point2i> pack_rects(const Vector<Size2i> &p_sizes, const Size2i &p_atlas_size);
+ static Vector<Vector3i> partial_pack_rects(const Vector<Vector2i> &p_sizes, const Size2i &p_atlas_size);
+
+private:
+ static Vector<Vector<Point2>> _polypaths_do_operation(PolyBooleanOperation p_op, const Vector<Point2> &p_polypath_a, const Vector<Point2> &p_polypath_b, bool is_a_open = false);
+ static Vector<Vector<Point2>> _polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type);
+};
+
+#endif // GEOMETRY_2D_H
diff --git a/core/math/geometry.cpp b/core/math/geometry_3d.cpp
index b0a46036f9..3b30f4b1fe 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry_3d.cpp
@@ -28,39 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "geometry.h"
+#include "geometry_3d.h"
#include "core/print_string.h"
#include "thirdparty/misc/clipper.hpp"
#include "thirdparty/misc/triangulator.h"
-#define STB_RECT_PACK_IMPLEMENTATION
-#include "thirdparty/misc/stb_rect_pack.h"
-
-#define SCALE_FACTOR 100000.0 // Based on CMP_EPSILON.
-
-// This implementation is very inefficient, commenting unless bugs happen. See the other one.
-/*
-bool Geometry::is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) {
-
- Vector<int> indices = Geometry::triangulate_polygon(p_polygon);
- for (int j = 0; j + 3 <= indices.size(); j += 3) {
- int i1 = indices[j], i2 = indices[j + 1], i3 = indices[j + 2];
- if (Geometry::is_point_in_triangle(p_point, p_polygon[i1], p_polygon[i2], p_polygon[i3]))
- return true;
- }
- return false;
-}
-*/
-
-void Geometry::MeshData::optimize_vertices() {
+void Geometry3D::MeshData::optimize_vertices() {
Map<int, int> vtx_remap;
for (int i = 0; i < faces.size(); i++) {
-
for (int j = 0; j < faces[i].indices.size(); j++) {
-
int idx = faces[i].indices[j];
if (!vtx_remap.has(idx)) {
int ni = vtx_remap.size();
@@ -72,7 +51,6 @@ void Geometry::MeshData::optimize_vertices() {
}
for (int i = 0; i < edges.size(); i++) {
-
int a = edges[i].a;
int b = edges[i].b;
@@ -93,36 +71,28 @@ void Geometry::MeshData::optimize_vertices() {
new_vertices.resize(vtx_remap.size());
for (int i = 0; i < vertices.size(); i++) {
-
- if (vtx_remap.has(i))
+ if (vtx_remap.has(i)) {
new_vertices.write[vtx_remap[i]] = vertices[i];
+ }
}
vertices = new_vertices;
}
struct _FaceClassify {
-
struct _Link {
-
- int face;
- int edge;
+ int face = -1;
+ int edge = -1;
void clear() {
face = -1;
edge = -1;
}
- _Link() {
- face = -1;
- edge = -1;
- }
+ _Link() {}
};
- bool valid;
- int group;
+ bool valid = false;
+ int group = -1;
_Link links[3];
Face3 face;
- _FaceClassify() {
- group = -1;
- valid = false;
- };
+ _FaceClassify() {}
};
static bool _connect_faces(_FaceClassify *p_faces, int len, int p_group) {
@@ -132,42 +102,36 @@ static bool _connect_faces(_FaceClassify *p_faces, int len, int p_group) {
bool error = false;
for (int i = 0; i < len; i++) {
-
for (int j = 0; j < 3; j++) {
-
p_faces[i].links[j].clear();
}
}
for (int i = 0; i < len; i++) {
-
- if (p_faces[i].group != p_group)
+ if (p_faces[i].group != p_group) {
continue;
+ }
for (int j = i + 1; j < len; j++) {
-
- if (p_faces[j].group != p_group)
+ if (p_faces[j].group != p_group) {
continue;
+ }
for (int k = 0; k < 3; k++) {
-
Vector3 vi1 = p_faces[i].face.vertex[k];
Vector3 vi2 = p_faces[i].face.vertex[(k + 1) % 3];
for (int l = 0; l < 3; l++) {
-
Vector3 vj2 = p_faces[j].face.vertex[l];
Vector3 vj1 = p_faces[j].face.vertex[(l + 1) % 3];
if (vi1.distance_to(vj1) < 0.00001 &&
vi2.distance_to(vj2) < 0.00001) {
if (p_faces[i].links[k].face != -1) {
-
ERR_PRINT("already linked\n");
error = true;
break;
}
if (p_faces[j].links[l].face != -1) {
-
ERR_PRINT("already linked\n");
error = true;
break;
@@ -179,37 +143,38 @@ static bool _connect_faces(_FaceClassify *p_faces, int len, int p_group) {
p_faces[j].links[l].edge = k;
}
}
- if (error)
+ if (error) {
break;
+ }
}
- if (error)
+ if (error) {
break;
+ }
}
- if (error)
+ if (error) {
break;
+ }
}
for (int i = 0; i < len; i++) {
-
p_faces[i].valid = true;
for (int j = 0; j < 3; j++) {
-
- if (p_faces[i].links[j].face == -1)
+ if (p_faces[i].links[j].face == -1) {
p_faces[i].valid = false;
+ }
}
}
return error;
}
static bool _group_face(_FaceClassify *p_faces, int len, int p_index, int p_group) {
-
- if (p_faces[p_index].group >= 0)
+ if (p_faces[p_index].group >= 0) {
return false;
+ }
p_faces[p_index].group = p_group;
for (int i = 0; i < 3; i++) {
-
ERR_FAIL_INDEX_V(p_faces[p_index].links[i].face, len, true);
_group_face(p_faces, len, p_faces[p_index].links[i].face, p_group);
}
@@ -217,8 +182,7 @@ static bool _group_face(_FaceClassify *p_faces, int len, int p_index, int p_grou
return true;
}
-Vector<Vector<Face3>> Geometry::separate_objects(Vector<Face3> p_array) {
-
+Vector<Vector<Face3>> Geometry3D::separate_objects(Vector<Face3> p_array) {
Vector<Vector<Face3>> objects;
int len = p_array.size();
@@ -232,7 +196,6 @@ Vector<Vector<Face3>> Geometry::separate_objects(Vector<Face3> p_array) {
_FaceClassify *_fcptr = fc.ptrw();
for (int i = 0; i < len; i++) {
-
_fcptr[i].face = arrayptr[i];
}
@@ -244,9 +207,9 @@ Vector<Vector<Face3>> Geometry::separate_objects(Vector<Face3> p_array) {
int group = 0;
for (int i = 0; i < len; i++) {
-
- if (!_fcptr[i].valid)
+ if (!_fcptr[i].valid) {
continue;
+ }
if (_group_face(_fcptr, len, i, group)) {
group++;
}
@@ -255,20 +218,18 @@ Vector<Vector<Face3>> Geometry::separate_objects(Vector<Face3> p_array) {
// Group connected faces in separate objects.
for (int i = 0; i < len; i++) {
-
_fcptr[i].face = arrayptr[i];
}
if (group >= 0) {
-
objects.resize(group);
Vector<Face3> *group_faces = objects.ptrw();
for (int i = 0; i < len; i++) {
- if (!_fcptr[i].valid)
+ if (!_fcptr[i].valid) {
continue;
+ }
if (_fcptr[i].group >= 0 && _fcptr[i].group < group) {
-
group_faces[_fcptr[i].group].push_back(_fcptr[i].face);
}
}
@@ -305,16 +266,15 @@ enum _CellFlags {
};
static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) {
-
AABB aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
aabb.position = aabb.position * voxelsize;
aabb.size = aabb.size * voxelsize;
- if (!p_face.intersects_aabb(aabb))
+ if (!p_face.intersects_aabb(aabb)) {
return;
+ }
if (len_x == 1 && len_y == 1 && len_z == 1) {
-
p_cell_status[x][y][z] = _CELL_SOLID;
return;
}
@@ -343,15 +303,12 @@ static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int
int new_len_z;
for (int i = 0; i < div_x; i++) {
-
_SPLIT(i, div_x, x, len_x, new_x, new_len_x);
for (int j = 0; j < div_y; j++) {
-
_SPLIT(j, div_y, y, len_y, new_y, new_len_y);
for (int k = 0; k < div_z; k++) {
-
_SPLIT(k, div_z, z, len_z, new_z, new_len_z);
_plot_face(p_cell_status, new_x, new_y, new_z, new_len_x, new_len_y, new_len_z, voxelsize, p_face);
@@ -361,14 +318,13 @@ static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int
}
static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z) {
-
- if (p_cell_status[x][y][z] & 3)
+ if (p_cell_status[x][y][z] & 3) {
return; // Nothing to do, already used and/or visited.
+ }
p_cell_status[x][y][z] = _CELL_PREV_FIRST;
while (true) {
-
uint8_t &c = p_cell_status[x][y][z];
if ((c & _CELL_STEP_MASK) == _CELL_STEP_NONE) {
@@ -422,9 +378,7 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
uint8_t prev = 0;
switch (c & _CELL_STEP_MASK) {
-
case _CELL_STEP_Y_POS: {
-
next_y++;
prev = _CELL_PREV_Y_NEG;
} break;
@@ -452,15 +406,19 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
ERR_FAIL();
}
- if (next_x < 0 || next_x >= len_x)
+ if (next_x < 0 || next_x >= len_x) {
continue;
- if (next_y < 0 || next_y >= len_y)
+ }
+ if (next_y < 0 || next_y >= len_y) {
continue;
- if (next_z < 0 || next_z >= len_z)
+ }
+ if (next_z < 0 || next_z >= len_z) {
continue;
+ }
- if (p_cell_status[next_x][next_y][next_z] & 3)
+ if (p_cell_status[next_x][next_y][next_z] & 3) {
continue;
+ }
x = next_x;
y = next_y;
@@ -470,13 +428,13 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
}
static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, Vector<Face3> &p_faces) {
-
ERR_FAIL_INDEX(x, len_x);
ERR_FAIL_INDEX(y, len_y);
ERR_FAIL_INDEX(z, len_z);
- if (p_cell_status[x][y][z] & _CELL_EXTERIOR)
+ if (p_cell_status[x][y][z] & _CELL_EXTERIOR) {
return;
+ }
#define vert(m_idx) Vector3(((m_idx)&4) >> 2, ((m_idx)&2) >> 1, (m_idx)&1)
@@ -491,7 +449,6 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
};
for (int i = 0; i < 6; i++) {
-
Vector3 face_points[4];
int disp_x = x + ((i % 3) == 0 ? ((i < 3) ? 1 : -1) : 0);
int disp_y = y + (((i - 1) % 3) == 0 ? ((i < 3) ? 1 : -1) : 0);
@@ -499,21 +456,27 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
bool plot = false;
- if (disp_x < 0 || disp_x >= len_x)
+ if (disp_x < 0 || disp_x >= len_x) {
plot = true;
- if (disp_y < 0 || disp_y >= len_y)
+ }
+ if (disp_y < 0 || disp_y >= len_y) {
plot = true;
- if (disp_z < 0 || disp_z >= len_z)
+ }
+ if (disp_z < 0 || disp_z >= len_z) {
plot = true;
+ }
- if (!plot && (p_cell_status[disp_x][disp_y][disp_z] & _CELL_EXTERIOR))
+ if (!plot && (p_cell_status[disp_x][disp_y][disp_z] & _CELL_EXTERIOR)) {
plot = true;
+ }
- if (!plot)
+ if (!plot) {
continue;
+ }
- for (int j = 0; j < 4; j++)
+ for (int j = 0; j < 4; j++) {
face_points[j] = vert(indices[i][j]) + Vector3(x, y, z);
+ }
p_faces.push_back(
Face3(
@@ -529,8 +492,7 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
}
}
-Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
-
+Vector<Face3> Geometry3D::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
#define _MIN_SIZE 1.0
#define _MAX_LENGTH 20
@@ -540,12 +502,9 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
AABB global_aabb;
for (int i = 0; i < face_count; i++) {
-
if (i == 0) {
-
global_aabb = faces[i].get_aabb();
} else {
-
global_aabb.merge_with(faces[i].get_aabb());
}
}
@@ -555,20 +514,23 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
// Determine amount of cells in grid axis.
int div_x, div_y, div_z;
- if (global_aabb.size.x / _MIN_SIZE < _MAX_LENGTH)
+ if (global_aabb.size.x / _MIN_SIZE < _MAX_LENGTH) {
div_x = (int)(global_aabb.size.x / _MIN_SIZE) + 1;
- else
+ } else {
div_x = _MAX_LENGTH;
+ }
- if (global_aabb.size.y / _MIN_SIZE < _MAX_LENGTH)
+ if (global_aabb.size.y / _MIN_SIZE < _MAX_LENGTH) {
div_y = (int)(global_aabb.size.y / _MIN_SIZE) + 1;
- else
+ } else {
div_y = _MAX_LENGTH;
+ }
- if (global_aabb.size.z / _MIN_SIZE < _MAX_LENGTH)
+ if (global_aabb.size.z / _MIN_SIZE < _MAX_LENGTH) {
div_z = (int)(global_aabb.size.z / _MIN_SIZE) + 1;
- else
+ } else {
div_z = _MAX_LENGTH;
+ }
Vector3 voxelsize = global_aabb.size;
voxelsize.x /= div_x;
@@ -579,15 +541,12 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
uint8_t ***cell_status = memnew_arr(uint8_t **, div_x);
for (int i = 0; i < div_x; i++) {
-
cell_status[i] = memnew_arr(uint8_t *, div_y);
for (int j = 0; j < div_y; j++) {
-
cell_status[i][j] = memnew_arr(uint8_t, div_z);
for (int k = 0; k < div_z; k++) {
-
cell_status[i][j][k] = 0;
}
}
@@ -596,10 +555,8 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
// Plot faces into cells.
for (int i = 0; i < face_count; i++) {
-
Face3 f = faces[i];
for (int j = 0; j < 3; j++) {
-
f.vertex[j] -= global_aabb.position;
}
_plot_face(cell_status, 0, 0, 0, div_x, div_y, div_z, voxelsize, f);
@@ -608,27 +565,21 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
// Determine which cells connect to the outside by traversing the outside and recursively flood-fill marking.
for (int i = 0; i < div_x; i++) {
-
for (int j = 0; j < div_y; j++) {
-
_mark_outside(cell_status, i, j, 0, div_x, div_y, div_z);
_mark_outside(cell_status, i, j, div_z - 1, div_x, div_y, div_z);
}
}
for (int i = 0; i < div_z; i++) {
-
for (int j = 0; j < div_y; j++) {
-
_mark_outside(cell_status, 0, j, i, div_x, div_y, div_z);
_mark_outside(cell_status, div_x - 1, j, i, div_x, div_y, div_z);
}
}
for (int i = 0; i < div_x; i++) {
-
for (int j = 0; j < div_z; j++) {
-
_mark_outside(cell_status, i, 0, j, div_x, div_y, div_z);
_mark_outside(cell_status, i, div_y - 1, j, div_x, div_y, div_z);
}
@@ -639,11 +590,8 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
Vector<Face3> wrapped_faces;
for (int i = 0; i < div_x; i++) {
-
for (int j = 0; j < div_y; j++) {
-
for (int k = 0; k < div_z; k++) {
-
_build_faces(cell_status, i, j, k, div_x, div_y, div_z, wrapped_faces);
}
}
@@ -655,9 +603,7 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
Face3 *wrapped_faces_ptr = wrapped_faces.ptrw();
for (int i = 0; i < wrapped_faces_count; i++) {
-
for (int j = 0; j < 3; j++) {
-
Vector3 &v = wrapped_faces_ptr[i].vertex[j];
v = v * voxelsize;
v += global_aabb.position;
@@ -667,9 +613,7 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
// clean up grid
for (int i = 0; i < div_x; i++) {
-
for (int j = 0; j < div_y; j++) {
-
memdelete_arr(cell_status[i][j]);
}
@@ -677,61 +621,27 @@ Vector<Face3> Geometry::wrap_geometry(Vector<Face3> p_array, real_t *p_error) {
}
memdelete_arr(cell_status);
- if (p_error)
+ if (p_error) {
*p_error = voxelsize.length();
-
- return wrapped_faces;
-}
-
-Vector<Vector<Vector2>> Geometry::decompose_polygon_in_convex(Vector<Point2> polygon) {
- Vector<Vector<Vector2>> decomp;
- List<TriangulatorPoly> in_poly, out_poly;
-
- TriangulatorPoly inp;
- inp.Init(polygon.size());
- for (int i = 0; i < polygon.size(); i++) {
- inp.GetPoint(i) = polygon[i];
- }
- inp.SetOrientation(TRIANGULATOR_CCW);
- in_poly.push_back(inp);
- TriangulatorPartition tpart;
- if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { // Failed.
- ERR_PRINT("Convex decomposing failed!");
- return decomp;
- }
-
- decomp.resize(out_poly.size());
- int idx = 0;
- for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
- TriangulatorPoly &tp = I->get();
-
- decomp.write[idx].resize(tp.GetNumPoints());
-
- for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
- decomp.write[idx].write[i] = tp.GetPoint(i);
- }
-
- idx++;
}
- return decomp;
+ return wrapped_faces;
}
-Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
-
+Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes) {
MeshData mesh;
#define SUBPLANE_SIZE 1024.0
real_t subplane_size = 1024.0; // Should compute this from the actual plane.
for (int i = 0; i < p_planes.size(); i++) {
-
Plane p = p_planes[i];
Vector3 ref = Vector3(0.0, 1.0, 0.0);
- if (ABS(p.normal.dot(ref)) > 0.95)
+ if (ABS(p.normal.dot(ref)) > 0.95) {
ref = Vector3(0.0, 0.0, 1.0); // Change axis.
+ }
Vector3 right = p.normal.cross(ref).normalized();
Vector3 up = p.normal.cross(right).normalized();
@@ -746,21 +656,22 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
vertices.push_back(center + up * subplane_size + right * subplane_size);
for (int j = 0; j < p_planes.size(); j++) {
-
- if (j == i)
+ if (j == i) {
continue;
+ }
Vector<Vector3> new_vertices;
Plane clip = p_planes[j];
- if (clip.normal.dot(p.normal) > 0.95)
+ if (clip.normal.dot(p.normal) > 0.95) {
continue;
+ }
- if (vertices.size() < 3)
+ if (vertices.size() < 3) {
break;
+ }
for (int k = 0; k < vertices.size(); k++) {
-
int k_n = (k + 1) % vertices.size();
Vector3 edge0_A = vertices[k];
@@ -776,13 +687,13 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
// Check for different sides and non coplanar.
if ((dist0 * dist1) < 0) {
-
// Calculate intersection.
Vector3 rel = edge1_A - edge0_A;
real_t den = clip.normal.dot(rel);
- if (Math::is_zero_approx(den))
+ if (Math::is_zero_approx(den)) {
continue; // Point too short.
+ }
real_t dist = -(clip.normal.dot(edge0_A) - clip.d) / den;
Vector3 inters = edge0_A + rel * dist;
@@ -793,8 +704,9 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
vertices = new_vertices;
}
- if (vertices.size() < 3)
+ if (vertices.size() < 3) {
continue;
+ }
// Result is a clockwise face.
@@ -802,19 +714,15 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
// Add face indices.
for (int j = 0; j < vertices.size(); j++) {
-
int idx = -1;
for (int k = 0; k < mesh.vertices.size(); k++) {
-
if (mesh.vertices[k].distance_to(vertices[j]) < 0.001) {
-
idx = k;
break;
}
}
if (idx == -1) {
-
idx = mesh.vertices.size();
mesh.vertices.push_back(vertices[j]);
}
@@ -827,13 +735,11 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
// Add edge.
for (int j = 0; j < face.indices.size(); j++) {
-
int a = face.indices[j];
int b = face.indices[(j + 1) % face.indices.size()];
bool found = false;
for (int k = 0; k < mesh.edges.size(); k++) {
-
if (mesh.edges[k].a == a && mesh.edges[k].b == b) {
found = true;
break;
@@ -844,8 +750,9 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
}
}
- if (found)
+ if (found) {
continue;
+ }
MeshData::Edge edge;
edge.a = a;
edge.b = b;
@@ -856,8 +763,7 @@ Geometry::MeshData Geometry::build_convex_mesh(const Vector<Plane> &p_planes) {
return mesh;
}
-Vector<Plane> Geometry::build_box_planes(const Vector3 &p_extents) {
-
+Vector<Plane> Geometry3D::build_box_planes(const Vector3 &p_extents) {
Vector<Plane> planes;
planes.push_back(Plane(Vector3(1, 0, 0), p_extents.x));
@@ -870,12 +776,10 @@ Vector<Plane> Geometry::build_box_planes(const Vector3 &p_extents) {
return planes;
}
-Vector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
-
+Vector<Plane> Geometry3D::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
Vector<Plane> planes;
for (int i = 0; i < p_sides; i++) {
-
Vector3 normal;
normal[(p_axis + 1) % 3] = Math::cos(i * (2.0 * Math_PI) / p_sides);
normal[(p_axis + 2) % 3] = Math::sin(i * (2.0 * Math_PI) / p_sides);
@@ -892,8 +796,7 @@ Vector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_height,
return planes;
}
-Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
-
+Vector<Plane> Geometry3D::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
Vector<Plane> planes;
Vector3 axis;
@@ -905,7 +808,6 @@ Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_l
axis_neg[p_axis] = -1.0;
for (int i = 0; i < p_lons; i++) {
-
Vector3 normal;
normal[(p_axis + 1) % 3] = Math::cos(i * (2.0 * Math_PI) / p_lons);
normal[(p_axis + 2) % 3] = Math::sin(i * (2.0 * Math_PI) / p_lons);
@@ -913,7 +815,6 @@ Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_l
planes.push_back(Plane(normal, p_radius));
for (int j = 1; j <= p_lats; j++) {
-
// FIXME: This is stupid.
Vector3 angle = normal.lerp(axis, j / (real_t)p_lats).normalized();
Vector3 pos = angle * p_radius;
@@ -925,8 +826,7 @@ Vector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_l
return planes;
}
-Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
-
+Vector<Plane> Geometry3D::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
Vector<Plane> planes;
Vector3 axis;
@@ -938,7 +838,6 @@ Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, i
axis_neg[p_axis] = -1.0;
for (int i = 0; i < p_sides; i++) {
-
Vector3 normal;
normal[(p_axis + 1) % 3] = Math::cos(i * (2.0 * Math_PI) / p_sides);
normal[(p_axis + 2) % 3] = Math::sin(i * (2.0 * Math_PI) / p_sides);
@@ -946,7 +845,6 @@ Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, i
planes.push_back(Plane(normal, p_radius));
for (int j = 1; j <= p_lats; j++) {
-
Vector3 angle = normal.lerp(axis, j / (real_t)p_lats).normalized();
Vector3 pos = axis * p_height * 0.5 + angle * p_radius;
planes.push_back(Plane(pos, angle));
@@ -957,270 +855,17 @@ Vector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, i
return planes;
}
-struct _AtlasWorkRect {
-
- Size2i s;
- Point2i p;
- int idx;
- _FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; };
-};
-
-struct _AtlasWorkRectResult {
-
- Vector<_AtlasWorkRect> result;
- int max_w;
- int max_h;
-};
-
-void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) {
-
- // Super simple, almost brute force scanline stacking fitter.
- // It's pretty basic for now, but it tries to make sure that the aspect ratio of the
- // resulting atlas is somehow square. This is necessary because video cards have limits.
- // On texture size (usually 2048 or 4096), so the more square a texture, the more chances.
- // It will work in every hardware.
- // For example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
- // 256x8192 atlas (won't work anywhere).
-
- ERR_FAIL_COND(p_rects.size() == 0);
-
- Vector<_AtlasWorkRect> wrects;
- wrects.resize(p_rects.size());
- for (int i = 0; i < p_rects.size(); i++) {
- wrects.write[i].s = p_rects[i];
- wrects.write[i].idx = i;
- }
- wrects.sort();
- int widest = wrects[0].s.width;
-
- Vector<_AtlasWorkRectResult> results;
-
- for (int i = 0; i <= 12; i++) {
-
- int w = 1 << i;
- int max_h = 0;
- int max_w = 0;
- if (w < widest)
- continue;
-
- Vector<int> hmax;
- hmax.resize(w);
- for (int j = 0; j < w; j++)
- hmax.write[j] = 0;
-
- // Place them.
- int ofs = 0;
- int limit_h = 0;
- for (int j = 0; j < wrects.size(); j++) {
-
- if (ofs + wrects[j].s.width > w) {
-
- ofs = 0;
- }
-
- int from_y = 0;
- for (int k = 0; k < wrects[j].s.width; k++) {
-
- if (hmax[ofs + k] > from_y)
- from_y = hmax[ofs + k];
- }
-
- wrects.write[j].p.x = ofs;
- wrects.write[j].p.y = from_y;
- int end_h = from_y + wrects[j].s.height;
- int end_w = ofs + wrects[j].s.width;
- if (ofs == 0)
- limit_h = end_h;
-
- for (int k = 0; k < wrects[j].s.width; k++) {
-
- hmax.write[ofs + k] = end_h;
- }
-
- if (end_h > max_h)
- max_h = end_h;
-
- if (end_w > max_w)
- max_w = end_w;
-
- if (ofs == 0 || end_h > limit_h) // While h limit not reached, keep stacking.
- ofs += wrects[j].s.width;
- }
-
- _AtlasWorkRectResult result;
- result.result = wrects;
- result.max_h = max_h;
- result.max_w = max_w;
- results.push_back(result);
- }
-
- // Find the result with the best aspect ratio.
-
- int best = -1;
- real_t best_aspect = 1e20;
-
- for (int i = 0; i < results.size(); i++) {
-
- real_t h = next_power_of_2(results[i].max_h);
- real_t w = next_power_of_2(results[i].max_w);
- real_t aspect = h > w ? h / w : w / h;
- if (aspect < best_aspect) {
- best = i;
- best_aspect = aspect;
- }
- }
-
- r_result.resize(p_rects.size());
-
- for (int i = 0; i < p_rects.size(); i++) {
-
- r_result.write[results[best].result[i].idx] = results[best].result[i].p;
- }
-
- r_size = Size2(results[best].max_w, results[best].max_h);
-}
-
-Vector<Vector<Point2>> Geometry::_polypaths_do_operation(PolyBooleanOperation p_op, const Vector<Point2> &p_polypath_a, const Vector<Point2> &p_polypath_b, bool is_a_open) {
-
- using namespace ClipperLib;
-
- ClipType op = ctUnion;
-
- switch (p_op) {
- case OPERATION_UNION:
- op = ctUnion;
- break;
- case OPERATION_DIFFERENCE:
- op = ctDifference;
- break;
- case OPERATION_INTERSECTION:
- op = ctIntersection;
- break;
- case OPERATION_XOR:
- op = ctXor;
- break;
- }
- Path path_a, path_b;
-
- // Need to scale points (Clipper's requirement for robust computation).
- for (int i = 0; i != p_polypath_a.size(); ++i) {
- path_a << IntPoint(p_polypath_a[i].x * SCALE_FACTOR, p_polypath_a[i].y * SCALE_FACTOR);
- }
- for (int i = 0; i != p_polypath_b.size(); ++i) {
- path_b << IntPoint(p_polypath_b[i].x * SCALE_FACTOR, p_polypath_b[i].y * SCALE_FACTOR);
- }
- Clipper clp;
- clp.AddPath(path_a, ptSubject, !is_a_open); // Forward compatible with Clipper 10.0.0.
- clp.AddPath(path_b, ptClip, true); // Polylines cannot be set as clip.
-
- Paths paths;
-
- if (is_a_open) {
- PolyTree tree; // Needed to populate polylines.
- clp.Execute(op, tree);
- OpenPathsFromPolyTree(tree, paths);
- } else {
- clp.Execute(op, paths); // Works on closed polygons only.
- }
- // Have to scale points down now.
- Vector<Vector<Point2>> polypaths;
-
- for (Paths::size_type i = 0; i < paths.size(); ++i) {
- Vector<Vector2> polypath;
-
- const Path &scaled_path = paths[i];
-
- for (Paths::size_type j = 0; j < scaled_path.size(); ++j) {
- polypath.push_back(Point2(
- static_cast<real_t>(scaled_path[j].X) / SCALE_FACTOR,
- static_cast<real_t>(scaled_path[j].Y) / SCALE_FACTOR));
- }
- polypaths.push_back(polypath);
- }
- return polypaths;
-}
-
-Vector<Vector<Point2>> Geometry::_polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
-
- using namespace ClipperLib;
-
- JoinType jt = jtSquare;
-
- switch (p_join_type) {
- case JOIN_SQUARE:
- jt = jtSquare;
- break;
- case JOIN_ROUND:
- jt = jtRound;
- break;
- case JOIN_MITER:
- jt = jtMiter;
- break;
- }
-
- EndType et = etClosedPolygon;
-
- switch (p_end_type) {
- case END_POLYGON:
- et = etClosedPolygon;
- break;
- case END_JOINED:
- et = etClosedLine;
- break;
- case END_BUTT:
- et = etOpenButt;
- break;
- case END_SQUARE:
- et = etOpenSquare;
- break;
- case END_ROUND:
- et = etOpenRound;
- break;
- }
- ClipperOffset co(2.0, 0.25 * SCALE_FACTOR); // Defaults from ClipperOffset.
- Path path;
-
- // Need to scale points (Clipper's requirement for robust computation).
- for (int i = 0; i != p_polypath.size(); ++i) {
- path << IntPoint(p_polypath[i].x * SCALE_FACTOR, p_polypath[i].y * SCALE_FACTOR);
- }
- co.AddPath(path, jt, et);
-
- Paths paths;
- co.Execute(paths, p_delta * SCALE_FACTOR); // Inflate/deflate.
-
- // Have to scale points down now.
- Vector<Vector<Point2>> polypaths;
-
- for (Paths::size_type i = 0; i < paths.size(); ++i) {
- Vector<Vector2> polypath;
-
- const Path &scaled_path = paths[i];
-
- for (Paths::size_type j = 0; j < scaled_path.size(); ++j) {
- polypath.push_back(Point2(
- static_cast<real_t>(scaled_path[j].X) / SCALE_FACTOR,
- static_cast<real_t>(scaled_path[j].Y) / SCALE_FACTOR));
- }
- polypaths.push_back(polypath);
- }
- return polypaths;
-}
-
-Vector<Vector3> Geometry::compute_convex_mesh_points(const Plane *p_planes, int p_plane_count) {
-
+Vector<Vector3> Geometry3D::compute_convex_mesh_points(const Plane *p_planes, int p_plane_count) {
Vector<Vector3> points;
// Iterate through every unique combination of any three planes.
for (int i = p_plane_count - 1; i >= 0; i--) {
for (int j = i - 1; j >= 0; j--) {
for (int k = j - 1; k >= 0; k--) {
-
// Find the point where these planes all cross over (if they
// do at all).
Vector3 convex_shape_point;
if (p_planes[i].intersect_3(p_planes[j], p_planes[k], &convex_shape_point)) {
-
// See if any *other* plane excludes this point because it's
// on the wrong side.
bool excluded = false;
@@ -1246,81 +891,11 @@ Vector<Vector3> Geometry::compute_convex_mesh_points(const Plane *p_planes, int
return points;
}
-Vector<Point2i> Geometry::pack_rects(const Vector<Size2i> &p_sizes, const Size2i &p_atlas_size) {
-
- Vector<stbrp_node> nodes;
- nodes.resize(p_atlas_size.width);
-
- stbrp_context context;
- stbrp_init_target(&context, p_atlas_size.width, p_atlas_size.height, nodes.ptrw(), p_atlas_size.width);
-
- Vector<stbrp_rect> rects;
- rects.resize(p_sizes.size());
-
- for (int i = 0; i < p_sizes.size(); i++) {
- rects.write[i].id = 0;
- rects.write[i].w = p_sizes[i].width;
- rects.write[i].h = p_sizes[i].height;
- rects.write[i].x = 0;
- rects.write[i].y = 0;
- rects.write[i].was_packed = 0;
- }
-
- int res = stbrp_pack_rects(&context, rects.ptrw(), rects.size());
- if (res == 0) { //pack failed
- return Vector<Point2i>();
- }
-
- Vector<Point2i> ret;
- ret.resize(p_sizes.size());
-
- for (int i = 0; i < p_sizes.size(); i++) {
- Point2i r(rects[i].x, rects[i].y);
- ret.write[i] = r;
- }
-
- return ret;
-}
-
-Vector<Vector3i> Geometry::partial_pack_rects(const Vector<Vector2i> &p_sizes, const Size2i &p_atlas_size) {
-
- Vector<stbrp_node> nodes;
- nodes.resize(p_atlas_size.width);
- zeromem(nodes.ptrw(), sizeof(stbrp_node) * nodes.size());
-
- stbrp_context context;
- stbrp_init_target(&context, p_atlas_size.width, p_atlas_size.height, nodes.ptrw(), p_atlas_size.width);
-
- Vector<stbrp_rect> rects;
- rects.resize(p_sizes.size());
-
- for (int i = 0; i < p_sizes.size(); i++) {
- rects.write[i].id = i;
- rects.write[i].w = p_sizes[i].width;
- rects.write[i].h = p_sizes[i].height;
- rects.write[i].x = 0;
- rects.write[i].y = 0;
- rects.write[i].was_packed = 0;
- }
-
- stbrp_pack_rects(&context, rects.ptrw(), rects.size());
-
- Vector<Vector3i> ret;
- ret.resize(p_sizes.size());
-
- for (int i = 0; i < p_sizes.size(); i++) {
- ret.write[rects[i].id] = Vector3i(rects[i].x, rects[i].y, rects[i].was_packed != 0 ? 1 : 0);
- }
-
- return ret;
-}
-
#define square(m_s) ((m_s) * (m_s))
#define INF 1e20
/* dt of 1d function using squared distance */
static void edt(float *f, int stride, int n) {
-
float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1));
int *v = (int *)&(d[n]);
float *z = (float *)&v[n];
@@ -1344,8 +919,9 @@ static void edt(float *f, int stride, int n) {
k = 0;
for (int q = 0; q <= n - 1; q++) {
- while (z[k + 1] < q)
+ while (z[k + 1] < q) {
k++;
+ }
d[q] = square(q - v[k]) + f[v[k] * stride];
}
@@ -1356,8 +932,7 @@ static void edt(float *f, int stride, int n) {
#undef square
-Vector<uint32_t> Geometry::generate_edf(const Vector<bool> &p_voxels, const Vector3i &p_size, bool p_negative) {
-
+Vector<uint32_t> Geometry3D::generate_edf(const Vector<bool> &p_voxels, const Vector3i &p_size, bool p_negative) {
uint32_t float_count = p_size.x * p_size.y * p_size.z;
ERR_FAIL_COND_V((uint32_t)p_voxels.size() != float_count, Vector<uint32_t>());
@@ -1374,7 +949,6 @@ Vector<uint32_t> Geometry::generate_edf(const Vector<bool> &p_voxels, const Vect
{
const bool *voxr = p_voxels.ptr();
for (uint32_t i = 0; i < float_count; i++) {
-
bool plot = voxr[i];
if (p_negative) {
plot = !plot;
@@ -1422,7 +996,7 @@ Vector<uint32_t> Geometry::generate_edf(const Vector<bool> &p_voxels, const Vect
return ret;
}
-Vector<int8_t> Geometry::generate_sdf8(const Vector<uint32_t> &p_positive, const Vector<uint32_t> &p_negative) {
+Vector<int8_t> Geometry3D::generate_sdf8(const Vector<uint32_t> &p_positive, const Vector<uint32_t> &p_negative) {
ERR_FAIL_COND_V(p_positive.size() != p_negative.size(), Vector<int8_t>());
Vector<int8_t> sdf8;
int s = p_positive.size();
diff --git a/core/math/geometry.h b/core/math/geometry_3d.h
index 45c8558fac..64cd34892e 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry_3d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* geometry.h */
+/* geometry_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,82 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GEOMETRY_H
-#define GEOMETRY_H
+#ifndef GEOMETRY_3D_H
+#define GEOMETRY_3D_H
-#include "core/math/delaunay_2d.h"
#include "core/math/face3.h"
-#include "core/math/rect2.h"
-#include "core/math/triangulate.h"
-#include "core/math/vector3.h"
#include "core/object.h"
-#include "core/print_string.h"
#include "core/vector.h"
-class Geometry {
- Geometry();
+class Geometry3D {
+ Geometry3D();
public:
- static real_t get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2, Vector2 &c1, Vector2 &c2) {
-
- Vector2 d1 = q1 - p1; // Direction vector of segment S1.
- Vector2 d2 = q2 - p2; // Direction vector of segment S2.
- Vector2 r = p1 - p2;
- real_t a = d1.dot(d1); // Squared length of segment S1, always nonnegative.
- real_t e = d2.dot(d2); // Squared length of segment S2, always nonnegative.
- real_t f = d2.dot(r);
- real_t s, t;
- // Check if either or both segments degenerate into points.
- if (a <= CMP_EPSILON && e <= CMP_EPSILON) {
- // Both segments degenerate into points.
- c1 = p1;
- c2 = p2;
- return Math::sqrt((c1 - c2).dot(c1 - c2));
- }
- if (a <= CMP_EPSILON) {
- // First segment degenerates into a point.
- s = 0.0;
- t = f / e; // s = 0 => t = (b*s + f) / e = f / e
- t = CLAMP(t, 0.0, 1.0);
- } else {
- real_t c = d1.dot(r);
- if (e <= CMP_EPSILON) {
- // Second segment degenerates into a point.
- t = 0.0;
- s = CLAMP(-c / a, 0.0, 1.0); // t = 0 => s = (b*t - c) / a = -c / a
- } else {
- // The general nondegenerate case starts here.
- real_t b = d1.dot(d2);
- real_t denom = a * e - b * b; // Always nonnegative.
- // If segments not parallel, compute closest point on L1 to L2 and
- // clamp to segment S1. Else pick arbitrary s (here 0).
- if (denom != 0.0) {
- s = CLAMP((b * f - c * e) / denom, 0.0, 1.0);
- } else
- s = 0.0;
- // Compute point on L2 closest to S1(s) using
- // t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
- t = (b * s + f) / e;
-
- //If t in [0,1] done. Else clamp t, recompute s for the new value
- // of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
- // and clamp s to [0, 1].
- if (t < 0.0) {
- t = 0.0;
- s = CLAMP(-c / a, 0.0, 1.0);
- } else if (t > 1.0) {
- t = 1.0;
- s = CLAMP((b - c) / a, 0.0, 1.0);
- }
- }
- }
- c1 = p1 + d1 * s;
- c2 = p2 + d2 * t;
- return Math::sqrt((c1 - c2).dot(c1 - c2));
- }
-
static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) {
-
// Do the function 'd' as defined by pb. I think is is dot product of some sort.
#define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z))
@@ -112,14 +48,18 @@ public:
real_t mub = (d_of(p1, q1, q2, q1) + mua * d_of(q2, q1, p2, p1)) / d_of(q2, q1, q2, q1);
// Clip the value between [0..1] constraining the solution to lie on the original curves.
- if (mua < 0)
+ if (mua < 0) {
mua = 0;
- if (mub < 0)
+ }
+ if (mub < 0) {
mub = 0;
- if (mua > 1)
+ }
+ if (mua > 1) {
mua = 1;
- if (mub > 1)
+ }
+ if (mub > 1) {
mub = 1;
+ }
c1 = p1.lerp(p2, mua);
c2 = q1.lerp(q2, mub);
}
@@ -160,22 +100,22 @@ public:
if (tN < 0.0) { // tc < 0 => the t=0 edge is visible.
tN = 0.0;
// Recompute sc for this edge.
- if (-d < 0.0)
+ if (-d < 0.0) {
sN = 0.0;
- else if (-d > a)
+ } else if (-d > a) {
sN = sD;
- else {
+ } else {
sN = -d;
sD = a;
}
} else if (tN > tD) { // tc > 1 => the t=1 edge is visible.
tN = tD;
// Recompute sc for this edge.
- if ((-d + b) < 0.0)
+ if ((-d + b) < 0.0) {
sN = 0;
- else if ((-d + b) > a)
+ } else if ((-d + b) > a) {
sN = sD;
- else {
+ } else {
sN = (-d + b);
sD = a;
}
@@ -190,120 +130,134 @@ public:
return dP.length(); // Return the closest distance.
}
- static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = 0) {
+ static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = nullptr) {
Vector3 e1 = p_v1 - p_v0;
Vector3 e2 = p_v2 - p_v0;
Vector3 h = p_dir.cross(e2);
real_t a = e1.dot(h);
- if (Math::is_zero_approx(a)) // Parallel test.
+ if (Math::is_zero_approx(a)) { // Parallel test.
return false;
+ }
real_t f = 1.0 / a;
Vector3 s = p_from - p_v0;
real_t u = f * s.dot(h);
- if (u < 0.0 || u > 1.0)
+ if (u < 0.0 || u > 1.0) {
return false;
+ }
Vector3 q = s.cross(e1);
real_t v = f * p_dir.dot(q);
- if (v < 0.0 || u + v > 1.0)
+ if (v < 0.0 || u + v > 1.0) {
return false;
+ }
// At this stage we can compute t to find out where
// the intersection point is on the line.
real_t t = f * e2.dot(q);
if (t > 0.00001) { // ray intersection
- if (r_res)
+ if (r_res) {
*r_res = p_from + p_dir * t;
+ }
return true;
- } else // This means that there is a line intersection but not a ray intersection.
+ } else { // This means that there is a line intersection but not a ray intersection.
return false;
+ }
}
- static inline bool segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = 0) {
-
+ static inline bool segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = nullptr) {
Vector3 rel = p_to - p_from;
Vector3 e1 = p_v1 - p_v0;
Vector3 e2 = p_v2 - p_v0;
Vector3 h = rel.cross(e2);
real_t a = e1.dot(h);
- if (Math::is_zero_approx(a)) // Parallel test.
+ if (Math::is_zero_approx(a)) { // Parallel test.
return false;
+ }
real_t f = 1.0 / a;
Vector3 s = p_from - p_v0;
real_t u = f * s.dot(h);
- if (u < 0.0 || u > 1.0)
+ if (u < 0.0 || u > 1.0) {
return false;
+ }
Vector3 q = s.cross(e1);
real_t v = f * rel.dot(q);
- if (v < 0.0 || u + v > 1.0)
+ if (v < 0.0 || u + v > 1.0) {
return false;
+ }
// At this stage we can compute t to find out where
// the intersection point is on the line.
real_t t = f * e2.dot(q);
if (t > CMP_EPSILON && t <= 1.0) { // Ray intersection.
- if (r_res)
+ if (r_res) {
*r_res = p_from + rel * t;
+ }
return true;
- } else // This means that there is a line intersection but not a ray intersection.
+ } else { // This means that there is a line intersection but not a ray intersection.
return false;
+ }
}
- static inline bool segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius, Vector3 *r_res = 0, Vector3 *r_norm = 0) {
-
+ static inline bool segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius, Vector3 *r_res = nullptr, Vector3 *r_norm = nullptr) {
Vector3 sphere_pos = p_sphere_pos - p_from;
Vector3 rel = (p_to - p_from);
real_t rel_l = rel.length();
- if (rel_l < CMP_EPSILON)
+ if (rel_l < CMP_EPSILON) {
return false; // Both points are the same.
+ }
Vector3 normal = rel / rel_l;
real_t sphere_d = normal.dot(sphere_pos);
real_t ray_distance = sphere_pos.distance_to(normal * sphere_d);
- if (ray_distance >= p_sphere_radius)
+ if (ray_distance >= p_sphere_radius) {
return false;
+ }
real_t inters_d2 = p_sphere_radius * p_sphere_radius - ray_distance * ray_distance;
real_t inters_d = sphere_d;
- if (inters_d2 >= CMP_EPSILON)
+ if (inters_d2 >= CMP_EPSILON) {
inters_d -= Math::sqrt(inters_d2);
+ }
// Check in segment.
- if (inters_d < 0 || inters_d > rel_l)
+ if (inters_d < 0 || inters_d > rel_l) {
return false;
+ }
Vector3 result = p_from + normal * inters_d;
- if (r_res)
+ if (r_res) {
*r_res = result;
- if (r_norm)
+ }
+ if (r_norm) {
*r_norm = (result - p_sphere_pos).normalized();
+ }
return true;
}
- static inline bool segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, real_t p_height, real_t p_radius, Vector3 *r_res = 0, Vector3 *r_norm = 0) {
-
+ static inline bool segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, real_t p_height, real_t p_radius, Vector3 *r_res = nullptr, Vector3 *r_norm = nullptr) {
Vector3 rel = (p_to - p_from);
real_t rel_l = rel.length();
- if (rel_l < CMP_EPSILON)
+ if (rel_l < CMP_EPSILON) {
return false; // Both points are the same.
+ }
// First check if they are parallel.
Vector3 normal = (rel / rel_l);
@@ -320,13 +274,15 @@ public:
real_t dist = z_dir.dot(p_from);
- if (dist >= p_radius)
+ if (dist >= p_radius) {
return false; // Too far away.
+ }
// Convert to 2D.
real_t w2 = p_radius * p_radius - dist * dist;
- if (w2 < CMP_EPSILON)
+ if (w2 < CMP_EPSILON) {
return false; // Avoid numerical error.
+ }
Size2 size(Math::sqrt(w2), p_height * 0.5);
Vector3 x_dir = z_dir.cross(Vector3(0, 0, 1)).normalized();
@@ -339,7 +295,6 @@ public:
int axis = -1;
for (int i = 0; i < 2; i++) {
-
real_t seg_from = from2D[i];
real_t seg_to = to2D[i];
real_t box_begin = -size[i];
@@ -347,17 +302,17 @@ public:
real_t cmin, cmax;
if (seg_from < seg_to) {
-
- if (seg_from > box_end || seg_to < box_begin)
+ if (seg_from > box_end || seg_to < box_begin) {
return false;
+ }
real_t length = seg_to - seg_from;
cmin = (seg_from < box_begin) ? ((box_begin - seg_from) / length) : 0;
cmax = (seg_to > box_end) ? ((box_end - seg_from) / length) : 1;
} else {
-
- if (seg_to > box_end || seg_from < box_begin)
+ if (seg_to > box_end || seg_from < box_begin) {
return false;
+ }
real_t length = seg_to - seg_from;
cmin = (seg_from > box_end) ? (box_end - seg_from) / length : 0;
cmax = (seg_to < box_begin) ? (box_begin - seg_from) / length : 1;
@@ -367,10 +322,12 @@ public:
min = cmin;
axis = i;
}
- if (cmax < max)
+ if (cmax < max) {
max = cmax;
- if (max < min)
+ }
+ if (max < min) {
return false;
+ }
}
// Convert to 3D again.
@@ -386,45 +343,47 @@ public:
res_normal.normalize();
- if (r_res)
+ if (r_res) {
*r_res = result;
- if (r_norm)
+ }
+ if (r_norm) {
*r_norm = res_normal;
+ }
return true;
}
static bool segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Plane *p_planes, int p_plane_count, Vector3 *p_res, Vector3 *p_norm) {
-
real_t min = -1e20, max = 1e20;
Vector3 rel = p_to - p_from;
real_t rel_l = rel.length();
- if (rel_l < CMP_EPSILON)
+ if (rel_l < CMP_EPSILON) {
return false;
+ }
Vector3 dir = rel / rel_l;
int min_index = -1;
for (int i = 0; i < p_plane_count; i++) {
-
const Plane &p = p_planes[i];
real_t den = p.normal.dot(dir);
- if (Math::abs(den) <= CMP_EPSILON)
+ if (Math::abs(den) <= CMP_EPSILON) {
continue; // Ignore parallel plane.
+ }
real_t dist = -p.distance_to(p_from) / den;
if (den > 0) {
// Backwards facing plane.
- if (dist < max)
+ if (dist < max) {
max = dist;
+ }
} else {
-
// Front facing plane.
if (dist > min) {
min = dist;
@@ -433,170 +392,89 @@ public:
}
}
- if (max <= min || min < 0 || min > rel_l || min_index == -1) // Exit conditions.
+ if (max <= min || min < 0 || min > rel_l || min_index == -1) { // Exit conditions.
return false; // No intersection.
+ }
- if (p_res)
+ if (p_res) {
*p_res = p_from + dir * min;
- if (p_norm)
+ }
+ if (p_norm) {
*p_norm = p_planes[min_index].normal;
+ }
return true;
}
static Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 *p_segment) {
-
Vector3 p = p_point - p_segment[0];
Vector3 n = p_segment[1] - p_segment[0];
real_t l2 = n.length_squared();
- if (l2 < 1e-20)
+ if (l2 < 1e-20) {
return p_segment[0]; // Both points are the same, just give any.
+ }
real_t d = n.dot(p) / l2;
- if (d <= 0.0)
+ if (d <= 0.0) {
return p_segment[0]; // Before first point.
- else if (d >= 1.0)
+ } else if (d >= 1.0) {
return p_segment[1]; // After first point.
- else
+ } else {
return p_segment[0] + n * d; // Inside.
+ }
}
static Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 *p_segment) {
-
Vector3 p = p_point - p_segment[0];
Vector3 n = p_segment[1] - p_segment[0];
real_t l2 = n.length_squared();
- if (l2 < 1e-20)
- return p_segment[0]; // Both points are the same, just give any.
-
- real_t d = n.dot(p) / l2;
-
- return p_segment[0] + n * d; // Inside.
- }
-
- static Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 *p_segment) {
-
- Vector2 p = p_point - p_segment[0];
- Vector2 n = p_segment[1] - p_segment[0];
- real_t l2 = n.length_squared();
- if (l2 < 1e-20)
- return p_segment[0]; // Both points are the same, just give any.
-
- real_t d = n.dot(p) / l2;
-
- if (d <= 0.0)
- return p_segment[0]; // Before first point.
- else if (d >= 1.0)
- return p_segment[1]; // After first point.
- else
- return p_segment[0] + n * d; // Inside.
- }
-
- static bool is_point_in_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) {
- Vector2 an = a - s;
- Vector2 bn = b - s;
- Vector2 cn = c - s;
-
- bool orientation = an.cross(bn) > 0;
-
- if ((bn.cross(cn) > 0) != orientation)
- return false;
-
- return (cn.cross(an) > 0) == orientation;
- }
-
- static Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 *p_segment) {
-
- Vector2 p = p_point - p_segment[0];
- Vector2 n = p_segment[1] - p_segment[0];
- real_t l2 = n.length_squared();
- if (l2 < 1e-20)
+ if (l2 < 1e-20) {
return p_segment[0]; // Both points are the same, just give any.
+ }
real_t d = n.dot(p) / l2;
return p_segment[0] + n * d; // Inside.
}
- static bool line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b, Vector2 &r_result) {
-
- // See http://paulbourke.net/geometry/pointlineplane/
-
- const real_t denom = p_dir_b.y * p_dir_a.x - p_dir_b.x * p_dir_a.y;
- if (Math::is_zero_approx(denom)) { // Parallel?
- return false;
- }
-
- const Vector2 v = p_from_a - p_from_b;
- const real_t t = (p_dir_b.x * v.y - p_dir_b.y * v.x) / denom;
- r_result = p_from_a + t * p_dir_a;
- return true;
- }
-
- static bool segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b, Vector2 *r_result) {
-
- Vector2 B = p_to_a - p_from_a;
- Vector2 C = p_from_b - p_from_a;
- Vector2 D = p_to_b - p_from_a;
-
- real_t ABlen = B.dot(B);
- if (ABlen <= 0)
- return false;
- Vector2 Bn = B / ABlen;
- C = Vector2(C.x * Bn.x + C.y * Bn.y, C.y * Bn.x - C.x * Bn.y);
- D = Vector2(D.x * Bn.x + D.y * Bn.y, D.y * Bn.x - D.x * Bn.y);
-
- if ((C.y < 0 && D.y < 0) || (C.y >= 0 && D.y >= 0))
- return false;
-
- real_t ABpos = D.x + (C.x - D.x) * D.y / (D.y - C.y);
-
- // Fail if segment C-D crosses line A-B outside of segment A-B.
- if (ABpos < 0 || ABpos > 1.0)
- return false;
-
- // (4) Apply the discovered position to line A-B in the original coordinate system.
- if (r_result)
- *r_result = p_from_a + B * ABpos;
-
- return true;
- }
-
static inline bool point_in_projected_triangle(const Vector3 &p_point, const Vector3 &p_v1, const Vector3 &p_v2, const Vector3 &p_v3) {
-
Vector3 face_n = (p_v1 - p_v3).cross(p_v1 - p_v2);
Vector3 n1 = (p_point - p_v3).cross(p_point - p_v2);
- if (face_n.dot(n1) < 0)
+ if (face_n.dot(n1) < 0) {
return false;
+ }
Vector3 n2 = (p_v1 - p_v3).cross(p_v1 - p_point);
- if (face_n.dot(n2) < 0)
+ if (face_n.dot(n2) < 0) {
return false;
+ }
Vector3 n3 = (p_v1 - p_point).cross(p_v1 - p_v2);
- if (face_n.dot(n3) < 0)
+ if (face_n.dot(n3) < 0) {
return false;
+ }
return true;
}
static inline bool triangle_sphere_intersection_test(const Vector3 *p_triangle, const Vector3 &p_normal, const Vector3 &p_sphere_pos, real_t p_sphere_radius, Vector3 &r_triangle_contact, Vector3 &r_sphere_contact) {
-
real_t d = p_normal.dot(p_sphere_pos) - p_normal.dot(p_triangle[0]);
- if (d > p_sphere_radius || d < -p_sphere_radius) // Not touching the plane of the face, return.
+ if (d > p_sphere_radius || d < -p_sphere_radius) {
+ // Not touching the plane of the face, return.
return false;
+ }
Vector3 contact = p_sphere_pos - (p_normal * d);
/** 2nd) TEST INSIDE TRIANGLE **/
- if (Geometry::point_in_projected_triangle(contact, p_triangle[0], p_triangle[1], p_triangle[2])) {
+ if (Geometry3D::point_in_projected_triangle(contact, p_triangle[0], p_triangle[1], p_triangle[2])) {
r_triangle_contact = contact;
r_sphere_contact = p_sphere_pos - p_normal * p_sphere_radius;
//printf("solved inside triangle\n");
@@ -608,7 +486,6 @@ public:
const Vector3 verts[4] = { p_triangle[0], p_triangle[1], p_triangle[2], p_triangle[0] }; // for() friendly
for (int i = 0; i < 3; i++) {
-
// Check edge cylinder.
Vector3 n1 = verts[i] - verts[i + 1];
@@ -633,7 +510,6 @@ public:
real_t sphere_at = n1.dot(n2);
if (sphere_at >= 0 && sphere_at < n1.dot(n1)) {
-
r_triangle_contact = p_sphere_pos - axis * (axis.dot(n2));
r_sphere_contact = p_sphere_pos - axis * p_sphere_radius;
// Point inside here.
@@ -643,7 +519,6 @@ public:
real_t r2 = p_sphere_radius * p_sphere_radius;
if (n2.length_squared() < r2) {
-
Vector3 n = (p_sphere_pos - verts[i + 1]).normalized();
r_triangle_contact = verts[i + 1];
@@ -665,54 +540,16 @@ public:
return false;
}
- static inline bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
-
- return p_point.distance_squared_to(p_circle_pos) <= p_circle_radius * p_circle_radius;
- }
-
- static real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
-
- Vector2 line_vec = p_to - p_from;
- Vector2 vec_to_line = p_from - p_circle_pos;
-
- // Create a quadratic formula of the form ax^2 + bx + c = 0
- real_t a, b, c;
-
- a = line_vec.dot(line_vec);
- b = 2 * vec_to_line.dot(line_vec);
- c = vec_to_line.dot(vec_to_line) - p_circle_radius * p_circle_radius;
-
- // Solve for t.
- real_t sqrtterm = b * b - 4 * a * c;
-
- // If the term we intend to square root is less than 0 then the answer won't be real,
- // so it definitely won't be t in the range 0 to 1.
- if (sqrtterm < 0)
- return -1;
-
- // If we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection)
- // then the following can be skipped and we can just return the equivalent of res1.
- sqrtterm = Math::sqrt(sqrtterm);
- real_t res1 = (-b - sqrtterm) / (2 * a);
- real_t res2 = (-b + sqrtterm) / (2 * a);
-
- if (res1 >= 0 && res1 <= 1)
- return res1;
- if (res2 >= 0 && res2 <= 1)
- return res2;
- return -1;
- }
-
static inline Vector<Vector3> clip_polygon(const Vector<Vector3> &polygon, const Plane &p_plane) {
-
enum LocationCache {
LOC_INSIDE = 1,
LOC_BOUNDARY = 0,
LOC_OUTSIDE = -1
};
- if (polygon.size() == 0)
+ if (polygon.size() == 0) {
return polygon;
+ }
int *location_cache = (int *)alloca(sizeof(int) * polygon.size());
int inside_count = 0;
@@ -734,11 +571,8 @@ public:
}
if (outside_count == 0) {
-
return polygon; // No changes.
-
} else if (inside_count == 0) {
-
return Vector<Vector3>(); // Empty.
}
@@ -778,141 +612,12 @@ public:
return clipped;
}
- enum PolyBooleanOperation {
- OPERATION_UNION,
- OPERATION_DIFFERENCE,
- OPERATION_INTERSECTION,
- OPERATION_XOR
- };
- enum PolyJoinType {
- JOIN_SQUARE,
- JOIN_ROUND,
- JOIN_MITER
- };
- enum PolyEndType {
- END_POLYGON,
- END_JOINED,
- END_BUTT,
- END_SQUARE,
- END_ROUND
- };
-
- static Vector<Vector<Point2>> merge_polygons_2d(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
-
- return _polypaths_do_operation(OPERATION_UNION, p_polygon_a, p_polygon_b);
- }
-
- static Vector<Vector<Point2>> clip_polygons_2d(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
-
- return _polypaths_do_operation(OPERATION_DIFFERENCE, p_polygon_a, p_polygon_b);
- }
-
- static Vector<Vector<Point2>> intersect_polygons_2d(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
-
- return _polypaths_do_operation(OPERATION_INTERSECTION, p_polygon_a, p_polygon_b);
- }
-
- static Vector<Vector<Point2>> exclude_polygons_2d(const Vector<Point2> &p_polygon_a, const Vector<Point2> &p_polygon_b) {
-
- return _polypaths_do_operation(OPERATION_XOR, p_polygon_a, p_polygon_b);
- }
-
- static Vector<Vector<Point2>> clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
-
- return _polypaths_do_operation(OPERATION_DIFFERENCE, p_polyline, p_polygon, true);
- }
-
- static Vector<Vector<Point2>> intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
-
- return _polypaths_do_operation(OPERATION_INTERSECTION, p_polyline, p_polygon, true);
- }
-
- static Vector<Vector<Point2>> offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
-
- return _polypath_offset(p_polygon, p_delta, p_join_type, END_POLYGON);
- }
-
- static Vector<Vector<Point2>> offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
-
- ERR_FAIL_COND_V_MSG(p_end_type == END_POLYGON, Vector<Vector<Point2>>(), "Attempt to offset a polyline like a polygon (use offset_polygon_2d instead).");
-
- return _polypath_offset(p_polygon, p_delta, p_join_type, p_end_type);
- }
-
- static Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points) {
-
- Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(p_points);
- Vector<int> triangles;
-
- for (int i = 0; i < tr.size(); i++) {
- triangles.push_back(tr[i].points[0]);
- triangles.push_back(tr[i].points[1]);
- triangles.push_back(tr[i].points[2]);
- }
- return triangles;
- }
-
- static Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon) {
-
- Vector<int> triangles;
- if (!Triangulate::triangulate(p_polygon, triangles))
- return Vector<int>(); //fail
- return triangles;
- }
-
- static bool is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
- int c = p_polygon.size();
- if (c < 3)
- return false;
- const Vector2 *p = p_polygon.ptr();
- real_t sum = 0;
- for (int i = 0; i < c; i++) {
- const Vector2 &v1 = p[i];
- const Vector2 &v2 = p[(i + 1) % c];
- sum += (v2.x - v1.x) * (v2.y + v1.y);
- }
-
- return sum > 0.0f;
- }
-
- // Alternate implementation that should be faster.
- static bool is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) {
- int c = p_polygon.size();
- if (c < 3)
- return false;
- const Vector2 *p = p_polygon.ptr();
- Vector2 further_away(-1e20, -1e20);
- Vector2 further_away_opposite(1e20, 1e20);
-
- for (int i = 0; i < c; i++) {
- further_away.x = MAX(p[i].x, further_away.x);
- further_away.y = MAX(p[i].y, further_away.y);
- further_away_opposite.x = MIN(p[i].x, further_away_opposite.x);
- further_away_opposite.y = MIN(p[i].y, further_away_opposite.y);
- }
-
- // Make point outside that won't intersect with points in segment from p_point.
- further_away += (further_away - further_away_opposite) * Vector2(1.221313, 1.512312);
-
- int intersections = 0;
- for (int i = 0; i < c; i++) {
- const Vector2 &v1 = p[i];
- const Vector2 &v2 = p[(i + 1) % c];
- if (segment_intersects_segment_2d(v1, v2, p_point, further_away, nullptr)) {
- intersections++;
- }
- }
-
- return (intersections & 1);
- }
-
static Vector<Vector<Face3>> separate_objects(Vector<Face3> p_array);
// Create a "wrap" that encloses the given geometry.
static Vector<Face3> wrap_geometry(Vector<Face3> p_array, real_t *p_error = nullptr);
struct MeshData {
-
struct Face {
Plane plane;
Vector<int> indices;
@@ -921,7 +626,6 @@ public:
Vector<Face> faces;
struct Edge {
-
int a, b;
};
@@ -933,7 +637,6 @@ public:
};
_FORCE_INLINE_ static int get_uv84_normal_bit(const Vector3 &p_vector) {
-
int lat = Math::fast_ftoi(Math::floor(Math::acos(p_vector.dot(Vector3(0, 1, 0))) * 4.0 / Math_PI + 0.5));
if (lat == 0) {
@@ -948,91 +651,61 @@ public:
}
_FORCE_INLINE_ static int get_uv84_normal_bit_neighbors(int p_idx) {
-
if (p_idx == 24) {
return 1 | 2 | 4 | 8;
} else if (p_idx == 25) {
return (1 << 23) | (1 << 22) | (1 << 21) | (1 << 20);
} else {
-
int ret = 0;
- if ((p_idx % 8) == 0)
+ if ((p_idx % 8) == 0) {
ret |= (1 << (p_idx + 7));
- else
+ } else {
ret |= (1 << (p_idx - 1));
- if ((p_idx % 8) == 7)
+ }
+ if ((p_idx % 8) == 7) {
ret |= (1 << (p_idx - 7));
- else
+ } else {
ret |= (1 << (p_idx + 1));
+ }
int mask = ret | (1 << p_idx);
- if (p_idx < 8)
+ if (p_idx < 8) {
ret |= 24;
- else
+ } else {
ret |= mask >> 8;
+ }
- if (p_idx >= 16)
+ if (p_idx >= 16) {
ret |= 25;
- else
+ } else {
ret |= mask << 8;
+ }
return ret;
}
}
-
- static real_t vec2_cross(const Point2 &O, const Point2 &A, const Point2 &B) {
- return (real_t)(A.x - O.x) * (B.y - O.y) - (real_t)(A.y - O.y) * (B.x - O.x);
- }
-
- // Returns a list of points on the convex hull in counter-clockwise order.
- // Note: the last point in the returned list is the same as the first one.
- static Vector<Point2> convex_hull_2d(Vector<Point2> P) {
- int n = P.size(), k = 0;
- Vector<Point2> H;
- H.resize(2 * n);
-
- // Sort points lexicographically.
- P.sort();
-
- // Build lower hull.
- for (int i = 0; i < n; ++i) {
- while (k >= 2 && vec2_cross(H[k - 2], H[k - 1], P[i]) <= 0)
- k--;
- H.write[k++] = P[i];
- }
-
- // Build upper hull.
- for (int i = n - 2, t = k + 1; i >= 0; i--) {
- while (k >= t && vec2_cross(H[k - 2], H[k - 1], P[i]) <= 0)
- k--;
- H.write[k++] = P[i];
- }
-
- H.resize(k);
- return H;
- }
- static Vector<Vector<Vector2>> decompose_polygon_in_convex(Vector<Point2> polygon);
-
static MeshData build_convex_mesh(const Vector<Plane> &p_planes);
static Vector<Plane> build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis = Vector3::AXIS_Z);
static Vector<Plane> build_box_planes(const Vector3 &p_extents);
static Vector<Plane> build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
static Vector<Plane> build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
- static void make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size);
-
static Vector<Vector3> compute_convex_mesh_points(const Plane *p_planes, int p_plane_count);
#define FINDMINMAX(x0, x1, x2, min, max) \
min = max = x0; \
- if (x1 < min) \
+ if (x1 < min) { \
min = x1; \
- if (x1 > max) \
+ } \
+ if (x1 > max) { \
max = x1; \
- if (x2 < min) \
+ } \
+ if (x2 < min) { \
min = x2; \
- if (x2 > max) \
- max = x2;
+ } \
+ if (x2 > max) { \
+ max = x2; \
+ }
_FORCE_INLINE_ static bool planeBoxOverlap(Vector3 normal, float d, Vector3 maxbox) {
int q;
@@ -1046,10 +719,12 @@ public:
vmax[q] = -maxbox[q];
}
}
- if (normal.dot(vmin) + d > 0.0f)
+ if (normal.dot(vmin) + d > 0.0f) {
return false;
- if (normal.dot(vmax) + d >= 0.0f)
+ }
+ if (normal.dot(vmax) + d >= 0.0f) {
return true;
+ }
return false;
}
@@ -1066,8 +741,9 @@ public:
max = p0; \
} \
rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \
- if (min > rad || max < -rad) \
- return false;
+ if (min > rad || max < -rad) { \
+ return false; \
+ }
#define AXISTEST_X2(a, b, fa, fb) \
p0 = a * v0.y - b * v0.z; \
@@ -1080,8 +756,9 @@ public:
max = p0; \
} \
rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \
- if (min > rad || max < -rad) \
- return false;
+ if (min > rad || max < -rad) { \
+ return false; \
+ }
/*======================== Y-tests ========================*/
#define AXISTEST_Y02(a, b, fa, fb) \
@@ -1095,8 +772,9 @@ public:
max = p0; \
} \
rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
- if (min > rad || max < -rad) \
- return false;
+ if (min > rad || max < -rad) { \
+ return false; \
+ }
#define AXISTEST_Y1(a, b, fa, fb) \
p0 = -a * v0.x + b * v0.z; \
@@ -1109,8 +787,9 @@ public:
max = p0; \
} \
rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
- if (min > rad || max < -rad) \
- return false;
+ if (min > rad || max < -rad) { \
+ return false; \
+ }
/*======================== Z-tests ========================*/
@@ -1125,8 +804,9 @@ public:
max = p2; \
} \
rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \
- if (min > rad || max < -rad) \
- return false;
+ if (min > rad || max < -rad) { \
+ return false; \
+ }
#define AXISTEST_Z0(a, b, fa, fb) \
p0 = a * v0.x - b * v0.y; \
@@ -1139,11 +819,11 @@ public:
max = p0; \
} \
rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \
- if (min > rad || max < -rad) \
- return false;
+ if (min > rad || max < -rad) { \
+ return false; \
+ }
_FORCE_INLINE_ static bool triangle_box_overlap(const Vector3 &boxcenter, const Vector3 boxhalfsize, const Vector3 *triverts) {
-
/* use separating axis theorem to test overlap between triangle and box */
/* need to test for overlap in these directions: */
/* 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */
@@ -1198,18 +878,21 @@ public:
/* test in X-direction */
FINDMINMAX(v0.x, v1.x, v2.x, min, max);
- if (min > boxhalfsize.x || max < -boxhalfsize.x)
+ if (min > boxhalfsize.x || max < -boxhalfsize.x) {
return false;
+ }
/* test in Y-direction */
FINDMINMAX(v0.y, v1.y, v2.y, min, max);
- if (min > boxhalfsize.y || max < -boxhalfsize.y)
+ if (min > boxhalfsize.y || max < -boxhalfsize.y) {
return false;
+ }
/* test in Z-direction */
FINDMINMAX(v0.z, v1.z, v2.z, min, max);
- if (min > boxhalfsize.z || max < -boxhalfsize.z)
+ if (min > boxhalfsize.z || max < -boxhalfsize.z) {
return false;
+ }
/* Bullet 2: */
/* test if the box intersects the plane of the triangle */
@@ -1219,9 +902,6 @@ public:
return planeBoxOverlap(normal, d, boxhalfsize); /* if true, box and triangle overlaps */
}
- static Vector<Point2i> pack_rects(const Vector<Size2i> &p_sizes, const Size2i &p_atlas_size);
- static Vector<Vector3i> partial_pack_rects(const Vector<Vector2i> &p_sizes, const Size2i &p_atlas_size);
-
static Vector<uint32_t> generate_edf(const Vector<bool> &p_voxels, const Vector3i &p_size, bool p_negative);
static Vector<int8_t> generate_sdf8(const Vector<uint32_t> &p_positive, const Vector<uint32_t> &p_negative);
@@ -1265,10 +945,6 @@ public:
return Color(va6 * v6, vb6 * v6, vc6 * v6, vd6 * v6);
#undef STP
}
-
-private:
- static Vector<Vector<Point2>> _polypaths_do_operation(PolyBooleanOperation p_op, const Vector<Point2> &p_polypath_a, const Vector<Point2> &p_polypath_b, bool is_a_open = false);
- static Vector<Vector<Point2>> _polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type);
};
-#endif // GEOMETRY_H
+#endif // GEOMETRY_3D_H
diff --git a/core/math/math_fieldwise.cpp b/core/math/math_fieldwise.cpp
index a47d4ef7ad..ef2a0c5339 100644
--- a/core/math/math_fieldwise.cpp
+++ b/core/math/math_fieldwise.cpp
@@ -41,7 +41,6 @@
}
Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field) {
-
ERR_FAIL_COND_V(p_target.get_type() != p_source.get_type(), p_target);
/* clang-format makes a mess of this macro usage */
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 7417e64ac1..1585c96b38 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -94,16 +94,18 @@ double Math::dectime(double p_value, double p_amount, double p_step) {
double sgn = p_value < 0 ? -1.0 : 1.0;
double val = Math::abs(p_value);
val -= p_amount * p_step;
- if (val < 0.0)
+ if (val < 0.0) {
val = 0.0;
+ }
return val * sgn;
}
double Math::ease(double p_x, double p_c) {
- if (p_x < 0)
+ if (p_x < 0) {
p_x = 0;
- else if (p_x > 1.0)
+ } else if (p_x > 1.0) {
p_x = 1.0;
+ }
if (p_c > 0) {
if (p_c < 1.0) {
return 1.0 - Math::pow(1.0 - p_x, 1.0 / p_c);
@@ -118,8 +120,9 @@ double Math::ease(double p_x, double p_c) {
} else {
return (1.0 - Math::pow(1.0 - (p_x - 0.5) * 2.0, -p_c)) * 0.5 + 0.5;
}
- } else
+ } else {
return 0; // no ease (raw)
+ }
}
double Math::stepify(double p_value, double p_step) {
@@ -130,7 +133,6 @@ double Math::stepify(double p_value, double p_step) {
}
uint32_t Math::larger_prime(uint32_t p_val) {
-
static const uint32_t primes[] = {
5,
13,
@@ -166,10 +168,10 @@ uint32_t Math::larger_prime(uint32_t p_val) {
int idx = 0;
while (true) {
-
ERR_FAIL_COND_V(primes[idx] == 0, 0);
- if (primes[idx] > p_val)
+ if (primes[idx] > p_val) {
return primes[idx];
+ }
idx++;
}
}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index bd13c82894..7a9fd60e23 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -41,7 +41,6 @@
#include <math.h>
class Math {
-
static RandomPCG default_rand;
public:
@@ -233,14 +232,16 @@ public:
static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
static _ALWAYS_INLINE_ double smoothstep(double p_from, double p_to, double p_weight) {
- if (is_equal_approx(p_from, p_to))
+ if (is_equal_approx(p_from, p_to)) {
return p_from;
+ }
double x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0, 1.0);
return x * x * (3.0 - 2.0 * x);
}
static _ALWAYS_INLINE_ float smoothstep(float p_from, float p_to, float p_weight) {
- if (is_equal_approx(p_from, p_to))
+ if (is_equal_approx(p_from, p_to)) {
return p_from;
+ }
float x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0f, 1.0f);
return x * x * (3.0f - 2.0f * x);
}
@@ -328,7 +329,6 @@ public:
}
static _ALWAYS_INLINE_ float absf(float g) {
-
union {
float f;
uint32_t i;
@@ -340,7 +340,6 @@ public:
}
static _ALWAYS_INLINE_ double absd(double g) {
-
union {
double d;
uint64_t i;
@@ -352,7 +351,6 @@ public:
//this function should be as fast as possible and rounding mode should not matter
static _ALWAYS_INLINE_ int fast_ftoi(float a) {
-
static int b;
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603) || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // windows 8 phone?
@@ -407,7 +405,6 @@ public:
}
static _ALWAYS_INLINE_ float halfptr_to_float(const uint16_t *h) {
-
union {
uint32_t u32;
float f32;
@@ -422,7 +419,6 @@ public:
}
static _ALWAYS_INLINE_ uint16_t make_half_float(float f) {
-
union {
float fv;
uint32_t ui;
@@ -453,7 +449,6 @@ public:
}
// check if exponent is <= -15
else if (exp <= 0x38000000) {
-
/*// store a denorm half-float value or zero
exp = (0x38000000 - exp) >> 23;
mantissa >>= (14 + exp);
@@ -478,10 +473,11 @@ public:
if (p_step != 0) {
float a = Math::stepify(p_target - p_offset, p_step + p_separation) + p_offset;
float b = a;
- if (p_target >= 0)
+ if (p_target >= 0) {
b -= p_separation;
- else
+ } else {
b += p_step;
+ }
return (Math::abs(p_target - a) < Math::abs(p_target - b)) ? a : b;
}
return p_target;
diff --git a/core/math/octree.h b/core/math/octree.h
index ffb405bd0f..5d9688d442 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -34,7 +34,7 @@
#include "core/list.h"
#include "core/map.h"
#include "core/math/aabb.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/math/vector3.h"
#include "core/print_string.h"
#include "core/variant.h"
@@ -52,7 +52,6 @@ public:
private:
enum {
-
NEG = 0,
POS = 1,
};
@@ -69,7 +68,6 @@ private:
};
struct PairKey {
-
union {
struct {
OctreeElementID A;
@@ -79,18 +77,14 @@ private:
};
_FORCE_INLINE_ bool operator<(const PairKey &p_pair) const {
-
return key < p_pair.key;
}
_FORCE_INLINE_ PairKey(OctreeElementID p_A, OctreeElementID p_B) {
-
if (p_A < p_B) {
-
A = p_A;
B = p_B;
} else {
-
B = p_A;
A = p_B;
}
@@ -102,53 +96,37 @@ private:
struct Element;
struct Octant {
-
// cached for FAST plane check
AABB aabb;
- uint64_t last_pass;
- Octant *parent;
- Octant *children[8];
+ uint64_t last_pass = 0;
+ Octant *parent = nullptr;
+ Octant *children[8] = { nullptr };
- int children_count; // cache for amount of childrens (fast check for removal)
- int parent_index; // cache for parent index (fast check for removal)
+ int children_count = 0; // cache for amount of childrens (fast check for removal)
+ int parent_index = -1; // cache for parent index (fast check for removal)
List<Element *, AL> pairable_elements;
List<Element *, AL> elements;
- Octant() {
- children_count = 0;
- parent_index = -1;
- last_pass = 0;
- parent = nullptr;
- for (int i = 0; i < 8; i++)
- children[i] = nullptr;
- }
-
- ~Octant() {
-
- /*
- for (int i=0;i<8;i++)
- memdelete_notnull(children[i]);
- */
- }
+ Octant() {}
+ ~Octant() {}
};
struct PairData;
struct Element {
+ Octree *octree = nullptr;
- Octree *octree;
-
- T *userdata;
- int subindex;
- bool pairable;
- uint32_t pairable_mask;
- uint32_t pairable_type;
+ T *userdata = nullptr;
+ int subindex = 0;
+ bool pairable = false;
+ uint32_t pairable_mask = 0;
+ uint32_t pairable_type = 0;
- uint64_t last_pass;
- OctreeElementID _id;
- Octant *common_parent;
+ uint64_t last_pass = 0;
+ OctreeElementID _id = 0;
+ Octant *common_parent = nullptr;
AABB aabb;
AABB container_aabb;
@@ -156,28 +134,16 @@ private:
List<PairData *, AL> pair_list;
struct OctantOwner {
-
Octant *octant;
typename List<Element *, AL>::Element *E;
}; // an element can be in max 8 octants
List<OctantOwner, AL> octant_owners;
- Element() {
- last_pass = 0;
- _id = 0;
- pairable = false;
- subindex = 0;
- userdata = 0;
- octree = 0;
- pairable_mask = 0;
- pairable_type = 0;
- common_parent = nullptr;
- }
+ Element() {}
};
struct PairData {
-
int refcount;
bool intersect;
Element *A, *B;
@@ -204,19 +170,15 @@ private:
int pair_count;
_FORCE_INLINE_ void _pair_check(PairData *p_pair) {
-
bool intersect = p_pair->A->aabb.intersects_inclusive(p_pair->B->aabb);
if (intersect != p_pair->intersect) {
-
if (intersect) {
-
if (pair_callback) {
p_pair->ud = pair_callback(pair_callback_userdata, p_pair->A->_id, p_pair->A->userdata, p_pair->A->subindex, p_pair->B->_id, p_pair->B->userdata, p_pair->B->subindex);
}
pair_count++;
} else {
-
if (unpair_callback) {
unpair_callback(pair_callback_userdata, p_pair->A->_id, p_pair->A->userdata, p_pair->A->subindex, p_pair->B->_id, p_pair->B->userdata, p_pair->B->subindex, p_pair->ud);
}
@@ -228,19 +190,19 @@ private:
}
_FORCE_INLINE_ void _pair_reference(Element *p_A, Element *p_B) {
-
- if (p_A == p_B || (p_A->userdata == p_B->userdata && p_A->userdata))
+ if (p_A == p_B || (p_A->userdata == p_B->userdata && p_A->userdata)) {
return;
+ }
if (!(p_A->pairable_type & p_B->pairable_mask) &&
- !(p_B->pairable_type & p_A->pairable_mask))
+ !(p_B->pairable_type & p_A->pairable_mask)) {
return; // none can pair with none
+ }
PairKey key(p_A->_id, p_B->_id);
typename PairMap::Element *E = pair_map.find(key);
if (!E) {
-
PairData pdata;
pdata.refcount = 1;
pdata.A = p_A;
@@ -255,15 +217,14 @@ private:
pair_callback(pair_callback_userdata,p_A->userdata,p_B->userdata);
*/
} else {
-
E->get().refcount++;
}
}
_FORCE_INLINE_ void _pair_unreference(Element *p_A, Element *p_B) {
-
- if (p_A == p_B)
+ if (p_A == p_B) {
return;
+ }
PairKey key(p_A->_id, p_B->_id);
typename PairMap::Element *E = pair_map.find(key);
@@ -296,24 +257,18 @@ private:
}
_FORCE_INLINE_ void _element_check_pairs(Element *p_element) {
-
typename List<PairData *, AL>::Element *E = p_element->pair_list.front();
while (E) {
-
_pair_check(E->get());
E = E->next();
}
}
_FORCE_INLINE_ void _optimize() {
-
while (root && root->children_count < 2 && !root->elements.size() && !(use_pairs && root->pairable_elements.size())) {
-
Octant *new_root = nullptr;
if (root->children_count == 1) {
-
for (int i = 0; i < 8; i++) {
-
if (root->children[i]) {
new_root = root->children[i];
root->children[i] = nullptr;
@@ -339,7 +294,6 @@ private:
void _unpair_element(Element *p_element, Octant *p_octant);
struct _CullConvexData {
-
const Plane *planes;
int plane_count;
const Vector3 *points;
@@ -356,14 +310,14 @@ private:
void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _remove_tree(Octant *p_octant) {
-
- if (!p_octant)
+ if (!p_octant) {
return;
+ }
for (int i = 0; i < 8; i++) {
-
- if (p_octant->children[i])
+ if (p_octant->children[i]) {
_remove_tree(p_octant->children[i]);
+ }
}
memdelete_allocator<Octant, AL>(p_octant);
@@ -405,7 +359,6 @@ T *Octree<T, use_pairs, AL>::get(OctreeElementID p_id) const {
template <class T, bool use_pairs, class AL>
bool Octree<T, use_pairs, AL>::is_pairable(OctreeElementID p_id) const {
-
const typename ElementMap::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, false);
return E->get().pairable;
@@ -413,7 +366,6 @@ bool Octree<T, use_pairs, AL>::is_pairable(OctreeElementID p_id) const {
template <class T, bool use_pairs, class AL>
int Octree<T, use_pairs, AL>::get_subindex(OctreeElementID p_id) const {
-
const typename ElementMap::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, -1);
return E->get().subindex;
@@ -423,7 +375,6 @@ int Octree<T, use_pairs, AL>::get_subindex(OctreeElementID p_id) const {
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_octant) {
-
real_t element_size = p_element->aabb.get_longest_axis_size() * 1.01; // avoid precision issues
if (p_octant->aabb.size.x / OCTREE_DIVISOR < element_size) {
@@ -434,11 +385,9 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
owner.octant = p_octant;
if (use_pairs && p_element->pairable) {
-
p_octant->pairable_elements.push_back(p_element);
owner.E = p_octant->pairable_elements.back();
} else {
-
p_octant->elements.push_back(p_element);
owner.E = p_octant->elements.back();
}
@@ -453,11 +402,9 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
}
if (use_pairs && p_octant->children_count > 0) {
-
pass++; //elements below this only get ONE reference added
for (int i = 0; i < 8; i++) {
-
if (p_octant->children[i]) {
_pair_element(p_element, p_octant->children[i]);
}
@@ -469,7 +416,6 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
bool candidate = p_element->common_parent == nullptr;
for (int i = 0; i < 8; i++) {
-
if (p_octant->children[i]) {
/* element exists, go straight to it */
if (p_octant->children[i]->aabb.intersects_inclusive(p_element->aabb)) {
@@ -482,12 +428,15 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
AABB aabb = p_octant->aabb;
aabb.size *= 0.5;
- if (i & 1)
+ if (i & 1) {
aabb.position.x += aabb.size.x;
- if (i & 2)
+ }
+ if (i & 2) {
aabb.position.y += aabb.size.y;
- if (i & 4)
+ }
+ if (i & 4) {
aabb.position.z += aabb.size.z;
+ }
if (aabb.intersects_inclusive(p_element->aabb)) {
/* if actually intersects, create the child */
@@ -509,13 +458,11 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
}
if (candidate && splits > 1) {
-
p_element->common_parent = p_octant;
}
}
if (use_pairs) {
-
typename List<Element *, AL>::Element *E = p_octant->pairable_elements.front();
while (E) {
@@ -536,14 +483,12 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
-
if (!root) {
// octre is empty
AABB base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
while (!base.encloses(p_aabb)) {
-
if (ABS(base.position.x + base.size.x) <= ABS(base.position.x)) {
/* grow towards positive */
base.size *= 2.0;
@@ -562,11 +507,9 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
octant_count++;
} else {
-
AABB base = root->aabb;
while (!base.encloses(p_aabb)) {
-
ERR_FAIL_COND_MSG(base.size.x > OCTREE_SIZE_LIMIT, "Octree upper size limit reached, does the AABB supplied contain NAN?");
Octant *gp = memnew_allocator(Octant, AL);
@@ -595,15 +538,14 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
template <class T, bool use_pairs, class AL>
bool Octree<T, use_pairs, AL>::_remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit) {
-
bool octant_removed = false;
while (true) {
-
// check all exit conditions
- if (p_octant == p_limit) // reached limit, nothing to erase, exit
+ if (p_octant == p_limit) { // reached limit, nothing to erase, exit
return octant_removed;
+ }
bool unpaired = false;
@@ -632,7 +574,6 @@ bool Octree<T, use_pairs, AL>::_remove_element_from_octant(Element *p_element, O
Octant *parent = p_octant->parent;
if (p_octant->children_count == 0 && p_octant->elements.empty() && p_octant->pairable_elements.empty()) {
-
// erase octant
if (p_octant == root) { // won't have a parent, just erase
@@ -651,8 +592,9 @@ bool Octree<T, use_pairs, AL>::_remove_element_from_octant(Element *p_element, O
octant_removed = true;
}
- if (!removed && !unpaired)
+ if (!removed && !unpaired) {
return octant_removed; // no reason to keep going up anymore! was already visited and was not removed
+ }
p_octant = parent;
}
@@ -662,7 +604,6 @@ bool Octree<T, use_pairs, AL>::_remove_element_from_octant(Element *p_element, O
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_unpair_element(Element *p_element, Octant *p_octant) {
-
// always test pairable
typename List<Element *, AL>::Element *E = p_octant->pairable_elements.front();
while (E) {
@@ -687,25 +628,24 @@ void Octree<T, use_pairs, AL>::_unpair_element(Element *p_element, Octant *p_oct
p_octant->last_pass = pass;
- if (p_octant->children_count == 0)
+ if (p_octant->children_count == 0) {
return; // small optimization for leafs
+ }
for (int i = 0; i < 8; i++) {
-
- if (p_octant->children[i])
+ if (p_octant->children[i]) {
_unpair_element(p_element, p_octant->children[i]);
+ }
}
}
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_pair_element(Element *p_element, Octant *p_octant) {
-
// always test pairable
typename List<Element *, AL>::Element *E = p_octant->pairable_elements.front();
while (E) {
-
if (E->get()->last_pass != pass) { // only get ONE reference
_pair_reference(p_element, E->get());
E->get()->last_pass = pass;
@@ -726,30 +666,30 @@ void Octree<T, use_pairs, AL>::_pair_element(Element *p_element, Octant *p_octan
}
p_octant->last_pass = pass;
- if (p_octant->children_count == 0)
+ if (p_octant->children_count == 0) {
return; // small optimization for leafs
+ }
for (int i = 0; i < 8; i++) {
-
- if (p_octant->children[i])
+ if (p_octant->children[i]) {
_pair_element(p_element, p_octant->children[i]);
+ }
}
}
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) {
-
pass++; // will do a new pass for this
typename List<typename Element::OctantOwner, AL>::Element *I = p_element->octant_owners.front();
/* FIRST remove going up normally */
for (; I; I = I->next()) {
-
Octant *o = I->get().octant;
- if (!use_pairs) // small speedup
+ if (!use_pairs) { // small speedup
o->elements.erase(I->get().E);
+ }
_remove_element_from_octant(p_element, o);
}
@@ -759,30 +699,28 @@ void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) {
I = p_element->octant_owners.front();
if (use_pairs) {
-
for (; I; I = I->next()) {
-
Octant *o = I->get().octant;
// erase children pairs, they are erased ONCE even if repeated
pass++;
for (int i = 0; i < 8; i++) {
-
- if (o->children[i])
+ if (o->children[i]) {
_unpair_element(p_element, o->children[i]);
+ }
}
- if (p_element->pairable)
+ if (p_element->pairable) {
o->pairable_elements.erase(I->get().E);
- else
+ } else {
o->elements.erase(I->get().E);
+ }
}
}
p_element->octant_owners.clear();
if (use_pairs) {
-
int remaining = p_element->pair_list.size();
//p_element->pair_list.clear();
ERR_FAIL_COND(remaining);
@@ -791,7 +729,6 @@ void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) {
template <class T, bool use_pairs, class AL>
OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
-
// check for AABB validity
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V(p_aabb.position.x > 1e15 || p_aabb.position.x < -1e15, 0);
@@ -822,8 +759,9 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aa
if (!e.aabb.has_no_surface()) {
_ensure_valid_root(p_aabb);
_insert_element(&e, root);
- if (use_pairs)
+ if (use_pairs) {
_element_check_pairs(&e);
+ }
}
return last_element_id - 1;
@@ -831,7 +769,6 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aa
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
-
#ifdef DEBUG_ENABLED
// check for AABB validity
ERR_FAIL_COND(p_aabb.position.x > 1e15 || p_aabb.position.x < -1e15);
@@ -852,7 +789,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
bool new_has_surf = !p_aabb.has_no_surface();
if (old_has_surf != new_has_surf) {
-
if (old_has_surf) {
_remove_element(&e); // removing
e.common_parent = nullptr;
@@ -863,22 +799,24 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
e.common_parent = nullptr;
e.aabb = p_aabb;
_insert_element(&e, root);
- if (use_pairs)
+ if (use_pairs) {
_element_check_pairs(&e);
+ }
}
return;
}
- if (!old_has_surf) // doing nothing
+ if (!old_has_surf) { // doing nothing
return;
+ }
// it still is enclosed in the same AABB it was assigned to
if (e.container_aabb.encloses(p_aabb)) {
-
e.aabb = p_aabb;
- if (use_pairs)
+ if (use_pairs) {
_element_check_pairs(&e); // must check pairs anyway
+ }
return;
}
@@ -898,8 +836,9 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
//src is now the place towards where insertion is going to happen
pass++;
- while (common_parent && !common_parent->aabb.encloses(p_aabb))
+ while (common_parent && !common_parent->aabb.encloses(p_aabb)) {
common_parent = common_parent->parent;
+ }
ERR_FAIL_COND(!common_parent);
@@ -913,7 +852,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
pass++;
for (typename List<typename Element::OctantOwner, AL>::Element *F = owners.front(); F;) {
-
Octant *o = F->get().octant;
typename List<typename Element::OctantOwner, AL>::Element *N = F->next();
@@ -922,13 +860,13 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
o->elements.erase( F->get().E );
*/
- if (use_pairs && e.pairable)
+ if (use_pairs && e.pairable) {
o->pairable_elements.erase(F->get().E);
- else
+ } else {
o->elements.erase(F->get().E);
+ }
if (_remove_element_from_octant(&e, o, common_parent->parent)) {
-
owners.erase(F);
}
@@ -938,15 +876,14 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
if (use_pairs) {
//unpair child elements in anything that survived
for (typename List<typename Element::OctantOwner, AL>::Element *F = owners.front(); F; F = F->next()) {
-
Octant *o = F->get().octant;
// erase children pairs, unref ONCE
pass++;
for (int i = 0; i < 8; i++) {
-
- if (o->children[i])
+ if (o->children[i]) {
_unpair_element(&e, o->children[i]);
+ }
}
}
@@ -958,14 +895,14 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::set_pairable(OctreeElementID p_id, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
-
typename ElementMap::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
Element &e = E->get();
- if (p_pairable == e.pairable && e.pairable_type == p_pairable_type && e.pairable_mask == p_pairable_mask)
+ if (p_pairable == e.pairable && e.pairable_type == p_pairable_type && e.pairable_mask == p_pairable_mask) {
return; // no changes, return
+ }
if (!e.aabb.has_no_surface()) {
_remove_element(&e);
@@ -979,21 +916,20 @@ void Octree<T, use_pairs, AL>::set_pairable(OctreeElementID p_id, bool p_pairabl
if (!e.aabb.has_no_surface()) {
_ensure_valid_root(e.aabb);
_insert_element(&e, root);
- if (use_pairs)
+ if (use_pairs) {
_element_check_pairs(&e);
+ }
}
}
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::erase(OctreeElementID p_id) {
-
typename ElementMap::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
Element &e = E->get();
if (!e.aabb.has_no_surface()) {
-
_remove_element(&e);
}
@@ -1003,21 +939,20 @@ void Octree<T, use_pairs, AL>::erase(OctreeElementID p_id) {
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p_cull) {
-
- if (*p_cull->result_idx == p_cull->result_max)
+ if (*p_cull->result_idx == p_cull->result_max) {
return; //pointless
+ }
if (!p_octant->elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_cull->mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_cull->mask))) {
continue;
+ }
e->last_pass = pass;
if (e->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count, p_cull->points, p_cull->point_count)) {
@@ -1025,7 +960,6 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
p_cull->result_array[*p_cull->result_idx] = e->userdata;
(*p_cull->result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1033,26 +967,22 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
}
if (use_pairs && !p_octant->pairable_elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->pairable_elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_cull->mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_cull->mask))) {
continue;
+ }
e->last_pass = pass;
if (e->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count, p_cull->points, p_cull->point_count)) {
-
if (*p_cull->result_idx < p_cull->result_max) {
-
p_cull->result_array[*p_cull->result_idx] = e->userdata;
(*p_cull->result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1060,7 +990,6 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
}
for (int i = 0; i < 8; i++) {
-
if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_convex_shape(p_cull->planes, p_cull->plane_count, p_cull->points, p_cull->point_count)) {
_cull_convex(p_octant->children[i], p_cull);
}
@@ -1069,33 +998,30 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
-
- if (*p_result_idx == p_result_max)
+ if (*p_result_idx == p_result_max) {
return; //pointless
+ }
if (!p_octant->elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask))) {
continue;
+ }
e->last_pass = pass;
if (p_aabb.intersects_inclusive(e->aabb)) {
-
if (*p_result_idx < p_result_max) {
-
p_result_array[*p_result_idx] = e->userdata;
- if (p_subindex_array)
+ if (p_subindex_array) {
p_subindex_array[*p_result_idx] = e->subindex;
+ }
(*p_result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1103,27 +1029,24 @@ void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb,
}
if (use_pairs && !p_octant->pairable_elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->pairable_elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask))) {
continue;
+ }
e->last_pass = pass;
if (p_aabb.intersects_inclusive(e->aabb)) {
-
if (*p_result_idx < p_result_max) {
-
p_result_array[*p_result_idx] = e->userdata;
- if (p_subindex_array)
+ if (p_subindex_array) {
p_subindex_array[*p_result_idx] = e->subindex;
+ }
(*p_result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1131,7 +1054,6 @@ void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb,
}
for (int i = 0; i < 8; i++) {
-
if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_inclusive(p_aabb)) {
_cull_aabb(p_octant->children[i], p_aabb, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask);
}
@@ -1140,33 +1062,30 @@ void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb,
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
-
- if (*p_result_idx == p_result_max)
+ if (*p_result_idx == p_result_max) {
return; //pointless
+ }
if (!p_octant->elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask))) {
continue;
+ }
e->last_pass = pass;
if (e->aabb.intersects_segment(p_from, p_to)) {
-
if (*p_result_idx < p_result_max) {
-
p_result_array[*p_result_idx] = e->userdata;
- if (p_subindex_array)
+ if (p_subindex_array) {
p_subindex_array[*p_result_idx] = e->subindex;
+ }
(*p_result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1174,30 +1093,27 @@ void Octree<T, use_pairs, AL>::_cull_segment(Octant *p_octant, const Vector3 &p_
}
if (use_pairs && !p_octant->pairable_elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->pairable_elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask))) {
continue;
+ }
e->last_pass = pass;
if (e->aabb.intersects_segment(p_from, p_to)) {
-
if (*p_result_idx < p_result_max) {
-
p_result_array[*p_result_idx] = e->userdata;
- if (p_subindex_array)
+ if (p_subindex_array) {
p_subindex_array[*p_result_idx] = e->subindex;
+ }
(*p_result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1205,7 +1121,6 @@ void Octree<T, use_pairs, AL>::_cull_segment(Octant *p_octant, const Vector3 &p_
}
for (int i = 0; i < 8; i++) {
-
if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_segment(p_from, p_to)) {
_cull_segment(p_octant->children[i], p_from, p_to, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask);
}
@@ -1214,33 +1129,30 @@ void Octree<T, use_pairs, AL>::_cull_segment(Octant *p_octant, const Vector3 &p_
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::_cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
-
- if (*p_result_idx == p_result_max)
+ if (*p_result_idx == p_result_max) {
return; //pointless
+ }
if (!p_octant->elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask))) {
continue;
+ }
e->last_pass = pass;
if (e->aabb.has_point(p_point)) {
-
if (*p_result_idx < p_result_max) {
-
p_result_array[*p_result_idx] = e->userdata;
- if (p_subindex_array)
+ if (p_subindex_array) {
p_subindex_array[*p_result_idx] = e->subindex;
+ }
(*p_result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1248,30 +1160,27 @@ void Octree<T, use_pairs, AL>::_cull_point(Octant *p_octant, const Vector3 &p_po
}
if (use_pairs && !p_octant->pairable_elements.empty()) {
-
typename List<Element *, AL>::Element *I;
I = p_octant->pairable_elements.front();
for (; I; I = I->next()) {
-
Element *e = I->get();
- if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask)))
+ if (e->last_pass == pass || (use_pairs && !(e->pairable_type & p_mask))) {
continue;
+ }
e->last_pass = pass;
if (e->aabb.has_point(p_point)) {
-
if (*p_result_idx < p_result_max) {
-
p_result_array[*p_result_idx] = e->userdata;
- if (p_subindex_array)
+ if (p_subindex_array) {
p_subindex_array[*p_result_idx] = e->subindex;
+ }
(*p_result_idx)++;
} else {
-
return; // pointless to continue
}
}
@@ -1279,7 +1188,6 @@ void Octree<T, use_pairs, AL>::_cull_point(Octant *p_octant, const Vector3 &p_po
}
for (int i = 0; i < 8; i++) {
-
//could be optimized..
if (p_octant->children[i] && p_octant->children[i]->aabb.has_point(p_point)) {
_cull_point(p_octant->children[i], p_point, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask);
@@ -1289,13 +1197,14 @@ void Octree<T, use_pairs, AL>::_cull_point(Octant *p_octant, const Vector3 &p_po
template <class T, bool use_pairs, class AL>
int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask) {
-
- if (!root || p_convex.size() == 0)
+ if (!root || p_convex.size() == 0) {
return 0;
+ }
- Vector<Vector3> convex_points = Geometry::compute_convex_mesh_points(&p_convex[0], p_convex.size());
- if (convex_points.size() == 0)
+ Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(&p_convex[0], p_convex.size());
+ if (convex_points.size() == 0) {
return 0;
+ }
int result_count = 0;
pass++;
@@ -1316,9 +1225,9 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r
template <class T, bool use_pairs, class AL>
int Octree<T, use_pairs, AL>::cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
-
- if (!root)
+ if (!root) {
return 0;
+ }
int result_count = 0;
pass++;
@@ -1329,9 +1238,9 @@ int Octree<T, use_pairs, AL>::cull_aabb(const AABB &p_aabb, T **p_result_array,
template <class T, bool use_pairs, class AL>
int Octree<T, use_pairs, AL>::cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
-
- if (!root)
+ if (!root) {
return 0;
+ }
int result_count = 0;
pass++;
@@ -1342,9 +1251,9 @@ int Octree<T, use_pairs, AL>::cull_segment(const Vector3 &p_from, const Vector3
template <class T, bool use_pairs, class AL>
int Octree<T, use_pairs, AL>::cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
-
- if (!root)
+ if (!root) {
return 0;
+ }
int result_count = 0;
pass++;
@@ -1355,20 +1264,18 @@ int Octree<T, use_pairs, AL>::cull_point(const Vector3 &p_point, T **p_result_ar
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::set_pair_callback(PairCallback p_callback, void *p_userdata) {
-
pair_callback = p_callback;
pair_callback_userdata = p_userdata;
}
+
template <class T, bool use_pairs, class AL>
void Octree<T, use_pairs, AL>::set_unpair_callback(UnpairCallback p_callback, void *p_userdata) {
-
unpair_callback = p_callback;
unpair_callback_userdata = p_userdata;
}
template <class T, bool use_pairs, class AL>
Octree<T, use_pairs, AL>::Octree(real_t p_unit_size) {
-
last_element_id = 1;
pass = 1;
unit_size = p_unit_size;
diff --git a/core/math/plane.cpp b/core/math/plane.cpp
index 26ac0aac47..df37ceb0e5 100644
--- a/core/math/plane.cpp
+++ b/core/math/plane.cpp
@@ -33,12 +33,10 @@
#include "core/math/math_funcs.h"
void Plane::set_normal(const Vector3 &p_normal) {
-
normal = p_normal;
}
void Plane::normalize() {
-
real_t l = normal.length();
if (l == 0) {
*this = Plane(0, 0, 0, 0);
@@ -49,27 +47,25 @@ void Plane::normalize() {
}
Plane Plane::normalized() const {
-
Plane p = *this;
p.normalize();
return p;
}
Vector3 Plane::get_any_point() const {
-
return get_normal() * d;
}
Vector3 Plane::get_any_perpendicular_normal() const {
-
static const Vector3 p1 = Vector3(1, 0, 0);
static const Vector3 p2 = Vector3(0, 1, 0);
Vector3 p;
- if (ABS(normal.dot(p1)) > 0.99) // if too similar to p1
+ if (ABS(normal.dot(p1)) > 0.99) { // if too similar to p1
p = p2; // use p2
- else
+ } else {
p = p1; // use p1
+ }
p -= normal * normal.dot(p);
p.normalize();
@@ -80,7 +76,6 @@ Vector3 Plane::get_any_perpendicular_normal() const {
/* intersections */
bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result) const {
-
const Plane &p_plane0 = *this;
Vector3 normal0 = p_plane0.normal;
Vector3 normal1 = p_plane1.normal;
@@ -88,8 +83,9 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r
real_t denom = vec3_cross(normal0, normal1).dot(normal2);
- if (Math::is_zero_approx(denom))
+ if (Math::is_zero_approx(denom)) {
return false;
+ }
if (r_result) {
*r_result = ((vec3_cross(normal1, normal2) * p_plane0.d) +
@@ -102,13 +98,11 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r
}
bool Plane::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const {
-
Vector3 segment = p_dir;
real_t den = normal.dot(segment);
//printf("den is %i\n",den);
if (Math::is_zero_approx(den)) {
-
return false;
}
@@ -127,13 +121,11 @@ bool Plane::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3
}
bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const {
-
Vector3 segment = p_begin - p_end;
real_t den = normal.dot(segment);
//printf("den is %i\n",den);
if (Math::is_zero_approx(den)) {
-
return false;
}
@@ -141,7 +133,6 @@ bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vec
//printf("dist is %i\n",dist);
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
-
return false;
}
@@ -158,11 +149,9 @@ bool Plane::is_equal_approx_any_side(const Plane &p_plane) const {
}
bool Plane::is_equal_approx(const Plane &p_plane) const {
-
return normal.is_equal_approx(p_plane.normal) && Math::is_equal_approx(d, p_plane.d);
}
Plane::operator String() const {
-
return normal.operator String() + ", " + rtos(d);
}
diff --git a/core/math/plane.h b/core/math/plane.h
index d4f23ff2b6..9a3e5a485f 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -36,7 +36,7 @@
class Plane {
public:
Vector3 normal;
- real_t d;
+ real_t d = 0;
void set_normal(const Vector3 &p_normal);
_FORCE_INLINE_ Vector3 get_normal() const { return normal; }; ///Point is coplanar, CMP_EPSILON for precision
@@ -56,12 +56,11 @@ public:
/* intersections */
- bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = 0) const;
+ bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = nullptr) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const;
bool intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const;
_FORCE_INLINE_ Vector3 project(const Vector3 &p_point) const {
-
return p_point - normal * distance_to(p_point);
}
@@ -75,8 +74,7 @@ public:
_FORCE_INLINE_ bool operator!=(const Plane &p_plane) const;
operator String() const;
- _FORCE_INLINE_ Plane() :
- d(0) {}
+ _FORCE_INLINE_ Plane() {}
_FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) :
normal(p_a, p_b, p_c),
d(p_d) {}
@@ -87,17 +85,14 @@ public:
};
bool Plane::is_point_over(const Vector3 &p_point) const {
-
return (normal.dot(p_point) > d);
}
real_t Plane::distance_to(const Vector3 &p_point) const {
-
return (normal.dot(p_point) - d);
}
bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
-
real_t dist = normal.dot(p_point) - d;
dist = ABS(dist);
return (dist <= _epsilon);
@@ -114,23 +109,21 @@ Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) :
}
Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) {
-
- if (p_dir == CLOCKWISE)
+ if (p_dir == CLOCKWISE) {
normal = (p_point1 - p_point3).cross(p_point1 - p_point2);
- else
+ } else {
normal = (p_point1 - p_point2).cross(p_point1 - p_point3);
+ }
normal.normalize();
d = normal.dot(p_point1);
}
bool Plane::operator==(const Plane &p_plane) const {
-
return normal == p_plane.normal && d == p_plane.d;
}
bool Plane::operator!=(const Plane &p_plane) const {
-
return normal != p_plane.normal || d != p_plane.d;
}
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 6fbea70279..c10f5da494 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -107,7 +107,6 @@ Vector3 Quat::get_euler_yxz() const {
}
void Quat::operator*=(const Quat &q) {
-
set(w * q.x + x * q.w + y * q.z - z * q.y,
w * q.y + y * q.w + z * q.x - x * q.z,
w * q.z + z * q.w + x * q.y - y * q.x,
@@ -115,19 +114,16 @@ void Quat::operator*=(const Quat &q) {
}
Quat Quat::operator*(const Quat &q) const {
-
Quat r = *this;
r *= q;
return r;
}
bool Quat::is_equal_approx(const Quat &p_quat) const {
-
return Math::is_equal_approx(x, p_quat.x) && Math::is_equal_approx(y, p_quat.y) && Math::is_equal_approx(z, p_quat.z) && Math::is_equal_approx(w, p_quat.w);
}
real_t Quat::length() const {
-
return Math::sqrt(length_squared());
}
@@ -206,8 +202,9 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const {
real_t dot = from.dot(q);
- if (Math::absf(dot) > 0.9999)
+ if (Math::absf(dot) > 0.9999) {
return from;
+ }
real_t theta = Math::acos(dot),
sinT = 1.0 / Math::sin(theta),
@@ -233,7 +230,6 @@ Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const
}
Quat::operator String() const {
-
return String::num(x) + ", " + String::num(y) + ", " + String::num(z) + ", " + String::num(w);
}
@@ -242,9 +238,9 @@ void Quat::set_axis_angle(const Vector3 &axis, const real_t &angle) {
ERR_FAIL_COND_MSG(!axis.is_normalized(), "The axis Vector3 must be normalized.");
#endif
real_t d = axis.length();
- if (d == 0)
+ if (d == 0) {
set(0, 0, 0, 0);
- else {
+ } else {
real_t sin_angle = Math::sin(angle * 0.5);
real_t cos_angle = Math::cos(angle * 0.5);
real_t s = sin_angle / d;
diff --git a/core/math/quat.h b/core/math/quat.h
index b3135ad1ca..64d0f00912 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -40,7 +40,7 @@
class Quat {
public:
- real_t x, y, z, w;
+ real_t x = 0, y = 0, z = 0, w = 1;
_FORCE_INLINE_ real_t length_squared() const;
bool is_equal_approx(const Quat &p_quat) const;
@@ -112,7 +112,9 @@ public:
z = p_z;
w = p_w;
}
- inline Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) :
+
+ _FORCE_INLINE_ Quat() {}
+ _FORCE_INLINE_ Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) :
x(p_x),
y(p_y),
z(p_z),
@@ -147,7 +149,6 @@ public:
z = 0;
w = 0;
} else {
-
real_t s = Math::sqrt((1.0 + d) * 2.0);
real_t rs = 1.0 / s;
@@ -157,13 +158,6 @@ public:
w = s * 0.5;
}
}
-
- inline Quat() :
- x(0),
- y(0),
- z(0),
- w(1) {
- }
};
real_t Quat::dot(const Quat &q) const {
@@ -196,7 +190,6 @@ void Quat::operator*=(const real_t &s) {
}
void Quat::operator/=(const real_t &s) {
-
*this *= 1.0 / s;
}
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 7fbb26c377..8ba1ba9286 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -34,13 +34,11 @@
uint32_t QuickHull::debug_stop_after = 0xFFFFFFFF;
-Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_mesh) {
-
+Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_mesh) {
/* CREATE AABB VOLUME */
AABB aabb;
for (int i = 0; i < p_points.size(); i++) {
-
if (i == 0) {
aabb.position = p_points[i];
} else {
@@ -57,7 +55,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Set<Vector3> valid_cache;
for (int i = 0; i < p_points.size(); i++) {
-
Vector3 sp = p_points[i].snapped(Vector3(0.0001, 0.0001, 0.0001));
if (valid_cache.has(sp)) {
valid_points.write[i] = false;
@@ -78,12 +75,11 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
real_t max = 0, min = 0;
for (int i = 0; i < p_points.size(); i++) {
-
- if (!valid_points[i])
+ if (!valid_points[i]) {
continue;
+ }
real_t d = p_points[i][longest_axis];
if (i == 0 || d < min) {
-
simplex[0] = i;
min = d;
}
@@ -102,15 +98,14 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Vector3 rel12 = p_points[simplex[0]] - p_points[simplex[1]];
for (int i = 0; i < p_points.size(); i++) {
-
- if (!valid_points[i])
+ if (!valid_points[i]) {
continue;
+ }
Vector3 n = rel12.cross(p_points[simplex[0]] - p_points[i]).cross(rel12).normalized();
real_t d = Math::abs(n.dot(p_points[simplex[0]]) - n.dot(p_points[i]));
if (i == 0 || d > maxd) {
-
maxd = d;
simplex[2] = i;
}
@@ -124,14 +119,13 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Plane p(p_points[simplex[0]], p_points[simplex[1]], p_points[simplex[2]]);
for (int i = 0; i < p_points.size(); i++) {
-
- if (!valid_points[i])
+ if (!valid_points[i]) {
continue;
+ }
real_t d = Math::abs(p.distance_to(p_points[i]));
if (i == 0 || d > maxd) {
-
maxd = d;
simplex[3] = i;
}
@@ -152,7 +146,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
List<Face> faces;
for (int i = 0; i < 4; i++) {
-
static const int face_order[4][3] = {
{ 0, 1, 2 },
{ 0, 1, 3 },
@@ -183,22 +176,24 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
/* COMPUTE AVAILABLE VERTICES */
for (int i = 0; i < p_points.size(); i++) {
-
- if (i == simplex[0])
+ if (i == simplex[0]) {
continue;
- if (i == simplex[1])
+ }
+ if (i == simplex[1]) {
continue;
- if (i == simplex[2])
+ }
+ if (i == simplex[2]) {
continue;
- if (i == simplex[3])
+ }
+ if (i == simplex[3]) {
continue;
- if (!valid_points[i])
+ }
+ if (!valid_points[i]) {
continue;
+ }
for (List<Face>::Element *E = faces.front(); E; E = E->next()) {
-
if (E->get().plane.distance_to(p_points[i]) > over_tolerance) {
-
E->get().points_over.push_back(i);
break;
}
@@ -219,7 +214,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
uint32_t debug_stop = debug_stop_after;
while (debug_stop > 0 && faces.back()->get().points_over.size()) {
-
debug_stop--;
Face &f = faces.back()->get();
@@ -228,7 +222,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
real_t next_d = 0;
for (int i = 0; i < f.points_over.size(); i++) {
-
real_t d = f.plane.distance_to(p_points[f.points_over[i]]);
if (d > next_d) {
@@ -247,9 +240,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Map<Edge, FaceConnect> lit_edges; //create this on the flight, should not be that bad for performance and simplifies code a lot
for (List<Face>::Element *E = faces.front(); E; E = E->next()) {
-
if (E->get().plane.distance_to(v) > 0) {
-
lit_faces.push_back(E);
for (int i = 0; i < 3; i++) {
@@ -265,7 +256,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//left
F->get().left = E;
} else {
-
F->get().right = E;
}
}
@@ -276,7 +266,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
List<List<Face>::Element *> new_faces; //new faces
for (Map<Edge, FaceConnect>::Element *E = lit_edges.front(); E; E = E->next()) {
-
FaceConnect &fc = E->get();
if (fc.left && fc.right) {
continue; //edge is uninteresting, not on horizont
@@ -304,17 +293,15 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//distribute points into new faces
for (List<List<Face>::Element *>::Element *F = lit_faces.front(); F; F = F->next()) {
-
Face &lf = F->get()->get();
for (int i = 0; i < lf.points_over.size(); i++) {
-
- if (lf.points_over[i] == f.points_over[next]) //do not add current one
+ if (lf.points_over[i] == f.points_over[next]) { //do not add current one
continue;
+ }
Vector3 p = p_points[lf.points_over[i]];
for (List<List<Face>::Element *>::Element *E = new_faces.front(); E; E = E->next()) {
-
Face &f2 = E->get()->get();
if (f2.plane.distance_to(p) > over_tolerance) {
f2.points_over.push_back(lf.points_over[i]);
@@ -327,7 +314,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//erase lit faces
while (lit_faces.size()) {
-
faces.erase(lit_faces.front()->get());
lit_faces.pop_front();
}
@@ -335,7 +321,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//put faces that contain no points on the front
for (List<List<Face>::Element *>::Element *E = new_faces.front(); E; E = E->next()) {
-
Face &f2 = E->get()->get();
if (f2.points_over.size() == 0) {
faces.move_to_front(E->get());
@@ -349,21 +334,19 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//make a map of edges again
Map<Edge, RetFaceConnect> ret_edges;
- List<Geometry::MeshData::Face> ret_faces;
+ List<Geometry3D::MeshData::Face> ret_faces;
for (List<Face>::Element *E = faces.front(); E; E = E->next()) {
-
- Geometry::MeshData::Face f;
+ Geometry3D::MeshData::Face f;
f.plane = E->get().plane;
for (int i = 0; i < 3; i++) {
f.indices.push_back(E->get().vertices[i]);
}
- List<Geometry::MeshData::Face>::Element *F = ret_faces.push_back(f);
+ List<Geometry3D::MeshData::Face>::Element *F = ret_faces.push_back(f);
for (int i = 0; i < 3; i++) {
-
uint32_t a = E->get().vertices[i];
uint32_t b = E->get().vertices[(i + 1) % 3];
Edge e(a, b);
@@ -376,7 +359,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//left
G->get().left = F;
} else {
-
G->get().right = F;
}
}
@@ -384,12 +366,10 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//fill faces
- for (List<Geometry::MeshData::Face>::Element *E = ret_faces.front(); E; E = E->next()) {
-
- Geometry::MeshData::Face &f = E->get();
+ for (List<Geometry3D::MeshData::Face>::Element *E = ret_faces.front(); E; E = E->next()) {
+ Geometry3D::MeshData::Face &f = E->get();
for (int i = 0; i < f.indices.size(); i++) {
-
int a = E->get().indices[i];
int b = E->get().indices[(i + 1) % f.indices.size()];
Edge e(a, b);
@@ -397,7 +377,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Map<Edge, RetFaceConnect>::Element *F = ret_edges.find(e);
ERR_CONTINUE(!F);
- List<Geometry::MeshData::Face>::Element *O = F->get().left == E ? F->get().right : F->get().left;
+ List<Geometry3D::MeshData::Face>::Element *O = F->get().left == E ? F->get().right : F->get().left;
ERR_CONTINUE(O == E);
ERR_CONTINUE(O == nullptr);
@@ -411,7 +391,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
if (O->get().indices[j] == a) {
//append the rest
for (int k = 0; k < ois; k++) {
-
int idx = O->get().indices[(k + j) % ois];
int idxn = O->get().indices[(k + j + 1) % ois];
if (idx == b && idxn == a) { //already have b!
@@ -427,10 +406,11 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Map<Edge, RetFaceConnect>::Element *F2 = ret_edges.find(e2);
ERR_CONTINUE(!F2);
//change faceconnect, point to this face instead
- if (F2->get().left == O)
+ if (F2->get().left == O) {
F2->get().left = E;
- else if (F2->get().right == O)
+ } else if (F2->get().right == O) {
F2->get().right = E;
+ }
}
break;
@@ -439,11 +419,13 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
// remove all edge connections to this face
for (Map<Edge, RetFaceConnect>::Element *G = ret_edges.front(); G; G = G->next()) {
- if (G->get().left == O)
+ if (G->get().left == O) {
G->get().left = nullptr;
+ }
- if (G->get().right == O)
+ if (G->get().right == O) {
G->get().right = nullptr;
+ }
}
ret_edges.erase(F); //remove the edge
@@ -457,14 +439,13 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
r_mesh.faces.resize(ret_faces.size());
int idx = 0;
- for (List<Geometry::MeshData::Face>::Element *E = ret_faces.front(); E; E = E->next()) {
+ for (List<Geometry3D::MeshData::Face>::Element *E = ret_faces.front(); E; E = E->next()) {
r_mesh.faces.write[idx++] = E->get();
}
r_mesh.edges.resize(ret_edges.size());
idx = 0;
for (Map<Edge, RetFaceConnect>::Element *E = ret_edges.front(); E; E = E->next()) {
-
- Geometry::MeshData::Edge e;
+ Geometry3D::MeshData::Edge e;
e.a = E->key().vertices[0];
e.b = E->key().vertices[1];
r_mesh.edges.write[idx++] = e;
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index 173f919a73..cac8e58d23 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -33,14 +33,12 @@
#include "core/list.h"
#include "core/math/aabb.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/set.h"
class QuickHull {
-
public:
struct Edge {
-
union {
uint32_t vertices[2];
uint64_t id;
@@ -51,7 +49,6 @@ public:
}
Edge(int p_vtx_a = 0, int p_vtx_b = 0) {
-
if (p_vtx_a > p_vtx_b) {
SWAP(p_vtx_a, p_vtx_b);
}
@@ -62,36 +59,28 @@ public:
};
struct Face {
-
Plane plane;
uint32_t vertices[3];
Vector<int> points_over;
bool operator<(const Face &p_face) const {
-
return points_over.size() < p_face.points_over.size();
}
};
private:
struct FaceConnect {
- List<Face>::Element *left, *right;
- FaceConnect() {
- left = nullptr;
- right = nullptr;
- }
+ List<Face>::Element *left, *right = nullptr;
+ FaceConnect() {}
};
struct RetFaceConnect {
- List<Geometry::MeshData::Face>::Element *left, *right;
- RetFaceConnect() {
- left = nullptr;
- right = nullptr;
- }
+ List<Geometry3D::MeshData::Face>::Element *left, *right = nullptr;
+ RetFaceConnect() {}
};
public:
static uint32_t debug_stop_after;
- static Error build(const Vector<Vector3> &p_points, Geometry::MeshData &r_mesh);
+ static Error build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_mesh);
};
#endif // QUICK_HULL_H
diff --git a/core/math/random_number_generator.cpp b/core/math/random_number_generator.cpp
index 1a1bffb562..67f4c0b14a 100644
--- a/core/math/random_number_generator.cpp
+++ b/core/math/random_number_generator.cpp
@@ -30,8 +30,6 @@
#include "random_number_generator.h"
-RandomNumberGenerator::RandomNumberGenerator() {}
-
void RandomNumberGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &RandomNumberGenerator::set_seed);
ClassDB::bind_method(D_METHOD("get_seed"), &RandomNumberGenerator::get_seed);
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h
index e7f188bb42..920308e597 100644
--- a/core/math/random_number_generator.h
+++ b/core/math/random_number_generator.h
@@ -59,13 +59,14 @@ public:
_FORCE_INLINE_ int randi_range(int from, int to) {
unsigned int ret = randbase.rand();
- if (to < from)
+ if (to < from) {
return ret % (from - to + 1) + to;
- else
+ } else {
return ret % (to - from + 1) + from;
+ }
}
- RandomNumberGenerator();
+ RandomNumberGenerator() {}
};
#endif // RANDOM_NUMBER_GENERATOR_H
diff --git a/core/math/rect2.cpp b/core/math/rect2.cpp
index 12b9904c88..0cc3c4ca0f 100644
--- a/core/math/rect2.cpp
+++ b/core/math/rect2.cpp
@@ -31,12 +31,10 @@
#include "core/math/transform_2d.h" // Includes rect2.h but Rect2 needs Transform2D
bool Rect2::is_equal_approx(const Rect2 &p_rect) const {
-
return position.is_equal_approx(p_rect.position) && size.is_equal_approx(p_rect.size);
}
bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos, Point2 *r_normal) const {
-
real_t min = 0, max = 1;
int axis = 0;
real_t sign = 0;
@@ -50,18 +48,18 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
real_t csign;
if (seg_from < seg_to) {
-
- if (seg_from > box_end || seg_to < box_begin)
+ if (seg_from > box_end || seg_to < box_begin) {
return false;
+ }
real_t length = seg_to - seg_from;
cmin = (seg_from < box_begin) ? ((box_begin - seg_from) / length) : 0;
cmax = (seg_to > box_end) ? ((box_end - seg_from) / length) : 1;
csign = -1.0;
} else {
-
- if (seg_to > box_end || seg_from < box_begin)
+ if (seg_to > box_end || seg_from < box_begin) {
return false;
+ }
real_t length = seg_to - seg_from;
cmin = (seg_from > box_end) ? (box_end - seg_from) / length : 0;
cmax = (seg_to < box_begin) ? (box_begin - seg_from) / length : 1;
@@ -73,10 +71,12 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
axis = i;
sign = csign;
}
- if (cmax < max)
+ if (cmax < max) {
max = cmax;
- if (max < min)
+ }
+ if (max < min) {
return false;
+ }
}
Vector2 rel = p_to - p_from;
@@ -87,14 +87,14 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
*r_normal = normal;
}
- if (r_pos)
+ if (r_pos) {
*r_pos = p_from + rel * min;
+ }
return true;
}
bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const {
-
//SAT intersection between local and transformed rect2
Vector2 xf_points[4] = {
@@ -108,14 +108,18 @@ bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_re
//base rect2 first (faster)
- if (xf_points[0].y > position.y)
+ if (xf_points[0].y > position.y) {
goto next1;
- if (xf_points[1].y > position.y)
+ }
+ if (xf_points[1].y > position.y) {
goto next1;
- if (xf_points[2].y > position.y)
+ }
+ if (xf_points[2].y > position.y) {
goto next1;
- if (xf_points[3].y > position.y)
+ }
+ if (xf_points[3].y > position.y) {
goto next1;
+ }
return false;
@@ -123,27 +127,35 @@ next1:
low_limit = position.y + size.y;
- if (xf_points[0].y < low_limit)
+ if (xf_points[0].y < low_limit) {
goto next2;
- if (xf_points[1].y < low_limit)
+ }
+ if (xf_points[1].y < low_limit) {
goto next2;
- if (xf_points[2].y < low_limit)
+ }
+ if (xf_points[2].y < low_limit) {
goto next2;
- if (xf_points[3].y < low_limit)
+ }
+ if (xf_points[3].y < low_limit) {
goto next2;
+ }
return false;
next2:
- if (xf_points[0].x > position.x)
+ if (xf_points[0].x > position.x) {
goto next3;
- if (xf_points[1].x > position.x)
+ }
+ if (xf_points[1].x > position.x) {
goto next3;
- if (xf_points[2].x > position.x)
+ }
+ if (xf_points[2].x > position.x) {
goto next3;
- if (xf_points[3].x > position.x)
+ }
+ if (xf_points[3].x > position.x) {
goto next3;
+ }
return false;
@@ -151,14 +163,18 @@ next3:
low_limit = position.x + size.x;
- if (xf_points[0].x < low_limit)
+ if (xf_points[0].x < low_limit) {
goto next4;
- if (xf_points[1].x < low_limit)
+ }
+ if (xf_points[1].x < low_limit) {
goto next4;
- if (xf_points[2].x < low_limit)
+ }
+ if (xf_points[2].x < low_limit) {
goto next4;
- if (xf_points[3].x < low_limit)
+ }
+ if (xf_points[3].x < low_limit) {
goto next4;
+ }
return false;
@@ -201,10 +217,12 @@ next4:
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
- if (mina > maxb)
+ if (mina > maxb) {
return false;
- if (minb > maxa)
+ }
+ if (minb > maxa) {
return false;
+ }
maxa = p_xform.elements[1].dot(xf_points2[0]);
mina = maxa;
@@ -236,10 +254,12 @@ next4:
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
- if (mina > maxb)
+ if (mina > maxb) {
return false;
- if (minb > maxa)
+ }
+ if (minb > maxa) {
return false;
+ }
return true;
}
diff --git a/core/math/rect2.h b/core/math/rect2.h
index 30dbfdbbe5..14393325ec 100644
--- a/core/math/rect2.h
+++ b/core/math/rect2.h
@@ -36,7 +36,6 @@
struct Transform2D;
struct Rect2 {
-
Point2 position;
Size2 size;
@@ -49,30 +48,37 @@ struct Rect2 {
inline bool intersects(const Rect2 &p_rect, const bool p_include_borders = false) const {
if (p_include_borders) {
- if (position.x > (p_rect.position.x + p_rect.size.width))
+ if (position.x > (p_rect.position.x + p_rect.size.width)) {
return false;
- if ((position.x + size.width) < p_rect.position.x)
+ }
+ if ((position.x + size.width) < p_rect.position.x) {
return false;
- if (position.y > (p_rect.position.y + p_rect.size.height))
+ }
+ if (position.y > (p_rect.position.y + p_rect.size.height)) {
return false;
- if ((position.y + size.height) < p_rect.position.y)
+ }
+ if ((position.y + size.height) < p_rect.position.y) {
return false;
+ }
} else {
- if (position.x >= (p_rect.position.x + p_rect.size.width))
+ if (position.x >= (p_rect.position.x + p_rect.size.width)) {
return false;
- if ((position.x + size.width) <= p_rect.position.x)
+ }
+ if ((position.x + size.width) <= p_rect.position.x) {
return false;
- if (position.y >= (p_rect.position.y + p_rect.size.height))
+ }
+ if (position.y >= (p_rect.position.y + p_rect.size.height)) {
return false;
- if ((position.y + size.height) <= p_rect.position.y)
+ }
+ if ((position.y + size.height) <= p_rect.position.y) {
return false;
+ }
}
return true;
}
inline real_t distance_to(const Vector2 &p_point) const {
-
real_t dist = 0.0;
bool inside = true;
@@ -97,10 +103,11 @@ struct Rect2 {
inside = false;
}
- if (inside)
+ if (inside) {
return 0;
- else
+ } else {
return dist;
+ }
}
bool intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const;
@@ -108,22 +115,21 @@ struct Rect2 {
bool intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos = nullptr, Point2 *r_normal = nullptr) const;
inline bool encloses(const Rect2 &p_rect) const {
-
return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
((p_rect.position.x + p_rect.size.x) <= (position.x + size.x)) &&
((p_rect.position.y + p_rect.size.y) <= (position.y + size.y));
}
_FORCE_INLINE_ bool has_no_area() const {
-
return (size.x <= 0 || size.y <= 0);
}
inline Rect2 clip(const Rect2 &p_rect) const { /// return a clipped rect
Rect2 new_rect = p_rect;
- if (!intersects(new_rect))
+ if (!intersects(new_rect)) {
return Rect2();
+ }
new_rect.position.x = MAX(p_rect.position.x, position.x);
new_rect.position.y = MAX(p_rect.position.y, position.y);
@@ -150,17 +156,21 @@ struct Rect2 {
new_rect.size = new_rect.size - new_rect.position; //make relative again
return new_rect;
- };
+ }
inline bool has_point(const Point2 &p_point) const {
- if (p_point.x < position.x)
+ if (p_point.x < position.x) {
return false;
- if (p_point.y < position.y)
+ }
+ if (p_point.y < position.y) {
return false;
+ }
- if (p_point.x >= (position.x + size.x))
+ if (p_point.x >= (position.x + size.x)) {
return false;
- if (p_point.y >= (position.y + size.y))
+ }
+ if (p_point.y >= (position.y + size.y)) {
return false;
+ }
return true;
}
@@ -170,7 +180,6 @@ struct Rect2 {
bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
inline Rect2 grow(real_t p_by) const {
-
Rect2 g = *this;
g.position.x -= p_by;
g.position.y -= p_by;
@@ -189,7 +198,6 @@ struct Rect2 {
}
inline Rect2 grow_individual(real_t p_left, real_t p_top, real_t p_right, real_t p_bottom) const {
-
Rect2 g = *this;
g.position.x -= p_left;
g.position.y -= p_top;
@@ -200,7 +208,6 @@ struct Rect2 {
}
_FORCE_INLINE_ Rect2 expand(const Vector2 &p_vector) const {
-
Rect2 r = *this;
r.expand_to(p_vector);
return r;
@@ -211,22 +218,25 @@ struct Rect2 {
Vector2 begin = position;
Vector2 end = position + size;
- if (p_vector.x < begin.x)
+ if (p_vector.x < begin.x) {
begin.x = p_vector.x;
- if (p_vector.y < begin.y)
+ }
+ if (p_vector.y < begin.y) {
begin.y = p_vector.y;
+ }
- if (p_vector.x > end.x)
+ if (p_vector.x > end.x) {
end.x = p_vector.x;
- if (p_vector.y > end.y)
+ }
+ if (p_vector.y > end.y) {
end.y = p_vector.y;
+ }
position = begin;
size = end - begin;
}
_FORCE_INLINE_ Rect2 abs() const {
-
return Rect2(Point2(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs());
}
@@ -244,7 +254,6 @@ struct Rect2 {
};
struct Rect2i {
-
Point2i position;
Size2i size;
@@ -256,35 +265,38 @@ struct Rect2i {
int get_area() const { return size.width * size.height; }
inline bool intersects(const Rect2i &p_rect) const {
- if (position.x > (p_rect.position.x + p_rect.size.width))
+ if (position.x > (p_rect.position.x + p_rect.size.width)) {
return false;
- if ((position.x + size.width) < p_rect.position.x)
+ }
+ if ((position.x + size.width) < p_rect.position.x) {
return false;
- if (position.y > (p_rect.position.y + p_rect.size.height))
+ }
+ if (position.y > (p_rect.position.y + p_rect.size.height)) {
return false;
- if ((position.y + size.height) < p_rect.position.y)
+ }
+ if ((position.y + size.height) < p_rect.position.y) {
return false;
+ }
return true;
}
inline bool encloses(const Rect2i &p_rect) const {
-
return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) &&
((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
}
_FORCE_INLINE_ bool has_no_area() const {
-
return (size.x <= 0 || size.y <= 0);
}
inline Rect2i clip(const Rect2i &p_rect) const { /// return a clipped rect
Rect2i new_rect = p_rect;
- if (!intersects(new_rect))
+ if (!intersects(new_rect)) {
return Rect2i();
+ }
new_rect.position.x = MAX(p_rect.position.x, position.x);
new_rect.position.y = MAX(p_rect.position.y, position.y);
@@ -311,17 +323,21 @@ struct Rect2i {
new_rect.size = new_rect.size - new_rect.position; //make relative again
return new_rect;
- };
+ }
bool has_point(const Point2 &p_point) const {
- if (p_point.x < position.x)
+ if (p_point.x < position.x) {
return false;
- if (p_point.y < position.y)
+ }
+ if (p_point.y < position.y) {
return false;
+ }
- if (p_point.x >= (position.x + size.x))
+ if (p_point.x >= (position.x + size.x)) {
return false;
- if (p_point.y >= (position.y + size.y))
+ }
+ if (p_point.y >= (position.y + size.y)) {
return false;
+ }
return true;
}
@@ -330,7 +346,6 @@ struct Rect2i {
bool operator!=(const Rect2i &p_rect) const { return position != p_rect.position || size != p_rect.size; }
Rect2i grow(int p_by) const {
-
Rect2i g = *this;
g.position.x -= p_by;
g.position.y -= p_by;
@@ -349,7 +364,6 @@ struct Rect2i {
}
inline Rect2i grow_individual(int p_left, int p_top, int p_right, int p_bottom) const {
-
Rect2i g = *this;
g.position.x -= p_left;
g.position.y -= p_top;
@@ -360,44 +374,46 @@ struct Rect2i {
}
_FORCE_INLINE_ Rect2i expand(const Vector2i &p_vector) const {
-
Rect2i r = *this;
r.expand_to(p_vector);
return r;
}
inline void expand_to(const Point2i &p_vector) {
-
Point2i begin = position;
Point2i end = position + size;
- if (p_vector.x < begin.x)
+ if (p_vector.x < begin.x) {
begin.x = p_vector.x;
- if (p_vector.y < begin.y)
+ }
+ if (p_vector.y < begin.y) {
begin.y = p_vector.y;
+ }
- if (p_vector.x > end.x)
+ if (p_vector.x > end.x) {
end.x = p_vector.x;
- if (p_vector.y > end.y)
+ }
+ if (p_vector.y > end.y) {
end.y = p_vector.y;
+ }
position = begin;
size = end - begin;
}
_FORCE_INLINE_ Rect2i abs() const {
-
return Rect2i(Point2i(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs());
}
operator String() const { return String(position) + ", " + String(size); }
operator Rect2() const { return Rect2(position, size); }
+
+ Rect2i() {}
Rect2i(const Rect2 &p_r2) :
position(p_r2.position),
size(p_r2.size) {
}
- Rect2i() {}
Rect2i(int p_x, int p_y, int p_width, int p_height) :
position(Point2(p_x, p_y)),
size(Size2(p_width, p_height)) {
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 82e4005d3e..0274dd18af 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -35,20 +35,17 @@
#include "core/print_string.h"
void Transform::affine_invert() {
-
basis.invert();
origin = basis.xform(-origin);
}
Transform Transform::affine_inverse() const {
-
Transform ret = *this;
ret.affine_invert();
return ret;
}
void Transform::invert() {
-
basis.transpose();
origin = basis.xform(-origin);
}
@@ -62,22 +59,18 @@ Transform Transform::inverse() const {
}
void Transform::rotate(const Vector3 &p_axis, real_t p_phi) {
-
*this = rotated(p_axis, p_phi);
}
Transform Transform::rotated(const Vector3 &p_axis, real_t p_phi) const {
-
return Transform(Basis(p_axis, p_phi), Vector3()) * (*this);
}
void Transform::rotate_basis(const Vector3 &p_axis, real_t p_phi) {
-
basis.rotate(p_axis, p_phi);
}
Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
-
Transform t = *this;
t.set_look_at(origin, p_target, p_up);
return t;
@@ -117,7 +110,6 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const
}
Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) const {
-
/* not sure if very "efficient" but good enough? */
Vector3 src_scale = basis.get_scale();
@@ -136,81 +128,70 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
}
void Transform::scale(const Vector3 &p_scale) {
-
basis.scale(p_scale);
origin *= p_scale;
}
Transform Transform::scaled(const Vector3 &p_scale) const {
-
Transform t = *this;
t.scale(p_scale);
return t;
}
void Transform::scale_basis(const Vector3 &p_scale) {
-
basis.scale(p_scale);
}
void Transform::translate(real_t p_tx, real_t p_ty, real_t p_tz) {
translate(Vector3(p_tx, p_ty, p_tz));
}
-void Transform::translate(const Vector3 &p_translation) {
+void Transform::translate(const Vector3 &p_translation) {
for (int i = 0; i < 3; i++) {
origin[i] += basis[i].dot(p_translation);
}
}
Transform Transform::translated(const Vector3 &p_translation) const {
-
Transform t = *this;
t.translate(p_translation);
return t;
}
void Transform::orthonormalize() {
-
basis.orthonormalize();
}
Transform Transform::orthonormalized() const {
-
Transform _copy = *this;
_copy.orthonormalize();
return _copy;
}
bool Transform::is_equal_approx(const Transform &p_transform) const {
-
return basis.is_equal_approx(p_transform.basis) && origin.is_equal_approx(p_transform.origin);
}
bool Transform::operator==(const Transform &p_transform) const {
-
return (basis == p_transform.basis && origin == p_transform.origin);
}
-bool Transform::operator!=(const Transform &p_transform) const {
+bool Transform::operator!=(const Transform &p_transform) const {
return (basis != p_transform.basis || origin != p_transform.origin);
}
void Transform::operator*=(const Transform &p_transform) {
-
origin = xform(p_transform.origin);
basis *= p_transform.basis;
}
Transform Transform::operator*(const Transform &p_transform) const {
-
Transform t = *this;
t *= p_transform;
return t;
}
Transform::operator String() const {
-
return basis.operator String() + " - " + origin.operator String();
}
diff --git a/core/math/transform.h b/core/math/transform.h
index c6e3be4c70..71847d36ac 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -92,14 +92,12 @@ public:
Transform interpolate_with(const Transform &p_transform, real_t p_c) const;
_FORCE_INLINE_ Transform inverse_xform(const Transform &t) const {
-
Vector3 v = t.origin - origin;
return Transform(basis.transpose_xform(t.basis),
basis.xform(v));
}
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t tx, real_t ty, real_t tz) {
-
basis.set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
origin.x = tx;
origin.y = ty;
@@ -114,14 +112,13 @@ public:
};
_FORCE_INLINE_ Vector3 Transform::xform(const Vector3 &p_vector) const {
-
return Vector3(
basis[0].dot(p_vector) + origin.x,
basis[1].dot(p_vector) + origin.y,
basis[2].dot(p_vector) + origin.z);
}
-_FORCE_INLINE_ Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
+_FORCE_INLINE_ Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
Vector3 v = p_vector - origin;
return Vector3(
@@ -131,7 +128,6 @@ _FORCE_INLINE_ Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
}
_FORCE_INLINE_ Plane Transform::xform(const Plane &p_plane) const {
-
Vector3 point = p_plane.normal * p_plane.d;
Vector3 point_dir = point + p_plane.normal;
point = xform(point);
@@ -143,8 +139,8 @@ _FORCE_INLINE_ Plane Transform::xform(const Plane &p_plane) const {
return Plane(normal, d);
}
-_FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
+_FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
Vector3 point = p_plane.normal * p_plane.d;
Vector3 point_dir = point + p_plane.normal;
xform_inv(point);
@@ -158,7 +154,6 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
}
_FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const {
-
/* http://dev.theomader.com/transform-bounding-boxes/ */
Vector3 min = p_aabb.position;
Vector3 max = p_aabb.position + p_aabb.size;
@@ -184,7 +179,6 @@ _FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const {
}
_FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
-
/* define vertices */
Vector3 vertices[8] = {
Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
@@ -202,7 +196,6 @@ _FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
ret.position = xform_inv(vertices[0]);
for (int i = 1; i < 8; i++) {
-
ret.expand_to(xform_inv(vertices[i]));
}
@@ -210,7 +203,6 @@ _FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
}
Vector<Vector3> Transform::xform(const Vector<Vector3> &p_array) const {
-
Vector<Vector3> array;
array.resize(p_array.size());
@@ -224,7 +216,6 @@ Vector<Vector3> Transform::xform(const Vector<Vector3> &p_array) const {
}
Vector<Vector3> Transform::xform_inv(const Vector<Vector3> &p_array) const {
-
Vector<Vector3> array;
array.resize(p_array.size());
diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp
index ed95baa233..dee1b3b23e 100644
--- a/core/math/transform_2d.cpp
+++ b/core/math/transform_2d.cpp
@@ -38,14 +38,12 @@ void Transform2D::invert() {
}
Transform2D Transform2D::inverse() const {
-
Transform2D inv = *this;
inv.invert();
return inv;
}
void Transform2D::affine_invert() {
-
real_t det = basis_determinant();
#ifdef MATH_CHECKS
ERR_FAIL_COND(det == 0);
@@ -60,7 +58,6 @@ void Transform2D::affine_invert() {
}
Transform2D Transform2D::affine_inverse() const {
-
Transform2D inv = *this;
inv.affine_invert();
return inv;
@@ -71,13 +68,11 @@ void Transform2D::rotate(real_t p_phi) {
}
real_t Transform2D::get_skew() const {
-
real_t det = basis_determinant();
return Math::acos(elements[0].normalized().dot(SGN(det) * elements[1].normalized())) - Math_PI * 0.5;
}
void Transform2D::set_skew(float p_angle) {
-
real_t det = basis_determinant();
elements[1] = SGN(det) * elements[0].rotated((Math_PI * 0.5 + p_angle)).normalized() * elements[1].length();
}
@@ -103,7 +98,6 @@ void Transform2D::set_rotation(real_t p_rot) {
}
Transform2D::Transform2D(real_t p_rot, const Vector2 &p_pos) {
-
real_t cr = Math::cos(p_rot);
real_t sr = Math::sin(p_rot);
elements[0][0] = cr;
@@ -129,24 +123,23 @@ void Transform2D::scale(const Size2 &p_scale) {
scale_basis(p_scale);
elements[2] *= p_scale;
}
-void Transform2D::scale_basis(const Size2 &p_scale) {
+void Transform2D::scale_basis(const Size2 &p_scale) {
elements[0][0] *= p_scale.x;
elements[0][1] *= p_scale.y;
elements[1][0] *= p_scale.x;
elements[1][1] *= p_scale.y;
}
-void Transform2D::translate(real_t p_tx, real_t p_ty) {
+void Transform2D::translate(real_t p_tx, real_t p_ty) {
translate(Vector2(p_tx, p_ty));
}
-void Transform2D::translate(const Vector2 &p_translation) {
+void Transform2D::translate(const Vector2 &p_translation) {
elements[2] += basis_xform(p_translation);
}
void Transform2D::orthonormalize() {
-
// Gram-Schmidt Process
Vector2 x = elements[0];
@@ -161,39 +154,36 @@ void Transform2D::orthonormalize() {
}
Transform2D Transform2D::orthonormalized() const {
-
Transform2D on = *this;
on.orthonormalize();
return on;
}
bool Transform2D::is_equal_approx(const Transform2D &p_transform) const {
-
return elements[0].is_equal_approx(p_transform.elements[0]) && elements[1].is_equal_approx(p_transform.elements[1]) && elements[2].is_equal_approx(p_transform.elements[2]);
}
bool Transform2D::operator==(const Transform2D &p_transform) const {
-
for (int i = 0; i < 3; i++) {
- if (elements[i] != p_transform.elements[i])
+ if (elements[i] != p_transform.elements[i]) {
return false;
+ }
}
return true;
}
bool Transform2D::operator!=(const Transform2D &p_transform) const {
-
for (int i = 0; i < 3; i++) {
- if (elements[i] != p_transform.elements[i])
+ if (elements[i] != p_transform.elements[i]) {
return true;
+ }
}
return false;
}
void Transform2D::operator*=(const Transform2D &p_transform) {
-
elements[2] = xform(p_transform.elements[2]);
real_t x0, x1, y0, y1;
@@ -210,54 +200,46 @@ void Transform2D::operator*=(const Transform2D &p_transform) {
}
Transform2D Transform2D::operator*(const Transform2D &p_transform) const {
-
Transform2D t = *this;
t *= p_transform;
return t;
}
Transform2D Transform2D::scaled(const Size2 &p_scale) const {
-
Transform2D copy = *this;
copy.scale(p_scale);
return copy;
}
Transform2D Transform2D::basis_scaled(const Size2 &p_scale) const {
-
Transform2D copy = *this;
copy.scale_basis(p_scale);
return copy;
}
Transform2D Transform2D::untranslated() const {
-
Transform2D copy = *this;
copy.elements[2] = Vector2();
return copy;
}
Transform2D Transform2D::translated(const Vector2 &p_offset) const {
-
Transform2D copy = *this;
copy.translate(p_offset);
return copy;
}
Transform2D Transform2D::rotated(real_t p_phi) const {
-
Transform2D copy = *this;
copy.rotate(p_phi);
return copy;
}
real_t Transform2D::basis_determinant() const {
-
return elements[0].x * elements[1].y - elements[0].y * elements[1].x;
}
Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t p_c) const {
-
//extract parameters
Vector2 p1 = get_origin();
Vector2 p2 = p_transform.get_origin();
@@ -293,6 +275,5 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t
}
Transform2D::operator String() const {
-
return String(String() + elements[0] + ", " + elements[1] + ", " + elements[2]);
}
diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h
index 459ceed7a9..46e97abaa7 100644
--- a/core/math/transform_2d.h
+++ b/core/math/transform_2d.h
@@ -120,7 +120,6 @@ struct Transform2D {
operator String() const;
Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
-
elements[0][0] = xx;
elements[0][1] = xy;
elements[1][0] = yx;
@@ -137,36 +136,33 @@ struct Transform2D {
};
Vector2 Transform2D::basis_xform(const Vector2 &p_vec) const {
-
return Vector2(
tdotx(p_vec),
tdoty(p_vec));
}
Vector2 Transform2D::basis_xform_inv(const Vector2 &p_vec) const {
-
return Vector2(
elements[0].dot(p_vec),
elements[1].dot(p_vec));
}
Vector2 Transform2D::xform(const Vector2 &p_vec) const {
-
return Vector2(
tdotx(p_vec),
tdoty(p_vec)) +
elements[2];
}
-Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
+Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
Vector2 v = p_vec - elements[2];
return Vector2(
elements[0].dot(v),
elements[1].dot(v));
}
-Rect2 Transform2D::xform(const Rect2 &p_rect) const {
+Rect2 Transform2D::xform(const Rect2 &p_rect) const {
Vector2 x = elements[0] * p_rect.size.x;
Vector2 y = elements[1] * p_rect.size.y;
Vector2 pos = xform(p_rect.position);
@@ -180,7 +176,6 @@ Rect2 Transform2D::xform(const Rect2 &p_rect) const {
}
void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
-
elements[0][0] = Math::cos(p_rot) * p_scale.x;
elements[1][1] = Math::cos(p_rot) * p_scale.y;
elements[1][0] = -Math::sin(p_rot) * p_scale.y;
@@ -188,7 +183,6 @@ void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
}
void Transform2D::set_rotation_scale_and_skew(real_t p_rot, const Size2 &p_scale, float p_skew) {
-
elements[0][0] = Math::cos(p_rot) * p_scale.x;
elements[1][1] = Math::cos(p_rot + p_skew) * p_scale.y;
elements[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y;
@@ -196,7 +190,6 @@ void Transform2D::set_rotation_scale_and_skew(real_t p_rot, const Size2 &p_scale
}
Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
-
Vector2 ends[4] = {
xform_inv(p_rect.position),
xform_inv(Vector2(p_rect.position.x, p_rect.position.y + p_rect.size.y)),
@@ -214,7 +207,6 @@ Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
}
Vector<Vector2> Transform2D::xform(const Vector<Vector2> &p_array) const {
-
Vector<Vector2> array;
array.resize(p_array.size());
@@ -228,7 +220,6 @@ Vector<Vector2> Transform2D::xform(const Vector<Vector2> &p_array) const {
}
Vector<Vector2> Transform2D::xform_inv(const Vector<Vector2> &p_array) const {
-
Vector<Vector2> array;
array.resize(p_array.size());
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 0f7350a260..c9a546e385 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -33,30 +33,25 @@
#include "core/sort_array.h"
int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, int p_depth, int &max_depth, int &max_alloc) {
-
if (p_depth > max_depth) {
max_depth = p_depth;
}
if (p_size == 1) {
-
return p_bb[p_from] - p_bvh;
} else if (p_size == 0) {
-
return -1;
}
AABB aabb;
aabb = p_bb[p_from]->aabb;
for (int i = 1; i < p_size; i++) {
-
aabb.merge_with(p_bb[p_from + i]->aabb);
}
int li = aabb.get_longest_axis_index();
switch (li) {
-
case Vector3::AXIS_X: {
SortArray<BVH *, BVHCmpX> sort_x;
sort_x.nth_element(0, p_size, p_size / 2, &p_bb[p_from]);
@@ -90,9 +85,9 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
}
void TriangleMesh::get_indices(Vector<int> *r_triangles_indices) const {
-
- if (!valid)
+ if (!valid) {
return;
+ }
const int triangles_num = triangles.size();
@@ -110,7 +105,6 @@ void TriangleMesh::get_indices(Vector<int> *r_triangles_indices) const {
}
void TriangleMesh::create(const Vector<Vector3> &p_faces) {
-
valid = false;
int fc = p_faces.size();
@@ -122,7 +116,6 @@ void TriangleMesh::create(const Vector<Vector3> &p_faces) {
BVH *bw = bvh.ptrw();
{
-
//create faces and indices and base bvh
//except for the Set for repeated triangles, everything
//goes in-place.
@@ -132,12 +125,10 @@ void TriangleMesh::create(const Vector<Vector3> &p_faces) {
Map<Vector3, int> db;
for (int i = 0; i < fc; i++) {
-
Triangle &f = w[i];
const Vector3 *v = &r[i * 3];
for (int j = 0; j < 3; j++) {
-
int vidx = -1;
Vector3 vs = v[j].snapped(Vector3(0.0001, 0.0001, 0.0001));
Map<Vector3, int>::Element *E = db.find(vs);
@@ -149,10 +140,11 @@ void TriangleMesh::create(const Vector<Vector3> &p_faces) {
}
f.indices[j] = vidx;
- if (j == 0)
+ if (j == 0) {
bw[i].aabb.position = vs;
- else
+ } else {
bw[i].aabb.expand_to(vs);
+ }
}
f.normal = Face3(r[i * 3 + 0], r[i * 3 + 1], r[i * 3 + 2]).get_plane().get_normal();
@@ -174,7 +166,6 @@ void TriangleMesh::create(const Vector<Vector3> &p_faces) {
bwptrs.resize(fc);
BVH **bwp = bwptrs.ptrw();
for (int i = 0; i < fc; i++) {
-
bwp[i] = &bw[i];
}
@@ -188,7 +179,6 @@ void TriangleMesh::create(const Vector<Vector3> &p_faces) {
}
Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
-
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth);
enum {
@@ -215,23 +205,18 @@ Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
stack[0] = pos;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &b = bvhptr[node];
bool done = false;
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool valid = b.aabb.intersects(p_aabb);
if (!valid) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (b.face_index >= 0) {
-
const Triangle &s = triangleptr[b.face_index];
n += s.normal;
n_count++;
@@ -239,49 +224,47 @@ Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
continue;
}
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.left | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.right | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
continue;
}
}
- if (done)
+ if (done) {
break;
+ }
}
- if (n_count > 0)
+ if (n_count > 0) {
n /= n_count;
+ }
return n;
}
bool TriangleMesh::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const {
-
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth);
enum {
@@ -309,35 +292,28 @@ bool TriangleMesh::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en
stack[0] = pos;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &b = bvhptr[node];
bool done = false;
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool valid = b.aabb.intersects_segment(p_begin, p_end);
//bool valid = b.aabb.intersects(ray_aabb);
if (!valid) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (b.face_index >= 0) {
-
const Triangle &s = triangleptr[b.face_index];
Face3 f3(vertexptr[s.indices[0]], vertexptr[s.indices[1]], vertexptr[s.indices[2]]);
Vector3 res;
if (f3.intersects_segment(p_begin, p_end, &res)) {
-
real_t nd = n.dot(res);
if (nd < d) {
-
d = nd;
r_point = res;
r_normal = f3.get_plane().get_normal();
@@ -348,52 +324,49 @@ bool TriangleMesh::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
continue;
}
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.left | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.right | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
continue;
}
}
- if (done)
+ if (done) {
break;
+ }
}
if (inters) {
-
- if (n.dot(r_normal) > 0)
+ if (n.dot(r_normal) > 0) {
r_normal = -r_normal;
+ }
}
return inters;
}
bool TriangleMesh::intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, Vector3 &r_point, Vector3 &r_normal) const {
-
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth);
enum {
@@ -421,33 +394,26 @@ bool TriangleMesh::intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, V
stack[0] = pos;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &b = bvhptr[node];
bool done = false;
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool valid = b.aabb.intersects_ray(p_begin, p_dir);
if (!valid) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (b.face_index >= 0) {
-
const Triangle &s = triangleptr[b.face_index];
Face3 f3(vertexptr[s.indices[0]], vertexptr[s.indices[1]], vertexptr[s.indices[2]]);
Vector3 res;
if (f3.intersects_ray(p_begin, p_dir, &res)) {
-
real_t nd = n.dot(res);
if (nd < d) {
-
d = nd;
r_point = res;
r_normal = f3.get_plane().get_normal();
@@ -458,45 +424,43 @@ bool TriangleMesh::intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, V
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
continue;
}
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.left | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.right | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
continue;
}
}
- if (done)
+ if (done) {
break;
+ }
}
if (inters) {
-
- if (n.dot(r_normal) > 0)
+ if (n.dot(r_normal) > 0) {
r_normal = -r_normal;
+ }
}
return inters;
@@ -528,23 +492,18 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
stack[0] = pos;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &b = bvhptr[node];
bool done = false;
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool valid = b.aabb.intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count);
if (!valid) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (b.face_index >= 0) {
-
const Triangle &s = triangleptr[b.face_index];
for (int j = 0; j < 3; ++j) {
@@ -558,16 +517,18 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
if (p.intersects_segment(point, next_point, &res)) {
bool inisde = true;
for (int k = 0; k < p_plane_count; k++) {
- if (k == i)
+ if (k == i) {
continue;
+ }
const Plane &pp = p_planes[k];
if (pp.is_point_over(res)) {
inisde = false;
break;
}
}
- if (inisde)
+ if (inisde) {
return true;
+ }
}
if (p.is_point_over(point)) {
@@ -575,46 +536,45 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou
break;
}
}
- if (over)
+ if (over) {
return true;
+ }
}
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
continue;
}
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.left | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.right | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
continue;
}
}
- if (done)
+ if (done) {
break;
+ }
}
return false;
@@ -646,86 +606,81 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count,
stack[0] = pos;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &b = bvhptr[node];
bool done = false;
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool intersects = scale.xform(b.aabb).intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count);
- if (!intersects)
+ if (!intersects) {
return false;
+ }
bool inside = scale.xform(b.aabb).inside_convex_shape(p_planes, p_plane_count);
if (inside) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (b.face_index >= 0) {
const Triangle &s = triangleptr[b.face_index];
for (int j = 0; j < 3; ++j) {
Vector3 point = scale.xform(vertexptr[s.indices[j]]);
for (int i = 0; i < p_plane_count; i++) {
const Plane &p = p_planes[i];
- if (p.is_point_over(point))
+ if (p.is_point_over(point)) {
return false;
+ }
}
}
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
continue;
}
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.left | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = b.right | TEST_AABB_BIT;
level++;
continue;
}
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
continue;
}
}
- if (done)
+ if (done) {
break;
+ }
}
return true;
}
bool TriangleMesh::is_valid() const {
-
return valid;
}
Vector<Face3> TriangleMesh::get_faces() const {
-
- if (!valid)
+ if (!valid) {
return Vector<Face3>();
+ }
Vector<Face3> faces;
int ts = triangles.size();
@@ -745,7 +700,6 @@ Vector<Face3> TriangleMesh::get_faces() const {
}
TriangleMesh::TriangleMesh() {
-
valid = false;
max_depth = 0;
}
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 64704477cc..86412cf725 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -35,11 +35,9 @@
#include "core/reference.h"
class TriangleMesh : public Reference {
-
GDCLASS(TriangleMesh, Reference);
struct Triangle {
-
Vector3 normal;
int indices[3];
};
@@ -48,7 +46,6 @@ class TriangleMesh : public Reference {
Vector<Vector3> vertices;
struct BVH {
-
AABB aabb;
Vector3 center; //used for sorting
int left;
@@ -58,24 +55,18 @@ class TriangleMesh : public Reference {
};
struct BVHCmpX {
-
bool operator()(const BVH *p_left, const BVH *p_right) const {
-
return p_left->center.x < p_right->center.x;
}
};
struct BVHCmpY {
-
bool operator()(const BVH *p_left, const BVH *p_right) const {
-
return p_left->center.y < p_right->center.y;
}
};
struct BVHCmpZ {
-
bool operator()(const BVH *p_left, const BVH *p_right) const {
-
return p_left->center.z < p_right->center.z;
}
};
diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp
index ae278b034d..12bd384c6a 100644
--- a/core/math/triangulate.cpp
+++ b/core/math/triangulate.cpp
@@ -31,7 +31,6 @@
#include "triangulate.h"
real_t Triangulate::get_area(const Vector<Vector2> &contour) {
-
int n = contour.size();
const Vector2 *c = &contour[0];
@@ -80,7 +79,7 @@ bool Triangulate::is_inside_triangle(real_t Ax, real_t Ay,
} else {
return ((aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0));
}
-};
+}
bool Triangulate::snip(const Vector<Vector2> &p_contour, int u, int v, int w, int n, const Vector<int> &V, bool relaxed) {
int p;
@@ -103,16 +102,19 @@ bool Triangulate::snip(const Vector<Vector2> &p_contour, int u, int v, int w, in
// To avoid that we allow zero-area triangles if all else failed.
float threshold = relaxed ? -CMP_EPSILON : CMP_EPSILON;
- if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax))))
+ if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) {
return false;
+ }
for (p = 0; p < n; p++) {
- if ((p == u) || (p == v) || (p == w))
+ if ((p == u) || (p == v) || (p == w)) {
continue;
+ }
Px = contour[V[p]].x;
Py = contour[V[p]].y;
- if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed))
+ if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed)) {
return false;
+ }
}
return true;
@@ -122,20 +124,24 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul
/* allocate and initialize list of Vertices in polygon */
int n = contour.size();
- if (n < 3)
+ if (n < 3) {
return false;
+ }
Vector<int> V;
V.resize(n);
/* we want a counter-clockwise polygon in V */
- if (0.0 < get_area(contour))
- for (int v = 0; v < n; v++)
+ if (0.0 < get_area(contour)) {
+ for (int v = 0; v < n; v++) {
V.write[v] = v;
- else
- for (int v = 0; v < n; v++)
+ }
+ } else {
+ for (int v = 0; v < n; v++) {
V.write[v] = (n - 1) - v;
+ }
+ }
bool relaxed = false;
@@ -165,14 +171,17 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul
/* three consecutive vertices in current polygon, <u,v,w> */
int u = v;
- if (nv <= u)
+ if (nv <= u) {
u = 0; /* previous */
+ }
v = u + 1;
- if (nv <= v)
+ if (nv <= v) {
v = 0; /* new v */
+ }
int w = v + 1;
- if (nv <= w)
+ if (nv <= w) {
w = 0; /* next */
+ }
if (snip(contour, u, v, w, nv, V, relaxed)) {
int a, b, c, s, t;
@@ -188,8 +197,9 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul
result.push_back(c);
/* remove v from remaining polygon */
- for (s = v, t = v + 1; t < nv; s++, t++)
+ for (s = v, t = v + 1; t < nv; s++, t++) {
V.write[s] = V[t];
+ }
nv--;
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index f46badd19e..233421e070 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -31,25 +31,20 @@
#include "vector2.h"
real_t Vector2::angle() const {
-
return Math::atan2(y, x);
}
real_t Vector2::length() const {
-
return Math::sqrt(x * x + y * y);
}
real_t Vector2::length_squared() const {
-
return x * x + y * y;
}
void Vector2::normalize() {
-
real_t l = x * x + y * y;
if (l != 0) {
-
l = Math::sqrt(l);
x /= l;
y /= l;
@@ -57,7 +52,6 @@ void Vector2::normalize() {
}
Vector2 Vector2::normalized() const {
-
Vector2 v = *this;
v.normalize();
return v;
@@ -69,52 +63,42 @@ bool Vector2::is_normalized() const {
}
real_t Vector2::distance_to(const Vector2 &p_vector2) const {
-
return Math::sqrt((x - p_vector2.x) * (x - p_vector2.x) + (y - p_vector2.y) * (y - p_vector2.y));
}
real_t Vector2::distance_squared_to(const Vector2 &p_vector2) const {
-
return (x - p_vector2.x) * (x - p_vector2.x) + (y - p_vector2.y) * (y - p_vector2.y);
}
real_t Vector2::angle_to(const Vector2 &p_vector2) const {
-
return Math::atan2(cross(p_vector2), dot(p_vector2));
}
real_t Vector2::angle_to_point(const Vector2 &p_vector2) const {
-
return Math::atan2(y - p_vector2.y, x - p_vector2.x);
}
real_t Vector2::dot(const Vector2 &p_other) const {
-
return x * p_other.x + y * p_other.y;
}
real_t Vector2::cross(const Vector2 &p_other) const {
-
return x * p_other.y - y * p_other.x;
}
Vector2 Vector2::sign() const {
-
return Vector2(SGN(x), SGN(y));
}
Vector2 Vector2::floor() const {
-
return Vector2(Math::floor(x), Math::floor(y));
}
Vector2 Vector2::ceil() const {
-
return Vector2(Math::ceil(x), Math::ceil(y));
}
Vector2 Vector2::round() const {
-
return Vector2(Math::round(x), Math::round(y));
}
@@ -139,18 +123,15 @@ Vector2 Vector2::project(const Vector2 &p_b) const {
}
Vector2 Vector2::snapped(const Vector2 &p_by) const {
-
return Vector2(
Math::stepify(x, p_by.x),
Math::stepify(y, p_by.y));
}
Vector2 Vector2::clamped(real_t p_len) const {
-
real_t l = length();
Vector2 v = *this;
if (l > 0 && p_len < l) {
-
v /= l;
v *= p_len;
}
@@ -159,7 +140,6 @@ Vector2 Vector2::clamped(real_t p_len) const {
}
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const {
-
Vector2 p0 = p_pre_a;
Vector2 p1 = *this;
Vector2 p2 = p_b;
@@ -210,65 +190,57 @@ bool Vector2::is_equal_approx(const Vector2 &p_v) const {
/* Vector2i */
Vector2i Vector2i::operator+(const Vector2i &p_v) const {
-
return Vector2i(x + p_v.x, y + p_v.y);
}
-void Vector2i::operator+=(const Vector2i &p_v) {
+void Vector2i::operator+=(const Vector2i &p_v) {
x += p_v.x;
y += p_v.y;
}
-Vector2i Vector2i::operator-(const Vector2i &p_v) const {
+Vector2i Vector2i::operator-(const Vector2i &p_v) const {
return Vector2i(x - p_v.x, y - p_v.y);
}
-void Vector2i::operator-=(const Vector2i &p_v) {
+void Vector2i::operator-=(const Vector2i &p_v) {
x -= p_v.x;
y -= p_v.y;
}
Vector2i Vector2i::operator*(const Vector2i &p_v1) const {
-
return Vector2i(x * p_v1.x, y * p_v1.y);
-};
+}
Vector2i Vector2i::operator*(const int &rvalue) const {
-
return Vector2i(x * rvalue, y * rvalue);
-};
-void Vector2i::operator*=(const int &rvalue) {
+}
+void Vector2i::operator*=(const int &rvalue) {
x *= rvalue;
y *= rvalue;
-};
+}
Vector2i Vector2i::operator/(const Vector2i &p_v1) const {
-
return Vector2i(x / p_v1.x, y / p_v1.y);
-};
+}
Vector2i Vector2i::operator/(const int &rvalue) const {
-
return Vector2i(x / rvalue, y / rvalue);
-};
+}
void Vector2i::operator/=(const int &rvalue) {
-
x /= rvalue;
y /= rvalue;
-};
+}
Vector2i Vector2i::operator-() const {
-
return Vector2i(-x, -y);
}
bool Vector2i::operator==(const Vector2i &p_vec2) const {
-
return x == p_vec2.x && y == p_vec2.y;
}
-bool Vector2i::operator!=(const Vector2i &p_vec2) const {
+bool Vector2i::operator!=(const Vector2i &p_vec2) const {
return x != p_vec2.x || y != p_vec2.y;
}
diff --git a/core/math/vector2.h b/core/math/vector2.h
index c0057f2543..8a08d3bf64 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -37,18 +37,17 @@
struct Vector2i;
struct Vector2 {
-
enum Axis {
AXIS_X,
AXIS_Y,
};
union {
- real_t x;
+ real_t x = 0;
real_t width;
};
union {
- real_t y;
+ real_t y = 0;
real_t height;
};
@@ -123,13 +122,11 @@ struct Vector2 {
real_t angle() const;
_FORCE_INLINE_ Vector2 abs() const {
-
return Vector2(Math::abs(x), Math::abs(y));
}
Vector2 rotated(real_t p_by) const;
Vector2 tangent() const {
-
return Vector2(y, -x);
}
@@ -142,89 +139,78 @@ struct Vector2 {
operator String() const { return String::num(x) + ", " + String::num(y); }
+ _FORCE_INLINE_ Vector2() {}
_FORCE_INLINE_ Vector2(real_t p_x, real_t p_y) {
x = p_x;
y = p_y;
}
- _FORCE_INLINE_ Vector2() { x = y = 0; }
};
_FORCE_INLINE_ Vector2 Vector2::plane_project(real_t p_d, const Vector2 &p_vec) const {
-
return p_vec - *this * (dot(p_vec) - p_d);
}
_FORCE_INLINE_ Vector2 operator*(real_t p_scalar, const Vector2 &p_vec) {
-
return p_vec * p_scalar;
}
_FORCE_INLINE_ Vector2 Vector2::operator+(const Vector2 &p_v) const {
-
return Vector2(x + p_v.x, y + p_v.y);
}
-_FORCE_INLINE_ void Vector2::operator+=(const Vector2 &p_v) {
+_FORCE_INLINE_ void Vector2::operator+=(const Vector2 &p_v) {
x += p_v.x;
y += p_v.y;
}
-_FORCE_INLINE_ Vector2 Vector2::operator-(const Vector2 &p_v) const {
+_FORCE_INLINE_ Vector2 Vector2::operator-(const Vector2 &p_v) const {
return Vector2(x - p_v.x, y - p_v.y);
}
-_FORCE_INLINE_ void Vector2::operator-=(const Vector2 &p_v) {
+_FORCE_INLINE_ void Vector2::operator-=(const Vector2 &p_v) {
x -= p_v.x;
y -= p_v.y;
}
_FORCE_INLINE_ Vector2 Vector2::operator*(const Vector2 &p_v1) const {
-
return Vector2(x * p_v1.x, y * p_v1.y);
-};
+}
_FORCE_INLINE_ Vector2 Vector2::operator*(const real_t &rvalue) const {
-
return Vector2(x * rvalue, y * rvalue);
-};
-_FORCE_INLINE_ void Vector2::operator*=(const real_t &rvalue) {
+}
+_FORCE_INLINE_ void Vector2::operator*=(const real_t &rvalue) {
x *= rvalue;
y *= rvalue;
-};
+}
_FORCE_INLINE_ Vector2 Vector2::operator/(const Vector2 &p_v1) const {
-
return Vector2(x / p_v1.x, y / p_v1.y);
-};
+}
_FORCE_INLINE_ Vector2 Vector2::operator/(const real_t &rvalue) const {
-
return Vector2(x / rvalue, y / rvalue);
-};
+}
_FORCE_INLINE_ void Vector2::operator/=(const real_t &rvalue) {
-
x /= rvalue;
y /= rvalue;
-};
+}
_FORCE_INLINE_ Vector2 Vector2::operator-() const {
-
return Vector2(-x, -y);
}
_FORCE_INLINE_ bool Vector2::operator==(const Vector2 &p_vec2) const {
-
return x == p_vec2.x && y == p_vec2.y;
}
-_FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const {
+_FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const {
return x != p_vec2.x || y != p_vec2.y;
}
Vector2 Vector2::lerp(const Vector2 &p_b, real_t p_t) const {
-
Vector2 res = *this;
res.x += (p_t * (p_b.x - x));
@@ -253,18 +239,17 @@ typedef Vector2 Point2;
/* INTEGER STUFF */
struct Vector2i {
-
enum Axis {
AXIS_X,
AXIS_Y,
};
union {
- int x;
+ int x = 0;
int width;
};
union {
- int y;
+ int y = 0;
int height;
};
@@ -307,6 +292,8 @@ struct Vector2i {
operator String() const { return String::num(x) + ", " + String::num(y); }
operator Vector2() const { return Vector2(x, y); }
+
+ inline Vector2i() {}
inline Vector2i(const Vector2 &p_vec2) {
x = (int)p_vec2.x;
y = (int)p_vec2.y;
@@ -315,10 +302,6 @@ struct Vector2i {
x = p_x;
y = p_y;
}
- inline Vector2i() {
- x = 0;
- y = 0;
- }
};
typedef Vector2i Size2i;
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 353b2acd16..568df48c62 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -33,12 +33,10 @@
#include "core/math/basis.h"
void Vector3::rotate(const Vector3 &p_axis, real_t p_phi) {
-
*this = Basis(p_axis, p_phi).xform(*this);
}
Vector3 Vector3::rotated(const Vector3 &p_axis, real_t p_phi) const {
-
Vector3 r = *this;
r.rotate(p_axis, p_phi);
return r;
@@ -48,36 +46,33 @@ void Vector3::set_axis(int p_axis, real_t p_value) {
ERR_FAIL_INDEX(p_axis, 3);
coord[p_axis] = p_value;
}
-real_t Vector3::get_axis(int p_axis) const {
+real_t Vector3::get_axis(int p_axis) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
return operator[](p_axis);
}
int Vector3::min_axis() const {
-
return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2);
}
-int Vector3::max_axis() const {
+int Vector3::max_axis() const {
return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0);
}
void Vector3::snap(Vector3 p_val) {
-
x = Math::stepify(x, p_val.x);
y = Math::stepify(y, p_val.y);
z = Math::stepify(z, p_val.z);
}
-Vector3 Vector3::snapped(Vector3 p_val) const {
+Vector3 Vector3::snapped(Vector3 p_val) const {
Vector3 v = *this;
v.snap(p_val);
return v;
}
Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const {
-
Vector3 p0 = p_pre_a;
Vector3 p1 = *this;
Vector3 p2 = p_b;
@@ -90,10 +85,12 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a,
real_t bc = p1.distance_to(p2);
real_t cd = p2.distance_to(p3);
- if (ab > 0)
+ if (ab > 0) {
p0 = p1 + (p0 - p1) * (bc / ab);
- if (cd > 0)
+ }
+ if (cd > 0) {
p3 = p2 + (p3 - p2) * (bc / cd);
+ }
}
real_t t = p_t;
@@ -109,7 +106,6 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a,
}
Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const {
-
Vector3 p0 = p_pre_a;
Vector3 p1 = *this;
Vector3 p2 = p_b;
@@ -135,7 +131,6 @@ Vector3 Vector3::move_toward(const Vector3 &p_to, const real_t p_delta) const {
}
Basis Vector3::outer(const Vector3 &p_b) const {
-
Vector3 row0(x * p_b.x, x * p_b.y, x * p_b.z);
Vector3 row1(y * p_b.x, y * p_b.y, y * p_b.z);
Vector3 row2(z * p_b.x, z * p_b.y, z * p_b.z);
@@ -150,11 +145,9 @@ Basis Vector3::to_diagonal_matrix() const {
}
bool Vector3::is_equal_approx(const Vector3 &p_v) const {
-
return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y) && Math::is_equal_approx(z, p_v.z);
}
Vector3::operator String() const {
-
return (rtos(x) + ", " + rtos(y) + ", " + rtos(z));
}
diff --git a/core/math/vector3.h b/core/math/vector3.h
index a5e9d09208..0bc1a467f2 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -38,7 +38,6 @@
class Basis;
struct Vector3 {
-
enum Axis {
AXIS_X,
AXIS_Y,
@@ -52,16 +51,14 @@ struct Vector3 {
real_t z;
};
- real_t coord[3];
+ real_t coord[3] = { 0 };
};
_FORCE_INLINE_ const real_t &operator[](int p_axis) const {
-
return coord[p_axis];
}
_FORCE_INLINE_ real_t &operator[](int p_axis) {
-
return coord[p_axis];
}
@@ -152,22 +149,20 @@ struct Vector3 {
return Vector3i(x, y, z);
}
+ _FORCE_INLINE_ Vector3() {}
_FORCE_INLINE_ Vector3(const Vector3i &p_ivec) {
x = p_ivec.x;
y = p_ivec.y;
z = p_ivec.z;
}
-
_FORCE_INLINE_ Vector3(real_t p_x, real_t p_y, real_t p_z) {
x = p_x;
y = p_y;
z = p_z;
}
- _FORCE_INLINE_ Vector3() { x = y = z = 0; }
};
Vector3 Vector3::cross(const Vector3 &p_b) const {
-
Vector3 ret(
(y * p_b.z) - (z * p_b.y),
(z * p_b.x) - (x * p_b.z),
@@ -177,37 +172,30 @@ Vector3 Vector3::cross(const Vector3 &p_b) const {
}
real_t Vector3::dot(const Vector3 &p_b) const {
-
return x * p_b.x + y * p_b.y + z * p_b.z;
}
Vector3 Vector3::abs() const {
-
return Vector3(Math::abs(x), Math::abs(y), Math::abs(z));
}
Vector3 Vector3::sign() const {
-
return Vector3(SGN(x), SGN(y), SGN(z));
}
Vector3 Vector3::floor() const {
-
return Vector3(Math::floor(x), Math::floor(y), Math::floor(z));
}
Vector3 Vector3::ceil() const {
-
return Vector3(Math::ceil(x), Math::ceil(y), Math::ceil(z));
}
Vector3 Vector3::round() const {
-
return Vector3(Math::round(x), Math::round(y), Math::round(z));
}
Vector3 Vector3::lerp(const Vector3 &p_b, real_t p_t) const {
-
return Vector3(
x + (p_t * (p_b.x - x)),
y + (p_t * (p_b.y - y)),
@@ -220,12 +208,10 @@ Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
}
real_t Vector3::distance_to(const Vector3 &p_b) const {
-
return (p_b - *this).length();
}
real_t Vector3::distance_squared_to(const Vector3 &p_b) const {
-
return (p_b - *this).length_squared();
}
@@ -242,7 +228,6 @@ Vector3 Vector3::project(const Vector3 &p_b) const {
}
real_t Vector3::angle_to(const Vector3 &p_b) const {
-
return Math::atan2(cross(p_b).length(), dot(p_b));
}
@@ -255,7 +240,6 @@ Vector3 Vector3::direction_to(const Vector3 &p_b) const {
/* Operators */
Vector3 &Vector3::operator+=(const Vector3 &p_v) {
-
x += p_v.x;
y += p_v.y;
z += p_v.z;
@@ -263,36 +247,32 @@ Vector3 &Vector3::operator+=(const Vector3 &p_v) {
}
Vector3 Vector3::operator+(const Vector3 &p_v) const {
-
return Vector3(x + p_v.x, y + p_v.y, z + p_v.z);
}
Vector3 &Vector3::operator-=(const Vector3 &p_v) {
-
x -= p_v.x;
y -= p_v.y;
z -= p_v.z;
return *this;
}
-Vector3 Vector3::operator-(const Vector3 &p_v) const {
+Vector3 Vector3::operator-(const Vector3 &p_v) const {
return Vector3(x - p_v.x, y - p_v.y, z - p_v.z);
}
Vector3 &Vector3::operator*=(const Vector3 &p_v) {
-
x *= p_v.x;
y *= p_v.y;
z *= p_v.z;
return *this;
}
-Vector3 Vector3::operator*(const Vector3 &p_v) const {
+Vector3 Vector3::operator*(const Vector3 &p_v) const {
return Vector3(x * p_v.x, y * p_v.y, z * p_v.z);
}
Vector3 &Vector3::operator/=(const Vector3 &p_v) {
-
x /= p_v.x;
y /= p_v.y;
z /= p_v.z;
@@ -300,12 +280,10 @@ Vector3 &Vector3::operator/=(const Vector3 &p_v) {
}
Vector3 Vector3::operator/(const Vector3 &p_v) const {
-
return Vector3(x / p_v.x, y / p_v.y, z / p_v.z);
}
Vector3 &Vector3::operator*=(real_t p_scalar) {
-
x *= p_scalar;
y *= p_scalar;
z *= p_scalar;
@@ -313,17 +291,14 @@ Vector3 &Vector3::operator*=(real_t p_scalar) {
}
_FORCE_INLINE_ Vector3 operator*(real_t p_scalar, const Vector3 &p_vec) {
-
return p_vec * p_scalar;
}
Vector3 Vector3::operator*(real_t p_scalar) const {
-
return Vector3(x * p_scalar, y * p_scalar, z * p_scalar);
}
Vector3 &Vector3::operator/=(real_t p_scalar) {
-
x /= p_scalar;
y /= p_scalar;
z /= p_scalar;
@@ -331,85 +306,78 @@ Vector3 &Vector3::operator/=(real_t p_scalar) {
}
Vector3 Vector3::operator/(real_t p_scalar) const {
-
return Vector3(x / p_scalar, y / p_scalar, z / p_scalar);
}
Vector3 Vector3::operator-() const {
-
return Vector3(-x, -y, -z);
}
bool Vector3::operator==(const Vector3 &p_v) const {
-
return x == p_v.x && y == p_v.y && z == p_v.z;
}
bool Vector3::operator!=(const Vector3 &p_v) const {
-
return x != p_v.x || y != p_v.y || z != p_v.z;
}
bool Vector3::operator<(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
- if (Math::is_equal_approx(y, p_v.y))
+ if (Math::is_equal_approx(y, p_v.y)) {
return z < p_v.z;
- else
+ } else {
return y < p_v.y;
+ }
} else {
return x < p_v.x;
}
}
bool Vector3::operator>(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
- if (Math::is_equal_approx(y, p_v.y))
+ if (Math::is_equal_approx(y, p_v.y)) {
return z > p_v.z;
- else
+ } else {
return y > p_v.y;
+ }
} else {
return x > p_v.x;
}
}
bool Vector3::operator<=(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
- if (Math::is_equal_approx(y, p_v.y))
+ if (Math::is_equal_approx(y, p_v.y)) {
return z <= p_v.z;
- else
+ } else {
return y < p_v.y;
+ }
} else {
return x < p_v.x;
}
}
bool Vector3::operator>=(const Vector3 &p_v) const {
-
if (Math::is_equal_approx(x, p_v.x)) {
- if (Math::is_equal_approx(y, p_v.y))
+ if (Math::is_equal_approx(y, p_v.y)) {
return z >= p_v.z;
- else
+ } else {
return y > p_v.y;
+ }
} else {
return x > p_v.x;
}
}
_FORCE_INLINE_ Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {
-
return p_a.cross(p_b);
}
_FORCE_INLINE_ real_t vec3_dot(const Vector3 &p_a, const Vector3 &p_b) {
-
return p_a.dot(p_b);
}
real_t Vector3::length() const {
-
real_t x2 = x * x;
real_t y2 = y * y;
real_t z2 = z * z;
@@ -418,7 +386,6 @@ real_t Vector3::length() const {
}
real_t Vector3::length_squared() const {
-
real_t x2 = x * x;
real_t y2 = y * y;
real_t z2 = z * z;
@@ -427,7 +394,6 @@ real_t Vector3::length_squared() const {
}
void Vector3::normalize() {
-
real_t lengthsq = length_squared();
if (lengthsq == 0) {
x = y = z = 0;
@@ -440,7 +406,6 @@ void Vector3::normalize() {
}
Vector3 Vector3::normalized() const {
-
Vector3 v = *this;
v.normalize();
return v;
@@ -452,12 +417,10 @@ bool Vector3::is_normalized() const {
}
Vector3 Vector3::inverse() const {
-
return Vector3(1.0 / x, 1.0 / y, 1.0 / z);
}
void Vector3::zero() {
-
x = y = z = 0;
}
diff --git a/core/math/vector3i.cpp b/core/math/vector3i.cpp
index 8a4ddf03b9..718a1553a0 100644
--- a/core/math/vector3i.cpp
+++ b/core/math/vector3i.cpp
@@ -34,22 +34,20 @@ void Vector3i::set_axis(int p_axis, int32_t p_value) {
ERR_FAIL_INDEX(p_axis, 3);
coord[p_axis] = p_value;
}
-int32_t Vector3i::get_axis(int p_axis) const {
+int32_t Vector3i::get_axis(int p_axis) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
return operator[](p_axis);
}
int Vector3i::min_axis() const {
-
return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2);
}
-int Vector3i::max_axis() const {
+int Vector3i::max_axis() const {
return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0);
}
Vector3i::operator String() const {
-
return (itos(x) + ", " + itos(y) + ", " + itos(z));
}
diff --git a/core/math/vector3i.h b/core/math/vector3i.h
index 6f9754d3b9..08729ad056 100644
--- a/core/math/vector3i.h
+++ b/core/math/vector3i.h
@@ -35,7 +35,6 @@
#include "core/ustring.h"
struct Vector3i {
-
enum Axis {
AXIS_X,
AXIS_Y,
@@ -49,16 +48,14 @@ struct Vector3i {
int32_t z;
};
- int32_t coord[3];
+ int32_t coord[3] = { 0 };
};
_FORCE_INLINE_ const int32_t &operator[](int p_axis) const {
-
return coord[p_axis];
}
_FORCE_INLINE_ int32_t &operator[](int p_axis) {
-
return coord[p_axis];
}
@@ -100,28 +97,25 @@ struct Vector3i {
operator String() const;
+ _FORCE_INLINE_ Vector3i() {}
_FORCE_INLINE_ Vector3i(int32_t p_x, int32_t p_y, int32_t p_z) {
x = p_x;
y = p_y;
z = p_z;
}
- _FORCE_INLINE_ Vector3i() { x = y = z = 0; }
};
Vector3i Vector3i::abs() const {
-
return Vector3i(ABS(x), ABS(y), ABS(z));
}
Vector3i Vector3i::sign() const {
-
return Vector3i(SGN(x), SGN(y), SGN(z));
}
/* Operators */
Vector3i &Vector3i::operator+=(const Vector3i &p_v) {
-
x += p_v.x;
y += p_v.y;
z += p_v.z;
@@ -129,36 +123,32 @@ Vector3i &Vector3i::operator+=(const Vector3i &p_v) {
}
Vector3i Vector3i::operator+(const Vector3i &p_v) const {
-
return Vector3i(x + p_v.x, y + p_v.y, z + p_v.z);
}
Vector3i &Vector3i::operator-=(const Vector3i &p_v) {
-
x -= p_v.x;
y -= p_v.y;
z -= p_v.z;
return *this;
}
-Vector3i Vector3i::operator-(const Vector3i &p_v) const {
+Vector3i Vector3i::operator-(const Vector3i &p_v) const {
return Vector3i(x - p_v.x, y - p_v.y, z - p_v.z);
}
Vector3i &Vector3i::operator*=(const Vector3i &p_v) {
-
x *= p_v.x;
y *= p_v.y;
z *= p_v.z;
return *this;
}
-Vector3i Vector3i::operator*(const Vector3i &p_v) const {
+Vector3i Vector3i::operator*(const Vector3i &p_v) const {
return Vector3i(x * p_v.x, y * p_v.y, z * p_v.z);
}
Vector3i &Vector3i::operator/=(const Vector3i &p_v) {
-
x /= p_v.x;
y /= p_v.y;
z /= p_v.z;
@@ -166,12 +156,10 @@ Vector3i &Vector3i::operator/=(const Vector3i &p_v) {
}
Vector3i Vector3i::operator/(const Vector3i &p_v) const {
-
return Vector3i(x / p_v.x, y / p_v.y, z / p_v.z);
}
Vector3i &Vector3i::operator*=(int32_t p_scalar) {
-
x *= p_scalar;
y *= p_scalar;
z *= p_scalar;
@@ -179,17 +167,14 @@ Vector3i &Vector3i::operator*=(int32_t p_scalar) {
}
_FORCE_INLINE_ Vector3i operator*(int32_t p_scalar, const Vector3i &p_vec) {
-
return p_vec * p_scalar;
}
Vector3i Vector3i::operator*(int32_t p_scalar) const {
-
return Vector3i(x * p_scalar, y * p_scalar, z * p_scalar);
}
Vector3i &Vector3i::operator/=(int32_t p_scalar) {
-
x /= p_scalar;
y /= p_scalar;
z /= p_scalar;
@@ -197,75 +182,70 @@ Vector3i &Vector3i::operator/=(int32_t p_scalar) {
}
Vector3i Vector3i::operator/(int32_t p_scalar) const {
-
return Vector3i(x / p_scalar, y / p_scalar, z / p_scalar);
}
Vector3i Vector3i::operator-() const {
-
return Vector3i(-x, -y, -z);
}
bool Vector3i::operator==(const Vector3i &p_v) const {
-
return (x == p_v.x && y == p_v.y && z == p_v.z);
}
bool Vector3i::operator!=(const Vector3i &p_v) const {
-
return (x != p_v.x || y != p_v.y || z != p_v.z);
}
bool Vector3i::operator<(const Vector3i &p_v) const {
-
if (x == p_v.x) {
- if (y == p_v.y)
+ if (y == p_v.y) {
return z < p_v.z;
- else
+ } else {
return y < p_v.y;
+ }
} else {
return x < p_v.x;
}
}
bool Vector3i::operator>(const Vector3i &p_v) const {
-
if (x == p_v.x) {
- if (y == p_v.y)
+ if (y == p_v.y) {
return z > p_v.z;
- else
+ } else {
return y > p_v.y;
+ }
} else {
return x > p_v.x;
}
}
bool Vector3i::operator<=(const Vector3i &p_v) const {
-
if (x == p_v.x) {
- if (y == p_v.y)
+ if (y == p_v.y) {
return z <= p_v.z;
- else
+ } else {
return y < p_v.y;
+ }
} else {
return x < p_v.x;
}
}
bool Vector3i::operator>=(const Vector3i &p_v) const {
-
if (x == p_v.x) {
- if (y == p_v.y)
+ if (y == p_v.y) {
return z >= p_v.z;
- else
+ } else {
return y > p_v.y;
+ }
} else {
return x > p_v.x;
}
}
void Vector3i::zero() {
-
x = y = z = 0;
}
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 652c424492..6dcf24e7ed 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -37,24 +37,22 @@
MessageQueue *MessageQueue::singleton = nullptr;
MessageQueue *MessageQueue::get_singleton() {
-
return singleton;
}
Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, const Variant **p_args, int p_argcount, bool p_show_error) {
-
return push_callable(Callable(p_id, p_method), p_args, p_argcount, p_show_error);
}
Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -62,15 +60,15 @@ Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, VARIANT
}
Error MessageQueue::push_set(ObjectID p_id, const StringName &p_prop, const Variant &p_value) {
-
_THREAD_SAFE_METHOD_
uint8_t room_needed = sizeof(Message) + sizeof(Variant);
if ((buffer_end + room_needed) >= buffer_size) {
String type;
- if (ObjectDB::get_instance(p_id))
+ if (ObjectDB::get_instance(p_id)) {
type = ObjectDB::get_instance(p_id)->get_class();
+ }
print_line("Failed set: " + type + ":" + p_prop + " target ID: " + itos(p_id));
statistics();
ERR_FAIL_V_MSG(ERR_OUT_OF_MEMORY, "Message queue out of memory. Try increasing 'memory/limits/message_queue/max_size_kb' in project settings.");
@@ -91,7 +89,6 @@ Error MessageQueue::push_set(ObjectID p_id, const StringName &p_prop, const Vari
}
Error MessageQueue::push_notification(ObjectID p_id, int p_notification) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_notification < 0, ERR_INVALID_PARAMETER);
@@ -117,21 +114,18 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) {
}
Error MessageQueue::push_call(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
return push_call(p_object->get_instance_id(), p_method, VARIANT_ARG_PASS);
}
Error MessageQueue::push_notification(Object *p_object, int p_notification) {
-
return push_notification(p_object->get_instance_id(), p_notification);
}
-Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const Variant &p_value) {
+Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const Variant &p_value) {
return push_set(p_object->get_instance_id(), p_prop, p_value);
}
Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_args, int p_argcount, bool p_show_error) {
-
_THREAD_SAFE_METHOD_
int room_needed = sizeof(Message) + sizeof(Variant) * p_argcount;
@@ -146,13 +140,13 @@ Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_
msg->args = p_argcount;
msg->callable = p_callable;
msg->type = TYPE_CALL;
- if (p_show_error)
+ if (p_show_error) {
msg->type |= FLAG_SHOW_ERROR;
+ }
buffer_end += sizeof(Message);
for (int i = 0; i < p_argcount; i++) {
-
Variant *v = memnew_placement(&buffer[buffer_end], Variant);
buffer_end += sizeof(Variant);
*v = *p_args[i];
@@ -161,8 +155,22 @@ Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_
return OK;
}
-void MessageQueue::statistics() {
+Error MessageQueue::push_callable(const Callable &p_callable, VARIANT_ARG_DECLARE) {
+ VARIANT_ARGPTRS;
+
+ int argc = 0;
+ for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+ if (argptr[i]->get_type() == Variant::NIL) {
+ break;
+ }
+ argc++;
+ }
+
+ return push_callable(p_callable, argptr, argc);
+}
+
+void MessageQueue::statistics() {
Map<StringName, int> set_count;
Map<int, int> notify_count;
Map<Callable, int> call_count;
@@ -175,30 +183,28 @@ void MessageQueue::statistics() {
Object *target = message->callable.get_object();
if (target != nullptr) {
-
switch (message->type & FLAG_MASK) {
-
case TYPE_CALL: {
-
- if (!call_count.has(message->callable))
+ if (!call_count.has(message->callable)) {
call_count[message->callable] = 0;
+ }
call_count[message->callable]++;
} break;
case TYPE_NOTIFICATION: {
-
- if (!notify_count.has(message->notification))
+ if (!notify_count.has(message->notification)) {
notify_count[message->notification] = 0;
+ }
notify_count[message->notification]++;
} break;
case TYPE_SET: {
-
StringName t = message->callable.get_method();
- if (!set_count.has(t))
+ if (!set_count.has(t)) {
set_count[t] = 0;
+ }
set_count[t]++;
@@ -213,8 +219,9 @@ void MessageQueue::statistics() {
}
read_pos += sizeof(Message);
- if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION)
+ if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
read_pos += sizeof(Variant) * message->args;
+ }
}
print_line("TOTAL BYTES: " + itos(buffer_end));
@@ -234,12 +241,10 @@ void MessageQueue::statistics() {
}
int MessageQueue::get_max_buffer_usage() const {
-
return buffer_max_used;
}
void MessageQueue::_call_function(const Callable &p_callable, const Variant *p_args, int p_argcount, bool p_show_error) {
-
const Variant **argptrs = nullptr;
if (p_argcount) {
argptrs = (const Variant **)alloca(sizeof(Variant *) * p_argcount);
@@ -252,13 +257,11 @@ void MessageQueue::_call_function(const Callable &p_callable, const Variant *p_a
Variant ret;
p_callable.call(argptrs, p_argcount, ret, ce);
if (p_show_error && ce.error != Callable::CallError::CALL_OK) {
-
ERR_PRINT("Error calling deferred method: " + Variant::get_callable_error_text(p_callable, argptrs, p_argcount, ce) + ".");
}
}
void MessageQueue::flush() {
-
if (buffer_end > buffer_max_used) {
buffer_max_used = buffer_end;
}
@@ -275,14 +278,14 @@ void MessageQueue::flush() {
flushing = true;
while (read_pos < buffer_end) {
-
//lock on each iteration, so a call can re-add itself to the message queue
Message *message = (Message *)&buffer[read_pos];
uint32_t advance = sizeof(Message);
- if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION)
+ if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
advance += sizeof(Variant) * message->args;
+ }
//pre-advance so this function is reentrant
read_pos += advance;
@@ -292,10 +295,8 @@ void MessageQueue::flush() {
Object *target = message->callable.get_object();
if (target != nullptr) {
-
switch (message->type & FLAG_MASK) {
case TYPE_CALL: {
-
Variant *args = (Variant *)(message + 1);
// messages don't expect a return value
@@ -304,13 +305,11 @@ void MessageQueue::flush() {
} break;
case TYPE_NOTIFICATION: {
-
// messages don't expect a return value
target->notification(message->notification);
} break;
case TYPE_SET: {
-
Variant *arg = (Variant *)(message + 1);
// messages don't expect a return value
target->set(message->callable.get_method(), *arg);
@@ -337,18 +336,13 @@ void MessageQueue::flush() {
}
bool MessageQueue::is_flushing() const {
-
return flushing;
}
MessageQueue::MessageQueue() {
-
ERR_FAIL_COND_MSG(singleton != nullptr, "A MessageQueue singleton already exists.");
singleton = this;
- flushing = false;
- buffer_end = 0;
- buffer_max_used = 0;
buffer_size = GLOBAL_DEF_RST("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB);
ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/message_queue/max_size_kb", PropertyInfo(Variant::INT, "memory/limits/message_queue/max_size_kb", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater"));
buffer_size *= 1024;
@@ -356,23 +350,23 @@ MessageQueue::MessageQueue() {
}
MessageQueue::~MessageQueue() {
-
uint32_t read_pos = 0;
while (read_pos < buffer_end) {
-
Message *message = (Message *)&buffer[read_pos];
Variant *args = (Variant *)(message + 1);
int argc = message->args;
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
- for (int i = 0; i < argc; i++)
+ for (int i = 0; i < argc; i++) {
args[i].~Variant();
+ }
}
message->~Message();
read_pos += sizeof(Message);
- if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION)
+ if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
read_pos += sizeof(Variant) * message->args;
+ }
}
singleton = nullptr;
diff --git a/core/message_queue.h b/core/message_queue.h
index 9ba748bb42..7d13e26208 100644
--- a/core/message_queue.h
+++ b/core/message_queue.h
@@ -35,7 +35,6 @@
#include "core/os/thread_safe.h"
class MessageQueue {
-
_THREAD_SAFE_CLASS_
enum {
@@ -53,7 +52,6 @@ class MessageQueue {
};
struct Message {
-
Callable callable;
int16_t type;
union {
@@ -63,15 +61,15 @@ class MessageQueue {
};
uint8_t *buffer;
- uint32_t buffer_end;
- uint32_t buffer_max_used;
+ uint32_t buffer_end = 0;
+ uint32_t buffer_max_used = 0;
uint32_t buffer_size;
void _call_function(const Callable &p_callable, const Variant *p_args, int p_argcount, bool p_show_error);
static MessageQueue *singleton;
- bool flushing;
+ bool flushing = false;
public:
static MessageQueue *get_singleton();
@@ -81,6 +79,7 @@ public:
Error push_notification(ObjectID p_id, int p_notification);
Error push_set(ObjectID p_id, const StringName &p_prop, const Variant &p_value);
Error push_callable(const Callable &p_callable, const Variant **p_args, int p_argcount, bool p_show_error = false);
+ Error push_callable(const Callable &p_callable, VARIANT_ARG_LIST);
Error push_call(Object *p_object, const StringName &p_method, VARIANT_ARG_LIST);
Error push_notification(Object *p_object, int p_notification);
diff --git a/core/method_bind.cpp b/core/method_bind.cpp
index c513de9ca0..3244c63292 100644
--- a/core/method_bind.cpp
+++ b/core/method_bind.cpp
@@ -36,7 +36,6 @@
#ifdef DEBUG_METHODS_ENABLED
PropertyInfo MethodBind::get_argument_info(int p_argument) const {
-
ERR_FAIL_INDEX_V(p_argument, get_argument_count(), PropertyInfo());
PropertyInfo info = _gen_argument_type_info(p_argument);
@@ -45,35 +44,32 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const {
}
PropertyInfo MethodBind::get_return_info() const {
-
return _gen_argument_type_info(-1);
}
#endif
void MethodBind::_set_const(bool p_const) {
-
_const = p_const;
}
void MethodBind::_set_returns(bool p_returns) {
-
_returns = p_returns;
}
StringName MethodBind::get_name() const {
return name;
}
+
void MethodBind::set_name(const StringName &p_name) {
name = p_name;
}
#ifdef DEBUG_METHODS_ENABLED
void MethodBind::set_argument_names(const Vector<StringName> &p_names) {
-
arg_names = p_names;
}
-Vector<StringName> MethodBind::get_argument_names() const {
+Vector<StringName> MethodBind::get_argument_names() const {
return arg_names;
}
@@ -86,7 +82,6 @@ void MethodBind::set_default_arguments(const Vector<Variant> &p_defargs) {
#ifdef DEBUG_METHODS_ENABLED
void MethodBind::_generate_argument_types(int p_count) {
-
set_argument_count(p_count);
Variant::Type *argt = memnew_arr(Variant::Type, p_count + 1);
@@ -104,19 +99,12 @@ void MethodBind::_generate_argument_types(int p_count) {
MethodBind::MethodBind() {
static int last_id = 0;
method_id = last_id++;
- hint_flags = METHOD_FLAGS_DEFAULT;
- argument_count = 0;
- default_argument_count = 0;
-#ifdef DEBUG_METHODS_ENABLED
- argument_types = nullptr;
-#endif
- _const = false;
- _returns = false;
}
MethodBind::~MethodBind() {
#ifdef DEBUG_METHODS_ENABLED
- if (argument_types)
+ if (argument_types) {
memdelete_arr(argument_types);
+ }
#endif
}
diff --git a/core/method_bind.h b/core/method_bind.h
index b3d4f1bf9b..ff2c771f81 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -59,27 +59,21 @@ enum MethodFlags {
template <class T>
struct VariantCaster {
-
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
-
return p_variant;
}
};
template <class T>
struct VariantCaster<T &> {
-
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
-
return p_variant;
}
};
template <class T>
struct VariantCaster<const T &> {
-
static _FORCE_INLINE_ T cast(const Variant &p_variant) {
-
return p_variant;
}
};
@@ -93,7 +87,6 @@ struct VariantCaster<const T &> {
MAKE_ENUM_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<m_enum> { \
- \
static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \
return (m_enum)p_variant.operator int(); \
} \
@@ -114,7 +107,6 @@ struct VariantCaster<const T &> {
MAKE_ENUM_TYPE_INFO(m_enum) \
template <> \
struct VariantCaster<m_enum> { \
- \
static _FORCE_INLINE_ m_enum cast(const Variant &p_variant) { \
return (m_enum)p_variant.operator int(); \
} \
@@ -165,8 +157,9 @@ struct VariantObjectClassChecker<Control *> {
#define CHECK_NOARG(m_arg) \
{ \
if (p_arg##m_arg.get_type() != Variant::NIL) { \
- if (r_argerror) \
+ if (r_argerror) { \
*r_argerror = (m_arg - 1); \
+ } \
return CALL_ERROR_EXTRA_ARGUMENT; \
} \
}
@@ -206,20 +199,19 @@ struct PtrToArg<wchar_t> {
#endif
class MethodBind {
-
int method_id;
- uint32_t hint_flags;
+ uint32_t hint_flags = METHOD_FLAGS_DEFAULT;
StringName name;
Vector<Variant> default_arguments;
- int default_argument_count;
- int argument_count;
+ int default_argument_count = 0;
+ int argument_count = 0;
- bool _const;
- bool _returns;
+ bool _const = false;
+ bool _returns = false;
protected:
#ifdef DEBUG_METHODS_ENABLED
- Variant::Type *argument_types;
+ Variant::Type *argument_types = nullptr;
Vector<StringName> arg_names;
#endif
void _set_const(bool p_const);
@@ -237,29 +229,28 @@ public:
_FORCE_INLINE_ int get_default_argument_count() const { return default_argument_count; }
_FORCE_INLINE_ Variant has_default_argument(int p_arg) const {
-
int idx = argument_count - p_arg - 1;
- if (idx < 0 || idx >= default_arguments.size())
+ if (idx < 0 || idx >= default_arguments.size()) {
return false;
- else
+ } else {
return true;
+ }
}
_FORCE_INLINE_ Variant get_default_argument(int p_arg) const {
-
int idx = argument_count - p_arg - 1;
- if (idx < 0 || idx >= default_arguments.size())
+ if (idx < 0 || idx >= default_arguments.size()) {
return Variant();
- else
+ } else {
return default_arguments[idx];
+ }
}
#ifdef DEBUG_METHODS_ENABLED
_FORCE_INLINE_ Variant::Type get_argument_type(int p_argument) const {
-
ERR_FAIL_COND_V(p_argument < -1 || p_argument > argument_count, Variant::NIL);
return argument_types[p_argument + 1];
}
@@ -304,17 +295,15 @@ public:
typedef Variant (T::*NativeCall)(const Variant **, int, Callable::CallError &);
protected:
- NativeCall call_method;
+ NativeCall call_method = nullptr;
#ifdef DEBUG_METHODS_ENABLED
-
MethodInfo arguments;
-
#endif
+
public:
#ifdef DEBUG_METHODS_ENABLED
virtual PropertyInfo _gen_argument_type_info(int p_arg) const {
-
if (p_arg < 0) {
return arguments.return_val;
} else if (p_arg < arguments.arguments.size()) {
@@ -340,23 +329,19 @@ public:
#endif
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
-
T *instance = static_cast<T *>(p_object);
return (instance->*call_method)(p_args, p_arg_count, r_error);
}
void set_method_info(const MethodInfo &p_info, bool p_return_nil_is_variant) {
-
set_argument_count(p_info.arguments.size());
#ifdef DEBUG_METHODS_ENABLED
Variant::Type *at = memnew_arr(Variant::Type, p_info.arguments.size() + 1);
at[0] = p_info.return_val.type;
if (p_info.arguments.size()) {
-
Vector<StringName> names;
names.resize(p_info.arguments.size());
for (int i = 0; i < p_info.arguments.size(); i++) {
-
at[i + 1] = p_info.arguments[i].type;
names.write[i] = p_info.arguments[i].name;
}
@@ -384,14 +369,12 @@ public:
virtual bool is_vararg() const { return true; }
MethodBindVarArg() {
- call_method = nullptr;
_set_returns(true);
}
};
template <class T>
MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, int, Callable::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) {
-
MethodBindVarArg<T> *a = memnew((MethodBindVarArg<T>));
a->set_method(p_method);
a->set_method_info(p_info, p_return_nil_is_variant);
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index 7ae0a788bd..022ed2a5d6 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -150,28 +150,22 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
template <class T>
struct PtrToArg<T *> {
-
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
-
return const_cast<T *>(reinterpret_cast<const T *>(p_ptr));
}
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
-
*((T **)p_ptr) = p_var;
}
};
template <class T>
struct PtrToArg<const T *> {
-
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
-
return reinterpret_cast<const T *>(p_ptr);
}
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
-
*((T **)p_ptr) = p_var;
}
};
@@ -181,12 +175,10 @@ struct PtrToArg<const T *> {
template <>
struct PtrToArg<ObjectID> {
_FORCE_INLINE_ static const ObjectID convert(const void *p_ptr) {
-
return ObjectID(*reinterpret_cast<const uint64_t *>(p_ptr));
}
_FORCE_INLINE_ static void encode(const ObjectID &p_val, void *p_ptr) {
-
*((uint64_t *)p_ptr) = p_val;
}
};
diff --git a/core/node_path.cpp b/core/node_path.cpp
index 25f1b38346..2a51dca74a 100644
--- a/core/node_path.cpp
+++ b/core/node_path.cpp
@@ -33,7 +33,6 @@
#include "core/print_string.h"
void NodePath::_update_hash_cache() const {
-
uint32_t h = data->absolute ? 1 : 0;
int pc = data->path.size();
const StringName *sn = data->path.ptr();
@@ -51,7 +50,6 @@ void NodePath::_update_hash_cache() const {
}
void NodePath::prepend_period() {
-
if (data->path.size() && data->path[0].operator String() != ".") {
data->path.insert(0, ".");
data->hash_cache_valid = false;
@@ -59,59 +57,60 @@ void NodePath::prepend_period() {
}
bool NodePath::is_absolute() const {
-
- if (!data)
+ if (!data) {
return false;
+ }
return data->absolute;
}
-int NodePath::get_name_count() const {
- if (!data)
+int NodePath::get_name_count() const {
+ if (!data) {
return 0;
+ }
return data->path.size();
}
-StringName NodePath::get_name(int p_idx) const {
+StringName NodePath::get_name(int p_idx) const {
ERR_FAIL_COND_V(!data, StringName());
ERR_FAIL_INDEX_V(p_idx, data->path.size(), StringName());
return data->path[p_idx];
}
int NodePath::get_subname_count() const {
-
- if (!data)
+ if (!data) {
return 0;
+ }
return data->subpath.size();
}
-StringName NodePath::get_subname(int p_idx) const {
+StringName NodePath::get_subname(int p_idx) const {
ERR_FAIL_COND_V(!data, StringName());
ERR_FAIL_INDEX_V(p_idx, data->subpath.size(), StringName());
return data->subpath[p_idx];
}
void NodePath::unref() {
-
if (data && data->refcount.unref()) {
-
memdelete(data);
}
data = nullptr;
}
bool NodePath::operator==(const NodePath &p_path) const {
-
- if (data == p_path.data)
+ if (data == p_path.data) {
return true;
+ }
- if (!data || !p_path.data)
+ if (!data || !p_path.data) {
return false;
+ }
- if (data->absolute != p_path.data->absolute)
+ if (data->absolute != p_path.data->absolute) {
return false;
+ }
int path_size = data->path.size();
@@ -129,85 +128,74 @@ bool NodePath::operator==(const NodePath &p_path) const {
const StringName *r_path_ptr = p_path.data->path.ptr();
for (int i = 0; i < path_size; i++) {
-
- if (l_path_ptr[i] != r_path_ptr[i])
+ if (l_path_ptr[i] != r_path_ptr[i]) {
return false;
+ }
}
const StringName *l_subpath_ptr = data->subpath.ptr();
const StringName *r_subpath_ptr = p_path.data->subpath.ptr();
for (int i = 0; i < subpath_size; i++) {
-
- if (l_subpath_ptr[i] != r_subpath_ptr[i])
+ if (l_subpath_ptr[i] != r_subpath_ptr[i]) {
return false;
+ }
}
return true;
}
-bool NodePath::operator!=(const NodePath &p_path) const {
+bool NodePath::operator!=(const NodePath &p_path) const {
return (!(*this == p_path));
}
void NodePath::operator=(const NodePath &p_path) {
-
- if (this == &p_path)
+ if (this == &p_path) {
return;
+ }
unref();
if (p_path.data && p_path.data->refcount.ref()) {
-
data = p_path.data;
}
}
NodePath::operator String() const {
-
- if (!data)
+ if (!data) {
return String();
+ }
String ret;
- if (data->absolute)
+ if (data->absolute) {
ret = "/";
+ }
for (int i = 0; i < data->path.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
ret += "/";
+ }
ret += data->path[i].operator String();
}
for (int i = 0; i < data->subpath.size(); i++) {
-
ret += ":" + data->subpath[i].operator String();
}
return ret;
}
-NodePath::NodePath(const NodePath &p_path) {
-
- data = nullptr;
-
- if (p_path.data && p_path.data->refcount.ref()) {
-
- data = p_path.data;
- }
-}
-
Vector<StringName> NodePath::get_names() const {
-
- if (data)
+ if (data) {
return data->path;
+ }
return Vector<StringName>();
}
Vector<StringName> NodePath::get_subnames() const {
-
- if (data)
+ if (data) {
return data->subpath;
+ }
return Vector<StringName>();
}
@@ -227,7 +215,6 @@ StringName NodePath::get_concatenated_subnames() const {
}
NodePath NodePath::rel_path_to(const NodePath &p_np) const {
-
ERR_FAIL_COND_V(!is_absolute(), NodePath());
ERR_FAIL_COND_V(!p_np.is_absolute(), NodePath());
@@ -238,12 +225,15 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const {
int common_parent = 0;
while (true) {
- if (src_dirs.size() == common_parent)
+ if (src_dirs.size() == common_parent) {
break;
- if (dst_dirs.size() == common_parent)
+ }
+ if (dst_dirs.size() == common_parent) {
break;
- if (src_dirs[common_parent] != dst_dirs[common_parent])
+ }
+ if (src_dirs[common_parent] != dst_dirs[common_parent]) {
break;
+ }
common_parent++;
}
@@ -252,23 +242,21 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const {
Vector<StringName> relpath;
for (int i = src_dirs.size() - 1; i > common_parent; i--) {
-
relpath.push_back("..");
}
for (int i = common_parent + 1; i < dst_dirs.size(); i++) {
-
relpath.push_back(dst_dirs[i]);
}
- if (relpath.size() == 0)
+ if (relpath.size() == 0) {
relpath.push_back(".");
+ }
return NodePath(relpath, p_np.get_subnames(), false);
}
NodePath NodePath::get_as_property_path() const {
-
if (!data || !data->path.size()) {
return *this;
} else {
@@ -285,44 +273,18 @@ NodePath NodePath::get_as_property_path() const {
}
}
-NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) {
-
- data = nullptr;
-
- if (p_path.size() == 0)
- return;
-
- data = memnew(Data);
- data->refcount.init();
- data->absolute = p_absolute;
- data->path = p_path;
- data->has_slashes = true;
- data->hash_cache_valid = false;
-}
-
-NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p_subpath, bool p_absolute) {
-
- data = nullptr;
-
- if (p_path.size() == 0 && p_subpath.size() == 0)
- return;
-
- data = memnew(Data);
- data->refcount.init();
- data->absolute = p_absolute;
- data->path = p_path;
- data->subpath = p_subpath;
- data->has_slashes = true;
- data->hash_cache_valid = false;
+bool NodePath::is_empty() const {
+ return !data;
}
void NodePath::simplify() {
-
- if (!data)
+ if (!data) {
return;
+ }
for (int i = 0; i < data->path.size(); i++) {
- if (data->path.size() == 1)
+ if (data->path.size() == 1) {
break;
+ }
if (data->path[i].operator String() == ".") {
data->path.remove(i);
i--;
@@ -341,18 +303,48 @@ void NodePath::simplify() {
}
NodePath NodePath::simplified() const {
-
NodePath np = *this;
np.simplify();
return np;
}
-NodePath::NodePath(const String &p_path) {
+NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) {
+ if (p_path.size() == 0) {
+ return;
+ }
- data = nullptr;
+ data = memnew(Data);
+ data->refcount.init();
+ data->absolute = p_absolute;
+ data->path = p_path;
+ data->has_slashes = true;
+ data->hash_cache_valid = false;
+}
- if (p_path.length() == 0)
+NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p_subpath, bool p_absolute) {
+ if (p_path.size() == 0 && p_subpath.size() == 0) {
return;
+ }
+
+ data = memnew(Data);
+ data->refcount.init();
+ data->absolute = p_absolute;
+ data->path = p_path;
+ data->subpath = p_subpath;
+ data->has_slashes = true;
+ data->hash_cache_valid = false;
+}
+
+NodePath::NodePath(const NodePath &p_path) {
+ if (p_path.data && p_path.data->refcount.ref()) {
+ data = p_path.data;
+ }
+}
+
+NodePath::NodePath(const String &p_path) {
+ if (p_path.length() == 0) {
+ return;
+ }
String path = p_path;
Vector<StringName> subpath;
@@ -364,17 +356,15 @@ NodePath::NodePath(const String &p_path) {
int subpath_pos = path.find(":");
if (subpath_pos != -1) {
-
int from = subpath_pos + 1;
for (int i = from; i <= path.length(); i++) {
-
if (path[i] == ':' || path[i] == 0) {
-
String str = path.substr(from, i - from);
if (str == "") {
- if (path[i] == 0)
+ if (path[i] == 0) {
continue; // Allow end-of-path :
+ }
ERR_FAIL_MSG("Invalid NodePath '" + p_path + "'.");
}
@@ -388,22 +378,21 @@ NodePath::NodePath(const String &p_path) {
}
for (int i = (int)absolute; i < path.length(); i++) {
-
if (path[i] == '/') {
-
last_is_slash = true;
has_slashes = true;
} else {
-
- if (last_is_slash)
+ if (last_is_slash) {
slices++;
+ }
last_is_slash = false;
}
}
- if (slices == 0 && !absolute && !subpath.size())
+ if (slices == 0 && !absolute && !subpath.size()) {
return;
+ }
data = memnew(Data);
data->refcount.init();
@@ -412,19 +401,17 @@ NodePath::NodePath(const String &p_path) {
data->subpath = subpath;
data->hash_cache_valid = false;
- if (slices == 0)
+ if (slices == 0) {
return;
+ }
data->path.resize(slices);
last_is_slash = true;
int from = (int)absolute;
int slice = 0;
for (int i = (int)absolute; i < path.length() + 1; i++) {
-
if (path[i] == '/' || path[i] == 0) {
-
if (!last_is_slash) {
-
String name = path.substr(from, i - from);
ERR_FAIL_INDEX(slice, data->path.size());
data->path.write[slice++] = name;
@@ -437,16 +424,6 @@ NodePath::NodePath(const String &p_path) {
}
}
-bool NodePath::is_empty() const {
-
- return !data;
-}
-NodePath::NodePath() {
-
- data = nullptr;
-}
-
NodePath::~NodePath() {
-
unref();
}
diff --git a/core/node_path.h b/core/node_path.h
index 76de36cd9f..7c06bf01ce 100644
--- a/core/node_path.h
+++ b/core/node_path.h
@@ -35,9 +35,7 @@
#include "core/ustring.h"
class NodePath {
-
struct Data {
-
SafeRefCount refcount;
Vector<StringName> path;
Vector<StringName> subpath;
@@ -48,7 +46,7 @@ class NodePath {
mutable uint32_t hash_cache;
};
- mutable Data *data;
+ mutable Data *data = nullptr;
void unref();
void _update_hash_cache() const;
@@ -71,8 +69,9 @@ public:
NodePath get_parent() const;
_FORCE_INLINE_ uint32_t hash() const {
- if (!data)
+ if (!data) {
return 0;
+ }
if (!data->hash_cache_valid) {
_update_hash_cache();
}
@@ -93,7 +92,7 @@ public:
NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p_subpath, bool p_absolute);
NodePath(const NodePath &p_path);
NodePath(const String &p_path);
- NodePath();
+ NodePath() {}
~NodePath();
};
diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h
index 71e3ba9068..775e17fdb5 100644
--- a/core/oa_hash_map.h
+++ b/core/oa_hash_map.h
@@ -45,20 +45,24 @@
*
* The entries are stored inplace, so huge keys or values might fill cache lines
* a lot faster.
+ *
+ * Only used keys and values are constructed. For free positions there's space
+ * in the arrays for each, but that memory is kept uninitialized.
+ *
+ * The assignment operator copy the pairs from one map to the other.
*/
template <class TKey, class TValue,
class Hasher = HashMapHasherDefault,
class Comparator = HashMapComparatorDefault<TKey>>
class OAHashMap {
-
private:
- TValue *values;
- TKey *keys;
- uint32_t *hashes;
+ TValue *values = nullptr;
+ TKey *keys = nullptr;
+ uint32_t *hashes = nullptr;
- uint32_t capacity;
+ uint32_t capacity = 0;
- uint32_t num_elements;
+ uint32_t num_elements = 0;
static const uint32_t EMPTY_HASH = 0;
@@ -90,7 +94,7 @@ private:
uint32_t pos = hash % capacity;
uint32_t distance = 0;
- while (42) {
+ while (true) {
if (hashes[pos] == EMPTY_HASH) {
return false;
}
@@ -110,7 +114,6 @@ private:
}
void _insert_with_hash(uint32_t p_hash, const TKey &p_key, const TValue &p_value) {
-
uint32_t hash = p_hash;
uint32_t distance = 0;
uint32_t pos = hash % capacity;
@@ -118,7 +121,7 @@ private:
TKey key = p_key;
TValue value = p_value;
- while (42) {
+ while (true) {
if (hashes[pos] == EMPTY_HASH) {
_construct(pos, hash, key, value);
@@ -140,34 +143,43 @@ private:
}
void _resize_and_rehash(uint32_t p_new_capacity) {
-
uint32_t old_capacity = capacity;
- capacity = p_new_capacity;
+
+ // Capacity can't be 0.
+ capacity = MAX(1, p_new_capacity);
TKey *old_keys = keys;
TValue *old_values = values;
uint32_t *old_hashes = hashes;
num_elements = 0;
- keys = memnew_arr(TKey, capacity);
- values = memnew_arr(TValue, capacity);
- hashes = memnew_arr(uint32_t, capacity);
+ keys = static_cast<TKey *>(Memory::alloc_static(sizeof(TKey) * capacity));
+ values = static_cast<TValue *>(Memory::alloc_static(sizeof(TValue) * capacity));
+ hashes = static_cast<uint32_t *>(Memory::alloc_static(sizeof(uint32_t) * capacity));
for (uint32_t i = 0; i < capacity; i++) {
hashes[i] = 0;
}
+ if (old_capacity == 0) {
+ // Nothing to do.
+ return;
+ }
+
for (uint32_t i = 0; i < old_capacity; i++) {
if (old_hashes[i] == EMPTY_HASH) {
continue;
}
_insert_with_hash(old_hashes[i], old_keys[i], old_values[i]);
+
+ old_keys[i].~TKey();
+ old_values[i].~TValue();
}
- memdelete_arr(old_keys);
- memdelete_arr(old_values);
- memdelete_arr(old_hashes);
+ Memory::free_static(old_keys);
+ Memory::free_static(old_values);
+ Memory::free_static(old_hashes);
}
void _resize_and_rehash() {
@@ -183,9 +195,7 @@ public:
}
void clear() {
-
for (uint32_t i = 0; i < capacity; i++) {
-
if (hashes[i] == EMPTY_HASH) {
continue;
}
@@ -199,7 +209,6 @@ public:
}
void insert(const TKey &p_key, const TValue &p_value) {
-
if (num_elements + 1 > 0.9 * capacity) {
_resize_and_rehash();
}
@@ -214,8 +223,7 @@ public:
bool exists = _lookup_pos(p_key, pos);
if (exists) {
- values[pos].~TValue();
- memnew_placement(&values[pos], TValue(p_data));
+ values[pos] = p_data;
} else {
insert(p_key, p_data);
}
@@ -232,8 +240,7 @@ public:
bool exists = _lookup_pos(p_key, pos);
if (exists) {
- r_data.~TValue();
- memnew_placement(&r_data, TValue(values[pos]));
+ r_data = values[pos];
return true;
}
@@ -300,7 +307,7 @@ public:
bool valid;
const TKey *key;
- const TValue *value;
+ TValue *value;
private:
uint32_t pos;
@@ -317,7 +324,6 @@ public:
}
Iterator next_iter(const Iterator &p_iter) const {
-
if (!p_iter.valid) {
return p_iter;
}
@@ -344,28 +350,49 @@ public:
return it;
}
- OAHashMap(const OAHashMap &) = delete; // Delete the copy constructor so we don't get unexpected copies and dangling pointers.
- OAHashMap &operator=(const OAHashMap &) = delete; // Same for assignment operator.
+ OAHashMap(const OAHashMap &p_other) {
+ (*this) = p_other;
+ }
- OAHashMap(uint32_t p_initial_capacity = 64) {
+ OAHashMap &operator=(const OAHashMap &p_other) {
+ if (capacity != 0) {
+ clear();
+ }
- capacity = p_initial_capacity;
- num_elements = 0;
+ _resize_and_rehash(p_other.capacity);
+
+ for (Iterator it = p_other.iter(); it.valid; it = p_other.next_iter(it)) {
+ set(*it.key, *it.value);
+ }
+ return *this;
+ }
- keys = memnew_arr(TKey, p_initial_capacity);
- values = memnew_arr(TValue, p_initial_capacity);
- hashes = memnew_arr(uint32_t, p_initial_capacity);
+ OAHashMap(uint32_t p_initial_capacity = 64) {
+ // Capacity can't be 0.
+ capacity = MAX(1, p_initial_capacity);
+
+ keys = static_cast<TKey *>(Memory::alloc_static(sizeof(TKey) * capacity));
+ values = static_cast<TValue *>(Memory::alloc_static(sizeof(TValue) * capacity));
+ hashes = static_cast<uint32_t *>(Memory::alloc_static(sizeof(uint32_t) * capacity));
- for (uint32_t i = 0; i < p_initial_capacity; i++) {
+ for (uint32_t i = 0; i < capacity; i++) {
hashes[i] = EMPTY_HASH;
}
}
~OAHashMap() {
+ for (uint32_t i = 0; i < capacity; i++) {
+ if (hashes[i] == EMPTY_HASH) {
+ continue;
+ }
+
+ values[i].~TValue();
+ keys[i].~TKey();
+ }
- memdelete_arr(keys);
- memdelete_arr(values);
- memdelete_arr(hashes);
+ Memory::free_static(keys);
+ Memory::free_static(values);
+ Memory::free_static(hashes);
}
};
diff --git a/core/object.cpp b/core/object.cpp
index 94d957f3af..8abea9ca7e 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -42,7 +42,6 @@
#ifdef DEBUG_ENABLED
struct _ObjectDebugLock {
-
Object *obj;
_ObjectDebugLock(Object *p_obj) {
@@ -63,7 +62,6 @@ struct _ObjectDebugLock {
#endif
PropertyInfo::operator Dictionary() const {
-
Dictionary d;
d["name"] = name;
d["class_name"] = class_name;
@@ -75,36 +73,38 @@ PropertyInfo::operator Dictionary() const {
}
PropertyInfo PropertyInfo::from_dict(const Dictionary &p_dict) {
-
PropertyInfo pi;
- if (p_dict.has("type"))
+ if (p_dict.has("type")) {
pi.type = Variant::Type(int(p_dict["type"]));
+ }
- if (p_dict.has("name"))
+ if (p_dict.has("name")) {
pi.name = p_dict["name"];
+ }
- if (p_dict.has("class_name"))
+ if (p_dict.has("class_name")) {
pi.class_name = p_dict["class_name"];
+ }
- if (p_dict.has("hint"))
+ if (p_dict.has("hint")) {
pi.hint = PropertyHint(int(p_dict["hint"]));
+ }
- if (p_dict.has("hint_string"))
-
+ if (p_dict.has("hint_string")) {
pi.hint_string = p_dict["hint_string"];
+ }
- if (p_dict.has("usage"))
+ if (p_dict.has("usage")) {
pi.usage = p_dict["usage"];
+ }
return pi;
}
Array convert_property_list(const List<PropertyInfo> *p_list) {
-
Array va;
for (const List<PropertyInfo>::Element *E = p_list->front(); E; E = E->next()) {
-
va.push_back(Dictionary(E->get()));
}
@@ -112,13 +112,13 @@ Array convert_property_list(const List<PropertyInfo> *p_list) {
}
MethodInfo::operator Dictionary() const {
-
Dictionary d;
d["name"] = name;
d["args"] = convert_property_list(&arguments);
Array da;
- for (int i = 0; i < default_arguments.size(); i++)
+ for (int i = 0; i < default_arguments.size(); i++) {
da.push_back(default_arguments[i]);
+ }
d["default_args"] = da;
d["flags"] = flags;
d["id"] = id;
@@ -127,17 +127,12 @@ MethodInfo::operator Dictionary() const {
return d;
}
-MethodInfo::MethodInfo() :
- flags(METHOD_FLAG_NORMAL),
- id(0) {
-}
-
MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
-
MethodInfo mi;
- if (p_dict.has("name"))
+ if (p_dict.has("name")) {
mi.name = p_dict["name"];
+ }
Array args;
if (p_dict.has("args")) {
args = p_dict["args"];
@@ -159,35 +154,37 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
mi.return_val = PropertyInfo::from_dict(p_dict["return"]);
}
- if (p_dict.has("flags"))
+ if (p_dict.has("flags")) {
mi.flags = p_dict["flags"];
+ }
return mi;
}
+MethodInfo::MethodInfo() :
+ flags(METHOD_FLAG_NORMAL) {}
+
MethodInfo::MethodInfo(const String &p_name) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
}
+
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
}
+
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
}
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
@@ -195,8 +192,7 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
@@ -205,8 +201,7 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
@@ -215,28 +210,26 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const
}
MethodInfo::MethodInfo(Variant::Type ret) :
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
}
+
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
arguments.push_back(p_param1);
}
+
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
@@ -244,8 +237,7 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
@@ -254,8 +246,7 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
@@ -265,8 +256,7 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) :
name(p_name),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
@@ -278,23 +268,20 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn
MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name) :
name(p_name),
return_val(p_ret),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
}
MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1) :
name(p_name),
return_val(p_ret),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
}
MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) :
name(p_name),
return_val(p_ret),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
}
@@ -302,8 +289,7 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr
MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) :
name(p_name),
return_val(p_ret),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
@@ -312,8 +298,7 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr
MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) :
name(p_name),
return_val(p_ret),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
@@ -323,8 +308,7 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr
MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) :
name(p_name),
return_val(p_ret),
- flags(METHOD_FLAG_NORMAL),
- id(0) {
+ flags(METHOD_FLAG_NORMAL) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
@@ -333,7 +317,6 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr
}
Object::Connection::operator Variant() const {
-
Dictionary d;
d["signal"] = signal;
d["callable"] = callable;
@@ -343,28 +326,30 @@ Object::Connection::operator Variant() const {
}
bool Object::Connection::operator<(const Connection &p_conn) const {
-
if (signal == p_conn.signal) {
return callable < p_conn.callable;
} else {
return signal < p_conn.signal;
}
}
-Object::Connection::Connection(const Variant &p_variant) {
+Object::Connection::Connection(const Variant &p_variant) {
Dictionary d = p_variant;
- if (d.has("signal"))
+ if (d.has("signal")) {
signal = d["signal"];
- if (d.has("callable"))
+ }
+ if (d.has("callable")) {
callable = d["callable"];
- if (d.has("flags"))
+ }
+ if (d.has("flags")) {
flags = d["flags"];
- if (d.has("binds"))
+ }
+ if (d.has("binds")) {
binds = d["binds"];
+ }
}
bool Object::_predelete() {
-
_predelete_ok = 1;
notification(NOTIFICATION_PREDELETE, true);
if (_predelete_ok) {
@@ -381,21 +366,21 @@ void Object::_postinitialize() {
void Object::get_valid_parents_static(List<String> *p_parents) {
}
+
void Object::_get_valid_parents_static(List<String> *p_parents) {
}
void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) {
-
#ifdef TOOLS_ENABLED
_edited = true;
#endif
if (script_instance) {
-
if (script_instance->set(p_name, p_value)) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return;
}
}
@@ -413,23 +398,26 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
if (p_name == CoreStringNames::get_singleton()->_script) {
set_script(p_value);
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return;
} else if (p_name == CoreStringNames::get_singleton()->_meta) {
//set_meta(p_name,p_value);
metadata = p_value.duplicate();
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return;
}
//something inside the object... :|
bool success = _setv(p_name, p_value);
if (success) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return;
}
@@ -437,8 +425,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
bool valid;
setvar(p_name, p_value, &valid);
if (valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return;
}
}
@@ -448,26 +437,27 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
bool valid;
script_instance->property_set_fallback(p_name, p_value, &valid);
if (valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return;
}
}
#endif
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
}
Variant Object::get(const StringName &p_name, bool *r_valid) const {
-
Variant ret;
if (script_instance) {
-
if (script_instance->get(p_name, ret)) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
}
}
@@ -475,30 +465,34 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
//try built-in setgetter
{
if (ClassDB::get_property(const_cast<Object *>(this), p_name, ret)) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
}
}
if (p_name == CoreStringNames::get_singleton()->_script) {
ret = get_script();
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
} else if (p_name == CoreStringNames::get_singleton()->_meta) {
ret = metadata;
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
} else {
//something inside the object... :|
bool success = _getv(p_name, ret);
if (success) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
}
@@ -507,8 +501,9 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
bool valid;
ret = getvar(p_name, &valid);
if (valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
}
}
@@ -518,23 +513,26 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
bool valid;
ret = script_instance->property_get_fallback(p_name, &valid);
if (valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret;
}
}
#endif
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant();
}
}
void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_value, bool *r_valid) {
if (p_names.empty()) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return;
}
if (p_names.size() == 1) {
@@ -543,8 +541,9 @@ void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_val
}
bool valid = false;
- if (!r_valid)
+ if (!r_valid) {
r_valid = &valid;
+ }
List<Variant> value_stack;
@@ -567,7 +566,6 @@ void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_val
value_stack.push_back(p_value); // p_names[p_names.size() - 1]
for (int i = p_names.size() - 1; i > 0; i--) {
-
value_stack.back()->prev()->get().set_named(p_names[i], value_stack.back()->get(), r_valid);
value_stack.pop_back();
@@ -585,8 +583,9 @@ void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_val
Variant Object::get_indexed(const Vector<StringName> &p_names, bool *r_valid) const {
if (p_names.empty()) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant();
}
bool valid = false;
@@ -595,17 +594,18 @@ Variant Object::get_indexed(const Vector<StringName> &p_names, bool *r_valid) co
for (int i = 1; i < p_names.size(); i++) {
current_value = current_value.get_named(p_names[i], &valid);
- if (!valid)
+ if (!valid) {
break;
+ }
}
- if (r_valid)
+ if (r_valid) {
*r_valid = valid;
+ }
return current_value;
}
void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) const {
-
if (script_instance && p_reversed) {
p_list->push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY));
script_instance->get_property_list(p_list);
@@ -632,7 +632,6 @@ void Object::_validate_property(PropertyInfo &property) const {
}
void Object::get_method_list(List<MethodInfo> *p_list) const {
-
ClassDB::get_method_list(get_class_name(), p_list);
if (script_instance) {
script_instance->get_method_list(p_list);
@@ -640,7 +639,6 @@ void Object::get_method_list(List<MethodInfo> *p_list) const {
}
Variant Object::_call_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 0;
@@ -660,7 +658,6 @@ Variant Object::_call_bind(const Variant **p_args, int p_argcount, Callable::Cal
}
Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 0;
@@ -685,24 +682,19 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Call
#ifdef DEBUG_ENABLED
static void _test_call_error(const StringName &p_func, const Callable::CallError &error) {
-
switch (error.error) {
-
case Callable::CallError::CALL_OK:
case Callable::CallError::CALL_ERROR_INVALID_METHOD:
break;
case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
-
ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Invalid type for argument " + itos(error.argument) + ", expected " + Variant::get_type_name(Variant::Type(error.expected)) + ".");
break;
}
case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
-
ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Too many arguments, expected " + itos(error.argument) + ".");
break;
}
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
-
ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Too few arguments, expected " + itos(error.argument) + ".");
break;
}
@@ -717,7 +709,6 @@ static void _test_call_error(const StringName &p_func, const Callable::CallError
#endif
void Object::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
-
if (p_method == CoreStringNames::get_singleton()->_free) {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(Object::cast_to<Reference>(this), "Can't 'free' a reference.");
@@ -743,21 +734,18 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
MethodBind *method = ClassDB::get_method(get_class_name(), p_method);
if (method) {
-
method->call(this, p_args, p_argcount, error);
_test_call_error(p_method, error);
}
}
void Object::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
-
MethodBind *method = ClassDB::get_method(get_class_name(), p_method);
Callable::CallError error;
OBJ_DEBUG_LOCK
if (method) {
-
method->call(this, p_args, p_argcount, error);
_test_call_error(p_method, error);
}
@@ -771,7 +759,6 @@ void Object::call_multilevel_reversed(const StringName &p_method, const Variant
}
bool Object::has_method(const StringName &p_method) const {
-
if (p_method == CoreStringNames::get_singleton()->_free) {
return true;
}
@@ -786,15 +773,16 @@ bool Object::has_method(const StringName &p_method) const {
}
Variant Object::getvar(const Variant &p_key, bool *r_valid) const {
-
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant();
}
-void Object::setvar(const Variant &p_key, const Variant &p_value, bool *r_valid) {
- if (r_valid)
+void Object::setvar(const Variant &p_key, const Variant &p_value, bool *r_valid) {
+ if (r_valid) {
*r_valid = false;
+ }
}
Variant Object::callv(const StringName &p_method, const Array &p_args) {
@@ -816,13 +804,13 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) {
}
Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -833,13 +821,13 @@ Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) {
}
void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -848,7 +836,6 @@ void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) {
}
Variant Object::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_OK;
if (p_method == CoreStringNames::get_singleton()->_free) {
@@ -884,7 +871,6 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
ret = script_instance->call(p_method, p_args, p_argcount, r_error);
//force jumptable
switch (r_error.error) {
-
case Callable::CallError::CALL_OK:
return ret;
case Callable::CallError::CALL_ERROR_INVALID_METHOD:
@@ -910,7 +896,6 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
}
void Object::notification(int p_notification, bool p_reversed) {
-
_notificationv(p_notification, p_reversed);
if (script_instance) {
@@ -922,8 +907,9 @@ String Object::to_string() {
if (script_instance) {
bool valid;
String ret = script_instance->to_string(&valid);
- if (valid)
+ if (valid) {
return ret;
+ }
}
return "[" + get_class() + ":" + itos(get_instance_id()) + "]";
}
@@ -932,27 +918,22 @@ void Object::_changed_callback(Object *p_changed, const char *p_prop) {
}
void Object::add_change_receptor(Object *p_receptor) {
-
change_receptors.insert(p_receptor);
}
void Object::remove_change_receptor(Object *p_receptor) {
-
change_receptors.erase(p_receptor);
}
void Object::property_list_changed_notify() {
-
_change_notify();
}
void Object::cancel_delete() {
-
_predelete_ok = true;
}
void Object::set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance) {
-
//this function is not meant to be used in any of these ways
ERR_FAIL_COND(p_script.is_null());
ERR_FAIL_COND(!p_instance);
@@ -963,9 +944,9 @@ void Object::set_script_and_instance(const Variant &p_script, ScriptInstance *p_
}
void Object::set_script(const Variant &p_script) {
-
- if (script == p_script)
+ if (script == p_script) {
return;
+ }
if (script_instance) {
memdelete(script_instance);
@@ -990,43 +971,41 @@ void Object::set_script(const Variant &p_script) {
}
void Object::set_script_instance(ScriptInstance *p_instance) {
-
- if (script_instance == p_instance)
+ if (script_instance == p_instance) {
return;
+ }
- if (script_instance)
+ if (script_instance) {
memdelete(script_instance);
+ }
script_instance = p_instance;
- if (p_instance)
+ if (p_instance) {
script = p_instance->get_script();
- else
+ } else {
script = Variant();
+ }
}
Variant Object::get_script() const {
-
return script;
}
bool Object::has_meta(const String &p_name) const {
-
return metadata.has(p_name);
}
void Object::set_meta(const String &p_name, const Variant &p_value) {
-
if (p_value.get_type() == Variant::NIL) {
metadata.erase(p_name);
return;
- };
+ }
metadata[p_name] = p_value;
}
Variant Object::get_meta(const String &p_name) const {
-
ERR_FAIL_COND_V(!metadata.has(p_name), Variant());
return metadata[p_name];
}
@@ -1036,20 +1015,17 @@ void Object::remove_meta(const String &p_name) {
}
Array Object::_get_property_list_bind() const {
-
List<PropertyInfo> lpi;
get_property_list(&lpi);
return convert_property_list(&lpi);
}
Array Object::_get_method_list_bind() const {
-
List<MethodInfo> ml;
get_method_list(&ml);
Array ret;
for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) {
-
Dictionary d = E->get();
//va.push_back(d);
ret.push_back(d);
@@ -1059,30 +1035,26 @@ Array Object::_get_method_list_bind() const {
}
Vector<String> Object::_get_meta_list_bind() const {
-
Vector<String> _metaret;
List<Variant> keys;
metadata.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
_metaret.push_back(E->get());
}
return _metaret;
}
-void Object::get_meta_list(List<String> *p_list) const {
+void Object::get_meta_list(List<String> *p_list) const {
List<Variant> keys;
metadata.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
p_list->push_back(E->get());
}
}
void Object::add_user_signal(const MethodInfo &p_signal) {
-
ERR_FAIL_COND_MSG(p_signal.name == "", "Signal name cannot be empty.");
ERR_FAIL_COND_MSG(ClassDB::has_signal(get_class_name(), p_signal.name), "User signal's name conflicts with a built-in signal of '" + get_class_name() + "'.");
ERR_FAIL_COND_MSG(signal_map.has(p_signal.name), "Trying to add already existing signal '" + p_signal.name + "'.");
@@ -1092,20 +1064,18 @@ void Object::add_user_signal(const MethodInfo &p_signal) {
}
bool Object::_has_user_signal(const StringName &p_name) const {
-
- if (!signal_map.has(p_name))
+ if (!signal_map.has(p_name)) {
return false;
+ }
return signal_map[p_name].user.name.length() > 0;
}
struct _ObjectSignalDisconnectData {
-
StringName signal;
Callable callable;
};
Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
ERR_FAIL_COND_V(p_argcount < 1, Variant());
@@ -1133,9 +1103,9 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Callable::C
}
Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) {
-
- if (_block_signals)
+ if (_block_signals) {
return ERR_CANT_ACQUIRE_RESOURCE; //no emit, signals blocked
+ }
SignalData *s = signal_map.getptr(p_name);
if (!s) {
@@ -1164,7 +1134,6 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
Error err = OK;
for (int i = 0; i < ssize; i++) {
-
const Connection &c = slot_map.getv(i).conn;
Object *target = c.callable.get_object();
@@ -1202,8 +1171,9 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
if (ce.error != Callable::CallError::CALL_OK) {
#ifdef DEBUG_ENABLED
- if (c.flags & CONNECT_PERSIST && Engine::get_singleton()->is_editor_hint() && (script.is_null() || !Ref<Script>(script)->is_tool()))
+ if (c.flags & CONNECT_PERSIST && Engine::get_singleton()->is_editor_hint() && (script.is_null() || !Ref<Script>(script)->is_tool())) {
continue;
+ }
#endif
if (ce.error == Callable::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) {
//most likely object is not initialized yet, do not throw error.
@@ -1222,7 +1192,6 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
}
#endif
if (disconnect) {
-
_ObjectSignalDisconnectData dd;
dd.signal = p_name;
dd.callable = c.callable;
@@ -1231,7 +1200,6 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
}
while (!disconnect_data.empty()) {
-
const _ObjectSignalDisconnectData &dd = disconnect_data.front()->get();
_disconnect(dd.signal, dd.callable);
@@ -1242,15 +1210,14 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
}
Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
-
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -1258,7 +1225,6 @@ Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
}
void Object::_add_user_signal(const String &p_name, const Array &p_args) {
-
// this version of add_user_signal is meant to be used from scripts or external apis
// without access to ADD_SIGNAL in bind_methods
// added events are per instance, as opposed to the other ones, which are global
@@ -1267,14 +1233,15 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) {
mi.name = p_name;
for (int i = 0; i < p_args.size(); i++) {
-
Dictionary d = p_args[i];
PropertyInfo param;
- if (d.has("name"))
+ if (d.has("name")) {
param.name = d["name"];
- if (d.has("type"))
+ }
+ if (d.has("type")) {
param.type = (Variant::Type)(int)d["type"];
+ }
mi.arguments.push_back(param);
}
@@ -1283,13 +1250,11 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) {
}
Array Object::_get_signal_list() const {
-
List<MethodInfo> signal_list;
get_signal_list(&signal_list);
Array ret;
for (List<MethodInfo>::Element *E = signal_list.front(); E; E = E->next()) {
-
ret.push_back(Dictionary(E->get()));
}
@@ -1297,14 +1262,12 @@ Array Object::_get_signal_list() const {
}
Array Object::_get_signal_connection_list(const String &p_signal) const {
-
List<Connection> conns;
get_all_signal_connections(&conns);
Array ret;
for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
-
Connection &c = E->get();
if (c.signal.get_name() == p_signal) {
ret.push_back(c);
@@ -1315,7 +1278,6 @@ Array Object::_get_signal_connection_list(const String &p_signal) const {
}
Array Object::_get_incoming_connections() const {
-
Array ret;
int connections_amount = connections.size();
for (int idx_conn = 0; idx_conn < connections_amount; idx_conn++) {
@@ -1345,7 +1307,6 @@ bool Object::has_signal(const StringName &p_name) const {
}
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
-
if (!script.is_null()) {
Ref<Script> scr = script;
if (scr.is_valid()) {
@@ -1358,7 +1319,6 @@ void Object::get_signal_list(List<MethodInfo> *p_signals) const {
const StringName *S = nullptr;
while ((S = signal_map.next(S))) {
-
if (signal_map[*S].user.name != "") {
//user signal
p_signals->push_back(signal_map[*S].user);
@@ -1367,37 +1327,33 @@ void Object::get_signal_list(List<MethodInfo> *p_signals) const {
}
void Object::get_all_signal_connections(List<Connection> *p_connections) const {
-
const StringName *S = nullptr;
while ((S = signal_map.next(S))) {
-
const SignalData *s = &signal_map[*S];
for (int i = 0; i < s->slot_map.size(); i++) {
-
p_connections->push_back(s->slot_map.getv(i).conn);
}
}
}
void Object::get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const {
-
const SignalData *s = signal_map.getptr(p_signal);
- if (!s)
+ if (!s) {
return; //nothing
+ }
- for (int i = 0; i < s->slot_map.size(); i++)
+ for (int i = 0; i < s->slot_map.size(); i++) {
p_connections->push_back(s->slot_map.getv(i).conn);
+ }
}
int Object::get_persistent_signal_connection_count() const {
-
int count = 0;
const StringName *S = nullptr;
while ((S = signal_map.next(S))) {
-
const SignalData *s = &signal_map[*S];
for (int i = 0; i < s->slot_map.size(); i++) {
@@ -1411,18 +1367,16 @@ int Object::get_persistent_signal_connection_count() const {
}
void Object::get_signals_connected_to_this(List<Connection> *p_connections) const {
-
for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) {
p_connections->push_back(E->get());
}
}
Error Object::connect_compat(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, const Vector<Variant> &p_binds, uint32_t p_flags) {
-
return connect(p_signal, Callable(p_to_object, p_to_method), p_binds, p_flags);
}
-Error Object::connect(const StringName &p_signal, const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
+Error Object::connect(const StringName &p_signal, const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
ERR_FAIL_COND_V(p_callable.is_null(), ERR_INVALID_PARAMETER);
Object *target_object = p_callable.get_object();
@@ -1433,7 +1387,6 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, co
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
//check in script
if (!signal_is_valid && !script.is_null()) {
-
if (Ref<Script>(script)->has_script_signal(p_signal)) {
signal_is_valid = true;
}
@@ -1483,21 +1436,21 @@ Error Object::connect(const StringName &p_signal, const Callable &p_callable, co
}
bool Object::is_connected_compat(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method) const {
-
return is_connected(p_signal, Callable(p_to_object, p_to_method));
}
bool Object::is_connected(const StringName &p_signal, const Callable &p_callable) const {
-
ERR_FAIL_COND_V(p_callable.is_null(), false);
const SignalData *s = signal_map.getptr(p_signal);
if (!s) {
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
- if (signal_is_valid)
+ if (signal_is_valid) {
return false;
+ }
- if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal))
+ if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal)) {
return false;
+ }
ERR_FAIL_V_MSG(false, "Nonexistent signal: " + p_signal + ".");
}
@@ -1510,7 +1463,6 @@ bool Object::is_connected(const StringName &p_signal, const Callable &p_callable
}
void Object::disconnect_compat(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method) {
-
_disconnect(p_signal, Callable(p_to_object, p_to_method));
}
@@ -1519,7 +1471,6 @@ void Object::disconnect(const StringName &p_signal, const Callable &p_callable)
}
void Object::_disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force) {
-
ERR_FAIL_COND(p_callable.is_null());
Object *target_object = p_callable.get_object();
@@ -1549,65 +1500,60 @@ void Object::_disconnect(const StringName &p_signal, const Callable &p_callable,
}
void Object::_set_bind(const String &p_set, const Variant &p_value) {
-
set(p_set, p_value);
}
Variant Object::_get_bind(const String &p_name) const {
-
return get(p_name);
}
void Object::_set_indexed_bind(const NodePath &p_name, const Variant &p_value) {
-
set_indexed(p_name.get_as_property_path().get_subnames(), p_value);
}
Variant Object::_get_indexed_bind(const NodePath &p_name) const {
-
return get_indexed(p_name.get_as_property_path().get_subnames());
}
void Object::initialize_class() {
-
static bool initialized = false;
- if (initialized)
+ if (initialized) {
return;
+ }
ClassDB::_add_class<Object>();
_bind_methods();
initialized = true;
}
StringName Object::tr(const StringName &p_message) const {
-
- if (!_can_translate || !TranslationServer::get_singleton())
+ if (!_can_translate || !TranslationServer::get_singleton()) {
return p_message;
+ }
return TranslationServer::get_singleton()->translate(p_message);
}
void Object::_clear_internal_resource_paths(const Variant &p_var) {
-
switch (p_var.get_type()) {
-
case Variant::OBJECT: {
-
RES r = p_var;
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
- if (!r->get_path().begins_with("res://") || r->get_path().find("::") == -1)
+ if (!r->get_path().begins_with("res://") || r->get_path().find("::") == -1) {
return; //not an internal resource
+ }
Object *object = p_var;
- if (!object)
+ if (!object) {
return;
+ }
r->set_path("");
r->clear_internal_resource_paths();
} break;
case Variant::ARRAY: {
-
Array a = p_var;
for (int i = 0; i < a.size(); i++) {
_clear_internal_resource_paths(a[i]);
@@ -1615,13 +1561,11 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
} break;
case Variant::DICTIONARY: {
-
Dictionary d = p_var;
List<Variant> keys;
d.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
_clear_internal_resource_paths(E->get());
_clear_internal_resource_paths(d[E->get()]);
}
@@ -1633,35 +1577,31 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
#ifdef TOOLS_ENABLED
void Object::editor_set_section_unfold(const String &p_section, bool p_unfolded) {
-
set_edited(true);
- if (p_unfolded)
+ if (p_unfolded) {
editor_section_folding.insert(p_section);
- else
+ } else {
editor_section_folding.erase(p_section);
+ }
}
bool Object::editor_is_section_unfolded(const String &p_section) {
-
return editor_section_folding.has(p_section);
}
#endif
void Object::clear_internal_resource_paths() {
-
List<PropertyInfo> pinfo;
get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
_clear_internal_resource_paths(get(E->get().name));
}
}
void Object::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class);
ClassDB::bind_method(D_METHOD("is_class", "class"), &Object::is_class);
ClassDB::bind_method(D_METHOD("set", "property", "value"), &Object::_set_bind);
@@ -1766,7 +1706,6 @@ void Object::_bind_methods() {
}
void Object::call_deferred(const StringName &p_method, VARIANT_ARG_DECLARE) {
-
MessageQueue::get_singleton()->push_call(this, p_method, VARIANT_ARG_PASS);
}
@@ -1775,58 +1714,57 @@ void Object::set_deferred(const StringName &p_property, const Variant &p_value)
}
void Object::set_block_signals(bool p_block) {
-
_block_signals = p_block;
}
bool Object::is_blocking_signals() const {
-
return _block_signals;
}
void Object::get_translatable_strings(List<String> *p_strings) const {
-
List<PropertyInfo> plist;
get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED))
+ if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED)) {
continue;
+ }
String text = get(E->get().name);
- if (text == "")
+ if (text == "") {
continue;
+ }
p_strings->push_back(text);
}
}
Variant::Type Object::get_static_property_type(const StringName &p_property, bool *r_valid) const {
-
bool valid;
Variant::Type t = ClassDB::get_property_type(get_class_name(), p_property, &valid);
if (valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return t;
}
if (get_script_instance()) {
return get_script_instance()->get_property_type(p_property, r_valid);
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant::NIL;
}
Variant::Type Object::get_static_property_type_indexed(const Vector<StringName> &p_path, bool *r_valid) const {
-
if (p_path.size() == 0) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant::NIL;
}
@@ -1834,8 +1772,9 @@ Variant::Type Object::get_static_property_type_indexed(const Vector<StringName>
bool valid = false;
Variant::Type t = get_static_property_type(p_path[0], &valid);
if (!valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant::NIL;
}
@@ -1846,22 +1785,25 @@ Variant::Type Object::get_static_property_type_indexed(const Vector<StringName>
for (int i = 1; i < p_path.size(); i++) {
if (check.get_type() == Variant::OBJECT || check.get_type() == Variant::DICTIONARY || check.get_type() == Variant::ARRAY) {
// We cannot be sure about the type of properties this types can have
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant::NIL;
}
check = check.get_named(p_path[i], &valid);
if (!valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant::NIL;
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return check.get_type();
}
@@ -1872,18 +1814,15 @@ bool Object::is_queued_for_deletion() const {
#ifdef TOOLS_ENABLED
void Object::set_edited(bool p_edited) {
-
_edited = p_edited;
_edited_version++;
}
bool Object::is_edited() const {
-
return _edited;
}
uint32_t Object::get_edited_version() const {
-
return _edited_version;
}
#endif
@@ -1910,7 +1849,6 @@ void *Object::get_script_instance_binding(int p_script_language_index) {
}
bool Object::has_script_instance_binding(int p_script_language_index) {
-
return _script_instance_bindings[p_script_language_index] != nullptr;
}
@@ -1923,39 +1861,26 @@ void Object::set_script_instance_binding(int p_script_language_index, void *p_da
void Object::_construct_object(bool p_reference) {
type_is_reference = p_reference;
- _class_ptr = nullptr;
- _block_signals = false;
- _predelete_ok = 0;
_instance_id = ObjectDB::add_instance(this);
- _can_translate = true;
- _is_queued_for_deletion = false;
- _emitting = false;
- instance_binding_count = 0;
memset(_script_instance_bindings, 0, sizeof(void *) * MAX_SCRIPT_INSTANCE_BINDINGS);
- script_instance = nullptr;
-#ifdef TOOLS_ENABLED
-
- _edited = false;
- _edited_version = 0;
-#endif
#ifdef DEBUG_ENABLED
_lock_index.init(1);
#endif
}
+
Object::Object(bool p_reference) {
_construct_object(p_reference);
}
Object::Object() {
-
_construct_object(false);
}
Object::~Object() {
-
- if (script_instance)
+ if (script_instance) {
memdelete(script_instance);
+ }
script_instance = nullptr;
const StringName *S = nullptr;
@@ -1966,7 +1891,6 @@ Object::~Object() {
}
while ((S = signal_map.next(nullptr))) {
-
SignalData *s = &signal_map[*S];
//brute force disconnect for performance
@@ -1974,7 +1898,6 @@ Object::~Object() {
const VMap<Callable, SignalData::Slot>::Pair *slot_list = s->slot_map.get_array();
for (int i = 0; i < slot_count; i++) {
-
slot_list[i].value.conn.callable.get_object()->connections.erase(slot_list[i].value.cE);
}
@@ -1983,7 +1906,6 @@ Object::~Object() {
//signals from nodes that connect to this node
while (connections.size()) {
-
Connection c = connections.front()->get();
c.signal.get_object()->_disconnect(c.signal.get_name(), c.callable, true);
}
@@ -2002,17 +1924,14 @@ Object::~Object() {
}
bool predelete_handler(Object *p_object) {
-
return p_object->_predelete();
}
void postinitialize_handler(Object *p_object) {
-
p_object->_postinitialize();
}
void ObjectDB::debug_objects(DebugFunc p_func) {
-
spin_lock.lock();
for (uint32_t i = 0; i < slot_count; i++) {
uint32_t slot = object_slots[i].next_free;
@@ -2031,15 +1950,12 @@ ObjectDB::ObjectSlot *ObjectDB::object_slots = nullptr;
uint64_t ObjectDB::validator_counter = 0;
int ObjectDB::get_object_count() {
-
return slot_count;
}
ObjectID ObjectDB::add_instance(Object *p_object) {
-
spin_lock.lock();
if (unlikely(slot_count == slot_max)) {
-
CRASH_COND(slot_count == (1 << OBJECTDB_SLOT_MAX_COUNT_BITS));
uint32_t new_slot_max = slot_max > 0 ? slot_max * 2 : 1;
@@ -2115,30 +2031,38 @@ void ObjectDB::remove_instance(Object *p_object) {
}
void ObjectDB::setup() {
-
//nothing to do now
}
void ObjectDB::cleanup() {
-
if (slot_count > 0) {
spin_lock.lock();
- WARN_PRINT("ObjectDB Instances still exist!");
+ WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details).");
if (OS::get_singleton()->is_stdout_verbose()) {
+ // Ensure calling the native classes because if a leaked instance has a script
+ // that overrides any of those methods, it'd not be OK to call them at this point,
+ // now the scripting languages have already been terminated.
+ MethodBind *node_get_name = ClassDB::get_method("Node", "get_name");
+ MethodBind *resource_get_path = ClassDB::get_method("Resource", "get_path");
+ Callable::CallError call_error;
+
for (uint32_t i = 0; i < slot_count; i++) {
uint32_t slot = object_slots[i].next_free;
Object *obj = object_slots[slot].object;
- String node_name;
- if (obj->is_class("Node"))
- node_name = " - Node name: " + String(obj->call("get_name"));
- if (obj->is_class("Resource"))
- node_name = " - Resource name: " + String(obj->call("get_name")) + " Path: " + String(obj->call("get_path"));
+ String extra_info;
+ if (obj->is_class("Node")) {
+ extra_info = " - Node name: " + String(node_get_name->call(obj, nullptr, 0, call_error));
+ }
+ if (obj->is_class("Resource")) {
+ extra_info = " - Resource path: " + String(resource_get_path->call(obj, nullptr, 0, call_error));
+ }
uint64_t id = uint64_t(slot) | (uint64_t(object_slots[slot].validator) << OBJECTDB_VALIDATOR_BITS) | (object_slots[slot].is_reference ? OBJECTDB_REFERENCE_BIT : 0);
- print_line("Leaked instance: " + String(obj->get_class()) + ":" + itos(id) + node_name);
+ print_line("Leaked instance: " + String(obj->get_class()) + ":" + itos(id) + extra_info);
}
+ print_line("Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).");
}
spin_lock.unlock();
}
diff --git a/core/object.h b/core/object.h
index 3dec8a0480..5b46a0f93a 100644
--- a/core/object.h
+++ b/core/object.h
@@ -124,6 +124,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 24,
PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 25, // Used in inspector to increment property when keyed in animation player
PROPERTY_USAGE_DEFERRED_SET_RESOURCE = 1 << 26, // when loading, the resource for this property can be set at the end of loading
+ PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 1 << 27, // For Object properties, instantiate them when creating in editor.
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
@@ -138,13 +139,12 @@ enum PropertyUsageFlags {
#define ADD_SUBGROUP(m_name, m_prefix) ClassDB::add_property_subgroup(get_class_static(), m_name, m_prefix)
struct PropertyInfo {
-
- Variant::Type type;
+ Variant::Type type = Variant::NIL;
String name;
StringName class_name; //for classes
- PropertyHint hint;
+ PropertyHint hint = PROPERTY_HINT_NONE;
String hint_string;
- uint32_t usage;
+ uint32_t usage = PROPERTY_USAGE_DEFAULT;
_FORCE_INLINE_ PropertyInfo added_usage(int p_fl) const {
PropertyInfo pi = *this;
@@ -156,11 +156,7 @@ struct PropertyInfo {
static PropertyInfo from_dict(const Dictionary &p_dict);
- PropertyInfo() :
- type(Variant::NIL),
- hint(PROPERTY_HINT_NONE),
- usage(PROPERTY_USAGE_DEFAULT) {
- }
+ PropertyInfo() {}
PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) :
type(p_type),
@@ -168,7 +164,6 @@ struct PropertyInfo {
hint(p_hint),
hint_string(p_hint_string),
usage(p_usage) {
-
if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
class_name = hint_string;
} else {
@@ -178,10 +173,7 @@ struct PropertyInfo {
PropertyInfo(const StringName &p_class_name) :
type(Variant::OBJECT),
- class_name(p_class_name),
- hint(PROPERTY_HINT_NONE),
- usage(PROPERTY_USAGE_DEFAULT) {
- }
+ class_name(p_class_name) {}
bool operator==(const PropertyInfo &p_info) const {
return ((type == p_info.type) &&
@@ -200,11 +192,10 @@ struct PropertyInfo {
Array convert_property_list(const List<PropertyInfo> *p_list);
struct MethodInfo {
-
String name;
PropertyInfo return_val;
- uint32_t flags;
- int id;
+ uint32_t flags; // NOLINT - prevent clang-tidy to assign method_bind.h constant here, it should stay in .cpp.
+ int id = 0;
List<PropertyInfo> arguments;
Vector<Variant> default_arguments;
@@ -214,6 +205,7 @@ struct MethodInfo {
operator Dictionary() const;
static MethodInfo from_dict(const Dictionary &p_dict);
+
MethodInfo();
MethodInfo(const String &p_name);
MethodInfo(const String &p_name, const PropertyInfo &p_param1);
@@ -269,8 +261,9 @@ public:
return String(#m_class); \
} \
virtual const StringName *_get_class_namev() const { \
- if (!_class_name) \
+ if (!_class_name) { \
_class_name = get_class_static(); \
+ } \
return &_class_name; \
} \
static _FORCE_INLINE_ void *get_class_ptr_static() { \
@@ -290,8 +283,9 @@ public:
static String get_category_static() { \
String category = m_inherits::get_category_static(); \
if (_get_category != m_inherits::_get_category) { \
- if (category != "") \
+ if (category != "") { \
category += "/"; \
+ } \
category += _get_category(); \
} \
return category; \
@@ -303,7 +297,6 @@ public:
virtual bool is_class_ptr(void *p_ptr) const { return (p_ptr == get_class_ptr_static()) ? true : m_inherits::is_class_ptr(p_ptr); } \
\
static void get_valid_parents_static(List<String> *p_parents) { \
- \
if (m_class::_get_valid_parents_static != m_inherits::_get_valid_parents_static) { \
m_class::_get_valid_parents_static(p_parents); \
} \
@@ -319,12 +312,14 @@ protected:
public: \
static void initialize_class() { \
static bool initialized = false; \
- if (initialized) \
+ if (initialized) { \
return; \
+ } \
m_inherits::initialize_class(); \
ClassDB::_add_class<m_class>(); \
- if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) \
+ if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) { \
_bind_methods(); \
+ } \
initialized = true; \
} \
\
@@ -337,8 +332,9 @@ protected:
} \
virtual bool _getv(const StringName &p_name, Variant &r_ret) const { \
if (m_class::_get_get() != m_inherits::_get_get()) { \
- if (_get(p_name, r_ret)) \
+ if (_get(p_name, r_ret)) { \
return true; \
+ } \
} \
return m_inherits::_getv(p_name, r_ret); \
} \
@@ -346,8 +342,9 @@ protected:
return (bool (Object::*)(const StringName &, const Variant &)) & m_class::_set; \
} \
virtual bool _setv(const StringName &p_name, const Variant &p_property) { \
- if (m_inherits::_setv(p_name, p_property)) \
+ if (m_inherits::_setv(p_name, p_property)) { \
return true; \
+ } \
if (m_class::_get_set() != m_inherits::_get_set()) { \
return _set(p_name, p_property); \
} \
@@ -361,13 +358,15 @@ protected:
m_inherits::_get_property_listv(p_list, p_reversed); \
} \
p_list->push_back(PropertyInfo(Variant::NIL, get_class_static(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); \
- if (!_is_gpl_reversed()) \
+ if (!_is_gpl_reversed()) { \
ClassDB::get_property_list(#m_class, p_list, true, this); \
+ } \
if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) { \
_get_property_list(p_list); \
} \
- if (_is_gpl_reversed()) \
+ if (_is_gpl_reversed()) { \
ClassDB::get_property_list(#m_class, p_list, true, this); \
+ } \
if (p_reversed) { \
m_inherits::_get_property_listv(p_list, p_reversed); \
} \
@@ -376,13 +375,15 @@ protected:
return (void (Object::*)(int)) & m_class::_notification; \
} \
virtual void _notificationv(int p_notification, bool p_reversed) { \
- if (!p_reversed) \
+ if (!p_reversed) { \
m_inherits::_notificationv(p_notification, p_reversed); \
+ } \
if (m_class::_get_notification() != m_inherits::_get_notification()) { \
_notification(p_notification); \
} \
- if (p_reversed) \
+ if (p_reversed) { \
m_inherits::_notificationv(p_notification, p_reversed); \
+ } \
} \
\
private:
@@ -412,18 +413,16 @@ public:
};
struct Connection {
-
::Signal signal;
Callable callable;
- uint32_t flags;
+ uint32_t flags = 0;
Vector<Variant> binds;
bool operator<(const Connection &p_conn) const;
operator Variant() const;
- Connection() {
- flags = 0;
- }
+
+ Connection() {}
Connection(const Variant &p_variant);
};
@@ -439,18 +438,14 @@ private:
friend void postinitialize_handler(Object *);
struct SignalData {
-
struct Slot {
-
- int reference_count;
+ int reference_count = 0;
Connection conn;
- List<Connection>::Element *cE;
- Slot() { reference_count = 0; }
+ List<Connection>::Element *cE = nullptr;
};
MethodInfo user;
VMap<Callable, Slot> slot_map;
- SignalData() {}
};
HashMap<StringName, SignalData> signal_map;
@@ -458,24 +453,24 @@ private:
#ifdef DEBUG_ENABLED
SafeRefCount _lock_index;
#endif
- bool _block_signals;
- int _predelete_ok;
+ bool _block_signals = false;
+ int _predelete_ok = 0;
Set<Object *> change_receptors;
ObjectID _instance_id;
bool _predelete();
void _postinitialize();
- bool _can_translate;
- bool _emitting;
+ bool _can_translate = true;
+ bool _emitting = false;
#ifdef TOOLS_ENABLED
- bool _edited;
- uint32_t _edited_version;
+ bool _edited = false;
+ uint32_t _edited_version = 0;
Set<String> editor_section_folding;
#endif
- ScriptInstance *script_instance;
+ ScriptInstance *script_instance = nullptr;
Variant script; //reference does not yet exist, store it in a
Dictionary metadata;
mutable StringName _class_name;
- mutable const StringName *_class_ptr;
+ mutable const StringName *_class_ptr = nullptr;
void _add_user_signal(const String &p_name, const Array &p_args = Array());
bool _has_user_signal(const StringName &p_name) const;
@@ -494,8 +489,9 @@ private:
friend class Reference;
bool type_is_reference = false;
- uint32_t instance_binding_count;
+ uint32_t instance_binding_count = 0;
void *_script_instance_bindings[MAX_SCRIPT_INSTANCE_BINDINGS];
+
Object(bool p_reference);
protected:
@@ -503,14 +499,14 @@ protected:
virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; };
virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; };
virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {};
- virtual void _notificationv(int p_notification, bool p_reversed){};
+ virtual void _notificationv(int p_notification, bool p_reversed) {}
static String _get_category() { return ""; }
static void _bind_methods();
bool _set(const StringName &p_name, const Variant &p_property) { return false; };
bool _get(const StringName &p_name, Variant &r_property) const { return false; };
void _get_property_list(List<PropertyInfo> *p_list) const {};
- void _notification(int p_notification){};
+ void _notification(int p_notification) {}
_FORCE_INLINE_ static void (*_get_bind_methods())() {
return &Object::_bind_methods;
@@ -541,8 +537,9 @@ protected:
Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual const StringName *_get_class_namev() const {
- if (!_class_name)
+ if (!_class_name) {
_class_name = get_class_static();
+ }
return &_class_name;
}
@@ -559,14 +556,15 @@ protected:
public: //should be protected, but bug in clang++
static void initialize_class();
- _FORCE_INLINE_ static void register_custom_data_to_otdb(){};
+ _FORCE_INLINE_ static void register_custom_data_to_otdb() {}
public:
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ void _change_notify(const char *p_property = "") {
_edited = true;
- for (Set<Object *>::Element *E = change_receptors.front(); E; E = E->next())
+ for (Set<Object *>::Element *E = change_receptors.front(); E; E = E->next()) {
((Object *)(E->get()))->_changed_callback(this, p_property);
+ }
}
#else
_FORCE_INLINE_ void _change_notify(const char *p_what = "") {}
@@ -579,8 +577,8 @@ public:
bool _is_gpl_reversed() const { return false; }
_FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_id; }
- // this is used for editors
+ // this is used for editors
void add_change_receptor(Object *p_receptor);
void remove_change_receptor(Object *p_receptor);
@@ -589,12 +587,14 @@ public:
#ifndef NO_SAFE_CAST
return dynamic_cast<T *>(p_object);
#else
- if (!p_object)
+ if (!p_object) {
return nullptr;
- if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ }
+ if (p_object->is_class_ptr(T::get_class_ptr_static())) {
return static_cast<T *>(p_object);
- else
+ } else {
return nullptr;
+ }
#endif
}
@@ -603,17 +603,18 @@ public:
#ifndef NO_SAFE_CAST
return dynamic_cast<const T *>(p_object);
#else
- if (!p_object)
+ if (!p_object) {
return nullptr;
- if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ }
+ if (p_object->is_class_ptr(T::get_class_ptr_static())) {
return static_cast<const T *>(p_object);
- else
+ } else {
return nullptr;
+ }
#endif
}
enum {
-
NOTIFICATION_POSTINITIALIZE = 0,
NOTIFICATION_PREDELETE = 1
};
@@ -723,7 +724,7 @@ public:
StringName tr(const StringName &p_message) const; // translate message (internationalization)
- bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete()
+ bool _is_queued_for_deletion = false; // set to true by SceneTree::queue_delete()
bool is_queued_for_deletion() const;
_FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; }
@@ -745,6 +746,7 @@ public:
void clear_internal_resource_paths();
_ALWAYS_INLINE_ bool is_reference() const { return type_is_reference; }
+
Object();
virtual ~Object();
};
@@ -753,7 +755,6 @@ bool predelete_handler(Object *p_object);
void postinitialize_handler(Object *p_object);
class ObjectDB {
-
//this needs to add up to 63, 1 bit is for reference
#define OBJECTDB_VALIDATOR_BITS 39
#define OBJECTDB_VALIDATOR_MASK ((uint64_t(1) << OBJECTDB_VALIDATOR_BITS) - 1)
@@ -788,7 +789,6 @@ public:
typedef void (*DebugFunc)(Object *p_obj);
_ALWAYS_INLINE_ static Object *get_instance(ObjectID p_instance_id) {
-
uint64_t id = p_instance_id;
uint32_t slot = id & OBJECTDB_SLOT_MAX_COUNT_MASK;
diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h
index 05debd529f..e6a6340a2f 100644
--- a/core/ordered_hash_map.h
+++ b/core/ordered_hash_map.h
@@ -55,9 +55,9 @@ public:
class Element {
friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>;
- typename InternalList::Element *list_element;
- typename InternalList::Element *prev_element;
- typename InternalList::Element *next_element;
+ typename InternalList::Element *list_element = nullptr;
+ typename InternalList::Element *prev_element = nullptr;
+ typename InternalList::Element *next_element = nullptr;
Element(typename InternalList::Element *p_element) {
list_element = p_element;
@@ -69,11 +69,7 @@ public:
}
public:
- _FORCE_INLINE_ Element() :
- list_element(nullptr),
- prev_element(nullptr),
- next_element(nullptr) {
- }
+ _FORCE_INLINE_ Element() {}
Element next() const {
return Element(next_element);
@@ -110,42 +106,40 @@ public:
const K &key() const {
CRASH_COND(!list_element);
return *(list_element->get().first);
- };
+ }
V &value() {
CRASH_COND(!list_element);
return list_element->get().second;
- };
+ }
const V &value() const {
CRASH_COND(!list_element);
return list_element->get().second;
- };
+ }
V &get() {
CRASH_COND(!list_element);
return list_element->get().second;
- };
+ }
const V &get() const {
CRASH_COND(!list_element);
return list_element->get().second;
- };
+ }
};
class ConstElement {
friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>;
- const typename InternalList::Element *list_element;
+ const typename InternalList::Element *list_element = nullptr;
ConstElement(const typename InternalList::Element *p_element) :
list_element(p_element) {
}
public:
- _FORCE_INLINE_ ConstElement() :
- list_element(nullptr) {
- }
+ _FORCE_INLINE_ ConstElement() {}
ConstElement(const ConstElement &other) :
list_element(other.list_element) {
@@ -178,17 +172,17 @@ public:
const K &key() const {
CRASH_COND(!list_element);
return *(list_element->get().first);
- };
+ }
const V &value() const {
CRASH_COND(!list_element);
return list_element->get().second;
- };
+ }
const V &get() const {
CRASH_COND(!list_element);
return list_element->get().second;
- };
+ }
};
ConstElement find(const K &p_key) const {
@@ -299,8 +293,7 @@ public:
_copy_from(p_map);
}
- _FORCE_INLINE_ OrderedHashMap() {
- }
+ _FORCE_INLINE_ OrderedHashMap() {}
};
#endif // ORDERED_HASH_MAP_H
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index b26cd46fd8..5e1cb8ea29 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -36,9 +36,7 @@
#include "core/project_settings.h"
String DirAccess::_get_root_path() const {
-
switch (_access_type) {
-
case ACCESS_RESOURCES:
return ProjectSettings::get_singleton()->get_resource_path();
case ACCESS_USERDATA:
@@ -47,10 +45,9 @@ String DirAccess::_get_root_path() const {
return "";
}
}
-String DirAccess::_get_root_string() const {
+String DirAccess::_get_root_string() const {
switch (_access_type) {
-
case ACCESS_RESOURCES:
return "res://";
case ACCESS_USERDATA:
@@ -61,37 +58,34 @@ String DirAccess::_get_root_string() const {
}
int DirAccess::get_current_drive() {
-
String path = get_current_dir().to_lower();
for (int i = 0; i < get_drive_count(); i++) {
String d = get_drive(i).to_lower();
- if (path.begins_with(d))
+ if (path.begins_with(d)) {
return i;
+ }
}
return 0;
}
bool DirAccess::drives_are_shortcuts() {
-
return false;
}
static Error _erase_recursive(DirAccess *da) {
-
List<String> dirs;
List<String> files;
da->list_dir_begin();
String n = da->get_next();
while (n != String()) {
-
if (n != "." && n != "..") {
-
- if (da->current_is_dir())
+ if (da->current_is_dir()) {
dirs.push_back(n);
- else
+ } else {
files.push_back(n);
+ }
}
n = da->get_next();
@@ -100,10 +94,8 @@ static Error _erase_recursive(DirAccess *da) {
da->list_dir_end();
for (List<String>::Element *E = dirs.front(); E; E = E->next()) {
-
Error err = da->change_dir(E->get());
if (err == OK) {
-
err = _erase_recursive(da);
if (err) {
da->change_dir("..");
@@ -123,7 +115,6 @@ static Error _erase_recursive(DirAccess *da) {
}
for (List<String>::Element *E = files.front(); E; E = E->next()) {
-
Error err = da->remove(da->get_current_dir().plus_file(E->get()));
if (err) {
return err;
@@ -134,15 +125,13 @@ static Error _erase_recursive(DirAccess *da) {
}
Error DirAccess::erase_contents_recursive() {
-
return _erase_recursive(this);
}
Error DirAccess::make_dir_recursive(String p_dir) {
-
if (p_dir.length() < 1) {
return OK;
- };
+ }
String full_dir;
@@ -160,13 +149,13 @@ Error DirAccess::make_dir_recursive(String p_dir) {
String base;
- if (full_dir.begins_with("res://"))
+ if (full_dir.begins_with("res://")) {
base = "res://";
- else if (full_dir.begins_with("user://"))
+ } else if (full_dir.begins_with("user://")) {
base = "user://";
- else if (full_dir.begins_with("/"))
+ } else if (full_dir.begins_with("/")) {
base = "/";
- else if (full_dir.find(":/") != -1) {
+ } else if (full_dir.find(":/") != -1) {
base = full_dir.substr(0, full_dir.find(":/") + 2);
} else {
ERR_FAIL_V(ERR_INVALID_PARAMETER);
@@ -178,11 +167,9 @@ Error DirAccess::make_dir_recursive(String p_dir) {
String curpath = base;
for (int i = 0; i < subdirs.size(); i++) {
-
curpath = curpath.plus_file(subdirs[i]);
Error err = make_dir(curpath);
if (err != OK && err != ERR_ALREADY_EXISTS) {
-
ERR_FAIL_V(err);
}
}
@@ -191,39 +178,30 @@ Error DirAccess::make_dir_recursive(String p_dir) {
}
String DirAccess::fix_path(String p_path) const {
-
switch (_access_type) {
-
case ACCESS_RESOURCES: {
-
if (ProjectSettings::get_singleton()) {
if (p_path.begins_with("res://")) {
-
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
-
return p_path.replace_first("res:/", resource_path);
- };
+ }
return p_path.replace_first("res://", "");
}
}
} break;
case ACCESS_USERDATA: {
-
if (p_path.begins_with("user://")) {
-
String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
-
return p_path.replace_first("user:/", data_dir);
- };
+ }
return p_path.replace_first("user://", "");
}
} break;
case ACCESS_FILESYSTEM: {
-
return p_path;
} break;
case ACCESS_MAX:
@@ -236,16 +214,12 @@ String DirAccess::fix_path(String p_path) const {
DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { nullptr, nullptr, nullptr };
DirAccess *DirAccess::create_for_path(const String &p_path) {
-
DirAccess *da = nullptr;
if (p_path.begins_with("res://")) {
-
da = create(ACCESS_RESOURCES);
} else if (p_path.begins_with("user://")) {
-
da = create(ACCESS_USERDATA);
} else {
-
da = create(ACCESS_FILESYSTEM);
}
@@ -253,13 +227,13 @@ DirAccess *DirAccess::create_for_path(const String &p_path) {
}
DirAccess *DirAccess::open(const String &p_path, Error *r_error) {
-
DirAccess *da = create_for_path(p_path);
ERR_FAIL_COND_V_MSG(!da, nullptr, "Cannot create DirAccess for path '" + p_path + "'.");
Error err = da->change_dir(p_path);
- if (r_error)
+ if (r_error) {
*r_error = err;
+ }
if (err != OK) {
memdelete(da);
return nullptr;
@@ -269,20 +243,19 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) {
}
DirAccess *DirAccess::create(AccessType p_access) {
-
DirAccess *da = create_func[p_access] ? create_func[p_access]() : nullptr;
if (da) {
da->_access_type = p_access;
}
return da;
-};
+}
String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
-
DirAccess *d = DirAccess::create(p_access);
- if (!d)
+ if (!d) {
return p_path;
+ }
d->change_dir(p_path);
String full = d->get_current_dir();
@@ -291,7 +264,6 @@ String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
}
Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
-
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
Error err;
FileAccess *fsrc = FileAccess::open(p_from, FileAccess::READ, &err);
@@ -303,7 +275,6 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
FileAccess *fdst = FileAccess::open(p_to, FileAccess::WRITE, &err);
if (err) {
-
fsrc->close();
memdelete(fsrc);
ERR_PRINT("Failed to open " + p_to);
@@ -315,7 +286,6 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
fsrc->seek(0);
err = OK;
while (size--) {
-
if (fsrc->get_error() != OK) {
err = fsrc->get_error();
break;
@@ -332,8 +302,9 @@ Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
fdst->close();
err = FileAccess::set_unix_permissions(p_to, p_chmod_flags);
// If running on a platform with no chmod support (i.e., Windows), don't fail
- if (err == ERR_UNAVAILABLE)
+ if (err == ERR_UNAVAILABLE) {
err = OK;
+ }
}
memdelete(fsrc);
@@ -367,12 +338,10 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
list_dir_begin();
String n = get_next();
while (n != String()) {
-
if (n != "." && n != "..") {
-
- if (current_is_dir())
+ if (current_is_dir()) {
dirs.push_back(n);
- else {
+ } else {
const String &rel_path = n;
if (!n.is_rel_path()) {
list_dir_end();
@@ -440,17 +409,8 @@ Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
}
bool DirAccess::exists(String p_dir) {
-
DirAccess *da = DirAccess::create_for_path(p_dir);
bool valid = da->change_dir(p_dir) == OK;
memdelete(da);
return valid;
}
-
-DirAccess::DirAccess() {
-
- _access_type = ACCESS_FILESYSTEM;
-}
-
-DirAccess::~DirAccess() {
-}
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 6c876cde5a..6bce9a4c12 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -47,7 +47,7 @@ public:
typedef DirAccess *(*CreateFunc)();
private:
- AccessType _access_type;
+ AccessType _access_type = ACCESS_FILESYSTEM;
static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object
Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags);
@@ -61,7 +61,6 @@ protected:
template <class T>
static DirAccess *_create_builtin() {
-
return memnew(T);
}
@@ -110,43 +109,33 @@ public:
static String get_full_path(const String &p_path, AccessType p_access);
static DirAccess *create_for_path(const String &p_path);
- /*
- enum DirType {
-
- FILE_TYPE_INVALID,
- FILE_TYPE_FILE,
- FILE_TYPE_DIR,
- };
-
- //virtual DirType get_file_type() const=0;
-*/
static DirAccess *create(AccessType p_access);
template <class T>
static void make_default(AccessType p_access) {
-
create_func[p_access] = _create_builtin<T>;
}
static DirAccess *open(const String &p_path, Error *r_error = nullptr);
- DirAccess();
- virtual ~DirAccess();
+ DirAccess() {}
+ virtual ~DirAccess() {}
};
struct DirAccessRef {
-
_FORCE_INLINE_ DirAccess *operator->() {
-
return f;
}
operator bool() const { return f != nullptr; }
+
DirAccess *f;
+
DirAccessRef(DirAccess *fa) { f = fa; }
~DirAccessRef() {
- if (f)
+ if (f) {
memdelete(f);
+ }
}
};
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 7055780f34..20b3435911 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -43,7 +43,6 @@ FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = nullptr;
bool FileAccess::backup_save = false;
FileAccess *FileAccess::create(AccessType p_access) {
-
ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr);
FileAccess *ret = create_func[p_access]();
@@ -52,34 +51,30 @@ FileAccess *FileAccess::create(AccessType p_access) {
}
bool FileAccess::exists(const String &p_name) {
-
- if (PackedData::get_singleton() && PackedData::get_singleton()->has_path(p_name))
+ if (PackedData::get_singleton() && PackedData::get_singleton()->has_path(p_name)) {
return true;
+ }
FileAccess *f = open(p_name, READ);
- if (!f)
+ if (!f) {
return false;
+ }
memdelete(f);
return true;
}
void FileAccess::_set_access_type(AccessType p_access) {
-
_access_type = p_access;
-};
+}
FileAccess *FileAccess::create_for_path(const String &p_path) {
-
FileAccess *ret = nullptr;
if (p_path.begins_with("res://")) {
-
ret = create(ACCESS_RESOURCES);
} else if (p_path.begins_with("user://")) {
-
ret = create(ACCESS_USERDATA);
} else {
-
ret = create(ACCESS_FILESYSTEM);
}
@@ -87,20 +82,19 @@ FileAccess *FileAccess::create_for_path(const String &p_path) {
}
Error FileAccess::reopen(const String &p_path, int p_mode_flags) {
-
return _open(p_path, p_mode_flags);
-};
+}
FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_error) {
-
//try packed data first
FileAccess *ret = nullptr;
if (!(p_mode_flags & WRITE) && PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled()) {
ret = PackedData::get_singleton()->try_open_path(p_path);
if (ret) {
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return ret;
}
}
@@ -108,10 +102,10 @@ FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_er
ret = create_for_path(p_path);
Error err = ret->_open(p_path, p_mode_flags);
- if (r_error)
+ if (r_error) {
*r_error = err;
+ }
if (err != OK) {
-
memdelete(ret);
ret = nullptr;
}
@@ -120,9 +114,8 @@ FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_er
}
FileAccess::CreateFunc FileAccess::get_create_func(AccessType p_access) {
-
return create_func[p_access];
-};
+}
String FileAccess::fix_path(const String &p_path) const {
//helper used by file accesses that use a single filesystem
@@ -130,37 +123,29 @@ String FileAccess::fix_path(const String &p_path) const {
String r_path = p_path.replace("\\", "/");
switch (_access_type) {
-
case ACCESS_RESOURCES: {
-
if (ProjectSettings::get_singleton()) {
if (r_path.begins_with("res://")) {
-
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
-
return r_path.replace("res:/", resource_path);
- };
+ }
return r_path.replace("res://", "");
}
}
} break;
case ACCESS_USERDATA: {
-
if (r_path.begins_with("user://")) {
-
String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
-
return r_path.replace("user:/", data_dir);
- };
+ }
return r_path.replace("user://", "");
}
} break;
case ACCESS_FILESYSTEM: {
-
return r_path;
} break;
case ACCESS_MAX:
@@ -173,7 +158,6 @@ String FileAccess::fix_path(const String &p_path) const {
/* these are all implemented for ease of porting, then can later be optimized */
uint16_t FileAccess::get_16() const {
-
uint16_t res;
uint8_t a, b;
@@ -181,7 +165,6 @@ uint16_t FileAccess::get_16() const {
b = get_8();
if (endian_swap) {
-
SWAP(a, b);
}
@@ -191,8 +174,8 @@ uint16_t FileAccess::get_16() const {
return res;
}
-uint32_t FileAccess::get_32() const {
+uint32_t FileAccess::get_32() const {
uint32_t res;
uint16_t a, b;
@@ -200,7 +183,6 @@ uint32_t FileAccess::get_32() const {
b = get_16();
if (endian_swap) {
-
SWAP(a, b);
}
@@ -210,8 +192,8 @@ uint32_t FileAccess::get_32() const {
return res;
}
-uint64_t FileAccess::get_64() const {
+uint64_t FileAccess::get_64() const {
uint64_t res;
uint32_t a, b;
@@ -219,7 +201,6 @@ uint64_t FileAccess::get_64() const {
b = get_32();
if (endian_swap) {
-
SWAP(a, b);
}
@@ -231,38 +212,35 @@ uint64_t FileAccess::get_64() const {
}
float FileAccess::get_float() const {
-
MarshallFloat m;
m.i = get_32();
return m.f;
-};
+}
real_t FileAccess::get_real() const {
-
- if (real_is_double)
+ if (real_is_double) {
return get_double();
- else
+ } else {
return get_float();
+ }
}
double FileAccess::get_double() const {
-
MarshallDouble m;
m.l = get_64();
return m.d;
-};
+}
String FileAccess::get_token() const {
-
CharString token;
CharType c = get_8();
while (!eof_reached()) {
-
if (c <= ' ') {
- if (token.length())
+ if (token.length()) {
break;
+ }
} else {
token += c;
}
@@ -278,19 +256,16 @@ class CharBuffer {
char *buffer;
int capacity;
- int written;
+ int written = 0;
bool grow() {
-
if (vector.resize(next_power_of_2(1 + written)) != OK) {
-
return false;
}
if (buffer == stack_buffer) { // first chunk?
for (int i = 0; i < written; i++) {
-
vector.write[i] = stack_buffer[i];
}
}
@@ -305,14 +280,11 @@ class CharBuffer {
public:
_FORCE_INLINE_ CharBuffer() :
buffer(stack_buffer),
- capacity(sizeof(stack_buffer) / sizeof(char)),
- written(0) {
+ capacity(sizeof(stack_buffer) / sizeof(char)) {
}
_FORCE_INLINE_ void push_back(char c) {
-
if (written >= capacity) {
-
ERR_FAIL_COND(!grow());
}
@@ -320,24 +292,22 @@ public:
}
_FORCE_INLINE_ const char *get_data() const {
-
return buffer;
}
};
String FileAccess::get_line() const {
-
CharBuffer line;
CharType c = get_8();
while (!eof_reached()) {
-
if (c == '\n' || c == '\0') {
line.push_back(0);
return String::utf8(line.get_data());
- } else if (c != '\r')
+ } else if (c != '\r') {
line.push_back(c);
+ }
c = get_8();
}
@@ -346,21 +316,21 @@ String FileAccess::get_line() const {
}
Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
-
ERR_FAIL_COND_V(p_delim.length() != 1, Vector<String>());
String l;
int qc = 0;
do {
- if (eof_reached())
+ if (eof_reached()) {
break;
+ }
l += get_line() + "\n";
qc = 0;
for (int i = 0; i < l.length(); i++) {
-
- if (l[i] == '"')
+ if (l[i] == '"') {
qc++;
+ }
}
} while (qc % 2);
@@ -372,7 +342,6 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
bool in_quote = false;
String current;
for (int i = 0; i < l.length(); i++) {
-
CharType c = l[i];
CharType s[2] = { 0, 0 };
@@ -385,7 +354,6 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
current += s;
i++;
} else {
-
in_quote = !in_quote;
}
} else {
@@ -400,10 +368,10 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
}
int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {
-
int i = 0;
- for (i = 0; i < p_length && !eof_reached(); i++)
+ for (i = 0; i < p_length && !eof_reached(); i++) {
p_dst[i] = get_8();
+ }
return i;
}
@@ -426,44 +394,40 @@ String FileAccess::get_as_utf8_string() const {
}
void FileAccess::store_16(uint16_t p_dest) {
-
uint8_t a, b;
a = p_dest & 0xFF;
b = p_dest >> 8;
if (endian_swap) {
-
SWAP(a, b);
}
store_8(a);
store_8(b);
}
-void FileAccess::store_32(uint32_t p_dest) {
+void FileAccess::store_32(uint32_t p_dest) {
uint16_t a, b;
a = p_dest & 0xFFFF;
b = p_dest >> 16;
if (endian_swap) {
-
SWAP(a, b);
}
store_16(a);
store_16(b);
}
-void FileAccess::store_64(uint64_t p_dest) {
+void FileAccess::store_64(uint64_t p_dest) {
uint32_t a, b;
a = p_dest & 0xFFFFFFFF;
b = p_dest >> 32;
if (endian_swap) {
-
SWAP(a, b);
}
@@ -472,31 +436,29 @@ void FileAccess::store_64(uint64_t p_dest) {
}
void FileAccess::store_real(real_t p_real) {
-
- if (sizeof(real_t) == 4)
+ if (sizeof(real_t) == 4) {
store_float(p_real);
- else
+ } else {
store_double(p_real);
+ }
}
void FileAccess::store_float(float p_dest) {
-
MarshallFloat m;
m.f = p_dest;
store_32(m.i);
-};
+}
void FileAccess::store_double(double p_dest) {
-
MarshallDouble m;
m.d = p_dest;
store_64(m.l);
-};
+}
uint64_t FileAccess::get_modified_time(const String &p_file) {
-
- if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
+ if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file)) {
return 0;
+ }
FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'.");
@@ -507,9 +469,9 @@ uint64_t FileAccess::get_modified_time(const String &p_file) {
}
uint32_t FileAccess::get_unix_permissions(const String &p_file) {
-
- if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
+ if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file)) {
return 0;
+ }
FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'.");
@@ -520,7 +482,6 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
}
Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) {
-
FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'.");
@@ -530,23 +491,21 @@ Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissi
}
void FileAccess::store_string(const String &p_string) {
-
- if (p_string.length() == 0)
+ if (p_string.length() == 0) {
return;
+ }
CharString cs = p_string.utf8();
store_buffer((uint8_t *)&cs[0], cs.length());
}
void FileAccess::store_pascal_string(const String &p_string) {
-
CharString cs = p_string.utf8();
store_32(cs.length());
store_buffer((uint8_t *)&cs[0], cs.length());
-};
+}
String FileAccess::get_pascal_string() {
-
uint32_t sl = get_32();
CharString cs;
cs.resize(sl + 1);
@@ -557,16 +516,14 @@ String FileAccess::get_pascal_string() {
ret.parse_utf8(cs.ptr());
return ret;
-};
+}
void FileAccess::store_line(const String &p_line) {
-
store_string(p_line);
store_8('\n');
}
void FileAccess::store_csv_line(const Vector<String> &p_values, const String &p_delim) {
-
ERR_FAIL_COND(p_delim.length() != 1);
String line = "";
@@ -588,13 +545,12 @@ void FileAccess::store_csv_line(const Vector<String> &p_values, const String &p_
}
void FileAccess::store_buffer(const uint8_t *p_src, int p_length) {
-
- for (int i = 0; i < p_length; i++)
+ for (int i = 0; i < p_length; i++) {
store_8(p_src[i]);
+ }
}
Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_error) {
-
FileAccess *f = FileAccess::open(p_path, READ, r_error);
if (!f) {
if (r_error) { // if error requested, do not throw error
@@ -610,7 +566,6 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err
}
String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
-
Error err;
Vector<uint8_t> array = get_file_as_array(p_path, &err);
if (r_error) {
@@ -629,10 +584,10 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
}
String FileAccess::get_md5(const String &p_file) {
-
FileAccess *f = FileAccess::open(p_file, READ);
- if (!f)
+ if (!f) {
return String();
+ }
CryptoCore::MD5Context ctx;
ctx.start();
@@ -640,14 +595,13 @@ String FileAccess::get_md5(const String &p_file) {
unsigned char step[32768];
while (true) {
-
int br = f->get_buffer(step, 32768);
if (br > 0) {
-
ctx.update(step, br);
}
- if (br < 4096)
+ if (br < 4096) {
break;
+ }
}
unsigned char hash[16];
@@ -659,7 +613,6 @@ String FileAccess::get_md5(const String &p_file) {
}
String FileAccess::get_multiple_md5(const Vector<String> &p_file) {
-
CryptoCore::MD5Context ctx;
ctx.start();
@@ -670,14 +623,13 @@ String FileAccess::get_multiple_md5(const Vector<String> &p_file) {
unsigned char step[32768];
while (true) {
-
int br = f->get_buffer(step, 32768);
if (br > 0) {
-
ctx.update(step, br);
}
- if (br < 4096)
+ if (br < 4096) {
break;
+ }
}
memdelete(f);
}
@@ -689,10 +641,10 @@ String FileAccess::get_multiple_md5(const Vector<String> &p_file) {
}
String FileAccess::get_sha256(const String &p_file) {
-
FileAccess *f = FileAccess::open(p_file, READ);
- if (!f)
+ if (!f) {
return String();
+ }
CryptoCore::SHA256Context ctx;
ctx.start();
@@ -700,14 +652,13 @@ String FileAccess::get_sha256(const String &p_file) {
unsigned char step[32768];
while (true) {
-
int br = f->get_buffer(step, 32768);
if (br > 0) {
-
ctx.update(step, br);
}
- if (br < 4096)
+ if (br < 4096) {
break;
+ }
}
unsigned char hash[32];
@@ -716,10 +667,3 @@ String FileAccess::get_sha256(const String &p_file) {
memdelete(f);
return String::hex_encode_buffer(hash, 32);
}
-
-FileAccess::FileAccess() {
-
- endian_swap = false;
- real_is_double = false;
- _access_type = ACCESS_FILESYSTEM;
-};
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 0f85c447b6..48b9ee4269 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -41,7 +41,6 @@
*/
class FileAccess {
-
public:
enum AccessType {
ACCESS_RESOURCES,
@@ -53,8 +52,8 @@ public:
typedef void (*FileCloseFailNotify)(const String &);
typedef FileAccess *(*CreateFunc)();
- bool endian_swap;
- bool real_is_double;
+ bool endian_swap = false;
+ bool real_is_double = false;
virtual uint32_t _get_unix_permissions(const String &p_file) = 0;
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) = 0;
@@ -69,11 +68,10 @@ protected:
private:
static bool backup_save;
- AccessType _access_type;
+ AccessType _access_type = ACCESS_FILESYSTEM;
static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */
template <class T>
static FileAccess *_create_builtin() {
-
return memnew(T);
}
@@ -172,28 +170,29 @@ public:
template <class T>
static void make_default(AccessType p_access) {
-
create_func[p_access] = _create_builtin<T>;
}
- FileAccess();
+ FileAccess() {}
virtual ~FileAccess() {}
};
struct FileAccessRef {
-
_FORCE_INLINE_ FileAccess *operator->() {
-
return f;
}
operator bool() const { return f != nullptr; }
+
FileAccess *f;
+
operator FileAccess *() { return f; }
+
FileAccessRef(FileAccess *fa) { f = fa; }
~FileAccessRef() {
- if (f)
+ if (f) {
memdelete(f);
+ }
}
};
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index c65d3fefc2..d088151a6d 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -293,9 +293,7 @@ static const _KeyCodeText _keycodes[] = {
};
bool keycode_has_unicode(uint32_t p_keycode) {
-
switch (p_keycode) {
-
case KEY_ESCAPE:
case KEY_TAB:
case KEY_BACKTAB:
@@ -394,7 +392,6 @@ bool keycode_has_unicode(uint32_t p_keycode) {
}
String keycode_get_string(uint32_t p_code) {
-
String codestr;
if (p_code & KEY_MASK_SHIFT) {
codestr += find_keycode_name(KEY_SHIFT);
@@ -418,9 +415,7 @@ String keycode_get_string(uint32_t p_code) {
const _KeyCodeText *kct = &_keycodes[0];
while (kct->text) {
-
if (kct->code == (int)p_code) {
-
codestr += kct->text;
return codestr;
}
@@ -433,11 +428,9 @@ String keycode_get_string(uint32_t p_code) {
}
int find_keycode(const String &p_code) {
-
const _KeyCodeText *kct = &_keycodes[0];
while (kct->text) {
-
if (p_code.nocasecmp_to(kct->text) == 0) {
return kct->code;
}
@@ -448,11 +441,9 @@ int find_keycode(const String &p_code) {
}
const char *find_keycode_name(int p_keycode) {
-
const _KeyCodeText *kct = &_keycodes[0];
while (kct->text) {
-
if (kct->code == p_keycode) {
return kct->text;
}
@@ -463,12 +454,10 @@ const char *find_keycode_name(int p_keycode) {
}
int keycode_get_count() {
-
const _KeyCodeText *kct = &_keycodes[0];
int count = 0;
while (kct->text) {
-
count++;
kct++;
}
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 0d1a080682..dc68c2a9f9 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -33,7 +33,6 @@
#include "core/script_language.h"
void MainLoop::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
ClassDB::bind_method(D_METHOD("idle", "delta"), &MainLoop::idle);
@@ -56,41 +55,36 @@ void MainLoop::_bind_methods() {
};
void MainLoop::set_init_script(const Ref<Script> &p_init_script) {
-
init_script = p_init_script;
}
-MainLoop::MainLoop() {
-}
-
-MainLoop::~MainLoop() {
-}
-
void MainLoop::init() {
-
- if (init_script.is_valid())
+ if (init_script.is_valid()) {
set_script(init_script);
+ }
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("_initialize");
+ }
}
-bool MainLoop::iteration(float p_time) {
- if (get_script_instance())
+bool MainLoop::iteration(float p_time) {
+ if (get_script_instance()) {
return get_script_instance()->call("_iteration", p_time);
+ }
return false;
}
-bool MainLoop::idle(float p_time) {
- if (get_script_instance())
+bool MainLoop::idle(float p_time) {
+ if (get_script_instance()) {
return get_script_instance()->call("_idle", p_time);
+ }
return false;
}
void MainLoop::finish() {
-
if (get_script_instance()) {
get_script_instance()->call("_finalize");
set_script(Variant()); //clear script
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 8f6c8c91b1..90790a45a1 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -36,7 +36,6 @@
#include "core/script_language.h"
class MainLoop : public Object {
-
GDCLASS(MainLoop, Object);
OBJ_CATEGORY("Main Loop");
@@ -64,8 +63,8 @@ public:
void set_init_script(const Ref<Script> &p_init_script);
- MainLoop();
- virtual ~MainLoop();
+ MainLoop() {}
+ virtual ~MainLoop() {}
};
#endif // MAIN_LOOP_H
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index d921c10ad4..8457c52092 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -38,28 +38,23 @@
#include <stdlib.h>
void *operator new(size_t p_size, const char *p_description) {
-
return Memory::alloc_static(p_size, false);
}
void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) {
-
return p_allocfunc(p_size);
}
#ifdef _MSC_VER
void operator delete(void *p_mem, const char *p_description) {
-
CRASH_NOW_MSG("Call to placement delete should not happen.");
}
void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) {
-
CRASH_NOW_MSG("Call to placement delete should not happen.");
}
void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) {
-
CRASH_NOW_MSG("Call to placement delete should not happen.");
}
#endif
@@ -72,7 +67,6 @@ uint64_t Memory::max_usage = 0;
uint64_t Memory::alloc_count = 0;
void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
-
#ifdef DEBUG_ENABLED
bool prepad = true;
#else
@@ -102,7 +96,6 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
}
void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
-
if (p_memory == nullptr) {
return alloc_static(p_bytes, p_pad_align);
}
@@ -144,7 +137,6 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
return mem + PAD_ALIGN;
}
} else {
-
mem = (uint8_t *)realloc(mem, p_bytes);
ERR_FAIL_COND_V(mem == nullptr && p_bytes > 0, nullptr);
@@ -154,7 +146,6 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
}
void Memory::free_static(void *p_ptr, bool p_pad_align) {
-
ERR_FAIL_COND(p_ptr == nullptr);
uint8_t *mem = (uint8_t *)p_ptr;
@@ -177,13 +168,11 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
free(mem);
} else {
-
free(mem);
}
}
uint64_t Memory::get_mem_available() {
-
return -1; // 0xFFFF...
}
@@ -204,8 +193,6 @@ uint64_t Memory::get_mem_max_usage() {
}
_GlobalNil::_GlobalNil() {
-
- color = 1;
left = this;
right = this;
parent = this;
diff --git a/core/os/memory.h b/core/os/memory.h
index d377d54fad..46ffb4124b 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -41,7 +41,6 @@
#endif
class Memory {
-
Memory();
#ifdef DEBUG_ENABLED
static uint64_t mem_usage;
@@ -87,7 +86,6 @@ _ALWAYS_INLINE_ void postinitialize_handler(void *) {}
template <class T>
_ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
-
postinitialize_handler(p_obj);
return p_obj;
}
@@ -110,45 +108,48 @@ _ALWAYS_INLINE_ bool predelete_handler(void *) {
template <class T>
void memdelete(T *p_class) {
-
- if (!predelete_handler(p_class))
+ if (!predelete_handler(p_class)) {
return; // doesn't want to be deleted
- if (!__has_trivial_destructor(T))
+ }
+ if (!__has_trivial_destructor(T)) {
p_class->~T();
+ }
Memory::free_static(p_class, false);
}
template <class T, class A>
void memdelete_allocator(T *p_class) {
-
- if (!predelete_handler(p_class))
+ if (!predelete_handler(p_class)) {
return; // doesn't want to be deleted
- if (!__has_trivial_destructor(T))
+ }
+ if (!__has_trivial_destructor(T)) {
p_class->~T();
+ }
A::free(p_class);
}
#define memdelete_notnull(m_v) \
{ \
- if (m_v) \
+ if (m_v) { \
memdelete(m_v); \
+ } \
}
#define memnew_arr(m_class, m_count) memnew_arr_template<m_class>(m_count)
template <typename T>
T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
-
- if (p_elements == 0)
- return 0;
+ if (p_elements == 0) {
+ return nullptr;
+ }
/** overloading operator new[] cannot be done , because it may not return the real allocated address (it may pad the 'element count' before the actual array). Because of that, it must be done by hand. This is the
same strategy used by std::vector, and the Vector class, so it should be safe.*/
size_t len = sizeof(T) * p_elements;
uint64_t *mem = (uint64_t *)Memory::alloc_static(len, true);
- T *failptr = 0; //get rid of a warning
+ T *failptr = nullptr; //get rid of a warning
ERR_FAIL_COND_V(!mem, failptr);
*(mem - 1) = p_elements;
@@ -171,14 +172,12 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
template <typename T>
size_t memarr_len(const T *p_class) {
-
uint64_t *ptr = (uint64_t *)p_class;
return *(ptr - 1);
}
template <typename T>
void memdelete_arr(T *p_class) {
-
uint64_t *ptr = (uint64_t *)p_class;
if (!__has_trivial_destructor(T)) {
@@ -193,8 +192,7 @@ void memdelete_arr(T *p_class) {
}
struct _GlobalNil {
-
- int color;
+ int color = 1;
_GlobalNil *right;
_GlobalNil *left;
_GlobalNil *parent;
@@ -203,7 +201,6 @@ struct _GlobalNil {
};
struct _GlobalNilClass {
-
static _GlobalNil _nil;
};
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index efd87d3ab6..e9919aeb86 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -36,17 +36,14 @@
uint8_t MIDIDriver::last_received_message = 0x00;
MIDIDriver *MIDIDriver::singleton = nullptr;
MIDIDriver *MIDIDriver::get_singleton() {
-
return singleton;
}
void MIDIDriver::set_singleton() {
-
singleton = this;
}
void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_t length) {
-
Ref<InputEventMIDI> event;
event.instance();
uint32_t param_position = 1;
@@ -122,12 +119,10 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
}
PackedStringArray MIDIDriver::get_connected_inputs() {
-
PackedStringArray list;
return list;
}
MIDIDriver::MIDIDriver() {
-
set_singleton();
}
diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h
index b7377a8a40..bc922e1fcf 100644
--- a/core/os/midi_driver.h
+++ b/core/os/midi_driver.h
@@ -39,7 +39,6 @@
*/
class MIDIDriver {
-
static MIDIDriver *singleton;
static uint8_t last_received_message;
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 526549dd93..d42cbed821 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -82,8 +82,7 @@ extern template class MutexLock<MutexImpl<std::mutex>>;
#else
class FakeMutex {
-
- FakeMutex(){};
+ FakeMutex() {}
};
template <class MutexT>
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 425132fbec..c842be333c 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -43,7 +43,6 @@
OS *OS::singleton = nullptr;
OS *OS::get_singleton() {
-
return singleton;
}
@@ -83,20 +82,14 @@ String OS::get_iso_date_time(bool local) const {
uint64_t OS::get_splash_tick_msec() const {
return _msec_splash;
}
-uint64_t OS::get_unix_time() const {
- return 0;
-};
-uint64_t OS::get_system_time_secs() const {
+double OS::get_unix_time() const {
return 0;
}
-uint64_t OS::get_system_time_msecs() const {
- return 0;
-}
-void OS::debug_break(){
+void OS::debug_break() {
// something
-};
+}
void OS::_set_logger(CompositeLogger *p_logger) {
if (_logger) {
@@ -116,19 +109,17 @@ void OS::add_logger(Logger *p_logger) {
}
void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type) {
-
_logger->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type);
}
void OS::print(const char *p_format, ...) {
-
va_list argp;
va_start(argp, p_format);
_logger->logv(p_format, argp, false);
va_end(argp);
-};
+}
void OS::printerr(const char *p_format, ...) {
va_list argp;
@@ -137,73 +128,63 @@ void OS::printerr(const char *p_format, ...) {
_logger->logv(p_format, argp, true);
va_end(argp);
-};
+}
void OS::set_low_processor_usage_mode(bool p_enabled) {
-
low_processor_usage_mode = p_enabled;
}
bool OS::is_in_low_processor_usage_mode() const {
-
return low_processor_usage_mode;
}
void OS::set_low_processor_usage_mode_sleep_usec(int p_usec) {
-
low_processor_usage_mode_sleep_usec = p_usec;
}
int OS::get_low_processor_usage_mode_sleep_usec() const {
-
return low_processor_usage_mode_sleep_usec;
}
String OS::get_executable_path() const {
-
return _execpath;
}
int OS::get_process_id() const {
-
return -1;
-};
+}
void OS::vibrate_handheld(int p_duration_ms) {
-
WARN_PRINT("vibrate_handheld() only works with Android and iOS");
}
bool OS::is_stdout_verbose() const {
-
return _verbose_stdout;
}
void OS::dump_memory_to_file(const char *p_file) {
-
//Memory::dump_static_mem_to_file(p_file);
}
static FileAccess *_OSPRF = nullptr;
static void _OS_printres(Object *p_obj) {
-
Resource *res = Object::cast_to<Resource>(p_obj);
- if (!res)
+ if (!res) {
return;
+ }
String str = itos(res->get_instance_id()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path();
- if (_OSPRF)
+ if (_OSPRF) {
_OSPRF->store_line(str);
- else
+ } else {
print_line(str);
+ }
}
void OS::print_all_resources(String p_to_file) {
-
ERR_FAIL_COND(p_to_file != "" && _OSPRF);
if (p_to_file != "") {
-
Error err;
_OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err);
if (err != OK) {
@@ -215,50 +196,43 @@ void OS::print_all_resources(String p_to_file) {
ObjectDB::debug_objects(_OS_printres);
if (p_to_file != "") {
-
- if (_OSPRF)
+ if (_OSPRF) {
memdelete(_OSPRF);
+ }
_OSPRF = nullptr;
}
}
void OS::print_resources_in_use(bool p_short) {
-
ResourceCache::dump(nullptr, p_short);
}
void OS::dump_resources_to_file(const char *p_file) {
-
ResourceCache::dump(p_file);
}
void OS::set_no_window_mode(bool p_enable) {
-
_no_window = p_enable;
}
bool OS::is_no_window_mode_enabled() const {
-
return _no_window;
}
int OS::get_exit_code() const {
-
return _exit_code;
}
-void OS::set_exit_code(int p_code) {
+void OS::set_exit_code(int p_code) {
_exit_code = p_code;
}
String OS::get_locale() const {
-
return "en";
}
// Helper function to ensure that a dir name/path will be valid on the OS
String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator) const {
-
Vector<String> invalid_chars = String(": * ? \" < > |").split(" ");
if (p_allow_dir_separator) {
// Dir separators are allowed, but disallow ".." to avoid going up the filesystem
@@ -278,76 +252,64 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separato
// Get properly capitalized engine name for system paths
String OS::get_godot_dir_name() const {
-
// Default to lowercase, so only override when different case is needed
return String(VERSION_SHORT_NAME).to_lower();
}
// OS equivalent of XDG_DATA_HOME
String OS::get_data_path() const {
-
return ".";
}
// OS equivalent of XDG_CONFIG_HOME
String OS::get_config_path() const {
-
return ".";
}
// OS equivalent of XDG_CACHE_HOME
String OS::get_cache_path() const {
-
return ".";
}
// Path to macOS .app bundle resources
String OS::get_bundle_resource_dir() const {
-
return ".";
-};
+}
// OS specific path for user://
String OS::get_user_data_dir() const {
-
return ".";
-};
+}
// Absolute path to res://
String OS::get_resource_dir() const {
-
return ProjectSettings::get_singleton()->get_resource_path();
}
// Access system-specific dirs like Documents, Downloads, etc.
String OS::get_system_dir(SystemDir p_dir) const {
-
return ".";
}
Error OS::shell_open(String p_uri) {
return ERR_UNAVAILABLE;
-};
+}
// implement these with the canvas?
uint64_t OS::get_static_memory_usage() const {
-
return Memory::get_mem_usage();
}
uint64_t OS::get_static_memory_peak_usage() const {
-
return Memory::get_mem_max_usage();
}
Error OS::set_cwd(const String &p_cwd) {
-
return ERR_CANT_OPEN;
}
uint64_t OS::get_free_static_memory() const {
-
return Memory::get_mem_available();
}
@@ -355,7 +317,6 @@ void OS::yield() {
}
void OS::ensure_user_data_dir() {
-
String dd = get_user_data_dir();
DirAccess *da = DirAccess::open(dd);
if (da) {
@@ -371,28 +332,23 @@ void OS::ensure_user_data_dir() {
}
String OS::get_model_name() const {
-
return "GenericDevice";
}
void OS::set_cmdline(const char *p_execpath, const List<String> &p_args) {
-
_execpath = p_execpath;
_cmdline = p_args;
-};
+}
String OS::get_unique_id() const {
-
ERR_FAIL_V("");
}
int OS::get_processor_count() const {
-
return 1;
}
bool OS::can_use_threads() const {
-
#ifdef NO_THREADS
return false;
#else
@@ -401,24 +357,25 @@ bool OS::can_use_threads() const {
}
void OS::set_has_server_feature_callback(HasServerFeatureCallback p_callback) {
-
has_server_feature_callback = p_callback;
}
bool OS::has_feature(const String &p_feature) {
-
- if (p_feature == get_name())
+ if (p_feature == get_name()) {
return true;
+ }
#ifdef DEBUG_ENABLED
- if (p_feature == "debug")
+ if (p_feature == "debug") {
return true;
+ }
#else
if (p_feature == "release")
return true;
#endif
#ifdef TOOLS_ENABLED
- if (p_feature == "editor")
+ if (p_feature == "editor") {
return true;
+ }
#else
if (p_feature == "standalone")
return true;
@@ -458,15 +415,17 @@ bool OS::has_feature(const String &p_feature) {
}
#endif
- if (_check_internal_feature_support(p_feature))
+ if (_check_internal_feature_support(p_feature)) {
return true;
+ }
if (has_server_feature_callback && has_server_feature_callback(p_feature)) {
return true;
}
- if (ProjectSettings::get_singleton()->has_custom_feature(p_feature))
+ if (ProjectSettings::get_singleton()->has_custom_feature(p_feature)) {
return true;
+ }
return false;
}
@@ -485,48 +444,37 @@ List<String> OS::get_restart_on_exit_arguments() const {
}
PackedStringArray OS::get_connected_midi_inputs() {
-
- if (MIDIDriver::get_singleton())
+ if (MIDIDriver::get_singleton()) {
return MIDIDriver::get_singleton()->get_connected_inputs();
+ }
PackedStringArray list;
- return list;
+ ERR_FAIL_V_MSG(list, vformat("MIDI input isn't supported on %s.", OS::get_singleton()->get_name()));
}
void OS::open_midi_inputs() {
-
- if (MIDIDriver::get_singleton())
+ if (MIDIDriver::get_singleton()) {
MIDIDriver::get_singleton()->open();
+ } else {
+ ERR_PRINT(vformat("MIDI input isn't supported on %s.", OS::get_singleton()->get_name()));
+ }
}
void OS::close_midi_inputs() {
-
- if (MIDIDriver::get_singleton())
+ if (MIDIDriver::get_singleton()) {
MIDIDriver::get_singleton()->close();
+ } else {
+ ERR_PRINT(vformat("MIDI input isn't supported on %s.", OS::get_singleton()->get_name()));
+ }
}
OS::OS() {
void *volatile stack_bottom;
- restart_on_exit = false;
singleton = this;
- _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0.
- low_processor_usage_mode = false;
- low_processor_usage_mode_sleep_usec = 10000;
- _verbose_stdout = false;
- _no_window = false;
- _exit_code = 0;
-
- _render_thread_mode = RENDER_THREAD_SAFE;
- _allow_hidpi = false;
- _allow_layered = false;
_stack_bottom = (void *)(&stack_bottom);
- _logger = nullptr;
-
- has_server_feature_callback = nullptr;
-
Vector<Logger *> loggers;
loggers.push_back(memnew(StdLogger));
_set_logger(memnew(CompositeLogger(loggers)));
diff --git a/core/os/os.h b/core/os/os.h
index 38114e6814..04e10518dc 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -42,32 +42,30 @@
#include <stdarg.h>
class OS {
-
static OS *singleton;
String _execpath;
List<String> _cmdline;
- bool _keep_screen_on;
- bool low_processor_usage_mode;
- int low_processor_usage_mode_sleep_usec;
- bool _verbose_stdout;
+ bool _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0.
+ bool low_processor_usage_mode = false;
+ int low_processor_usage_mode_sleep_usec = 10000;
+ bool _verbose_stdout = false;
String _local_clipboard;
uint64_t _msec_splash;
- bool _no_window;
- int _exit_code;
+ bool _no_window = false;
+ int _exit_code = 0;
int _orientation;
- bool _allow_hidpi;
- bool _allow_layered;
+ bool _allow_hidpi = false;
+ bool _allow_layered = false;
bool _use_vsync;
bool _vsync_via_compositor;
- bool _disable_wintab;
char *last_error;
void *_stack_bottom;
- CompositeLogger *_logger;
+ CompositeLogger *_logger = nullptr;
- bool restart_on_exit;
+ bool restart_on_exit = false;
List<String> restart_commandline;
protected:
@@ -87,8 +85,8 @@ public:
protected:
friend class Main;
- HasServerFeatureCallback has_server_feature_callback;
- RenderThreadMode _render_thread_mode;
+ HasServerFeatureCallback has_server_feature_callback = nullptr;
+ RenderThreadMode _render_thread_mode = RENDER_THREAD_SAFE;
// functions used by main to initialize/deinitialize the OS
void add_logger(Logger *p_logger);
@@ -149,7 +147,11 @@ public:
bool is_layered_allowed() const { return _allow_layered; }
bool is_hidpi_allowed() const { return _allow_hidpi; }
- bool is_wintab_disabled() const { return _disable_wintab; }
+
+ virtual int get_tablet_driver_count() const { return 0; };
+ virtual String get_tablet_driver_name(int p_driver) const { return ""; };
+ virtual String get_current_tablet_driver() const { return ""; };
+ virtual void set_current_tablet_driver(const String &p_driver){};
void ensure_user_data_dir();
@@ -185,7 +187,6 @@ public:
};
struct Date {
-
int year;
Month month;
int day;
@@ -194,7 +195,6 @@ public:
};
struct Time {
-
int hour;
int min;
int sec;
@@ -209,9 +209,7 @@ public:
virtual Time get_time(bool local = false) const = 0;
virtual TimeZoneInfo get_time_zone_info() const = 0;
virtual String get_iso_date_time(bool local = false) const;
- virtual uint64_t get_unix_time() const;
- virtual uint64_t get_system_time_secs() const;
- virtual uint64_t get_system_time_msecs() const;
+ virtual double get_unix_time() const;
virtual void delay_usec(uint32_t p_usec) const = 0;
virtual uint64_t get_ticks_usec() const = 0;
diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp
index 1dd2c3bccb..a668fe2b4c 100644
--- a/core/os/rw_lock.cpp
+++ b/core/os/rw_lock.cpp
@@ -37,11 +37,7 @@
RWLock *(*RWLock::create_func)() = nullptr;
RWLock *RWLock::create() {
-
ERR_FAIL_COND_V(!create_func, nullptr);
return create_func();
}
-
-RWLock::~RWLock() {
-}
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 2ef4df9b70..1035072cce 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -48,38 +48,40 @@ public:
static RWLock *create(); ///< Create a rwlock
- virtual ~RWLock();
+ virtual ~RWLock() {}
};
class RWLockRead {
-
RWLock *lock;
public:
RWLockRead(const RWLock *p_lock) {
lock = const_cast<RWLock *>(p_lock);
- if (lock)
+ if (lock) {
lock->read_lock();
+ }
}
~RWLockRead() {
- if (lock)
+ if (lock) {
lock->read_unlock();
+ }
}
};
class RWLockWrite {
-
RWLock *lock;
public:
RWLockWrite(RWLock *p_lock) {
lock = p_lock;
- if (lock)
+ if (lock) {
lock->write_lock();
+ }
}
~RWLockWrite() {
- if (lock)
+ if (lock) {
lock->write_unlock();
+ }
}
};
diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp
deleted file mode 100644
index 93f1e2dff4..0000000000
--- a/core/os/semaphore.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*************************************************************************/
-/* semaphore.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 "semaphore.h"
diff --git a/core/os/semaphore.h b/core/os/semaphore.h
index 3d9d1ab984..077e04704b 100644
--- a/core/os/semaphore.h
+++ b/core/os/semaphore.h
@@ -54,8 +54,9 @@ public:
_ALWAYS_INLINE_ void wait() const {
std::unique_lock<decltype(mutex_)> lock(mutex_);
- while (!count_) // Handle spurious wake-ups.
+ while (!count_) { // Handle spurious wake-ups.
condition_.wait(lock);
+ }
--count_;
}
diff --git a/core/os/thread.cpp b/core/os/thread.cpp
index 294b52f00c..fc0ce3c9b4 100644
--- a/core/os/thread.cpp
+++ b/core/os/thread.cpp
@@ -38,37 +38,29 @@ Error (*Thread::set_name_func)(const String &) = nullptr;
Thread::ID Thread::_main_thread_id = 0;
Thread::ID Thread::get_caller_id() {
-
- if (get_thread_id_func)
+ if (get_thread_id_func) {
return get_thread_id_func();
+ }
return 0;
}
Thread *Thread::create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings) {
-
if (create_func) {
-
return create_func(p_callback, p_user, p_settings);
}
return nullptr;
}
void Thread::wait_to_finish(Thread *p_thread) {
-
- if (wait_to_finish_func)
+ if (wait_to_finish_func) {
wait_to_finish_func(p_thread);
+ }
}
Error Thread::set_name(const String &p_name) {
-
- if (set_name_func)
+ if (set_name_func) {
return set_name_func(p_name);
+ }
return ERR_UNAVAILABLE;
-};
-
-Thread::Thread() {
-}
-
-Thread::~Thread() {
}
diff --git a/core/os/thread.h b/core/os/thread.h
index 76d296bcf7..f761d4ca43 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -46,7 +46,6 @@ public:
};
struct Settings {
-
Priority priority;
Settings() { priority = PRIORITY_NORMAL; }
};
@@ -63,7 +62,7 @@ protected:
static ID _main_thread_id;
- Thread();
+ Thread() {}
public:
virtual ID get_id() const = 0;
@@ -74,7 +73,7 @@ public:
static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it.
static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback
- virtual ~Thread();
+ virtual ~Thread() {}
};
#endif // THREAD_H
diff --git a/core/os/thread_dummy.cpp b/core/os/thread_dummy.cpp
index 9dcddcae11..2672cd7ad9 100644
--- a/core/os/thread_dummy.cpp
+++ b/core/os/thread_dummy.cpp
@@ -34,16 +34,16 @@
Thread *ThreadDummy::create(ThreadCreateCallback p_callback, void *p_user, const Thread::Settings &p_settings) {
return memnew(ThreadDummy);
-};
+}
void ThreadDummy::make_default() {
Thread::create_func = &ThreadDummy::create;
-};
+}
RWLock *RWLockDummy::create() {
return memnew(RWLockDummy);
-};
+}
void RWLockDummy::make_default() {
RWLock::create_func = &RWLockDummy::create;
-};
+}
diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h
index 066ee498ac..37d9ee0846 100644
--- a/core/os/thread_dummy.h
+++ b/core/os/thread_dummy.h
@@ -36,7 +36,6 @@
#include "core/os/thread.h"
class ThreadDummy : public Thread {
-
static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings());
public:
@@ -46,7 +45,6 @@ public:
};
class RWLockDummy : public RWLock {
-
static RWLock *create();
public:
diff --git a/core/os/threaded_array_processor.h b/core/os/threaded_array_processor.h
index 00dc53286e..d27399e4cc 100644
--- a/core/os/threaded_array_processor.h
+++ b/core/os/threaded_array_processor.h
@@ -54,19 +54,18 @@ struct ThreadArrayProcessData {
template <class T>
void process_array_thread(void *ud) {
-
T &data = *(T *)ud;
while (true) {
uint32_t index = atomic_increment(&data.index);
- if (index >= data.elements)
+ if (index >= data.elements) {
break;
+ }
data.process(index);
}
}
template <class C, class M, class U>
void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
-
ThreadArrayProcessData<C, U> data;
data.method = p_method;
data.instance = p_instance;
@@ -93,7 +92,6 @@ void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_us
template <class C, class M, class U>
void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
-
ThreadArrayProcessData<C, U> data;
data.method = p_method;
data.instance = p_instance;
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 04deba2c14..e335ec0daa 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -34,51 +34,50 @@
#include "core/io/marshalls.h"
Variant PackedDataContainer::getvar(const Variant &p_key, bool *r_valid) const {
-
bool err = false;
Variant ret = _key_at_ofs(0, p_key, err);
- if (r_valid)
+ if (r_valid) {
*r_valid = !err;
+ }
return ret;
}
int PackedDataContainer::size() const {
-
return _size(0);
-};
+}
Variant PackedDataContainer::_iter_init_ofs(const Array &p_iter, uint32_t p_offset) {
-
Array ref = p_iter;
uint32_t size = _size(p_offset);
- if (size == 0 || ref.size() != 1)
+ if (size == 0 || ref.size() != 1) {
return false;
- else {
+ } else {
ref[0] = 0;
return true;
}
}
Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offset) {
-
Array ref = p_iter;
int size = _size(p_offset);
- if (ref.size() != 1)
+ if (ref.size() != 1) {
return false;
+ }
int pos = ref[0];
- if (pos < 0 || pos >= size)
+ if (pos < 0 || pos >= size) {
return false;
+ }
pos += 1;
ref[0] = pos;
return pos != size;
}
Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) {
-
int size = _size(p_offset);
int pos = p_iter;
- if (pos < 0 || pos >= size)
+ if (pos < 0 || pos >= size) {
return Variant();
+ }
const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_offset];
@@ -86,12 +85,10 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_off
bool err = false;
if (type == TYPE_ARRAY) {
-
uint32_t vpos = decode_uint32(rd + p_offset + 8 + pos * 4);
return _get_at_ofs(vpos, rd, err);
} else if (type == TYPE_DICT) {
-
uint32_t vpos = decode_uint32(rd + p_offset + 8 + pos * 12 + 4);
return _get_at_ofs(vpos, rd, err);
} else {
@@ -100,11 +97,9 @@ Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_off
}
Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, bool &err) const {
-
uint32_t type = decode_uint32(p_buf + p_ofs);
if (type == TYPE_ARRAY || type == TYPE_DICT) {
-
Ref<PackedDataContainerRef> pdcr = memnew(PackedDataContainerRef);
Ref<PackedDataContainer> pdc = Ref<PackedDataContainer>((PackedDataContainer *)this);
@@ -112,12 +107,10 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b
pdcr->offset = p_ofs;
return pdcr;
} else {
-
Variant v;
Error rerr = decode_variant(v, p_buf + p_ofs, datalen - p_ofs, nullptr, false);
if (rerr != OK) {
-
err = true;
ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant.");
}
@@ -126,45 +119,38 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b
}
uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
-
const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
return type;
-};
+}
int PackedDataContainer::_size(uint32_t p_ofs) const {
-
const uint8_t *rd = data.ptr();
ERR_FAIL_COND_V(!rd, 0);
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
if (type == TYPE_ARRAY) {
-
uint32_t len = decode_uint32(r + 4);
return len;
} else if (type == TYPE_DICT) {
-
uint32_t len = decode_uint32(r + 4);
return len;
- };
+ }
return -1;
-};
+}
Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, bool &err) const {
-
const uint8_t *rd = data.ptr();
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
if (type == TYPE_ARRAY) {
-
if (p_key.is_num()) {
-
int idx = p_key;
int len = decode_uint32(r + 4);
if (idx < 0 || idx >= len) {
@@ -180,7 +166,6 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
}
} else if (type == TYPE_DICT) {
-
uint32_t hash = p_key.hash();
uint32_t len = decode_uint32(r + 4);
@@ -189,16 +174,18 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
if (khash == hash) {
Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd, err);
- if (err)
+ if (err) {
return Variant();
+ }
if (key == p_key) {
//key matches, return value
return _get_at_ofs(decode_uint32(r + 8 + i * 12 + 8), rd, err);
}
found = true;
} else {
- if (found)
+ if (found) {
break;
+ }
}
}
@@ -206,18 +193,14 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
return Variant();
} else {
-
err = true;
return Variant();
}
}
uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpdata, Map<String, uint32_t> &string_cache) {
-
switch (p_data.get_type()) {
-
case Variant::STRING: {
-
String s = p_data;
if (string_cache.has(s)) {
return string_cache[s];
@@ -251,7 +234,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::PACKED_COLOR_ARRAY:
case Variant::STRING_NAME:
case Variant::NODE_PATH: {
-
uint32_t pos = tmpdata.size();
int len;
encode_variant(p_data, nullptr, len, false);
@@ -263,11 +245,9 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
// misc types
case Variant::_RID:
case Variant::OBJECT: {
-
return _pack(Variant(), tmpdata, string_cache);
} break;
case Variant::DICTIONARY: {
-
Dictionary d = p_data;
//size is known, use sort
uint32_t pos = tmpdata.size();
@@ -281,7 +261,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
List<DictKey> sortk;
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
DictKey dk;
dk.hash = E->get().hash();
dk.key = E->get();
@@ -292,7 +271,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
int idx = 0;
for (List<DictKey>::Element *E = sortk.front(); E; E = E->next()) {
-
encode_uint32(E->get().hash, &tmpdata.write[pos + 8 + idx * 12 + 0]);
uint32_t ofs = _pack(E->get().key, tmpdata, string_cache);
encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 4]);
@@ -305,7 +283,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
} break;
case Variant::ARRAY: {
-
Array a = p_data;
//size is known, use sort
uint32_t pos = tmpdata.size();
@@ -315,7 +292,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
encode_uint32(len, &tmpdata.write[pos + 4]);
for (int i = 0; i < len; i++) {
-
uint32_t ofs = _pack(a[i], tmpdata, string_cache);
encode_uint32(ofs, &tmpdata.write[pos + 8 + i * 4]);
}
@@ -332,7 +308,6 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
}
Error PackedDataContainer::pack(const Variant &p_data) {
-
Vector<uint8_t> tmpdata;
Map<String, uint32_t> string_cache;
_pack(p_data, tmpdata, string_cache);
@@ -345,7 +320,6 @@ Error PackedDataContainer::pack(const Variant &p_data) {
}
void PackedDataContainer::_set_data(const Vector<uint8_t> &p_data) {
-
data = p_data;
datalen = data.size();
}
@@ -355,21 +329,18 @@ Vector<uint8_t> PackedDataContainer::_get_data() const {
}
Variant PackedDataContainer::_iter_init(const Array &p_iter) {
-
return _iter_init_ofs(p_iter, 0);
}
Variant PackedDataContainer::_iter_next(const Array &p_iter) {
-
return _iter_next_ofs(p_iter, 0);
}
-Variant PackedDataContainer::_iter_get(const Variant &p_iter) {
+Variant PackedDataContainer::_iter_get(const Variant &p_iter) {
return _iter_get_ofs(p_iter, 0);
}
void PackedDataContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_data"), &PackedDataContainer::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &PackedDataContainer::_get_data);
ClassDB::bind_method(D_METHOD("_iter_init"), &PackedDataContainer::_iter_init);
@@ -381,34 +352,25 @@ void PackedDataContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "__data__"), "_set_data", "_get_data");
}
-PackedDataContainer::PackedDataContainer() {
-
- datalen = 0;
-}
-
//////////////////
Variant PackedDataContainerRef::_iter_init(const Array &p_iter) {
-
return from->_iter_init_ofs(p_iter, offset);
}
Variant PackedDataContainerRef::_iter_next(const Array &p_iter) {
-
return from->_iter_next_ofs(p_iter, offset);
}
-Variant PackedDataContainerRef::_iter_get(const Variant &p_iter) {
+Variant PackedDataContainerRef::_iter_get(const Variant &p_iter) {
return from->_iter_get_ofs(p_iter, offset);
}
bool PackedDataContainerRef::_is_dictionary() const {
-
return from->_type_at_ofs(offset) == PackedDataContainer::TYPE_DICT;
-};
+}
void PackedDataContainerRef::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("size"), &PackedDataContainerRef::size);
ClassDB::bind_method(D_METHOD("_iter_init"), &PackedDataContainerRef::_iter_init);
ClassDB::bind_method(D_METHOD("_iter_get"), &PackedDataContainerRef::_iter_get);
@@ -417,18 +379,14 @@ void PackedDataContainerRef::_bind_methods() {
}
Variant PackedDataContainerRef::getvar(const Variant &p_key, bool *r_valid) const {
-
bool err = false;
Variant ret = from->_key_at_ofs(offset, p_key, err);
- if (r_valid)
+ if (r_valid) {
*r_valid = !err;
+ }
return ret;
}
int PackedDataContainerRef::size() const {
-
return from->_size(offset);
-};
-
-PackedDataContainerRef::PackedDataContainerRef() {
}
diff --git a/core/packed_data_container.h b/core/packed_data_container.h
index 0f08a1cb7b..b41e9aaefc 100644
--- a/core/packed_data_container.h
+++ b/core/packed_data_container.h
@@ -34,7 +34,6 @@
#include "core/resource.h"
class PackedDataContainer : public Resource {
-
GDCLASS(PackedDataContainer, Resource);
enum {
@@ -49,7 +48,7 @@ class PackedDataContainer : public Resource {
};
Vector<uint8_t> data;
- int datalen;
+ int datalen = 0;
uint32_t _pack(const Variant &p_data, Vector<uint8_t> &tmpdata, Map<String, uint32_t> &string_cache);
@@ -78,7 +77,7 @@ public:
int size() const;
- PackedDataContainer();
+ PackedDataContainer() {}
};
class PackedDataContainerRef : public Reference {
@@ -100,7 +99,7 @@ public:
int size() const;
virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const;
- PackedDataContainerRef();
+ PackedDataContainerRef() {}
};
#endif // PACKED_DATA_CONTAINER_H
diff --git a/core/pair.h b/core/pair.h
index 26a317e9d4..89ea2b9fd9 100644
--- a/core/pair.h
+++ b/core/pair.h
@@ -33,7 +33,6 @@
template <class F, class S>
struct Pair {
-
F first;
S second;
@@ -60,7 +59,6 @@ bool operator!=(const Pair<F, S> &pair, const Pair<F, S> &other) {
template <class F, class S>
struct PairSort {
-
bool operator()(const Pair<F, S> &A, const Pair<F, S> &B) const {
return A.first < B.first;
}
diff --git a/core/path_remap.cpp b/core/path_remap.cpp
deleted file mode 100644
index e1708e0350..0000000000
--- a/core/path_remap.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*************************************************************************/
-/* path_remap.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 "path_remap.h"
diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp
index 8fd67a47d2..b222c20a00 100644
--- a/core/pool_allocator.cpp
+++ b/core/pool_allocator.cpp
@@ -53,12 +53,11 @@ void PoolAllocator::mt_unlock() const {
}
bool PoolAllocator::get_free_entry(EntryArrayPos *p_pos) {
-
- if (entry_count == entry_max)
+ if (entry_count == entry_max) {
return false;
+ }
for (int i = 0; i < entry_max; i++) {
-
if (entry_array[i].len == 0) {
*p_pos = i;
return true;
@@ -77,13 +76,11 @@ bool PoolAllocator::get_free_entry(EntryArrayPos *p_pos) {
* @return false if hole found, true if no hole found
*/
bool PoolAllocator::find_hole(EntryArrayPos *p_pos, int p_for_size) {
-
/* position where previous entry ends. Defaults to zero (begin of pool) */
int prev_entry_end_pos = 0;
for (int i = 0; i < entry_count; i++) {
-
Entry &entry = entry_array[entry_indices[i]];
/* determine hole size to previous entry */
@@ -111,13 +108,12 @@ bool PoolAllocator::find_hole(EntryArrayPos *p_pos, int p_for_size) {
}
void PoolAllocator::compact(int p_up_to) {
-
uint32_t prev_entry_end_pos = 0;
- if (p_up_to < 0)
+ if (p_up_to < 0) {
p_up_to = entry_count;
+ }
for (int i = 0; i < p_up_to; i++) {
-
Entry &entry = entry_array[entry_indices[i]];
/* determine hole size to previous entry */
@@ -126,7 +122,6 @@ void PoolAllocator::compact(int p_up_to) {
/* if we can compact, do it */
if (hole_size > 0 && !entry.lock) {
-
COMPACT_CHUNK(entry, prev_entry_end_pos);
}
@@ -136,11 +131,9 @@ void PoolAllocator::compact(int p_up_to) {
}
void PoolAllocator::compact_up(int p_from) {
-
uint32_t next_entry_end_pos = pool_size; // - static_area_size;
for (int i = entry_count - 1; i >= p_from; i--) {
-
Entry &entry = entry_array[entry_indices[i]];
/* determine hole size to nextious entry */
@@ -149,7 +142,6 @@ void PoolAllocator::compact_up(int p_from) {
/* if we can compact, do it */
if (hole_size > 0 && !entry.lock) {
-
COMPACT_CHUNK(entry, (next_entry_end_pos - aligned(entry.len)));
}
@@ -159,31 +151,29 @@ void PoolAllocator::compact_up(int p_from) {
}
bool PoolAllocator::find_entry_index(EntryIndicesPos *p_map_pos, Entry *p_entry) {
-
EntryArrayPos entry_pos = entry_max;
for (int i = 0; i < entry_count; i++) {
-
if (&entry_array[entry_indices[i]] == p_entry) {
-
entry_pos = i;
break;
}
}
- if (entry_pos == entry_max)
+ if (entry_pos == entry_max) {
return false;
+ }
*p_map_pos = entry_pos;
return true;
}
PoolAllocator::ID PoolAllocator::alloc(int p_size) {
-
ERR_FAIL_COND_V(p_size < 1, POOL_ALLOCATOR_INVALID_ID);
#ifdef DEBUG_ENABLED
- if (p_size > free_mem)
+ if (p_size > free_mem) {
OS::get_singleton()->debug_break();
+ }
#endif
ERR_FAIL_COND_V(p_size > free_mem, POOL_ALLOCATOR_INVALID_ID);
@@ -221,7 +211,6 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
/* move all entry indices up, make room for this one */
for (int i = entry_count; i > new_entry_indices_pos; i--) {
-
entry_indices[i] = entry_indices[i - 1];
}
@@ -236,8 +225,9 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
entry.lock = 0;
entry.check = (check_count++) & CHECK_MASK;
free_mem -= size_to_alloc;
- if (free_mem < free_mem_peak)
+ if (free_mem < free_mem_peak) {
free_mem_peak = free_mem;
+ }
ID retval = (entry_indices[new_entry_indices_pos] << CHECK_BITS) | entry.check;
mt_unlock();
@@ -248,7 +238,6 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
}
PoolAllocator::Entry *PoolAllocator::get_entry(ID p_mem) {
-
unsigned int check = p_mem & CHECK_MASK;
int entry = p_mem >> CHECK_BITS;
ERR_FAIL_INDEX_V(entry, entry_max, nullptr);
@@ -259,7 +248,6 @@ PoolAllocator::Entry *PoolAllocator::get_entry(ID p_mem) {
}
const PoolAllocator::Entry *PoolAllocator::get_entry(ID p_mem) const {
-
unsigned int check = p_mem & CHECK_MASK;
int entry = p_mem >> CHECK_BITS;
ERR_FAIL_INDEX_V(entry, entry_max, nullptr);
@@ -270,7 +258,6 @@ const PoolAllocator::Entry *PoolAllocator::get_entry(ID p_mem) const {
}
void PoolAllocator::free(ID p_mem) {
-
mt_lock();
Entry *e = get_entry(p_mem);
if (!e) {
@@ -288,13 +275,11 @@ void PoolAllocator::free(ID p_mem) {
bool index_found = find_entry_index(&entry_indices_pos, e);
if (!index_found) {
-
mt_unlock();
ERR_FAIL_COND(!index_found);
}
for (int i = entry_indices_pos; i < (entry_count - 1); i++) {
-
entry_indices[i] = entry_indices[i + 1];
}
@@ -305,13 +290,11 @@ void PoolAllocator::free(ID p_mem) {
}
int PoolAllocator::get_size(ID p_mem) const {
-
int size;
mt_lock();
const Entry *e = get_entry(p_mem);
if (!e) {
-
mt_unlock();
ERR_PRINT("!e");
return 0;
@@ -325,7 +308,6 @@ int PoolAllocator::get_size(ID p_mem) const {
}
Error PoolAllocator::resize(ID p_mem, int p_new_size) {
-
mt_lock();
Entry *e = get_entry(p_mem);
@@ -342,12 +324,10 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
uint32_t alloc_size = aligned(p_new_size);
if ((uint32_t)aligned(e->len) == alloc_size) {
-
e->len = p_new_size;
mt_unlock();
return OK;
} else if (e->len > (uint32_t)p_new_size) {
-
free_mem += aligned(e->len);
free_mem -= alloc_size;
e->len = p_new_size;
@@ -361,14 +341,13 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
if (uint32_t(_free + aligned(e->len)) < alloc_size) {
mt_unlock();
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
- };
+ }
EntryIndicesPos entry_indices_pos;
bool index_found = find_entry_index(&entry_indices_pos, e);
if (!index_found) {
-
mt_unlock();
ERR_FAIL_COND_V(!index_found, ERR_BUG);
}
@@ -379,7 +358,7 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
next_pos = pool_size; // - static_area_size;
} else {
next_pos = entry_array[entry_indices[entry_indices_pos + 1]].pos;
- };
+ }
if ((next_pos - e->pos) > alloc_size) {
free_mem += aligned(e->len);
@@ -398,8 +377,9 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
e->len = p_new_size;
free_mem -= alloc_size;
mt_unlock();
- if (free_mem < free_mem_peak)
+ if (free_mem < free_mem_peak) {
free_mem_peak = free_mem;
+ }
return OK;
}
@@ -413,8 +393,9 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
e->len = p_new_size;
free_mem -= alloc_size;
mt_unlock();
- if (free_mem < free_mem_peak)
+ if (free_mem < free_mem_peak) {
free_mem_peak = free_mem;
+ }
return OK;
}
@@ -423,13 +404,12 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
}
Error PoolAllocator::lock(ID p_mem) {
-
- if (!needs_locking)
+ if (!needs_locking) {
return OK;
+ }
mt_lock();
Entry *e = get_entry(p_mem);
if (!e) {
-
mt_unlock();
ERR_PRINT("!e");
return ERR_INVALID_PARAMETER;
@@ -440,14 +420,13 @@ Error PoolAllocator::lock(ID p_mem) {
}
bool PoolAllocator::is_locked(ID p_mem) const {
-
- if (!needs_locking)
+ if (!needs_locking) {
return false;
+ }
mt_lock();
const Entry *e = ((PoolAllocator *)(this))->get_entry(p_mem);
if (!e) {
-
mt_unlock();
ERR_PRINT("!e");
return false;
@@ -458,9 +437,7 @@ bool PoolAllocator::is_locked(ID p_mem) const {
}
const void *PoolAllocator::get(ID p_mem) const {
-
if (!needs_locking) {
-
const Entry *e = get_entry(p_mem);
ERR_FAIL_COND_V(!e, nullptr);
return &pool[e->pos];
@@ -470,19 +447,16 @@ const void *PoolAllocator::get(ID p_mem) const {
const Entry *e = get_entry(p_mem);
if (!e) {
-
mt_unlock();
ERR_FAIL_COND_V(!e, nullptr);
}
if (e->lock == 0) {
-
mt_unlock();
ERR_PRINT("e->lock == 0");
return nullptr;
}
if ((int)e->pos >= pool_size) {
-
mt_unlock();
ERR_PRINT("e->pos<0 || e->pos>=pool_size");
return nullptr;
@@ -495,9 +469,7 @@ const void *PoolAllocator::get(ID p_mem) const {
}
void *PoolAllocator::get(ID p_mem) {
-
if (!needs_locking) {
-
Entry *e = get_entry(p_mem);
ERR_FAIL_COND_V(!e, nullptr);
return &pool[e->pos];
@@ -507,12 +479,10 @@ void *PoolAllocator::get(ID p_mem) {
Entry *e = get_entry(p_mem);
if (!e) {
-
mt_unlock();
ERR_FAIL_COND_V(!e, nullptr);
}
if (e->lock == 0) {
-
//assert(0);
mt_unlock();
ERR_PRINT("e->lock == 0");
@@ -520,7 +490,6 @@ void *PoolAllocator::get(ID p_mem) {
}
if ((int)e->pos >= pool_size) {
-
mt_unlock();
ERR_PRINT("e->pos<0 || e->pos>=pool_size");
return nullptr;
@@ -531,10 +500,11 @@ void *PoolAllocator::get(ID p_mem) {
return ptr;
}
-void PoolAllocator::unlock(ID p_mem) {
- if (!needs_locking)
+void PoolAllocator::unlock(ID p_mem) {
+ if (!needs_locking) {
return;
+ }
mt_lock();
Entry *e = get_entry(p_mem);
if (!e) {
@@ -551,22 +521,18 @@ void PoolAllocator::unlock(ID p_mem) {
}
int PoolAllocator::get_used_mem() const {
-
return pool_size - free_mem;
}
int PoolAllocator::get_free_peak() {
-
return free_mem_peak;
}
int PoolAllocator::get_free_mem() {
-
return free_mem;
}
void PoolAllocator::create_pool(void *p_mem, int p_size, int p_max_entries) {
-
pool = (uint8_t *)p_mem;
pool_size = p_size;
@@ -582,7 +548,6 @@ void PoolAllocator::create_pool(void *p_mem, int p_size, int p_max_entries) {
}
PoolAllocator::PoolAllocator(int p_size, bool p_needs_locking, int p_max_entries) {
-
mem_ptr = memalloc(p_size);
ERR_FAIL_COND(!mem_ptr);
align = 1;
@@ -591,9 +556,7 @@ PoolAllocator::PoolAllocator(int p_size, bool p_needs_locking, int p_max_entries
}
PoolAllocator::PoolAllocator(void *p_mem, int p_size, int p_align, bool p_needs_locking, int p_max_entries) {
-
if (p_align > 1) {
-
uint8_t *mem8 = (uint8_t *)p_mem;
uint64_t ofs = (uint64_t)mem8;
if (ofs % p_align) {
@@ -601,8 +564,8 @@ PoolAllocator::PoolAllocator(void *p_mem, int p_size, int p_align, bool p_needs_
mem8 += p_align - (ofs % p_align);
p_size -= dif;
p_mem = (void *)mem8;
- };
- };
+ }
+ }
create_pool(p_mem, p_size, p_max_entries);
needs_locking = p_needs_locking;
@@ -611,22 +574,22 @@ PoolAllocator::PoolAllocator(void *p_mem, int p_size, int p_align, bool p_needs_
}
PoolAllocator::PoolAllocator(int p_align, int p_size, bool p_needs_locking, int p_max_entries) {
-
ERR_FAIL_COND(p_align < 1);
mem_ptr = Memory::alloc_static(p_size + p_align, true);
uint8_t *mem8 = (uint8_t *)mem_ptr;
uint64_t ofs = (uint64_t)mem8;
- if (ofs % p_align)
+ if (ofs % p_align) {
mem8 += p_align - (ofs % p_align);
+ }
create_pool(mem8, p_size, p_max_entries);
needs_locking = p_needs_locking;
align = p_align;
}
PoolAllocator::~PoolAllocator() {
-
- if (mem_ptr)
+ if (mem_ptr) {
memfree(mem_ptr);
+ }
memdelete_arr(entry_array);
memdelete_arr(entry_indices);
diff --git a/core/pool_allocator.h b/core/pool_allocator.h
index 8c1710ebe0..7d77af6266 100644
--- a/core/pool_allocator.h
+++ b/core/pool_allocator.h
@@ -60,11 +60,10 @@ private:
};
struct Entry {
-
- unsigned int pos;
- unsigned int len;
- unsigned int lock;
- unsigned int check;
+ unsigned int pos = 0;
+ unsigned int len = 0;
+ unsigned int lock = 0;
+ unsigned int check = 0;
inline void clear() {
pos = 0;
@@ -72,7 +71,7 @@ private:
lock = 0;
check = 0;
}
- Entry() { clear(); }
+ Entry() {}
};
typedef int EntryArrayPos;
@@ -99,10 +98,10 @@ private:
return p_entry.pos + aligned(p_entry.len);
}
inline int aligned(int p_size) const {
-
int rem = p_size % align;
- if (rem)
+ if (rem) {
p_size += align - rem;
+ }
return p_size;
}
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 8eb1d9e86a..54de229471 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -39,7 +39,6 @@ bool _print_line_enabled = true;
bool _print_error_enabled = true;
void add_print_handler(PrintHandlerList *p_handler) {
-
_global_lock();
p_handler->next = print_handler_list;
print_handler_list = p_handler;
@@ -47,20 +46,18 @@ void add_print_handler(PrintHandlerList *p_handler) {
}
void remove_print_handler(PrintHandlerList *p_handler) {
-
_global_lock();
PrintHandlerList *prev = nullptr;
PrintHandlerList *l = print_handler_list;
while (l) {
-
if (l == p_handler) {
-
- if (prev)
+ if (prev) {
prev->next = l->next;
- else
+ } else {
print_handler_list = l->next;
+ }
break;
}
prev = l;
@@ -73,16 +70,15 @@ void remove_print_handler(PrintHandlerList *p_handler) {
}
void print_line(String p_string) {
-
- if (!_print_line_enabled)
+ if (!_print_line_enabled) {
return;
+ }
OS::get_singleton()->print("%s\n", p_string.utf8().get_data());
_global_lock();
PrintHandlerList *l = print_handler_list;
while (l) {
-
l->printfunc(l->userdata, p_string, false);
l = l->next;
}
@@ -91,16 +87,15 @@ void print_line(String p_string) {
}
void print_error(String p_string) {
-
- if (!_print_error_enabled)
+ if (!_print_error_enabled) {
return;
+ }
OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data());
_global_lock();
PrintHandlerList *l = print_handler_list;
while (l) {
-
l->printfunc(l->userdata, p_string, true);
l = l->next;
}
@@ -109,7 +104,6 @@ void print_error(String p_string) {
}
void print_verbose(String p_string) {
-
if (OS::get_singleton()->is_stdout_verbose()) {
print_line(p_string);
}
diff --git a/core/print_string.h b/core/print_string.h
index d83cc35dd6..4d03f4a6de 100644
--- a/core/print_string.h
+++ b/core/print_string.h
@@ -38,17 +38,12 @@ extern void (*_print_func)(String);
typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error);
struct PrintHandlerList {
+ PrintHandlerFunc printfunc = nullptr;
+ void *userdata = nullptr;
- PrintHandlerFunc printfunc;
- void *userdata;
+ PrintHandlerList *next = nullptr;
- PrintHandlerList *next;
-
- PrintHandlerList() {
- printfunc = 0;
- next = 0;
- userdata = 0;
- }
+ PrintHandlerList() {}
};
void add_print_handler(PrintHandlerList *p_handler);
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 12522281d0..5247f6da40 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -46,30 +46,28 @@
ProjectSettings *ProjectSettings::singleton = nullptr;
ProjectSettings *ProjectSettings::get_singleton() {
-
return singleton;
}
String ProjectSettings::get_resource_path() const {
-
return resource_path;
-};
+}
String ProjectSettings::localize_path(const String &p_path) const {
-
- if (resource_path == "")
+ if (resource_path == "") {
return p_path; //not initialized yet
+ }
if (p_path.begins_with("res://") || p_path.begins_with("user://") ||
- (p_path.is_abs_path() && !p_path.begins_with(resource_path)))
+ (p_path.is_abs_path() && !p_path.begins_with(resource_path))) {
return p_path.simplify_path();
+ }
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String path = p_path.replace("\\", "/").simplify_path();
if (dir->change_dir(path) == OK) {
-
String cwd = dir->get_current_dir();
cwd = cwd.replace("\\", "/");
@@ -89,59 +87,52 @@ String ProjectSettings::localize_path(const String &p_path) const {
if (!cwd.begins_with(res_path)) {
return p_path;
- };
+ }
return cwd.replace_first(res_path, "res://");
} else {
-
memdelete(dir);
int sep = path.find_last("/");
if (sep == -1) {
return "res://" + path;
- };
+ }
String parent = path.substr(0, sep);
String plocal = localize_path(parent);
if (plocal == "") {
return "";
- };
+ }
// Only strip the starting '/' from 'path' if its parent ('plocal') ends with '/'
if (plocal[plocal.length() - 1] == '/') {
sep += 1;
}
return plocal + path.substr(sep, path.size() - sep);
- };
+ }
}
void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) {
-
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props[p_name].initial = p_value;
}
-void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) {
+void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) {
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props[p_name].restart_if_changed = p_restart;
}
String ProjectSettings::globalize_path(const String &p_path) const {
-
if (p_path.begins_with("res://")) {
-
if (resource_path != "") {
-
return p_path.replace("res:/", resource_path);
- };
+ }
return p_path.replace("res://", "");
} else if (p_path.begins_with("user://")) {
-
String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
-
return p_path.replace("user:/", data_dir);
- };
+ }
return p_path.replace("user://", "");
}
@@ -149,17 +140,14 @@ String ProjectSettings::globalize_path(const String &p_path) const {
}
bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
-
_THREAD_SAFE_METHOD_
- if (p_value.get_type() == Variant::NIL)
+ if (p_value.get_type() == Variant::NIL) {
props.erase(p_name);
- else {
-
+ } else {
if (p_name == CoreStringNames::get_singleton()->_custom_features) {
Vector<String> custom_feature_array = String(p_value).split(",");
for (int i = 0; i < custom_feature_array.size(); i++) {
-
custom_features.insert(custom_feature_array[i]);
}
return true;
@@ -180,15 +168,15 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
}
if (override_valid) {
-
feature_overrides[s[0]] = p_name;
}
}
}
if (props.has(p_name)) {
- if (!props[p_name].overridden)
+ if (!props[p_name].overridden) {
props[p_name].variant = p_value;
+ }
} else {
props[p_name] = VariantContainer(p_value, last_order++);
@@ -197,8 +185,8 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
return true;
}
-bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
+bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
StringName name = p_name;
@@ -214,7 +202,6 @@ bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
}
struct _VCSort {
-
String name;
Variant::Type type;
int order;
@@ -224,26 +211,26 @@ struct _VCSort {
};
void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
-
_THREAD_SAFE_METHOD_
Set<_VCSort> vclist;
for (Map<StringName, VariantContainer>::Element *E = props.front(); E; E = E->next()) {
-
const VariantContainer *v = &E->get();
- if (v->hide_from_editor)
+ if (v->hide_from_editor) {
continue;
+ }
_VCSort vc;
vc.name = E->key();
vc.order = v->order;
vc.type = v->variant.get_type();
- if (vc.name.begins_with("input/") || vc.name.begins_with("import/") || vc.name.begins_with("export/") || vc.name.begins_with("/remap") || vc.name.begins_with("/locale") || vc.name.begins_with("/autoload"))
+ if (vc.name.begins_with("input/") || vc.name.begins_with("import/") || vc.name.begins_with("export/") || vc.name.begins_with("/remap") || vc.name.begins_with("/locale") || vc.name.begins_with("/autoload")) {
vc.flags = PROPERTY_USAGE_STORAGE;
- else
+ } else {
vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
+ }
if (v->restart_if_changed) {
vc.flags |= PROPERTY_USAGE_RESTART_IF_CHANGED;
@@ -252,31 +239,33 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
}
for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
-
String prop_info_name = E->get().name;
int dot = prop_info_name.find(".");
- if (dot != -1)
+ if (dot != -1) {
prop_info_name = prop_info_name.substr(0, dot);
+ }
if (custom_prop_info.has(prop_info_name)) {
PropertyInfo pi = custom_prop_info[prop_info_name];
pi.name = E->get().name;
pi.usage = E->get().flags;
p_list->push_back(pi);
- } else
+ } else {
p_list->push_back(PropertyInfo(E->get().type, E->get().name, PROPERTY_HINT_NONE, "", E->get().flags));
+ }
}
}
bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_files) {
-
- if (PackedData::get_singleton()->is_disabled())
+ if (PackedData::get_singleton()->is_disabled()) {
return false;
+ }
bool ok = PackedData::get_singleton()->add_pack(p_pack, p_replace_files) == OK;
- if (!ok)
+ if (!ok) {
return false;
+ }
//if data.pck is found, all directory access will be from here
DirAccess::make_default<DirAccessPack>(DirAccess::ACCESS_RESOURCES);
@@ -286,7 +275,6 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_f
}
void ProjectSettings::_convert_to_last_version(int p_from_version) {
-
if (p_from_version <= 3) {
// Converts the actions from array to dictionary (array of events to dictionary with deadzone + events)
for (Map<StringName, ProjectSettings::VariantContainer>::Element *E = props.front(); E; E = E->next()) {
@@ -307,10 +295,16 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) {
* using the following merit order:
* - If using NetworkClient, try to lookup project file or fail.
* - If --main-pack was passed by the user (`p_main_pack`), load it or fail.
- * - Search for .pck file matching binary name. There are two possibilities:
- * o exec_path.get_basename() + '.pck' (e.g. 'win_game.exe' -> 'win_game.pck')
- * o exec_path + '.pck' (e.g. 'linux_game' -> 'linux_game.pck')
- * For each tentative, if the file exists, load it or fail.
+ * - Search for project PCKs automatically. For each step we try loading a potential
+ * PCK, and if it doesn't work, we proceed to the next step. If any step succeeds,
+ * we try loading the project settings, and abort if it fails. Steps:
+ * o Bundled PCK in the executable.
+ * o [macOS only] PCK with same basename as the binary in the .app resource dir.
+ * o PCK with same basename as the binary in the binary's directory. We handle both
+ * changing the extension to '.pck' (e.g. 'win_game.exe' -> 'win_game.pck') and
+ * appending '.pck' to the binary name (e.g. 'linux_game' -> 'linux_game.pck').
+ * o PCK with the same basename as the binary in the current working directory.
+ * Same as above for the two possible PCK file names.
* - On relevant platforms (Android/iOS), lookup project file in OS resource path.
* If found, load it or fail.
* - Lookup project file in passed `p_path` (--path passed by the user), i.e. we
@@ -322,11 +316,9 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) {
* If nothing was found, error out.
*/
Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
-
// If looking for files in a network client, use it directly
if (FileAccessNetworkClient::get_singleton()) {
-
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
// Optional, we don't mind if it fails
@@ -338,7 +330,6 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
// Attempt with a user-defined main pack first
if (p_main_pack != "") {
-
bool ok = _load_resource_pack(p_main_pack);
ERR_FAIL_COND_V_MSG(!ok, ERR_CANT_OPEN, "Cannot open resource pack '" + p_main_pack + "'.");
@@ -354,65 +345,68 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
String exec_path = OS::get_singleton()->get_executable_path();
if (exec_path != "") {
- // Attempt with exec_name.pck
- // (This is the usual case when distributing a Godot game.)
+ // We do several tests sequentially until one succeeds to find a PCK,
+ // and if so we attempt loading it at the end.
- // Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
- // or the exec path's basename + '.pck' (Windows).
- // We need to test both possibilities as extensions for Linux binaries are optional
- // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
+ // Attempt with PCK bundled into executable.
+ bool found = _load_resource_pack(exec_path);
+ // Attempt with exec_name.pck.
+ // (This is the usual case when distributing a Godot game.)
String exec_dir = exec_path.get_base_dir();
String exec_filename = exec_path.get_file();
String exec_basename = exec_filename.get_basename();
- // Attempt with PCK bundled into executable
- bool found = _load_resource_pack(exec_path);
+ // Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
+ // or the exec path's basename + '.pck' (Windows).
+ // We need to test both possibilities as extensions for Linux binaries are optional
+ // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
#ifdef OSX_ENABLED
if (!found) {
- // Attempt to load PCK from macOS .app bundle resources
+ // Attempt to load PCK from macOS .app bundle resources.
found = _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_basename + ".pck"));
}
#endif
if (!found) {
- // Try to load data pack at the location of the executable
- // As mentioned above, we have two potential names to attempt
+ // Try to load data pack at the location of the executable.
+ // As mentioned above, we have two potential names to attempt.
found = _load_resource_pack(exec_dir.plus_file(exec_basename + ".pck")) || _load_resource_pack(exec_dir.plus_file(exec_filename + ".pck"));
+ }
- if (!found) {
- // If we couldn't find them next to the executable, we attempt
- // the current working directory. Same story, two tests.
- found = _load_resource_pack(exec_basename + ".pck") || _load_resource_pack(exec_filename + ".pck");
- }
+ if (!found) {
+ // If we couldn't find them next to the executable, we attempt
+ // the current working directory. Same story, two tests.
+ found = _load_resource_pack(exec_basename + ".pck") || _load_resource_pack(exec_filename + ".pck");
}
- // If we opened our package, try and load our project
+ // If we opened our package, try and load our project.
if (found) {
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
- // Load override from location of executable
- // Optional, we don't mind if it fails
+ // Load override from location of the executable.
+ // Optional, we don't mind if it fails.
_load_settings_text(exec_path.get_base_dir().plus_file("override.cfg"));
}
return err;
}
}
- // Try to use the filesystem for files, according to OS. (only Android -when reading from pck- and iOS use this)
+ // Try to use the filesystem for files, according to OS.
+ // (Only Android -when reading from pck- and iOS use this.)
if (OS::get_singleton()->get_resource_dir() != "") {
// OS will call ProjectSettings->get_resource_path which will be empty if not overridden!
// If the OS would rather use a specific location, then it will not be empty.
resource_path = OS::get_singleton()->get_resource_dir().replace("\\", "/");
if (resource_path != "" && resource_path[resource_path.length() - 1] == '/') {
- resource_path = resource_path.substr(0, resource_path.length() - 1); // chop end
+ resource_path = resource_path.substr(0, resource_path.length() - 1); // Chop end.
}
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
if (err == OK) {
- // Optional, we don't mind if it fails
+ // Optional, we don't mind if it fails.
_load_settings_text("res://override.cfg");
}
return err;
@@ -433,7 +427,7 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
while (true) {
err = _load_settings_text_or_binary(current_dir.plus_file("project.godot"), current_dir.plus_file("project.binary"));
if (err == OK) {
- // Optional, we don't mind if it fails
+ // Optional, we don't mind if it fails.
_load_settings_text(current_dir.plus_file("override.cfg"));
candidate = current_dir;
found = true;
@@ -443,8 +437,9 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
if (p_upwards) {
// Try to load settings ascending through parent directories
d->change_dir("..");
- if (d->get_current_dir() == current_dir)
+ if (d->get_current_dir() == current_dir) {
break; // not doing anything useful
+ }
current_dir = d->get_current_dir();
} else {
break;
@@ -452,14 +447,16 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
resource_path = candidate;
- resource_path = resource_path.replace("\\", "/"); // windows path to unix path just in case
+ resource_path = resource_path.replace("\\", "/"); // Windows path to Unix path just in case.
memdelete(d);
- if (!found)
+ if (!found) {
return err;
+ }
- if (resource_path.length() && resource_path[resource_path.length() - 1] == '/')
- resource_path = resource_path.substr(0, resource_path.length() - 1); // chop end
+ if (resource_path.length() && resource_path[resource_path.length() - 1] == '/') {
+ resource_path = resource_path.substr(0, resource_path.length() - 1); // Chop end.
+ }
return OK;
}
@@ -477,19 +474,16 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo
}
bool ProjectSettings::has_setting(String p_var) const {
-
_THREAD_SAFE_METHOD_
return props.has(p_var);
}
void ProjectSettings::set_registering_order(bool p_enable) {
-
registering_order = p_enable;
}
Error ProjectSettings::_load_settings_binary(const String &p_path) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err != OK) {
@@ -499,7 +493,6 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
uint8_t hdr[4];
f->get_buffer(hdr, 4);
if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') {
-
memdelete(f);
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Corrupted header in binary project.binary (not ECFG).");
}
@@ -507,7 +500,6 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
uint32_t count = f->get_32();
for (uint32_t i = 0; i < count; i++) {
-
uint32_t slen = f->get_32();
CharString cs;
cs.resize(slen + 1);
@@ -532,7 +524,6 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
}
Error ProjectSettings::_load_settings_text(const String &p_path) {
-
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -555,7 +546,6 @@ Error ProjectSettings::_load_settings_text(const String &p_path) {
int config_version = 0;
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -594,7 +584,6 @@ Error ProjectSettings::_load_settings_text(const String &p_path) {
}
Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path) {
-
// Attempt first to load the text-based project.godot file
Error err_text = _load_settings_text(p_text_path);
if (err_text == OK) {
@@ -611,19 +600,16 @@ Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path,
}
int ProjectSettings::get_order(const String &p_name) const {
-
ERR_FAIL_COND_V_MSG(!props.has(p_name), -1, "Request for nonexistent project setting: " + p_name + ".");
return props[p_name].order;
}
void ProjectSettings::set_order(const String &p_name, int p_order) {
-
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props[p_name].order = p_order;
}
void ProjectSettings::set_builtin_order(const String &p_name) {
-
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
if (props[p_name].order >= NO_BUILTIN_ORDER_BASE) {
props[p_name].order = last_builtin_order++;
@@ -631,18 +617,15 @@ void ProjectSettings::set_builtin_order(const String &p_name) {
}
void ProjectSettings::clear(const String &p_name) {
-
ERR_FAIL_COND_MSG(!props.has(p_name), "Request for nonexistent project setting: " + p_name + ".");
props.erase(p_name);
}
Error ProjectSettings::save() {
-
return save_custom(get_resource_path().plus_file("project.godot"));
}
Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
-
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + ".");
@@ -653,9 +636,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
int count = 0;
for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) {
-
for (List<String>::Element *F = E->get().front(); F; F = F->next()) {
-
count++;
}
}
@@ -690,33 +671,35 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
}
for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) {
-
for (List<String>::Element *F = E->get().front(); F; F = F->next()) {
-
String key = F->get();
- if (E->key() != "")
+ if (E->key() != "") {
key = E->key() + "/" + key;
+ }
Variant value;
- if (p_custom.has(key))
+ if (p_custom.has(key)) {
value = p_custom[key];
- else
+ } else {
value = get(key);
+ }
file->store_32(key.length());
file->store_string(key);
int len;
err = encode_variant(value, nullptr, len, true);
- if (err != OK)
+ if (err != OK) {
memdelete(file);
+ }
ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Error when trying to encode Variant.");
Vector<uint8_t> buff;
buff.resize(len);
err = encode_variant(value, buff.ptrw(), len, true);
- if (err != OK)
+ if (err != OK) {
memdelete(file);
+ }
ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Error when trying to encode Variant.");
file->store_32(len);
file->store_buffer(buff.ptr(), buff.size());
@@ -730,7 +713,6 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
}
Error ProjectSettings::_save_settings_text(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
-
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
@@ -746,27 +728,30 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
file->store_line("");
file->store_string("config_version=" + itos(CONFIG_VERSION) + "\n");
- if (p_custom_features != String())
+ if (p_custom_features != String()) {
file->store_string("custom_features=\"" + p_custom_features + "\"\n");
+ }
file->store_string("\n");
for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) {
-
- if (E != props.front())
+ if (E != props.front()) {
file->store_string("\n");
+ }
- if (E->key() != "")
+ if (E->key() != "") {
file->store_string("[" + E->key() + "]\n\n");
+ }
for (List<String>::Element *F = E->get().front(); F; F = F->next()) {
-
String key = F->get();
- if (E->key() != "")
+ if (E->key() != "") {
key = E->key() + "/" + key;
+ }
Variant value;
- if (p_custom.has(key))
+ if (p_custom.has(key)) {
value = p_custom[key];
- else
+ } else {
value = get(key);
+ }
String vstr;
VariantWriter::write_to_string(value, vstr);
@@ -783,39 +768,39 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array?
return save_custom(p_file);
-};
+}
Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector<String> &p_custom_features, bool p_merge_with_current) {
-
ERR_FAIL_COND_V_MSG(p_path == "", ERR_INVALID_PARAMETER, "Project settings save path cannot be empty.");
Set<_VCSort> vclist;
if (p_merge_with_current) {
for (Map<StringName, VariantContainer>::Element *G = props.front(); G; G = G->next()) {
-
const VariantContainer *v = &G->get();
- if (v->hide_from_editor)
+ if (v->hide_from_editor) {
continue;
+ }
- if (p_custom.has(G->key()))
+ if (p_custom.has(G->key())) {
continue;
+ }
_VCSort vc;
vc.name = G->key(); //*k;
vc.order = v->order;
vc.type = v->variant.get_type();
vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
- if (v->variant == v->initial)
+ if (v->variant == v->initial) {
continue;
+ }
vclist.insert(vc);
}
}
for (const Map<String, Variant>::Element *E = p_custom.front(); E; E = E->next()) {
-
// Lookup global prop to store in the same order
Map<StringName, VariantContainer>::Element *global_prop = props.find(E->key());
@@ -830,16 +815,14 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
Map<String, List<String>> props;
for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
-
String category = E->get().name;
String name = E->get().name;
int div = category.find("/");
- if (div < 0)
+ if (div < 0) {
category = "";
- else {
-
+ } else {
category = category.substr(0, div);
name = name.substr(div + 1, name.size());
}
@@ -849,25 +832,24 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
String custom_features;
for (int i = 0; i < p_custom_features.size(); i++) {
- if (i > 0)
+ if (i > 0) {
custom_features += ",";
+ }
String f = p_custom_features[i].strip_edges().replace("\"", "");
custom_features += f;
}
- if (p_path.ends_with(".godot"))
+ if (p_path.ends_with(".godot")) {
return _save_settings_text(p_path, props, p_custom, custom_features);
- else if (p_path.ends_with(".binary"))
+ } else if (p_path.ends_with(".binary")) {
return _save_settings_binary(p_path, props, p_custom, custom_features);
- else {
-
+ } else {
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown config file format: " + p_path + ".");
}
}
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed) {
-
Variant ret;
if (!ProjectSettings::get_singleton()->has_setting(p_var)) {
ProjectSettings::get_singleton()->set(p_var, p_default);
@@ -881,15 +863,14 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restar
}
Vector<String> ProjectSettings::get_optimizer_presets() const {
-
List<PropertyInfo> pi;
ProjectSettings::get_singleton()->get_property_list(&pi);
Vector<String> names;
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
-
- if (!E->get().name.begins_with("optimizer_presets/"))
+ if (!E->get().name.begins_with("optimizer_presets/")) {
continue;
+ }
names.push_back(E->get().name.get_slicec('/', 1));
}
@@ -899,7 +880,6 @@ Vector<String> ProjectSettings::get_optimizer_presets() const {
}
void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) {
-
ERR_FAIL_COND(!p_info.has("name"));
ERR_FAIL_COND(!p_info.has("type"));
@@ -909,16 +889,17 @@ void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) {
pinfo.type = Variant::Type(p_info["type"].operator int());
ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
- if (p_info.has("hint"))
+ if (p_info.has("hint")) {
pinfo.hint = PropertyHint(p_info["hint"].operator int());
- if (p_info.has("hint_string"))
+ }
+ if (p_info.has("hint_string")) {
pinfo.hint_string = p_info["hint_string"];
+ }
set_custom_property_info(pinfo.name, pinfo);
}
void ProjectSettings::set_custom_property_info(const String &p_prop, const PropertyInfo &p_info) {
-
ERR_FAIL_COND(!props.has(p_prop));
custom_prop_info[p_prop] = p_info;
custom_prop_info[p_prop].name = p_prop;
@@ -929,27 +910,25 @@ const Map<StringName, PropertyInfo> &ProjectSettings::get_custom_property_info()
}
void ProjectSettings::set_disable_feature_overrides(bool p_disable) {
-
disable_feature_overrides = p_disable;
}
bool ProjectSettings::is_using_datapack() const {
-
return using_datapack;
}
bool ProjectSettings::property_can_revert(const String &p_name) {
-
- if (!props.has(p_name))
+ if (!props.has(p_name)) {
return false;
+ }
return props[p_name].initial != props[p_name].variant;
}
Variant ProjectSettings::property_get_revert(const String &p_name) {
-
- if (!props.has(p_name))
+ if (!props.has(p_name)) {
return Variant();
+ }
return props[p_name].initial;
}
@@ -967,7 +946,6 @@ bool ProjectSettings::has_custom_feature(const String &p_feature) const {
}
void ProjectSettings::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("has_setting", "name"), &ProjectSettings::has_setting);
ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &ProjectSettings::set_setting);
ClassDB::bind_method(D_METHOD("get_setting", "name"), &ProjectSettings::get_setting);
@@ -987,12 +965,7 @@ void ProjectSettings::_bind_methods() {
}
ProjectSettings::ProjectSettings() {
-
singleton = this;
- last_order = NO_BUILTIN_ORDER_BASE;
- last_builtin_order = 0;
- disable_feature_overrides = false;
- registering_order = true;
Array events;
Dictionary action;
@@ -1014,8 +987,9 @@ ProjectSettings::ProjectSettings() {
PackedStringArray extensions = PackedStringArray();
extensions.push_back("gd");
- if (Engine::get_singleton()->has_singleton("GodotSharp"))
+ if (Engine::get_singleton()->has_singleton("GodotSharp")) {
extensions.push_back("cs");
+ }
extensions.push_back("shader");
GLOBAL_DEF("editor/search_in_file_extensions", extensions);
@@ -1203,11 +1177,8 @@ ProjectSettings::ProjectSettings() {
Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION);
custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
-
- using_datapack = false;
}
ProjectSettings::~ProjectSettings() {
-
singleton = nullptr;
}
diff --git a/core/project_settings.h b/core/project_settings.h
index 7b3ca18c62..3ed80738a1 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -36,7 +36,6 @@
#include "core/set.h"
class ProjectSettings : public Object {
-
GDCLASS(ProjectSettings, Object);
_THREAD_SAFE_CLASS_
@@ -50,38 +49,31 @@ public:
protected:
struct VariantContainer {
- int order;
- bool persist;
+ int order = 0;
+ bool persist = false;
Variant variant;
Variant initial;
- bool hide_from_editor;
- bool overridden;
- bool restart_if_changed;
- VariantContainer() :
- order(0),
- persist(false),
- hide_from_editor(false),
- overridden(false),
- restart_if_changed(false) {
- }
+ bool hide_from_editor = false;
+ bool overridden = false;
+ bool restart_if_changed = false;
+
+ VariantContainer() {}
+
VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) :
order(p_order),
persist(p_persist),
- variant(p_variant),
- hide_from_editor(false),
- overridden(false),
- restart_if_changed(false) {
+ variant(p_variant) {
}
};
- bool registering_order;
- int last_order;
- int last_builtin_order;
+ bool registering_order = true;
+ int last_order = 0;
+ int last_builtin_order = NO_BUILTIN_ORDER_BASE;
Map<StringName, VariantContainer> props;
String resource_path;
Map<StringName, PropertyInfo> custom_prop_info;
- bool disable_feature_overrides;
- bool using_datapack;
+ bool disable_feature_overrides = false;
+ bool using_datapack = false;
List<String> input_presets;
Set<String> custom_features;
diff --git a/core/reference.cpp b/core/reference.cpp
index dd65ccce69..d1dba0d9bf 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -33,22 +33,18 @@
#include "core/script_language.h"
bool Reference::init_ref() {
-
if (reference()) {
-
if (!is_referenced() && refcount_init.unref()) {
unreference(); // first referencing is already 1, so compensate for the ref above
}
return true;
} else {
-
return false;
}
}
void Reference::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("init_ref"), &Reference::init_ref);
ClassDB::bind_method(D_METHOD("reference"), &Reference::reference);
ClassDB::bind_method(D_METHOD("unreference"), &Reference::unreference);
@@ -59,7 +55,6 @@ int Reference::reference_get_count() const {
}
bool Reference::reference() {
-
uint32_t rc_val = refcount.refval();
bool success = rc_val != 0;
@@ -80,7 +75,6 @@ bool Reference::reference() {
}
bool Reference::unreference() {
-
uint32_t rc_val = refcount.unrefval();
bool die = rc_val == 0;
@@ -104,25 +98,21 @@ bool Reference::unreference() {
Reference::Reference() :
Object(true) {
-
refcount.init();
refcount_init.init();
}
-Reference::~Reference() {
-}
-
Variant WeakRef::get_ref() const {
-
- if (ref.is_null())
+ if (ref.is_null()) {
return Variant();
+ }
Object *obj = ObjectDB::get_instance(ref);
- if (!obj)
+ if (!obj) {
return Variant();
+ }
Reference *r = cast_to<Reference>(obj);
if (r) {
-
return REF(r);
}
@@ -134,14 +124,9 @@ void WeakRef::set_obj(Object *p_object) {
}
void WeakRef::set_ref(const REF &p_ref) {
-
ref = p_ref.is_valid() ? p_ref->get_instance_id() : ObjectID();
}
-WeakRef::WeakRef() {
-}
-
void WeakRef::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_ref"), &WeakRef::get_ref);
}
diff --git a/core/reference.h b/core/reference.h
index 30a93d82a6..f5794b0b67 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -36,7 +36,6 @@
#include "core/safe_refcount.h"
class Reference : public Object {
-
GDCLASS(Reference, Object);
SafeRefCount refcount;
SafeRefCount refcount_init;
@@ -52,32 +51,32 @@ public:
int reference_get_count() const;
Reference();
- ~Reference();
+ ~Reference() {}
};
template <class T>
class Ref {
-
- T *reference;
+ T *reference = nullptr;
void ref(const Ref &p_from) {
-
- if (p_from.reference == reference)
+ if (p_from.reference == reference) {
return;
+ }
unref();
reference = p_from.reference;
- if (reference)
+ if (reference) {
reference->reference();
+ }
}
void ref_pointer(T *p_ref) {
-
ERR_FAIL_COND(!p_ref);
- if (p_ref->init_ref())
+ if (p_ref->init_ref()) {
reference = p_ref;
+ }
}
//virtual Reference * get_reference() const { return reference; }
@@ -90,60 +89,48 @@ public:
}
_FORCE_INLINE_ bool operator<(const Ref<T> &p_r) const {
-
return reference < p_r.reference;
}
_FORCE_INLINE_ bool operator==(const Ref<T> &p_r) const {
-
return reference == p_r.reference;
}
_FORCE_INLINE_ bool operator!=(const Ref<T> &p_r) const {
-
return reference != p_r.reference;
}
_FORCE_INLINE_ T *operator->() {
-
return reference;
}
_FORCE_INLINE_ T *operator*() {
-
return reference;
}
_FORCE_INLINE_ const T *operator->() const {
-
return reference;
}
_FORCE_INLINE_ const T *ptr() const {
-
return reference;
}
_FORCE_INLINE_ T *ptr() {
-
return reference;
}
_FORCE_INLINE_ const T *operator*() const {
-
return reference;
}
operator Variant() const {
-
return Variant(reference);
}
void operator=(const Ref &p_from) {
-
ref(p_from);
}
template <class T_Other>
void operator=(const Ref<T_Other> &p_from) {
-
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr()));
if (!refb) {
unref();
@@ -156,7 +143,6 @@ public:
}
void operator=(const Variant &p_variant) {
-
Object *object = p_variant.get_validated_object();
if (object == reference) {
@@ -189,15 +175,11 @@ public:
}
Ref(const Ref &p_from) {
-
- reference = nullptr;
ref(p_from);
}
template <class T_Other>
Ref(const Ref<T_Other> &p_from) {
-
- reference = nullptr;
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr()));
if (!refb) {
unref();
@@ -210,26 +192,21 @@ public:
}
Ref(T *p_reference) {
-
- reference = nullptr;
- if (p_reference)
+ if (p_reference) {
ref_pointer(p_reference);
+ }
}
Ref(const Variant &p_variant) {
-
Object *object = p_variant.get_validated_object();
if (!object) {
- reference = nullptr;
return;
}
T *r = Object::cast_to<T>(object);
if (r && r->reference()) {
reference = r;
- } else {
- reference = nullptr;
}
}
@@ -242,7 +219,6 @@ public:
// mutexes will avoid more crashes?
if (reference && reference->unreference()) {
-
memdelete(reference);
}
reference = nullptr;
@@ -252,13 +228,9 @@ public:
ref(memnew(T));
}
- Ref() {
-
- reference = nullptr;
- }
+ Ref() {}
~Ref() {
-
unref();
}
};
@@ -266,7 +238,6 @@ public:
typedef Ref<Reference> REF;
class WeakRef : public Reference {
-
GDCLASS(WeakRef, Reference);
ObjectID ref;
@@ -279,30 +250,25 @@ public:
void set_obj(Object *p_object);
void set_ref(const REF &p_ref);
- WeakRef();
+ WeakRef() {}
};
#ifdef PTRCALL_ENABLED
template <class T>
struct PtrToArg<Ref<T>> {
-
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
-
return Ref<T>(const_cast<T *>(reinterpret_cast<const T *>(p_ptr)));
}
_FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) {
-
*(Ref<Reference> *)p_ptr = p_val;
}
};
template <class T>
struct PtrToArg<const Ref<T> &> {
-
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
-
return Ref<T>((T *)p_ptr);
}
};
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 4cf7e45205..c0f9eea76d 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -60,12 +60,12 @@
#include "core/io/xml_parser.h"
#include "core/math/a_star.h"
#include "core/math/expression.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
+#include "core/math/geometry_3d.h"
#include "core/math/random_number_generator.h"
#include "core/math/triangle_mesh.h"
#include "core/os/main_loop.h"
#include "core/packed_data_container.h"
-#include "core/path_remap.h"
#include "core/project_settings.h"
#include "core/translation.h"
#include "core/undo_redo.h"
@@ -88,7 +88,8 @@ static _JSON *_json = nullptr;
static IP *ip = nullptr;
-static _Geometry *_geometry = nullptr;
+static _Geometry2D *_geometry_2d = nullptr;
+static _Geometry3D *_geometry_3d = nullptr;
extern Mutex _global_mutex;
@@ -98,7 +99,6 @@ extern void register_variant_methods();
extern void unregister_variant_methods();
void register_core_types() {
-
//consistency check
static_assert(sizeof(Callable) <= 16);
@@ -215,7 +215,8 @@ void register_core_types() {
ip = IP::create();
- _geometry = memnew(_Geometry);
+ _geometry_2d = memnew(_Geometry2D);
+ _geometry_3d = memnew(_Geometry3D);
_resource_loader = memnew(_ResourceLoader);
_resource_saver = memnew(_ResourceSaver);
@@ -238,10 +239,10 @@ void register_core_settings() {
}
void register_core_singletons() {
-
ClassDB::register_class<ProjectSettings>();
ClassDB::register_virtual_class<IP>();
- ClassDB::register_class<_Geometry>();
+ ClassDB::register_class<_Geometry2D>();
+ ClassDB::register_class<_Geometry3D>();
ClassDB::register_class<_ResourceLoader>();
ClassDB::register_class<_ResourceSaver>();
ClassDB::register_class<_OS>();
@@ -256,7 +257,8 @@ void register_core_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry", _Geometry::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry2D", _Geometry2D::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry3D", _Geometry3D::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("OS", _OS::get_singleton()));
@@ -270,7 +272,6 @@ void register_core_singletons() {
}
void unregister_core_types() {
-
memdelete(_resource_loader);
memdelete(_resource_saver);
memdelete(_os);
@@ -279,7 +280,8 @@ void unregister_core_types() {
memdelete(_marshalls);
memdelete(_json);
- memdelete(_geometry);
+ memdelete(_geometry_2d);
+ memdelete(_geometry_3d);
ResourceLoader::remove_resource_format_loader(resource_format_image);
resource_format_image.unref();
@@ -301,8 +303,9 @@ void unregister_core_types() {
ResourceLoader::remove_resource_format_loader(resource_format_loader_crypto);
resource_format_loader_crypto.unref();
- if (ip)
+ if (ip) {
memdelete(ip);
+ }
ResourceLoader::finalize();
diff --git a/core/resource.cpp b/core/resource.cpp
index 8d5c441b21..3b589793ef 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -33,13 +33,13 @@
#include "core/core_string_names.h"
#include "core/io/resource_loader.h"
#include "core/os/file_access.h"
+#include "core/os/os.h"
#include "core/script_language.h"
#include "scene/main/node.h" //only so casting works
#include <stdio.h>
void Resource::emit_changed() {
-
emit_signal(CoreStringNames::get_singleton()->changed);
}
@@ -47,12 +47,11 @@ void Resource::_resource_path_changed() {
}
void Resource::set_path(const String &p_path, bool p_take_over) {
-
- if (path_cache == p_path)
+ if (path_cache == p_path) {
return;
+ }
if (path_cache != "") {
-
ResourceCache::lock->write_lock();
ResourceCache::resources.erase(path_cache);
ResourceCache::lock->write_unlock();
@@ -66,7 +65,6 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
if (has_path) {
if (p_take_over) {
-
ResourceCache::lock->write_lock();
Resource **res = ResourceCache::resources.getptr(p_path);
if (res) {
@@ -84,7 +82,6 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
path_cache = p_path;
if (path_cache != "") {
-
ResourceCache::lock->write_lock();
ResourceCache::resources[path_cache] = this;
ResourceCache::lock->write_unlock();
@@ -95,62 +92,58 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
}
String Resource::get_path() const {
-
return path_cache;
}
void Resource::set_subindex(int p_sub_index) {
-
subindex = p_sub_index;
}
int Resource::get_subindex() const {
-
return subindex;
}
void Resource::set_name(const String &p_name) {
-
name = p_name;
_change_notify("resource_name");
}
-String Resource::get_name() const {
+String Resource::get_name() const {
return name;
}
bool Resource::editor_can_reload_from_file() {
-
return true; //by default yes
}
void Resource::reload_from_file() {
-
String path = get_path();
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
Ref<Resource> s = ResourceLoader::load(ResourceLoader::path_remap(path), get_class(), true);
- if (!s.is_valid())
+ if (!s.is_valid()) {
return;
+ }
List<PropertyInfo> pi;
s->get_property_list(&pi);
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
- if (E->get().name == "resource_path")
+ }
+ if (E->get().name == "resource_path") {
continue; //do not change path
+ }
set(E->get().name, s->get(E->get().name));
}
}
Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource>> &remap_cache) {
-
List<PropertyInfo> plist;
get_property_list(&plist);
@@ -160,20 +153,17 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
r->local_scene = p_for_scene;
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
Variant p = get(E->get().name);
if (p.get_type() == Variant::OBJECT) {
-
RES sr = p;
if (sr.is_valid()) {
-
if (sr->is_local_to_scene()) {
if (remap_cache.has(sr)) {
p = remap_cache[sr];
} else {
-
RES dupe = sr->duplicate_for_local_scene(p_for_scene, remap_cache);
p = dupe;
remap_cache[sr] = dupe;
@@ -191,22 +181,19 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
}
void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource>> &remap_cache) {
-
List<PropertyInfo> plist;
get_property_list(&plist);
local_scene = p_for_scene;
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
Variant p = get(E->get().name);
if (p.get_type() == Variant::OBJECT) {
-
RES sr = p;
if (sr.is_valid()) {
-
if (sr->is_local_to_scene()) {
if (!remap_cache.has(sr)) {
sr->configure_for_local_scene(p_for_scene, remap_cache);
@@ -219,7 +206,6 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, R
}
Ref<Resource> Resource::duplicate(bool p_subresources) const {
-
List<PropertyInfo> plist;
get_property_list(&plist);
@@ -227,21 +213,19 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
ERR_FAIL_COND_V(!r, Ref<Resource>());
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
Variant p = get(E->get().name);
if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) {
r->set(E->get().name, p.duplicate(p_subresources));
} else if (p.get_type() == Variant::OBJECT && (p_subresources || (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) {
-
RES sr = p;
if (sr.is_valid()) {
r->set(E->get().name, sr->duplicate(p_subresources));
}
} else {
-
r->set(E->get().name, p);
}
}
@@ -250,34 +234,27 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
}
void Resource::_set_path(const String &p_path) {
-
set_path(p_path, false);
}
void Resource::_take_over_path(const String &p_path) {
-
set_path(p_path, true);
}
RID Resource::get_rid() const {
-
return RID();
}
void Resource::register_owner(Object *p_owner) {
-
owners.insert(p_owner->get_instance_id());
}
void Resource::unregister_owner(Object *p_owner) {
-
owners.erase(p_owner->get_instance_id());
}
void Resource::notify_change_to_owners() {
-
for (Set<ObjectID>::Element *E = owners.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf
//TODO store string
@@ -288,14 +265,12 @@ void Resource::notify_change_to_owners() {
#ifdef TOOLS_ENABLED
uint32_t Resource::hash_edited_version() const {
-
uint32_t hash = hash_djb2_one_32(get_edited_version());
List<PropertyInfo> plist;
get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_STORAGE && E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) {
RES res = get(E->get().name);
if (res.is_valid()) {
@@ -310,19 +285,17 @@ uint32_t Resource::hash_edited_version() const {
#endif
void Resource::set_local_to_scene(bool p_enable) {
-
local_to_scene = p_enable;
}
bool Resource::is_local_to_scene() const {
-
return local_to_scene;
}
Node *Resource::get_local_scene() const {
-
- if (local_scene)
+ if (local_scene) {
return local_scene;
+ }
if (_get_local_scene_func) {
return _get_local_scene_func();
@@ -332,17 +305,17 @@ Node *Resource::get_local_scene() const {
}
void Resource::setup_local_to_scene() {
-
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("_setup_local_to_scene");
+ }
}
Node *(*Resource::_get_local_scene_func)() = nullptr;
void Resource::set_as_translation_remapped(bool p_remapped) {
-
- if (remapped_list.in_list() == p_remapped)
+ if (remapped_list.in_list() == p_remapped) {
return;
+ }
if (ResourceCache::lock) {
ResourceCache::lock->write_lock();
@@ -360,7 +333,6 @@ void Resource::set_as_translation_remapped(bool p_remapped) {
}
bool Resource::is_translation_remapped() const {
-
return remapped_list.in_list();
}
@@ -406,7 +378,6 @@ int Resource::get_id_for_path(const String &p_path) const {
#endif
void Resource::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_path", "path"), &Resource::_set_path);
ClassDB::bind_method(D_METHOD("take_over_path", "path"), &Resource::_take_over_path);
ClassDB::bind_method(D_METHOD("get_path"), &Resource::get_path);
@@ -429,20 +400,9 @@ void Resource::_bind_methods() {
}
Resource::Resource() :
- remapped_list(this) {
-
-#ifdef TOOLS_ENABLED
- last_modified_time = 0;
- import_last_modified_time = 0;
-#endif
-
- subindex = 0;
- local_to_scene = false;
- local_scene = nullptr;
-}
+ remapped_list(this) {}
Resource::~Resource() {
-
if (path_cache != "") {
ResourceCache::lock->write_lock();
ResourceCache::resources.erase(path_cache);
@@ -464,7 +424,6 @@ RWLock *ResourceCache::path_cache_lock = nullptr;
#endif
void ResourceCache::setup() {
-
lock = RWLock::create();
#ifdef TOOLS_ENABLED
path_cache_lock = RWLock::create();
@@ -472,8 +431,16 @@ void ResourceCache::setup() {
}
void ResourceCache::clear() {
- if (resources.size())
- ERR_PRINT("Resources Still in use at Exit!");
+ if (resources.size()) {
+ ERR_PRINT("Resources still in use at exit (run with --verbose for details).");
+ if (OS::get_singleton()->is_stdout_verbose()) {
+ const String *K = nullptr;
+ while ((K = resources.next(K))) {
+ Resource *r = resources[*K];
+ print_line(vformat("Resource still in use: %s (%s)", *K, r->get_class()));
+ }
+ }
+ }
resources.clear();
memdelete(lock);
@@ -483,25 +450,17 @@ void ResourceCache::clear() {
}
void ResourceCache::reload_externals() {
-
- /*
- const String *K=nullptr;
- while ((K=resources.next(K))) {
- resources[*K]->reload_external_data();
- }
- */
}
bool ResourceCache::has(const String &p_path) {
-
lock->read_lock();
bool b = resources.has(p_path);
lock->read_unlock();
return b;
}
-Resource *ResourceCache::get(const String &p_path) {
+Resource *ResourceCache::get(const String &p_path) {
lock->read_lock();
Resource **res = resources.getptr(p_path);
@@ -516,11 +475,9 @@ Resource *ResourceCache::get(const String &p_path) {
}
void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) {
-
lock->read_lock();
const String *K = nullptr;
while ((K = resources.next(K))) {
-
Resource *r = resources[*K];
p_resources->push_back(Ref<Resource>(r));
}
@@ -528,7 +485,6 @@ void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) {
}
int ResourceCache::get_cached_resource_count() {
-
lock->read_lock();
int rc = resources.size();
lock->read_unlock();
@@ -550,7 +506,6 @@ void ResourceCache::dump(const char *p_file, bool p_short) {
const String *K = nullptr;
while ((K = resources.next(K))) {
-
Resource *r = resources[*K];
if (!type_count.has(r->get_class())) {
@@ -560,15 +515,16 @@ void ResourceCache::dump(const char *p_file, bool p_short) {
type_count[r->get_class()]++;
if (!p_short) {
- if (f)
+ if (f) {
f->store_line(r->get_class() + ": " + r->get_path());
+ }
}
}
for (Map<String, int>::Element *E = type_count.front(); E; E = E->next()) {
-
- if (f)
+ if (f) {
f->store_line(E->key() + " count: " + itos(E->get()));
+ }
}
if (f) {
f->close();
@@ -576,6 +532,5 @@ void ResourceCache::dump(const char *p_file, bool p_short) {
}
lock->read_unlock();
-
#endif
}
diff --git a/core/resource.h b/core/resource.h
index 3b7812c870..ad2f3ce913 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -45,7 +45,6 @@ public:
private:
class Resource : public Reference {
-
GDCLASS(Resource, Reference);
OBJ_CATEGORY("Resources");
RES_BASE_EXTENSION("res");
@@ -57,19 +56,19 @@ class Resource : public Reference {
String name;
String path_cache;
- int subindex;
+ int subindex = 0;
virtual bool _use_builtin_script() const { return true; }
#ifdef TOOLS_ENABLED
- uint64_t last_modified_time;
- uint64_t import_last_modified_time;
+ uint64_t last_modified_time = 0;
+ uint64_t import_last_modified_time = 0;
String import_path;
#endif
- bool local_to_scene;
+ bool local_to_scene = false;
friend class SceneState;
- Node *local_scene;
+ Node *local_scene = nullptr;
SelfList<Resource> remapped_list;
diff --git a/core/rid.h b/core/rid.h
index a2f73423a3..4b65f3fb6a 100644
--- a/core/rid.h
+++ b/core/rid.h
@@ -37,27 +37,22 @@ class RID_AllocBase;
class RID {
friend class RID_AllocBase;
- uint64_t _id;
+ uint64_t _id = 0;
public:
_FORCE_INLINE_ bool operator==(const RID &p_rid) const {
-
return _id == p_rid._id;
}
_FORCE_INLINE_ bool operator<(const RID &p_rid) const {
-
return _id < p_rid._id;
}
_FORCE_INLINE_ bool operator<=(const RID &p_rid) const {
-
return _id <= p_rid._id;
}
_FORCE_INLINE_ bool operator>(const RID &p_rid) const {
-
return _id > p_rid._id;
}
_FORCE_INLINE_ bool operator!=(const RID &p_rid) const {
-
return _id != p_rid._id;
}
_FORCE_INLINE_ bool is_valid() const { return _id != 0; }
@@ -65,9 +60,7 @@ public:
_FORCE_INLINE_ uint64_t get_id() const { return _id; }
- _FORCE_INLINE_ RID() {
- _id = 0;
- }
+ _FORCE_INLINE_ RID() {}
};
#endif // RID_H
diff --git a/core/rid_owner.h b/core/rid_owner.h
index ad6996b9a7..2489475c68 100644
--- a/core/rid_owner.h
+++ b/core/rid_owner.h
@@ -39,11 +39,11 @@
#include "core/safe_refcount.h"
#include "core/set.h"
#include "core/spin_lock.h"
+
#include <stdio.h>
#include <typeinfo>
class RID_AllocBase {
-
static volatile uint64_t base_id;
protected:
@@ -67,22 +67,20 @@ public:
template <class T, bool THREAD_SAFE = false>
class RID_Alloc : public RID_AllocBase {
-
- T **chunks;
- uint32_t **free_list_chunks;
- uint32_t **validator_chunks;
+ T **chunks = nullptr;
+ uint32_t **free_list_chunks = nullptr;
+ uint32_t **validator_chunks = nullptr;
uint32_t elements_in_chunk;
- uint32_t max_alloc;
- uint32_t alloc_count;
+ uint32_t max_alloc = 0;
+ uint32_t alloc_count = 0;
- const char *description;
+ const char *description = nullptr;
SpinLock spin_lock;
public:
RID make_rid(const T &p_value) {
-
if (THREAD_SAFE) {
spin_lock.lock();
}
@@ -136,7 +134,6 @@ public:
}
_FORCE_INLINE_ T *getornull(const RID &p_rid) {
-
if (THREAD_SAFE) {
spin_lock.lock();
}
@@ -171,7 +168,6 @@ public:
}
_FORCE_INLINE_ bool owns(const RID &p_rid) {
-
if (THREAD_SAFE) {
spin_lock.lock();
}
@@ -200,7 +196,6 @@ public:
}
_FORCE_INLINE_ void free(const RID &p_rid) {
-
if (THREAD_SAFE) {
spin_lock.lock();
}
@@ -288,14 +283,7 @@ public:
}
RID_Alloc(uint32_t p_target_chunk_byte_size = 4096) {
- chunks = nullptr;
- free_list_chunks = nullptr;
- validator_chunks = nullptr;
-
elements_in_chunk = sizeof(T) > p_target_chunk_byte_size ? 1 : (p_target_chunk_byte_size / sizeof(T));
- max_alloc = 0;
- alloc_count = 0;
- description = nullptr;
}
~RID_Alloc() {
@@ -412,4 +400,5 @@ public:
RID_Owner(uint32_t p_target_chunk_byte_size = 4096) :
alloc(p_target_chunk_byte_size) {}
};
+
#endif // RID_OWNER_H
diff --git a/core/ring_buffer.h b/core/ring_buffer.h
index 620a3a3846..6b71d12cf3 100644
--- a/core/ring_buffer.h
+++ b/core/ring_buffer.h
@@ -35,10 +35,9 @@
template <typename T>
class RingBuffer {
-
Vector<T> data;
- int read_pos;
- int write_pos;
+ int read_pos = 0;
+ int write_pos = 0;
int size_mask;
inline int inc(int &p_var, int p_size) const {
@@ -46,13 +45,13 @@ class RingBuffer {
p_var += p_size;
p_var = p_var & size_mask;
return ret;
- };
+ }
public:
T read() {
ERR_FAIL_COND_V(space_left() < 1, T());
return data.ptr()[inc(read_pos, 1)];
- };
+ }
int read(T *p_buf, int p_size, bool p_advance = true) {
int left = data_left();
@@ -67,23 +66,23 @@ public:
const T *read = data.ptr();
for (int i = 0; i < total; i++) {
p_buf[dst++] = read[pos + i];
- };
+ }
to_read -= total;
pos = 0;
- };
+ }
if (p_advance) {
inc(read_pos, p_size);
- };
+ }
return p_size;
- };
+ }
int copy(T *p_buf, int p_offset, int p_size) const {
-
int left = data_left();
if ((p_offset + p_size) > left) {
p_size -= left - p_offset;
- if (p_size <= 0)
+ if (p_size <= 0) {
return 0;
+ }
}
p_size = MIN(left, p_size);
int pos = read_pos;
@@ -96,20 +95,20 @@ public:
int total = end - pos;
for (int i = 0; i < total; i++) {
p_buf[dst++] = data[pos + i];
- };
+ }
to_read -= total;
pos = 0;
- };
+ }
return p_size;
- };
+ }
int find(const T &t, int p_offset, int p_max_size) const {
-
int left = data_left();
if ((p_offset + p_max_size) > left) {
p_max_size -= left - p_offset;
- if (p_max_size <= 0)
+ if (p_max_size <= 0) {
return 0;
+ }
}
p_max_size = MIN(left, p_max_size);
int pos = read_pos;
@@ -120,9 +119,10 @@ public:
end = MIN(end, size());
int total = end - pos;
for (int i = 0; i < total; i++) {
- if (data[pos + i] == t)
+ if (data[pos + i] == t) {
return i + (p_max_size - to_read);
- };
+ }
+ }
to_read -= total;
pos = 0;
}
@@ -133,7 +133,7 @@ public:
p_n = MIN(p_n, data_left());
inc(read_pos, p_n);
return p_n;
- };
+ }
inline int decrease_write(int p_n) {
p_n = MIN(p_n, data_left());
@@ -145,10 +145,9 @@ public:
ERR_FAIL_COND_V(space_left() < 1, FAILED);
data.write[inc(write_pos, 1)] = p_v;
return OK;
- };
+ }
int write(const T *p_buf, int p_size) {
-
int left = space_left();
p_size = MIN(left, p_size);
@@ -156,39 +155,38 @@ public:
int to_write = p_size;
int src = 0;
while (to_write) {
-
int end = pos + to_write;
end = MIN(end, size());
int total = end - pos;
for (int i = 0; i < total; i++) {
data.write[pos + i] = p_buf[src++];
- };
+ }
to_write -= total;
pos = 0;
- };
+ }
inc(write_pos, p_size);
return p_size;
- };
+ }
inline int space_left() const {
int left = read_pos - write_pos;
if (left < 0) {
return size() + left - 1;
- };
+ }
if (left == 0) {
return size() - 1;
- };
+ }
return left - 1;
- };
+ }
inline int data_left() const {
return size() - space_left() - 1;
- };
+ }
inline int size() const {
return data.size();
- };
+ }
inline void clear() {
read_pos = 0;
@@ -203,22 +201,20 @@ public:
if (old_size < new_size && read_pos > write_pos) {
for (int i = 0; i < write_pos; i++) {
data.write[(old_size + i) & mask] = data[i];
- };
+ }
write_pos = (old_size + write_pos) & mask;
} else {
read_pos = read_pos & mask;
write_pos = write_pos & mask;
- };
+ }
size_mask = mask;
- };
+ }
RingBuffer<T>(int p_power = 0) {
- read_pos = 0;
- write_pos = 0;
resize(p_power);
- };
- ~RingBuffer<T>(){};
+ }
+ ~RingBuffer<T>() {}
};
#endif // RING_BUFFER_H
diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp
index e4604faa09..d5ee778ef7 100644
--- a/core/safe_refcount.cpp
+++ b/core/safe_refcount.cpp
@@ -42,79 +42,71 @@
/* taken from boost */ \
while (true) { \
m_cpp_type tmp = static_cast<m_cpp_type const volatile &>(*(m_pw)); \
- if (tmp == 0) \
+ if (tmp == 0) { \
return 0; /* if zero, can't add to it anymore */ \
- if (m_win_cmpxchg((m_win_type volatile *)(m_pw), tmp + 1, tmp) == tmp) \
+ } \
+ if (m_win_cmpxchg((m_win_type volatile *)(m_pw), tmp + 1, tmp) == tmp) { \
return tmp + 1; \
+ } \
}
#define ATOMIC_EXCHANGE_IF_GREATER_BODY(m_pw, m_val, m_win_type, m_win_cmpxchg, m_cpp_type) \
while (true) { \
m_cpp_type tmp = static_cast<m_cpp_type const volatile &>(*(m_pw)); \
- if (tmp >= m_val) \
+ if (tmp >= m_val) { \
return tmp; /* already greater, or equal */ \
- if (m_win_cmpxchg((m_win_type volatile *)(m_pw), m_val, tmp) == tmp) \
+ } \
+ if (m_win_cmpxchg((m_win_type volatile *)(m_pw), m_val, tmp) == tmp) { \
return m_val; \
+ } \
}
-_ALWAYS_INLINE_ uint32_t _atomic_conditional_increment_impl(volatile uint32_t *pw){
-
- ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONG, InterlockedCompareExchange, uint32_t)
+_ALWAYS_INLINE_ uint32_t _atomic_conditional_increment_impl(volatile uint32_t *pw) {
+ ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONG, InterlockedCompareExchange, uint32_t);
}
_ALWAYS_INLINE_ uint32_t _atomic_decrement_impl(volatile uint32_t *pw) {
-
return InterlockedDecrement((LONG volatile *)pw);
}
_ALWAYS_INLINE_ uint32_t _atomic_increment_impl(volatile uint32_t *pw) {
-
return InterlockedIncrement((LONG volatile *)pw);
}
_ALWAYS_INLINE_ uint32_t _atomic_sub_impl(volatile uint32_t *pw, volatile uint32_t val) {
-
return InterlockedExchangeAdd((LONG volatile *)pw, -(int32_t)val) - val;
}
_ALWAYS_INLINE_ uint32_t _atomic_add_impl(volatile uint32_t *pw, volatile uint32_t val) {
-
return InterlockedAdd((LONG volatile *)pw, val);
}
-_ALWAYS_INLINE_ uint32_t _atomic_exchange_if_greater_impl(volatile uint32_t *pw, volatile uint32_t val){
-
- ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONG, InterlockedCompareExchange, uint32_t)
+_ALWAYS_INLINE_ uint32_t _atomic_exchange_if_greater_impl(volatile uint32_t *pw, volatile uint32_t val) {
+ ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONG, InterlockedCompareExchange, uint32_t);
}
-_ALWAYS_INLINE_ uint64_t _atomic_conditional_increment_impl(volatile uint64_t *pw){
-
- ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONGLONG, InterlockedCompareExchange64, uint64_t)
+_ALWAYS_INLINE_ uint64_t _atomic_conditional_increment_impl(volatile uint64_t *pw) {
+ ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONGLONG, InterlockedCompareExchange64, uint64_t);
}
_ALWAYS_INLINE_ uint64_t _atomic_decrement_impl(volatile uint64_t *pw) {
-
return InterlockedDecrement64((LONGLONG volatile *)pw);
}
_ALWAYS_INLINE_ uint64_t _atomic_increment_impl(volatile uint64_t *pw) {
-
return InterlockedIncrement64((LONGLONG volatile *)pw);
}
_ALWAYS_INLINE_ uint64_t _atomic_sub_impl(volatile uint64_t *pw, volatile uint64_t val) {
-
return InterlockedExchangeAdd64((LONGLONG volatile *)pw, -(int64_t)val) - val;
}
_ALWAYS_INLINE_ uint64_t _atomic_add_impl(volatile uint64_t *pw, volatile uint64_t val) {
-
return InterlockedAdd64((LONGLONG volatile *)pw, val);
}
-_ALWAYS_INLINE_ uint64_t _atomic_exchange_if_greater_impl(volatile uint64_t *pw, volatile uint64_t val){
-
- ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONGLONG, InterlockedCompareExchange64, uint64_t)
+_ALWAYS_INLINE_ uint64_t _atomic_exchange_if_greater_impl(volatile uint64_t *pw, volatile uint64_t val) {
+ ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONGLONG, InterlockedCompareExchange64, uint64_t);
}
// The actual advertised functions; they'll call the right implementation
diff --git a/core/safe_refcount.h b/core/safe_refcount.h
index 953a877397..dc4e62354a 100644
--- a/core/safe_refcount.h
+++ b/core/safe_refcount.h
@@ -43,9 +43,9 @@
template <class T>
static _ALWAYS_INLINE_ T atomic_conditional_increment(volatile T *pw) {
-
- if (*pw == 0)
+ if (*pw == 0) {
return 0;
+ }
(*pw)++;
@@ -54,7 +54,6 @@ static _ALWAYS_INLINE_ T atomic_conditional_increment(volatile T *pw) {
template <class T>
static _ALWAYS_INLINE_ T atomic_decrement(volatile T *pw) {
-
(*pw)--;
return *pw;
@@ -62,7 +61,6 @@ static _ALWAYS_INLINE_ T atomic_decrement(volatile T *pw) {
template <class T>
static _ALWAYS_INLINE_ T atomic_increment(volatile T *pw) {
-
(*pw)++;
return *pw;
@@ -70,7 +68,6 @@ static _ALWAYS_INLINE_ T atomic_increment(volatile T *pw) {
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_sub(volatile T *pw, volatile V val) {
-
(*pw) -= val;
return *pw;
@@ -78,7 +75,6 @@ static _ALWAYS_INLINE_ T atomic_sub(volatile T *pw, volatile V val) {
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_add(volatile T *pw, volatile V val) {
-
(*pw) += val;
return *pw;
@@ -86,9 +82,9 @@ static _ALWAYS_INLINE_ T atomic_add(volatile T *pw, volatile V val) {
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_exchange_if_greater(volatile T *pw, volatile V val) {
-
- if (val > *pw)
+ if (val > *pw) {
*pw = val;
+ }
return *pw;
}
@@ -102,49 +98,47 @@ static _ALWAYS_INLINE_ T atomic_exchange_if_greater(volatile T *pw, volatile V v
template <class T>
static _ALWAYS_INLINE_ T atomic_conditional_increment(volatile T *pw) {
-
while (true) {
T tmp = static_cast<T const volatile &>(*pw);
- if (tmp == 0)
+ if (tmp == 0) {
return 0; // if zero, can't add to it anymore
- if (__sync_val_compare_and_swap(pw, tmp, tmp + 1) == tmp)
+ }
+ if (__sync_val_compare_and_swap(pw, tmp, tmp + 1) == tmp) {
return tmp + 1;
+ }
}
}
template <class T>
static _ALWAYS_INLINE_ T atomic_decrement(volatile T *pw) {
-
return __sync_sub_and_fetch(pw, 1);
}
template <class T>
static _ALWAYS_INLINE_ T atomic_increment(volatile T *pw) {
-
return __sync_add_and_fetch(pw, 1);
}
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_sub(volatile T *pw, volatile V val) {
-
return __sync_sub_and_fetch(pw, val);
}
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_add(volatile T *pw, volatile V val) {
-
return __sync_add_and_fetch(pw, val);
}
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_exchange_if_greater(volatile T *pw, volatile V val) {
-
while (true) {
T tmp = static_cast<T const volatile &>(*pw);
- if (tmp >= val)
+ if (tmp >= val) {
return tmp; // already greater, or equal
- if (__sync_val_compare_and_swap(pw, tmp, val) == tmp)
+ }
+ if (__sync_val_compare_and_swap(pw, tmp, val) == tmp) {
return val;
+ }
}
}
@@ -171,7 +165,6 @@ uint64_t atomic_exchange_if_greater(volatile uint64_t *pw, volatile uint64_t val
#endif
struct SafeRefCount {
-
uint32_t count;
public:
@@ -203,7 +196,6 @@ public:
}
_ALWAYS_INLINE_ void init(uint32_t p_value = 1) {
-
count = p_value;
}
};
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 82cac6bc9a..38a970f3c6 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -34,6 +34,7 @@
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include "core/project_settings.h"
+
#include <stdint.h>
ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
@@ -45,11 +46,10 @@ bool ScriptServer::languages_finished = false;
ScriptEditRequestFunction ScriptServer::edit_request_func = nullptr;
void Script::_notification(int p_what) {
-
if (p_what == NOTIFICATION_POSTINITIALIZE) {
-
- if (EngineDebugger::is_active())
+ if (EngineDebugger::is_active()) {
EngineDebugger::get_script_debugger()->set_break_language(get_language());
+ }
}
}
@@ -100,7 +100,6 @@ Dictionary Script::_get_script_constant_map() {
}
void Script::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("can_instance"), &Script::can_instance);
//ClassDB::bind_method(D_METHOD("instance_create","base_object"),&Script::instance_create);
ClassDB::bind_method(D_METHOD("instance_has", "base_object"), &Script::instance_has);
@@ -125,30 +124,25 @@ void Script::_bind_methods() {
}
void ScriptServer::set_scripting_enabled(bool p_enabled) {
-
scripting_enabled = p_enabled;
}
bool ScriptServer::is_scripting_enabled() {
-
return scripting_enabled;
}
ScriptLanguage *ScriptServer::get_language(int p_idx) {
-
ERR_FAIL_INDEX_V(p_idx, _language_count, nullptr);
return _languages[p_idx];
}
void ScriptServer::register_language(ScriptLanguage *p_language) {
-
ERR_FAIL_COND(_language_count >= MAX_LANGUAGES);
_languages[_language_count++] = p_language;
}
void ScriptServer::unregister_language(ScriptLanguage *p_language) {
-
for (int i = 0; i < _language_count; i++) {
if (_languages[i] == p_language) {
_language_count--;
@@ -161,7 +155,6 @@ void ScriptServer::unregister_language(ScriptLanguage *p_language) {
}
void ScriptServer::init_languages() {
-
{ //load global classes
global_classes_clear();
if (ProjectSettings::get_singleton()->has_setting("_global_script_classes")) {
@@ -169,8 +162,9 @@ void ScriptServer::init_languages() {
for (int i = 0; i < script_classes.size(); i++) {
Dictionary c = script_classes[i];
- if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base"))
+ if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) {
continue;
+ }
add_global_class(c["class"], c["base"], c["language"], c["path"]);
}
}
@@ -182,7 +176,6 @@ void ScriptServer::init_languages() {
}
void ScriptServer::finish_languages() {
-
for (int i = 0; i < _language_count; i++) {
_languages[i]->finish();
}
@@ -191,24 +184,20 @@ void ScriptServer::finish_languages() {
}
void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
-
reload_scripts_on_save = p_enable;
}
bool ScriptServer::is_reload_scripts_on_save_enabled() {
-
return reload_scripts_on_save;
}
void ScriptServer::thread_enter() {
-
for (int i = 0; i < _language_count; i++) {
_languages[i]->thread_enter();
}
}
void ScriptServer::thread_exit() {
-
for (int i = 0; i < _language_count; i++) {
_languages[i]->thread_exit();
}
@@ -228,16 +217,20 @@ void ScriptServer::add_global_class(const StringName &p_class, const StringName
g.base = p_base;
global_classes[p_class] = g;
}
+
void ScriptServer::remove_global_class(const StringName &p_class) {
global_classes.erase(p_class);
}
+
bool ScriptServer::is_global_class(const StringName &p_class) {
return global_classes.has(p_class);
}
+
StringName ScriptServer::get_global_class_language(const StringName &p_class) {
ERR_FAIL_COND_V(!global_classes.has(p_class), StringName());
return global_classes[p_class].language;
}
+
String ScriptServer::get_global_class_path(const String &p_class) {
ERR_FAIL_COND_V(!global_classes.has(p_class), String());
return global_classes[p_class].path;
@@ -247,6 +240,7 @@ StringName ScriptServer::get_global_class_base(const String &p_class) {
ERR_FAIL_COND_V(!global_classes.has(p_class), String());
return global_classes[p_class].base;
}
+
StringName ScriptServer::get_global_class_native_base(const String &p_class) {
ERR_FAIL_COND_V(!global_classes.has(p_class), String());
String base = global_classes[p_class].base;
@@ -255,6 +249,7 @@ StringName ScriptServer::get_global_class_native_base(const String &p_class) {
}
return base;
}
+
void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
const StringName *K = nullptr;
List<StringName> classes;
@@ -266,6 +261,7 @@ void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
r_global_classes->push_back(E->get());
}
}
+
void ScriptServer::save_global_classes() {
List<StringName> gc;
get_global_class_list(&gc);
@@ -285,27 +281,26 @@ void ScriptServer::save_global_classes() {
////////////////////
void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) {
-
List<PropertyInfo> pinfo;
get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_STORAGE) {
Pair<StringName, Variant> p;
p.first = E->get().name;
- if (get(p.first, p.second))
+ if (get(p.first, p.second)) {
state.push_back(p);
+ }
}
}
}
Variant ScriptInstance::call(const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -324,23 +319,25 @@ void ScriptInstance::call_multilevel_reversed(const StringName &p_method, const
}
void ScriptInstance::property_set_fallback(const StringName &, const Variant &, bool *r_valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
}
Variant ScriptInstance::property_get_fallback(const StringName &, bool *r_valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant();
}
void ScriptInstance::call_multilevel(const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -359,9 +356,9 @@ void ScriptLanguage::frame() {
}
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
-
- if (script->is_placeholder_fallback_enabled())
+ if (script->is_placeholder_fallback_enabled()) {
return false;
+ }
if (values.has(p_name)) {
Variant defval;
@@ -384,8 +381,8 @@ bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_v
}
return false;
}
-bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
+bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
if (values.has(p_name)) {
r_ret = values[p_name];
return true;
@@ -408,7 +405,6 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co
}
void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
-
if (script->is_placeholder_fallback_enabled()) {
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
p_properties->push_back(E->get());
@@ -425,38 +421,41 @@ void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properti
}
Variant::Type PlaceHolderScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
-
if (values.has(p_name)) {
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = true;
+ }
return values[p_name].get_type();
}
if (constants.has(p_name)) {
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = true;
+ }
return constants[p_name].get_type();
}
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = false;
+ }
return Variant::NIL;
}
void PlaceHolderScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
-
- if (script->is_placeholder_fallback_enabled())
+ if (script->is_placeholder_fallback_enabled()) {
return;
+ }
if (script.is_valid()) {
script->get_script_method_list(p_list);
}
}
-bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const {
- if (script->is_placeholder_fallback_enabled())
+bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const {
+ if (script->is_placeholder_fallback_enabled()) {
return false;
+ }
if (script.is_valid()) {
return script->has_method(p_method);
@@ -465,17 +464,15 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const {
}
void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, const Map<StringName, Variant> &p_values) {
-
Set<StringName> new_values;
for (const List<PropertyInfo>::Element *E = p_properties.front(); E; E = E->next()) {
-
StringName n = E->get().name;
new_values.insert(n);
if (!values.has(n) || values[n].get_type() != E->get().type) {
-
- if (p_values.has(n))
+ if (p_values.has(n)) {
values[n] = p_values[n];
+ }
}
}
@@ -483,9 +480,9 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
List<StringName> to_remove;
for (Map<StringName, Variant>::Element *E = values.front(); E; E = E->next()) {
-
- if (!new_values.has(E->key()))
+ if (!new_values.has(E->key())) {
to_remove.push_back(E->key());
+ }
Variant defval;
if (script->get_property_default_value(E->key(), defval)) {
@@ -497,13 +494,11 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
}
while (to_remove.size()) {
-
values.erase(to_remove.front()->get());
to_remove.pop_front();
}
if (owner && owner->get_script_instance() == this) {
-
owner->_change_notify();
}
//change notify
@@ -513,7 +508,6 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
}
void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid) {
-
if (script->is_placeholder_fallback_enabled()) {
Map<StringName, Variant>::Element *E = values.find(p_name);
@@ -535,31 +529,34 @@ void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name,
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false; // Cannot change the value in either case
+ }
}
Variant PlaceHolderScriptInstance::property_get_fallback(const StringName &p_name, bool *r_valid) {
-
if (script->is_placeholder_fallback_enabled()) {
const Map<StringName, Variant>::Element *E = values.find(p_name);
if (E) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return E->value();
}
E = constants.find(p_name);
if (E) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return E->value();
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return Variant();
}
@@ -579,7 +576,6 @@ PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language,
}
PlaceHolderScriptInstance::~PlaceHolderScriptInstance() {
-
if (script.is_valid()) {
script->_placeholder_erased(this);
}
diff --git a/core/script_language.h b/core/script_language.h
index 5cc240efcb..b6c2a47245 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -112,7 +112,6 @@ class ScriptInstance;
class PlaceHolderScriptInstance;
class Script : public Resource {
-
GDCLASS(Script, Resource);
OBJ_SAVE_TYPE(Script);
@@ -205,8 +204,9 @@ public:
virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
virtual void notification(int p_notification) = 0;
virtual String to_string(bool *r_valid) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return String();
}
@@ -253,14 +253,12 @@ struct ScriptCodeCompletionOption {
KIND_FILE_PATH,
KIND_PLAIN_TEXT,
};
- Kind kind;
+ Kind kind = KIND_PLAIN_TEXT;
String display;
String insert_text;
RES icon;
- ScriptCodeCompletionOption() {
- kind = KIND_PLAIN_TEXT;
- }
+ ScriptCodeCompletionOption() {}
ScriptCodeCompletionOption(const String &p_text, Kind p_kind) {
display = p_text;
@@ -270,7 +268,6 @@ struct ScriptCodeCompletionOption {
};
class ScriptCodeCompletionCache {
-
static ScriptCodeCompletionCache *singleton;
public:
@@ -408,7 +405,6 @@ public:
extern uint8_t script_encryption_key[32];
class PlaceHolderScriptInstance : public ScriptInstance {
-
Object *owner;
List<PropertyInfo> properties;
Map<StringName, Variant> values;
diff --git a/core/self_list.h b/core/self_list.h
index 2c44b0caec..3104bcb714 100644
--- a/core/self_list.h
+++ b/core/self_list.h
@@ -38,13 +38,11 @@ template <class T>
class SelfList {
public:
class List {
-
- SelfList<T> *_first;
- SelfList<T> *_last;
+ SelfList<T> *_first = nullptr;
+ SelfList<T> *_last = nullptr;
public:
void add(SelfList<T> *p_elem) {
-
ERR_FAIL_COND(p_elem->_root);
p_elem->_root = this;
@@ -62,7 +60,6 @@ public:
}
void add_last(SelfList<T> *p_elem) {
-
ERR_FAIL_COND(p_elem->_root);
p_elem->_root = this;
@@ -80,7 +77,6 @@ public:
}
void remove(SelfList<T> *p_elem) {
-
ERR_FAIL_COND(p_elem->_root != this);
if (p_elem->_next) {
p_elem->_next->_prev = p_elem->_prev;
@@ -105,24 +101,23 @@ public:
_FORCE_INLINE_ SelfList<T> *first() { return _first; }
_FORCE_INLINE_ const SelfList<T> *first() const { return _first; }
- _FORCE_INLINE_ List() {
- _first = nullptr;
- _last = nullptr;
- }
+
+ _FORCE_INLINE_ List() {}
_FORCE_INLINE_ ~List() { ERR_FAIL_COND(_first != nullptr); }
};
private:
- List *_root;
+ List *_root = nullptr;
T *_self;
- SelfList<T> *_next;
- SelfList<T> *_prev;
+ SelfList<T> *_next = nullptr;
+ SelfList<T> *_prev = nullptr;
public:
_FORCE_INLINE_ bool in_list() const { return _root; }
_FORCE_INLINE_ void remove_from_list() {
- if (_root)
+ if (_root) {
_root->remove(this);
+ }
}
_FORCE_INLINE_ SelfList<T> *next() { return _next; }
_FORCE_INLINE_ SelfList<T> *prev() { return _prev; }
@@ -131,17 +126,13 @@ public:
_FORCE_INLINE_ T *self() const { return _self; }
_FORCE_INLINE_ SelfList(T *p_self) {
-
_self = p_self;
- _next = nullptr;
- _prev = nullptr;
- _root = nullptr;
}
_FORCE_INLINE_ ~SelfList() {
-
- if (_root)
+ if (_root) {
_root->remove(this);
+ }
}
};
diff --git a/core/set.h b/core/set.h
index c17ee15350..1bc0a3f41e 100644
--- a/core/set.h
+++ b/core/set.h
@@ -39,7 +39,6 @@
template <class T, class C = Comparator<T>, class A = DefaultAllocator>
class Set {
-
enum Color {
RED,
BLACK
@@ -48,54 +47,41 @@ class Set {
public:
class Element {
-
private:
friend class Set<T, C, A>;
- int color;
- Element *right;
- Element *left;
- Element *parent;
- Element *_next;
- Element *_prev;
+ int color = RED;
+ Element *right = nullptr;
+ Element *left = nullptr;
+ Element *parent = nullptr;
+ Element *_next = nullptr;
+ Element *_prev = nullptr;
T value;
//_Data *data;
public:
const Element *next() const {
-
return _next;
}
Element *next() {
-
return _next;
}
const Element *prev() const {
-
return _prev;
}
Element *prev() {
-
return _prev;
}
const T &get() const {
return value;
};
- Element() {
- color = RED;
- right = nullptr;
- left = nullptr;
- parent = nullptr;
- _next = nullptr;
- _prev = nullptr;
- };
+ Element() {}
};
private:
struct _Data {
-
- Element *_root;
+ Element *_root = nullptr;
Element *_nil;
- int size_cache;
+ int size_cache = 0;
_FORCE_INLINE_ _Data() {
#ifdef GLOBALNIL_DISABLED
@@ -105,19 +91,15 @@ private:
#else
_nil = (Element *)&_GlobalNilClass::_nil;
#endif
- _root = nullptr;
- size_cache = 0;
}
void _create_root() {
-
_root = memnew_allocator(Element, A);
_root->parent = _root->left = _root->right = _nil;
_root->color = BLACK;
}
void _free_root() {
-
if (_root) {
memdelete_allocator<Element, A>(_root);
_root = nullptr;
@@ -125,7 +107,6 @@ private:
}
~_Data() {
-
_free_root();
#ifdef GLOBALNIL_DISABLED
@@ -137,62 +118,61 @@ private:
_Data _data;
inline void _set_color(Element *p_node, int p_color) {
-
ERR_FAIL_COND(p_node == _data._nil && p_color == RED);
p_node->color = p_color;
}
inline void _rotate_left(Element *p_node) {
-
Element *r = p_node->right;
p_node->right = r->left;
- if (r->left != _data._nil)
+ if (r->left != _data._nil) {
r->left->parent = p_node;
+ }
r->parent = p_node->parent;
- if (p_node == p_node->parent->left)
+ if (p_node == p_node->parent->left) {
p_node->parent->left = r;
- else
+ } else {
p_node->parent->right = r;
+ }
r->left = p_node;
p_node->parent = r;
}
inline void _rotate_right(Element *p_node) {
-
Element *l = p_node->left;
p_node->left = l->right;
- if (l->right != _data._nil)
+ if (l->right != _data._nil) {
l->right->parent = p_node;
+ }
l->parent = p_node->parent;
- if (p_node == p_node->parent->right)
+ if (p_node == p_node->parent->right) {
p_node->parent->right = l;
- else
+ } else {
p_node->parent->left = l;
+ }
l->right = p_node;
p_node->parent = l;
}
inline Element *_successor(Element *p_node) const {
-
Element *node = p_node;
if (node->right != _data._nil) {
-
node = node->right;
while (node->left != _data._nil) { /* returns the minimum of the right subtree of node */
node = node->left;
}
return node;
} else {
-
while (node == node->parent->right) {
node = node->parent;
}
- if (node->parent == _data._root)
+ if (node->parent == _data._root) {
return nullptr; // No successor, as p_node = last node
+ }
return node->parent;
}
}
@@ -201,43 +181,41 @@ private:
Element *node = p_node;
if (node->left != _data._nil) {
-
node = node->left;
while (node->right != _data._nil) { /* returns the minimum of the left subtree of node */
node = node->right;
}
return node;
} else {
-
while (node == node->parent->left) {
node = node->parent;
}
- if (node == _data._root)
+ if (node == _data._root) {
return nullptr; // No predecessor, as p_node = first node.
+ }
return node->parent;
}
}
Element *_find(const T &p_value) const {
-
Element *node = _data._root->left;
C less;
while (node != _data._nil) {
- if (less(p_value, node->value))
+ if (less(p_value, node->value)) {
node = node->left;
- else if (less(node->value, p_value))
+ } else if (less(node->value, p_value)) {
node = node->right;
- else
+ } else {
return node; // found
+ }
}
return nullptr;
}
Element *_lower_bound(const T &p_value) const {
-
Element *node = _data._root->left;
Element *prev = nullptr;
C less;
@@ -245,25 +223,27 @@ private:
while (node != _data._nil) {
prev = node;
- if (less(p_value, node->value))
+ if (less(p_value, node->value)) {
node = node->left;
- else if (less(node->value, p_value))
+ } else if (less(node->value, p_value)) {
node = node->right;
- else
+ } else {
return node; // found
+ }
}
- if (prev == nullptr)
+ if (prev == nullptr) {
return nullptr; // tree empty
+ }
- if (less(prev->value, p_value))
+ if (less(prev->value, p_value)) {
prev = prev->_next;
+ }
return prev;
}
void _insert_rb_fix(Element *p_new_node) {
-
Element *node = p_new_node;
Element *nparent = node->parent;
Element *ngrand_parent;
@@ -312,20 +292,18 @@ private:
}
Element *_insert(const T &p_value) {
-
Element *new_parent = _data._root;
Element *node = _data._root->left;
C less;
while (node != _data._nil) {
-
new_parent = node;
- if (less(p_value, node->value))
+ if (less(p_value, node->value)) {
node = node->left;
- else if (less(node->value, p_value))
+ } else if (less(node->value, p_value)) {
node = node->right;
- else {
+ } else {
return node; // Return existing node
}
}
@@ -345,10 +323,12 @@ private:
new_node->_next = _successor(new_node);
new_node->_prev = _predecessor(new_node);
- if (new_node->_next)
+ if (new_node->_next) {
new_node->_next->_prev = new_node;
- if (new_node->_prev)
+ }
+ if (new_node->_prev) {
new_node->_prev->_next = new_node;
+ }
_data.size_cache++;
_insert_rb_fix(new_node);
@@ -356,7 +336,6 @@ private:
}
void _erase_fix_rb(Element *p_node) {
-
Element *root = _data._root->left;
Element *node = _data._nil;
Element *sibling = p_node;
@@ -418,7 +397,6 @@ private:
}
void _erase(Element *p_node) {
-
Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next;
Element *node = (rp->left == _data._nil) ? rp->right : rp->left;
@@ -439,17 +417,18 @@ private:
}
if (rp != p_node) {
-
ERR_FAIL_COND(rp == _data._nil);
rp->left = p_node->left;
rp->right = p_node->right;
rp->parent = p_node->parent;
rp->color = p_node->color;
- if (p_node->left != _data._nil)
+ if (p_node->left != _data._nil) {
p_node->left->parent = rp;
- if (p_node->right != _data._nil)
+ }
+ if (p_node->right != _data._nil) {
p_node->right->parent = rp;
+ }
if (p_node == p_node->parent->left) {
p_node->parent->left = rp;
@@ -458,10 +437,12 @@ private:
}
}
- if (p_node->_next)
+ if (p_node->_next) {
p_node->_next->_prev = p_node->_prev;
- if (p_node->_prev)
+ }
+ if (p_node->_prev) {
p_node->_prev->_next = p_node->_next;
+ }
memdelete_allocator<Element, A>(p_node);
_data.size_cache--;
@@ -469,21 +450,22 @@ private:
}
void _calculate_depth(Element *p_element, int &max_d, int d) const {
-
- if (p_element == _data._nil)
+ if (p_element == _data._nil) {
return;
+ }
_calculate_depth(p_element->left, max_d, d + 1);
_calculate_depth(p_element->right, max_d, d + 1);
- if (d > max_d)
+ if (d > max_d) {
max_d = d;
+ }
}
void _cleanup_tree(Element *p_element) {
-
- if (p_element == _data._nil)
+ if (p_element == _data._nil) {
return;
+ }
_cleanup_tree(p_element->left);
_cleanup_tree(p_element->right);
@@ -491,102 +473,105 @@ private:
}
void _copy_from(const Set &p_set) {
-
clear();
// not the fastest way, but safeset to write.
for (Element *I = p_set.front(); I; I = I->next()) {
-
insert(I->get());
}
}
public:
const Element *find(const T &p_value) const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
const Element *res = _find(p_value);
return res;
}
Element *find(const T &p_value) {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *res = _find(p_value);
return res;
}
Element *lower_bound(const T &p_value) const {
-
return _lower_bound(p_value);
}
bool has(const T &p_value) const {
-
return find(p_value) != nullptr;
}
Element *insert(const T &p_value) {
-
- if (!_data._root)
+ if (!_data._root) {
_data._create_root();
+ }
return _insert(p_value);
}
void erase(Element *p_element) {
-
- if (!_data._root || !p_element)
+ if (!_data._root || !p_element) {
return;
+ }
_erase(p_element);
- if (_data.size_cache == 0 && _data._root)
+ if (_data.size_cache == 0 && _data._root) {
_data._free_root();
+ }
}
bool erase(const T &p_value) {
-
- if (!_data._root)
+ if (!_data._root) {
return false;
+ }
Element *e = find(p_value);
- if (!e)
+ if (!e) {
return false;
+ }
_erase(e);
- if (_data.size_cache == 0 && _data._root)
+ if (_data.size_cache == 0 && _data._root) {
_data._free_root();
+ }
return true;
}
Element *front() const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *e = _data._root->left;
- if (e == _data._nil)
+ if (e == _data._nil) {
return nullptr;
+ }
- while (e->left != _data._nil)
+ while (e->left != _data._nil) {
e = e->left;
+ }
return e;
}
Element *back() const {
-
- if (!_data._root)
+ if (!_data._root) {
return nullptr;
+ }
Element *e = _data._root->left;
- if (e == _data._nil)
+ if (e == _data._nil) {
return nullptr;
+ }
- while (e->right != _data._nil)
+ while (e->right != _data._nil) {
e = e->right;
+ }
return e;
}
@@ -596,8 +581,9 @@ public:
int calculate_depth() const {
// used for debug mostly
- if (!_data._root)
+ if (!_data._root) {
return 0;
+ }
int max_d = 0;
_calculate_depth(_data._root->left, max_d, 0);
@@ -605,9 +591,9 @@ public:
}
void clear() {
-
- if (!_data._root)
+ if (!_data._root) {
return;
+ }
_cleanup_tree(_data._root->left);
_data._root->left = _data._nil;
@@ -616,20 +602,16 @@ public:
}
void operator=(const Set &p_set) {
-
_copy_from(p_set);
}
Set(const Set &p_set) {
-
_copy_from(p_set);
}
- _FORCE_INLINE_ Set() {
- }
+ _FORCE_INLINE_ Set() {}
~Set() {
-
clear();
}
};
diff --git a/core/simple_type.h b/core/simple_type.h
index da031854c6..10dc36cbd4 100644
--- a/core/simple_type.h
+++ b/core/simple_type.h
@@ -35,19 +35,16 @@
template <class T>
struct GetSimpleTypeT {
-
typedef T type_t;
};
template <class T>
struct GetSimpleTypeT<T &> {
-
typedef T type_t;
};
template <class T>
struct GetSimpleTypeT<T const> {
-
typedef T type_t;
};
diff --git a/core/sort_array.h b/core/sort_array.h
index 8aff0fb502..93cc6f727d 100644
--- a/core/sort_array.h
+++ b/core/sort_array.h
@@ -42,7 +42,6 @@
template <class T>
struct _DefaultComparator {
-
_FORCE_INLINE_ bool operator()(const T &a, const T &b) const { return (a < b); }
};
@@ -54,7 +53,6 @@ struct _DefaultComparator {
template <class T, class Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
class SortArray {
-
enum {
INTROSORT_THRESHOLD = 16
@@ -64,36 +62,36 @@ public:
Comparator compare;
inline const T &median_of_3(const T &a, const T &b, const T &c) const {
-
- if (compare(a, b))
- if (compare(b, c))
+ if (compare(a, b)) {
+ if (compare(b, c)) {
return b;
- else if (compare(a, c))
+ } else if (compare(a, c)) {
return c;
- else
+ } else {
return a;
- else if (compare(a, c))
+ }
+ } else if (compare(a, c)) {
return a;
- else if (compare(b, c))
+ } else if (compare(b, c)) {
return c;
- else
+ } else {
return b;
+ }
}
inline int bitlog(int n) const {
int k;
- for (k = 0; n != 1; n >>= 1)
+ for (k = 0; n != 1; n >>= 1) {
++k;
+ }
return k;
}
/* Heap / Heapsort functions */
inline void push_heap(int p_first, int p_hole_idx, int p_top_index, T p_value, T *p_array) const {
-
int parent = (p_hole_idx - 1) / 2;
while (p_hole_idx > p_top_index && compare(p_array[p_first + parent], p_value)) {
-
p_array[p_first + p_hole_idx] = p_array[p_first + parent];
p_hole_idx = parent;
parent = (p_hole_idx - 1) / 2;
@@ -102,24 +100,21 @@ public:
}
inline void pop_heap(int p_first, int p_last, int p_result, T p_value, T *p_array) const {
-
p_array[p_result] = p_array[p_first];
adjust_heap(p_first, 0, p_last - p_first, p_value, p_array);
}
inline void pop_heap(int p_first, int p_last, T *p_array) const {
-
pop_heap(p_first, p_last - 1, p_last - 1, p_array[p_last - 1], p_array);
}
inline void adjust_heap(int p_first, int p_hole_idx, int p_len, T p_value, T *p_array) const {
-
int top_index = p_hole_idx;
int second_child = 2 * p_hole_idx + 2;
while (second_child < p_len) {
-
- if (compare(p_array[p_first + second_child], p_array[p_first + (second_child - 1)]))
+ if (compare(p_array[p_first + second_child], p_array[p_first + (second_child - 1)])) {
second_child--;
+ }
p_array[p_first + p_hole_idx] = p_array[p_first + second_child];
p_hole_idx = second_child;
@@ -134,46 +129,47 @@ public:
}
inline void sort_heap(int p_first, int p_last, T *p_array) const {
-
while (p_last - p_first > 1) {
-
pop_heap(p_first, p_last--, p_array);
}
}
inline void make_heap(int p_first, int p_last, T *p_array) const {
- if (p_last - p_first < 2)
+ if (p_last - p_first < 2) {
return;
+ }
int len = p_last - p_first;
int parent = (len - 2) / 2;
while (true) {
adjust_heap(p_first, parent, len, p_array[p_first + parent], p_array);
- if (parent == 0)
+ if (parent == 0) {
return;
+ }
parent--;
}
}
inline void partial_sort(int p_first, int p_last, int p_middle, T *p_array) const {
-
make_heap(p_first, p_middle, p_array);
- for (int i = p_middle; i < p_last; i++)
- if (compare(p_array[i], p_array[p_first]))
+ for (int i = p_middle; i < p_last; i++) {
+ if (compare(p_array[i], p_array[p_first])) {
pop_heap(p_first, p_middle, i, p_array[i], p_array);
+ }
+ }
sort_heap(p_first, p_middle, p_array);
}
inline void partial_select(int p_first, int p_last, int p_middle, T *p_array) const {
-
make_heap(p_first, p_middle, p_array);
- for (int i = p_middle; i < p_last; i++)
- if (compare(p_array[i], p_array[p_first]))
+ for (int i = p_middle; i < p_last; i++) {
+ if (compare(p_array[i], p_array[p_first])) {
pop_heap(p_first, p_middle, i, p_array[i], p_array);
+ }
+ }
}
inline int partitioner(int p_first, int p_last, T p_pivot, T *p_array) const {
-
const int unmodified_first = p_first;
const int unmodified_last = p_last;
@@ -192,8 +188,9 @@ public:
p_last--;
}
- if (!(p_first < p_last))
+ if (!(p_first < p_last)) {
return p_first;
+ }
SWAP(p_array[p_first], p_array[p_last]);
p_first++;
@@ -201,9 +198,7 @@ public:
}
inline void introsort(int p_first, int p_last, T *p_array, int p_max_depth) const {
-
while (p_last - p_first > INTROSORT_THRESHOLD) {
-
if (p_max_depth == 0) {
partial_sort(p_first, p_last, p_last, p_array);
return;
@@ -226,9 +221,7 @@ public:
}
inline void introselect(int p_first, int p_nth, int p_last, T *p_array, int p_max_depth) const {
-
while (p_last - p_first > 3) {
-
if (p_max_depth == 0) {
partial_select(p_first, p_nth + 1, p_last, p_array);
SWAP(p_first, p_nth);
@@ -246,17 +239,17 @@ public:
p_array[p_last - 1]),
p_array);
- if (cut <= p_nth)
+ if (cut <= p_nth) {
p_first = cut;
- else
+ } else {
p_last = cut;
+ }
}
insertion_sort(p_first, p_last, p_array);
}
inline void unguarded_linear_insert(int p_last, T p_value, T *p_array) const {
-
int next = p_last - 1;
while (compare(p_value, p_array[next])) {
if (Validate) {
@@ -270,45 +263,43 @@ public:
}
inline void linear_insert(int p_first, int p_last, T *p_array) const {
-
T val = p_array[p_last];
if (compare(val, p_array[p_first])) {
-
- for (int i = p_last; i > p_first; i--)
+ for (int i = p_last; i > p_first; i--) {
p_array[i] = p_array[i - 1];
+ }
p_array[p_first] = val;
- } else
+ } else {
unguarded_linear_insert(p_last, val, p_array);
+ }
}
inline void insertion_sort(int p_first, int p_last, T *p_array) const {
-
- if (p_first == p_last)
+ if (p_first == p_last) {
return;
- for (int i = p_first + 1; i != p_last; i++)
+ }
+ for (int i = p_first + 1; i != p_last; i++) {
linear_insert(p_first, i, p_array);
+ }
}
inline void unguarded_insertion_sort(int p_first, int p_last, T *p_array) const {
-
- for (int i = p_first; i != p_last; i++)
+ for (int i = p_first; i != p_last; i++) {
unguarded_linear_insert(i, p_array[i], p_array);
+ }
}
inline void final_insertion_sort(int p_first, int p_last, T *p_array) const {
-
if (p_last - p_first > INTROSORT_THRESHOLD) {
insertion_sort(p_first, p_first + INTROSORT_THRESHOLD, p_array);
unguarded_insertion_sort(p_first + INTROSORT_THRESHOLD, p_last, p_array);
} else {
-
insertion_sort(p_first, p_last, p_array);
}
}
inline void sort_range(int p_first, int p_last, T *p_array) const {
-
if (p_first != p_last) {
introsort(p_first, p_last, p_array, bitlog(p_last - p_first) * 2);
final_insertion_sort(p_first, p_last, p_array);
@@ -316,14 +307,13 @@ public:
}
inline void sort(T *p_array, int p_len) const {
-
sort_range(0, p_len, p_array);
}
inline void nth_element(int p_first, int p_last, int p_nth, T *p_array) const {
-
- if (p_first == p_last || p_nth == p_last)
+ if (p_first == p_last || p_nth == p_last) {
return;
+ }
introselect(p_first, p_nth, p_last, p_array, bitlog(p_last - p_first) * 2);
}
};
diff --git a/core/spin_lock.h b/core/spin_lock.h
index c48631f94a..1bb810bb29 100644
--- a/core/spin_lock.h
+++ b/core/spin_lock.h
@@ -32,6 +32,7 @@
#define SPIN_LOCK_H
#include "core/typedefs.h"
+
#include <atomic>
class SpinLock {
diff --git a/core/string_buffer.h b/core/string_buffer.h
index a140f0abf7..956a6333d9 100644
--- a/core/string_buffer.h
+++ b/core/string_buffer.h
@@ -35,10 +35,9 @@
template <int SHORT_BUFFER_SIZE = 64>
class StringBuffer {
-
CharType short_buffer[SHORT_BUFFER_SIZE];
String buffer;
- int string_length;
+ int string_length = 0;
_FORCE_INLINE_ CharType *current_buffer_ptr() {
return static_cast<String &>(buffer).empty() ? short_buffer : buffer.ptrw();
@@ -78,10 +77,6 @@ public:
_FORCE_INLINE_ operator String() {
return as_string();
}
-
- StringBuffer() {
- string_length = 0;
- }
};
template <int SHORT_BUFFER_SIZE>
@@ -123,8 +118,9 @@ StringBuffer<SHORT_BUFFER_SIZE> &StringBuffer<SHORT_BUFFER_SIZE>::append(const C
template <int SHORT_BUFFER_SIZE>
StringBuffer<SHORT_BUFFER_SIZE> &StringBuffer<SHORT_BUFFER_SIZE>::reserve(int p_size) {
- if (p_size < SHORT_BUFFER_SIZE || p_size < buffer.size())
+ if (p_size < SHORT_BUFFER_SIZE || p_size < buffer.size()) {
return *this;
+ }
bool need_copy = string_length > 0 && buffer.empty();
buffer.resize(next_power_of_2(p_size));
diff --git a/core/string_builder.cpp b/core/string_builder.cpp
index 46c7e1c53f..c8d6498f27 100644
--- a/core/string_builder.cpp
+++ b/core/string_builder.cpp
@@ -33,9 +33,9 @@
#include <string.h>
StringBuilder &StringBuilder::append(const String &p_string) {
-
- if (p_string == String())
+ if (p_string == String()) {
return *this;
+ }
strings.push_back(p_string);
appended_strings.push_back(-1);
@@ -46,7 +46,6 @@ StringBuilder &StringBuilder::append(const String &p_string) {
}
StringBuilder &StringBuilder::append(const char *p_cstring) {
-
int32_t len = strlen(p_cstring);
c_strings.push_back(p_cstring);
@@ -58,9 +57,9 @@ StringBuilder &StringBuilder::append(const char *p_cstring) {
}
String StringBuilder::as_string() const {
-
- if (string_length == 0)
+ if (string_length == 0) {
return "";
+ }
CharType *buffer = memnew_arr(CharType, string_length);
@@ -80,7 +79,6 @@ String StringBuilder::as_string() const {
godot_string_elem++;
} else {
-
const char *s = c_strings[c_string_elem];
for (int32_t j = 0; j < appended_strings[i]; j++) {
diff --git a/core/string_builder.h b/core/string_builder.h
index dd8a154890..2a37d14218 100644
--- a/core/string_builder.h
+++ b/core/string_builder.h
@@ -32,12 +32,10 @@
#define STRING_BUILDER_H
#include "core/ustring.h"
-
#include "core/vector.h"
class StringBuilder {
-
- uint32_t string_length;
+ uint32_t string_length = 0;
Vector<String> strings;
Vector<const char *> c_strings;
@@ -80,9 +78,7 @@ public:
return as_string();
}
- StringBuilder() {
- string_length = 0;
- }
+ StringBuilder() {}
};
#endif // STRING_BUILDER_H
diff --git a/core/string_name.cpp b/core/string_name.cpp
index 9cbac97a7c..cbf6009681 100644
--- a/core/string_name.cpp
+++ b/core/string_name.cpp
@@ -42,7 +42,6 @@ StaticCString StaticCString::create(const char *p_ptr) {
StringName::_Data *StringName::_table[STRING_TABLE_LEN];
StringName _scs_create(const char *p_chr) {
-
return (p_chr[0] ? StringName(StaticCString::create(p_chr)) : StringName());
}
@@ -50,24 +49,19 @@ bool StringName::configured = false;
Mutex StringName::mutex;
void StringName::setup() {
-
ERR_FAIL_COND(configured);
for (int i = 0; i < STRING_TABLE_LEN; i++) {
-
_table[i] = nullptr;
}
configured = true;
}
void StringName::cleanup() {
-
MutexLock lock(mutex);
int lost_strings = 0;
for (int i = 0; i < STRING_TABLE_LEN; i++) {
-
while (_table[i]) {
-
_Data *d = _table[i];
lost_strings++;
if (OS::get_singleton()->is_stdout_verbose()) {
@@ -88,11 +82,9 @@ void StringName::cleanup() {
}
void StringName::unref() {
-
ERR_FAIL_COND(!configured);
if (_data && _data->refcount.unref()) {
-
MutexLock lock(mutex);
if (_data->prev) {
@@ -114,9 +106,7 @@ void StringName::unref() {
}
bool StringName::operator==(const String &p_name) const {
-
if (!_data) {
-
return (p_name.length() == 0);
}
@@ -124,9 +114,7 @@ bool StringName::operator==(const String &p_name) const {
}
bool StringName::operator==(const char *p_name) const {
-
if (!_data) {
-
return (p_name[0] == 0);
}
@@ -134,32 +122,28 @@ bool StringName::operator==(const char *p_name) const {
}
bool StringName::operator!=(const String &p_name) const {
-
return !(operator==(p_name));
}
bool StringName::operator!=(const StringName &p_name) const {
-
// the real magic of all this mess happens here.
// this is why path comparisons are very fast
return _data != p_name._data;
}
void StringName::operator=(const StringName &p_name) {
-
- if (this == &p_name)
+ if (this == &p_name) {
return;
+ }
unref();
if (p_name._data && p_name._data->refcount.ref()) {
-
_data = p_name._data;
}
}
StringName::StringName(const StringName &p_name) {
-
_data = nullptr;
ERR_FAIL_COND(!configured);
@@ -170,13 +154,13 @@ StringName::StringName(const StringName &p_name) {
}
StringName::StringName(const char *p_name) {
-
_data = nullptr;
ERR_FAIL_COND(!configured);
- if (!p_name || p_name[0] == 0)
+ if (!p_name || p_name[0] == 0) {
return; //empty, ignore
+ }
MutexLock lock(mutex);
@@ -187,10 +171,10 @@ StringName::StringName(const char *p_name) {
_data = _table[idx];
while (_data) {
-
// compare hash first
- if (_data->hash == hash && _data->get_name() == p_name)
+ if (_data->hash == hash && _data->get_name() == p_name) {
break;
+ }
_data = _data->next;
}
@@ -209,13 +193,13 @@ StringName::StringName(const char *p_name) {
_data->cname = nullptr;
_data->next = _table[idx];
_data->prev = nullptr;
- if (_table[idx])
+ if (_table[idx]) {
_table[idx]->prev = _data;
+ }
_table[idx] = _data;
}
StringName::StringName(const StaticCString &p_static_string) {
-
_data = nullptr;
ERR_FAIL_COND(!configured);
@@ -231,10 +215,10 @@ StringName::StringName(const StaticCString &p_static_string) {
_data = _table[idx];
while (_data) {
-
// compare hash first
- if (_data->hash == hash && _data->get_name() == p_static_string.ptr)
+ if (_data->hash == hash && _data->get_name() == p_static_string.ptr) {
break;
+ }
_data = _data->next;
}
@@ -253,19 +237,20 @@ StringName::StringName(const StaticCString &p_static_string) {
_data->cname = p_static_string.ptr;
_data->next = _table[idx];
_data->prev = nullptr;
- if (_table[idx])
+ if (_table[idx]) {
_table[idx]->prev = _data;
+ }
_table[idx] = _data;
}
StringName::StringName(const String &p_name) {
-
_data = nullptr;
ERR_FAIL_COND(!configured);
- if (p_name == String())
+ if (p_name == String()) {
return;
+ }
MutexLock lock(mutex);
@@ -275,9 +260,9 @@ StringName::StringName(const String &p_name) {
_data = _table[idx];
while (_data) {
-
- if (_data->hash == hash && _data->get_name() == p_name)
+ if (_data->hash == hash && _data->get_name() == p_name) {
break;
+ }
_data = _data->next;
}
@@ -296,18 +281,19 @@ StringName::StringName(const String &p_name) {
_data->cname = nullptr;
_data->next = _table[idx];
_data->prev = nullptr;
- if (_table[idx])
+ if (_table[idx]) {
_table[idx]->prev = _data;
+ }
_table[idx] = _data;
}
StringName StringName::search(const char *p_name) {
-
ERR_FAIL_COND_V(!configured, StringName());
ERR_FAIL_COND_V(!p_name, StringName());
- if (!p_name[0])
+ if (!p_name[0]) {
return StringName();
+ }
MutexLock lock(mutex);
@@ -317,10 +303,10 @@ StringName StringName::search(const char *p_name) {
_Data *_data = _table[idx];
while (_data) {
-
// compare hash first
- if (_data->hash == hash && _data->get_name() == p_name)
+ if (_data->hash == hash && _data->get_name() == p_name) {
break;
+ }
_data = _data->next;
}
@@ -332,12 +318,12 @@ StringName StringName::search(const char *p_name) {
}
StringName StringName::search(const CharType *p_name) {
-
ERR_FAIL_COND_V(!configured, StringName());
ERR_FAIL_COND_V(!p_name, StringName());
- if (!p_name[0])
+ if (!p_name[0]) {
return StringName();
+ }
MutexLock lock(mutex);
@@ -348,10 +334,10 @@ StringName StringName::search(const CharType *p_name) {
_Data *_data = _table[idx];
while (_data) {
-
// compare hash first
- if (_data->hash == hash && _data->get_name() == p_name)
+ if (_data->hash == hash && _data->get_name() == p_name) {
break;
+ }
_data = _data->next;
}
@@ -361,8 +347,8 @@ StringName StringName::search(const CharType *p_name) {
return StringName(); //does not exist
}
-StringName StringName::search(const String &p_name) {
+StringName StringName::search(const String &p_name) {
ERR_FAIL_COND_V(p_name == "", StringName());
MutexLock lock(mutex);
@@ -374,10 +360,10 @@ StringName StringName::search(const String &p_name) {
_Data *_data = _table[idx];
while (_data) {
-
// compare hash first
- if (_data->hash == hash && p_name == _data->get_name())
+ if (_data->hash == hash && p_name == _data->get_name()) {
break;
+ }
_data = _data->next;
}
@@ -388,12 +374,6 @@ StringName StringName::search(const String &p_name) {
return StringName(); //does not exist
}
-StringName::StringName() {
-
- _data = nullptr;
-}
-
StringName::~StringName() {
-
unref();
}
diff --git a/core/string_name.h b/core/string_name.h
index aec87b8e66..df6b458581 100644
--- a/core/string_name.h
+++ b/core/string_name.h
@@ -36,13 +36,11 @@
#include "core/ustring.h"
struct StaticCString {
-
const char *ptr;
static StaticCString create(const char *p_ptr);
};
class StringName {
-
enum {
STRING_TABLE_BITS = 12,
@@ -52,28 +50,22 @@ class StringName {
struct _Data {
SafeRefCount refcount;
- const char *cname;
+ const char *cname = nullptr;
String name;
String get_name() const { return cname ? String(cname) : name; }
- int idx;
- uint32_t hash;
- _Data *prev;
- _Data *next;
- _Data() {
- cname = nullptr;
- next = prev = nullptr;
- idx = 0;
- hash = 0;
- }
+ int idx = 0;
+ uint32_t hash = 0;
+ _Data *prev = nullptr;
+ _Data *next = nullptr;
+ _Data() {}
};
static _Data *_table[STRING_TABLE_LEN];
- _Data *_data;
+ _Data *_data = nullptr;
union _HashUnion {
-
_Data *ptr;
uint32_t hash;
};
@@ -90,13 +82,12 @@ class StringName {
StringName(_Data *p_data) { _data = p_data; }
public:
- operator const void *() const { return (_data && (_data->cname || !_data->name.empty())) ? (void *)1 : 0; }
+ operator const void *() const { return (_data && (_data->cname || !_data->name.empty())) ? (void *)1 : nullptr; }
bool operator==(const String &p_name) const;
bool operator==(const char *p_name) const;
bool operator!=(const String &p_name) const;
_FORCE_INLINE_ bool operator<(const StringName &p_name) const {
-
return _data < p_name._data;
}
_FORCE_INLINE_ bool operator==(const StringName &p_name) const {
@@ -105,11 +96,11 @@ public:
return _data == p_name._data;
}
_FORCE_INLINE_ uint32_t hash() const {
-
- if (_data)
+ if (_data) {
return _data->hash;
- else
+ } else {
return 0;
+ }
}
_FORCE_INLINE_ const void *data_unique_pointer() const {
return (void *)_data;
@@ -117,12 +108,12 @@ public:
bool operator!=(const StringName &p_name) const;
_FORCE_INLINE_ operator String() const {
-
if (_data) {
- if (_data->cname)
+ if (_data->cname) {
return String(_data->cname);
- else
+ } else {
return _data->name;
+ }
}
return String();
@@ -133,24 +124,22 @@ public:
static StringName search(const String &p_name);
struct AlphCompare {
-
_FORCE_INLINE_ bool operator()(const StringName &l, const StringName &r) const {
-
const char *l_cname = l._data ? l._data->cname : "";
const char *r_cname = r._data ? r._data->cname : "";
if (l_cname) {
-
- if (r_cname)
+ if (r_cname) {
return is_str_less(l_cname, r_cname);
- else
+ } else {
return is_str_less(l_cname, r._data->name.ptr());
+ }
} else {
-
- if (r_cname)
+ if (r_cname) {
return is_str_less(l._data->name.ptr(), r_cname);
- else
+ } else {
return is_str_less(l._data->name.ptr(), r._data->name.ptr());
+ }
}
}
};
@@ -160,7 +149,7 @@ public:
StringName(const StringName &p_name);
StringName(const String &p_name);
StringName(const StaticCString &p_static_string);
- StringName();
+ StringName() {}
~StringName();
};
diff --git a/core/thread_work_pool.cpp b/core/thread_work_pool.cpp
index c8311f102f..3a95e83ffc 100644
--- a/core/thread_work_pool.cpp
+++ b/core/thread_work_pool.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "thread_work_pool.h"
+
#include "core/os/os.h"
void ThreadWorkPool::_thread_function(ThreadData *p_thread) {
-
while (true) {
p_thread->start.wait();
if (p_thread->exit.load()) {
@@ -59,7 +59,6 @@ void ThreadWorkPool::init(int p_thread_count) {
}
void ThreadWorkPool::finish() {
-
if (threads == nullptr) {
return;
}
@@ -78,6 +77,5 @@ void ThreadWorkPool::finish() {
}
ThreadWorkPool::~ThreadWorkPool() {
-
finish();
}
diff --git a/core/thread_work_pool.h b/core/thread_work_pool.h
index 214d2c4aa7..e21d3974ee 100644
--- a/core/thread_work_pool.h
+++ b/core/thread_work_pool.h
@@ -33,10 +33,11 @@
#include "core/os/memory.h"
#include "core/os/semaphore.h"
+
#include <atomic>
#include <thread>
-class ThreadWorkPool {
+class ThreadWorkPool {
std::atomic<uint32_t> index;
struct BaseWork {
@@ -52,7 +53,6 @@ class ThreadWorkPool {
M method;
U userdata;
virtual void work() {
-
while (true) {
uint32_t work_index = index->fetch_add(1, std::memory_order_relaxed);
if (work_index >= max_elements) {
@@ -79,7 +79,6 @@ class ThreadWorkPool {
public:
template <class C, class M, class U>
void do_work(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) {
-
ERR_FAIL_COND(!threads); //never initialized
index.store(0);
diff --git a/core/translation.cpp b/core/translation.cpp
index 5f31bc7399..4f835bd7b4 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -795,12 +795,10 @@ static const char *locale_renames[][2] = {
///////////////////////////////////////////////
Vector<String> Translation::_get_messages() const {
-
Vector<String> msgs;
msgs.resize(translation_map.size() * 2);
int idx = 0;
for (const Map<StringName, StringName>::Element *E = translation_map.front(); E; E = E->next()) {
-
msgs.set(idx + 0, E->key());
msgs.set(idx + 1, E->get());
idx += 2;
@@ -810,12 +808,10 @@ Vector<String> Translation::_get_messages() const {
}
Vector<String> Translation::_get_message_list() const {
-
Vector<String> msgs;
msgs.resize(translation_map.size());
int idx = 0;
for (const Map<StringName, StringName>::Element *E = translation_map.front(); E; E = E->next()) {
-
msgs.set(idx, E->key());
idx += 1;
}
@@ -824,20 +820,17 @@ Vector<String> Translation::_get_message_list() const {
}
void Translation::_set_messages(const Vector<String> &p_messages) {
-
int msg_count = p_messages.size();
ERR_FAIL_COND(msg_count % 2);
const String *r = p_messages.ptr();
for (int i = 0; i < msg_count; i += 2) {
-
add_message(r[i + 0], r[i + 1]);
}
}
void Translation::set_locale(const String &p_locale) {
-
String univ_locale = TranslationServer::standardize_locale(p_locale);
if (!TranslationServer::is_locale_valid(univ_locale)) {
@@ -856,38 +849,33 @@ void Translation::set_locale(const String &p_locale) {
}
void Translation::add_message(const StringName &p_src_text, const StringName &p_xlated_text) {
-
translation_map[p_src_text] = p_xlated_text;
}
-StringName Translation::get_message(const StringName &p_src_text) const {
+StringName Translation::get_message(const StringName &p_src_text) const {
const Map<StringName, StringName>::Element *E = translation_map.find(p_src_text);
- if (!E)
+ if (!E) {
return StringName();
+ }
return E->get();
}
void Translation::erase_message(const StringName &p_src_text) {
-
translation_map.erase(p_src_text);
}
void Translation::get_message_list(List<StringName> *r_messages) const {
-
for (const Map<StringName, StringName>::Element *E = translation_map.front(); E; E = E->next()) {
-
r_messages->push_back(E->key());
}
}
int Translation::get_message_count() const {
-
return translation_map.size();
-};
+}
void Translation::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_locale", "locale"), &Translation::set_locale);
ClassDB::bind_method(D_METHOD("get_locale"), &Translation::get_locale);
ClassDB::bind_method(D_METHOD("add_message", "src_message", "xlated_message"), &Translation::add_message);
@@ -902,20 +890,15 @@ void Translation::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
}
-Translation::Translation() :
- locale("en") {
-}
-
///////////////////////////////////////////////
bool TranslationServer::is_locale_valid(const String &p_locale) {
-
const char **ptr = locale_list;
while (*ptr) {
-
- if (*ptr == p_locale)
+ if (*ptr == p_locale) {
return true;
+ }
ptr++;
}
@@ -923,7 +906,6 @@ bool TranslationServer::is_locale_valid(const String &p_locale) {
}
String TranslationServer::standardize_locale(const String &p_locale) {
-
// Replaces '-' with '_' for macOS Sierra-style locales
String univ_locale = p_locale.replace("-", "_");
@@ -941,7 +923,6 @@ String TranslationServer::standardize_locale(const String &p_locale) {
}
String TranslationServer::get_language_code(const String &p_locale) {
-
ERR_FAIL_COND_V_MSG(p_locale.length() < 2, p_locale, "Invalid locale '" + p_locale + "'.");
// Most language codes are two letters, but some are three,
// so we have to look for a regional code separator ('_' or '-')
@@ -958,7 +939,6 @@ String TranslationServer::get_language_code(const String &p_locale) {
}
void TranslationServer::set_locale(const String &p_locale) {
-
String univ_locale = standardize_locale(p_locale);
if (!is_locale_valid(univ_locale)) {
@@ -983,21 +963,19 @@ void TranslationServer::set_locale(const String &p_locale) {
}
String TranslationServer::get_locale() const {
-
return locale;
}
String TranslationServer::get_locale_name(const String &p_locale) const {
-
- if (!locale_name_map.has(p_locale))
+ if (!locale_name_map.has(p_locale)) {
return String();
+ }
return locale_name_map[p_locale];
}
Array TranslationServer::get_loaded_locales() const {
Array locales;
for (const Set<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) {
-
const Ref<Translation> &t = E->get();
ERR_FAIL_COND_V(t.is_null(), Array());
String l = t->get_locale();
@@ -1009,7 +987,6 @@ Array TranslationServer::get_loaded_locales() const {
}
Vector<String> TranslationServer::get_all_locales() {
-
Vector<String> locales;
const char **ptr = locale_list;
@@ -1023,7 +1000,6 @@ Vector<String> TranslationServer::get_all_locales() {
}
Vector<String> TranslationServer::get_all_locale_names() {
-
Vector<String> locales;
const char **ptr = locale_names;
@@ -1037,25 +1013,23 @@ Vector<String> TranslationServer::get_all_locale_names() {
}
void TranslationServer::add_translation(const Ref<Translation> &p_translation) {
-
translations.insert(p_translation);
}
-void TranslationServer::remove_translation(const Ref<Translation> &p_translation) {
+void TranslationServer::remove_translation(const Ref<Translation> &p_translation) {
translations.erase(p_translation);
}
void TranslationServer::clear() {
-
translations.clear();
-};
+}
StringName TranslationServer::translate(const StringName &p_message) const {
-
// Match given message against the translation catalog for the project locale.
- if (!enabled)
+ if (!enabled) {
return p_message;
+ }
ERR_FAIL_COND_V_MSG(locale.length() < 2, p_message, "Could not translate message as configured locale '" + locale + "' is invalid.");
@@ -1145,7 +1119,6 @@ StringName TranslationServer::translate(const StringName &p_message) const {
TranslationServer *TranslationServer::singleton = nullptr;
bool TranslationServer::_load_translations(const String &p_from) {
-
if (ProjectSettings::get_singleton()->has_setting(p_from)) {
Vector<String> translations = ProjectSettings::get_singleton()->get(p_from);
@@ -1155,10 +1128,10 @@ bool TranslationServer::_load_translations(const String &p_from) {
const String *r = translations.ptr();
for (int i = 0; i < tcount; i++) {
-
Ref<Translation> tr = ResourceLoader::load(r[i]);
- if (tr.is_valid())
+ if (tr.is_valid()) {
add_translation(tr);
+ }
}
}
return true;
@@ -1168,21 +1141,22 @@ bool TranslationServer::_load_translations(const String &p_from) {
}
void TranslationServer::setup() {
-
String test = GLOBAL_DEF("locale/test", "");
test = test.strip_edges();
- if (test != "")
+ if (test != "") {
set_locale(test);
- else
+ } else {
set_locale(OS::get_singleton()->get_locale());
+ }
fallback = GLOBAL_DEF("locale/fallback", "en");
#ifdef TOOLS_ENABLED
{
String options = "";
int idx = 0;
while (locale_list[idx]) {
- if (idx > 0)
+ if (idx > 0) {
options += ",";
+ }
options += locale_list[idx];
idx++;
}
@@ -1220,7 +1194,6 @@ StringName TranslationServer::doc_translate(const StringName &p_message) const {
}
void TranslationServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_locale", "locale"), &TranslationServer::set_locale);
ClassDB::bind_method(D_METHOD("get_locale"), &TranslationServer::get_locale);
@@ -1237,7 +1210,6 @@ void TranslationServer::_bind_methods() {
}
void TranslationServer::load_translations() {
-
String locale = get_locale();
_load_translations("locale/translations"); //all
_load_translations("locale/translations_" + locale.substr(0, 2));
@@ -1247,13 +1219,10 @@ void TranslationServer::load_translations() {
}
}
-TranslationServer::TranslationServer() :
- locale("en"),
- enabled(true) {
+TranslationServer::TranslationServer() {
singleton = this;
for (int i = 0; locale_list[i]; ++i) {
-
locale_name_map.insert(locale_list[i], String::utf8(locale_names[i]));
}
}
diff --git a/core/translation.h b/core/translation.h
index 29a068f450..4f50a1a4bc 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -34,12 +34,11 @@
#include "core/resource.h"
class Translation : public Resource {
-
GDCLASS(Translation, Resource);
OBJ_SAVE_TYPE(Translation);
RES_BASE_EXTENSION("translation");
- String locale;
+ String locale = "en";
Map<StringName, StringName> translation_map;
Vector<String> _get_message_list() const;
@@ -61,14 +60,13 @@ public:
void get_message_list(List<StringName> *r_messages) const;
int get_message_count() const;
- Translation();
+ Translation() {}
};
class TranslationServer : public Object {
-
GDCLASS(TranslationServer, Object);
- String locale;
+ String locale = "en";
String fallback;
Set<Ref<Translation>> translations;
@@ -77,7 +75,7 @@ class TranslationServer : public Object {
Map<String, String> locale_name_map;
- bool enabled;
+ bool enabled = true;
static TranslationServer *singleton;
bool _load_translations(const String &p_from);
diff --git a/core/type_info.h b/core/type_info.h
index 816d0d9381..e3d2b5bd53 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -35,7 +35,6 @@
template <bool C, typename T = void>
struct EnableIf {
-
typedef T type;
};
@@ -45,19 +44,16 @@ struct EnableIf<false, T> {
template <typename, typename>
struct TypesAreSame {
-
static bool const value = false;
};
template <typename A>
struct TypesAreSame<A, A> {
-
static bool const value = true;
};
template <typename B, typename D>
struct TypeInherits {
-
static D *get_d();
static char (&test(B *))[1];
@@ -262,8 +258,9 @@ struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>:
template <typename T>
inline StringName __constant_get_enum_name(T param, const String &p_constant) {
- if (GetTypeInfo<T>::VARIANT_TYPE == Variant::NIL)
+ if (GetTypeInfo<T>::VARIANT_TYPE == Variant::NIL) {
ERR_PRINT("Missing VARIANT_ENUM_CAST for constant's enum: " + p_constant);
+ }
return GetTypeInfo<T>::get_class_info().class_name;
}
diff --git a/core/typed_array.cpp b/core/typed_array.cpp
deleted file mode 100644
index a655a1b563..0000000000
--- a/core/typed_array.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*************************************************************************/
-/* typed_array.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 "typed_array.h"
diff --git a/core/typed_array.h b/core/typed_array.h
index 2c7b7e0384..86f26d7550 100644
--- a/core/typed_array.h
+++ b/core/typed_array.h
@@ -124,23 +124,18 @@ MAKE_TYPED_ARRAY(Vector<Color>, Variant::PACKED_COLOR_ARRAY)
template <class T>
struct PtrToArg<TypedArray<T>> {
-
_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
-
return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
}
_FORCE_INLINE_ static void encode(TypedArray<T> p_val, void *p_ptr) {
-
*(Array *)p_ptr = p_val;
}
};
template <class T>
struct PtrToArg<const TypedArray<T> &> {
-
_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
-
return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
}
};
diff --git a/core/typedefs.h b/core/typedefs.h
index bafbffcded..4bfa5debac 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -185,8 +185,9 @@ static _FORCE_INLINE_ T nearest_power_of_2_templated(T x) {
// Function to find the nearest (bigger) power of 2 to an integer.
static inline unsigned int nearest_shift(unsigned int p_number) {
for (int i = 30; i >= 0; i--) {
- if (p_number & (1 << i))
+ if (p_number & (1 << i)) {
return i + 1;
+ }
}
return 0;
diff --git a/core/ucaps.h b/core/ucaps.h
index ad71731617..79b346acba 100644
--- a/core/ucaps.h
+++ b/core/ucaps.h
@@ -1373,7 +1373,6 @@ static const int reverse_caps_table[CAPS_LEN - 1][2] = {
};
static int _find_upper(int ch) {
-
int low = 0;
int high = CAPS_LEN - 1;
int middle;
@@ -1394,7 +1393,6 @@ static int _find_upper(int ch) {
}
static int _find_lower(int ch) {
-
int low = 0;
int high = CAPS_LEN - 2;
int middle;
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index 62ad3e9f98..90750f2c6e 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -33,19 +33,17 @@
#include "core/os/os.h"
void UndoRedo::_discard_redo() {
-
- if (current_action == actions.size() - 1)
+ if (current_action == actions.size() - 1) {
return;
+ }
for (int i = current_action + 1; i < actions.size(); i++) {
-
for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) {
-
if (E->get().type == Operation::TYPE_REFERENCE) {
-
Object *obj = ObjectDB::get_instance(E->get().object);
- if (obj)
+ if (obj) {
memdelete(obj);
+ }
}
}
//ERASE do data
@@ -55,31 +53,26 @@ void UndoRedo::_discard_redo() {
}
void UndoRedo::create_action(const String &p_name, MergeMode p_mode) {
-
uint32_t ticks = OS::get_singleton()->get_ticks_msec();
if (action_level == 0) {
-
_discard_redo();
// Check if the merge operation is valid
if (p_mode != MERGE_DISABLE && actions.size() && actions[actions.size() - 1].name == p_name && actions[actions.size() - 1].last_tick + 800 > ticks) {
-
current_action = actions.size() - 2;
if (p_mode == MERGE_ENDS) {
-
// Clear all do ops from last action, and delete all object references
List<Operation>::Element *E = actions.write[current_action + 1].do_ops.front();
while (E) {
-
if (E->get().type == Operation::TYPE_REFERENCE) {
-
Object *obj = ObjectDB::get_instance(E->get().object);
- if (obj)
+ if (obj) {
memdelete(obj);
+ }
}
E = E->next();
@@ -92,7 +85,6 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) {
merge_mode = p_mode;
merging = true;
} else {
-
Action new_action;
new_action.name = p_name;
new_action.last_tick = ticks;
@@ -106,15 +98,15 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) {
}
void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS
ERR_FAIL_COND(p_object == nullptr);
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
- if (Object::cast_to<Resource>(p_object))
+ if (Object::cast_to<Resource>(p_object)) {
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
+ }
do_op.type = Operation::TYPE_METHOD;
do_op.name = p_method;
@@ -126,20 +118,21 @@ void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIA
}
void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS
ERR_FAIL_COND(p_object == nullptr);
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
// No undo if the merge mode is MERGE_ENDS
- if (merge_mode == MERGE_ENDS)
+ if (merge_mode == MERGE_ENDS) {
return;
+ }
Operation undo_op;
undo_op.object = p_object->get_instance_id();
- if (Object::cast_to<Resource>(p_object))
+ if (Object::cast_to<Resource>(p_object)) {
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
+ }
undo_op.type = Operation::TYPE_METHOD;
undo_op.name = p_method;
@@ -149,87 +142,92 @@ void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VAR
}
actions.write[current_action + 1].undo_ops.push_back(undo_op);
}
-void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, const Variant &p_value) {
+void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, const Variant &p_value) {
ERR_FAIL_COND(p_object == nullptr);
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
- if (Object::cast_to<Resource>(p_object))
+ if (Object::cast_to<Resource>(p_object)) {
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
+ }
do_op.type = Operation::TYPE_PROPERTY;
do_op.name = p_property;
do_op.args[0] = p_value;
actions.write[current_action + 1].do_ops.push_back(do_op);
}
-void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property, const Variant &p_value) {
+void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property, const Variant &p_value) {
ERR_FAIL_COND(p_object == nullptr);
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
// No undo if the merge mode is MERGE_ENDS
- if (merge_mode == MERGE_ENDS)
+ if (merge_mode == MERGE_ENDS) {
return;
+ }
Operation undo_op;
undo_op.object = p_object->get_instance_id();
- if (Object::cast_to<Resource>(p_object))
+ if (Object::cast_to<Resource>(p_object)) {
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
+ }
undo_op.type = Operation::TYPE_PROPERTY;
undo_op.name = p_property;
undo_op.args[0] = p_value;
actions.write[current_action + 1].undo_ops.push_back(undo_op);
}
-void UndoRedo::add_do_reference(Object *p_object) {
+void UndoRedo::add_do_reference(Object *p_object) {
ERR_FAIL_COND(p_object == nullptr);
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
- if (Object::cast_to<Resource>(p_object))
+ if (Object::cast_to<Resource>(p_object)) {
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
+ }
do_op.type = Operation::TYPE_REFERENCE;
actions.write[current_action + 1].do_ops.push_back(do_op);
}
-void UndoRedo::add_undo_reference(Object *p_object) {
+void UndoRedo::add_undo_reference(Object *p_object) {
ERR_FAIL_COND(p_object == nullptr);
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
// No undo if the merge mode is MERGE_ENDS
- if (merge_mode == MERGE_ENDS)
+ if (merge_mode == MERGE_ENDS) {
return;
+ }
Operation undo_op;
undo_op.object = p_object->get_instance_id();
- if (Object::cast_to<Resource>(p_object))
+ if (Object::cast_to<Resource>(p_object)) {
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
+ }
undo_op.type = Operation::TYPE_REFERENCE;
actions.write[current_action + 1].undo_ops.push_back(undo_op);
}
void UndoRedo::_pop_history_tail() {
-
_discard_redo();
- if (!actions.size())
+ if (!actions.size()) {
return;
+ }
for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) {
-
if (E->get().type == Operation::TYPE_REFERENCE) {
-
Object *obj = ObjectDB::get_instance(E->get().object);
- if (obj)
+ if (obj) {
memdelete(obj);
+ }
}
}
@@ -244,11 +242,11 @@ bool UndoRedo::is_committing_action() const {
}
void UndoRedo::commit_action() {
-
ERR_FAIL_COND(action_level <= 0);
action_level--;
- if (action_level > 0)
+ if (action_level > 0) {
return; //still nested
+ }
if (merging) {
version--;
@@ -264,19 +262,16 @@ void UndoRedo::commit_action() {
}
void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
-
for (; E; E = E->next()) {
-
Operation &op = E->get();
Object *obj = ObjectDB::get_instance(op.object);
- if (!obj) //may have been deleted and this is fine
+ if (!obj) { //may have been deleted and this is fine
continue;
+ }
switch (op.type) {
-
case Operation::TYPE_METHOD: {
-
Vector<const Variant *> argptrs;
argptrs.resize(VARIANT_ARG_MAX);
int argc = 0;
@@ -297,8 +292,9 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
}
#ifdef TOOLS_ENABLED
Resource *res = Object::cast_to<Resource>(obj);
- if (res)
+ if (res) {
res->set_edited(true);
+ }
#endif
@@ -307,12 +303,12 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
}
} break;
case Operation::TYPE_PROPERTY: {
-
obj->set(op.name, op.args[0]);
#ifdef TOOLS_ENABLED
Resource *res = Object::cast_to<Resource>(obj);
- if (res)
+ if (res) {
res->set_edited(true);
+ }
#endif
if (property_callback) {
property_callback(prop_callback_ud, obj, op.name, op.args[0]);
@@ -326,11 +322,11 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
}
bool UndoRedo::redo() {
-
ERR_FAIL_COND_V(action_level > 0, false);
- if ((current_action + 1) >= actions.size())
+ if ((current_action + 1) >= actions.size()) {
return false; //nothing to redo
+ }
current_action++;
@@ -342,10 +338,10 @@ bool UndoRedo::redo() {
}
bool UndoRedo::undo() {
-
ERR_FAIL_COND_V(action_level > 0, false);
- if (current_action < 0)
+ if (current_action < 0) {
return false; //nothing to redo
+ }
_process_operation_list(actions.write[current_action].undo_ops.front());
current_action--;
version--;
@@ -355,12 +351,12 @@ bool UndoRedo::undo() {
}
void UndoRedo::clear_history(bool p_increase_version) {
-
ERR_FAIL_COND(action_level > 0);
_discard_redo();
- while (actions.size())
+ while (actions.size()) {
_pop_history_tail();
+ }
if (p_increase_version) {
version++;
@@ -369,70 +365,45 @@ void UndoRedo::clear_history(bool p_increase_version) {
}
String UndoRedo::get_current_action_name() const {
-
ERR_FAIL_COND_V(action_level > 0, "");
- if (current_action < 0)
+ if (current_action < 0) {
return "";
+ }
return actions[current_action].name;
}
bool UndoRedo::has_undo() {
-
return current_action >= 0;
}
bool UndoRedo::has_redo() {
-
return (current_action + 1) < actions.size();
}
uint64_t UndoRedo::get_version() const {
-
return version;
}
void UndoRedo::set_commit_notify_callback(CommitNotifyCallback p_callback, void *p_ud) {
-
callback = p_callback;
callback_ud = p_ud;
}
void UndoRedo::set_method_notify_callback(MethodNotifyCallback p_method_callback, void *p_ud) {
-
method_callback = p_method_callback;
method_callbck_ud = p_ud;
}
void UndoRedo::set_property_notify_callback(PropertyNotifyCallback p_property_callback, void *p_ud) {
-
property_callback = p_property_callback;
prop_callback_ud = p_ud;
}
-UndoRedo::UndoRedo() {
-
- committing = 0;
- version = 1;
- action_level = 0;
- current_action = -1;
- merge_mode = MERGE_DISABLE;
- merging = false;
- callback = nullptr;
- callback_ud = nullptr;
-
- method_callbck_ud = nullptr;
- prop_callback_ud = nullptr;
- method_callback = nullptr;
- property_callback = nullptr;
-}
-
UndoRedo::~UndoRedo() {
-
clear_history();
}
Variant UndoRedo::_add_do_method(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 2) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 0;
@@ -461,7 +432,6 @@ Variant UndoRedo::_add_do_method(const Variant **p_args, int p_argcount, Callabl
Variant v[VARIANT_ARG_MAX];
for (int i = 0; i < MIN(VARIANT_ARG_MAX, p_argcount - 2); ++i) {
-
v[i] = *p_args[i + 2];
}
@@ -470,7 +440,6 @@ Variant UndoRedo::_add_do_method(const Variant **p_args, int p_argcount, Callabl
}
Variant UndoRedo::_add_undo_method(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 2) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 0;
@@ -499,7 +468,6 @@ Variant UndoRedo::_add_undo_method(const Variant **p_args, int p_argcount, Calla
Variant v[VARIANT_ARG_MAX];
for (int i = 0; i < MIN(VARIANT_ARG_MAX, p_argcount - 2); ++i) {
-
v[i] = *p_args[i + 2];
}
@@ -508,7 +476,6 @@ Variant UndoRedo::_add_undo_method(const Variant **p_args, int p_argcount, Calla
}
void UndoRedo::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create_action", "name", "merge_mode"), &UndoRedo::create_action, DEFVAL(MERGE_DISABLE));
ClassDB::bind_method(D_METHOD("commit_action"), &UndoRedo::commit_action);
ClassDB::bind_method(D_METHOD("is_committing_action"), &UndoRedo::is_committing_action);
diff --git a/core/undo_redo.h b/core/undo_redo.h
index 3b91e9ce36..b46f7ff867 100644
--- a/core/undo_redo.h
+++ b/core/undo_redo.h
@@ -35,7 +35,6 @@
#include "core/resource.h"
class UndoRedo : public Object {
-
GDCLASS(UndoRedo, Object);
OBJ_SAVE_TYPE(UndoRedo);
@@ -55,7 +54,6 @@ public:
private:
struct Operation {
-
enum Type {
TYPE_METHOD,
TYPE_PROPERTY,
@@ -77,25 +75,25 @@ private:
};
Vector<Action> actions;
- int current_action;
- int action_level;
- MergeMode merge_mode;
- bool merging;
- uint64_t version;
+ int current_action = -1;
+ int action_level = 0;
+ MergeMode merge_mode = MERGE_DISABLE;
+ bool merging = false;
+ uint64_t version = 1;
void _pop_history_tail();
void _process_operation_list(List<Operation>::Element *E);
void _discard_redo();
- CommitNotifyCallback callback;
- void *callback_ud;
- void *method_callbck_ud;
- void *prop_callback_ud;
+ CommitNotifyCallback callback = nullptr;
+ void *callback_ud = nullptr;
+ void *method_callbck_ud = nullptr;
+ void *prop_callback_ud = nullptr;
- MethodNotifyCallback method_callback;
- PropertyNotifyCallback property_callback;
+ MethodNotifyCallback method_callback = nullptr;
+ PropertyNotifyCallback property_callback = nullptr;
- int committing;
+ int committing = 0;
protected:
static void _bind_methods();
@@ -128,7 +126,7 @@ public:
void set_method_notify_callback(MethodNotifyCallback p_method_callback, void *p_ud);
void set_property_notify_callback(PropertyNotifyCallback p_property_callback, void *p_ud);
- UndoRedo();
+ UndoRedo() {}
~UndoRedo();
};
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 3e8a1ddbe3..444338d5ae 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -28,10 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef _MSC_VER
-#define _CRT_SECURE_NO_WARNINGS // to disable build-time warning which suggested to use strcpy_s instead strcpy
-#endif
-
#include "ustring.h"
#include "core/color.h"
@@ -51,6 +47,10 @@
#include <stdlib.h>
#endif
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS // to disable build-time warning which suggested to use strcpy_s instead strcpy
+#endif
+
#if defined(MINGW_ENABLED) || defined(_MSC_VER)
#define snprintf _snprintf_s
#endif
@@ -69,13 +69,11 @@ bool is_symbol(CharType c) {
}
bool select_word(const String &p_s, int p_col, int &r_beg, int &r_end) {
-
const String &s = p_s;
int beg = CLAMP(p_col, 0, s.length());
int end = beg;
if (s[beg] > 32 || beg == s.length()) {
-
bool symbol = beg < s.length() && is_symbol(s[beg]);
while (beg > 0 && s[beg - 1] > 32 && (symbol == is_symbol(s[beg - 1]))) {
@@ -85,15 +83,15 @@ bool select_word(const String &p_s, int p_col, int &r_beg, int &r_end) {
end++;
}
- if (end < s.length())
+ if (end < s.length()) {
end += 1;
+ }
r_beg = beg;
r_end = end;
return true;
} else {
-
return false;
}
}
@@ -101,7 +99,6 @@ bool select_word(const String &p_s, int p_col, int &r_beg, int &r_end) {
/** STRING **/
bool CharString::operator<(const CharString &p_right) const {
-
if (length() == 0) {
return p_right.length() != 0;
}
@@ -110,7 +107,6 @@ bool CharString::operator<(const CharString &p_right) const {
}
CharString &CharString::operator+=(char p_char) {
-
resize(size() ? size() + 1 : 2);
set(length(), 0);
set(length() - 1, p_char);
@@ -119,21 +115,19 @@ CharString &CharString::operator+=(char p_char) {
}
const char *CharString::get_data() const {
-
- if (size())
+ if (size()) {
return &operator[](0);
- else
+ } else {
return "";
+ }
}
CharString &CharString::operator=(const char *p_cstr) {
-
copy_from(p_cstr);
return *this;
}
void CharString::copy_from(const char *p_cstr) {
-
if (!p_cstr) {
resize(0);
return;
@@ -154,20 +148,18 @@ void CharString::copy_from(const char *p_cstr) {
}
void String::copy_from(const char *p_cstr) {
-
if (!p_cstr) {
-
resize(0);
return;
}
int len = 0;
const char *ptr = p_cstr;
- while (*(ptr++) != 0)
+ while (*(ptr++) != 0) {
len++;
+ }
if (len == 0) {
-
resize(0);
return;
}
@@ -177,26 +169,23 @@ void String::copy_from(const char *p_cstr) {
CharType *dst = this->ptrw();
for (int i = 0; i < len + 1; i++) {
-
dst[i] = p_cstr[i];
}
}
void String::copy_from(const CharType *p_cstr, const int p_clip_to) {
-
if (!p_cstr) {
-
resize(0);
return;
}
int len = 0;
const CharType *ptr = p_cstr;
- while ((p_clip_to < 0 || len < p_clip_to) && *(ptr++) != 0)
+ while ((p_clip_to < 0 || len < p_clip_to) && *(ptr++) != 0) {
len++;
+ }
if (len == 0) {
-
resize(0);
return;
}
@@ -220,18 +209,18 @@ void String::copy_from_unchecked(const CharType *p_char, const int p_length) {
}
void String::copy_from(const CharType &p_char) {
-
resize(2);
set(0, p_char);
set(1, 0);
}
bool String::operator==(const String &p_str) const {
-
- if (length() != p_str.length())
+ if (length() != p_str.length()) {
return false;
- if (empty())
+ }
+ if (empty()) {
return true;
+ }
int l = length();
@@ -240,43 +229,33 @@ bool String::operator==(const String &p_str) const {
/* Compare char by char */
for (int i = 0; i < l; i++) {
-
- if (src[i] != dst[i])
+ if (src[i] != dst[i]) {
return false;
+ }
}
return true;
}
bool String::operator!=(const String &p_str) const {
-
return !(*this == p_str);
}
String String::operator+(const String &p_str) const {
-
String res = *this;
res += p_str;
return res;
}
-/*
-String String::operator+(CharType p_chr) const {
-
- String res=*this;
- res+=p_chr;
- return res;
-}
-*/
String &String::operator+=(const String &p_str) {
-
if (empty()) {
*this = p_str;
return *this;
}
- if (p_str.empty())
+ if (p_str.empty()) {
return *this;
+ }
int from = length();
@@ -287,20 +266,19 @@ String &String::operator+=(const String &p_str) {
set(length(), 0);
- for (int i = 0; i < p_str.length(); i++)
+ for (int i = 0; i < p_str.length(); i++) {
dst[from + i] = src[i];
+ }
return *this;
}
String &String::operator+=(const CharType *p_str) {
-
*this += String(p_str);
return *this;
}
String &String::operator+=(CharType p_char) {
-
resize(size() ? size() + 1 : 2);
set(length(), 0);
set(length() - 1, p_char);
@@ -309,14 +287,15 @@ String &String::operator+=(CharType p_char) {
}
String &String::operator+=(const char *p_str) {
-
- if (!p_str || p_str[0] == 0)
+ if (!p_str || p_str[0] == 0) {
return *this;
+ }
int src_len = 0;
const char *ptr = p_str;
- while (*(ptr++) != 0)
+ while (*(ptr++) != 0) {
src_len++;
+ }
int from = length();
@@ -326,56 +305,58 @@ String &String::operator+=(const char *p_str) {
set(length(), 0);
- for (int i = 0; i < src_len; i++)
+ for (int i = 0; i < src_len; i++) {
dst[from + i] = p_str[i];
+ }
return *this;
}
void String::operator=(const char *p_str) {
-
copy_from(p_str);
}
void String::operator=(const CharType *p_str) {
-
copy_from(p_str);
}
bool String::operator==(const StrRange &p_str_range) const {
-
int len = p_str_range.len;
- if (length() != len)
+ if (length() != len) {
return false;
- if (empty())
+ }
+ if (empty()) {
return true;
+ }
const CharType *c_str = p_str_range.c_str;
const CharType *dst = &operator[](0);
/* Compare char by char */
for (int i = 0; i < len; i++) {
-
- if (c_str[i] != dst[i])
+ if (c_str[i] != dst[i]) {
return false;
+ }
}
return true;
}
bool String::operator==(const char *p_str) const {
-
int len = 0;
const char *aux = p_str;
- while (*(aux++) != 0)
+ while (*(aux++) != 0) {
len++;
+ }
- if (length() != len)
+ if (length() != len) {
return false;
- if (empty())
+ }
+ if (empty()) {
return true;
+ }
int l = length();
@@ -383,26 +364,28 @@ bool String::operator==(const char *p_str) const {
/* Compare char by char */
for (int i = 0; i < l; i++) {
-
- if (p_str[i] != dst[i])
+ if (p_str[i] != dst[i]) {
return false;
+ }
}
return true;
}
bool String::operator==(const CharType *p_str) const {
-
int len = 0;
const CharType *aux = p_str;
- while (*(aux++) != 0)
+ while (*(aux++) != 0) {
len++;
+ }
- if (length() != len)
+ if (length() != len) {
return false;
- if (empty())
+ }
+ if (empty()) {
return true;
+ }
int l = length();
@@ -410,78 +393,78 @@ bool String::operator==(const CharType *p_str) const {
/* Compare char by char */
for (int i = 0; i < l; i++) {
-
- if (p_str[i] != dst[i])
+ if (p_str[i] != dst[i]) {
return false;
+ }
}
return true;
}
bool String::operator!=(const char *p_str) const {
-
return (!(*this == p_str));
}
bool String::operator!=(const CharType *p_str) const {
-
return (!(*this == p_str));
}
bool String::operator<(const CharType *p_str) const {
-
- if (empty() && p_str[0] == 0)
+ if (empty() && p_str[0] == 0) {
return false;
- if (empty())
+ }
+ if (empty()) {
return true;
+ }
return is_str_less(c_str(), p_str);
}
bool String::operator<=(const String &p_str) const {
-
return (*this < p_str) || (*this == p_str);
}
bool String::operator<(const char *p_str) const {
-
- if (empty() && p_str[0] == 0)
+ if (empty() && p_str[0] == 0) {
return false;
- if (empty())
+ }
+ if (empty()) {
return true;
+ }
return is_str_less(c_str(), p_str);
}
bool String::operator<(const String &p_str) const {
-
return operator<(p_str.c_str());
}
signed char String::nocasecmp_to(const String &p_str) const {
-
- if (empty() && p_str.empty())
+ if (empty() && p_str.empty()) {
return 0;
- if (empty())
+ }
+ if (empty()) {
return -1;
- if (p_str.empty())
+ }
+ if (p_str.empty()) {
return 1;
+ }
const CharType *that_str = p_str.c_str();
const CharType *this_str = c_str();
while (true) {
-
- if (*that_str == 0 && *this_str == 0)
+ if (*that_str == 0 && *this_str == 0) {
return 0; //we're equal
- else if (*this_str == 0)
+ } else if (*this_str == 0) {
return -1; //if this is empty, and the other one is not, then we're less.. I think?
- else if (*that_str == 0)
+ } else if (*that_str == 0) {
return 1; //otherwise the other one is smaller..
- else if (_find_upper(*this_str) < _find_upper(*that_str)) //more than
+ } else if (_find_upper(*this_str) < _find_upper(*that_str)) { //more than
return -1;
- else if (_find_upper(*this_str) > _find_upper(*that_str)) //less than
+ } else if (_find_upper(*this_str) > _find_upper(*that_str)) { //less than
return 1;
+ }
this_str++;
that_str++;
@@ -489,29 +472,31 @@ signed char String::nocasecmp_to(const String &p_str) const {
}
signed char String::casecmp_to(const String &p_str) const {
-
- if (empty() && p_str.empty())
+ if (empty() && p_str.empty()) {
return 0;
- if (empty())
+ }
+ if (empty()) {
return -1;
- if (p_str.empty())
+ }
+ if (p_str.empty()) {
return 1;
+ }
const CharType *that_str = p_str.c_str();
const CharType *this_str = c_str();
while (true) {
-
- if (*that_str == 0 && *this_str == 0)
+ if (*that_str == 0 && *this_str == 0) {
return 0; //we're equal
- else if (*this_str == 0)
+ } else if (*this_str == 0) {
return -1; //if this is empty, and the other one is not, then we're less.. I think?
- else if (*that_str == 0)
+ } else if (*that_str == 0) {
return 1; //otherwise the other one is smaller..
- else if (*this_str < *that_str) //more than
+ } else if (*this_str < *that_str) { //more than
return -1;
- else if (*this_str > *that_str) //less than
+ } else if (*this_str > *that_str) { //less than
return 1;
+ }
this_str++;
that_str++;
@@ -519,84 +504,87 @@ signed char String::casecmp_to(const String &p_str) const {
}
signed char String::naturalnocasecmp_to(const String &p_str) const {
-
const CharType *this_str = c_str();
const CharType *that_str = p_str.c_str();
if (this_str && that_str) {
-
while (*this_str == '.' || *that_str == '.') {
- if (*this_str++ != '.')
+ if (*this_str++ != '.') {
return 1;
- if (*that_str++ != '.')
+ }
+ if (*that_str++ != '.') {
return -1;
- if (!*that_str)
+ }
+ if (!*that_str) {
return 1;
- if (!*this_str)
+ }
+ if (!*this_str) {
return -1;
+ }
}
while (*this_str) {
-
- if (!*that_str)
+ if (!*that_str) {
return 1;
- else if (IS_DIGIT(*this_str)) {
-
+ } else if (IS_DIGIT(*this_str)) {
int64_t this_int, that_int;
- if (!IS_DIGIT(*that_str))
+ if (!IS_DIGIT(*that_str)) {
return -1;
+ }
/* Compare the numbers */
this_int = to_int(this_str, -1, true);
that_int = to_int(that_str, -1, true);
- if (this_int < that_int)
+ if (this_int < that_int) {
return -1;
- else if (this_int > that_int)
+ } else if (this_int > that_int) {
return 1;
+ }
/* Skip */
- while (IS_DIGIT(*this_str))
+ while (IS_DIGIT(*this_str)) {
this_str++;
- while (IS_DIGIT(*that_str))
+ }
+ while (IS_DIGIT(*that_str)) {
that_str++;
- } else if (IS_DIGIT(*that_str))
+ }
+ } else if (IS_DIGIT(*that_str)) {
return 1;
- else {
- if (_find_upper(*this_str) < _find_upper(*that_str)) //more than
+ } else {
+ if (_find_upper(*this_str) < _find_upper(*that_str)) { //more than
return -1;
- else if (_find_upper(*this_str) > _find_upper(*that_str)) //less than
+ } else if (_find_upper(*this_str) > _find_upper(*that_str)) { //less than
return 1;
+ }
this_str++;
that_str++;
}
}
- if (*that_str)
+ if (*that_str) {
return -1;
+ }
}
return 0;
}
void String::erase(int p_pos, int p_chars) {
-
*this = left(p_pos) + substr(p_pos + p_chars, length() - ((p_pos + p_chars)));
}
String String::capitalize() const {
-
String aux = this->camelcase_to_underscore(true).replace("_", " ").strip_edges();
String cap;
for (int i = 0; i < aux.get_slice_count(" "); i++) {
-
String slice = aux.get_slicec(' ', i);
if (slice.length() > 0) {
-
slice[0] = _find_upper(slice[0]);
- if (i > 0)
+ if (i > 0) {
cap += " ";
+ }
cap += slice;
}
}
@@ -657,18 +645,19 @@ String String::get_with_code_lines() const {
}
return ret;
}
-int String::get_slice_count(String p_splitter) const {
- if (empty())
+int String::get_slice_count(String p_splitter) const {
+ if (empty()) {
return 0;
- if (p_splitter.empty())
+ }
+ if (p_splitter.empty()) {
return 0;
+ }
int pos = 0;
int slices = 1;
while ((pos = find(p_splitter, pos)) >= 0) {
-
slices++;
pos += p_splitter.length();
}
@@ -677,35 +666,37 @@ int String::get_slice_count(String p_splitter) const {
}
String String::get_slice(String p_splitter, int p_slice) const {
-
- if (empty() || p_splitter.empty())
+ if (empty() || p_splitter.empty()) {
return "";
+ }
int pos = 0;
int prev_pos = 0;
//int slices=1;
- if (p_slice < 0)
+ if (p_slice < 0) {
return "";
- if (find(p_splitter) == -1)
+ }
+ if (find(p_splitter) == -1) {
return *this;
+ }
int i = 0;
while (true) {
-
pos = find(p_splitter, pos);
- if (pos == -1)
+ if (pos == -1) {
pos = length(); //reached end
+ }
int from = prev_pos;
//int to=pos;
if (p_slice == i) {
-
return substr(from, pos - from);
}
- if (pos == length()) //reached end and no find
+ if (pos == length()) { //reached end and no find
break;
+ }
pos += p_splitter.length();
prev_pos = pos;
i++;
@@ -715,23 +706,21 @@ String String::get_slice(String p_splitter, int p_slice) const {
}
String String::get_slicec(CharType p_splitter, int p_slice) const {
-
- if (empty())
+ if (empty()) {
return String();
+ }
- if (p_slice < 0)
+ if (p_slice < 0) {
return String();
+ }
const CharType *c = this->ptr();
int i = 0;
int prev = 0;
int count = 0;
while (true) {
-
if (c[i] == 0 || c[i] == p_splitter) {
-
if (p_slice == count) {
-
return substr(prev, i - prev);
} else if (c[i] == 0) {
return String();
@@ -746,22 +735,22 @@ String String::get_slicec(CharType p_splitter, int p_slice) const {
}
Vector<String> String::split_spaces() const {
-
Vector<String> ret;
int from = 0;
int i = 0;
int len = length();
- if (len == 0)
+ if (len == 0) {
return ret;
+ }
bool inside = false;
while (true) {
-
bool empty = operator[](i) < 33;
- if (i == 0)
+ if (i == 0) {
inside = !empty;
+ }
if (!empty && !inside) {
inside = true;
@@ -769,13 +758,13 @@ Vector<String> String::split_spaces() const {
}
if (empty && inside) {
-
ret.push_back(substr(from, i - from));
inside = false;
}
- if (i == len)
+ if (i == len) {
break;
+ }
i++;
}
@@ -783,21 +772,19 @@ Vector<String> String::split_spaces() const {
}
Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p_maxsplit) const {
-
Vector<String> ret;
int from = 0;
int len = length();
while (true) {
-
int end = find(p_splitter, from);
- if (end < 0)
+ if (end < 0) {
end = len;
+ }
if (p_allow_empty || (end > from)) {
- if (p_maxsplit <= 0)
+ if (p_maxsplit <= 0) {
ret.push_back(substr(from, end - from));
- else {
-
+ } else {
// Put rest of the string and leave cycle.
if (p_maxsplit == ret.size()) {
ret.push_back(substr(from, len));
@@ -809,8 +796,9 @@ Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p
}
}
- if (end == len)
+ if (end == len) {
break;
+ }
from = end + p_splitter.length();
}
@@ -819,13 +807,11 @@ Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p
}
Vector<String> String::rsplit(const String &p_splitter, bool p_allow_empty, int p_maxsplit) const {
-
Vector<String> ret;
const int len = length();
int remaining_len = len;
while (true) {
-
if (remaining_len < p_splitter.length() || (p_maxsplit > 0 && p_maxsplit == ret.size())) {
// no room for another splitter or hit max splits, push what's left and we're done
if (p_allow_empty || remaining_len > 0) {
@@ -855,21 +841,22 @@ Vector<String> String::rsplit(const String &p_splitter, bool p_allow_empty, int
}
Vector<float> String::split_floats(const String &p_splitter, bool p_allow_empty) const {
-
Vector<float> ret;
int from = 0;
int len = length();
while (true) {
-
int end = find(p_splitter, from);
- if (end < 0)
+ if (end < 0) {
end = len;
- if (p_allow_empty || (end > from))
+ }
+ if (p_allow_empty || (end > from)) {
ret.push_back(String::to_double(&c_str()[from]));
+ }
- if (end == len)
+ if (end == len) {
break;
+ }
from = end + p_splitter.length();
}
@@ -878,13 +865,11 @@ Vector<float> String::split_floats(const String &p_splitter, bool p_allow_empty)
}
Vector<float> String::split_floats_mk(const Vector<String> &p_splitters, bool p_allow_empty) const {
-
Vector<float> ret;
int from = 0;
int len = length();
while (true) {
-
int idx;
int end = findmk(p_splitters, from, &idx);
int spl_len = 1;
@@ -898,8 +883,9 @@ Vector<float> String::split_floats_mk(const Vector<String> &p_splitters, bool p_
ret.push_back(String::to_double(&c_str()[from]));
}
- if (end == len)
+ if (end == len) {
break;
+ }
from = end + spl_len;
}
@@ -908,21 +894,22 @@ Vector<float> String::split_floats_mk(const Vector<String> &p_splitters, bool p_
}
Vector<int> String::split_ints(const String &p_splitter, bool p_allow_empty) const {
-
Vector<int> ret;
int from = 0;
int len = length();
while (true) {
-
int end = find(p_splitter, from);
- if (end < 0)
+ if (end < 0) {
end = len;
- if (p_allow_empty || (end > from))
+ }
+ if (p_allow_empty || (end > from)) {
ret.push_back(String::to_int(&c_str()[from], end - from));
+ }
- if (end == len)
+ if (end == len) {
break;
+ }
from = end + p_splitter.length();
}
@@ -931,13 +918,11 @@ Vector<int> String::split_ints(const String &p_splitter, bool p_allow_empty) con
}
Vector<int> String::split_ints_mk(const Vector<String> &p_splitters, bool p_allow_empty) const {
-
Vector<int> ret;
int from = 0;
int len = length();
while (true) {
-
int idx;
int end = findmk(p_splitters, from, &idx);
int spl_len = 1;
@@ -947,11 +932,13 @@ Vector<int> String::split_ints_mk(const Vector<String> &p_splitters, bool p_allo
spl_len = p_splitters[idx].length();
}
- if (p_allow_empty || (end > from))
+ if (p_allow_empty || (end > from)) {
ret.push_back(String::to_int(&c_str()[from], end - from));
+ }
- if (end == len)
+ if (end == len) {
break;
+ }
from = end + spl_len;
}
@@ -971,47 +958,42 @@ String String::join(Vector<String> parts) {
}
CharType String::char_uppercase(CharType p_char) {
-
return _find_upper(p_char);
}
CharType String::char_lowercase(CharType p_char) {
-
return _find_lower(p_char);
}
String String::to_upper() const {
-
String upper = *this;
for (int i = 0; i < upper.size(); i++) {
-
const CharType s = upper[i];
const CharType t = _find_upper(s);
- if (s != t) // avoid copy on write
+ if (s != t) { // avoid copy on write
upper[i] = t;
+ }
}
return upper;
}
String String::to_lower() const {
-
String lower = *this;
for (int i = 0; i < lower.size(); i++) {
-
const CharType s = lower[i];
const CharType t = _find_lower(s);
- if (s != t) // avoid copy on write
+ if (s != t) { // avoid copy on write
lower[i] = t;
+ }
}
return lower;
}
const CharType *String::c_str() const {
-
static const CharType zero = 0;
return size() ? &operator[](0) : &zero;
@@ -1038,23 +1020,22 @@ String String::hex_encode_buffer(const uint8_t *p_buffer, int p_len) {
}
String String::chr(CharType p_char) {
-
CharType c[2] = { p_char, 0 };
return String(c);
}
-String String::num(double p_num, int p_decimals) {
+String String::num(double p_num, int p_decimals) {
#ifndef NO_USE_STDLIB
- if (p_decimals > 16)
+ if (p_decimals > 16) {
p_decimals = 16;
+ }
char fmt[7];
fmt[0] = '%';
fmt[1] = '.';
if (p_decimals < 0) {
-
fmt[1] = 'l';
fmt[2] = 'f';
fmt[3] = 0;
@@ -1082,28 +1063,24 @@ String String::num(double p_num, int p_decimals) {
buf[255] = 0;
//destroy trailing zeroes
{
-
bool period = false;
int z = 0;
while (buf[z]) {
- if (buf[z] == '.')
+ if (buf[z] == '.') {
period = true;
+ }
z++;
}
if (period) {
z--;
while (z > 0) {
-
if (buf[z] == '0') {
-
buf[z] = 0;
} else if (buf[z] == '.') {
-
buf[z] = 0;
break;
} else {
-
break;
}
@@ -1126,7 +1103,6 @@ String String::num(double p_num, int p_decimals) {
/* decimal part */
if (p_decimals > 0 || (p_decimals == -1 && (int)p_num != p_num)) {
-
double dec = p_num - (float)((int)p_num);
int digit = 0;
@@ -1137,14 +1113,12 @@ String String::num(double p_num, int p_decimals) {
int dec_max = 0;
while (true) {
-
dec *= 10.0;
dec_int = dec_int * 10 + (int)dec % 10;
dec_max = dec_max * 10 + 9;
digit++;
if (p_decimals == -1) {
-
if (digit == MAX_DIGITS) //no point in going to infinite
break;
@@ -1160,18 +1134,15 @@ String String::num(double p_num, int p_decimals) {
if (last > 5) {
if (dec_int == dec_max) {
-
dec_int = 0;
intn++;
} else {
-
dec_int++;
}
}
String decimal;
for (int i = 0; i < digit; i++) {
-
char num[2] = { 0, 0 };
num[0] = '0' + dec_int % 10;
decimal = num + decimal;
@@ -1185,7 +1156,6 @@ String String::num(double p_num, int p_decimals) {
s = "0";
else {
while (intn) {
-
CharType num = '0' + (intn % 10);
intn /= 10;
s = num + s;
@@ -1200,7 +1170,6 @@ String String::num(double p_num, int p_decimals) {
}
String String::num_int64(int64_t p_num, int base, bool capitalize_hex) {
-
bool sign = p_num < 0;
int64_t n = p_num;
@@ -1211,8 +1180,9 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) {
chars++;
} while (n);
- if (sign)
+ if (sign) {
chars++;
+ }
String s;
s.resize(chars + 1);
CharType *c = s.ptrw();
@@ -1230,14 +1200,14 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) {
n /= base;
} while (n);
- if (sign)
+ if (sign) {
c[0] = '-';
+ }
return s;
}
String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) {
-
uint64_t n = p_num;
int chars = 0;
@@ -1267,7 +1237,6 @@ String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) {
}
String String::num_real(double p_num) {
-
String s;
String sd;
/* integer part */
@@ -1279,7 +1248,6 @@ String String::num_real(double p_num) {
/* decimal part */
if ((int)p_num != p_num) {
-
double dec = p_num - (float)((int)p_num);
int digit = 0;
@@ -1289,17 +1257,18 @@ String String::num_real(double p_num) {
int dec_max = 0;
while (true) {
-
dec *= 10.0;
dec_int = dec_int * 10 + (int)dec % 10;
dec_max = dec_max * 10 + 9;
digit++;
- if ((dec - (float)((int)dec)) < 1e-6)
+ if ((dec - (float)((int)dec)) < 1e-6) {
break;
+ }
- if (digit == decimals)
+ if (digit == decimals) {
break;
+ }
}
dec *= 10;
@@ -1307,18 +1276,15 @@ String String::num_real(double p_num) {
if (last > 5) {
if (dec_int == dec_max) {
-
dec_int = 0;
intn++;
} else {
-
dec_int++;
}
}
String decimal;
for (int i = 0; i < digit; i++) {
-
char num[2] = { 0, 0 };
num[0] = '0' + dec_int % 10;
decimal = num + decimal;
@@ -1329,12 +1295,10 @@ String String::num_real(double p_num) {
sd = ".0";
}
- if (intn == 0)
-
+ if (intn == 0) {
s = "0";
- else {
+ } else {
while (intn) {
-
CharType num = '0' + (intn % 10);
intn /= 10;
s = num + s;
@@ -1342,13 +1306,13 @@ String String::num_real(double p_num) {
}
s = s + sd;
- if (neg)
+ if (neg) {
s = "-" + s;
+ }
return s;
}
String String::num_scientific(double p_num) {
-
#ifndef NO_USE_STDLIB
char buf[256];
@@ -1379,33 +1343,33 @@ String String::num_scientific(double p_num) {
}
CharString String::ascii(bool p_allow_extended) const {
-
- if (!length())
+ if (!length()) {
return CharString();
+ }
CharString cs;
cs.resize(size());
- for (int i = 0; i < size(); i++)
+ for (int i = 0; i < size(); i++) {
cs[i] = operator[](i);
+ }
return cs;
}
String String::utf8(const char *p_utf8, int p_len) {
-
String ret;
ret.parse_utf8(p_utf8, p_len);
return ret;
-};
+}
bool String::parse_utf8(const char *p_utf8, int p_len) {
-
#define _UNICERROR(m_err) print_line("Unicode parsing error: " + String(m_err) + ". Is the string valid UTF-8?");
- if (!p_utf8)
+ if (!p_utf8) {
return true;
+ }
String aux;
@@ -1414,13 +1378,12 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
/* HANDLE BOM (Byte Order Mark) */
if (p_len < 0 || p_len >= 3) {
-
bool has_bom = uint8_t(p_utf8[0]) == 0xEF && uint8_t(p_utf8[1]) == 0xBB && uint8_t(p_utf8[2]) == 0xBF;
if (has_bom) {
-
//just skip it
- if (p_len >= 0)
+ if (p_len >= 0) {
p_len -= 3;
+ }
p_utf8 += 3;
}
}
@@ -1430,25 +1393,23 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
const char *ptrtmp_limit = &p_utf8[p_len];
int skip = 0;
while (ptrtmp != ptrtmp_limit && *ptrtmp) {
-
if (skip == 0) {
-
uint8_t c = *ptrtmp >= 0 ? *ptrtmp : uint8_t(256 + *ptrtmp);
/* Determine the number of characters in sequence */
- if ((c & 0x80) == 0)
+ if ((c & 0x80) == 0) {
skip = 0;
- else if ((c & 0xE0) == 0xC0)
+ } else if ((c & 0xE0) == 0xC0) {
skip = 1;
- else if ((c & 0xF0) == 0xE0)
+ } else if ((c & 0xF0) == 0xE0) {
skip = 2;
- else if ((c & 0xF8) == 0xF0)
+ } else if ((c & 0xF8) == 0xF0) {
skip = 3;
- else if ((c & 0xFC) == 0xF8)
+ } else if ((c & 0xFC) == 0xF8) {
skip = 4;
- else if ((c & 0xFE) == 0xFC)
+ } else if ((c & 0xFE) == 0xFC) {
skip = 5;
- else {
+ } else {
_UNICERROR("invalid skip");
return true; //invalid utf8
}
@@ -1462,7 +1423,6 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
str_size++;
} else {
-
--skip;
}
@@ -1486,23 +1446,22 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
dst[str_size] = 0;
while (cstr_size) {
-
int len = 0;
/* Determine the number of characters in sequence */
- if ((*p_utf8 & 0x80) == 0)
+ if ((*p_utf8 & 0x80) == 0) {
len = 1;
- else if ((*p_utf8 & 0xE0) == 0xC0)
+ } else if ((*p_utf8 & 0xE0) == 0xC0) {
len = 2;
- else if ((*p_utf8 & 0xF0) == 0xE0)
+ } else if ((*p_utf8 & 0xF0) == 0xE0) {
len = 3;
- else if ((*p_utf8 & 0xF8) == 0xF0)
+ } else if ((*p_utf8 & 0xF8) == 0xF0) {
len = 4;
- else if ((*p_utf8 & 0xFC) == 0xF8)
+ } else if ((*p_utf8 & 0xFC) == 0xF8) {
len = 5;
- else if ((*p_utf8 & 0xFE) == 0xFC)
+ } else if ((*p_utf8 & 0xFE) == 0xFC) {
len = 6;
- else {
+ } else {
_UNICERROR("invalid len");
return true; //invalid UTF8
@@ -1523,14 +1482,12 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
uint32_t unichar = 0;
- if (len == 1)
+ if (len == 1) {
unichar = *p_utf8;
- else {
-
+ } else {
unichar = (0xFF >> (len + 1)) & *p_utf8;
for (int i = 1; i < len; i++) {
-
if ((p_utf8[i] & 0xC0) != 0x80) {
_UNICERROR("invalid utf8");
return true; //invalid utf8
@@ -1557,19 +1514,18 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
}
CharString String::utf8() const {
-
int l = length();
- if (!l)
+ if (!l) {
return CharString();
+ }
const CharType *d = &operator[](0);
int fl = 0;
for (int i = 0; i < l; i++) {
-
uint32_t c = d[i];
- if (c <= 0x7f) // 7 bits.
+ if (c <= 0x7f) { // 7 bits.
fl += 1;
- else if (c <= 0x7ff) { // 11 bits
+ } else if (c <= 0x7ff) { // 11 bits
fl += 2;
} else if (c <= 0xffff) { // 16 bits
fl += 3;
@@ -1594,12 +1550,11 @@ CharString String::utf8() const {
#define APPEND_CHAR(m_c) *(cdst++) = m_c
for (int i = 0; i < l; i++) {
-
uint32_t c = d[i];
- if (c <= 0x7f) // 7 bits.
+ if (c <= 0x7f) { // 7 bits.
APPEND_CHAR(c);
- else if (c <= 0x7ff) { // 11 bits
+ } else if (c <= 0x7ff) { // 11 bits
APPEND_CHAR(uint32_t(0xc0 | ((c >> 6) & 0x1f))); // Top 5 bits.
APPEND_CHAR(uint32_t(0x80 | (c & 0x3f))); // Bottom 6 bits.
@@ -1643,30 +1598,30 @@ String::String(CharType p_char) {
shared=nullptr;
copy_from(p_char);
}
+
+
*/
String::String(const char *p_str) {
-
copy_from(p_str);
}
String::String(const CharType *p_str, int p_clip_to_len) {
-
copy_from(p_str, p_clip_to_len);
}
String::String(const StrRange &p_range) {
-
- if (!p_range.c_str)
+ if (!p_range.c_str) {
return;
+ }
copy_from(p_range.c_str, p_range.len);
}
int String::hex_to_int(bool p_with_prefix) const {
-
- if (p_with_prefix && length() < 3)
+ if (p_with_prefix && length() < 3) {
return 0;
+ }
const CharType *s = ptr();
@@ -1677,15 +1632,15 @@ int String::hex_to_int(bool p_with_prefix) const {
}
if (p_with_prefix) {
- if (s[0] != '0' || s[1] != 'x')
+ if (s[0] != '0' || s[1] != 'x') {
return 0;
+ }
s += 2;
}
int hex = 0;
while (*s) {
-
CharType c = LOWERCASE(*s);
int n;
if (c >= '0' && c <= '9') {
@@ -1706,9 +1661,9 @@ int String::hex_to_int(bool p_with_prefix) const {
}
int64_t String::hex_to_int64(bool p_with_prefix) const {
-
- if (p_with_prefix && length() < 3)
+ if (p_with_prefix && length() < 3) {
return 0;
+ }
const CharType *s = ptr();
@@ -1719,15 +1674,15 @@ int64_t String::hex_to_int64(bool p_with_prefix) const {
}
if (p_with_prefix) {
- if (s[0] != '0' || s[1] != 'x')
+ if (s[0] != '0' || s[1] != 'x') {
return 0;
+ }
s += 2;
}
int64_t hex = 0;
while (*s) {
-
CharType c = LOWERCASE(*s);
int64_t n;
if (c >= '0' && c <= '9') {
@@ -1748,9 +1703,9 @@ int64_t String::hex_to_int64(bool p_with_prefix) const {
}
int64_t String::bin_to_int64(bool p_with_prefix) const {
-
- if (p_with_prefix && length() < 3)
+ if (p_with_prefix && length() < 3) {
return 0;
+ }
const CharType *s = ptr();
@@ -1761,15 +1716,15 @@ int64_t String::bin_to_int64(bool p_with_prefix) const {
}
if (p_with_prefix) {
- if (s[0] != '0' || s[1] != 'b')
+ if (s[0] != '0' || s[1] != 'b') {
return 0;
+ }
s += 2;
}
int64_t binary = 0;
while (*s) {
-
CharType c = LOWERCASE(*s);
int64_t n;
if (c == '0' || c == '1') {
@@ -1788,9 +1743,9 @@ int64_t String::bin_to_int64(bool p_with_prefix) const {
}
int String::to_int() const {
-
- if (length() == 0)
+ if (length() == 0) {
return 0;
+ }
int to = (find(".") >= 0) ? find(".") : length();
@@ -1798,16 +1753,13 @@ int String::to_int() const {
int sign = 1;
for (int i = 0; i < to; i++) {
-
CharType c = operator[](i);
if (c >= '0' && c <= '9') {
-
ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
integer += c - '0';
} else if (integer == 0 && c == '-') {
-
sign = -sign;
}
}
@@ -1816,9 +1768,9 @@ int String::to_int() const {
}
int64_t String::to_int64() const {
-
- if (length() == 0)
+ if (length() == 0) {
return 0;
+ }
int to = (find(".") >= 0) ? find(".") : length();
@@ -1826,16 +1778,13 @@ int64_t String::to_int64() const {
int64_t sign = 1;
for (int i = 0; i < to; i++) {
-
CharType c = operator[](i);
if (c >= '0' && c <= '9') {
-
ERR_FAIL_COND_V_MSG(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
integer += c - '0';
} else if (integer == 0 && c == '-') {
-
sign = -sign;
}
}
@@ -1844,63 +1793,60 @@ int64_t String::to_int64() const {
}
int String::to_int(const char *p_str, int p_len) {
-
int to = 0;
- if (p_len >= 0)
+ if (p_len >= 0) {
to = p_len;
- else {
- while (p_str[to] != 0 && p_str[to] != '.')
+ } else {
+ while (p_str[to] != 0 && p_str[to] != '.') {
to++;
+ }
}
int integer = 0;
int sign = 1;
for (int i = 0; i < to; i++) {
-
char c = p_str[i];
if (c >= '0' && c <= '9') {
-
ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
integer *= 10;
integer += c - '0';
} else if (c == '-' && integer == 0) {
-
sign = -sign;
- } else if (c != ' ')
+ } else if (c != ' ') {
break;
+ }
}
return integer * sign;
}
bool String::is_numeric() const {
-
if (length() == 0) {
return false;
- };
+ }
int s = 0;
- if (operator[](0) == '-')
+ if (operator[](0) == '-') {
++s;
+ }
bool dot = false;
for (int i = s; i < length(); i++) {
-
CharType c = operator[](i);
if (c == '.') {
if (dot) {
return false;
- };
+ }
dot = true;
}
if (c < '0' || c > '9') {
return false;
- };
- };
+ }
+ }
return true; // TODO: Use the parser below for this instead
-};
+}
template <class C>
static double built_in_strtod(const C *string, /* A decimal ASCII floating-point number,
@@ -1917,7 +1863,6 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
C **endPtr = nullptr) /* If non-nullptr, store terminating Cacter's
* address here. */
{
-
static const int maxExponent = 511; /* Largest possible base 10 exponent. Any
* exponent larger than this will already
* produce underflow or overflow, so there's
@@ -2119,7 +2064,6 @@ done:
#define READING_DONE 4
double String::to_double(const char *p_str) {
-
#ifndef NO_USE_STDLIB
return built_in_strtod<char>(p_str);
//return atof(p_str); DOES NOT WORK ON ANDROID(??)
@@ -2129,19 +2073,17 @@ double String::to_double(const char *p_str) {
}
float String::to_float() const {
-
return to_double();
}
double String::to_double(const CharType *p_str, const CharType **r_end) {
-
return built_in_strtod<CharType>(p_str, (CharType **)r_end);
}
int64_t String::to_int(const CharType *p_str, int p_len, bool p_clamp) {
-
- if (p_len == 0 || !p_str[0])
+ if (p_len == 0 || !p_str[0]) {
return 0;
+ }
///@todo make more exact so saving and loading does not lose precision
int64_t integer = 0;
@@ -2152,7 +2094,6 @@ int64_t String::to_int(const CharType *p_str, int p_len, bool p_clamp) {
const CharType *limit = &p_str[p_len];
while (*str && reading != READING_DONE && str != limit) {
-
CharType c = *(str++);
switch (reading) {
case READING_SIGN: {
@@ -2173,9 +2114,7 @@ int64_t String::to_int(const CharType *p_str, int p_len, bool p_clamp) {
[[fallthrough]];
}
case READING_INT: {
-
if (c >= '0' && c <= '9') {
-
if (integer > INT64_MAX / 10) {
String number("");
str = p_str;
@@ -2206,9 +2145,9 @@ int64_t String::to_int(const CharType *p_str, int p_len, bool p_clamp) {
}
double String::to_double() const {
-
- if (empty())
+ if (empty()) {
return 0;
+ }
#ifndef NO_USE_STDLIB
return built_in_strtod<CharType>(c_str());
//return wcstod(c_str(),nullptr ); DOES NOT WORK ON ANDROID :(
@@ -2218,91 +2157,88 @@ double String::to_double() const {
}
bool operator==(const char *p_chr, const String &p_str) {
-
return p_str == p_chr;
}
String operator+(const char *p_chr, const String &p_str) {
-
String tmp = p_chr;
tmp += p_str;
return tmp;
}
-String operator+(CharType p_chr, const String &p_str) {
+String operator+(CharType p_chr, const String &p_str) {
return (String::chr(p_chr) + p_str);
}
uint32_t String::hash(const char *p_cstr) {
-
uint32_t hashv = 5381;
uint32_t c;
- while ((c = *p_cstr++))
+ while ((c = *p_cstr++)) {
hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */
+ }
return hashv;
}
uint32_t String::hash(const char *p_cstr, int p_len) {
-
uint32_t hashv = 5381;
- for (int i = 0; i < p_len; i++)
+ for (int i = 0; i < p_len; i++) {
hashv = ((hashv << 5) + hashv) + p_cstr[i]; /* hash * 33 + c */
+ }
return hashv;
}
uint32_t String::hash(const CharType *p_cstr, int p_len) {
-
uint32_t hashv = 5381;
- for (int i = 0; i < p_len; i++)
+ for (int i = 0; i < p_len; i++) {
hashv = ((hashv << 5) + hashv) + p_cstr[i]; /* hash * 33 + c */
+ }
return hashv;
}
uint32_t String::hash(const CharType *p_cstr) {
-
uint32_t hashv = 5381;
uint32_t c;
- while ((c = *p_cstr++))
+ while ((c = *p_cstr++)) {
hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */
+ }
return hashv;
}
uint32_t String::hash() const {
-
/* simple djb2 hashing */
const CharType *chr = c_str();
uint32_t hashv = 5381;
uint32_t c;
- while ((c = *chr++))
+ while ((c = *chr++)) {
hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */
+ }
return hashv;
}
uint64_t String::hash64() const {
-
/* simple djb2 hashing */
const CharType *chr = c_str();
uint64_t hashv = 5381;
uint64_t c;
- while ((c = *chr++))
+ while ((c = *chr++)) {
hashv = ((hashv << 5) + hashv) + c; /* hash * 33 + c */
+ }
return hashv;
}
String String::md5_text() const {
-
CharString cs = utf8();
unsigned char hash[16];
CryptoCore::md5((unsigned char *)cs.ptr(), cs.length(), hash);
@@ -2324,7 +2260,6 @@ String String::sha256_text() const {
}
Vector<uint8_t> String::md5_buffer() const {
-
CharString cs = utf8();
unsigned char hash[16];
CryptoCore::md5((unsigned char *)cs.ptr(), cs.length(), hash);
@@ -2335,7 +2270,7 @@ Vector<uint8_t> String::md5_buffer() const {
ret.write[i] = hash[i];
}
return ret;
-};
+}
Vector<uint8_t> String::sha1_buffer() const {
CharString cs = utf8();
@@ -2365,38 +2300,41 @@ Vector<uint8_t> String::sha256_buffer() const {
}
String String::insert(int p_at_pos, const String &p_string) const {
-
- if (p_at_pos < 0)
+ if (p_at_pos < 0) {
return *this;
+ }
- if (p_at_pos > length())
+ if (p_at_pos > length()) {
p_at_pos = length();
+ }
String pre;
- if (p_at_pos > 0)
+ if (p_at_pos > 0) {
pre = substr(0, p_at_pos);
+ }
String post;
- if (p_at_pos < length())
+ if (p_at_pos < length()) {
post = substr(p_at_pos, length() - p_at_pos);
+ }
return pre + p_string + post;
}
-String String::substr(int p_from, int p_chars) const {
- if (p_chars == -1)
+String String::substr(int p_from, int p_chars) const {
+ if (p_chars == -1) {
p_chars = length() - p_from;
+ }
- if (empty() || p_from < 0 || p_from >= length() || p_chars <= 0)
+ if (empty() || p_from < 0 || p_from >= length() || p_chars <= 0) {
return "";
+ }
if ((p_from + p_chars) > length()) {
-
p_chars = length() - p_from;
}
if (p_from == 0 && p_chars >= length()) {
-
return String(*this);
}
@@ -2406,12 +2344,10 @@ String String::substr(int p_from, int p_chars) const {
}
int String::find_last(const String &p_str) const {
-
int pos = -1;
int findfrom = 0;
int findres = -1;
while ((findres = find(p_str, findfrom)) != -1) {
-
pos = findres;
findfrom = pos + 1;
}
@@ -2420,32 +2356,30 @@ int String::find_last(const String &p_str) const {
}
int String::find(const String &p_str, int p_from) const {
-
- if (p_from < 0)
+ if (p_from < 0) {
return -1;
+ }
const int src_len = p_str.length();
const int len = length();
- if (src_len == 0 || len == 0)
+ if (src_len == 0 || len == 0) {
return -1; // won't find anything!
+ }
const CharType *src = c_str();
const CharType *str = p_str.c_str();
for (int i = p_from; i <= (len - src_len); i++) {
-
bool found = true;
for (int j = 0; j < src_len; j++) {
-
int read_pos = i + j;
if (read_pos >= len) {
-
ERR_PRINT("read_pos>=len");
return -1;
- };
+ }
if (src[read_pos] != str[j]) {
found = false;
@@ -2453,54 +2387,51 @@ int String::find(const String &p_str, int p_from) const {
}
}
- if (found)
+ if (found) {
return i;
+ }
}
return -1;
}
int String::find(const char *p_str, int p_from) const {
-
- if (p_from < 0)
+ if (p_from < 0) {
return -1;
+ }
const int len = length();
- if (len == 0)
+ if (len == 0) {
return -1; // won't find anything!
+ }
const CharType *src = c_str();
int src_len = 0;
- while (p_str[src_len] != '\0')
+ while (p_str[src_len] != '\0') {
src_len++;
+ }
if (src_len == 1) {
-
const char needle = p_str[0];
for (int i = p_from; i < len; i++) {
-
if (src[i] == needle) {
return i;
}
}
} else {
-
for (int i = p_from; i <= (len - src_len); i++) {
-
bool found = true;
for (int j = 0; j < src_len; j++) {
-
int read_pos = i + j;
if (read_pos >= len) {
-
ERR_PRINT("read_pos>=len");
return -1;
- };
+ }
if (src[read_pos] != p_str[j]) {
found = false;
@@ -2508,8 +2439,9 @@ int String::find(const char *p_str, int p_from) const {
}
}
- if (found)
+ if (found) {
return i;
+ }
}
}
@@ -2521,83 +2453,82 @@ int String::find_char(const CharType &p_char, int p_from) const {
}
int String::findmk(const Vector<String> &p_keys, int p_from, int *r_key) const {
-
- if (p_from < 0)
+ if (p_from < 0) {
return -1;
- if (p_keys.size() == 0)
+ }
+ if (p_keys.size() == 0) {
return -1;
+ }
//int src_len=p_str.length();
const String *keys = &p_keys[0];
int key_count = p_keys.size();
int len = length();
- if (len == 0)
+ if (len == 0) {
return -1; // won't find anything!
+ }
const CharType *src = c_str();
for (int i = p_from; i < len; i++) {
-
bool found = true;
for (int k = 0; k < key_count; k++) {
-
found = true;
- if (r_key)
+ if (r_key) {
*r_key = k;
+ }
const CharType *cmp = keys[k].c_str();
int l = keys[k].length();
for (int j = 0; j < l; j++) {
-
int read_pos = i + j;
if (read_pos >= len) {
-
found = false;
break;
- };
+ }
if (src[read_pos] != cmp[j]) {
found = false;
break;
}
}
- if (found)
+ if (found) {
break;
+ }
}
- if (found)
+ if (found) {
return i;
+ }
}
return -1;
}
int String::findn(const String &p_str, int p_from) const {
-
- if (p_from < 0)
+ if (p_from < 0) {
return -1;
+ }
int src_len = p_str.length();
- if (src_len == 0 || length() == 0)
+ if (src_len == 0 || length() == 0) {
return -1; // won't find anything!
+ }
const CharType *srcd = c_str();
for (int i = p_from; i <= (length() - src_len); i++) {
-
bool found = true;
for (int j = 0; j < src_len; j++) {
-
int read_pos = i + j;
if (read_pos >= length()) {
-
ERR_PRINT("read_pos>=length()");
return -1;
- };
+ }
CharType src = _find_lower(srcd[read_pos]);
CharType dst = _find_lower(p_str[j]);
@@ -2608,46 +2539,46 @@ int String::findn(const String &p_str, int p_from) const {
}
}
- if (found)
+ if (found) {
return i;
+ }
}
return -1;
}
int String::rfind(const String &p_str, int p_from) const {
-
// establish a limit
int limit = length() - p_str.length();
- if (limit < 0)
+ if (limit < 0) {
return -1;
+ }
// establish a starting point
- if (p_from < 0)
+ if (p_from < 0) {
p_from = limit;
- else if (p_from > limit)
+ } else if (p_from > limit) {
p_from = limit;
+ }
int src_len = p_str.length();
int len = length();
- if (src_len == 0 || len == 0)
+ if (src_len == 0 || len == 0) {
return -1; // won't find anything!
+ }
const CharType *src = c_str();
for (int i = p_from; i >= 0; i--) {
-
bool found = true;
for (int j = 0; j < src_len; j++) {
-
int read_pos = i + j;
if (read_pos >= len) {
-
ERR_PRINT("read_pos>=len");
return -1;
- };
+ }
if (src[read_pos] != p_str[j]) {
found = false;
@@ -2655,45 +2586,46 @@ int String::rfind(const String &p_str, int p_from) const {
}
}
- if (found)
+ if (found) {
return i;
+ }
}
return -1;
}
-int String::rfindn(const String &p_str, int p_from) const {
+int String::rfindn(const String &p_str, int p_from) const {
// establish a limit
int limit = length() - p_str.length();
- if (limit < 0)
+ if (limit < 0) {
return -1;
+ }
// establish a starting point
- if (p_from < 0)
+ if (p_from < 0) {
p_from = limit;
- else if (p_from > limit)
+ } else if (p_from > limit) {
p_from = limit;
+ }
int src_len = p_str.length();
int len = length();
- if (src_len == 0 || len == 0)
+ if (src_len == 0 || len == 0) {
return -1; // won't find anything!
+ }
const CharType *src = c_str();
for (int i = p_from; i >= 0; i--) {
-
bool found = true;
for (int j = 0; j < src_len; j++) {
-
int read_pos = i + j;
if (read_pos >= len) {
-
ERR_PRINT("read_pos>=len");
return -1;
- };
+ }
CharType srcc = _find_lower(src[read_pos]);
CharType dstc = _find_lower(p_str[j]);
@@ -2704,56 +2636,59 @@ int String::rfindn(const String &p_str, int p_from) const {
}
}
- if (found)
+ if (found) {
return i;
+ }
}
return -1;
}
bool String::ends_with(const String &p_string) const {
-
int pos = find_last(p_string);
- if (pos == -1)
+ if (pos == -1) {
return false;
+ }
return pos + p_string.length() == length();
}
bool String::begins_with(const String &p_string) const {
-
- if (p_string.length() > length())
+ if (p_string.length() > length()) {
return false;
+ }
int l = p_string.length();
- if (l == 0)
+ if (l == 0) {
return true;
+ }
const CharType *src = &p_string[0];
const CharType *str = &operator[](0);
int i = 0;
for (; i < l; i++) {
-
- if (src[i] != str[i])
+ if (src[i] != str[i]) {
return false;
+ }
}
// only if i == l the p_string matches the beginning
return i == l;
}
-bool String::begins_with(const char *p_string) const {
+bool String::begins_with(const char *p_string) const {
int l = length();
- if (l == 0 || !p_string)
+ if (l == 0 || !p_string) {
return false;
+ }
const CharType *str = &operator[](0);
int i = 0;
while (*p_string && i < l) {
-
- if (*p_string != str[i])
+ if (*p_string != str[i]) {
return false;
+ }
i++;
p_string++;
}
@@ -2762,22 +2697,18 @@ bool String::begins_with(const char *p_string) const {
}
bool String::is_enclosed_in(const String &p_string) const {
-
return begins_with(p_string) && ends_with(p_string);
}
bool String::is_subsequence_of(const String &p_string) const {
-
return _base_is_subsequence_of(p_string, false);
}
bool String::is_subsequence_ofi(const String &p_string) const {
-
return _base_is_subsequence_of(p_string, true);
}
bool String::is_quoted() const {
-
return is_enclosed_in("\"") || is_enclosed_in("'");
}
@@ -2827,7 +2758,6 @@ int String::countn(const String &p_string, int p_from, int p_to) const {
}
bool String::_base_is_subsequence_of(const String &p_string, bool case_insensitive) const {
-
int len = length();
if (len == 0) {
// Technically an empty string is subsequence of any string
@@ -2920,22 +2850,21 @@ static bool _wildcard_match(const CharType *p_pattern, const CharType *p_string,
}
bool String::match(const String &p_wildcard) const {
-
- if (!p_wildcard.length() || !length())
+ if (!p_wildcard.length() || !length()) {
return false;
+ }
return _wildcard_match(p_wildcard.c_str(), c_str(), true);
}
bool String::matchn(const String &p_wildcard) const {
-
- if (!p_wildcard.length() || !length())
+ if (!p_wildcard.length() || !length()) {
return false;
+ }
return _wildcard_match(p_wildcard.c_str(), c_str(), false);
}
String String::format(const Variant &values, String placeholder) const {
-
String new_string = String(this->ptr());
if (values.get_type() == Variant::ARRAY) {
@@ -3007,20 +2936,17 @@ String String::format(const Variant &values, String placeholder) const {
}
String String::replace(const String &p_key, const String &p_with) const {
-
String new_string;
int search_from = 0;
int result = 0;
while ((result = find(p_key, search_from)) >= 0) {
-
new_string += substr(search_from, result - search_from);
new_string += p_with;
search_from = result + p_key.length();
}
if (search_from == 0) {
-
return *this;
}
@@ -3030,23 +2956,21 @@ String String::replace(const String &p_key, const String &p_with) const {
}
String String::replace(const char *p_key, const char *p_with) const {
-
String new_string;
int search_from = 0;
int result = 0;
while ((result = find(p_key, search_from)) >= 0) {
-
new_string += substr(search_from, result - search_from);
new_string += p_with;
int k = 0;
- while (p_key[k] != '\0')
+ while (p_key[k] != '\0') {
k++;
+ }
search_from = result + k;
}
if (search_from == 0) {
-
return *this;
}
@@ -3056,7 +2980,6 @@ String String::replace(const char *p_key, const char *p_with) const {
}
String String::replace_first(const String &p_key, const String &p_with) const {
-
int pos = find(p_key);
if (pos >= 0) {
return substr(0, pos) + p_with + substr(pos + p_key.length(), length());
@@ -3064,21 +2987,19 @@ String String::replace_first(const String &p_key, const String &p_with) const {
return *this;
}
-String String::replacen(const String &p_key, const String &p_with) const {
+String String::replacen(const String &p_key, const String &p_with) const {
String new_string;
int search_from = 0;
int result = 0;
while ((result = findn(p_key, search_from)) >= 0) {
-
new_string += substr(search_from, result - search_from);
new_string += p_with;
search_from = result + p_key.length();
}
if (search_from == 0) {
-
return *this;
}
@@ -3087,7 +3008,6 @@ String String::replacen(const String &p_key, const String &p_with) const {
}
String String::repeat(int p_count) const {
-
ERR_FAIL_COND_V_MSG(p_count < 0, "", "Parameter count should be a positive number.");
String new_string;
@@ -3095,43 +3015,45 @@ String String::repeat(int p_count) const {
new_string.resize(length() * p_count + 1);
- for (int i = 0; i < p_count; i++)
- for (int j = 0; j < length(); j++)
+ for (int i = 0; i < p_count; i++) {
+ for (int j = 0; j < length(); j++) {
new_string[i * length() + j] = src[j];
+ }
+ }
return new_string;
}
String String::left(int p_pos) const {
-
- if (p_pos <= 0)
+ if (p_pos <= 0) {
return "";
+ }
- if (p_pos >= length())
+ if (p_pos >= length()) {
return *this;
+ }
return substr(0, p_pos);
}
String String::right(int p_pos) const {
-
- if (p_pos >= length())
+ if (p_pos >= length()) {
return "";
+ }
- if (p_pos <= 0)
+ if (p_pos <= 0) {
return *this;
+ }
return substr(p_pos, (length() - p_pos));
}
CharType String::ord_at(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, length(), 0);
return operator[](p_idx);
}
String String::dedent() const {
-
String new_string;
String indent;
bool has_indent = false;
@@ -3140,11 +3062,11 @@ String String::dedent() const {
int indent_stop = -1;
for (int i = 0; i < length(); i++) {
-
CharType c = operator[](i);
if (c == '\n') {
- if (has_text)
+ if (has_text) {
new_string += substr(indent_stop, i - indent_stop);
+ }
new_string += "\n";
has_text = false;
line_start = i + 1;
@@ -3160,57 +3082,58 @@ String String::dedent() const {
}
if (has_indent && indent_stop < 0) {
int j = i - line_start;
- if (j >= indent.length() || c != indent[j])
+ if (j >= indent.length() || c != indent[j]) {
indent_stop = i;
+ }
}
}
}
- if (has_text)
+ if (has_text) {
new_string += substr(indent_stop, length() - indent_stop);
+ }
return new_string;
}
String String::strip_edges(bool left, bool right) const {
-
int len = length();
int beg = 0, end = len;
if (left) {
for (int i = 0; i < len; i++) {
-
- if (operator[](i) <= 32)
+ if (operator[](i) <= 32) {
beg++;
- else
+ } else {
break;
+ }
}
}
if (right) {
for (int i = (int)(len - 1); i >= 0; i--) {
-
- if (operator[](i) <= 32)
+ if (operator[](i) <= 32) {
end--;
- else
+ } else {
break;
+ }
}
}
- if (beg == 0 && end == len)
+ if (beg == 0 && end == len) {
return *this;
+ }
return substr(beg, end - beg);
}
String String::strip_escapes() const {
-
String new_string;
for (int i = 0; i < length(); i++) {
-
// Escape characters on first page of the ASCII table, before 32 (Space).
- if (operator[](i) < 32)
+ if (operator[](i) < 32) {
continue;
+ }
new_string += operator[](i);
}
@@ -3218,65 +3141,60 @@ String String::strip_escapes() const {
}
String String::lstrip(const String &p_chars) const {
-
int len = length();
int beg;
for (beg = 0; beg < len; beg++) {
-
- if (p_chars.find_char(get(beg)) == -1)
+ if (p_chars.find_char(get(beg)) == -1) {
break;
+ }
}
- if (beg == 0)
+ if (beg == 0) {
return *this;
+ }
return substr(beg, len - beg);
}
String String::rstrip(const String &p_chars) const {
-
int len = length();
int end;
for (end = len - 1; end >= 0; end--) {
-
- if (p_chars.find_char(get(end)) == -1)
+ if (p_chars.find_char(get(end)) == -1) {
break;
+ }
}
- if (end == len - 1)
+ if (end == len - 1) {
return *this;
+ }
return substr(0, end + 1);
}
String String::simplify_path() const {
-
String s = *this;
String drive;
if (s.begins_with("local://")) {
drive = "local://";
s = s.substr(8, s.length());
} else if (s.begins_with("res://")) {
-
drive = "res://";
s = s.substr(6, s.length());
} else if (s.begins_with("user://")) {
-
drive = "user://";
s = s.substr(7, s.length());
} else if (s.begins_with("/") || s.begins_with("\\")) {
-
drive = s.substr(0, 1);
s = s.substr(1, s.length() - 1);
} else {
-
int p = s.find(":/");
- if (p == -1)
+ if (p == -1) {
p = s.find(":\\");
+ }
if (p != -1 && p < s.find("/")) {
-
drive = s.substr(0, p + 2);
s = s.substr(p + 2, s.length());
}
@@ -3285,21 +3203,20 @@ String String::simplify_path() const {
s = s.replace("\\", "/");
while (true) { // in case of using 2 or more slash
String compare = s.replace("//", "/");
- if (s == compare)
+ if (s == compare) {
break;
- else
+ } else {
s = compare;
+ }
}
Vector<String> dirs = s.split("/", false);
for (int i = 0; i < dirs.size(); i++) {
-
String d = dirs[i];
if (d == ".") {
dirs.remove(i);
i--;
} else if (d == "..") {
-
if (i == 0) {
dirs.remove(i);
i--;
@@ -3314,9 +3231,9 @@ String String::simplify_path() const {
s = "";
for (int i = 0; i < dirs.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
s += "/";
+ }
s += dirs[i];
}
@@ -3324,17 +3241,16 @@ String String::simplify_path() const {
}
static int _humanize_digits(int p_num) {
-
- if (p_num < 100)
+ if (p_num < 100) {
return 2;
- else if (p_num < 1024)
+ } else if (p_num < 1024) {
return 1;
- else
+ } else {
return 0;
+ }
}
String String::humanize_size(uint64_t p_size) {
-
uint64_t _div = 1;
Vector<String> prefixes;
prefixes.push_back(RTR("B"));
@@ -3357,36 +3273,38 @@ String String::humanize_size(uint64_t p_size) {
return String::num(p_size / divisor).pad_decimals(digits) + " " + prefixes[prefix_idx];
}
-bool String::is_abs_path() const {
- if (length() > 1)
+bool String::is_abs_path() const {
+ if (length() > 1) {
return (operator[](0) == '/' || operator[](0) == '\\' || find(":/") != -1 || find(":\\") != -1);
- else if ((length()) == 1)
+ } else if ((length()) == 1) {
return (operator[](0) == '/' || operator[](0) == '\\');
- else
+ } else {
return false;
+ }
}
bool String::is_valid_identifier() const {
-
int len = length();
- if (len == 0)
+ if (len == 0) {
return false;
+ }
const wchar_t *str = &operator[](0);
for (int i = 0; i < len; i++) {
-
if (i == 0) {
- if (str[0] >= '0' && str[0] <= '9')
+ if (str[0] >= '0' && str[0] <= '9') {
return false; // no start with number plz
+ }
}
bool valid_char = (str[i] >= '0' && str[i] <= '9') || (str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z') || str[i] == '_';
- if (!valid_char)
+ if (!valid_char) {
return false;
+ }
}
return true;
@@ -3395,7 +3313,6 @@ bool String::is_valid_identifier() const {
//kind of poor should be rewritten properly
String String::word_wrap(int p_chars_per_line) const {
-
int from = 0;
int last_space = 0;
String ret;
@@ -3472,7 +3389,6 @@ String String::http_unescape() const {
}
String String::c_unescape() const {
-
String escaped = *this;
escaped = escaped.replace("\\a", "\a");
escaped = escaped.replace("\\b", "\b");
@@ -3490,7 +3406,6 @@ String String::c_unescape() const {
}
String String::c_escape() const {
-
String escaped = *this;
escaped = escaped.replace("\\", "\\\\");
escaped = escaped.replace("\a", "\\a");
@@ -3508,7 +3423,6 @@ String String::c_escape() const {
}
String String::c_escape_multiline() const {
-
String escaped = *this;
escaped = escaped.replace("\\", "\\\\");
escaped = escaped.replace("\"", "\\\"");
@@ -3517,7 +3431,6 @@ String String::c_escape_multiline() const {
}
String String::json_escape() const {
-
String escaped = *this;
escaped = escaped.replace("\\", "\\\\");
escaped = escaped.replace("\b", "\\b");
@@ -3532,7 +3445,6 @@ String String::json_escape() const {
}
String String::xml_escape(bool p_escape_quotes) const {
-
String str = *this;
str = str.replace("&", "&amp;");
str = str.replace("<", "&lt;");
@@ -3542,29 +3454,24 @@ String String::xml_escape(bool p_escape_quotes) const {
str = str.replace("\"", "&quot;");
}
/*
- for (int i=1;i<32;i++) {
+for (int i=1;i<32;i++) {
- char chr[2]={i,0};
- str=str.replace(chr,"&#"+String::num(i)+";");
- }*/
+ char chr[2]={i,0};
+ str=str.replace(chr,"&#"+String::num(i)+";");
+}*/
return str;
}
static _FORCE_INLINE_ int _xml_unescape(const CharType *p_src, int p_src_len, CharType *p_dst) {
-
int len = 0;
while (p_src_len) {
-
if (*p_src == '&') {
-
int eat = 0;
if (p_src_len >= 4 && p_src[1] == '#') {
-
CharType c = 0;
for (int i = 2; i < p_src_len; i++) {
-
eat = i + 1;
CharType ct = p_src[i];
if (ct == ';') {
@@ -3582,49 +3489,50 @@ static _FORCE_INLINE_ int _xml_unescape(const CharType *p_src, int p_src_len, Ch
c |= ct;
}
- if (p_dst)
+ if (p_dst) {
*p_dst = c;
+ }
} else if (p_src_len >= 4 && p_src[1] == 'g' && p_src[2] == 't' && p_src[3] == ';') {
-
- if (p_dst)
+ if (p_dst) {
*p_dst = '>';
+ }
eat = 4;
} else if (p_src_len >= 4 && p_src[1] == 'l' && p_src[2] == 't' && p_src[3] == ';') {
-
- if (p_dst)
+ if (p_dst) {
*p_dst = '<';
+ }
eat = 4;
} else if (p_src_len >= 5 && p_src[1] == 'a' && p_src[2] == 'm' && p_src[3] == 'p' && p_src[4] == ';') {
-
- if (p_dst)
+ if (p_dst) {
*p_dst = '&';
+ }
eat = 5;
} else if (p_src_len >= 6 && p_src[1] == 'q' && p_src[2] == 'u' && p_src[3] == 'o' && p_src[4] == 't' && p_src[5] == ';') {
-
- if (p_dst)
+ if (p_dst) {
*p_dst = '"';
+ }
eat = 6;
} else if (p_src_len >= 6 && p_src[1] == 'a' && p_src[2] == 'p' && p_src[3] == 'o' && p_src[4] == 's' && p_src[5] == ';') {
-
- if (p_dst)
+ if (p_dst) {
*p_dst = '\'';
+ }
eat = 6;
} else {
-
- if (p_dst)
+ if (p_dst) {
*p_dst = *p_src;
+ }
eat = 1;
}
- if (p_dst)
+ if (p_dst) {
p_dst++;
+ }
len++;
p_src += eat;
p_src_len -= eat;
} else {
-
if (p_dst) {
*p_dst = *p_src;
p_dst++;
@@ -3639,12 +3547,12 @@ static _FORCE_INLINE_ int _xml_unescape(const CharType *p_src, int p_src_len, Ch
}
String String::xml_unescape() const {
-
String str;
int l = length();
int len = _xml_unescape(c_str(), l, nullptr);
- if (len == 0)
+ if (len == 0) {
return String();
+ }
str.resize(len + 1);
_xml_unescape(c_str(), l, str.ptrw());
str[len] = 0;
@@ -3652,7 +3560,6 @@ String String::xml_unescape() const {
}
String String::pad_decimals(int p_digits) const {
-
String s = *this;
int c = s.find(".");
@@ -3679,7 +3586,6 @@ String String::pad_decimals(int p_digits) const {
}
String String::pad_zeros(int p_digits) const {
-
String s = *this;
int end = s.find(".");
@@ -3687,8 +3593,9 @@ String String::pad_zeros(int p_digits) const {
end = s.length();
}
- if (end == 0)
+ if (end == 0) {
return s;
+ }
int begin = 0;
@@ -3696,11 +3603,11 @@ String String::pad_zeros(int p_digits) const {
begin++;
}
- if (begin >= end)
+ if (begin >= end) {
return s;
+ }
while (end - begin < p_digits) {
-
s = s.insert(begin, "0");
end++;
}
@@ -3709,7 +3616,6 @@ String String::pad_zeros(int p_digits) const {
}
String String::trim_prefix(const String &p_prefix) const {
-
String s = *this;
if (s.begins_with(p_prefix)) {
return s.substr(p_prefix.length(), s.length() - p_prefix.length());
@@ -3718,7 +3624,6 @@ String String::trim_prefix(const String &p_prefix) const {
}
String String::trim_suffix(const String &p_suffix) const {
-
String s = *this;
if (s.ends_with(p_suffix)) {
return s.substr(0, s.length() - p_suffix.length());
@@ -3727,40 +3632,42 @@ String String::trim_suffix(const String &p_suffix) const {
}
bool String::is_valid_integer() const {
-
int len = length();
- if (len == 0)
+ if (len == 0) {
return false;
+ }
int from = 0;
- if (len != 1 && (operator[](0) == '+' || operator[](0) == '-'))
+ if (len != 1 && (operator[](0) == '+' || operator[](0) == '-')) {
from++;
+ }
for (int i = from; i < len; i++) {
-
- if (operator[](i) < '0' || operator[](i) > '9')
+ if (operator[](i) < '0' || operator[](i) > '9') {
return false; // no start with number plz
+ }
}
return true;
}
bool String::is_valid_hex_number(bool p_with_prefix) const {
-
int len = length();
- if (len == 0)
+ if (len == 0) {
return false;
+ }
int from = 0;
- if (len != 1 && (operator[](0) == '+' || operator[](0) == '-'))
+ if (len != 1 && (operator[](0) == '+' || operator[](0) == '-')) {
from++;
+ }
if (p_with_prefix) {
-
- if (len < 3)
+ if (len < 3) {
return false;
+ }
if (operator[](from) != '0' || operator[](from + 1) != 'x') {
return false;
}
@@ -3768,22 +3675,22 @@ bool String::is_valid_hex_number(bool p_with_prefix) const {
}
for (int i = from; i < len; i++) {
-
CharType c = operator[](i);
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
+ if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
continue;
+ }
return false;
}
return true;
-};
+}
bool String::is_valid_float() const {
-
int len = length();
- if (len == 0)
+ if (len == 0) {
return false;
+ }
int from = 0;
if (operator[](0) == '+' || operator[](0) == '-') {
@@ -3797,71 +3704,70 @@ bool String::is_valid_float() const {
bool numbers_found = false;
for (int i = from; i < len; i++) {
-
if (operator[](i) >= '0' && operator[](i) <= '9') {
-
- if (exponent_found)
+ if (exponent_found) {
exponent_values_found = true;
- else
+ } else {
numbers_found = true;
+ }
} else if (numbers_found && !exponent_found && operator[](i) == 'e') {
exponent_found = true;
} else if (!period_found && !exponent_found && operator[](i) == '.') {
period_found = true;
} else if ((operator[](i) == '-' || operator[](i) == '+') && exponent_found && !exponent_values_found && !sign_found) {
sign_found = true;
- } else
+ } else {
return false; // no start with number plz
+ }
}
return numbers_found;
}
String String::path_to_file(const String &p_path) const {
-
// Don't get base dir for src, this is expected to be a dir already.
String src = this->replace("\\", "/");
String dst = p_path.replace("\\", "/").get_base_dir();
String rel = src.path_to(dst);
- if (rel == dst) // failed
+ if (rel == dst) { // failed
return p_path;
- else
+ } else {
return rel + p_path.get_file();
+ }
}
String String::path_to(const String &p_path) const {
-
String src = this->replace("\\", "/");
String dst = p_path.replace("\\", "/");
- if (!src.ends_with("/"))
+ if (!src.ends_with("/")) {
src += "/";
- if (!dst.ends_with("/"))
+ }
+ if (!dst.ends_with("/")) {
dst += "/";
+ }
String base;
if (src.begins_with("res://") && dst.begins_with("res://")) {
-
base = "res:/";
src = src.replace("res://", "/");
dst = dst.replace("res://", "/");
} else if (src.begins_with("user://") && dst.begins_with("user://")) {
-
base = "user:/";
src = src.replace("user://", "/");
dst = dst.replace("user://", "/");
} else if (src.begins_with("/") && dst.begins_with("/")) {
-
//nothing
} else {
//dos style
String src_begin = src.get_slicec('/', 0);
String dst_begin = dst.get_slicec('/', 0);
- if (src_begin != dst_begin)
+ if (src_begin != dst_begin) {
return p_path; //impossible to do this
+ }
base = src_begin;
src = src.substr(src_begin.length(), src.length());
@@ -3876,12 +3782,15 @@ String String::path_to(const String &p_path) const {
int common_parent = 0;
while (true) {
- if (src_dirs.size() == common_parent)
+ if (src_dirs.size() == common_parent) {
break;
- if (dst_dirs.size() == common_parent)
+ }
+ if (dst_dirs.size() == common_parent) {
break;
- if (src_dirs[common_parent] != dst_dirs[common_parent])
+ }
+ if (src_dirs[common_parent] != dst_dirs[common_parent]) {
break;
+ }
common_parent++;
}
@@ -3890,27 +3799,24 @@ String String::path_to(const String &p_path) const {
String dir;
for (int i = src_dirs.size() - 1; i > common_parent; i--) {
-
dir += "../";
}
for (int i = common_parent + 1; i < dst_dirs.size(); i++) {
-
dir += dst_dirs[i] + "/";
}
- if (dir.length() == 0)
+ if (dir.length() == 0) {
dir = "./";
+ }
return dir;
}
bool String::is_valid_html_color() const {
-
return Color::html_is_valid(*this);
}
bool String::is_valid_filename() const {
-
String stripped = strip_edges();
if (*this != stripped) {
return false;
@@ -3924,55 +3830,54 @@ bool String::is_valid_filename() const {
}
bool String::is_valid_ip_address() const {
-
if (find(":") >= 0) {
-
Vector<String> ip = split(":");
for (int i = 0; i < ip.size(); i++) {
-
String n = ip[i];
- if (n.empty())
+ if (n.empty()) {
continue;
+ }
if (n.is_valid_hex_number(false)) {
int nint = n.hex_to_int(false);
- if (nint < 0 || nint > 0xffff)
+ if (nint < 0 || nint > 0xffff) {
return false;
+ }
continue;
- };
- if (!n.is_valid_ip_address())
+ }
+ if (!n.is_valid_ip_address()) {
return false;
- };
+ }
+ }
} else {
Vector<String> ip = split(".");
- if (ip.size() != 4)
+ if (ip.size() != 4) {
return false;
+ }
for (int i = 0; i < ip.size(); i++) {
-
String n = ip[i];
- if (!n.is_valid_integer())
+ if (!n.is_valid_integer()) {
return false;
+ }
int val = n.to_int();
- if (val < 0 || val > 255)
+ if (val < 0 || val > 255) {
return false;
+ }
}
- };
+ }
return true;
}
bool String::is_resource_file() const {
-
return begins_with("res://") && find("::") == -1;
}
bool String::is_rel_path() const {
-
return !is_abs_path();
}
String String::get_base_dir() const {
-
int basepos = find("://");
String rs;
String base;
@@ -3985,52 +3890,52 @@ String String::get_base_dir() const {
rs = substr(1, length());
base = "/";
} else {
-
rs = *this;
}
}
int sep = MAX(rs.find_last("/"), rs.find_last("\\"));
- if (sep == -1)
+ if (sep == -1) {
return base;
+ }
return base + rs.substr(0, sep);
}
String String::get_file() const {
-
int sep = MAX(find_last("/"), find_last("\\"));
- if (sep == -1)
+ if (sep == -1) {
return *this;
+ }
return substr(sep + 1, length());
}
String String::get_extension() const {
-
int pos = find_last(".");
- if (pos < 0 || pos < MAX(find_last("/"), find_last("\\")))
+ if (pos < 0 || pos < MAX(find_last("/"), find_last("\\"))) {
return "";
+ }
return substr(pos + 1, length());
}
String String::plus_file(const String &p_file) const {
- if (empty())
+ if (empty()) {
return p_file;
- if (operator[](length() - 1) == '/' || (p_file.size() > 0 && p_file.operator[](0) == '/'))
+ }
+ if (operator[](length() - 1) == '/' || (p_file.size() > 0 && p_file.operator[](0) == '/')) {
return *this + p_file;
+ }
return *this + "/" + p_file;
}
String String::percent_encode() const {
-
CharString cs = utf8();
String encoded;
for (int i = 0; i < cs.length(); i++) {
uint8_t c = cs[i];
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '~' || c == '.') {
-
char p[2] = { (char)c, 0 };
encoded += p;
} else {
@@ -4045,34 +3950,34 @@ String String::percent_encode() const {
return encoded;
}
-String String::percent_decode() const {
+String String::percent_decode() const {
CharString pe;
CharString cs = utf8();
for (int i = 0; i < cs.length(); i++) {
-
uint8_t c = cs[i];
if (c == '%' && i < length() - 2) {
-
uint8_t a = LOWERCASE(cs[i + 1]);
uint8_t b = LOWERCASE(cs[i + 2]);
- if (a >= '0' && a <= '9')
+ if (a >= '0' && a <= '9') {
c = (a - '0') << 4;
- else if (a >= 'a' && a <= 'f')
+ } else if (a >= 'a' && a <= 'f') {
c = (a - 'a' + 10) << 4;
- else
+ } else {
continue;
+ }
uint8_t d = 0;
- if (b >= '0' && b <= '9')
+ if (b >= '0' && b <= '9') {
d = (b - '0');
- else if (b >= 'a' && b <= 'f')
+ } else if (b >= 'a' && b <= 'f') {
d = (b - 'a' + 10);
- else
+ } else {
continue;
+ }
c += d;
i += 2;
}
@@ -4096,31 +4001,27 @@ String String::property_name_encode() const {
}
String String::get_basename() const {
-
int pos = find_last(".");
- if (pos < 0 || pos < MAX(find_last("/"), find_last("\\")))
+ if (pos < 0 || pos < MAX(find_last("/"), find_last("\\"))) {
return *this;
+ }
return substr(0, pos);
}
String itos(int64_t p_val) {
-
return String::num_int64(p_val);
}
String uitos(uint64_t p_val) {
-
return String::num_uint64(p_val);
}
String rtos(double p_val) {
-
return String::num(p_val);
}
String rtoss(double p_val) {
-
return String::num_scientific(p_val);
}
@@ -4129,19 +4030,22 @@ String String::rpad(int min_length, const String &character) const {
String s = *this;
int padding = min_length - s.length();
if (padding > 0) {
- for (int i = 0; i < padding; i++)
+ for (int i = 0; i < padding; i++) {
s = s + character;
+ }
}
return s;
}
+
// Left-pad with a character.
String String::lpad(int min_length, const String &character) const {
String s = *this;
int padding = min_length - s.length();
if (padding > 0) {
- for (int i = 0; i < padding; i++)
+ for (int i = 0; i < padding; i++) {
s = character + s;
+ }
}
return s;
@@ -4239,27 +4143,40 @@ String String::sprintf(const Array &values, bool *error) const {
}
double value = values[value_index];
- String str = String::num(value, min_decimals);
+ bool is_negative = (value < 0);
+ String str = String::num(ABS(value), min_decimals);
// Pad decimals out.
str = str.pad_decimals(min_decimals);
- // Show sign
- if (show_sign && str.left(1) != "-") {
- str = str.insert(0, "+");
- }
+ int initial_len = str.length();
- // Padding
+ // Padding. Leave room for sign later if required.
+ int pad_chars_count = (is_negative || show_sign) ? min_chars - 1 : min_chars;
+ String pad_char = pad_with_zeroes ? String("0") : String(" ");
if (left_justified) {
- str = str.rpad(min_chars);
+ if (pad_with_zeroes) {
+ return "left justification cannot be used with zeros as the padding";
+ } else {
+ str = str.rpad(pad_chars_count, pad_char);
+ }
} else {
- str = str.lpad(min_chars);
+ str = str.lpad(pad_chars_count, pad_char);
+ }
+
+ // Add sign if needed.
+ if (show_sign || is_negative) {
+ String sign_char = is_negative ? "-" : "+";
+ if (left_justified) {
+ str = str.insert(0, sign_char);
+ } else {
+ str = str.insert(pad_with_zeroes ? 0 : str.length() - initial_len, sign_char);
+ }
}
formatted += str;
++value_index;
in_format = false;
-
break;
}
case 's': { // String
@@ -4434,13 +4351,14 @@ String TTR(const String &p_text) {
}
String DTR(const String &p_text) {
+ // Comes straight from the XML, so remove indentation and any trailing whitespace.
+ const String text = p_text.dedent().strip_edges();
+
if (TranslationServer::get_singleton()) {
- // Comes straight from the XML, so remove indentation and any trailing whitespace.
- const String text = p_text.dedent().strip_edges();
return TranslationServer::get_singleton()->doc_translate(text);
}
- return p_text;
+ return text;
}
#endif
diff --git a/core/ustring.h b/core/ustring.h
index 15bc2b323c..5b13a1c704 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -51,8 +51,9 @@ class CharProxy {
public:
_FORCE_INLINE_ operator T() const {
- if (unlikely(_index == _cowdata.size()))
+ if (unlikely(_index == _cowdata.size())) {
return _null;
+ }
return _cowdata.get(_index);
}
@@ -71,7 +72,6 @@ public:
};
class CharString {
-
CowData<char> _cowdata;
static const char _null;
@@ -84,8 +84,9 @@ public:
_FORCE_INLINE_ char get(int p_index) const { return _cowdata.get(p_index); }
_FORCE_INLINE_ void set(int p_index, const char &p_elem) { _cowdata.set(p_index, p_elem); }
_FORCE_INLINE_ const char &operator[](int p_index) const {
- if (unlikely(p_index == _cowdata.size()))
+ if (unlikely(p_index == _cowdata.size())) {
return _null;
+ }
return _cowdata.get(p_index);
}
@@ -113,7 +114,6 @@ protected:
typedef wchar_t CharType;
struct StrRange {
-
const CharType *c_str;
int len;
@@ -124,7 +124,6 @@ struct StrRange {
};
class String {
-
CowData<CharType> _cowdata;
static const CharType _null;
@@ -154,8 +153,9 @@ public:
Error resize(int p_size) { return _cowdata.resize(p_size); }
_FORCE_INLINE_ const CharType &operator[](int p_index) const {
- if (unlikely(p_index == _cowdata.size()))
+ if (unlikely(p_index == _cowdata.size())) {
return _null;
+ }
return _cowdata.get(p_index);
}
@@ -377,36 +377,31 @@ String rtos(double p_val);
String rtoss(double p_val); //scientific version
struct NoCaseComparator {
-
bool operator()(const String &p_a, const String &p_b) const {
-
return p_a.nocasecmp_to(p_b) < 0;
}
};
struct NaturalNoCaseComparator {
-
bool operator()(const String &p_a, const String &p_b) const {
-
return p_a.naturalnocasecmp_to(p_b) < 0;
}
};
template <typename L, typename R>
_FORCE_INLINE_ bool is_str_less(const L *l_ptr, const R *r_ptr) {
-
while (true) {
-
- if (*l_ptr == 0 && *r_ptr == 0)
+ if (*l_ptr == 0 && *r_ptr == 0) {
return false;
- else if (*l_ptr == 0)
+ } else if (*l_ptr == 0) {
return true;
- else if (*r_ptr == 0)
+ } else if (*r_ptr == 0) {
return false;
- else if (*l_ptr < *r_ptr)
+ } else if (*l_ptr < *r_ptr) {
return true;
- else if (*l_ptr > *r_ptr)
+ } else if (*l_ptr > *r_ptr) {
return false;
+ }
l_ptr++;
r_ptr++;
diff --git a/core/variant.cpp b/core/variant.cpp
index 2eacb5d58c..21aaa0fe9e 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -41,172 +41,136 @@
#include "scene/main/node.h"
String Variant::get_type_name(Variant::Type p_type) {
-
switch (p_type) {
case NIL: {
-
return "Nil";
} break;
// atomic types
case BOOL: {
-
return "bool";
} break;
case INT: {
-
return "int";
} break;
case FLOAT: {
-
return "float";
} break;
case STRING: {
-
return "String";
} break;
// math types
case VECTOR2: {
-
return "Vector2";
} break;
case VECTOR2I: {
-
return "Vector2i";
} break;
case RECT2: {
-
return "Rect2";
} break;
case RECT2I: {
-
return "Rect2i";
} break;
case TRANSFORM2D: {
-
return "Transform2D";
} break;
case VECTOR3: {
-
return "Vector3";
} break;
case VECTOR3I: {
-
return "Vector3i";
} break;
case PLANE: {
-
return "Plane";
} break;
case AABB: {
-
return "AABB";
} break;
case QUAT: {
-
return "Quat";
} break;
case BASIS: {
-
return "Basis";
} break;
case TRANSFORM: {
-
return "Transform";
} break;
// misc types
case COLOR: {
-
return "Color";
} break;
case _RID: {
-
return "RID";
} break;
case OBJECT: {
-
return "Object";
} break;
case CALLABLE: {
-
return "Callable";
} break;
case SIGNAL: {
-
return "Signal";
} break;
case STRING_NAME: {
-
return "StringName";
} break;
case NODE_PATH: {
-
return "NodePath";
} break;
case DICTIONARY: {
-
return "Dictionary";
} break;
case ARRAY: {
-
return "Array";
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
return "PackedByteArray";
} break;
case PACKED_INT32_ARRAY: {
-
return "PackedInt32Array";
} break;
case PACKED_INT64_ARRAY: {
-
return "PackedInt64Array";
} break;
case PACKED_FLOAT32_ARRAY: {
-
return "PackedFloat32Array";
} break;
case PACKED_FLOAT64_ARRAY: {
-
return "PackedFloat64Array";
} break;
case PACKED_STRING_ARRAY: {
-
return "PackedStringArray";
} break;
case PACKED_VECTOR2_ARRAY: {
-
return "PackedVector2Array";
} break;
case PACKED_VECTOR3_ARRAY: {
-
return "PackedVector3Array";
} break;
case PACKED_COLOR_ARRAY: {
-
return "PackedColorArray";
} break;
@@ -218,22 +182,22 @@ String Variant::get_type_name(Variant::Type p_type) {
}
bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
-
- if (p_type_from == p_type_to)
+ if (p_type_from == p_type_to) {
return true;
- if (p_type_to == NIL && p_type_from != NIL) //nil can convert to anything
+ }
+ if (p_type_to == NIL && p_type_from != NIL) { //nil can convert to anything
return true;
+ }
if (p_type_from == NIL) {
return (p_type_to == OBJECT);
- };
+ }
const Type *valid_types = nullptr;
const Type *invalid_types = nullptr;
switch (p_type_to) {
case BOOL: {
-
static const Type valid[] = {
INT,
FLOAT,
@@ -244,7 +208,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case INT: {
-
static const Type valid[] = {
BOOL,
FLOAT,
@@ -256,7 +219,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case FLOAT: {
-
static const Type valid[] = {
BOOL,
INT,
@@ -268,7 +230,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case STRING: {
-
static const Type invalid[] = {
OBJECT,
NIL
@@ -277,7 +238,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
invalid_types = invalid;
} break;
case VECTOR2: {
-
static const Type valid[] = {
VECTOR2I,
NIL,
@@ -287,7 +247,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case VECTOR2I: {
-
static const Type valid[] = {
VECTOR2,
NIL,
@@ -297,7 +256,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case RECT2: {
-
static const Type valid[] = {
RECT2I,
NIL,
@@ -307,7 +265,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case RECT2I: {
-
static const Type valid[] = {
RECT2,
NIL,
@@ -317,7 +274,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case TRANSFORM2D: {
-
static const Type valid[] = {
TRANSFORM,
NIL
@@ -326,7 +282,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case VECTOR3: {
-
static const Type valid[] = {
VECTOR3I,
NIL,
@@ -336,7 +291,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case VECTOR3I: {
-
static const Type valid[] = {
VECTOR3,
NIL,
@@ -347,7 +301,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case QUAT: {
-
static const Type valid[] = {
BASIS,
NIL
@@ -357,7 +310,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case BASIS: {
-
static const Type valid[] = {
QUAT,
VECTOR3,
@@ -368,7 +320,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case TRANSFORM: {
-
static const Type valid[] = {
TRANSFORM2D,
QUAT,
@@ -381,7 +332,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case COLOR: {
-
static const Type valid[] = {
STRING,
INT,
@@ -393,7 +343,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case _RID: {
-
static const Type valid[] = {
OBJECT,
NIL
@@ -402,7 +351,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case OBJECT: {
-
static const Type valid[] = {
NIL
};
@@ -410,7 +358,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case STRING_NAME: {
-
static const Type valid[] = {
STRING,
NIL
@@ -419,7 +366,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case NODE_PATH: {
-
static const Type valid[] = {
STRING,
NIL
@@ -428,7 +374,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case ARRAY: {
-
static const Type valid[] = {
PACKED_BYTE_ARRAY,
PACKED_INT32_ARRAY,
@@ -446,7 +391,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -455,7 +399,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case PACKED_INT32_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -463,7 +406,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case PACKED_INT64_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -471,7 +413,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case PACKED_FLOAT32_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -480,7 +421,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case PACKED_FLOAT64_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -489,7 +429,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case PACKED_STRING_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -497,7 +436,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
valid_types = valid;
} break;
case PACKED_VECTOR2_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -506,7 +444,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case PACKED_VECTOR3_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -515,7 +452,6 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
} break;
case PACKED_COLOR_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -529,22 +465,20 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
}
if (valid_types) {
-
int i = 0;
while (valid_types[i] != NIL) {
-
- if (p_type_from == valid_types[i])
+ if (p_type_from == valid_types[i]) {
return true;
+ }
i++;
}
} else if (invalid_types) {
-
int i = 0;
while (invalid_types[i] != NIL) {
-
- if (p_type_from == invalid_types[i])
+ if (p_type_from == invalid_types[i]) {
return false;
+ }
i++;
}
@@ -555,21 +489,21 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
}
bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type_to) {
-
- if (p_type_from == p_type_to)
+ if (p_type_from == p_type_to) {
return true;
- if (p_type_to == NIL && p_type_from != NIL) //nil can convert to anything
+ }
+ if (p_type_to == NIL && p_type_from != NIL) { //nil can convert to anything
return true;
+ }
if (p_type_from == NIL) {
return (p_type_to == OBJECT);
- };
+ }
const Type *valid_types = nullptr;
switch (p_type_to) {
case BOOL: {
-
static const Type valid[] = {
INT,
FLOAT,
@@ -580,7 +514,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case INT: {
-
static const Type valid[] = {
BOOL,
FLOAT,
@@ -592,7 +525,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case FLOAT: {
-
static const Type valid[] = {
BOOL,
INT,
@@ -604,7 +536,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case STRING: {
-
static const Type valid[] = {
NODE_PATH,
STRING_NAME,
@@ -614,7 +545,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case VECTOR2: {
-
static const Type valid[] = {
VECTOR2I,
NIL,
@@ -624,7 +554,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case VECTOR2I: {
-
static const Type valid[] = {
VECTOR2,
NIL,
@@ -634,7 +563,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case RECT2: {
-
static const Type valid[] = {
RECT2I,
NIL,
@@ -644,7 +572,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case RECT2I: {
-
static const Type valid[] = {
RECT2,
NIL,
@@ -654,7 +581,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case TRANSFORM2D: {
-
static const Type valid[] = {
TRANSFORM,
NIL
@@ -663,7 +589,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case VECTOR3: {
-
static const Type valid[] = {
VECTOR3I,
NIL,
@@ -673,7 +598,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case VECTOR3I: {
-
static const Type valid[] = {
VECTOR3,
NIL,
@@ -684,7 +608,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case QUAT: {
-
static const Type valid[] = {
BASIS,
NIL
@@ -694,7 +617,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case BASIS: {
-
static const Type valid[] = {
QUAT,
VECTOR3,
@@ -705,7 +627,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case TRANSFORM: {
-
static const Type valid[] = {
TRANSFORM2D,
QUAT,
@@ -718,7 +639,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case COLOR: {
-
static const Type valid[] = {
STRING,
INT,
@@ -730,7 +650,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case _RID: {
-
static const Type valid[] = {
OBJECT,
NIL
@@ -739,7 +658,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case OBJECT: {
-
static const Type valid[] = {
NIL
};
@@ -747,7 +665,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case STRING_NAME: {
-
static const Type valid[] = {
STRING,
NIL
@@ -756,7 +673,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case NODE_PATH: {
-
static const Type valid[] = {
STRING,
NIL
@@ -765,7 +681,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case ARRAY: {
-
static const Type valid[] = {
PACKED_BYTE_ARRAY,
PACKED_INT32_ARRAY,
@@ -783,7 +698,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -792,7 +706,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case PACKED_INT32_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -800,7 +713,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case PACKED_INT64_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -808,7 +720,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case PACKED_FLOAT32_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -817,7 +728,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case PACKED_FLOAT64_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -826,7 +736,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case PACKED_STRING_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -834,7 +743,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
valid_types = valid;
} break;
case PACKED_VECTOR2_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -843,7 +751,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case PACKED_VECTOR3_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -852,7 +759,6 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
} break;
case PACKED_COLOR_ARRAY: {
-
static const Type valid[] = {
ARRAY,
NIL
@@ -866,12 +772,11 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
}
if (valid_types) {
-
int i = 0;
while (valid_types[i] != NIL) {
-
- if (p_type_from == valid_types[i])
+ if (p_type_from == valid_types[i]) {
return true;
+ }
i++;
}
}
@@ -880,9 +785,9 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
}
bool Variant::operator==(const Variant &p_variant) const {
-
- if (type != p_variant.type) //evaluation of operator== needs to be more strict
+ if (type != p_variant.type) { //evaluation of operator== needs to be more strict
return false;
+ }
bool v;
Variant r;
evaluate(OP_EQUAL, *this, p_variant, r, v);
@@ -890,9 +795,9 @@ bool Variant::operator==(const Variant &p_variant) const {
}
bool Variant::operator!=(const Variant &p_variant) const {
-
- if (type != p_variant.type) //evaluation of operator== needs to be more strict
+ if (type != p_variant.type) { //evaluation of operator== needs to be more strict
return true;
+ }
bool v;
Variant r;
evaluate(OP_NOT_EQUAL, *this, p_variant, r, v);
@@ -900,8 +805,9 @@ bool Variant::operator!=(const Variant &p_variant) const {
}
bool Variant::operator<(const Variant &p_variant) const {
- if (type != p_variant.type) //if types differ, then order by type first
+ if (type != p_variant.type) { //if types differ, then order by type first
return type < p_variant.type;
+ }
bool v;
Variant r;
evaluate(OP_LESS, *this, p_variant, r, v);
@@ -909,186 +815,145 @@ bool Variant::operator<(const Variant &p_variant) const {
}
bool Variant::is_zero() const {
-
switch (type) {
case NIL: {
-
return true;
} break;
// atomic types
case BOOL: {
-
return !(_data._bool);
} break;
case INT: {
-
return _data._int == 0;
} break;
case FLOAT: {
-
return _data._float == 0;
} break;
case STRING: {
-
return *reinterpret_cast<const String *>(_data._mem) == String();
} break;
// math types
case VECTOR2: {
-
return *reinterpret_cast<const Vector2 *>(_data._mem) == Vector2();
} break;
case VECTOR2I: {
-
return *reinterpret_cast<const Vector2i *>(_data._mem) == Vector2i();
} break;
case RECT2: {
-
return *reinterpret_cast<const Rect2 *>(_data._mem) == Rect2();
} break;
case RECT2I: {
-
return *reinterpret_cast<const Rect2i *>(_data._mem) == Rect2i();
} break;
case TRANSFORM2D: {
-
return *_data._transform2d == Transform2D();
} break;
case VECTOR3: {
-
return *reinterpret_cast<const Vector3 *>(_data._mem) == Vector3();
} break;
case VECTOR3I: {
-
return *reinterpret_cast<const Vector3i *>(_data._mem) == Vector3i();
} break;
case PLANE: {
-
return *reinterpret_cast<const Plane *>(_data._mem) == Plane();
} break;
- /*
- case QUAT: {
-
-
- } break;*/
case AABB: {
-
return *_data._aabb == ::AABB();
} break;
case QUAT: {
-
return *reinterpret_cast<const Quat *>(_data._mem) == Quat();
} break;
case BASIS: {
-
return *_data._basis == Basis();
} break;
case TRANSFORM: {
-
return *_data._transform == Transform();
} break;
// misc types
case COLOR: {
-
return *reinterpret_cast<const Color *>(_data._mem) == Color();
} break;
case _RID: {
-
return *reinterpret_cast<const RID *>(_data._mem) == RID();
} break;
case OBJECT: {
-
return _get_obj().obj == nullptr;
} break;
case CALLABLE: {
-
return reinterpret_cast<const Callable *>(_data._mem)->is_null();
} break;
case SIGNAL: {
-
return reinterpret_cast<const Signal *>(_data._mem)->is_null();
} break;
case STRING_NAME: {
-
return *reinterpret_cast<const StringName *>(_data._mem) != StringName();
} break;
case NODE_PATH: {
-
return reinterpret_cast<const NodePath *>(_data._mem)->is_empty();
} break;
case DICTIONARY: {
-
return reinterpret_cast<const Dictionary *>(_data._mem)->empty();
} break;
case ARRAY: {
-
return reinterpret_cast<const Array *>(_data._mem)->empty();
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
return PackedArrayRef<uint8_t>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_INT32_ARRAY: {
-
return PackedArrayRef<int32_t>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_INT64_ARRAY: {
-
return PackedArrayRef<int64_t>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_FLOAT32_ARRAY: {
-
return PackedArrayRef<float>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_FLOAT64_ARRAY: {
-
return PackedArrayRef<double>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_STRING_ARRAY: {
-
return PackedArrayRef<String>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_VECTOR2_ARRAY: {
-
return PackedArrayRef<Vector2>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_VECTOR3_ARRAY: {
-
return PackedArrayRef<Vector3>::get_array(_data.packed_array).size() == 0;
} break;
case PACKED_COLOR_ARRAY: {
-
return PackedArrayRef<Color>::get_array(_data.packed_array).size() == 0;
} break;
@@ -1100,65 +965,52 @@ bool Variant::is_zero() const {
}
bool Variant::is_one() const {
-
switch (type) {
case NIL: {
-
return true;
} break;
// atomic types
case BOOL: {
-
return _data._bool;
} break;
case INT: {
-
return _data._int == 1;
} break;
case FLOAT: {
-
return _data._float == 1;
} break;
case VECTOR2: {
-
return *reinterpret_cast<const Vector2 *>(_data._mem) == Vector2(1, 1);
} break;
case VECTOR2I: {
-
return *reinterpret_cast<const Vector2i *>(_data._mem) == Vector2i(1, 1);
} break;
case RECT2: {
-
return *reinterpret_cast<const Rect2 *>(_data._mem) == Rect2(1, 1, 1, 1);
} break;
case RECT2I: {
-
return *reinterpret_cast<const Rect2i *>(_data._mem) == Rect2i(1, 1, 1, 1);
} break;
case VECTOR3: {
-
return *reinterpret_cast<const Vector3 *>(_data._mem) == Vector3(1, 1, 1);
} break;
case VECTOR3I: {
-
return *reinterpret_cast<const Vector3i *>(_data._mem) == Vector3i(1, 1, 1);
} break;
case PLANE: {
-
return *reinterpret_cast<const Plane *>(_data._mem) == Plane(1, 1, 1, 1);
} break;
case COLOR: {
-
return *reinterpret_cast<const Color *>(_data._mem) == Color(1, 1, 1, 1);
} break;
@@ -1180,7 +1032,6 @@ bool Variant::is_null() const {
}
void Variant::reference(const Variant &p_variant) {
-
switch (type) {
case NIL:
case BOOL:
@@ -1195,93 +1046,73 @@ void Variant::reference(const Variant &p_variant) {
switch (p_variant.type) {
case NIL: {
-
// none
} break;
// atomic types
case BOOL: {
-
_data._bool = p_variant._data._bool;
} break;
case INT: {
-
_data._int = p_variant._data._int;
} break;
case FLOAT: {
-
_data._float = p_variant._data._float;
} break;
case STRING: {
-
memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem)));
} break;
// math types
case VECTOR2: {
-
memnew_placement(_data._mem, Vector2(*reinterpret_cast<const Vector2 *>(p_variant._data._mem)));
} break;
case VECTOR2I: {
-
memnew_placement(_data._mem, Vector2i(*reinterpret_cast<const Vector2i *>(p_variant._data._mem)));
} break;
case RECT2: {
-
memnew_placement(_data._mem, Rect2(*reinterpret_cast<const Rect2 *>(p_variant._data._mem)));
} break;
case RECT2I: {
-
memnew_placement(_data._mem, Rect2i(*reinterpret_cast<const Rect2i *>(p_variant._data._mem)));
} break;
case TRANSFORM2D: {
-
_data._transform2d = memnew(Transform2D(*p_variant._data._transform2d));
} break;
case VECTOR3: {
-
memnew_placement(_data._mem, Vector3(*reinterpret_cast<const Vector3 *>(p_variant._data._mem)));
} break;
case VECTOR3I: {
-
memnew_placement(_data._mem, Vector3i(*reinterpret_cast<const Vector3i *>(p_variant._data._mem)));
} break;
case PLANE: {
-
memnew_placement(_data._mem, Plane(*reinterpret_cast<const Plane *>(p_variant._data._mem)));
} break;
case AABB: {
-
_data._aabb = memnew(::AABB(*p_variant._data._aabb));
} break;
case QUAT: {
-
memnew_placement(_data._mem, Quat(*reinterpret_cast<const Quat *>(p_variant._data._mem)));
} break;
case BASIS: {
-
_data._basis = memnew(Basis(*p_variant._data._basis));
} break;
case TRANSFORM: {
-
_data._transform = memnew(Transform(*p_variant._data._transform));
} break;
// misc types
case COLOR: {
-
memnew_placement(_data._mem, Color(*reinterpret_cast<const Color *>(p_variant._data._mem)));
} break;
case _RID: {
-
memnew_placement(_data._mem, RID(*reinterpret_cast<const RID *>(p_variant._data._mem)));
} break;
case OBJECT: {
-
memnew_placement(_data._mem, ObjData);
if (p_variant._get_obj().obj && p_variant._get_obj().id.is_reference()) {
@@ -1298,37 +1129,30 @@ void Variant::reference(const Variant &p_variant) {
} break;
case CALLABLE: {
-
memnew_placement(_data._mem, Callable(*reinterpret_cast<const Callable *>(p_variant._data._mem)));
} break;
case SIGNAL: {
-
memnew_placement(_data._mem, Signal(*reinterpret_cast<const Signal *>(p_variant._data._mem)));
} break;
case STRING_NAME: {
-
memnew_placement(_data._mem, StringName(*reinterpret_cast<const StringName *>(p_variant._data._mem)));
} break;
case NODE_PATH: {
-
memnew_placement(_data._mem, NodePath(*reinterpret_cast<const NodePath *>(p_variant._data._mem)));
} break;
case DICTIONARY: {
-
memnew_placement(_data._mem, Dictionary(*reinterpret_cast<const Dictionary *>(p_variant._data._mem)));
} break;
case ARRAY: {
-
memnew_placement(_data._mem, Array(*reinterpret_cast<const Array *>(p_variant._data._mem)));
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<uint8_t> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<uint8_t>::create();
@@ -1336,7 +1160,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_INT32_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<int32_t> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<int32_t>::create();
@@ -1344,7 +1167,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_INT64_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<int64_t> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<int64_t>::create();
@@ -1352,7 +1174,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_FLOAT32_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<float> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<float>::create();
@@ -1360,7 +1181,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_FLOAT64_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<double> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<double>::create();
@@ -1368,7 +1188,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_STRING_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<String> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<String>::create();
@@ -1376,7 +1195,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_VECTOR2_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<Vector2> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<Vector2>::create();
@@ -1384,7 +1202,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_VECTOR3_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<Vector3> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<Vector3>::create();
@@ -1392,7 +1209,6 @@ void Variant::reference(const Variant &p_variant) {
} break;
case PACKED_COLOR_ARRAY: {
-
_data.packed_array = static_cast<PackedArrayRef<Color> *>(p_variant._data.packed_array)->reference();
if (!_data.packed_array) {
_data.packed_array = PackedArrayRef<Color>::create();
@@ -1451,10 +1267,8 @@ void Variant::zero() {
}
void Variant::clear() {
-
switch (type) {
case STRING: {
-
reinterpret_cast<String *>(_data._mem)->~String();
} break;
/*
@@ -1465,35 +1279,28 @@ void Variant::clear() {
COLOR,
VECTOR2,
RECT2
- */
+ */
case TRANSFORM2D: {
-
memdelete(_data._transform2d);
} break;
case AABB: {
-
memdelete(_data._aabb);
} break;
case BASIS: {
-
memdelete(_data._basis);
} break;
case TRANSFORM: {
-
memdelete(_data._transform);
} break;
// misc types
case STRING_NAME: {
-
reinterpret_cast<StringName *>(_data._mem)->~StringName();
} break;
case NODE_PATH: {
-
reinterpret_cast<NodePath *>(_data._mem)->~NodePath();
} break;
case OBJECT: {
-
if (_get_obj().id.is_reference()) {
//we are safe that there is a reference here
Reference *reference = static_cast<Reference *>(_get_obj().obj);
@@ -1509,56 +1316,43 @@ void Variant::clear() {
reinterpret_cast<RID *>(_data._mem)->~RID();
} break;
case CALLABLE: {
-
reinterpret_cast<Callable *>(_data._mem)->~Callable();
} break;
case SIGNAL: {
-
reinterpret_cast<Signal *>(_data._mem)->~Signal();
} break;
case DICTIONARY: {
-
reinterpret_cast<Dictionary *>(_data._mem)->~Dictionary();
} break;
case ARRAY: {
-
reinterpret_cast<Array *>(_data._mem)->~Array();
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_INT32_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_INT64_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_FLOAT32_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_FLOAT64_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_STRING_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_VECTOR2_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_VECTOR3_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
case PACKED_COLOR_ARRAY: {
-
PackedArrayRefBase::destroy(_data.packed_array);
} break;
default: {
@@ -1569,9 +1363,7 @@ void Variant::clear() {
}
Variant::operator signed int() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1583,15 +1375,13 @@ Variant::operator signed int() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
}
-Variant::operator unsigned int() const {
+Variant::operator unsigned int() const {
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1603,16 +1393,13 @@ Variant::operator unsigned int() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
}
Variant::operator int64_t() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1624,36 +1411,13 @@ Variant::operator int64_t() const {
case STRING:
return operator String().to_int64();
default: {
-
return 0;
}
}
}
-/*
-Variant::operator long unsigned int() const {
-
- switch( type ) {
-
- case NIL: return 0;
- case BOOL: return _data._bool ? 1 : 0;
- case INT: return _data._int;
- case FLOAT: return _data._real;
- case STRING: return operator String().to_int();
- default: {
-
- return 0;
- }
- }
-
- return 0;
-};
-*/
-
Variant::operator uint64_t() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1665,7 +1429,6 @@ Variant::operator uint64_t() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
@@ -1683,9 +1446,7 @@ Variant::operator ObjectID() const {
#ifdef NEED_LONG_INT
Variant::operator signed long() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1697,18 +1458,15 @@ Variant::operator signed long() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
return 0;
-};
+}
Variant::operator unsigned long() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1720,19 +1478,16 @@ Variant::operator unsigned long() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
return 0;
-};
+}
#endif
Variant::operator signed short() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1744,15 +1499,13 @@ Variant::operator signed short() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
}
-Variant::operator unsigned short() const {
+Variant::operator unsigned short() const {
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1764,15 +1517,13 @@ Variant::operator unsigned short() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
}
-Variant::operator signed char() const {
+Variant::operator signed char() const {
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1784,15 +1535,13 @@ Variant::operator signed char() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
}
-Variant::operator unsigned char() const {
+Variant::operator unsigned char() const {
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1804,21 +1553,17 @@ Variant::operator unsigned char() const {
case STRING:
return operator String().to_int();
default: {
-
return 0;
}
}
}
Variant::operator CharType() const {
-
return operator unsigned int();
}
Variant::operator float() const {
-
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1830,15 +1575,13 @@ Variant::operator float() const {
case STRING:
return operator String().to_double();
default: {
-
return 0;
}
}
}
-Variant::operator double() const {
+Variant::operator double() const {
switch (type) {
-
case NIL:
return 0;
case BOOL:
@@ -1850,14 +1593,12 @@ Variant::operator double() const {
case STRING:
return operator String().to_double();
default: {
-
return 0;
}
}
}
Variant::operator StringName() const {
-
if (type == STRING_NAME) {
return *reinterpret_cast<const StringName *>(_data._mem);
} else if (type == STRING) {
@@ -1868,12 +1609,10 @@ Variant::operator StringName() const {
}
struct _VariantStrPair {
-
String key;
String value;
bool operator<(const _VariantStrPair &p) const {
-
return key < p.key;
}
};
@@ -1886,7 +1625,6 @@ Variant::operator String() const {
String Variant::stringify(List<const void *> &stack) const {
switch (type) {
-
case NIL:
return "Null";
case BOOL:
@@ -1906,7 +1644,6 @@ String Variant::stringify(List<const void *> &stack) const {
case RECT2I:
return "(" + operator Rect2i() + ")";
case TRANSFORM2D: {
-
Transform2D mat32 = operator Transform2D();
return "(" + Variant(mat32.elements[0]).operator String() + ", " + Variant(mat32.elements[1]).operator String() + ", " + Variant(mat32.elements[2]).operator String() + ")";
} break;
@@ -1922,21 +1659,20 @@ String Variant::stringify(List<const void *> &stack) const {
case QUAT:
return "(" + operator Quat() + ")";
case BASIS: {
-
Basis mat3 = operator Basis();
String mtx("(");
for (int i = 0; i < 3; i++) {
-
- if (i != 0)
+ if (i != 0) {
mtx += ", ";
+ }
mtx += "(";
for (int j = 0; j < 3; j++) {
-
- if (j != 0)
+ if (j != 0) {
mtx += ", ";
+ }
mtx += Variant(mat3.elements[i][j]).operator String();
}
@@ -1955,7 +1691,6 @@ String Variant::stringify(List<const void *> &stack) const {
case COLOR:
return String::num(operator Color().r) + "," + String::num(operator Color().g) + "," + String::num(operator Color().b) + "," + String::num(operator Color().a);
case DICTIONARY: {
-
const Dictionary &d = *reinterpret_cast<const Dictionary *>(_data._mem);
if (stack.find(d.id())) {
return "{...}";
@@ -1971,7 +1706,6 @@ String Variant::stringify(List<const void *> &stack) const {
Vector<_VariantStrPair> pairs;
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
_VariantStrPair sp;
sp.key = E->get().stringify(stack);
sp.value = d[E->get()].stringify(stack);
@@ -1982,8 +1716,9 @@ String Variant::stringify(List<const void *> &stack) const {
pairs.sort();
for (int i = 0; i < pairs.size(); i++) {
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str += pairs[i].key + ":" + pairs[i].value;
}
str += "}";
@@ -1991,98 +1726,90 @@ String Variant::stringify(List<const void *> &stack) const {
return str;
} break;
case PACKED_VECTOR2_ARRAY: {
-
Vector<Vector2> vec = operator Vector<Vector2>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + Variant(vec[i]);
}
str += "]";
return str;
} break;
case PACKED_VECTOR3_ARRAY: {
-
Vector<Vector3> vec = operator Vector<Vector3>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + Variant(vec[i]);
}
str += "]";
return str;
} break;
case PACKED_STRING_ARRAY: {
-
Vector<String> vec = operator Vector<String>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + vec[i];
}
str += "]";
return str;
} break;
case PACKED_INT32_ARRAY: {
-
Vector<int32_t> vec = operator Vector<int32_t>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + itos(vec[i]);
}
str += "]";
return str;
} break;
case PACKED_INT64_ARRAY: {
-
Vector<int64_t> vec = operator Vector<int64_t>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + itos(vec[i]);
}
str += "]";
return str;
} break;
case PACKED_FLOAT32_ARRAY: {
-
Vector<float> vec = operator Vector<float>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + rtos(vec[i]);
}
str += "]";
return str;
} break;
case PACKED_FLOAT64_ARRAY: {
-
Vector<double> vec = operator Vector<double>();
String str("[");
for (int i = 0; i < vec.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
str += ", ";
+ }
str = str + rtos(vec[i]);
}
str += "]";
return str;
} break;
case ARRAY: {
-
Array arr = operator Array();
if (stack.find(arr.id())) {
return "[...]";
@@ -2091,8 +1818,9 @@ String Variant::stringify(List<const void *> &stack) const {
String str("[");
for (int i = 0; i < arr.size(); i++) {
- if (i)
+ if (i) {
str += ", ";
+ }
str += arr[i].stringify(stack);
}
@@ -2102,16 +1830,15 @@ String Variant::stringify(List<const void *> &stack) const {
} break;
case OBJECT: {
-
if (_get_obj().obj) {
-
if (!_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
return "[Freed Object]";
- };
+ }
return _get_obj().obj->to_string();
- } else
+ } else {
return "[Object:null]";
+ }
} break;
case CALLABLE: {
@@ -2135,131 +1862,131 @@ String Variant::stringify(List<const void *> &stack) const {
}
Variant::operator Vector2() const {
-
- if (type == VECTOR2)
+ if (type == VECTOR2) {
return *reinterpret_cast<const Vector2 *>(_data._mem);
- else if (type == VECTOR2I)
+ } else if (type == VECTOR2I) {
return *reinterpret_cast<const Vector2i *>(_data._mem);
- else if (type == VECTOR3)
+ } else if (type == VECTOR3) {
return Vector2(reinterpret_cast<const Vector3 *>(_data._mem)->x, reinterpret_cast<const Vector3 *>(_data._mem)->y);
- else if (type == VECTOR3I)
+ } else if (type == VECTOR3I) {
return Vector2(reinterpret_cast<const Vector3i *>(_data._mem)->x, reinterpret_cast<const Vector3i *>(_data._mem)->y);
- else
+ } else {
return Vector2();
+ }
}
Variant::operator Vector2i() const {
-
- if (type == VECTOR2I)
+ if (type == VECTOR2I) {
return *reinterpret_cast<const Vector2i *>(_data._mem);
- else if (type == VECTOR2)
+ } else if (type == VECTOR2) {
return *reinterpret_cast<const Vector2 *>(_data._mem);
- else if (type == VECTOR3)
+ } else if (type == VECTOR3) {
return Vector2(reinterpret_cast<const Vector3 *>(_data._mem)->x, reinterpret_cast<const Vector3 *>(_data._mem)->y);
- else if (type == VECTOR3I)
+ } else if (type == VECTOR3I) {
return Vector2(reinterpret_cast<const Vector3i *>(_data._mem)->x, reinterpret_cast<const Vector3i *>(_data._mem)->y);
- else
+ } else {
return Vector2i();
+ }
}
Variant::operator Rect2() const {
-
- if (type == RECT2)
+ if (type == RECT2) {
return *reinterpret_cast<const Rect2 *>(_data._mem);
- else if (type == RECT2I)
+ } else if (type == RECT2I) {
return *reinterpret_cast<const Rect2i *>(_data._mem);
- else
+ } else {
return Rect2();
+ }
}
Variant::operator Rect2i() const {
-
- if (type == RECT2I)
+ if (type == RECT2I) {
return *reinterpret_cast<const Rect2i *>(_data._mem);
- else if (type == RECT2)
+ } else if (type == RECT2) {
return *reinterpret_cast<const Rect2 *>(_data._mem);
- else
+ } else {
return Rect2i();
+ }
}
Variant::operator Vector3() const {
-
- if (type == VECTOR3)
+ if (type == VECTOR3) {
return *reinterpret_cast<const Vector3 *>(_data._mem);
- else if (type == VECTOR3I)
+ } else if (type == VECTOR3I) {
return *reinterpret_cast<const Vector3i *>(_data._mem);
- else if (type == VECTOR2)
+ } else if (type == VECTOR2) {
return Vector3(reinterpret_cast<const Vector2 *>(_data._mem)->x, reinterpret_cast<const Vector2 *>(_data._mem)->y, 0.0);
- else if (type == VECTOR2I)
+ } else if (type == VECTOR2I) {
return Vector3(reinterpret_cast<const Vector2i *>(_data._mem)->x, reinterpret_cast<const Vector2i *>(_data._mem)->y, 0.0);
- else
+ } else {
return Vector3();
+ }
}
Variant::operator Vector3i() const {
-
- if (type == VECTOR3I)
+ if (type == VECTOR3I) {
return *reinterpret_cast<const Vector3i *>(_data._mem);
- else if (type == VECTOR3)
+ } else if (type == VECTOR3) {
return *reinterpret_cast<const Vector3 *>(_data._mem);
- else if (type == VECTOR2)
+ } else if (type == VECTOR2) {
return Vector3i(reinterpret_cast<const Vector2 *>(_data._mem)->x, reinterpret_cast<const Vector2 *>(_data._mem)->y, 0.0);
- else if (type == VECTOR2I)
+ } else if (type == VECTOR2I) {
return Vector3i(reinterpret_cast<const Vector2i *>(_data._mem)->x, reinterpret_cast<const Vector2i *>(_data._mem)->y, 0.0);
- else
+ } else {
return Vector3i();
+ }
}
Variant::operator Plane() const {
-
- if (type == PLANE)
+ if (type == PLANE) {
return *reinterpret_cast<const Plane *>(_data._mem);
- else
+ } else {
return Plane();
+ }
}
-Variant::operator ::AABB() const {
- if (type == AABB)
+Variant::operator ::AABB() const {
+ if (type == AABB) {
return *_data._aabb;
- else
+ } else {
return ::AABB();
+ }
}
Variant::operator Basis() const {
-
- if (type == BASIS)
+ if (type == BASIS) {
return *_data._basis;
- else if (type == QUAT)
+ } else if (type == QUAT) {
return *reinterpret_cast<const Quat *>(_data._mem);
- else if (type == VECTOR3) {
+ } else if (type == VECTOR3) {
return Basis(*reinterpret_cast<const Vector3 *>(_data._mem));
- } else if (type == TRANSFORM) // unexposed in Variant::can_convert?
+ } else if (type == TRANSFORM) { // unexposed in Variant::can_convert?
return _data._transform->basis;
- else
+ } else {
return Basis();
+ }
}
Variant::operator Quat() const {
-
- if (type == QUAT)
+ if (type == QUAT) {
return *reinterpret_cast<const Quat *>(_data._mem);
- else if (type == BASIS)
+ } else if (type == BASIS) {
return *_data._basis;
- else if (type == TRANSFORM)
+ } else if (type == TRANSFORM) {
return _data._transform->basis;
- else
+ } else {
return Quat();
+ }
}
Variant::operator Transform() const {
-
- if (type == TRANSFORM)
+ if (type == TRANSFORM) {
return *_data._transform;
- else if (type == BASIS)
+ } else if (type == BASIS) {
return Transform(*_data._basis, Vector3());
- else if (type == QUAT)
+ } else if (type == QUAT) {
return Transform(Basis(*reinterpret_cast<const Quat *>(_data._mem)), Vector3());
- else if (type == TRANSFORM2D) {
+ } else if (type == TRANSFORM2D) {
const Transform2D &t = *_data._transform2d;
Transform m;
m.basis.elements[0][0] = t.elements[0][0];
@@ -2269,12 +1996,12 @@ Variant::operator Transform() const {
m.origin[0] = t.elements[2][0];
m.origin[1] = t.elements[2][1];
return m;
- } else
+ } else {
return Transform();
+ }
}
Variant::operator Transform2D() const {
-
if (type == TRANSFORM2D) {
return *_data._transform2d;
} else if (type == TRANSFORM) {
@@ -2287,43 +2014,43 @@ Variant::operator Transform2D() const {
m.elements[2][0] = t.origin[0];
m.elements[2][1] = t.origin[1];
return m;
- } else
+ } else {
return Transform2D();
+ }
}
Variant::operator Color() const {
-
- if (type == COLOR)
+ if (type == COLOR) {
return *reinterpret_cast<const Color *>(_data._mem);
- else if (type == STRING)
+ } else if (type == STRING) {
return Color::html(operator String());
- else if (type == INT)
+ } else if (type == INT) {
return Color::hex(operator int());
- else
+ } else {
return Color();
+ }
}
Variant::operator NodePath() const {
-
- if (type == NODE_PATH)
+ if (type == NODE_PATH) {
return *reinterpret_cast<const NodePath *>(_data._mem);
- else if (type == STRING)
+ } else if (type == STRING) {
return NodePath(operator String());
- else
+ } else {
return NodePath();
+ }
}
Variant::operator RID() const {
-
- if (type == _RID)
+ if (type == _RID) {
return *reinterpret_cast<const RID *>(_data._mem);
- else if (type == OBJECT && _get_obj().obj == nullptr) {
+ } else if (type == OBJECT && _get_obj().obj == nullptr) {
return RID();
} else if (type == OBJECT && _get_obj().obj) {
#ifdef DEBUG_ENABLED
if (EngineDebugger::is_active()) {
ERR_FAIL_COND_V_MSG(ObjectDB::get_instance(_get_obj().id) == nullptr, RID(), "Invalid pointer (object was freed).");
- };
+ }
#endif
Callable::CallError ce;
Variant ret = _get_obj().obj->call(CoreStringNames::get_singleton()->get_rid, nullptr, 0, ce);
@@ -2337,11 +2064,11 @@ Variant::operator RID() const {
}
Variant::operator Object *() const {
-
- if (type == OBJECT)
+ if (type == OBJECT) {
return _get_obj().obj;
- else
+ } else {
return nullptr;
+ }
}
Object *Variant::get_validated_object_with_check(bool &r_previously_freed) const {
@@ -2356,59 +2083,59 @@ Object *Variant::get_validated_object_with_check(bool &r_previously_freed) const
}
Object *Variant::get_validated_object() const {
- if (type == OBJECT)
+ if (type == OBJECT) {
return ObjectDB::get_instance(_get_obj().id);
- else
+ } else {
return nullptr;
+ }
}
Variant::operator Node *() const {
-
- if (type == OBJECT)
+ if (type == OBJECT) {
return Object::cast_to<Node>(_get_obj().obj);
- else
+ } else {
return nullptr;
+ }
}
-Variant::operator Control *() const {
- if (type == OBJECT)
+Variant::operator Control *() const {
+ if (type == OBJECT) {
return Object::cast_to<Control>(_get_obj().obj);
- else
+ } else {
return nullptr;
+ }
}
Variant::operator Dictionary() const {
-
- if (type == DICTIONARY)
+ if (type == DICTIONARY) {
return *reinterpret_cast<const Dictionary *>(_data._mem);
- else
+ } else {
return Dictionary();
+ }
}
Variant::operator Callable() const {
-
- if (type == CALLABLE)
+ if (type == CALLABLE) {
return *reinterpret_cast<const Callable *>(_data._mem);
- else
+ } else {
return Callable();
+ }
}
Variant::operator Signal() const {
-
- if (type == SIGNAL)
+ if (type == SIGNAL) {
return *reinterpret_cast<const Signal *>(_data._mem);
- else
+ } else {
return Signal();
+ }
}
template <class DA, class SA>
inline DA _convert_array(const SA &p_array) {
-
DA da;
da.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
-
da.set(i, Variant(p_array.get(i)));
}
@@ -2417,9 +2144,7 @@ inline DA _convert_array(const SA &p_array) {
template <class DA>
inline DA _convert_array_from_variant(const Variant &p_variant) {
-
switch (p_variant.get_type()) {
-
case Variant::ARRAY: {
return _convert_array<DA, Array>(p_variant.operator Array());
}
@@ -2457,169 +2182,172 @@ inline DA _convert_array_from_variant(const Variant &p_variant) {
}
Variant::operator Array() const {
-
- if (type == ARRAY)
+ if (type == ARRAY) {
return *reinterpret_cast<const Array *>(_data._mem);
- else
+ } else {
return _convert_array_from_variant<Array>(*this);
+ }
}
Variant::operator Vector<uint8_t>() const {
-
- if (type == PACKED_BYTE_ARRAY)
+ if (type == PACKED_BYTE_ARRAY) {
return static_cast<PackedArrayRef<uint8_t> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<uint8_t>>(*this);
+ }
}
-Variant::operator Vector<int32_t>() const {
- if (type == PACKED_INT32_ARRAY)
+Variant::operator Vector<int32_t>() const {
+ if (type == PACKED_INT32_ARRAY) {
return static_cast<PackedArrayRef<int32_t> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<int>>(*this);
+ }
}
-Variant::operator Vector<int64_t>() const {
- if (type == PACKED_INT64_ARRAY)
+Variant::operator Vector<int64_t>() const {
+ if (type == PACKED_INT64_ARRAY) {
return static_cast<PackedArrayRef<int64_t> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<int64_t>>(*this);
+ }
}
Variant::operator Vector<float>() const {
-
- if (type == PACKED_FLOAT32_ARRAY)
+ if (type == PACKED_FLOAT32_ARRAY) {
return static_cast<PackedArrayRef<float> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<float>>(*this);
+ }
}
Variant::operator Vector<double>() const {
-
- if (type == PACKED_FLOAT64_ARRAY)
+ if (type == PACKED_FLOAT64_ARRAY) {
return static_cast<PackedArrayRef<double> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<double>>(*this);
+ }
}
Variant::operator Vector<String>() const {
-
- if (type == PACKED_STRING_ARRAY)
+ if (type == PACKED_STRING_ARRAY) {
return static_cast<PackedArrayRef<String> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<String>>(*this);
+ }
}
-Variant::operator Vector<Vector3>() const {
- if (type == PACKED_VECTOR3_ARRAY)
+Variant::operator Vector<Vector3>() const {
+ if (type == PACKED_VECTOR3_ARRAY) {
return static_cast<PackedArrayRef<Vector3> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<Vector3>>(*this);
+ }
}
-Variant::operator Vector<Vector2>() const {
- if (type == PACKED_VECTOR2_ARRAY)
+Variant::operator Vector<Vector2>() const {
+ if (type == PACKED_VECTOR2_ARRAY) {
return static_cast<PackedArrayRef<Vector2> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<Vector2>>(*this);
+ }
}
Variant::operator Vector<Color>() const {
-
- if (type == PACKED_COLOR_ARRAY)
+ if (type == PACKED_COLOR_ARRAY) {
return static_cast<PackedArrayRef<Color> *>(_data.packed_array)->array;
- else
+ } else {
return _convert_array_from_variant<Vector<Color>>(*this);
+ }
}
/* helpers */
Variant::operator Vector<RID>() const {
-
Array va = operator Array();
Vector<RID> rids;
rids.resize(va.size());
- for (int i = 0; i < rids.size(); i++)
+ for (int i = 0; i < rids.size(); i++) {
rids.write[i] = va[i];
+ }
return rids;
}
Variant::operator Vector<Plane>() const {
-
Array va = operator Array();
Vector<Plane> planes;
int va_size = va.size();
- if (va_size == 0)
+ if (va_size == 0) {
return planes;
+ }
planes.resize(va_size);
Plane *w = planes.ptrw();
- for (int i = 0; i < va_size; i++)
+ for (int i = 0; i < va_size; i++) {
w[i] = va[i];
+ }
return planes;
}
Variant::operator Vector<Face3>() const {
-
Vector<Vector3> va = operator Vector<Vector3>();
Vector<Face3> faces;
int va_size = va.size();
- if (va_size == 0)
+ if (va_size == 0) {
return faces;
+ }
faces.resize(va_size / 3);
Face3 *w = faces.ptrw();
const Vector3 *r = va.ptr();
- for (int i = 0; i < va_size; i++)
+ for (int i = 0; i < va_size; i++) {
w[i / 3].vertex[i % 3] = r[i];
+ }
return faces;
}
Variant::operator Vector<Variant>() const {
-
Array va = operator Array();
Vector<Variant> variants;
int va_size = va.size();
- if (va_size == 0)
+ if (va_size == 0) {
return variants;
+ }
variants.resize(va_size);
Variant *w = variants.ptrw();
- for (int i = 0; i < va_size; i++)
+ for (int i = 0; i < va_size; i++) {
w[i] = va[i];
+ }
return variants;
}
-Variant::operator Vector<StringName>() const {
+Variant::operator Vector<StringName>() const {
Vector<String> from = operator Vector<String>();
Vector<StringName> to;
int len = from.size();
to.resize(len);
for (int i = 0; i < len; i++) {
-
to.write[i] = from[i];
}
return to;
}
Variant::operator Margin() const {
-
return (Margin) operator int();
}
-Variant::operator Orientation() const {
+Variant::operator Orientation() const {
return (Orientation) operator int();
}
Variant::operator IP_Address() const {
-
if (type == PACKED_FLOAT32_ARRAY || type == PACKED_INT32_ARRAY || type == PACKED_FLOAT64_ARRAY || type == PACKED_INT64_ARRAY || type == PACKED_BYTE_ARRAY) {
-
Vector<int> addr = operator Vector<int>();
if (addr.size() == 4) {
return IP_Address(addr.get(0), addr.get(1), addr.get(2), addr.get(3));
@@ -2630,26 +2358,16 @@ Variant::operator IP_Address() const {
}
Variant::Variant(bool p_bool) {
-
type = BOOL;
_data._bool = p_bool;
}
-/*
-Variant::Variant(long unsigned int p_long) {
-
- type=INT;
- _data._int=p_long;
-};
-*/
-
Variant::Variant(signed int p_int) {
-
type = INT;
_data._int = p_int;
}
-Variant::Variant(unsigned int p_int) {
+Variant::Variant(unsigned int p_int) {
type = INT;
_data._int = p_int;
}
@@ -2657,56 +2375,52 @@ Variant::Variant(unsigned int p_int) {
#ifdef NEED_LONG_INT
Variant::Variant(signed long p_int) {
-
type = INT;
_data._int = p_int;
}
-Variant::Variant(unsigned long p_int) {
+Variant::Variant(unsigned long p_int) {
type = INT;
_data._int = p_int;
}
#endif
Variant::Variant(int64_t p_int) {
-
type = INT;
_data._int = p_int;
}
Variant::Variant(uint64_t p_int) {
-
type = INT;
_data._int = p_int;
}
Variant::Variant(signed short p_short) {
-
type = INT;
_data._int = p_short;
}
-Variant::Variant(unsigned short p_short) {
+Variant::Variant(unsigned short p_short) {
type = INT;
_data._int = p_short;
}
-Variant::Variant(signed char p_char) {
+Variant::Variant(signed char p_char) {
type = INT;
_data._int = p_char;
}
-Variant::Variant(unsigned char p_char) {
+Variant::Variant(unsigned char p_char) {
type = INT;
_data._int = p_char;
}
-Variant::Variant(float p_float) {
+Variant::Variant(float p_float) {
type = FLOAT;
_data._float = p_float;
}
-Variant::Variant(double p_double) {
+Variant::Variant(double p_double) {
type = FLOAT;
_data._float = p_double;
}
@@ -2717,121 +2431,106 @@ Variant::Variant(const ObjectID &p_id) {
}
Variant::Variant(const StringName &p_string) {
-
type = STRING_NAME;
memnew_placement(_data._mem, StringName(p_string));
}
-Variant::Variant(const String &p_string) {
+Variant::Variant(const String &p_string) {
type = STRING;
memnew_placement(_data._mem, String(p_string));
}
Variant::Variant(const char *const p_cstring) {
-
type = STRING;
memnew_placement(_data._mem, String((const char *)p_cstring));
}
Variant::Variant(const CharType *p_wstring) {
-
type = STRING;
memnew_placement(_data._mem, String(p_wstring));
}
-Variant::Variant(const Vector3 &p_vector3) {
+Variant::Variant(const Vector3 &p_vector3) {
type = VECTOR3;
memnew_placement(_data._mem, Vector3(p_vector3));
}
-Variant::Variant(const Vector3i &p_vector3i) {
+Variant::Variant(const Vector3i &p_vector3i) {
type = VECTOR3I;
memnew_placement(_data._mem, Vector3i(p_vector3i));
}
Variant::Variant(const Vector2 &p_vector2) {
-
type = VECTOR2;
memnew_placement(_data._mem, Vector2(p_vector2));
}
Variant::Variant(const Vector2i &p_vector2i) {
-
type = VECTOR2I;
memnew_placement(_data._mem, Vector2i(p_vector2i));
}
Variant::Variant(const Rect2 &p_rect2) {
-
type = RECT2;
memnew_placement(_data._mem, Rect2(p_rect2));
}
Variant::Variant(const Rect2i &p_rect2i) {
-
type = RECT2I;
memnew_placement(_data._mem, Rect2i(p_rect2i));
}
Variant::Variant(const Plane &p_plane) {
-
type = PLANE;
memnew_placement(_data._mem, Plane(p_plane));
}
-Variant::Variant(const ::AABB &p_aabb) {
+Variant::Variant(const ::AABB &p_aabb) {
type = AABB;
_data._aabb = memnew(::AABB(p_aabb));
}
Variant::Variant(const Basis &p_matrix) {
-
type = BASIS;
_data._basis = memnew(Basis(p_matrix));
}
Variant::Variant(const Quat &p_quat) {
-
type = QUAT;
memnew_placement(_data._mem, Quat(p_quat));
}
-Variant::Variant(const Transform &p_transform) {
+Variant::Variant(const Transform &p_transform) {
type = TRANSFORM;
_data._transform = memnew(Transform(p_transform));
}
Variant::Variant(const Transform2D &p_transform) {
-
type = TRANSFORM2D;
_data._transform2d = memnew(Transform2D(p_transform));
}
-Variant::Variant(const Color &p_color) {
+Variant::Variant(const Color &p_color) {
type = COLOR;
memnew_placement(_data._mem, Color(p_color));
}
Variant::Variant(const NodePath &p_node_path) {
-
type = NODE_PATH;
memnew_placement(_data._mem, NodePath(p_node_path));
}
Variant::Variant(const RID &p_rid) {
-
type = _RID;
memnew_placement(_data._mem, RID(p_rid));
}
Variant::Variant(const Object *p_object) {
-
type = OBJECT;
memnew_placement(_data._mem, ObjData);
if (p_object) {
-
if (p_object->is_reference()) {
Reference *reference = const_cast<Reference *>(static_cast<const Reference *>(p_object));
if (!reference->init_ref()) {
@@ -2850,30 +2549,26 @@ Variant::Variant(const Object *p_object) {
}
Variant::Variant(const Callable &p_callable) {
-
type = CALLABLE;
memnew_placement(_data._mem, Callable(p_callable));
}
-Variant::Variant(const Signal &p_callable) {
+Variant::Variant(const Signal &p_callable) {
type = SIGNAL;
memnew_placement(_data._mem, Signal(p_callable));
}
Variant::Variant(const Dictionary &p_dictionary) {
-
type = DICTIONARY;
memnew_placement(_data._mem, Dictionary(p_dictionary));
}
Variant::Variant(const Array &p_array) {
-
type = ARRAY;
memnew_placement(_data._mem, Array(p_array));
}
Variant::Variant(const Vector<Plane> &p_array) {
-
type = ARRAY;
Array *plane_array = memnew_placement(_data._mem, Array);
@@ -2881,13 +2576,11 @@ Variant::Variant(const Vector<Plane> &p_array) {
plane_array->resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
-
plane_array->operator[](i) = Variant(p_array[i]);
}
}
Variant::Variant(const Vector<RID> &p_array) {
-
type = ARRAY;
Array *rid_array = memnew_placement(_data._mem, Array);
@@ -2895,65 +2588,57 @@ Variant::Variant(const Vector<RID> &p_array) {
rid_array->resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
-
rid_array->set(i, Variant(p_array[i]));
}
}
Variant::Variant(const Vector<uint8_t> &p_byte_array) {
-
type = PACKED_BYTE_ARRAY;
_data.packed_array = PackedArrayRef<uint8_t>::create(p_byte_array);
}
-Variant::Variant(const Vector<int32_t> &p_int32_array) {
+Variant::Variant(const Vector<int32_t> &p_int32_array) {
type = PACKED_INT32_ARRAY;
_data.packed_array = PackedArrayRef<int32_t>::create(p_int32_array);
}
Variant::Variant(const Vector<int64_t> &p_int64_array) {
-
type = PACKED_INT64_ARRAY;
_data.packed_array = PackedArrayRef<int64_t>::create(p_int64_array);
}
Variant::Variant(const Vector<float> &p_float32_array) {
-
type = PACKED_FLOAT32_ARRAY;
_data.packed_array = PackedArrayRef<float>::create(p_float32_array);
}
Variant::Variant(const Vector<double> &p_float64_array) {
-
type = PACKED_FLOAT64_ARRAY;
_data.packed_array = PackedArrayRef<double>::create(p_float64_array);
}
Variant::Variant(const Vector<String> &p_string_array) {
-
type = PACKED_STRING_ARRAY;
_data.packed_array = PackedArrayRef<String>::create(p_string_array);
}
-Variant::Variant(const Vector<Vector3> &p_vector3_array) {
+Variant::Variant(const Vector<Vector3> &p_vector3_array) {
type = PACKED_VECTOR3_ARRAY;
_data.packed_array = PackedArrayRef<Vector3>::create(p_vector3_array);
}
Variant::Variant(const Vector<Vector2> &p_vector2_array) {
-
type = PACKED_VECTOR2_ARRAY;
_data.packed_array = PackedArrayRef<Vector2>::create(p_vector2_array);
}
-Variant::Variant(const Vector<Color> &p_color_array) {
+Variant::Variant(const Vector<Color> &p_color_array) {
type = PACKED_COLOR_ARRAY;
_data.packed_array = PackedArrayRef<Color>::create(p_color_array);
}
Variant::Variant(const Vector<Face3> &p_face_array) {
-
Vector<Vector3> vertices;
int face_count = p_face_array.size();
vertices.resize(face_count * 3);
@@ -2963,9 +2648,9 @@ Variant::Variant(const Vector<Face3> &p_face_array) {
Vector3 *w = vertices.ptrw();
for (int i = 0; i < face_count; i++) {
-
- for (int j = 0; j < 3; j++)
+ for (int j = 0; j < 3; j++) {
w[i * 3 + j] = r[i].vertex[j];
+ }
}
}
@@ -2986,20 +2671,20 @@ Variant::Variant(const Vector<Variant> &p_array) {
}
Variant::Variant(const Vector<StringName> &p_array) {
-
type = NIL;
Vector<String> v;
int len = p_array.size();
v.resize(len);
- for (int i = 0; i < len; i++)
+ for (int i = 0; i < len; i++) {
v.set(i, p_array[i]);
+ }
*this = v;
}
void Variant::operator=(const Variant &p_variant) {
-
- if (unlikely(this == &p_variant))
+ if (unlikely(this == &p_variant)) {
return;
+ }
if (unlikely(type != p_variant.type)) {
reference(p_variant);
@@ -3008,90 +2693,70 @@ void Variant::operator=(const Variant &p_variant) {
switch (p_variant.type) {
case NIL: {
-
// none
} break;
// atomic types
case BOOL: {
-
_data._bool = p_variant._data._bool;
} break;
case INT: {
-
_data._int = p_variant._data._int;
} break;
case FLOAT: {
-
_data._float = p_variant._data._float;
} break;
case STRING: {
-
*reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem);
} break;
// math types
case VECTOR2: {
-
*reinterpret_cast<Vector2 *>(_data._mem) = *reinterpret_cast<const Vector2 *>(p_variant._data._mem);
} break;
case VECTOR2I: {
-
*reinterpret_cast<Vector2i *>(_data._mem) = *reinterpret_cast<const Vector2i *>(p_variant._data._mem);
} break;
case RECT2: {
-
*reinterpret_cast<Rect2 *>(_data._mem) = *reinterpret_cast<const Rect2 *>(p_variant._data._mem);
} break;
case RECT2I: {
-
*reinterpret_cast<Rect2i *>(_data._mem) = *reinterpret_cast<const Rect2i *>(p_variant._data._mem);
} break;
case TRANSFORM2D: {
-
*_data._transform2d = *(p_variant._data._transform2d);
} break;
case VECTOR3: {
-
*reinterpret_cast<Vector3 *>(_data._mem) = *reinterpret_cast<const Vector3 *>(p_variant._data._mem);
} break;
case VECTOR3I: {
-
*reinterpret_cast<Vector3i *>(_data._mem) = *reinterpret_cast<const Vector3i *>(p_variant._data._mem);
} break;
case PLANE: {
-
*reinterpret_cast<Plane *>(_data._mem) = *reinterpret_cast<const Plane *>(p_variant._data._mem);
} break;
case AABB: {
-
*_data._aabb = *(p_variant._data._aabb);
} break;
case QUAT: {
-
*reinterpret_cast<Quat *>(_data._mem) = *reinterpret_cast<const Quat *>(p_variant._data._mem);
} break;
case BASIS: {
-
*_data._basis = *(p_variant._data._basis);
} break;
case TRANSFORM: {
-
*_data._transform = *(p_variant._data._transform);
} break;
// misc types
case COLOR: {
-
*reinterpret_cast<Color *>(_data._mem) = *reinterpret_cast<const Color *>(p_variant._data._mem);
} break;
case _RID: {
-
*reinterpret_cast<RID *>(_data._mem) = *reinterpret_cast<const RID *>(p_variant._data._mem);
} break;
case OBJECT: {
-
if (_get_obj().id.is_reference()) {
//we are safe that there is a reference here
Reference *reference = static_cast<Reference *>(_get_obj().obj);
@@ -3114,66 +2779,51 @@ void Variant::operator=(const Variant &p_variant) {
} break;
case CALLABLE: {
-
*reinterpret_cast<Callable *>(_data._mem) = *reinterpret_cast<const Callable *>(p_variant._data._mem);
} break;
case SIGNAL: {
-
*reinterpret_cast<Signal *>(_data._mem) = *reinterpret_cast<const Signal *>(p_variant._data._mem);
} break;
case STRING_NAME: {
-
*reinterpret_cast<StringName *>(_data._mem) = *reinterpret_cast<const StringName *>(p_variant._data._mem);
} break;
case NODE_PATH: {
-
*reinterpret_cast<NodePath *>(_data._mem) = *reinterpret_cast<const NodePath *>(p_variant._data._mem);
} break;
case DICTIONARY: {
-
*reinterpret_cast<Dictionary *>(_data._mem) = *reinterpret_cast<const Dictionary *>(p_variant._data._mem);
} break;
case ARRAY: {
-
*reinterpret_cast<Array *>(_data._mem) = *reinterpret_cast<const Array *>(p_variant._data._mem);
} break;
// arrays
case PACKED_BYTE_ARRAY: {
-
_data.packed_array = PackedArrayRef<uint8_t>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_INT32_ARRAY: {
-
_data.packed_array = PackedArrayRef<int32_t>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_INT64_ARRAY: {
-
_data.packed_array = PackedArrayRef<int64_t>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_FLOAT32_ARRAY: {
-
_data.packed_array = PackedArrayRef<float>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_FLOAT64_ARRAY: {
-
_data.packed_array = PackedArrayRef<double>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_STRING_ARRAY: {
-
_data.packed_array = PackedArrayRef<String>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_VECTOR2_ARRAY: {
-
_data.packed_array = PackedArrayRef<Vector2>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_VECTOR3_ARRAY: {
-
_data.packed_array = PackedArrayRef<Vector3>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
case PACKED_COLOR_ARRAY: {
-
_data.packed_array = PackedArrayRef<Color>::reference_from(_data.packed_array, p_variant._data.packed_array);
} break;
default: {
@@ -3182,77 +2832,56 @@ void Variant::operator=(const Variant &p_variant) {
}
Variant::Variant(const IP_Address &p_address) {
-
type = STRING;
memnew_placement(_data._mem, String(p_address));
}
Variant::Variant(const Variant &p_variant) {
-
- type = NIL;
reference(p_variant);
}
-/*
-Variant::~Variant() {
-
- clear();
-}*/
-
uint32_t Variant::hash() const {
-
switch (type) {
case NIL: {
-
return 0;
} break;
case BOOL: {
-
return _data._bool ? 1 : 0;
} break;
case INT: {
-
return _data._int;
} break;
case FLOAT: {
-
return hash_djb2_one_float(_data._float);
} break;
case STRING: {
-
return reinterpret_cast<const String *>(_data._mem)->hash();
} break;
// math types
case VECTOR2: {
-
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Vector2 *>(_data._mem)->x);
return hash_djb2_one_float(reinterpret_cast<const Vector2 *>(_data._mem)->y, hash);
} break;
case VECTOR2I: {
-
uint32_t hash = hash_djb2_one_32(reinterpret_cast<const Vector2i *>(_data._mem)->x);
return hash_djb2_one_32(reinterpret_cast<const Vector2i *>(_data._mem)->y, hash);
} break;
case RECT2: {
-
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->position.x);
hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->position.y, hash);
hash = hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->size.x, hash);
return hash_djb2_one_float(reinterpret_cast<const Rect2 *>(_data._mem)->size.y, hash);
} break;
case RECT2I: {
-
uint32_t hash = hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->position.x);
hash = hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->position.y, hash);
hash = hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->size.x, hash);
return hash_djb2_one_32(reinterpret_cast<const Rect2i *>(_data._mem)->size.y, hash);
} break;
case TRANSFORM2D: {
-
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
-
for (int j = 0; j < 2; j++) {
hash = hash_djb2_one_float(_data._transform2d->elements[i][j], hash);
}
@@ -3261,35 +2890,25 @@ uint32_t Variant::hash() const {
return hash;
} break;
case VECTOR3: {
-
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Vector3 *>(_data._mem)->x);
hash = hash_djb2_one_float(reinterpret_cast<const Vector3 *>(_data._mem)->y, hash);
return hash_djb2_one_float(reinterpret_cast<const Vector3 *>(_data._mem)->z, hash);
} break;
case VECTOR3I: {
-
uint32_t hash = hash_djb2_one_32(reinterpret_cast<const Vector3i *>(_data._mem)->x);
hash = hash_djb2_one_32(reinterpret_cast<const Vector3i *>(_data._mem)->y, hash);
return hash_djb2_one_32(reinterpret_cast<const Vector3i *>(_data._mem)->z, hash);
} break;
case PLANE: {
-
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->normal.x);
hash = hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->normal.y, hash);
hash = hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->normal.z, hash);
return hash_djb2_one_float(reinterpret_cast<const Plane *>(_data._mem)->d, hash);
} break;
- /*
- case QUAT: {
-
-
- } break;*/
case AABB: {
-
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
-
hash = hash_djb2_one_float(_data._aabb->position[i], hash);
hash = hash_djb2_one_float(_data._aabb->size[i], hash);
}
@@ -3298,7 +2917,6 @@ uint32_t Variant::hash() const {
} break;
case QUAT: {
-
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->x);
hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->y, hash);
hash = hash_djb2_one_float(reinterpret_cast<const Quat *>(_data._mem)->z, hash);
@@ -3306,10 +2924,8 @@ uint32_t Variant::hash() const {
} break;
case BASIS: {
-
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
-
for (int j = 0; j < 3; j++) {
hash = hash_djb2_one_float(_data._basis->elements[i][j], hash);
}
@@ -3319,10 +2935,8 @@ uint32_t Variant::hash() const {
} break;
case TRANSFORM: {
-
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
-
for (int j = 0; j < 3; j++) {
hash = hash_djb2_one_float(_data._transform->basis.elements[i][j], hash);
}
@@ -3335,7 +2949,6 @@ uint32_t Variant::hash() const {
// misc types
case COLOR: {
-
uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->r);
hash = hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->g, hash);
hash = hash_djb2_one_float(reinterpret_cast<const Color *>(_data._mem)->b, hash);
@@ -3343,45 +2956,36 @@ uint32_t Variant::hash() const {
} break;
case _RID: {
-
return hash_djb2_one_64(reinterpret_cast<const RID *>(_data._mem)->get_id());
} break;
case OBJECT: {
-
return hash_djb2_one_64(make_uint64_t(_get_obj().obj));
} break;
case STRING_NAME: {
-
return reinterpret_cast<const StringName *>(_data._mem)->hash();
} break;
case NODE_PATH: {
-
return reinterpret_cast<const NodePath *>(_data._mem)->hash();
} break;
case DICTIONARY: {
-
return reinterpret_cast<const Dictionary *>(_data._mem)->hash();
} break;
case CALLABLE: {
-
return reinterpret_cast<const Callable *>(_data._mem)->hash();
} break;
case SIGNAL: {
-
const Signal &s = *reinterpret_cast<const Signal *>(_data._mem);
uint32_t hash = s.get_name().hash();
return hash_djb2_one_64(s.get_object_id(), hash);
} break;
case ARRAY: {
-
const Array &arr = *reinterpret_cast<const Array *>(_data._mem);
return arr.hash();
} break;
case PACKED_BYTE_ARRAY: {
-
const Vector<uint8_t> &arr = PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3393,7 +2997,6 @@ uint32_t Variant::hash() const {
} break;
case PACKED_INT32_ARRAY: {
-
const Vector<int32_t> &arr = PackedArrayRef<int32_t>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3405,7 +3008,6 @@ uint32_t Variant::hash() const {
} break;
case PACKED_INT64_ARRAY: {
-
const Vector<int64_t> &arr = PackedArrayRef<int64_t>::get_array(_data.packed_array);
int len = arr.size();
if (likely(len)) {
@@ -3417,7 +3019,6 @@ uint32_t Variant::hash() const {
} break;
case PACKED_FLOAT32_ARRAY: {
-
const Vector<float> &arr = PackedArrayRef<float>::get_array(_data.packed_array);
int len = arr.size();
@@ -3430,7 +3031,6 @@ uint32_t Variant::hash() const {
} break;
case PACKED_FLOAT64_ARRAY: {
-
const Vector<double> &arr = PackedArrayRef<double>::get_array(_data.packed_array);
int len = arr.size();
@@ -3443,7 +3043,6 @@ uint32_t Variant::hash() const {
} break;
case PACKED_STRING_ARRAY: {
-
uint32_t hash = 5831;
const Vector<String> &arr = PackedArrayRef<String>::get_array(_data.packed_array);
int len = arr.size();
@@ -3459,7 +3058,6 @@ uint32_t Variant::hash() const {
return hash;
} break;
case PACKED_VECTOR2_ARRAY: {
-
uint32_t hash = 5831;
const Vector<Vector2> &arr = PackedArrayRef<Vector2>::get_array(_data.packed_array);
int len = arr.size();
@@ -3476,7 +3074,6 @@ uint32_t Variant::hash() const {
return hash;
} break;
case PACKED_VECTOR3_ARRAY: {
-
uint32_t hash = 5831;
const Vector<Vector3> &arr = PackedArrayRef<Vector3>::get_array(_data.packed_array);
int len = arr.size();
@@ -3494,7 +3091,6 @@ uint32_t Variant::hash() const {
return hash;
} break;
case PACKED_COLOR_ARRAY: {
-
uint32_t hash = 5831;
const Vector<Color> &arr = PackedArrayRef<Color>::get_array(_data.packed_array);
int len = arr.size();
@@ -3561,8 +3157,9 @@ uint32_t Variant::hash() const {
return true
bool Variant::hash_compare(const Variant &p_variant) const {
- if (type != p_variant.type)
+ if (type != p_variant.type) {
return false;
+ }
switch (type) {
case FLOAT: {
@@ -3600,8 +3197,9 @@ bool Variant::hash_compare(const Variant &p_variant) const {
Transform2D *r = p_variant._data._transform2d;
for (int i = 0; i < 3; i++) {
- if (!(hash_compare_vector2(l->elements[i], r->elements[i])))
+ if (!(hash_compare_vector2(l->elements[i], r->elements[i]))) {
return false;
+ }
}
return true;
@@ -3649,8 +3247,9 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Basis *r = p_variant._data._basis;
for (int i = 0; i < 3; i++) {
- if (!(hash_compare_vector3(l->elements[i], r->elements[i])))
+ if (!(hash_compare_vector3(l->elements[i], r->elements[i]))) {
return false;
+ }
}
return true;
@@ -3661,8 +3260,9 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Transform *r = p_variant._data._transform;
for (int i = 0; i < 3; i++) {
- if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i])))
+ if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i]))) {
return false;
+ }
}
return hash_compare_vector3(l->origin, r->origin);
@@ -3679,12 +3279,14 @@ bool Variant::hash_compare(const Variant &p_variant) const {
const Array &l = *(reinterpret_cast<const Array *>(_data._mem));
const Array &r = *(reinterpret_cast<const Array *>(p_variant._data._mem));
- if (l.size() != r.size())
+ if (l.size() != r.size()) {
return false;
+ }
for (int i = 0; i < l.size(); ++i) {
- if (!l[i].hash_compare(r[i]))
+ if (!l[i].hash_compare(r[i])) {
return false;
+ }
}
return true;
@@ -3722,38 +3324,35 @@ bool Variant::hash_compare(const Variant &p_variant) const {
}
bool Variant::is_ref() const {
-
return type == OBJECT && _get_obj().id.is_reference();
}
Vector<Variant> varray() {
-
return Vector<Variant>();
}
Vector<Variant> varray(const Variant &p_arg1) {
-
Vector<Variant> v;
v.push_back(p_arg1);
return v;
}
-Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2) {
+Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2) {
Vector<Variant> v;
v.push_back(p_arg1);
v.push_back(p_arg2);
return v;
}
-Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3) {
+Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3) {
Vector<Variant> v;
v.push_back(p_arg1);
v.push_back(p_arg2);
v.push_back(p_arg3);
return v;
}
-Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4) {
+Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4) {
Vector<Variant> v;
v.push_back(p_arg1);
v.push_back(p_arg2);
@@ -3763,7 +3362,6 @@ Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Varia
}
Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5) {
-
Vector<Variant> v;
v.push_back(p_arg1);
v.push_back(p_arg2);
@@ -3777,9 +3375,7 @@ void Variant::static_assign(const Variant &p_variant) {
}
bool Variant::is_shared() const {
-
switch (type) {
-
case OBJECT:
return true;
case ARRAY:
@@ -3797,8 +3393,9 @@ Variant Variant::call(const StringName &p_method, VARIANT_ARG_DECLARE) {
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -3807,20 +3404,16 @@ Variant Variant::call(const StringName &p_method, VARIANT_ARG_DECLARE) {
Variant ret = call(p_method, argptr, argc, error);
switch (error.error) {
-
case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
-
String err = "Invalid type for argument #" + itos(error.argument) + ", expected '" + Variant::get_type_name(Variant::Type(error.expected)) + "'.";
ERR_PRINT(err.utf8().get_data());
} break;
case Callable::CallError::CALL_ERROR_INVALID_METHOD: {
-
String err = "Invalid method '" + p_method + "' for type '" + Variant::get_type_name(type) + "'.";
ERR_PRINT(err.utf8().get_data());
} break;
case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
-
String err = "Too many arguments for method '" + p_method + "'";
ERR_PRINT(err.utf8().get_data());
} break;
@@ -3832,12 +3425,10 @@ Variant Variant::call(const StringName &p_method, VARIANT_ARG_DECLARE) {
}
void Variant::construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct, void *p_construct_ud) {
-
r_value = Variant();
}
String Variant::get_construct_string() const {
-
String vars;
VariantWriter::write_to_string(*this, vars);
@@ -3845,7 +3436,6 @@ String Variant::get_construct_string() const {
}
String Variant::get_call_error_text(Object *p_base, const StringName &p_method, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce) {
-
String err_text;
if (ce.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) {
@@ -3870,14 +3460,12 @@ String Variant::get_call_error_text(Object *p_base, const StringName &p_method,
String class_name = p_base->get_class();
Ref<Script> script = p_base->get_script();
if (script.is_valid() && script->get_path().is_resource_file()) {
-
class_name += "(" + script->get_path().get_file() + ")";
}
return "'" + class_name + "::" + String(p_method) + "': " + err_text;
}
String Variant::get_callable_error_text(const Callable &p_callable, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce) {
-
String err_text;
if (ce.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) {
@@ -3903,26 +3491,20 @@ String Variant::get_callable_error_text(const Callable &p_callable, const Varian
}
String vformat(const String &p_text, const Variant &p1, const Variant &p2, const Variant &p3, const Variant &p4, const Variant &p5) {
-
Array args;
if (p1.get_type() != Variant::NIL) {
-
args.push_back(p1);
if (p2.get_type() != Variant::NIL) {
-
args.push_back(p2);
if (p3.get_type() != Variant::NIL) {
-
args.push_back(p3);
if (p4.get_type() != Variant::NIL) {
-
args.push_back(p4);
if (p5.get_type() != Variant::NIL) {
-
args.push_back(p5);
}
}
diff --git a/core/variant.h b/core/variant.h
index 8e924be00a..50b7a21eda 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -123,10 +123,9 @@ private:
// Variant takes 20 bytes when real_t is float, and 36 if double
// it only allocates extra memory for aabb/matrix.
- Type type;
+ Type type = NIL;
struct ObjData {
-
ObjectID id;
Object *obj;
};
@@ -220,10 +219,10 @@ public:
bool is_ref() const;
_FORCE_INLINE_ bool is_num() const {
return type == INT || type == FLOAT;
- };
+ }
_FORCE_INLINE_ bool is_array() const {
return type >= ARRAY;
- };
+ }
bool is_shared() const;
bool is_zero() const;
bool is_one() const;
@@ -403,7 +402,6 @@ public:
static String get_operator_name(Operator p_op);
static void evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b, Variant &r_ret, bool &r_valid);
static _FORCE_INLINE_ Variant evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b) {
-
bool valid = true;
Variant res;
evaluate(p_op, p_a, p_b, res, valid);
@@ -469,13 +467,13 @@ public:
static void construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct = nullptr, void *p_construct_ud = nullptr);
void operator=(const Variant &p_variant); // only this is enough for all the other types
+
Variant(const Variant &p_variant);
- _FORCE_INLINE_ Variant() {
- type = NIL;
- }
+ _FORCE_INLINE_ Variant() {}
_FORCE_INLINE_ ~Variant() {
- if (type != Variant::NIL)
+ if (type != Variant::NIL) {
clear();
+ }
}
};
@@ -490,22 +488,18 @@ Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Varia
Vector<Variant> varray(const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5);
struct VariantHasher {
-
static _FORCE_INLINE_ uint32_t hash(const Variant &p_variant) { return p_variant.hash(); }
};
struct VariantComparator {
-
static _FORCE_INLINE_ bool compare(const Variant &p_lhs, const Variant &p_rhs) { return p_lhs.hash_compare(p_rhs); }
};
Variant::ObjData &Variant::_get_obj() {
-
return *reinterpret_cast<ObjData *>(&_data._mem[0]);
}
const Variant::ObjData &Variant::_get_obj() const {
-
return *reinterpret_cast<const ObjData *>(&_data._mem[0]);
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 416a1a5fb8..a8beac1e44 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -42,14 +42,11 @@ typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_a
typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args);
struct _VariantCall {
-
static void Vector3_dot(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
r_ret = reinterpret_cast<Vector3 *>(p_self._data._mem)->dot(*reinterpret_cast<const Vector3 *>(p_args[0]->_data._mem));
}
struct FuncData {
-
int arg_count;
Vector<Variant> default_args;
Vector<Variant::Type> arg_types;
@@ -62,16 +59,16 @@ struct _VariantCall {
VariantFunc func;
_FORCE_INLINE_ bool verify_arguments(const Variant **p_args, Callable::CallError &r_error) {
-
- if (arg_count == 0)
+ if (arg_count == 0) {
return true;
+ }
const Variant::Type *tptr = &arg_types[0];
for (int i = 0; i < arg_count; i++) {
-
- if (tptr[i] == Variant::NIL || tptr[i] == p_args[i]->type)
+ if (tptr[i] == Variant::NIL || tptr[i] == p_args[i]->type) {
continue; // all good
+ }
if (!Variant::can_convert(p_args[i]->type, tptr[i])) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = i;
@@ -102,21 +99,25 @@ struct _VariantCall {
#endif
ERR_FAIL_COND(p_argcount > VARIANT_ARG_MAX);
const Variant *newargs[VARIANT_ARG_MAX];
- for (int i = 0; i < p_argcount; i++)
+ for (int i = 0; i < p_argcount; i++) {
newargs[i] = p_args[i];
+ }
// fill in any remaining parameters with defaults
int first_default_arg = arg_count - def_argcount;
- for (int i = p_argcount; i < arg_count; i++)
+ for (int i = p_argcount; i < arg_count; i++) {
newargs[i] = &default_args[i - first_default_arg];
+ }
#ifdef DEBUG_ENABLED
- if (!verify_arguments(newargs, r_error))
+ if (!verify_arguments(newargs, r_error)) {
return;
+ }
#endif
func(r_ret, p_self, newargs);
} else {
#ifdef DEBUG_ENABLED
- if (!verify_arguments(p_args, r_error))
+ if (!verify_arguments(p_args, r_error)) {
return;
+ }
#endif
func(r_ret, p_self, p_args);
}
@@ -124,7 +125,6 @@ struct _VariantCall {
};
struct TypeFunc {
-
Map<StringName, FuncData> functions;
};
@@ -143,14 +143,12 @@ struct _VariantCall {
//void addfunc(Variant::Type p_type, const StringName& p_name,VariantFunc p_func);
static void make_func_return_variant(Variant::Type p_type, const StringName &p_name) {
-
#ifdef DEBUG_ENABLED
type_funcs[p_type].functions[p_name].returns = true;
#endif
}
static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, bool p_has_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) {
-
FuncData funcdata;
funcdata.func = p_func;
funcdata.default_args = p_defaultarg;
@@ -164,8 +162,9 @@ struct _VariantCall {
funcdata.arg_names.push_back(p_argtype1.name);
#endif
- } else
+ } else {
goto end;
+ }
if (p_argtype2.name) {
funcdata.arg_types.push_back(p_argtype2.type);
@@ -173,8 +172,9 @@ struct _VariantCall {
funcdata.arg_names.push_back(p_argtype2.name);
#endif
- } else
+ } else {
goto end;
+ }
if (p_argtype3.name) {
funcdata.arg_types.push_back(p_argtype3.type);
@@ -182,24 +182,27 @@ struct _VariantCall {
funcdata.arg_names.push_back(p_argtype3.name);
#endif
- } else
+ } else {
goto end;
+ }
if (p_argtype4.name) {
funcdata.arg_types.push_back(p_argtype4.type);
#ifdef DEBUG_ENABLED
funcdata.arg_names.push_back(p_argtype4.name);
#endif
- } else
+ } else {
goto end;
+ }
if (p_argtype5.name) {
funcdata.arg_types.push_back(p_argtype5.type);
#ifdef DEBUG_ENABLED
funcdata.arg_names.push_back(p_argtype5.name);
#endif
- } else
+ } else {
goto end;
+ }
end:
@@ -315,7 +318,6 @@ struct _VariantCall {
VCALL_LOCALMEM1R(String, trim_suffix);
static void _call_String_to_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
String *s = reinterpret_cast<String *>(p_self._data._mem);
if (s->empty()) {
r_ret = PackedByteArray();
@@ -333,7 +335,6 @@ struct _VariantCall {
}
static void _call_String_to_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
String *s = reinterpret_cast<String *>(p_self._data._mem);
if (s->empty()) {
r_ret = PackedByteArray();
@@ -465,26 +466,29 @@ struct _VariantCall {
//return vector3 if intersected, nil if not
static void _call_Plane_intersect_3(Variant &r_ret, Variant &p_self, const Variant **p_args) {
Vector3 result;
- if (reinterpret_cast<Plane *>(p_self._data._mem)->intersect_3(*p_args[0], *p_args[1], &result))
+ if (reinterpret_cast<Plane *>(p_self._data._mem)->intersect_3(*p_args[0], *p_args[1], &result)) {
r_ret = result;
- else
+ } else {
r_ret = Variant();
+ }
}
static void _call_Plane_intersects_ray(Variant &r_ret, Variant &p_self, const Variant **p_args) {
Vector3 result;
- if (reinterpret_cast<Plane *>(p_self._data._mem)->intersects_ray(*p_args[0], *p_args[1], &result))
+ if (reinterpret_cast<Plane *>(p_self._data._mem)->intersects_ray(*p_args[0], *p_args[1], &result)) {
r_ret = result;
- else
+ } else {
r_ret = Variant();
+ }
}
static void _call_Plane_intersects_segment(Variant &r_ret, Variant &p_self, const Variant **p_args) {
Vector3 result;
- if (reinterpret_cast<Plane *>(p_self._data._mem)->intersects_segment(*p_args[0], *p_args[1], &result))
+ if (reinterpret_cast<Plane *>(p_self._data._mem)->intersects_segment(*p_args[0], *p_args[1], &result)) {
r_ret = result;
- else
+ } else {
r_ret = Variant();
+ }
}
VCALL_LOCALMEM0R(Quat, length);
@@ -592,7 +596,6 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Array, min);
static void _call_PackedByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
String s;
if (ba->size() > 0) {
@@ -608,7 +611,6 @@ struct _VariantCall {
}
static void _call_PackedByteArray_get_string_from_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
String s;
if (ba->size() > 0) {
@@ -619,7 +621,6 @@ struct _VariantCall {
}
static void _call_PackedByteArray_compress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
PackedByteArray compressed;
if (ba->size() > 0) {
@@ -635,7 +636,6 @@ struct _VariantCall {
}
static void _call_PackedByteArray_decompress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
-
PackedByteArray *ba = reinterpret_cast<PackedByteArray *>(p_self._data._mem);
PackedByteArray decompressed;
Compression::Mode mode = (Compression::Mode)(int)(*p_args[1]);
@@ -923,6 +923,18 @@ struct _VariantCall {
VCALL_PTR1R(Basis, scaled);
VCALL_PTR0R(Basis, get_scale);
VCALL_PTR0R(Basis, get_euler);
+ VCALL_PTR0R(Basis, get_euler_xyz);
+ VCALL_PTR1(Basis, set_euler_xyz);
+ VCALL_PTR0R(Basis, get_euler_xzy);
+ VCALL_PTR1(Basis, set_euler_xzy);
+ VCALL_PTR0R(Basis, get_euler_yzx);
+ VCALL_PTR1(Basis, set_euler_yzx);
+ VCALL_PTR0R(Basis, get_euler_yxz);
+ VCALL_PTR1(Basis, set_euler_yxz);
+ VCALL_PTR0R(Basis, get_euler_zxy);
+ VCALL_PTR1(Basis, set_euler_zxy);
+ VCALL_PTR0R(Basis, get_euler_zyx);
+ VCALL_PTR1(Basis, set_euler_zyx);
VCALL_PTR1R(Basis, tdotx);
VCALL_PTR1R(Basis, tdoty);
VCALL_PTR1R(Basis, tdotz);
@@ -985,7 +997,6 @@ struct _VariantCall {
}
struct ConstructData {
-
int arg_count;
Vector<Variant::Type> arg_types;
Vector<String> arg_names;
@@ -993,50 +1004,41 @@ struct _VariantCall {
};
struct ConstructFunc {
-
List<ConstructData> constructors;
};
static ConstructFunc *construct_funcs;
static void Vector2_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Vector2(*p_args[0], *p_args[1]);
}
static void Vector2i_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Vector2i(*p_args[0], *p_args[1]);
}
static void Rect2_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Rect2(*p_args[0], *p_args[1]);
}
static void Rect2_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Rect2(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
}
static void Rect2i_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Rect2i(*p_args[0], *p_args[1]);
}
static void Rect2i_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Rect2i(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
}
static void Transform2D_init2(Variant &r_ret, const Variant **p_args) {
-
Transform2D m(*p_args[0], *p_args[1]);
r_ret = m;
}
static void Transform2D_init3(Variant &r_ret, const Variant **p_args) {
-
Transform2D m;
m[0] = *p_args[0];
m[1] = *p_args[1];
@@ -1045,81 +1047,65 @@ struct _VariantCall {
}
static void Vector3_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Vector3(*p_args[0], *p_args[1], *p_args[2]);
}
static void Vector3i_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Vector3i(*p_args[0], *p_args[1], *p_args[2]);
}
static void Plane_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Plane(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
}
static void Plane_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Plane(*p_args[0], *p_args[1], *p_args[2]);
}
static void Plane_init3(Variant &r_ret, const Variant **p_args) {
-
r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator real_t());
}
static void Plane_init4(Variant &r_ret, const Variant **p_args) {
-
r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator Vector3());
}
static void Quat_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Quat(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
}
static void Quat_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Quat(((Vector3)(*p_args[0])), ((real_t)(*p_args[1])));
}
static void Quat_init3(Variant &r_ret, const Variant **p_args) {
-
r_ret = Quat(((Vector3)(*p_args[0])));
}
static void Color_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = Color(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
}
static void Color_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Color(*p_args[0], *p_args[1], *p_args[2]);
}
static void Color_init3(Variant &r_ret, const Variant **p_args) {
-
r_ret = Color::html(*p_args[0]);
}
static void Color_init4(Variant &r_ret, const Variant **p_args) {
-
r_ret = Color::hex(*p_args[0]);
}
static void Color_init5(Variant &r_ret, const Variant **p_args) {
-
r_ret = Color(((Color)(*p_args[0])), *p_args[1]);
}
static void AABB_init1(Variant &r_ret, const Variant **p_args) {
-
r_ret = ::AABB(*p_args[0], *p_args[1]);
}
static void Basis_init1(Variant &r_ret, const Variant **p_args) {
-
Basis m;
m.set_axis(0, *p_args[0]);
m.set_axis(1, *p_args[1]);
@@ -1128,12 +1114,10 @@ struct _VariantCall {
}
static void Basis_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Basis(p_args[0]->operator Vector3(), p_args[1]->operator real_t());
}
static void Transform_init1(Variant &r_ret, const Variant **p_args) {
-
Transform t;
t.basis.set_axis(0, *p_args[0]);
t.basis.set_axis(1, *p_args[1]);
@@ -1143,17 +1127,14 @@ struct _VariantCall {
}
static void Transform_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Transform(p_args[0]->operator Basis(), p_args[1]->operator Vector3());
}
static void Callable_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Callable(p_args[0]->operator ObjectID(), p_args[1]->operator String());
}
static void Signal_init2(Variant &r_ret, const Variant **p_args) {
-
r_ret = Signal(p_args[0]->operator ObjectID(), p_args[1]->operator String());
}
@@ -1162,31 +1143,34 @@ struct _VariantCall {
const String &p_name2 = "", const Variant::Type p_type2 = Variant::NIL,
const String &p_name3 = "", const Variant::Type p_type3 = Variant::NIL,
const String &p_name4 = "", const Variant::Type p_type4 = Variant::NIL) {
-
ConstructData cd;
cd.func = p_func;
cd.arg_count = 0;
- if (p_name1 == "")
+ if (p_name1 == "") {
goto end;
+ }
cd.arg_count++;
cd.arg_names.push_back(p_name1);
cd.arg_types.push_back(p_type1);
- if (p_name2 == "")
+ if (p_name2 == "") {
goto end;
+ }
cd.arg_count++;
cd.arg_names.push_back(p_name2);
cd.arg_types.push_back(p_type2);
- if (p_name3 == "")
+ if (p_name3 == "") {
goto end;
+ }
cd.arg_count++;
cd.arg_names.push_back(p_name3);
cd.arg_types.push_back(p_type3);
- if (p_name4 == "")
+ if (p_name4 == "") {
goto end;
+ }
cd.arg_count++;
cd.arg_names.push_back(p_name4);
cd.arg_types.push_back(p_type4);
@@ -1197,18 +1181,19 @@ struct _VariantCall {
}
struct ConstantData {
-
Map<StringName, int> value;
#ifdef DEBUG_ENABLED
List<StringName> value_ordered;
#endif
Map<StringName, Variant> variant_value;
+#ifdef DEBUG_ENABLED
+ List<StringName> variant_value_ordered;
+#endif
};
static ConstantData *constant_data;
static void add_constant(int p_type, StringName p_constant_name, int p_constant_value) {
-
constant_data[p_type].value[p_constant_name] = p_constant_value;
#ifdef DEBUG_ENABLED
constant_data[p_type].value_ordered.push_back(p_constant_name);
@@ -1216,8 +1201,10 @@ struct _VariantCall {
}
static void add_variant_constant(int p_type, StringName p_constant_name, const Variant &p_constant_value) {
-
constant_data[p_type].variant_value[p_constant_name] = p_constant_value;
+#ifdef DEBUG_ENABLED
+ constant_data[p_type].variant_value_ordered.push_back(p_constant_name);
+#endif
}
};
@@ -1226,7 +1213,6 @@ _VariantCall::ConstructFunc *_VariantCall::construct_funcs = nullptr;
_VariantCall::ConstantData *_VariantCall::constant_data = nullptr;
Variant Variant::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
Variant ret;
call_ptr(p_method, p_args, p_argcount, &ret, r_error);
return ret;
@@ -1254,13 +1240,11 @@ void Variant::call_ptr(const StringName &p_method, const Variant **p_args, int p
//else if (type==Variant::METHOD) {
} else {
-
r_error.error = Callable::CallError::CALL_OK;
Map<StringName, _VariantCall::FuncData>::Element *E = _VariantCall::type_funcs[type].functions.find(p_method);
if (E) {
-
_VariantCall::FuncData &funcdata = E->get();
funcdata.call(ret, *this, p_args, p_argcount, r_error);
@@ -1269,7 +1253,6 @@ void Variant::call_ptr(const StringName &p_method, const Variant **p_args, int p
bool valid = false;
if (type == CALLABLE) {
if (p_method == CoreStringNames::get_singleton()->call) {
-
reinterpret_cast<const Callable *>(_data._mem)->call(p_args, p_argcount, ret, r_error);
valid = true;
}
@@ -1294,14 +1277,14 @@ void Variant::call_ptr(const StringName &p_method, const Variant **p_args, int p
}
}
- if (r_error.error == Callable::CallError::CALL_OK && r_ret)
+ if (r_error.error == Callable::CallError::CALL_OK && r_ret) {
*r_ret = ret;
+ }
}
#define VCALL(m_type, m_method) _VariantCall::_call_##m_type##_##m_method
Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, int p_argcount, Callable::CallError &r_error, bool p_strict) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
ERR_FAIL_INDEX_V(p_type, VARIANT_MAX, Variant());
@@ -1325,10 +1308,16 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
// math types
case VECTOR2:
return Vector2();
+ case VECTOR2I:
+ return Vector2i();
case RECT2:
return Rect2();
+ case RECT2I:
+ return Rect2i();
case VECTOR3:
return Vector3();
+ case VECTOR3I:
+ return Vector3i();
case TRANSFORM2D:
return Transform2D();
case PLANE:
@@ -1390,7 +1379,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
switch (p_type) {
case NIL: {
-
return Variant();
} break;
case BOOL: {
@@ -1475,14 +1463,14 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
return Variant();
}
} else if (p_argcount >= 1) {
-
_VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type];
for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) {
const _VariantCall::ConstructData &cd = E->get();
- if (cd.arg_count != p_argcount)
+ if (cd.arg_count != p_argcount) {
continue;
+ }
//validate parameters
for (int i = 0; i < cd.arg_count; i++) {
@@ -1504,11 +1492,11 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
}
bool Variant::has_method(const StringName &p_method) const {
-
if (type == OBJECT) {
Object *obj = get_validated_object();
- if (!obj)
+ if (!obj) {
return false;
+ }
return obj->has_method(p_method);
}
@@ -1518,69 +1506,68 @@ bool Variant::has_method(const StringName &p_method) const {
}
Vector<Variant::Type> Variant::get_method_argument_types(Variant::Type p_type, const StringName &p_method) {
-
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
- if (!E)
+ if (!E) {
return Vector<Variant::Type>();
+ }
return E->get().arg_types;
}
bool Variant::is_method_const(Variant::Type p_type, const StringName &p_method) {
-
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
- if (!E)
+ if (!E) {
return false;
+ }
return E->get()._const;
}
Vector<StringName> Variant::get_method_argument_names(Variant::Type p_type, const StringName &p_method) {
-
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
- if (!E)
+ if (!E) {
return Vector<StringName>();
+ }
return E->get().arg_names;
}
Variant::Type Variant::get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return) {
-
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
- if (!E)
+ if (!E) {
return Variant::NIL;
+ }
- if (r_has_return)
+ if (r_has_return) {
*r_has_return = E->get().returns;
+ }
return E->get().return_type;
}
Vector<Variant> Variant::get_method_default_arguments(Variant::Type p_type, const StringName &p_method) {
-
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
- if (!E)
+ if (!E) {
return Vector<Variant>();
+ }
return E->get().default_args;
}
void Variant::get_method_list(List<MethodInfo> *p_list) const {
-
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[type];
for (const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.front(); E; E = E->next()) {
-
const _VariantCall::FuncData &fd = E->get();
MethodInfo mi;
@@ -1591,7 +1578,6 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
}
for (int i = 0; i < fd.arg_types.size(); i++) {
-
PropertyInfo pi;
pi.type = fd.arg_types[i];
#ifdef DEBUG_ENABLED
@@ -1606,8 +1592,9 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
ret.type = fd.return_type;
if (fd.returns) {
ret.name = "ret";
- if (fd.return_type == Variant::NIL)
+ if (fd.return_type == Variant::NIL) {
ret.usage = PROPERTY_USAGE_NIL_IS_VARIANT;
+ }
}
mi.return_val = ret;
#endif
@@ -1616,7 +1603,6 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
}
if (type == CALLABLE) {
-
MethodInfo mi;
mi.name = "call";
mi.return_val.usage = PROPERTY_USAGE_NIL_IS_VARIANT;
@@ -1631,7 +1617,6 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
}
if (type == SIGNAL) {
-
MethodInfo mi;
mi.name = "emit";
mi.flags |= METHOD_FLAG_VARARG;
@@ -1641,18 +1626,15 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const {
}
void Variant::get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list) {
-
ERR_FAIL_INDEX(p_type, VARIANT_MAX);
//custom constructors
for (const List<_VariantCall::ConstructData>::Element *E = _VariantCall::construct_funcs[p_type].constructors.front(); E; E = E->next()) {
-
const _VariantCall::ConstructData &cd = E->get();
MethodInfo mi;
mi.name = Variant::get_type_name(p_type);
mi.return_val.type = p_type;
for (int i = 0; i < cd.arg_count; i++) {
-
PropertyInfo pi;
pi.name = cd.arg_names[i];
pi.type = cd.arg_types[i];
@@ -1662,10 +1644,12 @@ void Variant::get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_lis
}
//default constructors
for (int i = 0; i < VARIANT_MAX; i++) {
- if (i == p_type)
+ if (i == p_type) {
continue;
- if (!Variant::can_convert(Variant::Type(i), p_type))
+ }
+ if (!Variant::can_convert(Variant::Type(i), p_type)) {
continue;
+ }
MethodInfo mi;
mi.name = Variant::get_type_name(p_type);
@@ -1679,39 +1663,39 @@ void Variant::get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_lis
}
void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants) {
-
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
_VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
#ifdef DEBUG_ENABLED
for (List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) {
-
p_constants->push_back(E->get());
#else
for (Map<StringName, int>::Element *E = cd.value.front(); E; E = E->next()) {
-
p_constants->push_back(E->key());
#endif
}
+#ifdef DEBUG_ENABLED
+ for (List<StringName>::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) {
+ p_constants->push_back(E->get());
+#else
for (Map<StringName, Variant>::Element *E = cd.variant_value.front(); E; E = E->next()) {
-
p_constants->push_back(E->key());
+#endif
}
}
bool Variant::has_constant(Variant::Type p_type, const StringName &p_value) {
-
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
_VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
return cd.value.has(p_value) || cd.variant_value.has(p_value);
}
Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid) {
-
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
_VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
@@ -1720,21 +1704,22 @@ Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_va
if (!E) {
Map<StringName, Variant>::Element *F = cd.variant_value.find(p_value);
if (F) {
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return F->get();
} else {
return -1;
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return E->get();
}
void register_variant_methods() {
-
_VariantCall::type_funcs = memnew_arr(_VariantCall::TypeFunc, Variant::VARIANT_MAX);
_VariantCall::construct_funcs = memnew_arr(_VariantCall::ConstructFunc, Variant::VARIANT_MAX);
@@ -2395,7 +2380,6 @@ void register_variant_methods() {
}
void unregister_variant_methods() {
-
memdelete_arr(_VariantCall::type_funcs);
memdelete_arr(_VariantCall::construct_funcs);
memdelete_arr(_VariantCall::constant_data);
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 4c9848f26a..2c79e2029e 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -115,6 +115,7 @@
TYPE(PREFIX, OP, PACKED_VECTOR3_ARRAY), \
TYPE(PREFIX, OP, PACKED_COLOR_ARRAY), \
}
+
/* clang-format on */
#define CASES(PREFIX) static const void *switch_table_##PREFIX[25][Variant::VARIANT_MAX] = { \
@@ -159,7 +160,6 @@
#endif
Variant::operator bool() const {
-
return booleanize();
}
@@ -189,7 +189,7 @@ bool Variant::booleanize() const {
_RETURN(p_a._data.m_type m_op p_b._data._float); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -201,7 +201,7 @@ bool Variant::booleanize() const {
_RETURN(!(p_b.type m_op NIL)); \
\
_RETURN_FAIL \
- };
+ }
#ifdef DEBUG_ENABLED
#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \
@@ -222,7 +222,7 @@ bool Variant::booleanize() const {
} \
\
_RETURN_FAIL \
- };
+ }
#else
#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -232,18 +232,18 @@ bool Variant::booleanize() const {
_RETURN(p_a._data.m_type / p_b._data._float); \
\
_RETURN_FAIL \
- };
+ }
#endif
#define DEFAULT_OP_NUM_NEG(m_prefix, m_op_name, m_name, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
_RETURN(-p_a._data.m_type); \
- };
+ }
#define DEFAULT_OP_NUM_POS(m_prefix, m_op_name, m_name, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
_RETURN(p_a._data.m_type); \
- };
+ }
#define DEFAULT_OP_NUM_VEC(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -261,7 +261,7 @@ bool Variant::booleanize() const {
_RETURN(p_a._data.m_type m_op *reinterpret_cast<const Vector3 *>(p_b._data._mem)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_STR_REV(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -273,7 +273,7 @@ bool Variant::booleanize() const {
_RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const NodePath *>(p_a._data._mem)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_STR(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -285,7 +285,7 @@ bool Variant::booleanize() const {
_RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const NodePath *>(p_b._data._mem)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_STR_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -299,7 +299,7 @@ bool Variant::booleanize() const {
_RETURN(!(p_b.type m_op NIL)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_STR_NULL_NP(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -311,7 +311,7 @@ bool Variant::booleanize() const {
_RETURN(!(p_b.type m_op NIL)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_STR_NULL_SN(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -323,7 +323,7 @@ bool Variant::booleanize() const {
_RETURN(!(p_b.type m_op NIL)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_LOCALMEM_REV(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -331,7 +331,7 @@ bool Variant::booleanize() const {
_RETURN(*reinterpret_cast<const m_type *>(p_b._data._mem) m_op *reinterpret_cast<const m_type *>(p_a._data._mem)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_LOCALMEM(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -339,7 +339,7 @@ bool Variant::booleanize() const {
_RETURN(*reinterpret_cast<const m_type *>(p_a._data._mem) m_op *reinterpret_cast<const m_type *>(p_b._data._mem)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_LOCALMEM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -349,7 +349,7 @@ bool Variant::booleanize() const {
_RETURN(!(p_b.type m_op NIL)); \
\
_RETURN_FAIL \
- };
+ }
#define DEFAULT_OP_LOCALMEM_NEG(m_prefix, m_op_name, m_name, m_type) \
CASE_TYPE(m_prefix, m_op_name, m_name) { \
@@ -435,7 +435,6 @@ bool Variant::booleanize() const {
if (a_len m_opa array_b.size()) { \
_RETURN(m_ret_s); \
} else { \
- \
const m_type *ra = array_a.ptr(); \
const m_type *rb = array_b.ptr(); \
\
@@ -461,7 +460,6 @@ bool Variant::booleanize() const {
void Variant::evaluate(const Operator &p_op, const Variant &p_a,
const Variant &p_b, Variant &r_ret, bool &r_valid) {
-
CASES(math);
r_valid = true;
@@ -918,10 +916,12 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
int asize = array_a.size();
int bsize = array_b.size();
sum.resize(asize + bsize);
- for (int i = 0; i < asize; i++)
+ for (int i = 0; i < asize; i++) {
sum[i] = array_a[i];
- for (int i = 0; i < bsize; i++)
+ }
+ for (int i = 0; i < bsize; i++) {
sum[i + asize] = array_b[i];
+ }
_RETURN(sum);
}
@@ -1418,7 +1418,6 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
}
void Variant::set_named(const StringName &p_index, const Variant &p_value, bool *r_valid) {
-
bool valid = false;
switch (type) {
case VECTOR2: {
@@ -1466,7 +1465,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case RECT2: {
-
if (p_value.type == Variant::VECTOR2) {
Rect2 *v = reinterpret_cast<Rect2 *>(_data._mem);
//scalar name
@@ -1483,7 +1481,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break;
case RECT2I: {
-
if (p_value.type == Variant::VECTOR2I) {
Rect2i *v = reinterpret_cast<Rect2i *>(_data._mem);
//scalar name
@@ -1500,7 +1497,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break;
case TRANSFORM2D: {
-
if (p_value.type == Variant::VECTOR2) {
Transform2D *v = _data._transform2d;
if (p_index == CoreStringNames::singleton->x) {
@@ -1517,7 +1513,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case VECTOR3: {
-
if (p_value.type == Variant::INT) {
Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
@@ -1546,7 +1541,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case VECTOR3I: {
-
if (p_value.type == Variant::INT) {
Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
@@ -1575,7 +1569,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case PLANE: {
-
if (p_value.type == Variant::INT) {
Plane *v = reinterpret_cast<Plane *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
@@ -1617,7 +1610,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case QUAT: {
-
if (p_value.type == Variant::INT) {
Quat *v = reinterpret_cast<Quat *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
@@ -1652,7 +1644,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case AABB: {
-
if (p_value.type == Variant::VECTOR3) {
::AABB *v = _data._aabb;
//scalar name
@@ -1669,7 +1660,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break;
case BASIS: {
-
if (p_value.type == Variant::VECTOR3) {
Basis *v = _data._basis;
//scalar name
@@ -1686,7 +1676,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break;
case TRANSFORM: {
-
if (p_value.type == Variant::BASIS && p_index == CoreStringNames::singleton->basis) {
_data._transform->basis = *p_value._data._basis;
valid = true;
@@ -1697,7 +1686,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
} break;
case COLOR: {
-
if (p_value.type == Variant::INT) {
Color *v = reinterpret_cast<Color *>(_data._mem);
if (p_index == CoreStringNames::singleton->r) {
@@ -1773,7 +1761,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break;
case OBJECT: {
-
#ifdef DEBUG_ENABLED
if (!_get_obj().obj) {
break;
@@ -1796,7 +1783,6 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
-
if (r_valid) {
*r_valid = true;
}
@@ -1820,7 +1806,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case RECT2: {
-
const Rect2 *v = reinterpret_cast<const Rect2 *>(_data._mem);
//scalar name
if (p_index == CoreStringNames::singleton->position) {
@@ -1832,7 +1817,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
}
} break;
case RECT2I: {
-
const Rect2i *v = reinterpret_cast<const Rect2i *>(_data._mem);
//scalar name
if (p_index == CoreStringNames::singleton->position) {
@@ -1844,7 +1828,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
}
} break;
case TRANSFORM2D: {
-
const Transform2D *v = _data._transform2d;
if (p_index == CoreStringNames::singleton->x) {
return v->elements[0];
@@ -1856,7 +1839,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case VECTOR3: {
-
const Vector3 *v = reinterpret_cast<const Vector3 *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
return v->x;
@@ -1868,7 +1850,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case VECTOR3I: {
-
const Vector3i *v = reinterpret_cast<const Vector3i *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
return v->x;
@@ -1880,7 +1861,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case PLANE: {
-
const Plane *v = reinterpret_cast<const Plane *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
return v->normal.x;
@@ -1896,7 +1876,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case QUAT: {
-
const Quat *v = reinterpret_cast<const Quat *>(_data._mem);
if (p_index == CoreStringNames::singleton->x) {
return v->x;
@@ -1910,7 +1889,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case AABB: {
-
const ::AABB *v = _data._aabb;
//scalar name
if (p_index == CoreStringNames::singleton->position) {
@@ -1922,7 +1900,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
}
} break;
case BASIS: {
-
const Basis *v = _data._basis;
//scalar name
if (p_index == CoreStringNames::singleton->x) {
@@ -1935,7 +1912,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case TRANSFORM: {
-
if (p_index == CoreStringNames::singleton->basis) {
return _data._transform->basis;
} else if (p_index == CoreStringNames::singleton->origin) {
@@ -1944,7 +1920,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
case COLOR: {
-
const Color *v = reinterpret_cast<const Color *>(_data._mem);
if (p_index == CoreStringNames::singleton->r) {
return v->r;
@@ -1971,17 +1946,17 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
}
} break;
case OBJECT: {
-
#ifdef DEBUG_ENABLED
if (!_get_obj().obj) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return "Instance base is null.";
} else {
-
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return "Attempted use of stray pointer object.";
}
}
@@ -2039,7 +2014,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
#define DEFAULT_OP_DVECTOR_GET(m_name, m_type) \
case m_name: { \
- \
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) { \
int index = p_index; \
const Vector<m_type> *arr = &PackedArrayRef<m_type>::get_array(_data.packed_array); \
@@ -2054,7 +2028,6 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} break;
void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) {
-
static bool _dummy = false;
bool &valid = r_valid ? *r_valid : _dummy;
@@ -2074,24 +2047,24 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
} break;
case STRING: {
-
- if (p_index.type != Variant::INT && p_index.type != Variant::FLOAT)
+ if (p_index.type != Variant::INT && p_index.type != Variant::FLOAT) {
return;
+ }
int idx = p_index;
String *str = reinterpret_cast<String *>(_data._mem);
int len = str->length();
- if (idx < 0)
+ if (idx < 0) {
idx += len;
- if (idx < 0 || idx >= len)
+ }
+ if (idx < 0 || idx >= len) {
return;
+ }
String chr;
if (p_value.type == Variant::INT || p_value.type == Variant::FLOAT) {
-
chr = String::chr(p_value);
} else if (p_value.type == Variant::STRING) {
-
chr = p_value;
} else {
return;
@@ -2103,18 +2076,18 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR2: {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 2;
+ }
if (idx >= 0 && idx < 2) {
-
Vector2 *v = reinterpret_cast<Vector2 *>(_data._mem);
valid = true;
(*v)[idx] = p_value;
@@ -2138,18 +2111,18 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR2I: {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 2;
+ }
if (idx >= 0 && idx < 2) {
-
Vector2i *v = reinterpret_cast<Vector2i *>(_data._mem);
valid = true;
(*v)[idx] = p_value;
@@ -2173,9 +2146,9 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case RECT2: {
-
- if (p_value.type != Variant::VECTOR2)
+ if (p_value.type != Variant::VECTOR2) {
return;
+ }
if (p_index.get_type() == Variant::STRING) {
//scalar name
@@ -2198,9 +2171,9 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
} break;
case RECT2I: {
-
- if (p_value.type != Variant::VECTOR2I)
+ if (p_value.type != Variant::VECTOR2I) {
return;
+ }
if (p_index.get_type() == Variant::STRING) {
//scalar name
@@ -2223,16 +2196,16 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
} break;
case TRANSFORM2D: {
-
- if (p_value.type != Variant::VECTOR2)
+ if (p_value.type != Variant::VECTOR2) {
return;
+ }
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int index = p_index;
- if (index < 0)
+ if (index < 0) {
index += 3;
+ }
if (index >= 0 && index < 3) {
Transform2D *v = _data._transform2d;
@@ -2241,7 +2214,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
}
} else if (p_index.get_type() == Variant::STRING && p_value.get_type() == Variant::VECTOR2) {
-
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Transform2D *v = _data._transform2d;
@@ -2262,24 +2234,23 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR3: {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 3;
+ }
if (idx >= 0 && idx < 3) {
-
Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem);
valid = true;
(*v)[idx] = p_value;
return;
}
} else if (p_index.get_type() == Variant::STRING) {
-
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Vector3 *v = reinterpret_cast<Vector3 *>(_data._mem);
@@ -2300,24 +2271,23 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case VECTOR3I: {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 3;
+ }
if (idx >= 0 && idx < 3) {
-
Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem);
valid = true;
(*v)[idx] = p_value;
return;
}
} else if (p_index.get_type() == Variant::STRING) {
-
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Vector3i *v = reinterpret_cast<Vector3i *>(_data._mem);
@@ -2338,35 +2308,38 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case PLANE: {
-
if (p_index.get_type() == Variant::STRING) {
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Plane *v = reinterpret_cast<Plane *>(_data._mem);
if (*str == "x") {
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
valid = true;
v->normal.x = p_value;
return;
} else if (*str == "y") {
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
valid = true;
v->normal.y = p_value;
return;
} else if (*str == "z") {
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
valid = true;
v->normal.z = p_value;
return;
} else if (*str == "normal") {
- if (p_value.type != Variant::VECTOR3)
+ if (p_value.type != Variant::VECTOR3) {
return;
+ }
valid = true;
v->normal = p_value;
@@ -2380,12 +2353,11 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case QUAT: {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
if (p_index.get_type() == Variant::STRING) {
-
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Quat *v = reinterpret_cast<Quat *>(_data._mem);
if (*str == "x") {
@@ -2409,9 +2381,9 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case AABB: {
-
- if (p_value.type != Variant::VECTOR3)
+ if (p_value.type != Variant::VECTOR3) {
return;
+ }
if (p_index.get_type() == Variant::STRING) {
//scalar name
@@ -2434,16 +2406,16 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
} break;
case BASIS: {
-
- if (p_value.type != Variant::VECTOR3)
+ if (p_value.type != Variant::VECTOR3) {
return;
+ }
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int index = p_index;
- if (index < 0)
+ if (index < 0) {
index += 3;
+ }
if (index >= 0 && index < 3) {
Basis *v = _data._basis;
@@ -2452,7 +2424,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
}
} else if (p_index.get_type() == Variant::STRING) {
-
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Basis *v = _data._basis;
@@ -2473,41 +2444,42 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case TRANSFORM: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
- if (p_value.type != Variant::VECTOR3)
+ if (p_value.type != Variant::VECTOR3) {
return;
+ }
int index = p_index;
- if (index < 0)
+ if (index < 0) {
index += 4;
+ }
if (index >= 0 && index < 4) {
Transform *v = _data._transform;
valid = true;
- if (index == 3)
+ if (index == 3) {
v->origin = p_value;
- else
+ } else {
v->basis.set_axis(index, p_value);
+ }
return;
}
} else if (p_index.get_type() == Variant::STRING) {
-
Transform *v = _data._transform;
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
if (*str == "basis") {
-
- if (p_value.type != Variant::BASIS)
+ if (p_value.type != Variant::BASIS) {
return;
+ }
valid = true;
v->basis = p_value;
return;
}
if (*str == "origin") {
- if (p_value.type != Variant::VECTOR3)
+ if (p_value.type != Variant::VECTOR3) {
return;
+ }
valid = true;
v->origin = p_value;
return;
@@ -2516,12 +2488,11 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
} break;
case COLOR: {
-
- if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT)
+ if (p_value.type != Variant::INT && p_value.type != Variant::FLOAT) {
return;
+ }
if (p_index.get_type() == Variant::STRING) {
-
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
Color *v = reinterpret_cast<Color *>(_data._mem);
if (*str == "r") {
@@ -2570,10 +2541,10 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
}
} else if (p_index.get_type() == Variant::INT) {
-
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 4;
+ }
if (idx >= 0 && idx < 4) {
Color *v = reinterpret_cast<Color *>(_data._mem);
(*v)[idx] = p_value;
@@ -2589,14 +2560,12 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
case _RID: {
} break;
case OBJECT: {
-
Object *obj = _get_obj().obj;
//only if debugging!
if (obj) {
#ifdef DEBUG_ENABLED
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
-
WARN_PRINT("Attempted use of previously freed pointer object.");
valid = false;
return;
@@ -2613,7 +2582,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
} break;
case DICTIONARY: {
-
Dictionary *dic = reinterpret_cast<Dictionary *>(_data._mem);
dic->operator[](p_index) = p_value;
valid = true; //always valid, i guess? should this really be ok?
@@ -2635,7 +2603,6 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
Variant Variant::get(const Variant &p_index, bool *r_valid) const {
-
static bool _dummy = false;
bool &valid = r_valid ? *r_valid : _dummy;
@@ -2656,16 +2623,15 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
return Variant();
} break;
case STRING: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//string index
int idx = p_index;
const String *str = reinterpret_cast<const String *>(_data._mem);
- if (idx < 0)
+ if (idx < 0) {
idx += str->length();
+ }
if (idx >= 0 && idx < str->length()) {
-
valid = true;
return str->substr(idx, 1);
}
@@ -2673,14 +2639,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case VECTOR2: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 2;
+ }
if (idx >= 0 && idx < 2) {
-
const Vector2 *v = reinterpret_cast<const Vector2 *>(_data._mem);
valid = true;
return (*v)[idx];
@@ -2701,14 +2666,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case VECTOR2I: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
// scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 2;
+ }
if (idx >= 0 && idx < 2) {
-
const Vector2i *v = reinterpret_cast<const Vector2i *>(_data._mem);
valid = true;
return (*v)[idx];
@@ -2729,7 +2693,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case RECT2: {
-
if (p_index.get_type() == Variant::STRING) {
//scalar name
@@ -2748,7 +2711,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break;
case RECT2I: {
-
if (p_index.get_type() == Variant::STRING) {
//scalar name
@@ -2767,20 +2729,18 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break;
case VECTOR3: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 3;
+ }
if (idx >= 0 && idx < 3) {
-
const Vector3 *v = reinterpret_cast<const Vector3 *>(_data._mem);
valid = true;
return (*v)[idx];
}
} else if (p_index.get_type() == Variant::STRING) {
-
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Vector3 *v = reinterpret_cast<const Vector3 *>(_data._mem);
@@ -2798,20 +2758,18 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case VECTOR3I: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
//scalar index
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 3;
+ }
if (idx >= 0 && idx < 3) {
-
const Vector3i *v = reinterpret_cast<const Vector3i *>(_data._mem);
valid = true;
return (*v)[idx];
}
} else if (p_index.get_type() == Variant::STRING) {
-
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Vector3i *v = reinterpret_cast<const Vector3i *>(_data._mem);
@@ -2829,13 +2787,12 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case TRANSFORM2D: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int index = p_index;
- if (index < 0)
+ if (index < 0) {
index += 3;
+ }
if (index >= 0 && index < 3) {
const Transform2D *v = _data._transform2d;
@@ -2843,7 +2800,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
return v->elements[index];
}
} else if (p_index.get_type() == Variant::STRING) {
-
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Transform2D *v = _data._transform2d;
@@ -2861,7 +2817,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case PLANE: {
-
if (p_index.get_type() == Variant::STRING) {
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
@@ -2886,9 +2841,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case QUAT: {
-
if (p_index.get_type() == Variant::STRING) {
-
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Quat *v = reinterpret_cast<const Quat *>(_data._mem);
if (*str == "x") {
@@ -2908,7 +2861,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case AABB: {
-
if (p_index.get_type() == Variant::STRING) {
//scalar name
@@ -2927,12 +2879,11 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break;
case BASIS: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int index = p_index;
- if (index < 0)
+ if (index < 0) {
index += 3;
+ }
if (index >= 0 && index < 3) {
const Basis *v = _data._basis;
@@ -2940,7 +2891,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
return v->get_axis(index);
}
} else if (p_index.get_type() == Variant::STRING) {
-
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Basis *v = _data._basis;
@@ -2958,19 +2908,17 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case TRANSFORM: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int index = p_index;
- if (index < 0)
+ if (index < 0) {
index += 4;
+ }
if (index >= 0 && index < 4) {
const Transform *v = _data._transform;
valid = true;
return index == 3 ? v->origin : v->basis.get_axis(index);
}
} else if (p_index.get_type() == Variant::STRING) {
-
const Transform *v = _data._transform;
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
@@ -2986,9 +2934,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case COLOR: {
-
if (p_index.get_type() == Variant::STRING) {
-
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
const Color *v = reinterpret_cast<const Color *>(_data._mem);
if (*str == "r") {
@@ -3026,10 +2972,10 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
return (int)Math::round(v->a * 255.0);
}
} else if (p_index.get_type() == Variant::INT) {
-
int idx = p_index;
- if (idx < 0)
+ if (idx < 0) {
idx += 4;
+ }
if (idx >= 0 && idx < 4) {
const Color *v = reinterpret_cast<const Color *>(_data._mem);
valid = true;
@@ -3047,7 +2993,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
case OBJECT: {
Object *obj = _get_obj().obj;
if (obj) {
-
#ifdef DEBUG_ENABLED
if (EngineDebugger::is_active() && !_get_obj().id.is_reference() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
@@ -3065,7 +3010,6 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
} break;
case DICTIONARY: {
-
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
const Variant *res = dic->getptr(p_index);
if (res) {
@@ -3091,14 +3035,12 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
bool Variant::in(const Variant &p_index, bool *r_valid) const {
-
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
switch (type) {
-
case STRING: {
-
if (p_index.get_type() == Variant::STRING) {
//string index
String idx = p_index;
@@ -3111,7 +3053,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
case OBJECT: {
Object *obj = _get_obj().obj;
if (obj) {
-
bool valid = false;
#ifdef DEBUG_ENABLED
@@ -3132,26 +3073,25 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
return valid;
} else {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
}
return false;
} break;
case DICTIONARY: {
-
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
return dic->has(p_index);
} break;
case ARRAY: {
-
const Array *arr = reinterpret_cast<const Array *>(_data._mem);
int l = arr->size();
if (l) {
for (int i = 0; i < l; i++) {
-
- if (evaluate(OP_EQUAL, (*arr)[i], p_index))
+ if (evaluate(OP_EQUAL, (*arr)[i], p_index)) {
return true;
+ }
}
}
@@ -3160,15 +3100,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_BYTE_ARRAY: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int index = p_index;
const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
const uint8_t *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3178,15 +3118,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_INT32_ARRAY: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int32_t index = p_index;
const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
int32_t l = arr->size();
if (l) {
const int32_t *r = arr->ptr();
for (int32_t i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3195,15 +3135,15 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_INT64_ARRAY: {
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
int64_t index = p_index;
const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
int64_t l = arr->size();
if (l) {
const int64_t *r = arr->ptr();
for (int64_t i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3211,17 +3151,16 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
} break;
case PACKED_FLOAT32_ARRAY: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
real_t index = p_index;
const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
const float *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3230,17 +3169,16 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_FLOAT64_ARRAY: {
-
if (p_index.get_type() == Variant::INT || p_index.get_type() == Variant::FLOAT) {
-
real_t index = p_index;
const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
int l = arr->size();
if (l) {
const double *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3250,7 +3188,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_STRING_ARRAY: {
if (p_index.get_type() == Variant::STRING) {
-
String index = p_index;
const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
@@ -3258,8 +3195,9 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (l) {
const String *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3269,7 +3207,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break; //25
case PACKED_VECTOR2_ARRAY: {
if (p_index.get_type() == Variant::VECTOR2) {
-
Vector2 index = p_index;
const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
@@ -3277,8 +3214,9 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (l) {
const Vector2 *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3288,7 +3226,6 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_VECTOR3_ARRAY: {
if (p_index.get_type() == Variant::VECTOR3) {
-
Vector3 index = p_index;
const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
@@ -3296,8 +3233,9 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (l) {
const Vector3 *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3306,9 +3244,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
} break;
case PACKED_COLOR_ARRAY: {
-
if (p_index.get_type() == Variant::COLOR) {
-
Color index = p_index;
const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
@@ -3316,8 +3252,9 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (l) {
const Color *r = arr->ptr();
for (int i = 0; i < l; i++) {
- if (r[i] == index)
+ if (r[i] == index) {
return true;
+ }
}
}
@@ -3328,63 +3265,55 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return false;
}
void Variant::get_property_list(List<PropertyInfo> *p_list) const {
-
switch (type) {
case VECTOR2: {
-
p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
} break;
case VECTOR2I: {
-
p_list->push_back(PropertyInfo(Variant::INT, "x"));
p_list->push_back(PropertyInfo(Variant::INT, "y"));
} break;
case RECT2: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR2, "position"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "size"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "end"));
} break;
case RECT2I: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "position"));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "size"));
p_list->push_back(PropertyInfo(Variant::VECTOR2I, "end"));
} break;
case VECTOR3: {
-
p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "z"));
} break;
case VECTOR3I: {
-
p_list->push_back(PropertyInfo(Variant::INT, "x"));
p_list->push_back(PropertyInfo(Variant::INT, "y"));
p_list->push_back(PropertyInfo(Variant::INT, "z"));
} break;
case TRANSFORM2D: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR2, "x"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "y"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "origin"));
} break;
case PLANE: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR3, "normal"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
@@ -3393,7 +3322,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} break;
case QUAT: {
-
p_list->push_back(PropertyInfo(Variant::FLOAT, "x"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "y"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "z"));
@@ -3406,14 +3334,12 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "end"));
} break;
case BASIS: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR3, "x"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "y"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "z"));
} break;
case TRANSFORM: {
-
p_list->push_back(PropertyInfo(Variant::BASIS, "basis"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "origin"));
@@ -3439,7 +3365,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
case _RID: {
} break;
case OBJECT: {
-
Object *obj = _get_obj().obj;
if (obj) {
#ifdef DEBUG_ENABLED
@@ -3456,7 +3381,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
} break;
case DICTIONARY: {
-
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
List<Variant> keys;
dic->get_key_list(&keys);
@@ -3476,7 +3400,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
case PACKED_VECTOR2_ARRAY:
case PACKED_VECTOR3_ARRAY:
case PACKED_COLOR_ARRAY: {
-
//nothing
} break;
default: {
@@ -3485,7 +3408,6 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
}
bool Variant::iter_init(Variant &r_iter, bool &valid) const {
-
valid = true;
switch (type) {
case INT: {
@@ -3541,7 +3463,6 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
return step < 0;
} break;
case OBJECT: {
-
if (!_get_obj().obj) {
valid = false;
return false;
@@ -3573,18 +3494,18 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
} break;
case STRING: {
-
const String *str = reinterpret_cast<const String *>(_data._mem);
- if (str->empty())
+ if (str->empty()) {
return false;
+ }
r_iter = 0;
return true;
} break;
case DICTIONARY: {
-
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
- if (dic->empty())
+ if (dic->empty()) {
return false;
+ }
const Variant *next = dic->next(nullptr);
r_iter = *next;
@@ -3592,81 +3513,87 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
} break;
case ARRAY: {
-
const Array *arr = reinterpret_cast<const Array *>(_data._mem);
- if (arr->empty())
+ if (arr->empty()) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_BYTE_ARRAY: {
const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_INT32_ARRAY: {
const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_INT64_ARRAY: {
const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_FLOAT32_ARRAY: {
const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_FLOAT64_ARRAY: {
const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_STRING_ARRAY: {
const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_VECTOR2_ARRAY: {
-
const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_VECTOR3_ARRAY: {
-
const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
} break;
case PACKED_COLOR_ARRAY: {
-
const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
- if (arr->size() == 0)
+ if (arr->size() == 0) {
return false;
+ }
r_iter = 0;
return true;
@@ -3678,23 +3605,25 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const {
valid = false;
return false;
}
-bool Variant::iter_next(Variant &r_iter, bool &valid) const {
+bool Variant::iter_next(Variant &r_iter, bool &valid) const {
valid = true;
switch (type) {
case INT: {
int64_t idx = r_iter;
idx++;
- if (idx >= _data._int)
+ if (idx >= _data._int) {
return false;
+ }
r_iter = idx;
return true;
} break;
case FLOAT: {
int64_t idx = r_iter;
idx++;
- if (idx >= _data._float)
+ if (idx >= _data._float) {
return false;
+ }
r_iter = idx;
return true;
} break;
@@ -3704,8 +3633,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
double idx = r_iter;
idx++;
- if (idx >= to)
+ if (idx >= to) {
return false;
+ }
r_iter = idx;
return true;
@@ -3716,8 +3646,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
int64_t idx = r_iter;
idx++;
- if (idx >= to)
+ if (idx >= to) {
return false;
+ }
r_iter = idx;
return true;
@@ -3729,11 +3660,13 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
double idx = r_iter;
idx += step;
- if (step < 0 && idx <= to)
+ if (step < 0 && idx <= to) {
return false;
+ }
- if (step > 0 && idx >= to)
+ if (step > 0 && idx >= to) {
return false;
+ }
r_iter = idx;
return true;
@@ -3745,17 +3678,18 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
int64_t idx = r_iter;
idx += step;
- if (step < 0 && idx <= to)
+ if (step < 0 && idx <= to) {
return false;
+ }
- if (step > 0 && idx >= to)
+ if (step > 0 && idx >= to) {
return false;
+ }
r_iter = idx;
return true;
} break;
case OBJECT: {
-
if (!_get_obj().obj) {
valid = false;
return false;
@@ -3788,33 +3722,33 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
} break;
case STRING: {
-
const String *str = reinterpret_cast<const String *>(_data._mem);
int idx = r_iter;
idx++;
- if (idx >= str->length())
+ if (idx >= str->length()) {
return false;
+ }
r_iter = idx;
return true;
} break;
case DICTIONARY: {
-
const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem);
const Variant *next = dic->next(&r_iter);
- if (!next)
+ if (!next) {
return false;
+ }
r_iter = *next;
return true;
} break;
case ARRAY: {
-
const Array *arr = reinterpret_cast<const Array *>(_data._mem);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
} break;
@@ -3822,8 +3756,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
const Vector<uint8_t> *arr = &PackedArrayRef<uint8_t>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
@@ -3832,8 +3767,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
const Vector<int32_t> *arr = &PackedArrayRef<int32_t>::get_array(_data.packed_array);
int32_t idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
@@ -3842,8 +3778,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
const Vector<int64_t> *arr = &PackedArrayRef<int64_t>::get_array(_data.packed_array);
int64_t idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
@@ -3852,8 +3789,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
const Vector<float> *arr = &PackedArrayRef<float>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
@@ -3862,8 +3800,9 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
const Vector<double> *arr = &PackedArrayRef<double>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
@@ -3872,38 +3811,39 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
const Vector<String> *arr = &PackedArrayRef<String>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
} break;
case PACKED_VECTOR2_ARRAY: {
-
const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
} break;
case PACKED_VECTOR3_ARRAY: {
-
const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
} break;
case PACKED_COLOR_ARRAY: {
-
const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
int idx = r_iter;
idx++;
- if (idx >= arr->size())
+ if (idx >= arr->size()) {
return false;
+ }
r_iter = idx;
return true;
} break;
@@ -3916,35 +3856,27 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const {
}
Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
-
r_valid = true;
switch (type) {
case INT: {
-
return r_iter;
} break;
case FLOAT: {
-
return r_iter;
} break;
case VECTOR2: {
-
return r_iter;
} break;
case VECTOR2I: {
-
return r_iter;
} break;
case VECTOR3: {
-
return r_iter;
} break;
case VECTOR3I: {
-
return r_iter;
} break;
case OBJECT: {
-
if (!_get_obj().obj) {
r_valid = false;
return Variant();
@@ -3972,17 +3904,14 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
} break;
case STRING: {
-
const String *str = reinterpret_cast<const String *>(_data._mem);
return str->substr(r_iter, 1);
} break;
case DICTIONARY: {
-
return r_iter; //iterator is the same as the key
} break;
case ARRAY: {
-
const Array *arr = reinterpret_cast<const Array *>(_data._mem);
int idx = r_iter;
#ifdef DEBUG_ENABLED
@@ -4060,7 +3989,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return arr->get(idx);
} break;
case PACKED_VECTOR2_ARRAY: {
-
const Vector<Vector2> *arr = &PackedArrayRef<Vector2>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
@@ -4072,7 +4000,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return arr->get(idx);
} break;
case PACKED_VECTOR3_ARRAY: {
-
const Vector<Vector3> *arr = &PackedArrayRef<Vector3>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
@@ -4084,7 +4011,6 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return arr->get(idx);
} break;
case PACKED_COLOR_ARRAY: {
-
const Vector<Color> *arr = &PackedArrayRef<Color>::get_array(_data.packed_array);
int idx = r_iter;
#ifdef DEBUG_ENABLED
@@ -4237,7 +4163,6 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst)
}
void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst) {
-
if (a.type != b.type) {
if (a.is_num() && b.is_num()) {
//not as efficient but..
@@ -4252,7 +4177,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
switch (a.type) {
-
case NIL: {
r_dst = Variant();
}
@@ -4290,22 +4214,21 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
int split = csize / 2;
for (int i = 0; i < csize; i++) {
-
CharType chr = ' ';
if (i < split) {
-
- if (i < sa.length())
+ if (i < sa.length()) {
chr = sa[i];
- else if (i < sb.length())
+ } else if (i < sb.length()) {
chr = sb[i];
+ }
} else {
-
- if (i < sb.length())
+ if (i < sb.length()) {
chr = sb[i];
- else if (i < sa.length())
+ } else if (i < sa.length()) {
chr = sa[i];
+ }
}
dst[i] = chr;
@@ -4423,10 +4346,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
const Vector<int32_t> *arr_b = &PackedArrayRef<int32_t>::get_array(b._data.packed_array);
int32_t sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<int32_t> v;
v.resize(sz);
{
@@ -4449,10 +4370,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
const Vector<int64_t> *arr_b = &PackedArrayRef<int64_t>::get_array(b._data.packed_array);
int64_t sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<int64_t> v;
v.resize(sz);
{
@@ -4475,10 +4394,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
const Vector<float> *arr_b = &PackedArrayRef<float>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<float> v;
v.resize(sz);
{
@@ -4501,10 +4418,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
const Vector<double> *arr_b = &PackedArrayRef<double>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<double> v;
v.resize(sz);
{
@@ -4531,10 +4446,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
const Vector<Vector2> *arr_b = &PackedArrayRef<Vector2>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<Vector2> v;
v.resize(sz);
{
@@ -4551,15 +4464,12 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
return;
case PACKED_VECTOR3_ARRAY: {
-
const Vector<Vector3> *arr_a = &PackedArrayRef<Vector3>::get_array(a._data.packed_array);
const Vector<Vector3> *arr_b = &PackedArrayRef<Vector3>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<Vector3> v;
v.resize(sz);
{
@@ -4580,10 +4490,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
const Vector<Color> *arr_b = &PackedArrayRef<Color>::get_array(b._data.packed_array);
int sz = arr_a->size();
if (sz == 0 || arr_b->size() != sz) {
-
r_dst = a;
} else {
-
Vector<Color> v;
v.resize(sz);
{
@@ -4600,7 +4508,6 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
}
return;
default: {
-
r_dst = a;
}
}
@@ -4636,7 +4543,6 @@ static const char *_op_names[Variant::OP_MAX] = {
};
String Variant::get_operator_name(Operator p_op) {
-
ERR_FAIL_INDEX_V(p_op, OP_MAX, "");
return _op_names[p_op];
}
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index c9678c9933..74f4f32c0e 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -36,21 +36,18 @@
#include "core/string_buffer.h"
CharType VariantParser::StreamFile::get_char() {
-
return f->get_8();
}
bool VariantParser::StreamFile::is_utf8() const {
-
return true;
}
-bool VariantParser::StreamFile::is_eof() const {
+bool VariantParser::StreamFile::is_eof() const {
return f->eof_reached();
}
CharType VariantParser::StreamString::get_char() {
-
if (pos > s.length()) {
return 0;
} else if (pos == s.length()) {
@@ -66,6 +63,7 @@ CharType VariantParser::StreamString::get_char() {
bool VariantParser::StreamString::is_utf8() const {
return false;
}
+
bool VariantParser::StreamString::is_eof() const {
return pos > s.length();
}
@@ -93,11 +91,9 @@ const char *VariantParser::tk_name[TK_MAX] = {
};
Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, String &r_err_str) {
-
bool string_name = false;
while (true) {
-
CharType cchar;
if (p_stream->saved) {
cchar = p_stream->saved;
@@ -111,82 +107,69 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
}
switch (cchar) {
-
case '\n': {
-
line++;
break;
- };
+ }
case 0: {
r_token.type = TK_EOF;
return OK;
} break;
case '{': {
-
r_token.type = TK_CURLY_BRACKET_OPEN;
return OK;
- };
+ }
case '}': {
-
r_token.type = TK_CURLY_BRACKET_CLOSE;
return OK;
- };
+ }
case '[': {
-
r_token.type = TK_BRACKET_OPEN;
return OK;
- };
+ }
case ']': {
-
r_token.type = TK_BRACKET_CLOSE;
return OK;
- };
+ }
case '(': {
-
r_token.type = TK_PARENTHESIS_OPEN;
return OK;
- };
+ }
case ')': {
-
r_token.type = TK_PARENTHESIS_CLOSE;
return OK;
- };
+ }
case ':': {
-
r_token.type = TK_COLON;
return OK;
- };
+ }
case ';': {
-
while (true) {
CharType ch = p_stream->get_char();
if (p_stream->is_eof()) {
r_token.type = TK_EOF;
return OK;
}
- if (ch == '\n')
+ if (ch == '\n') {
break;
+ }
}
break;
- };
+ }
case ',': {
-
r_token.type = TK_COMMA;
return OK;
- };
+ }
case '.': {
-
r_token.type = TK_PERIOD;
return OK;
- };
+ }
case '=': {
-
r_token.type = TK_EQUAL;
return OK;
- };
+ }
case '#': {
-
StringBuffer<> color_str;
color_str += '#';
while (true) {
@@ -206,7 +189,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
r_token.value = Color::html(color_str.as_string());
r_token.type = TK_COLOR;
return OK;
- };
+ }
case '@': {
cchar = p_stream->get_char();
if (cchar != '"') {
@@ -219,10 +202,8 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
[[fallthrough]];
}
case '"': {
-
String str;
while (true) {
-
CharType ch = p_stream->get_char();
if (ch == 0) {
@@ -242,7 +223,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
CharType res = 0;
switch (next) {
-
case 'b':
res = 8;
break;
@@ -268,7 +248,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
return ERR_PARSE_ERROR;
}
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
-
r_err_str = "Malformed hex constant in string";
r_token.type = TK_ERROR;
return ERR_PARSE_ERROR;
@@ -300,8 +279,9 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
str += res;
} else {
- if (ch == '\n')
+ if (ch == '\n') {
line++;
+ }
str += ch;
}
}
@@ -321,7 +301,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
} break;
default: {
-
if (cchar <= 32) {
break;
}
@@ -348,10 +327,8 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
bool is_float = false;
while (true) {
-
switch (reading) {
case READING_INT: {
-
if (c >= '0' && c <= '9') {
//pass
} else if (c == '.') {
@@ -366,9 +343,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
} break;
case READING_DEC: {
-
if (c >= '0' && c <= '9') {
-
} else if (c == 'e') {
reading = READING_EXP;
} else {
@@ -377,7 +352,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
} break;
case READING_EXP: {
-
if (c >= '0' && c <= '9') {
exp_beg = true;
@@ -390,8 +364,9 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
} break;
}
- if (reading == READING_DONE)
+ if (reading == READING_DONE) {
break;
+ }
num += c;
c = p_stream->get_char();
}
@@ -400,19 +375,18 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
r_token.type = TK_NUMBER;
- if (is_float)
+ if (is_float) {
r_token.value = num.as_double();
- else
+ } else {
r_token.value = num.as_int();
+ }
return OK;
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
-
StringBuffer<> id;
bool first = true;
while ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_' || (!first && cchar >= '0' && cchar <= '9')) {
-
id += cchar;
cchar = p_stream->get_char();
first = false;
@@ -437,7 +411,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
}
Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings, int &line, String &r_err_str) {
-
Token token;
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
@@ -448,7 +421,6 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
String accum;
while (true) {
-
CharType c = p_stream->get_char();
if (p_stream->is_eof()) {
@@ -470,7 +442,6 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
template <class T>
Error VariantParser::_parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str) {
-
Token token;
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
@@ -480,7 +451,6 @@ Error VariantParser::_parse_construct(Stream *p_stream, Vector<T> &r_construct,
bool first = true;
while (true) {
-
if (!first) {
get_token(p_stream, token, line, r_err_str);
if (token.type == TK_COMMA) {
@@ -509,221 +479,208 @@ Error VariantParser::_parse_construct(Stream *p_stream, Vector<T> &r_construct,
}
Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
-
- /* {
- Error err = get_token(p_stream,token,line,r_err_str);
- if (err)
- return err;
- }*/
-
if (token.type == TK_CURLY_BRACKET_OPEN) {
-
Dictionary d;
Error err = _parse_dictionary(d, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
value = d;
return OK;
} else if (token.type == TK_BRACKET_OPEN) {
-
Array a;
Error err = _parse_array(a, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
value = a;
return OK;
-
} else if (token.type == TK_IDENTIFIER) {
-
String id = token.value;
- if (id == "true")
+ if (id == "true") {
value = true;
- else if (id == "false")
+ } else if (id == "false") {
value = false;
- else if (id == "null" || id == "nil")
+ } else if (id == "null" || id == "nil") {
value = Variant();
- else if (id == "inf")
+ } else if (id == "inf") {
value = Math_INF;
- else if (id == "nan")
+ } else if (id == "nan") {
value = Math_NAN;
- else if (id == "Vector2") {
-
+ } else if (id == "Vector2") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 2) {
r_err_str = "Expected 2 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Vector2(args[0], args[1]);
- return OK;
} else if (id == "Vector2i") {
-
Vector<int32_t> args;
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 2) {
r_err_str = "Expected 2 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Vector2i(args[0], args[1]);
- return OK;
} else if (id == "Rect2") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 4) {
r_err_str = "Expected 4 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Rect2(args[0], args[1], args[2], args[3]);
- return OK;
} else if (id == "Rect2i") {
-
Vector<int32_t> args;
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 4) {
r_err_str = "Expected 4 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Rect2i(args[0], args[1], args[2], args[3]);
- return OK;
} else if (id == "Vector3") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 3) {
r_err_str = "Expected 3 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Vector3(args[0], args[1], args[2]);
- return OK;
} else if (id == "Vector3i") {
-
Vector<int32_t> args;
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 3) {
r_err_str = "Expected 3 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Vector3i(args[0], args[1], args[2]);
- return OK;
} else if (id == "Transform2D" || id == "Matrix32") { //compatibility
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 6) {
r_err_str = "Expected 6 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
+
Transform2D m;
m[0] = Vector2(args[0], args[1]);
m[1] = Vector2(args[2], args[3]);
m[2] = Vector2(args[4], args[5]);
value = m;
- return OK;
} else if (id == "Plane") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 4) {
r_err_str = "Expected 4 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Plane(args[0], args[1], args[2], args[3]);
- return OK;
} else if (id == "Quat") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 4) {
r_err_str = "Expected 4 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Quat(args[0], args[1], args[2], args[3]);
- return OK;
-
} else if (id == "AABB" || id == "Rect3") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 6) {
r_err_str = "Expected 6 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
- return OK;
-
} else if (id == "Basis" || id == "Matrix3") { //compatibility
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 9) {
r_err_str = "Expected 9 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
- return OK;
} else if (id == "Transform") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 12) {
r_err_str = "Expected 12 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Transform(Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]), Vector3(args[9], args[10], args[11]));
- return OK;
-
} else if (id == "Color") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (args.size() != 4) {
r_err_str = "Expected 4 arguments for constructor";
+ return ERR_PARSE_ERROR;
}
value = Color(args[0], args[1], args[2], args[3]);
- return OK;
-
} else if (id == "NodePath") {
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '('";
@@ -743,9 +700,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
r_err_str = "Expected ')'";
return ERR_PARSE_ERROR;
}
-
} else if (id == "RID") {
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '('";
@@ -765,10 +720,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
r_err_str = "Expected ')'";
return ERR_PARSE_ERROR;
}
-
- return OK;
} else if (id == "Object") {
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '('";
@@ -803,17 +755,16 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
bool need_comma = false;
while (true) {
-
if (p_stream->is_eof()) {
r_err_str = "Unexpected End of File while parsing Object()";
return ERR_FILE_CORRUPT;
}
if (at_key) {
-
Error err = get_token(p_stream, token2, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token2.type == TK_PARENTHESIS_CLOSE) {
Reference *reference = Object::cast_to<Reference>(obj);
@@ -826,9 +777,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
if (need_comma) {
-
if (token2.type != TK_COMMA) {
-
r_err_str = "Expected '}' or ','";
return ERR_PARSE_ERROR;
} else {
@@ -846,32 +795,31 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
err = get_token(p_stream, token2, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token2.type != TK_COLON) {
-
r_err_str = "Expected ':'";
return ERR_PARSE_ERROR;
}
at_key = false;
} else {
-
Error err = get_token(p_stream, token2, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
Variant v;
err = parse_value(token2, v, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
obj->set(key, v);
need_comma = true;
at_key = true;
}
}
-
} else if (id == "Resource" || id == "SubResource" || id == "ExtResource") {
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '('";
@@ -879,37 +827,30 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
if (p_res_parser && id == "Resource" && p_res_parser->func) {
-
RES res;
Error err = p_res_parser->func(p_res_parser->userdata, p_stream, res, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
value = res;
-
- return OK;
} else if (p_res_parser && id == "ExtResource" && p_res_parser->ext_func) {
-
RES res;
Error err = p_res_parser->ext_func(p_res_parser->userdata, p_stream, res, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
value = res;
-
- return OK;
} else if (p_res_parser && id == "SubResource" && p_res_parser->sub_func) {
-
RES res;
Error err = p_res_parser->sub_func(p_res_parser->userdata, p_stream, res, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
value = res;
-
- return OK;
} else {
-
get_token(p_stream, token, line, r_err_str);
if (token.type == TK_STRING) {
String path = token.value;
@@ -926,20 +867,17 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = res;
- return OK;
-
} else {
r_err_str = "Expected string as argument for Resource().";
return ERR_PARSE_ERROR;
}
}
-
} else if (id == "PackedByteArray" || id == "PoolByteArray" || id == "ByteArray") {
-
Vector<uint8_t> args;
Error err = _parse_construct<uint8_t>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<uint8_t> arr;
{
@@ -952,15 +890,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
-
} else if (id == "PackedInt32Array" || id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") {
-
Vector<int32_t> args;
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<int32_t> arr;
{
@@ -973,15 +908,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
-
} else if (id == "PackedInt64Array") {
-
Vector<int64_t> args;
Error err = _parse_construct<int64_t>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<int64_t> arr;
{
@@ -994,15 +926,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
-
} else if (id == "PackedFloat32Array" || id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<float> arr;
{
@@ -1015,14 +944,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
} else if (id == "PackedFloat64Array") {
-
Vector<double> args;
Error err = _parse_construct<double>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<double> arr;
{
@@ -1035,10 +962,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
} else if (id == "PackedStringArray" || id == "PoolStringArray" || id == "StringArray") {
-
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '('";
@@ -1049,7 +973,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
bool first = true;
while (true) {
-
if (!first) {
get_token(p_stream, token, line, r_err_str);
if (token.type == TK_COMMA) {
@@ -1085,15 +1008,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
-
} else if (id == "PackedVector2Array" || id == "PoolVector2Array" || id == "Vector2Array") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<Vector2> arr;
{
@@ -1106,15 +1026,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
-
} else if (id == "PackedVector3Array" || id == "PoolVector3Array" || id == "Vector3Array") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<Vector3> arr;
{
@@ -1127,15 +1044,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
-
} else if (id == "PackedColorArray" || id == "PoolColorArray" || id == "ColorArray") {
-
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
Vector<Color> arr;
{
@@ -1148,29 +1062,23 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
value = arr;
-
- return OK;
} else {
r_err_str = "Unexpected identifier: '" + id + "'.";
return ERR_PARSE_ERROR;
}
+ // All above branches end up here unless they had an early return.
return OK;
-
} else if (token.type == TK_NUMBER) {
-
value = token.value;
return OK;
} else if (token.type == TK_STRING) {
-
value = token.value;
return OK;
} else if (token.type == TK_STRING_NAME) {
-
value = token.value;
return OK;
} else if (token.type == TK_COLOR) {
-
value = token.value;
return OK;
} else {
@@ -1180,30 +1088,26 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
-
Token token;
bool need_comma = false;
while (true) {
-
if (p_stream->is_eof()) {
r_err_str = "Unexpected End of File while parsing array";
return ERR_FILE_CORRUPT;
}
Error err = get_token(p_stream, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token.type == TK_BRACKET_CLOSE) {
-
return OK;
}
if (need_comma) {
-
if (token.type != TK_COMMA) {
-
r_err_str = "Expected ','";
return ERR_PARSE_ERROR;
} else {
@@ -1214,8 +1118,9 @@ Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, Str
Variant v;
err = parse_value(token, v, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
array.push_back(v);
need_comma = true;
@@ -1223,34 +1128,29 @@ Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, Str
}
Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
-
bool at_key = true;
Variant key;
Token token;
bool need_comma = false;
while (true) {
-
if (p_stream->is_eof()) {
r_err_str = "Unexpected End of File while parsing dictionary";
return ERR_FILE_CORRUPT;
}
if (at_key) {
-
Error err = get_token(p_stream, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token.type == TK_CURLY_BRACKET_CLOSE) {
-
return OK;
}
if (need_comma) {
-
if (token.type != TK_COMMA) {
-
r_err_str = "Expected '}' or ','";
return ERR_PARSE_ERROR;
} else {
@@ -1261,29 +1161,31 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
err = parse_value(token, key, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
err = get_token(p_stream, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (token.type != TK_COLON) {
-
r_err_str = "Expected ':'";
return ERR_PARSE_ERROR;
}
at_key = false;
} else {
-
Error err = get_token(p_stream, token, line, r_err_str);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
Variant v;
err = parse_value(token, v, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
object[key] = v;
need_comma = true;
at_key = true;
@@ -1292,7 +1194,6 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
}
Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser, bool p_simple_tag) {
-
r_tag.fields.clear();
if (token.type != TK_BRACKET_OPEN) {
@@ -1301,19 +1202,18 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
}
if (p_simple_tag) {
-
r_tag.name = "";
r_tag.fields.clear();
while (true) {
-
CharType c = p_stream->get_char();
if (p_stream->is_eof()) {
r_err_str = "Unexpected EOF while parsing simple tag";
return ERR_PARSE_ERROR;
}
- if (c == ']')
+ if (c == ']') {
break;
+ }
r_tag.name += String::chr(c);
}
@@ -1333,15 +1233,15 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
bool parsing_tag = true;
while (true) {
-
if (p_stream->is_eof()) {
r_err_str = "Unexpected End of File while parsing tag: " + r_tag.name;
return ERR_FILE_CORRUPT;
}
get_token(p_stream, token, line, r_err_str);
- if (token.type == TK_BRACKET_CLOSE)
+ if (token.type == TK_BRACKET_CLOSE) {
break;
+ }
if (parsing_tag && token.type == TK_PERIOD) {
r_tag.name += "."; //support tags such as [someprop.Android] for specific platforms
@@ -1373,8 +1273,9 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
get_token(p_stream, token, line, r_err_str);
Variant value;
Error err = parse_value(token, value, p_stream, line, r_err_str, p_res_parser);
- if (err)
+ if (err) {
return err;
+ }
r_tag.fields[id] = value;
}
@@ -1383,7 +1284,6 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
}
Error VariantParser::parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser, bool p_simple_tag) {
-
Token token;
get_token(p_stream, token, line, r_err_str);
@@ -1400,13 +1300,11 @@ Error VariantParser::parse_tag(Stream *p_stream, int &line, String &r_err_str, T
}
Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser, bool p_simple_tag) {
-
//assign..
r_assign = "";
String what;
while (true) {
-
CharType c;
if (p_stream->saved) {
c = p_stream->saved;
@@ -1416,8 +1314,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
c = p_stream->get_char();
}
- if (p_stream->is_eof())
+ if (p_stream->is_eof()) {
return ERR_FILE_EOF;
+ }
if (c == ';') { //comment
while (true) {
@@ -1425,8 +1324,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
if (p_stream->is_eof()) {
return ERR_FILE_EOF;
}
- if (ch == '\n')
+ if (ch == '\n') {
break;
+ }
}
continue;
}
@@ -1445,8 +1345,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
p_stream->saved = '"';
Token tk;
Error err = get_token(p_stream, tk, line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (tk.type != TK_STRING) {
r_err_str = "Error reading quoted string";
return ERR_INVALID_DATA;
@@ -1470,11 +1371,11 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
}
Error VariantParser::parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser) {
-
Token token;
Error err = get_token(p_stream, token, r_err_line, r_err_str);
- if (err)
+ if (err) {
return err;
+ }
if (token.type == TK_EOF) {
return ERR_FILE_EOF;
@@ -1488,103 +1389,88 @@ Error VariantParser::parse(Stream *p_stream, Variant &r_ret, String &r_err_str,
////////////////////////////////////////////////////////////////////////////////
static String rtosfix(double p_value) {
-
- if (p_value == 0.0)
+ if (p_value == 0.0) {
return "0"; //avoid negative zero (-0) being written, which may annoy git, svn, etc. for changes when they don't exist.
- else
+ } else {
return rtoss(p_value);
+ }
}
Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud) {
-
switch (p_variant.get_type()) {
-
case Variant::NIL: {
p_store_string_func(p_store_string_ud, "null");
} break;
case Variant::BOOL: {
-
p_store_string_func(p_store_string_ud, p_variant.operator bool() ? "true" : "false");
} break;
case Variant::INT: {
-
p_store_string_func(p_store_string_ud, itos(p_variant.operator int64_t()));
} break;
case Variant::FLOAT: {
-
String s = rtosfix(p_variant.operator real_t());
if (s != "inf" && s != "nan") {
- if (s.find(".") == -1 && s.find("e") == -1)
+ if (s.find(".") == -1 && s.find("e") == -1) {
s += ".0";
+ }
}
p_store_string_func(p_store_string_ud, s);
} break;
case Variant::STRING: {
-
String str = p_variant;
str = "\"" + str.c_escape_multiline() + "\"";
p_store_string_func(p_store_string_ud, str);
} break;
case Variant::VECTOR2: {
-
Vector2 v = p_variant;
p_store_string_func(p_store_string_ud, "Vector2( " + rtosfix(v.x) + ", " + rtosfix(v.y) + " )");
} break;
case Variant::VECTOR2I: {
-
Vector2i v = p_variant;
p_store_string_func(p_store_string_ud, "Vector2i( " + itos(v.x) + ", " + itos(v.y) + " )");
} break;
case Variant::RECT2: {
-
Rect2 aabb = p_variant;
p_store_string_func(p_store_string_ud, "Rect2( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + " )");
} break;
case Variant::RECT2I: {
-
Rect2i aabb = p_variant;
p_store_string_func(p_store_string_ud, "Rect2i( " + itos(aabb.position.x) + ", " + itos(aabb.position.y) + ", " + itos(aabb.size.x) + ", " + itos(aabb.size.y) + " )");
} break;
case Variant::VECTOR3: {
-
Vector3 v = p_variant;
p_store_string_func(p_store_string_ud, "Vector3( " + rtosfix(v.x) + ", " + rtosfix(v.y) + ", " + rtosfix(v.z) + " )");
} break;
case Variant::VECTOR3I: {
-
Vector3i v = p_variant;
p_store_string_func(p_store_string_ud, "Vector3i( " + itos(v.x) + ", " + itos(v.y) + ", " + itos(v.z) + " )");
} break;
case Variant::PLANE: {
-
Plane p = p_variant;
p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )");
} break;
case Variant::AABB: {
-
AABB aabb = p_variant;
p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )");
} break;
case Variant::QUAT: {
-
Quat quat = p_variant;
p_store_string_func(p_store_string_ud, "Quat( " + rtosfix(quat.x) + ", " + rtosfix(quat.y) + ", " + rtosfix(quat.z) + ", " + rtosfix(quat.w) + " )");
} break;
case Variant::TRANSFORM2D: {
-
String s = "Transform2D( ";
Transform2D m3 = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
-
- if (i != 0 || j != 0)
+ if (i != 0 || j != 0) {
s += ", ";
+ }
s += rtosfix(m3.elements[i][j]);
}
}
@@ -1593,14 +1479,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::BASIS: {
-
String s = "Basis( ";
Basis m3 = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
- if (i != 0 || j != 0)
+ if (i != 0 || j != 0) {
s += ", ";
+ }
s += rtosfix(m3.elements[i][j]);
}
}
@@ -1609,15 +1494,14 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::TRANSFORM: {
-
String s = "Transform( ";
Transform t = p_variant;
Basis &m3 = t.basis;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
-
- if (i != 0 || j != 0)
+ if (i != 0 || j != 0) {
s += ", ";
+ }
s += rtosfix(m3.elements[i][j]);
}
}
@@ -1629,13 +1513,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
// misc types
case Variant::COLOR: {
-
Color c = p_variant;
p_store_string_func(p_store_string_ud, "Color( " + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + " )");
} break;
case Variant::STRING_NAME: {
-
String str = p_variant;
str = "@\"" + str.c_escape() + "\"";
@@ -1643,7 +1525,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::NODE_PATH: {
-
String str = p_variant;
str = "NodePath(\"" + str.c_escape() + "\")";
@@ -1652,7 +1533,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::OBJECT: {
-
Object *obj = p_variant;
if (!obj) {
@@ -1667,13 +1547,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
//try external function
if (p_encode_res_func) {
-
res_text = p_encode_res_func(p_encode_res_ud, res);
}
//try path because it's a file
if (res_text == String() && res->get_path().is_resource_file()) {
-
//external resource
String path = res->get_path();
res_text = "Resource( \"" + path + "\")";
@@ -1694,7 +1572,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
obj->get_property_list(&props);
bool first = true;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_STORAGE || E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE) {
//must be serialized
@@ -1714,7 +1591,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::DICTIONARY: {
-
Dictionary dict = p_variant;
List<Variant> keys;
@@ -1723,7 +1599,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, "{\n");
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
/*
if (!_check_type(dict[E->get()]))
continue;
@@ -1731,22 +1606,22 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
p_store_string_func(p_store_string_ud, ": ");
write(dict[E->get()], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
- if (E->next())
+ if (E->next()) {
p_store_string_func(p_store_string_ud, ",\n");
+ }
}
p_store_string_func(p_store_string_ud, "\n}");
} break;
case Variant::ARRAY: {
-
p_store_string_func(p_store_string_ud, "[ ");
Array array = p_variant;
int len = array.size();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
}
p_store_string_func(p_store_string_ud, " ]");
@@ -1754,7 +1629,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_BYTE_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedByteArray( ");
String s;
Vector<uint8_t> data = p_variant;
@@ -1762,9 +1636,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
const uint8_t *ptr = data.ptr();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
@@ -1773,16 +1647,15 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_INT32_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedInt32Array( ");
Vector<int32_t> data = p_variant;
int32_t len = data.size();
const int32_t *ptr = data.ptr();
for (int32_t i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
@@ -1791,16 +1664,15 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_INT64_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedInt64Array( ");
Vector<int64_t> data = p_variant;
int64_t len = data.size();
const int64_t *ptr = data.ptr();
for (int64_t i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, itos(ptr[i]));
}
@@ -1809,16 +1681,15 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedFloat32Array( ");
Vector<float> data = p_variant;
int len = data.size();
const float *ptr = data.ptr();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
}
@@ -1826,16 +1697,15 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedFloat64Array( ");
Vector<double> data = p_variant;
int len = data.size();
const double *ptr = data.ptr();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
}
@@ -1843,7 +1713,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_STRING_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedStringArray( ");
Vector<String> data = p_variant;
int len = data.size();
@@ -1853,9 +1722,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
//write_string("\n");
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
String str = ptr[i];
p_store_string_func(p_store_string_ud, "\"" + str.c_escape() + "\"");
}
@@ -1864,16 +1733,15 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedVector2Array( ");
Vector<Vector2> data = p_variant;
int len = data.size();
const Vector2 *ptr = data.ptr();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y));
}
@@ -1881,16 +1749,15 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedVector3Array( ");
Vector<Vector3> data = p_variant;
int len = data.size();
const Vector3 *ptr = data.ptr();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y) + ", " + rtosfix(ptr[i].z));
}
@@ -1898,7 +1765,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
p_store_string_func(p_store_string_ud, "PackedColorArray( ");
Vector<Color> data = p_variant;
@@ -1906,9 +1772,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
const Color *ptr = data.ptr();
for (int i = 0; i < len; i++) {
-
- if (i > 0)
+ if (i > 0) {
p_store_string_func(p_store_string_ud, ", ");
+ }
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].r) + ", " + rtosfix(ptr[i].g) + ", " + rtosfix(ptr[i].b) + ", " + rtosfix(ptr[i].a));
}
@@ -1923,14 +1789,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
}
static Error _write_to_str(void *ud, const String &p_string) {
-
String *str = (String *)ud;
(*str) += p_string;
return OK;
}
Error VariantWriter::write_to_string(const Variant &p_variant, String &r_string, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud) {
-
r_string = String();
return write(p_variant, _write_to_str, &r_string, p_encode_res_func, p_encode_res_ud);
diff --git a/core/variant_parser.h b/core/variant_parser.h
index 63ed51bcc9..b55d7b2df0 100644
--- a/core/variant_parser.h
+++ b/core/variant_parser.h
@@ -38,45 +38,40 @@
class VariantParser {
public:
struct Stream {
-
virtual CharType get_char() = 0;
virtual bool is_utf8() const = 0;
virtual bool is_eof() const = 0;
- CharType saved;
+ CharType saved = 0;
- Stream() :
- saved(0) {}
+ Stream() {}
virtual ~Stream() {}
};
struct StreamFile : public Stream {
-
- FileAccess *f;
+ FileAccess *f = nullptr;
virtual CharType get_char();
virtual bool is_utf8() const;
virtual bool is_eof() const;
- StreamFile() { f = nullptr; }
+ StreamFile() {}
};
struct StreamString : public Stream {
-
String s;
- int pos;
+ int pos = 0;
virtual CharType get_char();
virtual bool is_utf8() const;
virtual bool is_eof() const;
- StreamString() { pos = 0; }
+ StreamString() {}
};
typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str);
struct ResourceParser {
-
void *userdata = nullptr;
ParseResourceFunc func;
ParseResourceFunc ext_func;
@@ -113,13 +108,11 @@ public:
};
struct Token {
-
TokenType type;
Variant value;
};
struct Tag {
-
String name;
Map<String, Variant> fields;
};
diff --git a/core/vector.h b/core/vector.h
index 74e0ab91c0..4c152fb084 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -70,8 +70,9 @@ public:
void remove(int p_index) { _cowdata.remove(p_index); }
void erase(const T &p_val) {
int idx = find(p_val);
- if (idx >= 0)
+ if (idx >= 0) {
remove(idx);
+ }
}
void invert();
@@ -93,10 +94,10 @@ public:
template <class C>
void sort_custom() {
-
int len = _cowdata.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
T *data = ptrw();
SortArray<T, C> sorter;
@@ -104,23 +105,19 @@ public:
}
void sort() {
-
sort_custom<_DefaultComparator<T>>();
}
void ordered_insert(const T &p_val) {
int i;
for (i = 0; i < _cowdata.size(); i++) {
-
if (p_val < operator[](i)) {
break;
- };
- };
+ }
+ }
insert(i, p_val);
}
- _FORCE_INLINE_ Vector() {}
- _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); }
inline Vector &operator=(const Vector &p_from) {
_cowdata._ref(p_from._cowdata);
return *this;
@@ -134,7 +131,6 @@ public:
}
Vector<T> subarray(int p_from, int p_to) const {
-
if (p_from < 0) {
p_from = size() + p_from;
}
@@ -157,12 +153,14 @@ public:
return slice;
}
+ _FORCE_INLINE_ Vector() {}
+ _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); }
+
_FORCE_INLINE_ ~Vector() {}
};
template <class T>
void Vector<T>::invert() {
-
for (int i = 0; i < size() / 2; i++) {
T *p = ptrw();
SWAP(p[i], p[size() - i - 1]);
@@ -172,17 +170,18 @@ void Vector<T>::invert() {
template <class T>
void Vector<T>::append_array(Vector<T> p_other) {
const int ds = p_other.size();
- if (ds == 0)
+ if (ds == 0) {
return;
+ }
const int bs = size();
resize(bs + ds);
- for (int i = 0; i < ds; ++i)
+ for (int i = 0; i < ds; ++i) {
ptrw()[bs + i] = p_other[i];
+ }
}
template <class T>
bool Vector<T>::push_back(T p_elem) {
-
Error err = resize(size() + 1);
ERR_FAIL_COND_V(err, true);
set(size() - 1, p_elem);
diff --git a/core/vmap.h b/core/vmap.h
index 84ae1aaf66..c91ea9b3c9 100644
--- a/core/vmap.h
+++ b/core/vmap.h
@@ -38,14 +38,12 @@ template <class T, class V>
class VMap {
public:
struct Pair {
-
T key;
V value;
_FORCE_INLINE_ Pair() {}
_FORCE_INLINE_ Pair(const T &p_key, const V &p_value) {
-
key = p_key;
value = p_value;
}
@@ -55,10 +53,10 @@ private:
CowData<Pair> _cowdata;
_FORCE_INLINE_ int _find(const T &p_val, bool &r_exact) const {
-
r_exact = false;
- if (_cowdata.empty())
+ if (_cowdata.empty()) {
return 0;
+ }
int low = 0;
int high = _cowdata.size() - 1;
@@ -66,8 +64,9 @@ private:
int middle = 0;
#ifdef DEBUG_ENABLED
- if (low > high)
+ if (low > high) {
ERR_PRINT("low > high, this may be a bug");
+ }
#endif
while (low <= high) {
middle = (low + high) / 2;
@@ -83,15 +82,16 @@ private:
}
//return the position where this would be inserted
- if (a[middle].key < p_val)
+ if (a[middle].key < p_val) {
middle++;
+ }
return middle;
}
_FORCE_INLINE_ int _find_exact(const T &p_val) const {
-
- if (_cowdata.empty())
+ if (_cowdata.empty()) {
return -1;
+ }
int low = 0;
int high = _cowdata.size() - 1;
@@ -115,7 +115,6 @@ private:
public:
int insert(const T &p_key, const V &p_val) {
-
bool exact;
int pos = _find(p_key, exact);
if (exact) {
@@ -127,25 +126,22 @@ public:
}
bool has(const T &p_val) const {
-
return _find_exact(p_val) != -1;
}
void erase(const T &p_val) {
-
int pos = _find_exact(p_val);
- if (pos < 0)
+ if (pos < 0) {
return;
+ }
_cowdata.remove(pos);
}
int find(const T &p_val) const {
-
return _find_exact(p_val);
}
int find_nearest(const T &p_val) const {
-
bool exact;
return _find(p_val, exact);
}
@@ -154,37 +150,30 @@ public:
_FORCE_INLINE_ bool empty() const { return _cowdata.empty(); }
const Pair *get_array() const {
-
return _cowdata.ptr();
}
Pair *get_array() {
-
return _cowdata.ptrw();
}
const V &getv(int p_index) const {
-
return _cowdata.get(p_index).value;
}
V &getv(int p_index) {
-
return _cowdata.get_m(p_index).value;
}
const T &getk(int p_index) const {
-
return _cowdata.get(p_index).key;
}
T &getk(int p_index) {
-
return _cowdata.get_m(p_index).key;
}
inline const V &operator[](const T &p_key) const {
-
int pos = _find_exact(p_key);
CRASH_COND(pos < 0);
@@ -193,7 +182,6 @@ public:
}
inline V &operator[](const T &p_key) {
-
int pos = _find_exact(p_key);
if (pos < 0) {
pos = insert(p_key, V());
@@ -202,11 +190,13 @@ public:
return _cowdata.get_m(pos).value;
}
- _FORCE_INLINE_ VMap(){};
+ _FORCE_INLINE_ VMap() {}
_FORCE_INLINE_ VMap(const VMap &p_from) { _cowdata._ref(p_from._cowdata); }
+
inline VMap &operator=(const VMap &p_from) {
_cowdata._ref(p_from._cowdata);
return *this;
}
};
+
#endif // VMAP_H
diff --git a/core/vset.h b/core/vset.h
index b96a115d21..034b8fe851 100644
--- a/core/vset.h
+++ b/core/vset.h
@@ -36,14 +36,13 @@
template <class T>
class VSet {
-
Vector<T> _data;
_FORCE_INLINE_ int _find(const T &p_val, bool &r_exact) const {
-
r_exact = false;
- if (_data.empty())
+ if (_data.empty()) {
return 0;
+ }
int low = 0;
int high = _data.size() - 1;
@@ -51,8 +50,9 @@ class VSet {
int middle = 0;
#ifdef DEBUG_ENABLED
- if (low > high)
+ if (low > high) {
ERR_PRINT("low > high, this may be a bug");
+ }
#endif
while (low <= high) {
@@ -69,15 +69,16 @@ class VSet {
}
//return the position where this would be inserted
- if (a[middle] < p_val)
+ if (a[middle] < p_val) {
middle++;
+ }
return middle;
}
_FORCE_INLINE_ int _find_exact(const T &p_val) const {
-
- if (_data.empty())
+ if (_data.empty()) {
return -1;
+ }
int low = 0;
int high = _data.size() - 1;
@@ -101,29 +102,27 @@ class VSet {
public:
void insert(const T &p_val) {
-
bool exact;
int pos = _find(p_val, exact);
- if (exact)
+ if (exact) {
return;
+ }
_data.insert(pos, p_val);
}
bool has(const T &p_val) const {
-
return _find_exact(p_val) != -1;
}
void erase(const T &p_val) {
-
int pos = _find_exact(p_val);
- if (pos < 0)
+ if (pos < 0) {
return;
+ }
_data.remove(pos);
}
int find(const T &p_val) const {
-
return _find_exact(p_val);
}
@@ -132,12 +131,10 @@ public:
_FORCE_INLINE_ int size() const { return _data.size(); }
inline T &operator[](int p_index) {
-
return _data.write[p_index];
}
inline const T &operator[](int p_index) const {
-
return _data[p_index];
}
};
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index bf2ce321ac..41811a48b1 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -27,8 +27,11 @@
<member name="Engine" type="Engine" setter="" getter="">
The [Engine] singleton.
</member>
- <member name="Geometry" type="Geometry" setter="" getter="">
- The [Geometry] singleton.
+ <member name="Geometry2D" type="Geometry2D" setter="" getter="">
+ The [Geometry2D] singleton.
+ </member>
+ <member name="Geometry3D" type="Geometry3D" setter="" getter="">
+ The [Geometry3D] singleton.
</member>
<member name="IP" type="IP" setter="" getter="">
The [IP] singleton.
@@ -1063,10 +1066,10 @@
<constant name="JOY_XBOX_RB" value="10" enum="JoyButtonList">
Xbox game controller right bumper button maps to SDL right shoulder button.
</constant>
- <constant name="JOY_BUTTON_MAX" value="36" enum="JoyAxisList">
+ <constant name="JOY_BUTTON_MAX" value="36" enum="JoyButtonList">
The maximum number of game controller buttons.
</constant>
- <constant name="JOY_INVALID_BUTTON" value="-1" enum="JoyButtonList">
+ <constant name="JOY_INVALID_AXIS" value="-1" enum="JoyAxisList">
An invalid game controller axis.
</constant>
<constant name="JOY_AXIS_LEFT_X" value="0" enum="JoyAxisList">
diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml
index e930abba87..2695e86f47 100644
--- a/doc/classes/AStar.xml
+++ b/doc/classes/AStar.xml
@@ -131,7 +131,8 @@
<argument index="1" name="include_disabled" type="bool" default="false">
</argument>
<description>
- Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns -1 if there are no points in the points pool.
+ Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns [code]-1[/code] if there are no points in the points pool.
+ [b]Note:[/b] If several points are the closest to [code]to_position[/code], the one with the smallest ID will be returned, ensuring a deterministic result.
</description>
</method>
<method name="get_closest_position_in_segment" qualifiers="const">
diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml
index 16fa05041e..622d336ef6 100644
--- a/doc/classes/AStar2D.xml
+++ b/doc/classes/AStar2D.xml
@@ -114,7 +114,8 @@
<argument index="1" name="include_disabled" type="bool" default="false">
</argument>
<description>
- Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns -1 if there are no points in the points pool.
+ Returns the ID of the closest point to [code]to_position[/code], optionally taking disabled points into account. Returns [code]-1[/code] if there are no points in the points pool.
+ [b]Note:[/b] If several points are the closest to [code]to_position[/code], the one with the smallest ID will be returned, ensuring a deterministic result.
</description>
</method>
<method name="get_closest_position_in_segment" qualifiers="const">
diff --git a/doc/classes/AnimationTree.xml b/doc/classes/AnimationTree.xml
index 9642dd1c70..dd04f4ce3f 100644
--- a/doc/classes/AnimationTree.xml
+++ b/doc/classes/AnimationTree.xml
@@ -4,6 +4,7 @@
A node to be used for advanced animation transitions in an [AnimationPlayer].
</brief_description>
<description>
+ Note: When linked with an [AnimationPlayer], several properties and methods of the corresponding [AnimationPlayer] will not function as expected. Playback and transitions should be handled using only the [AnimationTree] and its constituent [AnimationNode](s). The [AnimationPlayer] node should be used solely for adding, deleting, and editing animations.
</description>
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/animation/animation_tree.html</link>
@@ -23,6 +24,7 @@
<return type="Transform">
</return>
<description>
+ Retrieve the motion of the [member root_motion_track] as a [Transform] that can be used elsewhere. If [member root_motion_track] is not a path to a track of type [constant Animation.TYPE_TRANSFORM], returns an identity transformation.
</description>
</method>
<method name="rename_parameter">
@@ -47,6 +49,8 @@
The process mode of this [AnimationTree]. See [enum AnimationProcessMode] for available modes.
</member>
<member name="root_motion_track" type="NodePath" setter="set_root_motion_track" getter="get_root_motion_track" default="NodePath(&quot;&quot;)">
+ The path to the Animation track used for root motion. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. To specify a track that controls properties or bones, append its name after the path, separated by [code]":"[/code]. For example, [code]"character/skeleton:ankle"[/code] or [code]"character/mesh:transform/local"[/code].
+ If the track has type [constant Animation.TYPE_TRANSFORM], the transformation will be cancelled visually, and the animation will appear to stay in place.
</member>
<member name="tree_root" type="AnimationNode" setter="set_tree_root" getter="get_tree_root">
The root animation node of this [AnimationTree]. See [AnimationNode].
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml
index 20296bbf45..9a3eccd8dc 100644
--- a/doc/classes/Array.xml
+++ b/doc/classes/Array.xml
@@ -20,7 +20,7 @@
var array2 = [3, "Four"]
print(array1 + array2) # ["One", 2, 3, "Four"]
[/codeblock]
- Arrays are always passed by reference.
+ [b]Note:[/b] Arrays are always passed by reference. To get a copy of an array which can be modified independently of the original array, use [method duplicate].
</description>
<tutorials>
</tutorials>
@@ -200,7 +200,7 @@
<argument index="1" name="from" type="int" default="0">
</argument>
<description>
- Searches the array for a value and returns its index or -1 if not found. Optionally, the initial search index can be passed.
+ Searches the array for a value and returns its index or [code]-1[/code] if not found. Optionally, the initial search index can be passed.
</description>
</method>
<method name="find_last">
@@ -209,7 +209,7 @@
<argument index="0" name="value" type="Variant">
</argument>
<description>
- Searches the array in reverse order for a value and returns its index or -1 if not found.
+ Searches the array in reverse order for a value and returns its index or [code]-1[/code] if not found.
</description>
</method>
<method name="front">
@@ -232,6 +232,12 @@
["inside", 7].has(7) == true
["inside", 7].has("7") == false
[/codeblock]
+ [b]Note:[/b] This is equivalent to using the [code]in[/code] operator as follows:
+ [codeblock]
+ # Will evaluate to `true`.
+ if 2 in [2, 4, 6, 8]:
+ pass
+ [/codeblock]
</description>
</method>
<method name="hash">
diff --git a/doc/classes/AudioEffectRecord.xml b/doc/classes/AudioEffectRecord.xml
index 4dac81322f..a217342d98 100644
--- a/doc/classes/AudioEffectRecord.xml
+++ b/doc/classes/AudioEffectRecord.xml
@@ -4,6 +4,7 @@
Audio effect used for recording sound from a microphone.
</brief_description>
<description>
+ Allows the user to record sound from a microphone. It sets and gets the format in which the audio file will be recorded (8-bit, 16-bit, or compressed). It checks whether or not the recording is active, and if it is, records the sound. It then returns the recorded sample.
</description>
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/audio/recording_with_microphone.html</link>
diff --git a/doc/classes/BitmapFont.xml b/doc/classes/BitmapFont.xml
index 421b405808..87cffdaca0 100644
--- a/doc/classes/BitmapFont.xml
+++ b/doc/classes/BitmapFont.xml
@@ -65,17 +65,6 @@
Creates a BitmapFont from the [code]*.fnt[/code] file at [code]path[/code].
</description>
</method>
- <method name="get_char_size" qualifiers="const">
- <return type="Vector2">
- </return>
- <argument index="0" name="char" type="int">
- </argument>
- <argument index="1" name="next" type="int" default="0">
- </argument>
- <description>
- Returns the size of a character, optionally taking kerning into account if the next character is provided.
- </description>
- </method>
<method name="get_kerning_pair" qualifiers="const">
<return type="int">
</return>
diff --git a/doc/classes/Camera3D.xml b/doc/classes/Camera3D.xml
index 6ff4875364..598b4bd685 100644
--- a/doc/classes/Camera3D.xml
+++ b/doc/classes/Camera3D.xml
@@ -176,6 +176,7 @@
If not [constant DOPPLER_TRACKING_DISABLED], this camera will simulate the [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] for objects changed in particular [code]_process[/code] methods. See [enum DopplerTracking] for possible values.
</member>
<member name="effects" type="CameraEffects" setter="set_effects" getter="get_effects">
+ The [CameraEffects] to use for this camera.
</member>
<member name="environment" type="Environment" setter="set_environment" getter="get_environment">
The [Environment] to use for this camera.
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml
index 38e4453cf2..b3a3722836 100644
--- a/doc/classes/CanvasItem.xml
+++ b/doc/classes/CanvasItem.xml
@@ -608,8 +608,10 @@
If [code]true[/code], the object draws on top of its parent.
</member>
<member name="texture_filter" type="int" setter="set_texture_filter" getter="get_texture_filter" enum="CanvasItem.TextureFilter" default="0">
+ The texture filtering mode to use on this [CanvasItem].
</member>
<member name="texture_repeat" type="int" setter="set_texture_repeat" getter="get_texture_repeat" enum="CanvasItem.TextureRepeat" default="0">
+ The texture repeating mode to use on this [CanvasItem].
</member>
<member name="use_parent_material" type="bool" setter="set_use_parent_material" getter="get_use_parent_material" default="false">
If [code]true[/code], the parent [CanvasItem]'s [member material] property is used as this one's material.
@@ -666,12 +668,18 @@
The texture filter blends between the nearest four pixels. Use this for most cases where you want to avoid a pixelated style.
</constant>
<constant name="TEXTURE_FILTER_NEAREST_WITH_MIPMAPS" value="3" enum="TextureFilter">
+ The texture filter reads from the nearest pixel in the nearest mipmap. This is the fastest way to read from textures with mipmaps.
</constant>
<constant name="TEXTURE_FILTER_LINEAR_WITH_MIPMAPS" value="4" enum="TextureFilter">
+ The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps. Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to [Camera2D] zoom), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
</constant>
<constant name="TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC" value="5" enum="TextureFilter">
+ The texture filter reads from the nearest pixel, but selects a mipmap based on the angle between the surface and the camera view. This reduces artifacts on surfaces that are almost in line with the camera.
+ [b]Note:[/b] This texture filter is rarely useful in 2D projects. [constant TEXTURE_FILTER_NEAREST_WITH_MIPMAPS] is usually more appropriate.
</constant>
<constant name="TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC" value="6" enum="TextureFilter">
+ The texture filter blends between the nearest 4 pixels and selects a mipmap based on the angle between the surface and the camera view. This reduces artifacts on surfaces that are almost in line with the camera. This is the slowest of the filtering options, but results in the highest quality texturing.
+ [b]Note:[/b] This texture filter is rarely useful in 2D projects. [constant TEXTURE_FILTER_LINEAR_WITH_MIPMAPS] is usually more appropriate.
</constant>
<constant name="TEXTURE_FILTER_MAX" value="7" enum="TextureFilter">
Represents the size of the [enum TextureFilter] enum.
diff --git a/doc/classes/ConvexPolygonShape2D.xml b/doc/classes/ConvexPolygonShape2D.xml
index cba446fff8..42951e2158 100644
--- a/doc/classes/ConvexPolygonShape2D.xml
+++ b/doc/classes/ConvexPolygonShape2D.xml
@@ -16,7 +16,7 @@
<argument index="0" name="point_cloud" type="PackedVector2Array">
</argument>
<description>
- Based on the set of points provided, this creates and assigns the [member points] property using the convex hull algorithm. Removing all unneeded points. See [method Geometry.convex_hull_2d] for details.
+ Based on the set of points provided, this creates and assigns the [member points] property using the convex hull algorithm. Removing all unneeded points. See [method Geometry2D.convex_hull] for details.
</description>
</method>
</methods>
diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml
index e982e00d6d..5413fa33c6 100644
--- a/doc/classes/Dictionary.xml
+++ b/doc/classes/Dictionary.xml
@@ -7,6 +7,7 @@
Dictionary type. Associative container which contains values referenced by unique keys. Dictionaries are composed of pairs of keys (which must be unique) and values. Dictionaries will preserve the insertion order when adding elements, even though this may not be reflected when printing the dictionary. In other programming languages, this data structure is sometimes referred to as an hash map or associative array.
You can define a dictionary by placing a comma-separated list of [code]key: value[/code] pairs in curly braces [code]{}[/code].
Erasing elements while iterating over them [b]is not supported[/b] and will result in undefined behavior.
+ [b]Note:[/b] Dictionaries are always passed by reference. To get a copy of a dictionary which can be modified independently of the original dictionary, use [method duplicate].
Creating a dictionary:
[codeblock]
var my_dir = {} # Creates an empty dictionary.
@@ -125,6 +126,13 @@
</argument>
<description>
Returns [code]true[/code] if the dictionary has a given key.
+ [b]Note:[/b] This is equivalent to using the [code]in[/code] operator as follows:
+ [codeblock]
+ # Will evaluate to `true`.
+ if "godot" in {"godot": "engine"}:
+ pass
+ [/codeblock]
+ This method (like the [code]in[/code] operator) will evaluate to [code]true[/code] as long as the key exists, even if the associated value is [code]null[/code].
</description>
</method>
<method name="has_all">
@@ -147,6 +155,7 @@
# The line below prints `true`, whereas it would have printed `false` if both variables were compared directly.
print(dict1.hash() == dict2.hash())
[/codeblock]
+ [b]Note:[/b] Dictionaries with the same keys/values but in a different order will have a different hash.
</description>
</method>
<method name="keys">
diff --git a/doc/classes/DirectionalLight3D.xml b/doc/classes/DirectionalLight3D.xml
index 6c88dcf42e..f66be6ddde 100644
--- a/doc/classes/DirectionalLight3D.xml
+++ b/doc/classes/DirectionalLight3D.xml
@@ -42,19 +42,19 @@
</members>
<constants>
<constant name="SHADOW_ORTHOGONAL" value="0" enum="ShadowMode">
- Renders the entire scene's shadow map from an orthogonal point of view. May result in blockier shadows on close objects.
+ Renders the entire scene's shadow map from an orthogonal point of view. This is the fastest directional shadow mode. May result in blurrier shadows on close objects.
</constant>
<constant name="SHADOW_PARALLEL_2_SPLITS" value="1" enum="ShadowMode">
- Splits the view frustum in 2 areas, each with its own shadow map.
+ Splits the view frustum in 2 areas, each with its own shadow map. This shadow mode is a compromise between [constant SHADOW_ORTHOGONAL] and [constant SHADOW_PARALLEL_4_SPLITS] in terms of performance.
</constant>
<constant name="SHADOW_PARALLEL_4_SPLITS" value="2" enum="ShadowMode">
- Splits the view frustum in 4 areas, each with its own shadow map.
+ Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode.
</constant>
<constant name="SHADOW_DEPTH_RANGE_STABLE" value="0" enum="ShadowDepthRange">
Keeps the shadow stable when the camera moves, at the cost of lower effective shadow resolution.
</constant>
<constant name="SHADOW_DEPTH_RANGE_OPTIMIZED" value="1" enum="ShadowDepthRange">
- Tries to achieve maximum shadow resolution. May result in saw effect on shadow edges.
+ Tries to achieve maximum shadow resolution. May result in saw effect on shadow edges. This mode typically works best in games where the camera will often move at high speeds, such as most racing games.
</constant>
</constants>
</class>
diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml
index 90828089f9..f8306cbd72 100644
--- a/doc/classes/DisplayServer.xml
+++ b/doc/classes/DisplayServer.xml
@@ -127,12 +127,6 @@
<description>
</description>
</method>
- <method name="get_latin_keyboard_variant" qualifiers="const">
- <return type="int" enum="DisplayServer.LatinKeyboardVariant">
- </return>
- <description>
- </description>
- </method>
<method name="get_name" qualifiers="const">
<return type="String">
</return>
@@ -389,6 +383,52 @@
<description>
</description>
</method>
+ <method name="keyboard_get_current_layout" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ Returns active keyboard layout index.
+ [b]Note:[/b] This method is implemented on Linux, macOS and Windows.
+ </description>
+ </method>
+ <method name="keyboard_get_layout_count" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ Returns the number of keyboard layouts.
+ [b]Note:[/b] This method is implemented on Linux, macOS and Windows.
+ </description>
+ </method>
+ <method name="keyboard_get_layout_language" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ Returns the ISO-639/BCP-47 language code of the keyboard layout at position [code]index[/code].
+ [b]Note:[/b] This method is implemented on Linux, macOS and Windows.
+ </description>
+ </method>
+ <method name="keyboard_get_layout_name" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ Returns the localized name of the keyboard layout at position [code]index[/code].
+ [b]Note:[/b] This method is implemented on Linux, macOS and Windows.
+ </description>
+ </method>
+ <method name="keyboard_set_current_layout">
+ <return type="void">
+ </return>
+ <argument index="0" name="index" type="int">
+ </argument>
+ <description>
+ Sets active keyboard layout.
+ [b]Note:[/b] This method is implemented on Linux, macOS and Windows.
+ </description>
+ </method>
<method name="mouse_get_absolute_position" qualifiers="const">
<return type="Vector2i">
</return>
@@ -592,6 +632,10 @@
</argument>
<argument index="2" name="max_length" type="int" default="-1">
</argument>
+ <argument index="3" name="cursor_start" type="int" default="-1">
+ </argument>
+ <argument index="4" name="cursor_end" type="int" default="-1">
+ </argument>
<description>
</description>
</method>
@@ -1017,20 +1061,6 @@
</constant>
<constant name="WINDOW_FLAG_MAX" value="5" enum="WindowFlags">
</constant>
- <constant name="LATIN_KEYBOARD_QWERTY" value="0" enum="LatinKeyboardVariant">
- </constant>
- <constant name="LATIN_KEYBOARD_QWERTZ" value="1" enum="LatinKeyboardVariant">
- </constant>
- <constant name="LATIN_KEYBOARD_AZERTY" value="2" enum="LatinKeyboardVariant">
- </constant>
- <constant name="LATIN_KEYBOARD_QZERTY" value="3" enum="LatinKeyboardVariant">
- </constant>
- <constant name="LATIN_KEYBOARD_DVORAK" value="4" enum="LatinKeyboardVariant">
- </constant>
- <constant name="LATIN_KEYBOARD_NEO" value="5" enum="LatinKeyboardVariant">
- </constant>
- <constant name="LATIN_KEYBOARD_COLEMAK" value="6" enum="LatinKeyboardVariant">
- </constant>
<constant name="WINDOW_EVENT_MOUSE_ENTER" value="0" enum="WindowEvent">
</constant>
<constant name="WINDOW_EVENT_MOUSE_EXIT" value="1" enum="WindowEvent">
diff --git a/doc/classes/DynamicFontData.xml b/doc/classes/DynamicFontData.xml
index 2b4ec17bf1..483da96f3f 100644
--- a/doc/classes/DynamicFontData.xml
+++ b/doc/classes/DynamicFontData.xml
@@ -12,7 +12,7 @@
</methods>
<members>
<member name="antialiased" type="bool" setter="set_antialiased" getter="is_antialiased" default="true">
- If [code]true[/code], the font is rendered with anti-aliasing.
+ If [code]true[/code], the font is rendered with anti-aliasing. This property applies both to the main font and its outline (if it has one).
</member>
<member name="font_path" type="String" setter="set_font_path" getter="get_font_path" default="&quot;&quot;">
The path to the vector font file.
diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml
index 499c3b8271..dbe725f08b 100644
--- a/doc/classes/EditorInterface.xml
+++ b/doc/classes/EditorInterface.xml
@@ -182,14 +182,6 @@
Selects the file, with the path provided by [code]file[/code], in the FileSystem dock.
</description>
</method>
- <method name="set_distraction_free_mode">
- <return type="void">
- </return>
- <argument index="0" name="enter" type="bool">
- </argument>
- <description>
- </description>
- </method>
<method name="set_main_screen_editor">
<return type="void">
</return>
@@ -210,6 +202,10 @@
</description>
</method>
</methods>
+ <members>
+ <member name="distraction_free_mode" type="bool" setter="set_distraction_free_mode" getter="is_distraction_free_mode_enabled">
+ </member>
+ </members>
<constants>
</constants>
</class>
diff --git a/doc/classes/File.xml b/doc/classes/File.xml
index 17c65731ff..b90039e496 100644
--- a/doc/classes/File.xml
+++ b/doc/classes/File.xml
@@ -54,28 +54,28 @@
<return type="int">
</return>
<description>
- Returns the next 16 bits from the file as an integer.
+ Returns the next 16 bits from the file as an integer. See [method store_16] for details on what values can be stored and retrieved this way.
</description>
</method>
<method name="get_32" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the next 32 bits from the file as an integer.
+ Returns the next 32 bits from the file as an integer. See [method store_32] for details on what values can be stored and retrieved this way.
</description>
</method>
<method name="get_64" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the next 64 bits from the file as an integer.
+ Returns the next 64 bits from the file as an integer. See [method store_64] for details on what values can be stored and retrieved this way.
</description>
</method>
<method name="get_8" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the next 8 bits from the file as an integer.
+ Returns the next 8 bits from the file as an integer. See [method store_8] for details on what values can be stored and retrieved this way.
</description>
</method>
<method name="get_as_text" qualifiers="const">
@@ -297,7 +297,26 @@
</argument>
<description>
Stores an integer as 16 bits in the file.
- [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^16 - 1][/code].
+ [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^16 - 1][/code]. Any other value will overflow and wrap around.
+ To store a signed integer, use [method store_64] or store a signed integer from the interval [code][-2^15, 2^15 - 1][/code] (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
+ [codeblock]
+ const MAX_15B = 1 &lt;&lt; 15
+ const MAX_16B = 1 &lt;&lt; 16
+
+ func unsigned16_to_signed(unsigned):
+ return (unsigned + MAX_15B) % MAX_16B - MAX_15B
+
+ func _ready():
+ var f = File.new()
+ f.open("user://file.dat", File.WRITE_READ)
+ f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
+ f.store_16(121) # In bounds, will store 121.
+ f.seek(0) # Go back to start to read the stored value.
+ var read1 = f.get_16() # 65494
+ var read2 = f.get_16() # 121
+ var converted1 = unsigned16_to_signed(read1) # -42
+ var converted2 = unsigned16_to_signed(read2) # 121
+ [/codeblock]
</description>
</method>
<method name="store_32">
@@ -307,7 +326,8 @@
</argument>
<description>
Stores an integer as 32 bits in the file.
- [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^32 - 1][/code].
+ [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^32 - 1][/code]. Any other value will overflow and wrap around.
+ To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
</description>
</method>
<method name="store_64">
@@ -327,7 +347,8 @@
</argument>
<description>
Stores an integer as 8 bits in the file.
- [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 255][/code].
+ [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 255][/code]. Any other value will overflow and wrap around.
+ To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
</description>
</method>
<method name="store_buffer">
diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml
index 99563ee367..eaaccbd0dd 100644
--- a/doc/classes/FileDialog.xml
+++ b/doc/classes/FileDialog.xml
@@ -4,7 +4,7 @@
Dialog for selecting files or directories in the filesystem.
</brief_description>
<description>
- FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks.
+ FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks. The FileDialog automatically sets its window title according to the [member file_mode]. If you want to use a custom title, disable this by setting [member mode_overrides_title] to [code]false[/code].
</description>
<tutorials>
</tutorials>
@@ -132,6 +132,12 @@
</constant>
</constants>
<theme_items>
+ <theme_item name="file" type="Texture2D">
+ Custom icon for files.
+ </theme_item>
+ <theme_item name="file_icon_modulate" type="Color" default="Color( 1, 1, 1, 1 )">
+ The color modulation applied to the file icon.
+ </theme_item>
<theme_item name="files_disabled" type="Color" default="Color( 0, 0, 0, 0.7 )">
The color tint for disabled files (when the [FileDialog] is used in open folder mode).
</theme_item>
diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml
index 882f819e37..30b8c1fe76 100644
--- a/doc/classes/Font.xml
+++ b/doc/classes/Font.xml
@@ -54,6 +54,17 @@
Returns the font ascent (number of pixels above the baseline).
</description>
</method>
+ <method name="get_char_size" qualifiers="const">
+ <return type="Vector2">
+ </return>
+ <argument index="0" name="char" type="int">
+ </argument>
+ <argument index="1" name="next" type="int" default="0">
+ </argument>
+ <description>
+ Returns the size of a character, optionally taking kerning into account if the next character is provided.
+ </description>
+ </method>
<method name="get_descent" qualifiers="const">
<return type="float">
</return>
diff --git a/doc/classes/Geometry.xml b/doc/classes/Geometry2D.xml
index 4d6f7b60a3..ffd4bd108d 100644
--- a/doc/classes/Geometry.xml
+++ b/doc/classes/Geometry2D.xml
@@ -1,67 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="Geometry" inherits="Object" version="4.0">
+<class name="Geometry2D" inherits="Object" version="4.0">
<brief_description>
- Helper node to calculate generic geometry operations.
+ Helper node to calculate generic geometry operations in 2D space.
</brief_description>
<description>
- Geometry provides users with a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations.
+ Geometry2D provides users with a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations.
</description>
<tutorials>
</tutorials>
<methods>
- <method name="build_box_planes">
- <return type="Array">
- </return>
- <argument index="0" name="extents" type="Vector3">
- </argument>
- <description>
- Returns an array with 6 [Plane]s that describe the sides of a box centered at the origin. The box size is defined by [code]extents[/code], which represents one (positive) corner of the box (i.e. half its actual size).
- </description>
- </method>
- <method name="build_capsule_planes">
- <return type="Array">
- </return>
- <argument index="0" name="radius" type="float">
- </argument>
- <argument index="1" name="height" type="float">
- </argument>
- <argument index="2" name="sides" type="int">
- </argument>
- <argument index="3" name="lats" type="int">
- </argument>
- <argument index="4" name="axis" type="int" enum="Vector3.Axis" default="2">
- </argument>
- <description>
- Returns an array of [Plane]s closely bounding a faceted capsule centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the side part of the capsule, whereas [code]lats[/code] gives the number of latitudinal steps at the bottom and top of the capsule. The parameter [code]axis[/code] describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z).
- </description>
- </method>
- <method name="build_cylinder_planes">
- <return type="Array">
- </return>
- <argument index="0" name="radius" type="float">
- </argument>
- <argument index="1" name="height" type="float">
- </argument>
- <argument index="2" name="sides" type="int">
- </argument>
- <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="2">
- </argument>
- <description>
- Returns an array of [Plane]s closely bounding a faceted cylinder centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the round part of the cylinder. The parameter [code]axis[/code] describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z).
- </description>
- </method>
- <method name="clip_polygon">
- <return type="PackedVector3Array">
- </return>
- <argument index="0" name="points" type="PackedVector3Array">
- </argument>
- <argument index="1" name="plane" type="Plane">
- </argument>
- <description>
- Clips the polygon defined by the points in [code]points[/code] against the [code]plane[/code] and returns the points of the clipped polygon.
- </description>
- </method>
- <method name="clip_polygons_2d">
+ <method name="clip_polygons">
<return type="Array">
</return>
<argument index="0" name="polygon_a" type="PackedVector2Array">
@@ -73,7 +21,7 @@
If [code]polygon_b[/code] is enclosed by [code]polygon_a[/code], returns an outer polygon (boundary) and inner polygon (hole) which could be distinguished by calling [method is_polygon_clockwise].
</description>
</method>
- <method name="clip_polyline_with_polygon_2d">
+ <method name="clip_polyline_with_polygon">
<return type="Array">
</return>
<argument index="0" name="polyline" type="PackedVector2Array">
@@ -84,7 +32,7 @@
Clips [code]polyline[/code] against [code]polygon[/code] and returns an array of clipped polylines. This performs [constant OPERATION_DIFFERENCE] between the polyline and the polygon. This operation can be thought of as cutting a line with a closed shape.
</description>
</method>
- <method name="convex_hull_2d">
+ <method name="convex_hull">
<return type="PackedVector2Array">
</return>
<argument index="0" name="points" type="PackedVector2Array">
@@ -93,7 +41,7 @@
Given an array of [Vector2]s, returns the convex hull as a list of points in counterclockwise order. The last point is the same as the first one.
</description>
</method>
- <method name="exclude_polygons_2d">
+ <method name="exclude_polygons">
<return type="Array">
</return>
<argument index="0" name="polygon_a" type="PackedVector2Array">
@@ -101,24 +49,11 @@
<argument index="1" name="polygon_b" type="PackedVector2Array">
</argument>
<description>
- Mutually excludes common area defined by intersection of [code]polygon_a[/code] and [code]polygon_b[/code] (see [method intersect_polygons_2d]) and returns an array of excluded polygons. This performs [constant OPERATION_XOR] between polygons. In other words, returns all but common area between polygons.
+ Mutually excludes common area defined by intersection of [code]polygon_a[/code] and [code]polygon_b[/code] (see [method intersect_polygons]) and returns an array of excluded polygons. This performs [constant OPERATION_XOR] between polygons. In other words, returns all but common area between polygons.
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise].
</description>
</method>
<method name="get_closest_point_to_segment">
- <return type="Vector3">
- </return>
- <argument index="0" name="point" type="Vector3">
- </argument>
- <argument index="1" name="s1" type="Vector3">
- </argument>
- <argument index="2" name="s2" type="Vector3">
- </argument>
- <description>
- Returns the 3D point on the 3D segment ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point will always be inside the specified segment.
- </description>
- </method>
- <method name="get_closest_point_to_segment_2d">
<return type="Vector2">
</return>
<argument index="0" name="point" type="Vector2">
@@ -132,19 +67,6 @@
</description>
</method>
<method name="get_closest_point_to_segment_uncapped">
- <return type="Vector3">
- </return>
- <argument index="0" name="point" type="Vector3">
- </argument>
- <argument index="1" name="s1" type="Vector3">
- </argument>
- <argument index="2" name="s2" type="Vector3">
- </argument>
- <description>
- Returns the 3D point on the 3D line defined by ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point can be inside the segment ([code]s1[/code], [code]s2[/code]) or outside of it, i.e. somewhere on the line extending from the segment.
- </description>
- </method>
- <method name="get_closest_point_to_segment_uncapped_2d">
<return type="Vector2">
</return>
<argument index="0" name="point" type="Vector2">
@@ -158,21 +80,6 @@
</description>
</method>
<method name="get_closest_points_between_segments">
- <return type="PackedVector3Array">
- </return>
- <argument index="0" name="p1" type="Vector3">
- </argument>
- <argument index="1" name="p2" type="Vector3">
- </argument>
- <argument index="2" name="q1" type="Vector3">
- </argument>
- <argument index="3" name="q2" type="Vector3">
- </argument>
- <description>
- Given the two 3D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector3Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]).
- </description>
- </method>
- <method name="get_closest_points_between_segments_2d">
<return type="PackedVector2Array">
</return>
<argument index="0" name="p1" type="Vector2">
@@ -187,16 +94,7 @@
Given the two 2D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector2Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]).
</description>
</method>
- <method name="get_uv84_normal_bit">
- <return type="int">
- </return>
- <argument index="0" name="normal" type="Vector3">
- </argument>
- <description>
- Used internally by the engine.
- </description>
- </method>
- <method name="intersect_polygons_2d">
+ <method name="intersect_polygons">
<return type="Array">
</return>
<argument index="0" name="polygon_a" type="PackedVector2Array">
@@ -208,7 +106,7 @@
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise].
</description>
</method>
- <method name="intersect_polyline_with_polygon_2d">
+ <method name="intersect_polyline_with_polygon">
<return type="Array">
</return>
<argument index="0" name="polyline" type="PackedVector2Array">
@@ -252,7 +150,7 @@
Returns [code]true[/code] if [code]polygon[/code]'s vertices are ordered in clockwise order, otherwise returns [code]false[/code].
</description>
</method>
- <method name="line_intersects_line_2d">
+ <method name="line_intersects_line">
<return type="Variant">
</return>
<argument index="0" name="from_a" type="Vector2">
@@ -277,7 +175,7 @@
Given an array of [Vector2]s representing tiles, builds an atlas. The returned dictionary has two keys: [code]points[/code] is a vector of [Vector2] that specifies the positions of each tile, [code]size[/code] contains the overall size of the whole atlas as [Vector2].
</description>
</method>
- <method name="merge_polygons_2d">
+ <method name="merge_polygons">
<return type="Array">
</return>
<argument index="0" name="polygon_a" type="PackedVector2Array">
@@ -289,14 +187,14 @@
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise].
</description>
</method>
- <method name="offset_polygon_2d">
+ <method name="offset_polygon">
<return type="Array">
</return>
<argument index="0" name="polygon" type="PackedVector2Array">
</argument>
<argument index="1" name="delta" type="float">
</argument>
- <argument index="2" name="join_type" type="int" enum="Geometry.PolyJoinType" default="0">
+ <argument index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0">
</argument>
<description>
Inflates or deflates [code]polygon[/code] by [code]delta[/code] units (pixels). If [code]delta[/code] is positive, makes the polygon grow outward. If [code]delta[/code] is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if [code]delta[/code] is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon.
@@ -304,16 +202,16 @@
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling [method is_polygon_clockwise].
</description>
</method>
- <method name="offset_polyline_2d">
+ <method name="offset_polyline">
<return type="Array">
</return>
<argument index="0" name="polyline" type="PackedVector2Array">
</argument>
<argument index="1" name="delta" type="float">
</argument>
- <argument index="2" name="join_type" type="int" enum="Geometry.PolyJoinType" default="0">
+ <argument index="2" name="join_type" type="int" enum="Geometry2D.PolyJoinType" default="0">
</argument>
- <argument index="3" name="end_type" type="int" enum="Geometry.PolyEndType" default="3">
+ <argument index="3" name="end_type" type="int" enum="Geometry2D.PolyEndType" default="3">
</argument>
<description>
Inflates or deflates [code]polyline[/code] by [code]delta[/code] units (pixels), producing polygons. If [code]delta[/code] is positive, makes the polyline grow outward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. If [code]delta[/code] is negative, returns an empty array.
@@ -337,67 +235,7 @@
Returns if [code]point[/code] is inside the triangle specified by [code]a[/code], [code]b[/code] and [code]c[/code].
</description>
</method>
- <method name="ray_intersects_triangle">
- <return type="Variant">
- </return>
- <argument index="0" name="from" type="Vector3">
- </argument>
- <argument index="1" name="dir" type="Vector3">
- </argument>
- <argument index="2" name="a" type="Vector3">
- </argument>
- <argument index="3" name="b" type="Vector3">
- </argument>
- <argument index="4" name="c" type="Vector3">
- </argument>
- <description>
- Tests if the 3D ray starting at [code]from[/code] with the direction of [code]dir[/code] intersects the triangle specified by [code]a[/code], [code]b[/code] and [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned.
- </description>
- </method>
- <method name="segment_intersects_circle">
- <return type="float">
- </return>
- <argument index="0" name="segment_from" type="Vector2">
- </argument>
- <argument index="1" name="segment_to" type="Vector2">
- </argument>
- <argument index="2" name="circle_position" type="Vector2">
- </argument>
- <argument index="3" name="circle_radius" type="float">
- </argument>
- <description>
- Given the 2D segment ([code]segment_from[/code], [code]segment_to[/code]), returns the position on the segment (as a number between 0 and 1) at which the segment hits the circle that is located at position [code]circle_position[/code] and has radius [code]circle_radius[/code]. If the segment does not intersect the circle, -1 is returned (this is also the case if the line extending the segment would intersect the circle, but the segment does not).
- </description>
- </method>
- <method name="segment_intersects_convex">
- <return type="PackedVector3Array">
- </return>
- <argument index="0" name="from" type="Vector3">
- </argument>
- <argument index="1" name="to" type="Vector3">
- </argument>
- <argument index="2" name="planes" type="Array">
- </argument>
- <description>
- Given a convex hull defined though the [Plane]s in the array [code]planes[/code], tests if the segment ([code]from[/code], [code]to[/code]) intersects with that hull. If an intersection is found, returns a [PackedVector3Array] containing the point the intersection and the hull's normal. If no intersecion is found, an the returned array is empty.
- </description>
- </method>
- <method name="segment_intersects_cylinder">
- <return type="PackedVector3Array">
- </return>
- <argument index="0" name="from" type="Vector3">
- </argument>
- <argument index="1" name="to" type="Vector3">
- </argument>
- <argument index="2" name="height" type="float">
- </argument>
- <argument index="3" name="radius" type="float">
- </argument>
- <description>
- Checks if the segment ([code]from[/code], [code]to[/code]) intersects the cylinder with height [code]height[/code] that is centered at the origin and has radius [code]radius[/code]. If no, returns an empty [PackedVector3Array]. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection.
- </description>
- </method>
- <method name="segment_intersects_segment_2d">
+ <method name="segment_intersects_segment">
<return type="Variant">
</return>
<argument index="0" name="from_a" type="Vector2">
@@ -412,39 +250,7 @@
Checks if the two segments ([code]from_a[/code], [code]to_a[/code]) and ([code]from_b[/code], [code]to_b[/code]) intersect. If yes, return the point of intersection as [Vector2]. If no intersection takes place, returns an empty [Variant].
</description>
</method>
- <method name="segment_intersects_sphere">
- <return type="PackedVector3Array">
- </return>
- <argument index="0" name="from" type="Vector3">
- </argument>
- <argument index="1" name="to" type="Vector3">
- </argument>
- <argument index="2" name="sphere_position" type="Vector3">
- </argument>
- <argument index="3" name="sphere_radius" type="float">
- </argument>
- <description>
- Checks if the segment ([code]from[/code], [code]to[/code]) intersects the sphere that is located at [code]sphere_position[/code] and has radius [code]sphere_radius[/code]. If no, returns an empty [PackedVector3Array]. If yes, returns a [PackedVector3Array] containing the point of intersection and the sphere's normal at the point of intersection.
- </description>
- </method>
- <method name="segment_intersects_triangle">
- <return type="Variant">
- </return>
- <argument index="0" name="from" type="Vector3">
- </argument>
- <argument index="1" name="to" type="Vector3">
- </argument>
- <argument index="2" name="a" type="Vector3">
- </argument>
- <argument index="3" name="b" type="Vector3">
- </argument>
- <argument index="4" name="c" type="Vector3">
- </argument>
- <description>
- Tests if the segment ([code]from[/code], [code]to[/code]) intersects the triangle [code]a[/code], [code]b[/code], [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned.
- </description>
- </method>
- <method name="triangulate_delaunay_2d">
+ <method name="triangulate_delaunay">
<return type="PackedInt32Array">
</return>
<argument index="0" name="points" type="PackedVector2Array">
diff --git a/doc/classes/Geometry3D.xml b/doc/classes/Geometry3D.xml
new file mode 100644
index 0000000000..ec685a5ce7
--- /dev/null
+++ b/doc/classes/Geometry3D.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="Geometry3D" inherits="Object" version="4.0">
+ <brief_description>
+ Helper node to calculate generic geometry operations in 3D space.
+ </brief_description>
+ <description>
+ Geometry3D provides users with a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="build_box_planes">
+ <return type="Array">
+ </return>
+ <argument index="0" name="extents" type="Vector3">
+ </argument>
+ <description>
+ Returns an array with 6 [Plane]s that describe the sides of a box centered at the origin. The box size is defined by [code]extents[/code], which represents one (positive) corner of the box (i.e. half its actual size).
+ </description>
+ </method>
+ <method name="build_capsule_planes">
+ <return type="Array">
+ </return>
+ <argument index="0" name="radius" type="float">
+ </argument>
+ <argument index="1" name="height" type="float">
+ </argument>
+ <argument index="2" name="sides" type="int">
+ </argument>
+ <argument index="3" name="lats" type="int">
+ </argument>
+ <argument index="4" name="axis" type="int" enum="Vector3.Axis" default="2">
+ </argument>
+ <description>
+ Returns an array of [Plane]s closely bounding a faceted capsule centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the side part of the capsule, whereas [code]lats[/code] gives the number of latitudinal steps at the bottom and top of the capsule. The parameter [code]axis[/code] describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z).
+ </description>
+ </method>
+ <method name="build_cylinder_planes">
+ <return type="Array">
+ </return>
+ <argument index="0" name="radius" type="float">
+ </argument>
+ <argument index="1" name="height" type="float">
+ </argument>
+ <argument index="2" name="sides" type="int">
+ </argument>
+ <argument index="3" name="axis" type="int" enum="Vector3.Axis" default="2">
+ </argument>
+ <description>
+ Returns an array of [Plane]s closely bounding a faceted cylinder centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the round part of the cylinder. The parameter [code]axis[/code] describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z).
+ </description>
+ </method>
+ <method name="clip_polygon">
+ <return type="PackedVector3Array">
+ </return>
+ <argument index="0" name="points" type="PackedVector3Array">
+ </argument>
+ <argument index="1" name="plane" type="Plane">
+ </argument>
+ <description>
+ Clips the polygon defined by the points in [code]points[/code] against the [code]plane[/code] and returns the points of the clipped polygon.
+ </description>
+ </method>
+ <method name="get_closest_point_to_segment">
+ <return type="Vector3">
+ </return>
+ <argument index="0" name="point" type="Vector3">
+ </argument>
+ <argument index="1" name="s1" type="Vector3">
+ </argument>
+ <argument index="2" name="s2" type="Vector3">
+ </argument>
+ <description>
+ Returns the 3D point on the 3D segment ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point will always be inside the specified segment.
+ </description>
+ </method>
+ <method name="get_closest_point_to_segment_uncapped">
+ <return type="Vector3">
+ </return>
+ <argument index="0" name="point" type="Vector3">
+ </argument>
+ <argument index="1" name="s1" type="Vector3">
+ </argument>
+ <argument index="2" name="s2" type="Vector3">
+ </argument>
+ <description>
+ Returns the 3D point on the 3D line defined by ([code]s1[/code], [code]s2[/code]) that is closest to [code]point[/code]. The returned point can be inside the segment ([code]s1[/code], [code]s2[/code]) or outside of it, i.e. somewhere on the line extending from the segment.
+ </description>
+ </method>
+ <method name="get_closest_points_between_segments">
+ <return type="PackedVector3Array">
+ </return>
+ <argument index="0" name="p1" type="Vector3">
+ </argument>
+ <argument index="1" name="p2" type="Vector3">
+ </argument>
+ <argument index="2" name="q1" type="Vector3">
+ </argument>
+ <argument index="3" name="q2" type="Vector3">
+ </argument>
+ <description>
+ Given the two 3D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector3Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]).
+ </description>
+ </method>
+ <method name="get_uv84_normal_bit">
+ <return type="int">
+ </return>
+ <argument index="0" name="normal" type="Vector3">
+ </argument>
+ <description>
+ Used internally by the engine.
+ </description>
+ </method>
+ <method name="ray_intersects_triangle">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="from" type="Vector3">
+ </argument>
+ <argument index="1" name="dir" type="Vector3">
+ </argument>
+ <argument index="2" name="a" type="Vector3">
+ </argument>
+ <argument index="3" name="b" type="Vector3">
+ </argument>
+ <argument index="4" name="c" type="Vector3">
+ </argument>
+ <description>
+ Tests if the 3D ray starting at [code]from[/code] with the direction of [code]dir[/code] intersects the triangle specified by [code]a[/code], [code]b[/code] and [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned.
+ </description>
+ </method>
+ <method name="segment_intersects_convex">
+ <return type="PackedVector3Array">
+ </return>
+ <argument index="0" name="from" type="Vector3">
+ </argument>
+ <argument index="1" name="to" type="Vector3">
+ </argument>
+ <argument index="2" name="planes" type="Array">
+ </argument>
+ <description>
+ Given a convex hull defined though the [Plane]s in the array [code]planes[/code], tests if the segment ([code]from[/code], [code]to[/code]) intersects with that hull. If an intersection is found, returns a [PackedVector3Array] containing the point the intersection and the hull's normal. If no intersecion is found, an the returned array is empty.
+ </description>
+ </method>
+ <method name="segment_intersects_cylinder">
+ <return type="PackedVector3Array">
+ </return>
+ <argument index="0" name="from" type="Vector3">
+ </argument>
+ <argument index="1" name="to" type="Vector3">
+ </argument>
+ <argument index="2" name="height" type="float">
+ </argument>
+ <argument index="3" name="radius" type="float">
+ </argument>
+ <description>
+ Checks if the segment ([code]from[/code], [code]to[/code]) intersects the cylinder with height [code]height[/code] that is centered at the origin and has radius [code]radius[/code]. If no, returns an empty [PackedVector3Array]. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection.
+ </description>
+ </method>
+ <method name="segment_intersects_sphere">
+ <return type="PackedVector3Array">
+ </return>
+ <argument index="0" name="from" type="Vector3">
+ </argument>
+ <argument index="1" name="to" type="Vector3">
+ </argument>
+ <argument index="2" name="sphere_position" type="Vector3">
+ </argument>
+ <argument index="3" name="sphere_radius" type="float">
+ </argument>
+ <description>
+ Checks if the segment ([code]from[/code], [code]to[/code]) intersects the sphere that is located at [code]sphere_position[/code] and has radius [code]sphere_radius[/code]. If no, returns an empty [PackedVector3Array]. If yes, returns a [PackedVector3Array] containing the point of intersection and the sphere's normal at the point of intersection.
+ </description>
+ </method>
+ <method name="segment_intersects_triangle">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="from" type="Vector3">
+ </argument>
+ <argument index="1" name="to" type="Vector3">
+ </argument>
+ <argument index="2" name="a" type="Vector3">
+ </argument>
+ <argument index="3" name="b" type="Vector3">
+ </argument>
+ <argument index="4" name="c" type="Vector3">
+ </argument>
+ <description>
+ Tests if the segment ([code]from[/code], [code]to[/code]) intersects the triangle [code]a[/code], [code]b[/code], [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned.
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml
index 99253e8840..d29fcfd96f 100644
--- a/doc/classes/Image.xml
+++ b/doc/classes/Image.xml
@@ -154,7 +154,7 @@
<argument index="4" name="data" type="PackedByteArray">
</argument>
<description>
- Creates a new image of given size and format. See [enum Format] constants. Fills the image with the given raw data. If [code]use_mipmaps[/code] is [code]true[/code] then generate mipmaps for this image. See the [method generate_mipmaps].
+ Creates a new image of given size and format. See [enum Format] constants. Fills the image with the given raw data. If [code]use_mipmaps[/code] is [code]true[/code] then loads mipmaps for this image from [code]data[/code]. See [method generate_mipmaps].
</description>
</method>
<method name="crop">
@@ -190,13 +190,6 @@
<description>
</description>
</method>
- <method name="expand_x2_hq2x">
- <return type="void">
- </return>
- <description>
- Stretches the image and enlarges it by a factor of 2. No interpolation is done.
- </description>
- </method>
<method name="fill">
<return type="void">
</return>
@@ -443,6 +436,12 @@
Saves the image as a PNG file to [code]path[/code].
</description>
</method>
+ <method name="save_png_to_buffer" qualifiers="const">
+ <return type="PackedByteArray">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_pixel">
<return type="void">
</return>
diff --git a/doc/classes/ImageTextureLayered.xml b/doc/classes/ImageTextureLayered.xml
new file mode 100644
index 0000000000..d06b44afa9
--- /dev/null
+++ b/doc/classes/ImageTextureLayered.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="ImageTextureLayered" inherits="TextureLayered" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="create_from_images">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="images" type="Array">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="update_layer">
+ <return type="void">
+ </return>
+ <argument index="0" name="image" type="Image">
+ </argument>
+ <argument index="1" name="layer" type="int">
+ </argument>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/InputMap.xml b/doc/classes/InputMap.xml
index da93d7fb53..842c69de27 100644
--- a/doc/classes/InputMap.xml
+++ b/doc/classes/InputMap.xml
@@ -95,7 +95,7 @@
Returns [code]true[/code] if the given event is part of an existing action. This method ignores keyboard modifiers if the given [InputEvent] is not pressed (for proper release detection). See [method action_has_event] if you don't want this behavior.
</description>
</method>
- <method name="get_action_list">
+ <method name="action_get_events">
<return type="Array">
</return>
<argument index="0" name="action" type="StringName">
diff --git a/doc/classes/KinematicBody2D.xml b/doc/classes/KinematicBody2D.xml
index 6b2bbeb895..f0f4d83821 100644
--- a/doc/classes/KinematicBody2D.xml
+++ b/doc/classes/KinematicBody2D.xml
@@ -9,7 +9,7 @@
[b]Kinematic characters:[/b] KinematicBody2D also has an API for moving objects (the [method move_and_collide] and [method move_and_slide] methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
</description>
<tutorials>
- <link>https://docs.godotengine.org/en/latest/tutorials/physics/kinematic_character_2d.html</link>
+ <link title="Kinematic character (2D)">https://docs.godotengine.org/en/latest/tutorials/physics/kinematic_character_2d.html</link>
<link>https://docs.godotengine.org/en/latest/tutorials/physics/using_kinematic_body_2d.html</link>
</tutorials>
<methods>
diff --git a/doc/classes/KinematicBody3D.xml b/doc/classes/KinematicBody3D.xml
index 830d63ed11..5477c6bab6 100644
--- a/doc/classes/KinematicBody3D.xml
+++ b/doc/classes/KinematicBody3D.xml
@@ -18,7 +18,7 @@
<argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis">
</argument>
<description>
- Returns [code]true[/code] if the specified [code]axis[/code] is locked. See also [member move_lock_x], [member move_lock_y] and [member move_lock_z].
+ Returns [code]true[/code] if the specified [code]axis[/code] is locked. See also [member axis_lock_motion_x], [member axis_lock_motion_y] and [member axis_lock_motion_z].
</description>
</method>
<method name="get_floor_normal" qualifiers="const">
@@ -145,7 +145,7 @@
<argument index="1" name="lock" type="bool">
</argument>
<description>
- Locks or unlocks the specified [code]axis[/code] depending on the value of [code]lock[/code]. See also [member move_lock_x], [member move_lock_y] and [member move_lock_z].
+ Locks or unlocks the specified [code]axis[/code] depending on the value of [code]lock[/code]. See also [member axis_lock_motion_x], [member axis_lock_motion_y] and [member axis_lock_motion_z].
</description>
</method>
<method name="test_move">
@@ -163,18 +163,18 @@
</method>
</methods>
<members>
- <member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin" default="0.001">
- If the body is at least this close to another body, this body will consider them to be colliding.
- </member>
- <member name="move_lock_x" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
+ <member name="axis_lock_motion_x" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
Lock the body's X axis movement.
</member>
- <member name="move_lock_y" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
+ <member name="axis_lock_motion_y" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
Lock the body's Y axis movement.
</member>
- <member name="move_lock_z" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
+ <member name="axis_lock_motion_z" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false">
Lock the body's Z axis movement.
</member>
+ <member name="collision/safe_margin" type="float" setter="set_safe_margin" getter="get_safe_margin" default="0.001">
+ If the body is at least this close to another body, this body will consider them to be colliding.
+ </member>
</members>
<constants>
</constants>
diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml
index 263fb6c022..3318f2757d 100644
--- a/doc/classes/Label.xml
+++ b/doc/classes/Label.xml
@@ -57,7 +57,7 @@
</member>
<member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="2" />
<member name="percent_visible" type="float" setter="set_percent_visible" getter="get_percent_visible" default="1.0">
- Limits the count of visible characters. If you set [code]percent_visible[/code] to 50, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.
+ Limits the amount of visible characters. If you set [code]percent_visible[/code] to 0.5, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.
</member>
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="4" />
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml
index cb21db2d00..930a68be7f 100644
--- a/doc/classes/Light3D.xml
+++ b/doc/classes/Light3D.xml
@@ -4,7 +4,7 @@
Provides a base class for different kinds of light nodes.
</brief_description>
<description>
- Light3D is the abstract base class for light nodes, so it shouldn't be used directly (it can't be instanced). Other types of light nodes inherit from it. Light3D contains the common variables and parameters used for lighting.
+ Light3D is the [i]abstract[/i] base class for light nodes. As it can't be instanced, it shouldn't be used directly. Other types of light nodes inherit from it. Light3D contains the common variables and parameters used for lighting.
</description>
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/3d/lights_and_shadows.html</link>
@@ -36,19 +36,19 @@
If [code]true[/code], the light only appears in the editor and will not be visible at runtime.
</member>
<member name="light_angular_distance" type="float" setter="set_param" getter="get_param" default="0.0">
- Angular size of the light in degrees. Only available for [DirectionalLight3D]s. For reference, the sun from earth is approximately [code]0.5[/code].
+ The light's angular size in degrees. Only available for [DirectionalLight3D]s. For reference, the Sun from the Earth is approximately [code]0.5[/code].
</member>
<member name="light_bake_mode" type="int" setter="set_bake_mode" getter="get_bake_mode" enum="Light3D.BakeMode" default="1">
The light's bake mode. See [enum BakeMode].
</member>
<member name="light_color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )">
- The light's color.
+ The light's color. An [i]overbright[/i] color can be used to achieve a result equivalent to increasing the light's [member light_energy].
</member>
<member name="light_cull_mask" type="int" setter="set_cull_mask" getter="get_cull_mask" default="4294967295">
The light will affect objects in the selected layers.
</member>
<member name="light_energy" type="float" setter="set_param" getter="get_param" default="1.0">
- The light's strength multiplier.
+ The light's strength multiplier (this is not a physical unit). For [OmniLight3D] and [SpotLight3D], changing this value will only change the light color's intensity, not the light's radius.
</member>
<member name="light_indirect_energy" type="float" setter="set_param" getter="get_param" default="1.0">
Secondary multiplier used with indirect light (light bounces). Used with [GIProbe].
@@ -60,16 +60,16 @@
[Texture2D] projected by light. [member shadow_enabled] must be on for the projector to work. Light projectors make the light appear as if it is shining through a colored but transparent object, almost like light shining through stained glass.
</member>
<member name="light_size" type="float" setter="set_param" getter="get_param" default="0.0">
- The size of the light in Godot units. Only available for [OmniLight3D]s and [SpotLight3D]s.
+ The size of the light in Godot units. Only available for [OmniLight3D]s and [SpotLight3D]s. Increasing this value will make the light fade out slower and shadows appear blurrier. This can be used to simulate area lights to an extent.
</member>
<member name="light_specular" type="float" setter="set_param" getter="get_param" default="0.5">
- The intensity of the specular blob in objects affected by the light. At [code]0[/code] the light becomes a pure diffuse light.
+ The intensity of the specular blob in objects affected by the light. At [code]0[/code], the light becomes a pure diffuse light. When not baking emission, this can be used to avoid unrealistic reflections when placing lights above an emissive surface.
</member>
<member name="shadow_bias" type="float" setter="set_param" getter="get_param" default="0.02">
- Used to adjust shadow appearance. Too small a value results in self-shadowing, while too large a value causes shadows to separate from casters. Adjust as needed.
+ Used to adjust shadow appearance. Too small a value results in self-shadowing ("shadow acne"), while too large a value causes shadows to separate from casters ("peter-panning"). Adjust as needed.
</member>
<member name="shadow_blur" type="float" setter="set_param" getter="get_param" default="1.0">
- Blurs the edges of the shadow. Can be used to hide pixel artifacts in low resolution shadow maps. A high value can make shadows appear grainy and can cause other unwanted artifacts. Try to keep as near default as possible.
+ Blurs the edges of the shadow. Can be used to hide pixel artifacts in low-resolution shadow maps. A high value can impact performance, make shadows appear grainy and can cause other unwanted artifacts. Try to keep as near default as possible.
</member>
<member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 1 )">
The color of shadows cast by this light.
@@ -78,7 +78,7 @@
If [code]true[/code], the light will cast shadows.
</member>
<member name="shadow_normal_bias" type="float" setter="set_param" getter="get_param" default="1.0">
- Offsets the lookup into the shadow map by the objects normal. This can be used reduce self-shadowing artifacts without using [member shadow_bias]. In practice, this value should be tweaked along with [member shadow_bias] to reduce artifacts as much as possible.
+ Offsets the lookup into the shadow map by the object's normal. This can be used to reduce self-shadowing artifacts without using [member shadow_bias]. In practice, this value should be tweaked along with [member shadow_bias] to reduce artifacts as much as possible.
</member>
<member name="shadow_reverse_cull_face" type="bool" setter="set_shadow_reverse_cull_face" getter="get_shadow_reverse_cull_face" default="false">
If [code]true[/code], reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows with [constant GeometryInstance3D.SHADOW_CASTING_SETTING_DOUBLE_SIDED].
diff --git a/doc/classes/Lightmapper.xml b/doc/classes/Lightmapper.xml
new file mode 100644
index 0000000000..e80194858a
--- /dev/null
+++ b/doc/classes/Lightmapper.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="Lightmapper" inherits="Reference" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index 3eeb892719..c1c54dd11b 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -43,7 +43,25 @@
<return type="void">
</return>
<description>
- Erases the [LineEdit] text.
+ Erases the [LineEdit]'s [member text].
+ </description>
+ </method>
+ <method name="delete_char_at_cursor">
+ <return type="void">
+ </return>
+ <description>
+ Deletes one character at the cursor's current position (equivalent to pressing [kbd]Delete[/kbd]).
+ </description>
+ </method>
+ <method name="delete_text">
+ <return type="void">
+ </return>
+ <argument index="0" name="from_column" type="int">
+ </argument>
+ <argument index="1" name="to_column" type="int">
+ </argument>
+ <description>
+ Deletes a section of the [member text] going from position [code]from_column[/code] to [code]to_column[/code]. Both parameters should be within the text's length.
</description>
</method>
<method name="deselect">
diff --git a/doc/classes/Material.xml b/doc/classes/Material.xml
index a37c8127f0..f3686876ca 100644
--- a/doc/classes/Material.xml
+++ b/doc/classes/Material.xml
@@ -17,7 +17,7 @@
</member>
<member name="render_priority" type="int" setter="set_render_priority" getter="get_render_priority" default="0">
Sets the render priority for transparent objects in 3D scenes. Higher priority objects will be sorted in front of lower priority objects.
- [b]Note:[/b] this only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are sorted based on depth, while transparent objects are sorted from back to front (subject to priority).
+ [b]Note:[/b] this only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
</member>
</members>
<constants>
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 0c0d16753a..9617ee0437 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -55,6 +55,7 @@
It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_input].
To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called.
For gameplay input, [method _unhandled_input] and [method _unhandled_key_input] are usually a better fit as they allow the GUI to intercept the events first.
+ [b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
</description>
</method>
<method name="_physics_process" qualifiers="virtual">
@@ -66,6 +67,7 @@
Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the [code]delta[/code] variable should be constant.
It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_physics_process].
Corresponds to the [constant NOTIFICATION_PHYSICS_PROCESS] notification in [method Object._notification].
+ [b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
</description>
</method>
<method name="_process" qualifiers="virtual">
@@ -77,6 +79,7 @@
Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the [code]delta[/code] time since the previous frame is not constant.
It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process].
Corresponds to the [constant NOTIFICATION_PROCESS] notification in [method Object._notification].
+ [b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
</description>
</method>
<method name="_ready" qualifiers="virtual">
@@ -99,6 +102,7 @@
It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_input].
To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called.
For gameplay input, this and [method _unhandled_key_input] are usually a better fit than [method _input] as they allow the GUI to intercept the events first.
+ [b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
</description>
</method>
<method name="_unhandled_key_input" qualifiers="virtual">
@@ -111,6 +115,7 @@
It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_key_input].
To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called.
For gameplay input, this and [method _unhandled_input] are usually a better fit than [method _input] as they allow the GUI to intercept the events first.
+ [b]Note:[/b] This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
</description>
</method>
<method name="add_child">
@@ -129,21 +134,19 @@
child_node.get_parent().remove_child(child_node)
add_child(child_node)
[/codeblock]
- If you need the child node to be added below a specific node in the list of children, use [method add_child_below_node] instead of this method.
+ If you need the child node to be added below a specific node in the list of children, use [method add_sibling] instead of this method.
[b]Note:[/b] If you want a child to be persisted to a [PackedScene], you must set [member owner] in addition to calling [method add_child]. This is typically relevant for [url=https://godot.readthedocs.io/en/latest/tutorials/misc/running_code_in_the_editor.html]tool scripts[/url] and [url=https://godot.readthedocs.io/en/latest/tutorials/plugins/editor/index.html]editor plugins[/url]. If [method add_child] is called without setting [member owner], the newly added [Node] will not be visible in the scene tree, though it will be visible in the 2D/3D view.
</description>
</method>
- <method name="add_child_below_node">
+ <method name="add_sibling">
<return type="void">
</return>
- <argument index="0" name="preceding_node" type="Node">
+ <argument index="0" name="sibling" type="Node">
</argument>
- <argument index="1" name="node" type="Node">
- </argument>
- <argument index="2" name="legible_unique_name" type="bool" default="false">
+ <argument index="1" name="legible_unique_name" type="bool" default="false">
</argument>
<description>
- Adds a child node below the [code]preceding_node[/code].
+ Adds a [code]sibling[/code] node to current's node parent, at the the same level as that node, right below it.
If [code]legible_unique_name[/code] is [code]true[/code], the child node will have an human-readable name based on the name of the node being instanced instead of its type.
Use [method add_child] instead of this method if you don't need the child node to be added below a specific node in the list of children.
</description>
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 6a70297f40..b131d2728c 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -268,6 +268,24 @@
Returns the epoch time of the operating system in seconds.
</description>
</method>
+ <method name="get_tablet_driver_count" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ Returns the total number of available tablet drivers.
+ [b]Note:[/b] This method is implemented on Windows.
+ </description>
+ </method>
+ <method name="get_tablet_driver_name" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ Returns the tablet driver name for the given index.
+ [b]Note:[/b] This method is implemented on Windows.
+ </description>
+ </method>
<method name="get_ticks_msec" qualifiers="const">
<return type="int">
</return>
@@ -307,7 +325,7 @@
</description>
</method>
<method name="get_unix_time" qualifiers="const">
- <return type="int">
+ <return type="float">
</return>
<description>
Returns the current UNIX epoch timestamp.
@@ -500,6 +518,9 @@
<member name="low_processor_usage_mode_sleep_usec" type="int" setter="set_low_processor_usage_mode_sleep_usec" getter="get_low_processor_usage_mode_sleep_usec" default="6900">
The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage.
</member>
+ <member name="tablet_driver" type="String" setter="set_current_tablet_driver" getter="get_current_tablet_driver" default="&quot;&quot;">
+ The current tablet drvier in use.
+ </member>
</members>
<constants>
<constant name="VIDEO_DRIVER_GLES2" value="0" enum="VideoDriver">
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index 35e87d1a2a..8d08688b41 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -15,6 +15,7 @@
print("position" in n) # Prints "True".
print("other_property" in n) # Prints "False".
[/codeblock]
+ The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code].
Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification].
</description>
<tutorials>
@@ -192,7 +193,7 @@
<return type="void">
</return>
<description>
- Deletes the object from memory. Any pre-existing reference to the freed object will now return [code]null[/code].
+ Deletes the object from memory. Any pre-existing reference to the freed object will become invalid, e.g. [code]is_instance_valid(object)[/code] will return [code]false[/code].
</description>
</method>
<method name="get" qualifiers="const">
diff --git a/doc/classes/OmniLight3D.xml b/doc/classes/OmniLight3D.xml
index 0bbc987156..000d67e691 100644
--- a/doc/classes/OmniLight3D.xml
+++ b/doc/classes/OmniLight3D.xml
@@ -16,7 +16,7 @@
The light's attenuation (drop-off) curve. A number of presets are available in the [b]Inspector[/b] by right-clicking the curve.
</member>
<member name="omni_range" type="float" setter="set_param" getter="get_param" default="5.0">
- The light's radius.
+ The light's radius. Note that the effectively lit area may appear to be smaller depending on the [member omni_attenuation] in use. No matter the [member omni_attenuation] in use, the light will never reach anything outside this radius.
</member>
<member name="omni_shadow_mode" type="int" setter="set_shadow_mode" getter="get_shadow_mode" enum="OmniLight3D.ShadowMode" default="1">
See [enum ShadowMode].
diff --git a/doc/classes/PhysicalSkyMaterial.xml b/doc/classes/PhysicalSkyMaterial.xml
index 89b43158dc..2e0f9c52f2 100644
--- a/doc/classes/PhysicalSkyMaterial.xml
+++ b/doc/classes/PhysicalSkyMaterial.xml
@@ -31,6 +31,9 @@
<member name="mie_eccentricity" type="float" setter="set_mie_eccentricity" getter="get_mie_eccentricity" default="0.8">
Controls the direction of the mie scattering. A value of [code]1[/code] means that when light hits a particle it passing through straight forward. A value of [code]-1[/code] means that all light is scatter backwards.
</member>
+ <member name="night_sky" type="Texture2D" setter="set_night_sky" getter="get_night_sky">
+ [Texture2D] for the night sky. This is added to the sky, so if it is bright enough, it may be visible during the day.
+ </member>
<member name="rayleigh_coefficient" type="float" setter="set_rayleigh_coefficient" getter="get_rayleigh_coefficient" default="2.0">
Controls the strength of the rayleigh scattering. Rayleigh scattering results from light colliding with small particles. It is responsible for the blue color of the sky.
</member>
diff --git a/doc/classes/PhysicsMaterial.xml b/doc/classes/PhysicsMaterial.xml
index 6410626496..0889c238dc 100644
--- a/doc/classes/PhysicsMaterial.xml
+++ b/doc/classes/PhysicsMaterial.xml
@@ -12,6 +12,7 @@
</methods>
<members>
<member name="absorbent" type="bool" setter="set_absorbent" getter="is_absorbent" default="false">
+ If [code]true[/code], subtracts the bounciness from the colliding object's bounciness instead of adding it.
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce" default="0.0">
The body's bounciness. Values range from [code]0[/code] (no bounce) to [code]1[/code] (full bounciness).
@@ -20,6 +21,7 @@
The body's friction. Values range from [code]0[/code] (frictionless) to [code]1[/code] (maximum friction).
</member>
<member name="rough" type="bool" setter="set_rough" getter="is_rough" default="false">
+ If [code]true[/code], the physics engine will use the friction of the object marked as "rough" when two objects collide. If [code]false[/code], the physics engine will use the lowest friction of all colliding objects instead. If [code]true[/code] for both colliding objects, the physics engine will use the highest friction.
</member>
</members>
<constants>
diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml
index 9da739e57a..d7821b1045 100644
--- a/doc/classes/PhysicsServer2D.xml
+++ b/doc/classes/PhysicsServer2D.xml
@@ -864,28 +864,28 @@
Creates a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself.
</description>
</method>
- <method name="damped_string_joint_get_param" qualifiers="const">
+ <method name="damped_spring_joint_get_param" qualifiers="const">
<return type="float">
</return>
<argument index="0" name="joint" type="RID">
</argument>
- <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedStringParam">
+ <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam">
</argument>
<description>
- Returns the value of a damped spring joint parameter.
+ Returns the value of a damped spring joint parameter. See [enum DampedSpringParam] for a list of available parameters.
</description>
</method>
- <method name="damped_string_joint_set_param">
+ <method name="damped_spring_joint_set_param">
<return type="void">
</return>
<argument index="0" name="joint" type="RID">
</argument>
- <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedStringParam">
+ <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam">
</argument>
<argument index="2" name="value" type="float">
</argument>
<description>
- Sets a damped spring joint parameter. See [enum DampedStringParam] for a list of available parameters.
+ Sets a damped spring joint parameter. See [enum DampedSpringParam] for a list of available parameters.
</description>
</method>
<method name="free_rid">
@@ -1247,13 +1247,13 @@
</constant>
<constant name="JOINT_PARAM_MAX_FORCE" value="2" enum="JointParam">
</constant>
- <constant name="DAMPED_STRING_REST_LENGTH" value="0" enum="DampedStringParam">
+ <constant name="DAMPED_SPRING_REST_LENGTH" value="0" enum="DampedSpringParam">
Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart.
</constant>
- <constant name="DAMPED_STRING_STIFFNESS" value="1" enum="DampedStringParam">
+ <constant name="DAMPED_SPRING_STIFFNESS" value="1" enum="DampedSpringParam">
Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length.
</constant>
- <constant name="DAMPED_STRING_DAMPING" value="2" enum="DampedStringParam">
+ <constant name="DAMPED_SPRING_DAMPING" value="2" enum="DampedSpringParam">
Sets the damping ratio of the spring joint. A value of 0 indicates an undamped spring, while 1 causes the system to reach equilibrium as fast as possible (critical damping).
</constant>
<constant name="CCD_MODE_DISABLED" value="0" enum="CCDMode">
diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml
index 59450b7ea2..ce55c90c68 100644
--- a/doc/classes/PopupMenu.xml
+++ b/doc/classes/PopupMenu.xml
@@ -591,7 +591,7 @@
</method>
</methods>
<members>
- <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="false">
+ <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="true">
If [code]true[/code], allows to navigate [PopupMenu] with letter keys.
</member>
<member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection" default="true">
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 92f116c7ec..92e5b4a84f 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -137,7 +137,7 @@
<argument index="0" name="file" type="String">
</argument>
<description>
- Saves the configuration to a custom file.
+ Saves the configuration to a custom file. The file extension must be [code].godot[/code] (to save in text-based [ConfigFile] format) or [code].binary[/code] (to save in binary format).
</description>
</method>
<method name="set_initial_value">
@@ -414,9 +414,6 @@
<member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="" default="Vector2( 10, 10 )">
Position offset for tooltips, relative to the mouse cursor's hotspot.
</member>
- <member name="display/window/disable_wintab_api" type="bool" setter="" getter="" default="false">
- Disables WinTab API and always use Windows Ink API for the pen input (Windows only).
- </member>
<member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="false">
If [code]true[/code], allows HiDPI display on Windows and macOS. This setting has no effect on desktop Linux, as DPI-awareness fallbacks are not supported there.
</member>
@@ -453,6 +450,9 @@
<member name="display/window/size/width" type="int" setter="" getter="" default="1024">
Sets the game's main viewport width. On desktop platforms, this is the default window size. Stretch mode settings also use this as a reference when enabled.
</member>
+ <member name="display/window/tablet_driver" type="String" setter="" getter="" default="&quot;&quot;">
+ Specifies the tablet driver to use. If left empty, the default driver will be used.
+ </member>
<member name="display/window/vsync/use_vsync" type="bool" setter="" getter="" default="true">
If [code]true[/code], enables vertical synchronization. This eliminates tearing that may appear in moving scenes, at the cost of higher input latency and stuttering at lower framerates. If [code]false[/code], vertical synchronization will be disabled, however, many platforms will enforce it regardless (such as mobile platforms and HTML5).
</member>
@@ -844,30 +844,6 @@
<member name="network/limits/webrtc/max_channel_in_buffer_kb" type="int" setter="" getter="" default="64">
Maximum size (in kiB) for the [WebRTCDataChannel] input buffer.
</member>
- <member name="network/limits/websocket_client/max_in_buffer_kb" type="int" setter="" getter="" default="64">
- Maximum size (in kiB) for the [WebSocketClient] input buffer.
- </member>
- <member name="network/limits/websocket_client/max_in_packets" type="int" setter="" getter="" default="1024">
- Maximum number of concurrent input packets for [WebSocketClient].
- </member>
- <member name="network/limits/websocket_client/max_out_buffer_kb" type="int" setter="" getter="" default="64">
- Maximum size (in kiB) for the [WebSocketClient] output buffer.
- </member>
- <member name="network/limits/websocket_client/max_out_packets" type="int" setter="" getter="" default="1024">
- Maximum number of concurrent output packets for [WebSocketClient].
- </member>
- <member name="network/limits/websocket_server/max_in_buffer_kb" type="int" setter="" getter="" default="64">
- Maximum size (in kiB) for the [WebSocketServer] input buffer.
- </member>
- <member name="network/limits/websocket_server/max_in_packets" type="int" setter="" getter="" default="1024">
- Maximum number of concurrent input packets for [WebSocketServer].
- </member>
- <member name="network/limits/websocket_server/max_out_buffer_kb" type="int" setter="" getter="" default="64">
- Maximum size (in kiB) for the [WebSocketServer] output buffer.
- </member>
- <member name="network/limits/websocket_server/max_out_packets" type="int" setter="" getter="" default="1024">
- Maximum number of concurrent output packets for [WebSocketServer].
- </member>
<member name="network/remote_fs/page_read_ahead" type="int" setter="" getter="" default="4">
Amount of read ahead used by remote filesystem. Higher values decrease the effects of latency at the cost of higher bandwidth usage.
</member>
diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml
index 2e8be384c1..f3a7ba0476 100644
--- a/doc/classes/Rect2i.xml
+++ b/doc/classes/Rect2i.xml
@@ -46,7 +46,129 @@
Constructs a new [Rect2i] from [Rect2]. The floating point coordinates will be truncated.
</description>
</method>
+ <method name="abs">
+ <return type="Rect2i">
+ </return>
+ <description>
+ Returns a [Rect2i] with equivalent position and area, modified so that the top-left corner is the origin and [code]width[/code] and [code]height[/code] are positive.
+ </description>
+ </method>
+ <method name="clip">
+ <return type="Rect2i">
+ </return>
+ <argument index="0" name="b" type="Rect2i">
+ </argument>
+ <description>
+ Returns the intersection of this [Rect2i] and b.
+ </description>
+ </method>
+ <method name="encloses">
+ <return type="bool">
+ </return>
+ <argument index="0" name="b" type="Rect2i">
+ </argument>
+ <description>
+ Returns [code]true[/code] if this [Rect2i] completely encloses another one.
+ </description>
+ </method>
+ <method name="expand">
+ <return type="Rect2i">
+ </return>
+ <argument index="0" name="to" type="Vector2i">
+ </argument>
+ <description>
+ Returns this [Rect2i] expanded to include a given point.
+ </description>
+ </method>
+ <method name="get_area">
+ <return type="int">
+ </return>
+ <description>
+ Returns the area of the [Rect2i].
+ </description>
+ </method>
+ <method name="grow">
+ <return type="Rect2i">
+ </return>
+ <argument index="0" name="by" type="int">
+ </argument>
+ <description>
+ Returns a copy of the [Rect2i] grown a given amount of units towards all the sides.
+ </description>
+ </method>
+ <method name="grow_individual">
+ <return type="Rect2i">
+ </return>
+ <argument index="0" name="left" type="int">
+ </argument>
+ <argument index="1" name="top" type="int">
+ </argument>
+ <argument index="2" name="right" type="int">
+ </argument>
+ <argument index="3" name=" bottom" type="int">
+ </argument>
+ <description>
+ Returns a copy of the [Rect2i] grown a given amount of units towards each direction individually.
+ </description>
+ </method>
+ <method name="grow_margin">
+ <return type="Rect2i">
+ </return>
+ <argument index="0" name="margin" type="int">
+ </argument>
+ <argument index="1" name="by" type="int">
+ </argument>
+ <description>
+ Returns a copy of the [Rect2i] grown a given amount of units towards the [enum Margin] direction.
+ </description>
+ </method>
+ <method name="has_no_area">
+ <return type="bool">
+ </return>
+ <description>
+ Returns [code]true[/code] if the [Rect2i] is flat or empty.
+ </description>
+ </method>
+ <method name="has_point">
+ <return type="bool">
+ </return>
+ <argument index="0" name="point" type="Vector2i">
+ </argument>
+ <description>
+ Returns [code]true[/code] if the [Rect2i] contains a point.
+ </description>
+ </method>
+ <method name="intersects">
+ <return type="bool">
+ </return>
+ <argument index="0" name="b" type="Rect2i">
+ </argument>
+ <description>
+ Returns [code]true[/code] if the [Rect2i] overlaps with [code]b[/code] (i.e. they have at least one point in common).
+ If [code]include_borders[/code] is [code]true[/code], they will also be considered overlapping if their borders touch, even without intersection.
+ </description>
+ </method>
+ <method name="merge">
+ <return type="Rect2i">
+ </return>
+ <argument index="0" name="b" type="Rect2i">
+ </argument>
+ <description>
+ Returns a larger [Rect2i] that contains this [Rect2i] and [code]b[/code].
+ </description>
+ </method>
</methods>
+ <members>
+ <member name="end" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )">
+ Ending corner.
+ </member>
+ <member name="position" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )">
+ Position (starting corner).
+ </member>
+ <member name="size" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )">
+ Size from position to end.
+ </member>
+ </members>
<constants>
</constants>
</class>
diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml
index d8be6d4bd7..516a16e053 100644
--- a/doc/classes/RenderingServer.xml
+++ b/doc/classes/RenderingServer.xml
@@ -17,6 +17,11 @@
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/optimization/using_servers.html</link>
</tutorials>
+ <members>
+ <member name="render_loop_enabled" type="bool" setter="set_render_loop_enabled" getter="is_render_loop_enabled" default="true">
+ If [code]false[/code], disables rendering completely, but the engine logic is still being processed. You can call [method force_draw] to draw a frame even with rendering disabled.
+ </member>
+ </members>
<methods>
<method name="black_bars_set_images">
<return type="void">
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index efc0c9d600..db036d7d88 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -20,8 +20,10 @@
</argument>
<argument index="2" name="height" type="int" default="0">
</argument>
+ <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ </argument>
<description>
- Adds an image's opening and closing tags to the tag stack, optionally providing a [code]width[/code] and [code]height[/code] to resize the image.
+ Adds an image's opening and closing tags to the tag stack, optionally providing a [code]width[/code] and [code]height[/code] to resize the image and a [code]color[/code] to tint the image.
If [code]width[/code] or [code]height[/code] is set to 0, the image size will be adjusted in order to keep the original aspect ratio.
</description>
</method>
diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml
index 8379fc5b58..a3fd2e81fd 100644
--- a/doc/classes/RigidBody2D.xml
+++ b/doc/classes/RigidBody2D.xml
@@ -127,7 +127,7 @@
The body's total applied torque.
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true">
- If [code]true[/code], the body will not calculate forces and will act as a static body if there is no movement. The body will wake up when other forces are applied via collisions or by using [method apply_impulse] or [method add_force].
+ If [code]true[/code], the body can enter sleep mode when there is no movement. See [member sleeping].
</member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false">
If [code]true[/code], the body will emit signals when it collides with another RigidBody2D. See also [member contacts_reported].
@@ -165,7 +165,7 @@
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
</member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping" default="false">
- If [code]true[/code], the body is sleeping and will not calculate forces until woken up by a collision or by using [method apply_impulse] or [method add_force].
+ If [code]true[/code], the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the [method apply_impulse] or [method add_force] methods.
</member>
<member name="weight" type="float" setter="set_weight" getter="get_weight" default="9.8">
The body's weight based on its mass and the [b]Default Gravity[/b] value in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b].
@@ -214,7 +214,8 @@
</signal>
<signal name="sleeping_state_changed">
<description>
- Emitted when [member sleeping] changes.
+ Emitted when the physics engine changes the body's sleeping state.
+ [b]Note:[/b] Changing the value [member sleeping] will not trigger this signal. It is only emitted if the sleeping state is changed by the physics engine or [code]emit_signal("sleeping_state_changed")[/code] is used.
</description>
</signal>
</signals>
diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml
index 1db818d6af..063cc3ca59 100644
--- a/doc/classes/RigidBody3D.xml
+++ b/doc/classes/RigidBody3D.xml
@@ -147,7 +147,7 @@
Lock the body's movement in the Z axis.
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true">
- If [code]true[/code], the body is deactivated when there is no movement, so it will not take part in the simulation until it is awaken by an external force.
+ If [code]true[/code], the body can enter sleep mode when there is no movement. See [member sleeping].
</member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false">
If [code]true[/code], the RigidBody3D will emit signals when it collides with another RigidBody3D.
@@ -182,7 +182,7 @@
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
</member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping" default="false">
- If [code]true[/code], the body is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method.
+ If [code]true[/code], the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the [method apply_impulse] or [method add_force] methods.
</member>
<member name="weight" type="float" setter="set_weight" getter="get_weight" default="9.8">
The body's weight based on its mass and the global 3D gravity. Global values are set in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b].
@@ -233,7 +233,8 @@
</signal>
<signal name="sleeping_state_changed">
<description>
- Emitted when the body changes its sleeping state. Either by sleeping or waking up.
+ Emitted when the physics engine changes the body's sleeping state.
+ [b]Note:[/b] Changing the value [member sleeping] will not trigger this signal. It is only emitted if the sleeping state is changed by the physics engine or [code]emit_signal("sleeping_state_changed")[/code] is used.
</description>
</signal>
</signals>
diff --git a/doc/classes/Shape2D.xml b/doc/classes/Shape2D.xml
index 9e913cb44d..5f41d05816 100644
--- a/doc/classes/Shape2D.xml
+++ b/doc/classes/Shape2D.xml
@@ -74,6 +74,17 @@
This method needs the transformation matrix for this shape ([code]local_xform[/code]), the movement to test on this shape ([code]local_motion[/code]), the shape to check collisions with ([code]with_shape[/code]), the transformation matrix of that shape ([code]shape_xform[/code]), and the movement to test onto the other object ([code]shape_motion[/code]).
</description>
</method>
+ <method name="draw">
+ <return type="void">
+ </return>
+ <argument index="0" name="canvas_item" type="RID">
+ </argument>
+ <argument index="1" name="color" type="Color">
+ </argument>
+ <description>
+ Draws a solid shape onto a [CanvasItem] with the [RenderingServer] API filled with the specified [code]color[/code]. The exact drawing method is specific for each shape and cannot be configured.
+ </description>
+ </method>
</methods>
<members>
<member name="custom_solver_bias" type="float" setter="set_custom_solver_bias" getter="get_custom_solver_bias" default="0.0">
diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml
index 4460b519fc..183fd5396f 100644
--- a/doc/classes/Skeleton3D.xml
+++ b/doc/classes/Skeleton3D.xml
@@ -31,6 +31,16 @@
[i]Deprecated soon.[/i]
</description>
</method>
+ <method name="bone_transform_to_world_transform">
+ <return type="Transform">
+ </return>
+ <argument index="0" name="bone_transform" type="Transform">
+ </argument>
+ <description>
+ Takes the given bone pose/transform and converts it to a world transform, relative to the [Skeleton3D] node.
+ This is useful for using the bone transform in calculations with transforms from [Node3D]-based nodes.
+ </description>
+ </method>
<method name="clear_bones">
<return type="void">
</return>
@@ -42,6 +52,7 @@
<return type="void">
</return>
<description>
+ Removes the global pose override on all bones in the skeleton.
</description>
</method>
<method name="find_bone" qualifiers="const">
@@ -106,6 +117,12 @@
Returns the pose transform of the specified bone. Pose is applied on top of the custom pose, which is applied on top the rest pose.
</description>
</method>
+ <method name="get_bone_process_orders">
+ <return type="PackedInt32Array">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_bone_rest" qualifiers="const">
<return type="Transform">
</return>
@@ -130,12 +147,14 @@
<argument index="0" name="bone_idx" type="int">
</argument>
<description>
+ Returns whether the bone rest for the bone at [code]bone_idx[/code] is disabled.
</description>
</method>
<method name="localize_rests">
<return type="void">
</return>
<description>
+ Returns all bones in the skeleton to their rest poses.
</description>
</method>
<method name="physical_bones_add_collision_exception">
@@ -144,6 +163,8 @@
<argument index="0" name="exception" type="RID">
</argument>
<description>
+ Adds a collision exception to the physical bone.
+ Works just like the [RigidBody3D] node.
</description>
</method>
<method name="physical_bones_remove_collision_exception">
@@ -152,6 +173,8 @@
<argument index="0" name="exception" type="RID">
</argument>
<description>
+ Removes a collision exception to the physical bone.
+ Works just like the [RigidBody3D] node.
</description>
</method>
<method name="physical_bones_start_simulation">
@@ -160,12 +183,15 @@
<argument index="0" name="bones" type="StringName[]" default="[ ]">
</argument>
<description>
+ Tells the [PhysicalBone3D] nodes in the Skeleton to start simulating and reacting to the physics world.
+ Optionally, a list of bone names can be passed-in, allowing only the passed-in bones to be simulated.
</description>
</method>
<method name="physical_bones_stop_simulation">
<return type="void">
</return>
<description>
+ Tells the [PhysicalBone3D] nodes in the Skeleton to stop simulating.
</description>
</method>
<method name="register_skin">
@@ -174,6 +200,7 @@
<argument index="0" name="skin" type="Skin">
</argument>
<description>
+ Binds the given Skin to the Skeleton.
</description>
</method>
<method name="set_bone_custom_pose">
@@ -184,6 +211,8 @@
<argument index="1" name="custom_pose" type="Transform">
</argument>
<description>
+ Sets the custom pose transform, [code]custom_pose[/code], for the bone at [code]bone_idx[/code]. This pose is an addition to the bone rest pose.
+ [b]Note[/b]: The pose transform needs to be in bone space. Use [method world_transform_to_bone_transform] to convert a world transform, like one you can get from a [Node3D], to bone space.
</description>
</method>
<method name="set_bone_disable_rest">
@@ -194,6 +223,7 @@
<argument index="1" name="disable" type="bool">
</argument>
<description>
+ Disables the rest pose for the bone at [code]bone_idx[/code] if [code]true[/code], enables the bone rest if [code]false[/code].
</description>
</method>
<method name="set_bone_global_pose_override">
@@ -208,6 +238,9 @@
<argument index="3" name="persistent" type="bool" default="false">
</argument>
<description>
+ Sets the global pose transform, [code]pose[/code], for the bone at [code]bone_idx[/code].
+ [code]amount[/code] is the interpolation strengh that will be used when applying the pose, and [code]persistent[/code] determines if the applied pose will remain.
+ [b]Note[/b]: The pose transform needs to be in bone space. Use [method world_transform_to_bone_transform] to convert a world transform, like one you can get from a [Node3D], to bone space.
</description>
</method>
<method name="set_bone_parent">
@@ -231,6 +264,7 @@
</argument>
<description>
Returns the pose transform for bone [code]bone_idx[/code].
+ [b]Note[/b]: The pose transform needs to be in bone space. Use [method world_transform_to_bone_transform] to convert a world transform, like one you can get from a [Node3D], to bone space.
</description>
</method>
<method name="set_bone_rest">
@@ -261,6 +295,17 @@
<argument index="0" name="bone_idx" type="int">
</argument>
<description>
+ Unparents the bone at [code]bone_idx[/code] and sets its rest position to that of it's parent prior to being reset.
+ </description>
+ </method>
+ <method name="world_transform_to_bone_transform">
+ <return type="Transform">
+ </return>
+ <argument index="0" name="world_transform" type="Transform">
+ </argument>
+ <description>
+ Takes the given world transform, relative to the [Skeleton3D], and converts it to a bone pose/transform.
+ This is useful for using setting bone poses using transforms from [Node3D]-based nodes.
</description>
</method>
</methods>
@@ -268,6 +313,12 @@
<member name="animate_physical_bones" type="bool" setter="set_animate_physical_bones" getter="get_animate_physical_bones" default="true">
</member>
</members>
+ <signals>
+ <signal name="pose_updated">
+ <description>
+ </description>
+ </signal>
+ </signals>
<constants>
<constant name="NOTIFICATION_UPDATE_SKELETON" value="50">
</constant>
diff --git a/doc/classes/SpotLight3D.xml b/doc/classes/SpotLight3D.xml
index f094818c21..d8d82a6852 100644
--- a/doc/classes/SpotLight3D.xml
+++ b/doc/classes/SpotLight3D.xml
@@ -22,7 +22,7 @@
The spotlight's light energy attenuation curve.
</member>
<member name="spot_range" type="float" setter="set_param" getter="get_param" default="5.0">
- The maximal range that can be reached by the spotlight.
+ The maximal range that can be reached by the spotlight. Note that the effectively lit area may appear to be smaller depending on the [member spot_attenuation] in use. No matter the [member spot_attenuation] in use, the light will never reach anything outside this range.
</member>
</members>
<constants>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 0dd6923129..24d92b822a 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -412,7 +412,13 @@
<argument index="1" name="from" type="int" default="0">
</argument>
<description>
- Finds the first occurrence of a substring. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
+ Finds the first occurrence of a substring. Returns the starting position of the substring or [code]-1[/code] if not found. Optionally, the initial search index can be passed.
+ [b]Note:[/b] If you just want to know whether a string contains a substring, use the [code]in[/code] operator as follows:
+ [codeblock]
+ # Will evaluate to `false`.
+ if "i" in "team":
+ pass
+ [/codeblock]
</description>
</method>
<method name="find_last">
@@ -421,7 +427,7 @@
<argument index="0" name="what" type="String">
</argument>
<description>
- Finds the last occurrence of a substring. Returns the starting position of the substring or -1 if not found.
+ Finds the last occurrence of a substring. Returns the starting position of the substring or [code]-1[/code] if not found.
</description>
</method>
<method name="findn">
@@ -432,7 +438,7 @@
<argument index="1" name="from" type="int" default="0">
</argument>
<description>
- Finds the first occurrence of a substring, ignoring case. Returns the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
+ Finds the first occurrence of a substring, ignoring case. Returns the starting position of the substring or [code]-1[/code] if not found. Optionally, the initial search index can be passed.
</description>
</method>
<method name="format">
@@ -947,7 +953,7 @@
<argument index="1" name="len" type="int" default="-1">
</argument>
<description>
- Returns part of the string from the position [code]from[/code] with length [code]len[/code]. Argument [code]len[/code] is optional and using -1 will return remaining characters from given position.
+ Returns part of the string from the position [code]from[/code] with length [code]len[/code]. Argument [code]len[/code] is optional and using [code]-1[/code] will return remaining characters from given position.
</description>
</method>
<method name="to_ascii">
diff --git a/doc/classes/SubViewportContainer.xml b/doc/classes/SubViewportContainer.xml
index e6a0bd4866..16d483e7f8 100644
--- a/doc/classes/SubViewportContainer.xml
+++ b/doc/classes/SubViewportContainer.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
A [Container] node that holds a [SubViewport], automatically setting its size.
+ [b]Note:[/b] Changing a SubViewportContainer's [member Control.rect_scale] will cause its contents to appear distorted. To change its visual size without causing distortion, adjust the node's margins instead (if it's not already in a container).
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml
index 22e92ae5d9..d56781105b 100644
--- a/doc/classes/TabContainer.xml
+++ b/doc/classes/TabContainer.xml
@@ -204,8 +204,8 @@
<theme_item name="font_color_fg" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
Font color of the currently selected tab.
</theme_item>
- <theme_item name="hseparation" type="int" default="4">
- Horizontal separation between tabs.
+ <theme_item name="icon_separation" type="int" default="4">
+ Space between tab's name and its icon.
</theme_item>
<theme_item name="increment" type="Texture2D">
Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent.
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index e553518b39..0c6615c53b 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -299,7 +299,7 @@
</description>
</method>
<method name="search" qualifiers="const">
- <return type="PackedInt32Array">
+ <return type="Dictionary">
</return>
<argument index="0" name="key" type="String">
</argument>
@@ -311,13 +311,13 @@
</argument>
<description>
Perform a search inside the text. Search flags can be specified in the [enum SearchFlags] enum.
- Returns an empty [code]PackedInt32Array[/code] if no result was found. Otherwise, the result line and column can be accessed at indices specified in the [enum SearchResult] enum, e.g:
+ Returns an empty [code]Dictionary[/code] if no result was found. Otherwise, returns a [code]Dictionary[/code] containing [code]line[/code] and [code]column[/code] entries, e.g:
[codeblock]
var result = search(key, flags, line, column)
- if result.size() &gt; 0:
+ if !result.empty():
# Result found.
- var res_line = result[TextEdit.SEARCH_RESULT_LINE]
- var res_column = result[TextEdit.SEARCH_RESULT_COLUMN]
+ var line_number = result.line
+ var column_number = result.column
[/codeblock]
</description>
</method>
@@ -536,12 +536,6 @@
<constant name="SEARCH_BACKWARDS" value="4" enum="SearchFlags">
Search from end to beginning.
</constant>
- <constant name="SEARCH_RESULT_COLUMN" value="0" enum="SearchResult">
- Used to access the result column from [method search].
- </constant>
- <constant name="SEARCH_RESULT_LINE" value="1" enum="SearchResult">
- Used to access the result line from [method search].
- </constant>
<constant name="MENU_CUT" value="0" enum="MenuItems">
Cuts (copies and clears) the selected text.
</constant>
diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml
index c647f83598..9a78e45d46 100644
--- a/doc/classes/TileSet.xml
+++ b/doc/classes/TileSet.xml
@@ -44,6 +44,8 @@
<argument index="1" name="neighbor_id" type="int">
</argument>
<description>
+ Determines when the auto-tiler should consider two different auto-tile IDs to be bound together.
+ [b]Note:[/b] [code]neighbor_id[/code] will be [code]-1[/code] ([constant TileMap.INVALID_CELL]) when checking a tile against an empty neighbor tile.
</description>
</method>
<method name="autotile_clear_bitmask_map">
diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml
index a516eb01dd..71c7aaa4e5 100644
--- a/doc/classes/Vector2i.xml
+++ b/doc/classes/Vector2i.xml
@@ -31,7 +31,36 @@
Constructs a new [Vector2i] from [Vector2]. The floating point coordinates will be truncated.
</description>
</method>
+ <method name="abs">
+ <return type="Vector2i">
+ </return>
+ <description>
+ Returns a new vector with all components in absolute values (i.e. positive).
+ </description>
+ </method>
+ <method name="aspect">
+ <return type="float">
+ </return>
+ <description>
+ Returns the ratio of [member x] to [member y].
+ </description>
+ </method>
+ <method name="sign">
+ <return type="Vector2i">
+ </return>
+ <description>
+ Returns the vector with each component set to one or negative one, depending on the signs of the components.
+ </description>
+ </method>
</methods>
+ <members>
+ <member name="x" type="int" setter="" getter="" default="0">
+ The vector's X component. Also accessible by using the index position [code][0][/code].
+ </member>
+ <member name="y" type="int" setter="" getter="" default="0">
+ The vector's Y component. Also accessible by using the index position [code][1][/code].
+ </member>
+ </members>
<constants>
<constant name="AXIS_X" value="0">
Enumerated value for the X axis.
diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml
index 4f5a658b89..c5aa3d0347 100644
--- a/doc/classes/Vector3i.xml
+++ b/doc/classes/Vector3i.xml
@@ -33,7 +33,39 @@
Constructs a new [Vector3i] from [Vector3]. The floating point coordinates will be truncated.
</description>
</method>
+ <method name="max_axis">
+ <return type="int">
+ </return>
+ <description>
+ Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants.
+ </description>
+ </method>
+ <method name="min_axis">
+ <return type="int">
+ </return>
+ <description>
+ Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants.
+ </description>
+ </method>
+ <method name="sign">
+ <return type="Vector3i">
+ </return>
+ <description>
+ Returns the vector with each component set to one or negative one, depending on the signs of the components.
+ </description>
+ </method>
</methods>
+ <members>
+ <member name="x" type="int" setter="" getter="" default="0">
+ The vector's X component. Also accessible by using the index position [code][0][/code].
+ </member>
+ <member name="y" type="int" setter="" getter="" default="0">
+ The vector's Y component. Also accessible by using the index position [code][1][/code].
+ </member>
+ <member name="z" type="int" setter="" getter="" default="0">
+ The vector's Z component. Also accessible by using the index position [code][2][/code].
+ </member>
+ </members>
<constants>
<constant name="AXIS_X" value="0">
Enumerated value for the X axis.
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index a14ef7c665..c0bba38799 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -287,6 +287,8 @@ def main(): # type: () -> None
)
args = parser.parse_args()
+ print("Checking for errors in the XML class reference...")
+
file_list = [] # type: List[str]
for path in args.path:
@@ -345,7 +347,10 @@ def main(): # type: () -> None
state.current_class = class_name
make_rst_class(class_def, state, args.dry_run, args.output)
- if state.errored:
+ if not state.errored:
+ print("No errors found.")
+ else:
+ print("Errors were found in the class reference XML. Please check the messages above.")
exit(1)
@@ -561,71 +566,6 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
index += 1
-def make_class_list(class_list, columns): # type: (List[str], int) -> None
- # This function is no longer used.
- f = open("class_list.rst", "w", encoding="utf-8")
- col_max = len(class_list) // columns + 1
- print(("col max is ", col_max))
- fit_columns = [] # type: List[List[str]]
-
- for _ in range(0, columns):
- fit_columns.append([])
-
- indexers = [] # type List[str]
- last_initial = ""
-
- for idx, name in enumerate(class_list):
- col = idx // col_max
- if col >= columns:
- col = columns - 1
- fit_columns[col].append(name)
- idx += 1
- if name[:1] != last_initial:
- indexers.append(name)
- last_initial = name[:1]
-
- row_max = 0
- f.write("\n")
-
- for n in range(0, columns):
- if len(fit_columns[n]) > row_max:
- row_max = len(fit_columns[n])
-
- f.write("| ")
- for n in range(0, columns):
- f.write(" | |")
-
- f.write("\n")
- f.write("+")
- for n in range(0, columns):
- f.write("--+-------+")
- f.write("\n")
-
- for r in range(0, row_max):
- s = "+ "
- for c in range(0, columns):
- if r >= len(fit_columns[c]):
- continue
-
- classname = fit_columns[c][r]
- initial = classname[0]
- if classname in indexers:
- s += "**" + initial + "** | "
- else:
- s += " | "
-
- s += "[" + classname + "](class_" + classname.lower() + ") | "
-
- s += "\n"
- f.write(s)
-
- for n in range(0, columns):
- f.write("--+-------+")
- f.write("\n")
-
- f.close()
-
-
def escape_rst(text, until_pos=-1): # type: (str) -> str
# Escape \ character, otherwise it ends up as an escape character in rst
pos = 0
diff --git a/doc/translations/classes.pot b/doc/translations/classes.pot
index 28db7e4e04..c18fecc6f8 100644
--- a/doc/translations/classes.pot
+++ b/doc/translations/classes.pot
@@ -35842,7 +35842,7 @@ msgstr ""
#: doc/classes/PhysicsServer2D.xml:888
msgid ""
-"Sets a damped spring joint parameter. See [enum DampedStringParam] for a "
+"Sets a damped spring joint parameter. See [enum DampedSpringParam] for a "
"list of available parameters."
msgstr ""
diff --git a/doc/translations/fr.po b/doc/translations/fr.po
index 57466d0b04..8010437cf7 100644
--- a/doc/translations/fr.po
+++ b/doc/translations/fr.po
@@ -35852,7 +35852,7 @@ msgstr ""
#: doc/classes/PhysicsServer2D.xml:888
msgid ""
-"Sets a damped spring joint parameter. See [enum DampedStringParam] for a "
+"Sets a damped spring joint parameter. See [enum DampedSpringParam] for a "
"list of available parameters."
msgstr ""
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index 48e694dd3a..90c3d3af83 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -38,7 +38,7 @@
#include <errno.h>
Error AudioDriverALSA::init_device() {
- mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
@@ -104,7 +104,7 @@ Error AudioDriverALSA::init_device() {
// In ALSA the period size seems to be the one that will determine the actual latency
// Ref: https://www.alsa-project.org/main/index.php/FramesPeriods
unsigned int periods = 2;
- int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+ int latency = GLOBAL_GET("audio/output_latency");
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
buffer_size = buffer_frames * periods;
period_size = buffer_frames;
@@ -147,7 +147,6 @@ Error AudioDriverALSA::init_device() {
}
Error AudioDriverALSA::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
@@ -161,11 +160,9 @@ Error AudioDriverALSA::init() {
}
void AudioDriverALSA::thread_func(void *p_udata) {
-
AudioDriverALSA *ad = (AudioDriverALSA *)p_udata;
while (!ad->exit_thread) {
-
ad->lock();
ad->start_counting_ticks();
@@ -237,30 +234,27 @@ void AudioDriverALSA::thread_func(void *p_udata) {
}
void AudioDriverALSA::start() {
-
active = true;
}
int AudioDriverALSA::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const {
-
return speaker_mode;
}
Array AudioDriverALSA::get_device_list() {
-
Array list;
list.push_back("Default");
void **hints;
- if (snd_device_name_hint(-1, "pcm", &hints) < 0)
+ if (snd_device_name_hint(-1, "pcm", &hints) < 0) {
return list;
+ }
for (void **n = hints; *n != nullptr; n++) {
char *name = snd_device_name_get_hint(*n, "NAME");
@@ -274,10 +268,12 @@ Array AudioDriverALSA::get_device_list() {
}
}
- if (desc != nullptr)
+ if (desc != nullptr) {
free(desc);
- if (name != nullptr)
+ }
+ if (name != nullptr) {
free(name);
+ }
}
snd_device_name_free_hint(hints);
@@ -285,33 +281,30 @@ Array AudioDriverALSA::get_device_list() {
}
String AudioDriverALSA::get_device() {
-
return device_name;
}
void AudioDriverALSA::set_device(String device) {
-
lock();
new_device = device;
unlock();
}
void AudioDriverALSA::lock() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
mutex.lock();
}
void AudioDriverALSA::unlock() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
mutex.unlock();
}
void AudioDriverALSA::finish_device() {
-
if (pcm_handle) {
snd_pcm_close(pcm_handle);
pcm_handle = nullptr;
@@ -319,7 +312,6 @@ void AudioDriverALSA::finish_device() {
}
void AudioDriverALSA::finish() {
-
if (thread) {
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -331,14 +323,4 @@ void AudioDriverALSA::finish() {
finish_device();
}
-AudioDriverALSA::AudioDriverALSA() :
- thread(nullptr),
- pcm_handle(nullptr),
- device_name("Default"),
- new_device("Default") {
-}
-
-AudioDriverALSA::~AudioDriverALSA() {
-}
-
-#endif
+#endif // ALSA_ENABLED
diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h
index 50bd9e853d..7aec0c4071 100644
--- a/drivers/alsa/audio_driver_alsa.h
+++ b/drivers/alsa/audio_driver_alsa.h
@@ -40,14 +40,13 @@
#include <alsa/asoundlib.h>
class AudioDriverALSA : public AudioDriver {
-
- Thread *thread;
+ Thread *thread = nullptr;
Mutex mutex;
- snd_pcm_t *pcm_handle;
+ snd_pcm_t *pcm_handle = nullptr;
- String device_name;
- String new_device;
+ String device_name = "Default";
+ String new_device = "Default";
Vector<int32_t> samples_in;
Vector<int16_t> samples_out;
@@ -85,8 +84,8 @@ public:
virtual void unlock();
virtual void finish();
- AudioDriverALSA();
- ~AudioDriverALSA();
+ AudioDriverALSA() {}
+ ~AudioDriverALSA() {}
};
#endif // AUDIO_DRIVER_ALSA_H
diff --git a/drivers/alsamidi/midi_driver_alsamidi.cpp b/drivers/alsamidi/midi_driver_alsamidi.cpp
index e3e54ea267..69a6956c2b 100644
--- a/drivers/alsamidi/midi_driver_alsamidi.cpp
+++ b/drivers/alsamidi/midi_driver_alsamidi.cpp
@@ -125,11 +125,11 @@ void MIDIDriverALSAMidi::thread_func(void *p_udata) {
}
Error MIDIDriverALSAMidi::open() {
-
void **hints;
- if (snd_device_name_hint(-1, "rawmidi", &hints) < 0)
+ if (snd_device_name_hint(-1, "rawmidi", &hints) < 0) {
return ERR_CANT_OPEN;
+ }
int i = 0;
for (void **n = hints; *n != nullptr; n++) {
@@ -143,8 +143,9 @@ Error MIDIDriverALSAMidi::open() {
}
}
- if (name != nullptr)
+ if (name != nullptr) {
free(name);
+ }
}
snd_device_name_free_hint(hints);
@@ -155,7 +156,6 @@ Error MIDIDriverALSAMidi::open() {
}
void MIDIDriverALSAMidi::close() {
-
if (thread) {
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -172,17 +172,14 @@ void MIDIDriverALSAMidi::close() {
}
void MIDIDriverALSAMidi::lock() const {
-
mutex.lock();
}
void MIDIDriverALSAMidi::unlock() const {
-
mutex.unlock();
}
PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() {
-
PackedStringArray list;
lock();
@@ -201,14 +198,12 @@ PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() {
}
MIDIDriverALSAMidi::MIDIDriverALSAMidi() {
-
thread = nullptr;
exit_thread = false;
}
MIDIDriverALSAMidi::~MIDIDriverALSAMidi() {
-
close();
}
diff --git a/drivers/alsamidi/midi_driver_alsamidi.h b/drivers/alsamidi/midi_driver_alsamidi.h
index 6797c7c138..e8ed6df5b0 100644
--- a/drivers/alsamidi/midi_driver_alsamidi.h
+++ b/drivers/alsamidi/midi_driver_alsamidi.h
@@ -42,7 +42,6 @@
#include <stdio.h>
class MIDIDriverALSAMidi : public MIDIDriver {
-
Thread *thread;
Mutex mutex;
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 21c3649445..48d0a29516 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -116,7 +116,7 @@ Error AudioDriverCoreAudio::init() {
break;
}
- mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
zeromem(&strdesc, sizeof(strdesc));
strdesc.mFormatID = kAudioFormatLinearPCM;
@@ -131,7 +131,7 @@ Error AudioDriverCoreAudio::init() {
result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &strdesc, sizeof(strdesc));
ERR_FAIL_COND_V(result != noErr, FAILED);
- int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+ int latency = GLOBAL_GET("audio/output_latency");
// Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels)
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
@@ -168,7 +168,6 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData) {
-
AudioDriverCoreAudio *ad = (AudioDriverCoreAudio *)inRefCon;
if (!ad->active || !ad->try_lock()) {
@@ -182,18 +181,15 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
ad->start_counting_ticks();
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
-
AudioBuffer *abuf = &ioData->mBuffers[i];
unsigned int frames_left = inNumberFrames;
int16_t *out = (int16_t *)abuf->mData;
while (frames_left) {
-
unsigned int frames = MIN(frames_left, ad->buffer_frames);
ad->audio_server_process(frames, ad->samples_in.ptrw());
for (unsigned int j = 0; j < frames * ad->channels; j++) {
-
out[j] = ad->samples_in[j] >> 16;
}
@@ -213,7 +209,6 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData) {
-
AudioDriverCoreAudio *ad = (AudioDriverCoreAudio *)inRefCon;
if (!ad->active) {
return 0;
@@ -408,7 +403,7 @@ Error AudioDriverCoreAudio::capture_init() {
break;
}
- mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
zeromem(&strdesc, sizeof(strdesc));
strdesc.mFormatID = kAudioFormatLinearPCM;
@@ -475,7 +470,6 @@ void AudioDriverCoreAudio::capture_finish() {
}
Error AudioDriverCoreAudio::capture_start() {
-
input_buffer_init(buffer_frames);
OSStatus result = AudioOutputUnitStart(input_unit);
@@ -487,7 +481,6 @@ Error AudioDriverCoreAudio::capture_start() {
}
Error AudioDriverCoreAudio::capture_stop() {
-
if (input_unit) {
OSStatus result = AudioOutputUnitStop(input_unit);
if (result != noErr) {
@@ -501,7 +494,6 @@ Error AudioDriverCoreAudio::capture_stop() {
#ifdef OSX_ENABLED
Array AudioDriverCoreAudio::_get_device_list(bool capture) {
-
Array list;
list.push_back("Default");
@@ -558,7 +550,6 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
}
void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
-
AudioDeviceID deviceId;
bool found = false;
if (device != "Default") {
@@ -639,17 +630,14 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
Array AudioDriverCoreAudio::get_device_list() {
-
return _get_device_list();
}
String AudioDriverCoreAudio::get_device() {
-
return device_name;
}
void AudioDriverCoreAudio::set_device(String device) {
-
device_name = device;
if (active) {
_set_device(device_name);
@@ -657,7 +645,6 @@ void AudioDriverCoreAudio::set_device(String device) {
}
void AudioDriverCoreAudio::capture_set_device(const String &p_name) {
-
capture_device_name = p_name;
if (active) {
_set_device(capture_device_name, true);
@@ -665,30 +652,17 @@ void AudioDriverCoreAudio::capture_set_device(const String &p_name) {
}
Array AudioDriverCoreAudio::capture_get_device_list() {
-
return _get_device_list(true);
}
String AudioDriverCoreAudio::capture_get_device() {
-
return capture_device_name;
}
#endif
-AudioDriverCoreAudio::AudioDriverCoreAudio() :
- audio_unit(nullptr),
- input_unit(nullptr),
- active(false),
- device_name("Default"),
- capture_device_name("Default"),
- mix_rate(0),
- channels(2),
- capture_channels(2),
- buffer_frames(0) {
+AudioDriverCoreAudio::AudioDriverCoreAudio() {
samples_in.clear();
}
-AudioDriverCoreAudio::~AudioDriverCoreAudio(){};
-
-#endif
+#endif // COREAUDIO_ENABLED
diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h
index fb9473e230..6b7a35588f 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -41,20 +41,19 @@
#endif
class AudioDriverCoreAudio : public AudioDriver {
+ AudioComponentInstance audio_unit = nullptr;
+ AudioComponentInstance input_unit = nullptr;
- AudioComponentInstance audio_unit;
- AudioComponentInstance input_unit;
-
- bool active;
+ bool active = false;
Mutex mutex;
- String device_name;
- String capture_device_name;
+ String device_name = "Default";
+ String capture_device_name = "Default";
- int mix_rate;
- unsigned int channels;
- unsigned int capture_channels;
- unsigned int buffer_frames;
+ int mix_rate = 0;
+ unsigned int channels = 2;
+ unsigned int capture_channels = 2;
+ unsigned int buffer_frames = 0;
Vector<int32_t> samples_in;
Vector<int16_t> input_buf;
@@ -118,7 +117,7 @@ public:
#endif
AudioDriverCoreAudio();
- ~AudioDriverCoreAudio();
+ ~AudioDriverCoreAudio() {}
};
#endif
diff --git a/drivers/coremidi/midi_driver_coremidi.cpp b/drivers/coremidi/midi_driver_coremidi.cpp
index 2cd322813b..004c594e17 100644
--- a/drivers/coremidi/midi_driver_coremidi.cpp
+++ b/drivers/coremidi/midi_driver_coremidi.cpp
@@ -46,7 +46,6 @@ void MIDIDriverCoreMidi::read(const MIDIPacketList *packet_list, void *read_proc
}
Error MIDIDriverCoreMidi::open() {
-
CFStringRef name = CFStringCreateWithCString(nullptr, "Godot", kCFStringEncodingASCII);
OSStatus result = MIDIClientCreate(name, nullptr, nullptr, &client);
CFRelease(name);
@@ -63,7 +62,6 @@ Error MIDIDriverCoreMidi::open() {
int sources = MIDIGetNumberOfSources();
for (int i = 0; i < sources; i++) {
-
MIDIEndpointRef source = MIDIGetSource(i);
if (source) {
MIDIPortConnectSource(port_in, source, (void *)this);
@@ -75,7 +73,6 @@ Error MIDIDriverCoreMidi::open() {
}
void MIDIDriverCoreMidi::close() {
-
for (int i = 0; i < connected_sources.size(); i++) {
MIDIEndpointRef source = connected_sources[i];
MIDIPortDisconnectSource(port_in, source);
@@ -94,7 +91,6 @@ void MIDIDriverCoreMidi::close() {
}
PackedStringArray MIDIDriverCoreMidi::get_connected_inputs() {
-
PackedStringArray list;
for (int i = 0; i < connected_sources.size(); i++) {
@@ -112,9 +108,7 @@ PackedStringArray MIDIDriverCoreMidi::get_connected_inputs() {
return list;
}
-MIDIDriverCoreMidi::MIDIDriverCoreMidi() :
- client(0) {
-}
+MIDIDriverCoreMidi::MIDIDriverCoreMidi() {}
MIDIDriverCoreMidi::~MIDIDriverCoreMidi() {
close();
diff --git a/drivers/coremidi/midi_driver_coremidi.h b/drivers/coremidi/midi_driver_coremidi.h
index e8b4481c20..0459544f75 100644
--- a/drivers/coremidi/midi_driver_coremidi.h
+++ b/drivers/coremidi/midi_driver_coremidi.h
@@ -40,8 +40,7 @@
#include <stdio.h>
class MIDIDriverCoreMidi : public MIDIDriver {
-
- MIDIClientRef client;
+ MIDIClientRef client = 0;
MIDIPortRef port_in;
Vector<MIDIEndpointRef> connected_sources;
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h
index 05a45315b2..7af7678f63 100644
--- a/drivers/dummy/rasterizer_dummy.h
+++ b/drivers/dummy/rasterizer_dummy.h
@@ -855,13 +855,19 @@ public:
}
bool free(RID p_rid) {
-
if (texture_owner.owns(p_rid)) {
// delete the texture
DummyTexture *texture = texture_owner.getornull(p_rid);
texture_owner.free(p_rid);
memdelete(texture);
}
+
+ if (mesh_owner.owns(p_rid)) {
+ // delete the mesh
+ DummyMesh *mesh = mesh_owner.getornull(p_rid);
+ mesh_owner.free(p_rid);
+ memdelete(mesh);
+ }
return true;
}
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index 069eeaba6c..c92eb4cd11 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -40,7 +40,6 @@
#endif
RID RasterizerCanvasGLES2::light_internal_create() {
-
return RID();
}
@@ -51,7 +50,6 @@ void RasterizerCanvasGLES2::light_internal_free(RID p_rid) {
}
void RasterizerCanvasGLES2::_set_uniforms() {
-
state.canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, state.uniforms.projection_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
state.canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, state.uniforms.extra_matrix);
@@ -75,7 +73,6 @@ void RasterizerCanvasGLES2::_set_uniforms() {
}
if (state.using_light) {
-
Light *light = state.using_light;
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX, light->light_shader_xform);
Transform2D basis_inverse = light->light_shader_xform.affine_inverse().orthonormalized();
@@ -110,7 +107,6 @@ void RasterizerCanvasGLES2::_set_uniforms() {
}
void RasterizerCanvasGLES2::canvas_begin() {
-
state.canvas_shader.bind();
state.using_transparent_rt = false;
int viewport_x, viewport_y, viewport_width, viewport_height;
@@ -160,7 +156,6 @@ void RasterizerCanvasGLES2::canvas_begin() {
Transform canvas_transform;
if (storage->frame.current_rt) {
-
float csy = 1.0;
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP]) {
csy = -1.0;
@@ -185,7 +180,6 @@ void RasterizerCanvasGLES2::canvas_begin() {
}
void RasterizerCanvasGLES2::canvas_end() {
-
glBindBuffer(GL_ARRAY_BUFFER, 0);
for (int i = 0; i < RS::ARRAY_MAX; i++) {
@@ -207,11 +201,9 @@ void RasterizerCanvasGLES2::canvas_end() {
}
RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
-
RasterizerStorageGLES2::Texture *tex_return = nullptr;
if (p_texture.is_valid()) {
-
RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(p_texture);
if (!texture) {
@@ -222,7 +214,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
} else {
-
if (texture->redraw_if_visible) {
RenderingServerRaster::redraw_request();
}
@@ -254,7 +245,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
} else if (p_normal_map.is_valid()) {
-
RasterizerStorageGLES2::Texture *normal_map = storage->texture_owner.getornull(p_normal_map);
if (!normal_map) {
@@ -264,7 +254,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, false);
} else {
-
if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies
RenderingServerRaster::redraw_request();
}
@@ -278,7 +267,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
}
} else {
-
state.current_normal = RID();
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
@@ -289,7 +277,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con
}
void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
-
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
@@ -365,7 +352,6 @@ void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_coun
}
void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
-
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
@@ -407,7 +393,6 @@ void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count
}
void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
-
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
#ifndef GLES_OVER_GL
// Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData
@@ -467,7 +452,6 @@ void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int
}
void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) {
-
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
int color_offset = 0;
@@ -542,18 +526,14 @@ static const GLenum gl_primitive[] = {
};
void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip, RasterizerStorageGLES2::Material *p_material) {
-
int command_count = p_item->commands.size();
Item::Command **commands = p_item->commands.ptrw();
for (int i = 0; i < command_count; i++) {
-
Item::Command *command = commands[i];
switch (command->type) {
-
case Item::Command::TYPE_LINE: {
-
Item::CommandLine *line = static_cast<Item::CommandLine *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -613,7 +593,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_RECT: {
-
Item::CommandRect *r = static_cast<Item::CommandRect *>(command);
glDisableVertexAttribArray(RS::ARRAY_COLOR);
@@ -626,7 +605,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(r->texture);
if (texture) {
-
texture = texture->get_ptr();
if (next_power_of_2(texture->alloc_width) != (unsigned int)texture->alloc_width && next_power_of_2(texture->alloc_height) != (unsigned int)texture->alloc_height) {
@@ -750,7 +728,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} else {
-
bool untile = false;
if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RS::TEXTURE_FLAG_REPEAT)) {
@@ -807,7 +784,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_NINEPATCH: {
-
Item::CommandNinePatch *np = static_cast<Item::CommandNinePatch *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -845,7 +821,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
float screen_scale = 1.0;
if (source.size.x != 0 && source.size.y != 0) {
-
screen_scale = MIN(np->rect.size.x / source.size.x, np->rect.size.y / source.size.y);
screen_scale = MIN(1.0, screen_scale);
}
@@ -857,7 +832,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
float buffer[16 * 2 + 16 * 2];
{
-
// first row
buffer[(0 * 4 * 4) + 0] = np->rect.position.x;
@@ -982,7 +956,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_CIRCLE: {
-
Item::CommandCircle *circle = static_cast<Item::CommandCircle *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1012,7 +985,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_POLYGON: {
-
Item::CommandPolygon *polygon = static_cast<Item::CommandPolygon *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1043,7 +1015,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
#endif
} break;
case Item::Command::TYPE_MESH: {
-
Item::CommandMesh *mesh = static_cast<Item::CommandMesh *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1061,7 +1032,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
RasterizerStorageGLES2::Mesh *mesh_data = storage->mesh_owner.getornull(mesh->mesh);
if (mesh_data) {
-
for (int j = 0; j < mesh_data->surfaces.size(); j++) {
RasterizerStorageGLES2::Surface *s = mesh_data->surfaces[j];
// materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
@@ -1186,7 +1156,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
const float *buffer = base_buffer + k * stride;
{
-
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]);
if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) {
@@ -1252,7 +1221,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
glDisable(GL_LINE_SMOOTH);
#endif
} else {
-
#ifdef GLES_OVER_GL
if (pline->antialiased)
glEnable(GL_LINE_SMOOTH);
@@ -1281,7 +1249,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_PRIMITIVE: {
-
Item::CommandPrimitive *primitive = static_cast<Item::CommandPrimitive *>(command);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false);
@@ -1316,11 +1283,9 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
} break;
case Item::Command::TYPE_PARTICLES: {
-
} break;
case Item::Command::TYPE_CLIP_IGNORE: {
-
Item::CommandClipIgnore *ci = static_cast<Item::CommandClipIgnore *>(command);
if (current_clip) {
if (ci->ignore != reclip) {
@@ -1356,7 +1321,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
}
void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
-
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen.");
return;
@@ -1412,7 +1376,6 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
}
void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) {
-
state.canvas_texscreen_used = true;
_copy_screen(p_rect);
@@ -1425,7 +1388,6 @@ void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) {
}
void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) {
-
Item *current_clip = nullptr;
RasterizerStorageGLES2::Shader *shader_cache = nullptr;
@@ -1447,11 +1409,9 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
RID canvas_last_material = RID();
while (p_item_list) {
-
Item *ci = p_item_list;
if (current_clip != ci->final_clip_owner) {
-
current_clip = ci->final_clip_owner;
if (current_clip) {
@@ -1512,7 +1472,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
RasterizerStorageGLES2::Material *material_ptr = storage->material_owner.getornull(material);
if (material != canvas_last_material || rebind_shader) {
-
RasterizerStorageGLES2::Shader *shader_ptr = nullptr;
if (material_ptr) {
@@ -1540,7 +1499,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (shader_ptr != shader_cache) {
-
if (shader_ptr->canvas_item.uses_time) {
RenderingServerRaster::redraw_request();
}
@@ -1555,13 +1513,11 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = shader_ptr->texture_hints.ptrw();
for (int i = 0; i < tc; i++) {
-
glActiveTexture(GL_TEXTURE0 + i);
RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(textures[i].second);
if (!t) {
-
switch (texture_hints[i]) {
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO:
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
@@ -1616,9 +1572,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
bool reclip = false;
if (last_blend_mode != blend_mode) {
-
switch (blend_mode) {
-
case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_MIX: {
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
@@ -1629,7 +1583,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
} break;
case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_ADD: {
-
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
@@ -1639,7 +1592,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
} break;
case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_SUB: {
-
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE);
@@ -1679,24 +1631,19 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
rebind_shader = true; // hacked in for now.
if ((blend_mode == RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_PMALPHA) && p_light && !unshaded) {
-
Light *light = p_light;
bool light_used = false;
RS::CanvasLightMode mode = RS::CANVAS_LIGHT_MODE_ADD;
state.uniforms.final_modulate = ci->final_modulate; // remove the canvas modulate
while (light) {
-
if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) {
-
//intersects this light
if (!light_used || mode != light->mode) {
-
mode = light->mode;
switch (mode) {
-
case RS::CANVAS_LIGHT_MODE_ADD: {
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
@@ -1716,7 +1663,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (!light_used) {
-
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, true);
light_used = true;
}
@@ -1762,7 +1708,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
}
if (light_used) {
-
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, false);
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, false);
state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, false);
@@ -1824,7 +1769,6 @@ void RasterizerCanvasGLES2::canvas_debug_viewport_shadows(Light *p_lights_with_s
}
void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
-
RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(p_buffer);
ERR_FAIL_COND(!cls);
@@ -1849,7 +1793,6 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
RS::CanvasOccluderPolygonCullMode cull = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
for (int i = 0; i < 4; i++) {
-
//make sure it remains orthogonal, makes easy to read angle later
Transform light;
@@ -1893,10 +1836,8 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
LightOccluderInstance *instance = p_occluders;
while (instance) {
-
RasterizerStorageGLES2::CanvasOccluder *cc = storage->canvas_occluder_owner.getornull(instance->polygon_buffer);
if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) {
-
instance = instance->next;
continue;
}
@@ -1914,21 +1855,17 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
}
if (cull != transformed_cull_cache) {
-
cull = transformed_cull_cache;
switch (cull) {
case RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
-
glDisable(GL_CULL_FACE);
} break;
case RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: {
-
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
} break;
case RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: {
-
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -1950,8 +1887,8 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
-void RasterizerCanvasGLES2::reset_canvas() {
+void RasterizerCanvasGLES2::reset_canvas() {
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
@@ -1982,8 +1919,8 @@ void RasterizerCanvasGLES2::_bind_quad_buffer() {
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
}
-void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
+void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
state.canvas_shader.set_uniform(CanvasShaderGLES2::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES2::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
@@ -2028,7 +1965,6 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float
}
void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_image) {
-
Vector2 window_size = DisplayServer::get_singleton()->window_get_size();
int window_h = window_size.height;
int window_w = window_size.width;
@@ -2073,14 +2009,12 @@ void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_im
}
if (black_image[MARGIN_BOTTOM].is_valid()) {
-
_bind_canvas_texture(black_image[MARGIN_BOTTOM], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM]));
draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y));
} else if (black_margin[MARGIN_BOTTOM]) {
-
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
@@ -2091,7 +2025,6 @@ void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_im
}
void RasterizerCanvasGLES2::initialize() {
-
// quad buffer
{
glGenBuffers(1, &data.canvas_quad_vertices);
diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h
index 2d6355e948..84452fe220 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.h
+++ b/drivers/gles2/rasterizer_canvas_gles2.h
@@ -59,7 +59,6 @@ public:
};
struct Data {
-
GLuint canvas_quad_vertices;
GLuint polygon_buffer;
GLuint polygon_index_buffer;
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 28f06f939c..fc9f3c67e6 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -86,7 +86,6 @@
#ifdef CAN_DEBUG
static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) {
-
if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
return;
@@ -145,22 +144,18 @@ typedef void (*DEBUGPROCARB)(GLenum source,
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
RasterizerStorage *RasterizerGLES2::get_storage() {
-
return storage;
}
RasterizerCanvas *RasterizerGLES2::get_canvas() {
-
return canvas;
}
RasterizerScene *RasterizerGLES2::get_scene() {
-
return scene;
}
Error RasterizerGLES2::is_viable() {
-
#ifdef GLAD_ENABLED
if (!gladLoadGL()) {
ERR_PRINT("Error initializing GLAD");
@@ -214,7 +209,6 @@ Error RasterizerGLES2::is_viable() {
}
void RasterizerGLES2::initialize() {
-
print_verbose("Using GLES2 video driver");
#ifdef GLAD_ENABLED
@@ -253,7 +247,6 @@ void RasterizerGLES2::initialize() {
}
if (callback) {
-
print_line("godot: ENABLING GL DEBUG");
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
callback(_gl_debug_print, nullptr);
@@ -296,7 +289,6 @@ void RasterizerGLES2::begin_frame(double frame_step) {
}
void RasterizerGLES2::set_current_render_target(RID p_render_target) {
-
if (!p_render_target.is_valid() && storage->frame.current_rt && storage->frame.clear_request) {
// pending clear request. Do that first.
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
@@ -337,7 +329,6 @@ void RasterizerGLES2::clear_render_target(const Color &p_color) {
}
void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
-
if (p_image.is_null() || p_image->empty())
return;
@@ -364,7 +355,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height());
Rect2 screenrect;
if (p_scale) {
-
if (window_w > window_h) {
//scale horizontally
screenrect.size.y = window_h;
@@ -378,7 +368,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
screenrect.position.y = (window_h - screenrect.size.y) / 2;
}
} else {
-
screenrect = imgrect;
screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
}
@@ -396,7 +385,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
}
void RasterizerGLES2::blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen) {
-
ERR_FAIL_COND(storage->frame.current_rt);
RasterizerStorageGLES2::RenderTarget *rt = storage->render_target_owner.getornull(p_render_target);
@@ -446,7 +434,6 @@ void RasterizerGLES2::output_lens_distorted_to_screen(RID p_render_target, const
}
void RasterizerGLES2::end_frame(bool p_swap_buffers) {
-
if (OS::get_singleton()->is_layered_allowed()) {
if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) {
#if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED)
@@ -478,7 +465,6 @@ void RasterizerGLES2::finalize() {
}
Rasterizer *RasterizerGLES2::_create_current() {
-
return memnew(RasterizerGLES2);
}
@@ -490,7 +476,6 @@ void RasterizerGLES2::register_config() {
}
RasterizerGLES2::RasterizerGLES2() {
-
storage = memnew(RasterizerStorageGLES2);
canvas = memnew(RasterizerCanvasGLES2);
scene = memnew(RasterizerSceneGLES2);
@@ -504,7 +489,6 @@ RasterizerGLES2::RasterizerGLES2() {
}
RasterizerGLES2::~RasterizerGLES2() {
-
memdelete(storage);
memdelete(canvas);
}
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 027a634ae8..e9bef31d1e 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -37,7 +37,6 @@
#include "servers/rendering/rasterizer.h"
class RasterizerGLES2 : public Rasterizer {
-
static Rasterizer *_create_current();
RasterizerStorageGLES2 *storage;
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index bdf0559f58..c66506f182 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -72,7 +72,6 @@ static const GLenum _cube_side_enum[6] = {
/* SHADOW ATLAS API */
RID RasterizerSceneGLES2::shadow_atlas_create() {
-
ShadowAtlas *shadow_atlas = memnew(ShadowAtlas);
shadow_atlas->fbo = 0;
shadow_atlas->depth = 0;
@@ -133,7 +132,6 @@ void RasterizerSceneGLES2::shadow_atlas_set_size(RID p_atlas, int p_size) {
glActiveTexture(GL_TEXTURE0);
if (storage->config.use_rgba_3d_shadows) {
-
//maximum compatibility, renderbuffer and RGBA shadow
glGenRenderbuffers(1, &shadow_atlas->depth);
glBindRenderbuffer(GL_RENDERBUFFER, shadow_atlas->depth);
@@ -234,7 +232,6 @@ void RasterizerSceneGLES2::shadow_atlas_set_quadrant_subdivision(RID p_atlas, in
}
bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_in_quadrants, int p_quadrant_count, int p_current_subdiv, uint64_t p_tick, int &r_quadrant, int &r_shadow) {
-
for (int i = p_quadrant_count - 1; i >= 0; i--) {
int qidx = p_in_quadrants[i];
@@ -262,7 +259,6 @@ bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
ERR_CONTINUE(!sli);
if (sli->last_scene_pass != scene_pass) {
-
// was just allocated, don't kill it so soon, wait a bit...
if (p_tick - sarr[j].alloc_tick < shadow_atlas_realloc_tolerance_msec) {
@@ -294,7 +290,6 @@ bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
}
bool RasterizerSceneGLES2::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
ERR_FAIL_COND_V(!shadow_atlas, false);
@@ -441,7 +436,6 @@ void RasterizerSceneGLES2::set_directional_shadow_count(int p_count) {
}
int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance) {
-
ERR_FAIL_COND_V(directional_shadow.light_count == 0, 0);
int shadow_size;
@@ -466,6 +460,7 @@ int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance)
return shadow_size;
}
+
//////////////////////////////////////////////////////
RID RasterizerSceneGLES2::reflection_atlas_create() {
@@ -481,7 +476,6 @@ void RasterizerSceneGLES2::reflection_atlas_set_subdivision(RID p_ref_atlas, int
////////////////////////////////////////////////////
RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
-
RasterizerStorageGLES2::ReflectionProbe *probe = storage->reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!probe, RID());
@@ -512,7 +506,6 @@ RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
}
void RasterizerSceneGLES2::reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND(!rpi);
rpi->transform = p_transform;
@@ -535,14 +528,12 @@ bool RasterizerSceneGLES2::reflection_probe_instance_has_reflection(RID p_instan
}
bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
rpi->render_step = 0;
if (rpi->probe_ptr->resolution != rpi->current_resolution) {
-
//update cubemap if resolution changed
int size = rpi->probe_ptr->resolution;
rpi->current_resolution = size;
@@ -594,7 +585,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance
}
bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_instance) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
ERR_FAIL_COND_V(rpi->current_resolution == 0, false);
@@ -643,7 +633,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
//blur
while (size >= 1) {
-
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, storage->resources.mipmap_blur_color);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
@@ -652,7 +641,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
glActiveTexture(GL_TEXTURE0);
for (int i = 0; i < 6; i++) {
-
storage->bind_quad_array();
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i);
float roughness = CLAMP(lod / (float)(mipmaps - 1), 0, 1);
@@ -684,14 +672,12 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst
/* ENVIRONMENT API */
RID RasterizerSceneGLES2::environment_create() {
-
Environment *env = memnew(Environment);
return environment_owner.make_rid(env);
}
void RasterizerSceneGLES2::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->bg_mode = p_bg;
@@ -756,7 +742,6 @@ void RasterizerSceneGLES2::environment_set_camera_feed_id(RID p_env, int p_camer
}
void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -768,7 +753,6 @@ void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable
}
void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -780,7 +764,6 @@ void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enabl
}
void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -817,7 +800,6 @@ void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, RS::EnvironmentTon
}
void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -829,7 +811,6 @@ void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable,
}
void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -840,7 +821,6 @@ void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const C
}
void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -853,7 +833,6 @@ void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, f
}
void RasterizerSceneGLES2::environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {
-
Environment *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -862,6 +841,7 @@ void RasterizerSceneGLES2::environment_set_fog_height(RID p_env, bool p_enable,
env->fog_height_max = p_max_height;
env->fog_height_curve = p_height_curve;
}
+
bool RasterizerSceneGLES2::is_environment(RID p_env) {
return environment_owner.owns(p_env);
}
@@ -881,7 +861,6 @@ int RasterizerSceneGLES2::environment_get_canvas_max_layer(RID p_env) {
}
RID RasterizerSceneGLES2::light_instance_create(RID p_light) {
-
LightInstance *light_instance = memnew(LightInstance);
light_instance->last_scene_pass = 0;
@@ -902,7 +881,6 @@ RID RasterizerSceneGLES2::light_instance_create(RID p_light) {
}
void RasterizerSceneGLES2::light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -910,7 +888,6 @@ void RasterizerSceneGLES2::light_instance_set_transform(RID p_light_instance, co
}
void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -928,7 +905,6 @@ void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_insta
}
void RasterizerSceneGLES2::light_instance_mark_visible(RID p_light_instance) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -938,12 +914,12 @@ void RasterizerSceneGLES2::light_instance_mark_visible(RID p_light_instance) {
//////////////////////
RID RasterizerSceneGLES2::gi_probe_instance_create() {
-
return RID();
}
void RasterizerSceneGLES2::gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) {
}
+
void RasterizerSceneGLES2::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {
}
@@ -955,7 +931,6 @@ void RasterizerSceneGLES2::gi_probe_instance_set_bounds(RID p_probe, const Vecto
////////////////////////////
void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass) {
-
RasterizerStorageGLES2::Material *material = nullptr;
RID material_src;
@@ -993,8 +968,8 @@ void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geo
_add_geometry_with_material(p_geometry, p_instance, p_owner, material, p_depth_pass, p_shadow_pass);
}
}
-void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
+void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass) {
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture || p_material->shader->spatial.uses_depth_texture;
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_MIX;
bool has_alpha = has_base_alpha || has_blend_alpha;
@@ -1016,7 +991,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
}
if (p_depth_pass) {
-
if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
return; //bye
@@ -1077,7 +1051,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
e->refprobe_1_index = RenderList::MAX_REFLECTION_PROBES; //refprobe disabled by default
if (!p_depth_pass) {
-
e->depth_layer = e->instance->depth_layer;
e->priority = p_material->render_priority;
@@ -1119,11 +1092,9 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
if (p_material->shader->spatial.unshaded) {
e->light_mode = LIGHTMODE_UNSHADED;
} else {
-
bool copy = false;
for (int i = 0; i < render_directional_lights; i++) {
-
if (copy) {
RenderList::Element *e2 = has_alpha ? render_list.add_alpha_element() : render_list.add_element();
if (!e2) {
@@ -1144,7 +1115,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
//add omni / spots
for (int i = 0; i < e->instance->light_instances.size(); i++) {
-
LightInstance *li = light_instance_owner.getornull(e->instance->light_instances[i]);
if (!li || li->light_index >= render_light_instance_count || render_light_instances[li->light_index] != li) {
@@ -1186,7 +1156,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
}
void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer) {
-
//copy to front buffer
glBindFramebuffer(GL_FRAMEBUFFER, p_buffer);
@@ -1210,7 +1179,6 @@ void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_bu
}
void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass) {
-
render_pass++;
current_material_index = 0;
current_geometry_index = 0;
@@ -1219,13 +1187,10 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
current_shader_index = 0;
for (int i = 0; i < p_cull_count; i++) {
-
InstanceBase *instance = p_cull_result[i];
switch (instance->base_type) {
-
case RS::INSTANCE_MESH: {
-
RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getornull(instance->base);
ERR_CONTINUE(!mesh);
@@ -1285,7 +1250,6 @@ static const GLenum gl_primitive[] = {
};
void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_reverse_cull) {
-
bool front = p_front;
if (p_reverse_cull)
front = !front;
@@ -1300,14 +1264,12 @@ void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_rever
}
if (front != state.cull_front) {
-
glCullFace(front ? GL_FRONT : GL_BACK);
state.cull_front = front;
}
}
bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_material, bool p_alpha_pass, Size2i p_skeleton_tex_size) {
-
// material parameters
state.scene_shader.set_custom_shader(p_material->shader->custom_code_id);
@@ -1333,7 +1295,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
switch (p_material->shader->spatial.depth_draw_mode) {
case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS:
case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_OPAQUE: {
-
glDepthMask(!p_alpha_pass && !p_material->shader->spatial.uses_depth_texture);
} break;
case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALWAYS: {
@@ -1355,20 +1316,17 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
state.current_main_tex = 0;
for (int i = 0; i < tc; i++) {
-
glActiveTexture(GL_TEXTURE0 + i);
RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(textures[i].second);
if (!t) {
-
GLenum target = GL_TEXTURE_2D;
GLuint tex = 0;
switch (texture_types[i]) {
case ShaderLanguage::TYPE_ISAMPLER2D:
case ShaderLanguage::TYPE_USAMPLER2D:
case ShaderLanguage::TYPE_SAMPLER2D: {
-
switch (texture_hints[i]) {
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO:
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
@@ -1394,7 +1352,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
case ShaderLanguage::TYPE_ISAMPLER3D:
case ShaderLanguage::TYPE_USAMPLER3D:
case ShaderLanguage::TYPE_SAMPLER3D: {
-
target = GL_TEXTURE_3D;
tex = storage->resources.white_tex_3d;
@@ -1407,7 +1364,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY:
case ShaderLanguage::TYPE_SAMPLER2DARRAY: {
-
target = GL_TEXTURE_2D_ARRAY;
tex = storage->resources.white_tex_array;
@@ -1456,9 +1412,7 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m
}
void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, RasterizerStorageGLES2::Skeleton *p_skeleton) {
-
switch (p_element->instance->base_type) {
-
case RS::INSTANCE_MESH: {
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
@@ -1491,7 +1445,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
bool clear_skeleton_buffer = storage->config.use_skeleton_software;
if (p_skeleton) {
-
if (!storage->config.use_skeleton_software) {
//use float texture workflow
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1);
@@ -1524,7 +1477,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
const uint8_t *vertex_data = vertex_array_read.ptr();
for (int i = 0; i < s->array_len; i++) {
-
// do magic
size_t bones[4];
@@ -1613,7 +1565,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
}
if (clear_skeleton_buffer) {
-
glDisableVertexAttribArray(INSTANCE_BONE_BASE + 0);
glDisableVertexAttribArray(INSTANCE_BONE_BASE + 1);
glDisableVertexAttribArray(INSTANCE_BONE_BASE + 2);
@@ -1671,11 +1622,8 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
}
void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
-
switch (p_element->instance->base_type) {
-
case RS::INSTANCE_MESH: {
-
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
// drawing
@@ -1704,7 +1652,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
} break;
case RS::INSTANCE_MULTIMESH: {
-
RasterizerStorageGLES2::MultiMesh *multi_mesh = static_cast<RasterizerStorageGLES2::MultiMesh *>(p_element->owner);
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);
@@ -1727,7 +1674,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
const float *buffer = base_buffer + i * stride;
{
-
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]);
glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 2, &buffer[8]);
@@ -1809,7 +1755,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
glBindTexture(t->target, t->tex_id);
restore_tex = true;
} else if (restore_tex) {
-
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, state.current_main_tex);
restore_tex = false;
@@ -1880,7 +1825,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
}
void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas *shadow_atlas) {
-
//turn off all by default
state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTING, false);
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, false);
@@ -1902,7 +1846,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
switch (p_light->light_ptr->type) {
case RS::LIGHT_DIRECTIONAL: {
-
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_DIRECTIONAL, true);
switch (p_light->light_ptr->directional_shadow_mode) {
case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: {
@@ -1932,7 +1875,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
} break;
case RS::LIGHT_OMNI: {
-
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_OMNI, true);
if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, true);
@@ -1947,7 +1889,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
}
} break;
case RS::LIGHT_SPOT: {
-
state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_SPOT, true);
if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, true);
@@ -1965,7 +1906,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
}
void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform, bool accum_pass) {
-
RasterizerStorageGLES2::Light *light_ptr = light->light_ptr;
//common parameters
@@ -1990,7 +1930,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
CameraMatrix matrices[4];
if (!state.render_no_shadows && light_ptr->shadow && directional_shadow.depth) {
-
int shadow_count = 0;
Color split_offsets;
@@ -2009,14 +1948,12 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
for (int k = 0; k < shadow_count; k++) {
-
uint32_t x = light->directional_rect.position.x;
uint32_t y = light->directional_rect.position.y;
uint32_t width = light->directional_rect.size.x;
uint32_t height = light->directional_rect.size.y;
if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
-
width /= 2;
height /= 2;
@@ -2030,7 +1967,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
} else if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
-
height /= 2;
if (k != 0) {
@@ -2068,7 +2004,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
} break;
case RS::LIGHT_OMNI: {
-
Vector3 position = p_view_transform.xform_inv(light->transform.origin);
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position);
@@ -2080,7 +2015,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation);
if (!state.render_no_shadows && light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(light->self)) {
-
uint32_t key = shadow_atlas->shadow_owners[light->self];
uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x03;
@@ -2122,7 +2056,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
} break;
case RS::LIGHT_SPOT: {
-
Vector3 position = p_view_transform.xform_inv(light->transform.origin);
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position);
@@ -2191,7 +2124,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
}
void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform, Environment *p_env) {
-
if (p_refprobe1) {
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_USE_BOX_PROJECT, p_refprobe1->probe_ptr->box_projection);
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_BOX_EXTENTS, p_refprobe1->probe_ptr->extents);
@@ -2240,7 +2172,6 @@ void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1
}
void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, RID p_shadow_atlas, Environment *p_env, GLuint p_base_env, float p_shadow_bias, float p_shadow_normal_bias, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
Vector2 viewport_size = state.viewport_size;
@@ -2323,7 +2254,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
bool rebind_lightmap = false;
if (!p_shadow && material->shader) {
-
bool unshaded = material->shader->spatial.unshaded;
if (unshaded != prev_unshaded) {
@@ -2353,7 +2283,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (light != prev_light) {
-
_setup_light_type(light, shadow_atlas);
rebind = true;
rebind_light = true;
@@ -2369,7 +2298,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (prev_blend_mode != blend_mode) {
-
if (prev_blend_mode == -1 && blend_mode != -1) {
//does blend
glEnable(GL_BLEND);
@@ -2390,13 +2318,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
} break;
case RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_ADD: {
-
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(p_alpha_pass ? GL_SRC_ALPHA : GL_ONE, GL_ONE);
} break;
case RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_SUB: {
-
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
} break;
@@ -2449,13 +2375,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
use_lightmap_capture = !unshaded && !accum_pass && !e->instance->lightmap_capture_data.empty();
if (use_lightmap_capture != prev_use_lightmap_capture) {
-
state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP_CAPTURE, use_lightmap_capture);
rebind = true;
}
if (!unshaded && !accum_pass && e->instance->lightmap.is_valid()) {
-
lightmap = storage->texture_owner.getornull(e->instance->lightmap);
lightmap_energy = 1.0;
if (lightmap) {
@@ -2484,7 +2408,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
}
if (depth_prepass != prev_depth_prepass) {
-
state.scene_shader.set_conditional(SceneShaderGLES2::USE_DEPTH_PREPASS, depth_prepass);
prev_depth_prepass = depth_prepass;
rebind = true;
@@ -2493,7 +2416,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
bool instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH;
if (instancing != prev_instancing) {
-
state.scene_shader.set_conditional(SceneShaderGLES2::USE_INSTANCING, instancing);
rebind = true;
}
@@ -2520,7 +2442,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
bool shader_rebind = false;
if (rebind || material != prev_material) {
-
storage->info.render.material_switch_count++;
shader_rebind = _setup_material(material, p_alpha_pass, Size2i(skeleton ? skeleton->size * 3 : 0, 0));
if (shader_rebind) {
@@ -2572,7 +2493,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
rebind_lightmap = true;
if (using_fog) {
-
state.scene_shader.set_uniform(SceneShaderGLES2::FOG_COLOR_BASE, p_env->fog_color);
Color sun_color_amount = p_env->fog_sun_color;
sun_color_amount.a = p_env->fog_sun_amount;
@@ -2679,7 +2599,6 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
CameraMatrix camera;
if (p_custom_fov) {
-
float near_plane = p_projection.get_z_near();
float far_plane = p_projection.get_z_far();
float aspect = p_projection.get_aspect();
@@ -2763,7 +2682,6 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
}
void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p_cam_projection) {
-
//copy to front buffer
glDepthMask(GL_FALSE);
@@ -2839,7 +2757,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
// DOF Blur
if (env->dof_blur_far_enabled) {
-
int vp_h = storage->frame.current_rt->height;
int vp_w = storage->frame.current_rt->width;
@@ -2896,7 +2813,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
if (env->dof_blur_near_enabled) {
-
//convert texture to RGBA format if not already
if (!storage->frame.current_rt->used_dof_blur_near) {
glActiveTexture(GL_TEXTURE0);
@@ -3002,10 +2918,8 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
int glow_mask = 0;
if (env->glow_enabled) {
-
for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) {
if (env->glow_levels & (1 << i)) {
-
if (i >= storage->frame.current_rt->mip_maps[1].sizes.size()) {
max_glow_level = storage->frame.current_rt->mip_maps[1].sizes.size() - 1;
glow_mask |= 1 << max_glow_level;
@@ -3018,7 +2932,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
for (int i = 0; i < (max_glow_level + 1); i++) {
-
int vp_w = storage->frame.current_rt->mip_maps[1].sizes[i].width;
int vp_h = storage->frame.current_rt->mip_maps[1].sizes[i].height;
glViewport(0, 0, vp_w, vp_h);
@@ -3043,7 +2956,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
if (i == 0) {
-
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_BLOOM, env->glow_bloom);
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_THRESHOLD, env->glow_hdr_bleed_threshold);
state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_SCALE, env->glow_hdr_bleed_scale);
@@ -3094,7 +3006,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
if (max_glow_level >= 0) {
if (storage->frame.current_rt->mip_maps[0].color) {
for (int i = 0; i < (max_glow_level + 1); i++) {
-
if (glow_mask & (1 << i)) {
if (i == 0) {
state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL1, true);
@@ -3122,11 +3033,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color);
} else {
-
state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_MULTI_TEXTURE_GLOW, true);
int active_glow_level = 0;
for (int i = 0; i < (max_glow_level + 1); i++) {
-
if (glow_mask & (1 << i)) {
active_glow_level++;
glActiveTexture(GL_TEXTURE0 + active_glow_level);
@@ -3163,7 +3072,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
//Adjustments
if (env->adjustments_enabled) {
-
state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_BCS, true);
RasterizerStorageGLES2::Texture *tex = storage->texture_owner.getornull(env->color_correction);
if (tex) {
@@ -3176,7 +3084,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
state.tonemap_shader.bind();
if (max_glow_level >= 0) {
-
state.tonemap_shader.set_uniform(TonemapShaderGLES2::GLOW_INTENSITY, env->glow_intensity);
int ss[2] = {
storage->frame.current_rt->width,
@@ -3186,7 +3093,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
if (env->adjustments_enabled) {
-
state.tonemap_shader.set_uniform(TonemapShaderGLES2::BCS, Vector3(env->adjustments_brightness, env->adjustments_contrast, env->adjustments_saturation));
}
@@ -3210,7 +3116,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
}
void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
-
Transform cam_transform = p_cam_transform;
storage->info.render.object_count += p_cull_count;
@@ -3306,7 +3211,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
}
if (p_reflection_probe_cull_count) {
-
reflection_probe_instances = (ReflectionProbeInstance **)alloca(sizeof(ReflectionProbeInstance *) * p_reflection_probe_cull_count);
reflection_probe_count = p_reflection_probe_cull_count;
for (int i = 0; i < p_reflection_probe_cull_count; i++) {
@@ -3339,7 +3243,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
glViewport(viewport_x, viewport_y, viewport_width, viewport_height);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
-
glScissor(viewport_x, viewport_y, viewport_width, viewport_height);
glEnable(GL_SCISSOR_TEST);
}
@@ -3395,7 +3298,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
GLuint env_radiance_tex = 0;
if (env) {
switch (env->bg_mode) {
-
case RS::ENV_BG_COLOR_SKY:
case RS::ENV_BG_SKY: {
sky = storage->sky_owner.getornull(env->sky);
@@ -3485,7 +3387,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
// then draw the sky after
if (env && env->bg_mode == RS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) {
-
if (sky && sky->panorama.is_valid()) {
_draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation);
}
@@ -3586,7 +3487,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
}
void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {
-
state.render_no_shadows = false;
LightInstance *light_instance = light_instance_owner.getornull(p_light);
@@ -3652,7 +3552,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
height = light_instance->directional_rect.size.height;
if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
-
width /= 2;
height /= 2;
@@ -3666,11 +3565,9 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
}
} else if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
-
height /= 2;
if (p_pass == 0) {
-
} else {
y += height;
}
@@ -3737,7 +3634,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
light_transform = light_instance->shadow_transform[0].transform;
if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) {
-
height /= 2;
y += p_pass * height;
} else {
@@ -3871,9 +3767,7 @@ void RasterizerSceneGLES2::set_scene_pass(uint64_t p_pass) {
}
bool RasterizerSceneGLES2::free(RID p_rid) {
-
if (light_instance_owner.owns(p_rid)) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_rid);
//remove from shadow atlases..
@@ -3892,13 +3786,11 @@ bool RasterizerSceneGLES2::free(RID p_rid) {
memdelete(light_instance);
} else if (shadow_atlas_owner.owns(p_rid)) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_rid);
shadow_atlas_set_size(p_rid, 0);
shadow_atlas_owner.free(p_rid);
memdelete(shadow_atlas);
} else if (reflection_probe_instance_owner.owns(p_rid)) {
-
ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.getornull(p_rid);
for (int i = 0; i < 6; i++) {
@@ -4000,7 +3892,6 @@ void RasterizerSceneGLES2::initialize() {
glActiveTexture(GL_TEXTURE0);
while (cube_size >= 32) {
-
ShadowCubeMap cube;
cube.size = cube_size;
@@ -4009,7 +3900,6 @@ void RasterizerSceneGLES2::initialize() {
glBindTexture(GL_TEXTURE_CUBE_MAP, cube.cubemap);
for (int i = 0; i < 6; i++) {
-
glTexImage2D(_cube_side_enum[i], 0, storage->config.depth_internalformat, cube_size, cube_size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, nullptr);
}
@@ -4021,7 +3911,6 @@ void RasterizerSceneGLES2::initialize() {
glGenFramebuffers(6, cube.fbo);
for (int i = 0; i < 6; i++) {
-
glBindFramebuffer(GL_FRAMEBUFFER, cube.fbo[i]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _cube_side_enum[i], cube.cubemap, 0);
}
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index 56c0e632c2..d017fc49a2 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -77,7 +77,6 @@ public:
RasterizerStorageGLES2 *storage;
struct State {
-
bool texscreen_copied;
int current_blend_mode;
float current_line_width;
@@ -195,7 +194,6 @@ public:
/* REFLECTION PROBE INSTANCE */
struct ReflectionProbeInstance {
-
RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
RID probe;
RID self;
@@ -387,7 +385,6 @@ public:
/* LIGHT INSTANCE */
struct LightInstance {
-
struct ShadowTransform {
CameraMatrix camera;
Transform transform;
@@ -449,7 +446,6 @@ public:
};
struct RenderList {
-
enum {
MAX_LIGHTS = 255,
MAX_REFLECTION_PROBES = 255,
@@ -534,7 +530,6 @@ public:
}
struct SortByDepth {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
return A->instance->depth < B->instance->depth;
}
@@ -551,7 +546,6 @@ public:
}
struct SortByReverseDepthAndPriority {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
if (A->priority == B->priority) {
return A->instance->depth > B->instance->depth;
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index b8c7815f6a..6eef04b87f 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -135,7 +135,6 @@ void RasterizerStorageGLES2::bind_quad_array() const {
}
Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const {
-
r_gl_format = 0;
Ref<Image> image = p_image;
r_compressed = false;
@@ -144,9 +143,7 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
bool need_decompress = false;
switch (p_format) {
-
case Image::FORMAT_L8: {
-
r_gl_internal_format = GL_LUMINANCE;
r_gl_format = GL_LUMINANCE;
r_gl_type = GL_UNSIGNED_BYTE;
@@ -157,7 +154,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
r_gl_type = GL_UNSIGNED_BYTE;
} break;
case Image::FORMAT_R8: {
-
r_gl_internal_format = GL_ALPHA;
r_gl_format = GL_ALPHA;
r_gl_type = GL_UNSIGNED_BYTE;
@@ -174,28 +170,24 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_RGB8: {
-
r_gl_internal_format = GL_RGB;
r_gl_format = GL_RGB;
r_gl_type = GL_UNSIGNED_BYTE;
} break;
case Image::FORMAT_RGBA8: {
-
r_gl_format = GL_RGBA;
r_gl_internal_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
} break;
case Image::FORMAT_RGBA4444: {
-
r_gl_internal_format = GL_RGBA;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_SHORT_4_4_4_4;
} break;
case Image::FORMAT_RGB565: {
-
r_gl_internal_format = GL_RGB5_A1;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_SHORT_5_5_5_1;
@@ -280,7 +272,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT1: {
-
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
r_gl_format = GL_RGBA;
@@ -292,7 +283,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT3: {
-
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT;
r_gl_format = GL_RGBA;
@@ -304,7 +294,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT5: {
-
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT;
r_gl_format = GL_RGBA;
@@ -316,134 +305,107 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_RGTC_R: {
-
if (config.rgtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RED_RGTC1_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_RGTC_RG: {
-
if (config.rgtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RED_GREEN_RGTC2_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_BPTC_RGBA: {
-
if (config.bptc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGBA_BPTC_UNORM;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_BPTC_RGBF: {
-
if (config.bptc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT;
r_gl_format = GL_RGB;
r_gl_type = GL_FLOAT;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_BPTC_RGBFU: {
if (config.bptc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT;
r_gl_format = GL_RGB;
r_gl_type = GL_FLOAT;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC2: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC2A: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC4: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_PVRTC4A: {
-
if (config.pvrtc_supported) {
-
r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
} else {
-
need_decompress = true;
}
} break;
case Image::FORMAT_ETC: {
-
if (config.etc1_supported) {
r_gl_internal_format = _EXT_ETC1_RGB8_OES;
r_gl_format = GL_RGBA;
@@ -454,43 +416,33 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
}
} break;
case Image::FORMAT_ETC2_R11: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_R11S: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RG11: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RG11S: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RGB8: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RGBA8: {
-
need_decompress = true;
} break;
case Image::FORMAT_ETC2_RGB8A1: {
-
need_decompress = true;
} break;
default: {
-
ERR_FAIL_V(Ref<Image>());
}
}
if (need_decompress || p_force_decompress) {
-
if (!image.is_null()) {
-
image = image->duplicate();
image->decompress();
ERR_FAIL_COND_V(image->is_compressed(), image);
@@ -539,7 +491,6 @@ static const GLenum _cube_side_enum[6] = {
};
RID RasterizerStorageGLES2::texture_create() {
-
Texture *texture = memnew(Texture);
ERR_FAIL_COND_V(!texture, RID());
glGenTextures(1, &texture->tex_id);
@@ -612,7 +563,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
bool is_po2 = p_width == po2_width && p_height == po2_height;
if (!is_po2 && (p_flags & RS::TEXTURE_FLAG_REPEAT || p_flags & RS::TEXTURE_FLAG_MIPMAPS)) {
-
if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
//not supported
ERR_PRINT("Streaming texture for non power of 2 or has mipmaps on this hardware: " + texture->path + "'. Mipmaps and repeat disabled.");
@@ -641,7 +591,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
#if defined(GLES_OVER_GL) || defined(ANDROID_ENABLED)
if ((p_type == RS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == RS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) {
-
int width = p_width;
int height = p_height;
int depth = p_depth_3d;
@@ -718,15 +667,12 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
}
if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) {
-
texture->alloc_height = MAX(1, texture->alloc_height / 2);
texture->alloc_width = MAX(1, texture->alloc_width / 2);
if (texture->alloc_width == img->get_width() / 2 && texture->alloc_height == img->get_height() / 2) {
-
img->shrink_x2();
} else if (img->get_format() <= Image::FORMAT_RGBA8) {
-
img->resize(texture->alloc_width, texture->alloc_height, Image::INTERPOLATE_BILINEAR);
}
}
@@ -769,16 +715,13 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
}
if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
} else {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
-
if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
@@ -787,7 +730,6 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
} else {
-
//glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@@ -801,11 +743,9 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
int tsize = 0;
for (int i = 0; i < mipmaps; i++) {
-
int size, ofs;
img->get_mipmap_offset_and_size(i, ofs, size);
if (texture->type == RS::TEXTURE_TYPE_2D || texture->type == RS::TEXTURE_TYPE_CUBEMAP) {
-
if (compressed) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
@@ -814,7 +754,6 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
glCompressedTexImage2D(blit_target, i, internal_format, bw, bh, 0, size, &read[ofs]);
} else {
-
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) {
glTexSubImage2D(blit_target, i, 0, 0, w, h, format, type, &read[ofs]);
@@ -868,7 +807,6 @@ void RasterizerStorageGLES2::texture_set_data_partial(RID p_texture, const Ref<I
}
Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) const {
-
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Ref<Image>());
@@ -902,7 +840,6 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
for (int i = 0; i < texture->mipmaps; i++) {
-
int ofs = Image::get_image_mipmap_offset(texture->alloc_width, texture->alloc_height, real_format, i);
if (texture->compressed) {
@@ -993,7 +930,6 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
}
void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) {
-
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1005,7 +941,6 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
glBindTexture(texture->target, texture->tex_id);
if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
-
if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
@@ -1034,11 +969,9 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
}
if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering
} else {
-
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
}
@@ -1140,7 +1073,6 @@ void RasterizerStorageGLES2::texture_debug_usage(List<RS::TextureInfo> *r_info)
texture_owner.get_owned_list(&textures);
for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
-
Texture *t = texture_owner.getornull(E->get());
if (!t)
continue;
@@ -1164,7 +1096,6 @@ void RasterizerStorageGLES2::textures_keep_original(bool p_enable) {
}
Size2 RasterizerStorageGLES2::texture_size_with_proxy(RID p_texture) const {
-
const Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Size2());
if (texture->proxy) {
@@ -1193,7 +1124,6 @@ void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) {
}
void RasterizerStorageGLES2::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {
-
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -1225,7 +1155,6 @@ void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, R
}
RID RasterizerStorageGLES2::texture_create_radiance_cubemap(RID p_source, int p_resolution) const {
-
return RID();
}
@@ -1326,7 +1255,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
// third, render to the framebuffer using separate textures, then copy to mipmaps
while (size >= 1) {
-
//make framebuffer size the texture size, need to use a separate texture for compatibility
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, resources.mipmap_blur_color);
@@ -1348,7 +1276,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
glActiveTexture(GL_TEXTURE2); //back to panorama
for (int i = 0; i < 6; i++) {
-
shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i);
float roughness = mm_level >= 0 ? lod / (float)(mipmaps - 1) : 1;
@@ -1395,7 +1322,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra
/* SHADER API */
RID RasterizerStorageGLES2::shader_create() {
-
Shader *shader = memnew(Shader);
shader->mode = RS::SHADER_SPATIAL;
shader->shader = &scene->state.scene_shader;
@@ -1414,7 +1340,6 @@ void RasterizerStorageGLES2::_shader_make_dirty(Shader *p_shader) {
}
void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
@@ -1457,7 +1382,6 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
}
String RasterizerStorageGLES2::shader_get_code(RID p_shader) const {
-
const Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, "");
@@ -1465,7 +1389,6 @@ String RasterizerStorageGLES2::shader_get_code(RID p_shader) const {
}
void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
-
_shader_dirty_list.remove(&p_shader->dirty_list);
p_shader->valid = false;
@@ -1480,9 +1403,7 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const {
ShaderCompilerGLES2::IdentifierActions *actions = nullptr;
switch (p_shader->mode) {
-
case RS::SHADER_CANVAS_ITEM: {
-
p_shader->canvas_item.light_mode = Shader::CanvasItem::LIGHT_MODE_NORMAL;
p_shader->canvas_item.blend_mode = Shader::CanvasItem::BLEND_MODE_MIX;
@@ -1611,7 +1532,6 @@ void RasterizerStorageGLES2::update_dirty_shaders() {
}
void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
@@ -1622,7 +1542,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
Map<int, StringName> order;
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
-
if (E->get().texture_order >= 0) {
order[E->get().texture_order + 100000] = E->key();
} else {
@@ -1631,7 +1550,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
}
for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
-
PropertyInfo pi;
ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[E->get()];
@@ -1738,7 +1656,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY: {
-
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureArray";
@@ -1758,7 +1675,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
}
void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
@@ -1773,7 +1689,6 @@ void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, cons
}
RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
-
const Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, RID());
@@ -1789,7 +1704,6 @@ RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const
/* COMMON MATERIAL API */
void RasterizerStorageGLES2::_material_make_dirty(Material *p_material) const {
-
if (p_material->dirty_list.in_list())
return;
@@ -1797,14 +1711,12 @@ void RasterizerStorageGLES2::_material_make_dirty(Material *p_material) const {
}
RID RasterizerStorageGLES2::material_create() {
-
Material *material = memnew(Material);
return material_owner.make_rid(material);
}
void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1825,7 +1737,6 @@ void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
}
RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
-
const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, RID());
@@ -1837,7 +1748,6 @@ RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
}
void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1851,7 +1761,6 @@ void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName
}
Variant RasterizerStorageGLES2::material_get_param(RID p_material, const StringName &p_param) const {
-
const Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, RID());
@@ -1921,7 +1830,6 @@ bool RasterizerStorageGLES2::material_casts_shadows(RID p_material) {
}
void RasterizerStorageGLES2::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1934,7 +1842,6 @@ void RasterizerStorageGLES2::material_add_instance_owner(RID p_material, Rasteri
}
void RasterizerStorageGLES2::material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1976,7 +1883,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
bool is_animated = false;
if (p_material->shader && p_material->shader->mode == RS::SHADER_SPATIAL) {
-
if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX &&
(!p_material->shader->spatial.uses_alpha || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) {
can_cast_shadow = true;
@@ -2008,7 +1914,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
// uniforms and other things will be set in the use_material method in ShaderGLES2
if (p_material->shader && p_material->shader->texture_count > 0) {
-
p_material->textures.resize(p_material->shader->texture_count);
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = p_material->shader->uniforms.front(); E; E = E->next()) {
@@ -2052,7 +1957,6 @@ void RasterizerStorageGLES2::_material_add_geometry(RID p_material, Geometry *p_
}
void RasterizerStorageGLES2::_material_remove_geometry(RID p_material, Geometry *p_geometry) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -2068,7 +1972,6 @@ void RasterizerStorageGLES2::_material_remove_geometry(RID p_material, Geometry
void RasterizerStorageGLES2::update_dirty_materials() {
while (_material_dirty_list.first()) {
-
Material *material = _material_dirty_list.first()->self();
_update_material(material);
}
@@ -2077,14 +1980,12 @@ void RasterizerStorageGLES2::update_dirty_materials() {
/* MESH API */
RID RasterizerStorageGLES2::mesh_create() {
-
Mesh *mesh = memnew(Mesh);
return mesh_owner.make_rid(mesh);
}
static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_t &format, int p_vertices) {
-
uint32_t p_format = format;
static int src_size[RS::ARRAY_MAX];
@@ -2095,7 +1996,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
int dst_stride = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
to_convert[i] = 0;
if (!(p_format & (1 << i))) {
src_size[i] = 0;
@@ -2104,11 +2004,8 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & RS::ARRAY_COMPRESS_VERTEX) {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
src_size[i] = 4;
dst_size[i] = 8;
@@ -2121,7 +2018,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
format &= ~RS::ARRAY_COMPRESS_VERTEX;
} else {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
src_size[i] = 8;
dst_size[i] = 8;
@@ -2133,7 +2029,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_NORMAL: {
-
if (p_format & RS::ARRAY_COMPRESS_NORMAL) {
src_size[i] = 4;
dst_size[i] = 4;
@@ -2144,7 +2039,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_TANGENT: {
-
if (p_format & RS::ARRAY_COMPRESS_TANGENT) {
src_size[i] = 4;
dst_size[i] = 4;
@@ -2155,7 +2049,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_COLOR: {
-
if (p_format & RS::ARRAY_COMPRESS_COLOR) {
src_size[i] = 4;
dst_size[i] = 4;
@@ -2166,7 +2059,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_TEX_UV: {
-
if (p_format & RS::ARRAY_COMPRESS_TEX_UV) {
src_size[i] = 4;
to_convert[i] = 2;
@@ -2179,7 +2071,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_TEX_UV2: {
-
if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) {
src_size[i] = 4;
to_convert[i] = 2;
@@ -2192,7 +2083,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_BONES: {
-
if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) {
src_size[i] = 8;
dst_size[i] = 8;
@@ -2203,7 +2093,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_WEIGHTS: {
-
if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) {
src_size[i] = 8;
dst_size[i] = 8;
@@ -2214,7 +2103,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
} break;
case RS::ARRAY_INDEX: {
-
src_size[i] = 0;
dst_size[i] = 0;
@@ -2235,7 +2123,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
int dst_offset = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
if (src_size[i] == 0) {
continue; //no go
}
@@ -2248,7 +2135,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
float *dst = (float *)&wptr[dst_stride * j + dst_offset];
for (int k = 0; k < to_convert[i]; k++) {
-
dst[k] = Math::half_to_float(src[k]);
}
}
@@ -2273,7 +2159,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_
}
void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -2293,7 +2178,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
bool uses_half_float = false;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
attribs[i].index = i;
if (!(p_format & (1 << i))) {
@@ -2307,9 +2191,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
attribs[i].integer = false;
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
attribs[i].size = 2;
} else {
@@ -2329,7 +2211,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_NORMAL: {
-
attribs[i].size = 3;
if (p_format & RS::ARRAY_COMPRESS_NORMAL) {
@@ -2344,7 +2225,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_TANGENT: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_COMPRESS_TANGENT) {
@@ -2359,7 +2239,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_COLOR: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_COMPRESS_COLOR) {
@@ -2374,7 +2253,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_TEX_UV: {
-
attribs[i].size = 2;
if (p_format & RS::ARRAY_COMPRESS_TEX_UV) {
@@ -2390,7 +2268,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_TEX_UV2: {
-
attribs[i].size = 2;
if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) {
@@ -2405,7 +2282,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_BONES: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) {
@@ -2421,11 +2297,9 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_WEIGHTS: {
-
attribs[i].size = 4;
if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) {
-
attribs[i].type = GL_UNSIGNED_SHORT;
stride += 8;
attribs[i].normalized = GL_TRUE;
@@ -2437,7 +2311,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
} break;
case RS::ARRAY_INDEX: {
-
attribs[i].size = 1;
if (p_vertex_count >= (1 << 16)) {
@@ -2478,7 +2351,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
uint16_t one = Math::make_half_float(1);
for (int i = 0; i < p_vertex_count; i++) {
-
*w16++ = *r16++;
*w16++ = *r16++;
*w16++ = *r16++;
@@ -2492,7 +2364,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
ERR_FAIL_COND(array.size() != array_size);
if (!config.support_half_float_vertices && uses_half_float) {
-
uint32_t new_format = p_format;
Vector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count);
@@ -2501,7 +2372,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
}
if (p_format & RS::ARRAY_FORMAT_INDEX) {
-
index_array_size = attribs[RS::ARRAY_INDEX].stride * p_index_count;
}
@@ -2577,7 +2447,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS:
// blend shapes
for (int i = 0; i < p_blend_shapes.size(); i++) {
-
Surface::BlendShape mt;
const uint8_t *vr = p_blend_shapes[i].ptr();
@@ -2692,7 +2561,6 @@ int RasterizerStorageGLES2::mesh_surface_get_array_index_len(RID p_mesh, int p_s
}
Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const {
-
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, Vector<uint8_t>());
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>());
@@ -2749,6 +2617,7 @@ Vector<Vector<uint8_t>> RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RI
return mesh->surfaces[p_surface]->blend_shape_data;
}
+
Vector<AABB> RasterizerStorageGLES2::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, Vector<AABB>());
@@ -2758,7 +2627,6 @@ Vector<AABB> RasterizerStorageGLES2::mesh_surface_get_skeleton_aabb(RID p_mesh,
}
void RasterizerStorageGLES2::mesh_remove_surface(RID p_mesh, int p_surface) {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
ERR_FAIL_INDEX(p_surface, mesh->surfaces.size());
@@ -2823,12 +2691,9 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
AABB aabb;
if (sk && sk->size != 0) {
-
for (int i = 0; i < mesh->surfaces.size(); i++) {
-
AABB laabb;
if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
-
int bs = mesh->surfaces[i]->skeleton_bone_aabb.size();
const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr();
@@ -2840,7 +2705,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
bool first = true;
if (sk->use_2d) {
for (int j = 0; j < bs; j++) {
-
if (!skused[j])
continue;
@@ -2867,7 +2731,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
}
} else {
for (int j = 0; j < bs; j++) {
-
if (!skused[j])
continue;
@@ -2901,7 +2764,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
}
} else {
-
laabb = mesh->surfaces[i]->aabb;
}
@@ -2911,9 +2773,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
aabb.merge_with(laabb);
}
} else {
-
for (int i = 0; i < mesh->surfaces.size(); i++) {
-
if (i == 0)
aabb = mesh->surfaces[i]->aabb;
else
@@ -2923,6 +2783,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
return aabb;
}
+
void RasterizerStorageGLES2::mesh_clear(RID p_mesh) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -3158,7 +3019,6 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) {
-
uint8_t *data8 = (uint8_t *)dataptr;
data8[0] = CLAMP(p_color.r * 255.0, 0, 255);
data8[1] = CLAMP(p_color.g * 255.0, 0, 255);
@@ -3191,7 +3051,6 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh,
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) {
-
uint8_t *data8 = (uint8_t *)dataptr;
data8[0] = CLAMP(p_custom_data.r * 255.0, 0, 255);
data8[1] = CLAMP(p_custom_data.g * 255.0, 0, 255);
@@ -3379,13 +3238,10 @@ AABB RasterizerStorageGLES2::multimesh_get_aabb(RID p_multimesh) const {
}
void RasterizerStorageGLES2::update_dirty_multimeshes() {
-
while (multimesh_update_list.first()) {
-
MultiMesh *multimesh = multimesh_update_list.first()->self();
if (multimesh->size && multimesh->dirty_aabb) {
-
AABB mesh_aabb;
if (multimesh->mesh.is_valid()) {
@@ -3401,9 +3257,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() {
AABB aabb;
if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) {
-
for (int i = 0; i < count; i += stride) {
-
float *dataptr = &data[i];
Transform xform;
@@ -3424,9 +3278,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() {
}
} else {
-
for (int i = 0; i < count; i += stride) {
-
float *dataptr = &data[i];
Transform xform;
@@ -3599,7 +3451,6 @@ RID RasterizerStorageGLES2::immediate_get_material(RID p_immediate) const {
/* SKELETON API */
RID RasterizerStorageGLES2::skeleton_create() {
-
Skeleton *skeleton = memnew(Skeleton);
glGenTextures(1, &skeleton->tex_id);
@@ -3608,7 +3459,6 @@ RID RasterizerStorageGLES2::skeleton_create() {
}
void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_COND(p_bones < 0);
@@ -3621,7 +3471,6 @@ void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool
skeleton->use_2d = p_2d_skeleton;
if (!config.use_skeleton_software) {
-
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, skeleton->tex_id);
@@ -3713,6 +3562,7 @@ Transform RasterizerStorageGLES2::skeleton_bone_get_transform(RID p_skeleton, in
return ret;
}
+
void RasterizerStorageGLES2::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -3762,7 +3612,6 @@ Transform2D RasterizerStorageGLES2::skeleton_bone_get_transform_2d(RID p_skeleto
}
void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -3770,7 +3619,6 @@ void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, cons
}
void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size) {
-
glBindBuffer(GL_ARRAY_BUFFER, resources.skeleton_transform_buffer);
if (p_size > resources.skeleton_transform_buffer_size) {
@@ -3787,7 +3635,6 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<floa
}
void RasterizerStorageGLES2::update_dirty_skeletons() {
-
if (config.use_skeleton_software)
return;
@@ -3813,7 +3660,6 @@ void RasterizerStorageGLES2::update_dirty_skeletons() {
/* Light API */
RID RasterizerStorageGLES2::light_create(RS::LightType p_type) {
-
Light *light = memnew(Light);
light->type = p_type;
@@ -4060,7 +3906,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const {
ERR_FAIL_COND_V(!light, AABB());
switch (light->type) {
-
case RS::LIGHT_SPOT: {
float len = light->param[RS::LIGHT_PARAM_RANGE];
float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
@@ -4083,7 +3928,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const {
/* PROBE API */
RID RasterizerStorageGLES2::reflection_probe_create() {
-
ReflectionProbe *reflection_probe = memnew(ReflectionProbe);
reflection_probe->intensity = 1.0;
@@ -4104,7 +3948,6 @@ RID RasterizerStorageGLES2::reflection_probe_create() {
}
void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4113,7 +3956,6 @@ void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::R
}
void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4121,7 +3963,6 @@ void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p
}
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4129,7 +3970,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe,
}
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4137,7 +3977,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_
}
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4145,23 +3984,22 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contrib
}
void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->max_distance = p_distance;
reflection_probe->instance_change_notify(true, false);
}
-void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
+void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->extents = p_extents;
reflection_probe->instance_change_notify(true, false);
}
-void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
+void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4170,15 +4008,14 @@ void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, con
}
void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->interior = p_enable;
reflection_probe->instance_change_notify(true, false);
}
-void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
+void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4186,15 +4023,14 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_pr
}
void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->enable_shadows = p_enable;
reflection_probe->instance_change_notify(true, false);
}
-void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
+void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4203,7 +4039,6 @@ void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_
}
void RasterizerStorageGLES2::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -4220,8 +4055,8 @@ AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
-RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
+RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
@@ -4229,7 +4064,6 @@ RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_updat
}
uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -4237,14 +4071,13 @@ uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) con
}
Vector3 RasterizerStorageGLES2::reflection_probe_get_extents(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->extents;
}
-Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) const {
+Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
@@ -4252,7 +4085,6 @@ Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe)
}
bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
@@ -4260,7 +4092,6 @@ bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const
}
float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -4268,7 +4099,6 @@ float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_pro
}
int RasterizerStorageGLES2::reflection_probe_get_resolution(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -4339,6 +4169,7 @@ void RasterizerStorageGLES2::gi_probe_set_compress(RID p_probe, bool p_enable) {
bool RasterizerStorageGLES2::gi_probe_is_compressed(RID p_probe) const {
return false;
}
+
float RasterizerStorageGLES2::gi_probe_get_energy(RID p_probe) const {
return 0;
}
@@ -4373,26 +4204,24 @@ void RasterizerStorageGLES2::gi_probe_dynamic_data_update(RID p_gi_probe_data, i
///////
RID RasterizerStorageGLES2::lightmap_capture_create() {
-
LightmapCapture *capture = memnew(LightmapCapture);
return lightmap_capture_data_owner.make_rid(capture);
}
void RasterizerStorageGLES2::lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {
-
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
capture->bounds = p_bounds;
capture->instance_change_notify(true, false);
}
-AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const {
+AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, AABB());
return capture->bounds;
}
-void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {
+void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
@@ -4406,8 +4235,8 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Ve
}
capture->instance_change_notify(true, false);
}
-Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {
+Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, Vector<uint8_t>());
@@ -4450,14 +4279,12 @@ int RasterizerStorageGLES2::lightmap_capture_get_octree_cell_subdiv(RID p_captur
}
void RasterizerStorageGLES2::lightmap_capture_set_energy(RID p_capture, float p_energy) {
-
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
capture->energy = p_energy;
}
float RasterizerStorageGLES2::lightmap_capture_get_energy(RID p_capture) const {
-
const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND_V(!capture, 0);
return capture->energy;
@@ -4562,7 +4389,6 @@ bool RasterizerStorageGLES2::particles_is_inactive(RID p_particles) const {
////////
void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -4570,7 +4396,6 @@ void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerSce
}
void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -4578,7 +4403,6 @@ void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, Rasterizer
}
void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {
-
Instantiable *inst = nullptr;
switch (p_instance->base_type) {
case RS::INSTANCE_MESH: {
@@ -4622,7 +4446,6 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene
}
void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {
-
Instantiable *inst = nullptr;
switch (p_instance->base_type) {
@@ -4669,7 +4492,6 @@ void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerSc
/* RENDER TARGET */
void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
-
// do not allocate a render target with no size
if (rt->width <= 0 || rt->height <= 0)
return;
@@ -4707,7 +4529,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
rt->mip_maps_allocated = false;
{
-
/* Front FBO */
Texture *texture = texture_owner.getornull(rt->texture);
@@ -4724,11 +4545,9 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, nullptr);
if (texture->flags & RS::TEXTURE_FLAG_FILTER) {
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
@@ -4741,7 +4560,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
// depth
if (config.support_depth_texture) {
-
glGenTextures(1, &rt->depth);
glBindTexture(GL_TEXTURE_2D, rt->depth);
glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, config.depth_type, nullptr);
@@ -4753,7 +4571,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
} else {
-
glGenRenderbuffers(1, &rt->depth);
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth);
@@ -4765,13 +4582,10 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
-
glDeleteFramebuffers(1, &rt->fbo);
if (config.support_depth_texture) {
-
glDeleteTextures(1, &rt->depth);
} else {
-
glDeleteRenderbuffers(1, &rt->depth);
}
@@ -4806,7 +4620,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
#ifndef JAVASCRIPT_ENABLED
if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_16X && config.multisample_supported) {
-
rt->multisample_active = true;
static const int msaa_value[] = { 0, 2, 4, 8, 16 };
@@ -4889,7 +4702,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
// copy texscreen buffers
if (!(rt->flags[RasterizerStorage::RENDER_TARGET_NO_SAMPLING])) {
-
glGenTextures(1, &rt->copy_screen_effect.color);
glBindTexture(GL_TEXTURE_2D, rt->copy_screen_effect.color);
@@ -4920,9 +4732,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
// Allocate mipmap chains for post_process effects
if (!rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D] && rt->width >= 2 && rt->height >= 2) {
-
for (int i = 0; i < 2; i++) {
-
ERR_FAIL_COND(rt->mip_maps[i].sizes.size());
int w = rt->width;
int h = rt->height;
@@ -4937,7 +4747,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
int fb_h = h;
while (true) {
-
RenderTarget::MipMaps::Size mm;
mm.width = w;
mm.height = h;
@@ -4956,7 +4765,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
GLsizei height = fb_h;
if (config.render_to_mipmap_supported) {
-
glGenTextures(1, &rt->mip_maps[i].color);
glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].color);
@@ -4970,7 +4778,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
#endif
} else {
-
// Can't render to specific levels of a mipmap in ES 2.0 or Webgl so create a texture for each level
for (int l = 0; l < level + 1; l++) {
glGenTextures(1, &rt->mip_maps[i].sizes.write[l].color);
@@ -4990,17 +4797,14 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
glDepthMask(GL_TRUE);
for (int j = 0; j < rt->mip_maps[i].sizes.size(); j++) {
-
RenderTarget::MipMaps::Size &mm = rt->mip_maps[i].sizes.write[j];
glGenFramebuffers(1, &mm.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo);
if (config.render_to_mipmap_supported) {
-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].color, j);
} else {
-
glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color, 0);
}
@@ -5046,7 +4850,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
}
void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
-
// there is nothing to clear when DIRECT_TO_SCREEN is used
if (rt->flags[RENDER_TARGET_DIRECT_TO_SCREEN])
return;
@@ -5129,7 +4932,6 @@ void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
}
RID RasterizerStorageGLES2::render_target_create() {
-
RenderTarget *rt = memnew(RenderTarget);
Texture *t = memnew(Texture);
@@ -5160,7 +4962,6 @@ RID RasterizerStorageGLES2::render_target_create() {
}
void RasterizerStorageGLES2::render_target_set_position(RID p_render_target, int p_x, int p_y) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
@@ -5169,7 +4970,6 @@ void RasterizerStorageGLES2::render_target_set_position(RID p_render_target, int
}
void RasterizerStorageGLES2::render_target_set_size(RID p_render_target, int p_width, int p_height) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
@@ -5185,7 +4985,6 @@ void RasterizerStorageGLES2::render_target_set_size(RID p_render_target, int p_w
}
RID RasterizerStorageGLES2::render_target_get_texture(RID p_render_target) const {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
@@ -5390,7 +5189,6 @@ void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, RS::Vie
/* CANVAS SHADOW */
RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) {
-
CanvasLightShadow *cls = memnew(CanvasLightShadow);
if (p_width > config.max_texture_size)
@@ -5442,7 +5240,6 @@ RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) {
/* LIGHT SHADOW MAPPING */
RID RasterizerStorageGLES2::canvas_light_occluder_create() {
-
CanvasOccluder *co = memnew(CanvasOccluder);
co->index_id = 0;
co->vertex_id = 0;
@@ -5452,14 +5249,12 @@ RID RasterizerStorageGLES2::canvas_light_occluder_create() {
}
void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) {
-
CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!co);
co->lines = p_lines;
if (p_lines.size() != co->len) {
-
if (co->index_id)
glDeleteBuffers(1, &co->index_id);
if (co->vertex_id)
@@ -5471,7 +5266,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
}
if (p_lines.size()) {
-
Vector<float> geometry;
Vector<uint16_t> indices;
int lc = p_lines.size();
@@ -5487,7 +5281,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
const int POLY_HEIGHT = 16384;
for (int i = 0; i < lc / 2; i++) {
-
vw[i * 12 + 0] = lr[i * 2 + 0].x;
vw[i * 12 + 1] = lr[i * 2 + 0].y;
vw[i * 12 + 2] = POLY_HEIGHT;
@@ -5520,7 +5313,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id);
glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW);
} else {
-
glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id);
glBufferSubData(GL_ARRAY_BUFFER, 0, lc * 6 * sizeof(real_t), vw.ptr());
}
@@ -5528,12 +5320,10 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
if (!co->index_id) {
-
glGenBuffers(1, &co->index_id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, lc * 3 * sizeof(uint16_t), iw.ptr(), GL_DYNAMIC_DRAW);
} else {
-
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, lc * 3 * sizeof(uint16_t), iw.ptr());
}
@@ -5545,7 +5335,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder,
}
RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
-
if (mesh_owner.owns(p_rid)) {
return RS::INSTANCE_MESH;
} else if (light_owner.owns(p_rid)) {
@@ -5564,9 +5353,7 @@ RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
}
bool RasterizerStorageGLES2::free(RID p_rid) {
-
if (render_target_owner.owns(p_rid)) {
-
RenderTarget *rt = render_target_owner.getornull(p_rid);
_render_target_clear(rt);
@@ -5578,7 +5365,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (texture_owner.owns(p_rid)) {
-
Texture *t = texture_owner.getornull(p_rid);
// can't free a render target texture
ERR_FAIL_COND_V(t->render_target, true);
@@ -5589,7 +5375,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (sky_owner.owns(p_rid)) {
-
Sky *sky = sky_owner.getornull(p_rid);
sky_set_texture(p_rid, RID(), 256);
sky_owner.free(p_rid);
@@ -5597,7 +5382,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (shader_owner.owns(p_rid)) {
-
Shader *shader = shader_owner.getornull(p_rid);
if (shader->shader && shader->custom_code_id) {
@@ -5622,7 +5406,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (material_owner.owns(p_rid)) {
-
Material *m = material_owner.getornull(p_rid);
if (m->shader) {
@@ -5635,7 +5418,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
}
for (Map<RasterizerScene::InstanceBase *, int>::Element *E = m->instance_owners.front(); E; E = E->next()) {
-
RasterizerScene::InstanceBase *ins = E->key();
if (ins->material_override == p_rid) {
@@ -5654,7 +5436,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (skeleton_owner.owns(p_rid)) {
-
Skeleton *s = skeleton_owner.getornull(p_rid);
if (s->update_list.in_list()) {
@@ -5676,7 +5457,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (mesh_owner.owns(p_rid)) {
-
Mesh *mesh = mesh_owner.getornull(p_rid);
mesh->instance_remove_deps();
@@ -5699,7 +5479,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (multimesh_owner.owns(p_rid)) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
multimesh->instance_remove_deps();
@@ -5727,7 +5506,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (light_owner.owns(p_rid)) {
-
Light *light = light_owner.getornull(p_rid);
light->instance_remove_deps();
@@ -5736,7 +5514,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (reflection_probe_owner.owns(p_rid)) {
-
// delete the texture
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
reflection_probe->instance_remove_deps();
@@ -5746,7 +5523,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (lightmap_capture_data_owner.owns(p_rid)) {
-
// delete the texture
LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid);
lightmap_capture->instance_remove_deps();
@@ -5756,7 +5532,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (canvas_occluder_owner.owns(p_rid)) {
-
CanvasOccluder *co = canvas_occluder_owner.getornull(p_rid);
if (co->index_id)
glDeleteBuffers(1, &co->index_id);
@@ -5769,7 +5544,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
return true;
} else if (canvas_light_shadow_owner.owns(p_rid)) {
-
CanvasLightShadow *cls = canvas_light_shadow_owner.getornull(p_rid);
glDeleteFramebuffers(1, &cls->fbo);
glDeleteRenderbuffers(1, &cls->depth);
@@ -5784,7 +5558,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
}
bool RasterizerStorageGLES2::has_os_feature(const String &p_feature) const {
-
if (p_feature == "pvrtc")
return config.pvrtc_supported;
@@ -5803,12 +5576,10 @@ void RasterizerStorageGLES2::set_debug_generate_wireframes(bool p_generate) {
}
void RasterizerStorageGLES2::render_info_begin_capture() {
-
info.snap = info.render;
}
void RasterizerStorageGLES2::render_info_end_capture() {
-
info.snap.object_count = info.render.object_count - info.snap.object_count;
info.snap.draw_call_count = info.render.draw_call_count - info.snap.draw_call_count;
info.snap.material_switch_count = info.render.material_switch_count - info.snap.material_switch_count;
@@ -5818,7 +5589,6 @@ void RasterizerStorageGLES2::render_info_end_capture() {
}
int RasterizerStorageGLES2::get_captured_render_info(RS::RenderInfo p_info) {
-
switch (p_info) {
case RS::INFO_OBJECTS_IN_FRAME: {
return info.snap.object_count;
@@ -5872,12 +5642,10 @@ int RasterizerStorageGLES2::get_render_info(RS::RenderInfo p_info) {
}
String RasterizerStorageGLES2::get_video_adapter_name() const {
-
return (const char *)glGetString(GL_RENDERER);
}
String RasterizerStorageGLES2::get_video_adapter_vendor() const {
-
return (const char *)glGetString(GL_VENDOR);
}
@@ -5885,7 +5653,6 @@ void RasterizerStorageGLES2::initialize() {
RasterizerStorageGLES2::system_fbo = 0;
{
-
const GLubyte *extension_string = glGetString(GL_EXTENSIONS);
Vector<String> extensions = String((const char *)extension_string).split(" ");
@@ -6236,7 +6003,6 @@ void RasterizerStorageGLES2::initialize() {
}
{
-
glGenFramebuffers(1, &resources.mipmap_blur_fbo);
glGenTextures(1, &resources.mipmap_blur_color);
}
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index 29651936fb..15761e4efd 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -57,7 +57,6 @@ public:
static GLuint system_fbo;
struct Config {
-
bool shrink_textures_x2;
bool use_fast_texture_filter;
bool use_skeleton_software;
@@ -106,7 +105,6 @@ public:
} config;
struct Resources {
-
GLuint white_tex;
GLuint black_tex;
GLuint normal_tex;
@@ -129,7 +127,6 @@ public:
} resources;
mutable struct Shaders {
-
ShaderCompilerGLES2 compiler;
CopyShaderGLES2 copy;
@@ -142,7 +139,6 @@ public:
} shaders;
struct Info {
-
uint64_t texture_mem;
uint64_t vertex_mem;
@@ -183,10 +179,8 @@ public:
SelfList<RasterizerScene::InstanceBase>::List instance_list;
_FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
-
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
-
instances->self()->base_changed(p_aabb, p_materials);
instances = instances->next();
}
@@ -210,7 +204,6 @@ public:
};
struct Geometry : public Instantiable {
-
enum Type {
GEOMETRY_INVALID,
GEOMETRY_SURFACE,
@@ -240,7 +233,6 @@ public:
struct RenderTarget;
struct Texture {
-
Texture *proxy;
Set<Texture *> proxy_owners;
@@ -383,7 +375,6 @@ public:
/* SKY API */
struct Sky {
-
RID panorama;
GLuint radiance;
int radiance_size;
@@ -399,7 +390,6 @@ public:
struct Material;
struct Shader {
-
RID self;
RS::ShaderMode mode;
@@ -429,7 +419,6 @@ public:
uint64_t last_pass;
struct CanvasItem {
-
enum BlendMode {
BLEND_MODE_MIX,
BLEND_MODE_ADD,
@@ -455,7 +444,6 @@ public:
} canvas_item;
struct Spatial {
-
enum BlendMode {
BLEND_MODE_MIX,
BLEND_MODE_ADD,
@@ -499,7 +487,6 @@ public:
} spatial;
struct Particles {
-
} particles;
bool uses_vertex_time;
@@ -507,7 +494,6 @@ public:
Shader() :
dirty_list(this) {
-
shader = nullptr;
valid = false;
custom_code_id = 0;
@@ -536,7 +522,6 @@ public:
/* COMMON MATERIAL API */
struct Material {
-
Shader *shader;
Map<StringName, Variant> params;
SelfList<Material> list;
@@ -605,7 +590,6 @@ public:
struct Mesh;
struct Surface : public Geometry {
-
struct Attrib {
bool enabled;
bool integer;
@@ -669,7 +653,6 @@ public:
struct MultiMesh;
struct Mesh : public GeometryOwner {
-
bool active;
Vector<Surface *> surfaces;
@@ -740,7 +723,6 @@ public:
/* MULTIMESH API */
struct MultiMesh : public GeometryOwner {
-
RID mesh;
int size;
@@ -814,7 +796,6 @@ public:
/* IMMEDIATE API */
struct Immediate : public Geometry {
-
struct Chunk {
RID texture;
RS::PrimitiveType primitive;
@@ -862,7 +843,6 @@ public:
/* SKELETON API */
struct Skeleton {
-
bool use_2d;
int size;
@@ -972,7 +952,6 @@ public:
/* PROBE API */
struct ReflectionProbe : Instantiable {
-
RS::ReflectionProbeUpdateMode update_mode;
float intensity;
Color interior_ambient;
@@ -1062,7 +1041,6 @@ public:
/* LIGHTMAP */
struct LightmapCapture : public Instantiable {
-
Vector<LightmapCaptureOctree> octree;
AABB bounds;
Transform cell_xform;
@@ -1165,7 +1143,6 @@ public:
Effect copy_screen_effect;
struct MipMaps {
-
struct Size {
GLuint fbo;
GLuint color;
@@ -1252,7 +1229,6 @@ public:
/* CANVAS SHADOW */
struct CanvasLightShadow {
-
int size;
int height;
GLuint fbo;
@@ -1267,7 +1243,6 @@ public:
/* LIGHT SHADOW MAPPING */
struct CanvasOccluder {
-
GLuint vertex_id; // 0 means, unconfigured
GLuint index_id; // 0 means, unconfigured
Vector<Vector2> lines;
@@ -1284,7 +1259,6 @@ public:
virtual bool free(RID p_rid);
struct Frame {
-
RenderTarget *current_rt;
bool clear_request;
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index f6a764c26c..2e36de5c79 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -38,7 +38,6 @@
#define SL ShaderLanguage
static String _mktab(int p_level) {
-
String tb;
for (int i = 0; i < p_level; i++) {
tb += "\t";
@@ -48,12 +47,10 @@ static String _mktab(int p_level) {
}
static String _typestr(SL::DataType p_type) {
-
return ShaderLanguage::get_datatype_name(p_type);
}
static String _prestr(SL::DataPrecision p_pres) {
-
switch (p_pres) {
case SL::PRECISION_LOWP:
return "lowp ";
@@ -68,7 +65,6 @@ static String _prestr(SL::DataPrecision p_pres) {
}
static String _qualstr(SL::ArgumentQualifier p_qual) {
-
switch (p_qual) {
case SL::ARGUMENT_QUALIFIER_IN:
return "in ";
@@ -81,18 +77,15 @@ static String _qualstr(SL::ArgumentQualifier p_qual) {
}
static String _opstr(SL::Operator p_op) {
-
return SL::get_operator_text(p_op);
}
static String _mkid(const String &p_id) {
-
String id = "m_" + p_id.replace("__", "_dus_");
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
static String f2sp0(float p_float) {
-
String num = rtoss(p_float);
if (num.find(".") == -1 && num.find("e") == -1) {
num += ".0";
@@ -101,14 +94,12 @@ static String f2sp0(float p_float) {
}
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
-
switch (p_type) {
case SL::TYPE_BOOL:
return p_values[0].boolean ? "true" : "false";
case SL::TYPE_BVEC2:
case SL::TYPE_BVEC3:
case SL::TYPE_BVEC4: {
-
StringBuffer<> text;
text += "bvec";
@@ -131,7 +122,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_UVEC2:
case SL::TYPE_UVEC3:
case SL::TYPE_UVEC4: {
-
StringBuffer<> text;
text += "ivec";
@@ -154,7 +144,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_IVEC2:
case SL::TYPE_IVEC3:
case SL::TYPE_IVEC4: {
-
StringBuffer<> text;
text += "ivec";
@@ -176,7 +165,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_VEC2:
case SL::TYPE_VEC3:
case SL::TYPE_VEC4: {
-
StringBuffer<> text;
text += "vec";
@@ -196,7 +184,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_MAT2:
case SL::TYPE_MAT3:
case SL::TYPE_MAT4: {
-
StringBuffer<> text;
text += "mat";
@@ -231,7 +218,6 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri
ERR_FAIL_COND(fidx == -1);
for (Set<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) {
-
if (r_added.has(E->get())) {
continue;
}
@@ -276,20 +262,15 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri
}
}
-String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning) {
-
+String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) {
StringBuilder code;
switch (p_node->type) {
-
case SL::Node::TYPE_SHADER: {
-
SL::ShaderNode *snode = (SL::ShaderNode *)p_node;
for (int i = 0; i < snode->render_modes.size(); i++) {
-
if (p_default_actions.render_mode_defines.has(snode->render_modes[i]) && !used_rmode_defines.has(snode->render_modes[i])) {
-
r_gen_code.custom_defines.push_back(p_default_actions.render_mode_defines[snode->render_modes[i]].utf8());
used_rmode_defines.insert(snode->render_modes[i]);
}
@@ -326,7 +307,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
// structs
for (int i = 0; i < snode->vstructs.size(); i++) {
-
SL::StructNode *st = snode->vstructs[i].shader_struct;
String struct_code;
@@ -393,7 +373,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
// varyings
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = snode->varyings.front(); E; E = E->next()) {
-
StringBuffer<> varying_code;
varying_code += "varying ";
@@ -448,7 +427,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
Set<StringName> added_fragment;
for (int i = 0; i < snode->functions.size(); i++) {
-
SL::FunctionNode *fnode = snode->functions[i].function;
current_func_name = fnode->name;
@@ -472,14 +450,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
case SL::Node::TYPE_STRUCT: {
-
} break;
case SL::Node::TYPE_FUNCTION: {
-
} break;
case SL::Node::TYPE_BLOCK: {
-
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
if (!bnode->single_statement) {
@@ -520,7 +495,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
for (int i = 0; i < var_dec_node->declarations.size(); i++) {
-
if (i > 0) {
declaration += ",";
}
@@ -597,7 +571,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += ")";
} break;
case SL::Node::TYPE_ARRAY_DECLARATION: {
-
SL::ArrayDeclarationNode *arr_dec_node = (SL::ArrayDeclarationNode *)p_node;
StringBuffer<> declaration;
@@ -608,7 +581,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
declaration += _typestr(arr_dec_node->datatype);
}
for (int i = 0; i < arr_dec_node->declarations.size(); i++) {
-
if (i > 0) {
declaration += ",";
}
@@ -654,7 +626,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
if (arr_node->call_expression != nullptr) {
code += ".";
- code += _dump_node_code(arr_node->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += _dump_node_code(arr_node->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning, false);
}
if (arr_node->index_expression != nullptr) {
@@ -736,7 +708,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} else if (op_node->op == SL::OP_CONSTRUCT) {
code += var_node->name;
} else {
-
if (var_node->name == "texture") {
// emit texture call
@@ -764,9 +735,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
} else if (var_node->name == "mix") {
-
switch (op_node->arguments[3]->get_datatype()) {
-
case SL::TYPE_BVEC2: {
code += "select2";
} break;
@@ -783,7 +752,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
case SL::TYPE_VEC3:
case SL::TYPE_VEC4:
case SL::TYPE_FLOAT: {
-
code += "mix";
} break;
@@ -846,7 +814,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
case SL::OP_MOD: {
-
code += "mod(float(";
code += _dump_node_code(op_node->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += "), float(";
@@ -855,13 +822,17 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
} break;
default: {
- code += "(";
+ if (p_use_scope) {
+ code += "(";
+ }
code += _dump_node_code(op_node->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += " ";
code += _opstr(op_node->op);
code += " ";
code += _dump_node_code(op_node->arguments[1], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
- code += ")";
+ if (p_use_scope) {
+ code += ")";
+ }
} break;
}
} break;
@@ -870,7 +841,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
SL::ControlFlowNode *cf_node = (SL::ControlFlowNode *)p_node;
if (cf_node->flow_op == SL::FLOW_OP_IF) {
-
code += _mktab(p_level);
code += "if (";
code += _dump_node_code(cf_node->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
@@ -897,7 +867,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += ")\n";
code += _dump_node_code(cf_node->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cf_node->flow_op == SL::FLOW_OP_FOR) {
-
code += _mktab(p_level);
code += "for (";
code += _dump_node_code(cf_node->blocks[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
@@ -948,11 +917,9 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
}
Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
-
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types());
if (err != OK) {
-
Vector<String> shader = p_code.split("\n");
for (int i = 0; i < shader.size(); i++) {
print_line(itos(i + 1) + " " + shader[i]);
@@ -985,7 +952,6 @@ Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code,
}
ShaderCompilerGLES2::ShaderCompilerGLES2() {
-
/** CANVAS ITEM SHADER **/
actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h
index 757dcdd4f2..66a3af0739 100644
--- a/drivers/gles2/shader_compiler_gles2.h
+++ b/drivers/gles2/shader_compiler_gles2.h
@@ -40,7 +40,6 @@
class ShaderCompilerGLES2 {
public:
struct IdentifierActions {
-
Map<StringName, Pair<int *, int>> render_mode_values;
Map<StringName, bool *> render_mode_flags;
Map<StringName, bool *> usage_flag_pointers;
@@ -50,7 +49,6 @@ public:
};
struct GeneratedCode {
-
Vector<CharString> custom_defines;
Vector<StringName> uniforms;
Vector<StringName> texture_uniforms;
@@ -71,14 +69,13 @@ private:
ShaderLanguage parser;
struct DefaultIdentifierActions {
-
Map<StringName, String> renames;
Map<StringName, String> render_mode_defines;
Map<StringName, String> usage_defines;
};
void _dump_function_deps(ShaderLanguage::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, StringBuilder &r_to_add, Set<StringName> &r_added);
- String _dump_node_code(ShaderLanguage::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning);
+ String _dump_node_code(ShaderLanguage::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope = true);
StringName current_func_name;
StringName vertex_name;
diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp
index 2c335c6c5a..48b98435c4 100644
--- a/drivers/gles2/shader_gles2.cpp
+++ b/drivers/gles2/shader_gles2.cpp
@@ -70,14 +70,12 @@ ShaderGLES2 *ShaderGLES2::active = nullptr;
#endif
GLint ShaderGLES2::get_uniform_location(int p_index) const {
-
ERR_FAIL_COND_V(!version, -1);
return version->uniform_location[p_index];
}
bool ShaderGLES2::bind() {
-
if (active != this || !version || new_conditional_version.key != conditional_version.key) {
conditional_version = new_conditional_version;
version = get_current_version();
@@ -110,7 +108,6 @@ void ShaderGLES2::unbind() {
}
static void _display_error_with_code(const String &p_error, const Vector<const char *> &p_code) {
-
int line = 1;
String total_code;
@@ -121,7 +118,6 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
Vector<String> lines = String(total_code).split("\n");
for (int j = 0; j < lines.size(); j++) {
-
print_line(itos(line) + ": " + lines[j]);
line++;
}
@@ -130,13 +126,11 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
}
static String _mkid(const String &p_id) {
-
String id = "m_" + p_id;
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
ShaderGLES2::Version *ShaderGLES2::get_current_version() {
-
Version *_v = version_map.getptr(conditional_version);
if (_v) {
@@ -457,7 +451,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
}
GLint ShaderGLES2::get_uniform_location(const String &p_name) const {
-
ERR_FAIL_COND_V(!version, -1);
return glGetUniformLocation(version->id, p_name.ascii().get_data());
}
@@ -475,7 +468,6 @@ void ShaderGLES2::setup(
const char *p_fragment_code,
int p_vertex_code_start,
int p_fragment_code_start) {
-
ERR_FAIL_COND(version);
conditional_version.key = 0;
@@ -532,7 +524,6 @@ void ShaderGLES2::setup(
String code2;
if (cpos != -1) {
-
fragment_code1 = code.substr(0, cpos).ascii();
code2 = code.substr(cpos + light_code_tag.length(), code.length());
} else {
@@ -617,7 +608,6 @@ void ShaderGLES2::set_custom_shader(uint32_t p_code_id) {
}
void ShaderGLES2::free_custom_shader(uint32_t p_code_id) {
-
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
if (conditional_version.code_version == p_code_id) {
conditional_version.code_version = 0; //do not keep using a version that is going away
@@ -658,7 +648,6 @@ void ShaderGLES2::use_material(void *p_material) {
// bind uniforms
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = material->shader->uniforms.front(); E; E = E->next()) {
-
if (E->get().texture_order >= 0)
continue; // this is a texture, doesn't go here
@@ -673,7 +662,6 @@ void ShaderGLES2::use_material(void *p_material) {
if (V) {
switch (E->get().type) {
case ShaderLanguage::TYPE_BOOL: {
-
bool boolean = V->get();
glUniform1i(location, boolean ? 1 : 0);
} break;
@@ -684,7 +672,6 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_BVEC3: {
-
int flags = V->get();
glUniform3i(location, (flags & 1) ? 1 : 0, (flags & 2) ? 1 : 0, (flags & 4) ? 1 : 0);
@@ -704,7 +691,6 @@ void ShaderGLES2::use_material(void *p_material) {
case ShaderLanguage::TYPE_IVEC2:
case ShaderLanguage::TYPE_UVEC2: {
-
Array r = V->get();
const int count = 2;
if (r.size() == count) {
@@ -776,7 +762,6 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_MAT2: {
-
Transform2D tr = V->get();
GLfloat matrix[4] = {
/* build a 16x16 matrix */
@@ -809,7 +794,6 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_MAT4: {
-
Transform2D tr = V->get();
GLfloat matrix[16] = { /* build a 16x16 matrix */
tr.elements[0][0],
@@ -938,19 +922,15 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_SAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_ISAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_USAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE: {
-
} break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
@@ -1057,19 +1037,15 @@ void ShaderGLES2::use_material(void *p_material) {
} break;
case ShaderLanguage::TYPE_SAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_ISAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_USAMPLER2D: {
-
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE: {
-
} break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h
index d20d5bc585..3096c1e258 100644
--- a/drivers/gles2/shader_gles2.h
+++ b/drivers/gles2/shader_gles2.h
@@ -53,20 +53,17 @@ class RasterizerStorageGLES2;
class ShaderGLES2 {
protected:
struct Enum {
-
uint64_t mask;
uint64_t shift;
const char *defines[16];
};
struct EnumValue {
-
uint64_t set_mask;
uint64_t clear_mask;
};
struct AttributePair {
-
const char *name;
int index;
};
@@ -77,7 +74,6 @@ protected:
};
struct TexUnitPair {
-
const char *name;
int index;
};
@@ -94,7 +90,6 @@ private:
int attribute_pair_count;
struct CustomCode {
-
String vertex;
String vertex_globals;
String fragment;
@@ -108,7 +103,6 @@ private:
};
struct Version {
-
GLuint id;
GLuint vert_id;
GLuint frag_id;
@@ -130,7 +124,6 @@ private:
Version *version;
union VersionKey {
-
struct {
uint32_t version;
uint32_t code_version;
@@ -141,7 +134,6 @@ private:
};
struct VersionKeyHash {
-
static _FORCE_INLINE_ uint32_t hash(const VersionKey &p_key) { return HashMapHasherDefault::hash(p_key.key); }
};
@@ -252,14 +244,12 @@ public:
// called a lot, made inline
int ShaderGLES2::_get_uniform(int p_which) const {
-
ERR_FAIL_INDEX_V(p_which, uniform_count, -1);
ERR_FAIL_COND_V(!version, -1);
return version->uniform_location[p_which];
}
void ShaderGLES2::_set_conditional(int p_which, bool p_value) {
-
ERR_FAIL_INDEX(p_which, conditional_count);
if (p_value)
new_conditional_version.version |= (1 << p_which);
diff --git a/drivers/gles2/shaders/blend_shape.glsl b/drivers/gles2/shaders/blend_shape.glsl
index 0d0b3e24e4..e229da6f18 100644
--- a/drivers/gles2/shaders/blend_shape.glsl
+++ b/drivers/gles2/shaders/blend_shape.glsl
@@ -110,7 +110,6 @@ out vec4 weight_out; //tfb:ENABLE_SKELETON
uniform float blend_amount;
void main() {
-
#ifdef ENABLE_BLEND
vertex_out = vertex_attrib_blend + vertex_attrib * blend_amount;
@@ -191,4 +190,5 @@ void main() {
void main() {
}
+
/* clang-format on */
diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index 3b685b3f0b..1fadf44d97 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -111,7 +111,6 @@ vec2 select(vec2 a, vec2 b, bvec2 c) {
}
void main() {
-
vec4 color = color_attrib;
vec2 uv;
@@ -186,7 +185,6 @@ VERTEX_SHADER_CODE
// look up transform from the "pose texture"
if (bone_weights != vec4(0.0)) {
-
highp mat4 bone_transform = mat4(0.0);
for (int i = 0; i < 4; i++) {
@@ -367,7 +365,6 @@ LIGHT_SHADER_CODE
}
void main() {
-
vec4 color = color_interp;
vec2 uv = uv_interp;
#ifdef USE_FORCE_REPEAT
@@ -499,11 +496,9 @@ FRAGMENT_SHADER_CODE
point = -shadow_vec;
sh = 0.5 + (1.0 / 8.0);
} else if (angle_to_light > 0.0) {
-
point = vec2(shadow_vec.y, -shadow_vec.x);
sh = 0.25 + (1.0 / 8.0);
} else {
-
point = vec2(-shadow_vec.y, shadow_vec.x);
sh = 0.75 + (1.0 / 8.0);
}
diff --git a/drivers/gles2/shaders/canvas_shadow.glsl b/drivers/gles2/shaders/canvas_shadow.glsl
index 7a5ba4f571..2abcd5e67c 100644
--- a/drivers/gles2/shaders/canvas_shadow.glsl
+++ b/drivers/gles2/shaders/canvas_shadow.glsl
@@ -21,7 +21,6 @@ uniform highp float distance_norm;
varying highp vec4 position_interp;
void main() {
-
gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0)));
position_interp = gl_Position;
}
@@ -47,7 +46,6 @@ varying highp vec4 position_interp;
/* clang-format on */
void main() {
-
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
#ifdef USE_RGBA_SHADOWS
diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl
index aa967115da..e833722ac3 100644
--- a/drivers/gles2/shaders/copy.glsl
+++ b/drivers/gles2/shaders/copy.glsl
@@ -40,7 +40,6 @@ uniform highp mat4 display_transform;
#endif
void main() {
-
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
cube_interp = cube_in;
#elif defined(USE_ASYM_PANO)
@@ -115,7 +114,6 @@ uniform float custom_alpha;
uniform highp mat4 sky_transform;
vec4 texturePanorama(sampler2D pano, vec3 normal) {
-
vec2 st = vec2(
atan(normal.x, normal.z),
acos(normal.y));
@@ -131,7 +129,6 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) {
#endif
void main() {
-
#ifdef USE_PANORAMA
vec3 cube_normal = normalize(cube_interp);
diff --git a/drivers/gles2/shaders/cube_to_dp.glsl b/drivers/gles2/shaders/cube_to_dp.glsl
index 769908c3b4..1612ec3d5a 100644
--- a/drivers/gles2/shaders/cube_to_dp.glsl
+++ b/drivers/gles2/shaders/cube_to_dp.glsl
@@ -17,7 +17,6 @@ attribute vec2 uv_in; // attrib:4
varying vec2 uv_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
}
@@ -49,7 +48,6 @@ uniform highp float z_near;
uniform highp float bias;
void main() {
-
highp vec3 normal = vec3(uv_interp * 2.0 - 1.0, 0.0);
/*
if (z_flip) {
diff --git a/drivers/gles2/shaders/cubemap_filter.glsl b/drivers/gles2/shaders/cubemap_filter.glsl
index db3d8b3a1b..f5c91cc707 100644
--- a/drivers/gles2/shaders/cubemap_filter.glsl
+++ b/drivers/gles2/shaders/cubemap_filter.glsl
@@ -17,7 +17,6 @@ attribute highp vec2 uv; // attrib:4
varying highp vec2 uv_interp;
void main() {
-
uv_interp = uv;
gl_Position = vec4(vertex, 0, 1);
}
@@ -87,7 +86,6 @@ uniform sampler2D radical_inverse_vdc_cache; // texunit:1
#ifdef USE_SOURCE_PANORAMA
vec4 texturePanorama(sampler2D pano, vec3 normal) {
-
vec2 st = vec2(
atan(normal.x, normal.z),
acos(normal.y));
@@ -179,7 +177,6 @@ vec2 Hammersley(int i, int N) {
uniform bool z_flip;
void main() {
-
vec3 color = vec3(0.0);
vec2 uv = (uv_interp * 2.0) - 1.0;
@@ -200,7 +197,6 @@ void main() {
vec4 sum = vec4(0.0);
for (int sample_num = 0; sample_num < SAMPLE_COUNT; sample_num++) {
-
vec2 xi = Hammersley(sample_num, SAMPLE_COUNT);
vec3 H = ImportanceSampleGGX(xi, roughness, N);
diff --git a/drivers/gles2/shaders/effect_blur.glsl b/drivers/gles2/shaders/effect_blur.glsl
index b28d78a6ca..7b607dd76a 100644
--- a/drivers/gles2/shaders/effect_blur.glsl
+++ b/drivers/gles2/shaders/effect_blur.glsl
@@ -23,7 +23,6 @@ uniform vec4 blur_section;
#endif
void main() {
-
uv_interp = uv_in;
gl_Position = vec4(vertex_attrib, 0.0, 1.0);
#ifdef USE_BLUR_SECTION
@@ -127,7 +126,6 @@ uniform float camera_z_far;
uniform float camera_z_near;
void main() {
-
#ifdef GLOW_GAUSSIAN_HORIZONTAL
vec2 pix_size = pixel_size;
pix_size *= 0.5; //reading from larger buffer, so use more samples
@@ -228,7 +226,6 @@ void main() {
float k_accum = 0.0;
for (int i = 0; i < dof_kernel_size; i++) {
-
int int_ofs = i - dof_kernel_from;
vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * amount * dof_radius;
@@ -265,7 +262,6 @@ void main() {
float max_accum = 0.0;
for (int i = 0; i < dof_kernel_size; i++) {
-
int int_ofs = i - dof_kernel_from;
vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * dof_radius;
float ofs_influence = max(0.0, 1.0 - abs(float(int_ofs)) / float(dof_kernel_from));
diff --git a/drivers/gles2/shaders/exposure.glsl b/drivers/gles2/shaders/exposure.glsl
index 759adcda06..c20812bfa3 100644
--- a/drivers/gles2/shaders/exposure.glsl
+++ b/drivers/gles2/shaders/exposure.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
}
@@ -34,7 +33,6 @@ uniform highp float max_luminance;
layout(location = 0) out highp float exposure;
void main() {
-
#ifdef EXPOSURE_BEGIN
ivec2 src_pos = ivec2(gl_FragCoord.xy) * source_render_size / target_size;
diff --git a/drivers/gles2/shaders/lens_distorted.glsl b/drivers/gles2/shaders/lens_distorted.glsl
index f4ff80ba9a..d568006ccc 100644
--- a/drivers/gles2/shaders/lens_distorted.glsl
+++ b/drivers/gles2/shaders/lens_distorted.glsl
@@ -19,7 +19,6 @@ uniform vec2 scale;
varying vec2 uv_interp;
void main() {
-
uv_interp = vertex.xy * 2.0 - 1.0;
vec2 v = vertex.xy * scale + offset;
diff --git a/drivers/gles2/shaders/particles.glsl b/drivers/gles2/shaders/particles.glsl
index 5974050fc1..d762dade2f 100644
--- a/drivers/gles2/shaders/particles.glsl
+++ b/drivers/gles2/shaders/particles.glsl
@@ -10,7 +10,6 @@ layout(location = 4) in highp vec4 xform_2;
layout(location = 5) in highp vec4 xform_3;
struct Attractor {
-
vec3 pos;
vec3 dir;
float radius;
@@ -64,7 +63,6 @@ VERTEX_SHADER_GLOBALS
/* clang-format on */
uint hash(uint x) {
-
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
x = (x >> uint(16)) ^ x;
@@ -72,7 +70,6 @@ uint hash(uint x) {
}
void main() {
-
#ifdef PARTICLES_COPY
out_color = color;
@@ -183,10 +180,8 @@ VERTEX_SHADER_CODE
#if !defined(DISABLE_FORCE)
if (false) {
-
vec3 force = vec3(0.0);
for (int i = 0; i < attractor_count; i++) {
-
vec3 rel_vec = xform[3].xyz - attractors[i].pos;
float dist = length(rel_vec);
if (attractors[i].radius < dist)
@@ -214,7 +209,6 @@ VERTEX_SHADER_CODE
#if !defined(DISABLE_VELOCITY)
if (true) {
-
xform[3].xyz += out_velocity_active.xyz * local_delta;
}
#endif
@@ -263,4 +257,5 @@ FRAGMENT_SHADER_CODE
}
}
+
/* clang-format on */
diff --git a/drivers/gles2/shaders/resolve.glsl b/drivers/gles2/shaders/resolve.glsl
index 5c6f5d6561..071cb37a99 100644
--- a/drivers/gles2/shaders/resolve.glsl
+++ b/drivers/gles2/shaders/resolve.glsl
@@ -8,7 +8,6 @@ layout(location = 4) in vec2 uv_in;
out vec2 uv_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
}
@@ -32,7 +31,6 @@ in vec2 uv2_interp;
layout(location = 0) out vec4 frag_color;
void main() {
-
vec4 specular = texture(source_specular, uv_interp);
#ifdef USE_SSR
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index b720c71cec..0311dc4742 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -194,7 +194,6 @@ void light_compute(
vec3 light_color,
vec3 attenuation,
float roughness) {
-
//this makes lights behave closer to linear, but then addition of lights looks bad
//better left disabled
@@ -249,7 +248,6 @@ void light_compute(
diffuse_interp += light_color * diffuse_brdf_NL * attenuation;
if (roughness > 0.0) {
-
// D
float specular_brdf_NL = 0.0;
@@ -325,7 +323,6 @@ uniform mediump float fog_height_curve;
#endif //fog
void main() {
-
highp vec4 vertex = vertex_attrib;
mat4 world_matrix = world_transform;
@@ -394,7 +391,6 @@ void main() {
#else
// look up transform from the "pose texture"
{
-
for (int i = 0; i < 4; i++) {
ivec2 tex_ofs = ivec2(int(bone_ids[i]) * 3, 0);
@@ -512,7 +508,6 @@ VERTEX_SHADER_CODE
float normalized_distance = light_length / light_range;
if (normalized_distance < 1.0) {
-
float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation);
vec3 attenuation = vec3(omni_attenuation);
@@ -532,7 +527,6 @@ VERTEX_SHADER_CODE
float normalized_distance = light_length / light_range;
if (normalized_distance < 1.0) {
-
float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation);
vec3 spot_dir = light_direction;
@@ -541,7 +535,6 @@ VERTEX_SHADER_CODE
float angle = dot(-normalize(light_rel_vec), spot_dir);
if (angle > spot_cutoff) {
-
float scos = max(angle, spot_cutoff);
float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff));
@@ -645,7 +638,6 @@ VERTEX_SHADER_CODE
#ifdef FOG_DEPTH_ENABLED
{
-
float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a;
@@ -1073,6 +1065,7 @@ float G_GGX_2cos(float cos_theta_m, float alpha) {
// float sin2 = (1.0 - cos2);
// return 1.0 / (cos_theta_m + sqrt(cos2 + alpha * alpha * sin2));
}
+
*/
// This approximates G_GGX_2cos(cos_theta_l, alpha) * G_GGX_2cos(cos_theta_v, alpha)
@@ -1095,6 +1088,7 @@ float G_GGX_anisotropic_2cos(float cos_theta_m, float alpha_x, float alpha_y, fl
float s_y = alpha_y * sin_phi;
return 1.0 / max(cos_theta_m + sqrt(cos2 + (s_x * s_x + s_y * s_y) * sin2), 0.001);
}
+
*/
// This approximates G_GGX_anisotropic_2cos(cos_theta_l, ...) * G_GGX_anisotropic_2cos(cos_theta_v, ...)
@@ -1157,7 +1151,6 @@ void light_compute(
inout vec3 diffuse_light,
inout vec3 specular_light,
inout float alpha) {
-
//this makes lights behave closer to linear, but then addition of lights looks bad
//better left disabled
@@ -1381,7 +1374,6 @@ LIGHT_SHADER_CODE
#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(texture2DProj(p_shadow, p_pos)))
float sample_shadow(highp sampler2D shadow, highp vec4 spos) {
-
#ifdef SHADOW_MODE_PCF_13
spos.xyz /= spos.w;
@@ -1458,7 +1450,6 @@ uniform mediump float fog_height_curve;
#endif //fog
void main() {
-
#ifdef RENDER_DEPTH_DUAL_PARABOLOID
if (dp_clip > 0.0)
@@ -1653,7 +1644,6 @@ FRAGMENT_SHADER_CODE
// environment BRDF approximation
{
-
#if defined(DIFFUSE_TOON)
//simplify for toon, as
specular_light *= specular * metallic * albedo * 2.0;
@@ -1732,7 +1722,6 @@ FRAGMENT_SHADER_CODE
float normalized_distance = light_length / light_range;
if (normalized_distance < 1.0) {
-
float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation);
light_att = vec3(omni_attenuation);
@@ -1829,7 +1818,6 @@ FRAGMENT_SHADER_CODE
}
} else {
if (depth_z < light_split_offsets.z) {
-
shadow_att = shadow3;
#if defined(LIGHT_USE_PSSM_BLEND)
@@ -1838,7 +1826,6 @@ FRAGMENT_SHADER_CODE
#endif
} else {
-
shadow_att = shadow4;
pssm_fade = smoothstep(light_split_offsets.z, light_split_offsets.w, depth_z);
@@ -1881,7 +1868,6 @@ FRAGMENT_SHADER_CODE
pssm_blend = smoothstep(0.0, light_split_offsets.x, depth_z);
#endif
} else {
-
shadow_att = shadow2;
pssm_fade = smoothstep(light_split_offsets.x, light_split_offsets.y, depth_z);
#ifdef LIGHT_USE_PSSM_BLEND
@@ -1945,7 +1931,6 @@ FRAGMENT_SHADER_CODE
}
} else {
if (depth_z < light_split_offsets.z) {
-
pssm_coord = shadow_coord3;
#if defined(LIGHT_USE_PSSM_BLEND)
@@ -1954,7 +1939,6 @@ FRAGMENT_SHADER_CODE
#endif
} else {
-
pssm_coord = shadow_coord4;
pssm_fade = smoothstep(light_split_offsets.z, light_split_offsets.w, depth_z);
@@ -1968,7 +1952,6 @@ FRAGMENT_SHADER_CODE
#ifdef LIGHT_USE_PSSM2
if (depth_z < light_split_offsets.x) {
-
pssm_coord = shadow_coord;
#ifdef LIGHT_USE_PSSM_BLEND
@@ -1976,7 +1959,6 @@ FRAGMENT_SHADER_CODE
pssm_blend = smoothstep(0.0, light_split_offsets.x, depth_z);
#endif
} else {
-
pssm_coord = shadow_coord2;
pssm_fade = smoothstep(light_split_offsets.x, light_split_offsets.y, depth_z);
#ifdef LIGHT_USE_PSSM_BLEND
@@ -2165,7 +2147,6 @@ FRAGMENT_SHADER_CODE
#ifdef FOG_DEPTH_ENABLED
{
-
float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a;
diff --git a/drivers/gles2/shaders/screen_space_reflection.glsl b/drivers/gles2/shaders/screen_space_reflection.glsl
index a11da10b61..6b5b7c885c 100644
--- a/drivers/gles2/shaders/screen_space_reflection.glsl
+++ b/drivers/gles2/shaders/screen_space_reflection.glsl
@@ -9,7 +9,6 @@ out vec2 uv_interp;
out vec2 pos_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
pos_interp.xy = gl_Position.xy;
@@ -55,7 +54,6 @@ vec2 view_to_screen(vec3 view_pos, out float w) {
#define M_PI 3.14159265359
void main() {
-
vec4 diffuse = texture(source_diffuse, uv_interp);
vec4 normal_roughness = texture(source_normal_roughness, uv_interp);
@@ -142,7 +140,6 @@ void main() {
float steps_taken = 0.0;
for (int i = 0; i < num_steps; i++) {
-
pos += line_advance;
z += z_advance;
w += w_advance;
@@ -174,7 +171,6 @@ void main() {
}
if (found) {
-
float margin_blend = 1.0;
vec2 margin = vec2((viewport_size.x + viewport_size.y) * 0.5 * 0.05); //make a uniform margin
@@ -218,7 +214,6 @@ void main() {
final_color = vec4(0.0);
for (int i = 0; i < 7; i++) {
-
float op_len = 2.0 * tan(cone_angle) * cone_len; //opposite side of iso triangle
float radius;
{
diff --git a/drivers/gles2/shaders/ssao.glsl b/drivers/gles2/shaders/ssao.glsl
index 82eea8f274..0fd29e8dcc 100644
--- a/drivers/gles2/shaders/ssao.glsl
+++ b/drivers/gles2/shaders/ssao.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
gl_Position.z = 1.0;
}
@@ -207,7 +206,6 @@ float sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in f
}
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_FragCoord.xy);
diff --git a/drivers/gles2/shaders/ssao_blur.glsl b/drivers/gles2/shaders/ssao_blur.glsl
index e4133ad534..f065cd74eb 100644
--- a/drivers/gles2/shaders/ssao_blur.glsl
+++ b/drivers/gles2/shaders/ssao_blur.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
gl_Position.z = 1.0;
}
@@ -58,7 +57,6 @@ uniform float camera_z_near;
uniform ivec2 screen_size;
void main() {
-
ivec2 ssC = ivec2(gl_FragCoord.xy);
float depth = texelFetch(source_depth, ssC, 0).r;
@@ -91,7 +89,6 @@ void main() {
// We already handled the zero case above. This loop should be unrolled and the static branch optimized out,
// so the IF statement has no runtime cost
if (r != 0) {
-
ivec2 ppos = ssC + axis * (r * filter_scale);
float value = texelFetch(source_ssao, clamp(ppos, ivec2(0), clamp_limit), 0).r;
ivec2 rpos = clamp(ppos, ivec2(0), clamp_limit);
diff --git a/drivers/gles2/shaders/ssao_minify.glsl b/drivers/gles2/shaders/ssao_minify.glsl
index 272f3e236e..f654e00a4f 100644
--- a/drivers/gles2/shaders/ssao_minify.glsl
+++ b/drivers/gles2/shaders/ssao_minify.glsl
@@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib;
/* clang-format on */
void main() {
-
gl_Position = vertex_attrib;
}
@@ -33,7 +32,6 @@ uniform int source_mipmap;
layout(location = 0) out mediump uint depth;
void main() {
-
ivec2 ssP = ivec2(gl_FragCoord.xy);
// Rotated grid subsampling to avoid XY directional bias or Z precision bias while downsampling.
diff --git a/drivers/gles2/shaders/subsurf_scattering.glsl b/drivers/gles2/shaders/subsurf_scattering.glsl
index f40fb3a244..d0c34cf1b0 100644
--- a/drivers/gles2/shaders/subsurf_scattering.glsl
+++ b/drivers/gles2/shaders/subsurf_scattering.glsl
@@ -8,7 +8,6 @@ layout(location = 4) in vec2 uv_in;
out vec2 uv_interp;
void main() {
-
uv_interp = uv_in;
gl_Position = vertex_attrib;
}
@@ -102,7 +101,6 @@ uniform sampler2D source_depth; //texunit:2
layout(location = 0) out vec4 frag_color;
void main() {
-
float strength = texture(source_sss, uv_interp).r;
strength *= strength; //stored as sqrt
@@ -110,7 +108,6 @@ void main() {
vec4 base_color = texture(source_diffuse, uv_interp);
if (strength > 0.0) {
-
// Fetch linear depth of current pixel:
float depth = texture(source_depth, uv_interp).r * 2.0 - 1.0;
#ifdef USE_ORTHOGONAL_PROJECTION
diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp
index 4cb93a821c..8af58a7ed7 100644
--- a/drivers/png/image_loader_png.cpp
+++ b/drivers/png/image_loader_png.cpp
@@ -37,7 +37,6 @@
#include <string.h>
Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
const size_t buffer_size = f->get_len();
Vector<uint8_t> file_buffer;
Error err = file_buffer.resize(buffer_size);
@@ -55,12 +54,10 @@ Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("png");
}
Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) {
-
Ref<Image> img;
img.instance();
@@ -71,7 +68,6 @@ Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) {
}
Ref<Image> ImageLoaderPNG::lossless_unpack_png(const Vector<uint8_t> &p_data) {
-
const int len = p_data.size();
ERR_FAIL_COND_V(len < 4, Ref<Image>());
const uint8_t *r = p_data.ptr();
@@ -80,7 +76,6 @@ Ref<Image> ImageLoaderPNG::lossless_unpack_png(const Vector<uint8_t> &p_data) {
}
Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) {
-
Vector<uint8_t> out_buffer;
// add Godot's own "PNG " prefix
@@ -104,7 +99,6 @@ Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) {
}
ImageLoaderPNG::ImageLoaderPNG() {
-
Image::_png_mem_loader_func = load_mem_png;
Image::lossless_unpacker = lossless_unpack_png;
Image::lossless_packer = lossless_pack_png;
diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp
index f17abcb54c..77d5e68826 100644
--- a/drivers/png/png_driver_common.cpp
+++ b/drivers/png/png_driver_common.cpp
@@ -59,7 +59,6 @@ static bool check_error(const png_image &image) {
}
Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
-
png_image png_img;
zeromem(&png_img, sizeof(png_img));
png_img.version = PNG_IMAGE_VERSION;
@@ -115,17 +114,17 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
//print_line("png width: "+itos(png_img.width)+" height: "+itos(png_img.height));
- p_image->create(png_img.width, png_img.height, 0, dest_format, buffer);
+ p_image->create(png_img.width, png_img.height, false, dest_format, buffer);
return OK;
}
Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
-
Ref<Image> source_image = p_image->duplicate();
- if (source_image->is_compressed())
+ if (source_image->is_compressed()) {
source_image->decompress();
+ }
ERR_FAIL_COND_V(source_image->is_compressed(), FAILED);
@@ -179,7 +178,6 @@ Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
}
if (!success) {
-
// buffer was big enough, must be some other error
ERR_FAIL_COND_V(compressed_size <= png_size_estimate, FAILED);
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp
index 2380c2685f..3a0b319a45 100644
--- a/drivers/png/resource_saver_png.cpp
+++ b/drivers/png/resource_saver_png.cpp
@@ -36,7 +36,6 @@
#include "scene/resources/texture.h"
Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<ImageTexture> texture = p_resource;
ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG.");
@@ -50,7 +49,6 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32
};
Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) {
-
Vector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG.");
@@ -72,7 +70,6 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img
}
Vector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img) {
-
Vector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
ERR_FAIL_COND_V_MSG(err, Vector<uint8_t>(), "Can't convert image to PNG.");
@@ -80,19 +77,16 @@ Vector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img)
}
bool ResourceSaverPNG::recognize(const RES &p_resource) const {
-
return (p_resource.is_valid() && p_resource->is_class("ImageTexture"));
}
void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (Object::cast_to<ImageTexture>(*p_resource)) {
p_extensions->push_back("png");
}
}
ResourceSaverPNG::ResourceSaverPNG() {
-
Image::save_png_func = &save_image;
Image::save_png_buffer_func = &save_image_to_buffer;
};
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 8a47f6cf96..a6bc4f3b2c 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -78,7 +78,6 @@ void AudioDriverPulseAudio::pa_source_info_cb(pa_context *c, const pa_source_inf
}
void AudioDriverPulseAudio::pa_server_info_cb(pa_context *c, const pa_server_info *i, void *userdata) {
-
ERR_FAIL_COND_MSG(!i, "PulseAudio server info is null.");
AudioDriverPulseAudio *ad = (AudioDriverPulseAudio *)userdata;
@@ -88,7 +87,6 @@ void AudioDriverPulseAudio::pa_server_info_cb(pa_context *c, const pa_server_inf
}
void AudioDriverPulseAudio::detect_channels(bool capture) {
-
pa_channel_map_init_stereo(capture ? &pa_rec_map : &pa_map);
String device = capture ? capture_device_name : device_name;
@@ -145,7 +143,6 @@ void AudioDriverPulseAudio::detect_channels(bool capture) {
}
Error AudioDriverPulseAudio::init_device() {
-
// If there is a specified device check that it is really present
if (device_name != "Default") {
Array list = get_device_list();
@@ -182,7 +179,7 @@ Error AudioDriverPulseAudio::init_device() {
break;
}
- int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+ int latency = GLOBAL_GET("audio/output_latency");
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
pa_buffer_size = buffer_frames * pa_map.channels;
@@ -236,12 +233,11 @@ Error AudioDriverPulseAudio::init_device() {
}
Error AudioDriverPulseAudio::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
- mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
pa_ml = pa_mainloop_new();
ERR_FAIL_COND_V(pa_ml == nullptr, ERR_CANT_OPEN);
@@ -298,7 +294,6 @@ Error AudioDriverPulseAudio::init() {
}
float AudioDriverPulseAudio::get_latency() {
-
if (latency == 0) { //only do this once since it's approximate anyway
lock();
@@ -324,14 +319,12 @@ float AudioDriverPulseAudio::get_latency() {
}
void AudioDriverPulseAudio::thread_func(void *p_udata) {
-
AudioDriverPulseAudio *ad = (AudioDriverPulseAudio *)p_udata;
unsigned int write_ofs = 0;
size_t avail_bytes = 0;
uint32_t default_device_msec = OS::get_singleton()->get_ticks_msec();
while (!ad->exit_thread) {
-
size_t read_bytes = 0;
size_t written_bytes = 0;
@@ -421,7 +414,6 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
// If we're using the default device check that the current device is still the default
if (ad->device_name == "Default") {
-
uint32_t msec = OS::get_singleton()->get_ticks_msec();
if (msec > (default_device_msec + 1000)) {
String old_default_device = ad->default_device;
@@ -524,17 +516,14 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
}
void AudioDriverPulseAudio::start() {
-
active = true;
}
int AudioDriverPulseAudio::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverPulseAudio::get_speaker_mode() const {
-
return get_speaker_mode_by_total_channels(channels);
}
@@ -551,7 +540,6 @@ void AudioDriverPulseAudio::pa_sinklist_cb(pa_context *c, const pa_sink_info *l,
}
Array AudioDriverPulseAudio::get_device_list() {
-
pa_devices.clear();
pa_devices.push_back("Default");
@@ -583,33 +571,30 @@ Array AudioDriverPulseAudio::get_device_list() {
}
String AudioDriverPulseAudio::get_device() {
-
return device_name;
}
void AudioDriverPulseAudio::set_device(String device) {
-
lock();
new_device = device;
unlock();
}
void AudioDriverPulseAudio::lock() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
mutex.lock();
}
void AudioDriverPulseAudio::unlock() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
mutex.unlock();
}
void AudioDriverPulseAudio::finish_device() {
-
if (pa_str) {
pa_stream_disconnect(pa_str);
pa_stream_unref(pa_str);
@@ -618,9 +603,9 @@ void AudioDriverPulseAudio::finish_device() {
}
void AudioDriverPulseAudio::finish() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -644,7 +629,6 @@ void AudioDriverPulseAudio::finish() {
}
Error AudioDriverPulseAudio::capture_init_device() {
-
// If there is a specified device check that it is really present
if (capture_device_name != "Default") {
Array list = capture_get_device_list();
@@ -702,7 +686,6 @@ Error AudioDriverPulseAudio::capture_init_device() {
}
void AudioDriverPulseAudio::capture_finish_device() {
-
if (pa_rec_str) {
int ret = pa_stream_disconnect(pa_rec_str);
if (ret != 0) {
@@ -714,7 +697,6 @@ void AudioDriverPulseAudio::capture_finish_device() {
}
Error AudioDriverPulseAudio::capture_start() {
-
lock();
Error err = capture_init_device();
unlock();
@@ -731,7 +713,6 @@ Error AudioDriverPulseAudio::capture_stop() {
}
void AudioDriverPulseAudio::capture_set_device(const String &p_name) {
-
lock();
capture_new_device = p_name;
unlock();
@@ -753,7 +734,6 @@ void AudioDriverPulseAudio::pa_sourcelist_cb(pa_context *c, const pa_source_info
}
Array AudioDriverPulseAudio::capture_get_device_list() {
-
pa_rec_devices.clear();
pa_rec_devices.push_back("Default");
@@ -785,7 +765,6 @@ Array AudioDriverPulseAudio::capture_get_device_list() {
}
String AudioDriverPulseAudio::capture_get_device() {
-
lock();
String name = capture_device_name;
unlock();
@@ -793,30 +772,9 @@ String AudioDriverPulseAudio::capture_get_device() {
return name;
}
-AudioDriverPulseAudio::AudioDriverPulseAudio() :
- thread(nullptr),
- pa_ml(nullptr),
- pa_ctx(nullptr),
- pa_str(nullptr),
- pa_rec_str(nullptr),
- device_name("Default"),
- new_device("Default"),
- default_device(""),
- mix_rate(0),
- buffer_frames(0),
- pa_buffer_size(0),
- channels(0),
- pa_ready(0),
- pa_status(0),
- active(false),
- thread_exited(false),
- exit_thread(false),
- latency(0) {
+AudioDriverPulseAudio::AudioDriverPulseAudio() {
samples_in.clear();
samples_out.clear();
}
-AudioDriverPulseAudio::~AudioDriverPulseAudio() {
-}
-
-#endif
+#endif // PULSEAUDIO_ENABLED
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index 1ece332a8a..2f2ad0fc38 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -40,19 +40,18 @@
#include <pulse/pulseaudio.h>
class AudioDriverPulseAudio : public AudioDriver {
-
- Thread *thread;
+ Thread *thread = nullptr;
Mutex mutex;
- pa_mainloop *pa_ml;
- pa_context *pa_ctx;
- pa_stream *pa_str;
- pa_stream *pa_rec_str;
+ pa_mainloop *pa_ml = nullptr;
+ pa_context *pa_ctx = nullptr;
+ pa_stream *pa_str = nullptr;
+ pa_stream *pa_rec_str = nullptr;
pa_channel_map pa_map;
pa_channel_map pa_rec_map;
- String device_name;
- String new_device;
+ String device_name = "Default";
+ String new_device = "Default";
String default_device;
String capture_device_name;
@@ -62,20 +61,20 @@ class AudioDriverPulseAudio : public AudioDriver {
Vector<int32_t> samples_in;
Vector<int16_t> samples_out;
- unsigned int mix_rate;
- unsigned int buffer_frames;
- unsigned int pa_buffer_size;
- int channels;
- int pa_ready;
- int pa_status;
+ unsigned int mix_rate = 0;
+ unsigned int buffer_frames = 0;
+ unsigned int pa_buffer_size = 0;
+ int channels = 0;
+ int pa_ready = 0;
+ int pa_status = 0;
Array pa_devices;
Array pa_rec_devices;
- bool active;
- bool thread_exited;
- mutable bool exit_thread;
+ bool active = false;
+ bool thread_exited = false;
+ mutable bool exit_thread = false;
- float latency;
+ float latency = 0;
static void pa_state_cb(pa_context *c, void *userdata);
static void pa_sink_info_cb(pa_context *c, const pa_sink_info *l, int eol, void *userdata);
@@ -122,7 +121,7 @@ public:
virtual Error capture_stop();
AudioDriverPulseAudio();
- ~AudioDriverPulseAudio();
+ ~AudioDriverPulseAudio() {}
};
#endif // AUDIO_DRIVER_PULSEAUDIO_H
diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp
index dcc7a5c14d..f0deabec21 100644
--- a/drivers/register_driver_types.cpp
+++ b/drivers/register_driver_types.cpp
@@ -37,7 +37,6 @@ static ImageLoaderPNG *image_loader_png;
static Ref<ResourceSaverPNG> resource_saver_png;
void register_core_driver_types() {
-
image_loader_png = memnew(ImageLoaderPNG);
ImageLoader::add_image_format_loader(image_loader_png);
@@ -46,9 +45,9 @@ void register_core_driver_types() {
}
void unregister_core_driver_types() {
-
- if (image_loader_png)
+ if (image_loader_png) {
memdelete(image_loader_png);
+ }
ResourceSaver::remove_resource_format_saver(resource_saver_png);
resource_saver_png.unref();
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 00103684c7..325a88b573 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -50,12 +50,10 @@
#endif
DirAccess *DirAccessUnix::create_fs() {
-
return memnew(DirAccessUnix);
}
Error DirAccessUnix::list_dir_begin() {
-
list_dir_end(); //close any previous dir opening!
//char real_current_dir_name[2048]; //is this enough?!
@@ -63,18 +61,19 @@ Error DirAccessUnix::list_dir_begin() {
//chdir(current_path.utf8().get_data());
dir_stream = opendir(current_dir.utf8().get_data());
//chdir(real_current_dir_name);
- if (!dir_stream)
+ if (!dir_stream) {
return ERR_CANT_OPEN; //error!
+ }
return OK;
}
bool DirAccessUnix::file_exists(String p_file) {
-
GLOBAL_LOCK_FUNCTION
- if (p_file.is_rel_path())
+ if (p_file.is_rel_path()) {
p_file = current_dir.plus_file(p_file);
+ }
p_file = fix_path(p_file);
@@ -89,11 +88,11 @@ bool DirAccessUnix::file_exists(String p_file) {
}
bool DirAccessUnix::dir_exists(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
- if (p_dir.is_rel_path())
+ if (p_dir.is_rel_path()) {
p_dir = get_current_dir().plus_file(p_dir);
+ }
p_dir = fix_path(p_dir);
@@ -104,9 +103,9 @@ bool DirAccessUnix::dir_exists(String p_dir) {
}
uint64_t DirAccessUnix::get_modified_time(String p_file) {
-
- if (p_file.is_rel_path())
+ if (p_file.is_rel_path()) {
p_file = current_dir.plus_file(p_file);
+ }
p_file = fix_path(p_file);
@@ -116,16 +115,15 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) {
if (success) {
return flags.st_mtime;
} else {
-
ERR_FAIL_V(0);
};
return 0;
};
String DirAccessUnix::get_next() {
-
- if (!dir_stream)
+ if (!dir_stream) {
return "";
+ }
dirent *entry = readdir(dir_stream);
@@ -160,19 +158,17 @@ String DirAccessUnix::get_next() {
}
bool DirAccessUnix::current_is_dir() const {
-
return _cisdir;
}
bool DirAccessUnix::current_is_hidden() const {
-
return _cishidden;
}
void DirAccessUnix::list_dir_end() {
-
- if (dir_stream)
+ if (dir_stream) {
closedir(dir_stream);
+ }
dir_stream = nullptr;
_cisdir = false;
}
@@ -198,7 +194,6 @@ static bool _filter_drive(struct mntent *mnt) {
#endif
static void _get_drives(List<String> *list) {
-
#if defined(HAVE_MNTENT) && defined(X11_ENABLED)
// Check /etc/mtab for the list of mounted partitions
FILE *mtab = setmntent("/etc/mtab", "r");
@@ -252,7 +247,6 @@ static void _get_drives(List<String> *list) {
}
int DirAccessUnix::get_drive_count() {
-
List<String> list;
_get_drives(&list);
@@ -260,7 +254,6 @@ int DirAccessUnix::get_drive_count() {
}
String DirAccessUnix::get_drive(int p_drive) {
-
List<String> list;
_get_drives(&list);
@@ -270,16 +263,15 @@ String DirAccessUnix::get_drive(int p_drive) {
}
bool DirAccessUnix::drives_are_shortcuts() {
-
return true;
}
Error DirAccessUnix::make_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
- if (p_dir.is_rel_path())
+ if (p_dir.is_rel_path()) {
p_dir = get_current_dir().plus_file(p_dir);
+ }
p_dir = fix_path(p_dir);
@@ -298,7 +290,6 @@ Error DirAccessUnix::make_dir(String p_dir) {
}
Error DirAccessUnix::change_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
p_dir = fix_path(p_dir);
@@ -307,8 +298,9 @@ Error DirAccessUnix::change_dir(String p_dir) {
String prev_dir;
char real_current_dir_name[2048];
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG);
- if (prev_dir.parse_utf8(real_current_dir_name))
+ if (prev_dir.parse_utf8(real_current_dir_name)) {
prev_dir = real_current_dir_name; //no utf8, maybe latin?
+ }
// try_dir is the directory we are trying to change into
String try_dir = "";
@@ -343,28 +335,28 @@ Error DirAccessUnix::change_dir(String p_dir) {
}
String DirAccessUnix::get_current_dir(bool p_include_drive) {
-
String base = _get_root_path();
if (base != "") {
-
String bd = current_dir.replace_first(base, "");
- if (bd.begins_with("/"))
+ if (bd.begins_with("/")) {
return _get_root_string() + bd.substr(1, bd.length());
- else
+ } else {
return _get_root_string() + bd;
+ }
}
return current_dir;
}
Error DirAccessUnix::rename(String p_path, String p_new_path) {
-
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
p_path = get_current_dir().plus_file(p_path);
+ }
p_path = fix_path(p_path);
- if (p_new_path.is_rel_path())
+ if (p_new_path.is_rel_path()) {
p_new_path = get_current_dir().plus_file(p_new_path);
+ }
p_new_path = fix_path(p_new_path);
@@ -372,28 +364,28 @@ Error DirAccessUnix::rename(String p_path, String p_new_path) {
}
Error DirAccessUnix::remove(String p_path) {
-
- if (p_path.is_rel_path())
+ if (p_path.is_rel_path()) {
p_path = get_current_dir().plus_file(p_path);
+ }
p_path = fix_path(p_path);
struct stat flags;
- if ((stat(p_path.utf8().get_data(), &flags) != 0))
+ if ((stat(p_path.utf8().get_data(), &flags) != 0)) {
return FAILED;
+ }
- if (S_ISDIR(flags.st_mode))
+ if (S_ISDIR(flags.st_mode)) {
return ::rmdir(p_path.utf8().get_data()) == 0 ? OK : FAILED;
- else
+ } else {
return ::unlink(p_path.utf8().get_data()) == 0 ? OK : FAILED;
+ }
}
size_t DirAccessUnix::get_space_left() {
-
#ifndef NO_STATVFS
struct statvfs vfs;
if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
-
return 0;
};
@@ -409,7 +401,6 @@ String DirAccessUnix::get_filesystem_type() const {
}
DirAccessUnix::DirAccessUnix() {
-
dir_stream = nullptr;
_cisdir = false;
@@ -418,14 +409,14 @@ DirAccessUnix::DirAccessUnix() {
// set current directory to an absolute path of the current directory
char real_current_dir_name[2048];
ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == nullptr);
- if (current_dir.parse_utf8(real_current_dir_name))
+ if (current_dir.parse_utf8(real_current_dir_name)) {
current_dir = real_current_dir_name;
+ }
change_dir(current_dir);
}
DirAccessUnix::~DirAccessUnix() {
-
list_dir_end();
}
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index b403d8e356..b897efcafc 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -41,7 +41,6 @@
#include <unistd.h>
class DirAccessUnix : public DirAccess {
-
DIR *dir_stream;
static DirAccess *create_fs();
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 4aa408a1f0..06bad9f385 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -63,19 +63,17 @@
#endif
void FileAccessUnix::check_errors() const {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
if (feof(f)) {
-
last_error = ERR_FILE_EOF;
}
}
Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
-
- if (f)
+ if (f) {
fclose(f);
+ }
f = nullptr;
path_src = p_path;
@@ -85,16 +83,17 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
ERR_FAIL_COND_V_MSG(f, ERR_ALREADY_IN_USE, "File is already in use.");
const char *mode_string;
- if (p_mode_flags == READ)
+ if (p_mode_flags == READ) {
mode_string = "rb";
- else if (p_mode_flags == WRITE)
+ } else if (p_mode_flags == WRITE) {
mode_string = "wb";
- else if (p_mode_flags == READ_WRITE)
+ } else if (p_mode_flags == READ_WRITE) {
mode_string = "rb+";
- else if (p_mode_flags == WRITE_READ)
+ } else if (p_mode_flags == WRITE_READ) {
mode_string = "wb+";
- else
+ } else {
return ERR_INVALID_PARAMETER;
+ }
/* pretty much every implementation that uses fopen as primary
backend (unix-compatible mostly) supports utf8 encoding */
@@ -150,9 +149,9 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessUnix::close() {
-
- if (!f)
+ if (!f) {
return;
+ }
fclose(f);
f = nullptr;
@@ -174,39 +173,35 @@ void FileAccessUnix::close() {
}
bool FileAccessUnix::is_open() const {
-
return (f != nullptr);
}
String FileAccessUnix::get_path() const {
-
return path_src;
}
String FileAccessUnix::get_path_absolute() const {
-
return path;
}
void FileAccessUnix::seek(size_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
last_error = OK;
- if (fseek(f, p_position, SEEK_SET))
+ if (fseek(f, p_position, SEEK_SET)) {
check_errors();
+ }
}
void FileAccessUnix::seek_end(int64_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
- if (fseek(f, p_position, SEEK_END))
+ if (fseek(f, p_position, SEEK_END)) {
check_errors();
+ }
}
size_t FileAccessUnix::get_position() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
long pos = ftell(f);
@@ -218,7 +213,6 @@ size_t FileAccessUnix::get_position() const {
}
size_t FileAccessUnix::get_len() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
long pos = ftell(f);
@@ -232,12 +226,10 @@ size_t FileAccessUnix::get_len() const {
}
bool FileAccessUnix::eof_reached() const {
-
return last_error == ERR_FILE_EOF;
}
uint8_t FileAccessUnix::get_8() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
uint8_t b;
if (fread(&b, 1, 1, f) == 0) {
@@ -248,7 +240,6 @@ uint8_t FileAccessUnix::get_8() const {
}
int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
int read = fread(p_dst, 1, p_length, f);
check_errors();
@@ -256,44 +247,41 @@ int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {
};
Error FileAccessUnix::get_error() const {
-
return last_error;
}
void FileAccessUnix::flush() {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
fflush(f);
}
void FileAccessUnix::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND(fwrite(&p_dest, 1, 1, f) != 1);
}
void FileAccessUnix::store_buffer(const uint8_t *p_src, int p_length) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND(!p_src);
ERR_FAIL_COND((int)fwrite(p_src, 1, p_length, f) != p_length);
}
bool FileAccessUnix::file_exists(const String &p_path) {
-
int err;
struct stat st;
String filename = fix_path(p_path);
// Does the name exist at all?
err = stat(filename.utf8().get_data(), &st);
- if (err)
+ if (err) {
return false;
+ }
#ifdef UNIX_ENABLED
// See if we have access to the file
- if (access(filename.utf8().get_data(), F_OK))
+ if (access(filename.utf8().get_data(), F_OK)) {
return false;
+ }
#else
if (_access(filename.utf8().get_data(), 4) == -1)
return false;
@@ -310,7 +298,6 @@ bool FileAccessUnix::file_exists(const String &p_path) {
}
uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
-
String file = fix_path(p_file);
struct stat flags;
int err = stat(file.utf8().get_data(), &flags);
@@ -323,7 +310,6 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
}
uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
-
String file = fix_path(p_file);
struct stat flags;
int err = stat(file.utf8().get_data(), &flags);
@@ -336,7 +322,6 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) {
}
Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
-
String file = fix_path(p_file);
int err = chmod(file.utf8().get_data(), p_permissions);
@@ -348,20 +333,12 @@ Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_per
}
FileAccess *FileAccessUnix::create_libc() {
-
return memnew(FileAccessUnix);
}
CloseNotificationFunc FileAccessUnix::close_notification_func = nullptr;
-FileAccessUnix::FileAccessUnix() :
- f(nullptr),
- flags(0),
- last_error(OK) {
-}
-
FileAccessUnix::~FileAccessUnix() {
-
close();
}
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 8116f72345..9fe43a2554 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -41,11 +41,10 @@
typedef void (*CloseNotificationFunc)(const String &p_file, int p_flags);
class FileAccessUnix : public FileAccess {
-
- FILE *f;
- int flags;
+ FILE *f = nullptr;
+ int flags = 0;
void check_errors() const;
- mutable Error last_error;
+ mutable Error last_error = OK;
String save_path;
String path;
String path_src;
@@ -84,7 +83,7 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file);
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
- FileAccessUnix();
+ FileAccessUnix() {}
virtual ~FileAccessUnix();
};
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp
index 56be9a2f74..05eedccc1d 100644
--- a/drivers/unix/ip_unix.cpp
+++ b/drivers/unix/ip_unix.cpp
@@ -76,7 +76,6 @@
#endif
static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
-
IP_Address ip;
if (p_addr->sa_family == AF_INET) {
@@ -91,7 +90,6 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
};
IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
-
struct addrinfo hints;
struct addrinfo *result;
@@ -115,8 +113,9 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
if (result == nullptr || result->ai_addr == nullptr) {
ERR_PRINT("Invalid response from getaddrinfo");
- if (result)
+ if (result) {
freeaddrinfo(result);
+ }
return IP_Address();
};
@@ -132,7 +131,6 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
#if defined(UWP_ENABLED)
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
-
using namespace Windows::Networking;
using namespace Windows::Networking::Connectivity;
@@ -140,7 +138,6 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
auto hostnames = NetworkInformation::GetHostNames();
for (int i = 0; i < hostnames->Size; i++) {
-
auto hostname = hostnames->GetAt(i);
if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6)
@@ -167,12 +164,10 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
#else
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
-
ULONG buf_size = 1024;
IP_ADAPTER_ADDRESSES *addrs;
while (true) {
-
addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size);
int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME,
nullptr, addrs, &buf_size);
@@ -190,7 +185,6 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
IP_ADAPTER_ADDRESSES *adapter = addrs;
while (adapter != nullptr) {
-
Interface_Info info;
info.name = adapter->AdapterName;
info.name_friendly = adapter->FriendlyName;
@@ -218,7 +212,6 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
#else // UNIX
void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const {
-
struct ifaddrs *ifAddrStruct = nullptr;
struct ifaddrs *ifa = nullptr;
int family;
@@ -226,13 +219,15 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
getifaddrs(&ifAddrStruct);
for (ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) {
- if (!ifa->ifa_addr)
+ if (!ifa->ifa_addr) {
continue;
+ }
family = ifa->ifa_addr->sa_family;
- if (family != AF_INET && family != AF_INET6)
+ if (family != AF_INET && family != AF_INET6) {
continue;
+ }
Map<String, Interface_Info>::Element *E = r_interfaces->find(ifa->ifa_name);
if (!E) {
@@ -248,18 +243,17 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co
info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr));
}
- if (ifAddrStruct != nullptr)
+ if (ifAddrStruct != nullptr) {
freeifaddrs(ifAddrStruct);
+ }
}
#endif
void IP_Unix::make_default() {
-
_create = _create_unix;
}
IP *IP_Unix::_create_unix() {
-
return memnew(IP_Unix);
}
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index 7c6543c3a2..15ad187ab4 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -96,7 +96,6 @@
#endif
size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const IP_Address &p_ip, uint16_t p_port, IP::Type p_ip_type) {
-
memset(p_addr, 0, sizeof(struct sockaddr_storage));
if (p_ip_type == IP::TYPE_IPV6 || p_ip_type == IP::TYPE_ANY) { // IPv6 socket
@@ -132,16 +131,13 @@ size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const
}
void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IP_Address &r_ip, uint16_t &r_port) {
-
if (p_addr->ss_family == AF_INET) {
-
struct sockaddr_in *addr4 = (struct sockaddr_in *)p_addr;
r_ip.set_ipv4((uint8_t *)&(addr4->sin_addr.s_addr));
r_port = ntohs(addr4->sin_port);
} else if (p_addr->ss_family == AF_INET6) {
-
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr;
r_ip.set_ipv6(addr6->sin6_addr.s6_addr);
@@ -173,9 +169,7 @@ void NetSocketPosix::cleanup() {
}
NetSocketPosix::NetSocketPosix() :
- _sock(SOCK_EMPTY),
- _ip_type(IP::TYPE_NONE),
- _is_stream(false) {
+ _sock(SOCK_EMPTY) {
}
NetSocketPosix::~NetSocketPosix() {
@@ -202,12 +196,15 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
print_verbose("Socket error: " + itos(err));
return ERR_NET_OTHER;
#else
- if (errno == EISCONN)
+ if (errno == EISCONN) {
return ERR_NET_IS_CONNECTED;
- if (errno == EINPROGRESS || errno == EALREADY)
+ }
+ if (errno == EINPROGRESS || errno == EALREADY) {
return ERR_NET_IN_PROGRESS;
- if (errno == EAGAIN || errno == EWOULDBLOCK)
+ }
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
return ERR_NET_WOULD_BLOCK;
+ }
print_verbose("Socket error: " + itos(errno));
return ERR_NET_OTHER;
#endif
@@ -218,7 +215,6 @@ NetSocketPosix::NetError NetSocketPosix::_get_socket_error() const {
#endif
bool NetSocketPosix::_can_use_ip(const IP_Address &p_ip, const bool p_for_bind) const {
-
if (p_for_bind && !(p_ip.is_valid() || p_ip.is_wildcard())) {
return false;
} else if (!p_for_bind && !p_ip.is_valid()) {
@@ -230,7 +226,6 @@ bool NetSocketPosix::_can_use_ip(const IP_Address &p_ip, const bool p_for_bind)
}
_FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, String p_if_name, bool p_add) {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!_can_use_ip(p_ip, false), ERR_INVALID_PARAMETER);
@@ -246,16 +241,19 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, St
IP::get_singleton()->get_local_interfaces(&if_info);
for (Map<String, IP::Interface_Info>::Element *E = if_info.front(); E; E = E->next()) {
IP::Interface_Info &c = E->get();
- if (c.name != p_if_name)
+ if (c.name != p_if_name) {
continue;
+ }
if_v6id = (uint32_t)c.index.to_int64();
- if (type == IP::TYPE_IPV6)
+ if (type == IP::TYPE_IPV6) {
break; // IPv6 uses index.
+ }
for (List<IP_Address>::Element *F = c.ip_addresses.front(); F; F = F->next()) {
- if (!F->get().is_ipv4())
+ if (!F->get().is_ipv4()) {
continue; // Wrong IP type
+ }
if_ip = F->get();
break;
}
@@ -369,9 +367,9 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) {
}
void NetSocketPosix::close() {
-
- if (_sock != SOCK_EMPTY)
+ if (_sock != SOCK_EMPTY) {
SOCK_CLOSE(_sock);
+ }
_sock = SOCK_EMPTY;
_ip_type = IP::TYPE_NONE;
@@ -379,7 +377,6 @@ void NetSocketPosix::close() {
}
Error NetSocketPosix::bind(IP_Address p_addr, uint16_t p_port) {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!_can_use_ip(p_addr, true), ERR_INVALID_PARAMETER);
@@ -410,7 +407,6 @@ Error NetSocketPosix::listen(int p_max_pending) {
}
Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!_can_use_ip(p_host, false), ERR_INVALID_PARAMETER);
@@ -418,7 +414,6 @@ Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
size_t addr_size = _set_addr_storage(&addr, p_host, p_port, _ip_type);
if (SOCK_CONNECT(_sock, (struct sockaddr *)&addr, addr_size) != 0) {
-
NetError err = _get_socket_error();
switch (err) {
@@ -440,7 +435,6 @@ Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) {
}
Error NetSocketPosix::poll(PollType p_type, int p_timeout) const {
-
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
#if defined(WINDOWS_ENABLED)
@@ -521,8 +515,9 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const {
return FAILED;
}
- if (ret == 0)
+ if (ret == 0) {
return ERR_BUSY;
+ }
return OK;
#endif
@@ -535,8 +530,9 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) {
if (r_read < 0) {
NetError err = _get_socket_error();
- if (err == ERR_NET_WOULD_BLOCK)
+ if (err == ERR_NET_WOULD_BLOCK) {
return ERR_BUSY;
+ }
return FAILED;
}
@@ -555,8 +551,9 @@ Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Add
if (r_read < 0) {
NetError err = _get_socket_error();
- if (err == ERR_NET_WOULD_BLOCK)
+ if (err == ERR_NET_WOULD_BLOCK) {
return ERR_BUSY;
+ }
return FAILED;
}
@@ -582,15 +579,17 @@ Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) {
int flags = 0;
#ifdef MSG_NOSIGNAL
- if (_is_stream)
+ if (_is_stream) {
flags = MSG_NOSIGNAL;
+ }
#endif
r_sent = ::send(_sock, SOCK_CBUF(p_buffer), p_len, flags);
if (r_sent < 0) {
NetError err = _get_socket_error();
- if (err == ERR_NET_WOULD_BLOCK)
+ if (err == ERR_NET_WOULD_BLOCK) {
return ERR_BUSY;
+ }
return FAILED;
}
@@ -607,8 +606,9 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP
if (r_sent < 0) {
NetError err = _get_socket_error();
- if (err == ERR_NET_WOULD_BLOCK)
+ if (err == ERR_NET_WOULD_BLOCK) {
return ERR_BUSY;
+ }
return FAILED;
}
@@ -619,8 +619,9 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP
Error NetSocketPosix::set_broadcasting_enabled(bool p_enabled) {
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
// IPv6 has no broadcast support.
- if (_ip_type == IP::TYPE_IPV6)
+ if (_ip_type == IP::TYPE_IPV6) {
return ERR_UNAVAILABLE;
+ }
int par = p_enabled ? 1 : 0;
if (setsockopt(_sock, SOL_SOCKET, SO_BROADCAST, SOCK_CBUF(&par), sizeof(int)) != 0) {
@@ -639,14 +640,16 @@ void NetSocketPosix::set_blocking_enabled(bool p_enabled) {
ret = SOCK_IOCTL(_sock, FIONBIO, &par);
#else
int opts = fcntl(_sock, F_GETFL);
- if (p_enabled)
+ if (p_enabled) {
ret = fcntl(_sock, F_SETFL, opts & ~O_NONBLOCK);
- else
+ } else {
ret = fcntl(_sock, F_SETFL, opts | O_NONBLOCK);
+ }
#endif
- if (ret != 0)
+ if (ret != 0) {
WARN_PRINT("Unable to change non-block mode");
+ }
}
void NetSocketPosix::set_ipv6_only_enabled(bool p_enabled) {
@@ -701,7 +704,6 @@ bool NetSocketPosix::is_open() const {
}
int NetSocketPosix::get_available_bytes() const {
-
ERR_FAIL_COND_V(!is_open(), -1);
unsigned long len;
@@ -715,7 +717,6 @@ int NetSocketPosix::get_available_bytes() const {
}
Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) {
-
Ref<NetSocket> out;
ERR_FAIL_COND_V(!is_open(), out);
diff --git a/drivers/unix/net_socket_posix.h b/drivers/unix/net_socket_posix.h
index 0a19967265..8cefb6544e 100644
--- a/drivers/unix/net_socket_posix.h
+++ b/drivers/unix/net_socket_posix.h
@@ -45,11 +45,10 @@
#endif
class NetSocketPosix : public NetSocket {
-
private:
- SOCKET_TYPE _sock;
- IP::Type _ip_type;
- bool _is_stream;
+ SOCKET_TYPE _sock; // NOLINT - the default value is defined in the .cpp
+ IP::Type _ip_type = IP::TYPE_NONE;
+ bool _is_stream = false;
enum NetError {
ERR_NET_WOULD_BLOCK,
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 53c60951b7..9a5fc6d1a4 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -91,20 +91,19 @@ static void _setup_clock() {
#endif
void OS_Unix::debug_break() {
-
assert(false);
};
static void handle_interrupt(int sig) {
- if (!EngineDebugger::is_active())
+ if (!EngineDebugger::is_active()) {
return;
+ }
EngineDebugger::get_script_debugger()->set_depth(-1);
EngineDebugger::get_script_debugger()->set_lines_left(1);
}
void OS_Unix::initialize_debugging() {
-
if (EngineDebugger::is_active()) {
struct sigaction action;
memset(&action, 0, sizeof(action));
@@ -114,12 +113,10 @@ void OS_Unix::initialize_debugging() {
}
int OS_Unix::unix_initialize_audio(int p_audio_driver) {
-
return 0;
}
void OS_Unix::initialize_core() {
-
#ifdef NO_THREADS
ThreadDummy::make_default();
RWLockDummy::make_default();
@@ -144,17 +141,14 @@ void OS_Unix::initialize_core() {
}
void OS_Unix::finalize_core() {
-
NetSocketPosix::cleanup();
}
void OS_Unix::alert(const String &p_alert, const String &p_title) {
-
fprintf(stderr, "ERROR: %s\n", p_alert.utf8().get_data());
}
String OS_Unix::get_stdin_string(bool p_block) {
-
if (p_block) {
char buff[1024];
String ret = stdin_buf + fgets(buff, 1024, stdin);
@@ -166,35 +160,23 @@ String OS_Unix::get_stdin_string(bool p_block) {
}
String OS_Unix::get_name() const {
-
return "Unix";
}
-uint64_t OS_Unix::get_unix_time() const {
-
- return time(nullptr);
-};
-
-uint64_t OS_Unix::get_system_time_secs() const {
+double OS_Unix::get_unix_time() const {
struct timeval tv_now;
gettimeofday(&tv_now, nullptr);
- return uint64_t(tv_now.tv_sec);
-}
-
-uint64_t OS_Unix::get_system_time_msecs() const {
- struct timeval tv_now;
- gettimeofday(&tv_now, nullptr);
- return uint64_t(tv_now.tv_sec) * 1000 + uint64_t(tv_now.tv_usec) / 1000;
-}
+ return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000;
+};
OS::Date OS_Unix::get_date(bool utc) const {
-
time_t t = time(nullptr);
struct tm *lt;
- if (utc)
+ if (utc) {
lt = gmtime(&t);
- else
+ } else {
lt = localtime(&t);
+ }
Date ret;
ret.year = 1900 + lt->tm_year;
// Index starting at 1 to match OS_Unix::get_date
@@ -211,10 +193,11 @@ OS::Date OS_Unix::get_date(bool utc) const {
OS::Time OS_Unix::get_time(bool utc) const {
time_t t = time(nullptr);
struct tm *lt;
- if (utc)
+ if (utc) {
lt = gmtime(&t);
- else
+ } else {
lt = localtime(&t);
+ }
Time ret;
ret.hour = lt->tm_hour;
ret.min = lt->tm_min;
@@ -241,22 +224,22 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const {
// convert from ISO 8601 (1 minute=1, 1 hour=100) to minutes
int hour = (int)bias / 100;
int minutes = bias % 100;
- if (bias < 0)
+ if (bias < 0) {
ret.bias = hour * 60 - minutes;
- else
+ } else {
ret.bias = hour * 60 + minutes;
+ }
return ret;
}
void OS_Unix::delay_usec(uint32_t p_usec) const {
-
struct timespec rem = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 };
while (nanosleep(&rem, &rem) == EINTR) {
}
}
-uint64_t OS_Unix::get_ticks_usec() const {
+uint64_t OS_Unix::get_ticks_usec() const {
#if defined(__APPLE__)
uint64_t longtime = mach_absolute_time() * _clock_scale;
#else
@@ -272,19 +255,16 @@ uint64_t OS_Unix::get_ticks_usec() const {
}
Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
-
#ifdef __EMSCRIPTEN__
// Don't compile this code at all to avoid undefined references.
// Actual virtual call goes to OS_JavaScript.
ERR_FAIL_V(ERR_BUG);
#else
if (p_blocking && r_pipe) {
-
String argss;
argss = "\"" + p_path + "\"";
for (int i = 0; i < p_arguments.size(); i++) {
-
argss += String(" \"") + p_arguments[i] + "\"";
}
@@ -300,7 +280,6 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
char buf[65535];
while (fgets(buf, 65535, f)) {
-
if (p_pipe_mutex) {
p_pipe_mutex->lock();
}
@@ -310,8 +289,9 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
}
}
int rv = pclose(f);
- if (r_exitcode)
+ if (r_exitcode) {
*r_exitcode = WEXITSTATUS(rv);
+ }
return OK;
}
@@ -330,12 +310,14 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
Vector<CharString> cs;
cs.push_back(p_path.utf8());
- for (int i = 0; i < p_arguments.size(); i++)
+ for (int i = 0; i < p_arguments.size(); i++) {
cs.push_back(p_arguments[i].utf8());
+ }
Vector<char *> args;
- for (int i = 0; i < cs.size(); i++)
+ for (int i = 0; i < cs.size(); i++) {
args.push_back((char *)cs[i].get_data());
+ }
args.push_back(0);
execvp(p_path.utf8().get_data(), &args[0]);
@@ -345,16 +327,16 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
}
if (p_blocking) {
-
int status;
waitpid(pid, &status, 0);
- if (r_exitcode)
+ if (r_exitcode) {
*r_exitcode = WEXITSTATUS(status);
+ }
} else {
-
- if (r_child_id)
+ if (r_child_id) {
*r_child_id = pid;
+ }
}
return OK;
@@ -362,7 +344,6 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
}
Error OS_Unix::kill(const ProcessID &p_pid) {
-
int ret = ::kill(p_pid, SIGKILL);
if (!ret) {
//avoid zombie process
@@ -373,29 +354,27 @@ Error OS_Unix::kill(const ProcessID &p_pid) {
}
int OS_Unix::get_process_id() const {
-
return getpid();
};
bool OS_Unix::has_environment(const String &p_var) const {
-
return getenv(p_var.utf8().get_data()) != nullptr;
}
String OS_Unix::get_locale() const {
-
- if (!has_environment("LANG"))
+ if (!has_environment("LANG")) {
return "en";
+ }
String locale = get_environment("LANG");
int tp = locale.find(".");
- if (tp != -1)
+ if (tp != -1) {
locale = locale.substr(0, tp);
+ }
return locale;
}
Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
-
String path = p_path;
if (FileAccess::exists(path) && path.is_rel_path()) {
@@ -442,32 +421,29 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
}
Error OS_Unix::set_cwd(const String &p_cwd) {
-
- if (chdir(p_cwd.utf8().get_data()) != 0)
+ if (chdir(p_cwd.utf8().get_data()) != 0) {
return ERR_CANT_OPEN;
+ }
return OK;
}
String OS_Unix::get_environment(const String &p_var) const {
-
- if (getenv(p_var.utf8().get_data()))
+ if (getenv(p_var.utf8().get_data())) {
return getenv(p_var.utf8().get_data());
+ }
return "";
}
bool OS_Unix::set_environment(const String &p_var, const String &p_value) const {
-
return setenv(p_var.utf8().get_data(), p_value.utf8().get_data(), /* overwrite: */ true) == 0;
}
int OS_Unix::get_processor_count() const {
-
return sysconf(_SC_NPROCESSORS_CONF);
}
String OS_Unix::get_user_data_dir() const {
-
String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
if (appname != "") {
bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir");
@@ -486,7 +462,6 @@ String OS_Unix::get_user_data_dir() const {
}
String OS_Unix::get_executable_path() const {
-
#ifdef __linux__
//fix for running from a symlink
char buf[256];
@@ -544,10 +519,11 @@ void UnixTerminalLogger::log_error(const char *p_function, const char *p_file, i
}
const char *err_details;
- if (p_rationale && p_rationale[0])
+ if (p_rationale && p_rationale[0]) {
err_details = p_rationale;
- else
+ } else {
err_details = p_code;
+ }
// Disable color codes if stdout is not a TTY.
// This prevents Godot from writing ANSI escape codes when redirecting
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 90679ddf1d..2982e0c55c 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -37,7 +37,6 @@
#include "drivers/unix/ip_unix.h"
class OS_Unix : public OS {
-
protected:
// UNIX only handles the core functions.
// inheriting platforms under unix (eg. X11) should handle the rest
@@ -78,9 +77,7 @@ public:
virtual Time get_time(bool utc) const;
virtual TimeZoneInfo get_time_zone_info() const;
- virtual uint64_t get_unix_time() const;
- virtual uint64_t get_system_time_secs() const;
- virtual uint64_t get_system_time_msecs() const;
+ virtual double get_unix_time() const;
virtual void delay_usec(uint32_t p_usec) const;
virtual uint64_t get_ticks_usec() const;
diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp
index f219a0905c..50b74e84f7 100644
--- a/drivers/unix/rw_lock_posix.cpp
+++ b/drivers/unix/rw_lock_posix.cpp
@@ -37,7 +37,6 @@
#include <stdio.h>
void RWLockPosix::read_lock() {
-
int err = pthread_rwlock_rdlock(&rwlock);
if (err != 0) {
perror("Acquiring lock failed");
@@ -46,12 +45,10 @@ void RWLockPosix::read_lock() {
}
void RWLockPosix::read_unlock() {
-
pthread_rwlock_unlock(&rwlock);
}
Error RWLockPosix::read_try_lock() {
-
if (pthread_rwlock_tryrdlock(&rwlock) != 0) {
return ERR_BUSY;
} else {
@@ -60,13 +57,11 @@ Error RWLockPosix::read_try_lock() {
}
void RWLockPosix::write_lock() {
-
int err = pthread_rwlock_wrlock(&rwlock);
ERR_FAIL_COND(err != 0);
}
void RWLockPosix::write_unlock() {
-
pthread_rwlock_unlock(&rwlock);
}
@@ -79,23 +74,19 @@ Error RWLockPosix::write_try_lock() {
}
RWLock *RWLockPosix::create_func_posix() {
-
return memnew(RWLockPosix);
}
void RWLockPosix::make_default() {
-
create_func = create_func_posix;
}
RWLockPosix::RWLockPosix() {
-
//rwlock=PTHREAD_RWLOCK_INITIALIZER; fails on OSX
pthread_rwlock_init(&rwlock, nullptr);
}
RWLockPosix::~RWLockPosix() {
-
pthread_rwlock_destroy(&rwlock);
}
diff --git a/drivers/unix/rw_lock_posix.h b/drivers/unix/rw_lock_posix.h
index b12d373db5..056fcaea1c 100644
--- a/drivers/unix/rw_lock_posix.h
+++ b/drivers/unix/rw_lock_posix.h
@@ -37,7 +37,6 @@
#include <pthread.h>
class RWLockPosix : public RWLock {
-
pthread_rwlock_t rwlock;
static RWLock *create_func_posix();
diff --git a/drivers/unix/syslog_logger.cpp b/drivers/unix/syslog_logger.cpp
index 8296d6ce30..a4c7070f0e 100644
--- a/drivers/unix/syslog_logger.cpp
+++ b/drivers/unix/syslog_logger.cpp
@@ -67,10 +67,11 @@ void SyslogLogger::print_error(const char *p_function, const char *p_file, int p
}
const char *err_details;
- if (p_rationale && *p_rationale)
+ if (p_rationale && *p_rationale) {
err_details = p_rationale;
- else
+ } else {
err_details = p_code;
+ }
syslog(p_type == ERR_WARNING ? LOG_WARNING : LOG_ERR, "%s: %s\n At: %s:%i:%s() - %s", err_type, err_details, p_file, p_line, p_function, p_code);
}
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index c227aec6d6..aa1b5019ca 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -54,17 +54,14 @@ pthread_key_t ThreadPosix::thread_id_key = _create_thread_id_key();
Thread::ID ThreadPosix::next_thread_id = 0;
Thread::ID ThreadPosix::get_id() const {
-
return id;
}
Thread *ThreadPosix::create_thread_posix() {
-
return memnew(ThreadPosix);
}
void *ThreadPosix::thread_callback(void *userdata) {
-
ThreadPosix *t = reinterpret_cast<ThreadPosix *>(userdata);
t->id = atomic_increment(&next_thread_id);
pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id)));
@@ -79,7 +76,6 @@ void *ThreadPosix::thread_callback(void *userdata) {
}
Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
-
ThreadPosix *tr = memnew(ThreadPosix);
tr->callback = p_callback;
tr->user = p_user;
@@ -91,19 +87,20 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_
return tr;
}
-Thread::ID ThreadPosix::get_thread_id_func_posix() {
+Thread::ID ThreadPosix::get_thread_id_func_posix() {
void *value = pthread_getspecific(thread_id_key);
- if (value)
+ if (value) {
return *static_cast<ID *>(value);
+ }
ID new_id = atomic_increment(&next_thread_id);
pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id)));
return new_id;
}
-void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
+void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
ThreadPosix *tp = static_cast<ThreadPosix *>(p_thread);
ERR_FAIL_COND(!tp);
ERR_FAIL_COND(tp->pthread == 0);
@@ -113,7 +110,6 @@ void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
}
Error ThreadPosix::set_name_func_posix(const String &p_name) {
-
#ifdef PTHREAD_NO_RENAME
return ERR_UNAVAILABLE;
@@ -142,7 +138,6 @@ Error ThreadPosix::set_name_func_posix(const String &p_name) {
};
void ThreadPosix::make_default() {
-
create_func = create_func_posix;
get_thread_id_func = get_thread_id_func_posix;
wait_to_finish_func = wait_to_finish_func_posix;
@@ -150,7 +145,6 @@ void ThreadPosix::make_default() {
}
ThreadPosix::ThreadPosix() {
-
pthread = 0;
}
diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h
index e852dcf3d5..6607dbd111 100644
--- a/drivers/unix/thread_posix.h
+++ b/drivers/unix/thread_posix.h
@@ -38,7 +38,6 @@
#include <sys/types.h>
class ThreadPosix : public Thread {
-
static pthread_key_t thread_id_key;
static ID next_thread_id;
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 71be891b1d..c9e78678a8 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -35,12 +35,12 @@
#include "core/os/os.h"
#include "core/project_settings.h"
#include "drivers/vulkan/vulkan_context.h"
+
#include "thirdparty/spirv-reflect/spirv_reflect.h"
//#define FORCE_FULL_BARRIER
void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) {
-
if (!dependency_map.has(p_depends_on)) {
dependency_map[p_depends_on] = Set<RID>();
}
@@ -55,12 +55,10 @@ void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) {
}
void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
-
//direct dependencies must be freed
Map<RID, Set<RID>>::Element *E = dependency_map.find(p_id);
if (E) {
-
while (E->get().size()) {
free(E->get().front()->get());
}
@@ -71,7 +69,6 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
E = reverse_dependency_map.find(p_id);
if (E) {
-
for (Set<RID>::Element *F = E->get().front(); F; F = F->next()) {
Map<RID, Set<RID>>::Element *G = dependency_map.find(F->get());
ERR_CONTINUE(!G);
@@ -630,9 +627,7 @@ int RenderingDeviceVulkan::get_format_vertex_size(DataFormat p_format) {
}
uint32_t RenderingDeviceVulkan::get_image_format_pixel_size(DataFormat p_format) {
-
switch (p_format) {
-
case DATA_FORMAT_R4G4_UNORM_PACK8:
return 1;
case DATA_FORMAT_R4G4B4A4_UNORM_PACK16:
@@ -906,7 +901,6 @@ uint32_t RenderingDeviceVulkan::get_image_format_pixel_size(DataFormat p_format)
// https://www.khronos.org/registry/DataFormat/specs/1.1/dataformat.1.1.pdf
void RenderingDeviceVulkan::get_compressed_image_format_block_dimensions(DataFormat p_format, uint32_t &r_w, uint32_t &r_h) {
-
switch (p_format) {
case DATA_FORMAT_BC1_RGB_UNORM_BLOCK:
case DATA_FORMAT_BC1_RGB_SRGB_BLOCK:
@@ -987,7 +981,6 @@ void RenderingDeviceVulkan::get_compressed_image_format_block_dimensions(DataFor
}
uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(DataFormat p_format) {
-
switch (p_format) {
case DATA_FORMAT_BC1_RGB_UNORM_BLOCK:
case DATA_FORMAT_BC1_RGB_SRGB_BLOCK:
@@ -1072,7 +1065,6 @@ uint32_t RenderingDeviceVulkan::get_compressed_image_format_block_byte_size(Data
}
uint32_t RenderingDeviceVulkan::get_compressed_image_format_pixel_rshift(DataFormat p_format) {
-
switch (p_format) {
case DATA_FORMAT_BC1_RGB_UNORM_BLOCK: //these formats are half byte size, so rshift is 1
case DATA_FORMAT_BC1_RGB_SRGB_BLOCK:
@@ -1118,7 +1110,6 @@ bool RenderingDeviceVulkan::format_has_stencil(DataFormat p_format) {
}
uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_format, uint32_t p_width, uint32_t p_height, uint32_t p_depth, uint32_t p_mipmaps, uint32_t *r_blockw, uint32_t *r_blockh, uint32_t *r_depth) {
-
ERR_FAIL_COND_V(p_mipmaps == 0, 0);
uint32_t w = p_width;
uint32_t h = p_height;
@@ -1158,7 +1149,6 @@ uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_form
}
uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uint32_t p_height, uint32_t p_depth) {
-
//formats and block size don't really matter here since they can all go down to 1px (even if block is larger)
int w = p_width;
int h = p_height;
@@ -1167,7 +1157,6 @@ uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uin
int mipmaps = 1;
while (true) {
-
if (w == 1 && h == 1 && d == 1) {
break;
}
@@ -1337,7 +1326,6 @@ Error RenderingDeviceVulkan::_buffer_free(Buffer *p_buffer) {
}
Error RenderingDeviceVulkan::_insert_staging_block() {
-
VkBufferCreateInfo bufferInfo;
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.pNext = nullptr;
@@ -1375,7 +1363,6 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
r_alloc_size = p_amount;
while (true) {
-
r_alloc_offset = 0;
//see if we can use current block
@@ -1431,7 +1418,6 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
//block_until_next_frame()
continue;
} else {
-
//flush EVERYTHING including setup commands. IF not immediate, also need to flush the draw commands
_flush(true);
@@ -1476,7 +1462,6 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
//block_until_next_frame()
continue; //and try again
} else {
-
_flush(false);
for (int i = 0; i < staging_buffer_blocks.size(); i++) {
@@ -1506,13 +1491,11 @@ Error RenderingDeviceVulkan::_staging_buffer_allocate(uint32_t p_amount, uint32_
}
Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, const uint8_t *p_data, size_t p_data_size, bool p_use_draw_command_buffer, uint32_t p_required_align) {
-
//submitting may get chunked for various reasons, so convert this to a task
size_t to_submit = p_data_size;
size_t submit_from = 0;
while (to_submit > 0) {
-
uint32_t block_write_offset;
uint32_t block_write_amount;
@@ -1553,7 +1536,6 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c
}
void RenderingDeviceVulkan::_memory_barrier(VkPipelineStageFlags p_src_stage_mask, VkPipelineStageFlags p_dst_stage_mask, VkAccessFlags p_src_access, VkAccessFlags p_dst_sccess, bool p_sync_with_draw) {
-
VkMemoryBarrier mem_barrier;
mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
mem_barrier.pNext = nullptr;
@@ -1600,7 +1582,6 @@ void RenderingDeviceVulkan::_full_barrier(bool p_sync_with_draw) {
}
void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_from, uint64_t p_size, VkPipelineStageFlags p_src_stage_mask, VkPipelineStageFlags p_dst_stage_mask, VkAccessFlags p_src_access, VkAccessFlags p_dst_sccess, bool p_sync_with_draw) {
-
VkBufferMemoryBarrier buffer_mem_barrier;
buffer_mem_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
buffer_mem_barrier.pNext = nullptr;
@@ -1620,7 +1601,6 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f
/*****************/
RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data) {
-
_THREAD_SAFE_METHOD_
VkImageCreateInfo image_create_info;
@@ -1750,7 +1730,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
"Too many mipmaps requested for texture format and dimensions (" + itos(image_create_info.mipLevels) + "), maximum allowed: (" + itos(required_mipmaps) + ").");
if (p_data.size()) {
-
ERR_FAIL_COND_V_MSG(!(p_format.usage_bits & TEXTURE_USAGE_CAN_UPDATE_BIT), RID(),
"Texture needs the TEXTURE_USAGE_CAN_UPDATE_BIT usage flag in order to be updated at initialization or later");
@@ -1858,7 +1837,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
texture.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
} else if (p_format.usage_bits & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
texture.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
} else {
@@ -1866,7 +1844,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
}
if (p_format.usage_bits & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
texture.read_aspect_mask = VK_IMAGE_ASPECT_DEPTH_BIT;
texture.barrier_aspect_mask = VK_IMAGE_ASPECT_DEPTH_BIT;
@@ -1961,7 +1938,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
RID id = texture_owner.make_rid(texture);
if (p_data.size()) {
-
for (uint32_t i = 0; i < image_create_info.arrayLayers; i++) {
texture_update(id, i, p_data[i]);
}
@@ -1970,7 +1946,6 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
}
RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID p_with_texture) {
-
_THREAD_SAFE_METHOD_
Texture *src_texture = texture_owner.getornull(p_with_texture);
@@ -2050,7 +2025,6 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID
}
RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type) {
-
_THREAD_SAFE_METHOD_
Texture *src_texture = texture_owner.getornull(p_with_texture);
@@ -2150,7 +2124,6 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p
}
Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(draw_list && p_sync_with_draw, ERR_INVALID_PARAMETER,
@@ -2221,7 +2194,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
uint32_t mipmap_offset = 0;
for (uint32_t mm_i = 0; mm_i < texture->mipmaps; mm_i++) {
-
uint32_t depth;
uint32_t image_total = get_image_format_required_size(texture->format, texture->width, texture->height, texture->depth, mm_i + 1, &width, &height, &depth);
@@ -2234,7 +2206,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
for (uint32_t x = 0; x < width; x += region_size) {
for (uint32_t y = 0; y < height; y += region_size) {
-
uint32_t region_w = MIN(region_size, width - x);
uint32_t region_h = MIN(region_size, height - y);
@@ -2295,7 +2266,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
uint32_t dst_offset = (yr * region_w + xr) * pixel_size;
//copy block
for (uint32_t i = 0; i < pixel_size; i++) {
-
write_ptr[dst_offset + i] = read_ptr[src_offset + i];
}
}
@@ -2359,7 +2329,6 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
}
Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d) {
-
uint32_t width, height, depth;
uint32_t image_size = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, tex->mipmaps, &width, &height, &depth);
@@ -2379,7 +2348,6 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex
uint32_t mipmap_offset = 0;
for (uint32_t mm_i = 0; mm_i < tex->mipmaps; mm_i++) {
-
uint32_t image_total = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, mm_i + 1, &width, &height, &depth);
uint8_t *write_ptr_mipmap = w + mipmap_offset;
@@ -2426,7 +2394,6 @@ Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex
}
Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) {
-
_THREAD_SAFE_METHOD_
Texture *tex = texture_owner.getornull(p_texture);
@@ -2447,7 +2414,6 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
//does not need anything fancy, map and read.
return _texture_get_data_from_image(tex, tex->image, tex->allocation, p_layer);
} else {
-
//compute total image size
uint32_t width, height, depth;
uint32_t buffer_size = get_image_format_required_size(tex->format, tex->width, tex->height, tex->depth, tex->mipmaps, &width, &height, &depth);
@@ -2485,7 +2451,6 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
uint32_t prev_size = 0;
uint32_t offset = 0;
for (uint32_t i = 0; i < tex->mipmaps; i++) {
-
VkBufferImageCopy buffer_image_copy;
uint32_t image_size = get_image_format_required_size(tex->format, tex->width, tex->height, tex->depth, i + 1);
@@ -2542,7 +2507,6 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t
Vector<uint8_t> buffer_data;
{
-
buffer_data.resize(buffer_size);
uint8_t *w = buffer_data.ptrw();
copymem(w, buffer_mem, buffer_size);
@@ -2569,7 +2533,6 @@ bool RenderingDeviceVulkan::texture_is_valid(RID p_texture) {
}
Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, bool p_sync_with_draw) {
-
_THREAD_SAFE_METHOD_
Texture *src_tex = texture_owner.getornull(p_from_texture);
@@ -2620,7 +2583,6 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer;
{
-
//PRE Copy the image
{ //Source
@@ -2667,7 +2629,6 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
//COPY
{
-
VkImageCopy image_copy_region;
image_copy_region.srcSubresource.aspectMask = src_tex->read_aspect_mask;
image_copy_region.srcSubresource.baseArrayLayer = p_src_layer;
@@ -2739,6 +2700,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
return OK;
}
+
Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID p_to_texture, bool p_sync_with_draw) {
_THREAD_SAFE_METHOD_
@@ -2773,7 +2735,6 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer;
{
-
//PRE Copy the image
{ //Source
@@ -2820,7 +2781,6 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
//COPY
{
-
VkImageResolve image_copy_region;
image_copy_region.srcSubresource.aspectMask = src_tex->read_aspect_mask;
image_copy_region.srcSubresource.baseArrayLayer = src_tex->base_layer;
@@ -2894,7 +2854,6 @@ Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID
}
Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, bool p_sync_with_draw) {
-
_THREAD_SAFE_METHOD_
Texture *src_tex = texture_owner.getornull(p_texture);
@@ -3027,14 +2986,12 @@ bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_f
/********************/
VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentFormat> &p_format, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, int *r_color_attachment_count) {
-
Vector<VkAttachmentDescription> attachments;
Vector<VkAttachmentReference> color_references;
Vector<VkAttachmentReference> depth_stencil_references;
Vector<VkAttachmentReference> resolve_references;
for (int i = 0; i < p_format.size(); i++) {
-
VkAttachmentDescription description;
description.flags = 0;
@@ -3051,7 +3008,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
bool is_storage = p_format[i].usage_flags & TEXTURE_USAGE_STORAGE_BIT;
switch (is_depth_stencil ? p_initial_depth_action : p_initial_color_action) {
-
case INITIAL_ACTION_CLEAR: {
description.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
@@ -3109,13 +3065,11 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
switch (is_depth_stencil ? p_final_depth_action : p_final_color_action) {
case FINAL_ACTION_READ: {
-
if (p_format[i].usage_flags & TEXTURE_USAGE_COLOR_ATTACHMENT_BIT) {
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
} else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
@@ -3131,7 +3085,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
} else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
description.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = is_sampled ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL : (is_storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
@@ -3147,7 +3100,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
description.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
} else if (p_format[i].usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
description.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
description.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
@@ -3222,7 +3174,6 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF
}
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_format_create(const Vector<AttachmentFormat> &p_format) {
-
_THREAD_SAFE_METHOD_
FramebufferFormatKey key;
@@ -3264,7 +3215,6 @@ RenderingDevice::TextureSamples RenderingDeviceVulkan::framebuffer_format_get_te
/***********************/
RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check) {
-
_THREAD_SAFE_METHOD_
Vector<AttachmentFormat> attachments;
@@ -3312,7 +3262,6 @@ RID RenderingDeviceVulkan::framebuffer_create(const Vector<RID> &p_texture_attac
}
RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_get_format(RID p_framebuffer) {
-
_THREAD_SAFE_METHOD_
Framebuffer *framebuffer = framebuffer_owner.getornull(p_framebuffer);
@@ -3326,7 +3275,6 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::framebuffer_get_form
/*****************/
RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
-
_THREAD_SAFE_METHOD_
VkSamplerCreateInfo sampler_create_info;
@@ -3372,7 +3320,6 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
/**********************/
RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -3391,7 +3338,6 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vec
// Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated
RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats) {
-
_THREAD_SAFE_METHOD_
VertexDescriptionKey key;
@@ -3443,7 +3389,6 @@ RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(cons
}
RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!vertex_formats.has(p_vertex_format), RID());
@@ -3500,7 +3445,6 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo
}
RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const Vector<uint8_t> &p_data, bool p_use_restart_indices) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_index_count == 0, RID());
@@ -3550,7 +3494,6 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff
}
RID RenderingDeviceVulkan::index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!index_buffer_owner.owns(p_index_buffer), RID());
@@ -3814,7 +3757,6 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
#endif
RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages) {
-
//descriptor layouts
Vector<Vector<VkDescriptorSetLayoutBinding>> set_bindings;
Vector<Vector<UniformInfo>> uniform_info;
@@ -3831,7 +3773,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
bool is_compute = false;
for (int i = 0; i < p_stages.size(); i++) {
-
if (p_stages[i].shader_stage == SHADER_STAGE_COMPUTE) {
is_compute = true;
ERR_FAIL_COND_V_MSG(p_stages.size() != 1, RID(),
@@ -3855,7 +3796,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
uint32_t stage = p_stages[i].shader_stage;
if (binding_count > 0) {
-
//Parse bindings
Vector<SpvReflectDescriptorBinding *> bindings;
@@ -4006,7 +3946,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
}
if (stage == SHADER_STAGE_VERTEX) {
-
uint32_t iv_count = 0;
result = spvReflectEnumerateInputVariables(&module, &iv_count, nullptr);
ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(),
@@ -4029,7 +3968,6 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
}
if (stage == SHADER_STAGE_FRAGMENT) {
-
uint32_t ov_count = 0;
result = spvReflectEnumerateOutputVariables(&module, &ov_count, nullptr);
ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(),
@@ -4142,9 +4080,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages
//proceed to create descriptor sets
if (success) {
-
for (int i = 0; i < set_bindings.size(); i++) {
-
//empty ones are fine if they were not used according to spec (binding count will be 0)
VkDescriptorSetLayoutCreateInfo layout_create_info;
layout_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
@@ -4253,7 +4189,6 @@ uint32_t RenderingDeviceVulkan::shader_get_vertex_input_attribute_mask(RID p_sha
/******************/
RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -4271,7 +4206,6 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Ve
}
RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_data.size() && (uint32_t)p_data.size() != p_size_bytes, RID());
@@ -4290,7 +4224,6 @@ RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Ve
}
RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data) {
-
_THREAD_SAFE_METHOD_
uint32_t element_size = get_format_vertex_size(p_format);
@@ -4447,7 +4380,6 @@ void RenderingDeviceVulkan::_descriptor_pool_free(const DescriptorPoolKey &p_key
}
RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_uniforms.size() == 0, RID());
@@ -4500,6 +4432,12 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
write.pNext = nullptr;
write.dstSet = VK_NULL_HANDLE; //will assign afterwards when everything is valid
write.dstBinding = set_uniform.binding;
+ write.dstArrayElement = 0;
+ write.descriptorCount = 0;
+ write.descriptorType = VK_DESCRIPTOR_TYPE_MAX_ENUM; //Invalid value.
+ write.pImageInfo = nullptr;
+ write.pBufferInfo = nullptr;
+ write.pTexelBufferView = nullptr;
uint32_t type_size = 1;
switch (uniform.type) {
@@ -4537,7 +4475,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
} break;
case UNIFORM_TYPE_SAMPLER_WITH_TEXTURE: {
-
if (uniform.ids.size() != set_uniform.length * 2) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "SamplerTexture (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") sampler&texture elements, so it should provided twice the amount of IDs (sampler,texture pairs) to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4591,7 +4528,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
} break;
case UNIFORM_TYPE_TEXTURE: {
-
if (uniform.ids.size() != set_uniform.length) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "Texture (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") textures, so it should be provided equal number of texture IDs to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4642,7 +4578,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
type_size = uniform.ids.size();
} break;
case UNIFORM_TYPE_IMAGE: {
-
if (uniform.ids.size() != set_uniform.length) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "Image (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") textures, so it should be provided equal number of texture IDs to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4722,7 +4657,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
} break;
case UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER: {
-
if (uniform.ids.size() != set_uniform.length * 2) {
if (set_uniform.length > 1) {
ERR_FAIL_V_MSG(RID(), "SamplerBuffer (binding: " + itos(uniform.binding) + ") is an array of (" + itos(set_uniform.length) + ") sampler buffer elements, so it should provided twice the amount of IDs (sampler,buffer pairs) to satisfy it (IDs provided: " + itos(uniform.ids.size()) + ").");
@@ -4804,7 +4738,6 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
write.pTexelBufferView = nullptr;
} break;
case UNIFORM_TYPE_INPUT_ATTACHMENT: {
-
} break;
default: {
}
@@ -4928,7 +4861,6 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint
}
Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
-
_THREAD_SAFE_METHOD_
Buffer *buffer = nullptr;
@@ -4961,7 +4893,6 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
Vector<uint8_t> buffer_data;
{
-
buffer_data.resize(buffer->size);
uint8_t *w = buffer_data.ptrw();
copymem(w, buffer_mem, buffer->size);
@@ -4979,7 +4910,6 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
/*************************/
RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags) {
-
_THREAD_SAFE_METHOD_
//needs a shader
@@ -5389,7 +5319,6 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader) {
}
bool RenderingDeviceVulkan::compute_pipeline_is_valid(RID p_pipeline) {
-
return compute_pipeline_owner.owns(p_pipeline);
}
@@ -5402,14 +5331,15 @@ int RenderingDeviceVulkan::screen_get_width(DisplayServer::WindowID p_screen) co
ERR_FAIL_COND_V_MSG(local_device.is_valid(), -1, "Local devices have no screen");
return context->window_get_width(p_screen);
}
+
int RenderingDeviceVulkan::screen_get_height(DisplayServer::WindowID p_screen) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), -1, "Local devices have no screen");
return context->window_get_height(p_screen);
}
-RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuffer_format() const {
+RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuffer_format() const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), INVALID_ID, "Local devices have no screen");
@@ -5439,7 +5369,6 @@ RenderingDevice::FramebufferFormatID RenderingDeviceVulkan::screen_get_framebuff
/*******************/
RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(DisplayServer::WindowID p_screen, const Color &p_clear_color) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(local_device.is_valid(), INVALID_ID, "Local devices have no screen");
@@ -5503,7 +5432,6 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di
}
Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass) {
-
Framebuffer::VersionKey vk;
vk.initial_color_action = p_initial_color_action;
vk.final_color_action = p_final_color_action;
@@ -5548,7 +5476,6 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu
}
Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_colors, float p_clear_depth, uint32_t p_clear_stencil, Point2i viewport_offset, Point2i viewport_size, VkFramebuffer vkframebuffer, VkRenderPass render_pass, VkCommandBuffer command_buffer, VkSubpassContents subpass_contents) {
-
VkRenderPassBeginInfo render_pass_begin;
render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_begin.pNext = nullptr;
@@ -5625,7 +5552,6 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list,
clear_at.colorAttachment = color_index++;
clear_at.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
} else if (p_clear_depth && texture->usage_flags & TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
-
clear_at.clearValue.depthStencil.depth = p_depth;
clear_at.clearValue.depthStencil.stencil = p_stencil;
clear_at.colorAttachment = 0;
@@ -5651,7 +5577,6 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list,
}
RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time.");
@@ -5742,7 +5667,6 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu
}
Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, DrawListID *r_split_ids, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(p_splits < 1, ERR_INVALID_DECLARATION);
@@ -5789,7 +5713,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
uint32_t from = split_draw_list_allocators.size();
split_draw_list_allocators.resize(p_splits);
for (uint32_t i = from; i < p_splits; i++) {
-
VkCommandPoolCreateInfo cmd_pool_info;
cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
cmd_pool_info.pNext = nullptr;
@@ -5800,7 +5723,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + ".");
for (int j = 0; j < frame_count; j++) {
-
VkCommandBuffer command_buffer;
VkCommandBufferAllocateInfo cmdbuf;
@@ -5837,7 +5759,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
draw_list_split = true;
for (uint32_t i = 0; i < p_splits; i++) {
-
//take a command buffer and initialize it
VkCommandBuffer command_buffer = split_draw_list_allocators[p_splits].command_buffers[frame];
@@ -5906,7 +5827,6 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p
}
RenderingDeviceVulkan::DrawList *RenderingDeviceVulkan::_get_draw_list_ptr(DrawListID p_id) {
-
if (p_id < 0) {
return nullptr;
}
@@ -5936,7 +5856,6 @@ RenderingDeviceVulkan::DrawList *RenderingDeviceVulkan::_get_draw_list_ptr(DrawL
}
void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RID p_render_pipeline) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -5987,7 +5906,7 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI
if (pipeline->push_constant_size) {
dl->state.pipeline_push_constant_stages = pipeline->push_constant_stages;
#ifdef DEBUG_ENABLED
- dl->validation.pipeline_push_constant_suppplied = false;
+ dl->validation.pipeline_push_constant_supplied = false;
#endif
}
@@ -6007,7 +5926,6 @@ void RenderingDeviceVulkan::draw_list_bind_render_pipeline(DrawListID p_list, RI
}
void RenderingDeviceVulkan::draw_list_bind_uniform_set(DrawListID p_list, RID p_uniform_set, uint32_t p_index) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(p_index >= limits.maxBoundDescriptorSets || p_index > MAX_UNIFORM_SETS,
"Attempting to bind a descriptor set (" + itos(p_index) + ") greater than what the hardware supports (" + itos(limits.maxBoundDescriptorSets) + ").");
@@ -6070,8 +5988,8 @@ void RenderingDeviceVulkan::draw_list_bind_vertex_array(DrawListID p_list, RID p
dl->validation.vertex_array_size = vertex_array->vertex_count;
vkCmdBindVertexBuffers(dl->command_buffer, 0, vertex_array->buffers.size(), vertex_array->buffers.ptr(), vertex_array->offsets.ptr());
}
-void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_index_array) {
+void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_index_array) {
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6096,7 +6014,6 @@ void RenderingDeviceVulkan::draw_list_bind_index_array(DrawListID p_list, RID p_
}
void RenderingDeviceVulkan::draw_list_set_line_width(DrawListID p_list, float p_width) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6120,12 +6037,11 @@ void RenderingDeviceVulkan::draw_list_set_push_constant(DrawListID p_list, const
#endif
vkCmdPushConstants(dl->command_buffer, dl->state.pipeline_layout, dl->state.pipeline_push_constant_stages, 0, p_data_size, p_data);
#ifdef DEBUG_ENABLED
- dl->validation.pipeline_push_constant_suppplied = true;
+ dl->validation.pipeline_push_constant_supplied = true;
#endif
}
void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices, uint32_t p_instances, uint32_t p_procedural_vertices) {
-
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
#ifdef DEBUG_ENABLED
@@ -6149,7 +6065,7 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
if (dl->validation.pipeline_push_constant_size > 0) {
//using push constants, check that they were supplied
- ERR_FAIL_COND_MSG(!dl->validation.pipeline_push_constant_suppplied,
+ ERR_FAIL_COND_MSG(!dl->validation.pipeline_push_constant_supplied,
"The shader in this pipeline requires a push constant to be set before drawing, but it's not present.");
}
@@ -6158,13 +6074,11 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
//Bind descriptor sets
for (uint32_t i = 0; i < dl->state.set_count; i++) {
-
if (dl->state.sets[i].pipeline_expected_format == 0) {
continue; //nothing expected by this pipeline
}
#ifdef DEBUG_ENABLED
if (dl->state.sets[i].pipeline_expected_format != dl->state.sets[i].uniform_set_format) {
-
if (dl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(dl->state.sets[i].uniform_set)) {
@@ -6183,7 +6097,6 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
}
if (p_use_indices) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(p_procedural_vertices > 0,
"Procedural vertices can't be used together with indices.");
@@ -6211,7 +6124,6 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
#endif
vkCmdDrawIndexed(dl->command_buffer, to_draw, p_instances, dl->validation.index_array_offset, 0, 0);
} else {
-
uint32_t to_draw;
if (p_procedural_vertices > 0) {
@@ -6221,7 +6133,6 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices
#endif
to_draw = p_procedural_vertices;
} else {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(dl->validation.pipeline_vertex_format == INVALID_ID,
"Draw command lacks indices, but pipeline format does not use vertices.");
@@ -6264,6 +6175,7 @@ void RenderingDeviceVulkan::draw_list_enable_scissor(DrawListID p_list, const Re
vkCmdSetScissor(dl->command_buffer, 0, 1, &scissor);
}
+
void RenderingDeviceVulkan::draw_list_disable_scissor(DrawListID p_list) {
DrawList *dl = _get_draw_list_ptr(p_list);
ERR_FAIL_COND(!dl);
@@ -6280,7 +6192,6 @@ void RenderingDeviceVulkan::draw_list_disable_scissor(DrawListID p_list) {
}
void RenderingDeviceVulkan::draw_list_end() {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_MSG(!draw_list, "Immediate draw list is already inactive.");
@@ -6334,7 +6245,6 @@ void RenderingDeviceVulkan::draw_list_end() {
/***********************/
RenderingDevice::ComputeListID RenderingDeviceVulkan::compute_list_begin() {
-
ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time.");
ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time.");
@@ -6391,7 +6301,7 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l
if (pipeline->push_constant_size) {
cl->state.pipeline_push_constant_stages = pipeline->push_constant_stages;
#ifdef DEBUG_ENABLED
- cl->validation.pipeline_push_constant_suppplied = false;
+ cl->validation.pipeline_push_constant_supplied = false;
#endif
}
@@ -6404,6 +6314,7 @@ void RenderingDeviceVulkan::compute_list_bind_compute_pipeline(ComputeListID p_l
cl->validation.pipeline_push_constant_size = pipeline->push_constant_size;
#endif
}
+
void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, RID p_uniform_set, uint32_t p_index) {
ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST);
ERR_FAIL_COND(!compute_list);
@@ -6436,7 +6347,6 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list,
for (uint32_t i = 0; i < textures_to_sampled_count; i++) {
if (textures_to_sampled[i]->layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
-
VkImageMemoryBarrier image_memory_barrier;
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
@@ -6467,7 +6377,6 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list,
for (uint32_t i = 0; i < textures_to_storage_count; i++) {
if (textures_to_storage[i]->layout != VK_IMAGE_LAYOUT_GENERAL) {
-
VkImageMemoryBarrier image_memory_barrier;
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
@@ -6525,9 +6434,10 @@ void RenderingDeviceVulkan::compute_list_set_push_constant(ComputeListID p_list,
#endif
vkCmdPushConstants(cl->command_buffer, cl->state.pipeline_layout, cl->state.pipeline_push_constant_stages, 0, p_data_size, p_data);
#ifdef DEBUG_ENABLED
- cl->validation.pipeline_push_constant_suppplied = true;
+ cl->validation.pipeline_push_constant_supplied = true;
#endif
}
+
void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups) {
ERR_FAIL_COND(p_list != ID_TYPE_COMPUTE_LIST);
ERR_FAIL_COND(!compute_list);
@@ -6551,7 +6461,7 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t
if (cl->validation.pipeline_push_constant_size > 0) {
//using push constants, check that they were supplied
- ERR_FAIL_COND_MSG(!cl->validation.pipeline_push_constant_suppplied,
+ ERR_FAIL_COND_MSG(!cl->validation.pipeline_push_constant_supplied,
"The shader in this pipeline requires a push constant to be set before drawing, but it's not present.");
}
@@ -6560,13 +6470,11 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t
//Bind descriptor sets
for (uint32_t i = 0; i < cl->state.set_count; i++) {
-
if (cl->state.sets[i].pipeline_expected_format == 0) {
continue; //nothing expected by this pipeline
}
#ifdef DEBUG_ENABLED
if (cl->state.sets[i].pipeline_expected_format != cl->state.sets[i].uniform_set_format) {
-
if (cl->state.sets[i].uniform_set_format == 0) {
ERR_FAIL_MSG("Uniforms were never supplied for set (" + itos(i) + ") at the time of drawing, which are required by the pipeline");
} else if (uniform_set_owner.owns(cl->state.sets[i].uniform_set)) {
@@ -6599,7 +6507,6 @@ void RenderingDeviceVulkan::compute_list_end() {
ERR_FAIL_COND(!compute_list);
for (Set<Texture *>::Element *E = compute_list->state.textures_to_sampled_layout.front(); E; E = E->next()) {
-
VkImageMemoryBarrier image_memory_barrier;
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
image_memory_barrier.pNext = nullptr;
@@ -6691,7 +6598,6 @@ void RenderingDeviceVulkan::draw_list_render_secondary_to_framebuffer(ID p_frame
#endif
void RenderingDeviceVulkan::_free_internal(RID p_id) {
-
//push everything so it's disposed of next time this frame index is processed (means, it's safe to do it)
if (texture_owner.owns(p_id)) {
Texture *texture = texture_owner.getornull(p_id);
@@ -6754,8 +6660,8 @@ void RenderingDeviceVulkan::_free_internal(RID p_id) {
ERR_PRINT("Attempted to free invalid ID: " + itos(p_id.get_id()));
}
}
-void RenderingDeviceVulkan::free(RID p_id) {
+void RenderingDeviceVulkan::free(RID p_id) {
_THREAD_SAFE_METHOD_
_free_dependencies(p_id); //recursively erase dependencies first, to avoid potential API problems
@@ -6763,7 +6669,6 @@ void RenderingDeviceVulkan::free(RID p_id) {
}
void RenderingDeviceVulkan::_finalize_command_bufers() {
-
if (draw_list) {
ERR_PRINT("Found open draw list at the end of the frame, this should never happen (further drawing will likely not work).");
}
@@ -6779,7 +6684,6 @@ void RenderingDeviceVulkan::_finalize_command_bufers() {
}
void RenderingDeviceVulkan::_begin_frame() {
-
//erase pending resources
_free_pending_resources(frame);
@@ -6826,7 +6730,6 @@ void RenderingDeviceVulkan::_begin_frame() {
}
void RenderingDeviceVulkan::swap_buffers() {
-
ERR_FAIL_COND_MSG(local_device.is_valid(), "Local devices can't swap buffers.");
_THREAD_SAFE_METHOD_
@@ -6853,7 +6756,6 @@ void RenderingDeviceVulkan::submit() {
}
void RenderingDeviceVulkan::sync() {
-
ERR_FAIL_COND_MSG(local_device.is_null(), "Only local devices can submit and sync.");
ERR_FAIL_COND_MSG(!local_device_processing, "sync can only be called after a submit");
@@ -6959,7 +6861,6 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) {
//buffers
while (frames[p_frame].buffers_to_dispose_of.front()) {
-
_buffer_free(&frames[p_frame].buffers_to_dispose_of.front()->get());
frames[p_frame].buffers_to_dispose_of.pop_front();
@@ -6983,7 +6884,6 @@ uint64_t RenderingDeviceVulkan::get_memory_usage() const {
}
void RenderingDeviceVulkan::_flush(bool p_current_frame) {
-
if (local_device.is_valid() && !p_current_frame) {
return; //flushign previous frames has no effect with local device
}
@@ -6994,7 +6894,6 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) {
}
if (local_device.is_valid()) {
-
VkCommandBuffer command_buffers[2] = { frames[frame].setup_command_buffer, frames[frame].draw_command_buffer };
context->local_device_push_command_buffers(local_device, command_buffers, 2);
context->local_device_sync(local_device);
@@ -7040,7 +6939,6 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) {
}
void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_device) {
-
context = p_context;
device = p_context->get_device();
if (p_local_device) {
@@ -7066,7 +6964,6 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de
frame = 0;
//create setup and frame buffers
for (int i = 0; i < frame_count; i++) {
-
frames[i].index = 0;
{ //create command pool, one per frame is recommended
@@ -7190,7 +7087,6 @@ void RenderingDeviceVulkan::_free_rids(T &p_owner, const char *p_type) {
}
void RenderingDeviceVulkan::capture_timestamp(const String &p_name, bool p_sync_to_draw) {
-
ERR_FAIL_COND(frames[frame].timestamp_count >= max_timestamp_query_elements);
{
@@ -7282,10 +7178,12 @@ uint64_t RenderingDeviceVulkan::get_captured_timestamp_gpu_time(uint32_t p_index
return l;
}
+
uint64_t RenderingDeviceVulkan::get_captured_timestamp_cpu_time(uint32_t p_index) const {
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0);
return frames[frame].timestamp_cpu_result_values[p_index];
}
+
String RenderingDeviceVulkan::get_captured_timestamp_name(uint32_t p_index) const {
ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, String());
return frames[frame].timestamp_result_names[p_index];
@@ -7370,7 +7268,6 @@ int RenderingDeviceVulkan::limit_get(Limit p_limit) {
}
void RenderingDeviceVulkan::finalize() {
-
//free all resources
_flush(false);
@@ -7396,7 +7293,6 @@ void RenderingDeviceVulkan::finalize() {
WARN_PRINT(itos(owned.size()) + " RIDs of type 'Texture' were leaked.");
//free shared first
for (List<RID>::Element *E = owned.front(); E;) {
-
List<RID>::Element *N = E->next();
if (texture_is_shared(E->get())) {
free(E->get());
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 87af5d03d4..eac3250bf7 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -42,7 +42,9 @@
#endif
#endif
#include "vk_mem_alloc.h"
+
#include <vulkan/vulkan.h>
+
//todo:
//compute
//push constants
@@ -51,7 +53,6 @@
class VulkanContext;
class RenderingDeviceVulkan : public RenderingDevice {
-
_THREAD_SAFE_CLASS_
// Miscellaneous tables that map
@@ -123,7 +124,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
// for a framebuffer to render into it.
struct Texture {
-
VkImage image;
VmaAllocation allocation;
VmaAllocationInfo allocation_info;
@@ -204,16 +204,10 @@ class RenderingDeviceVulkan : public RenderingDevice {
Error _insert_staging_block();
struct Buffer {
-
- uint32_t size;
- VkBuffer buffer;
- VmaAllocation allocation;
+ uint32_t size = 0;
+ VkBuffer buffer = VK_NULL_HANDLE;
+ VmaAllocation allocation = nullptr;
VkDescriptorBufferInfo buffer_info; //used for binding
- Buffer() {
- size = 0;
- buffer = VK_NULL_HANDLE;
- allocation = nullptr;
- }
};
Error _buffer_allocate(Buffer *p_buffer, uint32_t p_size, uint32_t p_usage, VmaMemoryUsage p_mapping);
@@ -237,7 +231,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct FramebufferFormatKey {
Vector<AttachmentFormat> attachments;
bool operator<(const FramebufferFormatKey &p_key) const {
-
int as = attachments.size();
int bs = p_key.attachments.size();
if (as != bs) {
@@ -521,9 +514,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
// does not submit something invalid.
struct Shader {
-
struct Set {
-
Vector<UniformInfo> uniform_info;
VkDescriptorSetLayout descriptor_set_layout;
};
@@ -576,7 +567,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct DescriptorPoolKey {
union {
struct {
- uint16_t uniform_type[UNIFORM_TYPE_MAX]; //using 16 bits because, for sending arrays, each element is a pool set.
+ uint16_t uniform_type[UNIFORM_TYPE_MAX]; // Using 16 bits because, for sending arrays, each element is a pool set.
};
struct {
uint64_t key1;
@@ -685,7 +676,6 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID_Owner<RenderPipeline, true> render_pipeline_owner;
struct ComputePipeline {
-
RID shader;
Vector<uint32_t> set_formats;
VkPipelineLayout pipeline_layout; // not owned, needed for push constants
@@ -719,107 +709,67 @@ class RenderingDeviceVulkan : public RenderingDevice {
Vector<SplitDrawListAllocator> split_draw_list_allocators;
struct DrawList {
-
- VkCommandBuffer command_buffer; //if persistent, this is owned, otherwise it's shared with the ringbuffer
+ VkCommandBuffer command_buffer; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
Rect2i viewport;
struct SetState {
- uint32_t pipeline_expected_format;
- uint32_t uniform_set_format;
- VkDescriptorSet descriptor_set;
+ uint32_t pipeline_expected_format = 0;
+ uint32_t uniform_set_format = 0;
+ VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
RID uniform_set;
- bool bound;
- SetState() {
- bound = false;
- pipeline_expected_format = 0;
- uniform_set_format = 0;
- descriptor_set = VK_NULL_HANDLE;
- }
+ bool bound = false;
};
struct State {
SetState sets[MAX_UNIFORM_SETS];
- uint32_t set_count;
+ uint32_t set_count = 0;
RID pipeline;
RID pipeline_shader;
- VkPipelineLayout pipeline_layout;
+ VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
RID vertex_array;
RID index_array;
- uint32_t pipeline_push_constant_stages;
-
- State() {
- set_count = 0;
- pipeline_layout = VK_NULL_HANDLE;
- pipeline_push_constant_stages = 0;
- }
+ uint32_t pipeline_push_constant_stages = 0;
} state;
-#ifdef DEBUG_ENABLED
+#ifdef DEBUG_ENABLED
struct Validation {
- bool active; //means command buffer was not closes, so you can keep adding things
- FramebufferFormatID framebuffer_format;
- //actual render pass values
- uint32_t dynamic_state;
- VertexFormatID vertex_format; //INVALID_ID if not set
- uint32_t vertex_array_size; //0 if not set
- uint32_t vertex_max_instances_allowed;
- bool index_buffer_uses_restart_indices;
- uint32_t index_array_size; //0 if index buffer not set
- uint32_t index_array_max_index;
+ bool active = true; // Means command buffer was not closed, so you can keep adding things.
+ FramebufferFormatID framebuffer_format = INVALID_ID;
+ // Actual render pass values.
+ uint32_t dynamic_state = 0;
+ VertexFormatID vertex_format = INVALID_ID;
+ uint32_t vertex_array_size = 0;
+ uint32_t vertex_max_instances_allowed = 0xFFFFFFFF;
+ bool index_buffer_uses_restart_indices = false;
+ uint32_t index_array_size = 0;
+ uint32_t index_array_max_index = 0;
uint32_t index_array_offset;
Vector<uint32_t> set_formats;
Vector<bool> set_bound;
Vector<RID> set_rids;
- //last pipeline set values
- bool pipeline_active;
- uint32_t pipeline_dynamic_state;
- VertexFormatID pipeline_vertex_format;
+ // Last pipeline set values.
+ bool pipeline_active = false;
+ uint32_t pipeline_dynamic_state = 0;
+ VertexFormatID pipeline_vertex_format = INVALID_ID;
RID pipeline_shader;
- uint32_t invalid_set_from;
- bool pipeline_uses_restart_indices;
+ uint32_t invalid_set_from = 0;
+ bool pipeline_uses_restart_indices = false;
uint32_t pipeline_primitive_divisor;
uint32_t pipeline_primitive_minimum;
Vector<uint32_t> pipeline_set_formats;
- uint32_t pipeline_push_constant_size;
- bool pipeline_push_constant_suppplied;
-
- Validation() {
- active = true;
- dynamic_state = 0;
- vertex_format = INVALID_ID;
- vertex_array_size = 0;
- vertex_max_instances_allowed = 0xFFFFFFFF;
- framebuffer_format = INVALID_ID;
- index_array_size = 0; //not sent
- index_array_max_index = 0; //not set
- index_buffer_uses_restart_indices = false;
- invalid_set_from = 0;
-
- //pipeline state initalize
- pipeline_active = false;
- pipeline_dynamic_state = 0;
- pipeline_vertex_format = INVALID_ID;
- pipeline_uses_restart_indices = false;
- pipeline_push_constant_size = 0;
- pipeline_push_constant_suppplied = false;
- }
+ uint32_t pipeline_push_constant_size = 0;
+ bool pipeline_push_constant_supplied = false;
} validation;
#else
struct Validation {
- uint32_t vertex_array_size; //0 if not set
- uint32_t index_array_size; //0 if index buffer not set
+ uint32_t vertex_array_size = 0;
+ uint32_t index_array_size = 0;
uint32_t index_array_offset;
-
- Validation() {
- vertex_array_size = 0;
- index_array_size = 0; //not sent
- }
} validation;
-
#endif
};
- DrawList *draw_list; //one for regular draw lists, multiple for split.
+ DrawList *draw_list; // One for regular draw lists, multiple for split.
uint32_t draw_list_count;
bool draw_list_split;
Vector<RID> draw_list_bound_textures;
@@ -836,63 +786,39 @@ class RenderingDeviceVulkan : public RenderingDevice {
/**********************/
struct ComputeList {
-
- VkCommandBuffer command_buffer; //if persistent, this is owned, otherwise it's shared with the ringbuffer
+ VkCommandBuffer command_buffer; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
struct SetState {
- uint32_t pipeline_expected_format;
- uint32_t uniform_set_format;
- VkDescriptorSet descriptor_set;
+ uint32_t pipeline_expected_format = 0;
+ uint32_t uniform_set_format = 0;
+ VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
RID uniform_set;
- bool bound;
- SetState() {
- bound = false;
- pipeline_expected_format = 0;
- uniform_set_format = 0;
- descriptor_set = VK_NULL_HANDLE;
- }
+ bool bound = false;
};
struct State {
Set<Texture *> textures_to_sampled_layout;
-
SetState sets[MAX_UNIFORM_SETS];
- uint32_t set_count;
+ uint32_t set_count = 0;
RID pipeline;
RID pipeline_shader;
- VkPipelineLayout pipeline_layout;
- uint32_t pipeline_push_constant_stages;
-
- State() {
- set_count = 0;
- pipeline_layout = VK_NULL_HANDLE;
- pipeline_push_constant_stages = 0;
- }
+ VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
+ uint32_t pipeline_push_constant_stages = 0;
} state;
-#ifdef DEBUG_ENABLED
+#ifdef DEBUG_ENABLED
struct Validation {
- bool active; //means command buffer was not closes, so you can keep adding things
+ bool active = true; // Means command buffer was not closed, so you can keep adding things.
Vector<uint32_t> set_formats;
Vector<bool> set_bound;
Vector<RID> set_rids;
- //last pipeline set values
- bool pipeline_active;
+ // Last pipeline set values.
+ bool pipeline_active = false;
RID pipeline_shader;
- uint32_t invalid_set_from;
+ uint32_t invalid_set_from = 0;
Vector<uint32_t> pipeline_set_formats;
- uint32_t pipeline_push_constant_size;
- bool pipeline_push_constant_suppplied;
-
- Validation() {
- active = true;
- invalid_set_from = 0;
-
- //pipeline state initalize
- pipeline_active = false;
- pipeline_push_constant_size = 0;
- pipeline_push_constant_suppplied = false;
- }
+ uint32_t pipeline_push_constant_size = 0;
+ bool pipeline_push_constant_supplied = false;
} validation;
#endif
};
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 9471b4604c..a8a29aaeea 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -49,7 +49,6 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanContext::_debug_messenger_callback(
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
-
// This error needs to be ignored because the AMD allocator will mix up memory types on IGP processors.
if (strstr(pCallbackData->pMessage, "Mapping an image with layout") != nullptr &&
strstr(pCallbackData->pMessage, "can result in undefined behavior if this memory is used by the device") != nullptr) {
@@ -163,7 +162,6 @@ VkBool32 VulkanContext::_check_layers(uint32_t check_count, const char **check_n
}
Error VulkanContext::_create_validation_layers() {
-
VkResult err;
const char *instance_validation_layers_alt1[] = { "VK_LAYER_KHRONOS_validation" };
const char *instance_validation_layers_alt2[] = { "VK_LAYER_LUNARG_standard_validation" };
@@ -218,7 +216,6 @@ Error VulkanContext::_create_validation_layers() {
}
Error VulkanContext::_initialize_extensions() {
-
VkResult err;
uint32_t instance_extension_count = 0;
@@ -275,7 +272,6 @@ Error VulkanContext::_initialize_extensions() {
}
Error VulkanContext::_create_physical_device() {
-
/* Look for validation layers */
if (use_validation_layers) {
_create_validation_layers();
@@ -513,7 +509,6 @@ Error VulkanContext::_create_physical_device() {
}
Error VulkanContext::_create_device() {
-
VkResult err;
float queue_priorities[1] = { 0.0 };
VkDeviceQueueCreateInfo queues[2];
@@ -552,7 +547,6 @@ Error VulkanContext::_create_device() {
}
Error VulkanContext::_initialize_queues(VkSurfaceKHR surface) {
-
// Iterate over each queue to learn whether it supports presenting:
VkBool32 *supportsPresent = (VkBool32 *)malloc(queue_family_count * sizeof(VkBool32));
for (uint32_t i = 0; i < queue_family_count; i++) {
@@ -705,7 +699,6 @@ Error VulkanContext::_create_semaphores() {
}
Error VulkanContext::_window_create(DisplayServer::WindowID p_window_id, VkSurfaceKHR p_surface, int p_width, int p_height) {
-
ERR_FAIL_COND_V(windows.has(p_window_id), ERR_INVALID_PARAMETER);
if (!queues_initialized) {
@@ -766,7 +759,6 @@ void VulkanContext::window_destroy(DisplayServer::WindowID p_window_id) {
}
Error VulkanContext::_clean_up_swap_chain(Window *window) {
-
if (!window->swapchain) {
return OK;
}
@@ -1136,7 +1128,6 @@ Error VulkanContext::_update_swap_chain(Window *window) {
}
Error VulkanContext::initialize() {
-
Error err = _create_physical_device();
if (err) {
return err;
@@ -1150,7 +1141,6 @@ void VulkanContext::set_setup_buffer(const VkCommandBuffer &pCommandBuffer) {
}
void VulkanContext::append_command_buffer(const VkCommandBuffer &pCommandBuffer) {
-
if (command_buffer_queue.size() <= command_buffer_count) {
command_buffer_queue.resize(command_buffer_count + 1);
}
@@ -1160,14 +1150,12 @@ void VulkanContext::append_command_buffer(const VkCommandBuffer &pCommandBuffer)
}
void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) {
-
// ensure everything else pending is executed
vkDeviceWaitIdle(device);
//flush the pending setup buffer
if (p_flush_setup && command_buffer_queue[0]) {
-
//use a fence to wait for everything done
VkSubmitInfo submit_info;
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
@@ -1186,7 +1174,6 @@ void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) {
}
if (p_flush_pending && command_buffer_count > 1) {
-
//use a fence to wait for everything done
VkSubmitInfo submit_info;
@@ -1208,7 +1195,6 @@ void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) {
}
Error VulkanContext::prepare_buffers() {
-
if (!queues_initialized) {
return OK;
}
@@ -1220,7 +1206,6 @@ Error VulkanContext::prepare_buffers() {
vkResetFences(device, 1, &fences[frame_index]);
for (Map<int, Window>::Element *E = windows.front(); E; E = E->next()) {
-
Window *w = &E->get();
if (w->swapchain == VK_NULL_HANDLE) {
@@ -1256,7 +1241,6 @@ Error VulkanContext::prepare_buffers() {
}
Error VulkanContext::swap_buffers() {
-
if (!queues_initialized) {
return OK;
}
@@ -1475,9 +1459,11 @@ VkDevice VulkanContext::get_device() {
VkPhysicalDevice VulkanContext::get_physical_device() {
return gpu;
}
+
int VulkanContext::get_swapchain_image_count() const {
return swapchainImageCount;
}
+
uint32_t VulkanContext::get_graphics_queue() const {
return graphics_queue_family_index;
}
@@ -1551,7 +1537,6 @@ VkDevice VulkanContext::local_device_get_vk_device(RID p_local_device) {
}
void VulkanContext::local_device_push_command_buffers(RID p_local_device, const VkCommandBuffer *p_buffers, int p_count) {
-
LocalDevice *ld = local_device_owner.getornull(p_local_device);
ERR_FAIL_COND(ld->waiting);
@@ -1582,7 +1567,6 @@ void VulkanContext::local_device_push_command_buffers(RID p_local_device, const
}
void VulkanContext::local_device_sync(RID p_local_device) {
-
LocalDevice *ld = local_device_owner.getornull(p_local_device);
ERR_FAIL_COND(!ld->waiting);
@@ -1591,7 +1575,6 @@ void VulkanContext::local_device_sync(RID p_local_device) {
}
void VulkanContext::local_device_free(RID p_local_device) {
-
LocalDevice *ld = local_device_owner.getornull(p_local_device);
vkDestroyDevice(ld->device, nullptr);
local_device_owner.free(p_local_device);
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h
index 51c3febb47..3f4cfac123 100644
--- a/drivers/vulkan/vulkan_context.h
+++ b/drivers/vulkan/vulkan_context.h
@@ -40,7 +40,6 @@
#include <vulkan/vulkan.h>
class VulkanContext {
-
enum {
MAX_EXTENSIONS = 128,
MAX_LAYERS = 64,
@@ -81,30 +80,15 @@ class VulkanContext {
} SwapchainImageResources;
struct Window {
-
- bool is_minimzed;
- VkSurfaceKHR surface;
- VkSwapchainKHR swapchain;
- SwapchainImageResources *swapchain_image_resources;
- VkPresentModeKHR presentMode;
- uint32_t current_buffer;
- int width;
- int height;
+ VkSurfaceKHR surface = VK_NULL_HANDLE;
+ VkSwapchainKHR swapchain = VK_NULL_HANDLE;
+ SwapchainImageResources *swapchain_image_resources = VK_NULL_HANDLE;
+ VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR;
+ uint32_t current_buffer = 0;
+ int width = 0;
+ int height = 0;
VkCommandPool present_cmd_pool; //for separate present queue
-
- VkRenderPass render_pass;
-
- Window() {
- width = 0;
- height = 0;
- render_pass = VK_NULL_HANDLE;
- current_buffer = 0;
- surface = VK_NULL_HANDLE;
- swapchain_image_resources = VK_NULL_HANDLE;
- swapchain = VK_NULL_HANDLE;
- is_minimzed = false;
- presentMode = VK_PRESENT_MODE_FIFO_KHR;
- }
+ VkRenderPass render_pass = VK_NULL_HANDLE;
};
struct LocalDevice {
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index ab2976f02c..cd1c08b717 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -69,13 +69,11 @@ static bool default_render_device_changed = false;
static bool default_capture_device_changed = false;
class CMMNotificationClient : public IMMNotificationClient {
- LONG _cRef;
- IMMDeviceEnumerator *_pEnumerator;
+ LONG _cRef = 1;
+ IMMDeviceEnumerator *_pEnumerator = nullptr;
public:
- CMMNotificationClient() :
- _cRef(1),
- _pEnumerator(nullptr) {}
+ CMMNotificationClient() {}
virtual ~CMMNotificationClient() {
if ((_pEnumerator) != nullptr) {
(_pEnumerator)->Release();
@@ -141,7 +139,6 @@ public:
static CMMNotificationClient notif_client;
Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool reinit) {
-
WAVEFORMATEX *pwfex;
IMMDeviceEnumerator *enumerator = nullptr;
IMMDevice *device = nullptr;
@@ -313,7 +310,6 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c
}
Error AudioDriverWASAPI::init_render_device(bool reinit) {
-
Error err = audio_device_init(&audio_output, false, reinit);
if (err != OK)
return err;
@@ -352,7 +348,6 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) {
}
Error AudioDriverWASAPI::init_capture_device(bool reinit) {
-
Error err = audio_device_init(&audio_input, true, reinit);
if (err != OK)
return err;
@@ -368,7 +363,6 @@ Error AudioDriverWASAPI::init_capture_device(bool reinit) {
}
Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
-
if (p_device->active) {
if (p_device->audio_client) {
p_device->audio_client->Stop();
@@ -385,18 +379,15 @@ Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
}
Error AudioDriverWASAPI::finish_render_device() {
-
return audio_device_finish(&audio_output);
}
Error AudioDriverWASAPI::finish_capture_device() {
-
return audio_device_finish(&audio_input);
}
Error AudioDriverWASAPI::init() {
-
- mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
Error err = init_render_device();
if (err != OK) {
@@ -412,17 +403,14 @@ Error AudioDriverWASAPI::init() {
}
int AudioDriverWASAPI::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverWASAPI::get_speaker_mode() const {
-
return get_speaker_mode_by_total_channels(channels);
}
Array AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
-
Array list;
IMMDeviceCollection *devices = nullptr;
IMMDeviceEnumerator *enumerator = nullptr;
@@ -470,12 +458,10 @@ Array AudioDriverWASAPI::audio_device_get_list(bool p_capture) {
}
Array AudioDriverWASAPI::get_device_list() {
-
return audio_device_get_list(false);
}
String AudioDriverWASAPI::get_device() {
-
lock();
String name = audio_output.device_name;
unlock();
@@ -484,7 +470,6 @@ String AudioDriverWASAPI::get_device() {
}
void AudioDriverWASAPI::set_device(String device) {
-
lock();
audio_output.new_device = device;
unlock();
@@ -552,13 +537,11 @@ void AudioDriverWASAPI::write_sample(WORD format_tag, int bits_per_sample, BYTE
}
void AudioDriverWASAPI::thread_func(void *p_udata) {
-
AudioDriverWASAPI *ad = (AudioDriverWASAPI *)p_udata;
uint32_t avail_frames = 0;
uint32_t write_ofs = 0;
while (!ad->exit_thread) {
-
uint32_t read_frames = 0;
uint32_t written_frames = 0;
@@ -585,19 +568,16 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
ad->start_counting_ticks();
if (avail_frames > 0 && ad->audio_output.audio_client) {
-
UINT32 cur_frames;
bool invalidated = false;
HRESULT hr = ad->audio_output.audio_client->GetCurrentPadding(&cur_frames);
if (hr == S_OK) {
-
// Check how much frames are available on the WASAPI buffer
UINT32 write_frames = MIN(ad->buffer_frames - cur_frames, avail_frames);
if (write_frames > 0) {
BYTE *buffer = nullptr;
hr = ad->audio_output.render_client->GetBuffer(write_frames, &buffer);
if (hr == S_OK) {
-
// We're using WASAPI Shared Mode so we must convert the buffer
if (ad->channels == ad->audio_output.channels) {
for (unsigned int i = 0; i < write_frames * ad->channels; i++) {
@@ -768,7 +748,6 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
}
void AudioDriverWASAPI::start() {
-
if (audio_output.audio_client) {
HRESULT hr = audio_output.audio_client->Start();
if (hr != S_OK) {
@@ -780,17 +759,14 @@ void AudioDriverWASAPI::start() {
}
void AudioDriverWASAPI::lock() {
-
mutex.lock();
}
void AudioDriverWASAPI::unlock() {
-
mutex.unlock();
}
void AudioDriverWASAPI::finish() {
-
if (thread) {
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -804,7 +780,6 @@ void AudioDriverWASAPI::finish() {
}
Error AudioDriverWASAPI::capture_start() {
-
Error err = init_capture_device();
if (err != OK) {
ERR_PRINT("WASAPI: init_capture_device error");
@@ -821,7 +796,6 @@ Error AudioDriverWASAPI::capture_start() {
}
Error AudioDriverWASAPI::capture_stop() {
-
if (audio_input.active) {
audio_input.audio_client->Stop();
audio_input.active = false;
@@ -833,19 +807,16 @@ Error AudioDriverWASAPI::capture_stop() {
}
void AudioDriverWASAPI::capture_set_device(const String &p_name) {
-
lock();
audio_input.new_device = p_name;
unlock();
}
Array AudioDriverWASAPI::capture_get_device_list() {
-
return audio_device_get_list(true);
}
String AudioDriverWASAPI::capture_get_device() {
-
lock();
String name = audio_input.device_name;
unlock();
@@ -854,17 +825,7 @@ String AudioDriverWASAPI::capture_get_device() {
}
AudioDriverWASAPI::AudioDriverWASAPI() {
-
- thread = nullptr;
-
samples_in.clear();
-
- channels = 0;
- mix_rate = 0;
- buffer_frames = 0;
-
- thread_exited = false;
- exit_thread = false;
}
-#endif
+#endif // WASAPI_ENABLED
diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h
index 01a4666812..41ff7c9895 100644
--- a/drivers/wasapi/audio_driver_wasapi.h
+++ b/drivers/wasapi/audio_driver_wasapi.h
@@ -42,50 +42,38 @@
#include <windows.h>
class AudioDriverWASAPI : public AudioDriver {
-
class AudioDeviceWASAPI {
public:
- IAudioClient *audio_client;
- IAudioRenderClient *render_client;
- IAudioCaptureClient *capture_client;
- bool active;
-
- WORD format_tag;
- WORD bits_per_sample;
- unsigned int channels;
- unsigned int frame_size;
-
- String device_name;
- String new_device;
-
- AudioDeviceWASAPI() :
- audio_client(nullptr),
- render_client(nullptr),
- capture_client(nullptr),
- active(false),
- format_tag(0),
- bits_per_sample(0),
- channels(0),
- frame_size(0),
- device_name("Default"),
- new_device("Default") {
- }
+ IAudioClient *audio_client = nullptr;
+ IAudioRenderClient *render_client = nullptr;
+ IAudioCaptureClient *capture_client = nullptr;
+ bool active = false;
+
+ WORD format_tag = 0;
+ WORD bits_per_sample = 0;
+ unsigned int channels = 0;
+ unsigned int frame_size = 0;
+
+ String device_name = "Default";
+ String new_device = "Default";
+
+ AudioDeviceWASAPI() {}
};
AudioDeviceWASAPI audio_input;
AudioDeviceWASAPI audio_output;
Mutex mutex;
- Thread *thread;
+ Thread *thread = nullptr;
Vector<int32_t> samples_in;
- unsigned int channels;
- int mix_rate;
- int buffer_frames;
+ unsigned int channels = 0;
+ int mix_rate = 0;
+ int buffer_frames = 0;
- bool thread_exited;
- mutable bool exit_thread;
+ bool thread_exited = false;
+ mutable bool exit_thread = false;
static _FORCE_INLINE_ void write_sample(WORD format_tag, int bits_per_sample, BYTE *buffer, int i, int32_t sample);
static _FORCE_INLINE_ int32_t read_sample(WORD format_tag, int bits_per_sample, BYTE *buffer, int i);
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index a8618b05d7..2653ac1cdb 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -53,7 +53,6 @@
*/
struct DirAccessWindowsPrivate {
-
HANDLE h; //handle for findfirstfile
WIN32_FIND_DATA f;
WIN32_FIND_DATAW fu; //unicode version
@@ -62,7 +61,6 @@ struct DirAccessWindowsPrivate {
// CreateFolderAsync
Error DirAccessWindows::list_dir_begin() {
-
_cisdir = false;
_cishidden = false;
@@ -73,7 +71,6 @@ Error DirAccessWindows::list_dir_begin() {
}
String DirAccessWindows::get_next() {
-
if (p->h == INVALID_HANDLE_VALUE)
return "";
@@ -83,7 +80,6 @@ String DirAccessWindows::get_next() {
String name = p->fu.cFileName;
if (FindNextFileW(p->h, &p->fu) == 0) {
-
FindClose(p->h);
p->h = INVALID_HANDLE_VALUE;
}
@@ -92,29 +88,25 @@ String DirAccessWindows::get_next() {
}
bool DirAccessWindows::current_is_dir() const {
-
return _cisdir;
}
bool DirAccessWindows::current_is_hidden() const {
-
return _cishidden;
}
void DirAccessWindows::list_dir_end() {
-
if (p->h != INVALID_HANDLE_VALUE) {
-
FindClose(p->h);
p->h = INVALID_HANDLE_VALUE;
}
}
-int DirAccessWindows::get_drive_count() {
+int DirAccessWindows::get_drive_count() {
return drive_count;
}
-String DirAccessWindows::get_drive(int p_drive) {
+String DirAccessWindows::get_drive(int p_drive) {
if (p_drive < 0 || p_drive >= drive_count)
return "";
@@ -122,7 +114,6 @@ String DirAccessWindows::get_drive(int p_drive) {
}
Error DirAccessWindows::change_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
p_dir = fix_path(p_dir);
@@ -136,7 +127,6 @@ Error DirAccessWindows::change_dir(String p_dir) {
String base = _get_root_path();
if (base != "") {
-
GetCurrentDirectoryW(2048, real_current_dir_name);
String new_dir;
new_dir = String(real_current_dir_name).replace("\\", "/");
@@ -146,7 +136,6 @@ Error DirAccessWindows::change_dir(String p_dir) {
}
if (worked) {
-
GetCurrentDirectoryW(2048, real_current_dir_name);
current_dir = real_current_dir_name; // TODO, utf8 parser
current_dir = current_dir.replace("\\", "/");
@@ -160,7 +149,6 @@ Error DirAccessWindows::change_dir(String p_dir) {
}
Error DirAccessWindows::make_dir(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
p_dir = fix_path(p_dir);
@@ -190,10 +178,8 @@ Error DirAccessWindows::make_dir(String p_dir) {
}
String DirAccessWindows::get_current_dir(bool p_include_drive) {
-
String base = _get_root_path();
if (base != "") {
-
String bd = current_dir.replace("\\", "/").replace_first(base, "");
if (bd.begins_with("/"))
return _get_root_string() + bd.substr(1, bd.length());
@@ -217,7 +203,6 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) {
}
bool DirAccessWindows::file_exists(String p_file) {
-
GLOBAL_LOCK_FUNCTION
if (!p_file.is_abs_path())
@@ -239,7 +224,6 @@ bool DirAccessWindows::file_exists(String p_file) {
}
bool DirAccessWindows::dir_exists(String p_dir) {
-
GLOBAL_LOCK_FUNCTION
if (p_dir.is_rel_path())
@@ -260,7 +244,6 @@ bool DirAccessWindows::dir_exists(String p_dir) {
}
Error DirAccessWindows::rename(String p_path, String p_new_path) {
-
if (p_path.is_rel_path())
p_path = get_current_dir().plus_file(p_path);
@@ -298,16 +281,11 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) {
}
Error DirAccessWindows::remove(String p_path) {
-
if (p_path.is_rel_path())
p_path = get_current_dir().plus_file(p_path);
p_path = fix_path(p_path);
- printf("erasing %s\n", p_path.utf8().get_data());
- //WIN32_FILE_ATTRIBUTE_DATA fileInfo;
- //DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo);
-
DWORD fileAttr;
fileAttr = GetFileAttributesW(p_path.c_str());
@@ -318,6 +296,7 @@ Error DirAccessWindows::remove(String p_path) {
else
return ::_wunlink(p_path.c_str()) == 0 ? OK : FAILED;
}
+
/*
FileType DirAccessWindows::get_file_type(const String& p_file) const {
@@ -345,9 +324,9 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const {
return (attr&FILE_ATTRIBUTE_DIRECTORY)?FILE_TYPE_
}
+
*/
size_t DirAccessWindows::get_space_left() {
-
uint64_t bytes = 0;
if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr))
return 0;
@@ -377,7 +356,6 @@ String DirAccessWindows::get_filesystem_type() const {
&dwFileSystemFlags,
szFileSystemName,
sizeof(szFileSystemName)) == TRUE) {
-
return String(szFileSystemName);
}
@@ -385,7 +363,6 @@ String DirAccessWindows::get_filesystem_type() const {
}
DirAccessWindows::DirAccessWindows() {
-
p = memnew(DirAccessWindowsPrivate);
p->h = INVALID_HANDLE_VALUE;
current_dir = ".";
@@ -401,7 +378,6 @@ DirAccessWindows::DirAccessWindows() {
DWORD mask = GetLogicalDrives();
for (int i = 0; i < MAX_DRIVES; i++) {
-
if (mask & (1 << i)) { //DRIVE EXISTS
drives[drive_count] = 'A' + i;
@@ -414,7 +390,6 @@ DirAccessWindows::DirAccessWindows() {
}
DirAccessWindows::~DirAccessWindows() {
-
memdelete(p);
}
diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h
index f59e4d7030..47aedfecf5 100644
--- a/drivers/windows/dir_access_windows.h
+++ b/drivers/windows/dir_access_windows.h
@@ -42,7 +42,6 @@
struct DirAccessWindowsPrivate;
class DirAccessWindows : public DirAccess {
-
enum {
MAX_DRIVES = 26
};
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 69078b3326..50366d0b2d 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -49,17 +49,14 @@
#endif
void FileAccessWindows::check_errors() const {
-
ERR_FAIL_COND(!f);
if (feof(f)) {
-
last_error = ERR_FILE_EOF;
}
}
Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
-
path_src = p_path;
path = fix_path(p_path);
if (f)
@@ -83,7 +80,6 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
struct _stat st;
if (_wstat(path.c_str(), &st) == 0) {
-
if (!S_ISREG(st.st_mode))
return ERR_FILE_CANT_OPEN;
};
@@ -99,7 +95,6 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
if (f != INVALID_HANDLE_VALUE) {
String fname = d.cFileName;
if (fname != String()) {
-
String base_file = path.get_file();
if (base_file != fname && base_file.findn(fname) == 0) {
WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms.");
@@ -135,7 +130,6 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessWindows::close() {
-
if (!f)
return;
@@ -143,7 +137,6 @@ void FileAccessWindows::close() {
f = nullptr;
if (save_path != "") {
-
bool rename_error = true;
int attempts = 4;
while (rename_error && attempts) {
@@ -185,36 +178,33 @@ void FileAccessWindows::close() {
}
String FileAccessWindows::get_path() const {
-
return path_src;
}
String FileAccessWindows::get_path_absolute() const {
-
return path;
}
bool FileAccessWindows::is_open() const {
-
return (f != nullptr);
}
-void FileAccessWindows::seek(size_t p_position) {
+void FileAccessWindows::seek(size_t p_position) {
ERR_FAIL_COND(!f);
last_error = OK;
if (fseek(f, p_position, SEEK_SET))
check_errors();
prev_op = 0;
}
-void FileAccessWindows::seek_end(int64_t p_position) {
+void FileAccessWindows::seek_end(int64_t p_position) {
ERR_FAIL_COND(!f);
if (fseek(f, p_position, SEEK_END))
check_errors();
prev_op = 0;
}
-size_t FileAccessWindows::get_position() const {
+size_t FileAccessWindows::get_position() const {
size_t aux_position = 0;
aux_position = ftell(f);
if (!aux_position) {
@@ -222,8 +212,8 @@ size_t FileAccessWindows::get_position() const {
};
return aux_position;
}
-size_t FileAccessWindows::get_len() const {
+size_t FileAccessWindows::get_len() const {
ERR_FAIL_COND_V(!f, 0);
size_t pos = get_position();
@@ -235,13 +225,11 @@ size_t FileAccessWindows::get_len() const {
}
bool FileAccessWindows::eof_reached() const {
-
check_errors();
return last_error == ERR_FILE_EOF;
}
uint8_t FileAccessWindows::get_8() const {
-
ERR_FAIL_COND_V(!f, 0);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == WRITE) {
@@ -259,7 +247,6 @@ uint8_t FileAccessWindows::get_8() const {
}
int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const {
-
ERR_FAIL_COND_V(!f, -1);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == WRITE) {
@@ -273,12 +260,10 @@ int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const {
};
Error FileAccessWindows::get_error() const {
-
return last_error;
}
void FileAccessWindows::flush() {
-
ERR_FAIL_COND(!f);
fflush(f);
if (prev_op == WRITE)
@@ -286,7 +271,6 @@ void FileAccessWindows::flush() {
}
void FileAccessWindows::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND(!f);
if (flags == READ_WRITE || flags == WRITE_READ) {
if (prev_op == READ) {
@@ -313,23 +297,19 @@ void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) {
}
bool FileAccessWindows::file_exists(const String &p_name) {
-
FILE *g;
//printf("opening file %s\n", p_fname.c_str());
String filename = fix_path(p_name);
_wfopen_s(&g, filename.c_str(), L"rb");
if (g == nullptr) {
-
return false;
} else {
-
fclose(g);
return true;
}
}
uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
-
String file = fix_path(p_file);
if (file.ends_with("/") && file != "/")
file = file.substr(0, file.length() - 1);
@@ -338,7 +318,6 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
int rv = _wstat(file.c_str(), &st);
if (rv == 0) {
-
return st.st_mtime;
} else {
ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + file + ".");
@@ -353,15 +332,8 @@ Error FileAccessWindows::_set_unix_permissions(const String &p_file, uint32_t p_
return ERR_UNAVAILABLE;
}
-FileAccessWindows::FileAccessWindows() :
- f(nullptr),
- flags(0),
- prev_op(0),
- last_error(OK) {
-}
FileAccessWindows::~FileAccessWindows() {
-
close();
}
-#endif
+#endif // WINDOWS_ENABLED
diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h
index 28d4375878..98c0efe576 100644
--- a/drivers/windows/file_access_windows.h
+++ b/drivers/windows/file_access_windows.h
@@ -39,12 +39,11 @@
#include <stdio.h>
class FileAccessWindows : public FileAccess {
-
- FILE *f;
- int flags;
+ FILE *f = nullptr;
+ int flags = 0;
void check_errors() const;
- mutable int prev_op;
- mutable Error last_error;
+ mutable int prev_op = 0;
+ mutable Error last_error = OK;
String path;
String path_src;
String save_path;
@@ -79,9 +78,10 @@ public:
virtual uint32_t _get_unix_permissions(const String &p_file);
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
- FileAccessWindows();
+ FileAccessWindows() {}
virtual ~FileAccessWindows();
};
-#endif
-#endif
+#endif // WINDOWS_ENABLED
+
+#endif // FILE_ACCESS_WINDOWS_H
diff --git a/drivers/windows/rw_lock_windows.cpp b/drivers/windows/rw_lock_windows.cpp
index 438f4bf10d..757c7661f5 100644
--- a/drivers/windows/rw_lock_windows.cpp
+++ b/drivers/windows/rw_lock_windows.cpp
@@ -38,17 +38,14 @@
#include <stdio.h>
void RWLockWindows::read_lock() {
-
AcquireSRWLockShared(&lock);
}
void RWLockWindows::read_unlock() {
-
ReleaseSRWLockShared(&lock);
}
Error RWLockWindows::read_try_lock() {
-
if (TryAcquireSRWLockShared(&lock) == 0) {
return ERR_BUSY;
} else {
@@ -57,12 +54,10 @@ Error RWLockWindows::read_try_lock() {
}
void RWLockWindows::write_lock() {
-
AcquireSRWLockExclusive(&lock);
}
void RWLockWindows::write_unlock() {
-
ReleaseSRWLockExclusive(&lock);
}
@@ -75,17 +70,14 @@ Error RWLockWindows::write_try_lock() {
}
RWLock *RWLockWindows::create_func_windows() {
-
return memnew(RWLockWindows);
}
void RWLockWindows::make_default() {
-
create_func = create_func_windows;
}
RWLockWindows::RWLockWindows() {
-
InitializeSRWLock(&lock);
}
diff --git a/drivers/windows/rw_lock_windows.h b/drivers/windows/rw_lock_windows.h
index 3705c1eb38..61dd679d32 100644
--- a/drivers/windows/rw_lock_windows.h
+++ b/drivers/windows/rw_lock_windows.h
@@ -38,7 +38,6 @@
#include <windows.h>
class RWLockWindows : public RWLock {
-
SRWLOCK lock;
static RWLock *create_func_windows();
diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp
index aea2db2603..ca7d936fac 100644
--- a/drivers/windows/thread_windows.cpp
+++ b/drivers/windows/thread_windows.cpp
@@ -35,17 +35,14 @@
#include "core/os/memory.h"
Thread::ID ThreadWindows::get_id() const {
-
return id;
}
Thread *ThreadWindows::create_thread_windows() {
-
return memnew(ThreadWindows);
}
DWORD ThreadWindows::thread_callback(LPVOID userdata) {
-
ThreadWindows *t = reinterpret_cast<ThreadWindows *>(userdata);
ScriptServer::thread_enter(); //scripts may need to attach a stack
@@ -60,7 +57,6 @@ DWORD ThreadWindows::thread_callback(LPVOID userdata) {
}
Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
-
ThreadWindows *tr = memnew(ThreadWindows);
tr->callback = p_callback;
tr->user = p_user;
@@ -70,12 +66,12 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void
return tr;
}
-Thread::ID ThreadWindows::get_thread_id_func_windows() {
+Thread::ID ThreadWindows::get_thread_id_func_windows() {
return (ID)GetCurrentThreadId(); //must implement
}
-void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
+void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
ThreadWindows *tp = static_cast<ThreadWindows *>(p_thread);
ERR_FAIL_COND(!tp);
WaitForSingleObject(tp->handle, INFINITE);
@@ -84,17 +80,9 @@ void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
}
void ThreadWindows::make_default() {
-
create_func = create_func_windows;
get_thread_id_func = get_thread_id_func_windows;
wait_to_finish_func = wait_to_finish_func_windows;
}
-ThreadWindows::ThreadWindows() :
- handle(nullptr) {
-}
-
-ThreadWindows::~ThreadWindows() {
-}
-
#endif
diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h
index 669956cd32..502c418ce0 100644
--- a/drivers/windows/thread_windows.h
+++ b/drivers/windows/thread_windows.h
@@ -39,11 +39,10 @@
#include <windows.h>
class ThreadWindows : public Thread {
-
ThreadCreateCallback callback;
void *user;
ID id;
- HANDLE handle;
+ HANDLE handle = nullptr;
static Thread *create_thread_windows();
@@ -53,14 +52,14 @@ class ThreadWindows : public Thread {
static ID get_thread_id_func_windows();
static void wait_to_finish_func_windows(Thread *p_thread);
- ThreadWindows();
+ ThreadWindows() {}
public:
virtual ID get_id() const;
static void make_default();
- ~ThreadWindows();
+ ~ThreadWindows() {}
};
#endif
diff --git a/drivers/winmidi/midi_driver_winmidi.cpp b/drivers/winmidi/midi_driver_winmidi.cpp
index 57fb9b0e57..9cbc7f43e2 100644
--- a/drivers/winmidi/midi_driver_winmidi.cpp
+++ b/drivers/winmidi/midi_driver_winmidi.cpp
@@ -35,14 +35,12 @@
#include "core/print_string.h"
void MIDIDriverWinMidi::read(HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) {
-
if (wMsg == MIM_DATA) {
receive_input_packet((uint64_t)dwParam2, (uint8_t *)&dwParam1, 3);
}
}
Error MIDIDriverWinMidi::open() {
-
for (UINT i = 0; i < midiInGetNumDevs(); i++) {
HMIDIIN midi_in;
@@ -67,7 +65,6 @@ Error MIDIDriverWinMidi::open() {
}
PackedStringArray MIDIDriverWinMidi::get_connected_inputs() {
-
PackedStringArray list;
for (int i = 0; i < connected_sources.size(); i++) {
@@ -87,7 +84,6 @@ PackedStringArray MIDIDriverWinMidi::get_connected_inputs() {
}
void MIDIDriverWinMidi::close() {
-
for (int i = 0; i < connected_sources.size(); i++) {
HMIDIIN midi_in = connected_sources[i];
midiInStop(midi_in);
@@ -100,7 +96,6 @@ MIDIDriverWinMidi::MIDIDriverWinMidi() {
}
MIDIDriverWinMidi::~MIDIDriverWinMidi() {
-
close();
}
diff --git a/drivers/winmidi/midi_driver_winmidi.h b/drivers/winmidi/midi_driver_winmidi.h
index c240c8c7aa..934eb5a493 100644
--- a/drivers/winmidi/midi_driver_winmidi.h
+++ b/drivers/winmidi/midi_driver_winmidi.h
@@ -42,7 +42,6 @@
#include <mmsystem.h>
class MIDIDriverWinMidi : public MIDIDriver {
-
Vector<HMIDIIN> connected_sources;
static void CALLBACK read(HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index 120bfa2b36..421cf6a8cf 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -38,19 +38,18 @@ const char *AudioDriverXAudio2::get_name() const {
}
Error AudioDriverXAudio2::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
pcm_open = false;
samples_in = nullptr;
- mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
// FIXME: speaker_mode seems unused in the Xaudio2 driver so far
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
- int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+ int latency = GLOBAL_GET("audio/output_latency");
buffer_size = closest_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
@@ -85,19 +84,15 @@ Error AudioDriverXAudio2::init() {
}
void AudioDriverXAudio2::thread_func(void *p_udata) {
-
AudioDriverXAudio2 *ad = (AudioDriverXAudio2 *)p_udata;
while (!ad->exit_thread) {
-
if (!ad->active) {
-
for (int i = 0; i < AUDIO_BUFFERS; i++) {
ad->xaudio_buffer[i].Flags = XAUDIO2_END_OF_STREAM;
}
} else {
-
ad->lock();
ad->audio_server_process(ad->buffer_size, ad->samples_in);
@@ -105,7 +100,6 @@ void AudioDriverXAudio2::thread_func(void *p_udata) {
ad->unlock();
for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
-
ad->samples_out[ad->current_buffer][i] = ad->samples_in[i] >> 16;
}
@@ -128,24 +122,20 @@ void AudioDriverXAudio2::thread_func(void *p_udata) {
}
void AudioDriverXAudio2::start() {
-
active = true;
HRESULT hr = source_voice->Start(0);
ERR_FAIL_COND_MSG(hr != S_OK, "Error starting XAudio2 driver. Error code: " + itos(hr) + ".");
}
int AudioDriverXAudio2::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverXAudio2::get_speaker_mode() const {
-
return speaker_mode;
}
float AudioDriverXAudio2::get_latency() {
-
XAUDIO2_PERFORMANCE_DATA perf_data;
xaudio->GetPerformanceData(&perf_data);
if (perf_data.CurrentLatencyInSamples) {
@@ -156,20 +146,18 @@ float AudioDriverXAudio2::get_latency() {
}
void AudioDriverXAudio2::lock() {
-
if (!thread)
return;
mutex.lock();
}
-void AudioDriverXAudio2::unlock() {
+void AudioDriverXAudio2::unlock() {
if (!thread)
return;
mutex.unlock();
}
void AudioDriverXAudio2::finish() {
-
if (!thread)
return;
@@ -196,15 +184,9 @@ void AudioDriverXAudio2::finish() {
thread = nullptr;
}
-AudioDriverXAudio2::AudioDriverXAudio2() :
- thread(nullptr),
- current_buffer(0) {
- wave_format = { 0 };
+AudioDriverXAudio2::AudioDriverXAudio2() {
for (int i = 0; i < AUDIO_BUFFERS; i++) {
xaudio_buffer[i] = { 0 };
samples_out[i] = 0;
}
}
-
-AudioDriverXAudio2::~AudioDriverXAudio2() {
-}
diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h
index eb4a6d6e95..7fc1bb428d 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.h
+++ b/drivers/xaudio2/audio_driver_xaudio2.h
@@ -41,13 +41,11 @@
#include <xaudio2.h>
class AudioDriverXAudio2 : public AudioDriver {
-
enum {
AUDIO_BUFFERS = 2
};
struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback {
-
HANDLE buffer_end_event;
XAudio2DriverVoiceCallback() :
buffer_end_event(CreateEvent(nullptr, FALSE, FALSE, nullptr)) {}
@@ -64,7 +62,7 @@ class AudioDriverXAudio2 : public AudioDriver {
void STDMETHODCALLTYPE OnVoiceError(void *pBufferContext, HRESULT Error) {}
};
- Thread *thread;
+ Thread *thread = nullptr;
Mutex mutex;
int32_t *samples_in;
@@ -83,9 +81,9 @@ class AudioDriverXAudio2 : public AudioDriver {
mutable bool exit_thread;
bool pcm_open;
- WAVEFORMATEX wave_format;
+ WAVEFORMATEX wave_format = { 0 };
Microsoft::WRL::ComPtr<IXAudio2> xaudio;
- int current_buffer;
+ int current_buffer = 0;
IXAudio2MasteringVoice *mastering_voice;
XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS];
IXAudio2SourceVoice *source_voice;
@@ -104,7 +102,7 @@ public:
virtual void finish();
AudioDriverXAudio2();
- ~AudioDriverXAudio2();
+ ~AudioDriverXAudio2() {}
};
#endif
diff --git a/editor/SCsub b/editor/SCsub
index 13ae85bbf0..651dd5fffd 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -6,6 +6,7 @@ env.editor_sources = []
import os
import os.path
+import glob
from platform_methods import run_in_subprocess
import editor_builders
@@ -40,20 +41,21 @@ if env["tools"]:
f.write(reg_exporters_inc)
f.write(reg_exporters)
- # API documentation
+ # Core API documentation.
docs = []
- doc_dirs = ["doc/classes"]
+ docs += Glob("#doc/classes/*.xml")
- for p in env.doc_class_path.values():
- if p not in doc_dirs:
- doc_dirs.append(p)
+ # Module API documentation.
+ module_dirs = []
+ for d in env.doc_class_path.values():
+ if d not in module_dirs:
+ module_dirs.append(d)
- for d in doc_dirs:
- try:
- for f in os.listdir(os.path.join(env.Dir("#").abspath, d)):
- docs.append("#" + os.path.join(d, f))
- except OSError:
- pass
+ for d in module_dirs:
+ if not os.path.isabs(d):
+ docs += Glob("#" + d + "/*.xml") # Built-in.
+ else:
+ docs += Glob(d + "/*.xml") # Custom.
_make_doc_data_class_path(os.path.join(env.Dir("#").abspath, "editor"))
@@ -61,8 +63,6 @@ if env["tools"]:
env.Depends("#editor/doc_data_compressed.gen.h", docs)
env.CommandNoCache("#editor/doc_data_compressed.gen.h", docs, run_in_subprocess(editor_builders.make_doc_header))
- import glob
-
path = env.Dir(".").abspath
# Editor translations
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index 57c63dd40d..f880ece88b 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -51,7 +51,6 @@ static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, const Vector2 &start, con
}
void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
-
float scale = timeline->get_zoom_scale();
int limit = timeline->get_name_limit();
int right_limit = get_size().width - timeline->get_buttons_width();
@@ -69,11 +68,11 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
}
for (Map<float, int>::Element *E = key_order.front(); E; E = E->next()) {
-
int i = E->get();
- if (!E->next())
+ if (!E->next()) {
break;
+ }
int i_n = E->next()->get();
@@ -113,11 +112,13 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
int to_x = (offset_n - timeline->get_value()) * scale + limit;
int point_end = to_x;
- if (from_x > right_limit) //not visible
+ if (from_x > right_limit) { //not visible
continue;
+ }
- if (to_x < limit) //not visible
+ if (to_x < limit) { //not visible
continue;
+ }
from_x = MAX(from_x, limit);
to_x = MIN(to_x, right_limit);
@@ -127,7 +128,6 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
Vector2 prev_pos;
for (int j = from_x; j <= to_x; j++) {
-
float t = (j - limit) / scale + timeline->get_value();
float h;
@@ -144,7 +144,6 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
//narrow high and low as much as possible
for (int k = 0; k < iterations; k++) {
-
middle = (low + high) / 2;
Vector2 interp = _bezier_interp(middle, start, out_handle, in_handle, end);
@@ -183,21 +182,23 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
}
void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, int p_clip_left, int p_clip_right) {
-
Vector2 from = p_from;
Vector2 to = p_to;
- if (from.x == to.x)
+ if (from.x == to.x) {
return;
+ }
if (to.x < from.x) {
SWAP(to, from);
}
- if (to.x < p_clip_left)
+ if (to.x < p_clip_left) {
return;
+ }
- if (from.x > p_clip_right)
+ if (from.x > p_clip_right) {
return;
+ }
if (to.x > p_clip_right) {
float c = (p_clip_right - from.x) / (to.x - from.x);
@@ -213,7 +214,6 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V
}
void AnimationBezierTrackEdit::_notification(int p_what) {
-
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {
bezier_icon = get_theme_icon("KeyBezierPoint", "EditorIcons");
bezier_handle_icon = get_theme_icon("KeyBezierHandle", "EditorIcons");
@@ -225,7 +225,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
}
if (p_what == NOTIFICATION_RESIZED) {
-
int right_limit = get_size().width - timeline->get_buttons_width();
int hsep = get_theme_constant("hseparation", "ItemList");
int vsep = get_theme_constant("vseparation", "ItemList");
@@ -234,8 +233,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
handle_mode_option->set_size(Vector2(timeline->get_buttons_width() - hsep * 2, handle_mode_option->get_combined_minimum_size().height));
}
if (p_what == NOTIFICATION_DRAW) {
- if (animation.is_null())
+ if (animation.is_null()) {
return;
+ }
int limit = timeline->get_name_limit();
@@ -316,11 +316,13 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
subtracks.clear();
for (int i = 0; i < animation->get_track_count(); i++) {
- if (animation->track_get_type(i) != Animation::TYPE_BEZIER)
+ if (animation->track_get_type(i) != Animation::TYPE_BEZIER) {
continue;
+ }
String path = animation->track_get_path(i);
- if (!path.begins_with(base_path))
+ if (!path.begins_with(base_path)) {
continue; //another node
+ }
path = path.replace_first(base_path, "");
Color cc = color;
@@ -365,16 +367,15 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
bool first = true;
int prev_iv = 0;
for (int i = font->get_height(); i < get_size().height; i++) {
-
float ofs = get_size().height / 2 - i;
ofs *= v_zoom;
ofs += v_scroll;
int iv = int(ofs / scale);
- if (ofs < 0)
+ if (ofs < 0) {
iv -= 1;
+ }
if (!first && iv != prev_iv) {
-
Color lc = linecolor;
lc.a *= 0.5;
draw_line(Point2(limit, i), Point2(right_limit, i), lc);
@@ -393,11 +394,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
float scale = timeline->get_zoom_scale();
Ref<Texture2D> point = get_theme_icon("KeyValue", "EditorIcons");
for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) {
-
_draw_track(E->key(), E->get());
for (int i = 0; i < animation->track_get_key_count(E->key()); i++) {
-
float offset = animation->track_get_key_time(E->key(), i);
float value = animation->bezier_track_get_key_value(E->key(), i);
@@ -416,12 +415,10 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
//draw editor handles
{
-
float scale = timeline->get_zoom_scale();
edit_points.clear();
for (int i = 0; i < animation->track_get_key_count(track); i++) {
-
float offset = animation->track_get_key_time(track, i);
float value = animation->bezier_track_get_key_value(track, i);
@@ -499,20 +496,20 @@ Ref<Animation> AnimationBezierTrackEdit::get_animation() const {
}
void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) {
-
animation = p_animation;
track = p_track;
- if (is_connected_compat("select_key", editor, "_key_selected"))
+ if (is_connected_compat("select_key", editor, "_key_selected")) {
disconnect_compat("select_key", editor, "_key_selected");
- if (is_connected_compat("deselect_key", editor, "_key_deselected"))
+ }
+ if (is_connected_compat("deselect_key", editor, "_key_deselected")) {
disconnect_compat("deselect_key", editor, "_key_deselected");
+ }
connect_compat("select_key", editor, "_key_selected", varray(p_track), CONNECT_DEFERRED);
connect_compat("deselect_key", editor, "_key_deselected", varray(p_track), CONNECT_DEFERRED);
update();
}
Size2 AnimationBezierTrackEdit::get_minimum_size() const {
-
return Vector2(1, 1);
}
@@ -524,15 +521,16 @@ void AnimationBezierTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) {
timeline = p_timeline;
timeline->connect("zoom_changed", callable_mp(this, &AnimationBezierTrackEdit::_zoom_changed));
}
+
void AnimationBezierTrackEdit::set_editor(AnimationTrackEditor *p_editor) {
editor = p_editor;
connect_compat("clear_selection", editor, "_clear_selection", varray(false));
}
void AnimationBezierTrackEdit::_play_position_draw() {
-
- if (!animation.is_valid() || play_position_pos < 0)
+ if (!animation.is_valid() || play_position_pos < 0) {
return;
+ }
float scale = timeline->get_zoom_scale();
int h = get_size().height;
@@ -546,7 +544,6 @@ void AnimationBezierTrackEdit::_play_position_draw() {
}
void AnimationBezierTrackEdit::set_play_position(float p_pos) {
-
play_position_pos = p_pos;
play_position->update();
}
@@ -558,12 +555,12 @@ void AnimationBezierTrackEdit::update_play_position() {
void AnimationBezierTrackEdit::set_root(Node *p_root) {
root = p_root;
}
+
void AnimationBezierTrackEdit::_zoom_changed() {
update();
}
String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const {
-
return Control::get_tooltip(p_pos);
}
@@ -574,17 +571,17 @@ void AnimationBezierTrackEdit::_clear_selection() {
}
void AnimationBezierTrackEdit::_clear_selection_for_anim(const Ref<Animation> &p_anim) {
-
- if (!(animation == p_anim))
+ if (!(animation == p_anim)) {
return;
+ }
//selection.clear();
_clear_selection();
}
void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos) {
-
- if (!(animation == p_anim))
+ if (!(animation == p_anim)) {
return;
+ }
int idx = animation->track_find_key(p_track, p_pos, true);
ERR_FAIL_COND(idx < 0);
@@ -595,7 +592,6 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int
}
void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
-
if (p_event->is_pressed()) {
if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) {
duplicate_selection();
@@ -636,7 +632,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_MIDDLE) {
-
if (mb->is_pressed()) {
int x = mb->get_position().x - timeline->get_name_limit();
panning_timeline_from = x / timeline->get_zoom_scale();
@@ -648,7 +643,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
-
menu_insert_key = mb->get_position();
if (menu_insert_key.x >= timeline->get_name_limit() && menu_insert_key.x <= get_size().width - timeline->get_buttons_width()) {
Vector2 popup_pos = get_global_transform().xform(mb->get_position());
@@ -669,7 +663,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (close_icon_rect.has_point(mb->get_position())) {
emit_signal("close_request");
return;
@@ -683,7 +676,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
for (int i = 0; i < edit_points.size(); i++) {
-
//first check point
//command makes it ignore the main point, so control point editors can be force-edited
//path 2D editing in the 3D and 2D editors works the same way
@@ -706,7 +698,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
select_single_attempt = i;
update();
} else {
-
moving_selection_attempt = true;
moving_selection = true;
moving_selection_from_key = i;
@@ -741,7 +732,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
//insert new point
if (mb->get_command() && mb->get_position().x >= timeline->get_name_limit() && mb->get_position().x < get_size().width - timeline->get_buttons_width()) {
-
Array new_point;
new_point.resize(5);
@@ -790,7 +780,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (box_selecting_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (box_selecting) {
//do actual select
if (!box_selecting_add) {
@@ -808,7 +797,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
Rect2 selection_rect(bs_from, bs_to - bs_from);
for (int i = 0; i < edit_points.size(); i++) {
-
if (edit_points[i].point_rect.intersects(selection_rect)) {
selection.insert(i);
}
@@ -822,7 +810,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (moving_handle != 0 && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
undo_redo->create_action(TTR("Move Bezier Points"));
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", track, moving_handle_key, moving_handle_left);
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", track, moving_handle_key, moving_handle_right);
@@ -835,7 +822,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (moving_selection_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (moving_selection) {
//combit it
@@ -844,20 +830,20 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
List<AnimMoveRestore> to_restore;
// 1-remove the keys
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, E->get());
}
// 2- remove overlapped keys
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float newtime = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x);
int idx = animation->track_find_key(track, newtime, true);
- if (idx == -1)
+ if (idx == -1) {
continue;
+ }
- if (selection.has(idx))
+ if (selection.has(idx)) {
continue; //already in selection, don't save
+ }
undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_position", track, newtime);
AnimMoveRestore amr;
@@ -871,7 +857,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
// 3-move the keys (re insert them)
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float newpos = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x);
/*
if (newpos<0)
@@ -886,7 +871,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
// 4-(undo) remove inserted keys
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float newpos = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x);
/*
if (newpos<0)
@@ -897,14 +881,12 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
// 5-(undo) reinsert keys
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float oldpos = animation->track_get_key_time(track, E->get());
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, oldpos, animation->track_get_key_value(track, E->get()), 1);
}
// 6-(undo) reinsert overlapped keys
for (List<AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
-
AnimMoveRestore &amr = E->get();
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1);
}
@@ -915,7 +897,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
// 7-reselect
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float oldpos = animation->track_get_key_time(track, E->get());
float newpos = editor->snap_time(oldpos + moving_selection_offset.x);
@@ -938,10 +919,12 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) {
v_scroll += mm->get_relative().y * v_zoom;
- if (v_scroll > 100000)
+ if (v_scroll > 100000) {
v_scroll = 100000;
- if (v_scroll < -100000)
+ }
+ if (v_scroll < -100000) {
v_scroll = -100000;
+ }
int x = mm->get_position().x - timeline->get_name_limit();
float ofs = x / timeline->get_zoom_scale();
@@ -951,7 +934,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
update();
}
if (moving_selection_attempt && mm.is_valid()) {
-
if (!moving_selection) {
moving_selection = true;
select_single_attempt = -1;
@@ -965,7 +947,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (box_selecting_attempt && mm.is_valid()) {
-
if (!box_selecting) {
box_selecting = true;
box_selecting_add = mm->get_shift();
@@ -981,7 +962,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (moving_handle != 0 && mm.is_valid()) {
-
float y = (get_size().height / 2 - mm->get_position().y) * v_zoom + v_scroll;
float x = ((mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale()) + timeline->get_value();
@@ -1026,10 +1006,8 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
void AnimationBezierTrackEdit::_menu_selected(int p_index) {
-
switch (p_index) {
case MENU_KEY_INSERT: {
-
Array new_point;
new_point.resize(5);
@@ -1062,16 +1040,16 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) {
}
void AnimationBezierTrackEdit::duplicate_selection() {
-
- if (selection.size() == 0)
+ if (selection.size() == 0) {
return;
+ }
float top_time = 1e10;
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float t = animation->track_get_key_time(track, E->get());
- if (t < top_time)
+ if (t < top_time) {
top_time = t;
+ }
}
undo_redo->create_action(TTR("Anim Duplicate Keys"));
@@ -1079,7 +1057,6 @@ void AnimationBezierTrackEdit::duplicate_selection() {
List<Pair<int, float>> new_selection_values;
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
float t = animation->track_get_key_time(track, E->get());
float dst_time = t + (timeline->get_play_position() - top_time);
int existing_idx = animation->track_find_key(track, dst_time, true);
@@ -1093,7 +1070,6 @@ void AnimationBezierTrackEdit::duplicate_selection() {
new_selection_values.push_back(p);
if (existing_idx != -1) {
-
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, dst_time, animation->track_get_key_value(track, existing_idx), animation->track_get_key_transition(track, existing_idx));
}
}
@@ -1104,14 +1080,14 @@ void AnimationBezierTrackEdit::duplicate_selection() {
selection.clear();
for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) {
-
int track = E->get().first;
float time = E->get().second;
int existing_idx = animation->track_find_key(track, time, true);
- if (existing_idx == -1)
+ if (existing_idx == -1) {
continue;
+ }
selection.insert(existing_idx);
}
@@ -1124,7 +1100,6 @@ void AnimationBezierTrackEdit::delete_selection() {
undo_redo->create_action(TTR("Anim Delete Keys"));
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, E->get());
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, animation->track_get_key_time(track, E->get()), animation->track_get_key_value(track, E->get()), 1);
}
@@ -1140,7 +1115,6 @@ void AnimationBezierTrackEdit::set_block_animation_update_ptr(bool *p_block_ptr)
}
void AnimationBezierTrackEdit::_bind_methods() {
-
ClassDB::bind_method("_gui_input", &AnimationBezierTrackEdit::_gui_input);
ClassDB::bind_method("_clear_selection", &AnimationBezierTrackEdit::_clear_selection);
diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h
index 2be388fd57..1c1cde47b4 100644
--- a/editor/animation_bezier_editor.h
+++ b/editor/animation_bezier_editor.h
@@ -34,7 +34,6 @@
#include "animation_track_editor.h"
class AnimationBezierTrackEdit : public Control {
-
GDCLASS(AnimationBezierTrackEdit, Control);
enum HandleMode {
@@ -112,7 +111,6 @@ class AnimationBezierTrackEdit : public Control {
Vector2 menu_insert_key;
struct AnimMoveRestore {
-
int track;
float time;
Variant key;
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index da81732a01..8fd1f5951e 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -41,7 +41,6 @@
#include "servers/audio/audio_stream.h"
class AnimationTrackKeyEdit : public Object {
-
GDCLASS(AnimationTrackKeyEdit, Object);
public:
@@ -56,7 +55,6 @@ public:
}
static void _bind_methods() {
-
ClassDB::bind_method("_update_obj", &AnimationTrackKeyEdit::_update_obj);
ClassDB::bind_method("_key_ofs_changed", &AnimationTrackKeyEdit::_key_ofs_changed);
ClassDB::bind_method("_hide_script_from_inspector", &AnimationTrackKeyEdit::_hide_script_from_inspector);
@@ -65,11 +63,11 @@ public:
}
void _fix_node_path(Variant &value) {
-
NodePath np = value;
- if (np == NodePath())
+ if (np == NodePath()) {
return;
+ }
Node *root = EditorNode::get_singleton()->get_tree()->get_root();
@@ -83,34 +81,33 @@ public:
}
void _update_obj(const Ref<Animation> &p_anim) {
-
- if (setting || animation != p_anim)
+ if (setting || animation != p_anim) {
return;
+ }
notify_change();
}
void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) {
-
- if (animation != p_anim || from != key_ofs)
+ if (animation != p_anim || from != key_ofs) {
return;
+ }
key_ofs = to;
- if (setting)
+ if (setting) {
return;
+ }
notify_change();
}
bool _set(const StringName &p_name, const Variant &p_value) {
-
int key = animation->track_find_key(track, key_ofs, true);
ERR_FAIL_COND_V(key == -1, false);
String name = p_name;
if (name == "time" || name == "frame") {
-
float new_time = p_value;
if (name == "frame") {
@@ -121,8 +118,9 @@ public:
new_time /= fps;
}
- if (new_time == key_ofs)
+ if (new_time == key_ofs) {
return true;
+ }
int existing = animation->track_find_key(track, new_time, true);
@@ -151,7 +149,6 @@ public:
}
if (name == "easing") {
-
float val = p_value;
float prev_val = animation->track_get_key_transition(track, key);
setting = true;
@@ -167,9 +164,7 @@ public:
}
switch (animation->track_get_type(track)) {
-
case Animation::TYPE_TRANSFORM: {
-
Dictionary d_old = animation->track_get_key_value(track, key);
Dictionary d_new = d_old.duplicate();
d_new[p_name] = p_value;
@@ -185,9 +180,7 @@ public:
return true;
} break;
case Animation::TYPE_VALUE: {
-
if (name == "value") {
-
Variant value = p_value;
if (value.get_type() == Variant::NODE_PATH) {
@@ -208,7 +201,6 @@ public:
}
} break;
case Animation::TYPE_METHOD: {
-
Dictionary d_old = animation->track_get_key_value(track, key);
Dictionary d_new = d_old.duplicate();
@@ -216,16 +208,13 @@ public:
bool mergeable = false;
if (name == "name") {
-
d_new["method"] = p_value;
} else if (name == "arg_count") {
-
Vector<Variant> args = d_old["args"];
args.resize(p_value);
d_new["args"] = args;
change_notify_deserved = true;
} else if (name.begins_with("args/")) {
-
Vector<Variant> args = d_old["args"];
int idx = name.get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, args.size(), false);
@@ -241,17 +230,14 @@ public:
Variant *ptrs[1] = { &old };
args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err);
} else {
-
args.write[idx] = Variant::construct(t, nullptr, 0, err);
}
change_notify_deserved = true;
d_new["args"] = args;
}
} else if (what == "value") {
-
Variant value = p_value;
if (value.get_type() == Variant::NODE_PATH) {
-
_fix_node_path(value);
}
@@ -261,10 +247,11 @@ public:
}
}
- if (mergeable)
+ if (mergeable) {
undo_redo->create_action(TTR("Anim Change Call"), UndoRedo::MERGE_ENDS);
- else
+ } else {
undo_redo->create_action(TTR("Anim Change Call"));
+ }
setting = true;
undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, d_new);
@@ -274,14 +261,13 @@ public:
undo_redo->commit_action();
setting = false;
- if (change_notify_deserved)
+ if (change_notify_deserved) {
notify_change();
+ }
return true;
} break;
case Animation::TYPE_BEZIER: {
-
if (name == "value") {
-
const Variant &value = p_value;
setting = true;
@@ -298,7 +284,6 @@ public:
}
if (name == "in_handle") {
-
const Variant &value = p_value;
setting = true;
@@ -315,7 +300,6 @@ public:
}
if (name == "out_handle") {
-
const Variant &value = p_value;
setting = true;
@@ -332,9 +316,7 @@ public:
}
} break;
case Animation::TYPE_AUDIO: {
-
if (name == "stream") {
-
Ref<AudioStream> stream = p_value;
setting = true;
@@ -351,7 +333,6 @@ public:
}
if (name == "start_offset") {
-
float value = p_value;
setting = true;
@@ -368,7 +349,6 @@ public:
}
if (name == "end_offset") {
-
float value = p_value;
setting = true;
@@ -385,9 +365,7 @@ public:
}
} break;
case Animation::TYPE_ANIMATION: {
-
if (name == "animation") {
-
StringName anim_name = p_value;
setting = true;
@@ -409,7 +387,6 @@ public:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
int key = animation->track_find_key(track, key_ofs, true);
ERR_FAIL_COND_V(key == -1, false);
@@ -420,7 +397,6 @@ public:
}
if (name == "frame") {
-
float fps = animation->get_step();
if (fps > 0) {
fps = 1.0 / fps;
@@ -436,7 +412,6 @@ public:
switch (animation->track_get_type(track)) {
case Animation::TYPE_TRANSFORM: {
-
Dictionary d = animation->track_get_key_value(track, key);
ERR_FAIL_COND_V(!d.has(name), false);
r_ret = d[p_name];
@@ -444,7 +419,6 @@ public:
} break;
case Animation::TYPE_VALUE: {
-
if (name == "value") {
r_ret = animation->track_get_key_value(track, key);
return true;
@@ -452,11 +426,9 @@ public:
} break;
case Animation::TYPE_METHOD: {
-
Dictionary d = animation->track_get_key_value(track, key);
if (name == "name") {
-
ERR_FAIL_COND_V(!d.has("method"), false);
r_ret = d["method"];
return true;
@@ -472,7 +444,6 @@ public:
}
if (name.begins_with("args/")) {
-
int idx = name.get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, args.size(), false);
@@ -490,7 +461,6 @@ public:
} break;
case Animation::TYPE_BEZIER: {
-
if (name == "value") {
r_ret = animation->bezier_track_get_key_value(track, key);
return true;
@@ -508,7 +478,6 @@ public:
} break;
case Animation::TYPE_AUDIO: {
-
if (name == "stream") {
r_ret = animation->audio_track_get_key_stream(track, key);
return true;
@@ -526,7 +495,6 @@ public:
} break;
case Animation::TYPE_ANIMATION: {
-
if (name == "animation") {
r_ret = animation->animation_track_get_key_animation(track, key);
return true;
@@ -538,9 +506,9 @@ public:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
- if (animation.is_null())
+ if (animation.is_null()) {
return;
+ }
ERR_FAIL_INDEX(track, animation->get_track_count());
int key = animation->track_find_key(track, key_ofs, true);
@@ -554,25 +522,20 @@ public:
}
switch (animation->track_get_type(track)) {
-
case Animation::TYPE_TRANSFORM: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR3, "location"));
p_list->push_back(PropertyInfo(Variant::QUAT, "rotation"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
} break;
case Animation::TYPE_VALUE: {
-
Variant v = animation->track_get_key_value(track, key);
if (hint.type != Variant::NIL) {
-
PropertyInfo pi = hint;
pi.name = "value";
p_list->push_back(pi);
} else {
-
PropertyHint hint = PROPERTY_HINT_NONE;
String hint_string;
@@ -580,19 +543,18 @@ public:
//could actually check the object property if exists..? yes i will!
Ref<Resource> res = v;
if (res.is_valid()) {
-
hint = PROPERTY_HINT_RESOURCE_TYPE;
hint_string = res->get_class();
}
}
- if (v.get_type() != Variant::NIL)
+ if (v.get_type() != Variant::NIL) {
p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string));
+ }
}
} break;
case Animation::TYPE_METHOD: {
-
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name"));
p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1"));
@@ -601,40 +563,36 @@ public:
Vector<Variant> args = d["args"];
String vtypes;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
-
- if (i > 0)
+ if (i > 0) {
vtypes += ",";
+ }
vtypes += Variant::get_type_name(Variant::Type(i));
}
for (int i = 0; i < args.size(); i++) {
-
p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes));
- if (args[i].get_type() != Variant::NIL)
+ if (args[i].get_type() != Variant::NIL) {
p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value"));
+ }
}
} break;
case Animation::TYPE_BEZIER: {
-
p_list->push_back(PropertyInfo(Variant::FLOAT, "value"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle"));
} break;
case Animation::TYPE_AUDIO: {
-
p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
} break;
case Animation::TYPE_ANIMATION: {
-
String animations;
if (root_path && root_path->has_node(animation->track_get_path(track))) {
-
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(root_path->get_node(animation->track_get_path(track)));
if (ap) {
List<StringName> anims;
@@ -675,7 +633,6 @@ public:
bool use_fps;
void notify_change() {
-
_change_notify();
}
@@ -698,7 +655,6 @@ public:
};
class AnimationMultiTrackKeyEdit : public Object {
-
GDCLASS(AnimationMultiTrackKeyEdit, Object);
public:
@@ -713,7 +669,6 @@ public:
}
static void _bind_methods() {
-
ClassDB::bind_method("_update_obj", &AnimationMultiTrackKeyEdit::_update_obj);
ClassDB::bind_method("_key_ofs_changed", &AnimationMultiTrackKeyEdit::_key_ofs_changed);
ClassDB::bind_method("_hide_script_from_inspector", &AnimationMultiTrackKeyEdit::_hide_script_from_inspector);
@@ -722,11 +677,11 @@ public:
}
void _fix_node_path(Variant &value, NodePath &base) {
-
NodePath np = value;
- if (np == NodePath())
+ if (np == NodePath()) {
return;
+ }
Node *root = EditorNode::get_singleton()->get_tree()->get_root();
@@ -740,23 +695,21 @@ public:
}
void _update_obj(const Ref<Animation> &p_anim) {
-
- if (setting || animation != p_anim)
+ if (setting || animation != p_anim) {
return;
+ }
notify_change();
}
void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) {
-
- if (animation != p_anim)
+ if (animation != p_anim) {
return;
+ }
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
-
int key = 0;
for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
-
float key_ofs = F->get();
if (from != key_ofs) {
key++;
@@ -766,8 +719,9 @@ public:
int track = E->key();
key_ofs_map[track][key] = to;
- if (setting)
+ if (setting) {
return;
+ }
notify_change();
@@ -777,21 +731,17 @@ public:
}
bool _set(const StringName &p_name, const Variant &p_value) {
-
bool update_obj = false;
bool change_notify_deserved = false;
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
-
int track = E->key();
for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
-
float key_ofs = F->get();
int key = animation->track_find_key(track, key_ofs, true);
ERR_FAIL_COND_V(key == -1, false);
String name = p_name;
if (name == "time" || name == "frame") {
-
float new_time = p_value;
if (name == "frame") {
@@ -825,7 +775,6 @@ public:
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, new_time, v, trans);
}
} else if (name == "easing") {
-
float val = p_value;
float prev_val = animation->track_get_key_transition(track, key);
@@ -839,9 +788,7 @@ public:
}
switch (animation->track_get_type(track)) {
-
case Animation::TYPE_TRANSFORM: {
-
Dictionary d_old = animation->track_get_key_value(track, key);
Dictionary d_new = d_old.duplicate();
d_new[p_name] = p_value;
@@ -855,9 +802,7 @@ public:
update_obj = true;
} break;
case Animation::TYPE_VALUE: {
-
if (name == "value") {
-
Variant value = p_value;
if (value.get_type() == Variant::NODE_PATH) {
@@ -875,23 +820,19 @@ public:
}
} break;
case Animation::TYPE_METHOD: {
-
Dictionary d_old = animation->track_get_key_value(track, key);
Dictionary d_new = d_old.duplicate();
bool mergeable = false;
if (name == "name") {
-
d_new["method"] = p_value;
} else if (name == "arg_count") {
-
Vector<Variant> args = d_old["args"];
args.resize(p_value);
d_new["args"] = args;
change_notify_deserved = true;
} else if (name.begins_with("args/")) {
-
Vector<Variant> args = d_old["args"];
int idx = name.get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, args.size(), false);
@@ -907,17 +848,14 @@ public:
Variant *ptrs[1] = { &old };
args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err);
} else {
-
args.write[idx] = Variant::construct(t, nullptr, 0, err);
}
change_notify_deserved = true;
d_new["args"] = args;
}
} else if (what == "value") {
-
Variant value = p_value;
if (value.get_type() == Variant::NODE_PATH) {
-
_fix_node_path(value, base_map[track]);
}
@@ -930,10 +868,11 @@ public:
Variant prev = animation->track_get_key_value(track, key);
if (!setting) {
- if (mergeable)
+ if (mergeable) {
undo_redo->create_action(TTR("Anim Multi Change Call"), UndoRedo::MERGE_ENDS);
- else
+ } else {
undo_redo->create_action(TTR("Anim Multi Change Call"));
+ }
setting = true;
}
@@ -943,9 +882,7 @@ public:
update_obj = true;
} break;
case Animation::TYPE_BEZIER: {
-
if (name == "value") {
-
const Variant &value = p_value;
if (!setting) {
@@ -957,7 +894,6 @@ public:
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_value", track, key, prev);
update_obj = true;
} else if (name == "in_handle") {
-
const Variant &value = p_value;
if (!setting) {
@@ -969,7 +905,6 @@ public:
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, prev);
update_obj = true;
} else if (name == "out_handle") {
-
const Variant &value = p_value;
if (!setting) {
@@ -983,9 +918,7 @@ public:
}
} break;
case Animation::TYPE_AUDIO: {
-
if (name == "stream") {
-
Ref<AudioStream> stream = p_value;
if (!setting) {
@@ -997,7 +930,6 @@ public:
undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_stream", track, key, prev);
update_obj = true;
} else if (name == "start_offset") {
-
float value = p_value;
if (!setting) {
@@ -1009,7 +941,6 @@ public:
undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, prev);
update_obj = true;
} else if (name == "end_offset") {
-
float value = p_value;
if (!setting) {
@@ -1023,9 +954,7 @@ public:
}
} break;
case Animation::TYPE_ANIMATION: {
-
if (name == "animation") {
-
StringName anim_name = p_value;
if (!setting) {
@@ -1043,7 +972,6 @@ public:
}
if (setting) {
-
if (update_obj) {
undo_redo->add_do_method(this, "_update_obj", animation);
undo_redo->add_undo_method(this, "_update_obj", animation);
@@ -1052,8 +980,9 @@ public:
undo_redo->commit_action();
setting = false;
- if (change_notify_deserved)
+ if (change_notify_deserved) {
notify_change();
+ }
return true;
}
@@ -1062,12 +991,9 @@ public:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
-
int track = E->key();
for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
-
float key_ofs = F->get();
int key = animation->track_find_key(track, key_ofs, true);
ERR_CONTINUE(key == -1);
@@ -1079,7 +1005,6 @@ public:
}
if (name == "frame") {
-
float fps = animation->get_step();
if (fps > 0) {
fps = 1.0 / fps;
@@ -1094,9 +1019,7 @@ public:
}
switch (animation->track_get_type(track)) {
-
case Animation::TYPE_TRANSFORM: {
-
Dictionary d = animation->track_get_key_value(track, key);
ERR_FAIL_COND_V(!d.has(name), false);
r_ret = d[p_name];
@@ -1104,7 +1027,6 @@ public:
} break;
case Animation::TYPE_VALUE: {
-
if (name == "value") {
r_ret = animation->track_get_key_value(track, key);
return true;
@@ -1112,11 +1034,9 @@ public:
} break;
case Animation::TYPE_METHOD: {
-
Dictionary d = animation->track_get_key_value(track, key);
if (name == "name") {
-
ERR_FAIL_COND_V(!d.has("method"), false);
r_ret = d["method"];
return true;
@@ -1127,13 +1047,11 @@ public:
Vector<Variant> args = d["args"];
if (name == "arg_count") {
-
r_ret = args.size();
return true;
}
if (name.begins_with("args/")) {
-
int idx = name.get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, args.size(), false);
@@ -1151,7 +1069,6 @@ public:
} break;
case Animation::TYPE_BEZIER: {
-
if (name == "value") {
r_ret = animation->bezier_track_get_key_value(track, key);
return true;
@@ -1169,7 +1086,6 @@ public:
} break;
case Animation::TYPE_AUDIO: {
-
if (name == "stream") {
r_ret = animation->audio_track_get_key_stream(track, key);
return true;
@@ -1187,7 +1103,6 @@ public:
} break;
case Animation::TYPE_ANIMATION: {
-
if (name == "animation") {
r_ret = animation->animation_track_get_key_animation(track, key);
return true;
@@ -1201,9 +1116,9 @@ public:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
- if (animation.is_null())
+ if (animation.is_null()) {
return;
+ }
int first_track = -1;
float first_key = -1.0;
@@ -1212,38 +1127,38 @@ public:
bool same_track_type = true;
bool same_key_type = true;
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
-
int track = E->key();
ERR_FAIL_INDEX(track, animation->get_track_count());
- if (first_track < 0)
+ if (first_track < 0) {
first_track = track;
+ }
- if (show_time && E->value().size() > 1)
+ if (show_time && E->value().size() > 1) {
show_time = false;
+ }
if (same_track_type) {
-
if (animation->track_get_type(first_track) != animation->track_get_type(track)) {
same_track_type = false;
same_key_type = false;
}
for (List<float>::Element *F = E->value().front(); F; F = F->next()) {
-
int key = animation->track_find_key(track, F->get(), true);
ERR_FAIL_COND(key == -1);
- if (first_key < 0)
+ if (first_key < 0) {
first_key = key;
+ }
- if (animation->track_get_key_value(first_track, first_key).get_type() != animation->track_get_key_value(track, key).get_type())
+ if (animation->track_get_key_value(first_track, first_key).get_type() != animation->track_get_key_value(track, key).get_type()) {
same_key_type = false;
+ }
}
}
}
if (show_time) {
-
if (use_fps && animation->get_step() > 0) {
float max_frame = animation->get_length() / animation->get_step();
p_list->push_back(PropertyInfo(Variant::FLOAT, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1"));
@@ -1254,27 +1169,23 @@ public:
if (same_track_type) {
switch (animation->track_get_type(first_track)) {
-
case Animation::TYPE_TRANSFORM: {
-
p_list->push_back(PropertyInfo(Variant::VECTOR3, "location"));
p_list->push_back(PropertyInfo(Variant::QUAT, "rotation"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
} break;
case Animation::TYPE_VALUE: {
-
- if (!same_key_type)
+ if (!same_key_type) {
break;
+ }
Variant v = animation->track_get_key_value(first_track, first_key);
if (hint.type != Variant::NIL) {
-
PropertyInfo pi = hint;
pi.name = "value";
p_list->push_back(pi);
} else {
-
PropertyHint hint = PROPERTY_HINT_NONE;
String hint_string;
@@ -1282,20 +1193,19 @@ public:
//could actually check the object property if exists..? yes i will!
Ref<Resource> res = v;
if (res.is_valid()) {
-
hint = PROPERTY_HINT_RESOURCE_TYPE;
hint_string = res->get_class();
}
}
- if (v.get_type() != Variant::NIL)
+ if (v.get_type() != Variant::NIL) {
p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string));
+ }
}
p_list->push_back(PropertyInfo(Variant::FLOAT, "easing", PROPERTY_HINT_EXP_EASING));
} break;
case Animation::TYPE_METHOD: {
-
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name"));
p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1"));
@@ -1304,40 +1214,37 @@ public:
Vector<Variant> args = d["args"];
String vtypes;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
-
- if (i > 0)
+ if (i > 0) {
vtypes += ",";
+ }
vtypes += Variant::get_type_name(Variant::Type(i));
}
for (int i = 0; i < args.size(); i++) {
-
p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes));
- if (args[i].get_type() != Variant::NIL)
+ if (args[i].get_type() != Variant::NIL) {
p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value"));
+ }
}
} break;
case Animation::TYPE_BEZIER: {
-
p_list->push_back(PropertyInfo(Variant::FLOAT, "value"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle"));
} break;
case Animation::TYPE_AUDIO: {
-
p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
p_list->push_back(PropertyInfo(Variant::FLOAT, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater"));
} break;
case Animation::TYPE_ANIMATION: {
-
- if (key_ofs_map.size() > 1)
+ if (key_ofs_map.size() > 1) {
break;
+ }
String animations;
if (root_path && root_path->has_node(animation->track_get_path(first_track))) {
-
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(root_path->get_node(animation->track_get_path(first_track)));
if (ap) {
List<StringName> anims;
@@ -1376,7 +1283,6 @@ public:
UndoRedo *undo_redo;
void notify_change() {
-
_change_notify();
}
@@ -1397,14 +1303,12 @@ public:
};
void AnimationTimelineEdit::_zoom_changed(double) {
-
update();
play_position->update();
emit_signal("zoom_changed");
}
float AnimationTimelineEdit::get_zoom_scale() const {
-
float zv = zoom->get_max() - zoom->get_value();
if (zv < 1) {
zv = 1.0 - zv;
@@ -1415,9 +1319,9 @@ float AnimationTimelineEdit::get_zoom_scale() const {
}
void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
-
- if (editing)
+ if (editing) {
return;
+ }
p_new_len = MAX(0.001, p_new_len);
if (use_fps && animation->get_step() > 0) {
@@ -1436,7 +1340,6 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
}
void AnimationTimelineEdit::_anim_loop_pressed() {
-
undo_redo->create_action(TTR("Change Animation Loop"));
undo_redo->add_do_method(animation.ptr(), "set_loop", loop->is_pressed());
undo_redo->add_undo_method(animation.ptr(), "set_loop", animation->has_loop());
@@ -1444,7 +1347,6 @@ void AnimationTimelineEdit::_anim_loop_pressed() {
}
int AnimationTimelineEdit::get_buttons_width() const {
-
Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons");
Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons");
Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons");
@@ -1458,7 +1360,6 @@ int AnimationTimelineEdit::get_buttons_width() const {
}
int AnimationTimelineEdit::get_name_limit() const {
-
Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons");
int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width());
@@ -1469,7 +1370,6 @@ int AnimationTimelineEdit::get_name_limit() const {
}
void AnimationTimelineEdit::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
add_track->set_icon(get_theme_icon("Add", "EditorIcons"));
loop->set_icon(get_theme_icon("Loop", "EditorIcons"));
@@ -1490,11 +1390,11 @@ void AnimationTimelineEdit::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
int key_range = get_size().width - get_buttons_width() - get_name_limit();
- if (!animation.is_valid())
+ if (!animation.is_valid()) {
return;
+ }
Ref<Font> font = get_theme_font("font", "Label");
Color color = get_theme_color("font_color", "Label");
@@ -1504,8 +1404,9 @@ void AnimationTimelineEdit::_notification(int p_what) {
int h = get_size().height;
float l = animation->get_length();
- if (l <= 0)
+ if (l <= 0) {
l = 0.001; //avoid crashor
+ }
Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons");
hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
@@ -1515,24 +1416,24 @@ void AnimationTimelineEdit::_notification(int p_what) {
float time_min = 0;
float time_max = animation->get_length();
for (int i = 0; i < animation->get_track_count(); i++) {
-
if (animation->track_get_key_count(i) > 0) {
-
float beg = animation->track_get_key_time(i, 0);
/*if (animation->track_get_type(i) == Animation::TYPE_BEZIER) {
beg += animation->bezier_track_get_key_in_handle(i, 0).x;
}* not worth it since they have no use */
- if (beg < time_min)
+ if (beg < time_min) {
time_min = beg;
+ }
float end = animation->track_get_key_time(i, animation->track_get_key_count(i) - 1);
/*if (animation->track_get_type(i) == Animation::TYPE_BEZIER) {
end += animation->bezier_track_get_key_out_handle(i, animation->track_get_key_count(i) - 1).x;
} not worth it since they have no use */
- if (end > time_max)
+ if (end > time_max) {
time_max = end;
+ }
}
}
@@ -1548,7 +1449,6 @@ void AnimationTimelineEdit::_notification(int p_what) {
hscroll->show();
} else {
-
hscroll->hide();
}
}
@@ -1564,15 +1464,15 @@ void AnimationTimelineEdit::_notification(int p_what) {
linecolor.a = 0.2;
{
-
draw_rect(Rect2(Point2(get_name_limit(), 0), Point2(zoomw - 1, h)), notimecol);
if (begin_px < zoomw && end_px > 0) {
-
- if (begin_px < 0)
+ if (begin_px < 0) {
begin_px = 0;
- if (end_px > zoomw)
+ }
+ if (end_px > zoomw) {
end_px = zoomw;
+ }
draw_rect(Rect2(Point2(get_name_limit() + begin_px, 0), Point2(end_px - begin_px - 1, h)), timecolor);
}
@@ -1598,37 +1498,35 @@ void AnimationTimelineEdit::_notification(int p_what) {
const int max_sc_width = String::num(max_sc).length() * max_digit_width;
while (!step_found) {
-
min = max_sc_width;
- if (decimals > 0)
+ if (decimals > 0) {
min += period_width + max_digit_width * decimals;
+ }
static const int _multp[3] = { 1, 2, 5 };
for (int i = 0; i < 3; i++) {
-
step = (_multp[i] * dec);
if (step * scale / SC_ADJ > min) {
step_found = true;
break;
}
}
- if (step_found)
+ if (step_found) {
break;
+ }
dec *= 10;
decimals--;
- if (decimals < 0)
+ if (decimals < 0) {
decimals = 0;
+ }
}
if (use_fps) {
-
float step_size = animation->get_step();
if (step_size > 0) {
-
int prev_frame_ofs = -10000000;
for (int i = 0; i < zoomw; i++) {
-
float pos = get_value() + double(i) / scale;
float prev = get_value() + (double(i) - 1.0) / scale;
@@ -1638,7 +1536,6 @@ void AnimationTimelineEdit::_notification(int p_what) {
bool sub = Math::floor(prev) == Math::floor(pos);
if (frame != prev_frame && i >= prev_frame_ofs) {
-
draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
draw_string(font, Point2(get_name_limit() + i + 3 * EDSCALE, (h - font->get_height()) / 2 + font->get_ascent()).floor(), itos(frame), sub ? color_time_dec : color_time_sec, zoomw - i);
@@ -1649,7 +1546,6 @@ void AnimationTimelineEdit::_notification(int p_what) {
} else {
for (int i = 0; i < zoomw; i++) {
-
float pos = get_value() + double(i) / scale;
float prev = get_value() + (double(i) - 1.0) / scale;
@@ -1658,7 +1554,6 @@ void AnimationTimelineEdit::_notification(int p_what) {
bool sub = (sc % SC_ADJ);
if ((sc / step) != (prev_sc / step) || (prev_sc < 0 && sc >= 0)) {
-
int scd = sc < 0 ? prev_sc : sc;
draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE));
draw_string(font, Point2(get_name_limit() + i + 3, (h - font->get_height()) / 2 + font->get_ascent()).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), sub ? color_time_dec : color_time_sec, zoomw - i);
@@ -1686,7 +1581,6 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) {
}
Size2 AnimationTimelineEdit::get_minimum_size() const {
-
Size2 ms = add_track->get_minimum_size();
Ref<Font> font = get_theme_font("font", "Label");
ms.height = MAX(ms.height, font->get_height());
@@ -1704,7 +1598,6 @@ void AnimationTimelineEdit::set_zoom(Range *p_zoom) {
}
void AnimationTimelineEdit::set_play_position(float p_pos) {
-
play_position_pos = p_pos;
play_position->update();
}
@@ -1718,9 +1611,9 @@ void AnimationTimelineEdit::update_play_position() {
}
void AnimationTimelineEdit::update_values() {
-
- if (!animation.is_valid() || editing)
+ if (!animation.is_valid() || editing) {
return;
+ }
editing = true;
if (use_fps && animation->get_step() > 0) {
@@ -1739,9 +1632,9 @@ void AnimationTimelineEdit::update_values() {
}
void AnimationTimelineEdit::_play_position_draw() {
-
- if (!animation.is_valid() || play_position_pos < 0)
+ if (!animation.is_valid() || play_position_pos < 0) {
return;
+ }
float scale = get_zoom_scale();
int h = play_position->get_size().height;
@@ -1759,11 +1652,9 @@ void AnimationTimelineEdit::_play_position_draw() {
}
void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && hsize_rect.has_point(mb->get_position())) {
-
dragging_hsize = true;
dragging_hsize_from = mb->get_position().x;
dragging_hsize_at = name_limit;
@@ -1773,7 +1664,6 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) {
dragging_hsize = false;
}
if (mb.is_valid() && mb->get_position().x > get_name_limit() && mb->get_position().x < (get_size().width - get_buttons_width())) {
-
if (!panning_timeline && mb->get_button_index() == BUTTON_LEFT) {
int x = mb->get_position().x - get_name_limit();
@@ -1800,7 +1690,6 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (hsize_rect.has_point(mm->get_position())) {
// Change the cursor to indicate that the track name column's width can be adjusted
set_default_cursor_shape(Control::CURSOR_HSIZE);
@@ -1834,12 +1723,12 @@ void AnimationTimelineEdit::set_use_fps(bool p_use_fps) {
update_values();
update();
}
+
bool AnimationTimelineEdit::is_using_fps() const {
return use_fps;
}
void AnimationTimelineEdit::set_hscroll(HScrollBar *p_hscroll) {
-
hscroll = p_hscroll;
}
@@ -1858,7 +1747,6 @@ void AnimationTimelineEdit::_bind_methods() {
}
AnimationTimelineEdit::AnimationTimelineEdit() {
-
use_fps = false;
editing = false;
name_limit = 150 * EDSCALE;
@@ -1914,11 +1802,10 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
////////////////////////////////////
void AnimationTrackEdit::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
- if (animation.is_null())
+ if (animation.is_null()) {
return;
+ }
ERR_FAIL_INDEX(track, animation->get_track_count());
int limit = timeline->get_name_limit();
@@ -1947,7 +1834,6 @@ void AnimationTrackEdit::_notification(int p_what) {
// NAMES AND ICONS //
{
-
Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon("checked", "CheckBox") : get_theme_icon("unchecked", "CheckBox");
int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but..
@@ -1973,7 +1859,6 @@ void AnimationTrackEdit::_notification(int p_what) {
}
if (in_group) {
-
if (animation->track_get_type(track) == Animation::TYPE_METHOD) {
text = TTR("Functions:");
} else if (animation->track_get_type(track) == Animation::TYPE_AUDIO) {
@@ -2020,14 +1905,12 @@ void AnimationTrackEdit::_notification(int p_what) {
int limit_end = get_size().width - timeline->get_buttons_width();
for (int i = 0; i < animation->track_get_key_count(track); i++) {
-
float offset = animation->track_get_key_time(track, i) - timeline->get_value();
if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
offset = editor->snap_time(offset + editor->get_moving_selection_offset(), true);
}
offset = offset * scale + limit;
if (i < animation->track_get_key_count(track) - 1) {
-
float offset_n = animation->track_get_key_time(track, i + 1) - timeline->get_value();
if (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) {
offset_n = editor->snap_time(offset_n + editor->get_moving_selection_offset());
@@ -2046,7 +1929,6 @@ void AnimationTrackEdit::_notification(int p_what) {
// BUTTONS //
{
-
Ref<Texture2D> wrap_icon[2] = {
get_theme_icon("InterpWrapClamp", "EditorIcons"),
get_theme_icon("InterpWrapLoop", "EditorIcons"),
@@ -2220,15 +2102,17 @@ void AnimationTrackEdit::_notification(int p_what) {
}
int AnimationTrackEdit::get_key_height() const {
- if (!animation.is_valid())
+ if (!animation.is_valid()) {
return 0;
+ }
return type_icon->get_height();
}
-Rect2 AnimationTrackEdit::get_key_rect(int p_index, float p_pixels_sec) {
- if (!animation.is_valid())
+Rect2 AnimationTrackEdit::get_key_rect(int p_index, float p_pixels_sec) {
+ if (!animation.is_valid()) {
return Rect2();
+ }
Rect2 rect = Rect2(-type_icon->get_width() / 2, 0, type_icon->get_width(), get_size().height);
//make it a big easier to click
@@ -2242,15 +2126,18 @@ bool AnimationTrackEdit::is_key_selectable_by_distance() const {
}
void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
- if (p_next_x < p_clip_left)
+ if (p_next_x < p_clip_left) {
return;
- if (p_x > p_clip_right)
+ }
+ if (p_x > p_clip_right) {
return;
+ }
Variant current = animation->track_get_key_value(get_track(), p_index);
Variant next = animation->track_get_key_value(get_track(), p_index + 1);
- if (current != next)
+ if (current != next) {
return;
+ }
Color color = get_theme_color("font_color", "Label");
color.a = 0.5;
@@ -2262,12 +2149,13 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x,
}
void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
-
- if (!animation.is_valid())
+ if (!animation.is_valid()) {
return;
+ }
- if (p_x < p_clip_left || p_x > p_clip_right)
+ if (p_x < p_clip_left || p_x > p_clip_right) {
return;
+ }
Ref<Texture2D> icon_to_draw = p_selected ? selected_icon : type_icon;
@@ -2290,16 +2178,18 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
Dictionary d = animation->track_get_key_value(track, p_index);
String text;
- if (d.has("method"))
+ if (d.has("method")) {
text += String(d["method"]);
+ }
text += "(";
Vector<Variant> args;
- if (d.has("args"))
+ if (d.has("args")) {
args = d["args"];
+ }
for (int i = 0; i < args.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
text += ", ";
+ }
text += String(args[i]);
}
text += ")";
@@ -2315,14 +2205,15 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
//helper
void AnimationTrackEdit::draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled) {
-
int clip_left = timeline->get_name_limit();
int clip_right = get_size().width - timeline->get_buttons_width();
- if (p_rect.position.x > clip_right)
+ if (p_rect.position.x > clip_right) {
return;
- if (p_rect.position.x + p_rect.size.x < clip_left)
+ }
+ if (p_rect.position.x + p_rect.size.x < clip_left) {
return;
+ }
Rect2 clip = Rect2(clip_left, 0, clip_right - clip_left, get_size().height);
draw_rect(clip.clip(p_rect), p_color, p_filled);
}
@@ -2334,20 +2225,20 @@ void AnimationTrackEdit::draw_fg(int p_clip_left, int p_clip_right) {
}
void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos) {
-
draw_texture_region_clipped(p_texture, Rect2(p_pos, p_texture->get_size()), Rect2(Point2(), p_texture->get_size()));
}
void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) {
-
int clip_left = timeline->get_name_limit();
int clip_right = get_size().width - timeline->get_buttons_width();
//clip left and right
- if (clip_left > p_rect.position.x + p_rect.size.x)
+ if (clip_left > p_rect.position.x + p_rect.size.x) {
return;
- if (clip_right < p_rect.position.x)
+ }
+ if (clip_right < p_rect.position.x) {
return;
+ }
Rect2 rect = p_rect;
Rect2 region = p_region;
@@ -2364,7 +2255,6 @@ void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_tex
}
if (clip_right < rect.position.x + rect.size.x) {
-
int rect_pixels = rect.position.x + rect.size.x - clip_right;
int region_pixels = rect_pixels * region.size.x / rect.size.x;
@@ -2384,7 +2274,6 @@ Ref<Animation> AnimationTrackEdit::get_animation() const {
}
void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) {
-
animation = p_animation;
track = p_track;
update();
@@ -2410,7 +2299,6 @@ NodePath AnimationTrackEdit::get_path() const {
}
Size2 AnimationTrackEdit::get_minimum_size() const {
-
Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons");
Ref<Font> font = get_theme_font("font", "Label");
int separation = get_theme_constant("vseparation", "ItemList");
@@ -2430,14 +2318,15 @@ void AnimationTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) {
timeline->connect("zoom_changed", callable_mp(this, &AnimationTrackEdit::_zoom_changed));
timeline->connect("name_limit_changed", callable_mp(this, &AnimationTrackEdit::_zoom_changed));
}
+
void AnimationTrackEdit::set_editor(AnimationTrackEditor *p_editor) {
editor = p_editor;
}
void AnimationTrackEdit::_play_position_draw() {
-
- if (!animation.is_valid() || play_position_pos < 0)
+ if (!animation.is_valid() || play_position_pos < 0) {
return;
+ }
float scale = timeline->get_zoom_scale();
int h = get_size().height;
@@ -2451,7 +2340,6 @@ void AnimationTrackEdit::_play_position_draw() {
}
void AnimationTrackEdit::set_play_position(float p_pos) {
-
play_position_pos = p_pos;
play_position->update();
}
@@ -2478,9 +2366,9 @@ void AnimationTrackEdit::_path_entered(const String &p_text) {
}
bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const {
-
- if (root == nullptr)
+ if (root == nullptr) {
return false;
+ }
RES res;
Vector<StringName> leftover_path;
@@ -2502,7 +2390,6 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant
}
String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
-
if (check_rect.has_point(p_pos)) {
return TTR("Toggle this track on/off.");
}
@@ -2534,20 +2421,17 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
int limit_start_hitbox = limit - type_icon->get_width();
if (p_pos.x >= limit_start_hitbox && p_pos.x <= limit_end) {
-
int key_idx = -1;
float key_distance = 1e20;
// Select should happen in the opposite order of drawing for more accurate overlap select.
for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) {
-
Rect2 rect = const_cast<AnimationTrackEdit *>(this)->get_key_rect(i, timeline->get_zoom_scale());
float offset = animation->track_get_key_time(track, i) - timeline->get_value();
offset = offset * timeline->get_zoom_scale() + limit;
rect.position.x += offset;
if (rect.has_point(p_pos)) {
-
if (const_cast<AnimationTrackEdit *>(this)->is_key_selectable_by_distance()) {
float distance = ABS(offset - p_pos.x);
if (key_idx == -1 || distance < key_distance) {
@@ -2562,22 +2446,21 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
}
if (key_idx != -1) {
-
String text = TTR("Time (s): ") + rtos(animation->track_get_key_time(track, key_idx)) + "\n";
switch (animation->track_get_type(track)) {
-
case Animation::TYPE_TRANSFORM: {
-
Dictionary d = animation->track_get_key_value(track, key_idx);
- if (d.has("location"))
+ if (d.has("location")) {
text += "Pos: " + String(d["location"]) + "\n";
- if (d.has("rotation"))
+ }
+ if (d.has("rotation")) {
text += "Rot: " + String(d["rotation"]) + "\n";
- if (d.has("scale"))
+ }
+ if (d.has("scale")) {
text += "Scale: " + String(d["scale"]) + "\n";
+ }
} break;
case Animation::TYPE_VALUE: {
-
const Variant &v = animation->track_get_key_value(track, key_idx);
text += "Type: " + Variant::get_type_name(v.get_type()) + "\n";
Variant::Type valid_type = Variant::NIL;
@@ -2590,25 +2473,25 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
} break;
case Animation::TYPE_METHOD: {
-
Dictionary d = animation->track_get_key_value(track, key_idx);
- if (d.has("method"))
+ if (d.has("method")) {
text += String(d["method"]);
+ }
text += "(";
Vector<Variant> args;
- if (d.has("args"))
+ if (d.has("args")) {
args = d["args"];
+ }
for (int i = 0; i < args.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
text += ", ";
+ }
text += String(args[i]);
}
text += ")\n";
} break;
case Animation::TYPE_BEZIER: {
-
float h = animation->bezier_track_get_key_value(track, key_idx);
text += "Value: " + rtos(h) + "\n";
Vector2 ih = animation->bezier_track_get_key_in_handle(track, key_idx);
@@ -2617,7 +2500,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
text += "Out-Handle: " + oh + "\n";
} break;
case Animation::TYPE_AUDIO: {
-
String stream_name = "null";
RES stream = animation->audio_track_get_key_stream(track, key_idx);
if (stream.is_valid()) {
@@ -2637,7 +2519,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
text += "End (s): " + rtos(eo) + "\n";
} break;
case Animation::TYPE_ANIMATION: {
-
String name = animation->animation_track_get_key_animation(track, key_idx);
text += "Animation Clip: " + name + "\n";
} break;
@@ -2760,20 +2641,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
int limit_start_hitbox = limit - type_icon->get_width();
if (pos.x >= limit_start_hitbox && pos.x <= limit_end) {
-
int key_idx = -1;
float key_distance = 1e20;
// Select should happen in the opposite order of drawing for more accurate overlap select.
for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) {
-
Rect2 rect = get_key_rect(i, scale);
float offset = animation->track_get_key_time(track, i) - timeline->get_value();
offset = offset * scale + limit;
rect.position.x += offset;
if (rect.has_point(pos)) {
-
if (is_key_selectable_by_distance()) {
float distance = ABS(offset - pos.x);
if (key_idx == -1 || distance < key_distance) {
@@ -2845,7 +2723,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && clicking_on_name) {
-
if (!path) {
path_popup = memnew(Popup);
path_popup->set_wrap_controls(true);
@@ -2867,7 +2744,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && moving_selection_attempt) {
-
if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
moving_selection_attempt = false;
if (moving_selection) {
@@ -2880,7 +2756,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (moving_selection && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
-
moving_selection_attempt = false;
moving_selection = false;
emit_signal("move_selection_cancel");
@@ -2889,7 +2764,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT && moving_selection_attempt) {
-
if (!moving_selection) {
moving_selection = true;
emit_signal("move_selection_begin");
@@ -2901,9 +2775,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) {
-
- if (!clicking_on_name)
+ if (!clicking_on_name) {
return Variant();
+ }
Dictionary drag_data;
drag_data["type"] = "animation_track";
@@ -2923,7 +2797,6 @@ Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) {
}
bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
Dictionary d = p_data;
if (!d.has("type")) {
return false;
@@ -2954,8 +2827,8 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d
return true;
}
-void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
+void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
Dictionary d = p_data;
if (!d.has("type")) {
return;
@@ -2985,13 +2858,11 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data)
}
void AnimationTrackEdit::_menu_selected(int p_index) {
-
switch (p_index) {
case MENU_CALL_MODE_CONTINUOUS:
case MENU_CALL_MODE_DISCRETE:
case MENU_CALL_MODE_TRIGGER:
case MENU_CALL_MODE_CAPTURE: {
-
Animation::UpdateMode update_mode = Animation::UpdateMode(p_index);
undo_redo->create_action(TTR("Change Animation Update Mode"));
undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode);
@@ -3003,7 +2874,6 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
case MENU_INTERPOLATION_NEAREST:
case MENU_INTERPOLATION_LINEAR:
case MENU_INTERPOLATION_CUBIC: {
-
Animation::InterpolationType interp_mode = Animation::InterpolationType(p_index - MENU_INTERPOLATION_NEAREST);
undo_redo->create_action(TTR("Change Animation Interpolation Mode"));
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode);
@@ -3013,7 +2883,6 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
} break;
case MENU_LOOP_WRAP:
case MENU_LOOP_CLAMP: {
-
bool loop_wrap = p_index == MENU_LOOP_WRAP;
undo_redo->create_action(TTR("Change Animation Loop Mode"));
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap);
@@ -3042,6 +2911,7 @@ void AnimationTrackEdit::cancel_drop() {
update();
}
}
+
void AnimationTrackEdit::set_in_group(bool p_enable) {
in_group = p_enable;
update();
@@ -3055,23 +2925,22 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect
// Select should happen in the opposite order of drawing for more accurate overlap select.
for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) {
-
Rect2 rect = const_cast<AnimationTrackEdit *>(this)->get_key_rect(i, timeline->get_zoom_scale());
float offset = animation->track_get_key_time(track, i) - timeline->get_value();
offset = offset * timeline->get_zoom_scale() + timeline->get_name_limit();
rect.position.x += offset;
if (select_rect.intersects(rect)) {
- if (p_deselection)
+ if (p_deselection) {
emit_signal("deselect_key", i);
- else
+ } else {
emit_signal("select_key", i, false);
+ }
}
}
}
void AnimationTrackEdit::_bind_methods() {
-
ClassDB::bind_method("_gui_input", &AnimationTrackEdit::_gui_input);
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag")));
@@ -3147,7 +3016,6 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_
}
AnimationTrackEdit *AnimationTrackEditPlugin::create_audio_track_edit() {
-
if (get_script_instance()) {
return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_audio_track_edit").operator Object *());
}
@@ -3164,7 +3032,6 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object
///////////////////////////////////////
void AnimationTrackEditGroup::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
Ref<Font> font = get_theme_font("font", "Label");
int separation = get_theme_constant("hseparation", "ItemList");
@@ -3210,7 +3077,6 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co
}
Size2 AnimationTrackEditGroup::get_minimum_size() const {
-
Ref<Font> font = get_theme_font("font", "Label");
int separation = get_theme_constant("vseparation", "ItemList");
@@ -3242,19 +3108,17 @@ AnimationTrackEditGroup::AnimationTrackEditGroup() {
//////////////////////////////////////
void AnimationTrackEditor::add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin) {
-
- if (track_edit_plugins.find(p_plugin) != -1)
+ if (track_edit_plugins.find(p_plugin) != -1) {
return;
+ }
track_edit_plugins.push_back(p_plugin);
}
void AnimationTrackEditor::remove_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin) {
-
track_edit_plugins.erase(p_plugin);
}
void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
-
if (animation != p_anim && _get_track_selected() >= 0) {
track_edits[_get_track_selected()]->release_focus();
}
@@ -3302,7 +3166,6 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
}
Ref<Animation> AnimationTrackEditor::get_current_animation() const {
-
return animation;
}
@@ -3325,24 +3188,25 @@ void AnimationTrackEditor::set_root(Node *p_root) {
}
Node *AnimationTrackEditor::get_root() const {
-
return root;
}
void AnimationTrackEditor::update_keying() {
bool keying_enabled = is_visible_in_tree() && animation.is_valid();
- if (keying_enabled == keying)
+ if (keying_enabled == keying) {
return;
+ }
keying = keying_enabled;
- //_update_menu();
+
emit_signal("keying_changed");
}
bool AnimationTrackEditor::has_keying() const {
return keying;
}
+
Dictionary AnimationTrackEditor::get_state() const {
Dictionary state;
state["fps_mode"] = timeline->is_using_fps();
@@ -3351,6 +3215,7 @@ Dictionary AnimationTrackEditor::get_state() const {
state["v_scroll"] = scroll->get_v_scrollbar()->get_value();
return state;
}
+
void AnimationTrackEditor::set_state(const Dictionary &p_state) {
if (p_state.has("fps_mode")) {
bool fps_mode = p_state["fps_mode"];
@@ -3386,22 +3251,18 @@ void AnimationTrackEditor::cleanup() {
}
void AnimationTrackEditor::_name_limit_changed() {
-
for (int i = 0; i < track_edits.size(); i++) {
track_edits[i]->update();
}
}
void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag) {
-
emit_signal("timeline_changed", p_new_pos, p_drag);
}
void AnimationTrackEditor::_track_remove_request(int p_track) {
-
int idx = p_track;
if (idx >= 0 && idx < animation->get_track_count()) {
-
undo_redo->create_action(TTR("Remove Anim Track"));
undo_redo->add_do_method(this, "_clear_selection", false);
undo_redo->add_do_method(animation.ptr(), "remove_track", idx);
@@ -3410,7 +3271,6 @@ void AnimationTrackEditor::_track_remove_request(int p_track) {
// TODO interpolation.
for (int i = 0; i < animation->track_get_key_count(idx); i++) {
-
Variant v = animation->track_get_key_value(idx, i);
float time = animation->track_get_key_time(idx, i);
float trans = animation->track_get_key_transition(idx, i);
@@ -3429,14 +3289,13 @@ void AnimationTrackEditor::_track_remove_request(int p_track) {
}
void AnimationTrackEditor::_track_grab_focus(int p_track) {
-
// Don't steal focus if not working with the track editor.
- if (Object::cast_to<AnimationTrackEdit>(get_focus_owner()))
+ if (Object::cast_to<AnimationTrackEdit>(get_focus_owner())) {
track_edits[p_track]->grab_focus();
+ }
}
void AnimationTrackEditor::set_anim_pos(float p_pos) {
-
timeline->set_play_position(p_pos);
for (int i = 0; i < track_edits.size(); i++) {
track_edits[i]->set_play_position(p_pos);
@@ -3448,11 +3307,11 @@ void AnimationTrackEditor::set_anim_pos(float p_pos) {
}
void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
-
if (insert_frame != Engine::get_singleton()->get_frames_drawn()) {
//clear insert list for the frame if frame changed
- if (insert_confirm->is_visible())
+ if (insert_confirm->is_visible()) {
return; //do nothing
+ }
insert_data.clear();
insert_query = false;
}
@@ -3460,8 +3319,9 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
for (List<InsertData>::Element *E = insert_data.front(); E; E = E->next()) {
//prevent insertion of multiple tracks
- if (E->get().path == p_id.path)
+ if (E->get().path == p_id.path) {
return; //already inserted a track for this on this frame
+ }
}
insert_data.push_back(p_id);
@@ -3472,14 +3332,17 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
int num_tracks = 0;
bool all_bezier = true;
for (int i = 0; i < insert_data.size(); i++) {
- if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER)
+ if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER) {
all_bezier = false;
+ }
- if (insert_data[i].track_idx == -1)
+ if (insert_data[i].track_idx == -1) {
++num_tracks;
+ }
- if (insert_data[i].type != Animation::TYPE_VALUE)
+ if (insert_data[i].type != Animation::TYPE_VALUE) {
continue;
+ }
switch (insert_data[i].value.get_type()) {
case Variant::INT:
@@ -3497,10 +3360,11 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
}
}
- if (num_tracks == 1)
+ if (num_tracks == 1) {
insert_confirm_text->set_text(vformat(TTR("Create NEW track for %s and insert key?"), p_id.query));
- else
+ } else {
insert_confirm_text->set_text(vformat(TTR("Create %d NEW tracks and insert keys?"), num_tracks));
+ }
insert_confirm_bezier->set_visible(all_bezier);
insert_confirm->get_ok()->set_text(TTR("Create"));
@@ -3520,7 +3384,6 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
}
void AnimationTrackEditor::_insert_delay() {
-
if (insert_query) {
//discard since it's entered into query mode
insert_queue = false;
@@ -3532,9 +3395,9 @@ void AnimationTrackEditor::_insert_delay() {
int last_track = animation->get_track_count();
bool advance = false;
while (insert_data.size()) {
-
- if (insert_data.front()->get().advance)
+ if (insert_data.front()->get().advance) {
advance = true;
+ }
last_track = _confirm_insert(insert_data.front()->get(), last_track);
insert_data.pop_front();
}
@@ -3543,14 +3406,16 @@ void AnimationTrackEditor::_insert_delay() {
if (advance) {
float step = animation->get_step();
- if (step == 0)
+ if (step == 0) {
step = 1;
+ }
float pos = timeline->get_play_position();
pos = Math::stepify(pos + step, step);
- if (pos > animation->get_length())
+ if (pos > animation->get_length()) {
pos = animation->get_length();
+ }
set_anim_pos(pos);
emit_signal("timeline_changed", pos, true);
}
@@ -3558,28 +3423,31 @@ void AnimationTrackEditor::_insert_delay() {
}
void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) {
-
- if (!keying)
+ if (!keying) {
return;
- if (!animation.is_valid())
+ }
+ if (!animation.is_valid()) {
return;
+ }
ERR_FAIL_COND(!root);
//let's build a node path
String path = root->get_path_to(p_node);
- if (p_sub != "")
+ if (p_sub != "") {
path += ":" + p_sub;
+ }
NodePath np = path;
int track_idx = -1;
for (int i = 0; i < animation->get_track_count(); i++) {
-
- if (animation->track_get_type(i) != Animation::TYPE_TRANSFORM)
+ if (animation->track_get_type(i) != Animation::TYPE_TRANSFORM) {
continue;
- if (animation->track_get_path(i) != np)
+ }
+ if (animation->track_get_path(i) != np) {
continue;
+ }
track_idx = i;
break;
@@ -3601,12 +3469,10 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_
}
void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant &p_value) {
-
String path = p_path;
//animation property is a special case, always creates an animation track
for (int i = 0; i < animation->get_track_count(); i++) {
-
String np = animation->track_get_path(i);
if (path == np && animation->track_get_type(i) == Animation::TYPE_ANIMATION) {
@@ -3636,7 +3502,6 @@ void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant
}
void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists) {
-
ERR_FAIL_COND(!root);
//let's build a node path
@@ -3655,7 +3520,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
EditorHistory *history = EditorNode::get_singleton()->get_editor_history();
for (int i = 1; i < history->get_path_size(); i++) {
-
String prop = history->get_path_property(i);
ERR_FAIL_COND(prop == "");
path += ":" + prop;
@@ -3670,10 +3534,10 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
bool inserted = false;
for (int i = 0; i < animation->get_track_count(); i++) {
-
if (animation->track_get_type(i) == Animation::TYPE_VALUE) {
- if (animation->track_get_path(i) != np)
+ if (animation->track_get_path(i) != np) {
continue;
+ }
InsertData id;
id.path = np;
@@ -3686,7 +3550,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
_query_insert(id);
inserted = true;
} else if (animation->track_get_type(i) == Animation::TYPE_BEZIER) {
-
Variant value;
String track_path = animation->track_get_path(i);
if (track_path == np) {
@@ -3698,10 +3561,12 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
if (base_path == np) {
String value_name = track_path.substr(sep + 1);
value = p_value.get(value_name);
- } else
+ } else {
continue;
- } else
+ }
+ } else {
continue;
+ }
}
InsertData id;
@@ -3717,8 +3582,9 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
}
}
- if (inserted || p_only_if_exists)
+ if (inserted || p_only_if_exists) {
return;
+ }
InsertData id;
id.path = np;
id.track_idx = -1;
@@ -3731,7 +3597,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
}
void AnimationTrackEditor::insert_value_key(const String &p_property, const Variant &p_value, bool p_advance) {
-
EditorHistory *history = EditorNode::get_singleton()->get_editor_history();
ERR_FAIL_COND(!root);
@@ -3754,7 +3619,6 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
}
for (int i = 1; i < history->get_path_size(); i++) {
-
String prop = history->get_path_property(i);
ERR_FAIL_COND(prop == "");
path += ":" + prop;
@@ -3769,10 +3633,10 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
bool inserted = false;
for (int i = 0; i < animation->get_track_count(); i++) {
-
if (animation->track_get_type(i) == Animation::TYPE_VALUE) {
- if (animation->track_get_path(i) != np)
+ if (animation->track_get_path(i) != np) {
continue;
+ }
InsertData id;
id.path = np;
@@ -3785,7 +3649,6 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
_query_insert(id);
inserted = true;
} else if (animation->track_get_type(i) == Animation::TYPE_BEZIER) {
-
Variant value;
if (animation->track_get_path(i) == np) {
value = p_value; //all good
@@ -3827,12 +3690,10 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
}
void AnimationTrackEditor::_confirm_insert_list() {
-
undo_redo->create_action(TTR("Anim Create & Insert"));
int last_track = animation->get_track_count();
while (insert_data.size()) {
-
last_track = _confirm_insert(insert_data.front()->get(), last_track, insert_confirm_bezier->is_pressed());
insert_data.pop_front();
}
@@ -3841,7 +3702,6 @@ void AnimationTrackEditor::_confirm_insert_list() {
}
PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val) {
-
r_base_path = NodePath();
ERR_FAIL_COND_V(!animation.is_valid(), PropertyInfo());
ERR_FAIL_INDEX_V(p_idx, animation->get_track_count(), PropertyInfo());
@@ -3896,7 +3756,6 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b
property_info_base.get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
if (E->get().name == leftover_path[leftover_path.size() - 1]) {
return E->get();
}
@@ -3955,13 +3814,12 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool
}
int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, bool p_create_beziers) {
-
- if (p_last_track == -1)
+ if (p_last_track == -1) {
p_last_track = animation->get_track_count();
+ }
bool created = false;
if (p_id.track_idx < 0) {
-
if (p_create_beziers) {
bool valid;
Vector<String> subindices = _get_bezier_subindices_for_type(p_id.value.get_type(), &valid);
@@ -4002,7 +3860,6 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo
h.type == Variant::PLANE ||
h.type == Variant::TRANSFORM2D ||
h.type == Variant::TRANSFORM) {
-
update_mode = Animation::UPDATE_CONTINUOUS;
}
@@ -4016,8 +3873,9 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo
undo_redo->add_do_method(animation.ptr(), "add_track", p_id.type);
undo_redo->add_do_method(animation.ptr(), "track_set_path", p_id.track_idx, p_id.path);
- if (p_id.type == Animation::TYPE_VALUE)
+ if (p_id.type == Animation::TYPE_VALUE) {
undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", p_id.track_idx, update_mode);
+ }
} else {
undo_redo->create_action(TTR("Anim Insert Key"));
@@ -4027,14 +3885,11 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo
Variant value;
switch (p_id.type) {
-
case Animation::TYPE_VALUE: {
-
value = p_id.value;
} break;
case Animation::TYPE_TRANSFORM: {
-
Transform tr = p_id.value;
Dictionary d;
d["location"] = tr.origin;
@@ -4063,13 +3918,11 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo
undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, value);
if (created) {
-
// Just remove the track.
undo_redo->add_undo_method(this, "_clear_selection", false);
undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count());
p_last_track++;
} else {
-
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_id.track_idx, time);
int existing = animation->track_find_key(p_id.track_idx, time, true);
if (existing != -1) {
@@ -4085,12 +3938,10 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo
}
void AnimationTrackEditor::show_select_node_warning(bool p_show) {
-
info_message->set_visible(p_show);
}
bool AnimationTrackEditor::is_key_selected(int p_track, int p_key) const {
-
SelectedKey sk;
sk.key = p_key;
sk.track = p_track;
@@ -4107,7 +3958,6 @@ bool AnimationTrackEditor::is_snap_enabled() const {
}
void AnimationTrackEditor::_update_tracks() {
-
int selected = _get_track_selected();
while (track_vbox->get_child_count()) {
@@ -4117,8 +3967,9 @@ void AnimationTrackEditor::_update_tracks() {
track_edits.clear();
groups.clear();
- if (animation.is_null())
+ if (animation.is_null()) {
return;
+ }
Map<String, VBoxContainer *> group_sort;
@@ -4145,7 +3996,6 @@ void AnimationTrackEditor::_update_tracks() {
}
if (animation->track_get_type(i) == Animation::TYPE_VALUE) {
-
NodePath path = animation->track_get_path(i);
if (root && root->has_node_and_resource(path)) {
@@ -4175,7 +4025,6 @@ void AnimationTrackEditor::_update_tracks() {
}
}
if (animation->track_get_type(i) == Animation::TYPE_AUDIO) {
-
for (int j = 0; j < track_edit_plugins.size(); j++) {
track_edit = track_edit_plugins.write[j]->create_audio_track_edit();
if (track_edit) {
@@ -4277,7 +4126,6 @@ void AnimationTrackEditor::_update_tracks() {
}
void AnimationTrackEditor::_animation_changed() {
-
if (animation_changing_awaiting_update) {
return; //all will be updated, don't bother with anything
}
@@ -4285,10 +4133,11 @@ void AnimationTrackEditor::_animation_changed() {
if (key_edit && key_edit->setting) {
//if editing a key, just update the edited track, makes refresh less costly
if (key_edit->track < track_edits.size()) {
- if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER)
+ if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER) {
bezier_edit->update();
- else
+ } else {
track_edits[key_edit->track]->update();
+ }
}
return;
}
@@ -4298,7 +4147,6 @@ void AnimationTrackEditor::_animation_changed() {
}
void AnimationTrackEditor::_snap_mode_changed(int p_mode) {
-
timeline->set_use_fps(p_mode == 1);
if (key_edit) {
key_edit->set_use_fps(p_mode == 1);
@@ -4325,8 +4173,8 @@ void AnimationTrackEditor::_update_step_spinbox() {
step->set_block_signals(false);
}
-void AnimationTrackEditor::_animation_update() {
+void AnimationTrackEditor::_animation_update() {
timeline->update();
timeline->update_values();
@@ -4405,7 +4253,6 @@ void AnimationTrackEditor::_update_scroll(double) {
}
void AnimationTrackEditor::_update_step(double p_new_step) {
-
undo_redo->create_action(TTR("Change Animation Step"));
float step_value = p_new_step;
if (timeline->is_using_fps()) {
@@ -4422,7 +4269,6 @@ void AnimationTrackEditor::_update_step(double p_new_step) {
}
void AnimationTrackEditor::_update_length(double p_new_len) {
-
emit_signal("animation_len_changed", p_new_len);
}
@@ -4443,7 +4289,6 @@ void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) {
}
void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
-
ERR_FAIL_COND(!root);
Node *node = get_node(p_path);
ERR_FAIL_COND(!node);
@@ -4462,7 +4307,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
} break;
case Animation::TYPE_TRANSFORM:
case Animation::TYPE_METHOD: {
-
undo_redo->create_action(TTR("Add Track"));
undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type);
undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to);
@@ -4471,7 +4315,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
} break;
case Animation::TYPE_BEZIER: {
-
Vector<Variant::Type> filter;
filter.push_back(Variant::INT);
filter.push_back(Variant::FLOAT);
@@ -4486,7 +4329,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
prop_selector->select_property_from_instance(node);
} break;
case Animation::TYPE_AUDIO: {
-
if (!node->is_class("AudioStreamPlayer") && !node->is_class("AudioStreamPlayer2D") && !node->is_class("AudioStreamPlayer3D")) {
EditorNode::get_singleton()->show_warning(TTR("Audio tracks can only point to nodes of type:\n-AudioStreamPlayer\n-AudioStreamPlayer2D\n-AudioStreamPlayer3D"));
return;
@@ -4500,7 +4342,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
} break;
case Animation::TYPE_ANIMATION: {
-
if (!node->is_class("AnimationPlayer")) {
EditorNode::get_singleton()->show_warning(TTR("Animation tracks can only point to AnimationPlayer nodes."));
return;
@@ -4531,11 +4372,9 @@ void AnimationTrackEditor::_add_track(int p_type) {
}
void AnimationTrackEditor::_new_track_property_selected(String p_name) {
-
String full_path = String(adding_track_path) + ":" + p_name;
if (adding_track_type == Animation::TYPE_VALUE) {
-
Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE;
{
//hack
@@ -4554,7 +4393,6 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) {
h.type == Variant::PLANE ||
h.type == Variant::TRANSFORM2D ||
h.type == Variant::TRANSFORM) {
-
update_mode = Animation::UPDATE_CONTINUOUS;
}
@@ -4598,7 +4436,6 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) {
}
void AnimationTrackEditor::_timeline_value_changed(double) {
-
timeline->update_play_position();
for (int i = 0; i < track_edits.size(); i++) {
@@ -4615,17 +4452,16 @@ void AnimationTrackEditor::_timeline_value_changed(double) {
}
int AnimationTrackEditor::_get_track_selected() {
-
for (int i = 0; i < track_edits.size(); i++) {
- if (track_edits[i]->has_focus())
+ if (track_edits[i]->has_focus()) {
return i;
+ }
}
return -1;
}
void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
-
ERR_FAIL_INDEX(p_track, animation->get_track_count());
if (snap->is_pressed() && step->get_value() != 0) {
@@ -4661,7 +4497,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
} break;
case Animation::TYPE_VALUE: {
-
NodePath bp;
Variant value;
_find_hint_for_track(p_track, bp, &value);
@@ -4687,7 +4522,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
} break;
case Animation::TYPE_BEZIER: {
-
NodePath bp;
Variant value;
_find_hint_for_track(p_track, bp, &value);
@@ -4706,7 +4540,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
} break;
case Animation::TYPE_AUDIO: {
-
Dictionary ak;
ak["stream"] = RES();
ak["start_offset"] = 0;
@@ -4718,7 +4551,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
undo_redo->commit_action();
} break;
case Animation::TYPE_ANIMATION: {
-
StringName anim = "[stop]";
undo_redo->create_action(TTR("Add Track Key"));
@@ -4730,7 +4562,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
}
void AnimationTrackEditor::_add_method_key(const String &p_method) {
-
if (!root->has_node(animation->track_get_path(insert_key_from_track_call_track))) {
EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a method key."));
return;
@@ -4742,14 +4573,12 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) {
for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) {
if (E->get().name == p_method) {
-
Dictionary d;
d["method"] = p_method;
Array params;
int first_defarg = E->get().arguments.size() - E->get().default_arguments.size();
for (int i = 0; i < E->get().arguments.size(); i++) {
-
if (i >= first_defarg) {
Variant arg = E->get().default_arguments[i - first_defarg];
params.push_back(arg);
@@ -4774,7 +4603,6 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) {
}
void AnimationTrackEditor::_key_selected(int p_key, bool p_single, int p_track) {
-
ERR_FAIL_INDEX(p_track, animation->get_track_count());
ERR_FAIL_INDEX(p_key, animation->track_get_key_count(p_track));
@@ -4798,7 +4626,6 @@ void AnimationTrackEditor::_key_selected(int p_key, bool p_single, int p_track)
}
void AnimationTrackEditor::_key_deselected(int p_key, int p_track) {
-
ERR_FAIL_INDEX(p_track, animation->get_track_count());
ERR_FAIL_INDEX(p_key, animation->track_get_key_count(p_track));
@@ -4829,7 +4656,6 @@ void AnimationTrackEditor::_move_selection(float p_offset) {
}
struct _AnimMoveRestore {
-
int track;
float time;
Variant key;
@@ -4860,7 +4686,6 @@ void AnimationTrackEditor::_clear_key_edit() {
}
void AnimationTrackEditor::_clear_selection(bool p_update) {
-
selection.clear();
if (p_update) {
@@ -4873,13 +4698,12 @@ void AnimationTrackEditor::_clear_selection(bool p_update) {
}
void AnimationTrackEditor::_update_key_edit() {
-
_clear_key_edit();
- if (!animation.is_valid())
+ if (!animation.is_valid()) {
return;
+ }
if (selection.size() == 1) {
-
key_edit = memnew(AnimationTrackKeyEdit);
key_edit->animation = animation;
key_edit->track = selection.front()->key().track;
@@ -4896,7 +4720,6 @@ void AnimationTrackEditor::_update_key_edit() {
EditorNode::get_singleton()->push_item(key_edit);
} else if (selection.size() > 1) {
-
multi_key_edit = memnew(AnimationMultiTrackKeyEdit);
multi_key_edit->animation = animation;
@@ -4904,10 +4727,10 @@ void AnimationTrackEditor::_update_key_edit() {
Map<int, NodePath> base_map;
int first_track = -1;
for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
-
int track = E->key().track;
- if (first_track < 0)
+ if (first_track < 0) {
first_track = track;
+ }
if (!key_ofs_map.has(track)) {
key_ofs_map[track] = List<float>();
@@ -4931,17 +4754,17 @@ void AnimationTrackEditor::_update_key_edit() {
}
void AnimationTrackEditor::_clear_selection_for_anim(const Ref<Animation> &p_anim) {
-
- if (animation != p_anim)
+ if (animation != p_anim) {
return;
+ }
_clear_selection();
}
void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos) {
-
- if (animation != p_anim)
+ if (animation != p_anim) {
return;
+ }
int idx = animation->track_find_key(p_track, p_pos, true);
ERR_FAIL_COND(idx < 0);
@@ -4956,7 +4779,6 @@ void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_t
}
void AnimationTrackEditor::_move_selection_commit() {
-
undo_redo->create_action(TTR("Anim Move Keys"));
List<_AnimMoveRestore> to_restore;
@@ -4964,21 +4786,21 @@ void AnimationTrackEditor::_move_selection_commit() {
float motion = moving_selection_offset;
// 1 - remove the keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
}
// 2 - remove overlapped keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float newtime = snap_time(E->get().pos + motion);
int idx = animation->track_find_key(E->key().track, newtime, true);
- if (idx == -1)
+ if (idx == -1) {
continue;
+ }
SelectedKey sk;
sk.key = idx;
sk.track = E->key().track;
- if (selection.has(sk))
+ if (selection.has(sk)) {
continue; //already in selection, don't save
+ }
undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newtime);
_AnimMoveRestore amr;
@@ -4993,27 +4815,23 @@ void AnimationTrackEditor::_move_selection_commit() {
// 3 - move the keys (re insert them)
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float newpos = snap_time(E->get().pos + motion);
undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 4 - (undo) remove inserted keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float newpos = snap_time(E->get().pos + motion);
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos);
}
// 5 - (undo) reinsert keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 6 - (undo) reinsert overlapped keys
for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
-
_AnimMoveRestore &amr = E->get();
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition);
}
@@ -5023,7 +4841,6 @@ void AnimationTrackEditor::_move_selection_commit() {
// 7 - reselect
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float oldpos = E->get().pos;
float newpos = snap_time(oldpos + motion);
@@ -5040,8 +4857,8 @@ void AnimationTrackEditor::_move_selection_commit() {
_update_key_edit();
}
-void AnimationTrackEditor::_move_selection_cancel() {
+void AnimationTrackEditor::_move_selection_cancel() {
moving_selection = false;
for (int i = 0; i < track_edits.size(); i++) {
track_edits[i]->update();
@@ -5051,29 +4868,26 @@ void AnimationTrackEditor::_move_selection_cancel() {
bool AnimationTrackEditor::is_moving_selection() const {
return moving_selection;
}
+
float AnimationTrackEditor::get_moving_selection_offset() const {
return moving_selection_offset;
}
void AnimationTrackEditor::_box_selection_draw() {
-
const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size());
box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor"));
box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE));
}
void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == BUTTON_WHEEL_DOWN) {
-
+ if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == BUTTON_WHEEL_UP) {
timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() * 1.05);
scroll->accept_event();
}
- if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == BUTTON_WHEEL_UP) {
-
+ if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == BUTTON_WHEEL_DOWN) {
timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() / 1.05);
scroll->accept_event();
}
@@ -5084,11 +4898,9 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {
box_selecting_from = scroll->get_global_transform().xform(mb->get_position());
box_select_rect = Rect2();
} else if (box_selecting) {
-
if (box_selection->is_visible_in_tree()) {
//only if moved
for (int i = 0; i < track_edits.size(); i++) {
-
Rect2 local_rect = box_select_rect;
local_rect.position -= track_edits[i]->get_global_position();
track_edits[i]->append_to_selection(local_rect, mb->get_command());
@@ -5109,12 +4921,10 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) {
-
timeline->set_value(timeline->get_value() - mm->get_relative().x / timeline->get_zoom_scale());
}
if (mm.is_valid() && box_selecting) {
-
if (!(mm->get_button_mask() & BUTTON_MASK_LEFT)) {
//no longer
box_selection->hide();
@@ -5161,7 +4971,6 @@ void AnimationTrackEditor::_cancel_bezier_edit() {
}
void AnimationTrackEditor::_bezier_edit(int p_for_track) {
-
_clear_selection(); //bezier probably wants to use a separate selection mode
bezier_edit->set_root(root);
bezier_edit->set_animation_and_track(animation, p_for_track);
@@ -5173,18 +4982,18 @@ void AnimationTrackEditor::_bezier_edit(int p_for_track) {
void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
//duplicait!
if (selection.size() && animation.is_valid() && (!transpose || (_get_track_selected() >= 0 && _get_track_selected() < animation->get_track_count()))) {
-
int top_track = 0x7FFFFFFF;
float top_time = 1e10;
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
const SelectedKey &sk = E->key();
float t = animation->track_get_key_time(sk.track, sk.key);
- if (t < top_time)
+ if (t < top_time) {
top_time = t;
- if (sk.track < top_track)
+ }
+ if (sk.track < top_track) {
top_track = sk.track;
+ }
}
ERR_FAIL_COND(top_track == 0x7FFFFFFF || top_time == 1e10);
@@ -5197,7 +5006,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
List<Pair<int, float>> new_selection_values;
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
const SelectedKey &sk = E->key();
float t = animation->track_get_key_time(sk.track, sk.key);
@@ -5205,11 +5013,13 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
float dst_time = t + (timeline->get_play_position() - top_time);
int dst_track = sk.track + (start_track - top_track);
- if (dst_track < 0 || dst_track >= animation->get_track_count())
+ if (dst_track < 0 || dst_track >= animation->get_track_count()) {
continue;
+ }
- if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track))
+ if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track)) {
continue;
+ }
int existing_idx = animation->track_find_key(dst_track, dst_time, true);
@@ -5222,7 +5032,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
new_selection_values.push_back(p);
if (existing_idx != -1) {
-
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", dst_track, dst_time, animation->track_get_key_value(dst_track, existing_idx), animation->track_get_key_transition(dst_track, existing_idx));
}
}
@@ -5233,14 +5042,14 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
Map<SelectedKey, KeyInfo> new_selection;
for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) {
-
int track = E->get().first;
float time = E->get().second;
int existing_idx = animation->track_find_key(track, time, true);
- if (existing_idx == -1)
+ if (existing_idx == -1) {
continue;
+ }
SelectedKey sk2;
sk2.track = track;
sk2.key = existing_idx;
@@ -5256,8 +5065,8 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) {
_update_key_edit();
}
}
-void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
+void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
last_menu_track_opt = p_option;
switch (p_option) {
case EDIT_COPY_TRACKS: {
@@ -5265,7 +5074,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
TreeItem *troot = track_copy_select->create_item();
for (int i = 0; i < animation->get_track_count(); i++) {
-
NodePath path = animation->track_get_path(i);
Node *node = nullptr;
@@ -5328,11 +5136,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
track_copy_dialog->popup_centered(Size2(350, 500) * EDSCALE);
} break;
case EDIT_COPY_TRACKS_CONFIRM: {
-
track_clipboard.clear();
TreeItem *root = track_copy_select->get_root();
if (root) {
-
TreeItem *it = root->get_children();
while (it) {
Dictionary md = it->get_metadata(0);
@@ -5362,7 +5168,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}
} break;
case EDIT_PASTE_TRACKS: {
-
if (track_clipboard.size() == 0) {
EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty"));
break;
@@ -5408,8 +5213,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
scale_dialog->popup_centered(Size2(200, 100) * EDSCALE);
} break;
case EDIT_SCALE_CONFIRM: {
- if (selection.empty())
+ if (selection.empty()) {
return;
+ }
float from_t = 1e20;
float to_t = -1e20;
@@ -5418,10 +5224,12 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
float t = animation->track_get_key_time(E->key().track, E->key().key);
- if (t < from_t)
+ if (t < from_t) {
from_t = t;
- if (t > to_t)
+ }
+ if (t > to_t) {
to_t = t;
+ }
}
len = to_t - from_t;
@@ -5429,7 +5237,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
pivot = timeline->get_play_position();
} else {
-
pivot = from_t;
}
@@ -5444,21 +5251,21 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
// 1-remove the keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
}
// 2- remove overlapped keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float newtime = (E->get().pos - from_t) * s + from_t;
int idx = animation->track_find_key(E->key().track, newtime, true);
- if (idx == -1)
+ if (idx == -1) {
continue;
+ }
SelectedKey sk;
sk.key = idx;
sk.track = E->key().track;
- if (selection.has(sk))
+ if (selection.has(sk)) {
continue; //already in selection, don't save
+ }
undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newtime);
_AnimMoveRestore amr;
@@ -5474,27 +5281,23 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
#define _NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * ABS(s) + from_t
// 3-move the keys (re insert them)
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float newpos = _NEW_POS(E->get().pos);
undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 4-(undo) remove inserted keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float newpos = _NEW_POS(E->get().pos);
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos);
}
// 5-(undo) reinsert keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 6-(undo) reinsert overlapped keys
for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
-
_AnimMoveRestore &amr = E->get();
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition);
}
@@ -5504,18 +5307,17 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
// 7-reselect
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
float oldpos = E->get().pos;
float newpos = _NEW_POS(oldpos);
- if (newpos >= 0)
+ if (newpos >= 0) {
undo_redo->add_do_method(this, "_select_at_anim", animation, E->key().track, newpos);
+ }
undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos);
}
#undef _NEW_POS
undo_redo->commit_action();
} break;
case EDIT_DUPLICATE_SELECTION: {
-
if (bezier_edit->is_visible()) {
bezier_edit->duplicate_selection();
break;
@@ -5530,7 +5332,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
_anim_duplicate_keys(true);
} break;
case EDIT_DELETE_SELECTION: {
-
if (bezier_edit->is_visible()) {
bezier_edit->delete_selection();
break;
@@ -5540,7 +5341,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
undo_redo->create_action(TTR("Anim Delete Keys"));
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
-
undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
@@ -5551,34 +5351,39 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}
} break;
case EDIT_GOTO_NEXT_STEP: {
-
- if (animation.is_null())
+ if (animation.is_null()) {
break;
+ }
float step = animation->get_step();
- if (step == 0)
+ if (step == 0) {
step = 1;
+ }
float pos = timeline->get_play_position();
pos = Math::stepify(pos + step, step);
- if (pos > animation->get_length())
+ if (pos > animation->get_length()) {
pos = animation->get_length();
+ }
set_anim_pos(pos);
emit_signal("timeline_changed", pos, true);
} break;
case EDIT_GOTO_PREV_STEP: {
- if (animation.is_null())
+ if (animation.is_null()) {
break;
+ }
float step = animation->get_step();
- if (step == 0)
+ if (step == 0) {
step = 1;
+ }
float pos = timeline->get_play_position();
pos = Math::stepify(pos - step, step);
- if (pos < 0)
+ if (pos < 0) {
pos = 0;
+ }
set_anim_pos(pos);
emit_signal("timeline_changed", pos, true);
@@ -5613,9 +5418,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}
void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
-
for (int i = 0; i < p_animation->get_track_count(); i++) {
-
bool prop_exists = false;
Variant::Type valid_type = Variant::NIL;
Object *obj = nullptr;
@@ -5636,17 +5439,16 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
}
if (!obj && cleanup_tracks->is_pressed()) {
-
p_animation->remove_track(i);
i--;
continue;
}
- if (!prop_exists || p_animation->track_get_type(i) != Animation::TYPE_VALUE || !cleanup_keys->is_pressed())
+ if (!prop_exists || p_animation->track_get_type(i) != Animation::TYPE_VALUE || !cleanup_keys->is_pressed()) {
continue;
+ }
for (int j = 0; j < p_animation->track_get_key_count(i); j++) {
-
Variant v = p_animation->track_get_key_value(i, j);
if (!Variant::can_convert(v.get_type(), valid_type)) {
@@ -5666,13 +5468,11 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
}
void AnimationTrackEditor::_view_group_toggle() {
-
_update_tracks();
view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons"));
}
bool AnimationTrackEditor::is_grouping_tracks() {
-
if (!view_group) {
return false;
}
@@ -5681,7 +5481,6 @@ bool AnimationTrackEditor::is_grouping_tracks() {
}
void AnimationTrackEditor::_selection_changed() {
-
if (selected_filter->is_pressed()) {
_update_tracks(); //needs updatin
} else {
@@ -5696,14 +5495,13 @@ void AnimationTrackEditor::_selection_changed() {
}
float AnimationTrackEditor::snap_time(float p_value, bool p_relative) {
-
if (is_snap_enabled()) {
-
double snap_increment;
- if (timeline->is_using_fps() && step->get_value() > 0)
+ if (timeline->is_using_fps() && step->get_value() > 0) {
snap_increment = 1.0 / step->get_value();
- else
+ } else {
snap_increment = step->get_value();
+ }
if (p_relative) {
double rel = Math::fmod(timeline->get_value(), snap_increment);
@@ -5717,22 +5515,22 @@ float AnimationTrackEditor::snap_time(float p_value, bool p_relative) {
}
void AnimationTrackEditor::_show_imported_anim_warning() {
-
// It looks terrible on a single line but the TTR extractor doesn't support line breaks yet.
EditorNode::get_singleton()->show_warning(TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\nTo enable the ability to add custom tracks, navigate to the scene's import settings and set\n\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks\", then re-import.\nAlternatively, use an import preset that imports animations to separate files."),
TTR("Warning: Editing imported animation"));
}
void AnimationTrackEditor::_select_all_tracks_for_copy() {
-
TreeItem *track = track_copy_select->get_root()->get_children();
- if (!track)
+ if (!track) {
return;
+ }
bool all_selected = true;
while (track) {
- if (!track->is_checked(0))
+ if (!track->is_checked(0)) {
all_selected = false;
+ }
track = track->get_next();
}
@@ -5745,7 +5543,6 @@ void AnimationTrackEditor::_select_all_tracks_for_copy() {
}
void AnimationTrackEditor::_bind_methods() {
-
ClassDB::bind_method("_animation_update", &AnimationTrackEditor::_animation_update);
ClassDB::bind_method("_track_grab_focus", &AnimationTrackEditor::_track_grab_focus);
ClassDB::bind_method("_update_tracks", &AnimationTrackEditor::_update_tracks);
@@ -5955,7 +5752,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
insert_confirm_bezier->set_text(TTR("Use Bezier Curves"));
icvb->add_child(insert_confirm_bezier);
keying = false;
- moving_selection = 0;
+ moving_selection = false;
key_edit = nullptr;
multi_key_edit = nullptr;
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 96a60cc135..6a46a1e3ff 100644
--- a/editor/animation_track_editor.h
+++ b/editor/animation_track_editor.h
@@ -121,7 +121,6 @@ public:
class AnimationTrackEditor;
class AnimationTrackEdit : public Control {
-
GDCLASS(AnimationTrackEdit, Control);
enum {
@@ -354,7 +353,6 @@ class AnimationTrackEditor : public VBoxContainer {
bool keying;
struct InsertData {
-
Animation::TrackType type;
NodePath path;
int track_idx;
@@ -395,14 +393,12 @@ class AnimationTrackEditor : public VBoxContainer {
//selection
struct SelectedKey {
-
int track;
int key;
bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; };
};
struct KeyInfo {
-
float pos;
};
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index 0ce3ab292e..9fc67000f9 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -41,32 +41,32 @@
/// BOOL ///
int AnimationTrackEditBool::get_key_height() const {
-
Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox");
return checked->get_height();
}
-Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) {
Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox");
return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height);
}
bool AnimationTrackEditBool::is_key_selectable_by_distance() const {
-
return false;
}
-void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
+void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
bool checked = get_animation()->track_get_key_value(get_track(), p_index);
Ref<Texture2D> icon = get_theme_icon(checked ? "checked" : "unchecked", "CheckBox");
Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2);
- if (ofs.x + icon->get_width() / 2 < p_clip_left)
+ if (ofs.x + icon->get_width() / 2 < p_clip_left) {
return;
+ }
- if (ofs.x + icon->get_width() / 2 > p_clip_right)
+ if (ofs.x + icon->get_width() / 2 > p_clip_right) {
return;
+ }
draw_texture(icon, ofs);
@@ -79,24 +79,21 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x,
/// COLOR ///
int AnimationTrackEditColor::get_key_height() const {
-
Ref<Font> font = get_theme_font("font", "Label");
return font->get_height() * 0.8;
}
-Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) {
Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 0.8;
return Rect2(-fh / 2, 0, fh, get_size().height);
}
bool AnimationTrackEditColor::is_key_selectable_by_distance() const {
-
return false;
}
void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
-
Ref<Font> font = get_theme_font("font", "Label");
int fh = (font->get_height() * 0.8);
@@ -104,8 +101,9 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int
int x_to = p_next_x - fh / 2 + 1;
fh /= 3;
- if (x_from > p_clip_right || x_to < p_clip_left)
+ if (x_from > p_clip_right || x_to < p_clip_left) {
return;
+ }
Color color = get_animation()->track_get_key_value(get_track(), p_index);
Color color_next = get_animation()->track_get_key_value(get_track(), p_index + 1);
@@ -143,7 +141,6 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int
}
void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
-
Color color = get_animation()->track_get_key_value(get_track(), p_index);
Ref<Font> font = get_theme_font("font", "Label");
@@ -166,11 +163,11 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x,
/// AUDIO ///
void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) {
-
Object *object = ObjectDB::get_instance(id);
- if (!object)
+ if (!object) {
return;
+ }
Ref<AudioStream> stream = object->call("get_stream");
@@ -180,7 +177,6 @@ void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) {
}
int AnimationTrackEditAudio::get_key_height() const {
-
if (!ObjectDB::get_instance(id)) {
return AnimationTrackEdit::get_key_height();
}
@@ -188,8 +184,8 @@ int AnimationTrackEditAudio::get_key_height() const {
Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
-Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -207,7 +203,6 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
float len = stream->get_length();
if (len == 0) {
-
Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
len = preview->get_length();
}
@@ -225,11 +220,10 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
}
bool AnimationTrackEditAudio::is_key_selectable_by_distance() const {
-
return false;
}
-void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
+void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -261,11 +255,13 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
- if (pixel_end < p_clip_left)
+ if (pixel_end < p_clip_left) {
return;
+ }
- if (pixel_begin > p_clip_right)
+ if (pixel_begin > p_clip_right) {
return;
+ }
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
@@ -276,8 +272,9 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
to_x = MIN(limit_x, to_x);
}
- if (to_x <= from_x)
+ if (to_x <= from_x) {
return;
+ }
Ref<Font> font = get_theme_font("font", "Label");
float fh = int(font->get_height() * 1.5);
@@ -289,7 +286,6 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
preview_len = preview->get_length();
for (int i = from_x; i < to_x; i++) {
-
float ofs = (i - pixel_begin) * preview_len / pixel_len;
float ofs_n = ((i + 1) - pixel_begin) * preview_len / pixel_len;
float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
@@ -325,7 +321,6 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
}
void AnimationTrackEditAudio::set_node(Object *p_object) {
-
id = p_object->get_instance_id();
}
@@ -339,7 +334,6 @@ AnimationTrackEditAudio::AnimationTrackEditAudio() {
/// SPRITE FRAME / FRAME_COORDS ///
int AnimationTrackEditSpriteFrame::get_key_height() const {
-
if (!ObjectDB::get_instance(id)) {
return AnimationTrackEdit::get_key_height();
}
@@ -347,8 +341,8 @@ int AnimationTrackEditSpriteFrame::get_key_height() const {
Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 2);
}
-Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_sec) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -358,7 +352,6 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
Size2 size;
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
-
Ref<Texture2D> texture = object->call("get_texture");
if (!texture.is_valid()) {
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
@@ -380,7 +373,6 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
size.y /= vframes;
}
} else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
-
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
if (sf.is_null()) {
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
@@ -421,11 +413,10 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
}
bool AnimationTrackEditSpriteFrame::is_key_selectable_by_distance() const {
-
return false;
}
-void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
+void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -437,7 +428,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
Rect2 region;
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
-
texture = object->call("get_texture");
if (!texture.is_valid()) {
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
@@ -459,7 +449,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.size = texture->get_size();
if (bool(object->call("is_region"))) {
-
region = Rect2(object->call("get_region_rect"));
}
@@ -474,7 +463,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.position.y += region.size.y * coords.y;
} else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
-
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
if (sf.is_null()) {
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
@@ -514,11 +502,13 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
Rect2 rect(p_x, int(get_size().height - height) / 2, width, height);
- if (rect.position.x + rect.size.x < p_clip_left)
+ if (rect.position.x + rect.size.x < p_clip_left) {
return;
+ }
- if (rect.position.x > p_clip_right)
+ if (rect.position.x > p_clip_right) {
return;
+ }
Color accent = get_theme_color("accent_color", "Editor");
Color bg = accent;
@@ -534,19 +524,16 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
}
void AnimationTrackEditSpriteFrame::set_node(Object *p_object) {
-
id = p_object->get_instance_id();
}
void AnimationTrackEditSpriteFrame::set_as_coords() {
-
is_coords = true;
}
/// SUB ANIMATION ///
int AnimationTrackEditSubAnim::get_key_height() const {
-
if (!ObjectDB::get_instance(id)) {
return AnimationTrackEdit::get_key_height();
}
@@ -554,8 +541,8 @@ int AnimationTrackEditSubAnim::get_key_height() const {
Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
-Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -571,7 +558,6 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
String anim = get_animation()->track_get_key_value(get_track(), p_index);
if (anim != "[stop]" && ap->has_animation(anim)) {
-
float len = ap->get_animation(anim)->get_length();
if (get_animation()->track_get_key_count(get_track()) > p_index + 1) {
@@ -587,11 +573,10 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) {
}
bool AnimationTrackEditSubAnim::is_key_selectable_by_distance() const {
-
return false;
}
-void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
+void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -609,7 +594,6 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
String anim = get_animation()->track_get_key_value(get_track(), p_index);
if (anim != "[stop]" && ap->has_animation(anim)) {
-
float len = ap->get_animation(anim)->get_length();
if (get_animation()->track_get_key_count(get_track()) > p_index + 1) {
@@ -621,17 +605,20 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
- if (pixel_end < p_clip_left)
+ if (pixel_end < p_clip_left) {
return;
+ }
- if (pixel_begin > p_clip_right)
+ if (pixel_begin > p_clip_right) {
return;
+ }
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
- if (to_x <= from_x)
+ if (to_x <= from_x) {
return;
+ }
Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 1.5;
@@ -651,18 +638,17 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
Ref<Animation> animation = ap->get_animation(anim);
for (int i = 0; i < animation->get_track_count(); i++) {
-
float h = (rect.size.height - 2) / animation->get_track_count();
int y = 2 + h * i + h / 2;
for (int j = 0; j < animation->track_get_key_count(i); j++) {
-
float ofs = animation->track_get_key_time(i, j);
int x = p_x + ofs * p_pixels_sec + 2;
- if (x < from_x || x >= (to_x - 4))
+ if (x < from_x || x >= (to_x - 4)) {
continue;
+ }
lines.push_back(Point2(x, y));
lines.push_back(Point2(x + 1, y));
@@ -701,20 +687,17 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
}
void AnimationTrackEditSubAnim::set_node(Object *p_object) {
-
id = p_object->get_instance_id();
}
//// VOLUME DB ////
int AnimationTrackEditVolumeDB::get_key_height() const {
-
Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
return volume_texture->get_height() * 1.2;
}
void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) {
-
Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
@@ -726,7 +709,6 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) {
}
void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) {
-
Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;
@@ -736,9 +718,9 @@ void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) {
}
void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
-
- if (p_x > p_clip_right || p_next_x < p_clip_left)
+ if (p_x > p_clip_right || p_next_x < p_clip_left) {
return;
+ }
float db = get_animation()->track_get_key_value(get_track(), p_index);
float db_n = get_animation()->track_get_key_value(get_track(), p_index + 1);
@@ -778,7 +760,6 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec,
/// AUDIO ///
void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) {
-
for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) {
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i);
if (stream.is_valid() && stream->get_instance_id() == p_which) {
@@ -789,12 +770,11 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) {
}
int AnimationTrackEditTypeAudio::get_key_height() const {
-
Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
-Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) {
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), p_index);
if (!stream.is_valid()) {
@@ -807,7 +787,6 @@ Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec)
float len = stream->get_length();
if (len == 0) {
-
Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream);
len = preview->get_length();
}
@@ -826,11 +805,10 @@ Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec)
}
bool AnimationTrackEditTypeAudio::is_key_selectable_by_distance() const {
-
return false;
}
-void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
+void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), p_index);
if (!stream.is_valid()) {
@@ -845,12 +823,14 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
float ofs_local = -len_resizing_rel / get_timeline()->get_zoom_scale();
if (len_resizing_start) {
start_ofs += ofs_local;
- if (start_ofs < 0)
+ if (start_ofs < 0) {
start_ofs = 0;
+ }
} else {
end_ofs += ofs_local;
- if (end_ofs < 0)
+ if (end_ofs < 0) {
end_ofs = 0;
+ }
}
}
@@ -881,11 +861,13 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
- if (pixel_end < p_clip_left)
+ if (pixel_end < p_clip_left) {
return;
+ }
- if (pixel_begin > p_clip_right)
+ if (pixel_begin > p_clip_right) {
return;
+ }
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
@@ -909,7 +891,6 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
preview_len = preview->get_length();
for (int i = from_x; i < to_x; i++) {
-
float ofs = (i - pixel_begin) * preview_len / pixel_total_len;
float ofs_n = ((i + 1) - pixel_begin) * preview_len / pixel_total_len;
ofs += start_ofs;
@@ -952,9 +933,7 @@ AnimationTrackEditTypeAudio::AnimationTrackEditTypeAudio() {
}
bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
if (p_point.x > get_timeline()->get_name_limit() && p_point.x < get_size().width - get_timeline()->get_buttons_width()) {
-
Dictionary drag_data = p_data;
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
Ref<AudioStream> res = drag_data["resource"];
@@ -964,7 +943,6 @@ bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Var
}
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
-
Vector<String> files = drag_data["files"];
if (files.size() == 1) {
@@ -979,16 +957,14 @@ bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Var
return AnimationTrackEdit::can_drop_data(p_point, p_data);
}
-void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant &p_data) {
+void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant &p_data) {
if (p_point.x > get_timeline()->get_name_limit() && p_point.x < get_size().width - get_timeline()->get_buttons_width()) {
-
Ref<AudioStream> stream;
Dictionary drag_data = p_data;
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
stream = drag_data["resource"];
} else if (drag_data.has("type") && String(drag_data["type"]) == "files") {
-
Vector<String> files = drag_data["files"];
if (files.size() == 1) {
@@ -998,7 +974,6 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant
}
if (stream.is_valid()) {
-
int x = p_point.x - get_timeline()->get_name_limit();
float ofs = x / get_timeline()->get_zoom_scale();
ofs += get_timeline()->get_value();
@@ -1023,12 +998,10 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant
}
void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseMotion> mm = p_event;
if (!len_resizing && mm.is_valid()) {
bool use_hsize_cursor = false;
for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) {
-
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i);
if (!stream.is_valid()) {
@@ -1086,7 +1059,6 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && get_default_cursor_shape() == CURSOR_HSIZE) {
-
len_resizing = true;
len_resizing_start = mb->get_shift();
len_resizing_from_px = mb->get_position().x;
@@ -1097,7 +1069,6 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) {
}
if (len_resizing && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
float ofs_local = -len_resizing_rel / get_timeline()->get_zoom_scale();
if (len_resizing_start) {
float prev_ofs = get_animation()->audio_track_get_key_start_offset(get_track(), len_resizing_index);
@@ -1128,7 +1099,6 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) {
/// SUB ANIMATION ///
int AnimationTrackEditTypeAnimation::get_key_height() const {
-
if (!ObjectDB::get_instance(id)) {
return AnimationTrackEdit::get_key_height();
}
@@ -1136,8 +1106,8 @@ int AnimationTrackEditTypeAnimation::get_key_height() const {
Ref<Font> font = get_theme_font("font", "Label");
return int(font->get_height() * 1.5);
}
-Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_sec) {
+Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_sec) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -1153,7 +1123,6 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_
String anim = get_animation()->animation_track_get_key_animation(get_track(), p_index);
if (anim != "[stop]" && ap->has_animation(anim)) {
-
float len = ap->get_animation(anim)->get_length();
if (get_animation()->track_get_key_count(get_track()) > p_index + 1) {
@@ -1169,11 +1138,10 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_
}
bool AnimationTrackEditTypeAnimation::is_key_selectable_by_distance() const {
-
return false;
}
-void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
+void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
Object *object = ObjectDB::get_instance(id);
if (!object) {
@@ -1191,7 +1159,6 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
String anim = get_animation()->animation_track_get_key_animation(get_track(), p_index);
if (anim != "[stop]" && ap->has_animation(anim)) {
-
float len = ap->get_animation(anim)->get_length();
if (get_animation()->track_get_key_count(get_track()) > p_index + 1) {
@@ -1203,17 +1170,20 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
- if (pixel_end < p_clip_left)
+ if (pixel_end < p_clip_left) {
return;
+ }
- if (pixel_begin > p_clip_right)
+ if (pixel_begin > p_clip_right) {
return;
+ }
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
- if (to_x <= from_x)
+ if (to_x <= from_x) {
return;
+ }
Ref<Font> font = get_theme_font("font", "Label");
int fh = font->get_height() * 1.5;
@@ -1233,18 +1203,17 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
Ref<Animation> animation = ap->get_animation(anim);
for (int i = 0; i < animation->get_track_count(); i++) {
-
float h = (rect.size.height - 2) / animation->get_track_count();
int y = 2 + h * i + h / 2;
for (int j = 0; j < animation->track_get_key_count(i); j++) {
-
float ofs = animation->track_get_key_time(i, j);
int x = p_x + ofs * p_pixels_sec + 2;
- if (x < from_x || x >= (to_x - 4))
+ if (x < from_x || x >= (to_x - 4)) {
continue;
+ }
lines.push_back(Point2(x, y));
lines.push_back(Point2(x + 1, y));
@@ -1283,7 +1252,6 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
}
void AnimationTrackEditTypeAnimation::set_node(Object *p_object) {
-
id = p_object->get_instance_id();
}
@@ -1292,23 +1260,19 @@ AnimationTrackEditTypeAnimation::AnimationTrackEditTypeAnimation() {
/////////
AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Object *p_object, Variant::Type p_type, const String &p_property, PropertyHint p_hint, const String &p_hint_string, int p_usage) {
-
if (p_property == "playing" && (p_object->is_class("AudioStreamPlayer") || p_object->is_class("AudioStreamPlayer2D") || p_object->is_class("AudioStreamPlayer3D"))) {
-
AnimationTrackEditAudio *audio = memnew(AnimationTrackEditAudio);
audio->set_node(p_object);
return audio;
}
if (p_property == "frame" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite2D") || p_object->is_class("AnimatedSprite3D"))) {
-
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_node(p_object);
return sprite;
}
if (p_property == "frame_coords" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D"))) {
-
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_as_coords();
sprite->set_node(p_object);
@@ -1316,14 +1280,12 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj
}
if (p_property == "current_animation" && (p_object->is_class("AnimationPlayer"))) {
-
AnimationTrackEditSubAnim *player = memnew(AnimationTrackEditSubAnim);
player->set_node(p_object);
return player;
}
if (p_property == "volume_db") {
-
AnimationTrackEditVolumeDB *vu = memnew(AnimationTrackEditVolumeDB);
return vu;
}
@@ -1339,12 +1301,10 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj
}
AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_audio_track_edit() {
-
return memnew(AnimationTrackEditTypeAudio);
}
AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_animation_track_edit(Object *p_object) {
-
AnimationTrackEditTypeAnimation *an = memnew(AnimationTrackEditTypeAnimation);
an->set_node(p_object);
return an;
diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp
index 9f6785ec06..20f947e707 100644
--- a/editor/array_property_edit.cpp
+++ b/editor/array_property_edit.cpp
@@ -36,10 +36,10 @@
#define ITEMS_PER_PAGE 100
Variant ArrayPropertyEdit::get_array() const {
-
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return Array();
+ }
Variant arr = o->get(property);
if (!arr.is_array()) {
Callable::CallError ce;
@@ -51,47 +51,45 @@ Variant ArrayPropertyEdit::get_array() const {
void ArrayPropertyEdit::_notif_change() {
_change_notify();
}
-void ArrayPropertyEdit::_notif_changev(const String &p_v) {
+void ArrayPropertyEdit::_notif_changev(const String &p_v) {
_change_notify(p_v.utf8().get_data());
}
void ArrayPropertyEdit::_set_size(int p_size) {
-
Variant arr = get_array();
arr.call("resize", p_size);
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return;
+ }
o->set(property, arr);
}
void ArrayPropertyEdit::_set_value(int p_idx, const Variant &p_value) {
-
Variant arr = get_array();
arr.set(p_idx, p_value);
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return;
+ }
o->set(property, arr);
}
bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
-
String pn = p_name;
if (pn.begins_with("array/")) {
-
if (pn == "array/size") {
-
Variant arr = get_array();
int size = arr.call("size");
int newsize = p_value;
- if (newsize == size)
+ if (newsize == size) {
return true;
+ }
UndoRedo *ur = EditorNode::get_undo_redo();
ur->create_action(TTR("Resize Array"));
@@ -102,7 +100,6 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
ur->add_undo_method(this, "_set_value", i, arr.get(i));
}
} else if (newsize > size) {
-
Variant init;
Callable::CallError ce;
Variant::Type new_type = subtype;
@@ -128,7 +125,6 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
}
} else if (pn.begins_with("indices")) {
-
if (pn.find("_") != -1) {
//type
int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int();
@@ -173,13 +169,11 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
}
bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const {
-
Variant arr = get_array();
//int size = arr.call("size");
String pn = p_name;
if (pn.begins_with("array/")) {
-
if (pn == "array/size") {
r_ret = arr.call("size");
return true;
@@ -189,14 +183,14 @@ bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
} else if (pn.begins_with("indices")) {
-
if (pn.find("_") != -1) {
//type
int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int();
bool valid;
r_ret = arr.get(idx, &valid);
- if (valid)
+ if (valid) {
r_ret = r_ret.get_type();
+ }
return valid;
} else {
@@ -216,21 +210,20 @@ bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const {
}
void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const {
-
Variant arr = get_array();
int size = arr.call("size");
p_list->push_back(PropertyInfo(Variant::INT, "array/size", PROPERTY_HINT_RANGE, "0,100000,1"));
int pages = size / ITEMS_PER_PAGE;
- if (pages > 0)
+ if (pages > 0) {
p_list->push_back(PropertyInfo(Variant::INT, "array/page", PROPERTY_HINT_RANGE, "0," + itos(pages) + ",1"));
+ }
int offset = page * ITEMS_PER_PAGE;
int items = MIN(size - offset, ITEMS_PER_PAGE);
for (int i = 0; i < items; i++) {
-
Variant v = arr.get(i + offset);
bool is_typed = arr.get_type() != Variant::ARRAY || subtype != Variant::NIL;
@@ -260,7 +253,6 @@ void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const {
}
void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const String &p_hint_string, Variant::Type p_deftype) {
-
page = 0;
property = p_prop;
obj = p_obj->get_instance_id();
@@ -284,7 +276,6 @@ void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const Stri
}
Node *ArrayPropertyEdit::get_node() {
-
return Object::cast_to<Node>(ObjectDB::get_instance(obj));
}
@@ -293,7 +284,6 @@ bool ArrayPropertyEdit::_dont_undo_redo() {
}
void ArrayPropertyEdit::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_size"), &ArrayPropertyEdit::_set_size);
ClassDB::bind_method(D_METHOD("_set_value"), &ArrayPropertyEdit::_set_value);
ClassDB::bind_method(D_METHOD("_notif_change"), &ArrayPropertyEdit::_notif_change);
@@ -304,9 +294,9 @@ void ArrayPropertyEdit::_bind_methods() {
ArrayPropertyEdit::ArrayPropertyEdit() {
page = 0;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
-
- if (i > 0)
+ if (i > 0) {
vtypes += ",";
+ }
vtypes += Variant::get_type_name(Variant::Type(i));
}
default_type = Variant::NIL;
diff --git a/editor/array_property_edit.h b/editor/array_property_edit.h
index 675b842128..d91701ccaf 100644
--- a/editor/array_property_edit.h
+++ b/editor/array_property_edit.h
@@ -34,7 +34,6 @@
#include "scene/main/node.h"
class ArrayPropertyEdit : public Reference {
-
GDCLASS(ArrayPropertyEdit, Reference);
int page;
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp
index fe28c913a7..9e4e157c96 100644
--- a/editor/audio_stream_preview.cpp
+++ b/editor/audio_stream_preview.cpp
@@ -35,10 +35,11 @@
float AudioStreamPreview::get_length() const {
return length;
}
-float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
- if (length == 0)
+float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
+ if (length == 0) {
return 0;
+ }
int max = preview.size() / 2;
int time_from = p_time / length * max;
@@ -53,7 +54,6 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
uint8_t vmax = 0;
for (int i = time_from; i < time_to; i++) {
-
uint8_t v = preview[i * 2 + 1];
if (i == 0 || v > vmax) {
vmax = v;
@@ -62,10 +62,11 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
return (vmax / 255.0) * 2.0 - 1.0;
}
-float AudioStreamPreview::get_min(float p_time, float p_time_next) const {
- if (length == 0)
+float AudioStreamPreview::get_min(float p_time, float p_time_next) const {
+ if (length == 0) {
return 0;
+ }
int max = preview.size() / 2;
int time_from = p_time / length * max;
@@ -80,7 +81,6 @@ float AudioStreamPreview::get_min(float p_time, float p_time_next) const {
uint8_t vmin = 255;
for (int i = time_from; i < time_to; i++) {
-
uint8_t v = preview[i * 2];
if (i == 0 || v < vmin) {
vmin = v;
@@ -101,7 +101,6 @@ void AudioStreamPreviewGenerator::_update_emit(ObjectID p_id) {
}
void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) {
-
Preview *preview = (Preview *)p_preview;
float muxbuff_chunk_s = 0.25;
@@ -117,7 +116,6 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) {
preview->playback->start();
while (frames_todo) {
-
int ofs_write = uint64_t(frames_total - frames_todo) * uint64_t(preview->preview->preview.size() / 2) / uint64_t(frames_total);
int to_read = MIN(frames_todo, mixbuff_chunk_frames);
int to_write = uint64_t(to_read) * uint64_t(preview->preview->preview.size() / 2) / uint64_t(frames_total);
@@ -137,7 +135,6 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) {
}
for (int j = from; j < to; j++) {
-
max = MAX(max, mix_chunk[j].l);
max = MAX(max, mix_chunk[j].r);
@@ -199,8 +196,9 @@ Ref<AudioStreamPreview> AudioStreamPreviewGenerator::generate_preview(const Ref<
preview->preview->preview = maxmin;
preview->preview->length = len_s;
- if (preview->playback.is_valid())
+ if (preview->playback.is_valid()) {
preview->thread = Thread::create(_preview_thread, preview);
+ }
return preview->preview;
}
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 76716f01b7..95c7cc0bf1 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -41,7 +41,6 @@
#include "scene/resources/dynamic_font.h"
void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
-
text_editor = p_edit;
line->set_text(itos(text_editor->cursor_get_line()));
@@ -51,21 +50,19 @@ void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
}
int GotoLineDialog::get_line() const {
-
return line->get_text().to_int();
}
void GotoLineDialog::ok_pressed() {
-
- if (get_line() < 1 || get_line() > text_editor->get_line_count())
+ if (get_line() < 1 || get_line() > text_editor->get_line_count()) {
return;
+ }
text_editor->unfold_line(get_line() - 1);
text_editor->cursor_set_line(get_line() - 1);
hide();
}
GotoLineDialog::GotoLineDialog() {
-
set_title(TTR("Go to Line"));
VBoxContainer *vbc = memnew(VBoxContainer);
@@ -88,9 +85,7 @@ GotoLineDialog::GotoLineDialog() {
}
void FindReplaceBar::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
-
find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
@@ -98,10 +93,8 @@ void FindReplaceBar::_notification(int p_what) {
hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons"));
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
set_process_unhandled_input(is_visible_in_tree());
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
-
find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
@@ -114,22 +107,16 @@ void FindReplaceBar::_notification(int p_what) {
}
void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
-
if (k->is_pressed() && (text_edit->has_focus() || vbc_lineedit->is_a_parent_of(get_focus_owner()))) {
-
bool accepted = true;
switch (k->get_keycode()) {
-
case KEY_ESCAPE: {
-
_hide_bar();
} break;
default: {
-
accepted = false;
} break;
}
@@ -142,7 +129,6 @@ void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) {
}
bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) {
-
int line, col;
String text = get_search_text();
@@ -180,7 +166,6 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
}
void FindReplaceBar::_replace() {
-
if (result_line != -1 && result_col != -1) {
text_edit->begin_complex_operation();
@@ -199,7 +184,6 @@ void FindReplaceBar::_replace() {
}
void FindReplaceBar::_replace_all() {
-
text_edit->disconnect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
// Line as x so it gets priority in comparison, column as y.
Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column());
@@ -289,7 +273,6 @@ void FindReplaceBar::_replace_all() {
}
void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
-
r_line = text_edit->cursor_get_line();
r_col = text_edit->cursor_get_column();
@@ -303,14 +286,16 @@ void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
}
void FindReplaceBar::_update_results_count() {
- if (results_count != -1)
+ if (results_count != -1) {
return;
+ }
results_count = 0;
String searched = get_search_text();
- if (searched.empty())
+ if (searched.empty()) {
return;
+ }
String full_text = text_edit->get_text();
@@ -318,24 +303,27 @@ void FindReplaceBar::_update_results_count() {
while (true) {
int pos = is_case_sensitive() ? full_text.find(searched, from_pos) : full_text.findn(searched, from_pos);
- if (pos == -1)
+ if (pos == -1) {
break;
+ }
+ int pos_subsequent = pos + searched.length();
if (is_whole_words()) {
- from_pos++; // Making sure we won't hit the same match next time, if we get out via a continue.
- if (pos > 0 && !is_symbol(full_text[pos - 1]))
+ from_pos = pos + 1; // Making sure we won't hit the same match next time, if we get out via a continue.
+ if (pos > 0 && !(is_symbol(full_text[pos - 1]) || full_text[pos - 1] == '\n')) {
continue;
- if (pos + searched.length() < full_text.length() && !is_symbol(full_text[pos + searched.length()]))
+ }
+ if (pos_subsequent < full_text.length() && !(is_symbol(full_text[pos_subsequent]) || full_text[pos_subsequent] == '\n')) {
continue;
+ }
}
results_count++;
- from_pos = pos + searched.length();
+ from_pos = pos_subsequent;
}
}
void FindReplaceBar::_update_matches_label() {
-
if (search_text->get_text().empty() || results_count == -1) {
matches_label->hide();
} else {
@@ -347,13 +335,14 @@ void FindReplaceBar::_update_matches_label() {
}
bool FindReplaceBar::search_current() {
-
uint32_t flags = 0;
- if (is_whole_words())
+ if (is_whole_words()) {
flags |= TextEdit::SEARCH_WHOLE_WORDS;
- if (is_case_sensitive())
+ }
+ if (is_case_sensitive()) {
flags |= TextEdit::SEARCH_MATCH_CASE;
+ }
int line, col;
_get_search_from(line, col);
@@ -362,30 +351,34 @@ bool FindReplaceBar::search_current() {
}
bool FindReplaceBar::search_prev() {
-
- if (!is_visible())
+ if (!is_visible()) {
popup_search(true);
+ }
uint32_t flags = 0;
String text = get_search_text();
- if (is_whole_words())
+ if (is_whole_words()) {
flags |= TextEdit::SEARCH_WHOLE_WORDS;
- if (is_case_sensitive())
+ }
+ if (is_case_sensitive()) {
flags |= TextEdit::SEARCH_MATCH_CASE;
+ }
flags |= TextEdit::SEARCH_BACKWARDS;
int line, col;
_get_search_from(line, col);
- if (text_edit->is_selection_active())
+ if (text_edit->is_selection_active()) {
col--; // Skip currently selected word.
+ }
col -= text.length();
if (col < 0) {
line -= 1;
- if (line < 0)
+ if (line < 0) {
line = text_edit->get_line_count() - 1;
+ }
col = text_edit->get_line(line).length();
}
@@ -393,21 +386,24 @@ bool FindReplaceBar::search_prev() {
}
bool FindReplaceBar::search_next() {
-
- if (!is_visible())
+ if (!is_visible()) {
popup_search(true);
+ }
uint32_t flags = 0;
String text;
- if (replace_all_mode)
+ if (replace_all_mode) {
text = get_replace_text();
- else
+ } else {
text = get_search_text();
+ }
- if (is_whole_words())
+ if (is_whole_words()) {
flags |= TextEdit::SEARCH_WHOLE_WORDS;
- if (is_case_sensitive())
+ }
+ if (is_case_sensitive()) {
flags |= TextEdit::SEARCH_MATCH_CASE;
+ }
int line, col;
_get_search_from(line, col);
@@ -416,8 +412,9 @@ bool FindReplaceBar::search_next() {
col += text.length();
if (col > text_edit->get_line(line).length()) {
line += 1;
- if (line >= text_edit->get_line_count())
+ if (line >= text_edit->get_line_count()) {
line = 0;
+ }
col = 0;
}
}
@@ -426,9 +423,9 @@ bool FindReplaceBar::search_next() {
}
void FindReplaceBar::_hide_bar() {
-
- if (replace_text->has_focus() || search_text->has_focus())
+ if (replace_text->has_focus() || search_text->has_focus()) {
text_edit->grab_focus();
+ }
text_edit->set_search_text("");
result_line = -1;
@@ -437,10 +434,10 @@ void FindReplaceBar::_hide_bar() {
}
void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
-
show();
- if (p_show_only)
+ if (p_show_only) {
return;
+ }
if (p_focus_replace) {
search_text->deselect();
@@ -470,7 +467,6 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
}
void FindReplaceBar::popup_search(bool p_show_only) {
-
replace_text->hide();
hbc_button_replace->hide();
hbc_option_replace->hide();
@@ -479,7 +475,6 @@ void FindReplaceBar::popup_search(bool p_show_only) {
}
void FindReplaceBar::popup_replace() {
-
if (!replace_text->is_visible_in_tree()) {
replace_text->show();
hbc_button_replace->show();
@@ -492,13 +487,11 @@ void FindReplaceBar::popup_replace() {
}
void FindReplaceBar::_search_options_changed(bool p_pressed) {
-
results_count = -1;
search_current();
}
void FindReplaceBar::_editor_text_changed() {
-
results_count = -1;
if (is_visible_in_tree()) {
preserve_cursor = true;
@@ -508,13 +501,11 @@ void FindReplaceBar::_editor_text_changed() {
}
void FindReplaceBar::_search_text_changed(const String &p_text) {
-
results_count = -1;
search_current();
}
void FindReplaceBar::_search_text_entered(const String &p_text) {
-
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
search_prev();
} else {
@@ -523,7 +514,6 @@ void FindReplaceBar::_search_text_entered(const String &p_text) {
}
void FindReplaceBar::_replace_text_entered(const String &p_text) {
-
if (selection_only->is_pressed() && text_edit->is_selection_active()) {
_replace_all();
_hide_bar();
@@ -536,44 +526,36 @@ void FindReplaceBar::_replace_text_entered(const String &p_text) {
}
String FindReplaceBar::get_search_text() const {
-
return search_text->get_text();
}
String FindReplaceBar::get_replace_text() const {
-
return replace_text->get_text();
}
bool FindReplaceBar::is_case_sensitive() const {
-
return case_sensitive->is_pressed();
}
bool FindReplaceBar::is_whole_words() const {
-
return whole_words->is_pressed();
}
bool FindReplaceBar::is_selection_only() const {
-
return selection_only->is_pressed();
}
void FindReplaceBar::set_error(const String &p_label) {
-
emit_signal("error", p_label);
}
void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) {
-
results_count = -1;
text_edit = p_text_edit;
text_edit->connect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
}
void FindReplaceBar::_bind_methods() {
-
ClassDB::bind_method("_unhandled_input", &FindReplaceBar::_unhandled_input);
ClassDB::bind_method("_search_current", &FindReplaceBar::search_current);
@@ -583,7 +565,6 @@ void FindReplaceBar::_bind_methods() {
}
FindReplaceBar::FindReplaceBar() {
-
results_count = -1;
replace_all_mode = false;
preserve_cursor = false;
@@ -676,10 +657,10 @@ FindReplaceBar::FindReplaceBar() {
// This function should be used to handle shortcuts that could otherwise
// be handled too late if they weren't handled here.
void CodeTextEditor::_input(const Ref<InputEvent> &event) {
-
const Ref<InputEventKey> key_event = event;
- if (!key_event.is_valid() || !key_event->is_pressed())
+ if (!key_event.is_valid() || !key_event->is_pressed() || !text_editor->has_focus()) {
return;
+ }
if (ED_IS_SHORTCUT("script_text_editor/move_up", key_event)) {
move_lines_up();
@@ -704,13 +685,10 @@ void CodeTextEditor::_input(const Ref<InputEvent> &event) {
}
void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->is_pressed() && mb->get_command()) {
-
if (mb->get_button_index() == BUTTON_WHEEL_UP) {
_zoom_in();
} else if (mb->get_button_index() == BUTTON_WHEEL_DOWN) {
@@ -721,7 +699,6 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
-
Ref<DynamicFont> font = text_editor->get_theme_font("font");
if (font.is_valid()) {
@@ -739,7 +716,6 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
-
if (k->is_pressed()) {
if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) {
_zoom_in();
@@ -765,8 +741,9 @@ void CodeTextEditor::_zoom_out() {
}
void CodeTextEditor::_zoom_changed() {
- if (font_resize_timer->get_time_left() == 0)
+ if (font_resize_timer->get_time_left() == 0) {
font_resize_timer->start();
+ }
}
void CodeTextEditor::_reset_zoom() {
@@ -779,7 +756,6 @@ void CodeTextEditor::_reset_zoom() {
}
void CodeTextEditor::_line_col_changed() {
-
String line = text_editor->get_line(text_editor->cursor_get_line());
int positional_column = 0;
@@ -802,7 +778,6 @@ void CodeTextEditor::_line_col_changed() {
}
void CodeTextEditor::_text_changed() {
-
if (text_editor->is_insert_text_operation()) {
code_complete_timer->start();
}
@@ -811,13 +786,13 @@ void CodeTextEditor::_text_changed() {
}
void CodeTextEditor::_code_complete_timer_timeout() {
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
text_editor->query_code_comple();
}
void CodeTextEditor::_complete_request() {
-
List<ScriptCodeCompletionOption> entries;
String ctext = text_editor->get_text_for_completion();
_code_complete_script(ctext, &entries);
@@ -825,8 +800,9 @@ void CodeTextEditor::_complete_request() {
if (code_complete_func) {
code_complete_func(code_complete_ud, ctext, &entries, forced);
}
- if (entries.size() == 0)
+ if (entries.size() == 0) {
return;
+ }
for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) {
E->get().icon = _get_completion_icon(E->get());
@@ -879,14 +855,12 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp
}
void CodeTextEditor::_font_resize_timeout() {
-
if (_add_font_size(font_resize_val)) {
font_resize_val = 0;
}
}
bool CodeTextEditor::_add_font_size(int p_delta) {
-
Ref<DynamicFont> font = text_editor->get_theme_font("font");
if (font.is_valid()) {
@@ -904,7 +878,6 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
}
void CodeTextEditor::update_editor_settings() {
-
text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
@@ -940,7 +913,6 @@ void CodeTextEditor::trim_trailing_whitespace() {
for (int i = 0; i < text_editor->get_line_count(); i++) {
String line = text_editor->get_line(i);
if (line.ends_with(" ") || line.ends_with("\t")) {
-
if (!trimed_whitespace) {
text_editor->begin_complex_operation();
trimed_whitespace = true;
@@ -1088,10 +1060,12 @@ void CodeTextEditor::convert_case(CaseStyle p_case) {
for (int i = begin; i <= end; i++) {
int len = text_editor->get_line(i).length();
- if (i == end)
+ if (i == end) {
len = end_col;
- if (i == begin)
+ }
+ if (i == begin) {
len -= begin_col;
+ }
String new_line = text_editor->get_line(i).substr(i == begin ? begin_col : 0, len);
switch (p_case) {
@@ -1129,8 +1103,9 @@ void CodeTextEditor::move_lines_up() {
int line_id = i;
int next_id = i - 1;
- if (line_id == 0 || next_id < 0)
+ if (line_id == 0 || next_id < 0) {
return;
+ }
text_editor->unfold_line(line_id);
text_editor->unfold_line(next_id);
@@ -1145,8 +1120,9 @@ void CodeTextEditor::move_lines_up() {
int line_id = text_editor->cursor_get_line();
int next_id = line_id - 1;
- if (line_id == 0 || next_id < 0)
+ if (line_id == 0 || next_id < 0) {
return;
+ }
text_editor->unfold_line(line_id);
text_editor->unfold_line(next_id);
@@ -1170,8 +1146,9 @@ void CodeTextEditor::move_lines_down() {
int line_id = i;
int next_id = i + 1;
- if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count())
+ if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
return;
+ }
text_editor->unfold_line(line_id);
text_editor->unfold_line(next_id);
@@ -1186,8 +1163,9 @@ void CodeTextEditor::move_lines_down() {
int line_id = text_editor->cursor_get_line();
int next_id = line_id + 1;
- if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count())
+ if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
return;
+ }
text_editor->unfold_line(line_id);
text_editor->unfold_line(next_id);
@@ -1281,8 +1259,9 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
int end = text_editor->get_selection_to_line();
// End of selection ends on the first column of the last line, ignore it.
- if (text_editor->get_selection_to_column() == 0)
+ if (text_editor->get_selection_to_column() == 0) {
end -= 1;
+ }
int col_to = text_editor->get_selection_to_column();
int cursor_pos = text_editor->cursor_get_column();
@@ -1314,14 +1293,17 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
int offset = (is_commented ? -1 : 1) * delimiter.length();
int col_from = text_editor->get_selection_from_column() > 0 ? text_editor->get_selection_from_column() + offset : 0;
- if (is_commented && text_editor->cursor_get_column() == text_editor->get_line(text_editor->cursor_get_line()).length() + 1)
+ if (is_commented && text_editor->cursor_get_column() == text_editor->get_line(text_editor->cursor_get_line()).length() + 1) {
cursor_pos += 1;
+ }
- if (text_editor->get_selection_to_column() != 0 && col_to != text_editor->get_line(text_editor->get_selection_to_line()).length() + 1)
+ if (text_editor->get_selection_to_column() != 0 && col_to != text_editor->get_line(text_editor->get_selection_to_line()).length() + 1) {
col_to += offset;
+ }
- if (text_editor->cursor_get_column() != 0)
+ if (text_editor->cursor_get_column() != 0) {
cursor_pos += offset;
+ }
text_editor->select(begin, col_from, text_editor->get_selection_to_line(), col_to);
text_editor->cursor_set_column(cursor_pos);
@@ -1440,7 +1422,6 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
}
void CodeTextEditor::set_error(const String &p_error) {
-
error->set_text(p_error);
if (p_error != "") {
error->set_default_cursor_shape(CURSOR_POINTING_HAND);
@@ -1463,7 +1444,6 @@ void CodeTextEditor::goto_error() {
}
void CodeTextEditor::_update_font() {
-
text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts"));
@@ -1474,13 +1454,13 @@ void CodeTextEditor::_update_font() {
int count = status_bar->get_child_count();
for (int i = 0; i < count; i++) {
Control *n = Object::cast_to<Control>(status_bar->get_child(i));
- if (n)
+ if (n) {
n->add_theme_font_override("font", status_bar_font);
+ }
}
}
void CodeTextEditor::_on_settings_change() {
-
_update_font();
font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size");
@@ -1537,7 +1517,6 @@ void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
}
void CodeTextEditor::_notification(int p_what) {
-
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_load_theme_settings();
@@ -1568,18 +1547,17 @@ void CodeTextEditor::set_warning_nb(int p_warning_nb) {
warning_count_label->set_text(itos(p_warning_nb));
warning_count_label->set_visible(p_warning_nb > 0);
warning_button->set_visible(p_warning_nb > 0);
- if (!p_warning_nb)
+ if (!p_warning_nb) {
_set_show_warnings_panel(false);
+ }
}
void CodeTextEditor::toggle_bookmark() {
-
int line = text_editor->cursor_get_line();
text_editor->set_line_as_bookmark(line, !text_editor->is_line_set_as_bookmark(line));
}
void CodeTextEditor::goto_next_bookmark() {
-
List<int> bmarks;
text_editor->get_bookmarks(&bmarks);
if (bmarks.size() <= 0) {
@@ -1605,7 +1583,6 @@ void CodeTextEditor::goto_next_bookmark() {
}
void CodeTextEditor::goto_prev_bookmark() {
-
List<int> bmarks;
text_editor->get_bookmarks(&bmarks);
if (bmarks.size() <= 0) {
@@ -1631,7 +1608,6 @@ void CodeTextEditor::goto_prev_bookmark() {
}
void CodeTextEditor::remove_all_bookmarks() {
-
List<int> bmarks;
text_editor->get_bookmarks(&bmarks);
@@ -1641,7 +1617,6 @@ void CodeTextEditor::remove_all_bookmarks() {
}
void CodeTextEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_input"), &CodeTextEditor::_input);
ADD_SIGNAL(MethodInfo("validate_script"));
@@ -1665,7 +1640,6 @@ void CodeTextEditor::update_toggle_scripts_button() {
}
CodeTextEditor::CodeTextEditor() {
-
code_complete_func = nullptr;
ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL);
ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS);
diff --git a/editor/code_editor.h b/editor/code_editor.h
index 6b733a2b3c..d806be885f 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -41,7 +41,6 @@
#include "scene/main/timer.h"
class GotoLineDialog : public ConfirmationDialog {
-
GDCLASS(GotoLineDialog, ConfirmationDialog);
Label *line_label;
@@ -60,7 +59,6 @@ public:
};
class FindReplaceBar : public HBoxContainer {
-
GDCLASS(FindReplaceBar, HBoxContainer);
LineEdit *search_text;
@@ -138,7 +136,6 @@ public:
typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_forced);
class CodeTextEditor : public VBoxContainer {
-
GDCLASS(CodeTextEditor, VBoxContainer);
TextEdit *text_editor;
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 4556a6e827..6507956d07 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -47,7 +47,6 @@ static Node *_find_first_script(Node *p_root, Node *p_node) {
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *ret = _find_first_script(p_root, p_node->get_child(i));
if (ret) {
return ret;
@@ -58,49 +57,46 @@ static Node *_find_first_script(Node *p_root, Node *p_node) {
}
class ConnectDialogBinds : public Object {
-
GDCLASS(ConnectDialogBinds, Object);
public:
Vector<Variant> params;
bool _set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name.begins_with("bind/")) {
int which = name.get_slice("/", 1).to_int() - 1;
ERR_FAIL_INDEX_V(which, params.size(), false);
params.write[which] = p_value;
- } else
+ } else {
return false;
+ }
return true;
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name.begins_with("bind/")) {
int which = name.get_slice("/", 1).to_int() - 1;
ERR_FAIL_INDEX_V(which, params.size(), false);
r_ret = params[which];
- } else
+ } else {
return false;
+ }
return true;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
for (int i = 0; i < params.size(); i++) {
p_list->push_back(PropertyInfo(params[i].get_type(), "bind/" + itos(i + 1)));
}
}
void notify_changed() {
-
_change_notify();
}
@@ -112,7 +108,6 @@ public:
* Signal automatically called by parent dialog.
*/
void ConnectDialog::ok_pressed() {
-
if (dst_method->get_text() == "") {
error->set_text(TTR("Method in target node must be specified."));
error->popup_centered();
@@ -149,11 +144,11 @@ void ConnectDialog::_text_entered(const String &p_text) {
* Called each time a target node is selected within the target node tree.
*/
void ConnectDialog::_tree_node_selected() {
-
Node *current = tree->get_selected();
- if (!current)
+ if (!current) {
return;
+ }
dst_path = source->get_path_to(current);
_update_ok_enabled();
@@ -163,9 +158,9 @@ void ConnectDialog::_tree_node_selected() {
* Adds a new parameter bind to connection.
*/
void ConnectDialog::_add_bind() {
-
- if (cdbinds->params.size() >= VARIANT_ARG_MAX)
+ if (cdbinds->params.size() >= VARIANT_ARG_MAX) {
return;
+ }
Variant::Type vt = (Variant::Type)type_list->get_item_id(type_list->get_selected());
Variant value;
@@ -228,10 +223,10 @@ void ConnectDialog::_add_bind() {
* Remove parameter bind from connection.
*/
void ConnectDialog::_remove_bind() {
-
String st = bind_editor->get_selected_path();
- if (st == "")
+ if (st == "") {
return;
+ }
int idx = st.get_slice("/", 1).to_int() - 1;
ERR_FAIL_INDEX(idx, cdbinds->params.size());
@@ -244,7 +239,6 @@ void ConnectDialog::_remove_bind() {
* node is selected and valid in the selected mode.
*/
void ConnectDialog::_update_ok_enabled() {
-
Node *target = tree->get_selected();
if (target == nullptr) {
@@ -261,14 +255,12 @@ void ConnectDialog::_update_ok_enabled() {
}
void ConnectDialog::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
bind_editor->edit(cdbinds);
}
}
void ConnectDialog::_bind_methods() {
-
ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed);
ClassDB::bind_method("_update_ok_enabled", &ConnectDialog::_update_ok_enabled);
@@ -276,50 +268,42 @@ void ConnectDialog::_bind_methods() {
}
Node *ConnectDialog::get_source() const {
-
return source;
}
StringName ConnectDialog::get_signal_name() const {
-
return signal;
}
NodePath ConnectDialog::get_dst_path() const {
-
return dst_path;
}
void ConnectDialog::set_dst_node(Node *p_node) {
-
tree->set_selected(p_node);
}
StringName ConnectDialog::get_dst_method_name() const {
-
String txt = dst_method->get_text();
- if (txt.find("(") != -1)
+ if (txt.find("(") != -1) {
txt = txt.left(txt.find("(")).strip_edges();
+ }
return txt;
}
void ConnectDialog::set_dst_method(const StringName &p_method) {
-
dst_method->set_text(p_method);
}
Vector<Variant> ConnectDialog::get_binds() const {
-
return cdbinds->params;
}
bool ConnectDialog::get_deferred() const {
-
return deferred->is_pressed();
}
bool ConnectDialog::get_oneshot() const {
-
return oneshot->is_pressed();
}
@@ -327,7 +311,6 @@ bool ConnectDialog::get_oneshot() const {
* Returns true if ConnectDialog is being used to edit an existing connection.
*/
bool ConnectDialog::is_editing() const {
-
return bEditMode;
}
@@ -337,7 +320,6 @@ bool ConnectDialog::is_editing() const {
* If editing an existing connection, previous data is retained.
*/
void ConnectDialog::init(ConnectionData c, bool bEdit) {
-
set_hide_on_ok(false);
source = static_cast<Node *>(c.source);
@@ -367,17 +349,16 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) {
}
void ConnectDialog::popup_dialog(const String &p_for_signal) {
-
from_signal->set_text(p_for_signal);
error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor"));
- if (!advanced->is_pressed())
+ if (!advanced->is_pressed()) {
error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root()));
+ }
popup_centered();
}
void ConnectDialog::_advanced_pressed() {
-
if (advanced->is_pressed()) {
set_min_size(Size2(900, 500) * EDSCALE);
connect_to_label->set_text(TTR("Connect to Node:"));
@@ -401,7 +382,6 @@ void ConnectDialog::_advanced_pressed() {
}
ConnectDialog::ConnectDialog() {
-
set_min_size(Size2(600, 500) * EDSCALE);
VBoxContainer *vbc = memnew(VBoxContainer);
@@ -515,7 +495,6 @@ ConnectDialog::ConnectDialog() {
}
ConnectDialog::~ConnectDialog() {
-
memdelete(cdbinds);
}
@@ -523,7 +502,6 @@ ConnectDialog::~ConnectDialog() {
// Originally copied and adapted from EditorProperty, try to keep style in sync.
Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
-
EditorHelpBit *help_bit = memnew(EditorHelpBit);
help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
@@ -536,7 +514,6 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
}
struct _ConnectionsDockMethodInfoSort {
-
_FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const {
return a.name < b.name;
}
@@ -547,7 +524,6 @@ struct _ConnectionsDockMethodInfoSort {
* Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed.
*/
void ConnectionsDock::_make_or_edit_connection() {
-
TreeItem *it = tree->get_selected();
ERR_FAIL_COND(!it);
@@ -616,12 +592,12 @@ void ConnectionsDock::_make_or_edit_connection() {
* Creates single connection w/ undo-redo functionality.
*/
void ConnectionsDock::_connect(ConnectDialog::ConnectionData cToMake) {
-
Node *source = static_cast<Node *>(cToMake.source);
Node *target = static_cast<Node *>(cToMake.target);
- if (!source || !target)
+ if (!source || !target) {
return;
+ }
undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), String(cToMake.signal), String(cToMake.method)));
@@ -641,7 +617,6 @@ void ConnectionsDock::_connect(ConnectDialog::ConnectionData cToMake) {
* Break single connection w/ undo-redo functionality.
*/
void ConnectionsDock::_disconnect(TreeItem &item) {
-
Connection cd = item.get_metadata(0);
ConnectDialog::ConnectionData c = cd;
@@ -664,11 +639,11 @@ void ConnectionsDock::_disconnect(TreeItem &item) {
* Can undo-redo as a single action.
*/
void ConnectionsDock::_disconnect_all() {
-
TreeItem *item = tree->get_selected();
- if (!_is_item_signal(*item))
+ if (!_is_item_signal(*item)) {
return;
+ }
TreeItem *child = item->get_children();
String signalName = item->get_metadata(0).operator Dictionary()["name"];
@@ -691,7 +666,6 @@ void ConnectionsDock::_disconnect_all() {
}
void ConnectionsDock::_tree_item_selected() {
-
TreeItem *item = tree->get_selected();
if (!item) { // Unlikely. Disable button just in case.
connect_button->set_text(TTR("Connect..."));
@@ -709,8 +683,9 @@ void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click.
TreeItem *item = tree->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
if (_is_item_signal(*item)) {
_open_connection_dialog(*item);
@@ -720,7 +695,6 @@ void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click.
}
bool ConnectionsDock::_is_item_signal(TreeItem &item) {
-
return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root());
}
@@ -728,7 +702,6 @@ bool ConnectionsDock::_is_item_signal(TreeItem &item) {
* Open connection dialog with TreeItem data to CREATE a brand-new connection.
*/
void ConnectionsDock::_open_connection_dialog(TreeItem &item) {
-
String signal = item.get_metadata(0).operator Dictionary()["name"];
const String &signalname = signal;
String midname = selectedNode->get_name();
@@ -769,7 +742,6 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &item) {
* Open connection dialog with Connection data to EDIT an existing connection.
*/
void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToEdit) {
-
Node *src = static_cast<Node *>(cToEdit.source);
Node *dst = static_cast<Node *>(cToEdit.target);
@@ -784,21 +756,23 @@ void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToE
* Open slot method location in script editor.
*/
void ConnectionsDock::_go_to_script(TreeItem &item) {
-
- if (_is_item_signal(item))
+ if (_is_item_signal(item)) {
return;
+ }
Connection cd = item.get_metadata(0);
ConnectDialog::ConnectionData c = cd;
ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck
- if (!c.target)
+ if (!c.target) {
return;
+ }
Ref<Script> script = c.target->get_script();
- if (script.is_null())
+ if (script.is_null()) {
return;
+ }
if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) {
editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
@@ -806,11 +780,11 @@ void ConnectionsDock::_go_to_script(TreeItem &item) {
}
void ConnectionsDock::_handle_signal_menu_option(int option) {
-
TreeItem *item = tree->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
switch (option) {
case CONNECT: {
@@ -825,11 +799,11 @@ void ConnectionsDock::_handle_signal_menu_option(int option) {
}
void ConnectionsDock::_handle_slot_menu_option(int option) {
-
TreeItem *item = tree->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
switch (option) {
case EDIT: {
@@ -847,11 +821,11 @@ void ConnectionsDock::_handle_slot_menu_option(int option) {
}
void ConnectionsDock::_rmb_pressed(Vector2 position) {
-
TreeItem *item = tree->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
Vector2 global_position = tree->get_global_position() + position;
@@ -865,12 +839,10 @@ void ConnectionsDock::_rmb_pressed(Vector2 position) {
}
void ConnectionsDock::_close() {
-
hide();
}
void ConnectionsDock::_connect_pressed() {
-
TreeItem *item = tree->get_selected();
if (!item) {
connect_button->set_disabled(true);
@@ -886,29 +858,26 @@ void ConnectionsDock::_connect_pressed() {
}
void ConnectionsDock::_notification(int p_what) {
-
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
update_tree();
}
}
void ConnectionsDock::_bind_methods() {
-
ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree);
}
void ConnectionsDock::set_node(Node *p_node) {
-
selectedNode = p_node;
update_tree();
}
void ConnectionsDock::update_tree() {
-
tree->clear();
- if (!selectedNode)
+ if (!selectedNode) {
return;
+ }
TreeItem *root = tree->create_item();
@@ -920,27 +889,25 @@ void ConnectionsDock::update_tree() {
StringName base = selectedNode->get_class();
while (base) {
-
List<MethodInfo> node_signals2;
Ref<Texture2D> icon;
String name;
if (!did_script) {
-
Ref<Script> scr = selectedNode->get_script();
if (scr.is_valid()) {
scr->get_script_signal_list(&node_signals2);
- if (scr->get_path().is_resource_file())
+ if (scr->get_path().is_resource_file()) {
name = scr->get_path().get_file();
- else
+ } else {
name = scr->get_class();
+ }
if (has_theme_icon(scr->get_class(), "EditorIcons")) {
icon = get_theme_icon(scr->get_class(), "EditorIcons");
}
}
} else {
-
ClassDB::get_signal_list(base, &node_signals2, true);
if (has_theme_icon(base, "EditorIcons")) {
icon = get_theme_icon(base, "EditorIcons");
@@ -965,7 +932,6 @@ void ConnectionsDock::update_tree() {
}
for (List<MethodInfo>::Element *E = node_signals2.front(); E; E = E->next()) {
-
MethodInfo &mi = E->get();
StringName signal_name = mi.name;
@@ -973,11 +939,11 @@ void ConnectionsDock::update_tree() {
PackedStringArray argnames;
if (mi.arguments.size()) {
for (int i = 0; i < mi.arguments.size(); i++) {
-
PropertyInfo &pi = mi.arguments[i];
- if (i > 0)
+ if (i > 0) {
signaldesc += ", ";
+ }
String tname = "var";
if (pi.type == Variant::OBJECT && pi.class_name != StringName()) {
tname = pi.class_name.operator String();
@@ -1018,7 +984,7 @@ void ConnectionsDock::update_tree() {
while (F && descr == String()) {
for (int i = 0; i < F->get().signals.size(); i++) {
if (F->get().signals[i].name == signal_name.operator String()) {
- descr = DTR(F->get().signals[i].description.strip_edges());
+ descr = DTR(F->get().signals[i].description);
break;
}
}
@@ -1040,28 +1006,30 @@ void ConnectionsDock::update_tree() {
selectedNode->get_signal_connection_list(signal_name, &connections);
for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) {
-
Connection cn = F->get();
- if (!(cn.flags & CONNECT_PERSIST))
+ if (!(cn.flags & CONNECT_PERSIST)) {
continue;
+ }
ConnectDialog::ConnectionData c = cn;
Node *target = Object::cast_to<Node>(c.target);
- if (!target)
+ if (!target) {
continue;
+ }
String path = String(selectedNode->get_path_to(target)) + " :: " + c.method + "()";
- if (c.flags & CONNECT_DEFERRED)
+ if (c.flags & CONNECT_DEFERRED) {
path += " (deferred)";
- if (c.flags & CONNECT_ONESHOT)
+ }
+ if (c.flags & CONNECT_ONESHOT) {
path += " (oneshot)";
+ }
if (c.binds.size()) {
-
path += " binds(";
for (int i = 0; i < c.binds.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
path += ", ";
+ }
path += c.binds[i].operator String();
}
path += ")";
@@ -1087,7 +1055,6 @@ void ConnectionsDock::update_tree() {
}
ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
-
editor = p_editor;
set_name(TTR("Signals"));
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index 91d0d5c32c..d0c8d939cf 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -50,7 +50,6 @@ class PopupMenu;
class ConnectDialogBinds;
class ConnectDialog : public ConfirmationDialog {
-
GDCLASS(ConnectDialog, ConfirmationDialog);
public:
@@ -142,12 +141,10 @@ public:
// Custom Tree needed to use a RichTextLabel as tooltip control
// when display signal documentation.
class ConnectionsDockTree : public Tree {
-
virtual Control *make_custom_tooltip(const String &p_text) const;
};
class ConnectionsDock : public VBoxContainer {
-
GDCLASS(ConnectionsDock, VBoxContainer);
//Right-click Pop-up Menu Options.
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 6cbb1b1791..73468f8ce0 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -41,7 +41,6 @@
#include "scene/gui/box_container.h"
void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_select_type) {
-
type_list.clear();
ClassDB::get_class_list(&type_list);
ScriptServer::get_global_class_list(&type_list);
@@ -52,16 +51,17 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St
FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::READ);
if (f) {
-
TreeItem *root = recent->create_item();
+ String icon_fallback = search_options->has_theme_icon(base_type, "EditorIcons") ? base_type : "Object";
+
while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
String name = l.split(" ")[0];
if ((ClassDB::class_exists(name) || ScriptServer::is_global_class(name)) && !_is_class_disabled_by_feature_profile(name)) {
TreeItem *ti = recent->create_item(root);
ti->set_text(0, l);
- ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(l, base_type));
+ ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name, icon_fallback));
}
}
@@ -75,7 +75,6 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St
favorite_list.clear();
if (f) {
-
while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
@@ -120,49 +119,50 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St
}
void CreateDialog::_text_changed(const String &p_newtext) {
-
_update_search();
}
void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) {
-
Ref<InputEventKey> k = p_ie;
if (k.is_valid() && (k->get_keycode() == KEY_UP ||
k->get_keycode() == KEY_DOWN ||
k->get_keycode() == KEY_PAGEUP ||
k->get_keycode() == KEY_PAGEDOWN)) {
-
search_options->call("_gui_input", k);
search_box->accept_event();
}
}
void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) {
-
- if (p_types.has(p_type))
+ if (p_types.has(p_type)) {
return;
+ }
bool cpp_type = ClassDB::class_exists(p_type);
EditorData &ed = EditorNode::get_editor_data();
- if (p_type == base_type)
+ if (p_type == base_type) {
return;
+ }
if (cpp_type) {
- if (!ClassDB::is_parent_class(p_type, base_type))
+ if (!ClassDB::is_parent_class(p_type, base_type)) {
return;
+ }
} else {
if (!search_loaded_scripts.has(p_type)) {
search_loaded_scripts[p_type] = ed.script_class_load_script(p_type);
}
- if (!ScriptServer::is_global_class(p_type) || !ed.script_class_is_parent(p_type, base_type))
+ if (!ScriptServer::is_global_class(p_type) || !ed.script_class_is_parent(p_type, base_type)) {
return;
+ }
String script_path = ScriptServer::get_global_class_path(p_type);
if (script_path.find("res://addons/", 0) != -1) {
- if (!EditorNode::get_singleton()->is_addon_plugin_enabled(script_path.get_slicec('/', 3)))
+ if (!EditorNode::get_singleton()->is_addon_plugin_enabled(script_path.get_slicec('/', 3))) {
return;
+ }
}
}
@@ -171,16 +171,15 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
TreeItem *parent = p_root;
if (inherits.length()) {
-
if (!p_types.has(inherits)) {
-
add_type(inherits, p_types, p_root, to_select);
}
- if (p_types.has(inherits))
+ if (p_types.has(inherits)) {
parent = p_types[inherits];
- else if (ScriptServer::is_global_class(inherits))
+ } else if (ScriptServer::is_global_class(inherits)) {
return;
+ }
}
bool can_instance = (cpp_type && ClassDB::can_instance(p_type)) || ScriptServer::is_global_class(p_type);
@@ -251,7 +250,8 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description);
item->set_tooltip(0, description);
- item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, base_type));
+ String icon_fallback = search_options->has_theme_icon(base_type, "EditorIcons") ? base_type : "Object";
+ item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback));
p_types[p_type] = item;
}
@@ -267,7 +267,6 @@ bool CreateDialog::_is_type_prefered(const String &type) {
}
bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_class) {
-
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
if (profile.is_null()) {
return false;
@@ -277,7 +276,6 @@ bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_cla
}
void CreateDialog::select_type(const String &p_type) {
-
TreeItem *to_select;
if (search_options_types.has(p_type)) {
to_select = search_options_types[p_type];
@@ -310,14 +308,12 @@ void CreateDialog::_update_search() {
EditorData &ed = EditorNode::get_editor_data();
root->set_text(0, base_type);
- if (search_options->has_theme_icon(base_type, "EditorIcons")) {
- root->set_icon(0, search_options->get_theme_icon(base_type, "EditorIcons"));
- }
+ String base_icon = search_options->has_theme_icon(base_type, "EditorIcons") ? base_type : "Object";
+ root->set_icon(0, search_options->get_theme_icon(base_icon, "EditorIcons"));
TreeItem *to_select = search_box->get_text() == base_type ? root : nullptr;
for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) {
-
String type = I->get();
if (_is_class_disabled_by_feature_profile(type)) {
@@ -325,44 +321,48 @@ void CreateDialog::_update_search() {
}
bool cpp_type = ClassDB::class_exists(type);
- if (base_type == "Node" && type.begins_with("Editor"))
+ if (base_type == "Node" && type.begins_with("Editor")) {
continue; // do not show editor nodes
+ }
- if (cpp_type && !ClassDB::can_instance(type))
+ if (cpp_type && !ClassDB::can_instance(type)) {
continue; // can't create what can't be instanced
+ }
if (cpp_type) {
bool skip = false;
for (Set<StringName>::Element *E = type_blacklist.front(); E && !skip; E = E->next()) {
- if (ClassDB::is_parent_class(type, E->get()))
+ if (ClassDB::is_parent_class(type, E->get())) {
skip = true;
+ }
}
- if (skip)
+ if (skip) {
continue;
+ }
}
if (search_box->get_text() == "") {
add_type(type, search_options_types, root, &to_select);
} else {
-
bool found = false;
String type2 = type;
+ bool cpp_type2 = cpp_type;
if (!cpp_type && !search_loaded_scripts.has(type)) {
search_loaded_scripts[type] = ed.script_class_load_script(type);
}
- while (type2 != "" && (cpp_type ? ClassDB::is_parent_class(type2, base_type) : ed.script_class_is_parent(type2, base_type)) && type2 != base_type) {
+ while (type2 != "" && (cpp_type2 ? ClassDB::is_parent_class(type2, base_type) : ed.script_class_is_parent(type2, base_type)) && type2 != base_type) {
if (search_box->get_text().is_subsequence_ofi(type2)) {
-
found = true;
break;
}
- type2 = cpp_type ? ClassDB::get_parent_class(type2) : ed.script_class_get_base(type2);
+ type2 = cpp_type2 ? ClassDB::get_parent_class(type2) : ed.script_class_get_base(type2);
+ cpp_type2 = cpp_type2 || ClassDB::class_exists(type2); // Built-in class can't inherit from custom type, so we can skip the check if it's already true.
- if (!cpp_type && !search_loaded_scripts.has(type2)) {
+ if (!cpp_type2 && !search_loaded_scripts.has(type2)) {
search_loaded_scripts[type2] = ed.script_class_load_script(type2);
}
}
@@ -377,27 +377,27 @@ void CreateDialog::_update_search() {
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
for (int i = 0; i < ct.size(); i++) {
-
bool show = search_box->get_text().is_subsequence_ofi(ct[i].name);
- if (!show)
+ if (!show) {
continue;
+ }
- if (!search_options_types.has(type))
+ if (!search_options_types.has(type)) {
add_type(type, search_options_types, root, &to_select);
+ }
TreeItem *ti;
- if (search_options_types.has(type))
+ if (search_options_types.has(type)) {
ti = search_options_types[type];
- else
+ } else {
ti = search_options->get_root();
+ }
TreeItem *item = search_options->create_item(ti);
item->set_metadata(0, type);
item->set_text(0, ct[i].name);
- if (ct[i].icon.is_valid()) {
- item->set_icon(0, ct[i].icon);
- }
+ item->set_icon(0, ct[i].icon.is_valid() ? ct[i].icon : search_options->get_theme_icon(base_icon, "EditorIcons"));
if (!to_select || ct[i].name == search_box->get_text()) {
to_select = item;
@@ -421,22 +421,22 @@ void CreateDialog::_update_search() {
}
void CreateDialog::_confirmed() {
-
TreeItem *ti = search_options->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE);
if (f) {
f->store_line(get_selected_type());
TreeItem *t = recent->get_root();
- if (t)
+ if (t) {
t = t->get_children();
+ }
int count = 0;
while (t) {
if (t->get_text(0) != get_selected_type()) {
-
f->store_line(t->get_text(0));
}
@@ -456,7 +456,6 @@ void CreateDialog::_confirmed() {
}
void CreateDialog::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
@@ -480,18 +479,17 @@ void CreateDialog::_notification(int p_what) {
}
void CreateDialog::set_base_type(const String &p_base) {
-
base_type = p_base;
- if (is_replace_mode)
+ if (is_replace_mode) {
set_title(vformat(TTR("Change %s Type"), p_base));
- else
+ } else {
set_title(vformat(TTR("Create New %s"), p_base));
+ }
_update_search();
}
String CreateDialog::get_base_type() const {
-
return base_type;
}
@@ -500,60 +498,76 @@ void CreateDialog::set_preferred_search_result_type(const String &p_preferred_ty
}
String CreateDialog::get_preferred_search_result_type() {
-
return preferred_search_result_type;
}
-String CreateDialog::get_selected_type() {
+String CreateDialog::get_selected_type() {
TreeItem *selected = search_options->get_selected();
- if (selected)
+ if (selected) {
return selected->get_text(0);
- else
+ } else {
return String();
+ }
}
Object *CreateDialog::instance_selected() {
-
TreeItem *selected = search_options->get_selected();
- if (selected) {
+ if (!selected) {
+ return nullptr;
+ }
- Variant md = selected->get_metadata(0);
+ Variant md = selected->get_metadata(0);
+ String custom;
+ if (md.get_type() != Variant::NIL) {
+ custom = md;
+ }
- String custom;
- if (md.get_type() != Variant::NIL)
- custom = md;
+ Object *obj = nullptr;
- if (custom != String()) {
- if (ScriptServer::is_global_class(custom)) {
- Object *obj = EditorNode::get_editor_data().script_class_instance(custom);
- Node *n = Object::cast_to<Node>(obj);
- if (n)
- n->set_name(custom);
- return obj;
+ if (!custom.empty()) {
+ if (ScriptServer::is_global_class(custom)) {
+ obj = EditorNode::get_editor_data().script_class_instance(custom);
+ Node *n = Object::cast_to<Node>(obj);
+ if (n) {
+ n->set_name(custom);
}
- return EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom);
+ obj = n;
} else {
- return ClassDB::instance(selected->get_text(0));
+ obj = EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom);
}
+ } else {
+ obj = ClassDB::instance(selected->get_text(0));
}
- return nullptr;
+ // Check if any Object-type property should be instantiated.
+ List<PropertyInfo> pinfo;
+ obj->get_property_list(&pinfo);
+
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ if (E->get().type == Variant::OBJECT && E->get().usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
+ Object *prop = ClassDB::instance(E->get().class_name);
+ obj->set(E->get().name, prop);
+ }
+ }
+
+ return obj;
}
void CreateDialog::_item_selected() {
-
TreeItem *item = search_options->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
String name = item->get_text(0);
favorite->set_disabled(false);
favorite->set_pressed(favorite_list.find(name) != -1);
- if (!EditorHelp::get_doc_data()->class_list.has(name))
+ if (!EditorHelp::get_doc_data()->class_list.has(name)) {
return;
+ }
help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[name].brief_description));
@@ -565,10 +579,10 @@ void CreateDialog::_hide_requested() {
}
void CreateDialog::_favorite_toggled() {
-
TreeItem *item = search_options->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
String name = item->get_text(0);
@@ -584,16 +598,15 @@ void CreateDialog::_favorite_toggled() {
}
void CreateDialog::_save_favorite_list() {
-
FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE);
if (f) {
-
for (int i = 0; i < favorite_list.size(); i++) {
String l = favorite_list[i];
String name = l.split(" ")[0];
- if (!(ClassDB::class_exists(name) || ScriptServer::is_global_class(name)))
+ if (!(ClassDB::class_exists(name) || ScriptServer::is_global_class(name))) {
continue;
+ }
f->store_line(l);
}
memdelete(f);
@@ -601,26 +614,31 @@ void CreateDialog::_save_favorite_list() {
}
void CreateDialog::_update_favorite_list() {
-
favorites->clear();
+
TreeItem *root = favorites->create_item();
+
+ String icon_fallback = search_options->has_theme_icon(base_type, "EditorIcons") ? base_type : "Object";
+
for (int i = 0; i < favorite_list.size(); i++) {
String l = favorite_list[i];
String name = l.split(" ")[0];
- if (!((ClassDB::class_exists(name) || ScriptServer::is_global_class(name)) && !_is_class_disabled_by_feature_profile(name)))
+ if (!((ClassDB::class_exists(name) || ScriptServer::is_global_class(name)) && !_is_class_disabled_by_feature_profile(name))) {
continue;
+ }
+
TreeItem *ti = favorites->create_item(root);
ti->set_text(0, l);
- ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(l, base_type));
+ ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name, icon_fallback));
}
emit_signal("favorites_updated");
}
void CreateDialog::_history_selected() {
-
TreeItem *item = recent->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
search_box->set_text(item->get_text(0).get_slicec(' ', 0));
favorites->deselect_all();
@@ -628,10 +646,10 @@ void CreateDialog::_history_selected() {
}
void CreateDialog::_favorite_selected() {
-
TreeItem *item = favorites->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
search_box->set_text(item->get_text(0).get_slicec(' ', 0));
recent->deselect_all();
@@ -639,19 +657,16 @@ void CreateDialog::_favorite_selected() {
}
void CreateDialog::_history_activated() {
-
_history_selected();
_confirmed();
}
void CreateDialog::_favorite_activated() {
-
_favorite_selected();
_confirmed();
}
Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
TreeItem *ti = favorites->get_item_at_position(p_point);
if (ti) {
Dictionary d;
@@ -670,7 +685,6 @@ Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
}
bool CreateDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
if (d.has("type") && String(d["type"]) == "create_favorite_drag") {
favorites->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
@@ -679,26 +693,29 @@ bool CreateDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
return false;
}
-void CreateDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+void CreateDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data;
TreeItem *ti = favorites->get_item_at_position(p_point);
- if (!ti)
+ if (!ti) {
return;
+ }
String drop_at = ti->get_text(0);
int ds = favorites->get_drop_section_at_position(p_point);
int drop_idx = favorite_list.find(drop_at);
- if (drop_idx < 0)
+ if (drop_idx < 0) {
return;
+ }
String type = d["class"];
int from_idx = favorite_list.find(type);
- if (from_idx < 0)
+ if (from_idx < 0) {
return;
+ }
if (drop_idx == from_idx) {
ds = -1; //cause it will be gone
@@ -727,7 +744,6 @@ void CreateDialog::_save_and_update_favorite_list() {
}
void CreateDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_save_and_update_favorite_list"), &CreateDialog::_save_and_update_favorite_list);
ClassDB::bind_method("get_drag_data_fw", &CreateDialog::get_drag_data_fw);
@@ -739,7 +755,6 @@ void CreateDialog::_bind_methods() {
}
CreateDialog::CreateDialog() {
-
is_replace_mode = false;
HSplitContainer *hsc = memnew(HSplitContainer);
diff --git a/editor/create_dialog.h b/editor/create_dialog.h
index f2e2eb1b04..cdc91ae535 100644
--- a/editor/create_dialog.h
+++ b/editor/create_dialog.h
@@ -40,7 +40,6 @@
#include "scene/gui/tree.h"
class CreateDialog : public ConfirmationDialog {
-
GDCLASS(CreateDialog, ConfirmationDialog);
Vector<String> favorite_list;
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index 00ed2bbc4c..dcd7220ed0 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -36,9 +36,9 @@
#include "scene/debugger/scene_debugger.h"
bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p_value) {
-
- if (!editable || !prop_values.has(p_name) || String(p_name).begins_with("Constants/"))
+ if (!editable || !prop_values.has(p_name) || String(p_name).begins_with("Constants/")) {
return false;
+ }
prop_values[p_name] = p_value;
emit_signal("value_edited", remote_object_id, p_name, p_value);
@@ -46,16 +46,15 @@ bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p
}
bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (!prop_values.has(p_name))
+ if (!prop_values.has(p_name)) {
return false;
+ }
r_ret = prop_values[p_name];
return true;
}
void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const {
-
p_list->clear(); //sorry, no want category
for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) {
p_list->push_back(E->get());
@@ -63,10 +62,11 @@ void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list)
}
String EditorDebuggerRemoteObject::get_title() {
- if (remote_object_id.is_valid())
+ if (remote_object_id.is_valid()) {
return TTR("Remote ") + String(type_name) + ": " + itos(remote_object_id);
- else
+ } else {
return "<null>";
+ }
}
Variant EditorDebuggerRemoteObject::get_variant(const StringName &p_name) {
@@ -76,7 +76,6 @@ Variant EditorDebuggerRemoteObject::get_variant(const StringName &p_name) {
}
void EditorDebuggerRemoteObject::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_title"), &EditorDebuggerRemoteObject::get_title);
ClassDB::bind_method(D_METHOD("get_variant"), &EditorDebuggerRemoteObject::get_variant);
ClassDB::bind_method(D_METHOD("clear"), &EditorDebuggerRemoteObject::clear);
@@ -115,12 +114,10 @@ void EditorDebuggerInspector::_notification(int p_what) {
}
void EditorDebuggerInspector::_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) {
-
emit_signal("object_edited", p_id, p_prop, p_value);
}
void EditorDebuggerInspector::_object_selected(ObjectID p_object) {
-
emit_signal("object_selected", p_object);
}
@@ -147,7 +144,6 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
int new_props_added = 0;
Set<String> changed;
for (int i = 0; i < obj.properties.size(); i++) {
-
PropertyInfo &pinfo = obj.properties[i].first;
Variant &var = obj.properties[i].second;
@@ -157,12 +153,9 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
if (path.find("::") != -1) {
// built-in resource
String base_path = path.get_slice("::", 0);
- if (ResourceLoader::get_resource_type(base_path) == "PackedScene") {
- if (!EditorNode::get_singleton()->is_scene_open(base_path)) {
- EditorNode::get_singleton()->load_scene(base_path);
- }
- } else {
- EditorNode::get_singleton()->load_resource(base_path);
+ RES dependency = ResourceLoader::load(base_path);
+ if (dependency.is_valid()) {
+ remote_dependencies.insert(dependency);
}
}
var = ResourceLoader::load(path);
@@ -187,7 +180,6 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) {
new_props_added++;
debugObj->prop_values[pinfo.name] = var;
} else {
-
if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debugObj->prop_values[pinfo.name], var))) {
debugObj->prop_values[pinfo.name] = var;
changed.insert(pinfo.name);
@@ -216,16 +208,17 @@ void EditorDebuggerInspector::clear_cache() {
memdelete(E->value());
}
remote_objects.clear();
+ remote_dependencies.clear();
}
Object *EditorDebuggerInspector::get_object(ObjectID p_id) {
- if (remote_objects.has(p_id))
+ if (remote_objects.has(p_id)) {
return remote_objects[p_id];
+ }
return nullptr;
}
void EditorDebuggerInspector::add_stack_variable(const Array &p_array) {
-
DebuggerMarshalls::ScriptStackVariable var;
var.deserialize(p_array);
String n = var.name;
diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h
index e1dfbefcf3..7d13a4c362 100644
--- a/editor/debugger/editor_debugger_inspector.h
+++ b/editor/debugger/editor_debugger_inspector.h
@@ -33,7 +33,6 @@
#include "editor/editor_inspector.h"
class EditorDebuggerRemoteObject : public Object {
-
GDCLASS(EditorDebuggerRemoteObject, Object);
protected:
@@ -61,16 +60,16 @@ public:
void update() { _change_notify(); }
- EditorDebuggerRemoteObject(){};
+ EditorDebuggerRemoteObject() {}
};
class EditorDebuggerInspector : public EditorInspector {
-
GDCLASS(EditorDebuggerInspector, EditorInspector);
private:
ObjectID inspected_object_id;
Map<ObjectID, EditorDebuggerRemoteObject *> remote_objects;
+ Set<RES> remote_dependencies;
EditorDebuggerRemoteObject *variables;
void _object_selected(ObjectID p_object);
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 5bfb79806e..a9c18138d8 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -50,8 +50,9 @@ void _for_all(TabContainer *p_node, const Func &p_func) {
EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr;
EditorDebuggerNode::EditorDebuggerNode() {
- if (!singleton)
+ if (!singleton) {
singleton = this;
+ }
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT));
@@ -119,8 +120,9 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
void EditorDebuggerNode::_stack_frame_selected(int p_debugger) {
const ScriptEditorDebugger *dbg = get_debugger(p_debugger);
ERR_FAIL_COND(!dbg);
- if (dbg != get_current_debugger())
+ if (dbg != get_current_debugger()) {
return;
+ }
_text_editor_stack_goto(dbg);
}
@@ -131,8 +133,9 @@ void EditorDebuggerNode::_error_selected(const String &p_file, int p_line, int p
void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_debugger) {
const String file = p_debugger->get_stack_script_file();
- if (file.empty())
+ if (file.empty()) {
return;
+ }
stack_script = ResourceLoader::load(file);
const int line = p_debugger->get_stack_script_line() - 1;
emit_signal("goto_script_line", stack_script, line);
@@ -141,7 +144,6 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d
}
void EditorDebuggerNode::_bind_methods() {
-
// LiveDebug.
ClassDB::bind_method("live_debug_create_node", &EditorDebuggerNode::live_debug_create_node);
ClassDB::bind_method("live_debug_instance_node", &EditorDebuggerNode::live_debug_instance_node);
@@ -199,13 +201,15 @@ void EditorDebuggerNode::stop() {
}
// Also close all debugging sessions.
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- if (dbg->is_session_active())
+ if (dbg->is_session_active()) {
dbg->stop();
+ }
});
_break_state_changed();
if (hide_on_stop) {
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
EditorNode::get_singleton()->hide_bottom_panel();
+ }
}
breakpoints.clear();
set_process(false);
@@ -225,8 +229,9 @@ void EditorDebuggerNode::_notification(int p_what) {
break;
}
- if (p_what != NOTIFICATION_PROCESS || !server.is_valid())
+ if (p_what != NOTIFICATION_PROCESS || !server.is_valid()) {
return;
+ }
if (!server.is_valid() || !server->is_active()) {
stop();
@@ -243,7 +248,6 @@ void EditorDebuggerNode::_notification(int p_what) {
});
if (error_count != last_error_count || warning_count != last_warning_count) {
-
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->update_tabs();
});
@@ -287,8 +291,9 @@ void EditorDebuggerNode::_notification(int p_what) {
if (server->is_connection_available()) {
ScriptEditorDebugger *debugger = nullptr;
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
- if (debugger || dbg->is_session_active())
+ if (debugger || dbg->is_session_active()) {
return;
+ }
debugger = dbg;
});
if (debugger == nullptr) {
@@ -327,8 +332,9 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) {
bool found = false;
_for_all(tabs, [&](ScriptEditorDebugger *p_debugger) {
- if (p_debugger->is_session_active())
+ if (p_debugger->is_session_active()) {
found = true;
+ }
});
if (!found) {
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
@@ -342,8 +348,9 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) {
void EditorDebuggerNode::_debugger_wants_stop(int p_id) {
// Ask editor to kill PID.
int pid = get_debugger(p_id)->get_remote_pid();
- if (pid)
+ if (pid) {
EditorNode::get_singleton()->call_deferred("stop_child_process", pid);
+ }
}
void EditorDebuggerNode::_debugger_changed(int p_tab) {
@@ -382,12 +389,14 @@ void EditorDebuggerNode::set_script_debug_button(MenuButton *p_button) {
void EditorDebuggerNode::_break_state_changed() {
const bool breaked = get_current_debugger()->is_breaked();
const bool can_debug = get_current_debugger()->is_debuggable();
- if (breaked) // Show debugger.
+ if (breaked) { // Show debugger.
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
+ }
// Update script menu.
- if (!script_menu)
+ if (!script_menu) {
return;
+ }
PopupMenu *p = script_menu->get_popup();
p->set_item_disabled(p->get_item_index(DEBUG_NEXT), !(breaked && can_debug));
p->set_item_disabled(p->get_item_index(DEBUG_STEP), !(breaked && can_debug));
@@ -436,8 +445,9 @@ void EditorDebuggerNode::_paused() {
void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, int p_debugger) {
if (get_current_debugger() != get_debugger(p_debugger)) {
- if (!p_breaked)
+ if (!p_breaked) {
return;
+ }
tabs->set_current_tab(p_debugger);
}
_break_state_changed();
@@ -488,58 +498,67 @@ void EditorDebuggerNode::request_remote_tree() {
}
void EditorDebuggerNode::_remote_tree_updated(int p_debugger) {
- if (p_debugger != tabs->get_current_tab())
+ if (p_debugger != tabs->get_current_tab()) {
return;
+ }
remote_scene_tree->clear();
remote_scene_tree->update_scene_tree(get_current_debugger()->get_remote_tree(), p_debugger);
}
void EditorDebuggerNode::_remote_object_updated(ObjectID p_id, int p_debugger) {
- if (p_debugger != tabs->get_current_tab())
+ if (p_debugger != tabs->get_current_tab()) {
return;
+ }
if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) {
- if (obj->remote_object_id == p_id)
+ if (obj->remote_object_id == p_id) {
return; // Already being edited
+ }
}
EditorNode::get_singleton()->push_item(get_current_debugger()->get_remote_object(p_id));
}
void EditorDebuggerNode::_remote_object_property_updated(ObjectID p_id, const String &p_property, int p_debugger) {
- if (p_debugger != tabs->get_current_tab())
+ if (p_debugger != tabs->get_current_tab()) {
return;
+ }
if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) {
- if (obj->remote_object_id != p_id)
+ if (obj->remote_object_id != p_id) {
return;
+ }
EditorNode::get_singleton()->get_inspector()->update_property(p_property);
}
}
void EditorDebuggerNode::_remote_object_requested(ObjectID p_id, int p_debugger) {
- if (p_debugger != tabs->get_current_tab())
+ if (p_debugger != tabs->get_current_tab()) {
return;
+ }
inspect_edited_object_timeout = 0.7; // Temporarily disable timeout to avoid multiple requests.
get_current_debugger()->request_remote_object(p_id);
}
void EditorDebuggerNode::_save_node_requested(ObjectID p_id, const String &p_file, int p_debugger) {
- if (p_debugger != tabs->get_current_tab())
+ if (p_debugger != tabs->get_current_tab()) {
return;
+ }
get_current_debugger()->save_node(p_id, p_file);
}
// Remote inspector/edit.
void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
- if (!singleton)
+ if (!singleton) {
return;
+ }
_for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) {
dbg->_method_changed(p_base, p_name, VARIANT_ARG_PASS);
});
}
void EditorDebuggerNode::_property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value) {
- if (!singleton)
+ if (!singleton) {
return;
+ }
_for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) {
dbg->_property_changed(p_base, p_property, p_value);
});
@@ -547,46 +566,53 @@ void EditorDebuggerNode::_property_changeds(void *p_ud, Object *p_base, const St
// LiveDebug
void EditorDebuggerNode::set_live_debugging(bool p_enabled) {
-
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->set_live_debugging(p_enabled);
});
}
+
void EditorDebuggerNode::update_live_edit_root() {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->update_live_edit_root();
});
}
+
void EditorDebuggerNode::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_create_node(p_parent, p_type, p_name);
});
}
+
void EditorDebuggerNode::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_instance_node(p_parent, p_path, p_name);
});
}
+
void EditorDebuggerNode::live_debug_remove_node(const NodePath &p_at) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_remove_node(p_at);
});
}
+
void EditorDebuggerNode::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_remove_and_keep_node(p_at, p_keep_id);
});
}
+
void EditorDebuggerNode::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_restore_node(p_id, p_at, p_at_pos);
});
}
+
void EditorDebuggerNode::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_duplicate_node(p_at, p_new_name);
});
}
+
void EditorDebuggerNode::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->live_debug_reparent_node(p_at, p_new_place, p_new_name, p_at_pos);
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index 7546febd05..ff9601c026 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -42,7 +42,6 @@ class ScriptEditorDebugger;
class TabContainer;
class EditorDebuggerNode : public MarginContainer {
-
GDCLASS(EditorDebuggerNode, MarginContainer);
public:
@@ -71,12 +70,13 @@ private:
int line = 0;
bool operator<(const Breakpoint &p_b) const {
- if (line == p_b.line)
+ if (line == p_b.line) {
return source < p_b.source;
+ }
return line < p_b.line;
}
- Breakpoint(){};
+ Breakpoint() {}
Breakpoint(const String &p_source, int p_line) {
line = p_line;
diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp
index 33f20d9a12..0b655044a8 100644
--- a/editor/debugger/editor_debugger_server.cpp
+++ b/editor/debugger/editor_debugger_server.cpp
@@ -39,7 +39,6 @@
#include "editor/editor_settings.h"
class EditorDebuggerServerTCP : public EditorDebuggerServer {
-
private:
Ref<TCP_Server> server;
diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h
index 515ffce628..10a9a232ab 100644
--- a/editor/debugger/editor_debugger_server.h
+++ b/editor/debugger/editor_debugger_server.h
@@ -35,7 +35,6 @@
#include "core/reference.h"
class EditorDebuggerServer : public Reference {
-
public:
typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri);
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index c2b94c79bb..0b5f865a98 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -64,7 +64,6 @@ void EditorDebuggerTree::_bind_methods() {
}
void EditorDebuggerTree::_scene_tree_selected() {
-
if (updating_scene_tree) {
return;
}
@@ -80,15 +79,14 @@ void EditorDebuggerTree::_scene_tree_selected() {
}
void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) {
-
if (updating_scene_tree) {
-
return;
}
TreeItem *item = Object::cast_to<TreeItem>(p_obj);
- if (!item)
+ if (!item) {
return;
+ }
ObjectID id = ObjectID(uint64_t(item->get_metadata(0)));
if (unfold_cache.has(id)) {
@@ -99,10 +97,10 @@ void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) {
}
void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) {
-
TreeItem *item = get_item_at_position(p_position);
- if (!item)
+ if (!item) {
return;
+ }
item->select(0);
@@ -180,12 +178,14 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
// Apply filters.
while (parent) {
const bool had_siblings = item->get_prev() || item->get_next();
- if (filter.is_subsequence_ofi(item->get_text(0)))
+ if (filter.is_subsequence_ofi(item->get_text(0))) {
break; // Filter matches, must survive.
+ }
parent->remove_child(item);
memdelete(item);
- if (had_siblings)
+ if (had_siblings) {
break; // Parent must survive.
+ }
item = parent;
parent = item->get_parent();
// Check if parent expects more children.
@@ -203,8 +203,9 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
}
String EditorDebuggerTree::get_selected_path() {
- if (!get_selected())
+ if (!get_selected()) {
return "";
+ }
return _get_path(get_selected());
}
@@ -224,11 +225,8 @@ String EditorDebuggerTree::_get_path(TreeItem *p_item) {
}
void EditorDebuggerTree::_item_menu_id_pressed(int p_option) {
-
switch (p_option) {
-
case ITEM_MENU_SAVE_REMOTE_NODE: {
-
file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
@@ -243,7 +241,6 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) {
file_dialog->popup_centered_ratio();
} break;
case ITEM_MENU_COPY_NODE_PATH: {
-
String text = get_selected_path();
if (text.empty()) {
return;
@@ -264,7 +261,8 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) {
}
void EditorDebuggerTree::_file_selected(const String &p_file) {
- if (inspected_object_id.is_null())
+ if (inspected_object_id.is_null()) {
return;
+ }
emit_signal("save_node", inspected_object_id, p_file, debugger_id);
}
diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h
index 342eb23194..5ec1423c07 100644
--- a/editor/debugger/editor_debugger_tree.h
+++ b/editor/debugger/editor_debugger_tree.h
@@ -37,7 +37,6 @@ class SceneDebuggerTree;
class EditorFileDialog;
class EditorDebuggerTree : public Tree {
-
GDCLASS(EditorDebuggerTree, Tree);
private:
diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp
index b8c795d9ca..baa88bcdbc 100644
--- a/editor/debugger/editor_network_profiler.cpp
+++ b/editor/debugger/editor_network_profiler.cpp
@@ -39,7 +39,6 @@ void EditorNetworkProfiler::_bind_methods() {
}
void EditorNetworkProfiler::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
activate->set_icon(get_theme_icon("Play", "EditorIcons"));
clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
@@ -53,13 +52,11 @@ void EditorNetworkProfiler::_notification(int p_what) {
}
void EditorNetworkProfiler::_update_frame() {
-
counters_display->clear();
TreeItem *root = counters_display->create_item();
for (Map<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo>::Element *E = nodes_data.front(); E; E = E->next()) {
-
TreeItem *node = counters_display->create_item(root);
for (int j = 0; j < counters_display->get_columns(); ++j) {
@@ -75,7 +72,6 @@ void EditorNetworkProfiler::_update_frame() {
}
void EditorNetworkProfiler::_activate_pressed() {
-
if (activate->is_pressed()) {
activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop"));
@@ -96,7 +92,6 @@ void EditorNetworkProfiler::_clear_pressed() {
}
void EditorNetworkProfiler::add_node_frame_data(const DebuggerMarshalls::MultiplayerNodeInfo p_frame) {
-
if (!nodes_data.has(p_frame.node)) {
nodes_data.insert(p_frame.node, p_frame);
} else {
@@ -113,7 +108,6 @@ void EditorNetworkProfiler::add_node_frame_data(const DebuggerMarshalls::Multipl
}
void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) {
-
incoming_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_incoming)));
outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing)));
@@ -131,7 +125,6 @@ bool EditorNetworkProfiler::is_profiling() {
}
EditorNetworkProfiler::EditorNetworkProfiler() {
-
HBoxContainer *hb = memnew(HBoxContainer);
hb->add_theme_constant_override("separation", 8 * EDSCALE);
add_child(hb);
diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h
index f532dc5dd0..cf65fb5316 100644
--- a/editor/debugger/editor_network_profiler.h
+++ b/editor/debugger/editor_network_profiler.h
@@ -39,7 +39,6 @@
#include "scene/gui/tree.h"
class EditorNetworkProfiler : public VBoxContainer {
-
GDCLASS(EditorNetworkProfiler, VBoxContainer)
private:
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index c7d4e9128a..8bd21fff5c 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -35,7 +35,6 @@
#include "editor/editor_settings.h"
void EditorProfiler::_make_metric_ptrs(Metric &m) {
-
for (int i = 0; i < m.categories.size(); i++) {
m.category_ptrs[m.categories[i].signature] = &m.categories.write[i];
for (int j = 0; j < m.categories[i].items.size(); j++) {
@@ -45,10 +44,10 @@ void EditorProfiler::_make_metric_ptrs(Metric &m) {
}
void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) {
-
++last_metric;
- if (last_metric >= frame_metrics.size())
+ if (last_metric >= frame_metrics.size()) {
last_metric = 0;
+ }
frame_metrics.write[last_metric] = p_metric;
_make_metric_ptrs(frame_metrics.write[last_metric]);
@@ -69,7 +68,6 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) {
updating_frame = false;
if (frame_delay->is_stopped()) {
-
frame_delay->set_wait_time(p_final ? 0.1 : 1);
frame_delay->start();
}
@@ -81,7 +79,6 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) {
}
void EditorProfiler::clear() {
-
int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size");
metric_size = CLAMP(metric_size, 60, 1024);
frame_metrics.clear();
@@ -110,7 +107,6 @@ static String _get_percent_txt(float p_value, float p_total) {
}
String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_calls) {
-
const int dmode = display_mode->get_selected();
if (dmode == DISPLAY_FRAME_TIME) {
@@ -131,7 +127,6 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca
}
Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const {
-
Color bc = get_theme_color("error_color", "Editor");
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
Color c;
@@ -140,20 +135,22 @@ Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) c
}
void EditorProfiler::_item_edited() {
-
- if (updating_frame)
+ if (updating_frame) {
return;
+ }
TreeItem *item = variables->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
StringName signature = item->get_metadata(0);
bool checked = item->is_checked(0);
- if (checked)
+ if (checked) {
plot_sigs.insert(signature);
- else
+ } else {
plot_sigs.erase(signature);
+ }
if (!frame_delay->is_processing()) {
frame_delay->set_wait_time(0.1);
@@ -164,7 +161,6 @@ void EditorProfiler::_item_edited() {
}
void EditorProfiler::_update_plot() {
-
const int w = graph->get_size().width;
const int h = graph->get_size().height;
bool reset_texture = false;
@@ -193,11 +189,11 @@ void EditorProfiler::_update_plot() {
for (int i = 0; i < frame_metrics.size(); i++) {
const Metric &m = frame_metrics[i];
- if (!m.valid)
+ if (!m.valid) {
continue;
+ }
for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) {
-
const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get());
if (F) {
highest = MAX(F->get()->total_time, highest);
@@ -228,7 +224,6 @@ void EditorProfiler::_update_plot() {
//Map<StringName,int> plot_max;
for (int i = 0; i < w; i++) {
-
for (int j = 0; j < h * 4; j++) {
column[j] = 0;
}
@@ -238,15 +233,14 @@ void EditorProfiler::_update_plot() {
if (next > frame_metrics.size()) {
next = frame_metrics.size();
}
- if (next == current)
+ if (next == current) {
next = current + 1; //just because for loop must work
+ }
for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) {
-
int plot_pos = -1;
for (int j = current; j < next; j++) {
-
//wrap
int idx = last_metric + 1 + j;
while (idx >= frame_metrics.size()) {
@@ -255,8 +249,9 @@ void EditorProfiler::_update_plot() {
//get
const Metric &m = frame_metrics[idx];
- if (!m.valid)
+ if (!m.valid) {
continue; //skip because invalid
+ }
float value = 0;
@@ -292,7 +287,6 @@ void EditorProfiler::_update_plot() {
}
if (prev_plot != -1 && plot_pos == -1) {
-
plot_pos = prev_plot;
}
@@ -310,7 +304,6 @@ void EditorProfiler::_update_plot() {
Color col = _get_color_from_signature(E->get());
for (int j = prev_plot; j <= plot_pos; j++) {
-
column[j * 4 + 0] += Math::fast_ftoi(CLAMP(col.r * 255, 0, 255));
column[j * 4 + 1] += Math::fast_ftoi(CLAMP(col.g * 255, 0, 255));
column[j * 4 + 2] += Math::fast_ftoi(CLAMP(col.b * 255, 0, 255));
@@ -319,7 +312,6 @@ void EditorProfiler::_update_plot() {
}
for (int j = 0; j < h * 4; j += 4) {
-
const int a = column[j + 3];
if (a > 0) {
column[j + 0] /= a;
@@ -344,10 +336,9 @@ void EditorProfiler::_update_plot() {
Ref<Image> img;
img.instance();
- img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image);
+ img->create(w, h, false, Image::FORMAT_RGBA8, graph_image);
if (reset_texture) {
-
if (graph_texture.is_null()) {
graph_texture.instance();
}
@@ -361,7 +352,6 @@ void EditorProfiler::_update_plot() {
}
void EditorProfiler::_update_frame() {
-
int cursor_metric = _get_cursor_index();
ERR_FAIL_INDEX(cursor_metric, frame_metrics.size());
@@ -375,7 +365,6 @@ void EditorProfiler::_update_frame() {
int dtime = display_time->get_selected();
for (int i = 0; i < m.categories.size(); i++) {
-
TreeItem *category = variables->create_item(root);
category->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
category->set_editable(0, true);
@@ -418,7 +407,6 @@ void EditorProfiler::_update_frame() {
}
void EditorProfiler::_activate_pressed() {
-
if (activate->is_pressed()) {
activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop"));
@@ -430,13 +418,11 @@ void EditorProfiler::_activate_pressed() {
}
void EditorProfiler::_clear_pressed() {
-
clear();
_update_plot();
}
void EditorProfiler::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
activate->set_icon(get_theme_icon("Play", "EditorIcons"));
clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
@@ -444,15 +430,15 @@ void EditorProfiler::_notification(int p_what) {
}
void EditorProfiler::_graph_tex_draw() {
-
- if (last_metric < 0)
+ if (last_metric < 0) {
return;
+ }
if (seeking) {
-
int max_frames = frame_metrics.size();
int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1);
- if (frame < 0)
+ if (frame < 0) {
frame = 0;
+ }
int cur_x = frame * graph->get_size().x / max_frames;
@@ -460,11 +446,11 @@ void EditorProfiler::_graph_tex_draw() {
}
if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
-
int max_frames = frame_metrics.size();
int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1);
- if (frame < 0)
+ if (frame < 0) {
frame = 0;
+ }
int cur_x = frame * graph->get_size().x / max_frames;
@@ -473,23 +459,23 @@ void EditorProfiler::_graph_tex_draw() {
}
void EditorProfiler::_graph_tex_mouse_exit() {
-
hover_metric = -1;
graph->update();
}
void EditorProfiler::_cursor_metric_changed(double) {
- if (updating_frame)
+ if (updating_frame) {
return;
+ }
graph->update();
_update_frame();
}
void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
-
- if (last_metric < 0)
+ if (last_metric < 0) {
return;
+ }
Ref<InputEventMouse> me = p_ev;
Ref<InputEventMouseButton> mb = p_ev;
@@ -498,7 +484,6 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
if (
(mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) ||
(mm.is_valid())) {
-
int x = me->get_position().x;
x = x * frame_metrics.size() / graph->get_size().width;
@@ -519,7 +504,6 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
}
if (show_hover) {
-
hover_metric = metric;
} else {
@@ -533,19 +517,20 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
//metric may be invalid, so look for closest metric that is valid, this makes snap feel better
bool valid = false;
for (int i = 0; i < frame_metrics.size(); i++) {
-
if (frame_metrics[metric].valid) {
valid = true;
break;
}
metric++;
- if (metric >= frame_metrics.size())
+ if (metric >= frame_metrics.size()) {
metric = 0;
+ }
}
- if (valid)
+ if (valid) {
cursor_metric_edit->set_value(frame_metrics[metric].frame_number);
+ }
updating_frame = false;
@@ -568,11 +553,12 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
}
int EditorProfiler::_get_cursor_index() const {
-
- if (last_metric < 0)
+ if (last_metric < 0) {
return 0;
- if (!frame_metrics[last_metric].valid)
+ }
+ if (!frame_metrics[last_metric].valid) {
return 0;
+ }
int diff = (frame_metrics[last_metric].frame_number - cursor_metric_edit->get_value());
@@ -585,25 +571,21 @@ int EditorProfiler::_get_cursor_index() const {
}
void EditorProfiler::disable_seeking() {
-
seeking = false;
graph->update();
}
void EditorProfiler::_combo_changed(int) {
-
_update_frame();
_update_plot();
}
void EditorProfiler::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
ADD_SIGNAL(MethodInfo("break_request"));
}
void EditorProfiler::set_enabled(bool p_enable) {
-
activate->set_disabled(!p_enable);
}
@@ -623,7 +605,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
const Vector<EditorProfiler::Metric::Category> &categories = frame_metrics[0].categories;
for (int j = 0; j < categories.size(); j++) {
-
const EditorProfiler::Metric::Category &c = categories[j];
signatures.push_back(c.signature);
@@ -640,7 +621,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
int index = last_metric;
for (int i = 0; i < frame_metrics.size(); i++) {
-
++index;
if (index >= frame_metrics.size()) {
@@ -654,7 +634,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
const Vector<EditorProfiler::Metric::Category> &frame_cat = frame_metrics[index].categories;
for (int j = 0; j < frame_cat.size(); j++) {
-
const EditorProfiler::Metric::Category &c = frame_cat[j];
values.write[it++] = String::num_real(c.total_time);
@@ -669,7 +648,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
}
EditorProfiler::EditorProfiler() {
-
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
activate = memnew(Button);
diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h
index 4afd2c8302..aa2ef58db4 100644
--- a/editor/debugger/editor_profiler.h
+++ b/editor/debugger/editor_profiler.h
@@ -41,12 +41,10 @@
#include "scene/gui/tree.h"
class EditorProfiler : public VBoxContainer {
-
GDCLASS(EditorProfiler, VBoxContainer);
public:
struct Metric {
-
bool valid;
int frame_number;
@@ -56,13 +54,11 @@ public:
float physics_frame_time;
struct Category {
-
StringName signature;
String name;
float total_time; //total for category
struct Item {
-
StringName signature;
String name;
String script;
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index 7d2822b1c9..81b42da08e 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -35,10 +35,10 @@
#include "editor/editor_settings.h"
void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
-
++last_metric;
- if (last_metric >= frame_metrics.size())
+ if (last_metric >= frame_metrics.size()) {
last_metric = 0;
+ }
frame_metrics.write[last_metric] = p_metric;
// _make_metric_ptrs(frame_metrics.write[last_metric]);
@@ -60,7 +60,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
}
if (name[0] == '>') {
-
stack.push_back(full_name + "/");
}
@@ -83,7 +82,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
updating_frame = false;
if (frame_delay->is_stopped()) {
-
frame_delay->set_wait_time(0.1);
frame_delay->start();
}
@@ -95,7 +93,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
}
void EditorVisualProfiler::clear() {
-
int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size");
metric_size = CLAMP(metric_size, 60, 1024);
frame_metrics.clear();
@@ -114,7 +111,6 @@ void EditorVisualProfiler::clear() {
}
String EditorVisualProfiler::_get_time_as_text(float p_time) {
-
int dmode = display_mode->get_selected();
if (dmode == DISPLAY_FRAME_TIME) {
@@ -127,7 +123,6 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) {
}
Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const {
-
Color bc = get_theme_color("error_color", "Editor");
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
Color c;
@@ -136,19 +131,19 @@ Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signat
}
void EditorVisualProfiler::_item_selected() {
-
- if (updating_frame)
+ if (updating_frame) {
return;
+ }
TreeItem *item = variables->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
selected_area = item->get_metadata(0);
_update_plot();
}
void EditorVisualProfiler::_update_plot() {
-
int w = graph->get_size().width;
int h = graph->get_size().height;
@@ -178,8 +173,9 @@ void EditorVisualProfiler::_update_plot() {
for (int i = 0; i < frame_metrics.size(); i++) {
const Metric &m = frame_metrics[i];
- if (!m.valid)
+ if (!m.valid) {
continue;
+ }
if (m.areas.size()) {
highest_cpu = MAX(highest_cpu, m.areas[m.areas.size() - 1].cpu_time);
@@ -188,7 +184,6 @@ void EditorVisualProfiler::_update_plot() {
}
if (highest_cpu > 0 || highest_gpu > 0) {
-
if (frame_relative->is_pressed()) {
highest_cpu = MAX(graph_limit, highest_cpu);
highest_gpu = MAX(graph_limit, highest_gpu);
@@ -225,11 +220,11 @@ void EditorVisualProfiler::_update_plot() {
if (next > frame_metrics.size()) {
next = frame_metrics.size();
}
- if (next == current)
+ if (next == current) {
next = current + 1; //just because for loop must work
+ }
for (int j = current; j < next; j++) {
-
//wrap
int idx = last_metric + 1 + j;
while (idx >= frame_metrics.size()) {
@@ -262,7 +257,6 @@ void EditorVisualProfiler::_update_plot() {
//plot CPU
for (int j = 0; j < h; j++) {
-
uint8_t r, g, b;
if (column_cpu[j].a == 0) {
@@ -283,7 +277,6 @@ void EditorVisualProfiler::_update_plot() {
}
//plot GPU
for (int j = 0; j < h; j++) {
-
uint8_t r, g, b;
if (column_gpu[j].a == 0) {
@@ -307,10 +300,9 @@ void EditorVisualProfiler::_update_plot() {
Ref<Image> img;
img.instance();
- img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image);
+ img->create(w, h, false, Image::FORMAT_RGBA8, graph_image);
if (reset_texture) {
-
if (graph_texture.is_null()) {
graph_texture.instance();
}
@@ -324,7 +316,6 @@ void EditorVisualProfiler::_update_plot() {
}
void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
-
int cursor_metric = _get_cursor_index();
Ref<Texture> track_icon = get_theme_icon("TrackColor", "EditorIcons");
@@ -343,7 +334,6 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
TreeItem *ensure_selected = nullptr;
for (int i = 1; i < m.areas.size() - 1; i++) {
-
TreeItem *parent = stack.size() ? stack.back()->get() : root;
String name = m.areas[i].name;
@@ -416,7 +406,6 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) {
}
void EditorVisualProfiler::_activate_pressed() {
-
if (activate->is_pressed()) {
activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop"));
@@ -429,13 +418,11 @@ void EditorVisualProfiler::_activate_pressed() {
}
void EditorVisualProfiler::_clear_pressed() {
-
clear();
_update_plot();
}
void EditorVisualProfiler::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
activate->set_icon(get_theme_icon("Play", "EditorIcons"));
clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
@@ -443,16 +430,16 @@ void EditorVisualProfiler::_notification(int p_what) {
}
void EditorVisualProfiler::_graph_tex_draw() {
-
- if (last_metric < 0)
+ if (last_metric < 0) {
return;
+ }
Ref<Font> font = get_theme_font("font", "Label");
if (seeking) {
-
int max_frames = frame_metrics.size();
int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1);
- if (frame < 0)
+ if (frame < 0) {
frame = 0;
+ }
int half_width = graph->get_size().x / 2;
int cur_x = frame * half_width / max_frames;
@@ -503,23 +490,23 @@ void EditorVisualProfiler::_graph_tex_draw() {
}
void EditorVisualProfiler::_graph_tex_mouse_exit() {
-
hover_metric = -1;
graph->update();
}
void EditorVisualProfiler::_cursor_metric_changed(double) {
- if (updating_frame)
+ if (updating_frame) {
return;
+ }
graph->update();
_update_frame();
}
void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
-
- if (last_metric < 0)
+ if (last_metric < 0) {
return;
+ }
Ref<InputEventMouse> me = p_ev;
Ref<InputEventMouseButton> mb = p_ev;
@@ -528,7 +515,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
if (
(mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) ||
(mm.is_valid())) {
-
int half_w = graph->get_size().width / 2;
int x = me->get_position().x;
if (x > half_w) {
@@ -553,7 +539,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
}
if (show_hover) {
-
hover_metric = metric;
} else {
@@ -567,15 +552,15 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
//metric may be invalid, so look for closest metric that is valid, this makes snap feel better
bool valid = false;
for (int i = 0; i < frame_metrics.size(); i++) {
-
if (frame_metrics[metric].valid) {
valid = true;
break;
}
metric++;
- if (metric >= frame_metrics.size())
+ if (metric >= frame_metrics.size()) {
metric = 0;
+ }
}
if (!valid) {
@@ -607,7 +592,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
int last_valid = -1;
bool found = false;
for (int i = 0; i < area_count - 1; i++) {
-
if (areas[i].name[0] != '<' && areas[i].name[0] != '>') {
last_valid = i;
}
@@ -636,11 +620,12 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
}
int EditorVisualProfiler::_get_cursor_index() const {
-
- if (last_metric < 0)
+ if (last_metric < 0) {
return 0;
- if (!frame_metrics[last_metric].valid)
+ }
+ if (!frame_metrics[last_metric].valid) {
return 0;
+ }
int diff = (frame_metrics[last_metric].frame_number - cursor_metric_edit->get_value());
@@ -653,24 +638,20 @@ int EditorVisualProfiler::_get_cursor_index() const {
}
void EditorVisualProfiler::disable_seeking() {
-
seeking = false;
graph->update();
}
void EditorVisualProfiler::_combo_changed(int) {
-
_update_frame();
_update_plot();
}
void EditorVisualProfiler::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
}
void EditorVisualProfiler::set_enabled(bool p_enable) {
-
activate->set_disabled(!p_enable);
}
@@ -736,7 +717,6 @@ Vector<Vector<String>> EditorVisualProfiler::get_data_as_csv() const {
}
EditorVisualProfiler::EditorVisualProfiler() {
-
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
activate = memnew(Button);
diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h
index d3a758557c..3c1a55dc38 100644
--- a/editor/debugger/editor_visual_profiler.h
+++ b/editor/debugger/editor_visual_profiler.h
@@ -42,12 +42,10 @@
#include "scene/gui/tree.h"
class EditorVisualProfiler : public VBoxContainer {
-
GDCLASS(EditorVisualProfiler, VBoxContainer);
public:
struct Metric {
-
bool valid;
uint64_t frame_number;
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 3ed271c7c6..49137f76fa 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -74,17 +74,19 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) {
void ScriptEditorDebugger::debug_copy() {
String msg = reason->get_text();
- if (msg == "")
+ if (msg == "") {
return;
+ }
DisplayServer::get_singleton()->clipboard_set(msg);
}
void ScriptEditorDebugger::debug_skip_breakpoints() {
skip_breakpoints_value = !skip_breakpoints_value;
- if (skip_breakpoints_value)
+ if (skip_breakpoints_value) {
skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons"));
- else
+ } else {
skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons"));
+ }
Array msg;
msg.push_back(skip_breakpoints_value);
@@ -92,14 +94,13 @@ void ScriptEditorDebugger::debug_skip_breakpoints() {
}
void ScriptEditorDebugger::debug_next() {
-
ERR_FAIL_COND(!breaked);
_put_msg("next", Array());
_clear_execution();
}
-void ScriptEditorDebugger::debug_step() {
+void ScriptEditorDebugger::debug_step() {
ERR_FAIL_COND(!breaked);
_put_msg("step", Array());
@@ -107,19 +108,18 @@ void ScriptEditorDebugger::debug_step() {
}
void ScriptEditorDebugger::debug_break() {
-
ERR_FAIL_COND(breaked);
_put_msg("break", Array());
}
void ScriptEditorDebugger::debug_continue() {
-
ERR_FAIL_COND(!breaked);
// Allow focus stealing only if we actually run this client for security.
- if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid))
+ if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid)) {
DisplayServer::get_singleton()->enable_for_stealing_focus(remote_pid);
+ }
_clear_execution();
_put_msg("continue", Array());
@@ -153,7 +153,6 @@ void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) {
}
void ScriptEditorDebugger::_file_selected(const String &p_file) {
-
switch (file_dialog_purpose) {
case SAVE_MONITORS_CSV: {
Error err;
@@ -175,10 +174,8 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
// values
List<Vector<float>>::Element *E = perf_history.back();
while (E) {
-
Vector<float> &perf_data = E->get();
for (int i = 0; i < perf_data.size(); i++) {
-
line.write[i] = String::num_real(perf_data[i]);
}
file->store_csv_line(line);
@@ -225,7 +222,6 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
}
void ScriptEditorDebugger::request_remote_tree() {
-
_put_msg("scene:request_scene_tree", Array());
}
@@ -234,7 +230,6 @@ const SceneDebuggerTree *ScriptEditorDebugger::get_remote_tree() {
}
void ScriptEditorDebugger::update_remote_object(ObjectID p_obj_id, const String &p_prop, const Variant &p_value) {
-
Array msg;
msg.push_back(p_obj_id);
msg.push_back(p_prop);
@@ -243,7 +238,6 @@ void ScriptEditorDebugger::update_remote_object(ObjectID p_obj_id, const String
}
void ScriptEditorDebugger::request_remote_object(ObjectID p_obj_id) {
-
ERR_FAIL_COND(p_obj_id.is_null());
Array msg;
msg.push_back(p_obj_id);
@@ -268,12 +262,10 @@ void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const
}
void ScriptEditorDebugger::_video_mem_request() {
-
_put_msg("core:memory", Array());
}
void ScriptEditorDebugger::_video_mem_export() {
-
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog->clear_filters();
@@ -282,16 +274,13 @@ void ScriptEditorDebugger::_video_mem_export() {
}
Size2 ScriptEditorDebugger::get_minimum_size() const {
-
Size2 ms = MarginContainer::get_minimum_size();
ms.y = MAX(ms.y, 250 * EDSCALE);
return ms;
}
void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) {
-
if (p_msg == "debug_enter") {
-
_put_msg("get_stack_dump", Array());
ERR_FAIL_COND(p_data.size() != 2);
@@ -310,7 +299,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
inspector->clear_cache(); // Take a chance to force remote objects update.
} else if (p_msg == "debug_exit") {
-
breaked = false;
can_debug = false;
_clear_execution();
@@ -320,27 +308,23 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
profiler->set_enabled(true);
profiler->disable_seeking();
} else if (p_msg == "set_pid") {
-
ERR_FAIL_COND(p_data.size() < 1);
remote_pid = p_data[0];
} else if (p_msg == "scene:click_ctrl") {
-
ERR_FAIL_COND(p_data.size() < 2);
clicked_ctrl->set_text(p_data[0]);
clicked_ctrl_type->set_text(p_data[1]);
} else if (p_msg == "scene:scene_tree") {
-
scene_tree->nodes.clear();
scene_tree->deserialize(p_data);
emit_signal("remote_tree_updated");
_update_buttons_state();
} else if (p_msg == "scene:inspect_object") {
-
ObjectID id = inspector->add_object(p_data);
- if (id.is_valid())
+ if (id.is_valid()) {
emit_signal("remote_object_updated", id);
+ }
} else if (p_msg == "memory:usage") {
-
vmem_tree->clear();
TreeItem *root = vmem_tree->create_item();
DebuggerMarshalls::ResourceUsage usage;
@@ -349,7 +333,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
int total = 0;
for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) {
-
TreeItem *it = vmem_tree->create_item(root);
String type = E->get().type;
int bytes = E->get().vram;
@@ -359,15 +342,15 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
it->set_text(3, String::humanize_size(bytes));
total += bytes;
- if (has_theme_icon(type, "EditorIcons"))
+ if (has_theme_icon(type, "EditorIcons")) {
it->set_icon(0, get_theme_icon(type, "EditorIcons"));
+ }
}
vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total));
vmem_total->set_text(String::humanize_size(total));
} else if (p_msg == "stack_dump") {
-
DebuggerMarshalls::ScriptStackDump stack;
stack.deserialize(p_data);
@@ -376,7 +359,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
TreeItem *r = stack_dump->create_item();
for (int i = 0; i < stack.frames.size(); i++) {
-
TreeItem *s = stack_dump->create_item(r);
Dictionary d;
d["frame"] = i;
@@ -388,15 +370,14 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"];
s->set_text(0, line);
- if (i == 0)
+ if (i == 0) {
s->select(0);
+ }
}
} else if (p_msg == "stack_frame_vars") {
-
inspector->clear_stack_variables();
} else if (p_msg == "stack_frame_var") {
-
inspector->add_stack_variable(p_data);
} else if (p_msg == "output") {
@@ -433,7 +414,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
for (int i = 0; i < p_data.size(); i++) {
p.write[i] = p_data[i];
if (i < perf_items.size()) {
-
const float value = p[i];
String label = rtos(value);
String tooltip = label;
@@ -453,8 +433,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
perf_items[i]->set_text(1, label);
perf_items[i]->set_tooltip(1, tooltip);
- if (p[i] > perf_max[i])
+ if (p[i] > perf_max[i]) {
perf_max.write[i] = p[i];
+ }
}
}
perf_history.push_front(p);
@@ -480,7 +461,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
visual_profiler->add_frame_metric(metric);
} else if (p_msg == "error") {
-
DebuggerMarshalls::OutputError oe;
ERR_FAIL_COND_MSG(oe.deserialize(p_data) == false, "Failed to deserialize error message");
@@ -520,8 +500,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
String error_title;
// Include method name, when given, in error title.
- if (!oe.source_func.empty())
+ if (!oe.source_func.empty()) {
error_title += oe.source_func + ": ";
+ }
// If we have a (custom) error message, use it as title, and add a C++ Error
// item with the original error condition.
error_title += oe.error_descr.empty() ? oe.error : oe.error_descr;
@@ -535,16 +516,18 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
cpp_cond->set_text(1, oe.error);
cpp_cond->set_text_align(0, TreeItem::ALIGN_LEFT);
tooltip += TTR("C++ Error:") + " " + oe.error + "\n";
- if (source_is_project_file)
+ if (source_is_project_file) {
cpp_cond->set_metadata(0, source_meta);
+ }
}
Vector<uint8_t> v;
v.resize(100);
// Source of the error.
String source_txt = (source_is_project_file ? oe.source_file.get_file() : oe.source_file) + ":" + itos(oe.source_line);
- if (!oe.source_func.empty())
+ if (!oe.source_func.empty()) {
source_txt += " @ " + oe.source_func + "()";
+ }
TreeItem *cpp_source = error_tree->create_item(error);
cpp_source->set_text(0, "<" + (source_is_project_file ? TTR("Source") : TTR("C++ Source")) + ">");
@@ -566,7 +549,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
// of the stack trace (script, method, line).
const ScriptLanguage::StackInfo *infos = oe.callstack.ptr();
for (unsigned int i = 0; i < (unsigned int)oe.callstack.size(); i++) {
-
TreeItem *stack_trace = error_tree->create_item(error);
Array meta;
@@ -582,10 +564,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
stack_trace->set_text(1, infos[i].file.get_file() + ":" + itos(infos[i].line) + " @ " + infos[i].func + "()");
}
- if (oe.warning)
+ if (oe.warning) {
warning_count++;
- else
+ } else {
error_count++;
+ }
} else if (p_msg == "servers:function_signature") {
// Cache a profiler signature.
@@ -639,7 +622,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
}
for (int i = 0; i < frame.servers.size(); i++) {
-
const DebuggerMarshalls::ServerInfo &srv = frame.servers[i];
EditorProfiler::Metric::Category c;
const String name = srv.name;
@@ -648,7 +630,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
c.total_time = 0;
c.signature = "categ::" + name;
for (int j = 0; j < srv.functions.size(); j++) {
-
EditorProfiler::Metric::Category::Item item;
item.calls = 1;
item.line = 0;
@@ -669,7 +650,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
funcs.name = "Script Functions";
funcs.signature = "script_functions";
for (int i = 0; i < frame.script_functions.size(); i++) {
-
int signature = frame.script_functions[i].sig_id;
int calls = frame.script_functions[i].call_count;
float total = frame.script_functions[i].total_time;
@@ -677,7 +657,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
EditorProfiler::Metric::Category::Item item;
if (profiler_signature.has(signature)) {
-
item.signature = profiler_signature[signature];
String name = profiler_signature[signature];
@@ -704,10 +683,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
metric.categories.push_back(funcs);
- if (p_msg == "servers:profile_frame")
+ if (p_msg == "servers:profile_frame") {
profiler->add_frame_metric(metric, false);
- else
+ } else {
profiler->add_frame_metric(metric, true);
+ }
} else if (p_msg == "network:profile_frame") {
DebuggerMarshalls::NetworkProfilerFrame frame;
@@ -745,17 +725,15 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType
}
void ScriptEditorDebugger::_performance_select() {
-
perf_draw->update();
}
void ScriptEditorDebugger::_performance_draw() {
-
Vector<int> which;
for (int i = 0; i < perf_items.size(); i++) {
-
- if (perf_items[i]->is_checked(0))
+ if (perf_items[i]->is_checked(0)) {
which.push_back(i);
+ }
}
if (which.empty()) {
@@ -770,14 +748,14 @@ void ScriptEditorDebugger::_performance_draw() {
int cols = Math::ceil(Math::sqrt((float)which.size()));
int rows = Math::ceil((float)which.size() / cols);
- if (which.size() == 1)
+ if (which.size() == 1) {
rows = 1;
+ }
int margin = 3;
int point_sep = 5;
Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows);
for (int i = 0; i < which.size(); i++) {
-
Point2i p(i % cols, i / cols);
Rect2i r(p * s, s);
r.position += Point2(margin, margin);
@@ -803,15 +781,16 @@ void ScriptEditorDebugger::_performance_draw() {
List<Vector<float>>::Element *E = perf_history.front();
float prev = -1;
while (from >= 0 && E) {
-
float m = perf_max[pi];
- if (m == 0)
+ if (m == 0) {
m = 0.00001;
+ }
float h2 = E->get()[pi] / m;
h2 = (1.0 - h2) * r.size.y;
- if (E != perf_history.front())
+ if (E != perf_history.front()) {
perf_draw->draw_line(r.position + Point2(from, h2), r.position + Point2(from + spacing, prev), c, Math::round(EDSCALE));
+ }
prev = h2;
E = E->next();
from -= spacing;
@@ -820,11 +799,8 @@ void ScriptEditorDebugger::_performance_draw() {
}
void ScriptEditorDebugger::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons"));
copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons"));
@@ -843,9 +819,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
} break;
case NOTIFICATION_PROCESS: {
-
if (is_session_active()) {
-
peer->poll();
if (camera_override == CameraOverride::OVERRIDE_2D) {
@@ -886,7 +860,6 @@ void ScriptEditorDebugger::_notification(int p_what) {
const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20;
while (peer.is_valid() && peer->has_message()) {
-
Array arr = peer->get_message();
if (arr.size() != 2 || arr[0].get_type() != Variant::STRING || arr[1].get_type() != Variant::ARRAY) {
_stop_and_notify();
@@ -894,8 +867,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
_parse_message(arr[0], arr[1]);
- if (OS::get_singleton()->get_ticks_msec() > until)
+ if (OS::get_singleton()->get_ticks_msec() > until) {
break;
+ }
}
if (!is_session_active()) {
_stop_and_notify();
@@ -903,7 +877,6 @@ void ScriptEditorDebugger::_notification(int p_what) {
};
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
if (tabs->has_theme_stylebox_override("panel")) {
tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles"));
}
@@ -921,8 +894,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
void ScriptEditorDebugger::_clear_execution() {
TreeItem *ti = stack_dump->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
Dictionary d = ti->get_metadata(0);
@@ -934,7 +908,6 @@ void ScriptEditorDebugger::_clear_execution() {
}
void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) {
-
error_count = 0;
warning_count = 0;
stop();
@@ -944,7 +917,6 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) {
perf_history.clear();
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
-
perf_max.write[i] = 0;
}
@@ -978,7 +950,6 @@ void ScriptEditorDebugger::_stop_and_notify() {
}
void ScriptEditorDebugger::stop() {
-
set_process(false);
breaked = false;
can_debug = false;
@@ -1003,7 +974,6 @@ void ScriptEditorDebugger::stop() {
}
void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
-
Array data;
data.push_back(p_enable);
switch (p_type) {
@@ -1031,14 +1001,13 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) {
}
void ScriptEditorDebugger::_profiler_seeked() {
-
- if (breaked)
+ if (breaked) {
return;
+ }
debug_break();
}
void ScriptEditorDebugger::_stack_dump_frame_selected() {
-
emit_signal("stack_frame_selected");
int frame = get_stack_script_frame();
@@ -1053,7 +1022,6 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
}
void ScriptEditorDebugger::_export_csv() {
-
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
file_dialog_purpose = SAVE_MONITORS_CSV;
@@ -1061,16 +1029,17 @@ void ScriptEditorDebugger::_export_csv() {
}
String ScriptEditorDebugger::get_var_value(const String &p_var) const {
- if (!breaked)
+ if (!breaked) {
return String();
+ }
return inspector->get_stack_variable(p_var);
}
int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) {
-
const int *r = node_path_cache.getptr(p_path);
- if (r)
+ if (r) {
return *r;
+ }
last_path_id++;
@@ -1084,11 +1053,11 @@ int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) {
}
int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
-
Map<String, int>::Element *E = res_path_cache.find(p_path);
- if (E)
+ if (E) {
return E->get();
+ }
last_path_id++;
@@ -1102,9 +1071,9 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
}
void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
-
- if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene())
+ if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) {
return;
+ }
Node *node = Object::cast_to<Node>(p_base);
@@ -1112,12 +1081,12 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
//no pointers, sorry
- if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID))
+ if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID)) {
return;
+ }
}
if (node) {
-
NodePath path = editor->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
@@ -1136,7 +1105,6 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
Resource *res = Object::cast_to<Resource>(p_base);
if (res && res->get_path() != String()) {
-
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
@@ -1154,21 +1122,19 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
}
void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) {
-
- if (!p_base || !live_debug || !editor->get_edited_scene())
+ if (!p_base || !live_debug || !editor->get_edited_scene()) {
return;
+ }
Node *node = Object::cast_to<Node>(p_base);
if (node) {
-
NodePath path = editor->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
if (p_value.is_ref()) {
Ref<Resource> res = p_value;
if (res.is_valid() && res->get_path() != String()) {
-
Array msg;
msg.push_back(pathid);
msg.push_back(p_property);
@@ -1176,7 +1142,6 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
_put_msg("scene:live_node_prop_res", msg);
}
} else {
-
Array msg;
msg.push_back(pathid);
msg.push_back(p_property);
@@ -1190,14 +1155,12 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
Resource *res = Object::cast_to<Resource>(p_base);
if (res && res->get_path() != String()) {
-
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
if (p_value.is_ref()) {
Ref<Resource> res2 = p_value;
if (res2.is_valid() && res2->get_path() != String()) {
-
Array msg;
msg.push_back(pathid);
msg.push_back(p_property);
@@ -1205,7 +1168,6 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
_put_msg("scene:live_res_prop_res", msg);
}
} else {
-
Array msg;
msg.push_back(pathid);
msg.push_back(p_property);
@@ -1219,41 +1181,44 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
String ScriptEditorDebugger::get_stack_script_file() const {
TreeItem *ti = stack_dump->get_selected();
- if (!ti)
+ if (!ti) {
return "";
+ }
Dictionary d = ti->get_metadata(0);
return d["file"];
}
int ScriptEditorDebugger::get_stack_script_line() const {
TreeItem *ti = stack_dump->get_selected();
- if (!ti)
+ if (!ti) {
return -1;
+ }
Dictionary d = ti->get_metadata(0);
return d["line"];
}
int ScriptEditorDebugger::get_stack_script_frame() const {
TreeItem *ti = stack_dump->get_selected();
- if (!ti)
+ if (!ti) {
return -1;
+ }
Dictionary d = ti->get_metadata(0);
return d["frame"];
}
void ScriptEditorDebugger::set_live_debugging(bool p_enable) {
-
live_debug = p_enable;
}
void ScriptEditorDebugger::_live_edit_set() {
-
- if (!is_session_active() || !editor_remote_tree)
+ if (!is_session_active() || !editor_remote_tree) {
return;
+ }
TreeItem *ti = editor_remote_tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
String path;
@@ -1271,7 +1236,6 @@ void ScriptEditorDebugger::_live_edit_set() {
}
void ScriptEditorDebugger::_live_edit_clear() {
-
NodePath np = NodePath("/root");
editor->get_editor_data().set_edited_scene_live_edit_root(np);
@@ -1279,21 +1243,20 @@ void ScriptEditorDebugger::_live_edit_clear() {
}
void ScriptEditorDebugger::update_live_edit_root() {
-
NodePath np = editor->get_editor_data().get_edited_scene_live_edit_root();
Array msg;
msg.push_back(np);
- if (editor->get_edited_scene())
+ if (editor->get_edited_scene()) {
msg.push_back(editor->get_edited_scene()->get_filename());
- else
+ } else {
msg.push_back("");
+ }
_put_msg("scene:live_set_root", msg);
live_edit_root->set_text(np);
}
void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) {
-
if (live_debug) {
Array msg;
msg.push_back(p_parent);
@@ -1304,7 +1267,6 @@ void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, cons
}
void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
-
if (live_debug) {
Array msg;
msg.push_back(p_parent);
@@ -1313,16 +1275,16 @@ void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, co
_put_msg("scene:live_instance_node", msg);
}
}
-void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) {
+void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) {
if (live_debug) {
Array msg;
msg.push_back(p_at);
_put_msg("scene:live_remove_node", msg);
}
}
-void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) {
+void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) {
if (live_debug) {
Array msg;
msg.push_back(p_at);
@@ -1330,8 +1292,8 @@ void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at,
_put_msg("scene:live_remove_and_keep_node", msg);
}
}
-void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
+void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
if (live_debug) {
Array msg;
msg.push_back(p_id);
@@ -1340,8 +1302,8 @@ void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath
_put_msg("scene:live_restore_node", msg);
}
}
-void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) {
+void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) {
if (live_debug) {
Array msg;
msg.push_back(p_at);
@@ -1349,8 +1311,8 @@ void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const
_put_msg("scene:live_duplicate_node", msg);
}
}
-void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
+void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
if (live_debug) {
Array msg;
msg.push_back(p_at);
@@ -1366,7 +1328,6 @@ CameraOverride ScriptEditorDebugger::get_camera_override() const {
}
void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) {
-
if (p_override == CameraOverride::OVERRIDE_2D && camera_override != CameraOverride::OVERRIDE_2D) {
Array msg;
msg.push_back(true);
@@ -1389,7 +1350,6 @@ void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) {
}
void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool p_enabled) {
-
Array msg;
msg.push_back(p_path);
msg.push_back(p_line);
@@ -1398,7 +1358,6 @@ void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool
}
void ScriptEditorDebugger::reload_scripts() {
-
_put_msg("reload_scripts", Array());
}
@@ -1426,10 +1385,10 @@ void ScriptEditorDebugger::_error_selected() {
}
void ScriptEditorDebugger::_expand_errors_list() {
-
TreeItem *root = error_tree->get_root();
- if (!root)
+ if (!root) {
return;
+ }
TreeItem *item = root->get_children();
while (item) {
@@ -1439,10 +1398,10 @@ void ScriptEditorDebugger::_expand_errors_list() {
}
void ScriptEditorDebugger::_collapse_errors_list() {
-
TreeItem *root = error_tree->get_root();
- if (!root)
+ if (!root) {
return;
+ }
TreeItem *item = root->get_children();
while (item) {
@@ -1452,7 +1411,6 @@ void ScriptEditorDebugger::_collapse_errors_list() {
}
void ScriptEditorDebugger::_clear_errors_list() {
-
error_tree->clear();
error_count = 0;
warning_count = 0;
@@ -1460,7 +1418,6 @@ void ScriptEditorDebugger::_clear_errors_list() {
// Right click on specific file(s) or folder(s).
void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
-
item_menu->clear();
item_menu->set_size(Size2(1, 1));
@@ -1476,8 +1433,9 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
TreeItem *ti = error_tree->get_selected();
- while (ti->get_parent() != error_tree->get_root())
+ while (ti->get_parent() != error_tree->get_root()) {
ti = ti->get_parent();
+ }
String type;
@@ -1508,7 +1466,6 @@ void ScriptEditorDebugger::_tab_changed(int p_tab) {
}
void ScriptEditorDebugger::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("live_debug_create_node"), &ScriptEditorDebugger::live_debug_create_node);
ClassDB::bind_method(D_METHOD("live_debug_instance_node"), &ScriptEditorDebugger::live_debug_instance_node);
ClassDB::bind_method(D_METHOD("live_debug_remove_node"), &ScriptEditorDebugger::live_debug_remove_node);
@@ -1533,7 +1490,6 @@ void ScriptEditorDebugger::_bind_methods() {
}
ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
-
editor = p_editor;
tabs = memnew(TabContainer);
@@ -1729,7 +1685,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
TreeItem *root = perf_monitors->create_item();
perf_monitors->set_hide_root(true);
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
-
String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
Performance::MonitorType mtype = Performance::get_singleton()->get_monitor_type(Performance::Monitor(i));
String base = n.get_slice("/", 0);
@@ -1866,7 +1821,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
}
ScriptEditorDebugger::~ScriptEditorDebugger() {
-
if (peer.is_valid()) {
peer->close();
peer.unref();
diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h
index a08a7c67c2..2984051aa1 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -55,7 +55,6 @@ class EditorNetworkProfiler;
class SceneDebuggerTree;
class ScriptEditorDebugger : public MarginContainer {
-
GDCLASS(ScriptEditorDebugger, MarginContainer);
friend class EditorDebuggerNode;
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 2302fb0780..c6977779bd 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -37,7 +37,6 @@
#include "scene/gui/margin_container.h"
void DependencyEditor::_searched(const String &p_path) {
-
Map<String, String> dep_rename;
dep_rename[replacing] = p_path;
@@ -48,7 +47,6 @@ void DependencyEditor::_searched(const String &p_path) {
}
void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
replacing = ti->get_text(1);
@@ -64,21 +62,19 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
}
void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates) {
-
for (int i = 0; i < efsd->get_subdir_count(); i++) {
_fix_and_find(efsd->get_subdir(i), candidates);
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
String file = efsd->get_file(i);
- if (!candidates.has(file))
+ if (!candidates.has(file)) {
continue;
+ }
String path = efsd->get_file_path(i);
for (Map<String, String>::Element *E = candidates[file].front(); E; E = E->next()) {
-
if (E->get() == String()) {
E->get() = path;
continue;
@@ -100,7 +96,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
int current_score = 0;
for (int j = 0; j < lostv.size(); j++) {
-
if (j < existingv.size() && lostv[j] == existingv[j]) {
existing_score++;
}
@@ -110,7 +105,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
}
if (current_score > existing_score) {
-
//if it was the same, could track distance to new path but..
E->get() = path; //replace by more accurate
@@ -120,14 +114,13 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
}
void DependencyEditor::_fix_all() {
-
- if (!EditorFileSystem::get_singleton()->get_filesystem())
+ if (!EditorFileSystem::get_singleton()->get_filesystem()) {
return;
+ }
Map<String, Map<String, String>> candidates;
for (List<String>::Element *E = missing.front(); E; E = E->next()) {
-
String base = E->get().get_file();
if (!candidates.has(base)) {
candidates[base] = Map<String, String>();
@@ -141,9 +134,7 @@ void DependencyEditor::_fix_all() {
Map<String, String> remaps;
for (Map<String, Map<String, String>>::Element *E = candidates.front(); E; E = E->next()) {
-
for (Map<String, String>::Element *F = E->get().front(); F; F = F->next()) {
-
if (F->get() != String()) {
remaps[F->key()] = F->get();
}
@@ -151,7 +142,6 @@ void DependencyEditor::_fix_all() {
}
if (remaps.size()) {
-
ResourceLoader::rename_dependencies(editing, remaps);
_update_list();
@@ -160,12 +150,10 @@ void DependencyEditor::_fix_all() {
}
void DependencyEditor::_update_file() {
-
EditorFileSystem::get_singleton()->update_file(editing);
}
void DependencyEditor::_update_list() {
-
List<String> deps;
ResourceLoader::get_dependencies(editing, &deps, true);
@@ -179,7 +167,6 @@ void DependencyEditor::_update_list() {
bool broken = false;
for (List<String>::Element *E = deps.front(); E; E = E->next()) {
-
TreeItem *item = tree->create_item(root);
String n = E->get();
@@ -214,7 +201,6 @@ void DependencyEditor::_update_list() {
}
void DependencyEditor::edit(const String &p_path) {
-
editing = p_path;
set_title(TTR("Dependencies For:") + " " + p_path.get_file());
@@ -232,7 +218,6 @@ void DependencyEditor::_bind_methods() {
}
DependencyEditor::DependencyEditor() {
-
VBoxContainer *vb = memnew(VBoxContainer);
vb->set_name(TTR("Dependencies"));
add_child(vb);
@@ -271,7 +256,6 @@ DependencyEditor::DependencyEditor() {
/////////////////////////////////////
void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos) {
-
file_options->clear();
file_options->set_size(Size2(1, 1));
if (p_item >= 0) {
@@ -283,7 +267,6 @@ void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos)
}
void DependencyEditorOwners::_select_file(int p_idx) {
-
String fpath = owners->get_item_text(p_idx);
if (ResourceLoader::get_resource_type(fpath) == "PackedScene") {
@@ -294,12 +277,12 @@ void DependencyEditorOwners::_select_file(int p_idx) {
}
void DependencyEditorOwners::_file_option(int p_option) {
-
switch (p_option) {
case FILE_OPEN: {
int idx = owners->get_current();
- if (idx < 0 || idx >= owners->get_item_count())
+ if (idx < 0 || idx >= owners->get_item_count()) {
break;
+ }
_select_file(idx);
} break;
}
@@ -309,16 +292,15 @@ void DependencyEditorOwners::_bind_methods() {
}
void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
-
- if (!efsd)
+ if (!efsd) {
return;
+ }
for (int i = 0; i < efsd->get_subdir_count(); i++) {
_fill_owners(efsd->get_subdir(i));
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
Vector<String> deps = efsd->get_file_deps(i);
bool found = false;
for (int j = 0; j < deps.size(); j++) {
@@ -327,8 +309,9 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
break;
}
}
- if (!found)
+ if (!found) {
continue;
+ }
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i));
@@ -337,7 +320,6 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
}
void DependencyEditorOwners::show(const String &p_path) {
-
editing = p_path;
owners->clear();
_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());
@@ -347,7 +329,6 @@ void DependencyEditorOwners::show(const String &p_path) {
}
DependencyEditorOwners::DependencyEditorOwners(EditorNode *p_editor) {
-
editor = p_editor;
file_options = memnew(PopupMenu);
@@ -365,8 +346,9 @@ DependencyEditorOwners::DependencyEditorOwners(EditorNode *p_editor) {
///////////////////////
void DependencyRemoveDialog::_find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder) {
- if (!efsd)
+ if (!efsd) {
return;
+ }
for (int i = 0; i < efsd->get_subdir_count(); ++i) {
_find_files_in_removed_folder(efsd->get_subdir(i), p_folder);
@@ -379,8 +361,9 @@ void DependencyRemoveDialog::_find_files_in_removed_folder(EditorFileSystemDirec
}
void DependencyRemoveDialog::_find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed) {
- if (!efsd)
+ if (!efsd) {
return;
+ }
for (int i = 0; i < efsd->get_subdir_count(); i++) {
_find_all_removed_dependencies(efsd->get_subdir(i), p_removed);
@@ -390,8 +373,9 @@ void DependencyRemoveDialog::_find_all_removed_dependencies(EditorFileSystemDire
const String path = efsd->get_file_path(i);
//It doesn't matter if a file we are about to delete will have some of its dependencies removed too
- if (all_remove_files.has(path))
+ if (all_remove_files.has(path)) {
continue;
+ }
Vector<String> all_deps = efsd->get_file_deps(i);
for (int j = 0; j < all_deps.size(); ++j) {
@@ -479,7 +463,6 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
}
void DependencyRemoveDialog::ok_pressed() {
-
for (int i = 0; i < files_to_delete.size(); ++i) {
if (ResourceCache::has(files_to_delete[i])) {
Resource *res = ResourceCache::get(files_to_delete[i]);
@@ -525,10 +508,10 @@ void DependencyRemoveDialog::ok_pressed() {
if (dirs_to_delete.size() == 0) {
// If we only deleted files we should only need to tell the file system about the files we touched.
- for (int i = 0; i < files_to_delete.size(); ++i)
+ for (int i = 0; i < files_to_delete.size(); ++i) {
EditorFileSystem::get_singleton()->update_file(files_to_delete[i]);
+ }
} else {
-
for (int i = 0; i < dirs_to_delete.size(); ++i) {
String path = OS::get_singleton()->get_resource_dir() + dirs_to_delete[i].replace_first("res://", "/");
print_verbose("Moving to trash: " + path);
@@ -549,11 +532,13 @@ void DependencyRemoveDialog::ok_pressed() {
for (int i = 0; i < previous_favorites.size(); ++i) {
if (previous_favorites[i].ends_with("/")) {
- if (dirs_to_delete.find(previous_favorites[i]) < 0)
+ if (dirs_to_delete.find(previous_favorites[i]) < 0) {
new_favorites.push_back(previous_favorites[i]);
+ }
} else {
- if (files_to_delete.find(previous_favorites[i]) < 0)
+ if (files_to_delete.find(previous_favorites[i]) < 0) {
new_favorites.push_back(previous_favorites[i]);
+ }
}
}
@@ -568,7 +553,6 @@ void DependencyRemoveDialog::_bind_methods() {
}
DependencyRemoveDialog::DependencyRemoveDialog() {
-
get_ok()->set_text(TTR("Remove"));
VBoxContainer *vb = memnew(VBoxContainer);
@@ -586,7 +570,6 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
//////////////
void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Vector<String> &report) {
-
mode = p_mode;
for_file = p_for_file;
set_title(TTR("Error loading:") + " " + p_for_file.get_file());
@@ -594,12 +577,12 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve
TreeItem *root = files->create_item(nullptr);
for (int i = 0; i < report.size(); i++) {
-
String dep;
String type = "Object";
dep = report[i].get_slice("::", 0);
- if (report[i].get_slice_count("::") > 0)
+ if (report[i].get_slice_count("::") > 0) {
type = report[i].get_slice("::", 1);
+ }
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type);
@@ -612,7 +595,6 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve
}
void DependencyErrorDialog::ok_pressed() {
-
switch (mode) {
case MODE_SCENE:
EditorNode::get_singleton()->load_scene(for_file, true);
@@ -624,12 +606,10 @@ void DependencyErrorDialog::ok_pressed() {
}
void DependencyErrorDialog::custom_action(const String &) {
-
EditorNode::get_singleton()->fix_dependencies(for_file);
}
DependencyErrorDialog::DependencyErrorDialog() {
-
VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
@@ -654,26 +634,25 @@ DependencyErrorDialog::DependencyErrorDialog() {
//////////////////////////////////////////////////////////////////////
void OrphanResourcesDialog::ok_pressed() {
-
paths.clear();
_find_to_delete(files->get_root(), paths);
- if (paths.empty())
+ if (paths.empty()) {
return;
+ }
delete_confirm->set_text(vformat(TTR("Permanently delete %d item(s)? (No undo!)"), paths.size()));
delete_confirm->popup_centered();
}
bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) {
-
- if (!efsd)
+ if (!efsd) {
return false;
+ }
bool has_children = false;
for (int i = 0; i < efsd->get_subdir_count(); i++) {
-
TreeItem *dir_item = nullptr;
if (p_parent) {
dir_item = files->create_item(p_parent);
@@ -692,17 +671,14 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
if (!p_parent) {
Vector<String> deps = efsd->get_file_deps(i);
for (int j = 0; j < deps.size(); j++) {
-
if (!refs.has(deps[j])) {
refs[deps[j]] = 1;
}
}
} else {
-
String path = efsd->get_file_path(i);
if (!refs.has(path)) {
TreeItem *ti = files->create_item(p_parent);
@@ -737,15 +713,12 @@ void OrphanResourcesDialog::refresh() {
}
void OrphanResourcesDialog::show() {
-
refresh();
popup_centered_ratio();
}
void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) {
-
while (p_item) {
-
if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) {
paths.push_back(p_item->get_metadata(0));
}
@@ -759,10 +732,8 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path
}
void OrphanResourcesDialog::_delete_confirm() {
-
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
for (List<String>::Element *E = paths.front(); E; E = E->next()) {
-
da->remove(E->get());
EditorFileSystem::get_singleton()->update_file(E->get());
}
@@ -771,7 +742,6 @@ void OrphanResourcesDialog::_delete_confirm() {
}
void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String path = ti->get_metadata(0);
@@ -782,7 +752,6 @@ void OrphanResourcesDialog::_bind_methods() {
}
OrphanResourcesDialog::OrphanResourcesDialog() {
-
set_title(TTR("Orphan Resource Explorer"));
delete_confirm = memnew(ConfirmationDialog);
get_ok()->set_text(TTR("Delete"));
diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp
index 7169986b14..276cd12ded 100644
--- a/editor/dictionary_property_edit.cpp
+++ b/editor/dictionary_property_edit.cpp
@@ -40,34 +40,33 @@ void DictionaryPropertyEdit::_notif_changev(const String &p_v) {
}
void DictionaryPropertyEdit::_set_key(const Variant &p_old_key, const Variant &p_new_key) {
-
// TODO: Set key of a dictionary is not allowed yet
}
void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_value) {
-
Dictionary dict = get_dictionary();
dict[p_key] = p_value;
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return;
+ }
o->set(property, dict);
}
Variant DictionaryPropertyEdit::get_dictionary() const {
-
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return Dictionary();
+ }
Variant dict = o->get(property);
- if (dict.get_type() != Variant::DICTIONARY)
+ if (dict.get_type() != Variant::DICTIONARY) {
return Dictionary();
+ }
return dict;
}
void DictionaryPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const {
-
Dictionary dict = get_dictionary();
Array keys = dict.keys();
@@ -87,16 +86,15 @@ void DictionaryPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) cons
}
void DictionaryPropertyEdit::edit(Object *p_obj, const StringName &p_prop) {
-
property = p_prop;
obj = p_obj->get_instance_id();
}
Node *DictionaryPropertyEdit::get_node() {
-
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return nullptr;
+ }
return cast_to<Node>(o);
}
@@ -106,7 +104,6 @@ bool DictionaryPropertyEdit::_dont_undo_redo() {
}
void DictionaryPropertyEdit::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_key"), &DictionaryPropertyEdit::_set_key);
ClassDB::bind_method(D_METHOD("_set_value"), &DictionaryPropertyEdit::_set_value);
ClassDB::bind_method(D_METHOD("_notif_change"), &DictionaryPropertyEdit::_notif_change);
@@ -115,7 +112,6 @@ void DictionaryPropertyEdit::_bind_methods() {
}
bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
-
Dictionary dict = get_dictionary();
Array keys = dict.keys();
keys.sort();
@@ -126,7 +122,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val
String type = pn.substr(slash + 2, pn.length());
int index = pn.substr(0, slash).to_int();
if (type == "key" && index < keys.size()) {
-
const Variant &key = keys[index];
UndoRedo *ur = EditorNode::get_undo_redo();
@@ -141,7 +136,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val
} else if (type == "value" && index < keys.size()) {
const Variant &key = keys[index];
if (dict.has(key)) {
-
Variant value = dict[key];
UndoRedo *ur = EditorNode::get_undo_redo();
@@ -161,7 +155,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val
}
bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const {
-
Dictionary dict = get_dictionary();
Array keys = dict.keys();
keys.sort();
@@ -170,7 +163,6 @@ bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) cons
int slash = pn.find(": ");
if (slash != -1 && pn.length() > slash) {
-
String type = pn.substr(slash + 2, pn.length());
int index = pn.substr(0, slash).to_int();
diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp
index 310e78ee60..c52d91b03d 100644
--- a/editor/doc_data.cpp
+++ b/editor/doc_data.cpp
@@ -44,13 +44,12 @@
#include "modules/modules_enabled.gen.h"
void DocData::merge_from(const DocData &p_data) {
-
for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
-
ClassDoc &c = E->get();
- if (!p_data.class_list.has(c.name))
+ if (!p_data.class_list.has(c.name)) {
continue;
+ }
const ClassDoc &cf = p_data.class_list[c.name];
@@ -59,37 +58,42 @@ void DocData::merge_from(const DocData &p_data) {
c.tutorials = cf.tutorials;
for (int i = 0; i < c.methods.size(); i++) {
-
MethodDoc &m = c.methods.write[i];
for (int j = 0; j < cf.methods.size(); j++) {
-
- if (cf.methods[j].name != m.name)
+ if (cf.methods[j].name != m.name) {
continue;
- if (cf.methods[j].arguments.size() != m.arguments.size())
+ }
+ if (cf.methods[j].arguments.size() != m.arguments.size()) {
continue;
+ }
// since polymorphic functions are allowed we need to check the type of
// the arguments so we make sure they are different.
int arg_count = cf.methods[j].arguments.size();
Vector<bool> arg_used;
arg_used.resize(arg_count);
- for (int l = 0; l < arg_count; ++l)
+ for (int l = 0; l < arg_count; ++l) {
arg_used.write[l] = false;
+ }
// also there is no guarantee that argument ordering will match, so we
// have to check one by one so we make sure we have an exact match
for (int k = 0; k < arg_count; ++k) {
- for (int l = 0; l < arg_count; ++l)
+ for (int l = 0; l < arg_count; ++l) {
if (cf.methods[j].arguments[k].type == m.arguments[l].type && !arg_used[l]) {
arg_used.write[l] = true;
break;
}
+ }
}
bool not_the_same = false;
- for (int l = 0; l < arg_count; ++l)
- if (!arg_used[l]) // at least one of the arguments was different
+ for (int l = 0; l < arg_count; ++l) {
+ if (!arg_used[l]) { // at least one of the arguments was different
not_the_same = true;
- if (not_the_same)
+ }
+ }
+ if (not_the_same) {
continue;
+ }
const MethodDoc &mf = cf.methods[j];
@@ -99,13 +103,12 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.signals.size(); i++) {
-
MethodDoc &m = c.signals.write[i];
for (int j = 0; j < cf.signals.size(); j++) {
-
- if (cf.signals[j].name != m.name)
+ if (cf.signals[j].name != m.name) {
continue;
+ }
const MethodDoc &mf = cf.signals[j];
m.description = mf.description;
@@ -114,13 +117,12 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.constants.size(); i++) {
-
ConstantDoc &m = c.constants.write[i];
for (int j = 0; j < cf.constants.size(); j++) {
-
- if (cf.constants[j].name != m.name)
+ if (cf.constants[j].name != m.name) {
continue;
+ }
const ConstantDoc &mf = cf.constants[j];
m.description = mf.description;
@@ -129,13 +131,12 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.properties.size(); i++) {
-
PropertyDoc &p = c.properties.write[i];
for (int j = 0; j < cf.properties.size(); j++) {
-
- if (cf.properties[j].name != p.name)
+ if (cf.properties[j].name != p.name) {
continue;
+ }
const PropertyDoc &pf = cf.properties[j];
p.description = pf.description;
@@ -144,13 +145,12 @@ void DocData::merge_from(const DocData &p_data) {
}
for (int i = 0; i < c.theme_properties.size(); i++) {
-
PropertyDoc &p = c.theme_properties.write[i];
for (int j = 0; j < cf.theme_properties.size(); j++) {
-
- if (cf.theme_properties[j].name != p.name)
+ if (cf.theme_properties[j].name != p.name) {
continue;
+ }
const PropertyDoc &pf = cf.theme_properties[j];
p.description = pf.description;
@@ -179,17 +179,18 @@ void DocData::merge_from(const DocData &p_data) {
void DocData::remove_from(const DocData &p_data) {
for (Map<String, ClassDoc>::Element *E = p_data.class_list.front(); E; E = E->next()) {
- if (class_list.has(E->key()))
+ if (class_list.has(E->key())) {
class_list.erase(E->key());
+ }
}
}
static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo) {
-
if (p_retinfo.type == Variant::INT && p_retinfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
p_method.return_enum = p_retinfo.class_name;
- if (p_method.return_enum.begins_with("_")) //proxy class
+ if (p_method.return_enum.begins_with("_")) { //proxy class
p_method.return_enum = p_method.return_enum.substr(1, p_method.return_enum.length());
+ }
p_method.return_type = "int";
} else if (p_retinfo.class_name != StringName()) {
p_method.return_type = p_retinfo.class_name;
@@ -207,13 +208,13 @@ static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const Property
}
static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo) {
-
p_argument.name = p_arginfo.name;
if (p_arginfo.type == Variant::INT && p_arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
p_argument.enumeration = p_arginfo.class_name;
- if (p_argument.enumeration.begins_with("_")) //proxy class
+ if (p_argument.enumeration.begins_with("_")) { //proxy class
p_argument.enumeration = p_argument.enumeration.substr(1, p_argument.enumeration.length());
+ }
p_argument.type = "int";
} else if (p_arginfo.class_name != StringName()) {
p_argument.type = p_arginfo.class_name;
@@ -230,7 +231,6 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr
}
static Variant get_documentation_default_value(const StringName &p_class_name, const StringName &p_property_name, bool &r_default_value_valid) {
-
Variant default_value = Variant();
r_default_value_valid = false;
@@ -243,8 +243,9 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c
for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
if (ClassDB::can_instance(E2->get())) {
default_value = ClassDB::class_get_default_property_value(E2->get(), p_property_name, &r_default_value_valid);
- if (r_default_value_valid)
+ if (r_default_value_valid) {
break;
+ }
}
}
}
@@ -253,7 +254,6 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c
}
void DocData::generate(bool p_basic_types) {
-
List<StringName> classes;
ClassDB::get_class_list(&classes);
classes.sort_custom<StringName::AlphCompare>();
@@ -263,7 +263,6 @@ void DocData::generate(bool p_basic_types) {
bool skip_setter_getter_methods = true;
while (classes.size()) {
-
Set<StringName> setters_getters;
String name = classes.front()->get();
@@ -274,8 +273,9 @@ void DocData::generate(bool p_basic_types) {
}
String cname = name;
- if (cname.begins_with("_")) //proxy class
+ if (cname.begins_with("_")) { //proxy class
cname = cname.substr(1, name.length());
+ }
class_list[cname] = ClassDoc();
ClassDoc &c = class_list[cname];
@@ -301,8 +301,9 @@ void DocData::generate(bool p_basic_types) {
EO = EO->next();
}
- if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL)
+ if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) {
continue;
+ }
PropertyDoc prop;
@@ -329,8 +330,9 @@ void DocData::generate(bool p_basic_types) {
if (inherited) {
bool base_default_value_valid = false;
Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid);
- if (!default_value_valid || !base_default_value_valid || default_value == base_default_value)
+ if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) {
continue;
+ }
}
}
@@ -361,10 +363,8 @@ void DocData::generate(bool p_basic_types) {
} else if (retinfo.type == Variant::ARRAY && retinfo.hint == PROPERTY_HINT_ARRAY_TYPE) {
prop.type = retinfo.hint_string + "[]";
} else if (retinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
-
prop.type = retinfo.hint_string;
} else if (retinfo.type == Variant::NIL && retinfo.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
-
prop.type = "Variant";
} else if (retinfo.type == Variant::NIL) {
prop.type = "void";
@@ -377,16 +377,15 @@ void DocData::generate(bool p_basic_types) {
}
if (setter != StringName()) {
-
setters_getters.insert(setter);
}
if (!found_type) {
-
- if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE)
+ if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) {
prop.type = E->get().hint_string;
- else
+ } else {
prop.type = Variant::get_type_name(E->get().type);
+ }
}
c.properties.push_back(prop);
@@ -397,9 +396,9 @@ void DocData::generate(bool p_basic_types) {
method_list.sort();
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
-
- if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL)))
+ if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) {
continue; //hidden, don't count
+ }
if (skip_setter_getter_methods && setters_getters.has(E->get().name)) {
// Don't skip parametric setters and getters, i.e. method which require
@@ -414,27 +413,28 @@ void DocData::generate(bool p_basic_types) {
method.name = E->get().name;
- if (E->get().flags & METHOD_FLAG_VIRTUAL)
+ if (E->get().flags & METHOD_FLAG_VIRTUAL) {
method.qualifiers = "virtual";
+ }
if (E->get().flags & METHOD_FLAG_CONST) {
- if (method.qualifiers != "")
+ if (method.qualifiers != "") {
method.qualifiers += " ";
+ }
method.qualifiers += "const";
} else if (E->get().flags & METHOD_FLAG_VARARG) {
- if (method.qualifiers != "")
+ if (method.qualifiers != "") {
method.qualifiers += " ";
+ }
method.qualifiers += "vararg";
}
for (int i = -1; i < E->get().arguments.size(); i++) {
-
if (i == -1) {
#ifdef DEBUG_METHODS_ENABLED
return_doc_from_retinfo(method, E->get().return_val);
#endif
} else {
-
const PropertyInfo &arginfo = E->get().arguments[i];
ArgumentDoc argument;
argument_doc_from_arginfo(argument, arginfo);
@@ -456,13 +456,10 @@ void DocData::generate(bool p_basic_types) {
ClassDB::get_signal_list(name, &signal_list, true);
if (signal_list.size()) {
-
for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
-
MethodDoc signal;
signal.name = EV->get().name;
for (int i = 0; i < EV->get().arguments.size(); i++) {
-
const PropertyInfo &arginfo = EV->get().arguments[i];
ArgumentDoc argument;
argument_doc_from_arginfo(argument, arginfo);
@@ -478,7 +475,6 @@ void DocData::generate(bool p_basic_types) {
ClassDB::get_integer_constant_list(name, &constant_list, true);
for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
-
ConstantDoc constant;
constant.name = E->get();
constant.value = itos(ClassDB::get_integer_constant(name, E->get()));
@@ -492,7 +488,6 @@ void DocData::generate(bool p_basic_types) {
List<StringName> l;
Theme::get_default()->get_constant_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
-
PropertyDoc pd;
pd.name = E->get();
pd.type = "int";
@@ -503,7 +498,6 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_color_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
-
PropertyDoc pd;
pd.name = E->get();
pd.type = "Color";
@@ -514,7 +508,6 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_icon_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
-
PropertyDoc pd;
pd.name = E->get();
pd.type = "Texture2D";
@@ -523,7 +516,6 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_font_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
-
PropertyDoc pd;
pd.name = E->get();
pd.type = "Font";
@@ -532,7 +524,6 @@ void DocData::generate(bool p_basic_types) {
l.clear();
Theme::get_default()->get_stylebox_list(cname, &l);
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
-
PropertyDoc pd;
pd.name = E->get();
pd.type = "StyleBox";
@@ -549,15 +540,18 @@ void DocData::generate(bool p_basic_types) {
class_list["Variant"].name = "Variant";
}
- if (!p_basic_types)
+ if (!p_basic_types) {
return;
+ }
// Add Variant types.
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i == Variant::NIL)
+ if (i == Variant::NIL) {
continue; // Not exposed outside of 'null', should not be in class list.
- if (i == Variant::OBJECT)
+ }
+ if (i == Variant::OBJECT) {
continue; // Use the core type instead.
+ }
String cname = Variant::get_type_name(Variant::Type(i));
@@ -574,14 +568,12 @@ void DocData::generate(bool p_basic_types) {
Variant::get_constructor_list(Variant::Type(i), &method_list);
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
-
MethodInfo &mi = E->get();
MethodDoc method;
method.name = mi.name;
for (int j = 0; j < mi.arguments.size(); j++) {
-
PropertyInfo arginfo = mi.arguments[j];
ArgumentDoc ad;
argument_doc_from_arginfo(ad, mi.arguments[j]);
@@ -599,8 +591,9 @@ void DocData::generate(bool p_basic_types) {
return_doc_from_retinfo(method, mi.return_val);
if (mi.flags & METHOD_FLAG_VARARG) {
- if (method.qualifiers != "")
+ if (method.qualifiers != "") {
method.qualifiers += " ";
+ }
method.qualifiers += "vararg";
}
@@ -610,7 +603,6 @@ void DocData::generate(bool p_basic_types) {
List<PropertyInfo> properties;
v.get_property_list(&properties);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
-
PropertyInfo pi = E->get();
PropertyDoc property;
property.name = pi.name;
@@ -624,7 +616,6 @@ void DocData::generate(bool p_basic_types) {
Variant::get_constants_for_type(Variant::Type(i), &constants);
for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
-
ConstantDoc constant;
constant.name = E->get();
Variant value = Variant::get_constant_value(Variant::Type(i), E->get());
@@ -636,14 +627,12 @@ void DocData::generate(bool p_basic_types) {
//built in constants and functions
{
-
String cname = "@GlobalScope";
class_list[cname] = ClassDoc();
ClassDoc &c = class_list[cname];
c.name = cname;
for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
-
ConstantDoc cd;
cd.name = GlobalConstants::get_global_constant_name(i);
cd.value = itos(GlobalConstants::get_global_constant_value(i));
@@ -656,7 +645,6 @@ void DocData::generate(bool p_basic_types) {
//servers (this is kind of hackish)
for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
-
PropertyDoc pd;
Engine::Singleton &s = E->get();
if (!s.ptr) {
@@ -664,10 +652,12 @@ void DocData::generate(bool p_basic_types) {
}
pd.name = s.name;
pd.type = s.ptr->get_class();
- while (String(ClassDB::get_parent_class(pd.type)) != "Object")
+ while (String(ClassDB::get_parent_class(pd.type)) != "Object") {
pd.type = ClassDB::get_parent_class(pd.type);
- if (pd.type.begins_with("_"))
+ }
+ if (pd.type.begins_with("_")) {
pd.type = pd.type.substr(1, pd.type.length());
+ }
c.properties.push_back(pd);
}
}
@@ -675,9 +665,7 @@ void DocData::generate(bool p_basic_types) {
//built in script reference
{
-
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
-
ScriptLanguage *lang = ScriptServer::get_language(i);
String cname = "@" + lang->get_name();
class_list[cname] = ClassDoc();
@@ -689,21 +677,20 @@ void DocData::generate(bool p_basic_types) {
lang->get_public_functions(&minfo);
for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) {
-
MethodInfo &mi = E->get();
MethodDoc md;
md.name = mi.name;
if (mi.flags & METHOD_FLAG_VARARG) {
- if (md.qualifiers != "")
+ if (md.qualifiers != "") {
md.qualifiers += " ";
+ }
md.qualifiers += "vararg";
}
return_doc_from_retinfo(md, mi.return_val);
for (int j = 0; j < mi.arguments.size(); j++) {
-
ArgumentDoc ad;
argument_doc_from_arginfo(ad, mi.arguments[j]);
@@ -723,7 +710,6 @@ void DocData::generate(bool p_basic_types) {
lang->get_public_constants(&cinfo);
for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) {
-
ConstantDoc cd;
cd.name = E->get().first;
cd.value = E->get().second;
@@ -734,36 +720,29 @@ void DocData::generate(bool p_basic_types) {
}
static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) {
-
String section = parser->get_node_name();
String element = section.substr(0, section.length() - 1);
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser->get_node_name() == element) {
-
DocData::MethodDoc method;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
method.name = parser->get_attribute_value("name");
- if (parser->has_attribute("qualifiers"))
+ if (parser->has_attribute("qualifiers")) {
method.qualifiers = parser->get_attribute_value("qualifiers");
+ }
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser->get_node_name();
if (name == "return") {
-
ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
method.return_type = parser->get_attribute_value("type");
if (parser->has_attribute("enum")) {
method.return_enum = parser->get_attribute_value("enum");
}
} else if (name == "argument") {
-
DocData::ArgumentDoc argument;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
argument.name = parser->get_attribute_value("name");
@@ -776,14 +755,15 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &
method.arguments.push_back(argument);
} else if (name == "description") {
-
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
method.description = parser->get_node_data();
+ }
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element)
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element) {
break;
+ }
}
methods.push_back(method);
@@ -792,15 +772,15 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + parser->get_node_name() + ".");
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == section)
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == section) {
break;
+ }
}
return OK;
}
Error DocData::load_classes(const String &p_dir) {
-
Error err;
DirAccessRef da = DirAccess::open(p_dir, &err);
if (!da) {
@@ -814,8 +794,9 @@ Error DocData::load_classes(const String &p_dir) {
if (!da->current_is_dir() && path.ends_with("xml")) {
Ref<XMLParser> parser = memnew(XMLParser);
Error err2 = parser->open(p_dir.plus_file(path));
- if (err2)
+ if (err2) {
return err2;
+ }
_load(parser);
}
@@ -826,8 +807,8 @@ Error DocData::load_classes(const String &p_dir) {
return OK;
}
-Error DocData::erase_classes(const String &p_dir) {
+Error DocData::erase_classes(const String &p_dir) {
Error err;
DirAccessRef da = DirAccess::open(p_dir, &err);
if (!da) {
@@ -854,18 +835,18 @@ Error DocData::erase_classes(const String &p_dir) {
return OK;
}
-Error DocData::_load(Ref<XMLParser> parser) {
+Error DocData::_load(Ref<XMLParser> parser) {
Error err = OK;
while ((err = parser->read()) == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT && parser->get_node_name() == "?xml") {
parser->skip_section();
}
- if (parser->get_node_type() != XMLParser::NODE_ELEMENT)
+ if (parser->get_node_type() != XMLParser::NODE_ELEMENT) {
continue; //no idea what this may be, but skipping anyway
+ }
ERR_FAIL_COND_V(parser->get_node_name() != "class", ERR_FILE_CORRUPT);
@@ -875,98 +856,97 @@ Error DocData::_load(Ref<XMLParser> parser) {
ClassDoc &c = class_list[name];
c.name = name;
- if (parser->has_attribute("inherits"))
+ if (parser->has_attribute("inherits")) {
c.inherits = parser->get_attribute_value("inherits");
+ }
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name2 = parser->get_node_name();
if (name2 == "brief_description") {
-
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
c.brief_description = parser->get_node_data();
+ }
} else if (name2 == "description") {
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
c.description = parser->get_node_data();
+ }
} else if (name2 == "tutorials") {
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name3 = parser->get_node_name();
if (name3 == "link") {
-
+ TutorialDoc tutorial;
+ if (parser->has_attribute("title")) {
+ tutorial.title = parser->get_attribute_value("title");
+ }
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
- c.tutorials.push_back(parser->get_node_data().strip_edges());
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
+ tutorial.link = parser->get_node_data().strip_edges();
+ c.tutorials.push_back(tutorial);
+ }
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials") {
break; // End of <tutorials>.
+ }
}
} else if (name2 == "methods") {
-
Error err2 = _parse_methods(parser, c.methods);
ERR_FAIL_COND_V(err2, err2);
} else if (name2 == "signals") {
-
Error err2 = _parse_methods(parser, c.signals);
ERR_FAIL_COND_V(err2, err2);
} else if (name2 == "members") {
-
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name3 = parser->get_node_name();
if (name3 == "member") {
-
PropertyDoc prop2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
prop2.name = parser->get_attribute_value("name");
ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
prop2.type = parser->get_attribute_value("type");
- if (parser->has_attribute("setter"))
+ if (parser->has_attribute("setter")) {
prop2.setter = parser->get_attribute_value("setter");
- if (parser->has_attribute("getter"))
+ }
+ if (parser->has_attribute("getter")) {
prop2.getter = parser->get_attribute_value("getter");
- if (parser->has_attribute("enum"))
+ }
+ if (parser->has_attribute("enum")) {
prop2.enumeration = parser->get_attribute_value("enum");
+ }
if (!parser->is_empty()) {
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
prop2.description = parser->get_node_data();
+ }
}
c.properties.push_back(prop2);
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members") {
break; // End of <members>.
+ }
}
} else if (name2 == "theme_items") {
-
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name3 = parser->get_node_name();
if (name3 == "theme_item") {
-
PropertyDoc prop2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
@@ -975,28 +955,26 @@ Error DocData::_load(Ref<XMLParser> parser) {
prop2.type = parser->get_attribute_value("type");
if (!parser->is_empty()) {
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
prop2.description = parser->get_node_data();
+ }
}
c.theme_properties.push_back(prop2);
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items") {
break; // End of <theme_items>.
+ }
}
} else if (name2 == "constants") {
-
while (parser->read() == OK) {
-
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name3 = parser->get_node_name();
if (name3 == "constant") {
-
ConstantDoc constant2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
constant2.name = parser->get_attribute_value("name");
@@ -1007,25 +985,27 @@ Error DocData::_load(Ref<XMLParser> parser) {
}
if (!parser->is_empty()) {
parser->read();
- if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ if (parser->get_node_type() == XMLParser::NODE_TEXT) {
constant2.description = parser->get_node_data();
+ }
}
c.constants.push_back(constant2);
} else {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + ".");
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants") {
break; // End of <constants>.
+ }
}
} else {
-
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name2 + ".");
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class") {
break; // End of <class>.
+ }
}
}
@@ -1033,19 +1013,18 @@ Error DocData::_load(Ref<XMLParser> parser) {
}
static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) {
-
- if (p_string == "")
+ if (p_string == "") {
return;
+ }
String tab;
- for (int i = 0; i < p_tablevel; i++)
+ for (int i = 0; i < p_tablevel; i++) {
tab += "\t";
+ }
f->store_string(tab + p_string + "\n");
}
Error DocData::save_classes(const String &p_default_path, const Map<String, String> &p_class_path) {
-
for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
-
ClassDoc &c = E->get();
String save_path;
@@ -1064,8 +1043,9 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
String header = "<class name=\"" + c.name + "\"";
- if (c.inherits != "")
+ if (c.inherits != "") {
header += " inherits=\"" + c.inherits + "\"";
+ }
header += String(" version=\"") + VERSION_BRANCH + "\"";
header += ">";
_write_string(f, 0, header);
@@ -1080,7 +1060,9 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "<tutorials>");
for (int i = 0; i < c.tutorials.size(); i++) {
- _write_string(f, 2, "<link>" + c.tutorials.get(i).xml_escape() + "</link>");
+ TutorialDoc tutorial = c.tutorials.get(i);
+ String title_attribute = (!tutorial.title.empty()) ? " title=\"" + tutorial.title.xml_escape() + "\"" : "";
+ _write_string(f, 2, "<link" + title_attribute + ">" + tutorial.link.xml_escape() + "</link>");
}
_write_string(f, 1, "</tutorials>");
@@ -1089,17 +1071,16 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
c.methods.sort();
for (int i = 0; i < c.methods.size(); i++) {
-
const MethodDoc &m = c.methods[i];
String qualifiers;
- if (m.qualifiers != "")
+ if (m.qualifiers != "") {
qualifiers += " qualifiers=\"" + m.qualifiers.xml_escape() + "\"";
+ }
_write_string(f, 2, "<method name=\"" + m.name + "\"" + qualifiers + ">");
if (m.return_type != "") {
-
String enum_text;
if (m.return_enum != String()) {
enum_text = " enum=\"" + m.return_enum + "\"";
@@ -1109,7 +1090,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
}
for (int j = 0; j < m.arguments.size(); j++) {
-
const ArgumentDoc &a = m.arguments[j];
String enum_text;
@@ -1117,10 +1097,11 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
enum_text = " enum=\"" + a.enumeration + "\"";
}
- if (a.default_value != "")
+ if (a.default_value != "") {
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\">");
- else
+ } else {
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + ">");
+ }
_write_string(f, 3, "</argument>");
}
@@ -1140,7 +1121,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
c.properties.sort();
for (int i = 0; i < c.properties.size(); i++) {
-
String additional_attributes;
if (c.properties[i].enumeration != String()) {
additional_attributes += " enum=\"" + c.properties[i].enumeration + "\"";
@@ -1163,16 +1143,13 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
}
if (c.signals.size()) {
-
c.signals.sort();
_write_string(f, 1, "<signals>");
for (int i = 0; i < c.signals.size(); i++) {
-
const MethodDoc &m = c.signals[i];
_write_string(f, 2, "<signal name=\"" + m.name + "\">");
for (int j = 0; j < m.arguments.size(); j++) {
-
const ArgumentDoc &a = m.arguments[j];
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
_write_string(f, 3, "</argument>");
@@ -1191,7 +1168,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "<constants>");
for (int i = 0; i < c.constants.size(); i++) {
-
const ConstantDoc &k = c.constants[i];
if (k.enumeration != String()) {
_write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">");
@@ -1205,18 +1181,17 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
_write_string(f, 1, "</constants>");
if (c.theme_properties.size()) {
-
c.theme_properties.sort();
_write_string(f, 1, "<theme_items>");
for (int i = 0; i < c.theme_properties.size(); i++) {
-
const PropertyDoc &p = c.theme_properties[i];
- if (p.default_value != "")
+ if (p.default_value != "") {
_write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">");
- else
+ } else {
_write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+ }
_write_string(f, 3, p.description.strip_edges().xml_escape());
@@ -1232,7 +1207,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
}
Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) {
-
Vector<uint8_t> data;
data.resize(p_uncompressed_size);
Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE);
@@ -1240,8 +1214,9 @@ Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int
Ref<XMLParser> parser = memnew(XMLParser);
Error err = parser->open_buffer(data);
- if (err)
+ if (err) {
return err;
+ }
_load(parser);
diff --git a/editor/doc_data.h b/editor/doc_data.h
index 073705f0b1..1880be81ed 100644
--- a/editor/doc_data.h
+++ b/editor/doc_data.h
@@ -38,64 +38,70 @@
class DocData {
public:
struct ArgumentDoc {
-
String name;
String type;
String enumeration;
String default_value;
+ bool operator<(const ArgumentDoc &p_arg) const {
+ return name < p_arg.name;
+ }
};
struct MethodDoc {
-
String name;
String return_type;
String return_enum;
String qualifiers;
String description;
Vector<ArgumentDoc> arguments;
- bool operator<(const MethodDoc &p_md) const {
- return name < p_md.name;
+ bool operator<(const MethodDoc &p_method) const {
+ return name < p_method.name;
}
};
struct ConstantDoc {
-
String name;
String value;
String enumeration;
String description;
+ bool operator<(const ConstantDoc &p_const) const {
+ return name < p_const.name;
+ }
};
struct PropertyDoc {
-
String name;
String type;
String enumeration;
String description;
String setter, getter;
String default_value;
- bool overridden;
+ bool overridden = false;
bool operator<(const PropertyDoc &p_prop) const {
return name < p_prop.name;
}
- PropertyDoc() {
- overridden = false;
- }
};
- struct ClassDoc {
+ struct TutorialDoc {
+ String link;
+ String title;
+ };
+ struct ClassDoc {
String name;
String inherits;
String category;
String brief_description;
String description;
- Vector<String> tutorials;
+ Vector<TutorialDoc> tutorials;
Vector<MethodDoc> methods;
Vector<MethodDoc> signals;
Vector<ConstantDoc> constants;
Vector<PropertyDoc> properties;
Vector<PropertyDoc> theme_properties;
+ bool operator<(const ClassDoc &p_class) const {
+ return name < p_class.name;
+ }
};
String version;
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index b0bcc2b448..d99726c57c 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -38,7 +38,6 @@
#include "core/version_hash.gen.h"
void EditorAbout::_theme_changed() {
-
Control *base = EditorNode::get_singleton()->get_gui_base();
Ref<Font> font = base->get_theme_font("source", "EditorFonts");
_tpl_text->add_theme_font_override("normal_font", font);
@@ -49,9 +48,7 @@ void EditorAbout::_theme_changed() {
}
void EditorAbout::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
_theme_changed();
} break;
@@ -59,7 +56,6 @@ void EditorAbout::_notification(int p_what) {
}
void EditorAbout::_license_tree_selected() {
-
TreeItem *selected = _tpl_tree->get_selected();
_tpl_text->scroll_to_line(0);
_tpl_text->set_text(selected->get_metadata(0));
@@ -69,12 +65,10 @@ void EditorAbout::_bind_methods() {
}
TextureRect *EditorAbout::get_logo() const {
-
return _logo;
}
ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_flag_single_column) {
-
ScrollContainer *sc = memnew(ScrollContainer);
sc->set_name(p_name);
sc->set_v_size_flags(Control::SIZE_EXPAND);
@@ -84,11 +78,9 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
sc->add_child(vbc);
for (int i = 0; i < p_sections.size(); i++) {
-
bool single_column = p_flag_single_column & 1 << i;
const char *const *names_ptr = p_src[i];
if (*names_ptr) {
-
Label *lbl = memnew(Label);
lbl->set_text(p_sections[i]);
vbc->add_child(lbl);
@@ -115,7 +107,6 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St
}
EditorAbout::EditorAbout() {
-
set_title(TTR("Thanks from the Godot community!"));
set_hide_on_ok(true);
@@ -132,8 +123,9 @@ EditorAbout::EditorAbout() {
hbc->add_child(_logo);
String hash = String(VERSION_HASH);
- if (hash.length() != 0)
+ if (hash.length() != 0) {
hash = "." + hash.left(9);
+ }
Label *about_text = memnew(Label);
about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
@@ -213,7 +205,6 @@ EditorAbout::EditorAbout() {
tpl_ti_lc->set_selectable(0, false);
String long_text = "";
for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
-
const ComponentCopyright &component = COPYRIGHT_INFO[component_index];
TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
String component_name = component.name;
@@ -239,7 +230,6 @@ EditorAbout::EditorAbout() {
ti->set_metadata(0, text);
}
for (int i = 0; i < LICENSE_COUNT; i++) {
-
TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
String licensename = String(LICENSE_NAMES[i]);
ti->set_text(0, licensename);
diff --git a/editor/editor_about.h b/editor/editor_about.h
index 83e9e9f490..ae4d9c73bf 100644
--- a/editor/editor_about.h
+++ b/editor/editor_about.h
@@ -45,7 +45,6 @@
#include "editor_scale.h"
class EditorAbout : public AcceptDialog {
-
GDCLASS(EditorAbout, AcceptDialog);
private:
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index 74c4102003..b43ee0e245 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -37,7 +37,6 @@
#include "progress_dialog.h"
void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool p_first) {
-
if (p_check) {
if (p_item->get_custom_color(0) == Color()) {
p_item->set_checked(0, true);
@@ -56,13 +55,14 @@ void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool
}
void EditorAssetInstaller::_item_edited() {
-
- if (updating)
+ if (updating) {
return;
+ }
TreeItem *item = tree->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
String path = item->get_metadata(0);
@@ -81,7 +81,6 @@ void EditorAssetInstaller::_item_edited() {
}
void EditorAssetInstaller::open(const String &p_path, int p_depth) {
-
package_path = p_path;
Set<String> files_sorted;
@@ -90,7 +89,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io);
if (!pkg) {
-
error->set_text(TTR("Error opening package file, not in ZIP format."));
return;
}
@@ -98,7 +96,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
int ret = unzGoToFirstFile(pkg);
while (ret == UNZ_OK) {
-
//get filename
unz_file_info info;
char fname[16384];
@@ -137,7 +134,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
Map<String, TreeItem *> dir_map;
for (Set<String>::Element *E = files_sorted.front(); E; E = E->next()) {
-
String path = E->get();
int depth = p_depth;
bool skip = false;
@@ -151,8 +147,9 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
depth--;
}
- if (skip || path == String())
+ if (skip || path == String()) {
continue;
+ }
bool isdir = false;
@@ -211,13 +208,11 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
}
void EditorAssetInstaller::ok_pressed() {
-
FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
if (!pkg) {
-
error->set_text(TTR("Error opening package file, not in ZIP format."));
return;
}
@@ -230,7 +225,6 @@ void EditorAssetInstaller::ok_pressed() {
int idx = 0;
while (ret == UNZ_OK) {
-
//get filename
unz_file_info info;
char fname[16384];
@@ -239,7 +233,6 @@ void EditorAssetInstaller::ok_pressed() {
String name = fname;
if (status_map.has(name) && status_map[name]->is_checked(0)) {
-
String path = status_map[name]->get_metadata(0);
if (path == String()) { // a dir
@@ -259,7 +252,6 @@ void EditorAssetInstaller::ok_pressed() {
memdelete(da);
} else {
-
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
@@ -290,18 +282,19 @@ void EditorAssetInstaller::ok_pressed() {
if (failed_files.size()) {
String msg = TTR("The following files failed extraction from package:") + "\n\n";
for (int i = 0; i < failed_files.size(); i++) {
-
if (i > 15) {
msg += "\n" + vformat(TTR("And %s more files."), itos(failed_files.size() - i));
break;
}
msg += failed_files[i];
}
- if (EditorNode::get_singleton() != nullptr)
+ if (EditorNode::get_singleton() != nullptr) {
EditorNode::get_singleton()->show_warning(msg);
+ }
} else {
- if (EditorNode::get_singleton() != nullptr)
+ if (EditorNode::get_singleton() != nullptr) {
EditorNode::get_singleton()->show_warning(TTR("Package installed successfully!"), TTR("Success!"));
+ }
}
EditorFileSystem::get_singleton()->scan_changes();
}
@@ -310,7 +303,6 @@ void EditorAssetInstaller::_bind_methods() {
}
EditorAssetInstaller::EditorAssetInstaller() {
-
VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h
index 840e780264..7f3d00994f 100644
--- a/editor/editor_asset_installer.h
+++ b/editor/editor_asset_installer.h
@@ -34,7 +34,6 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
class EditorAssetInstaller : public ConfirmationDialog {
-
GDCLASS(EditorAssetInstaller, ConfirmationDialog);
Tree *tree;
diff --git a/editor/editor_atlas_packer.cpp b/editor/editor_atlas_packer.cpp
index d17b3bba4f..68abeb2cda 100644
--- a/editor/editor_atlas_packer.cpp
+++ b/editor/editor_atlas_packer.cpp
@@ -31,14 +31,12 @@
#include "editor_atlas_packer.h"
void EditorAtlasPacker::_plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices) {
-
int width = p_bitmap->get_size().width;
int height = p_bitmap->get_size().height;
int x[3];
int y[3];
for (int j = 0; j < 3; j++) {
-
x[j] = vertices[j].x;
y[j] = vertices[j].y;
}
@@ -71,26 +69,25 @@ void EditorAtlasPacker::_plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices)
}
for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) {
-
p_bitmap->set_bit(Point2(xi, yi), true);
}
}
xf += dx_far;
- if (yi < y[1])
+ if (yi < y[1]) {
xt += dx_upper;
- else
+ } else {
xt += dx_low;
+ }
}
}
-void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_height, int p_atlas_max_size, int p_cell_resolution) {
+void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_height, int p_atlas_max_size, int p_cell_resolution) {
int divide_by = MIN(64, p_cell_resolution);
Vector<PlottedBitmap> bitmaps;
int max_w = 0;
for (int i = 0; i < charts.size(); i++) {
-
const Chart &chart = charts[i];
//generate aabb
@@ -100,7 +97,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
const Vector2 *vertices = chart.vertices.ptr();
for (int j = 0; j < vertex_count; j++) {
-
if (j == 0) {
aabb.position = vertices[j];
} else {
@@ -118,7 +114,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
//plot triangles, using divisor
for (int j = 0; j < chart.faces.size(); j++) {
-
Vector2i v[3];
for (int k = 0; k < 3; k++) {
Vector2 vtx = chart.vertices[chart.faces[j].vertex[k]];
@@ -163,13 +158,14 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
bool found_pixel = false;
for (int lx = x - 1; lx < x + 2 && !found_pixel; lx++) {
for (int ly = y - 1; ly < y + 2 && !found_pixel; ly++) {
-
int px = lx - 1;
- if (px < 0 || px >= w)
+ if (px < 0 || px >= w) {
continue;
+ }
int py = ly - 1;
- if (py < 0 || py >= h)
+ if (py < 0 || py >= h) {
continue;
+ }
if (src_bitmap->get_bit(Vector2(px, py))) {
found_pixel = true;
@@ -177,7 +173,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
}
}
if (found_pixel) {
-
if (transpose) {
if (x > top_heights[y]) {
top_heights.write[y] = x;
@@ -231,7 +226,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
int *atlas_ptr = heights.ptrw();
for (int i = 0; i < bitmaps.size(); i++) {
-
int best_height = 0x7FFFFFFF;
int best_height_offset = -1;
int w = bitmaps[i].top_heights.size();
@@ -240,11 +234,9 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h
const int *bottom_heights = bitmaps[i].bottom_heights.ptr();
for (int j = 0; j < atlas_w - w; j++) {
-
int height = 0;
for (int k = 0; k < w; k++) {
-
int pixmap_h = bottom_heights[k];
if (pixmap_h == -1) {
continue; //no pixel here, anything is fine
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index c80ae5f21b..5cf5201b18 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -40,10 +40,8 @@
#include "servers/audio_server.h"
void EditorAudioBus::_update_visible_channels() {
-
int i = 0;
for (; i < cc; i++) {
-
if (!channel[i].vu_l->is_visible()) {
channel[i].vu_l->show();
}
@@ -53,7 +51,6 @@ void EditorAudioBus::_update_visible_channels() {
}
for (; i < CHANNELS_MAX; i++) {
-
if (channel[i].vu_l->is_visible()) {
channel[i].vu_l->hide();
}
@@ -64,10 +61,8 @@ void EditorAudioBus::_update_visible_channels() {
}
void EditorAudioBus::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY: {
-
for (int i = 0; i < CHANNELS_MAX; i++) {
channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons"));
channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons"));
@@ -95,7 +90,6 @@ void EditorAudioBus::_notification(int p_what) {
set_process(true);
} break;
case NOTIFICATION_DRAW: {
-
if (is_master) {
draw_style_box(get_theme_stylebox("disabled", "Button"), Rect2(Vector2(), get_size()));
} else if (has_focus()) {
@@ -111,7 +105,6 @@ void EditorAudioBus::_notification(int p_what) {
}
} break;
case NOTIFICATION_PROCESS: {
-
if (cc != AudioServer::get_singleton()->get_bus_channels(get_index())) {
cc = AudioServer::get_singleton()->get_bus_channels(get_index());
_update_visible_channels();
@@ -156,7 +149,6 @@ void EditorAudioBus::_notification(int p_what) {
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
for (int i = 0; i < CHANNELS_MAX; i++) {
channel[i].peak_l = -100;
channel[i].peak_r = -100;
@@ -166,7 +158,6 @@ void EditorAudioBus::_notification(int p_what) {
set_process(is_visible_in_tree());
} break;
case NOTIFICATION_THEME_CHANGED: {
-
for (int i = 0; i < CHANNELS_MAX; i++) {
channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons"));
channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons"));
@@ -185,7 +176,6 @@ void EditorAudioBus::_notification(int p_what) {
} break;
case NOTIFICATION_MOUSE_EXIT:
case NOTIFICATION_DRAG_END: {
-
if (hovering_drop) {
hovering_drop = false;
update();
@@ -195,7 +185,6 @@ void EditorAudioBus::_notification(int p_what) {
}
void EditorAudioBus::update_send() {
-
send->clear();
if (is_master) {
send->set_disabled(true);
@@ -218,9 +207,9 @@ void EditorAudioBus::update_send() {
}
void EditorAudioBus::update_bus() {
-
- if (updating_bus)
+ if (updating_bus) {
return;
+ }
updating_bus = true;
@@ -229,8 +218,9 @@ void EditorAudioBus::update_bus() {
float db_value = AudioServer::get_singleton()->get_bus_volume_db(index);
slider->set_value(_scaled_db_to_normalized_volume(db_value));
track_name->set_text(AudioServer::get_singleton()->get_bus_name(index));
- if (is_master)
+ if (is_master) {
track_name->set_editable(false);
+ }
solo->set_pressed(AudioServer::get_singleton()->is_bus_solo(index));
mute->set_pressed(AudioServer::get_singleton()->is_bus_mute(index));
@@ -240,7 +230,6 @@ void EditorAudioBus::update_bus() {
TreeItem *root = effects->create_item();
for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(index); i++) {
-
Ref<AudioEffect> afx = AudioServer::get_singleton()->get_bus_effect(index, i);
TreeItem *fx = effects->create_item(root);
@@ -263,18 +252,16 @@ void EditorAudioBus::update_bus() {
}
void EditorAudioBus::_name_changed(const String &p_new_name) {
-
- if (p_new_name == AudioServer::get_singleton()->get_bus_name(get_index()))
+ if (p_new_name == AudioServer::get_singleton()->get_bus_name(get_index())) {
return;
+ }
String attempt = p_new_name;
int attempts = 1;
while (true) {
-
bool name_free = true;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
-
if (AudioServer::get_singleton()->get_bus_name(i) == attempt) {
name_free = false;
break;
@@ -317,9 +304,9 @@ void EditorAudioBus::_name_changed(const String &p_new_name) {
}
void EditorAudioBus::_volume_changed(float p_normalized) {
-
- if (updating_bus)
+ if (updating_bus) {
return;
+ }
updating_bus = true;
@@ -384,7 +371,6 @@ float EditorAudioBus::_scaled_db_to_normalized_volume(float db) {
}
void EditorAudioBus::_show_value(float slider_value) {
-
float db;
if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
// Display the correct (snapped) value when holding Ctrl
@@ -415,7 +401,6 @@ void EditorAudioBus::_hide_value_preview() {
}
void EditorAudioBus::_solo_toggled() {
-
updating_bus = true;
UndoRedo *ur = EditorNode::get_undo_redo();
@@ -428,8 +413,8 @@ void EditorAudioBus::_solo_toggled() {
updating_bus = false;
}
-void EditorAudioBus::_mute_toggled() {
+void EditorAudioBus::_mute_toggled() {
updating_bus = true;
UndoRedo *ur = EditorNode::get_undo_redo();
@@ -442,8 +427,8 @@ void EditorAudioBus::_mute_toggled() {
updating_bus = false;
}
-void EditorAudioBus::_bypass_toggled() {
+void EditorAudioBus::_bypass_toggled() {
updating_bus = true;
UndoRedo *ur = EditorNode::get_undo_redo();
@@ -458,7 +443,6 @@ void EditorAudioBus::_bypass_toggled() {
}
void EditorAudioBus::_send_selected(int p_which) {
-
updating_bus = true;
UndoRedo *ur = EditorNode::get_undo_redo();
@@ -473,14 +457,13 @@ void EditorAudioBus::_send_selected(int p_which) {
}
void EditorAudioBus::_effect_selected() {
-
TreeItem *effect = effects->get_selected();
- if (!effect)
+ if (!effect) {
return;
+ }
updating_bus = true;
if (effect->get_metadata(0) != Variant()) {
-
int index = effect->get_metadata(0);
Ref<AudioEffect> effect2 = AudioServer::get_singleton()->get_bus_effect(get_index(), index);
if (effect2.is_valid()) {
@@ -492,13 +475,14 @@ void EditorAudioBus::_effect_selected() {
}
void EditorAudioBus::_effect_edited() {
-
- if (updating_bus)
+ if (updating_bus) {
return;
+ }
TreeItem *effect = effects->get_edited();
- if (!effect)
+ if (!effect) {
return;
+ }
if (effect->get_metadata(0) == Variant()) {
Rect2 area = effects->get_item_rect(effect);
@@ -523,9 +507,9 @@ void EditorAudioBus::_effect_edited() {
}
void EditorAudioBus::_effect_add(int p_which) {
-
- if (updating_bus)
+ if (updating_bus) {
return;
+ }
StringName name = effect_options->get_item_metadata(p_which);
@@ -547,7 +531,6 @@ void EditorAudioBus::_effect_add(int p_which) {
}
void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
accept_event();
@@ -556,15 +539,24 @@ void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) {
-
Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y);
bus_popup->set_position(get_global_position() + pos);
bus_popup->popup();
}
}
-void EditorAudioBus::_bus_popup_pressed(int p_option) {
+void EditorAudioBus::_unhandled_key_input(Ref<InputEvent> p_event) {
+ Ref<InputEventKey> k = p_event;
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_DELETE) {
+ TreeItem *current_effect = effects->get_selected();
+ if (current_effect && current_effect->get_metadata(0).get_type() == Variant::INT) {
+ _delete_effect_pressed(0);
+ accept_event();
+ }
+ }
+}
+void EditorAudioBus::_bus_popup_pressed(int p_option) {
if (p_option == 2) {
// Reset volume
emit_signal("vol_reset_request");
@@ -577,7 +569,6 @@ void EditorAudioBus::_bus_popup_pressed(int p_option) {
}
Variant EditorAudioBus::get_drag_data(const Point2 &p_point) {
-
if (get_index() == 0) {
return Variant();
}
@@ -602,7 +593,6 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) {
}
bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
if (get_index() == 0) {
return false;
}
@@ -617,13 +607,11 @@ bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data)
}
void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) {
-
Dictionary d = p_data;
emit_signal("dropped", d["index"], get_index());
}
Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
TreeItem *item = effects->get_item_at_position(p_point);
if (!item) {
return Variant();
@@ -647,14 +635,15 @@ Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from)
}
bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "audio_bus_effect")
+ if (!d.has("type") || String(d["type"]) != "audio_bus_effect") {
return false;
+ }
TreeItem *item = effects->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return false;
+ }
effects->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
@@ -662,12 +651,12 @@ bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
}
void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
Dictionary d = p_data;
TreeItem *item = effects->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return;
+ }
int pos = effects->get_drop_section_at_position(p_point);
Variant md = item->get_metadata(0);
@@ -677,8 +666,9 @@ void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (md.get_type() == Variant::INT) {
paste_at = md;
- if (pos > 0)
+ if (pos > 0) {
paste_at++;
+ }
if (bus == get_index() && paste_at > effect) {
paste_at--;
@@ -720,13 +710,14 @@ void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
void EditorAudioBus::_delete_effect_pressed(int p_option) {
-
TreeItem *item = effects->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
- if (item->get_metadata(0).get_type() != Variant::INT)
+ if (item->get_metadata(0).get_type() != Variant::INT) {
return;
+ }
int index = item->get_metadata(0);
@@ -741,23 +732,24 @@ void EditorAudioBus::_delete_effect_pressed(int p_option) {
}
void EditorAudioBus::_effect_rmb(const Vector2 &p_pos) {
-
TreeItem *item = effects->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
- if (item->get_metadata(0).get_type() != Variant::INT)
+ if (item->get_metadata(0).get_type() != Variant::INT) {
return;
+ }
delete_effect_popup->set_position(get_global_mouse_position());
delete_effect_popup->popup();
}
void EditorAudioBus::_bind_methods() {
-
ClassDB::bind_method("update_bus", &EditorAudioBus::update_bus);
ClassDB::bind_method("update_send", &EditorAudioBus::update_send);
ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input);
+ ClassDB::bind_method("_unhandled_key_input", &EditorAudioBus::_unhandled_key_input);
ClassDB::bind_method("get_drag_data_fw", &EditorAudioBus::get_drag_data_fw);
ClassDB::bind_method("can_drop_data_fw", &EditorAudioBus::can_drop_data_fw);
ClassDB::bind_method("drop_data_fw", &EditorAudioBus::drop_data_fw);
@@ -770,7 +762,6 @@ void EditorAudioBus::_bind_methods() {
}
EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
-
buses = p_buses;
updating_bus = false;
is_master = p_is_master;
@@ -782,6 +773,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
add_child(vb);
set_v_size_flags(SIZE_EXPAND_FILL);
+ set_process_unhandled_key_input(true);
track_name = memnew(LineEdit);
track_name->connect("text_entered", callable_mp(this, &EditorAudioBus::_name_changed));
@@ -926,8 +918,9 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
ClassDB::get_inheriters_from_class("AudioEffect", &effects);
effects.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = effects.front(); E; E = E->next()) {
- if (!ClassDB::can_instance(E->get()))
+ if (!ClassDB::can_instance(E->get())) {
continue;
+ }
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get());
String name = E->get().operator String().replace("AudioEffect", "");
@@ -950,7 +943,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
}
void EditorAudioBusDrop::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
draw_style_box(get_theme_stylebox("normal", "Button"), Rect2(Vector2(), get_size()));
@@ -962,7 +954,6 @@ void EditorAudioBusDrop::_notification(int p_what) {
}
} break;
case NOTIFICATION_MOUSE_ENTER: {
-
if (!hovering_drop) {
hovering_drop = true;
update();
@@ -970,7 +961,6 @@ void EditorAudioBusDrop::_notification(int p_what) {
} break;
case NOTIFICATION_MOUSE_EXIT:
case NOTIFICATION_DRAG_END: {
-
if (hovering_drop) {
hovering_drop = false;
update();
@@ -980,29 +970,24 @@ void EditorAudioBusDrop::_notification(int p_what) {
}
bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
Dictionary d = p_data;
return (d.has("type") && String(d["type"]) == "move_audio_bus");
}
void EditorAudioBusDrop::drop_data(const Point2 &p_point, const Variant &p_data) {
-
Dictionary d = p_data;
emit_signal("dropped", d["index"], AudioServer::get_singleton()->get_bus_count());
}
void EditorAudioBusDrop::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("dropped"));
}
EditorAudioBusDrop::EditorAudioBusDrop() {
-
hovering_drop = false;
}
void EditorAudioBuses::_update_buses() {
-
while (bus_hb->get_child_count() > 0) {
memdelete(bus_hb->get_child(0));
}
@@ -1010,7 +995,6 @@ void EditorAudioBuses::_update_buses() {
drop_end = nullptr;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
-
bool is_master = (i == 0);
EditorAudioBus *audio_bus = memnew(EditorAudioBus(this, is_master));
bus_hb->add_child(audio_bus);
@@ -1023,33 +1007,27 @@ void EditorAudioBuses::_update_buses() {
}
EditorAudioBuses *EditorAudioBuses::register_editor() {
-
EditorAudioBuses *audio_buses = memnew(EditorAudioBuses);
EditorNode::get_singleton()->add_bottom_panel_item(TTR("Audio"), audio_buses);
return audio_buses;
}
void EditorAudioBuses::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
-
bus_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
-
_update_buses();
} break;
case NOTIFICATION_DRAG_END: {
-
if (drop_end) {
drop_end->queue_delete();
drop_end = nullptr;
}
} break;
case NOTIFICATION_PROCESS: {
-
// Check if anything was edited.
bool edited = AudioServer::get_singleton()->is_edited();
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
@@ -1072,7 +1050,6 @@ void EditorAudioBuses::_notification(int p_what) {
}
void EditorAudioBuses::_add_bus() {
-
UndoRedo *ur = EditorNode::get_undo_redo();
ur->create_action(TTR("Add Audio Bus"));
@@ -1084,22 +1061,20 @@ void EditorAudioBuses::_add_bus() {
}
void EditorAudioBuses::_update_bus(int p_index) {
-
- if (p_index >= bus_hb->get_child_count())
+ if (p_index >= bus_hb->get_child_count()) {
return;
+ }
bus_hb->get_child(p_index)->call("update_bus");
}
void EditorAudioBuses::_update_sends() {
-
for (int i = 0; i < bus_hb->get_child_count(); i++) {
bus_hb->get_child(i)->call("update_send");
}
}
void EditorAudioBuses::_delete_bus(Object *p_which) {
-
EditorAudioBus *bus = Object::cast_to<EditorAudioBus>(p_which);
int index = bus->get_index();
if (index == 0) {
@@ -1119,7 +1094,6 @@ void EditorAudioBuses::_delete_bus(Object *p_which) {
ur->add_undo_method(AudioServer::get_singleton(), "set_bus_mute", index, AudioServer::get_singleton()->is_bus_mute(index));
ur->add_undo_method(AudioServer::get_singleton(), "set_bus_bypass_effects", index, AudioServer::get_singleton()->is_bus_bypassing_effects(index));
for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(index); i++) {
-
ur->add_undo_method(AudioServer::get_singleton(), "add_bus_effect", index, AudioServer::get_singleton()->get_bus_effect(index, i));
ur->add_undo_method(AudioServer::get_singleton(), "set_bus_effect_enabled", index, i, AudioServer::get_singleton()->is_bus_effect_enabled(index, i));
}
@@ -1129,7 +1103,6 @@ void EditorAudioBuses::_delete_bus(Object *p_which) {
}
void EditorAudioBuses::_duplicate_bus(int p_which) {
-
int add_at_pos = p_which + 1;
UndoRedo *ur = EditorNode::get_undo_redo();
ur->create_action(TTR("Duplicate Audio Bus"));
@@ -1141,7 +1114,6 @@ void EditorAudioBuses::_duplicate_bus(int p_which) {
ur->add_do_method(AudioServer::get_singleton(), "set_bus_mute", add_at_pos, AudioServer::get_singleton()->is_bus_mute(p_which));
ur->add_do_method(AudioServer::get_singleton(), "set_bus_bypass_effects", add_at_pos, AudioServer::get_singleton()->is_bus_bypassing_effects(p_which));
for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(p_which); i++) {
-
ur->add_do_method(AudioServer::get_singleton(), "add_bus_effect", add_at_pos, AudioServer::get_singleton()->get_bus_effect(p_which, i));
ur->add_do_method(AudioServer::get_singleton(), "set_bus_effect_enabled", add_at_pos, i, AudioServer::get_singleton()->is_bus_effect_enabled(p_which, i));
}
@@ -1152,7 +1124,6 @@ void EditorAudioBuses::_duplicate_bus(int p_which) {
}
void EditorAudioBuses::_reset_bus_volume(Object *p_which) {
-
EditorAudioBus *bus = Object::cast_to<EditorAudioBus>(p_which);
int index = bus->get_index();
@@ -1166,7 +1137,6 @@ void EditorAudioBuses::_reset_bus_volume(Object *p_which) {
}
void EditorAudioBuses::_request_drop_end() {
-
if (!drop_end && bus_hb->get_child_count()) {
drop_end = memnew(EditorAudioBusDrop);
@@ -1177,7 +1147,6 @@ void EditorAudioBuses::_request_drop_end() {
}
void EditorAudioBuses::_drop_at_index(int p_bus, int p_index) {
-
UndoRedo *ur = EditorNode::get_undo_redo();
ur->create_action(TTR("Move Audio Bus"));
@@ -1192,18 +1161,15 @@ void EditorAudioBuses::_drop_at_index(int p_bus, int p_index) {
}
void EditorAudioBuses::_server_save() {
-
Ref<AudioBusLayout> state = AudioServer::get_singleton()->generate_bus_layout();
ResourceSaver::save(edited_path, state);
}
void EditorAudioBuses::_select_layout() {
-
EditorNode::get_singleton()->get_filesystem_dock()->select_file(edited_path);
}
void EditorAudioBuses::_save_as_layout() {
-
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_title(TTR("Save Audio Bus Layout As..."));
file_dialog->set_current_path(edited_path);
@@ -1212,7 +1178,6 @@ void EditorAudioBuses::_save_as_layout() {
}
void EditorAudioBuses::_new_layout() {
-
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_dialog->set_title(TTR("Location for New Layout..."));
file_dialog->set_current_path(edited_path);
@@ -1221,7 +1186,6 @@ void EditorAudioBuses::_new_layout() {
}
void EditorAudioBuses::_load_layout() {
-
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_dialog->set_title(TTR("Open Audio Bus Layout"));
file_dialog->set_current_path(edited_path);
@@ -1230,7 +1194,6 @@ void EditorAudioBuses::_load_layout() {
}
void EditorAudioBuses::_load_default_layout() {
-
String layout_path = ProjectSettings::get_singleton()->get("audio/default_bus_layout");
Ref<AudioBusLayout> state = ResourceLoader::load(layout_path, "", true);
@@ -1248,7 +1211,6 @@ void EditorAudioBuses::_load_default_layout() {
}
void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
-
if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_OPEN_FILE) {
Ref<AudioBusLayout> state = ResourceLoader::load(p_string, "", true);
if (state.is_null()) {
@@ -1264,7 +1226,6 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
call_deferred("_select_layout");
} else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
-
if (new_layout) {
Ref<AudioBusLayout> empty_state;
empty_state.instance();
@@ -1287,7 +1248,6 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
}
void EditorAudioBuses::_bind_methods() {
-
ClassDB::bind_method("_update_buses", &EditorAudioBuses::_update_buses);
ClassDB::bind_method("_update_bus", &EditorAudioBuses::_update_bus);
ClassDB::bind_method("_update_sends", &EditorAudioBuses::_update_sends);
@@ -1295,7 +1255,6 @@ void EditorAudioBuses::_bind_methods() {
}
EditorAudioBuses::EditorAudioBuses() {
-
drop_end = nullptr;
top_hb = memnew(HBoxContainer);
add_child(top_hb);
@@ -1372,7 +1331,6 @@ EditorAudioBuses::EditorAudioBuses() {
}
void EditorAudioBuses::open_layout(const String &p_path) {
-
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
Ref<AudioBusLayout> state = ResourceLoader::load(p_path, "", true);
@@ -1390,9 +1348,7 @@ void EditorAudioBuses::open_layout(const String &p_path) {
}
void AudioBusesEditorPlugin::edit(Object *p_node) {
-
if (Object::cast_to<AudioBusLayout>(p_node)) {
-
String path = Object::cast_to<AudioBusLayout>(p_node)->get_path();
if (path.is_resource_file()) {
audio_bus_editor->open_layout(path);
@@ -1401,7 +1357,6 @@ void AudioBusesEditorPlugin::edit(Object *p_node) {
}
bool AudioBusesEditorPlugin::handles(Object *p_node) const {
-
return (Object::cast_to<AudioBusLayout>(p_node) != nullptr);
}
@@ -1409,7 +1364,6 @@ void AudioBusesEditorPlugin::make_visible(bool p_visible) {
}
AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) {
-
audio_bus_editor = p_node;
}
@@ -1417,12 +1371,10 @@ AudioBusesEditorPlugin::~AudioBusesEditorPlugin() {
}
void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_value, bool p_render_value) {
-
notches.push_back(AudioNotch(p_normalized_offset, p_db_value, p_render_value));
}
Size2 EditorAudioMeterNotches::get_minimum_size() const {
-
Ref<Font> font = get_theme_font("font", "Label");
float font_height = font->get_height();
@@ -1441,13 +1393,11 @@ Size2 EditorAudioMeterNotches::get_minimum_size() const {
}
void EditorAudioMeterNotches::_bind_methods() {
-
ClassDB::bind_method("add_notch", &EditorAudioMeterNotches::add_notch);
ClassDB::bind_method("_draw_audio_notches", &EditorAudioMeterNotches::_draw_audio_notches);
}
void EditorAudioMeterNotches::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(0, 0, 0);
@@ -1459,7 +1409,6 @@ void EditorAudioMeterNotches::_notification(int p_what) {
}
void EditorAudioMeterNotches::_draw_audio_notches() {
-
Ref<Font> font = get_theme_font("font", "Label");
float font_height = font->get_height();
@@ -1480,11 +1429,6 @@ void EditorAudioMeterNotches::_draw_audio_notches() {
}
}
-EditorAudioMeterNotches::EditorAudioMeterNotches() :
- line_length(5.0f),
- label_space(2.0f),
- btm_padding(9.0f),
- top_padding(5.0f) {
-
+EditorAudioMeterNotches::EditorAudioMeterNotches() {
notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(0, 0, 0);
}
diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h
index be1551629d..65caf84f0f 100644
--- a/editor/editor_audio_buses.h
+++ b/editor/editor_audio_buses.h
@@ -51,7 +51,6 @@
class EditorAudioBuses;
class EditorAudioBus : public PanelContainer {
-
GDCLASS(EditorAudioBus, PanelContainer);
Ref<Texture2D> disabled_vu;
@@ -93,6 +92,7 @@ class EditorAudioBus : public PanelContainer {
mutable bool hovering_drop;
void _gui_input(const Ref<InputEvent> &p_event);
+ void _unhandled_key_input(Ref<InputEvent> p_event);
void _bus_popup_pressed(int p_option);
void _name_changed(const String &p_new_name);
@@ -137,7 +137,6 @@ public:
};
class EditorAudioBusDrop : public Control {
-
GDCLASS(EditorAudioBusDrop, Control);
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
@@ -154,7 +153,6 @@ public:
};
class EditorAudioBuses : public VBoxContainer {
-
GDCLASS(EditorAudioBuses, VBoxContainer);
HBoxContainer *top_hb;
@@ -246,10 +244,10 @@ private:
List<AudioNotch> notches;
public:
- float line_length;
- float label_space;
- float btm_padding;
- float top_padding;
+ float line_length = 5.0f;
+ float label_space = 2.0f;
+ float btm_padding = 9.0f;
+ float top_padding = 5.0f;
Color notch_color;
void add_notch(float p_normalized_offset, float p_db_value, bool p_render_value = false);
@@ -265,7 +263,6 @@ public:
};
class AudioBusesEditorPlugin : public EditorPlugin {
-
GDCLASS(AudioBusesEditorPlugin, EditorPlugin);
EditorAudioBuses *audio_bus_editor;
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 6917b2b775..da0ff9f18f 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -41,15 +41,12 @@
#define PREVIEW_LIST_MAX_SIZE 10
void EditorAutoloadSettings::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
List<String> afn;
ResourceLoader::get_recognized_extensions_for_type("Script", &afn);
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn);
for (List<String>::Element *E = afn.front(); E; E = E->next()) {
-
file_dialog->add_filter("*." + E->get());
}
@@ -66,25 +63,27 @@ void EditorAutoloadSettings::_notification(int p_what) {
}
bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) {
-
if (!p_name.is_valid_identifier()) {
- if (r_error)
+ if (r_error) {
*r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:") + " a-z, A-Z, 0-9 or _";
+ }
return false;
}
if (ClassDB::class_exists(p_name)) {
- if (r_error)
+ if (r_error) {
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing engine class name.");
+ }
return false;
}
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (Variant::get_type_name(Variant::Type(i)) == p_name) {
- if (r_error)
+ if (r_error) {
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing built-in type name.");
+ }
return false;
}
@@ -92,8 +91,9 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
if (GlobalConstants::get_global_constant_name(i) == p_name) {
- if (r_error)
+ if (r_error) {
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing global constant name.");
+ }
return false;
}
@@ -104,8 +104,9 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
ScriptServer::get_language(i)->get_reserved_words(&keywords);
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
if (E->get() == p_name) {
- if (r_error)
+ if (r_error) {
*r_error = TTR("Invalid name.") + "\n" + TTR("Keyword cannot be used as an autoload name.");
+ }
return false;
}
@@ -116,28 +117,28 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
}
void EditorAutoloadSettings::_autoload_add() {
-
- if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text()))
+ if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) {
autoload_add_path->set_text("");
+ }
autoload_add_name->set_text("");
add_autoload->set_disabled(true);
}
void EditorAutoloadSettings::_autoload_selected() {
-
TreeItem *ti = tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
selected_autoload = "autoload/" + ti->get_text(0);
}
void EditorAutoloadSettings::_autoload_edited() {
-
- if (updating_autoload)
+ if (updating_autoload) {
return;
+ }
TreeItem *ti = tree->get_edited();
int column = tree->get_edited_column();
@@ -148,8 +149,9 @@ void EditorAutoloadSettings::_autoload_edited() {
String name = ti->get_text(0);
String old_name = selected_autoload.get_slice("/", 1);
- if (name == old_name)
+ if (name == old_name) {
return;
+ }
String error;
if (!_autoload_name_is_valid(name, &error)) {
@@ -199,12 +201,14 @@ void EditorAutoloadSettings::_autoload_edited() {
int order = ProjectSettings::get_singleton()->get_order(base);
String path = ProjectSettings::get_singleton()->get(base);
- if (path.begins_with("*"))
+ if (path.begins_with("*")) {
path = path.substr(1, path.length());
+ }
// Singleton autoloads are represented with a leading "*" in their path.
- if (checked)
+ if (checked) {
path = "*" + path;
+ }
undo_redo->create_action(TTR("Toggle AutoLoad Globals"));
@@ -227,7 +231,6 @@ void EditorAutoloadSettings::_autoload_edited() {
}
void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String name = "autoload/" + ti->get_text(0);
@@ -240,7 +243,6 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
} break;
case BUTTON_MOVE_UP:
case BUTTON_MOVE_DOWN: {
-
TreeItem *swap = nullptr;
if (p_button == BUTTON_MOVE_UP) {
@@ -249,8 +251,9 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
swap = ti->get_next();
}
- if (!swap)
+ if (!swap) {
return;
+ }
String swap_name = "autoload/" + swap->get_text(0);
@@ -274,7 +277,6 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
undo_redo->commit_action();
} break;
case BUTTON_DELETE: {
-
int order = ProjectSettings::get_singleton()->get_order(name);
undo_redo->create_action(TTR("Remove Autoload"));
@@ -298,8 +300,9 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
void EditorAutoloadSettings::_autoload_activated() {
TreeItem *ti = tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
_autoload_open(ti->get_text(1));
}
@@ -313,7 +316,6 @@ void EditorAutoloadSettings::_autoload_open(const String &fpath) {
}
void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) {
-
// Convert the file name to PascalCase, which is the convention for classes in GDScript.
const String class_name = p_path.get_file().get_basename().capitalize().replace(" ", "");
@@ -326,20 +328,17 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) {
}
void EditorAutoloadSettings::_autoload_text_entered(const String p_name) {
-
if (autoload_add_path->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) {
_autoload_add();
}
}
void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) {
-
add_autoload->set_disabled(
p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr));
}
void EditorAutoloadSettings::_autoload_text_changed(const String p_name) {
-
add_autoload->set_disabled(
autoload_add_path->get_text() == "" || !_autoload_name_is_valid(p_name, nullptr));
}
@@ -371,9 +370,9 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
}
void EditorAutoloadSettings::update_autoload() {
-
- if (updating_autoload)
+ if (updating_autoload) {
return;
+ }
updating_autoload = true;
@@ -394,17 +393,18 @@ void EditorAutoloadSettings::update_autoload() {
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
const PropertyInfo &pi = E->get();
- if (!pi.name.begins_with("autoload/"))
+ if (!pi.name.begins_with("autoload/")) {
continue;
+ }
String name = pi.name.get_slice("/", 1);
String path = ProjectSettings::get_singleton()->get(pi.name);
- if (name.empty())
+ if (name.empty()) {
continue;
+ }
AutoLoadInfo info;
info.is_singleton = path.begins_with("*");
@@ -518,9 +518,9 @@ void EditorAutoloadSettings::update_autoload() {
}
Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control *p_control) {
-
- if (autoload_cache.size() <= 1)
+ if (autoload_cache.size() <= 1) {
return false;
+ }
PackedStringArray autoloads;
@@ -531,8 +531,9 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control
next = tree->get_next_selected(next);
}
- if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size())
+ if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size()) {
return Variant();
+ }
VBoxContainer *preview = memnew(VBoxContainer);
@@ -556,19 +557,22 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control
}
bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const {
- if (updating_autoload)
+ if (updating_autoload) {
return false;
+ }
Dictionary drop_data = p_data;
- if (!drop_data.has("type"))
+ if (!drop_data.has("type")) {
return false;
+ }
if (drop_data.has("type")) {
TreeItem *ti = tree->get_item_at_position(p_point);
- if (!ti)
+ if (!ti) {
return false;
+ }
int section = tree->get_drop_section_at_position(p_point);
@@ -579,16 +583,17 @@ bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Varia
}
void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) {
-
TreeItem *ti = tree->get_item_at_position(p_point);
- if (!ti)
+ if (!ti) {
return;
+ }
int section = tree->get_drop_section_at_position(p_point);
- if (section < -1)
+ if (section < -1) {
return;
+ }
String name;
bool move_to_back = false;
@@ -665,23 +670,22 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
}
bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_path) {
-
String name = p_name;
String error;
if (!_autoload_name_is_valid(name, &error)) {
- EditorNode::get_singleton()->show_warning(error);
+ EditorNode::get_singleton()->show_warning(TTR("Can't add autoload:") + "\n" + error);
return false;
}
const String &path = p_path;
if (!FileAccess::exists(path)) {
- EditorNode::get_singleton()->show_warning(TTR("Invalid path.") + "\n" + TTR("File does not exist."));
+ EditorNode::get_singleton()->show_warning(TTR("Can't add autoload:") + "\n" + TTR(vformat("%s is an invalid path. File does not exist.", path)));
return false;
}
if (!path.begins_with("res://")) {
- EditorNode::get_singleton()->show_warning(TTR("Invalid path.") + "\n" + TTR("Not in resource path."));
+ EditorNode::get_singleton()->show_warning(TTR("Can't add autoload:") + "\n" + TTR(vformat("%s is an invalid path. Not in resource path (res://).", path)));
return false;
}
@@ -711,7 +715,6 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
}
void EditorAutoloadSettings::autoload_remove(const String &p_name) {
-
String name = "autoload/" + p_name;
UndoRedo *undo_redo = EditorNode::get_undo_redo();
@@ -736,7 +739,6 @@ void EditorAutoloadSettings::autoload_remove(const String &p_name) {
}
void EditorAutoloadSettings::_bind_methods() {
-
ClassDB::bind_method("_autoload_open", &EditorAutoloadSettings::_autoload_open);
ClassDB::bind_method("get_drag_data_fw", &EditorAutoloadSettings::get_drag_data_fw);
@@ -751,22 +753,22 @@ void EditorAutoloadSettings::_bind_methods() {
}
EditorAutoloadSettings::EditorAutoloadSettings() {
-
// Make first cache
List<PropertyInfo> props;
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
const PropertyInfo &pi = E->get();
- if (!pi.name.begins_with("autoload/"))
+ if (!pi.name.begins_with("autoload/")) {
continue;
+ }
String name = pi.name.get_slice("/", 1);
String path = ProjectSettings::get_singleton()->get(pi.name);
- if (name.empty())
+ if (name.empty()) {
continue;
+ }
AutoLoadInfo info;
info.is_singleton = path.begins_with("*");
@@ -904,12 +906,10 @@ EditorAutoloadSettings::~EditorAutoloadSettings() {
}
void EditorAutoloadSettings::_set_autoload_add_path(const String &p_text) {
-
autoload_add_path->set_text(p_text);
autoload_add_path->emit_signal("text_entered", p_text);
}
void EditorAutoloadSettings::_browse_autoload_add_path() {
-
file_dialog->popup_centered_ratio();
-} \ No newline at end of file
+}
diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h
index 94a581401c..646fe3992c 100644
--- a/editor/editor_autoload_settings.h
+++ b/editor/editor_autoload_settings.h
@@ -36,7 +36,6 @@
#include "editor_file_dialog.h"
class EditorAutoloadSettings : public VBoxContainer {
-
GDCLASS(EditorAutoloadSettings, VBoxContainer);
enum {
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 9c739474d1..130c330f5a 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -39,22 +39,23 @@
#include "scene/resources/packed_scene.h"
void EditorHistory::cleanup_history() {
-
for (int i = 0; i < history.size(); i++) {
-
bool fail = false;
for (int j = 0; j < history[i].path.size(); j++) {
- if (!history[i].path[j].ref.is_null())
+ if (!history[i].path[j].ref.is_null()) {
continue;
+ }
Object *obj = ObjectDB::get_instance(history[i].path[j].object);
if (obj) {
Node *n = Object::cast_to<Node>(obj);
- if (n && n->is_inside_tree())
+ if (n && n->is_inside_tree()) {
continue;
- if (!n) // Possibly still alive
+ }
+ if (!n) { // Possibly still alive
continue;
+ }
}
if (j <= history[i].level) {
@@ -74,18 +75,19 @@ void EditorHistory::cleanup_history() {
}
}
- if (current >= history.size())
+ if (current >= history.size()) {
current = history.size() - 1;
+ }
}
void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int p_level_change, bool p_inspector_only) {
-
Object *obj = ObjectDB::get_instance(p_object);
ERR_FAIL_COND(!obj);
Reference *r = Object::cast_to<Reference>(obj);
Obj o;
- if (r)
+ if (r) {
o.ref = REF(r);
+ }
o.object = p_object;
o.property = p_property;
o.inspector_only = p_inspector_only;
@@ -122,34 +124,30 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int
}
void EditorHistory::add_object_inspector_only(ObjectID p_object) {
-
_add_object(p_object, "", -1, true);
}
void EditorHistory::add_object(ObjectID p_object) {
-
_add_object(p_object, "", -1);
}
void EditorHistory::add_object(ObjectID p_object, const String &p_subprop) {
-
_add_object(p_object, p_subprop, -1);
}
void EditorHistory::add_object(ObjectID p_object, int p_relevel) {
-
_add_object(p_object, "", p_relevel);
}
int EditorHistory::get_history_len() {
return history.size();
}
+
int EditorHistory::get_history_pos() {
return current;
}
bool EditorHistory::is_history_obj_inspector_only(int p_obj) const {
-
ERR_FAIL_INDEX_V(p_obj, history.size(), false);
ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), false);
return history[p_obj].path[history[p_obj].level].inspector_only;
@@ -164,85 +162,88 @@ ObjectID EditorHistory::get_history_obj(int p_obj) const {
bool EditorHistory::is_at_beginning() const {
return current <= 0;
}
-bool EditorHistory::is_at_end() const {
+bool EditorHistory::is_at_end() const {
return ((current + 1) >= history.size());
}
bool EditorHistory::next() {
-
cleanup_history();
- if ((current + 1) < history.size())
+ if ((current + 1) < history.size()) {
current++;
- else
+ } else {
return false;
+ }
return true;
}
bool EditorHistory::previous() {
-
cleanup_history();
- if (current > 0)
+ if (current > 0) {
current--;
- else
+ } else {
return false;
+ }
return true;
}
bool EditorHistory::is_current_inspector_only() const {
-
- if (current < 0 || current >= history.size())
+ if (current < 0 || current >= history.size()) {
return false;
+ }
const History &h = history[current];
return h.path[h.level].inspector_only;
}
-ObjectID EditorHistory::get_current() {
- if (current < 0 || current >= history.size())
+ObjectID EditorHistory::get_current() {
+ if (current < 0 || current >= history.size()) {
return ObjectID();
+ }
History &h = history.write[current];
Object *obj = ObjectDB::get_instance(h.path[h.level].object);
- if (!obj)
+ if (!obj) {
return ObjectID();
+ }
return obj->get_instance_id();
}
int EditorHistory::get_path_size() const {
-
- if (current < 0 || current >= history.size())
+ if (current < 0 || current >= history.size()) {
return 0;
+ }
const History &h = history[current];
return h.path.size();
}
ObjectID EditorHistory::get_path_object(int p_index) const {
-
- if (current < 0 || current >= history.size())
+ if (current < 0 || current >= history.size()) {
return ObjectID();
+ }
const History &h = history[current];
ERR_FAIL_INDEX_V(p_index, h.path.size(), ObjectID());
Object *obj = ObjectDB::get_instance(h.path[p_index].object);
- if (!obj)
+ if (!obj) {
return ObjectID();
+ }
return obj->get_instance_id();
}
String EditorHistory::get_path_property(int p_index) const {
-
- if (current < 0 || current >= history.size())
+ if (current < 0 || current >= history.size()) {
return "";
+ }
const History &h = history[current];
@@ -252,33 +253,29 @@ String EditorHistory::get_path_property(int p_index) const {
}
void EditorHistory::clear() {
-
history.clear();
current = -1;
}
EditorHistory::EditorHistory() {
-
current = -1;
}
EditorPlugin *EditorData::get_editor(Object *p_object) {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
- if (editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object))
+ if (editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) {
return editor_plugins[i];
+ }
}
return nullptr;
}
EditorPlugin *EditorData::get_subeditor(Object *p_object) {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
- if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object))
+ if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) {
return editor_plugins[i];
+ }
}
return nullptr;
@@ -295,27 +292,25 @@ Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) {
}
EditorPlugin *EditorData::get_editor(String p_name) {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
- if (editor_plugins[i]->get_name() == p_name)
+ if (editor_plugins[i]->get_name() == p_name) {
return editor_plugins[i];
+ }
}
return nullptr;
}
void EditorData::copy_object_params(Object *p_object) {
-
clipboard.clear();
List<PropertyInfo> pinfo;
p_object->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts")
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") {
continue;
+ }
PropertyData pd;
pd.name = E->get().name;
@@ -325,21 +320,18 @@ void EditorData::copy_object_params(Object *p_object) {
}
void EditorData::get_editor_breakpoints(List<String> *p_breakpoints) {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->get_breakpoints(p_breakpoints);
}
}
Dictionary EditorData::get_editor_states() const {
-
Dictionary metadata;
for (int i = 0; i < editor_plugins.size(); i++) {
-
Dictionary state = editor_plugins[i]->get_state();
- if (state.empty())
+ if (state.empty()) {
continue;
+ }
metadata[editor_plugins[i]->get_name()] = state;
}
@@ -353,88 +345,71 @@ Dictionary EditorData::get_scene_editor_states(int p_idx) const {
}
void EditorData::set_editor_states(const Dictionary &p_states) {
-
List<Variant> keys;
p_states.get_key_list(&keys);
List<Variant>::Element *E = keys.front();
for (; E; E = E->next()) {
-
String name = E->get();
int idx = -1;
for (int i = 0; i < editor_plugins.size(); i++) {
-
if (editor_plugins[i]->get_name() == name) {
idx = i;
break;
}
}
- if (idx == -1)
+ if (idx == -1) {
continue;
+ }
editor_plugins[idx]->set_state(p_states[name]);
}
}
void EditorData::notify_edited_scene_changed() {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->edited_scene_changed();
editor_plugins[i]->notify_scene_changed(get_edited_scene_root());
}
}
void EditorData::notify_resource_saved(const Ref<Resource> &p_resource) {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->notify_resource_saved(p_resource);
}
}
void EditorData::clear_editor_states() {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->clear();
}
}
void EditorData::save_editor_external_data() {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->save_external_data();
}
}
void EditorData::apply_changes_in_editors() {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->apply_changes();
}
}
void EditorData::save_editor_global_states() {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->save_global_state();
}
}
void EditorData::restore_editor_global_states() {
-
for (int i = 0; i < editor_plugins.size(); i++) {
-
editor_plugins[i]->restore_global_state();
}
}
void EditorData::paste_object_params(Object *p_object) {
-
ERR_FAIL_NULL(p_object);
undo_redo.create_action(TTR("Paste Params"));
for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) {
@@ -446,11 +421,9 @@ void EditorData::paste_object_params(Object *p_object) {
}
bool EditorData::call_build() {
-
bool result = true;
for (int i = 0; i < editor_plugins.size() && result; i++) {
-
result &= editor_plugins[i]->build();
}
@@ -458,18 +431,15 @@ bool EditorData::call_build() {
}
UndoRedo &EditorData::get_undo_redo() {
-
return undo_redo;
}
void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) {
-
p_plugin->undo_redo = nullptr;
editor_plugins.erase(p_plugin);
}
void EditorData::add_editor_plugin(EditorPlugin *p_plugin) {
-
p_plugin->undo_redo = &undo_redo;
editor_plugins.push_back(p_plugin);
}
@@ -477,14 +447,13 @@ void EditorData::add_editor_plugin(EditorPlugin *p_plugin) {
int EditorData::get_editor_plugin_count() const {
return editor_plugins.size();
}
-EditorPlugin *EditorData::get_editor_plugin(int p_idx) {
+EditorPlugin *EditorData::get_editor_plugin(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), nullptr);
return editor_plugins[p_idx];
}
void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
-
ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object.");
CustomType ct;
ct.name = p_type;
@@ -498,9 +467,7 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits,
}
Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) {
-
if (get_custom_types().has(p_inherits)) {
-
for (int i = 0; i < get_custom_types()[p_inherits].size(); i++) {
if (get_custom_types()[p_inherits][i].name == p_type) {
Ref<Script> script = get_custom_types()[p_inherits][i].script;
@@ -520,9 +487,7 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i
}
void EditorData::remove_custom_type(const String &p_type) {
-
for (Map<String, Vector<CustomType>>::Element *E = custom_types.front(); E; E = E->next()) {
-
for (int i = 0; i < E->get().size(); i++) {
if (E->get()[i].name == p_type) {
E->get().remove(i);
@@ -536,9 +501,9 @@ void EditorData::remove_custom_type(const String &p_type) {
}
int EditorData::add_edited_scene(int p_at_pos) {
-
- if (p_at_pos < 0)
+ if (p_at_pos < 0) {
p_at_pos = edited_scene.size();
+ }
EditedScene es;
es.root = nullptr;
es.path = String();
@@ -546,18 +511,19 @@ int EditorData::add_edited_scene(int p_at_pos) {
es.version = 0;
es.live_edit_root = NodePath(String("/root"));
- if (p_at_pos == edited_scene.size())
+ if (p_at_pos == edited_scene.size()) {
edited_scene.push_back(es);
- else
+ } else {
edited_scene.insert(p_at_pos, es);
+ }
- if (current_edited_scene < 0)
+ if (current_edited_scene < 0) {
current_edited_scene = 0;
+ }
return p_at_pos;
}
void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
-
ERR_FAIL_INDEX(p_idx, edited_scene.size());
ERR_FAIL_INDEX(p_to_idx, edited_scene.size());
SWAP(edited_scene.write[p_idx], edited_scene.write[p_to_idx]);
@@ -566,7 +532,6 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
void EditorData::remove_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, edited_scene.size());
if (edited_scene[p_idx].root) {
-
for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename());
}
@@ -574,9 +539,9 @@ void EditorData::remove_scene(int p_idx) {
memdelete(edited_scene[p_idx].root);
}
- if (current_edited_scene > p_idx)
+ if (current_edited_scene > p_idx) {
current_edited_scene--;
- else if (current_edited_scene == p_idx && current_edited_scene > 0) {
+ } else if (current_edited_scene == p_idx && current_edited_scene > 0) {
current_edited_scene--;
}
@@ -584,7 +549,6 @@ void EditorData::remove_scene(int p_idx) {
}
bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) {
-
/*
if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
return false;
@@ -602,7 +566,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String>
String path = ss->get_path();
if (!checked_paths.has(path)) {
-
uint64_t modified_time = FileAccess::get_modified_time(path);
if (modified_time != ss->get_last_modified_time()) {
return true; //external scene changed
@@ -613,20 +576,20 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String>
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
bool found = _find_updated_instances(p_root, p_node->get_child(i), checked_paths);
- if (found)
+ if (found) {
return true;
+ }
}
return false;
}
bool EditorData::check_and_update_scene(int p_idx) {
-
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), false);
- if (!edited_scene[p_idx].root)
+ if (!edited_scene[p_idx].root) {
return false;
+ }
Set<String> checked_scenes;
@@ -650,16 +613,18 @@ bool EditorData::check_and_update_scene(int p_idx) {
for (List<Node *>::Element *E = edited_scene.write[p_idx].selection.front(); E; E = E->next()) {
NodePath p = edited_scene[p_idx].root->get_path_to(E->get());
Node *new_node = new_scene->get_node(p);
- if (new_node)
+ if (new_node) {
new_selection.push_back(new_node);
+ }
}
new_scene->set_filename(edited_scene[p_idx].root->get_filename());
memdelete(edited_scene[p_idx].root);
edited_scene.write[p_idx].root = new_scene;
- if (new_scene->get_filename() != "")
+ if (new_scene->get_filename() != "") {
edited_scene.write[p_idx].path = new_scene->get_filename();
+ }
edited_scene.write[p_idx].selection = new_selection;
return true;
@@ -669,15 +634,15 @@ bool EditorData::check_and_update_scene(int p_idx) {
}
int EditorData::get_edited_scene() const {
-
return current_edited_scene;
}
-void EditorData::set_edited_scene(int p_idx) {
+void EditorData::set_edited_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, edited_scene.size());
current_edited_scene = p_idx;
//swap
}
+
Node *EditorData::get_edited_scene_root(int p_idx) {
if (p_idx < 0) {
ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), nullptr);
@@ -687,25 +652,24 @@ Node *EditorData::get_edited_scene_root(int p_idx) {
return edited_scene[p_idx].root;
}
}
-void EditorData::set_edited_scene_root(Node *p_root) {
+void EditorData::set_edited_scene_root(Node *p_root) {
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
edited_scene.write[current_edited_scene].root = p_root;
if (p_root) {
- if (p_root->get_filename() != "")
+ if (p_root->get_filename() != "") {
edited_scene.write[current_edited_scene].path = p_root->get_filename();
- else
+ } else {
p_root->set_filename(edited_scene[current_edited_scene].path);
+ }
}
}
int EditorData::get_edited_scene_count() const {
-
return edited_scene.size();
}
Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const {
-
Vector<EditedScene> out_edited_scenes_list = Vector<EditedScene>();
for (int i = 0; i < edited_scene.size(); i++) {
@@ -726,24 +690,24 @@ void EditorData::set_edited_scene_version(uint64_t version, int p_scene_idx) {
}
uint64_t EditorData::get_edited_scene_version() const {
-
ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), 0);
return edited_scene[current_edited_scene].version;
}
+
uint64_t EditorData::get_scene_version(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), 0);
return edited_scene[p_idx].version;
}
String EditorData::get_scene_type(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
- if (!edited_scene[p_idx].root)
+ if (!edited_scene[p_idx].root) {
return "";
+ }
return edited_scene[p_idx].root->get_class();
}
-void EditorData::move_edited_scene_to_index(int p_idx) {
+void EditorData::move_edited_scene_to_index(int p_idx) {
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
ERR_FAIL_INDEX(p_idx, edited_scene.size());
@@ -754,10 +718,10 @@ void EditorData::move_edited_scene_to_index(int p_idx) {
}
Ref<Script> EditorData::get_scene_root_script(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Ref<Script>());
- if (!edited_scene[p_idx].root)
+ if (!edited_scene[p_idx].root) {
return Ref<Script>();
+ }
Ref<Script> s = edited_scene[p_idx].root->get_script();
if (!s.is_valid() && edited_scene[p_idx].root->get_child_count()) {
Node *n = edited_scene[p_idx].root->get_child(0);
@@ -771,10 +735,12 @@ Ref<Script> EditorData::get_scene_root_script(int p_idx) const {
String EditorData::get_scene_title(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
- if (!edited_scene[p_idx].root)
+ if (!edited_scene[p_idx].root) {
return TTR("[empty]");
- if (edited_scene[p_idx].root->get_filename() == "")
+ }
+ if (edited_scene[p_idx].root->get_filename() == "") {
return TTR("[unsaved]");
+ }
bool show_ext = EDITOR_DEF("interface/scene_tabs/show_extension", false);
String name = edited_scene[p_idx].root->get_filename().get_file();
if (!show_ext) {
@@ -784,24 +750,24 @@ String EditorData::get_scene_title(int p_idx) const {
}
void EditorData::set_scene_path(int p_idx, const String &p_path) {
-
ERR_FAIL_INDEX(p_idx, edited_scene.size());
edited_scene.write[p_idx].path = p_path;
- if (!edited_scene[p_idx].root)
+ if (!edited_scene[p_idx].root) {
return;
+ }
edited_scene[p_idx].root->set_filename(p_path);
}
String EditorData::get_scene_path(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
if (edited_scene[p_idx].root) {
- if (edited_scene[p_idx].root->get_filename() == "")
+ if (edited_scene[p_idx].root->get_filename() == "") {
edited_scene[p_idx].root->set_filename(edited_scene[p_idx].path);
- else
+ } else {
return edited_scene[p_idx].root->get_filename();
+ }
}
return edited_scene[p_idx].path;
@@ -812,15 +778,14 @@ void EditorData::set_edited_scene_live_edit_root(const NodePath &p_root) {
edited_scene.write[current_edited_scene].live_edit_root = p_root;
}
-NodePath EditorData::get_edited_scene_live_edit_root() {
+NodePath EditorData::get_edited_scene_live_edit_root() {
ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), String());
return edited_scene[current_edited_scene].live_edit_root;
}
void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom) {
-
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
EditedScene &es = edited_scene.write[current_edited_scene];
@@ -849,7 +814,6 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection,
}
void EditorData::clear_edited_scenes() {
-
for (int i = 0; i < edited_scene.size(); i++) {
if (edited_scene[i].root) {
memdelete(edited_scene[i].root);
@@ -871,8 +835,9 @@ void EditorData::get_plugin_window_layout(Ref<ConfigFile> p_layout) {
}
bool EditorData::script_class_is_parent(const String &p_class, const String &p_inherits) {
- if (!ScriptServer::is_global_class(p_class))
+ if (!ScriptServer::is_global_class(p_class)) {
return false;
+ }
String base = script_class_get_base(p_class);
Ref<Script> script = script_class_load_script(p_class);
Ref<Script> base_script = script->get_base_script();
@@ -892,10 +857,10 @@ bool EditorData::script_class_is_parent(const String &p_class, const String &p_i
}
StringName EditorData::script_class_get_base(const String &p_class) const {
-
Ref<Script> script = script_class_load_script(p_class);
- if (script.is_null())
+ if (script.is_null()) {
return StringName();
+ }
Ref<Script> base_script = script->get_base_script();
if (base_script.is_null()) {
@@ -910,8 +875,9 @@ Object *EditorData::script_class_instance(const String &p_class) {
Object *obj = ClassDB::instance(ScriptServer::get_global_class_native_base(p_class));
if (obj) {
Ref<Script> script = script_class_load_script(p_class);
- if (script.is_valid())
+ if (script.is_valid()) {
obj->set_script(script);
+ }
return obj;
}
}
@@ -919,9 +885,9 @@ Object *EditorData::script_class_instance(const String &p_class) {
}
Ref<Script> EditorData::script_class_load_script(const String &p_class) const {
-
- if (!ScriptServer::is_global_class(p_class))
+ if (!ScriptServer::is_global_class(p_class)) {
return Ref<Script>();
+ }
String path = ScriptServer::get_global_class_path(p_class);
return ResourceLoader::load(path, "Script");
@@ -932,15 +898,17 @@ void EditorData::script_class_set_icon_path(const String &p_class, const String
}
String EditorData::script_class_get_icon_path(const String &p_class) const {
- if (!ScriptServer::is_global_class(p_class))
+ if (!ScriptServer::is_global_class(p_class)) {
return String();
+ }
String current = p_class;
String ret = _script_class_icon_paths[current];
while (ret.empty()) {
current = script_class_get_base(current);
- if (!ScriptServer::is_global_class(current))
+ if (!ScriptServer::is_global_class(current)) {
return String();
+ }
ret = _script_class_icon_paths.has(current) ? _script_class_icon_paths[current] : String();
}
@@ -961,8 +929,9 @@ void EditorData::script_class_save_icon_paths() {
Dictionary d;
for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
- if (ScriptServer::is_global_class(E->get()))
+ if (ScriptServer::is_global_class(E->get())) {
d[E->get()] = _script_class_icon_paths[E->get()];
+ }
}
ProjectSettings::get_singleton()->set("_global_script_class_icons", d);
@@ -988,7 +957,6 @@ void EditorData::script_class_load_icon_paths() {
}
EditorData::EditorData() {
-
current_edited_scene = -1;
//load_imported_scenes_from_globals();
@@ -997,30 +965,30 @@ EditorData::EditorData() {
///////////
void EditorSelection::_node_removed(Node *p_node) {
-
- if (!selection.has(p_node))
+ if (!selection.has(p_node)) {
return;
+ }
Object *meta = selection[p_node];
- if (meta)
+ if (meta) {
memdelete(meta);
+ }
selection.erase(p_node);
changed = true;
nl_changed = true;
}
void EditorSelection::add_node(Node *p_node) {
-
ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(!p_node->is_inside_tree());
- if (selection.has(p_node))
+ if (selection.has(p_node)) {
return;
+ }
changed = true;
nl_changed = true;
Object *meta = nullptr;
for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) {
-
meta = E->get()->call("_get_editor_data", p_node);
if (meta) {
break;
@@ -1034,32 +1002,31 @@ void EditorSelection::add_node(Node *p_node) {
}
void EditorSelection::remove_node(Node *p_node) {
-
ERR_FAIL_NULL(p_node);
- if (!selection.has(p_node))
+ if (!selection.has(p_node)) {
return;
+ }
changed = true;
nl_changed = true;
Object *meta = selection[p_node];
- if (meta)
+ if (meta) {
memdelete(meta);
+ }
selection.erase(p_node);
p_node->disconnect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed));
//emit_signal("selection_changed");
}
-bool EditorSelection::is_selected(Node *p_node) const {
+bool EditorSelection::is_selected(Node *p_node) const {
return selection.has(p_node);
}
Array EditorSelection::_get_transformable_selected_nodes() {
-
Array ret;
for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
@@ -1067,11 +1034,9 @@ Array EditorSelection::_get_transformable_selected_nodes() {
}
TypedArray<Node> EditorSelection::get_selected_nodes() {
-
TypedArray<Node> ret;
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
ret.push_back(E->key());
}
@@ -1079,7 +1044,6 @@ TypedArray<Node> EditorSelection::get_selected_nodes() {
}
void EditorSelection::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("clear"), &EditorSelection::clear);
ClassDB::bind_method(D_METHOD("add_node", "node"), &EditorSelection::add_node);
ClassDB::bind_method(D_METHOD("remove_node", "node"), &EditorSelection::remove_node);
@@ -1090,19 +1054,17 @@ void EditorSelection::_bind_methods() {
}
void EditorSelection::add_editor_plugin(Object *p_object) {
-
editor_plugins.push_back(p_object);
}
void EditorSelection::_update_nl() {
-
- if (!nl_changed)
+ if (!nl_changed) {
return;
+ }
selected_node_list.clear();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
Node *parent = E->key();
parent = parent->get_parent();
bool skip = false;
@@ -1114,8 +1076,9 @@ void EditorSelection::_update_nl() {
parent = parent->get_parent();
}
- if (skip)
+ if (skip) {
continue;
+ }
selected_node_list.push_back(E->key());
}
@@ -1123,11 +1086,11 @@ void EditorSelection::_update_nl() {
}
void EditorSelection::update() {
-
_update_nl();
- if (!changed)
+ if (!changed) {
return;
+ }
changed = false;
if (!emitted) {
emitted = true;
@@ -1141,16 +1104,15 @@ void EditorSelection::_emit_change() {
}
List<Node *> &EditorSelection::get_selected_node_list() {
-
- if (changed)
+ if (changed) {
update();
- else
+ } else {
_update_nl();
+ }
return selected_node_list;
}
List<Node *> EditorSelection::get_full_selected_node_list() {
-
List<Node *> node_list;
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
node_list.push_back(E->key());
@@ -1160,23 +1122,20 @@ List<Node *> EditorSelection::get_full_selected_node_list() {
}
void EditorSelection::clear() {
-
while (!selection.empty()) {
-
remove_node(selection.front()->key());
}
changed = true;
nl_changed = true;
}
-EditorSelection::EditorSelection() {
+EditorSelection::EditorSelection() {
emitted = false;
changed = false;
nl_changed = false;
}
EditorSelection::~EditorSelection() {
-
clear();
}
diff --git a/editor/editor_data.h b/editor/editor_data.h
index e4f4c67c8e..8083dde09c 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -39,14 +39,12 @@
#include "scene/resources/texture.h"
class EditorHistory {
-
enum {
HISTORY_MAX = 64
};
struct Obj {
-
REF ref;
ObjectID object;
String property;
@@ -54,7 +52,6 @@ class EditorHistory {
};
struct History {
-
Vector<Obj> path;
int level;
};
@@ -66,7 +63,6 @@ class EditorHistory {
//Vector<EditorPlugin*> editor_plugins;
struct PropertyData {
-
String name;
Variant value;
};
@@ -106,10 +102,8 @@ public:
class EditorSelection;
class EditorData {
-
public:
struct CustomType {
-
String name;
Ref<Script> script;
Ref<Texture2D> icon;
@@ -131,7 +125,6 @@ private:
Vector<EditorPlugin *> editor_plugins;
struct PropertyData {
-
String name;
Variant value;
};
@@ -234,7 +227,6 @@ public:
};
class EditorSelection : public Object {
-
GDCLASS(EditorSelection, Object);
private:
@@ -264,8 +256,9 @@ public:
template <class T>
T *get_node_editor_data(Node *p_node) {
- if (!selection.has(p_node))
+ if (!selection.has(p_node)) {
return nullptr;
+ }
return Object::cast_to<T>(selection[p_node]);
}
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index cb87656382..3c1c3c8a86 100644
--- a/editor/editor_dir_dialog.cpp
+++ b/editor/editor_dir_dialog.cpp
@@ -38,7 +38,6 @@
#include "servers/display_server.h"
void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path) {
-
updating = true;
String path = p_dir->get_path();
@@ -49,7 +48,6 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p
if (!p_item->get_parent()) {
p_item->set_text(0, "res://");
} else {
-
if (!opened_paths.has(path) && (p_select_path == String() || !p_select_path.begins_with(path))) {
p_item->set_collapsed(true);
}
@@ -61,14 +59,12 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p
//bool show_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
updating = false;
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
-
TreeItem *ti = tree->create_item(p_item);
_update_dir(ti, p_dir->get_subdir(i));
}
}
void EditorDirDialog::reload(const String &p_path) {
-
if (!is_visible()) {
must_reload = true;
return;
@@ -82,7 +78,6 @@ void EditorDirDialog::reload(const String &p_path) {
}
void EditorDirDialog::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload), make_binds(""));
reload();
@@ -110,16 +105,17 @@ void EditorDirDialog::_notification(int p_what) {
}
void EditorDirDialog::_item_collapsed(Object *p_item) {
-
TreeItem *item = Object::cast_to<TreeItem>(p_item);
- if (updating)
+ if (updating) {
return;
+ }
- if (item->is_collapsed())
+ if (item->is_collapsed()) {
opened_paths.erase(item->get_metadata(0));
- else
+ } else {
opened_paths.insert(item->get_metadata(0));
+ }
}
void EditorDirDialog::_item_activated() {
@@ -127,10 +123,10 @@ void EditorDirDialog::_item_activated() {
}
void EditorDirDialog::ok_pressed() {
-
TreeItem *ti = tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
String dir = ti->get_metadata(0);
emit_signal("dir_selected", dir);
@@ -138,7 +134,6 @@ void EditorDirDialog::ok_pressed() {
}
void EditorDirDialog::_make_dir() {
-
TreeItem *ti = tree->get_selected();
if (!ti) {
mkdirerr->set_text(TTR("Please select a base directory first."));
@@ -151,10 +146,10 @@ void EditorDirDialog::_make_dir() {
}
void EditorDirDialog::_make_dir_confirm() {
-
TreeItem *ti = tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
String dir = ti->get_metadata(0);
@@ -173,12 +168,10 @@ void EditorDirDialog::_make_dir_confirm() {
}
void EditorDirDialog::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
}
EditorDirDialog::EditorDirDialog() {
-
updating = false;
set_title(TTR("Choose a Directory"));
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 24a69fe003..25594bf7c8 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -48,7 +48,6 @@
#include "scene/resources/resource_format_text.h"
static int _get_pad(int p_alignment, int p_n) {
-
int rest = p_n % p_alignment;
int pad = 0;
if (rest > 0) {
@@ -61,7 +60,6 @@ static int _get_pad(int p_alignment, int p_n) {
#define PCK_PADDING 16
bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {
-
if (values.has(p_name)) {
values[p_name] = p_value;
EditorExport::singleton->save_presets();
@@ -72,7 +70,6 @@ bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value)
}
bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
-
if (values.has(p_name)) {
r_ret = values[p_name];
return true;
@@ -82,9 +79,7 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
}
void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
-
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
-
if (platform->get_option_visibility(E->get().name, values)) {
p_list->push_back(E->get());
}
@@ -92,12 +87,23 @@ void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
}
Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
-
return platform;
}
-Vector<String> EditorExportPreset::get_files_to_export() const {
+void EditorExportPreset::update_files_to_export() {
+ Vector<String> to_remove;
+ for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
+ if (!FileAccess::exists(E->get())) {
+ to_remove.push_back(E->get());
+ }
+ }
+ for (int i = 0; i < to_remove.size(); ++i) {
+ selected_files.erase(to_remove[i]);
+ }
+ EditorExport::singleton->save_presets();
+}
+Vector<String> EditorExportPreset::get_files_to_export() const {
Vector<String> files;
for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
files.push_back(E->get());
@@ -115,18 +121,15 @@ String EditorExportPreset::get_name() const {
}
void EditorExportPreset::set_runnable(bool p_enable) {
-
runnable = p_enable;
EditorExport::singleton->save_presets();
}
bool EditorExportPreset::is_runnable() const {
-
return runnable;
}
void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
-
export_filter = p_filter;
EditorExport::singleton->save_presets();
}
@@ -136,18 +139,15 @@ EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
}
void EditorExportPreset::set_include_filter(const String &p_include) {
-
include_filter = p_include;
EditorExport::singleton->save_presets();
}
String EditorExportPreset::get_include_filter() const {
-
return include_filter;
}
void EditorExportPreset::set_export_path(const String &p_path) {
-
export_path = p_path;
/* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path,
* this should be removed. */
@@ -159,23 +159,19 @@ void EditorExportPreset::set_export_path(const String &p_path) {
}
String EditorExportPreset::get_export_path() const {
-
return export_path;
}
void EditorExportPreset::set_exclude_filter(const String &p_exclude) {
-
exclude_filter = p_exclude;
EditorExport::singleton->save_presets();
}
String EditorExportPreset::get_exclude_filter() const {
-
return exclude_filter;
}
void EditorExportPreset::add_export_file(const String &p_path) {
-
selected_files.insert(p_path);
EditorExport::singleton->save_presets();
}
@@ -186,16 +182,15 @@ void EditorExportPreset::remove_export_file(const String &p_path) {
}
bool EditorExportPreset::has_export_file(const String &p_path) {
-
return selected_files.has(p_path);
}
void EditorExportPreset::add_patch(const String &p_path, int p_at_pos) {
-
- if (p_at_pos < 0)
+ if (p_at_pos < 0) {
patches.push_back(p_path);
- else
+ } else {
patches.insert(p_at_pos, p_path);
+ }
EditorExport::singleton->save_presets();
}
@@ -209,8 +204,8 @@ void EditorExportPreset::set_patch(int p_index, const String &p_path) {
patches.write[p_index] = p_path;
EditorExport::singleton->save_presets();
}
-String EditorExportPreset::get_patch(int p_index) {
+String EditorExportPreset::get_patch(int p_index) {
ERR_FAIL_INDEX_V(p_index, patches.size(), String());
return patches[p_index];
}
@@ -220,54 +215,41 @@ Vector<String> EditorExportPreset::get_patches() const {
}
void EditorExportPreset::set_custom_features(const String &p_custom_features) {
-
custom_features = p_custom_features;
EditorExport::singleton->save_presets();
}
String EditorExportPreset::get_custom_features() const {
-
return custom_features;
}
void EditorExportPreset::set_script_export_mode(int p_mode) {
-
script_mode = p_mode;
EditorExport::singleton->save_presets();
}
int EditorExportPreset::get_script_export_mode() const {
-
return script_mode;
}
void EditorExportPreset::set_script_encryption_key(const String &p_key) {
-
script_key = p_key;
EditorExport::singleton->save_presets();
}
String EditorExportPreset::get_script_encryption_key() const {
-
return script_key;
}
-EditorExportPreset::EditorExportPreset() :
- export_filter(EXPORT_ALL_RESOURCES),
- export_path(""),
- runnable(false),
- script_mode(MODE_SCRIPT_COMPILED) {
-}
-
///////////////////////////////////
void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) {
-
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
- if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
+ if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) {
host = "localhost";
+ }
if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
@@ -281,7 +263,6 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
}
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) {
-
r_flags.push_back("--remote-debug");
r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port));
@@ -290,14 +271,13 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
if (breakpoints.size()) {
-
r_flags.push_back("--breakpoints");
String bpoints;
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
-
bpoints += E->get().replace(" ", "%20");
- if (E->next())
+ if (E->next()) {
bpoints += ",";
+ }
}
r_flags.push_back(bpoints);
@@ -305,18 +285,15 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
}
if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) {
-
r_flags.push_back("--debug-collisions");
}
if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) {
-
r_flags.push_back("--debug-navigation");
}
}
Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
-
PackData *pd = (PackData *)p_userdata;
SavedData sd;
@@ -349,7 +326,6 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa
}
Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
-
String path = p_path.replace_first("res://", "");
ZipData *zd = (ZipData *)p_userdata;
@@ -384,7 +360,6 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
}
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
-
String current_version = VERSION_FULL_CONFIG;
String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(current_version).plus_file(template_file_name);
@@ -404,7 +379,6 @@ bool EditorExportPlatform::exists_export_template(String template_file_name, Str
}
Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
-
Ref<EditorExportPreset> preset;
preset.instance();
preset->platform = Ref<EditorExportPlatform>(this);
@@ -413,7 +387,6 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
get_export_options(&options);
for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) {
-
preset->properties.push_back(E->get().option);
preset->values[E->get().option.name] = E->get().default_value;
}
@@ -422,7 +395,6 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
}
void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths) {
-
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
_export_find_resources(p_dir->get_subdir(i), p_paths);
}
@@ -433,40 +405,40 @@ void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_d
}
void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<String> &p_paths) {
-
- if (p_paths.has(p_path))
+ if (p_paths.has(p_path)) {
return;
+ }
p_paths.insert(p_path);
EditorFileSystemDirectory *dir;
int file_idx;
dir = EditorFileSystem::get_singleton()->find_file(p_path, &file_idx);
- if (!dir)
+ if (!dir) {
return;
+ }
Vector<String> deps = dir->get_file_deps(file_idx);
for (int i = 0; i < deps.size(); i++) {
-
_export_find_dependencies(deps[i], p_paths);
}
}
void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) {
-
da->list_dir_begin();
String cur_dir = da->get_current_dir().replace("\\", "/");
- if (!cur_dir.ends_with("/"))
+ if (!cur_dir.ends_with("/")) {
cur_dir += "/";
+ }
String cur_dir_no_prefix = cur_dir.replace("res://", "");
Vector<String> dirs;
String f;
while ((f = da->get_next()) != "") {
- if (da->current_is_dir())
+ if (da->current_is_dir()) {
dirs.push_back(f);
- else {
+ } else {
String fullpath = cur_dir + f;
// Test also against path without res:// so that filters like `file.txt` can work.
String fullpath_no_prefix = cur_dir_no_prefix + f;
@@ -486,8 +458,9 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S
for (int i = 0; i < dirs.size(); ++i) {
String dir = dirs[i];
- if (dir.begins_with("."))
+ if (dir.begins_with(".")) {
continue;
+ }
da->change_dir(dir);
_edit_files_with_filter(da, p_filters, r_list, exclude);
da->change_dir("..");
@@ -495,15 +468,16 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S
}
void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) {
-
- if (p_filter == "")
+ if (p_filter == "") {
return;
+ }
Vector<String> split = p_filter.split(",");
Vector<String> filters;
for (int i = 0; i < split.size(); i++) {
String f = split[i].strip_edges();
- if (f.empty())
+ if (f.empty()) {
continue;
+ }
filters.push_back(f);
}
@@ -514,19 +488,16 @@ void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &
}
void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) {
-
if (p_preset.is_valid()) {
export_preset = p_preset;
}
}
Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const {
-
return export_preset;
}
void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) {
-
ExtraFile ef;
ef.data = p_file;
ef.path = p_path;
@@ -535,7 +506,6 @@ void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p
}
void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &tags) {
-
shared_objects.push_back(SharedObject(p_path, tags));
}
@@ -591,21 +561,18 @@ Vector<String> EditorExportPlugin::get_ios_project_static_libs() const {
}
void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) {
-
if (get_script_instance()) {
get_script_instance()->call("_export_file", p_path, p_type, p_features);
}
}
void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
-
if (get_script_instance()) {
get_script_instance()->call("_export_begin", p_features, p_debug, p_path, p_flags);
}
}
void EditorExportPlugin::_export_end_script() {
-
if (get_script_instance()) {
get_script_instance()->call("_export_end");
}
@@ -618,12 +585,10 @@ void EditorExportPlugin::_export_begin(const Set<String> &p_features, bool p_deb
}
void EditorExportPlugin::skip() {
-
skipped = true;
}
void EditorExportPlugin::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags"), &EditorExportPlugin::add_shared_object);
ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib);
ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file);
@@ -656,7 +621,6 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai
}
if (p_preset->get_custom_features() != String()) {
-
Vector<String> tmp_custom_list = p_preset->get_custom_features().split(",");
for (int i = 0; i < tmp_custom_list.size(); i++) {
@@ -707,8 +671,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
Vector<String> files = p_preset->get_files_to_export();
for (int i = 0; i < files.size(); i++) {
- if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene")
+ if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene") {
continue;
+ }
_export_find_dependencies(files[i], paths);
}
@@ -723,7 +688,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
for (int i = 0; i < export_plugins.size(); i++) {
-
export_plugins.write[i]->set_export_preset(p_preset);
if (p_so_func) {
@@ -747,7 +711,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
int total = paths.size();
for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
-
String path = E->get();
String type = ResourceLoader::get_resource_type(path);
@@ -767,7 +730,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
Set<String> remap_features;
for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
-
String remap = F->get();
String feature = remap.get_slice(".", 1);
if (features.has(feature)) {
@@ -782,7 +744,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
err = OK;
for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
-
String remap = F->get();
if (remap == "path") {
String remapped_path = config->get_value("remap", remap);
@@ -812,7 +773,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
} else {
-
bool do_export = true;
for (int i = 0; i < export_plugins.size(); i++) {
if (export_plugins[i]->get_script_instance()) { //script based
@@ -840,8 +800,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
export_plugins.write[i]->_clear();
- if (!do_export)
+ if (!do_export) {
break; //apologies, not exporting
+ }
}
//just store it as it comes
if (do_export) {
@@ -858,7 +819,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
Vector<String> custom_list;
if (p_preset->get_custom_features() != String()) {
-
Vector<String> tmp_custom_list = p_preset->get_custom_features().split(",");
for (int i = 0; i < tmp_custom_list.size(); i++) {
@@ -871,7 +831,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
ProjectSettings::CustomMap custom_map;
if (path_remaps.size()) {
- if (1) { //new remap mode, use always as it's friendlier with multiple .pck exports
+ if (true) { //new remap mode, use always as it's friendlier with multiple .pck exports
for (int i = 0; i < path_remaps.size(); i += 2) {
String from = path_remaps[i];
String to = path_remaps[i + 1];
@@ -924,7 +884,6 @@ Error EditorExportPlatform::_add_shared_object(void *p_userdata, const SharedObj
}
Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files, bool p_embed, int64_t *r_embedded_start, int64_t *r_embedded_size) {
-
EditorProgress ep("savepack", TTR("Packing"), 102, true);
String tmppath = EditorSettings::get_singleton()->get_cache_dir().plus_file("packtmp");
@@ -1009,7 +968,6 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
int header_padding = _get_pad(PCK_PADDING, header_size);
for (int i = 0; i < pd.file_ofs.size(); i++) {
-
int string_len = pd.file_ofs[i].path_utf8.length();
int pad = _get_pad(4, string_len);
@@ -1041,10 +999,10 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
uint8_t buf[bufsize];
while (true) {
-
int got = ftmp->get_buffer(buf, bufsize);
- if (got <= 0)
+ if (got <= 0) {
break;
+ }
f->store_buffer(buf, got);
}
@@ -1074,7 +1032,6 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
}
Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
-
EditorProgress ep("savezip", TTR("Packing"), 102, true);
FileAccess *src_f;
@@ -1086,8 +1043,9 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co
zd.zip = zip;
Error err = export_project_files(p_preset, _save_zip_file, &zd);
- if (err != OK && err != ERR_SKIP)
+ if (err != OK && err != ERR_SKIP) {
ERR_PRINT("Failed to export project files");
+ }
zipClose(zip, nullptr);
@@ -1105,12 +1063,12 @@ Error EditorExportPlatform::export_zip(const Ref<EditorExportPreset> &p_preset,
}
void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) {
-
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
- if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
+ if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) {
host = "localhost";
+ }
if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
@@ -1124,7 +1082,6 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
}
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) {
-
r_flags.push_back("--remote-debug");
r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port));
@@ -1133,14 +1090,13 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
if (breakpoints.size()) {
-
r_flags.push_back("--breakpoints");
String bpoints;
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
-
bpoints += E->get().replace(" ", "%20");
- if (E->next())
+ if (E->next()) {
bpoints += ",";
+ }
}
r_flags.push_back(bpoints);
@@ -1148,15 +1104,14 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
}
if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) {
-
r_flags.push_back("--debug-collisions");
}
if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) {
-
r_flags.push_back("--debug-navigation");
}
}
+
EditorExportPlatform::EditorExportPlatform() {
}
@@ -1165,11 +1120,9 @@ EditorExportPlatform::EditorExportPlatform() {
EditorExport *EditorExport::singleton = nullptr;
void EditorExport::_save() {
-
Ref<ConfigFile> config;
config.instance();
for (int i = 0; i < export_presets.size(); i++) {
-
Ref<EditorExportPreset> preset = export_presets[i];
String section = "preset." + itos(i);
@@ -1215,42 +1168,39 @@ void EditorExport::_save() {
}
void EditorExport::save_presets() {
-
- if (block_save)
+ if (block_save) {
return;
+ }
save_timer->start();
}
void EditorExport::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("export_presets_updated"));
}
void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
-
export_platforms.push_back(p_platform);
}
int EditorExport::get_export_platform_count() {
-
return export_platforms.size();
}
Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
-
ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>());
return export_platforms[p_idx];
}
void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) {
-
- if (p_at_pos < 0)
+ if (p_at_pos < 0) {
export_presets.push_back(p_preset);
- else
+ } else {
export_presets.insert(p_at_pos, p_preset);
+ }
}
String EditorExportPlatform::test_etc2() const {
-
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
bool etc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc");
bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2");
@@ -1265,62 +1215,60 @@ String EditorExportPlatform::test_etc2() const {
}
int EditorExport::get_export_preset_count() const {
-
return export_presets.size();
}
Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) {
-
ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>());
return export_presets[p_idx];
}
void EditorExport::remove_export_preset(int p_idx) {
-
export_presets.remove(p_idx);
save_presets();
}
void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
-
if (export_plugins.find(p_plugin) == -1) {
export_plugins.push_back(p_plugin);
}
}
void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) {
-
export_plugins.erase(p_plugin);
}
Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
-
return export_plugins;
}
void EditorExport::_notification(int p_what) {
-
- if (p_what == NOTIFICATION_ENTER_TREE) {
- load_config();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ load_config();
+ } break;
+ case NOTIFICATION_PROCESS: {
+ update_export_presets();
+ } break;
}
}
void EditorExport::load_config() {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load("res://export_presets.cfg");
- if (err != OK)
+ if (err != OK) {
return;
+ }
block_save = true;
int index = 0;
while (true) {
-
String section = "preset." + itos(index);
- if (!config->has_section(section))
+ if (!config->has_section(section)) {
break;
+ }
String platform = config->get_value(section, "platform");
@@ -1360,11 +1308,14 @@ void EditorExport::load_config() {
}
if (get_files) {
-
Vector<String> files = config->get_value(section, "export_files");
for (int i = 0; i < files.size(); i++) {
- preset->add_export_file(files[i]);
+ if (!FileAccess::exists(files[i])) {
+ preset->remove_export_file(files[i]);
+ } else {
+ preset->add_export_file(files[i]);
+ }
}
}
@@ -1392,7 +1343,6 @@ void EditorExport::load_config() {
config->get_section_keys(option_section, &options);
for (List<String>::Element *E = options.front(); E; E = E->next()) {
-
Variant value = config->get_value(option_section, E->get());
preset->set(E->get(), value);
@@ -1405,8 +1355,50 @@ void EditorExport::load_config() {
block_save = false;
}
-bool EditorExport::poll_export_platforms() {
+void EditorExport::update_export_presets() {
+ Map<StringName, List<EditorExportPlatform::ExportOption>> platform_options;
+
+ for (int i = 0; i < export_platforms.size(); i++) {
+ Ref<EditorExportPlatform> platform = export_platforms[i];
+
+ if (platform->should_update_export_options()) {
+ List<EditorExportPlatform::ExportOption> options;
+ platform->get_export_options(&options);
+
+ platform_options[platform->get_name()] = options;
+ }
+ }
+ bool export_presets_updated = false;
+ for (int i = 0; i < export_presets.size(); i++) {
+ Ref<EditorExportPreset> preset = export_presets[i];
+ if (platform_options.has(preset->get_platform()->get_name())) {
+ export_presets_updated = true;
+
+ List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()];
+
+ // Copy the previous preset values
+ Map<StringName, Variant> previous_values = preset->values;
+
+ // Clear the preset properties and values prior to reloading
+ preset->properties.clear();
+ preset->values.clear();
+
+ for (List<EditorExportPlatform::ExportOption>::Element *E = options.front(); E; E = E->next()) {
+ preset->properties.push_back(E->get().option);
+
+ StringName option_name = E->get().option.name;
+ preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().default_value;
+ }
+ }
+ }
+
+ if (export_presets_updated) {
+ emit_signal(_export_presets_updated);
+ }
+}
+
+bool EditorExport::poll_export_platforms() {
bool changed = false;
for (int i = 0; i < export_platforms.size(); i++) {
if (export_platforms.write[i]->poll_export()) {
@@ -1418,7 +1410,6 @@ bool EditorExport::poll_export_platforms() {
}
EditorExport::EditorExport() {
-
save_timer = memnew(Timer);
add_child(save_timer);
save_timer->set_wait_time(0.8);
@@ -1426,7 +1417,10 @@ EditorExport::EditorExport() {
save_timer->connect("timeout", callable_mp(this, &EditorExport::_save));
block_save = false;
+ _export_presets_updated = "export_presets_updated";
+
singleton = this;
+ set_process(true);
}
EditorExport::~EditorExport() {
@@ -1435,7 +1429,6 @@ EditorExport::~EditorExport() {
//////////
void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
-
if (p_preset->get("texture_format/s3tc")) {
r_features->push_back("s3tc");
}
@@ -1454,7 +1447,6 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &
}
void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
-
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
@@ -1467,21 +1459,18 @@ void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
}
String EditorExportPlatformPC::get_name() const {
-
return name;
}
String EditorExportPlatformPC::get_os_name() const {
-
return os_name;
}
-Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
+Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
return logo;
}
bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
-
String err;
bool valid = false;
@@ -1507,8 +1496,9 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset,
valid = dvalid || rvalid;
r_missing_templates = !valid;
- if (!err.empty())
+ if (!err.empty()) {
r_error = err;
+ }
return valid;
}
@@ -1544,7 +1534,6 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr
template_path = template_path.strip_edges();
if (template_path == String()) {
-
if (p_preset->get("binary_format/64_bits")) {
if (p_debug) {
template_path = find_export_template(debug_file_64);
@@ -1583,7 +1572,6 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr
int64_t embedded_size;
err = save_pack(p_preset, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size);
if (err == OK && p_preset->get("binary_format/embed_pck")) {
-
if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) {
EditorNode::get_singleton()->show_warning(TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."));
return ERR_INVALID_PARAMETER;
@@ -1632,25 +1620,22 @@ void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) {
}
void EditorExportPlatformPC::set_release_64(const String &p_file) {
-
release_file_64 = p_file;
}
void EditorExportPlatformPC::set_release_32(const String &p_file) {
-
release_file_32 = p_file;
}
-void EditorExportPlatformPC::set_debug_64(const String &p_file) {
+void EditorExportPlatformPC::set_debug_64(const String &p_file) {
debug_file_64 = p_file;
}
-void EditorExportPlatformPC::set_debug_32(const String &p_file) {
+void EditorExportPlatformPC::set_debug_32(const String &p_file) {
debug_file_32 = p_file;
}
void EditorExportPlatformPC::add_platform_feature(const String &p_feature) {
-
extra_features.insert(p_feature);
}
@@ -1664,7 +1649,6 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
}
void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) {
-
if (p_features.has("bptc")) {
if (p_preset->has("texture_format/no_bptc_fallbacks")) {
p_features.erase("s3tc");
@@ -1673,27 +1657,22 @@ void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<Edito
}
int EditorExportPlatformPC::get_chmod_flags() const {
-
return chmod_flags;
}
void EditorExportPlatformPC::set_chmod_flags(int p_flags) {
-
chmod_flags = p_flags;
}
EditorExportPlatformPC::FixUpEmbeddedPckFunc EditorExportPlatformPC::get_fixup_embedded_pck_func() const {
-
return fixup_embedded_pck_func;
}
void EditorExportPlatformPC::set_fixup_embedded_pck_func(FixUpEmbeddedPckFunc p_fixup_embedded_pck_func) {
-
fixup_embedded_pck_func = p_fixup_embedded_pck_func;
}
EditorExportPlatformPC::EditorExportPlatformPC() {
-
chmod_flags = -1;
fixup_embedded_pck_func = nullptr;
}
@@ -1701,15 +1680,15 @@ EditorExportPlatformPC::EditorExportPlatformPC() {
///////////////////////
void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
-
String extension = p_path.get_extension().to_lower();
if (extension != "tres" && extension != "tscn") {
return;
}
bool convert = GLOBAL_GET("editor/convert_text_resources_to_binary_on_export");
- if (!convert)
+ if (!convert) {
return;
+ }
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpfile.res");
Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
if (err != OK) {
@@ -1726,6 +1705,5 @@ void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, con
}
EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() {
-
GLOBAL_DEF("editor/convert_text_resources_to_binary_on_export", false);
}
diff --git a/editor/editor_export.h b/editor/editor_export.h
index 50d1ff66c6..8ad8326f10 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -43,7 +43,6 @@ class EditorFileSystemDirectory;
struct EditorProgress;
class EditorExportPreset : public Reference {
-
GDCLASS(EditorExportPreset, Reference);
public:
@@ -61,14 +60,14 @@ public:
private:
Ref<EditorExportPlatform> platform;
- ExportFilter export_filter;
+ ExportFilter export_filter = EXPORT_ALL_RESOURCES;
String include_filter;
String exclude_filter;
String export_path;
String exporter;
Set<String> selected_files;
- bool runnable;
+ bool runnable = false;
Vector<String> patches;
@@ -82,7 +81,7 @@ private:
String custom_features;
- int script_mode;
+ int script_mode = MODE_SCRIPT_COMPILED;
String script_key;
protected:
@@ -95,6 +94,8 @@ public:
bool has(const StringName &p_property) const { return values.has(p_property); }
+ void update_files_to_export();
+
Vector<String> get_files_to_export() const;
void add_export_file(const String &p_path);
@@ -136,7 +137,7 @@ public:
const List<PropertyInfo> &get_properties() const { return properties; }
- EditorExportPreset();
+ EditorExportPreset() {}
};
struct SharedObject {
@@ -152,7 +153,6 @@ struct SharedObject {
};
class EditorExportPlatform : public Reference {
-
GDCLASS(EditorExportPlatform, Reference);
public:
@@ -161,7 +161,6 @@ public:
private:
struct SavedData {
-
uint64_t ofs;
uint64_t size;
Vector<uint8_t> md5;
@@ -173,7 +172,6 @@ private:
};
struct PackData {
-
FileAccess *f;
Vector<SavedData> file_ofs;
EditorProgress *ep;
@@ -181,7 +179,6 @@ private:
};
struct ZipData {
-
void *zip;
EditorProgress *ep;
};
@@ -232,6 +229,7 @@ public:
virtual Ref<EditorExportPreset> create_preset();
virtual void get_export_options(List<ExportOption> *r_options) = 0;
+ virtual bool should_update_export_options() { return false; }
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; }
virtual String get_os_name() const = 0;
@@ -355,6 +353,8 @@ class EditorExport : public Node {
Vector<Ref<EditorExportPreset>> export_presets;
Vector<Ref<EditorExportPlugin>> export_plugins;
+ StringName _export_presets_updated;
+
Timer *save_timer;
bool block_save;
@@ -386,7 +386,7 @@ public:
Vector<Ref<EditorExportPlugin>> get_export_plugins();
void load_config();
-
+ void update_export_presets();
bool poll_export_platforms();
EditorExport();
@@ -394,7 +394,6 @@ public:
};
class EditorExportPlatformPC : public EditorExportPlatform {
-
GDCLASS(EditorExportPlatformPC, EditorExportPlatform);
public:
@@ -456,7 +455,6 @@ public:
};
class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin {
-
GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin);
public:
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index e2b79efb43..2a410c03e7 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "editor_feature_profile.h"
+
#include "core/io/json.h"
#include "core/os/dir_access.h"
#include "editor/editor_settings.h"
@@ -86,7 +87,6 @@ bool EditorFeatureProfile::is_class_editor_disabled(const StringName &p_class) c
}
void EditorFeatureProfile::set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled) {
-
if (p_disabled) {
if (!disabled_properties.has(p_class)) {
disabled_properties[p_class] = Set<StringName>();
@@ -101,8 +101,8 @@ void EditorFeatureProfile::set_disable_class_property(const StringName &p_class,
}
}
}
-bool EditorFeatureProfile::is_class_property_disabled(const StringName &p_class, const StringName &p_property) const {
+bool EditorFeatureProfile::is_class_property_disabled(const StringName &p_class, const StringName &p_property) const {
if (!disabled_properties.has(p_class)) {
return false;
}
@@ -119,10 +119,10 @@ bool EditorFeatureProfile::has_class_properties_disabled(const StringName &p_cla
}
void EditorFeatureProfile::set_disable_feature(Feature p_feature, bool p_disable) {
-
ERR_FAIL_INDEX(p_feature, FEATURE_MAX);
features_disabled[p_feature] = p_disable;
}
+
bool EditorFeatureProfile::is_feature_disabled(Feature p_feature) const {
ERR_FAIL_INDEX_V(p_feature, FEATURE_MAX, false);
return features_disabled[p_feature];
@@ -134,7 +134,6 @@ String EditorFeatureProfile::get_feature_name(Feature p_feature) {
}
Error EditorFeatureProfile::save_to_file(const String &p_path) {
-
Dictionary json;
json["type"] = "feature_profile";
Array dis_classes;
@@ -180,7 +179,6 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
}
Error EditorFeatureProfile::load_from_file(const String &p_path) {
-
Error err;
String text = FileAccess::get_file_as_string(p_path, &err);
if (err != OK) {
@@ -232,7 +230,6 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) {
}
if (json.has("disabled_features")) {
-
Array disabled_features_arr = json["disabled_features"];
for (int i = 0; i < FEATURE_MAX; i++) {
bool found = false;
@@ -253,7 +250,6 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) {
}
void EditorFeatureProfile::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_disable_class", "class_name", "disable"), &EditorFeatureProfile::set_disable_class);
ClassDB::bind_method(D_METHOD("is_class_disabled", "class_name"), &EditorFeatureProfile::is_class_disabled);
@@ -282,7 +278,6 @@ void EditorFeatureProfile::_bind_methods() {
}
EditorFeatureProfile::EditorFeatureProfile() {
-
for (int i = 0; i < FEATURE_MAX; i++) {
features_disabled[i] = false;
}
@@ -292,7 +287,6 @@ EditorFeatureProfile::EditorFeatureProfile() {
void EditorFeatureProfileManager::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
-
current_profile = EDITOR_GET("_default_feature_profile");
if (current_profile != String()) {
current.instance();
@@ -317,7 +311,6 @@ String EditorFeatureProfileManager::_get_selected_profile() {
}
void EditorFeatureProfileManager::_update_profile_list(const String &p_select_profile) {
-
String selected_profile;
if (p_select_profile == String()) { //default, keep
if (profile_list->get_selected() >= 0) {
@@ -361,7 +354,7 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr
}
if (name == current_profile) {
- name += " (current)";
+ name += " " + TTR("(current)");
}
profile_list->add_item(name);
int index = profile_list->get_item_count() - 1;
@@ -371,21 +364,22 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr
}
}
+ class_list_vbc->set_visible(selected_profile != String());
+ property_list_vbc->set_visible(selected_profile != String());
+ no_profile_selected_help->set_visible(selected_profile == String());
profile_actions[PROFILE_CLEAR]->set_disabled(current_profile == String());
profile_actions[PROFILE_ERASE]->set_disabled(selected_profile == String());
profile_actions[PROFILE_EXPORT]->set_disabled(selected_profile == String());
profile_actions[PROFILE_SET]->set_disabled(selected_profile == String());
- current_profile_name->set_text(current_profile);
+ current_profile_name->set_text(current_profile != String() ? current_profile : TTR("(none)"));
_update_selected_profile();
}
void EditorFeatureProfileManager::_profile_action(int p_action) {
-
switch (p_action) {
case PROFILE_CLEAR: {
-
EditorSettings::get_singleton()->set("_default_feature_profile", "");
EditorSettings::get_singleton()->save();
current_profile = "";
@@ -395,7 +389,6 @@ void EditorFeatureProfileManager::_profile_action(int p_action) {
_emit_current_profile_changed();
} break;
case PROFILE_SET: {
-
String selected = _get_selected_profile();
ERR_FAIL_COND(selected == String());
if (selected == current_profile) {
@@ -410,22 +403,18 @@ void EditorFeatureProfileManager::_profile_action(int p_action) {
_emit_current_profile_changed();
} break;
case PROFILE_IMPORT: {
-
import_profiles->popup_centered_ratio();
} break;
case PROFILE_EXPORT: {
-
export_profile->popup_centered_ratio();
export_profile->set_current_file(_get_selected_profile() + ".profile");
} break;
case PROFILE_NEW: {
-
new_profile_dialog->popup_centered();
new_profile_name->clear();
new_profile_name->grab_focus();
} break;
case PROFILE_ERASE: {
-
String selected = _get_selected_profile();
ERR_FAIL_COND(selected == String());
@@ -436,7 +425,6 @@ void EditorFeatureProfileManager::_profile_action(int p_action) {
}
void EditorFeatureProfileManager::_erase_selected_profile() {
-
String selected = _get_selected_profile();
ERR_FAIL_COND(selected == String());
DirAccessRef da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
@@ -467,15 +455,17 @@ void EditorFeatureProfileManager::_create_new_profile() {
new_profile->save_to_file(file);
_update_profile_list(name);
+ // The newly created profile is the first one, make it the current profile automatically.
+ if (profile_list->get_item_count() == 1) {
+ _profile_action(PROFILE_SET);
+ }
}
void EditorFeatureProfileManager::_profile_selected(int p_what) {
-
_update_selected_profile();
}
void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) {
-
TreeItem *class_item = class_list->create_item(p_parent);
class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
class_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_class, "Node"));
@@ -522,9 +512,9 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S
}
void EditorFeatureProfileManager::_class_list_item_selected() {
-
- if (updating_features)
+ if (updating_features) {
return;
+ }
property_list->clear();
@@ -567,10 +557,10 @@ void EditorFeatureProfileManager::_class_list_item_selected() {
ClassDB::get_property_list(class_name, &props, true);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String name = E->get().name;
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) {
continue;
+ }
TreeItem *property = property_list->create_item(properties);
property->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
property->set_editable(0, true);
@@ -586,9 +576,9 @@ void EditorFeatureProfileManager::_class_list_item_selected() {
}
void EditorFeatureProfileManager::_class_list_item_edited() {
-
- if (updating_features)
+ if (updating_features) {
return;
+ }
TreeItem *item = class_list->get_edited();
if (!item) {
@@ -611,8 +601,9 @@ void EditorFeatureProfileManager::_class_list_item_edited() {
}
void EditorFeatureProfileManager::_property_item_edited() {
- if (updating_features)
+ if (updating_features) {
return;
+ }
TreeItem *class_item = class_list->get_selected();
if (!class_item) {
@@ -651,7 +642,6 @@ void EditorFeatureProfileManager::_property_item_edited() {
}
void EditorFeatureProfileManager::_update_selected_profile() {
-
String class_selected;
int feature_selected = -1;
@@ -690,7 +680,6 @@ void EditorFeatureProfileManager::_update_selected_profile() {
TreeItem *features = class_list->create_item(root);
features->set_text(0, TTR("Enabled Features:"));
for (int i = 0; i < EditorFeatureProfile::FEATURE_MAX; i++) {
-
TreeItem *feature = class_list->create_item(features);
feature->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
feature->set_text(0, TTRGET(EditorFeatureProfile::get_feature_name(EditorFeatureProfile::Feature(i))));
@@ -718,7 +707,6 @@ void EditorFeatureProfileManager::_update_selected_profile() {
}
void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths) {
-
//test it first
for (int i = 0; i < p_paths.size(); i++) {
Ref<EditorFeatureProfile> profile;
@@ -750,10 +738,13 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths
}
_update_profile_list();
+ // The newly imported profile is the first one, make it the current profile automatically.
+ if (profile_list->get_item_count() == 1) {
+ _profile_action(PROFILE_SET);
+ }
}
void EditorFeatureProfileManager::_export_profile(const String &p_path) {
-
ERR_FAIL_COND(edited.is_null());
Error err = edited->save_to_file(p_path);
if (err != OK) {
@@ -762,7 +753,6 @@ void EditorFeatureProfileManager::_export_profile(const String &p_path) {
}
void EditorFeatureProfileManager::_save_and_update() {
-
String edited_path = _get_selected_profile();
ERR_FAIL_COND(edited_path == String());
ERR_FAIL_COND(edited.is_null());
@@ -775,7 +765,6 @@ void EditorFeatureProfileManager::_save_and_update() {
}
void EditorFeatureProfileManager::_emit_current_profile_changed() {
-
emit_signal("current_feature_profile_changed");
}
@@ -790,20 +779,19 @@ Ref<EditorFeatureProfile> EditorFeatureProfileManager::get_current_profile() {
EditorFeatureProfileManager *EditorFeatureProfileManager::singleton = nullptr;
void EditorFeatureProfileManager::_bind_methods() {
-
ClassDB::bind_method("_update_selected_profile", &EditorFeatureProfileManager::_update_selected_profile);
ADD_SIGNAL(MethodInfo("current_feature_profile_changed"));
}
EditorFeatureProfileManager::EditorFeatureProfileManager() {
-
VBoxContainer *main_vbc = memnew(VBoxContainer);
add_child(main_vbc);
HBoxContainer *name_hbc = memnew(HBoxContainer);
current_profile_name = memnew(LineEdit);
name_hbc->add_child(current_profile_name);
+ current_profile_name->set_text(TTR("(none)"));
current_profile_name->set_editable(false);
current_profile_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
profile_actions[PROFILE_CLEAR] = memnew(Button(TTR("Unset")));
@@ -852,7 +840,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
h_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_vbc->add_child(h_split);
- VBoxContainer *class_list_vbc = memnew(VBoxContainer);
+ class_list_vbc = memnew(VBoxContainer);
h_split->add_child(class_list_vbc);
class_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -862,17 +850,30 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
class_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
class_list->connect("cell_selected", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_selected));
class_list->connect("item_edited", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_edited), varray(), CONNECT_DEFERRED);
+ // It will be displayed once the user creates or chooses a profile.
+ class_list_vbc->hide();
- VBoxContainer *property_list_vbc = memnew(VBoxContainer);
+ property_list_vbc = memnew(VBoxContainer);
h_split->add_child(property_list_vbc);
property_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
property_list = memnew(Tree);
- property_list_vbc->add_margin_child(TTR("Class Options"), property_list, true);
+ property_list_vbc->add_margin_child(TTR("Class Options:"), property_list, true);
property_list->set_hide_root(true);
property_list->set_hide_folding(true);
property_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
property_list->connect("item_edited", callable_mp(this, &EditorFeatureProfileManager::_property_item_edited), varray(), CONNECT_DEFERRED);
+ // It will be displayed once the user creates or chooses a profile.
+ property_list_vbc->hide();
+
+ no_profile_selected_help = memnew(Label(TTR("Create or import a profile to edit available classes and properties.")));
+ // Add some spacing above the help label.
+ Ref<StyleBoxEmpty> sb = memnew(StyleBoxEmpty);
+ sb->set_default_margin(MARGIN_TOP, 20 * EDSCALE);
+ no_profile_selected_help->add_theme_style_override("normal", sb);
+ no_profile_selected_help->set_align(Label::ALIGN_CENTER);
+ no_profile_selected_help->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ h_split->add_child(no_profile_selected_help);
new_profile_dialog = memnew(ConfirmationDialog);
new_profile_dialog->set_title(TTR("New profile name:"));
diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h
index 5ae2398027..38413e35a2 100644
--- a/editor/editor_feature_profile.h
+++ b/editor/editor_feature_profile.h
@@ -94,7 +94,6 @@ public:
VARIANT_ENUM_CAST(EditorFeatureProfile::Feature)
class EditorFeatureProfileManager : public AcceptDialog {
-
GDCLASS(EditorFeatureProfileManager, AcceptDialog);
enum Action {
@@ -121,8 +120,11 @@ class EditorFeatureProfileManager : public AcceptDialog {
HSplitContainer *h_split;
+ VBoxContainer *class_list_vbc;
Tree *class_list;
+ VBoxContainer *property_list_vbc;
Tree *property_list;
+ Label *no_profile_selected_help;
EditorFileDialog *import_profiles;
EditorFileDialog *export_profile;
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 2411852541..5ae5d1cb31 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -55,9 +55,7 @@ VBoxContainer *EditorFileDialog::get_vbox() {
}
void EditorFileDialog::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
// update icons
mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons"));
mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons"));
@@ -72,13 +70,13 @@ void EditorFileDialog::_notification(int p_what) {
fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons"));
} else if (p_what == NOTIFICATION_PROCESS) {
-
if (preview_waiting) {
preview_wheel_timeout -= get_process_delta_time();
if (preview_wheel_timeout <= 0) {
preview_wheel_index++;
- if (preview_wheel_index >= 8)
+ if (preview_wheel_index >= 8) {
preview_wheel_index = 0;
+ }
Ref<Texture2D> frame = item_list->get_theme_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons");
preview->set_texture(frame);
preview_wheel_timeout = 0.1;
@@ -86,10 +84,10 @@ void EditorFileDialog::_notification(int p_what) {
}
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
-
bool is_showing_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
- if (show_hidden_files != is_showing_hidden)
+ if (show_hidden_files != is_showing_hidden) {
set_show_hidden_files(is_showing_hidden);
+ }
set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
// update icons
@@ -106,7 +104,6 @@ void EditorFileDialog::_notification(int p_what) {
// DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD
invalidate();
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
if (!is_visible()) {
set_process_unhandled_input(false);
}
@@ -114,13 +111,10 @@ void EditorFileDialog::_notification(int p_what) {
}
void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
-
if (k->is_pressed()) {
-
bool handled = false;
if (ED_IS_SHORTCUT("file_dialog/go_back", p_event)) {
@@ -186,22 +180,20 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void EditorFileDialog::set_enable_multiple_selection(bool p_enable) {
-
item_list->set_select_mode(p_enable ? ItemList::SELECT_MULTI : ItemList::SELECT_SINGLE);
};
Vector<String> EditorFileDialog::get_selected_files() const {
-
Vector<String> list;
for (int i = 0; i < item_list->get_item_count(); i++) {
- if (item_list->is_selected(i))
+ if (item_list->is_selected(i)) {
list.push_back(item_list->get_item_text(i));
+ }
}
return list;
};
void EditorFileDialog::update_dir() {
-
if (drives->is_visible()) {
drives->select(dir_access->get_current_drive());
}
@@ -210,7 +202,6 @@ void EditorFileDialog::update_dir() {
// Disable "Open" button only when selecting file(s) mode.
get_ok()->set_disabled(_is_open_should_be_disabled());
switch (mode) {
-
case FILE_MODE_OPEN_FILE:
case FILE_MODE_OPEN_FILES:
get_ok()->set_text(TTR("Open"));
@@ -226,7 +217,6 @@ void EditorFileDialog::update_dir() {
}
void EditorFileDialog::_dir_entered(String p_dir) {
-
dir_access->change_dir(p_dir);
file->set_text("");
invalidate();
@@ -235,12 +225,10 @@ void EditorFileDialog::_dir_entered(String p_dir) {
}
void EditorFileDialog::_file_entered(const String &p_file) {
-
_action_pressed();
}
void EditorFileDialog::_save_confirm_pressed() {
-
String f = dir_access->get_current_dir().plus_file(file->get_text());
_save_to_recent();
hide();
@@ -248,16 +236,16 @@ void EditorFileDialog::_save_confirm_pressed() {
}
void EditorFileDialog::_post_popup() {
-
ConfirmationDialog::_post_popup();
if (invalidated) {
update_file_list();
invalidated = false;
}
- if (mode == FILE_MODE_SAVE_FILE)
+ if (mode == FILE_MODE_SAVE_FILE) {
file->grab_focus();
- else
+ } else {
item_list->grab_focus();
+ }
if (mode == FILE_MODE_OPEN_DIR) {
file_box->set_visible(false);
@@ -265,8 +253,9 @@ void EditorFileDialog::_post_popup() {
file_box->set_visible(true);
}
- if (is_visible() && get_current_file() != "")
+ if (is_visible() && get_current_file() != "") {
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
+ }
if (is_visible()) {
Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog");
@@ -277,8 +266,9 @@ void EditorFileDialog::_post_popup() {
Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs();
for (int i = 0; i < recentd.size(); i++) {
bool cres = recentd[i].begins_with("res://");
- if (cres != res)
+ if (cres != res) {
continue;
+ }
String name = recentd[i];
if (res && name == "res://") {
name = "/";
@@ -302,9 +292,9 @@ void EditorFileDialog::_post_popup() {
}
void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
-
- if (display_mode == DISPLAY_LIST || p_preview.is_null())
+ if (display_mode == DISPLAY_LIST || p_preview.is_null()) {
return;
+ }
for (int i = 0; i < item_list->get_item_count(); i++) {
Dictionary d = item_list->get_item_metadata(i);
@@ -317,12 +307,10 @@ void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture
}
void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
-
set_process(false);
preview_waiting = false;
if (p_preview.is_valid() && get_current_path() == p_path) {
-
preview->set_texture(p_preview);
if (display_mode == DISPLAY_THUMBNAILS) {
preview_vb->hide();
@@ -337,9 +325,9 @@ void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D
}
void EditorFileDialog::_request_single_thumbnail(const String &p_path) {
-
- if (!FileAccess::exists(p_path))
+ if (!FileAccess::exists(p_path)) {
return;
+ }
set_process(true);
preview_waiting = true;
@@ -348,15 +336,14 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) {
}
void EditorFileDialog::_action_pressed() {
-
if (mode == FILE_MODE_OPEN_FILES) {
-
String fbase = dir_access->get_current_dir();
Vector<String> files;
for (int i = 0; i < item_list->get_item_count(); i++) {
- if (item_list->is_selected(i))
+ if (item_list->is_selected(i)) {
files.push_back(fbase.plus_file(item_list->get_item_text(i)));
+ }
}
if (files.size()) {
@@ -375,7 +362,6 @@ void EditorFileDialog::_action_pressed() {
hide();
emit_signal("file_selected", f);
} else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) {
-
String path = dir_access->get_current_dir();
path = path.replace("\\", "/");
@@ -397,7 +383,6 @@ void EditorFileDialog::_action_pressed() {
}
if (mode == FILE_MODE_SAVE_FILE) {
-
bool valid = false;
if (filter->get_selected() == filter->get_item_count() - 1) {
@@ -405,29 +390,27 @@ void EditorFileDialog::_action_pressed() {
} else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
for (int i = 0; i < filters.size(); i++) {
-
String flt = filters[i].get_slice(";", 0);
for (int j = 0; j < flt.get_slice_count(","); j++) {
-
String str = flt.get_slice(",", j).strip_edges();
if (f.match(str)) {
valid = true;
break;
}
}
- if (valid)
+ if (valid) {
break;
+ }
}
} else {
int idx = filter->get_selected();
- if (filters.size() > 1)
+ if (filters.size() > 1) {
idx--;
+ }
if (idx >= 0 && idx < filters.size()) {
-
String flt = filters[idx].get_slice(";", 0);
int filterSliceCount = flt.get_slice_count(",");
for (int j = 0; j < filterSliceCount; j++) {
-
String str = (flt.get_slice(",", j).strip_edges());
if (f.match(str)) {
valid = true;
@@ -448,7 +431,6 @@ void EditorFileDialog::_action_pressed() {
}
if (!valid) {
-
exterr->popup_centered(Size2(250, 80) * EDSCALE);
return;
}
@@ -457,7 +439,6 @@ void EditorFileDialog::_action_pressed() {
confirm_save->set_text(TTR("File Exists, Overwrite?"));
confirm_save->popup_centered(Size2(200, 80));
} else {
-
_save_to_recent();
hide();
emit_signal("file_selected", f);
@@ -466,22 +447,20 @@ void EditorFileDialog::_action_pressed() {
}
void EditorFileDialog::_cancel_pressed() {
-
file->set_text("");
invalidate();
hide();
}
void EditorFileDialog::_item_selected(int p_item) {
-
int current = p_item;
- if (current < 0 || current >= item_list->get_item_count())
+ if (current < 0 || current >= item_list->get_item_count()) {
return;
+ }
Dictionary d = item_list->get_item_metadata(current);
if (!d["dir"]) {
-
file->set_text(d["name"]);
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
} else if (mode == FILE_MODE_OPEN_DIR) {
@@ -492,15 +471,14 @@ void EditorFileDialog::_item_selected(int p_item) {
}
void EditorFileDialog::_multi_selected(int p_item, bool p_selected) {
-
int current = p_item;
- if (current < 0 || current >= item_list->get_item_count())
+ if (current < 0 || current >= item_list->get_item_count()) {
return;
+ }
Dictionary d = item_list->get_item_metadata(current);
if (!d["dir"] && p_selected) {
-
file->set_text(d["name"]);
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
}
@@ -509,12 +487,10 @@ void EditorFileDialog::_multi_selected(int p_item, bool p_selected) {
}
void EditorFileDialog::_items_clear_selection() {
-
item_list->unselect_all();
// If nothing is selected, then block Open button.
switch (mode) {
-
case FILE_MODE_OPEN_FILE:
case FILE_MODE_OPEN_FILES:
get_ok()->set_text(TTR("Open"));
@@ -534,7 +510,6 @@ void EditorFileDialog::_items_clear_selection() {
}
void EditorFileDialog::_push_history() {
-
local_history.resize(local_history_pos + 1);
String new_path = dir_access->get_current_dir();
if (local_history.size() == 0 || new_path != local_history[local_history_pos]) {
@@ -544,16 +519,16 @@ void EditorFileDialog::_push_history() {
dir_next->set_disabled(true);
}
}
-void EditorFileDialog::_item_dc_selected(int p_item) {
+void EditorFileDialog::_item_dc_selected(int p_item) {
int current = p_item;
- if (current < 0 || current >= item_list->get_item_count())
+ if (current < 0 || current >= item_list->get_item_count()) {
return;
+ }
Dictionary d = item_list->get_item_metadata(current);
if (d["dir"]) {
-
dir_access->change_dir(d["name"]);
call_deferred("_update_file_list");
call_deferred("_update_dir");
@@ -561,13 +536,11 @@ void EditorFileDialog::_item_dc_selected(int p_item) {
_push_history();
} else {
-
_action_pressed();
}
}
void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p_pos) {
-
// Right click on specific file(s) or folder(s).
item_menu->clear();
item_menu->set_size(Size2(1, 1));
@@ -608,7 +581,6 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p
}
void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) {
-
// Right click on folder background. Deselect all files so that actions are applied on the current folder.
for (int i = 0; i < item_list->get_item_count(); i++) {
item_list->unselect(i);
@@ -629,9 +601,7 @@ void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) {
}
void EditorFileDialog::_item_menu_id_pressed(int p_option) {
-
switch (p_option) {
-
case ITEM_MENU_COPY_PATH: {
Dictionary item_meta = item_list->get_item_metadata(item_list->get_current());
DisplayServer::get_singleton()->clipboard_set(item_meta["path"]);
@@ -669,20 +639,21 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) {
}
bool EditorFileDialog::_is_open_should_be_disabled() {
-
- if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE)
+ if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE) {
return false;
+ }
Vector<int> items = item_list->get_selected_items();
- if (items.size() == 0)
+ if (items.size() == 0) {
return mode != FILE_MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder.
+ }
for (int i = 0; i < items.size(); i++) {
-
Dictionary d = item_list->get_item_metadata(items.get(i));
- if (((mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES) && d["dir"]) || (mode == FILE_MODE_OPEN_DIR && !d["dir"]))
+ if (((mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES) && d["dir"]) || (mode == FILE_MODE_OPEN_DIR && !d["dir"])) {
return true;
+ }
}
return false;
@@ -691,8 +662,9 @@ bool EditorFileDialog::_is_open_should_be_disabled() {
void EditorFileDialog::update_file_name() {
int idx = filter->get_selected() - 1;
if ((idx == -1 && filter->get_item_count() == 2) || (filter->get_item_count() > 2 && idx >= 0 && idx < filter->get_item_count() - 2)) {
- if (idx == -1)
+ if (idx == -1) {
idx += 1;
+ }
String filter_str = filters[idx];
String file_str = file->get_text();
String base_name = file_str.get_basename();
@@ -708,7 +680,6 @@ void EditorFileDialog::update_file_name() {
// DO NOT USE THIS FUNCTION UNLESS NEEDED, CALL INVALIDATE() INSTEAD.
void EditorFileDialog::update_file_list() {
-
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
thumbnail_size *= EDSCALE;
Ref<Texture2D> folder_thumbnail;
@@ -720,7 +691,6 @@ void EditorFileDialog::update_file_list() {
item_list->get_v_scroll()->set_value(0);
if (display_mode == DISPLAY_THUMBNAILS) {
-
item_list->set_max_columns(0);
item_list->set_icon_mode(ItemList::ICON_MODE_TOP);
item_list->set_fixed_column_width(thumbnail_size * 3 / 2);
@@ -738,14 +708,14 @@ void EditorFileDialog::update_file_list() {
preview_vb->hide();
} else {
-
item_list->set_icon_mode(ItemList::ICON_MODE_LEFT);
item_list->set_max_columns(1);
item_list->set_max_text_lines(1);
item_list->set_fixed_column_width(0);
item_list->set_fixed_icon_size(Size2());
- if (preview->get_texture().is_valid())
+ if (preview->get_texture().is_valid()) {
preview_vb->show();
+ }
}
String cdir = dir_access->get_current_dir();
@@ -760,15 +730,16 @@ void EditorFileDialog::update_file_list() {
String item;
while ((item = dir_access->get_next()) != "") {
-
- if (item == "." || item == "..")
+ if (item == "." || item == "..") {
continue;
+ }
if (show_hidden_files || !dir_access->current_is_hidden()) {
- if (!dir_access->current_is_dir())
+ if (!dir_access->current_is_dir()) {
files.push_back(item);
- else
+ } else {
dirs.push_back(item);
+ }
}
}
@@ -781,10 +752,8 @@ void EditorFileDialog::update_file_list() {
item_list->add_item(dir_name);
if (display_mode == DISPLAY_THUMBNAILS) {
-
item_list->set_item_icon(item_list->get_item_count() - 1, folder_thumbnail);
} else {
-
item_list->set_item_icon(item_list->get_item_count() - 1, folder);
}
@@ -802,55 +771,45 @@ void EditorFileDialog::update_file_list() {
List<String> patterns;
// build filter
if (filter->get_selected() == filter->get_item_count() - 1) {
-
// match all
} else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
for (int i = 0; i < filters.size(); i++) {
-
String f = filters[i].get_slice(";", 0);
for (int j = 0; j < f.get_slice_count(","); j++) {
-
patterns.push_back(f.get_slice(",", j).strip_edges());
}
}
} else {
int idx = filter->get_selected();
- if (filters.size() > 1)
+ if (filters.size() > 1) {
idx--;
+ }
if (idx >= 0 && idx < filters.size()) {
-
String f = filters[idx].get_slice(";", 0);
for (int j = 0; j < f.get_slice_count(","); j++) {
-
patterns.push_back(f.get_slice(",", j).strip_edges());
}
}
}
while (!files.empty()) {
-
bool match = patterns.empty();
for (List<String>::Element *E = patterns.front(); E; E = E->next()) {
-
if (files.front()->get().matchn(E->get())) {
-
match = true;
break;
}
}
if (match) {
-
item_list->add_item(files.front()->get());
if (get_icon_func) {
-
Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get()));
if (display_mode == DISPLAY_THUMBNAILS) {
-
item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail);
item_list->set_item_tag_icon(item_list->get_item_count() - 1, icon);
} else {
@@ -869,8 +828,9 @@ void EditorFileDialog::update_file_list() {
EditorResourcePreview::get_singleton()->queue_resource_preview(fullpath, this, "_thumbnail_result", fullpath);
}
- if (file->get_text() == files.front()->get())
+ if (file->get_text() == files.front()->get()) {
item_list->set_current(item_list->get_item_count() - 1);
+ }
}
files.pop_front();
@@ -905,7 +865,6 @@ void EditorFileDialog::_filter_selected(int) {
}
void EditorFileDialog::update_filters() {
-
filter->clear();
if (filters.size() > 1) {
@@ -915,64 +874,65 @@ void EditorFileDialog::update_filters() {
for (int i = 0; i < MIN(max_filters, filters.size()); i++) {
String flt = filters[i].get_slice(";", 0).strip_edges();
- if (i > 0)
+ if (i > 0) {
all_filters += ", ";
+ }
all_filters += flt;
}
- if (max_filters < filters.size())
+ if (max_filters < filters.size()) {
all_filters += ", ...";
+ }
filter->add_item(TTR("All Recognized") + " (" + all_filters + ")");
}
for (int i = 0; i < filters.size(); i++) {
-
String flt = filters[i].get_slice(";", 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
- if (desc.length())
+ if (desc.length()) {
filter->add_item(desc + " (" + flt + ")");
- else
+ } else {
filter->add_item("(" + flt + ")");
+ }
}
filter->add_item(TTR("All Files (*)"));
}
void EditorFileDialog::clear_filters() {
-
filters.clear();
update_filters();
invalidate();
}
-void EditorFileDialog::add_filter(const String &p_filter) {
+void EditorFileDialog::add_filter(const String &p_filter) {
filters.push_back(p_filter);
update_filters();
invalidate();
}
String EditorFileDialog::get_current_dir() const {
-
return dir_access->get_current_dir();
}
-String EditorFileDialog::get_current_file() const {
+String EditorFileDialog::get_current_file() const {
return file->get_text();
}
-String EditorFileDialog::get_current_path() const {
+String EditorFileDialog::get_current_path() const {
return dir_access->get_current_dir().plus_file(file->get_text());
}
-void EditorFileDialog::set_current_dir(const String &p_dir) {
- if (p_dir.is_rel_path())
+void EditorFileDialog::set_current_dir(const String &p_dir) {
+ if (p_dir.is_rel_path()) {
dir_access->change_dir(OS::get_singleton()->get_resource_dir());
+ }
dir_access->change_dir(p_dir);
update_dir();
invalidate();
}
-void EditorFileDialog::set_current_file(const String &p_file) {
+void EditorFileDialog::set_current_file(const String &p_file) {
file->set_text(p_file);
update_dir();
invalidate();
@@ -982,19 +942,19 @@ void EditorFileDialog::set_current_file(const String &p_file) {
file->grab_focus();
}
- if (is_visible())
+ if (is_visible()) {
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
+ }
}
-void EditorFileDialog::set_current_path(const String &p_path) {
- if (!p_path.size())
+void EditorFileDialog::set_current_path(const String &p_path) {
+ if (!p_path.size()) {
return;
+ }
int pos = MAX(p_path.find_last("/"), p_path.find_last("\\"));
if (pos == -1) {
-
set_current_file(p_path);
} else {
-
String dir = p_path.substr(0, pos);
String file = p_path.substr(pos + 1, p_path.length());
set_current_dir(dir);
@@ -1003,10 +963,8 @@ void EditorFileDialog::set_current_path(const String &p_path) {
}
void EditorFileDialog::set_file_mode(FileMode p_mode) {
-
mode = p_mode;
switch (mode) {
-
case FILE_MODE_OPEN_FILE:
get_ok()->set_text(TTR("Open"));
set_title(TTR("Open a File"));
@@ -1048,27 +1006,23 @@ void EditorFileDialog::set_file_mode(FileMode p_mode) {
}
EditorFileDialog::FileMode EditorFileDialog::get_file_mode() const {
-
return mode;
}
void EditorFileDialog::set_access(Access p_access) {
-
ERR_FAIL_INDEX(p_access, 3);
- if (access == p_access)
+ if (access == p_access) {
return;
+ }
memdelete(dir_access);
switch (p_access) {
case ACCESS_FILESYSTEM: {
-
dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
} break;
case ACCESS_RESOURCES: {
-
dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
} break;
case ACCESS_USERDATA: {
-
dir_access = DirAccess::create(DirAccess::ACCESS_USERDATA);
} break;
}
@@ -1080,7 +1034,6 @@ void EditorFileDialog::set_access(Access p_access) {
}
void EditorFileDialog::invalidate() {
-
if (is_visible()) {
update_file_list();
_update_favorites();
@@ -1091,12 +1044,10 @@ void EditorFileDialog::invalidate() {
}
EditorFileDialog::Access EditorFileDialog::get_access() const {
-
return access;
}
void EditorFileDialog::_make_dir_confirm() {
-
Error err = dir_access->make_dir(makedirname->get_text());
if (err == OK) {
dir_access->change_dir(makedirname->get_text());
@@ -1112,13 +1063,11 @@ void EditorFileDialog::_make_dir_confirm() {
}
void EditorFileDialog::_make_dir() {
-
makedialog->popup_centered(Size2(250, 80) * EDSCALE);
makedirname->grab_focus();
}
void EditorFileDialog::_delete_items() {
-
// Collect the selected folders and files to delete and check them in the deletion dependency dialog.
Vector<String> folders;
Vector<String> files;
@@ -1140,7 +1089,6 @@ void EditorFileDialog::_delete_items() {
}
void EditorFileDialog::_select_drive(int p_idx) {
-
String d = drives->get_item_text(p_idx);
dir_access->change_dir(d);
file->set_text("");
@@ -1150,7 +1098,6 @@ void EditorFileDialog::_select_drive(int p_idx) {
}
void EditorFileDialog::_update_drives() {
-
int dc = dir_access->get_drive_count();
if (dc == 0 || access != ACCESS_FILESYSTEM) {
drives->hide();
@@ -1174,7 +1121,6 @@ void EditorFileDialog::_update_drives() {
}
void EditorFileDialog::_favorite_selected(int p_idx) {
-
dir_access->change_dir(favorites->get_item_metadata(p_idx));
file->set_text("");
update_dir();
@@ -1183,7 +1129,6 @@ void EditorFileDialog::_favorite_selected(int p_idx) {
}
void EditorFileDialog::_favorite_move_up() {
-
int current = favorites->get_current();
if (current > 0 && current < favorites->get_item_count()) {
@@ -1192,8 +1137,9 @@ void EditorFileDialog::_favorite_move_up() {
int a_idx = favorited.find(String(favorites->get_item_metadata(current - 1)));
int b_idx = favorited.find(String(favorites->get_item_metadata(current)));
- if (a_idx == -1 || b_idx == -1)
+ if (a_idx == -1 || b_idx == -1) {
return;
+ }
SWAP(favorited.write[a_idx], favorited.write[b_idx]);
EditorSettings::get_singleton()->set_favorites(favorited);
@@ -1202,8 +1148,8 @@ void EditorFileDialog::_favorite_move_up() {
update_file_list();
}
}
-void EditorFileDialog::_favorite_move_down() {
+void EditorFileDialog::_favorite_move_down() {
int current = favorites->get_current();
if (current >= 0 && current < favorites->get_item_count() - 1) {
@@ -1212,8 +1158,9 @@ void EditorFileDialog::_favorite_move_down() {
int a_idx = favorited.find(String(favorites->get_item_metadata(current + 1)));
int b_idx = favorited.find(String(favorites->get_item_metadata(current)));
- if (a_idx == -1 || b_idx == -1)
+ if (a_idx == -1 || b_idx == -1) {
return;
+ }
SWAP(favorited.write[a_idx], favorited.write[b_idx]);
EditorSettings::get_singleton()->set_favorites(favorited);
@@ -1224,7 +1171,6 @@ void EditorFileDialog::_favorite_move_down() {
}
void EditorFileDialog::_update_favorites() {
-
bool res = access == ACCESS_RESOURCES;
String current = get_current_dir();
@@ -1237,20 +1183,23 @@ void EditorFileDialog::_update_favorites() {
Vector<String> favorited = EditorSettings::get_singleton()->get_favorites();
for (int i = 0; i < favorited.size(); i++) {
bool cres = favorited[i].begins_with("res://");
- if (cres != res)
+ if (cres != res) {
continue;
+ }
String name = favorited[i];
bool setthis = false;
if (res && name == "res://") {
- if (name == current)
+ if (name == current) {
setthis = true;
+ }
name = "/";
favorites->add_item(name, folder_icon);
} else if (name.ends_with("/")) {
- if (name == current || name == current + "/")
+ if (name == current || name == current + "/") {
setthis = true;
+ }
name = name.substr(0, name.length() - 1);
name = name.get_file();
@@ -1274,16 +1223,18 @@ void EditorFileDialog::_favorite_pressed() {
bool res = access == ACCESS_RESOURCES;
String cd = get_current_dir();
- if (!cd.ends_with("/"))
+ if (!cd.ends_with("/")) {
cd += "/";
+ }
Vector<String> favorited = EditorSettings::get_singleton()->get_favorites();
bool found = false;
for (int i = 0; i < favorited.size(); i++) {
bool cres = favorited[i].begins_with("res://");
- if (cres != res)
+ if (cres != res) {
continue;
+ }
if (favorited[i] == cd) {
found = true;
@@ -1291,10 +1242,11 @@ void EditorFileDialog::_favorite_pressed() {
}
}
- if (found)
+ if (found) {
favorited.erase(cd);
- else
+ } else {
favorited.push_back(cd);
+ }
EditorSettings::get_singleton()->set_favorites(favorited);
@@ -1302,7 +1254,6 @@ void EditorFileDialog::_favorite_pressed() {
}
void EditorFileDialog::_recent_selected(int p_idx) {
-
Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs();
ERR_FAIL_INDEX(p_idx, recentd.size());
@@ -1313,7 +1264,6 @@ void EditorFileDialog::_recent_selected(int p_idx) {
}
void EditorFileDialog::_go_up() {
-
dir_access->change_dir("..");
update_file_list();
update_dir();
@@ -1321,7 +1271,6 @@ void EditorFileDialog::_go_up() {
}
void EditorFileDialog::_go_back() {
-
if (local_history_pos <= 0) {
return;
}
@@ -1334,8 +1283,8 @@ void EditorFileDialog::_go_back() {
dir_prev->set_disabled(local_history_pos == 0);
dir_next->set_disabled(local_history_pos == local_history.size() - 1);
}
-void EditorFileDialog::_go_forward() {
+void EditorFileDialog::_go_forward() {
if (local_history_pos == local_history.size() - 1) {
return;
}
@@ -1354,9 +1303,9 @@ bool EditorFileDialog::default_show_hidden_files = false;
EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode = DISPLAY_THUMBNAILS;
void EditorFileDialog::set_display_mode(DisplayMode p_mode) {
-
- if (display_mode == p_mode)
+ if (display_mode == p_mode) {
return;
+ }
if (p_mode == DISPLAY_THUMBNAILS) {
mode_list->set_pressed(false);
mode_thumbnails->set_pressed(true);
@@ -1369,12 +1318,10 @@ void EditorFileDialog::set_display_mode(DisplayMode p_mode) {
}
EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const {
-
return display_mode;
}
void EditorFileDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorFileDialog::_unhandled_input);
ClassDB::bind_method(D_METHOD("_cancel_pressed"), &EditorFileDialog::_cancel_pressed);
@@ -1452,7 +1399,6 @@ void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) {
}
void EditorFileDialog::_save_to_recent() {
-
String dir = get_current_dir();
Vector<String> recent = EditorSettings::get_singleton()->get_recent_dirs();
@@ -1476,17 +1422,14 @@ void EditorFileDialog::_save_to_recent() {
}
void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) {
-
disable_overwrite_warning = p_disable;
}
bool EditorFileDialog::is_overwrite_warning_disabled() const {
-
return disable_overwrite_warning;
}
EditorFileDialog::EditorFileDialog() {
-
show_hidden_files = default_show_hidden_files;
display_mode = default_display_mode;
local_history_pos = 0;
@@ -1721,8 +1664,9 @@ EditorFileDialog::EditorFileDialog() {
vbox = vbc;
invalidated = true;
- if (register_func)
+ if (register_func) {
register_func(this);
+ }
preview_wheel_timeout = 0;
preview_wheel_index = 0;
@@ -1730,8 +1674,8 @@ EditorFileDialog::EditorFileDialog() {
}
EditorFileDialog::~EditorFileDialog() {
-
- if (unregister_func)
+ if (unregister_func) {
unregister_func(this);
+ }
memdelete(dir_access);
}
diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h
index 8efb8f5368..cbedfc72a6 100644
--- a/editor/editor_file_dialog.h
+++ b/editor/editor_file_dialog.h
@@ -45,7 +45,6 @@
class DependencyRemoveDialog;
class EditorFileDialog : public ConfirmationDialog {
-
GDCLASS(EditorFileDialog, ConfirmationDialog);
public:
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index c211d5852a..d88c61d7b2 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -46,53 +46,48 @@ EditorFileSystem *EditorFileSystem::singleton = nullptr;
#define CACHE_FILE_NAME "filesystem_cache6"
void EditorFileSystemDirectory::sort_files() {
-
files.sort_custom<FileInfoSort>();
}
int EditorFileSystemDirectory::find_file_index(const String &p_file) const {
-
for (int i = 0; i < files.size(); i++) {
- if (files[i]->file == p_file)
+ if (files[i]->file == p_file) {
return i;
+ }
}
return -1;
}
-int EditorFileSystemDirectory::find_dir_index(const String &p_dir) const {
+int EditorFileSystemDirectory::find_dir_index(const String &p_dir) const {
for (int i = 0; i < subdirs.size(); i++) {
- if (subdirs[i]->name == p_dir)
+ if (subdirs[i]->name == p_dir) {
return i;
+ }
}
return -1;
}
int EditorFileSystemDirectory::get_subdir_count() const {
-
return subdirs.size();
}
EditorFileSystemDirectory *EditorFileSystemDirectory::get_subdir(int p_idx) {
-
ERR_FAIL_INDEX_V(p_idx, subdirs.size(), nullptr);
return subdirs[p_idx];
}
int EditorFileSystemDirectory::get_file_count() const {
-
return files.size();
}
String EditorFileSystemDirectory::get_file(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, files.size(), "");
return files[p_idx]->file;
}
String EditorFileSystemDirectory::get_path() const {
-
String p;
const EditorFileSystemDirectory *d = this;
while (d->parent) {
@@ -104,7 +99,6 @@ String EditorFileSystemDirectory::get_path() const {
}
String EditorFileSystemDirectory::get_file_path(int p_idx) const {
-
String file = get_file(p_idx);
const EditorFileSystemDirectory *d = this;
while (d->parent) {
@@ -116,13 +110,11 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const {
}
Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, files.size(), Vector<String>());
return files[p_idx]->deps;
}
bool EditorFileSystemDirectory::get_file_import_is_valid(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, files.size(), false);
return files[p_idx]->import_valid;
}
@@ -140,23 +132,19 @@ String EditorFileSystemDirectory::get_file_script_class_icon_path(int p_idx) con
}
StringName EditorFileSystemDirectory::get_file_type(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, files.size(), "");
return files[p_idx]->type;
}
String EditorFileSystemDirectory::get_name() {
-
return name;
}
EditorFileSystemDirectory *EditorFileSystemDirectory::get_parent() {
-
return parent;
}
void EditorFileSystemDirectory::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_subdir_count"), &EditorFileSystemDirectory::get_subdir_count);
ClassDB::bind_method(D_METHOD("get_subdir", "idx"), &EditorFileSystemDirectory::get_subdir);
ClassDB::bind_method(D_METHOD("get_file_count"), &EditorFileSystemDirectory::get_file_count);
@@ -174,27 +162,22 @@ void EditorFileSystemDirectory::_bind_methods() {
}
EditorFileSystemDirectory::EditorFileSystemDirectory() {
-
modified_time = 0;
parent = nullptr;
verified = false;
}
EditorFileSystemDirectory::~EditorFileSystemDirectory() {
-
for (int i = 0; i < files.size(); i++) {
-
memdelete(files[i]);
}
for (int i = 0; i < subdirs.size(); i++) {
-
memdelete(subdirs[i]);
}
}
void EditorFileSystem::_scan_filesystem() {
-
ERR_FAIL_COND(!scanning || new_filesystem);
//read .fscache
@@ -212,7 +195,6 @@ void EditorFileSystem::_scan_filesystem() {
if (f) {
//read the disk cache
while (!f->eof_reached()) {
-
String l = f->get_line().strip_edges();
if (first) {
if (first_scan) {
@@ -229,8 +211,9 @@ void EditorFileSystem::_scan_filesystem() {
first = false;
continue;
}
- if (l == String())
+ if (l == String()) {
continue;
+ }
if (l.begins_with("::")) {
Vector<String> split = l.split("::");
@@ -282,7 +265,6 @@ void EditorFileSystem::_scan_filesystem() {
FileAccessRef f2 = FileAccess::open(update_cache, FileAccess::READ);
String l = f2->get_line().strip_edges();
while (l != String()) {
-
file_cache.erase(l); //erase cache for this, so it gets updated
l = f2->get_line().strip_edges();
}
@@ -319,7 +301,6 @@ void EditorFileSystem::_scan_filesystem() {
}
void EditorFileSystem::_save_filesystem_cache() {
-
group_file_cache.clear();
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME);
@@ -334,15 +315,14 @@ void EditorFileSystem::_save_filesystem_cache() {
}
void EditorFileSystem::_thread_func(void *_userdata) {
-
EditorFileSystem *sd = (EditorFileSystem *)_userdata;
sd->_scan_filesystem();
}
bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_imported_files) {
-
- if (!reimport_on_missing_imported_files && p_only_imported_files)
+ if (!reimport_on_missing_imported_files && p_only_imported_files) {
return false;
+ }
if (!FileAccess::exists(p_path + ".import")) {
return true;
@@ -378,7 +358,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
String dest_md5 = "";
while (true) {
-
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@@ -460,7 +439,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
//check source md5 matching
if (!p_only_imported_files) {
-
if (source_file != String() && source_file != p_path) {
return true; //file was moved, reimport
}
@@ -486,7 +464,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
}
bool EditorFileSystem::_update_scan_actions() {
-
sources_changed.clear();
bool fs_changed = false;
@@ -495,20 +472,17 @@ bool EditorFileSystem::_update_scan_actions() {
Vector<String> reloads;
for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) {
-
ItemAction &ia = E->get();
switch (ia.action) {
case ItemAction::ACTION_NONE: {
-
} break;
case ItemAction::ACTION_DIR_ADD: {
-
int idx = 0;
for (int i = 0; i < ia.dir->subdirs.size(); i++) {
-
- if (ia.new_dir->name < ia.dir->subdirs[i]->name)
+ if (ia.new_dir->name < ia.dir->subdirs[i]->name) {
break;
+ }
idx++;
}
if (idx == ia.dir->subdirs.size()) {
@@ -520,19 +494,17 @@ bool EditorFileSystem::_update_scan_actions() {
fs_changed = true;
} break;
case ItemAction::ACTION_DIR_REMOVE: {
-
ERR_CONTINUE(!ia.dir->parent);
ia.dir->parent->subdirs.erase(ia.dir);
memdelete(ia.dir);
fs_changed = true;
} break;
case ItemAction::ACTION_FILE_ADD: {
-
int idx = 0;
for (int i = 0; i < ia.dir->files.size(); i++) {
-
- if (ia.new_file->file < ia.dir->files[i]->file)
+ if (ia.new_file->file < ia.dir->files[i]->file) {
break;
+ }
idx++;
}
if (idx == ia.dir->files.size()) {
@@ -545,7 +517,6 @@ bool EditorFileSystem::_update_scan_actions() {
} break;
case ItemAction::ACTION_FILE_REMOVE: {
-
int idx = ia.dir->find_file_index(ia.file);
ERR_CONTINUE(idx == -1);
_delete_internal_files(ia.dir->files[idx]->file);
@@ -556,7 +527,6 @@ bool EditorFileSystem::_update_scan_actions() {
} break;
case ItemAction::ACTION_FILE_TEST_REIMPORT: {
-
int idx = ia.dir->find_file_index(ia.file);
ERR_CONTINUE(idx == -1);
String full_path = ia.dir->get_file_path(idx);
@@ -573,7 +543,6 @@ bool EditorFileSystem::_update_scan_actions() {
fs_changed = true;
} break;
case ItemAction::ACTION_FILE_RELOAD: {
-
int idx = ia.dir->find_file_index(ia.file);
ERR_CONTINUE(idx == -1);
String full_path = ia.dir->get_file_path(idx);
@@ -604,12 +573,13 @@ bool EditorFileSystem::_update_scan_actions() {
}
void EditorFileSystem::scan() {
-
- if (false /*&& bool(Globals::get_singleton()->get("debug/disable_scan"))*/)
+ if (false /*&& bool(Globals::get_singleton()->get("debug/disable_scan"))*/) {
return;
+ }
- if (scanning || scanning_changes || thread)
+ if (scanning || scanning_changes || thread) {
return;
+ }
_update_extensions();
@@ -618,8 +588,9 @@ void EditorFileSystem::scan() {
scanning = true;
scan_total = 0;
_scan_filesystem();
- if (filesystem)
+ if (filesystem) {
memdelete(filesystem);
+ }
//file_type_cache.clear();
filesystem = new_filesystem;
new_filesystem = nullptr;
@@ -630,7 +601,6 @@ void EditorFileSystem::scan() {
_queue_update_script_classes();
first_scan = false;
} else {
-
ERR_FAIL_COND(thread);
set_process(true);
Thread::Settings s;
@@ -644,14 +614,12 @@ void EditorFileSystem::scan() {
}
void EditorFileSystem::ScanProgress::update(int p_current, int p_total) const {
-
float ratio = low + ((hi - low) / p_total) * p_current;
progress->step(ratio * 1000);
EditorFileSystem::singleton->scan_total = ratio;
}
EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_current, int p_total) const {
-
ScanProgress sp = *this;
float slice = (sp.hi - sp.low) / p_total;
sp.low += slice * p_current;
@@ -660,7 +628,6 @@ EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_cur
}
void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) {
-
List<String> dirs;
List<String> files;
@@ -670,28 +637,30 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
da->list_dir_begin();
while (true) {
-
String f = da->get_next();
- if (f == "")
+ if (f == "") {
break;
+ }
- if (da->current_is_hidden())
+ if (da->current_is_hidden()) {
continue;
+ }
if (da->current_is_dir()) {
-
- if (f.begins_with(".")) // Ignore special and . / ..
+ if (f.begins_with(".")) { // Ignore special and . / ..
continue;
+ }
- if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this
+ if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) { // skip if another project inside this
continue;
- if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) // skip if another project inside this
+ }
+ if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) { // skip if another project inside this
continue;
+ }
dirs.push_back(f);
} else {
-
files.push_back(f);
}
}
@@ -705,15 +674,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
int idx = 0;
for (List<String>::Element *E = dirs.front(); E; E = E->next(), idx++) {
-
if (da->change_dir(E->get()) == OK) {
-
String d = da->get_current_dir();
if (d == cd || !d.begins_with(cd)) {
da->change_dir(cd); //avoid recursion
} else {
-
EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
efd->parent = p_dir;
@@ -723,9 +689,9 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
int idx2 = 0;
for (int i = 0; i < p_dir->subdirs.size(); i++) {
-
- if (efd->name < p_dir->subdirs[i]->name)
+ if (efd->name < p_dir->subdirs[i]->name) {
break;
+ }
idx2++;
}
if (idx2 == p_dir->subdirs.size()) {
@@ -744,7 +710,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
}
for (List<String>::Element *E = files.front(); E; E = E->next(), idx++) {
-
String ext = E->get().get_extension().to_lower();
if (!valid_extensions.has(ext)) {
continue; //invalid
@@ -759,7 +724,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
uint64_t mt = FileAccess::get_modified_time(path);
if (import_extensions.has(ext)) {
-
//is imported
uint64_t import_mt = 0;
if (FileAccess::exists(path + ".import")) {
@@ -767,7 +731,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
}
if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && !_test_for_reimport(path, true)) {
-
fi->type = fc->type;
fi->deps = fc->deps;
fi->modified_time = fc->modification_time;
@@ -795,7 +758,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
}
} else {
-
fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path);
fi->import_group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(path);
fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
@@ -810,7 +772,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
scan_actions.push_back(ia);
}
} else {
-
if (fc && fc->modification_time == mt) {
//not imported, so just update type if changed
fi->type = fc->type;
@@ -838,14 +799,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
}
void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress) {
-
uint64_t current_mtime = FileAccess::get_modified_time(p_dir->get_path());
bool updated_dir = false;
String cd = p_dir->get_path();
if (current_mtime != p_dir->modified_time || using_fat32_or_exfat) {
-
updated_dir = true;
p_dir->modified_time = current_mtime;
//ooooops, dir changed, see what's going on
@@ -853,12 +812,10 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
//first mark everything as veryfied
for (int i = 0; i < p_dir->files.size(); i++) {
-
p_dir->files[i]->verified = false;
}
for (int i = 0; i < p_dir->subdirs.size(); i++) {
-
p_dir->get_subdir(i)->verified = false;
}
@@ -869,26 +826,28 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
da->change_dir(cd);
da->list_dir_begin();
while (true) {
-
String f = da->get_next();
- if (f == "")
+ if (f == "") {
break;
+ }
- if (da->current_is_hidden())
+ if (da->current_is_hidden()) {
continue;
+ }
if (da->current_is_dir()) {
-
- if (f.begins_with(".")) // Ignore special and . / ..
+ if (f.begins_with(".")) { // Ignore special and . / ..
continue;
+ }
int idx = p_dir->find_dir_index(f);
if (idx == -1) {
-
- if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this
+ if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) { // skip if another project inside this
continue;
- if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) // skip if another project inside this
+ }
+ if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) { // skip if another project inside this
continue;
+ }
EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
@@ -911,8 +870,9 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
} else {
String ext = f.get_extension().to_lower();
- if (!valid_extensions.has(ext))
+ if (!valid_extensions.has(ext)) {
continue; //invalid
+ }
int idx = p_dir->find_file_index(f);
@@ -958,7 +918,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
}
for (int i = 0; i < p_dir->files.size(); i++) {
-
if (updated_dir && !p_dir->files[i]->verified) {
//this file was removed, add action to remove it
ItemAction ia;
@@ -983,7 +942,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
} else if (!FileAccess::exists(path + ".import")) {
reimport = true; //no .import file, obviously reimport
} else {
-
uint64_t import_mt = FileAccess::get_modified_time(path + ".import");
if (import_mt != p_dir->files[i]->import_modified_time) {
reimport = true;
@@ -993,7 +951,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
}
if (reimport) {
-
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_TEST_REIMPORT;
ia.dir = p_dir;
@@ -1005,7 +962,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
uint64_t mt = FileAccess::get_modified_time(path);
if (mt != p_dir->files[i]->modified_time) {
-
p_dir->files[i]->modified_time = mt; //save new time, but test for reload
ItemAction ia;
@@ -1018,7 +974,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
}
for (int i = 0; i < p_dir->subdirs.size(); i++) {
-
if (updated_dir && !p_dir->subdirs[i]->verified) {
//this directory was removed, add action to remove it
ItemAction ia;
@@ -1045,7 +1000,6 @@ void EditorFileSystem::_delete_internal_files(String p_file) {
}
void EditorFileSystem::_thread_func_sources(void *_userdata) {
-
EditorFileSystem *efs = (EditorFileSystem *)_userdata;
if (efs->filesystem) {
EditorProgressBG pr("sources", TTR("ScanSources"), 1000);
@@ -1059,12 +1013,10 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) {
}
void EditorFileSystem::get_changed_sources(List<String> *r_changed) {
-
*r_changed = sources_changed;
}
void EditorFileSystem::scan_changes() {
-
if (first_scan || // Prevent a premature changes scan from inhibiting the first full scan
scanning || scanning_changes || thread) {
scan_changes_pending = true;
@@ -1088,14 +1040,14 @@ void EditorFileSystem::scan_changes() {
sp.low = 0;
scan_total = 0;
_scan_fs_changes(filesystem, sp);
- if (_update_scan_actions())
+ if (_update_scan_actions()) {
emit_signal("filesystem_changed");
+ }
}
scanning_changes = false;
scanning_changes_done = true;
emit_signal("sources_changed", sources_changed.size() > 0);
} else {
-
ERR_FAIL_COND(thread_sources);
set_process(true);
scan_total = 0;
@@ -1106,11 +1058,8 @@ void EditorFileSystem::scan_changes() {
}
void EditorFileSystem::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
call_deferred("scan"); //this should happen after every editor node entered the tree
} break;
@@ -1130,22 +1079,20 @@ void EditorFileSystem::_notification(int p_what) {
set_process(false);
}
- if (filesystem)
+ if (filesystem) {
memdelete(filesystem);
- if (new_filesystem)
+ }
+ if (new_filesystem) {
memdelete(new_filesystem);
+ }
filesystem = nullptr;
new_filesystem = nullptr;
} break;
case NOTIFICATION_PROCESS: {
-
if (use_threads) {
-
if (scanning_changes) {
-
if (scanning_changes_done) {
-
scanning_changes = false;
set_process(false);
@@ -1153,18 +1100,19 @@ void EditorFileSystem::_notification(int p_what) {
Thread::wait_to_finish(thread_sources);
memdelete(thread_sources);
thread_sources = nullptr;
- if (_update_scan_actions())
+ if (_update_scan_actions()) {
emit_signal("filesystem_changed");
+ }
emit_signal("sources_changed", sources_changed.size() > 0);
_queue_update_script_classes();
first_scan = false;
}
} else if (!scanning) {
-
set_process(false);
- if (filesystem)
+ if (filesystem) {
memdelete(filesystem);
+ }
filesystem = new_filesystem;
new_filesystem = nullptr;
Thread::wait_to_finish(thread);
@@ -1187,36 +1135,33 @@ void EditorFileSystem::_notification(int p_what) {
}
bool EditorFileSystem::is_scanning() const {
-
return scanning || scanning_changes;
}
-float EditorFileSystem::get_scanning_progress() const {
+float EditorFileSystem::get_scanning_progress() const {
return scan_total;
}
EditorFileSystemDirectory *EditorFileSystem::get_filesystem() {
-
return filesystem;
}
void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, FileAccess *p_file) {
-
- if (!p_dir)
+ if (!p_dir) {
return; //none
+ }
p_file->store_line("::" + p_dir->get_path() + "::" + String::num(p_dir->modified_time));
for (int i = 0; i < p_dir->files.size(); i++) {
-
if (p_dir->files[i]->import_group_file != String()) {
group_file_cache.insert(p_dir->files[i]->import_group_file);
}
String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path;
s += "::";
for (int j = 0; j < p_dir->files[i]->deps.size(); j++) {
-
- if (j > 0)
+ if (j > 0) {
s += "<>";
+ }
s += p_dir->files[i]->deps[j];
}
@@ -1224,7 +1169,6 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir,
}
for (int i = 0; i < p_dir->subdirs.size(); i++) {
-
_save_filesystem_cache(p_dir->subdirs[i], p_file);
}
}
@@ -1232,33 +1176,35 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir,
bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirectory **r_d, int &r_file_pos) const {
//todo make faster
- if (!filesystem || scanning)
+ if (!filesystem || scanning) {
return false;
+ }
String f = ProjectSettings::get_singleton()->localize_path(p_file);
- if (!f.begins_with("res://"))
+ if (!f.begins_with("res://")) {
return false;
+ }
f = f.substr(6, f.length());
f = f.replace("\\", "/");
Vector<String> path = f.split("/");
- if (path.size() == 0)
+ if (path.size() == 0) {
return false;
+ }
String file = path[path.size() - 1];
path.resize(path.size() - 1);
EditorFileSystemDirectory *fs = filesystem;
for (int i = 0; i < path.size(); i++) {
-
- if (path[i].begins_with("."))
+ if (path[i].begins_with(".")) {
return false;
+ }
int idx = -1;
for (int j = 0; j < fs->get_subdir_count(); j++) {
-
if (fs->get_subdir(j)->get_name() == path[i]) {
idx = j;
break;
@@ -1274,26 +1220,25 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector
int idx2 = 0;
for (int j = 0; j < fs->get_subdir_count(); j++) {
-
- if (efsd->name < fs->get_subdir(j)->get_name())
+ if (efsd->name < fs->get_subdir(j)->get_name()) {
break;
+ }
idx2++;
}
- if (idx2 == fs->get_subdir_count())
+ if (idx2 == fs->get_subdir_count()) {
fs->subdirs.push_back(efsd);
- else
+ } else {
fs->subdirs.insert(idx2, efsd);
+ }
fs = efsd;
} else {
-
fs = fs->get_subdir(idx);
}
}
int cpos = -1;
for (int i = 0; i < fs->files.size(); i++) {
-
if (fs->files[i]->file == file) {
cpos = i;
break;
@@ -1307,12 +1252,10 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector
}
String EditorFileSystem::get_file_type(const String &p_file) const {
-
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
if (!_find_file(p_file, &fs, cpos)) {
-
return "";
}
@@ -1320,53 +1263,55 @@ String EditorFileSystem::get_file_type(const String &p_file) const {
}
EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int *r_index) const {
-
- if (!filesystem || scanning)
+ if (!filesystem || scanning) {
return nullptr;
+ }
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
if (!_find_file(p_file, &fs, cpos)) {
-
return nullptr;
}
- if (r_index)
+ if (r_index) {
*r_index = cpos;
+ }
return fs;
}
EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p_path) {
-
- if (!filesystem || scanning)
+ if (!filesystem || scanning) {
return nullptr;
+ }
String f = ProjectSettings::get_singleton()->localize_path(p_path);
- if (!f.begins_with("res://"))
+ if (!f.begins_with("res://")) {
return nullptr;
+ }
f = f.substr(6, f.length());
f = f.replace("\\", "/");
- if (f == String())
+ if (f == String()) {
return filesystem;
+ }
- if (f.ends_with("/"))
+ if (f.ends_with("/")) {
f = f.substr(0, f.length() - 1);
+ }
Vector<String> path = f.split("/");
- if (path.size() == 0)
+ if (path.size() == 0) {
return nullptr;
+ }
EditorFileSystemDirectory *fs = filesystem;
for (int i = 0; i < path.size(); i++) {
-
int idx = -1;
for (int j = 0; j < fs->get_subdir_count(); j++) {
-
if (fs->get_subdir(j)->get_name() == path[i]) {
idx = j;
break;
@@ -1376,7 +1321,6 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p
if (idx == -1) {
return nullptr;
} else {
-
fs = fs->get_subdir(idx);
}
}
@@ -1395,7 +1339,6 @@ void EditorFileSystem::_save_late_updated_files() {
}
Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) {
-
List<String> deps;
ResourceLoader::get_dependencies(p_path, &deps);
@@ -1408,7 +1351,6 @@ Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) {
}
String EditorFileSystem::_get_global_script_class(const String &p_type, const String &p_path, String *r_extends, String *r_icon_path) const {
-
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
if (ScriptServer::get_language(i)->handles_global_class_type(p_type)) {
String global_name;
@@ -1450,9 +1392,9 @@ void EditorFileSystem::_scan_script_classes(EditorFileSystemDirectory *p_dir) {
}
void EditorFileSystem::update_script_classes() {
-
- if (!update_script_classes_queued)
+ if (!update_script_classes_queued) {
return;
+ }
update_script_classes_queued = false;
ScriptServer::global_classes_clear();
@@ -1482,14 +1424,13 @@ void EditorFileSystem::_queue_update_script_classes() {
}
void EditorFileSystem::update_file(const String &p_file) {
-
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
if (!_find_file(p_file, &fs, cpos)) {
-
- if (!fs)
+ if (!fs) {
return;
+ }
}
if (!FileAccess::exists(p_file)) {
@@ -1508,15 +1449,15 @@ void EditorFileSystem::update_file(const String &p_file) {
String type = ResourceLoader::get_resource_type(p_file);
if (cpos == -1) {
-
//the file did not exist, it was added
late_added_files.insert(p_file); //remember that it was added. This mean it will be scanned and imported on editor restart
int idx = 0;
for (int i = 0; i < fs->files.size(); i++) {
- if (p_file < fs->files[i]->file)
+ if (p_file < fs->files[i]->file) {
break;
+ }
idx++;
}
@@ -1528,12 +1469,10 @@ void EditorFileSystem::update_file(const String &p_file) {
if (idx == fs->files.size()) {
fs->files.push_back(fi);
} else {
-
fs->files.insert(idx, fi);
}
cpos = idx;
} else {
-
//the file exists and it was updated, and was not added in this step.
//this means we must force upon next restart to scan it again, to get proper type and dependencies
late_update_files.insert(p_file);
@@ -1555,13 +1494,11 @@ void EditorFileSystem::update_file(const String &p_file) {
}
Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector<String> &p_files) {
-
String importer_name;
Map<String, Map<StringName, Variant>> source_file_options;
Map<String, String> base_paths;
for (int i = 0; i < p_files.size(); i++) {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load(p_files[i] + ".import");
@@ -1585,7 +1522,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
importer->get_import_options(&options);
//set default values
for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
-
source_file_options[p_files[i]][E->get().option.name] = E->get().default_value;
}
@@ -1611,7 +1547,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
//all went well, overwrite config files with proper remaps and md5s
for (Map<String, Map<StringName, Variant>>::Element *E = source_file_options.front(); E; E = E->next()) {
-
const String &file = E->key();
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file);
FileAccessRef f = FileAccess::open(file + ".import", FileAccess::WRITE);
@@ -1661,7 +1596,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
importer->get_import_options(&options);
//set default values
for (List<ResourceImporter::ImportOption>::Element *F = options.front(); F; F = F->next()) {
-
String base = F->get().option.name;
Variant v = F->get().default_value;
if (source_file_options[file].has(base)) {
@@ -1699,11 +1633,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
//if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it
//to reload properly
if (ResourceCache::has(file)) {
-
Resource *r = ResourceCache::get(file);
if (r->get_import_path() != String()) {
-
String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(file);
r->set_import_path(dst_path);
r->set_import_last_modified_time(0);
@@ -1717,7 +1649,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
}
void EditorFileSystem::_reimport_file(const String &p_file) {
-
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
bool found = _find_file(p_file, &fs, cpos);
@@ -1816,13 +1747,11 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
Vector<String> dest_paths;
if (err == OK) {
-
if (importer->get_save_extension() == "") {
//no path
} else if (import_variants.size()) {
//import with variants
for (List<String>::Element *E = import_variants.front(); E; E = E->next()) {
-
String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension();
f->store_line("path." + E->get() + "=\"" + path + "\"");
@@ -1835,7 +1764,6 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
}
} else {
-
f->store_line("valid=false");
}
@@ -1876,7 +1804,6 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
//store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) {
-
String base = E->get().option.name;
String value;
VariantWriter::write_to_string(params[base], value);
@@ -1907,11 +1834,9 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
//if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it
//to reload properly
if (ResourceCache::has(p_file)) {
-
Resource *r = ResourceCache::get(p_file);
if (r->get_import_path() != String()) {
-
String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_file);
r->set_import_path(dst_path);
r->set_import_last_modified_time(0);
@@ -1922,7 +1847,6 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
}
void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String>> &group_files, Set<String> &groups_to_reimport) {
-
int fc = efd->files.size();
const EditorFileSystemDirectory::FileInfo *const *files = efd->files.ptr();
for (int i = 0; i < fc; i++) {
@@ -1940,7 +1864,6 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str
}
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
-
{ //check that .import folder exists
DirAccess *da = DirAccess::open("res://");
if (da->change_dir(".import") != OK) {
@@ -1960,7 +1883,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
Set<String> groups_to_reimport;
for (int i = 0; i < p_files.size(); i++) {
-
String group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(p_files[i]);
if (group_file_cache.has(p_files[i])) {
@@ -1983,7 +1905,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
if (_find_file(p_files[i], &fs, cpos)) {
-
fs->files.write[cpos]->import_group_file = group_file;
}
}
@@ -2001,7 +1922,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
Map<String, Vector<String>> group_files;
_find_group_files(filesystem, group_files, groups_to_reimport);
for (Map<String, Vector<String>>::Element *E = group_files.front(); E; E = E->next()) {
-
Error err = _reimport_group(E->key(), E->get());
if (err == OK) {
_reimport_file(E->key());
@@ -2019,7 +1939,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
}
Error EditorFileSystem::_resource_import(const String &p_path) {
-
Vector<String> files;
files.push_back(p_path);
@@ -2034,13 +1953,10 @@ bool EditorFileSystem::is_group_file(const String &p_path) const {
}
void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const String &p_group_file, const String &p_new_location) {
-
int fc = efd->files.size();
EditorFileSystemDirectory::FileInfo *const *files = efd->files.ptrw();
for (int i = 0; i < fc; i++) {
-
if (files[i]->import_group_file == p_group_file) {
-
files[i]->import_group_file = p_new_location;
Ref<ConfigFile> config;
@@ -2051,7 +1967,6 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S
continue;
}
if (config->has_section_key("remap", "group_file")) {
-
config->set_value("remap", "group_file", p_new_location);
}
@@ -2076,7 +1991,6 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S
}
void EditorFileSystem::move_group_file(const String &p_path, const String &p_new_path) {
-
if (get_filesystem()) {
_move_group_files(get_filesystem(), p_path, p_new_path);
if (group_file_cache.has(p_path)) {
@@ -2087,7 +2001,6 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new
}
void EditorFileSystem::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_filesystem"), &EditorFileSystem::get_filesystem);
ClassDB::bind_method(D_METHOD("is_scanning"), &EditorFileSystem::is_scanning);
ClassDB::bind_method(D_METHOD("get_scanning_progress"), &EditorFileSystem::get_scanning_progress);
@@ -2105,27 +2018,23 @@ void EditorFileSystem::_bind_methods() {
}
void EditorFileSystem::_update_extensions() {
-
valid_extensions.clear();
import_extensions.clear();
List<String> extensionsl;
ResourceLoader::get_recognized_extensions_for_type("", &extensionsl);
for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) {
-
valid_extensions.insert(E->get());
}
extensionsl.clear();
ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl);
for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) {
-
import_extensions.insert(E->get());
}
}
EditorFileSystem::EditorFileSystem() {
-
ResourceLoader::import = _resource_import;
reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files", true);
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 55a2ed3d09..da27a63c64 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -40,7 +40,6 @@ class FileAccess;
struct EditorProgressBG;
class EditorFileSystemDirectory : public Object {
-
GDCLASS(EditorFileSystemDirectory, Object);
String name;
@@ -104,13 +103,11 @@ public:
};
class EditorFileSystem : public Node {
-
GDCLASS(EditorFileSystem, Node);
_THREAD_SAFE_CLASS_
struct ItemAction {
-
enum Action {
ACTION_NONE,
ACTION_DIR_ADD,
@@ -163,7 +160,6 @@ class EditorFileSystem : public Node {
/* Used for reading the filesystem cache file */
struct FileCache {
-
String type;
uint64_t modification_time;
uint64_t import_modification_time;
@@ -178,7 +174,6 @@ class EditorFileSystem : public Node {
HashMap<String, FileCache> file_cache;
struct ScanProgress {
-
float low;
float hi;
mutable EditorProgressBG *progress;
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp
index 507a77e641..f0e6e3a799 100644
--- a/editor/editor_folding.cpp
+++ b/editor/editor_folding.cpp
@@ -35,7 +35,6 @@
#include "editor_settings.h"
Vector<String> EditorFolding::_get_unfolds(const Object *p_object) {
-
Vector<String> sections;
sections.resize(p_object->editor_get_section_folding().size());
if (sections.size()) {
@@ -61,7 +60,6 @@ void EditorFolding::save_resource_folding(const RES &p_resource, const String &p
}
void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfolds) {
-
int uc = p_unfolds.size();
const String *r = p_unfolds.ptr();
p_object->editor_clear_section_folding();
@@ -71,7 +69,6 @@ void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfol
}
void EditorFolding::load_resource_folding(RES p_resource, const String &p_path) {
-
Ref<ConfigFile> config;
config.instance();
@@ -117,7 +114,6 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
if (E->get().type == Variant::OBJECT) {
RES res = p_node->get(E->get().name);
if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) {
-
Vector<String> res_unfolds = _get_unfolds(res.ptr());
resource_folds.push_back(res->get_path());
resource_folds.push_back(res_unfolds);
@@ -131,13 +127,14 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
_fill_folds(p_root, p_node->get_child(i), p_folds, resource_folds, nodes_folded, resources);
}
}
-void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) {
+void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) {
ERR_FAIL_NULL(p_scene);
FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- if (!file_check->file_exists(p_path)) //This can happen when creating scene from FilesystemDock. It has path, but no file.
+ if (!file_check->file_exists(p_path)) { //This can happen when creating scene from FilesystemDock. It has path, but no file.
return;
+ }
Ref<ConfigFile> config;
config.instance();
@@ -155,8 +152,8 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path
file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file);
config->save(file);
}
-void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
+void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
Ref<ConfigFile> config;
config.instance();
@@ -218,14 +215,12 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
}
bool EditorFolding::has_folding_data(const String &p_path) {
-
String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg";
file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file);
return FileAccess::exists(file);
}
void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
-
List<PropertyInfo> plist;
p_object->get_property_list(&plist);
String group_base;
@@ -234,7 +229,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
Set<String> unfold_group;
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_CATEGORY) {
group = "";
group_base = "";
@@ -249,7 +243,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
//can unfold
if (E->get().usage & PROPERTY_USAGE_EDITOR) {
-
if (group != "") { //group
if (group_base == String() || E->get().name.begins_with(group_base)) {
bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name);
@@ -271,7 +264,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) {
if (E->get().type == Variant::OBJECT) {
RES res = p_object->get(E->get().name);
if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) {
-
resources.insert(res);
_do_object_unfolds(res.ptr(), resources);
}
@@ -301,7 +293,6 @@ void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resou
}
void EditorFolding::unfold_scene(Node *p_scene) {
-
Set<RES> resources;
_do_node_unfolds(p_scene, p_scene, resources);
}
diff --git a/editor/editor_folding.h b/editor/editor_folding.h
index 5220907fe7..13f07b99b0 100644
--- a/editor/editor_folding.h
+++ b/editor/editor_folding.h
@@ -34,7 +34,6 @@
#include "scene/main/node.h"
class EditorFolding {
-
Vector<String> _get_unfolds(const Object *p_object);
void _set_unfolds(Object *p_object, const Vector<String> &p_unfolds);
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index b2bcab4717..f50ac6d580 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -43,7 +43,6 @@
DocData *EditorHelp::doc = nullptr;
void EditorHelp::_init_colors() {
-
title_color = get_theme_color("accent_color", "Editor");
text_color = get_theme_color("default_color", "RichTextLabel");
headline_color = get_theme_color("headline_color", "EditorHelp");
@@ -58,34 +57,31 @@ void EditorHelp::_init_colors() {
}
void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
-
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
Ref<InputEventKey> k = p_ev;
if (k.is_valid() && k->get_control() && k->get_keycode() == KEY_F) {
-
search->grab_focus();
search->select_all();
}
}
void EditorHelp::_search(bool p_search_previous) {
-
- if (p_search_previous)
+ if (p_search_previous) {
find_bar->search_prev();
- else
+ } else {
find_bar->search_next();
+ }
}
void EditorHelp::_class_list_select(const String &p_select) {
-
_goto_desc(p_select);
}
void EditorHelp::_class_desc_select(const String &p_select) {
-
if (p_select.begins_with("$")) { //enum
String select = p_select.substr(1, p_select.length());
String class_name;
@@ -182,10 +178,10 @@ void EditorHelp::_class_desc_resized() {
}
void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
-
String t = p_type;
- if (t.empty())
+ if (t.empty()) {
t = "void";
+ }
bool can_ref = (t != "void") || !p_enum.empty();
if (!p_enum.empty()) {
@@ -224,7 +220,6 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) {
}
String EditorHelp::_fix_constant(const String &p_constant) const {
-
if (p_constant.strip_edges() == "4294967295") {
return "0xFFFFFFFF";
}
@@ -241,7 +236,6 @@ String EditorHelp::_fix_constant(const String &p_constant) const {
}
void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) {
-
method_line[p_method.name] = class_desc->get_line_count() - 2; //gets overridden if description
const bool is_vararg = p_method.qualifiers.find("vararg") != -1;
@@ -249,6 +243,9 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
if (p_overview) {
class_desc->push_cell();
class_desc->push_align(RichTextLabel::ALIGN_RIGHT);
+ } else {
+ static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
+ class_desc->add_text(String(prefix));
}
_add_type(p_method.return_type, p_method.return_enum);
@@ -279,14 +276,14 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
for (int j = 0; j < p_method.arguments.size(); j++) {
class_desc->push_color(text_color);
- if (j > 0)
+ if (j > 0) {
class_desc->add_text(", ");
+ }
_add_text(p_method.arguments[j].name);
class_desc->add_text(": ");
_add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration);
if (p_method.arguments[j].default_value != "") {
-
class_desc->push_color(symbol_color);
class_desc->add_text(" = ");
class_desc->pop();
@@ -300,8 +297,9 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
if (is_vararg) {
class_desc->push_color(text_color);
- if (p_method.arguments.size())
+ if (p_method.arguments.size()) {
class_desc->add_text(", ");
+ }
class_desc->push_color(symbol_color);
class_desc->add_text("...");
class_desc->pop();
@@ -312,21 +310,21 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
class_desc->add_text(")");
class_desc->pop();
if (p_method.qualifiers != "") {
-
class_desc->push_color(qualifier_color);
class_desc->add_text(" ");
_add_text(p_method.qualifiers);
class_desc->pop();
}
- if (p_overview)
+ if (p_overview) {
class_desc->pop(); //cell
+ }
}
Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
-
- if (!doc->class_list.has(p_class))
+ if (!doc->class_list.has(p_class)) {
return ERR_DOES_NOT_EXIST;
+ }
select_locked = true;
@@ -334,8 +332,9 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
description_line = 0;
- if (p_class == edited_class)
+ if (p_class == edited_class) {
return OK; //already there
+ }
edited_class = p_class;
_update_doc();
@@ -343,8 +342,9 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
}
void EditorHelp::_update_doc() {
- if (!doc->class_list.has(edited_class))
+ if (!doc->class_list.has(edited_class)) {
return;
+ }
scroll_locked = true;
@@ -378,11 +378,9 @@ void EditorHelp::_update_doc() {
// Ascendents
if (cd.inherits != "") {
-
class_desc->push_color(title_color);
class_desc->push_font(doc_font);
class_desc->add_text(TTR("Inherits:") + " ");
- class_desc->pop();
String inherits = cd.inherits;
@@ -397,29 +395,25 @@ void EditorHelp::_update_doc() {
}
class_desc->pop();
+ class_desc->pop();
class_desc->add_newline();
}
// Descendents
if (ClassDB::class_exists(cd.name)) {
-
bool found = false;
bool prev = false;
+ class_desc->push_font(doc_font);
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
-
if (E->get().inherits == cd.name) {
-
if (!found) {
class_desc->push_color(title_color);
- class_desc->push_font(doc_font);
class_desc->add_text(TTR("Inherited by:") + " ");
- class_desc->pop();
found = true;
}
if (prev) {
-
class_desc->add_text(" , ");
}
@@ -427,6 +421,7 @@ void EditorHelp::_update_doc() {
prev = true;
}
}
+ class_desc->pop();
if (found) {
class_desc->pop();
@@ -439,7 +434,6 @@ void EditorHelp::_update_doc() {
// Brief description
if (cd.brief_description != "") {
-
class_desc->push_color(text_color);
class_desc->push_font(doc_bold_font);
class_desc->push_indent(1);
@@ -454,7 +448,6 @@ void EditorHelp::_update_doc() {
// Class description
if (cd.description != "") {
-
section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2));
description_line = class_desc->get_line_count() - 2;
class_desc->push_color(title_color);
@@ -490,8 +483,8 @@ void EditorHelp::_update_doc() {
class_desc->add_newline();
for (int i = 0; i < cd.tutorials.size(); i++) {
- const String link = DTR(cd.tutorials[i]);
- String linktxt = link;
+ const String link = DTR(cd.tutorials[i].link);
+ String linktxt = (cd.tutorials[i].title.empty()) ? link : DTR(cd.tutorials[i].title);
const int seppos = linktxt.find("//");
if (seppos != -1) {
linktxt = link.right(seppos + 2);
@@ -514,7 +507,6 @@ void EditorHelp::_update_doc() {
bool property_descr = false;
if (cd.properties.size()) {
-
section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -526,7 +518,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_code_font);
class_desc->push_indent(1);
class_desc->push_table(2);
- class_desc->set_table_column_expand(1, 1);
+ class_desc->set_table_column_expand(1, true);
for (int i = 0; i < cd.properties.size(); i++) {
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
@@ -614,9 +606,9 @@ void EditorHelp::_update_doc() {
}
if (methods.size()) {
-
- if (sort_methods)
+ if (sort_methods) {
methods.sort();
+ }
section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
@@ -629,7 +621,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_code_font);
class_desc->push_indent(1);
class_desc->push_table(2);
- class_desc->set_table_column_expand(1, 1);
+ class_desc->set_table_column_expand(1, true);
bool any_previous = false;
for (int pass = 0; pass < 2; pass++) {
@@ -688,7 +680,6 @@ void EditorHelp::_update_doc() {
// Theme properties
if (cd.theme_properties.size()) {
-
section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -698,10 +689,9 @@ void EditorHelp::_update_doc() {
class_desc->push_indent(1);
class_desc->push_table(2);
- class_desc->set_table_column_expand(1, 1);
+ class_desc->set_table_column_expand(1, true);
for (int i = 0; i < cd.theme_properties.size(); i++) {
-
theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
class_desc->push_cell();
@@ -751,7 +741,6 @@ void EditorHelp::_update_doc() {
// Signals
if (cd.signals.size()) {
-
if (sort_methods) {
cd.signals.sort();
}
@@ -769,10 +758,11 @@ void EditorHelp::_update_doc() {
class_desc->push_indent(1);
for (int i = 0; i < cd.signals.size(); i++) {
-
signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
class_desc->push_font(doc_code_font); // monofont
class_desc->push_color(headline_color);
+ static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
+ class_desc->add_text(String(prefix));
_add_text(cd.signals[i].name);
class_desc->pop();
class_desc->push_color(symbol_color);
@@ -780,14 +770,14 @@ void EditorHelp::_update_doc() {
class_desc->pop();
for (int j = 0; j < cd.signals[i].arguments.size(); j++) {
class_desc->push_color(text_color);
- if (j > 0)
+ if (j > 0) {
class_desc->add_text(", ");
+ }
_add_text(cd.signals[i].arguments[j].name);
class_desc->add_text(": ");
_add_type(cd.signals[i].arguments[j].type);
if (cd.signals[i].arguments[j].default_value != "") {
-
class_desc->push_color(symbol_color);
class_desc->add_text(" = ");
class_desc->pop();
@@ -802,7 +792,6 @@ void EditorHelp::_update_doc() {
class_desc->pop();
class_desc->pop(); // end monofont
if (cd.signals[i].description != "") {
-
class_desc->push_font(doc_font);
class_desc->push_color(comment_color);
class_desc->push_indent(1);
@@ -821,12 +810,10 @@ void EditorHelp::_update_doc() {
// Constants and enums
if (cd.constants.size()) {
-
Map<String, Vector<DocData::ConstantDoc>> enums;
Vector<DocData::ConstantDoc> constants;
for (int i = 0; i < cd.constants.size(); i++) {
-
if (cd.constants[i].enumeration != String()) {
if (!enums.has(cd.constants[i].enumeration)) {
enums[cd.constants[i].enumeration] = Vector<DocData::ConstantDoc>();
@@ -834,14 +821,12 @@ void EditorHelp::_update_doc() {
enums[cd.constants[i].enumeration].push_back(cd.constants[i]);
} else {
-
constants.push_back(cd.constants[i]);
}
}
// Enums
if (enums.size()) {
-
section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -853,13 +838,12 @@ void EditorHelp::_update_doc() {
class_desc->add_newline();
for (Map<String, Vector<DocData::ConstantDoc>>::Element *E = enums.front(); E; E = E->next()) {
-
enum_line[E->key()] = class_desc->get_line_count() - 2;
+ class_desc->push_font(doc_code_font);
class_desc->push_color(title_color);
class_desc->add_text("enum ");
class_desc->pop();
- class_desc->push_font(doc_code_font);
String e = E->key();
if ((e.get_slice_count(".") > 1) && (e.get_slice(".", 0) == edited_class)) {
e = e.get_slice(".", 1);
@@ -872,6 +856,8 @@ void EditorHelp::_update_doc() {
class_desc->push_color(symbol_color);
class_desc->add_text(":");
class_desc->pop();
+
+ class_desc->add_newline();
class_desc->add_newline();
class_desc->push_indent(1);
@@ -881,14 +867,17 @@ void EditorHelp::_update_doc() {
int enumStartingLine = enum_line[E->key()];
for (int i = 0; i < enum_list.size(); i++) {
- if (cd.name == "@GlobalScope")
+ if (cd.name == "@GlobalScope") {
enumValuesContainer[enum_list[i].name] = enumStartingLine;
+ }
// Add the enum constant line to the constant_line map so we can locate it as a constant
constant_line[enum_list[i].name] = class_desc->get_line_count() - 2;
class_desc->push_font(doc_code_font);
class_desc->push_color(headline_color);
+ static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
+ class_desc->add_text(String(prefix));
_add_text(enum_list[i].name);
class_desc->pop();
class_desc->push_color(symbol_color);
@@ -900,21 +889,23 @@ void EditorHelp::_update_doc() {
class_desc->pop();
if (enum_list[i].description != "") {
class_desc->push_font(doc_font);
- //class_desc->add_text(" ");
- class_desc->push_indent(1);
class_desc->push_color(comment_color);
+ static const CharType dash[6] = { ' ', ' ', 0x2013 /* en dash */, ' ', ' ', 0 };
+ class_desc->add_text(String(dash));
_add_text(DTR(enum_list[i].description));
class_desc->pop();
class_desc->pop();
- class_desc->pop(); // indent
- class_desc->add_newline();
+ if (DTR(enum_list[i].description).find("\n") > 0) {
+ class_desc->add_newline();
+ }
}
class_desc->add_newline();
}
- if (cd.name == "@GlobalScope")
+ if (cd.name == "@GlobalScope") {
enum_values_line[E->key()] = enumValuesContainer;
+ }
class_desc->pop();
@@ -927,7 +918,6 @@ void EditorHelp::_update_doc() {
// Constants
if (constants.size()) {
-
section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -939,7 +929,6 @@ void EditorHelp::_update_doc() {
class_desc->add_newline();
for (int i = 0; i < constants.size(); i++) {
-
constant_line[constants[i].name] = class_desc->get_line_count() - 2;
class_desc->push_font(doc_code_font);
@@ -952,6 +941,9 @@ void EditorHelp::_update_doc() {
class_desc->add_text(String(prefix));
class_desc->pop();
}
+ } else {
+ static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
+ class_desc->add_text(String(prefix));
}
class_desc->push_color(headline_color);
@@ -967,13 +959,15 @@ void EditorHelp::_update_doc() {
class_desc->pop();
if (constants[i].description != "") {
class_desc->push_font(doc_font);
- class_desc->push_indent(1);
class_desc->push_color(comment_color);
+ static const CharType dash[6] = { ' ', ' ', 0x2013 /* en dash */, ' ', ' ', 0 };
+ class_desc->add_text(String(dash));
_add_text(DTR(constants[i].description));
class_desc->pop();
class_desc->pop();
- class_desc->pop(); // indent
- class_desc->add_newline();
+ if (DTR(constants[i].description).find("\n") > 0) {
+ class_desc->add_newline();
+ }
}
class_desc->add_newline();
@@ -986,7 +980,6 @@ void EditorHelp::_update_doc() {
// Property descriptions
if (property_descr) {
-
section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -998,17 +991,20 @@ void EditorHelp::_update_doc() {
class_desc->add_newline();
for (int i = 0; i < cd.properties.size(); i++) {
-
- if (cd.properties[i].overridden)
+ if (cd.properties[i].overridden) {
continue;
+ }
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2;
class_desc->push_table(2);
- class_desc->set_table_column_expand(1, 1);
+ class_desc->set_table_column_expand(1, true);
class_desc->push_cell();
class_desc->push_font(doc_code_font);
+ static const CharType prefix[3] = { 0x25CF /* filled circle */, ' ', 0 };
+ class_desc->add_text(String(prefix));
+
_add_type(cd.properties[i].type, cd.properties[i].enumeration);
class_desc->add_text(" ");
class_desc->pop(); // font
@@ -1037,15 +1033,26 @@ void EditorHelp::_update_doc() {
class_desc->pop(); // font
class_desc->pop(); // cell
- if (cd.properties[i].setter != "") {
+ Map<String, DocData::MethodDoc> method_map;
+ for (int j = 0; j < methods.size(); j++) {
+ method_map[methods[j].name] = methods[j];
+ }
+ if (cd.properties[i].setter != "") {
class_desc->push_cell();
class_desc->pop(); // cell
class_desc->push_cell();
class_desc->push_font(doc_code_font);
class_desc->push_color(text_color);
- class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
+ if (method_map[cd.properties[i].setter].arguments.size() > 1) {
+ // Setters with additional arguments are exposed in the method list, so we link them here for quick access.
+ class_desc->push_meta("@method " + cd.properties[i].setter);
+ class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
+ class_desc->pop();
+ } else {
+ class_desc->add_text(cd.properties[i].setter + TTR("(value)"));
+ }
class_desc->pop(); // color
class_desc->push_color(comment_color);
class_desc->add_text(" setter");
@@ -1056,14 +1063,20 @@ void EditorHelp::_update_doc() {
}
if (cd.properties[i].getter != "") {
-
class_desc->push_cell();
class_desc->pop(); // cell
class_desc->push_cell();
class_desc->push_font(doc_code_font);
class_desc->push_color(text_color);
- class_desc->add_text(cd.properties[i].getter + "()");
+ if (method_map[cd.properties[i].getter].arguments.size() > 0) {
+ // Getters with additional arguments are exposed in the method list, so we link them here for quick access.
+ class_desc->push_meta("@method " + cd.properties[i].getter);
+ class_desc->add_text(cd.properties[i].getter + "()");
+ class_desc->pop();
+ } else {
+ class_desc->add_text(cd.properties[i].getter + "()");
+ }
class_desc->pop(); //color
class_desc->push_color(comment_color);
class_desc->add_text(" getter");
@@ -1101,7 +1114,6 @@ void EditorHelp::_update_doc() {
// Method descriptions
if (method_descr) {
-
section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_line_count() - 2));
class_desc->push_color(title_color);
class_desc->push_font(doc_title_font);
@@ -1123,7 +1135,6 @@ void EditorHelp::_update_doc() {
}
for (int i = 0; i < methods_filtered.size(); i++) {
-
class_desc->push_font(doc_code_font);
_add_method(methods_filtered[i], false);
class_desc->pop();
@@ -1165,12 +1176,12 @@ void EditorHelp::_request_help(const String &p_string) {
}
void EditorHelp::_help_callback(const String &p_topic) {
-
String what = p_topic.get_slice(":", 0);
String clss = p_topic.get_slice(":", 1);
String name;
- if (p_topic.get_slice_count(":") == 3)
+ if (p_topic.get_slice_count(":") == 3) {
name = p_topic.get_slice(":", 2);
+ }
_request_help(clss); //first go to class
@@ -1179,36 +1190,43 @@ void EditorHelp::_help_callback(const String &p_topic) {
if (what == "class_desc") {
line = description_line;
} else if (what == "class_signal") {
- if (signal_line.has(name))
+ if (signal_line.has(name)) {
line = signal_line[name];
+ }
} else if (what == "class_method" || what == "class_method_desc") {
- if (method_line.has(name))
+ if (method_line.has(name)) {
line = method_line[name];
+ }
} else if (what == "class_property") {
- if (property_line.has(name))
+ if (property_line.has(name)) {
line = property_line[name];
+ }
} else if (what == "class_enum") {
- if (enum_line.has(name))
+ if (enum_line.has(name)) {
line = enum_line[name];
+ }
} else if (what == "class_theme_item") {
- if (theme_property_line.has(name))
+ if (theme_property_line.has(name)) {
line = theme_property_line[name];
+ }
} else if (what == "class_constant") {
- if (constant_line.has(name))
+ if (constant_line.has(name)) {
line = constant_line[name];
+ }
} else if (what == "class_global") {
- if (constant_line.has(name))
+ if (constant_line.has(name)) {
line = constant_line[name];
- else {
+ } else {
Map<String, Map<String, int>>::Element *iter = enum_values_line.front();
while (true) {
if (iter->value().has(name)) {
line = iter->value()[name];
break;
- } else if (iter == enum_values_line.back())
+ } else if (iter == enum_values_line.back()) {
break;
- else
+ } else {
iter = iter->next();
+ }
}
}
}
@@ -1217,7 +1235,6 @@ void EditorHelp::_help_callback(const String &p_topic) {
}
static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
-
DocData *doc = EditorHelp::get_doc_data();
String base_path;
@@ -1244,29 +1261,31 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
int pos = 0;
while (pos < bbcode.length()) {
-
int brk_pos = bbcode.find("[", pos);
- if (brk_pos < 0)
+ if (brk_pos < 0) {
brk_pos = bbcode.length();
+ }
if (brk_pos > pos) {
String text = bbcode.substr(pos, brk_pos - pos);
- if (!code_tag)
+ if (!code_tag) {
text = text.replace("\n", "\n\n");
+ }
p_rt->add_text(text);
}
- if (brk_pos == bbcode.length())
+ if (brk_pos == bbcode.length()) {
break; //nothing else to add
+ }
int brk_end = bbcode.find("]", brk_pos + 1);
if (brk_end == -1) {
-
String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos);
- if (!code_tag)
+ if (!code_tag) {
text = text.replace("\n", "\n\n");
+ }
p_rt->add_text(text);
break;
@@ -1278,7 +1297,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
if (!tag_ok) {
-
p_rt->add_text("[");
pos = brk_pos + 1;
continue;
@@ -1295,12 +1313,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
code_tag = false;
} else if (code_tag) {
-
p_rt->add_text("[");
pos = brk_pos + 1;
} else if (tag.begins_with("method ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ")) {
-
int tag_end = tag.find(" ");
String link_tag = tag.substr(0, tag_end);
@@ -1314,7 +1330,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
pos = brk_end + 1;
} else if (doc->class_list.has(tag)) {
-
p_rt->push_color(link_color);
p_rt->push_meta("#" + tag);
p_rt->add_text(tag);
@@ -1323,19 +1338,16 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
pos = brk_end + 1;
} else if (tag == "b") {
-
//use bold font
p_rt->push_font(doc_bold_font);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "i") {
-
//use italics font
p_rt->push_color(font_color_hl);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "code" || tag == "codeblock") {
-
//use monospace font
p_rt->push_font(doc_code_font);
p_rt->push_color(code_color);
@@ -1343,7 +1355,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "kbd") {
-
//use keyboard font with custom color
p_rt->push_font(doc_kbd_font);
p_rt->push_color(kbd_color);
@@ -1351,112 +1362,107 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "center") {
-
//align to center
p_rt->push_align(RichTextLabel::ALIGN_CENTER);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "br") {
-
//force a line break
p_rt->add_newline();
pos = brk_end + 1;
} else if (tag == "u") {
-
//use underline
p_rt->push_underline();
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "s") {
-
//use strikethrough
p_rt->push_strikethrough();
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "url") {
-
int end = bbcode.find("[", brk_end);
- if (end == -1)
+ if (end == -1) {
end = bbcode.length();
+ }
String url = bbcode.substr(brk_end + 1, end - brk_end - 1);
p_rt->push_meta(url);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag.begins_with("url=")) {
-
String url = tag.substr(4, tag.length());
p_rt->push_meta(url);
pos = brk_end + 1;
tag_stack.push_front("url");
} else if (tag == "img") {
-
int end = bbcode.find("[", brk_end);
- if (end == -1)
+ if (end == -1) {
end = bbcode.length();
+ }
String image = bbcode.substr(brk_end + 1, end - brk_end - 1);
Ref<Texture2D> texture = ResourceLoader::load(base_path.plus_file(image), "Texture2D");
- if (texture.is_valid())
+ if (texture.is_valid()) {
p_rt->add_image(texture);
+ }
pos = end;
tag_stack.push_front(tag);
} else if (tag.begins_with("color=")) {
-
String col = tag.substr(6, tag.length());
Color color;
- if (col.begins_with("#"))
+ if (col.begins_with("#")) {
color = Color::html(col);
- else if (col == "aqua")
+ } else if (col == "aqua") {
color = Color(0, 1, 1);
- else if (col == "black")
+ } else if (col == "black") {
color = Color(0, 0, 0);
- else if (col == "blue")
+ } else if (col == "blue") {
color = Color(0, 0, 1);
- else if (col == "fuchsia")
+ } else if (col == "fuchsia") {
color = Color(1, 0, 1);
- else if (col == "gray" || col == "grey")
+ } else if (col == "gray" || col == "grey") {
color = Color(0.5, 0.5, 0.5);
- else if (col == "green")
+ } else if (col == "green") {
color = Color(0, 0.5, 0);
- else if (col == "lime")
+ } else if (col == "lime") {
color = Color(0, 1, 0);
- else if (col == "maroon")
+ } else if (col == "maroon") {
color = Color(0.5, 0, 0);
- else if (col == "navy")
+ } else if (col == "navy") {
color = Color(0, 0, 0.5);
- else if (col == "olive")
+ } else if (col == "olive") {
color = Color(0.5, 0.5, 0);
- else if (col == "purple")
+ } else if (col == "purple") {
color = Color(0.5, 0, 0.5);
- else if (col == "red")
+ } else if (col == "red") {
color = Color(1, 0, 0);
- else if (col == "silver")
+ } else if (col == "silver") {
color = Color(0.75, 0.75, 0.75);
- else if (col == "teal")
+ } else if (col == "teal") {
color = Color(0, 0.5, 0.5);
- else if (col == "white")
+ } else if (col == "white") {
color = Color(1, 1, 1);
- else if (col == "yellow")
+ } else if (col == "yellow") {
color = Color(1, 1, 0);
- else
+ } else {
color = Color(0, 0, 0); //base_color;
+ }
p_rt->push_color(color);
pos = brk_end + 1;
tag_stack.push_front("color");
} else if (tag.begins_with("font=")) {
-
String fnt = tag.substr(5, tag.length());
Ref<Font> font = ResourceLoader::load(base_path.plus_file(fnt), "Font");
- if (font.is_valid())
+ if (font.is_valid()) {
p_rt->push_font(font);
- else {
+ } else {
p_rt->push_font(doc_font);
}
@@ -1464,7 +1470,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
tag_stack.push_front("font");
} else {
-
p_rt->add_text("["); //ignore
pos = brk_pos + 1;
}
@@ -1476,7 +1481,6 @@ void EditorHelp::_add_text(const String &p_bbcode) {
}
void EditorHelp::generate_doc() {
-
doc = memnew(DocData);
doc->generate(true);
DocData compdoc;
@@ -1485,11 +1489,9 @@ void EditorHelp::generate_doc() {
}
void EditorHelp::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY:
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
_update_doc();
} break;
case NOTIFICATION_THEME_CHANGED: {
@@ -1503,12 +1505,10 @@ void EditorHelp::_notification(int p_what) {
}
void EditorHelp::go_to_help(const String &p_help) {
-
_help_callback(p_help);
}
void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
-
_goto_desc(p_class, p_scroll);
}
@@ -1527,12 +1527,10 @@ void EditorHelp::scroll_to_section(int p_section_index) {
}
void EditorHelp::popup_search() {
-
find_bar->popup_search();
}
String EditorHelp::get_class() {
-
return edited_class;
}
@@ -1541,16 +1539,14 @@ void EditorHelp::search_again(bool p_search_previous) {
}
int EditorHelp::get_scroll() const {
-
return class_desc->get_v_scroll()->get_value();
}
-void EditorHelp::set_scroll(int p_scroll) {
+void EditorHelp::set_scroll(int p_scroll) {
class_desc->get_v_scroll()->set_value(p_scroll);
}
void EditorHelp::_bind_methods() {
-
ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select);
ClassDB::bind_method("_request_help", &EditorHelp::_request_help);
ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input);
@@ -1561,7 +1557,6 @@ void EditorHelp::_bind_methods() {
}
EditorHelp::EditorHelp() {
-
set_custom_minimum_size(Size2(150 * EDSCALE, 0));
EDITOR_DEF("text_editor/help/sort_functions_alphabetically", true);
@@ -1593,14 +1588,12 @@ EditorHelp::~EditorHelp() {
}
void EditorHelpBit::_go_to_help(String p_what) {
-
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
ScriptEditor::get_singleton()->goto_help(p_what);
emit_signal("request_hide");
}
void EditorHelpBit::_meta_clicked(String p_select) {
-
if (p_select.begins_with("$")) { //enum
String select = p_select.substr(1, p_select.length());
@@ -1613,26 +1606,23 @@ void EditorHelpBit::_meta_clicked(String p_select) {
_go_to_help("class_enum:" + class_name + ":" + select);
return;
} else if (p_select.begins_with("#")) {
-
_go_to_help("class_name:" + p_select.substr(1, p_select.length()));
return;
} else if (p_select.begins_with("@")) {
-
String m = p_select.substr(1, p_select.length());
- if (m.find(".") != -1)
+ if (m.find(".") != -1) {
_go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0)); //must go somewhere else
+ }
}
}
void EditorHelpBit::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_text", "text"), &EditorHelpBit::set_text);
ADD_SIGNAL(MethodInfo("request_hide"));
}
void EditorHelpBit::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY: {
rich_text->clear();
@@ -1640,7 +1630,6 @@ void EditorHelpBit::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
} break;
default:
@@ -1649,14 +1638,12 @@ void EditorHelpBit::_notification(int p_what) {
}
void EditorHelpBit::set_text(const String &p_text) {
-
text = p_text;
rich_text->clear();
_add_text_to_rt(text, rich_text);
}
EditorHelpBit::EditorHelpBit() {
-
rich_text = memnew(RichTextLabel);
add_child(rich_text);
rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked));
@@ -1666,7 +1653,6 @@ EditorHelpBit::EditorHelpBit() {
}
FindBar::FindBar() {
-
search_text = memnew(LineEdit);
add_child(search_text);
search_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
@@ -1701,7 +1687,6 @@ FindBar::FindBar() {
}
void FindBar::popup_search() {
-
show();
bool grabbed_focus = false;
if (!search_text->has_focus()) {
@@ -1719,11 +1704,9 @@ void FindBar::popup_search() {
}
void FindBar::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
-
find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
@@ -1733,36 +1716,30 @@ void FindBar::_notification(int p_what) {
matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor"));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
set_process_unhandled_input(is_visible_in_tree());
} break;
}
}
void FindBar::_bind_methods() {
-
ClassDB::bind_method("_unhandled_input", &FindBar::_unhandled_input);
ADD_SIGNAL(MethodInfo("search"));
}
void FindBar::set_rich_text_label(RichTextLabel *p_rich_text_label) {
-
rich_text_label = p_rich_text_label;
}
bool FindBar::search_next() {
-
return _search();
}
bool FindBar::search_prev() {
-
return _search(true);
}
bool FindBar::_search(bool p_search_previous) {
-
String stext = search_text->get_text();
bool keep = prev_search == stext;
@@ -1784,12 +1761,12 @@ bool FindBar::_search(bool p_search_previous) {
}
void FindBar::_update_results_count() {
-
results_count = 0;
String searched = search_text->get_text();
- if (searched.empty())
+ if (searched.empty()) {
return;
+ }
String full_text = rich_text_label->get_text();
@@ -1797,8 +1774,9 @@ void FindBar::_update_results_count() {
while (true) {
int pos = full_text.find(searched, from_pos);
- if (pos == -1)
+ if (pos == -1) {
break;
+ }
results_count++;
from_pos = pos + searched.length();
@@ -1806,7 +1784,6 @@ void FindBar::_update_results_count() {
}
void FindBar::_update_matches_label() {
-
if (search_text->get_text().empty() || results_count == -1) {
matches_label->hide();
} else {
@@ -1818,30 +1795,24 @@ void FindBar::_update_matches_label() {
}
void FindBar::_hide_bar() {
-
- if (search_text->has_focus())
+ if (search_text->has_focus()) {
rich_text_label->grab_focus();
+ }
hide();
}
void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
-
if (k->is_pressed() && (rich_text_label->has_focus() || is_a_parent_of(get_focus_owner()))) {
-
bool accepted = true;
switch (k->get_keycode()) {
-
case KEY_ESCAPE: {
-
_hide_bar();
} break;
default: {
-
accepted = false;
} break;
}
@@ -1854,12 +1825,10 @@ void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void FindBar::_search_text_changed(const String &p_text) {
-
search_next();
}
void FindBar::_search_text_entered(const String &p_text) {
-
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
search_prev();
} else {
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 2e053e674f..4d42c1d38a 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -88,7 +88,6 @@ public:
};
class EditorHelp : public VBoxContainer {
-
GDCLASS(EditorHelp, VBoxContainer);
enum Page {
@@ -193,7 +192,6 @@ public:
};
class EditorHelpBit : public MarginContainer {
-
GDCLASS(EditorHelpBit, MarginContainer);
RichTextLabel *rich_text;
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index 01a50cad2c..5bfcbf06fc 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -36,33 +36,33 @@
#include "editor_scale.h"
void EditorHelpSearch::_update_icons() {
-
search_box->set_right_icon(results_tree->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon("Search", "EditorIcons"));
case_sensitive_button->set_icon(results_tree->get_theme_icon("MatchCase", "EditorIcons"));
hierarchy_button->set_icon(results_tree->get_theme_icon("ClassList", "EditorIcons"));
- if (is_visible())
+ if (is_visible()) {
_update_results();
+ }
}
void EditorHelpSearch::_update_results() {
-
String term = search_box->get_text();
int search_flags = filter_combo->get_selected_id();
- if (case_sensitive_button->is_pressed())
+ if (case_sensitive_button->is_pressed()) {
search_flags |= SEARCH_CASE_SENSITIVE;
- if (hierarchy_button->is_pressed())
+ }
+ if (hierarchy_button->is_pressed()) {
search_flags |= SEARCH_SHOW_HIERARCHY;
+ }
search = Ref<Runner>(memnew(Runner(results_tree, results_tree, term, search_flags)));
set_process(true);
}
void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) {
-
// Redirect up and down navigational key events to the results list.
Ref<InputEventKey> key = p_event;
if (key.is_valid()) {
@@ -79,20 +79,18 @@ void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorHelpSearch::_search_box_text_changed(const String &p_text) {
-
_update_results();
}
void EditorHelpSearch::_filter_combo_item_selected(int p_option) {
-
_update_results();
}
void EditorHelpSearch::_confirmed() {
-
TreeItem *item = results_tree->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
// Activate the script editor and emit the signal with the documentation link to display.
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
@@ -103,7 +101,6 @@ void EditorHelpSearch::_confirmed() {
}
void EditorHelpSearch::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
@@ -113,27 +110,25 @@ void EditorHelpSearch::_notification(int p_what) {
}
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
_update_icons();
} break;
case NOTIFICATION_ENTER_TREE: {
-
connect("confirmed", callable_mp(this, &EditorHelpSearch::_confirmed));
_update_icons();
} break;
case NOTIFICATION_PROCESS: {
-
// Update background search.
if (search.is_valid()) {
if (search->work()) {
// Search done.
// Only point to the perfect match if it's a new search, and not just reopening a old one.
- if (!old_search)
+ if (!old_search) {
results_tree->ensure_cursor_is_visible();
- else
+ } else {
old_search = false;
+ }
get_ok()->set_disabled(!results_tree->get_selected());
@@ -148,31 +143,30 @@ void EditorHelpSearch::_notification(int p_what) {
}
void EditorHelpSearch::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("go_to_help"));
}
void EditorHelpSearch::popup_dialog() {
-
popup_dialog(search_box->get_text());
}
void EditorHelpSearch::popup_dialog(const String &p_term) {
-
// Restore valid window bounds or pop up at default size.
Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "search_help", Rect2());
- if (saved_size != Rect2())
+ if (saved_size != Rect2()) {
popup(saved_size);
- else
+ } else {
popup_centered_ratio(0.5F);
+ }
if (p_term == "") {
search_box->clear();
} else {
- if (old_term == p_term)
+ if (old_term == p_term) {
old_search = true;
- else
+ } else {
old_term = p_term;
+ }
search_box->set_text(p_term);
search_box->select_all();
@@ -182,7 +176,6 @@ void EditorHelpSearch::popup_dialog(const String &p_term) {
}
EditorHelpSearch::EditorHelpSearch() {
-
old_search = false;
set_hide_on_ok(false);
@@ -254,7 +247,6 @@ EditorHelpSearch::EditorHelpSearch() {
}
bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const StringName &p_class) {
-
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
if (profile.is_null()) {
return false;
@@ -262,7 +254,6 @@ bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const Strin
StringName class_name = p_class;
while (class_name != StringName()) {
-
if (!ClassDB::class_exists(class_name)) {
return false;
}
@@ -277,7 +268,6 @@ bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const Strin
}
bool EditorHelpSearch::Runner::_slice() {
-
bool phase_done = false;
switch (phase) {
case PHASE_MATCH_CLASSES_INIT:
@@ -308,13 +298,13 @@ bool EditorHelpSearch::Runner::_slice() {
return true;
};
- if (phase_done)
+ if (phase_done) {
phase++;
+ }
return false;
}
bool EditorHelpSearch::Runner::_phase_match_classes_init() {
-
iterator_doc = EditorHelp::get_doc_data()->class_list.front();
matches.clear();
matched_item = nullptr;
@@ -323,51 +313,66 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() {
}
bool EditorHelpSearch::Runner::_phase_match_classes() {
-
DocData::ClassDoc &class_doc = iterator_doc->value();
if (!_is_class_disabled_by_feature_profile(class_doc.name)) {
-
matches[class_doc.name] = ClassMatch();
ClassMatch &match = matches[class_doc.name];
match.doc = &class_doc;
// Match class name.
- if (search_flags & SEARCH_CLASSES)
+ if (search_flags & SEARCH_CLASSES) {
match.name = term == "" || _match_string(term, class_doc.name);
+ }
// Match members if the term is long enough.
if (term.length() > 1) {
- if (search_flags & SEARCH_METHODS)
+ if (search_flags & SEARCH_METHODS) {
for (int i = 0; i < class_doc.methods.size(); i++) {
String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
String aux_term = (search_flags & SEARCH_CASE_SENSITIVE) ? term : term.to_lower();
- if (aux_term.begins_with("."))
+ if (aux_term.begins_with(".")) {
aux_term = aux_term.right(1);
+ }
- if (aux_term.ends_with("("))
+ if (aux_term.ends_with("(")) {
aux_term = aux_term.left(aux_term.length() - 1).strip_edges();
+ }
- if (aux_term.is_subsequence_of(method_name))
+ if (aux_term.is_subsequence_of(method_name)) {
match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i]));
+ }
}
- if (search_flags & SEARCH_SIGNALS)
- for (int i = 0; i < class_doc.signals.size(); i++)
- if (_match_string(term, class_doc.signals[i].name))
+ }
+ if (search_flags & SEARCH_SIGNALS) {
+ for (int i = 0; i < class_doc.signals.size(); i++) {
+ if (_match_string(term, class_doc.signals[i].name)) {
match.signals.push_back(const_cast<DocData::MethodDoc *>(&class_doc.signals[i]));
- if (search_flags & SEARCH_CONSTANTS)
- for (int i = 0; i < class_doc.constants.size(); i++)
- if (_match_string(term, class_doc.constants[i].name))
+ }
+ }
+ }
+ if (search_flags & SEARCH_CONSTANTS) {
+ for (int i = 0; i < class_doc.constants.size(); i++) {
+ if (_match_string(term, class_doc.constants[i].name)) {
match.constants.push_back(const_cast<DocData::ConstantDoc *>(&class_doc.constants[i]));
- if (search_flags & SEARCH_PROPERTIES)
- for (int i = 0; i < class_doc.properties.size(); i++)
- if (_match_string(term, class_doc.properties[i].name) || _match_string(term, class_doc.properties[i].getter) || _match_string(term, class_doc.properties[i].setter))
+ }
+ }
+ }
+ if (search_flags & SEARCH_PROPERTIES) {
+ for (int i = 0; i < class_doc.properties.size(); i++) {
+ if (_match_string(term, class_doc.properties[i].name) || _match_string(term, class_doc.properties[i].getter) || _match_string(term, class_doc.properties[i].setter)) {
match.properties.push_back(const_cast<DocData::PropertyDoc *>(&class_doc.properties[i]));
- if (search_flags & SEARCH_THEME_ITEMS)
- for (int i = 0; i < class_doc.theme_properties.size(); i++)
- if (_match_string(term, class_doc.theme_properties[i].name))
+ }
+ }
+ }
+ if (search_flags & SEARCH_THEME_ITEMS) {
+ for (int i = 0; i < class_doc.theme_properties.size(); i++) {
+ if (_match_string(term, class_doc.theme_properties[i].name)) {
match.theme_properties.push_back(const_cast<DocData::PropertyDoc *>(&class_doc.theme_properties[i]));
+ }
+ }
+ }
}
}
@@ -376,7 +381,6 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
}
bool EditorHelpSearch::Runner::_phase_class_items_init() {
-
iterator_match = matches.front();
results_tree->clear();
@@ -387,15 +391,16 @@ bool EditorHelpSearch::Runner::_phase_class_items_init() {
}
bool EditorHelpSearch::Runner::_phase_class_items() {
-
ClassMatch &match = iterator_match->value();
if (search_flags & SEARCH_SHOW_HIERARCHY) {
- if (match.required())
+ if (match.required()) {
_create_class_hierarchy(match);
+ }
} else {
- if (match.name)
+ if (match.name) {
_create_class_item(root_item, match.doc, false);
+ }
}
iterator_match = iterator_match->next();
@@ -403,64 +408,68 @@ bool EditorHelpSearch::Runner::_phase_class_items() {
}
bool EditorHelpSearch::Runner::_phase_member_items_init() {
-
iterator_match = matches.front();
return true;
}
bool EditorHelpSearch::Runner::_phase_member_items() {
-
ClassMatch &match = iterator_match->value();
TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
- for (int i = 0; i < match.methods.size(); i++)
+ for (int i = 0; i < match.methods.size(); i++) {
_create_method_item(parent, match.doc, match.methods[i]);
- for (int i = 0; i < match.signals.size(); i++)
+ }
+ for (int i = 0; i < match.signals.size(); i++) {
_create_signal_item(parent, match.doc, match.signals[i]);
- for (int i = 0; i < match.constants.size(); i++)
+ }
+ for (int i = 0; i < match.constants.size(); i++) {
_create_constant_item(parent, match.doc, match.constants[i]);
- for (int i = 0; i < match.properties.size(); i++)
+ }
+ for (int i = 0; i < match.properties.size(); i++) {
_create_property_item(parent, match.doc, match.properties[i]);
- for (int i = 0; i < match.theme_properties.size(); i++)
+ }
+ for (int i = 0; i < match.theme_properties.size(); i++) {
_create_theme_property_item(parent, match.doc, match.theme_properties[i]);
+ }
iterator_match = iterator_match->next();
return !iterator_match;
}
bool EditorHelpSearch::Runner::_phase_select_match() {
-
- if (matched_item)
+ if (matched_item) {
matched_item->select(0);
+ }
return true;
}
bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const {
-
- if (search_flags & SEARCH_CASE_SENSITIVE)
+ if (search_flags & SEARCH_CASE_SENSITIVE) {
return p_term.is_subsequence_of(p_string);
- else
+ } else {
return p_term.is_subsequence_ofi(p_string);
+ }
}
void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) {
-
if (!matched_item) {
if (search_flags & SEARCH_CASE_SENSITIVE) {
- if (p_text.casecmp_to(term) == 0)
+ if (p_text.casecmp_to(term) == 0) {
matched_item = p_item;
+ }
} else {
- if (p_text.nocasecmp_to(term) == 0)
+ if (p_text.nocasecmp_to(term) == 0) {
matched_item = p_item;
+ }
}
}
}
TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_match) {
-
- if (class_items.has(p_match.doc->name))
+ if (class_items.has(p_match.doc->name)) {
return class_items[p_match.doc->name];
+ }
// Ensure parent nodes are created first.
TreeItem *parent = root_item;
@@ -479,12 +488,12 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_
}
TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) {
-
Ref<Texture2D> icon = empty_icon;
- if (ui_service->has_theme_icon(p_doc->name, "EditorIcons"))
+ if (ui_service->has_theme_icon(p_doc->name, "EditorIcons")) {
icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons");
- else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object"))
+ } else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) {
icon = ui_service->get_theme_icon("Object", "EditorIcons");
+ }
String tooltip = p_doc->brief_description.strip_edges();
TreeItem *item = results_tree->create_item(p_parent);
@@ -505,43 +514,43 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const
}
TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) {
-
String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
for (int i = 0; i < p_doc->arguments.size(); i++) {
const DocData::ArgumentDoc &arg = p_doc->arguments[i];
tooltip += arg.type + " " + arg.name;
- if (arg.default_value != "")
+ if (arg.default_value != "") {
tooltip += " = " + arg.default_value;
- if (i < p_doc->arguments.size() - 1)
+ }
+ if (i < p_doc->arguments.size() - 1) {
tooltip += ", ";
+ }
}
tooltip += ")";
return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, TTRC("Method"), "method", tooltip);
}
TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) {
-
String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
for (int i = 0; i < p_doc->arguments.size(); i++) {
const DocData::ArgumentDoc &arg = p_doc->arguments[i];
tooltip += arg.type + " " + arg.name;
- if (arg.default_value != "")
+ if (arg.default_value != "") {
tooltip += " = " + arg.default_value;
- if (i < p_doc->arguments.size() - 1)
+ }
+ if (i < p_doc->arguments.size() - 1) {
tooltip += ", ";
+ }
}
tooltip += ")";
return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, TTRC("Signal"), "signal", tooltip);
}
TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) {
-
String tooltip = p_class_doc->name + "." + p_doc->name;
return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, TTRC("Constant"), "constant", tooltip);
}
TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) {
-
String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
tooltip += "\n " + p_class_doc->name + "." + p_doc->setter + "(value) setter";
tooltip += "\n " + p_class_doc->name + "." + p_doc->getter + "() getter";
@@ -549,13 +558,11 @@ TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, co
}
TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) {
-
String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, TTRC("Theme Property"), "theme_item", tooltip);
}
TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip) {
-
Ref<Texture2D> icon;
String text;
if (search_flags & SEARCH_SHOW_HIERARCHY) {
@@ -564,10 +571,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons
} else {
icon = ui_service->get_theme_icon(p_icon, "EditorIcons");
/*// In flat mode, show the class icon.
- if (ui_service->has_icon(p_class_name, "EditorIcons"))
- icon = ui_service->get_icon(p_class_name, "EditorIcons");
- else if (ClassDB::is_parent_class(p_class_name, "Object"))
- icon = ui_service->get_icon("Object", "EditorIcons");*/
+if (ui_service->has_icon(p_class_name, "EditorIcons"))
+icon = ui_service->get_icon(p_class_name, "EditorIcons");
+else if (ClassDB::is_parent_class(p_class_name, "Object"))
+icon = ui_service->get_icon("Object", "EditorIcons");*/
text = p_class_name + "." + p_name;
}
@@ -585,17 +592,17 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons
}
bool EditorHelpSearch::Runner::work(uint64_t slot) {
-
// Return true when the search has been completed, otherwise false.
const uint64_t until = OS::get_singleton()->get_ticks_usec() + slot;
- while (!_slice())
- if (OS::get_singleton()->get_ticks_usec() > until)
+ while (!_slice()) {
+ if (OS::get_singleton()->get_ticks_usec() > until) {
return false;
+ }
+ }
return true;
}
EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, const String &p_term, int p_search_flags) :
- phase(0),
ui_service(p_icon_service),
results_tree(p_results_tree),
term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()),
diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h
index feff96d2e5..f7dbc5c3ad 100644
--- a/editor/editor_help_search.h
+++ b/editor/editor_help_search.h
@@ -84,7 +84,6 @@ public:
};
class EditorHelpSearch::Runner : public Reference {
-
enum Phase {
PHASE_MATCH_CLASSES_INIT,
PHASE_MATCH_CLASSES,
@@ -95,7 +94,7 @@ class EditorHelpSearch::Runner : public Reference {
PHASE_SELECT_MATCH,
PHASE_MAX
};
- int phase;
+ int phase = 0;
struct ClassMatch {
DocData::ClassDoc *doc;
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 6adc640651..a8ded44323 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -39,22 +39,24 @@
#include "scene/resources/packed_scene.h"
Size2 EditorProperty::get_minimum_size() const {
-
Size2 ms;
Ref<Font> font = get_theme_font("font", "Tree");
ms.height = font->get_height();
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (!c->is_visible())
+ }
+ if (!c->is_visible()) {
continue;
- if (c == bottom_editor)
+ }
+ if (c == bottom_editor) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width, minsize.width);
@@ -88,7 +90,6 @@ Size2 EditorProperty::get_minimum_size() const {
}
void EditorProperty::emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field, bool p_changing) {
-
Variant args[4] = { p_property, p_value, p_field, p_changing };
const Variant *argptrs[4] = { &args[0], &args[1], &args[2], &args[3] };
@@ -96,9 +97,7 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p
}
void EditorProperty::_notification(int p_what) {
-
if (p_what == NOTIFICATION_SORT_CHILDREN) {
-
Size2 size = get_size();
Rect2 rect;
Rect2 bottom_rect;
@@ -114,14 +113,16 @@ void EditorProperty::_notification(int p_what) {
//compute room needed
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (c == bottom_editor)
+ }
+ if (c == bottom_editor) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
child_room = MAX(child_room, minsize.width);
@@ -138,7 +139,6 @@ void EditorProperty::_notification(int p_what) {
}
if (bottom_editor) {
-
int m = 0; //get_constant("item_margin", "Tree");
bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height);
@@ -175,14 +175,16 @@ void EditorProperty::_notification(int p_what) {
//set children
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (c == bottom_editor)
+ }
+ if (c == bottom_editor) {
continue;
+ }
fit_child_in_rect(c, rect);
right_child_rect = rect;
@@ -234,10 +236,11 @@ void EditorProperty::_notification(int p_what) {
if (checkable) {
Ref<Texture2D> checkbox;
- if (checked)
+ if (checked) {
checkbox = get_theme_icon("GuiChecked", "EditorIcons");
- else
+ } else {
checkbox = get_theme_icon("GuiUnchecked", "EditorIcons");
+ }
Color color2(1, 1, 1);
if (check_hover) {
@@ -335,8 +338,9 @@ StringName EditorProperty::get_edited_property() {
}
void EditorProperty::update_property() {
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("update_property");
+ }
}
void EditorProperty::set_read_only(bool p_read_only) {
@@ -348,14 +352,12 @@ bool EditorProperty::is_read_only() const {
}
bool EditorPropertyRevert::may_node_be_in_instance(Node *p_node) {
-
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
bool might_be = false;
Node *node = p_node;
while (node) {
-
if (node->get_scene_instance_state().is_valid()) {
might_be = true;
break;
@@ -375,7 +377,6 @@ bool EditorPropertyRevert::may_node_be_in_instance(Node *p_node) {
}
bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, const StringName &p_prop, Variant &value) {
-
Node *node = p_node;
Node *orig = node;
@@ -384,7 +385,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co
bool found = false;
while (node) {
-
Ref<SceneState> ss;
if (node == edited_scene) {
@@ -395,7 +395,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co
}
if (ss.is_valid()) {
-
NodePath np = node->get_path_to(orig);
int node_idx = ss->find_node_by_path(np);
if (node_idx >= 0) {
@@ -403,7 +402,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co
Variant lvar;
lvar = ss->get_property_value(node_idx, p_prop, lfound);
if (lfound) {
-
found = true;
value = lvar;
}
@@ -429,21 +427,20 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co
}
bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Variant &p_current, const Variant &p_orig) {
-
// this is a pretty difficult function, because a property may not be saved but may have
// the flag to not save if one or if zero
//make sure there is an actual state
{
Node *node = p_node;
- if (!node)
+ if (!node) {
return false;
+ }
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
bool found_state = false;
while (node) {
-
Ref<SceneState> ss;
if (node == edited_scene) {
@@ -463,8 +460,9 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian
node = node->get_owner();
}
- if (!found_state)
+ if (!found_state) {
return false; //pointless to check if we are not comparing against anything.
+ }
}
if (p_current.get_type() == Variant::FLOAT && p_orig.get_type() == Variant::FLOAT) {
@@ -478,7 +476,6 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian
}
bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringName &p_property) {
-
bool has_revert = false;
Node *node = Object::cast_to<Node>(p_object);
@@ -524,9 +521,9 @@ bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringNam
}
void EditorProperty::update_reload_status() {
-
- if (property == StringName())
+ if (property == StringName()) {
return; //no property, so nothing to do
+ }
bool has_reload = EditorPropertyRevert::can_property_revert(object, property);
@@ -550,31 +547,27 @@ bool EditorProperty::use_keying_next() const {
return false;
}
-void EditorProperty::set_checkable(bool p_checkable) {
+void EditorProperty::set_checkable(bool p_checkable) {
checkable = p_checkable;
update();
queue_sort();
}
bool EditorProperty::is_checkable() const {
-
return checkable;
}
void EditorProperty::set_checked(bool p_checked) {
-
checked = p_checked;
update();
}
bool EditorProperty::is_checked() const {
-
return checked;
}
void EditorProperty::set_draw_red(bool p_draw_red) {
-
draw_red = p_draw_red;
update();
}
@@ -600,14 +593,13 @@ bool EditorProperty::is_keying() const {
}
bool EditorProperty::is_draw_red() const {
-
return draw_red;
}
void EditorProperty::_focusable_focused(int p_index) {
-
- if (!selectable)
+ if (!selectable) {
return;
+ }
bool already_selected = selected;
selected = true;
selected_focusable = p_index;
@@ -618,13 +610,11 @@ void EditorProperty::_focusable_focused(int p_index) {
}
void EditorProperty::add_focusable(Control *p_control) {
-
p_control->connect("focus_entered", callable_mp(this, &EditorProperty::_focusable_focused), varray(focusables.size()));
focusables.push_back(p_control);
}
void EditorProperty::select(int p_focusable) {
-
bool already_selected = selected;
if (p_focusable >= 0) {
@@ -651,14 +641,13 @@ bool EditorProperty::is_selected() const {
}
void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
-
- if (property == StringName())
+ if (property == StringName()) {
return;
+ }
Ref<InputEventMouse> me = p_event;
if (me.is_valid()) {
-
bool button_left = me->get_button_mask() & BUTTON_MASK_LEFT;
bool new_keying_hover = keying_rect.has_point(me->get_position()) && !button_left;
@@ -689,7 +678,6 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (!selected && selectable) {
selected = true;
emit_signal("selected", property, -1);
@@ -721,12 +709,10 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
}
if (revert_rect.has_point(mb->get_position())) {
-
Variant vorig;
Node *node = Object::cast_to<Node>(object);
if (node && EditorPropertyRevert::may_node_be_in_instance(node) && EditorPropertyRevert::get_instanced_node_original_property(node, property, vorig)) {
-
emit_changed(property, vorig.duplicate(true));
update_property();
return;
@@ -767,17 +753,17 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorProperty::set_label_reference(Control *p_control) {
-
label_reference = p_control;
}
-void EditorProperty::set_bottom_editor(Control *p_control) {
+void EditorProperty::set_bottom_editor(Control *p_control) {
bottom_editor = p_control;
}
-Variant EditorProperty::get_drag_data(const Point2 &p_point) {
- if (property == StringName())
+Variant EditorProperty::get_drag_data(const Point2 &p_point) {
+ if (property == StringName()) {
return Variant();
+ }
Dictionary dp;
dp["type"] = "obj_property";
@@ -792,12 +778,10 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) {
}
void EditorProperty::set_use_folding(bool p_use_folding) {
-
use_folding = p_use_folding;
}
bool EditorProperty::is_using_folding() const {
-
return use_folding;
}
@@ -820,7 +804,6 @@ void EditorProperty::set_name_split_ratio(float p_ratio) {
}
float EditorProperty::get_name_split_ratio() const {
-
return split_ratio;
}
@@ -830,7 +813,6 @@ void EditorProperty::set_object_and_property(Object *p_object, const StringName
}
Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
-
tooltip_text = p_text;
EditorHelpBit *help_bit = memnew(EditorHelpBit);
//help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
@@ -859,7 +841,6 @@ String EditorProperty::get_tooltip_text() const {
}
void EditorProperty::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_label", "text"), &EditorProperty::set_label);
ClassDB::bind_method(D_METHOD("get_label"), &EditorProperty::get_label);
@@ -916,7 +897,6 @@ void EditorProperty::_bind_methods() {
}
EditorProperty::EditorProperty() {
-
draw_top_bg = true;
object = nullptr;
split_ratio = 0.5;
@@ -939,18 +919,17 @@ EditorProperty::EditorProperty() {
label_reference = nullptr;
bottom_editor = nullptr;
}
+
////////////////////////////////////////////////
////////////////////////////////////////////////
void EditorInspectorPlugin::add_custom_control(Control *control) {
-
AddedEditor ae;
ae.property_editor = control;
added_editors.push_back(ae);
}
void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Control *p_prop) {
-
ERR_FAIL_COND(Object::cast_to<EditorProperty>(p_prop) == nullptr);
AddedEditor ae;
@@ -960,7 +939,6 @@ void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Co
}
void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const String &p_label, const Vector<String> &p_properties, Control *p_prop) {
-
AddedEditor ae;
ae.properties = p_properties;
ae.property_editor = p_prop;
@@ -969,28 +947,25 @@ void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const St
}
bool EditorInspectorPlugin::can_handle(Object *p_object) {
-
if (get_script_instance()) {
return get_script_instance()->call("can_handle", p_object);
}
return false;
}
-void EditorInspectorPlugin::parse_begin(Object *p_object) {
+void EditorInspectorPlugin::parse_begin(Object *p_object) {
if (get_script_instance()) {
get_script_instance()->call("parse_begin", p_object);
}
}
void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_parse_category) {
-
if (get_script_instance()) {
get_script_instance()->call("parse_category", p_object, p_parse_category);
}
}
bool EditorInspectorPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
-
if (get_script_instance()) {
Variant arg[6] = {
p_object, p_type, p_path, p_hint, p_hint_text, p_usage
@@ -1004,15 +979,14 @@ bool EditorInspectorPlugin::parse_property(Object *p_object, Variant::Type p_typ
}
return false;
}
-void EditorInspectorPlugin::parse_end() {
+void EditorInspectorPlugin::parse_end() {
if (get_script_instance()) {
get_script_instance()->call("parse_end");
}
}
void EditorInspectorPlugin::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_custom_control", "control"), &EditorInspectorPlugin::add_custom_control);
ClassDB::bind_method(D_METHOD("add_property_editor", "property", "editor"), &EditorInspectorPlugin::add_property_editor);
ClassDB::bind_method(D_METHOD("add_property_editor_for_multiple_properties", "label", "properties", "editor"), &EditorInspectorPlugin::add_property_editor_for_multiple_properties);
@@ -1047,9 +1021,7 @@ void EditorInspectorPlugin::_bind_methods() {
////////////////////////////////////////////////
void EditorInspectorCategory::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
draw_rect(Rect2(Vector2(), get_size()), bg_color);
Ref<Font> font = get_theme_font("font", "Tree");
@@ -1073,7 +1045,6 @@ void EditorInspectorCategory::_notification(int p_what) {
}
Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
-
tooltip_text = p_text;
EditorHelpBit *help_bit = memnew(EditorHelpBit);
help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
@@ -1097,7 +1068,6 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
}
Size2 EditorInspectorCategory::get_minimum_size() const {
-
Ref<Font> font = get_theme_font("font", "Tree");
Size2 ms;
@@ -1116,7 +1086,6 @@ void EditorInspectorCategory::_bind_methods() {
}
String EditorInspectorCategory::get_tooltip_text() const {
-
return tooltip_text;
}
@@ -1127,7 +1096,6 @@ EditorInspectorCategory::EditorInspectorCategory() {
////////////////////////////////////////////////
void EditorInspectorSection::_test_unfold() {
-
if (!vbox_added) {
add_child(vbox);
vbox_added = true;
@@ -1135,9 +1103,7 @@ void EditorInspectorSection::_test_unfold() {
}
void EditorInspectorSection::_notification(int p_what) {
-
if (p_what == NOTIFICATION_SORT_CHILDREN) {
-
Ref<Font> font = get_theme_font("font", "Tree");
Ref<Texture2D> arrow;
@@ -1163,14 +1129,16 @@ void EditorInspectorSection::_notification(int p_what) {
//set children
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (!c->is_visible_in_tree())
+ }
+ if (!c->is_visible_in_tree()) {
continue;
+ }
fit_child_in_rect(c, rect);
}
@@ -1179,7 +1147,6 @@ void EditorInspectorSection::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
Ref<Texture2D> arrow;
if (foldable) {
@@ -1211,17 +1178,18 @@ void EditorInspectorSection::_notification(int p_what) {
}
Size2 EditorInspectorSection::get_minimum_size() const {
-
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (!c->is_visible())
+ }
+ if (!c->is_visible()) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width, minsize.width);
ms.height = MAX(ms.height, minsize.height);
@@ -1235,7 +1203,6 @@ Size2 EditorInspectorSection::get_minimum_size() const {
}
void EditorInspectorSection::setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable) {
-
section = p_section;
label = p_label;
object = p_object;
@@ -1258,13 +1225,12 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe
}
void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
-
- if (!foldable)
+ if (!foldable) {
return;
+ }
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
Ref<Font> font = get_theme_font("font", "Tree");
if (mb->get_position().y > font->get_height()) { //clicked outside
return;
@@ -1287,9 +1253,9 @@ VBoxContainer *EditorInspectorSection::get_vbox() {
}
void EditorInspectorSection::unfold() {
-
- if (!foldable)
+ if (!foldable) {
return;
+ }
_test_unfold();
@@ -1299,11 +1265,13 @@ void EditorInspectorSection::unfold() {
}
void EditorInspectorSection::fold() {
- if (!foldable)
+ if (!foldable) {
return;
+ }
- if (!vbox_added)
+ if (!vbox_added) {
return; //kinda pointless
+ }
object->editor_set_section_unfold(section, false);
vbox->hide();
@@ -1311,7 +1279,6 @@ void EditorInspectorSection::fold() {
}
void EditorInspectorSection::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("setup", "section", "label", "object", "bg_color", "foldable"), &EditorInspectorSection::setup);
ClassDB::bind_method(D_METHOD("get_vbox"), &EditorInspectorSection::get_vbox);
ClassDB::bind_method(D_METHOD("unfold"), &EditorInspectorSection::unfold);
@@ -1327,7 +1294,6 @@ EditorInspectorSection::EditorInspectorSection() {
}
EditorInspectorSection::~EditorInspectorSection() {
-
if (!vbox_added) {
memdelete(vbox);
}
@@ -1340,9 +1306,7 @@ Ref<EditorInspectorPlugin> EditorInspector::inspector_plugins[MAX_PLUGINS];
int EditorInspector::inspector_plugin_count = 0;
EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
-
for (int i = inspector_plugin_count - 1; i >= 0; i--) {
-
inspector_plugins[i]->parse_property(p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide);
if (inspector_plugins[i]->added_editors.size()) {
for (int j = 1; j < inspector_plugins[i]->added_editors.size(); j++) { //only keep first one
@@ -1351,7 +1315,6 @@ EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, V
EditorProperty *prop = Object::cast_to<EditorProperty>(inspector_plugins[i]->added_editors[0].property_editor);
if (prop) {
-
inspector_plugins[i]->added_editors.clear();
return prop;
} else {
@@ -1364,18 +1327,17 @@ EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, V
}
void EditorInspector::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
-
ERR_FAIL_COND(inspector_plugin_count == MAX_PLUGINS);
for (int i = 0; i < inspector_plugin_count; i++) {
- if (inspector_plugins[i] == p_plugin)
+ if (inspector_plugins[i] == p_plugin) {
return; //already exists
+ }
}
inspector_plugins[inspector_plugin_count++] = p_plugin;
}
void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
-
ERR_FAIL_COND(inspector_plugin_count == MAX_PLUGINS);
int idx = -1;
@@ -1391,8 +1353,9 @@ void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &
inspector_plugins[i] = inspector_plugins[i + 1];
}
- if (idx == inspector_plugin_count - 1)
+ if (idx == inspector_plugin_count - 1) {
inspector_plugins[idx] = Ref<EditorInspectorPlugin>();
+ }
inspector_plugin_count--;
}
@@ -1409,19 +1372,15 @@ void EditorInspector::set_undo_redo(UndoRedo *p_undo_redo) {
}
String EditorInspector::get_selected_path() const {
-
return property_selected;
}
void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped) {
-
for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) {
-
EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor);
current_vbox->add_child(F->get().property_editor);
if (ep) {
-
ep->object = object;
ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed));
ep->connect("property_keyed", callable_mp(this, &EditorInspector::_property_keyed));
@@ -1434,7 +1393,6 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit
ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED);
if (F->get().properties.size()) {
-
if (F->get().properties.size() == 1) {
//since it's one, associate:
ep->property = F->get().properties[0];
@@ -1465,7 +1423,6 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit
}
bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName &p_property) {
-
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
if (profile.is_null()) {
return false;
@@ -1474,7 +1431,6 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName
StringName class_name = object->get_class();
while (class_name != StringName()) {
-
if (profile->is_class_property_disabled(class_name, p_property)) {
return true;
}
@@ -1489,7 +1445,6 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName
}
void EditorInspector::update_tree() {
-
//to update properly if all is refreshed
StringName current_selected = property_selected;
int current_focusable = -1;
@@ -1517,14 +1472,16 @@ void EditorInspector::update_tree() {
_clear();
- if (!object)
+ if (!object) {
return;
+ }
List<Ref<EditorInspectorPlugin>> valid_plugins;
for (int i = inspector_plugin_count - 1; i >= 0; i--) { //start by last, so lastly added can override newly added
- if (!inspector_plugins[i]->can_handle(object))
+ if (!inspector_plugins[i]->can_handle(object)) {
continue;
+ }
valid_plugins.push_back(inspector_plugins[i]);
}
@@ -1565,20 +1522,17 @@ void EditorInspector::update_tree() {
}
for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) {
-
PropertyInfo &p = I->get();
//make sure the property can be edited
if (p.usage & PROPERTY_USAGE_SUBGROUP) {
-
subgroup = p.name;
subgroup_base = p.hint_string;
continue;
} else if (p.usage & PROPERTY_USAGE_GROUP) {
-
group = p.name;
group_base = p.hint_string;
subgroup = "";
@@ -1587,29 +1541,31 @@ void EditorInspector::update_tree() {
continue;
} else if (p.usage & PROPERTY_USAGE_CATEGORY) {
-
group = "";
group_base = "";
subgroup = "";
subgroup_base = "";
- if (!show_categories)
+ if (!show_categories) {
continue;
+ }
List<PropertyInfo>::Element *N = I->next();
bool valid = true;
//if no properties in category, skip
while (N) {
- if (N->get().usage & PROPERTY_USAGE_EDITOR)
+ if (N->get().usage & PROPERTY_USAGE_EDITOR) {
break;
+ }
if (N->get().usage & PROPERTY_USAGE_CATEGORY) {
valid = false;
break;
}
N = N->next();
}
- if (!valid)
+ if (!valid) {
continue; //empty, ignore
+ }
EditorInspectorCategory *category = memnew(EditorInspectorCategory);
main_vbox->add_child(category);
@@ -1623,14 +1579,13 @@ void EditorInspector::update_tree() {
if (use_doc_hints) {
StringName type2 = p.name;
if (!class_descr_cache.has(type2)) {
-
String descr;
DocData *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type2);
if (E) {
- descr = E->get().brief_description;
+ descr = DTR(E->get().brief_description);
}
- class_descr_cache[type2] = DTR(descr);
+ class_descr_cache[type2] = descr;
}
category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2]));
@@ -1644,11 +1599,13 @@ void EditorInspector::update_tree() {
continue;
- } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name))
+ } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name)) {
continue;
+ }
- if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end())
+ if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end()) {
continue; //do not show this property in low end gfx
+ }
if (p.name == "script" && (hide_script || bool(object->call("_hide_script_from_inspector")))) {
continue;
@@ -1704,14 +1661,15 @@ void EditorInspector::update_tree() {
String path = basename.left(basename.find_last("/"));
if (use_filter && filter != "") {
-
String cat = path;
- if (capitalize_paths)
+ if (capitalize_paths) {
cat = cat.capitalize();
+ }
- if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name) && property_prefix.to_lower().find(filter.to_lower()) == -1)
+ if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name) && property_prefix.to_lower().find(filter.to_lower()) == -1) {
continue;
+ }
}
if (category_vbox == nullptr) {
@@ -1722,21 +1680,22 @@ void EditorInspector::update_tree() {
VBoxContainer *current_vbox = main_vbox;
{
-
String acc_path = "";
int level = 1;
for (int i = 0; i < path.get_slice_count("/"); i++) {
String path_name = path.get_slice("/", i);
- if (i > 0)
+ if (i > 0) {
acc_path += "/";
+ }
acc_path += path_name;
if (!item_path.has(acc_path)) {
EditorInspectorSection *section = memnew(EditorInspectorSection);
current_vbox->add_child(section);
sections.push_back(section);
- if (capitalize_paths)
+ if (capitalize_paths) {
path_name = path_name.capitalize();
+ }
Color c = sscolor;
c.a /= level;
@@ -1773,7 +1732,6 @@ void EditorInspector::update_tree() {
String doc_hint;
if (use_doc_hints) {
-
StringName classname = object->get_class_name();
if (object_class != String()) {
classname = object_class;
@@ -1797,7 +1755,7 @@ void EditorInspector::update_tree() {
while (F && descr == String()) {
for (int i = 0; i < F->get().properties.size(); i++) {
if (F->get().properties[i].name == propname.operator String()) {
- descr = DTR(F->get().properties[i].description.strip_edges());
+ descr = DTR(F->get().properties[i].description);
break;
}
}
@@ -1807,7 +1765,7 @@ void EditorInspector::update_tree() {
// Likely a theme property.
for (int i = 0; i < F->get().theme_properties.size(); i++) {
if (F->get().theme_properties[i].name == slices[1]) {
- descr = DTR(F->get().theme_properties[i].description.strip_edges());
+ descr = DTR(F->get().theme_properties[i].description);
break;
}
}
@@ -1833,7 +1791,6 @@ void EditorInspector::update_tree() {
ped->added_editors.clear();
for (List<EditorInspectorPlugin::AddedEditor>::Element *F = editors.front(); F; F = F->next()) {
-
EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor);
if (ep) {
@@ -1841,7 +1798,6 @@ void EditorInspector::update_tree() {
ep->object = object;
if (F->get().properties.size()) {
-
if (F->get().properties.size() == 1) {
//since it's one, associate:
ep->property = F->get().properties[0];
@@ -1877,7 +1833,6 @@ void EditorInspector::update_tree() {
current_vbox->add_child(F->get().property_editor);
if (ep) {
-
ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed));
if (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED) {
ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed_update_all), varray(), CONNECT_DEFERRED);
@@ -1918,9 +1873,11 @@ void EditorInspector::update_tree() {
//see if this property exists and should be kept
}
+
void EditorInspector::update_property(const String &p_prop) {
- if (!editor_property_map.has(p_prop))
+ if (!editor_property_map.has(p_prop)) {
return;
+ }
for (List<EditorProperty *>::Element *E = editor_property_map[p_prop].front(); E; E = E->next()) {
E->get()->update_property();
@@ -1929,7 +1886,6 @@ void EditorInspector::update_property(const String &p_prop) {
}
void EditorInspector::_clear() {
-
while (main_vbox->get_child_count()) {
memdelete(main_vbox->get_child(0));
}
@@ -1942,9 +1898,9 @@ void EditorInspector::_clear() {
}
void EditorInspector::refresh() {
-
- if (refresh_countdown > 0 || changing)
+ if (refresh_countdown > 0 || changing) {
return;
+ }
refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
}
@@ -1953,10 +1909,10 @@ Object *EditorInspector::get_edited_object() {
}
void EditorInspector::edit(Object *p_object) {
- if (object == p_object)
+ if (object == p_object) {
return;
+ }
if (object) {
-
_clear();
object->remove_change_receptor(this);
}
@@ -1974,20 +1930,22 @@ void EditorInspector::edit(Object *p_object) {
}
void EditorInspector::set_keying(bool p_active) {
- if (keying == p_active)
+ if (keying == p_active) {
return;
+ }
keying = p_active;
update_tree();
}
+
void EditorInspector::set_read_only(bool p_read_only) {
read_only = p_read_only;
update_tree();
}
bool EditorInspector::is_capitalize_paths_enabled() const {
-
return capitalize_paths;
}
+
void EditorInspector::set_enable_capitalize_paths(bool p_capitalize) {
capitalize_paths = p_capitalize;
update_tree();
@@ -2006,22 +1964,25 @@ void EditorInspector::set_use_doc_hints(bool p_enable) {
use_doc_hints = p_enable;
update_tree();
}
+
void EditorInspector::set_hide_script(bool p_hide) {
hide_script = p_hide;
update_tree();
}
+
void EditorInspector::set_use_filter(bool p_use) {
use_filter = p_use;
update_tree();
}
+
void EditorInspector::register_text_enter(Node *p_line_edit) {
search_box = Object::cast_to<LineEdit>(p_line_edit);
- if (search_box)
+ if (search_box) {
search_box->connect("text_changed", callable_mp(this, &EditorInspector::_filter_changed));
+ }
}
void EditorInspector::_filter_changed(const String &p_text) {
-
_clear();
update_tree();
}
@@ -2036,7 +1997,6 @@ bool EditorInspector::is_using_folding() {
}
void EditorInspector::collapse_all_folding() {
-
for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) {
E->get()->fold();
}
@@ -2072,10 +2032,10 @@ void EditorInspector::set_use_wide_editors(bool p_enable) {
}
void EditorInspector::set_sub_inspector(bool p_enable) {
-
sub_inspector = p_enable;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (sub_inspector) {
add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
@@ -2089,22 +2049,22 @@ void EditorInspector::set_use_deletable_properties(bool p_enabled) {
}
void EditorInspector::_edit_request_change(Object *p_object, const String &p_property) {
-
- if (object != p_object) //may be undoing/redoing for a non edited object, so ignore
+ if (object != p_object) { //may be undoing/redoing for a non edited object, so ignore
return;
+ }
- if (changing)
+ if (changing) {
return;
+ }
- if (p_property == String())
+ if (p_property == String()) {
update_tree_pending = true;
- else {
+ } else {
pending.insert(p_property);
}
}
void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) {
-
if (autoclear && editor_property_map.has(p_name)) {
for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) {
if (E->get()->is_checkable()) {
@@ -2114,22 +2074,20 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
}
if (!undo_redo || bool(object->call("_dont_undo_redo"))) {
-
object->set(p_name, p_value);
- if (p_refresh_all)
+ if (p_refresh_all) {
_edit_request_change(object, "");
- else
+ } else {
_edit_request_change(object, p_name);
+ }
emit_signal(_prop_edited, p_name);
} else if (Object::cast_to<MultiNodeEdit>(object)) {
-
Object::cast_to<MultiNodeEdit>(object)->set_property_field(p_name, p_value, p_changed_field);
_edit_request_change(object, p_name);
emit_signal(_prop_edited, p_name);
} else {
-
undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS);
undo_redo->add_do_property(object, p_name, p_value);
undo_redo->add_undo_property(object, p_name, object->get(p_name));
@@ -2138,14 +2096,12 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
undo_redo->add_do_method(this, "_edit_request_change", object, "");
undo_redo->add_undo_method(this, "_edit_request_change", object, "");
} else {
-
undo_redo->add_do_method(this, "_edit_request_change", object, p_name);
undo_redo->add_undo_method(this, "_edit_request_change", object, p_name);
}
Resource *r = Object::cast_to<Resource>(object);
if (r) {
-
if (String(p_name) == "resource_local_to_scene") {
bool prev = object->get(p_name);
bool next = p_value;
@@ -2170,16 +2126,17 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
}
void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
-
// The "changing" variable must be true for properties that trigger events as typing occurs,
// like "text_changed" signal. E.g. text property of Label, Button, RichTextLabel, etc.
- if (p_changing)
+ if (p_changing) {
this->changing++;
+ }
_edit_set(p_path, p_value, false, p_name);
- if (p_changing)
+ if (p_changing) {
this->changing--;
+ }
if (restart_request_props.has(p_path)) {
emit_signal("restart_requested");
@@ -2191,13 +2148,13 @@ void EditorInspector::_property_changed_update_all(const String &p_path, const V
}
void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values) {
-
ERR_FAIL_COND(p_paths.size() == 0 || p_values.size() == 0);
ERR_FAIL_COND(p_paths.size() != p_values.size());
String names;
for (int i = 0; i < p_paths.size(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += p_paths[i];
}
undo_redo->create_action(TTR("Set Multiple:") + " " + names, UndoRedo::MERGE_ENDS);
@@ -2213,42 +2170,40 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array
}
void EditorInspector::_property_keyed(const String &p_path, bool p_advance) {
-
- if (!object)
+ if (!object) {
return;
+ }
emit_signal("property_keyed", p_path, object->get(p_path), p_advance); //second param is deprecated
}
void EditorInspector::_property_deleted(const String &p_path) {
-
print_line("deleted pressed?");
- if (!object)
+ if (!object) {
return;
+ }
emit_signal("property_deleted", p_path); //second param is deprecated
}
void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance) {
-
- if (!object)
+ if (!object) {
return;
+ }
emit_signal("property_keyed", p_path, p_value, p_advance); //second param is deprecated
}
void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
-
- if (!object)
+ if (!object) {
return;
+ }
//property checked
if (autoclear) {
-
if (!p_checked) {
object->set(p_path, Variant());
} else {
-
Variant to_create;
List<PropertyInfo> pinfo;
object->get_property_list(&pinfo);
@@ -2275,16 +2230,17 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
}
void EditorInspector::_property_selected(const String &p_path, int p_focusable) {
-
property_selected = p_path;
property_focusable = p_focusable;
//deselect the others
for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) {
- if (F->key() == property_selected)
+ if (F->key() == property_selected) {
continue;
+ }
for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) {
- if (E->get()->is_selected())
+ if (E->get()->is_selected()) {
E->get()->deselect();
+ }
}
}
@@ -2292,7 +2248,6 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable)
}
void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) {
-
emit_signal("object_id_selected", p_id);
}
@@ -2301,20 +2256,17 @@ void EditorInspector::_resource_selected(const String &p_path, RES p_resource) {
}
void EditorInspector::_node_removed(Node *p_node) {
-
if (p_node == object) {
edit(nullptr);
}
}
void EditorInspector::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
}
if (p_what == NOTIFICATION_ENTER_TREE) {
-
if (sub_inspector) {
add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
} else {
@@ -2326,7 +2278,6 @@ void EditorInspector::_notification(int p_what) {
edit(nullptr); //just in case
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
if (!sub_inspector) {
get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
}
@@ -2334,7 +2285,6 @@ void EditorInspector::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
-
if (update_scroll_request >= 0) {
get_v_scrollbar()->call_deferred("set_value", update_scroll_request);
update_scroll_request = -1;
@@ -2354,13 +2304,11 @@ void EditorInspector::_notification(int p_what) {
changing++;
if (update_tree_pending) {
-
update_tree();
update_tree_pending = false;
pending.clear();
} else {
-
while (pending.size()) {
StringName prop = pending.front()->get();
if (editor_property_map.has(prop)) {
@@ -2377,7 +2325,6 @@ void EditorInspector::_notification(int p_what) {
}
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
-
if (sub_inspector) {
add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
} else if (is_inside_tree()) {
@@ -2394,9 +2341,9 @@ void EditorInspector::_changed_callback(Object *p_changed, const char *p_prop) {
}
void EditorInspector::_vscroll_changed(double p_offset) {
-
- if (update_scroll_request >= 0) //waiting, do nothing
+ if (update_scroll_request >= 0) { //waiting, do nothing
return;
+ }
if (object) {
scroll_cache[object->get_instance_id()] = p_offset;
@@ -2420,12 +2367,10 @@ String EditorInspector::get_object_class() const {
}
void EditorInspector::_feature_profile_changed() {
-
update_tree();
}
void EditorInspector::_bind_methods() {
-
ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change);
ClassDB::bind_method("refresh", &EditorInspector::refresh);
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index c8c1ecc49a..90d995e36d 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -47,7 +47,6 @@ public:
};
class EditorProperty : public Container {
-
GDCLASS(EditorProperty, Container);
private:
diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp
index dbd043c494..14478b1386 100644
--- a/editor/editor_layouts_dialog.cpp
+++ b/editor/editor_layouts_dialog.cpp
@@ -41,21 +41,20 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
-
- if (!k->is_pressed())
+ if (!k->is_pressed()) {
return;
+ }
switch (k->get_keycode()) {
case KEY_KP_ENTER:
case KEY_ENTER: {
-
- if (get_hide_on_ok())
+ if (get_hide_on_ok()) {
hide();
+ }
ok_pressed();
set_input_as_handled();
} break;
case KEY_ESCAPE: {
-
hide();
set_input_as_handled();
} break;
@@ -64,27 +63,21 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorLayoutsDialog::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name")));
}
void EditorLayoutsDialog::ok_pressed() {
-
if (layout_names->is_anything_selected()) {
-
Vector<int> const selected_items = layout_names->get_selected_items();
for (int i = 0; i < selected_items.size(); ++i) {
-
emit_signal("name_confirmed", layout_names->get_item_text(selected_items[i]));
}
} else if (name->is_visible() && name->get_text() != "") {
-
emit_signal("name_confirmed", name->get_text());
}
}
void EditorLayoutsDialog::_post_popup() {
-
ConfirmationDialog::_post_popup();
name->clear();
layout_names->clear();
@@ -93,7 +86,6 @@ void EditorLayoutsDialog::_post_popup() {
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
if (err != OK) {
-
return;
}
@@ -101,13 +93,11 @@ void EditorLayoutsDialog::_post_popup() {
config.ptr()->get_sections(&layouts);
for (List<String>::Element *E = layouts.front(); E; E = E->next()) {
-
layout_names->add_item(**E);
}
}
EditorLayoutsDialog::EditorLayoutsDialog() {
-
makevb = memnew(VBoxContainer);
add_child(makevb);
makevb->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5);
@@ -133,6 +123,5 @@ EditorLayoutsDialog::EditorLayoutsDialog() {
}
void EditorLayoutsDialog::set_name_line_enabled(bool p_enabled) {
-
name->set_visible(p_enabled);
}
diff --git a/editor/editor_layouts_dialog.h b/editor/editor_layouts_dialog.h
index d18c2bce17..39f0f4163d 100644
--- a/editor/editor_layouts_dialog.h
+++ b/editor/editor_layouts_dialog.h
@@ -37,7 +37,6 @@ class LineEdit;
class ItemList;
class EditorLayoutsDialog : public ConfirmationDialog {
-
GDCLASS(EditorLayoutsDialog, ConfirmationDialog);
LineEdit *name;
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 78aed96363..ea5f73acd1 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -38,10 +38,10 @@
#include "scene/resources/dynamic_font.h"
void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) {
-
EditorLog *self = (EditorLog *)p_self;
- if (self->current != Thread::get_caller_id())
+ if (self->current != Thread::get_caller_id()) {
return;
+ }
String err_str;
if (p_errorexp && p_errorexp[0]) {
@@ -58,9 +58,7 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f
}
void EditorLog::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
//button->set_icon(get_icon("Console","EditorIcons"));
log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts"));
log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
@@ -76,13 +74,11 @@ void EditorLog::_notification(int p_what) {
}
void EditorLog::_clear_request() {
-
log->clear();
tool_button->set_icon(Ref<Texture2D>());
}
void EditorLog::_copy_request() {
-
log->selection_copy();
}
@@ -95,7 +91,6 @@ void EditorLog::copy() {
}
void EditorLog::add_message(const String &p_msg, MessageType p_type) {
-
log->add_newline();
bool restore = p_type != MSG_TYPE_STD;
@@ -124,8 +119,9 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) {
log->add_text(p_msg);
- if (restore)
+ if (restore) {
log->pop();
+ }
}
void EditorLog::set_tool_button(ToolButton *p_tool_button) {
@@ -133,19 +129,16 @@ void EditorLog::set_tool_button(ToolButton *p_tool_button) {
}
void EditorLog::_undo_redo_cbk(void *p_self, const String &p_name) {
-
EditorLog *self = (EditorLog *)p_self;
self->add_message(p_name, EditorLog::MSG_TYPE_EDITOR);
}
void EditorLog::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("clear_request"));
ADD_SIGNAL(MethodInfo("copy_request"));
}
EditorLog::EditorLog() {
-
VBoxContainer *vb = this;
HBoxContainer *hb = memnew(HBoxContainer);
@@ -189,7 +182,6 @@ EditorLog::EditorLog() {
}
void EditorLog::deinit() {
-
remove_error_handler(&eh);
}
diff --git a/editor/editor_log.h b/editor/editor_log.h
index e3980690b2..1c9a2d4062 100644
--- a/editor/editor_log.h
+++ b/editor/editor_log.h
@@ -44,7 +44,6 @@
#include "scene/gui/tool_button.h"
class EditorLog : public VBoxContainer {
-
GDCLASS(EditorLog, VBoxContainer);
Button *clearbutton;
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 42eef2d130..9a9a1bfdeb 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -42,7 +42,6 @@
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
-#include "core/path_remap.h"
#include "core/print_string.h"
#include "core/project_settings.h"
#include "core/translation.h"
@@ -181,7 +180,6 @@
EditorNode *EditorNode::singleton = nullptr;
void EditorNode::_update_scene_tabs() {
-
bool show_rb = EditorSettings::get_singleton()->get("interface/scene_tabs/show_script_button");
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
@@ -191,7 +189,6 @@ void EditorNode::_update_scene_tabs() {
scene_tabs->clear_tabs();
Ref<Texture2D> script_icon = gui_base->get_theme_icon("Script", "EditorIcons");
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
-
Node *type_node = editor_data.get_edited_scene_root(i);
Ref<Texture2D> icon;
if (type_node) {
@@ -233,44 +230,41 @@ void EditorNode::_update_scene_tabs() {
scene_tabs->add_child(scene_tab_add);
}
Rect2 last_tab = Rect2();
- if (scene_tabs->get_tab_count() != 0)
+ if (scene_tabs->get_tab_count() != 0) {
last_tab = scene_tabs->get_tab_rect(scene_tabs->get_tab_count() - 1);
+ }
scene_tab_add->set_position(Point2(last_tab.get_position().x + last_tab.get_size().x + 3, last_tab.get_position().y));
}
}
void EditorNode::_version_control_menu_option(int p_idx) {
-
switch (vcs_actions_menu->get_item_id(p_idx)) {
case RUN_VCS_SETTINGS: {
-
VersionControlEditorPlugin::get_singleton()->popup_vcs_set_up_dialog(gui_base);
} break;
case RUN_VCS_SHUT_DOWN: {
-
VersionControlEditorPlugin::get_singleton()->shut_down();
} break;
}
}
void EditorNode::_update_title() {
-
String appname = ProjectSettings::get_singleton()->get("application/config/name");
String title = appname.empty() ? String(VERSION_FULL_NAME) : String(VERSION_NAME + String(" - ") + appname);
String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String();
- if (!edited.empty())
+ if (!edited.empty()) {
title += " - " + String(edited.get_file());
- if (unsaved_cache)
+ }
+ if (unsaved_cache) {
title += " (*)";
+ }
DisplayServer::get_singleton()->window_set_title(title);
}
void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed() && !k->is_echo()) {
-
EditorPlugin *old_editor = editor_plugin_screen;
if (ED_IS_SHORTCUT("editor/next_tab", p_event)) {
@@ -310,14 +304,13 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void EditorNode::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_PROCESS: {
- if (opening_prev && !confirmation->is_visible())
+ if (opening_prev && !confirmation->is_visible()) {
opening_prev = false;
+ }
if (unsaved_cache != (saved_version != editor_data.get_undo_redo().get_version())) {
-
unsaved_cache = (saved_version != editor_data.get_undo_redo().get_version());
_update_title();
}
@@ -332,10 +325,10 @@ void EditorNode::_notification(int p_what) {
uint32_t tick = OS::get_singleton()->get_ticks_msec();
if (frame != update_spinner_step_frame && (tick - update_spinner_step_msec) > (1000 / 8)) {
-
update_spinner_step++;
- if (update_spinner_step >= 8)
+ if (update_spinner_step >= 8) {
update_spinner_step = 0;
+ }
update_spinner_step_msec = tick;
update_spinner_step_frame = frame + 1;
@@ -409,7 +402,6 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
-
{
_initializing_addons = true;
Vector<String> addons;
@@ -439,7 +431,6 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_WM_FOCUS_IN: {
-
// Restore the original FPS cap after focusing back on the editor
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
@@ -447,18 +438,15 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_WM_FOCUS_OUT: {
-
// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));
} break;
case NOTIFICATION_WM_ABOUT: {
-
show_about();
} break;
case NOTIFICATION_WM_CLOSE_REQUEST: {
-
_menu_option_confirm(FILE_QUIT, false);
} break;
@@ -491,12 +479,12 @@ void EditorNode::_notification(int p_what) {
recent_scenes->set_as_minsize();
// debugger area
- if (EditorDebuggerNode::get_singleton()->is_visible())
+ if (EditorDebuggerNode::get_singleton()->is_visible()) {
bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
+ }
// update_icons
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
-
ToolButton *tb = singleton->main_editor_buttons[i];
EditorPlugin *p_editor = singleton->editor_table[i];
Ref<Texture2D> icon = p_editor->get_icon();
@@ -558,8 +546,9 @@ void EditorNode::_update_update_spinner() {
void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_name) {
Ref<Script> script = Object::cast_to<Script>(p_script);
- if (script.is_null())
+ if (script.is_null()) {
return;
+ }
if (p_activate_name.length()) {
set_addon_plugin_enabled(p_activate_name, true);
}
@@ -569,23 +558,24 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam
}
void EditorNode::_resources_changed(const Vector<String> &p_resources) {
-
List<Ref<Resource>> changed;
int rc = p_resources.size();
for (int i = 0; i < rc; i++) {
-
Ref<Resource> res(ResourceCache::get(p_resources.get(i)));
if (res.is_null()) {
continue;
}
- if (!res->editor_can_reload_from_file())
+ if (!res->editor_can_reload_from_file()) {
continue;
- if (!res->get_path().is_resource_file() && !res->get_path().is_abs_path())
+ }
+ if (!res->get_path().is_resource_file() && !res->get_path().is_abs_path()) {
continue;
- if (!FileAccess::exists(res->get_path()))
+ }
+ if (!FileAccess::exists(res->get_path())) {
continue;
+ }
if (res->get_import_path() != String()) {
//this is an imported resource, will be reloaded if reimported via the _resources_reimported() callback
@@ -603,14 +593,11 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) {
}
void EditorNode::_fs_changed() {
-
for (Set<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) {
-
E->get()->invalidate();
}
for (Set<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) {
-
E->get()->invalidate();
}
@@ -632,7 +619,9 @@ void EditorNode::_fs_changed() {
preset.unref();
}
if (preset.is_null()) {
- export_error = vformat("Invalid export preset name: %s.", preset_name);
+ export_error = vformat(
+ "Invalid export preset name: %s. Make sure `export_presets.cfg` is present in the current directory.",
+ preset_name);
} else {
Ref<EditorExportPlatform> platform = preset->get_platform();
if (platform.is_null()) {
@@ -680,7 +669,6 @@ void EditorNode::_fs_changed() {
}
void EditorNode::_resources_reimported(const Vector<String> &p_resources) {
-
List<String> scenes; //will load later
int current_tab = scene_tabs->get_current_tab();
@@ -710,7 +698,6 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) {
}
void EditorNode::_sources_changed(bool p_exist) {
-
if (waiting_for_first_scan) {
waiting_for_first_scan = false;
@@ -736,13 +723,12 @@ void EditorNode::_vp_resized() {
}
void EditorNode::_node_renamed() {
-
- if (get_inspector())
+ if (get_inspector()) {
get_inspector()->update_tree();
+ }
}
void EditorNode::_editor_select_next() {
-
int editor = _get_current_main_editor();
do {
@@ -757,7 +743,6 @@ void EditorNode::_editor_select_next() {
}
void EditorNode::_editor_select_prev() {
-
int editor = _get_current_main_editor();
do {
@@ -772,7 +757,6 @@ void EditorNode::_editor_select_prev() {
}
Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_deps) {
-
dependency_errors.clear();
Error err;
@@ -780,11 +764,9 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN);
if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) {
-
//current_option = -1;
Vector<String> errors;
for (Set<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) {
-
errors.push_back(E->get());
}
dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors);
@@ -798,16 +780,15 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
}
void EditorNode::edit_node(Node *p_node) {
-
push_item(p_node);
}
void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) {
-
editor_data.apply_changes_in_editors();
int flg = 0;
- if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
flg |= ResourceSaver::FLAG_COMPRESS;
+ }
String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -827,7 +808,6 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
}
void EditorNode::save_resource(const Ref<Resource> &p_resource) {
-
if (p_resource->get_path().is_resource_file()) {
save_resource_in_path(p_resource, p_resource->get_path());
} else {
@@ -836,7 +816,6 @@ void EditorNode::save_resource(const Ref<Resource> &p_resource) {
}
void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) {
-
{
String path = p_resource->get_path();
int srpos = path.find("::");
@@ -860,7 +839,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
List<String> preferred;
for (int i = 0; i < extensions.size(); i++) {
-
if (p_resource->is_class("Script") && (extensions[i] == "tres" || extensions[i] == "res" || extensions[i] == "xml")) {
//this serves no purpose and confused people
continue;
@@ -870,7 +848,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
}
if (p_at_path != String()) {
-
file->set_current_dir(p_at_path);
if (p_resource->get_path().is_resource_file()) {
file->set_current_file(p_resource->get_path().get_file());
@@ -882,7 +859,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
}
}
} else if (p_resource->get_path() != "") {
-
file->set_current_path(p_resource->get_path());
if (extensions.size()) {
String ext = p_resource->get_path().get_extension().to_lower();
@@ -891,7 +867,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
}
}
} else if (preferred.size()) {
-
String existing;
if (extensions.size()) {
existing = "new_" + p_resource->get_class().to_lower() + "." + preferred.front()->get().to_lower();
@@ -903,31 +878,23 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
}
void EditorNode::_menu_option(int p_option) {
-
_menu_option_confirm(p_option, false);
}
void EditorNode::_menu_confirm_current() {
-
_menu_option_confirm(current_option, true);
}
void EditorNode::_dialog_display_save_error(String p_file, Error p_error) {
-
if (p_error) {
-
switch (p_error) {
-
case ERR_FILE_CANT_WRITE: {
-
show_accept(TTR("Can't open file for writing:") + " " + p_file.get_extension(), TTR("OK"));
} break;
case ERR_FILE_UNRECOGNIZED: {
-
show_accept(TTR("Requested file format unknown:") + " " + p_file.get_extension(), TTR("OK"));
} break;
default: {
-
show_accept(TTR("Error while saving."), TTR("OK"));
} break;
}
@@ -935,41 +902,33 @@ void EditorNode::_dialog_display_save_error(String p_file, Error p_error) {
}
void EditorNode::_dialog_display_load_error(String p_file, Error p_error) {
-
if (p_error) {
-
switch (p_error) {
-
case ERR_CANT_OPEN: {
-
- show_accept(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_file.get_file()), TTR("OK"));
+ show_accept(vformat(TTR("Can't open file '%s'. The file could have been moved or deleted."), p_file.get_file()), TTR("OK"));
} break;
case ERR_PARSE_ERROR: {
-
- show_accept(vformat(TTR("Error while parsing '%s'."), p_file.get_file()), TTR("OK"));
+ show_accept(vformat(TTR("Error while parsing file '%s'."), p_file.get_file()), TTR("OK"));
} break;
case ERR_FILE_CORRUPT: {
-
- show_accept(vformat(TTR("Unexpected end of file '%s'."), p_file.get_file()), TTR("OK"));
+ show_accept(vformat(TTR("Scene file '%s' appears to be invalid/corrupt."), p_file.get_file()), TTR("OK"));
} break;
case ERR_FILE_NOT_FOUND: {
-
- show_accept(vformat(TTR("Missing '%s' or its dependencies."), p_file.get_file()), TTR("OK"));
+ show_accept(vformat(TTR("Missing file '%s' or one its dependencies."), p_file.get_file()), TTR("OK"));
} break;
default: {
-
- show_accept(vformat(TTR("Error while loading '%s'."), p_file.get_file()), TTR("OK"));
+ show_accept(vformat(TTR("Error while loading file '%s'."), p_file.get_file()), TTR("OK"));
} break;
}
}
}
void EditorNode::_get_scene_metadata(const String &p_file) {
-
Node *scene = editor_data.get_edited_scene_root();
- if (!scene)
+ if (!scene) {
return;
+ }
String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg");
@@ -977,15 +936,15 @@ void EditorNode::_get_scene_metadata(const String &p_file) {
cf.instance();
Error err = cf->load(path);
- if (err != OK || !cf->has_section("editor_states"))
+ if (err != OK || !cf->has_section("editor_states")) {
return; //must not exist
+ }
List<String> esl;
cf->get_section_keys("editor_states", &esl);
Dictionary md;
for (List<String>::Element *E = esl.front(); E; E = E->next()) {
-
Variant st = cf->get_value("editor_states", E->get());
if (st.get_type() != Variant::NIL) {
md[E->get()] = st;
@@ -996,11 +955,11 @@ void EditorNode::_get_scene_metadata(const String &p_file) {
}
void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
-
Node *scene = editor_data.get_edited_scene_root(p_idx);
- if (!scene)
+ if (!scene) {
return;
+ }
scene->set_meta("__editor_run_settings__", Variant()); //clear it (no point in keeping it)
scene->set_meta("__editor_plugin_states__", Variant());
@@ -1022,7 +981,6 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
md.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
cf->set_value("editor_states", E->get(), md[E->get()]);
}
@@ -1031,12 +989,11 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
}
bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags) {
-
- if (p_res.is_null())
+ if (p_res.is_null()) {
return false;
+ }
if (processed.has(p_res)) {
-
return processed[p_res];
}
@@ -1053,55 +1010,51 @@ bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, i
processed[p_res] = false; //because it's a file
return false;
} else {
-
processed[p_res] = changed;
return changed;
}
}
bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags) {
-
bool ret_changed = false;
List<PropertyInfo> pi;
obj->get_property_list(&pi);
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
switch (E->get().type) {
case Variant::OBJECT: {
-
RES res = obj->get(E->get().name);
- if (_find_and_save_resource(res, processed, flags))
+ if (_find_and_save_resource(res, processed, flags)) {
ret_changed = true;
+ }
} break;
case Variant::ARRAY: {
-
Array varray = obj->get(E->get().name);
int len = varray.size();
for (int i = 0; i < len; i++) {
-
const Variant &v = varray.get(i);
RES res = v;
- if (_find_and_save_resource(res, processed, flags))
+ if (_find_and_save_resource(res, processed, flags)) {
ret_changed = true;
+ }
}
} break;
case Variant::DICTIONARY: {
-
Dictionary d = obj->get(E->get().name);
List<Variant> keys;
d.get_key_list(&keys);
for (List<Variant>::Element *F = keys.front(); F; F = F->next()) {
-
Variant v = d[F->get()];
RES res = v;
- if (_find_and_save_resource(res, processed, flags))
+ if (_find_and_save_resource(res, processed, flags)) {
ret_changed = true;
+ }
}
} break;
default: {
@@ -1113,34 +1066,34 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
}
void EditorNode::_save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags) {
-
_find_and_save_edited_subresources(scene, processed, flags);
for (int i = 0; i < scene->get_child_count(); i++) {
-
Node *n = scene->get_child(i);
- if (n->get_owner() != editor_data.get_edited_scene_root())
+ if (n->get_owner() != editor_data.get_edited_scene_root()) {
continue;
+ }
_save_edited_subresources(n, processed, flags);
}
}
void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) {
-
- if (p_node->is_class("Viewport") || (p_node != editor_data.get_edited_scene_root() && p_node->get_owner() != editor_data.get_edited_scene_root()))
+ if (p_node->is_class("Viewport") || (p_node != editor_data.get_edited_scene_root() && p_node->get_owner() != editor_data.get_edited_scene_root())) {
return;
+ }
- if (p_node->is_class("CanvasItem"))
+ if (p_node->is_class("CanvasItem")) {
count_2d++;
- else if (p_node->is_class("Node3D"))
+ } else if (p_node->is_class("Node3D")) {
count_3d++;
+ }
- for (int i = 0; i < p_node->get_child_count(); i++)
+ for (int i = 0; i < p_node->get_child_count(); i++) {
_find_node_types(p_node->get_child(i), count_2d, count_3d);
+ }
}
void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
-
EditorProgress save("save", TTR("Saving Scene"), 4);
if (editor_data.get_edited_scene_root() != nullptr) {
@@ -1168,7 +1121,6 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
}
if (img.is_valid()) {
-
img = img->duplicate();
save.step(TTR("Creating Thumbnail"), 2);
@@ -1220,7 +1172,6 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
}
bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_node) {
-
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *child = p_node->get_child(i);
if (child->get_filename() == p_filename) {
@@ -1236,7 +1187,6 @@ bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_nod
}
static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Resource>> &edited_resources) {
-
if (p_resource->is_edited()) {
edited_resources.insert(p_resource);
return true;
@@ -1268,8 +1218,9 @@ int EditorNode::_save_external_resources() {
//save external resources and its subresources if any was modified
int flg = 0;
- if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
flg |= ResourceSaver::FLAG_COMPRESS;
+ }
flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
Set<Ref<Resource>> edited_subresources;
@@ -1277,10 +1228,10 @@ int EditorNode::_save_external_resources() {
List<Ref<Resource>> cached;
ResourceCache::get_cached_resources(&cached);
for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) {
-
Ref<Resource> res = E->get();
- if (!res->get_path().is_resource_file())
+ if (!res->get_path().is_resource_file()) {
continue;
+ }
//not only check if this resourec is edited, check contained subresources too
if (_find_edited_resources(res, edited_subresources)) {
ResourceSaver::save(res->get_path(), res, flg);
@@ -1300,11 +1251,9 @@ int EditorNode::_save_external_resources() {
}
void EditorNode::_save_scene(String p_file, int idx) {
-
Node *scene = editor_data.get_edited_scene_root(idx);
if (!scene) {
-
show_accept(TTR("This operation can't be done without a tree root."), TTR("OK"));
return;
}
@@ -1327,17 +1276,17 @@ void EditorNode::_save_scene(String p_file, int idx) {
// old version still work for referencing changes in instanced or inherited scenes
sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(p_file)));
- if (sdata.is_valid())
+ if (sdata.is_valid()) {
sdata->recreate_state();
- else
+ } else {
sdata.instance();
+ }
} else {
sdata.instance();
}
Error err = sdata->pack(scene);
if (err != OK) {
-
show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK"));
return;
}
@@ -1352,8 +1301,9 @@ void EditorNode::_save_scene(String p_file, int idx) {
memdelete(dummy_scene);
int flg = 0;
- if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
flg |= ResourceSaver::FLAG_COMPRESS;
+ }
flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
err = ResourceSaver::save(p_file, sdata, flg);
@@ -1363,29 +1313,27 @@ void EditorNode::_save_scene(String p_file, int idx) {
editor_data.save_editor_external_data();
if (err == OK) {
scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file));
- if (idx < 0 || idx == editor_data.get_edited_scene())
+ if (idx < 0 || idx == editor_data.get_edited_scene()) {
set_current_version(editor_data.get_undo_redo().get_version());
- else
+ } else {
editor_data.set_edited_scene_version(0, idx);
+ }
editor_folding.save_scene_folding(scene, p_file);
_update_title();
_update_scene_tabs();
} else {
-
_dialog_display_save_error(p_file, err);
}
}
void EditorNode::save_all_scenes() {
-
_menu_option_confirm(RUN_STOP, true);
_save_all_scenes();
}
void EditorNode::save_scene_list(Vector<String> p_scene_filenames) {
-
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
@@ -1396,7 +1344,6 @@ void EditorNode::save_scene_list(Vector<String> p_scene_filenames) {
}
void EditorNode::restart_editor() {
-
exiting = true;
String to_reopen;
@@ -1418,14 +1365,14 @@ void EditorNode::restart_editor() {
}
void EditorNode::_save_all_scenes() {
-
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
if (scene && scene->get_filename() != "") {
- if (i != editor_data.get_edited_scene())
+ if (i != editor_data.get_edited_scene()) {
_save_scene(scene->get_filename(), i);
- else
+ } else {
_save_scene_with_preview(scene->get_filename());
+ }
} // else: ignore new scenes
}
@@ -1433,20 +1380,19 @@ void EditorNode::_save_all_scenes() {
}
void EditorNode::_mark_unsaved_scenes() {
-
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
-
Node *node = editor_data.get_edited_scene_root(i);
- if (!node)
+ if (!node) {
continue;
+ }
String path = node->get_filename();
if (!(path == String() || FileAccess::exists(path))) {
-
- if (i == editor_data.get_edited_scene())
+ if (i == editor_data.get_edited_scene()) {
set_current_version(-1);
- else
+ } else {
editor_data.set_edited_scene_version(-1, i);
+ }
}
}
@@ -1455,23 +1401,20 @@ void EditorNode::_mark_unsaved_scenes() {
}
void EditorNode::_dialog_action(String p_file) {
-
switch (current_option) {
case FILE_NEW_INHERITED_SCENE: {
-
Node *scene = editor_data.get_edited_scene_root();
// If the previous scene is rootless, just close it in favor of the new one.
- if (!scene)
+ if (!scene) {
_menu_option_confirm(FILE_CLOSE, true);
+ }
load_scene(p_file, false, true);
} break;
case FILE_OPEN_SCENE: {
-
load_scene(p_file);
} break;
case SETTINGS_PICK_MAIN_SCENE: {
-
ProjectSettings::get_singleton()->set("application/run/main_scene", p_file);
ProjectSettings::get_singleton()->save();
//would be nice to show the project manager opened with the highlighted field..
@@ -1488,14 +1431,14 @@ void EditorNode::_dialog_action(String p_file) {
case SCENE_TAB_CLOSE:
case FILE_SAVE_SCENE:
case FILE_SAVE_AS_SCENE: {
-
int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing;
if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
bool same_open_scene = false;
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- if (editor_data.get_scene_path(i) == p_file && i != scene_idx)
+ if (editor_data.get_scene_path(i) == p_file && i != scene_idx) {
same_open_scene = true;
+ }
}
if (same_open_scene) {
@@ -1508,15 +1451,15 @@ void EditorNode::_dialog_action(String p_file) {
_add_to_recent_scenes(p_file);
save_layout();
- if (scene_idx != -1)
+ if (scene_idx != -1) {
_discard_changes();
+ }
}
} break;
case FILE_SAVE_AND_RUN: {
if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
-
_save_default_environment();
_save_scene_with_preview(p_file);
_run(false, p_file);
@@ -1524,7 +1467,6 @@ void EditorNode::_dialog_action(String p_file) {
} break;
case FILE_EXPORT_MESH_LIBRARY: {
-
Ref<MeshLibrary> ml;
if (file_export_lib_merge->is_pressed() && FileAccess::exists(p_file)) {
ml = ResourceLoader::load(p_file, "MeshLibrary");
@@ -1549,7 +1491,6 @@ void EditorNode::_dialog_action(String p_file) {
} break;
case FILE_EXPORT_TILESET: {
-
Ref<TileSet> tileset;
if (FileAccess::exists(p_file) && file_export_lib_merge->is_pressed()) {
tileset = ResourceLoader::load(p_file, "TileSet");
@@ -1567,7 +1508,6 @@ void EditorNode::_dialog_action(String p_file) {
Error err = ResourceSaver::save(p_file, tileset);
if (err) {
-
show_accept(TTR("Error saving TileSet!"), TTR("OK"));
return;
}
@@ -1575,7 +1515,6 @@ void EditorNode::_dialog_action(String p_file) {
case RESOURCE_SAVE:
case RESOURCE_SAVE_AS: {
-
ERR_FAIL_COND(saving_resource.is_null());
save_resource_in_path(saving_resource, p_file);
saving_resource = Ref<Resource>();
@@ -1585,9 +1524,9 @@ void EditorNode::_dialog_action(String p_file) {
current_obj->_change_notify();
} break;
case SETTINGS_LAYOUT_SAVE: {
-
- if (p_file.empty())
+ if (p_file.empty()) {
return;
+ }
Ref<ConfigFile> config;
config.instance();
@@ -1613,9 +1552,9 @@ void EditorNode::_dialog_action(String p_file) {
} break;
case SETTINGS_LAYOUT_DELETE: {
-
- if (p_file.empty())
+ if (p_file.empty()) {
return;
+ }
Ref<ConfigFile> config;
config.instance();
@@ -1654,7 +1593,6 @@ void EditorNode::_dialog_action(String p_file) {
}
bool EditorNode::item_has_editor(Object *p_object) {
-
if (_is_class_editor_disabled_by_feature_profile(p_object->get_class())) {
return false;
}
@@ -1667,7 +1605,6 @@ void EditorNode::edit_item_resource(RES p_resource) {
}
bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName &p_class) {
-
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
if (profile.is_null()) {
return false;
@@ -1676,7 +1613,6 @@ bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName &
StringName class_name = p_class;
while (class_name != StringName()) {
-
if (profile->is_class_disabled(class_name)) {
return true;
}
@@ -1690,7 +1626,6 @@ bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName &
}
void EditorNode::edit_item(Object *p_object) {
-
Vector<EditorPlugin *> sub_plugins;
if (p_object) {
@@ -1701,7 +1636,6 @@ void EditorNode::edit_item(Object *p_object) {
}
if (!sub_plugins.empty()) {
-
bool same = true;
if (sub_plugins.size() == editor_plugins_over->get_plugins_list().size()) {
for (int i = 0; i < sub_plugins.size(); i++) {
@@ -1724,7 +1658,6 @@ void EditorNode::edit_item(Object *p_object) {
}
void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) {
-
if (!p_object) {
get_inspector()->edit(nullptr);
node_dock->set_node(nullptr);
@@ -1735,20 +1668,19 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in
ObjectID id = p_object->get_instance_id();
if (id != editor_history.get_current()) {
-
if (p_inspector_only) {
editor_history.add_object_inspector_only(id);
- } else if (p_property == "")
+ } else if (p_property == "") {
editor_history.add_object(id);
- else
+ } else {
editor_history.add_object(id, p_property);
+ }
}
_edit_current();
}
void EditorNode::_save_default_environment() {
-
Ref<Environment> fallback = get_tree()->get_root()->get_world_3d()->get_fallback_environment();
if (fallback.is_valid() && fallback->get_path().is_resource_file()) {
@@ -1759,7 +1691,6 @@ void EditorNode::_save_default_environment() {
}
void EditorNode::hide_top_editors() {
-
_display_top_editors(false);
editor_plugins_over->clear();
@@ -1778,17 +1709,16 @@ void EditorNode::_set_editing_top_editors(Object *p_current_object) {
}
static bool overrides_external_editor(Object *p_object) {
-
Script *script = Object::cast_to<Script>(p_object);
- if (!script)
+ if (!script) {
return false;
+ }
return script->get_language()->overrides_external_editor();
}
void EditorNode::_edit_current() {
-
ObjectID current = editor_history.get_current();
Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr;
bool inspector_only = editor_history.is_current_inspector_only();
@@ -1796,7 +1726,6 @@ void EditorNode::_edit_current() {
this->current = current_obj;
if (!current_obj) {
-
scene_tree_dock->set_selected(nullptr);
get_inspector()->edit(nullptr);
node_dock->set_node(nullptr);
@@ -1817,7 +1746,6 @@ void EditorNode::_edit_current() {
String editable_warning; //none by default
if (is_resource) {
-
Resource *current_res = Object::cast_to<Resource>(current_obj);
ERR_FAIL_COND(!current_res);
get_inspector()->edit(current_res);
@@ -1842,7 +1770,6 @@ void EditorNode::_edit_current() {
}
}
} else if (is_node) {
-
Node *current_node = Object::cast_to<Node>(current_obj);
ERR_FAIL_COND(!current_node);
@@ -1865,7 +1792,6 @@ void EditorNode::_edit_current() {
}
} else {
-
Node *selected_node = nullptr;
if (current_obj->is_class("EditorDebuggerRemoteObject")) {
@@ -1918,7 +1844,6 @@ void EditorNode::_edit_current() {
/* Take care of PLUGIN EDITOR */
if (!inspector_only) {
-
EditorPlugin *main_plugin = editor_data.get_editor(current_obj);
for (int i = 0; i < editor_table.size(); i++) {
@@ -1928,20 +1853,20 @@ void EditorNode::_edit_current() {
}
if (main_plugin) {
-
// special case if use of external editor is true
if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
- if (!changing_scene)
+ if (!changing_scene) {
main_plugin->edit(current_obj);
+ }
}
else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// update screen main_plugin
if (!changing_scene) {
-
- if (editor_plugin_screen)
+ if (editor_plugin_screen) {
editor_plugin_screen->make_visible(false);
+ }
editor_plugin_screen = main_plugin;
editor_plugin_screen->edit(current_obj);
@@ -1953,13 +1878,11 @@ void EditorNode::_edit_current() {
}
for (int i = 0; i < editor_table.size(); i++) {
-
main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin);
}
}
} else {
-
editor_plugin_screen->edit(current_obj);
}
}
@@ -1977,7 +1900,6 @@ void EditorNode::_edit_current() {
_set_editing_top_editors(current_obj);
_display_top_editors(true);
} else if (!editor_plugins_over->get_plugins_list().empty()) {
-
hide_top_editors();
}
}
@@ -1987,7 +1909,6 @@ void EditorNode::_edit_current() {
}
void EditorNode::_run(bool p_current, const String &p_custom) {
-
if (editor_run.get_status() == EditorRun::STATUS_PLAY) {
play_button->set_pressed(!_playing_edited);
play_scene_button->set_pressed(_playing_edited);
@@ -2007,7 +1928,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
bool skip_breakpoints;
if (p_current || (editor_data.get_edited_scene_root() && p_custom == editor_data.get_edited_scene_root()->get_filename())) {
-
Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
@@ -2027,7 +1947,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
}
if (run_filename == "") {
-
//evidently, run the scene
if (!ensure_main_scene(false)) {
return;
@@ -2035,15 +1954,12 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
}
if (bool(EDITOR_GET("run/auto_save/save_before_running"))) {
-
if (unsaved_cache) {
-
Node *scene = editor_data.get_edited_scene_root();
if (scene) { //only autosave if there is a scene obviously
if (scene->get_filename() == "") {
-
show_accept(TTR("Current scene was never saved, please save it prior to running."), TTR("OK"));
return;
}
@@ -2055,8 +1971,9 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
editor_data.save_editor_external_data();
}
- if (!call_build())
+ if (!call_build()) {
return;
+ }
if (bool(EDITOR_GET("run/output/always_clear_output_on_play"))) {
log->clear();
@@ -2075,7 +1992,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
EditorDebuggerNode::get_singleton()->start();
Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints);
if (error != OK) {
-
EditorDebuggerNode::get_singleton()->stop();
show_accept(TTR("Could not start subprocess!"), TTR("OK"));
return;
@@ -2099,7 +2015,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
}
void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
-
bool autosave = EDITOR_GET("run/auto_save/save_before_running");
if (autosave) {
_menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
@@ -2107,8 +2022,9 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
if (run_native->is_deploy_debug_remote_enabled()) {
_menu_option_confirm(RUN_STOP, true);
- if (!call_build())
+ if (!call_build()) {
return; // build failed
+ }
EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol());
emit_signal("play_pressed");
@@ -2117,25 +2033,22 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
}
void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
-
- if (!p_confirmed) //this may be a hack..
+ if (!p_confirmed) { //this may be a hack..
current_option = (MenuOptions)p_option;
+ }
switch (p_option) {
case FILE_NEW_SCENE: {
-
new_scene();
} break;
case FILE_NEW_INHERITED_SCENE:
case FILE_OPEN_SCENE: {
-
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
for (int i = 0; i < extensions.size(); i++) {
-
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
@@ -2148,27 +2061,24 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_QUICK_OPEN: {
-
quick_open->popup_dialog("Resource", true);
quick_open->set_title(TTR("Quick Open..."));
} break;
case FILE_QUICK_OPEN_SCENE: {
-
quick_open->popup_dialog("PackedScene", true);
quick_open->set_title(TTR("Quick Open Scene..."));
} break;
case FILE_QUICK_OPEN_SCRIPT: {
-
quick_open->popup_dialog("Script", true);
quick_open->set_title(TTR("Quick Open Script..."));
} break;
case FILE_OPEN_PREV: {
-
- if (previous_scenes.empty())
+ if (previous_scenes.empty()) {
break;
+ }
opening_prev = true;
open_request(previous_scenes.back()->get());
previous_scenes.pop_back();
@@ -2182,20 +2092,21 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
next_tab %= editor_data.get_edited_scene_count();
_scene_tab_closed(next_tab, current_option);
} else {
- if (current_option != FILE_CLOSE_ALL)
+ if (current_option != FILE_CLOSE_ALL) {
current_option = -1;
- else
+ } else {
_scene_tab_closed(editor_data.get_edited_scene());
+ }
}
- if (p_confirmed)
+ if (p_confirmed) {
_menu_option_confirm(SCENE_TAB_CLOSE, true);
+ }
} break;
case FILE_CLOSE_ALL_AND_QUIT:
case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
case FILE_CLOSE: {
-
if (!p_confirmed) {
tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene(false);
@@ -2219,19 +2130,19 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
case SCENE_TAB_CLOSE:
case FILE_SAVE_SCENE: {
-
int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing;
Node *scene = editor_data.get_edited_scene_root(scene_idx);
if (scene && scene->get_filename() != "") {
-
- if (scene_idx != editor_data.get_edited_scene())
+ if (scene_idx != editor_data.get_edited_scene()) {
_save_scene_with_preview(scene->get_filename(), scene_idx);
- else
+ } else {
_save_scene_with_preview(scene->get_filename());
+ }
- if (scene_idx != -1)
+ if (scene_idx != -1) {
_discard_changes();
+ }
save_layout();
break;
@@ -2244,7 +2155,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
Node *scene = editor_data.get_edited_scene_root(scene_idx);
if (!scene) {
-
int saved = _save_external_resources();
String err_text;
if (saved > 0) {
@@ -2264,7 +2174,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
ResourceSaver::get_recognized_extensions(sd, &extensions);
file->clear_filters();
for (int i = 0; i < extensions.size(); i++) {
-
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
@@ -2277,7 +2186,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
} else {
-
String existing;
if (extensions.size()) {
String root_name(scene->get_name());
@@ -2291,7 +2199,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_SAVE_ALL_SCENES: {
-
_save_all_scenes();
} break;
case FILE_SAVE_BEFORE_RUN: {
@@ -2308,14 +2215,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_EXPORT_PROJECT: {
-
project_export->popup_export();
} break;
case FILE_EXPORT_MESH_LIBRARY: {
-
if (!editor_data.get_edited_scene_root()) {
-
show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
break;
}
@@ -2333,7 +2237,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_EXPORT_TILESET: {
-
//Make sure that the scene has a root before trying to convert to tileset
if (!editor_data.get_edited_scene_root()) {
show_accept(TTR("This operation can't be done without a root node."), TTR("OK"));
@@ -2354,9 +2257,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_IMPORT_SUBSCENE: {
-
if (!editor_data.get_edited_scene_root()) {
-
show_accept(TTR("This operation can't be done without a selected node."), TTR("OK"));
break;
}
@@ -2366,9 +2267,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_EXTERNAL_OPEN_SCENE: {
-
if (unsaved_cache && !p_confirmed) {
-
confirmation->get_ok()->set_text(TTR("Open"));
confirmation->set_text(TTR("Current scene not saved. Open anyway?"));
confirmation->popup_centered();
@@ -2385,7 +2284,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case EDIT_UNDO: {
-
if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
log->add_message("Can't undo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR);
} else {
@@ -2399,7 +2297,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
} break;
case EDIT_REDO: {
-
if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
log->add_message("Can't redo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR);
} else {
@@ -2413,11 +2310,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case EDIT_RELOAD_SAVED_SCENE: {
-
Node *scene = get_edited_scene();
- if (!scene)
+ if (!scene) {
break;
+ }
String filename = scene->get_filename();
@@ -2437,8 +2334,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
int cur_idx = editor_data.get_edited_scene();
_remove_edited_scene();
Error err = load_scene(filename);
- if (err != OK)
+ if (err != OK) {
ERR_PRINT("Failed to load scene");
+ }
editor_data.move_edited_scene_to_index(cur_idx);
get_undo_redo()->clear_history(false);
scene_tabs->set_current_tab(cur_idx);
@@ -2463,9 +2361,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_STOP: {
-
- if (editor_run.get_status() == EditorRun::STATUS_STOP)
+ if (editor_run.get_status() == EditorRun::STATUS_STOP) {
break;
+ }
editor_run.stop();
run_custom_filename.clear();
@@ -2498,22 +2396,18 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_PLAY_SCENE: {
-
_save_default_environment();
_menu_option_confirm(RUN_STOP, true);
_run(true);
} break;
case RUN_SCENE_SETTINGS: {
-
run_settings_dialog->popup_run_settings();
} break;
case RUN_SETTINGS: {
-
project_settings->popup_project_settings();
} break;
case FILE_INSTALL_ANDROID_SOURCE: {
-
if (p_confirmed) {
export_template_manager->install_android_template();
} else {
@@ -2534,14 +2428,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_QUIT:
case RUN_PROJECT_MANAGER: {
-
if (!p_confirmed) {
bool save_each = EDITOR_GET("interface/editor/save_each_scene_on_quit");
if (_next_unsaved_scene(!save_each) == -1) {
-
bool confirm = EDITOR_GET("interface/editor/quit_confirmation");
if (confirm) {
-
confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes"));
confirmation->set_text(p_option == FILE_QUIT ? TTR("Exit the editor?") : TTR("Open Project Manager?"));
confirmation->popup_centered();
@@ -2550,12 +2441,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
break;
}
} else {
-
if (save_each) {
-
_menu_option_confirm(p_option == FILE_QUIT ? FILE_CLOSE_ALL_AND_QUIT : FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER, false);
} else {
-
String unsaved_scenes;
int i = _next_unsaved_scene(true, 0);
while (i != -1) {
@@ -2579,65 +2467,52 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_discard_changes();
} break;
case SETTINGS_UPDATE_CONTINUOUSLY: {
-
EditorSettings::get_singleton()->set("interface/editor/update_continuously", true);
_update_update_spinner();
show_accept(TTR("This option is deprecated. Situations where refresh must be forced are now considered a bug. Please report."), TTR("OK"));
} break;
case SETTINGS_UPDATE_WHEN_CHANGED: {
-
EditorSettings::get_singleton()->set("interface/editor/update_continuously", false);
_update_update_spinner();
} break;
case SETTINGS_UPDATE_SPINNER_HIDE: {
-
EditorSettings::get_singleton()->set("interface/editor/show_update_spinner", false);
_update_update_spinner();
} break;
case SETTINGS_PREFERENCES: {
-
settings_config_dialog->popup_edit_settings();
} break;
case SETTINGS_EDITOR_DATA_FOLDER: {
-
OS::get_singleton()->shell_open(String("file://") + EditorSettings::get_singleton()->get_data_dir());
} break;
case SETTINGS_EDITOR_CONFIG_FOLDER: {
-
OS::get_singleton()->shell_open(String("file://") + EditorSettings::get_singleton()->get_settings_dir());
} break;
case SETTINGS_MANAGE_EXPORT_TEMPLATES: {
-
export_template_manager->popup_manager();
} break;
case SETTINGS_MANAGE_FEATURE_PROFILES: {
-
feature_profile_manager->popup_centered_clamped(Size2(900, 800) * EDSCALE, 0.8);
} break;
case SETTINGS_TOGGLE_FULLSCREEN: {
-
DisplayServer::get_singleton()->window_set_mode(DisplayServer::get_singleton()->window_get_mode() == DisplayServer::WINDOW_MODE_FULLSCREEN ? DisplayServer::WINDOW_MODE_WINDOWED : DisplayServer::WINDOW_MODE_FULLSCREEN);
} break;
case SETTINGS_TOGGLE_CONSOLE: {
-
bool was_visible = DisplayServer::get_singleton()->is_console_visible();
DisplayServer::get_singleton()->console_set_visible(!was_visible);
EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", was_visible);
} break;
case EDITOR_SCREENSHOT: {
-
screenshot_timer->start();
} break;
case SETTINGS_PICK_MAIN_SCENE: {
-
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
for (int i = 0; i < extensions.size(); i++) {
-
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
@@ -2672,7 +2547,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case SET_VIDEO_DRIVER_SAVE_AND_RESTART: {
-
ProjectSettings::get_singleton()->set("rendering/quality/driver/driver_name", video_driver_request);
ProjectSettings::get_singleton()->save();
@@ -2696,7 +2570,6 @@ void EditorNode::_screenshot(bool p_use_utc) {
}
void EditorNode::_save_screenshot(NodePath p_path) {
-
SubViewport *viewport = Object::cast_to<SubViewport>(EditorInterface::get_singleton()->get_editor_viewport()->get_viewport());
viewport->set_clear_mode(SubViewport::CLEAR_MODE_ONLY_NEXT_FRAME);
Ref<Image> img = viewport->get_texture()->get_data();
@@ -2730,17 +2603,17 @@ void EditorNode::_tool_menu_option(int p_idx) {
}
int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) {
-
for (int i = p_start; i < editor_data.get_edited_scene_count(); i++) {
-
- if (!editor_data.get_edited_scene_root(i))
+ if (!editor_data.get_edited_scene_root(i)) {
continue;
+ }
int current = editor_data.get_edited_scene();
bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
if (unsaved) {
String scene_filename = editor_data.get_edited_scene_root(i)->get_filename();
- if (p_valid_filename && scene_filename.length() == 0)
+ if (p_valid_filename && scene_filename.length() == 0) {
continue;
+ }
return i;
}
}
@@ -2759,9 +2632,7 @@ void EditorNode::_exit_editor() {
}
void EditorNode::_discard_changes(const String &p_str) {
-
switch (current_option) {
-
case FILE_CLOSE_ALL_AND_QUIT:
case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
case FILE_CLOSE:
@@ -2769,7 +2640,6 @@ void EditorNode::_discard_changes(const String &p_str) {
case FILE_CLOSE_RIGHT:
case FILE_CLOSE_ALL:
case SCENE_TAB_CLOSE: {
-
Node *scene = editor_data.get_edited_scene_root(tab_closing);
if (scene != nullptr) {
String scene_filename = scene->get_filename();
@@ -2803,13 +2673,11 @@ void EditorNode::_discard_changes(const String &p_str) {
}
} break;
case FILE_QUIT: {
-
_menu_option_confirm(RUN_STOP, true);
_exit_editor();
} break;
case RUN_PROJECT_MANAGER: {
-
_menu_option_confirm(RUN_STOP, true);
_exit_editor();
String exec = OS::get_singleton()->get_executable_path();
@@ -2827,7 +2695,6 @@ void EditorNode::_discard_changes(const String &p_str) {
}
void EditorNode::_update_file_menu_opened() {
-
Ref<ShortCut> close_scene_sc = ED_GET_SHORTCUT("editor/close_scene");
close_scene_sc->set_name(TTR("Close Scene"));
Ref<ShortCut> reopen_closed_scene_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene");
@@ -2842,20 +2709,20 @@ void EditorNode::_update_file_menu_closed() {
}
Control *EditorNode::get_viewport() {
-
return viewport;
}
void EditorNode::_editor_select(int p_which) {
-
static bool selecting = false;
- if (selecting || changing_scene)
+ if (selecting || changing_scene) {
return;
+ }
ERR_FAIL_INDEX(p_which, editor_table.size());
- if (!main_editor_buttons[p_which]->is_visible()) //button hidden, no editor
+ if (!main_editor_buttons[p_which]->is_visible()) { //button hidden, no editor
return;
+ }
selecting = true;
@@ -2868,8 +2735,9 @@ void EditorNode::_editor_select(int p_which) {
EditorPlugin *new_editor = editor_table[p_which];
ERR_FAIL_COND(!new_editor);
- if (editor_plugin_screen == new_editor)
+ if (editor_plugin_screen == new_editor) {
return;
+ }
if (editor_plugin_screen) {
editor_plugin_screen->make_visible(false);
@@ -2907,9 +2775,7 @@ void EditorNode::select_editor_by_name(const String &p_name) {
}
void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
-
if (p_editor->has_main_screen()) {
-
ToolButton *tb = memnew(ToolButton);
tb->set_toggle_mode(true);
tb->connect("pressed", callable_mp(singleton, &EditorNode::_editor_select), varray(singleton->main_editor_buttons.size()));
@@ -2931,18 +2797,15 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
}
singleton->editor_data.add_editor_plugin(p_editor);
singleton->add_child(p_editor);
- if (p_config_changed)
+ if (p_config_changed) {
p_editor->enable_plugin();
+ }
}
void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
-
if (p_editor->has_main_screen()) {
-
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
-
if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
-
if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->_editor_select(EDITOR_SCRIPT);
}
@@ -2958,8 +2821,9 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan
}
p_editor->make_visible(false);
p_editor->clear();
- if (p_config_changed)
+ if (p_config_changed) {
p_editor->disable_plugin();
+ }
singleton->editor_plugins_over->get_plugins_list().erase(p_editor);
singleton->remove_child(p_editor);
singleton->editor_data.remove_editor_plugin(p_editor);
@@ -2967,9 +2831,9 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan
}
void EditorNode::_update_addon_config() {
-
- if (_initializing_addons)
+ if (_initializing_addons) {
return;
+ }
Vector<String> enabled_addons;
@@ -2987,12 +2851,10 @@ void EditorNode::_update_addon_config() {
}
void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) {
-
ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon));
ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon));
if (!p_enabled) {
-
EditorPlugin *addon = plugin_addons[p_addon];
remove_editor_plugin(addon, p_config_changed);
memdelete(addon); //bye
@@ -3069,7 +2931,6 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
}
bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const {
-
return plugin_addons.has(p_addon);
}
@@ -3090,8 +2951,9 @@ void EditorNode::_remove_edited_scene(bool p_change_tab) {
ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index));
}
- if (p_change_tab)
+ if (p_change_tab) {
_scene_tab_changed(new_index);
+ }
editor_data.remove_scene(old_index);
editor_data.get_undo_redo().clear_history(false);
_update_title();
@@ -3099,7 +2961,6 @@ void EditorNode::_remove_edited_scene(bool p_change_tab) {
}
void EditorNode::_remove_scene(int index, bool p_change_tab) {
-
if (editor_data.get_edited_scene() == index) {
//Scene to remove is current scene
_remove_edited_scene(p_change_tab);
@@ -3110,37 +2971,39 @@ void EditorNode::_remove_scene(int index, bool p_change_tab) {
}
void EditorNode::set_edited_scene(Node *p_scene) {
-
if (get_editor_data().get_edited_scene_root()) {
- if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root)
+ if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root) {
scene_root->remove_child(get_editor_data().get_edited_scene_root());
+ }
}
get_editor_data().set_edited_scene_root(p_scene);
- if (Object::cast_to<Popup>(p_scene))
+ if (Object::cast_to<Popup>(p_scene)) {
Object::cast_to<Popup>(p_scene)->show(); //show popups
+ }
scene_tree_dock->set_edited_scene(p_scene);
- if (get_tree())
+ if (get_tree()) {
get_tree()->set_edited_scene_root(p_scene);
+ }
if (p_scene) {
- if (p_scene->get_parent() != scene_root)
+ if (p_scene->get_parent() != scene_root) {
scene_root->add_child(p_scene);
+ }
}
}
int EditorNode::_get_current_main_editor() {
-
for (int i = 0; i < editor_table.size(); i++) {
- if (editor_table[i] == editor_plugin_screen)
+ if (editor_table[i] == editor_plugin_screen) {
return i;
+ }
}
return 0;
}
Dictionary EditorNode::_get_main_scene_state() {
-
Dictionary state;
state["main_tab"] = _get_current_main_editor();
state["scene_tree_offset"] = scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
@@ -3151,9 +3014,9 @@ Dictionary EditorNode::_get_main_scene_state() {
}
void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
-
- if (get_edited_scene() != p_for_scene && p_for_scene != nullptr)
+ if (get_edited_scene() != p_for_scene && p_for_scene != nullptr) {
return; //not for this scene
+ }
changing_scene = false;
@@ -3187,13 +3050,16 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
}
}
- if (p_state.has("scene_tree_offset"))
+ if (p_state.has("scene_tree_offset")) {
scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_value(p_state["scene_tree_offset"]);
- if (p_state.has("property_edit_offset"))
+ }
+ if (p_state.has("property_edit_offset")) {
get_inspector()->set_scroll_offset(p_state["property_edit_offset"]);
+ }
- if (p_state.has("node_filter"))
+ if (p_state.has("node_filter")) {
scene_tree_dock->set_filter(p_state["node_filter"]);
+ }
//this should only happen at the very end
@@ -3203,7 +3069,6 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
}
void EditorNode::set_current_version(uint64_t p_version) {
-
saved_version = p_version;
editor_data.set_edited_scene_version(p_version);
}
@@ -3213,19 +3078,19 @@ bool EditorNode::is_changing_scene() const {
}
void EditorNode::_clear_undo_history() {
-
get_undo_redo()->clear_history(false);
}
void EditorNode::set_current_scene(int p_idx) {
-
//Save the folding in case the scene gets reloaded.
- if (editor_data.get_scene_path(p_idx) != "" && editor_data.get_edited_scene_root(p_idx))
+ if (editor_data.get_scene_path(p_idx) != "" && editor_data.get_edited_scene_root(p_idx)) {
editor_folding.save_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx));
+ }
if (editor_data.check_and_update_scene(p_idx)) {
- if (editor_data.get_scene_path(p_idx) != "")
+ if (editor_data.get_scene_path(p_idx) != "") {
editor_folding.load_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx));
+ }
call_deferred("_clear_undo_history");
}
@@ -3234,8 +3099,9 @@ void EditorNode::set_current_scene(int p_idx) {
editor_data.save_edited_scene_state(editor_selection, &editor_history, _get_main_scene_state());
if (get_editor_data().get_edited_scene_root()) {
- if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root)
+ if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root) {
scene_root->remove_child(get_editor_data().get_edited_scene_root());
+ }
}
editor_selection->clear();
@@ -3243,16 +3109,19 @@ void EditorNode::set_current_scene(int p_idx) {
Node *new_scene = editor_data.get_edited_scene_root();
- if (Object::cast_to<Popup>(new_scene))
+ if (Object::cast_to<Popup>(new_scene)) {
Object::cast_to<Popup>(new_scene)->show(); //show popups
+ }
scene_tree_dock->set_edited_scene(new_scene);
- if (get_tree())
+ if (get_tree()) {
get_tree()->set_edited_scene_root(new_scene);
+ }
if (new_scene) {
- if (new_scene->get_parent() != scene_root)
+ if (new_scene->get_parent() != scene_root) {
scene_root->add_child(new_scene);
+ }
}
Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history);
@@ -3264,10 +3133,10 @@ void EditorNode::set_current_scene(int p_idx) {
}
bool EditorNode::is_scene_open(const String &p_path) {
-
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- if (editor_data.get_scene_path(i) == p_path)
+ if (editor_data.get_scene_path(i) == p_path) {
return true;
+ }
}
return false;
@@ -3286,16 +3155,13 @@ int EditorNode::new_scene() {
}
Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_clear_errors, bool p_force_open_imported) {
-
if (!is_inside_tree()) {
defer_load_scene = p_scene;
return OK;
}
if (!p_set_inherited) {
-
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
-
if (editor_data.get_scene_path(i) == p_scene) {
_scene_tab_changed(i);
return OK;
@@ -3311,13 +3177,13 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
}
}
- if (p_clear_errors)
+ if (p_clear_errors) {
load_errors->clear();
+ }
String lpath = ProjectSettings::get_singleton()->localize_path(p_scene);
if (!lpath.begins_with("res://")) {
-
show_accept(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."), TTR("OK"));
opening_prev = false;
return ERR_FILE_NOT_FOUND;
@@ -3337,7 +3203,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
Error err;
Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", true, &err);
if (!sdata.is_valid()) {
-
_dialog_display_load_error(lpath, err);
opening_prev = false;
@@ -3349,11 +3214,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
}
if (!p_ignore_broken_deps && dependency_errors.has(lpath)) {
-
current_option = -1;
Vector<String> errors;
for (Set<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) {
-
errors.push_back(E->get());
}
dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors);
@@ -3369,7 +3232,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
dependency_errors.erase(lpath); //at least not self path
for (Map<String, Set<String>>::Element *E = dependency_errors.front(); E; E = E->next()) {
-
String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E->key()) + "\n";
for (Set<String>::Element *F = E->get().front(); F; F = F->next()) {
txt += "\t" + F->get() + "\n";
@@ -3393,15 +3255,14 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
Node *new_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_MAIN);
if (!new_scene) {
-
sdata.unref();
- _dialog_display_load_error(lpath, ERR_FILE_NOT_FOUND);
+ _dialog_display_load_error(lpath, ERR_FILE_CORRUPT);
opening_prev = false;
if (prev != -1) {
set_current_scene(prev);
editor_data.remove_scene(idx);
}
- return ERR_FILE_NOT_FOUND;
+ return ERR_FILE_CORRUPT;
}
if (p_set_inherited) {
@@ -3444,7 +3305,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
}
void EditorNode::open_request(const String &p_path) {
-
if (!opening_prev) {
List<String>::Element *prev_scene = previous_scenes.find(p_path);
if (prev_scene != nullptr) {
@@ -3456,12 +3316,10 @@ void EditorNode::open_request(const String &p_path) {
}
void EditorNode::request_instance_scene(const String &p_path) {
-
scene_tree_dock->instance(p_path);
}
void EditorNode::request_instance_scenes(const Vector<String> &p_files) {
-
scene_tree_dock->instance_scenes(p_files);
}
@@ -3470,66 +3328,58 @@ ImportDock *EditorNode::get_import_dock() {
}
FileSystemDock *EditorNode::get_filesystem_dock() {
-
return filesystem_dock;
}
-SceneTreeDock *EditorNode::get_scene_tree_dock() {
+SceneTreeDock *EditorNode::get_scene_tree_dock() {
return scene_tree_dock;
}
-InspectorDock *EditorNode::get_inspector_dock() {
+InspectorDock *EditorNode::get_inspector_dock() {
return inspector_dock;
}
void EditorNode::_inherit_request(String p_file) {
-
current_option = FILE_NEW_INHERITED_SCENE;
_dialog_action(p_file);
}
void EditorNode::_instance_request(const Vector<String> &p_files) {
-
request_instance_scenes(p_files);
}
void EditorNode::_close_messages() {
-
old_split_ofs = center_split->get_split_offset();
center_split->set_split_offset(0);
}
void EditorNode::_show_messages() {
-
center_split->set_split_offset(old_split_ofs);
}
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
-
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
- if (rc.find(p_scene) != -1)
+ if (rc.find(p_scene) != -1) {
rc.erase(p_scene);
+ }
rc.push_front(p_scene);
- if (rc.size() > 10)
+ if (rc.size() > 10) {
rc.resize(10);
+ }
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc);
_update_recent_scenes();
}
void EditorNode::_open_recent_scene(int p_idx) {
-
if (p_idx == recent_scenes->get_item_count() - 1) {
-
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", Array());
call_deferred("_update_recent_scenes");
} else {
-
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
ERR_FAIL_INDEX(p_idx, rc.size());
if (load_scene(rc[p_idx]) != OK) {
-
rc.remove(p_idx);
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc);
_update_recent_scenes();
@@ -3538,13 +3388,11 @@ void EditorNode::_open_recent_scene(int p_idx) {
}
void EditorNode::_update_recent_scenes() {
-
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
recent_scenes->clear();
String path;
for (int i = 0; i < rc.size(); i++) {
-
path = rc[i];
recent_scenes->add_item(path.replace("res://", ""), i);
}
@@ -3555,7 +3403,6 @@ void EditorNode::_update_recent_scenes() {
}
void EditorNode::_quick_opened() {
-
Vector<String> files = quick_open->get_selected_files();
for (int i = 0; i < files.size(); i++) {
@@ -3570,12 +3417,10 @@ void EditorNode::_quick_opened() {
}
void EditorNode::_quick_run() {
-
_run(false, quick_run->get_selected());
}
void EditorNode::notify_all_debug_sessions_exited() {
-
_menu_option_confirm(RUN_STOP, false);
stop_button->set_pressed(false);
editor_run.stop();
@@ -3586,7 +3431,6 @@ void EditorNode::add_io_error(const String &p_error) {
}
void EditorNode::_load_error_notify(void *p_ud, const String &p_text) {
-
EditorNode *en = (EditorNode *)p_ud;
en->load_errors->add_image(en->gui_base->get_theme_icon("Error", "EditorIcons"));
en->load_errors->add_text(p_text + "\n");
@@ -3594,13 +3438,11 @@ void EditorNode::_load_error_notify(void *p_ud, const String &p_text) {
}
bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const {
-
if (p_node->get_filename() == p_path) {
return true;
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
if (_find_scene_in_use(p_node->get_child(i), p_path)) {
return true;
}
@@ -3610,15 +3452,14 @@ bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const {
}
bool EditorNode::is_scene_in_use(const String &p_path) {
-
Node *es = get_edited_scene();
- if (es)
+ if (es) {
return _find_scene_in_use(es, p_path);
+ }
return false;
}
void EditorNode::register_editor_types() {
-
ResourceLoader::set_timestamp_on_load(true);
ResourceSaver::set_timestamp_on_save(true);
@@ -3655,16 +3496,15 @@ void EditorNode::register_editor_types() {
}
void EditorNode::unregister_editor_types() {
-
_init_callbacks.clear();
}
void EditorNode::stop_child_process(OS::ProcessID p_pid) {
-
if (has_child_process(p_pid)) {
editor_run.stop_child_process(p_pid);
- if (!editor_run.get_child_process_count()) // All children stopped. Closing.
+ if (!editor_run.get_child_process_count()) { // All children stopped. Closing.
_menu_option_confirm(RUN_STOP, false);
+ }
}
}
@@ -3711,8 +3551,9 @@ StringName EditorNode::get_object_custom_type_name(const Object *p_object) const
Ref<Script> base_script = script;
while (base_script.is_valid()) {
StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path());
- if (name != StringName())
+ if (name != StringName()) {
return name;
+ }
// should probably be deprecated in 4.x
StringName base = base_script->get_instance_base_type();
@@ -3778,14 +3619,17 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String
}
// should probably be deprecated in 4.x
- if (p_object->has_meta("_editor_icon"))
+ if (p_object->has_meta("_editor_icon")) {
return p_object->get_meta("_editor_icon");
+ }
- if (gui_base->has_theme_icon(p_object->get_class(), "EditorIcons"))
+ if (gui_base->has_theme_icon(p_object->get_class(), "EditorIcons")) {
return gui_base->get_theme_icon(p_object->get_class(), "EditorIcons");
+ }
- if (p_fallback.length())
+ if (p_fallback.length()) {
return gui_base->get_theme_icon(p_fallback, "EditorIcons");
+ }
return nullptr;
}
@@ -3835,14 +3679,14 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
}
}
- if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons"))
+ if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons")) {
return gui_base->get_theme_icon(p_fallback, "EditorIcons");
+ }
return nullptr;
}
void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
-
if (singleton->cmdline_export_mode) {
print_line(p_task + ": begin: " + p_label + " steps: " + itos(p_steps));
} else {
@@ -3851,18 +3695,15 @@ void EditorNode::progress_add_task(const String &p_task, const String &p_label,
}
bool EditorNode::progress_task_step(const String &p_task, const String &p_state, int p_step, bool p_force_refresh) {
-
if (singleton->cmdline_export_mode) {
print_line("\t" + p_task + ": step " + itos(p_step) + ": " + p_state);
return false;
} else {
-
return singleton->progress_dialog->task_step(p_task, p_state, p_step, p_force_refresh);
}
}
void EditorNode::progress_end_task(const String &p_task) {
-
if (singleton->cmdline_export_mode) {
print_line(p_task + ": end");
} else {
@@ -3871,29 +3712,23 @@ void EditorNode::progress_end_task(const String &p_task) {
}
void EditorNode::progress_add_task_bg(const String &p_task, const String &p_label, int p_steps) {
-
singleton->progress_hb->add_task(p_task, p_label, p_steps);
}
void EditorNode::progress_task_step_bg(const String &p_task, int p_step) {
-
singleton->progress_hb->task_step(p_task, p_step);
}
void EditorNode::progress_end_task_bg(const String &p_task) {
-
singleton->progress_hb->end_task(p_task);
}
Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) {
-
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir());
if (efsd) {
-
String file = p_path.get_file();
for (int i = 0; i < efsd->get_file_count(); i++) {
if (efsd->get_file(i) == file) {
-
String type = efsd->get_file_type(i);
if (singleton->icon_type_cache.has(type)) {
@@ -3909,42 +3744,36 @@ Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) {
}
void EditorNode::_build_icon_type_cache() {
-
List<StringName> tl;
StringName ei = "EditorIcons";
theme_base->get_theme()->get_icon_list(ei, &tl);
for (List<StringName>::Element *E = tl.front(); E; E = E->next()) {
-
- if (!ClassDB::class_exists(E->get()))
+ if (!ClassDB::class_exists(E->get())) {
continue;
+ }
icon_type_cache[E->get()] = theme_base->get_theme()->get_icon(E->get(), ei);
}
}
void EditorNode::_file_dialog_register(FileDialog *p_dialog) {
-
singleton->file_dialogs.insert(p_dialog);
}
void EditorNode::_file_dialog_unregister(FileDialog *p_dialog) {
-
singleton->file_dialogs.erase(p_dialog);
}
void EditorNode::_editor_file_dialog_register(EditorFileDialog *p_dialog) {
-
singleton->editor_file_dialogs.insert(p_dialog);
}
void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog) {
-
singleton->editor_file_dialogs.erase(p_dialog);
}
Vector<EditorNodeInitCallback> EditorNode::_init_callbacks;
Error EditorNode::export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only) {
-
export_defer.preset = p_preset;
export_defer.path = p_path;
export_defer.debug = p_debug;
@@ -3961,7 +3790,6 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) {
}
void EditorNode::show_warning(const String &p_text, const String &p_title) {
-
if (warning->is_inside_tree()) {
warning->set_text(p_text);
warning->set_title(p_title);
@@ -3972,7 +3800,6 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) {
}
void EditorNode::_copy_warning(const String &p_str) {
-
DisplayServer::get_singleton()->clipboard_set(warning->get_text());
}
@@ -4037,7 +3864,6 @@ void EditorNode::_dock_make_float() {
}
void EditorNode::_update_dock_containers() {
-
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
if (dock_slot[i]->get_tab_count() == 0 && dock_slot[i]->is_visible()) {
dock_slot[i]->hide();
@@ -4048,24 +3874,24 @@ void EditorNode::_update_dock_containers() {
}
for (int i = 0; i < vsplits.size(); i++) {
bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
- if (in_use)
+ if (in_use) {
vsplits[i]->show();
- else
+ } else {
vsplits[i]->hide();
+ }
}
- if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible())
+ if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible()) {
right_hsplit->show();
- else
+ } else {
right_hsplit->hide();
+ }
}
void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
-
Ref<InputEventMouse> me = p_input;
if (me.is_valid()) {
-
Vector2 point = me->get_position();
int nrect = -1;
@@ -4081,8 +3907,9 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
dock_select_rect_over = nrect;
}
- if (nrect == -1)
+ if (nrect == -1) {
return;
+ }
Ref<InputEventMouseButton> mb = me;
@@ -4095,7 +3922,6 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
dock_slot[dock_popup_selected]->hide();
} else {
-
dock_slot[dock_popup_selected]->set_current_tab(0);
}
@@ -4114,24 +3940,23 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
}
void EditorNode::_dock_popup_exit() {
-
dock_select_rect_over = -1;
dock_select->update();
}
void EditorNode::_dock_pre_popup(int p_which) {
-
dock_popup_selected = p_which;
}
void EditorNode::_dock_move_left() {
-
- if (dock_popup_selected < 0 || dock_popup_selected >= DOCK_SLOT_MAX)
+ if (dock_popup_selected < 0 || dock_popup_selected >= DOCK_SLOT_MAX) {
return;
+ }
Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab());
Control *prev = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() - 1);
- if (!current || !prev)
+ if (!current || !prev) {
return;
+ }
dock_slot[dock_popup_selected]->move_child(current, prev->get_index());
dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() - 1);
dock_select->update();
@@ -4140,11 +3965,11 @@ void EditorNode::_dock_move_left() {
}
void EditorNode::_dock_move_right() {
-
Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab());
Control *next = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() + 1);
- if (!current || !next)
+ if (!current || !next) {
return;
+ }
dock_slot[dock_popup_selected]->move_child(next, current->get_index());
dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() + 1);
dock_select->update();
@@ -4175,18 +4000,15 @@ void EditorNode::_dock_select_draw() {
dock_tab_move_right->set_disabled(true);
if (dock_popup_selected != -1 && dock_slot[dock_popup_selected]->get_tab_count()) {
-
dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() == 0);
dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() >= dock_slot[dock_popup_selected]->get_tab_count() - 1);
}
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
-
Vector2 ofs;
switch (i) {
case DOCK_SLOT_LEFT_UL: {
-
} break;
case DOCK_SLOT_LEFT_BL: {
ofs.y += s.y;
@@ -4227,22 +4049,21 @@ void EditorNode::_dock_select_draw() {
} else if (dock_slot[i]->get_child_count() == 0) {
dock_select->draw_rect(r, unused);
} else {
-
dock_select->draw_rect(r, used);
}
for (int j = 0; j < MIN(3, dock_slot[i]->get_child_count()); j++) {
int xofs = (r.size.width / 3) * j;
Color c = used;
- if (i == dock_popup_selected && (dock_slot[i]->get_current_tab() > 3 || dock_slot[i]->get_current_tab() == j))
+ if (i == dock_popup_selected && (dock_slot[i]->get_current_tab() > 3 || dock_slot[i]->get_current_tab() == j)) {
c = tab_selected;
+ }
dock_select->draw_rect(Rect2(2 + ofs.x + xofs, ofs.y, r.size.width / 3 - 1, 3), c);
}
}
}
void EditorNode::_save_docks() {
-
if (waiting_for_first_scan) {
return; //scanning, do not touch docks
}
@@ -4257,13 +4078,13 @@ void EditorNode::_save_docks() {
}
void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) {
-
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
String names;
for (int j = 0; j < dock_slot[i]->get_tab_count(); j++) {
String name = dock_slot[i]->get_tab_control(j)->get_name();
- if (names != "")
+ if (names != "") {
names += ",";
+ }
names += name;
}
@@ -4277,14 +4098,12 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p
p_layout->set_value(p_section, "dock_filesystem_file_list_display_mode", filesystem_dock->get_file_list_display_mode());
for (int i = 0; i < vsplits.size(); i++) {
-
if (vsplits[i]->is_visible_in_tree()) {
p_layout->set_value(p_section, "dock_split_" + itos(i + 1), vsplits[i]->get_split_offset());
}
}
for (int i = 0; i < hsplits.size(); i++) {
-
p_layout->set_value(p_section, "dock_hsplit_" + itos(i + 1), hsplits[i]->get_split_offset());
}
}
@@ -4302,17 +4121,14 @@ void EditorNode::_save_open_scenes_to_config(Ref<ConfigFile> p_layout, const Str
}
void EditorNode::save_layout() {
-
dock_drag_timer->start();
}
void EditorNode::_dock_split_dragged(int ofs) {
-
dock_drag_timer->start();
}
void EditorNode::_load_docks() {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
@@ -4331,9 +4147,7 @@ void EditorNode::_load_docks() {
}
void EditorNode::_update_dock_slots_visibility() {
-
if (!docks_visible) {
-
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
dock_slot[i]->hide();
}
@@ -4346,48 +4160,47 @@ void EditorNode::_update_dock_slots_visibility() {
bottom_panel->hide();
} else {
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
-
int tabs_visible = 0;
for (int j = 0; j < dock_slot[i]->get_tab_count(); j++) {
if (!dock_slot[i]->get_tab_hidden(j)) {
tabs_visible++;
}
}
- if (tabs_visible)
+ if (tabs_visible) {
dock_slot[i]->show();
- else
+ } else {
dock_slot[i]->hide();
+ }
}
for (int i = 0; i < vsplits.size(); i++) {
bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
- if (in_use)
+ if (in_use) {
vsplits[i]->show();
- else
+ } else {
vsplits[i]->hide();
+ }
}
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
-
if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) {
dock_slot[i]->set_current_tab(0);
}
}
bottom_panel->show();
- if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible())
+ if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible()) {
right_hsplit->show();
- else
+ } else {
right_hsplit->hide();
+ }
}
}
void EditorNode::_dock_tab_changed(int p_tab) {
-
// update visibility but don't set current tab
if (!docks_visible) {
-
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
dock_slot[i]->hide();
}
@@ -4400,55 +4213,58 @@ void EditorNode::_dock_tab_changed(int p_tab) {
bottom_panel->hide();
} else {
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
-
- if (dock_slot[i]->get_tab_count())
+ if (dock_slot[i]->get_tab_count()) {
dock_slot[i]->show();
- else
+ } else {
dock_slot[i]->hide();
+ }
}
for (int i = 0; i < vsplits.size(); i++) {
bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
- if (in_use)
+ if (in_use) {
vsplits[i]->show();
- else
+ } else {
vsplits[i]->hide();
+ }
}
bottom_panel->show();
- if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible())
+ if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible()) {
right_hsplit->show();
- else
+ } else {
right_hsplit->hide();
+ }
}
}
void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section) {
-
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
-
- if (!p_layout->has_section_key(p_section, "dock_" + itos(i + 1)))
+ if (!p_layout->has_section_key(p_section, "dock_" + itos(i + 1))) {
continue;
+ }
Vector<String> names = String(p_layout->get_value(p_section, "dock_" + itos(i + 1))).split(",");
for (int j = 0; j < names.size(); j++) {
-
String name = names[j];
//find it, in a horribly inefficient way
int atidx = -1;
Control *node = nullptr;
for (int k = 0; k < DOCK_SLOT_MAX; k++) {
- if (!dock_slot[k]->has_node(name))
+ if (!dock_slot[k]->has_node(name)) {
continue;
+ }
node = Object::cast_to<Control>(dock_slot[k]->get_node(name));
- if (!node)
+ if (!node) {
continue;
+ }
atidx = k;
break;
}
- if (atidx == -1) //well, it's not anywhere
+ if (atidx == -1) { //well, it's not anywhere
continue;
+ }
if (atidx == i) {
node->raise();
@@ -4481,36 +4297,38 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String
}
for (int i = 0; i < vsplits.size(); i++) {
-
- if (!p_layout->has_section_key(p_section, "dock_split_" + itos(i + 1)))
+ if (!p_layout->has_section_key(p_section, "dock_split_" + itos(i + 1))) {
continue;
+ }
int ofs = p_layout->get_value(p_section, "dock_split_" + itos(i + 1));
vsplits[i]->set_split_offset(ofs);
}
for (int i = 0; i < hsplits.size(); i++) {
- if (!p_layout->has_section_key(p_section, "dock_hsplit_" + itos(i + 1)))
+ if (!p_layout->has_section_key(p_section, "dock_hsplit_" + itos(i + 1))) {
continue;
+ }
int ofs = p_layout->get_value(p_section, "dock_hsplit_" + itos(i + 1));
hsplits[i]->set_split_offset(ofs);
}
for (int i = 0; i < vsplits.size(); i++) {
bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
- if (in_use)
+ if (in_use) {
vsplits[i]->show();
- else
+ } else {
vsplits[i]->hide();
+ }
}
- if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible())
+ if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible()) {
right_hsplit->show();
- else
+ } else {
right_hsplit->hide();
+ }
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
-
if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) {
dock_slot[i]->set_current_tab(0);
}
@@ -4559,7 +4377,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
String main_scene = GLOBAL_DEF("application/run/main_scene", "");
if (main_scene == "") {
-
current_option = -1;
pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
pick_main_scene->popup_centered();
@@ -4567,7 +4384,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
}
if (!FileAccess::exists(main_scene)) {
-
current_option = -1;
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered();
@@ -4575,7 +4391,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
}
if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
-
current_option = -1;
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered();
@@ -4603,7 +4418,6 @@ void EditorNode::set_current_tab(int p_tab) {
}
void EditorNode::_update_layouts_menu() {
-
editor_layouts->clear();
overridden_default_layout = -1;
@@ -4624,7 +4438,6 @@ void EditorNode::_update_layouts_menu() {
config.ptr()->get_sections(&layouts);
for (List<String>::Element *E = layouts.front(); E; E = E->next()) {
-
String layout = E->get();
if (layout == TTR("Default")) {
@@ -4637,11 +4450,8 @@ void EditorNode::_update_layouts_menu() {
}
void EditorNode::_layout_menu_option(int p_id) {
-
switch (p_id) {
-
case SETTINGS_LAYOUT_SAVE: {
-
current_option = p_id;
layout_dialog->set_title(TTR("Save Layout"));
layout_dialog->get_ok()->set_text(TTR("Save"));
@@ -4649,7 +4459,6 @@ void EditorNode::_layout_menu_option(int p_id) {
layout_dialog->set_name_line_enabled(true);
} break;
case SETTINGS_LAYOUT_DELETE: {
-
current_option = p_id;
layout_dialog->set_title(TTR("Delete Layout"));
layout_dialog->get_ok()->set_text(TTR("Delete"));
@@ -4657,12 +4466,10 @@ void EditorNode::_layout_menu_option(int p_id) {
layout_dialog->set_name_line_enabled(false);
} break;
case SETTINGS_LAYOUT_DEFAULT: {
-
_load_docks_from_config(default_layout, "docks");
_save_docks();
} break;
default: {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config());
@@ -4677,10 +4484,10 @@ void EditorNode::_layout_menu_option(int p_id) {
}
void EditorNode::_scene_tab_script_edited(int p_tab) {
-
Ref<Script> script = editor_data.get_scene_root_script(p_tab);
- if (script.is_valid())
+ if (script.is_valid()) {
inspector_dock->edit_resource(script);
+ }
}
void EditorNode::_scene_tab_closed(int p_tab, int option) {
@@ -4731,7 +4538,6 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
-
if (scene_tabs->get_hovered_tab() >= 0) {
if (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed()) {
_scene_tab_closed(scene_tabs->get_hovered_tab());
@@ -4742,7 +4548,6 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
}
}
if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
-
// context menu
scene_tabs_context_menu->clear();
scene_tabs_context_menu->set_size(Size2(1, 1));
@@ -4799,8 +4604,9 @@ void EditorNode::_scene_tab_changed(int p_tab) {
bool unsaved = (saved_version != editor_data.get_undo_redo().get_version());
- if (p_tab == editor_data.get_edited_scene())
+ if (p_tab == editor_data.get_edited_scene()) {
return; //pointless
+ }
uint64_t next_scene_version = editor_data.get_scene_version(p_tab);
@@ -4816,7 +4622,6 @@ void EditorNode::_scene_tab_changed(int p_tab) {
}
ToolButton *EditorNode::add_bottom_panel_item(String p_text, Control *p_item) {
-
ToolButton *tb = memnew(ToolButton);
tb->connect("toggled", callable_mp(this, &EditorNode::_bottom_panel_switch), varray(bottom_panel_items.size()));
tb->set_text(p_text);
@@ -4837,19 +4642,17 @@ ToolButton *EditorNode::add_bottom_panel_item(String p_text, Control *p_item) {
}
bool EditorNode::are_bottom_panels_hidden() const {
-
for (int i = 0; i < bottom_panel_items.size(); i++) {
- if (bottom_panel_items[i].button->is_pressed())
+ if (bottom_panel_items[i].button->is_pressed()) {
return false;
+ }
}
return true;
}
void EditorNode::hide_bottom_panel() {
-
for (int i = 0; i < bottom_panel_items.size(); i++) {
-
if (bottom_panel_items[i].control->is_visible()) {
_bottom_panel_switch(false, i);
break;
@@ -4858,9 +4661,7 @@ void EditorNode::hide_bottom_panel() {
}
void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
-
for (int i = 0; i < bottom_panel_items.size(); i++) {
-
if (bottom_panel_items[i].control == p_item) {
_bottom_panel_switch(true, i);
break;
@@ -4869,9 +4670,7 @@ void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
}
void EditorNode::raise_bottom_panel_item(Control *p_item) {
-
for (int i = 0; i < bottom_panel_items.size(); i++) {
-
if (bottom_panel_items[i].control == p_item) {
bottom_panel_items[i].button->raise();
SWAP(bottom_panel_items.write[i], bottom_panel_items.write[bottom_panel_items.size() - 1]);
@@ -4886,9 +4685,7 @@ void EditorNode::raise_bottom_panel_item(Control *p_item) {
}
void EditorNode::remove_bottom_panel_item(Control *p_item) {
-
for (int i = 0; i < bottom_panel_items.size(); i++) {
-
if (bottom_panel_items[i].control == p_item) {
if (p_item->is_visible_in_tree()) {
_bottom_panel_switch(false, i);
@@ -4908,7 +4705,6 @@ void EditorNode::remove_bottom_panel_item(Control *p_item) {
}
void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
-
ERR_FAIL_INDEX(p_idx, bottom_panel_items.size());
if (bottom_panel_items[p_idx].control->is_visible() == p_enable) {
@@ -4917,7 +4713,6 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
if (p_enable) {
for (int i = 0; i < bottom_panel_items.size(); i++) {
-
bottom_panel_items[i].button->set_pressed(i == p_idx);
bottom_panel_items[i].control->set_visible(i == p_idx);
}
@@ -4956,7 +4751,6 @@ bool EditorNode::get_docks_visible() const {
}
void EditorNode::_toggle_distraction_free_mode() {
-
if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) {
int screen = -1;
for (int i = 0; i < editor_table.size(); i++) {
@@ -4979,7 +4773,6 @@ void EditorNode::_toggle_distraction_free_mode() {
}
void EditorNode::set_distraction_free_mode(bool p_enter) {
-
distraction_free->set_pressed(p_enter);
if (p_enter) {
@@ -4991,7 +4784,7 @@ void EditorNode::set_distraction_free_mode(bool p_enter) {
}
}
-bool EditorNode::get_distraction_free_mode() const {
+bool EditorNode::is_distraction_free_mode_enabled() const {
return distraction_free->is_pressed();
}
@@ -5002,7 +4795,6 @@ void EditorNode::add_control_to_dock(DockSlot p_slot, Control *p_control) {
}
void EditorNode::remove_control_from_dock(Control *p_control) {
-
Control *dock = nullptr;
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
if (p_control->get_parent() == dock_slot[i]) {
@@ -5018,7 +4810,6 @@ void EditorNode::remove_control_from_dock(Control *p_control) {
}
Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) {
-
Control *drag_control = memnew(Control);
TextureRect *drag_preview = memnew(TextureRect);
Label *label = memnew(Label);
@@ -5134,8 +4925,9 @@ void EditorNode::add_tool_submenu_item(const String &p_name, PopupMenu *p_submen
void EditorNode::remove_tool_menu_item(const String &p_name) {
for (int i = 0; i < tool_menu->get_item_count(); i++) {
- if (tool_menu->get_item_id(i) != TOOLS_CUSTOM)
+ if (tool_menu->get_item_id(i) != TOOLS_CUSTOM) {
continue;
+ }
if (tool_menu->get_item_text(i) == p_name) {
if (tool_menu->get_item_submenu(i) != "") {
@@ -5167,7 +4959,6 @@ void EditorNode::_global_menu_new_window(const Variant &p_tag) {
}
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
-
String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_selected_path());
_add_dropped_files_recursive(p_files, to_path);
@@ -5176,17 +4967,14 @@ void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
}
void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, String to_path) {
-
DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Vector<String> just_copy = String("ttf,otf").split(",");
for (int i = 0; i < p_files.size(); i++) {
-
String from = p_files[i];
String to = to_path.plus_file(from.get_file());
if (dir->dir_exists(from)) {
-
Vector<String> sub_files;
DirAccessRef sub_dir = DirAccess::open(from);
@@ -5219,19 +5007,16 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str
}
void EditorNode::_file_access_close_error_notify(const String &p_str) {
-
add_io_error("Unable to write to file '" + p_str + "', file in use, locked or lacking permissions.");
}
void EditorNode::reload_scene(const String &p_path) {
-
//first of all, reload internal textures, materials, meshes, etc. as they might have changed on disk
List<Ref<Resource>> cached;
ResourceCache::get_cached_resources(&cached);
List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used
for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) {
-
if (E->get()->get_path().begins_with(p_path + "::")) { //subresources of existing scene
to_clear.push_back(E->get());
}
@@ -5245,7 +5030,6 @@ void EditorNode::reload_scene(const String &p_path) {
int scene_idx = -1;
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
-
if (editor_data.get_scene_path(i) == p_path) {
scene_idx = i;
break;
@@ -5284,7 +5068,6 @@ void EditorNode::reload_scene(const String &p_path) {
int EditorNode::plugin_init_callback_count = 0;
void EditorNode::add_plugin_init_callback(EditorPluginInitializeCallback p_callback) {
-
ERR_FAIL_COND(plugin_init_callback_count == MAX_INIT_CALLBACKS);
plugin_init_callbacks[plugin_init_callback_count++] = p_callback;
@@ -5295,7 +5078,6 @@ EditorPluginInitializeCallback EditorNode::plugin_init_callbacks[EditorNode::MAX
int EditorNode::build_callback_count = 0;
void EditorNode::add_build_callback(EditorBuildCallback p_callback) {
-
ERR_FAIL_COND(build_callback_count == MAX_INIT_CALLBACKS);
build_callbacks[build_callback_count++] = p_callback;
@@ -5304,7 +5086,6 @@ void EditorNode::add_build_callback(EditorBuildCallback p_callback) {
EditorBuildCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS];
bool EditorNode::call_build() {
-
bool builds_successful = true;
for (int i = 0; i < build_callback_count && builds_successful; i++) {
@@ -5323,13 +5104,11 @@ bool EditorNode::call_build() {
}
void EditorNode::_inherit_imported(const String &p_action) {
-
open_imported->hide();
load_scene(open_import_request, true, true);
}
void EditorNode::_open_imported() {
-
load_scene(open_import_request, true, false, true, true);
}
@@ -5349,7 +5128,6 @@ bool EditorNode::is_editor_dimmed() const {
}
void EditorNode::open_export_template_manager() {
-
export_template_manager->popup_manager();
}
@@ -5362,7 +5140,6 @@ void EditorNode::remove_resource_conversion_plugin(const Ref<EditorResourceConve
}
Vector<Ref<EditorResourceConversionPlugin>> EditorNode::find_resource_conversion_plugin(const Ref<Resource> &p_for_resource) {
-
Vector<Ref<EditorResourceConversionPlugin>> ret;
for (int i = 0; i < resource_conversion_plugins.size(); i++) {
@@ -5375,12 +5152,10 @@ Vector<Ref<EditorResourceConversionPlugin>> EditorNode::find_resource_conversion
}
void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
-
top_split->set_visible(!p_pressed);
}
void EditorNode::_update_video_driver_color() {
-
// TODO: Probably should de-hardcode this and add to editor settings.
if (video_driver->get_text() == "GLES2") {
video_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
@@ -5390,7 +5165,6 @@ void EditorNode::_update_video_driver_color() {
}
void EditorNode::_video_driver_selected(int p_which) {
-
String driver = video_driver->get_item_metadata(p_which);
String current = ""; //OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
@@ -5414,33 +5188,30 @@ void EditorNode::_resource_saved(RES p_resource, const String &p_path) {
}
void EditorNode::_resource_loaded(RES p_resource, const String &p_path) {
-
singleton->editor_folding.load_resource_folding(p_resource, p_path);
}
void EditorNode::_feature_profile_changed() {
-
Ref<EditorFeatureProfile> profile = feature_profile_manager->get_current_profile();
TabContainer *import_tabs = cast_to<TabContainer>(import_dock->get_parent());
TabContainer *node_tabs = cast_to<TabContainer>(node_dock->get_parent());
TabContainer *fs_tabs = cast_to<TabContainer>(filesystem_dock->get_parent());
if (profile.is_valid()) {
-
import_tabs->set_tab_hidden(import_dock->get_index(), profile->is_feature_disabled(EditorFeatureProfile::FEATURE_IMPORT_DOCK));
node_tabs->set_tab_hidden(node_dock->get_index(), profile->is_feature_disabled(EditorFeatureProfile::FEATURE_NODE_DOCK));
fs_tabs->set_tab_hidden(filesystem_dock->get_index(), profile->is_feature_disabled(EditorFeatureProfile::FEATURE_FILESYSTEM_DOCK));
main_editor_buttons[EDITOR_3D]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D));
main_editor_buttons[EDITOR_SCRIPT]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT));
- if (StreamPeerSSL::is_available())
+ if (StreamPeerSSL::is_available()) {
main_editor_buttons[EDITOR_ASSETLIB]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB));
+ }
if ((profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) && singleton->main_editor_buttons[EDITOR_3D]->is_pressed()) ||
(profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT) && singleton->main_editor_buttons[EDITOR_SCRIPT]->is_pressed()) ||
(StreamPeerSSL::is_available() && profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) {
_editor_select(EDITOR_2D);
}
} else {
-
import_tabs->set_tab_hidden(import_dock->get_index(), false);
node_tabs->set_tab_hidden(node_dock->get_index(), false);
fs_tabs->set_tab_hidden(filesystem_dock->get_index(), false);
@@ -5449,15 +5220,15 @@ void EditorNode::_feature_profile_changed() {
filesystem_dock->set_visible(true);
main_editor_buttons[EDITOR_3D]->set_visible(true);
main_editor_buttons[EDITOR_SCRIPT]->set_visible(true);
- if (StreamPeerSSL::is_available())
+ if (StreamPeerSSL::is_available()) {
main_editor_buttons[EDITOR_ASSETLIB]->set_visible(true);
+ }
}
_update_dock_slots_visibility();
}
void EditorNode::_bind_methods() {
-
ClassDB::bind_method("_editor_select", &EditorNode::_editor_select);
ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed);
ClassDB::bind_method("edit_node", &EditorNode::edit_node);
@@ -5501,7 +5272,6 @@ void EditorNode::_bind_methods() {
}
static Node *_resource_get_edited_scene() {
-
return EditorNode::get_singleton()->get_edited_scene();
}
@@ -5511,7 +5281,6 @@ void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_err
}
static void _execute_thread(void *p_ud) {
-
EditorNode::ExecuteThreadArgs *eta = (EditorNode::ExecuteThreadArgs *)p_ud;
Error err = OS::get_singleton()->execute(eta->path, eta->args, true, nullptr, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex);
print_verbose("Thread exit status: " + itos(eta->exitcode));
@@ -5523,7 +5292,6 @@ static void _execute_thread(void *p_ud) {
}
int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) {
-
execute_output_dialog->set_title(p_title);
execute_output_dialog->get_ok()->set_disabled(true);
execute_outputs->clear();
@@ -5572,7 +5340,6 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p
}
EditorNode::EditorNode() {
-
Input::get_singleton()->set_use_accumulated_input(true);
Resource::_get_local_scene_func = _resource_get_edited_scene;
@@ -5592,7 +5359,6 @@ EditorNode::EditorNode() {
Input *id = Input::get_singleton();
if (id) {
-
bool found_touchscreen = false;
for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) {
@@ -5621,8 +5387,9 @@ EditorNode::EditorNode() {
TranslationServer::get_singleton()->set_enabled(false);
// load settings
- if (!EditorSettings::get_singleton())
+ if (!EditorSettings::get_singleton()) {
EditorSettings::create();
+ }
FileAccess::set_backup_save(EDITOR_GET("filesystem/on_save/safe_save_on_backup_then_rename"));
@@ -6249,8 +6016,11 @@ EditorNode::EditorNode() {
left_menu_hb->add_child(settings_menu);
p = settings_menu->get_popup();
-
+#ifdef OSX_ENABLED
+ p->add_shortcut(ED_SHORTCUT("editor/editor_settings", TTR("Editor Settings..."), KEY_MASK_CMD + KEY_COMMA), SETTINGS_PREFERENCES);
+#else
p->add_shortcut(ED_SHORTCUT("editor/editor_settings", TTR("Editor Settings...")), SETTINGS_PREFERENCES);
+#endif
p->add_separator();
editor_layouts = memnew(PopupMenu);
@@ -6494,8 +6264,9 @@ EditorNode::EditorNode() {
default_layout->set_value(docks_section, "dock_4", "FileSystem");
default_layout->set_value(docks_section, "dock_5", "Inspector,Node");
- for (int i = 0; i < vsplits.size(); i++)
+ for (int i = 0; i < vsplits.size(); i++) {
default_layout->set_value(docks_section, "dock_split_" + itos(i + 1), 0);
+ }
default_layout->set_value(docks_section, "dock_hsplit_1", 0);
default_layout->set_value(docks_section, "dock_hsplit_2", 70 * EDSCALE);
default_layout->set_value(docks_section, "dock_hsplit_3", -70 * EDSCALE);
@@ -6696,8 +6467,9 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(MeshEditorPlugin(this)));
add_editor_plugin(memnew(MaterialEditorPlugin(this)));
- for (int i = 0; i < EditorPlugins::get_plugin_count(); i++)
+ for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) {
add_editor_plugin(EditorPlugins::create(i, this));
+ }
for (int i = 0; i < plugin_init_callback_count; i++) {
plugin_init_callbacks[i]();
@@ -6798,6 +6570,7 @@ EditorNode::EditorNode() {
gui_base->add_child(load_error_dialog);
execute_outputs = memnew(RichTextLabel);
+ execute_outputs->set_selection_enabled(true);
execute_output_dialog = memnew(AcceptDialog);
execute_output_dialog->add_child(execute_outputs);
execute_output_dialog->set_title("");
@@ -6817,8 +6590,9 @@ EditorNode::EditorNode() {
pick_main_scene->get_ok()->set_text(TTR("Select"));
pick_main_scene->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_PICK_MAIN_SCENE));
- for (int i = 0; i < _init_callbacks.size(); i++)
+ for (int i = 0; i < _init_callbacks.size(); i++) {
_init_callbacks[i]();
+ }
editor_data.add_edited_scene(-1);
editor_data.set_edited_scene(0);
@@ -6864,7 +6638,6 @@ EditorNode::EditorNode() {
}
EditorNode::~EditorNode() {
-
EditorInspector::cleanup_plugins();
remove_print_handler(&print_handler);
@@ -6883,21 +6656,18 @@ EditorNode::~EditorNode() {
*/
void EditorPluginList::make_visible(bool p_visible) {
-
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->make_visible(p_visible);
}
}
void EditorPluginList::edit(Object *p_object) {
-
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->edit(p_object);
}
}
bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) {
-
bool discard = false;
for (int i = 0; i < plugins_list.size(); i++) {
@@ -6926,28 +6696,24 @@ bool EditorPluginList::forward_spatial_gui_input(Camera3D *p_camera, const Ref<I
}
void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) {
-
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->forward_canvas_draw_over_viewport(p_overlay);
}
}
void EditorPluginList::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
-
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->forward_canvas_force_draw_over_viewport(p_overlay);
}
}
void EditorPluginList::forward_spatial_draw_over_viewport(Control *p_overlay) {
-
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->forward_spatial_draw_over_viewport(p_overlay);
}
}
void EditorPluginList::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
-
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->forward_spatial_force_draw_over_viewport(p_overlay);
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index b39a3bbfd0..7c9cf44d6c 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -89,7 +89,6 @@ class Window;
class SubViewport;
class EditorNode : public Node {
-
GDCLASS(EditorNode, Node);
public:
@@ -548,8 +547,9 @@ private:
static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
EditorNode *en = (EditorNode *)ud;
- if (!en->dependency_errors.has(p_path))
+ if (!en->dependency_errors.has(p_path)) {
en->dependency_errors[p_path] = Set<String>();
+ }
en->dependency_errors[p_path].insert(p_dep + "::" + p_type);
}
@@ -693,7 +693,7 @@ public:
bool get_docks_visible() const;
void set_distraction_free_mode(bool p_enter);
- bool get_distraction_free_mode() const;
+ bool is_distraction_free_mode_enabled() const;
void add_control_to_dock(DockSlot p_slot, Control *p_control);
void remove_control_from_dock(Control *p_control);
@@ -802,10 +802,11 @@ public:
static void progress_end_task_bg(const String &p_task);
void save_scene_to_path(String p_file, bool p_with_preview = true) {
- if (p_with_preview)
+ if (p_with_preview) {
_save_scene_with_preview(p_file);
- else
+ } else {
_save_scene(p_file);
+ }
}
bool is_scene_in_use(const String &p_path);
@@ -868,7 +869,6 @@ public:
};
struct EditorProgress {
-
String task;
bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); }
EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false) {
@@ -909,7 +909,6 @@ public:
};
struct EditorProgressBG {
-
String task;
void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); }
EditorProgressBG(const String &p_task, const String &p_label, int p_amount) {
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index 804ad62bbb..c249974f99 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -34,25 +34,28 @@
#include "editor_scale.h"
void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
-
- if (p_depth > 8)
+ if (p_depth > 8) {
return;
+ }
List<PropertyInfo> pinfo;
p_obj->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) {
continue;
- if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE)
+ }
+ if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) {
continue;
+ }
Variant value = p_obj->get(E->get().name);
- if (value.get_type() != Variant::OBJECT)
+ if (value.get_type() != Variant::OBJECT) {
continue;
+ }
Object *obj = value;
- if (!obj)
+ if (!obj) {
continue;
+ }
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
@@ -66,10 +69,10 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
}
void EditorPath::_about_to_show() {
-
Object *obj = ObjectDB::get_instance(history->get_path_object(history->get_path_size() - 1));
- if (!obj)
+ if (!obj) {
return;
+ }
objects.clear();
get_popup()->clear();
@@ -83,37 +86,39 @@ void EditorPath::_about_to_show() {
}
void EditorPath::update_path() {
-
for (int i = 0; i < history->get_path_size(); i++) {
-
Object *obj = ObjectDB::get_instance(history->get_path_object(i));
- if (!obj)
+ if (!obj) {
continue;
+ }
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
- if (icon.is_valid())
+ if (icon.is_valid()) {
set_icon(icon);
+ }
if (i == history->get_path_size() - 1) {
String name;
if (Object::cast_to<Resource>(obj)) {
-
Resource *r = Object::cast_to<Resource>(obj);
- if (r->get_path().is_resource_file())
+ if (r->get_path().is_resource_file()) {
name = r->get_path().get_file();
- else
+ } else {
name = r->get_name();
+ }
- if (name == "")
+ if (name == "") {
name = r->get_class();
- } else if (obj->is_class("EditorDebuggerRemoteObject"))
+ }
+ } else if (obj->is_class("EditorDebuggerRemoteObject")) {
name = obj->call("get_title");
- else if (Object::cast_to<Node>(obj))
+ } else if (Object::cast_to<Node>(obj)) {
name = Object::cast_to<Node>(obj)->get_name();
- else if (Object::cast_to<Resource>(obj) && Object::cast_to<Resource>(obj)->get_name() != "")
+ } else if (Object::cast_to<Resource>(obj) && Object::cast_to<Resource>(obj)->get_name() != "") {
name = Object::cast_to<Resource>(obj)->get_name();
- else
+ } else {
name = obj->get_class();
+ }
set_text(" " + name); // An extra space so the text is not too close of the icon.
set_tooltip(obj->get_class());
@@ -122,18 +127,17 @@ void EditorPath::update_path() {
}
void EditorPath::_id_pressed(int p_idx) {
-
ERR_FAIL_INDEX(p_idx, objects.size());
Object *obj = ObjectDB::get_instance(objects[p_idx]);
- if (!obj)
+ if (!obj) {
return;
+ }
EditorNode::get_singleton()->push_item(obj);
}
void EditorPath::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
update_path();
@@ -145,7 +149,6 @@ void EditorPath::_bind_methods() {
}
EditorPath::EditorPath(EditorHistory *p_history) {
-
history = p_history;
set_clip_text(true);
set_text_align(ALIGN_LEFT);
diff --git a/editor/editor_path.h b/editor/editor_path.h
index b0ffc487ac..01ba25ab69 100644
--- a/editor/editor_path.h
+++ b/editor/editor_path.h
@@ -35,7 +35,6 @@
#include "scene/gui/menu_button.h"
class EditorPath : public MenuButton {
-
GDCLASS(EditorPath, MenuButton);
EditorHistory *history;
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 746ebc8292..6d93e92555 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -44,7 +44,6 @@
#include "servers/rendering_server.h"
Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) {
-
Vector<Ref<Mesh>> meshes;
for (int i = 0; i < p_meshes.size(); i++) {
@@ -61,7 +60,6 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_
}
Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) {
-
int size = p_preview_size;
RID scenario = RS::get_singleton()->scenario_create();
@@ -89,7 +87,6 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
Vector<Ref<Texture2D>> textures;
for (int i = 0; i < p_meshes.size(); i++) {
-
Ref<Mesh> mesh = p_meshes[i];
if (!mesh.is_valid()) {
textures.push_back(Ref<Texture2D>());
@@ -156,17 +153,14 @@ void EditorInterface::set_main_screen_editor(const String &p_name) {
}
Control *EditorInterface::get_editor_viewport() {
-
return EditorNode::get_singleton()->get_viewport();
}
void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
-
EditorNode::get_singleton()->edit_resource(p_resource);
}
void EditorInterface::open_scene_from_path(const String &scene_path) {
-
if (EditorNode::get_singleton()->is_changing_scene()) {
return;
}
@@ -175,7 +169,6 @@ void EditorInterface::open_scene_from_path(const String &scene_path) {
}
void EditorInterface::reload_scene_from_path(const String &scene_path) {
-
if (EditorNode::get_singleton()->is_changing_scene()) {
return;
}
@@ -188,14 +181,14 @@ Node *EditorInterface::get_edited_scene_root() {
}
Array EditorInterface::get_open_scenes() const {
-
Array ret;
Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes();
int scns_amount = scenes.size();
for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
- if (scenes[idx_scn].root == nullptr)
+ if (scenes[idx_scn].root == nullptr) {
continue;
+ }
ret.push_back(scenes[idx_scn].root->get_filename());
}
return ret;
@@ -218,7 +211,6 @@ String EditorInterface::get_current_path() const {
}
void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property) {
-
EditorNode::get_singleton()->push_item(p_obj, p_for_property);
}
@@ -243,7 +235,6 @@ EditorResourcePreview *EditorInterface::get_resource_previewer() {
}
Control *EditorInterface::get_base_control() {
-
return EditorNode::get_singleton()->get_gui_base();
}
@@ -260,17 +251,18 @@ EditorInspector *EditorInterface::get_inspector() const {
}
Error EditorInterface::save_scene() {
- if (!get_edited_scene_root())
+ if (!get_edited_scene_root()) {
return ERR_CANT_CREATE;
- if (get_edited_scene_root()->get_filename() == String())
+ }
+ if (get_edited_scene_root()->get_filename() == String()) {
return ERR_CANT_CREATE;
+ }
save_scene_as(get_edited_scene_root()->get_filename());
return OK;
}
void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) {
-
EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview);
}
@@ -278,10 +270,13 @@ void EditorInterface::set_distraction_free_mode(bool p_enter) {
EditorNode::get_singleton()->set_distraction_free_mode(p_enter);
}
+bool EditorInterface::is_distraction_free_mode_enabled() const {
+ return EditorNode::get_singleton()->is_distraction_free_mode_enabled();
+}
+
EditorInterface *EditorInterface::singleton = nullptr;
void EditorInterface::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property"), &EditorInterface::inspect_object, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
@@ -311,6 +306,9 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
+ ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distraction_free_mode"), "set_distraction_free_mode", "is_distraction_free_mode_enabled");
}
EditorInterface::EditorInterface() {
@@ -319,12 +317,10 @@ EditorInterface::EditorInterface() {
///////////////////////////////////////////
void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
-
EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
}
void EditorPlugin::remove_custom_type(const String &p_type) {
-
EditorNode::get_editor_data().remove_custom_type(p_type);
}
@@ -342,19 +338,16 @@ ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const
}
void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
-
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control);
}
void EditorPlugin::remove_control_from_docks(Control *p_control) {
-
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->remove_control_from_dock(p_control);
}
void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
-
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
}
@@ -363,69 +356,56 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C
ERR_FAIL_NULL(p_control);
switch (p_location) {
-
case CONTAINER_TOOLBAR: {
-
EditorNode::get_menu_hb()->add_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_MENU: {
-
Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
-
Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control);
Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
-
Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control);
Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
-
Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
-
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
-
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
-
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
} break;
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
-
CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
} break;
case CONTAINER_PROPERTY_EDITOR_BOTTOM: {
-
EditorNode::get_singleton()->get_inspector_dock_addon_area()->add_child(p_control);
} break;
case CONTAINER_PROJECT_SETTING_TAB_LEFT: {
-
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0);
} break;
case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
-
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1);
@@ -437,52 +417,42 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati
ERR_FAIL_NULL(p_control);
switch (p_location) {
-
case CONTAINER_TOOLBAR: {
-
EditorNode::get_menu_hb()->remove_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_MENU: {
-
Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT:
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
-
Node3DEditor::get_singleton()->get_palette_split()->remove_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
-
Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
-
CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT:
case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
-
CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
-
CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control);
} break;
case CONTAINER_PROPERTY_EDITOR_BOTTOM: {
-
EditorNode::get_singleton()->get_inspector_dock_addon_area()->remove_child(p_control);
} break;
case CONTAINER_PROJECT_SETTING_TAB_LEFT:
case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
-
ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control);
} break;
@@ -521,9 +491,9 @@ void EditorPlugin::notify_scene_changed(const Node *scn_root) {
}
void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
-
- if (screen_name == last_main_screen_name)
+ if (screen_name == last_main_screen_name) {
return;
+ }
emit_signal("main_screen_changed", screen_name);
last_main_screen_name = screen_name;
@@ -538,7 +508,6 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
}
bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
-
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) {
return get_script_instance()->call("forward_canvas_gui_input", p_event);
}
@@ -546,14 +515,12 @@ bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
-
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_draw_over_viewport")) {
get_script_instance()->call("forward_canvas_draw_over_viewport", p_overlay);
}
}
void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
-
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_force_draw_over_viewport")) {
get_script_instance()->call("forward_canvas_force_draw_over_viewport", p_overlay);
}
@@ -561,7 +528,6 @@ void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
// Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
int EditorPlugin::update_overlays() const {
-
if (Node3DEditor::get_singleton()->is_visible()) {
int count = 0;
for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
@@ -580,7 +546,6 @@ int EditorPlugin::update_overlays() const {
}
bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
-
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
}
@@ -589,51 +554,48 @@ bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<Input
}
void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
-
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_draw_over_viewport")) {
get_script_instance()->call("forward_spatial_draw_over_viewport", p_overlay);
}
}
void EditorPlugin::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
-
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_force_draw_over_viewport")) {
get_script_instance()->call("forward_spatial_force_draw_over_viewport", p_overlay);
}
}
-String EditorPlugin::get_name() const {
+String EditorPlugin::get_name() const {
if (get_script_instance() && get_script_instance()->has_method("get_plugin_name")) {
return get_script_instance()->call("get_plugin_name");
}
return String();
}
-const Ref<Texture2D> EditorPlugin::get_icon() const {
+const Ref<Texture2D> EditorPlugin::get_icon() const {
if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) {
return get_script_instance()->call("get_plugin_icon");
}
return Ref<Texture2D>();
}
-bool EditorPlugin::has_main_screen() const {
+bool EditorPlugin::has_main_screen() const {
if (get_script_instance() && get_script_instance()->has_method("has_main_screen")) {
return get_script_instance()->call("has_main_screen");
}
return false;
}
-void EditorPlugin::make_visible(bool p_visible) {
+void EditorPlugin::make_visible(bool p_visible) {
if (get_script_instance() && get_script_instance()->has_method("make_visible")) {
get_script_instance()->call("make_visible", p_visible);
}
}
void EditorPlugin::edit(Object *p_object) {
-
if (get_script_instance() && get_script_instance()->has_method("edit")) {
if (p_object->is_class("Resource")) {
get_script_instance()->call("edit", Ref<Resource>(Object::cast_to<Resource>(p_object)));
@@ -644,15 +606,14 @@ void EditorPlugin::edit(Object *p_object) {
}
bool EditorPlugin::handles(Object *p_object) const {
-
if (get_script_instance() && get_script_instance()->has_method("handles")) {
return get_script_instance()->call("handles", p_object);
}
return false;
}
-Dictionary EditorPlugin::get_state() const {
+Dictionary EditorPlugin::get_state() const {
if (get_script_instance() && get_script_instance()->has_method("get_state")) {
return get_script_instance()->call("get_state");
}
@@ -661,14 +622,12 @@ Dictionary EditorPlugin::get_state() const {
}
void EditorPlugin::set_state(const Dictionary &p_state) {
-
if (get_script_instance() && get_script_instance()->has_method("set_state")) {
get_script_instance()->call("set_state", p_state);
}
}
void EditorPlugin::clear() {
-
if (get_script_instance() && get_script_instance()->has_method("clear")) {
get_script_instance()->call("clear");
}
@@ -676,7 +635,6 @@ void EditorPlugin::clear() {
// if editor references external resources/scenes, save them
void EditorPlugin::save_external_data() {
-
if (get_script_instance() && get_script_instance()->has_method("save_external_data")) {
get_script_instance()->call("save_external_data");
}
@@ -684,22 +642,21 @@ void EditorPlugin::save_external_data() {
// if changes are pending in editor, apply them
void EditorPlugin::apply_changes() {
-
if (get_script_instance() && get_script_instance()->has_method("apply_changes")) {
get_script_instance()->call("apply_changes");
}
}
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
-
if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
PackedStringArray arr = get_script_instance()->call("get_breakpoints");
- for (int i = 0; i < arr.size(); i++)
+ for (int i = 0; i < arr.size(); i++) {
p_breakpoints->push_back(arr[i]);
+ }
}
}
-bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
+bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
return false;
}
@@ -777,21 +734,18 @@ void EditorPlugin::disable_plugin() {
}
void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
-
if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) {
get_script_instance()->call("set_window_layout", p_layout);
}
}
void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
-
if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) {
get_script_instance()->call("get_window_layout", p_layout);
}
}
bool EditorPlugin::build() {
-
if (get_script_instance() && get_script_instance()->has_method("build")) {
return get_script_instance()->call("build");
}
@@ -800,17 +754,14 @@ bool EditorPlugin::build() {
}
void EditorPlugin::queue_save_layout() const {
-
EditorNode::get_singleton()->save_layout();
}
void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
-
EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
}
void EditorPlugin::hide_bottom_panel() {
-
EditorNode::get_singleton()->hide_bottom_panel();
}
@@ -823,7 +774,6 @@ ScriptCreateDialog *EditorPlugin::get_script_create_dialog() {
}
void EditorPlugin::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container);
ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel);
ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock);
@@ -913,16 +863,6 @@ void EditorPlugin::_bind_methods() {
BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
}
-EditorPlugin::EditorPlugin() :
- undo_redo(nullptr),
- input_event_forwarding_always_enabled(false),
- force_draw_over_forwarding_enabled(false),
- last_main_screen_name("") {
-}
-
-EditorPlugin::~EditorPlugin() {
-}
-
EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
int EditorPlugins::creation_func_count = 0;
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 2ca96ceed2..aac36bfdfd 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -105,20 +105,20 @@ public:
void set_main_screen_editor(const String &p_name);
void set_distraction_free_mode(bool p_enter);
+ bool is_distraction_free_mode_enabled() const;
EditorInterface();
};
class EditorPlugin : public Node {
-
GDCLASS(EditorPlugin, Node);
friend class EditorData;
- UndoRedo *undo_redo;
+ UndoRedo *undo_redo = nullptr;
UndoRedo *_get_undo_redo() { return undo_redo; }
- bool input_event_forwarding_always_enabled;
- bool force_draw_over_forwarding_enabled;
+ bool input_event_forwarding_always_enabled = false;
+ bool force_draw_over_forwarding_enabled = false;
String last_main_screen_name;
@@ -242,8 +242,8 @@ public:
void enable_plugin();
void disable_plugin();
- EditorPlugin();
- virtual ~EditorPlugin();
+ EditorPlugin() {}
+ virtual ~EditorPlugin() {}
};
VARIANT_ENUM_CAST(EditorPlugin::CustomControlContainer);
@@ -252,7 +252,6 @@ VARIANT_ENUM_CAST(EditorPlugin::DockSlot);
typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *);
class EditorPlugins {
-
enum {
MAX_CREATE_FUNCS = 64
};
@@ -278,7 +277,6 @@ public:
}
static void add_create_func(EditorPluginCreateFunc p_func) {
-
ERR_FAIL_COND(creation_func_count >= MAX_CREATE_FUNCS);
creation_funcs[creation_func_count++] = p_func;
}
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 62a76786ae..b5f1133a9e 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -39,7 +39,6 @@
#include "scene/gui/margin_container.h"
void EditorPluginSettings::_notification(int p_what) {
-
if (p_what == NOTIFICATION_WM_FOCUS_IN) {
update_plugins();
} else if (p_what == Node::NOTIFICATION_READY) {
@@ -49,7 +48,6 @@ void EditorPluginSettings::_notification(int p_what) {
}
void EditorPluginSettings::update_plugins() {
-
plugin_list->clear();
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
@@ -70,12 +68,10 @@ void EditorPluginSettings::update_plugins() {
Vector<String> plugins;
while (d != String()) {
-
bool dir = da->current_is_dir();
String path = "res://addons/" + d + "/plugin.cfg";
if (dir && FileAccess::exists(path)) {
-
plugins.push_back(d);
}
@@ -88,7 +84,6 @@ void EditorPluginSettings::update_plugins() {
plugins.sort();
for (int i = 0; i < plugins.size(); i++) {
-
Ref<ConfigFile> cf;
cf.instance();
String path = "res://addons/" + plugins[i] + "/plugin.cfg";
@@ -151,9 +146,9 @@ void EditorPluginSettings::update_plugins() {
}
void EditorPluginSettings::_plugin_activity_changed() {
-
- if (updating)
+ if (updating) {
return;
+ }
TreeItem *ti = plugin_list->get_edited();
ERR_FAIL_COND(!ti);
@@ -178,8 +173,9 @@ void EditorPluginSettings::_create_clicked() {
void EditorPluginSettings::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
TreeItem *item = Object::cast_to<TreeItem>(p_item);
- if (!item)
+ if (!item) {
return;
+ }
if (p_id == BUTTON_PLUGIN_EDIT) {
if (p_column == 4) {
String dir = item->get_metadata(0);
@@ -193,7 +189,6 @@ void EditorPluginSettings::_bind_methods() {
}
EditorPluginSettings::EditorPluginSettings() {
-
plugin_config_dialog = memnew(PluginConfigDialog);
plugin_config_dialog->config("");
add_child(plugin_config_dialog);
diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h
index 63a8395805..ceb00eb12f 100644
--- a/editor/editor_plugin_settings.h
+++ b/editor/editor_plugin_settings.h
@@ -38,7 +38,6 @@
#include "scene/gui/dialogs.h"
class EditorPluginSettings : public VBoxContainer {
-
GDCLASS(EditorPluginSettings, VBoxContainer);
enum {
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index c5772e0ea7..74267452e6 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -51,8 +51,9 @@ EditorPropertyNil::EditorPropertyNil() {
///////////////////// TEXT /////////////////////////
void EditorPropertyText::_text_entered(const String &p_string) {
- if (updating)
+ if (updating) {
return;
+ }
if (text->has_focus()) {
text->release_focus();
@@ -61,8 +62,9 @@ void EditorPropertyText::_text_entered(const String &p_string) {
}
void EditorPropertyText::_text_changed(const String &p_string) {
- if (updating)
+ if (updating) {
return;
+ }
if (string_name) {
emit_changed(get_edited_property(), StringName(p_string), "", true);
@@ -82,6 +84,7 @@ void EditorPropertyText::update_property() {
void EditorPropertyText::set_string_name(bool p_enabled) {
string_name = p_enabled;
}
+
void EditorPropertyText::set_placeholder(const String &p_string) {
text->set_placeholder(p_string);
}
@@ -112,7 +115,6 @@ void EditorPropertyMultilineText::_text_changed() {
}
void EditorPropertyMultilineText::_open_big_text() {
-
if (!big_text_dialog) {
big_text = memnew(TextEdit);
big_text->connect("text_changed", callable_mp(this, &EditorPropertyMultilineText::_big_text_changed));
@@ -172,9 +174,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() {
///////////////////// TEXT ENUM /////////////////////////
void EditorPropertyTextEnum::_option_selected(int p_which) {
-
if (string_name) {
-
emit_changed(get_edited_property(), StringName(options->get_item_text(p_which)));
} else {
emit_changed(get_edited_property(), options->get_item_text(p_which));
@@ -182,7 +182,6 @@ void EditorPropertyTextEnum::_option_selected(int p_which) {
}
void EditorPropertyTextEnum::update_property() {
-
String which = get_edited_object()->get(get_edited_property());
for (int i = 0; i < options->get_item_count(); i++) {
String t = options->get_item_text(i);
@@ -213,15 +212,15 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
add_focusable(options);
options->connect("item_selected", callable_mp(this, &EditorPropertyTextEnum::_option_selected));
}
+
///////////////////// PATH /////////////////////////
void EditorPropertyPath::_path_selected(const String &p_path) {
-
emit_changed(get_edited_property(), p_path);
update_property();
}
-void EditorPropertyPath::_path_pressed() {
+void EditorPropertyPath::_path_pressed() {
if (!dialog) {
dialog = memnew(EditorFileDialog);
dialog->connect("file_selected", callable_mp(this, &EditorPropertyPath::_path_selected));
@@ -257,33 +256,28 @@ void EditorPropertyPath::_path_pressed() {
}
void EditorPropertyPath::update_property() {
-
String full_path = get_edited_object()->get(get_edited_property());
path->set_text(full_path);
path->set_tooltip(full_path);
}
void EditorPropertyPath::setup(const Vector<String> &p_extensions, bool p_folder, bool p_global) {
-
extensions = p_extensions;
folder = p_folder;
global = p_global;
}
void EditorPropertyPath::set_save_mode() {
-
save_mode = true;
}
void EditorPropertyPath::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
path_edit->set_icon(get_theme_icon("Folder", "EditorIcons"));
}
}
void EditorPropertyPath::_path_focus_exited() {
-
_path_selected(path->get_text());
}
@@ -313,7 +307,6 @@ EditorPropertyPath::EditorPropertyPath() {
///////////////////// CLASS NAME /////////////////////////
void EditorPropertyClassName::setup(const String &p_base_type, const String &p_selected_type) {
-
base_type = p_base_type;
dialog->set_base_type(base_type);
selected_type = p_selected_type;
@@ -321,7 +314,6 @@ void EditorPropertyClassName::setup(const String &p_base_type, const String &p_s
}
void EditorPropertyClassName::update_property() {
-
String s = get_edited_object()->get(get_edited_property());
property->set_text(s);
selected_type = s;
@@ -356,13 +348,11 @@ EditorPropertyClassName::EditorPropertyClassName() {
///////////////////// MEMBER /////////////////////////
void EditorPropertyMember::_property_selected(const String &p_selected) {
-
emit_changed(get_edited_property(), p_selected);
update_property();
}
void EditorPropertyMember::_property_select() {
-
if (!selector) {
selector = memnew(PropertySelector);
selector->connect("selected", callable_mp(this, &EditorPropertyMember::_property_selected));
@@ -372,60 +362,57 @@ void EditorPropertyMember::_property_select() {
String current = get_edited_object()->get(get_edited_property());
if (hint == MEMBER_METHOD_OF_VARIANT_TYPE) {
-
Variant::Type type = Variant::NIL;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (hint_text == Variant::get_type_name(Variant::Type(i))) {
type = Variant::Type(i);
}
}
- if (type != Variant::NIL)
+ if (type != Variant::NIL) {
selector->select_method_from_basic_type(type, current);
+ }
} else if (hint == MEMBER_METHOD_OF_BASE_TYPE) {
-
selector->select_method_from_base_type(hint_text, current);
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
-
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
- if (instance)
+ if (instance) {
selector->select_method_from_instance(instance, current);
+ }
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
-
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
} else if (hint == MEMBER_PROPERTY_OF_VARIANT_TYPE) {
-
Variant::Type type = Variant::NIL;
String tname = hint_text;
- if (tname.find(".") != -1)
+ if (tname.find(".") != -1) {
tname = tname.get_slice(".", 0);
+ }
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (tname == Variant::get_type_name(Variant::Type(i))) {
type = Variant::Type(Variant::Type(i));
}
}
- if (type != Variant::NIL)
+ if (type != Variant::NIL) {
selector->select_property_from_basic_type(type, current);
+ }
} else if (hint == MEMBER_PROPERTY_OF_BASE_TYPE) {
-
selector->select_property_from_base_type(hint_text, current);
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
-
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
- if (instance)
+ if (instance) {
selector->select_property_from_instance(instance, current);
+ }
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
-
Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
@@ -439,7 +426,6 @@ void EditorPropertyMember::setup(Type p_hint, const String &p_hint_text) {
}
void EditorPropertyMember::update_property() {
-
String full_path = get_edited_object()->get(get_edited_property());
property->set_text(full_path);
}
@@ -458,7 +444,6 @@ EditorPropertyMember::EditorPropertyMember() {
///////////////////// CHECK /////////////////////////
void EditorPropertyCheck::_checkbox_pressed() {
-
emit_changed(get_edited_property(), checkbox->is_pressed());
}
@@ -482,13 +467,11 @@ EditorPropertyCheck::EditorPropertyCheck() {
///////////////////// ENUM /////////////////////////
void EditorPropertyEnum::_option_selected(int p_which) {
-
int64_t val = options->get_item_metadata(p_which);
emit_changed(get_edited_property(), val);
}
void EditorPropertyEnum::update_property() {
-
int64_t which = get_edited_object()->get(get_edited_property());
for (int i = 0; i < options->get_item_count(); i++) {
@@ -500,12 +483,12 @@ void EditorPropertyEnum::update_property() {
}
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
-
int64_t current_val = 0;
for (int i = 0; i < p_options.size(); i++) {
Vector<String> text_split = p_options[i].split(":");
- if (text_split.size() != 1)
+ if (text_split.size() != 1) {
current_val = text_split[1].to_int64();
+ }
options->add_item(text_split[0]);
options->set_item_metadata(i, current_val);
current_val += 1;
@@ -531,7 +514,6 @@ EditorPropertyEnum::EditorPropertyEnum() {
///////////////////// FLAGS /////////////////////////
void EditorPropertyFlags::_flag_toggled() {
-
uint32_t value = 0;
for (int i = 0; i < flags.size(); i++) {
if (flags[i]->is_pressed()) {
@@ -545,14 +527,12 @@ void EditorPropertyFlags::_flag_toggled() {
}
void EditorPropertyFlags::update_property() {
-
uint32_t value = get_edited_object()->get(get_edited_property());
for (int i = 0; i < flags.size(); i++) {
uint32_t val = 1;
val <<= flag_indices[i];
if (value & val) {
-
flags[i]->set_pressed(true);
} else {
flags[i]->set_pressed(false);
@@ -587,7 +567,6 @@ void EditorPropertyFlags::_bind_methods() {
}
EditorPropertyFlags::EditorPropertyFlags() {
-
vbox = memnew(VBoxContainer);
add_child(vbox);
}
@@ -602,6 +581,7 @@ public:
Vector<Rect2> flag_rects;
Vector<String> names;
Vector<String> tooltips;
+ int hovered_index;
virtual Size2 get_minimum_size() const {
Ref<Font> font = get_theme_font("font", "Label");
@@ -617,57 +597,79 @@ public:
return String();
}
void _gui_input(const Ref<InputEvent> &p_ev) {
- Ref<InputEventMouseButton> mb = p_ev;
- if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ const Ref<InputEventMouseMotion> mm = p_ev;
+
+ if (mm.is_valid()) {
for (int i = 0; i < flag_rects.size(); i++) {
- if (flag_rects[i].has_point(mb->get_position())) {
- //toggle
- if (value & (1 << i)) {
- value &= ~(1 << i);
- } else {
- value |= (1 << i);
- }
- emit_signal("flag_changed", value);
+ if (flag_rects[i].has_point(mm->get_position())) {
+ // Used to highlight the hovered flag in the layers grid.
+ hovered_index = i;
update();
+ break;
}
}
}
- }
-
- void _notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
-
- Rect2 rect;
- rect.size = get_size();
- flag_rects.clear();
-
- int bsize = (rect.size.height * 80 / 100) / 2;
-
- int h = bsize * 2 + 1;
- int vofs = (rect.size.height - h) / 2;
- Color color = get_theme_color("highlight_color", "Editor");
- for (int i = 0; i < 2; i++) {
+ const Ref<InputEventMouseButton> mb = p_ev;
- Point2 ofs(4, vofs);
- if (i == 1)
- ofs.y += bsize + 1;
+ if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ // Toggle the flag.
+ // We base our choice on the hovered flag, so that it always matches the hovered flag.
+ if (value & (1 << hovered_index)) {
+ value &= ~(1 << hovered_index);
+ } else {
+ value |= (1 << hovered_index);
+ }
- ofs += rect.position;
- for (int j = 0; j < 10; j++) {
+ emit_signal("flag_changed", value);
+ update();
+ }
+ }
- Point2 o = ofs + Point2(j * (bsize + 1), 0);
- if (j >= 5)
- o.x += 1;
+ void _notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+ Rect2 rect;
+ rect.size = get_size();
+ flag_rects.clear();
+
+ const int bsize = (rect.size.height * 80 / 100) / 2;
+ const int h = bsize * 2 + 1;
+ const int vofs = (rect.size.height - h) / 2;
+
+ Color color = get_theme_color("highlight_color", "Editor");
+ for (int i = 0; i < 2; i++) {
+ Point2 ofs(4, vofs);
+ if (i == 1)
+ ofs.y += bsize + 1;
+
+ ofs += rect.position;
+ for (int j = 0; j < 10; j++) {
+ Point2 o = ofs + Point2(j * (bsize + 1), 0);
+ if (j >= 5)
+ o.x += 1;
+
+ const int idx = i * 10 + j;
+ const bool on = value & (1 << idx);
+ Rect2 rect2 = Rect2(o, Size2(bsize, bsize));
+
+ color.a = on ? 0.6 : 0.2;
+ if (idx == hovered_index) {
+ // Add visual feedback when hovering a flag.
+ color.a += 0.15;
+ }
- uint32_t idx = i * 10 + j;
- bool on = value & (1 << idx);
- Rect2 rect2 = Rect2(o, Size2(bsize, bsize));
- color.a = on ? 0.6 : 0.2;
- draw_rect(rect2, color);
- flag_rects.push_back(rect2);
+ draw_rect(rect2, color);
+ flag_rects.push_back(rect2);
+ }
}
- }
+ } break;
+ case NOTIFICATION_MOUSE_EXIT: {
+ hovered_index = -1;
+ update();
+ } break;
+ default:
+ break;
}
}
@@ -677,29 +679,26 @@ public:
}
static void _bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &EditorPropertyLayersGrid::_gui_input);
ADD_SIGNAL(MethodInfo("flag_changed", PropertyInfo(Variant::INT, "flag")));
}
EditorPropertyLayersGrid() {
value = 0;
+ hovered_index = -1; // Nothing is hovered.
}
};
void EditorPropertyLayers::_grid_changed(uint32_t p_grid) {
-
emit_changed(get_edited_property(), p_grid);
}
void EditorPropertyLayers::update_property() {
-
uint32_t value = get_edited_object()->get(get_edited_property());
grid->set_flag(value);
}
void EditorPropertyLayers::setup(LayerType p_layer_type) {
-
String basename;
switch (p_layer_type) {
case LAYER_RENDER_2D:
@@ -738,7 +737,6 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) {
}
void EditorPropertyLayers::_button_pressed() {
-
layers->clear();
for (int i = 0; i < 20; i++) {
if (i == 5 || i == 10 || i == 15) {
@@ -771,7 +769,6 @@ void EditorPropertyLayers::_bind_methods() {
}
EditorPropertyLayers::EditorPropertyLayers() {
-
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
grid = memnew(EditorPropertyLayersGrid);
@@ -780,7 +777,7 @@ EditorPropertyLayers::EditorPropertyLayers() {
hb->add_child(grid);
button = memnew(Button);
button->set_toggle_mode(true);
- button->set_text("..");
+ button->set_text("...");
button->connect("pressed", callable_mp(this, &EditorPropertyLayers::_button_pressed));
hb->add_child(button);
set_bottom_editor(hb);
@@ -794,8 +791,9 @@ EditorPropertyLayers::EditorPropertyLayers() {
///////////////////// INT /////////////////////////
void EditorPropertyInteger::_value_changed(int64_t val) {
- if (setting)
+ if (setting) {
return;
+ }
emit_changed(get_edited_property(), val);
}
@@ -835,14 +833,14 @@ EditorPropertyInteger::EditorPropertyInteger() {
///////////////////// OBJECT ID /////////////////////////
void EditorPropertyObjectID::_edit_pressed() {
-
emit_signal("object_id_selected", get_edited_property(), get_edited_object()->get(get_edited_property()));
}
void EditorPropertyObjectID::update_property() {
String type = base_type;
- if (type == "")
+ if (type == "") {
type = "Object";
+ }
ObjectID id = get_edited_object()->get(get_edited_property());
if (id.is_valid()) {
@@ -873,8 +871,9 @@ EditorPropertyObjectID::EditorPropertyObjectID() {
///////////////////// FLOAT /////////////////////////
void EditorPropertyFloat::_value_changed(double val) {
- if (setting)
+ if (setting) {
return;
+ }
emit_changed(get_edited_property(), val);
}
@@ -890,7 +889,6 @@ void EditorPropertyFloat::_bind_methods() {
}
void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser) {
-
spin->set_min(p_min);
spin->set_max(p_max);
spin->set_step(p_step);
@@ -912,7 +910,6 @@ EditorPropertyFloat::EditorPropertyFloat() {
///////////////////// EASING /////////////////////////
void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
-
const Ref<InputEventMouseButton> mb = p_ev;
if (mb.is_valid()) {
if (mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
@@ -938,17 +935,19 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
const Ref<InputEventMouseMotion> mm = p_ev;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
float rel = mm->get_relative().x;
- if (rel == 0)
+ if (rel == 0) {
return;
+ }
- if (flip)
+ if (flip) {
rel = -rel;
+ }
float val = get_edited_object()->get(get_edited_property());
- if (val == 0)
+ if (val == 0) {
return;
+ }
bool sg = val < 0;
val = Math::absf(val);
@@ -957,8 +956,9 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
val += rel * 0.05;
val = Math::pow(2.0f, val);
- if (sg)
+ if (sg) {
val = -val;
+ }
emit_changed(get_edited_property(), val);
easing_draw->update();
@@ -966,7 +966,6 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
}
void EditorPropertyEasing::_draw_easing() {
-
RID ci = easing_draw->get_canvas_item();
Size2 s = easing_draw->get_size();
@@ -987,7 +986,6 @@ void EditorPropertyEasing::_draw_easing() {
Vector<Point2> lines;
for (int i = 1; i <= points; i++) {
-
float ifl = i / float(points);
float iflp = (i - 1) / float(points);
@@ -1027,8 +1025,9 @@ void EditorPropertyEasing::_setup_spin() {
}
void EditorPropertyEasing::_spin_value_changed(double p_value) {
- if (setting)
+ if (setting) {
return;
+ }
// 0 is a singularity, but both positive and negative values
// are otherwise allowed. Enforce 0+ as workaround.
@@ -1047,13 +1046,11 @@ void EditorPropertyEasing::_spin_focus_exited() {
}
void EditorPropertyEasing::setup(bool p_full, bool p_flip) {
-
flip = p_flip;
full = p_full;
}
void EditorPropertyEasing::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
@@ -1075,7 +1072,6 @@ void EditorPropertyEasing::_bind_methods() {
}
EditorPropertyEasing::EditorPropertyEasing() {
-
easing_draw = memnew(Control);
easing_draw->connect("draw", callable_mp(this, &EditorPropertyEasing::_draw_easing));
easing_draw->connect("gui_input", callable_mp(this, &EditorPropertyEasing::_drag_easing));
@@ -1107,8 +1103,9 @@ EditorPropertyEasing::EditorPropertyEasing() {
///////////////////// VECTOR2 /////////////////////////
void EditorPropertyVector2::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Vector2 v2;
v2.x = spin[0]->get_value();
@@ -1128,7 +1125,6 @@ void EditorPropertyVector2::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 2; i++) {
-
Color c = base;
c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
@@ -1189,8 +1185,9 @@ EditorPropertyVector2::EditorPropertyVector2(bool p_force_wide) {
///////////////////// RECT2 /////////////////////////
void EditorPropertyRect2::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Rect2 r2;
r2.position.x = spin[0]->get_value();
@@ -1209,17 +1206,18 @@ void EditorPropertyRect2::update_property() {
spin[3]->set_value(val.size.y);
setting = false;
}
+
void EditorPropertyRect2::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 4; i++) {
-
Color c = base;
c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyRect2::_bind_methods() {
}
@@ -1235,7 +1233,6 @@ void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool
}
EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) {
-
bool horizontal = !p_force_wide && bool(EDITOR_GET("interface/inspector/horizontal_vector_types_editing"));
BoxContainer *bc;
@@ -1274,8 +1271,9 @@ EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) {
///////////////////// VECTOR3 /////////////////////////
void EditorPropertyVector3::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Vector3 v3;
v3.x = spin[0]->get_value();
@@ -1285,24 +1283,36 @@ void EditorPropertyVector3::_value_changed(double val, const String &p_name) {
}
void EditorPropertyVector3::update_property() {
- Vector3 val = get_edited_object()->get(get_edited_property());
+ update_using_vector(get_edited_object()->get(get_edited_property()));
+}
+
+void EditorPropertyVector3::update_using_vector(Vector3 p_vector) {
setting = true;
- spin[0]->set_value(val.x);
- spin[1]->set_value(val.y);
- spin[2]->set_value(val.z);
+ spin[0]->set_value(p_vector.x);
+ spin[1]->set_value(p_vector.y);
+ spin[2]->set_value(p_vector.z);
setting = false;
}
+
+Vector3 EditorPropertyVector3::get_vector() {
+ Vector3 v3;
+ v3.x = spin[0]->get_value();
+ v3.y = spin[1]->get_value();
+ v3.z = spin[2]->get_value();
+ return v3;
+}
+
void EditorPropertyVector3::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
-
Color c = base;
c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyVector3::_bind_methods() {
}
@@ -1356,8 +1366,9 @@ EditorPropertyVector3::EditorPropertyVector3(bool p_force_wide) {
///////////////////// VECTOR2i /////////////////////////
void EditorPropertyVector2i::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Vector2i v2;
v2.x = spin[0]->get_value();
@@ -1377,7 +1388,6 @@ void EditorPropertyVector2i::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 2; i++) {
-
Color c = base;
c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
@@ -1435,11 +1445,12 @@ EditorPropertyVector2i::EditorPropertyVector2i(bool p_force_wide) {
setting = false;
}
-///////////////////// RECT2 /////////////////////////
+///////////////////// RECT2i /////////////////////////
void EditorPropertyRect2i::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Rect2i r2;
r2.position.x = spin[0]->get_value();
@@ -1458,17 +1469,18 @@ void EditorPropertyRect2i::update_property() {
spin[3]->set_value(val.size.y);
setting = false;
}
+
void EditorPropertyRect2i::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 4; i++) {
-
Color c = base;
c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyRect2i::_bind_methods() {
}
@@ -1484,7 +1496,6 @@ void EditorPropertyRect2i::setup(int p_min, int p_max, bool p_no_slider) {
}
EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) {
-
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
BoxContainer *bc;
@@ -1520,11 +1531,12 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) {
setting = false;
}
-///////////////////// VECTOR3 /////////////////////////
+///////////////////// VECTOR3i /////////////////////////
void EditorPropertyVector3i::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Vector3i v3;
v3.x = spin[0]->get_value();
@@ -1541,17 +1553,18 @@ void EditorPropertyVector3i::update_property() {
spin[2]->set_value(val.z);
setting = false;
}
+
void EditorPropertyVector3i::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
-
Color c = base;
c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyVector3i::_bind_methods() {
}
@@ -1604,8 +1617,9 @@ EditorPropertyVector3i::EditorPropertyVector3i(bool p_force_wide) {
///////////////////// PLANE /////////////////////////
void EditorPropertyPlane::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Plane p;
p.normal.x = spin[0]->get_value();
@@ -1624,17 +1638,18 @@ void EditorPropertyPlane::update_property() {
spin[3]->set_value(val.d);
setting = false;
}
+
void EditorPropertyPlane::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
-
Color c = base;
c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyPlane::_bind_methods() {
}
@@ -1650,7 +1665,6 @@ void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool
}
EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) {
-
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
BoxContainer *bc;
@@ -1689,8 +1703,9 @@ EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) {
///////////////////// QUAT /////////////////////////
void EditorPropertyQuat::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Quat p;
p.x = spin[0]->get_value();
@@ -1709,17 +1724,18 @@ void EditorPropertyQuat::update_property() {
spin[3]->set_value(val.w);
setting = false;
}
+
void EditorPropertyQuat::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 3; i++) {
-
Color c = base;
c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyQuat::_bind_methods() {
}
@@ -1770,8 +1786,9 @@ EditorPropertyQuat::EditorPropertyQuat() {
///////////////////// AABB /////////////////////////
void EditorPropertyAABB::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
AABB p;
p.position.x = spin[0]->get_value();
@@ -1796,17 +1813,18 @@ void EditorPropertyAABB::update_property() {
setting = false;
}
+
void EditorPropertyAABB::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 6; i++) {
-
Color c = base;
c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyAABB::_bind_methods() {
}
@@ -1844,8 +1862,9 @@ EditorPropertyAABB::EditorPropertyAABB() {
///////////////////// TRANSFORM2D /////////////////////////
void EditorPropertyTransform2D::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Transform2D p;
p[0][0] = spin[0]->get_value();
@@ -1870,17 +1889,18 @@ void EditorPropertyTransform2D::update_property() {
setting = false;
}
+
void EditorPropertyTransform2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 6; i++) {
-
Color c = base;
c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyTransform2D::_bind_methods() {
}
@@ -1917,8 +1937,9 @@ EditorPropertyTransform2D::EditorPropertyTransform2D() {
///////////////////// BASIS /////////////////////////
void EditorPropertyBasis::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Basis p;
p[0][0] = spin[0]->get_value();
@@ -1949,17 +1970,18 @@ void EditorPropertyBasis::update_property() {
setting = false;
}
+
void EditorPropertyBasis::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 9; i++) {
-
Color c = base;
c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyBasis::_bind_methods() {
}
@@ -1996,8 +2018,9 @@ EditorPropertyBasis::EditorPropertyBasis() {
///////////////////// TRANSFORM /////////////////////////
void EditorPropertyTransform::_value_changed(double val, const String &p_name) {
- if (setting)
+ if (setting) {
return;
+ }
Transform p;
p.basis[0][0] = spin[0]->get_value();
@@ -2017,34 +2040,37 @@ void EditorPropertyTransform::_value_changed(double val, const String &p_name) {
}
void EditorPropertyTransform::update_property() {
- Transform val = get_edited_object()->get(get_edited_property());
- setting = true;
- spin[0]->set_value(val.basis[0][0]);
- spin[1]->set_value(val.basis[1][0]);
- spin[2]->set_value(val.basis[2][0]);
- spin[3]->set_value(val.basis[0][1]);
- spin[4]->set_value(val.basis[1][1]);
- spin[5]->set_value(val.basis[2][1]);
- spin[6]->set_value(val.basis[0][2]);
- spin[7]->set_value(val.basis[1][2]);
- spin[8]->set_value(val.basis[2][2]);
- spin[9]->set_value(val.origin[0]);
- spin[10]->set_value(val.origin[1]);
- spin[11]->set_value(val.origin[2]);
+ update_using_transform(get_edited_object()->get(get_edited_property()));
+}
+void EditorPropertyTransform::update_using_transform(Transform p_transform) {
+ setting = true;
+ spin[0]->set_value(p_transform.basis[0][0]);
+ spin[1]->set_value(p_transform.basis[1][0]);
+ spin[2]->set_value(p_transform.basis[2][0]);
+ spin[3]->set_value(p_transform.basis[0][1]);
+ spin[4]->set_value(p_transform.basis[1][1]);
+ spin[5]->set_value(p_transform.basis[2][1]);
+ spin[6]->set_value(p_transform.basis[0][2]);
+ spin[7]->set_value(p_transform.basis[1][2]);
+ spin[8]->set_value(p_transform.basis[2][2]);
+ spin[9]->set_value(p_transform.origin[0]);
+ spin[10]->set_value(p_transform.origin[1]);
+ spin[11]->set_value(p_transform.origin[2]);
setting = false;
}
+
void EditorPropertyTransform::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Color base = get_theme_color("accent_color", "Editor");
for (int i = 0; i < 12; i++) {
-
Color c = base;
c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
spin[i]->set_custom_label_color(true, c);
}
}
}
+
void EditorPropertyTransform::_bind_methods() {
}
@@ -2081,29 +2107,27 @@ EditorPropertyTransform::EditorPropertyTransform() {
////////////// COLOR PICKER //////////////////////
void EditorPropertyColor::_color_changed(const Color &p_color) {
-
emit_changed(get_edited_property(), p_color, "", true);
}
void EditorPropertyColor::_popup_closed() {
-
emit_changed(get_edited_property(), picker->get_pick_color(), "", false);
}
void EditorPropertyColor::_picker_created() {
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
- if (default_color_mode == 1)
+ if (default_color_mode == 1) {
picker->get_picker()->set_hsv_mode(true);
- else if (default_color_mode == 2)
+ } else if (default_color_mode == 2) {
picker->get_picker()->set_raw_mode(true);
+ }
}
void EditorPropertyColor::_bind_methods() {
}
void EditorPropertyColor::update_property() {
-
picker->set_pick_color(get_edited_object()->get(get_edited_property()));
const Color color = picker->get_pick_color();
@@ -2129,7 +2153,6 @@ void EditorPropertyColor::setup(bool p_show_alpha) {
}
EditorPropertyColor::EditorPropertyColor() {
-
picker = memnew(ColorPickerButton);
add_child(picker);
picker->set_flat(true);
@@ -2141,7 +2164,6 @@ EditorPropertyColor::EditorPropertyColor() {
////////////// NODE PATH //////////////////////
void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
-
NodePath path = p_path;
Node *base_node = nullptr;
@@ -2188,13 +2210,11 @@ void EditorPropertyNodePath::_node_assign() {
}
void EditorPropertyNodePath::_node_clear() {
-
emit_changed(get_edited_property(), NodePath());
update_property();
}
void EditorPropertyNodePath::update_property() {
-
NodePath p = get_edited_object()->get(get_edited_property());
assign->set_tooltip(p);
@@ -2235,14 +2255,12 @@ void EditorPropertyNodePath::update_property() {
}
void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root) {
-
base_hint = p_base_hint;
valid_types = p_valid_types;
use_path_from_scene_root = p_use_path_from_scene_root;
}
void EditorPropertyNodePath::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons");
clear->set_icon(t);
@@ -2253,7 +2271,6 @@ void EditorPropertyNodePath::_bind_methods() {
}
EditorPropertyNodePath::EditorPropertyNodePath() {
-
HBoxContainer *hbc = memnew(HBoxContainer);
add_child(hbc);
assign = memnew(Button);
@@ -2292,7 +2309,6 @@ EditorPropertyRID::EditorPropertyRID() {
////////////// RESOURCE //////////////////////
void EditorPropertyResource::_file_selected(const String &p_path) {
-
RES res = ResourceLoader::load(p_path);
ERR_FAIL_COND_MSG(res.is_null(), "Cannot load resource from path '" + p_path + "'.");
@@ -2316,8 +2332,9 @@ void EditorPropertyResource::_file_selected(const String &p_path) {
}
}
- if (!any_type_matches)
+ if (!any_type_matches) {
EditorNode::get_singleton()->show_warning(vformat(TTR("The selected resource (%s) does not match any type expected for this property (%s)."), res->get_class(), property_types));
+ }
}
emit_changed(get_edited_property(), res);
@@ -2325,11 +2342,9 @@ void EditorPropertyResource::_file_selected(const String &p_path) {
}
void EditorPropertyResource::_menu_option(int p_which) {
-
// scene_tree->popup_centered_ratio();
switch (p_which) {
case OBJ_MENU_LOAD: {
-
if (!file) {
file = memnew(EditorFileDialog);
file->connect("file_selected", callable_mp(this, &EditorPropertyResource::_file_selected));
@@ -2340,7 +2355,6 @@ void EditorPropertyResource::_menu_option(int p_which) {
List<String> extensions;
for (int i = 0; i < type.get_slice_count(","); i++) {
-
ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions);
}
@@ -2351,7 +2365,6 @@ void EditorPropertyResource::_menu_option(int p_which) {
file->clear_filters();
for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
-
file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
@@ -2359,37 +2372,32 @@ void EditorPropertyResource::_menu_option(int p_which) {
} break;
case OBJ_MENU_EDIT: {
-
RES res = get_edited_object()->get(get_edited_property());
if (!res.is_null()) {
-
emit_signal("resource_selected", get_edited_property(), res);
}
} break;
case OBJ_MENU_CLEAR: {
-
emit_changed(get_edited_property(), RES());
update_property();
} break;
case OBJ_MENU_MAKE_UNIQUE: {
-
RES res_orig = get_edited_object()->get(get_edited_property());
- if (res_orig.is_null())
+ if (res_orig.is_null()) {
return;
+ }
List<PropertyInfo> property_list;
res_orig->get_property_list(&property_list);
List<Pair<String, Variant>> propvalues;
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
-
Pair<String, Variant> p;
PropertyInfo &pi = E->get();
if (pi.usage & PROPERTY_USAGE_STORAGE) {
-
p.first = pi.name;
p.second = res_orig->get(pi.name);
}
@@ -2406,7 +2414,6 @@ void EditorPropertyResource::_menu_option(int p_which) {
ERR_FAIL_COND(res.is_null());
for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) {
-
Pair<String, Variant> &p = E->get();
res->set(p.first, p.second);
}
@@ -2418,8 +2425,9 @@ void EditorPropertyResource::_menu_option(int p_which) {
case OBJ_MENU_SAVE: {
RES res = get_edited_object()->get(get_edited_property());
- if (res.is_null())
+ if (res.is_null()) {
return;
+ }
EditorNode::get_singleton()->save_resource(res);
} break;
@@ -2430,21 +2438,18 @@ void EditorPropertyResource::_menu_option(int p_which) {
} break;
case OBJ_MENU_PASTE: {
-
RES res = EditorSettings::get_singleton()->get_resource_clipboard();
emit_changed(get_edited_property(), res);
update_property();
} break;
case OBJ_MENU_NEW_SCRIPT: {
-
if (Object::cast_to<Node>(get_edited_object())) {
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), false);
}
} break;
case OBJ_MENU_EXTEND_SCRIPT: {
-
if (Object::cast_to<Node>(get_edited_object())) {
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), true);
}
@@ -2460,11 +2465,9 @@ void EditorPropertyResource::_menu_option(int p_which) {
tab_container->set_current_tab(file_system_dock->get_index());
} break;
default: {
-
RES res = get_edited_object()->get(get_edited_property());
if (p_which >= CONVERT_BASE_ID) {
-
int to_type = p_which - CONVERT_BASE_ID;
Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res);
@@ -2482,7 +2485,6 @@ void EditorPropertyResource::_menu_option(int p_which) {
String intype = inheritors_array[p_which - TYPE_BASE_ID];
if (intype == "ViewportTexture") {
-
Resource *r = Object::cast_to<Resource>(get_edited_object());
if (r && r->get_path().is_resource_file()) {
EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on resources saved as a file.\nResource needs to belong to a scene."));
@@ -2544,7 +2546,6 @@ void EditorPropertyResource::_menu_option(int p_which) {
}
void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj) {
-
RES p = get_edited_object()->get(get_edited_property());
if (p.is_valid() && p->get_instance_id() == p_obj) {
String type = p->get_class_name();
@@ -2572,7 +2573,6 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T
}
void EditorPropertyResource::_update_menu_items() {
-
//////////////////// UPDATE MENU //////////////////////////
RES res = get_edited_object()->get(get_edited_property());
@@ -2592,7 +2592,6 @@ void EditorPropertyResource::_update_menu_items() {
}
for (int i = 0; i < base_type.get_slice_count(","); i++) {
-
String base = base_type.get_slice(",", i);
Set<String> valid_inheritors;
@@ -2629,20 +2628,23 @@ void EditorPropertyResource::_update_menu_items() {
for (int j = 0; j < custom_resources.size(); j++) {
if (custom_resources[j].name == t) {
is_custom_resource = true;
- if (custom_resources[j].icon.is_valid())
+ if (custom_resources[j].icon.is_valid()) {
icon = custom_resources[j].icon;
+ }
break;
}
}
}
- if (!is_custom_resource && !(ScriptServer::is_global_class(t) || ClassDB::can_instance(t)))
+ if (!is_custom_resource && !(ScriptServer::is_global_class(t) || ClassDB::can_instance(t))) {
continue;
+ }
inheritors_array.push_back(t);
- if (!icon.is_valid())
+ if (!icon.is_valid()) {
icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons");
+ }
int id = TYPE_BASE_ID + idx;
menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
@@ -2651,14 +2653,14 @@ void EditorPropertyResource::_update_menu_items() {
}
}
- if (menu->get_item_count())
+ if (menu->get_item_count()) {
menu->add_separator();
+ }
}
menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD);
if (!res.is_null()) {
-
menu->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT);
menu->add_icon_item(get_theme_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR);
menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
@@ -2673,32 +2675,31 @@ void EditorPropertyResource::_update_menu_items() {
RES cb = EditorSettings::get_singleton()->get_resource_clipboard();
bool paste_valid = false;
if (cb.is_valid()) {
- if (base_type == "")
+ if (base_type == "") {
paste_valid = true;
- else
- for (int i = 0; i < base_type.get_slice_count(","); i++)
+ } else {
+ for (int i = 0; i < base_type.get_slice_count(","); i++) {
if (ClassDB::is_parent_class(cb->get_class(), base_type.get_slice(",", i))) {
paste_valid = true;
break;
}
+ }
+ }
}
if (!res.is_null() || paste_valid) {
menu->add_separator();
if (!res.is_null()) {
-
menu->add_item(TTR("Copy"), OBJ_MENU_COPY);
}
if (paste_valid) {
-
menu->add_item(TTR("Paste"), OBJ_MENU_PASTE);
}
}
if (!res.is_null()) {
-
Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res);
if (conversions.size()) {
menu->add_separator();
@@ -2707,10 +2708,8 @@ void EditorPropertyResource::_update_menu_items() {
String what = conversions[i]->converts_to();
Ref<Texture2D> icon;
if (has_theme_icon(what, "EditorIcons")) {
-
icon = get_theme_icon(what, "EditorIcons");
} else {
-
icon = get_theme_icon(what, "Resource");
}
@@ -2720,7 +2719,6 @@ void EditorPropertyResource::_update_menu_items() {
}
void EditorPropertyResource::_update_menu() {
-
_update_menu_items();
Rect2 gt = edit->get_screen_rect();
@@ -2732,17 +2730,14 @@ void EditorPropertyResource::_update_menu() {
}
void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) {
-
emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value, false);
}
void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) {
-
emit_signal("resource_selected", String(get_edited_property()) + ":" + p_property, p_resource);
}
void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) {
-
emit_signal("object_id_selected", get_edited_property(), p_id);
}
@@ -2768,15 +2763,15 @@ void EditorPropertyResource::_open_editor_pressed() {
}
void EditorPropertyResource::_fold_other_editors(Object *p_self) {
-
if (this == p_self) {
return;
}
RES res = get_edited_object()->get(get_edited_property());
- if (!res.is_valid())
+ if (!res.is_valid()) {
return;
+ }
bool use_editor = false;
for (int i = 0; i < EditorNode::get_editor_data().get_editor_plugin_count(); i++) {
EditorPlugin *ep = EditorNode::get_editor_data().get_editor_plugin(i);
@@ -2785,8 +2780,9 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) {
}
}
- if (!use_editor)
+ if (!use_editor) {
return;
+ }
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
opened_editor = false;
@@ -2800,17 +2796,14 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) {
}
void EditorPropertyResource::update_property() {
-
RES res = get_edited_object()->get(get_edited_property());
if (use_sub_inspector) {
-
if (res.is_valid() != assign->is_toggle_mode()) {
assign->set_toggle_mode(res.is_valid());
}
if (res.is_valid() && get_edited_object()->editor_is_section_unfolded(get_edited_property())) {
-
if (!sub_inspector) {
sub_inspector = memnew(EditorInspector);
sub_inspector->set_enable_v_scroll(false);
@@ -2876,7 +2869,6 @@ void EditorPropertyResource::update_property() {
assign->set_icon(Ref<Texture2D>());
assign->set_text(TTR("[empty]"));
} else {
-
assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Object"));
if (res->get_name() != String()) {
@@ -2907,12 +2899,10 @@ void EditorPropertyResource::_resource_selected() {
}
if (use_sub_inspector) {
-
bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property());
get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold);
update_property();
} else {
-
emit_signal("resource_selected", get_edited_property(), res);
}
}
@@ -2922,14 +2912,12 @@ void EditorPropertyResource::setup(const String &p_base_type) {
}
void EditorPropertyResource::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Texture2D> t = get_theme_icon("select_arrow", "Tree");
edit->set_icon(t);
}
if (p_what == NOTIFICATION_DRAG_BEGIN) {
-
if (is_visible_in_tree()) {
if (_is_drop_valid(get_viewport()->gui_get_drag_data())) {
dropping = true;
@@ -2947,7 +2935,6 @@ void EditorPropertyResource::_notification(int p_what) {
}
void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
-
Node *to_node = get_node(p_path);
if (!Object::cast_to<Viewport>(to_node)) {
EditorNode::get_singleton()->show_warning(TTR("Selected node is not a Viewport!"));
@@ -2970,14 +2957,12 @@ void EditorPropertyResource::collapse_all_folding() {
}
void EditorPropertyResource::expand_all_folding() {
-
if (sub_inspector) {
sub_inspector->expand_all_folding();
}
}
void EditorPropertyResource::_button_draw() {
-
if (dropping) {
Color color = get_theme_color("accent_color", "Editor");
assign->draw_rect(Rect2(Point2(), assign->get_size()), color, false);
@@ -2985,10 +2970,8 @@ void EditorPropertyResource::_button_draw() {
}
Variant EditorPropertyResource::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
RES res = get_edited_object()->get(get_edited_property());
if (res.is_valid()) {
-
return EditorNode::get_singleton()->drag_resource(res, p_from);
}
@@ -2996,7 +2979,6 @@ Variant EditorPropertyResource::get_drag_data_fw(const Point2 &p_point, Control
}
bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const {
-
String allowed_type = base_type;
Dictionary drag_data = p_drag_data;
@@ -3011,7 +2993,6 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const
}
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
-
Vector<String> files = drag_data["files"];
if (files.size() == 1) {
@@ -3019,7 +3000,6 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
if (ftype != "") {
-
for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
String at = allowed_type.get_slice(",", i).strip_edges();
if (ClassDB::is_parent_class(ftype, at)) {
@@ -3034,11 +3014,10 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const
}
bool EditorPropertyResource::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
return _is_drop_valid(p_data);
}
-void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
ERR_FAIL_COND(!_is_drop_valid(p_data));
Dictionary drag_data = p_data;
@@ -3052,7 +3031,6 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &
}
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
-
Vector<String> files = drag_data["files"];
if (files.size() == 1) {
@@ -3072,7 +3050,6 @@ void EditorPropertyResource::set_use_sub_inspector(bool p_enable) {
}
void EditorPropertyResource::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_resource_preview"), &EditorPropertyResource::_resource_preview);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &EditorPropertyResource::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &EditorPropertyResource::can_drop_data_fw);
@@ -3082,7 +3059,6 @@ void EditorPropertyResource::_bind_methods() {
}
EditorPropertyResource::EditorPropertyResource() {
-
opened_editor = false;
sub_inspector = nullptr;
sub_inspector_vbox = nullptr;
@@ -3139,11 +3115,9 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) {
}
bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
-
float default_float_step = EDITOR_GET("interface/inspector/default_float_step");
switch (p_type) {
-
// atomic types
case Variant::NIL: {
EditorPropertyNil *editor = memnew(EditorPropertyNil);
@@ -3154,7 +3128,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
add_property_editor(p_path, editor);
} break;
case Variant::INT: {
-
if (p_hint == PROPERTY_HINT_ENUM) {
EditorPropertyEnum *editor = memnew(EditorPropertyEnum);
Vector<String> options = p_hint_text.split(",");
@@ -3168,7 +3141,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
add_property_editor(p_path, editor);
} else if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_2D_RENDER || p_hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
-
EditorPropertyLayers::LayerType lt = EditorPropertyLayers::LAYER_RENDER_2D;
switch (p_hint) {
case PROPERTY_HINT_LAYERS_2D_RENDER:
@@ -3190,7 +3162,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
editor->setup(lt);
add_property_editor(p_path, editor);
} else if (p_hint == PROPERTY_HINT_OBJECT_ID) {
-
EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID);
editor->setup(p_hint_text);
add_property_editor(p_path, editor);
@@ -3227,7 +3198,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
} break;
case Variant::FLOAT: {
-
if (p_hint == PROPERTY_HINT_EXP_EASING) {
EditorPropertyEasing *editor = memnew(EditorPropertyEasing);
bool full = true;
@@ -3280,7 +3250,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
} break;
case Variant::STRING: {
-
if (p_hint == PROPERTY_HINT_ENUM) {
EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum);
Vector<String> options = p_hint_text.split(",");
@@ -3294,7 +3263,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
editor->setup("Object", p_hint_text);
add_property_editor(p_path, editor);
} else if (p_hint == PROPERTY_HINT_DIR || p_hint == PROPERTY_HINT_FILE || p_hint == PROPERTY_HINT_SAVE_FILE || p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE) {
-
Vector<String> extensions = p_hint_text.split(",");
bool global = p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE;
bool folder = p_hint == PROPERTY_HINT_DIR || p_hint == PROPERTY_HINT_GLOBAL_DIR;
@@ -3313,7 +3281,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
p_hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE ||
p_hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE ||
p_hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
-
EditorPropertyMember *editor = memnew(EditorPropertyMember);
EditorPropertyMember::Type type = EditorPropertyMember::MEMBER_METHOD_OF_BASE_TYPE;
@@ -3346,7 +3313,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
add_property_editor(p_path, editor);
} else {
-
EditorPropertyText *editor = memnew(EditorPropertyText);
if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) {
editor->set_placeholder(p_hint_text);
@@ -3567,7 +3533,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
add_property_editor(p_path, editor);
} break;
case Variant::STRING_NAME: {
-
if (p_hint == PROPERTY_HINT_ENUM) {
EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum);
Vector<String> options = p_hint_text.split(",");
@@ -3583,7 +3548,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
}
} break;
case Variant::NODE_PATH: {
-
EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath);
if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) {
editor->setup(p_hint_text, Vector<StringName>(), (p_usage & PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT));
@@ -3611,7 +3575,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
for (int j = 0; j < p_hint_text.get_slice_count(","); j++) {
String inherits = p_hint_text.get_slicec(',', j);
if (ClassDB::is_parent_class(inherits, type)) {
-
editor->set_use_sub_inspector(false);
}
}
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 61c11f4534..35e6c10d90 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -392,6 +392,8 @@ protected:
public:
virtual void update_property();
+ virtual void update_using_vector(Vector3 p_vector);
+ virtual Vector3 get_vector();
void setup(double p_min, double p_max, double p_step, bool p_no_slider);
EditorPropertyVector3(bool p_force_wide = false);
};
@@ -536,6 +538,7 @@ protected:
public:
virtual void update_property();
+ virtual void update_using_transform(Transform p_transform);
void setup(double p_min, double p_max, double p_step, bool p_no_slider);
EditorPropertyTransform();
};
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 49cffb015f..51fac6acec 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -35,7 +35,6 @@
#include "editor_properties.h"
bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) {
-
String pn = p_name;
if (pn.begins_with("indices")) {
@@ -48,11 +47,9 @@ bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_
}
bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) const {
-
String pn = p_name;
if (pn.begins_with("indices")) {
-
int idx = pn.get_slicec('/', 1).to_int();
bool valid;
r_ret = array.get(idx, &valid);
@@ -80,17 +77,14 @@ EditorPropertyArrayObject::EditorPropertyArrayObject() {
///////////////////
bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Variant &p_value) {
-
String pn = p_name;
if (pn == "new_item_key") {
-
new_item_key = p_value;
return true;
}
if (pn == "new_item_value") {
-
new_item_value = p_value;
return true;
}
@@ -106,23 +100,19 @@ bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Varian
}
bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const {
-
String pn = p_name;
if (pn == "new_item_key") {
-
r_ret = new_item_key;
return true;
}
if (pn == "new_item_value") {
-
r_ret = new_item_value;
return true;
}
if (pn.begins_with("indices")) {
-
int idx = pn.get_slicec('/', 1).to_int();
Variant key = dict.get_key_at_index(idx);
r_ret = dict[key];
@@ -166,7 +156,6 @@ EditorPropertyDictionaryObject::EditorPropertyDictionaryObject() {
///////////////////// ARRAY ///////////////////////////
void EditorPropertyArray::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) {
-
if (p_property.begins_with("indices")) {
int idx = p_property.get_slice("/", 1).to_int();
Variant array = object->get_array();
@@ -181,7 +170,6 @@ void EditorPropertyArray::_property_changed(const String &p_property, Variant p_
}
void EditorPropertyArray::_change_type(Object *p_button, int p_index) {
-
Button *button = Object::cast_to<Button>(p_button);
changing_type_idx = p_index;
Rect2 rect = button->get_screen_rect();
@@ -191,7 +179,6 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) {
}
void EditorPropertyArray::_change_type_menu(int p_index) {
-
if (p_index == Variant::VARIANT_MAX) {
_remove_pressed(changing_type_idx);
return;
@@ -218,7 +205,6 @@ void EditorPropertyArray::_object_id_selected(const StringName &p_property, Obje
}
void EditorPropertyArray::update_property() {
-
Variant array = get_edited_object()->get(get_edited_property());
String arrtype = "";
@@ -278,11 +264,9 @@ void EditorPropertyArray::update_property() {
}
if (unfolded) {
-
updating = true;
if (!vbox) {
-
vbox = memnew(VBoxContainer);
add_child(vbox);
set_bottom_editor(vbox);
@@ -371,13 +355,11 @@ void EditorPropertyArray::update_property() {
bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL;
if (is_untyped_array) {
-
Button *edit = memnew(Button);
edit->set_icon(get_theme_icon("Edit", "EditorIcons"));
hb->add_child(edit);
edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type), varray(edit, i + offset));
} else {
-
Button *remove = memnew(Button);
remove->set_icon(get_theme_icon("Remove", "EditorIcons"));
remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset));
@@ -399,7 +381,6 @@ void EditorPropertyArray::update_property() {
}
void EditorPropertyArray::_remove_pressed(int p_index) {
-
Variant array = object->get_array();
array.call("remove", p_index);
@@ -425,7 +406,6 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
Dictionary drag_data = p_drag_data;
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
-
Vector<String> files = drag_data["files"];
for (int i = 0; i < files.size(); i++) {
@@ -449,7 +429,6 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
}
bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
return _is_drop_valid(p_data);
}
@@ -459,7 +438,6 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d
Dictionary drag_data = p_data;
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
-
Vector<String> files = drag_data["files"];
Variant array = object->get_array();
@@ -493,7 +471,6 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d
void EditorPropertyArray::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAG_BEGIN) {
-
if (is_visible_in_tree()) {
if (_is_drop_valid(get_viewport()->gui_get_drag_data())) {
dropping = true;
@@ -511,7 +488,6 @@ void EditorPropertyArray::_notification(int p_what) {
}
void EditorPropertyArray::_edit_pressed() {
-
Variant array = get_edited_object()->get(get_edited_property());
if (!array.is_array()) {
Callable::CallError ce;
@@ -525,15 +501,17 @@ void EditorPropertyArray::_edit_pressed() {
}
void EditorPropertyArray::_page_changed(double p_page) {
- if (updating)
+ if (updating) {
return;
+ }
page_idx = p_page;
update_property();
}
void EditorPropertyArray::_length_changed(double p_page) {
- if (updating)
+ if (updating) {
return;
+ }
Variant array = object->get_array();
int previous_size = array.call("size");
@@ -566,7 +544,6 @@ void EditorPropertyArray::_length_changed(double p_page) {
}
void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint_string) {
-
array_type = p_array_type;
if (array_type == Variant::ARRAY && !p_hint_string.empty()) {
@@ -591,7 +568,6 @@ void EditorPropertyArray::_bind_methods() {
}
EditorPropertyArray::EditorPropertyArray() {
-
object.instance();
page_idx = 0;
page_len = 10;
@@ -631,12 +607,9 @@ EditorPropertyArray::EditorPropertyArray() {
///////////////////// DICTIONARY ///////////////////////////
void EditorPropertyDictionary::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) {
-
if (p_property == "new_item_key") {
-
object->set_new_item_key(p_value);
} else if (p_property == "new_item_value") {
-
object->set_new_item_value(p_value);
} else if (p_property.begins_with("indices")) {
int idx = p_property.get_slice("/", 1).to_int();
@@ -652,7 +625,6 @@ void EditorPropertyDictionary::_property_changed(const String &p_property, Varia
}
void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) {
-
Button *button = Object::cast_to<Button>(p_button);
Rect2 rect = button->get_screen_rect();
@@ -663,7 +635,6 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) {
}
void EditorPropertyDictionary::_add_key_value() {
-
// Do not allow nil as valid key. I experienced errors with this
if (object->get_new_item_key().get_type() == Variant::NIL) {
return;
@@ -683,7 +654,6 @@ void EditorPropertyDictionary::_add_key_value() {
}
void EditorPropertyDictionary::_change_type_menu(int p_index) {
-
if (changing_type_idx < 0) {
Variant value;
Callable::CallError ce;
@@ -700,7 +670,6 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) {
Dictionary dict = object->get_dict();
if (p_index < Variant::VARIANT_MAX) {
-
Variant value;
Callable::CallError ce;
value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce);
@@ -719,7 +688,6 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) {
}
void EditorPropertyDictionary::update_property() {
-
Variant updated_val = get_edited_object()->get(get_edited_property());
if (updated_val.get_type() == Variant::NIL) {
@@ -743,11 +711,9 @@ void EditorPropertyDictionary::update_property() {
}
if (unfolded) {
-
updating = true;
if (!vbox) {
-
vbox = memnew(VBoxContainer);
add_child(vbox);
set_bottom_editor(vbox);
@@ -814,7 +780,6 @@ void EditorPropertyDictionary::update_property() {
// atomic types
case Variant::BOOL: {
-
prop = memnew(EditorPropertyCheck);
} break;
@@ -825,83 +790,71 @@ void EditorPropertyDictionary::update_property() {
} break;
case Variant::FLOAT: {
-
EditorPropertyFloat *editor = memnew(EditorPropertyFloat);
editor->setup(-100000, 100000, 0.001, true, false, true, true);
prop = editor;
} break;
case Variant::STRING: {
-
prop = memnew(EditorPropertyText);
} break;
// math types
case Variant::VECTOR2: {
-
EditorPropertyVector2 *editor = memnew(EditorPropertyVector2);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
} break;
case Variant::VECTOR2I: {
-
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i);
editor->setup(-100000, 100000, true);
prop = editor;
} break;
case Variant::RECT2: {
-
EditorPropertyRect2 *editor = memnew(EditorPropertyRect2);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
} break;
case Variant::RECT2I: {
-
EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i);
editor->setup(-100000, 100000, true);
prop = editor;
} break;
case Variant::VECTOR3: {
-
EditorPropertyVector3 *editor = memnew(EditorPropertyVector3);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
} break;
case Variant::VECTOR3I: {
-
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i);
editor->setup(-100000, 100000, true);
prop = editor;
} break;
case Variant::TRANSFORM2D: {
-
EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
} break;
case Variant::PLANE: {
-
EditorPropertyPlane *editor = memnew(EditorPropertyPlane);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
} break;
case Variant::QUAT: {
-
EditorPropertyQuat *editor = memnew(EditorPropertyQuat);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
} break;
case Variant::AABB: {
-
EditorPropertyAABB *editor = memnew(EditorPropertyAABB);
editor->setup(-100000, 100000, 0.001, true);
prop = editor;
@@ -940,15 +893,12 @@ void EditorPropertyDictionary::update_property() {
} break;
case Variant::OBJECT: {
-
if (Object::cast_to<EncodedObjectAsID>(value)) {
-
EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID);
editor->setup("Object");
prop = editor;
} else {
-
EditorPropertyResource *editor = memnew(EditorPropertyResource);
editor->setup("Resource");
prop = editor;
@@ -967,55 +917,46 @@ void EditorPropertyDictionary::update_property() {
// arrays
case Variant::PACKED_BYTE_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_BYTE_ARRAY);
prop = editor;
} break;
case Variant::PACKED_INT32_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_INT32_ARRAY);
prop = editor;
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_FLOAT32_ARRAY);
prop = editor;
} break;
case Variant::PACKED_INT64_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_INT64_ARRAY);
prop = editor;
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_FLOAT64_ARRAY);
prop = editor;
} break;
case Variant::PACKED_STRING_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_STRING_ARRAY);
prop = editor;
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_VECTOR2_ARRAY);
prop = editor;
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_VECTOR3_ARRAY);
prop = editor;
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
EditorPropertyArray *editor = memnew(EditorPropertyArray);
editor->setup(Variant::PACKED_COLOR_ARRAY);
prop = editor;
@@ -1100,7 +1041,6 @@ void EditorPropertyDictionary::_notification(int p_what) {
}
void EditorPropertyDictionary::_edit_pressed() {
-
Variant prop_val = get_edited_object()->get(get_edited_property());
if (prop_val.get_type() == Variant::NIL) {
Callable::CallError ce;
@@ -1113,8 +1053,9 @@ void EditorPropertyDictionary::_edit_pressed() {
}
void EditorPropertyDictionary::_page_changed(double p_page) {
- if (updating)
+ if (updating) {
return;
+ }
page_idx = p_page;
update_property();
}
@@ -1123,7 +1064,6 @@ void EditorPropertyDictionary::_bind_methods() {
}
EditorPropertyDictionary::EditorPropertyDictionary() {
-
object.instance();
page_idx = 0;
page_len = 10;
diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h
index d6f3c976f9..7eed9b4fa7 100644
--- a/editor/editor_properties_array_dict.h
+++ b/editor/editor_properties_array_dict.h
@@ -37,7 +37,6 @@
#include "scene/gui/button.h"
class EditorPropertyArrayObject : public Reference {
-
GDCLASS(EditorPropertyArrayObject, Reference);
Variant array;
@@ -54,7 +53,6 @@ public:
};
class EditorPropertyDictionaryObject : public Reference {
-
GDCLASS(EditorPropertyDictionaryObject, Reference);
Variant new_item_key;
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 2a4300f833..7ac8fae156 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -42,7 +42,6 @@
#include "editor_settings.h"
bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
-
if (get_script_instance() && get_script_instance()->has_method("handles")) {
return get_script_instance()->call("handles", p_type);
}
@@ -50,7 +49,6 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
}
Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const {
-
if (get_script_instance() && get_script_instance()->has_method("generate")) {
return get_script_instance()->call("generate", p_from, p_size);
}
@@ -58,19 +56,18 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const
}
Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const {
-
if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) {
return get_script_instance()->call("generate_from_path", p_path, p_size);
}
RES res = ResourceLoader::load(p_path);
- if (!res.is_valid())
+ if (!res.is_valid()) {
return res;
+ }
return generate(res, p_size);
}
bool EditorResourcePreviewGenerator::generate_small_preview_automatically() const {
-
if (get_script_instance() && get_script_instance()->has_method("generate_small_preview_automatically")) {
return get_script_instance()->call("generate_small_preview_automatically");
}
@@ -79,7 +76,6 @@ bool EditorResourcePreviewGenerator::generate_small_preview_automatically() cons
}
bool EditorResourcePreviewGenerator::can_generate_small_preview() const {
-
if (get_script_instance() && get_script_instance()->has_method("can_generate_small_preview")) {
return get_script_instance()->call("can_generate_small_preview");
}
@@ -88,7 +84,6 @@ bool EditorResourcePreviewGenerator::can_generate_small_preview() const {
}
void EditorResourcePreviewGenerator::_bind_methods() {
-
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::STRING, "type")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size")));
@@ -102,13 +97,11 @@ EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() {
EditorResourcePreview *EditorResourcePreview::singleton = nullptr;
void EditorResourcePreview::_thread_func(void *ud) {
-
EditorResourcePreview *erp = (EditorResourcePreview *)ud;
erp->_thread();
}
void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) {
-
String path = p_str;
{
MutexLock lock(preview_mutex);
@@ -139,10 +132,11 @@ void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Textur
void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<ImageTexture> &r_small_texture, const QueueItem &p_item, const String &cache_base) {
String type;
- if (p_item.resource.is_valid())
+ if (p_item.resource.is_valid()) {
type = p_item.resource->get_class();
- else
+ } else {
type = ResourceLoader::get_resource_type(p_item.path);
+ }
if (type == "") {
r_texture = Ref<ImageTexture>();
@@ -157,8 +151,9 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
r_small_texture = Ref<ImageTexture>();
for (int i = 0; i < preview_generators.size(); i++) {
- if (!preview_generators[i]->handles(type))
+ if (!preview_generators[i]->handles(type)) {
continue;
+ }
Ref<Texture2D> generated;
if (p_item.resource.is_valid()) {
@@ -214,15 +209,12 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
}
void EditorResourcePreview::_thread() {
-
exited = false;
while (!exit) {
-
preview_sem.wait();
preview_mutex.lock();
if (queue.size()) {
-
QueueItem item = queue.front()->get();
queue.pop_front();
@@ -237,7 +229,6 @@ void EditorResourcePreview::_thread() {
preview_mutex.unlock();
} else {
-
preview_mutex.unlock();
Ref<ImageTexture> texture;
@@ -247,14 +238,12 @@ void EditorResourcePreview::_thread() {
thumbnail_size *= EDSCALE;
if (item.resource.is_valid()) {
-
_generate_preview(texture, small_texture, item, String());
//adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred
_preview_ready(item.path + ":" + itos(item.resource->hash_edited_version()), texture, small_texture, item.id, item.function, item.userdata);
} else {
-
String temp_path = EditorSettings::get_singleton()->get_cache_dir();
String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text();
cache_base = temp_path.plus_file("resthumb-" + cache_base);
@@ -264,11 +253,9 @@ void EditorResourcePreview::_thread() {
String file = cache_base + ".txt";
FileAccess *f = FileAccess::open(file, FileAccess::READ);
if (!f) {
-
// No cache found, generate
_generate_preview(texture, small_texture, item, cache_base);
} else {
-
uint64_t modtime = FileAccess::get_modified_time(item.path);
int tsize = f->get_line().to_int64();
bool has_small_texture = f->get_line().to_int();
@@ -277,17 +264,14 @@ void EditorResourcePreview::_thread() {
bool cache_valid = true;
if (tsize != thumbnail_size) {
-
cache_valid = false;
memdelete(f);
} else if (last_modtime != modtime) {
-
String last_md5 = f->get_line();
String md5 = FileAccess::get_md5(item.path);
memdelete(f);
if (last_md5 != md5) {
-
cache_valid = false;
} else {
@@ -311,7 +295,6 @@ void EditorResourcePreview::_thread() {
}
if (cache_valid) {
-
Ref<Image> img;
img.instance();
Ref<Image> small_img;
@@ -320,7 +303,6 @@ void EditorResourcePreview::_thread() {
if (img->load(cache_base + ".png") != OK) {
cache_valid = false;
} else {
-
texture.instance();
texture->create_from_image(img);
@@ -336,7 +318,6 @@ void EditorResourcePreview::_thread() {
}
if (!cache_valid) {
-
_generate_preview(texture, small_texture, item, cache_base);
}
}
@@ -352,7 +333,6 @@ void EditorResourcePreview::_thread() {
}
void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
-
ERR_FAIL_NULL(p_receiver);
ERR_FAIL_COND(!p_res.is_valid());
@@ -362,7 +342,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p
String path_id = "ID:" + itos(p_res->get_instance_id());
if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version()) {
-
cache[path_id].order = order++;
p_receiver->call(p_receiver_func, path_id, cache[path_id].preview, cache[path_id].small_preview, p_userdata);
return;
@@ -383,7 +362,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p
}
void EditorResourcePreview::queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
-
ERR_FAIL_NULL(p_receiver);
{
MutexLock lock(preview_mutex);
@@ -406,22 +384,18 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object
}
void EditorResourcePreview::add_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) {
-
preview_generators.push_back(p_generator);
}
void EditorResourcePreview::remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) {
-
preview_generators.erase(p_generator);
}
EditorResourcePreview *EditorResourcePreview::get_singleton() {
-
return singleton;
}
void EditorResourcePreview::_bind_methods() {
-
ClassDB::bind_method("_preview_ready", &EditorResourcePreview::_preview_ready);
ClassDB::bind_method(D_METHOD("queue_resource_preview", "path", "receiver", "receiver_func", "userdata"), &EditorResourcePreview::queue_resource_preview);
@@ -434,13 +408,11 @@ void EditorResourcePreview::_bind_methods() {
}
void EditorResourcePreview::check_for_invalidation(const String &p_path) {
-
bool call_invalidated = false;
{
MutexLock lock(preview_mutex);
if (cache.has(p_path)) {
-
uint64_t modified_time = FileAccess::get_modified_time(p_path);
if (modified_time != cache[p_path].modified_time) {
cache.erase(p_path);
@@ -482,6 +454,5 @@ EditorResourcePreview::EditorResourcePreview() {
}
EditorResourcePreview::~EditorResourcePreview() {
-
stop();
}
diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h
index dc5a3b9c93..2f4bc65de9 100644
--- a/editor/editor_resource_preview.h
+++ b/editor/editor_resource_preview.h
@@ -37,7 +37,6 @@
#include "scene/resources/texture.h"
class EditorResourcePreviewGenerator : public Reference {
-
GDCLASS(EditorResourcePreviewGenerator, Reference);
protected:
@@ -55,7 +54,6 @@ public:
};
class EditorResourcePreview : public Node {
-
GDCLASS(EditorResourcePreview, Node);
static EditorResourcePreview *singleton;
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index 01156d9809..1148a6c7ec 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -35,12 +35,10 @@
#include "servers/display_server.h"
EditorRun::Status EditorRun::get_status() const {
-
return status;
}
Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints) {
-
List<String> args;
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
@@ -106,7 +104,6 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
test_size.x = ProjectSettings::get_singleton()->get("display/window/size/test_width");
test_size.y = ProjectSettings::get_singleton()->get("display/window/size/test_height");
if (test_size.x > 0 && test_size.y > 0) {
-
desired_size = test_size;
}
@@ -155,14 +152,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
}
if (p_breakpoints.size()) {
-
args.push_back("--breakpoints");
String bpoints;
for (const List<String>::Element *E = p_breakpoints.front(); E; E = E->next()) {
-
bpoints += E->get().replace(" ", "%20");
- if (E->next())
+ if (E->next()) {
bpoints += ",";
+ }
}
args.push_back(bpoints);
@@ -187,7 +183,6 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
printf("Running: %ls", exec.c_str());
for (List<String>::Element *E = args.front(); E; E = E->next()) {
-
printf(" %ls", E->get().c_str());
};
printf("\n");
@@ -207,8 +202,9 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
bool EditorRun::has_child_process(OS::ProcessID p_pid) const {
for (const List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) {
- if (E->get() == p_pid)
+ if (E->get() == p_pid) {
return true;
+ }
}
return false;
}
@@ -221,9 +217,7 @@ void EditorRun::stop_child_process(OS::ProcessID p_pid) {
}
void EditorRun::stop() {
-
if (status != STATUS_STOP && pids.size() > 0) {
-
for (List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) {
OS::get_singleton()->kill(E->get());
}
@@ -233,6 +227,5 @@ void EditorRun::stop() {
}
EditorRun::EditorRun() {
-
status = STATUS_STOP;
}
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index d4450acea2..9a834977fd 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -35,21 +35,18 @@
#include "editor_scale.h"
void EditorRunNative::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
-
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i);
- if (eep.is_null())
+ if (eep.is_null()) {
continue;
+ }
Ref<ImageTexture> icon = eep->get_run_icon();
if (!icon.is_null()) {
Ref<Image> im = icon->get_data();
im = im->duplicate();
im->clear_mipmaps();
if (!im->empty()) {
-
im->resize(16 * EDSCALE, 16 * EDSCALE);
Ref<ImageTexture> small_icon;
small_icon.instance();
@@ -66,13 +63,10 @@ void EditorRunNative::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
-
bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;
if (changed) {
-
for (Map<int, MenuButton *>::Element *E = menus.front(); E; E = E->next()) {
-
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key());
MenuButton *mb = E->get();
int dc = eep->get_options_count();
@@ -98,7 +92,6 @@ void EditorRunNative::_notification(int p_what) {
}
void EditorRunNative::_run_native(int p_idx, int p_platform) {
-
if (!EditorNode::get_singleton()->ensure_main_scene(true)) {
resume_idx = p_idx;
resume_platform = p_platform;
@@ -120,7 +113,6 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
Ref<EditorExportPreset> preset;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
-
Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
if (ep->is_runnable() && ep->get_platform() == eep) {
preset = ep;
@@ -142,14 +134,18 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
bool debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
bool debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false);
- if (deploy_debug_remote)
+ if (deploy_debug_remote) {
flags |= EditorExportPlatform::DEBUG_FLAG_REMOTE_DEBUG;
- if (deploy_dumb)
+ }
+ if (deploy_dumb) {
flags |= EditorExportPlatform::DEBUG_FLAG_DUMB_CLIENT;
- if (debug_collisions)
+ }
+ if (debug_collisions) {
flags |= EditorExportPlatform::DEBUG_FLAG_VIEW_COLLISONS;
- if (debug_navigation)
+ }
+ if (debug_navigation) {
flags |= EditorExportPlatform::DEBUG_FLAG_VIEW_NAVIGATION;
+ }
eep->run(preset, p_idx, flags);
}
@@ -159,12 +155,10 @@ void EditorRunNative::resume_run_native() {
}
void EditorRunNative::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("native_run", PropertyInfo(Variant::OBJECT, "preset", PROPERTY_HINT_RESOURCE_TYPE, "EditorExportPreset")));
}
bool EditorRunNative::is_deploy_debug_remote_enabled() const {
-
return EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false);
}
diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h
index 5f2236b88c..df6714cb53 100644
--- a/editor/editor_run_native.h
+++ b/editor/editor_run_native.h
@@ -35,7 +35,6 @@
#include "scene/gui/menu_button.h"
class EditorRunNative : public HBoxContainer {
-
GDCLASS(EditorRunNative, HBoxContainer);
Map<int, MenuButton *> menus;
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index c03fd4f6f5..e2446e92be 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -33,7 +33,6 @@
#include "editor_node.h"
void EditorScript::add_root_node(Node *p_node) {
-
if (!editor) {
EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("Write your logic in the _run() method."));
return;
@@ -48,12 +47,10 @@ void EditorScript::add_root_node(Node *p_node) {
}
EditorInterface *EditorScript::get_editor_interface() {
-
return EditorInterface::get_singleton();
}
Node *EditorScript::get_scene() {
-
if (!editor) {
EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method."));
return nullptr;
@@ -63,7 +60,6 @@ Node *EditorScript::get_scene() {
}
void EditorScript::_run() {
-
Ref<Script> s = get_script();
ERR_FAIL_COND(!s.is_valid());
if (!get_script_instance()) {
@@ -75,18 +71,15 @@ void EditorScript::_run() {
ce.error = Callable::CallError::CALL_OK;
get_script_instance()->call("_run", nullptr, 0, ce);
if (ce.error != Callable::CallError::CALL_OK) {
-
EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?"));
}
}
void EditorScript::set_editor(EditorNode *p_editor) {
-
editor = p_editor;
}
void EditorScript::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
@@ -94,6 +87,5 @@ void EditorScript::_bind_methods() {
}
EditorScript::EditorScript() {
-
editor = nullptr;
}
diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h
index edf75b9e73..261e2a7e41 100644
--- a/editor/editor_run_script.h
+++ b/editor/editor_run_script.h
@@ -35,7 +35,6 @@
#include "editor_plugin.h"
class EditorNode;
class EditorScript : public Reference {
-
GDCLASS(EditorScript, Reference);
EditorNode *editor;
diff --git a/editor/editor_scale.cpp b/editor/editor_scale.cpp
index 358241cbcc..450de75328 100644
--- a/editor/editor_scale.cpp
+++ b/editor/editor_scale.cpp
@@ -35,10 +35,9 @@
static float scale = 1.0;
void editor_set_scale(float p_scale) {
-
scale = p_scale;
}
-float editor_get_scale() {
+float editor_get_scale() {
return scale;
}
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index bccc38ca1b..eabbf6b0d8 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -29,9 +29,10 @@
/*************************************************************************/
#include "editor_sectioned_inspector.h"
+
#include "editor_scale.h"
-class SectionedInspectorFilter : public Object {
+class SectionedInspectorFilter : public Object {
GDCLASS(SectionedInspectorFilter, Object);
Object *edited;
@@ -39,9 +40,9 @@ class SectionedInspectorFilter : public Object {
bool allow_sub;
bool _set(const StringName &p_name, const Variant &p_value) {
-
- if (!edited)
+ if (!edited) {
return false;
+ }
String name = p_name;
if (section != "") {
@@ -54,9 +55,9 @@ class SectionedInspectorFilter : public Object {
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
- if (!edited)
+ if (!edited) {
return false;
+ }
String name = p_name;
if (section != "") {
@@ -69,19 +70,19 @@ class SectionedInspectorFilter : public Object {
return valid;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
- if (!edited)
+ if (!edited) {
return;
+ }
List<PropertyInfo> pinfo;
edited->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
PropertyInfo pi = E->get();
int sp = pi.name.find("/");
- if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/") || pi.name.begins_with("_global_script")) //skip resource stuff
+ if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/") || pi.name.begins_with("_global_script")) { //skip resource stuff
continue;
+ }
if (sp == -1) {
pi.name = "global/" + pi.name;
@@ -89,33 +90,30 @@ class SectionedInspectorFilter : public Object {
if (pi.name.begins_with(section + "/")) {
pi.name = pi.name.replace_first(section + "/", "");
- if (!allow_sub && pi.name.find("/") != -1)
+ if (!allow_sub && pi.name.find("/") != -1) {
continue;
+ }
p_list->push_back(pi);
}
}
}
bool property_can_revert(const String &p_name) {
-
return edited->call("property_can_revert", section + "/" + p_name);
}
Variant property_get_revert(const String &p_name) {
-
return edited->call("property_get_revert", section + "/" + p_name);
}
protected:
static void _bind_methods() {
-
ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert);
ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert);
}
public:
void set_section(const String &p_section, bool p_allow_sub) {
-
section = p_section;
allow_sub = p_allow_sub;
_change_notify();
@@ -132,14 +130,13 @@ public:
};
void SectionedInspector::_bind_methods() {
-
ClassDB::bind_method("update_category_list", &SectionedInspector::update_category_list);
}
void SectionedInspector::_section_selected() {
-
- if (!sections->get_selected())
+ if (!sections->get_selected()) {
return;
+ }
selected_category = sections->get_selected()->get_metadata(0);
filter->set_section(selected_category, sections->get_selected()->get_children() == nullptr);
@@ -147,32 +144,30 @@ void SectionedInspector::_section_selected() {
}
void SectionedInspector::set_current_section(const String &p_section) {
-
if (section_map.has(p_section)) {
section_map[p_section]->select(0);
}
}
String SectionedInspector::get_current_section() const {
-
- if (sections->get_selected())
+ if (sections->get_selected()) {
return sections->get_selected()->get_metadata(0);
- else
+ } else {
return "";
+ }
}
String SectionedInspector::get_full_item_path(const String &p_item) {
-
String base = get_current_section();
- if (base != "")
+ if (base != "") {
return base + "/" + p_item;
- else
+ } else {
return p_item;
+ }
}
void SectionedInspector::edit(Object *p_object) {
-
if (!p_object) {
obj = ObjectID();
sections->clear();
@@ -188,7 +183,6 @@ void SectionedInspector::edit(Object *p_object) {
inspector->set_object_class(p_object->get_class());
if (obj != id) {
-
obj = id;
update_category_list();
@@ -197,26 +191,26 @@ void SectionedInspector::edit(Object *p_object) {
TreeItem *first_item = sections->get_root();
if (first_item) {
- while (first_item->get_children())
+ while (first_item->get_children()) {
first_item = first_item->get_children();
+ }
first_item->select(0);
selected_category = first_item->get_metadata(0);
}
} else {
-
update_category_list();
}
}
void SectionedInspector::update_category_list() {
-
sections->clear();
Object *o = ObjectDB::get_instance(obj);
- if (!o)
+ if (!o) {
return;
+ }
List<PropertyInfo> pinfo;
o->get_property_list(&pinfo);
@@ -227,27 +221,31 @@ void SectionedInspector::update_category_list() {
section_map[""] = root;
String filter;
- if (search_box)
+ if (search_box) {
filter = search_box->get_text();
+ }
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
PropertyInfo pi = E->get();
- if (pi.usage & PROPERTY_USAGE_CATEGORY)
+ if (pi.usage & PROPERTY_USAGE_CATEGORY) {
continue;
- else if (!(pi.usage & PROPERTY_USAGE_EDITOR))
+ } else if (!(pi.usage & PROPERTY_USAGE_EDITOR)) {
continue;
+ }
- if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene" || pi.name.begins_with("_global_script"))
+ if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene" || pi.name.begins_with("_global_script")) {
continue;
+ }
- if (!filter.empty() && !filter.is_subsequence_ofi(pi.name) && !filter.is_subsequence_ofi(pi.name.replace("/", " ").capitalize()))
+ if (!filter.empty() && !filter.is_subsequence_ofi(pi.name) && !filter.is_subsequence_ofi(pi.name.replace("/", " ").capitalize())) {
continue;
+ }
int sp = pi.name.find("/");
- if (sp == -1)
+ if (sp == -1) {
pi.name = "global/" + pi.name;
+ }
Vector<String> sectionarr = pi.name.split("/");
String metasection;
@@ -255,7 +253,6 @@ void SectionedInspector::update_category_list() {
int sc = MIN(2, sectionarr.size() - 1);
for (int i = 0; i < sc; i++) {
-
TreeItem *parent = section_map[metasection];
parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
@@ -288,27 +285,23 @@ void SectionedInspector::update_category_list() {
}
void SectionedInspector::register_search_box(LineEdit *p_box) {
-
search_box = p_box;
inspector->register_text_enter(p_box);
search_box->connect("text_changed", callable_mp(this, &SectionedInspector::_search_changed));
}
void SectionedInspector::_search_changed(const String &p_what) {
-
update_category_list();
}
EditorInspector *SectionedInspector::get_inspector() {
-
return inspector;
}
SectionedInspector::SectionedInspector() :
sections(memnew(Tree)),
filter(memnew(SectionedInspectorFilter)),
- inspector(memnew(EditorInspector)),
- search_box(nullptr) {
+ inspector(memnew(EditorInspector)) {
add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up
VBoxContainer *left_vb = memnew(VBoxContainer);
@@ -333,6 +326,5 @@ SectionedInspector::SectionedInspector() :
}
SectionedInspector::~SectionedInspector() {
-
memdelete(filter);
}
diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h
index 7073b73751..dfc521302a 100644
--- a/editor/editor_sectioned_inspector.h
+++ b/editor/editor_sectioned_inspector.h
@@ -38,7 +38,6 @@
class SectionedInspectorFilter;
class SectionedInspector : public HSplitContainer {
-
GDCLASS(SectionedInspector, HSplitContainer);
ObjectID obj;
@@ -48,7 +47,7 @@ class SectionedInspector : public HSplitContainer {
Map<String, TreeItem *> section_map;
EditorInspector *inspector;
- LineEdit *search_box;
+ LineEdit *search_box = nullptr;
String selected_category;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 5e34913cf0..5f293f1fb3 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -58,7 +58,6 @@ Ref<EditorSettings> EditorSettings::singleton = nullptr;
// Properties
bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
-
_THREAD_SAFE_METHOD_
bool changed = _set_only(p_name, p_value);
@@ -69,15 +68,12 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
}
bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) {
-
_THREAD_SAFE_METHOD_
if (p_name.operator String() == "shortcuts") {
-
Array arr = p_value;
ERR_FAIL_COND_V(arr.size() && arr.size() & 1, true);
for (int i = 0; i < arr.size(); i += 2) {
-
String name = arr[i];
Ref<InputEvent> shortcut = arr[i + 1];
@@ -120,14 +116,11 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value)
}
bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
-
_THREAD_SAFE_METHOD_
if (p_name.operator String() == "shortcuts") {
-
Array arr;
for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) {
-
Ref<ShortCut> sc = E->get();
if (optimize_save) {
@@ -136,8 +129,9 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
}
Ref<InputEvent> original = sc->get_meta("original");
- if (sc->is_shortcut(original) || (original.is_null() && sc->get_shortcut().is_null()))
+ if (sc->is_shortcut(original) || (original.is_null() && sc->get_shortcut().is_null())) {
continue; //not changed from default, don't save
+ }
}
arr.push_back(E->key());
@@ -163,7 +157,6 @@ void EditorSettings::_initial_set(const StringName &p_name, const Variant &p_val
}
struct _EVCSort {
-
String name;
Variant::Type type;
int order;
@@ -174,18 +167,17 @@ struct _EVCSort {
};
void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
-
_THREAD_SAFE_METHOD_
const String *k = nullptr;
Set<_EVCSort> vclist;
while ((k = props.next(k))) {
-
const VariantContainer *v = props.getptr(*k);
- if (v->hide_from_editor)
+ if (v->hide_from_editor) {
continue;
+ }
_EVCSort vc;
vc.name = *k;
@@ -203,7 +195,6 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
}
for (Set<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) {
-
int pinfo = 0;
if (E->get().save || !optimize_save) {
pinfo |= PROPERTY_USAGE_STORAGE;
@@ -217,8 +208,9 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
PropertyInfo pi(E->get().type, E->get().name);
pi.usage = pinfo;
- if (hints.has(E->get().name))
+ if (hints.has(E->get().name)) {
pi = hints[E->get().name];
+ }
if (E->get().restart_if_changed) {
pi.usage |= PROPERTY_USAGE_RESTART_IF_CHANGED;
@@ -231,7 +223,6 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
}
void EditorSettings::_add_property_info_bind(const Dictionary &p_info) {
-
ERR_FAIL_COND(!p_info.has("name"));
ERR_FAIL_COND(!p_info.has("type"));
@@ -241,26 +232,27 @@ void EditorSettings::_add_property_info_bind(const Dictionary &p_info) {
pinfo.type = Variant::Type(p_info["type"].operator int());
ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
- if (p_info.has("hint"))
+ if (p_info.has("hint")) {
pinfo.hint = PropertyHint(p_info["hint"].operator int());
- if (p_info.has("hint_string"))
+ }
+ if (p_info.has("hint_string")) {
pinfo.hint_string = p_info["hint_string"];
+ }
add_property_hint(pinfo);
}
// Default configs
bool EditorSettings::has_default_value(const String &p_setting) const {
-
_THREAD_SAFE_METHOD_
- if (!props.has(p_setting))
+ if (!props.has(p_setting)) {
return false;
+ }
return props[p_setting].has_default_value;
}
void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
-
_THREAD_SAFE_METHOD_
/* Languages */
@@ -280,7 +272,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EditorTranslationList *etl = _editor_translations;
while (etl->data) {
-
const String &locale = etl->lang;
// Skip locales which we can't render properly (see above comment).
@@ -512,17 +503,38 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/grid_map/pick_distance", 5000.0);
// 3D
- _initial_set("editors/3d/primary_grid_color", Color(0.56, 0.56, 0.56));
- hints["editors/3d/primary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/primary_grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
-
- _initial_set("editors/3d/secondary_grid_color", Color(0.38, 0.38, 0.38));
- hints["editors/3d/secondary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/secondary_grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("editors/3d/primary_grid_color", Color(0.56, 0.56, 0.56, 0.5));
+ hints["editors/3d/primary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/primary_grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
- _initial_set("editors/3d/grid_size", 50);
- hints["editors/3d/grid_size"] = PropertyInfo(Variant::INT, "editors/3d/grid_size", PROPERTY_HINT_RANGE, "1,500,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("editors/3d/secondary_grid_color", Color(0.38, 0.38, 0.38, 0.5));
+ hints["editors/3d/secondary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/secondary_grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
+ // If a line is a multiple of this, it uses the primary grid color.
_initial_set("editors/3d/primary_grid_steps", 10);
- hints["editors/3d/primary_grid_steps"] = PropertyInfo(Variant::INT, "editors/3d/primary_grid_steps", PROPERTY_HINT_RANGE, "1,100,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["editors/3d/primary_grid_steps"] = PropertyInfo(Variant::INT, "editors/3d/primary_grid_steps", PROPERTY_HINT_RANGE, "1,100,1", PROPERTY_USAGE_DEFAULT);
+
+ // At 1000, the grid mostly looks like it has no edge.
+ _initial_set("editors/3d/grid_size", 200);
+ hints["editors/3d/grid_size"] = PropertyInfo(Variant::INT, "editors/3d/grid_size", PROPERTY_HINT_RANGE, "1,2000,1", PROPERTY_USAGE_DEFAULT);
+
+ // Default largest grid size is 100m, 10^2 (primary grid lines are 1km apart when primary_grid_steps is 10).
+ _initial_set("editors/3d/grid_division_level_max", 2);
+ // Higher values produce graphical artifacts when far away unless View Z-Far
+ // is increased significantly more than it really should need to be.
+ hints["editors/3d/grid_division_level_max"] = PropertyInfo(Variant::INT, "editors/3d/grid_division_level_max", PROPERTY_HINT_RANGE, "-1,3,1", PROPERTY_USAGE_DEFAULT);
+
+ // Default smallest grid size is 1cm, 10^-2.
+ _initial_set("editors/3d/grid_division_level_min", -2);
+ // Lower values produce graphical artifacts regardless of view clipping planes, so limit to -2 as a lower bound.
+ hints["editors/3d/grid_division_level_min"] = PropertyInfo(Variant::INT, "editors/3d/grid_division_level_min", PROPERTY_HINT_RANGE, "-2,2,1", PROPERTY_USAGE_DEFAULT);
+
+ // -0.2 seems like a sensible default. -1.0 gives Blender-like behavior, 0.5 gives huge grids.
+ _initial_set("editors/3d/grid_division_level_bias", -0.2);
+ hints["editors/3d/grid_division_level_bias"] = PropertyInfo(Variant::FLOAT, "editors/3d/grid_division_level_bias", PROPERTY_HINT_RANGE, "-1.0,0.5,0.1", PROPERTY_USAGE_DEFAULT);
+
+ _initial_set("editors/3d/grid_xz_plane", true);
+ _initial_set("editors/3d/grid_xy_plane", false);
+ _initial_set("editors/3d/grid_yz_plane", false);
_initial_set("editors/3d/default_fov", 70.0);
_initial_set("editors/3d/default_z_near", 0.05);
@@ -640,24 +652,19 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Path,Last Edited");
if (p_extra_config.is_valid()) {
-
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
-
Vector<String> list = p_extra_config->get_value("init_projects", "list");
for (int i = 0; i < list.size(); i++) {
-
String name = list[i].replace("/", "::");
set("projects/" + name, list[i]);
};
};
if (p_extra_config->has_section("presets")) {
-
List<String> keys;
p_extra_config->get_section_keys("presets", &keys);
for (List<String>::Element *E = keys.front(); E; E = E->next()) {
-
String key = E->get();
Variant val = p_extra_config->get_value("presets", key);
set(key, val);
@@ -667,7 +674,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
}
void EditorSettings::_load_default_text_editor_theme() {
-
bool dark_theme = is_dark_theme();
_initial_set("text_editor/highlighting/symbol_color", Color(0.73, 0.87, 1.0));
@@ -751,7 +757,6 @@ static Dictionary _get_builtin_script_templates() {
}
static void _create_script_templates(const String &p_path) {
-
Dictionary templates = _get_builtin_script_templates();
List<Variant> keys;
templates.get_key_list(&keys);
@@ -775,14 +780,13 @@ static void _create_script_templates(const String &p_path) {
// PUBLIC METHODS
EditorSettings *EditorSettings::get_singleton() {
-
return singleton.ptr();
}
void EditorSettings::create() {
-
- if (singleton.ptr())
+ if (singleton.ptr()) {
return; //pointless
+ }
DirAccess *dir = nullptr;
@@ -815,7 +819,6 @@ void EditorSettings::create() {
memdelete(d);
if (self_contained) {
-
// editor is self contained, all in same folder
data_path = exe_path;
data_dir = data_path.plus_file("editor_data");
@@ -824,7 +827,6 @@ void EditorSettings::create() {
cache_path = exe_path;
cache_dir = data_dir.plus_file("cache");
} else {
-
// Typically XDG_DATA_HOME or %APPDATA%
data_path = OS::get_singleton()->get_data_path();
data_dir = data_path.plus_file(OS::get_singleton()->get_godot_dir_name());
@@ -845,7 +847,6 @@ void EditorSettings::create() {
String config_file_path;
if (data_path != "" && config_path != "" && cache_path != "") {
-
// Validate/create data dir and subdirectories
dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -916,8 +917,9 @@ void EditorSettings::create() {
dir->change_dir("projects");
String project_config_dir = ProjectSettings::get_singleton()->get_resource_path();
- if (project_config_dir.ends_with("/"))
+ if (project_config_dir.ends_with("/")) {
project_config_dir = config_path.substr(0, project_config_dir.size() - 1);
+ }
project_config_dir = project_config_dir.get_file() + "-" + project_config_dir.md5_text();
if (dir->change_dir(project_config_dir) != OK) {
@@ -967,7 +969,6 @@ fail:
if (extra_config->has_section("init_projects")) {
Vector<String> list = extra_config->get_value("init_projects", "list");
for (int i = 0; i < list.size(); i++) {
-
list.write[i] = exe_path.plus_file(list[i]);
};
extra_config->set_value("init_projects", "list", list);
@@ -986,10 +987,10 @@ fail:
}
void EditorSettings::setup_language() {
-
String lang = get("interface/editor/editor_language");
- if (lang == "en")
+ if (lang == "en") {
return; // Default, nothing to do.
+ }
// Load editor translation for configured/detected locale.
EditorTranslationList *etl = _editor_translations;
@@ -1039,7 +1040,6 @@ void EditorSettings::setup_language() {
}
void EditorSettings::setup_network() {
-
List<IP_Address> local_ip;
IP::get_singleton()->get_local_addresses(&local_ip);
String hint;
@@ -1048,20 +1048,23 @@ void EditorSettings::setup_network() {
// Check that current remote_host is a valid interface address and populate hints.
for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) {
-
String ip = E->get();
// link-local IPv6 addresses don't work, skipping them
- if (ip.begins_with("fe80:0:0:0:")) // fe80::/64
+ if (ip.begins_with("fe80:0:0:0:")) { // fe80::/64
continue;
+ }
// Same goes for IPv4 link-local (APIPA) addresses.
- if (ip.begins_with("169.254.")) // 169.254.0.0/16
+ if (ip.begins_with("169.254.")) { // 169.254.0.0/16
continue;
+ }
// Select current IP (found)
- if (ip == current)
+ if (ip == current) {
selected = ip;
- if (hint != "")
+ }
+ if (hint != "") {
hint += ",";
+ }
hint += ip;
}
@@ -1072,11 +1075,11 @@ void EditorSettings::setup_network() {
}
void EditorSettings::save() {
-
//_THREAD_SAFE_METHOD_
- if (!singleton.ptr())
+ if (!singleton.ptr()) {
return;
+ }
if (singleton->config_file_path == "") {
ERR_PRINT("Cannot save EditorSettings config, no valid path");
@@ -1093,15 +1096,14 @@ void EditorSettings::save() {
}
void EditorSettings::destroy() {
-
- if (!singleton.ptr())
+ if (!singleton.ptr()) {
return;
+ }
save();
singleton = Ref<EditorSettings>();
}
void EditorSettings::set_optimize_save(bool p_optimize) {
-
optimize_save = p_optimize;
}
@@ -1118,14 +1120,12 @@ Variant EditorSettings::get_setting(const String &p_setting) const {
}
bool EditorSettings::has_setting(const String &p_setting) const {
-
_THREAD_SAFE_METHOD_
return props.has(p_setting);
}
void EditorSettings::erase(const String &p_setting) {
-
_THREAD_SAFE_METHOD_
props.erase(p_setting);
@@ -1141,17 +1141,18 @@ void EditorSettings::raise_order(const String &p_setting) {
void EditorSettings::set_restart_if_changed(const StringName &p_setting, bool p_restart) {
_THREAD_SAFE_METHOD_
- if (!props.has(p_setting))
+ if (!props.has(p_setting)) {
return;
+ }
props[p_setting].restart_if_changed = p_restart;
}
void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current) {
-
_THREAD_SAFE_METHOD_
- if (!props.has(p_setting))
+ if (!props.has(p_setting)) {
return;
+ }
props[p_setting].initial = p_value;
props[p_setting].has_default_value = true;
if (p_update_current) {
@@ -1160,7 +1161,6 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian
}
Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed) {
-
Variant ret = p_default;
if (EditorSettings::get_singleton()->has_setting(p_setting)) {
ret = EditorSettings::get_singleton()->get(p_setting);
@@ -1177,32 +1177,31 @@ Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_re
}
Variant _EDITOR_GET(const String &p_setting) {
-
ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has_setting(p_setting), Variant());
return EditorSettings::get_singleton()->get(p_setting);
}
bool EditorSettings::property_can_revert(const String &p_setting) {
-
- if (!props.has(p_setting))
+ if (!props.has(p_setting)) {
return false;
+ }
- if (!props[p_setting].has_default_value)
+ if (!props[p_setting].has_default_value) {
return false;
+ }
return props[p_setting].initial != props[p_setting].variant;
}
Variant EditorSettings::property_get_revert(const String &p_setting) {
-
- if (!props.has(p_setting) || !props[p_setting].has_default_value)
+ if (!props.has(p_setting) || !props[p_setting].has_default_value) {
return Variant();
+ }
return props[p_setting].initial;
}
void EditorSettings::add_property_hint(const PropertyInfo &p_hint) {
-
_THREAD_SAFE_METHOD_
hints[p_hint.name] = p_hint;
@@ -1211,51 +1210,42 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) {
// Data directories
String EditorSettings::get_data_dir() const {
-
return data_dir;
}
String EditorSettings::get_templates_dir() const {
-
return get_data_dir().plus_file("templates");
}
// Config directories
String EditorSettings::get_settings_dir() const {
-
return settings_dir;
}
String EditorSettings::get_project_settings_dir() const {
-
return get_settings_dir().plus_file("projects").plus_file(project_config_dir);
}
String EditorSettings::get_text_editor_themes_dir() const {
-
return get_settings_dir().plus_file("text_editor_themes");
}
String EditorSettings::get_script_templates_dir() const {
-
return get_settings_dir().plus_file("script_templates");
}
String EditorSettings::get_project_script_templates_dir() const {
-
return ProjectSettings::get_singleton()->get("editor/script_templates_search_path");
}
// Cache directory
String EditorSettings::get_cache_dir() const {
-
return cache_dir;
}
String EditorSettings::get_feature_profiles_dir() const {
-
return get_settings_dir().plus_file("feature_profiles");
}
@@ -1283,39 +1273,36 @@ Variant EditorSettings::get_project_metadata(const String &p_section, const Stri
}
void EditorSettings::set_favorites(const Vector<String> &p_favorites) {
-
favorites = p_favorites;
FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::WRITE);
if (f) {
- for (int i = 0; i < favorites.size(); i++)
+ for (int i = 0; i < favorites.size(); i++) {
f->store_line(favorites[i]);
+ }
memdelete(f);
}
}
Vector<String> EditorSettings::get_favorites() const {
-
return favorites;
}
void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) {
-
recent_dirs = p_recent_dirs;
FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::WRITE);
if (f) {
- for (int i = 0; i < recent_dirs.size(); i++)
+ for (int i = 0; i < recent_dirs.size(); i++) {
f->store_line(recent_dirs[i]);
+ }
memdelete(f);
}
}
Vector<String> EditorSettings::get_recent_dirs() const {
-
return recent_dirs;
}
void EditorSettings::load_favorites() {
-
FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::READ);
if (f) {
String line = f->get_line().strip_edges();
@@ -1398,7 +1385,6 @@ void EditorSettings::load_text_editor_theme() {
// don't load if it's not already there!
if (has_setting("text_editor/highlighting/" + key)) {
-
// make sure it is actually a color
if (val.is_valid_html_color() && key.find("color") >= 0) {
props["text_editor/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
@@ -1410,7 +1396,6 @@ void EditorSettings::load_text_editor_theme() {
}
bool EditorSettings::import_text_editor_theme(String p_file) {
-
if (!p_file.ends_with(".tet")) {
return false;
} else {
@@ -1429,7 +1414,6 @@ bool EditorSettings::import_text_editor_theme(String p_file) {
}
bool EditorSettings::save_text_editor_theme() {
-
String p_file = get("text_editor/theme/color_theme");
if (_is_default_text_editor_theme(p_file.get_file().to_lower())) {
@@ -1448,7 +1432,6 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) {
return false;
}
if (_save_text_editor_theme(p_file)) {
-
// switch to theme is saved in the theme directory
list_text_editor_themes();
String theme_name = p_file.substr(0, p_file.length() - 4).get_file();
@@ -1468,7 +1451,6 @@ bool EditorSettings::is_default_text_editor_theme() {
}
Vector<String> EditorSettings::get_script_templates(const String &p_extension, const String &p_custom_path) {
-
Vector<String> templates;
String template_dir = get_script_templates_dir();
if (!p_custom_path.empty()) {
@@ -1491,19 +1473,16 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c
}
String EditorSettings::get_editor_layouts_config() const {
-
return get_settings_dir().plus_file("editor_layouts.cfg");
}
// Shortcuts
void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut) {
-
shortcuts[p_name] = p_shortcut;
}
bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const {
-
const Map<String, Ref<ShortCut>>::Element *E = shortcuts.find(p_name);
ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_name + ".");
@@ -1511,24 +1490,21 @@ bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_
}
Ref<ShortCut> EditorSettings::get_shortcut(const String &p_name) const {
-
const Map<String, Ref<ShortCut>>::Element *E = shortcuts.find(p_name);
- if (!E)
+ if (!E) {
return Ref<ShortCut>();
+ }
return E->get();
}
void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
-
for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) {
-
r_shortcuts->push_back(E->key());
}
}
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
-
if (!EditorSettings::get_singleton()) {
return nullptr;
}
@@ -1546,7 +1522,6 @@ struct ShortCutMapping {
};
Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) {
-
#ifdef OSX_ENABLED
// Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS
if (p_keycode == KEY_DELETE) {
@@ -1577,7 +1552,6 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (sc.is_valid()) {
-
sc->set_name(p_name); //keep name (the ones that come from disk have no name)
sc->set_meta("original", ie); //to compare against changes
return sc;
@@ -1593,7 +1567,6 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
}
void EditorSettings::notify_changes() {
-
_THREAD_SAFE_METHOD_
SceneTree *sml = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
@@ -1611,7 +1584,6 @@ void EditorSettings::notify_changes() {
}
void EditorSettings::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("has_setting", "name"), &EditorSettings::has_setting);
ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &EditorSettings::set_setting);
ClassDB::bind_method(D_METHOD("get_setting", "name"), &EditorSettings::get_setting);
@@ -1638,7 +1610,6 @@ void EditorSettings::_bind_methods() {
}
EditorSettings::EditorSettings() {
-
last_order = 0;
optimize_save = true;
save_changed_setting = true;
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 29b89ef1a8..13aebb7ea6 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -42,7 +42,6 @@
class EditorPlugin;
class EditorSettings : public Resource {
-
GDCLASS(EditorSettings, Resource);
private:
@@ -50,7 +49,6 @@ private:
public:
struct Plugin {
-
EditorPlugin *instance;
String path;
String name;
@@ -64,27 +62,19 @@ public:
private:
struct VariantContainer {
- int order;
+ int order = 0;
Variant variant;
Variant initial;
- bool has_default_value;
- bool hide_from_editor;
- bool save;
- bool restart_if_changed;
- VariantContainer() :
- order(0),
- has_default_value(false),
- hide_from_editor(false),
- save(false),
- restart_if_changed(false) {
- }
+ bool has_default_value = false;
+ bool hide_from_editor = false;
+ bool save = false;
+ bool restart_if_changed = false;
+
+ VariantContainer() {}
+
VariantContainer(const Variant &p_variant, int p_order) :
order(p_order),
- variant(p_variant),
- has_default_value(false),
- hide_from_editor(false),
- save(false),
- restart_if_changed(false) {
+ variant(p_variant) {
}
};
@@ -148,10 +138,11 @@ public:
void set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current = false);
void set_restart_if_changed(const StringName &p_setting, bool p_restart);
void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) {
- if (p_emit_signal)
+ if (p_emit_signal) {
_set(p_setting, p_value);
- else
+ } else {
_set_only(p_setting, p_value);
+ }
}
bool property_can_revert(const String &p_setting);
Variant property_get_revert(const String &p_setting);
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 2c70e16610..67d92c4839 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -47,16 +47,14 @@ String EditorSpinSlider::get_text_value() const {
}
void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
-
- if (read_only)
+ if (read_only) {
return;
+ }
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
-
if (updown_offset != -1 && mb->get_position().x > updown_offset) {
//there is an updown, so use it.
if (mb->get_position().y < get_size().height / 2) {
@@ -66,7 +64,6 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
}
return;
} else {
-
grabbing_spinner_attempt = true;
grabbing_spinner_dist_cache = 0;
pre_grab_value = get_value();
@@ -74,11 +71,8 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position();
}
} else {
-
if (grabbing_spinner_attempt) {
-
if (grabbing_spinner) {
-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
update();
@@ -91,17 +85,15 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
}
}
} else if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN) {
-
- if (grabber->is_visible())
+ if (grabber->is_visible()) {
call_deferred("update");
+ }
}
}
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (grabbing_spinner_attempt) {
-
double diff_x = mm->get_relative().x;
if (mm->get_shift() && grabbing_spinner) {
diff_x *= 0.1;
@@ -150,12 +142,10 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (grabbing_grabber) {
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_WHEEL_UP) {
set_value(get_value() + get_step());
mousewheel_over_grabber = true;
@@ -167,9 +157,7 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
-
grabbing_grabber = true;
if (!mousewheel_over_grabber) {
grabbing_ratio = get_as_ratio();
@@ -183,8 +171,9 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && grabbing_grabber) {
- if (mousewheel_over_grabber)
+ if (mousewheel_over_grabber) {
return;
+ }
float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range);
set_as_ratio(grabbing_ratio + grabbing_ofs);
@@ -193,11 +182,11 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
}
void EditorSpinSlider::_notification(int p_what) {
-
if (p_what == NOTIFICATION_WM_FOCUS_OUT ||
p_what == NOTIFICATION_WM_FOCUS_IN ||
p_what == NOTIFICATION_EXIT_TREE) {
if (grabbing_spinner) {
+ grabber->hide();
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
grabbing_spinner = false;
grabbing_spinner_attempt = false;
@@ -218,7 +207,6 @@ void EditorSpinSlider::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
updown_offset = -1;
Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit");
@@ -324,12 +312,10 @@ void EditorSpinSlider::_notification(int p_what) {
}
if (p_what == NOTIFICATION_MOUSE_ENTER) {
-
mouse_over_spin = true;
update();
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {
-
mouse_over_spin = false;
update();
}
@@ -342,7 +328,6 @@ void EditorSpinSlider::_notification(int p_what) {
}
Size2 EditorSpinSlider::get_minimum_size() const {
-
Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit");
Ref<Font> font = get_theme_font("font", "LineEdit");
@@ -380,8 +365,9 @@ void EditorSpinSlider::_evaluate_input_text() {
}
Variant v = expr->execute(Array(), nullptr, false);
- if (v.get_type() == Variant::NIL)
+ if (v.get_type() == Variant::NIL) {
return;
+ }
set_value(v);
}
@@ -399,10 +385,10 @@ void EditorSpinSlider::_value_input_closed() {
//focus_exited signal
void EditorSpinSlider::_value_focus_exited() {
-
// discontinue because the focus_exit was caused by right-click context menu
- if (value_input->get_menu()->is_visible())
+ if (value_input->get_menu()->is_visible()) {
return;
+ }
_evaluate_input_text();
// focus is not on the same element after the vlalue_input was exited
@@ -429,7 +415,6 @@ void EditorSpinSlider::_grabber_mouse_exited() {
}
void EditorSpinSlider::set_read_only(bool p_enable) {
-
read_only = p_enable;
update();
}
@@ -439,7 +424,6 @@ bool EditorSpinSlider::is_read_only() const {
}
void EditorSpinSlider::set_flat(bool p_enable) {
-
flat = p_enable;
update();
}
@@ -483,7 +467,6 @@ void EditorSpinSlider::_bind_methods() {
}
EditorSpinSlider::EditorSpinSlider() {
-
flat = false;
grabbing_spinner_attempt = false;
grabbing_spinner = false;
diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp
index 1205e0b37c..a9b1a28092 100644
--- a/editor/editor_sub_scene.cpp
+++ b/editor/editor_sub_scene.cpp
@@ -35,13 +35,11 @@
#include "scene/resources/packed_scene.h"
void EditorSubScene::_path_selected(const String &p_path) {
-
path->set_text(p_path);
_path_changed(p_path);
}
void EditorSubScene::_path_changed(const String &p_path) {
-
tree->clear();
if (scene) {
@@ -49,29 +47,30 @@ void EditorSubScene::_path_changed(const String &p_path) {
scene = nullptr;
}
- if (p_path == "")
+ if (p_path == "") {
return;
+ }
Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene");
- if (ps.is_null())
+ if (ps.is_null()) {
return;
+ }
scene = ps->instance();
- if (!scene)
+ if (!scene) {
return;
+ }
_fill_tree(scene, nullptr);
}
void EditorSubScene::_path_browse() {
-
file_dialog->popup_centered_ratio();
}
void EditorSubScene::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
if (is_visible() && scene == nullptr) {
_path_browse();
}
@@ -79,7 +78,6 @@ void EditorSubScene::_notification(int p_what) {
}
void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) {
-
TreeItem *it = tree->create_item(p_parent);
it->set_metadata(0, p_node);
it->set_text(0, p_node->get_name());
@@ -88,10 +86,10 @@ void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) {
it->set_icon(0, EditorNode::get_singleton()->get_object_icon(p_node, "Node"));
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *c = p_node->get_child(i);
- if (c->get_owner() != scene)
+ if (c->get_owner() != scene) {
continue;
+ }
_fill_tree(c, it);
}
}
@@ -114,8 +112,9 @@ void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_s
Node *n = item->get_metadata(0);
- if (!n)
+ if (!n) {
return;
+ }
if (p_selected) {
if (n == scene) {
is_root = true;
@@ -125,8 +124,9 @@ void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_s
} else {
List<Node *>::Element *E = selection.find(n);
- if (E)
+ if (E) {
selection.erase(E);
+ }
}
}
}
@@ -165,13 +165,10 @@ void EditorSubScene::ok_pressed() {
}
void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) {
-
if (p_node == scene) {
-
scene->set_filename("");
p_to_reown->push_back(p_node);
} else if (p_node->get_owner() == scene) {
-
p_to_reown->push_back(p_node);
}
@@ -214,18 +211,15 @@ void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) {
}
void EditorSubScene::clear() {
-
path->set_text("");
_path_changed("");
}
void EditorSubScene::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("subscene_selected"));
}
EditorSubScene::EditorSubScene() {
-
scene = nullptr;
is_root = false;
@@ -262,7 +256,6 @@ EditorSubScene::EditorSubScene() {
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
file_dialog->add_filter("*." + E->get());
}
diff --git a/editor/editor_sub_scene.h b/editor/editor_sub_scene.h
index 5c3b4377d4..cd88805254 100644
--- a/editor/editor_sub_scene.h
+++ b/editor/editor_sub_scene.h
@@ -36,7 +36,6 @@
#include "scene/gui/tree.h"
class EditorSubScene : public ConfirmationDialog {
-
GDCLASS(EditorSubScene, ConfirmationDialog);
List<Node *> selection;
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 0ef173f074..ace106cd3e 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -86,7 +86,6 @@ static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1,
}
Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float p_scale = EDSCALE, bool p_force_filter = false) {
-
Ref<ImageTexture> icon = memnew(ImageTexture);
Ref<Image> img = memnew(Image);
@@ -106,7 +105,6 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float
#endif
void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = true, int p_thumb_size = 32, bool p_only_thumbs = false) {
-
#ifdef MODULE_SVG_ENABLED
// The default icon theme is designed to be used for a dark theme.
// This dictionary stores color codes to convert to other colors
@@ -255,7 +253,6 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme =
}
Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
-
Ref<Theme> theme = Ref<Theme>(memnew(Theme));
const float default_contrast = 0.25;
diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp
index 6f3a8d9ea7..4b13a5dd89 100644
--- a/editor/editor_vcs_interface.cpp
+++ b/editor/editor_vcs_interface.cpp
@@ -33,7 +33,6 @@
EditorVCSInterface *EditorVCSInterface::singleton = nullptr;
void EditorVCSInterface::_bind_methods() {
-
// Proxy end points that act as fallbacks to unavailability of a function in the VCS addon
ClassDB::bind_method(D_METHOD("_initialize", "project_root_path"), &EditorVCSInterface::_initialize);
ClassDB::bind_method(D_METHOD("_is_vcs_initialized"), &EditorVCSInterface::_is_vcs_initialized);
@@ -62,18 +61,15 @@ void EditorVCSInterface::_bind_methods() {
}
bool EditorVCSInterface::_initialize(String p_project_root_path) {
-
WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed.");
return true;
}
bool EditorVCSInterface::_is_vcs_initialized() {
-
return false;
}
Dictionary EditorVCSInterface::_get_modified_files_data() {
-
return Dictionary();
}
@@ -87,96 +83,76 @@ void EditorVCSInterface::_commit(String p_msg) {
}
Array EditorVCSInterface::_get_file_diff(String p_file_path) {
-
return Array();
}
bool EditorVCSInterface::_shut_down() {
-
return false;
}
String EditorVCSInterface::_get_project_name() {
-
return String();
}
String EditorVCSInterface::_get_vcs_name() {
-
return "";
}
bool EditorVCSInterface::initialize(String p_project_root_path) {
-
is_initialized = call("_initialize", p_project_root_path);
return is_initialized;
}
bool EditorVCSInterface::is_vcs_initialized() {
-
return call("_is_vcs_initialized");
}
Dictionary EditorVCSInterface::get_modified_files_data() {
-
return call("_get_modified_files_data");
}
void EditorVCSInterface::stage_file(String p_file_path) {
-
if (is_addon_ready()) {
-
call("_stage_file", p_file_path);
}
}
void EditorVCSInterface::unstage_file(String p_file_path) {
-
if (is_addon_ready()) {
-
call("_unstage_file", p_file_path);
}
}
bool EditorVCSInterface::is_addon_ready() {
-
return is_initialized;
}
void EditorVCSInterface::commit(String p_msg) {
-
if (is_addon_ready()) {
-
call("_commit", p_msg);
}
}
Array EditorVCSInterface::get_file_diff(String p_file_path) {
-
if (is_addon_ready()) {
-
return call("_get_file_diff", p_file_path);
}
return Array();
}
bool EditorVCSInterface::shut_down() {
-
return call("_shut_down");
}
String EditorVCSInterface::get_project_name() {
-
return call("_get_project_name");
}
String EditorVCSInterface::get_vcs_name() {
-
return call("_get_vcs_name");
}
EditorVCSInterface::EditorVCSInterface() {
-
is_initialized = false;
}
@@ -184,11 +160,9 @@ EditorVCSInterface::~EditorVCSInterface() {
}
EditorVCSInterface *EditorVCSInterface::get_singleton() {
-
return singleton;
}
void EditorVCSInterface::set_singleton(EditorVCSInterface *p_singleton) {
-
singleton = p_singleton;
}
diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h
index 85d5e30367..ee9e51441d 100644
--- a/editor/editor_vcs_interface.h
+++ b/editor/editor_vcs_interface.h
@@ -36,7 +36,6 @@
#include "scene/gui/panel_container.h"
class EditorVCSInterface : public Object {
-
GDCLASS(EditorVCSInterface, Object)
bool is_initialized;
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index f52e340a26..fb12c15913 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -42,7 +42,6 @@
#include "scene/gui/link_button.h"
void ExportTemplateManager::_update_template_list() {
-
while (current_hb->get_child_count()) {
memdelete(current_hb->get_child(0));
}
@@ -57,7 +56,6 @@ void ExportTemplateManager::_update_template_list() {
Set<String> templates;
d->list_dir_begin();
if (err == OK) {
-
String c = d->get_next();
while (c != String()) {
if (d->current_is_dir() && !c.begins_with(".")) {
@@ -118,7 +116,6 @@ void ExportTemplateManager::_update_template_list() {
}
for (Set<String>::Element *E = templates.back(); E; E = E->prev()) {
-
HBoxContainer *hbc = memnew(HBoxContainer);
Label *version = memnew(Label);
version->set_modulate(current->get_theme_color("disabled_font_color", "Editor"));
@@ -141,7 +138,6 @@ void ExportTemplateManager::_update_template_list() {
}
void ExportTemplateManager::_download_template(const String &p_version) {
-
while (template_list->get_child_count()) {
memdelete(template_list->get_child(0));
}
@@ -155,14 +151,12 @@ void ExportTemplateManager::_download_template(const String &p_version) {
}
void ExportTemplateManager::_uninstall_template(const String &p_version) {
-
remove_confirm->set_text(vformat(TTR("Remove template version '%s'?"), p_version));
remove_confirm->popup_centered();
to_remove = p_version;
}
void ExportTemplateManager::_uninstall_template_confirm() {
-
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
Error err = da->change_dir(templates_dir);
@@ -181,7 +175,6 @@ void ExportTemplateManager::_uninstall_template_confirm() {
}
bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_progress) {
-
// unzClose() will take care of closing the file stored in the unzFile,
// so we don't need to `memdelete(fa)` in this method.
FileAccess *fa = nullptr;
@@ -189,7 +182,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
-
EditorNode::get_singleton()->show_warning(TTR("Can't open export templates zip."));
return false;
}
@@ -200,7 +192,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
String contents_dir;
while (ret == UNZ_OK) {
-
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
@@ -208,7 +199,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
String file = fname;
if (file.ends_with("version.txt")) {
-
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
@@ -266,7 +256,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
fc = 0;
while (ret == UNZ_OK) {
-
//get filename
unz_file_info info;
char fname[16384];
@@ -340,18 +329,15 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
}
void ExportTemplateManager::popup_manager() {
-
_update_template_list();
popup_centered(Size2(400, 400) * EDSCALE);
}
void ExportTemplateManager::ok_pressed() {
-
template_open->popup_centered_ratio();
}
void ExportTemplateManager::_http_download_mirror_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
-
if (p_status != HTTPRequest::RESULT_SUCCESS || p_code != 200) {
EditorNode::get_singleton()->show_warning(TTR("Error getting the list of mirrors."));
return;
@@ -396,10 +382,9 @@ void ExportTemplateManager::_http_download_mirror_completed(int p_status, int p_
return;
}
}
-void ExportTemplateManager::_http_download_templates_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
+void ExportTemplateManager::_http_download_templates_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
switch (p_status) {
-
case HTTPRequest::RESULT_CANT_RESOLVE: {
template_list_state->set_text(TTR("Can't resolve."));
} break;
@@ -445,7 +430,6 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
}
void ExportTemplateManager::_begin_template_download(const String &p_url) {
-
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
OS::get_singleton()->shell_open(p_url);
return;
@@ -482,14 +466,12 @@ void ExportTemplateManager::_window_template_downloader_closed() {
}
void ExportTemplateManager::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (!is_visible()) {
set_process(false);
}
}
if (p_what == NOTIFICATION_PROCESS) {
-
update_countdown -= get_process_delta_time();
if (update_countdown > 0) {
@@ -552,13 +534,11 @@ void ExportTemplateManager::_notification(int p_what) {
}
bool ExportTemplateManager::can_install_android_template() {
-
const String templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
return FileAccess::exists(templates_dir.plus_file("android_source.zip"));
}
Error ExportTemplateManager::install_android_template() {
-
// To support custom Android builds, we install the Java source code and buildsystem
// from android_source.zip to the project's res://android folder.
@@ -615,7 +595,6 @@ Error ExportTemplateManager::install_android_template() {
Set<String> dirs_tested;
int idx = 0;
while (ret == UNZ_OK) {
-
// Get file path.
unz_file_info info;
char fpath[16384];
@@ -667,7 +646,6 @@ void ExportTemplateManager::_bind_methods() {
}
ExportTemplateManager::ExportTemplateManager() {
-
VBoxContainer *main_vb = memnew(VBoxContainer);
add_child(main_vb);
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index fb44c145b2..7e05bc5d88 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -40,7 +40,6 @@
#define DEBUG_TIME(m_what)
void EditorFileServer::_close_client(ClientData *cd) {
-
cd->connection->disconnect_from_host();
{
MutexLock lock(cd->efs->wait_mutex);
@@ -54,7 +53,6 @@ void EditorFileServer::_close_client(ClientData *cd) {
}
void EditorFileServer::_subthread_start(void *s) {
-
ClientData *cd = (ClientData *)s;
cd->connection->set_no_delay(true);
@@ -68,11 +66,9 @@ void EditorFileServer::_subthread_start(void *s) {
int passlen = decode_uint32(buf4);
if (passlen > 512) {
-
_close_client(cd);
ERR_FAIL_COND(passlen > 512);
} else if (passlen > 0) {
-
Vector<char> passutf8;
passutf8.resize(passlen + 1);
err = cd->connection->get_data((uint8_t *)passutf8.ptr(), passlen);
@@ -106,7 +102,6 @@ void EditorFileServer::_subthread_start(void *s) {
cd->connection->put_data(buf4, 4);
while (!cd->quit) {
-
//wait for ID
err = cd->connection->get_data(buf4, 4);
DEBUG_TIME("get_data")
@@ -126,11 +121,9 @@ void EditorFileServer::_subthread_start(void *s) {
int cmd = decode_uint32(buf4);
switch (cmd) {
-
case FileAccessNetwork::COMMAND_FILE_EXISTS:
case FileAccessNetwork::COMMAND_GET_MODTIME:
case FileAccessNetwork::COMMAND_OPEN_FILE: {
-
DEBUG_TIME("open_file")
err = cd->connection->get_data(buf4, 4);
if (err != OK) {
@@ -161,14 +154,12 @@ void EditorFileServer::_subthread_start(void *s) {
}
if (!s2.begins_with("res://")) {
-
_close_client(cd);
ERR_FAIL_COND(!s2.begins_with("res://"));
}
ERR_CONTINUE(cd->files.has(id));
if (cmd == FileAccessNetwork::COMMAND_FILE_EXISTS) {
-
encode_uint32(id, buf4);
cd->connection->put_data(buf4, 4);
encode_uint32(FileAccessNetwork::RESPONSE_FILE_EXISTS, buf4);
@@ -180,7 +171,6 @@ void EditorFileServer::_subthread_start(void *s) {
}
if (cmd == FileAccessNetwork::COMMAND_GET_MODTIME) {
-
encode_uint32(id, buf4);
cd->connection->put_data(buf4, 4);
encode_uint32(FileAccessNetwork::RESPONSE_GET_MODTIME, buf4);
@@ -218,7 +208,6 @@ void EditorFileServer::_subthread_start(void *s) {
} break;
case FileAccessNetwork::COMMAND_READ_BLOCK: {
-
err = cd->connection->get_data(buf4, 8);
if (err != OK) {
_close_client(cd);
@@ -259,7 +248,6 @@ void EditorFileServer::_subthread_start(void *s) {
} break;
case FileAccessNetwork::COMMAND_CLOSE: {
-
print_verbose("CLOSED");
ERR_CONTINUE(!cd->files.has(id));
memdelete(cd->files[id]);
@@ -272,10 +260,8 @@ void EditorFileServer::_subthread_start(void *s) {
}
void EditorFileServer::_thread_start(void *s) {
-
EditorFileServer *self = (EditorFileServer *)s;
while (!self->quit) {
-
if (self->cmd == CMD_ACTIVATE) {
self->server->listen(self->port);
self->active = true;
@@ -312,7 +298,6 @@ void EditorFileServer::_thread_start(void *s) {
}
void EditorFileServer::start() {
-
stop();
port = EDITOR_DEF("filesystem/file_server/port", 6010);
password = EDITOR_DEF("filesystem/file_server/password", "");
@@ -320,17 +305,14 @@ void EditorFileServer::start() {
}
bool EditorFileServer::is_active() const {
-
return active;
}
void EditorFileServer::stop() {
-
cmd = CMD_STOP;
}
EditorFileServer::EditorFileServer() {
-
server.instance();
quit = false;
active = false;
@@ -342,7 +324,6 @@ EditorFileServer::EditorFileServer() {
}
EditorFileServer::~EditorFileServer() {
-
quit = true;
Thread::wait_to_finish(thread);
memdelete(thread);
diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h
index cc3cb44566..9645fbf39e 100644
--- a/editor/fileserver/editor_file_server.h
+++ b/editor/fileserver/editor_file_server.h
@@ -38,7 +38,6 @@
#include "core/os/thread.h"
class EditorFileServer : public Object {
-
GDCLASS(EditorFileServer, Object);
enum Command {
@@ -48,7 +47,6 @@ class EditorFileServer : public Object {
};
struct ClientData {
-
Thread *thread;
Ref<StreamPeerTCP> connection;
Map<int, FileAccess *> files;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 236ae16ccf..f279f402d9 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -63,8 +63,9 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
// Create a tree item for the subdirectory.
TreeItem *subdirectory_item = tree->create_item(p_parent);
String dname = p_dir->get_name();
- if (dname == "")
+ if (dname == "") {
dname = "res://";
+ }
subdirectory_item->set_text(0, dname);
subdirectory_item->set_icon(0, get_theme_icon("Folder", "EditorIcons"));
@@ -86,14 +87,14 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
}
// Create items for all subdirectories.
- for (int i = 0; i < p_dir->get_subdir_count(); i++)
+ for (int i = 0; i < p_dir->get_subdir_count(); i++) {
parent_should_expand = (_create_tree(subdirectory_item, p_dir->get_subdir(i), uncollapsed_paths, p_select_in_favorites, p_unfold_path) || parent_should_expand);
+ }
// Create all items for the files in the subdirectory.
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene");
for (int i = 0; i < p_dir->get_file_count(); i++) {
-
String file_type = p_dir->get_file_type(i);
if (_is_file_type_disabled_by_feature_profile(file_type)) {
@@ -196,8 +197,9 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites();
for (int i = 0; i < favorite_paths.size(); i++) {
String fave = favorite_paths[i];
- if (!fave.begins_with("res://"))
+ if (!fave.begins_with("res://")) {
continue;
+ }
Ref<Texture2D> folder_icon = get_theme_icon("Folder", "EditorIcons");
const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog");
@@ -298,8 +300,9 @@ void FileSystemDock::_update_display_mode(bool p_force) {
void FileSystemDock::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- if (initialized)
+ if (initialized) {
return;
+ }
initialized = true;
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &FileSystemDock::_feature_profile_changed));
@@ -350,8 +353,9 @@ void FileSystemDock::_notification(int p_what) {
Dictionary dd = get_viewport()->gui_get_drag_data();
if (tree->is_visible_in_tree() && dd.has("type")) {
if (dd.has("favorite")) {
- if ((String(dd["favorite"]) == "all"))
+ if ((String(dd["favorite"]) == "all")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
+ }
} else if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM | Tree::DROP_MODE_INBETWEEN);
}
@@ -405,13 +409,15 @@ void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_s
call_deferred("_update_import_dock");
// Return if we don't select something new.
- if (!p_selected)
+ if (!p_selected) {
return;
+ }
// Tree item selected.
TreeItem *selected = tree->get_selected();
- if (!selected)
+ if (!selected) {
return;
+ }
TreeItem *favorites_item = tree->get_root()->get_children();
if (selected->get_parent() == favorites_item && !String(selected->get_metadata(0)).ends_with("/")) {
@@ -433,10 +439,11 @@ void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_s
}
String FileSystemDock::get_selected_path() const {
- if (path.ends_with("/"))
+ if (path.ends_with("/")) {
return path;
- else
+ } else {
return path.get_base_dir();
+ }
}
String FileSystemDock::get_current_path() const {
@@ -505,8 +512,9 @@ void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<T
String file = uarr[1];
if (idx < files->get_item_count() && files->get_item_text(idx) == file && files->get_item_metadata(idx) == p_path) {
if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) {
- if (p_small_preview.is_valid())
+ if (p_small_preview.is_valid()) {
files->set_item_icon(idx, p_small_preview);
+ }
} else {
files->set_item_icon(idx, p_preview);
}
@@ -554,7 +562,6 @@ bool FileSystemDock::_is_file_type_disabled_by_feature_profile(const StringName
StringName class_name = p_class;
while (class_name != StringName()) {
-
if (profile->is_class_disabled(class_name)) {
return true;
}
@@ -565,8 +572,9 @@ bool FileSystemDock::_is_file_type_disabled_by_feature_profile(const StringName
}
void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *matches, int p_max_items) {
- if (matches->size() > p_max_items)
+ if (matches->size() > p_max_items) {
return;
+ }
for (int i = 0; i < p_path->get_subdir_count(); i++) {
_search(p_path->get_subdir(i), matches, p_max_items);
@@ -576,7 +584,6 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *
String file = p_path->get_file(i);
if (file.to_lower().find(searched_string) != -1) {
-
FileInfo fi;
fi.name = file;
fi.type = p_path->get_file_type(i);
@@ -589,8 +596,9 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *
}
matches->push_back(fi);
- if (matches->size() > p_max_items)
+ if (matches->size() > p_max_items) {
return;
+ }
}
}
}
@@ -600,8 +608,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
Set<String> cselection;
if (p_keep_selection) {
for (int i = 0; i < files->get_item_count(); i++) {
- if (files->is_selected(i))
+ if (files->is_selected(i)) {
cselection.insert(files->get_item_text(i));
+ }
}
}
@@ -704,8 +713,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
file = path.get_file();
efd = EditorFileSystem::get_singleton()->get_filesystem_path(directory);
}
- if (!efd)
+ if (!efd) {
return;
+ }
if (searched_string.length() > 0) {
// Display the search results.
@@ -717,8 +727,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
files->add_item("..", folder_icon, true);
String bd = directory.get_base_dir();
- if (bd != "res://" && !bd.ends_with("/"))
+ if (bd != "res://" && !bd.ends_with("/")) {
bd += "/";
+ }
files->set_item_metadata(files->get_item_count() - 1, bd);
files->set_item_selectable(files->get_item_count() - 1, false);
@@ -804,8 +815,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
}
// Select the items.
- if (cselection.has(fname))
+ if (cselection.has(fname)) {
files->select(item_index, false);
+ }
if (!p_keep_selection && file != "" && fname == file) {
files->select(item_index, true);
@@ -860,9 +872,7 @@ void FileSystemDock::_file_list_activate_file(int p_idx) {
void FileSystemDock::_preview_invalidated(const String &p_path) {
if (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && searched_string.length() == 0 && file_list_vb->is_visible_in_tree()) {
-
for (int i = 0; i < files->get_item_count(); i++) {
-
if (files->get_item_metadata(i) == p_path) {
// Re-request preview.
Array udata;
@@ -907,15 +917,17 @@ void FileSystemDock::_set_scanning_mode() {
}
void FileSystemDock::_fw_history() {
- if (history_pos < history.size() - 1)
+ if (history_pos < history.size() - 1) {
history_pos++;
+ }
_update_history();
}
void FileSystemDock::_bw_history() {
- if (history_pos > 0)
+ if (history_pos > 0) {
history_pos--;
+ }
_update_history();
}
@@ -955,8 +967,9 @@ void FileSystemDock::_push_to_history() {
}
void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const {
- if (efsd == nullptr)
+ if (efsd == nullptr) {
return;
+ }
for (int i = 0; i < efsd->get_subdir_count(); i++) {
folders.push_back(efsd->get_subdir(i)->get_path());
@@ -1111,8 +1124,9 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String>
for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) {
String path;
if (i == EditorNode::get_editor_data().get_edited_scene()) {
- if (!get_tree()->get_edited_scene_root())
+ if (!get_tree()->get_edited_scene_root()) {
continue;
+ }
path = get_tree()->get_edited_scene_root()->get_filename();
} else {
@@ -1143,8 +1157,9 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &
print_verbose("Remapping dependencies for: " + file);
Error err = ResourceLoader::rename_dependencies(file, p_renames);
if (err == OK) {
- if (ResourceLoader::get_resource_type(file) == "PackedScene")
+ if (ResourceLoader::get_resource_type(file) == "PackedScene") {
editor->reload_scene(file);
+ }
} else {
EditorNode::get_singleton()->add_io_error(TTR("Unable to update dependencies:") + "\n" + remaps[i] + "\n");
}
@@ -1272,8 +1287,9 @@ void FileSystemDock::_make_scene_confirm() {
break;
}
}
- if (!extension_correct)
+ if (!extension_correct) {
scene_name = scene_name.get_basename() + ".tscn";
+ }
scene_name = directory.plus_file(scene_name);
@@ -1626,8 +1642,9 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
}
EditorSettings::get_singleton()->set_favorites(favorites);
_update_tree(_compute_uncollapsed_paths());
- if (path == "Favorites")
+ if (path == "Favorites") {
_update_file_list(true);
+ }
} break;
case FILE_DEPENDENCIES: {
@@ -1728,7 +1745,6 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
} break;
case FILE_INFO: {
-
} break;
case FILE_REIMPORT: {
@@ -1813,10 +1829,11 @@ void FileSystemDock::_search_changed(const String &p_text, const Control *p_from
searched_string = p_text.to_lower();
- if (p_from == tree_search_box)
+ if (p_from == tree_search_box) {
file_list_search_box->set_text(searched_string);
- else // File_list_search_box.
+ } else { // File_list_search_box.
tree_search_box->set_text(searched_string);
+ }
bool unfold_path = (p_text == String() && path != String());
switch (display_mode) {
@@ -1849,8 +1866,9 @@ void FileSystemDock::focus_on_filter() {
}
void FileSystemDock::set_file_list_display_mode(FileListDisplayMode p_mode) {
- if (p_mode == file_list_display_mode)
+ if (p_mode == file_list_display_mode) {
return;
+ }
_toggle_file_display();
}
@@ -1891,8 +1909,9 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
all_not_favorites = true;
}
- if (paths.empty())
+ if (paths.empty()) {
return Variant();
+ }
Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from);
if (!all_not_favorites) {
@@ -1905,15 +1924,15 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
Dictionary drag_data = p_data;
if (drag_data.has("favorite")) {
-
if (String(drag_data["favorite"]) != "all") {
return false;
}
// Moving favorite around.
TreeItem *ti = tree->get_item_at_position(p_point);
- if (!ti)
+ if (!ti) {
return false;
+ }
int drop_section = tree->get_drop_section_at_position(p_point);
TreeItem *favorites_item = tree->get_root()->get_children();
@@ -1947,19 +1966,22 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
bool favorite;
_get_drag_target_folder(to_dir, favorite, p_point, p_from);
- if (favorite)
+ if (favorite) {
return true;
+ }
- if (to_dir.empty())
+ if (to_dir.empty()) {
return false;
+ }
// Attempting to move a folder into itself will fail later,
// rather than bring up a message don't try to do it in the first place.
to_dir = to_dir.ends_with("/") ? to_dir : (to_dir + "/");
Vector<String> fnames = drag_data["files"];
for (int i = 0; i < fnames.size(); ++i) {
- if (fnames[i].ends_with("/") && to_dir.begins_with(fnames[i]))
+ if (fnames[i].ends_with("/") && to_dir.begins_with(fnames[i])) {
return false;
+ }
}
return true;
@@ -1969,21 +1991,22 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
}
void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
Dictionary drag_data = p_data;
Vector<String> dirs = EditorSettings::get_singleton()->get_favorites();
if (drag_data.has("favorite")) {
-
if (String(drag_data["favorite"]) != "all") {
return;
}
// Moving favorite around.
TreeItem *ti = tree->get_item_at_position(p_point);
- if (!ti)
+ if (!ti) {
return;
+ }
int drop_section = tree->get_drop_section_at_position(p_point);
int drop_position;
@@ -2030,8 +2053,9 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
EditorSettings::get_singleton()->set_favorites(dirs);
_update_tree(_compute_uncollapsed_paths());
- if (display_mode == DISPLAY_MODE_SPLIT && path == "Favorites")
+ if (display_mode == DISPLAY_MODE_SPLIT && path == "Favorites") {
_update_file_list(true);
+ }
return;
}
@@ -2061,7 +2085,32 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
}
if (!to_move.empty()) {
- _move_operation_confirm(to_dir);
+ if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ for (int i = 0; i < to_move.size(); i++) {
+ String new_path;
+ String new_path_base;
+
+ if (to_move[i].is_file) {
+ new_path = to_dir.plus_file(to_move[i].path.get_file());
+ new_path_base = new_path.get_basename() + " (%d)." + new_path.get_extension();
+ } else {
+ PackedStringArray path_split = to_move[i].path.split("/");
+ new_path = to_dir.plus_file(path_split[path_split.size() - 2]);
+ new_path_base = new_path + " (%d)";
+ }
+
+ int exist_counter = 1;
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ while (da->file_exists(new_path) || da->dir_exists(new_path)) {
+ exist_counter++;
+ new_path = vformat(new_path_base, exist_counter);
+ }
+ _try_duplicate_item(to_move[i], new_path);
+ }
+ _rescan();
+ } else {
+ _move_operation_confirm(to_dir);
+ }
}
} else if (favorite) {
// Add the files from favorites.
@@ -2290,8 +2339,9 @@ void FileSystemDock::_file_list_rmb_select(int p_item, const Vector2 &p_pos) {
// Right click is pressed in the file list.
Vector<String> paths;
for (int i = 0; i < files->get_item_count(); i++) {
- if (!files->is_selected(i))
+ if (!files->is_selected(i)) {
continue;
+ }
if (files->get_item_text(p_item) == "..") {
files->unselect(i);
continue;
@@ -2311,8 +2361,9 @@ void FileSystemDock::_file_list_rmb_select(int p_item, const Vector2 &p_pos) {
void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) {
// Right click on empty space for file list.
- if (searched_string.length() > 0)
+ if (searched_string.length() > 0) {
return;
+ }
file_list_popup->clear();
file_list_popup->set_size(Size2(1, 1));
@@ -2350,7 +2401,6 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
}
void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) {
@@ -2366,7 +2416,6 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
}
void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) {
@@ -2382,8 +2431,9 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
}
void FileSystemDock::_update_import_dock() {
- if (!import_dock_needs_update)
+ if (!import_dock_needs_update) {
return;
+ }
// List selected.
Vector<String> selected;
@@ -2394,8 +2444,9 @@ void FileSystemDock::_update_import_dock() {
} else {
// Use the file list.
for (int i = 0; i < files->get_item_count(); i++) {
- if (!files->is_selected(i))
+ if (!files->is_selected(i)) {
continue;
+ }
selected.push_back(files->get_item_metadata(i));
}
@@ -2451,7 +2502,6 @@ void FileSystemDock::_feature_profile_changed() {
}
void FileSystemDock::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
ClassDB::bind_method(D_METHOD("_file_list_thumbnail_done"), &FileSystemDock::_file_list_thumbnail_done);
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 6d2d8510d1..08c2124ae8 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -148,11 +148,9 @@ private:
class FileOrFolder {
public:
String path;
- bool is_file;
+ bool is_file = false;
- FileOrFolder() :
- path(""),
- is_file(false) {}
+ FileOrFolder() {}
FileOrFolder(const String &p_path, bool p_is_file) :
path(p_path),
is_file(p_is_file) {}
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index d73180c831..1bc0de1ab0 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -59,14 +59,14 @@ static bool is_text_char(CharType c) {
}
static bool find_next(const String &line, String pattern, int from, bool match_case, bool whole_words, int &out_begin, int &out_end) {
-
int end = from;
while (true) {
int begin = match_case ? line.find(pattern, end) : line.findn(pattern, end);
- if (begin == -1)
+ if (begin == -1) {
return false;
+ }
end = begin + pattern.length();
out_begin = begin;
@@ -157,15 +157,14 @@ void FindInFiles::_process() {
while (is_processing()) {
_iterate();
float elapsed = (os.get_ticks_msec() - time_before);
- if (elapsed > 1000.0 / 120.0)
+ if (elapsed > 1000.0 / 120.0) {
break;
+ }
}
}
void FindInFiles::_iterate() {
-
if (_folders_stack.size() != 0) {
-
// Scan folders first so we can build a list of files and have progress info later
PackedStringArray &folders_to_scan = _folders_stack.write[_folders_stack.size() - 1];
@@ -196,7 +195,6 @@ void FindInFiles::_iterate() {
}
} else if (_files_to_scan.size() != 0) {
-
// Then scan files
String fpath = _files_to_scan[_files_to_scan.size() - 1];
@@ -220,7 +218,6 @@ float FindInFiles::get_progress() const {
}
void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
-
DirAccessRef dir = DirAccess::open(path);
if (!dir) {
print_verbose("Cannot open directory! " + path);
@@ -232,19 +229,22 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
for (int i = 0; i < 1000; ++i) {
String file = dir->get_next();
- if (file == "")
+ if (file == "") {
break;
+ }
// Ignore special dirs (such as .git and .import)
- if (file == "." || file == ".." || file.begins_with("."))
+ if (file == "." || file == ".." || file.begins_with(".")) {
continue;
- if (dir->current_is_hidden())
+ }
+ if (dir->current_is_hidden()) {
continue;
+ }
- if (dir->current_is_dir())
+ if (dir->current_is_dir()) {
out_folders.push_back(file);
- else {
+ } else {
String file_ext = file.get_extension();
if (_extension_filter.has(file_ext)) {
_files_to_scan.push_back(path.plus_file(file));
@@ -254,7 +254,6 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
}
void FindInFiles::_scan_file(String fpath) {
-
FileAccessRef f = FileAccess::open(fpath, FileAccess::READ);
if (!f) {
print_verbose(String("Cannot open file ") + fpath);
@@ -264,7 +263,6 @@ void FindInFiles::_scan_file(String fpath) {
int line_number = 0;
while (!f->eof_reached()) {
-
// line number starts at 1
++line_number;
@@ -282,7 +280,6 @@ void FindInFiles::_scan_file(String fpath) {
}
void FindInFiles::_bind_methods() {
-
ADD_SIGNAL(MethodInfo(SIGNAL_RESULT_FOUND,
PropertyInfo(Variant::STRING, "path"),
PropertyInfo(Variant::INT, "line_number"),
@@ -298,7 +295,6 @@ const char *FindInFilesDialog::SIGNAL_FIND_REQUESTED = "find_requested";
const char *FindInFilesDialog::SIGNAL_REPLACE_REQUESTED = "replace_requested";
FindInFilesDialog::FindInFilesDialog() {
-
set_min_size(Size2(500 * EDSCALE, 0));
set_title(TTR("Find in Files"));
@@ -408,9 +404,9 @@ void FindInFilesDialog::set_replace_text(String text) {
}
void FindInFilesDialog::set_find_in_files_mode(FindInFilesMode p_mode) {
-
- if (_mode == p_mode)
+ if (_mode == p_mode) {
return;
+ }
_mode = p_mode;
@@ -464,7 +460,6 @@ Set<String> FindInFilesDialog::get_filter() const {
void FindInFilesDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
if (is_visible()) {
// Doesn't work more than once if not deferred...
_search_text_line_edit->call_deferred("grab_focus");
@@ -506,7 +501,6 @@ void FindInFilesDialog::custom_action(const String &p_action) {
}
void FindInFilesDialog::_on_search_text_modified(String text) {
-
ERR_FAIL_COND(!_find_button);
ERR_FAIL_COND(!_replace_button);
@@ -540,13 +534,13 @@ void FindInFilesDialog::_on_replace_text_entered(String text) {
void FindInFilesDialog::_on_folder_selected(String path) {
int i = path.find("://");
- if (i != -1)
+ if (i != -1) {
path = path.right(i + 3);
+ }
_folder_line_edit->set_text(path);
}
void FindInFilesDialog::_bind_methods() {
-
ADD_SIGNAL(MethodInfo(SIGNAL_FIND_REQUESTED));
ADD_SIGNAL(MethodInfo(SIGNAL_REPLACE_REQUESTED));
}
@@ -556,7 +550,6 @@ const char *FindInFilesPanel::SIGNAL_RESULT_SELECTED = "result_selected";
const char *FindInFilesPanel::SIGNAL_FILES_MODIFIED = "files_modified";
FindInFilesPanel::FindInFilesPanel() {
-
_finder = memnew(FindInFiles);
_finder->connect(FindInFiles::SIGNAL_RESULT_FOUND, callable_mp(this, &FindInFilesPanel::_on_result_found));
_finder->connect(FindInFiles::SIGNAL_FINISHED, callable_mp(this, &FindInFilesPanel::_on_finished));
@@ -641,7 +634,6 @@ FindInFilesPanel::FindInFilesPanel() {
}
void FindInFilesPanel::set_with_replace(bool with_replace) {
-
_with_replace = with_replace;
_replace_container->set_visible(with_replace);
@@ -670,7 +662,6 @@ void FindInFilesPanel::clear() {
}
void FindInFilesPanel::start_search() {
-
clear();
_status_label->set_text(TTR("Searching..."));
@@ -687,7 +678,6 @@ void FindInFilesPanel::start_search() {
}
void FindInFilesPanel::stop_search() {
-
_finder->stop();
_status_label->set_text("");
@@ -704,7 +694,6 @@ void FindInFilesPanel::_notification(int p_what) {
}
void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin, int end, String text) {
-
TreeItem *file_item;
Map<String, TreeItem *>::Element *E = _file_items.find(fpath);
@@ -756,14 +745,15 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
}
void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
-
TreeItem *item = Object::cast_to<TreeItem>(item_obj);
- if (!item)
+ if (!item) {
return;
+ }
Map<TreeItem *, Result>::Element *E = _result_items.find(item);
- if (!E)
+ if (!E) {
return;
+ }
Result r = E->value();
Rect2 match_rect = rect;
@@ -777,7 +767,6 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
}
void FindInFilesPanel::_on_item_edited() {
-
TreeItem *item = _results_display->get_selected();
if (item->is_checked(0)) {
@@ -792,7 +781,6 @@ void FindInFilesPanel::_on_item_edited() {
}
void FindInFilesPanel::_on_finished() {
-
_status_label->set_text(TTR("Search complete"));
update_replace_buttons();
set_progress_visible(false);
@@ -809,12 +797,12 @@ void FindInFilesPanel::_on_cancel_button_clicked() {
}
void FindInFilesPanel::_on_result_selected() {
-
TreeItem *item = _results_display->get_selected();
Map<TreeItem *, Result>::Element *E = _result_items.find(item);
- if (E == nullptr)
+ if (E == nullptr) {
return;
+ }
Result r = E->value();
TreeItem *file_item = item->get_parent();
@@ -828,21 +816,19 @@ void FindInFilesPanel::_on_replace_text_changed(String text) {
}
void FindInFilesPanel::_on_replace_all_clicked() {
-
String replace_text = get_replace_text();
PackedStringArray modified_files;
for (Map<String, TreeItem *>::Element *E = _file_items.front(); E; E = E->next()) {
-
TreeItem *file_item = E->value();
String fpath = file_item->get_metadata(0);
Vector<Result> locations;
for (TreeItem *item = file_item->get_children(); item; item = item->get_next()) {
-
- if (!item->is_checked(0))
+ if (!item->is_checked(0)) {
continue;
+ }
Map<TreeItem *, Result>::Element *F = _result_items.find(item);
ERR_FAIL_COND(F == nullptr);
@@ -866,13 +852,11 @@ void FindInFilesPanel::_on_replace_all_clicked() {
class ConservativeGetLine {
public:
String get_line(FileAccess *f) {
-
_line_buffer.clear();
CharType c = f->get_8();
while (!f->eof_reached()) {
-
if (c == '\n') {
_line_buffer.push_back(c);
_line_buffer.push_back(0);
@@ -898,7 +882,6 @@ private:
};
void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result> &locations, String new_text) {
-
// If the file is already open, I assume the editor will reload it.
// If there are unsaved changes, the user will be asked on focus,
// however that means either losing changes or losing replaces.
@@ -917,7 +900,6 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result>
int offset = 0;
for (int i = 0; i < locations.size(); ++i) {
-
int repl_line_number = locations[i].line_number;
while (current_line < repl_line_number) {
@@ -963,7 +945,6 @@ String FindInFilesPanel::get_replace_text() {
}
void FindInFilesPanel::update_replace_buttons() {
-
bool disabled = _finder->is_searching();
_replace_all_button->set_disabled(disabled);
@@ -974,7 +955,6 @@ void FindInFilesPanel::set_progress_visible(bool visible) {
}
void FindInFilesPanel::_bind_methods() {
-
ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found);
ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished);
ClassDB::bind_method("_draw_result_text", &FindInFilesPanel::draw_result_text);
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 7e5d2e87d6..98b216acda 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -300,8 +300,9 @@ void GroupDialog::_load_groups(Node *p_current) {
void GroupDialog::_delete_group_pressed(Object *p_item, int p_column, int p_id) {
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
- if (!ti)
+ if (!ti) {
return;
+ }
String name = ti->get_text(0);
@@ -536,16 +537,18 @@ GroupDialog::GroupDialog() {
////////////////////////////////////////////////////////////////////////////////
void GroupsEditor::_add_group(const String &p_group) {
-
- if (!node)
+ if (!node) {
return;
+ }
const String name = group_name->get_text().strip_edges();
- if (name.empty())
+ if (name.empty()) {
return;
+ }
- if (node->is_in_group(name))
+ if (node->is_in_group(name)) {
return;
+ }
undo_redo->create_action(TTR("Add to Group"));
@@ -564,13 +567,14 @@ void GroupsEditor::_add_group(const String &p_group) {
}
void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) {
-
- if (!node)
+ if (!node) {
return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
- if (!ti)
+ if (!ti) {
return;
+ }
String name = ti->get_text(0);
@@ -589,18 +593,17 @@ void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) {
}
struct _GroupInfoComparator {
-
bool operator()(const Node::GroupInfo &p_a, const Node::GroupInfo &p_b) const {
return p_a.name.operator String() < p_b.name.operator String();
}
};
void GroupsEditor::update_tree() {
-
tree->clear();
- if (!node)
+ if (!node) {
return;
+ }
List<Node::GroupInfo> groups;
node->get_groups(&groups);
@@ -609,20 +612,18 @@ void GroupsEditor::update_tree() {
TreeItem *root = tree->create_item();
for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
-
Node::GroupInfo gi = E->get();
- if (!gi.persistent)
+ if (!gi.persistent) {
continue;
+ }
Node *n = node;
bool can_be_deleted = true;
while (n) {
-
Ref<SceneState> ss = (n == EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state();
if (ss.is_valid()) {
-
int path = ss->find_node_by_path(n->get_path_to(node));
if (path != -1) {
if (ss->is_node_in_group(path, gi.name)) {
@@ -645,13 +646,11 @@ void GroupsEditor::update_tree() {
}
void GroupsEditor::set_current(Node *p_node) {
-
node = p_node;
update_tree();
}
void GroupsEditor::_show_group_dialog() {
-
group_dialog->edit();
group_dialog->set_undo_redo(undo_redo);
}
@@ -661,7 +660,6 @@ void GroupsEditor::_bind_methods() {
}
GroupsEditor::GroupsEditor() {
-
node = nullptr;
VBoxContainer *vbc = this;
diff --git a/editor/groups_editor.h b/editor/groups_editor.h
index 40c7b3c75a..911c82e7f0 100644
--- a/editor/groups_editor.h
+++ b/editor/groups_editor.h
@@ -42,7 +42,6 @@
#include "scene/gui/tree.h"
class GroupDialog : public AcceptDialog {
-
GDCLASS(GroupDialog, AcceptDialog);
ConfirmationDialog *error;
@@ -104,7 +103,6 @@ public:
};
class GroupsEditor : public VBoxContainer {
-
GDCLASS(GroupsEditor, VBoxContainer);
Node *node;
diff --git a/editor/icons/CameraEffects.svg b/editor/icons/CameraEffects.svg
new file mode 100644
index 0000000000..2f6dad5fd8
--- /dev/null
+++ b/editor/icons/CameraEffects.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m5.9492188 2a3 3 0 0 0 -2.9492188 3 3 3 0 0 0 1 2.2304688v1.7695312l-3-2v6l3-2v1c0 .554.44599 1 1 1h3c.0076117-.045309.0115938-.096059.0214844-.134766.0773621-.302758.1860981-.478282.2832031-.625.1397097-.211089.2814954-.338835.4257813-.480468-.1445165-.141692-.2879205-.269839-.4277344-.480469-.0971224-.146315-.2052562-.321748-.2832032-.623047-.0777157-.300405-.1044198-.8152648.1640626-1.2910156.2700589-.4775976.7340166-.7239536 1.0371093-.8105469.3037241-.0867737.5108695-.0808838.6875-.0703125.2608449.0156115.4500479.0763383.6503909.1328125.049596-.1859081.086921-.3641449.195312-.5800781.078477-.1563394.174637-.3364783.396485-.5527344.221847-.2162561.652628-.4930277 1.195312-.4980469a1.6124973 1.6124973 0 0 1 .033203 0c.542861.0056205.97185.2837448 1.19336.5.146452.1429781.230167.265896.298828.3808594a3 3 0 0 0 .128906-.8671875 3 3 0 0 0 -3-3 3 3 0 0 0 -2.0117188.7773438 3 3 0 0 0 -2.9882812-2.7773438 3 3 0 0 0 -.0507812 0z" fill="#e0e0e0"/><path d="m12.36062 8.59795a.53334 3.2001 0 0 0 -.50976 2.2754 3.2001.53334 30 0 0 -2.2656-.71484 3.2001.53334 30 0 0 1.75 1.6016.53334 3.2001 60 0 0 -1.7461 1.5996.53334 3.2001 60 0 0 2.2578-.71094.53334 3.2001 0 0 0 .51367 2.3496.53334 3.2001 0 0 0 .51367-2.3516 3.2001.53334 30 0 0 2.2539.71094 3.2001.53334 30 0 0 -1.7441-1.5977.53334 3.2001 60 0 0 1.748-1.5996.53334 3.2001 60 0 0 -2.2617.71484.53334 3.2001 0 0 0 -.50977-2.2773z" fill="#cea4f1" stroke-width="1.0667"/></svg> \ No newline at end of file
diff --git a/editor/icons/CubeMap.svg b/editor/icons/Cubemap.svg
index c9e6f1fa7d..c9e6f1fa7d 100644
--- a/editor/icons/CubeMap.svg
+++ b/editor/icons/Cubemap.svg
diff --git a/editor/icons/CubemapArray.svg b/editor/icons/CubemapArray.svg
new file mode 100644
index 0000000000..350a64f9c2
--- /dev/null
+++ b/editor/icons/CubemapArray.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 6v4h2v-4zm6 0v4h4v-4z" fill="#84ffb1"/><path d="m4 6v4h4v-4zm8 0v4h2v-4z" fill="#ff8484"/><path d="m4 2v4h4v-4zm0 8v4h4v-4z" fill="#84c2ff"/><path d="m-.00000002 2v12h4.00000002v-2h-2v-8h2v-2h-2zm12.00000002 0v2h2.000001v8h-2.000001v2h4.000001v-12h-2z" fill="#e0e0e0"/></svg> \ No newline at end of file
diff --git a/editor/icons/LightmapProbe.svg b/editor/icons/LightmapProbe.svg
new file mode 100644
index 0000000000..0972220fda
--- /dev/null
+++ b/editor/icons/LightmapProbe.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 9h3v-2h-3zm2.050781 2.535156 1.414063 1.414063 1.414062-1.414063-1.414062-1.414062zm0-7.070312 1.414063 1.414062 1.414062-1.414062-1.414062-1.414063zm1.949219 3.535156c0 1.6569 1.3432 3 3 3s3-1.3431 3-3-1.3432-3-3-3-3 1.3431-3 3zm3 7c3.865993 0 7-3.134007 7-7s-3.134007-7-7-7v2.333984c2.577329 0 4.666016 2.088687 4.666016 4.666016s-2.088687 4.666016-4.666016 4.666016z" fill="#fc9c9c" fill-opacity=".996078" stroke-width="1.16667"/></svg> \ No newline at end of file
diff --git a/editor/icons/PanoramaSky.svg b/editor/icons/PanoramaSky.svg
deleted file mode 100644
index bfff6840bd..0000000000
--- a/editor/icons/PanoramaSky.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientTransform="matrix(1.0096 0 0 1.0227 -.009615 -22.593)" gradientUnits="userSpaceOnUse" x1="8" x2="8" y1="1038.4" y2="1050.4"><stop offset="0" stop-color="#1ec3ff"/><stop offset="1" stop-color="#b2e1ff"/></linearGradient><g transform="translate(0 -1037.4)"><path d="m1 1039.4c4.2749 2.6091 10.765 2.7449 14 0v12c-3.5849-2.6849-9.7929-2.6544-14 0z" fill="url(#a)" stroke-width="15.242"/><path d="m11 6c-.554 0-1 .446-1 1h-1c-.554 0-1 .446-1 1s.446 1 1 1h2c.554 0 1-.446 1-1h1c.554 0 1-.446 1-1s-.446-1-1-1zm-8 3c-.554 0-1 .446-1 1s.446 1 1 1h1c.554 0 1-.446 1-1s-.446-1-1-1z" fill="#fff" transform="translate(0 1037.4)"/></g></svg> \ No newline at end of file
diff --git a/editor/icons/PanoramaSkyMaterial.svg b/editor/icons/PanoramaSkyMaterial.svg
new file mode 100644
index 0000000000..9f40ffb63c
--- /dev/null
+++ b/editor/icons/PanoramaSkyMaterial.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 5v2h8 1c0-.554.446-1 1-1h2c.554 0 1 .446 1 1h1v-2z" fill="#9dff70"/><path d="m1 3v2h14v-2h-1.589844c-2.86436 1.357608-6.9481434 1.30996-10.347656 0z" fill="#ffeb70"/><path d="m1 2v1h2.0625c-.7241713-.2790504-1.419865-.6077805-2.0625-1zm14 0c-.465784.3952185-1.005424.7230054-1.589844 1h1.589844z" fill="#ff7070"/><path d="m1 7v2h2 1 5c-.554 0-1-.446-1-1s.446-1 1-1zm13 0c0 .554-.446 1-1 1h-1c0 .554-.446 1-1 1h4v-2z" fill="#70ffb9"/><path d="m1 9v2h2c-.554 0-1-.446-1-1s.446-1 1-1zm3 0c.554 0 1 .446 1 1s-.446 1-1 1h11v-2h-4-2z" fill="#70deff"/><path d="m1 13v-2h14v2h-1.589844c-2.86436-1.357608-6.9481434-1.30996-10.347656 0z" fill="#9f70ff"/><path d="m1 14v-1h2.0625c-.7241713.27905-1.419865.60778-2.0625 1zm14 0c-.465784-.395219-1.005424-.723005-1.589844-1h1.589844z" fill="#ff70ac"/></svg> \ No newline at end of file
diff --git a/editor/icons/PhysicalSkyMaterial.svg b/editor/icons/PhysicalSkyMaterial.svg
new file mode 100644
index 0000000000..5831cb2c63
--- /dev/null
+++ b/editor/icons/PhysicalSkyMaterial.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 5v2h8 1c0-.554.446-1 1-1h2c.554 0 1 .446 1 1h1v-2z" fill="#9dff70"/><path d="m1 7v2h2 1 5c-.554 0-1-.446-1-1s.446-1 1-1zm13 0c0 .554-.446 1-1 1h-1c0 .554-.446 1-1 1h4v-2z" fill="#70ffb9"/><path d="m1 9v2h2c-.554 0-1-.446-1-1s.446-1 1-1zm3 0c.554 0 1 .446 1 1s-.446 1-1 1h11v-2h-4-2z" fill="#70deff"/><path d="m1 3v2h14v-2z" fill="#ffeb70"/><path d="m1 11v2h14v-2z" fill="#9f70ff"/></svg> \ No newline at end of file
diff --git a/editor/icons/ProceduralSky.svg b/editor/icons/ProceduralSky.svg
deleted file mode 100644
index 356a966fe9..0000000000
--- a/editor/icons/ProceduralSky.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="8" x2="8" y1="1040.4" y2="1050.4"><stop offset="0" stop-color="#1ec3ff"/><stop offset="1" stop-color="#b2e1ff"/></linearGradient><g transform="translate(0 -1037.4)"><path d="m8 1040.4a7 7 0 0 0 -7 7 7 7 0 0 0 .68555 3h12.631a7 7 0 0 0 .68359-3 7 7 0 0 0 -7-7z" fill="url(#a)"/><path d="m10 7c-.554 0-1 .446-1 1h-1c-.554 0-1 .446-1 1s.446 1 1 1h2c.554 0 1-.446 1-1h1c.554 0 1-.446 1-1s-.446-1-1-1zm-7 3c-.554 0-1 .446-1 1s.446 1 1 1h1c.554 0 1-.446 1-1s-.446-1-1-1z" fill="#fff" transform="translate(0 1037.4)"/></g></svg> \ No newline at end of file
diff --git a/editor/icons/ProceduralSkyMaterial.svg b/editor/icons/ProceduralSkyMaterial.svg
new file mode 100644
index 0000000000..f7a3944671
--- /dev/null
+++ b/editor/icons/ProceduralSkyMaterial.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1.0761719 11a7 7 0 0 0 .609375 2h12.6308591a7 7 0 0 0 .609375-2h-9.925781c0 .554-.446 1-1 1h-1c-.554 0-1-.446-1-1z" fill="#9f70ff"/><path d="m1.0722656 9a7 7 0 0 0 -.0722656 1 7 7 0 0 0 .0761719 1h.9238281c0-.554.446-1 1-1h1c.554 0 1 .446 1 1h9.925781a7 7 0 0 0 .074219-1 7 7 0 0 0 -.072266-1h-2.927734-1c0 .554-.446 1-1 1h-2c-.554 0-1-.446-1-1z" fill="#70deff"/><path d="m1.6757812 7a7 7 0 0 0 -.6035156 2h5.9277344c0-.554.446-1 1-1h1c0-.554.446-1 1-1zm10.3242188 0c.554 0 1 .446 1 1s-.446 1-1 1h2.927734a7 7 0 0 0 -.603515-2z" fill="#70ffb9"/><path d="m3.1035156 5a7 7 0 0 0 -1.4277344 2h12.6484378a7 7 0 0 0 -1.425781-2z" fill="#9dff70"/><path d="m8 3a7 7 0 0 0 -4.8964844 2h9.7949224a7 7 0 0 0 -4.898438-2z" fill="#ffeb70"/></svg> \ No newline at end of file
diff --git a/editor/icons/RootMotionView.svg b/editor/icons/RootMotionView.svg
new file mode 100644
index 0000000000..4d33420383
--- /dev/null
+++ b/editor/icons/RootMotionView.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><radialGradient id="a" cx="8" cy="8" gradientTransform="matrix(.85714281 -.00000007 .00000004 .85714284 1.142858 1.142858)" gradientUnits="userSpaceOnUse" r="7"><stop offset="0" stop-color="#fc9c9c"/><stop offset=".83333331" stop-color="#fc9c9c" stop-opacity=".701961"/><stop offset="1" stop-color="#fc9c9c" stop-opacity="0"/></radialGradient><path d="m5 2v3h-3v2h3v2h-3v2h3v3h2v-3h2v3h2v-3h3v-2h-3v-2h3v-2h-3v-3h-2v3h-2v-3zm2 5h2v2h-2z" fill="url(#a)"/></svg> \ No newline at end of file
diff --git a/editor/icons/SCsub b/editor/icons/SCsub
index f0d51999f0..e143276259 100644
--- a/editor/icons/SCsub
+++ b/editor/icons/SCsub
@@ -2,6 +2,8 @@
Import("env")
+import os
+
from platform_methods import run_in_subprocess
import editor_icons_builders
@@ -15,7 +17,10 @@ env["BUILDERS"]["MakeEditorIconsBuilder"] = make_editor_icons_builder
icon_sources = Glob("*.svg")
# Module icons
-for module_icons in env.module_icons_paths:
- icon_sources += Glob("#" + module_icons + "/*.svg")
+for path in env.module_icons_paths:
+ if not os.path.isabs(path):
+ icon_sources += Glob("#" + path + "/*.svg") # Built-in.
+ else:
+ icon_sources += Glob(path + "/*.svg") # Custom.
env.Alias("editor_icons", [env.MakeEditorIconsBuilder("#editor/editor_icons.gen.h", icon_sources)])
diff --git a/editor/icons/ShaderGlobalsOverride.svg b/editor/icons/ShaderGlobalsOverride.svg
new file mode 100644
index 0000000000..2fe76ed777
--- /dev/null
+++ b/editor/icons/ShaderGlobalsOverride.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 1c-.55226.0001-.99994.4477-1 1v12c.0000552.5523.44774.9999 1 1h12c.55226-.0001.99994-.4477 1-1v-8l-5-5zm1 2h6v3c0 .554.44599 1 1 1h3v6h-10zm1 1v1h3v-1zm0 2v1h2v-1zm3 0v1h1v-1zm-2 3 3 3 3-3z" fill="#e0e0e0"/></svg> \ No newline at end of file
diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp
index 9e49fa9066..41e71248a9 100644
--- a/editor/import/collada.cpp
+++ b/editor/import/collada.cpp
@@ -45,14 +45,12 @@
/* HELPERS */
String Collada::Effect::get_texture_path(const String &p_source, Collada &state) const {
-
const String &image = p_source;
ERR_FAIL_COND_V(!state.state.image_map.has(image), "");
return state.state.image_map[image].path;
}
Transform Collada::get_root_transform() const {
-
Transform unit_scale_transform;
#ifndef COLLADA_IMPORT_SCALE_SCENE
unit_scale_transform.scale(Vector3(state.unit_scale, state.unit_scale, state.unit_scale));
@@ -67,27 +65,27 @@ void Collada::Vertex::fix_unit_scale(Collada &state) {
}
static String _uri_to_id(const String &p_uri) {
-
- if (p_uri.begins_with("#"))
+ if (p_uri.begins_with("#")) {
return p_uri.substr(1, p_uri.size() - 1);
- else
+ } else {
return p_uri;
+ }
}
/** HELPER FUNCTIONS **/
Transform Collada::fix_transform(const Transform &p_transform) {
-
Transform tr = p_transform;
#ifndef NO_UP_AXIS_SWAP
if (state.up_axis != Vector3::AXIS_Y) {
-
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
SWAP(tr.basis[1][i], tr.basis[state.up_axis][i]);
- for (int i = 0; i < 3; i++)
+ }
+ for (int i = 0; i < 3; i++) {
SWAP(tr.basis[i][1], tr.basis[i][state.up_axis]);
+ }
SWAP(tr.origin[1], tr.origin[state.up_axis]);
@@ -105,7 +103,6 @@ Transform Collada::fix_transform(const Transform &p_transform) {
}
static Transform _read_transform_from_array(const Vector<float> &array, int ofs = 0) {
-
Transform tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl..
tr.basis.elements[0][0] = array[0 + ofs];
@@ -126,39 +123,30 @@ static Transform _read_transform_from_array(const Vector<float> &array, int ofs
/* STRUCTURES */
Transform Collada::Node::compute_transform(Collada &state) const {
-
Transform xform;
for (int i = 0; i < xform_list.size(); i++) {
-
Transform xform_step;
const XForm &xf = xform_list[i];
switch (xf.op) {
-
case XForm::OP_ROTATE: {
if (xf.data.size() >= 4) {
-
xform_step.rotate(Vector3(xf.data[0], xf.data[1], xf.data[2]), Math::deg2rad(xf.data[3]));
}
} break;
case XForm::OP_SCALE: {
-
if (xf.data.size() >= 3) {
-
xform_step.scale(Vector3(xf.data[0], xf.data[1], xf.data[2]));
}
} break;
case XForm::OP_TRANSLATE: {
-
if (xf.data.size() >= 3) {
-
xform_step.origin = Vector3(xf.data[0], xf.data[1], xf.data[2]);
}
} break;
case XForm::OP_MATRIX: {
-
if (xf.data.size() >= 16) {
xform_step = _read_transform_from_array(xf.data, 0);
}
@@ -178,39 +166,37 @@ Transform Collada::Node::compute_transform(Collada &state) const {
}
Transform Collada::Node::get_transform() const {
-
return default_transform;
}
Transform Collada::Node::get_global_transform() const {
-
- if (parent)
+ if (parent) {
return parent->get_global_transform() * default_transform;
- else
+ } else {
return default_transform;
+ }
}
Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const {
-
ERR_FAIL_COND_V(keys.size() == 0, Vector<float>());
int i = 0;
for (i = 0; i < keys.size(); i++) {
-
- if (keys[i].time > p_time)
+ if (keys[i].time > p_time) {
break;
+ }
}
- if (i == 0)
+ if (i == 0) {
return keys[0].data;
- if (i == keys.size())
+ }
+ if (i == keys.size()) {
return keys[keys.size() - 1].data;
+ }
switch (keys[i].interp_type) {
-
case INTERP_BEZIER: //wait for bezier
case INTERP_LINEAR: {
-
float c = (p_time - keys[i - 1].time) / (keys[i].time - keys[i - 1].time);
if (keys[i].data.size() == 16) {
@@ -243,11 +229,9 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const {
return ret;
} else {
-
Vector<float> dest;
dest.resize(keys[i].data.size());
for (int j = 0; j < dest.size(); j++) {
-
dest.write[j] = keys[i].data[j] * c + keys[i - 1].data[j] * (1.0 - c);
}
return dest;
@@ -260,42 +244,41 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const {
}
void Collada::_parse_asset(XMLParser &parser) {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "up_axis") {
-
parser.read();
- if (parser.get_node_data() == "X_UP")
+ if (parser.get_node_data() == "X_UP") {
state.up_axis = Vector3::AXIS_X;
- if (parser.get_node_data() == "Y_UP")
+ }
+ if (parser.get_node_data() == "Y_UP") {
state.up_axis = Vector3::AXIS_Y;
- if (parser.get_node_data() == "Z_UP")
+ }
+ if (parser.get_node_data() == "Z_UP") {
state.up_axis = Vector3::AXIS_Z;
+ }
COLLADA_PRINT("up axis: " + parser.get_node_data());
} else if (name == "unit") {
-
state.unit_scale = parser.get_attribute_value("meter").to_double();
COLLADA_PRINT("unit scale: " + rtos(state.unit_scale));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "asset")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "asset") {
break; //end of <asset>
+ }
}
}
void Collada::_parse_image(XMLParser &parser) {
-
String id = parser.get_attribute_value("id");
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
@@ -309,15 +292,11 @@ void Collada::_parse_image(XMLParser &parser) {
image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().plus_file(path.percent_decode()));
}
} else {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "init_from") {
-
parser.read();
String path = parser.get_node_data().strip_edges().percent_decode();
@@ -333,14 +312,15 @@ void Collada::_parse_image(XMLParser &parser) {
image.path = path;
} else if (name == "data") {
-
ERR_PRINT("COLLADA Embedded image data not supported!");
- } else if (name == "extra" && !parser.is_empty())
+ } else if (name == "extra" && !parser.is_empty()) {
parser.skip_section();
+ }
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "image")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "image") {
break; //end of <asset>
+ }
}
}
@@ -348,31 +328,30 @@ void Collada::_parse_image(XMLParser &parser) {
}
void Collada::_parse_material(XMLParser &parser) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
Material material;
String id = parser.get_attribute_value("id");
- if (parser.has_attribute("name"))
+ if (parser.has_attribute("name")) {
material.name = parser.get_attribute_value("name");
+ }
if (state.version < State::Version(1, 4, 0)) {
/* <1.4 */
ERR_PRINT("Collada Materials < 1.4 are not supported (yet)");
} else {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT && parser.get_node_name() == "instance_effect") {
-
material.instance_effect = _uri_to_id(parser.get_attribute_value("url"));
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "material")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "material") {
break; //end of <asset>
+ }
}
}
@@ -381,9 +360,9 @@ void Collada::_parse_material(XMLParser &parser) {
//! reads floats from inside of xml element until end of xml element
Vector<float> Collada::_read_float_array(XMLParser &parser) {
-
- if (parser.is_empty())
+ if (parser.is_empty()) {
return Vector<float>();
+ }
Vector<String> splitters;
splitters.push_back(" ");
@@ -401,17 +380,18 @@ Vector<float> Collada::_read_float_array(XMLParser &parser) {
String str = parser.get_node_data();
array = str.split_floats_mk(splitters, false);
//array=str.split_floats(" ",false);
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) {
break; // end parsing text
+ }
}
return array;
}
Vector<String> Collada::_read_string_array(XMLParser &parser) {
-
- if (parser.is_empty())
+ if (parser.is_empty()) {
return Vector<String>();
+ }
Vector<String> array;
while (parser.read() == OK) {
@@ -422,17 +402,18 @@ Vector<String> Collada::_read_string_array(XMLParser &parser) {
// parse String data
String str = parser.get_node_data();
array = str.split_spaces();
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) {
break; // end parsing text
+ }
}
return array;
}
Transform Collada::_read_transform(XMLParser &parser) {
-
- if (parser.is_empty())
+ if (parser.is_empty()) {
return Transform();
+ }
Vector<String> array;
while (parser.read() == OK) {
@@ -443,8 +424,9 @@ Transform Collada::_read_transform(XMLParser &parser) {
// parse float data
String str = parser.get_node_data();
array = str.split_spaces();
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) {
break; // end parsing text
+ }
}
ERR_FAIL_COND_V(array.size() != 16, Transform());
@@ -458,103 +440,88 @@ Transform Collada::_read_transform(XMLParser &parser) {
}
String Collada::_read_empty_draw_type(XMLParser &parser) {
-
String empty_draw_type = "";
- if (parser.is_empty())
+ if (parser.is_empty()) {
return empty_draw_type;
+ }
while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
empty_draw_type = parser.get_node_data();
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) {
break; // end parsing text
+ }
}
return empty_draw_type;
}
Variant Collada::_parse_param(XMLParser &parser) {
-
- if (parser.is_empty())
+ if (parser.is_empty()) {
return Variant();
+ }
String from = parser.get_node_name();
Variant data;
while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "float") {
-
parser.read();
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
-
data = parser.get_node_data().to_double();
}
} else if (parser.get_node_name() == "float2") {
-
Vector<float> v2 = _read_float_array(parser);
if (v2.size() >= 2) {
-
data = Vector2(v2[0], v2[1]);
}
} else if (parser.get_node_name() == "float3") {
-
Vector<float> v3 = _read_float_array(parser);
if (v3.size() >= 3) {
-
data = Vector3(v3[0], v3[1], v3[2]);
}
} else if (parser.get_node_name() == "float4") {
-
Vector<float> v4 = _read_float_array(parser);
if (v4.size() >= 4) {
-
data = Color(v4[0], v4[1], v4[2], v4[3]);
}
} else if (parser.get_node_name() == "sampler2D") {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "source") {
-
parser.read();
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
-
data = parser.get_node_data();
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "sampler2D")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "sampler2D") {
break;
+ }
}
} else if (parser.get_node_name() == "surface") {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "init_from") {
-
parser.read();
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
-
data = parser.get_node_data();
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "surface")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "surface") {
break;
+ }
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == from)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == from) {
break;
+ }
}
COLLADA_PRINT("newparam ending " + parser.get_node_name());
@@ -562,23 +529,20 @@ Variant Collada::_parse_param(XMLParser &parser) {
}
void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &id) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
// first come the tags we descend, but ignore the top-levels
COLLADA_PRINT("node name: " + parser.get_node_name());
if (!parser.is_empty() && (parser.get_node_name() == "profile_COMMON" || parser.get_node_name() == "technique" || parser.get_node_name() == "extra")) {
-
_parse_effect_material(parser, effect, id); // try again
} else if (parser.get_node_name() == "newparam") {
@@ -591,45 +555,39 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &
parser.get_node_name() == "lambert" ||
parser.get_node_name() == "phong" ||
parser.get_node_name() == "blinn") {
-
COLLADA_PRINT("shade model: " + parser.get_node_name());
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String what = parser.get_node_name();
if (what == "emission" ||
what == "diffuse" ||
what == "specular" ||
what == "reflective") {
-
// color or texture types
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "color") {
-
Vector<float> colorarr = _read_float_array(parser);
COLLADA_PRINT("colorarr size: " + rtos(colorarr.size()));
if (colorarr.size() >= 3) {
-
// alpha strangely not alright? maybe it needs to be multiplied by value as a channel intensity
Color color(colorarr[0], colorarr[1], colorarr[2], 1.0);
- if (what == "diffuse")
+ if (what == "diffuse") {
effect.diffuse.color = color;
- if (what == "specular")
+ }
+ if (what == "specular") {
effect.specular.color = color;
- if (what == "emission")
+ }
+ if (what == "emission") {
effect.emission.color = color;
+ }
COLLADA_PRINT(what + " color: " + color);
}
} else if (parser.get_node_name() == "texture") {
-
String sampler = parser.get_attribute_value("texture");
if (!effect.params.has(sampler)) {
ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data());
@@ -658,11 +616,13 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &
COLLADA_PRINT(what + " texture: " + uri);
}
}
- } else if (!parser.is_empty())
+ } else if (!parser.is_empty()) {
parser.skip_section();
+ }
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == what)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == what) {
break;
+ }
}
} else if (what == "shininess") {
@@ -671,8 +631,9 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && (parser.get_node_name() == "constant" ||
parser.get_node_name() == "lambert" ||
parser.get_node_name() == "phong" ||
- parser.get_node_name() == "blinn"))
+ parser.get_node_name() == "blinn")) {
break;
+ }
}
} else if (parser.get_node_name() == "double_sided" || parser.get_node_name() == "show_double_sided") { // colladamax / google earth
@@ -685,14 +646,10 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &
parser.read();
effect.unshaded = parser.get_node_data().to_int();
} else if (parser.get_node_name() == "bump") {
-
// color or texture types
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "texture") {
-
String sampler = parser.get_attribute_value("texture");
if (!effect.params.has(sampler)) {
ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data());
@@ -712,37 +669,42 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &
COLLADA_PRINT(" bump: " + uri);
}
}
- } else if (!parser.is_empty())
+ } else if (!parser.is_empty()) {
parser.skip_section();
+ }
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "bump")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "bump") {
break;
+ }
}
- } else if (!parser.is_empty())
+ } else if (!parser.is_empty()) {
parser.skip_section();
+ }
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END &&
(parser.get_node_name() == "effect" ||
parser.get_node_name() == "profile_COMMON" ||
parser.get_node_name() == "technique" ||
- parser.get_node_name() == "extra"))
+ parser.get_node_name() == "extra")) {
break;
+ }
}
}
void Collada::_parse_effect(XMLParser &parser) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
String id = parser.get_attribute_value("id");
Effect effect;
- if (parser.has_attribute("name"))
+ if (parser.has_attribute("name")) {
effect.name = parser.get_attribute_value("name");
+ }
_parse_effect_material(parser, effect, id);
state.effect_map[id] = effect;
@@ -751,10 +713,10 @@ void Collada::_parse_effect(XMLParser &parser) {
}
void Collada::_parse_camera(XMLParser &parser) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
@@ -764,63 +726,53 @@ void Collada::_parse_camera(XMLParser &parser) {
CameraData &camera = state.camera_data_map[id];
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "perspective") {
-
camera.mode = CameraData::MODE_PERSPECTIVE;
} else if (name == "orthographic") {
-
camera.mode = CameraData::MODE_ORTHOGONAL;
} else if (name == "xfov") {
-
parser.read();
camera.perspective.x_fov = parser.get_node_data().to_double();
} else if (name == "yfov") {
-
parser.read();
camera.perspective.y_fov = parser.get_node_data().to_double();
} else if (name == "xmag") {
-
parser.read();
camera.orthogonal.x_mag = parser.get_node_data().to_double();
} else if (name == "ymag") {
-
parser.read();
camera.orthogonal.y_mag = parser.get_node_data().to_double();
} else if (name == "aspect_ratio") {
-
parser.read();
camera.aspect = parser.get_node_data().to_double();
} else if (name == "znear") {
-
parser.read();
camera.z_near = parser.get_node_data().to_double();
} else if (name == "zfar") {
-
parser.read();
camera.z_far = parser.get_node_data().to_double();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "camera")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "camera") {
break; //end of <asset>
+ }
}
COLLADA_PRINT("Camera ID:" + id);
}
void Collada::_parse_light(XMLParser &parser) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
@@ -830,25 +782,18 @@ void Collada::_parse_light(XMLParser &parser) {
LightData &light = state.light_data_map[id];
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "ambient") {
-
light.mode = LightData::MODE_AMBIENT;
} else if (name == "directional") {
-
light.mode = LightData::MODE_DIRECTIONAL;
} else if (name == "point") {
-
light.mode = LightData::MODE_OMNI;
} else if (name == "spot") {
-
light.mode = LightData::MODE_SPOT;
} else if (name == "color") {
-
parser.read();
Vector<float> colorarr = _read_float_array(parser);
COLLADA_PRINT("colorarr size: " + rtos(colorarr.size()));
@@ -860,40 +805,36 @@ void Collada::_parse_light(XMLParser &parser) {
}
} else if (name == "constant_attenuation") {
-
parser.read();
light.constant_att = parser.get_node_data().to_double();
} else if (name == "linear_attenuation") {
-
parser.read();
light.linear_att = parser.get_node_data().to_double();
} else if (name == "quadratic_attenuation") {
-
parser.read();
light.quad_att = parser.get_node_data().to_double();
} else if (name == "falloff_angle") {
-
parser.read();
light.spot_angle = parser.get_node_data().to_double();
} else if (name == "falloff_exponent") {
-
parser.read();
light.spot_exp = parser.get_node_data().to_double();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "light")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "light") {
break; //end of <asset>
+ }
}
COLLADA_PRINT("Light ID:" + id);
}
void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_name) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
@@ -914,13 +855,10 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "source") {
-
String id = parser.get_attribute_value("id");
curvedata.sources[id] = CurveData::Source();
current_source = id;
@@ -929,14 +867,12 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam
} else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (curvedata.sources.has(current_source)) {
-
curvedata.sources[current_source].array = _read_float_array(parser);
COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values.");
}
} else if (section == "Name_array") {
// create a new array and read it.
if (curvedata.sources.has(current_source)) {
-
curvedata.sources[current_source].sarray = _read_string_array(parser);
COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values.");
}
@@ -950,13 +886,9 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam
COLLADA_PRINT("section: " + current_source + " stride " + itos(curvedata.sources[current_source].stride));
}
} else if (section == "control_vertices") {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "input") {
-
String semantic = parser.get_attribute_value("semantic");
String source = _uri_to_id(parser.get_attribute_value("source"));
@@ -964,24 +896,25 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam
COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) {
break;
+ }
}
} else if (!parser.is_empty()) {
-
parser.skip_section();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "spline")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "spline") {
break;
+ }
}
}
void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name) {
-
if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
@@ -1002,13 +935,10 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "source") {
-
String id = parser.get_attribute_value("id");
meshdata.sources[id] = MeshData::Source();
current_source = id;
@@ -1017,7 +947,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
} else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (meshdata.sources.has(current_source)) {
-
meshdata.sources[current_source].array = _read_float_array(parser);
COLLADA_PRINT("section: " + current_source + " read " + itos(meshdata.sources[current_source].array.size()) + " values.");
}
@@ -1030,16 +959,12 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
COLLADA_PRINT("section: " + current_source + " stride " + itos(meshdata.sources[current_source].stride));
}
} else if (section == "vertices") {
-
MeshData::Vertices vert;
String id = parser.get_attribute_value("id");
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "input") {
-
String semantic = parser.get_attribute_value("semantic");
String source = _uri_to_id(parser.get_attribute_value("source"));
@@ -1047,32 +972,30 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) {
break;
+ }
}
meshdata.vertices[id] = vert;
} else if (section == "triangles" || section == "polylist" || section == "polygons") {
-
bool polygons = (section == "polygons");
if (polygons) {
WARN_PRINT("Primitive type \"polygons\" is not well supported (concave shapes may fail). To ensure that the geometry is properly imported, please re-export using \"triangles\" or \"polylist\".");
}
MeshData::Primitives prim;
- if (parser.has_attribute("material"))
+ if (parser.has_attribute("material")) {
prim.material = parser.get_attribute_value("material");
+ }
prim.count = parser.get_attribute_value("count").to_int();
prim.vertex_size = 0;
int last_ref = 0;
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "input") {
-
String semantic = parser.get_attribute_value("semantic");
String source = _uri_to_id(parser.get_attribute_value("source"));
@@ -1098,13 +1021,13 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
Vector<float> values = _read_float_array(parser);
if (polygons) {
-
ERR_CONTINUE(prim.vertex_size == 0);
prim.polygons.push_back(values.size() / prim.vertex_size);
int from = prim.indices.size();
prim.indices.resize(from + values.size());
- for (int i = 0; i < values.size(); i++)
+ for (int i = 0; i < values.size(); i++) {
prim.indices.write[from + i] = values[i];
+ }
} else if (prim.vertex_size > 0) {
prim.indices = values;
@@ -1118,14 +1041,14 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
prim.polygons = values;
COLLADA_PRINT("read " + itos(values.size()) + " polygon values");
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) {
break;
+ }
}
meshdata.primitives.push_back(prim);
} else if (parser.get_node_name() == "double_sided") {
-
parser.read();
meshdata.found_double_sided = true;
meshdata.double_sided = parser.get_node_data().to_int();
@@ -1133,16 +1056,15 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name
} else if (parser.get_node_name() == "polygons") {
ERR_PRINT("Primitive type \"polygons\" not supported, re-export using \"polylist\" or \"triangles\".");
} else if (!parser.is_empty()) {
-
parser.skip_section();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "mesh")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "mesh") {
break;
+ }
}
}
void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
-
state.skin_controller_data_map[p_id] = SkinControllerData();
SkinControllerData &skindata = state.skin_controller_data_map[p_id];
@@ -1151,13 +1073,10 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
String current_source;
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "bind_shape_matrix") {
-
skindata.bind_shape = _read_transform(parser);
#ifdef COLLADA_IMPORT_SCALE_SCENE
skindata.bind_shape.origin *= state.unit_scale;
@@ -1166,7 +1085,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
COLLADA_PRINT("skeleton bind shape transform: " + skindata.bind_shape);
} else if (section == "source") {
-
String id = parser.get_attribute_value("id");
skindata.sources[id] = SkinControllerData::Source();
current_source = id;
@@ -1175,22 +1093,22 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
} else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (skindata.sources.has(current_source)) {
-
skindata.sources[current_source].array = _read_float_array(parser);
COLLADA_PRINT("section: " + current_source + " read " + itos(skindata.sources[current_source].array.size()) + " values.");
}
} else if (section == "Name_array" || section == "IDREF_array") {
// create a new array and read it.
- if (section == "IDREF_array")
+ if (section == "IDREF_array") {
skindata.use_idrefs = true;
+ }
if (skindata.sources.has(current_source)) {
-
skindata.sources[current_source].sarray = _read_string_array(parser);
if (section == "IDREF_array") {
Vector<String> sa = skindata.sources[current_source].sarray;
- for (int i = 0; i < sa.size(); i++)
+ for (int i = 0; i < sa.size(); i++) {
state.idref_joints.insert(sa[i]);
+ }
}
COLLADA_PRINT("section: " + current_source + " read " + itos(skindata.sources[current_source].array.size()) + " values.");
}
@@ -1199,25 +1117,21 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
} else if (section == "accessor") { // child of source (below a technique tag)
if (skindata.sources.has(current_source)) {
-
int stride = 1;
- if (parser.has_attribute("stride"))
+ if (parser.has_attribute("stride")) {
stride = parser.get_attribute_value("stride").to_int();
+ }
skindata.sources[current_source].stride = stride;
COLLADA_PRINT("section: " + current_source + " stride " + itos(skindata.sources[current_source].stride));
}
} else if (section == "joints") {
-
SkinControllerData::Joints joint;
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "input") {
-
String semantic = parser.get_attribute_value("semantic");
String source = _uri_to_id(parser.get_attribute_value("source"));
@@ -1225,24 +1139,21 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) {
break;
+ }
}
skindata.joints = joint;
} else if (section == "vertex_weights") {
-
SkinControllerData::Weights weights;
weights.count = parser.get_attribute_value("count").to_int();
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "input") {
-
String semantic = parser.get_attribute_value("semantic");
String source = _uri_to_id(parser.get_attribute_value("source"));
@@ -1267,8 +1178,9 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
weights.sets = values;
COLLADA_PRINT("read " + itos(values.size()) + " polygon values");
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) {
break;
+ }
}
skindata.weights = weights;
@@ -1278,8 +1190,9 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
parser.skip_section();
*/
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin") {
break;
+ }
}
/* STORE REST MATRICES */
@@ -1300,7 +1213,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
ERR_FAIL_COND(joint_source.sarray.size() != ibm_source.array.size() / 16);
for (int i = 0; i < joint_source.sarray.size(); i++) {
-
String name = joint_source.sarray[i];
Transform xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices
xform.affine_invert(); // inverse for rest, because it's an inverse
@@ -1312,7 +1224,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
}
void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
-
state.morph_controller_data_map[p_id] = MorphControllerData();
MorphControllerData &morphdata = state.morph_controller_data_map[p_id];
@@ -1321,13 +1232,10 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
String current_source;
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "source") {
-
String id = parser.get_attribute_value("id");
morphdata.sources[id] = MorphControllerData::Source();
current_source = id;
@@ -1336,7 +1244,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
} else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (morphdata.sources.has(current_source)) {
-
morphdata.sources[current_source].array = _read_float_array(parser);
COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values.");
}
@@ -1348,7 +1255,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
morphdata.use_idrefs=true;
*/
if (morphdata.sources.has(current_source)) {
-
morphdata.sources[current_source].sarray = _read_string_array(parser);
/*
if (section=="IDREF_array") {
@@ -1363,23 +1269,19 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
} else if (section == "accessor") { // child of source (below a technique tag)
if (morphdata.sources.has(current_source)) {
-
int stride = 1;
- if (parser.has_attribute("stride"))
+ if (parser.has_attribute("stride")) {
stride = parser.get_attribute_value("stride").to_int();
+ }
morphdata.sources[current_source].stride = stride;
COLLADA_PRINT("section: " + current_source + " stride " + itos(morphdata.sources[current_source].stride));
}
} else if (section == "targets") {
-
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "input") {
-
String semantic = parser.get_attribute_value("semantic");
String source = _uri_to_id(parser.get_attribute_value("source"));
@@ -1387,8 +1289,9 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) {
break;
+ }
}
}
/*
@@ -1396,18 +1299,17 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
parser.skip_section();
*/
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph") {
break;
+ }
}
if (morphdata.targets.has("MORPH_WEIGHT")) {
-
state.morph_name_map[morphdata.targets["MORPH_WEIGHT"]] = p_id;
}
}
void Collada::_parse_controller(XMLParser &parser) {
-
String id = parser.get_attribute_value("id");
if (parser.is_empty()) {
@@ -1415,9 +1317,7 @@ void Collada::_parse_controller(XMLParser &parser) {
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "skin") {
@@ -1425,27 +1325,25 @@ void Collada::_parse_controller(XMLParser &parser) {
} else if (section == "morph") {
_parse_morph_controller(parser, id);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "controller")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "controller") {
break;
+ }
}
}
Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) {
-
String type = parser.get_node_name();
NodeGeometry *geom = memnew(NodeGeometry);
geom->controller = type == "instance_controller";
geom->source = _uri_to_id(parser.get_attribute_value_safe("url"));
- if (parser.is_empty()) //nothing else to parse...
+ if (parser.is_empty()) { //nothing else to parse...
return geom;
+ }
// try to find also many materials and skeletons!
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "instance_material") {
-
String symbol = parser.get_attribute_value("symbol");
String target = _uri_to_id(parser.get_attribute_value("target"));
@@ -1454,7 +1352,6 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) {
geom->material_map[symbol] = mat;
COLLADA_PRINT("uses material: '" + target + "' on primitive'" + symbol + "'");
} else if (parser.get_node_name() == "skeleton") {
-
parser.read();
String uri = _uri_to_id(parser.get_node_data());
if (uri != "") {
@@ -1462,12 +1359,12 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) {
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == type)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == type) {
break;
+ }
}
if (geom->controller) {
-
if (geom->skeletons.empty()) {
//XSI style
@@ -1487,72 +1384,72 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) {
}
Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) {
-
NodeCamera *cam = memnew(NodeCamera);
cam->camera = _uri_to_id(parser.get_attribute_value_safe("url"));
- if (state.up_axis == Vector3::AXIS_Z) //collada weirdness
+ if (state.up_axis == Vector3::AXIS_Z) { //collada weirdness
cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
+ }
- if (parser.is_empty()) //nothing else to parse...
+ if (parser.is_empty()) { //nothing else to parse...
return cam;
+ }
while (parser.read() == OK) {
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_camera")
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_camera") {
break;
+ }
}
return cam;
}
Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) {
-
NodeLight *cam = memnew(NodeLight);
cam->light = _uri_to_id(parser.get_attribute_value_safe("url"));
- if (state.up_axis == Vector3::AXIS_Z) //collada weirdness
+ if (state.up_axis == Vector3::AXIS_Z) { //collada weirdness
cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
+ }
- if (parser.is_empty()) //nothing else to parse...
+ if (parser.is_empty()) { //nothing else to parse...
return cam;
+ }
while (parser.read() == OK) {
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_light")
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_light") {
break;
+ }
}
return cam;
}
Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) {
-
String instance_type = parser.get_node_name();
if (instance_type == "instance_geometry" || instance_type == "instance_controller") {
return _parse_visual_instance_geometry(parser);
} else if (instance_type == "instance_camera") {
-
return _parse_visual_instance_camera(parser);
} else if (instance_type == "instance_light") {
return _parse_visual_instance_light(parser);
}
- if (parser.is_empty()) //nothing else to parse...
+ if (parser.is_empty()) { //nothing else to parse...
return nullptr;
+ }
while (parser.read() == OK) {
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == instance_type)
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == instance_type) {
break;
+ }
}
return nullptr;
}
Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
-
String name;
String id = parser.get_attribute_value_safe("id");
@@ -1560,7 +1457,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
bool found_name = false;
if (id == "") {
-
id = "%NODEID%" + itos(Math::rand());
} else {
@@ -1576,7 +1472,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
name = parser.has_attribute("name") ? parser.get_attribute_value_safe("name") : parser.get_attribute_value_safe("id");
if (name == "") {
-
name = id;
} else {
found_name = true;
@@ -1604,9 +1499,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "translate") {
@@ -1657,8 +1550,9 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
xf.data = matrix;
String mtx;
- for (int i = 0; i < matrix.size(); i++)
+ for (int i = 0; i < matrix.size(); i++) {
mtx += " " + rtos(matrix[i]);
+ }
xform_list.push_back(xf);
@@ -1678,13 +1572,10 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
} else if (section == "empty_draw_type") {
empty_draw_type = _read_empty_draw_type(parser);
} else if (section == "technique" || section == "extra") {
-
} else if (section != "node") {
//usually what defines the type of node
if (section.begins_with("instance_")) {
-
if (!node) {
-
node = _parse_visual_node_instance_data(parser);
} else {
@@ -1693,19 +1584,18 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
}
} else {
-
/* Found a child node!! what to do..*/
Node *child = _parse_visual_scene_node(parser);
children.push_back(child);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "node")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "node") {
break;
+ }
}
if (!node) {
-
node = memnew(Node); //generic node, nothing of relevance found
}
@@ -1734,7 +1624,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
}
void Collada::_parse_visual_scene(XMLParser &parser) {
-
String id = parser.get_attribute_value("id");
if (parser.is_empty()) {
@@ -1744,31 +1633,31 @@ void Collada::_parse_visual_scene(XMLParser &parser) {
state.visual_scene_map[id] = VisualScene();
VisualScene &vscene = state.visual_scene_map[id];
- if (parser.has_attribute("name"))
+ if (parser.has_attribute("name")) {
vscene.name = parser.get_attribute_value("name");
+ }
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String section = parser.get_node_name();
if (section == "node") {
vscene.root_nodes.push_back(_parse_visual_scene_node(parser));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "visual_scene")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "visual_scene") {
break;
+ }
}
COLLADA_PRINT("Scene ID:" + id);
}
void Collada::_parse_animation(XMLParser &parser) {
-
if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
@@ -1781,8 +1670,9 @@ void Collada::_parse_animation(XMLParser &parser) {
Map<String, Vector<String>> source_param_types;
String id = "";
- if (parser.has_attribute("id"))
+ if (parser.has_attribute("id")) {
id = parser.get_attribute_value("id");
+ }
String current_source;
String current_sampler;
@@ -1790,67 +1680,58 @@ void Collada::_parse_animation(XMLParser &parser) {
Vector<String> channel_targets;
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "source") {
-
current_source = parser.get_attribute_value("id");
source_param_names[current_source] = Vector<String>();
source_param_types[current_source] = Vector<String>();
} else if (name == "float_array") {
-
if (current_source != "") {
float_sources[current_source] = _read_float_array(parser);
}
} else if (name == "Name_array") {
-
if (current_source != "") {
string_sources[current_source] = _read_string_array(parser);
}
} else if (name == "accessor") {
-
if (current_source != "" && parser.has_attribute("stride")) {
source_strides[current_source] = parser.get_attribute_value("stride").to_int();
}
} else if (name == "sampler") {
-
current_sampler = parser.get_attribute_value("id");
samplers[current_sampler] = Map<String, String>();
} else if (name == "param") {
-
- if (parser.has_attribute("name"))
+ if (parser.has_attribute("name")) {
source_param_names[current_source].push_back(parser.get_attribute_value("name"));
- else
+ } else {
source_param_names[current_source].push_back("");
+ }
- if (parser.has_attribute("type"))
+ if (parser.has_attribute("type")) {
source_param_types[current_source].push_back(parser.get_attribute_value("type"));
- else
+ } else {
source_param_types[current_source].push_back("");
+ }
} else if (name == "input") {
-
if (current_sampler != "") {
-
samplers[current_sampler][parser.get_attribute_value("semantic")] = parser.get_attribute_value("source");
}
} else if (name == "channel") {
-
channel_sources.push_back(parser.get_attribute_value("source"));
channel_targets.push_back(parser.get_attribute_value("target"));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation") {
break; //end of <asset>
+ }
}
for (int i = 0; i < channel_sources.size(); i++) {
-
String source = _uri_to_id(channel_sources[i]);
String target = channel_targets[i];
ERR_CONTINUE(!samplers.has(source));
@@ -1870,7 +1751,6 @@ void Collada::_parse_animation(XMLParser &parser) {
Vector<String> &names = source_param_names[output_id];
for (int l = 0; l < names.size(); l++) {
-
String name = names[l];
Vector<float> &time_keys = float_sources[input_id];
@@ -1890,8 +1770,9 @@ void Collada::_parse_animation(XMLParser &parser) {
int stride = 1;
- if (source_strides.has(output_id))
+ if (source_strides.has(output_id)) {
stride = source_strides[output_id];
+ }
int output_len = stride / names.size();
ERR_CONTINUE(output_len == 0);
@@ -1903,22 +1784,23 @@ void Collada::_parse_animation(XMLParser &parser) {
for (int j = 0; j < key_count; j++) {
track.keys.write[j].data.resize(output_len);
- for (int k = 0; k < output_len; k++)
+ for (int k = 0; k < output_len; k++) {
track.keys.write[j].data.write[k] = output[l + j * stride + k]; //super weird but should work:
+ }
}
if (sampler.has("INTERPOLATION")) {
-
String interp_id = _uri_to_id(sampler["INTERPOLATION"]);
ERR_CONTINUE(!string_sources.has(interp_id));
Vector<String> &interps = string_sources[interp_id];
ERR_CONTINUE(interps.size() != key_count);
for (int j = 0; j < key_count; j++) {
- if (interps[j] == "BEZIER")
+ if (interps[j] == "BEZIER") {
track.keys.write[j].interp_type = AnimationTrack::INTERP_BEZIER;
- else
+ } else {
track.keys.write[j].interp_type = AnimationTrack::INTERP_LINEAR;
+ }
}
}
@@ -1944,8 +1826,9 @@ void Collada::_parse_animation(XMLParser &parser) {
if (target.find("/") != -1) { //transform component
track.target = target.get_slicec('/', 0);
track.param = target.get_slicec('/', 1);
- if (track.param.find(".") != -1)
+ if (track.param.find(".") != -1) {
track.component = track.param.get_slice(".", 1).to_upper();
+ }
track.param = track.param.get_slice(".", 0);
if (names.size() > 1 && track.component == "") {
//this is a guess because the collada spec is ambiguous here...
@@ -1958,14 +1841,16 @@ void Collada::_parse_animation(XMLParser &parser) {
state.animation_tracks.push_back(track);
- if (!state.referenced_tracks.has(target))
+ if (!state.referenced_tracks.has(target)) {
state.referenced_tracks[target] = Vector<int>();
+ }
state.referenced_tracks[target].push_back(state.animation_tracks.size() - 1);
if (id != "") {
- if (!state.by_id_tracks.has(id))
+ if (!state.by_id_tracks.has(id)) {
state.by_id_tracks[id] = Vector<int>();
+ }
state.by_id_tracks[id].push_back(state.animation_tracks.size() - 1);
}
@@ -1976,158 +1861,138 @@ void Collada::_parse_animation(XMLParser &parser) {
}
void Collada::_parse_animation_clip(XMLParser &parser) {
-
if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) {
- if (!parser.is_empty())
+ if (!parser.is_empty()) {
parser.skip_section();
+ }
return;
}
AnimationClip clip;
- if (parser.has_attribute("name"))
+ if (parser.has_attribute("name")) {
clip.name = parser.get_attribute_value("name");
- else if (parser.has_attribute("id"))
+ } else if (parser.has_attribute("id")) {
clip.name = parser.get_attribute_value("id");
- if (parser.has_attribute("start"))
+ }
+ if (parser.has_attribute("start")) {
clip.begin = parser.get_attribute_value("start").to_double();
- if (parser.has_attribute("end"))
+ }
+ if (parser.has_attribute("end")) {
clip.end = parser.get_attribute_value("end").to_double();
+ }
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "instance_animation") {
-
String url = _uri_to_id(parser.get_attribute_value("url"));
clip.tracks.push_back(url);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation_clip")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation_clip") {
break; //end of <asset>
+ }
}
state.animation_clips.push_back(clip);
}
void Collada::_parse_scene(XMLParser &parser) {
-
if (parser.is_empty()) {
return;
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
if (name == "instance_visual_scene") {
-
state.root_visual_scene = _uri_to_id(parser.get_attribute_value("url"));
} else if (name == "instance_physics_scene") {
-
state.root_physics_scene = _uri_to_id(parser.get_attribute_value("url"));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "scene")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "scene") {
break; //end of <asset>
+ }
}
}
void Collada::_parse_library(XMLParser &parser) {
-
if (parser.is_empty()) {
return;
}
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
String name = parser.get_node_name();
COLLADA_PRINT("library name is: " + name);
if (name == "image") {
-
_parse_image(parser);
} else if (name == "material") {
-
_parse_material(parser);
} else if (name == "effect") {
-
_parse_effect(parser);
} else if (name == "camera") {
-
_parse_camera(parser);
} else if (name == "light") {
-
_parse_light(parser);
} else if (name == "geometry") {
-
String id = parser.get_attribute_value("id");
String name2 = parser.get_attribute_value_safe("name");
while (parser.read() == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "mesh") {
state.mesh_name_map[id] = (name2 != "") ? name2 : id;
_parse_mesh_geometry(parser, id, name2);
} else if (parser.get_node_name() == "spline") {
state.mesh_name_map[id] = (name2 != "") ? name2 : id;
_parse_curve_geometry(parser, id, name2);
- } else if (!parser.is_empty())
+ } else if (!parser.is_empty()) {
parser.skip_section();
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "geometry")
+ }
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "geometry") {
break;
+ }
}
} else if (name == "controller") {
-
_parse_controller(parser);
} else if (name == "animation") {
-
_parse_animation(parser);
} else if (name == "animation_clip") {
-
_parse_animation_clip(parser);
} else if (name == "visual_scene") {
-
COLLADA_PRINT("visual scene");
_parse_visual_scene(parser);
- } else if (!parser.is_empty())
+ } else if (!parser.is_empty()) {
parser.skip_section();
+ }
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name().begins_with("library_"))
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name().begins_with("library_")) {
break; //end of <asset>
+ }
}
}
void Collada::_joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner) {
-
if (p_node->type == Node::TYPE_JOINT) {
-
NodeJoint *nj = static_cast<NodeJoint *>(p_node);
nj->owner = p_owner;
for (int i = 0; i < nj->children.size(); i++) {
-
_joint_set_owner(nj->children.write[i], p_owner);
}
}
}
void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton) {
-
Node *node = *p_node;
if (node->type == Node::TYPE_JOINT) {
-
if (!p_skeleton) {
-
// ohohohoohoo it's a joint node, time to work!
NodeSkeleton *sk = memnew(NodeSkeleton);
*p_node = sk;
@@ -2149,47 +2014,41 @@ void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton
}
bool Collada::_remove_node(Node *p_parent, Node *p_node) {
-
for (int i = 0; i < p_parent->children.size(); i++) {
-
if (p_parent->children[i] == p_node) {
p_parent->children.remove(i);
return true;
}
- if (_remove_node(p_parent->children[i], p_node))
+ if (_remove_node(p_parent->children[i], p_node)) {
return true;
+ }
}
return false;
}
void Collada::_remove_node(VisualScene *p_vscene, Node *p_node) {
-
for (int i = 0; i < p_vscene->root_nodes.size(); i++) {
if (p_vscene->root_nodes[i] == p_node) {
-
p_vscene->root_nodes.remove(i);
return;
}
- if (_remove_node(p_vscene->root_nodes[i], p_node))
+ if (_remove_node(p_vscene->root_nodes[i], p_node)) {
return;
+ }
}
ERR_PRINT("ERROR: Not found node to remove?");
}
void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
-
if (p_node->type == Node::TYPE_GEOMETRY) {
-
NodeGeometry *gnode = static_cast<NodeGeometry *>(p_node);
if (gnode->controller) {
-
// recount skeletons used
Set<NodeSkeleton *> skeletons;
for (int i = 0; i < gnode->skeletons.size(); i++) {
-
String nodeid = gnode->skeletons[i];
ERR_CONTINUE(!state.scene_map.has(nodeid)); //weird, it should have it...
@@ -2206,17 +2065,14 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
}
if (skeletons.size() > 1) {
-
//do the merger!!
Set<NodeSkeleton *>::Element *E = skeletons.front();
NodeSkeleton *base = E->get();
for (E = E->next(); E; E = E->next()) {
-
NodeSkeleton *merged = E->get();
_remove_node(p_vscene, merged);
for (int i = 0; i < merged->children.size(); i++) {
-
_joint_set_owner(merged->children[i], base);
base->children.push_back(merged->children[i]);
merged->children[i]->parent = base;
@@ -2235,15 +2091,12 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
}
void Collada::_merge_skeletons2(VisualScene *p_vscene) {
-
for (Map<String, SkinControllerData>::Element *E = state.skin_controller_data_map.front(); E; E = E->next()) {
-
SkinControllerData &cd = E->get();
NodeSkeleton *skeleton = nullptr;
for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) {
-
String name;
if (!state.sid_to_node_map.has(F->key())) {
@@ -2260,7 +2113,6 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
NodeSkeleton *sk = nullptr;
while (node && !sk) {
-
if (node->type == Node::TYPE_SKELETON) {
sk = static_cast<NodeSkeleton *>(node);
}
@@ -2278,7 +2130,6 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
//whoa.. wtf, merge.
_remove_node(p_vscene, sk);
for (int i = 0; i < sk->children.size(); i++) {
-
_joint_set_owner(sk->children[i], skeleton);
skeleton->children.push_back(sk->children[i]);
sk->children[i]->parent = skeleton;
@@ -2292,7 +2143,6 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
}
bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) {
-
Node *node = p_node;
if (node->type == Node::TYPE_SKELETON && node->parent && node->parent->type == Node::TYPE_NODE && node->parent->children.size() == 1) {
@@ -2312,7 +2162,6 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) {
Node *gp = parent->parent;
bool found = false;
for (int i = 0; i < gp->children.size(); i++) {
-
if (gp->children[i] == parent) {
gp->children.write[i] = node;
found = true;
@@ -2323,13 +2172,10 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) {
ERR_PRINT("BUG");
}
} else {
-
bool found = false;
for (int i = 0; i < p_vscene->root_nodes.size(); i++) {
-
if (p_vscene->root_nodes[i] == parent) {
-
p_vscene->root_nodes.write[i] = node;
found = true;
break;
@@ -2346,27 +2192,25 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) {
}
for (int i = 0; i < node->children.size(); i++) {
-
- if (_optimize_skeletons(p_vscene, node->children[i]))
+ if (_optimize_skeletons(p_vscene, node->children[i])) {
return false; //stop processing, go up
+ }
}
return false;
}
bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, List<Node *> *p_mgeom) {
-
// Bind Shape Matrix scales the bones and makes them gigantic, so the matrix then shrinks the model?
// Solution: apply the Bind Shape Matrix to the VERTICES, and if the object comes scaled, it seems to be left alone!
if (p_node->type == Node::TYPE_GEOMETRY) {
-
NodeGeometry *ng = static_cast<NodeGeometry *>(p_node);
- if (ng->ignore_anim)
+ if (ng->ignore_anim) {
return false; //already made child of skeleton and processeg
+ }
if (ng->controller && ng->skeletons.size()) {
-
String nodeid = ng->skeletons[0];
ERR_FAIL_COND_V(!state.scene_map.has(nodeid), false); //weird, it should have it...
@@ -2401,7 +2245,6 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
//make rests relative to the skeleton (they seem to be always relative to world)
for (Map<String, Transform>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) {
-
E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton
state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative
}
@@ -2419,7 +2262,6 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
}
for (int i = 0; i < p_node->children.size(); i++) {
-
if (_move_geometry_to_skeletons(p_vscene, p_node->children[i], p_mgeom)) {
p_node->children.remove(i);
i--;
@@ -2430,23 +2272,17 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L
}
void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) {
-
if (p_node->type == Node::TYPE_GEOMETRY) {
-
NodeGeometry *nj = static_cast<NodeGeometry *>(p_node);
if (nj->controller) {
-
String base = nj->source;
while (base != "" && !state.mesh_data_map.has(base)) {
-
if (state.skin_controller_data_map.has(base)) {
-
SkinControllerData &sk = state.skin_controller_data_map[base];
base = sk.base;
} else if (state.morph_controller_data_map.has(base)) {
-
state.morph_ownership_map[base] = nj->id;
break;
} else {
@@ -2457,15 +2293,12 @@ void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) {
}
for (int i = 0; i < p_node->children.size(); i++) {
-
_find_morph_nodes(p_vscene, p_node->children[i]);
}
}
void Collada::_optimize() {
-
for (Map<String, VisualScene>::Element *E = state.visual_scene_map.front(); E; E = E->next()) {
-
VisualScene &vs = E->get();
for (int i = 0; i < vs.root_nodes.size(); i++) {
_create_skeletons(&vs.root_nodes.write[i]);
@@ -2482,7 +2315,6 @@ void Collada::_optimize() {
}
for (int i = 0; i < vs.root_nodes.size(); i++) {
-
List<Node *> mgeom;
if (_move_geometry_to_skeletons(&vs, vs.root_nodes[i], &mgeom)) {
vs.root_nodes.remove(i);
@@ -2490,7 +2322,6 @@ void Collada::_optimize() {
}
while (!mgeom.empty()) {
-
Node *n = mgeom.front()->get();
n->parent->children.push_back(n);
mgeom.pop_front();
@@ -2504,9 +2335,7 @@ void Collada::_optimize() {
}
int Collada::get_uv_channel(String p_name) {
-
if (!channel_map.has(p_name)) {
-
ERR_FAIL_COND_V(channel_map.size() == 2, 0);
channel_map[p_name] = channel_map.size();
@@ -2516,7 +2345,6 @@ int Collada::get_uv_channel(String p_name) {
}
Error Collada::load(const String &p_path, int p_flags) {
-
Ref<XMLParser> parserr = memnew(XMLParser);
XMLParser &parser = *parserr.ptr();
Error err = parser.open(p_path);
@@ -2526,13 +2354,12 @@ Error Collada::load(const String &p_path, int p_flags) {
state.import_flags = p_flags;
/* Skip headers */
while ((err = parser.read()) == OK) {
-
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
if (parser.get_node_name() == "COLLADA") {
break;
- } else if (!parser.is_empty())
+ } else if (!parser.is_empty()) {
parser.skip_section(); // unknown section, likely headers
+ }
}
}
@@ -2550,11 +2377,11 @@ Error Collada::load(const String &p_path, int p_flags) {
}
while ((err = parser.read()) == OK) {
-
/* Read all the main sections.. */
- if (parser.get_node_type() != XMLParser::NODE_ELEMENT)
+ if (parser.get_node_type() != XMLParser::NODE_ELEMENT) {
continue; //no idea what this may be, but skipping anyway
+ }
String section = parser.get_node_name();
@@ -2564,10 +2391,8 @@ Error Collada::load(const String &p_path, int p_flags) {
_parse_asset(parser);
} else if (section.begins_with("library_")) {
-
_parse_library(parser);
} else if (section == "scene") {
-
_parse_scene(parser);
} else if (!parser.is_empty()) {
parser.skip_section(); // unknown section, likely headers
diff --git a/editor/import/collada.h b/editor/import/collada.h
index b74332fb22..90c6c47e0b 100644
--- a/editor/import/collada.h
+++ b/editor/import/collada.h
@@ -44,82 +44,65 @@ public:
};
struct Image {
-
String path;
};
struct Material {
-
String name;
String instance_effect;
};
struct Effect {
-
String name;
Map<String, Variant> params;
struct Channel {
-
- int uv_idx;
+ int uv_idx = 0;
String texture;
Color color;
- Channel() { uv_idx = 0; }
+ Channel() {}
};
Channel diffuse, specular, emission, bump;
- float shininess;
- bool found_double_sided;
- bool double_sided;
- bool unshaded;
+ float shininess = 40;
+ bool found_double_sided = false;
+ bool double_sided = true;
+ bool unshaded = false;
String get_texture_path(const String &p_source, Collada &state) const;
Effect() {
diffuse.color = Color(1, 1, 1, 1);
- double_sided = true;
- found_double_sided = false;
- shininess = 40;
- unshaded = false;
}
};
struct CameraData {
-
enum Mode {
MODE_PERSPECTIVE,
MODE_ORTHOGONAL
};
- Mode mode;
+ Mode mode = MODE_PERSPECTIVE;
union {
struct {
- float x_fov;
- float y_fov;
+ float x_fov = 0;
+ float y_fov = 0;
} perspective;
struct {
- float x_mag;
- float y_mag;
+ float x_mag = 0;
+ float y_mag = 0;
} orthogonal;
};
- float aspect;
- float z_near;
- float z_far;
-
- CameraData() :
- mode(MODE_PERSPECTIVE),
- aspect(1),
- z_near(0.1),
- z_far(100) {
- perspective.x_fov = 0;
- perspective.y_fov = 0;
- }
+ float aspect = 1;
+ float z_near = 0.1;
+ float z_far = 100;
+
+ CameraData() {}
};
struct LightData {
-
enum Mode {
MODE_AMBIENT,
MODE_DIRECTIONAL,
@@ -127,33 +110,23 @@ public:
MODE_SPOT
};
- Mode mode;
+ Mode mode = MODE_AMBIENT;
- Color color;
+ Color color = Color(1, 1, 1, 1);
- float constant_att;
- float linear_att;
- float quad_att;
-
- float spot_angle;
- float spot_exp;
-
- LightData() :
- mode(MODE_AMBIENT),
- color(Color(1, 1, 1, 1)),
- constant_att(0),
- linear_att(0),
- quad_att(0),
- spot_angle(45),
- spot_exp(1) {
- }
+ float constant_att = 0;
+ float linear_att = 0;
+ float quad_att = 0;
+
+ float spot_angle = 45;
+ float spot_exp = 1;
+
+ LightData() {}
};
struct MeshData {
-
String name;
struct Source {
-
Vector<float> array;
int stride;
};
@@ -161,16 +134,13 @@ public:
Map<String, Source> sources;
struct Vertices {
-
Map<String, String> sources;
};
Map<String, Vertices> vertices;
struct Primitives {
-
struct SourceRef {
-
String source;
int offset;
};
@@ -185,22 +155,17 @@ public:
Vector<Primitives> primitives;
- bool found_double_sided;
- bool double_sided;
+ bool found_double_sided = false;
+ bool double_sided = true;
- MeshData() {
- found_double_sided = false;
- double_sided = true;
- }
+ MeshData() {}
};
struct CurveData {
-
String name;
- bool closed;
+ bool closed = false;
struct Source {
-
Vector<String> sarray;
Vector<float> array;
int stride;
@@ -210,39 +175,30 @@ public:
Map<String, String> control_vertices;
- CurveData() {
-
- closed = false;
- }
+ CurveData() {}
};
- struct SkinControllerData {
+ struct SkinControllerData {
String base;
- bool use_idrefs;
+ bool use_idrefs = false;
Transform bind_shape;
struct Source {
-
Vector<String> sarray; //maybe for names
Vector<float> array;
- int stride;
- Source() {
- stride = 1;
- }
+ int stride = 1;
+ Source() {}
};
Map<String, Source> sources;
struct Joints {
-
Map<String, String> sources;
} joints;
struct Weights {
-
struct SourceRef {
-
String source;
int offset;
};
@@ -256,20 +212,18 @@ public:
Map<String, Transform> bone_rest_map;
- SkinControllerData() { use_idrefs = false; }
+ SkinControllerData() {}
};
struct MorphControllerData {
-
String mesh;
String mode;
struct Source {
-
- int stride;
+ int stride = 1;
Vector<String> sarray; //maybe for names
Vector<float> array;
- Source() { stride = 1; }
+ Source() {}
};
Map<String, Source> sources;
@@ -279,15 +233,14 @@ public:
};
struct Vertex {
-
- int idx;
+ int idx = 0;
Vector3 vertex;
Vector3 normal;
Vector3 uv;
Vector3 uv2;
Plane tangent;
Color color;
- int uid;
+ int uid = 0;
struct Weight {
int bone_idx;
float weight;
@@ -297,40 +250,40 @@ public:
Vector<Weight> weights;
void fix_weights() {
-
weights.sort();
if (weights.size() > 4) {
//cap to 4 and make weights add up 1
weights.resize(4);
float total = 0;
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++) {
total += weights[i].weight;
- if (total)
- for (int i = 0; i < 4; i++)
+ }
+ if (total) {
+ for (int i = 0; i < 4; i++) {
weights.write[i].weight /= total;
+ }
+ }
}
}
void fix_unit_scale(Collada &state);
bool operator<(const Vertex &p_vert) const {
-
if (uid == p_vert.uid) {
if (vertex == p_vert.vertex) {
if (normal == p_vert.normal) {
if (uv == p_vert.uv) {
if (uv2 == p_vert.uv2) {
-
if (!weights.empty() || !p_vert.weights.empty()) {
-
if (weights.size() == p_vert.weights.size()) {
-
for (int i = 0; i < weights.size(); i++) {
- if (weights[i].bone_idx != p_vert.weights[i].bone_idx)
+ if (weights[i].bone_idx != p_vert.weights[i].bone_idx) {
return weights[i].bone_idx < p_vert.weights[i].bone_idx;
+ }
- if (weights[i].weight != p_vert.weights[i].weight)
+ if (weights[i].weight != p_vert.weights[i].weight) {
return weights[i].weight < p_vert.weights[i].weight;
+ }
}
} else {
return weights.size() < p_vert.weights.size();
@@ -338,25 +291,27 @@ public:
}
return (color < p_vert.color);
- } else
+ } else {
return (uv2 < p_vert.uv2);
- } else
+ }
+ } else {
return (uv < p_vert.uv);
- } else
+ }
+ } else {
return (normal < p_vert.normal);
- } else
+ }
+ } else {
return vertex < p_vert.vertex;
- } else
+ }
+ } else {
return uid < p_vert.uid;
+ }
}
- Vertex() {
- uid = 0;
- idx = 0;
- }
+ Vertex() {}
};
- struct Node {
+ struct Node {
enum Type {
TYPE_NODE,
@@ -368,7 +323,6 @@ public:
};
struct XForm {
-
enum Op {
OP_ROTATE,
OP_SCALE,
@@ -382,54 +336,46 @@ public:
Vector<float> data;
};
- Type type;
+ Type type = TYPE_NODE;
String name;
String id;
String empty_draw_type;
- bool noname;
+ bool noname = false;
Vector<XForm> xform_list;
Transform default_transform;
Transform post_transform;
Vector<Node *> children;
- Node *parent;
+ Node *parent = nullptr;
Transform compute_transform(Collada &state) const;
Transform get_global_transform() const;
Transform get_transform() const;
- bool ignore_anim;
+ bool ignore_anim = false;
- Node() {
- noname = false;
- type = TYPE_NODE;
- parent = nullptr;
- ignore_anim = false;
- }
+ Node() {}
virtual ~Node() {
- for (int i = 0; i < children.size(); i++)
+ for (int i = 0; i < children.size(); i++) {
memdelete(children[i]);
+ }
};
};
struct NodeSkeleton : public Node {
-
NodeSkeleton() { type = TYPE_SKELETON; }
};
struct NodeJoint : public Node {
-
- NodeSkeleton *owner;
+ NodeSkeleton *owner = nullptr;
String sid;
NodeJoint() {
type = TYPE_JOINT;
- owner = nullptr;
}
};
struct NodeGeometry : public Node {
-
bool controller;
String source;
@@ -444,50 +390,43 @@ public:
};
struct NodeCamera : public Node {
-
String camera;
NodeCamera() { type = TYPE_CAMERA; }
};
struct NodeLight : public Node {
-
String light;
NodeLight() { type = TYPE_LIGHT; }
};
struct VisualScene {
-
String name;
Vector<Node *> root_nodes;
~VisualScene() {
- for (int i = 0; i < root_nodes.size(); i++)
+ for (int i = 0; i < root_nodes.size(); i++) {
memdelete(root_nodes[i]);
+ }
}
};
struct AnimationClip {
-
String name;
- float begin;
- float end;
+ float begin = 0;
+ float end = 1;
Vector<String> tracks;
- AnimationClip() {
- begin = 0;
- end = 1;
- }
+ AnimationClip() {}
};
struct AnimationTrack {
-
String id;
String target;
String param;
String component;
- bool property;
+ bool property = false;
enum InterpolationType {
INTERP_LINEAR,
@@ -495,7 +434,6 @@ public:
};
struct Key {
-
enum Type {
TYPE_FLOAT,
TYPE_MATRIX
@@ -505,16 +443,16 @@ public:
Vector<float> data;
Point2 in_tangent;
Point2 out_tangent;
- InterpolationType interp_type;
+ InterpolationType interp_type = INTERP_LINEAR;
- Key() { interp_type = INTERP_LINEAR; }
+ Key() {}
};
Vector<float> get_value_at_time(float p_time) const;
Vector<Key> keys;
- AnimationTrack() { property = false; }
+ AnimationTrack() {}
};
/****************/
@@ -522,15 +460,13 @@ public:
/****************/
struct State {
+ int import_flags = 0;
- int import_flags;
-
- float unit_scale;
- Vector3::Axis up_axis;
+ float unit_scale = 1.0;
+ Vector3::Axis up_axis = Vector3::AXIS_Y;
bool z_up;
struct Version {
-
int major, minor, rev;
bool operator<(const Version &p_ver) const { return (major == p_ver.major) ? ((minor == p_ver.minor) ? (rev < p_ver.rev) : minor < p_ver.minor) : major < p_ver.major; }
@@ -573,14 +509,9 @@ public:
Map<String, Vector<int>> referenced_tracks;
Map<String, Vector<int>> by_id_tracks;
- float animation_length;
+ float animation_length = 0;
- State() :
- import_flags(0),
- unit_scale(1.0),
- up_axis(Vector3::AXIS_Y),
- animation_length(0) {
- }
+ State() {}
} state;
Error load(const String &p_path, int p_flags = 0);
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 697ddfba96..12cbaaa885 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -45,7 +45,6 @@
#include "scene/resources/surface_tool.h"
struct ColladaImport {
-
Collada collada;
Node3D *scene;
@@ -101,7 +100,6 @@ struct ColladaImport {
void _pre_process_lights(Collada::Node *p_node);
ColladaImport() {
-
found_ambient = false;
found_directional = false;
force_make_tangents = false;
@@ -111,15 +109,16 @@ struct ColladaImport {
};
Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {
-
- if (p_node->type != Collada::Node::TYPE_JOINT)
+ if (p_node->type != Collada::Node::TYPE_JOINT) {
return OK;
+ }
Collada::NodeJoint *joint = static_cast<Collada::NodeJoint *>(p_node);
p_skeleton->add_bone(p_node->name);
- if (p_parent >= 0)
+ if (p_parent >= 0) {
p_skeleton->set_bone_parent(r_bone, p_parent);
+ }
NodeMap nm;
nm.node = p_skeleton;
@@ -130,7 +129,6 @@ Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p
skeleton_bone_map[p_skeleton][joint->sid] = r_bone;
if (collada.state.bone_rest_map.has(joint->sid)) {
-
p_skeleton->set_bone_rest(r_bone, collada.fix_transform(collada.state.bone_rest_map[joint->sid]));
//should map this bone to something for animation?
} else {
@@ -139,22 +137,19 @@ Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p
int id = r_bone++;
for (int i = 0; i < p_node->children.size(); i++) {
-
Error err = _populate_skeleton(p_skeleton, p_node->children[i], r_bone, id);
- if (err)
+ if (err) {
return err;
+ }
}
return OK;
}
void ColladaImport::_pre_process_lights(Collada::Node *p_node) {
-
if (p_node->type == Collada::Node::TYPE_LIGHT) {
-
Collada::NodeLight *light = static_cast<Collada::NodeLight *>(p_node);
if (collada.state.light_data_map.has(light->light)) {
-
Collada::LightData &ld = collada.state.light_data_map[light->light];
if (ld.mode == Collada::LightData::MODE_AMBIENT) {
found_ambient = true;
@@ -166,18 +161,16 @@ void ColladaImport::_pre_process_lights(Collada::Node *p_node) {
}
}
- for (int i = 0; i < p_node->children.size(); i++)
+ for (int i = 0; i < p_node->children.size(); i++) {
_pre_process_lights(p_node->children[i]);
+ }
}
Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
-
if (p_node->type == Collada::Node::TYPE_SKELETON) {
-
Skeleton3D *sk = memnew(Skeleton3D);
int bone = 0;
for (int i = 0; i < p_node->children.size(); i++) {
-
_populate_skeleton(sk, p_node->children[i], bone, -1);
}
sk->localize_rests(); //after creating skeleton, rests must be localized...!
@@ -185,43 +178,38 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
}
for (int i = 0; i < p_node->children.size(); i++) {
-
Error err = _create_scene_skeletons(p_node->children[i]);
- if (err)
+ if (err) {
return err;
+ }
}
return OK;
}
Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
-
Node3D *node = nullptr;
switch (p_node->type) {
-
case Collada::Node::TYPE_NODE: {
-
node = memnew(Node3D);
} break;
case Collada::Node::TYPE_JOINT: {
-
return OK; // do nothing
} break;
case Collada::Node::TYPE_LIGHT: {
-
//node = memnew( Light)
Collada::NodeLight *light = static_cast<Collada::NodeLight *>(p_node);
if (collada.state.light_data_map.has(light->light)) {
-
Collada::LightData &ld = collada.state.light_data_map[light->light];
if (ld.mode == Collada::LightData::MODE_AMBIENT) {
-
- if (found_directional)
+ if (found_directional) {
return OK; //do nothing not needed
+ }
- if (!bool(GLOBAL_DEF("collada/use_ambient", false)))
+ if (!bool(GLOBAL_DEF("collada/use_ambient", false))) {
return OK;
+ }
//well, it's an ambient light..
Light3D *l = memnew(DirectionalLight3D);
//l->set_color(Light::COLOR_AMBIENT,ld.color);
@@ -230,7 +218,6 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
node = l;
} else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) {
-
//well, it's an ambient light..
Light3D *l = memnew(DirectionalLight3D);
/*
@@ -242,12 +229,11 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
*/
node = l;
} else {
-
Light3D *l;
- if (ld.mode == Collada::LightData::MODE_OMNI)
+ if (ld.mode == Collada::LightData::MODE_OMNI) {
l = memnew(OmniLight3D);
- else {
+ } else {
l = memnew(SpotLight3D);
//l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle);
//l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp);
@@ -261,43 +247,33 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
}
} else {
-
node = memnew(Node3D);
}
} break;
case Collada::Node::TYPE_CAMERA: {
-
Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node);
Camera3D *camera = memnew(Camera3D);
if (collada.state.camera_data_map.has(cam->camera)) {
-
const Collada::CameraData &cd = collada.state.camera_data_map[cam->camera];
switch (cd.mode) {
-
case Collada::CameraData::MODE_ORTHOGONAL: {
-
if (cd.orthogonal.y_mag) {
-
camera->set_keep_aspect_mode(Camera3D::KEEP_HEIGHT);
camera->set_orthogonal(cd.orthogonal.y_mag * 2.0, cd.z_near, cd.z_far);
} else if (!cd.orthogonal.y_mag && cd.orthogonal.x_mag) {
-
camera->set_keep_aspect_mode(Camera3D::KEEP_WIDTH);
camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far);
}
} break;
case Collada::CameraData::MODE_PERSPECTIVE: {
-
if (cd.perspective.y_fov) {
-
camera->set_perspective(cd.perspective.y_fov, cd.z_near, cd.z_far);
} else if (!cd.perspective.y_fov && cd.perspective.x_fov) {
-
camera->set_perspective(cd.perspective.x_fov / cd.aspect, cd.z_near, cd.z_far);
}
@@ -309,11 +285,9 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
} break;
case Collada::Node::TYPE_GEOMETRY: {
-
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
if (collada.state.curve_data_map.has(ng->source)) {
-
node = memnew(Path3D);
} else {
//mesh since nothing else
@@ -322,15 +296,15 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
}
} break;
case Collada::Node::TYPE_SKELETON: {
-
ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE);
Skeleton3D *sk = skeleton_map[p_node];
node = sk;
} break;
}
- if (p_node->name != "")
+ if (p_node->name != "") {
node->set_name(p_node->name);
+ }
NodeMap nm;
nm.node = node;
node_map[p_node->id] = nm;
@@ -347,16 +321,15 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
}
for (int i = 0; i < p_node->children.size(); i++) {
-
Error err = _create_scene(p_node->children[i], node);
- if (err)
+ if (err) {
return err;
+ }
}
return OK;
}
Error ColladaImport::_create_material(const String &p_target) {
-
ERR_FAIL_COND_V(material_cache.has(p_target), ERR_ALREADY_EXISTS);
ERR_FAIL_COND_V(!collada.state.material_map.has(p_target), ERR_INVALID_PARAMETER);
Collada::Material &src_mat = collada.state.material_map[p_target];
@@ -365,24 +338,22 @@ Error ColladaImport::_create_material(const String &p_target) {
Ref<StandardMaterial3D> material = memnew(StandardMaterial3D);
- if (src_mat.name != "")
+ if (src_mat.name != "") {
material->set_name(src_mat.name);
- else if (effect.name != "")
+ } else if (effect.name != "") {
material->set_name(effect.name);
+ }
// DIFFUSE
if (effect.diffuse.texture != "") {
-
String texfile = effect.get_texture_path(effect.diffuse.texture, collada);
if (texfile != "") {
-
if (texfile.begins_with("/")) {
texfile = texfile.replace_first("/", "res://");
}
Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D");
if (texture.is_valid()) {
-
material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture);
material->set_albedo(Color(1, 1, 1, 1));
//material->set_parameter(StandardMaterial3D::PARAM_DIFFUSE,Color(1,1,1,1));
@@ -397,10 +368,8 @@ Error ColladaImport::_create_material(const String &p_target) {
// SPECULAR
if (effect.specular.texture != "") {
-
String texfile = effect.get_texture_path(effect.specular.texture, collada);
if (texfile != "") {
-
if (texfile.begins_with("/")) {
texfile = texfile.replace_first("/", "res://");
}
@@ -424,17 +393,14 @@ Error ColladaImport::_create_material(const String &p_target) {
// EMISSION
if (effect.emission.texture != "") {
-
String texfile = effect.get_texture_path(effect.emission.texture, collada);
if (texfile != "") {
-
if (texfile.begins_with("/")) {
texfile = texfile.replace_first("/", "res://");
}
Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D");
if (texture.is_valid()) {
-
material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
material->set_texture(StandardMaterial3D::TEXTURE_EMISSION, texture);
material->set_emission(Color(1, 1, 1, 1));
@@ -454,10 +420,8 @@ Error ColladaImport::_create_material(const String &p_target) {
// NORMAL
if (effect.bump.texture != "") {
-
String texfile = effect.get_texture_path(effect.bump.texture, collada);
if (texfile != "") {
-
if (texfile.begins_with("/")) {
texfile = texfile.replace_first("/", "res://");
}
@@ -490,33 +454,30 @@ Error ColladaImport::_create_material(const String &p_target) {
}
Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) {
-
bool local_xform_mirror = p_local_xform.basis.determinant() < 0;
if (p_morph_data) {
-
//add morphie target
ERR_FAIL_COND_V(!p_morph_data->targets.has("MORPH_TARGET"), ERR_INVALID_DATA);
String mt = p_morph_data->targets["MORPH_TARGET"];
ERR_FAIL_COND_V(!p_morph_data->sources.has(mt), ERR_INVALID_DATA);
int morph_targets = p_morph_data->sources[mt].sarray.size();
for (int i = 0; i < morph_targets; i++) {
-
String target = p_morph_data->sources[mt].sarray[i];
ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(target), ERR_INVALID_DATA);
String name = collada.state.mesh_data_map[target].name;
p_mesh->add_blend_shape(name);
}
- if (p_morph_data->mode == "RELATIVE")
+ if (p_morph_data->mode == "RELATIVE") {
p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_RELATIVE);
- else if (p_morph_data->mode == "NORMALIZED")
+ } else if (p_morph_data->mode == "NORMALIZED") {
p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED);
+ }
}
int surface = 0;
for (int p_i = 0; p_i < meshdata.primitives.size(); p_i++) {
-
const Collada::MeshData::Primitives &p = meshdata.primitives[p_i];
/* VERTEX SOURCE */
@@ -540,7 +501,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int normal_ofs = 0;
if (p.sources.has("NORMAL")) {
-
String normal_source_id = p.sources["NORMAL"].source;
normal_ofs = p.sources["NORMAL"].offset;
ERR_FAIL_COND_V(!meshdata.sources.has(normal_source_id), ERR_INVALID_DATA);
@@ -551,7 +511,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int binormal_ofs = 0;
if (p.sources.has("TEXBINORMAL")) {
-
String binormal_source_id = p.sources["TEXBINORMAL"].source;
binormal_ofs = p.sources["TEXBINORMAL"].offset;
ERR_FAIL_COND_V(!meshdata.sources.has(binormal_source_id), ERR_INVALID_DATA);
@@ -562,7 +521,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int tangent_ofs = 0;
if (p.sources.has("TEXTANGENT")) {
-
String tangent_source_id = p.sources["TEXTANGENT"].source;
tangent_ofs = p.sources["TEXTANGENT"].offset;
ERR_FAIL_COND_V(!meshdata.sources.has(tangent_source_id), ERR_INVALID_DATA);
@@ -573,7 +531,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int uv_ofs = 0;
if (p.sources.has("TEXCOORD0")) {
-
String uv_source_id = p.sources["TEXCOORD0"].source;
uv_ofs = p.sources["TEXCOORD0"].offset;
ERR_FAIL_COND_V(!meshdata.sources.has(uv_source_id), ERR_INVALID_DATA);
@@ -584,7 +541,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int uv2_ofs = 0;
if (p.sources.has("TEXCOORD1")) {
-
String uv2_source_id = p.sources["TEXCOORD1"].source;
uv2_ofs = p.sources["TEXCOORD1"].offset;
ERR_FAIL_COND_V(!meshdata.sources.has(uv2_source_id), ERR_INVALID_DATA);
@@ -595,7 +551,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int color_ofs = 0;
if (p.sources.has("COLOR")) {
-
String color_source_id = p.sources["COLOR"].source;
color_ofs = p.sources["COLOR"].offset;
ERR_FAIL_COND_V(!meshdata.sources.has(color_source_id), ERR_INVALID_DATA);
@@ -613,16 +568,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
bool has_weights = false;
if (p_skin_controller) {
-
const Collada::SkinControllerData::Source *weight_src = nullptr;
int weight_ofs = 0;
if (p_skin_controller->weights.sources.has("WEIGHT")) {
-
String weight_id = p_skin_controller->weights.sources["WEIGHT"].source;
weight_ofs = p_skin_controller->weights.sources["WEIGHT"].offset;
if (p_skin_controller->sources.has(weight_id)) {
-
weight_src = &p_skin_controller->sources[weight_id];
}
}
@@ -630,7 +582,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int joint_ofs = 0;
if (p_skin_controller->weights.sources.has("JOINT")) {
-
joint_ofs = p_skin_controller->weights.sources["JOINT"].offset;
}
@@ -639,13 +590,11 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int index_ofs = 0;
int wstride = p_skin_controller->weights.sources.size();
for (int w_i = 0; w_i < p_skin_controller->weights.sets.size(); w_i++) {
-
int amount = p_skin_controller->weights.sets[w_i];
Vector<Collada::Vertex::Weight> weights;
for (int a_i = 0; a_i < amount; a_i++) {
-
Collada::Vertex::Weight w;
int read_from = index_ofs + a_i * wstride;
@@ -656,8 +605,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
w.weight = weight_src->array[weight_index];
int bone_index = p_skin_controller->weights.indices[read_from + joint_ofs];
- if (bone_index == -1)
+ if (bone_index == -1) {
continue; //ignore this weight (refers to bind shape)
+ }
ERR_FAIL_INDEX_V(bone_index, bone_remap.size(), ERR_INVALID_DATA);
w.bone_idx = bone_remap[bone_index];
@@ -676,11 +626,14 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
//make sure weights always add up to 1
float total = 0;
- for (int i = 0; i < weights.size(); i++)
+ for (int i = 0; i < weights.size(); i++) {
total += weights[i].weight;
- if (total)
- for (int i = 0; i < weights.size(); i++)
+ }
+ if (total) {
+ for (int i = 0; i < weights.size(); i++) {
weights.write[i].weight /= total;
+ }
+ }
if (weights.size() == 0 || total == 0) { //if nothing, add a weight to bone 0
//no weights assigned
@@ -715,10 +668,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int _prim_ofs = 0;
int vertidx = 0;
for (int p_j = 0; p_j < p.count; p_j++) {
-
int amount;
if (p.polygons.size()) {
-
ERR_FAIL_INDEX_V(p_j, p.polygons.size(), ERR_INVALID_DATA);
amount = p.polygons[p_j];
} else {
@@ -730,15 +681,15 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
int prev2[2] = { 0, 0 };
for (int j = 0; j < amount; j++) {
-
int src = _prim_ofs;
//_prim_ofs+=p.sources.size()
ERR_FAIL_INDEX_V(src, p.indices.size(), ERR_INVALID_DATA);
Collada::Vertex vertex;
- if (!p_optimize)
+ if (!p_optimize) {
vertex.uid = vertidx++;
+ }
int vertex_index = p.indices[src + vertex_ofs]; //used for index field (later used by controllers)
int vertex_pos = (vertex_src->stride ? vertex_src->stride : 3) * vertex_index;
@@ -750,13 +701,11 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
}
if (normal_src) {
-
int normal_pos = (normal_src->stride ? normal_src->stride : 3) * p.indices[src + normal_ofs];
ERR_FAIL_INDEX_V(normal_pos, normal_src->array.size(), ERR_INVALID_DATA);
vertex.normal = Vector3(normal_src->array[normal_pos + 0], normal_src->array[normal_pos + 1], normal_src->array[normal_pos + 2]);
if (tangent_src && binormal_src) {
-
int binormal_pos = (binormal_src->stride ? binormal_src->stride : 3) * p.indices[src + binormal_ofs];
ERR_FAIL_INDEX_V(binormal_pos, binormal_src->array.size(), ERR_INVALID_DATA);
Vector3 binormal = Vector3(binormal_src->array[binormal_pos + 0], binormal_src->array[binormal_pos + 1], binormal_src->array[binormal_pos + 2]);
@@ -771,21 +720,18 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
}
if (uv_src) {
-
int uv_pos = (uv_src->stride ? uv_src->stride : 2) * p.indices[src + uv_ofs];
ERR_FAIL_INDEX_V(uv_pos, uv_src->array.size(), ERR_INVALID_DATA);
vertex.uv = Vector3(uv_src->array[uv_pos + 0], 1.0 - uv_src->array[uv_pos + 1], 0);
}
if (uv2_src) {
-
int uv2_pos = (uv2_src->stride ? uv2_src->stride : 2) * p.indices[src + uv2_ofs];
ERR_FAIL_INDEX_V(uv2_pos, uv2_src->array.size(), ERR_INVALID_DATA);
vertex.uv2 = Vector3(uv2_src->array[uv2_pos + 0], 1.0 - uv2_src->array[uv2_pos + 1], 0);
}
if (color_src) {
-
int color_pos = (color_src->stride ? color_src->stride : 3) * p.indices[src + color_ofs]; // colors are RGB in collada..
ERR_FAIL_INDEX_V(color_pos, color_src->array.size(), ERR_INVALID_DATA);
vertex.color = Color(color_src->array[color_pos + 0], color_src->array[color_pos + 1], color_src->array[color_pos + 2], (color_src->stride > 3) ? color_src->array[color_pos + 3] : 1.0);
@@ -793,7 +739,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
#ifndef NO_UP_AXIS_SWAP
if (collada.state.up_axis == Vector3::AXIS_Z) {
-
Vector3 bn = vertex.normal.cross(vertex.tangent.normal) * vertex.tangent.d;
SWAP(vertex.vertex.z, vertex.vertex.y);
@@ -815,23 +760,21 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
//COLLADA_PRINT("vertex: "+vertex.vertex);
if (vertex_set.has(vertex)) {
-
index = vertex_set.find(vertex)->get().idx;
} else {
-
index = vertex_set.size();
vertex.idx = index;
vertex_set.insert(vertex);
}
//build triangles if needed
- if (j == 0)
+ if (j == 0) {
prev2[0] = index;
+ }
if (j >= 2) {
//insert indices in reverse order (collada uses CCW as frontface)
if (local_xform_mirror) {
-
indices_list.push_back(prev2[0]);
indices_list.push_back(prev2[1]);
indices_list.push_back(index);
@@ -852,16 +795,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
vertex_array.resize(vertex_set.size());
for (Set<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) {
-
vertex_array.write[F->get().idx] = F->get();
}
if (has_weights) {
-
//if skeleton, localize
Transform local_xform = p_local_xform;
for (int i = 0; i < vertex_array.size(); i++) {
-
vertex_array.write[i].vertex = local_xform.xform(vertex_array[i].vertex);
vertex_array.write[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized();
vertex_array.write[i].tangent.normal = local_xform.basis.xform(vertex_array[i].tangent.normal).normalized();
@@ -878,20 +818,20 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
/*****************/
{
-
Ref<StandardMaterial3D> material;
{
-
if (p_material_map.has(p.material)) {
String target = p_material_map[p.material].target;
if (!material_cache.has(target)) {
Error err = _create_material(target);
- if (!err)
+ if (!err) {
material = material_cache[target];
- } else
+ }
+ } else {
material = material_cache[target];
+ }
} else if (p.material != "") {
WARN_PRINT("Collada: Unreferenced material in geometry instance: " + p.material);
@@ -931,7 +871,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
bones.write[l] = vertex_array[k].weights[l].bone_idx;
//sum += vertex_array[k].weights[l].weight;
} else {
-
weights.write[l] = 0;
bones.write[l] = 0;
}
@@ -954,7 +893,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
}
if ((!binormal_src || !tangent_src) && normal_src && uv_src && force_make_tangents) {
-
surftool->generate_tangents();
}
@@ -972,7 +910,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
////////////////////////////
for (int mi = 0; mi < p_morph_meshes.size(); mi++) {
-
Array a = p_morph_meshes[mi]->surface_get_arrays(surface);
//add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not)
@@ -1007,21 +944,16 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
}
Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compression) {
-
if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
-
Node3D *node = node_map[p_node->id].node;
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
if (Object::cast_to<Path3D>(node)) {
-
Path3D *path = Object::cast_to<Path3D>(node);
if (curve_cache.has(ng->source)) {
-
path->set_curve(curve_cache[ng->source]);
} else {
-
Ref<Curve3D> c = memnew(Curve3D);
const Collada::CurveData &cd = collada.state.curve_data_map[ng->source];
@@ -1048,19 +980,18 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
ERR_FAIL_COND_V(interps.stride != 1, ERR_INVALID_DATA);
const Collada::CurveData::Source *tilts = nullptr;
- if (cd.control_vertices.has("TILT") && cd.sources.has(cd.control_vertices["TILT"]))
+ if (cd.control_vertices.has("TILT") && cd.sources.has(cd.control_vertices["TILT"])) {
tilts = &cd.sources[cd.control_vertices["TILT"]];
+ }
int pc = vertices.array.size() / 3;
for (int i = 0; i < pc; i++) {
-
Vector3 pos(vertices.array[i * 3 + 0], vertices.array[i * 3 + 1], vertices.array[i * 3 + 2]);
Vector3 in(in_tangents.array[i * 3 + 0], in_tangents.array[i * 3 + 1], in_tangents.array[i * 3 + 2]);
Vector3 out(out_tangents.array[i * 3 + 0], out_tangents.array[i * 3 + 1], out_tangents.array[i * 3 + 2]);
#ifndef NO_UP_AXIS_SWAP
if (collada.state.up_axis == Vector3::AXIS_Z) {
-
SWAP(pos.y, pos.z);
pos.z = -pos.z;
SWAP(in.y, in.z);
@@ -1074,8 +1005,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
out *= collada.state.unit_scale;
c->add_point(pos, in - pos, out - pos);
- if (tilts)
+ if (tilts) {
c->set_point_tilt(i, tilts->array[i]);
+ }
}
curve_cache[ng->source] = c;
@@ -1084,7 +1016,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
}
if (Object::cast_to<MeshInstance3D>(node)) {
-
Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node);
@@ -1099,11 +1030,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
Vector<Ref<ArrayMesh>> morphs;
if (ng2->controller) {
-
String ngsource = ng2->source;
if (collada.state.skin_controller_data_map.has(ngsource)) {
-
ERR_FAIL_COND_V(!collada.state.skin_controller_data_map.has(ngsource), ERR_INVALID_DATA);
skin = &collada.state.skin_controller_data_map[ngsource];
@@ -1147,7 +1076,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
bone_remap.resize(joint_src->sarray.size());
for (int i = 0; i < bone_remap.size(); i++) {
-
String str = joint_src->sarray[i];
ERR_FAIL_COND_V(!bone_remap_map.has(str), ERR_INVALID_DATA);
bone_remap.write[i] = bone_remap_map[str];
@@ -1155,7 +1083,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
}
if (collada.state.morph_controller_data_map.has(ngsource)) {
-
//it's a morph!!
morph = &collada.state.morph_controller_data_map[ngsource];
meshid = morph->mesh;
@@ -1167,7 +1094,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
valid = true;
Vector<String> names = morph->sources[target].sarray;
for (int i = 0; i < names.size(); i++) {
-
String meshid2 = names[i];
if (collada.state.mesh_data_map.has(meshid2)) {
Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
@@ -1183,8 +1109,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
}
}
- if (!valid)
+ if (!valid) {
morphs.clear();
+ }
ngsource = "";
}
}
@@ -1211,19 +1138,16 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
mesh_cache[meshid] = mesh;
} else {
-
WARN_PRINT("Collada: Will not import geometry: " + meshid);
}
}
if (!mesh.is_null()) {
-
mi->set_mesh(mesh);
if (!use_mesh_builtin_materials) {
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
for (int i = 0; i < meshdata.primitives.size(); i++) {
-
String matname = meshdata.primitives[i].material;
if (ng2->material_map.has(matname)) {
@@ -1232,10 +1156,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
Ref<Material> material;
if (!material_cache.has(target)) {
Error err = _create_material(target);
- if (!err)
+ if (!err) {
material = material_cache[target];
- } else
+ }
+ } else {
material = material_cache[target];
+ }
mi->set_surface_material(i, material);
} else if (matname != "") {
@@ -1248,16 +1174,15 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
}
for (int i = 0; i < p_node->children.size(); i++) {
-
Error err = _create_resources(p_node->children[i], p_use_compression);
- if (err)
+ if (err) {
return err;
+ }
}
return OK;
}
Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents, bool p_use_compression) {
-
Error err = collada.load(p_path, p_flags);
ERR_FAIL_COND_V_MSG(err, err, "Cannot load file '" + p_path + "'.");
@@ -1269,13 +1194,11 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
//determine what's going on with the lights
for (int i = 0; i < vs.root_nodes.size(); i++) {
-
_pre_process_lights(vs.root_nodes[i]);
}
//import scene
for (int i = 0; i < vs.root_nodes.size(); i++) {
-
Error err2 = _create_scene_skeletons(vs.root_nodes[i]);
if (err2 != OK) {
memdelete(scene);
@@ -1284,7 +1207,6 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
}
for (int i = 0; i < vs.root_nodes.size(); i++) {
-
Error err2 = _create_scene(vs.root_nodes[i], scene);
if (err2 != OK) {
memdelete(scene);
@@ -1305,48 +1227,36 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
}
void ColladaImport::_fix_param_animation_tracks() {
-
for (Map<String, Collada::Node *>::Element *E = collada.state.scene_map.front(); E; E = E->next()) {
-
Collada::Node *n = E->get();
switch (n->type) {
-
case Collada::Node::TYPE_NODE: {
// ? do nothing
} break;
case Collada::Node::TYPE_JOINT: {
-
} break;
case Collada::Node::TYPE_SKELETON: {
-
} break;
case Collada::Node::TYPE_LIGHT: {
-
} break;
case Collada::Node::TYPE_CAMERA: {
-
} break;
case Collada::Node::TYPE_GEOMETRY: {
-
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(n);
// test source(s)
String source = ng->source;
while (source != "") {
-
if (collada.state.skin_controller_data_map.has(source)) {
-
const Collada::SkinControllerData &skin = collada.state.skin_controller_data_map[source];
//nothing to animate here i think
source = skin.base;
} else if (collada.state.morph_controller_data_map.has(source)) {
-
const Collada::MorphControllerData &morph = collada.state.morph_controller_data_map[source];
if (morph.targets.has("MORPH_WEIGHT") && morph.targets.has("MORPH_TARGET")) {
-
String weights = morph.targets["MORPH_WEIGHT"];
String targets = morph.targets["MORPH_TARGET"];
//fails here
@@ -1358,11 +1268,9 @@ void ColladaImport::_fix_param_animation_tracks() {
ERR_FAIL_COND(weight_src.array.size() != target_src.sarray.size());
for (int i = 0; i < weight_src.array.size(); i++) {
-
String track_name = weights + "(" + itos(i) + ")";
String mesh_name = target_src.sarray[i];
if (collada.state.mesh_name_map.has(mesh_name) && collada.state.referenced_tracks.has(track_name)) {
-
const Vector<int> &rt = collada.state.referenced_tracks[track_name];
for (int rti = 0; rti < rt.size(); rti++) {
@@ -1379,7 +1287,6 @@ void ColladaImport::_fix_param_animation_tracks() {
}
source = morph.mesh;
} else {
-
source = ""; // for now nothing else supported
}
}
@@ -1390,24 +1297,20 @@ void ColladaImport::_fix_param_animation_tracks() {
}
void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks) {
-
_fix_param_animation_tracks();
for (int i = 0; i < collada.state.animation_clips.size(); i++) {
-
- for (int j = 0; j < collada.state.animation_clips[i].tracks.size(); j++)
+ for (int j = 0; j < collada.state.animation_clips[i].tracks.size(); j++) {
tracks_in_clips.insert(collada.state.animation_clips[i].tracks[j]);
+ }
}
for (int i = 0; i < collada.state.animation_tracks.size(); i++) {
-
const Collada::AnimationTrack &at = collada.state.animation_tracks[i];
String node;
if (!node_map.has(at.target)) {
-
if (node_name_map.has(at.target)) {
-
node = node_name_map[at.target];
} else {
WARN_PRINT("Collada: Couldn't find node: " + at.target);
@@ -1418,23 +1321,21 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im
}
if (at.property) {
-
valid_animated_properties.push_back(i);
} else {
-
node_map[node].anim_tracks.push_back(i);
valid_animated_nodes.insert(node);
}
}
create_animation(-1, p_make_tracks_in_all_bones, p_import_value_tracks);
- for (int i = 0; i < collada.state.animation_clips.size(); i++)
+ for (int i = 0; i < collada.state.animation_clips.size(); i++) {
create_animation(i, p_make_tracks_in_all_bones, p_import_value_tracks);
+ }
}
void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks) {
-
Ref<Animation> animation = Ref<Animation>(memnew(Animation));
if (p_clip == -1) {
@@ -1444,9 +1345,9 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
for (Map<String, NodeMap>::Element *E = node_map.front(); E; E = E->next()) {
-
- if (E->get().bone < 0)
+ if (E->get().bone < 0) {
continue;
+ }
bones_with_animation[E->key()] = false;
}
//store and validate tracks
@@ -1458,15 +1359,11 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Set<int> track_filter;
if (p_clip == -1) {
-
for (int i = 0; i < collada.state.animation_clips.size(); i++) {
-
int tc = collada.state.animation_clips[i].tracks.size();
for (int j = 0; j < tc; j++) {
-
String n = collada.state.animation_clips[i].tracks[j];
if (collada.state.by_id_tracks.has(n)) {
-
const Vector<int> &ti = collada.state.by_id_tracks[n];
for (int k = 0; k < ti.size(); k++) {
track_filter.insert(ti[k]);
@@ -1475,13 +1372,10 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
}
} else {
-
int tc = collada.state.animation_clips[p_clip].tracks.size();
for (int j = 0; j < tc; j++) {
-
String n = collada.state.animation_clips[p_clip].tracks[j];
if (collada.state.by_id_tracks.has(n)) {
-
const Vector<int> &ti = collada.state.by_id_tracks[n];
for (int k = 0; k < ti.size(); k++) {
track_filter.insert(ti[k]);
@@ -1499,11 +1393,11 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
float snapshot_interval = 1.0 / bake_fps; //should be customizable somewhere...
float anim_length = collada.state.animation_length;
- if (p_clip >= 0 && collada.state.animation_clips[p_clip].end)
+ if (p_clip >= 0 && collada.state.animation_clips[p_clip].end) {
anim_length = collada.state.animation_clips[p_clip].end;
+ }
while (f < anim_length) {
-
base_snapshots.push_back(f);
f += snapshot_interval;
@@ -1518,11 +1412,9 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
bool tracks_found = false;
for (Set<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) {
-
// take snapshots
if (!collada.state.scene_map.has(E->get())) {
-
continue;
}
@@ -1539,7 +1431,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Collada::Node *cn = collada.state.scene_map[E->get()];
if (cn->ignore_anim) {
-
continue;
}
@@ -1554,25 +1445,23 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
//use snapshot keys from anim track instead, because this was most likely exported baked
const Collada::AnimationTrack &at = collada.state.animation_tracks[nm.anim_tracks.front()->get()];
snapshots.clear();
- for (int i = 0; i < at.keys.size(); i++)
+ for (int i = 0; i < at.keys.size(); i++) {
snapshots.push_back(at.keys[i].time);
+ }
}
for (int i = 0; i < snapshots.size(); i++) {
-
for (List<int>::Element *ET = nm.anim_tracks.front(); ET; ET = ET->next()) {
//apply tracks
if (p_clip == -1) {
-
if (track_filter.has(ET->get())) {
-
continue;
}
} else {
-
- if (!track_filter.has(ET->get()))
+ if (!track_filter.has(ET->get())) {
continue;
+ }
}
found_anim = true;
@@ -1581,9 +1470,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
int xform_idx = -1;
for (int j = 0; j < cn->xform_list.size(); j++) {
-
if (cn->xform_list[j].id == at.param) {
-
xform_idx = j;
break;
}
@@ -1623,10 +1510,8 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
//make bone transform relative to rest (in case of skeleton)
Skeleton3D *sk = Object::cast_to<Skeleton3D>(nm.node);
if (sk) {
-
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;
} else {
-
ERR_PRINT("Collada: Invalid skeleton");
}
}
@@ -1640,24 +1525,24 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
if (nm.bone >= 0) {
- if (found_anim)
+ if (found_anim) {
bones_with_animation[E->get()] = true;
+ }
}
- if (found_anim)
+ if (found_anim) {
tracks_found = true;
- else {
+ } else {
animation->remove_track(track);
}
}
if (p_make_tracks_in_all_bones) {
-
//some bones may lack animation, but since we don't store pose as a property, we must add keyframes!
for (Map<String, bool>::Element *E = bones_with_animation.front(); E; E = E->next()) {
-
- if (E->get())
+ if (E->get()) {
continue;
+ }
NodeMap &nm = node_map[E->key()];
String path = scene->get_path_to(nm.node);
@@ -1695,24 +1580,24 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (p_import_value_tracks) {
for (int i = 0; i < valid_animated_properties.size(); i++) {
-
int ti = valid_animated_properties[i];
if (p_clip == -1) {
-
- if (track_filter.has(ti))
+ if (track_filter.has(ti)) {
continue;
+ }
} else {
-
- if (!track_filter.has(ti))
+ if (!track_filter.has(ti)) {
continue;
+ }
}
const Collada::AnimationTrack &at = collada.state.animation_tracks[ti];
// take snapshots
- if (!collada.state.scene_map.has(at.target))
+ if (!collada.state.scene_map.has(at.target)) {
continue;
+ }
NodeMap &nm = node_map[at.target];
String path = scene->get_path_to(nm.node);
@@ -1725,7 +1610,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->track_set_imported(track, true); //helps merging later
for (int j = 0; j < at.keys.size(); j++) {
-
float time = at.keys[j].time;
Variant value;
Vector<float> data = at.keys[j].data;
@@ -1748,7 +1632,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
if (tracks_found) {
-
animations.push_back(animation);
}
}
@@ -1758,19 +1641,19 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
/*********************************************************************************/
uint32_t EditorSceneImporterCollada::get_import_flags() const {
-
return IMPORT_SCENE | IMPORT_ANIMATION;
}
-void EditorSceneImporterCollada::get_extensions(List<String> *r_extensions) const {
+void EditorSceneImporterCollada::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("dae");
}
-Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
ColladaImport state;
uint32_t flags = Collada::IMPORT_FLAG_SCENE;
- if (p_flags & IMPORT_ANIMATION)
+ if (p_flags & IMPORT_ANIMATION) {
flags |= Collada::IMPORT_FLAG_ANIMATION;
+ }
state.use_mesh_builtin_materials = !(p_flags & IMPORT_MATERIALS_IN_INSTANCES);
state.bake_fps = p_bake_fps;
@@ -1780,15 +1663,13 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Cannot load scene from file '" + p_path + "'.");
if (state.missing_textures.size()) {
-
/*
- for(int i=0;i<state.missing_textures.size();i++) {
- EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]);
- }
- */
+ for(int i=0;i<state.missing_textures.size();i++) {
+ EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]);
+ }
+ */
if (r_missing_deps) {
-
for (int i = 0; i < state.missing_textures.size(); i++) {
//EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]);
r_missing_deps->push_back(state.missing_textures[i]);
@@ -1797,18 +1678,17 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
}
if (p_flags & IMPORT_ANIMATION) {
-
state.create_animations(p_flags & IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
AnimationPlayer *ap = memnew(AnimationPlayer);
for (int i = 0; i < state.animations.size(); i++) {
String name;
- if (state.animations[i]->get_name() == "")
+ if (state.animations[i]->get_name() == "") {
name = "default";
- else
+ } else {
name = state.animations[i]->get_name();
+ }
if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) {
-
if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) {
state.animations.write[i]->set_loop(true);
}
@@ -1824,7 +1704,6 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
}
Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
ColladaImport state;
state.use_mesh_builtin_materials = false;
@@ -1833,15 +1712,16 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path
ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot load animation from file '" + p_path + "'.");
state.create_animations(p_flags & EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
- if (state.scene)
+ if (state.scene) {
memdelete(state.scene);
+ }
- if (state.animations.size() == 0)
+ if (state.animations.size() == 0) {
return Ref<Animation>();
+ }
Ref<Animation> anim = state.animations[0];
String base = p_path.get_basename().to_lower();
if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) {
-
if (base.begins_with("loop") || base.ends_with("loop") || base.begins_with("cycle") || base.ends_with("cycle")) {
anim->set_loop(true);
}
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index 932a064e76..57c694b698 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -34,7 +34,6 @@
#include "editor/import/resource_importer_scene.h"
class EditorSceneImporterCollada : public EditorSceneImporter {
-
GDCLASS(EditorSceneImporterCollada, EditorSceneImporter);
public:
diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp
index aad378c94f..6d46d4d2e9 100644
--- a/editor/import/editor_import_plugin.cpp
+++ b/editor/import/editor_import_plugin.cpp
@@ -87,7 +87,6 @@ int EditorImportPlugin::get_import_order() const {
}
void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const {
-
ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("get_import_options")));
Array needed;
needed.push_back("name");
@@ -131,7 +130,6 @@ bool EditorImportPlugin::get_option_visibility(const String &p_option, const Map
}
Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("import")), ERR_UNAVAILABLE);
Dictionary options;
Array platform_variants, gen_files;
@@ -153,7 +151,6 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa
}
void EditorImportPlugin::_bind_methods() {
-
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_importer_name"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_visible_name"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_preset_count"));
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 1a1e7171b9..1a232658fe 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -44,17 +44,15 @@
#include "scene/resources/surface_tool.h"
uint32_t EditorSceneImporterGLTF::get_import_flags() const {
-
return IMPORT_SCENE | IMPORT_ANIMATION;
}
-void EditorSceneImporterGLTF::get_extensions(List<String> *r_extensions) const {
+void EditorSceneImporterGLTF::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("gltf");
r_extensions->push_back("glb");
}
Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &state) {
-
Error err;
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
if (!f) {
@@ -81,7 +79,6 @@ Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &stat
}
Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state) {
-
Error err;
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
if (!f) {
@@ -163,7 +160,6 @@ String EditorSceneImporterGLTF::_sanitize_scene_name(const String &name) {
}
String EditorSceneImporterGLTF::_gen_unique_name(GLTFState &state, const String &p_name) {
-
const String s_name = _sanitize_scene_name(p_name);
String name;
@@ -204,7 +200,6 @@ String EditorSceneImporterGLTF::_sanitize_bone_name(const String &name) {
}
String EditorSceneImporterGLTF::_gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name) {
-
const String s_name = _sanitize_bone_name(p_name);
String name;
@@ -227,7 +222,6 @@ String EditorSceneImporterGLTF::_gen_unique_bone_name(GLTFState &state, const GL
}
Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) {
-
ERR_FAIL_COND_V(!state.json.has("scenes"), ERR_FILE_CORRUPT);
const Array &scenes = state.json["scenes"];
int loaded_scene = 0;
@@ -257,11 +251,9 @@ Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) {
}
Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
-
ERR_FAIL_COND_V(!state.json.has("nodes"), ERR_FILE_CORRUPT);
const Array &nodes = state.json["nodes"];
for (int i = 0; i < nodes.size(); i++) {
-
GLTFNode *node = memnew(GLTFNode);
const Dictionary &n = nodes[i];
@@ -281,7 +273,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
node->xform = _arr_to_xform(n["matrix"]);
} else {
-
if (n.has("translation")) {
node->translation = _arr_to_vec3(n["translation"]);
}
@@ -295,7 +286,16 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
node->xform.basis.set_quat_scale(node->rotation, node->scale);
node->xform.origin = node->translation;
}
-
+ if (n.has("extensions")) {
+ Dictionary extensions = n["extensions"];
+ if (extensions.has("KHR_lights_punctual")) {
+ Dictionary lights_punctual = extensions["KHR_lights_punctual"];
+ if (lights_punctual.has("light")) {
+ GLTFLightIndex light = lights_punctual["light"];
+ node->light = light;
+ }
+ }
+ }
if (n.has("children")) {
const Array &children = n["children"];
for (int j = 0; j < children.size(); j++) {
@@ -308,7 +308,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
// build the hierarchy
for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); node_i++) {
-
for (int j = 0; j < state.nodes[node_i]->children.size(); j++) {
GLTFNodeIndex child_i = state.nodes[node_i]->children[j];
@@ -325,7 +324,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
}
void EditorSceneImporterGLTF::_compute_node_heights(GLTFState &state) {
-
state.root_nodes.clear();
for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) {
GLTFNode *node = state.nodes[node_i];
@@ -347,7 +345,6 @@ void EditorSceneImporterGLTF::_compute_node_heights(GLTFState &state) {
}
static Vector<uint8_t> _parse_base64_uri(const String &uri) {
-
int start = uri.find(",");
ERR_FAIL_COND_V(start == -1, Vector<uint8_t>());
@@ -367,20 +364,18 @@ static Vector<uint8_t> _parse_base64_uri(const String &uri) {
}
Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_base_path) {
-
- if (!state.json.has("buffers"))
+ if (!state.json.has("buffers")) {
return OK;
+ }
const Array &buffers = state.json["buffers"];
for (GLTFBufferIndex i = 0; i < buffers.size(); i++) {
-
if (i == 0 && state.glb_data.size()) {
state.buffers.push_back(state.glb_data);
} else {
const Dictionary &buffer = buffers[i];
if (buffer.has("uri")) {
-
Vector<uint8_t> buffer_data;
String uri = buffer["uri"];
@@ -388,7 +383,6 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_
//embedded data
buffer_data = _parse_base64_uri(uri);
} else {
-
uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows
buffer_data = FileAccess::get_file_as_array(uri);
ERR_FAIL_COND_V(buffer.size() == 0, ERR_PARSE_ERROR);
@@ -408,11 +402,9 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_
}
Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) {
-
ERR_FAIL_COND_V(!state.json.has("bufferViews"), ERR_FILE_CORRUPT);
const Array &buffers = state.json["bufferViews"];
for (GLTFBufferViewIndex i = 0; i < buffers.size(); i++) {
-
const Dictionary &d = buffers[i];
GLTFBufferView buffer_view;
@@ -444,33 +436,37 @@ Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) {
}
EditorSceneImporterGLTF::GLTFType EditorSceneImporterGLTF::_get_type_from_str(const String &p_string) {
-
- if (p_string == "SCALAR")
+ if (p_string == "SCALAR") {
return TYPE_SCALAR;
+ }
- if (p_string == "VEC2")
+ if (p_string == "VEC2") {
return TYPE_VEC2;
- if (p_string == "VEC3")
+ }
+ if (p_string == "VEC3") {
return TYPE_VEC3;
- if (p_string == "VEC4")
+ }
+ if (p_string == "VEC4") {
return TYPE_VEC4;
+ }
- if (p_string == "MAT2")
+ if (p_string == "MAT2") {
return TYPE_MAT2;
- if (p_string == "MAT3")
+ }
+ if (p_string == "MAT3") {
return TYPE_MAT3;
- if (p_string == "MAT4")
+ }
+ if (p_string == "MAT4") {
return TYPE_MAT4;
+ }
ERR_FAIL_V(TYPE_SCALAR);
}
Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) {
-
ERR_FAIL_COND_V(!state.json.has("accessors"), ERR_FILE_CORRUPT);
const Array &accessors = state.json["accessors"];
for (GLTFAccessorIndex i = 0; i < accessors.size(); i++) {
-
const Dictionary &d = accessors[i];
GLTFAccessor accessor;
@@ -536,7 +532,6 @@ Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) {
}
String EditorSceneImporterGLTF::_get_component_type_name(const uint32_t p_component) {
-
switch (p_component) {
case COMPONENT_TYPE_BYTE:
return "Byte";
@@ -556,7 +551,6 @@ String EditorSceneImporterGLTF::_get_component_type_name(const uint32_t p_compon
}
String EditorSceneImporterGLTF::_get_type_name(const GLTFType p_component) {
-
static const char *names[] = {
"float",
"vec2",
@@ -571,7 +565,6 @@ String EditorSceneImporterGLTF::_get_type_name(const GLTFType p_component) {
}
Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst, const GLTFBufferViewIndex p_buffer_view, const int skip_every, const int skip_bytes, const int element_size, const int count, const GLTFType type, const int component_count, const int component_type, const int component_size, const bool normalized, const int byte_offset, const bool for_vertex) {
-
const GLTFBufferView &bv = state.buffer_views[p_buffer_view];
int stride = bv.byte_stride ? bv.byte_stride : element_size;
@@ -597,11 +590,9 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst
//fill everything as doubles
for (int i = 0; i < count; i++) {
-
const uint8_t *src = &bufptr[offset + i * stride];
for (int j = 0; j < component_count; j++) {
-
if (skip_every && j > 0 && (j % skip_every) == 0) {
src += skip_bytes;
}
@@ -659,7 +650,6 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst
}
int EditorSceneImporterGLTF::_get_component_type_size(const int component_type) {
-
switch (component_type) {
case COMPONENT_TYPE_BYTE:
return 1;
@@ -687,7 +677,6 @@ int EditorSceneImporterGLTF::_get_component_type_size(const int component_type)
}
Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
//spec, for reference:
//https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
@@ -710,7 +699,6 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const
switch (a.component_type) {
case COMPONENT_TYPE_BYTE:
case COMPONENT_TYPE_UNSIGNED_BYTE: {
-
if (a.type == TYPE_MAT2) {
skip_every = 2;
skip_bytes = 2;
@@ -740,12 +728,12 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const
double *dst = dst_buffer.ptrw();
if (a.buffer_view >= 0) {
-
ERR_FAIL_INDEX_V(a.buffer_view, state.buffer_views.size(), Vector<double>());
const Error err = _decode_buffer_view(state, dst, a.buffer_view, skip_every, skip_bytes, element_size, a.count, a.type, component_count, a.component_type, component_size, a.normalized, a.byte_offset, p_for_vertex);
- if (err != OK)
+ if (err != OK) {
return Vector<double>();
+ }
} else {
//fill with zeros, as bufferview is not defined.
@@ -761,14 +749,16 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const
const int indices_component_size = _get_component_type_size(a.sparse_indices_component_type);
Error err = _decode_buffer_view(state, indices.ptrw(), a.sparse_indices_buffer_view, 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false);
- if (err != OK)
+ if (err != OK) {
return Vector<double>();
+ }
Vector<double> data;
data.resize(component_count * a.sparse_count);
err = _decode_buffer_view(state, data.ptrw(), a.sparse_values_buffer_view, skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex);
- if (err != OK)
+ if (err != OK) {
return Vector<double>();
+ }
for (int i = 0; i < indices.size(); i++) {
const int write_offset = int(indices[i]) * component_count;
@@ -783,12 +773,12 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const
}
Vector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<int> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
const double *attribs_ptr = attribs.ptr();
const int ret_size = attribs.size();
@@ -803,12 +793,12 @@ Vector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state,
}
Vector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<float> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
const double *attribs_ptr = attribs.ptr();
const int ret_size = attribs.size();
@@ -823,12 +813,12 @@ Vector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &sta
}
Vector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Vector2> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
ERR_FAIL_COND_V(attribs.size() % 2 != 0, ret);
const double *attribs_ptr = attribs.ptr();
@@ -844,12 +834,12 @@ Vector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &sta
}
Vector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Vector3> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
ERR_FAIL_COND_V(attribs.size() % 3 != 0, ret);
const double *attribs_ptr = attribs.ptr();
@@ -865,12 +855,12 @@ Vector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &sta
}
Vector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Color> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
const int type = state.accessors[p_accessor].type;
ERR_FAIL_COND_V(!(type == TYPE_VEC3 || type == TYPE_VEC4), ret);
@@ -893,12 +883,12 @@ Vector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &stat
}
Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Quat> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret);
const double *attribs_ptr = attribs.ptr();
@@ -911,13 +901,14 @@ Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state,
}
return ret;
}
-Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
+Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Transform2D> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret);
ret.resize(attribs.size() / 4);
@@ -929,12 +920,12 @@ Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFSta
}
Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &state, const GLTFAccessorIndex p_accessor, bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Basis> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
ERR_FAIL_COND_V(attribs.size() % 9 != 0, ret);
ret.resize(attribs.size() / 9);
@@ -947,12 +938,12 @@ Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &stat
}
Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) {
-
const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
Vector<Transform> ret;
- if (attribs.size() == 0)
+ if (attribs.size() == 0) {
return ret;
+ }
ERR_FAIL_COND_V(attribs.size() % 16 != 0, ret);
ret.resize(attribs.size() / 16);
@@ -966,13 +957,15 @@ Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState &
}
Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
-
- if (!state.json.has("meshes"))
+ if (!state.json.has("meshes")) {
return OK;
+ }
+
+ bool compress_vert_data = state.import_flags & IMPORT_USE_COMPRESSION;
+ uint32_t mesh_flags = compress_vert_data ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
Array meshes = state.json["meshes"];
for (GLTFMeshIndex i = 0; i < meshes.size(); i++) {
-
print_verbose("glTF: Parsing mesh: " + itos(i));
Dictionary d = meshes[i];
@@ -985,7 +978,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
const Dictionary &extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary();
for (int j = 0; j < primitives.size(); j++) {
-
Dictionary p = primitives[j];
Array array;
@@ -1123,7 +1115,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
}
for (int k = 0; k < targets.size(); k++) {
-
const Dictionary &t = targets[k];
Array array_copy;
@@ -1141,7 +1132,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
const int size = src_varr.size();
ERR_FAIL_COND_V(size == 0, ERR_PARSE_ERROR);
{
-
const int max_idx = varr.size();
varr.resize(size);
@@ -1188,7 +1178,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
Vector<float> tangents_v4;
{
-
int max_idx = tangents_v3.size();
int size4 = src_tangents.size();
@@ -1199,7 +1188,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
const float *r4 = src_tangents.ptr();
for (int l = 0; l < size4 / 4; l++) {
-
if (l < max_idx) {
w4[l * 4 + 0] = r3[l].x + r4[l * 4 + 0];
w4[l * 4 + 1] = r3[l].y + r4[l * 4 + 1];
@@ -1230,7 +1218,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
}
//just add it
- mesh.mesh->add_surface_from_arrays(primitive, array, morphs);
+ mesh.mesh->add_surface_from_arrays(primitive, array, morphs, Dictionary(), mesh_flags);
if (p.has("material")) {
const int material = p["material"];
@@ -1259,13 +1247,12 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
}
Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_base_path) {
-
- if (!state.json.has("images"))
+ if (!state.json.has("images")) {
return OK;
+ }
const Array &images = state.json["images"];
for (int i = 0; i < images.size(); i++) {
-
const Dictionary &d = images[i];
String mimetype;
@@ -1287,7 +1274,6 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
data_ptr = data.ptr();
data_size = data.size();
} else {
-
uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows
Ref<Texture2D> texture = ResourceLoader::load(uri);
state.images.push_back(texture);
@@ -1355,13 +1341,12 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
}
Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) {
-
- if (!state.json.has("textures"))
+ if (!state.json.has("textures")) {
return OK;
+ }
const Array &textures = state.json["textures"];
for (GLTFTextureIndex i = 0; i < textures.size(); i++) {
-
const Dictionary &d = textures[i];
ERR_FAIL_COND_V(!d.has("source"), ERR_PARSE_ERROR);
@@ -1384,13 +1369,12 @@ Ref<Texture2D> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLT
}
Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
-
- if (!state.json.has("materials"))
+ if (!state.json.has("materials")) {
return OK;
+ }
const Array &materials = state.json["materials"];
for (GLTFMaterialIndex i = 0; i < materials.size(); i++) {
-
const Dictionary &d = materials[i];
Ref<StandardMaterial3D> material;
@@ -1400,7 +1384,6 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
}
if (d.has("pbrMetallicRoughness")) {
-
const Dictionary &mr = d["pbrMetallicRoughness"];
if (mr.has("baseColorFactor")) {
const Array &arr = mr["baseColorFactor"];
@@ -1534,7 +1517,6 @@ EditorSceneImporterGLTF::GLTFNodeIndex EditorSceneImporterGLTF::_find_highest_no
}
bool EditorSceneImporterGLTF::_capture_nodes_in_skin(GLTFState &state, GLTFSkin &skin, const GLTFNodeIndex node_index) {
-
bool found_joint = false;
for (int i = 0; i < state.nodes[node_index]->children.size(); ++i) {
@@ -1558,7 +1540,6 @@ bool EditorSceneImporterGLTF::_capture_nodes_in_skin(GLTFState &state, GLTFSkin
}
void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &state, GLTFSkin &skin) {
-
DisjointSet<GLTFNodeIndex> disjoint_set;
for (int i = 0; i < skin.joints.size(); ++i) {
@@ -1592,7 +1573,6 @@ void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &sta
// Go up the tree till all of the multiple roots of the skin are at the same hierarchy level.
// This sucks, but 99% of all game engines (not just Godot) would have this same issue.
for (int i = 0; i < roots.size(); ++i) {
-
GLTFNodeIndex current_node = roots[i];
while (state.nodes[current_node]->height > maxHeight) {
GLTFNodeIndex parent = state.nodes[current_node]->parent;
@@ -1640,7 +1620,6 @@ void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &sta
}
Error EditorSceneImporterGLTF::_expand_skin(GLTFState &state, GLTFSkin &skin) {
-
_capture_nodes_for_multirooted_skin(state, skin);
// Grab all nodes that lay in between skin joints/nodes
@@ -1686,7 +1665,6 @@ Error EditorSceneImporterGLTF::_expand_skin(GLTFState &state, GLTFSkin &skin) {
}
Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) {
-
// This may seem duplicated from expand_skins, but this is really a sanity check! (so it kinda is)
// In case additional interpolating logic is added to the skins, this will help ensure that you
// do not cause it to self implode into a fiery blaze
@@ -1752,15 +1730,14 @@ Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) {
}
Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
-
- if (!state.json.has("skins"))
+ if (!state.json.has("skins")) {
return OK;
+ }
const Array &skins = state.json["skins"];
// Create the base skins, and mark nodes that are joints
for (int i = 0; i < skins.size(); i++) {
-
const Dictionary &d = skins[i];
GLTFSkin skin;
@@ -1810,7 +1787,6 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
}
Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) {
-
// Using a disjoint set, we are going to potentially combine all skins that are actually branches
// of a main skeleton, or treat skins defining the same set of nodes as ONE skeleton.
// This is another unclear issue caused by the current glTF specification.
@@ -1888,7 +1864,6 @@ Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) {
// Mark all the skins actual skeletons, after we have merged them
for (GLTFSkeletonIndex skel_i = 0; skel_i < skeleton_owners.size(); ++skel_i) {
-
const GLTFNodeIndex skeleton_owner = skeleton_owners[skel_i];
GLTFSkeleton skeleton;
@@ -1943,7 +1918,6 @@ Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) {
}
Error EditorSceneImporterGLTF::_reparent_non_joint_skeleton_subtrees(GLTFState &state, GLTFSkeleton &skeleton, const Vector<GLTFNodeIndex> &non_joints) {
-
DisjointSet<GLTFNodeIndex> subtree_set;
// Populate the disjoint set with ONLY non joints that are in the skeleton hierarchy (non_joints vector)
@@ -2003,8 +1977,9 @@ Error EditorSceneImporterGLTF::_reparent_to_fake_joint(GLTFState &state, GLTFSke
state.nodes.push_back(fake_joint);
// We better not be a joint, or we messed up in our logic
- if (node->joint)
+ if (node->joint) {
return FAILED;
+ }
fake_joint->translation = node->translation;
fake_joint->rotation = node->rotation;
@@ -2058,7 +2033,6 @@ Error EditorSceneImporterGLTF::_reparent_to_fake_joint(GLTFState &state, GLTFSke
}
Error EditorSceneImporterGLTF::_determine_skeleton_roots(GLTFState &state, const GLTFSkeletonIndex skel_i) {
-
DisjointSet<GLTFNodeIndex> disjoint_set;
for (GLTFNodeIndex i = 0; i < state.nodes.size(); ++i) {
@@ -2113,7 +2087,6 @@ Error EditorSceneImporterGLTF::_determine_skeleton_roots(GLTFState &state, const
Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) {
for (GLTFSkeletonIndex skel_i = 0; skel_i < state.skeletons.size(); ++skel_i) {
-
GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i];
Skeleton3D *skeleton = memnew(Skeleton3D);
@@ -2214,7 +2187,6 @@ Error EditorSceneImporterGLTF::_create_skins(GLTFState &state) {
const bool has_ibms = !gltf_skin.inverse_binds.empty();
for (int joint_i = 0; joint_i < gltf_skin.joints_original.size(); ++joint_i) {
-
Transform xform;
if (has_ibms) {
xform = gltf_skin.inverse_binds[joint_i];
@@ -2253,7 +2225,6 @@ bool EditorSceneImporterGLTF::_skins_are_same(const Ref<Skin> &skin_a, const Ref
}
for (int i = 0; i < skin_a->get_bind_count(); ++i) {
-
if (skin_a->get_bind_bone(i) != skin_b->get_bind_bone(i)) {
return false;
}
@@ -2283,22 +2254,72 @@ void EditorSceneImporterGLTF::_remove_duplicate_skins(GLTFState &state) {
}
}
-Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
+Error EditorSceneImporterGLTF::_parse_lights(GLTFState &state) {
+ if (!state.json.has("extensions")) {
+ return OK;
+ }
+ Dictionary extensions = state.json["extensions"];
+ if (!extensions.has("KHR_lights_punctual")) {
+ return OK;
+ }
+ Dictionary lights_punctual = extensions["KHR_lights_punctual"];
+ if (!lights_punctual.has("lights")) {
+ return OK;
+ }
+
+ const Array &lights = lights_punctual["lights"];
+
+ for (GLTFLightIndex light_i = 0; light_i < lights.size(); light_i++) {
+ const Dictionary &d = lights[light_i];
+
+ GLTFLight light;
+ ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
+ const String &type = d["type"];
+ light.type = type;
+
+ if (d.has("color")) {
+ const Array &arr = d["color"];
+ ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR);
+ const Color c = Color(arr[0], arr[1], arr[2]).to_srgb();
+ light.color = c;
+ }
+ if (d.has("intensity")) {
+ light.intensity = d["intensity"];
+ }
+ if (d.has("range")) {
+ light.range = d["range"];
+ }
+ if (type == "spot") {
+ const Dictionary &spot = d["spot"];
+ light.inner_cone_angle = spot["innerConeAngle"];
+ light.outer_cone_angle = spot["outerConeAngle"];
+ ERR_FAIL_COND_V_MSG(light.inner_cone_angle >= light.outer_cone_angle, ERR_PARSE_ERROR, "The inner angle must be smaller than the outer angle.");
+ } else if (type != "point" && type != "directional") {
+ ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "Light type is unknown.");
+ }
+
+ state.lights.push_back(light);
+ }
+
+ print_verbose("glTF: Total lights: " + itos(state.lights.size()));
- if (!state.json.has("cameras"))
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
+ if (!state.json.has("cameras")) {
return OK;
+ }
const Array &cameras = state.json["cameras"];
for (GLTFCameraIndex i = 0; i < cameras.size(); i++) {
-
const Dictionary &d = cameras[i];
GLTFCamera camera;
ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
const String &type = d["type"];
if (type == "orthographic") {
-
camera.perspective = false;
if (d.has("orthographic")) {
const Dictionary &og = d["orthographic"];
@@ -2310,7 +2331,6 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
}
} else if (type == "perspective") {
-
camera.perspective = true;
if (d.has("perspective")) {
const Dictionary &ppt = d["perspective"];
@@ -2334,20 +2354,20 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
}
Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
-
- if (!state.json.has("animations"))
+ if (!state.json.has("animations")) {
return OK;
+ }
const Array &animations = state.json["animations"];
for (GLTFAnimationIndex i = 0; i < animations.size(); i++) {
-
const Dictionary &d = animations[i];
GLTFAnimation animation;
- if (!d.has("channels") || !d.has("samplers"))
+ if (!d.has("channels") || !d.has("samplers")) {
continue;
+ }
Array channels = d["channels"];
Array samplers = d["samplers"];
@@ -2361,10 +2381,10 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
}
for (int j = 0; j < channels.size(); j++) {
-
const Dictionary &c = channels[j];
- if (!c.has("target"))
+ if (!c.has("target")) {
continue;
+ }
const Dictionary &t = c["target"];
if (!t.has("node") || !t.has("path")) {
@@ -2471,13 +2491,13 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
}
void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) {
-
for (int i = 0; i < state.nodes.size(); i++) {
GLTFNode *n = state.nodes[i];
// Any joints get unique names generated when the skeleton is made, unique to the skeleton
- if (n->skeleton >= 0)
+ if (n->skeleton >= 0) {
continue;
+ }
if (n->name.empty()) {
if (n->mesh >= 0) {
@@ -2494,7 +2514,6 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) {
}
BoneAttachment3D *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index) {
-
const GLTFNode *gltf_node = state.nodes[node_index];
const GLTFNode *bone_node = state.nodes[gltf_node->parent];
@@ -2530,6 +2549,58 @@ MeshInstance3D *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &stat
return mi;
}
+Light3D *EditorSceneImporterGLTF::_generate_light(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
+ const GLTFNode *gltf_node = state.nodes[node_index];
+
+ ERR_FAIL_INDEX_V(gltf_node->light, state.lights.size(), nullptr);
+
+ print_verbose("glTF: Creating light for: " + gltf_node->name);
+
+ const GLTFLight &l = state.lights[gltf_node->light];
+
+ float intensity = l.intensity;
+ if (intensity > 10) {
+ // GLTF spec has the default around 1, but Blender defaults lights to 100.
+ // The only sane way to handle this is to check where it came from and
+ // handle it accordingly. If it's over 10, it probably came from Blender.
+ intensity /= 100;
+ }
+
+ if (l.type == "directional") {
+ DirectionalLight3D *light = memnew(DirectionalLight3D);
+ light->set_param(Light3D::PARAM_ENERGY, intensity);
+ light->set_color(l.color);
+ return light;
+ }
+
+ const float range = CLAMP(l.range, 0, 4096);
+ // Doubling the range will double the effective brightness, so we need double attenuation (half brightness).
+ // We want to have double intensity give double brightness, so we need half the attenuation.
+ const float attenuation = range / intensity;
+ if (l.type == "point") {
+ OmniLight3D *light = memnew(OmniLight3D);
+ light->set_param(OmniLight3D::PARAM_ATTENUATION, attenuation);
+ light->set_param(OmniLight3D::PARAM_RANGE, range);
+ light->set_color(l.color);
+ return light;
+ }
+ if (l.type == "spot") {
+ SpotLight3D *light = memnew(SpotLight3D);
+ light->set_param(SpotLight3D::PARAM_ATTENUATION, attenuation);
+ light->set_param(SpotLight3D::PARAM_RANGE, range);
+ light->set_param(SpotLight3D::PARAM_SPOT_ANGLE, Math::rad2deg(l.outer_cone_angle));
+ light->set_color(l.color);
+
+ // Line of best fit derived from guessing, see https://www.desmos.com/calculator/biiflubp8b
+ // The points in desmos are not exact, except for (1, infinity).
+ float angle_ratio = l.inner_cone_angle / l.outer_cone_angle;
+ float angle_attenuation = 0.2 / (1 - angle_ratio) - 0.1;
+ light->set_param(SpotLight3D::PARAM_SPOT_ATTENUATION, angle_attenuation);
+ return light;
+ }
+ return nullptr;
+}
+
Camera3D *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
@@ -2558,7 +2629,6 @@ Node3D *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene
}
void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index) {
-
const GLTFNode *gltf_node = state.nodes[node_index];
Node3D *current_node = nullptr;
@@ -2604,6 +2674,8 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene
current_node = _generate_mesh_instance(state, scene_parent, node_index);
} else if (gltf_node->camera >= 0) {
current_node = _generate_camera(state, scene_parent, node_index);
+ } else if (gltf_node->light >= 0) {
+ current_node = _generate_light(state, scene_parent, node_index);
} else {
current_node = _generate_spatial(state, scene_parent, node_index);
}
@@ -2623,14 +2695,11 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene
template <class T>
struct EditorSceneImporterGLTFInterpolate {
-
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) {
-
const float t2 = t * t;
const float t3 = t2 * t;
@@ -2652,7 +2721,6 @@ struct EditorSceneImporterGLTFInterpolate {
// thank you for existing, partial specialization
template <>
struct EditorSceneImporterGLTFInterpolate<Quat> {
-
Quat lerp(const Quat &a, const Quat &b, const 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.");
@@ -2677,12 +2745,12 @@ struct EditorSceneImporterGLTFInterpolate<Quat> {
template <class T>
T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) {
-
//could use binary search, worth it?
int idx = -1;
for (int i = 0; i < p_times.size(); i++) {
- if (p_times[i] > p_time)
+ if (p_times[i] > p_time) {
break;
+ }
idx++;
}
@@ -2690,7 +2758,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons
switch (p_interp) {
case GLTFAnimation::INTERP_LINEAR: {
-
if (idx == -1) {
return p_values[0];
} else if (idx >= p_times.size() - 1) {
@@ -2703,7 +2770,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons
} break;
case GLTFAnimation::INTERP_STEP: {
-
if (idx == -1) {
return p_values[0];
} else if (idx >= p_times.size() - 1) {
@@ -2714,7 +2780,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons
} break;
case GLTFAnimation::INTERP_CATMULLROMSPLINE: {
-
if (idx == -1) {
return p_values[1];
} else if (idx >= p_times.size() - 1) {
@@ -2727,7 +2792,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons
} break;
case GLTFAnimation::INTERP_CUBIC_SPLINE: {
-
if (idx == -1) {
return p_values[1];
} else if (idx >= p_times.size() - 1) {
@@ -2750,7 +2814,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons
}
void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps) {
-
const GLTFAnimation &anim = state.animations[index];
String name = anim.name;
@@ -2770,7 +2833,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
float length = 0;
for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) {
-
const GLTFAnimation::Track &track = E->get();
//need to find the path
NodePath node_path;
@@ -2838,7 +2900,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
bool last = false;
while (true) {
-
Vector3 pos = base_pos;
Quat rot = base_rot;
Vector3 scale = base_scale;
@@ -2856,7 +2917,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
}
if (node->skeleton >= 0) {
-
Transform xform;
xform.basis.set_quat_scale(rot, scale);
xform.origin = pos;
@@ -2958,7 +3018,6 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D *
}
Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) {
-
Node3D *root = memnew(Node3D);
// scene_name is already unique
@@ -2985,20 +3044,21 @@ Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_b
}
Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
-
GLTFState state;
if (p_path.to_lower().ends_with("glb")) {
//binary file
//text file
Error err = _parse_glb(p_path, state);
- if (err)
+ if (err) {
return nullptr;
+ }
} else {
//text file
Error err = _parse_json(p_path, state);
- if (err)
+ if (err) {
return nullptr;
+ }
}
ERR_FAIL_COND_V(!state.json.has("asset"), nullptr);
@@ -3009,96 +3069,117 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla
String version = asset["version"];
+ state.import_flags = p_flags;
state.major_version = version.get_slice(".", 0).to_int();
state.minor_version = version.get_slice(".", 1).to_int();
state.use_named_skin_binds = p_flags & IMPORT_USE_NAMED_SKIN_BINDS;
/* STEP 0 PARSE SCENE */
Error err = _parse_scenes(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 1 PARSE NODES */
err = _parse_nodes(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 2 PARSE BUFFERS */
err = _parse_buffers(state, p_path.get_base_dir());
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 3 PARSE BUFFER VIEWS */
err = _parse_buffer_views(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 4 PARSE ACCESSORS */
err = _parse_accessors(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 5 PARSE IMAGES */
err = _parse_images(state, p_path.get_base_dir());
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 6 PARSE TEXTURES */
err = _parse_textures(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 7 PARSE TEXTURES */
err = _parse_materials(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 9 PARSE SKINS */
err = _parse_skins(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 10 DETERMINE SKELETONS */
err = _determine_skeletons(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 11 CREATE SKELETONS */
err = _create_skeletons(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 12 CREATE SKINS */
err = _create_skins(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
/* STEP 13 PARSE MESHES (we have enough info now) */
err = _parse_meshes(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
- /* STEP 14 PARSE CAMERAS */
+ /* STEP 14 PARSE LIGHTS */
+ err = _parse_lights(state);
+ if (err != OK) {
+ return NULL;
+ }
+
+ /* STEP 15 PARSE CAMERAS */
err = _parse_cameras(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
- /* STEP 15 PARSE ANIMATIONS */
+ /* STEP 16 PARSE ANIMATIONS */
err = _parse_animations(state);
- if (err != OK)
+ if (err != OK) {
return nullptr;
+ }
- /* STEP 16 ASSIGN SCENE NAMES */
+ /* STEP 17 ASSIGN SCENE NAMES */
_assign_scene_names(state);
- /* STEP 17 MAKE SCENE! */
+ /* STEP 18 MAKE SCENE! */
Node3D *scene = _generate_scene(state, p_bake_fps);
return scene;
}
Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
return Ref<Animation>();
}
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
index d127a87782..95c6b87af5 100644
--- a/editor/import/editor_scene_importer_gltf.h
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -32,6 +32,7 @@
#define EDITOR_SCENE_IMPORTER_GLTF_H
#include "editor/import/resource_importer_scene.h"
+#include "scene/3d/light_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/3d/skeleton_3d.h"
@@ -40,7 +41,6 @@ class BoneAttachment3D;
class MeshInstance3D;
class EditorSceneImporterGLTF : public EditorSceneImporter {
-
GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter);
typedef int GLTFAccessorIndex;
@@ -51,6 +51,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
typedef int GLTFImageIndex;
typedef int GLTFMaterialIndex;
typedef int GLTFMeshIndex;
+ typedef int GLTFLightIndex;
typedef int GLTFNodeIndex;
typedef int GLTFSkeletonIndex;
typedef int GLTFSkinIndex;
@@ -92,92 +93,61 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
String _get_type_name(const GLTFType p_component);
struct GLTFNode {
-
//matrices need to be transformed to this
- GLTFNodeIndex parent;
- int height;
+ GLTFNodeIndex parent = -1;
+ int height = -1;
Transform xform;
String name;
- GLTFMeshIndex mesh;
- GLTFCameraIndex camera;
- GLTFSkinIndex skin;
+ GLTFMeshIndex mesh = -1;
+ GLTFCameraIndex camera = -1;
+ GLTFSkinIndex skin = -1;
- GLTFSkeletonIndex skeleton;
- bool joint;
+ GLTFSkeletonIndex skeleton = -1;
+ bool joint = false;
Vector3 translation;
Quat rotation;
- Vector3 scale;
+ Vector3 scale = Vector3(1, 1, 1);
Vector<int> children;
- GLTFNodeIndex fake_joint_parent;
-
- GLTFNode() :
- parent(-1),
- height(-1),
- mesh(-1),
- camera(-1),
- skin(-1),
- skeleton(-1),
- joint(false),
- translation(0, 0, 0),
- scale(Vector3(1, 1, 1)),
- fake_joint_parent(-1) {}
+ GLTFNodeIndex fake_joint_parent = -1;
+
+ GLTFLightIndex light = -1;
+
+ GLTFNode() {}
};
struct GLTFBufferView {
-
- GLTFBufferIndex buffer;
- int byte_offset;
- int byte_length;
- int byte_stride;
- bool indices;
+ GLTFBufferIndex buffer = -1;
+ int byte_offset = 0;
+ int byte_length = 0;
+ int byte_stride = 0;
+ bool indices = false;
//matrices need to be transformed to this
- GLTFBufferView() :
- buffer(-1),
- byte_offset(0),
- byte_length(0),
- byte_stride(0),
- indices(false) {
- }
+ GLTFBufferView() {}
};
struct GLTFAccessor {
-
- GLTFBufferViewIndex buffer_view;
- int byte_offset;
- int component_type;
- bool normalized;
- int count;
+ GLTFBufferViewIndex buffer_view = 0;
+ int byte_offset = 0;
+ int component_type = 0;
+ bool normalized = false;
+ int count = 0;
GLTFType type;
- float min;
- float max;
- int sparse_count;
- int sparse_indices_buffer_view;
- int sparse_indices_byte_offset;
- int sparse_indices_component_type;
- int sparse_values_buffer_view;
- int sparse_values_byte_offset;
-
- GLTFAccessor() {
- buffer_view = 0;
- byte_offset = 0;
- component_type = 0;
- normalized = false;
- count = 0;
- min = 0;
- max = 0;
- sparse_count = 0;
- sparse_indices_buffer_view = 0;
- sparse_indices_byte_offset = 0;
- sparse_indices_component_type = 0;
- sparse_values_buffer_view = 0;
- sparse_values_byte_offset = 0;
- }
+ float min = 0;
+ float max = 0;
+ int sparse_count = 0;
+ int sparse_indices_buffer_view = 0;
+ int sparse_indices_byte_offset = 0;
+ int sparse_indices_component_type = 0;
+ int sparse_values_buffer_view = 0;
+ int sparse_values_byte_offset = 0;
+
+ GLTFAccessor() {}
};
struct GLTFTexture {
GLTFImageIndex src_image;
@@ -192,21 +162,19 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<GLTFNodeIndex> roots;
// The created Skeleton for the scene
- Skeleton3D *godot_skeleton;
+ Skeleton3D *godot_skeleton = nullptr;
// Set of unique bone names for the skeleton
Set<String> unique_names;
- GLTFSkeleton() :
- godot_skeleton(nullptr) {
- }
+ GLTFSkeleton() {}
};
struct GLTFSkin {
String name;
// The "skeleton" property defined in the gltf spec. -1 = Scene Root
- GLTFNodeIndex skin_root;
+ GLTFNodeIndex skin_root = -1;
Vector<GLTFNodeIndex> joints_original;
Vector<Transform> inverse_binds;
@@ -226,7 +194,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<GLTFNodeIndex> roots;
// The GLTF Skeleton this Skin points to (after we determine skeletons)
- GLTFSkeletonIndex skeleton;
+ GLTFSkeletonIndex skeleton = -1;
// A mapping from the joint indices (in the order of joints_original) to the
// Godot Skeleton's bone_indices
@@ -237,9 +205,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
// to the generated skeleton for the mesh instances.
Ref<Skin> godot_skin;
- GLTFSkin() :
- skin_root(-1),
- skeleton(-1) {}
+ GLTFSkin() {}
};
struct GLTFMesh {
@@ -248,18 +214,23 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
};
struct GLTFCamera {
+ bool perspective = true;
+ float fov_size = 64;
+ float zfar = 500;
+ float znear = 0.1;
+
+ GLTFCamera() {}
+ };
- bool perspective;
- float fov_size;
- float zfar;
- float znear;
+ struct GLTFLight {
+ Color color = Color(1.0f, 1.0f, 1.0f);
+ float intensity = 1.0f;
+ String type = "";
+ float range = Math_INF;
+ float inner_cone_angle = 0.0f;
+ float outer_cone_angle = Math_PI / 4.0;
- GLTFCamera() {
- perspective = true;
- fov_size = 65;
- zfar = 500;
- znear = 0.1;
- }
+ GLTFLight() {}
};
struct GLTFAnimation {
@@ -280,7 +251,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
};
struct Track {
-
Channel<Vector3> translation_track;
Channel<Quat> rotation_track;
Channel<Vector3> scale_track;
@@ -293,7 +263,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
};
struct GLTFState {
-
Dictionary json;
int major_version;
int minor_version;
@@ -317,6 +286,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<GLTFSkin> skins;
Vector<GLTFCamera> cameras;
+ Vector<GLTFLight> lights;
Set<String> unique_names;
@@ -325,6 +295,9 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Map<GLTFNodeIndex, Node *> scene_nodes;
+ // EditorSceneImporter::ImportFlags
+ uint32_t import_flags;
+
~GLTFState() {
for (int i = 0; i < nodes.size(); i++) {
memdelete(nodes[i]);
@@ -392,12 +365,13 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
void _remove_duplicate_skins(GLTFState &state);
Error _parse_cameras(GLTFState &state);
-
+ Error _parse_lights(GLTFState &state);
Error _parse_animations(GLTFState &state);
BoneAttachment3D *_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index);
MeshInstance3D *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
Camera3D *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
+ Light3D *_generate_light(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
Node3D *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
void _generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index);
diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp
index 252af9050b..da2d1c9bdf 100644
--- a/editor/import/resource_importer_bitmask.cpp
+++ b/editor/import/resource_importer_bitmask.cpp
@@ -38,55 +38,51 @@
#include "scene/resources/texture.h"
String ResourceImporterBitMap::get_importer_name() const {
-
return "bitmap";
}
String ResourceImporterBitMap::get_visible_name() const {
-
return "BitMap";
}
-void ResourceImporterBitMap::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterBitMap::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
+
String ResourceImporterBitMap::get_save_extension() const {
return "res";
}
String ResourceImporterBitMap::get_resource_type() const {
-
return "BitMap";
}
bool ResourceImporterBitMap::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
return true;
}
int ResourceImporterBitMap::get_preset_count() const {
return 0;
}
-String ResourceImporterBitMap::get_preset_name(int p_idx) const {
+String ResourceImporterBitMap::get_preset_name(int p_idx) const {
return String();
}
void ResourceImporterBitMap::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "create_from", PROPERTY_HINT_ENUM, "Black & White,Alpha"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.5));
}
Error ResourceImporterBitMap::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
int create_from = p_options["create_from"];
float threshold = p_options["threshold"];
Ref<Image> image;
image.instance();
Error err = ImageLoader::load_image(p_source_file, image);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
int w = image->get_width();
int h = image->get_height();
@@ -97,7 +93,6 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
-
bool bit;
Color c = image->get_pixel(j, i);
if (create_from == 0) { //b&W
diff --git a/editor/import/resource_importer_csv.cpp b/editor/import/resource_importer_csv.cpp
index 424f90bd54..d29ba28a96 100644
--- a/editor/import/resource_importer_csv.cpp
+++ b/editor/import/resource_importer_csv.cpp
@@ -34,16 +34,14 @@
#include "core/os/file_access.h"
String ResourceImporterCSV::get_importer_name() const {
-
return "csv";
}
String ResourceImporterCSV::get_visible_name() const {
-
return "CSV";
}
-void ResourceImporterCSV::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterCSV::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("csv");
}
@@ -52,20 +50,18 @@ String ResourceImporterCSV::get_save_extension() const {
}
String ResourceImporterCSV::get_resource_type() const {
-
return "TextFile";
}
bool ResourceImporterCSV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
return true;
}
int ResourceImporterCSV::get_preset_count() const {
return 0;
}
-String ResourceImporterCSV::get_preset_name(int p_idx) const {
+String ResourceImporterCSV::get_preset_name(int p_idx) const {
return "";
}
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index 9d72396449..04e20dee86 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -36,16 +36,14 @@
#include "core/translation.h"
String ResourceImporterCSVTranslation::get_importer_name() const {
-
return "csv_translation";
}
String ResourceImporterCSVTranslation::get_visible_name() const {
-
return "CSV Translation";
}
-void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("csv");
}
@@ -54,31 +52,27 @@ String ResourceImporterCSVTranslation::get_save_extension() const {
}
String ResourceImporterCSVTranslation::get_resource_type() const {
-
return "Translation";
}
bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
return true;
}
int ResourceImporterCSVTranslation::get_preset_count() const {
return 0;
}
-String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const {
+String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const {
return "";
}
void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0));
}
Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
bool compress = p_options["compress"];
String delimiter;
@@ -105,7 +99,6 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
Vector<Ref<Translation>> translations;
for (int i = 1; i < line.size(); i++) {
-
String locale = line[i];
ERR_FAIL_COND_V_MSG(!TranslationServer::is_locale_valid(locale), ERR_PARSE_ERROR, "Error importing CSV translation: '" + locale + "' is not a valid locale.");
@@ -119,10 +112,8 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
line = f->get_csv_line(delimiter);
while (line.size() == locales.size() + 1) {
-
String key = line[0];
if (key != "") {
-
for (int i = 1; i < line.size(); i++) {
translations.write[i - 1]->add_message(key, line[i].c_unescape());
}
diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp
index a1f5a79b00..885b00865b 100644
--- a/editor/import/resource_importer_image.cpp
+++ b/editor/import/resource_importer_image.cpp
@@ -36,16 +36,14 @@
#include "scene/resources/texture.h"
String ResourceImporterImage::get_importer_name() const {
-
return "image";
}
String ResourceImporterImage::get_visible_name() const {
-
return "Image";
}
-void ResourceImporterImage::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterImage::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
@@ -54,20 +52,18 @@ String ResourceImporterImage::get_save_extension() const {
}
String ResourceImporterImage::get_resource_type() const {
-
return "Image";
}
bool ResourceImporterImage::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
return true;
}
int ResourceImporterImage::get_preset_count() const {
return 0;
}
-String ResourceImporterImage::get_preset_name(int p_idx) const {
+String ResourceImporterImage::get_preset_name(int p_idx) const {
return String();
}
@@ -75,7 +71,6 @@ void ResourceImporterImage::get_import_options(List<ImportOption> *r_options, in
}
Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'.");
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index c46cf4c1a8..b57ea3745d 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -40,7 +40,6 @@
#include "scene/resources/texture.h"
String ResourceImporterLayeredTexture::get_importer_name() const {
-
switch (mode) {
case MODE_CUBEMAP: {
return "cubemap_texture";
@@ -60,7 +59,6 @@ String ResourceImporterLayeredTexture::get_importer_name() const {
}
String ResourceImporterLayeredTexture::get_visible_name() const {
-
switch (mode) {
case MODE_CUBEMAP: {
return "Cubemap";
@@ -78,10 +76,11 @@ String ResourceImporterLayeredTexture::get_visible_name() const {
ERR_FAIL_V("");
}
-void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
+
String ResourceImporterLayeredTexture::get_save_extension() const {
switch (mode) {
case MODE_CUBEMAP: {
@@ -102,7 +101,6 @@ String ResourceImporterLayeredTexture::get_save_extension() const {
}
String ResourceImporterLayeredTexture::get_resource_type() const {
-
switch (mode) {
case MODE_CUBEMAP: {
return "StreamCubemap";
@@ -121,7 +119,6 @@ String ResourceImporterLayeredTexture::get_resource_type() const {
}
bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
if (p_option == "compress/lossy_quality" && p_options.has("compress/mode")) {
return int(p_options["compress/mode"]) == COMPRESS_LOSSY;
}
@@ -131,14 +128,13 @@ bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_optio
int ResourceImporterLayeredTexture::get_preset_count() const {
return 0;
}
-String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const {
+String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const {
return "";
}
void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,Video RAM,Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless (PNG),Lossy (WebP),Video RAM (S3TC/ETC/BPTC),Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Disabled,Enabled,RGBA Only"), 0));
@@ -160,9 +156,7 @@ void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_op
}
void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, const String &p_to_path, int p_compress_mode, float p_lossy, Image::CompressMode p_vram_compression, Image::CompressSource p_csource, Image::UsedChannels used_channels, bool p_mipmaps, bool p_force_po2) {
-
for (int i = 0; i < p_images.size(); i++) {
-
if (p_force_po2) {
p_images.write[i]->resize_to_po2();
}
@@ -199,7 +193,6 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
}
Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
int compress_mode = p_options["compress/mode"];
float lossy = p_options["compress/lossy_quality"];
int hdr_compression = p_options["compress/hdr_compression"];
@@ -246,8 +239,9 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
Ref<Image> image;
image.instance();
Error err = ImageLoader::load_image(p_source_file, image, nullptr, false, 1.0);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
if (compress_mode == COMPRESS_BASIS_UNIVERSAL && image->get_format() >= Image::FORMAT_RF) {
//basis universal does not support float formats, fall back
@@ -315,7 +309,6 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
bool can_compress_hdr = hdr_compression > 0;
if (is_hdr && can_compress_hdr) {
-
if (used_channels == Image::USED_CHANNELS_LA || used_channels == Image::USED_CHANNELS_RGBA) {
//can compress hdr, but hdr with alpha is not compressible
@@ -337,9 +330,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
}
if (can_compress_hdr) {
-
if (!can_bptc) {
-
//default to rgbe
if (image->get_format() != Image::FORMAT_RGBE9995) {
for (int i = 0; i < slices.size(); i++) {
@@ -366,14 +357,12 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
-
_save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, lossy, Image::COMPRESS_ETC2, csource, used_channels, mipmaps, true);
r_platform_variants->push_back("etc2");
formats_imported.push_back("etc2");
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
-
_save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, lossy, Image::COMPRESS_ETC2, csource, used_channels, mipmaps, true);
r_platform_variants->push_back("pvrtc");
formats_imported.push_back("pvrtc");
@@ -408,7 +397,6 @@ const char *ResourceImporterLayeredTexture::compression_formats[] = {
nullptr
};
String ResourceImporterLayeredTexture::get_import_settings_string() const {
-
String s;
int index = 0;
@@ -425,7 +413,6 @@ String ResourceImporterLayeredTexture::get_import_settings_string() const {
}
bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_path) const {
-
//will become invalid if formats are missing to import
Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
@@ -463,7 +450,6 @@ bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_p
ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = nullptr;
ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() {
-
singleton = this;
mode = MODE_CUBEMAP;
}
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 6a6eadfa5c..49b47bf4be 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -38,12 +38,10 @@
#include "scene/resources/surface_tool.h"
uint32_t EditorOBJImporter::get_import_flags() const {
-
return IMPORT_SCENE;
}
static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) {
-
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path));
@@ -51,7 +49,6 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand
String current_name;
String base_path = p_path.get_base_dir();
while (true) {
-
String l = f->get_line().strip_edges();
if (l.begins_with("newmtl ")) {
@@ -204,7 +201,6 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand
}
static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, Vector3 p_offset_mesh, List<String> *r_missing_deps) {
-
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
@@ -231,7 +227,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
String current_group;
while (true) {
-
String l = f->get_line().strip_edges();
while (l.length() && l[l.length() - 1] == '\\') {
String add = f->get_line().strip_edges();
@@ -283,12 +278,10 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_FILE_CORRUPT);
for (int i = 2; i < v.size() - 1; i++) {
-
face[2] = v[i + 1].split("/");
ERR_FAIL_COND_V(face[0].size() != face[2].size(), ERR_FILE_CORRUPT);
for (int j = 0; j < 3; j++) {
-
int idx = j;
if (idx < 2) {
@@ -297,23 +290,26 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
if (face[idx].size() == 3) {
int norm = face[idx][2].to_int() - 1;
- if (norm < 0)
+ if (norm < 0) {
norm += normals.size() + 1;
+ }
ERR_FAIL_INDEX_V(norm, normals.size(), ERR_FILE_CORRUPT);
surf_tool->add_normal(normals[norm]);
}
if (face[idx].size() >= 2 && face[idx][1] != String()) {
int uv = face[idx][1].to_int() - 1;
- if (uv < 0)
+ if (uv < 0) {
uv += uvs.size() + 1;
+ }
ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_FILE_CORRUPT);
surf_tool->add_uv(uvs[uv]);
}
int vtx = face[idx][0].to_int() - 1;
- if (vtx < 0)
+ if (vtx < 0) {
vtx += vertices.size() + 1;
+ }
ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_FILE_CORRUPT);
Vector3 vertex = vertices[vtx];
@@ -326,10 +322,11 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
}
} else if (l.begins_with("s ")) { //smoothing
String what = l.substr(2, l.length()).strip_edges();
- if (what == "off")
+ if (what == "off") {
surf_tool->add_smooth_group(false);
- else
+ } else {
surf_tool->add_smooth_group(true);
+ }
} else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh
//groups are too annoying
if (surf_tool->get_vertex_array().size()) {
@@ -365,7 +362,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
}
if (l.begins_with("o ") || f->eof_reached()) {
-
if (!p_single_mesh) {
mesh->set_name(name);
r_meshes.push_back(mesh);
@@ -384,12 +380,10 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
}
if (l.begins_with("usemtl ")) {
-
current_material = l.replace("usemtl", "").strip_edges();
}
if (l.begins_with("g ")) {
-
current_group = l.substr(2, l.length()).strip_edges();
}
@@ -411,7 +405,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
}
if (p_single_mesh) {
-
r_meshes.push_back(mesh);
}
@@ -419,7 +412,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
}
Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
-
List<Ref<Mesh>> meshes;
Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps);
@@ -434,7 +426,6 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
Node3D *scene = memnew(Node3D);
for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) {
-
MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(E->get());
mi->set_name(E->get()->get_name());
@@ -448,33 +439,36 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
return scene;
}
-Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
+Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
return Ref<Animation>();
}
void EditorOBJImporter::get_extensions(List<String> *r_extensions) const {
-
r_extensions->push_back("obj");
}
EditorOBJImporter::EditorOBJImporter() {
}
+
////////////////////////////////////////////////////
String ResourceImporterOBJ::get_importer_name() const {
return "wavefront_obj";
}
+
String ResourceImporterOBJ::get_visible_name() const {
return "OBJ As Mesh";
}
-void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("obj");
}
+
String ResourceImporterOBJ::get_save_extension() const {
return "mesh";
}
+
String ResourceImporterOBJ::get_resource_type() const {
return "Mesh";
}
@@ -482,24 +476,23 @@ String ResourceImporterOBJ::get_resource_type() const {
int ResourceImporterOBJ::get_preset_count() const {
return 0;
}
+
String ResourceImporterOBJ::get_preset_name(int p_idx) const {
return "";
}
void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "scale_mesh"), Vector3(1, 1, 1)));
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "offset_mesh"), Vector3(0, 0, 0)));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true));
}
-bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
+bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
return true;
}
Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
List<Ref<Mesh>> meshes;
Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], nullptr);
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 7485e60f7b..aec5de3dcc 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -34,7 +34,6 @@
#include "resource_importer_scene.h"
class EditorOBJImporter : public EditorSceneImporter {
-
GDCLASS(EditorOBJImporter, EditorSceneImporter);
public:
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 37941109a1..ec82f78e75 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -47,15 +47,14 @@
#include "scene/resources/world_margin_shape_3d.h"
uint32_t EditorSceneImporter::get_import_flags() const {
-
if (get_script_instance()) {
return get_script_instance()->call("_get_import_flags");
}
ERR_FAIL_V(0);
}
-void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
+void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
if (get_script_instance()) {
Array arr = get_script_instance()->call("_get_extensions");
for (int i = 0; i < arr.size(); i++) {
@@ -66,8 +65,8 @@ void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
ERR_FAIL();
}
-Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
if (get_script_instance()) {
return get_script_instance()->call("_import_scene", p_path, p_flags, p_bake_fps);
}
@@ -76,7 +75,6 @@ Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags,
}
Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
if (get_script_instance()) {
return get_script_instance()->call("_import_animation", p_path, p_flags);
}
@@ -88,17 +86,14 @@ Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint3
//and you want to load the resulting file
Node *EditorSceneImporter::import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
return ResourceImporterScene::get_singleton()->import_scene_from_other_importer(this, p_path, p_flags, p_bake_fps);
}
Ref<Animation> EditorSceneImporter::import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
return ResourceImporterScene::get_singleton()->import_animation_from_other_importer(this, p_path, p_flags, p_bake_fps);
}
void EditorSceneImporter::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("import_scene_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_scene_from_other_importer);
ClassDB::bind_method(D_METHOD("import_animation_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_animation_from_other_importer);
@@ -126,27 +121,24 @@ void EditorSceneImporter::_bind_methods() {
/////////////////////////////////
void EditorScenePostImport::_bind_methods() {
-
BIND_VMETHOD(MethodInfo(Variant::OBJECT, "post_import", PropertyInfo(Variant::OBJECT, "scene")));
ClassDB::bind_method(D_METHOD("get_source_folder"), &EditorScenePostImport::get_source_folder);
ClassDB::bind_method(D_METHOD("get_source_file"), &EditorScenePostImport::get_source_file);
}
Node *EditorScenePostImport::post_import(Node *p_scene) {
-
- if (get_script_instance())
+ if (get_script_instance()) {
return get_script_instance()->call("post_import", p_scene);
+ }
return p_scene;
}
String EditorScenePostImport::get_source_folder() const {
-
return source_folder;
}
String EditorScenePostImport::get_source_file() const {
-
return source_file;
}
@@ -159,17 +151,14 @@ EditorScenePostImport::EditorScenePostImport() {
}
String ResourceImporterScene::get_importer_name() const {
-
return "scene";
}
String ResourceImporterScene::get_visible_name() const {
-
return "Scene";
}
void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const {
-
for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
E->get()->get_extensions(p_extensions);
}
@@ -180,27 +169,29 @@ String ResourceImporterScene::get_save_extension() const {
}
String ResourceImporterScene::get_resource_type() const {
-
return "PackedScene";
}
bool ResourceImporterScene::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
if (p_option.begins_with("animation/")) {
- if (p_option != "animation/import" && !bool(p_options["animation/import"]))
+ if (p_option != "animation/import" && !bool(p_options["animation/import"])) {
return false;
+ }
- if (p_option == "animation/keep_custom_tracks" && int(p_options["animation/storage"]) == 0)
+ if (p_option == "animation/keep_custom_tracks" && int(p_options["animation/storage"]) == 0) {
return false;
+ }
- if (p_option.begins_with("animation/optimizer/") && p_option != "animation/optimizer/enabled" && !bool(p_options["animation/optimizer/enabled"]))
+ if (p_option.begins_with("animation/optimizer/") && p_option != "animation/optimizer/enabled" && !bool(p_options["animation/optimizer/enabled"])) {
return false;
+ }
if (p_option.begins_with("animation/clip_")) {
int max_clip = p_options["animation/clips/amount"];
int clip = p_option.get_slice("/", 1).get_slice("_", 1).to_int() - 1;
- if (clip >= max_clip)
+ if (clip >= max_clip) {
return false;
+ }
}
}
@@ -218,8 +209,8 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const
int ResourceImporterScene::get_preset_count() const {
return PRESET_MAX;
}
-String ResourceImporterScene::get_preset_name(int p_idx) const {
+String ResourceImporterScene::get_preset_name(int p_idx) const {
switch (p_idx) {
case PRESET_SINGLE_SCENE:
return TTR("Import as Single Scene");
@@ -247,53 +238,52 @@ String ResourceImporterScene::get_preset_name(int p_idx) const {
}
static bool _teststr(const String &p_what, const String &p_str) {
-
String what = p_what;
//remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
while (what.length() && ((what[what.length() - 1] >= '0' && what[what.length() - 1] <= '9') || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) {
-
what = what.substr(0, what.length() - 1);
}
- if (what.findn("$" + p_str) != -1) //blender and other stuff
+ if (what.findn("$" + p_str) != -1) { //blender and other stuff
return true;
- if (what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
+ }
+ if (what.to_lower().ends_with("-" + p_str)) { //collada only supports "_" and "-" besides letters
return true;
- if (what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
+ }
+ if (what.to_lower().ends_with("_" + p_str)) { //collada only supports "_" and "-" besides letters
return true;
+ }
return false;
}
static String _fixstr(const String &p_what, const String &p_str) {
-
String what = p_what;
//remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
while (what.length() && ((what[what.length() - 1] >= '0' && what[what.length() - 1] <= '9') || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) {
-
what = what.substr(0, what.length() - 1);
}
String end = p_what.substr(what.length(), p_what.length() - what.length());
- if (what.findn("$" + p_str) != -1) //blender and other stuff
+ if (what.findn("$" + p_str) != -1) { //blender and other stuff
return what.replace("$" + p_str, "") + end;
- if (what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
+ }
+ if (what.to_lower().ends_with("-" + p_str)) { //collada only supports "_" and "-" besides letters
return what.substr(0, what.length() - (p_str.length() + 1)) + end;
- if (what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
+ }
+ if (what.to_lower().ends_with("_" + p_str)) { //collada only supports "_" and "-" besides letters
return what.substr(0, what.length() - (p_str.length() + 1)) + end;
+ }
return what;
}
static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) {
-
if (!p_convex) {
-
Ref<Shape3D> shape = mesh->create_trimesh_shape();
r_shape_list.push_back(shape);
} else {
-
Vector<Ref<Shape3D>> cd = mesh->convex_decompose();
if (cd.size()) {
for (int i = 0; i < cd.size(); i++) {
@@ -304,10 +294,8 @@ static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_l
}
Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode) {
-
// children first
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *r = _fix_node(p_node->get_child(i), p_root, collision_map, p_light_bake_mode);
if (!r) {
i--; //was erased
@@ -319,32 +307,27 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
bool isroot = p_node == p_root;
if (!isroot && _teststr(name, "noimp")) {
-
memdelete(p_node);
return nullptr;
}
if (Object::cast_to<MeshInstance3D>(p_node)) {
-
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> m = mi->get_mesh();
if (m.is_valid()) {
-
for (int i = 0; i < m->get_surface_count(); i++) {
-
Ref<StandardMaterial3D> mat = m->surface_get_material(i);
- if (!mat.is_valid())
+ if (!mat.is_valid()) {
continue;
+ }
if (_teststr(mat->get_name(), "alpha")) {
-
mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
mat->set_name(_fixstr(mat->get_name(), "alpha"));
}
if (_teststr(mat->get_name(), "vcol")) {
-
mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
mat->set_name(_fixstr(mat->get_name(), "vcol"));
@@ -353,7 +336,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
if (p_light_bake_mode != LIGHT_BAKE_DISABLED) {
-
mi->set_gi_mode(GeometryInstance3D::GI_MODE_BAKED);
}
}
@@ -365,7 +347,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
List<StringName> anims;
ap->get_animation_list(&anims);
for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
-
Ref<Animation> anim = ap->get_animation(E->get());
ERR_CONTINUE(anim.is_null());
for (int i = 0; i < anim->get_track_count(); i++) {
@@ -384,9 +365,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
if (_teststr(name, "colonly") || _teststr(name, "convcolonly")) {
-
- if (isroot)
+ if (isroot) {
return p_node;
+ }
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi) {
Ref<Mesh> mesh = mi->get_mesh();
@@ -413,7 +394,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
ERR_FAIL_COND_V(fixed_name == String(), nullptr);
if (shapes.size()) {
-
StaticBody3D *col = memnew(StaticBody3D);
col->set_transform(mi->get_transform());
col->set_name(fixed_name);
@@ -423,7 +403,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
int idx = 0;
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
-
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@@ -470,9 +449,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
} else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance3D>(p_node)) {
-
- if (isroot)
+ if (isroot) {
return p_node;
+ }
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
@@ -497,7 +476,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
int idx = 0;
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
-
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
rigid_body->add_child(cshape);
@@ -509,7 +487,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
} else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance3D>(p_node)) {
-
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
@@ -547,7 +524,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
int idx = 0;
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
-
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@@ -561,9 +537,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
} else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance3D>(p_node)) {
-
- if (isroot)
+ if (isroot) {
return p_node;
+ }
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
@@ -580,9 +556,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
memdelete(p_node);
p_node = nmi;
} else if (_teststr(name, "vehicle")) {
-
- if (isroot)
+ if (isroot) {
return p_node;
+ }
Node *owner = p_node->get_owner();
Node3D *s = Object::cast_to<Node3D>(p_node);
@@ -600,9 +576,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
p_node = bv;
} else if (_teststr(name, "wheel")) {
-
- if (isroot)
+ if (isroot) {
return p_node;
+ }
Node *owner = p_node->get_owner();
Node3D *s = Object::cast_to<Node3D>(p_node);
@@ -620,14 +596,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
p_node = bv;
} else if (Object::cast_to<MeshInstance3D>(p_node)) {
-
//last attempt, maybe collision inside the mesh data
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
-
List<Ref<Shape3D>> shapes;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
@@ -649,7 +623,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
int idx = 0;
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
-
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@@ -666,41 +639,39 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, bool p_bake_all) {
-
- if (!scene->has_node(String("AnimationPlayer")))
+ if (!scene->has_node(String("AnimationPlayer"))) {
return;
+ }
Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
ERR_FAIL_COND(!anim);
- if (!anim->has_animation("default"))
+ if (!anim->has_animation("default")) {
return;
+ }
Ref<Animation> default_anim = anim->get_animation("default");
for (int i = 0; i < p_clips.size(); i += 4) {
-
String name = p_clips[i];
float from = p_clips[i + 1];
float to = p_clips[i + 2];
bool loop = p_clips[i + 3];
- if (from >= to)
+ if (from >= to) {
continue;
+ }
Ref<Animation> new_anim = memnew(Animation);
for (int j = 0; j < default_anim->get_track_count(); j++) {
-
List<float> keys;
int kc = default_anim->track_get_key_count(j);
int dtrack = -1;
for (int k = 0; k < kc; k++) {
-
float kt = default_anim->track_get_key_time(j, k);
if (kt >= from && kt < to) {
-
//found a key within range, so create track
if (dtrack == -1) {
new_anim->add_track(default_anim->track_get_type(j));
@@ -708,7 +679,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
new_anim->track_set_path(dtrack, default_anim->track_get_path(j));
if (kt > (from + 0.01) && k > 0) {
-
if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
Quat q;
Vector3 p;
@@ -737,7 +707,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
}
if (dtrack != -1 && kt >= to) {
-
if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
Quat q;
Vector3 p;
@@ -757,7 +726,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
dtrack = new_anim->get_track_count() - 1;
new_anim->track_set_path(dtrack, default_anim->track_get_path(j));
if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
-
Quat q;
Vector3 p;
Vector3 s;
@@ -784,12 +752,10 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo
}
void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim, Set<String> &keep) {
-
Ref<Animation> a = anim;
ERR_FAIL_COND(!a.is_valid());
for (int j = 0; j < a->get_track_count(); j++) {
-
String path = a->track_get_path(j);
if (!keep.has(path)) {
@@ -800,9 +766,9 @@ void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim, Set<String>
}
void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
-
- if (!scene->has_node(String("AnimationPlayer")))
+ if (!scene->has_node(String("AnimationPlayer"))) {
return;
+ }
Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
@@ -810,14 +776,12 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
Vector<String> strings = p_text.split("\n");
for (int i = 0; i < strings.size(); i++) {
-
strings.write[i] = strings[i].strip_edges();
}
List<StringName> anim_names;
anim->get_animation_list(&anim_names);
for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
-
String name = E->get();
bool valid_for_this = false;
bool valid = false;
@@ -826,9 +790,7 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
Set<String> keep_local;
for (int i = 0; i < strings.size(); i++) {
-
if (strings[i].begins_with("@")) {
-
valid_for_this = false;
for (Set<String>::Element *F = keep_local.front(); F; F = F->next()) {
keep.insert(F->get());
@@ -837,59 +799,64 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
Vector<String> filters = strings[i].substr(1, strings[i].length()).split(",");
for (int j = 0; j < filters.size(); j++) {
-
String fname = filters[j].strip_edges();
- if (fname == "")
+ if (fname == "") {
continue;
+ }
int fc = fname[0];
bool plus;
- if (fc == '+')
+ if (fc == '+') {
plus = true;
- else if (fc == '-')
+ } else if (fc == '-') {
plus = false;
- else
+ } else {
continue;
+ }
String filter = fname.substr(1, fname.length()).strip_edges();
- if (!name.matchn(filter))
+ if (!name.matchn(filter)) {
continue;
+ }
valid_for_this = plus;
}
- if (valid_for_this)
+ if (valid_for_this) {
valid = true;
+ }
} else if (valid_for_this) {
-
Ref<Animation> a = anim->get_animation(name);
- if (!a.is_valid())
+ if (!a.is_valid()) {
continue;
+ }
for (int j = 0; j < a->get_track_count(); j++) {
-
String path = a->track_get_path(j);
String tname = strings[i];
- if (tname == "")
+ if (tname == "") {
continue;
+ }
int fc = tname[0];
bool plus;
- if (fc == '+')
+ if (fc == '+') {
plus = true;
- else if (fc == '-')
+ } else if (fc == '-') {
plus = false;
- else
+ } else {
continue;
+ }
String filter = tname.substr(1, tname.length()).strip_edges();
- if (!path.matchn(filter))
+ if (!path.matchn(filter)) {
continue;
+ }
- if (plus)
+ if (plus) {
keep_local.insert(path);
- else if (!keep.has(path)) {
+ } else if (!keep.has(path)) {
keep_local.erase(path);
}
}
@@ -906,9 +873,9 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
}
void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle) {
-
- if (!scene->has_node(String("AnimationPlayer")))
+ if (!scene->has_node(String("AnimationPlayer"))) {
return;
+ }
Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n);
@@ -917,14 +884,12 @@ void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_er
List<StringName> anim_names;
anim->get_animation_list(&anim_names);
for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
-
Ref<Animation> a = anim->get_animation(E->get());
a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle));
}
}
static String _make_extname(const String &p_str) {
-
String ext_name = p_str.replace(".", "_");
ext_name = ext_name.replace(":", "_");
ext_name = ext_name.replace("\"", "_");
@@ -940,14 +905,12 @@ static String _make_extname(const String &p_str) {
}
void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Transform> &meshes) {
-
List<PropertyInfo> pi;
p_node->get_property_list(&pi);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi) {
-
Ref<ArrayMesh> mesh = mi->get_mesh();
if (mesh.is_valid() && !meshes.has(mesh)) {
@@ -962,13 +925,11 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans
}
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
_find_meshes(p_node->get_child(i), meshes);
}
}
void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation>> &p_animations, Map<Ref<Material>, Ref<Material>> &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh>> &p_meshes) {
-
List<PropertyInfo> pi;
if (p_make_animations) {
@@ -978,12 +939,10 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
List<StringName> anims;
ap->get_animation_list(&anims);
for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
-
Ref<Animation> anim = ap->get_animation(E->get());
ERR_CONTINUE(anim.is_null());
if (!p_animations.has(anim)) {
-
//mark what comes from the file first, this helps eventually keep user data
for (int i = 0; i < anim->get_track_count(); i++) {
anim->track_set_imported(i, true);
@@ -1022,15 +981,11 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
p_node->get_property_list(&pi);
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
-
if (E->get().type == Variant::OBJECT) {
-
Ref<Material> mat = p_node->get(E->get().name);
if (p_make_materials && mat.is_valid() && mat->get_name() != "") {
-
if (!p_materials.has(mat)) {
-
String ext_name;
if (p_materials_as_text) {
@@ -1043,28 +998,22 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
//if exists, use it
p_materials[mat] = ResourceLoader::load(ext_name);
} else {
-
ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH);
p_materials[mat] = ResourceLoader::load(ext_name, "", true); // disable loading from the cache.
}
}
if (p_materials[mat] != mat) {
-
p_node->set(E->get().name, p_materials[mat]);
}
} else {
-
Ref<ArrayMesh> mesh = p_node->get(E->get().name);
if (mesh.is_valid()) {
-
bool mesh_just_added = false;
if (p_make_meshes) {
-
if (!p_meshes.has(mesh)) {
-
//meshes are always overwritten, keeping them is not practical
String ext_name;
@@ -1082,16 +1031,16 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
}
if (p_make_materials) {
-
if (mesh_just_added || !p_meshes.has(mesh)) {
-
for (int i = 0; i < mesh->get_surface_count(); i++) {
mat = mesh->surface_get_material(i);
- if (!mat.is_valid())
+ if (!mat.is_valid()) {
continue;
- if (mat->get_name() == "")
+ }
+ if (mat->get_name() == "") {
continue;
+ }
if (!p_materials.has(mat)) {
String ext_name;
@@ -1106,19 +1055,16 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
//if exists, use it
p_materials[mat] = ResourceLoader::load(ext_name);
} else {
-
ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH);
p_materials[mat] = ResourceLoader::load(ext_name, "", true); // disable loading from the cache.
}
}
if (p_materials[mat] != mat) {
-
mesh->surface_set_material(i, p_materials[mat]);
//re-save the mesh since a material is now assigned
if (p_make_meshes) {
-
String ext_name;
if (p_meshes_as_text) {
@@ -1144,13 +1090,11 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
_make_external_resources(p_node->get_child(i), p_base_path, p_make_animations, p_animations_as_text, p_keep_animations, p_make_materials, p_materials_as_text, p_keep_materials, p_make_meshes, p_meshes_as_text, p_animations, p_materials, p_meshes);
}
}
void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Node3D"));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root"));
@@ -1160,8 +1104,9 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
String script_ext_hint;
for (List<String>::Element *E = script_extentions.front(); E; E = E->next()) {
- if (script_ext_hint != "")
+ if (script_ext_hint != "") {
script_ext_hint += ",";
+ }
script_ext_hint += "*." + E->get();
}
@@ -1203,7 +1148,6 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
}
void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner) {
-
if (p_node != p_new_owner && p_node->get_owner() == p_scene) {
p_node->set_owner(p_new_owner);
}
@@ -1215,28 +1159,26 @@ void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_
}
Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
Ref<EditorSceneImporter> importer;
String ext = p_path.get_extension().to_lower();
for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
-
- if (E->get().ptr() == p_exception)
+ if (E->get().ptr() == p_exception) {
continue;
+ }
List<String> extensions;
E->get()->get_extensions(&extensions);
for (List<String>::Element *F = extensions.front(); F; F = F->next()) {
-
if (F->get().to_lower() == ext) {
-
importer = E->get();
break;
}
}
- if (importer.is_valid())
+ if (importer.is_valid()) {
break;
+ }
}
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
@@ -1247,28 +1189,26 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte
}
Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) {
-
Ref<EditorSceneImporter> importer;
String ext = p_path.get_extension().to_lower();
for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
-
- if (E->get().ptr() == p_exception)
+ if (E->get().ptr() == p_exception) {
continue;
+ }
List<String> extensions;
E->get()->get_extensions(&extensions);
for (List<String>::Element *F = extensions.front(); F; F = F->next()) {
-
if (F->get().to_lower() == ext) {
-
importer = E->get();
break;
}
}
- if (importer.is_valid())
+ if (importer.is_valid()) {
break;
+ }
}
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
@@ -1277,7 +1217,6 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito
}
Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
const String &src_path = p_source_file;
Ref<EditorSceneImporter> importer;
@@ -1287,21 +1226,19 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
progress.step(TTR("Importing Scene..."), 0);
for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) {
-
List<String> extensions;
E->get()->get_extensions(&extensions);
for (List<String>::Element *F = extensions.front(); F; F = F->next()) {
-
if (F->get().to_lower() == ext) {
-
importer = E->get();
break;
}
}
- if (importer.is_valid())
+ if (importer.is_valid()) {
break;
+ }
}
ERR_FAIL_COND_V(!importer.is_valid(), ERR_FILE_UNRECOGNIZED);
@@ -1309,23 +1246,29 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
float fps = p_options["animation/fps"];
int import_flags = EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP;
- if (!bool(p_options["animation/optimizer/remove_unused_tracks"]))
+ if (!bool(p_options["animation/optimizer/remove_unused_tracks"])) {
import_flags |= EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS;
+ }
- if (bool(p_options["animation/import"]))
+ if (bool(p_options["animation/import"])) {
import_flags |= EditorSceneImporter::IMPORT_ANIMATION;
+ }
- if (int(p_options["meshes/compress"]))
+ if (int(p_options["meshes/compress"])) {
import_flags |= EditorSceneImporter::IMPORT_USE_COMPRESSION;
+ }
- if (bool(p_options["meshes/ensure_tangents"]))
+ if (bool(p_options["meshes/ensure_tangents"])) {
import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
+ }
- if (int(p_options["materials/location"]) == 0)
+ if (int(p_options["materials/location"]) == 0) {
import_flags |= EditorSceneImporter::IMPORT_MATERIALS_IN_INSTANCES;
+ }
- if (bool(p_options["skins/use_named_skins"]))
+ if (bool(p_options["skins/use_named_skins"])) {
import_flags |= EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ }
Error err = OK;
List<String> missing_deps; // for now, not much will be done with this
@@ -1347,7 +1290,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
if (base_node) {
-
scene->replace_by(base_node);
memdelete(scene);
scene = base_node;
@@ -1364,10 +1306,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
}
- if (p_options["nodes/root_name"] != "Scene Root")
+ if (p_options["nodes/root_name"] != "Scene Root") {
scene->set_name(p_options["nodes/root_name"]);
- else
+ } else {
scene->set_name(p_save_path.get_file().get_basename());
+ }
err = OK;
@@ -1389,7 +1332,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Array animation_clips;
{
-
int clip_count = p_options["animation/clips/amount"];
for (int i = 0; i < clip_count; i++) {
@@ -1424,7 +1366,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
String base_path = p_source_file.get_base_dir();
if (external_animations || external_materials || external_meshes || external_scenes) {
-
if (bool(p_options["external_files/store_in_subdir"])) {
String subdir_name = p_source_file.get_file().get_basename();
DirAccess *da = DirAccess::open(base_path);
@@ -1436,7 +1377,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
if (light_bake_mode == 2 /* || generate LOD */) {
-
Map<Ref<ArrayMesh>, Transform> meshes;
_find_meshes(scene, meshes);
@@ -1450,8 +1390,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
FileAccess *file = FileAccess::open(cache_file_path, FileAccess::READ, &err2);
if (err2) {
- if (file)
+ if (file) {
memdelete(file);
+ }
} else {
int cache_size = file->get_len();
cache_data.resize(cache_size);
@@ -1467,7 +1408,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
EditorProgress progress2("gen_lightmaps", TTR("Generating Lightmaps"), meshes.size());
int step = 0;
for (Map<Ref<ArrayMesh>, Transform>::Element *E = meshes.front(); E; E = E->next()) {
-
Ref<ArrayMesh> mesh = E->key();
String name = mesh->get_name();
if (name == "") { //should not happen but..
@@ -1484,7 +1424,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
if (err2 != OK) {
EditorNode::add_io_error("Mesh '" + name + "' failed lightmap generation. Please fix geometry.");
} else {
-
String hash = String::md5((unsigned char *)ret_cache_data);
used_unwraps.insert(hash, ret_cache_size);
@@ -1512,10 +1451,10 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
FileAccess *file = FileAccess::open(cache_file_path, FileAccess::WRITE, &err2);
if (err2) {
- if (file)
+ if (file) {
memdelete(file);
+ }
} else {
-
// Store number of entries
file->store_32(used_unwraps.size());
@@ -1567,7 +1506,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
if (!scr.is_valid()) {
EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path);
} else {
-
post_import_script = Ref<EditorScenePostImport>(memnew(EditorScenePostImport));
post_import_script->set_script(scr);
if (!post_import_script->get_script_instance()) {
@@ -1595,8 +1533,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
//save sub-scenes as instances!
for (int i = 0; i < scene->get_child_count(); i++) {
Node *child = scene->get_child(i);
- if (child->get_owner() != scene)
+ if (child->get_owner() != scene) {
continue; //not a real child probably created by scene type (ig, a scrollbar)
+ }
_replace_owner(child, scene, child);
String cn = String(child->get_name()).strip_edges().replace(".", "_").replace(":", "_");
@@ -1632,16 +1571,18 @@ ResourceImporterScene *ResourceImporterScene::singleton = nullptr;
ResourceImporterScene::ResourceImporterScene() {
singleton = this;
}
+
///////////////////////////////////////
uint32_t EditorSceneImporterESCN::get_import_flags() const {
return IMPORT_SCENE;
}
+
void EditorSceneImporterESCN::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("escn");
}
-Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
Error error;
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'.");
@@ -1651,6 +1592,7 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla
return scene;
}
+
Ref<Animation> EditorSceneImporterESCN::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
ERR_FAIL_V(Ref<Animation>());
}
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index f48f181951..34d96bbc44 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -39,7 +39,6 @@
class Material;
class EditorSceneImporter : public Reference {
-
GDCLASS(EditorSceneImporter, Reference);
protected:
@@ -73,7 +72,6 @@ public:
};
class EditorScenePostImport : public Reference {
-
GDCLASS(EditorScenePostImport, Reference);
String source_folder;
diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp
index f085341969..a2e80dfa18 100644
--- a/editor/import/resource_importer_shader_file.cpp
+++ b/editor/import/resource_importer_shader_file.cpp
@@ -38,32 +38,30 @@
#include "servers/rendering/rendering_device_binds.h"
String ResourceImporterShaderFile::get_importer_name() const {
-
return "glsl";
}
String ResourceImporterShaderFile::get_visible_name() const {
-
return "GLSL Shader File";
}
-void ResourceImporterShaderFile::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterShaderFile::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("glsl");
}
+
String ResourceImporterShaderFile::get_save_extension() const {
return "res";
}
String ResourceImporterShaderFile::get_resource_type() const {
-
return "RDShaderFile";
}
int ResourceImporterShaderFile::get_preset_count() const {
return 0;
}
-String ResourceImporterShaderFile::get_preset_name(int p_idx) const {
+String ResourceImporterShaderFile::get_preset_name(int p_idx) const {
return String();
}
@@ -73,6 +71,7 @@ void ResourceImporterShaderFile::get_import_options(List<ImportOption> *r_option
bool ResourceImporterShaderFile::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
return true;
}
+
static String _include_function(const String &p_path, void *userpointer) {
Error err;
@@ -91,7 +90,6 @@ static String _include_function(const String &p_path, void *userpointer) {
}
Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
/* STEP 1, Read shader code */
Error err;
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 111eab78b4..3a0e624a8f 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -37,7 +37,6 @@
#include "editor/editor_node.h"
void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) {
-
MutexLock lock(singleton->mutex);
StringName path = p_tex->get_path();
@@ -52,7 +51,6 @@ void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTextur
}
void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p_tex) {
-
MutexLock lock(singleton->mutex);
StringName path = p_tex->get_path();
@@ -65,7 +63,6 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p
}
void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture2D> &p_tex) {
-
MutexLock lock(singleton->mutex);
StringName path = p_tex->get_path();
@@ -78,7 +75,6 @@ void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture2D
}
void ResourceImporterTexture::update_imports() {
-
if (EditorFileSystem::get_singleton()->is_scanning() || EditorFileSystem::get_singleton()->is_importing()) {
return; // do nothing for now
}
@@ -91,7 +87,6 @@ void ResourceImporterTexture::update_imports() {
}
for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) {
-
Ref<ConfigFile> cf;
cf.instance();
String src_path = String(E->key()) + ".import";
@@ -139,29 +134,26 @@ void ResourceImporterTexture::update_imports() {
}
String ResourceImporterTexture::get_importer_name() const {
-
return "texture";
}
String ResourceImporterTexture::get_visible_name() const {
-
return "Texture2D";
}
-void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
+
String ResourceImporterTexture::get_save_extension() const {
return "stex";
}
String ResourceImporterTexture::get_resource_type() const {
-
return "StreamTexture2D";
}
bool ResourceImporterTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
if (p_option == "compress/lossy_quality") {
int compress_mode = int(p_options["compress/mode"]);
if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VRAM_COMPRESSED) {
@@ -189,22 +181,20 @@ bool ResourceImporterTexture::get_option_visibility(const String &p_option, cons
}
int ResourceImporterTexture::get_preset_count() const {
- return 4;
+ return 3;
}
-String ResourceImporterTexture::get_preset_name(int p_idx) const {
+String ResourceImporterTexture::get_preset_name(int p_idx) const {
static const char *preset_names[] = {
- "2D, Detect 3D",
+ "2D/3D (Auto-Detect)",
"2D",
- "2D Pixel",
- "3D"
+ "3D",
};
return preset_names[p_idx];
}
void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,VRAM Compressed,VRAM Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1));
@@ -226,10 +216,8 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
}
void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) {
-
switch (p_compress_mode) {
case COMPRESS_LOSSLESS: {
-
f->store_32(StreamTexture2D::DATA_FORMAT_LOSSLESS);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
@@ -237,7 +225,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
f->store_32(p_image->get_format());
for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) {
-
Vector<uint8_t> data = Image::lossless_packer(p_image->get_image_from_mipmap(i));
int data_len = data.size();
f->store_32(data_len);
@@ -248,7 +235,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
} break;
case COMPRESS_LOSSY: {
-
f->store_32(StreamTexture2D::DATA_FORMAT_LOSSY);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
@@ -256,7 +242,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
f->store_32(p_image->get_format());
for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) {
-
Vector<uint8_t> data = Image::lossy_packer(p_image->get_image_from_mipmap(i), p_lossy_quality);
int data_len = data.size();
f->store_32(data_len);
@@ -266,7 +251,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
}
} break;
case COMPRESS_VRAM_COMPRESSED: {
-
Ref<Image> image = p_image->duplicate();
image->compress_from_channels(p_compress_format, p_channels, p_lossy_quality);
@@ -283,7 +267,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
f->store_buffer(r, dl);
} break;
case COMPRESS_VRAM_UNCOMPRESSED: {
-
f->store_32(StreamTexture2D::DATA_FORMAT_IMAGE);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
@@ -298,7 +281,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
} break;
case COMPRESS_BASIS_UNIVERSAL: {
-
f->store_32(StreamTexture2D::DATA_FORMAT_BASIS_UNIVERSAL);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
@@ -306,7 +288,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
f->store_32(p_image->get_format());
for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) {
-
Vector<uint8_t> data = Image::basis_universal_packer(p_image->get_image_from_mipmap(i), p_channels);
int data_len = data.size();
f->store_32(data_len);
@@ -319,7 +300,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
}
void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) {
-
FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
f->store_8('G');
f->store_8('S');
@@ -333,16 +313,21 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
f->store_32(p_image->get_height());
uint32_t flags = 0;
- if (p_streamable)
+ if (p_streamable) {
flags |= StreamTexture2D::FORMAT_BIT_STREAM;
- if (p_mipmaps)
+ }
+ if (p_mipmaps) {
flags |= StreamTexture2D::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
- if (p_detect_3d)
+ }
+ if (p_detect_3d) {
flags |= StreamTexture2D::FORMAT_BIT_DETECT_3D;
- if (p_detect_roughness)
+ }
+ if (p_detect_roughness) {
flags |= StreamTexture2D::FORMAT_BIT_DETECT_ROUGNESS;
- if (p_detect_normal)
+ }
+ if (p_detect_normal) {
flags |= StreamTexture2D::FORMAT_BIT_DETECT_NORMAL;
+ }
f->store_32(flags);
f->store_32(p_limit_mipmap);
@@ -396,7 +381,6 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
}
Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
CompressMode compress_mode = CompressMode(int(p_options["compress/mode"]));
float lossy = p_options["compress/lossy_quality"];
int pack_channels = p_options["compress/channel_pack"];
@@ -427,8 +411,9 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
Ref<Image> image;
image.instance();
Error err = ImageLoader::load_image(p_source_file, image, nullptr, hdr_as_srgb, scale);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
Array formats_imported;
@@ -440,7 +425,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC);
} else {
-
int new_height = size_limit;
int new_width = image->get_width() * new_height / image->get_height();
@@ -501,7 +485,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
bool has_alpha = image->detect_alpha() != Image::ALPHA_NONE;
if (is_hdr && can_compress_hdr) {
-
if (has_alpha) {
//can compress hdr, but hdr with alpha is not compressible
if (hdr_compression == 2) {
@@ -542,7 +525,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
-
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("etc2");
formats_imported.push_back("etc2");
@@ -555,7 +537,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
-
_save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("pvrtc");
formats_imported.push_back("pvrtc");
@@ -589,7 +570,6 @@ const char *ResourceImporterTexture::compression_formats[] = {
nullptr
};
String ResourceImporterTexture::get_import_settings_string() const {
-
String s;
int index = 0;
@@ -606,7 +586,6 @@ String ResourceImporterTexture::get_import_settings_string() const {
}
bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) const {
-
//will become invalid if formats are missing to import
Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path);
@@ -644,7 +623,6 @@ bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) co
ResourceImporterTexture *ResourceImporterTexture::singleton = nullptr;
ResourceImporterTexture::ResourceImporterTexture() {
-
singleton = this;
StreamTexture2D::request_3d_callback = _texture_reimport_3d;
StreamTexture2D::request_roughness_callback = _texture_reimport_roughness;
diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h
index da8ce3c0a8..12eb7f67c2 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -60,7 +60,6 @@ protected:
Mutex mutex;
struct MakeInfo {
-
int flags;
String normal_path_for_roughness;
RS::TextureDetectRoughnessChannel channel_for_roughness;
@@ -94,7 +93,6 @@ public:
enum Preset {
PRESET_DETECT,
PRESET_2D,
- PRESET_2D_PIXEL,
PRESET_3D,
};
diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp
index 2765bb7fae..2423553d22 100644
--- a/editor/import/resource_importer_texture_atlas.cpp
+++ b/editor/import/resource_importer_texture_atlas.cpp
@@ -33,22 +33,21 @@
#include "atlas_import_failed.xpm"
#include "core/io/image_loader.h"
#include "core/io/resource_saver.h"
+#include "core/math/geometry_2d.h"
#include "core/os/file_access.h"
#include "editor/editor_atlas_packer.h"
#include "scene/resources/mesh.h"
#include "scene/resources/texture.h"
String ResourceImporterTextureAtlas::get_importer_name() const {
-
return "texture_atlas";
}
String ResourceImporterTextureAtlas::get_visible_name() const {
-
return "TextureAtlas";
}
-void ResourceImporterTextureAtlas::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterTextureAtlas::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
@@ -57,25 +56,22 @@ String ResourceImporterTextureAtlas::get_save_extension() const {
}
String ResourceImporterTextureAtlas::get_resource_type() const {
-
return "Texture2D";
}
bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
return true;
}
int ResourceImporterTextureAtlas::get_preset_count() const {
return 0;
}
-String ResourceImporterTextureAtlas::get_preset_name(int p_idx) const {
+String ResourceImporterTextureAtlas::get_preset_name(int p_idx) const {
return String();
}
void ResourceImporterTextureAtlas::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "atlas_file", PROPERTY_HINT_SAVE_FILE, "*.png"), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_mode", PROPERTY_HINT_ENUM, "Region,Mesh2D"), 0));
}
@@ -85,7 +81,6 @@ String ResourceImporterTextureAtlas::get_option_group_file() const {
}
Error ResourceImporterTextureAtlas::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
/* If this happens, it's because the atlas_file field was not filled, so just import a broken texture */
//use an xpm because it's size independent, the editor images are vector and size dependent
@@ -103,7 +98,6 @@ Error ResourceImporterTextureAtlas::import(const String &p_source_file, const St
}
static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_transposed, Ref<Image> p_image, const Ref<Image> &p_src_image) {
-
int width = p_image->get_width();
int height = p_image->get_height();
int src_width = p_src_image->get_width();
@@ -113,7 +107,6 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
int y[3];
for (int j = 0; j < 3; j++) {
-
x[j] = vertices[j].x;
y[j] = vertices[j].y;
}
@@ -137,10 +130,10 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
double dx_low = double(x[2] - x[1]) / (y[2] - y[1] + 1);
double xf = x[0];
double xt = x[0] + dx_upper; // if y[0] == y[1], special case
- for (int yi = y[0]; yi <= (y[2] > height - 1 ? height - 1 : y[2]); yi++) {
+ int max_y = MIN(y[2], height - p_offset.y - 1);
+ for (int yi = y[0]; yi <= max_y; yi++) {
if (yi >= 0) {
for (int xi = (xf > 0 ? int(xf) : 0); xi <= (xt < width ? xt : width - 1); xi++) {
-
int px = xi, py = yi;
int sx = px, sy = py;
sx = CLAMP(sx, 0, src_width - 1);
@@ -185,15 +178,15 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
}
}
xf += dx_far;
- if (yi < y[1])
+ if (yi < y[1]) {
xt += dx_upper;
- else
+ } else {
xt += dx_low;
+ }
}
}
Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) {
-
ERR_FAIL_COND_V(p_source_file_options.size() == 0, ERR_BUG); //should never happen
Vector<EditorAtlasPacker::Chart> charts;
@@ -203,7 +196,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
int idx = 0;
for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) {
-
PackData &pack_data = pack_data_files.write[idx];
const String &source = E->key();
const Map<StringName, Variant> &options = E->get();
@@ -218,7 +210,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
int mode = options["import_mode"];
if (mode == IMPORT_MODE_REGION) {
-
pack_data.is_mesh = false;
EditorAtlasPacker::Chart chart;
@@ -254,14 +245,12 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
Vector<Vector<Vector2>> polygons = bit_map->clip_opaque_to_polygons(Rect2(0, 0, image->get_width(), image->get_height()));
for (int j = 0; j < polygons.size(); j++) {
-
EditorAtlasPacker::Chart chart;
chart.vertices = polygons[j];
chart.can_transpose = true;
- Vector<int> poly = Geometry::triangulate_polygon(polygons[j]);
+ Vector<int> poly = Geometry2D::triangulate_polygon(polygons[j]);
for (int i = 0; i < poly.size(); i += 3) {
-
EditorAtlasPacker::Chart::Face f;
f.vertex[0] = poly[i + 0];
f.vertex[1] = poly[i + 1];
@@ -287,7 +276,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
new_atlas->create(atlas_width, atlas_height, false, Image::FORMAT_RGBA8);
for (int i = 0; i < pack_data_files.size(); i++) {
-
PackData &pack_data = pack_data_files.write[i];
for (int j = 0; j < pack_data.chart_pieces.size(); j++) {
@@ -324,7 +312,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//save the images
idx = 0;
for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) {
-
PackData &pack_data = pack_data_files.write[idx];
Ref<Texture2D> texture;
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 71f81051bc..cb669b4c89 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -39,29 +39,26 @@ const float TRIM_DB_LIMIT = -50;
const int TRIM_FADE_OUT_FRAMES = 500;
String ResourceImporterWAV::get_importer_name() const {
-
return "wav";
}
String ResourceImporterWAV::get_visible_name() const {
-
return "Microsoft WAV";
}
-void ResourceImporterWAV::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterWAV::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("wav");
}
+
String ResourceImporterWAV::get_save_extension() const {
return "sample";
}
String ResourceImporterWAV::get_resource_type() const {
-
return "AudioStreamSample";
}
bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) {
return false;
}
@@ -72,13 +69,12 @@ bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Ma
int ResourceImporterWAV::get_preset_count() const {
return 0;
}
-String ResourceImporterWAV::get_preset_name(int p_idx) const {
+String ResourceImporterWAV::get_preset_name(int p_idx) const {
return String();
}
void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/8_bit"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
@@ -90,7 +86,6 @@ void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int
}
Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
/* STEP 1, READ WAVE FILE */
Error err;
@@ -104,7 +99,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->get_buffer((uint8_t *)&riff, 4); //RIFF
if (riff[0] != 'R' || riff[1] != 'I' || riff[2] != 'F' || riff[3] != 'F') {
-
file->close();
memdelete(file);
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
@@ -120,7 +114,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->get_buffer((uint8_t *)&wave, 4); //RIFF
if (wave[0] != 'W' || wave[1] != 'A' || wave[2] != 'V' || wave[3] != 'E') {
-
file->close();
memdelete(file);
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Not a WAV file (no WAVE RIFF header).");
@@ -141,7 +134,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
Vector<float> data;
while (!file->eof_reached()) {
-
/* chunk */
char chunkID[4];
file->get_buffer((uint8_t *)&chunkID, 4); //RIFF
@@ -151,7 +143,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
uint32_t file_pos = file->get_position(); //save file pos, so we can skip to next chunk safely
if (file->eof_reached()) {
-
//ERR_PRINT("EOF REACH");
break;
}
@@ -242,7 +233,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
uint32_t s = 0;
for (int b = 0; b < (format_bits >> 3); b++) {
-
s |= ((uint32_t)file->get_8()) << (b * 8);
}
s <<= (32 - format_bits);
@@ -270,8 +260,9 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
* 22:38 06.07.2017 GMT
**/
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++) {
file->get_32(); // i wish to know why should i do this... no doc!
+ }
// only read 0x00 (loop forward), 0x01 (loop ping-pong) and 0x02 (loop backward)
// Skip anything else because it's not supported, reserved for future uses or sampler specific
@@ -322,12 +313,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
Vector<float> new_data;
new_data.resize(new_data_frames * format_channels);
for (int c = 0; c < format_channels; c++) {
-
float frac = .0f;
int ipos = 0;
for (int i = 0; i < new_data_frames; i++) {
-
//simple cubic interpolation should be enough.
float mu = frac;
@@ -370,20 +359,17 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool normalize = p_options["edit/normalize"];
if (normalize) {
-
float max = 0;
for (int i = 0; i < data.size(); i++) {
-
float amp = Math::abs(data[i]);
- if (amp > max)
+ if (amp > max) {
max = amp;
+ }
}
if (max > 0) {
-
float mult = 1.0 / max;
for (int i = 0; i < data.size(); i++) {
-
data.write[i] *= mult;
}
}
@@ -392,7 +378,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool trim = p_options["edit/trim"];
if (trim && !loop && format_channels > 0) {
-
int first = 0;
int last = (frames / format_channels) - 1;
bool found = false;
@@ -420,7 +405,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
Vector<float> new_data;
new_data.resize((last - first) * format_channels);
for (int i = first; i < last; i++) {
-
float fadeOutMult = 1;
if (last - i < TRIM_FADE_OUT_FRAMES) {
@@ -440,7 +424,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool make_loop = p_options["edit/loop"];
if (make_loop && !loop) {
-
loop = AudioStreamSample::LOOP_FORWARD;
loop_begin = 0;
loop_end = frames;
@@ -450,7 +433,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool force_mono = p_options["force/mono"];
if (force_mono && format_channels == 2) {
-
Vector<float> new_data;
new_data.resize(data.size() / 2);
for (int i = 0; i < frames; i++) {
@@ -463,7 +445,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool force_8_bit = p_options["force/8_bit"];
if (force_8_bit) {
-
is16 = false;
}
@@ -471,12 +452,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
AudioStreamSample::Format dst_format;
if (compression == 1) {
-
dst_format = AudioStreamSample::FORMAT_IMA_ADPCM;
if (format_channels == 1) {
_compress_ima_adpcm(data, dst_data);
} else {
-
//byte interleave
Vector<float> left;
Vector<float> right;
@@ -510,7 +489,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
} else {
-
dst_format = is16 ? AudioStreamSample::FORMAT_16_BITS : AudioStreamSample::FORMAT_8_BITS;
dst_data.resize(data.size() * (is16 ? 2 : 1));
{
@@ -518,7 +496,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
int ds = data.size();
for (int i = 0; i < ds; i++) {
-
if (is16) {
int16_t v = CLAMP(data[i] * 32768, -32768, 32767);
encode_uint16(v, &w[i * 2]);
diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h
index bc2f023e6b..3ff3aea9f4 100644
--- a/editor/import/resource_importer_wav.h
+++ b/editor/import/resource_importer_wav.h
@@ -72,8 +72,9 @@ public:
int datalen = p_data.size();
int datamax = datalen;
- if (datalen & 1)
+ if (datalen & 1) {
datalen++;
+ }
dst_data.resize(datalen / 2 + 4);
uint8_t *w = dst_data.ptrw();
@@ -96,10 +97,9 @@ public:
uint8_t nibble;
int16_t xm_sample;
- if (i >= datamax)
+ if (i >= datamax) {
xm_sample = 0;
- else {
-
+ } else {
xm_sample = CLAMP(in[i] * 32767.0, -32768, 32767);
/*
if (xm_sample==32767 || xm_sample==-32768)
@@ -121,9 +121,7 @@ public:
}
mask = 4;
while (mask) {
-
if (diff >= step) {
-
nibble |= mask;
diff -= step;
vpdiff += step;
@@ -133,10 +131,11 @@ public:
mask >>= 1;
};
- if (nibble & 8)
+ if (nibble & 8) {
prev -= vpdiff;
- else
+ } else {
prev += vpdiff;
+ }
if (prev > 32767) {
//printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev);
@@ -147,10 +146,11 @@ public:
}
step_idx += _ima_adpcm_index_table[nibble];
- if (step_idx < 0)
+ if (step_idx < 0) {
step_idx = 0;
- else if (step_idx > 88)
+ } else if (step_idx > 88) {
step_idx = 88;
+ }
if (i & 1) {
*out |= nibble << 4;
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 22f6aedeaa..8ab2e0aef1 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -44,7 +44,6 @@ public:
bool checking;
bool _set(const StringName &p_name, const Variant &p_value) {
-
if (values.has(p_name)) {
values[p_name] = p_value;
if (checking) {
@@ -58,7 +57,6 @@ public:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
if (values.has(p_name)) {
r_ret = values[p_name];
return true;
@@ -67,10 +65,10 @@ public:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- if (!importer->get_option_visibility(E->get().name, values))
+ if (!importer->get_option_visibility(E->get().name, values)) {
continue;
+ }
PropertyInfo pi = E->get();
if (checking) {
pi.usage |= PROPERTY_USAGE_CHECKABLE;
@@ -92,7 +90,6 @@ public:
};
void ImportDock::set_edit_path(const String &p_path) {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load(p_path + ".import");
@@ -140,7 +137,6 @@ void ImportDock::set_edit_path(const String &p_path) {
}
void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
-
List<ResourceImporter::ImportOption> options;
params->importer->get_import_options(&options);
@@ -150,7 +146,6 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
params->checked.clear();
for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
-
params->properties.push_back(E->get().option);
if (p_config.is_valid() && p_config->has_section_key("params", E->get().option.name)) {
params->values[E->get().option.name] = p_config->get_value("params", E->get().option.name);
@@ -164,14 +159,12 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
}
void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
-
clear();
// Use the value that is repeated the most.
Map<String, Dictionary> value_frequency;
for (int i = 0; i < p_paths.size(); i++) {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load(p_paths[i] + ".import");
@@ -189,7 +182,6 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
config->get_section_keys("params", &keys);
for (List<String>::Element *E = keys.front(); E; E = E->next()) {
-
if (!value_frequency.has(E->get())) {
value_frequency[E->get()] = Dictionary();
}
@@ -215,11 +207,9 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
params->checked.clear();
for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
-
params->properties.push_back(E->get().option);
if (value_frequency.has(E->get().option.name)) {
-
Dictionary d = value_frequency[E->get().option.name];
int freq = 0;
List<Variant> v;
@@ -309,7 +299,6 @@ void ImportDock::_importer_selected(int i_idx) {
}
void ImportDock::_preset_selected(int p_idx) {
-
int item_id = preset->get_popup()->get_item_id(p_idx);
switch (item_id) {
@@ -325,7 +314,6 @@ void ImportDock::_preset_selected(int p_idx) {
_update_preset_menu();
} break;
case ITEM_LOAD_DEFAULT: {
-
ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name()));
Dictionary d = ProjectSettings::get_singleton()->get("importer_defaults/" + params->importer->get_importer_name());
@@ -344,13 +332,11 @@ void ImportDock::_preset_selected(int p_idx) {
params->update();
} break;
case ITEM_CLEAR_DEFAULT: {
-
ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), Variant());
ProjectSettings::get_singleton()->save();
_update_preset_menu();
} break;
default: {
-
List<ResourceImporter::ImportOption> options;
params->importer->get_import_options(&options, p_idx);
@@ -370,7 +356,6 @@ void ImportDock::_preset_selected(int p_idx) {
}
void ImportDock::clear() {
-
imported->set_text("");
import->set_disabled(true);
import_as->clear();
@@ -383,28 +368,27 @@ void ImportDock::clear() {
}
static bool _find_owners(EditorFileSystemDirectory *efsd, const String &p_path) {
-
- if (!efsd)
+ if (!efsd) {
return false;
+ }
for (int i = 0; i < efsd->get_subdir_count(); i++) {
-
if (_find_owners(efsd->get_subdir(i), p_path)) {
return true;
}
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
Vector<String> deps = efsd->get_file_deps(i);
- if (deps.find(p_path) != -1)
+ if (deps.find(p_path) != -1) {
return true;
+ }
}
return false;
}
-void ImportDock::_reimport_attempt() {
+void ImportDock::_reimport_attempt() {
bool need_restart = false;
bool used_in_resources = false;
for (int i = 0; i < params->paths.size(); i++) {
@@ -432,7 +416,6 @@ void ImportDock::_reimport_attempt() {
}
void ImportDock::_reimport_and_restart() {
-
EditorNode::get_singleton()->save_all_scenes();
EditorResourcePreview::get_singleton()->stop(); //don't try to re-create previews after import
_reimport();
@@ -440,9 +423,7 @@ void ImportDock::_reimport_and_restart() {
}
void ImportDock::_reimport() {
-
for (int i = 0; i < params->paths.size(); i++) {
-
Ref<ConfigFile> config;
config.instance();
Error err = config->load(params->paths[i] + ".import");
@@ -460,7 +441,9 @@ void ImportDock::_reimport() {
} else {
//override entirely
config->set_value("remap", "importer", importer_name);
- config->erase_section("params");
+ if (config->has_section("params")) {
+ config->erase_section("params");
+ }
for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) {
config->set_value("params", E->get().name, params->values[E->get().name]);
@@ -489,14 +472,11 @@ void ImportDock::_reimport() {
void ImportDock::_notification(int p_what) {
switch (p_what) {
-
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
imported->add_theme_style_override("normal", get_theme_stylebox("normal", "LineEdit"));
} break;
case NOTIFICATION_ENTER_TREE: {
-
import_opts->edit(params);
label_warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
} break;
@@ -510,20 +490,18 @@ void ImportDock::_property_toggled(const StringName &p_prop, bool p_checked) {
params->checked.erase(p_prop);
}
}
-void ImportDock::_bind_methods() {
+void ImportDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport);
}
void ImportDock::initialize_import_options() const {
-
ERR_FAIL_COND(!import_opts || !params);
import_opts->edit(params);
}
ImportDock::ImportDock() {
-
set_name("Import");
imported = memnew(Label);
imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit"));
@@ -572,6 +550,5 @@ ImportDock::ImportDock() {
}
ImportDock::~ImportDock() {
-
memdelete(params);
}
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 3715547bdc..2b26851140 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -68,14 +68,16 @@ void InspectorDock::_menu_option(int p_option) {
case OBJECT_COPY_PARAMS: {
editor_data->apply_changes_in_editors();
- if (current)
+ if (current) {
editor_data->copy_object_params(current);
+ }
} break;
case OBJECT_PASTE_PARAMS: {
editor_data->apply_changes_in_editors();
- if (current)
+ if (current) {
editor_data->paste_object_params(current);
+ }
} break;
case OBJECT_UNIQUE_RESOURCES: {
@@ -85,18 +87,16 @@ void InspectorDock::_menu_option(int p_option) {
current->get_property_list(&props);
Map<RES, RES> duplicates;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
Variant v = current->get(E->get().name);
if (v.is_ref()) {
REF ref = v;
if (ref.is_valid()) {
-
RES res = ref;
if (res.is_valid()) {
-
if (!duplicates.has(res)) {
duplicates[res] = res->duplicate();
}
@@ -172,10 +172,11 @@ void InspectorDock::_save_resource(bool save_as) const {
RES current_res = RES(Object::cast_to<Resource>(current_obj));
- if (save_as)
+ if (save_as) {
editor->save_resource_as(current_res);
- else
+ } else {
editor->save_resource(current_res);
+ }
}
void InspectorDock::_unref_resource() const {
@@ -217,7 +218,6 @@ void InspectorDock::_prepare_history() {
Ref<Texture2D> base_icon = get_theme_icon("Object", "EditorIcons");
Set<ObjectID> already;
for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) {
-
ObjectID id = editor_history->get_history_obj(i);
Object *obj = ObjectDB::get_instance(id);
if (!obj || already.has(id)) {
@@ -237,9 +237,9 @@ void InspectorDock::_prepare_history() {
String text;
if (Object::cast_to<Resource>(obj)) {
Resource *r = Object::cast_to<Resource>(obj);
- if (r->get_path().is_resource_file())
+ if (r->get_path().is_resource_file()) {
text = r->get_path().get_file();
- else if (r->get_name() != String()) {
+ } else if (r->get_name() != String()) {
text = r->get_name();
} else {
text = r->get_class();
@@ -263,8 +263,9 @@ void InspectorDock::_select_history(int p_idx) {
//push it to the top, it is not correct, but it's more useful
ObjectID id = EditorNode::get_singleton()->get_editor_history()->get_history_obj(p_idx);
Object *obj = ObjectDB::get_instance(id);
- if (!obj)
+ if (!obj) {
return;
+ }
editor->push_item(obj);
}
@@ -280,21 +281,25 @@ void InspectorDock::_resource_created() {
}
void InspectorDock::_resource_selected(const RES &p_res, const String &p_property) {
- if (p_res.is_null())
+ if (p_res.is_null()) {
return;
+ }
RES r = p_res;
editor->push_item(r.operator->(), p_property);
}
void InspectorDock::_edit_forward() {
- if (EditorNode::get_singleton()->get_editor_history()->next())
+ if (EditorNode::get_singleton()->get_editor_history()->next()) {
editor->edit_current();
+ }
}
+
void InspectorDock::_edit_back() {
EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
- if ((current && editor_history->previous()) || editor_history->get_path_size() == 1)
+ if ((current && editor_history->previous()) || editor_history->get_path_size() == 1) {
editor->edit_current();
+ }
}
void InspectorDock::_menu_collapseall() {
@@ -311,8 +316,9 @@ void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_valu
void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) {
Node3D *s = Object::cast_to<Node3D>(sp);
- if (!s)
+ if (!s) {
return;
+ }
AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(s, p_sub, p_key);
}
@@ -342,7 +348,6 @@ void InspectorDock::_notification(int p_what) {
}
void InspectorDock::_bind_methods() {
-
ClassDB::bind_method("update_keying", &InspectorDock::update_keying);
ClassDB::bind_method("_transform_keyed", &InspectorDock::_transform_keyed); // Still used by some connect_compat.
@@ -376,7 +381,6 @@ void InspectorDock::clear() {
}
void InspectorDock::update(Object *p_object) {
-
EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
backward_button->set_disabled(editor_history->is_at_beginning());
forward_button->set_disabled(editor_history->is_at_end());
@@ -442,12 +446,10 @@ void InspectorDock::update(Object *p_object) {
p_object->get_method_list(&methods);
if (!methods.empty()) {
-
bool found = false;
List<MethodInfo>::Element *I = methods.front();
int i = 0;
while (I) {
-
if (I->get().flags & METHOD_FLAG_EDITOR) {
if (!found) {
p->add_separator();
@@ -469,13 +471,10 @@ void InspectorDock::update_keying() {
bool valid = false;
if (AnimationPlayerEditor::singleton->get_track_editor()->has_keying()) {
-
EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
if (editor_history->get_path_size() >= 1) {
-
Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0));
if (Object::cast_to<Node>(obj)) {
-
valid = true;
}
}
diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h
index 61b3239169..2a99a7db45 100644
--- a/editor/inspector_dock.h
+++ b/editor/inspector_dock.h
@@ -47,7 +47,6 @@
class EditorNode;
class InspectorDock : public VBoxContainer {
-
GDCLASS(InspectorDock, VBoxContainer);
enum MenuOptions {
diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp
index 7bc67b54c1..1077aca7b3 100644
--- a/editor/multi_node_edit.cpp
+++ b/editor/multi_node_edit.cpp
@@ -39,8 +39,9 @@ bool MultiNodeEdit::_set(const StringName &p_name, const Variant &p_value) {
bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, const String &p_field) {
Node *es = EditorNode::get_singleton()->get_edited_scene();
- if (!es)
+ if (!es) {
return false;
+ }
String name = p_name;
@@ -52,13 +53,14 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS);
for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) {
-
- if (!es->has_node(E->get()))
+ if (!es->has_node(E->get())) {
continue;
+ }
Node *n = es->get_node(E->get());
- if (!n)
+ if (!n) {
continue;
+ }
if (p_value.get_type() == Variant::NODE_PATH) {
Node *tonode = n->get_node(p_value);
@@ -87,8 +89,9 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const {
Node *es = EditorNode::get_singleton()->get_edited_scene();
- if (!es)
+ if (!es) {
return false;
+ }
String name = p_name;
if (name == "scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
@@ -96,18 +99,20 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const {
}
for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) {
-
- if (!es->has_node(E->get()))
+ if (!es->has_node(E->get())) {
continue;
+ }
const Node *n = es->get_node(E->get());
- if (!n)
+ if (!n) {
continue;
+ }
bool found;
r_ret = n->get(name, &found);
- if (found)
+ if (found) {
return true;
+ }
}
return false;
@@ -117,29 +122,31 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const {
HashMap<String, PLData> usage;
Node *es = EditorNode::get_singleton()->get_edited_scene();
- if (!es)
+ if (!es) {
return;
+ }
int nc = 0;
List<PLData *> data_list;
for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) {
-
- if (!es->has_node(E->get()))
+ if (!es->has_node(E->get())) {
continue;
+ }
Node *n = es->get_node(E->get());
- if (!n)
+ if (!n) {
continue;
+ }
List<PropertyInfo> plist;
n->get_property_list(&plist, true);
for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) {
-
- if (F->get().name == "script")
+ if (F->get().name == "script") {
continue; //added later manually, since this is intercepted before being set (check Variant Object::get() )
+ }
if (!usage.has(F->get().name)) {
PLData pld;
pld.uses = 0;
@@ -149,15 +156,15 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const {
}
// Make sure only properties with the same exact PropertyInfo data will appear
- if (usage[F->get().name].info == F->get())
+ if (usage[F->get().name].info == F->get()) {
usage[F->get().name].uses++;
+ }
}
nc++;
}
for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) {
-
if (nc == E->get()->uses) {
p_list->push_back(E->get()->info);
}
diff --git a/editor/multi_node_edit.h b/editor/multi_node_edit.h
index d3eefafcec..694dad76f1 100644
--- a/editor/multi_node_edit.h
+++ b/editor/multi_node_edit.h
@@ -34,7 +34,6 @@
#include "scene/main/node.h"
class MultiNodeEdit : public Reference {
-
GDCLASS(MultiNodeEdit, Reference);
List<NodePath> nodes;
diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp
index cb0d9fa02b..2ddcf3d877 100644
--- a/editor/node_3d_editor_gizmos.cpp
+++ b/editor/node_3d_editor_gizmos.cpp
@@ -30,7 +30,8 @@
#include "node_3d_editor_gizmos.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
+#include "core/math/geometry_3d.h"
#include "core/math/quick_hull.h"
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/3d/baked_lightmap.h"
@@ -69,26 +70,27 @@
#define HANDLE_HALF_SIZE 9.5
bool EditorNode3DGizmo::is_editable() const {
-
ERR_FAIL_COND_V(!spatial_node, false);
Node *edited_root = spatial_node->get_tree()->get_edited_scene_root();
- if (spatial_node == edited_root)
+ if (spatial_node == edited_root) {
return true;
- if (spatial_node->get_owner() == edited_root)
+ }
+ if (spatial_node->get_owner() == edited_root) {
return true;
+ }
- if (edited_root->is_editable_instance(spatial_node->get_owner()))
+ if (edited_root->is_editable_instance(spatial_node->get_owner())) {
return true;
+ }
return false;
}
void EditorNode3DGizmo::clear() {
-
for (int i = 0; i < instances.size(); i++) {
-
- if (instances[i].instance.is_valid())
+ if (instances[i].instance.is_valid()) {
RS::get_singleton()->free(instances[i].instance);
+ }
}
billboard_handle = false;
@@ -100,7 +102,6 @@ void EditorNode3DGizmo::clear() {
}
void EditorNode3DGizmo::redraw() {
-
if (get_script_instance() && get_script_instance()->has_method("redraw")) {
get_script_instance()->call("redraw");
return;
@@ -111,7 +112,6 @@ void EditorNode3DGizmo::redraw() {
}
String EditorNode3DGizmo::get_handle_name(int p_idx) const {
-
if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) {
return get_script_instance()->call("get_handle_name", p_idx);
}
@@ -121,7 +121,6 @@ String EditorNode3DGizmo::get_handle_name(int p_idx) const {
}
bool EditorNode3DGizmo::is_handle_highlighted(int p_idx) const {
-
if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) {
return get_script_instance()->call("is_handle_highlighted", p_idx);
}
@@ -131,7 +130,6 @@ bool EditorNode3DGizmo::is_handle_highlighted(int p_idx) const {
}
Variant EditorNode3DGizmo::get_handle_value(int p_idx) {
-
if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) {
return get_script_instance()->call("get_handle_value", p_idx);
}
@@ -141,7 +139,6 @@ Variant EditorNode3DGizmo::get_handle_value(int p_idx) {
}
void EditorNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
-
if (get_script_instance() && get_script_instance()->has_method("set_handle")) {
get_script_instance()->call("set_handle", p_idx, p_camera, p_point);
return;
@@ -152,7 +149,6 @@ void EditorNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &
}
void EditorNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
-
if (get_script_instance() && get_script_instance()->has_method("commit_handle")) {
get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel);
return;
@@ -163,27 +159,25 @@ void EditorNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
}
void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) {
-
ERR_FAIL_NULL(p_node);
spatial_node = p_node;
}
void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) {
-
instance = RS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world_3d()->get_scenario());
RS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id());
if (skin_reference.is_valid()) {
RS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton());
}
- if (extra_margin)
+ if (extra_margin) {
RS::get_singleton()->instance_set_extra_visibility_margin(instance, 1);
+ }
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, RS::SHADOW_CASTING_SETTING_OFF);
int layer = p_hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER;
RS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26
}
void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) {
-
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -221,10 +215,11 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate
{
Color *w = color.ptrw();
for (int i = 0; i < p_lines.size(); i++) {
- if (is_selected())
+ if (is_selected()) {
w[i] = Color(1, 1, 1, 0.8) * p_modulate;
- else
+ } else {
w[i] = Color(1, 1, 1, 0.2) * p_modulate;
+ }
}
}
@@ -236,7 +231,6 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate
if (p_billboard) {
float md = 0;
for (int i = 0; i < p_lines.size(); i++) {
-
md = MAX(0, p_lines[i].length());
}
if (md) {
@@ -255,7 +249,6 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate
}
void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) {
-
ERR_FAIL_COND(!spatial_node);
Instance ins;
@@ -297,7 +290,6 @@ void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
float md = 0;
for (int i = 0; i < vs.size(); i++) {
-
md = MAX(0, vs[i].length());
}
if (md) {
@@ -325,21 +317,19 @@ void EditorNode3DGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh
}
void EditorNode3DGizmo::add_collision_segments(const Vector<Vector3> &p_lines) {
-
int from = collision_segments.size();
collision_segments.resize(from + p_lines.size());
for (int i = 0; i < p_lines.size(); i++) {
-
collision_segments.write[from + i] = p_lines[i];
}
}
void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) {
-
billboard_handle = p_billboard;
- if (!is_selected() || !is_editable())
+ if (!is_selected() || !is_editable()) {
return;
+ }
ERR_FAIL_COND(!spatial_node);
@@ -355,13 +345,14 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
colors.resize(p_handles.size());
Color *w = colors.ptrw();
for (int i = 0; i < p_handles.size(); i++) {
-
Color col(1, 1, 1, 1);
- if (is_handle_highlighted(i))
+ if (is_handle_highlighted(i)) {
col = Color(0, 0, 1, 0.9);
+ }
- if (Node3DEditor::get_singleton()->get_over_gizmo_handle() != i)
+ if (Node3DEditor::get_singleton()->get_over_gizmo_handle() != i) {
col.a = 0.8;
+ }
w[i] = col;
}
@@ -373,7 +364,6 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
if (p_billboard) {
float md = 0;
for (int i = 0; i < p_handles.size(); i++) {
-
md = MAX(0, p_handles[i].length());
}
if (md) {
@@ -396,7 +386,6 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
handles.write[i + chs] = p_handles[i];
}
} else {
-
int chs = secondary_handles.size();
secondary_handles.resize(chs + p_handles.size());
for (int i = 0; i < p_handles.size(); i++) {
@@ -428,12 +417,12 @@ void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size,
}
bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) {
-
ERR_FAIL_COND_V(!spatial_node, false);
ERR_FAIL_COND_V(!valid, false);
- if (hidden && !gizmo_plugin->is_selectable_when_hidden())
+ if (hidden && !gizmo_plugin->is_selectable_when_hidden()) {
return false;
+ }
if (selectable_icon_size > 0.0f) {
Vector3 origin = spatial_node->get_global_transform().get_origin();
@@ -444,7 +433,6 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
bool any_out = false;
for (int j = 0; j < fc; j++) {
-
if (p[j].is_point_over(origin)) {
any_out = true;
break;
@@ -455,7 +443,6 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
}
if (collision_segments.size()) {
-
const Plane *p = p_frustum.ptr();
int fc = p_frustum.size();
@@ -472,12 +459,14 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
break;
}
}
- if (any_out)
+ if (any_out) {
break;
+ }
}
- if (!any_out)
+ if (!any_out) {
return true;
+ }
}
if (collision_mesh.is_valid()) {
@@ -494,7 +483,7 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
transformed_frustum.push_back(it.xform(p_frustum[i]));
}
- Vector<Vector3> convex_points = Geometry::compute_convex_mesh_points(p_frustum.ptr(), p_frustum.size());
+ Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(p_frustum.ptr(), p_frustum.size());
if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), convex_points.ptr(), convex_points.size(), mesh_scale)) {
return true;
}
@@ -504,15 +493,14 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector
}
bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) {
-
ERR_FAIL_COND_V(!spatial_node, false);
ERR_FAIL_COND_V(!valid, false);
- if (hidden && !gizmo_plugin->is_selectable_when_hidden())
+ if (hidden && !gizmo_plugin->is_selectable_when_hidden()) {
return false;
+ }
if (r_gizmo_handle && !hidden) {
-
Transform t = spatial_node->get_global_transform();
if (billboard_handle) {
t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
@@ -522,15 +510,12 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
int idx = -1;
for (int i = 0; i < secondary_handles.size(); i++) {
-
Vector3 hpos = t.xform(secondary_handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
if (p.distance_to(p_point) < HANDLE_HALF_SIZE) {
-
real_t dp = p_camera->get_transform().origin.distance_to(hpos);
if (dp < min_d) {
-
r_pos = t.xform(hpos);
r_normal = p_camera->get_transform().basis.get_axis(2);
min_d = dp;
@@ -540,7 +525,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
}
if (p_sec_first && idx != -1) {
-
*r_gizmo_handle = idx;
return true;
}
@@ -548,15 +532,12 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
min_d = 1e20;
for (int i = 0; i < handles.size(); i++) {
-
Vector3 hpos = t.xform(handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
if (p.distance_to(p_point) < HANDLE_HALF_SIZE) {
-
real_t dp = p_camera->get_transform().origin.distance_to(hpos);
if (dp < min_d) {
-
r_pos = t.xform(hpos);
r_normal = p_camera->get_transform().basis.get_axis(2);
min_d = dp;
@@ -572,7 +553,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
}
if (selectable_icon_size > 0.0f) {
-
Transform t = spatial_node->get_global_transform();
Vector3 camera_position = p_camera->get_camera_transform().origin;
if (camera_position.distance_squared_to(t.origin) > 0.01) {
@@ -618,7 +598,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
}
if (collision_segments.size()) {
-
Plane camp(p_camera->get_transform().origin, (-p_camera->get_transform().basis.get_axis(2)).normalized());
int vc = collision_segments.size();
@@ -632,23 +611,20 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
float cpd = 1e20;
for (int i = 0; i < vc / 2; i++) {
-
Vector3 a = t.xform(vptr[i * 2 + 0]);
Vector3 b = t.xform(vptr[i * 2 + 1]);
Vector2 s[2];
s[0] = p_camera->unproject_position(a);
s[1] = p_camera->unproject_position(b);
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, s);
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, s);
float pd = p.distance_to(p_point);
if (pd < cpd) {
-
float d = s[0].distance_to(s[1]);
Vector3 tcp;
if (d > 0) {
-
float d2 = s[0].distance_to(p) / d;
tcp = a + (b - a) * d2;
@@ -656,15 +632,15 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
tcp = a;
}
- if (camp.distance_to(tcp) < p_camera->get_znear())
+ if (camp.distance_to(tcp) < p_camera->get_znear()) {
continue;
+ }
cp = tcp;
cpd = pd;
}
}
if (cpd < 8) {
-
r_pos = cp;
r_normal = -p_camera->project_ray_normal(p_point);
return true;
@@ -686,7 +662,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
Vector3 rpos, rnorm;
if (collision_mesh->intersect_ray(ray_from, ray_dir, rpos, rnorm)) {
-
r_pos = gt.xform(rpos);
r_normal = gt.basis.xform(rnorm).normalized();
return true;
@@ -697,13 +672,11 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point,
}
void EditorNode3DGizmo::create() {
-
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(valid);
valid = true;
for (int i = 0; i < instances.size(); i++) {
-
instances.write[i].create_instance(spatial_node, hidden);
}
@@ -711,7 +684,6 @@ void EditorNode3DGizmo::create() {
}
void EditorNode3DGizmo::transform() {
-
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
for (int i = 0; i < instances.size(); i++) {
@@ -720,14 +692,13 @@ void EditorNode3DGizmo::transform() {
}
void EditorNode3DGizmo::free() {
-
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
for (int i = 0; i < instances.size(); i++) {
-
- if (instances[i].instance.is_valid())
+ if (instances[i].instance.is_valid()) {
RS::get_singleton()->free(instances[i].instance);
+ }
instances.write[i].instance = RID();
}
@@ -749,7 +720,6 @@ void EditorNode3DGizmo::set_plugin(EditorNode3DGizmoPlugin *p_plugin) {
}
void EditorNode3DGizmo::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorNode3DGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorNode3DGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorNode3DGizmo::add_collision_segments);
@@ -789,14 +759,13 @@ EditorNode3DGizmo::EditorNode3DGizmo() {
}
EditorNode3DGizmo::~EditorNode3DGizmo() {
-
- if (gizmo_plugin != nullptr)
+ if (gizmo_plugin != nullptr) {
gizmo_plugin->unregister_gizmo(this);
+ }
clear();
}
Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3());
return handles[p_idx];
@@ -805,7 +774,6 @@ Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const {
//// light gizmo
Light3DGizmoPlugin::Light3DGizmoPlugin() {
-
// Enable vertex colors for the materials below as the gizmo color depends on the light color.
create_material("lines_primary", Color(1, 1, 1), false, false, true);
create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true);
@@ -832,40 +800,39 @@ int Light3DGizmoPlugin::get_priority() const {
}
String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
- if (p_idx == 0)
+ if (p_idx == 0) {
return "Radius";
- else
+ } else {
return "Aperture";
+ }
}
Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
- if (p_idx == 0)
+ if (p_idx == 0) {
return light->get_param(Light3D::PARAM_RANGE);
- if (p_idx == 1)
+ }
+ if (p_idx == 1) {
return light->get_param(Light3D::PARAM_SPOT_ANGLE);
+ }
return Variant();
}
static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform &p_arc_xform) {
-
//bleh, discrete is simpler
static const int arc_test_points = 64;
float min_d = 1e20;
Vector3 min_p;
for (int i = 0; i < arc_test_points; i++) {
-
float a = i * Math_PI * 0.5 / arc_test_points;
float an = (i + 1) * Math_PI * 0.5 / arc_test_points;
Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius;
Vector3 n = Vector3(Math::cos(an), 0, -Math::sin(an)) * p_arc_radius;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(p, n, p_from, p_to, ra, rb);
+ Geometry3D::get_closest_points_between_segments(p, n, p_from, p_to, ra, rb);
float d = ra.distance_to(rb);
if (d < min_d) {
@@ -880,7 +847,6 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec
}
void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
-
Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
Transform gt = light->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -890,27 +856,25 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer
Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (p_idx == 0) {
-
if (Object::cast_to<SpotLight3D>(light)) {
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb);
float d = -ra.z;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d <= 0) // Equal is here for negative zero.
+ if (d <= 0) { // Equal is here for negative zero.
d = 0;
+ }
light->set_param(Light3D::PARAM_RANGE, d);
} else if (Object::cast_to<OmniLight3D>(light)) {
-
Plane cp = Plane(gt.origin, p_camera->get_transform().basis.get_axis(2));
Vector3 inters;
if (cp.intersects_ray(ray_from, ray_dir, &inters)) {
-
float r = inters.distance_to(gt.origin);
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
r = Math::stepify(r, Node3DEditor::get_singleton()->get_translate_snap());
@@ -921,28 +885,23 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer
}
} else if (p_idx == 1) {
-
float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light3D::PARAM_RANGE), gt);
light->set_param(Light3D::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99));
}
}
void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
-
light->set_param(p_idx == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore);
} else if (p_idx == 0) {
-
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Light Radius"));
ur->add_do_method(light, "set_param", Light3D::PARAM_RANGE, light->get_param(Light3D::PARAM_RANGE));
ur->add_undo_method(light, "set_param", Light3D::PARAM_RANGE, p_restore);
ur->commit_action();
} else if (p_idx == 1) {
-
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Light Radius"));
ur->add_do_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, light->get_param(Light3D::PARAM_SPOT_ANGLE));
@@ -952,7 +911,6 @@ void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, co
}
void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node());
Color color = light->get_color();
@@ -962,7 +920,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
if (Object::cast_to<DirectionalLight3D>(light)) {
-
Ref<Material> material = get_material("lines_primary", p_gizmo);
Ref<Material> icon = get_material("light_directional_icon", p_gizmo);
@@ -1000,7 +957,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<OmniLight3D>(light)) {
-
// Use both a billboard circle and 3 non-billboard circles for a better sphere-like representation
const Ref<Material> lines_material = get_material("lines_secondary", p_gizmo);
const Ref<Material> lines_billboard_material = get_material("lines_billboard", p_gizmo);
@@ -1012,7 +968,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> points_billboard;
for (int i = 0; i < 120; i++) {
-
// Create a circle
const float ra = Math::deg2rad((float)(i * 3));
const float rb = Math::deg2rad((float)((i + 1) * 3));
@@ -1042,7 +997,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<SpotLight3D>(light)) {
-
const Ref<Material> material_primary = get_material("lines_primary", p_gizmo);
const Ref<Material> material_secondary = get_material("lines_secondary", p_gizmo);
const Ref<Material> icon = get_material("light_spot_icon", p_gizmo);
@@ -1056,7 +1010,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
float d = r * Math::cos(Math::deg2rad(sl->get_param(Light3D::PARAM_SPOT_ANGLE)));
for (int i = 0; i < 120; i++) {
-
// Draw a circle
const float ra = Math::deg2rad((float)(i * 3));
const float rb = Math::deg2rad((float)((i + 1) * 3));
@@ -1095,7 +1048,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
//// player gizmo
AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() {
-
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1));
create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("Gizmo3DSamplePlayer", "EditorIcons"));
@@ -1117,7 +1069,6 @@ int AudioStreamPlayer3DGizmoPlugin::get_priority() const {
}
String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
return "Emission Radius";
}
@@ -1127,7 +1078,6 @@ Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gi
}
void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
-
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
Transform gt = player->get_global_transform();
@@ -1144,7 +1094,6 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int
float closest_angle = 1e20;
for (int i = 0; i < 180; i++) {
-
float a = i * Math_PI / 180.0;
float an = (i + 1) * Math_PI / 180.0;
@@ -1152,7 +1101,7 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int
Vector3 to(Math::sin(an), 0, -Math::cos(an));
Vector3 r1, r2;
- Geometry::get_closest_points_between_segments(from, to, ray_from, ray_to, r1, r2);
+ Geometry3D::get_closest_points_between_segments(from, to, ray_from, ray_to, r1, r2);
float d = r1.distance_to(r2);
if (d < closest_dist) {
closest_dist = d;
@@ -1166,15 +1115,12 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int
}
void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
-
player->set_emission_angle(p_restore);
} else {
-
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change AudioStreamPlayer3D Emission Angle"));
ur->add_do_method(player, "set_emission_angle", player->get_emission_angle());
@@ -1184,7 +1130,6 @@ void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, i
}
void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1192,7 +1137,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
const Ref<Material> icon = get_material("stream_player_3d_icon", p_gizmo);
if (player->is_emission_angle_enabled()) {
-
const float pc = player->get_emission_angle();
const float ofs = -Math::cos(Math::deg2rad(pc));
const float radius = Math::sin(Math::deg2rad(pc));
@@ -1201,7 +1145,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
points_primary.resize(200);
for (int i = 0; i < 100; i++) {
-
const float a = i * 2.0 * Math_PI / 100.0;
const float an = (i + 1) * 2.0 * Math_PI / 100.0;
@@ -1219,7 +1162,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
points_secondary.resize(16);
for (int i = 0; i < 8; i++) {
-
const float a = i * 2.0 * Math_PI / 8.0;
const Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs);
@@ -1242,7 +1184,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
//////
Camera3DGizmoPlugin::Camera3DGizmoPlugin() {
-
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8));
create_material("camera_material", gizmo_color);
@@ -1262,7 +1203,6 @@ int Camera3DGizmoPlugin::get_priority() const {
}
String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
@@ -1273,19 +1213,16 @@ String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, in
}
Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
return camera->get_fov();
} else {
-
return camera->get_size();
}
}
void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
-
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
Transform gt = camera->get_global_transform();
@@ -1301,9 +1238,8 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came
float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2);
camera->set("fov", CLAMP(a * 2.0, 1, 179));
} else {
-
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb);
float d = ra.x * 2.0;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
@@ -1316,13 +1252,10 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came
}
void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) {
-
if (p_cancel) {
-
camera->set("fov", p_restore);
} else {
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
@@ -1333,9 +1266,7 @@ void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, c
}
} else {
-
if (p_cancel) {
-
camera->set("size", p_restore);
} else {
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
@@ -1348,7 +1279,6 @@ void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, c
}
void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1381,9 +1311,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
switch (camera->get_projection()) {
-
case Camera3D::PROJECTION_PERSPECTIVE: {
-
// The real FOV is halved for accurate representation
float fov = camera->get_fov() / 2.0;
@@ -1405,7 +1333,6 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
} break;
case Camera3D::PROJECTION_ORTHOGONAL: {
-
float size = camera->get_size();
float hsize = size * 0.5;
@@ -1517,15 +1444,15 @@ bool MeshInstance3DGizmoPlugin::can_be_hidden() const {
}
void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
Ref<Mesh> m = mesh->get_mesh();
- if (!m.is_valid())
+ if (!m.is_valid()) {
return; //none
+ }
Ref<TriangleMesh> tm = m->generate_triangle_mesh();
if (tm.is_valid()) {
@@ -1554,7 +1481,6 @@ bool Sprite3DGizmoPlugin::can_be_hidden() const {
}
void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1613,7 +1539,6 @@ int Position3DGizmoPlugin::get_priority() const {
}
void Position3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
p_gizmo->clear();
p_gizmo->add_mesh(pos3d_mesh);
p_gizmo->add_collision_segments(cursor_points);
@@ -1622,7 +1547,6 @@ void Position3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
/////
Skeleton3DGizmoPlugin::Skeleton3DGizmoPlugin() {
-
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/skeleton", Color(1, 0.8, 0.4));
create_material("skeleton_material", gizmo_color);
}
@@ -1640,7 +1564,6 @@ int Skeleton3DGizmoPlugin::get_priority() const {
}
void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Skeleton3D *skel = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -1672,7 +1595,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Color rootcolor = Color(0.4, 1.0, 0.4, 0.1);
for (int i_bone = 0; i_bone < skel->get_bone_count(); i_bone++) {
-
int i = skel->get_process_order(i_bone);
int parent = skel->get_bone_parent(i);
@@ -1691,8 +1613,9 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
for (int j = 0; j < 3; j++) {
float dp = Math::abs(grests[parent].basis[j].normalized().dot(d));
- if (j == 0 || dp > closest_d)
+ if (j == 0 || dp > closest_d) {
closest = j;
+ }
}
//find closest other
@@ -1700,7 +1623,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector3 points[4];
int pointidx = 0;
for (int j = 0; j < 3; j++) {
-
bones.write[0] = parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
@@ -1711,8 +1633,9 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
surface_tool->add_color(rootcolor);
surface_tool->add_vertex(v0 + grests[parent].basis[j].normalized() * dist * 0.05);
- if (j == closest)
+ if (j == closest) {
continue;
+ }
Vector3 axis;
if (first == Vector3()) {
@@ -1723,9 +1646,9 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
for (int k = 0; k < 2; k++) {
-
- if (k == 1)
+ if (k == 1) {
axis = -axis;
+ }
Vector3 point = v0 + d * dist * 0.2;
point += axis * dist * 0.1;
@@ -1755,7 +1678,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
SWAP(points[1], points[2]);
for (int j = 0; j < 4; j++) {
-
bones.write[0] = parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
@@ -1780,7 +1702,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
surface_tool->add_vertex(v1);
*/
} else {
-
grests.write[i] = skel->get_bone_rest(i);
bones.write[0] = i;
}
@@ -1847,35 +1768,36 @@ int PhysicalBone3DGizmoPlugin::get_priority() const {
}
void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
p_gizmo->clear();
PhysicalBone3D *physical_bone = Object::cast_to<PhysicalBone3D>(p_gizmo->get_spatial_node());
- if (!physical_bone)
+ if (!physical_bone) {
return;
+ }
Skeleton3D *sk(physical_bone->find_skeleton_parent());
- if (!sk)
+ if (!sk) {
return;
+ }
PhysicalBone3D *pb(sk->get_physical_bone(physical_bone->get_bone_id()));
- if (!pb)
+ if (!pb) {
return;
+ }
PhysicalBone3D *pbp(sk->get_physical_bone_parent(physical_bone->get_bone_id()));
- if (!pbp)
+ if (!pbp) {
return;
+ }
Vector<Vector3> points;
switch (physical_bone->get_joint_type()) {
case PhysicalBone3D::JOINT_TYPE_PIN: {
-
Joint3DGizmoPlugin::CreatePinJointGizmo(physical_bone->get_joint_offset(), points);
} break;
case PhysicalBone3D::JOINT_TYPE_CONE: {
-
const PhysicalBone3D::ConeJointData *cjd(static_cast<const PhysicalBone3D::ConeJointData *>(physical_bone->get_joint_data()));
Joint3DGizmoPlugin::CreateConeTwistJointGizmo(
physical_bone->get_joint_offset(),
@@ -1888,7 +1810,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
&points);
} break;
case PhysicalBone3D::JOINT_TYPE_HINGE: {
-
const PhysicalBone3D::HingeJointData *hjd(static_cast<const PhysicalBone3D::HingeJointData *>(physical_bone->get_joint_data()));
Joint3DGizmoPlugin::CreateHingeJointGizmo(
physical_bone->get_joint_offset(),
@@ -1903,7 +1824,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
&points);
} break;
case PhysicalBone3D::JOINT_TYPE_SLIDER: {
-
const PhysicalBone3D::SliderJointData *sjd(static_cast<const PhysicalBone3D::SliderJointData *>(physical_bone->get_joint_data()));
Joint3DGizmoPlugin::CreateSliderJointGizmo(
physical_bone->get_joint_offset(),
@@ -1919,7 +1839,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
&points);
} break;
case PhysicalBone3D::JOINT_TYPE_6DOF: {
-
const PhysicalBone3D::SixDOFJointData *sdofjd(static_cast<const PhysicalBone3D::SixDOFJointData *>(physical_bone->get_joint_data()));
Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
physical_bone->get_joint_offset(),
@@ -1966,7 +1885,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
/////
RayCast3DGizmoPlugin::RayCast3DGizmoPlugin() {
-
const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
const float gizmo_value = gizmo_color.get_v();
@@ -1987,7 +1905,6 @@ int RayCast3DGizmoPlugin::get_priority() const {
}
void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
RayCast3D *raycast = Object::cast_to<RayCast3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2007,7 +1924,6 @@ void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
/////
void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
SpringArm3D *spring_arm = Object::cast_to<SpringArm3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2043,7 +1959,6 @@ int SpringArm3DGizmoPlugin::get_priority() const {
/////
VehicleWheel3DGizmoPlugin::VehicleWheel3DGizmoPlugin() {
-
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
create_material("shape_material", gizmo_color);
}
@@ -2061,7 +1976,6 @@ int VehicleWheel3DGizmoPlugin::get_priority() const {
}
void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
VehicleWheel3D *car_wheel = Object::cast_to<VehicleWheel3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2071,7 +1985,6 @@ void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
float r = car_wheel->get_radius();
const int skip = 10;
for (int i = 0; i <= 360; i += skip) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + skip);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
@@ -2211,7 +2124,6 @@ int VisibilityNotifier3DGizmoPlugin::get_priority() const {
}
String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
switch (p_idx) {
case 0:
return "Size X";
@@ -2231,12 +2143,11 @@ String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo
}
Variant VisibilityNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
return notifier->get_aabb();
}
-void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
Transform gt = notifier->get_global_transform();
@@ -2258,9 +2169,8 @@ void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int
axis[p_idx] = 1.0;
if (move) {
-
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
@@ -2272,15 +2182,16 @@ void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int
} else {
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx] - ofs[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
//resize
aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d;
aabb.size[p_idx] = d * 2;
@@ -2289,7 +2200,6 @@ void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int
}
void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
@@ -2305,7 +2215,6 @@ void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo,
}
void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2323,7 +2232,6 @@ void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> handles;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = aabb.position[i] + aabb.size[i];
ax[(i + 1) % 3] = aabb.position[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5;
@@ -2333,7 +2241,6 @@ void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector3 center = aabb.position + aabb.size * 0.5;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = 1.0;
handles.push_back(center + ax);
@@ -2409,7 +2316,6 @@ bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const {
}
String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
switch (p_idx) {
case 0:
return "Size X";
@@ -2427,13 +2333,13 @@ String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_giz
return "";
}
-Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
return particles->get_visibility_aabb();
}
-void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
Transform gt = particles->get_global_transform();
@@ -2454,9 +2360,8 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx
axis[p_idx] = 1.0;
if (move) {
-
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
@@ -2468,15 +2373,16 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx
} else {
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx] - ofs[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
//resize
aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d;
aabb.size[p_idx] = d * 2;
@@ -2485,7 +2391,6 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx
}
void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
if (p_cancel) {
@@ -2501,7 +2406,6 @@ void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_
}
void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2519,7 +2423,6 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> handles;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = aabb.position[i] + aabb.size[i];
ax[(i + 1) % 3] = aabb.position[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5;
@@ -2529,7 +2432,6 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector3 center = aabb.position + aabb.size * 0.5;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = 1.0;
handles.push_back(center + ax);
@@ -2550,6 +2452,7 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_handles(handles, get_material("handles"));
p_gizmo->add_unscaled_billboard(icon, 0.05);
}
+
////
ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() {
@@ -2580,7 +2483,6 @@ int ReflectionProbeGizmoPlugin::get_priority() const {
}
String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
switch (p_idx) {
case 0:
return "Extents X";
@@ -2598,13 +2500,13 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi
return "";
}
-Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
return AABB(probe->get_extents(), probe->get_origin_offset());
}
-void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform();
@@ -2622,19 +2524,19 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id
axis[p_idx] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
extents[p_idx] = d;
probe->set_extents(extents);
} else {
-
p_idx -= 3;
Vector3 origin = probe->get_origin_offset();
@@ -2649,7 +2551,7 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id
axis[p_idx] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb);
// Adjust the actual position to account for the gizmo handle position
float d = ra[p_idx] + 0.25;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
@@ -2662,7 +2564,6 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id
}
void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
AABB restore = p_restore;
@@ -2683,7 +2584,6 @@ void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p
}
void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2712,14 +2612,12 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> handles;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = aabb.position[i] + aabb.size[i];
handles.push_back(ax);
}
for (int i = 0; i < 3; i++) {
-
Vector3 orig_handle = probe->get_origin_offset();
orig_handle[i] -= 0.25;
lines.push_back(orig_handle);
@@ -2744,6 +2642,7 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_unscaled_billboard(icon, 0.05);
p_gizmo->add_handles(handles, get_material("handles"));
}
+
///////////////////////////////
////
@@ -2769,7 +2668,6 @@ int DecalGizmoPlugin::get_priority() const {
}
String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
switch (p_idx) {
case 0:
return "Extents X";
@@ -2781,13 +2679,13 @@ String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p
return "";
}
-Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
return decal->get_extents();
}
-void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
Transform gt = decal->get_global_transform();
@@ -2804,21 +2702,21 @@ void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3
axis[p_idx] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
extents[p_idx] = d;
decal->set_extents(extents);
}
void DecalGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
Vector3 restore = p_restore;
@@ -2836,7 +2734,6 @@ void DecalGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, cons
}
void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -2870,7 +2767,6 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> handles;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = aabb.position[i] + aabb.size[i];
handles.push_back(ax);
@@ -2913,7 +2809,6 @@ int GIProbeGizmoPlugin::get_priority() const {
}
String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
switch (p_idx) {
case 0:
return "Extents X";
@@ -2925,13 +2820,13 @@ String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int
return "";
}
-Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
return probe->get_extents();
}
-void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
Transform gt = probe->get_global_transform();
@@ -2948,21 +2843,21 @@ void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer
axis[p_idx] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
extents[p_idx] = d;
probe->set_extents(extents);
}
void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
-
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
Vector3 restore = p_restore;
@@ -2980,7 +2875,6 @@ void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, co
}
void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node());
Ref<Material> material = get_material("gi_probe_material", p_gizmo);
@@ -3010,9 +2904,7 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
lines.clear();
for (int i = 1; i < subdiv; i++) {
-
for (int j = 0; j < 3; j++) {
-
if (cell_size * i > aabb.size[j]) {
continue;
}
@@ -3026,7 +2918,6 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
tb[j_n2] = 1.0;
for (int k = 0; k < 4; k++) {
-
Vector3 from = aabb.position, to = aabb.position;
from[j] += cell_size * i;
to[j] += cell_size * i;
@@ -3034,7 +2925,6 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
if (k & 1) {
to[j_n1] += aabb.size[j_n1];
} else {
-
to[j_n2] += aabb.size[j_n2];
}
@@ -3054,7 +2944,6 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> handles;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = aabb.position[i] + aabb.size[i];
handles.push_back(ax);
@@ -3089,13 +2978,13 @@ BakedLightmapGizmoPlugin::BakedLightmapGizmoPlugin() {
}
String BakedLightmapGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
return "";
}
-Variant BakedLightmapGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant BakedLightmapGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
return Variant();
}
+
void BakedLightmapGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
}
@@ -3115,7 +3004,6 @@ int BakedLightmapGizmoPlugin::get_priority() const {
}
void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Ref<Material> icon = get_material("baked_indirect_light_icon", p_gizmo);
BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node());
Ref<BakedLightmapData> data = baker->get_light_data();
@@ -3146,10 +3034,8 @@ void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<int> tetrahedrons = data->get_capture_tetrahedra();
for (int i = 0; i < tetrahedrons.size(); i += 4) {
-
for (int j = 0; j < 4; j++) {
for (int k = j + 1; k < 4; k++) {
-
Vector2i pair;
pair.x = tetrahedrons[i + j];
pair.y = tetrahedrons[i + k];
@@ -3181,7 +3067,6 @@ void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
float radius = 0.3;
for (int p = 0; p < points.size(); p++) {
-
int vertex_base = vertices.size();
Vector3 sh_col[9];
for (int i = 0; i < 9; i++) {
@@ -3264,6 +3149,7 @@ void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_mesh(mesh);
}
+
/////////
LightmapProbeGizmoPlugin::LightmapProbeGizmoPlugin() {
@@ -3274,13 +3160,13 @@ LightmapProbeGizmoPlugin::LightmapProbeGizmoPlugin() {
}
String LightmapProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
return "";
}
-Variant LightmapProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant LightmapProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
return Variant();
}
+
void LightmapProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
}
@@ -3300,7 +3186,6 @@ int LightmapProbeGizmoPlugin::get_priority() const {
}
void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
Ref<Material> material_lines = get_material("lightprobe_lines", p_gizmo);
p_gizmo->clear();
@@ -3360,6 +3245,7 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_lines(lines, material_lines);
}
+
////
CollisionShape3DGizmoPlugin::CollisionShape3DGizmoPlugin() {
@@ -3384,35 +3270,30 @@ int CollisionShape3DGizmoPlugin::get_priority() const {
}
String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
Ref<Shape3D> s = cs->get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return "";
+ }
if (Object::cast_to<SphereShape3D>(*s)) {
-
return "Radius";
}
if (Object::cast_to<BoxShape3D>(*s)) {
-
return "Extents";
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
-
return p_idx == 0 ? "Radius" : "Height";
}
if (Object::cast_to<CylinderShape3D>(*s)) {
-
return p_idx == 0 ? "Radius" : "Height";
}
if (Object::cast_to<RayShape3D>(*s)) {
-
return "Length";
}
@@ -3420,52 +3301,48 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
}
Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
Ref<Shape3D> s = cs->get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return Variant();
+ }
if (Object::cast_to<SphereShape3D>(*s)) {
-
Ref<SphereShape3D> ss = s;
return ss->get_radius();
}
if (Object::cast_to<BoxShape3D>(*s)) {
-
Ref<BoxShape3D> bs = s;
return bs->get_extents();
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
-
Ref<CapsuleShape3D> cs2 = s;
return p_idx == 0 ? cs2->get_radius() : cs2->get_height();
}
if (Object::cast_to<CylinderShape3D>(*s)) {
-
Ref<CylinderShape3D> cs2 = s;
return p_idx == 0 ? cs2->get_radius() : cs2->get_height();
}
if (Object::cast_to<RayShape3D>(*s)) {
-
Ref<RayShape3D> cs2 = s;
return cs2->get_length();
}
return Variant();
}
-void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
Ref<Shape3D> s = cs->get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return;
+ }
Transform gt = cs->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -3476,51 +3353,51 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (Object::cast_to<SphereShape3D>(*s)) {
-
Ref<SphereShape3D> ss = s;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
ss->set_radius(d);
}
if (Object::cast_to<RayShape3D>(*s)) {
-
Ref<RayShape3D> rs = s;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, 4096), sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(0, 0, 4096), sg[0], sg[1], ra, rb);
float d = ra.z;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
rs->set_length(d);
}
if (Object::cast_to<BoxShape3D>(*s)) {
-
Vector3 axis;
axis[p_idx] = 1.0;
Ref<BoxShape3D> bs = s;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
Vector3 he = bs->get_extents();
he[p_idx] = d;
@@ -3528,60 +3405,63 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
-
Vector3 axis;
axis[p_idx == 0 ? 0 : 2] = 1.0;
Ref<CapsuleShape3D> cs2 = s;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (p_idx == 1)
+ if (p_idx == 1) {
d -= cs2->get_radius();
+ }
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
- if (p_idx == 0)
+ if (p_idx == 0) {
cs2->set_radius(d);
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
cs2->set_height(d * 2.0);
+ }
}
if (Object::cast_to<CylinderShape3D>(*s)) {
-
Vector3 axis;
axis[p_idx == 0 ? 0 : 1] = 1.0;
Ref<CylinderShape3D> cs2 = s;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
- if (p_idx == 0)
+ if (p_idx == 0) {
cs2->set_radius(d);
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
cs2->set_height(d * 2.0);
+ }
}
}
-void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
Ref<Shape3D> s = cs->get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return;
+ }
if (Object::cast_to<SphereShape3D>(*s)) {
-
Ref<SphereShape3D> ss = s;
if (p_cancel) {
ss->set_radius(p_restore);
@@ -3596,7 +3476,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int
}
if (Object::cast_to<BoxShape3D>(*s)) {
-
Ref<BoxShape3D> ss = s;
if (p_cancel) {
ss->set_extents(p_restore);
@@ -3611,13 +3490,13 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
-
Ref<CapsuleShape3D> ss = s;
if (p_cancel) {
- if (p_idx == 0)
+ if (p_idx == 0) {
ss->set_radius(p_restore);
- else
+ } else {
ss->set_height(p_restore);
+ }
return;
}
@@ -3636,13 +3515,13 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int
}
if (Object::cast_to<CylinderShape3D>(*s)) {
-
Ref<CylinderShape3D> ss = s;
if (p_cancel) {
- if (p_idx == 0)
+ if (p_idx == 0) {
ss->set_radius(p_restore);
- else
+ } else {
ss->set_height(p_restore);
+ }
return;
}
@@ -3665,7 +3544,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int
}
if (Object::cast_to<RayShape3D>(*s)) {
-
Ref<RayShape3D> ss = s;
if (p_cancel) {
ss->set_length(p_restore);
@@ -3679,29 +3557,28 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int
ur->commit_action();
}
}
-void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
+void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
Ref<Shape3D> s = cs->get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return;
+ }
const Ref<Material> material =
get_material(!cs->is_disabled() ? "shape_material" : "shape_material_disabled", p_gizmo);
Ref<Material> handles_material = get_material("handles");
if (Object::cast_to<SphereShape3D>(*s)) {
-
Ref<SphereShape3D> sp = s;
float r = sp->get_radius();
Vector<Vector3> points;
for (int i = 0; i <= 360; i++) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
@@ -3718,7 +3595,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> collision_segments;
for (int i = 0; i < 64; i++) {
-
float ra = i * Math_PI * 2.0 / 64.0;
float rb = (i + 1) * Math_PI * 2.0 / 64.0;
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
@@ -3740,7 +3616,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<BoxShape3D>(*s)) {
-
Ref<BoxShape3D> bs = s;
Vector<Vector3> lines;
AABB aabb;
@@ -3757,7 +3632,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> handles;
for (int i = 0; i < 3; i++) {
-
Vector3 ax;
ax[i] = bs->get_extents()[i];
handles.push_back(ax);
@@ -3769,7 +3643,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
-
Ref<CapsuleShape3D> cs2 = s;
float radius = cs2->get_radius();
float height = cs2->get_height();
@@ -3778,7 +3651,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector3 d(0, height * 0.5, 0);
for (int i = 0; i < 360; i++) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
@@ -3791,7 +3663,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
points.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 90 == 0) {
-
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(a.x, 0, a.y) - d);
}
@@ -3809,7 +3680,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> collision_segments;
for (int i = 0; i < 64; i++) {
-
float ra = i * Math_PI * 2.0 / 64.0;
float rb = (i + 1) * Math_PI * 2.0 / 64.0;
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
@@ -3822,7 +3692,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
collision_segments.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 16 == 0) {
-
collision_segments.push_back(Vector3(a.x, 0, a.y) + d);
collision_segments.push_back(Vector3(a.x, 0, a.y) - d);
}
@@ -3844,7 +3713,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<CylinderShape3D>(*s)) {
-
Ref<CylinderShape3D> cs2 = s;
float radius = cs2->get_radius();
float height = cs2->get_height();
@@ -3853,7 +3721,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector3 d(0, height * 0.5, 0);
for (int i = 0; i < 360; i++) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
@@ -3866,7 +3733,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
points.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 90 == 0) {
-
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(a.x, 0, a.y) - d);
}
@@ -3877,7 +3743,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> collision_segments;
for (int i = 0; i < 64; i++) {
-
float ra = i * Math_PI * 2.0 / 64.0;
float rb = (i + 1) * Math_PI * 2.0 / 64.0;
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
@@ -3890,7 +3755,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
collision_segments.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 16 == 0) {
-
collision_segments.push_back(Vector3(a.x, 0, a.y) + d);
collision_segments.push_back(Vector3(a.x, 0, a.y) - d);
}
@@ -3905,7 +3769,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<WorldMarginShape3D>(*s)) {
-
Ref<WorldMarginShape3D> ps = s;
Plane p = ps->get_plane();
Vector<Vector3> points;
@@ -3936,13 +3799,11 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<ConvexPolygonShape3D>(*s)) {
-
Vector<Vector3> points = Object::cast_to<ConvexPolygonShape3D>(*s)->get_points();
if (points.size() > 3) {
-
Vector<Vector3> varr = Variant(points);
- Geometry::MeshData md;
+ Geometry3D::MeshData md;
Error err = QuickHull::build(varr, md);
if (err == OK) {
Vector<Vector3> points2;
@@ -3959,7 +3820,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<ConcavePolygonShape3D>(*s)) {
-
Ref<ConcavePolygonShape3D> cs2 = s;
Ref<ArrayMesh> mesh = cs2->get_debug_mesh();
p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material);
@@ -3967,7 +3827,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<RayShape3D>(*s)) {
-
Ref<RayShape3D> rs = s;
Vector<Vector3> points;
@@ -3981,7 +3840,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (Object::cast_to<HeightMapShape3D>(*s)) {
-
Ref<HeightMapShape3D> hms = s;
Ref<ArrayMesh> mesh = hms->get_debug_mesh();
@@ -4012,7 +3870,6 @@ int CollisionPolygon3DGizmoPlugin::get_priority() const {
}
void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
CollisionPolygon3D *polygon = Object::cast_to<CollisionPolygon3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
@@ -4022,7 +3879,6 @@ void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> lines;
for (int i = 0; i < points.size(); i++) {
-
int n = (i + 1) % points.size();
lines.push_back(Vector3(points[i].x, points[i].y, depth));
lines.push_back(Vector3(points[n].x, points[n].y, depth));
@@ -4061,7 +3917,6 @@ int NavigationRegion3DGizmoPlugin::get_priority() const {
}
void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
NavigationRegion3D *navmesh = Object::cast_to<NavigationRegion3D>(p_gizmo->get_spatial_node());
Ref<Material> edge_material = get_material("navigation_edge_material", p_gizmo);
@@ -4071,8 +3926,9 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
Ref<NavigationMesh> navmeshie = navmesh->get_navigation_mesh();
- if (navmeshie.is_null())
+ if (navmeshie.is_null()) {
return;
+ }
Vector<Vector3> vertices = navmeshie->get_vertices();
const Vector3 *vr = vertices.ptr();
@@ -4090,8 +3946,9 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
}
- if (faces.empty())
+ if (faces.empty()) {
return;
+ }
Map<_EdgeKey, bool> edge_map;
Vector<Vector3> tmeshfaces;
@@ -4102,26 +3959,23 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
int tidx = 0;
for (List<Face3>::Element *E = faces.front(); E; E = E->next()) {
-
const Face3 &f = E->get();
for (int j = 0; j < 3; j++) {
-
tw[tidx++] = f.vertex[j];
_EdgeKey ek;
ek.from = f.vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
ek.to = f.vertex[(j + 1) % 3].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
- if (ek.from < ek.to)
+ if (ek.from < ek.to) {
SWAP(ek.from, ek.to);
+ }
Map<_EdgeKey, bool>::Element *F = edge_map.find(ek);
if (F) {
-
F->get() = false;
} else {
-
edge_map[ek] = true;
}
}
@@ -4130,7 +3984,6 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector<Vector3> lines;
for (Map<_EdgeKey, bool>::Element *E = edge_map.front(); E; E = E->next()) {
-
if (E->get()) {
lines.push_back(E->key().from);
lines.push_back(E->key().to);
@@ -4140,8 +3993,9 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Ref<TriangleMesh> tmesh = memnew(TriangleMesh);
tmesh->create(tmeshfaces);
- if (lines.size())
+ if (lines.size()) {
p_gizmo->add_lines(lines, navmesh->is_enabled() ? edge_material : edge_material_disabled);
+ }
p_gizmo->add_collision_triangles(tmesh);
Ref<ArrayMesh> m = memnew(ArrayMesh);
Array a;
@@ -4184,7 +4038,6 @@ Basis JointGizmosDrawer::look_body(const Transform &p_joint_transform, const Tra
}
Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform) {
-
switch (p_axis) {
case Vector3::AXIS_X:
return look_body_toward_x(joint_transform, body_transform);
@@ -4198,7 +4051,6 @@ Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform
}
Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform) {
-
const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin);
@@ -4230,7 +4082,6 @@ Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform,
}
Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform) {
-
const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin);
@@ -4262,7 +4113,6 @@ Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform,
}
Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform) {
-
const Vector3 &p_eye(p_joint_transform.origin);
const Vector3 &p_target(p_body_transform.origin);
@@ -4294,14 +4144,11 @@ Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform,
}
void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse) {
-
if (p_limit_lower == p_limit_upper) {
-
r_points.push_back(p_offset.translated(Vector3()).origin);
r_points.push_back(p_offset.translated(p_base.xform(Vector3(0.5, 0, 0))).origin);
} else {
-
if (p_limit_lower > p_limit_upper) {
p_limit_lower = -Math_PI;
p_limit_upper = Math_PI;
@@ -4310,7 +4157,6 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const
const int points = 32;
for (int i = 0; i < points; i++) {
-
real_t s = p_limit_lower + i * (p_limit_upper - p_limit_lower) / points;
real_t n = p_limit_lower + (i + 1) * (p_limit_upper - p_limit_lower) / points;
@@ -4360,14 +4206,12 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const
}
void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points) {
-
float r = 1.0;
float w = r * Math::sin(p_swing);
float d = r * Math::cos(p_swing);
//swing
for (int i = 0; i < 360; i += 10) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 10);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w;
@@ -4377,7 +4221,6 @@ void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base
r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, b.x, b.y))).origin);
if (i % 90 == 0) {
-
r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, a.x, a.y))).origin);
r_points.push_back(p_offset.translated(p_base.xform(Vector3())).origin);
}
@@ -4391,7 +4234,6 @@ void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base
ts = MIN(ts, 720);
for (int i = 0; i < int(ts); i += 5) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 5);
float c = i / 720.0;
@@ -4474,7 +4316,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint);
if (hinge) {
-
CreateHingeJointGizmo(
Transform(),
hinge->get_global_transform(),
@@ -4498,7 +4339,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint);
if (slider) {
-
CreateSliderJointGizmo(
Transform(),
slider->get_global_transform(),
@@ -4523,7 +4363,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint);
if (cone) {
-
CreateConeTwistJointGizmo(
Transform(),
cone->get_global_transform(),
@@ -4543,7 +4382,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint);
if (gen) {
-
CreateGeneric6DOFJointGizmo(
Transform(),
gen->get_global_transform(),
@@ -4597,7 +4435,6 @@ void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<V
}
void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
-
r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin);
r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin);
@@ -4607,7 +4444,6 @@ void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const
}
if (r_body_a_points) {
-
JointGizmosDrawer::draw_circle(Vector3::AXIS_Z,
BODY_A_RADIUS,
p_offset,
@@ -4629,7 +4465,6 @@ void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const
}
void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
-
p_linear_limit_lower = -p_linear_limit_lower;
p_linear_limit_upper = -p_linear_limit_upper;
@@ -4638,7 +4473,6 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const
r_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin);
if (p_linear_limit_lower >= p_linear_limit_upper) {
-
r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, 0, 0)).origin);
r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, 0, 0)).origin);
@@ -4661,12 +4495,11 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const
r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, -cs, -cs)).origin);
} else {
-
r_points.push_back(p_offset.translated(Vector3(+cs * 2, 0, 0)).origin);
r_points.push_back(p_offset.translated(Vector3(-cs * 2, 0, 0)).origin);
}
- if (r_body_a_points)
+ if (r_body_a_points) {
JointGizmosDrawer::draw_circle(
Vector3::AXIS_X,
BODY_A_RADIUS,
@@ -4675,8 +4508,9 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const
p_angular_limit_lower,
p_angular_limit_upper,
*r_body_a_points);
+ }
- if (r_body_b_points)
+ if (r_body_b_points) {
JointGizmosDrawer::draw_circle(
Vector3::AXIS_X,
BODY_B_RADIUS,
@@ -4686,25 +4520,27 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const
p_angular_limit_upper,
*r_body_b_points,
true);
+ }
}
void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) {
-
- if (r_body_a_points)
+ if (r_body_a_points) {
JointGizmosDrawer::draw_cone(
p_offset,
JointGizmosDrawer::look_body(p_trs_joint, p_trs_body_a),
p_swing,
p_twist,
*r_body_a_points);
+ }
- if (r_body_b_points)
+ if (r_body_b_points) {
JointGizmosDrawer::draw_cone(
p_offset,
JointGizmosDrawer::look_body(p_trs_joint, p_trs_body_b),
p_swing,
p_twist,
*r_body_b_points);
+ }
}
void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
@@ -4733,7 +4569,6 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
Vector<Vector3> &r_points,
Vector<Vector3> *r_body_a_points,
Vector<Vector3> *r_body_b_points) {
-
float cs = 0.25;
for (int ax = 0; ax < 3; ax++) {
@@ -4794,7 +4629,6 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
}
if (enable_lin && lll >= lul) {
-
ADD_VTX(lul, 0, 0);
ADD_VTX(lll, 0, 0);
@@ -4817,7 +4651,6 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
ADD_VTX(lll, -cs, -cs);
} else {
-
ADD_VTX(+cs * 2, 0, 0);
ADD_VTX(-cs * 2, 0, 0);
}
@@ -4827,7 +4660,7 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
ul = -1;
}
- if (r_body_a_points)
+ if (r_body_a_points) {
JointGizmosDrawer::draw_circle(
static_cast<Vector3::Axis>(ax),
BODY_A_RADIUS,
@@ -4837,8 +4670,9 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
ul,
*r_body_a_points,
true);
+ }
- if (r_body_b_points)
+ if (r_body_b_points) {
JointGizmosDrawer::draw_circle(
static_cast<Vector3::Axis>(ax),
BODY_B_RADIUS,
@@ -4847,6 +4681,7 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo(
ll,
ul,
*r_body_b_points);
+ }
}
#undef ADD_VTX
diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h
index c25fff528c..8154dc7a6d 100644
--- a/editor/node_3d_editor_gizmos.h
+++ b/editor/node_3d_editor_gizmos.h
@@ -37,7 +37,6 @@
class Camera3D;
class Light3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Light3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -55,7 +54,6 @@ public:
};
class AudioStreamPlayer3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(AudioStreamPlayer3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -73,7 +71,6 @@ public:
};
class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Camera3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -91,7 +88,6 @@ public:
};
class MeshInstance3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(MeshInstance3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -105,7 +101,6 @@ public:
};
class Sprite3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Sprite3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -119,7 +114,6 @@ public:
};
class Position3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Position3DGizmoPlugin, EditorNode3DGizmoPlugin);
Ref<ArrayMesh> pos3d_mesh;
@@ -135,7 +129,6 @@ public:
};
class Skeleton3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Skeleton3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -148,7 +141,6 @@ public:
};
class PhysicalBone3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(PhysicalBone3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -161,7 +153,6 @@ public:
};
class RayCast3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(RayCast3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -174,7 +165,6 @@ public:
};
class SpringArm3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(SpringArm3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -187,7 +177,6 @@ public:
};
class VehicleWheel3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(VehicleWheel3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -200,7 +189,6 @@ public:
};
class SoftBody3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(SoftBody3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -219,7 +207,6 @@ public:
};
class VisibilityNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(VisibilityNotifier3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -249,7 +236,6 @@ public:
};
class GPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(GPUParticles3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -268,7 +254,6 @@ public:
};
class ReflectionProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(ReflectionProbeGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -286,7 +271,6 @@ public:
};
class DecalGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(DecalGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -304,7 +288,6 @@ public:
};
class GIProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(GIProbeGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -322,7 +305,6 @@ public:
};
class BakedLightmapGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(BakedLightmapGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -340,7 +322,6 @@ public:
};
class LightmapProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(LightmapProbeGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -358,7 +339,6 @@ public:
};
class CollisionShape3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(CollisionShape3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
@@ -387,11 +367,9 @@ public:
};
class NavigationRegion3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(NavigationRegion3DGizmoPlugin, EditorNode3DGizmoPlugin);
struct _EdgeKey {
-
Vector3 from;
Vector3 to;
@@ -423,7 +401,6 @@ public:
};
class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin);
Timer *update_timer;
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index a076b1eecc..9b9cfad9eb 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -34,7 +34,6 @@
#include "editor_scale.h"
void NodeDock::show_groups() {
-
groups_button->set_pressed(true);
connections_button->set_pressed(false);
groups->show();
@@ -42,7 +41,6 @@ void NodeDock::show_groups() {
}
void NodeDock::show_connections() {
-
groups_button->set_pressed(false);
connections_button->set_pressed(true);
groups->hide();
@@ -53,7 +51,6 @@ void NodeDock::_bind_methods() {
}
void NodeDock::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
connections_button->set_icon(get_theme_icon("Signals", "EditorIcons"));
groups_button->set_icon(get_theme_icon("Groups", "EditorIcons"));
@@ -63,20 +60,19 @@ void NodeDock::_notification(int p_what) {
NodeDock *NodeDock::singleton = nullptr;
void NodeDock::update_lists() {
-
connections->update_tree();
}
void NodeDock::set_node(Node *p_node) {
-
connections->set_node(p_node);
groups->set_current(p_node);
if (p_node) {
- if (connections_button->is_pressed())
+ if (connections_button->is_pressed()) {
connections->show();
- else
+ } else {
groups->show();
+ }
mode_hb->show();
select_a_node->hide();
@@ -89,7 +85,6 @@ void NodeDock::set_node(Node *p_node) {
}
NodeDock::NodeDock() {
-
singleton = this;
set_name("Node");
diff --git a/editor/node_dock.h b/editor/node_dock.h
index ae33c5b9a5..c165974678 100644
--- a/editor/node_dock.h
+++ b/editor/node_dock.h
@@ -35,7 +35,6 @@
#include "groups_editor.h"
class NodeDock : public VBoxContainer {
-
GDCLASS(NodeDock, VBoxContainer);
ToolButton *connections_button;
diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp
index ce90fa94dc..09f2b90b90 100644
--- a/editor/pane_drag.cpp
+++ b/editor/pane_drag.cpp
@@ -31,23 +31,19 @@
#include "pane_drag.h"
void PaneDrag::_gui_input(const Ref<InputEvent> &p_input) {
-
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
emit_signal("dragged", Point2(mm->get_relative().x, mm->get_relative().y));
}
}
void PaneDrag::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
Ref<Texture2D> icon = mouse_over ? get_theme_icon("PaneDragHover", "EditorIcons") : get_theme_icon("PaneDrag", "EditorIcons");
- if (!icon.is_null())
+ if (!icon.is_null()) {
icon->draw(get_canvas_item(), Point2(0, 0));
+ }
} break;
case NOTIFICATION_MOUSE_ENTER:
@@ -60,21 +56,20 @@ void PaneDrag::_notification(int p_what) {
break;
}
}
-Size2 PaneDrag::get_minimum_size() const {
+Size2 PaneDrag::get_minimum_size() const {
Ref<Texture2D> icon = get_theme_icon("PaneDrag", "EditorIcons");
- if (!icon.is_null())
+ if (!icon.is_null()) {
return icon->get_size();
+ }
return Size2();
}
void PaneDrag::_bind_methods() {
-
ClassDB::bind_method("_gui_input", &PaneDrag::_gui_input);
ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "amount")));
}
PaneDrag::PaneDrag() {
-
mouse_over = false;
}
diff --git a/editor/pane_drag.h b/editor/pane_drag.h
index 7e66bb429f..81aff4b2a8 100644
--- a/editor/pane_drag.h
+++ b/editor/pane_drag.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class PaneDrag : public Control {
-
GDCLASS(PaneDrag, Control);
bool mouse_over;
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp
index 4317a5e80f..3ad6938498 100644
--- a/editor/plugin_config_dialog.cpp
+++ b/editor/plugin_config_dialog.cpp
@@ -52,13 +52,13 @@ void PluginConfigDialog::_clear_fields() {
}
void PluginConfigDialog::_on_confirmed() {
-
String path = "res://addons/" + subfolder_edit->get_text();
if (!_edit_mode) {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (!d || d->make_dir_recursive(path) != OK)
+ if (!d || d->make_dir_recursive(path) != OK) {
return;
+ }
}
Ref<ConfigFile> cf = memnew(ConfigFile);
diff --git a/editor/plugin_config_dialog.h b/editor/plugin_config_dialog.h
index fa148125bc..93c8c01c70 100644
--- a/editor/plugin_config_dialog.h
+++ b/editor/plugin_config_dialog.h
@@ -38,7 +38,6 @@
#include "scene/gui/text_edit.h"
class PluginConfigDialog : public ConfirmationDialog {
-
GDCLASS(PluginConfigDialog, ConfirmationDialog);
LineEdit *name_edit;
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index c26daa3857..b905c8db12 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -31,135 +31,89 @@
#include "abstract_polygon_2d_editor.h"
#include "canvas_item_editor_plugin.h"
+#include "core/math/geometry_2d.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
-AbstractPolygon2DEditor::Vertex::Vertex() :
- polygon(-1),
- vertex(-1) {
- // invalid vertex
-}
-
-AbstractPolygon2DEditor::Vertex::Vertex(int p_vertex) :
- polygon(-1),
- vertex(p_vertex) {
- // vertex p_vertex of current wip polygon
-}
-
-AbstractPolygon2DEditor::Vertex::Vertex(int p_polygon, int p_vertex) :
- polygon(p_polygon),
- vertex(p_vertex) {
- // vertex p_vertex of polygon p_polygon
-}
-
bool AbstractPolygon2DEditor::Vertex::operator==(const AbstractPolygon2DEditor::Vertex &p_vertex) const {
-
return polygon == p_vertex.polygon && vertex == p_vertex.vertex;
}
bool AbstractPolygon2DEditor::Vertex::operator!=(const AbstractPolygon2DEditor::Vertex &p_vertex) const {
-
return !(*this == p_vertex);
}
bool AbstractPolygon2DEditor::Vertex::valid() const {
-
return vertex >= 0;
}
-AbstractPolygon2DEditor::PosVertex::PosVertex() {
- // invalid vertex
-}
-
-AbstractPolygon2DEditor::PosVertex::PosVertex(const Vertex &p_vertex, const Vector2 &p_pos) :
- Vertex(p_vertex.polygon, p_vertex.vertex),
- pos(p_pos) {
-}
-
-AbstractPolygon2DEditor::PosVertex::PosVertex(int p_polygon, int p_vertex, const Vector2 &p_pos) :
- Vertex(p_polygon, p_vertex),
- pos(p_pos) {
-}
-
bool AbstractPolygon2DEditor::_is_empty() const {
-
- if (!_get_node())
+ if (!_get_node()) {
return true;
+ }
const int n = _get_polygon_count();
for (int i = 0; i < n; i++) {
-
Vector<Vector2> vertices = _get_polygon(i);
- if (vertices.size() != 0)
+ if (vertices.size() != 0) {
return false;
+ }
}
return true;
}
bool AbstractPolygon2DEditor::_is_line() const {
-
return false;
}
bool AbstractPolygon2DEditor::_has_uv() const {
-
return false;
}
int AbstractPolygon2DEditor::_get_polygon_count() const {
-
return 1;
}
Variant AbstractPolygon2DEditor::_get_polygon(int p_idx) const {
-
return _get_node()->get("polygon");
}
void AbstractPolygon2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
-
_get_node()->set("polygon", p_polygon);
}
void AbstractPolygon2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
-
Node2D *node = _get_node();
undo_redo->add_do_method(node, "set_polygon", p_polygon);
undo_redo->add_undo_method(node, "set_polygon", p_previous);
}
Vector2 AbstractPolygon2DEditor::_get_offset(int p_idx) const {
-
return Vector2(0, 0);
}
void AbstractPolygon2DEditor::_commit_action() {
-
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
}
void AbstractPolygon2DEditor::_action_add_polygon(const Variant &p_polygon) {
-
_action_set_polygon(0, p_polygon);
}
void AbstractPolygon2DEditor::_action_remove_polygon(int p_idx) {
-
_action_set_polygon(p_idx, _get_polygon(p_idx), Vector<Vector2>());
}
void AbstractPolygon2DEditor::_action_set_polygon(int p_idx, const Variant &p_polygon) {
-
_action_set_polygon(p_idx, _get_polygon(p_idx), p_polygon);
}
bool AbstractPolygon2DEditor::_has_resource() const {
-
return true;
}
@@ -167,18 +121,14 @@ void AbstractPolygon2DEditor::_create_resource() {
}
void AbstractPolygon2DEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MODE_CREATE: {
-
mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
button_delete->set_pressed(false);
} break;
case MODE_EDIT: {
-
_wip_close();
mode = MODE_EDIT;
button_create->set_pressed(false);
@@ -186,7 +136,6 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) {
button_delete->set_pressed(false);
} break;
case MODE_DELETE: {
-
_wip_close();
mode = MODE_DELETE;
button_create->set_pressed(false);
@@ -197,11 +146,8 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) {
}
void AbstractPolygon2DEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
-
disable_polygon_editing(false, String());
button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons"));
@@ -216,7 +162,6 @@ void AbstractPolygon2DEditor::_notification(int p_what) {
}
void AbstractPolygon2DEditor::_node_removed(Node *p_node) {
-
if (p_node == _get_node()) {
edit(nullptr);
hide();
@@ -226,14 +171,12 @@ void AbstractPolygon2DEditor::_node_removed(Node *p_node) {
}
void AbstractPolygon2DEditor::_wip_changed() {
-
if (wip_active && _is_line()) {
_set_polygon(0, wip);
}
}
void AbstractPolygon2DEditor::_wip_cancel() {
-
wip.clear();
wip_active = false;
@@ -245,14 +188,13 @@ void AbstractPolygon2DEditor::_wip_cancel() {
}
void AbstractPolygon2DEditor::_wip_close() {
- if (!wip_active)
+ if (!wip_active) {
return;
+ }
if (_is_line()) {
-
_set_polygon(0, wip);
} else if (wip.size() >= (_is_line() ? 2 : 3)) {
-
undo_redo->create_action(TTR("Create Polygon"));
_action_add_polygon(wip);
if (_has_uv()) {
@@ -261,7 +203,6 @@ void AbstractPolygon2DEditor::_wip_close() {
}
_commit_action();
} else {
-
return;
}
@@ -279,7 +220,6 @@ void AbstractPolygon2DEditor::_wip_close() {
}
void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_reason) {
-
_polygon_editing_enabled = !p_disable;
button_create->set_disabled(p_disable);
@@ -287,12 +227,10 @@ void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_r
button_delete->set_disabled(p_disable);
if (p_disable) {
-
button_create->set_tooltip(p_reason);
button_edit->set_tooltip(p_reason);
button_delete->set_tooltip(p_reason);
} else {
-
button_create->set_tooltip(TTR("Create points."));
button_edit->set_tooltip(TTR("Edit points.\nLMB: Move Point\nRMB: Erase Point"));
button_delete->set_tooltip(TTR("Erase points."));
@@ -300,14 +238,13 @@ void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_r
}
bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
-
- if (!_get_node() || !_polygon_editing_enabled)
+ if (!_get_node() || !_polygon_editing_enabled) {
return false;
+ }
Ref<InputEventMouseButton> mb = p_event;
if (!_has_resource()) {
-
if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
create_resource->set_text(String("No polygon resource on this node.\nCreate and assign one?"));
create_resource->popup_centered();
@@ -316,11 +253,11 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
CanvasItemEditor::Tool tool = CanvasItemEditor::get_singleton()->get_current_tool();
- if (tool != CanvasItemEditor::TOOL_SELECT)
+ if (tool != CanvasItemEditor::TOOL_SELECT) {
return false;
+ }
if (mb.is_valid()) {
-
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
Vector2 gpoint = mb->get_position();
@@ -329,17 +266,16 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
- if (mb->get_control() || mb->get_shift() || mb->get_alt())
+ if (mb->get_control() || mb->get_shift() || mb->get_alt()) {
return false;
+ }
const PosVertex insert = closest_edge_point(gpoint);
if (insert.valid()) {
-
Vector<Vector2> vertices = _get_polygon(insert.polygon);
if (vertices.size() < (_is_line() ? 2 : 3)) {
-
vertices.push_back(cpoint);
undo_redo->create_action(TTR("Edit Polygon"));
selected_point = Vertex(insert.polygon, vertices.size());
@@ -347,7 +283,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
_commit_action();
return true;
} else {
-
Vector<Vector2> vertices2 = _get_polygon(insert.polygon);
pre_move_edit = vertices2;
edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos));
@@ -361,12 +296,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
}
} else {
-
//look for points to move
const PosVertex closest = closest_point(gpoint);
if (closest.valid()) {
-
pre_move_edit = _get_polygon(closest.polygon);
edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos));
selected_point = closest;
@@ -374,14 +307,11 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
canvas_item_editor->update_viewport();
return true;
} else {
-
selected_point = Vertex();
}
}
} else {
-
if (edited_point.valid()) {
-
//apply
Vector<Vector2> vertices = _get_polygon(edited_point.polygon);
@@ -397,23 +327,18 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
}
} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && !edited_point.valid()) {
-
const PosVertex closest = closest_point(gpoint);
if (closest.valid()) {
-
remove_point(closest);
return true;
}
}
} else if (mode == MODE_DELETE) {
-
if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
-
const PosVertex closest = closest_point(gpoint);
if (closest.valid()) {
-
remove_point(closest);
return true;
}
@@ -421,11 +346,8 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
if (mode == MODE_CREATE) {
-
if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
-
if (_is_line()) {
-
// for lines, we don't have a wip mode, and we can undo each single add point.
Vector<Vector2> vertices = _get_polygon(0);
vertices.push_back(cpoint);
@@ -434,7 +356,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
_commit_action();
return true;
} else if (!wip_active) {
-
wip.clear();
wip.push_back(cpoint);
wip_active = true;
@@ -446,7 +367,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
edge_point = PosVertex();
return true;
} else {
-
const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
if (!_is_line() && wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) {
@@ -455,7 +375,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
} else {
-
//add wip point
wip.push_back(cpoint);
_wip_changed();
@@ -474,11 +393,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
Vector2 gpoint = mm->get_position();
if (edited_point.valid() && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) {
-
Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
//Move the point in a single axis. Should only work when editing a polygon and while holding shift.
@@ -494,7 +411,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
edited_point = PosVertex(edited_point, cpoint);
if (!wip_active) {
-
Vector<Vector2> vertices = _get_polygon(edited_point.polygon);
ERR_FAIL_INDEX_V(edited_point.vertex, vertices.size(), false);
vertices.write[edited_point.vertex] = cpoint - _get_offset(edited_point.polygon);
@@ -503,25 +419,20 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
canvas_item_editor->update_viewport();
} else if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
-
const PosVertex onEdgeVertex = closest_edge_point(gpoint);
if (onEdgeVertex.valid()) {
-
hover_point = Vertex();
edge_point = onEdgeVertex;
canvas_item_editor->update_viewport();
} else {
-
if (edge_point.valid()) {
-
edge_point = PosVertex();
canvas_item_editor->update_viewport();
}
const PosVertex new_hover_point = closest_point(gpoint);
if (hover_point != new_hover_point) {
-
hover_point = new_hover_point;
canvas_item_editor->update_viewport();
}
@@ -532,13 +443,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
-
if (k->get_keycode() == KEY_DELETE || k->get_keycode() == KEY_BACKSPACE) {
-
if (wip_active && selected_point.polygon == -1) {
-
if (wip.size() > selected_point.vertex) {
-
wip.remove(selected_point.vertex);
_wip_changed();
selected_point = wip.size() - 1;
@@ -546,17 +453,14 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
return true;
}
} else {
-
const Vertex active_point = get_active_point();
if (active_point.valid()) {
-
remove_point(active_point);
return true;
}
}
} else if (wip_active && k->get_keycode() == KEY_ENTER) {
-
_wip_close();
} else if (wip_active && k->get_keycode() == KEY_ESCAPE) {
_wip_cancel();
@@ -567,9 +471,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
}
void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
-
- if (!_get_node())
+ if (!_get_node()) {
return;
+ }
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
// All polygon points are sharp, so use the sharp handle icon
@@ -580,31 +484,28 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
const bool is_closed = !_is_line();
for (int j = -1; j < n_polygons; j++) {
-
- if (wip_active && wip_destructive && j != -1)
+ if (wip_active && wip_destructive && j != -1) {
continue;
+ }
Vector<Vector2> points;
Vector2 offset;
if (wip_active && j == edited_point.polygon) {
-
points = Variant(wip);
offset = Vector2(0, 0);
} else {
-
- if (j == -1)
+ if (j == -1) {
continue;
+ }
points = _get_polygon(j);
offset = _get_offset(j);
}
if (!wip_active && j == edited_point.polygon && EDITOR_GET("editors/poly_editor/show_previous_outline")) {
-
const Color col = Color(0.5, 0.5, 0.5); // FIXME polygon->get_outline_color();
const int n = pre_move_edit.size();
for (int i = 0; i < n - (is_closed ? 0 : 1); i++) {
-
Vector2 p, p2;
p = pre_move_edit[i] + offset;
p2 = pre_move_edit[(i + 1) % n] + offset;
@@ -620,20 +521,19 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
const Color col = Color(1, 0.3, 0.1, 0.8);
for (int i = 0; i < n_points; i++) {
-
const Vertex vertex(j, i);
const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset);
const Vector2 point = xform.xform(p);
if (is_closed || i < n_points - 1) {
-
Vector2 p2;
if (j == edited_point.polygon &&
- ((wip_active && i == n_points - 1) || (((i + 1) % n_points) == edited_point.vertex)))
+ ((wip_active && i == n_points - 1) || (((i + 1) % n_points) == edited_point.vertex))) {
p2 = edited_point.pos;
- else
+ } else {
p2 = points[(i + 1) % n_points] + offset;
+ }
const Vector2 next_point = xform.xform(p2);
p_overlay->draw_line(point, next_point, col, Math::round(2 * EDSCALE));
@@ -641,7 +541,6 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
}
for (int i = 0; i < n_points; i++) {
-
const Vertex vertex(j, i);
const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset);
@@ -660,26 +559,25 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
}
if (edge_point.valid()) {
-
Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5);
}
}
void AbstractPolygon2DEditor::edit(Node *p_polygon) {
-
- if (!canvas_item_editor)
+ if (!canvas_item_editor) {
canvas_item_editor = CanvasItemEditor::get_singleton();
+ }
if (p_polygon) {
-
_set_node(p_polygon);
// Enable the pencil tool if the polygon is empty.
- if (_is_empty())
+ if (_is_empty()) {
_menu_option(MODE_CREATE);
- else
+ } else {
_menu_option(MODE_EDIT);
+ }
wip.clear();
wip_active = false;
@@ -689,7 +587,6 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) {
canvas_item_editor->update_viewport();
} else {
-
_set_node(nullptr);
}
}
@@ -698,38 +595,35 @@ void AbstractPolygon2DEditor::_bind_methods() {
}
void AbstractPolygon2DEditor::remove_point(const Vertex &p_vertex) {
-
Vector<Vector2> vertices = _get_polygon(p_vertex.polygon);
if (vertices.size() > (_is_line() ? 2 : 3)) {
-
vertices.remove(p_vertex.vertex);
undo_redo->create_action(TTR("Edit Polygon (Remove Point)"));
_action_set_polygon(p_vertex.polygon, vertices);
_commit_action();
} else {
-
undo_redo->create_action(TTR("Remove Polygon And Point"));
_action_remove_polygon(p_vertex.polygon);
_commit_action();
}
- if (_is_empty())
+ if (_is_empty()) {
_menu_option(MODE_CREATE);
+ }
hover_point = Vertex();
- if (selected_point == p_vertex)
+ if (selected_point == p_vertex) {
selected_point = Vertex();
+ }
}
AbstractPolygon2DEditor::Vertex AbstractPolygon2DEditor::get_active_point() const {
-
return hover_point.valid() ? hover_point : selected_point;
}
AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const Vector2 &p_pos) const {
-
const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
const int n_polygons = _get_polygon_count();
@@ -739,13 +633,11 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const
real_t closest_dist = 1e10;
for (int j = 0; j < n_polygons; j++) {
-
Vector<Vector2> points = _get_polygon(j);
const Vector2 offset = _get_offset(j);
const int n_points = points.size();
for (int i = 0; i < n_points; i++) {
-
Vector2 cp = xform.xform(points[i] + offset);
real_t d = cp.distance_to(p_pos);
@@ -760,7 +652,6 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const
}
AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(const Vector2 &p_pos) const {
-
const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
const real_t eps = grab_threshold * 2;
const real_t eps2 = eps * eps;
@@ -772,21 +663,20 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c
real_t closest_dist = 1e10;
for (int j = 0; j < n_polygons; j++) {
-
Vector<Vector2> points = _get_polygon(j);
const Vector2 offset = _get_offset(j);
const int n_points = points.size();
const int n_segments = n_points - (_is_line() ? 1 : 0);
for (int i = 0; i < n_segments; i++) {
-
Vector2 segment[2] = { xform.xform(points[i] + offset),
xform.xform(points[(i + 1) % n_points] + offset) };
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(p_pos, segment);
+ Vector2 cp = Geometry2D::get_closest_point_to_segment(p_pos, segment);
- if (cp.distance_squared_to(segment[0]) < eps2 || cp.distance_squared_to(segment[1]) < eps2)
+ if (cp.distance_squared_to(segment[0]) < eps2 || cp.distance_squared_to(segment[1]) < eps2) {
continue; //not valid to reuse point
+ }
real_t d = cp.distance_to(p_pos);
if (d < closest_dist && d < grab_threshold) {
@@ -800,7 +690,6 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c
}
AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive) {
-
canvas_item_editor = nullptr;
editor = p_editor;
undo_redo = EditorNode::get_undo_redo();
@@ -837,22 +726,17 @@ AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wi
}
void AbstractPolygon2DEditorPlugin::edit(Object *p_object) {
-
polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool AbstractPolygon2DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class(klass);
}
void AbstractPolygon2DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
polygon_editor->show();
} else {
-
polygon_editor->hide();
polygon_editor->edit(nullptr);
}
diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h
index 6ed6d0a257..d5b3a916d1 100644
--- a/editor/plugins/abstract_polygon_2d_editor.h
+++ b/editor/plugins/abstract_polygon_2d_editor.h
@@ -39,7 +39,6 @@
class CanvasItemEditor;
class AbstractPolygon2DEditor : public HBoxContainer {
-
GDCLASS(AbstractPolygon2DEditor, HBoxContainer);
ToolButton *button_create;
@@ -47,23 +46,30 @@ class AbstractPolygon2DEditor : public HBoxContainer {
ToolButton *button_delete;
struct Vertex {
- Vertex();
- Vertex(int p_vertex);
- Vertex(int p_polygon, int p_vertex);
+ Vertex() {}
+ Vertex(int p_vertex) :
+ vertex(p_vertex) {}
+ Vertex(int p_polygon, int p_vertex) :
+ polygon(p_polygon),
+ vertex(p_vertex) {}
bool operator==(const Vertex &p_vertex) const;
bool operator!=(const Vertex &p_vertex) const;
bool valid() const;
- int polygon;
- int vertex;
+ int polygon = -1;
+ int vertex = -1;
};
struct PosVertex : public Vertex {
- PosVertex();
- PosVertex(const Vertex &p_vertex, const Vector2 &p_pos);
- PosVertex(int p_polygon, int p_vertex, const Vector2 &p_pos);
+ PosVertex() {}
+ PosVertex(const Vertex &p_vertex, const Vector2 &p_pos) :
+ Vertex(p_vertex.polygon, p_vertex.vertex),
+ pos(p_pos) {}
+ PosVertex(int p_polygon, int p_vertex, const Vector2 &p_pos) :
+ Vertex(p_polygon, p_vertex),
+ pos(p_pos) {}
Vector2 pos;
};
@@ -144,7 +150,6 @@ public:
};
class AbstractPolygon2DEditorPlugin : public EditorPlugin {
-
GDCLASS(AbstractPolygon2DEditorPlugin, EditorPlugin);
AbstractPolygon2DEditor *polygon_editor;
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index eb50df2166..75eacf56ec 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -81,8 +81,9 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
String name = String(E->get()).replace_first("AnimationNode", "");
- if (name == "Animation")
+ if (name == "Animation") {
continue;
+ }
int idx = menu->get_item_count();
menu->add_item(vformat("Add %s", name), idx);
@@ -117,7 +118,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
_update_tool_erase();
for (int i = 0; i < points.size(); i++) {
-
if (Math::abs(float(points[i] - mb->get_position().x)) < 10 * EDSCALE) {
selected_point = i;
@@ -196,7 +196,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
}
void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
-
Color linecolor = get_theme_color("font_color", "Label");
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
@@ -227,7 +226,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
}
if (snap->is_pressed()) {
-
linecolor_soft.a = linecolor.a * 0.1;
if (blend_space->get_snap() > 0) {
@@ -303,9 +301,9 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
}
void AnimationNodeBlendSpace1DEditor::_update_space() {
-
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
@@ -322,8 +320,9 @@ void AnimationNodeBlendSpace1DEditor::_update_space() {
}
void AnimationNodeBlendSpace1DEditor::_config_changed(double) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
undo_redo->create_action(TTR("Change BlendSpace1D Limits"));
@@ -342,8 +341,9 @@ void AnimationNodeBlendSpace1DEditor::_config_changed(double) {
}
void AnimationNodeBlendSpace1DEditor::_labels_changed(String) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
undo_redo->create_action(TTR("Change BlendSpace1D Labels"), UndoRedo::MERGE_ENDS);
@@ -360,7 +360,6 @@ void AnimationNodeBlendSpace1DEditor::_snap_toggled() {
}
void AnimationNodeBlendSpace1DEditor::_file_opened(const String &p_file) {
-
file_loaded = ResourceLoader::load(p_file);
if (file_loaded.is_valid()) {
_add_menu_type(MENU_LOAD_FILE_CONFIRM);
@@ -370,7 +369,6 @@ void AnimationNodeBlendSpace1DEditor::_file_opened(const String &p_file) {
void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) {
Ref<AnimationRootNode> node;
if (p_index == MENU_LOAD_FILE) {
-
open_file->clear_filters();
List<String> filters;
ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters);
@@ -383,7 +381,6 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) {
node = file_loaded;
file_loaded.unref();
} else if (p_index == MENU_PASTE) {
-
node = EditorSettings::get_singleton()->get_resource_clipboard();
} else {
String type = menu->get_item_metadata(p_index);
@@ -432,7 +429,6 @@ void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) {
}
void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) {
-
if (p_tool == 0) {
tool_erase->show();
tool_erase_sep->show();
@@ -446,8 +442,9 @@ void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) {
}
void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() {
- if (updating)
+ if (updating) {
return;
+ }
if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) {
float pos = blend_space->get_blend_point_position(selected_point);
@@ -467,7 +464,6 @@ void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() {
}
void AnimationNodeBlendSpace1DEditor::_update_tool_erase() {
-
bool point_valid = selected_point >= 0 && selected_point < blend_space->get_blend_point_count();
tool_erase->set_disabled(!point_valid);
@@ -504,8 +500,9 @@ void AnimationNodeBlendSpace1DEditor::_erase_selected() {
}
void AnimationNodeBlendSpace1DEditor::_edit_point_pos(double) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
undo_redo->create_action(TTR("Move BlendSpace1D Node Point"));
@@ -522,7 +519,6 @@ void AnimationNodeBlendSpace1DEditor::_edit_point_pos(double) {
}
void AnimationNodeBlendSpace1DEditor::_open_editor() {
-
if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) {
Ref<AnimationNode> an = blend_space->get_blend_point_node(selected_point);
ERR_FAIL_COND(an.is_null());
@@ -575,13 +571,11 @@ void AnimationNodeBlendSpace1DEditor::_bind_methods() {
}
bool AnimationNodeBlendSpace1DEditor::can_edit(const Ref<AnimationNode> &p_node) {
-
Ref<AnimationNodeBlendSpace1D> b1d = p_node;
return b1d.is_valid();
}
void AnimationNodeBlendSpace1DEditor::edit(const Ref<AnimationNode> &p_node) {
-
blend_space = p_node;
if (!blend_space.is_null()) {
diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h
index 346ad36cff..8cfd6714ad 100644
--- a/editor/plugins/animation_blend_space_1d_editor.h
+++ b/editor/plugins/animation_blend_space_1d_editor.h
@@ -42,7 +42,6 @@
#include "scene/gui/tree.h"
class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin {
-
GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin);
Ref<AnimationNodeBlendSpace1D> blend_space;
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 4ea84e716b..a7d5c2207b 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -32,7 +32,7 @@
#include "core/input/input.h"
#include "core/io/resource_loader.h"
-#include "core/math/delaunay_2d.h"
+#include "core/math/geometry_2d.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_scale.h"
@@ -43,7 +43,6 @@
#include "scene/main/window.h"
bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) {
-
Ref<AnimationNodeBlendSpace2D> bs2d = p_node;
return bs2d.is_valid();
}
@@ -53,7 +52,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_changed() {
}
void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) {
-
if (blend_space.is_valid()) {
blend_space->disconnect("triangles_updated", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_blend_space_changed));
}
@@ -71,7 +69,6 @@ StringName AnimationNodeBlendSpace2DEditor::get_blend_position_path() const {
}
void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
if (selected_point != -1 || selected_triangle != -1) {
@@ -107,10 +104,10 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
-
String name = String(E->get()).replace_first("AnimationNode", "");
- if (name == "Animation")
+ if (name == "Animation") {
continue; // nope
+ }
int idx = menu->get_item_count();
menu->add_item(vformat("Add %s", name), idx);
menu->set_item_metadata(idx, E->get());
@@ -138,7 +135,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
blend_space_draw->update(); //update anyway
//try to see if a point can be selected
selected_point = -1;
@@ -146,7 +142,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
_update_tool_erase();
for (int i = 0; i < points.size(); i++) {
-
if (points[i].distance_to(mb->get_position()) < 10 * EDSCALE) {
selected_point = i;
Ref<AnimationNode> node = blend_space->get_blend_point_node(i);
@@ -170,7 +165,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
triangle.push_back(points[idx]);
}
- if (Geometry::is_point_in_triangle(mb->get_position(), triangle[0], triangle[1], triangle[2])) {
+ if (Geometry2D::is_point_in_triangle(mb->get_position(), triangle[0], triangle[1], triangle[2])) {
selected_triangle = i;
_update_tool_erase();
return;
@@ -180,15 +175,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
if (mb.is_valid() && mb->is_pressed() && tool_triangle->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
blend_space_draw->update(); //update anyway
//try to see if a point can be selected
selected_point = -1;
for (int i = 0; i < points.size(); i++) {
-
- if (making_triangle.find(i) != -1)
+ if (making_triangle.find(i) != -1) {
continue;
+ }
if (points[i].distance_to(mb->get_position()) < 10 * EDSCALE) {
making_triangle.push_back(i);
@@ -243,7 +237,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
Vector2 blend_pos = (mb->get_position() / blend_space_draw->get_size());
blend_pos.y = 1.0 - blend_pos.y;
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
@@ -278,7 +271,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
if (mm.is_valid() && tool_blend->is_pressed() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
Vector2 blend_pos = (mm->get_position() / blend_space_draw->get_size());
blend_pos.y = 1.0 - blend_pos.y;
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
@@ -291,7 +283,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
}
void AnimationNodeBlendSpace2DEditor::_file_opened(const String &p_file) {
-
file_loaded = ResourceLoader::load(p_file);
if (file_loaded.is_valid()) {
_add_menu_type(MENU_LOAD_FILE_CONFIRM);
@@ -299,10 +290,8 @@ void AnimationNodeBlendSpace2DEditor::_file_opened(const String &p_file) {
}
void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) {
-
Ref<AnimationRootNode> node;
if (p_index == MENU_LOAD_FILE) {
-
open_file->clear_filters();
List<String> filters;
ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters);
@@ -315,7 +304,6 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) {
node = file_loaded;
file_loaded.unref();
} else if (p_index == MENU_PASTE) {
-
node = EditorSettings::get_singleton()->get_resource_clipboard();
} else {
String type = menu->get_item_metadata(p_index);
@@ -346,7 +334,6 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) {
}
void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) {
-
Ref<AnimationNodeAnimation> anim;
anim.instance();
@@ -405,7 +392,6 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) {
}
void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
-
Color linecolor = get_theme_color("font_color", "Label");
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
@@ -438,14 +424,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
if (snap->is_pressed()) {
-
linecolor_soft.a = linecolor.a * 0.1;
if (blend_space->get_snap().x > 0) {
-
int prev_idx = 0;
for (int i = 0; i < s.x; i++) {
-
float v = blend_space->get_min_space().x + i * (blend_space->get_max_space().x - blend_space->get_min_space().x) / s.x;
int idx = int(v / blend_space->get_snap().x);
@@ -458,10 +441,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
if (blend_space->get_snap().y > 0) {
-
int prev_idx = 0;
for (int i = 0; i < s.y; i++) {
-
float v = blend_space->get_max_space().y - i * (blend_space->get_max_space().y - blend_space->get_min_space().y) / s.y;
int idx = int(v / blend_space->get_snap().y);
@@ -476,7 +457,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
//triangles first
for (int i = 0; i < blend_space->get_triangle_count(); i++) {
-
Vector<Vector2> points;
points.resize(3);
@@ -518,7 +498,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
points.clear();
for (int i = 0; i < blend_space->get_blend_point_count(); i++) {
-
Vector2 point = blend_space->get_blend_point_position(i);
if (dragging_selected && selected_point == i) {
point += drag_ofs;
@@ -597,14 +576,13 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
}
void AnimationNodeBlendSpace2DEditor::_snap_toggled() {
-
blend_space_draw->update();
}
void AnimationNodeBlendSpace2DEditor::_update_space() {
-
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
@@ -636,8 +614,9 @@ void AnimationNodeBlendSpace2DEditor::_update_space() {
}
void AnimationNodeBlendSpace2DEditor::_config_changed(double) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
undo_redo->create_action(TTR("Change BlendSpace2D Limits"));
@@ -658,8 +637,9 @@ void AnimationNodeBlendSpace2DEditor::_config_changed(double) {
}
void AnimationNodeBlendSpace2DEditor::_labels_changed(String) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
undo_redo->create_action(TTR("Change BlendSpace2D Labels"), UndoRedo::MERGE_ENDS);
@@ -674,9 +654,7 @@ void AnimationNodeBlendSpace2DEditor::_labels_changed(String) {
}
void AnimationNodeBlendSpace2DEditor::_erase_selected() {
-
if (selected_point != -1) {
-
updating = true;
undo_redo->create_action(TTR("Remove BlendSpace2D Point"));
undo_redo->add_do_method(blend_space.ptr(), "remove_blend_point", selected_point);
@@ -699,7 +677,6 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() {
blend_space_draw->update();
} else if (selected_triangle != -1) {
-
updating = true;
undo_redo->create_action(TTR("Remove BlendSpace2D Triangle"));
undo_redo->add_do_method(blend_space.ptr(), "remove_triangle", selected_triangle);
@@ -715,8 +692,9 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() {
}
void AnimationNodeBlendSpace2DEditor::_update_edited_point_pos() {
- if (updating)
+ if (updating) {
return;
+ }
if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) {
Vector2 pos = blend_space->get_blend_point_position(selected_point);
@@ -735,8 +713,9 @@ void AnimationNodeBlendSpace2DEditor::_update_edited_point_pos() {
}
void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
undo_redo->create_action(TTR("Move Node Point"));
undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, Vector2(edit_x->get_value(), edit_y->get_value()));
@@ -752,7 +731,6 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) {
}
void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
@@ -772,7 +750,6 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
-
String error;
if (!AnimationTreeEditor::get_singleton()->get_tree()) {
@@ -801,7 +778,6 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
}
void AnimationNodeBlendSpace2DEditor::_open_editor() {
-
if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) {
Ref<AnimationNode> an = blend_space->get_blend_point_node(selected_point);
ERR_FAIL_COND(an.is_null());
@@ -814,7 +790,6 @@ void AnimationNodeBlendSpace2DEditor::_removed_from_graph() {
}
void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() {
-
undo_redo->create_action(TTR("Toggle Auto Triangles"));
undo_redo->add_do_method(blend_space.ptr(), "set_auto_triangles", auto_triangles->is_pressed());
undo_redo->add_undo_method(blend_space.ptr(), "set_auto_triangles", blend_space->get_auto_triangles());
@@ -824,7 +799,6 @@ void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() {
}
void AnimationNodeBlendSpace2DEditor::_bind_methods() {
-
ClassDB::bind_method("_update_space", &AnimationNodeBlendSpace2DEditor::_update_space);
ClassDB::bind_method("_update_tool_erase", &AnimationNodeBlendSpace2DEditor::_update_tool_erase);
@@ -836,7 +810,6 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() {
AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = nullptr;
AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
-
singleton = this;
updating = false;
diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h
index 50b0d9a06c..b430a12297 100644
--- a/editor/plugins/animation_blend_space_2d_editor.h
+++ b/editor/plugins/animation_blend_space_2d_editor.h
@@ -42,7 +42,6 @@
#include "scene/gui/tree.h"
class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin {
-
GDCLASS(AnimationNodeBlendSpace2DEditor, AnimationTreeNodeEditorPlugin);
Ref<AnimationNodeBlendSpace2D> blend_space;
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 23e547f55d..82d942821f 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -43,7 +43,6 @@
#include "scene/main/window.h"
void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script) {
-
for (int i = 0; i < add_options.size(); i++) {
ERR_FAIL_COND(add_options[i].script == p_script);
}
@@ -57,7 +56,6 @@ void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const R
}
void AnimationNodeBlendTreeEditor::remove_custom_type(const Ref<Script> &p_script) {
-
for (int i = 0; i < add_options.size(); i++) {
if (add_options[i].script == p_script) {
add_options.remove(i);
@@ -69,7 +67,6 @@ void AnimationNodeBlendTreeEditor::remove_custom_type(const Ref<Script> &p_scrip
}
void AnimationNodeBlendTreeEditor::_update_options_menu() {
-
add_node->get_popup()->clear();
for (int i = 0; i < add_options.size(); i++) {
add_node->get_popup()->add_item(add_options[i].name, i);
@@ -86,12 +83,10 @@ void AnimationNodeBlendTreeEditor::_update_options_menu() {
}
Size2 AnimationNodeBlendTreeEditor::get_minimum_size() const {
-
return Size2(10, 200);
}
void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
-
AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_tree();
updating = true;
undo_redo->create_action(TTR("Parameter Changed") + ": " + String(p_property), UndoRedo::MERGE_ENDS);
@@ -104,9 +99,9 @@ void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_propert
}
void AnimationNodeBlendTreeEditor::_update_graph() {
-
- if (updating)
+ if (updating) {
return;
+ }
visible_properties.clear();
@@ -115,7 +110,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
graph->clear_connections();
//erase all nodes
for (int i = 0; i < graph->get_child_count(); i++) {
-
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
@@ -128,7 +122,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
blend_tree->get_node_list(&nodes);
for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) {
-
GraphNode *node = memnew(GraphNode);
graph->add_child(node);
@@ -163,7 +156,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
List<PropertyInfo> pinfo;
agnode->get_parameter_list(&pinfo);
for (List<PropertyInfo>::Element *F = pinfo.front(); F; F = F->next()) {
-
if (!(F->get().usage & PROPERTY_USAGE_EDITOR)) {
continue;
}
@@ -192,7 +184,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
}
if (agnode->has_filter()) {
-
node->add_child(memnew(HSeparator));
Button *edit_filters = memnew(Button);
edit_filters->set_text(TTR("Edit Filters"));
@@ -204,7 +195,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
Ref<AnimationNodeAnimation> anim = agnode;
if (anim.is_valid()) {
-
MenuButton *mb = memnew(MenuButton);
mb->set_text(anim->get_animation());
mb->set_icon(get_theme_icon("Animation", "EditorIcons"));
@@ -259,7 +249,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
blend_tree->get_node_connections(&connections);
for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) {
-
StringName from = E->get().output_node;
StringName to = E->get().input_node;
int to_idx = E->get().input_index;
@@ -269,7 +258,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
}
void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) {
-
file_loaded = ResourceLoader::load(p_file);
if (file_loaded.is_valid()) {
_add_node(MENU_LOAD_FILE_CONFIRM);
@@ -277,13 +265,11 @@ void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) {
}
void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
-
Ref<AnimationNode> anode;
String base_name;
if (p_idx == MENU_LOAD_FILE) {
-
open_file->clear_filters();
List<String> filters;
ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters);
@@ -297,7 +283,6 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
file_loaded.unref();
base_name = anode->get_class();
} else if (p_idx == MENU_PASTE) {
-
anode = EditorSettings::get_singleton()->get_resource_clipboard();
ERR_FAIL_COND(!anode.is_valid());
base_name = anode->get_class();
@@ -347,7 +332,6 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
}
void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, const StringName &p_which) {
-
updating = true;
undo_redo->create_action(TTR("Node Moved"));
undo_redo->add_do_method(blend_tree.ptr(), "set_node_position", p_which, p_to / EDSCALE);
@@ -359,7 +343,6 @@ void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Ve
}
void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
-
AnimationNodeBlendTree::ConnectionError err = blend_tree->can_connect_node(p_to, p_to_index, p_from);
if (err != AnimationNodeBlendTree::CONNECTION_OK) {
@@ -376,7 +359,6 @@ void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int
}
void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
-
graph->disconnect_node(p_from, p_from_index, p_to, p_to_index);
updating = true;
@@ -390,7 +372,6 @@ void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from,
}
void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, const String &p_node) {
-
String option = p_options[p_index];
Ref<AnimationNodeAnimation> anim = blend_tree->get_node(p_node);
@@ -405,7 +386,6 @@ void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options,
}
void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) {
-
undo_redo->create_action(TTR("Delete Node"));
undo_redo->add_do_method(blend_tree.ptr(), "remove_node", p_which);
undo_redo->add_undo_method(blend_tree.ptr(), "add_node", p_which, blend_tree->get_node(p_which), blend_tree.ptr()->get_node_position(p_which));
@@ -425,7 +405,6 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) {
}
void AnimationNodeBlendTreeEditor::_delete_nodes_request() {
-
List<StringName> to_erase;
for (int i = 0; i < graph->get_child_count(); i++) {
@@ -437,8 +416,9 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() {
}
}
- if (to_erase.empty())
+ if (to_erase.empty()) {
return;
+ }
undo_redo->create_action(TTR("Delete Node(s)"));
@@ -450,7 +430,6 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() {
}
void AnimationNodeBlendTreeEditor::_popup_request(const Vector2 &p_position) {
-
_update_options_menu();
use_popup_menu_position = true;
popup_menu_position = graph->get_local_mouse_position();
@@ -459,7 +438,6 @@ void AnimationNodeBlendTreeEditor::_popup_request(const Vector2 &p_position) {
}
void AnimationNodeBlendTreeEditor::_node_selected(Object *p_node) {
-
GraphNode *gn = Object::cast_to<GraphNode>(p_node);
ERR_FAIL_COND(!gn);
@@ -472,14 +450,12 @@ void AnimationNodeBlendTreeEditor::_node_selected(Object *p_node) {
}
void AnimationNodeBlendTreeEditor::_open_in_editor(const String &p_which) {
-
Ref<AnimationNode> an = blend_tree->get_node(p_which);
ERR_FAIL_COND(!an.is_valid());
AnimationTreeEditor::get_singleton()->enter_editor(p_which);
}
void AnimationNodeBlendTreeEditor::_filter_toggled() {
-
updating = true;
undo_redo->create_action(TTR("Toggle Filter On/Off"));
undo_redo->add_do_method(_filter_edit.ptr(), "set_filter_enabled", filter_enabled->is_pressed());
@@ -491,7 +467,6 @@ void AnimationNodeBlendTreeEditor::_filter_toggled() {
}
void AnimationNodeBlendTreeEditor::_filter_edited() {
-
TreeItem *edited = filters->get_edited();
ERR_FAIL_COND(!edited);
@@ -509,9 +484,9 @@ void AnimationNodeBlendTreeEditor::_filter_edited() {
}
bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &anode) {
-
- if (updating || _filter_edit != anode)
+ if (updating || _filter_edit != anode) {
return false;
+ }
NodePath player_path = AnimationTreeEditor::get_singleton()->get_tree()->get_animation_player();
@@ -542,7 +517,6 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
player->get_animation_list(&animations);
for (List<StringName>::Element *E = animations.front(); E; E = E->next()) {
-
Ref<Animation> anim = player->get_animation(E->get());
for (int i = 0; i < anim->get_track_count(); i++) {
String track_path = anim->track_get_path(i);
@@ -577,7 +551,6 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
Map<String, TreeItem *> parenthood;
for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
-
NodePath path = E->get();
TreeItem *ti = nullptr;
String accum;
@@ -612,11 +585,11 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
if (base->has_node(accum)) {
node = base->get_node(accum);
}
- if (!node)
+ if (!node) {
continue; //no node, can't edit
+ }
if (path.get_subname_count()) {
-
String concat = path.get_concatenated_subnames();
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
@@ -697,13 +670,13 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
}
void AnimationNodeBlendTreeEditor::_edit_filters(const String &p_which) {
-
Ref<AnimationNode> anode = blend_tree->get_node(p_which);
ERR_FAIL_COND(!anode.is_valid());
_filter_edit = anode;
- if (!_update_filters(anode))
+ if (!_update_filters(anode)) {
return;
+ }
filter_dialog->popup_centered(Size2(500, 500) * EDSCALE);
}
@@ -715,18 +688,16 @@ void AnimationNodeBlendTreeEditor::_removed_from_graph() {
}
void AnimationNodeBlendTreeEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
-
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
- if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree())
+ if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) {
_update_graph();
+ }
}
if (p_what == NOTIFICATION_PROCESS) {
-
String error;
if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) {
@@ -789,15 +760,15 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
}
void AnimationNodeBlendTreeEditor::_scroll_changed(const Vector2 &p_scroll) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
blend_tree->set_graph_offset(p_scroll / EDSCALE);
updating = false;
}
void AnimationNodeBlendTreeEditor::_bind_methods() {
-
ClassDB::bind_method("_update_graph", &AnimationNodeBlendTreeEditor::_update_graph);
ClassDB::bind_method("_update_filters", &AnimationNodeBlendTreeEditor::_update_filters);
}
@@ -805,7 +776,6 @@ void AnimationNodeBlendTreeEditor::_bind_methods() {
AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr;
void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) {
-
String prev_name = blend_tree->get_node_name(p_node);
ERR_FAIL_COND(prev_name == String());
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name));
@@ -858,7 +828,6 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
blend_tree->get_node_connections(&connections);
for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) {
-
StringName from = E->get().output_node;
StringName to = E->get().input_node;
int to_idx = E->get().input_index;
@@ -888,7 +857,6 @@ bool AnimationNodeBlendTreeEditor::can_edit(const Ref<AnimationNode> &p_node) {
}
void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) {
-
if (blend_tree.is_valid()) {
blend_tree->disconnect("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph));
}
@@ -905,7 +873,6 @@ void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) {
}
AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
-
singleton = this;
updating = false;
use_popup_menu_position = false;
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index 4f5badea9f..6bdb7e7909 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -44,7 +44,6 @@
class ProgressBar;
class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin {
-
GDCLASS(AnimationNodeBlendTreeEditor, AnimationTreeNodeEditorPlugin);
Ref<AnimationNodeBlendTree> blend_tree;
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 0a252cc0a3..1e0a9535e2 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -44,7 +44,6 @@
#include "servers/rendering_server.h"
void AnimationPlayerEditor::_node_removed(Node *p_node) {
-
if (player && player == p_node) {
player = nullptr;
@@ -58,24 +57,21 @@ void AnimationPlayerEditor::_node_removed(Node *p_node) {
}
void AnimationPlayerEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_PROCESS: {
-
- if (!player)
+ if (!player) {
return;
+ }
updating = true;
if (player->is_playing()) {
-
{
String animname = player->get_assigned_animation();
if (player->has_animation(animname)) {
Ref<Animation> anim = player->get_animation(animname);
if (!anim.is_null()) {
-
frame->set_max(anim->get_length());
}
}
@@ -96,7 +92,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
updating = false;
} break;
case NOTIFICATION_ENTER_TREE: {
-
tool_anim->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu));
onion_skinning->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu));
@@ -108,11 +103,9 @@ void AnimationPlayerEditor::_notification(int p_what) {
add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
} break;
case NOTIFICATION_THEME_CHANGED: {
-
autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons"));
play->set_icon(get_theme_icon("PlayStart", "EditorIcons"));
@@ -147,9 +140,9 @@ void AnimationPlayerEditor::_notification(int p_what) {
}
void AnimationPlayerEditor::_autoplay_pressed() {
-
- if (updating)
+ if (updating) {
return;
+ }
if (animation->get_item_count() == 0) {
return;
}
@@ -176,17 +169,15 @@ void AnimationPlayerEditor::_autoplay_pressed() {
}
void AnimationPlayerEditor::_play_pressed() {
-
String current;
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
-
current = animation->get_item_text(animation->get_selected());
}
if (current != "") {
-
- if (current == player->get_assigned_animation())
+ if (current == player->get_assigned_animation()) {
player->stop(); //so it won't blend with itself
+ }
player->play(current);
}
@@ -195,19 +186,15 @@ void AnimationPlayerEditor::_play_pressed() {
}
void AnimationPlayerEditor::_play_from_pressed() {
-
String current;
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
-
current = animation->get_item_text(animation->get_selected());
}
if (current != "") {
-
float time = player->get_current_animation_position();
if (current == player->get_assigned_animation() && player->is_playing()) {
-
player->stop(); //so it won't blend with itself
}
@@ -220,17 +207,15 @@ void AnimationPlayerEditor::_play_from_pressed() {
}
void AnimationPlayerEditor::_play_bw_pressed() {
-
String current;
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
-
current = animation->get_item_text(animation->get_selected());
}
if (current != "") {
-
- if (current == player->get_assigned_animation())
+ if (current == player->get_assigned_animation()) {
player->stop(); //so it won't blend with itself
+ }
player->play(current, -1, -1, true);
}
@@ -239,18 +224,16 @@ void AnimationPlayerEditor::_play_bw_pressed() {
}
void AnimationPlayerEditor::_play_bw_from_pressed() {
-
String current;
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
-
current = animation->get_item_text(animation->get_selected());
}
if (current != "") {
-
float time = player->get_current_animation_position();
- if (current == player->get_assigned_animation())
+ if (current == player->get_assigned_animation()) {
player->stop(); //so it won't blend with itself
+ }
player->play(current, -1, -1, true);
player->seek(time);
@@ -259,8 +242,8 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
//unstop
stop->set_pressed(false);
}
-void AnimationPlayerEditor::_stop_pressed() {
+void AnimationPlayerEditor::_stop_pressed() {
if (!player) {
return;
}
@@ -271,24 +254,21 @@ void AnimationPlayerEditor::_stop_pressed() {
}
void AnimationPlayerEditor::_animation_selected(int p_which) {
-
- if (updating)
+ if (updating) {
return;
+ }
// when selecting an animation, the idea is that the only interesting behavior
// ui-wise is that it should play/blend the next one if currently playing
String current;
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
-
current = animation->get_item_text(animation->get_selected());
}
if (current != "") {
-
player->set_assigned_animation(current);
Ref<Animation> anim = player->get_animation(current);
{
-
track_editor->set_animation(anim);
Node *root = player->get_node(player->get_root());
if (root) {
@@ -310,7 +290,6 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
}
void AnimationPlayerEditor::_animation_new() {
-
renaming = false;
name_title->set_text(TTR("New Animation Name:"));
@@ -318,8 +297,9 @@ void AnimationPlayerEditor::_animation_new() {
String base = TTR("New Anim");
while (true) {
String attempt = base;
- if (count > 1)
+ if (count > 1) {
attempt += " (" + itos(count) + ")";
+ }
if (player->has_animation(attempt)) {
count++;
continue;
@@ -333,10 +313,11 @@ void AnimationPlayerEditor::_animation_new() {
name->select_all();
name->grab_focus();
}
-void AnimationPlayerEditor::_animation_rename() {
- if (animation->get_item_count() == 0)
+void AnimationPlayerEditor::_animation_rename() {
+ if (animation->get_item_count() == 0) {
return;
+ }
int selected = animation->get_selected();
String selected_name = animation->get_item_text(selected);
@@ -347,6 +328,7 @@ void AnimationPlayerEditor::_animation_rename() {
name->select_all();
name->grab_focus();
}
+
void AnimationPlayerEditor::_animation_load() {
ERR_FAIL_COND(!player);
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
@@ -355,7 +337,6 @@ void AnimationPlayerEditor::_animation_load() {
ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
@@ -364,10 +345,10 @@ void AnimationPlayerEditor::_animation_load() {
}
void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path) {
-
int flg = 0;
- if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
flg |= ResourceSaver::FLAG_COMPRESS;
+ }
String path = ProjectSettings::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -382,7 +363,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
}
void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
-
if (p_resource->get_path().is_resource_file()) {
_animation_save_in_path(p_resource, p_resource->get_path());
} else {
@@ -391,14 +371,12 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
}
void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) {
-
file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
List<String> extensions;
ResourceSaver::get_recognized_extensions(p_resource, &extensions);
file->clear_filters();
for (int i = 0; i < extensions.size(); i++) {
-
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
@@ -412,7 +390,6 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource)
}
}
} else {
-
String existing;
if (extensions.size()) {
if (p_resource->get_name() != "") {
@@ -429,9 +406,9 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource)
}
void AnimationPlayerEditor::_animation_remove() {
-
- if (animation->get_item_count() == 0)
+ if (animation->get_item_count() == 0) {
return;
+ }
String current = animation->get_item_text(animation->get_selected());
@@ -440,7 +417,6 @@ void AnimationPlayerEditor::_animation_remove() {
}
void AnimationPlayerEditor::_animation_remove_confirmed() {
-
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
@@ -463,12 +439,9 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
}
void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) {
-
int idx = -1;
for (int i = 0; i < animation->get_item_count(); i++) {
-
if (animation->get_item_text(i) == p_anim) {
-
idx = i;
break;
}
@@ -482,7 +455,6 @@ void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) {
}
double AnimationPlayerEditor::_get_editor_step() const {
-
// Returns the effective snapping value depending on snapping modifiers, or 0 if snapping is disabled.
if (track_editor->is_snap_enabled()) {
const String current = player->get_assigned_animation();
@@ -497,7 +469,6 @@ double AnimationPlayerEditor::_get_editor_step() const {
}
void AnimationPlayerEditor::_animation_name_edited() {
-
player->stop();
String new_name = name->get_text();
@@ -534,7 +505,6 @@ void AnimationPlayerEditor::_animation_name_edited() {
_select_anim_by_name(new_name);
} else {
-
Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
new_anim->set_name(new_name);
@@ -556,9 +526,9 @@ void AnimationPlayerEditor::_animation_name_edited() {
}
void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
-
- if (animation->get_item_count() == 0)
+ if (animation->get_item_count() == 0) {
return;
+ }
String current = animation->get_item_text(animation->get_selected());
@@ -571,14 +541,15 @@ void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
}
void AnimationPlayerEditor::_animation_blend() {
-
- if (updating_blends)
+ if (updating_blends) {
return;
+ }
blend_editor.tree->clear();
- if (animation->get_item_count() == 0)
+ if (animation->get_item_count() == 0) {
return;
+ }
String current = animation->get_item_text(animation->get_selected());
@@ -599,7 +570,6 @@ void AnimationPlayerEditor::_animation_blend() {
blend_editor.next->add_item("", i);
for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
-
String to = E->get();
TreeItem *blend = blend_editor.tree->create_item(root);
blend->set_editable(0, false);
@@ -627,18 +597,20 @@ void AnimationPlayerEditor::_animation_blend() {
}
void AnimationPlayerEditor::_blend_edited() {
-
- if (updating_blends)
+ if (updating_blends) {
return;
+ }
- if (animation->get_item_count() == 0)
+ if (animation->get_item_count() == 0) {
return;
+ }
String current = animation->get_item_text(animation->get_selected());
TreeItem *selected = blend_editor.tree->get_edited();
- if (!selected)
+ if (!selected) {
return;
+ }
updating_blends = true;
String to = selected->get_text(0);
@@ -655,15 +627,14 @@ void AnimationPlayerEditor::_blend_edited() {
}
void AnimationPlayerEditor::ensure_visibility() {
-
- if (player && pin->is_pressed())
+ if (player && pin->is_pressed()) {
return; // another player is pinned, don't reset
+ }
_animation_edit();
}
Dictionary AnimationPlayerEditor::get_state() const {
-
Dictionary d;
d["visible"] = is_visible_in_tree();
@@ -675,8 +646,8 @@ Dictionary AnimationPlayerEditor::get_state() const {
return d;
}
-void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
+void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
if (!p_state.has("visible") || !p_state["visible"]) {
return;
}
@@ -685,7 +656,6 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
}
if (p_state.has("player")) {
-
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
player = Object::cast_to<AnimationPlayer>(n);
@@ -710,7 +680,6 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
}
void AnimationPlayerEditor::_animation_resource_edit() {
-
if (animation->get_item_count()) {
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
@@ -719,7 +688,6 @@ void AnimationPlayerEditor::_animation_resource_edit() {
}
void AnimationPlayerEditor::_animation_edit() {
-
if (animation->get_item_count()) {
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
@@ -736,7 +704,6 @@ void AnimationPlayerEditor::_animation_edit() {
}
void AnimationPlayerEditor::_dialog_action(String p_file) {
-
switch (current_option) {
case RESOURCE_LOAD: {
ERR_FAIL_COND(!player);
@@ -745,16 +712,15 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
ERR_FAIL_COND_MSG(res.is_null(), "Cannot load Animation from file '" + p_file + "'.");
ERR_FAIL_COND_MSG(!res->is_class("Animation"), "Loaded resource from file '" + p_file + "' is not Animation.");
if (p_file.find_last("/") != -1) {
-
p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length());
}
if (p_file.find_last("\\") != -1) {
-
p_file = p_file.substr(p_file.find_last("\\") + 1, p_file.length());
}
- if (p_file.find(".") != -1)
+ if (p_file.find(".") != -1) {
p_file = p_file.substr(0, p_file.find("."));
+ }
undo_redo->create_action(TTR("Load Animation"));
undo_redo->add_do_method(player, "add_animation", p_file, res);
@@ -768,7 +734,6 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
break;
}
case RESOURCE_SAVE: {
-
String current = animation->get_item_text(animation->get_selected());
if (current != "") {
Ref<Animation> anim = player->get_animation(current);
@@ -784,24 +749,20 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
}
void AnimationPlayerEditor::_scale_changed(const String &p_scale) {
-
player->set_speed_scale(p_scale.to_double());
}
void AnimationPlayerEditor::_update_animation() {
-
// the purpose of _update_animation is to reflect the current state
// of the animation player in the current editor..
updating = true;
if (player->is_playing()) {
-
play->set_pressed(true);
stop->set_pressed(false);
} else {
-
play->set_pressed(false);
stop->set_pressed(true);
}
@@ -810,7 +771,6 @@ void AnimationPlayerEditor::_update_animation() {
String current = player->get_assigned_animation();
for (int i = 0; i < animation->get_item_count(); i++) {
-
if (animation->get_item_text(i) == current) {
animation->select(i);
break;
@@ -821,11 +781,11 @@ void AnimationPlayerEditor::_update_animation() {
}
void AnimationPlayerEditor::_update_player() {
-
updating = true;
List<StringName> animlist;
- if (player)
+ if (player) {
player->get_animation_list(&animlist);
+ }
animation->clear();
@@ -860,14 +820,15 @@ void AnimationPlayerEditor::_update_player() {
int active_idx = -1;
for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) {
-
- if (player->get_autoplay() == E->get())
+ if (player->get_autoplay() == E->get()) {
animation->add_icon_item(autoplay_icon, E->get());
- else
+ } else {
animation->add_item(E->get());
+ }
- if (player->get_assigned_animation() == E->get())
+ if (player->get_assigned_animation() == E->get()) {
active_idx = animation->get_item_count() - 1;
+ }
}
updating = false;
@@ -877,7 +838,6 @@ void AnimationPlayerEditor::_update_player() {
_animation_selected(active_idx);
} else if (animation->get_item_count() > 0) {
-
animation->select(0);
autoplay->set_pressed(animation->get_item_text(0) == player->get_autoplay());
_animation_selected(0);
@@ -899,38 +859,41 @@ void AnimationPlayerEditor::_update_player() {
}
void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
-
- if (player && pin->is_pressed())
+ if (player && pin->is_pressed()) {
return; // Ignore, pinned.
+ }
player = p_player;
if (player) {
_update_player();
if (onion.enabled) {
- if (animation->get_item_count() > 0)
+ if (animation->get_item_count() > 0) {
_start_onion_skinning();
- else
+ } else {
_stop_onion_skinning();
+ }
}
track_editor->show_select_node_warning(false);
} else {
- if (onion.enabled)
+ if (onion.enabled) {
_stop_onion_skinning();
+ }
track_editor->show_select_node_warning(true);
}
}
void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
-
- if (!onion.can_overlay)
+ if (!onion.can_overlay) {
return;
+ }
// Can happen on viewport resize, at least.
- if (!_are_onion_layers_valid())
+ if (!_are_onion_layers_valid()) {
return;
+ }
RID ci = p_overlay->get_canvas_item();
Rect2 src_rect = p_overlay->get_global_rect();
@@ -973,22 +936,21 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o
}
void AnimationPlayerEditor::_animation_duplicate() {
-
- if (!animation->get_item_count())
+ if (!animation->get_item_count()) {
return;
+ }
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
- if (!anim.is_valid())
+ if (!anim.is_valid()) {
return;
+ }
Ref<Animation> new_anim = memnew(Animation);
List<PropertyInfo> plist;
anim->get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
if (E->get().usage & PROPERTY_USAGE_STORAGE) {
-
new_anim->set(E->get().name, anim->get(E->get().name));
}
}
@@ -1009,9 +971,7 @@ void AnimationPlayerEditor::_animation_duplicate() {
undo_redo->commit_action();
for (int i = 0; i < animation->get_item_count(); i++) {
-
if (animation->get_item_text(i) == new_name) {
-
animation->select(i);
_animation_selected(i);
return;
@@ -1020,7 +980,6 @@ void AnimationPlayerEditor::_animation_duplicate() {
}
void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) {
-
if (updating || !player || player->is_playing()) {
return;
};
@@ -1056,41 +1015,42 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) {
};
void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
-
if (player == p_pl && is_visible_in_tree()) {
-
_update_player();
- if (blend_editor.dialog->is_visible())
+ if (blend_editor.dialog->is_visible()) {
_animation_blend(); // Update.
+ }
}
}
void AnimationPlayerEditor::_list_changed() {
-
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
_update_player();
+ }
}
void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) {
-
frame->set_max(p_len);
}
void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag) {
-
timeline_position = p_pos;
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
- if (!player)
+ if (!player) {
return;
+ }
- if (player->is_playing())
+ if (player->is_playing()) {
return;
+ }
- if (!player->has_animation(player->get_assigned_animation()))
+ if (!player->has_animation(player->get_assigned_animation())) {
return;
+ }
updating = true;
frame->set_value(Math::stepify(p_pos, _get_editor_step()));
@@ -1101,7 +1061,6 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag)
}
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
-
String current;
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
current = animation->get_item_text(animation->get_selected());
@@ -1113,47 +1072,37 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
}
switch (p_option) {
-
case TOOL_NEW_ANIM: {
-
_animation_new();
} break;
case TOOL_LOAD_ANIM: {
-
_animation_load();
} break;
case TOOL_SAVE_ANIM: {
-
if (anim.is_valid()) {
_animation_save(anim);
}
} break;
case TOOL_SAVE_AS_ANIM: {
-
if (anim.is_valid()) {
_animation_save_as(anim);
}
} break;
case TOOL_DUPLICATE_ANIM: {
-
_animation_duplicate();
[[fallthrough]]; // Allow immediate rename after animation is duplicated
}
case TOOL_RENAME_ANIM: {
-
_animation_rename();
} break;
case TOOL_EDIT_TRANSITIONS: {
-
_animation_blend();
} break;
case TOOL_REMOVE_ANIM: {
-
_animation_remove();
} break;
case TOOL_COPY_ANIM: {
-
if (!animation->get_item_count()) {
error_dialog->set_text(TTR("No animation to copy!"));
error_dialog->popup_centered();
@@ -1165,7 +1114,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
EditorSettings::get_singleton()->set_resource_clipboard(anim2);
} break;
case TOOL_PASTE_ANIM: {
-
Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
if (!anim2.is_valid()) {
error_dialog->set_text(TTR("No animation resource on clipboard!"));
@@ -1181,7 +1129,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
int idx = 1;
String base = name;
while (player->has_animation(name)) {
-
idx++;
name = base + " " + itos(idx);
}
@@ -1196,7 +1143,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
_select_anim_by_name(name);
} break;
case TOOL_EDIT_RESOURCE: {
-
if (!animation->get_item_count()) {
error_dialog->set_text(TTR("No animation to edit!"));
error_dialog->popup_centered();
@@ -1211,30 +1157,26 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
}
void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
-
PopupMenu *menu = onion_skinning->get_popup();
int idx = menu->get_item_index(p_option);
switch (p_option) {
-
case ONION_SKINNING_ENABLE: {
-
onion.enabled = !onion.enabled;
- if (onion.enabled)
+ if (onion.enabled) {
_start_onion_skinning();
- else
+ } else {
_stop_onion_skinning();
+ }
} break;
case ONION_SKINNING_PAST: {
-
// Ensure at least one of past/future is checked.
onion.past = onion.future ? !onion.past : true;
menu->set_item_checked(idx, onion.past);
} break;
case ONION_SKINNING_FUTURE: {
-
// Ensure at least one of past/future is checked.
onion.future = onion.past ? !onion.future : true;
menu->set_item_checked(idx, onion.future);
@@ -1242,7 +1184,6 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
case ONION_SKINNING_1_STEP: // Fall-through.
case ONION_SKINNING_2_STEPS:
case ONION_SKINNING_3_STEPS: {
-
onion.steps = (p_option - ONION_SKINNING_1_STEP) + 1;
int one_frame_idx = menu->get_item_index(ONION_SKINNING_1_STEP);
for (int i = 0; i <= ONION_SKINNING_LAST_STEPS_OPTION - ONION_SKINNING_1_STEP; i++) {
@@ -1250,17 +1191,14 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
}
} break;
case ONION_SKINNING_DIFFERENCES_ONLY: {
-
onion.differences_only = !onion.differences_only;
menu->set_item_checked(idx, onion.differences_only);
} break;
case ONION_SKINNING_FORCE_WHITE_MODULATE: {
-
onion.force_white_modulate = !onion.force_white_modulate;
menu->set_item_checked(idx, onion.force_white_modulate);
} break;
case ONION_SKINNING_INCLUDE_GIZMOS: {
-
onion.include_gizmos = !onion.include_gizmos;
menu->set_item_checked(idx, onion.include_gizmos);
} break;
@@ -1268,40 +1206,37 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
}
void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventKey> k = p_ev;
if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) {
-
switch (k->get_keycode()) {
-
case KEY_A: {
- if (!k->get_shift())
+ if (!k->get_shift()) {
_play_bw_from_pressed();
- else
+ } else {
_play_bw_pressed();
+ }
} break;
case KEY_S: {
_stop_pressed();
} break;
case KEY_D: {
- if (!k->get_shift())
+ if (!k->get_shift()) {
_play_from_pressed();
- else
+ } else {
_play_pressed();
+ }
} break;
}
}
}
void AnimationPlayerEditor::_editor_visibility_changed() {
-
if (is_visible() && animation->get_item_count() > 0) {
_start_onion_skinning();
}
}
bool AnimationPlayerEditor::_are_onion_layers_valid() {
-
ERR_FAIL_COND_V(!onion.past && !onion.future, false);
Point2 capture_size = get_tree()->get_root()->get_size();
@@ -1309,7 +1244,6 @@ bool AnimationPlayerEditor::_are_onion_layers_valid() {
}
void AnimationPlayerEditor::_allocate_onion_layers() {
-
_free_onion_layers();
int captures = onion.get_needed_capture_count();
@@ -1338,7 +1272,6 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
}
void AnimationPlayerEditor::_free_onion_layers() {
-
for (int i = 0; i < onion.captures.size(); i++) {
if (onion.captures[i].is_valid()) {
RS::get_singleton()->free(onion.captures[i]);
@@ -1349,11 +1282,11 @@ void AnimationPlayerEditor::_free_onion_layers() {
}
void AnimationPlayerEditor::_prepare_onion_layers_1() {
-
// This would be called per viewport and we want to act once only.
int64_t frame = get_tree()->get_frame();
- if (frame == onion.last_frame)
+ if (frame == onion.last_frame) {
return;
+ }
if (!onion.enabled || !is_processing() || !is_visible() || !get_player()) {
_stop_onion_skinning();
@@ -1366,8 +1299,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() {
onion.can_overlay = false;
plugin->update_overlays();
- if (player->is_playing())
+ if (player->is_playing()) {
return;
+ }
// And go to next step afterwards.
call_deferred("_prepare_onion_layers_2");
@@ -1378,13 +1312,14 @@ void AnimationPlayerEditor::_prepare_onion_layers_1_deferred() {
}
void AnimationPlayerEditor::_prepare_onion_layers_2() {
-
Ref<Animation> anim = player->get_animation(player->get_assigned_animation());
- if (!anim.is_valid())
+ if (!anim.is_valid()) {
return;
+ }
- if (!_are_onion_layers_valid())
+ if (!_are_onion_layers_valid()) {
_allocate_onion_layers();
+ }
// Hide superfluous elements that would make the overlay unnecessary cluttered.
Dictionary canvas_edit_state;
@@ -1455,11 +1390,11 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
int cidx = 0;
onion.capture.material->set_shader_param("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color")));
for (int step_off = step_off_a; step_off <= step_off_b; step_off++) {
-
if (step_off == 0) {
// Skip present step and switch to the color of future.
- if (!onion.force_white_modulate)
+ if (!onion.force_white_modulate) {
onion.capture.material->set_shader_param("dir_color", EDITOR_GET("editors/animation/onion_layers_future_color"));
+ }
continue;
}
@@ -1507,7 +1442,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
}
void AnimationPlayerEditor::_start_onion_skinning() {
-
// FIXME: Using "idle_frame" makes onion layers update one frame behind the current.
if (!get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) {
get_tree()->connect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred));
@@ -1515,9 +1449,7 @@ void AnimationPlayerEditor::_start_onion_skinning() {
}
void AnimationPlayerEditor::_stop_onion_skinning() {
-
if (get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) {
-
get_tree()->disconnect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred));
_free_onion_layers();
@@ -1529,12 +1461,10 @@ void AnimationPlayerEditor::_stop_onion_skinning() {
}
void AnimationPlayerEditor::_pin_pressed() {
-
EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->update_tree();
}
void AnimationPlayerEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_animation_new"), &AnimationPlayerEditor::_animation_new);
ClassDB::bind_method(D_METHOD("_animation_rename"), &AnimationPlayerEditor::_animation_rename);
ClassDB::bind_method(D_METHOD("_animation_load"), &AnimationPlayerEditor::_animation_load);
@@ -1556,7 +1486,6 @@ void AnimationPlayerEditor::_bind_methods() {
AnimationPlayerEditor *AnimationPlayerEditor::singleton = nullptr;
AnimationPlayer *AnimationPlayerEditor::get_player() const {
-
return player;
}
@@ -1800,39 +1729,33 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
}
AnimationPlayerEditor::~AnimationPlayerEditor() {
-
_free_onion_layers();
RS::get_singleton()->free(onion.capture.canvas);
RS::get_singleton()->free(onion.capture.canvas_item);
}
void AnimationPlayerEditorPlugin::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
set_force_draw_over_forwarding_enabled();
} break;
}
}
void AnimationPlayerEditorPlugin::edit(Object *p_object) {
-
anim_editor->set_undo_redo(&get_undo_redo());
- if (!p_object)
+ if (!p_object) {
return;
+ }
anim_editor->edit(Object::cast_to<AnimationPlayer>(p_object));
}
bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("AnimationPlayer");
}
void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
editor->make_bottom_panel_item_visible(anim_editor);
anim_editor->set_process(true);
anim_editor->ensure_visibility();
@@ -1840,7 +1763,6 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
}
AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
anim_editor = memnew(AnimationPlayerEditor(editor, this));
anim_editor->set_undo_redo(EditorNode::get_undo_redo());
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 1abefad635..18f2d3b25e 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -43,7 +43,6 @@ class AnimationTrackEditor;
class AnimationPlayerEditorPlugin;
class AnimationPlayerEditor : public VBoxContainer {
-
GDCLASS(AnimationPlayerEditor, VBoxContainer);
EditorNode *editor;
@@ -114,7 +113,6 @@ class AnimationPlayerEditor : public VBoxContainer {
int current_option;
struct BlendEditor {
-
AcceptDialog *dialog;
Tree *tree;
OptionButton *next;
@@ -244,7 +242,6 @@ public:
};
class AnimationPlayerEditorPlugin : public EditorPlugin {
-
GDCLASS(AnimationPlayerEditorPlugin, EditorPlugin);
AnimationPlayerEditor *anim_editor;
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 509bf59716..a435b1c482 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -32,7 +32,7 @@
#include "core/input/input.h"
#include "core/io/resource_loader.h"
-#include "core/math/delaunay_2d.h"
+#include "core/math/geometry_2d.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_scale.h"
@@ -43,17 +43,14 @@
#include "scene/main/window.h"
bool AnimationNodeStateMachineEditor::can_edit(const Ref<AnimationNode> &p_node) {
-
Ref<AnimationNodeStateMachine> ansm = p_node;
return ansm.is_valid();
}
void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) {
-
state_machine = p_node;
if (state_machine.is_valid()) {
-
selected_transition_from = StringName();
selected_transition_to = StringName();
selected_node = StringName();
@@ -63,10 +60,10 @@ void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) {
}
void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
- if (playback.is_null())
+ if (playback.is_null()) {
return;
+ }
Ref<InputEventKey> k = p_event;
if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) {
@@ -104,10 +101,10 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
-
String name = String(E->get()).replace_first("AnimationNode", "");
- if (name == "Animation")
+ if (name == "Animation") {
continue; // nope
+ }
int idx = menu->get_item_count();
menu->add_item(vformat("Add %s", name), idx);
menu->set_item_metadata(idx, E->get());
@@ -128,7 +125,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
// select node or push a field inside
if (mb.is_valid() && !mb->get_shift() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
selected_transition_from = StringName();
selected_transition_to = StringName();
selected_node = StringName();
@@ -191,12 +187,11 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
int closest = -1;
float closest_d = 1e20;
for (int i = 0; i < transition_lines.size(); i++) {
-
Vector2 s[2] = {
transition_lines[i].from,
transition_lines[i].to
};
- Vector2 cpoint = Geometry::get_closest_point_to_segment_2d(mb->get_position(), s);
+ Vector2 cpoint = Geometry2D::get_closest_point_to_segment(mb->get_position(), s);
float d = cpoint.distance_to(mb->get_position());
if (d > transition_lines[i].width) {
continue;
@@ -222,9 +217,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//end moving node
if (mb.is_valid() && dragging_selected_attempt && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
-
if (dragging_selected) {
-
Ref<AnimationNode> an = state_machine->get_node(selected_node);
updating = true;
undo_redo->create_action(TTR("Move Node"));
@@ -245,7 +238,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//connect nodes
if (mb.is_valid() && ((tool_select->is_pressed() && mb->get_shift()) || tool_connect->is_pressed()) && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
-
for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
if (node_rects[i].node.has_point(mb->get_position())) { //select node since nothing else was selected
connecting = true;
@@ -259,14 +251,11 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//end connecting nodes
if (mb.is_valid() && connecting && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
-
if (connecting_to_node != StringName()) {
-
if (state_machine->has_transition(connecting_from, connecting_to_node)) {
EditorNode::get_singleton()->show_warning(TTR("Transition exists!"));
} else {
-
Ref<AnimationNodeStateMachineTransition> tr;
tr.instance();
tr->set_switch_mode(AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()));
@@ -296,14 +285,12 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//pan window
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) {
-
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
}
//move mouse while connecting
if (mm.is_valid() && connecting) {
-
connecting_to = mm->get_position();
connecting_to_node = StringName();
state_machine_draw->update();
@@ -318,7 +305,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//move mouse while moving a node
if (mm.is_valid() && dragging_selected_attempt) {
-
dragging_selected = true;
drag_ofs = mm->get_position() - drag_from;
snap_x = StringName();
@@ -333,8 +319,9 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
float best_d_y = 1e20;
for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) {
- if (E->get() == selected_node)
+ if (E->get() == selected_node) {
continue;
+ }
Vector2 npos = state_machine->get_node_position(E->get());
float d_x = ABS(npos.x - cpos.x);
@@ -358,14 +345,12 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//put ibeam (text cursor) over names to make it clearer that they are editable
if (mm.is_valid()) {
-
state_machine_draw->grab_focus();
bool over_text_now = false;
String new_over_node = StringName();
int new_over_node_what = -1;
if (tool_select->is_pressed()) {
-
for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
if (node_rects[i].name.has_point(mm->get_position())) {
@@ -392,7 +377,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
if (over_text != over_text_now) {
-
if (over_text_now) {
state_machine_draw->set_default_cursor_shape(CURSOR_IBEAM);
} else {
@@ -405,7 +389,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
-
file_loaded = ResourceLoader::load(p_file);
if (file_loaded.is_valid()) {
_add_menu_type(MENU_LOAD_FILE_CONFIRM);
@@ -413,12 +396,10 @@ void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
}
void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
-
String base_name;
Ref<AnimationRootNode> node;
if (p_index == MENU_LOAD_FILE) {
-
open_file->clear_filters();
List<String> filters;
ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters);
@@ -431,7 +412,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
node = file_loaded;
file_loaded.unref();
} else if (p_index == MENU_PASTE) {
-
node = EditorSettings::get_singleton()->get_resource_clipboard();
} else {
@@ -452,7 +432,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
}
if (base_name == String()) {
-
base_name = node->get_class().replace_first("AnimationNode", "");
}
@@ -476,7 +455,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
}
void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
-
Ref<AnimationNodeAnimation> anim;
anim.instance();
@@ -503,7 +481,6 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
}
void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, bool p_auto_advance) {
-
Color linecolor = get_theme_color("font_color", "Label");
Color icon_color(1, 1, 1);
Color accent = get_theme_color("accent_color", "Editor");
@@ -546,9 +523,9 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
}
void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) {
-
- if (r_to == r_from)
+ if (r_to == r_from) {
return;
+ }
//this could be optimized...
Vector2 n = (r_to - r_from).normalized();
@@ -558,9 +535,9 @@ void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Ve
}
void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) {
-
- if (r_to == r_from)
+ if (r_to == r_from) {
return;
+ }
//this could be optimized...
Vector2 n = (r_to - r_from).normalized();
@@ -570,7 +547,6 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Ve
}
void AnimationNodeStateMachineEditor::_state_machine_draw() {
-
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
Ref<StyleBox> style = get_theme_stylebox("state_machine_frame", "GraphNode");
@@ -611,7 +587,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//snap lines
if (dragging_selected) {
-
Vector2 from = (state_machine->get_node_position(selected_node) * EDSCALE) + drag_ofs - state_machine->get_graph_offset() * EDSCALE;
if (snap_x != StringName()) {
Vector2 to = (state_machine->get_node_position(snap_x) * EDSCALE) - state_machine->get_graph_offset() * EDSCALE;
@@ -625,7 +600,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//pre pass nodes so we know the rectangles
for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) {
-
Ref<AnimationNode> anode = state_machine->get_node(E->get());
String name = E->get();
bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr());
@@ -691,7 +665,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//draw transition lines
for (int i = 0; i < state_machine->get_transition_count(); i++) {
-
TransitionLine tl;
tl.from_node = state_machine->get_transition_from(i);
Vector2 ofs_from = (dragging_selected && tl.from_node == selected_node) ? drag_ofs : Vector2();
@@ -733,7 +706,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
if (travel_path.size()) {
-
if (current == tl.from_node && travel_path[0] == tl.to_node) {
travel = true;
} else {
@@ -759,7 +731,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//draw actual nodes
for (int i = 0; i < node_rects.size(); i++) {
-
String name = node_rects[i].node_name;
Ref<AnimationNode> anode = state_machine->get_node(name);
bool needs_editor = AnimationTreeEditor::get_singleton()->can_edit(anode);
@@ -786,7 +757,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
if (state_machine->get_end_node() == name) {
-
int endofs = nr.node.size.x - font->get_string_size(TTR("End")).x;
state_machine_draw->draw_string(font, offset + Vector2(endofs, -font->get_height() - 3 * EDSCALE + font->get_ascent()), TTR("End"), font_color);
}
@@ -844,11 +814,11 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
-
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
- if (!playback.is_valid() || !playback->is_playing())
+ if (!playback.is_valid() || !playback->is_playing()) {
return;
+ }
int idx = -1;
for (int i = 0; i < node_rects.size(); i++) {
@@ -858,8 +828,9 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
}
}
- if (idx == -1)
+ if (idx == -1) {
return;
+ }
const NodeRect &nr = node_rects[idx];
@@ -891,9 +862,9 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
}
void AnimationNodeStateMachineEditor::_update_graph() {
-
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
@@ -903,7 +874,6 @@ void AnimationNodeStateMachineEditor::_update_graph() {
}
void AnimationNodeStateMachineEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
@@ -928,7 +898,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
-
String error;
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
@@ -1017,7 +986,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
{
-
if (last_travel_path.size() != tp.size()) {
same_travel_path = false;
} else {
@@ -1032,7 +1000,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
//update if travel state changed
if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) {
-
state_machine_draw->update();
last_travel_path = tp;
last_current_node = current_node;
@@ -1043,7 +1010,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
{
if (current_node != StringName() && state_machine->has_node(current_node)) {
-
String next = current_node;
Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next);
Ref<AnimationNodeStateMachinePlayback> current_node_playback;
@@ -1063,7 +1029,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
if (last_play_pos != play_pos) {
-
last_play_pos = play_pos;
state_machine_play_pos->update();
}
@@ -1076,17 +1041,14 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) {
-
AnimationTreeEditor::get_singleton()->enter_editor(p_name);
}
void AnimationNodeStateMachineEditor::_removed_from_graph() {
-
EditorNode::get_singleton()->edit_item(nullptr);
}
void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
-
const String &new_name = p_text;
ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1);
@@ -1117,24 +1079,23 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
}
void AnimationNodeStateMachineEditor::_name_edited_focus_out() {
-
- if (updating)
+ if (updating) {
return;
+ }
_name_edited(name_edit->get_text());
}
void AnimationNodeStateMachineEditor::_scroll_changed(double) {
-
- if (updating)
+ if (updating) {
return;
+ }
state_machine->set_graph_offset(Vector2(h_scroll->get_value(), v_scroll->get_value()));
state_machine_draw->update();
}
void AnimationNodeStateMachineEditor::_erase_selected() {
-
if (selected_node != StringName() && state_machine->has_node(selected_node)) {
updating = true;
undo_redo->create_action(TTR("Node Removed"));
@@ -1158,7 +1119,6 @@ void AnimationNodeStateMachineEditor::_erase_selected() {
}
if (selected_transition_to != StringName() && selected_transition_from != StringName() && state_machine->has_transition(selected_transition_from, selected_transition_to)) {
-
Ref<AnimationNodeStateMachineTransition> tr = state_machine->get_transition(state_machine->find_transition(selected_transition_from, selected_transition_to));
updating = true;
undo_redo->create_action(TTR("Transition Removed"));
@@ -1176,9 +1136,7 @@ void AnimationNodeStateMachineEditor::_erase_selected() {
}
void AnimationNodeStateMachineEditor::_autoplay_selected() {
-
if (selected_node != StringName() && state_machine->has_node(selected_node)) {
-
StringName new_start_node;
if (state_machine->get_start_node() == selected_node) { //toggle it
new_start_node = StringName();
@@ -1199,9 +1157,7 @@ void AnimationNodeStateMachineEditor::_autoplay_selected() {
}
void AnimationNodeStateMachineEditor::_end_selected() {
-
if (selected_node != StringName() && state_machine->has_node(selected_node)) {
-
StringName new_end_node;
if (state_machine->get_end_node() == selected_node) { //toggle it
new_end_node = StringName();
@@ -1220,8 +1176,8 @@ void AnimationNodeStateMachineEditor::_end_selected() {
state_machine_draw->update();
}
}
-void AnimationNodeStateMachineEditor::_update_mode() {
+void AnimationNodeStateMachineEditor::_update_mode() {
if (tool_select->is_pressed()) {
tool_erase_hb->show();
tool_erase->set_disabled(selected_node == StringName() && selected_transition_from == StringName() && selected_transition_to == StringName());
@@ -1233,7 +1189,6 @@ void AnimationNodeStateMachineEditor::_update_mode() {
}
void AnimationNodeStateMachineEditor::_bind_methods() {
-
ClassDB::bind_method("_update_graph", &AnimationNodeStateMachineEditor::_update_graph);
ClassDB::bind_method("_removed_from_graph", &AnimationNodeStateMachineEditor::_removed_from_graph);
@@ -1244,7 +1199,6 @@ void AnimationNodeStateMachineEditor::_bind_methods() {
AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = nullptr;
AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
-
singleton = this;
updating = false;
diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h
index 5c4fc87df5..022c32ef48 100644
--- a/editor/plugins/animation_state_machine_editor.h
+++ b/editor/plugins/animation_state_machine_editor.h
@@ -42,7 +42,6 @@
#include "scene/gui/tree.h"
class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
-
GDCLASS(AnimationNodeStateMachineEditor, AnimationTreeNodeEditorPlugin);
Ref<AnimationNodeStateMachine> state_machine;
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 9c48444e3e..ec3e25f999 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -48,9 +48,9 @@
#include "scene/scene_string_names.h"
void AnimationTreeEditor::edit(AnimationTree *p_tree) {
-
- if (tree == p_tree)
+ if (tree == p_tree) {
return;
+ }
tree = p_tree;
@@ -64,7 +64,6 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
}
void AnimationTreeEditor::_path_button_pressed(int p_path) {
-
edited_path.clear();
for (int i = 0; i <= p_path; i++) {
edited_path.push_back(button_path[i]);
@@ -100,7 +99,6 @@ void AnimationTreeEditor::_update_path() {
}
void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
-
button_path.clear();
Ref<AnimationNode> node = tree->get_tree_root();
@@ -109,7 +107,6 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
current_root = node->get_instance_id();
for (int i = 0; i < p_path.size(); i++) {
-
Ref<AnimationNode> child = node->get_child_by_name(p_path[i]);
ERR_BREAK(child.is_null());
node = child;
@@ -140,7 +137,6 @@ Vector<String> AnimationTreeEditor::get_edited_path() const {
}
void AnimationTreeEditor::enter_editor(const String &p_path) {
-
Vector<String> path = edited_path;
path.push_back(p_path);
edit_path(path);
@@ -204,19 +200,20 @@ bool AnimationTreeEditor::can_edit(const Ref<AnimationNode> &p_node) const {
}
Vector<String> AnimationTreeEditor::get_animation_list() {
-
if (!singleton->is_visible()) {
return Vector<String>();
}
AnimationTree *tree = singleton->tree;
- if (!tree || !tree->has_node(tree->get_animation_player()))
+ if (!tree || !tree->has_node(tree->get_animation_player())) {
return Vector<String>();
+ }
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(tree->get_node(tree->get_animation_player()));
- if (!ap)
+ if (!ap) {
return Vector<String>();
+ }
List<StringName> anims;
ap->get_animation_list(&anims);
@@ -229,7 +226,6 @@ Vector<String> AnimationTreeEditor::get_animation_list() {
}
AnimationTreeEditor::AnimationTreeEditor() {
-
AnimationNodeAnimation::get_editable_animation_list = get_animation_list;
path_edit = memnew(ScrollContainer);
add_child(path_edit);
@@ -253,17 +249,14 @@ AnimationTreeEditor::AnimationTreeEditor() {
}
void AnimationTreeEditorPlugin::edit(Object *p_object) {
-
anim_tree_editor->edit(Object::cast_to<AnimationTree>(p_object));
}
bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("AnimationTree");
}
void AnimationTreeEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
//editor->hide_animation_player_editors();
//editor->animation_panel_make_visible(true);
@@ -271,16 +264,15 @@ void AnimationTreeEditorPlugin::make_visible(bool p_visible) {
editor->make_bottom_panel_item_visible(anim_tree_editor);
anim_tree_editor->set_process(true);
} else {
-
- if (anim_tree_editor->is_visible_in_tree())
+ if (anim_tree_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
button->hide();
anim_tree_editor->set_process(false);
}
}
AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
anim_tree_editor = memnew(AnimationTreeEditor);
anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h
index 0b93b0fd8e..25af81ea9b 100644
--- a/editor/plugins/animation_tree_editor_plugin.h
+++ b/editor/plugins/animation_tree_editor_plugin.h
@@ -49,7 +49,6 @@ public:
};
class AnimationTreeEditor : public VBoxContainer {
-
GDCLASS(AnimationTreeEditor, VBoxContainer);
ScrollContainer *path_edit;
@@ -95,7 +94,6 @@ public:
};
class AnimationTreeEditorPlugin : public EditorPlugin {
-
GDCLASS(AnimationTreeEditorPlugin, EditorPlugin);
AnimationTreeEditor *anim_tree_editor;
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 1928d49556..da170cd498 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -40,7 +40,6 @@
#include "editor/project_settings_editor.h"
void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) {
-
title->set_text(p_title);
asset_id = p_asset_id;
category->set_text(p_category);
@@ -51,7 +50,6 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co
}
void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) {
-
ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON);
ERR_FAIL_COND(p_index != 0);
@@ -59,9 +57,7 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur
}
void EditorAssetLibraryItem::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
icon->set_normal_texture(get_theme_icon("ProjectIconLoading", "EditorIcons"));
category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5));
@@ -70,21 +66,18 @@ void EditorAssetLibraryItem::_notification(int p_what) {
}
void EditorAssetLibraryItem::_asset_clicked() {
-
emit_signal("asset_selected", asset_id);
}
void EditorAssetLibraryItem::_category_clicked() {
-
emit_signal("category_selected", category_id);
}
-void EditorAssetLibraryItem::_author_clicked() {
+void EditorAssetLibraryItem::_author_clicked() {
emit_signal("author_selected", author_id);
}
void EditorAssetLibraryItem::_bind_methods() {
-
ClassDB::bind_method("set_image", &EditorAssetLibraryItem::set_image);
ADD_SIGNAL(MethodInfo("asset_selected"));
ADD_SIGNAL(MethodInfo("category_selected"));
@@ -92,7 +85,6 @@ void EditorAssetLibraryItem::_bind_methods() {
}
EditorAssetLibraryItem::EditorAssetLibraryItem() {
-
Ref<StyleBoxEmpty> border;
border.instance();
border->set_default_margin(MARGIN_LEFT, 5 * EDSCALE);
@@ -143,16 +135,12 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
//////////////////////////////////////////////////////////////////////////////
void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) {
-
switch (p_type) {
-
case EditorAssetLibrary::IMAGE_QUEUE_ICON: {
-
item->call("set_image", p_type, p_index, p_image);
icon = p_image;
} break;
case EditorAssetLibrary::IMAGE_QUEUE_THUMBNAIL: {
-
for (int i = 0; i < preview_images.size(); i++) {
if (preview_images[i].id == p_index) {
if (preview_images[i].is_video) {
@@ -181,7 +169,6 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
}
} break;
case EditorAssetLibrary::IMAGE_QUEUE_SCREENSHOT: {
-
for (int i = 0; i < preview_images.size(); i++) {
if (preview_images[i].id == p_index) {
preview_images.write[i].image = p_image;
@@ -231,7 +218,6 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) {
}
void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) {
-
asset_id = p_asset_id;
title = p_title;
download_url = p_download_url;
@@ -249,7 +235,6 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a
}
void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) {
-
Preview preview;
preview.id = p_id;
preview.video_link = p_url;
@@ -270,7 +255,6 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons
}
EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
-
HBoxContainer *hbox = memnew(HBoxContainer);
add_child(hbox);
VBoxContainer *desc_vbox = memnew(VBoxContainer);
@@ -314,14 +298,13 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
get_ok()->set_text(TTR("Download"));
get_cancel()->set_text(TTR("Close"));
}
+
///////////////////////////////////////////////////////////////////////////////////
void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
-
String error_text;
switch (p_status) {
-
case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH:
case HTTPRequest::RESULT_CONNECTION_ERROR:
case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED: {
@@ -388,29 +371,25 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
}
void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash) {
-
title->set_text(p_title);
icon->set_texture(p_preview);
asset_id = p_asset_id;
- if (!p_preview.is_valid())
+ if (!p_preview.is_valid()) {
icon->set_texture(get_theme_icon("FileBrokenBigThumb", "EditorIcons"));
+ }
host = p_download_url;
sha256 = p_sha256_hash;
_make_request();
}
void EditorAssetLibraryItemDownload::_notification(int p_what) {
-
switch (p_what) {
-
// FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used.
case NOTIFICATION_ENTER_TREE: {
-
add_theme_style_override("panel", get_theme_stylebox("panel", "TabContainer"));
dismiss->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
} break;
case NOTIFICATION_PROCESS: {
-
// Make the progress bar visible again when retrying the download.
progress->set_modulate(Color(1, 1, 1, 1));
@@ -438,7 +417,6 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
if (cstatus != prev_status) {
switch (cstatus) {
-
case HTTPClient::STATUS_RESOLVING: {
status->set_text(TTR("Resolving..."));
progress->set_max(1);
@@ -462,15 +440,14 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
} break;
}
}
-void EditorAssetLibraryItemDownload::_close() {
+void EditorAssetLibraryItemDownload::_close() {
// Clean up downloaded file.
DirAccess::remove_file_or_error(download->get_download_file());
queue_delete();
}
void EditorAssetLibraryItemDownload::_install() {
-
String file = download->get_download_file();
if (external_install) {
@@ -494,12 +471,10 @@ void EditorAssetLibraryItemDownload::_make_request() {
}
void EditorAssetLibraryItemDownload::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
-
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
icon = memnew(TextureRect);
@@ -566,11 +541,8 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
////////////////////////////////////////////////////////////////////////////////
void EditorAssetLibrary::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
-
error_tr->set_texture(get_theme_icon("Error", "EditorIcons"));
filter->set_right_icon(get_theme_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
@@ -578,13 +550,11 @@ void EditorAssetLibrary::_notification(int p_what) {
error_label->raise();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
if (is_visible() && initial_loading) {
_repository_changed(0); // Update when shown for the first time.
}
} break;
case NOTIFICATION_PROCESS: {
-
HTTPClient::Status s = request->get_http_client_status();
const bool loading = s != HTTPClient::STATUS_DISCONNECTED;
@@ -601,7 +571,6 @@ void EditorAssetLibrary::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
-
library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
downloads_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
error_tr->set_texture(get_theme_icon("Error", "EditorIcons"));
@@ -612,13 +581,10 @@ void EditorAssetLibrary::_notification(int p_what) {
}
void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) {
-
const Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed()) {
-
if (key->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) {
-
filter->grab_focus();
filter->select_all();
accept_event();
@@ -627,16 +593,14 @@ void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void EditorAssetLibrary::_install_asset() {
-
ERR_FAIL_COND(!description);
for (int i = 0; i < downloads_hb->get_child_count(); i++) {
-
EditorAssetLibraryItemDownload *d = Object::cast_to<EditorAssetLibraryItemDownload>(downloads_hb->get_child(i));
if (d && d->get_asset_id() == description->get_asset_id()) {
-
- if (EditorNode::get_singleton() != nullptr)
+ if (EditorNode::get_singleton() != nullptr) {
EditorNode::get_singleton()->show_warning(TTR("Download for this asset is already in progress!"));
+ }
return;
}
}
@@ -676,16 +640,14 @@ const char *EditorAssetLibrary::support_key[SUPPORT_MAX] = {
};
void EditorAssetLibrary::_select_author(int p_id) {
-
// Open author window.
}
void EditorAssetLibrary::_select_category(int p_id) {
-
for (int i = 0; i < categories->get_item_count(); i++) {
-
- if (i == 0)
+ if (i == 0) {
continue;
+ }
int id = categories->get_item_metadata(i);
if (id == p_id) {
categories->select(i);
@@ -694,8 +656,8 @@ void EditorAssetLibrary::_select_category(int p_id) {
}
}
}
-void EditorAssetLibrary::_select_asset(int p_id) {
+void EditorAssetLibrary::_select_asset(int p_id) {
_api_request("asset/" + itos(p_id), REQUESTING_ASSET);
}
@@ -780,11 +742,9 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB
}
void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data, int p_queue_id) {
-
ERR_FAIL_COND(!image_queue.has(p_queue_id));
if (p_status == HTTPRequest::RESULT_SUCCESS && p_code < HTTPClient::RESPONSE_BAD_REQUEST) {
-
if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) {
for (int i = 0; i < headers.size(); i++) {
if (headers[i].findn("ETag:") == 0) { // Save etag
@@ -830,14 +790,12 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
}
void EditorAssetLibrary::_update_image_queue() {
-
const int max_images = 6;
int current_images = 0;
List<int> to_delete;
for (Map<int, ImageQueue>::Element *E = image_queue.front(); E; E = E->next()) {
if (!E->get().active && current_images < max_images) {
-
String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + E->get().image_url.md5_text());
Vector<String> headers;
@@ -870,7 +828,6 @@ void EditorAssetLibrary::_update_image_queue() {
}
void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, ImageType p_type, int p_image_index) {
-
ImageQueue iq;
iq.image_url = p_image_url;
iq.image_index = p_image_index;
@@ -911,7 +868,6 @@ void EditorAssetLibrary::_rerun_search(int p_ignore) {
}
void EditorAssetLibrary::_search(int p_page) {
-
String args;
if (templates_only) {
@@ -935,7 +891,6 @@ void EditorAssetLibrary::_search(int p_page) {
}
if (categories->get_selected() > 0) {
-
args += "&category=" + itos(categories->get_item_metadata(categories->get_selected()));
}
@@ -956,24 +911,25 @@ void EditorAssetLibrary::_search(int p_page) {
}
void EditorAssetLibrary::_search_text_entered(const String &p_text) {
-
_search();
}
HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items) {
-
HBoxContainer *hbc = memnew(HBoxContainer);
- if (p_page_count < 2)
+ if (p_page_count < 2) {
return hbc;
+ }
//do the mario
int from = p_page - 5;
- if (from < 0)
+ if (from < 0) {
from = 0;
+ }
int to = from + 10;
- if (to > p_page_count)
+ if (to > p_page_count) {
to = p_page_count;
+ }
hbc->add_spacer();
hbc->add_theme_constant_override("separation", 5 * EDSCALE);
@@ -1000,9 +956,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
hbc->add_child(memnew(VSeparator));
for (int i = from; i < to; i++) {
-
if (i == p_page) {
-
Button *current = memnew(Button);
current->set_text(itos(i + 1));
current->set_disabled(true);
@@ -1010,7 +964,6 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
hbc->add_child(current);
} else {
-
Button *current = memnew(Button);
current->set_text(itos(i + 1));
current->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(i));
@@ -1046,7 +999,6 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
}
void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_request_type, const String &p_arguments) {
-
if (requesting != REQUESTING_NONE) {
request->cancel_request();
}
@@ -1058,7 +1010,6 @@ void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_req
}
void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
-
String str;
{
@@ -1070,7 +1021,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
bool error_abort = true;
switch (p_status) {
-
case HTTPRequest::RESULT_CANT_RESOLVE: {
error_label->set_text(TTR("Can't resolve hostname:") + " " + host);
} break;
@@ -1097,7 +1047,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
if (p_code != 200) {
error_label->set_text(TTR("Request failed, return code:") + " " + itos(p_code));
} else {
-
error_abort = false;
}
} break;
@@ -1122,7 +1071,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
switch (requested) {
case REQUESTING_CONFIG: {
-
categories->clear();
categories->add_item(TTR("All"));
categories->set_item_metadata(0, 0);
@@ -1130,8 +1078,9 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
Array clist = d["categories"];
for (int i = 0; i < clist.size(); i++) {
Dictionary cat = clist[i];
- if (!cat.has("name") || !cat.has("id"))
+ if (!cat.has("name") || !cat.has("id")) {
continue;
+ }
String name = cat["name"];
int id = cat["id"];
categories->add_item(name);
@@ -1143,7 +1092,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
_search();
} break;
case REQUESTING_SEARCH: {
-
initial_loading = false;
// The loading text only needs to be displayed before the first page is loaded.
@@ -1214,7 +1162,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
}
for (int i = 0; i < result.size(); i++) {
-
Dictionary r = result[i];
ERR_CONTINUE(!r.has("title"));
@@ -1273,7 +1220,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
Array previews = d["previews"];
for (int i = 0; i < previews.size(); i++) {
-
Dictionary p = previews[i];
ERR_CONTINUE(!p.has("type"));
@@ -1303,7 +1249,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
}
void EditorAssetLibrary::_asset_file_selected(const String &p_file) {
-
if (asset_installer) {
memdelete(asset_installer);
asset_installer = nullptr;
@@ -1315,18 +1260,15 @@ void EditorAssetLibrary::_asset_file_selected(const String &p_file) {
}
void EditorAssetLibrary::_asset_open() {
-
asset_open->popup_centered_ratio();
}
void EditorAssetLibrary::_manage_plugins() {
-
ProjectSettingsEditor::get_singleton()->popup_project_settings();
ProjectSettingsEditor::get_singleton()->set_plugins_page();
}
void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) {
-
emit_signal("install_asset", p_zip_path, p_title);
}
@@ -1335,14 +1277,12 @@ void EditorAssetLibrary::disable_community_support() {
}
void EditorAssetLibrary::_bind_methods() {
-
ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input);
ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
-
requesting = REQUESTING_NONE;
templates_only = p_templates_only;
initial_loading = true;
@@ -1364,8 +1304,9 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), make_binds(0));
search_hb->add_child(search);
- if (!p_templates_only)
+ if (!p_templates_only) {
search_hb->add_child(memnew(VSeparator));
+ }
Button *open_asset = memnew(Button);
open_asset->set_text(TTR("Import..."));
@@ -1527,18 +1468,14 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
///////
void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
addon_library->show();
} else {
-
addon_library->hide();
}
}
AssetLibraryEditorPlugin::AssetLibraryEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
addon_library = memnew(EditorAssetLibrary);
addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index 536a855d03..d5d381dee3 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -50,7 +50,6 @@
#include "scene/main/http_request.h"
class EditorAssetLibraryItem : public PanelContainer {
-
GDCLASS(EditorAssetLibraryItem, PanelContainer);
TextureButton *icon;
@@ -81,7 +80,6 @@ public:
};
class EditorAssetLibraryItemDescription : public ConfirmationDialog {
-
GDCLASS(EditorAssetLibraryItemDescription, ConfirmationDialog);
EditorAssetLibraryItem *item;
@@ -129,7 +127,6 @@ public:
};
class EditorAssetLibraryItemDownload : public PanelContainer {
-
GDCLASS(EditorAssetLibraryItemDownload, PanelContainer);
TextureRect *icon;
@@ -237,7 +234,6 @@ class EditorAssetLibrary : public PanelContainer {
};
struct ImageQueue {
-
bool active;
int queue_id;
ImageType image_type;
@@ -309,7 +305,6 @@ public:
};
class AssetLibraryEditorPlugin : public EditorPlugin {
-
GDCLASS(AssetLibraryEditorPlugin, EditorPlugin);
EditorAssetLibrary *addon_library;
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index 0459ac7618..3b7a9320f0 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -37,7 +37,6 @@
#include "editor/editor_settings.h"
void AudioStreamEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed));
}
@@ -75,7 +74,6 @@ void AudioStreamEditor::_draw_preview() {
lines.resize(size.width * 2);
for (int i = 0; i < size.width; i++) {
-
float ofs = i * preview_len / size.width;
float ofs_n = (i + 1) * preview_len / size.width;
float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5;
@@ -93,21 +91,19 @@ void AudioStreamEditor::_draw_preview() {
}
void AudioStreamEditor::_preview_changed(ObjectID p_which) {
-
if (stream.is_valid() && stream->get_instance_id() == p_which) {
_preview->update();
}
}
void AudioStreamEditor::_changed_callback(Object *p_changed, const char *p_prop) {
-
- if (!is_visible())
+ if (!is_visible()) {
return;
+ }
update();
}
void AudioStreamEditor::_play() {
-
if (_player->is_playing()) {
_player->stop();
_play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
@@ -120,7 +116,6 @@ void AudioStreamEditor::_play() {
}
void AudioStreamEditor::_stop() {
-
_player->stop();
_play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
_current = 0;
@@ -129,7 +124,6 @@ void AudioStreamEditor::_stop() {
}
void AudioStreamEditor::_on_finished() {
-
_play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons"));
if (_current == _player->get_stream()->get_length()) {
_current = 0;
@@ -138,7 +132,6 @@ void AudioStreamEditor::_on_finished() {
}
void AudioStreamEditor::_draw_indicator() {
-
if (!stream.is_valid()) {
return;
}
@@ -178,9 +171,9 @@ void AudioStreamEditor::_seek_to(real_t p_x) {
}
void AudioStreamEditor::edit(Ref<AudioStream> p_stream) {
-
- if (!stream.is_null())
+ if (!stream.is_null()) {
stream->remove_change_receptor(this);
+ }
stream = p_stream;
_player->set_stream(stream);
@@ -200,7 +193,6 @@ void AudioStreamEditor::_bind_methods() {
}
AudioStreamEditor::AudioStreamEditor() {
-
set_custom_minimum_size(Size2(1, 100) * EDSCALE);
_current = 0;
_dragging = false;
@@ -251,26 +243,23 @@ AudioStreamEditor::AudioStreamEditor() {
}
void AudioStreamEditorPlugin::edit(Object *p_object) {
-
AudioStream *s = Object::cast_to<AudioStream>(p_object);
- if (!s)
+ if (!s) {
return;
+ }
audio_editor->edit(Ref<AudioStream>(s));
}
bool AudioStreamEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("AudioStream");
}
void AudioStreamEditorPlugin::make_visible(bool p_visible) {
-
audio_editor->set_visible(p_visible);
}
AudioStreamEditorPlugin::AudioStreamEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
audio_editor = memnew(AudioStreamEditor);
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, audio_editor);
diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h
index 2191b541f6..dd7caaa15e 100644
--- a/editor/plugins/audio_stream_editor_plugin.h
+++ b/editor/plugins/audio_stream_editor_plugin.h
@@ -38,7 +38,6 @@
#include "scene/resources/texture.h"
class AudioStreamEditor : public ColorRect {
-
GDCLASS(AudioStreamEditor, ColorRect);
Ref<AudioStream> stream;
@@ -73,7 +72,6 @@ public:
};
class AudioStreamEditorPlugin : public EditorPlugin {
-
GDCLASS(AudioStreamEditorPlugin, EditorPlugin);
AudioStreamEditor *audio_editor;
diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp
index f754dd4725..8fbe1646f7 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.cpp
+++ b/editor/plugins/baked_lightmap_editor_plugin.cpp
@@ -31,7 +31,6 @@
#include "baked_lightmap_editor_plugin.h"
void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
-
if (lightmap) {
BakedLightmap::BakeError err;
if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == lightmap) {
@@ -71,30 +70,26 @@ void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) {
}
void BakedLightmapEditorPlugin::_bake() {
-
_bake_select_file("");
}
void BakedLightmapEditorPlugin::edit(Object *p_object) {
-
BakedLightmap *s = Object::cast_to<BakedLightmap>(p_object);
- if (!s)
+ if (!s) {
return;
+ }
lightmap = s;
}
bool BakedLightmapEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("BakedLightmap");
}
void BakedLightmapEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
bake->show();
} else {
-
bake->hide();
}
}
@@ -102,7 +97,6 @@ void BakedLightmapEditorPlugin::make_visible(bool p_visible) {
EditorProgress *BakedLightmapEditorPlugin::tmp_progress = nullptr;
bool BakedLightmapEditorPlugin::bake_func_step(float p_progress, const String &p_description, void *, bool p_refresh) {
-
if (!tmp_progress) {
tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), 1000, false));
ERR_FAIL_COND_V(tmp_progress == nullptr, false);
@@ -118,12 +112,10 @@ void BakedLightmapEditorPlugin::bake_func_end() {
}
void BakedLightmapEditorPlugin::_bind_methods() {
-
ClassDB::bind_method("_bake", &BakedLightmapEditorPlugin::_bake);
}
BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
bake = memnew(ToolButton);
bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons"));
diff --git a/editor/plugins/baked_lightmap_editor_plugin.h b/editor/plugins/baked_lightmap_editor_plugin.h
index 2dbc09fc1d..67fb368a86 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.h
+++ b/editor/plugins/baked_lightmap_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/resources/material.h"
class BakedLightmapEditorPlugin : public EditorPlugin {
-
GDCLASS(BakedLightmapEditorPlugin, EditorPlugin);
BakedLightmap *lightmap;
diff --git a/editor/plugins/camera_3d_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp
index 8bc1374269..48f9f208a5 100644
--- a/editor/plugins/camera_3d_editor_plugin.cpp
+++ b/editor/plugins/camera_3d_editor_plugin.cpp
@@ -33,7 +33,6 @@
#include "node_3d_editor_plugin.h"
void Camera3DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
Node3DEditor::get_singleton()->set_custom_camera(nullptr);
@@ -42,7 +41,6 @@ void Camera3DEditor::_node_removed(Node *p_node) {
}
void Camera3DEditor::_pressed() {
-
Node *sn = (node && preview->is_pressed()) ? node : nullptr;
Node3DEditor::get_singleton()->set_custom_camera(sn);
}
@@ -51,23 +49,21 @@ void Camera3DEditor::_bind_methods() {
}
void Camera3DEditor::edit(Node *p_camera) {
-
node = p_camera;
if (!node) {
preview->set_pressed(false);
Node3DEditor::get_singleton()->set_custom_camera(nullptr);
} else {
-
- if (preview->is_pressed())
+ if (preview->is_pressed()) {
Node3DEditor::get_singleton()->set_custom_camera(p_camera);
- else
+ } else {
Node3DEditor::get_singleton()->set_custom_camera(nullptr);
+ }
}
}
Camera3DEditor::Camera3DEditor() {
-
preview = memnew(Button);
add_child(preview);
@@ -83,18 +79,15 @@ Camera3DEditor::Camera3DEditor() {
}
void Camera3DEditorPlugin::edit(Object *p_object) {
-
Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object));
//camera_editor->edit(Object::cast_to<Node>(p_object));
}
bool Camera3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("Camera3D");
}
void Camera3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
//Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object));
} else {
@@ -103,7 +96,6 @@ void Camera3DEditorPlugin::make_visible(bool p_visible) {
}
Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
/* camera_editor = memnew( CameraEditor );
editor->get_viewport()->add_child(camera_editor);
diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h
index 1e57ac7cd2..2603229a46 100644
--- a/editor/plugins/camera_3d_editor_plugin.h
+++ b/editor/plugins/camera_3d_editor_plugin.h
@@ -36,7 +36,6 @@
#include "scene/3d/camera_3d.h"
class Camera3DEditor : public Control {
-
GDCLASS(Camera3DEditor, Control);
Panel *panel;
@@ -55,7 +54,6 @@ public:
};
class Camera3DEditorPlugin : public EditorPlugin {
-
GDCLASS(Camera3DEditorPlugin, EditorPlugin);
//CameraEditor *camera_editor;
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index b5fcf82d76..2f7080b1a5 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -31,6 +31,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/input/input.h"
+#include "core/math/geometry_2d.h"
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/project_settings.h"
@@ -53,15 +54,16 @@
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
-#define MIN_ZOOM 0.01
-#define MAX_ZOOM 100
+// Min and Max are power of two in order to play nicely with successive increment.
+// That way, we can naturally reach a 100% zoom from boundaries.
+#define MIN_ZOOM 1. / 128
+#define MAX_ZOOM 128
#define RULER_WIDTH (15 * EDSCALE)
#define SCALE_HANDLE_DISTANCE 25
#define MOVE_HANDLE_DISTANCE 25
class SnapDialog : public ConfirmationDialog {
-
GDCLASS(SnapDialog, ConfirmationDialog);
friend class CanvasItemEditor;
@@ -87,7 +89,6 @@ public:
GridContainer *child_container;
set_title(TTR("Configure Snap"));
- get_ok()->set_text(TTR("Close"));
container = memnew(VBoxContainer);
add_child(container);
@@ -252,7 +253,6 @@ void CanvasItemEditor::_snap_if_closer_float(
float &r_current_snap, SnapTarget &r_current_snap_target,
float p_target_value, SnapTarget p_snap_target,
float p_radius) {
-
float radius = p_radius / zoom;
float dist = Math::abs(p_value - p_target_value);
if ((p_radius < 0 || dist < radius) && (r_current_snap_target == SNAP_TARGET_NONE || dist < Math::abs(r_current_snap - p_value))) {
@@ -267,7 +267,6 @@ void CanvasItemEditor::_snap_if_closer_point(
Point2 p_target_value, SnapTarget p_snap_target,
real_t rotation,
float p_radius) {
-
Transform2D rot_trans = Transform2D(rotation, Point2());
p_value = rot_trans.inverse().xform(p_value);
p_target_value = rot_trans.inverse().xform(p_target_value);
@@ -330,7 +329,6 @@ void CanvasItemEditor::_snap_other_nodes(
}
Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsigned int p_forced_modes, const CanvasItem *p_self_canvas_item, List<CanvasItem *> p_other_nodes_exceptions) {
-
snap_target[0] = SNAP_TARGET_NONE;
snap_target[1] = SNAP_TARGET_NONE;
@@ -474,11 +472,11 @@ float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
}
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventKey> k = p_ev;
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
viewport->update();
@@ -492,28 +490,29 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
} else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
// Divide the grid size
Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
- if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0)
+ if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
grid_step_multiplier--;
+ }
viewport->update();
}
}
}
Object *CanvasItemEditor::_get_editor_data(Object *p_what) {
-
CanvasItem *ci = Object::cast_to<CanvasItem>(p_what);
- if (!ci)
+ if (!ci) {
return nullptr;
+ }
return memnew(CanvasItemEditorSelectedItem);
}
void CanvasItemEditor::_keying_changed() {
-
- if (AnimationPlayerEditor::singleton->get_track_editor()->is_visible_in_tree())
+ if (AnimationPlayerEditor::singleton->get_track_editor()->is_visible_in_tree()) {
animation_hb->show();
- else
+ } else {
animation_hb->hide();
+ }
}
Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_list) {
@@ -539,10 +538,12 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li
}
void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, const Node *p_node, bool &r_first, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, bool include_locked_nodes) {
- if (!p_node)
+ if (!p_node) {
return;
- if (Object::cast_to<Viewport>(p_node))
+ }
+ if (Object::cast_to<Viewport>(p_node)) {
return;
+ }
const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
@@ -578,10 +579,12 @@ Rect2 CanvasItemEditor::_get_encompassing_rect(const Node *p_node) {
}
void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
- if (!p_node)
+ if (!p_node) {
return;
- if (Object::cast_to<Viewport>(p_node))
+ }
+ if (Object::cast_to<Viewport>(p_node)) {
return;
+ }
const real_t grab_distance = EDITOR_GET("editors/poly_editor/point_grab_radius");
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
@@ -615,7 +618,6 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
}
void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked) {
-
Node *scene = editor->get_edited_scene();
_find_canvas_items_at_pos(p_pos, scene, r_items);
@@ -667,11 +669,12 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
Vector<Vector2> bone_shape;
- if (!_get_bone_shape(&bone_shape, nullptr, E))
+ if (!_get_bone_shape(&bone_shape, nullptr, E)) {
continue;
+ }
// Check if the point is inside the Polygon2D
- if (Geometry::is_point_in_polygon(screen_pos, bone_shape)) {
+ if (Geometry2D::is_point_in_polygon(screen_pos, bone_shape)) {
// Check if the item is already in the list
bool duplicate = false;
for (int i = 0; i < r_items.size(); i++) {
@@ -680,8 +683,9 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu
break;
}
}
- if (duplicate)
+ if (duplicate) {
continue;
+ }
// Else, add it
_SelectResult res;
@@ -700,21 +704,25 @@ bool CanvasItemEditor::_get_bone_shape(Vector<Vector2> *shape, Vector<Vector2> *
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(bone->key().from));
Node2D *to_node = Object::cast_to<Node2D>(ObjectDB::get_instance(bone->key().to));
- if (!from_node)
+ if (!from_node) {
return false;
- if (!from_node->is_inside_tree())
+ }
+ if (!from_node->is_inside_tree()) {
return false; //may have been removed
+ }
- if (!to_node && bone->get().length == 0)
+ if (!to_node && bone->get().length == 0) {
return false;
+ }
Vector2 from = transform.xform(from_node->get_global_position());
Vector2 to;
- if (to_node)
+ if (to_node) {
to = transform.xform(to_node->get_global_position());
- else
+ } else {
to = transform.xform(from_node->get_global_transform().xform(Vector2(bone->get().length, 0)));
+ }
Vector2 rel = to - from;
Vector2 relt = rel.tangent().normalized() * bone_width;
@@ -742,10 +750,12 @@ bool CanvasItemEditor::_get_bone_shape(Vector<Vector2> *shape, Vector<Vector2> *
}
void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
- if (!p_node)
+ if (!p_node) {
return;
- if (Object::cast_to<Viewport>(p_node))
+ }
+ if (Object::cast_to<Viewport>(p_node)) {
return;
+ }
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
Node *scene = editor->get_edited_scene();
@@ -778,7 +788,6 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, 0))) &&
p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, rect.size.y))) &&
p_rect.has_point(xform.xform(rect.position + Vector2(0, rect.size.y)))) {
-
r_items->push_back(canvas_item);
}
} else {
@@ -861,10 +870,12 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2
}
void CanvasItemEditor::_save_canvas_item_ik_chain(const CanvasItem *p_canvas_item, List<float> *p_bones_length, List<Dictionary> *p_bones_state) {
- if (p_bones_length)
+ if (p_bones_length) {
*p_bones_length = List<float>();
- if (p_bones_state)
+ }
+ if (p_bones_state) {
*p_bones_state = List<Dictionary>();
+ }
const Node2D *bone = Object::cast_to<Node2D>(p_canvas_item);
if (bone && bone->has_meta("_edit_bone_")) {
@@ -890,10 +901,12 @@ void CanvasItemEditor::_save_canvas_item_ik_chain(const CanvasItem *p_canvas_ite
for (List<const Node2D *>::Element *bone_E = bone_ik_list.front(); bone_E; bone_E = bone_E->next()) {
bone_xform = bone_xform * bone->get_transform().affine_inverse();
const Node2D *parent_bone = bone_E->get();
- if (p_bones_length)
+ if (p_bones_length) {
p_bones_length->push_back(parent_bone->get_global_transform().get_origin().distance_to(bone->get_global_position()));
- if (p_bones_state)
+ }
+ if (p_bones_state) {
p_bones_state->push_back(parent_bone->_edit_get_state());
+ }
bone = parent_bone;
}
}
@@ -965,18 +978,18 @@ void CanvasItemEditor::_snap_changed() {
}
void CanvasItemEditor::_selection_result_pressed(int p_result) {
-
- if (selection_results.size() <= p_result)
+ if (selection_results.size() <= p_result) {
return;
+ }
CanvasItem *item = selection_results[p_result].item;
- if (item)
+ if (item) {
_select_click_on_item(item, Point2(), selection_menu_additive_selection);
+ }
}
void CanvasItemEditor::_selection_menu_hide() {
-
selection_results.clear();
selection_menu->clear();
selection_menu->set_size(Vector2(0, 0));
@@ -1027,7 +1040,6 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
// Start dragging a guide
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
-
// Press button
if (b->get_position().x < RULER_WIDTH && b->get_position().y < RULER_WIDTH) {
// Drag a new double guide
@@ -1203,7 +1215,11 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
view_offset.y += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
update_viewport();
} else {
- _zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), b->get_position());
+ float new_zoom = _get_next_zoom_value(-1);
+ if (b->get_factor() != 1.f) {
+ new_zoom = zoom * ((new_zoom / zoom - 1.f) * b->get_factor() + 1.f);
+ }
+ _zoom_on_position(new_zoom, b->get_position());
}
return true;
}
@@ -1214,7 +1230,11 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
view_offset.y -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
update_viewport();
} else {
- _zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), b->get_position());
+ float new_zoom = _get_next_zoom_value(1);
+ if (b->get_factor() != 1.f) {
+ new_zoom = zoom * ((new_zoom / zoom - 1.f) * b->get_factor() + 1.f);
+ }
+ _zoom_on_position(new_zoom, b->get_position());
}
return true;
}
@@ -1274,8 +1294,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
}
}
- if (is_pan_key)
+ if (is_pan_key) {
pan_pressed = k->is_pressed();
+ }
}
Ref<InputEventMouseMotion> m = p_event;
@@ -1362,10 +1383,11 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) {
drag_to = transform.affine_inverse().xform(m->get_position());
_restore_canvas_item_state(drag_selection);
Vector2 new_pos;
- if (drag_selection.size() == 1)
+ if (drag_selection.size() == 1) {
new_pos = snap_point(drag_to, SNAP_NODE_SIDES | SNAP_NODE_CENTER | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, drag_selection[0]);
- else
+ } else {
new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL);
+ }
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get();
canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos));
@@ -1397,7 +1419,6 @@ void CanvasItemEditor::_solve_IK(Node2D *leaf_node, Point2 target_position) {
if (se) {
int nb_bones = se->pre_drag_bones_undo_state.size();
if (nb_bones > 0) {
-
// Build the node list
Point2 leaf_pos = target_position;
@@ -1475,8 +1496,9 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
// Remove not movable nodes
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
- if (!_is_node_movable(E->get(), true))
+ if (!_is_node_movable(E->get(), true)) {
selection.erase(E);
+ }
}
drag_selection = selection;
@@ -1624,28 +1646,36 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
switch (drag_type) {
case DRAG_ANCHOR_TOP_LEFT:
- if (!use_single_axis || !use_y)
+ if (!use_single_axis || !use_y) {
control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false);
- if (!use_single_axis || use_y)
+ }
+ if (!use_single_axis || use_y) {
control->set_anchor(MARGIN_TOP, new_anchor.y, false, false);
+ }
break;
case DRAG_ANCHOR_TOP_RIGHT:
- if (!use_single_axis || !use_y)
+ if (!use_single_axis || !use_y) {
control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false);
- if (!use_single_axis || use_y)
+ }
+ if (!use_single_axis || use_y) {
control->set_anchor(MARGIN_TOP, new_anchor.y, false, false);
+ }
break;
case DRAG_ANCHOR_BOTTOM_RIGHT:
- if (!use_single_axis || !use_y)
+ if (!use_single_axis || !use_y) {
control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false);
- if (!use_single_axis || use_y)
+ }
+ if (!use_single_axis || use_y) {
control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
+ }
break;
case DRAG_ANCHOR_BOTTOM_LEFT:
- if (!use_single_axis || !use_y)
+ if (!use_single_axis || !use_y) {
control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false);
- if (!use_single_axis || use_y)
+ }
+ if (!use_single_axis || use_y) {
control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
+ }
break;
case DRAG_ANCHOR_ALL:
if (!use_single_axis || !use_y) {
@@ -1723,13 +1753,15 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
ofs *= (select_handle->get_size().width / 2);
ofs += endpoints[i];
- if (ofs.distance_to(b->get_position()) < radius)
+ if (ofs.distance_to(b->get_position()) < radius) {
resize_drag = dragger[i * 2];
+ }
ofs = (endpoints[i] + endpoints[next]) / 2;
ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
- if (ofs.distance_to(b->get_position()) < radius)
+ if (ofs.distance_to(b->get_position()) < radius) {
resize_drag = dragger[i * 2 + 1];
+ }
}
if (resize_drag != DRAG_NONE) {
@@ -1866,7 +1898,6 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
}
bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> b = p_event;
Ref<InputEventMouseMotion> m = p_event;
@@ -1878,7 +1909,6 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
CanvasItem *canvas_item = selection[0];
if (_is_node_movable(canvas_item)) {
-
Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
@@ -2041,7 +2071,6 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (drag_type == DRAG_MOVE || drag_type == DRAG_MOVE_X || drag_type == DRAG_MOVE_Y) {
// Move the nodes
if (m.is_valid()) {
-
// Save the ik chain for reapplying before IK solve
Vector<List<Dictionary>> all_bones_ik_states;
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
@@ -2143,7 +2172,6 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
}
if (drag_selection.size() > 0) {
-
// Save the ik chain for reapplying before IK solve
Vector<List<Dictionary>> all_bones_ik_states;
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
@@ -2158,20 +2186,23 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
bool move_local_base_rotated = k->get_control() || k->get_metakey();
Vector2 dir;
- if (k->get_keycode() == KEY_UP)
+ if (k->get_keycode() == KEY_UP) {
dir += Vector2(0, -1);
- else if (k->get_keycode() == KEY_DOWN)
+ } else if (k->get_keycode() == KEY_DOWN) {
dir += Vector2(0, 1);
- else if (k->get_keycode() == KEY_LEFT)
+ } else if (k->get_keycode() == KEY_LEFT) {
dir += Vector2(-1, 0);
- else if (k->get_keycode() == KEY_RIGHT)
+ } else if (k->get_keycode() == KEY_RIGHT) {
dir += Vector2(1, 0);
- if (k->get_shift())
+ }
+ if (k->get_shift()) {
dir *= grid_step * Math::pow(2.0, grid_step_multiplier);
+ }
drag_to += dir;
- if (k->get_shift())
+ if (k->get_shift()) {
drag_to = drag_to.snapped(grid_step * Math::pow(2.0, grid_step_multiplier));
+ }
Point2 previous_pos;
if (drag_selection.size() == 1) {
@@ -2219,7 +2250,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
return true;
}
- if (k.is_valid() && !k->is_pressed() && drag_type == DRAG_KEY_MOVE && tool == TOOL_SELECT &&
+ if (k.is_valid() && !k->is_pressed() && drag_type == DRAG_KEY_MOVE && (tool == TOOL_SELECT || tool == TOOL_MOVE) &&
(k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) {
// Confirm canvas items move by arrow keys
if ((!Input::get_singleton()->is_key_pressed(KEY_UP)) &&
@@ -2310,8 +2341,9 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
Point2 click = transform.affine_inverse().xform(b->get_position());
Node *scene = editor->get_edited_scene();
- if (!scene)
+ if (!scene) {
return true;
+ }
// Find the item to select
CanvasItem *canvas_item = nullptr;
@@ -2379,10 +2411,12 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
Point2 bsfrom = drag_from;
Point2 bsto = box_selecting_to;
- if (bsfrom.x > bsto.x)
+ if (bsfrom.x > bsto.x) {
SWAP(bsfrom.x, bsto.x);
- if (bsfrom.y > bsto.y)
+ }
+ if (bsfrom.y > bsto.y) {
SWAP(bsfrom.y, bsto.y);
+ }
_find_canvas_items_in_rect(Rect2(bsfrom, bsto - bsfrom), scene, &selitems);
for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) {
@@ -2419,16 +2453,17 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
}
bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
-
- if (tool != TOOL_RULER)
+ if (tool != TOOL_RULER) {
return false;
+ }
Ref<InputEventMouseButton> b = p_event;
Ref<InputEventMouseMotion> m = p_event;
Point2 previous_origin = ruler_tool_origin;
- if (!ruler_tool_active)
+ if (!ruler_tool_active) {
ruler_tool_origin = snap_point(viewport->get_local_mouse_position() / zoom + view_offset);
+ }
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT) {
if (b->is_pressed()) {
@@ -2442,7 +2477,6 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
}
if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) {
-
viewport->update();
return true;
}
@@ -2451,7 +2485,6 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
}
bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
Point2 click = transform.affine_inverse().xform(m->get_position());
@@ -2466,8 +2499,9 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) {
for (int i = 0; i < hovering_results_items.size(); i++) {
CanvasItem *canvas_item = hovering_results_items[i].item;
- if (canvas_item->_edit_use_rect())
+ if (canvas_item->_edit_use_rect()) {
continue;
+ }
_HoverResult hover_result;
hover_result.position = canvas_item->get_global_transform_with_canvas().get_origin();
@@ -2536,8 +2570,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
accepted = (_gui_input_zoom_or_pan(p_event, accepted) || accepted);
- if (accepted)
+ if (accepted) {
accept_event();
+ }
// Handles the mouse hovering
_gui_input_hover(p_event);
@@ -2589,10 +2624,11 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
break;
}
- if (is_hovering_h_guide)
+ if (is_hovering_h_guide) {
c = CURSOR_VSIZE;
- else if (is_hovering_v_guide)
+ } else if (is_hovering_v_guide) {
c = CURSOR_HSIZE;
+ }
viewport->set_default_cursor_shape(c);
@@ -2646,7 +2682,6 @@ void CanvasItemEditor::_draw_focus() {
}
void CanvasItemEditor::_draw_guides() {
-
Color guide_color = EditorSettings::get_singleton()->get("editors/2d/guides_color");
Transform2D xform = viewport_scrollable->get_transform() * transform;
@@ -2654,8 +2689,9 @@ void CanvasItemEditor::_draw_guides() {
if (EditorNode::get_singleton()->get_edited_scene() && EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) {
Array vguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_vertical_guides_");
for (int i = 0; i < vguides.size(); i++) {
- if (drag_type == DRAG_V_GUIDE && i == dragged_guide_index)
+ if (drag_type == DRAG_V_GUIDE && i == dragged_guide_index) {
continue;
+ }
float x = xform.xform(Point2(vguides[i], 0)).x;
viewport->draw_line(Point2(x, 0), Point2(x, viewport->get_size().y), guide_color, Math::round(EDSCALE));
}
@@ -2664,8 +2700,9 @@ void CanvasItemEditor::_draw_guides() {
if (EditorNode::get_singleton()->get_edited_scene() && EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_")) {
Array hguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_horizontal_guides_");
for (int i = 0; i < hguides.size(); i++) {
- if (drag_type == DRAG_H_GUIDE && i == dragged_guide_index)
+ if (drag_type == DRAG_H_GUIDE && i == dragged_guide_index) {
continue;
+ }
float y = xform.xform(Point2(0, hguides[i])).y;
viewport->draw_line(Point2(0, y), Point2(viewport->get_size().x, y), guide_color, Math::round(EDSCALE));
}
@@ -2793,7 +2830,6 @@ void CanvasItemEditor::_draw_rulers() {
}
void CanvasItemEditor::_draw_grid() {
-
if (show_grid || grid_snap_active) {
// Draw the grid
Vector2 real_grid_offset;
@@ -2866,9 +2902,9 @@ void CanvasItemEditor::_draw_grid() {
}
void CanvasItemEditor::_draw_ruler_tool() {
-
- if (tool != TOOL_RULER)
+ if (tool != TOOL_RULER) {
return;
+ }
if (ruler_tool_active) {
Color ruler_primary_color = get_theme_color("accent_color", "Editor");
@@ -2967,7 +3003,6 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
if (grid_snap_active) {
-
text_pos = (begin + end) / 2 + Vector2(-text_width / 2, text_height / 2);
text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5);
text_pos.y = CLAMP(text_pos.y, text_height * 2.5, viewport->get_rect().size.y - text_height / 2);
@@ -2987,7 +3022,6 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
}
} else {
-
if (grid_snap_active) {
Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons");
viewport->draw_texture(get_theme_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
@@ -2999,7 +3033,6 @@ void CanvasItemEditor::_draw_control_anchors(Control *control) {
Transform2D xform = transform * control->get_global_transform_with_canvas();
RID ci = viewport->get_canvas_item();
if (tool == TOOL_SELECT && !Object::cast_to<Container>(control->get_parent())) {
-
// Compute the anchors
float anchors_values[4];
anchors_values[0] = control->get_anchor(MARGIN_LEFT);
@@ -3264,7 +3297,6 @@ void CanvasItemEditor::_draw_selection() {
viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE));
}
} else {
-
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@@ -3275,7 +3307,6 @@ void CanvasItemEditor::_draw_selection() {
if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks
// Draw the pivot
if (canvas_item->_edit_use_pivot()) {
-
// Draw the node's pivot
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
@@ -3453,15 +3484,12 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c
}
void CanvasItemEditor::_draw_axis() {
-
if (show_origin) {
-
_draw_straight_line(Point2(), Point2(1, 0), get_theme_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75));
_draw_straight_line(Point2(), Point2(0, 1), get_theme_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75));
}
if (show_viewport) {
-
RID ci = viewport->get_canvas_item();
Color area_axis_color = EditorSettings::get_singleton()->get("editors/2d/viewport_border_color");
@@ -3492,15 +3520,16 @@ void CanvasItemEditor::_draw_bones() {
Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2d/bone_selected_color");
for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
-
Vector<Vector2> bone_shape;
Vector<Vector2> bone_shape_outline;
- if (!_get_bone_shape(&bone_shape, &bone_shape_outline, E))
+ if (!_get_bone_shape(&bone_shape, &bone_shape_outline, E)) {
continue;
+ }
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
- if (!from_node->is_visible_in_tree())
+ if (!from_node->is_visible_in_tree()) {
continue;
+ }
Vector<Color> colors;
if (from_node->has_meta("_edit_ik_")) {
@@ -3543,11 +3572,13 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
ERR_FAIL_COND(!p_node);
Node *scene = editor->get_edited_scene();
- if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner()))
+ if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) {
return;
+ }
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
- if (canvas_item && !canvas_item->is_visible())
+ if (canvas_item && !canvas_item->is_visible()) {
return;
+ }
Transform2D parent_xform = p_parent_xform;
Transform2D canvas_xform = p_canvas_xform;
@@ -3581,7 +3612,6 @@ void CanvasItemEditor::_draw_hover() {
List<Rect2> previous_rects;
for (int i = 0; i < hovering_results.size(); i++) {
-
Ref<Texture2D> node_icon = hovering_results[i].icon;
String node_name = hovering_results[i].name;
@@ -3611,11 +3641,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
ERR_FAIL_COND(!p_node);
Node *scene = editor->get_edited_scene();
- if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner()))
+ if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) {
return;
+ }
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
- if (canvas_item && !canvas_item->is_visible())
+ if (canvas_item && !canvas_item->is_visible()) {
return;
+ }
Transform2D parent_xform = p_parent_xform;
Transform2D canvas_xform = p_canvas_xform;
@@ -3717,7 +3749,6 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
}
void CanvasItemEditor::_draw_viewport() {
-
// Update the transform
transform = Transform2D();
transform.scale_basis(Size2(zoom, zoom));
@@ -3777,10 +3808,12 @@ void CanvasItemEditor::_draw_viewport() {
}
_draw_bones();
- if (show_rulers)
+ if (show_rulers) {
_draw_rulers();
- if (show_guides)
+ }
+ if (show_guides) {
_draw_guides();
+ }
_draw_smart_snapping();
_draw_focus();
_draw_hover();
@@ -3796,7 +3829,6 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) {
}
void CanvasItemEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_PHYSICS_PROCESS) {
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
@@ -3882,10 +3914,8 @@ void CanvasItemEditor::_notification(int p_what) {
// Update the viewport if bones changes
for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
-
Object *b = ObjectDB::get_instance(E->key().from);
if (!b) {
-
viewport->update();
break;
}
@@ -3898,14 +3928,12 @@ void CanvasItemEditor::_notification(int p_what) {
Transform2D global_xform = b2->get_global_transform();
if (global_xform != E->get().xform) {
-
E->get().xform = global_xform;
viewport->update();
}
Bone2D *bone = Object::cast_to<Bone2D>(b);
if (bone && bone->get_default_length() != E->get().length) {
-
E->get().length = bone->get_default_length();
viewport->update();
}
@@ -3913,7 +3941,6 @@ void CanvasItemEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
-
select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons"));
for (int i = 0; i < 4; i++) {
select_sb->set_margin_size(Margin(i), 4);
@@ -3926,7 +3953,6 @@ void CanvasItemEditor::_notification(int p_what) {
get_tree()->connect("node_removed", callable_mp(this, &CanvasItemEditor::_tree_changed), varray());
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
-
select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons"));
}
@@ -4034,10 +4060,12 @@ void CanvasItemEditor::_selection_changed() {
List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Control *control = Object::cast_to<Control>(E->get());
- if (!control)
+ if (!control) {
continue;
- if (Object::cast_to<Container>(control->get_parent()))
+ }
+ if (Object::cast_to<Container>(control->get_parent())) {
continue;
+ }
nbValidControls++;
if (control->has_meta("_edit_use_anchors_") && control->get_meta("_edit_use_anchors_")) {
@@ -4054,7 +4082,6 @@ void CanvasItemEditor::_selection_changed() {
}
void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
-
Array selection = editor_selection->get_selected_nodes();
if (selection.size() != 1 || (Node *)selection[0] != p_canvas_item) {
drag_type = DRAG_NONE;
@@ -4066,16 +4093,15 @@ void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
}
void CanvasItemEditor::_queue_update_bone_list() {
-
- if (bone_list_dirty)
+ if (bone_list_dirty) {
return;
+ }
call_deferred("_update_bone_list");
bone_list_dirty = true;
}
void CanvasItemEditor::_update_bone_list() {
-
bone_last_frame++;
if (editor->get_edited_scene()) {
@@ -4107,7 +4133,6 @@ void CanvasItemEditor::_tree_changed(Node *) {
}
void CanvasItemEditor::_update_scrollbars() {
-
updating_scroll = true;
// Move the zoom buttons.
@@ -4225,9 +4250,9 @@ void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const floa
}
void CanvasItemEditor::_update_scroll(float) {
-
- if (updating_scroll)
+ if (updating_scroll) {
return;
+ }
view_offset.x = h_scroll->get_value();
view_offset.y = v_scroll->get_value();
@@ -4240,7 +4265,6 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
undo_redo->create_action(TTR("Change Anchors and Margins"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Control *control = Object::cast_to<Control>(E->get());
if (control) {
undo_redo->add_do_method(control, "set_anchors_preset", p_preset);
@@ -4282,7 +4306,6 @@ void CanvasItemEditor::_set_anchors_and_margins_to_keep_ratio() {
undo_redo->create_action(TTR("Change Anchors and Margins"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Control *control = Object::cast_to<Control>(E->get());
if (control) {
Point2 top_left_anchor = _position_to_anchor(control, Point2());
@@ -4310,7 +4333,6 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
undo_redo->create_action(TTR("Change Anchors"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Control *control = Object::cast_to<Control>(E->get());
if (control) {
undo_redo->add_do_method(control, "set_anchors_preset", p_preset);
@@ -4321,9 +4343,39 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) {
undo_redo->commit_action();
}
+float CanvasItemEditor::_get_next_zoom_value(int p_increment_count) const {
+ // Base increment factor defined as the twelveth root of two.
+ // This allow a smooth geometric evolution of the zoom, with the advantage of
+ // visiting all integer power of two scale factors.
+ // note: this is analogous to the 'semitones' interval in the music world
+ // In order to avoid numerical imprecisions, we compute and edit a zoom index
+ // with the following relation: zoom = 2 ^ (index / 12)
+
+ if (zoom < CMP_EPSILON || p_increment_count == 0) {
+ return 1.f;
+ }
+
+ // Remove Editor scale from the index computation
+ float zoom_noscale = zoom / MAX(1, EDSCALE);
+
+ // zoom = 2**(index/12) => log2(zoom) = index/12
+ float closest_zoom_index = Math::round(Math::log(zoom_noscale) * 12.f / Math::log(2.f));
+
+ float new_zoom_index = closest_zoom_index + p_increment_count;
+ float new_zoom = Math::pow(2.f, new_zoom_index / 12.f);
+
+ // Restore Editor scale transformation
+ new_zoom *= MAX(1, EDSCALE);
+
+ return new_zoom;
+}
+
void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
- if (p_zoom < MIN_ZOOM || p_zoom > MAX_ZOOM)
+ p_zoom = CLAMP(p_zoom, MIN_ZOOM, MAX_ZOOM);
+
+ if (p_zoom == zoom) {
return;
+ }
float prev_zoom = zoom;
zoom = p_zoom;
@@ -4363,7 +4415,7 @@ void CanvasItemEditor::_update_zoom_label() {
}
void CanvasItemEditor::_button_zoom_minus() {
- _zoom_on_position(zoom / Math_SQRT2, viewport_scrollable->get_size() / 2.0);
+ _zoom_on_position(_get_next_zoom_value(-6), viewport_scrollable->get_size() / 2.0);
}
void CanvasItemEditor::_button_zoom_reset() {
@@ -4371,7 +4423,7 @@ void CanvasItemEditor::_button_zoom_reset() {
}
void CanvasItemEditor::_button_zoom_plus() {
- _zoom_on_position(zoom * Math_SQRT2, viewport_scrollable->get_size() / 2.0);
+ _zoom_on_position(_get_next_zoom_value(6), viewport_scrollable->get_size() / 2.0);
}
void CanvasItemEditor::_button_toggle_smart_snap(bool p_status) {
@@ -4383,6 +4435,7 @@ void CanvasItemEditor::_button_toggle_grid_snap(bool p_status) {
grid_snap_active = p_status;
viewport->update();
}
+
void CanvasItemEditor::_button_override_camera(bool p_pressed) {
EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton();
@@ -4394,7 +4447,6 @@ void CanvasItemEditor::_button_override_camera(bool p_pressed) {
}
void CanvasItemEditor::_button_tool_select(int p_index) {
-
ToolButton *tb[TOOL_MAX] = { select_button, list_select_button, move_button, scale_button, rotate_button, pivot_button, pan_button, ruler_button };
for (int i = 0; i < TOOL_MAX; i++) {
tb[i]->set_pressed(i == p_index);
@@ -4405,27 +4457,30 @@ void CanvasItemEditor::_button_tool_select(int p_index) {
}
void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) {
-
Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
- if (!canvas_item || !canvas_item->is_visible_in_tree())
+ if (!canvas_item || !canvas_item->is_visible_in_tree()) {
continue;
+ }
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
if (Object::cast_to<Node2D>(canvas_item)) {
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
- if (key_pos && p_location)
+ if (key_pos && p_location) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), p_on_existing);
- if (key_rot && p_rotation)
+ }
+ if (key_rot && p_rotation) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), p_on_existing);
- if (key_scale && p_scale)
+ }
+ if (key_scale && p_scale) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), p_on_existing);
+ }
if (n2d->has_meta("_edit_bone_") && n2d->get_parent_item()) {
//look for an IK chain
@@ -4435,42 +4490,45 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation,
bool has_chain = false;
while (n) {
-
ik_chain.push_back(n);
if (n->has_meta("_edit_ik_")) {
has_chain = true;
break;
}
- if (!n->get_parent_item())
+ if (!n->get_parent_item()) {
break;
+ }
n = Object::cast_to<Node2D>(n->get_parent_item());
}
if (has_chain && ik_chain.size()) {
-
for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) {
-
- if (key_pos)
+ if (key_pos) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing);
- if (key_rot)
+ }
+ if (key_rot) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), p_on_existing);
- if (key_scale)
+ }
+ if (key_scale) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), p_on_existing);
+ }
}
}
}
} else if (Object::cast_to<Control>(canvas_item)) {
-
Control *ctrl = Object::cast_to<Control>(canvas_item);
- if (key_pos)
+ if (key_pos) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), p_on_existing);
- if (key_rot)
+ }
+ if (key_rot) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), p_on_existing);
- if (key_scale)
+ }
+ if (key_scale) {
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), p_on_existing);
+ }
}
}
}
@@ -4479,8 +4537,9 @@ void CanvasItemEditor::_button_toggle_anchor_mode(bool p_status) {
List<CanvasItem *> selection = _get_edited_canvas_items(false, false);
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
Control *control = Object::cast_to<Control>(E->get());
- if (!control || Object::cast_to<Container>(control->get_parent()))
+ if (!control || Object::cast_to<Container>(control->get_parent())) {
continue;
+ }
control->set_meta("_edit_use_anchors_", p_status);
}
@@ -4619,10 +4678,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
- if (!canvas_item || !canvas_item->is_inside_tree())
+ if (!canvas_item || !canvas_item->is_inside_tree()) {
continue;
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ }
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(canvas_item, "set_meta", "_edit_lock_", true);
undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_lock_");
@@ -4639,10 +4700,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
- if (!canvas_item || !canvas_item->is_inside_tree())
+ if (!canvas_item || !canvas_item->is_inside_tree()) {
continue;
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ }
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_lock_");
undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_lock_", true);
@@ -4659,10 +4722,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
- if (!canvas_item || !canvas_item->is_inside_tree())
+ if (!canvas_item || !canvas_item->is_inside_tree()) {
continue;
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ }
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(canvas_item, "set_meta", "_edit_group_", true);
undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_group_");
@@ -4679,10 +4744,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
- if (!canvas_item || !canvas_item->is_inside_tree())
+ if (!canvas_item || !canvas_item->is_inside_tree()) {
continue;
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ }
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_group_");
undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_group_", true);
@@ -4796,41 +4863,36 @@ void CanvasItemEditor::_popup_callback(int p_op) {
case ANIM_INSERT_KEY:
case ANIM_INSERT_KEY_EXISTING: {
-
bool existing = p_op == ANIM_INSERT_KEY_EXISTING;
_insert_animation_keys(true, true, true, existing);
} break;
case ANIM_INSERT_POS: {
-
key_pos = key_loc_button->is_pressed();
} break;
case ANIM_INSERT_ROT: {
-
key_rot = key_rot_button->is_pressed();
} break;
case ANIM_INSERT_SCALE: {
-
key_scale = key_scale_button->is_pressed();
} break;
case ANIM_COPY_POSE: {
-
pose_clipboard.clear();
Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
- if (!canvas_item || !canvas_item->is_visible_in_tree())
+ if (!canvas_item || !canvas_item->is_visible_in_tree()) {
continue;
+ }
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
if (Object::cast_to<Node2D>(canvas_item)) {
-
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
PoseClipboard pc;
pc.pos = n2d->get_position();
@@ -4843,16 +4905,16 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case ANIM_PASTE_POSE: {
-
- if (!pose_clipboard.size())
+ if (!pose_clipboard.size()) {
break;
+ }
undo_redo->create_action(TTR("Paste Pose"));
for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) {
-
Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id));
- if (!n2d)
+ if (!n2d) {
continue;
+ }
undo_redo->add_do_method(n2d, "set_position", E->get().pos);
undo_redo->add_do_method(n2d, "set_rotation", E->get().rot);
undo_redo->add_do_method(n2d, "set_scale", E->get().scale);
@@ -4864,33 +4926,36 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case ANIM_CLEAR_POSE: {
-
Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
- if (!canvas_item || !canvas_item->is_visible_in_tree())
+ if (!canvas_item || !canvas_item->is_visible_in_tree()) {
continue;
+ }
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
if (Object::cast_to<Node2D>(canvas_item)) {
Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
- if (key_pos)
+ if (key_pos) {
n2d->set_position(Vector2());
- if (key_rot)
+ }
+ if (key_rot) {
n2d->set_rotation(0);
- if (key_scale)
+ }
+ if (key_scale) {
n2d->set_scale(Vector2(1, 1));
+ }
} else if (Object::cast_to<Control>(canvas_item)) {
-
Control *ctrl = Object::cast_to<Control>(canvas_item);
- if (key_pos)
+ if (key_pos) {
ctrl->set_position(Point2());
+ }
/*
if (key_scale)
AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
@@ -4900,7 +4965,6 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case CLEAR_GUIDES: {
-
Node *const root = EditorNode::get_singleton()->get_edited_scene();
if (root && (root->has_meta("_edit_horizontal_guides_") || root->has_meta("_edit_vertical_guides_"))) {
@@ -4924,12 +4988,10 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case VIEW_CENTER_TO_SELECTION:
case VIEW_FRAME_TO_SELECTION: {
-
_focus_selection(p_op);
} break;
case PREVIEW_CANVAS_SCALE: {
-
bool preview = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE));
preview = !preview;
RS::get_singleton()->canvas_set_disable_scale(!preview);
@@ -4937,21 +4999,23 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_MAKE_BONES: {
-
Map<Node *, Object *> &selection = editor_selection->get_selection();
undo_redo->create_action(TTR("Create Custom Bone(s) from Node(s)"));
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
Node2D *n2d = Object::cast_to<Node2D>(E->key());
- if (!n2d)
+ if (!n2d) {
continue;
- if (!n2d->is_visible_in_tree())
+ }
+ if (!n2d->is_visible_in_tree()) {
continue;
- if (!n2d->get_parent_item())
+ }
+ if (!n2d->get_parent_item()) {
continue;
- if (n2d->has_meta("_edit_bone_") && n2d->get_meta("_edit_bone_"))
+ }
+ if (n2d->has_meta("_edit_bone_") && n2d->get_meta("_edit_bone_")) {
continue;
+ }
undo_redo->add_do_method(n2d, "set_meta", "_edit_bone_", true);
undo_redo->add_undo_method(n2d, "remove_meta", "_edit_bone_");
@@ -4964,19 +5028,20 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_CLEAR_BONES: {
-
Map<Node *, Object *> &selection = editor_selection->get_selection();
undo_redo->create_action(TTR("Clear Bones"));
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
Node2D *n2d = Object::cast_to<Node2D>(E->key());
- if (!n2d)
+ if (!n2d) {
continue;
- if (!n2d->is_visible_in_tree())
+ }
+ if (!n2d->is_visible_in_tree()) {
continue;
- if (!n2d->has_meta("_edit_bone_"))
+ }
+ if (!n2d->has_meta("_edit_bone_")) {
continue;
+ }
undo_redo->add_do_method(n2d, "remove_meta", "_edit_bone_");
undo_redo->add_undo_method(n2d, "set_meta", "_edit_bone_", n2d->get_meta("_edit_bone_"));
@@ -4989,19 +5054,20 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_SET_IK_CHAIN: {
-
List<Node *> selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Make IK Chain"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get());
- if (!canvas_item || !canvas_item->is_visible_in_tree())
+ if (!canvas_item || !canvas_item->is_visible_in_tree()) {
continue;
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ }
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
- if (canvas_item->has_meta("_edit_ik_") && canvas_item->get_meta("_edit_ik_"))
+ }
+ if (canvas_item->has_meta("_edit_ik_") && canvas_item->get_meta("_edit_ik_")) {
continue;
+ }
undo_redo->add_do_method(canvas_item, "set_meta", "_edit_ik_", true);
undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_ik_");
@@ -5012,19 +5078,20 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_CLEAR_IK_CHAIN: {
-
Map<Node *, Object *> &selection = editor_selection->get_selection();
undo_redo->create_action(TTR("Clear IK Chain"));
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
CanvasItem *n2d = Object::cast_to<CanvasItem>(E->key());
- if (!n2d)
+ if (!n2d) {
continue;
- if (!n2d->is_visible_in_tree())
+ }
+ if (!n2d->is_visible_in_tree()) {
continue;
- if (!n2d->has_meta("_edit_ik_"))
+ }
+ if (!n2d->has_meta("_edit_ik_")) {
continue;
+ }
undo_redo->add_do_method(n2d, "remove_meta", "_edit_ik_");
undo_redo->add_undo_method(n2d, "set_meta", "_edit_ik_", n2d->get_meta("_edit_ik_"));
@@ -5045,10 +5112,12 @@ void CanvasItemEditor::_focus_selection(int p_op) {
Map<Node *, Object *> &selection = editor_selection->get_selection();
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
- if (!canvas_item)
+ if (!canvas_item) {
continue;
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ }
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
// counting invisible items, for now
//if (!canvas_item->is_visible_in_tree()) continue;
@@ -5074,11 +5143,11 @@ void CanvasItemEditor::_focus_selection(int p_op) {
rect = rect.merge(canvas_item_rect);
}
};
- if (count == 0)
+ if (count == 0) {
return;
+ }
if (p_op == VIEW_CENTER_TO_SELECTION) {
-
center = rect.position + rect.size / 2;
Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center);
view_offset.x -= Math::round(offset.x / zoom);
@@ -5100,7 +5169,6 @@ void CanvasItemEditor::_focus_selection(int p_op) {
}
void CanvasItemEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_update_override_camera_button", "game_running"), &CanvasItemEditor::_update_override_camera_button);
ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data);
ClassDB::bind_method("_unhandled_key_input", &CanvasItemEditor::_unhandled_key_input);
@@ -5114,7 +5182,6 @@ void CanvasItemEditor::_bind_methods() {
}
Dictionary CanvasItemEditor::get_state() const {
-
Dictionary state;
// Take the editor scale into account.
state["zoom"] = zoom / MAX(1, EDSCALE);
@@ -5151,7 +5218,6 @@ Dictionary CanvasItemEditor::get_state() const {
}
void CanvasItemEditor::set_state(const Dictionary &p_state) {
-
bool update_scrollbars = false;
Dictionary state = p_state;
if (state.has("zoom")) {
@@ -5336,7 +5402,6 @@ void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) {
}
void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) {
-
info_overlay->remove_child(p_control);
info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
}
@@ -5348,17 +5413,14 @@ void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) {
}
void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) {
-
hb->remove_child(p_control);
}
HSplitContainer *CanvasItemEditor::get_palette_split() {
-
return palette_split;
}
VSplitContainer *CanvasItemEditor::get_bottom_split() {
-
return bottom_split;
}
@@ -5367,7 +5429,6 @@ void CanvasItemEditor::focus_selection() {
}
CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
-
key_pos = true;
key_rot = true;
key_scale = false;
@@ -5588,6 +5649,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(pan_button);
pan_button->set_toggle_mode(true);
pan_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_PAN));
+ pan_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/pan_mode", TTR("Pan Mode"), KEY_G));
pan_button->set_tooltip(TTR("Pan Mode"));
ruler_button = memnew(ToolButton);
@@ -5826,25 +5888,21 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
CanvasItemEditor *CanvasItemEditor::singleton = nullptr;
void CanvasItemEditorPlugin::edit(Object *p_object) {
-
canvas_item_editor->set_undo_redo(&get_undo_redo());
canvas_item_editor->edit(Object::cast_to<CanvasItem>(p_object));
}
bool CanvasItemEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("CanvasItem");
}
void CanvasItemEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
canvas_item_editor->show();
canvas_item_editor->set_physics_process(true);
RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false);
} else {
-
canvas_item_editor->hide();
canvas_item_editor->set_physics_process(false);
RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true);
@@ -5852,16 +5910,14 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) {
}
Dictionary CanvasItemEditorPlugin::get_state() const {
-
return canvas_item_editor->get_state();
}
-void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) {
+void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) {
canvas_item_editor->set_state(p_state);
}
CanvasItemEditorPlugin::CanvasItemEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
canvas_item_editor = memnew(CanvasItemEditor(editor));
canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -5887,8 +5943,9 @@ void CanvasItemEditorViewport::_on_select_type(Object *selected) {
}
void CanvasItemEditorViewport::_on_change_type_confirmed() {
- if (!button_group->get_pressed_button())
+ if (!button_group->get_pressed_button()) {
return;
+ }
CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
default_type = check->get_text();
@@ -5897,7 +5954,6 @@ void CanvasItemEditorViewport::_on_change_type_confirmed() {
}
void CanvasItemEditorViewport::_on_change_type_closed() {
-
_remove_preview();
}
@@ -5929,8 +5985,9 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
}
}
- if (add_preview)
+ if (add_preview) {
editor->get_scene_root()->add_child(preview_node);
+ }
}
void CanvasItemEditorViewport::_remove_preview() {
@@ -6104,20 +6161,21 @@ void CanvasItemEditorViewport::_perform_drop_data() {
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (texture != nullptr && texture.is_valid()) {
Node *child;
- if (default_type == "Light2D")
+ if (default_type == "Light2D") {
child = memnew(Light2D);
- else if (default_type == "GPUParticles2D")
+ } else if (default_type == "GPUParticles2D") {
child = memnew(GPUParticles2D);
- else if (default_type == "Polygon2D")
+ } else if (default_type == "Polygon2D") {
child = memnew(Polygon2D);
- else if (default_type == "TouchScreenButton")
+ } else if (default_type == "TouchScreenButton") {
child = memnew(TouchScreenButton);
- else if (default_type == "TextureRect")
+ } else if (default_type == "TextureRect") {
child = memnew(TextureRect);
- else if (default_type == "NinePatchRect")
+ } else if (default_type == "NinePatchRect") {
child = memnew(NinePatchRect);
- else
+ } else {
child = memnew(Sprite2D); // default
+ }
_create_nodes(target_node, child, path, drop_pos);
}
@@ -6203,7 +6261,6 @@ void CanvasItemEditorViewport::_show_resource_type_selector() {
}
bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
-
for (int i = 0; i < selected_files.size(); ++i) {
if (ResourceLoader::load(selected_files[i])->get_class() != "PackedScene") {
return false;
@@ -6222,8 +6279,9 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
if (d.has("type") && String(d["type"]) == "files") {
selected_files = d["files"];
}
- if (selected_files.size() == 0)
+ if (selected_files.size() == 0) {
return;
+ }
List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
if (list.size() == 0) {
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 9f1a92f563..765d5f81d0 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -43,15 +43,14 @@
class CanvasItemEditorViewport;
class CanvasItemEditorSelectedItem : public Object {
-
GDCLASS(CanvasItemEditorSelectedItem, Object);
public:
Transform2D prev_xform;
- float prev_rot;
+ float prev_rot = 0;
Rect2 prev_rect;
Vector2 prev_pivot;
- float prev_anchors[4];
+ float prev_anchors[4] = { 0.0f };
Transform2D pre_drag_xform;
Rect2 pre_drag_rect;
@@ -61,14 +60,10 @@ public:
Dictionary undo_state;
- CanvasItemEditorSelectedItem() :
- prev_anchors() {
- prev_rot = 0;
- }
+ CanvasItemEditorSelectedItem() {}
};
class CanvasItemEditor : public VBoxContainer {
-
GDCLASS(CanvasItemEditor, VBoxContainer);
public:
@@ -293,7 +288,6 @@ private:
MenuOption last_option;
struct _SelectResult {
-
CanvasItem *item;
float z_index;
bool has_z;
@@ -304,7 +298,6 @@ private:
Vector<_SelectResult> selection_results;
struct _HoverResult {
-
Point2 position;
Ref<Texture2D> icon;
String name;
@@ -312,14 +305,11 @@ private:
Vector<_HoverResult> hovering_results;
struct BoneList {
-
Transform2D xform;
- float length;
- uint64_t last_pass;
+ float length = 0.f;
+ uint64_t last_pass = 0;
- BoneList() :
- length(0.f),
- last_pass(0) {}
+ BoneList() {}
};
uint64_t bone_last_frame;
@@ -328,10 +318,11 @@ private:
ObjectID from;
ObjectID to;
_FORCE_INLINE_ bool operator<(const BoneKey &p_key) const {
- if (from == p_key.from)
+ if (from == p_key.from) {
return to < p_key.to;
- else
+ } else {
return from < p_key.from;
+ }
}
};
@@ -537,6 +528,7 @@ private:
VBoxContainer *controls_vb;
HBoxContainer *zoom_hb;
+ float _get_next_zoom_value(int p_increment_count) const;
void _zoom_on_position(float p_zoom, Point2 p_position = Point2());
void _update_zoom_label();
void _button_zoom_minus();
@@ -651,7 +643,6 @@ public:
};
class CanvasItemEditorPlugin : public EditorPlugin {
-
GDCLASS(CanvasItemEditorPlugin, EditorPlugin);
CanvasItemEditor *canvas_item_editor;
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 87e9987aa1..08d6fc966d 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -31,12 +31,10 @@
#include "collision_polygon_2d_editor_plugin.h"
Node2D *CollisionPolygon2DEditor::_get_node() const {
-
return node;
}
void CollisionPolygon2DEditor::_set_node(Node *p_polygon) {
-
node = Object::cast_to<CollisionPolygon2D>(p_polygon);
}
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h
index a4fa7c7b3b..b0be92db44 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/2d/collision_polygon_2d.h"
class CollisionPolygon2DEditor : public AbstractPolygon2DEditor {
-
GDCLASS(CollisionPolygon2DEditor, AbstractPolygon2DEditor);
CollisionPolygon2D *node;
@@ -49,7 +48,6 @@ public:
};
class CollisionPolygon2DEditorPlugin : public AbstractPolygon2DEditorPlugin {
-
GDCLASS(CollisionPolygon2DEditorPlugin, AbstractPolygon2DEditorPlugin);
public:
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
index 1cee1a040f..d9d9cf6a87 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
@@ -32,6 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/input/input.h"
+#include "core/math/geometry_2d.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "editor/editor_settings.h"
@@ -39,11 +40,8 @@
#include "scene/3d/camera_3d.h"
void CollisionPolygon3DEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
-
button_create->set_icon(get_theme_icon("Edit", "EditorIcons"));
button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
@@ -63,29 +61,26 @@ void CollisionPolygon3DEditor::_notification(int p_what) {
} break;
}
}
-void CollisionPolygon3DEditor::_node_removed(Node *p_node) {
+void CollisionPolygon3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = nullptr;
- if (imgeom->get_parent() == p_node)
+ if (imgeom->get_parent() == p_node) {
p_node->remove_child(imgeom);
+ }
hide();
set_process(false);
}
}
void CollisionPolygon3DEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MODE_CREATE: {
-
mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
} break;
case MODE_EDIT: {
-
mode = MODE_EDIT;
button_create->set_pressed(false);
button_edit->set_pressed(true);
@@ -94,7 +89,6 @@ void CollisionPolygon3DEditor::_menu_option(int p_option) {
}
void CollisionPolygon3DEditor::_wip_close() {
-
undo_redo->create_action(TTR("Create Polygon3D"));
undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon"));
undo_redo->add_do_method(node, "set_polygon", wip);
@@ -110,9 +104,9 @@ void CollisionPolygon3DEditor::_wip_close() {
}
bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
-
- if (!node)
+ if (!node) {
return false;
+ }
Transform gt = node->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -123,15 +117,15 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
Vector2 gpoint = mb->get_position();
Vector3 ray_from = p_camera->project_ray_origin(gpoint);
Vector3 ray_dir = p_camera->project_ray_normal(gpoint);
Vector3 spoint;
- if (!p.intersects_ray(ray_from, ray_dir, &spoint))
+ if (!p.intersects_ray(ray_from, ray_dir, &spoint)) {
return false;
+ }
spoint = gi.xform(spoint);
@@ -147,13 +141,9 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
switch (mode) {
-
case MODE_CREATE: {
-
if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
-
if (!wip_active) {
-
wip.clear();
wip.push_back(cpoint);
wip_active = true;
@@ -163,14 +153,12 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
edited_point = 1;
return true;
} else {
-
if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close();
return true;
} else {
-
wip.push_back(cpoint);
edited_point = wip.size();
snap_ignore = false;
@@ -185,14 +173,10 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
} break;
case MODE_EDIT: {
-
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
-
if (mb->get_control()) {
-
if (poly.size() < 3) {
-
undo_redo->create_action(TTR("Edit Poly"));
undo_redo->add_undo_method(node, "set_polygon", poly);
poly.push_back(cpoint);
@@ -208,15 +192,15 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
Vector2 closest_pos;
real_t closest_dist = 1e10;
for (int i = 0; i < poly.size(); i++) {
-
Vector2 points[2] = {
p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))),
p_camera->unproject_position(gt.xform(Vector3(poly[(i + 1) % poly.size()].x, poly[(i + 1) % poly.size()].y, depth)))
};
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points);
- if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2)
+ Vector2 cp = Geometry2D::get_closest_point_to_segment(gpoint, points);
+ if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2) {
continue; //not valid to reuse point
+ }
real_t d = cp.distance_to(gpoint);
if (d < closest_dist && d < grab_threshold) {
@@ -227,7 +211,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
if (closest_idx >= 0) {
-
pre_move_edit = poly;
poly.insert(closest_idx + 1, cpoint);
edited_point = closest_idx + 1;
@@ -239,14 +222,12 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
return true;
}
} else {
-
//look for points to move
int closest_idx = -1;
Vector2 closest_pos;
real_t closest_dist = 1e10;
for (int i = 0; i < poly.size(); i++) {
-
Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth)));
real_t d = cp.distance_to(gpoint);
@@ -258,7 +239,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
if (closest_idx >= 0) {
-
pre_move_edit = poly;
edited_point = closest_idx;
edited_point_pos = poly[closest_idx];
@@ -268,11 +248,9 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
}
} else {
-
snap_ignore = false;
if (edited_point != -1) {
-
//apply
ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
@@ -290,12 +268,10 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
}
if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && edited_point == -1) {
-
int closest_idx = -1;
Vector2 closest_pos;
real_t closest_dist = 1e10;
for (int i = 0; i < poly.size(); i++) {
-
Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth)));
real_t d = cp.distance_to(gpoint);
@@ -307,7 +283,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
if (closest_idx >= 0) {
-
undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
undo_redo->add_undo_method(node, "set_polygon", poly);
poly.remove(closest_idx);
@@ -327,7 +302,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
if (mm.is_valid()) {
if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) {
-
Vector2 gpoint = mm->get_position();
Vector3 ray_from = p_camera->project_ray_origin(gpoint);
@@ -335,8 +309,9 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
Vector3 spoint;
- if (!p.intersects_ray(ray_from, ray_dir, &spoint))
+ if (!p.intersects_ray(ray_from, ray_dir, &spoint)) {
return false;
+ }
spoint = gi.xform(spoint);
@@ -361,24 +336,25 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con
}
float CollisionPolygon3DEditor::_get_depth() {
-
- if (bool(node->call("_has_editable_3d_polygon_no_depth")))
+ if (bool(node->call("_has_editable_3d_polygon_no_depth"))) {
return 0;
+ }
return float(node->call("get_depth"));
}
void CollisionPolygon3DEditor::_polygon_draw() {
-
- if (!node)
+ if (!node) {
return;
+ }
Vector<Vector2> poly;
- if (wip_active)
+ if (wip_active) {
poly = wip;
- else
+ } else {
poly = node->call("get_polygon");
+ }
float depth = _get_depth() * 0.5;
@@ -389,18 +365,19 @@ void CollisionPolygon3DEditor::_polygon_draw() {
Rect2 rect;
for (int i = 0; i < poly.size(); i++) {
-
Vector2 p, p2;
p = i == edited_point ? edited_point_pos : poly[i];
- if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point))
+ if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point)) {
p2 = edited_point_pos;
- else
+ } else {
p2 = poly[(i + 1) % poly.size()];
+ }
- if (i == 0)
+ if (i == 0) {
rect.position = p;
- else
+ } else {
rect.expand_to(p);
+ }
Vector3 point = Vector3(p.x, p.y, depth);
Vector3 next_point = Vector3(p2.x, p2.y, depth);
@@ -465,18 +442,17 @@ void CollisionPolygon3DEditor::_polygon_draw() {
m->clear_surfaces();
- if (poly.size() == 0)
+ if (poly.size() == 0) {
return;
+ }
Array a;
a.resize(Mesh::ARRAY_MAX);
Vector<Vector3> va;
{
-
va.resize(poly.size());
Vector3 *w = va.ptrw();
for (int i = 0; i < poly.size(); i++) {
-
Vector2 p, p2;
p = i == edited_point ? edited_point_pos : poly[i];
@@ -490,9 +466,7 @@ void CollisionPolygon3DEditor::_polygon_draw() {
}
void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) {
-
if (p_collision_polygon) {
-
node = Object::cast_to<Node3D>(p_collision_polygon);
//Enable the pencil tool if the polygon is empty
if (Vector<Vector2>(node->call("get_polygon")).size() == 0) {
@@ -509,20 +483,19 @@ void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) {
} else {
node = nullptr;
- if (imgeom->get_parent())
+ if (imgeom->get_parent()) {
imgeom->get_parent()->remove_child(imgeom);
+ }
set_process(false);
}
}
void CollisionPolygon3DEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygon3DEditor::_polygon_draw);
}
CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
-
node = nullptr;
editor = p_editor;
undo_redo = EditorNode::get_undo_redo();
@@ -570,33 +543,27 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
}
CollisionPolygon3DEditor::~CollisionPolygon3DEditor() {
-
memdelete(imgeom);
}
void Polygon3DEditorPlugin::edit(Object *p_object) {
-
collision_polygon_editor->edit(Object::cast_to<Node>(p_object));
}
bool Polygon3DEditorPlugin::handles(Object *p_object) const {
-
return Object::cast_to<Node3D>(p_object) && bool(p_object->call("_is_editable_3d_polygon"));
}
void Polygon3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
collision_polygon_editor->show();
} else {
-
collision_polygon_editor->hide();
collision_polygon_editor->edit(nullptr);
}
}
Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
collision_polygon_editor = memnew(CollisionPolygon3DEditor(p_node));
Node3DEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.h b/editor/plugins/collision_polygon_3d_editor_plugin.h
index 9751b1f79e..5215cbb678 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.h
@@ -41,7 +41,6 @@
class CanvasItemEditor;
class CollisionPolygon3DEditor : public HBoxContainer {
-
GDCLASS(CollisionPolygon3DEditor, HBoxContainer);
UndoRedo *undo_redo;
@@ -97,7 +96,6 @@ public:
};
class Polygon3DEditorPlugin : public EditorPlugin {
-
GDCLASS(Polygon3DEditorPlugin, EditorPlugin);
CollisionPolygon3DEditor *collision_polygon_editor;
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 8973dca963..596629f8e8 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -36,18 +36,17 @@
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "scene/resources/line_shape_2d.h"
+#include "scene/resources/ray_shape_2d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/segment_shape_2d.h"
void CollisionShape2DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
}
}
Variant CollisionShape2DEditor::get_handle_value(int idx) const {
-
switch (shape_type) {
case CAPSULE_SHAPE: {
Ref<CapsuleShape2D> capsule = node->get_shape();
@@ -70,11 +69,9 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
} break;
case CONCAVE_POLYGON_SHAPE: {
-
} break;
case CONVEX_POLYGON_SHAPE: {
-
} break;
case LINE_SHAPE: {
@@ -122,7 +119,6 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
}
void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
-
switch (shape_type) {
case CAPSULE_SHAPE: {
if (idx < 2) {
@@ -150,11 +146,9 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
} break;
case CONCAVE_POLYGON_SHAPE: {
-
} break;
case CONVEX_POLYGON_SHAPE: {
-
} break;
case LINE_SHAPE: {
@@ -217,7 +211,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
}
void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
-
undo_redo->create_action(TTR("Set Handle"));
switch (shape_type) {
@@ -249,11 +242,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
} break;
case CONCAVE_POLYGON_SHAPE: {
-
} break;
case CONVEX_POLYGON_SHAPE: {
-
} break;
case LINE_SHAPE: {
@@ -314,7 +305,6 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
}
bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
-
if (!node) {
return false;
}
@@ -331,7 +321,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
if (mb.is_valid()) {
-
Vector2 gpoint = mb->get_position();
if (mb->get_button_index() == BUTTON_LEFT) {
@@ -373,7 +362,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (edit_handle == -1 || !pressed) {
return false;
}
@@ -390,7 +378,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
}
void CollisionShape2DEditor::_get_current_shape_type() {
-
if (!node) {
return;
}
@@ -425,7 +412,6 @@ void CollisionShape2DEditor::_get_current_shape_type() {
}
void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
-
if (!node) {
return;
}
@@ -474,11 +460,9 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
} break;
case CONCAVE_POLYGON_SHAPE: {
-
} break;
case CONVEX_POLYGON_SHAPE: {
-
} break;
case LINE_SHAPE: {
@@ -533,9 +517,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
}
void CollisionShape2DEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
get_tree()->connect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed));
} break;
@@ -547,7 +529,6 @@ void CollisionShape2DEditor::_notification(int p_what) {
}
void CollisionShape2DEditor::edit(Node *p_node) {
-
if (!canvas_item_editor) {
canvas_item_editor = CanvasItemEditor::get_singleton();
}
@@ -568,12 +549,10 @@ void CollisionShape2DEditor::edit(Node *p_node) {
}
void CollisionShape2DEditor::_bind_methods() {
-
ClassDB::bind_method("_get_current_shape_type", &CollisionShape2DEditor::_get_current_shape_type);
}
CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) {
-
node = nullptr;
canvas_item_editor = nullptr;
editor = p_editor;
@@ -585,24 +564,20 @@ CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) {
}
void CollisionShape2DEditorPlugin::edit(Object *p_obj) {
-
collision_shape_2d_editor->edit(Object::cast_to<Node>(p_obj));
}
bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const {
-
return p_obj->is_class("CollisionShape2D");
}
void CollisionShape2DEditorPlugin::make_visible(bool visible) {
-
if (!visible) {
edit(nullptr);
}
}
CollisionShape2DEditorPlugin::CollisionShape2DEditorPlugin(EditorNode *p_editor) {
-
editor = p_editor;
collision_shape_2d_editor = memnew(CollisionShape2DEditor(p_editor));
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index ef4d7d7646..008de7cfb4 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -37,53 +37,42 @@
#include "scene/resources/particles_material.h"
void CPUParticles2DEditorPlugin::edit(Object *p_object) {
-
particles = Object::cast_to<CPUParticles2D>(p_object);
}
bool CPUParticles2DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("CPUParticles2D");
}
void CPUParticles2DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
toolbar->show();
} else {
-
toolbar->hide();
}
}
void CPUParticles2DEditorPlugin::_file_selected(const String &p_file) {
-
source_emission_file = p_file;
emission_mask->popup_centered();
}
void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
-
switch (p_idx) {
case MENU_LOAD_EMISSION_MASK: {
-
file->popup_centered_ratio();
} break;
case MENU_CLEAR_EMISSION_MASK: {
-
emission_mask->popup_centered();
} break;
case MENU_RESTART: {
-
particles->restart();
}
}
}
void CPUParticles2DEditorPlugin::_generate_emission_mask() {
-
Ref<Image> img;
img.instance();
Error err = ImageLoader::load_image(source_emission_file, img);
@@ -123,13 +112,10 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
for (int i = 0; i < s.width; i++) {
for (int j = 0; j < s.height; j++) {
-
uint8_t a = r[(j * s.width + i) * 4 + 3];
if (a > 128) {
-
if (emode == EMISSION_MODE_SOLID) {
-
if (capture_colors) {
valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0];
valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1];
@@ -139,19 +125,18 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
valid_positions.write[vpc++] = Point2(i, j);
} else {
-
bool on_border = false;
for (int x = i - 1; x <= i + 1; x++) {
for (int y = j - 1; y <= j + 1; y++) {
-
if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) {
on_border = true;
break;
}
}
- if (on_border)
+ if (on_border) {
break;
+ }
}
if (on_border) {
@@ -161,9 +146,9 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
Vector2 normal;
for (int x = i - 2; x <= i + 2; x++) {
for (int y = j - 2; y <= j + 2; y++) {
-
- if (x == i && y == j)
+ if (x == i && y == j) {
continue;
+ }
if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) {
normal += Vector2(x - i, y - j).normalized();
@@ -237,9 +222,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() {
}
void CPUParticles2DEditorPlugin::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback));
menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons"));
file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected));
@@ -250,7 +233,6 @@ void CPUParticles2DEditorPlugin::_bind_methods() {
}
CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
-
particles = nullptr;
editor = p_node;
undo_redo = editor->get_undo_redo();
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h
index 21b06b6489..fecbb8b1cd 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.h
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.h
@@ -39,7 +39,6 @@
#include "scene/gui/file_dialog.h"
class CPUParticles2DEditorPlugin : public EditorPlugin {
-
GDCLASS(CPUParticles2DEditorPlugin, EditorPlugin);
enum {
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
index 59a353a581..ef26ecd767 100644
--- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
@@ -33,7 +33,6 @@
#include "editor/plugins/node_3d_editor_plugin.h"
void CPUParticles3DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
hide();
@@ -41,24 +40,19 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) {
}
void CPUParticles3DEditor::_notification(int p_notification) {
-
if (p_notification == NOTIFICATION_ENTER_TREE) {
options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons"));
}
}
void CPUParticles3DEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
-
emission_tree_dialog->popup_centered_ratio();
} break;
case MENU_OPTION_RESTART: {
-
node->restart();
} break;
@@ -66,13 +60,11 @@ void CPUParticles3DEditor::_menu_option(int p_option) {
}
void CPUParticles3DEditor::edit(CPUParticles3D *p_particles) {
-
base_node = p_particles;
node = p_particles;
}
void CPUParticles3DEditor::_generate_emission_points() {
-
/// hacer codigo aca
Vector<Vector3> points;
Vector<Vector3> normals;
@@ -95,7 +87,6 @@ void CPUParticles3DEditor::_bind_methods() {
}
CPUParticles3DEditor::CPUParticles3DEditor() {
-
particles_editor_hb = memnew(HBoxContainer);
Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
options = memnew(MenuButton);
@@ -110,17 +101,14 @@ CPUParticles3DEditor::CPUParticles3DEditor() {
}
void CPUParticles3DEditorPlugin::edit(Object *p_object) {
-
particles_editor->edit(Object::cast_to<CPUParticles3D>(p_object));
}
bool CPUParticles3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("CPUParticles3D");
}
void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
particles_editor->show();
particles_editor->particles_editor_hb->show();
@@ -132,7 +120,6 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {
}
CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
particles_editor = memnew(CPUParticles3DEditor);
editor->get_viewport()->add_child(particles_editor);
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h
index 796c842e07..d9680496ba 100644
--- a/editor/plugins/cpu_particles_3d_editor_plugin.h
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/3d/cpu_particles_3d.h"
class CPUParticles3DEditor : public GPUParticles3DEditorBase {
-
GDCLASS(CPUParticles3DEditor, GPUParticles3DEditorBase);
enum Menu {
@@ -65,7 +64,6 @@ public:
};
class CPUParticles3DEditorPlugin : public EditorPlugin {
-
GDCLASS(CPUParticles3DEditorPlugin, EditorPlugin);
CPUParticles3DEditor *particles_editor;
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 9b5c6bae3b..539ab03f5b 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -65,9 +65,9 @@ CurveEditor::CurveEditor() {
}
void CurveEditor::set_curve(Ref<Curve> curve) {
-
- if (curve == _curve_ref)
+ if (curve == _curve_ref) {
return;
+ }
if (_curve_ref.is_valid()) {
_curve_ref->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveEditor::_curve_changed));
@@ -96,24 +96,23 @@ Size2 CurveEditor::get_minimum_size() const {
}
void CurveEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW)
+ if (p_what == NOTIFICATION_DRAW) {
_draw();
+ }
}
void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb_ref = p_event;
if (mb_ref.is_valid()) {
-
const InputEventMouseButton &mb = **mb_ref;
if (mb.is_pressed() && !_dragging) {
-
Vector2 mpos = mb.get_position();
_selected_tangent = get_tangent_at(mpos);
- if (_selected_tangent == TANGENT_NONE)
+ if (_selected_tangent == TANGENT_NONE) {
set_selected_point(get_point_at(mpos));
+ }
switch (mb.get_button_index()) {
case BUTTON_RIGHT:
@@ -134,7 +133,6 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
if (!mb.is_pressed() && _dragging && mb.get_button_index() == BUTTON_LEFT) {
_dragging = false;
if (_has_undo_data) {
-
UndoRedo &ur = *EditorNode::get_singleton()->get_undo_redo();
ur.create_action(_selected_tangent == TANGENT_NONE ? TTR("Modify Curve Point") : TTR("Modify Curve Tangent"));
@@ -151,13 +149,11 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm_ref = p_event;
if (mm_ref.is_valid()) {
-
const InputEventMouseMotion &mm = **mm_ref;
Vector2 mpos = mm.get_position();
if (_dragging && _curve_ref.is_valid()) {
-
if (_selected_point != -1) {
Curve &curve = **_curve_ref;
@@ -189,10 +185,11 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
set_selected_point(i);
// This is to prevent the user from losing a point out of view.
- if (point_pos.y < curve.get_min_value())
+ if (point_pos.y < curve.get_min_value()) {
point_pos.y = curve.get_min_value();
- else if (point_pos.y > curve.get_max_value())
+ } else if (point_pos.y > curve.get_max_value()) {
point_pos.y = curve.get_max_value();
+ }
curve.set_point_value(_selected_point, point_pos.y);
@@ -205,10 +202,11 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
Vector2 dir = (control_pos - point_pos).normalized();
real_t tangent;
- if (!Math::is_zero_approx(dir.x))
+ if (!Math::is_zero_approx(dir.x)) {
tangent = dir.y / dir.x;
- else
+ } else {
tangent = 9999 * (dir.y >= 0 ? 1 : -1);
+ }
bool link = !Input::get_singleton()->is_key_pressed(KEY_SHIFT);
@@ -216,14 +214,16 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
curve.set_point_left_tangent(_selected_point, tangent);
// Note: if a tangent is set to linear, it shouldn't be linked to the other
- if (link && _selected_point != (curve.get_point_count() - 1) && curve.get_point_right_mode(_selected_point) != Curve::TANGENT_LINEAR)
+ if (link && _selected_point != (curve.get_point_count() - 1) && curve.get_point_right_mode(_selected_point) != Curve::TANGENT_LINEAR) {
curve.set_point_right_tangent(_selected_point, tangent);
+ }
} else {
curve.set_point_right_tangent(_selected_point, tangent);
- if (link && _selected_point != 0 && curve.get_point_left_mode(_selected_point) != Curve::TANGENT_LINEAR)
+ if (link && _selected_point != 0 && curve.get_point_left_mode(_selected_point) != Curve::TANGENT_LINEAR) {
curve.set_point_left_tangent(_selected_point, tangent);
+ }
}
}
}
@@ -238,8 +238,9 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
const InputEventKey &key = **key_ref;
if (key.is_pressed() && _selected_point != -1) {
- if (key.get_keycode() == KEY_DELETE)
+ if (key.get_keycode() == KEY_DELETE) {
remove_point(_selected_point);
+ }
}
}
}
@@ -358,8 +359,9 @@ void CurveEditor::open_context_menu(Vector2 pos) {
_context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_LINEAR), is_linear);
} else {
- if (_selected_point > 0 || _selected_point + 1 < _curve_ref->get_point_count())
+ if (_selected_point > 0 || _selected_point + 1 < _curve_ref->get_point_count()) {
_context_menu->add_separator();
+ }
if (_selected_point > 0) {
_context_menu->add_check_item(TTR("Left Linear"), CONTEXT_LEFT_LINEAR);
@@ -384,8 +386,9 @@ void CurveEditor::open_context_menu(Vector2 pos) {
}
int CurveEditor::get_point_at(Vector2 pos) const {
- if (_curve_ref.is_null())
+ if (_curve_ref.is_null()) {
return -1;
+ }
const Curve &curve = **_curve_ref;
const float r = _hover_radius * _hover_radius;
@@ -401,8 +404,9 @@ int CurveEditor::get_point_at(Vector2 pos) const {
}
CurveEditor::TangentIndex CurveEditor::get_tangent_at(Vector2 pos) const {
- if (_curve_ref.is_null() || _selected_point < 0)
+ if (_curve_ref.is_null() || _selected_point < 0) {
return TANGENT_NONE;
+ }
if (_selected_point != 0) {
Vector2 control_pos = get_tangent_view_pos(_selected_point, TANGENT_LEFT);
@@ -428,10 +432,11 @@ void CurveEditor::add_point(Vector2 pos) {
ur.create_action(TTR("Remove Curve Point"));
Vector2 point_pos = get_world_pos(pos);
- if (point_pos.y < 0.0)
+ if (point_pos.y < 0.0) {
point_pos.y = 0.0;
- else if (point_pos.y > 1.0)
+ } else if (point_pos.y > 1.0) {
point_pos.y = 1.0;
+ }
// Small trick to get the point index to feed the undo method
int i = _curve_ref->add_point(point_pos);
@@ -454,11 +459,13 @@ void CurveEditor::remove_point(int index) {
ur.add_do_method(*_curve_ref, "remove_point", index);
ur.add_undo_method(*_curve_ref, "add_point", p.pos, p.left_tangent, p.right_tangent, p.left_mode, p.right_mode);
- if (index == _selected_point)
+ if (index == _selected_point) {
set_selected_point(-1);
+ }
- if (index == _hover_point)
+ if (index == _hover_point) {
set_hover_point_index(-1);
+ }
ur.commit_action();
}
@@ -469,11 +476,11 @@ void CurveEditor::toggle_linear(TangentIndex tangent) {
UndoRedo &ur = *EditorNode::get_singleton()->get_undo_redo();
ur.create_action(TTR("Toggle Curve Linear Tangent"));
- if (tangent == TANGENT_NONE)
+ if (tangent == TANGENT_NONE) {
tangent = _selected_tangent;
+ }
if (tangent == TANGENT_LEFT) {
-
bool is_linear = _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR;
Curve::TangentMode prev_mode = _curve_ref->get_point_left_mode(_selected_point);
@@ -483,7 +490,6 @@ void CurveEditor::toggle_linear(TangentIndex tangent) {
ur.add_undo_method(*_curve_ref, "set_point_left_mode", _selected_point, prev_mode);
} else {
-
bool is_linear = _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
Curve::TangentMode prev_mode = _curve_ref->get_point_right_mode(_selected_point);
@@ -538,12 +544,12 @@ void CurveEditor::update_view_transform() {
}
Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const {
-
Vector2 dir;
- if (tangent == TANGENT_LEFT)
+ if (tangent == TANGENT_LEFT) {
dir = -Vector2(1, _curve_ref->get_point_left_tangent(i));
- else
+ } else {
dir = Vector2(1, _curve_ref->get_point_right_tangent(i));
+ }
Vector2 point_pos = get_view_pos(_curve_ref->get_point_position(i));
Vector2 control_pos = get_view_pos(_curve_ref->get_point_position(i) + dir);
@@ -562,7 +568,6 @@ Vector2 CurveEditor::get_world_pos(Vector2 view_pos) const {
// Uses non-baked points, but takes advantage of ordered iteration to be faster
template <typename T>
static void plot_curve_accurate(const Curve &curve, float step, T plot_func) {
-
if (curve.get_point_count() <= 1) {
// Not enough points to make a curve, so it's just a straight line
float y = curve.interpolate(0);
@@ -600,7 +605,6 @@ static void plot_curve_accurate(const Curve &curve, float step, T plot_func) {
}
struct CanvasItemPlotCurve {
-
CanvasItem &ci;
Color color1;
Color color2;
@@ -617,8 +621,9 @@ struct CanvasItemPlotCurve {
};
void CurveEditor::_draw() {
- if (_curve_ref.is_null())
+ if (_curve_ref.is_null()) {
return;
+ }
Curve &curve = **_curve_ref;
update_view_transform();
@@ -685,7 +690,6 @@ void CurveEditor::_draw() {
// Draw tangents for current point
if (_selected_point >= 0) {
-
const Color tangent_color = get_theme_color("accent_color", "Editor");
int i = _selected_point;
@@ -754,12 +758,10 @@ void CurveEditor::_bind_methods() {
//---------------
bool EditorInspectorPluginCurve::can_handle(Object *p_object) {
-
return Object::cast_to<Curve>(p_object) != nullptr;
}
void EditorInspectorPluginCurve::parse_begin(Object *p_object) {
-
Curve *curve = Object::cast_to<Curve>(p_object);
ERR_FAIL_COND(!curve);
Ref<Curve> c(curve);
@@ -785,7 +787,6 @@ bool CurvePreviewGenerator::handles(const String &p_type) const {
}
Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
-
Ref<Curve> curve_ref = p_from;
ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture2D>(), "It's not a reference to a valid Resource object.");
Curve &curve = **curve_ref;
@@ -797,7 +798,7 @@ Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, cons
img_ref.instance();
Image &im = **img_ref;
- im.create(thumbnail_size, thumbnail_size / 2, 0, Image::FORMAT_RGBA8);
+ im.create(thumbnail_size, thumbnail_size / 2, false, Image::FORMAT_RGBA8);
Color bg_color(0.1, 0.1, 0.1, 1.0);
for (int i = 0; i < thumbnail_size; i++) {
@@ -811,7 +812,6 @@ Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, cons
int prev_y = 0;
for (int x = 0; x < im.get_width(); ++x) {
-
float t = static_cast<float>(x) / im.get_width();
float v = (curve.interpolate_baked(t) - curve.get_min_value()) / range_y;
int y = CLAMP(im.get_height() - v * im.get_height(), 0, im.get_height());
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index e0d345663c..0a4d173923 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -68,13 +68,10 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
p->add_check_shortcut(ED_SHORTCUT("editor/visible_navigation", TTR("Visible Navigation")), RUN_DEBUG_NAVIGATION);
p->set_item_tooltip(p->get_item_count() - 1, TTR("Navigation meshes and polygons will be visible on the running game if this option is turned on."));
p->add_separator();
- //those are now on by default, since they are harmless
p->add_check_shortcut(ED_SHORTCUT("editor/sync_scene_changes", TTR("Sync Scene Changes")), RUN_LIVE_DEBUG);
p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any changes made to the scene in the editor will be replicated in the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->set_item_checked(p->get_item_count() - 1, true);
p->add_check_shortcut(ED_SHORTCUT("editor/sync_script_changes", TTR("Sync Script Changes")), RUN_RELOAD_SCRIPTS);
p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any script that is saved will be reloaded on the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->set_item_checked(p->get_item_count() - 1, true);
// Multi-instance, start/stop
instances_menu = memnew(PopupMenu);
@@ -114,7 +111,6 @@ void DebuggerEditorPlugin::_select_run_count(int p_index) {
void DebuggerEditorPlugin::_menu_option(int p_option) {
switch (p_option) {
case RUN_FILE_SERVER: {
-
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER));
if (ischecked) {
@@ -128,7 +124,6 @@ void DebuggerEditorPlugin::_menu_option(int p_option) {
} break;
case RUN_LIVE_DEBUG: {
-
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG));
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG), !ischecked);
@@ -137,28 +132,24 @@ void DebuggerEditorPlugin::_menu_option(int p_option) {
} break;
case RUN_DEPLOY_REMOTE_DEBUG: {
-
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked);
} break;
case RUN_DEBUG_COLLISONS: {
-
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_COLLISONS));
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_COLLISONS), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisons", !ischecked);
} break;
case RUN_DEBUG_NAVIGATION: {
-
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION));
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked);
} break;
case RUN_RELOAD_SCRIPTS: {
-
bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS));
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked);
@@ -170,8 +161,9 @@ void DebuggerEditorPlugin::_menu_option(int p_option) {
}
void DebuggerEditorPlugin::_notification(int p_what) {
- if (p_what == NOTIFICATION_READY)
+ if (p_what == NOTIFICATION_READY) {
_update_debug_options();
+ }
}
void DebuggerEditorPlugin::_update_debug_options() {
@@ -179,22 +171,28 @@ void DebuggerEditorPlugin::_update_debug_options() {
bool check_file_server = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false);
bool check_debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
bool check_debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false);
- bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", false);
- bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", false);
+ bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", true);
+ bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", true);
int instances = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_instances", 1);
- if (check_deploy_remote)
+ if (check_deploy_remote) {
_menu_option(RUN_DEPLOY_REMOTE_DEBUG);
- if (check_file_server)
+ }
+ if (check_file_server) {
_menu_option(RUN_FILE_SERVER);
- if (check_debug_collisions)
+ }
+ if (check_debug_collisions) {
_menu_option(RUN_DEBUG_COLLISONS);
- if (check_debug_navigation)
+ }
+ if (check_debug_navigation) {
_menu_option(RUN_DEBUG_NAVIGATION);
- if (check_live_debug)
+ }
+ if (check_live_debug) {
_menu_option(RUN_LIVE_DEBUG);
- if (check_reload_scripts)
+ }
+ if (check_reload_scripts) {
_menu_option(RUN_RELOAD_SCRIPTS);
+ }
int len = instances_menu->get_item_count();
for (int idx = 0; idx < len; idx++) {
diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h
index 5ec6399921..465041b5a7 100644
--- a/editor/plugins/debugger_editor_plugin.h
+++ b/editor/plugins/debugger_editor_plugin.h
@@ -39,7 +39,6 @@ class MenuButton;
class PopupMenu;
class DebuggerEditorPlugin : public EditorPlugin {
-
GDCLASS(DebuggerEditorPlugin, EditorPlugin);
private:
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index a8c4bddccf..9cb167b41c 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -43,9 +43,9 @@
#include "servers/audio/audio_stream.h"
void post_process_preview(Ref<Image> p_image) {
-
- if (p_image->get_format() != Image::FORMAT_RGBA8)
+ if (p_image->get_format() != Image::FORMAT_RGBA8) {
p_image->convert(Image::FORMAT_RGBA8);
+ }
const int w = p_image->get_width();
const int h = p_image->get_height();
@@ -71,7 +71,6 @@ void post_process_preview(Ref<Image> p_image) {
}
bool EditorTexturePreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "Texture2D");
}
@@ -80,7 +79,6 @@ bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const {
}
Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<Image> img;
Ref<AtlasTexture> atex = p_from;
Ref<LargeTexture> ltex = p_from;
@@ -108,14 +106,16 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Siz
}
}
- if (img.is_null() || img->empty())
+ if (img.is_null() || img->empty()) {
return Ref<Texture2D>();
+ }
img->clear_mipmaps();
if (img->is_compressed()) {
- if (img->decompress() != OK)
+ if (img->decompress() != OK) {
return Ref<Texture2D>();
+ }
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@@ -143,23 +143,23 @@ EditorTexturePreviewPlugin::EditorTexturePreviewPlugin() {
////////////////////////////////////////////////////////////////////////////
bool EditorImagePreviewPlugin::handles(const String &p_type) const {
-
return p_type == "Image";
}
Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<Image> img = p_from;
- if (img.is_null() || img->empty())
+ if (img.is_null() || img->empty()) {
return Ref<Image>();
+ }
img = img->duplicate();
img->clear_mipmaps();
if (img->is_compressed()) {
- if (img->decompress() != OK)
+ if (img->decompress() != OK) {
return Ref<Image>();
+ }
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@@ -188,15 +188,14 @@ EditorImagePreviewPlugin::EditorImagePreviewPlugin() {
bool EditorImagePreviewPlugin::generate_small_preview_automatically() const {
return true;
}
+
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////
bool EditorBitmapPreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "BitMap");
}
Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<BitMap> bm = p_from;
if (bm->get_size() == Size2()) {
@@ -223,11 +222,12 @@ Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size
Ref<Image> img;
img.instance();
- img->create(bm->get_size().width, bm->get_size().height, 0, Image::FORMAT_L8, data);
+ img->create(bm->get_size().width, bm->get_size().height, false, Image::FORMAT_L8, data);
if (img->is_compressed()) {
- if (img->decompress() != OK)
+ if (img->decompress() != OK) {
return Ref<Texture2D>();
+ }
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@@ -259,17 +259,14 @@ EditorBitmapPreviewPlugin::EditorBitmapPreviewPlugin() {
///////////////////////////////////////////////////////////////////////////
bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "PackedScene");
}
Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
return generate_from_path(p_from->get_path(), p_size);
}
Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
-
String temp_path = EditorSettings::get_singleton()->get_cache_dir();
String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text();
cache_base = temp_path.plus_file("resthumb-" + cache_base);
@@ -278,14 +275,14 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
String path = cache_base + ".png";
- if (!FileAccess::exists(path))
+ if (!FileAccess::exists(path)) {
return Ref<Texture2D>();
+ }
Ref<Image> img;
img.instance();
Error err = img->load(path);
if (err == OK) {
-
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
post_process_preview(img);
@@ -303,17 +300,14 @@ EditorPackedScenePreviewPlugin::EditorPackedScenePreviewPlugin() {
//////////////////////////////////////////////////////////////////
void EditorMaterialPreviewPlugin::_preview_done(const Variant &p_udata) {
-
preview_done = true;
}
void EditorMaterialPreviewPlugin::_bind_methods() {
-
ClassDB::bind_method("_preview_done", &EditorMaterialPreviewPlugin::_preview_done);
}
bool EditorMaterialPreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "Material"); //any material
}
@@ -322,12 +316,10 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const {
}
Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<Material> material = p_from;
ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>());
if (material->get_shader_mode() == Shader::MODE_SPATIAL) {
-
RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid());
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture
@@ -357,7 +349,6 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si
}
EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
-
scenario = RS::get_singleton()->scenario_create();
viewport = RS::get_singleton()->viewport_create();
@@ -408,7 +399,6 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
double zr1 = Math::cos(lat1);
for (int j = lons; j >= 1; j--) {
-
double lng0 = 2 * Math_PI * (double)(j - 1) / lons;
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
@@ -462,7 +452,6 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
}
EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() {
-
RS::get_singleton()->free(sphere);
RS::get_singleton()->free(sphere_instance);
RS::get_singleton()->free(viewport);
@@ -477,24 +466,23 @@ EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() {
///////////////////////////////////////////////////////////////////////////
static bool _is_text_char(CharType c) {
-
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
bool EditorScriptPreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "Script");
}
Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<Script> scr = p_from;
- if (scr.is_null())
+ if (scr.is_null()) {
return Ref<Texture2D>();
+ }
String code = scr->get_source_code().strip_edges();
- if (code == "")
+ if (code == "") {
return Ref<Texture2D>();
+ }
List<String> kwors;
scr->get_language()->get_reserved_words(&kwors);
@@ -502,7 +490,6 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
Set<String> keywords;
for (List<String>::Element *E = kwors.front(); E; E = E->next()) {
-
keywords.insert(E->get());
}
@@ -511,15 +498,16 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
Ref<Image> img;
img.instance();
int thumbnail_size = MAX(p_size.x, p_size.y);
- img->create(thumbnail_size, thumbnail_size, 0, Image::FORMAT_RGBA8);
+ img->create(thumbnail_size, thumbnail_size, false, Image::FORMAT_RGBA8);
Color bg_color = EditorSettings::get_singleton()->get("text_editor/highlighting/background_color");
Color keyword_color = EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color");
Color text_color = EditorSettings::get_singleton()->get("text_editor/highlighting/text_color");
Color symbol_color = EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color");
- if (bg_color.a == 0)
+ if (bg_color.a == 0) {
bg_color = Color(0, 0, 0, 0);
+ }
bg_color.a = MAX(bg_color.a, 0.2); // some background
for (int i = 0; i < thumbnail_size; i++) {
@@ -536,7 +524,6 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
bool prev_is_text = false;
bool in_keyword = false;
for (int i = 0; i < code.length(); i++) {
-
CharType c = code[i];
if (c > 32) {
if (col < thumbnail_size) {
@@ -553,15 +540,17 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
pos++;
}
String word = code.substr(i, pos - i);
- if (keywords.has(word))
+ if (keywords.has(word)) {
in_keyword = true;
+ }
} else if (!_is_text_char(c)) {
in_keyword = false;
}
- if (in_keyword)
+ if (in_keyword) {
color = keyword_color;
+ }
Color ul = color;
ul.a *= 0.5;
@@ -571,15 +560,15 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
prev_is_text = _is_text_char(c);
}
} else {
-
prev_is_text = false;
in_keyword = false;
if (c == '\n') {
col = x0;
line++;
- if (line >= available_height / 2)
+ if (line >= available_height / 2) {
break;
+ }
} else if (c == '\t') {
col += 3;
}
@@ -597,15 +586,14 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() {
}
+
///////////////////////////////////////////////////////////////////
bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "AudioStream");
}
Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<AudioStream> stream = p_from;
ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>());
@@ -635,7 +623,6 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const
playback->stop();
for (int i = 0; i < w; i++) {
-
float max = -1000;
float min = 1000;
int from = uint64_t(i) * frame_length / w;
@@ -647,7 +634,6 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const
}
for (int j = from; j < to; j++) {
-
max = MAX(max, frames[j].l);
max = MAX(max, frames[j].r);
@@ -688,21 +674,18 @@ EditorAudioStreamPreviewPlugin::EditorAudioStreamPreviewPlugin() {
///////////////////////////////////////////////////////////////////////////
void EditorMeshPreviewPlugin::_preview_done(const Variant &p_udata) {
-
preview_done = true;
}
void EditorMeshPreviewPlugin::_bind_methods() {
-
ClassDB::bind_method("_preview_done", &EditorMeshPreviewPlugin::_preview_done);
}
-bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
+bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh
}
Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
Ref<Mesh> mesh = p_from;
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>());
@@ -716,8 +699,9 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis;
AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
- if (m == 0)
+ if (m == 0) {
return Ref<Texture2D>();
+ }
m = 1.0 / m;
m *= 0.5;
xform.basis.scale(Vector3(m, m, m));
@@ -758,7 +742,6 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
}
EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
-
scenario = RS::get_singleton()->scenario_create();
viewport = RS::get_singleton()->viewport_create();
@@ -792,7 +775,6 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
}
EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() {
-
//RS::get_singleton()->free(sphere);
RS::get_singleton()->free(mesh_instance);
RS::get_singleton()->free(viewport);
@@ -807,22 +789,18 @@ EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() {
///////////////////////////////////////////////////////////////////////////
void EditorFontPreviewPlugin::_preview_done(const Variant &p_udata) {
-
preview_done = true;
}
void EditorFontPreviewPlugin::_bind_methods() {
-
ClassDB::bind_method("_preview_done", &EditorFontPreviewPlugin::_preview_done);
}
bool EditorFontPreviewPlugin::handles(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont");
}
Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
-
RES res = ResourceLoader::load(p_path);
Ref<DynamicFont> sampled_font;
if (res->is_class("DynamicFont")) {
@@ -881,7 +859,6 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path,
}
Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
-
String path = p_from->get_path();
if (!FileAccess::exists(path)) {
return Ref<Texture2D>();
@@ -890,7 +867,6 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2
}
EditorFontPreviewPlugin::EditorFontPreviewPlugin() {
-
viewport = RS::get_singleton()->viewport_create();
RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED);
RS::get_singleton()->viewport_set_size(viewport, 128, 128);
@@ -905,7 +881,6 @@ EditorFontPreviewPlugin::EditorFontPreviewPlugin() {
}
EditorFontPreviewPlugin::~EditorFontPreviewPlugin() {
-
RS::get_singleton()->free(canvas_item);
RS::get_singleton()->free(canvas);
RS::get_singleton()->free(viewport);
diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h
index 840fa2410a..8a9d6a93fb 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -69,7 +69,6 @@ public:
};
class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
-
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
@@ -79,7 +78,6 @@ public:
};
class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
-
GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator);
RID scenario;
@@ -125,7 +123,6 @@ public:
};
class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
-
GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator);
RID scenario;
@@ -153,7 +150,6 @@ public:
};
class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {
-
GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator);
RID viewport;
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index 6a171c4703..94f771e643 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -31,7 +31,6 @@
#include "gi_probe_editor_plugin.h"
void GIProbeEditorPlugin::_bake() {
-
if (gi_probe) {
if (gi_probe->get_probe_data().is_null()) {
String path = get_tree()->get_edited_scene_root()->get_filename();
@@ -50,21 +49,19 @@ void GIProbeEditorPlugin::_bake() {
}
void GIProbeEditorPlugin::edit(Object *p_object) {
-
GIProbe *s = Object::cast_to<GIProbe>(p_object);
- if (!s)
+ if (!s) {
return;
+ }
gi_probe = s;
}
bool GIProbeEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("GIProbe");
}
void GIProbeEditorPlugin::_notification(int p_what) {
-
if (p_what == NOTIFICATION_PROCESS) {
if (!gi_probe) {
return;
@@ -102,12 +99,10 @@ void GIProbeEditorPlugin::_notification(int p_what) {
}
void GIProbeEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
bake_hb->show();
set_process(true);
} else {
-
bake_hb->hide();
set_process(false);
}
@@ -116,14 +111,12 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) {
EditorProgress *GIProbeEditorPlugin::tmp_progress = nullptr;
void GIProbeEditorPlugin::bake_func_begin(int p_steps) {
-
ERR_FAIL_COND(tmp_progress != nullptr);
tmp_progress = memnew(EditorProgress("bake_gi", TTR("Bake GI Probe"), p_steps));
}
void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) {
-
ERR_FAIL_COND(tmp_progress == nullptr);
tmp_progress->step(p_description, p_step, false);
}
@@ -147,7 +140,6 @@ void GIProbeEditorPlugin::_bind_methods() {
}
GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
bake_hb = memnew(HBoxContainer);
bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h
index 2068ebaaa8..508c3d825b 100644
--- a/editor/plugins/gi_probe_editor_plugin.h
+++ b/editor/plugins/gi_probe_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/resources/material.h"
class GIProbeEditorPlugin : public EditorPlugin {
-
GDCLASS(GIProbeEditorPlugin, EditorPlugin);
GIProbe *gi_probe;
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
index 5c35285c22..01420dac3e 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
@@ -37,54 +37,45 @@
#include "scene/resources/particles_material.h"
void GPUParticles2DEditorPlugin::edit(Object *p_object) {
-
particles = Object::cast_to<GPUParticles2D>(p_object);
}
bool GPUParticles2DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("GPUParticles2D");
}
void GPUParticles2DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
toolbar->show();
} else {
-
toolbar->hide();
}
}
void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) {
-
source_emission_file = p_file;
emission_mask->popup_centered();
}
void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
-
switch (p_idx) {
case MENU_GENERATE_VISIBILITY_RECT: {
float gen_time = particles->get_lifetime();
- if (gen_time < 1.0)
+ if (gen_time < 1.0) {
generate_seconds->set_value(1.0);
- else
+ } else {
generate_seconds->set_value(trunc(gen_time) + 1.0);
+ }
generate_visibility_rect->popup_centered();
} break;
case MENU_LOAD_EMISSION_MASK: {
-
file->popup_centered_ratio();
} break;
case MENU_CLEAR_EMISSION_MASK: {
-
emission_mask->popup_centered();
} break;
case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
-
CPUParticles2D *cpu_particles = memnew(CPUParticles2D);
cpu_particles->convert_from_particles(particles);
cpu_particles->set_name(particles->get_name());
@@ -103,14 +94,12 @@ void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
} break;
case MENU_RESTART: {
-
particles->restart();
}
}
}
void GPUParticles2DEditorPlugin::_generate_visibility_rect() {
-
float time = generate_seconds->get_value();
float running = 0.0;
@@ -125,16 +114,16 @@ void GPUParticles2DEditorPlugin::_generate_visibility_rect() {
Rect2 rect;
while (running < time) {
-
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
ep.step("Generating...", int(running), true);
OS::get_singleton()->delay_usec(1000);
Rect2 capture = particles->capture_rect();
- if (rect == Rect2())
+ if (rect == Rect2()) {
rect = capture;
- else
+ } else {
rect = rect.merge(capture);
+ }
running += (OS::get_singleton()->get_ticks_usec() - ticks) / 1000000.0;
}
@@ -150,7 +139,6 @@ void GPUParticles2DEditorPlugin::_generate_visibility_rect() {
}
void GPUParticles2DEditorPlugin::_generate_emission_mask() {
-
Ref<ParticlesMaterial> pm = particles->get_process_material();
if (!pm.is_valid()) {
EditorNode::get_singleton()->show_warning(TTR("Can only set point into a ParticlesMaterial process material"));
@@ -196,13 +184,10 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
for (int i = 0; i < s.width; i++) {
for (int j = 0; j < s.height; j++) {
-
uint8_t a = r[(j * s.width + i) * 4 + 3];
if (a > 128) {
-
if (emode == EMISSION_MODE_SOLID) {
-
if (capture_colors) {
valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0];
valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1];
@@ -212,19 +197,18 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
valid_positions.write[vpc++] = Point2(i, j);
} else {
-
bool on_border = false;
for (int x = i - 1; x <= i + 1; x++) {
for (int y = j - 1; y <= j + 1; y++) {
-
if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) {
on_border = true;
break;
}
}
- if (on_border)
+ if (on_border) {
break;
+ }
}
if (on_border) {
@@ -234,9 +218,9 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
Vector2 normal;
for (int x = i - 2; x <= i + 2; x++) {
for (int y = j - 2; y <= j + 2; y++) {
-
- if (x == i && y == j)
+ if (x == i && y == j) {
continue;
+ }
if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) {
normal += Vector2(x - i, y - j).normalized();
@@ -281,7 +265,6 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
uint8_t *tw = texdata.ptrw();
float *twf = (float *)tw;
for (int i = 0; i < vpc; i++) {
-
twf[i * 2 + 0] = valid_positions[i].x;
twf[i * 2 + 1] = valid_positions[i].y;
}
@@ -298,14 +281,12 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
pm->set_emission_point_count(vpc);
if (capture_colors) {
-
Vector<uint8_t> colordata;
colordata.resize(w * h * 4); //use RG texture
{
uint8_t *tw = colordata.ptrw();
for (int i = 0; i < vpc * 4; i++) {
-
tw[i] = valid_colors[i];
}
}
@@ -346,9 +327,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() {
}
void GPUParticles2DEditorPlugin::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback));
menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons"));
file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected));
@@ -359,7 +338,6 @@ void GPUParticles2DEditorPlugin::_bind_methods() {
}
GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) {
-
particles = nullptr;
editor = p_node;
undo_redo = editor->get_undo_redo();
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h
index 008d04a211..c76cecb3a2 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.h
@@ -39,7 +39,6 @@
#include "scene/gui/file_dialog.h"
class GPUParticles2DEditorPlugin : public EditorPlugin {
-
GDCLASS(GPUParticles2DEditorPlugin, EditorPlugin);
enum {
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index 7f80acc176..fa507dd3d7 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -36,25 +36,22 @@
#include "scene/resources/particles_material.h"
bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) {
-
bool use_normals = emission_fill->get_selected() == 1;
if (emission_fill->get_selected() < 2) {
-
float area_accum = 0;
Map<float, int> triangle_area_map;
for (int i = 0; i < geometry.size(); i++) {
-
float area = geometry[i].get_area();
- if (area < CMP_EPSILON)
+ if (area < CMP_EPSILON) {
continue;
+ }
triangle_area_map[area_accum] = i;
area_accum += area;
}
if (!triangle_area_map.size() || area_accum == 0) {
-
EditorNode::get_singleton()->show_warning(TTR("The geometry's faces don't contain any area."));
return false;
}
@@ -62,7 +59,6 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3
int emissor_count = emission_amount->get_value();
for (int i = 0; i < emissor_count; i++) {
-
float areapos = Math::random(0.0f, area_accum);
Map<float, int>::Element *E = triangle_area_map.find_closest(areapos);
@@ -84,11 +80,9 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3
}
}
} else {
-
int gcount = geometry.size();
if (gcount == 0) {
-
EditorNode::get_singleton()->show_warning(TTR("The geometry doesn't contain any faces."));
return false;
}
@@ -98,24 +92,21 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3
AABB aabb;
for (int i = 0; i < gcount; i++) {
-
for (int j = 0; j < 3; j++) {
-
- if (i == 0 && j == 0)
+ if (i == 0 && j == 0) {
aabb.position = r[i].vertex[j];
- else
+ } else {
aabb.expand_to(r[i].vertex[j]);
+ }
}
}
int emissor_count = emission_amount->get_value();
for (int i = 0; i < emissor_count; i++) {
-
int attempts = 5;
for (int j = 0; j < attempts; j++) {
-
Vector3 dir;
dir[Math::rand() % 3] = 1.0;
Vector3 ofs = (Vector3(1, 1, 1) - dir) * Vector3(Math::randf(), Math::randf(), Math::randf()) * aabb.size + aabb.position;
@@ -129,24 +120,25 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3
float max = -1e7, min = 1e7;
for (int k = 0; k < gcount; k++) {
-
const Face3 &f3 = r[k];
Vector3 res;
if (f3.intersects_segment(ofs, ofsv, &res)) {
-
res -= ofs;
float d = dir.dot(res);
- if (d < min)
+ if (d < min) {
min = d;
- if (d > max)
+ }
+ if (d > max) {
max = d;
+ }
}
}
- if (max < min)
+ if (max < min) {
continue; //lost attempt
+ }
float val = min + (max - min) * Math::randf();
@@ -162,20 +154,18 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3
}
void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) {
-
Node *sel = get_node(p_path);
- if (!sel)
+ if (!sel) {
return;
+ }
if (!sel->is_class("Node3D")) {
-
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Node3D."), sel->get_name()));
return;
}
VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sel);
if (!vi) {
-
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain geometry."), sel->get_name()));
return;
}
@@ -183,7 +173,6 @@ void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) {
geometry = vi->get_faces(VisualInstance3D::FACES_SOLID);
if (geometry.size() == 0) {
-
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain face geometry."), sel->get_name()));
return;
}
@@ -206,7 +195,6 @@ void GPUParticles3DEditorBase::_bind_methods() {
}
GPUParticles3DEditorBase::GPUParticles3DEditorBase() {
-
emission_dialog = memnew(ConfirmationDialog);
emission_dialog->set_title(TTR("Create Emitter"));
add_child(emission_dialog);
@@ -234,7 +222,6 @@ GPUParticles3DEditorBase::GPUParticles3DEditorBase() {
}
void GPUParticles3DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
hide();
@@ -242,7 +229,6 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) {
}
void GPUParticles3DEditor::_notification(int p_notification) {
-
if (p_notification == NOTIFICATION_ENTER_TREE) {
options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons"));
get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed));
@@ -250,16 +236,15 @@ void GPUParticles3DEditor::_notification(int p_notification) {
}
void GPUParticles3DEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MENU_OPTION_GENERATE_AABB: {
float gen_time = node->get_lifetime();
- if (gen_time < 1.0)
+ if (gen_time < 1.0) {
generate_seconds->set_value(1.0);
- else
+ } else {
generate_seconds->set_value(trunc(gen_time) + 1.0);
+ }
generate_aabb->popup_centered();
} break;
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: {
@@ -273,7 +258,6 @@ void GPUParticles3DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
-
CPUParticles3D *cpu_particles = memnew(CPUParticles3D);
cpu_particles->convert_from_particles(node);
cpu_particles->set_name(node->get_name());
@@ -291,7 +275,6 @@ void GPUParticles3DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_RESTART: {
-
node->restart();
} break;
@@ -299,7 +282,6 @@ void GPUParticles3DEditor::_menu_option(int p_option) {
}
void GPUParticles3DEditor::_generate_aabb() {
-
float time = generate_seconds->get_value();
float running = 0.0;
@@ -315,16 +297,16 @@ void GPUParticles3DEditor::_generate_aabb() {
AABB rect;
while (running < time) {
-
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
ep.step("Generating...", int(running), true);
OS::get_singleton()->delay_usec(1000);
AABB capture = node->capture_aabb();
- if (rect == AABB())
+ if (rect == AABB()) {
rect = capture;
- else
+ } else {
rect.merge_with(capture);
+ }
running += (OS::get_singleton()->get_ticks_usec() - ticks) / 1000000.0;
}
@@ -341,13 +323,11 @@ void GPUParticles3DEditor::_generate_aabb() {
}
void GPUParticles3DEditor::edit(GPUParticles3D *p_particles) {
-
base_node = p_particles;
node = p_particles;
}
void GPUParticles3DEditor::_generate_emission_points() {
-
/// hacer codigo aca
Vector<Vector3> points;
Vector<Vector3> normals;
@@ -385,7 +365,6 @@ void GPUParticles3DEditor::_generate_emission_points() {
ERR_FAIL_COND(material.is_null());
if (normals.size() > 0) {
-
material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_DIRECTED_POINTS);
material->set_emission_point_count(point_count);
material->set_emission_point_texture(tex);
@@ -412,7 +391,6 @@ void GPUParticles3DEditor::_generate_emission_points() {
material->set_emission_normal_texture(tex2);
} else {
-
material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_POINTS);
material->set_emission_point_count(point_count);
material->set_emission_point_texture(tex);
@@ -423,7 +401,6 @@ void GPUParticles3DEditor::_bind_methods() {
}
GPUParticles3DEditor::GPUParticles3DEditor() {
-
node = nullptr;
particles_editor_hb = memnew(HBoxContainer);
Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
@@ -456,17 +433,14 @@ GPUParticles3DEditor::GPUParticles3DEditor() {
}
void GPUParticles3DEditorPlugin::edit(Object *p_object) {
-
particles_editor->edit(Object::cast_to<GPUParticles3D>(p_object));
}
bool GPUParticles3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("GPUParticles3D");
}
void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
particles_editor->show();
particles_editor->particles_editor_hb->show();
@@ -478,7 +452,6 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {
}
GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
particles_editor = memnew(GPUParticles3DEditor);
editor->get_viewport()->add_child(particles_editor);
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h
index cf1cff32c0..7838a63436 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/gui/spin_box.h"
class GPUParticles3DEditorBase : public Control {
-
GDCLASS(GPUParticles3DEditorBase, Control);
protected:
@@ -65,7 +64,6 @@ public:
};
class GPUParticles3DEditor : public GPUParticles3DEditorBase {
-
GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase);
ConfirmationDialog *generate_aabb;
@@ -101,7 +99,6 @@ public:
};
class GPUParticles3DEditorPlugin : public EditorPlugin {
-
GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin);
GPUParticles3DEditor *particles_editor;
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index 67de610ae7..13b5c8cef5 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -37,10 +37,11 @@
Size2 GradientEditor::get_minimum_size() const {
return Size2(0, 60) * EDSCALE;
}
-void GradientEditor::_gradient_changed() {
- if (editing)
+void GradientEditor::_gradient_changed() {
+ if (editing) {
return;
+ }
editing = true;
Vector<Gradient::Point> points = gradient->get_points();
@@ -49,7 +50,6 @@ void GradientEditor::_gradient_changed() {
}
void GradientEditor::_ramp_changed() {
-
editing = true;
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Gradient Edited"));
@@ -78,12 +78,10 @@ GradientEditor::GradientEditor() {
///////////////////////
bool EditorInspectorPluginGradient::can_handle(Object *p_object) {
-
return Object::cast_to<Gradient>(p_object) != nullptr;
}
void EditorInspectorPluginGradient::parse_begin(Object *p_object) {
-
Gradient *gradient = Object::cast_to<Gradient>(p_object);
Ref<Gradient> g(gradient);
@@ -93,7 +91,6 @@ void EditorInspectorPluginGradient::parse_begin(Object *p_object) {
}
GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
-
Ref<EditorInspectorPluginGradient> plugin;
plugin.instance();
add_inspector_plugin(plugin);
diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h
index 9ebd9610e5..0641d54d5c 100644
--- a/editor/plugins/gradient_editor_plugin.h
+++ b/editor/plugins/gradient_editor_plugin.h
@@ -62,7 +62,6 @@ public:
};
class GradientEditorPlugin : public EditorPlugin {
-
GDCLASS(GradientEditorPlugin, EditorPlugin);
public:
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index 1dbc78804b..7402baad57 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -34,16 +34,15 @@
#include "editor/editor_scale.h"
bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
int idx = name.get_slice("/", 0).to_int();
String what = name.get_slice("/", 1);
- if (what == "text")
+ if (what == "text") {
set_item_text(idx, p_value);
- else if (what == "icon")
+ } else if (what == "icon") {
set_item_icon(idx, p_value);
- else if (what == "checkable") {
+ } else if (what == "checkable") {
// This keeps compatibility to/from versions where this property was a boolean, before radio buttons
switch ((int)p_value) {
case 0:
@@ -54,54 +53,54 @@ bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) {
set_item_radio_checkable(idx, true);
break;
}
- } else if (what == "checked")
+ } else if (what == "checked") {
set_item_checked(idx, p_value);
- else if (what == "id")
+ } else if (what == "id") {
set_item_id(idx, p_value);
- else if (what == "enabled")
+ } else if (what == "enabled") {
set_item_enabled(idx, p_value);
- else if (what == "separator")
+ } else if (what == "separator") {
set_item_separator(idx, p_value);
- else
+ } else {
return false;
+ }
return true;
}
bool ItemListPlugin::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
int idx = name.get_slice("/", 0).to_int();
String what = name.get_slice("/", 1);
- if (what == "text")
+ if (what == "text") {
r_ret = get_item_text(idx);
- else if (what == "icon")
+ } else if (what == "icon") {
r_ret = get_item_icon(idx);
- else if (what == "checkable") {
+ } else if (what == "checkable") {
// This keeps compatibility to/from versions where this property was a boolean, before radio buttons
if (!is_item_checkable(idx)) {
r_ret = 0;
} else {
r_ret = is_item_radio_checkable(idx) ? 2 : 1;
}
- } else if (what == "checked")
+ } else if (what == "checked") {
r_ret = is_item_checked(idx);
- else if (what == "id")
+ } else if (what == "id") {
r_ret = get_item_id(idx);
- else if (what == "enabled")
+ } else if (what == "enabled") {
r_ret = is_item_enabled(idx);
- else if (what == "separator")
+ } else if (what == "separator") {
r_ret = is_item_separator(idx);
- else
+ } else {
return false;
+ }
return true;
}
-void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
+void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < get_item_count(); i++) {
-
String base = itos(i) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, base + "text"));
@@ -114,14 +113,17 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::BOOL, base + "checked"));
}
- if (flags & FLAG_ID)
+ if (flags & FLAG_ID) {
p_list->push_back(PropertyInfo(Variant::INT, base + "id", PROPERTY_HINT_RANGE, "-1,4096"));
+ }
- if (flags & FLAG_ENABLE)
+ if (flags & FLAG_ENABLE) {
p_list->push_back(PropertyInfo(Variant::BOOL, base + "enabled"));
+ }
- if (flags & FLAG_SEPARATOR)
+ if (flags & FLAG_SEPARATOR) {
p_list->push_back(PropertyInfo(Variant::BOOL, base + "separator"));
+ }
}
}
@@ -130,120 +132,100 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
///////////////////////////////////////////////////////////////
void ItemListOptionButtonPlugin::set_object(Object *p_object) {
-
ob = Object::cast_to<OptionButton>(p_object);
}
bool ItemListOptionButtonPlugin::handles(Object *p_object) const {
-
return p_object->is_class("OptionButton");
}
int ItemListOptionButtonPlugin::get_flags() const {
-
return FLAG_ICON | FLAG_ID | FLAG_ENABLE;
}
void ItemListOptionButtonPlugin::add_item() {
-
ob->add_item(vformat(TTR("Item %d"), ob->get_item_count()));
_change_notify();
}
int ItemListOptionButtonPlugin::get_item_count() const {
-
return ob->get_item_count();
}
void ItemListOptionButtonPlugin::erase(int p_idx) {
-
ob->remove_item(p_idx);
_change_notify();
}
ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
-
ob = nullptr;
}
///////////////////////////////////////////////////////////////
void ItemListPopupMenuPlugin::set_object(Object *p_object) {
-
- if (p_object->is_class("MenuButton"))
+ if (p_object->is_class("MenuButton")) {
pp = Object::cast_to<MenuButton>(p_object)->get_popup();
- else
+ } else {
pp = Object::cast_to<PopupMenu>(p_object);
+ }
}
bool ItemListPopupMenuPlugin::handles(Object *p_object) const {
-
return p_object->is_class("PopupMenu") || p_object->is_class("MenuButton");
}
int ItemListPopupMenuPlugin::get_flags() const {
-
return FLAG_ICON | FLAG_CHECKABLE | FLAG_ID | FLAG_ENABLE | FLAG_SEPARATOR;
}
void ItemListPopupMenuPlugin::add_item() {
-
pp->add_item(vformat(TTR("Item %d"), pp->get_item_count()));
_change_notify();
}
int ItemListPopupMenuPlugin::get_item_count() const {
-
return pp->get_item_count();
}
void ItemListPopupMenuPlugin::erase(int p_idx) {
-
pp->remove_item(p_idx);
_change_notify();
}
ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
-
pp = nullptr;
}
///////////////////////////////////////////////////////////////
void ItemListItemListPlugin::set_object(Object *p_object) {
-
pp = Object::cast_to<ItemList>(p_object);
}
bool ItemListItemListPlugin::handles(Object *p_object) const {
-
return p_object->is_class("ItemList");
}
int ItemListItemListPlugin::get_flags() const {
-
return FLAG_ICON | FLAG_ENABLE;
}
void ItemListItemListPlugin::add_item() {
-
pp->add_item(vformat(TTR("Item %d"), pp->get_item_count()));
_change_notify();
}
int ItemListItemListPlugin::get_item_count() const {
-
return pp->get_item_count();
}
void ItemListItemListPlugin::erase(int p_idx) {
-
pp->remove_item(p_idx);
_change_notify();
}
ItemListItemListPlugin::ItemListItemListPlugin() {
-
pp = nullptr;
}
@@ -252,7 +234,6 @@ ItemListItemListPlugin::ItemListItemListPlugin() {
///////////////////////////////////////////////////////////////
void ItemListEditor::_node_removed(Node *p_node) {
-
if (p_node == item_list) {
item_list = nullptr;
hide();
@@ -261,34 +242,32 @@ void ItemListEditor::_node_removed(Node *p_node) {
}
void ItemListEditor::_notification(int p_notification) {
-
if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) {
-
add_button->set_icon(get_theme_icon("Add", "EditorIcons"));
del_button->set_icon(get_theme_icon("Remove", "EditorIcons"));
} else if (p_notification == NOTIFICATION_READY) {
-
get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed));
}
}
void ItemListEditor::_add_pressed() {
-
- if (selected_idx == -1)
+ if (selected_idx == -1) {
return;
+ }
item_plugins[selected_idx]->add_item();
}
void ItemListEditor::_delete_pressed() {
-
- if (selected_idx == -1)
+ if (selected_idx == -1) {
return;
+ }
String current_selected = (String)property_editor->get_selected_path();
- if (current_selected == "")
+ if (current_selected == "") {
return;
+ }
// FIXME: Currently relying on selecting a *property* to derive what item to delete
// e.g. you select "1/enabled" to delete item 1.
@@ -301,12 +280,10 @@ void ItemListEditor::_delete_pressed() {
}
void ItemListEditor::_edit_items() {
-
dialog->popup_centered_clamped(Vector2(425, 1200) * EDSCALE, 0.8);
}
void ItemListEditor::edit(Node *p_item_list) {
-
item_list = p_item_list;
if (!item_list) {
@@ -317,7 +294,6 @@ void ItemListEditor::edit(Node *p_item_list) {
for (int i = 0; i < item_plugins.size(); i++) {
if (item_plugins[i]->handles(p_item_list)) {
-
item_plugins[i]->set_object(p_item_list);
property_editor->edit(item_plugins[i]);
@@ -333,7 +309,6 @@ void ItemListEditor::edit(Node *p_item_list) {
}
bool ItemListEditor::handles(Object *p_object) const {
-
for (int i = 0; i < item_plugins.size(); i++) {
if (item_plugins[i]->handles(p_object)) {
return true;
@@ -347,7 +322,6 @@ void ItemListEditor::_bind_methods() {
}
ItemListEditor::ItemListEditor() {
-
selected_idx = -1;
item_list = nullptr;
@@ -386,34 +360,29 @@ ItemListEditor::ItemListEditor() {
}
ItemListEditor::~ItemListEditor() {
-
- for (int i = 0; i < item_plugins.size(); i++)
+ for (int i = 0; i < item_plugins.size(); i++) {
memdelete(item_plugins[i]);
+ }
}
void ItemListEditorPlugin::edit(Object *p_object) {
-
item_list_editor->edit(Object::cast_to<Node>(p_object));
}
bool ItemListEditorPlugin::handles(Object *p_object) const {
-
return item_list_editor->handles(p_object);
}
void ItemListEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
item_list_editor->show();
} else {
-
item_list_editor->hide();
item_list_editor->edit(nullptr);
}
}
ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
item_list_editor = memnew(ItemListEditor);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(item_list_editor);
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 8dcf938139..61dd617e3b 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -40,7 +40,6 @@
#include "scene/gui/popup_menu.h"
class ItemListPlugin : public Object {
-
GDCLASS(ItemListPlugin, Object);
protected:
@@ -96,7 +95,6 @@ public:
///////////////////////////////////////////////////////////////
class ItemListOptionButtonPlugin : public ItemListPlugin {
-
GDCLASS(ItemListOptionButtonPlugin, ItemListPlugin);
OptionButton *ob;
@@ -126,7 +124,6 @@ public:
};
class ItemListPopupMenuPlugin : public ItemListPlugin {
-
GDCLASS(ItemListPopupMenuPlugin, ItemListPlugin);
PopupMenu *pp;
@@ -169,7 +166,6 @@ public:
///////////////////////////////////////////////////////////////
class ItemListItemListPlugin : public ItemListPlugin {
-
GDCLASS(ItemListItemListPlugin, ItemListPlugin);
ItemList *pp;
@@ -198,7 +194,6 @@ public:
///////////////////////////////////////////////////////////////
class ItemListEditor : public HBoxContainer {
-
GDCLASS(ItemListEditor, HBoxContainer);
Node *item_list;
@@ -235,7 +230,6 @@ public:
};
class ItemListEditorPlugin : public EditorPlugin {
-
GDCLASS(ItemListEditorPlugin, EditorPlugin);
ItemListEditor *item_list_editor;
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index f8550a884b..e422140efa 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -31,10 +31,8 @@
#include "light_occluder_2d_editor_plugin.h"
Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const {
-
Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon();
if (!occluder.is_valid()) {
-
occluder = Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D));
node->set_occluder_polygon(occluder);
}
@@ -42,64 +40,59 @@ Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const {
}
Node2D *LightOccluder2DEditor::_get_node() const {
-
return node;
}
void LightOccluder2DEditor::_set_node(Node *p_polygon) {
-
node = Object::cast_to<LightOccluder2D>(p_polygon);
}
bool LightOccluder2DEditor::_is_line() const {
-
Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon();
- if (occluder.is_valid())
+ if (occluder.is_valid()) {
return !occluder->is_closed();
- else
+ } else {
return false;
+ }
}
int LightOccluder2DEditor::_get_polygon_count() const {
-
Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon();
- if (occluder.is_valid())
+ if (occluder.is_valid()) {
return occluder->get_polygon().size();
- else
+ } else {
return 0;
+ }
}
Variant LightOccluder2DEditor::_get_polygon(int p_idx) const {
-
Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon();
- if (occluder.is_valid())
+ if (occluder.is_valid()) {
return occluder->get_polygon();
- else
+ } else {
return Variant(Vector<Vector2>());
+ }
}
void LightOccluder2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
-
Ref<OccluderPolygon2D> occluder = _ensure_occluder();
occluder->set_polygon(p_polygon);
}
void LightOccluder2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
-
Ref<OccluderPolygon2D> occluder = _ensure_occluder();
undo_redo->add_do_method(occluder.ptr(), "set_polygon", p_polygon);
undo_redo->add_undo_method(occluder.ptr(), "set_polygon", p_previous);
}
bool LightOccluder2DEditor::_has_resource() const {
-
return node && node->get_occluder_polygon().is_valid();
}
void LightOccluder2DEditor::_create_resource() {
-
- if (!node)
+ if (!node) {
return;
+ }
undo_redo->create_action(TTR("Create Occluder Polygon"));
undo_redo->add_do_method(node, "set_occluder_polygon", Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D)));
@@ -111,7 +104,6 @@ void LightOccluder2DEditor::_create_resource() {
LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) :
AbstractPolygon2DEditor(p_editor) {
-
node = nullptr;
}
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h
index 74ae9e0889..11c9f2b2a4 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.h
+++ b/editor/plugins/light_occluder_2d_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/2d/light_occluder_2d.h"
class LightOccluder2DEditor : public AbstractPolygon2DEditor {
-
GDCLASS(LightOccluder2DEditor, AbstractPolygon2DEditor);
LightOccluder2D *node;
@@ -61,7 +60,6 @@ public:
};
class LightOccluder2DEditorPlugin : public AbstractPolygon2DEditorPlugin {
-
GDCLASS(LightOccluder2DEditorPlugin, AbstractPolygon2DEditorPlugin);
public:
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 5b887390a6..77eeb19d26 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -31,32 +31,26 @@
#include "line_2d_editor_plugin.h"
Node2D *Line2DEditor::_get_node() const {
-
return node;
}
void Line2DEditor::_set_node(Node *p_line) {
-
node = Object::cast_to<Line2D>(p_line);
}
bool Line2DEditor::_is_line() const {
-
return true;
}
Variant Line2DEditor::_get_polygon(int p_idx) const {
-
return _get_node()->get("points");
}
void Line2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
-
_get_node()->set("points", p_polygon);
}
void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
-
Node2D *node = _get_node();
undo_redo->add_do_method(node, "set_points", p_polygon);
undo_redo->add_undo_method(node, "set_points", p_previous);
diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h
index ef54dbc3f7..bf411a070a 100644
--- a/editor/plugins/line_2d_editor_plugin.h
+++ b/editor/plugins/line_2d_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/2d/line_2d.h"
class Line2DEditor : public AbstractPolygon2DEditor {
-
GDCLASS(Line2DEditor, AbstractPolygon2DEditor);
Line2D *node;
@@ -54,7 +53,6 @@ public:
};
class Line2DEditorPlugin : public AbstractPolygon2DEditorPlugin {
-
GDCLASS(Line2DEditorPlugin, AbstractPolygon2DEditorPlugin);
public:
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index f63bcb69b8..e49cfd51f7 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -36,9 +36,7 @@
#include "scene/resources/sky_material.h"
void MaterialEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
-
//get_scene()->connect("node_removed",this,"_node_removed");
if (first_enter) {
@@ -59,7 +57,6 @@ void MaterialEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
@@ -68,20 +65,17 @@ void MaterialEditor::_notification(int p_what) {
}
void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_env) {
-
material = p_material;
camera->set_environment(p_env);
if (!material.is_null()) {
sphere_instance->set_material_override(material);
box_instance->set_material_override(material);
} else {
-
hide();
}
}
void MaterialEditor::_button_pressed(Node *p_button) {
-
if (p_button == light_1_switch) {
light1->set_visible(!light_1_switch->is_pressed());
}
@@ -111,7 +105,6 @@ void MaterialEditor::_bind_methods() {
}
MaterialEditor::MaterialEditor() {
-
vc = memnew(SubViewportContainer);
vc->set_stretch(true);
add_child(vc);
@@ -209,16 +202,15 @@ MaterialEditor::MaterialEditor() {
///////////////////////
bool EditorInspectorPluginMaterial::can_handle(Object *p_object) {
-
Material *material = Object::cast_to<Material>(p_object);
- if (!material)
+ if (!material) {
return false;
+ }
return material->get_shader_mode() == Shader::MODE_SPATIAL;
}
void EditorInspectorPluginMaterial::parse_begin(Object *p_object) {
-
Material *material = Object::cast_to<Material>(p_object);
if (!material) {
return;
@@ -240,23 +232,21 @@ EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() {
}
MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
-
Ref<EditorInspectorPluginMaterial> plugin;
plugin.instance();
add_inspector_plugin(plugin);
}
String StandardMaterial3DConversionPlugin::converts_to() const {
-
return "ShaderMaterial";
}
-bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<StandardMaterial3D> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<StandardMaterial3D> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
@@ -276,7 +266,6 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p
RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), &params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
-
// Texture parameter has to be treated specially since StandardMaterial3D saved it
// as RID but ShaderMaterial needs Texture itself
Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name);
@@ -293,16 +282,15 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p
}
String ParticlesMaterialConversionPlugin::converts_to() const {
-
return "ShaderMaterial";
}
-bool ParticlesMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool ParticlesMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<ParticlesMaterial> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<ParticlesMaterial> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
@@ -331,16 +319,15 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_
}
String CanvasItemMaterialConversionPlugin::converts_to() const {
-
return "ShaderMaterial";
}
-bool CanvasItemMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool CanvasItemMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<CanvasItemMaterial> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<CanvasItemMaterial> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
@@ -369,16 +356,15 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p
}
String ProceduralSkyMaterialConversionPlugin::converts_to() const {
-
return "ShaderMaterial";
}
-bool ProceduralSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool ProceduralSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<ProceduralSkyMaterial> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<ProceduralSkyMaterial> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
@@ -407,16 +393,15 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource>
}
String PanoramaSkyMaterialConversionPlugin::converts_to() const {
-
return "ShaderMaterial";
}
-bool PanoramaSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool PanoramaSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<PanoramaSkyMaterial> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<PanoramaSkyMaterial> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
@@ -445,16 +430,15 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &
}
String PhysicalSkyMaterialConversionPlugin::converts_to() const {
-
return "ShaderMaterial";
}
-bool PhysicalSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+bool PhysicalSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<PhysicalSkyMaterial> mat = p_resource;
return mat.is_valid();
}
-Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<PhysicalSkyMaterial> mat = p_resource;
ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>());
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 50036e4f72..e03cb1b3ab 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -44,7 +44,6 @@
class SubViewportContainer;
class MaterialEditor : public Control {
-
GDCLASS(MaterialEditor, Control);
SubViewportContainer *vc;
@@ -91,7 +90,6 @@ public:
};
class MaterialEditorPlugin : public EditorPlugin {
-
GDCLASS(MaterialEditorPlugin, EditorPlugin);
public:
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 3e603fa499..9d396467c3 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -33,15 +33,13 @@
#include "editor/editor_scale.h"
void MeshEditor::_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
rot_x -= mm->get_relative().y * 0.01;
rot_y -= mm->get_relative().x * 0.01;
- if (rot_x < -Math_PI / 2)
+ if (rot_x < -Math_PI / 2) {
rot_x = -Math_PI / 2;
- else if (rot_x > Math_PI / 2) {
+ } else if (rot_x > Math_PI / 2) {
rot_x = Math_PI / 2;
}
_update_rotation();
@@ -49,9 +47,7 @@ void MeshEditor::_gui_input(Ref<InputEvent> p_event) {
}
void MeshEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
-
//get_scene()->connect("node_removed",this,"_node_removed");
if (first_enter) {
@@ -67,7 +63,6 @@ void MeshEditor::_notification(int p_what) {
}
void MeshEditor::_update_rotation() {
-
Transform t;
t.basis.rotate(Vector3(0, 1, 0), -rot_y);
t.basis.rotate(Vector3(1, 0, 0), -rot_x);
@@ -75,7 +70,6 @@ void MeshEditor::_update_rotation() {
}
void MeshEditor::edit(Ref<Mesh> p_mesh) {
-
mesh = p_mesh;
mesh_instance->set_mesh(mesh);
@@ -98,7 +92,6 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) {
}
void MeshEditor::_button_pressed(Node *p_button) {
-
if (p_button == light_1_switch) {
light1->set_visible(!light_1_switch->is_pressed());
}
@@ -109,12 +102,10 @@ void MeshEditor::_button_pressed(Node *p_button) {
}
void MeshEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &MeshEditor::_gui_input);
}
MeshEditor::MeshEditor() {
-
viewport = memnew(SubViewport);
Ref<World3D> world_3d;
world_3d.instance();
@@ -172,12 +163,10 @@ MeshEditor::MeshEditor() {
///////////////////////
bool EditorInspectorPluginMesh::can_handle(Object *p_object) {
-
return Object::cast_to<Mesh>(p_object) != nullptr;
}
void EditorInspectorPluginMesh::parse_begin(Object *p_object) {
-
Mesh *mesh = Object::cast_to<Mesh>(p_object);
if (!mesh) {
return;
@@ -190,7 +179,6 @@ void EditorInspectorPluginMesh::parse_begin(Object *p_object) {
}
MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) {
-
Ref<EditorInspectorPluginMesh> plugin;
plugin.instance();
add_inspector_plugin(plugin);
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 072e21f260..6f171a0eab 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -40,7 +40,6 @@
#include "scene/resources/material.h"
class MeshEditor : public SubViewportContainer {
-
GDCLASS(MeshEditor, SubViewportContainer);
float rot_x;
@@ -82,7 +81,6 @@ public:
};
class MeshEditorPlugin : public EditorPlugin {
-
GDCLASS(MeshEditorPlugin, EditorPlugin);
public:
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index 7819f62bc7..1b65987af0 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -38,7 +38,6 @@
#include "scene/gui/box_container.h"
void MeshInstance3DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
options->hide();
@@ -46,12 +45,10 @@ void MeshInstance3DEditor::_node_removed(Node *p_node) {
}
void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) {
-
node = p_mesh;
}
void MeshInstance3DEditor::_menu_option(int p_option) {
-
Ref<Mesh> mesh = node->get_mesh();
if (mesh.is_null()) {
err_dialog->set_text(TTR("Mesh is empty!"));
@@ -61,7 +58,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
switch (p_option) {
case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: {
-
EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -95,18 +91,20 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
ur->create_action(TTR("Create Static Trimesh Body"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get());
- if (!instance)
+ if (!instance) {
continue;
+ }
Ref<Mesh> m = instance->get_mesh();
- if (m.is_null())
+ if (m.is_null()) {
continue;
+ }
Ref<Shape3D> shape = m->create_trimesh_shape();
- if (shape.is_null())
+ if (shape.is_null()) {
continue;
+ }
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
@@ -127,7 +125,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE: {
-
if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("This doesn't work on scene root!"));
err_dialog->popup_centered();
@@ -135,8 +132,9 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
}
Ref<Shape3D> shape = mesh->create_trimesh_shape();
- if (shape.is_null())
+ if (shape.is_null()) {
return;
+ }
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
@@ -155,7 +153,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
ur->commit_action();
} break;
case MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE: {
-
if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("Can't create a single convex collision shape for the scene root."));
err_dialog->popup_centered();
@@ -189,7 +186,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES: {
-
if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("Can't create multiple convex collision shapes for the scene root."));
err_dialog->popup_centered();
@@ -208,7 +204,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
ur->create_action(TTR("Create Multiple Convex Shapes"));
for (int i = 0; i < shapes.size(); i++) {
-
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shapes[i]);
cshape->set_transform(node->get_transform());
@@ -226,11 +221,11 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CREATE_NAVMESH: {
-
Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
- if (nmesh.is_null())
+ if (nmesh.is_null()) {
return;
+ }
nmesh->create_from_mesh(mesh);
NavigationRegion3D *nmi = memnew(NavigationRegion3D);
@@ -250,11 +245,9 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CREATE_OUTLINE_MESH: {
-
outline_dialog->popup_centered(Vector2(200, 90));
} break;
case MENU_OPTION_CREATE_UV2: {
-
Ref<ArrayMesh> mesh2 = node->get_mesh();
if (!mesh2.is_valid()) {
err_dialog->set_text(TTR("Contained Mesh is not of type ArrayMesh."));
@@ -292,15 +285,15 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
}
struct MeshInstance3DEditorEdgeSort {
-
Vector2 a;
Vector2 b;
bool operator<(const MeshInstance3DEditorEdgeSort &p_b) const {
- if (a == p_b.a)
+ if (a == p_b.a) {
return b < p_b.b;
- else
+ } else {
return a < p_b.a;
+ }
}
MeshInstance3DEditorEdgeSort() {}
@@ -316,15 +309,15 @@ struct MeshInstance3DEditorEdgeSort {
};
void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
-
Ref<Mesh> mesh = node->get_mesh();
ERR_FAIL_COND(!mesh.is_valid());
Set<MeshInstance3DEditorEdgeSort> edges;
uv_lines.clear();
for (int i = 0; i < mesh->get_surface_count(); i++) {
- if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
+ }
Array a = mesh->surface_get_arrays(i);
Vector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2];
@@ -349,9 +342,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
}
for (int j = 0; j < ic; j += 3) {
-
for (int k = 0; k < 3; k++) {
-
MeshInstance3DEditorEdgeSort edge;
if (ri) {
edge.a = r[ri[j + k]];
@@ -361,8 +352,9 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
edge.b = r[j + ((k + 1) % 3)];
}
- if (edges.has(edge))
+ if (edges.has(edge)) {
continue;
+ }
uv_lines.push_back(edge.a);
uv_lines.push_back(edge.b);
@@ -375,9 +367,9 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
}
void MeshInstance3DEditor::_debug_uv_draw() {
-
- if (uv_lines.size() == 0)
+ if (uv_lines.size() == 0) {
return;
+ }
debug_uv->set_clip_contents(true);
debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), Color(0.2, 0.2, 0.0));
@@ -386,7 +378,6 @@ void MeshInstance3DEditor::_debug_uv_draw() {
}
void MeshInstance3DEditor::_create_outline_mesh() {
-
Ref<Mesh> mesh = node->get_mesh();
if (mesh.is_null()) {
err_dialog->set_text(TTR("MeshInstance3D lacks a Mesh."));
@@ -435,7 +426,6 @@ void MeshInstance3DEditor::_bind_methods() {
}
MeshInstance3DEditor::MeshInstance3DEditor() {
-
options = memnew(MenuButton);
options->set_switch_on_hover(true);
Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
@@ -495,28 +485,23 @@ MeshInstance3DEditor::MeshInstance3DEditor() {
}
void MeshInstance3DEditorPlugin::edit(Object *p_object) {
-
mesh_editor->edit(Object::cast_to<MeshInstance3D>(p_object));
}
bool MeshInstance3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("MeshInstance3D");
}
void MeshInstance3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
mesh_editor->options->show();
} else {
-
mesh_editor->options->hide();
mesh_editor->edit(nullptr);
}
}
MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
mesh_editor = memnew(MeshInstance3DEditor);
editor->get_viewport()->add_child(mesh_editor);
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h
index a5d90c42d5..3350a792bc 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.h
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/gui/spin_box.h"
class MeshInstance3DEditor : public Control {
-
GDCLASS(MeshInstance3DEditor, Control);
enum Menu {
@@ -84,7 +83,6 @@ public:
};
class MeshInstance3DEditorPlugin : public EditorPlugin {
-
GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin);
MeshInstance3DEditor *mesh_editor;
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index a3e3d88ae2..7690beeee8 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -41,18 +41,15 @@
#include "scene/resources/packed_scene.h"
void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_mesh_library) {
-
mesh_library = p_mesh_library;
- if (mesh_library.is_valid())
+ if (mesh_library.is_valid()) {
menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), !mesh_library->has_meta("_editor_source_scene"));
+ }
}
void MeshLibraryEditor::_menu_confirm() {
-
switch (option) {
-
case MENU_OPTION_REMOVE_ITEM: {
-
mesh_library->remove_item(to_erase);
} break;
case MENU_OPTION_UPDATE_FROM_SCENE: {
@@ -67,14 +64,13 @@ void MeshLibraryEditor::_menu_confirm() {
}
void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, bool p_merge) {
-
- if (!p_merge)
+ if (!p_merge) {
p_library->clear();
+ }
Map<int, MeshInstance3D *> mesh_instances;
for (int i = 0; i < p_scene->get_child_count(); i++) {
-
Node *child = p_scene->get_child(i);
if (!Object::cast_to<MeshInstance3D>(child)) {
@@ -84,14 +80,16 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue;
}
- } else
+ } else {
continue;
+ }
}
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(child);
Ref<Mesh> mesh = mi->get_mesh();
- if (mesh.is_null())
+ if (mesh.is_null()) {
continue;
+ }
mesh = mesh->duplicate();
for (int j = 0; j < mesh->get_surface_count(); ++j) {
@@ -104,7 +102,6 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
int id = p_library->find_item_by_name(mi->get_name());
if (id < 0) {
-
id = p_library->get_last_unused_item_id();
p_library->create_item(id);
p_library->set_item_name(id, mi->get_name());
@@ -116,28 +113,29 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Vector<MeshLibrary::ShapeData> collisions;
for (int j = 0; j < mi->get_child_count(); j++) {
-
Node *child2 = mi->get_child(j);
- if (!Object::cast_to<StaticBody3D>(child2))
+ if (!Object::cast_to<StaticBody3D>(child2)) {
continue;
+ }
StaticBody3D *sb = Object::cast_to<StaticBody3D>(child2);
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) {
- if (sb->is_shape_owner_disabled(E->get()))
+ if (sb->is_shape_owner_disabled(E->get())) {
continue;
+ }
//Transform shape_transform = sb->shape_owner_get_transform(E->get());
//shape_transform.set_origin(shape_transform.get_origin() - phys_offset);
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
-
Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k);
- if (!collision.is_valid())
+ if (!collision.is_valid()) {
continue;
+ }
MeshLibrary::ShapeData shape_data;
shape_data.shape = collision;
shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get());
@@ -152,13 +150,15 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Transform navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
- if (!Object::cast_to<NavigationRegion3D>(child2))
+ if (!Object::cast_to<NavigationRegion3D>(child2)) {
continue;
+ }
NavigationRegion3D *sb = Object::cast_to<NavigationRegion3D>(child2);
navmesh = sb->get_navigation_mesh();
navmesh_transform = sb->get_transform();
- if (!navmesh.is_null())
+ if (!navmesh.is_null()) {
break;
+ }
}
if (!navmesh.is_null()) {
p_library->set_item_navmesh(id, navmesh);
@@ -168,15 +168,12 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
//generate previews!
- if (1) {
-
+ if (true) {
Vector<Ref<Mesh>> meshes;
Vector<Transform> transforms;
Vector<int> ids = p_library->get_item_list();
for (int i = 0; i < ids.size(); i++) {
-
if (mesh_instances.find(ids[i])) {
-
meshes.push_back(p_library->get_item_mesh(ids[i]));
transforms.push_back(mesh_instances[ids[i]]->get_transform());
}
@@ -185,9 +182,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Vector<Ref<Texture2D>> textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size"));
int j = 0;
for (int i = 0; i < ids.size(); i++) {
-
if (mesh_instances.find(ids[i])) {
-
p_library->set_item_preview(ids[i], textures[j]);
j++;
}
@@ -196,7 +191,6 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
}
void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
-
Ref<PackedScene> ps = ResourceLoader::load(p_str, "PackedScene");
ERR_FAIL_COND(ps.is_null());
Node *scene = ps->instance();
@@ -211,36 +205,28 @@ void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
}
Error MeshLibraryEditor::update_library_file(Node *p_base_scene, Ref<MeshLibrary> ml, bool p_merge) {
-
_import_scene(p_base_scene, ml, p_merge);
return OK;
}
void MeshLibraryEditor::_menu_cbk(int p_option) {
-
option = p_option;
switch (p_option) {
-
case MENU_OPTION_ADD_ITEM: {
-
mesh_library->create_item(mesh_library->get_last_unused_item_id());
} break;
case MENU_OPTION_REMOVE_ITEM: {
-
String p = editor->get_inspector()->get_selected_path();
if (p.begins_with("/MeshLibrary/item") && p.get_slice_count("/") >= 3) {
-
to_erase = p.get_slice("/", 3).to_int();
cd->set_text(vformat(TTR("Remove item %d?"), to_erase));
cd->popup_centered(Size2(300, 60));
}
} break;
case MENU_OPTION_IMPORT_FROM_SCENE: {
-
file->popup_centered_ratio();
} break;
case MENU_OPTION_UPDATE_FROM_SCENE: {
-
cd->set_text(vformat(TTR("Update from existing scene?:\n%s"), String(mesh_library->get_meta("_editor_source_scene"))));
cd->popup_centered(Size2(500, 60));
} break;
@@ -251,7 +237,6 @@ void MeshLibraryEditor::_bind_methods() {
}
MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
-
file = memnew(EditorFileDialog);
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
//not for now?
@@ -260,7 +245,6 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
file->clear_filters();
file->set_title(TTR("Import Scene"));
for (int i = 0; i < extensions.size(); i++) {
-
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
add_child(file);
@@ -287,21 +271,19 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
}
void MeshLibraryEditorPlugin::edit(Object *p_node) {
-
if (Object::cast_to<MeshLibrary>(p_node)) {
mesh_library_editor->edit(Object::cast_to<MeshLibrary>(p_node));
mesh_library_editor->show();
- } else
+ } else {
mesh_library_editor->hide();
+ }
}
bool MeshLibraryEditorPlugin::handles(Object *p_node) const {
-
return p_node->is_class("MeshLibrary");
}
void MeshLibraryEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
mesh_library_editor->show();
mesh_library_editor->get_menu_button()->show();
@@ -312,7 +294,6 @@ void MeshLibraryEditorPlugin::make_visible(bool p_visible) {
}
MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {
-
EDITOR_DEF("editors/grid_map/preview_size", 64);
mesh_library_editor = memnew(MeshLibraryEditor(p_node));
diff --git a/editor/plugins/mesh_library_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h
index 74b0a280e3..61ce5692bc 100644
--- a/editor/plugins/mesh_library_editor_plugin.h
+++ b/editor/plugins/mesh_library_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/resources/mesh_library.h"
class MeshLibraryEditor : public Control {
-
GDCLASS(MeshLibraryEditor, Control);
Ref<MeshLibrary> mesh_library;
@@ -74,7 +73,6 @@ public:
};
class MeshLibraryEditorPlugin : public EditorPlugin {
-
GDCLASS(MeshLibraryEditorPlugin, EditorPlugin);
MeshLibraryEditor *mesh_library_editor;
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index 4f482c2b43..3904389e09 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -35,7 +35,6 @@
#include "scene/gui/box_container.h"
void MultiMeshEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
hide();
@@ -43,24 +42,21 @@ void MultiMeshEditor::_node_removed(Node *p_node) {
}
void MultiMeshEditor::_populate() {
-
- if (!node)
+ if (!node) {
return;
+ }
Ref<Mesh> mesh;
if (mesh_source->get_text() == "") {
-
Ref<MultiMesh> multimesh;
multimesh = node->get_multimesh();
if (multimesh.is_null()) {
-
err_dialog->set_text(TTR("No mesh source specified (and no MultiMesh set in node)."));
err_dialog->popup_centered();
return;
}
if (multimesh->get_mesh().is_null()) {
-
err_dialog->set_text(TTR("No mesh source specified (and MultiMesh contains no Mesh)."));
err_dialog->popup_centered();
return;
@@ -68,11 +64,9 @@ void MultiMeshEditor::_populate() {
mesh = multimesh->get_mesh();
} else {
-
Node *ms_node = node->get_node(mesh_source->get_text());
if (!ms_node) {
-
err_dialog->set_text(TTR("Mesh source is invalid (invalid path)."));
err_dialog->popup_centered();
return;
@@ -81,7 +75,6 @@ void MultiMeshEditor::_populate() {
MeshInstance3D *ms_instance = Object::cast_to<MeshInstance3D>(ms_node);
if (!ms_instance) {
-
err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance3D)."));
err_dialog->popup_centered();
return;
@@ -90,7 +83,6 @@ void MultiMeshEditor::_populate() {
mesh = ms_instance->get_mesh();
if (mesh.is_null()) {
-
err_dialog->set_text(TTR("Mesh source is invalid (contains no Mesh resource)."));
err_dialog->popup_centered();
return;
@@ -98,7 +90,6 @@ void MultiMeshEditor::_populate() {
}
if (surface_source->get_text() == "") {
-
err_dialog->set_text(TTR("No surface source specified."));
err_dialog->popup_centered();
return;
@@ -107,7 +98,6 @@ void MultiMeshEditor::_populate() {
Node *ss_node = node->get_node(surface_source->get_text());
if (!ss_node) {
-
err_dialog->set_text(TTR("Surface source is invalid (invalid path)."));
err_dialog->popup_centered();
return;
@@ -116,7 +106,6 @@ void MultiMeshEditor::_populate() {
GeometryInstance3D *ss_instance = Object::cast_to<MeshInstance3D>(ss_node);
if (!ss_instance) {
-
err_dialog->set_text(TTR("Surface source is invalid (no geometry)."));
err_dialog->popup_centered();
return;
@@ -127,7 +116,6 @@ void MultiMeshEditor::_populate() {
Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID);
if (geometry.size() == 0) {
-
err_dialog->set_text(TTR("Surface source is invalid (no faces)."));
err_dialog->popup_centered();
return;
@@ -153,10 +141,10 @@ void MultiMeshEditor::_populate() {
float area_accum = 0;
Map<float, int> triangle_area_map;
for (int i = 0; i < facecount; i++) {
-
float area = r[i].get_area();
- if (area < CMP_EPSILON)
+ if (area < CMP_EPSILON) {
continue;
+ }
triangle_area_map[area_accum] = i;
area_accum += area;
}
@@ -188,7 +176,6 @@ void MultiMeshEditor::_populate() {
}
for (int i = 0; i < instance_count; i++) {
-
float areapos = Math::random(0.0f, area_accum);
Map<float, int>::Element *E = triangle_area_map.find_closest(areapos);
@@ -227,23 +214,19 @@ void MultiMeshEditor::_populate() {
}
void MultiMeshEditor::_browsed(const NodePath &p_path) {
-
NodePath path = node->get_path_to(get_node(p_path));
- if (browsing_source)
+ if (browsing_source) {
mesh_source->set_text(path);
- else
+ } else {
surface_source->set_text(path);
+ }
}
void MultiMeshEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MENU_OPTION_POPULATE: {
-
if (_last_pp_node != node) {
-
surface_source->set_text("..");
mesh_source->set_text("..");
populate_axis->select(1);
@@ -262,26 +245,24 @@ void MultiMeshEditor::_menu_option(int p_option) {
}
void MultiMeshEditor::edit(MultiMeshInstance3D *p_multimesh) {
-
node = p_multimesh;
}
void MultiMeshEditor::_browse(bool p_source) {
-
browsing_source = p_source;
std->get_scene_tree()->set_marked(node, false);
std->popup_centered_ratio();
- if (p_source)
+ if (p_source) {
std->set_title(TTR("Select a Source Mesh:"));
- else
+ } else {
std->set_title(TTR("Select a Target Surface:"));
+ }
}
void MultiMeshEditor::_bind_methods() {
}
MultiMeshEditor::MultiMeshEditor() {
-
options = memnew(MenuButton);
options->set_switch_on_hover(true);
Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
@@ -378,28 +359,23 @@ MultiMeshEditor::MultiMeshEditor() {
}
void MultiMeshEditorPlugin::edit(Object *p_object) {
-
multimesh_editor->edit(Object::cast_to<MultiMeshInstance3D>(p_object));
}
bool MultiMeshEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("MultiMeshInstance3D");
}
void MultiMeshEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
multimesh_editor->options->show();
} else {
-
multimesh_editor->options->hide();
multimesh_editor->edit(nullptr);
}
}
MultiMeshEditorPlugin::MultiMeshEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
multimesh_editor = memnew(MultiMeshEditor);
editor->get_viewport()->add_child(multimesh_editor);
diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h
index 15c9b91fee..2b0a0c137f 100644
--- a/editor/plugins/multimesh_editor_plugin.h
+++ b/editor/plugins/multimesh_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/gui/spin_box.h"
class MultiMeshEditor : public Control {
-
GDCLASS(MultiMeshEditor, Control);
friend class MultiMeshEditorPlugin;
@@ -83,7 +82,6 @@ public:
};
class MultiMeshEditorPlugin : public EditorPlugin {
-
GDCLASS(MultiMeshEditorPlugin, EditorPlugin);
MultiMeshEditor *multimesh_editor;
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index e41b32ac86..8cf9f01fa0 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -31,10 +31,8 @@
#include "navigation_polygon_editor_plugin.h"
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
-
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
if (!navpoly.is_valid()) {
-
navpoly = Ref<NavigationPolygon>(memnew(NavigationPolygon));
node->set_navigation_polygon(navpoly);
}
@@ -42,42 +40,38 @@ Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
}
Node2D *NavigationPolygonEditor::_get_node() const {
-
return node;
}
void NavigationPolygonEditor::_set_node(Node *p_polygon) {
-
node = Object::cast_to<NavigationRegion2D>(p_polygon);
}
int NavigationPolygonEditor::_get_polygon_count() const {
-
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
- if (navpoly.is_valid())
+ if (navpoly.is_valid()) {
return navpoly->get_outline_count();
- else
+ } else {
return 0;
+ }
}
Variant NavigationPolygonEditor::_get_polygon(int p_idx) const {
-
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
- if (navpoly.is_valid())
+ if (navpoly.is_valid()) {
return navpoly->get_outline(p_idx);
- else
+ } else {
return Variant(Vector<Vector2>());
+ }
}
void NavigationPolygonEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
-
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
navpoly->set_outline(p_idx, p_polygon);
navpoly->make_polygons_from_outlines();
}
void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) {
-
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
undo_redo->add_do_method(navpoly.ptr(), "add_outline", p_polygon);
undo_redo->add_undo_method(navpoly.ptr(), "remove_outline", navpoly->get_outline_count());
@@ -86,7 +80,6 @@ void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) {
}
void NavigationPolygonEditor::_action_remove_polygon(int p_idx) {
-
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
undo_redo->add_do_method(navpoly.ptr(), "remove_outline", p_idx);
undo_redo->add_undo_method(navpoly.ptr(), "add_outline_at_index", navpoly->get_outline(p_idx), p_idx);
@@ -95,7 +88,6 @@ void NavigationPolygonEditor::_action_remove_polygon(int p_idx) {
}
void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
-
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
undo_redo->add_do_method(navpoly.ptr(), "set_outline", p_idx, p_polygon);
undo_redo->add_undo_method(navpoly.ptr(), "set_outline", p_idx, p_previous);
@@ -104,14 +96,13 @@ void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_pr
}
bool NavigationPolygonEditor::_has_resource() const {
-
return node && node->get_navigation_polygon().is_valid();
}
void NavigationPolygonEditor::_create_resource() {
-
- if (!node)
+ if (!node) {
return;
+ }
undo_redo->create_action(TTR("Create Navigation Polygon"));
undo_redo->add_do_method(node, "set_navigation_polygon", Ref<NavigationPolygon>(memnew(NavigationPolygon)));
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 0bc35e2498..0767322c17 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/2d/navigation_region_2d.h"
class NavigationPolygonEditor : public AbstractPolygon2DEditor {
-
GDCLASS(NavigationPolygonEditor, AbstractPolygon2DEditor);
NavigationRegion2D *node;
@@ -62,7 +61,6 @@ public:
};
class NavigationPolygonEditorPlugin : public AbstractPolygon2DEditorPlugin {
-
GDCLASS(NavigationPolygonEditorPlugin, AbstractPolygon2DEditorPlugin);
public:
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 69f8efa86e..7bf8fd7d26 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -77,7 +77,6 @@
#define MAX_FOV 179
void ViewportRotationControl::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
axis_menu_options.clear();
axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT);
@@ -255,19 +254,16 @@ void ViewportRotationControl::_bind_methods() {
}
void Node3DEditorViewport::_update_camera(float p_interp_delta) {
-
bool is_orthogonal = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL;
Cursor old_camera_cursor = camera_cursor;
camera_cursor = cursor;
if (p_interp_delta > 0) {
-
//-------
// Perform smoothing
if (is_freelook_active()) {
-
// Higher inertia should increase "lag" (lerp with factor between 0 and 1)
// Inertia of zero should produce instant movement (lerp with factor of 1) in this case it returns a really high value and gets clamped to 1.
real_t inertia = EDITOR_GET("editors/3d/freelook/freelook_inertia");
@@ -294,7 +290,6 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) {
camera_cursor.pos = camera_cursor.eye_pos + forward * camera_cursor.distance;
} else {
-
//when not being manipulated, move softly
float free_orbit_inertia = EDITOR_GET("editors/3d/navigation_feel/orbit_inertia");
float free_translation_inertia = EDITOR_GET("editors/3d/navigation_feel/translation_inertia");
@@ -333,22 +328,17 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) {
//-------
// Apply camera transform
- float tolerance = 0.001;
+ real_t tolerance = 0.001;
bool equal = true;
- if (Math::abs(old_camera_cursor.x_rot - camera_cursor.x_rot) > tolerance || Math::abs(old_camera_cursor.y_rot - camera_cursor.y_rot) > tolerance) {
+ if (!Math::is_equal_approx(old_camera_cursor.x_rot, camera_cursor.x_rot, tolerance) || !Math::is_equal_approx(old_camera_cursor.y_rot, camera_cursor.y_rot, tolerance)) {
equal = false;
- }
-
- if (equal && old_camera_cursor.pos.distance_squared_to(camera_cursor.pos) > tolerance * tolerance) {
+ } else if (!old_camera_cursor.pos.is_equal_approx(camera_cursor.pos)) {
equal = false;
- }
-
- if (equal && Math::abs(old_camera_cursor.distance - camera_cursor.distance) > tolerance) {
+ } else if (!Math::is_equal_approx(old_camera_cursor.distance, camera_cursor.distance, tolerance)) {
equal = false;
}
if (!equal || p_interp_delta == 0 || is_freelook_active() || is_orthogonal != orthogonal) {
-
camera->set_global_transform(to_camera_transform(camera_cursor));
if (orthogonal) {
@@ -362,6 +352,7 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) {
update_transform_gizmo_view();
rotation_control->update();
}
+ spatial_editor->update_grid();
}
Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const {
@@ -370,29 +361,30 @@ Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) cons
camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot);
camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot);
- if (orthogonal)
+ if (orthogonal) {
camera_transform.translate(0, 0, (get_zfar() - get_znear()) / 2.0);
- else
+ } else {
camera_transform.translate(0, 0, p_cursor.distance);
+ }
return camera_transform;
}
int Node3DEditorViewport::get_selected_count() const {
-
Map<Node *, Object *> &selection = editor_selection->get_selection();
int count = 0;
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->key());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
count++;
}
@@ -401,62 +393,55 @@ int Node3DEditorViewport::get_selected_count() const {
}
float Node3DEditorViewport::get_znear() const {
-
return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z);
}
-float Node3DEditorViewport::get_zfar() const {
+float Node3DEditorViewport::get_zfar() const {
return CLAMP(spatial_editor->get_zfar(), MIN_Z, MAX_Z);
}
-float Node3DEditorViewport::get_fov() const {
+float Node3DEditorViewport::get_fov() const {
return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV);
}
Transform Node3DEditorViewport::_get_camera_transform() const {
-
return camera->get_global_transform();
}
Vector3 Node3DEditorViewport::_get_camera_position() const {
-
return _get_camera_transform().origin;
}
Point2 Node3DEditorViewport::_point_to_screen(const Vector3 &p_point) {
-
return camera->unproject_position(p_point) * subviewport_container->get_stretch_shrink();
}
Vector3 Node3DEditorViewport::_get_ray_pos(const Vector2 &p_pos) const {
-
return camera->project_ray_origin(p_pos / subviewport_container->get_stretch_shrink());
}
Vector3 Node3DEditorViewport::_get_camera_normal() const {
-
return -_get_camera_transform().basis.get_axis(2);
}
Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const {
-
return camera->project_ray_normal(p_pos / subviewport_container->get_stretch_shrink());
}
void Node3DEditorViewport::_clear_selected() {
-
editor_selection->clear();
}
void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) {
-
- if (clicked.is_null())
+ if (clicked.is_null()) {
return;
+ }
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked));
Node3D *selected = Object::cast_to<Node3D>(node);
- if (!selected)
+ if (!selected) {
return;
+ }
if (!p_allow_locked) {
// Replace the node by the group if grouped
@@ -475,7 +460,6 @@ void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_
}
void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) {
-
if (!p_append) {
editor_selection->clear();
}
@@ -484,20 +468,20 @@ void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) {
//erase
editor_selection->remove_node(p_node);
} else {
-
editor_selection->add_node(p_node);
}
if (p_single) {
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
editor->call("edit_node", p_node);
+ }
}
}
ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) {
-
- if (r_gizmo_handle)
+ if (r_gizmo_handle) {
*r_gizmo_handle = -1;
+ }
Vector3 ray = _get_ray(p_pos);
Vector3 pos = _get_ray_pos(p_pos);
@@ -513,11 +497,11 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b
int selected_handle = -1;
for (int i = 0; i < instances.size(); i++) {
-
Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i]));
- if (!spat)
+ if (!spat) {
continue;
+ }
Ref<EditorNode3DGizmo> seg = spat->get_gizmo();
@@ -532,16 +516,17 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b
int handle = -1;
bool inters = seg->intersect_ray(camera, shrinked_pos, point, normal, &handle, p_alt_select);
- if (!inters)
+ if (!inters) {
continue;
+ }
float dist = pos.distance_to(point);
- if (dist < 0)
+ if (dist < 0) {
continue;
+ }
if (dist < closest_dist) {
-
item = Object::cast_to<Node>(spat);
while (item->get_owner() && item->get_owner() != edited_scene && !edited_scene->is_editable_instance(item->get_owner())) {
item = item->get_owner();
@@ -553,20 +538,20 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b
}
}
- if (!item)
+ if (!item) {
return ObjectID();
+ }
if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) {
-
- if (r_gizmo_handle)
+ if (r_gizmo_handle) {
*r_gizmo_handle = selected_handle;
+ }
}
return closest;
}
void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) {
-
Vector3 ray = _get_ray(p_pos);
Vector3 pos = _get_ray_pos(p_pos);
@@ -576,19 +561,21 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu
r_includes_current = false;
for (int i = 0; i < instances.size(); i++) {
-
Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i]));
- if (!spat)
+ if (!spat) {
continue;
+ }
Ref<EditorNode3DGizmo> seg = spat->get_gizmo();
- if (!seg.is_valid())
+ if (!seg.is_valid()) {
continue;
+ }
- if (found_gizmos.has(seg))
+ if (found_gizmos.has(seg)) {
continue;
+ }
found_gizmos.insert(seg);
Vector3 point;
@@ -597,16 +584,19 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu
int handle = -1;
bool inters = seg->intersect_ray(camera, p_pos, point, normal, nullptr, p_alt_select);
- if (!inters)
+ if (!inters) {
continue;
+ }
float dist = pos.distance_to(point);
- if (dist < 0)
+ if (dist < 0) {
continue;
+ }
- if (editor_selection->is_selected(spat))
+ if (editor_selection->is_selected(spat)) {
r_includes_current = true;
+ }
_RayResult res;
res.item = spat;
@@ -615,14 +605,14 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu
results.push_back(res);
}
- if (results.empty())
+ if (results.empty()) {
return;
+ }
results.sort();
}
Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
-
CameraMatrix cm;
if (orthogonal) {
cm.set_orthogonal(camera->get_size(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar());
@@ -641,9 +631,9 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) {
}
void Node3DEditorViewport::_select_region() {
-
- if (cursor.region_begin == cursor.region_end)
+ if (cursor.region_begin == cursor.region_end) {
return; //nothing really
+ }
float z_offset = MAX(0.0, 5.0 - get_znear());
@@ -671,7 +661,6 @@ void Node3DEditorViewport::_select_region() {
Vector3 cam_pos = _get_camera_position();
for (int i = 0; i < 4; i++) {
-
Vector3 a = _get_screen_to_space(box[i]);
Vector3 b = _get_screen_to_space(box[(i + 1) % 4]);
if (orthogonal) {
@@ -695,10 +684,10 @@ void Node3DEditorViewport::_select_region() {
Node *edited_scene = get_tree()->get_edited_scene_root();
for (int i = 0; i < instances.size(); i++) {
-
Node3D *sp = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i]));
- if (!sp || _is_node_locked(sp))
+ if (!sp || _is_node_locked(sp)) {
continue;
+ }
Node *item = Object::cast_to<Node>(sp);
while (item->get_owner() && item->get_owner() != edited_scene && !edited_scene->is_editable_instance(item->get_owner())) {
@@ -718,16 +707,19 @@ void Node3DEditorViewport::_select_region() {
item = sel;
}
- if (selected.find(item) != -1)
+ if (selected.find(item) != -1) {
continue;
+ }
- if (_is_node_locked(item))
+ if (_is_node_locked(item)) {
continue;
+ }
Ref<EditorNode3DGizmo> seg = sp->get_gizmo();
- if (!seg.is_valid())
+ if (!seg.is_valid()) {
continue;
+ }
if (seg->intersect_frustum(camera, frustum)) {
selected.push_back(item);
@@ -741,23 +733,22 @@ void Node3DEditorViewport::_select_region() {
}
void Node3DEditorViewport::_update_name() {
-
String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective");
if (auto_orthogonal) {
view_mode += " [auto]";
}
- if (name != "")
+ if (name != "") {
view_menu->set_text(name + " " + view_mode);
- else
+ } else {
view_menu->set_text(view_mode);
+ }
view_menu->set_size(Vector2(0, 0)); // resets the button size
}
void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
-
_edit.click_ray = _get_ray(Vector2(p_point.x, p_point.y));
_edit.click_ray_pos = _get_ray_pos(Vector2(p_point.x, p_point.y));
_edit.plane = TRANSFORM_VIEW;
@@ -767,14 +758,15 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
se->original = se->sp->get_global_gizmo_transform();
se->original_local = se->sp->get_local_gizmo_transform();
@@ -782,9 +774,7 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
}
static int _get_key_modifier_setting(const String &p_property) {
-
switch (EditorSettings::get_singleton()->get(p_property).operator int()) {
-
case 0:
return 0;
case 1:
@@ -800,24 +790,29 @@ static int _get_key_modifier_setting(const String &p_property) {
}
static int _get_key_modifier(Ref<InputEventWithModifiers> e) {
- if (e->get_shift())
+ if (e->get_shift()) {
return KEY_SHIFT;
- if (e->get_alt())
+ }
+ if (e->get_alt()) {
return KEY_ALT;
- if (e->get_control())
+ }
+ if (e->get_control()) {
return KEY_CONTROL;
- if (e->get_metakey())
+ }
+ if (e->get_metakey()) {
return KEY_META;
+ }
return 0;
}
bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) {
-
- if (!spatial_editor->is_gizmo_visible())
+ if (!spatial_editor->is_gizmo_visible()) {
return false;
+ }
if (get_selected_count() == 0) {
- if (p_highlight_only)
+ if (p_highlight_only) {
spatial_editor->select_gizmo_highlight_axis(-1);
+ }
return false;
}
@@ -828,18 +823,16 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
float gs = gizmo_scale;
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
-
int col_axis = -1;
float col_d = 1e20;
for (int i = 0; i < 3; i++) {
-
Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs * (GIZMO_ARROW_OFFSET + (GIZMO_ARROW_SIZE * 0.5));
float grabber_radius = gs * GIZMO_ARROW_SIZE;
Vector3 r;
- if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * MAX_Z, grabber_pos, grabber_radius, &r)) {
+ if (Geometry3D::segment_intersects_sphere(ray_pos, ray_pos + ray * MAX_Z, grabber_pos, grabber_radius, &r)) {
float d = r.distance_to(ray_pos);
if (d < col_d) {
col_d = d;
@@ -854,7 +847,6 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
col_d = 1e20;
for (int i = 0; i < 3; i++) {
-
Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized();
Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized();
@@ -864,10 +856,8 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
if (plane.intersects_ray(ray_pos, ray, &r)) {
-
float dist = r.distance_to(grabber_pos);
if (dist < (gs * GIZMO_PLANE_SIZE)) {
-
float d = ray_pos.distance_to(r);
if (d < col_d) {
col_d = d;
@@ -881,9 +871,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
if (col_axis != -1) {
-
if (p_highlight_only) {
-
spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_translate ? 6 : 0));
} else {
@@ -897,21 +885,19 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
-
int col_axis = -1;
float col_d = 1e20;
for (int i = 0; i < 3; i++) {
-
Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
Vector3 r;
- if (!plane.intersects_ray(ray_pos, ray, &r))
+ if (!plane.intersects_ray(ray_pos, ray, &r)) {
continue;
+ }
float dist = r.distance_to(gt.origin);
if (dist > gs * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gs * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) {
-
float d = ray_pos.distance_to(r);
if (d < col_d) {
col_d = d;
@@ -921,9 +907,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
if (col_axis != -1) {
-
if (p_highlight_only) {
-
spatial_editor->select_gizmo_highlight_axis(col_axis + 3);
} else {
//handle rotate
@@ -936,18 +920,16 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
-
int col_axis = -1;
float col_d = 1e20;
for (int i = 0; i < 3; i++) {
-
Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs * GIZMO_SCALE_OFFSET;
float grabber_radius = gs * GIZMO_ARROW_SIZE;
Vector3 r;
- if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * MAX_Z, grabber_pos, grabber_radius, &r)) {
+ if (Geometry3D::segment_intersects_sphere(ray_pos, ray_pos + ray * MAX_Z, grabber_pos, grabber_radius, &r)) {
float d = r.distance_to(ray_pos);
if (d < col_d) {
col_d = d;
@@ -962,7 +944,6 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
col_d = 1e20;
for (int i = 0; i < 3; i++) {
-
Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized();
Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized();
@@ -972,10 +953,8 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
if (plane.intersects_ray(ray_pos, ray, &r)) {
-
float dist = r.distance_to(grabber_pos);
if (dist < (gs * GIZMO_PLANE_SIZE)) {
-
float d = ray_pos.distance_to(r);
if (d < col_d) {
col_d = d;
@@ -989,9 +968,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
if (col_axis != -1) {
-
if (p_highlight_only) {
-
spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_scale ? 12 : 9));
} else {
@@ -1004,37 +981,36 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high
}
}
- if (p_highlight_only)
+ if (p_highlight_only) {
spatial_editor->select_gizmo_highlight_axis(-1);
+ }
return false;
}
void Node3DEditorViewport::_surface_mouse_enter() {
-
- if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
+ if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) {
surface->grab_focus();
+ }
}
void Node3DEditorViewport::_surface_mouse_exit() {
-
_remove_preview();
}
void Node3DEditorViewport::_surface_focus_enter() {
-
view_menu->set_disable_shortcuts(false);
}
void Node3DEditorViewport::_surface_focus_exit() {
-
view_menu->set_disable_shortcuts(true);
}
+
bool Node3DEditorViewport ::_is_node_locked(const Node *p_node) {
return p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_");
}
-void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
+void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
_find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->get_shift());
Node *scene = editor->get_edited_scene();
@@ -1051,7 +1027,6 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
clicked_wants_append = b->get_shift();
if (selection_results.size() == 1) {
-
clicked = selection_results[0].item->get_instance_id();
selection_results.clear();
@@ -1061,12 +1036,10 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
}
} else if (!selection_results.empty()) {
-
NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
StringName root_name = root_path.get_name(root_path.get_name_count() - 1);
for (int i = 0; i < selection_results.size(); i++) {
-
Node3D *spat = selection_results[i].item;
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
@@ -1107,17 +1080,18 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
}
void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
-
- if (previewing)
+ if (previewing) {
return; //do NONE
+ }
{
EditorNode *en = editor;
EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding();
if (!force_input_forwarding_list->empty()) {
bool discard = force_input_forwarding_list->forward_spatial_gui_input(camera, p_event, true);
- if (discard)
+ if (discard) {
return;
+ }
}
}
{
@@ -1125,8 +1099,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false);
- if (discard)
+ if (discard) {
return;
+ }
}
}
@@ -1137,23 +1112,23 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
float zoom_factor = 1 + (ZOOM_MULTIPLIER - 1) * b->get_factor();
switch (b->get_button_index()) {
-
case BUTTON_WHEEL_UP: {
- if (is_freelook_active())
+ if (is_freelook_active()) {
scale_freelook_speed(zoom_factor);
- else
+ } else {
scale_cursor_distance(1.0 / zoom_factor);
+ }
} break;
case BUTTON_WHEEL_DOWN: {
- if (is_freelook_active())
+ if (is_freelook_active()) {
scale_freelook_speed(1.0 / zoom_factor);
- else
+ } else {
scale_cursor_distance(zoom_factor);
+ }
} break;
case BUTTON_RIGHT: {
-
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
if (b->is_pressed() && _edit.gizmo.is_valid()) {
@@ -1163,11 +1138,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (_edit.mode == TRANSFORM_NONE && b->is_pressed()) {
-
if (b->get_alt()) {
-
- if (nav_scheme == NAVIGATION_MAYA)
+ if (nav_scheme == NAVIGATION_MAYA) {
break;
+ }
_list_select(b);
return;
@@ -1181,14 +1155,15 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
sp->set_global_transform(se->original);
}
@@ -1215,32 +1190,25 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} break;
case BUTTON_MIDDLE: {
-
if (b->is_pressed() && _edit.mode != TRANSFORM_NONE) {
-
switch (_edit.plane) {
-
case TRANSFORM_VIEW: {
-
_edit.plane = TRANSFORM_X_AXIS;
set_message(TTR("X-Axis Transform."), 2);
name = "";
_update_name();
} break;
case TRANSFORM_X_AXIS: {
-
_edit.plane = TRANSFORM_Y_AXIS;
set_message(TTR("Y-Axis Transform."), 2);
} break;
case TRANSFORM_Y_AXIS: {
-
_edit.plane = TRANSFORM_Z_AXIS;
set_message(TTR("Z-Axis Transform."), 2);
} break;
case TRANSFORM_Z_AXIS: {
-
_edit.plane = TRANSFORM_VIEW;
set_message(TTR("View Plane Transform."), 2);
@@ -1253,9 +1221,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} break;
case BUTTON_LEFT: {
-
if (b->is_pressed()) {
-
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
if ((nav_scheme == NAVIGATION_MAYA || nav_scheme == NAVIGATION_MODO) && b->get_alt()) {
break;
@@ -1280,7 +1246,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (can_select_gizmos && spatial_editor->get_selected()) {
-
Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo();
if (seg.is_valid()) {
int handle = -1;
@@ -1288,7 +1253,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Vector3 normal;
bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, b->get_shift());
if (inters && handle != -1) {
-
_edit.gizmo = seg;
_edit.gizmo_handle = handle;
_edit.gizmo_initial_value = seg->get_handle_value(handle);
@@ -1297,17 +1261,18 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
}
- if (_gizmo_select(_edit.mouse_pos))
+ if (_gizmo_select(_edit.mouse_pos)) {
break;
+ }
clicked = ObjectID();
clicked_includes_current = false;
if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) {
-
/* HANDLE ROTATION */
- if (get_selected_count() == 0)
+ if (get_selected_count() == 0) {
break; //bye
+ }
//handle rotate
_edit.mode = TRANSFORM_ROTATE;
_compute_edit(b->get_position());
@@ -1315,9 +1280,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) {
-
- if (get_selected_count() == 0)
+ if (get_selected_count() == 0) {
break; //bye
+ }
//handle translate
_edit.mode = TRANSFORM_TRANSLATE;
_compute_edit(b->get_position());
@@ -1325,9 +1290,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) {
-
- if (get_selected_count() == 0)
+ if (get_selected_count() == 0) {
break; //bye
+ }
//handle scale
_edit.mode = TRANSFORM_SCALE;
_compute_edit(b->get_position());
@@ -1345,9 +1310,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
clicked_wants_append = b->get_shift();
if (clicked.is_null()) {
-
- if (!clicked_wants_append)
+ if (!clicked_wants_append) {
_clear_selected();
+ }
//default to regionselect
cursor.region_select = true;
@@ -1356,13 +1321,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (clicked.is_valid() && gizmo_handle >= 0) {
-
Node3D *spa = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked));
if (spa) {
-
Ref<EditorNode3DGizmo> seg = spa->get_gizmo();
if (seg.is_valid()) {
-
_edit.gizmo = seg;
_edit.gizmo_handle = gizmo_handle;
_edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle);
@@ -1373,9 +1335,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
surface->update();
} else {
-
if (_edit.gizmo.is_valid()) {
-
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, false);
_edit.gizmo = Ref<EditorNode3DGizmo>();
break;
@@ -1387,9 +1347,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (cursor.region_select) {
-
- if (!clicked_wants_append)
+ if (!clicked_wants_append) {
_clear_selected();
+ }
_select_region();
cursor.region_select = false;
@@ -1397,21 +1357,21 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (_edit.mode != TRANSFORM_NONE) {
-
static const char *_transform_name[4] = { "None", "Rotate", "Translate", "Scale" };
undo_redo->create_action(_transform_name[_edit.mode]);
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
undo_redo->add_do_method(sp, "set_global_transform", sp->get_global_gizmo_transform());
undo_redo->add_undo_method(sp, "set_global_transform", se->original);
@@ -1431,14 +1391,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
-
_edit.mouse_pos = m->get_position();
if (spatial_editor->get_selected()) {
-
Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo();
if (seg.is_valid()) {
-
int selected_handle = -1;
int handle = -1;
@@ -1446,21 +1403,20 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Vector3 normal;
bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, false);
if (inters && handle != -1) {
-
selected_handle = handle;
}
if (selected_handle != spatial_editor->get_over_gizmo_handle()) {
spatial_editor->set_over_gizmo_handle(selected_handle);
spatial_editor->get_selected()->update_gizmo();
- if (selected_handle != -1)
+ if (selected_handle != -1) {
spatial_editor->select_gizmo_highlight_axis(-1);
+ }
}
}
}
if (spatial_editor->get_over_gizmo_handle() == -1 && !(m->get_button_mask() & 1) && !_edit.gizmo.is_valid()) {
-
_gizmo_select(_edit.mouse_pos, true);
}
@@ -1468,14 +1424,12 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
NavigationMode nav_mode = NAVIGATION_NONE;
if (_edit.gizmo.is_valid()) {
-
_edit.gizmo->set_handle(_edit.gizmo_handle, camera, m->get_position());
Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle);
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle);
set_message(n + ": " + String(v));
} else if (m->get_button_mask() & BUTTON_MASK_LEFT) {
-
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
nav_mode = NAVIGATION_ORBIT;
} else if (nav_scheme == NAVIGATION_MODO && m->get_alt() && m->get_shift()) {
@@ -1486,9 +1440,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
nav_mode = NAVIGATION_ORBIT;
} else {
if (clicked.is_valid()) {
-
if (!clicked_includes_current) {
-
_select_clicked(clicked_wants_append, true);
// Processing was deferred.
}
@@ -1505,8 +1457,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
return;
}
- if (_edit.mode == TRANSFORM_NONE)
+ if (_edit.mode == TRANSFORM_NONE) {
return;
+ }
Vector3 ray_pos = _get_ray_pos(m->get_position());
Vector3 ray = _get_ray(m->get_position());
@@ -1514,9 +1467,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
int snap_step_decimals = Math::range_step_decimals(snap);
switch (_edit.mode) {
-
case TRANSFORM_SCALE: {
-
Vector3 motion_mask;
Plane plane;
bool plane_mv = false;
@@ -1556,22 +1507,21 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
Vector3 intersection;
- if (!plane.intersects_ray(ray_pos, ray, &intersection))
+ if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
break;
+ }
Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click))
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
break;
+ }
Vector3 motion = intersection - click;
if (_edit.plane != TRANSFORM_VIEW) {
-
if (!plane_mv) {
-
motion = motion_mask.dot(motion) * motion_mask;
} else {
-
// Alternative planar scaling mode
if (_get_key_modifier(m) != KEY_SHIFT) {
motion = motion_mask.dot(motion) * motion_mask;
@@ -1581,8 +1531,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else {
float center_click_dist = click.distance_to(_edit.center);
float center_inters_dist = intersection.distance_to(_edit.center);
- if (center_click_dist == 0)
+ if (center_click_dist == 0) {
break;
+ }
float scale = center_inters_dist - center_click_dist;
motion = Vector3(scale, scale, scale);
@@ -1603,7 +1554,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")");
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp) {
continue;
@@ -1625,7 +1575,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Vector3 local_scale;
if (local_coords) {
-
Basis g = original.basis.orthonormalized();
Vector3 local_motion = g.inverse().xform(motion);
@@ -1639,13 +1588,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Basis check = original_local.basis;
check.scale(local_scale);
if (check.determinant() != 0) {
-
// Apply scale
sp->set_scale(local_scale);
}
} else {
-
if (_edit.snap || spatial_editor->is_snap_enabled()) {
motion.snap(Vector3(snap, snap, snap));
}
@@ -1664,7 +1611,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} break;
case TRANSFORM_TRANSLATE: {
-
Vector3 motion_mask;
Plane plane;
bool plane_mv = false;
@@ -1700,12 +1646,14 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
Vector3 intersection;
- if (!plane.intersects_ray(ray_pos, ray, &intersection))
+ if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
break;
+ }
Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click))
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
break;
+ }
Vector3 motion = intersection - click;
if (_edit.plane != TRANSFORM_VIEW) {
@@ -1728,7 +1676,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")");
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
if (!sp) {
continue;
@@ -1747,7 +1694,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Transform t;
if (local_coords) {
-
if (_edit.snap || spatial_editor->is_snap_enabled()) {
Basis g = original.basis.orthonormalized();
Vector3 local_motion = g.inverse().xform(motion);
@@ -1757,7 +1703,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} else {
-
if (_edit.snap || spatial_editor->is_snap_enabled()) {
motion.snap(Vector3(snap, snap, snap));
}
@@ -1774,7 +1719,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} break;
case TRANSFORM_ROTATE: {
-
Plane plane;
Vector3 axis;
@@ -1801,12 +1745,14 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
Vector3 intersection;
- if (!plane.intersects_ray(ray_pos, ray, &intersection))
+ if (!plane.intersects_ray(ray_pos, ray, &intersection)) {
break;
+ }
Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click))
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) {
break;
+ }
Vector3 y_axis = (click - _edit.center).normalized();
Vector3 x_axis = plane.normal.cross(y_axis).normalized();
@@ -1826,14 +1772,15 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
if (sp->has_meta("_edit_lock_")) {
continue;
@@ -1842,7 +1789,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Transform t;
if (local_coords) {
-
Transform original_local = se->original_local;
Basis rot = Basis(axis, angle);
@@ -1854,7 +1800,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
sp->set_scale(original_local.basis.get_scale()); // re-apply original scale
} else {
-
Transform original = se->original;
Transform r;
Transform base = Transform(Basis(), _edit.center);
@@ -1876,7 +1821,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} else if ((m->get_button_mask() & BUTTON_MASK_RIGHT) || freelook_active) {
-
if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) {
nav_mode = NAVIGATION_ZOOM;
} else if (freelook_active) {
@@ -1886,9 +1830,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} else if (m->get_button_mask() & BUTTON_MASK_MIDDLE) {
-
if (nav_scheme == NAVIGATION_GODOT) {
-
const int mod = _get_key_modifier(m);
if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) {
@@ -1901,8 +1843,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} else if (nav_scheme == NAVIGATION_MAYA) {
- if (m->get_alt())
+ if (m->get_alt()) {
nav_mode = NAVIGATION_PAN;
+ }
}
} else if (EditorSettings::get_singleton()->get("editors/3d/navigation/emulate_3_button_mouse")) {
@@ -1949,21 +1892,19 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
-
- if (is_freelook_active())
+ if (is_freelook_active()) {
scale_freelook_speed(magnify_gesture->get_factor());
- else
+ } else {
scale_cursor_distance(1.0 / magnify_gesture->get_factor());
+ }
}
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
-
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
NavigationMode nav_mode = NAVIGATION_NONE;
if (nav_scheme == NAVIGATION_GODOT) {
-
const int mod = _get_key_modifier(pan_gesture);
if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) {
@@ -1976,8 +1917,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
} else if (nav_scheme == NAVIGATION_MAYA) {
- if (pan_gesture->get_alt())
+ if (pan_gesture->get_alt()) {
nav_mode = NAVIGATION_PAN;
+ }
}
switch (nav_mode) {
@@ -2009,8 +1951,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
- if (!k->is_pressed())
+ if (!k->is_pressed()) {
return;
+ }
if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
if (_edit.mode != TRANSFORM_NONE) {
@@ -2053,8 +1996,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
_menu_option(VIEW_ALIGN_ROTATION_WITH_VIEW);
}
if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
- if (!get_selected_count() || _edit.mode != TRANSFORM_NONE)
+ if (!get_selected_count() || _edit.mode != TRANSFORM_NONE) {
return;
+ }
if (!AnimationPlayerEditor::singleton->get_track_editor()->has_keying()) {
set_message(TTR("Keying is disabled (no key inserted)."));
@@ -2064,10 +2008,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
spatial_editor->emit_signal("transform_key_request", sp, "", sp->get_transform());
}
@@ -2084,25 +2028,27 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}
if (k->get_keycode() == KEY_SPACE) {
- if (!k->is_pressed())
+ if (!k->is_pressed()) {
emit_signal("toggle_maximize_view", this);
+ }
}
}
// freelook uses most of the useful shortcuts, like save, so its ok
// to consider freelook active as end of the line for future events.
- if (freelook_active)
+ if (freelook_active) {
accept_event();
+ }
}
void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
-
const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
real_t pan_speed = 1 / 150.0;
int pan_speed_modifier = 10;
- if (nav_scheme == NAVIGATION_MAYA && p_event->get_shift())
+ if (nav_scheme == NAVIGATION_MAYA && p_event->get_shift()) {
pan_speed *= pan_speed_modifier;
+ }
Transform camera_transform;
@@ -2116,30 +2062,31 @@ void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const
}
void Node3DEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
-
const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
real_t zoom_speed = 1 / 80.0;
int zoom_speed_modifier = 10;
- if (nav_scheme == NAVIGATION_MAYA && p_event->get_shift())
+ if (nav_scheme == NAVIGATION_MAYA && p_event->get_shift()) {
zoom_speed *= zoom_speed_modifier;
+ }
NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/navigation/zoom_style").operator int();
if (zoom_style == NAVIGATION_ZOOM_HORIZONTAL) {
- if (p_relative.x > 0)
+ if (p_relative.x > 0) {
scale_cursor_distance(1 - p_relative.x * zoom_speed);
- else if (p_relative.x < 0)
+ } else if (p_relative.x < 0) {
scale_cursor_distance(1.0 / (1 + p_relative.x * zoom_speed));
+ }
} else {
- if (p_relative.y > 0)
+ if (p_relative.y > 0) {
scale_cursor_distance(1 + p_relative.y * zoom_speed);
- else if (p_relative.y < 0)
+ } else if (p_relative.y < 0) {
scale_cursor_distance(1.0 / (1 - p_relative.y * zoom_speed));
+ }
}
}
void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
-
if (lock_rotation) {
_nav_pan(p_event, p_relative);
return;
@@ -2159,16 +2106,17 @@ void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, cons
cursor.x_rot += p_relative.y * radians_per_pixel;
}
cursor.y_rot += p_relative.x * radians_per_pixel;
- if (cursor.x_rot > Math_PI / 2.0)
+ if (cursor.x_rot > Math_PI / 2.0) {
cursor.x_rot = Math_PI / 2.0;
- if (cursor.x_rot < -Math_PI / 2.0)
+ }
+ if (cursor.x_rot < -Math_PI / 2.0) {
cursor.x_rot = -Math_PI / 2.0;
+ }
name = "";
_update_name();
}
void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) {
-
if (orthogonal) {
_nav_pan(p_event, p_relative);
return;
@@ -2191,10 +2139,12 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const
cursor.x_rot += p_relative.y * radians_per_pixel;
}
cursor.y_rot += p_relative.x * radians_per_pixel;
- if (cursor.x_rot > Math_PI / 2.0)
+ if (cursor.x_rot > Math_PI / 2.0) {
cursor.x_rot = Math_PI / 2.0;
- if (cursor.x_rot < -Math_PI / 2.0)
+ }
+ if (cursor.x_rot < -Math_PI / 2.0) {
cursor.x_rot = -Math_PI / 2.0;
+ }
// Look is like the opposite of Orbit: the focus point rotates around the camera
Transform camera_transform = to_camera_transform(cursor);
@@ -2208,7 +2158,6 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const
}
void Node3DEditorViewport::set_freelook_active(bool active_now) {
-
if (!freelook_active && active_now) {
// Sync camera cursor to cursor to "cut" interpolation jumps due to changing referential
cursor = camera_cursor;
@@ -2240,30 +2189,32 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) {
}
void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
-
// Prevents zero distance which would short-circuit any scaling
- if (cursor.distance < ZOOM_MIN_DISTANCE)
+ if (cursor.distance < ZOOM_MIN_DISTANCE) {
cursor.distance = ZOOM_MIN_DISTANCE;
+ }
cursor.distance *= scale;
- if (cursor.distance < ZOOM_MIN_DISTANCE)
+ if (cursor.distance < ZOOM_MIN_DISTANCE) {
cursor.distance = ZOOM_MIN_DISTANCE;
+ }
zoom_indicator_delay = ZOOM_INDICATOR_DELAY_S;
surface->update();
}
void Node3DEditorViewport::scale_freelook_speed(real_t scale) {
-
// Prevents zero distance which would short-circuit any scaling
- if (freelook_speed < FREELOOK_MIN_SPEED)
+ if (freelook_speed < FREELOOK_MIN_SPEED) {
freelook_speed = FREELOOK_MIN_SPEED;
+ }
freelook_speed *= scale;
- if (freelook_speed < FREELOOK_MIN_SPEED)
+ if (freelook_speed < FREELOOK_MIN_SPEED) {
freelook_speed = FREELOOK_MIN_SPEED;
+ }
zoom_indicator_delay = ZOOM_INDICATOR_DELAY_S;
surface->update();
@@ -2294,7 +2245,6 @@ static bool is_shortcut_pressed(const String &p_path) {
}
void Node3DEditorViewport::_update_freelook(real_t delta) {
-
if (!is_freelook_active()) {
return;
}
@@ -2357,7 +2307,6 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
}
void Node3DEditorViewport::set_message(String p_message, float p_time) {
-
message = p_message;
message_time = p_time;
}
@@ -2372,9 +2321,7 @@ void Node3DEditorPlugin::edited_scene_changed() {
}
void Node3DEditorViewport::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
bool visible = is_visible_in_tree();
set_process(visible);
@@ -2391,7 +2338,6 @@ void Node3DEditorViewport::_notification(int p_what) {
}
if (p_what == NOTIFICATION_RESIZED) {
-
call_deferred("update_transform_gizmo_view");
}
@@ -2403,7 +2349,6 @@ void Node3DEditorViewport::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
-
real_t delta = get_process_delta_time();
if (zoom_indicator_delay > 0) {
@@ -2438,20 +2383,22 @@ void Node3DEditorViewport::_notification(int p_what) {
bool exist = false;
for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->key());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
Transform t = sp->get_global_gizmo_transform();
exist = true;
- if (se->last_xform == t && !se->last_xform_dirty)
+ if (se->last_xform == t && !se->last_xform_dirty) {
continue;
+ }
changed = true;
se->last_xform_dirty = false;
se->last_xform = t;
@@ -2475,15 +2422,15 @@ void Node3DEditorViewport::_notification(int p_what) {
}
if (message_time > 0) {
-
if (message != last_message) {
surface->update();
last_message = message;
}
message_time -= get_physics_process_delta_time();
- if (message_time < 0)
+ if (message_time < 0) {
surface->update();
+ }
}
//update shadow atlas if changed
@@ -2561,7 +2508,6 @@ void Node3DEditorViewport::_notification(int p_what) {
cpu_time_history_index = 0;
}
if (show_fps) {
-
cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid());
cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY;
float cpu_time = 0.0;
@@ -2600,7 +2546,6 @@ void Node3DEditorViewport::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
-
surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw));
surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput));
surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter));
@@ -2612,12 +2557,10 @@ void Node3DEditorViewport::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
_finish_gizmo_instances();
}
if (p_what == NOTIFICATION_THEME_CHANGED) {
-
view_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons"));
preview_camera->set_icon(get_theme_icon("Camera3D", "EditorIcons"));
@@ -2640,15 +2583,14 @@ void Node3DEditorViewport::_notification(int p_what) {
}
}
-static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> icon) {
-
+static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2D> icon, const Ref<Font> font, const String &text) {
// Adjust bar size from control height
- Vector2 surface_size = surface.get_size();
- real_t h = surface_size.y / 2.0;
- real_t y = (surface_size.y - h) / 2.0;
+ const Vector2 surface_size = surface.get_size();
+ const real_t h = surface_size.y / 2.0;
+ const real_t y = (surface_size.y - h) / 2.0;
- Rect2 r(10, y, 6, h);
- real_t sy = r.size.y * fill;
+ const Rect2 r(10 * EDSCALE, y, 6 * EDSCALE, h);
+ const real_t sy = r.size.y * fill;
// Note: because this bar appears over the viewport, it has to stay readable for any background color
// Draw both neutral dark and bright colors to account this
@@ -2656,13 +2598,15 @@ static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> ico
surface.draw_rect(Rect2(r.position.x, r.position.y + r.size.y - sy, r.size.x, sy), Color(1, 1, 1, 0.6));
surface.draw_rect(r.grow(1), Color(0, 0, 0, 0.7), false, Math::round(EDSCALE));
- Vector2 icon_size = icon->get_size();
- Vector2 icon_pos = Vector2(r.position.x - (icon_size.x - r.size.x) / 2, r.position.y + r.size.y + 2);
+ const Vector2 icon_size = icon->get_size();
+ const Vector2 icon_pos = Vector2(r.position.x - (icon_size.x - r.size.x) / 2, r.position.y + r.size.y + 2 * EDSCALE);
surface.draw_texture(icon, icon_pos);
+
+ // Draw text below the bar (for speed/zoom information).
+ surface.draw_string(font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), text);
}
void Node3DEditorViewport::_draw() {
-
EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
over_plugin_list->forward_spatial_draw_over_viewport(surface);
@@ -2704,7 +2648,6 @@ void Node3DEditorViewport::_draw() {
}
if (_edit.mode == TRANSFORM_ROTATE) {
-
Point2 center = _point_to_screen(_edit.center);
RenderingServer::get_singleton()->canvas_item_add_line(
ci,
@@ -2714,7 +2657,6 @@ void Node3DEditorViewport::_draw() {
Math::round(2 * EDSCALE));
}
if (previewing) {
-
Size2 ss = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
float aspect = ss.aspect();
Size2 s = get_size();
@@ -2723,14 +2665,12 @@ void Node3DEditorViewport::_draw() {
switch (previewing->get_keep_aspect_mode()) {
case Camera3D::KEEP_WIDTH: {
-
draw_rect.size = Size2(s.width, s.width / aspect);
draw_rect.position.x = 0;
draw_rect.position.y = (s.height - draw_rect.size.y) * 0.5;
} break;
case Camera3D::KEEP_HEIGHT: {
-
draw_rect.size = Size2(s.height * aspect, s.height);
draw_rect.position.y = 0;
draw_rect.position.x = (s.width - draw_rect.size.x) * 0.5;
@@ -2743,9 +2683,7 @@ void Node3DEditorViewport::_draw() {
surface->draw_rect(draw_rect, Color(0.6, 0.6, 0.1, 0.5), false, Math::round(2 * EDSCALE));
} else {
-
if (zoom_indicator_delay > 0.0) {
-
if (is_freelook_active()) {
// Show speed
@@ -2758,10 +2696,18 @@ void Node3DEditorViewport::_draw() {
// There is no real maximum speed so that factor can become negative,
// Let's make it look asymptotic instead (will decrease slower and slower).
- if (logscale_t < 0.25)
+ if (logscale_t < 0.25) {
logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0);
+ }
- draw_indicator_bar(*surface, 1.0 - logscale_t, get_theme_icon("ViewportSpeed", "EditorIcons"));
+ // Display the freelook speed to help the user get a better sense of scale.
+ const int precision = freelook_speed < 1.0 ? 2 : 1;
+ draw_indicator_bar(
+ *surface,
+ 1.0 - logscale_t,
+ get_theme_icon("ViewportSpeed", "EditorIcons"),
+ get_theme_font("font", "Label"),
+ vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision)));
}
} else {
@@ -2776,10 +2722,18 @@ void Node3DEditorViewport::_draw() {
// There is no real maximum distance so that factor can become negative,
// Let's make it look asymptotic instead (will decrease slower and slower).
- if (logscale_t < 0.25)
+ if (logscale_t < 0.25) {
logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0);
+ }
- draw_indicator_bar(*surface, logscale_t, get_theme_icon("ViewportZoom", "EditorIcons"));
+ // Display the zoom center distance to help the user get a better sense of scale.
+ const int precision = cursor.distance < 1.0 ? 2 : 1;
+ draw_indicator_bar(
+ *surface,
+ logscale_t,
+ get_theme_icon("ViewportZoom", "EditorIcons"),
+ get_theme_font("font", "Label"),
+ vformat("%s u", String::num(cursor.distance).pad_decimals(precision)));
}
}
}
@@ -2787,11 +2741,8 @@ void Node3DEditorViewport::_draw() {
}
void Node3DEditorViewport::_menu_option(int p_option) {
-
switch (p_option) {
-
case VIEW_TOP: {
-
cursor.y_rot = 0;
cursor.x_rot = Math_PI / 2.0;
set_message(TTR("Top View."), 2);
@@ -2801,7 +2752,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_BOTTOM: {
-
cursor.y_rot = 0;
cursor.x_rot = -Math_PI / 2.0;
set_message(TTR("Bottom View."), 2);
@@ -2811,7 +2761,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_LEFT: {
-
cursor.x_rot = 0;
cursor.y_rot = Math_PI / 2.0;
set_message(TTR("Left View."), 2);
@@ -2821,7 +2770,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_RIGHT: {
-
cursor.x_rot = 0;
cursor.y_rot = -Math_PI / 2.0;
set_message(TTR("Right View."), 2);
@@ -2831,7 +2779,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_FRONT: {
-
cursor.x_rot = 0;
cursor.y_rot = 0;
set_message(TTR("Front View."), 2);
@@ -2841,7 +2788,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_REAR: {
-
cursor.x_rot = 0;
cursor.y_rot = Math_PI;
set_message(TTR("Rear View."), 2);
@@ -2851,19 +2797,17 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_CENTER_TO_ORIGIN: {
-
cursor.pos = Vector3(0, 0, 0);
} break;
case VIEW_CENTER_TO_SELECTION: {
-
focus_selection();
} break;
case VIEW_ALIGN_TRANSFORM_WITH_VIEW: {
-
- if (!get_selected_count())
+ if (!get_selected_count()) {
break;
+ }
Transform camera_transform = camera->get_global_transform();
@@ -2872,14 +2816,15 @@ void Node3DEditorViewport::_menu_option(int p_option) {
undo_redo->create_action(TTR("Align Transform with View"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
Transform xform;
if (orthogonal) {
@@ -2897,9 +2842,9 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_ALIGN_ROTATION_WITH_VIEW: {
-
- if (!get_selected_count())
+ if (!get_selected_count()) {
break;
+ }
Transform camera_transform = camera->get_global_transform();
@@ -2907,14 +2852,15 @@ void Node3DEditorViewport::_menu_option(int p_option) {
undo_redo->create_action(TTR("Align Rotation with View"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
undo_redo->add_do_method(sp, "set_rotation", camera_transform.basis.get_rotation());
undo_redo->add_undo_method(sp, "set_rotation", sp->get_rotation());
@@ -2923,15 +2869,12 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_ENVIRONMENT: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
if (current) {
-
camera->set_environment(RES());
} else {
-
camera->set_environment(Node3DEditor::get_singleton()->get_viewport_environment());
}
@@ -2939,7 +2882,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_PERSPECTIVE: {
-
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), true);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false);
orthogonal = false;
@@ -2949,7 +2891,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_ORTHOGONAL: {
-
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), false);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true);
orthogonal = true;
@@ -2959,7 +2900,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_AUTO_ORTHOGONAL: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
@@ -2970,7 +2910,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
}
} break;
case VIEW_LOCK_ROTATION: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
bool current = view_menu->get_popup()->is_item_checked(idx);
lock_rotation = !current;
@@ -2983,7 +2922,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_AUDIO_LISTENER: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
@@ -2992,7 +2930,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_AUDIO_DOPPLER: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
@@ -3001,7 +2938,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_CINEMATIC_PREVIEW: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
@@ -3012,38 +2948,36 @@ void Node3DEditorViewport::_menu_option(int p_option) {
if (current) {
preview_camera->hide();
} else {
- if (previewing != nullptr)
+ if (previewing != nullptr) {
preview_camera->show();
+ }
}
} break;
case VIEW_GIZMOS: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
- if (current)
+ if (current) {
camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER));
- else
+ } else {
camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_GRID_LAYER));
+ }
view_menu->get_popup()->set_item_checked(idx, current);
} break;
case VIEW_HALF_RESOLUTION: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
view_menu->get_popup()->set_item_checked(idx, current);
} break;
case VIEW_INFORMATION: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_INFORMATION);
bool current = view_menu->get_popup()->is_item_checked(idx);
view_menu->get_popup()->set_item_checked(idx, !current);
} break;
case VIEW_FRAME_TIME: {
-
int idx = view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME);
bool current = view_menu->get_popup()->is_item_checked(idx);
view_menu->get_popup()->set_item_checked(idx, !current);
@@ -3065,7 +2999,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_DISPLAY_DEBUG_PSSM_SPLITS:
case VIEW_DISPLAY_DEBUG_DECAL_ATLAS:
case VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER: {
-
static const int display_options[] = {
VIEW_DISPLAY_NORMAL,
VIEW_DISPLAY_WIREFRAME,
@@ -3109,7 +3042,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
int idx = 0;
while (display_options[idx] != VIEW_MAX) {
-
int id = display_options[idx];
int item_idx = view_menu->get_popup()->get_item_index(id);
if (item_idx != -1) {
@@ -3137,7 +3069,6 @@ void Node3DEditorViewport::_set_auto_orthogonal() {
}
void Node3DEditorViewport::_preview_exited_scene() {
-
preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview));
preview_camera->set_pressed(false);
_toggle_camera_preview(false);
@@ -3146,7 +3077,6 @@ void Node3DEditorViewport::_preview_exited_scene() {
}
void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
-
uint32_t layer = 1 << (GIZMO_BASE_LAYER + p_idx);
for (int i = 0; i < 3; i++) {
@@ -3188,7 +3118,6 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) {
}
void Node3DEditorViewport::_finish_gizmo_instances() {
-
for (int i = 0; i < 3; i++) {
RS::get_singleton()->free(move_gizmo_instance[i]);
RS::get_singleton()->free(move_plane_gizmo_instance[i]);
@@ -3197,25 +3126,24 @@ void Node3DEditorViewport::_finish_gizmo_instances() {
RS::get_singleton()->free(scale_plane_gizmo_instance[i]);
}
}
-void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {
+void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {
ERR_FAIL_COND(p_activate && !preview);
ERR_FAIL_COND(!p_activate && !previewing);
rotation_control->set_visible(!p_activate);
if (!p_activate) {
-
previewing->disconnect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
previewing = nullptr;
RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
- if (!preview)
+ if (!preview) {
preview_camera->hide();
+ }
view_menu->set_disabled(false);
surface->update();
} else {
-
previewing = preview;
previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
@@ -3227,8 +3155,9 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {
void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) {
previewing_cinema = p_activate;
if (!previewing_cinema) {
- if (previewing != nullptr)
+ if (previewing != nullptr) {
previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
+ }
previewing = nullptr;
RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
@@ -3244,9 +3173,9 @@ void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) {
}
void Node3DEditorViewport::_selection_result_pressed(int p_result) {
-
- if (selection_results.size() <= p_result)
+ if (selection_results.size() <= p_result) {
return;
+ }
clicked = selection_results[p_result].item->get_instance_id();
@@ -3257,24 +3186,23 @@ void Node3DEditorViewport::_selection_result_pressed(int p_result) {
}
void Node3DEditorViewport::_selection_menu_hide() {
-
selection_results.clear();
selection_menu->clear();
selection_menu->set_size(Vector2(0, 0));
}
void Node3DEditorViewport::set_can_preview(Camera3D *p_preview) {
-
preview = p_preview;
- if (!preview_camera->is_pressed() && !previewing_cinema)
+ if (!preview_camera->is_pressed() && !previewing_cinema) {
preview_camera->set_visible(p_preview);
+ }
}
void Node3DEditorViewport::update_transform_gizmo_view() {
-
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
Transform xform = spatial_editor->get_gizmo_transform();
@@ -3298,8 +3226,9 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
float d0 = camera->unproject_position(camera_xform.origin + camz * gizmo_d).y;
float d1 = camera->unproject_position(camera_xform.origin + camz * gizmo_d + camy).y;
float dd = Math::abs(d0 - d1);
- if (dd == 0)
+ if (dd == 0) {
dd = 0.0001;
+ }
float gizmo_size = EditorSettings::get_singleton()->get("editors/3d/manipulator_gizmo_size");
// At low viewport heights, multiply the gizmo scale based on the viewport height.
@@ -3328,23 +3257,27 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
}
void Node3DEditorViewport::set_state(const Dictionary &p_state) {
-
- if (p_state.has("position"))
+ if (p_state.has("position")) {
cursor.pos = p_state["position"];
- if (p_state.has("x_rotation"))
+ }
+ if (p_state.has("x_rotation")) {
cursor.x_rot = p_state["x_rotation"];
- if (p_state.has("y_rotation"))
+ }
+ if (p_state.has("y_rotation")) {
cursor.y_rot = p_state["y_rotation"];
- if (p_state.has("distance"))
+ }
+ if (p_state.has("distance")) {
cursor.distance = p_state["distance"];
+ }
if (p_state.has("use_orthogonal")) {
bool orth = p_state["use_orthogonal"];
- if (orth)
+ if (orth) {
_menu_option(VIEW_ORTHOGONAL);
- else
+ } else {
_menu_option(VIEW_PERSPECTIVE);
+ }
}
if (p_state.has("view_name")) {
name = p_state["view_name"];
@@ -3362,8 +3295,9 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
int display = p_state["display_mode"];
int idx = view_menu->get_popup()->get_item_index(display);
- if (!view_menu->get_popup()->is_item_checked(idx))
+ if (!view_menu->get_popup()->is_item_checked(idx)) {
_menu_option(display);
+ }
}
if (p_state.has("lock_rotation")) {
lock_rotation = p_state["lock_rotation"];
@@ -3374,8 +3308,9 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
if (p_state.has("use_environment")) {
bool env = p_state["use_environment"];
- if (env != camera->get_environment().is_valid())
+ if (env != camera->get_environment().is_valid()) {
_menu_option(VIEW_ENVIRONMENT);
+ }
}
if (p_state.has("listener")) {
bool listener = p_state["listener"];
@@ -3395,22 +3330,25 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
bool gizmos = p_state["gizmos"];
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
- if (view_menu->get_popup()->is_item_checked(idx) != gizmos)
+ if (view_menu->get_popup()->is_item_checked(idx) != gizmos) {
_menu_option(VIEW_GIZMOS);
+ }
}
if (p_state.has("information")) {
bool information = p_state["information"];
int idx = view_menu->get_popup()->get_item_index(VIEW_INFORMATION);
- if (view_menu->get_popup()->is_item_checked(idx) != information)
+ if (view_menu->get_popup()->is_item_checked(idx) != information) {
_menu_option(VIEW_INFORMATION);
+ }
}
if (p_state.has("frame_time")) {
bool fps = p_state["frame_time"];
int idx = view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME);
- if (view_menu->get_popup()->is_item_checked(idx) != fps)
+ if (view_menu->get_popup()->is_item_checked(idx) != fps) {
_menu_option(VIEW_FRAME_TIME);
+ }
}
if (p_state.has("half_res")) {
bool half_res = p_state["half_res"];
@@ -3444,7 +3382,6 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
}
Dictionary Node3DEditorViewport::get_state() const {
-
Dictionary d;
d["position"] = cursor.pos;
d["x_rotation"] = cursor.x_rot;
@@ -3455,14 +3392,15 @@ Dictionary Node3DEditorViewport::get_state() const {
d["view_name"] = name;
d["auto_orthogonal"] = auto_orthogonal;
d["auto_orthogonal_enabled"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL));
- if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL)))
+ if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL))) {
d["display_mode"] = VIEW_DISPLAY_NORMAL;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME))) {
d["display_mode"] = VIEW_DISPLAY_WIREFRAME;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW))) {
d["display_mode"] = VIEW_DISPLAY_OVERDRAW;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS))) {
d["display_mode"] = VIEW_DISPLAY_SHADELESS;
+ }
d["listener"] = viewport->is_audio_listener();
d["doppler"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER));
d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS));
@@ -3470,16 +3408,17 @@ Dictionary Node3DEditorViewport::get_state() const {
d["frame_time"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME));
d["half_res"] = subviewport_container->get_stretch_shrink() > 1;
d["cinematic_preview"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW));
- if (previewing)
+ if (previewing) {
d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
- if (lock_rotation)
+ }
+ if (lock_rotation) {
d["lock_rotation"] = lock_rotation;
+ }
return d;
}
void Node3DEditorViewport::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &Node3DEditorViewport::update_transform_gizmo_view); // Used by call_deferred.
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &Node3DEditorViewport::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &Node3DEditorViewport::drop_data_fw);
@@ -3489,7 +3428,6 @@ void Node3DEditorViewport::_bind_methods() {
}
void Node3DEditorViewport::reset() {
-
orthogonal = false;
auto_orthogonal = false;
lock_rotation = false;
@@ -3498,17 +3436,14 @@ void Node3DEditorViewport::reset() {
last_message = "";
name = "";
- cursor.x_rot = 0.5;
- cursor.y_rot = 0.5;
- cursor.distance = 4;
- cursor.region_select = false;
- cursor.pos = Vector3();
+ cursor = Cursor();
_update_name();
}
void Node3DEditorViewport::focus_selection() {
- if (!get_selected_count())
+ if (!get_selected_count()) {
return;
+ }
Vector3 center;
int count = 0;
@@ -3516,14 +3451,15 @@ void Node3DEditorViewport::focus_selection() {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
center += sp->get_global_gizmo_transform().origin;
count++;
@@ -3557,11 +3493,11 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const
Vector3 normal = Vector3(0.0, 0.0, 0.0);
for (int i = 0; i < instances.size(); i++) {
-
MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(instances[i]));
- if (!mesh_instance)
+ if (!mesh_instance) {
continue;
+ }
Ref<EditorNode3DGizmo> seg = mesh_instance->get_gizmo();
@@ -3575,13 +3511,15 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const
Vector3 hit_normal;
bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, nullptr, false);
- if (!inters)
+ if (!inters) {
continue;
+ }
float dist = world_pos.distance_to(hit_point);
- if (dist < 0)
+ if (dist < 0) {
continue;
+ }
if (dist < closest_dist) {
closest_dist = dist;
@@ -3591,10 +3529,11 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const
}
Vector3 offset = Vector3();
for (int i = 0; i < 3; i++) {
- if (normal[i] > 0.0)
+ if (normal[i] > 0.0) {
offset[i] = (preview_bounds->get_size()[i] - (preview_bounds->get_size()[i] + preview_bounds->get_position()[i]));
- else if (normal[i] < 0.0)
+ } else if (normal[i] < 0.0) {
offset[i] = -(preview_bounds->get_size()[i] + preview_bounds->get_position()[i]);
+ }
}
return point + offset;
}
@@ -3732,14 +3671,19 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
- Transform global_transform;
- Node3D *parent_spatial = Object::cast_to<Node3D>(parent);
- if (parent_spatial)
- global_transform = parent_spatial->get_global_gizmo_transform();
+ Node3D *node3d = Object::cast_to<Node3D>(instanced_scene);
+ if (node3d) {
+ Transform global_transform;
+ Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
+ if (parent_node3d) {
+ global_transform = parent_node3d->get_global_gizmo_transform();
+ }
- global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
+ global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
+ global_transform.basis *= node3d->get_transform().basis;
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+ }
return true;
}
@@ -3781,7 +3725,6 @@ void Node3DEditorViewport::_perform_drop_data() {
}
bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
bool can_instance = false;
if (!preview_node->is_inside_tree()) {
@@ -3838,8 +3781,9 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant
}
void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
@@ -3878,14 +3822,13 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
}
Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
-
cpu_time_history_index = 0;
gpu_time_history_index = 0;
_edit.mode = TRANSFORM_NONE;
_edit.plane = TRANSFORM_VIEW;
_edit.edited_gizmo = 0;
- _edit.snap = 1;
+ _edit.snap = true;
_edit.gizmo_handle = 0;
index = p_index;
@@ -4132,11 +4075,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
//////////////////////////////////////////////////////////////
void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
Vector2 size = get_size();
@@ -4155,25 +4096,21 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
switch (view) {
case VIEW_USE_1_VIEWPORT: {
-
dragging_h = false;
dragging_v = false;
} break;
case VIEW_USE_2_VIEWPORTS: {
-
dragging_h = false;
} break;
case VIEW_USE_2_VIEWPORTS_ALT: {
-
dragging_v = false;
} break;
case VIEW_USE_3_VIEWPORTS:
case VIEW_USE_3_VIEWPORTS_ALT:
case VIEW_USE_4_VIEWPORTS: {
-
// Do nothing.
} break;
@@ -4187,7 +4124,6 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (view == VIEW_USE_3_VIEWPORTS || view == VIEW_USE_3_VIEWPORTS_ALT || view == VIEW_USE_4_VIEWPORTS) {
Vector2 size = get_size();
@@ -4225,15 +4161,12 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
}
void Node3DEditorViewportContainer::_notification(int p_what) {
-
if (p_what == NOTIFICATION_MOUSE_ENTER || p_what == NOTIFICATION_MOUSE_EXIT) {
-
mouseover = (p_what == NOTIFICATION_MOUSE_ENTER);
update();
}
if (p_what == NOTIFICATION_DRAW && mouseover) {
-
Ref<Texture2D> h_grabber = get_theme_icon("grabber", "HSplitContainer");
Ref<Texture2D> v_grabber = get_theme_icon("grabber", "VSplitContainer");
@@ -4254,26 +4187,21 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
int size_bottom = size.height - mid_h - v_sep / 2;
switch (view) {
-
case VIEW_USE_1_VIEWPORT: {
-
// Nothing to show.
} break;
case VIEW_USE_2_VIEWPORTS: {
-
draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
set_default_cursor_shape(CURSOR_VSPLIT);
} break;
case VIEW_USE_2_VIEWPORTS_ALT: {
-
draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
set_default_cursor_shape(CURSOR_HSPLIT);
} break;
case VIEW_USE_3_VIEWPORTS: {
-
if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4));
set_default_cursor_shape(CURSOR_DRAG);
@@ -4287,7 +4215,6 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_3_VIEWPORTS_ALT: {
-
if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2));
set_default_cursor_shape(CURSOR_DRAG);
@@ -4301,7 +4228,6 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_4_VIEWPORTS: {
-
Vector2 half(mid_w, mid_h);
if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0);
@@ -4319,7 +4245,6 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
}
if (p_what == NOTIFICATION_SORT_CHILDREN) {
-
Node3DEditorViewport *viewports[4];
int vc = 0;
for (int i = 0; i < get_child_count(); i++) {
@@ -4353,12 +4278,9 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
int size_bottom = size.height - mid_h - v_sep / 2;
switch (view) {
-
case VIEW_USE_1_VIEWPORT: {
-
viewports[0]->show();
for (int i = 1; i < 4; i++) {
-
viewports[i]->hide();
}
@@ -4366,13 +4288,12 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_2_VIEWPORTS: {
-
for (int i = 0; i < 4; i++) {
-
- if (i == 1 || i == 3)
+ if (i == 1 || i == 3) {
viewports[i]->hide();
- else
+ } else {
viewports[i]->show();
+ }
}
fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top)));
@@ -4380,26 +4301,24 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_2_VIEWPORTS_ALT: {
-
for (int i = 0; i < 4; i++) {
-
- if (i == 1 || i == 3)
+ if (i == 1 || i == 3) {
viewports[i]->hide();
- else
+ } else {
viewports[i]->show();
+ }
}
fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size.height)));
fit_child_in_rect(viewports[2], Rect2(Vector2(mid_w + h_sep / 2, 0), Vector2(size_right, size.height)));
} break;
case VIEW_USE_3_VIEWPORTS: {
-
for (int i = 0; i < 4; i++) {
-
- if (i == 1)
+ if (i == 1) {
viewports[i]->hide();
- else
+ } else {
viewports[i]->show();
+ }
}
fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size.width, size_top)));
@@ -4408,13 +4327,12 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_3_VIEWPORTS_ALT: {
-
for (int i = 0; i < 4; i++) {
-
- if (i == 1)
+ if (i == 1) {
viewports[i]->hide();
- else
+ } else {
viewports[i]->show();
+ }
}
fit_child_in_rect(viewports[0], Rect2(Vector2(), Vector2(size_left, size_top)));
@@ -4423,9 +4341,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_4_VIEWPORTS: {
-
for (int i = 0; i < 4; i++) {
-
viewports[i]->show();
}
@@ -4440,23 +4356,19 @@ void Node3DEditorViewportContainer::_notification(int p_what) {
}
void Node3DEditorViewportContainer::set_view(View p_view) {
-
view = p_view;
queue_sort();
}
Node3DEditorViewportContainer::View Node3DEditorViewportContainer::get_view() {
-
return view;
}
void Node3DEditorViewportContainer::_bind_methods() {
-
ClassDB::bind_method("_gui_input", &Node3DEditorViewportContainer::_gui_input);
}
Node3DEditorViewportContainer::Node3DEditorViewportContainer() {
-
set_clip_contents(true);
view = VIEW_USE_1_VIEWPORT;
mouseover = false;
@@ -4473,15 +4385,13 @@ Node3DEditorViewportContainer::Node3DEditorViewportContainer() {
Node3DEditor *Node3DEditor::singleton = nullptr;
Node3DEditorSelectedItem::~Node3DEditorSelectedItem() {
-
- if (sbox_instance.is_valid())
+ if (sbox_instance.is_valid()) {
RenderingServer::get_singleton()->free(sbox_instance);
+ }
}
void Node3DEditor::select_gizmo_highlight_axis(int p_axis) {
-
for (int i = 0; i < 3; i++) {
-
move_gizmo[i]->surface_set_material(0, i == p_axis ? gizmo_color_hl[i] : gizmo_color[i]);
move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? plane_gizmo_color_hl[i] : plane_gizmo_color[i]);
rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_color_hl[i] : gizmo_color[i]);
@@ -4491,7 +4401,6 @@ void Node3DEditor::select_gizmo_highlight_axis(int p_axis) {
}
void Node3DEditor::update_transform_gizmo() {
-
List<Node *> &selection = editor_selection->get_selected_node_list();
AABB center;
bool first = true;
@@ -4500,14 +4409,15 @@ void Node3DEditor::update_transform_gizmo() {
bool local_gizmo_coords = are_local_coords_enabled();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
Transform xf = se->sp->get_global_gizmo_transform();
@@ -4553,10 +4463,10 @@ void Node3DEditor::update_all_gizmos(Node *p_node) {
}
Object *Node3DEditor::_get_editor_data(Object *p_what) {
-
Node3D *sp = Object::cast_to<Node3D>(p_what);
- if (!sp)
+ if (!sp) {
return nullptr;
+ }
Node3DEditorSelectedItem *si = memnew(Node3DEditorSelectedItem);
@@ -4568,7 +4478,6 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) {
}
void Node3DEditor::_generate_selection_box() {
-
AABB aabb(Vector3(), Vector3(1, 1, 1));
aabb.grow_by(aabb.get_longest_axis_size() / 20.0);
@@ -4576,7 +4485,6 @@ void Node3DEditor::_generate_selection_box() {
st->begin(Mesh::PRIMITIVE_LINES);
for (int i = 0; i < 12; i++) {
-
Vector3 a, b;
aabb.get_edge(i, a, b);
@@ -4602,7 +4510,6 @@ void Node3DEditor::_generate_selection_box() {
}
Dictionary Node3DEditor::get_state() const {
-
Dictionary d;
d["snap_enabled"] = snap_enabled;
@@ -4613,18 +4520,19 @@ Dictionary Node3DEditor::get_state() const {
d["local_coords"] = tool_option_button[TOOL_OPT_LOCAL_COORDS]->is_pressed();
int vc = 0;
- if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT)))
+ if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT))) {
vc = 1;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS))) {
vc = 2;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS))) {
vc = 3;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS))) {
vc = 4;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT))) {
vc = 5;
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT))) {
vc = 6;
+ }
d["viewport_mode"] = vc;
Array vpdata;
@@ -4642,8 +4550,9 @@ Dictionary Node3DEditor::get_state() const {
Dictionary gizmos_status;
for (int i = 0; i < gizmo_plugins_by_name.size(); i++) {
- if (!gizmo_plugins_by_name[i]->can_be_hidden())
+ if (!gizmo_plugins_by_name[i]->can_be_hidden()) {
continue;
+ }
int state = gizmos_menu->get_item_state(gizmos_menu->get_item_index(i));
String name = gizmo_plugins_by_name[i]->get_name();
gizmos_status[name] = state;
@@ -4653,8 +4562,8 @@ Dictionary Node3DEditor::get_state() const {
return d;
}
-void Node3DEditor::set_state(const Dictionary &p_state) {
+void Node3DEditor::set_state(const Dictionary &p_state) {
Dictionary d = p_state;
if (d.has("snap_enabled")) {
@@ -4662,14 +4571,17 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
tool_option_button[TOOL_OPT_USE_SNAP]->set_pressed(d["snap_enabled"]);
}
- if (d.has("translate_snap"))
+ if (d.has("translate_snap")) {
snap_translate_value = d["translate_snap"];
+ }
- if (d.has("rotate_snap"))
+ if (d.has("rotate_snap")) {
snap_rotate_value = d["rotate_snap"];
+ }
- if (d.has("scale_snap"))
+ if (d.has("scale_snap")) {
snap_scale_value = d["scale_snap"];
+ }
_snap_update();
@@ -4681,18 +4593,19 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
if (d.has("viewport_mode")) {
int vc = d["viewport_mode"];
- if (vc == 1)
+ if (vc == 1) {
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
- else if (vc == 2)
+ } else if (vc == 2) {
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS);
- else if (vc == 3)
+ } else if (vc == 3) {
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS);
- else if (vc == 4)
+ } else if (vc == 4) {
_menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS);
- else if (vc == 5)
+ } else if (vc == 5) {
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT);
- else if (vc == 6)
+ } else if (vc == 6) {
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT);
+ }
}
if (d.has("viewports")) {
@@ -4708,12 +4621,15 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
}
}
- if (d.has("zfar"))
+ if (d.has("zfar")) {
settings_zfar->set_value(float(d["zfar"]));
- if (d.has("znear"))
+ }
+ if (d.has("znear")) {
settings_znear->set_value(float(d["znear"]));
- if (d.has("fov"))
+ }
+ if (d.has("fov")) {
settings_fov->set_value(float(d["fov"]));
+ }
if (d.has("show_grid")) {
bool use = d["show_grid"];
@@ -4737,8 +4653,9 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
gizmos_status.get_key_list(&keys);
for (int j = 0; j < gizmo_plugins_by_name.size(); ++j) {
- if (!gizmo_plugins_by_name[j]->can_be_hidden())
+ if (!gizmo_plugins_by_name[j]->can_be_hidden()) {
continue;
+ }
int state = EditorNode3DGizmoPlugin::VISIBLE;
for (int i = 0; i < keys.size(); i++) {
if (gizmo_plugins_by_name.write[j]->get_name() == keys[i]) {
@@ -4754,10 +4671,8 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
}
void Node3DEditor::edit(Node3D *p_spatial) {
-
if (p_spatial != selected) {
if (selected) {
-
Ref<EditorNode3DGizmo> seg = selected->get_gizmo();
if (seg.is_valid()) {
seg->set_selected(false);
@@ -4769,7 +4684,6 @@ void Node3DEditor::edit(Node3D *p_spatial) {
over_gizmo_handle = -1;
if (selected) {
-
Ref<EditorNode3DGizmo> seg = selected->get_gizmo();
if (seg.is_valid()) {
seg->set_selected(true);
@@ -4780,21 +4694,18 @@ void Node3DEditor::edit(Node3D *p_spatial) {
}
void Node3DEditor::_snap_changed() {
-
snap_translate_value = snap_translate->get_text().to_double();
snap_rotate_value = snap_rotate->get_text().to_double();
snap_scale_value = snap_scale->get_text().to_double();
}
void Node3DEditor::_snap_update() {
-
snap_translate->set_text(String::num(snap_translate_value));
snap_rotate->set_text(String::num(snap_rotate_value));
snap_scale->set_text(String::num(snap_scale_value));
}
void Node3DEditor::_xform_dialog_action() {
-
Transform t;
//translation
Vector3 scale;
@@ -4816,22 +4727,22 @@ void Node3DEditor::_xform_dialog_action() {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *sp = Object::cast_to<Node3D>(E->get());
- if (!sp)
+ if (!sp) {
continue;
+ }
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp);
- if (!se)
+ if (!se) {
continue;
+ }
bool post = xform_type->get_selected() > 0;
Transform tr = sp->get_global_gizmo_transform();
- if (post)
+ if (post) {
tr = tr * t;
- else {
-
+ } else {
tr.basis = t.basis * tr.basis;
tr.origin += t.origin;
}
@@ -4843,10 +4754,8 @@ void Node3DEditor::_xform_dialog_action() {
}
void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) {
-
switch (p_option) {
case MENU_TOOL_LOCAL_COORDS: {
-
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_pressed(pressed);
update_transform_gizmo();
} break;
@@ -4861,7 +4770,6 @@ void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) {
using Override = EditorDebuggerNode::CameraOverride;
if (pressed) {
-
debugger->set_camera_override((Override)(Override::OVERRIDE_3D_1 + camera_override_viewport_id));
} else {
debugger->set_camera_override(Override::OVERRIDE_NONE);
@@ -4872,7 +4780,6 @@ void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) {
}
void Node3DEditor::_menu_gizmo_toggled(int p_option) {
-
const int idx = gizmos_menu->get_item_index(p_option);
gizmos_menu->toggle_item_multistate(idx);
@@ -4911,8 +4818,9 @@ void Node3DEditor::_update_camera_override_button(bool p_game_running) {
void Node3DEditor::_update_camera_override_viewport(Object *p_viewport) {
Node3DEditorViewport *current_viewport = Object::cast_to<Node3DEditorViewport>(p_viewport);
- if (!current_viewport)
+ if (!current_viewport) {
return;
+ }
EditorDebuggerNode *const debugger = EditorDebuggerNode::get_singleton();
@@ -4925,29 +4833,24 @@ void Node3DEditor::_update_camera_override_viewport(Object *p_viewport) {
}
void Node3DEditor::_menu_item_pressed(int p_option) {
-
switch (p_option) {
-
case MENU_TOOL_SELECT:
case MENU_TOOL_MOVE:
case MENU_TOOL_ROTATE:
case MENU_TOOL_SCALE:
case MENU_TOOL_LIST_SELECT: {
-
- for (int i = 0; i < TOOL_MAX; i++)
+ for (int i = 0; i < TOOL_MAX; i++) {
tool_button[i]->set_pressed(i == p_option);
+ }
tool_mode = (ToolMode)p_option;
update_transform_gizmo();
} break;
case MENU_TRANSFORM_CONFIGURE_SNAP: {
-
snap_dialog->popup_centered(Size2(200, 180));
} break;
case MENU_TRANSFORM_DIALOG: {
-
for (int i = 0; i < 3; i++) {
-
xform_translate[i]->set_text("0");
xform_rotate[i]->set_text("0");
xform_scale[i]->set_text("1");
@@ -4957,7 +4860,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_1_VIEWPORT: {
-
viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_1_VIEWPORT);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), true);
@@ -4969,7 +4871,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_2_VIEWPORTS: {
-
viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_2_VIEWPORTS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
@@ -4981,7 +4882,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_2_VIEWPORTS_ALT: {
-
viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_2_VIEWPORTS_ALT);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
@@ -4993,7 +4893,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_3_VIEWPORTS: {
-
viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_3_VIEWPORTS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
@@ -5005,7 +4904,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_3_VIEWPORTS_ALT: {
-
viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_3_VIEWPORTS_ALT);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
@@ -5017,7 +4915,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_USE_4_VIEWPORTS: {
-
viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_4_VIEWPORTS);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
@@ -5029,7 +4926,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_ORIGIN: {
-
bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
origin_enabled = !is_checked;
@@ -5041,15 +4937,16 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), origin_enabled);
} break;
case MENU_VIEW_GRID: {
-
bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
grid_enabled = !is_checked;
for (int i = 0; i < 3; ++i) {
if (grid_enable[i]) {
- RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled);
grid_visible[i] = grid_enabled;
+ if (grid_instance[i].is_valid()) {
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled);
+ }
}
}
@@ -5057,7 +4954,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_VIEW_CAMERA_SETTINGS: {
-
settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50));
} break;
case MENU_SNAP_TO_FLOOR: {
@@ -5069,13 +4965,14 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *spatial = Object::cast_to<Node3D>(E->get());
- if (!spatial || !spatial->is_visible_in_tree())
+ if (!spatial || !spatial->is_visible_in_tree()) {
continue;
+ }
- if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(spatial, "set_meta", "_edit_lock_", true);
undo_redo->add_undo_method(spatial, "remove_meta", "_edit_lock_");
@@ -5093,13 +4990,14 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *spatial = Object::cast_to<Node3D>(E->get());
- if (!spatial || !spatial->is_visible_in_tree())
+ if (!spatial || !spatial->is_visible_in_tree()) {
continue;
+ }
- if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(spatial, "remove_meta", "_edit_lock_");
undo_redo->add_undo_method(spatial, "set_meta", "_edit_lock_", true);
@@ -5117,13 +5015,14 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *spatial = Object::cast_to<Node3D>(E->get());
- if (!spatial || !spatial->is_visible_in_tree())
+ if (!spatial || !spatial->is_visible_in_tree()) {
continue;
+ }
- if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(spatial, "set_meta", "_edit_group_", true);
undo_redo->add_undo_method(spatial, "remove_meta", "_edit_group_");
@@ -5140,13 +5039,14 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
List<Node *> &selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node3D *spatial = Object::cast_to<Node3D>(E->get());
- if (!spatial || !spatial->is_visible_in_tree())
+ if (!spatial || !spatial->is_visible_in_tree()) {
continue;
+ }
- if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ if (spatial->get_viewport() != EditorNode::get_singleton()->get_scene_root()) {
continue;
+ }
undo_redo->add_do_method(spatial, "remove_meta", "_edit_group_");
undo_redo->add_undo_method(spatial, "set_meta", "_edit_group_", true);
@@ -5162,7 +5062,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
}
void Node3DEditor::_init_indicators() {
-
{
origin_enabled = true;
grid_enabled = true;
@@ -5171,6 +5070,7 @@ void Node3DEditor::_init_indicators() {
indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ indicator_mat->set_transparency(StandardMaterial3D::Transparency::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS);
Vector<Color> origin_colors;
Vector<Vector3> origin_points;
@@ -5199,12 +5099,27 @@ void Node3DEditor::_init_indicators() {
origin_colors.push_back(origin_color);
origin_colors.push_back(origin_color);
- origin_points.push_back(axis * 4096);
- origin_points.push_back(axis * -4096);
+ origin_colors.push_back(origin_color);
+ origin_colors.push_back(origin_color);
+ origin_colors.push_back(origin_color);
+ origin_colors.push_back(origin_color);
+ // To both allow having a large origin size and avoid jitter
+ // at small scales, we should segment the line into pieces.
+ // 3 pieces seems to do the trick, and let's use powers of 2.
+ origin_points.push_back(axis * 1048576);
+ origin_points.push_back(axis * 1024);
+ origin_points.push_back(axis * 1024);
+ origin_points.push_back(axis * -1024);
+ origin_points.push_back(axis * -1024);
+ origin_points.push_back(axis * -1048576);
}
- grid_enable[1] = true;
- grid_visible[1] = true;
+ grid_enable[0] = EditorSettings::get_singleton()->get("editors/3d/grid_xy_plane");
+ grid_enable[1] = EditorSettings::get_singleton()->get("editors/3d/grid_yz_plane");
+ grid_enable[2] = EditorSettings::get_singleton()->get("editors/3d/grid_xz_plane");
+ grid_visible[0] = grid_enable[0];
+ grid_visible[1] = grid_enable[1];
+ grid_visible[2] = grid_enable[2];
_init_grid();
@@ -5224,11 +5139,9 @@ void Node3DEditor::_init_indicators() {
}
{
-
//move gizmo
for (int i = 0; i < 3; i++) {
-
Color col;
switch (i) {
case 0:
@@ -5276,7 +5189,6 @@ void Node3DEditor::_init_indicators() {
//translate
{
-
Ref<SurfaceTool> surftool = memnew(SurfaceTool);
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
@@ -5293,12 +5205,10 @@ void Node3DEditor::_init_indicators() {
int arrow_sides = 16;
for (int k = 0; k < arrow_sides; k++) {
-
Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
for (int j = 0; j < arrow_points - 1; j++) {
-
Vector3 points[4] = {
ma.xform(arrow[j]),
mb.xform(arrow[j]),
@@ -5365,7 +5275,6 @@ void Node3DEditor::_init_indicators() {
// Rotate
{
-
Ref<SurfaceTool> surftool = memnew(SurfaceTool);
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
@@ -5378,12 +5287,10 @@ void Node3DEditor::_init_indicators() {
};
for (int k = 0; k < 64; k++) {
-
Basis ma(ivec, Math_PI * 2 * float(k) / 64);
Basis mb(ivec, Math_PI * 2 * float(k + 1) / 64);
for (int j = 0; j < 4; j++) {
-
Vector3 points[4] = {
ma.xform(circle[j]),
mb.xform(circle[j]),
@@ -5423,12 +5330,10 @@ void Node3DEditor::_init_indicators() {
int arrow_sides = 4;
for (int k = 0; k < 4; k++) {
-
Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
for (int j = 0; j < arrow_points - 1; j++) {
-
Vector3 points[4] = {
ma.xform(arrow[j]),
mb.xform(arrow[j]),
@@ -5499,16 +5404,19 @@ void Node3DEditor::_init_indicators() {
}
void Node3DEditor::_update_gizmos_menu() {
-
gizmos_menu->clear();
for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) {
- if (!gizmo_plugins_by_name[i]->can_be_hidden())
+ if (!gizmo_plugins_by_name[i]->can_be_hidden()) {
continue;
+ }
String plugin_name = gizmo_plugins_by_name[i]->get_name();
const int plugin_state = gizmo_plugins_by_name[i]->get_state();
gizmos_menu->add_multistate_item(TTR(plugin_name), 3, plugin_state, i);
const int idx = gizmos_menu->get_item_index(i);
+ gizmos_menu->set_item_tooltip(
+ idx,
+ TTR("Click to toggle between visibility states.\n\nOpen eye: Gizmo is visible.\nClosed eye: Gizmo is hidden.\nHalf-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."));
switch (plugin_state) {
case EditorNode3DGizmoPlugin::VISIBLE:
gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible"));
@@ -5525,8 +5433,9 @@ void Node3DEditor::_update_gizmos_menu() {
void Node3DEditor::_update_gizmos_menu_theme() {
for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) {
- if (!gizmo_plugins_by_name[i]->can_be_hidden())
+ if (!gizmo_plugins_by_name[i]->can_be_hidden()) {
continue;
+ }
const int plugin_state = gizmo_plugins_by_name[i]->get_state();
const int idx = gizmos_menu->get_item_index(i);
switch (plugin_state) {
@@ -5544,6 +5453,14 @@ void Node3DEditor::_update_gizmos_menu_theme() {
}
void Node3DEditor::_init_grid() {
+ if (!grid_enabled) {
+ return;
+ }
+ Camera3D *camera = get_editor_viewport(0)->camera;
+ Vector3 camera_position = camera->get_translation();
+ if (camera_position == Vector3()) {
+ return; // Camera3D is invalid, don't draw the grid.
+ }
Vector<Color> grid_colors[3];
Vector<Vector3> grid_points[3];
@@ -5553,57 +5470,115 @@ void Node3DEditor::_init_grid() {
int grid_size = EditorSettings::get_singleton()->get("editors/3d/grid_size");
int primary_grid_steps = EditorSettings::get_singleton()->get("editors/3d/primary_grid_steps");
- for (int i = 0; i < 3; i++) {
- Vector3 axis;
- axis[i] = 1;
- Vector3 axis_n1;
- axis_n1[(i + 1) % 3] = 1;
- Vector3 axis_n2;
- axis_n2[(i + 2) % 3] = 1;
-
- for (int j = -grid_size; j <= grid_size; j++) {
- Vector3 p1 = axis_n1 * j + axis_n2 * -grid_size;
- Vector3 p1_dest = p1 * (-axis_n2 + axis_n1);
- Vector3 p2 = axis_n2 * j + axis_n1 * -grid_size;
- Vector3 p2_dest = p2 * (-axis_n1 + axis_n2);
-
- Color line_color = secondary_grid_color;
- if (origin_enabled && j == 0) {
- // Don't draw the center lines of the grid if the origin is enabled
- // The origin would overlap the grid lines in this case, causing flickering
- continue;
- } else if (j % primary_grid_steps == 0) {
- line_color = primary_grid_color;
+ // Which grid planes are enabled? Which should we generate?
+ grid_enable[0] = grid_visible[0] = EditorSettings::get_singleton()->get("editors/3d/grid_xy_plane");
+ grid_enable[1] = grid_visible[1] = EditorSettings::get_singleton()->get("editors/3d/grid_yz_plane");
+ grid_enable[2] = grid_visible[2] = EditorSettings::get_singleton()->get("editors/3d/grid_xz_plane");
+
+ // Offsets division_level for bigger or smaller grids.
+ // Default value is -0.2. -1.0 gives Blender-like behavior, 0.5 gives huge grids.
+ real_t division_level_bias = EditorSettings::get_singleton()->get("editors/3d/grid_division_level_bias");
+ // Default largest grid size is 100m, 10^2 (default value is 2).
+ int division_level_max = EditorSettings::get_singleton()->get("editors/3d/grid_division_level_max");
+ // Default smallest grid size is 1cm, 10^-2 (default value is -2).
+ int division_level_min = EditorSettings::get_singleton()->get("editors/3d/grid_division_level_min");
+ ERR_FAIL_COND_MSG(division_level_max < division_level_min, "The 3D grid's maximum division level cannot be lower than its minimum division level.");
+
+ if (primary_grid_steps != 10) { // Log10 of 10 is 1.
+ // Change of base rule, divide by ln(10).
+ real_t div = Math::log((real_t)primary_grid_steps) / (real_t)2.302585092994045901094;
+ // Trucation (towards zero) is intentional.
+ division_level_max = (int)(division_level_max / div);
+ division_level_min = (int)(division_level_min / div);
+ }
+
+ for (int a = 0; a < 3; a++) {
+ if (!grid_enable[a]) {
+ continue; // If this grid plane is disabled, skip generation.
+ }
+ int b = (a + 1) % 3;
+ int c = (a + 2) % 3;
+
+ real_t division_level = Math::log(Math::abs(camera_position[c])) / Math::log((double)primary_grid_steps) + division_level_bias;
+ division_level = CLAMP(division_level, division_level_min, division_level_max);
+ real_t division_level_floored = Math::floor(division_level);
+ real_t division_level_decimals = division_level - division_level_floored;
+
+ real_t small_step_size = Math::pow(primary_grid_steps, division_level_floored);
+ real_t large_step_size = small_step_size * primary_grid_steps;
+ real_t center_a = large_step_size * (int)(camera_position[a] / large_step_size);
+ real_t center_b = large_step_size * (int)(camera_position[b] / large_step_size);
+
+ real_t bgn_a = center_a - grid_size * small_step_size;
+ real_t end_a = center_a + grid_size * small_step_size;
+ real_t bgn_b = center_b - grid_size * small_step_size;
+ real_t end_b = center_b + grid_size * small_step_size;
+
+ // In each iteration of this loop, draw one line in each direction (so two lines per loop, in each if statement).
+ for (int i = -grid_size; i <= grid_size; i++) {
+ Color line_color;
+ // Is this a primary line? Set the appropriate color.
+ if (i % primary_grid_steps == 0) {
+ line_color = primary_grid_color.lerp(secondary_grid_color, division_level_decimals);
+ } else {
+ line_color = secondary_grid_color;
+ line_color.a = line_color.a * (1 - division_level_decimals);
+ }
+ // Makes lines farther from the center fade out.
+ // Due to limitations of lines, any that come near the camera have full opacity always.
+ // This should eventually be replaced by some kind of "distance fade" system, outside of this function.
+ // But the effect is still somewhat convincing...
+ line_color.a *= 1 - (1 - division_level_decimals * 0.9) * (Math::abs(i / (float)grid_size));
+
+ real_t position_a = center_a + i * small_step_size;
+ real_t position_b = center_b + i * small_step_size;
+
+ // Don't draw lines over the origin if it's enabled.
+ if (!(origin_enabled && Math::is_zero_approx(position_a))) {
+ Vector3 line_bgn = Vector3();
+ Vector3 line_end = Vector3();
+ line_bgn[a] = position_a;
+ line_end[a] = position_a;
+ line_bgn[b] = bgn_b;
+ line_end[b] = end_b;
+ grid_points[c].push_back(line_bgn);
+ grid_points[c].push_back(line_end);
+ grid_colors[c].push_back(line_color);
+ grid_colors[c].push_back(line_color);
}
- grid_points[i].push_back(p1);
- grid_points[i].push_back(p1_dest);
- grid_colors[i].push_back(line_color);
- grid_colors[i].push_back(line_color);
-
- grid_points[i].push_back(p2);
- grid_points[i].push_back(p2_dest);
- grid_colors[i].push_back(line_color);
- grid_colors[i].push_back(line_color);
+ if (!(origin_enabled && Math::is_zero_approx(position_b))) {
+ Vector3 line_bgn = Vector3();
+ Vector3 line_end = Vector3();
+ line_bgn[b] = position_b;
+ line_end[b] = position_b;
+ line_bgn[a] = bgn_a;
+ line_end[a] = end_a;
+ grid_points[c].push_back(line_bgn);
+ grid_points[c].push_back(line_end);
+ grid_colors[c].push_back(line_color);
+ grid_colors[c].push_back(line_color);
+ }
}
- grid[i] = RenderingServer::get_singleton()->mesh_create();
+ // Create a mesh from the pushed vector points and colors.
+ grid[c] = RenderingServer::get_singleton()->mesh_create();
Array d;
d.resize(RS::ARRAY_MAX);
- d[RenderingServer::ARRAY_VERTEX] = grid_points[i];
- d[RenderingServer::ARRAY_COLOR] = grid_colors[i];
- RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d);
- RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
- grid_instance[i] = RenderingServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world_3d()->get_scenario());
+ d[RenderingServer::ARRAY_VERTEX] = grid_points[c];
+ d[RenderingServer::ARRAY_COLOR] = grid_colors[c];
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[c], RenderingServer::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(grid[c], 0, indicator_mat->get_rid());
+ grid_instance[c] = RenderingServer::get_singleton()->instance_create2(grid[c], get_tree()->get_root()->get_world_3d()->get_scenario());
- RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]);
- RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], RS::SHADOW_CASTING_SETTING_OFF);
- RS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER);
+ // Yes, the end of this line is supposed to be a.
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[c], grid_visible[a]);
+ RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[c], RS::SHADOW_CASTING_SETTING_OFF);
+ RS::get_singleton()->instance_set_layer_mask(grid_instance[c], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER);
}
}
void Node3DEditor::_finish_indicators() {
-
RenderingServer::get_singleton()->free(origin_instance);
RenderingServer::get_singleton()->free(origin);
@@ -5617,16 +5592,21 @@ void Node3DEditor::_finish_grid() {
}
}
+void Node3DEditor::update_grid() {
+ _finish_grid();
+ _init_grid();
+}
+
bool Node3DEditor::is_any_freelook_active() const {
for (unsigned int i = 0; i < VIEWPORTS_COUNT; ++i) {
- if (viewports[i]->is_freelook_active())
+ if (viewports[i]->is_freelook_active()) {
return true;
+ }
}
return false;
}
void Node3DEditor::_refresh_menu_icons() {
-
bool all_locked = true;
bool all_grouped = true;
@@ -5798,16 +5778,15 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
}
void Node3DEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
-
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
snap_key_enabled = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
}
-void Node3DEditor::_notification(int p_what) {
+void Node3DEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
-
tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons"));
tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons"));
@@ -5840,14 +5819,12 @@ void Node3DEditor::_notification(int p_what) {
editor->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(false));
editor->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(true));
} else if (p_what == NOTIFICATION_ENTER_TREE) {
-
_register_all_gizmos();
_update_gizmos_menu();
_init_indicators();
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
_update_gizmos_menu_theme();
} else if (p_what == NOTIFICATION_EXIT_TREE) {
-
_finish_indicators();
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons"));
@@ -5884,39 +5861,33 @@ void Node3DEditor::_notification(int p_what) {
}
void Node3DEditor::add_control_to_menu_panel(Control *p_control) {
-
hbc_menu->add_child(p_control);
}
void Node3DEditor::remove_control_from_menu_panel(Control *p_control) {
-
hbc_menu->remove_child(p_control);
}
void Node3DEditor::set_can_preview(Camera3D *p_preview) {
-
for (int i = 0; i < 4; i++) {
viewports[i]->set_can_preview(p_preview);
}
}
VSplitContainer *Node3DEditor::get_shader_split() {
-
return shader_split;
}
HSplitContainer *Node3DEditor::get_palette_split() {
-
return palette_split;
}
void Node3DEditor::_request_gizmo(Object *p_obj) {
-
Node3D *sp = Object::cast_to<Node3D>(p_obj);
- if (!sp)
+ if (!sp) {
return;
+ }
if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_a_parent_of(sp)))) {
-
Ref<EditorNode3DGizmo> seg;
for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) {
@@ -5937,57 +5908,62 @@ void Node3DEditor::_request_gizmo(Object *p_obj) {
}
void Node3DEditor::_toggle_maximize_view(Object *p_viewport) {
- if (!p_viewport)
+ if (!p_viewport) {
return;
+ }
Node3DEditorViewport *current_viewport = Object::cast_to<Node3DEditorViewport>(p_viewport);
- if (!current_viewport)
+ if (!current_viewport) {
return;
+ }
int index = -1;
bool maximized = false;
for (int i = 0; i < 4; i++) {
if (viewports[i] == current_viewport) {
index = i;
- if (current_viewport->get_global_rect() == viewport_base->get_global_rect())
+ if (current_viewport->get_global_rect() == viewport_base->get_global_rect()) {
maximized = true;
+ }
break;
}
}
- if (index == -1)
+ if (index == -1) {
return;
+ }
if (!maximized) {
-
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
- if (i == (uint32_t)index)
+ if (i == (uint32_t)index) {
viewports[i]->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- else
+ } else {
viewports[i]->hide();
+ }
}
} else {
-
- for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++)
+ for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->show();
+ }
- if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT)))
+ if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT))) {
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS))) {
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS);
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT))) {
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT);
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS))) {
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS);
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT))) {
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT);
- else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS)))
+ } else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS))) {
_menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS);
+ }
}
}
void Node3DEditor::_node_removed(Node *p_node) {
-
- if (p_node == selected)
+ if (p_node == selected) {
selected = nullptr;
+ }
}
void Node3DEditor::_register_all_gizmos() {
@@ -6018,7 +5994,6 @@ void Node3DEditor::_register_all_gizmos() {
}
void Node3DEditor::_bind_methods() {
-
ClassDB::bind_method("_unhandled_key_input", &Node3DEditor::_unhandled_key_input);
ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data);
ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo);
@@ -6029,7 +6004,6 @@ void Node3DEditor::_bind_methods() {
}
void Node3DEditor::clear() {
-
settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0));
settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05));
settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0));
@@ -6048,7 +6022,6 @@ void Node3DEditor::clear() {
}
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
-
viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(Node3DEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
viewports[i]->viewport->set_as_audio_listener(i == 0);
}
@@ -6057,7 +6030,6 @@ void Node3DEditor::clear() {
}
Node3DEditor::Node3DEditor(EditorNode *p_editor) {
-
gizmo.visible = true;
gizmo.scale = 1.0;
@@ -6270,7 +6242,6 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
shader_split->add_child(viewport_base);
viewport_base->set_v_size_flags(SIZE_EXPAND_FILL);
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
-
viewports[i] = memnew(Node3DEditorViewport(this, editor, i));
viewports[i]->connect("toggle_maximize_view", callable_mp(this, &Node3DEditor::_toggle_maximize_view));
viewports[i]->connect("clicked", callable_mp(this, &Node3DEditor::_update_camera_override_viewport));
@@ -6355,7 +6326,6 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
xform_vbc->add_child(xform_hbc);
for (int i = 0; i < 3; i++) {
-
xform_translate[i] = memnew(LineEdit);
xform_translate[i]->set_h_size_flags(SIZE_EXPAND_FILL);
xform_hbc->add_child(xform_translate[i]);
@@ -6420,25 +6390,21 @@ Node3DEditor::~Node3DEditor() {
}
void Node3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
spatial_editor->show();
spatial_editor->set_process(true);
} else {
-
spatial_editor->hide();
spatial_editor->set_process(false);
}
}
-void Node3DEditorPlugin::edit(Object *p_object) {
+void Node3DEditorPlugin::edit(Object *p_object) {
spatial_editor->edit(Object::cast_to<Node3D>(p_object));
}
bool Node3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("Node3D");
}
@@ -6447,12 +6413,10 @@ Dictionary Node3DEditorPlugin::get_state() const {
}
void Node3DEditorPlugin::set_state(const Dictionary &p_state) {
-
spatial_editor->set_state(p_state);
}
void Node3DEditor::snap_cursor_to_plane(const Plane &p_plane) {
-
//cursor.pos=p_plane.project(cursor.pos);
}
@@ -6499,17 +6463,14 @@ float Node3DEditor::get_scale_snap() const {
}
void Node3DEditorPlugin::_bind_methods() {
-
ClassDB::bind_method("snap_cursor_to_plane", &Node3DEditorPlugin::snap_cursor_to_plane);
}
void Node3DEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) {
-
spatial_editor->snap_cursor_to_plane(p_plane);
}
struct _GizmoPluginPriorityComparator {
-
bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const {
if (p_a->get_priority() == p_b->get_priority()) {
return p_a->get_name() < p_b->get_name();
@@ -6519,7 +6480,6 @@ struct _GizmoPluginPriorityComparator {
};
struct _GizmoPluginNameComparator {
-
bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const {
return p_a->get_name() < p_b->get_name();
}
@@ -6545,7 +6505,6 @@ void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {
}
Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
spatial_editor = memnew(Node3DEditor(p_node));
spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -6559,7 +6518,6 @@ Node3DEditorPlugin::~Node3DEditorPlugin() {
}
void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) {
-
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
Vector<Ref<StandardMaterial3D>> mats;
@@ -6601,7 +6559,6 @@ void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color
}
void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) {
-
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
Vector<Ref<StandardMaterial3D>> icons;
@@ -6672,8 +6629,9 @@ Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_na
ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>());
ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>());
- if (p_gizmo.is_null() || materials[p_name].size() == 1)
+ if (p_gizmo.is_null() || materials[p_name].size() == 1) {
return materials[p_name][0];
+ }
int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0);
@@ -6703,15 +6661,15 @@ int EditorNode3DGizmoPlugin::get_priority() const {
}
Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) {
-
if (get_script_instance() && get_script_instance()->has_method("get_gizmo")) {
return get_script_instance()->call("get_gizmo", p_spatial);
}
Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial);
- if (ref.is_null())
+ if (ref.is_null()) {
return ref;
+ }
ref->set_plugin(this);
ref->set_spatial_node(p_spatial);
@@ -6764,14 +6722,14 @@ bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
}
Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
-
if (get_script_instance() && get_script_instance()->has_method("create_gizmo")) {
return get_script_instance()->call("create_gizmo", p_spatial);
}
Ref<EditorNode3DGizmo> ref;
- if (has_gizmo(p_spatial))
+ if (has_gizmo(p_spatial)) {
ref.instance();
+ }
return ref;
}
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index fdc0741651..83173b5ad2 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -46,7 +46,6 @@ class Node3DEditorViewport;
class SubViewportContainer;
class EditorNode3DGizmo : public Node3DGizmo {
-
GDCLASS(EditorNode3DGizmo, Node3DGizmo);
bool selected;
@@ -57,7 +56,6 @@ public:
bool is_selected() const { return selected; }
struct Instance {
-
RID instance;
Ref<ArrayMesh> mesh;
Ref<Material> material;
@@ -68,7 +66,6 @@ public:
bool can_intersect;
bool extra_margin;
Instance() {
-
billboard = false;
unscaled = false;
can_intersect = false;
@@ -179,7 +176,6 @@ public:
};
class Node3DEditorViewport : public Control {
-
GDCLASS(Node3DEditorViewport, Control);
friend class Node3DEditor;
friend class ViewportRotationControl;
@@ -299,7 +295,6 @@ private:
Label *fps_label;
struct _RayResult {
-
Node3D *item;
float depth;
int handle;
@@ -389,7 +384,6 @@ private:
} _edit;
struct Cursor {
-
Vector3 pos;
float x_rot, y_rot, distance;
Vector3 eye_pos; // Used in freelook mode
@@ -397,7 +391,9 @@ private:
Point2 region_begin, region_end;
Cursor() {
- x_rot = y_rot = 0.5;
+ // These rotations place the camera in +X +Y +Z, aka south east, facing north west.
+ x_rot = 0.5;
+ y_rot = -0.5;
distance = 4;
region_select = false;
}
@@ -490,7 +486,6 @@ public:
};
class Node3DEditorSelectedItem : public Object {
-
GDCLASS(Node3DEditorSelectedItem, Object);
public:
@@ -510,7 +505,6 @@ public:
};
class Node3DEditorViewportContainer : public Container {
-
GDCLASS(Node3DEditorViewportContainer, Container);
public:
@@ -551,7 +545,6 @@ public:
};
class Node3DEditor : public VBoxContainer {
-
GDCLASS(Node3DEditor, VBoxContainer);
public:
@@ -629,7 +622,6 @@ private:
AABB preview_bounds;
struct Gizmo {
-
bool visible;
float scale;
Transform transform;
@@ -776,6 +768,7 @@ public:
Ref<ArrayMesh> get_scale_gizmo(int idx) const { return scale_gizmo[idx]; }
Ref<ArrayMesh> get_scale_plane_gizmo(int idx) const { return scale_plane_gizmo[idx]; }
+ void update_grid();
void update_transform_gizmo();
void update_all_gizmos(Node *p_node = nullptr);
void snap_selected_nodes_to_floor();
@@ -819,7 +812,6 @@ public:
};
class Node3DEditorPlugin : public EditorPlugin {
-
GDCLASS(Node3DEditorPlugin, EditorPlugin);
Node3DEditor *spatial_editor;
@@ -849,7 +841,6 @@ public:
};
class EditorNode3DGizmoPlugin : public Resource {
-
GDCLASS(EditorNode3DGizmoPlugin, Resource);
public:
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 2edb337b1c..a3dab665b8 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -37,11 +37,8 @@
#include "editor/editor_settings.h"
void Path2DEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
-
//button_create->set_icon( get_icon("Edit","EditorIcons"));
//button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
//set_pressed_button(button_edit);
@@ -49,12 +46,11 @@ void Path2DEditor::_notification(int p_what) {
} break;
case NOTIFICATION_PHYSICS_PROCESS: {
-
} break;
}
}
-void Path2DEditor::_node_removed(Node *p_node) {
+void Path2DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = nullptr;
hide();
@@ -62,31 +58,31 @@ void Path2DEditor::_node_removed(Node *p_node) {
}
bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
- if (!node)
+ if (!node) {
return false;
+ }
- if (!node->is_visible_in_tree())
+ if (!node->is_visible_in_tree()) {
return false;
+ }
- if (!node->get_curve().is_valid())
+ if (!node->get_curve().is_valid()) {
return false;
+ }
real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius");
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Vector2 gpoint = mb->get_position();
Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
if (mb->is_pressed() && action == ACTION_NONE) {
-
Ref<Curve2D> curve = node->get_curve();
for (int i = 0; i < curve->get_point_count(); i++) {
-
real_t dist_to_p = gpoint.distance_to(xform.xform(curve->get_point_position(i)));
real_t dist_to_p_out = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_out(i)));
real_t dist_to_p_in = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_in(i)));
@@ -104,7 +100,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (mode == MODE_EDIT || mode == MODE_EDIT_CURVE) {
// In/out controls can be moved in multiple modes.
if (dist_to_p_out < grab_threshold && i < (curve->get_point_count() - 1)) {
-
action = ACTION_MOVING_OUT;
action_point = i;
moving_from = curve->get_point_out(i);
@@ -112,7 +107,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
orig_in_length = curve->get_point_in(action_point).length();
return true;
} else if (dist_to_p_in < grab_threshold && i > 0) {
-
action = ACTION_MOVING_IN;
action_point = i;
moving_from = curve->get_point_in(i);
@@ -126,7 +120,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
// Check for point deletion.
if ((mb->get_button_index() == BUTTON_RIGHT && mode == MODE_EDIT) || (mb->get_button_index() == BUTTON_LEFT && mode == MODE_DELETE)) {
if (dist_to_p < grab_threshold) {
-
undo_redo->create_action(TTR("Remove Point from Curve"));
undo_redo->add_do_method(curve.ptr(), "remove_point", i);
undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_position(i), curve->get_point_in(i), curve->get_point_out(i), i);
@@ -135,7 +128,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->commit_action();
return true;
} else if (dist_to_p_out < grab_threshold) {
-
undo_redo->create_action(TTR("Remove Out-Control from Curve"));
undo_redo->add_do_method(curve.ptr(), "set_point_out", i, Vector2());
undo_redo->add_undo_method(curve.ptr(), "set_point_out", i, curve->get_point_out(i));
@@ -144,7 +136,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->commit_action();
return true;
} else if (dist_to_p_in < grab_threshold) {
-
undo_redo->create_action(TTR("Remove In-Control from Curve"));
undo_redo->add_do_method(curve.ptr(), "set_point_in", i, Vector2());
undo_redo->add_undo_method(curve.ptr(), "set_point_in", i, curve->get_point_in(i));
@@ -159,7 +150,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
// Check for point creation.
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && ((mb->get_command() && mode == MODE_EDIT) || mode == MODE_CREATE)) {
-
Ref<Curve2D> curve = node->get_curve();
undo_redo->create_action(TTR("Add Point to Curve"));
@@ -189,11 +179,13 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
int len = curve->get_point_count();
for (int i = 0; i < len - 1; i++) {
float compareLength = curve->get_closest_offset(curve->get_point_position(i + 1));
- if (mbLength >= curve->get_closest_offset(curve->get_point_position(i)) && mbLength <= compareLength)
+ if (mbLength >= curve->get_closest_offset(curve->get_point_position(i)) && mbLength <= compareLength) {
insertion_point = i;
+ }
}
- if (insertion_point == -1)
+ if (insertion_point == -1) {
insertion_point = curve->get_point_count() - 2;
+ }
undo_redo->create_action(TTR("Split Curve"));
undo_redo->add_do_method(curve.ptr(), "add_point", xform.affine_inverse().xform(gpoint2), Vector2(0, 0), Vector2(0, 0), insertion_point + 1);
@@ -216,18 +208,15 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
// Check for point movement completion.
if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && action != ACTION_NONE) {
-
Ref<Curve2D> curve = node->get_curve();
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
switch (action) {
-
case ACTION_NONE:
// N/A, handled in above condition.
break;
case ACTION_MOVING_POINT: {
-
undo_redo->create_action(TTR("Move Point in Curve"));
undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint);
undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
@@ -238,7 +227,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} break;
case ACTION_MOVING_IN: {
-
undo_redo->create_action(TTR("Move In-Control in Curve"));
undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);
@@ -254,7 +242,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} break;
case ACTION_MOVING_OUT: {
-
undo_redo->create_action(TTR("Move Out-Control in Curve"));
undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);
undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from);
@@ -279,7 +266,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (action == ACTION_NONE && mode == MODE_EDIT) {
// Handle Edge Follow
bool old_edge = on_edge;
@@ -288,10 +274,12 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 gpoint = mm->get_position();
Ref<Curve2D> curve = node->get_curve();
- if (curve == nullptr)
+ if (curve == nullptr) {
return true;
- if (curve->get_point_count() < 2)
+ }
+ if (curve->get_point_count() < 2) {
return true;
+ }
// Find edge
edge_point = xform.xform(curve->get_closest_point(xform.affine_inverse().xform(mm->get_position())));
@@ -336,7 +324,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
switch (action) {
-
case ACTION_NONE:
// N/A, handled in above condition.
break;
@@ -348,15 +335,17 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
case ACTION_MOVING_IN: {
curve->set_point_in(action_point, new_pos);
- if (mirror_handle_angle)
+ if (mirror_handle_angle) {
curve->set_point_out(action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_out_length));
+ }
} break;
case ACTION_MOVING_OUT: {
curve->set_point_out(action_point, new_pos);
- if (mirror_handle_angle)
+ if (mirror_handle_angle) {
curve->set_point_in(action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_in_length));
+ }
} break;
}
@@ -369,9 +358,9 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
-
- if (!node || !node->is_visible_in_tree() || !node->get_curve().is_valid())
+ if (!node || !node->is_visible_in_tree() || !node->get_curve().is_valid()) {
return;
+ }
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
@@ -428,77 +417,73 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
void Path2DEditor::_node_visibility_changed() {
- if (!node)
+ if (!node) {
return;
+ }
canvas_item_editor->update_viewport();
}
void Path2DEditor::edit(Node *p_path2d) {
-
if (!canvas_item_editor) {
canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_path2d) {
-
node = Object::cast_to<Path2D>(p_path2d);
- if (!node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)))
+ if (!node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed))) {
node->connect("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed));
+ }
} else {
-
// node may have been deleted at this point
- if (node && node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)))
+ if (node && node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed))) {
node->disconnect("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed));
+ }
node = nullptr;
}
}
void Path2DEditor::_bind_methods() {
-
//ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option);
}
void Path2DEditor::_mode_selected(int p_mode) {
-
if (p_mode == MODE_CREATE) {
-
curve_create->set_pressed(true);
curve_edit->set_pressed(false);
curve_edit_curve->set_pressed(false);
curve_del->set_pressed(false);
} else if (p_mode == MODE_EDIT) {
-
curve_create->set_pressed(false);
curve_edit->set_pressed(true);
curve_edit_curve->set_pressed(false);
curve_del->set_pressed(false);
} else if (p_mode == MODE_EDIT_CURVE) {
-
curve_create->set_pressed(false);
curve_edit->set_pressed(false);
curve_edit_curve->set_pressed(true);
curve_del->set_pressed(false);
} else if (p_mode == MODE_DELETE) {
-
curve_create->set_pressed(false);
curve_edit->set_pressed(false);
curve_edit_curve->set_pressed(false);
curve_del->set_pressed(true);
} else if (p_mode == ACTION_CLOSE) {
-
//?
- if (!node->get_curve().is_valid())
+ if (!node->get_curve().is_valid()) {
return;
- if (node->get_curve()->get_point_count() < 3)
+ }
+ if (node->get_curve()->get_point_count() < 3) {
return;
+ }
Vector2 begin = node->get_curve()->get_point_position(0);
Vector2 end = node->get_curve()->get_point_position(node->get_curve()->get_point_count() - 1);
- if (begin.distance_to(end) < CMP_EPSILON)
+ if (begin.distance_to(end) < CMP_EPSILON) {
return;
+ }
undo_redo->create_action(TTR("Remove Point from Curve"));
undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin);
@@ -513,7 +498,6 @@ void Path2DEditor::_mode_selected(int p_mode) {
}
void Path2DEditor::_handle_option_pressed(int p_option) {
-
PopupMenu *pm;
pm = handle_menu->get_popup();
@@ -533,7 +517,6 @@ void Path2DEditor::_handle_option_pressed(int p_option) {
}
Path2DEditor::Path2DEditor(EditorNode *p_editor) {
-
canvas_item_editor = nullptr;
editor = p_editor;
undo_redo = editor->get_undo_redo();
@@ -603,23 +586,19 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
}
void Path2DEditorPlugin::edit(Object *p_object) {
-
path2d_editor->edit(Object::cast_to<Node>(p_object));
}
bool Path2DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("Path2D");
}
void Path2DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
path2d_editor->show();
path2d_editor->base_hb->show();
} else {
-
path2d_editor->hide();
path2d_editor->base_hb->hide();
path2d_editor->edit(nullptr);
@@ -627,7 +606,6 @@ void Path2DEditorPlugin::make_visible(bool p_visible) {
}
Path2DEditorPlugin::Path2DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
path2d_editor = memnew(Path2DEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(path2d_editor);
diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h
index aae0e11c99..390dfdfdf7 100644
--- a/editor/plugins/path_2d_editor_plugin.h
+++ b/editor/plugins/path_2d_editor_plugin.h
@@ -39,7 +39,6 @@
class CanvasItemEditor;
class Path2DEditor : public HBoxContainer {
-
GDCLASS(Path2DEditor, HBoxContainer);
UndoRedo *undo_redo;
@@ -112,7 +111,6 @@ public:
};
class Path2DEditorPlugin : public EditorPlugin {
-
GDCLASS(Path2DEditorPlugin, EditorPlugin);
Path2DEditor *path2d_editor;
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index 6c475d829f..25cffa3d6c 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -30,18 +30,19 @@
#include "path_3d_editor_plugin.h"
+#include "core/math/geometry_2d.h"
+#include "core/math/geometry_3d.h"
#include "core/os/keyboard.h"
#include "node_3d_editor_plugin.h"
#include "scene/resources/curve.h"
String Path3DGizmo::get_handle_name(int p_idx) const {
-
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return "";
+ }
if (p_idx < c->get_point_count()) {
-
return TTR("Curve Point #") + itos(p_idx);
}
@@ -50,21 +51,22 @@ String Path3DGizmo::get_handle_name(int p_idx) const {
int idx = p_idx / 2;
int t = p_idx % 2;
String n = TTR("Curve Point #") + itos(idx);
- if (t == 0)
+ if (t == 0) {
n += " In";
- else
+ } else {
n += " Out";
+ }
return n;
}
-Variant Path3DGizmo::get_handle_value(int p_idx) {
+Variant Path3DGizmo::get_handle_value(int p_idx) {
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return Variant();
+ }
if (p_idx < c->get_point_count()) {
-
original = c->get_point_position(p_idx);
return original;
}
@@ -75,20 +77,22 @@ Variant Path3DGizmo::get_handle_value(int p_idx) {
int t = p_idx % 2;
Vector3 ofs;
- if (t == 0)
+ if (t == 0) {
ofs = c->get_point_in(idx);
- else
+ } else {
ofs = c->get_point_out(idx);
+ }
original = ofs + c->get_point_position(idx);
return ofs;
}
-void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) {
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return;
+ }
Transform gt = path->get_global_transform();
Transform gi = gt.affine_inverse();
@@ -97,13 +101,11 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
// Setting curve point positions
if (p_idx < c->get_point_count()) {
-
Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2));
Vector3 inters;
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
-
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
float snap = Node3DEditor::get_singleton()->get_translate_snap();
inters.snap(Vector3(snap, snap, snap));
@@ -129,7 +131,6 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
// Setting curve in/out positions
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
-
if (!Path3DEditorPlugin::singleton->is_handle_clicked()) {
orig_in_length = c->get_point_in(idx).length();
orig_out_length = c->get_point_out(idx).length();
@@ -144,28 +145,28 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin
if (t == 0) {
c->set_point_in(idx, local);
- if (Path3DEditorPlugin::singleton->mirror_angle_enabled())
+ if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length));
+ }
} else {
c->set_point_out(idx, local);
- if (Path3DEditorPlugin::singleton->mirror_angle_enabled())
+ if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
c->set_point_in(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_in_length));
+ }
}
}
}
void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
-
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return;
+ }
UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx < c->get_point_count()) {
-
if (p_cancel) {
-
c->set_point_position(p_idx, p_restore);
return;
}
@@ -218,7 +219,6 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc
}
void Path3DGizmo::redraw() {
-
clear();
Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this);
@@ -226,21 +226,22 @@ void Path3DGizmo::redraw() {
Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles");
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return;
+ }
Vector<Vector3> v3a = c->tessellate();
//Vector<Vector3> v3a=c->get_baked_points();
int v3s = v3a.size();
- if (v3s == 0)
+ if (v3s == 0) {
return;
+ }
Vector<Vector3> v3p;
const Vector3 *r = v3a.ptr();
// BUG: the following won't work when v3s, avoid drawing as a temporary workaround.
for (int i = 0; i < v3s - 1; i++) {
-
v3p.push_back(r[i]);
v3p.push_back(r[i + 1]);
//v3p.push_back(r[i]);
@@ -258,7 +259,6 @@ void Path3DGizmo::redraw() {
Vector<Vector3> sec_handles;
for (int i = 0; i < c->get_point_count(); i++) {
-
Vector3 p = c->get_point_position(i);
handles.push_back(p);
if (i > 0) {
@@ -287,18 +287,18 @@ void Path3DGizmo::redraw() {
}
Path3DGizmo::Path3DGizmo(Path3D *p_path) {
-
path = p_path;
set_spatial_node(p_path);
}
bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
-
- if (!path)
+ if (!path) {
return false;
+ }
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return false;
+ }
Transform gt = path->get_global_transform();
Transform it = gt.affine_inverse();
@@ -307,11 +307,11 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
Point2 mbpos(mb->get_position().x, mb->get_position().y);
- if (!mb->is_pressed())
+ if (!mb->is_pressed()) {
set_handle_clicked(false);
+ }
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) {
//click into curve, break it down
@@ -325,17 +325,18 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
if (rc >= 2) {
const Vector3 *r = v3a.ptr();
- if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist)
+ if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) {
return false; //nope, existing
+ }
for (int i = 0; i < c->get_point_count() - 1; i++) {
//find the offset and point index of the place to break up
int j = idx;
- if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist)
+ if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist) {
return false; //nope, existing
+ }
while (j < rc && c->get_point_position(i + 1) != r[j]) {
-
Vector3 from = r[j];
Vector3 to = r[j + 1];
real_t cdist = from.distance_to(to);
@@ -345,31 +346,32 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
Vector2 s[2];
s[0] = p_camera->unproject_position(from);
s[1] = p_camera->unproject_position(to);
- Vector2 inters = Geometry::get_closest_point_to_segment_2d(mbpos, s);
+ Vector2 inters = Geometry2D::get_closest_point_to_segment(mbpos, s);
float d = inters.distance_to(mbpos);
if (d < 10 && d < closest_d) {
-
closest_d = d;
closest_seg = i;
Vector3 ray_from = p_camera->project_ray_origin(mbpos);
Vector3 ray_dir = p_camera->project_ray_normal(mbpos);
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(ray_from, ray_from + ray_dir * 4096, from, to, ra, rb);
+ Geometry3D::get_closest_points_between_segments(ray_from, ray_from + ray_dir * 4096, from, to, ra, rb);
closest_seg_point = it.xform(rb);
}
}
j++;
}
- if (idx == j)
+ if (idx == j) {
idx++; //force next
- else
+ } else {
idx = j; //swap
+ }
- if (j == rc)
+ if (j == rc) {
break;
+ }
}
}
@@ -384,19 +386,18 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
return true;
} else {
-
Vector3 org;
- if (c->get_point_count() == 0)
+ if (c->get_point_count() == 0) {
org = path->get_transform().get_origin();
- else
+ } else {
org = gt.xform(c->get_point_position(c->get_point_count() - 1));
+ }
Plane p(org, p_camera->get_transform().basis.get_axis(2));
Vector3 ray_from = p_camera->project_ray_origin(mbpos);
Vector3 ray_dir = p_camera->project_ray_normal(mbpos);
Vector3 inters;
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
-
ur->create_action(TTR("Add Point to Curve"));
ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1);
ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
@@ -408,7 +409,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
}
} else if (mb->is_pressed() && ((mb->get_button_index() == BUTTON_LEFT && curve_del->is_pressed()) || (mb->get_button_index() == BUTTON_RIGHT && curve_edit->is_pressed()))) {
-
for (int i = 0; i < c->get_point_count(); i++) {
real_t dist_to_p = p_camera->unproject_position(gt.xform(c->get_point_position(i))).distance_to(mbpos);
real_t dist_to_p_out = p_camera->unproject_position(gt.xform(c->get_point_position(i) + c->get_point_out(i))).distance_to(mbpos);
@@ -417,7 +417,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
// Find the offset and point index of the place to break up.
// Also check for the control points.
if (dist_to_p < click_dist) {
-
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove Path Point"));
ur->add_do_method(c.ptr(), "remove_point", i);
@@ -425,7 +424,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
ur->commit_action();
return true;
} else if (dist_to_p_out < click_dist) {
-
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove Out-Control Point"));
ur->add_do_method(c.ptr(), "set_point_out", i, Vector3());
@@ -433,7 +431,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
ur->commit_action();
return true;
} else if (dist_to_p_in < click_dist) {
-
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove In-Control Point"));
ur->add_do_method(c.ptr(), "set_point_in", i, Vector3());
@@ -449,11 +446,9 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref
}
void Path3DEditorPlugin::edit(Object *p_object) {
-
if (p_object) {
path = Object::cast_to<Path3D>(p_object);
if (path) {
-
if (path->get_curve().is_valid()) {
path->get_curve()->emit_signal("changed");
}
@@ -469,14 +464,11 @@ void Path3DEditorPlugin::edit(Object *p_object) {
}
bool Path3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("Path3D");
}
void Path3DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
curve_create->show();
curve_edit->show();
curve_del->show();
@@ -484,7 +476,6 @@ void Path3DEditorPlugin::make_visible(bool p_visible) {
handle_menu->show();
sep->show();
} else {
-
curve_create->hide();
curve_edit->hide();
curve_del->hide();
@@ -503,24 +494,23 @@ void Path3DEditorPlugin::make_visible(bool p_visible) {
}
void Path3DEditorPlugin::_mode_changed(int p_idx) {
-
curve_create->set_pressed(p_idx == 0);
curve_edit->set_pressed(p_idx == 1);
curve_del->set_pressed(p_idx == 2);
}
void Path3DEditorPlugin::_close_curve() {
-
Ref<Curve3D> c = path->get_curve();
- if (c.is_null())
+ if (c.is_null()) {
return;
- if (c->get_point_count() < 2)
+ }
+ if (c->get_point_count() < 2) {
return;
+ }
c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0));
}
void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
-
PopupMenu *pm;
pm = handle_menu->get_popup();
@@ -540,9 +530,7 @@ void Path3DEditorPlugin::_handle_option_pressed(int p_option) {
}
void Path3DEditorPlugin::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
curve_create->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(0));
curve_edit->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(1));
curve_del->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(2));
@@ -556,7 +544,6 @@ void Path3DEditorPlugin::_bind_methods() {
Path3DEditorPlugin *Path3DEditorPlugin::singleton = nullptr;
Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) {
-
path = nullptr;
editor = p_node;
singleton = this;
@@ -631,8 +618,9 @@ Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
Ref<Path3DGizmo> ref;
Path3D *path = Object::cast_to<Path3D>(p_spatial);
- if (path)
+ if (path) {
ref = Ref<Path3DGizmo>(memnew(Path3DGizmo(path)));
+ }
return ref;
}
@@ -646,7 +634,6 @@ int Path3DGizmoPlugin::get_priority() const {
}
Path3DGizmoPlugin::Path3DGizmoPlugin() {
-
Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8));
create_material("path_material", path_color);
create_material("path_thin_material", Color(0.5, 0.5, 0.5));
diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h
index 3f18cadacd..8bec5df797 100644
--- a/editor/plugins/path_3d_editor_plugin.h
+++ b/editor/plugins/path_3d_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/3d/path_3d.h"
class Path3DGizmo : public EditorNode3DGizmo {
-
GDCLASS(Path3DGizmo, EditorNode3DGizmo);
Path3D *path;
@@ -54,7 +53,6 @@ public:
};
class Path3DGizmoPlugin : public EditorNode3DGizmoPlugin {
-
GDCLASS(Path3DGizmoPlugin, EditorNode3DGizmoPlugin);
protected:
@@ -67,7 +65,6 @@ public:
};
class Path3DEditorPlugin : public EditorPlugin {
-
GDCLASS(Path3DEditorPlugin, EditorPlugin);
Separator *sep;
diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp
index 6d38f7f318..bcbf88e7dc 100644
--- a/editor/plugins/physical_bone_3d_editor_plugin.cpp
+++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp
@@ -37,7 +37,6 @@ void PhysicalBone3DEditor::_bind_methods() {
}
void PhysicalBone3DEditor::_on_toggle_button_transform_joint(bool p_is_pressed) {
-
_set_move_joint();
}
@@ -48,9 +47,7 @@ void PhysicalBone3DEditor::_set_move_joint() {
}
PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) :
- editor(p_editor),
- selected(nullptr) {
-
+ editor(p_editor) {
spatial_editor_hb = memnew(HBoxContainer);
spatial_editor_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN);
@@ -69,10 +66,7 @@ PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) :
hide();
}
-PhysicalBone3DEditor::~PhysicalBone3DEditor() {}
-
void PhysicalBone3DEditor::set_selected(PhysicalBone3D *p_pb) {
-
button_transform_joint->set_pressed(false);
_set_move_joint();
@@ -90,15 +84,12 @@ void PhysicalBone3DEditor::show() {
PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin(EditorNode *p_editor) :
editor(p_editor),
- selected(nullptr),
physical_bone_editor(editor) {}
void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
-
physical_bone_editor.show();
} else {
-
physical_bone_editor.hide();
physical_bone_editor.set_selected(nullptr);
selected = nullptr;
diff --git a/editor/plugins/physical_bone_3d_editor_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h
index 74932710d6..79c7cc4bb1 100644
--- a/editor/plugins/physical_bone_3d_editor_plugin.h
+++ b/editor/plugins/physical_bone_3d_editor_plugin.h
@@ -40,7 +40,7 @@ class PhysicalBone3DEditor : public Object {
HBoxContainer *spatial_editor_hb;
ToolButton *button_transform_joint;
- PhysicalBone3D *selected;
+ PhysicalBone3D *selected = nullptr;
protected:
static void _bind_methods();
@@ -51,7 +51,7 @@ private:
public:
PhysicalBone3DEditor(EditorNode *p_editor);
- ~PhysicalBone3DEditor();
+ ~PhysicalBone3DEditor() {}
void set_selected(PhysicalBone3D *p_pb);
@@ -63,7 +63,7 @@ class PhysicalBone3DEditorPlugin : public EditorPlugin {
GDCLASS(PhysicalBone3DEditorPlugin, EditorPlugin);
EditorNode *editor;
- PhysicalBone3D *selected;
+ PhysicalBone3D *selected = nullptr;
PhysicalBone3DEditor physical_bone_editor;
public:
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index e15d8556e4..1f98c0139b 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -32,6 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "core/input/input.h"
+#include "core/math/geometry_2d.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
@@ -39,23 +40,19 @@
#include "scene/2d/skeleton_2d.h"
Node2D *Polygon2DEditor::_get_node() const {
-
return node;
}
void Polygon2DEditor::_set_node(Node *p_polygon) {
-
node = Object::cast_to<Polygon2D>(p_polygon);
_update_polygon_editing_state();
}
Vector2 Polygon2DEditor::_get_offset(int p_idx) const {
-
return node->get_offset();
}
int Polygon2DEditor::_get_polygon_count() const {
-
if (node->get_internal_vertex_count() > 0) {
return 0; //do not edit if internal vertices exist
} else {
@@ -64,17 +61,13 @@ int Polygon2DEditor::_get_polygon_count() const {
}
void Polygon2DEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
-
uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
bone_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
-
button_uv->set_icon(get_theme_icon("Uv", "EditorIcons"));
uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon("Edit", "EditorIcons"));
@@ -97,7 +90,6 @@ void Polygon2DEditor::_notification(int p_what) {
uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
if (!is_visible()) {
uv_edit->hide();
}
@@ -106,7 +98,6 @@ void Polygon2DEditor::_notification(int p_what) {
}
void Polygon2DEditor::_sync_bones() {
-
Skeleton2D *skeleton = nullptr;
if (!node->has_node(node->get_skeleton())) {
error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node"));
@@ -161,7 +152,6 @@ void Polygon2DEditor::_sync_bones() {
}
void Polygon2DEditor::_update_bone_list() {
-
NodePath selected;
while (bone_scroll_vb->get_child_count()) {
CheckBox *cb = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(0));
@@ -189,8 +179,9 @@ void Polygon2DEditor::_update_bone_list() {
cb->set_focus_mode(FOCUS_NONE);
bone_scroll_vb->add_child(cb);
- if (np == selected || bone_scroll_vb->get_child_count() < 2)
+ if (np == selected || bone_scroll_vb->get_child_count() < 2) {
cb->set_pressed(true);
+ }
cb->connect("pressed", callable_mp(this, &Polygon2DEditor::_bone_paint_selected), varray(i));
}
@@ -203,7 +194,6 @@ void Polygon2DEditor::_bone_paint_selected(int p_index) {
}
void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
-
if (p_mode == 0) { //uv
uv_button[UV_MODE_CREATE]->hide();
@@ -274,20 +264,15 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
}
void Polygon2DEditor::_uv_edit_popup_hide() {
-
EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", Rect2(uv_edit->get_position(), uv_edit->get_size()));
_cancel_editing();
}
void Polygon2DEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MODE_EDIT_UV: {
-
if (node->get_texture().is_null()) {
-
error->set_text(TTR("No texture in this polygon.\nSet a texture to be able to edit UV."));
error->popup_centered();
return;
@@ -304,17 +289,18 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
}
- if (EditorSettings::get_singleton()->has_setting("interface/dialogs/uv_editor_bounds"))
+ if (EditorSettings::get_singleton()->has_setting("interface/dialogs/uv_editor_bounds")) {
uv_edit->popup(EditorSettings::get_singleton()->get("interface/dialogs/uv_editor_bounds"));
- else
+ } else {
uv_edit->popup_centered_ratio(0.85);
+ }
_update_bone_list();
} break;
case UVEDIT_POLYGON_TO_UV: {
-
Vector<Vector2> points = node->get_polygon();
- if (points.size() == 0)
+ if (points.size() == 0) {
break;
+ }
Vector<Vector2> uvs = node->get_uv();
undo_redo->create_action(TTR("Create UV Map"));
undo_redo->add_do_method(node, "set_uv", points);
@@ -324,11 +310,11 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
} break;
case UVEDIT_UV_TO_POLYGON: {
-
Vector<Vector2> points = node->get_polygon();
Vector<Vector2> uvs = node->get_uv();
- if (uvs.size() == 0)
+ if (uvs.size() == 0) {
break;
+ }
undo_redo->create_action(TTR("Create Polygon"));
undo_redo->add_do_method(node, "set_polygon", uvs);
@@ -338,10 +324,10 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
} break;
case UVEDIT_UV_CLEAR: {
-
Vector<Vector2> uvs = node->get_uv();
- if (uvs.size() == 0)
+ if (uvs.size() == 0) {
break;
+ }
undo_redo->create_action(TTR("Create UV Map"));
undo_redo->add_do_method(node, "set_uv", Vector<Vector2>());
undo_redo->add_undo_method(node, "set_uv", uvs);
@@ -350,18 +336,15 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
} break;
case UVEDIT_GRID_SETTINGS: {
-
grid_settings->popup_centered();
} break;
default: {
-
AbstractPolygon2DEditor::_menu_option(p_option);
} break;
}
}
void Polygon2DEditor::_cancel_editing() {
-
if (uv_create) {
uv_drag = false;
uv_create = false;
@@ -386,18 +369,18 @@ void Polygon2DEditor::_cancel_editing() {
}
void Polygon2DEditor::_update_polygon_editing_state() {
-
- if (!_get_node())
+ if (!_get_node()) {
return;
+ }
- if (node->get_internal_vertex_count() > 0)
+ if (node->get_internal_vertex_count() > 0) {
disable_polygon_editing(true, TTR("Polygon 2D has internal vertices, so it can no longer be edited in the viewport."));
- else
+ } else {
disable_polygon_editing(false, String());
+ }
}
void Polygon2DEditor::_commit_action() {
-
// Makes that undo/redoing actions made outside of the UV editor still affect its polygon.
undo_redo->add_do_method(uv_edit_draw, "update");
undo_redo->add_undo_method(uv_edit_draw, "update");
@@ -442,7 +425,6 @@ void Polygon2DEditor::_set_snap_step_y(float p_val) {
}
void Polygon2DEditor::_uv_mode(int p_mode) {
-
polygon_create.clear();
uv_drag = false;
uv_create = false;
@@ -454,9 +436,9 @@ void Polygon2DEditor::_uv_mode(int p_mode) {
}
void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
-
- if (!_get_node())
+ if (!_get_node()) {
return;
+ }
Transform2D mtx;
mtx.elements[2] = -uv_draw_ofs;
@@ -465,11 +447,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
-
uv_drag_from = snap_point(Vector2(mb->get_position().x, mb->get_position().y));
uv_drag = true;
points_prev = node->get_uv();
@@ -482,9 +461,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_move_current = uv_mode;
if (uv_move_current == UV_MODE_CREATE) {
-
if (!uv_create) {
-
points_prev.resize(0);
Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y)));
points_prev.push_back(tuv);
@@ -506,7 +483,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_edit_draw->update();
} else {
-
Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y)));
if (points_prev.size() > 2 && tuv.distance_to(points_prev[0]) < 8) {
@@ -544,7 +520,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_CREATE_INTERNAL) {
-
uv_create_uv_prev = node->get_uv();
uv_create_poly_prev = node->get_polygon();
uv_create_colors_prev = node->get_vertex_colors();
@@ -582,21 +557,20 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_REMOVE_INTERNAL) {
-
uv_create_uv_prev = node->get_uv();
uv_create_poly_prev = node->get_polygon();
uv_create_colors_prev = node->get_vertex_colors();
uv_create_bones_prev = node->call("_get_bones");
int internal_vertices = node->get_internal_vertex_count();
- if (internal_vertices <= 0)
+ if (internal_vertices <= 0) {
return;
+ }
int closest = -1;
float closest_dist = 1e20;
for (int i = points_prev.size() - internal_vertices; i < points_prev.size(); i++) {
-
Vector2 tuv = mtx.xform(uv_create_poly_prev[i]);
float dist = tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y));
if (dist < 8 && dist < closest_dist) {
@@ -605,8 +579,9 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
}
- if (closest == -1)
+ if (closest == -1) {
return;
+ }
uv_create_poly_prev.remove(closest);
uv_create_uv_prev.remove(closest);
@@ -637,20 +612,18 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_EDIT_POINT) {
-
- if (mb->get_shift() && mb->get_command())
+ if (mb->get_shift() && mb->get_command()) {
uv_move_current = UV_MODE_SCALE;
- else if (mb->get_shift())
+ } else if (mb->get_shift()) {
uv_move_current = UV_MODE_MOVE;
- else if (mb->get_command())
+ } else if (mb->get_command()) {
uv_move_current = UV_MODE_ROTATE;
+ }
}
if (uv_move_current == UV_MODE_EDIT_POINT) {
-
point_drag_index = -1;
for (int i = 0; i < points_prev.size(); i++) {
-
Vector2 tuv = mtx.xform(points_prev[i]);
if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < 8) {
uv_drag_from = tuv;
@@ -664,12 +637,10 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_ADD_POLYGON) {
-
int closest = -1;
float closest_dist = 1e20;
for (int i = 0; i < points_prev.size(); i++) {
-
Vector2 tuv = mtx.xform(points_prev[i]);
float dist = tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y));
if (dist < 8 && dist < closest_dist) {
@@ -717,12 +688,13 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
polys.resize(points.size());
for (int j = 0; j < polys.size(); j++) {
int idx = points[j];
- if (idx < 0 || idx >= points_prev.size())
+ if (idx < 0 || idx >= points_prev.size()) {
continue;
+ }
polys.write[j] = mtx.xform(points_prev[idx]);
}
- if (Geometry::is_point_in_polygon(Vector2(mb->get_position().x, mb->get_position().y), polys)) {
+ if (Geometry2D::is_point_in_polygon(Vector2(mb->get_position().x, mb->get_position().y), polys)) {
erase_index = i;
break;
}
@@ -740,7 +712,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_PAINT_WEIGHT || uv_move_current == UV_MODE_CLEAR_WEIGHT) {
-
int bone_selected = -1;
for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) {
CheckBox *c = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(i));
@@ -751,7 +722,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == points_prev.size()) {
-
prev_weights = node->get_bone_weights(bone_selected);
bone_painting = true;
bone_painting_bone = bone_selected;
@@ -759,7 +729,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} else if (uv_drag && !uv_create) {
-
if (uv_edit_mode[0]->is_pressed()) { // Edit UV.
undo_redo->create_action(TTR("Transform UV Map"));
undo_redo->add_do_method(node, "set_uv", node->get_uv());
@@ -778,7 +747,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_drag = false;
} else if (bone_painting) {
-
undo_redo->create_action(TTR("Paint Bone Weights"));
undo_redo->add_do_method(node, "set_bone_weights", bone_painting_bone, node->get_bone_weights(bone_painting_bone));
undo_redo->add_undo_method(node, "set_bone_weights", bone_painting_bone, prev_weights);
@@ -789,19 +757,17 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
-
_cancel_editing();
- if (bone_painting)
+ if (bone_painting) {
node->set_bone_weights(bone_painting_bone, prev_weights);
+ }
uv_edit_draw->update();
} else if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
-
uv_zoom->set_value(uv_zoom->get_value() / (1 - (0.1 * mb->get_factor())));
} else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed()) {
-
uv_zoom->set_value(uv_zoom->get_value() * (1 - (0.1 * mb->get_factor())));
}
}
@@ -809,29 +775,23 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid()) {
-
if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
-
Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
uv_vscroll->set_value(uv_vscroll->get_value() - drag.y);
} else if (uv_drag) {
-
Vector2 uv_drag_to = mm->get_position();
uv_drag_to = snap_point(uv_drag_to); // FIXME: Only works correctly with 'UV_MODE_EDIT_POINT', it's imprecise with the rest.
Vector2 drag = mtx.affine_inverse().xform(uv_drag_to) - mtx.affine_inverse().xform(uv_drag_from);
switch (uv_move_current) {
-
case UV_MODE_CREATE: {
-
if (uv_create) {
uv_create_to = mtx.affine_inverse().xform(snap_point(Vector2(mm->get_position().x, mm->get_position().y)));
}
} break;
case UV_MODE_EDIT_POINT: {
-
Vector<Vector2> uv_new = points_prev;
uv_new.set(point_drag_index, uv_new[point_drag_index] + drag);
@@ -842,10 +802,10 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} break;
case UV_MODE_MOVE: {
-
Vector<Vector2> uv_new = points_prev;
- for (int i = 0; i < uv_new.size(); i++)
+ for (int i = 0; i < uv_new.size(); i++) {
uv_new.set(i, uv_new[i] + drag);
+ }
if (uv_edit_mode[0]->is_pressed()) { //edit uv
node->set_uv(uv_new);
@@ -854,12 +814,12 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} break;
case UV_MODE_ROTATE: {
-
Vector2 center;
Vector<Vector2> uv_new = points_prev;
- for (int i = 0; i < uv_new.size(); i++)
+ for (int i = 0; i < uv_new.size(); i++) {
center += points_prev[i];
+ }
center /= uv_new.size();
float angle = (uv_drag_from - mtx.xform(center)).normalized().angle_to((uv_drag_to - mtx.xform(center)).normalized());
@@ -877,18 +837,19 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} break;
case UV_MODE_SCALE: {
-
Vector2 center;
Vector<Vector2> uv_new = points_prev;
- for (int i = 0; i < uv_new.size(); i++)
+ for (int i = 0; i < uv_new.size(); i++) {
center += points_prev[i];
+ }
center /= uv_new.size();
float from_dist = uv_drag_from.distance_to(mtx.xform(center));
float to_dist = uv_drag_to.distance_to(mtx.xform(center));
- if (from_dist < 2)
+ if (from_dist < 2) {
break;
+ }
float scale = to_dist / from_dist;
@@ -906,7 +867,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
} break;
case UV_MODE_PAINT_WEIGHT:
case UV_MODE_CLEAR_WEIGHT: {
-
bone_paint_pos = Vector2(mm->get_position().x, mm->get_position().y);
} break;
default: {
@@ -952,22 +912,20 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
if (magnify_gesture.is_valid()) {
-
uv_zoom->set_value(uv_zoom->get_value() * magnify_gesture->get_factor());
}
Ref<InputEventPanGesture> pan_gesture = p_input;
if (pan_gesture.is_valid()) {
-
uv_hscroll->set_value(uv_hscroll->get_value() + uv_hscroll->get_page() * pan_gesture->get_delta().x / 8);
uv_vscroll->set_value(uv_vscroll->get_value() + uv_vscroll->get_page() * pan_gesture->get_delta().y / 8);
}
}
void Polygon2DEditor::_uv_scroll_changed(float) {
-
- if (updating_uv_scroll)
+ if (updating_uv_scroll) {
return;
+ }
uv_draw_ofs.x = uv_hscroll->get_value();
uv_draw_ofs.y = uv_vscroll->get_value();
@@ -976,13 +934,14 @@ void Polygon2DEditor::_uv_scroll_changed(float) {
}
void Polygon2DEditor::_uv_draw() {
-
- if (!uv_edit->is_visible() || !_get_node())
+ if (!uv_edit->is_visible() || !_get_node()) {
return;
+ }
Ref<Texture2D> base_tex = node->get_texture();
- if (base_tex.is_null())
+ if (base_tex.is_null()) {
return;
+ }
String warning;
@@ -1002,10 +961,12 @@ void Polygon2DEditor::_uv_draw() {
if (snap_step.x != 0) {
for (int i = 0; i < s.width; i++) {
int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i, 0)).x - snap_offset.x) / snap_step.x));
- if (i == 0)
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
+ }
+ if (last_cell != cell) {
uv_edit_draw->draw_line(Point2(i, 0), Point2(i, s.height), grid_color, Math::round(EDSCALE));
+ }
last_cell = cell;
}
}
@@ -1013,10 +974,12 @@ void Polygon2DEditor::_uv_draw() {
if (snap_step.y != 0) {
for (int i = 0; i < s.height; i++) {
int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0, i)).y - snap_offset.y) / snap_step.y));
- if (i == 0)
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
+ }
+ if (last_cell != cell) {
uv_edit_draw->draw_line(Point2(0, i), Point2(s.width, i), grid_color, Math::round(EDSCALE));
+ }
last_cell = cell;
}
}
@@ -1073,7 +1036,6 @@ void Polygon2DEditor::_uv_draw() {
}
for (int i = 0; i < uvs.size(); i++) {
-
int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0;
if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) {
@@ -1092,7 +1054,6 @@ void Polygon2DEditor::_uv_draw() {
}
for (int i = 0; i < polygons.size(); i++) {
-
Vector<int> points = polygons[i];
Vector<Vector2> polypoints;
for (int j = 0; j < points.size(); j++) {
@@ -1100,12 +1061,14 @@ void Polygon2DEditor::_uv_draw() {
int idx = points[j];
int idx_next = points[next];
- if (idx < 0 || idx >= uvs.size())
+ if (idx < 0 || idx >= uvs.size()) {
continue;
+ }
polypoints.push_back(mtx.xform(uvs[idx]));
- if (idx_next < 0 || idx_next >= uvs.size())
+ if (idx_next < 0 || idx_next >= uvs.size()) {
continue;
+ }
uv_edit_draw->draw_line(mtx.xform(uvs[idx]), mtx.xform(uvs[idx_next]), polygon_line_color, Math::round(EDSCALE));
}
if (points.size() >= 3) {
@@ -1114,7 +1077,6 @@ void Polygon2DEditor::_uv_draw() {
}
for (int i = 0; i < uvs.size(); i++) {
-
if (weight_r) {
Vector2 draw_pos = mtx.xform(uvs[i]);
float weight = weight_r[i];
@@ -1138,7 +1100,6 @@ void Polygon2DEditor::_uv_draw() {
}
if (uv_mode == UV_MODE_PAINT_WEIGHT || uv_mode == UV_MODE_CLEAR_WEIGHT) {
-
NodePath bone_path;
for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) {
CheckBox *c = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(i));
@@ -1154,20 +1115,20 @@ void Polygon2DEditor::_uv_draw() {
Skeleton2D *skeleton = Object::cast_to<Skeleton2D>(node->get_node(skeleton_path));
if (skeleton) {
for (int i = 0; i < skeleton->get_bone_count(); i++) {
-
Bone2D *bone = skeleton->get_bone(i);
- if (bone->get_rest() == Transform2D(0, 0, 0, 0, 0, 0))
+ if (bone->get_rest() == Transform2D(0, 0, 0, 0, 0, 0)) {
continue; //not set
+ }
bool current = bone_path == skeleton->get_path_to(bone);
bool found_child = false;
for (int j = 0; j < bone->get_child_count(); j++) {
-
Bone2D *n = Object::cast_to<Bone2D>(bone->get_child(j));
- if (!n)
+ if (!n) {
continue;
+ }
found_child = true;
@@ -1232,7 +1193,6 @@ void Polygon2DEditor::_uv_draw() {
}
void Polygon2DEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_update_bone_list"), &Polygon2DEditor::_update_bone_list);
ClassDB::bind_method(D_METHOD("_update_polygon_editing_state"), &Polygon2DEditor::_update_polygon_editing_state);
}
@@ -1248,7 +1208,6 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const {
Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
AbstractPolygon2DEditor(p_editor) {
-
node = nullptr;
snap_offset = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_offset", Vector2());
snap_step = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_step", Vector2(10, 10));
@@ -1305,7 +1264,6 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_main_vb->add_child(uv_mode_hb);
for (int i = 0; i < UV_MODE_MAX; i++) {
-
uv_button[i] = memnew(ToolButton);
uv_button[i]->set_toggle_mode(true);
uv_mode_hb->add_child(uv_button[i]);
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h
index 2b00b50e5c..b94ae53e2b 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/gui/scroll_container.h"
class Polygon2DEditor : public AbstractPolygon2DEditor {
-
GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor);
enum Mode {
@@ -165,7 +164,6 @@ public:
};
class Polygon2DEditorPlugin : public AbstractPolygon2DEditorPlugin {
-
GDCLASS(Polygon2DEditorPlugin, AbstractPolygon2DEditorPlugin);
public:
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index 852feeb675..75cb93ee76 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -39,13 +39,11 @@ void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) {
}
void ResourcePreloaderEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
load->set_icon(get_theme_icon("Folder", "EditorIcons"));
}
if (p_what == NOTIFICATION_READY) {
-
//NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
@@ -54,9 +52,7 @@ void ResourcePreloaderEditor::_notification(int p_what) {
}
void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths) {
-
for (int i = 0; i < p_paths.size(); i++) {
-
String path = p_paths[i];
RES resource;
@@ -89,14 +85,14 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths)
}
void ResourcePreloaderEditor::_load_pressed() {
-
loading_scene = false;
file->clear_filters();
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("", &extensions);
- for (int i = 0; i < extensions.size(); i++)
+ for (int i = 0; i < extensions.size(); i++) {
file->add_filter("*." + extensions[i]);
+ }
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
@@ -104,9 +100,9 @@ void ResourcePreloaderEditor::_load_pressed() {
}
void ResourcePreloaderEditor::_item_edited() {
-
- if (!tree->get_selected())
+ if (!tree->get_selected()) {
return;
+ }
TreeItem *s = tree->get_selected();
@@ -114,11 +110,11 @@ void ResourcePreloaderEditor::_item_edited() {
// renamed
String old_name = s->get_metadata(0);
String new_name = s->get_text(0);
- if (old_name == new_name)
+ if (old_name == new_name) {
return;
+ }
if (new_name == "" || new_name.find("\\") != -1 || new_name.find("/") != -1 || preloader->has_resource(new_name)) {
-
s->set_text(0, old_name);
return;
}
@@ -136,7 +132,6 @@ void ResourcePreloaderEditor::_item_edited() {
}
void ResourcePreloaderEditor::_remove_resource(const String &p_to_remove) {
-
undo_redo->create_action(TTR("Delete Resource"));
undo_redo->add_do_method(preloader, "remove_resource", p_to_remove);
undo_redo->add_undo_method(preloader, "add_resource", p_to_remove, preloader->get_resource(p_to_remove));
@@ -146,7 +141,6 @@ void ResourcePreloaderEditor::_remove_resource(const String &p_to_remove) {
}
void ResourcePreloaderEditor::_paste_pressed() {
-
RES r = EditorSettings::get_singleton()->get_resource_clipboard();
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty!"));
@@ -157,10 +151,12 @@ void ResourcePreloaderEditor::_paste_pressed() {
}
String name = r->get_name();
- if (name == "")
+ if (name == "") {
name = r->get_path().get_file();
- if (name == "")
+ }
+ if (name == "") {
name = r->get_class();
+ }
String basename = name;
int counter = 1;
@@ -178,7 +174,6 @@ void ResourcePreloaderEditor::_paste_pressed() {
}
void ResourcePreloaderEditor::_update_library() {
-
tree->clear();
tree->set_hide_root(true);
TreeItem *root = tree->create_item(nullptr);
@@ -194,7 +189,6 @@ void ResourcePreloaderEditor::_update_library() {
names.sort();
for (List<String>::Element *E = names.front(); E; E = E->next()) {
-
TreeItem *ti = tree->create_item(root);
ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING);
ti->set_editable(0, true);
@@ -226,7 +220,6 @@ void ResourcePreloaderEditor::_update_library() {
}
void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
-
TreeItem *item = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!item);
@@ -244,42 +237,42 @@ void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column,
}
void ResourcePreloaderEditor::edit(ResourcePreloader *p_preloader) {
-
preloader = p_preloader;
if (p_preloader) {
_update_library();
} else {
-
hide();
set_physics_process(false);
}
}
Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
TreeItem *ti = tree->get_item_at_position(p_point);
- if (!ti)
+ if (!ti) {
return Variant();
+ }
String name = ti->get_metadata(0);
RES res = preloader->get_resource(name);
- if (!res.is_valid())
+ if (!res.is_valid()) {
return Variant();
+ }
return EditorNode::get_singleton()->drag_resource(res, p_from);
}
bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
- if (d.has("from") && (Object *)(d["from"]) == tree)
+ if (d.has("from") && (Object *)(d["from"]) == tree) {
return false;
+ }
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
@@ -288,7 +281,6 @@ bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Vari
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
return files.size() != 0;
@@ -297,20 +289,20 @@ bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Vari
}
void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return;
+ }
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
if (r.is_valid()) {
-
String basename;
if (r->get_name() != "") {
basename = r->get_name();
@@ -337,7 +329,6 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
_files_load_request(files);
@@ -345,7 +336,6 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant
}
void ResourcePreloaderEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &ResourcePreloaderEditor::_gui_input);
ClassDB::bind_method(D_METHOD("_update_library"), &ResourcePreloaderEditor::_update_library);
ClassDB::bind_method(D_METHOD("_remove_resource", "to_remove"), &ResourcePreloaderEditor::_remove_resource);
@@ -356,7 +346,6 @@ void ResourcePreloaderEditor::_bind_methods() {
}
ResourcePreloaderEditor::ResourcePreloaderEditor() {
-
//add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));
VBoxContainer *vbc = memnew(VBoxContainer);
@@ -399,31 +388,29 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
}
void ResourcePreloaderEditorPlugin::edit(Object *p_object) {
-
preloader_editor->set_undo_redo(&get_undo_redo());
ResourcePreloader *s = Object::cast_to<ResourcePreloader>(p_object);
- if (!s)
+ if (!s) {
return;
+ }
preloader_editor->edit(s);
}
bool ResourcePreloaderEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("ResourcePreloader");
}
void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
//preloader_editor->show();
button->show();
editor->make_bottom_panel_item_visible(preloader_editor);
//preloader_editor->set_process(true);
} else {
-
- if (preloader_editor->is_visible_in_tree())
+ if (preloader_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
button->hide();
//preloader_editor->hide();
//preloader_editor->set_process(false);
@@ -431,7 +418,6 @@ void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) {
}
ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
preloader_editor = memnew(ResourcePreloaderEditor);
preloader_editor->set_custom_minimum_size(Size2(0, 250) * EDSCALE);
diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h
index 88e9cf4956..2d7a54eda5 100644
--- a/editor/plugins/resource_preloader_editor_plugin.h
+++ b/editor/plugins/resource_preloader_editor_plugin.h
@@ -39,7 +39,6 @@
#include "scene/main/resource_preloader.h"
class ResourcePreloaderEditor : public PanelContainer {
-
GDCLASS(ResourcePreloaderEditor, PanelContainer);
enum {
@@ -87,7 +86,6 @@ public:
};
class ResourcePreloaderEditorPlugin : public EditorPlugin {
-
GDCLASS(ResourcePreloaderEditorPlugin, EditorPlugin);
ResourcePreloaderEditor *preloader_editor;
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index a7120c5d68..e107435373 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -33,10 +33,10 @@
#include "scene/main/window.h"
void EditorPropertyRootMotion::_confirmed() {
-
TreeItem *ti = filters->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
NodePath path = ti->get_metadata(0);
emit_changed(get_edited_property(), path);
@@ -45,7 +45,6 @@ void EditorPropertyRootMotion::_confirmed() {
}
void EditorPropertyRootMotion::_node_assign() {
-
NodePath current = get_edited_object()->get(get_edited_property());
AnimationTree *atree = Object::cast_to<AnimationTree>(get_edited_object());
@@ -72,7 +71,6 @@ void EditorPropertyRootMotion::_node_assign() {
player->get_animation_list(&animations);
for (List<StringName>::Element *E = animations.front(); E; E = E->next()) {
-
Ref<Animation> anim = player->get_animation(E->get());
for (int i = 0; i < anim->get_track_count(); i++) {
paths.insert(anim->track_get_path(i));
@@ -86,7 +84,6 @@ void EditorPropertyRootMotion::_node_assign() {
Map<String, TreeItem *> parenthood;
for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
-
NodePath path = E->get();
TreeItem *ti = nullptr;
String accum;
@@ -121,11 +118,11 @@ void EditorPropertyRootMotion::_node_assign() {
if (base->has_node(accum)) {
node = base->get_node(accum);
}
- if (!node)
+ if (!node) {
continue; //no node, can't edit
+ }
if (path.get_subname_count()) {
-
String concat = path.get_concatenated_subnames();
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
@@ -194,13 +191,11 @@ void EditorPropertyRootMotion::_node_assign() {
}
void EditorPropertyRootMotion::_node_clear() {
-
emit_changed(get_edited_property(), NodePath());
update_property();
}
void EditorPropertyRootMotion::update_property() {
-
NodePath p = get_edited_object()->get(get_edited_property());
assign->set_tooltip(p);
@@ -235,12 +230,10 @@ void EditorPropertyRootMotion::update_property() {
}
void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) {
-
base_hint = p_base_hint;
}
void EditorPropertyRootMotion::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons");
clear->set_icon(t);
@@ -251,7 +244,6 @@ void EditorPropertyRootMotion::_bind_methods() {
}
EditorPropertyRootMotion::EditorPropertyRootMotion() {
-
HBoxContainer *hbc = memnew(HBoxContainer);
add_child(hbc);
assign = memnew(Button);
@@ -278,6 +270,7 @@ EditorPropertyRootMotion::EditorPropertyRootMotion() {
filters->connect("item_activated", callable_mp(this, &EditorPropertyRootMotion::_confirmed));
//filters->connect("item_edited", this, "_filter_edited");
}
+
//////////////////////////
bool EditorInspectorRootMotionPlugin::can_handle(Object *p_object) {
@@ -289,7 +282,6 @@ void EditorInspectorRootMotionPlugin::parse_begin(Object *p_object) {
}
bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
-
if (p_path == "root_motion_track" && p_object->is_class("AnimationTree") && p_type == Variant::NODE_PATH) {
EditorPropertyRootMotion *editor = memnew(EditorPropertyRootMotion);
if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) {
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index e6d3f17f12..48a9febcf9 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -54,7 +54,6 @@
/*** SCRIPT EDITOR ****/
void ScriptEditorBase::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("name_changed"));
ADD_SIGNAL(MethodInfo("edited_script_changed"));
ADD_SIGNAL(MethodInfo("request_help", PropertyInfo(Variant::STRING, "topic")));
@@ -73,7 +72,6 @@ static bool _is_built_in_script(Script *p_script) {
}
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
-
struct Cache {
uint64_t time_loaded;
RES cache;
@@ -86,7 +84,6 @@ public:
int max_cache_size;
void cleanup() {
-
List<Map<String, Cache>::Element *> to_clean;
Map<String, Cache>::Element *I = cached.front();
@@ -104,10 +101,8 @@ public:
}
virtual RES get_cached_resource(const String &p_path) {
-
Map<String, Cache>::Element *E = cached.find(p_path);
if (!E) {
-
Cache c;
c.cache = ResourceLoader::load(p_path);
E = cached.insert(p_path, c);
@@ -137,7 +132,6 @@ public:
}
EditorScriptCodeCompletionCache() {
-
max_cache_size = 128;
max_time_cache = 5 * 60 * 1000; //minutes, five
}
@@ -146,50 +140,45 @@ public:
};
void ScriptEditorQuickOpen::popup_dialog(const Vector<String> &p_functions, bool p_dontclear) {
-
popup_centered_ratio(0.6);
- if (p_dontclear)
+ if (p_dontclear) {
search_box->select_all();
- else
+ } else {
search_box->clear();
+ }
search_box->grab_focus();
functions = p_functions;
_update_search();
}
void ScriptEditorQuickOpen::_text_changed(const String &p_newtext) {
-
_update_search();
}
void ScriptEditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
-
Ref<InputEventKey> k = p_ie;
if (k.is_valid() && (k->get_keycode() == KEY_UP ||
k->get_keycode() == KEY_DOWN ||
k->get_keycode() == KEY_PAGEUP ||
k->get_keycode() == KEY_PAGEDOWN)) {
-
search_options->call("_gui_input", k);
search_box->accept_event();
}
}
void ScriptEditorQuickOpen::_update_search() {
-
search_options->clear();
TreeItem *root = search_options->create_item();
for (int i = 0; i < functions.size(); i++) {
-
String file = functions[i];
if ((search_box->get_text() == "" || file.findn(search_box->get_text()) != -1)) {
-
TreeItem *ti = search_options->create_item(root);
ti->set_text(0, file);
- if (root->get_children() == ti)
+ if (root->get_children() == ti) {
ti->select(0);
+ }
}
}
@@ -197,10 +186,10 @@ void ScriptEditorQuickOpen::_update_search() {
}
void ScriptEditorQuickOpen::_confirmed() {
-
TreeItem *ti = search_options->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
int line = ti->get_text(0).get_slice(":", 1).to_int();
emit_signal("goto_line", line - 1);
@@ -208,7 +197,6 @@ void ScriptEditorQuickOpen::_confirmed() {
}
void ScriptEditorQuickOpen::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
@@ -226,12 +214,10 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
}
void ScriptEditorQuickOpen::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("goto_line", PropertyInfo(Variant::INT, "line")));
}
ScriptEditorQuickOpen::ScriptEditorQuickOpen() {
-
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
search_box = memnew(LineEdit);
@@ -257,24 +243,20 @@ ScriptEditor *ScriptEditor::script_editor = nullptr;
/*** SCRIPT EDITOR ******/
String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
-
String val = EditorDebuggerNode::get_singleton()->get_var_value(p_text);
if (val != String()) {
return p_text + ": " + val;
} else {
-
return String();
}
}
void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
-
if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
return;
}
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
continue;
@@ -289,14 +271,13 @@ void ScriptEditor::_script_created(Ref<Script> p_script) {
}
void ScriptEditor::_goto_script_line2(int p_line) {
-
ScriptEditorBase *current = _get_current_editor();
- if (current)
+ if (current) {
current->goto_line(p_line);
+ }
}
void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
-
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
if (edit(p_script, p_line, 0)) {
@@ -316,10 +297,10 @@ void ScriptEditor::_set_execution(REF p_script, int p_line) {
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) {
se->set_executing_line(p_line);
@@ -332,10 +313,10 @@ void ScriptEditor::_clear_execution(REF p_script) {
Ref<Script> script = Object::cast_to<Script>(*p_script);
if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) {
se->clear_executing_line();
@@ -345,32 +326,27 @@ void ScriptEditor::_clear_execution(REF p_script) {
}
ScriptEditorBase *ScriptEditor::_get_current_editor() const {
-
int selected = tab_container->get_current_tab();
- if (selected < 0 || selected >= tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count()) {
return nullptr;
+ }
return Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
}
void ScriptEditor::_update_history_arrows() {
-
script_back->set_disabled(history_pos <= 0);
script_forward->set_disabled(history_pos >= history.size() - 1);
}
void ScriptEditor::_save_history() {
-
if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) {
-
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(n)) {
-
history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
if (Object::cast_to<EditorHelp>(n)) {
-
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
}
@@ -387,29 +363,25 @@ void ScriptEditor::_save_history() {
}
void ScriptEditor::_go_to_tab(int p_idx) {
-
ScriptEditorBase *current = _get_current_editor();
if (current) {
if (current->is_unsaved()) {
-
current->apply_code();
}
}
Control *c = Object::cast_to<Control>(tab_container->get_child(p_idx));
- if (!c)
+ if (!c) {
return;
+ }
if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) {
-
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(n)) {
-
history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
if (Object::cast_to<EditorHelp>(n)) {
-
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
}
@@ -427,11 +399,11 @@ void ScriptEditor::_go_to_tab(int p_idx) {
c = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(c)) {
-
script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_theme_icon());
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
+ }
Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
if (script != nullptr) {
@@ -441,11 +413,11 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Object::cast_to<ScriptEditorBase>(c)->validate();
}
if (Object::cast_to<EditorHelp>(c)) {
-
script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class());
script_icon->set_texture(get_theme_icon("Help", "EditorIcons"));
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
Object::cast_to<EditorHelp>(c)->set_focused();
+ }
}
c->set_meta("__editor_pass", ++edit_pass);
@@ -459,7 +431,6 @@ void ScriptEditor::_go_to_tab(int p_idx) {
}
void ScriptEditor::_add_recent_script(String p_path) {
-
if (p_path.empty()) {
return;
}
@@ -478,13 +449,11 @@ void ScriptEditor::_add_recent_script(String p_path) {
}
void ScriptEditor::_update_recent_scripts() {
-
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array());
recent_scripts->clear();
String path;
for (int i = 0; i < rc.size(); i++) {
-
path = rc[i];
recent_scripts->add_item(path.replace("res://", ""));
}
@@ -496,7 +465,6 @@ void ScriptEditor::_update_recent_scripts() {
}
void ScriptEditor::_open_recent_script(int p_idx) {
-
// clear button
if (p_idx == recent_scripts->get_item_count() - 1) {
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", Array());
@@ -555,16 +523,15 @@ void ScriptEditor::_open_recent_script(int p_idx) {
}
void ScriptEditor::_show_error_dialog(String p_path) {
-
error_dialog->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_path));
error_dialog->popup_centered();
}
void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
-
int selected = p_idx;
- if (selected < 0 || selected >= tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count()) {
return;
+ }
Node *tselected = tab_container->get_child(selected);
@@ -606,10 +573,10 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
current->clear_edit_menu();
}
memdelete(tselected);
- if (idx >= tab_container->get_child_count())
+ if (idx >= tab_container->get_child_count()) {
idx = tab_container->get_child_count() - 1;
+ }
if (idx >= 0) {
-
if (history_pos >= 0) {
idx = history[history_pos].control->get_index();
}
@@ -627,7 +594,6 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
}
void ScriptEditor::_close_current_tab() {
-
_close_tab(tab_container->get_current_tab());
}
@@ -637,10 +603,8 @@ void ScriptEditor::_close_discard_current_tab(const String &p_str) {
}
void ScriptEditor::_close_docs_tab() {
-
int child_count = tab_container->get_child_count();
for (int i = child_count - 1; i >= 0; i--) {
-
EditorHelp *se = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (se) {
@@ -656,11 +620,9 @@ void ScriptEditor::_copy_script_path() {
}
void ScriptEditor::_close_other_tabs() {
-
int child_count = tab_container->get_child_count();
int current_idx = tab_container->get_current_tab();
for (int i = child_count - 1; i >= 0; i--) {
-
if (i == current_idx) {
continue;
}
@@ -669,7 +631,6 @@ void ScriptEditor::_close_other_tabs() {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
-
// Maybe there are unsaved changes
if (se->is_unsaved()) {
_ask_close_current_unsaved_tab(se);
@@ -682,15 +643,12 @@ void ScriptEditor::_close_other_tabs() {
}
void ScriptEditor::_close_all_tabs() {
-
int child_count = tab_container->get_child_count();
for (int i = child_count - 1; i >= 0; i--) {
-
tab_container->set_current_tab(i);
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
-
// Maybe there are unsaved changes
if (se->is_unsaved()) {
_ask_close_current_unsaved_tab(se);
@@ -708,19 +666,19 @@ void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) {
}
void ScriptEditor::_resave_scripts(const String &p_str) {
-
apply_scripts();
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
RES script = se->get_edited_resource();
- if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)
+ if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
continue; //internal script, who cares
+ }
if (trim_trailing_whitespace_on_save) {
se->trim_trailing_whitespace();
@@ -751,19 +709,15 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
}
void ScriptEditor::_reload_scripts() {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
-
continue;
}
RES edited_res = se->get_edited_resource();
if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) {
-
continue; //internal script, who cares
}
@@ -799,12 +753,9 @@ void ScriptEditor::_reload_scripts() {
}
void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
-
continue;
}
@@ -815,7 +766,6 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
}
if (script == p_res) {
-
se->tag_saved_version();
}
}
@@ -834,7 +784,6 @@ void ScriptEditor::_live_auto_reload_running_scripts() {
}
bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
-
disk_changed_list->clear();
TreeItem *r = disk_changed_list->create_item();
disk_changed_list->set_hide_root(true);
@@ -844,22 +793,21 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
bool use_autoreload = bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", false));
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
-
RES edited_res = se->get_edited_resource();
- if (p_for_script.is_valid() && edited_res.is_valid() && p_for_script != edited_res)
+ if (p_for_script.is_valid() && edited_res.is_valid() && p_for_script != edited_res) {
continue;
+ }
- if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1)
+ if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) {
continue; //internal script, who cares
+ }
uint64_t last_date = edited_res->get_last_modified_time();
uint64_t date = FileAccess::get_modified_time(edited_res->get_path());
if (last_date != date) {
-
TreeItem *ti = disk_changed_list->create_item(r);
ti->set_text(0, edited_res->get_path().get_file());
@@ -884,13 +832,11 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
}
void ScriptEditor::_file_dialog_action(String p_file) {
-
switch (file_dialog_option) {
case FILE_NEW_TEXTFILE: {
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err) {
- memdelete(file);
editor->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!"));
break;
}
@@ -899,7 +845,6 @@ void ScriptEditor::_file_dialog_action(String p_file) {
[[fallthrough]];
}
case FILE_OPEN: {
-
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
if (extensions.find(p_file.get_extension())) {
@@ -956,7 +901,6 @@ void ScriptEditor::_file_dialog_action(String p_file) {
}
Ref<Script> ScriptEditor::_get_current_script() {
-
ScriptEditorBase *current = _get_current_editor();
if (current) {
@@ -968,7 +912,6 @@ Ref<Script> ScriptEditor::_get_current_script() {
}
Array ScriptEditor::_get_open_scripts() const {
-
Array ret;
Vector<Ref<Script>> scripts = get_open_scripts();
int scrits_amount = scripts.size();
@@ -988,7 +931,6 @@ bool ScriptEditor::is_scripts_panel_toggled() {
}
void ScriptEditor::_menu_option(int p_option) {
-
ScriptEditorBase *current = _get_current_editor();
switch (p_option) {
case FILE_NEW: {
@@ -1021,9 +963,9 @@ void ScriptEditor::_menu_option(int p_option) {
return;
} break;
case FILE_REOPEN_CLOSED: {
-
- if (previous_scripts.empty())
+ if (previous_scripts.empty()) {
return;
+ }
String path = previous_scripts.back()->get();
previous_scripts.pop_back();
@@ -1060,8 +1002,9 @@ void ScriptEditor::_menu_option(int p_option) {
} else {
Error error;
Ref<TextFile> text_file = _load_text_file(path, &error);
- if (error != OK)
+ if (error != OK) {
editor->show_warning(TTR("Could not load file at:") + "\n\n" + path, TTR("Error!"));
+ }
if (text_file.is_valid()) {
edit(text_file);
@@ -1071,34 +1014,28 @@ void ScriptEditor::_menu_option(int p_option) {
}
} break;
case FILE_SAVE_ALL: {
-
- if (_test_script_times_on_disk())
+ if (_test_script_times_on_disk()) {
return;
+ }
save_all_scripts();
} break;
case SEARCH_IN_FILES: {
-
_on_find_in_files_requested("");
} break;
case REPLACE_IN_FILES: {
-
_on_replace_in_files_requested("");
} break;
case SEARCH_HELP: {
-
help_search_dialog->popup_dialog();
} break;
case SEARCH_WEBSITE: {
-
OS::get_singleton()->shell_open("https://docs.godotengine.org/");
} break;
case WINDOW_NEXT: {
-
_history_forward();
} break;
case WINDOW_PREV: {
-
_history_back();
} break;
case WINDOW_SORT: {
@@ -1119,15 +1056,15 @@ void ScriptEditor::_menu_option(int p_option) {
}
if (current) {
-
switch (p_option) {
case FILE_SAVE: {
-
- if (_test_script_times_on_disk())
+ if (_test_script_times_on_disk()) {
return;
+ }
- if (trim_trailing_whitespace_on_save)
+ if (trim_trailing_whitespace_on_save) {
current->trim_trailing_whitespace();
+ }
current->insert_final_newline();
@@ -1149,9 +1086,9 @@ void ScriptEditor::_menu_option(int p_option) {
} break;
case FILE_SAVE_AS: {
-
- if (trim_trailing_whitespace_on_save)
+ if (trim_trailing_whitespace_on_save) {
current->trim_trailing_whitespace();
+ }
current->insert_final_newline();
@@ -1186,12 +1123,10 @@ void ScriptEditor::_menu_option(int p_option) {
case FILE_TOOL_RELOAD:
case FILE_TOOL_RELOAD_SOFT: {
-
current->reload(p_option == FILE_TOOL_RELOAD_SOFT);
} break;
case FILE_RUN: {
-
Ref<Script> scr = current->get_edited_resource();
if (scr == nullptr || scr.is_null()) {
EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running."));
@@ -1206,13 +1141,11 @@ void ScriptEditor::_menu_option(int p_option) {
return;
}
if (!scr->is_tool()) {
-
EditorNode::get_singleton()->show_warning(TTR("Script is not in tool mode, will not be able to run."));
return;
}
if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) {
-
EditorNode::get_singleton()->show_warning(TTR("To run this script, it must inherit EditorScript and be set to tool mode."));
return;
}
@@ -1256,7 +1189,6 @@ void ScriptEditor::_menu_option(int p_option) {
_close_all_tabs();
} break;
case WINDOW_MOVE_UP: {
-
if (tab_container->get_current_tab() > 0) {
tab_container->move_child(current, tab_container->get_current_tab() - 1);
tab_container->set_current_tab(tab_container->get_current_tab() - 1);
@@ -1264,7 +1196,6 @@ void ScriptEditor::_menu_option(int p_option) {
}
} break;
case WINDOW_MOVE_DOWN: {
-
if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) {
tab_container->move_child(current, tab_container->get_current_tab() + 1);
tab_container->set_current_tab(tab_container->get_current_tab() + 1);
@@ -1272,19 +1203,15 @@ void ScriptEditor::_menu_option(int p_option) {
}
} break;
default: {
-
if (p_option >= WINDOW_SELECT_BASE) {
-
tab_container->set_current_tab(p_option - WINDOW_SELECT_BASE);
_update_script_names();
}
}
}
} else {
-
EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
if (help) {
-
switch (p_option) {
case HELP_SEARCH_FIND: {
help->popup_search();
@@ -1308,7 +1235,6 @@ void ScriptEditor::_menu_option(int p_option) {
_close_all_tabs();
} break;
case WINDOW_MOVE_UP: {
-
if (tab_container->get_current_tab() > 0) {
tab_container->move_child(help, tab_container->get_current_tab() - 1);
tab_container->set_current_tab(tab_container->get_current_tab() - 1);
@@ -1316,7 +1242,6 @@ void ScriptEditor::_menu_option(int p_option) {
}
} break;
case WINDOW_MOVE_DOWN: {
-
if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) {
tab_container->move_child(help, tab_container->get_current_tab() + 1);
tab_container->set_current_tab(tab_container->get_current_tab() + 1);
@@ -1367,16 +1292,12 @@ void ScriptEditor::_show_save_theme_as_dialog() {
}
void ScriptEditor::_tab_changed(int p_which) {
-
ensure_select_current();
}
void ScriptEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
editor->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
editor->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback));
editor->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback));
@@ -1390,7 +1311,6 @@ void ScriptEditor::_notification(int p_what) {
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
-
help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons"));
site_search->set_icon(get_theme_icon("Instance", "EditorIcons"));
@@ -1408,25 +1328,21 @@ void ScriptEditor::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
-
get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed));
editor->get_inspector_dock()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open));
editor->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search));
} break;
case NOTIFICATION_EXIT_TREE: {
-
editor->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop));
} break;
case NOTIFICATION_WM_FOCUS_IN: {
-
_test_script_times_on_disk();
_update_modified_scripts_for_external_editor();
} break;
case CanvasItem::NOTIFICATION_VISIBILITY_CHANGED: {
-
if (is_visible()) {
find_in_files_button->show();
} else {
@@ -1444,25 +1360,23 @@ void ScriptEditor::_notification(int p_what) {
}
bool ScriptEditor::can_take_away_focus() const {
-
ScriptEditorBase *current = _get_current_editor();
- if (current)
+ if (current) {
return current->can_lose_focus_on_node_selection();
- else
+ } else {
return true;
+ }
}
void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
-
Ref<Script> script = se->get_edited_resource();
- if (script == nullptr || !script.is_valid())
+ if (script == nullptr || !script.is_valid()) {
continue;
+ }
if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
_close_tab(i);
@@ -1473,7 +1387,6 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
}
void ScriptEditor::edited_scene_changed() {
-
_update_modified_scripts_for_external_editor();
}
@@ -1486,12 +1399,11 @@ void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) {
}
void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
Ref<Script> script = se->get_edited_resource();
if (script == nullptr) {
@@ -1504,20 +1416,20 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
ERR_CONTINUE(base.begins_with("local://") || base == "");
for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
-
p_breakpoints->push_back(base + ":" + itos(E->get() + 1));
}
}
}
void ScriptEditor::ensure_focus_current() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
ScriptEditorBase *current = _get_current_editor();
- if (current)
+ if (current) {
current->ensure_focus();
+ }
}
void ScriptEditor::_members_overview_selected(int p_idx) {
@@ -1544,7 +1456,6 @@ void ScriptEditor::_help_overview_selected(int p_idx) {
}
void ScriptEditor::_script_selected(int p_idx) {
-
grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
_go_to_tab(script_list->get_item_metadata(p_idx));
@@ -1552,14 +1463,12 @@ void ScriptEditor::_script_selected(int p_idx) {
}
void ScriptEditor::ensure_select_current() {
-
if (tab_container->get_child_count() && tab_container->get_current_tab() >= 0) {
-
ScriptEditorBase *se = _get_current_editor();
if (se) {
-
- if (!grab_focus_block && is_visible_in_tree())
+ if (!grab_focus_block && is_visible_in_tree()) {
se->ensure_focus();
+ }
}
}
@@ -1567,13 +1476,15 @@ void ScriptEditor::ensure_select_current() {
}
void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> &used) {
- if (p_current != p_base && p_current->get_owner() != p_base)
+ if (p_current != p_base && p_current->get_owner() != p_base) {
return;
+ }
if (p_current->get_script_instance()) {
Ref<Script> scr = p_current->get_script();
- if (scr.is_valid())
+ if (scr.is_valid()) {
used.insert(scr);
+ }
}
for (int i = 0; i < p_current->get_child_count(); i++) {
@@ -1582,7 +1493,6 @@ void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>>
}
struct _ScriptEditorItemData {
-
String name;
String sort_key;
Ref<Texture2D> icon;
@@ -1593,7 +1503,6 @@ struct _ScriptEditorItemData {
Node *ref;
bool operator<(const _ScriptEditorItemData &id) const {
-
if (category == id.category) {
if (sort_key == id.sort_key) {
return index < id.index;
@@ -1607,7 +1516,6 @@ struct _ScriptEditorItemData {
};
void ScriptEditor::_update_members_overview_visibility() {
-
ScriptEditorBase *se = _get_current_editor();
if (!se) {
members_overview_alphabeta_sort_button->set_visible(false);
@@ -1661,7 +1569,6 @@ void ScriptEditor::_update_members_overview() {
}
void ScriptEditor::_update_help_overview_visibility() {
-
int selected = tab_container->get_current_tab();
if (selected < 0 || selected >= tab_container->get_child_count()) {
help_overview->set_visible(false);
@@ -1690,8 +1597,9 @@ void ScriptEditor::_update_help_overview() {
help_overview->clear();
int selected = tab_container->get_current_tab();
- if (selected < 0 || selected >= tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count()) {
return;
+ }
Node *current = tab_container->get_child(tab_container->get_current_tab());
EditorHelp *se = Object::cast_to<EditorHelp>(current);
@@ -1707,7 +1615,6 @@ void ScriptEditor::_update_help_overview() {
}
void ScriptEditor::_update_script_colors() {
-
bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_enabled");
bool highlight_current = EditorSettings::get_singleton()->get("text_editor/script_list/highlight_current_script");
@@ -1716,11 +1623,11 @@ void ScriptEditor::_update_script_colors() {
Color cold_color = get_theme_color("font_color", "Editor");
for (int i = 0; i < script_list->get_item_count(); i++) {
-
int c = script_list->get_item_metadata(i);
Node *n = tab_container->get_child(c);
- if (!n)
+ if (!n) {
continue;
+ }
script_list->set_item_custom_bg_color(i, Color(0, 0, 0, 0));
@@ -1729,7 +1636,6 @@ void ScriptEditor::_update_script_colors() {
script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/script_list/current_script_background_color"));
} else if (script_temperature_enabled) {
-
if (!n->has_meta("__editor_pass")) {
continue;
}
@@ -1748,9 +1654,9 @@ void ScriptEditor::_update_script_colors() {
}
void ScriptEditor::_update_script_names() {
-
- if (restoring_layout)
+ if (restoring_layout) {
return;
+ }
Set<Ref<Script>> used;
Node *edited = EditorNode::get_singleton()->get_edited_scene();
@@ -1766,17 +1672,14 @@ void ScriptEditor::_update_script_names() {
Vector<_ScriptEditorItemData> sedata;
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
-
Ref<Texture2D> icon = se->get_theme_icon();
String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name;
if (built_in) {
-
name = path.get_file();
const String &resource_name = se->get_edited_resource()->get_name();
if (resource_name != "") {
@@ -1785,7 +1688,6 @@ void ScriptEditor::_update_script_names() {
name = vformat("%s (%s)", resource_name, name.substr(0, name.find("::", 0)));
}
} else {
-
name = se->get_name();
}
@@ -1831,7 +1733,6 @@ void ScriptEditor::_update_script_names() {
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
-
String name = eh->get_class();
Ref<Texture2D> icon = get_theme_icon("Help", "EditorIcons");
String tooltip = vformat(TTR("%s Class Reference"), name);
@@ -1978,9 +1879,9 @@ Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_p
}
bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus) {
-
- if (p_resource.is_null())
+ if (p_resource.is_null()) {
return false;
+ }
Ref<Script> script = p_resource;
@@ -1995,8 +1896,9 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
if (script != nullptr && script->get_language()->overrides_external_editor()) {
if (should_open) {
Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col);
- if (err != OK)
+ if (err != OK) {
ERR_PRINT("Couldn't open script in the overridden external text editor");
+ }
}
return false;
}
@@ -2005,7 +1907,6 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
p_resource->get_path().is_resource_file() &&
p_resource->get_class_name() != StringName("VisualScript") &&
bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
-
String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
@@ -2025,16 +1926,13 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
bool inside_quotes = false;
for (int i = 0; i < flags.size(); i++) {
-
if (flags[i] == '"' && (!i || flags[i - 1] != '\\')) {
-
if (!inside_quotes) {
from++;
}
inside_quotes = !inside_quotes;
} else if (flags[i] == '\0' || (!inside_quotes && flags[i] == ' ')) {
-
String arg = flags.substr(from, num_chars);
if (arg.find("{file}") != -1) {
has_file_flag = true;
@@ -2059,26 +1957,27 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
}
Error err = OS::get_singleton()->execute(path, args, false);
- if (err == OK)
+ if (err == OK) {
return false;
+ }
WARN_PRINT("Couldn't open external text editor, using internal");
}
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) {
-
if (should_open) {
if (tab_container->get_current_tab() != i) {
_go_to_tab(i);
_update_script_names();
}
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
se->ensure_focus();
+ }
if (p_line > 0) {
se->goto_line(p_line - 1);
@@ -2096,8 +1995,9 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
for (int i = script_editor_func_count - 1; i >= 0; i--) {
se = script_editor_funcs[i](p_resource);
- if (se)
+ if (se) {
break;
+ }
}
ERR_FAIL_COND_V(!se, false);
@@ -2157,12 +2057,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
}
void ScriptEditor::save_all_scripts() {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
if (convert_indent_on_save) {
if (use_space_indentation) {
@@ -2178,8 +2077,9 @@ void ScriptEditor::save_all_scripts() {
se->insert_final_newline();
- if (!se->is_unsaved())
+ if (!se->is_unsaved()) {
continue;
+ }
RES edited_res = se->get_edited_resource();
if (edited_res.is_valid()) {
@@ -2201,12 +2101,11 @@ void ScriptEditor::save_all_scripts() {
}
void ScriptEditor::apply_scripts() const {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
se->apply_code();
}
}
@@ -2218,10 +2117,8 @@ void ScriptEditor::open_script_create_dialog(const String &p_base_name, const St
void ScriptEditor::_editor_stop() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
-
continue;
}
@@ -2230,7 +2127,6 @@ void ScriptEditor::_editor_stop() {
}
void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) {
-
ERR_FAIL_COND(!p_obj);
Ref<Script> script = p_obj->get_script();
ERR_FAIL_COND(!script.is_valid());
@@ -2238,12 +2134,13 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
editor->push_item(script.ptr());
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
- if (se->get_edited_resource() != script)
+ }
+ if (se->get_edited_resource() != script) {
continue;
+ }
se->add_callback(p_function, p_args);
@@ -2256,7 +2153,6 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
}
void ScriptEditor::_save_layout() {
-
if (restoring_layout) {
return;
}
@@ -2265,7 +2161,6 @@ void ScriptEditor::_save_layout() {
}
void ScriptEditor::_editor_settings_changed() {
-
trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/files/trim_trailing_whitespace_on_save");
convert_indent_on_save = EditorSettings::get_singleton()->get("text_editor/indent/convert_indent_on_save");
use_space_indentation = EditorSettings::get_singleton()->get("text_editor/indent/type");
@@ -2285,10 +2180,10 @@ void ScriptEditor::_editor_settings_changed() {
}
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
se->update_settings();
}
@@ -2299,12 +2194,10 @@ void ScriptEditor::_editor_settings_changed() {
}
void ScriptEditor::_autosave_scripts() {
-
save_all_scripts();
}
void ScriptEditor::_update_autosave_timer() {
-
if (!autosave_timer->is_inside_tree()) {
return;
}
@@ -2319,9 +2212,9 @@ void ScriptEditor::_update_autosave_timer() {
}
void ScriptEditor::_tree_changed() {
-
- if (waiting_update_names)
+ if (waiting_update_names) {
return;
+ }
waiting_update_names = true;
call_deferred("_update_script_names");
@@ -2329,14 +2222,13 @@ void ScriptEditor::_tree_changed() {
}
void ScriptEditor::_script_split_dragged(float) {
-
_save_layout();
}
Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
- if (tab_container->get_child_count() == 0)
+ if (tab_container->get_child_count() == 0) {
return Variant();
+ }
Node *cur_node = tab_container->get_child(tab_container->get_current_tab());
@@ -2372,13 +2264,12 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
}
bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
if (String(d["type"]) == "script_list_element") {
-
Node *node = d["script_list_element"];
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node);
@@ -2392,10 +2283,10 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (String(d["type"]) == "nodes") {
-
Array nodes = d["nodes"];
- if (nodes.size() == 0)
+ if (nodes.size() == 0) {
return false;
+ }
Node *node = get_node((nodes[0]));
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node);
@@ -2409,16 +2300,17 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
- if (files.size() == 0)
+ if (files.size() == 0) {
return false; //weird
+ }
for (int i = 0; i < files.size(); i++) {
String file = files[i];
- if (file == "" || !FileAccess::exists(file))
+ if (file == "" || !FileAccess::exists(file)) {
continue;
+ }
Ref<Script> scr = ResourceLoader::load(file);
if (scr.is_valid()) {
return true;
@@ -2431,16 +2323,16 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data
}
void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return;
+ }
if (String(d["type"]) == "script_list_element") {
-
Node *node = d["script_list_element"];
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node);
@@ -2457,10 +2349,10 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
if (String(d["type"]) == "nodes") {
-
Array nodes = d["nodes"];
- if (nodes.size() == 0)
+ if (nodes.size() == 0) {
return;
+ }
Node *node = get_node(nodes[0]);
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node);
@@ -2477,7 +2369,6 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
int new_index = 0;
@@ -2487,8 +2378,9 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
int num_tabs_before = tab_container->get_child_count();
for (int i = 0; i < files.size(); i++) {
String file = files[i];
- if (file == "" || !FileAccess::exists(file))
+ if (file == "" || !FileAccess::exists(file)) {
continue;
+ }
Ref<Script> scr = ResourceLoader::load(file);
if (scr.is_valid()) {
edit(scr);
@@ -2506,8 +2398,9 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
}
void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
- if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo())
+ if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) {
return;
+ }
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
if (script_list->get_item_count() > 1) {
int next_tab = script_list->get_current() + 1;
@@ -2533,11 +2426,9 @@ void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
-
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid() && mb->is_pressed()) {
switch (mb->get_button_index()) {
-
case BUTTON_MIDDLE: {
// Right-click selects automatically; middle-click does not.
int idx = script_list->get_item_at_position(mb->get_position(), true);
@@ -2556,12 +2447,12 @@ void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
}
void ScriptEditor::_make_script_list_context_menu() {
-
context_menu->clear();
int selected = tab_container->get_current_tab();
- if (selected < 0 || selected >= tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count()) {
return;
+ }
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (se) {
@@ -2597,18 +2488,19 @@ void ScriptEditor::_make_script_list_context_menu() {
}
void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
-
if (!bool(EDITOR_DEF("text_editor/files/restore_scripts_on_load", true))) {
return;
}
- if (!p_layout->has_section_key("ScriptEditor", "open_scripts") && !p_layout->has_section_key("ScriptEditor", "open_help"))
+ if (!p_layout->has_section_key("ScriptEditor", "open_scripts") && !p_layout->has_section_key("ScriptEditor", "open_help")) {
return;
+ }
Array scripts = p_layout->get_value("ScriptEditor", "open_scripts");
Array helps;
- if (p_layout->has_section_key("ScriptEditor", "open_help"))
+ if (p_layout->has_section_key("ScriptEditor", "open_help")) {
helps = p_layout->get_value("ScriptEditor", "open_help");
+ }
restoring_layout = true;
@@ -2616,7 +2508,6 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
for (int i = 0; i < scripts.size(); i++) {
-
String path = scripts[i];
Dictionary script_info = scripts[i];
@@ -2624,8 +2515,9 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
path = script_info["path"];
}
- if (!FileAccess::exists(path))
+ if (!FileAccess::exists(path)) {
continue;
+ }
if (extensions.find(path.get_extension())) {
Ref<Script> scr = ResourceLoader::load(path);
@@ -2655,7 +2547,6 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
}
for (int i = 0; i < helps.size(); i++) {
-
String path = helps[i];
if (path == "") { // invalid, skip
continue;
@@ -2677,18 +2568,16 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
}
void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
-
Array scripts;
Array helps;
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
-
String path = se->get_edited_resource()->get_path();
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
continue;
+ }
Dictionary script_info;
script_info["path"] = path;
@@ -2700,7 +2589,6 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
-
helps.push_back(eh->get_class());
}
}
@@ -2711,16 +2599,14 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
}
void ScriptEditor::_help_class_open(const String &p_class) {
-
- if (p_class == "")
+ if (p_class == "") {
return;
+ }
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh && eh->get_class() == p_class) {
-
_go_to_tab(i);
_update_script_names();
return;
@@ -2741,15 +2627,12 @@ void ScriptEditor::_help_class_open(const String &p_class) {
}
void ScriptEditor::_help_class_goto(const String &p_desc) {
-
String cname = p_desc.get_slice(":", 1);
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh && eh->get_class() == cname) {
-
_go_to_tab(i);
eh->go_to_help(p_desc);
_update_script_names();
@@ -2771,25 +2654,22 @@ void ScriptEditor::_help_class_goto(const String &p_desc) {
}
void ScriptEditor::_update_selected_editor_menu() {
-
for (int i = 0; i < tab_container->get_child_count(); i++) {
-
bool current = tab_container->get_current_tab() == i;
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se && se->get_edit_menu()) {
-
- if (current)
+ if (current) {
se->get_edit_menu()->show();
- else
+ } else {
se->get_edit_menu()->hide();
+ }
}
}
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control());
script_search_menu->get_popup()->clear();
if (eh) {
-
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F), HELP_SEARCH_FIND);
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), HELP_SEARCH_FIND_NEXT);
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3), HELP_SEARCH_FIND_PREVIOUS);
@@ -2797,7 +2677,6 @@ void ScriptEditor::_update_selected_editor_menu() {
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_in_files", TTR("Find in Files"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F), SEARCH_IN_FILES);
script_search_menu->show();
} else {
-
if (tab_container->get_child_count() == 0) {
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_in_files", TTR("Find in Files"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F), SEARCH_IN_FILES);
script_search_menu->show();
@@ -2808,15 +2687,12 @@ void ScriptEditor::_update_selected_editor_menu() {
}
void ScriptEditor::_update_history_pos(int p_new_pos) {
-
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<ScriptEditorBase>(n)) {
-
history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state();
}
if (Object::cast_to<EditorHelp>(n)) {
-
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
}
@@ -2826,7 +2702,6 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n = history[history_pos].control;
if (Object::cast_to<ScriptEditorBase>(n)) {
-
Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state);
Object::cast_to<ScriptEditorBase>(n)->ensure_focus();
@@ -2837,7 +2712,6 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
}
if (Object::cast_to<EditorHelp>(n)) {
-
Object::cast_to<EditorHelp>(n)->set_scroll(history[history_pos].state);
Object::cast_to<EditorHelp>(n)->set_focused();
}
@@ -2849,27 +2723,25 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
}
void ScriptEditor::_history_forward() {
-
if (history_pos < history.size() - 1) {
_update_history_pos(history_pos + 1);
}
}
void ScriptEditor::_history_back() {
-
if (history_pos > 0) {
_update_history_pos(history_pos - 1);
}
}
Vector<Ref<Script>> ScriptEditor::get_open_scripts() const {
-
Vector<Ref<Script>> out_scripts = Vector<Ref<Script>>();
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
- if (!se)
+ if (!se) {
continue;
+ }
Ref<Script> script = se->get_edited_resource();
if (script != nullptr) {
@@ -2881,11 +2753,11 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const {
}
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
-
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
- if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")))
+ if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
return;
+ }
if (open_dominant && p_script.is_valid()) {
edit(p_script);
@@ -2893,17 +2765,16 @@ void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
}
bool ScriptEditor::script_goto_method(Ref<Script> p_script, const String &p_method) {
-
int line = p_script->get_member_line(p_method);
- if (line == -1)
+ if (line == -1) {
return false;
+ }
return edit(p_script, line, 0);
}
void ScriptEditor::set_live_auto_reload_running_scripts(bool p_enabled) {
-
auto_reload_running_scripts = p_enabled;
}
@@ -2912,7 +2783,6 @@ void ScriptEditor::_help_search(String p_text) {
}
void ScriptEditor::_open_script_request(const String &p_path) {
-
Ref<Script> script = ResourceLoader::load(p_path);
if (script.is_valid()) {
script_editor->edit(script, false);
@@ -2939,25 +2809,21 @@ int ScriptEditor::script_editor_func_count = 0;
CreateScriptEditorFunc ScriptEditor::script_editor_funcs[ScriptEditor::SCRIPT_EDITOR_FUNC_MAX];
void ScriptEditor::register_create_script_editor_function(CreateScriptEditorFunc p_func) {
-
ERR_FAIL_COND(script_editor_func_count == SCRIPT_EDITOR_FUNC_MAX);
script_editor_funcs[script_editor_func_count++] = p_func;
}
void ScriptEditor::_script_changed() {
-
NodeDock::singleton->update_lists();
}
void ScriptEditor::_on_find_in_files_requested(String text) {
-
find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::SEARCH_MODE);
find_in_files_dialog->set_search_text(text);
find_in_files_dialog->popup_centered();
}
void ScriptEditor::_on_replace_in_files_requested(String text) {
-
find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::REPLACE_MODE);
find_in_files_dialog->set_search_text(text);
find_in_files_dialog->set_replace_text("");
@@ -2965,7 +2831,6 @@ void ScriptEditor::_on_replace_in_files_requested(String text) {
}
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
-
if (ResourceLoader::exists(fpath)) {
RES res = ResourceLoader::load(fpath);
@@ -3003,7 +2868,6 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb
}
void ScriptEditor::_start_find_in_files(bool with_replace) {
-
FindInFiles *f = find_in_files->get_finder();
f->set_search_text(find_in_files_dialog->get_search_text());
@@ -3020,7 +2884,6 @@ void ScriptEditor::_start_find_in_files(bool with_replace) {
}
void ScriptEditor::_on_find_in_files_modified_files(PackedStringArray paths) {
-
_test_script_times_on_disk();
_update_modified_scripts_for_external_editor();
}
@@ -3034,7 +2897,6 @@ void ScriptEditor::_filter_methods_text_changed(const String &p_newtext) {
}
void ScriptEditor::_bind_methods() {
-
ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab);
ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs);
ClassDB::bind_method("_close_other_tabs", &ScriptEditor::_close_other_tabs);
@@ -3063,7 +2925,6 @@ void ScriptEditor::_bind_methods() {
}
ScriptEditor::ScriptEditor(EditorNode *p_editor) {
-
current_theme = "";
completion_cache = memnew(EditorScriptCodeCompletionCache);
@@ -3364,14 +3225,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
}
ScriptEditor::~ScriptEditor() {
-
memdelete(completion_cache);
}
void ScriptEditorPlugin::edit(Object *p_object) {
-
if (Object::cast_to<Script>(p_object)) {
-
Script *p_script = Object::cast_to<Script>(p_object);
String res_path = p_script->get_path().get_slice("::", 0);
@@ -3391,7 +3249,6 @@ void ScriptEditorPlugin::edit(Object *p_object) {
}
bool ScriptEditorPlugin::handles(Object *p_object) const {
-
if (Object::cast_to<TextFile>(p_object)) {
return true;
}
@@ -3404,30 +3261,25 @@ bool ScriptEditorPlugin::handles(Object *p_object) const {
}
void ScriptEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
script_editor->show();
script_editor->set_process(true);
script_editor->ensure_select_current();
} else {
-
script_editor->hide();
script_editor->set_process(false);
}
}
void ScriptEditorPlugin::selected_notify() {
-
script_editor->ensure_select_current();
}
void ScriptEditorPlugin::save_external_data() {
-
script_editor->save_all_scripts();
}
void ScriptEditorPlugin::apply_changes() {
-
script_editor->apply_scripts();
}
@@ -3438,27 +3290,22 @@ void ScriptEditorPlugin::save_global_state() {
}
void ScriptEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
-
script_editor->set_window_layout(p_layout);
}
void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
-
script_editor->get_window_layout(p_layout);
}
void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
-
script_editor->get_breakpoints(p_breakpoints);
}
void ScriptEditorPlugin::edited_scene_changed() {
-
script_editor->edited_scene_changed();
}
ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
script_editor = memnew(ScriptEditor(p_node));
editor->get_viewport()->add_child(script_editor);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index e895867268..f7352be7e8 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -49,7 +49,6 @@
#include "scene/resources/text_file.h"
class ScriptEditorQuickOpen : public ConfirmationDialog {
-
GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog);
LineEdit *search_box;
@@ -76,7 +75,6 @@ public:
class EditorDebuggerNode;
class ScriptEditorBase : public VBoxContainer {
-
GDCLASS(ScriptEditorBase, VBoxContainer);
protected:
@@ -131,7 +129,6 @@ class FindInFilesDialog;
class FindInFilesPanel;
class ScriptEditor : public PanelContainer {
-
GDCLASS(ScriptEditor, PanelContainer);
EditorNode *editor;
@@ -250,7 +247,6 @@ class ScriptEditor : public PanelContainer {
static CreateSyntaxHighlighterFunc syntax_highlighters_funcs[SYNTAX_HIGHLIGHTER_FUNC_MAX];
struct ScriptHistory {
-
Control *control;
Variant state;
};
@@ -454,7 +450,6 @@ public:
};
class ScriptEditorPlugin : public EditorPlugin {
-
GDCLASS(ScriptEditorPlugin, EditorPlugin);
ScriptEditor *script_editor;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 109d83d838..4b79d8c344 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -109,7 +109,6 @@ ConnectionInfoDialog::ConnectionInfoDialog() {
////////////////////////////////////////////////////////////////////////////////
Vector<String> ScriptTextEditor::get_functions() {
-
String errortxt;
int line = -1, col;
TextEdit *te = code_editor->get_text_edit();
@@ -117,11 +116,9 @@ Vector<String> ScriptTextEditor::get_functions() {
List<String> fnc;
if (script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc)) {
-
//if valid rewrite functions to latest
functions.clear();
for (List<String>::Element *E = fnc.front(); E; E = E->next()) {
-
functions.push_back(E->get());
}
}
@@ -130,9 +127,9 @@ Vector<String> ScriptTextEditor::get_functions() {
}
void ScriptTextEditor::apply_code() {
-
- if (script.is_null())
+ if (script.is_null()) {
return;
+ }
script->set_source_code(code_editor->get_text_edit()->get_text());
script->update_exports();
_update_member_keywords();
@@ -165,17 +162,20 @@ void ScriptTextEditor::_update_member_keywords() {
StringName instance_base = script->get_instance_base_type();
- if (instance_base == StringName())
+ if (instance_base == StringName()) {
return;
+ }
List<PropertyInfo> plist;
ClassDB::get_property_list(instance_base, &plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
String name = E->get().name;
- if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP)
+ if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) {
continue;
- if (name.find("/") != -1)
+ }
+ if (name.find("/") != -1) {
continue;
+ }
code_editor->get_text_edit()->add_member_keyword(name, member_variable_color);
}
@@ -184,13 +184,11 @@ void ScriptTextEditor::_update_member_keywords() {
ClassDB::get_integer_constant_list(instance_base, &clist);
for (List<String>::Element *E = clist.front(); E; E = E->next()) {
-
code_editor->get_text_edit()->add_member_keyword(E->get(), member_variable_color);
}
}
void ScriptTextEditor::_load_theme_settings() {
-
TextEdit *text_edit = code_editor->get_text_edit();
text_edit->clear_colors();
@@ -270,14 +268,15 @@ void ScriptTextEditor::_load_theme_settings() {
colors_cache.string_color = string_color;
theme_loaded = true;
- if (!script.is_null())
+ if (!script.is_null()) {
_set_theme_for_script();
+ }
}
void ScriptTextEditor::_set_theme_for_script() {
-
- if (!theme_loaded)
+ if (!theme_loaded) {
return;
+ }
TextEdit *text_edit = code_editor->get_text_edit();
@@ -285,7 +284,6 @@ void ScriptTextEditor::_set_theme_for_script() {
script->get_language()->get_reserved_words(&keywords);
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
-
text_edit->add_keyword_color(E->get(), colors_cache.keyword_color);
}
@@ -327,10 +325,10 @@ void ScriptTextEditor::_set_theme_for_script() {
ClassDB::get_class_list(&types);
for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
-
String n = E->get();
- if (n.begins_with("_"))
+ if (n.begins_with("_")) {
n = n.substr(1, n.length());
+ }
text_edit->add_keyword_color(n, colors_cache.type_color);
}
@@ -341,7 +339,6 @@ void ScriptTextEditor::_set_theme_for_script() {
ScriptServer::get_global_class_list(&global_classes);
for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) {
-
text_edit->add_keyword_color(E->get(), colors_cache.usertype_color);
}
@@ -364,7 +361,6 @@ void ScriptTextEditor::_set_theme_for_script() {
script->get_language()->get_comment_delimiters(&comments);
for (List<String>::Element *E = comments.front(); E; E = E->next()) {
-
String comment = E->get();
String beg = comment.get_slice(" ", 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
@@ -376,7 +372,6 @@ void ScriptTextEditor::_set_theme_for_script() {
List<String> strings;
script->get_language()->get_string_delimiters(&strings);
for (List<String>::Element *E = strings.front(); E; E = E->next()) {
-
String string = E->get();
String beg = string.get_slice(" ", 0);
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
@@ -403,7 +398,6 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) {
}
void ScriptTextEditor::reload_text() {
-
ERR_FAIL_COND(script.is_null());
TextEdit *te = code_editor->get_text_edit();
@@ -424,7 +418,6 @@ void ScriptTextEditor::reload_text() {
}
void ScriptTextEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY:
_load_theme_settings();
@@ -433,7 +426,6 @@ void ScriptTextEditor::_notification(int p_what) {
}
void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray p_args) {
-
String code = code_editor->get_text_edit()->get_text();
int pos = script->get_language()->find_function(p_function, code);
if (pos == -1) {
@@ -455,22 +447,18 @@ bool ScriptTextEditor::show_members_overview() {
}
void ScriptTextEditor::update_settings() {
-
code_editor->update_editor_settings();
}
bool ScriptTextEditor::is_unsaved() {
-
return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version();
}
Variant ScriptTextEditor::get_edit_state() {
-
return code_editor->get_edit_state();
}
void ScriptTextEditor::set_edit_state(const Variant &p_state) {
-
code_editor->set_edit_state(p_state);
Dictionary state = p_state;
@@ -483,47 +471,38 @@ void ScriptTextEditor::set_edit_state(const Variant &p_state) {
}
void ScriptTextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
-
code_editor->convert_case(p_case);
}
void ScriptTextEditor::trim_trailing_whitespace() {
-
code_editor->trim_trailing_whitespace();
}
void ScriptTextEditor::insert_final_newline() {
-
code_editor->insert_final_newline();
}
void ScriptTextEditor::convert_indent_to_spaces() {
-
code_editor->convert_indent_to_spaces();
}
void ScriptTextEditor::convert_indent_to_tabs() {
-
code_editor->convert_indent_to_tabs();
}
void ScriptTextEditor::tag_saved_version() {
-
code_editor->get_text_edit()->tag_saved_version();
}
void ScriptTextEditor::goto_line(int p_line, bool p_with_error) {
-
code_editor->goto_line(p_line);
}
void ScriptTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
-
code_editor->goto_line_selection(p_line, p_begin, p_end);
}
void ScriptTextEditor::goto_line_centered(int p_line) {
-
code_editor->goto_line_centered(p_line);
}
@@ -536,7 +515,6 @@ void ScriptTextEditor::clear_executing_line() {
}
void ScriptTextEditor::ensure_focus() {
-
code_editor->get_text_edit()->grab_focus();
}
@@ -548,16 +526,16 @@ String ScriptTextEditor::get_name() {
if (is_unsaved()) {
name += "(*)";
}
- } else if (script->get_name() != "")
+ } else if (script->get_name() != "") {
name = script->get_name();
- else
+ } else {
name = script->get_class() + "(" + itos(script->get_instance_id()) + ")";
+ }
return name;
}
Ref<Texture2D> ScriptTextEditor::get_theme_icon() {
-
if (get_parent_control() && get_parent_control()->has_theme_icon(script->get_class(), "EditorIcons")) {
return get_parent_control()->get_theme_icon(script->get_class(), "EditorIcons");
}
@@ -566,7 +544,6 @@ Ref<Texture2D> ScriptTextEditor::get_theme_icon() {
}
void ScriptTextEditor::_validate_script() {
-
String errortxt;
int line = -1, col;
TextEdit *te = code_editor->get_text_edit();
@@ -592,7 +569,6 @@ void ScriptTextEditor::_validate_script() {
functions.clear();
for (List<String>::Element *E = fnc.front(); E; E = E->next()) {
-
functions.push_back(E->get());
}
script_is_valid = true;
@@ -633,6 +609,18 @@ void ScriptTextEditor::_validate_script() {
for (List<ScriptLanguage::Warning>::Element *E = warnings.front(); E; E = E->next()) {
ScriptLanguage::Warning w = E->get();
+ Dictionary ignore_meta;
+ ignore_meta["line"] = w.line;
+ ignore_meta["code"] = w.string_code.to_lower();
+ warnings_panel->push_cell();
+ warnings_panel->push_meta(ignore_meta);
+ warnings_panel->push_color(
+ warnings_panel->get_theme_color("accent_color", "Editor").lerp(warnings_panel->get_theme_color("mono_color", "Editor"), 0.5));
+ warnings_panel->add_text(TTR("[Ignore]"));
+ warnings_panel->pop(); // Color.
+ warnings_panel->pop(); // Meta ignore.
+ warnings_panel->pop(); // Cell.
+
warnings_panel->push_cell();
warnings_panel->push_meta(w.line - 1);
warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor"));
@@ -645,15 +633,6 @@ void ScriptTextEditor::_validate_script() {
warnings_panel->push_cell();
warnings_panel->add_text(w.message);
warnings_panel->pop(); // Cell.
-
- Dictionary ignore_meta;
- ignore_meta["line"] = w.line;
- ignore_meta["code"] = w.string_code.to_lower();
- warnings_panel->push_cell();
- warnings_panel->push_meta(ignore_meta);
- warnings_panel->add_text(TTR("(ignore)"));
- warnings_panel->pop(); // Meta ignore.
- warnings_panel->pop(); // Cell.
}
warnings_panel->pop(); // Table.
@@ -682,7 +661,6 @@ void ScriptTextEditor::_validate_script() {
}
void ScriptTextEditor::_update_bookmark_list() {
-
bookmarks_menu->clear();
bookmarks_menu->set_size(Size2(1, 1));
@@ -714,7 +692,6 @@ void ScriptTextEditor::_update_bookmark_list() {
}
void ScriptTextEditor::_bookmark_item_pressed(int p_idx) {
-
if (p_idx < 4) { // Any item before the separator.
_edit_option(bookmarks_menu->get_item_id(p_idx));
} else {
@@ -724,7 +701,6 @@ void ScriptTextEditor::_bookmark_item_pressed(int p_idx) {
}
static Vector<Node *> _find_all_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) {
-
Vector<Node *> nodes;
if (p_current->get_owner() != p_base && p_base != p_current) {
@@ -745,29 +721,32 @@ static Vector<Node *> _find_all_node_for_script(Node *p_base, Node *p_current, c
}
static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) {
-
- if (p_current->get_owner() != p_base && p_base != p_current)
+ if (p_current->get_owner() != p_base && p_base != p_current) {
return nullptr;
+ }
Ref<Script> c = p_current->get_script();
- if (c == p_script)
+ if (c == p_script) {
return p_current;
+ }
for (int i = 0; i < p_current->get_child_count(); i++) {
Node *found = _find_node_for_script(p_base, p_current->get_child(i), p_script);
- if (found)
+ if (found) {
return found;
+ }
}
return nullptr;
}
static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) {
-
- if (p_current->get_owner() != p_base && p_base != p_current)
+ if (p_current->get_owner() != p_base && p_base != p_current) {
return;
+ }
Ref<Script> c = p_current->get_script();
- if (c.is_valid())
+ if (c.is_valid()) {
r_scripts.insert(c);
+ }
for (int i = 0; i < p_current->get_child_count(); i++) {
_find_changed_scripts_for_external_editor(p_base, p_current->get_child(i), r_scripts);
@@ -775,9 +754,9 @@ static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_curr
}
void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_for_script) {
-
- if (!bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")))
+ if (!bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
return;
+ }
ERR_FAIL_COND(!get_tree());
@@ -789,14 +768,13 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
}
for (Set<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) {
-
Ref<Script> script = E->get();
- if (p_for_script.is_valid() && p_for_script != script)
+ if (p_for_script.is_valid() && p_for_script != script) {
continue;
+ }
if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
-
continue; //internal script, who cares, though weird
}
@@ -804,7 +782,6 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
uint64_t date = FileAccess::get_modified_time(script->get_path());
if (last_date != date) {
-
Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
ERR_CONTINUE(!rel_script.is_valid());
script->set_source_code(rel_script->get_source_code());
@@ -815,15 +792,14 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
}
void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) {
-
ScriptTextEditor *ste = (ScriptTextEditor *)p_ud;
ste->_code_complete_script(p_code, r_options, r_force);
}
void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) {
-
- if (color_panel->is_visible())
+ if (color_panel->is_visible()) {
return;
+ }
Node *base = get_tree()->get_edited_scene_root();
if (base) {
base = _find_node_for_script(base, base, script);
@@ -836,7 +812,6 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
}
void ScriptTextEditor::_update_breakpoint_list() {
-
breakpoints_menu->clear();
breakpoints_menu->set_size(Size2(1, 1));
@@ -868,7 +843,6 @@ void ScriptTextEditor::_update_breakpoint_list() {
}
void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
-
if (p_idx < 4) { // Any item before the separator.
_edit_option(breakpoints_menu->get_item_id(p_idx));
} else {
@@ -878,12 +852,10 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
}
void ScriptTextEditor::_breakpoint_toggled(int p_row) {
-
EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row));
}
void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) {
-
Node *base = get_tree()->get_edited_scene_root();
if (base) {
base = _find_node_for_script(base, base, script);
@@ -903,14 +875,12 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
} else if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) {
-
_goto_line(p_row);
result.class_name = result.class_name.trim_prefix("_");
switch (result.type) {
case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: {
-
if (result.script.is_valid()) {
emit_signal("request_open_script_at_line", result.script, result.location - 1);
} else {
@@ -922,7 +892,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
emit_signal("go_to_help", "class_name:" + result.class_name);
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: {
-
StringName cname = result.class_name;
bool success;
while (true) {
@@ -943,7 +912,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: {
-
StringName cname = result.class_name;
while (true) {
@@ -959,7 +927,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS_ENUM: {
-
StringName cname = result.class_name;
StringName success;
while (true) {
@@ -1003,7 +970,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
-
TextEdit *text_edit = code_editor->get_text_edit();
Node *base = get_tree()->get_edited_scene_root();
@@ -1015,7 +981,6 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK || ProjectSettings::get_singleton()->has_setting("autoload/" + p_symbol)) {
text_edit->set_highlighted_word(p_symbol);
} else if (p_symbol.is_rel_path()) {
-
String path = _get_absolute_path(p_symbol);
if (FileAccess::exists(path)) {
text_edit->set_highlighted_word(p_symbol);
@@ -1124,101 +1089,85 @@ void ScriptTextEditor::_lookup_connections(int p_row, String p_method) {
}
void ScriptTextEditor::_edit_option(int p_op) {
-
TextEdit *tx = code_editor->get_text_edit();
switch (p_op) {
case EDIT_UNDO: {
-
tx->undo();
tx->call_deferred("grab_focus");
} break;
case EDIT_REDO: {
-
tx->redo();
tx->call_deferred("grab_focus");
} break;
case EDIT_CUT: {
-
tx->cut();
tx->call_deferred("grab_focus");
} break;
case EDIT_COPY: {
-
tx->copy();
tx->call_deferred("grab_focus");
} break;
case EDIT_PASTE: {
-
tx->paste();
tx->call_deferred("grab_focus");
} break;
case EDIT_SELECT_ALL: {
-
tx->select_all();
tx->call_deferred("grab_focus");
} break;
case EDIT_MOVE_LINE_UP: {
-
code_editor->move_lines_up();
} break;
case EDIT_MOVE_LINE_DOWN: {
-
code_editor->move_lines_down();
} break;
case EDIT_INDENT_LEFT: {
-
Ref<Script> scr = script;
- if (scr.is_null())
+ if (scr.is_null()) {
return;
+ }
tx->indent_left();
} break;
case EDIT_INDENT_RIGHT: {
-
Ref<Script> scr = script;
- if (scr.is_null())
+ if (scr.is_null()) {
return;
+ }
tx->indent_right();
} break;
case EDIT_DELETE_LINE: {
-
code_editor->delete_lines();
} break;
case EDIT_CLONE_DOWN: {
-
code_editor->clone_lines_down();
} break;
case EDIT_TOGGLE_FOLD_LINE: {
-
tx->toggle_fold_line(tx->cursor_get_line());
tx->update();
} break;
case EDIT_FOLD_ALL_LINES: {
-
tx->fold_all_lines();
tx->update();
} break;
case EDIT_UNFOLD_ALL_LINES: {
-
tx->unhide_all_lines();
tx->update();
} break;
case EDIT_TOGGLE_COMMENT: {
-
_edit_option_toggle_inline_comment();
} break;
case EDIT_COMPLETE: {
-
tx->query_code_comple();
} break;
case EDIT_AUTO_INDENT: {
-
String text = tx->get_text();
Ref<Script> scr = script;
- if (scr.is_null())
+ if (scr.is_null()) {
return;
+ }
tx->begin_complex_operation();
int begin, end;
@@ -1242,35 +1191,27 @@ void ScriptTextEditor::_edit_option(int p_op) {
tx->end_complex_operation();
} break;
case EDIT_TRIM_TRAILING_WHITESAPCE: {
-
trim_trailing_whitespace();
} break;
case EDIT_CONVERT_INDENT_TO_SPACES: {
-
convert_indent_to_spaces();
} break;
case EDIT_CONVERT_INDENT_TO_TABS: {
-
convert_indent_to_tabs();
} break;
case EDIT_PICK_COLOR: {
-
color_panel->popup();
} break;
case EDIT_TO_UPPERCASE: {
-
_convert_case(CodeTextEditor::UPPER);
} break;
case EDIT_TO_LOWERCASE: {
-
_convert_case(CodeTextEditor::LOWER);
} break;
case EDIT_CAPITALIZE: {
-
_convert_case(CodeTextEditor::CAPITALIZE);
} break;
case EDIT_EVALUATE: {
-
Expression expression;
Vector<String> lines = code_editor->get_text_edit()->get_selection_text().split("\n");
PackedStringArray results;
@@ -1296,23 +1237,18 @@ void ScriptTextEditor::_edit_option(int p_op) {
code_editor->get_text_edit()->end_complex_operation();
} break;
case SEARCH_FIND: {
-
code_editor->get_find_replace_bar()->popup_search();
} break;
case SEARCH_FIND_NEXT: {
-
code_editor->get_find_replace_bar()->search_next();
} break;
case SEARCH_FIND_PREV: {
-
code_editor->get_find_replace_bar()->search_prev();
} break;
case SEARCH_REPLACE: {
-
code_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_IN_FILES: {
-
String selected_text = code_editor->get_text_edit()->get_selection_text();
// Yep, because it doesn't make sense to instance this dialog for every single script open...
@@ -1320,45 +1256,36 @@ void ScriptTextEditor::_edit_option(int p_op) {
emit_signal("search_in_files_requested", selected_text);
} break;
case REPLACE_IN_FILES: {
-
String selected_text = code_editor->get_text_edit()->get_selection_text();
emit_signal("replace_in_files_requested", selected_text);
} break;
case SEARCH_LOCATE_FUNCTION: {
-
quick_open->popup_dialog(get_functions());
quick_open->set_title(TTR("Go to Function"));
} break;
case SEARCH_GOTO_LINE: {
-
goto_line_dialog->popup_find_line(tx);
} break;
case BOOKMARK_TOGGLE: {
-
code_editor->toggle_bookmark();
} break;
case BOOKMARK_GOTO_NEXT: {
-
code_editor->goto_next_bookmark();
} break;
case BOOKMARK_GOTO_PREV: {
-
code_editor->goto_prev_bookmark();
} break;
case BOOKMARK_REMOVE_ALL: {
-
code_editor->remove_all_bookmarks();
} break;
case DEBUG_TOGGLE_BREAKPOINT: {
-
int line = tx->cursor_get_line();
bool dobreak = !tx->is_line_set_as_breakpoint(line);
tx->set_line_as_breakpoint(line, dobreak);
EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak);
} break;
case DEBUG_REMOVE_ALL_BREAKPOINTS: {
-
List<int> bpoints;
tx->get_breakpoints(&bpoints);
@@ -1370,7 +1297,6 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
} break;
case DEBUG_GOTO_NEXT_BREAKPOINT: {
-
List<int> bpoints;
tx->get_breakpoints(&bpoints);
if (bpoints.size() <= 0) {
@@ -1398,7 +1324,6 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case DEBUG_GOTO_PREV_BREAKPOINT: {
-
List<int> bpoints;
tx->get_breakpoints(&bpoints);
if (bpoints.size() <= 0) {
@@ -1425,19 +1350,19 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case HELP_CONTEXTUAL: {
-
String text = tx->get_selection_text();
- if (text == "")
+ if (text == "") {
text = tx->get_word_under_cursor();
+ }
if (text != "") {
emit_signal("request_help", text);
}
} break;
case LOOKUP_SYMBOL: {
-
String text = tx->get_word_under_cursor();
- if (text == "")
+ if (text == "") {
text = tx->get_selection_text();
+ }
if (text != "") {
_lookup_symbol(text, tx->cursor_get_line(), tx->cursor_get_column());
}
@@ -1446,8 +1371,9 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
void ScriptTextEditor::_edit_option_toggle_inline_comment() {
- if (script.is_null())
+ if (script.is_null()) {
return;
+ }
String delimiter = "#";
List<String> comment_delimiters;
@@ -1472,10 +1398,11 @@ void ScriptTextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter)
void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
TextEdit *te = code_editor->get_text_edit();
te->_set_syntax_highlighting(p_highlighter);
- if (p_highlighter != nullptr)
+ if (p_highlighter != nullptr) {
highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true);
- else
+ } else {
highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(TTR("Standard")), true);
+ }
}
void ScriptTextEditor::_change_syntax_highlighter(int p_idx) {
@@ -1489,7 +1416,6 @@ void ScriptTextEditor::_change_syntax_highlighter(int p_idx) {
}
void ScriptTextEditor::_bind_methods() {
-
ClassDB::bind_method("_update_connected_methods", &ScriptTextEditor::_update_connected_methods);
ClassDB::bind_method("get_drag_data_fw", &ScriptTextEditor::get_drag_data_fw);
@@ -1498,7 +1424,6 @@ void ScriptTextEditor::_bind_methods() {
}
Control *ScriptTextEditor::get_edit_menu() {
-
return edit_hb;
}
@@ -1507,11 +1432,11 @@ void ScriptTextEditor::clear_edit_menu() {
}
void ScriptTextEditor::reload(bool p_soft) {
-
TextEdit *te = code_editor->get_text_edit();
Ref<Script> scr = script;
- if (scr.is_null())
+ if (scr.is_null()) {
return;
+ }
scr->set_source_code(te->get_text());
bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; //always soft-reload editor plugins
@@ -1519,12 +1444,10 @@ void ScriptTextEditor::reload(bool p_soft) {
}
void ScriptTextEditor::get_breakpoints(List<int> *p_breakpoints) {
-
code_editor->get_text_edit()->get_breakpoints(p_breakpoints);
}
void ScriptTextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
-
code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
}
@@ -1532,18 +1455,15 @@ void ScriptTextEditor::set_debugger_active(bool p_active) {
}
Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
return Variant();
}
bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
if (d.has("type") && (String(d["type"]) == "resource" ||
String(d["type"]) == "files" ||
String(d["type"]) == "nodes" ||
String(d["type"]) == "files_and_dirs")) {
-
return true;
}
@@ -1551,26 +1471,27 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_
}
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
- if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
+ if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
return nullptr;
+ }
Ref<Script> scr = p_current_node->get_script();
- if (scr.is_valid() && scr == script)
+ if (scr.is_valid() && scr == script) {
return p_current_node;
+ }
for (int i = 0; i < p_current_node->get_child_count(); i++) {
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
- if (n)
+ if (n) {
return n;
+ }
}
return nullptr;
}
void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
Dictionary d = p_data;
TextEdit *te = code_editor->get_text_edit();
@@ -1578,7 +1499,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
te->_get_mouse_pos(p_point, row, col);
if (d.has("type") && String(d["type"]) == "resource") {
-
Ref<Resource> res = d["resource"];
if (!res.is_valid()) {
return;
@@ -1595,14 +1515,13 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) {
-
Array files = d["files"];
String text_to_drop;
for (int i = 0; i < files.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
text_to_drop += ",";
+ }
text_to_drop += "\"" + String(files[i]).c_escape() + "\"";
}
@@ -1612,7 +1531,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && String(d["type"]) == "nodes") {
-
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn) {
@@ -1623,9 +1541,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
Array nodes = d["nodes"];
String text_to_drop;
for (int i = 0; i < nodes.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
text_to_drop += ",";
+ }
NodePath np = nodes[i];
Node *node = get_node(np);
@@ -1644,7 +1562,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
-
Ref<InputEventMouseButton> mb = ev;
Ref<InputEventKey> k = ev;
Point2 local_pos;
@@ -1683,10 +1600,12 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
String word_at_pos = tx->get_word_at_pos(local_pos);
- if (word_at_pos == "")
+ if (word_at_pos == "") {
word_at_pos = tx->get_word_under_cursor();
- if (word_at_pos == "")
+ }
+ if (word_at_pos == "") {
word_at_pos = tx->get_selection_text();
+ }
bool has_color = (word_at_pos == "Color");
bool foldable = tx->can_fold(row) || tx->is_folded(row);
@@ -1763,7 +1682,6 @@ void ScriptTextEditor::_color_changed(const Color &p_color) {
}
void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos) {
-
context_menu->clear();
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
@@ -1788,15 +1706,18 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_lowercase"), EDIT_TO_LOWERCASE);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/evaluate_selection"), EDIT_EVALUATE);
}
- if (p_foldable)
+ if (p_foldable) {
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE);
+ }
if (p_color || p_open_docs || p_goto_definition) {
context_menu->add_separator();
- if (p_open_docs)
+ if (p_open_docs) {
context_menu->add_item(TTR("Lookup Symbol"), LOOKUP_SYMBOL);
- if (p_color)
+ }
+ if (p_color) {
context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR);
+ }
}
context_menu->set_position(get_global_transform().xform(p_pos));
@@ -1805,7 +1726,6 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p
}
ScriptTextEditor::ScriptTextEditor() {
-
theme_loaded = false;
script_is_valid = false;
@@ -1830,6 +1750,8 @@ ScriptTextEditor::ScriptTextEditor() {
warnings_panel = memnew(RichTextLabel);
editor_box->add_child(warnings_panel);
+ warnings_panel->add_theme_font_override(
+ "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts"));
warnings_panel->set_custom_minimum_size(Size2(0, 100 * EDSCALE));
warnings_panel->set_h_size_flags(SIZE_EXPAND_FILL);
warnings_panel->set_meta_underline(true);
@@ -1864,10 +1786,11 @@ ScriptTextEditor::ScriptTextEditor() {
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
- if (default_color_mode == 1)
+ if (default_color_mode == 1) {
color_picker->set_hsv_mode(true);
- else if (default_color_mode == 2)
+ } else if (default_color_mode == 2) {
color_picker->set_raw_mode(true);
+ }
edit_hb = memnew(HBoxContainer);
@@ -1988,7 +1911,6 @@ ScriptTextEditor::~ScriptTextEditor() {
}
static ScriptEditorBase *create_editor(const RES &p_resource) {
-
if (Object::cast_to<Script>(*p_resource)) {
return memnew(ScriptTextEditor);
}
@@ -1996,7 +1918,6 @@ static ScriptEditorBase *create_editor(const RES &p_resource) {
}
void ScriptTextEditor::register_editor() {
-
ED_SHORTCUT("script_text_editor/undo", TTR("Undo"), KEY_MASK_CMD | KEY_Z);
ED_SHORTCUT("script_text_editor/redo", TTR("Redo"), KEY_MASK_CMD | KEY_Y);
ED_SHORTCUT("script_text_editor/cut", TTR("Cut"), KEY_MASK_CMD | KEY_X);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index a0dfba6cc8..adcd0218bc 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -37,7 +37,6 @@
#include "script_editor_plugin.h"
class ConnectionInfoDialog : public AcceptDialog {
-
GDCLASS(ConnectionInfoDialog, AcceptDialog);
Label *method;
@@ -52,7 +51,6 @@ public:
};
class ScriptTextEditor : public ScriptEditorBase {
-
GDCLASS(ScriptTextEditor, ScriptEditorBase);
CodeTextEditor *code_editor;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 9ef8148241..0c3a44e4cd 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -44,11 +44,10 @@
/*** SHADER SCRIPT EDITOR ****/
Ref<Shader> ShaderTextEditor::get_edited_shader() const {
-
return shader;
}
-void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
+void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
if (shader == p_shader) {
return;
}
@@ -84,7 +83,6 @@ void ShaderTextEditor::reload_text() {
}
void ShaderTextEditor::_load_theme_settings() {
-
get_text_edit()->clear_colors();
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
@@ -149,22 +147,18 @@ void ShaderTextEditor::_load_theme_settings() {
ShaderLanguage::get_keyword_list(&keywords);
if (shader.is_valid()) {
-
for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) {
-
for (const Map<StringName, ShaderLanguage::BuiltInInfo>::Element *F = E->get().built_ins.front(); F; F = F->next()) {
keywords.push_back(F->key());
}
}
for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())).size(); i++) {
-
keywords.push_back(ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()))[i]);
}
}
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
-
get_text_edit()->add_keyword_color(E->get(), keyword_color);
}
@@ -174,7 +168,6 @@ void ShaderTextEditor::_load_theme_settings() {
}
void ShaderTextEditor::_check_shader_mode() {
-
String type = ShaderLanguage::get_shader_type(get_text_edit()->get_text());
Shader::Mode mode;
@@ -194,13 +187,11 @@ void ShaderTextEditor::_check_shader_mode() {
}
static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
-
RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
return RS::global_variable_type_get_shader_datatype(gvt);
}
void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) {
-
_check_shader_mode();
ShaderLanguage sl;
@@ -212,7 +203,6 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
}
void ShaderTextEditor::_validate_script() {
-
_check_shader_mode();
String code = get_text_edit()->get_text();
@@ -227,13 +217,15 @@ void ShaderTextEditor::_validate_script() {
String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
set_error(error_text);
set_error_pos(sl.get_error_line() - 1, 0);
- for (int i = 0; i < get_text_edit()->get_line_count(); i++)
+ for (int i = 0; i < get_text_edit()->get_line_count(); i++) {
get_text_edit()->set_line_as_marked(i, false);
+ }
get_text_edit()->set_line_as_marked(sl.get_error_line() - 1, true);
} else {
- for (int i = 0; i < get_text_edit()->get_line_count(); i++)
+ for (int i = 0; i < get_text_edit()->get_line_count(); i++) {
get_text_edit()->set_line_as_marked(i, false);
+ }
set_error("");
}
@@ -249,7 +241,6 @@ ShaderTextEditor::ShaderTextEditor() {
/*** SCRIPT EDITOR ******/
void ShaderEditor::_menu_option(int p_option) {
-
switch (p_option) {
case EDIT_UNDO: {
shader_editor->get_text_edit()->undo();
@@ -276,18 +267,18 @@ void ShaderEditor::_menu_option(int p_option) {
shader_editor->move_lines_down();
} break;
case EDIT_INDENT_LEFT: {
-
- if (shader.is_null())
+ if (shader.is_null()) {
return;
+ }
TextEdit *tx = shader_editor->get_text_edit();
tx->indent_left();
} break;
case EDIT_INDENT_RIGHT: {
-
- if (shader.is_null())
+ if (shader.is_null()) {
return;
+ }
TextEdit *tx = shader_editor->get_text_edit();
tx->indent_right();
@@ -300,51 +291,41 @@ void ShaderEditor::_menu_option(int p_option) {
shader_editor->clone_lines_down();
} break;
case EDIT_TOGGLE_COMMENT: {
-
- if (shader.is_null())
+ if (shader.is_null()) {
return;
+ }
shader_editor->toggle_inline_comment("//");
} break;
case EDIT_COMPLETE: {
-
shader_editor->get_text_edit()->query_code_comple();
} break;
case SEARCH_FIND: {
-
shader_editor->get_find_replace_bar()->popup_search();
} break;
case SEARCH_FIND_NEXT: {
-
shader_editor->get_find_replace_bar()->search_next();
} break;
case SEARCH_FIND_PREV: {
-
shader_editor->get_find_replace_bar()->search_prev();
} break;
case SEARCH_REPLACE: {
-
shader_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_GOTO_LINE: {
-
goto_line_dialog->popup_find_line(shader_editor->get_text_edit());
} break;
case BOOKMARK_TOGGLE: {
-
shader_editor->toggle_bookmark();
} break;
case BOOKMARK_GOTO_NEXT: {
-
shader_editor->goto_next_bookmark();
} break;
case BOOKMARK_GOTO_PREV: {
-
shader_editor->goto_prev_bookmark();
} break;
case BOOKMARK_REMOVE_ALL: {
-
shader_editor->remove_all_bookmarks();
} break;
case HELP_DOCS: {
@@ -357,19 +338,16 @@ void ShaderEditor::_menu_option(int p_option) {
}
void ShaderEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_WM_FOCUS_IN) {
_check_for_external_edit();
}
}
void ShaderEditor::_params_changed() {
-
shader_editor->_validate_script();
}
void ShaderEditor::_editor_settings_changed() {
-
shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
shader_editor->get_text_edit()->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size"));
@@ -396,12 +374,10 @@ void ShaderEditor::_editor_settings_changed() {
}
void ShaderEditor::_bind_methods() {
-
ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed);
}
void ShaderEditor::ensure_select_current() {
-
/*
if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) {
@@ -414,12 +390,10 @@ void ShaderEditor::ensure_select_current() {
}
void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
-
shader_editor->goto_line_selection(p_line, p_begin, p_end);
}
void ShaderEditor::_check_for_external_edit() {
-
if (shader.is_null() || !shader.is_valid()) {
return;
}
@@ -440,7 +414,6 @@ void ShaderEditor::_check_for_external_edit() {
}
void ShaderEditor::_reload_shader_from_disk() {
-
Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), true);
ERR_FAIL_COND(!rel_shader.is_valid());
@@ -450,12 +423,13 @@ void ShaderEditor::_reload_shader_from_disk() {
}
void ShaderEditor::edit(const Ref<Shader> &p_shader) {
-
- if (p_shader.is_null() || !p_shader->is_text_shader())
+ if (p_shader.is_null() || !p_shader->is_text_shader()) {
return;
+ }
- if (shader == p_shader)
+ if (shader == p_shader) {
return;
+ }
shader = p_shader;
@@ -466,7 +440,6 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) {
}
void ShaderEditor::save_external_data(const String &p_str) {
-
if (shader.is_null()) {
disk_changed->hide();
return;
@@ -482,7 +455,6 @@ void ShaderEditor::save_external_data(const String &p_str) {
}
void ShaderEditor::apply_shaders() {
-
if (shader.is_valid()) {
String shader_code = shader->get_code();
String editor_code = shader_editor->get_text_edit()->get_text();
@@ -494,13 +466,10 @@ void ShaderEditor::apply_shaders() {
}
void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
-
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
-
int col, row;
TextEdit *tx = shader_editor->get_text_edit();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
@@ -508,7 +477,6 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (tx->is_right_click_moving_caret()) {
if (tx->is_selection_active()) {
-
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
int from_column = tx->get_selection_from_column();
@@ -537,7 +505,6 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
void ShaderEditor::_update_bookmark_list() {
-
bookmarks_menu->clear();
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
@@ -565,7 +532,6 @@ void ShaderEditor::_update_bookmark_list() {
}
void ShaderEditor::_bookmark_item_pressed(int p_idx) {
-
if (p_idx < 4) { // Any item before the separator.
_menu_option(bookmarks_menu->get_item_id(p_idx));
} else {
@@ -574,7 +540,6 @@ void ShaderEditor::_bookmark_item_pressed(int p_idx) {
}
void ShaderEditor::_make_context_menu(bool p_selection, Vector2 p_position) {
-
context_menu->clear();
if (p_selection) {
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT);
@@ -599,7 +564,6 @@ void ShaderEditor::_make_context_menu(bool p_selection, Vector2 p_position) {
}
ShaderEditor::ShaderEditor(EditorNode *p_node) {
-
shader_editor = memnew(ShaderTextEditor);
shader_editor->set_v_size_flags(SIZE_EXPAND_FILL);
shader_editor->add_theme_constant_override("separation", 0);
@@ -714,49 +678,42 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
}
void ShaderEditorPlugin::edit(Object *p_object) {
-
Shader *s = Object::cast_to<Shader>(p_object);
shader_editor->edit(s);
}
bool ShaderEditorPlugin::handles(Object *p_object) const {
-
Shader *shader = Object::cast_to<Shader>(p_object);
return shader != nullptr && shader->is_text_shader();
}
void ShaderEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
button->show();
editor->make_bottom_panel_item_visible(shader_editor);
} else {
-
button->hide();
- if (shader_editor->is_visible_in_tree())
+ if (shader_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
shader_editor->apply_shaders();
}
}
void ShaderEditorPlugin::selected_notify() {
-
shader_editor->ensure_select_current();
}
void ShaderEditorPlugin::save_external_data() {
-
shader_editor->save_external_data();
}
void ShaderEditorPlugin::apply_changes() {
-
shader_editor->apply_shaders();
}
ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
shader_editor = memnew(ShaderEditor(p_node));
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index f02ed590fc..0208b43e13 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -42,7 +42,6 @@
#include "servers/rendering/shader_language.h"
class ShaderTextEditor : public CodeTextEditor {
-
GDCLASS(ShaderTextEditor, CodeTextEditor);
Ref<Shader> shader;
@@ -66,7 +65,6 @@ public:
};
class ShaderEditor : public PanelContainer {
-
GDCLASS(ShaderEditor, PanelContainer);
enum {
@@ -143,7 +141,6 @@ public:
};
class ShaderEditorPlugin : public EditorPlugin {
-
GDCLASS(ShaderEditorPlugin, EditorPlugin);
bool _2d;
diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp
index 9d5ffd6516..0ac29f68f6 100644
--- a/editor/plugins/shader_file_editor_plugin.cpp
+++ b/editor/plugins/shader_file_editor_plugin.cpp
@@ -49,7 +49,6 @@ void ShaderFileEditor::_update_version(const StringName &p_version_txt, const RD
}
void ShaderFileEditor::_version_selected(int p_option) {
-
int c = versions->get_current();
StringName version_txt = versions->get_item_metadata(c);
@@ -106,7 +105,6 @@ void ShaderFileEditor::_version_selected(int p_option) {
}
void ShaderFileEditor::_update_options() {
-
ERR_FAIL_COND(shader_file.is_null());
if (shader_file->get_base_error() != String()) {
@@ -202,7 +200,6 @@ void ShaderFileEditor::_update_options() {
}
void ShaderFileEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_WM_FOCUS_IN) {
if (is_visible_in_tree() && shader_file.is_valid()) {
_update_options();
@@ -211,7 +208,6 @@ void ShaderFileEditor::_notification(int p_what) {
}
void ShaderFileEditor::_editor_settings_changed() {
-
if (is_visible_in_tree() && shader_file.is_valid()) {
_update_options();
}
@@ -221,7 +217,6 @@ void ShaderFileEditor::_bind_methods() {
}
void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) {
-
if (p_shader.is_null()) {
if (shader_file.is_valid()) {
shader_file->disconnect("changed", callable_mp(this, &ShaderFileEditor::_shader_changed));
@@ -229,8 +224,9 @@ void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) {
return;
}
- if (shader_file == p_shader)
+ if (shader_file == p_shader) {
return;
+ }
shader_file = p_shader;
@@ -242,7 +238,6 @@ void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) {
}
void ShaderFileEditor::_shader_changed() {
-
if (is_visible_in_tree()) {
_update_options();
}
@@ -294,33 +289,29 @@ ShaderFileEditor::ShaderFileEditor(EditorNode *p_node) {
}
void ShaderFileEditorPlugin::edit(Object *p_object) {
-
RDShaderFile *s = Object::cast_to<RDShaderFile>(p_object);
shader_editor->edit(s);
}
bool ShaderFileEditorPlugin::handles(Object *p_object) const {
-
RDShaderFile *shader = Object::cast_to<RDShaderFile>(p_object);
return shader != nullptr;
}
void ShaderFileEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
button->show();
editor->make_bottom_panel_item_visible(shader_editor);
} else {
-
button->hide();
- if (shader_editor->is_visible_in_tree())
+ if (shader_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
}
}
ShaderFileEditorPlugin::ShaderFileEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
shader_editor = memnew(ShaderFileEditor(p_node));
diff --git a/editor/plugins/shader_file_editor_plugin.h b/editor/plugins/shader_file_editor_plugin.h
index 7df177a0d5..19617366b2 100644
--- a/editor/plugins/shader_file_editor_plugin.h
+++ b/editor/plugins/shader_file_editor_plugin.h
@@ -42,7 +42,6 @@
#include "servers/rendering/rendering_device_binds.h"
class ShaderFileEditor : public PanelContainer {
-
GDCLASS(ShaderFileEditor, PanelContainer);
Ref<RDShaderFile> shader_file;
@@ -71,7 +70,6 @@ public:
};
class ShaderFileEditorPlugin : public EditorPlugin {
-
GDCLASS(ShaderFileEditorPlugin, EditorPlugin);
ShaderFileEditor *shader_editor;
diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp
index c81d3f787e..a198e4ff8f 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_2d_editor_plugin.cpp
@@ -36,7 +36,6 @@
#include "thirdparty/misc/clipper.hpp"
void Skeleton2DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
options->hide();
@@ -44,19 +43,16 @@ void Skeleton2DEditor::_node_removed(Node *p_node) {
}
void Skeleton2DEditor::edit(Skeleton2D *p_sprite) {
-
node = p_sprite;
}
void Skeleton2DEditor::_menu_option(int p_option) {
-
if (!node) {
return;
}
switch (p_option) {
case MENU_OPTION_MAKE_REST: {
-
if (node->get_bone_count() == 0) {
err_dialog->set_text(TTR("This skeleton has no bones, create some children Bone2D nodes."));
err_dialog->popup_centered();
@@ -95,7 +91,6 @@ void Skeleton2DEditor::_bind_methods() {
}
Skeleton2DEditor::Skeleton2DEditor() {
-
options = memnew(MenuButton);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
@@ -115,28 +110,23 @@ Skeleton2DEditor::Skeleton2DEditor() {
}
void Skeleton2DEditorPlugin::edit(Object *p_object) {
-
sprite_editor->edit(Object::cast_to<Skeleton2D>(p_object));
}
bool Skeleton2DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("Skeleton2D");
}
void Skeleton2DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
sprite_editor->options->show();
} else {
-
sprite_editor->options->hide();
sprite_editor->edit(nullptr);
}
}
Skeleton2DEditorPlugin::Skeleton2DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
sprite_editor = memnew(Skeleton2DEditor);
editor->get_viewport()->add_child(sprite_editor);
diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/editor/plugins/skeleton_2d_editor_plugin.h
index ebc6746b81..f1ba1a3612 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.h
+++ b/editor/plugins/skeleton_2d_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/gui/spin_box.h"
class Skeleton2DEditor : public Control {
-
GDCLASS(Skeleton2DEditor, Control);
enum Menu {
@@ -65,7 +64,6 @@ public:
};
class Skeleton2DEditorPlugin : public EditorPlugin {
-
GDCLASS(Skeleton2DEditorPlugin, EditorPlugin);
Skeleton2DEditor *sprite_editor;
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index fac4cb19d8..52da8dea19 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -30,13 +30,289 @@
#include "skeleton_3d_editor_plugin.h"
+#include "core/io/resource_saver.h"
+#include "editor/editor_file_dialog.h"
+#include "editor/editor_properties.h"
+#include "editor/editor_scale.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/3d/physics_joint_3d.h"
#include "scene/resources/capsule_shape_3d.h"
#include "scene/resources/sphere_shape_3d.h"
+void BoneTransformEditor::create_editors() {
+ const Color section_color = get_theme_color("prop_subsection", "Editor");
+
+ section = memnew(EditorInspectorSection);
+ section->setup("trf_properties", label, this, section_color, true);
+ add_child(section);
+
+ key_button = memnew(Button);
+ key_button->set_text(TTR("Key Transform"));
+ key_button->set_visible(keyable);
+ key_button->set_icon(get_theme_icon("Key", "EditorIcons"));
+ key_button->set_flat(true);
+ section->get_vbox()->add_child(key_button);
+
+ enabled_checkbox = memnew(CheckBox(TTR("Pose Enabled")));
+ enabled_checkbox->set_flat(true);
+ enabled_checkbox->set_visible(toggle_enabled);
+ section->get_vbox()->add_child(enabled_checkbox);
+
+ // Translation property
+ translation_property = memnew(EditorPropertyVector3());
+ translation_property->setup(-10000, 10000, 0.001f, true);
+ translation_property->set_label("Translation");
+ translation_property->set_use_folding(true);
+ translation_property->set_read_only(false);
+ translation_property->connect("property_changed", callable_mp(this, &BoneTransformEditor::_value_changed_vector3));
+ section->get_vbox()->add_child(translation_property);
+
+ // Rotation property
+ rotation_property = memnew(EditorPropertyVector3());
+ rotation_property->setup(-10000, 10000, 0.001f, true);
+ rotation_property->set_label("Rotation Degrees");
+ rotation_property->set_use_folding(true);
+ rotation_property->set_read_only(false);
+ rotation_property->connect("property_changed", callable_mp(this, &BoneTransformEditor::_value_changed_vector3));
+ section->get_vbox()->add_child(rotation_property);
+
+ // Scale property
+ scale_property = memnew(EditorPropertyVector3());
+ scale_property->setup(-10000, 10000, 0.001f, true);
+ scale_property->set_label("Scale");
+ scale_property->set_use_folding(true);
+ scale_property->set_read_only(false);
+ scale_property->connect("property_changed", callable_mp(this, &BoneTransformEditor::_value_changed_vector3));
+ section->get_vbox()->add_child(scale_property);
+
+ // Transform/Matrix section
+ transform_section = memnew(EditorInspectorSection);
+ transform_section->setup("trf_properties_transform", "Matrix", this, section_color, true);
+ section->get_vbox()->add_child(transform_section);
+
+ // Transform/Matrix property
+ transform_property = memnew(EditorPropertyTransform());
+ transform_property->setup(-10000, 10000, 0.001f, true);
+ transform_property->set_label("Transform");
+ transform_property->set_use_folding(true);
+ transform_property->set_read_only(false);
+ transform_property->connect("property_changed", callable_mp(this, &BoneTransformEditor::_value_changed_transform));
+ transform_section->get_vbox()->add_child(transform_property);
+}
+
+void BoneTransformEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ create_editors();
+ key_button->connect("pressed", callable_mp(this, &BoneTransformEditor::_key_button_pressed));
+ enabled_checkbox->connect("toggled", callable_mp(this, &BoneTransformEditor::_checkbox_toggled));
+ [[fallthrough]];
+ }
+ case NOTIFICATION_SORT_CHILDREN: {
+ const Ref<Font> font = get_theme_font("font", "Tree");
+
+ Point2 buffer;
+ buffer.x += get_theme_constant("inspector_margin", "Editor");
+ buffer.y += font->get_height();
+ buffer.y += get_theme_constant("vseparation", "Tree");
+
+ const float vector_height = translation_property->get_size().y;
+ const float transform_height = transform_property->get_size().y;
+ const float button_height = key_button->get_size().y;
+
+ const float width = get_size().x - get_theme_constant("inspector_margin", "Editor");
+ Vector<Rect2> input_rects;
+ if (keyable && section->get_vbox()->is_visible()) {
+ input_rects.push_back(Rect2(key_button->get_position() + buffer, Size2(width, button_height)));
+ } else {
+ input_rects.push_back(Rect2(0, 0, 0, 0));
+ }
+
+ if (section->get_vbox()->is_visible()) {
+ input_rects.push_back(Rect2(translation_property->get_position() + buffer, Size2(width, vector_height)));
+ input_rects.push_back(Rect2(rotation_property->get_position() + buffer, Size2(width, vector_height)));
+ input_rects.push_back(Rect2(scale_property->get_position() + buffer, Size2(width, vector_height)));
+ input_rects.push_back(Rect2(transform_property->get_position() + buffer, Size2(width, transform_height)));
+ } else {
+ const int32_t start = input_rects.size();
+ const int32_t empty_input_rect_elements = 4;
+ const int32_t end = start + empty_input_rect_elements;
+ for (int i = start; i < end; ++i) {
+ input_rects.push_back(Rect2(0, 0, 0, 0));
+ }
+ }
+
+ for (int32_t i = 0; i < input_rects.size(); i++) {
+ background_rects[i] = input_rects[i];
+ }
+
+ update();
+ break;
+ }
+ case NOTIFICATION_DRAW: {
+ const Color dark_color = get_theme_color("dark_color_2", "Editor");
+
+ for (int i = 0; i < 5; ++i) {
+ draw_rect(background_rects[i], dark_color);
+ }
+
+ break;
+ }
+ }
+}
+
+void BoneTransformEditor::_value_changed(const double p_value) {
+ if (updating)
+ return;
+
+ Transform tform = compute_transform_from_vector3s();
+ _change_transform(tform);
+}
+
+void BoneTransformEditor::_value_changed_vector3(const String p_property_name, const Vector3 p_vector, const StringName p_edited_property_name, const bool p_boolean) {
+ if (updating)
+ return;
+ Transform tform = compute_transform_from_vector3s();
+ _change_transform(tform);
+}
+
+Transform BoneTransformEditor::compute_transform_from_vector3s() const {
+ // Convert rotation from degrees to radians.
+ Vector3 prop_rotation = rotation_property->get_vector();
+ prop_rotation.x = Math::deg2rad(prop_rotation.x);
+ prop_rotation.y = Math::deg2rad(prop_rotation.y);
+ prop_rotation.z = Math::deg2rad(prop_rotation.z);
+
+ return Transform(
+ Basis(prop_rotation, scale_property->get_vector()),
+ translation_property->get_vector());
+}
+
+void BoneTransformEditor::_value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean) {
+ if (updating)
+ return;
+ _change_transform(p_transform);
+}
+
+void BoneTransformEditor::_change_transform(Transform p_new_transform) {
+ if (property.get_slicec('/', 0) == "bones" && property.get_slicec('/', 2) == "custom_pose") {
+ undo_redo->create_action(TTR("Set Custom Bone Pose Transform"), UndoRedo::MERGE_ENDS);
+ undo_redo->add_undo_method(skeleton, "set_bone_custom_pose", property.get_slicec('/', 1).to_int(), skeleton->get_bone_custom_pose(property.get_slicec('/', 1).to_int()));
+ undo_redo->add_do_method(skeleton, "set_bone_custom_pose", property.get_slicec('/', 1).to_int(), p_new_transform);
+ undo_redo->commit_action();
+ } else if (property.get_slicec('/', 0) == "bones") {
+ undo_redo->create_action(TTR("Set Bone Transform"), UndoRedo::MERGE_ENDS);
+ undo_redo->add_undo_property(skeleton, property, skeleton->get(property));
+ undo_redo->add_do_property(skeleton, property, p_new_transform);
+ undo_redo->commit_action();
+ }
+}
+
+void BoneTransformEditor::update_enabled_checkbox() {
+ if (enabled_checkbox) {
+ const String path = "bones/" + property.get_slicec('/', 1) + "/enabled";
+ const bool is_enabled = skeleton->get(path);
+ enabled_checkbox->set_pressed(is_enabled);
+ }
+}
+
+void BoneTransformEditor::_update_properties() {
+ if (updating)
+ return;
+
+ if (skeleton == nullptr)
+ return;
+
+ updating = true;
+
+ Transform tform = skeleton->get(property);
+ _update_transform_properties(tform);
+}
+
+void BoneTransformEditor::_update_custom_pose_properties() {
+ if (updating)
+ return;
+
+ if (skeleton == nullptr)
+ return;
+
+ updating = true;
+
+ Transform tform = skeleton->get_bone_custom_pose(property.to_int());
+ _update_transform_properties(tform);
+}
+
+void BoneTransformEditor::_update_transform_properties(Transform tform) {
+ Basis rotation_basis = tform.get_basis();
+ Vector3 rotation_radians = rotation_basis.get_rotation_euler();
+ Vector3 rotation_degrees = Vector3(Math::rad2deg(rotation_radians.x), Math::rad2deg(rotation_radians.y), Math::rad2deg(rotation_radians.z));
+ Vector3 translation = tform.get_origin();
+ Vector3 scale = tform.basis.get_scale();
+
+ translation_property->update_using_vector(translation);
+ rotation_property->update_using_vector(rotation_degrees);
+ scale_property->update_using_vector(scale);
+ transform_property->update_using_transform(tform);
+
+ update_enabled_checkbox();
+ updating = false;
+}
+
+BoneTransformEditor::BoneTransformEditor(Skeleton3D *p_skeleton) :
+ skeleton(p_skeleton),
+ key_button(nullptr),
+ enabled_checkbox(nullptr),
+ keyable(false),
+ toggle_enabled(false),
+ updating(false) {
+ undo_redo = EditorNode::get_undo_redo();
+}
+
+void BoneTransformEditor::set_target(const String &p_prop) {
+ property = p_prop;
+}
+
+void BoneTransformEditor::set_keyable(const bool p_keyable) {
+ keyable = p_keyable;
+ if (key_button) {
+ key_button->set_visible(p_keyable);
+ }
+}
+
+void BoneTransformEditor::set_toggle_enabled(const bool p_enabled) {
+ toggle_enabled = p_enabled;
+ if (enabled_checkbox) {
+ enabled_checkbox->set_visible(p_enabled);
+ }
+}
+
+void BoneTransformEditor::_key_button_pressed() {
+ if (skeleton == nullptr)
+ return;
+
+ const BoneId bone_id = property.get_slicec('/', 1).to_int();
+ const String name = skeleton->get_bone_name(bone_id);
+
+ if (name.empty())
+ return;
+
+ // Need to normalize the basis before you key it
+ Transform tform = compute_transform_from_vector3s();
+ tform.orthonormalize();
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(skeleton, name, tform);
+}
+
+void BoneTransformEditor::_checkbox_toggled(const bool p_toggled) {
+ if (enabled_checkbox) {
+ const String path = "bones/" + property.get_slicec('/', 1) + "/enabled";
+ skeleton->set(path, p_toggled);
+ }
+}
+
void Skeleton3DEditor::_on_click_option(int p_option) {
if (!skeleton) {
return;
@@ -45,12 +321,14 @@ void Skeleton3DEditor::_on_click_option(int p_option) {
switch (p_option) {
case MENU_OPTION_CREATE_PHYSICAL_SKELETON: {
create_physical_skeleton();
- } break;
+ break;
+ }
}
}
void Skeleton3DEditor::create_physical_skeleton() {
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ERR_FAIL_COND(!get_tree());
Node *owner = skeleton == get_tree()->get_edited_scene_root() ? skeleton : skeleton->get_owner();
const int bc = skeleton->get_bone_count();
@@ -63,22 +341,18 @@ void Skeleton3DEditor::create_physical_skeleton() {
bones_infos.resize(bc);
for (int bone_id = 0; bc > bone_id; ++bone_id) {
-
const int parent = skeleton->get_bone_parent(bone_id);
if (parent < 0) {
-
bones_infos.write[bone_id].relative_rest = skeleton->get_bone_rest(bone_id);
} else {
-
const int parent_parent = skeleton->get_bone_parent(parent);
bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id);
/// create physical bone on parent
if (!bones_infos[parent].physical_bone) {
-
bones_infos.write[parent].physical_bone = create_physical_bone(parent, bone_id, bones_infos);
ur->create_action(TTR("Create physical bones"));
@@ -93,7 +367,6 @@ void Skeleton3DEditor::create_physical_skeleton() {
/// Create joint between parent of parent
if (-1 != parent_parent) {
-
bones_infos[parent].physical_bone->set_joint_type(PhysicalBone3D::JOINT_TYPE_PIN);
}
}
@@ -102,7 +375,6 @@ void Skeleton3DEditor::create_physical_skeleton() {
}
PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) {
-
const Transform child_rest = skeleton->get_bone_rest(bone_child_id);
const real_t half_height(child_rest.origin.length() * 0.5);
@@ -130,30 +402,163 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi
return physical_bone;
}
-void Skeleton3DEditor::edit(Skeleton3D *p_node) {
+Variant Skeleton3DEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
+ TreeItem *selected = joint_tree->get_selected();
+
+ if (!selected)
+ return Variant();
+
+ Ref<Texture> icon = selected->get_icon(0);
- skeleton = p_node;
+ VBoxContainer *vb = memnew(VBoxContainer);
+ HBoxContainer *hb = memnew(HBoxContainer);
+ TextureRect *tf = memnew(TextureRect);
+ tf->set_texture(icon);
+ tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
+ hb->add_child(tf);
+ Label *label = memnew(Label(selected->get_text(0)));
+ hb->add_child(label);
+ vb->add_child(hb);
+ hb->set_modulate(Color(1, 1, 1, 1));
+
+ set_drag_preview(vb);
+ Dictionary drag_data;
+ drag_data["type"] = "nodes";
+ drag_data["node"] = selected;
+
+ return drag_data;
}
-void Skeleton3DEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed));
+bool Skeleton3DEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
+ TreeItem *target = joint_tree->get_item_at_position(p_point);
+ if (!target)
+ return false;
+
+ const String path = target->get_metadata(0);
+ if (!path.begins_with("bones/"))
+ return false;
+
+ TreeItem *selected = Object::cast_to<TreeItem>(Dictionary(p_data)["node"]);
+ if (target == selected)
+ return false;
+
+ const String path2 = target->get_metadata(0);
+ if (!path2.begins_with("bones/"))
+ return false;
+
+ return true;
+}
+
+void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+ if (!can_drop_data_fw(p_point, p_data, p_from))
+ return;
+
+ TreeItem *target = joint_tree->get_item_at_position(p_point);
+ TreeItem *selected = Object::cast_to<TreeItem>(Dictionary(p_data)["node"]);
+
+ const BoneId target_boneidx = String(target->get_metadata(0)).get_slicec('/', 1).to_int();
+ const BoneId selected_boneidx = String(selected->get_metadata(0)).get_slicec('/', 1).to_int();
+
+ move_skeleton_bone(skeleton->get_path(), selected_boneidx, target_boneidx);
+}
+
+void Skeleton3DEditor::move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx) {
+ Node *node = get_node_or_null(p_skeleton_path);
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
+ ERR_FAIL_NULL(skeleton);
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Set Bone Parentage"));
+ // If the target is a child of ourselves, we move only *us* and not our children
+ if (skeleton->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) {
+ const BoneId parent_idx = skeleton->get_bone_parent(p_selected_boneidx);
+ const int bone_count = skeleton->get_bone_count();
+ for (BoneId i = 0; i < bone_count; ++i) {
+ if (skeleton->get_bone_parent(i) == p_selected_boneidx) {
+ ur->add_undo_method(skeleton, "set_bone_parent", i, skeleton->get_bone_parent(i));
+ ur->add_do_method(skeleton, "set_bone_parent", i, parent_idx);
+ skeleton->set_bone_parent(i, parent_idx);
+ }
+ }
}
+ ur->add_undo_method(skeleton, "set_bone_parent", p_selected_boneidx, skeleton->get_bone_parent(p_selected_boneidx));
+ ur->add_do_method(skeleton, "set_bone_parent", p_selected_boneidx, p_target_boneidx);
+ skeleton->set_bone_parent(p_selected_boneidx, p_target_boneidx);
+
+ update_joint_tree();
+ ur->commit_action();
}
-void Skeleton3DEditor::_node_removed(Node *p_node) {
+void Skeleton3DEditor::_joint_tree_selection_changed() {
+ TreeItem *selected = joint_tree->get_selected();
+ const String path = selected->get_metadata(0);
- if (p_node == skeleton) {
- skeleton = nullptr;
- options->hide();
+ if (path.begins_with("bones/")) {
+ const int b_idx = path.get_slicec('/', 1).to_int();
+ const String bone_path = "bones/" + itos(b_idx) + "/";
+
+ pose_editor->set_target(bone_path + "pose");
+ rest_editor->set_target(bone_path + "rest");
+ custom_pose_editor->set_target(bone_path + "custom_pose");
+
+ pose_editor->set_visible(true);
+ rest_editor->set_visible(true);
+ custom_pose_editor->set_visible(true);
}
}
-void Skeleton3DEditor::_bind_methods() {
+void Skeleton3DEditor::_joint_tree_rmb_select(const Vector2 &p_pos) {
+}
+
+void Skeleton3DEditor::_update_properties() {
+ if (rest_editor)
+ rest_editor->_update_properties();
+ if (pose_editor)
+ pose_editor->_update_properties();
+ if (custom_pose_editor)
+ custom_pose_editor->_update_custom_pose_properties();
}
-Skeleton3DEditor::Skeleton3DEditor() {
- skeleton = nullptr;
+void Skeleton3DEditor::update_joint_tree() {
+ joint_tree->clear();
+
+ if (skeleton == nullptr)
+ return;
+
+ TreeItem *root = joint_tree->create_item();
+
+ Map<int, TreeItem *> items;
+
+ items.insert(-1, root);
+
+ const Vector<int> &joint_porder = skeleton->get_bone_process_orders();
+ Ref<Texture> bone_icon = get_theme_icon("BoneAttachment3D", "EditorIcons");
+
+ for (int i = 0; i < joint_porder.size(); ++i) {
+ const int b_idx = joint_porder[i];
+
+ const int p_idx = skeleton->get_bone_parent(b_idx);
+ TreeItem *p_item = items.find(p_idx)->get();
+
+ TreeItem *joint_item = joint_tree->create_item(p_item);
+ items.insert(b_idx, joint_item);
+
+ joint_item->set_text(0, skeleton->get_bone_name(b_idx));
+ joint_item->set_icon(0, bone_icon);
+ joint_item->set_selectable(0, true);
+ joint_item->set_metadata(0, "bones/" + itos(b_idx));
+ }
+}
+
+void Skeleton3DEditor::update_editors() {
+}
+
+void Skeleton3DEditor::create_editors() {
+ set_h_size_flags(SIZE_EXPAND_FILL);
+ add_theme_constant_override("separation", 0);
+
+ set_focus_mode(FOCUS_ALL);
+
+ // Create Top Menu Bar
options = memnew(MenuButton);
Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
@@ -163,33 +568,119 @@ Skeleton3DEditor::Skeleton3DEditor() {
options->get_popup()->add_item(TTR("Create physical skeleton"), MENU_OPTION_CREATE_PHYSICAL_SKELETON);
options->get_popup()->connect("id_pressed", callable_mp(this, &Skeleton3DEditor::_on_click_option));
- options->hide();
+
+ const Color section_color = get_theme_color("prop_subsection", "Editor");
+
+ EditorInspectorSection *bones_section = memnew(EditorInspectorSection);
+ bones_section->setup("bones", "Bones", skeleton, section_color, true);
+ add_child(bones_section);
+ bones_section->unfold();
+
+ ScrollContainer *s_con = memnew(ScrollContainer);
+ s_con->set_h_size_flags(SIZE_EXPAND_FILL);
+ s_con->set_custom_minimum_size(Size2(1, 350) * EDSCALE);
+ bones_section->get_vbox()->add_child(s_con);
+
+ joint_tree = memnew(Tree);
+ joint_tree->set_columns(1);
+ joint_tree->set_focus_mode(Control::FocusMode::FOCUS_NONE);
+ joint_tree->set_select_mode(Tree::SELECT_SINGLE);
+ joint_tree->set_hide_root(true);
+ joint_tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ joint_tree->set_h_size_flags(SIZE_EXPAND_FILL);
+ joint_tree->set_allow_rmb_select(true);
+ joint_tree->set_drag_forwarding(this);
+ s_con->add_child(joint_tree);
+
+ pose_editor = memnew(BoneTransformEditor(skeleton));
+ pose_editor->set_label(TTR("Bone Pose"));
+ pose_editor->set_keyable(AnimationPlayerEditor::singleton->get_track_editor()->has_keying());
+ pose_editor->set_toggle_enabled(true);
+ pose_editor->set_visible(false);
+ add_child(pose_editor);
+
+ rest_editor = memnew(BoneTransformEditor(skeleton));
+ rest_editor->set_label(TTR("Bone Rest"));
+ rest_editor->set_visible(false);
+ add_child(rest_editor);
+
+ custom_pose_editor = memnew(BoneTransformEditor(skeleton));
+ custom_pose_editor->set_label(TTR("Bone Custom Pose"));
+ custom_pose_editor->set_visible(false);
+ add_child(custom_pose_editor);
}
-Skeleton3DEditor::~Skeleton3DEditor() {}
+void Skeleton3DEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ create_editors();
+ update_joint_tree();
+ update_editors();
+
+ get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Vector<Variant>(), Object::CONNECT_ONESHOT);
+ joint_tree->connect("item_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_selection_changed));
+ joint_tree->connect("item_rmb_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_rmb_select));
+#ifdef TOOLS_ENABLED
+ skeleton->connect("pose_updated", callable_mp(this, &Skeleton3DEditor::_update_properties));
+#endif // TOOLS_ENABLED
+
+ break;
+ }
+ }
+}
-void Skeleton3DEditorPlugin::edit(Object *p_object) {
- skeleton_editor->edit(Object::cast_to<Skeleton3D>(p_object));
+void Skeleton3DEditor::_node_removed(Node *p_node) {
+ if (skeleton && p_node == skeleton) {
+ skeleton = nullptr;
+ options->hide();
+ }
+
+ _update_properties();
}
-bool Skeleton3DEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Skeleton3D");
+void Skeleton3DEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_node_removed"), &Skeleton3DEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_joint_tree_selection_changed"), &Skeleton3DEditor::_joint_tree_selection_changed);
+ ClassDB::bind_method(D_METHOD("_joint_tree_rmb_select"), &Skeleton3DEditor::_joint_tree_rmb_select);
+ ClassDB::bind_method(D_METHOD("_update_properties"), &Skeleton3DEditor::_update_properties);
+ ClassDB::bind_method(D_METHOD("_on_click_option"), &Skeleton3DEditor::_on_click_option);
+
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &Skeleton3DEditor::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &Skeleton3DEditor::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &Skeleton3DEditor::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("move_skeleton_bone"), &Skeleton3DEditor::move_skeleton_bone);
}
-void Skeleton3DEditorPlugin::make_visible(bool p_visible) {
- if (p_visible) {
- skeleton_editor->options->show();
- } else {
+Skeleton3DEditor::Skeleton3DEditor(EditorInspectorPluginSkeleton *e_plugin, EditorNode *p_editor, Skeleton3D *p_skeleton) :
+ editor(p_editor),
+ editor_plugin(e_plugin),
+ skeleton(p_skeleton) {
+}
- skeleton_editor->options->hide();
- skeleton_editor->edit(nullptr);
+Skeleton3DEditor::~Skeleton3DEditor() {
+ if (options) {
+ Node3DEditor::get_singleton()->remove_control_from_menu_panel(options);
}
}
+bool EditorInspectorPluginSkeleton::can_handle(Object *p_object) {
+ return Object::cast_to<Skeleton3D>(p_object) != nullptr;
+}
+
+void EditorInspectorPluginSkeleton::parse_begin(Object *p_object) {
+ Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(p_object);
+ ERR_FAIL_COND(!skeleton);
+
+ Skeleton3DEditor *skel_editor = memnew(Skeleton3DEditor(this, editor, skeleton));
+ add_custom_control(skel_editor);
+}
+
Skeleton3DEditorPlugin::Skeleton3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
- skeleton_editor = memnew(Skeleton3DEditor);
- editor->get_viewport()->add_child(skeleton_editor);
-}
-Skeleton3DEditorPlugin::~Skeleton3DEditorPlugin() {}
+ Ref<EditorInspectorPluginSkeleton> skeleton_plugin;
+ skeleton_plugin.instance();
+ skeleton_plugin->editor = editor;
+
+ EditorInspector::add_inspector_plugin(skeleton_plugin);
+}
diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h
index 2ba5a817bc..a5b8ce80a9 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_3d_editor_plugin.h
@@ -35,62 +35,174 @@
#include "editor/editor_plugin.h"
#include "scene/3d/skeleton_3d.h"
+class EditorInspectorPluginSkeleton;
+class Joint;
class PhysicalBone3D;
-class Joint3D;
+class Skeleton3DEditorPlugin;
+class Button;
+class CheckBox;
+class EditorPropertyTransform;
+class EditorPropertyVector3;
-class Skeleton3DEditor : public Node {
- GDCLASS(Skeleton3DEditor, Node);
+class BoneTransformEditor : public VBoxContainer {
+ GDCLASS(BoneTransformEditor, VBoxContainer);
+
+ EditorInspectorSection *section;
+
+ EditorPropertyVector3 *translation_property;
+ EditorPropertyVector3 *rotation_property;
+ EditorPropertyVector3 *scale_property;
+ EditorInspectorSection *transform_section;
+ EditorPropertyTransform *transform_property;
+
+ Rect2 background_rects[5];
+
+ Skeleton3D *skeleton;
+ String property;
+
+ UndoRedo *undo_redo;
+
+ Button *key_button;
+ CheckBox *enabled_checkbox;
+
+ bool keyable;
+ bool toggle_enabled;
+ bool updating;
+
+ String label;
+
+ void create_editors();
+
+ // Called when one of the EditorSpinSliders are changed.
+ void _value_changed(const double p_value);
+ // Called when the one of the EditorPropertyVector3 are updated.
+ void _value_changed_vector3(const String p_property_name, const Vector3 p_vector, const StringName p_edited_property_name, const bool p_boolean);
+ // Called when the transform_property is updated.
+ void _value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean);
+ // Changes the transform to the given transform and updates the UI accordingly.
+ void _change_transform(Transform p_new_transform);
+ // Creates a Transform using the EditorPropertyVector3 properties.
+ Transform compute_transform_from_vector3s() const;
+
+ void update_enabled_checkbox();
+
+protected:
+ void _notification(int p_what);
+
+public:
+ BoneTransformEditor(Skeleton3D *p_skeleton);
+
+ // Which transform target to modify
+ void set_target(const String &p_prop);
+ void set_label(const String &p_label) { label = p_label; }
+
+ void _update_properties();
+ void _update_custom_pose_properties();
+ void _update_transform_properties(Transform p_transform);
+
+ // Can/cannot modify the spinner values for the Transform
+ void set_read_only(const bool p_read_only);
+
+ // Transform can be keyed, whether or not to show the button
+ void set_keyable(const bool p_keyable);
+
+ // Bone can be toggled enabled or disabled, whether or not to show the checkbox
+ void set_toggle_enabled(const bool p_enabled);
+
+ // Key Transform Button pressed
+ void _key_button_pressed();
+
+ // Bone Enabled Checkbox toggled
+ void _checkbox_toggled(const bool p_toggled);
+};
+
+class Skeleton3DEditor : public VBoxContainer {
+ GDCLASS(Skeleton3DEditor, VBoxContainer);
+
+ friend class Skeleton3DEditorPlugin;
enum Menu {
MENU_OPTION_CREATE_PHYSICAL_SKELETON
};
struct BoneInfo {
- PhysicalBone3D *physical_bone;
+ PhysicalBone3D *physical_bone = nullptr;
Transform relative_rest; // Relative to skeleton node
- BoneInfo() :
- physical_bone(nullptr) {}
+ BoneInfo() {}
};
+ EditorNode *editor;
+ EditorInspectorPluginSkeleton *editor_plugin;
+
Skeleton3D *skeleton;
+ Tree *joint_tree;
+ BoneTransformEditor *rest_editor;
+ BoneTransformEditor *pose_editor;
+ BoneTransformEditor *custom_pose_editor;
+
MenuButton *options;
+ EditorFileDialog *file_dialog;
+
+ UndoRedo *undo_redo;
void _on_click_option(int p_option);
+ void _file_selected(const String &p_file);
- friend class Skeleton3DEditorPlugin;
+ EditorFileDialog *file_export_lib;
+
+ void update_joint_tree();
+ void update_editors();
+
+ void create_editors();
+
+ void create_physical_skeleton();
+ PhysicalBone3D *create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos);
+
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
- void create_physical_skeleton();
- PhysicalBone3D *create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos);
-
public:
- void edit(Skeleton3D *p_node);
+ void move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx);
+
+ Skeleton3D *get_skeleton() const { return skeleton; };
+
+ void _joint_tree_selection_changed();
+ void _joint_tree_rmb_select(const Vector2 &p_pos);
- Skeleton3DEditor();
+ void _update_properties();
+
+ Skeleton3DEditor(EditorInspectorPluginSkeleton *e_plugin, EditorNode *p_editor, Skeleton3D *skeleton);
~Skeleton3DEditor();
};
-class Skeleton3DEditorPlugin : public EditorPlugin {
+class EditorInspectorPluginSkeleton : public EditorInspectorPlugin {
+ GDCLASS(EditorInspectorPluginSkeleton, EditorInspectorPlugin);
- GDCLASS(Skeleton3DEditorPlugin, EditorPlugin);
+ friend class Skeleton3DEditorPlugin;
EditorNode *editor;
- Skeleton3DEditor *skeleton_editor;
public:
- virtual String get_name() const { return "Skeleton3D"; }
- virtual bool has_main_screen() const { return false; }
- virtual void edit(Object *p_object);
- virtual bool handles(Object *p_object) const;
- virtual void make_visible(bool p_visible);
+ virtual bool can_handle(Object *p_object);
+ virtual void parse_begin(Object *p_object);
+};
+
+class Skeleton3DEditorPlugin : public EditorPlugin {
+ GDCLASS(Skeleton3DEditorPlugin, EditorPlugin);
+
+ EditorNode *editor;
+public:
Skeleton3DEditorPlugin(EditorNode *p_node);
- ~Skeleton3DEditorPlugin();
+
+ virtual String get_name() const { return "Skeleton3D"; }
};
#endif // SKELETON_3D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
index a22534eac0..8fc789b94a 100644
--- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
@@ -33,12 +33,13 @@
#include "scene/3d/skeleton_ik_3d.h"
void SkeletonIK3DEditorPlugin::_play() {
-
- if (!skeleton_ik)
+ if (!skeleton_ik) {
return;
+ }
- if (!skeleton_ik->get_parent_skeleton())
+ if (!skeleton_ik->get_parent_skeleton()) {
return;
+ }
if (play_btn->is_pressed()) {
skeleton_ik->start();
@@ -49,7 +50,6 @@ void SkeletonIK3DEditorPlugin::_play() {
}
void SkeletonIK3DEditorPlugin::edit(Object *p_object) {
-
if (p_object != skeleton_ik) {
if (skeleton_ik) {
play_btn->set_pressed(false);
@@ -58,30 +58,29 @@ void SkeletonIK3DEditorPlugin::edit(Object *p_object) {
}
SkeletonIK3D *s = Object::cast_to<SkeletonIK3D>(p_object);
- if (!s)
+ if (!s) {
return;
+ }
skeleton_ik = s;
}
bool SkeletonIK3DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("SkeletonIK3D");
}
void SkeletonIK3DEditorPlugin::make_visible(bool p_visible) {
-
- if (p_visible)
+ if (p_visible) {
play_btn->show();
- else
+ } else {
play_btn->hide();
+ }
}
void SkeletonIK3DEditorPlugin::_bind_methods() {
}
SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
play_btn = memnew(Button);
play_btn->set_icon(editor->get_gui_base()->get_theme_icon("Play", "EditorIcons"));
diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h
index 88472a2963..bd4c5ba93e 100644
--- a/editor/plugins/skeleton_ik_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h
@@ -37,7 +37,6 @@
class SkeletonIK3D;
class SkeletonIK3DEditorPlugin : public EditorPlugin {
-
GDCLASS(SkeletonIK3DEditorPlugin, EditorPlugin);
SkeletonIK3D *skeleton_ik;
diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp
index ab0f15d3d0..f5fafb68a5 100644
--- a/editor/plugins/sprite_2d_editor_plugin.cpp
+++ b/editor/plugins/sprite_2d_editor_plugin.cpp
@@ -31,6 +31,7 @@
#include "sprite_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "core/math/geometry_2d.h"
#include "editor/editor_scale.h"
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/light_occluder_2d.h"
@@ -40,7 +41,6 @@
#include "thirdparty/misc/clipper.hpp"
void Sprite2DEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
options->hide();
@@ -48,7 +48,6 @@ void Sprite2DEditor::_node_removed(Node *p_node) {
}
void Sprite2DEditor::edit(Sprite2D *p_sprite) {
-
node = p_sprite;
}
@@ -63,7 +62,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
ClipperLib::PolyTree out;
for (int i = 0; i < points.size(); i++) {
-
subj << ClipperLib::IntPoint(points[i].x * PRECISION, points[i].y * PRECISION);
}
ClipperLib::ClipperOffset co;
@@ -104,7 +102,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
int lasti = p2->Contour.size() - 1;
Vector2 prev = Vector2(p2->Contour[lasti].X / PRECISION, p2->Contour[lasti].Y / PRECISION);
for (uint64_t i = 0; i < p2->Contour.size(); i++) {
-
Vector2 cur = Vector2(p2->Contour[i].X / PRECISION, p2->Contour[i].Y / PRECISION);
if (cur.distance_to(prev) > 0.5) {
outPoints.push_back(cur);
@@ -115,7 +112,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
}
void Sprite2DEditor::_menu_option(int p_option) {
-
if (!node) {
return;
}
@@ -124,7 +120,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
switch (p_option) {
case MENU_OPTION_CONVERT_TO_MESH_2D: {
-
debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D"));
debug_uv_dialog->set_title(TTR("Mesh2D Preview"));
@@ -134,7 +129,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CONVERT_TO_POLYGON_2D: {
-
debug_uv_dialog->get_ok()->set_text(TTR("Create Polygon2D"));
debug_uv_dialog->set_title(TTR("Polygon2D Preview"));
@@ -143,7 +137,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
debug_uv->update();
} break;
case MENU_OPTION_CREATE_COLLISION_POLY_2D: {
-
debug_uv_dialog->get_ok()->set_text(TTR("Create CollisionPolygon2D"));
debug_uv_dialog->set_title(TTR("CollisionPolygon2D Preview"));
@@ -153,7 +146,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: {
-
debug_uv_dialog->get_ok()->set_text(TTR("Create LightOccluder2D"));
debug_uv_dialog->set_title(TTR("LightOccluder2D Preview"));
@@ -166,7 +158,6 @@ void Sprite2DEditor::_menu_option(int p_option) {
}
void Sprite2DEditor::_update_mesh_data() {
-
Ref<Texture2D> texture = node->get_texture();
if (texture.is_null()) {
err_dialog->set_text(TTR("Sprite2D is empty!"));
@@ -183,10 +174,11 @@ void Sprite2DEditor::_update_mesh_data() {
Ref<Image> image = texture->get_data();
ERR_FAIL_COND(image.is_null());
Rect2 rect;
- if (node->is_region())
+ if (node->is_region()) {
rect = node->get_region_rect();
- else
+ } else {
rect.size = Size2(image->get_width(), image->get_height());
+ }
Ref<BitMap> bm;
bm.instance();
@@ -218,7 +210,6 @@ void Sprite2DEditor::_update_mesh_data() {
}
if (selected_menu_item == MENU_OPTION_CONVERT_TO_MESH_2D) {
-
for (int j = 0; j < lines.size(); j++) {
int index_ofs = computed_vertices.size();
@@ -229,18 +220,21 @@ void Sprite2DEditor::_update_mesh_data() {
vtx -= rect.position; //offset by rect position
//flip if flipped
- if (node->is_flipped_h())
+ if (node->is_flipped_h()) {
vtx.x = rect.size.x - vtx.x - 1.0;
- if (node->is_flipped_v())
+ }
+ if (node->is_flipped_v()) {
vtx.y = rect.size.y - vtx.y - 1.0;
+ }
- if (node->is_centered())
+ if (node->is_centered()) {
vtx -= rect.size / 2.0;
+ }
computed_vertices.push_back(vtx);
}
- Vector<int> poly = Geometry::triangulate_polygon(lines[j]);
+ Vector<int> poly = Geometry2D::triangulate_polygon(lines[j]);
for (int i = 0; i < poly.size(); i += 3) {
for (int k = 0; k < 3; k++) {
@@ -262,7 +256,6 @@ void Sprite2DEditor::_update_mesh_data() {
outline_lines.resize(lines.size());
computed_outline_lines.resize(lines.size());
for (int pi = 0; pi < lines.size(); pi++) {
-
Vector<Vector2> ol;
Vector<Vector2> col;
@@ -277,13 +270,16 @@ void Sprite2DEditor::_update_mesh_data() {
vtx -= rect.position; //offset by rect position
//flip if flipped
- if (node->is_flipped_h())
+ if (node->is_flipped_h()) {
vtx.x = rect.size.x - vtx.x - 1.0;
- if (node->is_flipped_v())
+ }
+ if (node->is_flipped_v()) {
vtx.y = rect.size.y - vtx.y - 1.0;
+ }
- if (node->is_centered())
+ if (node->is_centered()) {
vtx -= rect.size / 2.0;
+ }
col.write[i] = vtx;
}
@@ -314,7 +310,6 @@ void Sprite2DEditor::_create_node() {
}
void Sprite2DEditor::_convert_to_mesh_2d_node() {
-
if (computed_vertices.size() < 3) {
err_dialog->set_text(TTR("Invalid geometry, can't replace by mesh."));
err_dialog->popup_centered();
@@ -345,7 +340,6 @@ void Sprite2DEditor::_convert_to_mesh_2d_node() {
}
void Sprite2DEditor::_convert_to_polygon_2d_node() {
-
if (computed_outline_lines.empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create polygon."));
err_dialog->popup_centered();
@@ -355,8 +349,9 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() {
Polygon2D *polygon_2d_instance = memnew(Polygon2D);
int total_point_count = 0;
- for (int i = 0; i < computed_outline_lines.size(); i++)
+ for (int i = 0; i < computed_outline_lines.size(); i++) {
total_point_count += computed_outline_lines[i].size();
+ }
PackedVector2Array polygon;
polygon.resize(total_point_count);
@@ -372,7 +367,6 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() {
polys.resize(computed_outline_lines.size());
for (int i = 0; i < computed_outline_lines.size(); i++) {
-
Vector<Vector2> outline = computed_outline_lines[i];
Vector<Vector2> uv_outline = outline_lines[i];
@@ -404,7 +398,6 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() {
}
void Sprite2DEditor::_create_collision_polygon_2d_node() {
-
if (computed_outline_lines.empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon."));
err_dialog->popup_centered();
@@ -412,7 +405,6 @@ void Sprite2DEditor::_create_collision_polygon_2d_node() {
}
for (int i = 0; i < computed_outline_lines.size(); i++) {
-
Vector<Vector2> outline = computed_outline_lines[i];
CollisionPolygon2D *collision_polygon_2d_instance = memnew(CollisionPolygon2D);
@@ -428,7 +420,6 @@ void Sprite2DEditor::_create_collision_polygon_2d_node() {
}
void Sprite2DEditor::_create_light_occluder_2d_node() {
-
if (computed_outline_lines.empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create light occluder."));
err_dialog->popup_centered();
@@ -436,7 +427,6 @@ void Sprite2DEditor::_create_light_occluder_2d_node() {
}
for (int i = 0; i < computed_outline_lines.size(); i++) {
-
Vector<Vector2> outline = computed_outline_lines[i];
Ref<OccluderPolygon2D> polygon;
@@ -475,7 +465,6 @@ void Sprite2DEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node
}
void Sprite2DEditor::_debug_uv_draw() {
-
Ref<Texture2D> tex = node->get_texture();
ERR_FAIL_COND(!tex.is_valid());
@@ -503,12 +492,10 @@ void Sprite2DEditor::_debug_uv_draw() {
}
void Sprite2DEditor::_bind_methods() {
-
ClassDB::bind_method("_add_as_sibling_or_child", &Sprite2DEditor::_add_as_sibling_or_child);
}
Sprite2DEditor::Sprite2DEditor() {
-
options = memnew(MenuButton);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
@@ -577,28 +564,23 @@ Sprite2DEditor::Sprite2DEditor() {
}
void Sprite2DEditorPlugin::edit(Object *p_object) {
-
sprite_editor->edit(Object::cast_to<Sprite2D>(p_object));
}
bool Sprite2DEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("Sprite2D");
}
void Sprite2DEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
sprite_editor->options->show();
} else {
-
sprite_editor->options->hide();
sprite_editor->edit(nullptr);
}
}
Sprite2DEditorPlugin::Sprite2DEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
sprite_editor = memnew(Sprite2DEditor);
editor->get_viewport()->add_child(sprite_editor);
diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h
index 0add77843b..c2b942fd82 100644
--- a/editor/plugins/sprite_2d_editor_plugin.h
+++ b/editor/plugins/sprite_2d_editor_plugin.h
@@ -37,7 +37,6 @@
#include "scene/gui/spin_box.h"
class Sprite2DEditor : public Control {
-
GDCLASS(Sprite2DEditor, Control);
enum Menu {
@@ -97,7 +96,6 @@ public:
};
class Sprite2DEditorPlugin : public EditorPlugin {
-
GDCLASS(Sprite2DEditorPlugin, EditorPlugin);
Sprite2DEditor *sprite_editor;
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 34ff34d45b..859fec1628 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -41,7 +41,6 @@ void SpriteFramesEditor::_gui_input(Ref<InputEvent> p_event) {
}
void SpriteFramesEditor::_open_sprite_sheet() {
-
file_split_sheet->clear_filters();
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
@@ -53,7 +52,6 @@ void SpriteFramesEditor::_open_sprite_sheet() {
}
void SpriteFramesEditor::_sheet_preview_draw() {
-
Size2i size = split_sheet_preview->get_size();
int h = split_sheet_h->get_value();
int v = split_sheet_v->get_value();
@@ -61,13 +59,11 @@ void SpriteFramesEditor::_sheet_preview_draw() {
int height = size.height / v;
const float a = 0.3;
for (int i = 1; i < h; i++) {
-
int x = i * width;
split_sheet_preview->draw_line(Point2(x, 0), Point2(x, size.height), Color(1, 1, 1, a));
split_sheet_preview->draw_line(Point2(x + 1, 0), Point2(x + 1, size.height), Color(0, 0, 0, a));
for (int j = 1; j < v; j++) {
-
int y = j * height;
split_sheet_preview->draw_line(Point2(0, y), Point2(size.width, y), Color(1, 1, 1, a));
@@ -102,8 +98,8 @@ void SpriteFramesEditor::_sheet_preview_draw() {
split_sheet_dialog->get_ok()->set_disabled(false);
split_sheet_dialog->get_ok()->set_text(vformat(TTR("Add %d Frame(s)"), frames_selected.size()));
}
-void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
+void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
@@ -145,7 +141,6 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
}
void SpriteFramesEditor::_sheet_add_frames() {
-
Size2i size = split_sheet_preview->get_size();
int h = split_sheet_h->get_value();
int v = split_sheet_v->get_value();
@@ -158,8 +153,9 @@ void SpriteFramesEditor::_sheet_add_frames() {
Rect2 region_rect = Rect2();
- if (atlas_source && atlas_source->get_atlas().is_valid())
+ if (atlas_source && atlas_source->get_atlas().is_valid()) {
region_rect = atlas_source->get_region();
+ }
for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) {
int idx = E->get();
@@ -185,7 +181,6 @@ void SpriteFramesEditor::_sheet_add_frames() {
}
void SpriteFramesEditor::_sheet_select_clear_all_frames() {
-
bool should_clear = true;
for (int i = 0; i < split_sheet_h->get_value() * split_sheet_v->get_value(); i++) {
if (!frames_selected.has(i)) {
@@ -201,14 +196,12 @@ void SpriteFramesEditor::_sheet_select_clear_all_frames() {
}
void SpriteFramesEditor::_sheet_spin_changed(double) {
-
frames_selected.clear();
last_frame_selected = -1;
split_sheet_preview->update();
}
void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
-
Ref<Resource> texture = ResourceLoader::load(p_file);
if (!texture.is_valid()) {
EditorNode::get_singleton()->show_warning(TTR("Unable to load images"));
@@ -227,7 +220,6 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
}
void SpriteFramesEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
load->set_icon(get_theme_icon("Load", "EditorIcons"));
@@ -253,13 +245,11 @@ void SpriteFramesEditor::_notification(int p_what) {
}
void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_at_pos) {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
List<Ref<Texture2D>> resources;
for (int i = 0; i < p_path.size(); i++) {
-
Ref<Texture2D> resource;
resource = ResourceLoader::load(p_path[i]);
@@ -286,7 +276,6 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_
int count = 0;
for (List<Ref<Texture2D>>::Element *E = resources.front(); E; E = E->next()) {
-
undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count);
undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos);
count++;
@@ -298,15 +287,15 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_
}
void SpriteFramesEditor::_load_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
loading_scene = false;
file->clear_filters();
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
- for (int i = 0; i < extensions.size(); i++)
+ for (int i = 0; i < extensions.size(); i++) {
file->add_filter("*." + extensions[i]);
+ }
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
@@ -314,7 +303,6 @@ void SpriteFramesEditor::_load_pressed() {
}
void SpriteFramesEditor::_paste_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
Ref<Texture2D> r = EditorSettings::get_singleton()->get_resource_clipboard();
@@ -338,8 +326,9 @@ void SpriteFramesEditor::_paste_pressed() {
void SpriteFramesEditor::_copy_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current() < 0)
+ if (tree->get_current() < 0) {
return;
+ }
Ref<Texture2D> r = frames->get_frame(edited_anim, tree->get_current());
if (!r.is_valid()) {
return;
@@ -349,13 +338,11 @@ void SpriteFramesEditor::_copy_pressed() {
}
void SpriteFramesEditor::_empty_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
int from = -1;
if (tree->get_current() >= 0) {
-
from = tree->get_current();
sel = from;
@@ -374,13 +361,11 @@ void SpriteFramesEditor::_empty_pressed() {
}
void SpriteFramesEditor::_empty2_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
int from = -1;
if (tree->get_current() >= 0) {
-
from = tree->get_current();
sel = from;
@@ -399,15 +384,16 @@ void SpriteFramesEditor::_empty2_pressed() {
}
void SpriteFramesEditor::_up_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current() < 0)
+ if (tree->get_current() < 0) {
return;
+ }
int to_move = tree->get_current();
- if (to_move < 1)
+ if (to_move < 1) {
return;
+ }
sel = to_move;
sel -= 1;
@@ -423,15 +409,16 @@ void SpriteFramesEditor::_up_pressed() {
}
void SpriteFramesEditor::_down_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current() < 0)
+ if (tree->get_current() < 0) {
return;
+ }
int to_move = tree->get_current();
- if (to_move < 0 || to_move >= frames->get_frame_count(edited_anim) - 1)
+ if (to_move < 0 || to_move >= frames->get_frame_count(edited_anim) - 1) {
return;
+ }
sel = to_move;
sel += 1;
@@ -447,11 +434,11 @@ void SpriteFramesEditor::_down_pressed() {
}
void SpriteFramesEditor::_delete_pressed() {
-
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current() < 0)
+ if (tree->get_current() < 0) {
return;
+ }
int to_delete = tree->get_current();
if (to_delete < 0 || to_delete >= frames->get_frame_count(edited_anim)) {
@@ -467,14 +454,15 @@ void SpriteFramesEditor::_delete_pressed() {
}
void SpriteFramesEditor::_animation_select() {
-
- if (updating)
+ if (updating) {
return;
+ }
if (frames->has_animation(edited_anim)) {
double value = anim_speed->get_line_edit()->get_text().to_double();
- if (!Math::is_equal_approx(value, frames->get_animation_speed(edited_anim)))
+ if (!Math::is_equal_approx(value, frames->get_animation_speed(edited_anim))) {
_animation_fps_changed(value);
+ }
}
TreeItem *selected = animations->get_selected();
@@ -484,12 +472,13 @@ void SpriteFramesEditor::_animation_select() {
}
static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFrames> p_sfames) {
-
Node *edited = EditorNode::get_singleton()->get_edited_scene();
- if (!edited)
+ if (!edited) {
return;
- if (p_node != edited && p_node->get_owner() != edited)
+ }
+ if (p_node != edited && p_node->get_owner() != edited) {
return;
+ }
{
AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node);
@@ -511,21 +500,24 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr
}
void SpriteFramesEditor::_animation_name_edited() {
-
- if (updating)
+ if (updating) {
return;
+ }
- if (!frames->has_animation(edited_anim))
+ if (!frames->has_animation(edited_anim)) {
return;
+ }
TreeItem *edited = animations->get_edited();
- if (!edited)
+ if (!edited) {
return;
+ }
String new_name = edited->get_text(0);
- if (new_name == String(edited_anim))
+ if (new_name == String(edited_anim)) {
return;
+ }
new_name = new_name.replace("/", "_").replace(",", " ");
@@ -544,7 +536,6 @@ void SpriteFramesEditor::_animation_name_edited() {
undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim);
for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) {
-
String current = E->get()->call("get_animation");
undo_redo->add_do_method(E->get(), "set_animation", name);
undo_redo->add_undo_method(E->get(), "set_animation", edited_anim);
@@ -559,7 +550,6 @@ void SpriteFramesEditor::_animation_name_edited() {
}
void SpriteFramesEditor::_animation_add() {
-
String name = "New Anim";
int counter = 0;
while (frames->has_animation(name)) {
@@ -577,7 +567,6 @@ void SpriteFramesEditor::_animation_add() {
undo_redo->add_undo_method(this, "_update_library");
for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) {
-
String current = E->get()->call("get_animation");
undo_redo->add_do_method(E->get(), "set_animation", name);
undo_redo->add_undo_method(E->get(), "set_animation", current);
@@ -590,19 +579,19 @@ void SpriteFramesEditor::_animation_add() {
}
void SpriteFramesEditor::_animation_remove() {
-
- if (updating)
+ if (updating) {
return;
+ }
- if (!frames->has_animation(edited_anim))
+ if (!frames->has_animation(edited_anim)) {
return;
+ }
delete_dialog->set_text(TTR("Delete Animation?"));
delete_dialog->popup_centered();
}
void SpriteFramesEditor::_animation_remove_confirmed() {
-
undo_redo->create_action(TTR("Remove Animation"));
undo_redo->add_do_method(frames, "remove_animation", edited_anim);
undo_redo->add_undo_method(frames, "add_animation", edited_anim);
@@ -622,9 +611,9 @@ void SpriteFramesEditor::_animation_remove_confirmed() {
}
void SpriteFramesEditor::_animation_loop_changed() {
-
- if (updating)
+ if (updating) {
return;
+ }
undo_redo->create_action(TTR("Change Animation Loop"));
undo_redo->add_do_method(frames, "set_animation_loop", edited_anim, anim_loop->is_pressed());
@@ -635,9 +624,9 @@ void SpriteFramesEditor::_animation_loop_changed() {
}
void SpriteFramesEditor::_animation_fps_changed(double p_value) {
-
- if (updating)
+ if (updating) {
return;
+ }
undo_redo->create_action(TTR("Change Animation FPS"), UndoRedo::MERGE_ENDS);
undo_redo->add_do_method(frames, "set_animation_speed", edited_anim, p_value);
@@ -649,7 +638,6 @@ void SpriteFramesEditor::_animation_fps_changed(double p_value) {
}
void SpriteFramesEditor::_update_library(bool p_skip_selector) {
-
updating = true;
if (!p_skip_selector) {
@@ -664,7 +652,6 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
anim_names.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
-
String name = E->get();
TreeItem *it = animations->create_item(anim_root);
@@ -687,18 +674,17 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
return;
}
- if (sel >= frames->get_frame_count(edited_anim))
+ if (sel >= frames->get_frame_count(edited_anim)) {
sel = frames->get_frame_count(edited_anim) - 1;
- else if (sel < 0 && frames->get_frame_count(edited_anim))
+ } else if (sel < 0 && frames->get_frame_count(edited_anim)) {
sel = 0;
+ }
for (int i = 0; i < frames->get_frame_count(edited_anim); i++) {
-
String name;
Ref<Texture2D> icon;
if (frames->get_frame(edited_anim, i).is_null()) {
-
name = itos(i) + ": " + TTR("(empty)");
} else {
@@ -707,10 +693,12 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
}
tree->add_item(name, icon);
- if (frames->get_frame(edited_anim, i).is_valid())
+ if (frames->get_frame(edited_anim, i).is_valid()) {
tree->set_item_tooltip(tree->get_item_count() - 1, frames->get_frame(edited_anim, i)->get_path());
- if (sel == i)
+ }
+ if (sel == i) {
tree->select(tree->get_item_count() - 1);
+ }
}
anim_speed->set_value(frames->get_animation_speed(edited_anim));
@@ -721,16 +709,14 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
}
void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
-
- if (frames == p_frames)
+ if (frames == p_frames) {
return;
+ }
frames = p_frames;
if (p_frames) {
-
if (!p_frames->has_animation(edited_anim)) {
-
List<StringName> anim_names;
frames->get_animation_list(&anim_names);
anim_names.sort_custom<StringName::AlphCompare>();
@@ -743,25 +729,26 @@ void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
_update_library();
} else {
-
hide();
}
}
Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
- if (!frames->has_animation(edited_anim))
+ if (!frames->has_animation(edited_anim)) {
return false;
+ }
int idx = tree->get_item_at_position(p_point, true);
- if (idx < 0 || idx >= frames->get_frame_count(edited_anim))
+ if (idx < 0 || idx >= frames->get_frame_count(edited_anim)) {
return Variant();
+ }
RES frame = frames->get_frame(edited_anim, idx);
- if (frame.is_null())
+ if (frame.is_null()) {
return Variant();
+ }
Dictionary drag_data = EditorNode::get_singleton()->drag_resource(frame, p_from);
drag_data["frame"] = idx; // store the frame, in case we want to reorder frames inside 'drop_data_fw'
@@ -769,15 +756,16 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
}
bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
// reordering frames
- if (d.has("from") && (Object *)(d["from"]) == tree)
+ if (d.has("from") && (Object *)(d["from"]) == tree) {
return true;
+ }
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
@@ -785,17 +773,16 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
Ref<Texture2D> texture = r;
if (texture.is_valid()) {
-
return true;
}
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
- if (files.size() == 0)
+ if (files.size() == 0) {
return false;
+ }
for (int i = 0; i < files.size(); i++) {
String file = files[i];
@@ -812,14 +799,15 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return;
+ }
int at_pos = tree->get_item_at_position(p_point, true);
@@ -830,13 +818,15 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (texture.is_valid()) {
bool reorder = false;
- if (d.has("from") && (Object *)(d["from"]) == tree)
+ if (d.has("from") && (Object *)(d["from"]) == tree) {
reorder = true;
+ }
if (reorder) { //drop is from reordering frames
int from_frame = -1;
- if (d.has("frame"))
+ if (d.has("frame")) {
from_frame = d["frame"];
+ }
undo_redo->create_action(TTR("Move Frame"));
undo_redo->add_do_method(frames, "remove_frame", edited_anim, from_frame == -1 ? frames->get_frame_count(edited_anim) : from_frame);
@@ -858,7 +848,6 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
_file_load_request(files, at_pos);
@@ -866,7 +855,6 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
void SpriteFramesEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_update_library", "skipsel"), &SpriteFramesEditor::_update_library, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpriteFramesEditor::can_drop_data_fw);
@@ -874,7 +862,6 @@ void SpriteFramesEditor::_bind_methods() {
}
SpriteFramesEditor::SpriteFramesEditor() {
-
VBoxContainer *vbc_animlist = memnew(VBoxContainer);
add_child(vbc_animlist);
vbc_animlist->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
@@ -1071,7 +1058,6 @@ SpriteFramesEditor::SpriteFramesEditor() {
}
void SpriteFramesEditorPlugin::edit(Object *p_object) {
-
frames_editor->set_undo_redo(&get_undo_redo());
SpriteFrames *s;
@@ -1083,7 +1069,6 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) {
if (animated_sprite_3d) {
s = *animated_sprite_3d->get_sprite_frames();
} else {
-
s = Object::cast_to<SpriteFrames>(p_object);
}
}
@@ -1092,7 +1077,6 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) {
}
bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
-
AnimatedSprite2D *animated_sprite = Object::cast_to<AnimatedSprite2D>(p_object);
AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object);
if (animated_sprite && *animated_sprite->get_sprite_frames()) {
@@ -1105,20 +1089,18 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
}
void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
button->show();
editor->make_bottom_panel_item_visible(frames_editor);
} else {
-
button->hide();
- if (frames_editor->is_visible_in_tree())
+ if (frames_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
}
}
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
frames_editor = memnew(SpriteFramesEditor);
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 89d9bc6fd3..45646eb9e4 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -41,7 +41,6 @@
#include "scene/gui/tree.h"
class SpriteFramesEditor : public HSplitContainer {
-
GDCLASS(SpriteFramesEditor, HSplitContainer);
ToolButton *load;
@@ -134,7 +133,6 @@ public:
};
class SpriteFramesEditorPlugin : public EditorPlugin {
-
GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
SpriteFramesEditor *frames_editor;
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index eb6e261305..3641052a4e 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -33,28 +33,28 @@
#include "editor/editor_scale.h"
bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) {
-
return Object::cast_to<StyleBox>(p_object) != nullptr;
}
void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) {
-
Ref<StyleBox> sb = Ref<StyleBox>(Object::cast_to<StyleBox>(p_object));
StyleBoxPreview *preview = memnew(StyleBoxPreview);
preview->edit(sb);
add_custom_control(preview);
}
+
bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
return false; //do not want
}
+
void EditorInspectorPluginStyleBox::parse_end() {
}
void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
-
- if (stylebox.is_valid())
+ if (stylebox.is_valid()) {
stylebox->disconnect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed));
+ }
stylebox = p_stylebox;
if (p_stylebox.is_valid()) {
preview->add_theme_style_override("panel", stylebox);
@@ -64,7 +64,6 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
}
void StyleBoxPreview::_sb_changed() {
-
preview->update();
}
@@ -93,7 +92,6 @@ StyleBoxPreview::StyleBoxPreview() {
}
StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) {
-
Ref<EditorInspectorPluginStyleBox> inspector_plugin;
inspector_plugin.instance();
add_inspector_plugin(inspector_plugin);
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index 1eea9260b2..d9958d42e6 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -38,7 +38,6 @@
#include "scene/resources/style_box.h"
class StyleBoxPreview : public VBoxContainer {
-
GDCLASS(StyleBoxPreview, VBoxContainer);
Control *preview;
@@ -67,7 +66,6 @@ public:
};
class StyleBoxEditorPlugin : public EditorPlugin {
-
GDCLASS(StyleBoxEditorPlugin, EditorPlugin);
public:
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 2786a568ea..3ceb9bfd82 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -70,7 +70,6 @@ void TextEditor::_change_syntax_highlighter(int p_idx) {
}
void TextEditor::_load_theme_settings() {
-
TextEdit *text_edit = code_editor->get_text_edit();
text_edit->clear_colors();
@@ -164,7 +163,6 @@ String TextEditor::get_name() {
}
Ref<Texture2D> TextEditor::get_theme_icon() {
-
return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), "");
}
@@ -195,7 +193,6 @@ void TextEditor::get_breakpoints(List<int> *p_breakpoints) {
}
void TextEditor::reload_text() {
-
ERR_FAIL_COND(text_file.is_null());
TextEdit *te = code_editor->get_text_edit();
@@ -221,7 +218,6 @@ void TextEditor::_validate_script() {
}
void TextEditor::_update_bookmark_list() {
-
bookmarks_menu->clear();
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
@@ -249,7 +245,6 @@ void TextEditor::_update_bookmark_list() {
}
void TextEditor::_bookmark_item_pressed(int p_idx) {
-
if (p_idx < 4) { // Any item before the separator.
_edit_option(bookmarks_menu->get_item_id(p_idx));
} else {
@@ -262,17 +257,14 @@ void TextEditor::apply_code() {
}
bool TextEditor::is_unsaved() {
-
return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version();
}
Variant TextEditor::get_edit_state() {
-
return code_editor->get_edit_state();
}
void TextEditor::set_edit_state(const Variant &p_state) {
-
code_editor->set_edit_state(p_state);
Dictionary state = p_state;
@@ -285,42 +277,34 @@ void TextEditor::set_edit_state(const Variant &p_state) {
}
void TextEditor::trim_trailing_whitespace() {
-
code_editor->trim_trailing_whitespace();
}
void TextEditor::insert_final_newline() {
-
code_editor->insert_final_newline();
}
void TextEditor::convert_indent_to_spaces() {
-
code_editor->convert_indent_to_spaces();
}
void TextEditor::convert_indent_to_tabs() {
-
code_editor->convert_indent_to_tabs();
}
void TextEditor::tag_saved_version() {
-
code_editor->get_text_edit()->tag_saved_version();
}
void TextEditor::goto_line(int p_line, bool p_with_error) {
-
code_editor->goto_line(p_line);
}
void TextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
-
code_editor->goto_line_selection(p_line, p_begin, p_end);
}
void TextEditor::set_executing_line(int p_line) {
-
code_editor->set_executing_line(p_line);
}
@@ -329,12 +313,10 @@ void TextEditor::clear_executing_line() {
}
void TextEditor::ensure_focus() {
-
code_editor->get_text_edit()->grab_focus();
}
Vector<String> TextEditor::get_functions() {
-
return Vector<String>();
}
@@ -343,17 +325,14 @@ bool TextEditor::show_members_overview() {
}
void TextEditor::update_settings() {
-
code_editor->update_editor_settings();
}
void TextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
-
code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
}
Control *TextEditor::get_edit_menu() {
-
return edit_hb;
}
@@ -362,7 +341,6 @@ void TextEditor::clear_edit_menu() {
}
void TextEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY:
_load_theme_settings();
@@ -375,116 +353,90 @@ void TextEditor::_edit_option(int p_op) {
switch (p_op) {
case EDIT_UNDO: {
-
tx->undo();
tx->call_deferred("grab_focus");
} break;
case EDIT_REDO: {
-
tx->redo();
tx->call_deferred("grab_focus");
} break;
case EDIT_CUT: {
-
tx->cut();
tx->call_deferred("grab_focus");
} break;
case EDIT_COPY: {
-
tx->copy();
tx->call_deferred("grab_focus");
} break;
case EDIT_PASTE: {
-
tx->paste();
tx->call_deferred("grab_focus");
} break;
case EDIT_SELECT_ALL: {
-
tx->select_all();
tx->call_deferred("grab_focus");
} break;
case EDIT_MOVE_LINE_UP: {
-
code_editor->move_lines_up();
} break;
case EDIT_MOVE_LINE_DOWN: {
-
code_editor->move_lines_down();
} break;
case EDIT_INDENT_LEFT: {
-
tx->indent_left();
} break;
case EDIT_INDENT_RIGHT: {
-
tx->indent_right();
} break;
case EDIT_DELETE_LINE: {
-
code_editor->delete_lines();
} break;
case EDIT_CLONE_DOWN: {
-
code_editor->clone_lines_down();
} break;
case EDIT_TOGGLE_FOLD_LINE: {
-
tx->toggle_fold_line(tx->cursor_get_line());
tx->update();
} break;
case EDIT_FOLD_ALL_LINES: {
-
tx->fold_all_lines();
tx->update();
} break;
case EDIT_UNFOLD_ALL_LINES: {
-
tx->unhide_all_lines();
tx->update();
} break;
case EDIT_TRIM_TRAILING_WHITESAPCE: {
-
trim_trailing_whitespace();
} break;
case EDIT_CONVERT_INDENT_TO_SPACES: {
-
convert_indent_to_spaces();
} break;
case EDIT_CONVERT_INDENT_TO_TABS: {
-
convert_indent_to_tabs();
} break;
case EDIT_TO_UPPERCASE: {
-
_convert_case(CodeTextEditor::UPPER);
} break;
case EDIT_TO_LOWERCASE: {
-
_convert_case(CodeTextEditor::LOWER);
} break;
case EDIT_CAPITALIZE: {
-
_convert_case(CodeTextEditor::CAPITALIZE);
} break;
case SEARCH_FIND: {
-
code_editor->get_find_replace_bar()->popup_search();
} break;
case SEARCH_FIND_NEXT: {
-
code_editor->get_find_replace_bar()->search_next();
} break;
case SEARCH_FIND_PREV: {
-
code_editor->get_find_replace_bar()->search_prev();
} break;
case SEARCH_REPLACE: {
-
code_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_IN_FILES: {
-
String selected_text = code_editor->get_text_edit()->get_selection_text();
// Yep, because it doesn't make sense to instance this dialog for every single script open...
@@ -492,36 +444,29 @@ void TextEditor::_edit_option(int p_op) {
emit_signal("search_in_files_requested", selected_text);
} break;
case REPLACE_IN_FILES: {
-
String selected_text = code_editor->get_text_edit()->get_selection_text();
emit_signal("replace_in_files_requested", selected_text);
} break;
case SEARCH_GOTO_LINE: {
-
goto_line_dialog->popup_find_line(tx);
} break;
case BOOKMARK_TOGGLE: {
-
code_editor->toggle_bookmark();
} break;
case BOOKMARK_GOTO_NEXT: {
-
code_editor->goto_next_bookmark();
} break;
case BOOKMARK_GOTO_PREV: {
-
code_editor->goto_prev_bookmark();
} break;
case BOOKMARK_REMOVE_ALL: {
-
code_editor->remove_all_bookmarks();
} break;
}
}
void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
-
code_editor->convert_case(p_case);
}
@@ -529,7 +474,6 @@ void TextEditor::_bind_methods() {
}
static ScriptEditorBase *create_editor(const RES &p_resource) {
-
if (Object::cast_to<TextFile>(*p_resource)) {
return memnew(TextEditor);
}
@@ -537,17 +481,14 @@ static ScriptEditorBase *create_editor(const RES &p_resource) {
}
void TextEditor::register_editor() {
-
ScriptEditor::register_create_script_editor_function(create_editor);
}
void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
-
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid()) {
if (mb->get_button_index() == BUTTON_RIGHT) {
-
int col, row;
TextEdit *tx = code_editor->get_text_edit();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
@@ -558,7 +499,6 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (tx->is_right_click_moving_caret()) {
if (tx->is_selection_active()) {
-
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
int from_column = tx->get_selection_from_column();
@@ -591,7 +531,6 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded, Vector2 p_position) {
-
context_menu->clear();
if (p_selection) {
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT);
@@ -613,8 +552,9 @@ void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_uppercase"), EDIT_TO_UPPERCASE);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_lowercase"), EDIT_TO_LOWERCASE);
}
- if (p_can_fold || p_is_folded)
+ if (p_can_fold || p_is_folded) {
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE);
+ }
context_menu->set_position(get_global_transform().xform(p_position));
context_menu->set_size(Vector2(1, 1));
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index b41e11c3aa..9d9025a2c4 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -34,7 +34,6 @@
#include "script_editor_plugin.h"
class TextEditor : public ScriptEditorBase {
-
GDCLASS(TextEditor, ScriptEditorBase);
private:
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 7a3e571f16..b728a6700c 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -38,14 +38,11 @@ void TextureEditor::_gui_input(Ref<InputEvent> p_event) {
}
void TextureEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
-
//get_scene()->connect("node_removed",this,"_node_removed");
}
if (p_what == NOTIFICATION_DRAW) {
-
Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
@@ -60,10 +57,12 @@ void TextureEditor::_notification(int p_what) {
}
// Prevent the texture from being unpreviewable after the rescale, so that we can still see something
- if (tex_height <= 0)
+ if (tex_height <= 0) {
tex_height = 1;
- if (tex_width <= 0)
+ }
+ if (tex_width <= 0) {
tex_width = 1;
+ }
int ofs_x = (size.width - tex_width) / 2;
int ofs_y = (size.height - tex_height) / 2;
@@ -94,8 +93,9 @@ void TextureEditor::_notification(int p_what) {
Size2 rect = font->get_string_size(text);
Vector2 draw_from = size - rect + Size2(-2, font->get_ascent() - 2);
- if (draw_from.x < 0)
+ if (draw_from.x < 0) {
draw_from.x = 0;
+ }
draw_string(font, draw_from + Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
draw_string(font, draw_from - Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
@@ -104,16 +104,16 @@ void TextureEditor::_notification(int p_what) {
}
void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) {
-
- if (!is_visible())
+ if (!is_visible()) {
return;
+ }
update();
}
void TextureEditor::edit(Ref<Texture2D> p_texture) {
-
- if (!texture.is_null())
+ if (!texture.is_null()) {
texture->remove_change_receptor(this);
+ }
texture = p_texture;
@@ -126,12 +126,10 @@ void TextureEditor::edit(Ref<Texture2D> p_texture) {
}
void TextureEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &TextureEditor::_gui_input);
}
TextureEditor::TextureEditor() {
-
set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
set_custom_minimum_size(Size2(1, 150));
}
@@ -141,14 +139,13 @@ TextureEditor::~TextureEditor() {
texture->remove_change_receptor(this);
}
}
+
//
bool EditorInspectorPluginTexture::can_handle(Object *p_object) {
-
return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<StreamTexture2D>(p_object) != nullptr || Object::cast_to<LargeTexture>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr;
}
void EditorInspectorPluginTexture::parse_begin(Object *p_object) {
-
Texture2D *texture = Object::cast_to<Texture2D>(p_object);
if (!texture) {
return;
@@ -161,7 +158,6 @@ void EditorInspectorPluginTexture::parse_begin(Object *p_object) {
}
TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) {
-
Ref<EditorInspectorPluginTexture> plugin;
plugin.instance();
add_inspector_plugin(plugin);
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index 29ad0183dc..63eea2b767 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -36,7 +36,6 @@
#include "scene/resources/texture.h"
class TextureEditor : public Control {
-
GDCLASS(TextureEditor, Control);
Ref<Texture2D> texture;
@@ -62,7 +61,6 @@ public:
};
class TextureEditorPlugin : public EditorPlugin {
-
GDCLASS(TextureEditorPlugin, EditorPlugin);
public:
diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp
index 6d716951b3..59e87fb273 100644
--- a/editor/plugins/texture_layered_editor_plugin.cpp
+++ b/editor/plugins/texture_layered_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* texture_editor_plugin.cpp */
+/* texture_layered_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -48,9 +48,7 @@ void TextureLayeredEditor::_texture_rect_draw() {
}
void TextureLayeredEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
-
//get_scene()->connect("node_removed",this,"_node_removed");
}
if (p_what == NOTIFICATION_RESIZED) {
@@ -58,7 +56,6 @@ void TextureLayeredEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
@@ -67,14 +64,13 @@ void TextureLayeredEditor::_notification(int p_what) {
}
void TextureLayeredEditor::_changed_callback(Object *p_changed, const char *p_prop) {
-
- if (!is_visible())
+ if (!is_visible()) {
return;
+ }
update();
}
void TextureLayeredEditor::_update_material() {
-
materials[0]->set_shader_param("layer", layer->get_value());
materials[2]->set_shader_param("layer", layer->get_value());
materials[texture->get_layered_type()]->set_shader_param("tex", texture->get_rid());
@@ -151,7 +147,6 @@ void TextureLayeredEditor::_make_shaders() {
}
void TextureLayeredEditor::_texture_rect_update_area() {
-
Size2 size = get_size();
int tex_width = texture->get_width() * size.height / texture->get_height();
int tex_height = size.height;
@@ -162,10 +157,12 @@ void TextureLayeredEditor::_texture_rect_update_area() {
}
// Prevent the texture from being unpreviewable after the rescale, so that we can still see something
- if (tex_height <= 0)
+ if (tex_height <= 0) {
tex_height = 1;
- if (tex_width <= 0)
+ }
+ if (tex_width <= 0) {
tex_width = 1;
+ }
int ofs_x = (size.width - tex_width) / 2;
int ofs_y = (size.height - tex_height) / 2;
@@ -175,14 +172,13 @@ void TextureLayeredEditor::_texture_rect_update_area() {
}
void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) {
-
- if (!texture.is_null())
+ if (!texture.is_null()) {
texture->remove_change_receptor(this);
+ }
texture = p_texture;
if (!texture.is_null()) {
-
if (shaders[0].is_null()) {
_make_shaders();
}
@@ -213,13 +209,11 @@ void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) {
}
void TextureLayeredEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &TextureLayeredEditor::_gui_input);
ClassDB::bind_method(D_METHOD("_layer_changed"), &TextureLayeredEditor::_layer_changed);
}
TextureLayeredEditor::TextureLayeredEditor() {
-
set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED);
set_custom_minimum_size(Size2(1, 150));
texture_rect = memnew(Control);
@@ -259,14 +253,13 @@ TextureLayeredEditor::~TextureLayeredEditor() {
texture->remove_change_receptor(this);
}
}
+
//
bool EditorInspectorPluginLayeredTexture::can_handle(Object *p_object) {
-
return Object::cast_to<TextureLayered>(p_object) != nullptr;
}
void EditorInspectorPluginLayeredTexture::parse_begin(Object *p_object) {
-
TextureLayered *texture = Object::cast_to<TextureLayered>(p_object);
if (!texture) {
return;
@@ -279,7 +272,6 @@ void EditorInspectorPluginLayeredTexture::parse_begin(Object *p_object) {
}
TextureLayeredEditorPlugin::TextureLayeredEditorPlugin(EditorNode *p_node) {
-
Ref<EditorInspectorPluginLayeredTexture> plugin;
plugin.instance();
add_inspector_plugin(plugin);
diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h
index e8503e845e..4c5e06a5b8 100644
--- a/editor/plugins/texture_layered_editor_plugin.h
+++ b/editor/plugins/texture_layered_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* texture_editor_plugin.h */
+/* texture_layered_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -35,8 +35,8 @@
#include "editor/editor_plugin.h"
#include "scene/resources/shader.h"
#include "scene/resources/texture.h"
-class TextureLayeredEditor : public Control {
+class TextureLayeredEditor : public Control {
GDCLASS(TextureLayeredEditor, Control);
SpinBox *layer;
@@ -55,8 +55,9 @@ class TextureLayeredEditor : public Control {
void _update_material();
bool setting;
void _layer_changed(double) {
- if (!setting)
+ if (!setting) {
_update_material();
+ }
}
void _texture_rect_update_area();
@@ -83,7 +84,6 @@ public:
};
class TextureLayeredEditorPlugin : public EditorPlugin {
-
GDCLASS(TextureLayeredEditorPlugin, EditorPlugin);
public:
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 099c9ceb5d..9b8b111be5 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -50,19 +50,21 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
void TextureRegionEditor::_region_draw() {
Ref<Texture2D> base_tex = nullptr;
- if (node_sprite)
+ if (node_sprite) {
base_tex = node_sprite->get_texture();
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
base_tex = node_sprite_3d->get_texture();
- else if (node_ninepatch)
+ } else if (node_ninepatch) {
base_tex = node_ninepatch->get_texture();
- else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
base_tex = obj_styleBox->get_texture();
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
base_tex = atlas_tex->get_atlas();
+ }
- if (base_tex.is_null())
+ if (base_tex.is_null()) {
return;
+ }
Transform2D mtx;
mtx.elements[2] = -draw_ofs * draw_zoom;
@@ -78,45 +80,55 @@ void TextureRegionEditor::_region_draw() {
int last_cell = 0;
if (snap_step.x != 0) {
- if (snap_separation.x == 0)
+ if (snap_separation.x == 0) {
for (int i = 0; i < s.width; i++) {
int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i, 0)).x - snap_offset.x) / snap_step.x));
- if (i == 0)
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
+ }
+ if (last_cell != cell) {
edit_draw->draw_line(Point2(i, 0), Point2(i, s.height), grid_color);
+ }
last_cell = cell;
}
- else
+ } else {
for (int i = 0; i < s.width; i++) {
int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i, 0)).x - snap_offset.x) / (snap_step.x + snap_separation.x)));
- if (i == 0)
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
+ }
+ if (last_cell != cell) {
edit_draw->draw_rect(Rect2(i - snap_separation.x * draw_zoom, 0, snap_separation.x * draw_zoom, s.height), grid_color);
+ }
last_cell = cell;
}
+ }
}
if (snap_step.y != 0) {
- if (snap_separation.y == 0)
+ if (snap_separation.y == 0) {
for (int i = 0; i < s.height; i++) {
int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0, i)).y - snap_offset.y) / snap_step.y));
- if (i == 0)
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
+ }
+ if (last_cell != cell) {
edit_draw->draw_line(Point2(0, i), Point2(s.width, i), grid_color);
+ }
last_cell = cell;
}
- else
+ } else {
for (int i = 0; i < s.height; i++) {
int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0, i)).y - snap_offset.y) / (snap_step.y + snap_separation.y)));
- if (i == 0)
+ if (i == 0) {
last_cell = cell;
- if (last_cell != cell)
+ }
+ if (last_cell != cell) {
edit_draw->draw_rect(Rect2(0, i - snap_separation.y * draw_zoom, s.width, snap_separation.y * draw_zoom), grid_color);
+ }
last_cell = cell;
}
+ }
}
} else if (snap_mode == SNAP_AUTOSLICE) {
for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
@@ -152,7 +164,6 @@ void TextureRegionEditor::_region_draw() {
};
Color color = get_theme_color("mono_color", "Editor");
for (int i = 0; i < 4; i++) {
-
int prev = (i + 3) % 4;
int next = (i + 1) % 4;
@@ -161,14 +172,16 @@ void TextureRegionEditor::_region_draw() {
edit_draw->draw_line(endpoints[i] - draw_ofs * draw_zoom, endpoints[next] - draw_ofs * draw_zoom, color, 2);
- if (snap_mode != SNAP_AUTOSLICE)
+ if (snap_mode != SNAP_AUTOSLICE) {
edit_draw->draw_texture(select_handle, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor() - draw_ofs * draw_zoom);
+ }
ofs = (endpoints[next] - endpoints[i]) / 2;
ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
- if (snap_mode != SNAP_AUTOSLICE)
+ if (snap_mode != SNAP_AUTOSLICE) {
edit_draw->draw_texture(select_handle, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor() - draw_ofs * draw_zoom);
+ }
scroll_rect.expand_to(raw_endpoints[i]);
}
@@ -259,9 +272,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
if (node_ninepatch || obj_styleBox.is_valid()) {
edited_margin = -1;
@@ -309,16 +320,17 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
rect = E->get();
if (Input::get_singleton()->is_key_pressed(KEY_CONTROL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) {
Rect2 r;
- if (node_sprite)
+ if (node_sprite) {
r = node_sprite->get_region_rect();
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
r = node_sprite_3d->get_region_rect();
- else if (node_ninepatch)
+ } else if (node_ninepatch) {
r = node_ninepatch->get_region_rect();
- else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
r = obj_styleBox->get_region_rect();
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
r = atlas_tex->get_region();
+ }
rect.expand_to(r.position);
rect.expand_to(r.position + r.size);
}
@@ -349,21 +361,23 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
}
} else if (edited_margin < 0) {
drag_from = mtx.affine_inverse().xform(Vector2(mb->get_position().x, mb->get_position().y));
- if (snap_mode == SNAP_PIXEL)
+ if (snap_mode == SNAP_PIXEL) {
drag_from = drag_from.snapped(Vector2(1, 1));
- else if (snap_mode == SNAP_GRID)
+ } else if (snap_mode == SNAP_GRID) {
drag_from = snap_point(drag_from);
+ }
drag = true;
- if (node_sprite)
+ if (node_sprite) {
rect_prev = node_sprite->get_region_rect();
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
rect_prev = node_sprite_3d->get_region_rect();
- else if (node_ninepatch)
+ } else if (node_ninepatch) {
rect_prev = node_ninepatch->get_region_rect();
- else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
rect_prev = obj_styleBox->get_region_rect();
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
rect_prev = atlas_tex->get_region();
+ }
for (int i = 0; i < 8; i++) {
Vector2 tuv = endpoints[i];
@@ -421,15 +435,16 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
}
} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
-
if (drag) {
drag = false;
if (edited_margin >= 0) {
static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
- if (node_ninepatch)
+ if (node_ninepatch) {
node_ninepatch->set_patch_margin(m[edited_margin], prev_margin);
- if (obj_styleBox.is_valid())
+ }
+ if (obj_styleBox.is_valid()) {
obj_styleBox->set_margin_size(m[edited_margin], prev_margin);
+ }
edited_margin = -1;
} else {
apply_rect(rect_prev);
@@ -448,41 +463,43 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid()) {
-
if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
-
Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
hscroll->set_value(hscroll->get_value() - dragged.x);
vscroll->set_value(vscroll->get_value() - dragged.y);
} else if (drag) {
-
if (edited_margin >= 0) {
float new_margin = 0;
- if (edited_margin == 0)
+ if (edited_margin == 0) {
new_margin = prev_margin + (mm->get_position().y - drag_from.y) / draw_zoom;
- else if (edited_margin == 1)
+ } else if (edited_margin == 1) {
new_margin = prev_margin - (mm->get_position().y - drag_from.y) / draw_zoom;
- else if (edited_margin == 2)
+ } else if (edited_margin == 2) {
new_margin = prev_margin + (mm->get_position().x - drag_from.x) / draw_zoom;
- else if (edited_margin == 3)
+ } else if (edited_margin == 3) {
new_margin = prev_margin - (mm->get_position().x - drag_from.x) / draw_zoom;
- else
+ } else {
ERR_PRINT("Unexpected edited_margin");
+ }
- if (new_margin < 0)
+ if (new_margin < 0) {
new_margin = 0;
+ }
static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
- if (node_ninepatch)
+ if (node_ninepatch) {
node_ninepatch->set_patch_margin(m[edited_margin], new_margin);
- if (obj_styleBox.is_valid())
+ }
+ if (obj_styleBox.is_valid()) {
obj_styleBox->set_margin_size(m[edited_margin], new_margin);
+ }
} else {
Vector2 new_pos = mtx.affine_inverse().xform(mm->get_position());
- if (snap_mode == SNAP_PIXEL)
+ if (snap_mode == SNAP_PIXEL) {
new_pos = new_pos.snapped(Vector2(1, 1));
- else if (snap_mode == SNAP_GRID)
+ } else if (snap_mode == SNAP_GRID) {
new_pos = snap_point(new_pos);
+ }
if (creating) {
rect = Rect2(drag_from, Size2());
@@ -560,8 +577,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
}
void TextureRegionEditor::_scroll_changed(float) {
- if (updating_scroll)
+ if (updating_scroll) {
return;
+ }
draw_ofs.x = hscroll->get_value();
draw_ofs.y = vscroll->get_value();
@@ -571,10 +589,11 @@ void TextureRegionEditor::_scroll_changed(float) {
void TextureRegionEditor::_set_snap_mode(int p_mode) {
snap_mode = p_mode;
- if (snap_mode == SNAP_GRID)
+ if (snap_mode == SNAP_GRID) {
hb_grid->show();
- else
+ } else {
hb_grid->hide();
+ }
if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) {
_update_autoslice();
@@ -614,8 +633,9 @@ void TextureRegionEditor::_set_snap_sep_y(float p_val) {
}
void TextureRegionEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
- if (p_zoom < 0.25 || p_zoom > 8)
+ if (p_zoom < 0.25 || p_zoom > 8) {
return;
+ }
float prev_zoom = draw_zoom;
draw_zoom = p_zoom;
@@ -640,32 +660,34 @@ void TextureRegionEditor::_zoom_out() {
}
void TextureRegionEditor::apply_rect(const Rect2 &p_rect) {
- if (node_sprite)
+ if (node_sprite) {
node_sprite->set_region_rect(p_rect);
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
node_sprite_3d->set_region_rect(p_rect);
- else if (node_ninepatch)
+ } else if (node_ninepatch) {
node_ninepatch->set_region_rect(p_rect);
- else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
obj_styleBox->set_region_rect(p_rect);
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
atlas_tex->set_region(p_rect);
+ }
}
void TextureRegionEditor::_update_rect() {
- if (node_sprite)
+ if (node_sprite) {
rect = node_sprite->get_region_rect();
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
rect = node_sprite_3d->get_region_rect();
- else if (node_ninepatch) {
+ } else if (node_ninepatch) {
rect = node_ninepatch->get_region_rect();
if (rect == Rect2()) {
rect = Rect2(Vector2(), node_ninepatch->get_texture()->get_size());
}
- } else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
rect = obj_styleBox->get_region_rect();
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
rect = atlas_tex->get_region();
+ }
}
void TextureRegionEditor::_update_autoslice() {
@@ -673,16 +695,17 @@ void TextureRegionEditor::_update_autoslice() {
autoslice_cache.clear();
Ref<Texture2D> texture = nullptr;
- if (node_sprite)
+ if (node_sprite) {
texture = node_sprite->get_texture();
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
texture = node_sprite_3d->get_texture();
- else if (node_ninepatch)
+ } else if (node_ninepatch) {
texture = node_ninepatch->get_texture();
- else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
texture = obj_styleBox->get_texture();
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
texture = atlas_tex->get_atlas();
+ }
if (texture.is_null()) {
return;
@@ -707,8 +730,9 @@ void TextureRegionEditor::_update_autoslice() {
autoslice_cache.erase(F->prev());
queue_erase = false;
}
- if (F == E)
+ if (F == E) {
continue;
+ }
if (E->get().grow(1).intersects(F->get())) {
E->get().expand_to(F->get().position);
E->get().expand_to(F->get().position + F->get().size);
@@ -788,7 +812,6 @@ bool TextureRegionEditor::is_stylebox() {
}
bool TextureRegionEditor::is_atlas_texture() {
-
return atlas_tex.is_valid();
}
@@ -805,24 +828,31 @@ Sprite2D *TextureRegionEditor::get_sprite() {
}
void TextureRegionEditor::edit(Object *p_obj) {
- if (node_sprite)
+ if (node_sprite) {
node_sprite->remove_change_receptor(this);
- if (node_sprite_3d)
+ }
+ if (node_sprite_3d) {
node_sprite_3d->remove_change_receptor(this);
- if (node_ninepatch)
+ }
+ if (node_ninepatch) {
node_ninepatch->remove_change_receptor(this);
- if (obj_styleBox.is_valid())
+ }
+ if (obj_styleBox.is_valid()) {
obj_styleBox->remove_change_receptor(this);
- if (atlas_tex.is_valid())
+ }
+ if (atlas_tex.is_valid()) {
atlas_tex->remove_change_receptor(this);
+ }
if (p_obj) {
node_sprite = Object::cast_to<Sprite2D>(p_obj);
node_sprite_3d = Object::cast_to<Sprite3D>(p_obj);
node_ninepatch = Object::cast_to<NinePatchRect>(p_obj);
- if (Object::cast_to<StyleBoxTexture>(p_obj))
+ if (Object::cast_to<StyleBoxTexture>(p_obj)) {
obj_styleBox = Ref<StyleBoxTexture>(Object::cast_to<StyleBoxTexture>(p_obj));
- if (Object::cast_to<AtlasTexture>(p_obj))
+ }
+ if (Object::cast_to<AtlasTexture>(p_obj)) {
atlas_tex = Ref<AtlasTexture>(Object::cast_to<AtlasTexture>(p_obj));
+ }
p_obj->add_change_receptor(this);
_edit_region();
} else {
@@ -842,25 +872,27 @@ void TextureRegionEditor::edit(Object *p_obj) {
}
void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) {
-
- if (!is_visible())
+ if (!is_visible()) {
return;
- if (p_prop == StringName("atlas") || p_prop == StringName("texture"))
+ }
+ if (p_prop == StringName("atlas") || p_prop == StringName("texture")) {
_edit_region();
+ }
}
void TextureRegionEditor::_edit_region() {
Ref<Texture2D> texture = nullptr;
- if (node_sprite)
+ if (node_sprite) {
texture = node_sprite->get_texture();
- else if (node_sprite_3d)
+ } else if (node_sprite_3d) {
texture = node_sprite_3d->get_texture();
- else if (node_ninepatch)
+ } else if (node_ninepatch) {
texture = node_ninepatch->get_texture();
- else if (obj_styleBox.is_valid())
+ } else if (obj_styleBox.is_valid()) {
texture = obj_styleBox->get_texture();
- else if (atlas_tex.is_valid())
+ } else if (atlas_tex.is_valid()) {
texture = atlas_tex->get_atlas();
+ }
if (texture.is_null()) {
_zoom_reset();
@@ -1063,7 +1095,6 @@ void TextureRegionEditorPlugin::make_visible(bool p_visible) {
}
Dictionary TextureRegionEditorPlugin::get_state() const {
-
Dictionary state;
state["snap_offset"] = region_editor->snap_offset;
state["snap_step"] = region_editor->snap_step;
@@ -1073,7 +1104,6 @@ Dictionary TextureRegionEditorPlugin::get_state() const {
}
void TextureRegionEditorPlugin::set_state(const Dictionary &p_state) {
-
Dictionary state = p_state;
if (state.has("snap_step")) {
Vector2 s = state["snap_step"];
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index c6cd648842..93da23fd50 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -45,7 +45,6 @@
*/
class TextureRegionEditor : public VBoxContainer {
-
GDCLASS(TextureRegionEditor, VBoxContainer);
enum SnapMode {
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index d9be2e32cb..eb028659fd 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -36,44 +36,38 @@
#include "scene/gui/progress_bar.h"
void ThemeEditor::edit(const Ref<Theme> &p_theme) {
-
theme = p_theme;
main_panel->set_theme(p_theme);
main_container->set_theme(p_theme);
}
void ThemeEditor::_propagate_redraw(Control *p_at) {
-
p_at->notification(NOTIFICATION_THEME_CHANGED);
p_at->minimum_size_changed();
p_at->update();
for (int i = 0; i < p_at->get_child_count(); i++) {
Control *a = Object::cast_to<Control>(p_at->get_child(i));
- if (a)
+ if (a) {
_propagate_redraw(a);
+ }
}
}
void ThemeEditor::_refresh_interval() {
-
_propagate_redraw(main_panel);
_propagate_redraw(main_container);
}
void ThemeEditor::_type_menu_cbk(int p_option) {
-
type_edit->set_text(type_menu->get_popup()->get_item_text(p_option));
}
void ThemeEditor::_name_menu_about_to_show() {
-
String fromtype = type_edit->get_text();
List<StringName> names;
if (popup_mode == POPUP_ADD) {
-
switch (type_select->get_selected()) {
-
case 0:
Theme::get_default()->get_icon_list(fromtype, &names);
break;
@@ -91,7 +85,6 @@ void ThemeEditor::_name_menu_about_to_show() {
break;
}
} else if (popup_mode == POPUP_REMOVE) {
-
theme->get_icon_list(fromtype, &names);
theme->get_stylebox_list(fromtype, &names);
theme->get_font_list(fromtype, &names);
@@ -102,21 +95,17 @@ void ThemeEditor::_name_menu_about_to_show() {
name_menu->get_popup()->clear();
name_menu->get_popup()->set_size(Size2());
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
name_menu->get_popup()->add_item(E->get());
}
}
void ThemeEditor::_name_menu_cbk(int p_option) {
-
name_edit->set_text(name_menu->get_popup()->get_item_text(p_option));
}
struct _TECategory {
-
template <class T>
struct RefItem {
-
Ref<T> item;
StringName name;
bool operator<(const RefItem<T> &p) const { return item->get_instance_id() < p.item->get_instance_id(); }
@@ -124,7 +113,6 @@ struct _TECategory {
template <class T>
struct Item {
-
T item;
String name;
bool operator<(const Item<T> &p) const { return name < p.name; }
@@ -139,7 +127,6 @@ struct _TECategory {
};
void ThemeEditor::_save_template_cbk(String fname) {
-
String filename = file_dialog->get_current_path();
Map<String, _TECategory> categories;
@@ -153,7 +140,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
// Fill default theme.
for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) {
-
_TECategory &tc = E->get();
List<StringName> stylebox_list;
@@ -270,55 +256,55 @@ void ThemeEditor::_save_template_cbk(String fname) {
// Write default theme.
for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) {
-
_TECategory &tc = E->get();
String underline = "; ";
- for (int i = 0; i < E->key().length(); i++)
+ for (int i = 0; i < E->key().length(); i++) {
underline += "*";
+ }
file->store_line("");
file->store_line(underline);
file->store_line("; " + E->key());
file->store_line(underline);
- if (tc.stylebox_items.size())
+ if (tc.stylebox_items.size()) {
file->store_line("\n; StyleBox Items:\n");
+ }
for (Set<_TECategory::RefItem<StyleBox>>::Element *F = tc.stylebox_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
- if (tc.font_items.size())
+ if (tc.font_items.size()) {
file->store_line("\n; Font Items:\n");
+ }
for (Set<_TECategory::RefItem<Font>>::Element *F = tc.font_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
- if (tc.icon_items.size())
+ if (tc.icon_items.size()) {
file->store_line("\n; Icon Items:\n");
+ }
for (Set<_TECategory::RefItem<Texture2D>>::Element *F = tc.icon_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
- if (tc.color_items.size())
+ if (tc.color_items.size()) {
file->store_line("\n; Color Items:\n");
+ }
for (Set<_TECategory::Item<Color>>::Element *F = tc.color_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
- if (tc.constant_items.size())
+ if (tc.constant_items.size()) {
file->store_line("\n; Constant Items:\n");
+ }
for (Set<_TECategory::Item<int>>::Element *F = tc.constant_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
}
@@ -328,12 +314,9 @@ void ThemeEditor::_save_template_cbk(String fname) {
}
void ThemeEditor::_dialog_cbk() {
-
switch (popup_mode) {
case POPUP_ADD: {
-
switch (type_select->get_selected()) {
-
case 0:
theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>());
break;
@@ -353,7 +336,6 @@ void ThemeEditor::_dialog_cbk() {
} break;
case POPUP_CLASS_ADD: {
-
StringName fromtype = type_edit->get_text();
List<StringName> names;
@@ -395,7 +377,6 @@ void ThemeEditor::_dialog_cbk() {
} break;
case POPUP_REMOVE: {
switch (type_select->get_selected()) {
-
case 0:
theme->clear_icon(name_edit->get_text(), type_edit->get_text());
break;
@@ -459,9 +440,7 @@ void ThemeEditor::_dialog_cbk() {
}
void ThemeEditor::_theme_menu_cbk(int p_option) {
-
if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) {
-
bool import = (p_option == POPUP_IMPORT_EDITOR_THEME);
Ref<Theme> base_theme;
@@ -473,7 +452,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
}
{
-
List<StringName> types;
base_theme->get_type_list(&types);
@@ -555,7 +533,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
type_select->hide();
} else if (p_option == POPUP_REMOVE) {
-
add_del_dialog->set_title(TTR("Remove Item"));
add_del_dialog->get_ok()->set_text(TTR("Remove"));
add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
@@ -563,7 +540,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
base_theme = theme;
} else if (p_option == POPUP_CLASS_REMOVE) {
-
add_del_dialog->set_title(TTR("Remove All Items"));
add_del_dialog->get_ok()->set_text(TTR("Remove All"));
add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
@@ -589,30 +565,27 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
List<StringName> new_types;
theme->get_type_list(&new_types);
for (List<StringName>::Element *F = new_types.front(); F; F = F->next()) {
-
bool found = false;
for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
-
if (E->get() == F->get()) {
found = true;
break;
}
}
- if (!found)
+ if (!found) {
types.push_back(F->get());
+ }
}
}
types.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
-
type_menu->get_popup()->add_item(E->get());
}
}
void ThemeEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_PROCESS: {
time_left -= get_process_delta_time();
@@ -631,7 +604,6 @@ void ThemeEditor::_bind_methods() {
}
ThemeEditor::ThemeEditor() {
-
time_left = 0;
HBoxContainer *top_menu = memnew(HBoxContainer);
@@ -901,7 +873,6 @@ ThemeEditor::ThemeEditor() {
}
void ThemeEditorPlugin::edit(Object *p_node) {
-
if (Object::cast_to<Theme>(p_node)) {
theme_editor->edit(Object::cast_to<Theme>(p_node));
} else {
@@ -910,27 +881,25 @@ void ThemeEditorPlugin::edit(Object *p_node) {
}
bool ThemeEditorPlugin::handles(Object *p_node) const {
-
return p_node->is_class("Theme");
}
void ThemeEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
theme_editor->set_process(true);
button->show();
editor->make_bottom_panel_item_visible(theme_editor);
} else {
theme_editor->set_process(false);
- if (theme_editor->is_visible_in_tree())
+ if (theme_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
button->hide();
}
}
ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
theme_editor = memnew(ThemeEditor);
theme_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index c51583593d..983bfb6b50 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -42,7 +42,6 @@
#include "editor/editor_node.h"
class ThemeEditor : public VBoxContainer {
-
GDCLASS(ThemeEditor, VBoxContainer);
Panel *main_panel;
@@ -99,7 +98,6 @@ public:
};
class ThemeEditorPlugin : public EditorPlugin {
-
GDCLASS(ThemeEditorPlugin, EditorPlugin);
ThemeEditor *theme_editor;
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index e22e0cc052..3281a59c1c 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -39,18 +39,14 @@
#include "scene/gui/split_container.h"
void TileMapEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
}
}
void TileMapEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_PROCESS: {
-
if (bucket_queue.size()) {
CanvasItemEditor::get_singleton()->update_viewport();
}
@@ -58,13 +54,11 @@ void TileMapEditor::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
-
get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
[[fallthrough]];
}
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
if (is_visible_in_tree()) {
_update_palette();
}
@@ -97,7 +91,6 @@ void TileMapEditor::_notification(int p_what) {
}
void TileMapEditor::_update_button_tool() {
-
ToolButton *tb[4] = { paint_button, bucket_fill_button, picker_button, select_button };
// Unpress all buttons
for (int i = 0; i < 4; i++) {
@@ -123,8 +116,9 @@ void TileMapEditor::_update_button_tool() {
break;
}
- if (tool != TOOL_PICKING)
+ if (tool != TOOL_PICKING) {
last_tool = tool;
+ }
}
void TileMapEditor::_button_tool_select(int p_tool) {
@@ -132,7 +126,6 @@ void TileMapEditor::_button_tool_select(int p_tool) {
_update_button_tool();
switch (tool) {
case TOOL_SELECTING: {
-
selection_active = false;
} break;
default:
@@ -142,10 +135,8 @@ void TileMapEditor::_button_tool_select(int p_tool) {
}
void TileMapEditor::_menu_option(int p_option) {
-
switch (p_option) {
case OPTION_COPY: {
-
_update_copydata();
if (selection_active) {
@@ -155,9 +146,9 @@ void TileMapEditor::_menu_option(int p_option) {
}
} break;
case OPTION_ERASE_SELECTION: {
-
- if (!selection_active)
+ if (!selection_active) {
return;
+ }
_start_undo(TTR("Erase Selection"));
_erase_selection();
@@ -169,7 +160,6 @@ void TileMapEditor::_menu_option(int p_option) {
CanvasItemEditor::get_singleton()->update_viewport();
} break;
case OPTION_FIX_INVALID: {
-
undo_redo->create_action(TTR("Fix Invalid Tiles"));
undo_redo->add_undo_method(node, "set", "tile_data", node->get("tile_data"));
node->fix_invalid_tiles();
@@ -178,7 +168,6 @@ void TileMapEditor::_menu_option(int p_option) {
} break;
case OPTION_CUT: {
-
if (selection_active) {
_update_copydata();
@@ -205,20 +194,32 @@ void TileMapEditor::_palette_multi_selected(int index, bool selected) {
_update_palette();
}
-void TileMapEditor::_canvas_mouse_enter() {
+void TileMapEditor::_palette_input(const Ref<InputEvent> &p_event) {
+ const Ref<InputEventMouseButton> mb = p_event;
+
+ // Zoom in/out using Ctrl + mouse wheel.
+ if (mb.is_valid() && mb->is_pressed() && mb->get_command()) {
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_UP) {
+ size_slider->set_value(size_slider->get_value() + 0.2);
+ }
+
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_DOWN) {
+ size_slider->set_value(size_slider->get_value() - 0.2);
+ }
+ }
+}
+void TileMapEditor::_canvas_mouse_enter() {
mouse_over = true;
CanvasItemEditor::get_singleton()->update_viewport();
}
void TileMapEditor::_canvas_mouse_exit() {
-
mouse_over = false;
CanvasItemEditor::get_singleton()->update_viewport();
}
Vector<int> TileMapEditor::get_selected_tiles() const {
-
Vector<int> items = palette->get_selected_items();
if (items.size() == 0) {
@@ -233,7 +234,6 @@ Vector<int> TileMapEditor::get_selected_tiles() const {
}
void TileMapEditor::set_selected_tiles(Vector<int> p_tiles) {
-
palette->unselect_all();
for (int i = p_tiles.size() - 1; i >= 0; i--) {
@@ -248,7 +248,6 @@ void TileMapEditor::set_selected_tiles(Vector<int> p_tiles) {
}
Dictionary TileMapEditor::_create_cell_dictionary(int tile, bool flip_x, bool flip_y, bool transpose, Vector2 autotile_coord) {
-
Dictionary cell;
cell["id"] = tile;
@@ -261,7 +260,6 @@ Dictionary TileMapEditor::_create_cell_dictionary(int tile, bool flip_x, bool fl
}
void TileMapEditor::_create_set_cell_undo_redo(const Vector2 &p_vec, const CellOp &p_cell_old, const CellOp &p_cell_new) {
-
Dictionary cell_old = _create_cell_dictionary(p_cell_old.idx, p_cell_old.xf, p_cell_old.yf, p_cell_old.tr, p_cell_old.ac);
Dictionary cell_new = _create_cell_dictionary(p_cell_new.idx, p_cell_new.xf, p_cell_new.yf, p_cell_new.tr, p_cell_new.ac);
@@ -270,13 +268,11 @@ void TileMapEditor::_create_set_cell_undo_redo(const Vector2 &p_vec, const CellO
}
void TileMapEditor::_start_undo(const String &p_action) {
-
undo_data.clear();
undo_redo->create_action(p_action);
}
void TileMapEditor::_finish_undo() {
-
if (undo_data.size()) {
for (Map<Point2i, CellOp>::Element *E = undo_data.front(); E; E = E->next()) {
_create_set_cell_undo_redo(E->key(), E->get(), _get_op_from_cell(E->key()));
@@ -289,11 +285,11 @@ void TileMapEditor::_finish_undo() {
}
void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord) {
-
ERR_FAIL_COND(!node);
- if (p_values.size() == 0)
+ if (p_values.size() == 0) {
return;
+ }
int p_value = p_values[Math::rand() % p_values.size()];
int prev_val = node->get_cell(p_pos.x, p_pos.y);
@@ -319,8 +315,9 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
position = prev_position;
}
- if (p_value == prev_val && p_flip_h == prev_flip_h && p_flip_v == prev_flip_v && p_transpose == prev_transpose && prev_position == position)
+ if (p_value == prev_val && p_flip_h == prev_flip_h && p_flip_v == prev_flip_v && p_transpose == prev_transpose && prev_position == position) {
return; // Check that it's actually different.
+ }
for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) {
for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) {
@@ -333,8 +330,9 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
node->_set_celld(p_pos, _create_cell_dictionary(p_value, p_flip_h, p_flip_v, p_transpose, p_autotile_coord));
- if (tool == TOOL_PASTING)
+ if (tool == TOOL_PASTING) {
return;
+ }
if (manual_autotile || (p_value != -1 && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE)) {
if (current != -1) {
@@ -360,7 +358,6 @@ void TileMapEditor::_priority_toggled(bool p_enabled) {
}
void TileMapEditor::_text_entered(const String &p_text) {
-
canvas_item_editor_viewport->grab_focus();
}
@@ -369,14 +366,12 @@ void TileMapEditor::_text_changed(const String &p_text) {
}
void TileMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
-
Ref<InputEventKey> k = p_ie;
if (k.is_valid() && (k->get_keycode() == KEY_UP ||
k->get_keycode() == KEY_DOWN ||
k->get_keycode() == KEY_PAGEUP ||
k->get_keycode() == KEY_PAGEDOWN)) {
-
palette->call("_gui_input", k);
search_box->accept_event();
}
@@ -396,9 +391,9 @@ struct _PaletteEntry {
} // namespace
void TileMapEditor::_update_palette() {
-
- if (!node)
+ if (!node) {
return;
+ }
// Update the clear button.
clear_transform_button->set_disabled(!flip_h && !flip_v && !transpose);
@@ -424,8 +419,9 @@ void TileMapEditor::_update_palette() {
List<int> tiles;
tileset->get_tile_list(&tiles);
- if (tiles.empty())
+ if (tiles.empty()) {
return;
+ }
float min_size = EDITOR_DEF("editors/tile_map/preview_size", 64);
min_size *= EDSCALE;
@@ -447,7 +443,6 @@ void TileMapEditor::_update_palette() {
Vector<_PaletteEntry> entries;
for (List<int>::Element *E = tiles.front(); E; E = E->next()) {
-
String name = tileset->tile_get_name(E->get());
if (name != "") {
@@ -462,8 +457,9 @@ void TileMapEditor::_update_palette() {
name = "#" + itos(E->get());
}
- if (filter != "" && !filter.is_subsequence_ofi(name))
+ if (filter != "" && !filter.is_subsequence_ofi(name)) {
continue;
+ }
const _PaletteEntry entry = { E->get(), name };
entries.push_back(entry);
@@ -474,7 +470,6 @@ void TileMapEditor::_update_palette() {
}
for (int i = 0; i < entries.size(); i++) {
-
if (show_tile_names) {
palette->add_item(entries[i].name);
} else {
@@ -502,8 +497,9 @@ void TileMapEditor::_update_palette() {
}
// Set region.
- if (region.size != Size2())
+ if (region.size != Size2()) {
palette->set_item_icon_region(palette->get_item_count() - 1, region);
+ }
// Set icon.
palette->set_item_icon(palette->get_item_count() - 1, tex);
@@ -526,7 +522,6 @@ void TileMapEditor::_update_palette() {
}
if (sel_tile != TileMap::INVALID_CELL && ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || (!priority_atlastile && tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE))) {
-
const Map<Vector2, uint32_t> &tiles2 = tileset->autotile_get_bitmask_map(sel_tile);
Vector<Vector2> entries2;
@@ -544,18 +539,17 @@ void TileMapEditor::_update_palette() {
Ref<Texture2D> tex = tileset->tile_get_texture(sel_tile);
for (int i = 0; i < entries2.size(); i++) {
-
manual_palette->add_item(String());
if (tex.is_valid()) {
-
Rect2 region = tileset->tile_get_region(sel_tile);
int spacing = tileset->autotile_get_spacing(sel_tile);
region.size = tileset->autotile_get_size(sel_tile); // !!
region.position += (region.size + Vector2(spacing, spacing)) * entries2[i];
- if (!region.has_no_area())
+ if (!region.has_no_area()) {
manual_palette->set_item_icon_region(manual_palette->get_item_count() - 1, region);
+ }
manual_palette->set_item_icon(manual_palette->get_item_count() - 1, tex);
}
@@ -566,10 +560,12 @@ void TileMapEditor::_update_palette() {
if (manual_palette->get_item_count() > 0) {
// Only show the manual palette if at least tile exists in it.
- if (selected_manual == -1 || selected_single != palette->get_current())
+ if (selected_manual == -1 || selected_single != palette->get_current()) {
selected_manual = 0;
- if (selected_manual < manual_palette->get_item_count())
+ }
+ if (selected_manual < manual_palette->get_item_count()) {
manual_palette->set_current(selected_manual);
+ }
manual_palette->show();
}
@@ -583,11 +579,11 @@ void TileMapEditor::_update_palette() {
}
void TileMapEditor::_pick_tile(const Point2 &p_pos) {
-
int id = node->get_cell(p_pos.x, p_pos.y);
- if (id == TileMap::INVALID_CELL)
+ if (id == TileMap::INVALID_CELL) {
return;
+ }
if (search_box->get_text() != "") {
search_box->set_text("");
@@ -612,15 +608,15 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
}
Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) {
-
int prev_id = node->get_cell(p_start.x, p_start.y);
Vector<int> ids;
ids.push_back(TileMap::INVALID_CELL);
if (!erase) {
ids = get_selected_tiles();
- if (ids.size() == 0 || ids[0] == TileMap::INVALID_CELL)
+ if (ids.size() == 0 || ids[0] == TileMap::INVALID_CELL) {
return Vector<Vector2>();
+ }
} else if (prev_id == TileMap::INVALID_CELL) {
return Vector<Vector2>();
}
@@ -637,8 +633,9 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase,
// Test if we can re-use the result from preview bucket fill
bool invalidate_cache = false;
// Area changed
- if (r != bucket_cache_rect)
+ if (r != bucket_cache_rect) {
_clear_bucket_cache();
+ }
// Cache grid is not initialized
if (bucket_cache_visited == nullptr) {
bucket_cache_visited = new bool[area];
@@ -651,8 +648,9 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase,
invalidate_cache = true;
}
if (invalidate_cache) {
- for (int i = 0; i < area; ++i)
+ for (int i = 0; i < area; ++i) {
bucket_cache_visited[i] = false;
+ }
bucket_cache = Vector<Vector2>();
bucket_cache_tile = prev_id;
bucket_cache_rect = r;
@@ -674,24 +672,25 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase,
bucket_queue.push_back(p_start);
while (bucket_queue.size()) {
-
Point2i n = bucket_queue.front()->get();
bucket_queue.pop_front();
- if (!r.has_point(n))
+ if (!r.has_point(n)) {
continue;
+ }
if (node->get_cell(n.x, n.y) == prev_id) {
-
if (preview) {
int loc = (n.x - r.position.x) + (n.y - r.position.y) * r.get_size().x;
- if (bucket_cache_visited[loc])
+ if (bucket_cache_visited[loc]) {
continue;
+ }
bucket_cache_visited[loc] = true;
bucket_cache.push_back(n);
} else {
- if (non_preview_cache.find(n) >= 0)
+ if (non_preview_cache.find(n) >= 0) {
continue;
+ }
points.push_back(n);
non_preview_cache.push_back(n);
}
@@ -712,7 +711,6 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase,
}
void TileMapEditor::_fill_points(const Vector<Vector2> &p_points, const Dictionary &p_op) {
-
int len = p_points.size();
const Vector2 *pr = p_points.ptr();
@@ -725,32 +723,28 @@ void TileMapEditor::_fill_points(const Vector<Vector2> &p_points, const Dictiona
_set_cell(pr[i], ids, xf, yf, tr);
node->make_bitmask_area_dirty(pr[i]);
}
- if (!manual_autotile)
+ if (!manual_autotile) {
node->update_dirty_bitmask();
+ }
}
void TileMapEditor::_erase_points(const Vector<Vector2> &p_points) {
-
int len = p_points.size();
const Vector2 *pr = p_points.ptr();
for (int i = 0; i < len; i++) {
-
_set_cell(pr[i], invalid_cell);
}
}
void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) {
-
Point2i begin = p_from;
Point2i end = p_to;
if (begin.x > end.x) {
-
SWAP(begin.x, end.x);
}
if (begin.y > end.y) {
-
SWAP(begin.y, end.y);
}
@@ -761,23 +755,23 @@ void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) {
}
void TileMapEditor::_erase_selection() {
- if (!selection_active)
+ if (!selection_active) {
return;
+ }
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
-
_set_cell(Point2i(j, i), invalid_cell, false, false, false);
}
}
}
void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) {
-
Ref<Texture2D> t = node->get_tileset()->tile_get_texture(p_cell);
- if (t.is_null())
+ if (t.is_null()) {
return;
+ }
Vector2 tile_ofs = node->get_tileset()->tile_get_texture_offset(p_cell);
@@ -814,11 +808,13 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
if (compatibility_mode_enabled && !centered_texture) {
if (rect.size.y > rect.size.x) {
- if ((p_flip_h && (p_flip_v || p_transpose)) || (p_flip_v && !p_transpose))
+ if ((p_flip_h && (p_flip_v || p_transpose)) || (p_flip_v && !p_transpose)) {
tile_ofs.y += rect.size.y - rect.size.x;
+ }
} else if (rect.size.y < rect.size.x) {
- if ((p_flip_v && (p_flip_h || p_transpose)) || (p_flip_h && !p_transpose))
+ if ((p_flip_v && (p_flip_h || p_transpose)) || (p_flip_h && !p_transpose)) {
tile_ofs.x += rect.size.x - rect.size.y;
+ }
}
}
@@ -844,37 +840,38 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
if (compatibility_mode_enabled && !centered_texture) {
if (node->get_tile_origin() == TileMap::TILE_ORIGIN_TOP_LEFT) {
-
rect.position += tile_ofs;
} else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_BOTTOM_LEFT) {
-
rect.position += tile_ofs;
if (p_transpose) {
- if (p_flip_h)
+ if (p_flip_h) {
rect.position.x -= cell_size.x;
- else
+ } else {
rect.position.x += cell_size.x;
+ }
} else {
- if (p_flip_v)
+ if (p_flip_v) {
rect.position.y -= cell_size.y;
- else
+ } else {
rect.position.y += cell_size.y;
+ }
}
} else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_CENTER) {
-
rect.position += tile_ofs;
- if (p_flip_h)
+ if (p_flip_h) {
rect.position.x -= cell_size.x / 2;
- else
+ } else {
rect.position.x += cell_size.x / 2;
+ }
- if (p_flip_v)
+ if (p_flip_v) {
rect.position.y -= cell_size.y / 2;
- else
+ } else {
rect.position.y += cell_size.y / 2;
+ }
}
} else {
rect.position += tile_ofs;
@@ -894,7 +891,6 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p
}
void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) {
-
Vector<Vector2> points = _bucket_fill(p_point, false, true);
const Vector2 *pr = points.ptr();
int len = points.size();
@@ -912,16 +908,14 @@ void TileMapEditor::_clear_bucket_cache() {
}
void TileMapEditor::_update_copydata() {
-
copydata.clear();
- if (!selection_active)
+ if (!selection_active) {
return;
+ }
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
-
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
-
TileData tcd;
tcd.cell = node->get_cell(j, i);
@@ -939,7 +933,6 @@ void TileMapEditor::_update_copydata() {
}
static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
-
Vector<Point2i> points;
float dx = ABS(x1 - x0);
@@ -983,9 +976,9 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
}
bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
-
- if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree() || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT)
+ if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree() || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT) {
return false;
+ }
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
Transform2D xform_inv = xform.affine_inverse();
@@ -994,20 +987,18 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid()) {
if (mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
-
- if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
return false; // Drag.
+ }
if (tool == TOOL_NONE) {
-
if (mb->get_shift()) {
-
- if (mb->get_command())
+ if (mb->get_command()) {
tool = TOOL_RECTANGLE_PAINT;
- else
+ } else {
tool = TOOL_LINE_PAINT;
+ }
selection_active = false;
rectangle_begin = over_tile;
@@ -1029,20 +1020,16 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_PAINTING) {
-
Vector<int> ids = get_selected_tiles();
if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
-
tool = TOOL_PAINTING;
_start_undo(TTR("Paint TileMap"));
}
} else if (tool == TOOL_PICKING) {
-
_pick_tile(over_tile);
} else if (tool == TOOL_SELECTING) {
-
selection_active = true;
rectangle_begin = over_tile;
}
@@ -1053,27 +1040,21 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else {
// Mousebutton was released.
if (tool != TOOL_NONE) {
-
if (tool == TOOL_PAINTING) {
-
Vector<int> ids = get_selected_tiles();
if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
-
_set_cell(over_tile, ids, flip_h, flip_v, transpose);
_finish_undo();
paint_undo.clear();
}
} else if (tool == TOOL_LINE_PAINT) {
-
Vector<int> ids = get_selected_tiles();
if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
-
_start_undo(TTR("Line Draw"));
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
-
_set_cell(E->key(), ids, flip_h, flip_v, transpose);
}
_finish_undo();
@@ -1083,15 +1064,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
}
} else if (tool == TOOL_RECTANGLE_PAINT) {
-
Vector<int> ids = get_selected_tiles();
if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
-
_start_undo(TTR("Rectangle Paint"));
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
-
_set_cell(Point2i(j, i), ids, flip_h, flip_v, transpose);
}
}
@@ -1100,14 +1078,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
CanvasItemEditor::get_singleton()->update_viewport();
}
} else if (tool == TOOL_PASTING) {
-
Point2 ofs = over_tile - rectangle.position;
Vector<int> ids;
_start_undo(TTR("Paste"));
ids.push_back(0);
for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) {
-
ids.write[0] = E->get().cell;
_set_cell(E->get().pos + ofs, ids, E->get().flip_h, E->get().flip_v, E->get().transpose, E->get().autotile_coord);
}
@@ -1117,15 +1093,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true; // We want to keep the Pasting tool.
} else if (tool == TOOL_SELECTING) {
-
CanvasItemEditor::get_singleton()->update_viewport();
} else if (tool == TOOL_BUCKET) {
-
Vector<Vector2> points = _bucket_fill(over_tile);
- if (points.size() == 0)
+ if (points.size() == 0) {
return false;
+ }
_start_undo(TTR("Bucket Fill"));
@@ -1153,11 +1128,8 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
}
} else if (mb->get_button_index() == BUTTON_RIGHT) {
-
if (mb->is_pressed()) {
-
if (tool == TOOL_SELECTING || selection_active) {
-
tool = TOOL_NONE;
selection_active = false;
@@ -1168,7 +1140,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_PASTING) {
-
tool = TOOL_NONE;
copydata.clear();
@@ -1179,7 +1150,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_NONE) {
-
paint_undo.clear();
Point2 local = node->world_to_map(xform_inv.xform(mb->get_position()));
@@ -1187,15 +1157,15 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_start_undo(TTR("Erase TileMap"));
if (mb->get_shift()) {
- if (mb->get_command())
+ if (mb->get_command()) {
tool = TOOL_RECTANGLE_ERASE;
- else
+ } else {
tool = TOOL_LINE_ERASE;
+ }
selection_active = false;
rectangle_begin = local;
} else {
-
tool = TOOL_ERASING;
_set_cell(local, invalid_cell);
@@ -1207,7 +1177,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else {
if (tool == TOOL_ERASING || tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) {
-
_finish_undo();
if (tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) {
@@ -1220,7 +1189,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
} else if (tool == TOOL_BUCKET) {
-
Vector<int> ids;
ids.push_back(node->get_cell(over_tile.x, over_tile.y));
Dictionary pop;
@@ -1231,8 +1199,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Vector<Vector2> points = _bucket_fill(over_tile, true);
- if (points.size() == 0)
+ if (points.size() == 0) {
return false;
+ }
undo_redo->create_action(TTR("Bucket Fill"));
@@ -1248,12 +1217,10 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
Point2i new_over_tile = node->world_to_map(xform_inv.xform(mm->get_position()));
Point2i old_over_tile = over_tile;
if (new_over_tile != over_tile) {
-
over_tile = new_over_tile;
CanvasItemEditor::get_singleton()->update_viewport();
}
@@ -1261,20 +1228,19 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
int tile_under = node->get_cell(over_tile.x, over_tile.y);
String tile_name = "none";
- if (node->get_tileset()->has_tile(tile_under))
+ if (node->get_tileset()->has_tile(tile_under)) {
tile_name = node->get_tileset()->tile_get_name(tile_under);
+ }
tile_info->show();
tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]");
if (tool == TOOL_PAINTING) {
-
// Paint using bresenham line to prevent holes in painting if the user moves fast.
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
Vector<int> ids = get_selected_tiles();
for (int i = 0; i < points.size(); ++i) {
-
Point2i pos = points[i];
if (!paint_undo.has(pos)) {
@@ -1288,13 +1254,11 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_ERASING) {
-
// Erase using bresenham line to prevent holes in painting if the user moves fast.
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
for (int i = 0; i < points.size(); ++i) {
-
Point2i pos = points[i];
_set_cell(pos, invalid_cell);
@@ -1304,23 +1268,19 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_SELECTING) {
-
_select(rectangle_begin, over_tile);
return true;
}
if (tool == TOOL_LINE_PAINT || tool == TOOL_LINE_ERASE) {
-
Vector<int> ids = get_selected_tiles();
Vector<int> tmp_cell;
bool erasing = (tool == TOOL_LINE_ERASE);
tmp_cell.push_back(0);
if (erasing && paint_undo.size()) {
-
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
-
tmp_cell.write[0] = E->get().idx;
_set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr);
}
@@ -1329,15 +1289,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
paint_undo.clear();
if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
-
Vector<Point2i> points = line(rectangle_begin.x, over_tile.x, rectangle_begin.y, over_tile.y);
for (int i = 0; i < points.size(); i++) {
-
paint_undo[points[i]] = _get_op_from_cell(points[i]);
- if (erasing)
+ if (erasing) {
_set_cell(points[i], invalid_cell);
+ }
}
CanvasItemEditor::get_singleton()->update_viewport();
@@ -1346,18 +1305,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
if (tool == TOOL_RECTANGLE_PAINT || tool == TOOL_RECTANGLE_ERASE) {
-
Vector<int> tmp_cell;
tmp_cell.push_back(0);
_select(rectangle_begin, over_tile);
if (tool == TOOL_RECTANGLE_ERASE) {
-
if (paint_undo.size()) {
-
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
-
tmp_cell.write[0] = E->get().idx;
_set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr);
}
@@ -1367,7 +1322,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
-
Point2i tile = Point2i(j, i);
paint_undo[tile] = _get_op_from_cell(tile);
@@ -1379,7 +1333,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
return true;
}
if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
-
_pick_tile(over_tile);
return true;
@@ -1389,7 +1342,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
-
if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_keycode() == KEY_SHIFT && k->get_command()) {
// trying to draw a rectangle with the painting tool, so change to the correct tool
tool = last_tool;
@@ -1399,11 +1351,11 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (k->get_keycode() == KEY_ESCAPE) {
-
- if (tool == TOOL_PASTING)
+ if (tool == TOOL_PASTING) {
copydata.clear();
- else if (tool == TOOL_SELECTING || selection_active)
+ } else if (tool == TOOL_SELECTING || selection_active) {
selection_active = false;
+ }
tool = TOOL_NONE;
@@ -1518,14 +1470,11 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (k.is_valid()) { // Release event.
if (tool == TOOL_NONE) {
-
if (k->get_keycode() == KEY_SHIFT && k->get_command()) {
-
tool = TOOL_PICKING;
_update_button_tool();
}
} else if (tool == TOOL_PICKING) {
-
#ifdef APPLE_STYLE_KEYS
if (k->get_keycode() == KEY_META) {
#else
@@ -1543,9 +1492,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
-
- if (!node || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT)
+ if (!node || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT) {
return;
+ }
Transform2D cell_xf = node->get_cell_transform();
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
@@ -1561,27 +1510,23 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
Rect2i si = aabb.grow(1.0);
if (node->get_half_offset() != TileMap::HALF_OFFSET_X && node->get_half_offset() != TileMap::HALF_OFFSET_NEGATIVE_X) {
-
int max_lines = 2000; //avoid crash if size too small
for (int i = (si.position.x) - 1; i <= (si.position.x + si.size.x); i++) {
-
Vector2 from = xform.xform(node->map_to_world(Vector2(i, si.position.y)));
Vector2 to = xform.xform(node->map_to_world(Vector2(i, si.position.y + si.size.y + 1)));
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
p_overlay->draw_line(from, to, col, 1);
- if (max_lines-- == 0)
+ if (max_lines-- == 0) {
break;
+ }
}
} else {
-
int max_lines = 10000; //avoid crash if size too small
for (int i = (si.position.x) - 1; i <= (si.position.x + si.size.x); i++) {
-
for (int j = (si.position.y) - 1; j <= (si.position.y + si.size.y); j++) {
-
Vector2 ofs;
if (ABS(j) & 1) {
ofs = cell_xf[0] * (node->get_half_offset() == TileMap::HALF_OFFSET_X ? 0.5 : -0.5);
@@ -1593,35 +1538,33 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
p_overlay->draw_line(from, to, col, 1);
- if (--max_lines == 0)
+ if (--max_lines == 0) {
break;
+ }
}
- if (max_lines == 0)
+ if (max_lines == 0) {
break;
+ }
}
}
int max_lines = 10000; //avoid crash if size too small
if (node->get_half_offset() != TileMap::HALF_OFFSET_Y && node->get_half_offset() != TileMap::HALF_OFFSET_NEGATIVE_Y) {
-
for (int i = (si.position.y) - 1; i <= (si.position.y + si.size.y); i++) {
-
Vector2 from = xform.xform(node->map_to_world(Vector2(si.position.x, i)));
Vector2 to = xform.xform(node->map_to_world(Vector2(si.position.x + si.size.x + 1, i)));
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
p_overlay->draw_line(from, to, col, 1);
- if (max_lines-- == 0)
+ if (max_lines-- == 0) {
break;
+ }
}
} else {
-
for (int i = (si.position.y) - 1; i <= (si.position.y + si.size.y); i++) {
-
for (int j = (si.position.x) - 1; j <= (si.position.x + si.size.x); j++) {
-
Vector2 ofs;
if (ABS(j) & 1) {
ofs = cell_xf[1] * (node->get_half_offset() == TileMap::HALF_OFFSET_Y ? 0.5 : -0.5);
@@ -1633,17 +1576,18 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
p_overlay->draw_line(from, to, col, 1);
- if (--max_lines == 0)
+ if (--max_lines == 0) {
break;
+ }
}
- if (max_lines == 0)
+ if (max_lines == 0) {
break;
+ }
}
}
}
if (selection_active) {
-
Vector<Vector2> points;
points.push_back(xform.xform(node->map_to_world((rectangle.position))));
points.push_back(xform.xform(node->map_to_world((rectangle.position + Point2(rectangle.size.x + 1, 0)))));
@@ -1654,7 +1598,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
if (mouse_over && node->get_tileset().is_valid()) {
-
Vector2 endpoints[4] = {
node->map_to_world(over_tile, true),
node->map_to_world((over_tile + Point2(1, 0)), true),
@@ -1663,24 +1606,30 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
};
for (int i = 0; i < 4; i++) {
- if (node->get_half_offset() == TileMap::HALF_OFFSET_X && ABS(over_tile.y) & 1)
+ if (node->get_half_offset() == TileMap::HALF_OFFSET_X && ABS(over_tile.y) & 1) {
endpoints[i] += cell_xf[0] * 0.5;
- if (node->get_half_offset() == TileMap::HALF_OFFSET_NEGATIVE_X && ABS(over_tile.y) & 1)
+ }
+ if (node->get_half_offset() == TileMap::HALF_OFFSET_NEGATIVE_X && ABS(over_tile.y) & 1) {
endpoints[i] += cell_xf[0] * -0.5;
- if (node->get_half_offset() == TileMap::HALF_OFFSET_Y && ABS(over_tile.x) & 1)
+ }
+ if (node->get_half_offset() == TileMap::HALF_OFFSET_Y && ABS(over_tile.x) & 1) {
endpoints[i] += cell_xf[1] * 0.5;
- if (node->get_half_offset() == TileMap::HALF_OFFSET_NEGATIVE_Y && ABS(over_tile.x) & 1)
+ }
+ if (node->get_half_offset() == TileMap::HALF_OFFSET_NEGATIVE_Y && ABS(over_tile.x) & 1) {
endpoints[i] += cell_xf[1] * -0.5;
+ }
endpoints[i] = xform.xform(endpoints[i]);
}
Color col;
- if (node->get_cell(over_tile.x, over_tile.y) != TileMap::INVALID_CELL)
+ if (node->get_cell(over_tile.x, over_tile.y) != TileMap::INVALID_CELL) {
col = Color(0.2, 0.8, 1.0, 0.8);
- else
+ } else {
col = Color(1.0, 0.4, 0.2, 0.8);
+ }
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++) {
p_overlay->draw_line(endpoints[i], endpoints[(i + 1) % 4], col, 2);
+ }
bool bucket_preview = EditorSettings::get_singleton()->get("editors/tile_map/bucket_fill_preview");
if (tool == TOOL_SELECTING || tool == TOOL_PICKING || !bucket_preview) {
@@ -1688,49 +1637,49 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
if (tool == TOOL_LINE_PAINT) {
-
- if (paint_undo.empty())
+ if (paint_undo.empty()) {
return;
+ }
Vector<int> ids = get_selected_tiles();
- if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL)
+ if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL) {
return;
+ }
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
-
_draw_cell(p_overlay, ids[0], E->key(), flip_h, flip_v, transpose, autotile_coord, xform);
}
} else if (tool == TOOL_RECTANGLE_PAINT) {
-
Vector<int> ids = get_selected_tiles();
- if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL)
+ if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL) {
return;
+ }
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
-
_draw_cell(p_overlay, ids[0], Point2i(j, i), flip_h, flip_v, transpose, autotile_coord, xform);
}
}
} else if (tool == TOOL_PASTING) {
-
- if (copydata.empty())
+ if (copydata.empty()) {
return;
+ }
Ref<TileSet> ts = node->get_tileset();
- if (ts.is_null())
+ if (ts.is_null()) {
return;
+ }
Point2 ofs = over_tile - rectangle.position;
for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) {
-
- if (!ts->has_tile(E->get().cell))
+ if (!ts->has_tile(E->get().cell)) {
continue;
+ }
TileData tcd = E->get();
@@ -1749,16 +1698,15 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
p_overlay->draw_colored_polygon(points, Color(0.2, 1.0, 0.8, 0.2));
} else if (tool == TOOL_BUCKET) {
-
Vector<int> tiles = get_selected_tiles();
_draw_fill_preview(p_overlay, tiles[0], over_tile, flip_h, flip_v, transpose, autotile_coord, xform);
} else {
-
Vector<int> st = get_selected_tiles();
- if (st.size() == 1 && st[0] == TileMap::INVALID_CELL)
+ if (st.size() == 1 && st[0] == TileMap::INVALID_CELL) {
return;
+ }
_draw_cell(p_overlay, st[0], over_tile, flip_h, flip_v, transpose, autotile_coord, xform);
}
@@ -1766,44 +1714,47 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
void TileMapEditor::edit(Node *p_tile_map) {
-
search_box->set_text("");
if (!canvas_item_editor_viewport) {
canvas_item_editor_viewport = CanvasItemEditor::get_singleton()->get_viewport_control();
}
- if (node)
+ if (node) {
node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
+ }
if (p_tile_map) {
-
node = Object::cast_to<TileMap>(p_tile_map);
- if (!canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)))
+ if (!canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter))) {
canvas_item_editor_viewport->connect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter));
- if (!canvas_item_editor_viewport->is_connected("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit)))
+ }
+ if (!canvas_item_editor_viewport->is_connected("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit))) {
canvas_item_editor_viewport->connect("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit));
+ }
_update_palette();
} else {
node = nullptr;
- if (canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)))
+ if (canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter))) {
canvas_item_editor_viewport->disconnect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter));
- if (canvas_item_editor_viewport->is_connected("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit)))
+ }
+ if (canvas_item_editor_viewport->is_connected("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit))) {
canvas_item_editor_viewport->disconnect("mouse_exited", callable_mp(this, &TileMapEditor::_canvas_mouse_exit));
+ }
_update_palette();
}
- if (node)
+ if (node) {
node->connect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
+ }
_clear_bucket_cache();
}
void TileMapEditor::_tileset_settings_changed() {
-
_update_palette();
CanvasItemEditor::get_singleton()->update_viewport();
}
@@ -1817,7 +1768,6 @@ void TileMapEditor::_icon_size_changed(float p_value) {
}
void TileMapEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_fill_points"), &TileMapEditor::_fill_points);
ClassDB::bind_method(D_METHOD("_erase_points"), &TileMapEditor::_erase_points);
}
@@ -1826,12 +1776,15 @@ TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i &p_pos) {
CellOp op;
op.idx = node->get_cell(p_pos.x, p_pos.y);
if (op.idx != TileMap::INVALID_CELL) {
- if (node->is_cell_x_flipped(p_pos.x, p_pos.y))
+ if (node->is_cell_x_flipped(p_pos.x, p_pos.y)) {
op.xf = true;
- if (node->is_cell_y_flipped(p_pos.x, p_pos.y))
+ }
+ if (node->is_cell_y_flipped(p_pos.x, p_pos.y)) {
op.yf = true;
- if (node->is_cell_transposed(p_pos.x, p_pos.y))
+ }
+ if (node->is_cell_transposed(p_pos.x, p_pos.y)) {
op.tr = true;
+ }
op.ac = node->get_cell_autotile_coord(p_pos.x, p_pos.y);
}
return op;
@@ -1901,7 +1854,6 @@ void TileMapEditor::_clear_transform() {
}
TileMapEditor::TileMapEditor(EditorNode *p_editor) {
-
node = nullptr;
manual_autotile = false;
priority_atlastile = false;
@@ -1976,6 +1928,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
palette->add_theme_constant_override("vseparation", 8 * EDSCALE);
palette->connect("item_selected", callable_mp(this, &TileMapEditor::_palette_selected));
palette->connect("multi_selected", callable_mp(this, &TileMapEditor::_palette_multi_selected));
+ palette->connect("gui_input", callable_mp(this, &TileMapEditor::_palette_input));
palette_container->add_child(palette);
// Add message for when no texture is selected.
@@ -2014,7 +1967,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
toolbar->add_child(paint_button);
bucket_fill_button = memnew(ToolButton);
- bucket_fill_button->set_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_G));
+ bucket_fill_button->set_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_B));
bucket_fill_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_BUCKET));
bucket_fill_button->set_toggle_mode(true);
toolbar->add_child(bucket_fill_button);
@@ -2112,9 +2065,7 @@ TileMapEditor::~TileMapEditor() {
///////////////////////////////////////////////////////////////
void TileMapEditorPlugin::_notification(int p_what) {
-
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
-
switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) {
case 0: { // Left.
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 0);
@@ -2127,19 +2078,15 @@ void TileMapEditorPlugin::_notification(int p_what) {
}
void TileMapEditorPlugin::edit(Object *p_object) {
-
tile_map_editor->edit(Object::cast_to<Node>(p_object));
}
bool TileMapEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("TileMap");
}
void TileMapEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
-
tile_map_editor->show();
tile_map_editor->get_toolbar()->show();
tile_map_editor->get_toolbar_right()->show();
@@ -2150,7 +2097,6 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
// Change to TOOL_SELECT when TileMap node is selected, to prevent accidental movement.
CanvasItemEditor::get_singleton()->set_current_tool(CanvasItemEditor::TOOL_SELECT);
} else {
-
tile_map_editor->hide();
tile_map_editor->get_toolbar()->hide();
tile_map_editor->get_toolbar_right()->hide();
@@ -2160,7 +2106,6 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
}
TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
-
EDITOR_DEF("editors/tile_map/preview_size", 64);
EDITOR_DEF("editors/tile_map/palette_item_hseparation", 8);
EDITOR_DEF("editors/tile_map/show_tile_names", true);
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index f43e5bb5cb..e25e2d2add 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -33,7 +33,6 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-
#include "scene/2d/tile_map.h"
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
@@ -42,7 +41,6 @@
#include "scene/gui/tool_button.h"
class TileMapEditor : public VBoxContainer {
-
GDCLASS(TileMapEditor, VBoxContainer);
enum Tool {
@@ -127,34 +125,26 @@ class TileMapEditor : public VBoxContainer {
List<Point2i> bucket_queue;
struct CellOp {
- int idx;
- bool xf;
- bool yf;
- bool tr;
+ int idx = TileMap::INVALID_CELL;
+ bool xf = false;
+ bool yf = false;
+ bool tr = false;
Vector2 ac;
- CellOp() :
- idx(TileMap::INVALID_CELL),
- xf(false),
- yf(false),
- tr(false) {}
+ CellOp() {}
};
Map<Point2i, CellOp> paint_undo;
struct TileData {
Point2i pos;
- int cell;
- bool flip_h;
- bool flip_v;
- bool transpose;
+ int cell = TileMap::INVALID_CELL;
+ bool flip_h = false;
+ bool flip_v = false;
+ bool transpose = false;
Point2i autotile_coord;
- TileData() :
- cell(TileMap::INVALID_CELL),
- flip_h(false),
- flip_v(false),
- transpose(false) {}
+ TileData() {}
};
List<TileData> copydata;
@@ -192,6 +182,7 @@ class TileMapEditor : public VBoxContainer {
void _menu_option(int p_option);
void _palette_selected(int index);
void _palette_multi_selected(int index, bool selected);
+ void _palette_input(const Ref<InputEvent> &p_event);
Dictionary _create_cell_dictionary(int tile, bool flip_x, bool flip_y, bool transpose, Vector2 autotile_coord);
void _start_undo(const String &p_action);
@@ -230,7 +221,6 @@ public:
};
class TileMapEditorPlugin : public EditorPlugin {
-
GDCLASS(TileMapEditorPlugin, EditorPlugin);
TileMapEditor *tile_map_editor;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index b0d325efc1..b3d4b391d3 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -38,7 +38,6 @@
#include "scene/2d/sprite_2d.h"
void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
-
tileset = p_tileset;
tileset->add_change_receptor(this);
@@ -48,9 +47,7 @@ void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
}
void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
-
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *child = p_node->get_child(i);
if (!Object::cast_to<Sprite2D>(child)) {
@@ -66,12 +63,12 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
Ref<Texture2D> normal_map = mi->get_normal_map();
Ref<ShaderMaterial> material = mi->get_material();
- if (texture.is_null())
+ if (texture.is_null()) {
continue;
+ }
int id = p_library->find_tile_by_name(mi->get_name());
if (id < 0) {
-
id = p_library->get_last_unused_tile_id();
p_library->create_tile(id);
p_library->tile_set_name(id, mi->get_name());
@@ -106,17 +103,19 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
bool found_collisions = false;
for (int j = 0; j < mi->get_child_count(); j++) {
-
Node *child2 = mi->get_child(j);
- if (Object::cast_to<NavigationRegion2D>(child2))
+ if (Object::cast_to<NavigationRegion2D>(child2)) {
nav_poly = Object::cast_to<NavigationRegion2D>(child2)->get_navigation_polygon();
+ }
- if (Object::cast_to<LightOccluder2D>(child2))
+ if (Object::cast_to<LightOccluder2D>(child2)) {
occluder = Object::cast_to<LightOccluder2D>(child2)->get_occluder_polygon();
+ }
- if (!Object::cast_to<StaticBody2D>(child2))
+ if (!Object::cast_to<StaticBody2D>(child2)) {
continue;
+ }
found_collisions = true;
@@ -126,8 +125,9 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
sb->get_shape_owners(&shapes);
for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) {
- if (sb->is_shape_owner_disabled(E->get()))
+ if (sb->is_shape_owner_disabled(E->get())) {
continue;
+ }
Transform2D shape_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get());
bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get());
@@ -135,7 +135,6 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
shape_transform[2] -= phys_offset;
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
-
Ref<Shape2D> shape = sb->shape_owner_get_shape(E->get(), k);
TileSet::ShapeData shape_data;
shape_data.shape = shape;
@@ -160,38 +159,36 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
}
void TileSetEditor::_import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge) {
-
- if (!p_merge)
+ if (!p_merge) {
p_library->clear();
+ }
_import_node(p_scene, p_library);
}
void TileSetEditor::_undo_redo_import_scene(Node *p_scene, bool p_merge) {
-
_import_scene(p_scene, tileset, p_merge);
}
Error TileSetEditor::update_library_file(Node *p_base_scene, Ref<TileSet> ml, bool p_merge) {
-
_import_scene(p_base_scene, ml, p_merge);
return OK;
}
Variant TileSetEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
return false;
}
bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
- if (d.has("from") && (Object *)(d["from"]) == texture_list)
+ if (d.has("from") && (Object *)(d["from"]) == texture_list) {
return false;
+ }
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
@@ -199,17 +196,16 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat
Ref<Texture2D> texture = r;
if (texture.is_valid()) {
-
return true;
}
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
- if (files.size() == 0)
+ if (files.size() == 0) {
return false;
+ }
for (int i = 0; i < files.size(); i++) {
String file = files[i];
@@ -226,22 +222,24 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat
}
void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return;
+ }
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
Ref<Texture2D> texture = r;
- if (texture.is_valid())
+ if (texture.is_valid()) {
add_texture(texture);
+ }
if (texture_list->get_item_count() > 0) {
update_texture_list_icon();
@@ -251,7 +249,6 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
_on_textures_added(files);
@@ -259,7 +256,6 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C
}
void TileSetEditor::_bind_methods() {
-
ClassDB::bind_method("_undo_redo_import_scene", &TileSetEditor::_undo_redo_import_scene);
ClassDB::bind_method("_on_workspace_process", &TileSetEditor::_on_workspace_process); // Still used by some connect_compat.
ClassDB::bind_method("_set_snap_step", &TileSetEditor::_set_snap_step);
@@ -281,15 +277,12 @@ void TileSetEditor::_bind_methods() {
}
void TileSetEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY: {
-
add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
-
tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_icon(get_theme_icon("ToolAddNode", "EditorIcons"));
tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->set_icon(get_theme_icon("Remove", "EditorIcons"));
tileset_toolbar_tools->set_icon(get_theme_icon("Tools", "EditorIcons"));
@@ -331,7 +324,6 @@ void TileSetEditor::_notification(int p_what) {
}
TileSetEditor::TileSetEditor(EditorNode *p_editor) {
-
editor = p_editor;
undo_redo = EditorNode::get_undo_redo();
current_tile = -1;
@@ -577,6 +569,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
scroll = memnew(ScrollContainer);
main_vb->add_child(scroll);
scroll->set_v_size_flags(SIZE_EXPAND_FILL);
+ scroll->connect("gui_input", callable_mp(this, &TileSetEditor::_on_scroll_container_input));
scroll->set_clip_contents(true);
empty_message = memnew(Label);
@@ -626,7 +619,6 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
texture_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
add_child(texture_dialog);
@@ -643,8 +635,9 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
}
TileSetEditor::~TileSetEditor() {
- if (helper)
+ if (helper) {
memdelete(helper);
+ }
}
void TileSetEditor::_on_tileset_toolbar_button_pressed(int p_index) {
@@ -663,12 +656,10 @@ void TileSetEditor::_on_tileset_toolbar_button_pressed(int p_index) {
}
} break;
case TOOL_TILESET_CREATE_SCENE: {
-
cd->set_text(TTR("Create from scene? This will overwrite all current tiles."));
cd->popup_centered(Size2(300, 60));
} break;
case TOOL_TILESET_MERGE_SCENE: {
-
cd->set_text(TTR("Merge from scene?"));
cd->popup_centered(Size2(300, 60));
} break;
@@ -696,11 +687,11 @@ void TileSetEditor::_on_tileset_toolbar_confirm() {
} break;
case TOOL_TILESET_MERGE_SCENE:
case TOOL_TILESET_CREATE_SCENE: {
-
EditorNode *en = editor;
Node *scene = en->get_edited_scene();
- if (!scene)
+ if (!scene) {
break;
+ }
List<int> ids;
tileset->get_tile_list(&ids);
@@ -895,9 +886,9 @@ void TileSetEditor::_on_workspace_mode_changed(int p_workspace_mode) {
}
void TileSetEditor::_on_workspace_draw() {
-
- if (tileset.is_null() || !get_current_texture().is_valid())
+ if (tileset.is_null() || !get_current_texture().is_valid()) {
return;
+ }
const Color COLOR_AUTOTILE = Color(0.3, 0.6, 1);
const Color COLOR_SINGLE = Color(1, 1, 0.3);
@@ -1056,12 +1047,13 @@ void TileSetEditor::_on_workspace_draw() {
Rect2i region = tileset->tile_get_region(t_id);
region.position += WORKSPACE_MARGIN;
Color c;
- if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
+ if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE) {
c = COLOR_SINGLE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
+ } else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE) {
c = COLOR_AUTOTILE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
+ } else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE) {
c = COLOR_ATLAS;
+ }
draw_tile_subdivision(t_id, COLOR_SUBDIVISION);
workspace->draw_rect(region, c, false);
}
@@ -1072,39 +1064,43 @@ void TileSetEditor::_on_workspace_draw() {
if (workspace_mode != WORKSPACE_EDIT) {
Rect2i region = edited_region;
Color c;
- if (workspace_mode == WORKSPACE_CREATE_SINGLE)
+ if (workspace_mode == WORKSPACE_CREATE_SINGLE) {
c = COLOR_SINGLE;
- else if (workspace_mode == WORKSPACE_CREATE_AUTOTILE)
+ } else if (workspace_mode == WORKSPACE_CREATE_AUTOTILE) {
c = COLOR_AUTOTILE;
- else if (workspace_mode == WORKSPACE_CREATE_ATLAS)
+ } else if (workspace_mode == WORKSPACE_CREATE_ATLAS) {
c = COLOR_ATLAS;
+ }
workspace->draw_rect(region, c, false);
draw_edited_region_subdivision();
} else {
int t_id = get_current_tile();
- if (t_id < 0)
+ if (t_id < 0) {
return;
+ }
Rect2i region;
- if (draw_edited_region)
+ if (draw_edited_region) {
region = edited_region;
- else {
+ } else {
region = tileset->tile_get_region(t_id);
region.position += WORKSPACE_MARGIN;
}
- if (draw_edited_region)
+ if (draw_edited_region) {
draw_edited_region_subdivision();
- else
+ } else {
draw_tile_subdivision(t_id, COLOR_SUBDIVISION);
+ }
Color c;
- if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
+ if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE) {
c = COLOR_SINGLE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
+ } else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE) {
c = COLOR_AUTOTILE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
+ } else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE) {
c = COLOR_ATLAS;
+ }
workspace->draw_rect(region, c, false);
}
}
@@ -1113,7 +1109,6 @@ void TileSetEditor::_on_workspace_draw() {
}
void TileSetEditor::_on_workspace_process() {
-
if (Input::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) {
if (!tile_names_visible) {
tile_names_visible = true;
@@ -1126,9 +1121,9 @@ void TileSetEditor::_on_workspace_process() {
}
void TileSetEditor::_on_workspace_overlay_draw() {
-
- if (!tileset.is_valid() || !get_current_texture().is_valid())
+ if (!tileset.is_valid() || !get_current_texture().is_valid()) {
return;
+ }
const Color COLOR_AUTOTILE = Color(0.266373, 0.565288, 0.988281);
const Color COLOR_SINGLE = Color(0.988281, 0.909323, 0.266373);
@@ -1140,19 +1135,21 @@ void TileSetEditor::_on_workspace_overlay_draw() {
tileset->get_tile_list(tiles);
for (List<int>::Element *E = tiles->front(); E; E = E->next()) {
int t_id = E->get();
- if (tileset->tile_get_texture(t_id)->get_rid() != current_texture_rid)
+ if (tileset->tile_get_texture(t_id)->get_rid() != current_texture_rid) {
continue;
+ }
Rect2 region = tileset->tile_get_region(t_id);
region.position += WORKSPACE_MARGIN;
region.position *= workspace->get_scale().x;
Color c;
- if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
+ if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE) {
c = COLOR_SINGLE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
+ } else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE) {
c = COLOR_AUTOTILE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
+ } else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE) {
c = COLOR_ATLAS;
+ }
String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
Ref<Font> font = get_theme_font("font", "Label");
region.set_size(font->get_string_size(tile_id_name));
@@ -1165,8 +1162,9 @@ void TileSetEditor::_on_workspace_overlay_draw() {
}
int t_id = get_current_tile();
- if (t_id < 0)
+ if (t_id < 0) {
return;
+ }
Ref<Texture2D> handle = get_theme_icon("EditorHandle", "EditorIcons");
if (draw_handles) {
@@ -1201,10 +1199,31 @@ bool TileSetEditor::is_within_grabbing_distance_of_first_point(const Vector2 &p_
return distance < p_grab_threshold;
}
-void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
+void TileSetEditor::_on_scroll_container_input(const Ref<InputEvent> &p_event) {
+ const Ref<InputEventMouseButton> mb = p_event;
- if (tileset.is_null() || !get_current_texture().is_valid())
+ if (mb.is_valid()) {
+ // Zoom in/out using Ctrl + mouse wheel. This is done on the ScrollContainer
+ // to allow performing this action anywhere, even if the cursor isn't
+ // hovering the texture in the workspace.
+ if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
+ print_line("zooming in");
+ _zoom_in();
+ // Don't scroll up after zooming in.
+ accept_event();
+ } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
+ print_line("zooming out");
+ _zoom_out();
+ // Don't scroll down after zooming out.
+ accept_event();
+ }
+ }
+}
+
+void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
+ if (tileset.is_null() || !get_current_texture().is_valid()) {
return;
+ }
static bool dragging;
static bool erasing;
@@ -1217,8 +1236,8 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
current_tile_region.position += WORKSPACE_MARGIN;
- Ref<InputEventMouseButton> mb = p_ie;
- Ref<InputEventMouseMotion> mm = p_ie;
+ const Ref<InputEventMouseButton> mb = p_ie;
+ const Ref<InputEventMouseMotion> mm = p_ie;
if (mb.is_valid()) {
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && !creating_shape) {
@@ -1242,13 +1261,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
delete tiles;
}
}
-
- // Mouse Wheel Event
- if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed() && mb->get_control()) {
- _zoom_in();
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed() && mb->get_control()) {
- _zoom_out();
- }
}
// Drag Middle Mouse
if (mm.is_valid()) {
@@ -1658,7 +1670,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
pos = snap_point(pos);
if (creating_shape) {
if (current_shape.size() > 2) {
-
if (is_within_grabbing_distance_of_first_point(mb->get_position(), grab_threshold)) {
close_shape(shape_anchor);
workspace->update();
@@ -1708,7 +1719,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
} else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
if (creating_shape) {
-
// if the first two corners are within grabbing distance of one another, expand the rect to fill the tile
if (is_within_grabbing_distance_of_first_point(current_shape[1], grab_threshold)) {
current_shape.set(0, snap_point(shape_anchor));
@@ -1909,8 +1919,9 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
}
void TileSetEditor::_on_priority_changed(float val) {
- if ((int)val == tileset->autotile_get_subtile_priority(get_current_tile(), edited_shape_coord))
+ if ((int)val == tileset->autotile_get_subtile_priority(get_current_tile(), edited_shape_coord)) {
return;
+ }
undo_redo->create_action(TTR("Edit Tile Priority"));
undo_redo->add_do_method(tileset.ptr(), "autotile_set_subtile_priority", get_current_tile(), edited_shape_coord, (int)val);
@@ -1921,8 +1932,9 @@ void TileSetEditor::_on_priority_changed(float val) {
}
void TileSetEditor::_on_z_index_changed(float val) {
- if ((int)val == tileset->autotile_get_z_index(get_current_tile(), edited_shape_coord))
+ if ((int)val == tileset->autotile_get_z_index(get_current_tile(), edited_shape_coord)) {
return;
+ }
undo_redo->create_action(TTR("Edit Tile Z Index"));
undo_redo->add_do_method(tileset.ptr(), "autotile_set_z_index", get_current_tile(), edited_shape_coord, (int)val);
@@ -1978,8 +1990,9 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) {
void TileSetEditor::_update_tile_data() {
current_tile_data.clear();
- if (get_current_tile() < 0)
+ if (get_current_tile() < 0) {
return;
+ }
Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(get_current_tile());
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
@@ -2323,8 +2336,9 @@ void TileSetEditor::_set_snap_sep(Vector2 p_val) {
}
void TileSetEditor::_validate_current_tile_id() {
- if (get_current_tile() >= 0 && !tileset->has_tile(get_current_tile()))
+ if (get_current_tile() >= 0 && !tileset->has_tile(get_current_tile())) {
set_current_tile(-1);
+ }
}
void TileSetEditor::_select_edited_shape_coord() {
@@ -2388,6 +2402,7 @@ void TileSetEditor::_zoom_in() {
workspace_overlay->set_custom_minimum_size(workspace->get_rect().size * scale);
}
}
+
void TileSetEditor::_zoom_out() {
float scale = workspace->get_scale().x;
if (scale > min_scale) {
@@ -2397,6 +2412,7 @@ void TileSetEditor::_zoom_out() {
workspace_overlay->set_custom_minimum_size(workspace->get_rect().size * scale);
}
}
+
void TileSetEditor::_zoom_reset() {
workspace->set_scale(Vector2(1, 1));
workspace_container->set_custom_minimum_size(workspace->get_rect().size);
@@ -2404,7 +2420,6 @@ void TileSetEditor::_zoom_reset() {
}
void TileSetEditor::draw_highlight_current_tile() {
-
Color shadow_color = Color(0.3, 0.3, 0.3, 0.3);
if ((workspace_mode == WORKSPACE_EDIT && get_current_tile() >= 0) || !edited_region.has_no_area()) {
Rect2 region;
@@ -2415,21 +2430,24 @@ void TileSetEditor::draw_highlight_current_tile() {
region = edited_region;
}
- if (region.position.y >= 0)
+ if (region.position.y >= 0) {
workspace->draw_rect(Rect2(0, 0, workspace->get_rect().size.x, region.position.y), shadow_color);
- if (region.position.x >= 0)
+ }
+ if (region.position.x >= 0) {
workspace->draw_rect(Rect2(0, MAX(0, region.position.y), region.position.x, MIN(workspace->get_rect().size.y - region.position.y, MIN(region.size.y, region.position.y + region.size.y))), shadow_color);
- if (region.position.x + region.size.x <= workspace->get_rect().size.x)
+ }
+ if (region.position.x + region.size.x <= workspace->get_rect().size.x) {
workspace->draw_rect(Rect2(region.position.x + region.size.x, MAX(0, region.position.y), workspace->get_rect().size.x - region.position.x - region.size.x, MIN(workspace->get_rect().size.y - region.position.y, MIN(region.size.y, region.position.y + region.size.y))), shadow_color);
- if (region.position.y + region.size.y <= workspace->get_rect().size.y)
+ }
+ if (region.position.y + region.size.y <= workspace->get_rect().size.y) {
workspace->draw_rect(Rect2(0, region.position.y + region.size.y, workspace->get_rect().size.x, workspace->get_rect().size.y - region.size.y - region.position.y), shadow_color);
+ }
} else {
workspace->draw_rect(Rect2(Point2(0, 0), workspace->get_rect().size), shadow_color);
}
}
void TileSetEditor::draw_highlight_subtile(Vector2 coord, const Vector<Vector2> &other_highlighted) {
-
Color shadow_color = Color(0.3, 0.3, 0.3, 0.3);
Vector2 size = tileset->autotile_get_size(get_current_tile());
int spacing = tileset->autotile_get_spacing(get_current_tile());
@@ -2439,14 +2457,18 @@ void TileSetEditor::draw_highlight_subtile(Vector2 coord, const Vector<Vector2>
coord += region.position;
coord += WORKSPACE_MARGIN;
- if (coord.y >= 0)
+ if (coord.y >= 0) {
workspace->draw_rect(Rect2(0, 0, workspace->get_rect().size.x, coord.y), shadow_color);
- if (coord.x >= 0)
+ }
+ if (coord.x >= 0) {
workspace->draw_rect(Rect2(0, MAX(0, coord.y), coord.x, MIN(workspace->get_rect().size.y - coord.y, MIN(size.y, coord.y + size.y))), shadow_color);
- if (coord.x + size.x <= workspace->get_rect().size.x)
+ }
+ if (coord.x + size.x <= workspace->get_rect().size.x) {
workspace->draw_rect(Rect2(coord.x + size.x, MAX(0, coord.y), workspace->get_rect().size.x - coord.x - size.x, MIN(workspace->get_rect().size.y - coord.y, MIN(size.y, coord.y + size.y))), shadow_color);
- if (coord.y + size.y <= workspace->get_rect().size.y)
+ }
+ if (coord.y + size.y <= workspace->get_rect().size.y) {
workspace->draw_rect(Rect2(0, coord.y + size.y, workspace->get_rect().size.x, workspace->get_rect().size.y - size.y - coord.y), shadow_color);
+ }
coord += Vector2(1, 1) / workspace->get_scale().x;
workspace->draw_rect(Rect2(coord, size - Vector2(2, 2) / workspace->get_scale().x), Color(1, 0, 0), false);
@@ -2579,10 +2601,10 @@ void TileSetEditor::draw_grid_snap() {
}
void TileSetEditor::draw_polygon_shapes() {
-
int t_id = get_current_tile();
- if (t_id < 0)
+ if (t_id < 0) {
return;
+ }
switch (edit_mode) {
case EDITMODE_COLLISION: {
@@ -2638,8 +2660,9 @@ void TileSetEditor::draw_polygon_shapes() {
}
}
- if (polygon.size() < 3)
+ if (polygon.size() < 3) {
continue;
+ }
workspace->draw_polygon(polygon, colors);
@@ -2848,7 +2871,6 @@ void TileSetEditor::draw_polygon_shapes() {
}
void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
-
creating_shape = false;
if (edit_mode == EDITMODE_COLLISION) {
@@ -2861,14 +2883,16 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
for (int i = 0; i < current_shape.size(); i++) {
points.push_back(current_shape[i] - shape_anchor);
- if (i != current_shape.size() - 1)
+ if (i != current_shape.size() - 1) {
p_total += ((current_shape[i + 1].x - current_shape[i].x) * (-current_shape[i + 1].y + (-current_shape[i].y)));
- else
+ } else {
p_total += ((current_shape[0].x - current_shape[i].x) * (-current_shape[0].y + (-current_shape[i].y)));
+ }
}
- if (p_total < 0)
+ if (p_total < 0) {
points.invert();
+ }
shape->set_points(points);
@@ -2883,10 +2907,11 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
}
}
undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd);
- if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE)
+ if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) {
undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), shape, Transform2D(), false, edited_shape_coord);
- else
+ } else {
undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), shape, Transform2D());
+ }
tools[TOOL_SELECT]->set_pressed(true);
undo_redo->add_do_method(this, "_select_edited_shape_coord");
undo_redo->add_undo_method(this, "_select_edited_shape_coord");
@@ -2955,17 +2980,21 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
void TileSetEditor::select_coord(const Vector2 &coord) {
_update_tile_data();
current_shape = PackedVector2Array();
- if (get_current_tile() == -1)
+ if (get_current_tile() == -1) {
return;
+ }
Rect2 current_tile_region = tileset->tile_get_region(get_current_tile());
current_tile_region.position += WORKSPACE_MARGIN;
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
- if (edited_collision_shape != tileset->tile_get_shape(get_current_tile(), 0))
+ if (edited_collision_shape != tileset->tile_get_shape(get_current_tile(), 0)) {
_set_edited_collision_shape(tileset->tile_get_shape(get_current_tile(), 0));
- if (edited_occlusion_shape != tileset->tile_get_light_occluder(get_current_tile()))
+ }
+ if (edited_occlusion_shape != tileset->tile_get_light_occluder(get_current_tile())) {
edited_occlusion_shape = tileset->tile_get_light_occluder(get_current_tile());
- if (edited_navigation_shape != tileset->tile_get_navigation_polygon(get_current_tile()))
+ }
+ if (edited_navigation_shape != tileset->tile_get_navigation_polygon(get_current_tile())) {
edited_navigation_shape = tileset->tile_get_navigation_polygon(get_current_tile());
+ }
if (edit_mode == EDITMODE_COLLISION) {
current_shape.resize(0);
@@ -2997,18 +3026,22 @@ void TileSetEditor::select_coord(const Vector2 &coord) {
bool found_collision_shape = false;
for (int i = 0; i < sd.size(); i++) {
if (sd[i].autotile_coord == coord) {
- if (edited_collision_shape != sd[i].shape)
+ if (edited_collision_shape != sd[i].shape) {
_set_edited_collision_shape(sd[i].shape);
+ }
found_collision_shape = true;
break;
}
}
- if (!found_collision_shape)
+ if (!found_collision_shape) {
_set_edited_collision_shape(Ref<ConvexPolygonShape2D>(nullptr));
- if (edited_occlusion_shape != tileset->autotile_get_light_occluder(get_current_tile(), coord))
+ }
+ if (edited_occlusion_shape != tileset->autotile_get_light_occluder(get_current_tile(), coord)) {
edited_occlusion_shape = tileset->autotile_get_light_occluder(get_current_tile(), coord);
- if (edited_navigation_shape != tileset->autotile_get_navigation_polygon(get_current_tile(), coord))
+ }
+ if (edited_navigation_shape != tileset->autotile_get_navigation_polygon(get_current_tile(), coord)) {
edited_navigation_shape = tileset->autotile_get_navigation_polygon(get_current_tile(), coord);
+ }
int spacing = tileset->autotile_get_spacing(get_current_tile());
Vector2 size = tileset->autotile_get_size(get_current_tile());
@@ -3068,14 +3101,18 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
p.y = Math::snap_scalar_separation(snap_offset.y, snap_step.y, p.y, snap_separation.y);
}
if (tools[SHAPE_KEEP_INSIDE_TILE]->is_pressed()) {
- if (p.x < region.position.x)
+ if (p.x < region.position.x) {
p.x = region.position.x;
- if (p.y < region.position.y)
+ }
+ if (p.y < region.position.y) {
p.y = region.position.y;
- if (p.x > region.position.x + region.size.x)
+ }
+ if (p.x > region.position.x + region.size.x) {
p.x = region.position.x + region.size.x;
- if (p.y > region.position.y + region.size.y)
+ }
+ if (p.y > region.position.y + region.size.y) {
p.y = region.position.y + region.size.y;
+ }
}
return p;
}
@@ -3123,8 +3160,9 @@ void TileSetEditor::update_texture_list() {
if (texture_list->get_item_count() > 0 && selected_texture.is_valid()) {
texture_list->select(texture_list->find_metadata(selected_texture->get_rid()));
- if (texture_list->get_selected_items().size() > 0)
+ if (texture_list->get_selected_items().size() > 0) {
_on_texture_list_selected(texture_list->get_selected_items()[0]);
+ }
} else if (get_current_texture().is_valid()) {
_on_texture_list_selected(texture_list->find_metadata(get_current_texture()->get_rid()));
} else {
@@ -3137,7 +3175,6 @@ void TileSetEditor::update_texture_list() {
}
void TileSetEditor::update_texture_list_icon() {
-
for (int current_idx = 0; current_idx < texture_list->get_item_count(); current_idx++) {
RID rid = texture_list->get_item_metadata(current_idx);
texture_list->set_item_icon(current_idx, texture_map[rid]);
@@ -3148,7 +3185,6 @@ void TileSetEditor::update_texture_list_icon() {
}
void TileSetEditor::update_workspace_tile_mode() {
-
if (!get_current_texture().is_valid()) {
tool_workspacemode[WORKSPACE_EDIT]->set_pressed(true);
workspace_mode = WORKSPACE_EDIT;
@@ -3224,19 +3260,21 @@ void TileSetEditor::update_workspace_tile_mode() {
tool_editmode[EDITMODE_PRIORITY]->hide();
tool_editmode[EDITMODE_Z_INDEX]->hide();
} else if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE) {
- if (edit_mode == EDITMODE_ICON)
+ if (edit_mode == EDITMODE_ICON) {
select_coord(tileset->autotile_get_icon_coordinate(get_current_tile()));
- else
+ } else {
_select_edited_shape_coord();
+ }
} else if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) {
if (tool_editmode[EDITMODE_PRIORITY]->is_pressed() || tool_editmode[EDITMODE_BITMASK]->is_pressed()) {
tool_editmode[EDITMODE_COLLISION]->set_pressed(true);
edit_mode = EDITMODE_COLLISION;
}
- if (edit_mode == EDITMODE_ICON)
+ if (edit_mode == EDITMODE_ICON) {
select_coord(tileset->autotile_get_icon_coordinate(get_current_tile()));
- else
+ } else {
_select_edited_shape_coord();
+ }
tool_editmode[EDITMODE_BITMASK]->hide();
}
@@ -3309,14 +3347,14 @@ void TileSetEditor::set_current_tile(int p_id) {
}
Ref<Texture2D> TileSetEditor::get_current_texture() {
- if (texture_list->get_selected_items().size() == 0)
+ if (texture_list->get_selected_items().size() == 0) {
return Ref<Texture2D>();
- else
+ } else {
return texture_map[texture_list->get_item_metadata(texture_list->get_selected_items()[0])];
+ }
}
void TilesetEditorContext::set_tileset(const Ref<TileSet> &p_tileset) {
-
tileset = p_tileset;
}
@@ -3326,7 +3364,6 @@ void TilesetEditorContext::set_snap_options_visible(bool p_visible) {
}
bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name.operator String();
if (name == "options_offset") {
@@ -3345,8 +3382,9 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value
String name2 = p_name.operator String().right(5);
bool v = false;
- if (tileset_editor->get_current_tile() < 0 || tileset.is_null())
+ if (tileset_editor->get_current_tile() < 0 || tileset.is_null()) {
return false;
+ }
if (name2 == "autotile_bitmask_mode") {
tileset->set(String::num(tileset_editor->get_current_tile(), 0) + "/autotile/bitmask_mode", p_value, &v);
@@ -3392,7 +3430,6 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value
}
bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name.operator String();
bool v = false;
@@ -3408,10 +3445,12 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const
} else if (name.left(5) == "tile_") {
name = name.right(5);
- if (tileset_editor->get_current_tile() < 0 || tileset.is_null())
+ if (tileset_editor->get_current_tile() < 0 || tileset.is_null()) {
return false;
- if (!tileset->has_tile(tileset_editor->get_current_tile()))
+ }
+ if (!tileset->has_tile(tileset_editor->get_current_tile())) {
return false;
+ }
if (name == "autotile_bitmask_mode") {
r_ret = tileset->get(String::num(tileset_editor->get_current_tile(), 0) + "/autotile/bitmask_mode", &v);
@@ -3458,7 +3497,6 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const
}
void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const {
-
if (snap_options_visible) {
p_list->push_back(PropertyInfo(Variant::NIL, "Snap Options", PROPERTY_HINT_NONE, "options_", PROPERTY_USAGE_GROUP));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "options_offset"));
@@ -3507,25 +3545,21 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const
}
void TilesetEditorContext::_bind_methods() {
-
ClassDB::bind_method("_hide_script_from_inspector", &TilesetEditorContext::_hide_script_from_inspector);
}
TilesetEditorContext::TilesetEditorContext(TileSetEditor *p_tileset_editor) {
-
tileset_editor = p_tileset_editor;
snap_options_visible = false;
}
void TileSetEditorPlugin::edit(Object *p_node) {
-
if (Object::cast_to<TileSet>(p_node)) {
tileset_editor->edit(Object::cast_to<TileSet>(p_node));
}
}
bool TileSetEditorPlugin::handles(Object *p_node) const {
-
return p_node->is_class("TileSet") || p_node->is_class("TilesetEditorContext");
}
@@ -3542,7 +3576,6 @@ void TileSetEditorPlugin::make_visible(bool p_visible) {
}
Dictionary TileSetEditorPlugin::get_state() const {
-
Dictionary state;
state["snap_offset"] = tileset_editor->snap_offset;
state["snap_step"] = tileset_editor->snap_step;
@@ -3554,7 +3587,6 @@ Dictionary TileSetEditorPlugin::get_state() const {
}
void TileSetEditorPlugin::set_state(const Dictionary &p_state) {
-
Dictionary state = p_state;
if (state.has("snap_step")) {
tileset_editor->_set_snap_step(state["snap_step"]);
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 53f8e8c4d6..2955dda244 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -41,7 +41,6 @@
class TilesetEditorContext;
class TileSetEditor : public HSplitContainer {
-
friend class TileSetEditorPlugin;
friend class TilesetEditorContext;
@@ -201,6 +200,7 @@ private:
void _on_workspace_overlay_draw();
void _on_workspace_draw();
void _on_workspace_process();
+ void _on_scroll_container_input(const Ref<InputEvent> &p_event);
void _on_workspace_input(const Ref<InputEvent> &p_ie);
void _on_tool_clicked(int p_tool);
void _on_priority_changed(float val);
@@ -252,7 +252,6 @@ private:
};
class TilesetEditorContext : public Object {
-
friend class TileSetEditor;
GDCLASS(TilesetEditorContext, Object);
@@ -278,7 +277,6 @@ public:
};
class TileSetEditorPlugin : public EditorPlugin {
-
GDCLASS(TileSetEditorPlugin, EditorPlugin);
TileSetEditor *tileset_editor;
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index fe8392593b..a1436e123d 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -38,7 +38,6 @@
VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr;
void VersionControlEditorPlugin::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("popup_vcs_set_up_dialog"), &VersionControlEditorPlugin::popup_vcs_set_up_dialog);
// Used to track the status of files in the staging area
@@ -50,20 +49,16 @@ void VersionControlEditorPlugin::_bind_methods() {
}
void VersionControlEditorPlugin::_selected_a_vcs(int p_id) {
-
List<StringName> available_addons = get_available_vcs_names();
const StringName selected_vcs = set_up_choice->get_item_text(p_id);
}
void VersionControlEditorPlugin::_populate_available_vcs_names() {
-
static bool called = false;
if (!called) {
-
List<StringName> available_addons = get_available_vcs_names();
for (int i = 0; i < available_addons.size(); i++) {
-
set_up_choice->add_item(available_addons[i]);
}
@@ -72,16 +67,13 @@ void VersionControlEditorPlugin::_populate_available_vcs_names() {
}
VersionControlEditorPlugin *VersionControlEditorPlugin::get_singleton() {
-
return singleton ? singleton : memnew(VersionControlEditorPlugin);
}
void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_base) {
-
fetch_available_vcs_addon_names();
List<StringName> available_addons = get_available_vcs_names();
if (available_addons.size() >= 1) {
-
Size2 popup_size = Size2(400, 100);
Size2 window_size = p_gui_base->get_viewport_rect().size;
popup_size.x = MIN(window_size.x * 0.5, popup_size.x);
@@ -91,13 +83,11 @@ void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_ba
set_up_dialog->popup_centered_clamped(popup_size * EDSCALE);
} else {
-
EditorNode::get_singleton()->show_warning(TTR("No VCS addons are available."), TTR("Error"));
}
}
void VersionControlEditorPlugin::_initialize_vcs() {
-
register_editor();
ERR_FAIL_COND_MSG(EditorVCSInterface::get_singleton(), EditorVCSInterface::get_singleton()->get_vcs_name() + " is already active");
@@ -129,18 +119,14 @@ void VersionControlEditorPlugin::_initialize_vcs() {
}
void VersionControlEditorPlugin::_send_commit_msg() {
-
String msg = commit_message->get_text();
if (msg == "") {
-
commit_status->set_text(TTR("No commit message was provided"));
return;
}
if (EditorVCSInterface::get_singleton()) {
-
if (staged_files_count == 0) {
-
commit_status->set_text(TTR("No files added to stage"));
return;
}
@@ -150,7 +136,6 @@ void VersionControlEditorPlugin::_send_commit_msg() {
commit_message->set_text("");
version_control_dock_button->set_pressed(false);
} else {
-
WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu");
}
@@ -160,20 +145,16 @@ void VersionControlEditorPlugin::_send_commit_msg() {
}
void VersionControlEditorPlugin::_refresh_stage_area() {
-
if (EditorVCSInterface::get_singleton()) {
-
staged_files_count = 0;
clear_stage_area();
Dictionary modified_file_paths = EditorVCSInterface::get_singleton()->get_modified_files_data();
String file_path;
for (int i = 0; i < modified_file_paths.size(); i++) {
-
file_path = modified_file_paths.get_key_at_index(i);
TreeItem *found = stage_files->search_item_text(file_path, nullptr, true);
if (!found) {
-
ChangeType change_index = (ChangeType)(int)modified_file_paths.get_value_at_index(i);
String change_text = file_path + " (" + change_type_to_strings[change_index] + ")";
Color &change_color = change_type_to_color[change_index];
@@ -185,24 +166,19 @@ void VersionControlEditorPlugin::_refresh_stage_area() {
new_item->set_checked(0, true);
new_item->set_editable(0, true);
} else {
-
if (found->get_metadata(0) == diff_file_name->get_text()) {
-
_refresh_file_diff();
}
}
commit_status->set_text("New changes detected");
}
} else {
-
WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu.");
}
}
void VersionControlEditorPlugin::_stage_selected() {
-
if (!EditorVCSInterface::get_singleton()) {
-
WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu");
return;
}
@@ -210,17 +186,13 @@ void VersionControlEditorPlugin::_stage_selected() {
staged_files_count = 0;
TreeItem *root = stage_files->get_root();
if (root) {
-
TreeItem *file_entry = root->get_children();
while (file_entry) {
-
if (file_entry->is_checked(0)) {
-
EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0));
file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
staged_files_count++;
} else {
-
EditorVCSInterface::get_singleton()->unstage_file(file_entry->get_metadata(0));
file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
}
@@ -233,9 +205,7 @@ void VersionControlEditorPlugin::_stage_selected() {
}
void VersionControlEditorPlugin::_stage_all() {
-
if (!EditorVCSInterface::get_singleton()) {
-
WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu");
return;
}
@@ -243,10 +213,8 @@ void VersionControlEditorPlugin::_stage_all() {
staged_files_count = 0;
TreeItem *root = stage_files->get_root();
if (root) {
-
TreeItem *file_entry = root->get_children();
while (file_entry) {
-
EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0));
file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
file_entry->set_checked(0, true);
@@ -260,7 +228,6 @@ void VersionControlEditorPlugin::_stage_all() {
}
void VersionControlEditorPlugin::_view_file_diff() {
-
version_control_dock_button->set_pressed(true);
String file_path = stage_files->get_selected()->get_metadata(0);
@@ -269,7 +236,6 @@ void VersionControlEditorPlugin::_view_file_diff() {
}
void VersionControlEditorPlugin::_display_file_diff(String p_file_path) {
-
Array diff_content = EditorVCSInterface::get_singleton()->get_file_diff(p_file_path);
diff_file_name->set_text(p_file_path);
@@ -277,17 +243,13 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) {
diff->clear();
diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts"));
for (int i = 0; i < diff_content.size(); i++) {
-
Dictionary line_result = diff_content[i];
if (line_result["status"] == "+") {
-
diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"));
} else if (line_result["status"] == "-") {
-
diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"));
} else {
-
diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Label"));
}
@@ -299,42 +261,33 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) {
}
void VersionControlEditorPlugin::_refresh_file_diff() {
-
String open_file = diff_file_name->get_text();
if (open_file != "") {
-
_display_file_diff(diff_file_name->get_text());
}
}
void VersionControlEditorPlugin::_clear_file_diff() {
-
diff->clear();
diff_file_name->set_text("");
version_control_dock_button->set_pressed(false);
}
void VersionControlEditorPlugin::_update_stage_status() {
-
String status;
if (staged_files_count == 1) {
-
status = "Stage contains 1 file";
} else {
-
status = "Stage contains " + String::num_int64(staged_files_count) + " files";
}
commit_status->set_text(status);
}
void VersionControlEditorPlugin::_update_commit_status() {
-
String status;
if (staged_files_count == 1) {
-
status = "Committed 1 file";
} else {
-
status = "Committed " + String::num_int64(staged_files_count) + " files ";
}
commit_status->set_text(status);
@@ -342,9 +295,7 @@ void VersionControlEditorPlugin::_update_commit_status() {
}
void VersionControlEditorPlugin::register_editor() {
-
if (!EditorVCSInterface::get_singleton()) {
-
EditorNode::get_singleton()->add_control_to_dock(EditorNode::DOCK_SLOT_RIGHT_UL, version_commit_dock);
TabContainer *dock_vbc = (TabContainer *)version_commit_dock->get_parent_control();
dock_vbc->set_tab_title(version_commit_dock->get_index(), TTR("Commit"));
@@ -355,30 +306,25 @@ void VersionControlEditorPlugin::register_editor() {
}
void VersionControlEditorPlugin::fetch_available_vcs_addon_names() {
-
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
for (int i = 0; i != global_classes.size(); i++) {
-
String path = ScriptServer::get_global_class_path(global_classes[i]);
Ref<Script> script = ResourceLoader::load(path);
ERR_FAIL_COND(script.is_null());
if (script->get_instance_base_type() == "EditorVCSInterface") {
-
available_addons.push_back(global_classes[i]);
}
}
}
void VersionControlEditorPlugin::clear_stage_area() {
-
stage_files->get_root()->clear_children();
}
void VersionControlEditorPlugin::shut_down() {
-
if (EditorVCSInterface::get_singleton()) {
if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area))) {
EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));
@@ -393,17 +339,14 @@ void VersionControlEditorPlugin::shut_down() {
}
bool VersionControlEditorPlugin::is_vcs_initialized() const {
-
return EditorVCSInterface::get_singleton() ? EditorVCSInterface::get_singleton()->is_vcs_initialized() : false;
}
const String VersionControlEditorPlugin::get_vcs_name() const {
-
return EditorVCSInterface::get_singleton() ? EditorVCSInterface::get_singleton()->get_vcs_name() : "";
}
VersionControlEditorPlugin::VersionControlEditorPlugin() {
-
singleton = this;
staged_files_count = 0;
@@ -570,7 +513,6 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
}
VersionControlEditorPlugin::~VersionControlEditorPlugin() {
-
shut_down();
memdelete(version_control_dock);
memdelete(version_commit_dock);
diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h
index 4a98c8580e..664e38d65f 100644
--- a/editor/plugins/version_control_editor_plugin.h
+++ b/editor/plugins/version_control_editor_plugin.h
@@ -39,7 +39,6 @@
#include "scene/gui/tree.h"
class VersionControlEditorPlugin : public EditorPlugin {
-
GDCLASS(VersionControlEditorPlugin, EditorPlugin)
public:
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 07251ad7ad..92bdba93e7 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -48,7 +48,6 @@
#include "servers/rendering/shader_types.h"
Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
-
if (get_script_instance()) {
return get_script_instance()->call("create_editor", p_parent_resource, p_node);
}
@@ -56,14 +55,12 @@ Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_res
}
void VisualShaderNodePlugin::_bind_methods() {
-
BIND_VMETHOD(MethodInfo(Variant::OBJECT, "create_editor", PropertyInfo(Variant::OBJECT, "parent_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::OBJECT, "for_node", PROPERTY_HINT_RESOURCE_TYPE, "VisualShaderNode")));
}
///////////////////
void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
-
bool changed = false;
if (p_visual_shader) {
if (visual_shader.is_null()) {
@@ -106,8 +103,9 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
}
void VisualShaderEditor::add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin) {
- if (plugins.find(p_plugin) != -1)
+ if (plugins.find(p_plugin) != -1) {
return;
+ }
plugins.push_back(p_plugin);
}
@@ -125,14 +123,14 @@ void VisualShaderEditor::clear_custom_types() {
}
void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) {
-
ERR_FAIL_COND(!p_name.is_valid_identifier());
ERR_FAIL_COND(!p_script.is_valid());
for (int i = 0; i < add_options.size(); i++) {
if (add_options[i].is_custom) {
- if (add_options[i].script == p_script)
+ if (add_options[i].script == p_script) {
return;
+ }
}
}
@@ -166,11 +164,9 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script>
}
bool VisualShaderEditor::_is_available(int p_mode) {
-
int current_mode = edit_type->get_selected();
if (p_mode != -1) {
-
switch (current_mode) {
case VisualShader::TYPE_VERTEX:
current_mode = 1;
@@ -215,7 +211,6 @@ void VisualShaderEditor::update_custom_nodes() {
Dictionary added;
for (int i = 0; i < class_list.size(); i++) {
if (ScriptServer::get_global_class_native_base(class_list[i]) == "VisualShaderNodeCustom") {
-
String script_path = ScriptServer::get_global_class_path(class_list[i]);
Ref<Resource> res = ResourceLoader::load(script_path);
ERR_FAIL_COND(res.is_null());
@@ -285,7 +280,6 @@ void VisualShaderEditor::update_custom_nodes() {
keys.sort();
for (int i = 0; i < keys.size(); i++) {
-
const Variant &key = keys.get(i);
const Dictionary &value = (Dictionary)added[key];
@@ -301,7 +295,6 @@ String VisualShaderEditor::_get_description(int p_idx) {
}
void VisualShaderEditor::_update_options_menu() {
-
node_desc->set_text("");
members_dialog->get_ok()->set_disabled(true);
@@ -374,10 +367,11 @@ void VisualShaderEditor::_update_options_menu() {
}
TreeItem *item = members->create_item(category);
- if (options[i].highend && low_driver)
+ if (options[i].highend && low_driver) {
item->set_custom_color(0, unsupported_color);
- else if (options[i].highend)
+ } else if (options[i].highend) {
item->set_custom_color(0, supported_color);
+ }
item->set_text(0, options[i].name);
if (is_first_item && use_filter) {
item->select(0);
@@ -411,15 +405,14 @@ void VisualShaderEditor::_update_options_menu() {
}
Size2 VisualShaderEditor::get_minimum_size() const {
-
return Size2(10, 200);
}
void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) {
-
Button *button = Object::cast_to<Button>(obj);
- if (!button)
+ if (!button) {
return;
+ }
Ref<StyleBox> normal = get_theme_stylebox("normal", "Button");
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
@@ -435,7 +428,6 @@ static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_
}
void VisualShaderEditor::_update_created_node(GraphNode *node) {
-
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode");
Color c = sb->get_border_color();
@@ -459,12 +451,13 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
}
void VisualShaderEditor::_update_graph() {
-
- if (updating)
+ if (updating) {
return;
+ }
- if (visual_shader.is_null())
+ if (visual_shader.is_null()) {
return;
+ }
graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE);
@@ -472,7 +465,6 @@ void VisualShaderEditor::_update_graph() {
graph->clear_connections();
//erase all nodes
for (int i = 0; i < graph->get_child_count(); i++) {
-
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
Node *node = graph->get_child(i);
graph->remove_child(node);
@@ -500,7 +492,6 @@ void VisualShaderEditor::_update_graph() {
Control *offset;
for (int n_i = 0; n_i < nodes.size(); n_i++) {
-
Vector2 position = visual_shader->get_node_position(type, nodes[n_i]);
Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]);
@@ -592,7 +583,6 @@ void VisualShaderEditor::_update_graph() {
if (custom_editor && !float_uniform.is_valid() && !int_uniform.is_valid() && !vec3_uniform.is_valid() && !bool_uniform.is_valid() && !transform_uniform.is_valid() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
//will be embedded in first port
} else if (custom_editor) {
-
port_offset++;
node->add_child(custom_editor);
if (color_uniform.is_valid()) {
@@ -606,7 +596,6 @@ void VisualShaderEditor::_update_graph() {
}
if (is_group) {
-
offset = memnew(Control);
offset->set_custom_minimum_size(Size2(0, 6 * EDSCALE));
node->add_child(offset);
@@ -631,7 +620,6 @@ void VisualShaderEditor::_update_graph() {
}
for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
-
if (vsnode->is_port_separator(i)) {
node->add_child(memnew(HSeparator));
port_offset++;
@@ -674,7 +662,6 @@ void VisualShaderEditor::_update_graph() {
button->connect("pressed", callable_mp(this, &VisualShaderEditor::_edit_port_default_input), varray(button, nodes[n_i], i));
switch (default_value.get_type()) {
-
case Variant::COLOR: {
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
button->connect("draw", callable_mp(this, &VisualShaderEditor::_draw_color_over_button), varray(button, default_value));
@@ -699,9 +686,7 @@ void VisualShaderEditor::_update_graph() {
hb->add_child(custom_editor);
custom_editor->set_h_size_flags(SIZE_EXPAND_FILL);
} else {
-
if (valid_left) {
-
if (is_group) {
OptionButton *type_box = memnew(OptionButton);
hb->add_child(type_box);
@@ -729,14 +714,12 @@ void VisualShaderEditor::_update_graph() {
remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
hb->add_child(remove_btn);
} else {
-
Label *label = memnew(Label);
label->set_text(name_left);
label->add_theme_style_override("normal", label_style); //more compact
hb->add_child(label);
if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) {
-
Label *hint_label = memnew(Label);
hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]");
hint_label->add_theme_color_override("font_color", get_theme_color("font_color_readonly", "TextEdit"));
@@ -840,7 +823,6 @@ void VisualShaderEditor::_update_graph() {
}
if (is_expression) {
-
TextEdit *expression_box = memnew(TextEdit);
expression_node->set_control(expression_box, 0);
node->add_child(expression_box);
@@ -855,7 +837,6 @@ void VisualShaderEditor::_update_graph() {
expression_box->add_theme_color_override("background_color", background_color);
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
-
expression_box->add_keyword_color(E->get(), keyword_color);
}
@@ -875,13 +856,13 @@ void VisualShaderEditor::_update_graph() {
if (!uniform.is_valid()) {
graph->add_child(node);
_update_created_node(node);
- if (is_group)
+ if (is_group) {
call_deferred("_set_node_size", (int)type, nodes[n_i], size);
+ }
}
}
for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {
-
int from = E->get().from_node;
int from_idx = E->get().from_port;
int to = E->get().to_node;
@@ -892,7 +873,6 @@ void VisualShaderEditor::_update_graph() {
}
void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type, const String &p_name) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -910,7 +890,6 @@ void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type
}
void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_type, const String &p_name) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -928,7 +907,6 @@ void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_typ
}
void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_port) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -946,7 +924,6 @@ void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_p
}
void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_port) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -964,7 +941,6 @@ void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_
}
void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
@@ -979,7 +955,6 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *l
}
void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
@@ -994,7 +969,6 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *
}
void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -1006,7 +980,6 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
List<VisualShader::Connection> conns;
visual_shader->get_node_connections(type, &conns);
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
-
int from_node = E->get().from_node;
int from_port = E->get().from_port;
int to_node = E->get().to_node;
@@ -1039,7 +1012,6 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
}
void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -1051,7 +1023,6 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
List<VisualShader::Connection> conns;
visual_shader->get_node_connections(type, &conns);
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
-
int from_node = E->get().from_node;
int from_port = E->get().from_port;
int to_node = E->get().to_node;
@@ -1084,7 +1055,6 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
}
void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -1093,8 +1063,9 @@ void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) {
TextEdit *expression_box = Object::cast_to<TextEdit>(text_edit);
- if (node->get_expression() == expression_box->get_text())
+ if (node->get_expression() == expression_box->get_text()) {
return;
+ }
undo_redo->create_action(TTR("Set expression"));
undo_redo->add_do_method(node.ptr(), "set_expression", expression_box->get_text());
@@ -1112,7 +1083,6 @@ void VisualShaderEditor::_rebuild() {
}
void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p_size) {
-
VisualShader::Type type = VisualShader::Type(p_type);
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -1133,8 +1103,9 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p
if (edit_type->get_selected() == p_type) { // check - otherwise the error will be emitted
Node *node2 = graph->get_node(itos(p_node));
gn = Object::cast_to<GraphNode>(node2);
- if (!gn)
+ if (!gn) {
return;
+ }
gn->set_custom_minimum_size(size);
gn->set_size(Size2(1, 1));
@@ -1159,7 +1130,6 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p
}
void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, int p_node) {
-
VisualShader::Type type = VisualShader::Type(p_type);
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -1173,7 +1143,6 @@ void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, in
}
void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
if (node.is_null()) {
@@ -1192,7 +1161,6 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
}
void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_edit, int p_node_id) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id);
@@ -1213,13 +1181,11 @@ void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_e
}
void VisualShaderEditor::_line_edit_focus_out(Object *line_edit, int p_node_id) {
-
String text = Object::cast_to<LineEdit>(line_edit)->get_text();
_line_edit_changed(text, line_edit, p_node_id);
}
void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
@@ -1228,24 +1194,28 @@ void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id,
String text = Object::cast_to<LineEdit>(line_edit)->get_text();
if (!p_output) {
- if (node->get_input_port_name(p_port_id) == text)
+ if (node->get_input_port_name(p_port_id) == text) {
return;
+ }
} else {
- if (node->get_output_port_name(p_port_id) == text)
+ if (node->get_output_port_name(p_port_id) == text) {
return;
+ }
}
List<String> input_names;
List<String> output_names;
for (int i = 0; i < node->get_input_port_count(); i++) {
- if (!p_output && i == p_port_id)
+ if (!p_output && i == p_port_id) {
continue;
+ }
input_names.push_back(node->get_input_port_name(i));
}
for (int i = 0; i < node->get_output_port_count(); i++) {
- if (p_output && i == p_port_id)
+ if (p_output && i == p_port_id) {
continue;
+ }
output_names.push_back(node->get_output_port_name(i));
}
@@ -1267,7 +1237,6 @@ void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id,
}
void VisualShaderEditor::_port_edited() {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Variant value = property_editor->get_variant();
@@ -1285,7 +1254,6 @@ void VisualShaderEditor::_port_edited() {
}
void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, int p_port) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNode> vsn = visual_shader->get_node(type, p_node);
@@ -1301,7 +1269,6 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node,
}
void VisualShaderEditor::_add_custom_node(const String &p_path) {
-
int idx = -1;
for (int i = custom_node_option_idx; i < add_options.size(); i++) {
@@ -1323,7 +1290,6 @@ void VisualShaderEditor::_add_texture_node(const String &p_path) {
}
VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
-
ERR_FAIL_INDEX_V(p_idx, add_options.size(), nullptr);
Ref<VisualShaderNode> vsnode;
@@ -1337,12 +1303,12 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn);
if (constant) {
- if ((int)add_options[p_idx].value != -1)
+ if ((int)add_options[p_idx].value != -1) {
constant->set_constant(add_options[p_idx].value);
+ }
}
if (p_op_idx != -1) {
-
VisualShaderNodeInput *input = Object::cast_to<VisualShaderNodeInput>(vsn);
if (input) {
@@ -1463,7 +1429,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
if (to_node != -1 && to_slot != -1) {
if (vsnode->get_output_port_count() > 0) {
-
int _from_node = id_to_use;
int _from_slot = 0;
@@ -1474,7 +1439,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
}
} else if (from_node != -1 && from_slot != -1) {
if (vsnode->get_input_port_count() > 0) {
-
int _to_node = id_to_use;
int _to_slot = 0;
@@ -1492,7 +1456,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
}
void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
updating = true;
@@ -1506,7 +1469,6 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t
}
void VisualShaderEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
int from = p_from.to_int();
@@ -1536,7 +1498,6 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in
}
void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
-
graph->disconnect_node(p_from, p_from_index, p_to, p_to_index);
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
@@ -1567,7 +1528,6 @@ void VisualShaderEditor::_connection_from_empty(const String &p_to, int p_to_slo
}
void VisualShaderEditor::_delete_request(int which) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
Ref<VisualShaderNode> node = Ref<VisualShaderNode>(visual_shader->get_node(type, which));
@@ -1607,7 +1567,6 @@ void VisualShaderEditor::_delete_request(int which) {
}
void VisualShaderEditor::_node_selected(Object *p_node) {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
GraphNode *gn = Object::cast_to<GraphNode>(p_node);
@@ -1623,7 +1582,6 @@ void VisualShaderEditor::_node_selected(Object *p_node) {
}
void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
@@ -1652,7 +1610,6 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
}
void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
-
if (at_mouse_pos) {
saved_node_pos_dirty = true;
saved_node_pos = graph->get_local_mouse_position();
@@ -1688,7 +1645,6 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
ie->get_keycode() == KEY_DOWN ||
ie->get_keycode() == KEY_ENTER ||
ie->get_keycode() == KEY_KP_ENTER)) {
-
members->call("_gui_input", ie);
node_filter->accept_event();
}
@@ -1696,7 +1652,6 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
void VisualShaderEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
-
node_filter->set_clear_button_enabled(true);
// collapse tree by default
@@ -1723,7 +1678,6 @@ void VisualShaderEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
-
highend_label->set_modulate(get_theme_color("vulkan_color", "Editor"));
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
@@ -1743,7 +1697,6 @@ void VisualShaderEditor::_notification(int p_what) {
preview_text->add_theme_color_override("background_color", background_color);
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
-
preview_text->add_keyword_color(E->get(), keyword_color);
}
@@ -1759,22 +1712,25 @@ void VisualShaderEditor::_notification(int p_what) {
tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Tools", "EditorIcons"));
- if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree())
+ if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) {
_update_graph();
+ }
}
}
void VisualShaderEditor::_scroll_changed(const Vector2 &p_scroll) {
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
visual_shader->set_graph_offset(p_scroll / EDSCALE);
updating = false;
}
void VisualShaderEditor::_node_changed(int p_id) {
- if (updating)
+ if (updating) {
return;
+ }
if (is_visible_in_tree()) {
_update_graph();
@@ -1786,7 +1742,6 @@ void VisualShaderEditor::_dup_update_excluded(int p_type, Set<int> &r_excluded)
VisualShader::Type type = (VisualShader::Type)p_type;
for (int i = 0; i < graph->get_child_count(); i++) {
-
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
int id = String(gn->get_name()).to_int();
@@ -1802,14 +1757,12 @@ void VisualShaderEditor::_dup_update_excluded(int p_type, Set<int> &r_excluded)
}
void VisualShaderEditor::_dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int> &r_excluded) {
-
VisualShader::Type type = (VisualShader::Type)p_type;
selection_center.x = 0.0f;
selection_center.y = 0.0f;
for (int i = 0; i < graph->get_child_count(); i++) {
-
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
int id = String(gn->get_name()).to_int();
@@ -1832,7 +1785,6 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int
}
void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<int> &r_nodes, Set<int> &r_excluded, const Vector2 &p_offset, bool p_select) {
-
VisualShader::Type type = (VisualShader::Type)p_type;
VisualShader::Type pasted_type = (VisualShader::Type)p_pasted_type;
@@ -1842,7 +1794,6 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
Set<int> unsupported_set;
for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) {
-
connection_remap[E->get()] = id_from;
Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E->get());
@@ -1900,7 +1851,6 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
if (p_select) {
// reselect duplicated nodes by excluding the other ones
for (int i = 0; i < graph->get_child_count(); i++) {
-
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
int id = String(gn->get_name()).to_int();
@@ -1915,13 +1865,11 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
}
void VisualShaderEditor::_clear_buffer() {
-
copy_nodes_buffer.clear();
copy_nodes_excluded_buffer.clear();
}
void VisualShaderEditor::_duplicate_nodes() {
-
int type = edit_type->get_selected();
List<int> nodes;
@@ -1929,8 +1877,9 @@ void VisualShaderEditor::_duplicate_nodes() {
_dup_copy_nodes(type, nodes, excluded);
- if (nodes.empty())
+ if (nodes.empty()) {
return;
+ }
undo_redo->create_action(TTR("Duplicate Nodes"));
@@ -1938,7 +1887,6 @@ void VisualShaderEditor::_duplicate_nodes() {
}
void VisualShaderEditor::_copy_nodes() {
-
copy_type = edit_type->get_selected();
_clear_buffer();
@@ -1947,9 +1895,9 @@ void VisualShaderEditor::_copy_nodes() {
}
void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) {
-
- if (copy_nodes_buffer.empty())
+ if (copy_nodes_buffer.empty()) {
return;
+ }
int type = edit_type->get_selected();
@@ -1970,7 +1918,6 @@ void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2
}
void VisualShaderEditor::_delete_nodes() {
-
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
List<int> to_erase;
@@ -1983,13 +1930,13 @@ void VisualShaderEditor::_delete_nodes() {
}
}
- if (to_erase.empty())
+ if (to_erase.empty()) {
return;
+ }
undo_redo->create_action(TTR("Delete Nodes"));
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
-
Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get());
undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get());
@@ -2020,7 +1967,6 @@ void VisualShaderEditor::_delete_nodes() {
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
if (E->get().from_node == F->get() || E->get().to_node == F->get()) {
-
bool cancel = false;
for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) {
if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) {
@@ -2042,17 +1988,16 @@ void VisualShaderEditor::_delete_nodes() {
}
void VisualShaderEditor::_mode_selected(int p_id) {
-
_update_options_menu();
_update_graph();
}
void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> input, String name) {
-
String prev_name = input->get_input_name();
- if (name == prev_name)
+ if (name == prev_name) {
return;
+ }
bool type_changed = input->get_input_type_by_name(name) != input->get_input_type_by_name(prev_name);
@@ -2119,7 +2064,6 @@ void VisualShaderEditor::_member_cancel() {
}
void VisualShaderEditor::_tools_menu_option(int p_idx) {
-
TreeItem *category = members->get_root()->get_children();
switch (p_idx) {
@@ -2176,13 +2120,14 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
}
Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
if (p_from == members) {
TreeItem *it = members->get_item_at_position(p_point);
- if (!it)
+ if (!it) {
return Variant();
- if (!it->has_meta("id"))
+ }
+ if (!it->has_meta("id")) {
return Variant();
+ }
int id = it->get_meta("id");
AddOption op = add_options[id];
@@ -2204,9 +2149,7 @@ Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
}
bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
if (p_from == graph) {
-
Dictionary d = p_data;
if (d.has("id")) {
@@ -2221,9 +2164,7 @@ bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
if (p_from == graph) {
-
Dictionary d = p_data;
if (d.has("id")) {
@@ -2233,11 +2174,9 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
_add_node(idx, add_options[idx].sub_func);
} else if (d.has("files")) {
if (d["files"].get_type() == Variant::PACKED_STRING_ARRAY) {
-
int j = 0;
PackedStringArray arr = d["files"];
for (int i = 0; i < arr.size(); i++) {
-
String type = ResourceLoader::get_resource_type(arr[i]);
if (type == "GDScript") {
Ref<Script> script = ResourceLoader::load(arr[i]);
@@ -2271,13 +2210,11 @@ void VisualShaderEditor::_show_preview_text() {
}
static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
-
RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
return RS::global_variable_type_get_shader_datatype(gvt);
}
void VisualShaderEditor::_update_preview() {
-
if (!preview_showed) {
pending_update_preview = true;
return;
@@ -2327,7 +2264,6 @@ void VisualShaderEditor::_bind_methods() {
VisualShaderEditor *VisualShaderEditor::singleton = nullptr;
VisualShaderEditor::VisualShaderEditor() {
-
singleton = this;
updating = false;
saved_node_pos_dirty = false;
@@ -2945,17 +2881,14 @@ VisualShaderEditor::VisualShaderEditor() {
}
void VisualShaderEditorPlugin::edit(Object *p_object) {
-
visual_shader_editor->edit(Object::cast_to<VisualShader>(p_object));
}
bool VisualShaderEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("VisualShader");
}
void VisualShaderEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
//editor->hide_animation_player_editors();
//editor->animation_panel_make_visible(true);
@@ -2965,9 +2898,9 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) {
visual_shader_editor->set_process_input(true);
//visual_shader_editor->set_process(true);
} else {
-
- if (visual_shader_editor->is_visible_in_tree())
+ if (visual_shader_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ }
button->hide();
visual_shader_editor->set_process_input(false);
//visual_shader_editor->set_process(false);
@@ -2975,7 +2908,6 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) {
}
VisualShaderEditorPlugin::VisualShaderEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
visual_shader_editor = memnew(VisualShaderEditor);
visual_shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
@@ -3037,9 +2969,9 @@ class VisualShaderNodePluginDefaultEditor : public VBoxContainer {
public:
void _property_changed(const String &p_property, const Variant &p_value, const String &p_field = "", bool p_changing = false) {
-
- if (p_changing)
+ if (p_changing) {
return;
+ }
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
@@ -3049,7 +2981,6 @@ public:
undo_redo->add_undo_property(node.ptr(), p_property, node->get(p_property));
if (p_value.get_type() == Variant::OBJECT) {
-
RES prev_res = node->get(p_property);
RES curr_res = p_value;
@@ -3072,8 +3003,9 @@ public:
}
void _node_changed() {
- if (updating)
+ if (updating) {
return;
+ }
for (int i = 0; i < properties.size(); i++) {
properties[i]->update_property();
}
@@ -3109,7 +3041,6 @@ public:
properties = p_properties;
for (int i = 0; i < p_properties.size(); i++) {
-
HBoxContainer *hbox = memnew(HBoxContainer);
hbox->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(hbox);
@@ -3147,7 +3078,6 @@ public:
};
Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
-
if (p_node->is_class("VisualShaderNodeInput")) {
//create input
VisualShaderNodePluginInputEditor *input_editor = memnew(VisualShaderNodePluginInputEditor);
@@ -3166,7 +3096,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
Vector<PropertyInfo> pinfo;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
for (int i = 0; i < properties.size(); i++) {
if (E->get().name == String(properties[i])) {
pinfo.push_back(E->get());
@@ -3174,8 +3103,9 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
}
}
- if (pinfo.size() == 0)
+ if (pinfo.size() == 0) {
return nullptr;
+ }
properties.clear();
@@ -3183,10 +3113,10 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
Vector<EditorProperty *> editors;
for (int i = 0; i < pinfo.size(); i++) {
-
EditorProperty *prop = EditorInspector::instantiate_property_editor(node.ptr(), pinfo[i].type, pinfo[i].name, pinfo[i].hint, pinfo[i].hint_string, pinfo[i].usage);
- if (!prop)
+ if (!prop) {
return nullptr;
+ }
if (Object::cast_to<EditorPropertyResource>(prop)) {
Object::cast_to<EditorPropertyResource>(prop)->set_use_sub_inspector(false);
@@ -3209,14 +3139,14 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
}
void EditorPropertyShaderMode::_option_selected(int p_which) {
-
//will not use this, instead will do all the logic setting manually
//emit_signal("property_changed", get_edited_property(), p_which);
Ref<VisualShader> visual_shader(Object::cast_to<VisualShader>(get_edited_object()));
- if (visual_shader->get_mode() == p_which)
+ if (visual_shader->get_mode() == p_which) {
return;
+ }
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Visual Shader Mode Changed"));
@@ -3227,7 +3157,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
//1. restore connections to output
for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
-
VisualShader::Type type = VisualShader::Type(i);
List<VisualShader::Connection> conns;
visual_shader->get_node_connections(type, &conns);
@@ -3239,7 +3168,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
}
//2. restore input indices
for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
-
VisualShader::Type type = VisualShader::Type(i);
Vector<int> nodes = visual_shader->get_node_list(type);
for (int j = 0; j < nodes.size(); j++) {
@@ -3257,7 +3185,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
visual_shader->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
if (E->get().name.begins_with("flags/") || E->get().name.begins_with("modes/")) {
undo_redo->add_undo_property(visual_shader.ptr(), E->get().name, visual_shader->get(E->get().name));
}
@@ -3274,7 +3201,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
}
void EditorPropertyShaderMode::update_property() {
-
int which = get_edited_object()->get(get_edited_property());
options->select(which);
}
@@ -3309,9 +3235,7 @@ void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) {
}
bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
-
if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) {
-
EditorPropertyShaderMode *editor = memnew(EditorPropertyShaderMode);
Vector<String> options = p_hint_text.split(",");
editor->setup(options);
@@ -3326,6 +3250,7 @@ bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::
void EditorInspectorShaderModePlugin::parse_end() {
//do none
}
+
//////////////////////////////////
void VisualShaderNodePortPreview::_shader_changed() {
@@ -3351,11 +3276,11 @@ void VisualShaderNodePortPreview::_shader_changed() {
for (int i = EditorNode::get_singleton()->get_editor_history()->get_path_size() - 1; i >= 0; i--) {
Object *object = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_path_object(i));
- if (!object)
+ if (!object) {
continue;
+ }
ShaderMaterial *src_mat = Object::cast_to<ShaderMaterial>(object);
if (src_mat && src_mat->get_shader().is_valid()) {
-
List<PropertyInfo> params;
src_mat->get_shader()->get_param_list(&params);
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
@@ -3368,7 +3293,6 @@ void VisualShaderNodePortPreview::_shader_changed() {
}
void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) {
-
shader = p_shader;
shader->connect("changed", callable_mp(this, &VisualShaderNodePortPreview::_shader_changed));
type = p_type;
@@ -3413,18 +3337,15 @@ VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
//////////////////////////////////
String VisualShaderConversionPlugin::converts_to() const {
-
return "Shader";
}
bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const {
-
Ref<VisualShader> vshader = p_resource;
return vshader.is_valid();
}
Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {
-
Ref<VisualShader> vshader = p_resource;
ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>());
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index a495b09b5c..d2f10d9407 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -41,7 +41,6 @@
#include "scene/resources/visual_shader.h"
class VisualShaderNodePlugin : public Reference {
-
GDCLASS(VisualShaderNodePlugin, Reference);
protected:
@@ -52,7 +51,6 @@ public:
};
class VisualShaderEditor : public VBoxContainer {
-
GDCLASS(VisualShaderEditor, VBoxContainer);
CustomPropertyEditor *property_editor;
@@ -157,7 +155,6 @@ class VisualShaderEditor : public VBoxContainer {
}
};
struct _OptionComparator {
-
_FORCE_INLINE_ bool operator()(const AddOption &a, const AddOption &b) const {
return a.category.count("/") > b.category.count("/") || (a.category + "/" + a.name).naturalnocasecmp_to(b.category + "/" + b.name) < 0;
}
@@ -290,7 +287,6 @@ public:
};
class VisualShaderEditorPlugin : public EditorPlugin {
-
GDCLASS(VisualShaderEditorPlugin, EditorPlugin);
VisualShaderEditor *visual_shader_editor;
@@ -309,7 +305,6 @@ public:
};
class VisualShaderNodePluginDefault : public VisualShaderNodePlugin {
-
GDCLASS(VisualShaderNodePluginDefault, VisualShaderNodePlugin);
public:
diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp
index 86df069b8b..541cba836b 100644
--- a/editor/progress_dialog.cpp
+++ b/editor/progress_dialog.cpp
@@ -37,7 +37,6 @@
#include "servers/display_server.h"
void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_MSG(tasks.has(p_task), "Task '" + p_task + "' already exists.");
BackgroundProgress::Task t;
@@ -62,11 +61,9 @@ void BackgroundProgress::_add_task(const String &p_task, const String &p_label,
}
void BackgroundProgress::_update() {
-
_THREAD_SAFE_METHOD_
for (Map<String, int>::Element *E = updates.front(); E; E = E->next()) {
-
if (tasks.has(E->key())) {
_task_step(E->key(), E->get());
}
@@ -76,19 +73,19 @@ void BackgroundProgress::_update() {
}
void BackgroundProgress::_task_step(const String &p_task, int p_step) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!tasks.has(p_task));
Task &t = tasks[p_task];
- if (p_step < 0)
+ if (p_step < 0) {
t.progress->set_value(t.progress->get_value() + 1);
- else
+ } else {
t.progress->set_value(p_step);
+ }
}
-void BackgroundProgress::_end_task(const String &p_task) {
+void BackgroundProgress::_end_task(const String &p_task) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!tasks.has(p_task));
@@ -99,7 +96,6 @@ void BackgroundProgress::_end_task(const String &p_task) {
}
void BackgroundProgress::_bind_methods() {
-
ClassDB::bind_method("_add_task", &BackgroundProgress::_add_task);
ClassDB::bind_method("_task_step", &BackgroundProgress::_task_step);
ClassDB::bind_method("_end_task", &BackgroundProgress::_end_task);
@@ -107,11 +103,10 @@ void BackgroundProgress::_bind_methods() {
}
void BackgroundProgress::add_task(const String &p_task, const String &p_label, int p_steps) {
-
MessageQueue::get_singleton()->push_call(this, "_add_task", p_task, p_label, p_steps);
}
-void BackgroundProgress::task_step(const String &p_task, int p_step) {
+void BackgroundProgress::task_step(const String &p_task, int p_step) {
//this code is weird, but it prevents deadlock.
bool no_updates = true;
{
@@ -119,8 +114,9 @@ void BackgroundProgress::task_step(const String &p_task, int p_step) {
no_updates = updates.empty();
}
- if (no_updates)
+ if (no_updates) {
MessageQueue::get_singleton()->push_call(this, "_update");
+ }
{
_THREAD_SAFE_METHOD_
@@ -129,7 +125,6 @@ void BackgroundProgress::task_step(const String &p_task, int p_step) {
}
void BackgroundProgress::end_task(const String &p_task) {
-
MessageQueue::get_singleton()->push_call(this, "_end_task", p_task);
}
@@ -141,7 +136,6 @@ void ProgressDialog::_notification(int p_what) {
}
void ProgressDialog::_popup() {
-
Size2 ms = main->get_combined_minimum_size();
ms.width = MAX(500 * EDSCALE, ms.width);
@@ -157,7 +151,6 @@ void ProgressDialog::_popup() {
}
void ProgressDialog::add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
-
if (MessageQueue::get_singleton()->is_flushing()) {
ERR_PRINT("Do not use progress dialog (task) while flushing the message queue or using call_deferred()!");
return;
@@ -192,20 +185,21 @@ void ProgressDialog::add_task(const String &p_task, const String &p_label, int p
}
bool ProgressDialog::task_step(const String &p_task, const String &p_state, int p_step, bool p_force_redraw) {
-
ERR_FAIL_COND_V(!tasks.has(p_task), cancelled);
if (!p_force_redraw) {
uint64_t tus = OS::get_singleton()->get_ticks_usec();
- if (tus - last_progress_tick < 200000) //200ms
+ if (tus - last_progress_tick < 200000) { //200ms
return cancelled;
+ }
}
Task &t = tasks[p_task];
- if (p_step < 0)
+ if (p_step < 0) {
t.progress->set_value(t.progress->get_value() + 1);
- else
+ } else {
t.progress->set_value(p_step);
+ }
t.state->set_text(p_state);
last_progress_tick = OS::get_singleton()->get_ticks_usec();
@@ -218,17 +212,17 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int
}
void ProgressDialog::end_task(const String &p_task) {
-
ERR_FAIL_COND(!tasks.has(p_task));
Task &t = tasks[p_task];
memdelete(t.vb);
tasks.erase(p_task);
- if (tasks.empty())
+ if (tasks.empty()) {
hide();
- else
+ } else {
_popup();
+ }
}
void ProgressDialog::_cancel_pressed() {
@@ -239,7 +233,6 @@ void ProgressDialog::_bind_methods() {
}
ProgressDialog::ProgressDialog() {
-
main = memnew(VBoxContainer);
add_child(main);
main->set_anchors_and_margins_preset(Control::PRESET_WIDE);
diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h
index 82f479ae9d..753b6ac955 100644
--- a/editor/progress_dialog.h
+++ b/editor/progress_dialog.h
@@ -38,13 +38,11 @@
#include "scene/gui/progress_bar.h"
class BackgroundProgress : public HBoxContainer {
-
GDCLASS(BackgroundProgress, HBoxContainer);
_THREAD_SAFE_CLASS_
struct Task {
-
HBoxContainer *hb;
ProgressBar *progress;
};
@@ -69,10 +67,8 @@ public:
};
class ProgressDialog : public PopupPanel {
-
GDCLASS(ProgressDialog, PopupPanel);
struct Task {
-
String task;
VBoxContainer *vb;
ProgressBar *progress;
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 04ec5ae043..c53a59604a 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -52,11 +52,12 @@ void ProjectExportDialog::_theme_changed() {
duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons"));
delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons"));
Control *panel = custom_feature_display->get_parent_control();
- if (panel)
+ if (panel) {
panel->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree"));
+ }
}
-void ProjectExportDialog::_notification(int p_what) {
+void ProjectExportDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
@@ -73,10 +74,8 @@ void ProjectExportDialog::_notification(int p_what) {
}
void ProjectExportDialog::popup_export() {
-
add_preset->get_popup()->clear();
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
-
Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i);
add_preset->get_popup()->add_icon_item(plat->get_logo(), plat->get_name());
@@ -97,7 +96,6 @@ void ProjectExportDialog::popup_export() {
}
void ProjectExportDialog::_add_preset(int p_platform) {
-
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset();
ERR_FAIL_COND(!preset.is_valid());
@@ -105,7 +103,6 @@ void ProjectExportDialog::_add_preset(int p_platform) {
bool make_runnable = true;
int attempt = 1;
while (true) {
-
bool valid = true;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@@ -119,33 +116,40 @@ void ProjectExportDialog::_add_preset(int p_platform) {
}
}
- if (valid)
+ if (valid) {
break;
+ }
attempt++;
name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
}
preset->set_name(name);
- if (make_runnable)
+ if (make_runnable) {
preset->set_runnable(make_runnable);
+ }
EditorExport::get_singleton()->add_export_preset(preset);
_update_presets();
_edit_preset(EditorExport::get_singleton()->get_export_preset_count() - 1);
}
-void ProjectExportDialog::_update_current_preset() {
+void ProjectExportDialog::_force_update_current_preset_parameters() {
+ // Force the parameters section to refresh its UI.
+ parameters->edit(nullptr);
+ _update_current_preset();
+}
+void ProjectExportDialog::_update_current_preset() {
_edit_preset(presets->get_current());
}
void ProjectExportDialog::_update_presets() {
-
updating = true;
Ref<EditorExportPreset> current;
- if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count())
+ if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count()) {
current = get_current_preset();
+ }
int current_idx = -1;
presets->clear();
@@ -156,8 +160,10 @@ void ProjectExportDialog::_update_presets() {
}
String name = preset->get_name();
- if (preset->is_runnable())
+ if (preset->is_runnable()) {
name += " (" + TTR("Runnable") + ")";
+ }
+ preset->update_files_to_export();
presets->add_item(name, preset->get_platform()->get_logo());
}
@@ -169,7 +175,6 @@ void ProjectExportDialog::_update_presets() {
}
void ProjectExportDialog::_update_export_all() {
-
bool can_export = EditorExport::get_singleton()->get_export_preset_count() > 0;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@@ -190,7 +195,6 @@ void ProjectExportDialog::_update_export_all() {
}
void ProjectExportDialog::_edit_preset(int p_index) {
-
if (p_index < 0 || p_index >= presets->get_item_count()) {
name->set_text("");
name->set_editable(false);
@@ -246,8 +250,9 @@ void ProjectExportDialog::_edit_preset(int p_index) {
String file = patchlist[i].get_file();
patch->set_editable(0, true);
patch->set_text(0, file.get_file().replace("*", ""));
- if (file.ends_with("*"))
+ if (file.ends_with("*")) {
patch->set_checked(0, true);
+ }
patch->set_tooltip(0, patchlist[i]);
patch->set_metadata(0, i);
patch->add_button(0, presets->get_theme_icon("Remove", "EditorIcons"), 0);
@@ -256,10 +261,11 @@ void ProjectExportDialog::_edit_preset(int p_index) {
TreeItem *patch_add = patches->create_item(patch_root);
patch_add->set_metadata(0, patchlist.size());
- if (patchlist.size() == 0)
+ if (patchlist.size() == 0) {
patch_add->set_text(0, TTR("Add initial export..."));
- else
+ } else {
patch_add->set_text(0, TTR("Add previous patches..."));
+ }
patch_add->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1);
@@ -268,14 +274,13 @@ void ProjectExportDialog::_edit_preset(int p_index) {
bool needs_templates;
String error;
if (!current->get_platform()->can_export(current, error, needs_templates)) {
-
if (error != String()) {
-
Vector<String> items = error.split("\n", false);
error = "";
for (int i = 0; i < items.size(); i++) {
- if (i > 0)
+ if (i > 0) {
error += "\n";
+ }
error += " - " + items[i];
}
@@ -284,10 +289,11 @@ void ProjectExportDialog::_edit_preset(int p_index) {
} else {
export_error->hide();
}
- if (needs_templates)
+ if (needs_templates) {
export_templates_error->show();
- else
+ } else {
export_templates_error->hide();
+ }
export_button->set_disabled(true);
get_ok()->set_disabled(true);
@@ -329,7 +335,6 @@ void ProjectExportDialog::_edit_preset(int p_index) {
}
void ProjectExportDialog::_update_feature_list() {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -363,9 +368,9 @@ void ProjectExportDialog::_update_feature_list() {
}
void ProjectExportDialog::_custom_features_changed(const String &p_text) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -379,7 +384,6 @@ void ProjectExportDialog::_tab_changed(int) {
}
void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) {
-
TreeItem *ti = (TreeItem *)p_item;
patch_index = ti->get_metadata(0);
@@ -398,10 +402,10 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in
}
void ProjectExportDialog::_patch_edited() {
-
TreeItem *item = patches->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
int index = item->get_metadata(0);
Ref<EditorExportPreset> current = get_current_preset();
@@ -421,14 +425,12 @@ void ProjectExportDialog::_patch_edited() {
}
void ProjectExportDialog::_patch_selected(const String &p_path) {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Vector<String> patches = current->get_patches();
if (patch_index >= patches.size()) {
-
current->add_patch(ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + "*");
} else {
String enabled = patches[patch_index].ends_with("*") ? String("*") : String();
@@ -439,33 +441,29 @@ void ProjectExportDialog::_patch_selected(const String &p_path) {
}
void ProjectExportDialog::_patch_deleted() {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Vector<String> patches = current->get_patches();
if (patch_index < patches.size()) {
-
current->remove_patch(patch_index);
_update_current_preset();
}
}
void ProjectExportDialog::_update_parameters(const String &p_edited_property) {
-
_update_current_preset();
}
void ProjectExportDialog::_runnable_pressed() {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
if (runnable->is_pressed()) {
-
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
if (p->get_platform() == current->get_platform()) {
@@ -473,7 +471,6 @@ void ProjectExportDialog::_runnable_pressed() {
}
}
} else {
-
current->set_runnable(false);
}
@@ -481,9 +478,9 @@ void ProjectExportDialog::_runnable_pressed() {
}
void ProjectExportDialog::_name_changed(const String &p_string) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -507,14 +504,13 @@ String ProjectExportDialog::get_export_path() {
}
Ref<EditorExportPreset> ProjectExportDialog::get_current_preset() const {
-
return EditorExport::get_singleton()->get_export_preset(presets->get_current());
}
void ProjectExportDialog::_export_path_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -524,9 +520,9 @@ void ProjectExportDialog::_export_path_changed(const StringName &p_property, con
}
void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -537,9 +533,9 @@ void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
}
void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -552,7 +548,6 @@ void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) {
}
bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
-
bool is_valid = false;
if (!p_key.empty() && p_key.is_valid_hex_number(false) && p_key.length() == 64) {
@@ -562,10 +557,10 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
}
void ProjectExportDialog::_duplicate_preset() {
-
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
Ref<EditorExportPreset> preset = current->get_platform()->create_preset();
ERR_FAIL_COND(!preset.is_valid());
@@ -573,7 +568,6 @@ void ProjectExportDialog::_duplicate_preset() {
String name = current->get_name() + " (copy)";
bool make_runnable = true;
while (true) {
-
bool valid = true;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@@ -587,15 +581,17 @@ void ProjectExportDialog::_duplicate_preset() {
}
}
- if (valid)
+ if (valid) {
break;
+ }
name += " (copy)";
}
preset->set_name(name);
- if (make_runnable)
+ if (make_runnable) {
preset->set_runnable(make_runnable);
+ }
preset->set_export_filter(current->get_export_filter());
preset->set_include_filter(current->get_include_filter());
preset->set_exclude_filter(current->get_exclude_filter());
@@ -615,17 +611,16 @@ void ProjectExportDialog::_duplicate_preset() {
}
void ProjectExportDialog::_delete_preset() {
-
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name()));
delete_confirm->popup_centered();
}
void ProjectExportDialog::_delete_preset_confirm() {
-
int idx = presets->get_current();
_edit_preset(-1);
export_button->set_disabled(true);
@@ -635,7 +630,6 @@ void ProjectExportDialog::_delete_preset_confirm() {
}
Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
if (p_from == presets) {
int pos = presets->get_item_at_position(p_point, true);
@@ -657,11 +651,9 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
return d;
}
} else if (p_from == patches) {
-
TreeItem *item = patches->get_item_at_position(p_point);
if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) {
-
int metadata = item->get_metadata(0);
Dictionary d;
d["type"] = "export_patch";
@@ -679,26 +671,26 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
}
bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
if (p_from == presets) {
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "export_preset")
+ if (!d.has("type") || String(d["type"]) != "export_preset") {
return false;
+ }
- if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point))
+ if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point)) {
return false;
+ }
} else if (p_from == patches) {
-
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "export_patch")
+ if (!d.has("type") || String(d["type"]) != "export_patch") {
return false;
+ }
patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
TreeItem *item = patches->get_item_at_position(p_point);
if (!item) {
-
return false;
}
}
@@ -707,7 +699,6 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant
}
void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
if (p_from == presets) {
Dictionary d = p_data;
int from_pos = d["preset"];
@@ -718,12 +709,13 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
to_pos = presets->get_item_at_position(p_point, true);
}
- if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point))
+ if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point)) {
return;
+ }
- if (to_pos == from_pos)
+ if (to_pos == from_pos) {
return;
- else if (to_pos > from_pos) {
+ } else if (to_pos > from_pos) {
to_pos--;
}
@@ -732,27 +724,29 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
EditorExport::get_singleton()->add_export_preset(preset, to_pos);
_update_presets();
- if (to_pos >= 0)
+ if (to_pos >= 0) {
_edit_preset(to_pos);
- else
+ } else {
_edit_preset(presets->get_item_count() - 1);
+ }
} else if (p_from == patches) {
-
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "export_patch")
+ if (!d.has("type") || String(d["type"]) != "export_patch") {
return;
+ }
int from_pos = d["patch"];
TreeItem *item = patches->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return;
+ }
int to_pos = item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
- if (to_pos == from_pos)
+ if (to_pos == from_pos) {
return;
- else if (to_pos > from_pos) {
+ } else if (to_pos > from_pos) {
to_pos--;
}
@@ -766,13 +760,14 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
}
void ProjectExportDialog::_export_type_changed(int p_which) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
current->set_export_filter(EditorExportPreset::ExportFilter(p_which));
updating = true;
@@ -781,27 +776,28 @@ void ProjectExportDialog::_export_type_changed(int p_which) {
}
void ProjectExportDialog::_filter_changed(const String &p_filter) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
current->set_include_filter(include_filters->get_text());
current->set_exclude_filter(exclude_filters->get_text());
}
void ProjectExportDialog::_fill_resource_tree() {
-
include_files->clear();
include_label->hide();
include_margin->hide();
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
EditorExportPreset::ExportFilter f = current->get_export_filter();
@@ -818,13 +814,11 @@ void ProjectExportDialog::_fill_resource_tree() {
}
bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> &current, bool p_only_scenes) {
-
p_item->set_icon(0, presets->get_theme_icon("folder", "FileDialog"));
p_item->set_text(0, p_dir->get_name() + "/");
bool used = false;
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
-
TreeItem *subdir = include_files->create_item(p_item);
if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes)) {
used = true;
@@ -834,10 +828,10 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
}
for (int i = 0; i < p_dir->get_file_count(); i++) {
-
String type = p_dir->get_file_type(i);
- if (p_only_scenes && type != "PackedScene")
+ if (p_only_scenes && type != "PackedScene") {
continue;
+ }
TreeItem *file = include_files->create_item(p_item);
file->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
@@ -857,17 +851,19 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
}
void ProjectExportDialog::_tree_changed() {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
TreeItem *item = include_files->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
String path = item->get_metadata(0);
bool added = item->is_checked(0);
@@ -880,12 +876,10 @@ void ProjectExportDialog::_tree_changed() {
}
void ProjectExportDialog::_export_pck_zip() {
-
export_pck_zip->popup_centered_ratio();
}
void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Ref<EditorExportPlatform> platform = current->get_platform();
@@ -899,7 +893,6 @@ void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
}
void ProjectExportDialog::_open_export_template_manager() {
-
EditorNode::get_singleton()->open_export_template_manager();
hide();
}
@@ -909,10 +902,12 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) {
bool invalid_path = (p_path.get_file().get_basename() == "");
// Check if state change before needlessly messing with signals
- if (invalid_path && export_project->get_ok()->is_disabled())
+ if (invalid_path && export_project->get_ok()->is_disabled()) {
return;
- if (!invalid_path && !export_project->get_ok()->is_disabled())
+ }
+ if (!invalid_path && !export_project->get_ok()->is_disabled()) {
return;
+ }
if (invalid_path) {
export_project->get_ok()->set_disabled(true);
@@ -924,7 +919,6 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) {
}
void ProjectExportDialog::_export_project() {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Ref<EditorExportPlatform> platform = current->get_platform();
@@ -987,20 +981,17 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) {
}
void ProjectExportDialog::_export_all_dialog() {
-
export_all_dialog->show();
export_all_dialog->popup_centered(Size2(300, 80));
}
void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
-
export_all_dialog->hide();
_export_all(p_str != "release");
}
void ProjectExportDialog::_export_all(bool p_debug) {
-
String mode = p_debug ? TTR("Debug") : TTR("Release");
EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count(), true);
@@ -1027,7 +1018,6 @@ void ProjectExportDialog::_export_all(bool p_debug) {
}
void ProjectExportDialog::_bind_methods() {
-
ClassDB::bind_method("get_drag_data_fw", &ProjectExportDialog::get_drag_data_fw);
ClassDB::bind_method("can_drop_data_fw", &ProjectExportDialog::can_drop_data_fw);
ClassDB::bind_method("drop_data_fw", &ProjectExportDialog::drop_data_fw);
@@ -1040,7 +1030,6 @@ void ProjectExportDialog::_bind_methods() {
}
ProjectExportDialog::ProjectExportDialog() {
-
set_title(TTR("Export"));
VBoxContainer *main_vb = memnew(VBoxContainer);
@@ -1119,6 +1108,7 @@ ProjectExportDialog::ProjectExportDialog() {
parameters->set_name(TTR("Options"));
parameters->set_v_size_flags(Control::SIZE_EXPAND_FILL);
parameters->connect("property_edited", callable_mp(this, &ProjectExportDialog::_update_parameters));
+ EditorExport::get_singleton()->connect("export_presets_updated", callable_mp(this, &ProjectExportDialog::_force_update_current_preset_parameters));
// Resources export parameters.
diff --git a/editor/project_export.h b/editor/project_export.h
index 2e311eb3b3..cfa00773d8 100644
--- a/editor/project_export.h
+++ b/editor/project_export.h
@@ -123,6 +123,7 @@ private:
void _delete_preset_confirm();
void _update_export_all();
+ void _force_update_current_preset_parameters();
void _update_current_preset();
void _update_presets();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 2d1eb54e9a..cbba4b4834 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -59,7 +59,6 @@ static inline String get_project_key_from_path(const String &dir) {
}
class ProjectDialog : public ConfirmationDialog {
-
GDCLASS(ProjectDialog, ConfirmationDialog);
public:
@@ -107,30 +106,25 @@ private:
String created_folder_path;
void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH) {
-
msg->set_text(p_msg);
Ref<Texture2D> current_path_icon = status_rect->get_texture();
Ref<Texture2D> current_install_icon = install_status_rect->get_texture();
Ref<Texture2D> new_icon;
switch (p_type) {
-
case MESSAGE_ERROR: {
-
msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor"));
msg->set_modulate(Color(1, 1, 1, 1));
new_icon = msg->get_theme_icon("StatusError", "EditorIcons");
} break;
case MESSAGE_WARNING: {
-
msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor"));
msg->set_modulate(Color(1, 1, 1, 1));
new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons");
} break;
case MESSAGE_SUCCESS: {
-
msg->set_modulate(Color(1, 1, 1, 0));
new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons");
@@ -147,7 +141,6 @@ private:
}
String _test_path() {
-
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String valid_path, valid_install_path;
if (d->change_dir(project_path->get_text()) == OK) {
@@ -187,16 +180,13 @@ private:
}
if (mode == MODE_IMPORT || mode == MODE_RENAME) {
-
if (valid_path != "" && !d->file_exists("project.godot")) {
-
if (valid_path.ends_with(".zip")) {
FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
if (!pkg) {
-
set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR);
memdelete(d);
get_ok()->set_disabled(true);
@@ -245,7 +235,6 @@ private:
d->list_dir_end();
if (!is_empty) {
-
set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH);
memdelete(d);
get_ok()->set_disabled(true);
@@ -261,7 +250,6 @@ private:
}
} else if (valid_path.ends_with("zip")) {
-
set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
memdelete(d);
get_ok()->set_disabled(true);
@@ -269,7 +257,6 @@ private:
}
} else {
-
// check if the specified folder is empty, even though this is not an error, it is good to check here
d->list_dir_begin();
bool is_empty = true;
@@ -288,7 +275,6 @@ private:
d->list_dir_end();
if (!is_empty) {
-
set_message(TTR("Please choose an empty folder."), MESSAGE_ERROR);
memdelete(d);
get_ok()->set_disabled(true);
@@ -304,10 +290,8 @@ private:
}
void _path_text_changed(const String &p_path) {
-
String sp = _test_path();
if (sp != "") {
-
// If the project name is empty or default, infer the project name from the selected folder name
if (project_name->get_text() == "" || project_name->get_text() == TTR("New Game Project")) {
sp = sp.replace("\\", "/");
@@ -316,8 +300,9 @@ private:
if (lidx != -1) {
sp = sp.substr(lidx + 1, sp.length()).capitalize();
}
- if (sp == "" && mode == MODE_IMPORT)
+ if (sp == "" && mode == MODE_IMPORT) {
sp = TTR("Imported Project");
+ }
project_name->set_text(sp);
_text_changed(sp);
@@ -330,7 +315,6 @@ private:
}
void _file_selected(const String &p_path) {
-
String p = p_path;
if (mode == MODE_IMPORT) {
if (p.ends_with("project.godot")) {
@@ -358,7 +342,6 @@ private:
}
void _path_selected(const String &p_path) {
-
String sp = p_path.simplify_path();
project_path->set_text(sp);
_path_text_changed(sp);
@@ -366,7 +349,6 @@ private:
}
void _install_path_selected(const String &p_path) {
-
String sp = p_path.simplify_path();
install_path->set_text(sp);
_path_text_changed(sp);
@@ -374,11 +356,9 @@ private:
}
void _browse_path() {
-
fdialog->set_current_dir(project_path->get_text());
if (mode == MODE_IMPORT) {
-
fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
fdialog->clear_filters();
fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project")));
@@ -396,7 +376,6 @@ private:
}
void _create_folder() {
-
if (project_name->get_text() == "" || created_folder_path != "" || project_name->get_text().ends_with(".") || project_name->get_text().ends_with(" ")) {
set_message(TTR("Invalid Project Name."), MESSAGE_WARNING);
return;
@@ -404,11 +383,8 @@ private:
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (d->change_dir(project_path->get_text()) == OK) {
-
if (!d->dir_exists(project_name->get_text())) {
-
if (d->make_dir(project_name->get_text()) == OK) {
-
d->change_dir(project_name->get_text());
String dir_str = d->get_current_dir();
project_path->set_text(dir_str);
@@ -416,12 +392,10 @@ private:
created_folder_path = d->get_current_dir();
create_dir->set_disabled(true);
} else {
-
dialog_error->set_text(TTR("Couldn't create folder."));
dialog_error->popup_centered();
}
} else {
-
dialog_error->set_text(TTR("There is already a folder in this path with the specified name."));
dialog_error->popup_centered();
}
@@ -431,22 +405,21 @@ private:
}
void _text_changed(const String &p_text) {
-
- if (mode != MODE_NEW)
+ if (mode != MODE_NEW) {
return;
+ }
_test_path();
- if (p_text == "")
+ if (p_text == "") {
set_message(TTR("It would be a good idea to name your project."), MESSAGE_WARNING);
+ }
}
void ok_pressed() {
-
String dir = project_path->get_text();
if (mode == MODE_RENAME) {
-
String dir2 = _test_path();
if (dir2 == "") {
set_message(TTR("Invalid project path (changed anything?)."), MESSAGE_ERROR);
@@ -471,11 +444,8 @@ private:
emit_signal("projects_updated");
} else {
-
if (mode == MODE_IMPORT) {
-
if (project_path->get_text().ends_with(".zip")) {
-
mode = MODE_INSTALL;
ok_pressed();
@@ -484,7 +454,6 @@ private:
} else {
if (mode == MODE_NEW) {
-
ProjectSettings::CustomMap initial_settings;
if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") {
initial_settings["rendering/quality/driver/driver_name"] = "Vulkan";
@@ -516,7 +485,6 @@ private:
}
} else if (mode == MODE_INSTALL) {
-
if (project_path->get_text().ends_with(".zip")) {
dir = install_path->get_text();
zip_path = project_path->get_text();
@@ -527,7 +495,6 @@ private:
unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
if (!pkg) {
-
dialog_error->set_text(TTR("Error opening package file, not in ZIP format."));
dialog_error->popup_centered();
return;
@@ -539,7 +506,6 @@ private:
int idx = 0;
while (ret == UNZ_OK) {
-
//get filename
unz_file_info info;
char fname[16384];
@@ -570,7 +536,6 @@ private:
memdelete(da);
} else {
-
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
@@ -598,7 +563,6 @@ private:
if (failed_files.size()) {
String msg = TTR("The following files failed extraction from package:") + "\n\n";
for (int i = 0; i < failed_files.size(); i++) {
-
if (i > 15) {
msg += "\nAnd " + itos(failed_files.size() - i) + " more files.";
break;
@@ -617,8 +581,9 @@ private:
}
dir = dir.replace("\\", "/");
- if (dir.ends_with("/"))
+ if (dir.ends_with("/")) {
dir = dir.substr(0, dir.length() - 1);
+ }
String proj = get_project_key_from_path(dir);
EditorSettings::get_singleton()->set("projects/" + proj, dir);
EditorSettings::get_singleton()->save();
@@ -629,7 +594,6 @@ private:
}
void _remove_created_folder() {
-
if (created_folder_path != "") {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
d->remove(created_folder_path);
@@ -641,7 +605,6 @@ private:
}
void cancel_pressed() {
-
_remove_created_folder();
project_path->clear();
@@ -649,22 +612,23 @@ private:
project_name->clear();
_text_changed("");
- if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
+ if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) {
msg->show();
+ }
- if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
+ if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) {
msg->show();
+ }
}
void _notification(int p_what) {
-
- if (p_what == NOTIFICATION_WM_CLOSE_REQUEST)
+ if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) {
_remove_created_folder();
+ }
}
protected:
static void _bind_methods() {
-
ClassDB::bind_method("_browse_path", &ProjectDialog::_browse_path);
ClassDB::bind_method("_create_folder", &ProjectDialog::_create_folder);
ClassDB::bind_method("_text_changed", &ProjectDialog::_text_changed);
@@ -686,7 +650,6 @@ public:
}
void set_mode(Mode p_mode) {
-
mode = p_mode;
}
@@ -695,9 +658,7 @@ public:
}
void show_dialog() {
-
if (mode == MODE_RENAME) {
-
project_path->set_editable(false);
browse->hide();
install_browse->hide();
@@ -731,7 +692,6 @@ public:
create_dir->hide();
} else {
-
fav_dir = EditorSettings::get_singleton()->get("filesystem/directories/default_project_path");
if (fav_dir != "") {
project_path->set_text(fav_dir);
@@ -765,7 +725,6 @@ public:
project_path->grab_focus();
} else if (mode == MODE_NEW) {
-
set_title(TTR("Create New Project"));
get_ok()->set_text(TTR("Create & Edit"));
name_container->show();
@@ -775,7 +734,6 @@ public:
project_name->call_deferred("select_all");
} else if (mode == MODE_INSTALL) {
-
set_title(TTR("Install Project:") + " " + zip_title);
get_ok()->set_text(TTR("Install & Edit"));
project_name->set_text(zip_title);
@@ -792,7 +750,6 @@ public:
}
ProjectDialog() {
-
VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
@@ -959,6 +916,8 @@ public:
icon = nullptr;
icon_needs_reload = true;
hover = false;
+
+ set_focus_mode(FocusMode::FOCUS_ALL);
}
void set_is_favorite(bool fav) {
@@ -1024,7 +983,6 @@ public:
bool p_grayed,
bool p_missing,
int p_version) {
-
project_key = p_project;
project_name = p_name;
description = p_description;
@@ -1137,7 +1095,6 @@ void ProjectList::update_icons_async() {
void ProjectList::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
-
// Load icons as a coroutine to speed up launch when you have hundreds of projects
if (_icon_load_index < _projects.size()) {
Item &item = _projects.write[_icon_load_index];
@@ -1162,7 +1119,6 @@ void ProjectList::load_project_icon(int p_index) {
img.instance();
Error err = img->load(item.icon.replace_first("res://", item.path + "/"));
if (err == OK) {
-
img->resize(default_icon->get_width(), default_icon->get_height(), Image::INTERPOLATE_LANCZOS);
Ref<ImageTexture> it = memnew(ImageTexture);
it->create_from_image(img);
@@ -1178,7 +1134,6 @@ void ProjectList::load_project_icon(int p_index) {
}
void ProjectList::load_project_data(const String &p_property_key, Item &p_item, bool p_favorite) {
-
String path = EditorSettings::get_singleton()->get(p_property_key);
String conf = path.plus_file("project.godot");
bool grayed = false;
@@ -1191,8 +1146,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String project_name = TTR("Unnamed Project");
if (cf_err == OK) {
String cf_project_name = static_cast<String>(cf->get_value("application", "config/name", ""));
- if (cf_project_name != "")
+ if (cf_project_name != "") {
project_name = cf_project_name.xml_unescape();
+ }
config_version = (int)cf->get_value("", "config_version", 0);
}
@@ -1215,8 +1171,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String fscache = path.plus_file(".fscache");
if (FileAccess::exists(fscache)) {
uint64_t cache_modified = FileAccess::get_modified_time(fscache);
- if (cache_modified > last_edited)
+ if (cache_modified > last_edited) {
last_edited = cache_modified;
+ }
}
} else {
grayed = true;
@@ -1262,8 +1219,9 @@ void ProjectList::load_projects() {
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
// This is actually something like "projects/C:::Documents::Godot::Projects::MyGame"
String property_key = E->get().name;
- if (!property_key.begins_with("projects/"))
+ if (!property_key.begins_with("projects/")) {
continue;
+ }
String project_key = property_key.get_slice("/", 1);
bool favorite = favorites.has("favorite_projects/" + project_key);
@@ -1289,7 +1247,6 @@ void ProjectList::load_projects() {
}
void ProjectList::update_dock_menu() {
-
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
return;
}
@@ -1341,7 +1298,6 @@ void ProjectList::_global_menu_open_project(const Variant &p_tag) {
}
void ProjectList::create_project_item_control(int p_index) {
-
// Will be added last in the list, so make sure indexes match
ERR_FAIL_COND(p_index != _scroll_children->get_child_count());
@@ -1383,8 +1339,9 @@ void ProjectList::create_project_item_control(int p_index) {
hb->icon = tf;
VBoxContainer *vb = memnew(VBoxContainer);
- if (item.grayed)
+ if (item.grayed) {
vb->set_modulate(Color(1, 1, 1, 0.5));
+ }
vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(vb);
Control *ec = memnew(Control);
@@ -1442,7 +1399,6 @@ void ProjectList::set_order_option(ProjectListFilter::FilterOption p_option) {
}
void ProjectList::sort_projects() {
-
SortArray<Item, ProjectListComparator> sorter;
sorter.compare.order_option = _order_option;
sorter.sort(_projects.ptrw(), _projects.size());
@@ -1452,7 +1408,6 @@ void ProjectList::sort_projects() {
bool visible = true;
if (_search_term != "") {
-
String search_path;
if (_search_term.find("/") != -1) {
// Search path will match the whole path
@@ -1568,7 +1523,6 @@ bool ProjectList::is_any_project_missing() const {
}
void ProjectList::erase_missing_projects() {
-
if (_projects.empty()) {
return;
}
@@ -1669,7 +1623,6 @@ int ProjectList::get_project_count() const {
}
void ProjectList::select_project(int p_index) {
-
Vector<Item> previous_selected_items = get_selected_projects();
_selected_project_keys.clear();
@@ -1724,7 +1677,6 @@ void ProjectList::toggle_select(int p_index) {
}
void ProjectList::erase_selected_projects() {
-
if (_selected_project_keys.size() == 0) {
return;
}
@@ -1732,7 +1684,6 @@ void ProjectList::erase_selected_projects() {
for (int i = 0; i < _projects.size(); ++i) {
Item &item = _projects.write[i];
if (_selected_project_keys.has(item.project_key) && item.control->is_visible()) {
-
EditorSettings::get_singleton()->erase("projects/" + item.project_key);
EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
@@ -1765,15 +1716,12 @@ void ProjectList::_panel_draw(Node *p_hb) {
// Input for each item in the list
void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
-
Ref<InputEventMouseButton> mb = p_ev;
int clicked_index = p_hb->get_index();
const Item &clicked_project = _projects[clicked_index];
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->get_shift() && _selected_project_keys.size() > 0 && _last_clicked != "" && clicked_project.project_key != _last_clicked) {
-
int anchor_index = -1;
for (int i = 0; i < _projects.size(); ++i) {
const Item &p = _projects[i];
@@ -1802,7 +1750,6 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
}
void ProjectList::_favorite_pressed(Node *p_hb) {
-
ProjectListItemControl *control = Object::cast_to<ProjectListItemControl>(p_hb);
int index = control->get_index();
@@ -1836,7 +1783,6 @@ void ProjectList::_favorite_pressed(Node *p_hb) {
}
void ProjectList::_show_project(const String &p_path) {
-
OS::get_singleton()->shell_open(String("file://") + p_path);
}
@@ -1844,28 +1790,24 @@ const char *ProjectList::SIGNAL_SELECTION_CHANGED = "selection_changed";
const char *ProjectList::SIGNAL_PROJECT_ASK_OPEN = "project_ask_open";
void ProjectList::_bind_methods() {
-
ADD_SIGNAL(MethodInfo(SIGNAL_SELECTION_CHANGED));
ADD_SIGNAL(MethodInfo(SIGNAL_PROJECT_ASK_OPEN));
}
void ProjectManager::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
Engine::get_singleton()->set_editor_hint(false);
} break;
case NOTIFICATION_RESIZED: {
-
if (open_templates->is_visible()) {
open_templates->popup_centered();
}
} break;
case NOTIFICATION_READY: {
-
- if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available())
+ if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) {
open_templates->popup_centered();
+ }
if (_project_list->get_project_count() >= 1) {
// Focus on the search box immediately to allow the user
@@ -1874,18 +1816,15 @@ void ProjectManager::_notification(int p_what) {
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
set_process_unhandled_input(is_visible_in_tree());
} break;
case NOTIFICATION_WM_CLOSE_REQUEST: {
-
_dim_window();
} break;
}
}
void ProjectManager::_dim_window() {
-
// This method must be called before calling `get_tree()->quit()`.
// Otherwise, its effect won't be visible
@@ -1897,7 +1836,6 @@ void ProjectManager::_dim_window() {
}
void ProjectManager::_update_project_buttons() {
-
Vector<ProjectList::Item> selected_projects = _project_list->get_selected_projects();
bool empty_selection = selected_projects.empty();
@@ -1918,11 +1856,9 @@ void ProjectManager::_update_project_buttons() {
}
void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventKey> k = p_ev;
if (k.is_valid()) {
-
if (!k->is_pressed()) {
return;
}
@@ -1937,23 +1873,20 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
}
#endif
- if (tabs->get_current_tab() != 0)
+ if (tabs->get_current_tab() != 0) {
return;
+ }
bool keycode_handled = true;
switch (k->get_keycode()) {
-
case KEY_ENTER: {
-
_open_selected_projects_ask();
} break;
case KEY_DELETE: {
-
_erase_project();
} break;
case KEY_HOME: {
-
if (_project_list->get_project_count() > 0) {
_project_list->select_project(0);
_update_project_buttons();
@@ -1961,7 +1894,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_END: {
-
if (_project_list->get_project_count() > 0) {
_project_list->select_project(_project_list->get_project_count() - 1);
_update_project_buttons();
@@ -1969,9 +1901,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_UP: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
break;
+ }
int index = _project_list->get_single_selected_index();
if (index > 0) {
@@ -1983,9 +1915,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
break;
}
case KEY_DOWN: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
break;
+ }
int index = _project_list->get_single_selected_index();
if (index + 1 < _project_list->get_project_count()) {
@@ -1996,10 +1928,11 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_F: {
- if (k->get_command())
+ if (k->get_command()) {
this->project_filter->search_box->grab_focus();
- else
+ } else {
keycode_handled = false;
+ }
} break;
default: {
keycode_handled = false;
@@ -2013,7 +1946,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
}
void ProjectManager::_load_recent_projects() {
-
_project_list->set_order_option(project_order_filter->get_filter_option());
_project_list->set_search_term(project_filter->get_search_term());
_project_list->load_projects();
@@ -2051,7 +1983,6 @@ void ProjectManager::_confirm_update_settings() {
}
void ProjectManager::_open_selected_projects() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
for (const Set<String>::Element *E = selected_list.front(); E; E = E->next()) {
@@ -2090,7 +2021,6 @@ void ProjectManager::_open_selected_projects() {
}
void ProjectManager::_open_selected_projects_ask() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() < 1) {
@@ -2136,11 +2066,9 @@ void ProjectManager::_open_selected_projects_ask() {
}
void ProjectManager::_run_project_confirm() {
-
Vector<ProjectList::Item> selected_list = _project_list->get_selected_projects();
for (int i = 0; i < selected_list.size(); ++i) {
-
const String &selected_main = selected_list[i].main_scene;
if (selected_main == "") {
run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category."));
@@ -2178,7 +2106,6 @@ void ProjectManager::_run_project_confirm() {
// When you press the "Run" button
void ProjectManager::_run_project() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() < 1) {
@@ -2211,7 +2138,6 @@ void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) {
}
void ProjectManager::_scan_begin(const String &p_base) {
-
print_line("Scanning projects at: " + p_base);
List<String> projects;
_scan_dir(p_base, &projects);
@@ -2226,24 +2152,20 @@ void ProjectManager::_scan_begin(const String &p_base) {
}
void ProjectManager::_scan_projects() {
-
scan_dir->popup_centered_ratio();
}
void ProjectManager::_new_project() {
-
npdialog->set_mode(ProjectDialog::MODE_NEW);
npdialog->show_dialog();
}
void ProjectManager::_import_project() {
-
npdialog->set_mode(ProjectDialog::MODE_IMPORT);
npdialog->show_dialog();
}
void ProjectManager::_rename_project() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() == 0) {
@@ -2270,11 +2192,11 @@ void ProjectManager::_erase_missing_projects_confirm() {
}
void ProjectManager::_erase_project() {
-
const Set<String> &selected_list = _project_list->get_selected_project_keys();
- if (selected_list.size() == 0)
+ if (selected_list.size() == 0) {
return;
+ }
String confirm_message;
if (selected_list.size() >= 2) {
@@ -2288,13 +2210,11 @@ void ProjectManager::_erase_project() {
}
void ProjectManager::_erase_missing_projects() {
-
erase_missing_ask->set_text(TTR("Remove all missing projects from the list?\nThe project folders' contents won't be modified."));
erase_missing_ask->popup_centered();
}
void ProjectManager::_language_selected(int p_id) {
-
String lang = language_btn->get_item_metadata(p_id);
EditorSettings::get_singleton()->set("interface/editor/editor_language", lang);
language_btn->set_text(lang);
@@ -2305,7 +2225,6 @@ void ProjectManager::_language_selected(int p_id) {
}
void ProjectManager::_restart_confirm() {
-
List<String> args = OS::get_singleton()->get_cmdline_args();
String exec = OS::get_singleton()->get_executable_path();
OS::ProcessID pid = 0;
@@ -2317,13 +2236,11 @@ void ProjectManager::_restart_confirm() {
}
void ProjectManager::_exit_dialog() {
-
_dim_window();
get_tree()->quit();
}
void ProjectManager::_install_project(const String &p_zip_path, const String &p_title) {
-
npdialog->set_mode(ProjectDialog::MODE_INSTALL);
npdialog->set_zip_path(p_zip_path);
npdialog->set_zip_title(p_title);
@@ -2395,7 +2312,6 @@ void ProjectManager::_on_filter_option_changed() {
}
void ProjectManager::_bind_methods() {
-
ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog);
ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input);
ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons);
@@ -2407,10 +2323,10 @@ void ProjectManager::_open_asset_library() {
}
ProjectManager::ProjectManager() {
-
// load settings
- if (!EditorSettings::get_singleton())
+ if (!EditorSettings::get_singleton()) {
EditorSettings::create();
+ }
EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
@@ -2730,16 +2646,16 @@ ProjectManager::ProjectManager() {
}
ProjectManager::~ProjectManager() {
-
- if (EditorSettings::get_singleton())
+ if (EditorSettings::get_singleton()) {
EditorSettings::destroy();
+ }
}
void ProjectListFilter::_setup_filters(Vector<String> options) {
-
filter_option->clear();
- for (int i = 0; i < options.size(); i++)
+ for (int i = 0; i < options.size(); i++) {
filter_option->add_item(options[i]);
+ }
}
void ProjectListFilter::_search_text_changed(const String &p_newtext) {
@@ -2763,13 +2679,13 @@ void ProjectListFilter::_filter_option_selected(int p_idx) {
FilterOption selected = (FilterOption)(filter_option->get_selected());
if (_current_filter != selected) {
_current_filter = selected;
- if (is_inside_tree())
+ if (is_inside_tree()) {
emit_signal("filter_changed");
+ }
}
}
void ProjectListFilter::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE && has_search_box) {
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
@@ -2777,7 +2693,6 @@ void ProjectListFilter::_notification(int p_what) {
}
void ProjectListFilter::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("filter_changed"));
}
@@ -2805,7 +2720,6 @@ void ProjectListFilter::set_filter_size(int h_size) {
}
ProjectListFilter::ProjectListFilter() {
-
_current_filter = FILTER_NAME;
has_search_box = false;
}
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 6385000821..e5471bd392 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -43,7 +43,6 @@ class ProjectList;
class ProjectListFilter;
class ProjectManager : public Control {
-
GDCLASS(ProjectManager, Control);
Button *erase_btn;
@@ -126,7 +125,6 @@ public:
};
class ProjectListFilter : public HBoxContainer {
-
GDCLASS(ProjectListFilter, HBoxContainer);
public:
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index e5dd0c148e..a7c260c0f8 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -85,11 +85,9 @@ static const char *_axis_descriptions[JOY_AXIS_MAX * 2] = {
};
void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
-
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
-
if (k->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) {
if (search_button->is_pressed()) {
search_box->grab_focus();
@@ -105,7 +103,6 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void ProjectSettingsEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
@@ -133,14 +130,12 @@ void ProjectSettingsEditor::_notification(int p_what) {
List<String> tfn;
ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
for (List<String>::Element *E = tfn.front(); E; E = E->next()) {
-
translation_file_open->add_filter("*." + E->get());
}
List<String> rfn;
ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn);
for (List<String>::Element *E = rfn.front(); E; E = E->next()) {
-
translation_res_file_open->add_filter("*." + E->get());
translation_res_option_file_open->add_filter("*." + E->get());
}
@@ -168,39 +163,40 @@ void ProjectSettingsEditor::_notification(int p_what) {
static bool _validate_action_name(const String &p_name) {
const CharType *cstr = p_name.c_str();
- for (int i = 0; cstr[i]; i++)
+ for (int i = 0; cstr[i]; i++) {
if (cstr[i] == '/' || cstr[i] == ':' || cstr[i] == '"' ||
- cstr[i] == '=' || cstr[i] == '\\' || cstr[i] < 32)
+ cstr[i] == '=' || cstr[i] == '\\' || cstr[i] < 32) {
return false;
+ }
+ }
return true;
}
void ProjectSettingsEditor::_action_selected() {
-
TreeItem *ti = input_editor->get_selected();
- if (!ti || !ti->is_editable(0))
+ if (!ti || !ti->is_editable(0)) {
return;
+ }
add_at = "input/" + ti->get_text(0);
edit_idx = -1;
}
void ProjectSettingsEditor::_action_edited() {
-
TreeItem *ti = input_editor->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
if (input_editor->get_selected_column() == 0) {
-
String new_name = ti->get_text(0);
String old_name = add_at.substr(add_at.find("/") + 1, add_at.length());
- if (new_name == old_name)
+ if (new_name == old_name) {
return;
+ }
if (new_name == "" || !_validate_action_name(new_name)) {
-
ti->set_text(0, old_name);
add_at = "input/" + old_name;
@@ -212,7 +208,6 @@ void ProjectSettingsEditor::_action_edited() {
String action_prop = "input/" + new_name;
if (ProjectSettings::get_singleton()->has_setting(action_prop)) {
-
ti->set_text(0, old_name);
add_at = "input/" + old_name;
@@ -241,7 +236,6 @@ void ProjectSettingsEditor::_action_edited() {
add_at = action_prop;
} else if (input_editor->get_selected_column() == 1) {
-
String name = "input/" + ti->get_text(0);
Dictionary old_action = ProjectSettings::get_singleton()->get(name);
Dictionary new_action = old_action.duplicate();
@@ -257,7 +251,6 @@ void ProjectSettingsEditor::_action_edited() {
}
void ProjectSettingsEditor::_device_input_add() {
-
Ref<InputEvent> ie;
String name = add_at;
int idx = edit_idx;
@@ -266,19 +259,17 @@ void ProjectSettingsEditor::_device_input_add() {
Array events = action["events"];
switch (add_type) {
-
case INPUT_MOUSE_BUTTON: {
-
Ref<InputEventMouseButton> mb;
mb.instance();
mb->set_button_index(device_index->get_selected() + 1);
mb->set_device(_get_current_device());
for (int i = 0; i < events.size(); i++) {
-
Ref<InputEventMouseButton> aie = events[i];
- if (aie.is_null())
+ if (aie.is_null()) {
continue;
+ }
if (aie->get_device() == mb->get_device() && aie->get_button_index() == mb->get_button_index()) {
return;
}
@@ -288,7 +279,6 @@ void ProjectSettingsEditor::_device_input_add() {
} break;
case INPUT_JOY_MOTION: {
-
Ref<InputEventJoypadMotion> jm;
jm.instance();
jm->set_axis(device_index->get_selected() >> 1);
@@ -296,10 +286,10 @@ void ProjectSettingsEditor::_device_input_add() {
jm->set_device(_get_current_device());
for (int i = 0; i < events.size(); i++) {
-
Ref<InputEventJoypadMotion> aie = events[i];
- if (aie.is_null())
+ if (aie.is_null()) {
continue;
+ }
if (aie->get_device() == jm->get_device() && aie->get_axis() == jm->get_axis() && aie->get_axis_value() == jm->get_axis_value()) {
return;
@@ -310,7 +300,6 @@ void ProjectSettingsEditor::_device_input_add() {
} break;
case INPUT_JOY_BUTTON: {
-
Ref<InputEventJoypadButton> jb;
jb.instance();
@@ -318,10 +307,10 @@ void ProjectSettingsEditor::_device_input_add() {
jb->set_device(_get_current_device());
for (int i = 0; i < events.size(); i++) {
-
Ref<InputEventJoypadButton> aie = events[i];
- if (aie.is_null())
+ if (aie.is_null()) {
continue;
+ }
if (aie->get_device() == jb->get_device() && aie->get_button_index() == jb->get_button_index()) {
return;
}
@@ -361,15 +350,16 @@ int ProjectSettingsEditor::_get_current_device() {
}
String ProjectSettingsEditor::_get_device_string(int i_device) {
- if (i_device == InputMap::ALL_DEVICES)
+ if (i_device == InputMap::ALL_DEVICES) {
return TTR("All Devices");
+ }
return TTR("Device") + " " + itos(i_device);
}
void ProjectSettingsEditor::_press_a_key_confirm() {
-
- if (last_wait_for_key.is_null())
+ if (last_wait_for_key.is_null()) {
return;
+ }
Ref<InputEventKey> ie;
ie.instance();
@@ -393,10 +383,10 @@ void ProjectSettingsEditor::_press_a_key_confirm() {
Array events = action["events"];
for (int i = 0; i < events.size(); i++) {
-
Ref<InputEventKey> aie = events[i];
- if (aie.is_null())
+ if (aie.is_null()) {
continue;
+ }
if (!press_a_key_physical) {
if (aie->get_keycode_with_modifiers() == ie->get_keycode_with_modifiers()) {
return;
@@ -432,11 +422,13 @@ void ProjectSettingsEditor::_show_last_added(const Ref<InputEvent> &p_event, con
String name = p_name;
name.erase(0, 6);
- if (!r)
+ if (!r) {
return;
+ }
r = r->get_children();
- if (!r)
+ if (!r) {
return;
+ }
bool found = false;
while (r) {
if (r->get_text(0) != name) {
@@ -454,21 +446,21 @@ void ProjectSettingsEditor::_show_last_added(const Ref<InputEvent> &p_event, con
}
child = child->get_next();
}
- if (found)
+ if (found) {
break;
+ }
r = r->get_next();
}
- if (found)
+ if (found) {
input_editor->ensure_cursor_is_visible();
+ }
}
void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed() && k->get_keycode() != 0) {
-
last_wait_for_key = p_event;
const String str = (press_a_key_physical) ? keycode_get_string(k->get_physical_keycode_with_modifiers()) + TTR(" (Physical)") : keycode_get_string(k->get_keycode_with_modifiers());
@@ -479,13 +471,10 @@ void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) {
}
void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
-
add_type = InputType(p_item);
switch (add_type) {
-
case INPUT_KEY: {
-
press_a_key_physical = false;
press_a_key_label->set_text(TTR("Press a Key..."));
press_a_key->get_ok()->set_disabled(true);
@@ -495,7 +484,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
} break;
case INPUT_KEY_PHYSICAL: {
-
press_a_key_physical = true;
press_a_key_label->set_text(TTR("Press a Key..."));
@@ -505,7 +493,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
} break;
case INPUT_MOUSE_BUTTON: {
-
device_index_label->set_text(TTR("Mouse Button Index:"));
device_index->clear();
device_index->add_item(TTR("Left Button"));
@@ -531,7 +518,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
} break;
case INPUT_JOY_MOTION: {
-
device_index_label->set_text(TTR("Joypad Axis Index:"));
device_index->clear();
for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
@@ -553,13 +539,13 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
} break;
case INPUT_JOY_BUTTON: {
-
device_index_label->set_text(TTR("Joypad Button Index:"));
device_index->clear();
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
String desc = TTR("Button") + " " + itos(i);
- if (i < JOY_SDL_BUTTONS)
+ if (i < JOY_SDL_BUTTONS) {
desc += " (" + TTR(_button_descriptions[i]) + ")";
+ }
device_index->add_item(desc);
}
device_input->popup_centered(Size2(350, 95) * EDSCALE);
@@ -581,7 +567,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
}
void ProjectSettingsEditor::_edit_item(Ref<InputEvent> p_exiting_event) {
-
InputType ie_type;
if ((Ref<InputEventKey>(p_exiting_event)).is_valid()) {
@@ -606,12 +591,13 @@ void ProjectSettingsEditor::_edit_item(Ref<InputEvent> p_exiting_event) {
_add_item(ie_type, p_exiting_event);
}
-void ProjectSettingsEditor::_action_activated() {
+void ProjectSettingsEditor::_action_activated() {
TreeItem *ti = input_editor->get_selected();
- if (!ti || ti->get_parent() == input_editor->get_root())
+ if (!ti || ti->get_parent() == input_editor->get_root()) {
return;
+ }
String name = "input/" + ti->get_parent()->get_text(0);
int idx = ti->get_metadata(0);
@@ -620,8 +606,9 @@ void ProjectSettingsEditor::_action_activated() {
ERR_FAIL_INDEX(idx, events.size());
Ref<InputEvent> event = events[idx];
- if (event.is_null())
+ if (event.is_null()) {
return;
+ }
add_at = name;
edit_idx = idx;
@@ -629,7 +616,6 @@ void ProjectSettingsEditor::_action_activated() {
}
void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
ERR_FAIL_COND(!ti);
@@ -705,8 +691,9 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column,
Ref<InputEvent> event = events[idx];
- if (event.is_null())
+ if (event.is_null()) {
return;
+ }
ti->set_as_cursor(0);
add_at = name;
@@ -717,9 +704,9 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column,
}
void ProjectSettingsEditor::_update_actions() {
-
- if (setting)
+ if (setting) {
return;
+ }
Map<String, bool> collapsed;
@@ -737,14 +724,15 @@ void ProjectSettingsEditor::_update_actions() {
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
const PropertyInfo &pi = E->get();
- if (!pi.name.begins_with("input/"))
+ if (!pi.name.begins_with("input/")) {
continue;
+ }
String name = pi.name.get_slice("/", 1);
- if (name == "")
+ if (name == "") {
continue;
+ }
Dictionary action = ProjectSettings::get_singleton()->get(pi.name);
Array events = action["events"];
@@ -752,8 +740,9 @@ void ProjectSettingsEditor::_update_actions() {
TreeItem *item = input_editor->create_item(root);
item->set_text(0, name);
item->set_custom_bg_color(0, input_editor->get_theme_color("prop_subsection", "Editor"));
- if (collapsed.has(name))
+ if (collapsed.has(name)) {
item->set_collapsed(collapsed[name]);
+ }
item->set_editable(1, true);
item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
@@ -777,16 +766,15 @@ void ProjectSettingsEditor::_update_actions() {
}
for (int i = 0; i < events.size(); i++) {
-
Ref<InputEvent> event = events[i];
- if (event.is_null())
+ if (event.is_null()) {
continue;
+ }
TreeItem *action2 = input_editor->create_item(item);
Ref<InputEventKey> k = event;
if (k.is_valid()) {
-
const String str = (k->get_keycode() == 0) ? keycode_get_string(k->get_physical_keycode_with_modifiers()) + TTR(" (Physical)") : keycode_get_string(k->get_keycode_with_modifiers());
action2->set_text(0, str);
@@ -800,7 +788,6 @@ void ProjectSettingsEditor::_update_actions() {
Ref<InputEventJoypadButton> jb = event;
if (jb.is_valid()) {
-
String str = _get_device_string(jb->get_device()) + ", " +
TTR("Button") + " " + itos(jb->get_button_index());
if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_SDL_BUTTONS) {
@@ -842,7 +829,6 @@ void ProjectSettingsEditor::_update_actions() {
Ref<InputEventJoypadMotion> jm = event;
if (jm.is_valid()) {
-
int ax = jm->get_axis();
int n = 2 * ax + (jm->get_axis_value() < 0 ? 0 : 1);
String str = _get_device_string(jm->get_device()) + ", " +
@@ -867,7 +853,6 @@ void ProjectSettingsEditor::_update_actions() {
}
void ProjectSettingsEditor::popup_project_settings() {
-
// Restore valid window bounds or pop up at default size.
Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "project_settings", Rect2());
if (saved_size != Rect2()) {
@@ -888,22 +873,20 @@ void ProjectSettingsEditor::update_plugins() {
}
void ProjectSettingsEditor::_item_selected(const String &p_path) {
-
const String &selected_path = p_path;
- if (selected_path == String())
+ if (selected_path == String()) {
return;
+ }
category->set_text(globals_editor->get_current_section());
property->set_text(selected_path);
popup_copy_to_feature->set_disabled(false);
}
void ProjectSettingsEditor::_item_adds(String) {
-
_item_add();
}
void ProjectSettingsEditor::_item_add() {
-
// Initialize the property with the default value for the given type.
// The type list starts at 1 (as we exclude Nil), so add 1 to the selected value.
Callable::CallError ce;
@@ -946,7 +929,6 @@ void ProjectSettingsEditor::_item_add() {
}
void ProjectSettingsEditor::_item_del() {
-
String path = globals_editor->get_inspector()->get_selected_path();
if (path == String()) {
EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
@@ -984,21 +966,16 @@ void ProjectSettingsEditor::_item_del() {
}
void ProjectSettingsEditor::_action_check(String p_action) {
-
if (p_action == "") {
-
action_add->set_disabled(true);
} else {
-
if (!_validate_action_name(p_action)) {
-
action_add_error->set_text(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'."));
action_add_error->show();
action_add->set_disabled(true);
return;
}
if (ProjectSettings::get_singleton()->has_setting("input/" + p_action)) {
-
action_add_error->set_text(vformat(TTR("An action with the name '%s' already exists."), p_action));
action_add_error->show();
action_add->set_disabled(true);
@@ -1012,14 +989,12 @@ void ProjectSettingsEditor::_action_check(String p_action) {
}
void ProjectSettingsEditor::_action_adds(String) {
-
if (!action_add->is_disabled()) {
_action_add();
}
}
void ProjectSettingsEditor::_action_add() {
-
Dictionary action;
action["events"] = Array();
action["deadzone"] = 0.5f;
@@ -1035,13 +1010,16 @@ void ProjectSettingsEditor::_action_add() {
TreeItem *r = input_editor->get_root();
- if (!r)
+ if (!r) {
return;
+ }
r = r->get_children();
- if (!r)
+ if (!r) {
return;
- while (r->get_next())
+ }
+ while (r->get_next()) {
r = r->get_next();
+ }
r->select(0);
input_editor->ensure_cursor_is_visible();
@@ -1053,20 +1031,17 @@ void ProjectSettingsEditor::_item_checked(const String &p_item, bool p_check) {
}
void ProjectSettingsEditor::_save() {
-
Error err = ProjectSettings::get_singleton()->save();
message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK."));
message->popup_centered(Size2(300, 100) * EDSCALE);
}
void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) {
-
// Method needed to discard the mandatory argument of the property_edited signal
_settings_changed();
}
void ProjectSettingsEditor::_settings_changed() {
-
timer->start();
}
@@ -1075,7 +1050,6 @@ void ProjectSettingsEditor::queue_save() {
}
void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
-
Set<String> presets;
presets.insert("bptc");
@@ -1101,7 +1075,6 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
}
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
-
List<String> p;
EditorExport::get_singleton()->get_export_preset(i)->get_platform()->get_preset_features(EditorExport::get_singleton()->get_export_preset(i), &p);
for (List<String>::Element *E = p.front(); E; E = E->next()) {
@@ -1126,10 +1099,10 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
}
Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
TreeItem *selected = input_editor->get_selected();
- if (!selected || selected->get_parent() != input_editor->get_root())
+ if (!selected || selected->get_parent() != input_editor->get_root()) {
return Variant();
+ }
String name = selected->get_text(0);
VBoxContainer *vb = memnew(VBoxContainer);
@@ -1149,28 +1122,30 @@ Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control *
}
bool ProjectSettingsEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
Dictionary d = p_data;
- if (!d.has("type") || d["type"] != "nodes")
+ if (!d.has("type") || d["type"] != "nodes") {
return false;
+ }
TreeItem *selected = input_editor->get_selected();
TreeItem *item = input_editor->get_item_at_position(p_point);
- if (!selected || !item || item == selected || item->get_parent() == selected)
+ if (!selected || !item || item == selected || item->get_parent() == selected) {
return false;
+ }
return true;
}
void ProjectSettingsEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
- if (!can_drop_data_fw(p_point, p_data, p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
TreeItem *selected = input_editor->get_selected();
TreeItem *item = input_editor->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return;
+ }
TreeItem *target = item->get_parent() == input_editor->get_root() ? item : item->get_parent();
String selected_name = "input/" + selected->get_text(0);
@@ -1184,7 +1159,6 @@ void ProjectSettingsEditor::drop_data_fw(const Point2 &p_point, const Variant &p
undo_redo->create_action(TTR("Moved Input Action Event"));
while (iterator != target) {
-
String iterator_name = "input/" + iterator->get_text(0);
int iterator_order = ProjectSettings::get_singleton()->get_order(iterator_name);
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", iterator_name, order);
@@ -1206,7 +1180,6 @@ void ProjectSettingsEditor::drop_data_fw(const Point2 &p_point, const Variant &p
}
void ProjectSettingsEditor::_copy_to_platform(int p_which) {
-
String path = globals_editor->get_inspector()->get_selected_path();
if (path == String()) {
EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
@@ -1241,18 +1214,16 @@ void ProjectSettingsEditor::_copy_to_platform(int p_which) {
}
void ProjectSettingsEditor::add_translation(const String &p_translation) {
-
_translation_add(p_translation);
}
void ProjectSettingsEditor::_translation_add(const String &p_path) {
-
PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
for (int i = 0; i < translations.size(); i++) {
-
- if (translations[i] == p_path)
+ if (translations[i] == p_path) {
return; //exists
+ }
}
translations.push_back(p_path);
@@ -1267,12 +1238,10 @@ void ProjectSettingsEditor::_translation_add(const String &p_path) {
}
void ProjectSettingsEditor::_translation_file_open() {
-
translation_file_open->popup_centered_ratio();
}
void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, int p_button) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
@@ -1295,12 +1264,10 @@ void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, in
}
void ProjectSettingsEditor::_translation_res_file_open() {
-
translation_res_file_open->popup_centered_ratio();
}
void ProjectSettingsEditor::_translation_res_add(const String &p_path) {
-
Variant prev;
Dictionary remaps;
@@ -1309,8 +1276,9 @@ void ProjectSettingsEditor::_translation_res_add(const String &p_path) {
prev = remaps;
}
- if (remaps.has(p_path))
+ if (remaps.has(p_path)) {
return; //pointless already has it
+ }
remaps[p_path] = PackedStringArray();
@@ -1325,11 +1293,10 @@ void ProjectSettingsEditor::_translation_res_add(const String &p_path) {
}
void ProjectSettingsEditor::_translation_res_option_file_open() {
-
translation_res_option_file_open->popup_centered_ratio();
}
-void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) {
+void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) {
ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps"));
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
@@ -1355,20 +1322,21 @@ void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) {
}
void ProjectSettingsEditor::_translation_res_select() {
-
- if (updating_translations)
+ if (updating_translations) {
return;
+ }
call_deferred("_update_translations");
}
void ProjectSettingsEditor::_translation_res_option_changed() {
-
- if (updating_translations)
+ if (updating_translations) {
return;
+ }
- if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
return;
+ }
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
@@ -1409,12 +1377,13 @@ void ProjectSettingsEditor::_translation_res_option_changed() {
}
void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column, int p_button) {
-
- if (updating_translations)
+ if (updating_translations) {
return;
+ }
- if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
return;
+ }
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
@@ -1436,12 +1405,13 @@ void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column
}
void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p_column, int p_button) {
-
- if (updating_translations)
+ if (updating_translations) {
return;
+ }
- if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps"))
+ if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
return;
+ }
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
@@ -1470,7 +1440,6 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p
}
void ProjectSettingsEditor::_translation_filter_option_changed() {
-
int sel_id = translation_locale_filter_mode->get_selected_id();
TreeItem *t = translation_filter->get_edited();
String locale = t->get_tooltip(0);
@@ -1519,7 +1488,6 @@ void ProjectSettingsEditor::_translation_filter_option_changed() {
}
void ProjectSettingsEditor::_translation_filter_mode_changed(int p_mode) {
-
int sel_id = translation_locale_filter_mode->get_selected_id();
Variant prev;
@@ -1552,11 +1520,11 @@ void ProjectSettingsEditor::_translation_filter_mode_changed(int p_mode) {
}
void ProjectSettingsEditor::_update_translations() {
-
//update translations
- if (updating_translations)
+ if (updating_translations) {
return;
+ }
updating_translations = true;
@@ -1564,10 +1532,8 @@ void ProjectSettingsEditor::_update_translations() {
TreeItem *root = translation_list->create_item(nullptr);
translation_list->set_hide_root(true);
if (ProjectSettings::get_singleton()->has_setting("locale/translations")) {
-
PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
for (int i = 0; i < translations.size(); i++) {
-
TreeItem *t = translation_list->create_item(root);
t->set_editable(0, false);
t->set_text(0, translations[i].replace_first("res://", ""));
@@ -1585,17 +1551,14 @@ void ProjectSettingsEditor::_update_translations() {
bool is_arr_empty = true;
if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) {
-
l_filter_all = ProjectSettings::get_singleton()->get("locale/locale_filter");
if (l_filter_all.size() == 2) {
-
translation_locale_filter_mode->select(l_filter_all[0]);
is_arr_empty = false;
}
}
if (is_arr_empty) {
-
l_filter_all.append(0);
l_filter_all.append(Array());
translation_locale_filter_mode->select(0);
@@ -1610,7 +1573,6 @@ void ProjectSettingsEditor::_update_translations() {
bool should_recreate_locales_list = is_short_list_when_show_all_selected || is_full_list_when_show_only_selected;
if (!translation_locales_list_created || should_recreate_locales_list) {
-
translation_locales_list_created = true;
translation_filter->clear();
root = translation_filter->create_item(nullptr);
@@ -1620,8 +1582,9 @@ void ProjectSettingsEditor::_update_translations() {
String n = names[i];
String l = langs[i];
bool is_checked = l_filter.has(l);
- if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && !is_checked)
+ if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && !is_checked) {
continue;
+ }
TreeItem *t = translation_filter->create_item(root);
t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
@@ -1660,27 +1623,26 @@ void ProjectSettingsEditor::_update_translations() {
String langnames = "";
int l_idx = 0;
for (int i = 0; i < names.size(); i++) {
-
if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && fl_idx_count != 0) {
if (l_filter.size() > 0) {
-
if (l_filter.find(langs[i]) != -1) {
- if (langnames.length() > 0)
+ if (langnames.length() > 0) {
langnames += ",";
+ }
langnames += names[i];
translation_locales_idxs_remap.write[l_idx] = i;
l_idx++;
}
}
} else {
- if (i > 0)
+ if (i > 0) {
langnames += ",";
+ }
langnames += names[i];
}
}
if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) {
-
Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> rk;
remaps.get_key_list(&rk);
@@ -1691,7 +1653,6 @@ void ProjectSettingsEditor::_update_translations() {
keys.sort();
for (int i = 0; i < keys.size(); i++) {
-
TreeItem *t = translation_remap->create_item(root);
t->set_editable(0, false);
t->set_text(0, keys[i].replace_first("res://", ""));
@@ -1704,7 +1665,6 @@ void ProjectSettingsEditor::_update_translations() {
PackedStringArray selected = remaps[keys[i]];
for (int j = 0; j < selected.size(); j++) {
-
String s2 = selected[j];
int qp = s2.find_last(":");
String path = s2.substr(0, qp);
@@ -1721,15 +1681,14 @@ void ProjectSettingsEditor::_update_translations() {
t2->set_editable(1, true);
t2->set_metadata(1, path);
int idx = langs.find(locale);
- if (idx < 0)
+ if (idx < 0) {
idx = 0;
+ }
int f_idx = translation_locales_idxs_remap.find(idx);
if (f_idx != -1 && fl_idx_count > 0 && filter_mode == SHOW_ONLY_SELECTED_LOCALES) {
-
t2->set_range(1, f_idx);
} else {
-
t2->set_range(1, idx);
}
}
@@ -1741,17 +1700,14 @@ void ProjectSettingsEditor::_update_translations() {
}
void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
-
globals_editor->get_inspector()->set_use_filter(p_pressed);
if (p_pressed) {
-
search_bar->show();
add_prop_bar->hide();
search_box->grab_focus();
search_box->select_all();
} else {
-
search_box->clear();
search_bar->hide();
add_prop_bar->show();
@@ -1759,12 +1715,10 @@ void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
}
void ProjectSettingsEditor::set_plugins_page() {
-
tab_container->set_current_tab(plugin_settings->get_index());
}
TabContainer *ProjectSettingsEditor::get_tabs() {
-
return tab_container;
}
@@ -1782,7 +1736,6 @@ void ProjectSettingsEditor::_editor_restart_close() {
}
void ProjectSettingsEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_unhandled_input"), &ProjectSettingsEditor::_unhandled_input);
ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettingsEditor::_item_checked);
ClassDB::bind_method(D_METHOD("_save"), &ProjectSettingsEditor::_save);
@@ -1798,7 +1751,6 @@ void ProjectSettingsEditor::_bind_methods() {
}
ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
-
singleton = this;
set_title(TTR("Project Settings (project.godot)"));
@@ -2021,8 +1973,9 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
vbc_left->add_child(l);
device_id = memnew(OptionButton);
- for (int i = -1; i < 8; i++)
+ for (int i = -1; i < 8; i++) {
device_id->add_item(_get_device_string(i));
+ }
_set_current_device(0);
vbc_left->add_child(device_id);
@@ -2052,7 +2005,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translation_locales_list_created = false;
{
-
VBoxContainer *tvb = memnew(VBoxContainer);
translations->add_child(tvb);
tvb->set_name(TTR("Translations"));
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 5475bb5508..445ef58351 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -41,7 +41,6 @@
#include "scene/gui/tab_container.h"
class ProjectSettingsEditor : public AcceptDialog {
-
GDCLASS(ProjectSettingsEditor, AcceptDialog);
enum InputType {
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 60329fb7bc..49b9ca167b 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -59,7 +59,6 @@
#include "scene/scene_string_names.h"
void EditorResourceConversionPlugin::_bind_methods() {
-
MethodInfo mi;
mi.name = "_convert";
mi.return_val.type = Variant::OBJECT;
@@ -78,48 +77,42 @@ void EditorResourceConversionPlugin::_bind_methods() {
}
String EditorResourceConversionPlugin::converts_to() const {
-
- if (get_script_instance())
+ if (get_script_instance()) {
return get_script_instance()->call("_converts_to");
+ }
return "";
}
bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const {
-
- if (get_script_instance())
+ if (get_script_instance()) {
return get_script_instance()->call("_handles", p_resource);
+ }
return false;
}
Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) const {
-
- if (get_script_instance())
+ if (get_script_instance()) {
return get_script_instance()->call("_convert", p_resource);
+ }
return Ref<Resource>();
}
void CustomPropertyEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) {
hide();
}
}
void CustomPropertyEditor::_menu_option(int p_which) {
-
switch (type) {
-
case Variant::INT: {
-
if (hint == PROPERTY_HINT_FLAGS) {
-
int val = v;
if (val & (1 << p_which)) {
-
val &= ~(1 << p_which);
} else {
val |= (1 << p_which);
@@ -128,30 +121,24 @@ void CustomPropertyEditor::_menu_option(int p_which) {
v = val;
emit_signal("variant_changed");
} else if (hint == PROPERTY_HINT_ENUM) {
-
v = menu->get_item_metadata(p_which);
emit_signal("variant_changed");
}
} break;
case Variant::STRING: {
-
if (hint == PROPERTY_HINT_ENUM) {
-
v = hint_text.get_slice(",", p_which);
emit_signal("variant_changed");
}
} break;
case Variant::OBJECT: {
-
switch (p_which) {
case OBJ_MENU_LOAD: {
-
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
List<String> extensions;
for (int i = 0; i < type.get_slice_count(","); i++) {
-
ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions);
}
@@ -162,7 +149,6 @@ void CustomPropertyEditor::_menu_option(int p_which) {
file->clear_filters();
for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
-
file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
@@ -170,38 +156,33 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_EDIT: {
-
REF r = v;
if (!r.is_null()) {
-
emit_signal("resource_edit_request");
hide();
}
} break;
case OBJ_MENU_CLEAR: {
-
v = Variant();
emit_signal("variant_changed");
hide();
} break;
case OBJ_MENU_MAKE_UNIQUE: {
-
Ref<Resource> res_orig = v;
- if (res_orig.is_null())
+ if (res_orig.is_null()) {
return;
+ }
List<PropertyInfo> property_list;
res_orig->get_property_list(&property_list);
List<Pair<String, Variant>> propvalues;
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
-
Pair<String, Variant> p;
PropertyInfo &pi = E->get();
if (pi.usage & PROPERTY_USAGE_STORAGE) {
-
p.first = pi.name;
p.second = res_orig->get(pi.name);
}
@@ -218,7 +199,6 @@ void CustomPropertyEditor::_menu_option(int p_which) {
ERR_FAIL_COND(res.is_null());
for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) {
-
Pair<String, Variant> &p = E->get();
res->set(p.first, p.second);
}
@@ -229,26 +209,24 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_COPY: {
-
EditorSettings::get_singleton()->set_resource_clipboard(v);
} break;
case OBJ_MENU_PASTE: {
-
v = EditorSettings::get_singleton()->get_resource_clipboard();
emit_signal("variant_changed");
} break;
case OBJ_MENU_NEW_SCRIPT: {
-
- if (Object::cast_to<Node>(owner))
+ if (Object::cast_to<Node>(owner)) {
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner), false);
+ }
} break;
case OBJ_MENU_EXTEND_SCRIPT: {
-
- if (Object::cast_to<Node>(owner))
+ if (Object::cast_to<Node>(owner)) {
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner), true);
+ }
} break;
case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
@@ -260,9 +238,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
tab_container->set_current_tab(file_system_dock->get_index());
} break;
default: {
-
if (p_which >= CONVERT_BASE_ID) {
-
int to_type = p_which - CONVERT_BASE_ID;
Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v));
@@ -280,7 +256,6 @@ void CustomPropertyEditor::_menu_option(int p_which) {
String intype = inheritors_array[p_which - TYPE_BASE_ID];
if (intype == "ViewportTexture") {
-
scene_tree->set_title(TTR("Pick a Viewport"));
scene_tree->popup_centered_ratio();
picking_viewport = true;
@@ -322,17 +297,14 @@ void CustomPropertyEditor::hide_menu() {
}
Variant CustomPropertyEditor::get_variant() const {
-
return v;
}
String CustomPropertyEditor::get_name() const {
-
return name;
}
bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text) {
-
owner = p_owner;
updating = true;
name = p_name;
@@ -341,8 +313,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
hint = p_hint;
hint_text = p_hint_text;
type_button->hide();
- if (color_picker)
+ if (color_picker) {
color_picker->hide();
+ }
texture_preview->hide();
inheritors_array.clear();
text_edit->hide();
@@ -353,28 +326,29 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->set_size(Size2(1, 1) * EDSCALE);
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
-
+ if (i < MAX_VALUE_EDITORS / 4) {
+ value_hboxes[i]->hide();
+ }
value_editor[i]->hide();
value_label[i]->hide();
- if (i < 4)
+ if (i < 4) {
scroll[i]->hide();
+ }
}
for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
-
action_buttons[i]->hide();
}
checks20gc->hide();
- for (int i = 0; i < 20; i++)
+ for (int i = 0; i < 20; i++) {
checks20[i]->hide();
+ }
type = (p_variant.get_type() != Variant::NIL && p_variant.get_type() != Variant::_RID && p_type != Variant::OBJECT) ? p_variant.get_type() : p_type;
switch (type) {
-
case Variant::BOOL: {
-
checks20gc->show();
CheckBox *c = checks20[0];
@@ -389,26 +363,24 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::INT:
case Variant::FLOAT: {
-
if (hint == PROPERTY_HINT_RANGE) {
-
int c = hint_text.get_slice_count(",");
float min = 0, max = 100, step = type == Variant::FLOAT ? .01 : 1;
if (c >= 1) {
-
- if (!hint_text.get_slice(",", 0).empty())
+ if (!hint_text.get_slice(",", 0).empty()) {
min = hint_text.get_slice(",", 0).to_double();
+ }
}
if (c >= 2) {
-
- if (!hint_text.get_slice(",", 1).empty())
+ if (!hint_text.get_slice(",", 1).empty()) {
max = hint_text.get_slice(",", 1).to_double();
+ }
}
if (c >= 3) {
-
- if (!hint_text.get_slice(",", 2).empty())
+ if (!hint_text.get_slice(",", 2).empty()) {
step = hint_text.get_slice(",", 2).to_double();
+ }
}
if (c >= 4 && hint_text.get_slice(",", 3) == "slider") {
@@ -428,13 +400,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
} else if (hint == PROPERTY_HINT_ENUM) {
-
Vector<String> options = hint_text.split(",");
int current_val = 0;
for (int i = 0; i < options.size(); i++) {
Vector<String> text_split = options[i].split(":");
- if (text_split.size() != 1)
+ if (text_split.size() != 1) {
current_val = text_split[1].to_int();
+ }
menu->add_item(text_split[0]);
menu->set_item_metadata(i, current_val);
current_val += 1;
@@ -446,7 +418,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return false;
} else if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
-
String basename;
switch (hint) {
case PROPERTY_HINT_LAYERS_2D_RENDER:
@@ -466,11 +437,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
checks20gc->show();
uint32_t flgs = v;
for (int i = 0; i < 2; i++) {
-
Point2 ofs(4, 4);
ofs.y += 22 * i;
for (int j = 0; j < 10; j++) {
-
int idx = i * 10 + j;
CheckBox *c = checks20[idx];
c->set_text(ProjectSettings::get_singleton()->get(basename + "/layer_" + itos(idx + 1)));
@@ -487,7 +456,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
set_size(Vector2(4, 4) * EDSCALE + checks20gc->get_position() + checks20gc->get_size());
} else if (hint == PROPERTY_HINT_EXP_EASING) {
-
easing_draw->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5 * EDSCALE);
easing_draw->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5 * EDSCALE);
easing_draw->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 5 * EDSCALE);
@@ -514,12 +482,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Vector<String> flags = hint_text.split(",");
for (int i = 0; i < flags.size(); i++) {
String flag = flags[i];
- if (flag == "")
+ if (flag == "") {
continue;
+ }
menu->add_check_item(flag, i);
int f = v;
- if (f & (1 << i))
+ if (f & (1 << i)) {
menu->set_item_checked(menu->get_item_index(i), true);
+ }
}
menu->set_position(get_position());
menu->popup();
@@ -536,22 +506,18 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::STRING: {
-
if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_GLOBAL_FILE) {
-
List<String> names;
names.push_back(TTR("File..."));
names.push_back(TTR("Clear"));
config_action_buttons(names);
} else if (hint == PROPERTY_HINT_DIR || hint == PROPERTY_HINT_GLOBAL_DIR) {
-
List<String> names;
names.push_back(TTR("Dir..."));
names.push_back(TTR("Clear"));
config_action_buttons(names);
} else if (hint == PROPERTY_HINT_ENUM) {
-
Vector<String> options = hint_text.split(",");
for (int i = 0; i < options.size(); i++) {
menu->add_item(options[i], i);
@@ -563,7 +529,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return false;
} else if (hint == PROPERTY_HINT_MULTILINE_TEXT) {
-
text_edit->show();
text_edit->set_text(v);
text_edit->deselect();
@@ -581,7 +546,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
action_buttons[0]->show();
} else if (hint == PROPERTY_HINT_TYPE_STRING) {
-
if (!create_dialog) {
create_dialog = memnew(CreateDialog);
create_dialog->connect("create", callable_mp(this, &CustomPropertyEditor::_create_dialog_callback));
@@ -616,8 +580,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
type = Variant::Type(i);
}
}
- if (type != Variant::NIL)
+ if (type != Variant::NIL) {
property_select->select_method_from_basic_type(type, v);
+ }
updating = false;
return false;
@@ -630,12 +595,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return false;
} else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
-
MAKE_PROPSELECT
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
- if (instance)
+ if (instance) {
property_select->select_method_from_instance(instance, v);
+ }
updating = false;
return false;
@@ -651,26 +616,26 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return false;
} else if (hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE) {
-
MAKE_PROPSELECT
Variant::Type type = Variant::NIL;
String tname = hint_text;
- if (tname.find(".") != -1)
+ if (tname.find(".") != -1) {
tname = tname.get_slice(".", 0);
+ }
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (tname == Variant::get_type_name(Variant::Type(i))) {
type = Variant::Type(Variant::Type(i));
}
}
- if (type != Variant::NIL)
+ if (type != Variant::NIL) {
property_select->select_property_from_basic_type(type, v);
+ }
updating = false;
return false;
} else if (hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE) {
-
MAKE_PROPSELECT
property_select->select_property_from_base_type(hint_text, v);
@@ -679,12 +644,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
return false;
} else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
-
MAKE_PROPSELECT
Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
- if (instance)
+ if (instance) {
property_select->select_property_from_instance(instance, v);
+ }
updating = false;
return false;
@@ -709,7 +674,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::VECTOR2: {
-
field_names.push_back("x");
field_names.push_back("y");
config_value_editors(2, 2, 10, field_names);
@@ -718,7 +682,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
value_editor[1]->set_text(String::num(vec.y));
} break;
case Variant::RECT2: {
-
field_names.push_back("x");
field_names.push_back("y");
field_names.push_back("w");
@@ -731,7 +694,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
value_editor[3]->set_text(String::num(r.size.y));
} break;
case Variant::VECTOR3: {
-
field_names.push_back("x");
field_names.push_back("y");
field_names.push_back("z");
@@ -742,7 +704,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
value_editor[2]->set_text(String::num(vec.z));
} break;
case Variant::PLANE: {
-
field_names.push_back("x");
field_names.push_back("y");
field_names.push_back("z");
@@ -756,7 +717,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::QUAT: {
-
field_names.push_back("x");
field_names.push_back("y");
field_names.push_back("z");
@@ -770,7 +730,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::AABB: {
-
field_names.push_back("px");
field_names.push_back("py");
field_names.push_back("pz");
@@ -789,7 +748,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::TRANSFORM2D: {
-
field_names.push_back("xx");
field_names.push_back("xy");
field_names.push_back("yx");
@@ -800,13 +758,11 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Transform2D basis = v;
for (int i = 0; i < 6; i++) {
-
value_editor[i]->set_text(String::num(basis.elements[i / 2][i % 2]));
}
} break;
case Variant::BASIS: {
-
field_names.push_back("xx");
field_names.push_back("xy");
field_names.push_back("xz");
@@ -820,13 +776,11 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Basis basis = v;
for (int i = 0; i < 9; i++) {
-
value_editor[i]->set_text(String::num(basis.elements[i / 3][i % 3]));
}
} break;
case Variant::TRANSFORM: {
-
field_names.push_back("xx");
field_names.push_back("xy");
field_names.push_back("xz");
@@ -843,7 +797,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Transform tr = v;
for (int i = 0; i < 9; i++) {
-
value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3]));
}
@@ -853,7 +806,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::COLOR: {
-
if (!color_picker) {
//late init for performance
color_picker = memnew(ColorPicker);
@@ -864,10 +816,11 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
- if (default_color_mode == 1)
+ if (default_color_mode == 1) {
color_picker->set_hsv_mode(true);
- else if (default_color_mode == 2)
+ } else if (default_color_mode == 2) {
color_picker->set_raw_mode(true);
+ }
}
color_picker->show();
@@ -878,21 +831,21 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} break;
case Variant::NODE_PATH: {
-
List<String> names;
names.push_back(TTR("Assign"));
names.push_back(TTR("Clear"));
- if (owner && owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v))
+ if (owner && owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) {
names.push_back(TTR("Select Node"));
+ }
config_action_buttons(names);
} break;
case Variant::OBJECT: {
-
- if (hint != PROPERTY_HINT_RESOURCE_TYPE)
+ if (hint != PROPERTY_HINT_RESOURCE_TYPE) {
break;
+ }
if (p_name == "script" && hint_text == "Script" && Object::cast_to<Node>(owner)) {
menu->add_item(TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
@@ -907,7 +860,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
for (int i = 0; i < hint_text.get_slice_count(","); i++) {
-
String base = hint_text.get_slice(",", i);
Set<String> valid_inheritors;
@@ -934,15 +886,17 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
for (int k = 0; k < custom_resources.size(); k++) {
if (custom_resources[k].name == t) {
is_custom_resource = true;
- if (custom_resources[k].icon.is_valid())
+ if (custom_resources[k].icon.is_valid()) {
icon = custom_resources[k].icon;
+ }
break;
}
}
}
- if (!is_custom_resource && !ClassDB::can_instance(t))
+ if (!is_custom_resource && !ClassDB::can_instance(t)) {
continue;
+ }
inheritors_array.push_back(t);
@@ -954,14 +908,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
}
- if (menu->get_item_count())
+ if (menu->get_item_count()) {
menu->add_separator();
+ }
}
menu->add_item(TTR("Load"), OBJ_MENU_LOAD);
if (!RES(v).is_null()) {
-
menu->add_item(TTR("Edit"), OBJ_MENU_EDIT);
menu->add_item(TTR("Clear"), OBJ_MENU_CLEAR);
menu->add_item(TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE);
@@ -976,32 +930,31 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
RES cb = EditorSettings::get_singleton()->get_resource_clipboard();
bool paste_valid = false;
if (cb.is_valid()) {
- if (hint_text == "")
+ if (hint_text == "") {
paste_valid = true;
- else
- for (int i = 0; i < hint_text.get_slice_count(","); i++)
+ } else {
+ for (int i = 0; i < hint_text.get_slice_count(","); i++) {
if (ClassDB::is_parent_class(cb->get_class(), hint_text.get_slice(",", i))) {
paste_valid = true;
break;
}
+ }
+ }
}
if (!RES(v).is_null() || paste_valid) {
menu->add_separator();
if (!RES(v).is_null()) {
-
menu->add_item(TTR("Copy"), OBJ_MENU_COPY);
}
if (paste_valid) {
-
menu->add_item(TTR("Paste"), OBJ_MENU_PASTE);
}
}
if (!RES(v).is_null()) {
-
Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v));
if (conversions.size()) {
menu->add_separator();
@@ -1017,34 +970,24 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
hide();
updating = false;
return false;
-
} break;
case Variant::DICTIONARY: {
-
} break;
case Variant::PACKED_BYTE_ARRAY: {
-
} break;
case Variant::PACKED_INT32_ARRAY: {
-
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
} break;
case Variant::PACKED_INT64_ARRAY: {
-
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
} break;
case Variant::PACKED_STRING_ARRAY: {
-
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
} break;
default: {
}
@@ -1055,20 +998,15 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
}
void CustomPropertyEditor::_file_selected(String p_file) {
-
switch (type) {
-
case Variant::STRING: {
-
if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) {
-
v = ProjectSettings::get_singleton()->localize_path(p_file);
emit_signal("variant_changed");
hide();
}
if (hint == PROPERTY_HINT_GLOBAL_FILE || hint == PROPERTY_HINT_GLOBAL_DIR) {
-
v = p_file;
emit_signal("variant_changed");
hide();
@@ -1076,7 +1014,6 @@ void CustomPropertyEditor::_file_selected(String p_file) {
} break;
case Variant::OBJECT: {
-
String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
RES res = ResourceLoader::load(p_file, type);
@@ -1095,29 +1032,22 @@ void CustomPropertyEditor::_file_selected(String p_file) {
}
void CustomPropertyEditor::_type_create_selected(int p_idx) {
-
if (type == Variant::INT || type == Variant::FLOAT) {
-
float newval = 0;
switch (p_idx) {
-
case EASING_LINEAR: {
-
newval = 1;
} break;
case EASING_EASE_IN: {
-
newval = 2.0;
} break;
case EASING_EASE_OUT: {
newval = 0.5;
} break;
case EASING_ZERO: {
-
newval = 0;
} break;
case EASING_IN_OUT: {
-
newval = -0.5;
} break;
case EASING_OUT_IN: {
@@ -1130,7 +1060,6 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
easing_draw->update();
} else if (type == Variant::OBJECT) {
-
ERR_FAIL_INDEX(p_idx, inheritors_array.size());
String intype = inheritors_array[p_idx];
@@ -1157,15 +1086,12 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
}
void CustomPropertyEditor::_color_changed(const Color &p_color) {
-
v = p_color;
emit_signal("variant_changed");
}
void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
-
if (picking_viewport) {
-
Node *to_node = get_node(p_path);
if (!Object::cast_to<Viewport>(to_node)) {
EditorNode::get_singleton()->show_warning(TTR("Selected node is not a Viewport!"));
@@ -1182,10 +1108,8 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
}
if (hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && hint_text != String()) {
-
Node *node = get_node(hint_text);
if (node) {
-
Node *tonode = node->get_node(p_path);
if (tonode) {
p_path = node->get_path_to(tonode);
@@ -1193,15 +1117,15 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
}
} else if (owner) {
-
Node *node = nullptr;
- if (owner->is_class("Node"))
+ if (owner->is_class("Node")) {
node = Object::cast_to<Node>(owner);
- else if (owner->is_class("ArrayPropertyEdit"))
+ } else if (owner->is_class("ArrayPropertyEdit")) {
node = Object::cast_to<ArrayPropertyEdit>(owner)->get_node();
- else if (owner->is_class("DictionaryPropertyEdit"))
+ } else if (owner->is_class("DictionaryPropertyEdit")) {
node = Object::cast_to<DictionaryPropertyEdit>(owner)->get_node();
+ }
if (!node) {
v = p_path;
emit_signal("variant_changed");
@@ -1221,9 +1145,9 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
}
void CustomPropertyEditor::_action_pressed(int p_which) {
-
- if (updating)
+ if (updating) {
return;
+ }
switch (type) {
case Variant::BOOL: {
@@ -1231,14 +1155,13 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
emit_signal("variant_changed");
} break;
case Variant::INT: {
-
if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
-
uint32_t f = v;
- if (checks20[p_which]->is_pressed())
+ if (checks20[p_which]->is_pressed()) {
f |= (1 << p_which);
- else
+ } else {
f &= ~(1 << p_which);
+ }
v = f;
emit_signal("variant_changed");
@@ -1246,18 +1169,16 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
case Variant::STRING: {
-
if (hint == PROPERTY_HINT_MULTILINE_TEXT) {
-
hide();
} else if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_GLOBAL_FILE) {
if (p_which == 0) {
-
- if (hint == PROPERTY_HINT_FILE)
+ if (hint == PROPERTY_HINT_FILE) {
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
- else
+ } else {
file->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+ }
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file->clear_filters();
@@ -1267,37 +1188,34 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
if (hint_text != "") {
Vector<String> extensions = hint_text.split(",");
for (int i = 0; i < extensions.size(); i++) {
-
String filter = extensions[i];
- if (filter.begins_with("."))
+ if (filter.begins_with(".")) {
filter = "*" + extensions[i];
- else if (!filter.begins_with("*"))
+ } else if (!filter.begins_with("*")) {
filter = "*." + extensions[i];
+ }
file->add_filter(filter + " ; " + extensions[i].to_upper());
}
}
file->popup_centered_ratio();
} else {
-
v = "";
emit_signal("variant_changed");
hide();
}
} else if (hint == PROPERTY_HINT_DIR || hint == PROPERTY_HINT_GLOBAL_DIR) {
-
if (p_which == 0) {
-
- if (hint == PROPERTY_HINT_DIR)
+ if (hint == PROPERTY_HINT_DIR) {
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
- else
+ } else {
file->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+ }
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
file->clear_filters();
file->popup_centered_ratio();
} else {
-
v = "";
emit_signal("variant_changed");
hide();
@@ -1306,22 +1224,17 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
case Variant::NODE_PATH: {
-
if (p_which == 0) {
-
picking_viewport = false;
scene_tree->set_title(TTR("Pick a Node"));
scene_tree->popup_centered_ratio();
} else if (p_which == 1) {
-
v = NodePath();
emit_signal("variant_changed");
hide();
} else if (p_which == 2) {
-
if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) {
-
Node *target_node = Object::cast_to<Node>(owner)->get_node(v);
EditorNode::get_singleton()->get_editor_selection()->clear();
EditorNode::get_singleton()->get_scene_tree_dock()->set_selected(target_node);
@@ -1332,15 +1245,12 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
case Variant::OBJECT: {
-
if (p_which == 0) {
-
ERR_FAIL_COND(inheritors_array.empty());
String intype = inheritors_array[0];
if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
-
Object *obj = ClassDB::instance(intype);
if (!obj) {
@@ -1360,7 +1270,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
hide();
}
} else if (p_which == 1) {
-
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> extensions;
@@ -1369,43 +1278,37 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
ResourceLoader::get_recognized_extensions_for_type(type, &extensions);
file->clear_filters();
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
-
file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
file->popup_centered_ratio();
} else if (p_which == 2) {
-
RES r = v;
if (!r.is_null()) {
-
emit_signal("resource_edit_request");
hide();
}
} else if (p_which == 3) {
-
v = Variant();
emit_signal("variant_changed");
hide();
} else if (p_which == 4) {
-
Ref<Resource> res_orig = v;
- if (res_orig.is_null())
+ if (res_orig.is_null()) {
return;
+ }
List<PropertyInfo> property_list;
res_orig->get_property_list(&property_list);
List<Pair<String, Variant>> propvalues;
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
-
Pair<String, Variant> p;
PropertyInfo &pi = E->get();
if (pi.usage & PROPERTY_USAGE_STORAGE) {
-
p.first = pi.name;
p.second = res_orig->get(pi.name);
}
@@ -1418,7 +1321,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
ERR_FAIL_COND(res.is_null());
for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) {
-
Pair<String, Variant> &p = E->get();
res->set(p.first, p.second);
}
@@ -1436,23 +1338,24 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
}
void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventMouseMotion> mm = p_ev;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
float rel = mm->get_relative().x;
- if (rel == 0)
+ if (rel == 0) {
return;
+ }
bool flip = hint_text == "attenuation";
- if (flip)
+ if (flip) {
rel = -rel;
+ }
float val = v;
- if (val == 0)
+ if (val == 0) {
return;
+ }
bool sg = val < 0;
val = Math::absf(val);
@@ -1461,8 +1364,9 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
val += rel * 0.05;
val = Math::pow(2.0f, val);
- if (sg)
+ if (sg) {
val = -val;
+ }
v = val;
easing_draw->update();
@@ -1471,7 +1375,6 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) {
}
void CustomPropertyEditor::_draw_easing() {
-
RID ci = easing_draw->get_canvas_item();
Size2 s = easing_draw->get_size();
@@ -1489,7 +1392,6 @@ void CustomPropertyEditor::_draw_easing() {
Color color = easing_draw->get_theme_color("font_color", "Label");
for (int i = 1; i <= points; i++) {
-
float ifl = i / float(points);
float iflp = (i - 1) / float(points);
@@ -1508,27 +1410,24 @@ void CustomPropertyEditor::_draw_easing() {
}
void CustomPropertyEditor::_text_edit_changed() {
-
v = text_edit->get_text();
emit_signal("variant_changed");
}
void CustomPropertyEditor::_create_dialog_callback() {
-
v = create_dialog->get_selected_type();
emit_signal("variant_changed");
}
void CustomPropertyEditor::_create_selected_property(const String &p_prop) {
-
v = p_prop;
emit_signal("variant_changed");
}
void CustomPropertyEditor::_modified(String p_string) {
-
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
switch (type) {
@@ -1547,7 +1446,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::FLOAT: {
-
if (hint != PROPERTY_HINT_EXP_EASING) {
String text = value_editor[0]->get_text();
v = _parse_real_expression(text);
@@ -1556,12 +1454,10 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::STRING: {
-
v = value_editor[0]->get_text();
emit_signal("variant_changed");
} break;
case Variant::VECTOR2: {
-
Vector2 vec;
vec.x = _parse_real_expression(value_editor[0]->get_text());
vec.y = _parse_real_expression(value_editor[1]->get_text());
@@ -1570,7 +1466,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::RECT2: {
-
Rect2 r2;
r2.position.x = _parse_real_expression(value_editor[0]->get_text());
@@ -1583,7 +1478,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::VECTOR3: {
-
Vector3 vec;
vec.x = _parse_real_expression(value_editor[0]->get_text());
vec.y = _parse_real_expression(value_editor[1]->get_text());
@@ -1593,7 +1487,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::PLANE: {
-
Plane pl;
pl.normal.x = _parse_real_expression(value_editor[0]->get_text());
pl.normal.y = _parse_real_expression(value_editor[1]->get_text());
@@ -1604,7 +1497,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::QUAT: {
-
Quat q;
q.x = _parse_real_expression(value_editor[0]->get_text());
q.y = _parse_real_expression(value_editor[1]->get_text());
@@ -1615,7 +1507,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::AABB: {
-
Vector3 pos;
Vector3 size;
@@ -1630,7 +1521,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::TRANSFORM2D: {
-
Transform2D m;
for (int i = 0; i < 6; i++) {
m.elements[i / 2][i % 2] = _parse_real_expression(value_editor[i]->get_text());
@@ -1641,7 +1531,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::BASIS: {
-
Basis m;
for (int i = 0; i < 9; i++) {
m.elements[i / 3][i % 3] = _parse_real_expression(value_editor[i]->get_text());
@@ -1652,7 +1541,6 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::TRANSFORM: {
-
Basis basis;
for (int i = 0; i < 9; i++) {
basis.elements[i / 3][i % 3] = _parse_real_expression(value_editor[(i / 3) * 4 + i % 3]->get_text());
@@ -1669,34 +1557,25 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::COLOR: {
-
} break;
case Variant::NODE_PATH: {
-
v = NodePath(value_editor[0]->get_text());
emit_signal("variant_changed");
} break;
case Variant::DICTIONARY: {
-
} break;
case Variant::PACKED_BYTE_ARRAY: {
-
} break;
case Variant::PACKED_INT32_ARRAY: {
-
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
} break;
case Variant::PACKED_STRING_ARRAY: {
-
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
} break;
default: {
}
@@ -1719,7 +1598,6 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) {
}
void CustomPropertyEditor::_emit_changed_whole_or_field() {
-
if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
emit_signal("variant_changed");
} else {
@@ -1781,7 +1659,6 @@ void CustomPropertyEditor::_focus_exit() {
}
void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) {
-
Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox("panel");
int margin_top = sb->get_margin(MARGIN_TOP);
int margin_left = sb->get_margin(MARGIN_LEFT);
@@ -1792,15 +1669,14 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings)
int height = 0;
for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
-
if (i < p_strings.size()) {
-
action_buttons[i]->show();
action_buttons[i]->set_text(p_strings[i]);
Size2 btn_m_size = action_buttons[i]->get_minimum_size();
- if (btn_m_size.width > max_width)
+ if (btn_m_size.width > max_width) {
max_width = btn_m_size.width;
+ }
} else {
action_buttons[i]->hide();
@@ -1808,7 +1684,6 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings)
}
for (int i = 0; i < p_strings.size(); i++) {
-
Size2 btn_m_size = action_buttons[i]->get_size();
action_buttons[i]->set_position(Point2(0, height) + Point2(margin_left, margin_top));
action_buttons[i]->set_size(Size2(max_width, btn_m_size.height));
@@ -1819,7 +1694,6 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings)
}
void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings) {
-
int cell_width = 95;
int cell_height = 25;
int cell_margin = 5;
@@ -1830,6 +1704,13 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int
set_size(Size2(cell_margin + p_label_w + (cell_width + cell_margin + p_label_w) * p_columns, cell_margin + (cell_height + cell_margin) * rows) * EDSCALE);
for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
+ if (i < MAX_VALUE_EDITORS / 4) {
+ if (i <= p_amount / 4) {
+ value_hboxes[i]->show();
+ } else {
+ value_hboxes[i]->hide();
+ }
+ }
int c = i % p_columns;
int r = i / p_columns;
@@ -1850,25 +1731,32 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int
}
void CustomPropertyEditor::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("variant_changed"));
ADD_SIGNAL(MethodInfo("variant_field_changed", PropertyInfo(Variant::STRING, "field")));
ADD_SIGNAL(MethodInfo("resource_edit_request"));
}
CustomPropertyEditor::CustomPropertyEditor() {
-
read_only = false;
updating = false;
- for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
+ value_vbox = memnew(VBoxContainer);
+ add_child(value_vbox);
- value_editor[i] = memnew(LineEdit);
- add_child(value_editor[i]);
+ for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
+ if (i < MAX_VALUE_EDITORS / 4) {
+ value_hboxes[i] = memnew(HBoxContainer);
+ value_vbox->add_child(value_hboxes[i]);
+ value_hboxes[i]->hide();
+ }
+ int hbox_idx = i / 4;
value_label[i] = memnew(Label);
- add_child(value_label[i]);
- value_editor[i]->hide();
+ value_hboxes[hbox_idx]->add_child(value_label[i]);
value_label[i]->hide();
+ value_editor[i] = memnew(LineEdit);
+ value_hboxes[hbox_idx]->add_child(value_editor[i]);
+ value_editor[i]->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ value_editor[i]->hide();
value_editor[i]->connect("text_entered", callable_mp(this, &CustomPropertyEditor::_modified));
value_editor[i]->connect("focus_entered", callable_mp(this, &CustomPropertyEditor::_focus_enter));
value_editor[i]->connect("focus_exited", callable_mp(this, &CustomPropertyEditor::_focus_exit));
@@ -1876,7 +1764,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
focused_value_editor = -1;
for (int i = 0; i < 4; i++) {
-
scroll[i] = memnew(HScrollBar);
scroll[i]->hide();
scroll[i]->set_min(0);
@@ -1914,7 +1801,6 @@ CustomPropertyEditor::CustomPropertyEditor() {
text_edit->connect("text_changed", callable_mp(this, &CustomPropertyEditor::_text_edit_changed));
for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
-
action_buttons[i] = memnew(Button);
action_buttons[i]->hide();
add_child(action_buttons[i]);
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 45466eaa42..75c6fd372b 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -51,7 +51,6 @@ class CreateDialog;
class PropertySelector;
class EditorResourceConversionPlugin : public Reference {
-
GDCLASS(EditorResourceConversionPlugin, Reference);
protected:
@@ -64,7 +63,6 @@ public:
};
class CustomPropertyEditor : public PopupPanel {
-
GDCLASS(CustomPropertyEditor, PopupPanel);
enum {
@@ -102,6 +100,8 @@ class CustomPropertyEditor : public PopupPanel {
List<String> field_names;
int hint;
String hint_text;
+ HBoxContainer *value_hboxes[MAX_VALUE_EDITORS / 4];
+ VBoxContainer *value_vbox;
LineEdit *value_editor[MAX_VALUE_EDITORS];
int focused_value_editor;
Label *value_label[MAX_VALUE_EDITORS];
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index 1960ecc604..c6c93fae83 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -35,28 +35,25 @@
#include "editor_scale.h"
void PropertySelector::_text_changed(const String &p_newtext) {
-
_update_search();
}
void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
-
Ref<InputEventKey> k = p_ie;
if (k.is_valid()) {
-
switch (k->get_keycode()) {
case KEY_UP:
case KEY_DOWN:
case KEY_PAGEUP:
case KEY_PAGEDOWN: {
-
search_options->call("_gui_input", k);
search_box->accept_event();
TreeItem *root = search_options->get_root();
- if (!root->get_children())
+ if (!root->get_children()) {
break;
+ }
TreeItem *current = search_options->get_selected();
@@ -74,13 +71,13 @@ void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
}
void PropertySelector::_update_search() {
-
- if (properties)
+ if (properties) {
set_title(TTR("Select Property"));
- else if (virtuals_only)
+ } else if (virtuals_only) {
set_title(TTR("Select Virtual Method"));
- else
+ } else {
set_title(TTR("Select Method"));
+ }
search_options->clear();
help_bit->set_text("");
@@ -88,7 +85,6 @@ void PropertySelector::_update_search() {
TreeItem *root = search_options->create_item();
if (properties) {
-
List<PropertyInfo> props;
if (instance) {
@@ -100,10 +96,8 @@ void PropertySelector::_update_search() {
v.get_property_list(&props);
} else {
-
Object *obj = ObjectDB::get_instance(script);
if (Object::cast_to<Script>(obj)) {
-
props.push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY));
Object::cast_to<Script>(obj)->get_script_property_list(&props);
}
@@ -169,14 +163,17 @@ void PropertySelector::_update_search() {
continue;
}
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
continue;
+ }
- if (search_box->get_text() != String() && E->get().name.find(search_box->get_text()) == -1)
+ if (search_box->get_text() != String() && E->get().name.find(search_box->get_text()) == -1) {
continue;
+ }
- if (type_filter.size() && type_filter.find(E->get().type) == -1)
+ if (type_filter.size() && type_filter.find(E->get().type) == -1) {
continue;
+ }
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, E->get().name);
@@ -195,7 +192,6 @@ void PropertySelector::_update_search() {
memdelete(category); //old category was unused
}
} else {
-
List<MethodInfo> methods;
if (type != Variant::NIL) {
@@ -204,10 +200,8 @@ void PropertySelector::_update_search() {
v = Variant::construct(type, nullptr, 0, ce);
v.get_method_list(&methods);
} else {
-
Object *obj = ObjectDB::get_instance(script);
if (Object::cast_to<Script>(obj)) {
-
methods.push_back(MethodInfo("*Script Methods"));
Object::cast_to<Script>(obj)->get_script_method_list(&methods);
}
@@ -249,17 +243,21 @@ void PropertySelector::_update_search() {
}
String name = E->get().name.get_slice(":", 0);
- if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL))
+ if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL)) {
continue;
+ }
- if (virtuals_only && !(E->get().flags & METHOD_FLAG_VIRTUAL))
+ if (virtuals_only && !(E->get().flags & METHOD_FLAG_VIRTUAL)) {
continue;
+ }
- if (!virtuals_only && (E->get().flags & METHOD_FLAG_VIRTUAL))
+ if (!virtuals_only && (E->get().flags & METHOD_FLAG_VIRTUAL)) {
continue;
+ }
- if (search_box->get_text() != String() && name.find(search_box->get_text()) == -1)
+ if (search_box->get_text() != String() && name.find(search_box->get_text()) == -1) {
continue;
+ }
TreeItem *item = search_options->create_item(category ? category : root);
@@ -269,36 +267,40 @@ void PropertySelector::_update_search() {
if (mi.name.find(":") != -1) {
desc = mi.name.get_slice(":", 1) + " ";
mi.name = mi.name.get_slice(":", 0);
- } else if (mi.return_val.type != Variant::NIL)
+ } else if (mi.return_val.type != Variant::NIL) {
desc = Variant::get_type_name(mi.return_val.type);
- else
+ } else {
desc = "void ";
+ }
desc += " " + mi.name + " ( ";
for (int i = 0; i < mi.arguments.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
desc += ", ";
+ }
- if (mi.arguments[i].type == Variant::NIL)
+ if (mi.arguments[i].type == Variant::NIL) {
desc += "var ";
- else if (mi.arguments[i].name.find(":") != -1) {
+ } else if (mi.arguments[i].name.find(":") != -1) {
desc += mi.arguments[i].name.get_slice(":", 1) + " ";
mi.arguments[i].name = mi.arguments[i].name.get_slice(":", 0);
- } else
+ } else {
desc += Variant::get_type_name(mi.arguments[i].type) + " ";
+ }
desc += mi.arguments[i].name;
}
desc += " )";
- if (E->get().flags & METHOD_FLAG_CONST)
+ if (E->get().flags & METHOD_FLAG_CONST) {
desc += " const";
+ }
- if (E->get().flags & METHOD_FLAG_VIRTUAL)
+ if (E->get().flags & METHOD_FLAG_VIRTUAL) {
desc += " virtual";
+ }
item->set_text(0, desc);
item->set_metadata(0, name);
@@ -319,21 +321,21 @@ void PropertySelector::_update_search() {
}
void PropertySelector::_confirmed() {
-
TreeItem *ti = search_options->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
emit_signal("selected", ti->get_metadata(0));
hide();
}
void PropertySelector::_item_selected() {
-
help_bit->set_text("");
TreeItem *item = search_options->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
String name = item->get_metadata(0);
String class_type;
@@ -348,16 +350,14 @@ void PropertySelector::_item_selected() {
String text;
if (properties) {
-
String at_class = class_type;
while (at_class != String()) {
-
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
if (E) {
for (int i = 0; i < E->get().properties.size(); i++) {
if (E->get().properties[i].name == name) {
- text = E->get().properties[i].description;
+ text = DTR(E->get().properties[i].description);
}
}
}
@@ -365,16 +365,14 @@ void PropertySelector::_item_selected() {
at_class = ClassDB::get_parent_class(at_class);
}
} else {
-
String at_class = class_type;
while (at_class != String()) {
-
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
if (E) {
for (int i = 0; i < E->get().methods.size(); i++) {
if (E->get().methods[i].name == name) {
- text = E->get().methods[i].description;
+ text = DTR(E->get().methods[i].description);
}
}
}
@@ -383,8 +381,9 @@ void PropertySelector::_item_selected() {
}
}
- if (text == String())
+ if (text == String()) {
return;
+ }
help_bit->set_text(text);
}
@@ -394,9 +393,7 @@ void PropertySelector::_hide_requested() {
}
void PropertySelector::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
connect("confirmed", callable_mp(this, &PropertySelector::_confirmed));
} else if (p_what == NOTIFICATION_EXIT_TREE) {
disconnect("confirmed", callable_mp(this, &PropertySelector::_confirmed));
@@ -404,7 +401,6 @@ void PropertySelector::_notification(int p_what) {
}
void PropertySelector::select_method_from_base_type(const String &p_base, const String &p_current, bool p_virtuals_only) {
-
base_type = p_base;
selected = p_current;
type = Variant::NIL;
@@ -420,7 +416,6 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const
}
void PropertySelector::select_method_from_script(const Ref<Script> &p_script, const String &p_current) {
-
ERR_FAIL_COND(p_script.is_null());
base_type = p_script->get_instance_base_type();
selected = p_current;
@@ -435,8 +430,8 @@ void PropertySelector::select_method_from_script(const Ref<Script> &p_script, co
search_box->grab_focus();
_update_search();
}
-void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const String &p_current) {
+void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const String &p_current) {
ERR_FAIL_COND(p_type == Variant::NIL);
base_type = "";
selected = p_current;
@@ -453,15 +448,15 @@ void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const
}
void PropertySelector::select_method_from_instance(Object *p_instance, const String &p_current) {
-
base_type = p_instance->get_class();
selected = p_current;
type = Variant::NIL;
script = ObjectID();
{
Ref<Script> scr = p_instance->get_script();
- if (scr.is_valid())
+ if (scr.is_valid()) {
script = scr->get_instance_id();
+ }
}
properties = false;
instance = nullptr;
@@ -474,7 +469,6 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str
}
void PropertySelector::select_property_from_base_type(const String &p_base, const String &p_current) {
-
base_type = p_base;
selected = p_current;
type = Variant::NIL;
@@ -490,7 +484,6 @@ void PropertySelector::select_property_from_base_type(const String &p_base, cons
}
void PropertySelector::select_property_from_script(const Ref<Script> &p_script, const String &p_current) {
-
ERR_FAIL_COND(p_script.is_null());
base_type = p_script->get_instance_base_type();
@@ -508,7 +501,6 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script,
}
void PropertySelector::select_property_from_basic_type(Variant::Type p_type, const String &p_current) {
-
ERR_FAIL_COND(p_type == Variant::NIL);
base_type = "";
selected = p_current;
@@ -525,7 +517,6 @@ void PropertySelector::select_property_from_basic_type(Variant::Type p_type, con
}
void PropertySelector::select_property_from_instance(Object *p_instance, const String &p_current) {
-
base_type = "";
selected = p_current;
type = Variant::NIL;
@@ -545,12 +536,10 @@ void PropertySelector::set_type_filter(const Vector<Variant::Type> &p_type_filte
}
void PropertySelector::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name")));
}
PropertySelector::PropertySelector() {
-
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp
index 1363fe2942..23bcf9540e 100644
--- a/editor/pvrtc_compress.cpp
+++ b/editor/pvrtc_compress.cpp
@@ -42,21 +42,21 @@ static void (*_base_image_compress_pvrtc2_func)(Image *) = nullptr;
static void (*_base_image_compress_pvrtc4_func)(Image *) = nullptr;
static void _compress_image(Image::CompressMode p_mode, Image *p_image) {
-
String ttpath = EditorSettings::get_singleton()->get("filesystem/import/pvrtc_texture_tool");
if (ttpath.strip_edges() == "" || !FileAccess::exists(ttpath)) {
switch (p_mode) {
-
case Image::COMPRESS_PVRTC2:
- if (_base_image_compress_pvrtc2_func)
+ if (_base_image_compress_pvrtc2_func) {
_base_image_compress_pvrtc2_func(p_image);
- else if (_base_image_compress_pvrtc4_func)
+ } else if (_base_image_compress_pvrtc4_func) {
_base_image_compress_pvrtc4_func(p_image);
+ }
break;
case Image::COMPRESS_PVRTC4:
- if (_base_image_compress_pvrtc4_func)
+ if (_base_image_compress_pvrtc4_func) {
_base_image_compress_pvrtc4_func(p_image);
+ }
break;
default:
ERR_FAIL_MSG("Unsupported Image compress mode used in PVRTC module.");
@@ -125,17 +125,14 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) {
}
static void _compress_pvrtc2(Image *p_image) {
-
_compress_image(Image::COMPRESS_PVRTC2, p_image);
}
static void _compress_pvrtc4(Image *p_image) {
-
_compress_image(Image::COMPRESS_PVRTC4, p_image);
}
void _pvrtc_register_compressors() {
-
_base_image_compress_pvrtc2_func = Image::_image_compress_pvrtc2_func;
_base_image_compress_pvrtc4_func = Image::_image_compress_pvrtc4_func;
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index b872bc3dd4..bcef29dfa6 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -33,38 +33,37 @@
#include "core/os/keyboard.h"
void EditorQuickOpen::popup_dialog(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
-
add_directories = p_add_dirs;
popup_centered_ratio(0.6);
- if (p_dontclear)
+ if (p_dontclear) {
search_box->select_all();
- else
+ } else {
search_box->clear();
- if (p_enable_multi)
+ }
+ if (p_enable_multi) {
search_options->set_select_mode(Tree::SELECT_MULTI);
- else
+ } else {
search_options->set_select_mode(Tree::SELECT_SINGLE);
+ }
search_box->grab_focus();
base_type = p_base;
_update_search();
}
String EditorQuickOpen::get_selected() const {
-
TreeItem *ti = search_options->get_selected();
- if (!ti)
+ if (!ti) {
return String();
+ }
return "res://" + ti->get_text(0);
}
Vector<String> EditorQuickOpen::get_selected_files() const {
-
Vector<String> files;
TreeItem *item = search_options->get_next_selected(search_options->get_root());
while (item) {
-
files.push_back("res://" + item->get_text(0));
item = search_options->get_next_selected(item);
@@ -74,27 +73,24 @@ Vector<String> EditorQuickOpen::get_selected_files() const {
}
void EditorQuickOpen::_text_changed(const String &p_newtext) {
-
_update_search();
}
void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
-
Ref<InputEventKey> k = p_ie;
if (k.is_valid()) {
-
switch (k->get_keycode()) {
case KEY_UP:
case KEY_DOWN:
case KEY_PAGEUP:
case KEY_PAGEDOWN: {
-
search_options->call("_gui_input", k);
search_box->accept_event();
TreeItem *root = search_options->get_root();
- if (!root->get_children())
+ if (!root->get_children()) {
break;
+ }
TreeItem *current = search_options->get_selected();
@@ -112,7 +108,6 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
}
float EditorQuickOpen::_path_cmp(String search, String path) const {
-
// Exact match.
if (search == path) {
return 1.2f;
@@ -129,10 +124,8 @@ float EditorQuickOpen::_path_cmp(String search, String path) const {
}
void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list) {
-
if (!add_directories) {
for (int i = 0; i < efsd->get_subdir_count(); i++) {
-
_parse_fs(efsd->get_subdir(i), list);
}
}
@@ -141,8 +134,9 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
if (add_directories) {
String path = efsd->get_path();
- if (!path.ends_with("/"))
+ if (!path.ends_with("/")) {
path += "/";
+ }
if (path != "res://") {
path = path.substr(6, path.length());
if (search_text.is_subsequence_ofi(path)) {
@@ -151,7 +145,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
pair.second = search_options->get_theme_icon("folder", "FileDialog");
if (search_text != String() && list.size() > 0) {
-
float this_sim = _path_cmp(search_text, path);
float other_sim = _path_cmp(list[0].first, path);
int pos = 1;
@@ -170,7 +163,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
}
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
String file = efsd->get_file_path(i);
file = file.substr(6, file.length());
@@ -184,27 +176,26 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
if (add_directories) {
for (int i = 0; i < efsd->get_subdir_count(); i++) {
-
_parse_fs(efsd->get_subdir(i), list);
}
}
}
Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list) {
-
String search_text = search_box->get_text();
Vector<Pair<String, Ref<Texture2D>>> sorted_list;
- if (search_text == String() || list.size() == 0)
+ if (search_text == String() || list.size() == 0) {
return list;
+ }
Vector<float> scores;
scores.resize(list.size());
- for (int i = 0; i < list.size(); i++)
+ for (int i = 0; i < list.size(); i++) {
scores.write[i] = _path_cmp(search_text, list[i].first);
+ }
while (list.size() > 0) {
-
float best_score = 0.0f;
int best_idx = 0;
@@ -225,7 +216,6 @@ Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<Strin
}
void EditorQuickOpen::_update_search() {
-
search_options->clear();
TreeItem *root = search_options->create_item();
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem();
@@ -251,21 +241,19 @@ void EditorQuickOpen::_update_search() {
}
void EditorQuickOpen::_confirmed() {
-
TreeItem *ti = search_options->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
emit_signal("quick_open");
hide();
}
void EditorQuickOpen::_theme_changed() {
-
search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons"));
}
void EditorQuickOpen::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed));
@@ -279,17 +267,14 @@ void EditorQuickOpen::_notification(int p_what) {
}
StringName EditorQuickOpen::get_base_type() const {
-
return base_type;
}
void EditorQuickOpen::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("quick_open"));
}
EditorQuickOpen::EditorQuickOpen() {
-
VBoxContainer *vbc = memnew(VBoxContainer);
vbc->connect("theme_changed", callable_mp(this, &EditorQuickOpen::_theme_changed));
diff --git a/editor/quick_open.h b/editor/quick_open.h
index c0e2cb85d8..e446ed6823 100644
--- a/editor/quick_open.h
+++ b/editor/quick_open.h
@@ -36,7 +36,6 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
class EditorQuickOpen : public ConfirmationDialog {
-
GDCLASS(EditorQuickOpen, ConfirmationDialog);
LineEdit *search_box;
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index 8ae8d0991d..6a54894f40 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -42,7 +42,6 @@
#include "scene/gui/tab_container.h"
RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) {
-
scene_tree_editor = p_scene_tree_editor;
undo_redo = p_undo_redo;
preview_node = nullptr;
@@ -341,12 +340,10 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
}
void RenameDialog::_bind_methods() {
-
ClassDB::bind_method("rename", &RenameDialog::rename);
}
void RenameDialog::_update_substitute() {
-
LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner());
bool is_main_field = _is_main_field(focus_owner_line_edit);
@@ -367,7 +364,6 @@ void RenameDialog::_update_substitute() {
}
void RenameDialog::_post_popup() {
-
EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
preview_node = nullptr;
@@ -385,9 +381,9 @@ void RenameDialog::_update_preview_int(int new_value) {
}
void RenameDialog::_update_preview(String new_text) {
-
- if (lock_preview_update || preview_node == nullptr)
+ if (lock_preview_update || preview_node == nullptr) {
return;
+ }
has_errors = false;
add_error_handler(&eh);
@@ -395,7 +391,6 @@ void RenameDialog::_update_preview(String new_text) {
String new_name = _apply_rename(preview_node, spn_count_start->get_value());
if (!has_errors) {
-
lbl_preview_title->set_text(TTR("Preview"));
lbl_preview->set_text(new_name);
@@ -413,7 +408,6 @@ void RenameDialog::_update_preview(String new_text) {
}
String RenameDialog::_apply_rename(const Node *node, int count) {
-
String search = lne_search->get_text();
String replace = lne_replace->get_text();
String prefix = lne_prefix->get_text();
@@ -428,7 +422,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) {
}
if (cbut_regex->is_pressed()) {
-
new_name = _regex(search, new_name, replace);
} else {
new_name = new_name.replace(search, replace);
@@ -444,7 +437,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) {
}
String RenameDialog::_substitute(const String &subject, const Node *node, int count) {
-
String result = subject.replace("${COUNTER}", vformat("%0" + itos(spn_count_padding->get_value()) + "d", count));
if (node) {
@@ -474,13 +466,13 @@ String RenameDialog::_substitute(const String &subject, const Node *node, int co
}
void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) {
-
RenameDialog *self = (RenameDialog *)p_self;
String source_file(p_file);
// Only show first error that is related to "regex"
- if (self->has_errors || source_file.find("regex") < 0)
+ if (self->has_errors || source_file.find("regex") < 0) {
return;
+ }
String err_str;
if (p_errorexp && p_errorexp[0]) {
@@ -496,14 +488,12 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *
}
String RenameDialog::_regex(const String &pattern, const String &subject, const String &replacement) {
-
RegEx regex(pattern);
return regex.sub(subject, replacement, true);
}
String RenameDialog::_postprocess(const String &subject) {
-
int style_id = opt_style->get_selected();
String result = subject;
@@ -550,12 +540,11 @@ String RenameDialog::_postprocess(const String &subject) {
}
void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int *counter) {
-
- if (!node)
+ if (!node) {
return;
+ }
if (selection.has(node)) {
-
String new_name = _apply_rename(node, *counter);
if (node->get_name() != new_name) {
@@ -581,7 +570,6 @@ void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int
}
void RenameDialog::rename() {
-
// Editor selection is not ordered via scene tree. Instead iterate
// over scene tree until all selected nodes are found in order.
@@ -596,12 +584,10 @@ void RenameDialog::rename() {
_iterate_scene(root_node, selected_node_list, &global_count);
if (undo_redo && !to_rename.empty()) {
-
undo_redo->create_action(TTR("Batch Rename"));
// Make sure to iterate reversed so that child nodes will find parents.
for (int i = to_rename.size() - 1; i >= 0; --i) {
-
Node *n = root_node->get_node(to_rename[i].first);
const String &new_name = to_rename[i].second;
@@ -620,7 +606,6 @@ void RenameDialog::rename() {
}
void RenameDialog::reset() {
-
lock_preview_update = true;
lne_prefix->clear();
@@ -651,7 +636,6 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) {
}
void RenameDialog::_insert_text(String text) {
-
LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner());
if (_is_main_field(focus_owner)) {
diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h
index 194dd57648..dfdb1bcd76 100644
--- a/editor/rename_dialog.h
+++ b/editor/rename_dialog.h
@@ -44,11 +44,10 @@
*/
class RenameDialog : public ConfirmationDialog {
-
GDCLASS(RenameDialog, ConfirmationDialog);
virtual void ok_pressed() { rename(); };
- void _cancel_pressed(){};
+ void _cancel_pressed() {}
void _features_toggled(bool pressed);
void _insert_text(String text);
void _update_substitute();
@@ -111,7 +110,7 @@ public:
void rename();
RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo = nullptr);
- ~RenameDialog(){};
+ ~RenameDialog() {}
};
#endif
diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp
index b71c2bd078..e5ae09f5ff 100644
--- a/editor/reparent_dialog.cpp
+++ b/editor/reparent_dialog.cpp
@@ -35,46 +35,38 @@
#include "scene/gui/label.h"
void ReparentDialog::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
connect("confirmed", callable_mp(this, &ReparentDialog::_reparent));
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
disconnect("confirmed", callable_mp(this, &ReparentDialog::_reparent));
}
}
void ReparentDialog::_cancel() {
-
hide();
}
-void ReparentDialog::_reparent() {
+void ReparentDialog::_reparent() {
if (tree->get_selected()) {
-
emit_signal("reparent", tree->get_selected()->get_path(), keep_transform->is_pressed());
hide();
}
}
void ReparentDialog::set_current(const Set<Node *> &p_selection) {
-
tree->set_marked(p_selection, false, false);
//tree->set_selected(p_node->get_parent());
}
void ReparentDialog::_bind_methods() {
-
ClassDB::bind_method("_cancel", &ReparentDialog::_cancel);
ADD_SIGNAL(MethodInfo("reparent", PropertyInfo(Variant::NODE_PATH, "path"), PropertyInfo(Variant::BOOL, "keep_global_xform")));
}
ReparentDialog::ReparentDialog() {
-
set_title(TTR("Reparent Node"));
VBoxContainer *vbc = memnew(VBoxContainer);
diff --git a/editor/reparent_dialog.h b/editor/reparent_dialog.h
index 29db70baa5..4566e3a02a 100644
--- a/editor/reparent_dialog.h
+++ b/editor/reparent_dialog.h
@@ -41,7 +41,6 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
class ReparentDialog : public ConfirmationDialog {
-
GDCLASS(ReparentDialog, ConfirmationDialog);
SceneTreeEditor *tree;
diff --git a/editor/run_settings_dialog.cpp b/editor/run_settings_dialog.cpp
index a5ae1fd8a6..b6dda4c5bb 100644
--- a/editor/run_settings_dialog.cpp
+++ b/editor/run_settings_dialog.cpp
@@ -31,45 +31,39 @@
#include "run_settings_dialog.h"
void RunSettingsDialog::popup_run_settings() {
-
popup_centered(Size2(300, 150));
}
void RunSettingsDialog::set_custom_arguments(const String &p_arguments) {
-
arguments->set_text(p_arguments);
}
-String RunSettingsDialog::get_custom_arguments() const {
+String RunSettingsDialog::get_custom_arguments() const {
return arguments->get_text();
}
void RunSettingsDialog::_bind_methods() {
-
//ClassDB::bind_method("_browse_selected_file",&RunSettingsDialog::_browse_selected_file);
}
void RunSettingsDialog::_run_mode_changed(int idx) {
-
- if (idx == 0)
+ if (idx == 0) {
arguments->set_editable(false);
- else
+ } else {
arguments->set_editable(true);
+ }
}
int RunSettingsDialog::get_run_mode() const {
-
return run_mode->get_selected();
}
void RunSettingsDialog::set_run_mode(int p_run_mode) {
-
run_mode->select(p_run_mode);
arguments->set_editable(p_run_mode);
}
RunSettingsDialog::RunSettingsDialog() {
-
/* SNAP DIALOG */
VBoxContainer *vbc = memnew(VBoxContainer);
diff --git a/editor/run_settings_dialog.h b/editor/run_settings_dialog.h
index b812bbfa9e..4d6d842de0 100644
--- a/editor/run_settings_dialog.h
+++ b/editor/run_settings_dialog.h
@@ -37,7 +37,6 @@
#include "scene/gui/line_edit.h"
class RunSettingsDialog : public AcceptDialog {
-
GDCLASS(RunSettingsDialog, AcceptDialog);
public:
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 6e00e3c291..5795d85e66 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -50,7 +50,6 @@
#include "servers/rendering_server.h"
void SceneTreeDock::_nodes_drag_begin() {
-
if (restore_script_editor_on_drag) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
restore_script_editor_on_drag = false;
@@ -65,7 +64,6 @@ void SceneTreeDock::_quick_open() {
}
void SceneTreeDock::_input(Ref<InputEvent> p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
@@ -74,12 +72,13 @@ void SceneTreeDock::_input(Ref<InputEvent> p_event) {
}
void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
-
- if (get_focus_owner() && get_focus_owner()->is_text_field())
+ if (get_focus_owner() && get_focus_owner()->is_text_field()) {
return;
+ }
- if (!p_event->is_pressed() || p_event->is_echo())
+ if (!p_event->is_pressed() || p_event->is_echo()) {
return;
+ }
if (ED_IS_SHORTCUT("scene_tree/batch_rename", p_event)) {
_tool_selected(TOOL_BATCH_RENAME);
@@ -119,7 +118,6 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
}
void SceneTreeDock::instance(const String &p_file) {
-
Node *parent = scene_tree->get_selected();
if (!parent) {
@@ -127,7 +125,6 @@ void SceneTreeDock::instance(const String &p_file) {
};
if (!edited_scene) {
-
current_option = -1;
accept->set_text(TTR("No parent to instance a child at."));
accept->popup_centered();
@@ -142,7 +139,6 @@ void SceneTreeDock::instance(const String &p_file) {
}
void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_parent) {
-
Node *parent = p_parent;
if (!parent) {
@@ -150,7 +146,6 @@ void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_paren
}
if (!parent || !edited_scene) {
-
accept->set_text(TTR("No parent to instance the scenes at."));
accept->popup_centered();
return;
@@ -160,7 +155,6 @@ void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_paren
}
void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos) {
-
ERR_FAIL_COND(!parent);
Vector<Node *> instances;
@@ -168,7 +162,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
bool error = false;
for (int i = 0; i < p_files.size(); i++) {
-
Ref<PackedScene> sdata = ResourceLoader::load(p_files[i]);
if (!sdata.is_valid()) {
current_option = -1;
@@ -188,9 +181,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
}
if (edited_scene->get_filename() != "") {
-
if (_cyclical_dependency_exists(edited_scene->get_filename(), instanced_scene)) {
-
accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."), p_files[i]));
accept->popup_centered();
error = true;
@@ -213,7 +204,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)"));
for (int i = 0; i < instances.size(); i++) {
-
Node *instanced_scene = instances[i];
editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
@@ -316,13 +306,16 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
Ref<PackedScene> data = ResourceLoader::load(path);
if (data.is_valid()) {
p = data->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- if (!p)
+ if (!p) {
continue;
+ }
instances.push_back(p);
- } else
+ } else {
break;
- } else
+ }
+ } else {
break;
+ }
}
for (int i = 0; i < instances.size(); i++) {
memdelete(instances[i]);
@@ -331,11 +324,9 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
}
void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
-
current_option = p_tool;
switch (p_tool) {
-
case TOOL_BATCH_RENAME: {
if (!profile_allow_editing) {
break;
@@ -356,7 +347,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_NEW:
case TOOL_REPARENT_TO_NEW_NODE: {
-
if (!profile_allow_editing) {
break;
}
@@ -364,17 +354,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene();
if (current_edited_scene_root) {
-
- if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node2D"))
+ if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node2D")) {
preferred = "Node2D";
- else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node3D"))
+ } else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node3D")) {
preferred = "Node3D";
+ }
}
create_dialog->set_preferred_search_result_type(preferred);
create_dialog->popup_create(true);
} break;
case TOOL_INSTANCE: {
-
if (!profile_allow_editing) {
break;
}
@@ -390,15 +379,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_EXPAND_COLLAPSE: {
-
- if (!scene_tree->get_selected())
+ if (!scene_tree->get_selected()) {
break;
+ }
Tree *tree = scene_tree->get_scene_tree();
TreeItem *selected_item = tree->get_selected();
- if (!selected_item)
+ if (!selected_item) {
selected_item = tree->get_root();
+ }
bool collapsed = _is_collapsed_recursive(selected_item);
_set_collapsed_recursive(selected_item, !collapsed);
@@ -407,17 +397,18 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_REPLACE: {
-
if (!profile_allow_editing) {
break;
}
Node *selected = scene_tree->get_selected();
- if (!selected && !editor_selection->get_selected_node_list().empty())
+ if (!selected && !editor_selection->get_selected_node_list().empty()) {
selected = editor_selection->get_selected_node_list().front()->get();
+ }
- if (selected)
+ if (selected) {
create_dialog->popup_create(false, true, selected->get_class());
+ }
} break;
case TOOL_EXTEND_SCRIPT: {
@@ -427,21 +418,20 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
attach_script_to_selected(false);
} break;
case TOOL_DETACH_SCRIPT: {
-
if (!profile_allow_script_editing) {
break;
}
Array selection = editor_selection->get_selected_nodes();
- if (selection.empty())
+ if (selection.empty()) {
return;
+ }
editor_data->get_undo_redo().create_action(TTR("Detach Script"));
editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)nullptr);
for (int i = 0; i < selection.size(); i++) {
-
Node *n = Object::cast_to<Node>(selection[i]);
Ref<Script> existing = n->get_script();
Ref<Script> empty = EditorNode::get_singleton()->get_object_custom_type_base(n);
@@ -458,24 +448,24 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_MOVE_UP:
case TOOL_MOVE_DOWN: {
-
if (!profile_allow_editing) {
break;
}
- if (!scene_tree->get_selected())
+ if (!scene_tree->get_selected()) {
break;
+ }
if (scene_tree->get_selected() == edited_scene) {
-
current_option = -1;
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered();
break;
}
- if (!_validate_no_foreign())
+ if (!_validate_no_foreign()) {
break;
+ }
bool MOVING_DOWN = (p_tool == TOOL_MOVE_DOWN);
bool MOVING_UP = !MOVING_DOWN;
@@ -483,30 +473,37 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *common_parent = scene_tree->get_selected()->get_parent();
List<Node *> selection = editor_selection->get_selected_node_list();
selection.sort_custom<Node::Comparator>(); // sort by index
- if (MOVING_DOWN)
+ if (MOVING_DOWN) {
selection.invert();
+ }
int lowest_id = common_parent->get_child_count() - 1;
int highest_id = 0;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
int index = E->get()->get_index();
- if (index > highest_id)
+ if (index > highest_id) {
highest_id = index;
- if (index < lowest_id)
+ }
+ if (index < lowest_id) {
lowest_id = index;
+ }
- if (E->get()->get_parent() != common_parent)
+ if (E->get()->get_parent() != common_parent) {
common_parent = nullptr;
+ }
}
- if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0))
+ if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0)) {
break; // one or more nodes can not be moved
+ }
- if (selection.size() == 1)
+ if (selection.size() == 1) {
editor_data->get_undo_redo().create_action(TTR("Move Node In Parent"));
- if (selection.size() > 1)
+ }
+ if (selection.size() > 1) {
editor_data->get_undo_redo().create_action(TTR("Move Nodes In Parent"));
+ }
for (int i = 0; i < selection.size(); i++) {
Node *top_node = selection[i];
@@ -526,28 +523,29 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_DUPLICATE: {
-
if (!profile_allow_editing) {
break;
}
- if (!edited_scene)
+ if (!edited_scene) {
break;
+ }
if (editor_selection->is_selected(edited_scene)) {
-
current_option = -1;
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered();
break;
}
- if (!_validate_no_foreign())
+ if (!_validate_no_foreign()) {
break;
+ }
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.size() == 0)
+ if (selection.size() == 0) {
break;
+ }
editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)"));
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
@@ -560,7 +558,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *add_below_node = selection.back()->get();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
Node *node = E->get();
Node *parent = node->get_parent();
@@ -570,21 +567,22 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Map<const Node *, Node *> duplimap;
Node *dup = node->duplicate_from_editor(duplimap);
- if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node))
+ if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node)) {
editable_children.push_back(dup);
+ }
ERR_CONTINUE(!dup);
- if (selection.size() == 1)
+ if (selection.size() == 1) {
dupsingle = dup;
+ }
dup->set_name(parent->validate_child_name(dup));
- editor_data->get_undo_redo().add_do_method(parent, "add_child_below_node", add_below_node, dup);
- for (List<Node *>::Element *F = owned.front(); F; F = F->next()) {
+ editor_data->get_undo_redo().add_do_method(add_below_node, "add_sibling", dup);
+ for (List<Node *>::Element *F = owned.front(); F; F = F->next()) {
if (!duplimap.has(F->get())) {
-
continue;
}
Node *d = duplimap[F->get()];
@@ -604,37 +602,38 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().commit_action();
- if (dupsingle)
+ if (dupsingle) {
editor->push_item(dupsingle);
+ }
- for (List<Node *>::Element *E = editable_children.back(); E; E = E->prev())
+ for (List<Node *>::Element *E = editable_children.back(); E; E = E->prev()) {
_toggle_editable_children(E->get());
+ }
} break;
case TOOL_REPARENT: {
-
if (!profile_allow_editing) {
break;
}
- if (!scene_tree->get_selected())
+ if (!scene_tree->get_selected()) {
break;
+ }
if (editor_selection->is_selected(edited_scene)) {
-
current_option = -1;
accept->set_text(TTR("This operation can't be done on the tree root."));
accept->popup_centered();
break;
}
- if (!_validate_no_foreign())
+ if (!_validate_no_foreign()) {
break;
+ }
List<Node *> nodes = editor_selection->get_selected_node_list();
Set<Node *> nodeset;
for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) {
-
nodeset.insert(E->get());
}
reparent_dialog->popup_centered_ratio();
@@ -642,7 +641,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_MAKE_ROOT: {
-
if (!profile_allow_editing) {
break;
}
@@ -653,8 +651,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *node = nodes.front()->get();
Node *root = get_tree()->get_edited_scene_root();
- if (node == root)
+ if (node == root) {
return;
+ }
//check that from node to root, all owners are right
@@ -701,14 +700,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().commit_action();
} break;
case TOOL_MULTI_EDIT: {
-
if (!profile_allow_editing) {
break;
}
Node *root = EditorNode::get_singleton()->get_edited_scene();
- if (!root)
+ if (!root) {
break;
+ }
Ref<MultiNodeEdit> mne = memnew(MultiNodeEdit);
for (const Map<Node *, Object *>::Element *E = EditorNode::get_singleton()->get_editor_selection()->get_selection().front(); E; E = E->next()) {
mne->add_node(root->get_path_to(E->key()));
@@ -719,18 +718,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_ERASE: {
-
if (!profile_allow_editing) {
break;
}
List<Node *> remove_list = editor_selection->get_selected_node_list();
- if (remove_list.empty())
+ if (remove_list.empty()) {
return;
+ }
- if (!_validate_no_foreign())
+ if (!_validate_no_foreign()) {
break;
+ }
if (p_confirm_override) {
_delete_confirm();
@@ -756,7 +756,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_MERGE_FROM_SCENE: {
-
if (!profile_allow_editing) {
break;
}
@@ -764,7 +763,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
EditorNode::get_singleton()->merge_from_scene();
} break;
case TOOL_NEW_SCENE_FROM: {
-
if (!profile_allow_editing) {
break;
}
@@ -820,7 +818,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
new_scene_from_dialog->set_title(TTR("Save New Scene As..."));
} break;
case TOOL_COPY_NODE_PATH: {
-
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@@ -840,7 +837,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
} break;
case TOOL_SCENE_EDITABLE_CHILDREN: {
-
if (!profile_allow_editing) {
break;
}
@@ -862,7 +858,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_USE_PLACEHOLDER: {
-
if (!profile_allow_editing) {
break;
}
@@ -884,8 +879,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
placeholder = !placeholder;
- if (placeholder)
+ if (placeholder) {
EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false);
+ }
node->set_scene_instance_load_placeholder(placeholder);
scene_tree->update_tree();
@@ -893,7 +889,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_MAKE_LOCAL: {
-
if (!profile_allow_editing) {
break;
}
@@ -905,8 +900,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (node) {
Node *root = EditorNode::get_singleton()->get_edited_scene();
UndoRedo *undo_redo = &editor_data->get_undo_redo();
- if (!root)
+ if (!root) {
break;
+ }
ERR_FAIL_COND(node->get_filename() == String());
undo_redo->create_action(TTR("Make Local"));
@@ -920,7 +916,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_OPEN: {
-
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@@ -954,7 +949,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_OPEN_INHERITED: {
-
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@@ -968,7 +962,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
case TOOL_CREATE_3D_SCENE:
case TOOL_CREATE_USER_INTERFACE:
case TOOL_CREATE_FAVORITE: {
-
Node *new_node = nullptr;
if (TOOL_CREATE_FAVORITE == p_tool) {
@@ -1019,9 +1012,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
default: {
-
if (p_tool >= EDIT_SUBRESOURCE_BASE) {
-
int idx = p_tool - EDIT_SUBRESOURCE_BASE;
ERR_FAIL_INDEX(idx, subresources.size());
@@ -1036,10 +1027,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
void SceneTreeDock::_node_collapsed(Object *p_obj) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
- if (!ti)
+ if (!ti) {
return;
+ }
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
_set_collapsed_recursive(ti, ti->is_collapsed());
@@ -1047,12 +1038,11 @@ void SceneTreeDock::_node_collapsed(Object *p_obj) {
}
void SceneTreeDock::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY: {
-
- if (!first_enter)
+ if (!first_enter) {
break;
+ }
first_enter = false;
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &SceneTreeDock::_feature_profile_changed));
@@ -1154,7 +1144,6 @@ void SceneTreeDock::_notification(int p_what) {
filter->set_clear_button_enabled(true);
} break;
case NOTIFICATION_PROCESS: {
-
bool show_create_root = bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) && get_tree()->get_edited_scene_root() == nullptr;
if (show_create_root != create_root_dialog->is_visible_in_tree() && !remote_tree->is_visible()) {
@@ -1172,7 +1161,6 @@ void SceneTreeDock::_notification(int p_what) {
}
void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root, ReplaceOwnerMode p_mode) {
-
if (p_node->get_owner() == p_base && p_node != p_root) {
UndoRedo *undo_redo = &editor_data->get_undo_redo();
switch (p_mode) {
@@ -1198,21 +1186,17 @@ void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root
}
void SceneTreeDock::_load_request(const String &p_path) {
-
editor->open_request(p_path);
}
void SceneTreeDock::_script_open_request(const Ref<Script> &p_script) {
-
editor->edit_resource(p_script);
}
void SceneTreeDock::_node_selected() {
-
Node *node = scene_tree->get_selected();
if (!node) {
-
editor->push_item(nullptr);
return;
}
@@ -1225,31 +1209,30 @@ void SceneTreeDock::_node_selected() {
}
void SceneTreeDock::_node_renamed() {
-
_node_selected();
}
void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) {
-
for (int i = 0; i < p_nodes.size(); i++) {
-
Node *n = Object::cast_to<Node>(p_nodes[i]);
- if (!n)
+ if (!n) {
continue;
+ }
n->set_owner(p_owner);
}
}
void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames) {
-
base_path.push_back(p_node->get_name());
- if (new_base_path.size())
+ if (new_base_path.size()) {
new_base_path.push_back(p_node->get_name());
+ }
NodePath from(base_path, true);
NodePath to;
- if (new_base_path.size())
+ if (new_base_path.size()) {
to = NodePath(new_base_path, true);
+ }
Pair<NodePath, NodePath> npp;
npp.first = from;
@@ -1258,15 +1241,14 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri
p_renames->push_back(npp);
for (int i = 0; i < p_node->get_child_count(); i++) {
-
_fill_path_renames(base_path, new_base_path, p_node->get_child(i), p_renames);
}
}
void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames) {
-
- if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true)))
+ if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true))) {
return;
+ }
Vector<StringName> base_path;
Node *n = p_node->get_parent();
@@ -1291,39 +1273,34 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai
}
void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) {
-
Map<Ref<Animation>, Set<int>> rem_anims;
- if (!r_rem_anims)
+ if (!r_rem_anims) {
r_rem_anims = &rem_anims;
+ }
if (!p_base) {
-
p_base = edited_scene;
}
- if (!p_base)
+ if (!p_base) {
return;
+ }
// Renaming node paths used in script instances
if (p_base->get_script_instance()) {
-
ScriptInstance *si = p_base->get_script_instance();
if (si) {
-
List<PropertyInfo> properties;
si->get_property_list(&properties);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
-
String propertyname = E->get().name;
Variant p = p_base->get(propertyname);
if (p.get_type() == Variant::NODE_PATH) {
-
// Goes through all paths to check if its matching
for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) {
-
NodePath root_path = p_base->get_path();
NodePath rel_path_old = root_path.rel_path_to(F->get().first);
@@ -1337,7 +1314,6 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
// if old path detected, then it needs to be replaced with the new one
if (p == rel_path_old) {
-
editor_data->get_undo_redo().add_do_property(p_base, propertyname, rel_path_new);
editor_data->get_undo_redo().add_undo_property(p_base, propertyname, rel_path_old);
@@ -1353,19 +1329,16 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
bool autorename_animation_tracks = bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true));
if (autorename_animation_tracks && Object::cast_to<AnimationPlayer>(p_base)) {
-
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_base);
List<StringName> anims;
ap->get_animation_list(&anims);
Node *root = ap->get_node(ap->get_root());
if (root) {
-
NodePath root_path = root->get_path();
NodePath new_root_path = root_path;
for (List<Pair<NodePath, NodePath>>::Element *E = p_renames->front(); E; E = E->next()) {
-
if (E->get().first == root_path) {
new_root_path = E->get().second;
break;
@@ -1376,22 +1349,22 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
//will not be erased
for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
-
Ref<Animation> anim = ap->get_animation(E->get());
if (!r_rem_anims->has(anim)) {
r_rem_anims->insert(anim, Set<int>());
Set<int> &ran = r_rem_anims->find(anim)->get();
- for (int i = 0; i < anim->get_track_count(); i++)
+ for (int i = 0; i < anim->get_track_count(); i++) {
ran.insert(i);
+ }
}
Set<int> &ran = r_rem_anims->find(anim)->get();
- if (anim.is_null())
+ if (anim.is_null()) {
continue;
+ }
for (int i = 0; i < anim->get_track_count(); i++) {
-
NodePath track_np = anim->track_get_path(i);
Node *n = root->get_node(track_np);
if (!n) {
@@ -1400,13 +1373,12 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
NodePath old_np = n->get_path();
- if (!ran.has(i))
+ if (!ran.has(i)) {
continue; //channel was removed
+ }
for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) {
-
if (F->get().first == old_np) {
-
if (F->get().second == NodePath()) {
//will be erased
@@ -1424,7 +1396,6 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np);
editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i));
for (int j = 0; j < anim->track_get_key_count(i); j++) {
-
editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j));
}
@@ -1435,8 +1406,9 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
NodePath rel_path = new_root_path.rel_path_to(F->get().second);
NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false);
- if (new_path == track_np)
+ if (new_path == track_np) {
continue; //bleh
+ }
editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path);
editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", i, track_np);
}
@@ -1448,12 +1420,12 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
}
}
- for (int i = 0; i < p_base->get_child_count(); i++)
+ for (int i = 0; i < p_base->get_child_count(); i++) {
perform_node_renames(p_base->get_child(i), p_renames, r_rem_anims);
+ }
}
void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
-
List<Pair<NodePath, NodePath>> path_renames;
Vector<StringName> base_path;
@@ -1474,20 +1446,18 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
npp.second = NodePath(new_base_path, true);
path_renames.push_back(npp);
- for (int i = 0; i < p_node->get_child_count(); i++)
+ for (int i = 0; i < p_node->get_child_count(); i++) {
_fill_path_renames(base_path, new_base_path, p_node->get_child(i), &path_renames);
+ }
perform_node_renames(nullptr, &path_renames);
}
bool SceneTreeDock::_validate_no_foreign() {
-
List<Node *> selection = editor_selection->get_selected_node_list();
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
-
if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) {
-
accept->set_text(TTR("Can't operate on nodes from a foreign scene!"));
accept->popup_centered();
return false;
@@ -1501,7 +1471,6 @@ bool SceneTreeDock::_validate_no_foreign() {
}
if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) {
-
accept->set_text(TTR("Can't operate on nodes the current scene inherits from!"));
accept->popup_centered();
return false;
@@ -1512,14 +1481,14 @@ bool SceneTreeDock::_validate_no_foreign() {
}
void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
-
Node *new_parent = scene_root->get_node(p_path);
ERR_FAIL_COND(!new_parent);
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.empty())
+ if (selection.empty()) {
return; // Nothing to reparent.
+ }
Vector<Node *> nodes;
@@ -1531,31 +1500,32 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
}
void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform) {
-
Node *new_parent = p_new_parent;
ERR_FAIL_COND(!new_parent);
- if (p_nodes.size() == 0)
+ if (p_nodes.size() == 0) {
return; // Nothing to reparent.
+ }
p_nodes.sort_custom<Node::Comparator>(); //Makes result reliable.
bool no_change = true;
for (int ni = 0; ni < p_nodes.size(); ni++) {
-
- if (p_nodes[ni] == p_new_parent)
+ if (p_nodes[ni] == p_new_parent) {
return; // Attempt to reparent to itself.
+ }
- if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_index())
+ if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_index()) {
no_change = false;
+ }
}
- if (no_change)
+ if (no_change) {
return; // Position and parent didn't change.
+ }
Node *validate = new_parent;
while (validate) {
-
ERR_FAIL_COND_MSG(p_nodes.find(validate) != -1, "Selection changed at some point. Can't reparent.");
validate = validate->get_parent();
}
@@ -1571,7 +1541,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
int inc = 0;
for (int ni = 0; ni < p_nodes.size(); ni++) {
-
// No undo implemented for this yet.
Node *node = p_nodes[ni];
@@ -1585,14 +1554,16 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
owners.push_back(E->get());
}
- if (new_parent == node->get_parent() && node->get_index() < p_position_in_parent + ni)
+ if (new_parent == node->get_parent() && node->get_index() < p_position_in_parent + ni) {
inc--; // If the child will generate a gap when moved, adjust.
+ }
editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
editor_data->get_undo_redo().add_do_method(new_parent, "add_child", node);
- if (p_position_in_parent >= 0)
+ if (p_position_in_parent >= 0) {
editor_data->get_undo_redo().add_do_method(new_parent, "move_child", node, p_position_in_parent + inc);
+ }
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
String old_name = former_names[ni];
@@ -1600,7 +1571,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
// Name was modified, fix the path renames.
if (old_name.casecmp_to(new_name) != 0) {
-
// Fix the to name to have the new name.
NodePath old_new_name = path_renames[ni].second;
NodePath new_path;
@@ -1623,18 +1593,22 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).plus_file(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index());
if (p_keep_global_xform) {
- if (Object::cast_to<Node2D>(node))
+ if (Object::cast_to<Node2D>(node)) {
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node2D>(node)->get_global_transform());
- if (Object::cast_to<Node3D>(node))
+ }
+ if (Object::cast_to<Node3D>(node)) {
editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node3D>(node)->get_global_transform());
- if (Object::cast_to<Control>(node))
+ }
+ if (Object::cast_to<Control>(node)) {
editor_data->get_undo_redo().add_do_method(node, "set_global_position", Object::cast_to<Control>(node)->get_global_position());
+ }
}
editor_data->get_undo_redo().add_do_method(this, "_set_owners", edited_scene, owners);
- if (AnimationPlayerEditor::singleton->get_track_editor()->get_root() == node)
+ if (AnimationPlayerEditor::singleton->get_track_editor()->get_root() == node) {
editor_data->get_undo_redo().add_do_method(AnimationPlayerEditor::singleton->get_track_editor(), "set_root", node);
+ }
editor_data->get_undo_redo().add_undo_method(new_parent, "remove_child", node);
editor_data->get_undo_redo().add_undo_method(node, "set_name", former_names[ni]);
@@ -1644,14 +1618,12 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
// Add and move in a second step (so old order is preserved).
for (int ni = 0; ni < p_nodes.size(); ni++) {
-
Node *node = p_nodes[ni];
List<Node *> owned;
node->get_owned_by(node->get_owner(), &owned);
Array owners;
for (List<Node *>::Element *E = owned.front(); E; E = E->next()) {
-
owners.push_back(E->get());
}
@@ -1660,16 +1632,20 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, child_pos);
editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
- if (AnimationPlayerEditor::singleton->get_track_editor()->get_root() == node)
+ if (AnimationPlayerEditor::singleton->get_track_editor()->get_root() == node) {
editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_track_editor(), "set_root", node);
+ }
if (p_keep_global_xform) {
- if (Object::cast_to<Node2D>(node))
+ if (Object::cast_to<Node2D>(node)) {
editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node2D>(node)->get_transform());
- if (Object::cast_to<Node3D>(node))
+ }
+ if (Object::cast_to<Node3D>(node)) {
editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node3D>(node)->get_transform());
- if (Object::cast_to<Control>(node))
+ }
+ if (Object::cast_to<Control>(node)) {
editor_data->get_undo_redo().add_undo_method(node, "set_position", Object::cast_to<Control>(node)->get_position());
+ }
}
}
@@ -1679,14 +1655,12 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
}
bool SceneTreeDock::_is_collapsed_recursive(TreeItem *p_item) const {
-
bool is_branch_collapsed = false;
List<TreeItem *> needs_check;
needs_check.push_back(p_item);
while (!needs_check.empty()) {
-
TreeItem *item = needs_check.back()->get();
needs_check.pop_back();
@@ -1705,12 +1679,10 @@ bool SceneTreeDock::_is_collapsed_recursive(TreeItem *p_item) const {
}
void SceneTreeDock::_set_collapsed_recursive(TreeItem *p_item, bool p_collapsed) {
-
List<TreeItem *> to_collapse;
to_collapse.push_back(p_item);
while (!to_collapse.empty()) {
-
TreeItem *item = to_collapse.back()->get();
to_collapse.pop_back();
@@ -1725,15 +1697,14 @@ void SceneTreeDock::_set_collapsed_recursive(TreeItem *p_item, bool p_collapsed)
}
void SceneTreeDock::_script_created(Ref<Script> p_script) {
-
List<Node *> selected = editor_selection->get_selected_node_list();
- if (selected.empty())
+ if (selected.empty()) {
return;
+ }
editor_data->get_undo_redo().create_action(TTR("Attach Script"));
for (List<Node *>::Element *E = selected.front(); E; E = E->next()) {
-
Ref<Script> existing = E->get()->get_script();
editor_data->get_undo_redo().add_do_method(E->get(), "set_script", p_script);
editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing);
@@ -1752,7 +1723,6 @@ void SceneTreeDock::_script_creation_closed() {
}
void SceneTreeDock::_toggle_editable_children_from_selection() {
-
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
@@ -1762,7 +1732,6 @@ void SceneTreeDock::_toggle_editable_children_from_selection() {
}
void SceneTreeDock::_toggle_placeholder_from_selection() {
-
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
@@ -1781,12 +1750,12 @@ void SceneTreeDock::_toggle_placeholder_from_selection() {
}
void SceneTreeDock::_toggle_editable_children(Node *p_node) {
-
if (p_node) {
bool editable = !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node);
EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(p_node, editable);
- if (editable)
+ if (editable) {
p_node->set_scene_instance_load_placeholder(false);
+ }
Node3DEditor::get_singleton()->update_all_gizmos(p_node);
@@ -1795,11 +1764,11 @@ void SceneTreeDock::_toggle_editable_children(Node *p_node) {
}
void SceneTreeDock::_delete_confirm() {
-
List<Node *> remove_list = editor_selection->get_selected_node_list();
- if (remove_list.empty())
+ if (remove_list.empty()) {
return;
+ }
editor->get_editor_plugins_over()->make_visible(false);
@@ -1808,14 +1777,12 @@ void SceneTreeDock::_delete_confirm() {
bool entire_scene = false;
for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) {
-
if (E->get() == edited_scene) {
entire_scene = true;
}
}
if (entire_scene) {
-
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)nullptr);
editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", edited_scene);
editor_data->get_undo_redo().add_undo_method(edited_scene, "set_owner", edited_scene->get_owner());
@@ -1823,15 +1790,15 @@ void SceneTreeDock::_delete_confirm() {
editor_data->get_undo_redo().add_undo_reference(edited_scene);
} else {
-
remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions
List<Pair<NodePath, NodePath>> path_renames;
//delete from animation
for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) {
Node *n = E->get();
- if (!n->is_inside_tree() || !n->get_parent())
+ if (!n->is_inside_tree() || !n->get_parent()) {
continue;
+ }
fill_path_renames(n, nullptr, &path_renames);
}
@@ -1840,22 +1807,23 @@ void SceneTreeDock::_delete_confirm() {
//delete for read
for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) {
Node *n = E->get();
- if (!n->is_inside_tree() || !n->get_parent())
+ if (!n->is_inside_tree() || !n->get_parent()) {
continue;
+ }
List<Node *> owned;
n->get_owned_by(n->get_owner(), &owned);
Array owners;
for (List<Node *>::Element *F = owned.front(); F; F = F->next()) {
-
owners.push_back(F->get());
}
editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n);
editor_data->get_undo_redo().add_undo_method(n->get_parent(), "add_child", n);
editor_data->get_undo_redo().add_undo_method(n->get_parent(), "move_child", n, n->get_index());
- if (AnimationPlayerEditor::singleton->get_track_editor()->get_root() == n)
+ if (AnimationPlayerEditor::singleton->get_track_editor()->get_root() == n) {
editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_track_editor(), "set_root", n);
+ }
editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
editor_data->get_undo_redo().add_undo_reference(n);
@@ -1867,8 +1835,9 @@ void SceneTreeDock::_delete_confirm() {
editor_data->get_undo_redo().commit_action();
// hack, force 2d editor viewport to refresh after deletion
- if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton())
+ if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) {
editor->get_viewport_control()->update();
+ }
editor->push_item(nullptr);
@@ -1879,9 +1848,7 @@ void SceneTreeDock::_delete_confirm() {
}
void SceneTreeDock::_update_script_button() {
-
if (!profile_allow_script_editing) {
-
button_create_script->hide();
button_detach_script->hide();
} else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 0) {
@@ -1911,7 +1878,6 @@ void SceneTreeDock::_update_script_button() {
}
void SceneTreeDock::_selection_changed() {
-
int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
if (selection_size > 1) {
//automatically turn on multi-edit
@@ -1925,17 +1891,17 @@ void SceneTreeDock::_selection_changed() {
}
Node *SceneTreeDock::_get_selection_group_tail(Node *p_node, List<Node *> p_list) {
-
Node *tail = p_node;
Node *parent = tail->get_parent();
for (int i = p_node->get_index(); i < parent->get_child_count(); i++) {
Node *sibling = parent->get_child(i);
- if (p_list.find(sibling))
+ if (p_list.find(sibling)) {
tail = sibling;
- else
+ } else {
break;
+ }
}
return tail;
@@ -1951,7 +1917,6 @@ void SceneTreeDock::_do_create(Node *p_parent) {
editor_data->get_undo_redo().create_action(TTR("Create Node"));
if (edited_scene) {
-
editor_data->get_undo_redo().add_do_method(p_parent, "add_child", child);
editor_data->get_undo_redo().add_do_method(child, "set_owner", edited_scene);
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
@@ -1965,7 +1930,6 @@ void SceneTreeDock::_do_create(Node *p_parent) {
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).plus_file(new_name)));
} else {
-
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child);
editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree");
editor_data->get_undo_redo().add_do_reference(child);
@@ -1981,25 +1945,26 @@ void SceneTreeDock::_do_create(Node *p_parent) {
Control *ct = Object::cast_to<Control>(c);
Size2 ms = ct->get_minimum_size();
- if (ms.width < 4)
+ if (ms.width < 4) {
ms.width = 40;
- if (ms.height < 4)
+ }
+ if (ms.height < 4) {
ms.height = 40;
+ }
ct->set_size(ms);
}
}
void SceneTreeDock::_create() {
-
if (current_option == TOOL_NEW) {
-
Node *parent = nullptr;
if (edited_scene) {
// If root exists in edited scene
parent = scene_tree->get_selected();
- if (!parent)
+ if (!parent) {
parent = edited_scene;
+ }
} else {
// If no root exist in edited scene
@@ -2057,17 +2022,19 @@ void SceneTreeDock::_create() {
smaller_path_to_top = path_length;
only_one_top_node = true;
} else if (smaller_path_to_top == path_length) {
- if (only_one_top_node && top_node->get_parent() != n->get_parent())
+ if (only_one_top_node && top_node->get_parent() != n->get_parent()) {
only_one_top_node = false;
+ }
}
}
}
Node *parent = nullptr;
- if (only_one_top_node)
+ if (only_one_top_node) {
parent = top_node->get_parent();
- else
+ } else {
parent = top_node->get_parent()->get_parent();
+ }
_do_create(parent);
@@ -2085,7 +2052,6 @@ void SceneTreeDock::_create() {
}
void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties, bool p_remove_old) {
-
Node *n = p_node;
Node *newnode = p_by_node;
@@ -2095,10 +2061,24 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
n->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
- if (E->get().name == "__meta__")
+ }
+
+ if (E->get().name == "__meta__") {
+ if (Object::cast_to<CanvasItem>(newnode)) {
+ Dictionary metadata = n->get(E->get().name);
+ if (metadata.has("_edit_group_") && metadata["_edit_group_"]) {
+ newnode->set_meta("_edit_group_", true);
+ }
+ if (metadata.has("_edit_lock_") && metadata["_edit_lock_"]) {
+ newnode->set_meta("_edit_lock_", true);
+ }
+ }
+
continue;
+ }
+
if (default_oldnode->get(E->get().name) != n->get(E->get().name)) {
newnode->set(E->get().name, n->get(E->get().name));
}
@@ -2114,15 +2094,14 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
n->get_signal_list(&sl);
for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) {
-
List<Object::Connection> cl;
n->get_signal_connection_list(E->get().name, &cl);
for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) {
-
Object::Connection &c = F->get();
- if (!(c.flags & Object::CONNECT_PERSIST))
+ if (!(c.flags & Object::CONNECT_PERSIST)) {
continue;
+ }
newnode->connect(c.signal.get_name(), c.callable, c.binds, Object::CONNECT_PERSIST);
}
}
@@ -2149,8 +2128,9 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
c->call("set_transform", c->call("get_transform"));
}
//p_remove_old was added to support undo
- if (p_remove_old)
+ if (p_remove_old) {
editor_data->get_undo_redo().clear_history();
+ }
newnode->set_name(newname);
editor->push_item(newnode);
@@ -2166,22 +2146,18 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
}
void SceneTreeDock::set_edited_scene(Node *p_scene) {
-
edited_scene = p_scene;
}
void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) {
-
scene_tree->set_selected(p_node, p_emit_selected);
}
void SceneTreeDock::import_subscene() {
-
import_subscene_dialog->popup_centered_clamped(Size2(500, 800) * EDSCALE, 0.8);
}
void SceneTreeDock::_import_subscene() {
-
Node *parent = scene_tree->get_selected();
if (!parent) {
parent = editor_data->get_edited_scene_root();
@@ -2193,7 +2169,6 @@ void SceneTreeDock::_import_subscene() {
}
void SceneTreeDock::_new_scene_from(String p_file) {
-
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.size() != 1) {
@@ -2214,7 +2189,6 @@ void SceneTreeDock::_new_scene_from(String p_file) {
reown[editor_data->get_edited_scene_root()] = base;
Node *copy = base->duplicate_and_reown(reown);
if (copy) {
-
Ref<PackedScene> sdata = memnew(PackedScene);
Error err = sdata->pack(copy);
memdelete(copy);
@@ -2226,8 +2200,9 @@ void SceneTreeDock::_new_scene_from(String p_file) {
}
int flg = 0;
- if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
flg |= ResourceSaver::FLAG_COMPRESS;
+ }
err = ResourceSaver::save(p_file, sdata, flg);
if (err != OK) {
@@ -2244,26 +2219,27 @@ void SceneTreeDock::_new_scene_from(String p_file) {
}
static bool _is_node_visible(Node *p_node) {
-
- if (!p_node->get_owner())
+ if (!p_node->get_owner()) {
return false;
- if (p_node->get_owner() != EditorNode::get_singleton()->get_edited_scene() && !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node->get_owner()))
+ }
+ if (p_node->get_owner() != EditorNode::get_singleton()->get_edited_scene() && !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node->get_owner())) {
return false;
+ }
return true;
}
static bool _has_visible_children(Node *p_node) {
-
bool collapsed = p_node->is_displayed_folded();
- if (collapsed)
+ if (collapsed) {
return false;
+ }
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *child = p_node->get_child(i);
- if (!_is_node_visible(child))
+ if (!_is_node_visible(child)) {
continue;
+ }
return true;
}
@@ -2272,7 +2248,6 @@ static bool _has_visible_children(Node *p_node) {
}
void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
-
to_pos = -1;
if (p_type == -1) {
@@ -2315,7 +2290,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
}
void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_type) {
-
Node *node = get_node(p_to);
ERR_FAIL_COND(!node);
@@ -2339,15 +2313,16 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) {
}
void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) {
-
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.empty())
+ if (selection.empty()) {
return; //nothing to reparent
+ }
Node *to_node = get_node(p_to);
- if (!to_node)
+ if (!to_node) {
return;
+ }
Vector<Node *> nodes;
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
@@ -2361,25 +2336,28 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) {
}
void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
-
- if (p_depth > 8)
+ if (p_depth > 8) {
return;
+ }
List<PropertyInfo> pinfo;
p_obj->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) {
continue;
- if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE)
+ }
+ if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) {
continue;
+ }
Variant value = p_obj->get(E->get().name);
- if (value.get_type() != Variant::OBJECT)
+ if (value.get_type() != Variant::OBJECT) {
continue;
+ }
Object *obj = value;
- if (!obj)
+ if (!obj) {
continue;
+ }
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
@@ -2396,9 +2374,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
}
void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
-
if (!EditorNode::get_singleton()->get_edited_scene()) {
-
menu->clear();
if (profile_allow_editing) {
menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
@@ -2414,15 +2390,15 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *> full_selection = editor_selection->get_full_selected_node_list(); // Above method only returns nodes with common parent.
- if (selection.size() == 0)
+ if (selection.size() == 0) {
return;
+ }
menu->clear();
Ref<Script> existing_script;
bool existing_script_removable = true;
if (selection.size() == 1) {
-
Node *selected = selection[0];
if (profile_allow_editing) {
@@ -2430,8 +2406,9 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu_subresources->clear();
menu_subresources->set_size(Size2(1, 1));
_add_children_to_popup(selection.front()->get(), 0);
- if (menu->get_item_count() > 0)
+ if (menu->get_item_count() > 0) {
menu->add_separator();
+ }
menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
@@ -2498,7 +2475,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
}
if (selection.size() == 1) {
-
if (profile_allow_editing) {
menu->add_separator();
menu->add_icon_shortcut(get_theme_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
@@ -2555,23 +2531,19 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
void SceneTreeDock::_filter_changed(const String &p_filter) {
-
scene_tree->set_filter(p_filter);
}
String SceneTreeDock::get_filter() {
-
return filter->get_text();
}
void SceneTreeDock::set_filter(const String &p_filter) {
-
filter->set_text(p_filter);
scene_tree->set_filter(p_filter);
}
void SceneTreeDock::_focus_node() {
-
Node *node = scene_tree->get_selected();
ERR_FAIL_COND(!node);
@@ -2585,17 +2557,24 @@ void SceneTreeDock::_focus_node() {
}
void SceneTreeDock::attach_script_to_selected(bool p_extend) {
+ if (ScriptServer::get_language_count() == 0) {
+ EditorNode::get_singleton()->show_warning(TTR("Cannot attach a script: there are no languages registered.\nThis is probably because this editor was built with all language modules disabled."));
+ return;
+ }
+
if (!profile_allow_script_editing) {
return;
}
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.empty())
+ if (selection.empty()) {
return;
+ }
Node *selected = scene_tree->get_selected();
- if (!selected)
+ if (!selected) {
selected = selection.front()->get();
+ }
Ref<Script> existing = selected->get_script();
@@ -2634,7 +2613,6 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) {
}
void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) {
-
scene_tree->set_selected(p_for_node, false);
if (p_extend) {
@@ -2652,31 +2630,27 @@ void SceneTreeDock::add_remote_tree_editor(Control *p_remote) {
}
void SceneTreeDock::show_remote_tree() {
-
_remote_tree_selected();
}
void SceneTreeDock::hide_remote_tree() {
-
_local_tree_selected();
}
void SceneTreeDock::show_tab_buttons() {
-
button_hb->show();
}
void SceneTreeDock::hide_tab_buttons() {
-
button_hb->hide();
}
void SceneTreeDock::_remote_tree_selected() {
-
scene_tree->hide();
create_root_dialog->hide();
- if (remote_tree)
+ if (remote_tree) {
remote_tree->show();
+ }
edit_remote->set_pressed(true);
edit_local->set_pressed(false);
@@ -2684,32 +2658,34 @@ void SceneTreeDock::_remote_tree_selected() {
}
void SceneTreeDock::_local_tree_selected() {
-
- scene_tree->show();
- if (remote_tree)
+ if (!bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) || get_tree()->get_edited_scene_root() != nullptr) {
+ scene_tree->show();
+ }
+ if (remote_tree) {
remote_tree->hide();
+ }
edit_remote->set_pressed(false);
edit_local->set_pressed(true);
}
void SceneTreeDock::_update_create_root_dialog() {
-
BaseButton *toggle = Object::cast_to<BaseButton>(create_root_dialog->get_node(String("NodeShortcutsTopRow/NodeShortcutsToggle")));
Node *node_shortcuts = create_root_dialog->get_node(String("NodeShortcuts"));
- if (!toggle || !node_shortcuts)
+ if (!toggle || !node_shortcuts) {
return;
+ }
Control *beginner_nodes = Object::cast_to<Control>(node_shortcuts->get_node(String("BeginnerNodeShortcuts")));
Control *favorite_nodes = Object::cast_to<Control>(node_shortcuts->get_node(String("FavoriteNodeShortcuts")));
- if (!beginner_nodes || !favorite_nodes)
+ if (!beginner_nodes || !favorite_nodes) {
return;
+ }
EditorSettings::get_singleton()->set_setting("_use_favorites_root_selection", toggle->is_pressed());
EditorSettings::get_singleton()->save();
if (toggle->is_pressed()) {
-
for (int i = 0; i < favorite_nodes->get_child_count(); i++) {
favorite_nodes->get_child(i)->queue_delete();
}
@@ -2717,7 +2693,6 @@ void SceneTreeDock::_update_create_root_dialog() {
FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites.Node"), FileAccess::READ);
if (f) {
-
while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
@@ -2726,8 +2701,9 @@ void SceneTreeDock::_update_create_root_dialog() {
favorite_nodes->add_child(button);
button->set_text(TTR(l));
String name = l.get_slicec(' ', 0);
- if (ScriptServer::is_global_class(name))
+ if (ScriptServer::is_global_class(name)) {
name = ScriptServer::get_global_class_native_base(name);
+ }
button->set_icon(EditorNode::get_singleton()->get_class_icon(name));
button->connect("pressed", callable_mp(this, &SceneTreeDock::_favorite_root_selected), make_binds(l));
}
@@ -2754,11 +2730,9 @@ void SceneTreeDock::_favorite_root_selected(const String &p_class) {
}
void SceneTreeDock::_feature_profile_changed() {
-
Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
if (profile.is_valid()) {
-
profile_allow_editing = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCENE_TREE);
profile_allow_script_editing = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT);
bool profile_allow_3d = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D);
@@ -2781,7 +2755,6 @@ void SceneTreeDock::_feature_profile_changed() {
}
void SceneTreeDock::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_owners"), &SceneTreeDock::_set_owners);
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &SceneTreeDock::_unhandled_key_input);
ClassDB::bind_method(D_METHOD("_input"), &SceneTreeDock::_input);
@@ -2795,7 +2768,6 @@ void SceneTreeDock::_bind_methods() {
}
SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data) {
-
set_name("Scene");
editor = p_editor;
edited_scene = nullptr;
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 00b95c9853..72be3fb02f 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -53,7 +53,6 @@
class EditorNode;
class SceneTreeDock : public VBoxContainer {
-
GDCLASS(SceneTreeDock, VBoxContainer);
enum Tool {
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 251c911038..1b818036e1 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -41,14 +41,12 @@
#include "scene/resources/packed_scene.h"
Node *SceneTreeEditor::get_scene_node() {
-
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
return get_tree()->get_edited_scene_root();
}
void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
-
if (connect_to_script_mode) {
return; //don't do anything in this mode
}
@@ -71,8 +69,9 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
}
} else if (p_id == BUTTON_SCRIPT) {
Ref<Script> script_typed = n->get_script();
- if (!script_typed.is_null())
+ if (!script_typed.is_null()) {
emit_signal("open_script", script_typed);
+ }
} else if (p_id == BUTTON_VISIBILITY) {
undo_redo->create_action(TTR("Toggle Visible"));
@@ -93,7 +92,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
undo_redo->create_action(TTR("Unlock Node"));
if (n->is_class("CanvasItem") || n->is_class("Node3D")) {
-
undo_redo->add_do_method(n, "remove_meta", "_edit_lock_");
undo_redo->add_undo_method(n, "set_meta", "_edit_lock_", true);
undo_redo->add_do_method(this, "_update_tree", Variant());
@@ -103,7 +101,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
}
undo_redo->commit_action();
} else if (p_id == BUTTON_PIN) {
-
if (n->is_class("AnimationPlayer")) {
AnimationPlayerEditor::singleton->unpin();
_update_tree();
@@ -113,7 +110,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
undo_redo->create_action(TTR("Button Group"));
if (n->is_class("CanvasItem") || n->is_class("Node3D")) {
-
undo_redo->add_do_method(n, "remove_meta", "_edit_group_");
undo_redo->add_undo_method(n, "set_meta", "_edit_group_", true);
undo_redo->add_do_method(this, "_update_tree", Variant());
@@ -123,16 +119,15 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
}
undo_redo->commit_action();
} else if (p_id == BUTTON_WARNING) {
-
String config_err = n->get_configuration_warning();
- if (config_err == String())
+ if (config_err == String()) {
return;
+ }
config_err = config_err.word_wrap(80);
warning->set_text(config_err);
warning->popup_centered();
} else if (p_id == BUTTON_SIGNALS) {
-
editor_selection->clear();
editor_selection->add_node(n);
@@ -142,7 +137,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
NodeDock::singleton->show_connections();
} else if (p_id == BUTTON_GROUPS) {
-
editor_selection->clear();
editor_selection->add_node(n);
@@ -152,6 +146,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
NodeDock::singleton->show_groups();
}
}
+
void SceneTreeEditor::_toggle_visible(Node *p_node) {
if (p_node->has_method("is_visible") && p_node->has_method("set_visible")) {
bool v = bool(p_node->call("is_visible"));
@@ -161,9 +156,9 @@ void SceneTreeEditor::_toggle_visible(Node *p_node) {
}
bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
-
- if (!p_node)
+ if (!p_node) {
return false;
+ }
// only owned nodes are editable, since nodes can create their own (manually owned) child nodes,
// which the editor needs not to know about.
@@ -171,9 +166,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
bool part_of_subscene = false;
if (!display_foreign && p_node->get_owner() != get_scene_node() && p_node != get_scene_node()) {
-
if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()))) {
-
part_of_subscene = true;
//allow
} else {
@@ -186,14 +179,16 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
TreeItem *item = tree->create_item(p_parent);
item->set_text(0, p_node->get_name());
- if (can_rename && !part_of_subscene)
+ if (can_rename && !part_of_subscene) {
item->set_editable(0, true);
+ }
item->set_selectable(0, true);
if (can_rename) {
bool collapsed = p_node->is_displayed_folded();
- if (collapsed)
+ if (collapsed) {
item->set_collapsed(true);
+ }
}
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node");
@@ -229,12 +224,10 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_custom_color(0, accent);
}
} else if (part_of_subscene) {
-
if (valid_types.size() == 0) {
item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor"));
}
} else if (marked.has(p_node)) {
-
String node_name = p_node->get_name();
if (connecting_signal) {
node_name += " " + TTR("(Connecting From)");
@@ -243,7 +236,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_selectable(0, marked_selectable);
item->set_custom_color(0, get_theme_color("accent_color", "Editor"));
} else if (!marked_selectable && !marked_children_selectable) {
-
Node *node = p_node;
while (node) {
if (marked.has(node)) {
@@ -323,8 +315,9 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (can_open_instance && undo_redo) { //Show buttons only when necessary(SceneTreeDock) to avoid crashes
- if (!p_node->is_connected("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed)))
+ if (!p_node->is_connected("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed))) {
p_node->connect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed), varray(p_node));
+ }
Ref<Script> script = p_node->get_script();
if (!script.is_null()) {
@@ -335,47 +328,52 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
if (p_node->is_class("CanvasItem")) {
-
bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_
- if (is_locked)
+ if (is_locked) {
item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
+ }
bool is_grouped = p_node->has_meta("_edit_group_");
- if (is_grouped)
+ if (is_grouped) {
item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
+ }
bool v = p_node->call("is_visible");
- if (v)
+ if (v) {
item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
- else
+ } else {
item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
+ }
- if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)))
+ if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) {
p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node));
+ }
_update_visibility_color(p_node, item);
} else if (p_node->is_class("Node3D")) {
-
bool is_locked = p_node->has_meta("_edit_lock_");
- if (is_locked)
+ if (is_locked) {
item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it."));
+ }
bool is_grouped = p_node->has_meta("_edit_group_");
- if (is_grouped)
+ if (is_grouped) {
item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable."));
+ }
bool v = p_node->call("is_visible");
- if (v)
+ if (v) {
item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
- else
+ } else {
item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
+ }
- if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)))
+ if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) {
p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node));
+ }
_update_visibility_color(p_node, item);
} else if (p_node->is_class("AnimationPlayer")) {
-
bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned();
if (is_pinned) {
@@ -386,21 +384,20 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (editor_selection) {
if (editor_selection->is_selected(p_node)) {
-
item->select(0);
}
}
if (selected == p_node) {
- if (!editor_selection)
+ if (!editor_selection) {
item->select(0);
+ }
item->set_as_cursor(0);
}
bool keep = (filter.is_subsequence_ofi(String(p_node->get_name())));
for (int i = 0; i < p_node->get_child_count(); i++) {
-
bool child_keep = _add_nodes(p_node->get_child(i), item);
keep = keep || child_keep;
@@ -437,9 +434,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
-
if (!p_node || (p_node != get_scene_node() && !p_node->get_owner())) {
-
return;
}
@@ -461,10 +456,11 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
visible = p_node->call("is_visible");
}
- if (visible)
+ if (visible) {
item->set_button(0, idx, get_theme_icon("GuiVisibilityVisible", "EditorIcons"));
- else
+ } else {
item->set_button(0, idx, get_theme_icon("GuiVisibilityHidden", "EditorIcons"));
+ }
_update_visibility_color(p_node, item);
}
@@ -482,25 +478,27 @@ void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) {
}
void SceneTreeEditor::_node_script_changed(Node *p_node) {
-
- if (tree_dirty)
+ if (tree_dirty) {
return;
+ }
MessageQueue::get_singleton()->push_call(this, "_update_tree");
tree_dirty = true;
}
void SceneTreeEditor::_node_removed(Node *p_node) {
-
- if (EditorNode::get_singleton()->is_exiting())
+ if (EditorNode::get_singleton()->is_exiting()) {
return; //speed up exit
+ }
- if (p_node->is_connected("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed)))
+ if (p_node->is_connected("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed))) {
p_node->disconnect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed));
+ }
if (p_node->is_class("Node3D") || p_node->is_class("CanvasItem")) {
- if (p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)))
+ if (p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) {
p_node->disconnect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed));
+ }
}
if (p_node == selected) {
@@ -510,7 +508,6 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
}
void SceneTreeEditor::_node_renamed(Node *p_node) {
-
emit_signal("node_renamed");
if (!tree_dirty) {
@@ -520,7 +517,6 @@ void SceneTreeEditor::_node_renamed(Node *p_node) {
}
void SceneTreeEditor::_update_tree() {
-
if (!is_inside_tree()) {
tree_dirty = false;
return;
@@ -539,61 +535,65 @@ void SceneTreeEditor::_update_tree() {
}
void SceneTreeEditor::_compute_hash(Node *p_node, uint64_t &hash) {
-
hash = hash_djb2_one_64(p_node->get_instance_id(), hash);
- if (p_node->get_parent())
+ if (p_node->get_parent()) {
hash = hash_djb2_one_64(p_node->get_parent()->get_instance_id(), hash); //so a reparent still produces a different hash
+ }
for (int i = 0; i < p_node->get_child_count(); i++) {
-
_compute_hash(p_node->get_child(i), hash);
}
}
void SceneTreeEditor::_test_update_tree() {
-
pending_test_update = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (tree_dirty)
+ if (tree_dirty) {
return; // don't even bother
+ }
uint64_t hash = hash_djb2_one_64(0);
- if (get_scene_node())
+ if (get_scene_node()) {
_compute_hash(get_scene_node(), hash);
+ }
//test hash
- if (hash == last_hash)
+ if (hash == last_hash) {
return; // did not change
+ }
MessageQueue::get_singleton()->push_call(this, "_update_tree");
tree_dirty = true;
}
void SceneTreeEditor::_tree_changed() {
-
- if (EditorNode::get_singleton()->is_exiting())
+ if (EditorNode::get_singleton()->is_exiting()) {
return; //speed up exit
- if (pending_test_update)
+ }
+ if (pending_test_update) {
return;
- if (tree_dirty)
+ }
+ if (tree_dirty) {
return;
+ }
MessageQueue::get_singleton()->push_call(this, "_test_update_tree");
pending_test_update = true;
}
void SceneTreeEditor::_selected_changed() {
-
TreeItem *s = tree->get_selected();
ERR_FAIL_COND(!s);
NodePath np = s->get_metadata(0);
Node *n = get_node(np);
- if (n == selected)
+ if (n == selected) {
return;
+ }
selected = get_node(np);
@@ -603,7 +603,6 @@ void SceneTreeEditor::_selected_changed() {
}
void SceneTreeEditor::_deselect_items() {
-
// Clear currently elected items in scene tree dock.
if (editor_selection) {
editor_selection->clear();
@@ -612,7 +611,6 @@ void SceneTreeEditor::_deselect_items() {
}
void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) {
-
TreeItem *item = Object::cast_to<TreeItem>(p_object);
ERR_FAIL_COND(!item);
@@ -620,11 +618,13 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_
Node *n = get_node(np);
- if (!n)
+ if (!n) {
return;
+ }
- if (!editor_selection)
+ if (!editor_selection) {
return;
+ }
if (p_selected) {
editor_selection->add_node(n);
@@ -636,10 +636,8 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_
}
void SceneTreeEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
get_tree()->connect("tree_changed", callable_mp(this, &SceneTreeEditor::_tree_changed));
get_tree()->connect("node_removed", callable_mp(this, &SceneTreeEditor::_node_removed));
get_tree()->connect("node_renamed", callable_mp(this, &SceneTreeEditor::_node_renamed));
@@ -650,7 +648,6 @@ void SceneTreeEditor::_notification(int p_what) {
_update_tree();
} break;
case NOTIFICATION_EXIT_TREE: {
-
get_tree()->disconnect("tree_changed", callable_mp(this, &SceneTreeEditor::_tree_changed));
get_tree()->disconnect("node_removed", callable_mp(this, &SceneTreeEditor::_node_removed));
get_tree()->disconnect("node_renamed", callable_mp(this, &SceneTreeEditor::_node_renamed));
@@ -658,27 +655,27 @@ void SceneTreeEditor::_notification(int p_what) {
get_tree()->disconnect("node_configuration_warning_changed", callable_mp(this, &SceneTreeEditor::_warning_changed));
} break;
case NOTIFICATION_THEME_CHANGED: {
-
_update_tree();
} break;
}
}
TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) {
-
- if (!p_node)
+ if (!p_node) {
return nullptr;
+ }
NodePath np = p_node->get_metadata(0);
- if (np == p_path)
+ if (np == p_path) {
return p_node;
+ }
TreeItem *children = p_node->get_children();
while (children) {
-
TreeItem *n = _find(children, p_path);
- if (n)
+ if (n) {
return n;
+ }
children = children->get_next();
}
@@ -686,16 +683,18 @@ TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) {
}
void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
-
ERR_FAIL_COND(blocked > 0);
- if (pending_test_update)
+ if (pending_test_update) {
_test_update_tree();
- if (tree_dirty)
+ }
+ if (tree_dirty) {
_update_tree();
+ }
- if (selected == p_node)
+ if (selected == p_node) {
return;
+ }
TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : nullptr;
@@ -712,8 +711,9 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
tree->ensure_cursor_is_visible();
} else {
- if (!p_node)
+ if (!p_node) {
selected = nullptr;
+ }
_update_tree();
selected = p_node;
}
@@ -724,7 +724,6 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
}
void SceneTreeEditor::_rename_node(ObjectID p_node, const String &p_name) {
-
Object *o = ObjectDB::get_instance(p_node);
ERR_FAIL_COND(!o);
Node *n = Object::cast_to<Node>(o);
@@ -738,7 +737,6 @@ void SceneTreeEditor::_rename_node(ObjectID p_node, const String &p_name) {
}
void SceneTreeEditor::_renamed() {
-
TreeItem *which = tree->get_edited();
ERR_FAIL_COND(!which);
@@ -755,7 +753,6 @@ void SceneTreeEditor::_renamed() {
String new_name = which->get_text(0);
if (!Node::_validate_node_name(new_name)) {
-
error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n" + Node::invalid_character);
error->popup_centered();
@@ -767,8 +764,9 @@ void SceneTreeEditor::_renamed() {
which->set_text(0, new_name);
}
- if (new_name == n->get_name())
+ if (new_name == n->get_name()) {
return;
+ }
if (!undo_redo) {
n->set_name(new_name);
@@ -784,14 +782,13 @@ void SceneTreeEditor::_renamed() {
}
Node *SceneTreeEditor::get_selected() {
-
return selected;
}
void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable, bool p_children_selectable) {
-
- if (tree_dirty)
+ if (tree_dirty) {
_update_tree();
+ }
marked = p_marked;
marked_selectable = p_selectable;
marked_children_selectable = p_children_selectable;
@@ -799,31 +796,28 @@ void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable,
}
void SceneTreeEditor::set_marked(Node *p_marked, bool p_selectable, bool p_children_selectable) {
-
Set<Node *> s;
- if (p_marked)
+ if (p_marked) {
s.insert(p_marked);
+ }
set_marked(s, p_selectable, p_children_selectable);
}
void SceneTreeEditor::set_filter(const String &p_filter) {
-
filter = p_filter;
_update_tree();
}
String SceneTreeEditor::get_filter() const {
-
return filter;
}
void SceneTreeEditor::set_display_foreign_nodes(bool p_display) {
-
display_foreign = p_display;
_update_tree();
}
-bool SceneTreeEditor::get_display_foreign_nodes() const {
+bool SceneTreeEditor::get_display_foreign_nodes() const {
return display_foreign;
}
@@ -832,7 +826,6 @@ void SceneTreeEditor::set_valid_types(const Vector<StringName> &p_valid) {
}
void SceneTreeEditor::set_editor_selection(EditorSelection *p_selection) {
-
editor_selection = p_selection;
tree->set_select_mode(Tree::SELECT_MULTI);
tree->set_cursor_can_exit_tree(false);
@@ -840,55 +833,59 @@ void SceneTreeEditor::set_editor_selection(EditorSelection *p_selection) {
}
void SceneTreeEditor::_update_selection(TreeItem *item) {
-
ERR_FAIL_COND(!item);
NodePath np = item->get_metadata(0);
- if (!has_node(np))
+ if (!has_node(np)) {
return;
+ }
Node *n = get_node(np);
- if (!n)
+ if (!n) {
return;
+ }
- if (editor_selection->is_selected(n))
+ if (editor_selection->is_selected(n)) {
item->select(0);
- else
+ } else {
item->deselect(0);
+ }
TreeItem *c = item->get_children();
while (c) {
-
_update_selection(c);
c = c->get_next();
}
}
void SceneTreeEditor::_selection_changed() {
-
- if (!editor_selection)
+ if (!editor_selection) {
return;
+ }
TreeItem *root = tree->get_root();
- if (!root)
+ if (!root) {
return;
+ }
_update_selection(root);
}
void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
-
- if (updating_tree)
+ if (updating_tree) {
return;
- if (!can_rename)
+ }
+ if (!can_rename) {
return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_obj);
- if (!ti)
+ if (!ti) {
return;
+ }
bool collapsed = ti->is_collapsed();
@@ -901,14 +898,14 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
}
Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
- if (!can_rename)
+ if (!can_rename) {
return Variant(); //not editable tree
+ }
Vector<Node *> selected;
Vector<Ref<Texture2D>> icons;
TreeItem *next = tree->get_next_selected(nullptr);
while (next) {
-
NodePath np = next->get_metadata(0);
Node *n = get_node(np);
@@ -922,8 +919,9 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
next = tree->get_next_selected(next);
}
- if (selected.empty())
+ if (selected.empty()) {
return Variant();
+ }
VBoxContainer *vb = memnew(VBoxContainer);
Array objs;
@@ -931,7 +929,6 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
float opacity_step = 1.0f / list_max;
float opacity_item = 1.0f;
for (int i = 0; i < selected.size(); i++) {
-
if (i < list_max) {
HBoxContainer *hb = memnew(HBoxContainer);
TextureRect *tf = memnew(TextureRect);
@@ -964,30 +961,34 @@ bool SceneTreeEditor::_is_script_type(const StringName &p_type) const {
}
bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
- if (!can_rename)
+ if (!can_rename) {
return false; //not editable tree
- if (filter != String())
+ }
+ if (filter != String()) {
return false; //can't rearrange tree with filter turned on
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
TreeItem *item = tree->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return false;
+ }
int section = tree->get_drop_section_at_position(p_point);
- if (section < -1 || (section == -1 && !item->get_parent()))
+ if (section < -1 || (section == -1 && !item->get_parent())) {
return false;
+ }
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
- if (files.size() == 0)
+ if (files.size() == 0) {
return false; //weird
+ }
if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(files[0]))) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
@@ -997,8 +998,9 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d
for (int i = 0; i < files.size(); i++) {
String file = files[i];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
- if (ftype != "PackedScene")
+ if (ftype != "PackedScene") {
return false;
+ }
}
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); //so it works..
@@ -1019,22 +1021,26 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d
return String(d["type"]) == "nodes";
}
-void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point, p_data, p_from))
+void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+ if (!can_drop_data_fw(p_point, p_data, p_from)) {
return;
+ }
TreeItem *item = tree->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return;
+ }
int section = tree->get_drop_section_at_position(p_point);
- if (section < -1)
+ if (section < -1) {
return;
+ }
NodePath np = item->get_metadata(0);
Node *n = get_node(np);
- if (!n)
+ if (!n) {
return;
+ }
Dictionary d = p_data;
@@ -1044,7 +1050,6 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
if (String(d["type"]) == "files") {
-
Vector<String> files = d["files"];
String ftype = EditorFileSystem::get_singleton()->get_file_type(files[0]);
@@ -1067,12 +1072,10 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) {
-
emit_signal("rmb_pressed", tree->get_global_transform().xform(p_pos));
}
void SceneTreeEditor::_warning_changed(Node *p_for_node) {
-
//should use a timer
update_timer->start();
}
@@ -1088,7 +1091,6 @@ void SceneTreeEditor::set_connecting_signal(bool p_enable) {
}
void SceneTreeEditor::_bind_methods() {
-
ClassDB::bind_method("_update_tree", &SceneTreeEditor::_update_tree); // Still used by some connect_compat.
ClassDB::bind_method("_rename_node", &SceneTreeEditor::_rename_node);
ClassDB::bind_method("_test_update_tree", &SceneTreeEditor::_test_update_tree);
@@ -1114,7 +1116,6 @@ void SceneTreeEditor::_bind_methods() {
}
SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_open_instance) {
-
connect_to_script_mode = false;
connecting_signal = false;
undo_redo = nullptr;
@@ -1184,19 +1185,17 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
}
SceneTreeEditor::~SceneTreeEditor() {
-
memdelete(script_types);
}
/******** DIALOG *********/
void SceneTreeDialog::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
-
- if (is_visible())
+ if (is_visible()) {
tree->update_tree();
+ }
} break;
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &SceneTreeDialog::_select));
@@ -1210,11 +1209,10 @@ void SceneTreeDialog::_notification(int p_what) {
}
void SceneTreeDialog::_cancel() {
-
hide();
}
-void SceneTreeDialog::_select() {
+void SceneTreeDialog::_select() {
if (tree->get_selected()) {
emit_signal("selected", tree->get_selected()->get_path());
hide();
@@ -1222,19 +1220,16 @@ void SceneTreeDialog::_select() {
}
void SceneTreeDialog::_filter_changed(const String &p_filter) {
-
tree->set_filter(p_filter);
}
void SceneTreeDialog::_bind_methods() {
-
ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel);
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::NODE_PATH, "path")));
}
SceneTreeDialog::SceneTreeDialog() {
-
set_title(TTR("Select a Node"));
VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index 17ee5ace66..106837f69a 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -39,7 +39,6 @@
#include "scene/gui/tree.h"
class SceneTreeEditor : public Control {
-
GDCLASS(SceneTreeEditor, Control);
EditorSelection *editor_selection;
@@ -163,7 +162,6 @@ public:
};
class SceneTreeDialog : public ConfirmationDialog {
-
GDCLASS(SceneTreeDialog, ConfirmationDialog);
SceneTreeEditor *tree;
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index f84b7e73ed..ae5229b628 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -67,8 +67,8 @@ void ScriptCreateDialog::_theme_changed() {
parent_search_button->set_icon(gc->get_theme_icon("ClassList", "EditorIcons"));
status_panel->add_theme_style_override("panel", gc->get_theme_stylebox("bg", "Tree"));
}
-void ScriptCreateDialog::_notification(int p_what) {
+void ScriptCreateDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
_theme_changed();
@@ -99,7 +99,6 @@ bool ScriptCreateDialog::_can_be_built_in() {
}
void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled) {
-
class_name->set_text("");
class_name->deselect();
parent_name->set_text(p_base_name);
@@ -124,57 +123,60 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_
}
void ScriptCreateDialog::set_inheritance_base_type(const String &p_base) {
-
base_type = p_base;
}
bool ScriptCreateDialog::_validate_parent(const String &p_string) {
-
- if (p_string.length() == 0)
+ if (p_string.length() == 0) {
return false;
+ }
if (can_inherit_from_file && p_string.is_quoted()) {
String p = p_string.substr(1, p_string.length() - 2);
- if (_validate_path(p, true) == "")
+ if (_validate_path(p, true) == "") {
return true;
+ }
}
return ClassDB::class_exists(p_string) || ScriptServer::is_global_class(p_string);
}
bool ScriptCreateDialog::_validate_class(const String &p_string) {
-
- if (p_string.length() == 0)
+ if (p_string.length() == 0) {
return false;
+ }
for (int i = 0; i < p_string.length(); i++) {
-
if (i == 0) {
- if (p_string[0] >= '0' && p_string[0] <= '9')
+ if (p_string[0] >= '0' && p_string[0] <= '9') {
return false; // no start with number plz
+ }
}
bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_' || p_string[i] == '.';
- if (!valid_char)
+ if (!valid_char) {
return false;
+ }
}
return true;
}
String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must_exist) {
-
String p = p_path.strip_edges();
- if (p == "")
+ if (p == "") {
return TTR("Path is empty.");
- if (p.get_file().get_basename() == "")
+ }
+ if (p.get_file().get_basename() == "") {
return TTR("Filename is empty.");
+ }
p = ProjectSettings::get_singleton()->localize_path(p);
- if (!p.begins_with("res://"))
+ if (!p.begins_with("res://")) {
return TTR("Path is not local.");
+ }
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (d->change_dir(p.get_base_dir()) != OK) {
@@ -219,22 +221,24 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must
index++;
}
- if (!found)
+ if (!found) {
return TTR("Invalid extension.");
- if (!match)
+ }
+ if (!match) {
return TTR("Wrong extension chosen.");
+ }
/* Let ScriptLanguage do custom validation */
String path_error = ScriptServer::get_language(language_menu->get_selected())->validate_path(p);
- if (path_error != "")
+ if (path_error != "") {
return path_error;
+ }
/* All checks passed */
return "";
}
void ScriptCreateDialog::_class_name_changed(const String &p_name) {
-
if (_validate_class(class_name->get_text())) {
is_class_name_valid = true;
} else {
@@ -244,7 +248,6 @@ void ScriptCreateDialog::_class_name_changed(const String &p_name) {
}
void ScriptCreateDialog::_parent_name_changed(const String &p_parent) {
-
if (_validate_parent(parent_name->get_text())) {
is_parent_name_valid = true;
} else {
@@ -254,7 +257,6 @@ void ScriptCreateDialog::_parent_name_changed(const String &p_parent) {
}
void ScriptCreateDialog::_template_changed(int p_template) {
-
String selected_template = p_template == 0 ? "" : template_menu->get_item_text(p_template);
EditorSettings::get_singleton()->set_project_metadata("script_setup", "last_selected_template", selected_template);
if (p_template == 0) {
@@ -274,7 +276,6 @@ void ScriptCreateDialog::_template_changed(int p_template) {
}
void ScriptCreateDialog::ok_pressed() {
-
if (is_new_script_created) {
_create_new();
} else {
@@ -286,7 +287,6 @@ void ScriptCreateDialog::ok_pressed() {
}
void ScriptCreateDialog::_create_new() {
-
String cname_param;
if (has_named_classes) {
@@ -311,8 +311,9 @@ void ScriptCreateDialog::_create_new() {
if (has_named_classes) {
String cname = class_name->get_text();
- if (cname.length())
+ if (cname.length()) {
scr->set_name(cname);
+ }
}
if (!is_built_in) {
@@ -331,7 +332,6 @@ void ScriptCreateDialog::_create_new() {
}
void ScriptCreateDialog::_load_exist() {
-
String path = file_path->get_text();
RES p_script = ResourceLoader::load(path, "Script");
if (p_script.is_null()) {
@@ -345,14 +345,14 @@ void ScriptCreateDialog::_load_exist() {
}
void ScriptCreateDialog::_lang_changed(int l) {
-
ScriptLanguage *language = ScriptServer::get_language(l);
has_named_classes = language->has_named_classes();
can_inherit_from_file = language->can_inherit_from_file();
supports_built_in = language->supports_builtin_mode();
- if (!supports_built_in)
+ if (!supports_built_in) {
is_built_in = false;
+ }
String selected_ext = "." + language->get_extension();
String path = file_path->get_text();
@@ -409,7 +409,6 @@ void ScriptCreateDialog::_lang_changed(int l) {
// Populate script template items previously sorted and now grouped by origin
for (int i = 0; i < template_list.size(); i++) {
-
if (int(templates[i].origin) != cur_origin) {
template_menu->add_separator();
@@ -474,7 +473,6 @@ void ScriptCreateDialog::_lang_changed(int l) {
}
void ScriptCreateDialog::_update_script_templates(const String &p_extension) {
-
template_list.clear();
template_overrides.clear();
@@ -485,7 +483,6 @@ void ScriptCreateDialog::_update_script_templates(const String &p_extension) {
dirs.push_back(EditorSettings::get_singleton()->get_script_templates_dir());
for (int i = 0; i < dirs.size(); i++) {
-
Vector<String> list = EditorSettings::get_singleton()->get_script_templates(p_extension, dirs[i]);
for (int j = 0; j < list.size(); j++) {
@@ -509,7 +506,6 @@ void ScriptCreateDialog::_update_script_templates(const String &p_extension) {
}
void ScriptCreateDialog::_built_in_pressed() {
-
if (internal->is_pressed()) {
is_built_in = true;
is_new_script_created = true;
@@ -521,7 +517,6 @@ void ScriptCreateDialog::_built_in_pressed() {
}
void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) {
-
is_browsing_parent = browse_parent;
if (p_save) {
@@ -549,7 +544,6 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) {
}
void ScriptCreateDialog::_file_selected(const String &p_file) {
-
String p = ProjectSettings::get_singleton()->localize_path(p_file);
if (is_browsing_parent) {
parent_name->set_text("\"" + p + "\"");
@@ -567,19 +561,16 @@ void ScriptCreateDialog::_file_selected(const String &p_file) {
}
void ScriptCreateDialog::_create() {
-
parent_name->set_text(select_class->get_selected_type().split(" ")[0]);
_parent_name_changed(parent_name->get_text());
}
void ScriptCreateDialog::_browse_class_in_tree() {
-
select_class->set_base_type(base_type);
select_class->popup_create(true);
}
void ScriptCreateDialog::_path_changed(const String &p_path) {
-
if (is_built_in) {
return;
}
@@ -612,7 +603,6 @@ void ScriptCreateDialog::_path_entered(const String &p_path) {
}
void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
-
error_label->set_text("- " + TTR(p_msg));
if (valid) {
error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor"));
@@ -622,7 +612,6 @@ void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
}
void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
-
path_error_label->set_text("- " + TTR(p_msg));
if (valid) {
path_error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor"));
@@ -632,7 +621,6 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
}
void ScriptCreateDialog::_update_dialog() {
-
/* "Add Script Dialog" GUI logic and script checks. */
bool script_ok = true;
@@ -737,14 +725,12 @@ void ScriptCreateDialog::_update_dialog() {
}
void ScriptCreateDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled", "load_enabled"), &ScriptCreateDialog::config, DEFVAL(true), DEFVAL(true));
ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
}
ScriptCreateDialog::ScriptCreateDialog() {
-
/* DIALOG */
/* Main Controls */
@@ -797,17 +783,17 @@ ScriptCreateDialog::ScriptCreateDialog() {
gc->add_child(memnew(Label(TTR("Language:"))));
gc->add_child(language_menu);
- default_language = 0;
+ default_language = -1;
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
-
String lang = ScriptServer::get_language(i)->get_name();
language_menu->add_item(lang);
if (lang == "GDScript") {
default_language = i;
}
}
-
- language_menu->select(default_language);
+ if (default_language >= 0) {
+ language_menu->select(default_language);
+ }
current_language = default_language;
language_menu->connect("item_selected", callable_mp(this, &ScriptCreateDialog::_lang_changed));
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 8910e8ec3a..c461bf0410 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -41,21 +41,19 @@
#include "scene/gui/margin_container.h"
void EditorSettingsDialog::ok_pressed() {
-
- if (!EditorSettings::get_singleton())
+ if (!EditorSettings::get_singleton()) {
return;
+ }
_settings_save();
timer->stop();
}
void EditorSettingsDialog::_settings_changed() {
-
timer->start();
}
void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
-
String full_name = inspector->get_full_item_path(p_name);
if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") {
@@ -66,23 +64,22 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
}
void EditorSettingsDialog::_settings_save() {
-
EditorSettings::get_singleton()->notify_changes();
EditorSettings::get_singleton()->save();
}
void EditorSettingsDialog::cancel_pressed() {
-
- if (!EditorSettings::get_singleton())
+ if (!EditorSettings::get_singleton()) {
return;
+ }
EditorSettings::get_singleton()->notify_changes();
}
void EditorSettingsDialog::popup_edit_settings() {
-
- if (!EditorSettings::get_singleton())
+ if (!EditorSettings::get_singleton()) {
return;
+ }
EditorSettings::get_singleton()->list_text_editor_themes(); // make sure we have an up to date list of themes
@@ -116,7 +113,6 @@ void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_nam
}
void EditorSettingsDialog::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
@@ -142,17 +138,16 @@ void EditorSettingsDialog::_notification(int p_what) {
}
void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
-
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
-
bool handled = false;
if (ED_IS_SHORTCUT("editor/undo", p_event)) {
String action = undo_redo->get_current_action_name();
- if (action != "")
+ if (action != "") {
EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR);
+ }
undo_redo->undo();
handled = true;
}
@@ -160,8 +155,9 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
if (ED_IS_SHORTCUT("editor/redo", p_event)) {
undo_redo->redo();
String action = undo_redo->get_current_action_name();
- if (action != "")
+ if (action != "") {
EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR);
+ }
handled = true;
}
@@ -177,7 +173,6 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
}
void EditorSettingsDialog::_update_icons() {
-
search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons"));
@@ -190,7 +185,6 @@ void EditorSettingsDialog::_update_icons() {
}
void EditorSettingsDialog::_update_shortcuts() {
-
Map<String, bool> collapsed;
if (shortcuts->get_root() && shortcuts->get_root()->get_children()) {
@@ -208,10 +202,10 @@ void EditorSettingsDialog::_update_shortcuts() {
Map<String, TreeItem *> sections;
for (List<String>::Element *E = slist.front(); E; E = E->next()) {
-
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(E->get());
- if (!sc->has_meta("original"))
+ if (!sc->has_meta("original")) {
continue;
+ }
Ref<InputEvent> original = sc->get_meta("original");
@@ -270,7 +264,6 @@ void EditorSettingsDialog::_update_shortcuts() {
}
void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
@@ -287,8 +280,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
shortcut_configured = item;
} else if (p_idx == 1) { //erase
- if (!sc.is_valid())
+ if (!sc.is_valid()) {
return; //pointless, there is nothing
+ }
undo_redo->create_action(TTR("Erase Shortcut"));
undo_redo->add_do_method(sc.ptr(), "set_shortcut", Ref<InputEvent>());
@@ -299,8 +293,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
} else if (p_idx == 2) { //revert to original
- if (!sc.is_valid())
+ if (!sc.is_valid()) {
return; //pointless, there is nothing
+ }
Ref<InputEvent> original = sc->get_meta("original");
@@ -316,11 +311,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column
}
void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed() && k->get_keycode() != 0) {
-
last_wait_for_key = k;
const String str = keycode_get_string(k->get_keycode_with_modifiers());
@@ -330,9 +323,9 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) {
}
void EditorSettingsDialog::_press_a_key_confirm() {
-
- if (last_wait_for_key.is_null())
+ if (last_wait_for_key.is_null()) {
return;
+ }
Ref<InputEventKey> ie;
ie.instance();
@@ -355,18 +348,17 @@ void EditorSettingsDialog::_press_a_key_confirm() {
}
void EditorSettingsDialog::_tabs_tab_changed(int p_tab) {
-
_focus_current_search_box();
}
void EditorSettingsDialog::_focus_current_search_box() {
-
Control *tab = tabs->get_current_tab_control();
LineEdit *current_search_box = nullptr;
- if (tab == tab_general)
+ if (tab == tab_general) {
current_search_box = search_box;
- else if (tab == tab_shortcuts)
+ } else if (tab == tab_shortcuts) {
current_search_box = shortcut_search_box;
+ }
if (current_search_box) {
current_search_box->grab_focus();
@@ -388,13 +380,11 @@ void EditorSettingsDialog::_editor_restart_close() {
}
void EditorSettingsDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorSettingsDialog::_unhandled_input);
ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts);
}
EditorSettingsDialog::EditorSettingsDialog() {
-
set_title(TTR("Editor Settings"));
undo_redo = memnew(UndoRedo);
diff --git a/editor/settings_config_dialog.h b/editor/settings_config_dialog.h
index 03dd18d23f..05566762fc 100644
--- a/editor/settings_config_dialog.h
+++ b/editor/settings_config_dialog.h
@@ -41,7 +41,6 @@
#include "scene/gui/tool_button.h"
class EditorSettingsDialog : public AcceptDialog {
-
GDCLASS(EditorSettingsDialog, AcceptDialog);
bool updating;
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index 6bf9c5ffae..aa88b0ef39 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -225,7 +225,6 @@ protected:
pinfo.hint_string = "Cubemap";
} break;
default: {
-
} break;
}
@@ -367,7 +366,6 @@ static Variant create_var(RS::GlobalVariableType p_type) {
}
void ShaderGlobalsEditor::_variable_added() {
-
String var = variable_name->get_text().strip_edges();
if (var == "" || !var.is_valid_identifier()) {
EditorNode::get_singleton()->show_warning(TTR("Please specify a valid variable identifier name."));
@@ -406,7 +404,6 @@ void ShaderGlobalsEditor::_variable_added() {
}
void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) {
-
print_line("deleted " + p_variable);
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
@@ -443,7 +440,6 @@ void ShaderGlobalsEditor::_notification(int p_what) {
}
ShaderGlobalsEditor::ShaderGlobalsEditor() {
-
HBoxContainer *add_menu_hb = memnew(HBoxContainer);
add_child(add_menu_hb);
@@ -476,7 +472,8 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
interface = memnew(ShaderGlobalsEditorInterface);
interface->connect("var_changed", Callable(this, "_changed"));
}
+
ShaderGlobalsEditor::~ShaderGlobalsEditor() {
- inspector->edit(NULL);
+ inspector->edit(nullptr);
memdelete(interface);
}
diff --git a/editor/shader_globals_editor.h b/editor/shader_globals_editor.h
index b3dbddc87e..33f527f314 100644
--- a/editor/shader_globals_editor.h
+++ b/editor/shader_globals_editor.h
@@ -42,7 +42,6 @@
class ShaderGlobalsEditorInterface;
class ShaderGlobalsEditor : public VBoxContainer {
-
GDCLASS(ShaderGlobalsEditor, VBoxContainer)
ShaderGlobalsEditorInterface *interface;
diff --git a/editor/translations/af.po b/editor/translations/af.po
index fb354fa199..1f598ef5e5 100644
--- a/editor/translations/af.po
+++ b/editor/translations/af.po
@@ -870,7 +870,6 @@ msgstr "Koppel tans Sein:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1513,18 +1512,9 @@ msgstr "Aktiveer"
msgid "Rearrange Autoloads"
msgstr "Herrangskik AutoLaaie"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Ongeldige Pad."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Lêer bestaan nie."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Nie in hulpbron pad nie."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2497,11 +2487,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Open Lêer(s)"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2774,10 +2767,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3392,6 +3381,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -4014,6 +4007,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -7005,15 +7002,15 @@ msgid ""
msgstr "Koppel '%s' aan '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Reël:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Maak Funksie"
@@ -7496,6 +7493,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10516,8 +10522,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Deursoek Hulp"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10680,6 +10687,13 @@ msgid "Open Documentation"
msgstr "Opnoemings"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10729,11 +10743,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10858,6 +10872,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Lêer bestaan nie."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Moet 'n geldige uitbreiding gebruik."
@@ -10900,6 +10918,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Ongeldige Pad."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Ongeldige naam."
@@ -11963,6 +11986,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11987,6 +12014,32 @@ msgstr "Ongeldige naam."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12641,6 +12694,9 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Nie in hulpbron pad nie."
+
#~ msgid "Replaced %d occurrence(s)."
#~ msgstr "Het %d verskynsel(s) vervang."
diff --git a/editor/translations/ar.po b/editor/translations/ar.po
index 22358973a0..a60de1a41e 100644
--- a/editor/translations/ar.po
+++ b/editor/translations/ar.po
@@ -37,12 +37,16 @@
# Nabeel20 <nabeelandnizam@gmail.com>, 2020.
# merouche djallal <kbordora@gmail.com>, 2020.
# Airbus5717 <Abdussamadf350@gmail.com>, 2020.
+# tamsamani mohamed <tamsmoha@gmail.com>, 2020.
+# Anas <anas.ghamdi61@gmail.com>, 2020.
+# R-K <raouf9005@gmail.com>, 2020.
+# HeroFight dev <abdkafi2002@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-05 14:01+0000\n"
-"Last-Translator: Anonymous <noreply@weblate.org>\n"
+"PO-Revision-Date: 2020-06-09 02:02+0000\n"
+"Last-Translator: HeroFight dev <abdkafi2002@gmail.com>\n"
"Language-Team: Arabic <https://hosted.weblate.org/projects/godot-engine/"
"godot/ar/>\n"
"Language: ar\n"
@@ -862,7 +866,6 @@ msgstr "إشارة غير قادر على الاتصال"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1472,17 +1475,9 @@ msgstr "تمكين"
msgid "Rearrange Autoloads"
msgstr "اعادة ترتيب التحميلات التلقائية"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "مسار غير صالح."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "المل٠غير موجود."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "ليس ÙÙŠ مسار الموارد."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2431,12 +2426,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "لا يمكن إعادة تحميل مشهد لم يتم Ø­Ùظه من قبل."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "إرجاع"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Ø­Ùظ المشهد"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "هذا الÙعل لا يمكن إرجاعة. إرجاع علي أية حال؟"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2721,10 +2719,6 @@ msgid "Redo"
msgstr "إعادة تراجع"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "إعادة المشهد"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "ادوات لكل-المشهد او لمشاريع متنوعه."
@@ -3007,9 +3001,8 @@ msgid "Update When Changed"
msgstr "تحديث عند التغيير"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Hide Update Spinner"
-msgstr "تعطيل دوار التحديث"
+msgstr "إخÙاء دوران التحديث"
#: editor/editor_node.cpp
msgid "FileSystem"
@@ -3238,9 +3231,8 @@ msgid "Assign..."
msgstr "إلحاق..."
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Invalid RID"
-msgstr "اسم غير صالح."
+msgstr "إسم RID غير صالح."
#: editor/editor_properties.cpp
msgid ""
@@ -3278,9 +3270,8 @@ msgid "New Script"
msgstr "نص برمجي جديد"
#: editor/editor_properties.cpp editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Extend Script"
-msgstr "Ùتح الكود"
+msgstr "Ùتح الكود البرمجي"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "New %s"
@@ -3326,14 +3317,12 @@ msgid "Remove Item"
msgstr "إزالة عنصر"
#: editor/editor_properties_array_dict.cpp
-#, fuzzy
msgid "New Key:"
-msgstr "إسم جديد:"
+msgstr "Ù…Ùتاح جديد:"
#: editor/editor_properties_array_dict.cpp
-#, fuzzy
msgid "New Value:"
-msgstr "إسم جديد:"
+msgstr "قيمة جديدة:"
#: editor/editor_properties_array_dict.cpp
msgid "Add Key/Value Pair"
@@ -3371,6 +3360,13 @@ msgstr "لم نستطع تشغيل الكود:"
msgid "Did you forget the '_run' method?"
msgstr "هل نسيت الطريقة '_run' ؟"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"اضغط مطولاً على Ctrl لإسقاط جالب Getter. اضغط مطولاً على Shift لإسقاط توقيع "
+"عام generic signature."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "إختيار عقدة(عقد) للإستيراد"
@@ -3388,9 +3384,8 @@ msgid "Import From Node:"
msgstr "إستيراد من عقدة:"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Redownload"
-msgstr "اعادة التحميل"
+msgstr "إعادة التحميل"
#: editor/export_template_manager.cpp
msgid "Uninstall"
@@ -3430,9 +3425,8 @@ msgid "Can't open export templates zip."
msgstr "لم نستطع Ùتح المل٠المضغوط المÙورد."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Invalid version.txt format inside templates: %s."
-msgstr "صيغة غير صالحة لـ version.txt داخل القالب."
+msgstr "صيغة غير صالحة ل version.txt داخل القالب: %s."
#: editor/export_template_manager.cpp
msgid "No version.txt found inside templates."
@@ -3501,9 +3495,8 @@ msgid "Download Complete."
msgstr "التحميل إكتمل."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Cannot remove temporary file:"
-msgstr "لا يمكن المسح:"
+msgstr "لا يمكن حذ٠مل٠مؤقت:"
#: editor/export_template_manager.cpp
msgid ""
@@ -3514,9 +3507,8 @@ msgstr ""
"يمكن إيجاد أرشي٠القوالب المعطوبة ÙÙŠ '%s'."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Error requesting URL:"
-msgstr "خطأ ÙÙŠ طلب الرابط: "
+msgstr "خطأ ÙÙŠ طلب الرابط:"
#: editor/export_template_manager.cpp
msgid "Connecting to Mirror..."
@@ -3565,9 +3557,8 @@ msgid "SSL Handshake Error"
msgstr "خطأ مطابقة ssl"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Uncompressing Android Build Sources"
-msgstr "ÙŠÙكك الضغط عن الأصول"
+msgstr "يتم تÙكيك مصادر بناء أندرويد Android"
#: editor/export_template_manager.cpp
msgid "Current Version:"
@@ -3586,14 +3577,12 @@ msgid "Remove Template"
msgstr "مسح القالب"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Select Template File"
msgstr "حدد مل٠القالب"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Godot Export Templates"
-msgstr "إدارة قوالب التصدير"
+msgstr "إدارة قوالب التصدير Godot"
#: editor/export_template_manager.cpp
msgid "Export Template Manager"
@@ -3604,14 +3593,12 @@ msgid "Download Templates"
msgstr "تنزيل القوالب"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Select mirror from list: (Shift+Click: Open in Browser)"
-msgstr "حدد السرÙر من القائمة: "
+msgstr "حدد السرÙر من القائمة: (Shift+Click: للÙتح ÙÙŠ المتصÙØ­)"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Favorites"
-msgstr "المÙضلة:"
+msgstr "المÙضلات"
#: editor/filesystem_dock.cpp
msgid "Status: Import of file failed. Please fix file and reimport manually."
@@ -3642,9 +3629,8 @@ msgid "No name provided."
msgstr "لا أسم Ù…Ùقدم."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Provided name contains invalid characters."
-msgstr "الأسم المÙقدم يحتوي علي حرو٠خاطئة"
+msgstr "الإسم المÙقدم يحتوي على أحر٠خاطئة."
#: editor/filesystem_dock.cpp
msgid "A file or folder with this name already exists."
@@ -3671,33 +3657,28 @@ msgid "Duplicating folder:"
msgstr "تكرار مجلد:"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Inherited Scene"
-msgstr "مشهد مورث جديد..."
+msgstr "مشهد Ù…Ùوّرَث جديد"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Set As Main Scene"
-msgstr "إختر المشهد الأساسي"
+msgstr "تعيين كمشهد أساسي"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Open Scenes"
-msgstr "Ùتح مشهد"
+msgstr "Ùتح المَشاهÙد"
#: editor/filesystem_dock.cpp
msgid "Instance"
msgstr "نموذج"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Add to Favorites"
-msgstr "المÙضلة:"
+msgstr "إضاÙØ© إلى المÙضلات"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Remove from Favorites"
-msgstr "حذ٠من المجموعة"
+msgstr "حذ٠من المÙضلات"
#: editor/filesystem_dock.cpp
msgid "Edit Dependencies..."
@@ -3720,29 +3701,24 @@ msgid "Move To..."
msgstr "تحريك إلي..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Scene..."
-msgstr "مشهد جديد"
+msgstr "مشهد جديد..."
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "New Script..."
-msgstr "Ùتح سريع للكود..."
+msgstr "Ùتح السكريبت..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Resource..."
-msgstr "Ø­Ùظ المورد باسم..."
+msgstr "مورد جديد..."
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Expand All"
msgstr "توسيع الكل"
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Collapse All"
msgstr "طوي الكل"
@@ -3754,28 +3730,24 @@ msgid "Rename"
msgstr "إعادة التسمية"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Previous Folder/File"
-msgstr "المجلد السابق"
+msgstr "‪المجلد/المل٠السابق"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Next Folder/File"
-msgstr "المجلد اللاحق"
+msgstr "المجلد/المل٠التالي"
#: editor/filesystem_dock.cpp
msgid "Re-Scan Filesystem"
msgstr "إعادة Ùحص نظام الملÙات"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Toggle Split Mode"
-msgstr "أظهر المود"
+msgstr "تعيين وضعية الإنقسام"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Search files"
-msgstr "إبحث ÙÙŠ الأصناÙ"
+msgstr "بحث الملÙات"
#: editor/filesystem_dock.cpp
msgid ""
@@ -3790,42 +3762,36 @@ msgid "Move"
msgstr "تحريك"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "There is already file or folder with the same name in this location."
-msgstr "مل٠أو مجلد مع هذا الأسم موجود بالÙعل."
+msgstr "يوجد بالÙعل مل٠أو مجلد بنÙس الاسم ÙÙŠ هذا المكان."
#: editor/filesystem_dock.cpp
msgid "Overwrite"
msgstr "الكتابة المÙتراكبة Overwrite"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Create Scene"
-msgstr "Ø­Ùظ المشهد"
+msgstr "إنشاء المشهد"
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
msgid "Create Script"
msgstr "إنشاء نص برمجي"
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Find in Files"
-msgstr "%d مزيد من الملÙات"
+msgstr "إبحث ÙÙŠ الملÙات"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Find:"
-msgstr "جد"
+msgstr "إيجاد:"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Folder:"
-msgstr "أنشئ مجلد"
+msgstr "مجلد:"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Filters:"
-msgstr "وضع المÙصÙÙŠ:"
+msgstr "Ùلتر:"
#: editor/find_in_files.cpp
msgid ""
@@ -3849,29 +3815,24 @@ msgid "Cancel"
msgstr "إلغاء"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Find: "
-msgstr "جد"
+msgstr "إيجاد: "
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Replace: "
-msgstr "إستبدال"
+msgstr "إستبدال:"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Replace all (no undo)"
-msgstr "إستبدال الكل"
+msgstr "إستبدال الكل (بلا تراجع)"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Searching..."
-msgstr "جاري الحÙظ..."
+msgstr "جاري البحث..."
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Search complete"
-msgstr "إبحث عن كتابة"
+msgstr "إكتمل البحث"
#: editor/groups_editor.cpp
msgid "Add to Group"
@@ -3882,57 +3843,49 @@ msgid "Remove from Group"
msgstr "حذ٠من المجموعة"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Group name already exists."
-msgstr "خطأ: إسم الحركة موجود بالÙعل!"
+msgstr "توجد مجموعة بهذا الاسم."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Invalid group name."
-msgstr "اسم غير صالح."
+msgstr "اسم المجموعة غير صالح."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Rename Group"
-msgstr "المجموعات"
+msgstr "إعادة تسمية المجموعة"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Delete Group"
-msgstr "مسح المخطط"
+msgstr "حذ٠المجموعة"
#: editor/groups_editor.cpp editor/node_dock.cpp
msgid "Groups"
msgstr "المجموعات"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Nodes Not in Group"
-msgstr "إضاÙØ© إلي مجموعة"
+msgstr "العÙقد خارج المجموعة"
#: editor/groups_editor.cpp editor/scene_tree_dock.cpp
#: editor/scene_tree_editor.cpp
msgid "Filter nodes"
-msgstr "العÙقد المÙرشحة Filter nodes"
+msgstr "تصÙية العÙقد"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Nodes in Group"
-msgstr "إضاÙØ© إلي مجموعة"
+msgstr "العÙقد ÙÙŠ المجموعة"
#: editor/groups_editor.cpp
msgid "Empty groups will be automatically removed."
-msgstr "ستزال المجموعات الÙارغة بصورة تلقائية."
+msgstr "ستزال المجموعات الÙارغة تلقائياً."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Group Editor"
-msgstr "Ùتح Ù…Ùعدل الكود"
+msgstr "محرر المجموعات"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Manage Groups"
-msgstr "المجموعات"
+msgstr "إدارة المجموعات"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Single Scene"
@@ -4008,6 +3961,10 @@ msgid "Error running post-import script:"
msgstr "خطأ ÙÙŠ تشغيل الكود الملصق- المستورد:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "جاري الحÙظ..."
@@ -4028,7 +3985,6 @@ msgid "Import As:"
msgstr "إستيراد كـ:"
#: editor/import_dock.cpp
-#, fuzzy
msgid "Preset"
msgstr "إعداد Ù…Ùسبق..."
@@ -4054,14 +4010,12 @@ msgid "Failed to load resource."
msgstr "Ùشل تحميل المورد."
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Expand All Properties"
-msgstr "توسيع كل التÙاصيل"
+msgstr "توسيع كل الخصائص"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Collapse All Properties"
-msgstr "طي كل التÙاصيل"
+msgstr "طي كل الخصائص"
#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
@@ -4073,9 +4027,8 @@ msgid "Copy Params"
msgstr "إنسخ المÙعامل"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Edit Resource Clipboard"
-msgstr "خطأ: لا مصدر حركة علي الحاÙظة!"
+msgstr "تحرير حاÙظة الموارد"
#: editor/inspector_dock.cpp
msgid "Copy Resource"
@@ -4122,9 +4075,8 @@ msgid "Object properties."
msgstr "خصائص العنصر."
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Filter properties"
-msgstr "خصائص العنصر."
+msgstr "تصÙية الخصائص"
#: editor/inspector_dock.cpp
msgid "Changes may be lost!"
@@ -4135,24 +4087,20 @@ msgid "MultiNode Set"
msgstr "تحديد عقد متعددة"
#: editor/node_dock.cpp
-#, fuzzy
msgid "Select a single node to edit its signals and groups."
-msgstr "حدد عقدة لكي تÙعدل الإشارات والمجموعات."
+msgstr "حدد عقدة لكي تÙعدل إشاراتها ومجموعاتها."
#: editor/plugin_config_dialog.cpp
-#, fuzzy
msgid "Edit a Plugin"
-msgstr "تعديل البولي"
+msgstr "تعديل إضاÙØ©"
#: editor/plugin_config_dialog.cpp
-#, fuzzy
msgid "Create a Plugin"
-msgstr "إنشاء حل C#‎"
+msgstr "إنشاء إضاÙØ©"
#: editor/plugin_config_dialog.cpp
-#, fuzzy
msgid "Plugin Name:"
-msgstr "إضاÙات"
+msgstr "اسم الإضاÙØ©:"
#: editor/plugin_config_dialog.cpp
msgid "Subfolder:"
@@ -4172,53 +4120,45 @@ msgstr "التÙعيل الآن؟"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Create Polygon"
-msgstr "إنشاء بولي"
+msgstr "إنشاء مضلع"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Create points."
-msgstr "مسح النقاط"
+msgstr "إنشاء نقاط."
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid ""
"Edit points.\n"
"LMB: Move Point\n"
"RMB: Erase Point"
msgstr ""
-"تعديل المضلعات الموجودة:\n"
-"زر الÙأرة الأيسر: لتحريك النقطة.\n"
-"Ctrl+زر الÙأرة الأيسر: لتقسيم الجزء.\n"
-"زر الÙأرة الأيمن: مسح النقطة."
+"تعديل النقاط.\n"
+"زر الÙأرة الأيسر: لتحريك النقطة\n"
+"زر الÙأرة الأيمن: مسح النقطة"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
msgid "Erase points."
-msgstr "زر الÙأرة الأيمن: مسح النقطة."
+msgstr "مسح النقاط."
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Edit Polygon"
-msgstr "تعديل البولي"
+msgstr "تعديل مضلع"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid "Insert Point"
msgstr "إدخال نقطة"
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Edit Polygon (Remove Point)"
-msgstr "تعديل البولي (مسح النقطة)"
+msgstr "تعديل المضلع (مسح النقطة)"
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Remove Polygon And Point"
-msgstr "مسح البولي والنقطة"
+msgstr "مسح المضلع والنقطة"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4232,15 +4172,13 @@ msgstr "أض٠حركة"
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Load..."
-msgstr "تحميل"
+msgstr "تحميل..."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Move Node Point"
-msgstr "مسح النقطة"
+msgstr "تحريك نقطة العقدة"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#, fuzzy
@@ -4261,9 +4199,8 @@ msgstr ""
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Node Point"
-msgstr "إضاÙØ© نقطة"
+msgstr "إضاÙØ© نقطة العقدة"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -7011,12 +6948,13 @@ msgstr "قطع إتصال'%s' من '%s'"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
-msgid "Line"
-msgstr "الخط:"
+msgid "[Ignore]"
+msgstr "(تجاهل)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(تجاهل)"
+#, fuzzy
+msgid "Line"
+msgstr "الخط:"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
@@ -7509,6 +7447,15 @@ msgid "XForm Dialog"
msgstr "ناÙذة XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "محاذاة العÙقد إلى الأرضية"
@@ -7963,7 +7910,7 @@ msgstr "الخطوة:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Sep.:"
-msgstr ""
+msgstr "الÙاصل:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "TextureRegion"
@@ -8050,7 +7997,7 @@ msgstr "عنصر Ù…ÙÙعل اختياري"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Named Sep."
-msgstr ""
+msgstr "الÙاصل المÙسمّى"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Submenu"
@@ -9195,9 +9142,8 @@ msgid "Scalar constant."
msgstr "ثابت الكمية القياسية Scalar constant."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar uniform."
-msgstr "تحويل تغيير التحريك"
+msgstr "الكمية القياسية المÙوحدة Scalar uniform."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Perform the cubic texture lookup."
@@ -9219,6 +9165,7 @@ msgstr "البحث عن النقش الموحد ثنائي البÙعد."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "2D texture uniform lookup with triplanar."
msgstr ""
+"البحث عن النقش ثنائي البÙعد الموحد باستخدام الإسقاط ثلاثي المستويات triplanar."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Transform function."
@@ -9234,6 +9181,13 @@ msgid ""
"whose number of rows is the number of components in 'c' and whose number of "
"columns is the number of components in 'r'."
msgstr ""
+"يحسب الجداء السلمي لزوج من المÙتجهات (الأشعة). \n"
+"\n"
+"يعامل OuterProduct (الجداء السلمي) المعامل الأول 'c' كمتجه عمودي (مصÙÙˆÙØ© "
+"بعمود واحد) بينما يعامل المعامل الثاني 'r' كمÙتجه Ø£Ùقي (مصÙÙˆÙØ© بص٠واحد) حيث "
+"يقوم بالجداء الجبري الخطي للمصÙÙˆÙتين بضرب 'c * r'ØŒ الأمر الذي ينتج عنه "
+"مصÙÙˆÙØ© عدد صÙÙˆÙها يساوي عدد مكونات 'c' وعدد الأعمدة Ùيها يكون عدد المكونات "
+"ÙÙŠ 'r'."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Composes transform from four vectors."
@@ -9306,6 +9260,11 @@ msgid ""
"incident vector, and Nref, the reference vector. If the dot product of I and "
"Nref is smaller than zero the return value is N. Otherwise -N is returned."
msgstr ""
+"ÙŠÙرجع المÙتجه (الشعاع) الذي يشير إلى ذات اتجاه المÙتجه المرجعي. ولدى هذه "
+"الوظيÙØ© البرمجية ثلاث مَعالم كمتجهات: NØŒ المÙتجه الموجه، IØŒ المÙتجه المÙسقط "
+"وأخيراً Nref الذي يمثل المÙوجه المرجعي. إذا كان الجداء السÙلمي dot product لكل "
+"من I ÙˆNref أصغر من الصÙر Ùإن القيمة المÙرجعة وقتها ستكون N. عدا ذلك سيتم "
+"إرجاع -N."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the length of a vector."
@@ -9323,25 +9282,27 @@ msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the normalize product of vector."
-msgstr ""
+msgstr "يحسب قيمة المÙتجه (الشعاع) نسبة للواحد normalize product."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "1.0 - vector"
-msgstr ""
+msgstr "1.0 - Ù…Ùتجه (شعاع)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "1.0 / vector"
-msgstr ""
+msgstr "1.0 \\ المÙتجه (الشعاع)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns the vector that points in the direction of reflection ( a : incident "
"vector, b : normal vector )."
msgstr ""
+"ÙŠÙرجع المÙتجه الذي يشير إلى باتجاه الانعكاس (Ø£: المÙتجه (الشعاع) المÙسقَط، ب: "
+"المÙتجه (الشعاع) الطبيعي)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the vector that points in the direction of refraction."
-msgstr ""
+msgstr "ÙŠÙرجع المÙتجه (الشعاع) الذي يشير باتجاه الانكسار."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9351,6 +9312,11 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n"
+"\n"
+"تÙرجع قيمة 0.0 إذا كان 'x' أصغر من 'edge0' Ùˆ 1.0 إذا كان 'x' أكبر من 'edge1'. "
+"بخلا٠ذلك القيمة المÙرجعة سيتم استيÙاؤها (استقراء داخلي) بين 0.0 Ùˆ1.0 "
+"باستخدام متعددات الحدود لهيرمت Hermite polynomials."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9360,6 +9326,11 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n"
+"\n"
+"تÙرجع قيمة 0.0 إذا كان 'x' أصغر من 'edge0' Ùˆ 1.0 إذا كان 'x' أكبر من 'edge1'. "
+"بخلا٠ذلك القيمة المÙرجعة سيتم استيÙاؤها (استقراء داخلي) بين 0.0 Ùˆ1.0 "
+"باستخدام متعددات الحدود لهيرمت Hermite polynomials."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9367,6 +9338,9 @@ msgid ""
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Step function( vector(edge), vector(x) ).\n"
+"\n"
+"ÙŠÙرجع القيمة 0.0 إذا كان 'x' أصغر من 'edge' وعدا ذلك ستÙرجع القيمة 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9374,10 +9348,13 @@ msgid ""
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Step function( scalar(edge), vector(x) ).\n"
+"\n"
+"ÙŠÙرجع القيمة 0.0 إذا كان 'x' أصغر من 'edge' وعدا ذلك ستÙرجع القيمة 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Adds vector to vector."
-msgstr ""
+msgstr "إضاÙØ© Ù…Ùتجه (شعاع) إلى Ù…Ùتجه (شعاع)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Divides vector by vector."
@@ -9385,19 +9362,19 @@ msgstr "ÙŠÙقسّم المÙتجه (الشعاع) على المÙتجه."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Multiplies vector by vector."
-msgstr ""
+msgstr "جداء (مضاعÙØ©) Ù…Ùتجه بمÙتجه."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the remainder of the two vectors."
-msgstr ""
+msgstr "ÙŠÙرجع باقي كل من المÙتجهين (الشعاعين)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Subtracts vector from vector."
-msgstr ""
+msgstr "طرح Ù…Ùتجه (شعاع) من Ù…Ùتجه."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector constant."
-msgstr ""
+msgstr "ثابت المÙتجه."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9410,12 +9387,18 @@ msgid ""
"output ports. This is a direct injection of code into the vertex/fragment/"
"light function, do not use it to write the function declarations inside."
msgstr ""
+"تعبير إصلاحي (لغوي) خاص بمÙظلل غودوت، بواسطة كمية Ù…Ùخصصة من مناÙØ° المÙدخلات "
+"والمÙخرجات. إنه إقحام مباشر للنص البرمجي ضمن الوظائ٠الخاصة بالقمة vertex/ "
+"بالجزء fragment/ بالضوء light ، لذا لا تستخدمها لكي تكتب تعري٠وتوضيح "
+"الوظيÙØ© البرمجية داخلها."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns falloff based on the dot product of surface normal and view "
"direction of camera (pass associated inputs to it)."
msgstr ""
+"ÙŠÙرجع الإسقاط المبني على الجداء السÙلمي لكل من السطح الطبيعي وتوجيه الكاميرا "
+"(يمرر المÙدخلات المرتبطة بها)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9424,50 +9407,67 @@ msgid ""
"it later in the Expressions. You can also declare varyings, uniforms and "
"constants."
msgstr ""
+"تعبير (إصطلاحي) لغوي خاص بمÙظلل غودوت، والذي يكون أعلى المÙظلل الناتج. يمكنك "
+"أن تضع تعريÙات وظيÙية برمجية مختلÙØ© ضمنه واستدعاءها لاحقاً ÙÙŠ التعابير عنها. "
+"كما يمكنك أيضاً أن تÙصرّح (تعرّÙ) عن المتحولات، الموحدات (uniforms)ØŒ وكذلك "
+"الثوابت."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "(Fragment/Light mode only) Scalar derivative function."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) وظيÙية برمجية اشتقاقية للكمية القياسية "
+"Scalar."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "(Fragment/Light mode only) Vector derivative function."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) وظيÙية برمجية اشتقاقية للمÙتجه (الشعاع)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Vector) Derivative in 'x' using local "
"differencing."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) (Ù…Ùتجه) Ù…Ùشتق ÙÙŠ 'x' باستخدام الاختلاÙات "
+"المحلية."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Scalar) Derivative in 'x' using local "
"differencing."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) (كمية قياسية Scalar) Ù…Ùشتقة ÙÙŠ 'x' باستخدام "
+"الاختلاÙات المحلية."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Vector) Derivative in 'y' using local "
"differencing."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) (Ù…Ùتجه) Ù…Ùشتق ÙÙŠ 'y' باستخدام الاختلاÙات "
+"المحلية."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Scalar) Derivative in 'y' using local "
"differencing."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) (كمية قياسية Scalar) Ù…Ùشتقة ÙÙŠ 'y' باستخدام "
+"الاختلاÙات المحلية."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and "
"'y'."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) (Ù…Ùتجه)مجموع الاشتقاق المÙطلق ÙÙŠ 'x' Ùˆ 'y'."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and "
"'y'."
msgstr ""
+"(Ùقط وضع القÙطع Fragment/ الضوء) (كمية قياسية Scalar) Ù…Ùشتق Ù…Ùطلق ÙÙŠ 'x' Ùˆ'y'."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "VisualShader"
@@ -9863,6 +9863,14 @@ msgid ""
"Warning: You won't be able to open the project with previous versions of the "
"engine anymore."
msgstr ""
+"إن مل٠إعدادت المشروع المرÙÙ‚ لا ÙŠÙحدد نسخة غودوت التي تم بناؤه بها. \n"
+"\n"
+"%s\n"
+"\n"
+"إن أصريت على Ùتحه، سيتم تحويله لبنية مل٠التهيئة (التكوين) الحالي الخاص "
+"بغودوت. \n"
+"تحذير: لن تعد قادارً على Ùتح المشروع باستخدام النÙسخ السابقة من المÙحرك بعد "
+"الآن."
#: editor/project_manager.cpp
msgid ""
@@ -9875,6 +9883,13 @@ msgid ""
"Warning: You won't be able to open the project with previous versions of the "
"engine anymore."
msgstr ""
+"إن مل٠إعدادات المشروع المرÙÙ‚ كان قد تم إنشاؤه باستخدام إصدار أقدم من "
+"المحرك، لذا إنه بحاجة لتحويله إلى النسخة الحالية:\n"
+"\n"
+"%s\n"
+"\n"
+"هل ترغب ÙÙŠ تحويله؟\n"
+"تحذير: لن تعد قادراً على Ùتح المشروع بالنÙسخ السابقة من المÙحرك بعد الآن."
#: editor/project_manager.cpp
msgid ""
@@ -9999,6 +10014,9 @@ msgid ""
"To filter projects by name and full path, the query must contain at least "
"one `/` character."
msgstr ""
+"صندوق البحث ÙŠÙرشح (ÙŠÙغربل) المشاريع ÙˆÙقاً للاسم Ùˆ مكون المسار الأخير.\n"
+"لتشريح (غربلة) المشاريع باستخدام الاسم والمسار الكامل، يجب أن تحتوي المبحوث "
+"عنه query على الأقل حر٠`/` واحد."
#: editor/project_settings_editor.cpp
msgid "Key "
@@ -10021,8 +10039,8 @@ msgid ""
"Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'"
msgstr ""
-"اسم Ùعالية غير صحيح. لا يمكن أن يكون Ùارغاً أو أو يتضمن '/'ØŒ ':'ØŒ '='ØŒ '\\' "
-"أو '\"'"
+"اسم Ùعالية غير صحيح. لا يمكن أن يكون Ùارغاً أو يتضمن '/'ØŒ ':'ØŒ '='ØŒ '\\' أو "
+"'\"'"
#: editor/project_settings_editor.cpp
msgid "An action with the name '%s' already exists."
@@ -10086,27 +10104,27 @@ msgstr "زر العجلة يميناً"
#: editor/project_settings_editor.cpp
msgid "X Button 1"
-msgstr ""
+msgstr "زر X 1"
#: editor/project_settings_editor.cpp
msgid "X Button 2"
-msgstr ""
+msgstr "زر X 2"
#: editor/project_settings_editor.cpp
msgid "Joypad Axis Index:"
-msgstr ""
+msgstr "مؤشر محور القبضة Joypad :"
#: editor/project_settings_editor.cpp
msgid "Axis"
-msgstr ""
+msgstr "محاور"
#: editor/project_settings_editor.cpp
msgid "Joypad Button Index:"
-msgstr ""
+msgstr "مؤشر زر القبضة Joypad:"
#: editor/project_settings_editor.cpp
msgid "Erase Input Action"
-msgstr ""
+msgstr "مسح إجراء الإدخال"
#: editor/project_settings_editor.cpp
msgid "Erase Input Action Event"
@@ -10203,19 +10221,19 @@ msgstr "إضاÙØ© مسار Ù…Ùعاد تعيينه Remapped"
#: editor/project_settings_editor.cpp
msgid "Resource Remap Add Remap"
-msgstr ""
+msgstr "مورد إعادة رسم الخريطة ÙŠÙضي٠إعادة رسم خريطة"
#: editor/project_settings_editor.cpp
msgid "Change Resource Remap Language"
-msgstr ""
+msgstr "تغيير لغة مورد إعادة تعيين الخريطة"
#: editor/project_settings_editor.cpp
msgid "Remove Resource Remap"
-msgstr ""
+msgstr "إزالة مورد إعادة تعيين الخريطة"
#: editor/project_settings_editor.cpp
msgid "Remove Resource Remap Option"
-msgstr ""
+msgstr "إزالة إعداد مورد إعادة تعيين الخريطة"
#: editor/project_settings_editor.cpp
msgid "Changed Locale Filter"
@@ -10223,7 +10241,7 @@ msgstr "Ù…Ùرشح محلي Ù…Ùعدّل"
#: editor/project_settings_editor.cpp
msgid "Changed Locale Filter Mode"
-msgstr ""
+msgstr "وضع المÙرشح (المÙغربل) المحلي المÙعدّل"
#: editor/project_settings_editor.cpp
msgid "Project Settings (project.godot)"
@@ -10279,7 +10297,7 @@ msgstr "الترجمات:"
#: editor/project_settings_editor.cpp
msgid "Remaps"
-msgstr ""
+msgstr "إعادة تعيين الخرائط"
#: editor/project_settings_editor.cpp
msgid "Resources:"
@@ -10343,7 +10361,7 @@ msgstr "ملÙ..."
#: editor/property_editor.cpp
msgid "Dir..."
-msgstr ""
+msgstr "مسار..."
#: editor/property_editor.cpp
msgid "Assign"
@@ -10454,13 +10472,15 @@ msgstr "مقدار الزيادة للعداد لكل عÙقدة"
#: editor/rename_dialog.cpp
msgid "Padding"
-msgstr ""
+msgstr "الحدود المÙبطنة Padding"
#: editor/rename_dialog.cpp
msgid ""
"Minimum number of digits for the counter.\n"
"Missing digits are padded with leading zeros."
msgstr ""
+"أصغر عدد خانات للعداد.\n"
+"الخانات الناقصة ستعوض padded بأصÙار قياسية."
#: editor/rename_dialog.cpp
msgid "Post-Process"
@@ -10566,8 +10586,9 @@ msgid "Instance Child Scene"
msgstr "نمذجة المشهد الابن"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "إخلاء الكود"
+#, fuzzy
+msgid "Detach Script"
+msgstr "إلحاق نص برمجي"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10736,6 +10757,13 @@ msgid "Open Documentation"
msgstr "ÙÙتح مؤخراً"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "إضاÙØ© عÙقدة ابن"
@@ -10788,11 +10816,13 @@ msgstr ""
"موروث."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "إلحاق نص برمجي موجود أو جديد للعÙقدة المختارة."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "مسح النص البرمجي للعÙقدة المختارة."
#: editor/scene_tree_dock.cpp
@@ -10829,86 +10859,95 @@ msgstr "خطأ ÙÙŠ الإتصال"
#: editor/scene_tree_editor.cpp
msgid "Node configuration warning:"
-msgstr ""
+msgstr "تحذير تهيئة العÙقدة:"
#: editor/scene_tree_editor.cpp
msgid ""
"Node has %s connection(s) and %s group(s).\n"
"Click to show signals dock."
msgstr ""
+"تملك هذه العÙقدة %s اتصال(ات) Ùˆ %s مجموعة(مجموعات).\n"
+"اضغط لإظهار رصي٠(ميناء) الإشارات."
#: editor/scene_tree_editor.cpp
msgid ""
"Node has %s connection(s).\n"
"Click to show signals dock."
msgstr ""
+"تملك العÙقدة %s اتصال(ات).\n"
+"اضغط لإظهار رصي٠(ميناء) الإشارات."
#: editor/scene_tree_editor.cpp
msgid ""
"Node is in %s group(s).\n"
"Click to show groups dock."
msgstr ""
+"العÙقدة ضمن %s مجموعة(مجموعات).\n"
+"اضغط لإظهار رصي٠(ميناء) المجموعات."
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Open Script:"
-msgstr "Ùتح الكود"
+msgstr "Ùتح النص البرمجي:"
#: editor/scene_tree_editor.cpp
msgid ""
"Node is locked.\n"
"Click to unlock it."
msgstr ""
+"إن العÙقدة مقÙولة. \n"
+"اضغط Ù„Ùكّ القÙÙ„."
#: editor/scene_tree_editor.cpp
msgid ""
"Children are not selectable.\n"
"Click to make selectable."
msgstr ""
+"الابن غير قابل للاختيار.\n"
+"اضغط لجعله قابلاً للاختيار."
#: editor/scene_tree_editor.cpp
msgid "Toggle Visibility"
-msgstr ""
+msgstr "تشغيل/إطÙاء الوضوحية Visibility"
#: editor/scene_tree_editor.cpp
msgid ""
"AnimationPlayer is pinned.\n"
"Click to unpin."
msgstr ""
+"تم تعليق Ù…Ùشغل الرسومات المÙتحركة.\n"
+"اضغط لإزالة تعليقه."
#: editor/scene_tree_editor.cpp
msgid "Invalid node name, the following characters are not allowed:"
-msgstr ""
+msgstr "اسم عÙقدة غير صالح، إن الأحر٠التالية غير مسموحة:"
#: editor/scene_tree_editor.cpp
msgid "Rename Node"
-msgstr ""
+msgstr "إعادة تسمية العÙقدة"
#: editor/scene_tree_editor.cpp
msgid "Scene Tree (Nodes):"
-msgstr ""
+msgstr "شجرة المشهد (العÙقد):"
#: editor/scene_tree_editor.cpp
msgid "Node Configuration Warning!"
-msgstr ""
+msgstr "تحذير تهيئة العÙقدة!"
#: editor/scene_tree_editor.cpp
msgid "Select a Node"
-msgstr ""
+msgstr "اختر عÙقدة"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Path is empty."
-msgstr "الميش Ùارغ!"
+msgstr "المسار Ùارغ!."
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Filename is empty."
-msgstr "الميش Ùارغ!"
+msgstr "اسم المل٠Ùارغ."
#: editor/script_create_dialog.cpp
msgid "Path is not local."
-msgstr ""
+msgstr "المسار ليس محلياً."
#: editor/script_create_dialog.cpp
#, fuzzy
@@ -10921,57 +10960,61 @@ msgid "A directory with the same name exists."
msgstr "مل٠أو مجلد مع هذا الأسم موجود بالÙعل."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "المل٠غير موجود."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "يجب أن يستخدم صيغة صحيحة."
#: editor/script_create_dialog.cpp
msgid "Wrong extension chosen."
-msgstr ""
+msgstr "لاحقة Ù…Ùختارة غير مناسبة."
#: editor/script_create_dialog.cpp
msgid "Error loading template '%s'"
-msgstr ""
+msgstr "خطأ ÙÙŠ تحميل القالب '%s'"
#: editor/script_create_dialog.cpp
msgid "Error - Could not create script in filesystem."
-msgstr ""
+msgstr "خطأ - Ùشل إنشاء النص البرمجي ÙÙŠ نظام الملÙات filesystem."
#: editor/script_create_dialog.cpp
msgid "Error loading script from %s"
-msgstr ""
+msgstr "خطأ ÙÙŠ تحميل النص البرمجي من %s"
#: editor/script_create_dialog.cpp
msgid "Overrides"
-msgstr ""
+msgstr "يتجاوز"
#: editor/script_create_dialog.cpp
msgid "N/A"
-msgstr ""
+msgstr "غير متواÙÙ‚ N/A"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Open Script / Choose Location"
-msgstr "Ùتح Ù…Ùعدل الكود"
+msgstr "Ùتح النص البرمجي / انتقاء الموقع"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Open Script"
-msgstr "Ùتح الكود"
+msgstr "Ùتح النص البرمجي"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "File exists, it will be reused."
-msgstr "المل٠موجود، سيعاد إستخدامه"
+msgstr "إن المل٠موجود، سيعاد إستخدامه."
+
+#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "مسار غير صالح."
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Invalid class name."
-msgstr "إسم صن٠غير صالح"
+msgstr "إسم ص٠غير صالح."
#: editor/script_create_dialog.cpp
msgid "Invalid inherited parent name or path."
-msgstr ""
+msgstr "إن اسم أو مسار الأب (الأصل parent) الموروث غير صالح."
#: editor/script_create_dialog.cpp
#, fuzzy
@@ -10980,7 +11023,7 @@ msgstr "شجرة الحركة صحيحة."
#: editor/script_create_dialog.cpp
msgid "Allowed: a-z, A-Z, 0-9, _ and ."
-msgstr ""
+msgstr "المسموح: a-z، A-Z ، 0-9 ، _ و ."
#: editor/script_create_dialog.cpp
#, fuzzy
@@ -11007,6 +11050,8 @@ msgid ""
"Note: Built-in scripts have some limitations and can't be edited using an "
"external editor."
msgstr ""
+"ملاحظة: النصوص البرمجية المبنية ضمناً تملك مقيدة ولها إمكانيات محددة ولا يمكن "
+"تعديلها باستخدام Ù…Ùحرر خارجي."
#: editor/script_create_dialog.cpp
#, fuzzy
@@ -11025,7 +11070,7 @@ msgstr "Ùتح الكود"
#: editor/script_create_dialog.cpp
msgid "Attach Node Script"
-msgstr ""
+msgstr "ألحق نص برمجي للعÙقدة"
#: editor/script_editor_debugger.cpp
msgid "Remote "
@@ -11033,7 +11078,7 @@ msgstr "من بعد "
#: editor/script_editor_debugger.cpp
msgid "Bytes:"
-msgstr ""
+msgstr "Bytes:"
#: editor/script_editor_debugger.cpp
#, fuzzy
@@ -11072,11 +11117,11 @@ msgstr "مورد"
#: editor/script_editor_debugger.cpp
msgid "Stack Trace"
-msgstr ""
+msgstr "تتبع المÙكدس Stack Trace"
#: editor/script_editor_debugger.cpp
msgid "Errors"
-msgstr ""
+msgstr "أخطاء"
#: editor/script_editor_debugger.cpp
#, fuzzy
@@ -11089,7 +11134,7 @@ msgstr "خطأ ÙÙŠ نسخ"
#: editor/script_editor_debugger.cpp
msgid "Video RAM"
-msgstr ""
+msgstr "ذاكرة الÙيديو Video RAM"
#: editor/script_editor_debugger.cpp
#, fuzzy
@@ -11098,19 +11143,19 @@ msgstr "مسح النقاط"
#: editor/script_editor_debugger.cpp
msgid "Inspect Previous Instance"
-msgstr ""
+msgstr "تÙحص النمذجة السابقة"
#: editor/script_editor_debugger.cpp
msgid "Inspect Next Instance"
-msgstr ""
+msgstr "تÙحص النمذجة التالية"
#: editor/script_editor_debugger.cpp
msgid "Stack Frames"
-msgstr ""
+msgstr "حزم الإطارات Stack Frames"
#: editor/script_editor_debugger.cpp
msgid "Profiler"
-msgstr ""
+msgstr "Ù…Ùنشئ الملÙات التعريÙية Profiler"
#: editor/script_editor_debugger.cpp
msgid "Network Profiler"
@@ -11118,27 +11163,27 @@ msgstr "مل٠تعري٠الشبكة Network Profiler"
#: editor/script_editor_debugger.cpp
msgid "Monitor"
-msgstr ""
+msgstr "المراقب Monitor"
#: editor/script_editor_debugger.cpp
msgid "Value"
-msgstr ""
+msgstr "القيمة"
#: editor/script_editor_debugger.cpp
msgid "Monitors"
-msgstr ""
+msgstr "المراقبون Monitors"
#: editor/script_editor_debugger.cpp
msgid "Pick one or more items from the list to display the graph."
-msgstr ""
+msgstr "اختر واحدة أو كثر من العناصر ÙÙŠ القائمة لعرض الرسم البياني graph."
#: editor/script_editor_debugger.cpp
msgid "List of Video Memory Usage by Resource:"
-msgstr ""
+msgstr "قائمة باستخدام ذاكرة الÙيديو لكل من الموارد:"
#: editor/script_editor_debugger.cpp
msgid "Total:"
-msgstr ""
+msgstr "المجموع الكلي:"
#: editor/script_editor_debugger.cpp
#, fuzzy
@@ -11147,35 +11192,35 @@ msgstr "تصدير الملÙ"
#: editor/script_editor_debugger.cpp
msgid "Resource Path"
-msgstr ""
+msgstr "مسار المورد"
#: editor/script_editor_debugger.cpp
msgid "Type"
-msgstr ""
+msgstr "النوع"
#: editor/script_editor_debugger.cpp
msgid "Format"
-msgstr ""
+msgstr "البنية (اللاحقة)"
#: editor/script_editor_debugger.cpp
msgid "Usage"
-msgstr ""
+msgstr "الاستخدام"
#: editor/script_editor_debugger.cpp
msgid "Misc"
-msgstr ""
+msgstr "المتنوعات Misc"
#: editor/script_editor_debugger.cpp
msgid "Clicked Control:"
-msgstr ""
+msgstr "التحكم بالنقر Clicked Control:"
#: editor/script_editor_debugger.cpp
msgid "Clicked Control Type:"
-msgstr ""
+msgstr "نوع التحكم بالنقر Clicked Control:"
#: editor/script_editor_debugger.cpp
msgid "Live Edit Root:"
-msgstr ""
+msgstr "جذر التعديل المباشر:"
#: editor/script_editor_debugger.cpp
msgid "Set From Tree"
@@ -11218,10 +11263,11 @@ msgstr "تغيير نص٠قطر الإنارة"
#: editor/spatial_editor_gizmos.cpp
msgid "Change AudioStreamPlayer3D Emission Angle"
msgstr ""
+"تعديل زاوية انبعاث (إصدار) Ù…Ùشغل الصوت ثلاثي الأبعاد AudioStreamPlayer3D"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Camera FOV"
-msgstr ""
+msgstr "تعديل حقل رؤية الكاميرا Camera FOV"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Camera Size"
@@ -11229,43 +11275,43 @@ msgstr "غيّر حجم الكاميرا"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Notifier AABB"
-msgstr ""
+msgstr "تعديل Notifier AABB"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Particles AABB"
-msgstr ""
+msgstr "تعديل جÙزيئات AABB"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Probe Extents"
-msgstr ""
+msgstr "تعديل نطاقات المسبر Probe Extents"
#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
msgid "Change Sphere Shape Radius"
-msgstr ""
+msgstr "تعديل نص٠قطر الشكل الكروي"
#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
msgid "Change Box Shape Extents"
-msgstr ""
+msgstr "تعديل حجم الشكل الصندوقي"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Capsule Shape Radius"
-msgstr ""
+msgstr "تعديل نص٠قطر الشكل الكبسولي Capsule Shape"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Capsule Shape Height"
-msgstr ""
+msgstr "تعديل ارتÙاع الشكل الكبسولي Capsule Shape"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Cylinder Shape Radius"
-msgstr ""
+msgstr "تعديل نص٠قطر الشكل الأسطواني"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Cylinder Shape Height"
-msgstr ""
+msgstr "تعديل ارتÙاع الشكل الأسطواني"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Ray Shape Length"
-msgstr ""
+msgstr "تعديل طول الشكل الشعاعي"
#: modules/csg/csg_gizmos.cpp
#, fuzzy
@@ -11284,15 +11330,15 @@ msgstr "تغيير المرتكزات و الهوامش"
#: modules/csg/csg_gizmos.cpp
msgid "Change Torus Outer Radius"
-msgstr ""
+msgstr "تعديل نص٠القطر الخارجي للطارة Torus Outer Radius"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Select the dynamic library for this entry"
-msgstr ""
+msgstr "اختر المكتبة المطاوعة (الديناميكية) لأجل هذا الإدخال"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Select dependencies of the library for this entry"
-msgstr ""
+msgstr "اختر تبعيات المكتبة لأجل هذا الإدخال"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Remove current entry"
@@ -11300,31 +11346,31 @@ msgstr "مسح المدخلة الحالية"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Double click to create a new entry"
-msgstr ""
+msgstr "الضغط المزدوج لإنشاء إدخال جديد"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Platform:"
-msgstr ""
+msgstr "المنصة:"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Platform"
-msgstr ""
+msgstr "منصة"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Dynamic Library"
-msgstr ""
+msgstr "مكتبة مطاوعة (ديناميكية)"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Add an architecture entry"
-msgstr ""
+msgstr "إضاÙØ© إدخال معماري architecture entry"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "GDNativeLibrary"
-msgstr ""
+msgstr "مكتبة GDNativeLibrary"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Enabled GDNative Singleton"
-msgstr ""
+msgstr "تمكين نمط البرمجة Singleton ل٠GDNative"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
#, fuzzy
@@ -11333,15 +11379,15 @@ msgstr "تعطيل دوار التحديث"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Library"
-msgstr ""
+msgstr "مكتبة"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Libraries: "
-msgstr ""
+msgstr "مكتبات: "
#: modules/gdnative/register_types.cpp
msgid "GDNative"
-msgstr ""
+msgstr "GDNative"
#: modules/gdscript/gdscript_functions.cpp
#, fuzzy
@@ -11383,7 +11429,7 @@ msgstr "مجسّد القاموس غير صالح (أصنا٠Ùرعية غير
#: modules/gdscript/gdscript_functions.cpp
msgid "Object can't provide a length."
-msgstr ""
+msgstr "لا يمكن للكائن Object أن يمنح طولاً."
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
@@ -11397,23 +11443,23 @@ msgstr "التبويب السابق"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Plane:"
-msgstr ""
+msgstr "المستوى:"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Next Floor"
-msgstr ""
+msgstr "الطابق التالي"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Previous Floor"
-msgstr ""
+msgstr "الطابق السابق"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Floor:"
-msgstr ""
+msgstr "الطابق:"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "GridMap Delete Selection"
-msgstr ""
+msgstr "خريطة الشبكة GridMap لحذ٠المÙختار"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
@@ -11427,67 +11473,67 @@ msgstr "ÙƒÙÙ„ المÙحدد"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "GridMap Paint"
-msgstr ""
+msgstr "تلوين (طلاء) خريطة الشبكة GridMap"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Grid Map"
-msgstr ""
+msgstr "خريطة الشبكة"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Snap View"
-msgstr ""
+msgstr "مظهر المحاذاة"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clip Disabled"
-msgstr ""
+msgstr "القص Clip Ù…Ùعطّل"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clip Above"
-msgstr ""
+msgstr "القص Clip أعلاه"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clip Below"
-msgstr ""
+msgstr "القص Clip أدناه"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Edit X Axis"
-msgstr ""
+msgstr "تعديل المحور X"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Edit Y Axis"
-msgstr ""
+msgstr "تعديل المحور Y"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Edit Z Axis"
-msgstr ""
+msgstr "تعديل المحور Z"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Rotate X"
-msgstr ""
+msgstr "تدوير المؤشر X"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Rotate Y"
-msgstr ""
+msgstr "تدوير المؤشر Y"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Rotate Z"
-msgstr ""
+msgstr "تدوير المؤشر Z"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Back Rotate X"
-msgstr ""
+msgstr "تدوير المؤشر عكساً على X"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Back Rotate Y"
-msgstr ""
+msgstr "تدوير المؤشر عكساً على Y"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Back Rotate Z"
-msgstr ""
+msgstr "تدوير المؤشر عكساً على Z"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Clear Rotation"
-msgstr ""
+msgstr "مسح تدوير المؤشر"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
@@ -11504,11 +11550,11 @@ msgstr "تعبئة المÙحدد"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "GridMap Settings"
-msgstr ""
+msgstr "إعدادات خريطة الشبكة"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Pick Distance:"
-msgstr ""
+msgstr "اختر المساÙØ©:"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
@@ -11518,18 +11564,20 @@ msgstr "وضع المÙصÙÙŠ:"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Give a MeshLibrary resource to this GridMap to use its meshes."
msgstr ""
+"امنح مكتبة السطوح MeshLibrary وصولاً لخريطة الشبكة لتستخدم السطوح المجسمة "
+"الخاصة بها meshes."
#: modules/mono/csharp_script.cpp
msgid "Class name can't be a reserved keyword"
-msgstr ""
+msgstr "لا يمكن أن يكون اسم الص٠كلمة محجوزة"
#: modules/mono/mono_gd/gd_mono_utils.cpp
msgid "End of inner exception stack trace"
-msgstr ""
+msgstr "نهاية تتبع مكدس الاستثناء الداخلي"
#: modules/recast/navigation_mesh_editor_plugin.cpp
msgid "Bake NavMesh"
-msgstr ""
+msgstr "اطبخ شبكة ملاحة"
#: modules/recast/navigation_mesh_editor_plugin.cpp
msgid "Clear the navigation mesh."
@@ -11592,26 +11640,29 @@ msgid ""
"A node yielded without working memory, please read the docs on how to yield "
"properly!"
msgstr ""
+"عقدة Ø­ÙصÙلت بدون ذاكرة Ùعالة,الرجاء قراءة الدليل عن كيÙية تحصيلها بطريقة صحيحة!"
#: modules/visual_script/visual_script.cpp
msgid ""
"Node yielded, but did not return a function state in the first working "
"memory."
-msgstr ""
+msgstr "العقدة Ø­ÙصÙلت,ولكنها لم ترجع حالة الوظيÙØ© ÙÙŠ اول ذاكرة Ùعالة."
#: modules/visual_script/visual_script.cpp
msgid ""
"Return value must be assigned to first element of node working memory! Fix "
"your node please."
msgstr ""
+"يجب أن تكون القيمة المÙرجهة مقرونة بالعنصر الأول من العÙقدة العاملة بالذاكرة! "
+"أصلح العقدة من Ùضلك."
#: modules/visual_script/visual_script.cpp
msgid "Node returned an invalid sequence output: "
-msgstr ""
+msgstr "أرجعت العÙقدة تسلسلاً Ù…Ùخرجاً غير صالح: "
#: modules/visual_script/visual_script.cpp
msgid "Found sequence bit but not the node in the stack, report bug!"
-msgstr ""
+msgstr "عثر على تسلسل بت ولكن ليس العقدة ÙÙŠ المكدس ,ارÙع تقرير عن الخطأ!"
#: modules/visual_script/visual_script.cpp
msgid "Stack overflow with stack depth: "
@@ -11619,23 +11670,23 @@ msgstr ""
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Signal Arguments"
-msgstr ""
+msgstr "تعديل معاملات الإشارات"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Argument Type"
-msgstr ""
+msgstr "تعديل نوع المعامل"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Argument name"
-msgstr ""
+msgstr "تعديل اسم المعامل"
#: modules/visual_script/visual_script_editor.cpp
msgid "Set Variable Default Value"
-msgstr ""
+msgstr "تحديد القيمة الاÙتراضية للمتغير"
#: modules/visual_script/visual_script_editor.cpp
msgid "Set Variable Type"
-msgstr ""
+msgstr "تحيد نوع المتغير"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11659,7 +11710,7 @@ msgstr "إنشاء %s جديد"
#: modules/visual_script/visual_script_editor.cpp
msgid "Variables:"
-msgstr ""
+msgstr "المتغيرات:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11677,27 +11728,27 @@ msgstr "أنشئ شكل جديد من لا شئ."
#: modules/visual_script/visual_script_editor.cpp
msgid "Name is not a valid identifier:"
-msgstr ""
+msgstr "هذا الاسم ليس Ù…ÙعرÙاً مميزاً صالحاً:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Name already in use by another func/var/signal:"
-msgstr ""
+msgstr "لقد تم استخدام هذا الاسم ÙÙŠ وظيÙØ© برمجية/ Ù…Ùتغيّر/ إشارة، من قبل:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Rename Function"
-msgstr ""
+msgstr "إعادة تسمية الوظيÙØ© البرمجية"
#: modules/visual_script/visual_script_editor.cpp
msgid "Rename Variable"
-msgstr ""
+msgstr "إعادة تسمية المÙتغيّر"
#: modules/visual_script/visual_script_editor.cpp
msgid "Rename Signal"
-msgstr ""
+msgstr "إعادة تسمية الإشارة"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Function"
-msgstr ""
+msgstr "إضاÙØ© وظيÙØ© برمجية"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11706,11 +11757,11 @@ msgstr "مسح النقطة"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Variable"
-msgstr ""
+msgstr "إضاÙØ© Ù…Ùتغيّر"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Signal"
-msgstr ""
+msgstr "إضاÙØ© إشارة"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11724,65 +11775,72 @@ msgstr "مسح النقطة"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Expression"
-msgstr ""
+msgstr "تعديل التعبير"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove VisualScript Nodes"
-msgstr ""
+msgstr "إزالة عÙقد البرمجة البصرية VisualScript"
#: modules/visual_script/visual_script_editor.cpp
msgid "Duplicate VisualScript Nodes"
-msgstr ""
+msgstr "Ù…ÙضاعÙØ© عÙقد البرمجة البصرية VisualScript"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a Getter. Hold Shift to drop a generic signature."
msgstr ""
+"اضغط مطولاً %s لإسقاط جالب Getter. اضغط مطولاً على Shift لإسقاط توقيع عام "
+"generic signature."
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."
msgstr ""
+"اضغط مطولاً على Ctrl لإسقاط جالب Getter. اضغط مطولاً على Shift لإسقاط توقيع "
+"عام generic signature."
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a simple reference to the node."
-msgstr ""
+msgstr "اضغط مطولاً على %s لإسقاط مرجعية بسيطة للعÙقدة."
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold Ctrl to drop a simple reference to the node."
-msgstr ""
+msgstr "اضغط مطولاً على Ctrl لإسقاط مرجعية بسيطة للعÙقدة."
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a Variable Setter."
-msgstr ""
+msgstr "اضغط مطولاً على %s لإسقاط Ù…Ùحدد المÙتغير Variable Setter."
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold Ctrl to drop a Variable Setter."
-msgstr ""
+msgstr "اضغط مطولاً على Ctrl لإسقاط Ù…Ùحدد المÙتغيّر Variable Setter."
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Preload Node"
-msgstr ""
+msgstr "إضاÙØ© عÙقدة مسبقة التحميل"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Node(s) From Tree"
-msgstr ""
+msgstr "إضاÙØ© عÙقدة (عÙقد) من الشجرة"
#: modules/visual_script/visual_script_editor.cpp
msgid ""
"Can't drop properties because script '%s' is not used in this scene.\n"
"Drop holding 'Shift' to just copy the signature."
msgstr ""
+"لا يمكن إضاÙØ© (إسقاط) الخاصيات لأن النص البرمجي '%s' ليس موجوداً ÙÙŠ هذا "
+"المشهد.\n"
+"للإضاÙØ© (للإسقاط) اضغط مطولاً 'Shift' ببساطة لنسخ التوقيع signature."
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Getter Property"
-msgstr ""
+msgstr "إضاÙية خاصية جالب Getter Property"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Setter Property"
-msgstr ""
+msgstr "إضاÙØ© خاصية Ù…Ùحدد Setter Property"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Base Type"
-msgstr ""
+msgstr "تعديل النوع الأساس"
#: modules/visual_script/visual_script_editor.cpp
msgid "Move Node(s)"
@@ -11790,11 +11848,11 @@ msgstr "تحريك العقدة(عقدات)"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove VisualScript Node"
-msgstr ""
+msgstr "إزالة عÙقدة البرمجة البصرية VisualScript"
#: modules/visual_script/visual_script_editor.cpp
msgid "Connect Nodes"
-msgstr ""
+msgstr "وصل العÙقد"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11813,11 +11871,11 @@ msgstr "صلها بالعقدة:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Script already has function '%s'"
-msgstr ""
+msgstr "يملك النص البرمجي سلÙاً الوظيÙØ© البرمجية '%s'"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Input Value"
-msgstr ""
+msgstr "تعديل قيمة الإدخال"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11826,31 +11884,32 @@ msgstr "تعديل العنصر القماشي"
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't copy the function node."
-msgstr ""
+msgstr "لا يمكن نسخ الوظيÙØ© البرمجية للعÙقدة."
#: modules/visual_script/visual_script_editor.cpp
msgid "Clipboard is empty!"
-msgstr ""
+msgstr "الحاÙظة Ùارغة!"
#: modules/visual_script/visual_script_editor.cpp
msgid "Paste VisualScript Nodes"
-msgstr ""
+msgstr "لصق عÙقد البرمجة البصرية VisualScript"
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't create function with a function node."
-msgstr ""
+msgstr "لا يمكن إنشاء وظيÙØ© برمجية من دون عÙقدة وظيÙية."
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't create function of nodes from nodes of multiple functions."
msgstr ""
+"لا يمكن إنشاء وظيÙØ© برمجية لعÙقد من عÙقد تابعة للعديد من الوظائ٠البرمجية."
#: modules/visual_script/visual_script_editor.cpp
msgid "Select at least one node with sequence port."
-msgstr ""
+msgstr "اختر على الأقل واحدة من العقد التي تملك منÙØ° تسلسل sequence port."
#: modules/visual_script/visual_script_editor.cpp
msgid "Try to only have one sequence input in selection."
-msgstr ""
+msgstr "حاول أن يكون لديك تسلسل إدخال واحد من المÙختار."
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11863,19 +11922,19 @@ msgstr "مسح المهمة"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove Variable"
-msgstr ""
+msgstr "إزالة المÙتغيّر"
#: modules/visual_script/visual_script_editor.cpp
msgid "Editing Variable:"
-msgstr ""
+msgstr "تحرير المÙتغيّر:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove Signal"
-msgstr ""
+msgstr "إزالة الإشارة"
#: modules/visual_script/visual_script_editor.cpp
msgid "Editing Signal:"
-msgstr ""
+msgstr "تحرير الإشارة:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11908,23 +11967,23 @@ msgstr "الإعدادات:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Select or create a function to edit its graph."
-msgstr ""
+msgstr "اختر أو أنشئ وظيÙØ© برمجية لتحرير الرسم الخاص بها (graph)."
#: modules/visual_script/visual_script_editor.cpp
msgid "Delete Selected"
-msgstr ""
+msgstr "حذ٠المÙختار"
#: modules/visual_script/visual_script_editor.cpp
msgid "Find Node Type"
-msgstr ""
+msgstr "إيجاد نوع العÙقدة"
#: modules/visual_script/visual_script_editor.cpp
msgid "Copy Nodes"
-msgstr ""
+msgstr "نسخ العÙقد"
#: modules/visual_script/visual_script_editor.cpp
msgid "Cut Nodes"
-msgstr ""
+msgstr "قص العÙقد"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11943,47 +12002,47 @@ msgstr "الأعضاء"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Input type not iterable: "
-msgstr ""
+msgstr "نوع الإدخال غير متوقع: "
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Iterator became invalid"
-msgstr ""
+msgstr "أصبح المÙكرر غير صالحاً"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Iterator became invalid: "
-msgstr ""
+msgstr "أصبح المÙكرر غير صالحاً: "
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Invalid index property name."
-msgstr ""
+msgstr "اسم خاصية المؤشر index property غير صالح."
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Base object is not a Node!"
-msgstr ""
+msgstr "الكائن الأساس ليس بعÙقدة!"
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Path does not lead Node!"
-msgstr ""
+msgstr "لا يؤدي المسار للوصول لعÙقدة!"
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Invalid index property name '%s' in node %s."
-msgstr ""
+msgstr "اسم خاصية المؤشر \"الÙهرس\" '%s' ÙÙŠ العÙقدة %s غير صالح."
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid argument of type: "
-msgstr ""
+msgstr ": معامل النوع غير صحيح: "
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid arguments: "
-msgstr ""
+msgstr ": معاملات غير صالحة: "
#: modules/visual_script/visual_script_nodes.cpp
msgid "VariableGet not found in script: "
-msgstr ""
+msgstr "لم يتم إيجاد VariableGet ÙÙŠ النص البرمجي: "
#: modules/visual_script/visual_script_nodes.cpp
msgid "VariableSet not found in script: "
-msgstr ""
+msgstr "لم يتم إيجاد (Ù…Ùحدد المÙتغير) VariableSet ÙÙŠ النص البرمجي: "
#: modules/visual_script/visual_script_nodes.cpp
msgid "Custom node has no _step() method, can't process graph."
@@ -11994,6 +12053,8 @@ msgid ""
"Invalid return value from _step(), must be integer (seq out), or string "
"(error)."
msgstr ""
+"القيمة المÙرجعة من _step() غير صالحة، ينبغي أن تكون رقماً (تسلسل)ØŒ أو نصاً "
+"(خطأ)."
#: modules/visual_script/visual_script_property_selector.cpp
#, fuzzy
@@ -12053,6 +12114,13 @@ msgstr ""
"الموضوعة سلÙاً."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Ù…Ùنقح أخطاء Ù…Ùتاح المتجر keystore غير Ù…Ùهيئ ÙÙŠ إعدادت المÙحرر أو ÙÙŠ الإعدادات "
+"الموضوعة سلÙاً."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"البÙنى المخصوصة تتطلب مساراً لحزمة تطوير Android SDK صالحة ÙÙŠ إعدادات المÙحرر."
@@ -12079,6 +12147,32 @@ msgstr "اسم رÙزمة غير صالح:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12237,6 +12331,8 @@ msgid ""
"Only one visible CanvasModulate is allowed per scene (or set of instanced "
"scenes). The first created one will work, while the rest will be ignored."
msgstr ""
+"ÙŠÙسمح بواحد Ùقط من CanvasModulate (Ù…Ùعدلات اللوحة) ÙÙŠ ÙƒÙÙ„ مشهد (أو مجموعة "
+"المشاهد المÙنمذجة). سيعمل أول واحد Ùقط، بينما الباقي سيتم تجاهلهم."
#: scene/2d/collision_object_2d.cpp
msgid ""
@@ -12244,6 +12340,11 @@ msgid ""
"Consider adding a CollisionShape2D or CollisionPolygon2D as a child to "
"define its shape."
msgstr ""
+"لا تملك هذه العÙقدة شكلاً، بالتالي إنها غير قادرة على التصادم أو التÙاعل مع "
+"الكائنات الأخرى.\n"
+"ضع ÙÙŠ الحسبان إضاÙØ© عÙقدة بنت كالشكل التصادمي ثنائي الأبعاد CollisionShape2D "
+"أو الشكل التصادمي المÙضلع ثنائي الأبعاد CollisionPolygon2D لتحديد الشكل "
+"الخاصة بها."
#: scene/2d/collision_polygon_2d.cpp
msgid ""
@@ -12251,6 +12352,11 @@ msgid ""
"CollisionObject2D derived node. Please only use it as a child of Area2D, "
"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
msgstr ""
+"يعمل Ù…Ùضلع التصادم ثنائي الأبعاد CollisionPolygon2D Ùقط كشكل تصادمي لكل العÙقد "
+"المشتقة من الكائن التصادمي ثنائي الأبعاد CollisionObject2D. من Ùضلك استخدمه "
+"Ùقط لكل أبناء الحيز ثنائي الأبعاد Area2DØŒ الجسم السكوني ثنائي الأبعاد "
+"StaticBody2D و الجسم الجامد ثنائي الأبعاد RigidBody2D، والجسم المتحرك ثنائي "
+"الأبعاد KinematicBody2D إلخ.. لكي تمنح كل منهم شكلاً."
#: scene/2d/collision_polygon_2d.cpp
msgid "An empty CollisionPolygon2D has no effect on collision."
@@ -12262,6 +12368,11 @@ msgid ""
"CollisionObject2D derived node. Please only use it as a child of Area2D, "
"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
msgstr ""
+"يعمل Ù…Ùضلع التصادم ثنائي الأبعاد CollisionPolygon2D Ùقط كشكل تصادمي لكل العÙقد "
+"المشتقة من الكائن التصادمي ثنائي الأبعاد CollisionObject2D. من Ùضلك استخدمه "
+"Ùقط لكل أبناء الحيز ثنائي الأبعاد Area2DØŒ الجسم السكوني ثنائي الأبعاد "
+"StaticBody2D و الجسم الجامد ثنائي الأبعاد RigidBody2D، والجسم المتحرك ثنائي "
+"الأبعاد KinematicBody2D إلخ.. لكي تمنح كل منهم شكلاً."
#: scene/2d/collision_shape_2d.cpp
msgid ""
@@ -12276,12 +12387,14 @@ msgid ""
"CPUParticles2D animation requires the usage of a CanvasItemMaterial with "
"\"Particles Animation\" enabled."
msgstr ""
+"تتطلب الرسوم المتحركة CPUParticles2D استخدام CanvasItemMaterial مع تمكين "
+"\"الرسوم المتحركة للجزيئات\"."
#: scene/2d/light_2d.cpp
msgid ""
"A texture with the shape of the light must be supplied to the \"Texture\" "
"property."
-msgstr ""
+msgstr "يجب توريد نقش بهيئة الضوء لخاصية \"النقش\"."
#: scene/2d/light_occluder_2d.cpp
msgid ""
@@ -12748,6 +12861,21 @@ msgstr "يمكن تعيين المتغيرات Ùقط ÙÙŠ الذروة ."
msgid "Constants cannot be modified."
msgstr "لا يمكن تعديل الثوابت."
+#~ msgid "Not in resource path."
+#~ msgstr "ليس ÙÙŠ مسار الموارد."
+
+#~ msgid "Revert"
+#~ msgstr "إرجاع"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "هذا الÙعل لا يمكن إرجاعة. إرجاع علي أية حال؟"
+
+#~ msgid "Revert Scene"
+#~ msgstr "إعادة المشهد"
+
+#~ msgid "Clear Script"
+#~ msgstr "إخلاء الكود"
+
#~ msgid "Issue Tracker"
#~ msgstr "متتبع الأخطاء"
diff --git a/editor/translations/bg.po b/editor/translations/bg.po
index c9be0c2c3f..f08f2b1362 100644
--- a/editor/translations/bg.po
+++ b/editor/translations/bg.po
@@ -825,7 +825,6 @@ msgstr "Сигналът не може да бъде Ñвързан"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1426,17 +1425,9 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Ðеправилен път."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ðе е в Ð¿ÑŠÑ‚Ñ Ð½Ð° реÑурÑите."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2356,11 +2347,14 @@ msgid "Can't reload a scene that was never saved."
msgstr "Сцена, коÑто никога не е била запазвана, не може да бъде презаредена."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Запазване на Ñцената"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2626,10 +2620,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3237,6 +3227,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3822,6 +3816,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Запазване..."
@@ -6763,12 +6761,12 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Ред"
+msgid "[Ignore]"
+msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
+msgid "Line"
+msgstr "Ред"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7246,6 +7244,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10245,8 +10252,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Премахване на Ñкрипта"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Закачане на Ñкрипт"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10403,6 +10411,13 @@ msgid "Open Documentation"
msgstr "ОтварÑне на документациÑта"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10453,11 +10468,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10584,6 +10599,10 @@ msgid "A directory with the same name exists."
msgstr "Вече ÑъщеÑтвува файл или папка Ñ Ñ‚Ð¾Ð²Ð° име."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "ТрÑбва да Ñе използва правилно разширение."
@@ -10630,6 +10649,10 @@ msgid "File exists, it will be reused."
msgstr "Файлът ÑъщеÑтвува. ИÑкате ли да го презапишете?"
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Ðеправилен път."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid class name."
msgstr "невалидно име на Група."
@@ -11711,6 +11734,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11735,6 +11762,32 @@ msgstr "невалидно име на Група."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12427,6 +12480,12 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Ðе е в Ð¿ÑŠÑ‚Ñ Ð½Ð° реÑурÑите."
+
+#~ msgid "Clear Script"
+#~ msgstr "Премахване на Ñкрипта"
+
#~ msgid "Replaced %d occurrence(s)."
#~ msgstr "Заменени ÑъвпадениÑ: %d ."
diff --git a/editor/translations/bn.po b/editor/translations/bn.po
index aaa46da54d..3680e4ce6c 100644
--- a/editor/translations/bn.po
+++ b/editor/translations/bn.po
@@ -897,7 +897,6 @@ msgstr "সংযোজক সংকেত/সিগনà§à¦¯à¦¾à¦²:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1546,18 +1545,9 @@ msgstr "সকà§à¦°à¦¿à¦¯à¦¼ করà§à¦¨"
msgid "Rearrange Autoloads"
msgstr "Autoload সমূহ পà§à¦¨à¦°à§à¦¬à¦¿à¦¨à§à¦¯à¦¸à§à¦¤ করà§à¦¨"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "অকারà§à¦¯à¦•à¦° পথ।"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "ফাইলটি বিদà§à¦¯à¦®à¦¾à¦¨ নয়।"
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "রিসোরà§à¦¸à§‡à¦° পথে নয়।"
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2591,12 +2581,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "পূরà§à¦¬à§‡ কখনোই সংরকà§à¦·à¦¿à¦¤ হয়নি à¦à¦®à¦¨ দৃশà§à¦¯ পà§à¦¨à¦°à¦¾à§Ÿ-লোড (রিলোড) করা অসমà§à¦­à¦¬à¥¤"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "পà§à¦°à¦¤à§à¦¯à¦¾à¦¬à¦°à§à¦¤à¦¨ করà§à¦¨"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "দৃশà§à¦¯ সংরকà§à¦·à¦£ করà§à¦¨"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "à¦à¦‡ কাজটি অসমà§à¦ªà¦¾à¦¦à¦¿à¦¤ করা সমà§à¦­à¦¬ হবে না। তবà§à¦“ পà§à¦°à¦¤à§à¦¯à¦¾à¦¬à¦°à§à¦¤à¦¨ করবেন?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2900,10 +2893,6 @@ msgid "Redo"
msgstr "পà§à¦¨à¦°à¦¾à¦¯à¦¼ করà§à¦¨"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "দৃশà§à¦¯ পà§à¦°à¦¤à§à¦¯à¦¾à¦¬à§ƒà¦¤à§à¦¤ করà§à¦¨"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "পà§à¦°à¦•à¦²à§à¦ª অথবা দৃশà§à¦¯à§‡-বà§à¦¯à¦¾à¦ªà§€ বিবিধ সরঞà§à¦œà¦¾à¦®-সমূহ।"
@@ -3584,6 +3573,13 @@ msgstr "সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ চালানো সমà§à¦­à¦¬ হয়ন
msgid "Did you forget the '_run' method?"
msgstr "আপনি কি '_run' মেথডটি দিতে ভà§à¦²à§‡à¦›à§‡à¦¨?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"গেটার (Getter) তৈরি করতে/নামাতে কনà§à¦Ÿà§à¦°à§‹à¦² কী (Ctrl) চেপে রাখà§à¦¨à¥¤ জেনেরিক সিগনেচার "
+"(generic signature) তৈরি করতে/নামাতে শিফট কী (Shift) চেপে রাখà§à¦¨à¥¤"
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "ইমà§à¦ªà§‹à¦°à§à¦Ÿà§‡à¦° জনà§à¦¯ নোড(সমূহ) নিরà§à¦¬à¦¾à¦šà¦¨ করà§à¦¨"
@@ -4265,6 +4261,10 @@ msgid "Error running post-import script:"
msgstr "ইমà§à¦ªà§‹à¦°à§à¦Ÿ-পরবরà§à¦¤à§€ সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ চালানোয় সমসà§à¦¯à¦¾ হয়েছে:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "সংরকà§à¦·à¦¿à¦¤ হচà§à¦›à§‡..."
@@ -7429,15 +7429,15 @@ msgid ""
msgstr "'%s' à¦à¦° সাথে '%s' সংযà§à¦•à§à¦¤ করà§à¦¨"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "লাইন:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "ফাংশনে যান..."
@@ -7953,6 +7953,15 @@ msgid "XForm Dialog"
msgstr "XForm à¦à¦° সংলাপ"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "সà§à¦¨à§à¦¯à¦¾à¦ª মোড:"
@@ -11164,8 +11173,9 @@ msgid "Instance Child Scene"
msgstr "শীষà§à¦¯ নোড ইনà§à¦¸à¦Ÿà§à¦¯à¦¾à¦¨à§à¦¸ করà§à¦¨"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ পরিসà§à¦•à¦¾à¦° করà§à¦¨"
+#, fuzzy
+msgid "Detach Script"
+msgstr "সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ সংযà§à¦•à§à¦¤ করà§à¦¨"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -11337,6 +11347,13 @@ msgid "Open Documentation"
msgstr "রেফারেনà§à¦¸à§‡à¦° ডকà§à¦®à§‡à¦¨à§à¦Ÿà§‡à¦¶à¦¨à§‡ খà§à¦à¦œà§à¦¨à¥¤"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "শীষà§à¦¯ নোড তৈরি করà§à¦¨"
@@ -11390,11 +11407,13 @@ msgstr ""
"উতà§à¦¤à¦°à¦¾à¦§à¦¿à¦•à¦¾à¦°à§€ দৃশà§à¦¯ তৈরি করে।"
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "à¦à¦•à¦Ÿà¦¿ নতà§à¦¨ বা বিদà§à¦¯à¦®à¦¾à¦¨ সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ নিরà§à¦¬à¦¾à¦šà¦¿à¦¤ নোডে সংযà§à¦•à§à¦¤ করà§à¦¨à¥¤"
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "নিরà§à¦¬à¦¾à¦šà¦¿à¦¤ নোড হতে à¦à¦•à¦Ÿà¦¿ সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ পরিসà§à¦•à¦¾à¦° করà§à¦¨à¥¤"
#: editor/scene_tree_dock.cpp
@@ -11542,6 +11561,10 @@ msgid "A directory with the same name exists."
msgstr "à¦à¦•à¦‡ নামের ডিরেকà§à¦Ÿà¦°à¦¿ বিদà§à¦¯à¦®à¦¾à¦¨"
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "ফাইলটি বিদà§à¦¯à¦®à¦¾à¦¨ নয়।"
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "অগà§à¦°à¦¹à¦£à¦¯à§‹à¦—à§à¦¯ à¦à¦•à§à¦¸à¦Ÿà§‡à¦¨à¦¶à¦¨"
@@ -11591,6 +11614,11 @@ msgstr "à¦à¦•à¦‡ নামের ফাইল উপসà§à¦¥à¦¿à¦¤, তা ম
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "অকারà§à¦¯à¦•à¦° পথ।"
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "অগà§à¦°à¦¹à¦£à¦¯à§‹à¦—à§à¦¯ কà§à¦²à¦¾à¦¸ নাম"
@@ -12743,6 +12771,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12767,6 +12799,32 @@ msgstr "অগà§à¦°à¦¹à¦£à¦¯à§‹à¦—à§à¦¯ কà§à¦²à¦¾à¦¸ নাম"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -13489,6 +13547,21 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "রিসোরà§à¦¸à§‡à¦° পথে নয়।"
+
+#~ msgid "Revert"
+#~ msgstr "পà§à¦°à¦¤à§à¦¯à¦¾à¦¬à¦°à§à¦¤à¦¨ করà§à¦¨"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "à¦à¦‡ কাজটি অসমà§à¦ªà¦¾à¦¦à¦¿à¦¤ করা সমà§à¦­à¦¬ হবে না। তবà§à¦“ পà§à¦°à¦¤à§à¦¯à¦¾à¦¬à¦°à§à¦¤à¦¨ করবেন?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "দৃশà§à¦¯ পà§à¦°à¦¤à§à¦¯à¦¾à¦¬à§ƒà¦¤à§à¦¤ করà§à¦¨"
+
+#~ msgid "Clear Script"
+#~ msgstr "সà§à¦•à§à¦°à¦¿à¦ªà§à¦Ÿ পরিসà§à¦•à¦¾à¦° করà§à¦¨"
+
#~ msgid "Issue Tracker"
#~ msgstr "ইসà§à¦¯à§ টà§à¦°à§à¦¯à¦¾à¦•à¦¾à¦°"
diff --git a/editor/translations/ca.po b/editor/translations/ca.po
index a1577b5a15..1640367701 100644
--- a/editor/translations/ca.po
+++ b/editor/translations/ca.po
@@ -16,8 +16,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-03-11 12:20+0000\n"
-"Last-Translator: Alex Mancha <codingstain@gmail.com>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: roger <616steam@gmail.com>\n"
"Language-Team: Catalan <https://hosted.weblate.org/projects/godot-engine/"
"godot/ca/>\n"
"Language: ca\n"
@@ -25,7 +25,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -567,7 +567,7 @@ msgstr "Escala amb el Cursor"
#: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp
msgid "Duplicate Selection"
-msgstr "Duplica la Selecció"
+msgstr "Duplicar la Selecció"
#: editor/animation_track_editor.cpp
msgid "Duplicate Transposed"
@@ -575,7 +575,7 @@ msgstr "Duplica'l Transposat"
#: editor/animation_track_editor.cpp
msgid "Delete Selection"
-msgstr "Elimina la Selecció"
+msgstr "Suprimir la Selecció"
#: editor/animation_track_editor.cpp
msgid "Go to Next Step"
@@ -656,7 +656,7 @@ msgstr "Seleccioneu les Pistes a Copiar"
#: editor/plugins/sprite_frames_editor_plugin.cpp editor/property_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Copy"
-msgstr "Copia"
+msgstr "Copiar"
#: editor/animation_track_editor.cpp
msgid "Select All/None"
@@ -688,7 +688,7 @@ msgstr "Modifica el Valor de la Taula"
#: editor/code_editor.cpp
msgid "Go to Line"
-msgstr "Vés a la Línia"
+msgstr "Anar a la Línia"
#: editor/code_editor.cpp
msgid "Line Number:"
@@ -715,8 +715,9 @@ msgid "Whole Words"
msgstr "Paraules senceres"
#: editor/code_editor.cpp editor/rename_dialog.cpp
+#, fuzzy
msgid "Replace"
-msgstr "Reemplaça"
+msgstr "Reemplaçar"
#: editor/code_editor.cpp
msgid "Replace All"
@@ -847,7 +848,6 @@ msgstr "No es pot connectar el senyal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1328,7 +1328,7 @@ msgstr "El Bus Principal no es pot pas eliminar!"
#: editor/editor_audio_buses.cpp
msgid "Delete Audio Bus"
-msgstr "Elimina Bus d'Àudio"
+msgstr "Elimina Bus d'Àudio"
#: editor/editor_audio_buses.cpp
msgid "Duplicate Audio Bus"
@@ -1460,17 +1460,9 @@ msgstr "Activa"
msgid "Rearrange Autoloads"
msgstr "Reorganitza AutoCàrregues"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Camí no vàlid."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "El Fitxer no existeix."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Fora del camí dels recursos."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1499,7 +1491,7 @@ msgstr "Singleton"
#: editor/editor_data.cpp editor/inspector_dock.cpp
msgid "Paste Params"
-msgstr "Enganxa els Paràmetres"
+msgstr "Enganxa els Paràmetres"
#: editor/editor_data.cpp
msgid "Updating Scene"
@@ -1984,6 +1976,7 @@ msgid "Constants"
msgstr "Constants"
#: editor/editor_help.cpp
+#, fuzzy
msgid "Property Descriptions"
msgstr "Descripcions de la Propietat"
@@ -2000,6 +1993,7 @@ msgstr ""
"$color][url=$url] totaportant-ne una[/url][/color]!"
#: editor/editor_help.cpp
+#, fuzzy
msgid "Method Descriptions"
msgstr "Descripcions del Mètode"
@@ -2008,7 +2002,7 @@ msgid ""
"There is currently no description for this method. Please help us by [color="
"$color][url=$url]contributing one[/url][/color]!"
msgstr ""
-"Aquest mètode no disposa de cap descripció. Podeu contribuir [color=$color]"
+"Aquest mètode no disposa de cap descripció. Podeu contribuir [color=$color]"
"[url=$url] tot aportant-ne una[/url][/color]!"
#: editor/editor_help_search.cpp editor/editor_node.cpp
@@ -2077,7 +2071,6 @@ msgid "Property"
msgstr "Propietat"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Theme Property"
msgstr "Propietats del tema"
@@ -2430,12 +2423,19 @@ msgid "Can't reload a scene that was never saved."
msgstr "No es pot recarregar una escena mai desada."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Reverteix"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Desa Escena"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Aquesta acció no es pot desfer. N'esteu segur?"
+#, fuzzy
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"L'escena actual té canvis sense desar.\n"
+"Voleu torna a carregar l'escena desada de totes maneres? Aquesta acció no es "
+"pot desfer."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2484,14 +2484,13 @@ msgid "Close Scene"
msgstr "Tanca l'Escena"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Reopen Closed Scene"
msgstr "Reobrir l'escena tancada"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
msgstr ""
-"No es pot habilitar el complement a: '%s' ha fallat l'anàlisi de la "
+"No es pot habilitar el complement a: '%s' ha fallat l'anàlisi de la "
"configuració."
#: editor/editor_node.cpp
@@ -2530,8 +2529,8 @@ msgid ""
"Scene '%s' was automatically imported, so it can't be modified.\n"
"To make changes to it, a new inherited scene can be created."
msgstr ""
-"En ser importada automàticament, l'escena '%s' no es pot modificar. Per fer-"
-"hi canvis, creeu una nova escena heretada."
+"En ser importada automàticament, l'escena '%s' no es pot modificar. \n"
+"Per fer-hi canvis, creeu una nova escena heretada."
#: editor/editor_node.cpp
msgid ""
@@ -2607,7 +2606,6 @@ msgid "Close Tab"
msgstr "Tanca la Pestanya"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Undo Close Tab"
msgstr "Desfer Tancament de Pestanya"
@@ -2730,10 +2728,6 @@ msgid "Redo"
msgstr "Refés"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Reverteix Escena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Eines vàries o d'escena."
@@ -2751,7 +2745,6 @@ msgid "Version Control"
msgstr "Control de Versions"
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Set Up Version Control"
msgstr "Configurar Control de Versions"
@@ -2764,9 +2757,8 @@ msgid "Export..."
msgstr "Exportar..."
#: editor/editor_node.cpp
-#, fuzzy
msgid "Install Android Build Template..."
-msgstr "Instal·lar plantilla de compilació d'Android"
+msgstr "Instal·lar Plantilla de Compilació d'Android..."
#: editor/editor_node.cpp
msgid "Open Project Data Folder"
@@ -2777,9 +2769,8 @@ msgid "Tools"
msgstr "Eines"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Orphan Resource Explorer..."
-msgstr "Navegador de Recursos Orfes"
+msgstr "Navegador de Recursos Orfes..."
#: editor/editor_node.cpp
msgid "Quit to Project List"
@@ -2921,14 +2912,12 @@ msgid "Open Editor Settings Folder"
msgstr "Obre el directori de Configuració de l'Editor"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Manage Editor Features..."
-msgstr "Administrar Característiques de l'Editor"
+msgstr "Administrar Característiques de l'Editor..."
#: editor/editor_node.cpp
-#, fuzzy
msgid "Manage Export Templates..."
-msgstr "Gestor de Plantilles d'Exportació"
+msgstr "Administrar Plantilles d'Exportació..."
#: editor/editor_node.cpp editor/plugins/shader_editor_plugin.cpp
msgid "Help"
@@ -2958,8 +2947,9 @@ msgid "Report a Bug"
msgstr "ReImportar"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Send Docs Feedback"
-msgstr ""
+msgstr "Enviar suggeriments sobre la documentació"
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
msgid "Community"
@@ -3219,7 +3209,7 @@ msgstr "% del Fotograma"
#: editor/editor_profiler.cpp
msgid "Physics Frame %"
-msgstr "Fotograma de Física %"
+msgstr "Fotograma de Física %"
#: editor/editor_profiler.cpp
msgid "Inclusive"
@@ -3294,7 +3284,7 @@ msgid ""
msgstr ""
"No es pot crear una ViewportTexture en aquest recurs ja que no s'ha definit "
"com local per a l'escena.\n"
-"Activeu la propietat \"local a l'escena\" del recurs i també en tots els "
+"Activeu la propietat \"local a l'escena\" del recurs i també en tots els "
"recurs intermitjos que el continguin fins a un node."
#: editor/editor_properties.cpp editor/property_editor.cpp
@@ -3369,7 +3359,7 @@ msgid ""
"No runnable export preset found for this platform.\n"
"Please add a runnable preset in the export menu."
msgstr ""
-"No s'ha trobat cap patró d'exportació executable per aquesta plataforma. \n"
+"No s'ha trobat cap patró d'exportació executable per aquesta plataforma. \n"
"Afegiu un patró predeterminat en el menú d'exportació."
#: editor/editor_run_script.cpp
@@ -3396,6 +3386,13 @@ msgstr "No s'ha pogut executar l'Script:"
msgid "Did you forget the '_run' method?"
msgstr "Podria mancar el mètode '_run'?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Retén Ctrl per dipositar un mètode Accessor (Getter). Retén Maj per "
+"dipositar una firma genèrica."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selecciona Node(s) per Importar"
@@ -3538,13 +3535,12 @@ msgid ""
"Templates installation failed.\n"
"The problematic templates archives can be found at '%s'."
msgstr ""
-"No s'han pogut instal·lar les plantilles. Els fitxers problemàtics es troben "
-"a '%s'."
+"No s'han pogut instal·lar les plantilles. \n"
+"Les plantilles problemàtics es troben a '%s'."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Error requesting URL:"
-msgstr "Error en la sol·licitud de l'url: "
+msgstr "Error en sol·licitar l'URL:"
#: editor/export_template_manager.cpp
msgid "Connecting to Mirror..."
@@ -3739,9 +3735,8 @@ msgid "Move To..."
msgstr "Mou cap a..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Scene..."
-msgstr "Nova Escena"
+msgstr "Nova Escena..."
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
msgid "New Script..."
@@ -3792,7 +3787,9 @@ msgstr "Cerca Fitxers"
msgid ""
"Scanning Files,\n"
"Please Wait..."
-msgstr "Analitzant Fitxers..."
+msgstr ""
+"Analitzant Fitxers,\n"
+"Si Us Plau Espereu..."
#: editor/filesystem_dock.cpp
msgid "Move"
@@ -3931,7 +3928,7 @@ msgstr "Gestiona Grups"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Single Scene"
-msgstr "Importar com a Única Escena"
+msgstr "Importar com a Única Escena"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Animations"
@@ -4003,6 +4000,10 @@ msgid "Error running post-import script:"
msgstr "Error en l'execució de l'Script de post-importació:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Desant..."
@@ -4771,9 +4772,8 @@ msgid "Transition: "
msgstr "Transició: "
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Play Mode:"
-msgstr "Mode d'Escombratge lateral"
+msgstr "Mode de Reproducció:"
#: editor/plugins/animation_tree_editor_plugin.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -4836,7 +4836,7 @@ msgstr "Mescla 1:"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "X-Fade Time (s):"
-msgstr "Durada de la fosa (s):"
+msgstr "Durada de la fosa (s):"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Current:"
@@ -4970,12 +4970,12 @@ msgstr "Bucle de redirecció."
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "Request failed, timeout"
-msgstr "Ha fallat la sol·licitud, codi de devolució:"
+msgstr "La sol·licitud ha fallat, s'ha esgotat el temps d'espera"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "Timeout."
-msgstr "Temps"
+msgstr "Temps esgotat."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Bad download hash, assuming file has been tampered with."
@@ -5348,9 +5348,8 @@ msgid "Full Rect"
msgstr "Rect. Complet"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Keep Ratio"
-msgstr "Relació d'Escala:"
+msgstr "Mantenir Proporcions"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Anchors only"
@@ -5371,7 +5370,7 @@ msgid ""
"Overrides game camera with editor viewport camera."
msgstr ""
"Substitueix la càmera del joc.\n"
-"Substitueix la càmera del joc per la la càmera de l'editor."
+"Substitueix la càmera del joc per la càmera de l'editor."
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5499,9 +5498,8 @@ msgid "Pan Mode"
msgstr "Mode d'Escombratge lateral"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Ruler Mode"
-msgstr "Mode d'Execució:"
+msgstr "Mode Regla"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
@@ -5700,9 +5698,8 @@ msgid "Auto Insert Key"
msgstr "Inserir Clau Automàticament"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Animation Key and Pose Options"
-msgstr "S'ha insertit una Clau d'Animació."
+msgstr "Opcions de Clau d'Animació i Pose"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key (Existing Tracks)"
@@ -5760,7 +5757,7 @@ msgid ""
"Drag & drop + Shift : Add node as sibling\n"
"Drag & drop + Alt : Change node type"
msgstr ""
-"Arrossegar i deixar anar + Maj: Afegeix un node com a germà\n"
+"Arrossegar i deixar anar + Maj: Afegeix un node com a germà\n"
"Arrossegar i deixar anar + Maj: Canvia el tipus del node"
#: editor/plugins/collision_polygon_editor_plugin.cpp
@@ -5958,7 +5955,7 @@ msgstr "La malla és buida!"
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "Couldn't create a Trimesh collision shape."
-msgstr "Crea una Col·lisió entre malles de triangles germanes"
+msgstr "Crea una Col·lisió entre malles de triangles germanes."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Static Trimesh Body"
@@ -5974,12 +5971,15 @@ msgid "Create Trimesh Static Shape"
msgstr "Crea un forma amb una malla de triangles"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Can't create a single convex collision shape for the scene root."
msgstr ""
+"No es pot crear una sola forma de col·lisió convexa per a l'arrel de "
+"l'escena."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Couldn't create a single convex collision shape."
-msgstr "No s'ha pogut crear una capa de col·lisió convexa."
+msgstr "No s'ha pogut crear una forma de col·lisió convexa."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
@@ -6132,12 +6132,14 @@ msgstr "Elimina l'element %d?"
msgid ""
"Update from existing scene?:\n"
"%s"
-msgstr "Actualitza des de l'Escena"
+msgstr ""
+"Actualitzar des d'una 'Escena existent?:\n"
+"%s"
#: editor/plugins/mesh_library_editor_plugin.cpp
#, fuzzy
msgid "Mesh Library"
-msgstr "Biblioteca de Models (MeshLibrary)..."
+msgstr "Biblioteca de Models (MeshLibrary)"
#: editor/plugins/mesh_library_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
@@ -6381,7 +6383,7 @@ msgstr "Selecciona Punts"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Shift+Drag: Select Control Points"
-msgstr "Maj.+ Arrossegar: Selecciona Punts de Control"
+msgstr "Maj.+ Arrossegar: Selecciona Punts de Control"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
@@ -6656,7 +6658,7 @@ msgstr "Configurar Quadrícula:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Offset X:"
-msgstr "Desplaçament X de la quadrícula:"
+msgstr "Desplaçament X de la quadrícula:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Offset Y:"
@@ -7028,12 +7030,13 @@ msgstr ""
"'%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Línia"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(ignorar)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorar)"
+msgid "Line"
+msgstr "Línia"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7089,9 +7092,8 @@ msgid "Bookmarks"
msgstr "Marcadors"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Breakpoints"
-msgstr "Crea punts."
+msgstr "Punts d’interrupció"
#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
@@ -7125,7 +7127,7 @@ msgstr "(Des)Plega la línia"
#: editor/plugins/script_text_editor.cpp
msgid "Fold All Lines"
-msgstr "Plega totes les Línies"
+msgstr "Plega totes les Línies"
#: editor/plugins/script_text_editor.cpp
msgid "Unfold All Lines"
@@ -7245,7 +7247,7 @@ msgstr "Esquelet2D"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
#, fuzzy
msgid "Make Rest Pose (From Bones)"
-msgstr "Crear Pose de Repòs (A partir dels Ossos)"
+msgstr "Crear Pose de Repòs (A partir dels Ossos)"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
#, fuzzy
@@ -7311,7 +7313,7 @@ msgstr "Rotació de %s graus."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Keying is disabled (no key inserted)."
-msgstr "l'Edició de Claus està inhabilitada (no s'ha inserit cap Clau)."
+msgstr "l'Edició de Claus està inhabilitada (no s'ha inserit cap Clau)."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Animation Key Inserted."
@@ -7526,6 +7528,15 @@ msgid "XForm Dialog"
msgstr "Diàleg XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Ajustar Nodes al Terra"
@@ -7540,9 +7551,9 @@ msgid ""
"Alt+Drag: Move\n"
"Alt+RMB: Depth list selection"
msgstr ""
-"Arrossegar: Gira\n"
+"Arrossegar: Gira\n"
"Alt+Arrossegar: Mou\n"
-"Alt+Clic Dret: Selecció de llista de profunditat"
+"Alt+Clic Dret: Selecció de llista de profunditat"
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
@@ -7649,9 +7660,8 @@ msgstr "Mostra la Graella"
#: editor/plugins/spatial_editor_plugin.cpp
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Settings..."
-msgstr "Configuració"
+msgstr "Configuració..."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Settings"
@@ -7842,9 +7852,8 @@ msgid "Add Frame"
msgstr "Afegeix Fotograma"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Unable to load images"
-msgstr "No s'ha pogut carregar el recurs."
+msgstr "No s'han pogut carregar les imatges"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "ERROR: Couldn't load frame resource!"
@@ -8208,7 +8217,7 @@ msgstr "Habilitar Prioritat"
#: editor/plugins/tile_map_editor_plugin.cpp
#, fuzzy
msgid "Filter tiles"
-msgstr "Filtrat de Fitxers..."
+msgstr "Filtrat de Fitxers"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Give a TileSet resource to this TileMap to use its tiles."
@@ -8254,12 +8263,12 @@ msgstr "Restablir Transformació"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
msgid "Add Texture(s) to TileSet."
-msgstr "Afegeix Nodes des d'Arbre"
+msgstr "Afegeix Nodes des d'Arbre."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
msgid "Remove selected Texture from TileSet."
-msgstr "Elimina l'entrada actual"
+msgstr "Elimineu la textura seleccionada de TileSet."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Create from Scene"
@@ -8608,9 +8617,8 @@ msgid "TileSet"
msgstr "Conjunt de rajoles"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "No VCS addons are available."
-msgstr "Nom del pare del node, si està disponible"
+msgstr "No hi ha addons VCS disponibles."
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Error"
@@ -8649,9 +8657,8 @@ msgid "Staging area"
msgstr "Zona de posada en escena"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Detect new changes"
-msgstr "Crear un nou rectangle."
+msgstr "Detectar nous canvis"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8727,9 +8734,8 @@ msgid "Add Output"
msgstr "Afegeix una Entrada"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar"
-msgstr "Escala:"
+msgstr "Escalar"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector"
@@ -8850,7 +8856,7 @@ msgstr "Crear node Shader"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Color function."
-msgstr "Vés a la Funció"
+msgstr "Funció color."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Color operator."
@@ -8871,7 +8877,7 @@ msgstr "Converteix el vector RGB en un equivalent de HSV."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Sepia function."
-msgstr "Reanomena Funció"
+msgstr "Funció sèpia."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Burn operator."
@@ -8919,7 +8925,7 @@ msgstr "Constant de color."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Color uniform."
-msgstr "Transforma"
+msgstr "Color uniforme."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9004,9 +9010,8 @@ msgstr ""
"escalar."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Boolean constant."
-msgstr "Modificar una constant vectorial"
+msgstr "Constant booleana."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Boolean uniform."
@@ -9052,14 +9057,12 @@ msgid "'%s' input parameter for vertex and fragment shader mode."
msgstr "paràmetre d'entrada 'alpha' per modes shader vèrtex i el fragment."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar function."
-msgstr "Modifica una Funció Escalar"
+msgstr "Funció escalar."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar operator."
-msgstr "Modifica un operador escalar"
+msgstr "Operador escalar."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "E constant (2.718282). Represents the base of the natural logarithm."
@@ -9100,7 +9103,7 @@ msgstr "Retorna el valor absolut del paràmetre."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the arc-cosine of the parameter."
-msgstr "Retorna el l'arc cosinus del paràmetre."
+msgstr "Retorna el l'arc cosinus del paràmetre."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9302,14 +9305,13 @@ msgid "Subtracts scalar from scalar."
msgstr "Resta escalar d'escalar."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar constant."
-msgstr "Modificar una constant escalar"
+msgstr "Constant escalar."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Scalar uniform."
-msgstr "Modificar un Uniforme Escalar"
+msgstr "Escalar uniforme."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9324,7 +9326,7 @@ msgstr "Realitza la cerca de textures."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Cubic texture uniform lookup."
-msgstr "Modifica un Uniforme Textura"
+msgstr "Modifica un Uniforme Textura."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9405,7 +9407,7 @@ msgstr "Funció vector."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Vector operator."
-msgstr "Modifica un operador vectorial"
+msgstr "Operador de vector."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Composes vector from three scalars."
@@ -9556,16 +9558,15 @@ msgid "Vector uniform."
msgstr "Modifica un Uniforme Vectorial"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid ""
"Custom Godot Shader Language expression, with custom amount of input and "
"output ports. This is a direct injection of code into the vertex/fragment/"
"light function, do not use it to write the function declarations inside."
msgstr ""
"Expressió personalitzada del llenguatge de Shader de Godot, amb una "
-"quantitat de ports d'entrada i sortida personalitzats. Això es una una "
-"injecció de codi directa en la funció vertex/fragment/light, no lo utilitzau "
-"per a escriure les declaracions de la funció dins seu."
+"quantitat de ports d'entrada i sortida personalitzats. Això es una injecció "
+"de codi directa en la funció vertex/fragment/light, no lo utilitzau per a "
+"escriure les declaracions de la funció dins seu."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9690,7 +9691,7 @@ msgstr "El camí d'exportació donat no existeix:"
#: editor/project_export.cpp
msgid "Export templates for this platform are missing/corrupted:"
-msgstr "Manquen d'exportació per aquesta plataforma o s'han malmès:"
+msgstr "Manquen d'exportació per aquesta plataforma o s'han malmès:"
#: editor/project_export.cpp
msgid "Presets"
@@ -9735,22 +9736,20 @@ msgid "Resources to export:"
msgstr "Recursos per exportar:"
#: editor/project_export.cpp
-#, fuzzy
msgid ""
"Filters to export non-resource files/folders\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
msgstr ""
-"Filtres per a l'exportació fitxers no-recurs (separats per comes, ex: *."
-"json, *. txt)"
+"Filtres per a l'exportació de fitxers/carpetes no-recurs \n"
+"(separats per comes, ex: *.json, *. txt, docs/*)"
#: editor/project_export.cpp
-#, fuzzy
msgid ""
"Filters to exclude files/folders from project\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
msgstr ""
-"Filtres per excloure fitxers del projecte (separats per comes, ex:*.json, *."
-"txt)"
+"Filtres per excloure fitxers/carpetes del projecte\n"
+"(separats per comes, ex:*.json, *.txt, docs/*)"
#: editor/project_export.cpp
msgid "Patches"
@@ -9763,7 +9762,7 @@ msgstr "Crea un Pedaç"
#: editor/project_export.cpp
#, fuzzy
msgid "Pack File"
-msgstr " Fitxers"
+msgstr "Fitxers"
#: editor/project_export.cpp
msgid "Features"
@@ -9823,9 +9822,8 @@ msgid "Export All"
msgstr "Exportar Tot"
#: editor/project_export.cpp editor/project_manager.cpp
-#, fuzzy
msgid "ZIP File"
-msgstr " Fitxers"
+msgstr "Fitxer ZIP"
#: editor/project_export.cpp
msgid "Godot Game Pack"
@@ -10217,7 +10215,7 @@ msgid ""
"Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'"
msgstr ""
-"Nom d'acció no vàlid. No pot estar buit ni contenir '/', ':', '=', '\\' o "
+"Nom d'acció no vàlid. No pot estar buit ni contenir '/', ':', '=', '\\' o "
"'\"'"
#: editor/project_settings_editor.cpp
@@ -10705,7 +10703,7 @@ msgstr "Expressions Regulars"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "At character %s"
-msgstr "Caràcters vàlids:"
+msgstr "Al caràcter %s"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
msgid "Reparent Node"
@@ -10773,8 +10771,9 @@ msgid "Instance Child Scene"
msgstr "Instancia una Escena Filla"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Esborra l'Script"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Adjunta-li un Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10814,14 +10813,12 @@ msgid "Make node as Root"
msgstr "Convertir node en arrel"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete %d nodes?"
-msgstr "Eliminar Nodes"
+msgstr "Suprimir %d nodes?"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete the root node \"%s\"?"
-msgstr "Elimina el(s) Node(s) de Graf d'Ombreig"
+msgstr "Voleu suprimir el node arrel \"% s\"?"
#: editor/scene_tree_dock.cpp
#, fuzzy
@@ -10829,9 +10826,8 @@ msgid "Delete node \"%s\" and its children?"
msgstr "Voleu suprimir el node \"%s\" i els seus fills?"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete node \"%s\"?"
-msgstr "Eliminar Nodes"
+msgstr "Suprimir el node \"% s\"?"
#: editor/scene_tree_dock.cpp
msgid "Can not perform with the root node."
@@ -10950,6 +10946,13 @@ msgid "Open Documentation"
msgstr "Obrir documentació"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Afegeix un Node Fill"
@@ -11002,11 +11005,13 @@ msgstr ""
"node arrel."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Adjunta un Script nou o existent per al Node Seleccionat."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Reestableix un Script per al node Seleccionat."
#: editor/scene_tree_dock.cpp
@@ -11142,6 +11147,10 @@ msgid "A directory with the same name exists."
msgstr "Ja existeix un directori amb el mateix nom."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "El Fitxer no existeix."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "L'extensió no és vàlida."
@@ -11183,6 +11192,10 @@ msgid "File exists, it will be reused."
msgstr "El fitxer ja existeix, es reutilitzarà."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Camí no vàlid."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nom de classe no vàlid."
@@ -11224,19 +11237,16 @@ msgid ""
msgstr ""
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Class Name:"
-msgstr "Nom de Classe"
+msgstr "Nom de la Classe:"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Template:"
-msgstr "Plantilla"
+msgstr "Plantilla:"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Built-in Script:"
-msgstr "Script Integrat"
+msgstr "Script integrat:"
#: editor/script_create_dialog.cpp
msgid "Attach Node Script"
@@ -11275,14 +11285,13 @@ msgid "C++ Source"
msgstr "Font"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Source:"
-msgstr "Font"
+msgstr "Font:"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "C++ Source:"
-msgstr "Font"
+msgstr "Font de C++:"
#: editor/script_editor_debugger.cpp
#, fuzzy
@@ -11729,7 +11738,7 @@ msgstr "Trieu la distància:"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "Filter meshes"
-msgstr "Filtra Mode:"
+msgstr "Filtrar malles"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Give a MeshLibrary resource to this GridMap to use its meshes."
@@ -12043,7 +12052,7 @@ msgstr "Connecta els Nodes"
#: modules/visual_script/visual_script_editor.cpp
msgid "Script already has function '%s'"
-msgstr "La funció '%s' ja existeix en l'Script"
+msgstr "La funció '%s' ja existeix en l'Script"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Input Value"
@@ -12112,7 +12121,7 @@ msgstr "Edició del Senyal:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Make Tool:"
-msgstr "Fer Local"
+msgstr "Convertir en Eina:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Members:"
@@ -12121,7 +12130,7 @@ msgstr "Membres:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Change Base Type:"
-msgstr "Modifica el Tipus de Base"
+msgstr "Canviar Tipus de Base:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -12136,7 +12145,7 @@ msgstr "Afegeix una Funció"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "function_name"
-msgstr "Funció:"
+msgstr "nom_funció"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -12284,13 +12293,17 @@ msgstr "L'executable ADB no està configurat a la configuració de l'editor."
#: platform/android/export/export.cpp
#, fuzzy
msgid "OpenJDK jarsigner not configured in the Editor Settings."
-msgstr "OpenJDK Jarsigner no està configurat en la configuració de l'editor."
+msgstr "OpenJDK Jarsigner no està configurat en la configuració de l'editor."
#: platform/android/export/export.cpp
msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
#, fuzzy
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12322,6 +12335,32 @@ msgid "Invalid package name:"
msgstr "El nom del paquet no és vàlid:"
#: platform/android/export/export.cpp
+msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
#, fuzzy
msgid ""
"Trying to build from a custom built template, but no version info for it "
@@ -12426,7 +12465,7 @@ msgstr "Utilitzant la imatge de presentació per defecte."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid package short name."
-msgstr "El nom del paquet no és vàlid:"
+msgstr "El nom curt del paquet no és vàlid."
#: platform/uwp/export/export.cpp
msgid "Invalid package unique name."
@@ -13057,7 +13096,7 @@ msgid ""
msgstr ""
"ScrollContainer fou pensat per treballar-hi amb un sol Control fill.\n"
"Utilitzeu un contenidor (VBox, HBox, ...) com a fill, o un utilitzeu Control "
-"i personalitzeu-hi la mida mínima manualment."
+"i personalitzeu-hi la mida mínima manualment."
#: scene/gui/tree.cpp
msgid "(Other)"
@@ -13117,6 +13156,21 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Les constants no es poden modificar."
+#~ msgid "Not in resource path."
+#~ msgstr "Fora del camí dels recursos."
+
+#~ msgid "Revert"
+#~ msgstr "Reverteix"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Aquesta acció no es pot desfer. N'esteu segur?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Reverteix Escena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Esborra l'Script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Seguiment d'Incidències"
diff --git a/editor/translations/cs.po b/editor/translations/cs.po
index 566ff0c1e2..fabec77283 100644
--- a/editor/translations/cs.po
+++ b/editor/translations/cs.po
@@ -18,12 +18,14 @@
# David Kubeš <kubesdavid@email.cz>, 2019.
# Emil Jiří Tywoniak <emil.tywoniak@gmail.com>, 2020.
# Filip Vincůrek <vincurek.f@gmail.com>, 2020.
+# Ondrej Pavelka <ondrej.pavelka@outlook.com>, 2020.
+# Zbyněk <zbynek.fiala@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-03-12 23:33+0000\n"
-"Last-Translator: Vojtěch Šamla <auzkok@seznam.cz>\n"
+"PO-Revision-Date: 2020-06-06 10:15+0000\n"
+"Last-Translator: Zbyněk <zbynek.fiala@gmail.com>\n"
"Language-Team: Czech <https://hosted.weblate.org/projects/godot-engine/godot/"
"cs/>\n"
"Language: cs\n"
@@ -31,7 +33,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
-"X-Generator: Weblate 4.0-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -746,13 +748,13 @@ msgstr "Přepnout panel skriptů"
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom In"
-msgstr "Přiblížit"
+msgstr "Zvětšit"
#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom Out"
-msgstr "Oddálit"
+msgstr "Změnšit"
#: editor/code_editor.cpp
msgid "Reset Zoom"
@@ -852,7 +854,6 @@ msgstr "Připojit Signál"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1463,17 +1464,9 @@ msgstr "Povolit"
msgid "Rearrange Autoloads"
msgstr "Přeskupit Autoloady"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Neplatná cesta."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Soubor neexistuje."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Není v cestě ke zdroji."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1624,7 +1617,7 @@ msgstr "Editor skriptů"
#: editor/editor_feature_profile.cpp
msgid "Asset Library"
-msgstr "Knihovna assetů"
+msgstr "Otevřít knihovnu assetů"
#: editor/editor_feature_profile.cpp
msgid "Scene Tree Editing"
@@ -1888,9 +1881,8 @@ msgid "(Un)favorite current folder."
msgstr "Přidat/odebrat složku z oblíbených."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Toggle the visibility of hidden files."
-msgstr "Zobrazit skryté soubory"
+msgstr "Změnit viditelnost skrytých souborů."
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a grid of thumbnails."
@@ -1990,7 +1982,7 @@ msgstr "Konstanty"
#: editor/editor_help.cpp
msgid "Property Descriptions"
-msgstr "Popis vlastnosti"
+msgstr "Popisy vlastnosti"
#: editor/editor_help.cpp
msgid "(value)"
@@ -2006,7 +1998,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Method Descriptions"
-msgstr "Popis metody"
+msgstr "Popisy metod"
#: editor/editor_help.cpp
msgid ""
@@ -2123,7 +2115,7 @@ msgstr "Vymazat výstup"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
#: editor/editor_profiler.cpp
msgid "Stop"
-msgstr "Zastavit"
+msgstr "Stop"
#: editor/editor_network_profiler.cpp editor/editor_profiler.cpp
#: editor/plugins/animation_state_machine_editor.cpp editor/rename_dialog.cpp
@@ -2430,12 +2422,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Nelze naÄíst scénu, která nebyla nikdy uložena."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Vrátit zpět"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Uložit scénu"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Tuto akci nelze vrátit zpÄ›t. PokraÄovat?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2483,7 +2478,7 @@ msgstr "Zavřít scénu"
#: editor/editor_node.cpp
msgid "Reopen Closed Scene"
-msgstr "Znovuotevřít uzavřenou scénu"
+msgstr "Znovu otevřít zavřenou scénu"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
@@ -2631,7 +2626,7 @@ msgstr "Pozice doku"
#: editor/editor_node.cpp
msgid "Distraction Free Mode"
-msgstr "Nerozptylující režim"
+msgstr "Nerozptylující režitm"
#: editor/editor_node.cpp
msgid "Toggle distraction-free mode."
@@ -2655,11 +2650,11 @@ msgstr "Kopírovat text"
#: editor/editor_node.cpp
msgid "Next tab"
-msgstr "Další záložka"
+msgstr "Další panel"
#: editor/editor_node.cpp
msgid "Previous tab"
-msgstr "Předchozí záložka"
+msgstr "Předchozí tab"
#: editor/editor_node.cpp
msgid "Filter Files..."
@@ -2716,10 +2711,6 @@ msgid "Redo"
msgstr "Znovu"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Vrátit scénu"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Různé nástroje pro projekt nebo scény."
@@ -2882,7 +2873,7 @@ msgstr "Otevřít složku s daty a nastavením editoru"
#: editor/editor_node.cpp
msgid "Toggle Fullscreen"
-msgstr "Celá obrazovka"
+msgstr "Přepnout celou obrazovku"
#: editor/editor_node.cpp
#, fuzzy
@@ -2955,7 +2946,7 @@ msgstr "Spustit projekt."
#: editor/editor_node.cpp
msgid "Play"
-msgstr "Spustit"
+msgstr "Hrát"
#: editor/editor_node.cpp
msgid "Pause the scene execution for debugging."
@@ -2975,7 +2966,7 @@ msgstr "Spustit upravenou scénu."
#: editor/editor_node.cpp
msgid "Play Scene"
-msgstr "Spustit scénu"
+msgstr "Přehrát scénu"
#: editor/editor_node.cpp
msgid "Play custom scene"
@@ -2983,7 +2974,7 @@ msgstr "Přehrát vlastní scénu"
#: editor/editor_node.cpp
msgid "Play Custom Scene"
-msgstr "Spustit vlastní scénu"
+msgstr "Přehrát upravenou scénu"
#: editor/editor_node.cpp
msgid "Changing the video driver requires restarting the editor."
@@ -3091,15 +3082,15 @@ msgstr "Vybrat"
#: editor/editor_node.cpp
msgid "Open 2D Editor"
-msgstr "Otevřít 2D editor"
+msgstr "Otevřít 2D Editor"
#: editor/editor_node.cpp
msgid "Open 3D Editor"
-msgstr "Otevřít 3D editor"
+msgstr "Otevřít 3D Editor"
#: editor/editor_node.cpp
msgid "Open Script Editor"
-msgstr "Otevřít editor skriptů"
+msgstr "Otevřít Editor Skriptů"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
@@ -3327,8 +3318,9 @@ msgid ""
"No runnable export preset found for this platform.\n"
"Please add a runnable preset in the export menu."
msgstr ""
-"Nenalezen žádný spustitelný preset pro export pro tuto platformu.\n"
-"rosím přidejte spustitelný preset v menu exportu."
+"Nebylo nalezeno žádné spustilené přednastavení pro exportování na tuto "
+"platformu.\n"
+"Přidejte prosím spustitelné přednastavení v exportovacím menu."
#: editor/editor_run_script.cpp
msgid "Write your logic in the _run() method."
@@ -3354,6 +3346,13 @@ msgstr "Nelze spustit skript:"
msgid "Did you forget the '_run' method?"
msgstr "Nezapoměl jste metodu '_run'?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Podržte Ctrl k uvolnění getteru. Podržte Shift k uvolnění generického "
+"podpisu."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3948,6 +3947,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Ukládání..."
@@ -5067,7 +5070,6 @@ msgid "Failed creating lightmap images, make sure path is writable."
msgstr ""
#: editor/plugins/baked_lightmap_editor_plugin.cpp
-#, fuzzy
msgid "Bake Lightmaps"
msgstr "Zapéct lightmapy"
@@ -5332,7 +5334,7 @@ msgstr ""
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom Reset"
-msgstr "Resetovat zoom"
+msgstr "Obnovení lupy"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -6012,11 +6014,12 @@ msgid "Remove item %d?"
msgstr "Odstranit %d?"
#: editor/plugins/mesh_library_editor_plugin.cpp
-#, fuzzy
msgid ""
"Update from existing scene?:\n"
"%s"
-msgstr "Aktualizovat ze scény"
+msgstr ""
+"Aktualizovat z existující scény?:\n"
+"%s"
#: editor/plugins/mesh_library_editor_plugin.cpp
#, fuzzy
@@ -6898,12 +6901,13 @@ msgid ""
msgstr "Odpojit '%s' od '%s'"
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Řádek"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(ignorovat)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorovat)"
+msgid "Line"
+msgstr "Řádek"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7389,6 +7393,15 @@ msgid "XForm Dialog"
msgstr "XForm Dialog"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "Přichytit k mřížce"
@@ -8055,7 +8068,7 @@ msgstr "Najít dlaždici"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Transpose"
-msgstr ""
+msgstr "Transponovat"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Disable Autotile"
@@ -8195,14 +8208,12 @@ msgid "Z Index"
msgstr "Index:"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Region Mode"
-msgstr "Režim otáÄení"
+msgstr "Režim oblasti"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Collision Mode"
-msgstr "InterpolaÄní režim"
+msgstr "Kolizní režim"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8210,14 +8221,12 @@ msgid "Occlusion Mode"
msgstr "Editovat polygon"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Navigation Mode"
-msgstr "Vytvořit Navigation Mesh"
+msgstr "NavigaÄní režim"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Bitmask Mode"
-msgstr "Režim otáÄení"
+msgstr "Režim bitové masky"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8225,9 +8234,8 @@ msgid "Priority Mode"
msgstr "Expertní režim:"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Icon Mode"
-msgstr "Režim přesouvání"
+msgstr "Režim ikony"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Z Index Mode"
@@ -9512,9 +9520,8 @@ msgid "Make Patch"
msgstr ""
#: editor/project_export.cpp
-#, fuzzy
msgid "Pack File"
-msgstr " Soubory"
+msgstr "Soubour balíÄk"
#: editor/project_export.cpp
msgid "Features"
@@ -10498,8 +10505,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Vymazat skript"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Připojit skript"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10661,6 +10669,13 @@ msgid "Open Documentation"
msgstr "Otevřít dokumentaci"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Přidat podřízený uzel"
@@ -10710,12 +10725,14 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Připojit nový, nebo existující skript k vybranému uzlu."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Detach the script from the selected node."
+msgstr "Připojit nový, nebo existující skript k vybranému uzlu."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10837,6 +10854,10 @@ msgid "A directory with the same name exists."
msgstr "Složka se stejným jménem již existuje."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Soubor neexistuje."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Neplatná přípona."
@@ -10878,6 +10899,10 @@ msgid "File exists, it will be reused."
msgstr "Soubor již existuje, bude znovu použit."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Neplatná cesta."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Neplatné jméno třídy."
@@ -11947,6 +11972,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11971,6 +12000,32 @@ msgstr "Neplatné jméno třídy"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12702,6 +12757,21 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Konstanty není možné upravovat."
+#~ msgid "Not in resource path."
+#~ msgstr "Není v cestě ke zdroji."
+
+#~ msgid "Revert"
+#~ msgstr "Vrátit zpět"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Tuto akci nelze vrátit zpÄ›t. PokraÄovat?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Vrátit scénu"
+
+#~ msgid "Clear Script"
+#~ msgstr "Vymazat skript"
+
#~ msgid "Issue Tracker"
#~ msgstr "Sledování chyb"
diff --git a/editor/translations/da.po b/editor/translations/da.po
index 5e88313d95..8eeaaafaea 100644
--- a/editor/translations/da.po
+++ b/editor/translations/da.po
@@ -881,7 +881,6 @@ msgstr "Forbind Signal: "
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1516,18 +1515,9 @@ msgstr "Aktivér"
msgid "Rearrange Autoloads"
msgstr "Flytte om på Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Ugyldig Sti."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Fil eksisterer ikke."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ikke i stien for ressource."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2520,12 +2510,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Kan ikke genindlæse en scene, der aldrig blev gemt."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Vend tilbage"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Gem Scene"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Denne handling kan ikke fortrydes. Vend tilbage alligevel?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2816,10 +2809,6 @@ msgid "Redo"
msgstr "Annuller Fortyd"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Gendan scene"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Diverse projekt eller scene redskaber."
@@ -3469,6 +3458,10 @@ msgstr "Kunne ikke køre script:"
msgid "Did you forget the '_run' method?"
msgstr "Glemte du '_run' metoden?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Vælg Noder at Importere"
@@ -4108,6 +4101,10 @@ msgid "Error running post-import script:"
msgstr "Fejl ved kørsel af efter-import script:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Gemmer..."
@@ -7154,15 +7151,15 @@ msgid ""
msgstr "Afbryd '%s' fra '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Linje:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Tilføj Funktion"
@@ -7651,6 +7648,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10733,7 +10739,8 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+#, fuzzy
+msgid "Detach Script"
msgstr "Ryd Script"
#: editor/scene_tree_dock.cpp
@@ -10902,6 +10909,13 @@ msgid "Open Documentation"
msgstr "Ã…ben Seneste"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10952,11 +10966,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -11087,6 +11101,10 @@ msgid "A directory with the same name exists."
msgstr "En fil eller mappe med dette navn findes allerede."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Fil eksisterer ikke."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Du skal bruge en gyldig udvidelse."
@@ -11132,6 +11150,11 @@ msgstr "Filen findes, vil blive genbrugt"
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Ugyldig Sti."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Ugyldigt navn."
@@ -12224,6 +12247,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12248,6 +12275,32 @@ msgstr "Ugyldigt navn."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12971,6 +13024,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Konstanter kan ikke ændres."
+#~ msgid "Not in resource path."
+#~ msgstr "Ikke i stien for ressource."
+
+#~ msgid "Revert"
+#~ msgstr "Vend tilbage"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Denne handling kan ikke fortrydes. Vend tilbage alligevel?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Gendan scene"
+
#~ msgid "Issue Tracker"
#~ msgstr "Problem Tracker"
diff --git a/editor/translations/de.po b/editor/translations/de.po
index c3b2d6ee58..b52206e56e 100644
--- a/editor/translations/de.po
+++ b/editor/translations/de.po
@@ -49,12 +49,15 @@
# Draco Drache <jan.holger.te@gmail.com>, 2019.
# Jonas <dotchucknorris@gmx.de>, 2019.
# PagDev <pag.develop@gmail.com>, 2020.
+# artism90 <artism90@googlemail.com>, 2020.
+# Jaigskim <filzstift112@gmail.com>, 2020.
+# Jacqueline Ulken <Jacqueline.Ulken@protonmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-04 15:11+0000\n"
-"Last-Translator: Anonymous <noreply@weblate.org>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: So Wieso <sowieso@dukun.de>\n"
"Language-Team: German <https://hosted.weblate.org/projects/godot-engine/"
"godot/de/>\n"
"Language: de\n"
@@ -67,12 +70,11 @@ msgstr ""
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr ""
-"Ungültiger Argument-Typ in convert()-Aufruf, TYPE_*-Konstanten benötigt."
+msgstr "Ungültiger Argument-Typ in convert(), TYPE_*-Konstanten benötigt."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "Zeichenkette der Länge 1 erwartet (ein Zeichen)."
+msgstr "Zeichenkette der Länge 1 erwartet (exakt ein Symbol)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -95,7 +97,7 @@ msgstr "Ungültige Operanden für Operator %s, %s und %s."
#: core/math/expression.cpp
msgid "Invalid index of type %s for base type %s"
-msgstr "Ungültiger Index des Typs ‚%s‘ für Grundtyp %s"
+msgstr "Ungültiger Index des Typs %s für Grundtyp %s"
#: core/math/expression.cpp
msgid "Invalid named index '%s' for base type %s"
@@ -435,7 +437,7 @@ msgstr "Spuren neu anordnen"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr "Transformationsspuren gelten nur für Nodes die auf Spatial basieren."
+msgstr "Transformationsspuren gelten nur für Nodes, die auf Spatial basieren."
#: editor/animation_track_editor.cpp
msgid ""
@@ -538,11 +540,11 @@ msgstr ""
"Diese Animation gehört zu einer importierten Szene, Änderungen an "
"importierten Spuren werden nicht gespeichert.\n"
"\n"
-"Um neue Spuren hinzufügen zu können muss unter den Importeinstellungen\n"
+"Um neue Spuren hinzufügen zu können muss unter den Importeinstellungen der "
+"Szene\n"
"„Animation > Storage“ zu „Files“ gesetzt und „Animation > Keep Custom "
-"Tracks“ aktiviert werden.\n"
-"Danach ist die Szene erneut zu importieren.\n"
-"Alternativ kann eine Importeinstllung benutzt werden welche Animationen in "
+"Tracks“ aktiviert werden, danach ist die Szene erneut zu importieren.\n"
+"Alternativ kann eine Importeinstellung benutzt werden, welche Animationen in "
"separate Dateien importiert."
#: editor/animation_track_editor.cpp
@@ -552,7 +554,7 @@ msgstr "Achtung: Es wird eine importierte Animation bearbeitet"
#: editor/animation_track_editor.cpp
msgid "Select an AnimationPlayer node to create and edit animations."
msgstr ""
-"Ein AnimationPlayer-Node auswählen um Animationen zu erzeugen oder zu "
+"Ein AnimationPlayer-Node auswählen, um Animationen zu erzeugen oder zu "
"bearbeiten."
#: editor/animation_track_editor.cpp
@@ -887,7 +889,6 @@ msgstr "Signal kann nicht verbunden werden"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1502,17 +1503,9 @@ msgstr "Aktivieren"
msgid "Rearrange Autoloads"
msgstr "Autoloads neu anordnen"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Ungültiger Pfad."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Datei existiert nicht."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Nicht im Ressourcen-Pfad."
+msgid "Can't add autoload:"
+msgstr "Autoload konnte nicht hinzugefügt werden:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1629,8 +1622,9 @@ msgid ""
"Enabled'."
msgstr ""
"Die Zielplattform benötigt ‚ETC‘-Texturkompression für den Treiber-Fallback "
-"auf GLES2. Bitte ‚Import Etc‘ in den Projekteinstellungen aktivieren oder "
-"‚Driver Fallback Enabled‘ ausschalten."
+"auf GLES2. \n"
+"Bitte ‚Import Etc‘ in den Projekteinstellungen aktivieren oder ‚Driver "
+"Fallback Enabled‘ ausschalten."
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
@@ -2015,7 +2009,7 @@ msgstr "Methoden"
#: editor/editor_help.cpp
msgid "Theme Properties"
-msgstr "Motiv-Eigenschaften"
+msgstr "Theme-Eigenschaften"
#: editor/editor_help.cpp
msgid "Enumerations"
@@ -2092,11 +2086,11 @@ msgstr "Nur Eigenschaften"
#: editor/editor_help_search.cpp
msgid "Theme Properties Only"
-msgstr "Nur Motiv-Eigenschaften"
+msgstr "Nur Theme-Eigenschaften"
#: editor/editor_help_search.cpp
msgid "Member Type"
-msgstr "Mitgliedstyp"
+msgstr "Attribut-Typ"
#: editor/editor_help_search.cpp
msgid "Class"
@@ -2112,7 +2106,7 @@ msgstr "Signal"
#: editor/editor_help_search.cpp editor/plugins/theme_editor_plugin.cpp
msgid "Constant"
-msgstr "Konstant"
+msgstr "Konstante"
#: editor/editor_help_search.cpp
msgid "Property"
@@ -2120,7 +2114,7 @@ msgstr "Eigenschaft"
#: editor/editor_help_search.cpp
msgid "Theme Property"
-msgstr "Motiv-Eigenschaft"
+msgstr "Theme-Eigenschaft"
#: editor/editor_inspector.cpp editor/project_settings_editor.cpp
msgid "Property:"
@@ -2128,11 +2122,11 @@ msgstr "Eigenschaft:"
#: editor/editor_inspector.cpp
msgid "Set"
-msgstr "Setze"
+msgstr "Festlegen"
#: editor/editor_inspector.cpp
msgid "Set Multiple:"
-msgstr "Mehrfach einstellen:"
+msgstr "Mehrfach festlegen:"
#: editor/editor_log.cpp
msgid "Output:"
@@ -2159,7 +2153,7 @@ msgstr "Ausgabe löschen"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
#: editor/editor_profiler.cpp
msgid "Stop"
-msgstr "Stop"
+msgstr "Stopp"
#: editor/editor_network_profiler.cpp editor/editor_profiler.cpp
#: editor/plugins/animation_state_machine_editor.cpp editor/rename_dialog.cpp
@@ -2172,7 +2166,7 @@ msgstr "%s/s"
#: editor/editor_network_profiler.cpp
msgid "Down"
-msgstr "Herunter"
+msgstr "Runter"
#: editor/editor_network_profiler.cpp
msgid "Up"
@@ -2213,7 +2207,7 @@ msgstr "OK"
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Error saving resource!"
-msgstr "Fehler beim speichern der Ressource!"
+msgstr "Fehler beim Speichern der Ressource!"
#: editor/editor_node.cpp
msgid ""
@@ -2229,7 +2223,7 @@ msgstr "Speichere Ressource als..."
#: editor/editor_node.cpp
msgid "Can't open file for writing:"
-msgstr "Datei kann nicht zum schreiben geöffnet werden:"
+msgstr "Datei kann nicht zum Schreiben geöffnet werden:"
#: editor/editor_node.cpp
msgid "Requested file format unknown:"
@@ -2237,13 +2231,13 @@ msgstr "Angefordertes Dateiformat unbekannt:"
#: editor/editor_node.cpp
msgid "Error while saving."
-msgstr "Fehler beim speichern."
+msgstr "Fehler beim Speichern."
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
msgid "Can't open '%s'. The file could have been moved or deleted."
msgstr ""
"Datei ‚%s‘ kann nicht geöffnet werden. Die Datei könnte verschoben oder "
-"gelöscht sein."
+"gelöscht worden sein."
#: editor/editor_node.cpp
msgid "Error while parsing '%s'."
@@ -2282,8 +2276,8 @@ msgid ""
"This scene can't be saved because there is a cyclic instancing inclusion.\n"
"Please resolve it and then attempt to save again."
msgstr ""
-"Diese Szene kann nicht gespeichert werden da sie eine zyklische "
-"Instantiierungshierarchie enthält.\n"
+"Diese Szene kann nicht gespeichert werden, da sie eine zyklische "
+"Instanziierungshierarchie enthält.\n"
"Speichern ist erst nach Beheben des Konflikts möglich."
#: editor/editor_node.cpp
@@ -2300,23 +2294,23 @@ msgstr "Momentan geöffnete Szenen können nicht überschrieben werden!"
#: editor/editor_node.cpp
msgid "Can't load MeshLibrary for merging!"
-msgstr "MeshLibrary konnte nicht zum vereinen geladen werden!"
+msgstr "MeshLibrary konnte nicht zum Vereinen geladen werden!"
#: editor/editor_node.cpp
msgid "Error saving MeshLibrary!"
-msgstr "Fehler beim speichern der MeshLibrary!"
+msgstr "Fehler beim Speichern der MeshLibrary!"
#: editor/editor_node.cpp
msgid "Can't load TileSet for merging!"
-msgstr "TileSet konnte nicht zum vereinen geladen werden!"
+msgstr "TileSet konnte nicht zum Vereinen geladen werden!"
#: editor/editor_node.cpp
msgid "Error saving TileSet!"
-msgstr "Fehler beim speichern des TileSet!"
+msgstr "Fehler beim Speichern des TileSet!"
#: editor/editor_node.cpp
msgid "Error trying to save layout!"
-msgstr "Fehler beim speichern des Layouts!"
+msgstr "Fehler beim Speichern des Layouts!"
#: editor/editor_node.cpp
msgid "Default editor layout overridden."
@@ -2324,7 +2318,7 @@ msgstr "Standard-Editorlayout überschrieben."
#: editor/editor_node.cpp
msgid "Layout name not found!"
-msgstr "Layout Name nicht gefunden!"
+msgstr "Layout-Name nicht gefunden!"
#: editor/editor_node.cpp
msgid "Restored default layout to base settings."
@@ -2345,7 +2339,7 @@ msgid ""
"This resource belongs to a scene that was instanced or inherited.\n"
"Changes to it won't be kept when saving the current scene."
msgstr ""
-"Diese Ressource gehört zu einer instantiierten oder geerbten Szene.\n"
+"Diese Ressource gehört zu einer instanziierten oder geerbten Szene.\n"
"Änderungen an der Ressource werden beim Speichern der aktuellen Szene nicht "
"mitgespeichert."
@@ -2366,7 +2360,7 @@ msgid ""
"understand this workflow."
msgstr ""
"Diese Szene wurde importiert, Änderungen an ihr werden nicht gespeichert.\n"
-"Instantiierung oder Vererbung sind nötig um Änderungen vorzunehmen.\n"
+"Instanziierung oder Vererbung ist nötig, um Änderungen vorzunehmen.\n"
"Die Dokumentation zum Szenenimport beschreibt den nötigen Arbeitsablauf."
#: editor/editor_node.cpp
@@ -2375,18 +2369,19 @@ msgid ""
"Please read the documentation relevant to debugging to better understand "
"this workflow."
msgstr ""
-"Dies ist ein Fern-Objekt, Änderungen an ihm werden nicht gespeichert.\n"
+"Dies ist ein nicht-lokales Objekt, Änderungen an ihm werden nicht "
+"gespeichert.\n"
"Die Dokumentation zum Debugging beschreibt den nötigen Arbeitsablauf."
#: editor/editor_node.cpp
msgid "There is no defined scene to run."
-msgstr "Es ist keine zu startende Szene definiert."
+msgstr "Es ist keine abzuspielende Szene definiert."
#: editor/editor_node.cpp
msgid "Current scene was never saved, please save it prior to running."
msgstr ""
-"Die aktuelle Szene wurde noch nicht gespeichert, bitte speichere sie vor dem "
-"Starten."
+"Die aktuelle Szene wurde noch nicht gespeichert, bitte vor dem Abspielen "
+"sichern."
#: editor/editor_node.cpp
msgid "Could not start subprocess!"
@@ -2474,13 +2469,17 @@ msgstr ""
"Szene kann nicht neu geladen werden, wenn sie vorher nicht gespeichert wurde."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Zurücksetzen"
+msgid "Reload Saved Scene"
+msgstr "Gespeicherte Szene neu laden"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
-"Diese Aktion kann nicht rückgängig gemacht werden. Trotzdem zurücksetzen?"
+"Die aktuelle Szene enthält ungesicherte Änderungen.\n"
+"Soll die Szene trotzdem neu geladen werden? Diese Aktion kann nicht "
+"rückgängig gemacht werden."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2612,9 +2611,10 @@ msgid ""
"You can change it later in \"Project Settings\" under the 'application' "
"category."
msgstr ""
-"Die ausgewählte Szene ‚%s‘ existiert nicht.\n"
-"Wähle eine gültige Szene in den Projekteinstellungen unter der Kategorie "
-"„Anwendung“."
+"Die ausgewählte Szene ‚%s‘ existiert nicht, soll eine gültige ausgewählt "
+"werden?\n"
+"Dies kann später in den Projekteinstellungen unter der Kategorie ‚Anwendung‘ "
+"geändert werden."
#: editor/editor_node.cpp
msgid ""
@@ -2622,9 +2622,10 @@ msgid ""
"You can change it later in \"Project Settings\" under the 'application' "
"category."
msgstr ""
-"Die ausgewählte Szene ‚%s‘ ist keine gültige Datei für eine Szene.\n"
-"Wähle eine gültige Szene in den Projekteinstellungen unter der Kategorie "
-"„Anwendung“."
+"Die ausgewählte Szene ‚%s‘ ist keine gültige Datei für eine Szene, soll eine "
+"andere ausgewählt werden?\n"
+"Dies kann später in den Projekteinstellungen unter der Kategorie ‚Anwendung‘ "
+"geändert werden."
#: editor/editor_node.cpp
msgid "Save Layout"
@@ -2775,10 +2776,6 @@ msgid "Redo"
msgstr "Wiederherstellen"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Szene zurücksetzen"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Sonstiges Projekt oder szenenübergreifende Werkzeuge."
@@ -3428,6 +3425,12 @@ msgstr "Skript konnte nicht ausgeführt werden:"
msgid "Did you forget the '_run' method?"
msgstr "Hast du die '_run' Methode vergessen?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Strg-Taste halten um auf Ganzzahlen zu runden. Umschalt-Taste halten für "
+"präzisere Änderungen."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selektiere Node(s) für den Import"
@@ -3939,7 +3942,7 @@ msgstr "Nodes filtern"
#: editor/groups_editor.cpp
msgid "Nodes in Group"
-msgstr "Nodes in der Gruppe"
+msgstr "Nodes in Gruppe"
#: editor/groups_editor.cpp
msgid "Empty groups will be automatically removed."
@@ -4027,6 +4030,12 @@ msgid "Error running post-import script:"
msgstr "Fehler beim ausführen des Post-Import Skripts:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+"Wurde ein von Node abstammendes Objekt in der ‚post_import()‘-Methode "
+"zurückgegeben?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Speichere..."
@@ -4581,7 +4590,7 @@ msgstr "Spiele ausgewählte Animation vom Start. (Umschalt+D)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Play selected animation from current pos. (D)"
-msgstr "Ausgewählte Animation von aktueller Position aus abspielen. (D)"
+msgstr "Spiele ausgewählte Animation von aktueller Position. (D)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Animation position (in seconds)."
@@ -4621,7 +4630,7 @@ msgstr "Zwiebelhaut aktivieren"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Onion Skinning Options"
-msgstr "Zwiebelhaut-Einstellugen"
+msgstr "Zwiebelhaut-Einstellungen"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Directions"
@@ -5268,8 +5277,8 @@ msgid ""
"When active, moving Control nodes changes their anchors instead of their "
"margins."
msgstr ""
-"Wenn aktiviert ändert das Verschieben von Control-Nodes ihre Anker anstatt "
-"ihre Ausmaße."
+"Wenn aktiviert, ändert das Verschieben von Control-Nodes deren Bezugspunkte "
+"statt ihre Randabstände."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Top Left"
@@ -5624,7 +5633,7 @@ msgstr "Zeige Ansichtsfenster (Viewport)"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Group And Lock Icons"
-msgstr "Gruppe zeigen und Icons sperren"
+msgstr "Gruppen und Symbole anzeigen"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Center Selection"
@@ -6769,11 +6778,11 @@ msgstr ""
#: editor/plugins/script_editor_plugin.cpp
msgid "Import Theme"
-msgstr "Motiv importieren"
+msgstr "Theme importieren"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error while saving theme"
-msgstr "Fehler beim Speichern des Motivs"
+msgstr "Fehler beim Speichern des Themes"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error saving"
@@ -6781,7 +6790,7 @@ msgstr "Fehler beim Speichern"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save Theme As..."
-msgstr "Motiv speichern als..."
+msgstr "Theme speichern als..."
#: editor/plugins/script_editor_plugin.cpp
msgid "%s Class Reference"
@@ -6868,7 +6877,7 @@ msgstr "Vorwärts im Verlauf"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Theme"
-msgstr "Motiv"
+msgstr "Theme"
#: editor/plugins/script_editor_plugin.cpp
msgid "Import Theme..."
@@ -6876,11 +6885,11 @@ msgstr "Thema importieren..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Reload Theme"
-msgstr "Motiv neu laden"
+msgstr "Theme neu laden"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save Theme"
-msgstr "Motiv speichern"
+msgstr "Theme speichern"
#: editor/plugins/script_editor_plugin.cpp
msgid "Close All"
@@ -6988,12 +6997,12 @@ msgstr ""
"Fehlende verbundene Methode ‚%s‘ für Signal ‚%s‘ von Node ‚%s‘ zu Node ‚%s‘."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Zeile"
+msgid "[Ignore]"
+msgstr "[Ignorieren]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorieren)"
+msgid "Line"
+msgstr "Zeile"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7471,6 +7480,21 @@ msgid "XForm Dialog"
msgstr "Transformationsdialog"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Klicken um zwischen Sichtbarkeitsmodi umzuschalten.\n"
+"\n"
+"Offenes Auge: Griffe sind sichtbar.\n"
+"Geschlossenes Auge: Griffe sind unsichtbar.\n"
+"Halb offenes Auge: Griffe sind auch durch deckende Oberflächen sichtbar "
+"(\"Röntgenblick\")."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Nodes am Boden einrasten"
@@ -7961,7 +7985,7 @@ msgstr "Aus derzeitigem Editor-Thema erstellen"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Toggle Button"
-msgstr "Knopf umschalten"
+msgstr "Umschaltknopf"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Disabled Button"
@@ -8066,7 +8090,7 @@ msgstr "Farbe"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Theme File"
-msgstr "Motiv-Datei"
+msgstr "Theme-Datei"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Erase Selection"
@@ -8196,7 +8220,7 @@ msgstr "Nächste Koordinate"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Select the next shape, subtile, or Tile."
-msgstr "Die nächste Form oder Kachel auswählen."
+msgstr "Die nächste Form oder (Unter-)Kachel auswählen."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Previous Coordinate"
@@ -8204,7 +8228,7 @@ msgstr "Vorherige Koordinate"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Select the previous shape, subtile, or Tile."
-msgstr "Die vorherige Form oder Kachel auswählen."
+msgstr "Die vorherige Form oder (Unter-)Kachel auswählen."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Region"
@@ -8244,7 +8268,7 @@ msgstr "Kollisionsmodus"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Occlusion Mode"
-msgstr "Verschlussmodus"
+msgstr "Verdeckungsmodus"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Navigation Mode"
@@ -9317,7 +9341,7 @@ msgid ""
msgstr ""
"Stufenfunktion ( Vektor(Kante), Vektor(x) ).\n"
"\n"
-"Gibt 0.0 zurück falls ‚x‘ kleiner als ‚Kante‘, ansonsten 1.0."
+"Gibt 0.0 zurück falls ‚x‘ kleiner als ‚Kante‘, ansonsten 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -10575,8 +10599,8 @@ msgid "Instance Child Scene"
msgstr "Szene hier instantiieren"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Skript leeren"
+msgid "Detach Script"
+msgstr "Skript loslösen"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10742,6 +10766,15 @@ msgid "Open Documentation"
msgstr "Dokumentation öffnen"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"Skript konnte nicht angehängt werden: Keine Sprachen registriert.\n"
+"Vermutliche Ursache ist dass der Editor ohne Sprachmodulen gebaut wurde."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Node hier anhängen"
@@ -10790,12 +10823,12 @@ msgstr ""
"kein Root-Node existiert."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr "Ein neues oder existierendes Skript zum ausgewählten Node hinzufügen."
+msgid "Attach a new or existing script to the selected node."
+msgstr "Ein neues oder existierendes Skript dem ausgewählten Node anhängen."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Entferne Skript von ausgewähltem Node."
+msgid "Detach the script from the selected node."
+msgstr "Skript vom ausgewählten Node loslösen."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10850,12 +10883,12 @@ msgid ""
"Node is in %s group(s).\n"
"Click to show groups dock."
msgstr ""
-"Node ist %s Gruppe(n).\n"
+"Node gehört zu %s Gruppe(n).\n"
"Hier klicken zur Gruppenverwaltung."
#: editor/scene_tree_editor.cpp
msgid "Open Script:"
-msgstr "Offenes Skript:"
+msgstr "Skript öffnen:"
#: editor/scene_tree_editor.cpp
msgid ""
@@ -10927,6 +10960,10 @@ msgid "A directory with the same name exists."
msgstr "Ein Verzeichnis mit gleichem Namen existiert bereits."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Datei existiert nicht."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Ungültige Dateiendung."
@@ -10967,6 +11004,10 @@ msgid "File exists, it will be reused."
msgstr "Datei existiert bereits, wird erneut verwendet."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Ungültiger Pfad."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Ungültiger Klassenname."
@@ -11986,7 +12027,7 @@ msgstr "Paketsegmente dürfen keine Länge gleich Null haben."
#: platform/android/export/export.cpp
msgid "The character '%s' is not allowed in Android application package names."
-msgstr "Das Zeichen ‚%s‘ ist in Android-Anwendungs-Paketnamen nicht gestattet."
+msgstr "Das Zeichen ‚%s‘ ist in Android-Anwendungspaketnamen nicht gestattet."
#: platform/android/export/export.cpp
msgid "A digit cannot be the first character in a package segment."
@@ -12020,6 +12061,11 @@ msgstr ""
"konfiguriert."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Release-Keystore wurde nicht korrekt konfiguriert in den Exporteinstellungen."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Eigene Builds erfordern gültigen Android-SDK-Pfad in den Editoreinstellungen."
@@ -12047,6 +12093,41 @@ msgstr "Ungültiger Paketname:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"Ungültiges „GodotPaymentV3“-Modul eingebunden in den „android/modules“-"
+"Projekteinstellungen (wurde in Godot 3.2.2 geändert).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+"„Use Custom Build“ muss aktiviert werden um die Plugins nutzen zu können."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"„Degrees Of Freedom“ ist nur gültig wenn „Xr Mode“ als „Occulus Mobile VR“ "
+"gesetzt wurde."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"„Hand Tracking“ ist nur gültig wenn „Xr Mode“ als „Occulus Mobile VR“ "
+"gesetzt wurde."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"„Focus Awareness“ ist nur gültig wenn „Xr Mode“ als „Occulus Mobile VR“ "
+"gesetzt wurde."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12229,7 +12310,7 @@ msgid ""
msgstr ""
"CollisionPolygon2D liefert nur eine Kollisionsform für ein von "
"CollisionObject2D abgeleitetes Node. Es kann nur als Unterobjekt von Area2D, "
-"StaticBody2D, RigidBody2D, KinematicBody2D usw. eingehängt werden um diesen "
+"StaticBody2D, RigidBody2D, KinematicBody2D usw. eingehängt werden, um diesen "
"eine Form zu geben."
#: scene/2d/collision_polygon_2d.cpp
@@ -12244,7 +12325,7 @@ msgid ""
msgstr ""
"CollisionShape2D liefert nur eine Kollisionsform für ein von "
"CollisionObject2D abgeleitetes Node. Es kann nur als Unterobjekt von Area2D, "
-"StaticBody2D, RigidBody2D, KinematicBody2D usw. eingehängt werden um diesen "
+"StaticBody2D, RigidBody2D, KinematicBody2D usw. eingehängt werden, um diesen "
"eine Form zu geben."
#: scene/2d/collision_shape_2d.cpp
@@ -12298,9 +12379,9 @@ msgid ""
"NavigationPolygonInstance must be a child or grandchild to a Navigation2D "
"node. It only provides navigation data."
msgstr ""
-"Eine NavigationPolygon-Instanz muss ein Unterobjekt erster oder zweiter "
-"Ordnung unterhalb eines Navigation2D-Node sein. Sie liefert nur "
-"Navigationsdaten."
+"NavigationPolygonInstance muss ein Unterobjekt erster oder zweiter Ordnung "
+"unterhalb eines Navigation2D-Node sein. Es liefert nur "
+"Navigationsinformationen."
#: scene/2d/parallax_layer.cpp
msgid ""
@@ -12381,10 +12462,10 @@ msgid ""
"to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, "
"KinematicBody2D, etc. to give them a shape."
msgstr ""
-"Ein TileMap mit aktivierter „Use Parent“-Option benötigt ein "
-"CollisionObject2D-Elternnode dem es Form verleiht. Das TileMap sollte als "
-"als Unterobjekt von Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, usw. "
-"verwendet werden um ihnen eine Form zu geben."
+"Eine TileMap mit aktivierter „Use Parent“-Option benötigt ein Eltern-Node "
+"des Typs CollisionObject2D, welcher der TileMap eine Form verleiht. Sie "
+"sollte als Unterobjekt von Area2D, StaticBody2D, RigidBody2D, "
+"KinematicBody2D, usw. verwendet werden, um ihnen eine Form zu geben."
#: scene/2d/visibility_notifier_2d.cpp
msgid ""
@@ -12469,7 +12550,8 @@ msgid ""
msgstr ""
"CollisionPolygon liefert nur eine Kollisionsform für ein von CollisionObject "
"abgeleitetes Node. Es kann nur als Unterobjekt von Area, StaticBody, "
-"RigidBody, KinematicBody usw. eingehängt werden um diesen eine Form zu geben."
+"RigidBody, KinematicBody usw. eingehängt werden, um diesen eine Form zu "
+"verleihen."
#: scene/3d/collision_polygon.cpp
msgid "An empty CollisionPolygon has no effect on collision."
@@ -12483,7 +12565,8 @@ msgid ""
msgstr ""
"CollisionShape liefert nur eine Kollisionsform für ein von CollisionObject "
"abgeleitetes Node. Es kann nur als Unterobjekt von Area, StaticBody, "
-"RigidBody, KinematicBody usw. eingehängt werden um diesen eine Form zu geben."
+"RigidBody, KinematicBody usw. eingehängt werden, um diesen eine Form zu "
+"geben."
#: scene/3d/collision_shape.cpp
msgid ""
@@ -12547,8 +12630,8 @@ msgid ""
"NavigationMeshInstance must be a child or grandchild to a Navigation node. "
"It only provides navigation data."
msgstr ""
-"Eine NavigationMesh-Instanz muss ein Unterobjekt erster oder höherer Ordnung "
-"eines Navigation-Nodes sein. Es liefert nur Navigationsdaten."
+"NavigationMeshInstance muss ein Unterobjekt erster oder zweiter Ordnung "
+"eines Navigation-Nodes sein. Es liefert nur Navigationsinformationen."
#: scene/3d/particles.cpp
msgid ""
@@ -12852,6 +12935,22 @@ msgstr "Varyings können nur in Vertex-Funktion zugewiesen werden."
msgid "Constants cannot be modified."
msgstr "Konstanten können nicht verändert werden."
+#~ msgid "Not in resource path."
+#~ msgstr "Nicht im Ressourcen-Pfad."
+
+#~ msgid "Revert"
+#~ msgstr "Zurücksetzen"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr ""
+#~ "Diese Aktion kann nicht rückgängig gemacht werden. Trotzdem zurücksetzen?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Szene zurücksetzen"
+
+#~ msgid "Clear Script"
+#~ msgstr "Skript leeren"
+
#~ msgid "Issue Tracker"
#~ msgstr "Problem-Melder"
diff --git a/editor/translations/de_CH.po b/editor/translations/de_CH.po
deleted file mode 100644
index c86daa54dc..0000000000
--- a/editor/translations/de_CH.po
+++ /dev/null
@@ -1,12956 +0,0 @@
-# Swiss High German translation of the Godot Engine editor
-# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
-# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
-# This file is distributed under the same license as the Godot source code.
-# Christian Fisch <christian.fiesel@gmail.com>, 2016.
-# Nils <nfa106008@iet-gibb.ch>, 2020.
-# PagDev <pag.develop@gmail.com>, 2020.
-msgid ""
-msgstr ""
-"Project-Id-Version: Godot Engine editor\n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-03-08 22:33+0000\n"
-"Last-Translator: PagDev <pag.develop@gmail.com>\n"
-"Language-Team: German (Switzerland) <https://hosted.weblate.org/projects/"
-"godot-engine/godot/de_CH/>\n"
-"Language: de_CH\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0-dev\n"
-
-#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
-#: modules/visual_script/visual_script_builtin_funcs.cpp
-msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr ""
-"Ungültiger Argument-Typ in convert()-Aufruf, TYPE_*-Konstanten benötigt."
-
-#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
-msgid "Expected a string of length 1 (a character)."
-msgstr "Es wurde eine Zeichenfolge der Länge 1 (a character) erwartet."
-
-#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
-#: modules/mono/glue/gd_glue.cpp
-#: modules/visual_script/visual_script_builtin_funcs.cpp
-msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr "Nicht genügend Bytes zum Decodieren von Bytes oder ungültiges Format."
-
-#: core/math/expression.cpp
-msgid "Invalid input %i (not passed) in expression"
-msgstr ""
-
-#: core/math/expression.cpp
-msgid "self can't be used because instance is null (not passed)"
-msgstr "self cha nid brucht wärde wöu d Instanz null isch (nid düre cho)"
-
-#: core/math/expression.cpp
-msgid "Invalid operands to operator %s, %s and %s."
-msgstr "Invalidi Operande füre Operator %s, %s und %s."
-
-#: core/math/expression.cpp
-msgid "Invalid index of type %s for base type %s"
-msgstr "Invalide index vom Typ %s füre Basis Typ %s"
-
-#: core/math/expression.cpp
-msgid "Invalid named index '%s' for base type %s"
-msgstr "Invalid benamslete index '%s' füre Basis Typ %s"
-
-#: core/math/expression.cpp
-msgid "Invalid arguments to construct '%s'"
-msgstr "Invalidi argumänt für s '%s' z konstruiere"
-
-#: core/math/expression.cpp
-msgid "On call to '%s':"
-msgstr "Ufem ufruef für '%s':"
-
-#: core/ustring.cpp
-msgid "B"
-msgstr "B"
-
-#: core/ustring.cpp
-msgid "KiB"
-msgstr "KiB"
-
-#: core/ustring.cpp
-msgid "MiB"
-msgstr "MiB"
-
-#: core/ustring.cpp
-msgid "GiB"
-msgstr "GiB"
-
-#: core/ustring.cpp
-msgid "TiB"
-msgstr "TiB"
-
-#: core/ustring.cpp
-msgid "PiB"
-msgstr "PiB"
-
-#: core/ustring.cpp
-msgid "EiB"
-msgstr "EiB"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Free"
-msgstr "Gratis"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Balanced"
-msgstr "Usgliche"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Mirror"
-msgstr "Spiegu"
-
-#: editor/animation_bezier_editor.cpp editor/editor_profiler.cpp
-msgid "Time:"
-msgstr "Zit:"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Value:"
-msgstr "Wärt:"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Insert Key Here"
-msgstr "Schlüssu hie ifüege"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Duplicate Selected Key(s)"
-msgstr "Usgwäuti Schlüssle dupliziere"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Delete Selected Key(s)"
-msgstr "Usgwäuti Schlüssle lösche"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Add Bezier Point"
-msgstr "Dr Bezier Punkt hinzuefüege"
-
-#: editor/animation_bezier_editor.cpp
-msgid "Move Bezier Points"
-msgstr "Dr Bezier Punkt bewege"
-
-#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
-msgid "Anim Duplicate Keys"
-msgstr "Anim Schlüssle Dupliziere"
-
-#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
-msgid "Anim Delete Keys"
-msgstr "Anim Schlüssle lösche"
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Change Keyframe Time"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Change Transition"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Change Transform"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Change Keyframe Value"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Change Call"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Multi Change Keyframe Time"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Multi Change Transition"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Multi Change Transform"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Multi Change Keyframe Value"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Multi Change Call"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Change Animation Length"
-msgstr "Typ ändern"
-
-#: editor/animation_track_editor.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Change Animation Loop"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Property Track"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "3D Transform Track"
-msgstr "Transformationstyp"
-
-#: editor/animation_track_editor.cpp
-msgid "Call Method Track"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Bezier Curve Track"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Audio Playback Track"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Animation Playback Track"
-msgstr "Stoppe Animations-Wiedergabe. (S)"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Animation length (frames)"
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Animation length (seconds)"
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-msgid "Add Track"
-msgstr "Spur hinzuefüege"
-
-#: editor/animation_track_editor.cpp
-msgid "Animation Looping"
-msgstr "Animationswiderholig"
-
-#: editor/animation_track_editor.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Functions:"
-msgstr "Funktione:"
-
-#: editor/animation_track_editor.cpp
-msgid "Audio Clips:"
-msgstr "Audioclips:"
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Clips:"
-msgstr "Animationsclips:"
-
-#: editor/animation_track_editor.cpp
-msgid "Change Track Path"
-msgstr "D Spur wächsle"
-
-#: editor/animation_track_editor.cpp
-msgid "Toggle this track on/off."
-msgstr "Die Spur ah-/abschaute"
-
-#: editor/animation_track_editor.cpp
-msgid "Update Mode (How this property is set)"
-msgstr "Update Modus (Wie die Eigeschaft gsetzt isch)"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Interpolation Mode"
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Remove this track."
-msgstr "Ungültige Bilder löschen"
-
-#: editor/animation_track_editor.cpp
-msgid "Time (s): "
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Toggle Track Enabled"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Continuous"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Discrete"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Trigger"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Capture"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Nearest"
-msgstr ""
-
-#: editor/animation_track_editor.cpp editor/plugins/curve_editor_plugin.cpp
-#: editor/property_editor.cpp
-msgid "Linear"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Cubic"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Clamp Loop Interp"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Wrap Loop Interp"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Insert Key"
-msgstr "Bild einfügen"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Duplicate Key(s)"
-msgstr "Node(s) duplizieren"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Delete Key(s)"
-msgstr "Node(s) löschen"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Change Animation Update Mode"
-msgstr "Typ ändern"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Change Animation Interpolation Mode"
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Change Animation Loop Mode"
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-msgid "Remove Anim Track"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Create NEW track for %s and insert key?"
-msgstr "Willst du eine neue Ebene inklusiv Bild in %s einfügen?"
-
-#: editor/animation_track_editor.cpp
-msgid "Create %d NEW tracks and insert keys?"
-msgstr "Erstelle %d in neuer Ebene inklusiv Bild?"
-
-#: editor/animation_track_editor.cpp editor/create_dialog.cpp
-#: editor/editor_audio_buses.cpp editor/editor_feature_profile.cpp
-#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#: editor/script_create_dialog.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Create"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Insert"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "AnimationPlayer can't animate itself, only other players."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Create & Insert"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Insert Track & Key"
-msgstr "Anim Ebene und Bild einfügen"
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Insert Key"
-msgstr "Anim Bild einfügen"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Change Animation Step"
-msgstr "Bild einfügen"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Rearrange Tracks"
-msgstr "Node erstellen"
-
-#: editor/animation_track_editor.cpp
-msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid ""
-"Audio tracks can only point to nodes of type:\n"
-"-AudioStreamPlayer\n"
-"-AudioStreamPlayer2D\n"
-"-AudioStreamPlayer3D"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Animation tracks can only point to AnimationPlayer nodes."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "An animation player can't animate itself, only other players."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Not possible to add a new track without a root"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Invalid track for Bezier (no suitable sub-properties)"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Add Bezier Track"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Track path is invalid, so can't add a key."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Track is not of type Spatial, can't insert key"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Add Transform Track Key"
-msgstr "Transformationstyp"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Add Track Key"
-msgstr "Anim Ebene und Bild einfügen"
-
-#: editor/animation_track_editor.cpp
-msgid "Track path is invalid, so can't add a method key."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Add Method Track Key"
-msgstr "Anim Ebene und Bild einfügen"
-
-#: editor/animation_track_editor.cpp
-msgid "Method not found in object: "
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Move Keys"
-msgstr "Anim Bilder bewegen"
-
-#: editor/animation_track_editor.cpp
-msgid "Clipboard is empty"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Paste Tracks"
-msgstr "Node erstellen"
-
-#: editor/animation_track_editor.cpp
-msgid "Anim Scale Keys"
-msgstr "Anim verlängern"
-
-#: editor/animation_track_editor.cpp
-msgid ""
-"This option does not work for Bezier editing, as it's only a single track."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid ""
-"This animation belongs to an imported scene, so changes to imported tracks "
-"will not be saved.\n"
-"\n"
-"To enable the ability to add custom tracks, navigate to the scene's import "
-"settings and set\n"
-"\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks"
-"\", then re-import.\n"
-"Alternatively, use an import preset that imports animations to separate "
-"files."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Warning: Editing imported animation"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Select an AnimationPlayer node to create and edit animations."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Only show tracks from nodes selected in tree."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Group tracks by node or display them as plain list."
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Snap:"
-msgstr "Selektiere Node(s) zum Importieren aus"
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Animation step value."
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-msgid "Seconds"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "FPS"
-msgstr ""
-
-#: editor/animation_track_editor.cpp editor/editor_properties.cpp
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
-#: editor/plugins/tile_set_editor_plugin.cpp editor/project_manager.cpp
-#: editor/project_settings_editor.cpp editor/property_editor.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Edit"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Animation properties."
-msgstr "Animations-Node"
-
-#: editor/animation_track_editor.cpp
-msgid "Copy Tracks"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Scale Selection"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Scale From Cursor"
-msgstr ""
-
-#: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Duplicate Selection"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Duplicate Transposed"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Delete Selection"
-msgstr "Script hinzufügen"
-
-#: editor/animation_track_editor.cpp
-msgid "Go to Next Step"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Go to Previous Step"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Optimize Animation"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Clean-Up Animation"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Pick the node that will be animated:"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Use Bezier Curves"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Anim. Optimizer"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Max. Linear Error:"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Max. Angular Error:"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Max Optimizable Angle:"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Optimize"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Remove invalid keys"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/animation_track_editor.cpp
-msgid "Remove unresolved and empty tracks"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Clean-up all animations"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Clean-Up Animation(s) (NO UNDO!)"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Clean-Up"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Scale Ratio:"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-msgid "Select Tracks to Copy"
-msgstr ""
-
-#: editor/animation_track_editor.cpp editor/editor_log.cpp
-#: editor/editor_properties.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp editor/property_editor.cpp
-#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
-msgid "Copy"
-msgstr ""
-
-#: editor/animation_track_editor.cpp
-#, fuzzy
-msgid "Select All/None"
-msgstr "Node(s) löschen"
-
-#: editor/animation_track_editor_plugins.cpp
-msgid "Add Audio Track Clip"
-msgstr ""
-
-#: editor/animation_track_editor_plugins.cpp
-msgid "Change Audio Track Clip Start Offset"
-msgstr ""
-
-#: editor/animation_track_editor_plugins.cpp
-msgid "Change Audio Track Clip End Offset"
-msgstr ""
-
-#: editor/array_property_edit.cpp
-msgid "Resize Array"
-msgstr ""
-
-#: editor/array_property_edit.cpp
-msgid "Change Array Value Type"
-msgstr ""
-
-#: editor/array_property_edit.cpp
-msgid "Change Array Value"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Go to Line"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Line Number:"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "%d replaced."
-msgstr ""
-
-#: editor/code_editor.cpp editor/editor_help.cpp
-msgid "%d match."
-msgstr ""
-
-#: editor/code_editor.cpp editor/editor_help.cpp
-msgid "%d matches."
-msgstr ""
-
-#: editor/code_editor.cpp editor/find_in_files.cpp
-msgid "Match Case"
-msgstr ""
-
-#: editor/code_editor.cpp editor/find_in_files.cpp
-msgid "Whole Words"
-msgstr ""
-
-#: editor/code_editor.cpp editor/rename_dialog.cpp
-msgid "Replace"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Replace All"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Selection Only"
-msgstr ""
-
-#: editor/code_editor.cpp editor/plugins/script_text_editor.cpp
-#: editor/plugins/text_editor.cpp
-msgid "Standard"
-msgstr ""
-
-#: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp
-msgid "Toggle Scripts Panel"
-msgstr ""
-
-#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/texture_region_editor_plugin.cpp
-#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
-msgid "Zoom In"
-msgstr ""
-
-#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/texture_region_editor_plugin.cpp
-#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
-msgid "Zoom Out"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Reset Zoom"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Warnings"
-msgstr ""
-
-#: editor/code_editor.cpp
-msgid "Line and column numbers."
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Method in target node must be specified."
-msgstr "Die Methode muss im Ziel Node definiert werden!"
-
-#: editor/connections_dialog.cpp
-msgid ""
-"Target method not found. Specify a valid method or attach a script to the "
-"target node."
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Connect to Node:"
-msgstr "Verbindung zu Node:"
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Connect to Script:"
-msgstr "Verbindung zu Node:"
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "From Signal:"
-msgstr "Connections editieren"
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Scene does not contain any script."
-msgstr "Node enthält keine Geometrie (Flächen)."
-
-#: editor/connections_dialog.cpp editor/editor_autoload_settings.cpp
-#: editor/groups_editor.cpp editor/plugins/item_list_editor_plugin.cpp
-#: editor/plugins/theme_editor_plugin.cpp editor/project_settings_editor.cpp
-msgid "Add"
-msgstr ""
-
-#: editor/connections_dialog.cpp editor/dependency_editor.cpp
-#: editor/editor_feature_profile.cpp editor/groups_editor.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/plugins/theme_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp editor/project_manager.cpp
-#: editor/project_settings_editor.cpp
-msgid "Remove"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Add Extra Call Argument:"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Extra Call Arguments:"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Receiver Method:"
-msgstr "Node erstellen"
-
-#: editor/connections_dialog.cpp
-msgid "Advanced"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Deferred"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid ""
-"Defers the signal, storing it in a queue and only firing it at idle time."
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Oneshot"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Disconnects the signal after its first emission."
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Cannot connect signal"
-msgstr "Connections editieren"
-
-#: editor/connections_dialog.cpp editor/dependency_editor.cpp
-#: editor/export_template_manager.cpp editor/groups_editor.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#: editor/plugins/version_control_editor_plugin.cpp editor/project_export.cpp
-#: editor/project_settings_editor.cpp editor/property_editor.cpp
-#: editor/run_settings_dialog.cpp editor/settings_config_dialog.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Close"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Connect"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Signal:"
-msgstr "Script hinzufügen"
-
-#: editor/connections_dialog.cpp
-msgid "Connect '%s' to '%s'"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Disconnect '%s' from '%s'"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Disconnect all from signal: '%s'"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Connect..."
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Disconnect"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Connect a Signal to a Method"
-msgstr "Connections editieren"
-
-#: editor/connections_dialog.cpp
-#, fuzzy
-msgid "Edit Connection:"
-msgstr "Connections editieren"
-
-#: editor/connections_dialog.cpp
-msgid "Are you sure you want to remove all connections from the \"%s\" signal?"
-msgstr ""
-
-#: editor/connections_dialog.cpp editor/editor_help.cpp editor/node_dock.cpp
-msgid "Signals"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Are you sure you want to remove all connections from this signal?"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Disconnect All"
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Edit..."
-msgstr ""
-
-#: editor/connections_dialog.cpp
-msgid "Go To Method"
-msgstr ""
-
-#: editor/create_dialog.cpp
-#, fuzzy
-msgid "Change %s Type"
-msgstr "Typ ändern"
-
-#: editor/create_dialog.cpp editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Change"
-msgstr "Typ ändern"
-
-#: editor/create_dialog.cpp
-#, fuzzy
-msgid "Create New %s"
-msgstr "Node erstellen"
-
-#: editor/create_dialog.cpp editor/editor_file_dialog.cpp
-#: editor/filesystem_dock.cpp
-msgid "Favorites:"
-msgstr ""
-
-#: editor/create_dialog.cpp editor/editor_file_dialog.cpp
-msgid "Recent:"
-msgstr ""
-
-#: editor/create_dialog.cpp editor/plugins/script_editor_plugin.cpp
-#: editor/property_selector.cpp editor/quick_open.cpp
-#: modules/visual_script/visual_script_property_selector.cpp
-msgid "Search:"
-msgstr ""
-
-#: editor/create_dialog.cpp editor/plugins/script_editor_plugin.cpp
-#: editor/property_selector.cpp editor/quick_open.cpp
-#: modules/visual_script/visual_script_property_selector.cpp
-msgid "Matches:"
-msgstr ""
-
-#: editor/create_dialog.cpp editor/editor_plugin_settings.cpp
-#: editor/plugin_config_dialog.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp editor/property_selector.cpp
-#: modules/visual_script/visual_script_property_selector.cpp
-msgid "Description:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Search Replacement For:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Dependencies For:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid ""
-"Scene '%s' is currently being edited.\n"
-"Changes will only take effect when reloaded."
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid ""
-"Resource '%s' is in use.\n"
-"Changes will only take effect when reloaded."
-msgstr ""
-
-#: editor/dependency_editor.cpp
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Dependencies"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Resource"
-msgstr ""
-
-#: editor/dependency_editor.cpp editor/editor_autoload_settings.cpp
-#: editor/project_manager.cpp editor/project_settings_editor.cpp
-msgid "Path"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Dependencies:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Fix Broken"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Dependency Editor"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Search Replacement Resource:"
-msgstr ""
-
-#: editor/dependency_editor.cpp editor/editor_file_dialog.cpp
-#: editor/editor_help_search.cpp editor/editor_node.cpp
-#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
-#: editor/property_selector.cpp editor/quick_open.cpp
-#: editor/script_create_dialog.cpp
-#: modules/visual_script/visual_script_property_selector.cpp
-#: scene/gui/file_dialog.cpp
-msgid "Open"
-msgstr "Öffnen"
-
-#: editor/dependency_editor.cpp
-msgid "Owners Of:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Remove selected files from the project? (Can't be restored)"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid ""
-"The files being removed are required by other resources in order for them to "
-"work.\n"
-"Remove them anyway? (no undo)"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Cannot remove:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Error loading:"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-#, fuzzy
-msgid "Load failed due to missing dependencies:"
-msgstr "Szene '%s' hat kapute Abhängigkeiten:"
-
-#: editor/dependency_editor.cpp editor/editor_node.cpp
-msgid "Open Anyway"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Which action should be taken?"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Fix Dependencies"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Errors loading!"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Permanently delete %d item(s)? (No undo!)"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Show Dependencies"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Orphan Resource Explorer"
-msgstr ""
-
-#: editor/dependency_editor.cpp editor/editor_audio_buses.cpp
-#: editor/editor_file_dialog.cpp editor/editor_node.cpp
-#: editor/filesystem_dock.cpp editor/plugins/item_list_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp editor/project_export.cpp
-#: editor/project_settings_editor.cpp editor/scene_tree_dock.cpp
-msgid "Delete"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Owns"
-msgstr ""
-
-#: editor/dependency_editor.cpp
-msgid "Resources Without Explicit Ownership:"
-msgstr ""
-
-#: editor/dictionary_property_edit.cpp
-msgid "Change Dictionary Key"
-msgstr ""
-
-#: editor/dictionary_property_edit.cpp
-#, fuzzy
-msgid "Change Dictionary Value"
-msgstr "Typ ändern"
-
-#: editor/editor_about.cpp
-msgid "Thanks from the Godot community!"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Godot Engine contributors"
-msgstr ""
-
-#: editor/editor_about.cpp
-#, fuzzy
-msgid "Project Founders"
-msgstr "Projekt exportieren"
-
-#: editor/editor_about.cpp
-msgid "Lead Developer"
-msgstr ""
-
-#: editor/editor_about.cpp
-#, fuzzy
-msgid "Project Manager "
-msgstr "Projektname:"
-
-#: editor/editor_about.cpp
-msgid "Developers"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Authors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Platinum Sponsors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Gold Sponsors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Mini Sponsors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Gold Donors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Silver Donors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Bronze Donors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Donors"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "License"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Third-party Licenses"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid ""
-"Godot Engine relies on a number of third-party free and open source "
-"libraries, all compatible with the terms of its MIT license. The following "
-"is an exhaustive list of all such third-party components with their "
-"respective copyright statements and license terms."
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "All Components"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Components"
-msgstr ""
-
-#: editor/editor_about.cpp
-msgid "Licenses"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp editor/project_manager.cpp
-msgid "Error opening package file, not in ZIP format."
-msgstr ""
-
-#: editor/editor_asset_installer.cpp
-msgid "%s (Already Exists)"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp
-msgid "Uncompressing Assets"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp editor/project_manager.cpp
-msgid "The following files failed extraction from package:"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp
-#, fuzzy
-msgid "And %s more files."
-msgstr "Node erstellen"
-
-#: editor/editor_asset_installer.cpp editor/project_manager.cpp
-msgid "Package installed successfully!"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Success!"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp
-msgid "Package Contents:"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp editor/editor_node.cpp
-msgid "Install"
-msgstr ""
-
-#: editor/editor_asset_installer.cpp
-msgid "Package Installer"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Speakers"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Add Effect"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Rename Audio Bus"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-#, fuzzy
-msgid "Change Audio Bus Volume"
-msgstr "Autoplay Umschalten"
-
-#: editor/editor_audio_buses.cpp
-#, fuzzy
-msgid "Toggle Audio Bus Solo"
-msgstr "Autoplay Umschalten"
-
-#: editor/editor_audio_buses.cpp
-msgid "Toggle Audio Bus Mute"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Toggle Audio Bus Bypass Effects"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Select Audio Bus Send"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Add Audio Bus Effect"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Move Bus Effect"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Delete Bus Effect"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Drag & drop to rearrange."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Solo"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Mute"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Bypass"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Bus options"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp editor/filesystem_dock.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp editor/scene_tree_dock.cpp
-msgid "Duplicate"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Reset Volume"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Delete Effect"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Audio"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Add Audio Bus"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Master bus can't be deleted!"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-#, fuzzy
-msgid "Delete Audio Bus"
-msgstr "Bild einfügen"
-
-#: editor/editor_audio_buses.cpp
-#, fuzzy
-msgid "Duplicate Audio Bus"
-msgstr "Node(s) duplizieren"
-
-#: editor/editor_audio_buses.cpp
-msgid "Reset Bus Volume"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-#, fuzzy
-msgid "Move Audio Bus"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/editor_audio_buses.cpp
-msgid "Save Audio Bus Layout As..."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Location for New Layout..."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Open Audio Bus Layout"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "There is no '%s' file."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Layout"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Invalid file, not an audio bus layout."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-#, fuzzy
-msgid "Error saving file: %s"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/editor_audio_buses.cpp
-msgid "Add Bus"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Add a new Audio Bus to this layout."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp editor/editor_properties.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp editor/property_editor.cpp
-#: editor/script_create_dialog.cpp
-msgid "Load"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Load an existing Bus Layout."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Save As"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Save this Bus Layout to a file."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp editor/import_dock.cpp
-msgid "Load Default"
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Load the default Bus Layout."
-msgstr ""
-
-#: editor/editor_audio_buses.cpp
-msgid "Create a new Bus Layout."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Invalid name."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Valid characters:"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Must not collide with an existing engine class name."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Must not collide with an existing built-in type name."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Must not collide with an existing global constant name."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Keyword cannot be used as an autoload name."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Autoload '%s' already exists!"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Rename Autoload"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Toggle AutoLoad Globals"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Move Autoload"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Remove Autoload"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/editor_plugin_settings.cpp
-msgid "Enable"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Rearrange Autoloads"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Projektname:"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Add AutoLoad"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/editor_file_dialog.cpp
-#: editor/editor_plugin_settings.cpp
-#: editor/plugins/animation_tree_editor_plugin.cpp
-#: editor/script_create_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Path:"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Node Name:"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/editor_help_search.cpp
-#: editor/editor_profiler.cpp editor/project_manager.cpp
-#: editor/settings_config_dialog.cpp
-msgid "Name"
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp
-msgid "Singleton"
-msgstr ""
-
-#: editor/editor_data.cpp editor/inspector_dock.cpp
-msgid "Paste Params"
-msgstr ""
-
-#: editor/editor_data.cpp
-msgid "Updating Scene"
-msgstr ""
-
-#: editor/editor_data.cpp
-msgid "Storing local changes..."
-msgstr ""
-
-#: editor/editor_data.cpp
-msgid "Updating scene..."
-msgstr ""
-
-#: editor/editor_data.cpp editor/editor_properties.cpp
-msgid "[empty]"
-msgstr ""
-
-#: editor/editor_data.cpp
-msgid "[unsaved]"
-msgstr ""
-
-#: editor/editor_dir_dialog.cpp
-msgid "Please select a base directory first."
-msgstr ""
-
-#: editor/editor_dir_dialog.cpp
-msgid "Choose a Directory"
-msgstr ""
-
-#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
-#: editor/filesystem_dock.cpp editor/project_manager.cpp
-#: scene/gui/file_dialog.cpp
-msgid "Create Folder"
-msgstr ""
-
-#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
-#: editor/editor_plugin_settings.cpp editor/filesystem_dock.cpp
-#: editor/plugins/theme_editor_plugin.cpp editor/project_export.cpp
-#: modules/visual_script/visual_script_editor.cpp scene/gui/file_dialog.cpp
-msgid "Name:"
-msgstr ""
-
-#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
-#: editor/filesystem_dock.cpp scene/gui/file_dialog.cpp
-msgid "Could not create folder."
-msgstr ""
-
-#: editor/editor_dir_dialog.cpp
-msgid "Choose"
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid "Storing File:"
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid "No export template found at the expected path:"
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid "Packing"
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid ""
-"Target platform requires 'ETC' texture compression for GLES2. Enable 'Import "
-"Etc' in Project Settings."
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid ""
-"Target platform requires 'ETC2' texture compression for GLES3. Enable "
-"'Import Etc 2' in Project Settings."
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid ""
-"Target platform requires 'ETC' texture compression for the driver fallback "
-"to GLES2.\n"
-"Enable 'Import Etc' in Project Settings, or disable 'Driver Fallback "
-"Enabled'."
-msgstr ""
-
-#: editor/editor_export.cpp platform/android/export/export.cpp
-#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
-#: platform/osx/export/export.cpp platform/uwp/export/export.cpp
-msgid "Custom debug template not found."
-msgstr ""
-
-#: editor/editor_export.cpp platform/android/export/export.cpp
-#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
-#: platform/osx/export/export.cpp platform/uwp/export/export.cpp
-msgid "Custom release template not found."
-msgstr ""
-
-#: editor/editor_export.cpp platform/javascript/export/export.cpp
-msgid "Template file not found:"
-msgstr ""
-
-#: editor/editor_export.cpp
-msgid "On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "3D Editor"
-msgstr "Verzeichnis öffnen"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Script Editor"
-msgstr "Verzeichnis öffnen"
-
-#: editor/editor_feature_profile.cpp
-msgid "Asset Library"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "Scene Tree Editing"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Import Dock"
-msgstr "Importierte Projekte"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Node Dock"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/editor_feature_profile.cpp
-msgid "FileSystem and Import Docks"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "Erase profile '%s'? (no undo)"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "Profile must be a valid filename and must not contain '.'"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "Profile with this name already exists."
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "(Editor Disabled, Properties Disabled)"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "(Properties Disabled)"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "(Editor Disabled)"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Class Options:"
-msgstr "Script hinzufügen"
-
-#: editor/editor_feature_profile.cpp
-msgid "Enable Contextual Editor"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Enabled Properties:"
-msgstr "Node erstellen"
-
-#: editor/editor_feature_profile.cpp
-msgid "Enabled Features:"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "Enabled Classes:"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid "File '%s' format is invalid, import aborted."
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-msgid ""
-"Profile '%s' already exists. Remove it first before importing, import "
-"aborted."
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Error saving profile to path: '%s'."
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/editor_feature_profile.cpp
-msgid "Unset"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Current Profile:"
-msgstr "Node(s) löschen"
-
-#: editor/editor_feature_profile.cpp
-msgid "Make Current"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "New"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp editor/editor_node.cpp
-#: editor/project_manager.cpp
-msgid "Import"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp editor/project_export.cpp
-msgid "Export"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Available Profiles:"
-msgstr "TimeScale-Node"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Class Options"
-msgstr "Script hinzufügen"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "New profile name:"
-msgstr "Node"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Erase Profile"
-msgstr "Oberfläche %d"
-
-#: editor/editor_feature_profile.cpp
-msgid "Godot Feature Profile"
-msgstr ""
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Import Profile(s)"
-msgstr "Importierte Projekte"
-
-#: editor/editor_feature_profile.cpp
-#, fuzzy
-msgid "Export Profile"
-msgstr "Projekt exportieren"
-
-#: editor/editor_feature_profile.cpp
-msgid "Manage Editor Feature Profiles"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
-msgid "Select Current Folder"
-msgstr "Node(s) löschen"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "File Exists, Overwrite?"
-msgstr "Datei existiert, Ãœberschreiben?"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
-msgid "Select This Folder"
-msgstr "Node(s) löschen"
-
-#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-msgid "Copy Path"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Open in File Manager"
-msgstr "Datei öffnen"
-
-#: editor/editor_file_dialog.cpp editor/editor_node.cpp
-#: editor/filesystem_dock.cpp editor/project_manager.cpp
-#, fuzzy
-msgid "Show in File Manager"
-msgstr "Datei öffnen"
-
-#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-msgid "New Folder..."
-msgstr ""
-
-#: editor/editor_file_dialog.cpp editor/find_in_files.cpp
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Refresh"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "All Recognized"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "All Files (*)"
-msgstr "Alle Dateien (*)"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Open a File"
-msgstr "Datei öffnen"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Open File(s)"
-msgstr "Datei(en) öffnen"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Open a Directory"
-msgstr "Verzeichnis öffnen"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Open a File or Directory"
-msgstr "Datei oder Verzeichnis öffnen"
-
-#: editor/editor_file_dialog.cpp editor/editor_node.cpp
-#: editor/editor_properties.cpp editor/inspector_dock.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp
-msgid "Save"
-msgstr "Speichern"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Save a File"
-msgstr "Datei speichern"
-
-#: editor/editor_file_dialog.cpp
-msgid "Go Back"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Go Forward"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Go Up"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Toggle Hidden Files"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Toggle Favorite"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Toggle Mode"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Focus Path"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Move Favorite Up"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "Move Favorite Down"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-#, fuzzy
-msgid "Go to previous folder."
-msgstr "Node erstellen"
-
-#: editor/editor_file_dialog.cpp
-#, fuzzy
-msgid "Go to next folder."
-msgstr "Node erstellen"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
-msgid "Go to parent folder."
-msgstr "Node erstellen"
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Refresh files."
-msgstr ""
-
-#: editor/editor_file_dialog.cpp
-msgid "(Un)favorite current folder."
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Toggle the visibility of hidden files."
-msgstr ""
-
-#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-msgid "View items as a grid of thumbnails."
-msgstr ""
-
-#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-msgid "View items as a list."
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Directories & Files:"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp editor/plugins/sprite_editor_plugin.cpp
-#: editor/plugins/style_box_editor_plugin.cpp
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Preview:"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "File:"
-msgstr ""
-
-#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-msgid "Must use a valid extension."
-msgstr ""
-
-#: editor/editor_file_system.cpp
-msgid "ScanSources"
-msgstr ""
-
-#: editor/editor_file_system.cpp
-msgid ""
-"There are multiple importers for different types pointing to file %s, import "
-"aborted"
-msgstr ""
-
-#: editor/editor_file_system.cpp
-msgid "(Re)Importing Assets"
-msgstr ""
-
-#: editor/editor_help.cpp editor/plugins/spatial_editor_plugin.cpp
-msgid "Top"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "Class:"
-msgstr ""
-
-#: editor/editor_help.cpp editor/scene_tree_editor.cpp
-#: editor/script_create_dialog.cpp
-msgid "Inherits:"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "Inherited by:"
-msgstr ""
-
-#: editor/editor_help.cpp
-#, fuzzy
-msgid "Description"
-msgstr "Script hinzufügen"
-
-#: editor/editor_help.cpp
-msgid "Online Tutorials"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "Properties"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "override:"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "default:"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "Methods"
-msgstr ""
-
-#: editor/editor_help.cpp
-#, fuzzy
-msgid "Theme Properties"
-msgstr "Node erstellen"
-
-#: editor/editor_help.cpp
-msgid "Enumerations"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid "Constants"
-msgstr ""
-
-#: editor/editor_help.cpp
-#, fuzzy
-msgid "Property Descriptions"
-msgstr "Script hinzufügen"
-
-#: editor/editor_help.cpp
-msgid "(value)"
-msgstr ""
-
-#: editor/editor_help.cpp
-msgid ""
-"There is currently no description for this property. Please help us by "
-"[color=$color][url=$url]contributing one[/url][/color]!"
-msgstr ""
-
-#: editor/editor_help.cpp
-#, fuzzy
-msgid "Method Descriptions"
-msgstr "Script hinzufügen"
-
-#: editor/editor_help.cpp
-msgid ""
-"There is currently no description for this method. Please help us by [color="
-"$color][url=$url]contributing one[/url][/color]!"
-msgstr ""
-
-#: editor/editor_help_search.cpp editor/editor_node.cpp
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Search Help"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Case Sensitive"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Show Hierarchy"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Display All"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Classes Only"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Methods Only"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Signals Only"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Constants Only"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Properties Only"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Theme Properties Only"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Member Type"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Class"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Method"
-msgstr ""
-
-#: editor/editor_help_search.cpp editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Signal"
-msgstr "Script hinzufügen"
-
-#: editor/editor_help_search.cpp editor/plugins/theme_editor_plugin.cpp
-msgid "Constant"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-msgid "Property"
-msgstr ""
-
-#: editor/editor_help_search.cpp
-#, fuzzy
-msgid "Theme Property"
-msgstr "Node erstellen"
-
-#: editor/editor_inspector.cpp editor/project_settings_editor.cpp
-msgid "Property:"
-msgstr ""
-
-#: editor/editor_inspector.cpp
-msgid "Set"
-msgstr ""
-
-#: editor/editor_inspector.cpp
-msgid "Set Multiple:"
-msgstr ""
-
-#: editor/editor_log.cpp
-msgid "Output:"
-msgstr ""
-
-#: editor/editor_log.cpp editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
-msgid "Copy Selection"
-msgstr "Script hinzufügen"
-
-#: editor/editor_log.cpp editor/editor_network_profiler.cpp
-#: editor/editor_profiler.cpp editor/editor_properties.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#: editor/property_editor.cpp editor/scene_tree_dock.cpp
-#: editor/script_editor_debugger.cpp
-#: modules/gdnative/gdnative_library_editor_plugin.cpp scene/gui/line_edit.cpp
-#: scene/gui/text_edit.cpp
-msgid "Clear"
-msgstr ""
-
-#: editor/editor_log.cpp
-#, fuzzy
-msgid "Clear Output"
-msgstr "Script hinzufügen"
-
-#: editor/editor_network_profiler.cpp editor/editor_node.cpp
-#: editor/editor_profiler.cpp
-msgid "Stop"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp editor/editor_profiler.cpp
-#: editor/plugins/animation_state_machine_editor.cpp editor/rename_dialog.cpp
-msgid "Start"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp
-msgid "%s/s"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp
-msgid "Down"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp
-msgid "Up"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp editor/editor_node.cpp
-msgid "Node"
-msgstr "Node"
-
-#: editor/editor_network_profiler.cpp
-msgid "Incoming RPC"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp
-msgid "Incoming RSET"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp
-msgid "Outgoing RPC"
-msgstr ""
-
-#: editor/editor_network_profiler.cpp
-msgid "Outgoing RSET"
-msgstr ""
-
-#: editor/editor_node.cpp editor/project_manager.cpp
-msgid "New Window"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Imported resources can't be saved."
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
-#: scene/gui/dialogs.cpp
-msgid "OK"
-msgstr "Okay"
-
-#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
-msgid "Error saving resource!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This resource can't be saved because it does not belong to the edited scene. "
-"Make it unique first."
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
-msgid "Save Resource As..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Can't open file for writing:"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Requested file format unknown:"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Error while saving."
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
-msgid "Can't open '%s'. The file could have been moved or deleted."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Error while parsing '%s'."
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/editor_node.cpp
-msgid "Unexpected end of file '%s'."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Missing '%s' or its dependencies."
-msgstr "Szene '%s' hat kapute Abhängigkeiten:"
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Error while loading '%s'."
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/editor_node.cpp
-msgid "Saving Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Analyzing"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Creating Thumbnail"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "This operation can't be done without a tree root."
-msgstr "Ohne eine Szene kann das nicht funktionieren."
-
-#: editor/editor_node.cpp
-msgid ""
-"This scene can't be saved because there is a cyclic instancing inclusion.\n"
-"Please resolve it and then attempt to save again."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Couldn't save scene. Likely dependencies (instances or inheritance) couldn't "
-"be satisfied."
-msgstr ""
-
-#: editor/editor_node.cpp editor/scene_tree_dock.cpp
-msgid "Can't overwrite scene that is still open!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Can't load MeshLibrary for merging!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Error saving MeshLibrary!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Can't load TileSet for merging!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Error saving TileSet!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Error trying to save layout!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Default editor layout overridden."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Layout name not found!"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Restored default layout to base settings."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This resource belongs to a scene that was imported, so it's not editable.\n"
-"Please read the documentation relevant to importing scenes to better "
-"understand this workflow."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This resource belongs to a scene that was instanced or inherited.\n"
-"Changes to it won't be kept when saving the current scene."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This resource was imported, so it's not editable. Change its settings in the "
-"import panel and then re-import."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This scene was imported, so changes to it won't be kept.\n"
-"Instancing it or inheriting will allow making changes to it.\n"
-"Please read the documentation relevant to importing scenes to better "
-"understand this workflow."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This is a remote object, so changes to it won't be kept.\n"
-"Please read the documentation relevant to debugging to better understand "
-"this workflow."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "There is no defined scene to run."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Current scene was never saved, please save it prior to running."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Could not start subprocess!"
-msgstr ""
-
-#: editor/editor_node.cpp editor/filesystem_dock.cpp
-msgid "Open Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open Base Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Quick Open..."
-msgstr "Öffnen"
-
-#: editor/editor_node.cpp
-msgid "Quick Open Scene..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Quick Open Script..."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Save & Close"
-msgstr "Datei speichern"
-
-#: editor/editor_node.cpp
-msgid "Save changes to '%s' before closing?"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Saved %s modified resource(s)."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "A root node is required to save the scene."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Save Scene As..."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "No"
-msgstr "Node"
-
-#: editor/editor_node.cpp
-msgid "Yes"
-msgstr "Ja"
-
-#: editor/editor_node.cpp
-msgid "This scene has never been saved. Save before running?"
-msgstr ""
-
-#: editor/editor_node.cpp editor/scene_tree_dock.cpp
-msgid "This operation can't be done without a scene."
-msgstr "Ohne eine Szene kann das nicht funktionieren."
-
-#: editor/editor_node.cpp
-msgid "Export Mesh Library"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "This operation can't be done without a root node."
-msgstr "Ohne eine Szene kann das nicht funktionieren."
-
-#: editor/editor_node.cpp
-msgid "Export Tile Set"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "This operation can't be done without a selected node."
-msgstr "Ohne eine Szene kann das nicht funktionieren."
-
-#: editor/editor_node.cpp
-msgid "Current scene not saved. Open anyway?"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Can't reload a scene that was never saved."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Quick Run Scene..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Quit"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Exit the editor?"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open Project Manager?"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Save & Quit"
-msgstr "Datei speichern"
-
-#: editor/editor_node.cpp
-msgid "Save changes to the following scene(s) before quitting?"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Save changes the following scene(s) before opening Project Manager?"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"This option is deprecated. Situations where refresh must be forced are now "
-"considered a bug. Please report."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Pick a Main Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Close Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Reopen Closed Scene"
-msgstr "Datei(en) öffnen"
-
-#: editor/editor_node.cpp
-msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Unable to find script field for addon plugin at: 'res://addons/%s'."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Unable to load addon script from path: '%s'."
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/editor_node.cpp
-msgid ""
-"Unable to load addon script from path: '%s' There seems to be an error in "
-"the code, please check the syntax."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Unable to load addon script from path: '%s' Base type is not EditorPlugin."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Unable to load addon script from path: '%s' Script is not in tool mode."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Scene '%s' was automatically imported, so it can't be modified.\n"
-"To make changes to it, a new inherited scene can be created."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Error loading scene, it must be inside the project path. Use 'Import' to "
-"open the scene, then save it inside the project path."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Scene '%s' has broken dependencies:"
-msgstr "Szene '%s' hat kapute Abhängigkeiten:"
-
-#: editor/editor_node.cpp
-msgid "Clear Recent Scenes"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"No main scene has ever been defined, select one?\n"
-"You can change it later in \"Project Settings\" under the 'application' "
-"category."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Selected scene '%s' does not exist, select a valid one?\n"
-"You can change it later in \"Project Settings\" under the 'application' "
-"category."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Selected scene '%s' is not a scene file, select a valid one?\n"
-"You can change it later in \"Project Settings\" under the 'application' "
-"category."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Save Layout"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Delete Layout"
-msgstr ""
-
-#: editor/editor_node.cpp editor/import_dock.cpp
-#: editor/script_create_dialog.cpp
-msgid "Default"
-msgstr ""
-
-#: editor/editor_node.cpp editor/editor_properties.cpp
-#: editor/plugins/script_editor_plugin.cpp editor/property_editor.cpp
-#, fuzzy
-msgid "Show in FileSystem"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Play This Scene"
-msgstr "Szene starten"
-
-#: editor/editor_node.cpp
-msgid "Close Tab"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Undo Close Tab"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
-msgid "Close Other Tabs"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Close Tabs to the Right"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Close All Tabs"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Switch Scene Tab"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "%d more files or folders"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "%d more folders"
-msgstr "Node erstellen"
-
-#: editor/editor_node.cpp
-msgid "%d more files"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Dock Position"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Distraction Free Mode"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Toggle distraction-free mode."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Add a new scene."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Go to previously opened scene."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Copy Text"
-msgstr "Script hinzufügen"
-
-#: editor/editor_node.cpp
-msgid "Next tab"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Previous tab"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Filter Files..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Operations with scene files."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "New Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "New Inherited Scene..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open Scene..."
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
-msgid "Open Recent"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Save Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Save All Scenes"
-msgstr "Neue Szene speichern als..."
-
-#: editor/editor_node.cpp
-msgid "Convert To..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "MeshLibrary..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "TileSet..."
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
-#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
-msgid "Undo"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
-#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
-msgid "Redo"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Miscellaneous project or scene-wide tools."
-msgstr "Verschiedene Projekte oder Szenenweite Werkzeuge."
-
-#: editor/editor_node.cpp editor/project_manager.cpp
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Project"
-msgstr "Projektname:"
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Project Settings..."
-msgstr "Projekteinstellungen"
-
-#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
-msgid "Version Control"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
-msgid "Set Up Version Control"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Shut Down Version Control"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Export..."
-msgstr "Projekt exportieren"
-
-#: editor/editor_node.cpp
-msgid "Install Android Build Template..."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Open Project Data Folder"
-msgstr "Projekt exportieren"
-
-#: editor/editor_node.cpp editor/plugins/tile_set_editor_plugin.cpp
-msgid "Tools"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Orphan Resource Explorer..."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Quit to Project List"
-msgstr "Zurück zur Projektliste"
-
-#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
-#: editor/project_export.cpp
-msgid "Debug"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Deploy with Remote Debug"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"When exporting or deploying, the resulting executable will attempt to "
-"connect to the IP of this computer in order to be debugged."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Small Deploy with Network FS"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"When this option is enabled, export or deploy will produce a minimal "
-"executable.\n"
-"The filesystem will be provided from the project by the editor over the "
-"network.\n"
-"On Android, deploy will use the USB cable for faster performance. This "
-"option speeds up testing for games with a large footprint."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Visible Collision Shapes"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid ""
-"Collision shapes and raycast nodes (for 2D and 3D) will be visible on the "
-"running game if this option is turned on."
-msgstr ""
-"Collision-Formen und Raycast Nodes (für 2D und 3D) werden im laufenden Spiel "
-"angezeigt, falls diese Option aktiviert ist."
-
-#: editor/editor_node.cpp
-msgid "Visible Navigation"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"Navigation meshes and polygons will be visible on the running game if this "
-"option is turned on."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Sync Scene Changes"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"When this option is turned on, any changes made to the scene in the editor "
-"will be replicated in the running game.\n"
-"When used remotely on a device, this is more efficient with network "
-"filesystem."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Sync Script Changes"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"When this option is turned on, any script that is saved will be reloaded on "
-"the running game.\n"
-"When used remotely on a device, this is more efficient with network "
-"filesystem."
-msgstr ""
-
-#: editor/editor_node.cpp editor/script_create_dialog.cpp
-msgid "Editor"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Editor Settings..."
-msgstr "Connections editieren"
-
-#: editor/editor_node.cpp
-msgid "Editor Layout"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Take Screenshot"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Screenshots are stored in the Editor Data/Settings Folder."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Toggle Fullscreen"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Toggle System Console"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open Editor Data/Settings Folder"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open Editor Data Folder"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open Editor Settings Folder"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Manage Editor Features..."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Manage Export Templates..."
-msgstr "Ungültige Bilder löschen"
-
-#: editor/editor_node.cpp editor/plugins/shader_editor_plugin.cpp
-msgid "Help"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp editor/project_manager.cpp
-#: editor/project_settings_editor.cpp editor/rename_dialog.cpp
-msgid "Search"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/shader_editor_plugin.cpp
-msgid "Online Docs"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Q&A"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Report a Bug"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Send Docs Feedback"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
-msgid "Community"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "About"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Play the project."
-msgstr "Projekt starten."
-
-#: editor/editor_node.cpp
-msgid "Play"
-msgstr "Abspielen"
-
-#: editor/editor_node.cpp
-msgid "Pause the scene execution for debugging."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Pause Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Stop the scene."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Play the edited scene."
-msgstr "Spiele die editierte Szene."
-
-#: editor/editor_node.cpp
-msgid "Play Scene"
-msgstr "Szene starten"
-
-#: editor/editor_node.cpp
-msgid "Play custom scene"
-msgstr "Spiele angepasste Szene"
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Play Custom Scene"
-msgstr "Spiele angepasste Szene"
-
-#: editor/editor_node.cpp
-msgid "Changing the video driver requires restarting the editor."
-msgstr ""
-
-#: editor/editor_node.cpp editor/project_settings_editor.cpp
-#: editor/settings_config_dialog.cpp
-#, fuzzy
-msgid "Save & Restart"
-msgstr "Datei speichern"
-
-#: editor/editor_node.cpp
-msgid "Spins when the editor window redraws."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Update Continuously"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Update When Changed"
-msgstr "Typ ändern"
-
-#: editor/editor_node.cpp
-msgid "Hide Update Spinner"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "FileSystem"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Inspector"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Expand Bottom Panel"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Output"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Don't Save"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Android build template is missing, please install relevant templates."
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Manage Templates"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/editor_node.cpp
-msgid ""
-"This will set up your project for custom Android builds by installing the "
-"source template to \"res://android/build\".\n"
-"You can then apply modifications and build your own custom APK on export "
-"(adding modules, changing the AndroidManifest.xml, etc.).\n"
-"Note that in order to make custom builds instead of using pre-built APKs, "
-"the \"Use Custom Build\" option should be enabled in the Android export "
-"preset."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid ""
-"The Android build template is already installed in this project and it won't "
-"be overwritten.\n"
-"Remove the \"res://android/build\" directory manually before attempting this "
-"operation again."
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Import Templates From ZIP File"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Template Package"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/editor_node.cpp
-msgid "Export Library"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Merge With Existing"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open & Run a Script"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "New Inherited"
-msgstr "Script hinzufügen"
-
-#: editor/editor_node.cpp
-msgid "Load Errors"
-msgstr ""
-
-#: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp
-msgid "Select"
-msgstr ""
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Open 2D Editor"
-msgstr "Verzeichnis öffnen"
-
-#: editor/editor_node.cpp
-#, fuzzy
-msgid "Open 3D Editor"
-msgstr "Verzeichnis öffnen"
-
-#: editor/editor_node.cpp
-msgid "Open Script Editor"
-msgstr ""
-
-#: editor/editor_node.cpp editor/project_manager.cpp
-msgid "Open Asset Library"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open the next Editor"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Open the previous Editor"
-msgstr ""
-
-#: editor/editor_node.h
-msgid "Warning!"
-msgstr ""
-
-#: editor/editor_path.cpp
-#, fuzzy
-msgid "No sub-resources found."
-msgstr "Keine Oberflächen Quelle spezifiziert."
-
-#: editor/editor_plugin.cpp
-msgid "Creating Mesh Previews"
-msgstr ""
-
-#: editor/editor_plugin.cpp
-msgid "Thumbnail..."
-msgstr ""
-
-#: editor/editor_plugin_settings.cpp
-#, fuzzy
-msgid "Main Script:"
-msgstr "Script hinzufügen"
-
-#: editor/editor_plugin_settings.cpp
-#, fuzzy
-msgid "Edit Plugin"
-msgstr "Script hinzufügen"
-
-#: editor/editor_plugin_settings.cpp
-msgid "Installed Plugins:"
-msgstr ""
-
-#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
-msgid "Update"
-msgstr ""
-
-#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Version:"
-msgstr ""
-
-#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
-msgid "Author:"
-msgstr ""
-
-#: editor/editor_plugin_settings.cpp
-msgid "Status:"
-msgstr ""
-
-#: editor/editor_plugin_settings.cpp
-msgid "Edit:"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Measure:"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Frame Time (sec)"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Average Time (sec)"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Frame %"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Physics Frame %"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Inclusive"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Self"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Frame #:"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Time"
-msgstr ""
-
-#: editor/editor_profiler.cpp
-msgid "Calls"
-msgstr ""
-
-#: editor/editor_properties.cpp
-#, fuzzy
-msgid "Edit Text:"
-msgstr "Node Filter editieren"
-
-#: editor/editor_properties.cpp editor/script_create_dialog.cpp
-msgid "On"
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid "Layer"
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid "Bit %d, value %d"
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid "[Empty]"
-msgstr ""
-
-#: editor/editor_properties.cpp editor/plugins/root_motion_editor_plugin.cpp
-msgid "Assign..."
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid "Invalid RID"
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid ""
-"The selected resource (%s) does not match any type expected for this "
-"property (%s)."
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid ""
-"Can't create a ViewportTexture on resources saved as a file.\n"
-"Resource needs to belong to a scene."
-msgstr ""
-
-#: editor/editor_properties.cpp
-msgid ""
-"Can't create a ViewportTexture on this resource because it's not set as "
-"local to scene.\n"
-"Please switch on the 'local to scene' property on it (and all resources "
-"containing it up to a node)."
-msgstr ""
-
-#: editor/editor_properties.cpp editor/property_editor.cpp
-msgid "Pick a Viewport"
-msgstr ""
-
-#: editor/editor_properties.cpp editor/property_editor.cpp
-#, fuzzy
-msgid "New Script"
-msgstr "Script hinzufügen"
-
-#: editor/editor_properties.cpp editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Extend Script"
-msgstr "Script hinzufügen"
-
-#: editor/editor_properties.cpp editor/property_editor.cpp
-msgid "New %s"
-msgstr ""
-
-#: editor/editor_properties.cpp editor/property_editor.cpp
-msgid "Make Unique"
-msgstr ""
-
-#: editor/editor_properties.cpp
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#: editor/plugins/tile_map_editor_plugin.cpp editor/property_editor.cpp
-#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
-msgid "Paste"
-msgstr ""
-
-#: editor/editor_properties.cpp editor/property_editor.cpp
-#, fuzzy
-msgid "Convert To %s"
-msgstr "Verbindung zu Node:"
-
-#: editor/editor_properties.cpp editor/property_editor.cpp
-#, fuzzy
-msgid "Selected node is not a Viewport!"
-msgstr "Selektiere Node(s) zum Importieren aus"
-
-#: editor/editor_properties_array_dict.cpp
-msgid "Size: "
-msgstr ""
-
-#: editor/editor_properties_array_dict.cpp
-msgid "Page: "
-msgstr ""
-
-#: editor/editor_properties_array_dict.cpp
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Remove Item"
-msgstr ""
-
-#: editor/editor_properties_array_dict.cpp
-msgid "New Key:"
-msgstr ""
-
-#: editor/editor_properties_array_dict.cpp
-msgid "New Value:"
-msgstr ""
-
-#: editor/editor_properties_array_dict.cpp
-msgid "Add Key/Value Pair"
-msgstr ""
-
-#: editor/editor_run_native.cpp
-msgid ""
-"No runnable export preset found for this platform.\n"
-"Please add a runnable preset in the export menu."
-msgstr ""
-
-#: editor/editor_run_script.cpp
-msgid "Write your logic in the _run() method."
-msgstr ""
-
-#: editor/editor_run_script.cpp
-msgid "There is an edited scene already."
-msgstr ""
-
-#: editor/editor_run_script.cpp
-msgid "Couldn't instance script:"
-msgstr ""
-
-#: editor/editor_run_script.cpp
-msgid "Did you forget the 'tool' keyword?"
-msgstr "Sieht so aus als hättest du das Schlüsselwort \"tool\" vergessen?"
-
-#: editor/editor_run_script.cpp
-msgid "Couldn't run script:"
-msgstr ""
-
-#: editor/editor_run_script.cpp
-msgid "Did you forget the '_run' method?"
-msgstr ""
-
-#: editor/editor_sub_scene.cpp
-msgid "Select Node(s) to Import"
-msgstr "Selektiere Node(s) zum Importieren aus"
-
-#: editor/editor_sub_scene.cpp editor/project_manager.cpp
-msgid "Browse"
-msgstr ""
-
-#: editor/editor_sub_scene.cpp
-msgid "Scene Path:"
-msgstr ""
-
-#: editor/editor_sub_scene.cpp
-msgid "Import From Node:"
-msgstr "Importiere von folgendem Node:"
-
-#: editor/export_template_manager.cpp
-msgid "Redownload"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Uninstall"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "(Installed)"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Download"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Official export templates aren't available for development builds."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "(Missing)"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "(Current)"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Retrieving mirrors, please wait..."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Remove template version '%s'?"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Can't open export templates zip."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Invalid version.txt format inside templates: %s."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "No version.txt found inside templates."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Error creating path for templates:"
-msgstr "Fehler beim Schreiben des Projekts PCK!"
-
-#: editor/export_template_manager.cpp
-msgid "Extracting Export Templates"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Importing:"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Error getting the list of mirrors."
-msgstr "Fehler beim Schreiben des Projekts PCK!"
-
-#: editor/export_template_manager.cpp
-msgid "Error parsing JSON of mirror list. Please report this issue!"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid ""
-"No download links found for this version. Direct download is only available "
-"for official releases."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Can't resolve."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Can't connect."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "No response."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Request Failed."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Redirect Loop."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Failed:"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Download Complete."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Cannot remove temporary file:"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid ""
-"Templates installation failed.\n"
-"The problematic templates archives can be found at '%s'."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Error requesting URL:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Connecting to Mirror..."
-msgstr "Connections editieren"
-
-#: editor/export_template_manager.cpp
-msgid "Disconnected"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Resolving"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Can't Resolve"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
-msgid "Connecting..."
-msgstr "Connections editieren"
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Can't Connect"
-msgstr "Neues Projekt erstellen"
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Connected"
-msgstr "Verbindung zu Node:"
-
-#: editor/export_template_manager.cpp
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Requesting..."
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Downloading"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Connection Error"
-msgstr "Connections editieren"
-
-#: editor/export_template_manager.cpp
-msgid "SSL Handshake Error"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Uncompressing Android Build Sources"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Current Version:"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Installed Versions:"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-msgid "Install From File"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Remove Template"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Select Template File"
-msgstr "Node(s) löschen"
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Godot Export Templates"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/export_template_manager.cpp
-msgid "Export Template Manager"
-msgstr ""
-
-#: editor/export_template_manager.cpp
-#, fuzzy
-msgid "Download Templates"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/export_template_manager.cpp
-msgid "Select mirror from list: (Shift+Click: Open in Browser)"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Favorites"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Status: Import of file failed. Please fix file and reimport manually."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Cannot move/rename resources root."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Cannot move a folder into itself."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Error moving:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Error duplicating:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Unable to update dependencies:"
-msgstr "Szene '%s' hat kapute Abhängigkeiten:"
-
-#: editor/filesystem_dock.cpp editor/scene_tree_editor.cpp
-msgid "No name provided."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Provided name contains invalid characters."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "A file or folder with this name already exists."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Name contains invalid characters."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Renaming file:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/filesystem_dock.cpp
-msgid "Renaming folder:"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Duplicating file:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Duplicating folder:"
-msgstr "Node(s) duplizieren"
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "New Inherited Scene"
-msgstr "Script hinzufügen"
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Set As Main Scene"
-msgstr "Neue Szene speichern als..."
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Open Scenes"
-msgstr "Datei(en) öffnen"
-
-#: editor/filesystem_dock.cpp
-msgid "Instance"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Add to Favorites"
-msgstr "Node"
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Remove from Favorites"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/filesystem_dock.cpp
-msgid "Edit Dependencies..."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "View Owners..."
-msgstr ""
-
-#: editor/filesystem_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
-msgid "Rename..."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Duplicate..."
-msgstr "Node(s) duplizieren"
-
-#: editor/filesystem_dock.cpp
-msgid "Move To..."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "New Scene..."
-msgstr "Neue Szene speichern als..."
-
-#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "New Script..."
-msgstr "Script hinzufügen"
-
-#: editor/filesystem_dock.cpp
-msgid "New Resource..."
-msgstr ""
-
-#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
-#: editor/script_editor_debugger.cpp
-msgid "Expand All"
-msgstr ""
-
-#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
-#: editor/script_editor_debugger.cpp
-msgid "Collapse All"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#: editor/project_manager.cpp editor/rename_dialog.cpp
-#: editor/scene_tree_dock.cpp
-msgid "Rename"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Previous Folder/File"
-msgstr "Node(s) löschen"
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Next Folder/File"
-msgstr "Node erstellen"
-
-#: editor/filesystem_dock.cpp
-msgid "Re-Scan Filesystem"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Toggle Split Mode"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Search files"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid ""
-"Scanning Files,\n"
-"Please Wait..."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Move"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "There is already file or folder with the same name in this location."
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-msgid "Overwrite"
-msgstr ""
-
-#: editor/filesystem_dock.cpp
-#, fuzzy
-msgid "Create Scene"
-msgstr "Node erstellen"
-
-#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
-msgid "Create Script"
-msgstr ""
-
-#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Find in Files"
-msgstr "Node Filter editieren"
-
-#: editor/find_in_files.cpp
-msgid "Find:"
-msgstr ""
-
-#: editor/find_in_files.cpp
-msgid "Folder:"
-msgstr ""
-
-#: editor/find_in_files.cpp
-#, fuzzy
-msgid "Filters:"
-msgstr "Node erstellen"
-
-#: editor/find_in_files.cpp
-msgid ""
-"Include the files with the following extensions. Add or remove them in "
-"ProjectSettings."
-msgstr ""
-
-#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-msgid "Find..."
-msgstr ""
-
-#: editor/find_in_files.cpp editor/plugins/script_text_editor.cpp
-msgid "Replace..."
-msgstr ""
-
-#: editor/find_in_files.cpp editor/progress_dialog.cpp scene/gui/dialogs.cpp
-msgid "Cancel"
-msgstr "Abbrechen"
-
-#: editor/find_in_files.cpp
-msgid "Find: "
-msgstr ""
-
-#: editor/find_in_files.cpp
-msgid "Replace: "
-msgstr ""
-
-#: editor/find_in_files.cpp
-msgid "Replace all (no undo)"
-msgstr ""
-
-#: editor/find_in_files.cpp
-#, fuzzy
-msgid "Searching..."
-msgstr "Connections editieren"
-
-#: editor/find_in_files.cpp
-msgid "Search complete"
-msgstr ""
-
-#: editor/groups_editor.cpp
-msgid "Add to Group"
-msgstr ""
-
-#: editor/groups_editor.cpp
-msgid "Remove from Group"
-msgstr ""
-
-#: editor/groups_editor.cpp
-msgid "Group name already exists."
-msgstr ""
-
-#: editor/groups_editor.cpp
-#, fuzzy
-msgid "Invalid group name."
-msgstr "Projektname:"
-
-#: editor/groups_editor.cpp
-#, fuzzy
-msgid "Rename Group"
-msgstr "Neues Projekt erstellen"
-
-#: editor/groups_editor.cpp
-#, fuzzy
-msgid "Delete Group"
-msgstr "Node(s) löschen"
-
-#: editor/groups_editor.cpp editor/node_dock.cpp
-msgid "Groups"
-msgstr ""
-
-#: editor/groups_editor.cpp
-msgid "Nodes Not in Group"
-msgstr ""
-
-#: editor/groups_editor.cpp editor/scene_tree_dock.cpp
-#: editor/scene_tree_editor.cpp
-#, fuzzy
-msgid "Filter nodes"
-msgstr "Node erstellen"
-
-#: editor/groups_editor.cpp
-msgid "Nodes in Group"
-msgstr ""
-
-#: editor/groups_editor.cpp
-msgid "Empty groups will be automatically removed."
-msgstr ""
-
-#: editor/groups_editor.cpp
-#, fuzzy
-msgid "Group Editor"
-msgstr "Verzeichnis öffnen"
-
-#: editor/groups_editor.cpp
-msgid "Manage Groups"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import as Single Scene"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Animations"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Materials"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Objects"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Objects+Materials"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Objects+Animations"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Materials+Animations"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import with Separate Objects+Materials+Animations"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import as Multiple Scenes"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Import as Multiple Scenes+Materials"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid "Import Scene"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Importing Scene..."
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Generating Lightmaps"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Generating for Mesh: "
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Running Custom Script..."
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Couldn't load post-import script:"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Invalid/broken script for post-import (check console):"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Error running post-import script:"
-msgstr ""
-
-#: editor/import/resource_importer_scene.cpp
-msgid "Saving..."
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "%d Files"
-msgstr "%d Dateien"
-
-#: editor/import_dock.cpp
-msgid "Set as Default for '%s'"
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "Clear Default for '%s'"
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "Import As:"
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "Preset"
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "Reimport"
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "Save Scenes, Re-Import, and Restart"
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid "Changing the type of an imported file requires editor restart."
-msgstr ""
-
-#: editor/import_dock.cpp
-msgid ""
-"WARNING: Assets exist that use this resource, they may stop loading properly."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Failed to load resource."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Expand All Properties"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-#, fuzzy
-msgid "Collapse All Properties"
-msgstr "Node erstellen"
-
-#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Save As..."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Copy Params"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Edit Resource Clipboard"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Copy Resource"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Make Built-In"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Make Sub-Resources Unique"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Open in Help"
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Create a new resource in memory and edit it."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Load an existing resource from disk and edit it."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Save the currently edited resource."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Go to the previous edited object in history."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Go to the next edited object in history."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "History of recently edited objects."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-msgid "Object properties."
-msgstr ""
-
-#: editor/inspector_dock.cpp
-#, fuzzy
-msgid "Filter properties"
-msgstr "Node erstellen"
-
-#: editor/inspector_dock.cpp
-msgid "Changes may be lost!"
-msgstr ""
-
-#: editor/multi_node_edit.cpp
-#, fuzzy
-msgid "MultiNode Set"
-msgstr "MultiNode Set"
-
-#: editor/node_dock.cpp
-#, fuzzy
-msgid "Select a single node to edit its signals and groups."
-msgstr "Selektiere ein Node um deren Signale und Gruppen zu ändern."
-
-#: editor/plugin_config_dialog.cpp
-msgid "Edit a Plugin"
-msgstr ""
-
-#: editor/plugin_config_dialog.cpp
-#, fuzzy
-msgid "Create a Plugin"
-msgstr "Node erstellen"
-
-#: editor/plugin_config_dialog.cpp
-msgid "Plugin Name:"
-msgstr ""
-
-#: editor/plugin_config_dialog.cpp
-msgid "Subfolder:"
-msgstr ""
-
-#: editor/plugin_config_dialog.cpp editor/script_create_dialog.cpp
-msgid "Language:"
-msgstr ""
-
-#: editor/plugin_config_dialog.cpp
-#, fuzzy
-msgid "Script Name:"
-msgstr "Projektname:"
-
-#: editor/plugin_config_dialog.cpp
-msgid "Activate now?"
-msgstr ""
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Create Polygon"
-msgstr "Node erstellen"
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Create points."
-msgstr "Bild einfügen"
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-msgid ""
-"Edit points.\n"
-"LMB: Move Point\n"
-"RMB: Erase Point"
-msgstr ""
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
-msgid "Erase points."
-msgstr "Oberfläche %d"
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
-msgid "Edit Polygon"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
-msgid "Insert Point"
-msgstr "Bild einfügen"
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-msgid "Edit Polygon (Remove Point)"
-msgstr ""
-
-#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
-msgid "Remove Polygon And Point"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Add Animation"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Load..."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Move Node Point"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-msgid "Change BlendSpace1D Limits"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-msgid "Change BlendSpace1D Labels"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "This type of node can't be used. Only root nodes are allowed."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Add Node Point"
-msgstr "Node"
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Add Animation Point"
-msgstr "Animations-Node"
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
-msgid "Remove BlendSpace1D Point"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-msgid "Move BlendSpace1D Node Point"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid ""
-"AnimationTree is inactive.\n"
-"Activate to enable playback, check node warnings if activation fails."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Set the blending position within the space"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Select and move points, create points with RMB."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp
-msgid "Enable snap and show grid."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Point"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Open Editor"
-msgstr "Verzeichnis öffnen"
-
-#: editor/plugins/animation_blend_space_1d_editor.cpp
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Open Animation Node"
-msgstr "Animations-Node"
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Triangle already exists."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Add Triangle"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Change BlendSpace2D Limits"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Change BlendSpace2D Labels"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Remove BlendSpace2D Point"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Remove BlendSpace2D Triangle"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "BlendSpace2D does not belong to an AnimationTree node."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "No triangles exist, so no blending can take place."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
-msgid "Toggle Auto Triangles"
-msgstr "Autoplay Umschalten"
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Create triangles by connecting points."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Erase points and triangles."
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-msgid "Generate blend triangles automatically (instead of manually)"
-msgstr ""
-
-#: editor/plugins/animation_blend_space_2d_editor.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend:"
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Parameter Changed"
-msgstr "Typ ändern"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Filters"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "Output node can't be added to the blend tree."
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Add Node to BlendTree"
-msgstr "Node von Szene"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Node Moved"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "Unable to connect, port may be in use or connection may be invalid."
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Nodes Connected"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Nodes Disconnected"
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Set Animation"
-msgstr "Bild einfügen"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Delete Node"
-msgstr "Node(s) löschen"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/scene_tree_dock.cpp
-msgid "Delete Node(s)"
-msgstr "Node(s) löschen"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "Toggle Filter On/Off"
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Change Filter"
-msgstr "Typ ändern"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "No animation player set, so unable to retrieve track names."
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "Player path set is invalid, so unable to retrieve track names."
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/root_motion_editor_plugin.cpp
-msgid ""
-"Animation player has no valid root node path, so unable to retrieve track "
-"names."
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "Anim Clips"
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-msgid "Audio Clips"
-msgstr ""
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Functions"
-msgstr "Node erstellen"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Node Renamed"
-msgstr "Node"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Add Node..."
-msgstr "Node"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#: editor/plugins/root_motion_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Filtered Tracks:"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
-msgid "Enable Filtering"
-msgstr "Typ ändern"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Toggle Autoplay"
-msgstr "Autoplay Umschalten"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "New Animation Name:"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "New Anim"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Change Animation Name:"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Delete Animation?"
-msgstr "Bild einfügen"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Remove Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Invalid animation name!"
-msgstr "Bild einfügen"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Animation name already exists!"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Rename Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Blend Next Changed"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Change Blend Time"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Load Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Duplicate Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "No animation to copy!"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "No animation resource on clipboard!"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Pasted Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Paste Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "No animation to edit!"
-msgstr "Animations-Node"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Play selected animation backwards from current pos. (A)"
-msgstr "Spiele ausgewählte Animation rückwärts von aktueller Position. (A)"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Play selected animation backwards from end. (Shift+A)"
-msgstr "Spiele ausgewählte Animation rückwärts vom Ende. (Shift+A)"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Stop animation playback. (S)"
-msgstr "Stoppe Animations-Wiedergabe. (S)"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Play selected animation from start. (Shift+D)"
-msgstr "Spiele ausgewählte Animation vom Start. (Shift+D)"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Play selected animation from current pos. (D)"
-msgstr "Ausgewählte Animation von der aktueller Position aus abspielen. (D)"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Animation position (in seconds)."
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Scale animation playback globally for the node."
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Animation Tools"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Transitions..."
-msgstr "Connections editieren"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Open in Inspector"
-msgstr "Verzeichnis öffnen"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Display list of animations in player."
-msgstr "Liste der Animationen anzeigen."
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Autoplay on Load"
-msgstr "Beim Laden automatisch abpielen"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Enable Onion Skinning"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Onion Skinning Options"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Directions"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Past"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Future"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Depth"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "1 step"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "2 steps"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "3 steps"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Differences Only"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Force White Modulate"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Include Gizmos (3D)"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
-msgid "Pin AnimationPlayer"
-msgstr "Animations-Node"
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Create New Animation"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Animation Name:"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp editor/property_editor.cpp
-msgid "Error!"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Blend Times:"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Next (Auto Queue):"
-msgstr ""
-
-#: editor/plugins/animation_player_editor_plugin.cpp
-msgid "Cross-Animation Blend Times"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Move Node"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Transition exists!"
-msgstr "Transition-Node"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Add Transition"
-msgstr "Transition-Node"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Node"
-msgstr "Node"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "End"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Immediate"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Sync"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "At End"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Travel"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Start and end nodes are needed for a sub-transition."
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "No playback resource set at path: %s."
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Node Removed"
-msgstr "Node"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Transition Removed"
-msgstr "Transition-Node"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Set Start Node (Autoplay)"
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid ""
-"Select and move nodes.\n"
-"RMB to add new nodes.\n"
-"Shift+LMB to create connections."
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Create new nodes."
-msgstr "Node erstellen"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Connect nodes."
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Remove selected node or transition."
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Toggle autoplay this animation on start, restart or seek to zero."
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-msgid "Set the end animation. This is useful for sub-transitions."
-msgstr ""
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Transition: "
-msgstr "Transition-Node"
-
-#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
-msgid "Play Mode:"
-msgstr "Node erstellen"
-
-#: editor/plugins/animation_tree_editor_plugin.cpp
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#, fuzzy
-msgid "AnimationTree"
-msgstr "Animations-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "New name:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Scale:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Fade In (s):"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Fade Out (s):"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Mix"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Auto Restart:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Restart (s):"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Random Restart (s):"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Start!"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Amount:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend 0:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend 1:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "X-Fade Time (s):"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Current:"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Add Input"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Clear Auto-Advance"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Set Auto-Advance"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Delete Input"
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Animation tree is valid."
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Animation tree is invalid."
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Animation Node"
-msgstr "Animations-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "OneShot Node"
-msgstr "OneShot-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Mix Node"
-msgstr "Mix-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend2 Node"
-msgstr "Blend2-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend3 Node"
-msgstr "Blend3-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Blend4 Node"
-msgstr "Blend4-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "TimeScale Node"
-msgstr "TimeScale-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "TimeSeek Node"
-msgstr "TimeSeek-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Transition Node"
-msgstr "Transition-Node"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Import Animations..."
-msgstr ""
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Edit Node Filters"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/animation_tree_player_editor_plugin.cpp
-msgid "Filters..."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Contents:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
-msgid "View Files"
-msgstr "Datei(en) öffnen"
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Connection error, please try again."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
-msgid "Can't connect to host:"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "No response from host:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Can't resolve hostname:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Request failed, return code:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Request failed."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Cannot save response to:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Write error."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Request failed, too many redirects"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Redirect loop."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Request failed, timeout"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Timeout."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Bad download hash, assuming file has been tampered with."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Expected:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Got:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Failed sha256 hash check"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Asset Download Error:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Downloading (%s / %s)..."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Downloading..."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Resolving..."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
-msgid "Error making request"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Idle"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Install..."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Retry"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Download Error"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Download for this asset is already in progress!"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Recently Updated"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Least Recently Updated"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Name (A-Z)"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Name (Z-A)"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "License (A-Z)"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "License (Z-A)"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "First"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Previous"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Next"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Last"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "All"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "No results for \"%s\"."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
-msgid "Import..."
-msgstr "Importierte Projekte"
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Plugins..."
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp editor/project_manager.cpp
-msgid "Sort:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/project_settings_editor.cpp
-msgid "Category:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Site:"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Support"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Official"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Testing"
-msgstr ""
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
-msgid "Loading..."
-msgstr "Connections editieren"
-
-#: editor/plugins/asset_library_editor_plugin.cpp
-msgid "Assets ZIP File"
-msgstr ""
-
-#: editor/plugins/baked_lightmap_editor_plugin.cpp
-msgid ""
-"Can't determine a save path for lightmap images.\n"
-"Save your scene (for images to be saved in the same dir), or pick a save "
-"path from the BakedLightmap properties."
-msgstr ""
-
-#: editor/plugins/baked_lightmap_editor_plugin.cpp
-msgid ""
-"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake "
-"Light' flag is on."
-msgstr ""
-
-#: editor/plugins/baked_lightmap_editor_plugin.cpp
-msgid "Failed creating lightmap images, make sure path is writable."
-msgstr ""
-
-#: editor/plugins/baked_lightmap_editor_plugin.cpp
-msgid "Bake Lightmaps"
-msgstr ""
-
-#: editor/plugins/camera_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp editor/rename_dialog.cpp
-msgid "Preview"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Configure Snap"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Grid Offset:"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Grid Step:"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Primary Line Every:"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "steps"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Rotation Offset:"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Rotation Step:"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Scale Step:"
-msgstr "TimeScale-Node"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Move Vertical Guide"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Create Vertical Guide"
-msgstr "Neues Projekt erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Vertical Guide"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Move Horizontal Guide"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Create Horizontal Guide"
-msgstr "Neues Projekt erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Horizontal Guide"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Create Horizontal and Vertical Guides"
-msgstr "Neues Projekt erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Move pivot"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Rotate CanvasItem"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Move anchor"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Resize CanvasItem"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Scale CanvasItem"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Move CanvasItem"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid ""
-"Children of containers have their anchors and margins values overridden by "
-"their parent."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Presets for the anchors and margins values of a Control node."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid ""
-"When active, moving Control nodes changes their anchors instead of their "
-"margins."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Top Left"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Top Right"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Bottom Right"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Bottom Left"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Center Left"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Center Top"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Center Right"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Center Bottom"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Center"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Left Wide"
-msgstr "Bild einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Top Wide"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Right Wide"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Bottom Wide"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "VCenter Wide"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "HCenter Wide"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Full Rect"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Keep Ratio"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Anchors only"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Change Anchors and Margins"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Change Anchors"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid ""
-"Game Camera Override\n"
-"Overrides game camera with editor viewport camera."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid ""
-"Game Camera Override\n"
-"No game instance running."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Lock Selected"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Unlock Selected"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Group Selected"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Ungroup Selected"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Paste Pose"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Guides"
-msgstr "Spiele angepasste Szene"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Create Custom Bone(s) from Node(s)"
-msgstr "Spiele angepasste Szene"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Bones"
-msgstr "Spiele angepasste Szene"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Make IK Chain"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Clear IK Chain"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid ""
-"Warning: Children of a container get their position and size determined only "
-"by their parent."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/texture_region_editor_plugin.cpp
-#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
-msgid "Zoom Reset"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Select Mode"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Drag: Rotate"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Alt+Drag: Move"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving)."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Alt+RMB: Depth list selection"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Move Mode"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Rotate Mode"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Scale Mode"
-msgstr "TimeScale-Node"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid ""
-"Show a list of all objects at the position clicked\n"
-"(same as Alt+RMB in select mode)."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Click to change object's rotation pivot."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Pan Mode"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Ruler Mode"
-msgstr "TimeScale-Node"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Toggle smart snapping."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Use Smart Snap"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Toggle grid snapping."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Use Grid Snap"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Snapping Options"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Use Rotation Snap"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Use Scale Snap"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Snap Relative"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Use Pixel Snap"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Smart Snapping"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Configure Snap..."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Snap to Parent"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Snap to Node Anchor"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Snap to Node Sides"
-msgstr "Selektiere Node(s) zum Importieren aus"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Snap to Node Center"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Snap to Other Nodes"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Snap to Guides"
-msgstr "Selektiere Node(s) zum Importieren aus"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Lock the selected object in place (can't be moved)."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Unlock the selected object (can be moved)."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Makes sure the object's children are not selectable."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Restores the object's children's ability to be selected."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Skeleton Options"
-msgstr "Bild einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Bones"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Make Custom Bone(s) from Node(s)"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Custom Bones"
-msgstr "Spiele angepasste Szene"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Always Show Grid"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Helpers"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Rulers"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Guides"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Origin"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Viewport"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Show Group And Lock Icons"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Center Selection"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Frame Selection"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Preview Canvas Scale"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Translation mask for inserting keys."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Rotation mask for inserting keys."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Scale mask for inserting keys."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Insert keys (based on mask)."
-msgstr "Bilder (innerhalb) einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid ""
-"Auto insert keys when objects are translated, rotated or scaled (based on "
-"mask).\n"
-"Keys are only added to existing tracks, no new tracks will be created.\n"
-"Keys must be inserted manually for the first time."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Auto Insert Key"
-msgstr "Anim Bild einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Animation Key and Pose Options"
-msgstr "Animationsbild eingefügt."
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Insert Key (Existing Tracks)"
-msgstr "Bild in bestehende Ebene einfügen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Copy Pose"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Clear Pose"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Multiply grid step by 2"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Divide grid step by 2"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Pan View"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Add %s"
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Adding %s..."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid "Cannot instantiate multiple nodes without root."
-msgstr ""
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
-msgid "Create Node"
-msgstr "Node erstellen"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
-msgid "Error instancing scene from %s"
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
-msgid "Change Default Type"
-msgstr "Typ ändern"
-
-#: editor/plugins/canvas_item_editor_plugin.cpp
-msgid ""
-"Drag & drop + Shift : Add node as sibling\n"
-"Drag & drop + Alt : Change node type"
-msgstr ""
-
-#: editor/plugins/collision_polygon_editor_plugin.cpp
-#, fuzzy
-msgid "Create Polygon3D"
-msgstr "Node erstellen"
-
-#: editor/plugins/collision_polygon_editor_plugin.cpp
-msgid "Edit Poly"
-msgstr ""
-
-#: editor/plugins/collision_polygon_editor_plugin.cpp
-msgid "Edit Poly (Remove Point)"
-msgstr ""
-
-#: editor/plugins/collision_shape_2d_editor_plugin.cpp
-msgid "Set Handle"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Load Emission Mask"
-msgstr "Emissions-Maske laden"
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/cpu_particles_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "Restart"
-msgstr "Datei speichern"
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Emission Mask"
-msgstr "Inhalt der Emissions-Masken löschen"
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Particles"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Generated Point Count:"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Emission Mask"
-msgstr "Emissions-Maske setzen"
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Solid Pixels"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Border Pixels"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Directed Border Pixels"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Capture from Pixel"
-msgstr ""
-
-#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Emission Colors"
-msgstr "Emissions-Maske setzen"
-
-#: editor/plugins/cpu_particles_editor_plugin.cpp
-msgid "CPUParticles"
-msgstr ""
-
-#: editor/plugins/cpu_particles_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Create Emission Points From Mesh"
-msgstr ""
-
-#: editor/plugins/cpu_particles_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Create Emission Points From Node"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Flat 0"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Flat 1"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp editor/property_editor.cpp
-msgid "Ease In"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp editor/property_editor.cpp
-msgid "Ease Out"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Smoothstep"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Modify Curve Point"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Modify Curve Tangent"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Load Curve Preset"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
-msgid "Add Point"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Point"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
-msgid "Left Linear"
-msgstr "Bild einfügen"
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Right Linear"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Load Preset"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Curve Point"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Toggle Curve Linear Tangent"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Hold Shift to edit tangents individually"
-msgstr ""
-
-#: editor/plugins/curve_editor_plugin.cpp
-msgid "Right click to add point"
-msgstr ""
-
-#: editor/plugins/gi_probe_editor_plugin.cpp
-msgid "Bake GI Probe"
-msgstr ""
-
-#: editor/plugins/gradient_editor_plugin.cpp
-msgid "Gradient Edited"
-msgstr ""
-
-#: editor/plugins/item_list_editor_plugin.cpp
-msgid "Item %d"
-msgstr ""
-
-#: editor/plugins/item_list_editor_plugin.cpp
-msgid "Items"
-msgstr ""
-
-#: editor/plugins/item_list_editor_plugin.cpp
-msgid "Item List Editor"
-msgstr ""
-
-#: editor/plugins/light_occluder_2d_editor_plugin.cpp
-msgid "Create Occluder Polygon"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Mesh is empty!"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "Couldn't create a Trimesh collision shape."
-msgstr "Node erstellen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Static Trimesh Body"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "This doesn't work on scene root!"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Trimesh Static Shape"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Can't create a single convex collision shape for the scene root."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Couldn't create a single convex collision shape."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "Create Single Convex Shape"
-msgstr "Node erstellen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Can't create multiple convex collision shapes for the scene root."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "Couldn't create any collision shapes."
-msgstr "Node erstellen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "Create Multiple Convex Shapes"
-msgstr "Node erstellen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Navigation Mesh"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Contained Mesh is not of type ArrayMesh."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "UV Unwrap failed, mesh may not be manifold?"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "No mesh to debug."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Model has no UV in this layer"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "MeshInstance lacks a Mesh!"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Mesh has not surface to create outlines from!"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Mesh primitive type is not PRIMITIVE_TRIANGLES!"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Could not create outline!"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Outline"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Mesh"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Trimesh Static Body"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid ""
-"Creates a StaticBody and assigns a polygon-based collision shape to it "
-"automatically.\n"
-"This is the most accurate (but slowest) option for collision detection."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Trimesh Collision Sibling"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid ""
-"Creates a polygon-based collision shape.\n"
-"This is the most accurate (but slowest) option for collision detection."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "Create Single Convex Collision Sibling"
-msgstr "Node erstellen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid ""
-"Creates a single convex collision shape.\n"
-"This is the fastest (but least accurate) option for collision detection."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "Create Multiple Convex Collision Siblings"
-msgstr "Node erstellen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid ""
-"Creates a polygon-based collision shape.\n"
-"This is a performance middle-ground between the two above options."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Outline Mesh..."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid ""
-"Creates a static outline mesh. The outline mesh will have its normals "
-"flipped automatically.\n"
-"This can be used instead of the SpatialMaterial Grow property when using "
-"that property isn't possible."
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "View UV1"
-msgstr "Datei(en) öffnen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
-msgid "View UV2"
-msgstr "Datei(en) öffnen"
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Unwrap UV2 for Lightmap/AO"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Create Outline Mesh"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "Outline Size:"
-msgstr ""
-
-#: editor/plugins/mesh_instance_editor_plugin.cpp
-msgid "UV Channel Debug"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid "Remove item %d?"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid ""
-"Update from existing scene?:\n"
-"%s"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid "Mesh Library"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Add Item"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid "Remove Selected Item"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid "Import from Scene"
-msgstr ""
-
-#: editor/plugins/mesh_library_editor_plugin.cpp
-msgid "Update from Scene"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "No mesh source specified (and no MultiMesh set in node)."
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "No mesh source specified (and MultiMesh contains no Mesh)."
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Mesh source is invalid (invalid path)."
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Mesh source is invalid (not a MeshInstance)."
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Mesh source is invalid (contains no Mesh resource)."
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "No surface source specified."
-msgstr "Keine Oberflächen Quelle spezifiziert."
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Surface source is invalid (invalid path)."
-msgstr "Oberflächen Quelle is invalid (invalider Pfad)."
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Surface source is invalid (no geometry)."
-msgstr "Oberflächen Quelle is invalid (keine Form)."
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-#, fuzzy
-msgid "Surface source is invalid (no faces)."
-msgstr "Oberflächen Quelle is invalid (kein Face)"
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Select a Source Mesh:"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Select a Target Surface:"
-msgstr "Wähle eine Ziel Oberfläche aus:"
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Populate Surface"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Populate MultiMesh"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Target Surface:"
-msgstr "Ziel Oberfläche:"
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Source Mesh:"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "X-Axis"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Y-Axis"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Z-Axis"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Mesh Up Axis:"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Random Rotation:"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Random Tilt:"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Random Scale:"
-msgstr ""
-
-#: editor/plugins/multimesh_editor_plugin.cpp
-msgid "Populate"
-msgstr ""
-
-#: editor/plugins/navigation_polygon_editor_plugin.cpp
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Create Navigation Polygon"
-msgstr ""
-
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "Convert to CPUParticles"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Generating Visibility Rect"
-msgstr ""
-
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Generate Visibility Rect"
-msgstr ""
-
-#: editor/plugins/particles_2d_editor_plugin.cpp
-msgid "Can only set point into a ParticlesMaterial process material"
-msgstr ""
-
-#: editor/plugins/particles_2d_editor_plugin.cpp
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Generation Time (sec):"
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "The geometry's faces don't contain any area."
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "The geometry doesn't contain any faces."
-msgstr "Node enthält keine Geometrie (Flächen)."
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "\"%s\" doesn't inherit from Spatial."
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "\"%s\" doesn't contain geometry."
-msgstr "Node enthält keine Geometrie (Flächen)."
-
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "\"%s\" doesn't contain face geometry."
-msgstr "Node enthält keine Geometrie (Flächen)."
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Create Emitter"
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "Emission Points:"
-msgstr "Emissions-Maske setzen"
-
-#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
-msgid "Surface Points"
-msgstr "Oberfläche %d"
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Surface Points+Normal (Directed)"
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Volume"
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Emission Source: "
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "A processor material of type 'ParticlesMaterial' is required."
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Generating AABB"
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Generate Visibility AABB"
-msgstr ""
-
-#: editor/plugins/particles_editor_plugin.cpp
-msgid "Generate AABB"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Remove Point from Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Remove Out-Control from Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Remove In-Control from Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Add Point to Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Split Curve"
-msgstr "Node Kurve editieren"
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Move Point in Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Move In-Control in Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Move Out-Control in Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Select Points"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Shift+Drag: Select Control Points"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Click: Add Point"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Left Click: Split Segment (in curve)"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Right Click: Delete Point"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-msgid "Select Control Points (Shift+Drag)"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Add Point (in empty space)"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Delete Point"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Close Curve"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp editor/plugins/theme_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp editor/project_export.cpp
-msgid "Options"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Mirror Handle Angles"
-msgstr ""
-
-#: editor/plugins/path_2d_editor_plugin.cpp
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Mirror Handle Lengths"
-msgstr ""
-
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Curve Point #"
-msgstr ""
-
-#: editor/plugins/path_editor_plugin.cpp
-#, fuzzy
-msgid "Set Curve Point Position"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/path_editor_plugin.cpp
-#, fuzzy
-msgid "Set Curve In Position"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/path_editor_plugin.cpp
-#, fuzzy
-msgid "Set Curve Out Position"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Split Path"
-msgstr ""
-
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Remove Path Point"
-msgstr ""
-
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Remove Out-Control Point"
-msgstr ""
-
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Remove In-Control Point"
-msgstr ""
-
-#: editor/plugins/path_editor_plugin.cpp
-msgid "Split Segment (in curve)"
-msgstr ""
-
-#: editor/plugins/physical_bone_plugin.cpp
-#, fuzzy
-msgid "Move Joint"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid ""
-"The skeleton property of the Polygon2D does not point to a Skeleton2D node"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Sync Bones"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid ""
-"No texture in this polygon.\n"
-"Set a texture to be able to edit UV."
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Create UV Map"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid ""
-"Polygon 2D has internal vertices, so it can no longer be edited in the "
-"viewport."
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Create Polygon & UV"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Create Internal Vertex"
-msgstr "Neues Projekt erstellen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Internal Vertex"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Invalid Polygon (need 3 different vertices)"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Add Custom Polygon"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Custom Polygon"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Transform UV Map"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Transform Polygon"
-msgstr "Transformationstyp"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Paint Bone Weights"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Open Polygon 2D UV editor."
-msgstr "Polygon 2D UV Editor"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Polygon 2D UV Editor"
-msgstr "Polygon 2D UV Editor"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "UV"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Points"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Polygons"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Bones"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Move Points"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Ctrl: Rotate"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Shift: Move All"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Shift+Ctrl: Scale"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Move Polygon"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Rotate Polygon"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Scale Polygon"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Create a custom polygon. Enables custom polygon rendering."
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid ""
-"Remove a custom polygon. If none remain, custom polygon rendering is "
-"disabled."
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Paint weights with specified intensity."
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Unpaint weights with specified intensity."
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Radius:"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Polygon->UV"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "UV->Polygon"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Clear UV"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Grid Settings"
-msgstr "Projekteinstellungen"
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Snap"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Enable Snap"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Grid"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Show Grid"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Configure Grid:"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Grid Offset X:"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Grid Offset Y:"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Grid Step X:"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Grid Step Y:"
-msgstr ""
-
-#: editor/plugins/polygon_2d_editor_plugin.cpp
-msgid "Sync Bones to Polygon"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "ERROR: Couldn't load resource!"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "Add Resource"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "Rename Resource"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Delete Resource"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "Resource clipboard is empty!"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "Paste Resource"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/scene_tree_editor.cpp
-msgid "Instance:"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/plugins/theme_editor_plugin.cpp editor/project_settings_editor.cpp
-#: editor/scene_tree_editor.cpp editor/script_editor_debugger.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Type:"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-#: editor/scene_tree_dock.cpp editor/scene_tree_editor.cpp
-msgid "Open in Editor"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "Load Resource"
-msgstr ""
-
-#: editor/plugins/resource_preloader_editor_plugin.cpp
-msgid "ResourcePreloader"
-msgstr ""
-
-#: editor/plugins/root_motion_editor_plugin.cpp
-msgid "AnimationTree has no path set to an AnimationPlayer"
-msgstr ""
-
-#: editor/plugins/root_motion_editor_plugin.cpp
-msgid "Path to AnimationPlayer is invalid"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Clear Recent Files"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Close and save changes?"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Error writing TextFile:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Could not load file at:"
-msgstr "Neues Projekt erstellen"
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Error saving file!"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Error while saving theme."
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Error Saving"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Error importing theme."
-msgstr "Fehler beim Exportieren des Projekts!"
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Error Importing"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "New Text File..."
-msgstr "Datei(en) öffnen"
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Open File"
-msgstr "Datei öffnen"
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Save File As..."
-msgstr "Datei speichern"
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Can't obtain the script for running."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Script failed reloading, check console for errors."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Script is not in tool mode, will not be able to run."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid ""
-"To run this script, it must inherit EditorScript and be set to tool mode."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Import Theme"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Error while saving theme"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Error saving"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Save Theme As..."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "%s Class Reference"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-msgid "Find Next"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp
-msgid "Find Previous"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Filter scripts"
-msgstr "Node erstellen"
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Toggle alphabetical sorting of the method list."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Filter methods"
-msgstr "Node erstellen"
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Sort"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp editor/scene_tree_dock.cpp
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Move Up"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/script_text_editor.cpp editor/scene_tree_dock.cpp
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Move Down"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Next script"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Previous script"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "File"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Open..."
-msgstr "Öffnen"
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Reopen Closed Script"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Save All"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Soft Reload Script"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Copy Script Path"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "History Previous"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "History Next"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Theme"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Import Theme..."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Reload Theme"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Save Theme"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Close All"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Close Docs"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp editor/project_manager.cpp
-msgid "Run"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
-msgid "Step Into"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
-msgid "Step Over"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
-msgid "Break"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp editor/project_manager.cpp
-#: editor/script_editor_debugger.cpp
-msgid "Continue"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Keep Debugger Open"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Debug with External Editor"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Open Godot online documentation."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Search the reference documentation."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Go to previous edited document."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Go to next edited document."
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid "Discard"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-msgid ""
-"The following files are newer on disk.\n"
-"What action should be taken?:"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/shader_editor_plugin.cpp
-msgid "Reload"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#: editor/plugins/shader_editor_plugin.cpp
-msgid "Resave"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
-msgid "Debugger"
-msgstr ""
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Search Results"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Recent Scripts"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Connections to method:"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/script_text_editor.cpp editor/script_editor_debugger.cpp
-msgid "Source"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Target"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid ""
-"Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Function"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Only resources from filesystem can be dropped."
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Can't drop nodes because script '%s' is not used in this scene."
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Lookup Symbol"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Pick Color"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
-msgid "Convert Case"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
-msgid "Uppercase"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
-msgid "Lowercase"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
-msgid "Capitalize"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
-msgid "Syntax Highlighter"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
-msgid "Go To"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
-msgid "Bookmarks"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Breakpoints"
-msgstr "Bild einfügen"
-
-#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
-#: scene/gui/text_edit.cpp
-msgid "Cut"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
-#: scene/gui/text_edit.cpp
-msgid "Select All"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Delete Line"
-msgstr "Bild einfügen"
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Indent Left"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Indent Right"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Toggle Comment"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Fold/Unfold Line"
-msgstr "Bild einfügen"
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Fold All Lines"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Unfold All Lines"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Clone Down"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Complete Symbol"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Evaluate Selection"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Trim Trailing Whitespace"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Convert Indent to Spaces"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Convert Indent to Tabs"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Auto Indent"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Find in Files..."
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Contextual Help"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Toggle Bookmark"
-msgstr "Autoplay Umschalten"
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Next Bookmark"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Previous Bookmark"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Remove All Bookmarks"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Function..."
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Line..."
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Toggle Breakpoint"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Remove All Breakpoints"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Next Breakpoint"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
-msgid "Go to Previous Breakpoint"
-msgstr ""
-
-#: editor/plugins/shader_editor_plugin.cpp
-msgid ""
-"This shader has been modified on on disk.\n"
-"What action should be taken?"
-msgstr ""
-
-#: editor/plugins/shader_editor_plugin.cpp
-msgid "Shader"
-msgstr ""
-
-#: editor/plugins/skeleton_2d_editor_plugin.cpp
-msgid "This skeleton has no bones, create some children Bone2D nodes."
-msgstr ""
-
-#: editor/plugins/skeleton_2d_editor_plugin.cpp
-#, fuzzy
-msgid "Create Rest Pose from Bones"
-msgstr "Spiele angepasste Szene"
-
-#: editor/plugins/skeleton_2d_editor_plugin.cpp
-msgid "Set Rest Pose to Bones"
-msgstr ""
-
-#: editor/plugins/skeleton_2d_editor_plugin.cpp
-msgid "Skeleton2D"
-msgstr ""
-
-#: editor/plugins/skeleton_2d_editor_plugin.cpp
-msgid "Make Rest Pose (From Bones)"
-msgstr ""
-
-#: editor/plugins/skeleton_2d_editor_plugin.cpp
-msgid "Set Bones to Rest Pose"
-msgstr ""
-
-#: editor/plugins/skeleton_editor_plugin.cpp
-msgid "Create physical bones"
-msgstr ""
-
-#: editor/plugins/skeleton_editor_plugin.cpp
-msgid "Skeleton"
-msgstr ""
-
-#: editor/plugins/skeleton_editor_plugin.cpp
-msgid "Create physical skeleton"
-msgstr ""
-
-#: editor/plugins/skeleton_ik_editor_plugin.cpp
-#, fuzzy
-msgid "Play IK"
-msgstr "Abspielen"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Orthogonal"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Perspective"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Transform Aborted."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "X-Axis Transform."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Y-Axis Transform."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Z-Axis Transform."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Plane Transform."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Scaling: "
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Translating: "
-msgstr "Transition-Node"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Rotating %s degrees."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Keying is disabled (no key inserted)."
-msgstr "\"keying\" ist deaktiviert (Bild nicht hinzugefügt)."
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Animation Key Inserted."
-msgstr "Animationsbild eingefügt."
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Pitch"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Yaw"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Objects Drawn"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Material Changes"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Shader Changes"
-msgstr "Typ ändern"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Surface Changes"
-msgstr "Oberfläche %d"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Draw Calls"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Vertices"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Top View."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Bottom View."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Bottom"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Left View."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Left"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Right View."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Right"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Front View."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Front"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Rear View."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Rear"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Align Transform with View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Align Rotation with View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
-msgid "No parent to instance a child at."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
-msgid "This operation requires a single selected node."
-msgstr "Bitte nur ein Node selektieren."
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Auto Orthogonal Enabled"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Lock View Rotation"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Display Normal"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Display Wireframe"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Display Overdraw"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Display Unshaded"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Environment"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Gizmos"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Information"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "View FPS"
-msgstr "Datei(en) öffnen"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Half Resolution"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Audio Listener"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Enable Doppler"
-msgstr "Typ ändern"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Cinematic Preview"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Not available when using the GLES2 renderer."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Left"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Right"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Forward"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Backwards"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Up"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Down"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Speed Modifier"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Freelook Slow Modifier"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Rotation Locked"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid ""
-"Note: The FPS value displayed is the editor's framerate.\n"
-"It cannot be used as a reliable indication of in-game performance."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "XForm Dialog"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Snap Nodes To Floor"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Couldn't find a solid floor to snap the selection to."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid ""
-"Drag: Rotate\n"
-"Alt+Drag: Move\n"
-"Alt+RMB: Depth list selection"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Use Local Space"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Use Snap"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Bottom View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Top View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Rear View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Front View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Left View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Right View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Switch Perspective/Orthogonal View"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
-msgid "Insert Animation Key"
-msgstr "Bild einfügen"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Focus Origin"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Focus Selection"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Toggle Freelook"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Transform"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Snap Object to Floor"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Transform Dialog..."
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "1 Viewport"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "2 Viewports"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "2 Viewports (Alt)"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "3 Viewports"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "3 Viewports (Alt)"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "4 Viewports"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Gizmos"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Origin"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Grid"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "Settings..."
-msgstr "Projekteinstellungen"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Snap Settings"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Translate Snap:"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Rotate Snap (deg.):"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Scale Snap (%):"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Viewport Settings"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Perspective FOV (deg.):"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Z-Near:"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "View Z-Far:"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Transform Change"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Translate:"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Rotate (deg.):"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Scale (ratio):"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Transform Type"
-msgstr "Transformationstyp"
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Pre"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Post"
-msgstr ""
-
-#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Nameless gizmo"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Create Mesh2D"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Mesh2D Preview"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Create Polygon2D"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Polygon2D Preview"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Create CollisionPolygon2D"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "CollisionPolygon2D Preview"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Create LightOccluder2D"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "LightOccluder2D Preview"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Sprite is empty!"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Can't convert a sprite using animation frames to mesh."
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Invalid geometry, can't replace by mesh."
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Convert to Mesh2D"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Invalid geometry, can't create polygon."
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Convert to Polygon2D"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Invalid geometry, can't create collision polygon."
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Create CollisionPolygon2D Sibling"
-msgstr "Node erstellen"
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Invalid geometry, can't create light occluder."
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Create LightOccluder2D Sibling"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Sprite"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Simplification: "
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Shrink (Pixels): "
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Grow (Pixels): "
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-msgid "Update Preview"
-msgstr ""
-
-#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
-msgid "Settings:"
-msgstr "Projekteinstellungen"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "No Frames Selected"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Add %d Frame(s)"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Add Frame"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Unable to load images"
-msgstr "Selektiere Node(s) zum Importieren aus"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "ERROR: Couldn't load frame resource!"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Resource clipboard is empty or not a texture!"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Paste Frame"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Add Empty"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Change Animation FPS"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "(empty)"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Move Frame"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Animations:"
-msgstr "Animations-Node"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "New Animation"
-msgstr "Bild einfügen"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Speed (FPS):"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Loop"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Animation Frames:"
-msgstr "Animations-Node"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Add a Texture from File"
-msgstr "Node von Szene"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Add Frames from a Sprite Sheet"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Insert Empty (Before)"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Insert Empty (After)"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Move (Before)"
-msgstr "Node(s) entfernen"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Move (After)"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
-msgid "Select Frames"
-msgstr "Node(s) löschen"
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Horizontal:"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Vertical:"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Select/Clear All Frames"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "Create Frames from Sprite Sheet"
-msgstr ""
-
-#: editor/plugins/sprite_frames_editor_plugin.cpp
-msgid "SpriteFrames"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Set Region Rect"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Set Margin"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Snap Mode:"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-#: scene/resources/visual_shader.cpp
-msgid "None"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Pixel Snap"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Grid Snap"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Auto Slice"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Offset:"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Step:"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-msgid "Sep.:"
-msgstr ""
-
-#: editor/plugins/texture_region_editor_plugin.cpp
-#, fuzzy
-msgid "TextureRegion"
-msgstr "2D-Textur"
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Add All Items"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Add All"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
-msgid "Remove All Items"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/theme_editor_plugin.cpp editor/project_manager.cpp
-#, fuzzy
-msgid "Remove All"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Theme"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Theme editing menu."
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Add Class Items"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Remove Class Items"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Create Empty Template"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Create Empty Editor Template"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Create From Current Editor Theme"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
-msgid "Toggle Button"
-msgstr "Autoplay Umschalten"
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Disabled Button"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Item"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
-msgid "Disabled Item"
-msgstr "Node(s) löschen"
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Check Item"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Checked Item"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Radio Item"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Checked Radio Item"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Named Sep."
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Submenu"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Subitem 1"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Subitem 2"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Has"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Many"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Disabled LineEdit"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Tab 1"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Tab 2"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Tab 3"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
-msgid "Editable Item"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Subtree"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Has,Many,Options"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Data Type:"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Icon"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp editor/rename_dialog.cpp
-msgid "Style"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Font"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-msgid "Color"
-msgstr ""
-
-#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
-msgid "Theme File"
-msgstr "Datei öffnen"
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Erase Selection"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Fix Invalid Tiles"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "Cut Selection"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Paint TileMap"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Line Draw"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Rectangle Paint"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Bucket Fill"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Erase TileMap"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Find Tile"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Transpose"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Disable Autotile"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
-msgid "Enable Priority"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
-msgid "Filter tiles"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Give a TileSet resource to this TileMap to use its tiles."
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Paint Tile"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid ""
-"Shift+LMB: Line Draw\n"
-"Shift+Ctrl+LMB: Rectangle Paint"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Pick Tile"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
-msgid "Rotate Left"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
-msgid "Rotate Right"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Flip Horizontally"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-msgid "Flip Vertically"
-msgstr ""
-
-#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Transform"
-msgstr "Transformationstyp"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Add Texture(s) to TileSet."
-msgstr "Node von Szene"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Remove selected Texture from TileSet."
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Create from Scene"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Merge from Scene"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "New Single Tile"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "New Autotile"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "New Atlas"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Next Coordinate"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Select the next shape, subtile, or Tile."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Previous Coordinate"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Select the previous shape, subtile, or Tile."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Region"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Collision"
-msgstr "Animations-Node"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Occlusion"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Navigation"
-msgstr "Animations-Node"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Bitmask"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Priority"
-msgstr "Projekt exportieren"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Z Index"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Region Mode"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Collision Mode"
-msgstr "Animations-Node"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Occlusion Mode"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Navigation Mode"
-msgstr "Animations-Node"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Bitmask Mode"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Priority Mode"
-msgstr "Projekt exportieren"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Icon Mode"
-msgstr "Bild bewegen/einfügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Z Index Mode"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Copy bitmask."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Paste bitmask."
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Erase bitmask."
-msgstr "Oberfläche %d"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Create a new rectangle."
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Create a new polygon."
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Keep polygon inside region Rect."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Enable snap and show grid (configurable via the Inspector)."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Display Tile Names (Hold Alt Key)"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid ""
-"Add or select a texture on the left panel to edit the tiles bound to it."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Remove selected texture? This will remove all tiles which use it."
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "You haven't selected a texture to remove."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Create from scene? This will overwrite all current tiles."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Merge from scene?"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Texture"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "%s file(s) were not added because was already on the list."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid ""
-"Drag handles to edit Rect.\n"
-"Click on another Tile to edit it."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Delete selected Rect."
-msgstr "Node(s) löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid ""
-"Select current edited sub-tile.\n"
-"Click on another Tile to edit it."
-msgstr "Node(s) löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Delete polygon."
-msgstr "Bild einfügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid ""
-"LMB: Set bit on.\n"
-"RMB: Set bit off.\n"
-"Shift+LMB: Set wildcard bit.\n"
-"Click on another Tile to edit it."
-msgstr "Node(s) löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid ""
-"Select sub-tile to use as icon, this will be also used on invalid autotile "
-"bindings.\n"
-"Click on another Tile to edit it."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid ""
-"Select sub-tile to change its priority.\n"
-"Click on another Tile to edit it."
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid ""
-"Select sub-tile to change its z index.\n"
-"Click on another Tile to edit it."
-msgstr "Node(s) löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Set Tile Region"
-msgstr "2D-Textur"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Create Tile"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Set Tile Icon"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Tile Bitmask"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Collision Polygon"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Occlusion Polygon"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Navigation Polygon"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Paste Tile Bitmask"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Clear Tile Bitmask"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Make Polygon Concave"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Make Polygon Convex"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Tile"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Remove Collision Polygon"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Remove Occlusion Polygon"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Remove Navigation Polygon"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Tile Priority"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-msgid "Edit Tile Z Index"
-msgstr ""
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Make Convex"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Make Concave"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Create Collision Polygon"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "Create Occlusion Polygon"
-msgstr "Node erstellen"
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "This property can't be changed."
-msgstr "Ohne eine Szene kann das nicht funktionieren."
-
-#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
-msgid "TileSet"
-msgstr "Datei(en) öffnen"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "No VCS addons are available."
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Error"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "No commit message was provided"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "No files added to stage"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Commit"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "VCS Addon is not initialized"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Version Control System"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Initialize"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Staging area"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Detect new changes"
-msgstr "Node erstellen"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Changes"
-msgstr "Typ ändern"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Modified"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Renamed"
-msgstr "Node"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Deleted"
-msgstr "Node(s) löschen"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Typechange"
-msgstr "Typ ändern"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Stage Selected"
-msgstr "Verbindung zu Node:"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Stage All"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Add a commit message"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
-msgid "Commit Changes"
-msgstr "Typ ändern"
-
-#: editor/plugins/version_control_editor_plugin.cpp
-#: modules/gdnative/gdnative_library_singleton_editor.cpp
-msgid "Status"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "View file diffs before committing them to the latest version"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "No file diff is active"
-msgstr ""
-
-#: editor/plugins/version_control_editor_plugin.cpp
-msgid "Detect changes in file diff"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "(GLES3 only)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Add Output"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Scalar"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Vector"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Boolean"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Sampler"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Add input port"
-msgstr "Script hinzufügen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Add output port"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Change input port type"
-msgstr "Typ ändern"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Change output port type"
-msgstr "Typ ändern"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Change input port name"
-msgstr "Typ ändern"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Change output port name"
-msgstr "Typ ändern"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Remove input port"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Remove output port"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Set expression"
-msgstr "Typ ändern"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Resize VisualShader node"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Set Uniform Name"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Set Input Default Port"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Add Node to Visual Shader"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Duplicate Nodes"
-msgstr "Node(s) duplizieren"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Paste Nodes"
-msgstr "Node erstellen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Delete Nodes"
-msgstr "Node(s) löschen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Visual Shader Input Type Changed"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Vertex"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Fragment"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Light"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Show resulted shader code."
-msgstr "Node erstellen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Create Shader Node"
-msgstr "Node erstellen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Color function."
-msgstr "Script hinzufügen"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Color operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Grayscale function."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Converts HSV vector to RGB equivalent."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Converts RGB vector to HSV equivalent."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Sepia function."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Burn operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Darken operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Difference operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Dodge operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "HardLight operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Lighten operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Overlay operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Screen operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "SoftLight operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Color constant."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Color uniform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the boolean result of the %s comparison between two parameters."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Equal (==)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Greater Than (>)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Greater Than or Equal (>=)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns an associated vector if the provided scalars are equal, greater or "
-"less."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns the boolean result of the comparison between INF and a scalar "
-"parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns the boolean result of the comparison between NaN and a scalar "
-"parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Less Than (<)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Less Than or Equal (<=)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Not Equal (!=)"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns an associated vector if the provided boolean value is true or false."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns an associated scalar if the provided boolean value is true or false."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the boolean result of the comparison between two parameters."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns the boolean result of the comparison between INF (or NaN) and a "
-"scalar parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Boolean constant."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Boolean uniform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for all shader modes."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Input parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for vertex and fragment shader modes."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for fragment and light shader modes."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for fragment shader mode."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for light shader mode."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for vertex shader mode."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "'%s' input parameter for vertex and fragment shader mode."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Scalar function."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Scalar operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "E constant (2.718282). Represents the base of the natural logarithm."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Epsilon constant (0.00001). Smallest possible scalar number."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Phi constant (1.618034). Golden ratio."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Pi/4 constant (0.785398) or 45 degrees."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Pi/2 constant (1.570796) or 90 degrees."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Pi constant (3.141593) or 180 degrees."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Tau constant (6.283185) or 360 degrees."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Sqrt2 constant (1.414214). Square root of 2."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the absolute value of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the arc-cosine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the inverse hyperbolic cosine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the arc-sine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the inverse hyperbolic sine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the arc-tangent of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the arc-tangent of the parameters."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the inverse hyperbolic tangent of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Finds the nearest integer that is greater than or equal to the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Constrains a value to lie between two further values."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the cosine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the hyperbolic cosine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Converts a quantity in radians to degrees."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Base-e Exponential."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Base-2 Exponential."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Finds the nearest integer less than or equal to the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Computes the fractional part of the argument."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the inverse of the square root of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Natural logarithm."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Base-2 logarithm."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the greater of two values."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the lesser of two values."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Linear interpolation between two scalars."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the opposite value of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "1.0 - scalar"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns the value of the first parameter raised to the power of the second."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Converts a quantity in degrees to radians."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "1.0 / scalar"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Finds the nearest integer to the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Finds the nearest even integer to the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Clamps the value between 0.0 and 1.0."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Extracts the sign of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the sine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the hyperbolic sine of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the square root of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n"
-"\n"
-"Returns 0.0 if 'x' is smaller than 'edge0' and 1.0 if x is larger than "
-"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
-"using Hermite polynomials."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Step function( scalar(edge), scalar(x) ).\n"
-"\n"
-"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the tangent of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the hyperbolic tangent of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Finds the truncated value of the parameter."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Adds scalar to scalar."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Divides scalar by scalar."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Multiplies scalar by scalar."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the remainder of the two scalars."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Subtracts scalar from scalar."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Scalar constant."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Scalar uniform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Perform the cubic texture lookup."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Perform the texture lookup."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Cubic texture uniform lookup."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "2D texture uniform lookup."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "2D texture uniform lookup with triplanar."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Transform function."
-msgstr "Transformationstyp"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Calculate the outer product of a pair of vectors.\n"
-"\n"
-"OuterProduct treats the first parameter 'c' as a column vector (matrix with "
-"one column) and the second parameter 'r' as a row vector (matrix with one "
-"row) and does a linear algebraic matrix multiply 'c * r', yielding a matrix "
-"whose number of rows is the number of components in 'c' and whose number of "
-"columns is the number of components in 'r'."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Composes transform from four vectors."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Decomposes transform to four vectors."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the determinant of a transform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the inverse of a transform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the transpose of a transform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Multiplies transform by transform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Multiplies vector by transform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Transform constant."
-msgstr "Transformationstyp"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Transform uniform."
-msgstr "Transformationstyp"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Vector function."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Vector operator."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Composes vector from three scalars."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Decomposes vector to three scalars."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the cross product of two vectors."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the distance between two points."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the dot product of two vectors."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns the vector that points in the same direction as a reference vector. "
-"The function has three vector parameters : N, the vector to orient, I, the "
-"incident vector, and Nref, the reference vector. If the dot product of I and "
-"Nref is smaller than zero the return value is N. Otherwise -N is returned."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the length of a vector."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Linear interpolation between two vectors."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Linear interpolation between two vectors using scalar."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Calculates the normalize product of vector."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "1.0 - vector"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "1.0 / vector"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns the vector that points in the direction of reflection ( a : incident "
-"vector, b : normal vector )."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the vector that points in the direction of refraction."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n"
-"\n"
-"Returns 0.0 if 'x' is smaller than 'edge0' and 1.0 if 'x' is larger than "
-"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
-"using Hermite polynomials."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n"
-"\n"
-"Returns 0.0 if 'x' is smaller than 'edge0' and 1.0 if 'x' is larger than "
-"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
-"using Hermite polynomials."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Step function( vector(edge), vector(x) ).\n"
-"\n"
-"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Step function( scalar(edge), vector(x) ).\n"
-"\n"
-"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Adds vector to vector."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Divides vector by vector."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Multiplies vector by vector."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Returns the remainder of the two vectors."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Subtracts vector from vector."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Vector constant."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "Vector uniform."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Custom Godot Shader Language expression, with custom amount of input and "
-"output ports. This is a direct injection of code into the vertex/fragment/"
-"light function, do not use it to write the function declarations inside."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Returns falloff based on the dot product of surface normal and view "
-"direction of camera (pass associated inputs to it)."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"Custom Godot Shader Language expression, which is placed on top of the "
-"resulted shader. You can place various function definitions inside and call "
-"it later in the Expressions. You can also declare varyings, uniforms and "
-"constants."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "(Fragment/Light mode only) Scalar derivative function."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "(Fragment/Light mode only) Vector derivative function."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"(Fragment/Light mode only) (Vector) Derivative in 'x' using local "
-"differencing."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"(Fragment/Light mode only) (Scalar) Derivative in 'x' using local "
-"differencing."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"(Fragment/Light mode only) (Vector) Derivative in 'y' using local "
-"differencing."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"(Fragment/Light mode only) (Scalar) Derivative in 'y' using local "
-"differencing."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and "
-"'y'."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid ""
-"(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and "
-"'y'."
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-msgid "VisualShader"
-msgstr ""
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Edit Visual Property"
-msgstr "Node Filter editieren"
-
-#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
-msgid "Visual Shader Mode Changed"
-msgstr "Typ ändern"
-
-#: editor/project_export.cpp
-msgid "Runnable"
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Add initial export..."
-msgstr "Script hinzufügen"
-
-#: editor/project_export.cpp
-msgid "Add previous patches..."
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Delete patch '%s' from list?"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Delete preset '%s'?"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid ""
-"Failed to export the project for platform '%s'.\n"
-"Export templates seem to be missing or invalid."
-msgstr ""
-
-#: editor/project_export.cpp
-msgid ""
-"Failed to export the project for platform '%s'.\n"
-"This might be due to a configuration issue in the export preset or your "
-"export settings."
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Release"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Exporting All"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "The given export path doesn't exist:"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Export templates for this platform are missing/corrupted:"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Presets"
-msgstr ""
-
-#: editor/project_export.cpp editor/project_settings_editor.cpp
-msgid "Add..."
-msgstr ""
-
-#: editor/project_export.cpp
-msgid ""
-"If checked, the preset will be available for use in one-click deploy.\n"
-"Only one preset per platform may be marked as runnable."
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Export Path"
-msgstr "Projekt exportieren"
-
-#: editor/project_export.cpp
-msgid "Resources"
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Export all resources in the project"
-msgstr "Exportiere alle Resources des Projekts."
-
-#: editor/project_export.cpp
-msgid "Export selected scenes (and dependencies)"
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Export selected resources (and dependencies)"
-msgstr "Exportiere alle Resources des Projekts."
-
-#: editor/project_export.cpp
-msgid "Export Mode:"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Resources to export:"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid ""
-"Filters to export non-resource files/folders\n"
-"(comma-separated, e.g: *.json, *.txt, docs/*)"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid ""
-"Filters to exclude files/folders from project\n"
-"(comma-separated, e.g: *.json, *.txt, docs/*)"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Patches"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Make Patch"
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Pack File"
-msgstr "Datei(en) öffnen"
-
-#: editor/project_export.cpp
-msgid "Features"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Custom (comma-separated):"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Feature List:"
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Script"
-msgstr "Script hinzufügen"
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Script Export Mode:"
-msgstr "Projekt exportieren"
-
-#: editor/project_export.cpp
-msgid "Text"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Compiled"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Encrypted (Provide Key Below)"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Invalid Encryption Key (must be 64 characters long)"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Script Encryption Key (256-bits as hex):"
-msgstr ""
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Export PCK/Zip"
-msgstr "Exportiere das Projekt PCK"
-
-#: editor/project_export.cpp
-msgid "Export Project"
-msgstr "Projekt exportieren"
-
-#: editor/project_export.cpp
-#, fuzzy
-msgid "Export mode?"
-msgstr "Projekt exportieren"
-
-#: editor/project_export.cpp
-msgid "Export All"
-msgstr ""
-
-#: editor/project_export.cpp editor/project_manager.cpp
-#, fuzzy
-msgid "ZIP File"
-msgstr "Datei(en) öffnen"
-
-#: editor/project_export.cpp
-msgid "Godot Game Pack"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Export templates for this platform are missing:"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Manage Export Templates"
-msgstr ""
-
-#: editor/project_export.cpp
-msgid "Export With Debug"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "The path specified doesn't exist."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Error opening package file (it's not in ZIP format)."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."
-msgstr ""
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Please choose an empty folder."
-msgstr "Bitte ausserhalb des Projekt Verzeichnis exportieren!"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Please choose a \"project.godot\" or \".zip\" file."
-msgstr "Bitte ausserhalb des Projekt Verzeichnis exportieren!"
-
-#: editor/project_manager.cpp
-msgid "This directory already contains a Godot project."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "New Game Project"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Imported Project"
-msgstr "Importierte Projekte"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Invalid Project Name."
-msgstr "Projektname:"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Couldn't create folder."
-msgstr "Node erstellen"
-
-#: editor/project_manager.cpp
-msgid "There is already a folder in this path with the specified name."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "It would be a good idea to name your project."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Invalid project path (changed anything?)."
-msgstr "Ungültiger Projektpfad, (wurde was geändert?)!"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid ""
-"Couldn't load project.godot in project path (error %d). It may be missing or "
-"corrupted."
-msgstr "Die engine.cfg kann im Projektverzeichnis nicht erstellt werden."
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Couldn't edit project.godot in project path."
-msgstr "Die engine.cfg kann im Projektverzeichnis nicht erstellt werden."
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Couldn't create project.godot in project path."
-msgstr "Die engine.cfg kann im Projektverzeichnis nicht erstellt werden."
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Rename Project"
-msgstr "Neues Projekt erstellen"
-
-#: editor/project_manager.cpp
-msgid "Import Existing Project"
-msgstr "Existierendes Projekt importieren"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Import & Edit"
-msgstr "Importiere von folgendem Node:"
-
-#: editor/project_manager.cpp
-msgid "Create New Project"
-msgstr "Neues Projekt erstellen"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Create & Edit"
-msgstr "Node erstellen"
-
-#: editor/project_manager.cpp
-msgid "Install Project:"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Install & Edit"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Project Name:"
-msgstr "Projektname:"
-
-#: editor/project_manager.cpp
-msgid "Project Path:"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Project Installation Path:"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Renderer:"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "OpenGL ES 3.0"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Higher visual quality\n"
-"All features available\n"
-"Incompatible with older hardware\n"
-"Not recommended for web games"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "OpenGL ES 2.0"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Lower visual quality\n"
-"Some features not available\n"
-"Works on most hardware\n"
-"Recommended for web games"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Renderer can be changed later, but scenes may need to be adjusted."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Unnamed Project"
-msgstr ""
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Missing Project"
-msgstr "Existierendes Projekt importieren"
-
-#: editor/project_manager.cpp
-msgid "Error: Project is missing on the filesystem."
-msgstr ""
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Can't open project at '%s'."
-msgstr "Neues Projekt erstellen"
-
-#: editor/project_manager.cpp
-msgid "Are you sure to open more than one project?"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"The following project settings file does not specify the version of Godot "
-"through which it was created.\n"
-"\n"
-"%s\n"
-"\n"
-"If you proceed with opening it, it will be converted to Godot's current "
-"configuration file format.\n"
-"Warning: You won't be able to open the project with previous versions of the "
-"engine anymore."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"The following project settings file was generated by an older engine "
-"version, and needs to be converted for this version:\n"
-"\n"
-"%s\n"
-"\n"
-"Do you want to convert it?\n"
-"Warning: You won't be able to open the project with previous versions of the "
-"engine anymore."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"The project settings were created by a newer engine version, whose settings "
-"are not compatible with this version."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Can't run project: no main scene defined.\n"
-"Please edit the project and set the main scene in the Project Settings under "
-"the \"Application\" category."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Can't run project: Assets need to be imported.\n"
-"Please edit the project to trigger the initial import."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Are you sure to run %d projects at once?"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Remove %d projects from the list?\n"
-"The project folders' contents won't be modified."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Remove this project from the list?\n"
-"The project folder's contents won't be modified."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Remove all missing projects from the list?\n"
-"The project folders' contents won't be modified."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Language changed.\n"
-"The interface will update after restarting the editor or project manager."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"Are you sure to scan %s folders for existing Godot projects?\n"
-"This could take a while."
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Project Manager"
-msgstr ""
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Projects"
-msgstr "Projektname:"
-
-#: editor/project_manager.cpp
-msgid "Last Modified"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Scan"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "Select a Folder to Scan"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid "New Project"
-msgstr ""
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Remove Missing"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Templates"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/project_manager.cpp
-msgid "Restart Now"
-msgstr ""
-
-#: editor/project_manager.cpp
-#, fuzzy
-msgid "Can't run project"
-msgstr "Neues Projekt erstellen"
-
-#: editor/project_manager.cpp
-msgid ""
-"You currently don't have any projects.\n"
-"Would you like to explore official example projects in the Asset Library?"
-msgstr ""
-
-#: editor/project_manager.cpp
-msgid ""
-"The search box filters projects by name and last path component.\n"
-"To filter projects by name and full path, the query must contain at least "
-"one `/` character."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Key "
-msgstr "Taste "
-
-#: editor/project_settings_editor.cpp
-msgid "Joy Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Joy Axis"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Mouse Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid ""
-"Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or "
-"'\"'"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "An action with the name '%s' already exists."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Rename Input Action Event"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Change Action deadzone"
-msgstr "Typ ändern"
-
-#: editor/project_settings_editor.cpp
-msgid "Add Input Action Event"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "All Devices"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Device"
-msgstr ""
-
-#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
-msgid "Press a Key..."
-msgstr "Taste drücken..."
-
-#: editor/project_settings_editor.cpp
-msgid "Mouse Button Index:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Left Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Right Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Middle Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Wheel Up Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Wheel Down Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Wheel Left Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Wheel Right Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "X Button 1"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "X Button 2"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Joypad Axis Index:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Axis"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Joypad Button Index:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Erase Input Action"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Erase Input Action Event"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Add Event"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Button"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Left Button."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Right Button."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Middle Button."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Wheel Up."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Wheel Down."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Add Global Property"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Select a setting item first!"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "No property '%s' exists."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Setting '%s' is internal, and it can't be deleted."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Delete Item"
-msgstr "Node(s) löschen"
-
-#: editor/project_settings_editor.cpp
-msgid ""
-"Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or "
-"'\"'."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Add Input Action"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Error saving settings."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Settings saved OK."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Moved Input Action Event"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Override for Feature"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Add Translation"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Remove Translation"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Add Remapped Path"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Resource Remap Add Remap"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Change Resource Remap Language"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Remove Resource Remap"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Remove Resource Remap Option"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Changed Locale Filter"
-msgstr "Typ ändern"
-
-#: editor/project_settings_editor.cpp
-msgid "Changed Locale Filter Mode"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Project Settings (project.godot)"
-msgstr "Projekteinstellungen"
-
-#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
-msgid "General"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Override For..."
-msgstr ""
-
-#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
-msgid "The editor must be restarted for changes to take effect."
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Input Map"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Action:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Action"
-msgstr "Script hinzufügen"
-
-#: editor/project_settings_editor.cpp
-msgid "Deadzone"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Device:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Index:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Localization"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Translations"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Translations:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Remaps"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Resources:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Remaps by Locale:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Locale"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Locales Filter"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Show All Locales"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Show Selected Locales Only"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-#, fuzzy
-msgid "Filter mode:"
-msgstr "Node erstellen"
-
-#: editor/project_settings_editor.cpp
-msgid "Locales:"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "AutoLoad"
-msgstr ""
-
-#: editor/project_settings_editor.cpp
-msgid "Plugins"
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "Preset..."
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "Zero"
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "Easing In-Out"
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "Easing Out-In"
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "File..."
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "Dir..."
-msgstr ""
-
-#: editor/property_editor.cpp
-msgid "Assign"
-msgstr ""
-
-#: editor/property_editor.cpp
-#, fuzzy
-msgid "Select Node"
-msgstr "Node(s) löschen"
-
-#: editor/property_editor.cpp
-msgid "Error loading file: Not a resource!"
-msgstr ""
-
-#: editor/property_editor.cpp
-#, fuzzy
-msgid "Pick a Node"
-msgstr "TimeScale-Node"
-
-#: editor/property_editor.cpp
-msgid "Bit %d, val %d."
-msgstr ""
-
-#: editor/property_selector.cpp
-msgid "Select Property"
-msgstr ""
-
-#: editor/property_selector.cpp
-msgid "Select Virtual Method"
-msgstr ""
-
-#: editor/property_selector.cpp
-msgid "Select Method"
-msgstr ""
-
-#: editor/rename_dialog.cpp editor/scene_tree_dock.cpp
-msgid "Batch Rename"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Prefix"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Suffix"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-#, fuzzy
-msgid "Use Regular Expressions"
-msgstr "Typ ändern"
-
-#: editor/rename_dialog.cpp
-msgid "Advanced Options"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Substitute"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-#, fuzzy
-msgid "Node name"
-msgstr "Node"
-
-#: editor/rename_dialog.cpp
-msgid "Node's parent name, if available"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-#, fuzzy
-msgid "Node type"
-msgstr "Node"
-
-#: editor/rename_dialog.cpp
-msgid "Current scene name"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Root node name"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid ""
-"Sequential integer counter.\n"
-"Compare counter options."
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Per-level Counter"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "If set the counter restarts for each group of child nodes"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Initial value for the counter"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Step"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Amount by which counter is incremented for each node"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Padding"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid ""
-"Minimum number of digits for the counter.\n"
-"Missing digits are padded with leading zeros."
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Post-Process"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Keep"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "PascalCase to snake_case"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "snake_case to PascalCase"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Case"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-#, fuzzy
-msgid "To Lowercase"
-msgstr "Verbindung zu Node:"
-
-#: editor/rename_dialog.cpp
-msgid "To Uppercase"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-msgid "Reset"
-msgstr ""
-
-#: editor/rename_dialog.cpp
-#, fuzzy
-msgid "Regular Expression Error"
-msgstr "Typ ändern"
-
-#: editor/rename_dialog.cpp
-msgid "At character %s"
-msgstr ""
-
-#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
-msgid "Reparent Node"
-msgstr ""
-
-#: editor/reparent_dialog.cpp
-msgid "Reparent Location (Select new Parent):"
-msgstr ""
-
-#: editor/reparent_dialog.cpp
-msgid "Keep Global Transform"
-msgstr ""
-
-#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
-msgid "Reparent"
-msgstr ""
-
-#: editor/run_settings_dialog.cpp
-msgid "Run Mode:"
-msgstr ""
-
-#: editor/run_settings_dialog.cpp
-msgid "Current Scene"
-msgstr ""
-
-#: editor/run_settings_dialog.cpp
-msgid "Main Scene"
-msgstr ""
-
-#: editor/run_settings_dialog.cpp
-msgid "Main Scene Arguments:"
-msgstr ""
-
-#: editor/run_settings_dialog.cpp
-msgid "Scene Run Settings"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "No parent to instance the scenes at."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Error loading scene from %s"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid ""
-"Cannot instance the scene '%s' because the current scene exists within one "
-"of its nodes."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Instance Scene(s)"
-msgstr "Instanziere Szene(n)"
-
-#: editor/scene_tree_dock.cpp
-msgid "Replace with Branch Scene"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Instance Child Scene"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Clear Script"
-msgstr "Script hinzufügen"
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "This operation can't be done on the tree root."
-msgstr "Das funktioniert nicht beim obersten Node. (tree root)"
-
-#: editor/scene_tree_dock.cpp
-msgid "Move Node In Parent"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Move Nodes In Parent"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Duplicate Node(s)"
-msgstr "Node(s) duplizieren"
-
-#: editor/scene_tree_dock.cpp
-msgid "Can't reparent nodes in inherited scenes, order of nodes can't change."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Node must belong to the edited scene to become root."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Instantiated scenes can't become root"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Make node as Root"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Delete %d nodes?"
-msgstr "Node(s) löschen"
-
-#: editor/scene_tree_dock.cpp
-msgid "Delete the root node \"%s\"?"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Delete node \"%s\" and its children?"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Delete node \"%s\"?"
-msgstr "Node(s) löschen"
-
-#: editor/scene_tree_dock.cpp
-msgid "Can not perform with the root node."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "This operation can't be done on instanced scenes."
-msgstr "Das funktioniert nicht bei einer instanzierten Szene."
-
-#: editor/scene_tree_dock.cpp
-msgid "Save New Scene As..."
-msgstr "Neue Szene speichern als..."
-
-#: editor/scene_tree_dock.cpp
-msgid ""
-"Disabling \"editable_instance\" will cause all properties of the node to be "
-"reverted to their default."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid ""
-"Enabling \"Load As Placeholder\" will disable \"Editable Children\" and "
-"cause all properties of the node to be reverted to their default."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Make Local"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "New Scene Root"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Create Root Node:"
-msgstr "Node erstellen"
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "2D Scene"
-msgstr "Szene starten"
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "3D Scene"
-msgstr "Szene starten"
-
-#: editor/scene_tree_dock.cpp
-msgid "User Interface"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Other Node"
-msgstr "Node(s) löschen"
-
-#: editor/scene_tree_dock.cpp
-msgid "Can't operate on nodes from a foreign scene!"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Can't operate on nodes the current scene inherits from!"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Attach Script"
-msgstr "Script hinzufügen"
-
-#: editor/scene_tree_dock.cpp
-msgid "Remove Node(s)"
-msgstr "Node(s) entfernen"
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Change type of node(s)"
-msgstr "Typ ändern"
-
-#: editor/scene_tree_dock.cpp
-msgid ""
-"Couldn't save new scene. Likely dependencies (instances) couldn't be "
-"satisfied."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Error saving scene."
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/scene_tree_dock.cpp
-msgid "Error duplicating scene to save it."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Sub-Resources"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Clear Inheritance"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Editable Children"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Load As Placeholder"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Open Documentation"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Add Child Node"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Expand/Collapse All"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Change Type"
-msgstr "Typ ändern"
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Reparent to New Node"
-msgstr "Node erstellen"
-
-#: editor/scene_tree_dock.cpp
-msgid "Make Scene Root"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Merge From Scene"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
-msgid "Save Branch as Scene"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
-msgid "Copy Node Path"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Delete (No Confirm)"
-msgstr "Bitte bestätigen..."
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Add/Create a New Node."
-msgstr "Node erstellen"
-
-#: editor/scene_tree_dock.cpp
-msgid ""
-"Instance a scene file as a Node. Creates an inherited scene if no root node "
-"exists."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-#, fuzzy
-msgid "Remote"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/scene_tree_dock.cpp
-msgid "Local"
-msgstr ""
-
-#: editor/scene_tree_dock.cpp
-msgid "Clear Inheritance? (No Undo!)"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Toggle Visible"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-#, fuzzy
-msgid "Unlock Node"
-msgstr "Node(s) löschen"
-
-#: editor/scene_tree_editor.cpp
-msgid "Button Group"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-#, fuzzy
-msgid "(Connecting From)"
-msgstr "Connections editieren"
-
-#: editor/scene_tree_editor.cpp
-msgid "Node configuration warning:"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid ""
-"Node has %s connection(s) and %s group(s).\n"
-"Click to show signals dock."
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid ""
-"Node has %s connection(s).\n"
-"Click to show signals dock."
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid ""
-"Node is in %s group(s).\n"
-"Click to show groups dock."
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-#, fuzzy
-msgid "Open Script:"
-msgstr "Script hinzufügen"
-
-#: editor/scene_tree_editor.cpp
-msgid ""
-"Node is locked.\n"
-"Click to unlock it."
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid ""
-"Children are not selectable.\n"
-"Click to make selectable."
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Toggle Visibility"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid ""
-"AnimationPlayer is pinned.\n"
-"Click to unpin."
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Invalid node name, the following characters are not allowed:"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Rename Node"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Scene Tree (Nodes):"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Node Configuration Warning!"
-msgstr ""
-
-#: editor/scene_tree_editor.cpp
-msgid "Select a Node"
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Path is empty."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Filename is empty."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Path is not local."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid base path."
-msgstr "Projektname:"
-
-#: editor/script_create_dialog.cpp
-msgid "A directory with the same name exists."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid extension."
-msgstr "Projektname:"
-
-#: editor/script_create_dialog.cpp
-msgid "Wrong extension chosen."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Error loading template '%s'"
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/script_create_dialog.cpp
-msgid "Error - Could not create script in filesystem."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Error loading script from %s"
-msgstr "Fehler beim Instanzieren der %s Szene"
-
-#: editor/script_create_dialog.cpp
-msgid "Overrides"
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "N/A"
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Open Script / Choose Location"
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Open Script"
-msgstr "Script hinzufügen"
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "File exists, it will be reused."
-msgstr "Datei existiert, Ãœberschreiben?"
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid class name."
-msgstr "Projektname:"
-
-#: editor/script_create_dialog.cpp
-msgid "Invalid inherited parent name or path."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Script path/name is valid."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Allowed: a-z, A-Z, 0-9, _ and ."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Built-in script (into scene file)."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Will create a new script file."
-msgstr "Neues Projekt erstellen"
-
-#: editor/script_create_dialog.cpp
-msgid "Will load an existing script file."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Script file already exists."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid ""
-"Note: Built-in scripts have some limitations and can't be edited using an "
-"external editor."
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-msgid "Class Name:"
-msgstr ""
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Template:"
-msgstr "Ungültige Bilder löschen"
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Built-in Script:"
-msgstr "Script hinzufügen"
-
-#: editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Attach Node Script"
-msgstr "Script hinzufügen"
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Remote "
-msgstr "Ungültige Bilder löschen"
-
-#: editor/script_editor_debugger.cpp
-msgid "Bytes:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Warning:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Error:"
-msgstr "Szene kann nicht gespeichert werden."
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "C++ Error"
-msgstr "Connections editieren"
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "C++ Error:"
-msgstr "Connections editieren"
-
-#: editor/script_editor_debugger.cpp
-msgid "C++ Source"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Source:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "C++ Source:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Stack Trace"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Errors"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Child process connected."
-msgstr "Verbindung zu Node:"
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Copy Error"
-msgstr "Connections editieren"
-
-#: editor/script_editor_debugger.cpp
-msgid "Video RAM"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Skip Breakpoints"
-msgstr "Bild einfügen"
-
-#: editor/script_editor_debugger.cpp
-msgid "Inspect Previous Instance"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Inspect Next Instance"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Stack Frames"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Profiler"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Network Profiler"
-msgstr "Projekt exportieren"
-
-#: editor/script_editor_debugger.cpp
-msgid "Monitor"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Value"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Monitors"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Pick one or more items from the list to display the graph."
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "List of Video Memory Usage by Resource:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Total:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-#, fuzzy
-msgid "Export list to a CSV file"
-msgstr "Projekt exportieren"
-
-#: editor/script_editor_debugger.cpp
-msgid "Resource Path"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Type"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Format"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Usage"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Misc"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Clicked Control:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Clicked Control Type:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Live Edit Root:"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Set From Tree"
-msgstr ""
-
-#: editor/script_editor_debugger.cpp
-msgid "Export measures as CSV"
-msgstr ""
-
-#: editor/settings_config_dialog.cpp
-msgid "Erase Shortcut"
-msgstr ""
-
-#: editor/settings_config_dialog.cpp
-msgid "Restore Shortcut"
-msgstr ""
-
-#: editor/settings_config_dialog.cpp
-msgid "Change Shortcut"
-msgstr ""
-
-#: editor/settings_config_dialog.cpp
-msgid "Editor Settings"
-msgstr ""
-
-#: editor/settings_config_dialog.cpp
-msgid "Shortcuts"
-msgstr ""
-
-#: editor/settings_config_dialog.cpp
-msgid "Binding"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Light Radius"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change AudioStreamPlayer3D Emission Angle"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Camera FOV"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Camera Size"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Notifier AABB"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Particles AABB"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Probe Extents"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
-msgid "Change Sphere Shape Radius"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
-msgid "Change Box Shape Extents"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Capsule Shape Radius"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Capsule Shape Height"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Cylinder Shape Radius"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Cylinder Shape Height"
-msgstr ""
-
-#: editor/spatial_editor_gizmos.cpp
-msgid "Change Ray Shape Length"
-msgstr ""
-
-#: modules/csg/csg_gizmos.cpp
-msgid "Change Cylinder Radius"
-msgstr ""
-
-#: modules/csg/csg_gizmos.cpp
-msgid "Change Cylinder Height"
-msgstr ""
-
-#: modules/csg/csg_gizmos.cpp
-msgid "Change Torus Inner Radius"
-msgstr ""
-
-#: modules/csg/csg_gizmos.cpp
-msgid "Change Torus Outer Radius"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Select the dynamic library for this entry"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Select dependencies of the library for this entry"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-#, fuzzy
-msgid "Remove current entry"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Double click to create a new entry"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Platform:"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Platform"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Dynamic Library"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "Add an architecture entry"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_editor_plugin.cpp
-msgid "GDNativeLibrary"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_singleton_editor.cpp
-msgid "Enabled GDNative Singleton"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_singleton_editor.cpp
-msgid "Disabled GDNative Singleton"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_singleton_editor.cpp
-msgid "Library"
-msgstr ""
-
-#: modules/gdnative/gdnative_library_singleton_editor.cpp
-msgid "Libraries: "
-msgstr ""
-
-#: modules/gdnative/register_types.cpp
-msgid "GDNative"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Step argument is zero!"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Not a script with an instance"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Not based on a script"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Not based on a resource file"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Invalid instance dictionary format (missing @path)"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Invalid instance dictionary format (can't load script at @path)"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Invalid instance dictionary format (invalid script at @path)"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Invalid instance dictionary (invalid subclasses)"
-msgstr ""
-
-#: modules/gdscript/gdscript_functions.cpp
-msgid "Object can't provide a length."
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Next Plane"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Previous Plane"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Plane:"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Next Floor"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Previous Floor"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Floor:"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "GridMap Delete Selection"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "GridMap Fill Selection"
-msgstr "Projekteinstellungen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "GridMap Paste Selection"
-msgstr "Projekteinstellungen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "GridMap Paint"
-msgstr "Projekteinstellungen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Grid Map"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Snap View"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Clip Disabled"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Clip Above"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Clip Below"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Edit X Axis"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Edit Y Axis"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Edit Z Axis"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Rotate X"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Rotate Y"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Rotate Z"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Back Rotate X"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Back Rotate Y"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Back Rotate Z"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Cursor Clear Rotation"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "Paste Selects"
-msgstr "Projekteinstellungen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "Clear Selection"
-msgstr "Script hinzufügen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "Fill Selection"
-msgstr "Script hinzufügen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "GridMap Settings"
-msgstr "Projekteinstellungen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Pick Distance:"
-msgstr ""
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
-msgid "Filter meshes"
-msgstr "Node erstellen"
-
-#: modules/gridmap/grid_map_editor_plugin.cpp
-msgid "Give a MeshLibrary resource to this GridMap to use its meshes."
-msgstr ""
-
-#: modules/mono/csharp_script.cpp
-msgid "Class name can't be a reserved keyword"
-msgstr ""
-
-#: modules/mono/mono_gd/gd_mono_utils.cpp
-msgid "End of inner exception stack trace"
-msgstr ""
-
-#: modules/recast/navigation_mesh_editor_plugin.cpp
-msgid "Bake NavMesh"
-msgstr ""
-
-#: modules/recast/navigation_mesh_editor_plugin.cpp
-msgid "Clear the navigation mesh."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Setting up Configuration..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Calculating grid size..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Creating heightfield..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Marking walkable triangles..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Constructing compact heightfield..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Eroding walkable area..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Partitioning..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Creating contours..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Creating polymesh..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Converting to native navigation mesh..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Navigation Mesh Generator Setup:"
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Parsing Geometry..."
-msgstr ""
-
-#: modules/recast/navigation_mesh_generator.cpp
-msgid "Done!"
-msgstr ""
-
-#: modules/visual_script/visual_script.cpp
-msgid ""
-"A node yielded without working memory, please read the docs on how to yield "
-"properly!"
-msgstr ""
-
-#: modules/visual_script/visual_script.cpp
-msgid ""
-"Node yielded, but did not return a function state in the first working "
-"memory."
-msgstr ""
-
-#: modules/visual_script/visual_script.cpp
-msgid ""
-"Return value must be assigned to first element of node working memory! Fix "
-"your node please."
-msgstr ""
-
-#: modules/visual_script/visual_script.cpp
-msgid "Node returned an invalid sequence output: "
-msgstr ""
-
-#: modules/visual_script/visual_script.cpp
-msgid "Found sequence bit but not the node in the stack, report bug!"
-msgstr ""
-
-#: modules/visual_script/visual_script.cpp
-msgid "Stack overflow with stack depth: "
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Change Signal Arguments"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Change Argument Type"
-msgstr "Typ ändern"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Change Argument name"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Set Variable Default Value"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Set Variable Type"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Input Port"
-msgstr "Script hinzufügen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Output Port"
-msgstr "Script hinzufügen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Override an existing built-in function."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Create a new function."
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Variables:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Create a new variable."
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Signals:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Create a new signal."
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Name is not a valid identifier:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Name already in use by another func/var/signal:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Rename Function"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Rename Variable"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Rename Signal"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Add Function"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Delete input port"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Add Variable"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Signal"
-msgstr "Script hinzufügen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Remove Input Port"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Remove Output Port"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Change Expression"
-msgstr "Typ ändern"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Remove VisualScript Nodes"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Duplicate VisualScript Nodes"
-msgstr "Node(s) duplizieren"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Hold %s to drop a Getter. Hold Shift to drop a generic signature."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Hold %s to drop a simple reference to the node."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Hold Ctrl to drop a simple reference to the node."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Hold %s to drop a Variable Setter."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Hold Ctrl to drop a Variable Setter."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Preload Node"
-msgstr "Node"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Node(s) From Tree"
-msgstr "Node von Szene"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid ""
-"Can't drop properties because script '%s' is not used in this scene.\n"
-"Drop holding 'Shift' to just copy the signature."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Add Getter Property"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Add Setter Property"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Change Base Type"
-msgstr "Typ ändern"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Move Node(s)"
-msgstr "Node(s) entfernen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Remove VisualScript Node"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Connect Nodes"
-msgstr "Verbindung zu Node:"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Disconnect Nodes"
-msgstr "Verbindung zu Node:"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Connect Node Data"
-msgstr "Verbindung zu Node:"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Connect Node Sequence"
-msgstr "Verbindung zu Node:"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Script already has function '%s'"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Change Input Value"
-msgstr "Typ ändern"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Resize Comment"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Can't copy the function node."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Clipboard is empty!"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Paste VisualScript Nodes"
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Can't create function with a function node."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Can't create function of nodes from nodes of multiple functions."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Select at least one node with sequence port."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Try to only have one sequence input in selection."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Create Function"
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Remove Function"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Remove Variable"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Editing Variable:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Remove Signal"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Editing Signal:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Make Tool:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Members:"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Change Base Type:"
-msgstr "Typ ändern"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Nodes..."
-msgstr "Node"
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Add Function..."
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "function_name"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Select or create a function to edit its graph."
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Delete Selected"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Find Node Type"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Copy Nodes"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Cut Nodes"
-msgstr "Node erstellen"
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Make Function"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-msgid "Refresh Graph"
-msgstr ""
-
-#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
-msgid "Edit Member"
-msgstr "Node Filter editieren"
-
-#: modules/visual_script/visual_script_flow_control.cpp
-msgid "Input type not iterable: "
-msgstr ""
-
-#: modules/visual_script/visual_script_flow_control.cpp
-msgid "Iterator became invalid"
-msgstr ""
-
-#: modules/visual_script/visual_script_flow_control.cpp
-msgid "Iterator became invalid: "
-msgstr ""
-
-#: modules/visual_script/visual_script_func_nodes.cpp
-msgid "Invalid index property name."
-msgstr ""
-
-#: modules/visual_script/visual_script_func_nodes.cpp
-msgid "Base object is not a Node!"
-msgstr ""
-
-#: modules/visual_script/visual_script_func_nodes.cpp
-msgid "Path does not lead Node!"
-msgstr ""
-
-#: modules/visual_script/visual_script_func_nodes.cpp
-msgid "Invalid index property name '%s' in node %s."
-msgstr ""
-
-#: modules/visual_script/visual_script_nodes.cpp
-msgid ": Invalid argument of type: "
-msgstr ""
-
-#: modules/visual_script/visual_script_nodes.cpp
-msgid ": Invalid arguments: "
-msgstr ""
-
-#: modules/visual_script/visual_script_nodes.cpp
-msgid "VariableGet not found in script: "
-msgstr ""
-
-#: modules/visual_script/visual_script_nodes.cpp
-msgid "VariableSet not found in script: "
-msgstr ""
-
-#: modules/visual_script/visual_script_nodes.cpp
-msgid "Custom node has no _step() method, can't process graph."
-msgstr ""
-
-#: modules/visual_script/visual_script_nodes.cpp
-msgid ""
-"Invalid return value from _step(), must be integer (seq out), or string "
-"(error)."
-msgstr ""
-
-#: modules/visual_script/visual_script_property_selector.cpp
-#, fuzzy
-msgid "Search VisualScript"
-msgstr "Ungültige Bilder löschen"
-
-#: modules/visual_script/visual_script_property_selector.cpp
-msgid "Get %s"
-msgstr ""
-
-#: modules/visual_script/visual_script_property_selector.cpp
-msgid "Set %s"
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Package name is missing."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Package segments must be of non-zero length."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "The character '%s' is not allowed in Android application package names."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "A digit cannot be the first character in a package segment."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "The character '%s' cannot be the first character in a package segment."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "The package must have at least one '.' separator."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Select device from the list"
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "ADB executable not configured in the Editor Settings."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "OpenJDK jarsigner not configured in the Editor Settings."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Debug keystore not configured in the Editor Settings nor in the preset."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Custom build requires a valid Android SDK path in Editor Settings."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Invalid Android SDK path for custom build in Editor Settings."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid ""
-"Android build template not installed in the project. Install it from the "
-"Project menu."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Invalid public key for APK expansion."
-msgstr ""
-
-#: platform/android/export/export.cpp
-#, fuzzy
-msgid "Invalid package name:"
-msgstr "Projektname:"
-
-#: platform/android/export/export.cpp
-msgid ""
-"Trying to build from a custom built template, but no version info for it "
-"exists. Please reinstall from the 'Project' menu."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid ""
-"Android build version mismatch:\n"
-" Template installed: %s\n"
-" Godot Version: %s\n"
-"Please reinstall Android build template from 'Project' menu."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "Building Android Project (gradle)"
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid ""
-"Building of Android project failed, check output for the error.\n"
-"Alternatively visit docs.godotengine.org for Android build documentation."
-msgstr ""
-
-#: platform/android/export/export.cpp
-msgid "No build apk generated at: "
-msgstr ""
-
-#: platform/iphone/export/export.cpp
-msgid "Identifier is missing."
-msgstr ""
-
-#: platform/iphone/export/export.cpp
-msgid "The character '%s' is not allowed in Identifier."
-msgstr ""
-
-#: platform/iphone/export/export.cpp
-msgid "App Store Team ID not specified - cannot configure the project."
-msgstr ""
-
-#: platform/iphone/export/export.cpp
-msgid "Invalid Identifier:"
-msgstr ""
-
-#: platform/iphone/export/export.cpp
-msgid "Required icon is not specified in the preset."
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Stop HTTP Server"
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Run in Browser"
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Run exported HTML in the system's default browser."
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-#, fuzzy
-msgid "Could not write file:"
-msgstr "Neues Projekt erstellen"
-
-#: platform/javascript/export/export.cpp
-msgid "Could not open template for export:"
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Invalid export template:"
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Could not read custom HTML shell:"
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Could not read boot splash image file:"
-msgstr ""
-
-#: platform/javascript/export/export.cpp
-msgid "Using default boot splash image."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-#, fuzzy
-msgid "Invalid package short name."
-msgstr "Projektname:"
-
-#: platform/uwp/export/export.cpp
-#, fuzzy
-msgid "Invalid package unique name."
-msgstr "Projektname:"
-
-#: platform/uwp/export/export.cpp
-#, fuzzy
-msgid "Invalid package publisher display name."
-msgstr "Projektname:"
-
-#: platform/uwp/export/export.cpp
-#, fuzzy
-msgid "Invalid product GUID."
-msgstr "Projektname:"
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid publisher GUID."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-#, fuzzy
-msgid "Invalid background color."
-msgstr "Projektname:"
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid Store Logo image dimensions (should be 50x50)."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid square 44x44 logo image dimensions (should be 44x44)."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid square 71x71 logo image dimensions (should be 71x71)."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid square 150x150 logo image dimensions (should be 150x150)."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid square 310x310 logo image dimensions (should be 310x310)."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid wide 310x150 logo image dimensions (should be 310x150)."
-msgstr ""
-
-#: platform/uwp/export/export.cpp
-msgid "Invalid splash screen image dimensions (should be 620x300)."
-msgstr ""
-
-#: scene/2d/animated_sprite.cpp
-#, fuzzy
-msgid ""
-"A SpriteFrames resource must be created or set in the \"Frames\" property in "
-"order for AnimatedSprite to display frames."
-msgstr ""
-"Damit AnimatedSprite Frames anzeigen kann, muss eine SpriteFrame Resource "
-"unter der 'Frames' Property erstellt oder gesetzt sein."
-
-#: scene/2d/canvas_modulate.cpp
-msgid ""
-"Only one visible CanvasModulate is allowed per scene (or set of instanced "
-"scenes). The first created one will work, while the rest will be ignored."
-msgstr ""
-"Nur ein sichtbares CanvasModulate ist pro Szene (oder ein Satz von "
-"instanzierten Szenen) erlaubt. Das erste erstellte gewinnt der Rest wird "
-"ignoriert."
-
-#: scene/2d/collision_object_2d.cpp
-msgid ""
-"This node has no shape, so it can't collide or interact with other objects.\n"
-"Consider adding a CollisionShape2D or CollisionPolygon2D as a child to "
-"define its shape."
-msgstr ""
-
-#: scene/2d/collision_polygon_2d.cpp
-msgid ""
-"CollisionPolygon2D only serves to provide a collision shape to a "
-"CollisionObject2D derived node. Please only use it as a child of Area2D, "
-"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
-msgstr ""
-
-#: scene/2d/collision_polygon_2d.cpp
-msgid "An empty CollisionPolygon2D has no effect on collision."
-msgstr "Ein leeres CollisionPolygon2D hat keinen Einfluss au die Kollision."
-
-#: scene/2d/collision_shape_2d.cpp
-msgid ""
-"CollisionShape2D only serves to provide a collision shape to a "
-"CollisionObject2D derived node. Please only use it as a child of Area2D, "
-"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
-msgstr ""
-
-#: scene/2d/collision_shape_2d.cpp
-msgid ""
-"A shape must be provided for CollisionShape2D to function. Please create a "
-"shape resource for it!"
-msgstr ""
-
-#: scene/2d/cpu_particles_2d.cpp
-msgid ""
-"CPUParticles2D animation requires the usage of a CanvasItemMaterial with "
-"\"Particles Animation\" enabled."
-msgstr ""
-
-#: scene/2d/light_2d.cpp
-msgid ""
-"A texture with the shape of the light must be supplied to the \"Texture\" "
-"property."
-msgstr ""
-
-#: scene/2d/light_occluder_2d.cpp
-msgid ""
-"An occluder polygon must be set (or drawn) for this occluder to take effect."
-msgstr ""
-"Ein Okkluder Polygon muss gesetzt oder gezeichnet werden, damit dieser "
-"Okkluder funktioniert."
-
-#: scene/2d/light_occluder_2d.cpp
-#, fuzzy
-msgid "The occluder polygon for this occluder is empty. Please draw a polygon."
-msgstr ""
-"Das Okkluder Polygon für diesen Okkluder ist leer. Bitte zeichne ein Polygon!"
-
-#: scene/2d/navigation_polygon.cpp
-#, fuzzy
-msgid ""
-"A NavigationPolygon resource must be set or created for this node to work. "
-"Please set a property or draw a polygon."
-msgstr ""
-"Eine NavigationPolygon Ressource muss für diesen Node gesetzt oder erstellt "
-"werden, damit er funktioniert. Bitte setze eine Variable oder zeichne ein "
-"Polygon."
-
-#: scene/2d/navigation_polygon.cpp
-msgid ""
-"NavigationPolygonInstance must be a child or grandchild to a Navigation2D "
-"node. It only provides navigation data."
-msgstr ""
-"NavigationPolygonInstance muss ein Kind oder Grosskind vom Navigation2D Node "
-"sein. Es liefert nur Navigationsdaten."
-
-#: scene/2d/parallax_layer.cpp
-msgid ""
-"ParallaxLayer node only works when set as child of a ParallaxBackground node."
-msgstr ""
-
-#: scene/2d/particles_2d.cpp
-msgid ""
-"GPU-based particles are not supported by the GLES2 video driver.\n"
-"Use the CPUParticles2D node instead. You can use the \"Convert to "
-"CPUParticles\" option for this purpose."
-msgstr ""
-
-#: scene/2d/particles_2d.cpp scene/3d/particles.cpp
-msgid ""
-"A material to process the particles is not assigned, so no behavior is "
-"imprinted."
-msgstr ""
-
-#: scene/2d/particles_2d.cpp
-msgid ""
-"Particles2D animation requires the usage of a CanvasItemMaterial with "
-"\"Particles Animation\" enabled."
-msgstr ""
-
-#: scene/2d/path_2d.cpp
-msgid "PathFollow2D only works when set as a child of a Path2D node."
-msgstr ""
-"PathFollow2D funktioniert nur, wenn sie als Unterobjekt eines Path2D Nodes "
-"gesetzt wird."
-
-#: scene/2d/physics_body_2d.cpp
-msgid ""
-"Size changes to RigidBody2D (in character or rigid modes) will be overridden "
-"by the physics engine when running.\n"
-"Change the size in children collision shapes instead."
-msgstr ""
-
-#: scene/2d/remote_transform_2d.cpp
-msgid "Path property must point to a valid Node2D node to work."
-msgstr ""
-"Die Pfad-Variable muss auf einen gültigen Node2D Node zeigen um zu "
-"funktionieren."
-
-#: scene/2d/skeleton_2d.cpp
-msgid "This Bone2D chain should end at a Skeleton2D node."
-msgstr ""
-
-#: scene/2d/skeleton_2d.cpp
-msgid "A Bone2D only works with a Skeleton2D or another Bone2D as parent node."
-msgstr ""
-
-#: scene/2d/skeleton_2d.cpp
-msgid ""
-"This bone lacks a proper REST pose. Go to the Skeleton2D node and set one."
-msgstr ""
-
-#: scene/2d/tile_map.cpp
-msgid ""
-"TileMap with Use Parent on needs a parent CollisionObject2D to give shapes "
-"to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, "
-"KinematicBody2D, etc. to give them a shape."
-msgstr ""
-
-#: scene/2d/visibility_notifier_2d.cpp
-#, fuzzy
-msgid ""
-"VisibilityEnabler2D works best when used with the edited scene root directly "
-"as parent."
-msgstr ""
-"VisibilityEnable2D funktioniert am besten, wenn es ein Unterobjekt erster "
-"Ordnung der bearbeiteten Hauptszene ist."
-
-#: scene/3d/arvr_nodes.cpp
-msgid "ARVRCamera must have an ARVROrigin node as its parent."
-msgstr ""
-
-#: scene/3d/arvr_nodes.cpp
-msgid "ARVRController must have an ARVROrigin node as its parent."
-msgstr ""
-
-#: scene/3d/arvr_nodes.cpp
-msgid ""
-"The controller ID must not be 0 or this controller won't be bound to an "
-"actual controller."
-msgstr ""
-
-#: scene/3d/arvr_nodes.cpp
-msgid "ARVRAnchor must have an ARVROrigin node as its parent."
-msgstr ""
-
-#: scene/3d/arvr_nodes.cpp
-msgid ""
-"The anchor ID must not be 0 or this anchor won't be bound to an actual "
-"anchor."
-msgstr ""
-
-#: scene/3d/arvr_nodes.cpp
-msgid "ARVROrigin requires an ARVRCamera child node."
-msgstr ""
-
-#: scene/3d/baked_lightmap.cpp
-msgid "%d%%"
-msgstr ""
-
-#: scene/3d/baked_lightmap.cpp
-msgid "(Time Left: %d:%02d s)"
-msgstr ""
-
-#: scene/3d/baked_lightmap.cpp
-msgid "Plotting Meshes: "
-msgstr ""
-
-#: scene/3d/baked_lightmap.cpp
-msgid "Plotting Lights:"
-msgstr ""
-
-#: scene/3d/baked_lightmap.cpp scene/3d/gi_probe.cpp
-msgid "Finishing Plot"
-msgstr ""
-
-#: scene/3d/baked_lightmap.cpp
-msgid "Lighting Meshes: "
-msgstr ""
-
-#: scene/3d/collision_object.cpp
-msgid ""
-"This node has no shape, so it can't collide or interact with other objects.\n"
-"Consider adding a CollisionShape or CollisionPolygon as a child to define "
-"its shape."
-msgstr ""
-
-#: scene/3d/collision_polygon.cpp
-msgid ""
-"CollisionPolygon only serves to provide a collision shape to a "
-"CollisionObject derived node. Please only use it as a child of Area, "
-"StaticBody, RigidBody, KinematicBody, etc. to give them a shape."
-msgstr ""
-
-#: scene/3d/collision_polygon.cpp
-msgid "An empty CollisionPolygon has no effect on collision."
-msgstr ""
-
-#: scene/3d/collision_shape.cpp
-msgid ""
-"CollisionShape only serves to provide a collision shape to a CollisionObject "
-"derived node. Please only use it as a child of Area, StaticBody, RigidBody, "
-"KinematicBody, etc. to give them a shape."
-msgstr ""
-
-#: scene/3d/collision_shape.cpp
-msgid ""
-"A shape must be provided for CollisionShape to function. Please create a "
-"shape resource for it."
-msgstr ""
-
-#: scene/3d/collision_shape.cpp
-msgid ""
-"Plane shapes don't work well and will be removed in future versions. Please "
-"don't use them."
-msgstr ""
-
-#: scene/3d/collision_shape.cpp
-msgid ""
-"ConcavePolygonShape doesn't support RigidBody in another mode than static."
-msgstr ""
-
-#: scene/3d/cpu_particles.cpp
-msgid "Nothing is visible because no mesh has been assigned."
-msgstr ""
-
-#: scene/3d/cpu_particles.cpp
-msgid ""
-"CPUParticles animation requires the usage of a SpatialMaterial whose "
-"Billboard Mode is set to \"Particle Billboard\"."
-msgstr ""
-
-#: scene/3d/gi_probe.cpp
-msgid "Plotting Meshes"
-msgstr ""
-
-#: scene/3d/gi_probe.cpp
-msgid ""
-"GIProbes are not supported by the GLES2 video driver.\n"
-"Use a BakedLightmap instead."
-msgstr ""
-
-#: scene/3d/light.cpp
-msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows."
-msgstr ""
-
-#: scene/3d/navigation_mesh.cpp
-msgid "A NavigationMesh resource must be set or created for this node to work."
-msgstr ""
-
-#: scene/3d/navigation_mesh.cpp
-msgid ""
-"NavigationMeshInstance must be a child or grandchild to a Navigation node. "
-"It only provides navigation data."
-msgstr ""
-
-#: scene/3d/particles.cpp
-msgid ""
-"GPU-based particles are not supported by the GLES2 video driver.\n"
-"Use the CPUParticles node instead. You can use the \"Convert to CPUParticles"
-"\" option for this purpose."
-msgstr ""
-
-#: scene/3d/particles.cpp
-msgid ""
-"Nothing is visible because meshes have not been assigned to draw passes."
-msgstr ""
-
-#: scene/3d/particles.cpp
-msgid ""
-"Particles animation requires the usage of a SpatialMaterial whose Billboard "
-"Mode is set to \"Particle Billboard\"."
-msgstr ""
-
-#: scene/3d/path.cpp
-#, fuzzy
-msgid "PathFollow only works when set as a child of a Path node."
-msgstr ""
-"PathFollow2D funktioniert nur, wenn sie als Unterobjekt eines Path2D Nodes "
-"gesetzt wird."
-
-#: scene/3d/path.cpp
-msgid ""
-"PathFollow's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its "
-"parent Path's Curve resource."
-msgstr ""
-
-#: scene/3d/physics_body.cpp
-msgid ""
-"Size changes to RigidBody (in character or rigid modes) will be overridden "
-"by the physics engine when running.\n"
-"Change the size in children collision shapes instead."
-msgstr ""
-
-#: scene/3d/remote_transform.cpp
-#, fuzzy
-msgid ""
-"The \"Remote Path\" property must point to a valid Spatial or Spatial-"
-"derived node to work."
-msgstr "Die Pfad-Variable muss auf einen gültigen Particles2D Node verweisen."
-
-#: scene/3d/soft_body.cpp
-msgid "This body will be ignored until you set a mesh."
-msgstr ""
-
-#: scene/3d/soft_body.cpp
-msgid ""
-"Size changes to SoftBody will be overridden by the physics engine when "
-"running.\n"
-"Change the size in children collision shapes instead."
-msgstr ""
-
-#: scene/3d/sprite_3d.cpp
-#, fuzzy
-msgid ""
-"A SpriteFrames resource must be created or set in the \"Frames\" property in "
-"order for AnimatedSprite3D to display frames."
-msgstr ""
-"Damit AnimatedSprite Frames anzeigen kann, muss eine SpriteFrame Resource "
-"unter der 'Frames' Property erstellt oder gesetzt sein."
-
-#: scene/3d/vehicle_body.cpp
-msgid ""
-"VehicleWheel serves to provide a wheel system to a VehicleBody. Please use "
-"it as a child of a VehicleBody."
-msgstr ""
-
-#: scene/3d/world_environment.cpp
-msgid ""
-"WorldEnvironment requires its \"Environment\" property to contain an "
-"Environment to have a visible effect."
-msgstr ""
-
-#: scene/3d/world_environment.cpp
-msgid ""
-"Only one WorldEnvironment is allowed per scene (or set of instanced scenes)."
-msgstr ""
-
-#: scene/3d/world_environment.cpp
-msgid ""
-"This WorldEnvironment is ignored. Either add a Camera (for 3D scenes) or set "
-"this environment's Background Mode to Canvas (for 2D scenes)."
-msgstr ""
-
-#: scene/animation/animation_blend_tree.cpp
-msgid "On BlendTree node '%s', animation not found: '%s'"
-msgstr ""
-
-#: scene/animation/animation_blend_tree.cpp
-#, fuzzy
-msgid "Animation not found: '%s'"
-msgstr "Animations-Node"
-
-#: scene/animation/animation_tree.cpp
-msgid "In node '%s', invalid animation: '%s'."
-msgstr ""
-
-#: scene/animation/animation_tree.cpp
-msgid "Invalid animation: '%s'."
-msgstr ""
-
-#: scene/animation/animation_tree.cpp
-msgid "Nothing connected to input '%s' of node '%s'."
-msgstr ""
-
-#: scene/animation/animation_tree.cpp
-msgid "No root AnimationNode for the graph is set."
-msgstr ""
-
-#: scene/animation/animation_tree.cpp
-msgid "Path to an AnimationPlayer node containing animations is not set."
-msgstr ""
-
-#: scene/animation/animation_tree.cpp
-msgid "Path set for AnimationPlayer does not lead to an AnimationPlayer node."
-msgstr ""
-
-#: scene/animation/animation_tree.cpp
-msgid "The AnimationPlayer root node is not a valid node."
-msgstr ""
-
-#: scene/animation/animation_tree_player.cpp
-msgid "This node has been deprecated. Use AnimationTree instead."
-msgstr ""
-
-#: scene/gui/color_picker.cpp
-msgid ""
-"Color: #%s\n"
-"LMB: Set color\n"
-"RMB: Remove preset"
-msgstr ""
-
-#: scene/gui/color_picker.cpp
-msgid "Pick a color from the editor window."
-msgstr ""
-
-#: scene/gui/color_picker.cpp
-msgid "HSV"
-msgstr ""
-
-#: scene/gui/color_picker.cpp
-msgid "Raw"
-msgstr ""
-
-#: scene/gui/color_picker.cpp
-msgid "Switch between hexadecimal and code values."
-msgstr ""
-
-#: scene/gui/color_picker.cpp
-msgid "Add current color as a preset."
-msgstr ""
-
-#: scene/gui/container.cpp
-msgid ""
-"Container by itself serves no purpose unless a script configures its "
-"children placement behavior.\n"
-"If you don't intend to add a script, use a plain Control node instead."
-msgstr ""
-
-#: scene/gui/control.cpp
-msgid ""
-"The Hint Tooltip won't be displayed as the control's Mouse Filter is set to "
-"\"Ignore\". To solve this, set the Mouse Filter to \"Stop\" or \"Pass\"."
-msgstr ""
-
-#: scene/gui/dialogs.cpp
-msgid "Alert!"
-msgstr "Alert!"
-
-#: scene/gui/dialogs.cpp
-msgid "Please Confirm..."
-msgstr "Bitte bestätigen..."
-
-#: scene/gui/popup.cpp
-msgid ""
-"Popups will hide by default unless you call popup() or any of the popup*() "
-"functions. Making them visible for editing is fine, but they will hide upon "
-"running."
-msgstr ""
-
-#: scene/gui/range.cpp
-msgid "If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0."
-msgstr ""
-
-#: scene/gui/scroll_container.cpp
-msgid ""
-"ScrollContainer is intended to work with a single child control.\n"
-"Use a container as child (VBox, HBox, etc.), or a Control and set the custom "
-"minimum size manually."
-msgstr ""
-
-#: scene/gui/tree.cpp
-msgid "(Other)"
-msgstr ""
-
-#: scene/main/scene_tree.cpp
-msgid ""
-"Default Environment as specified in Project Settings (Rendering -> "
-"Environment -> Default Environment) could not be loaded."
-msgstr ""
-
-#: scene/main/viewport.cpp
-msgid ""
-"This viewport is not set as render target. If you intend for it to display "
-"its contents directly to the screen, make it a child of a Control so it can "
-"obtain a size. Otherwise, make it a RenderTarget and assign its internal "
-"texture to some node for display."
-msgstr ""
-
-#: scene/main/viewport.cpp
-msgid "Viewport size must be greater than 0 to render anything."
-msgstr ""
-
-#: scene/resources/visual_shader_nodes.cpp
-msgid "Invalid source for preview."
-msgstr ""
-
-#: scene/resources/visual_shader_nodes.cpp
-msgid "Invalid source for shader."
-msgstr ""
-
-#: scene/resources/visual_shader_nodes.cpp
-msgid "Invalid comparison function for that type."
-msgstr ""
-
-#: servers/visual/shader_language.cpp
-msgid "Assignment to function."
-msgstr ""
-
-#: servers/visual/shader_language.cpp
-msgid "Assignment to uniform."
-msgstr ""
-
-#: servers/visual/shader_language.cpp
-msgid "Varyings can only be assigned in vertex function."
-msgstr ""
-
-#: servers/visual/shader_language.cpp
-msgid "Constants cannot be modified."
-msgstr ""
-
-#, fuzzy
-#~ msgid "Class Description"
-#~ msgstr "Script hinzufügen"
-
-#, fuzzy
-#~ msgid "Base Type:"
-#~ msgstr "Typ ändern"
-
-#, fuzzy
-#~ msgid "Available Nodes:"
-#~ msgstr "TimeScale-Node"
-
-#, fuzzy
-#~ msgid "Theme Properties:"
-#~ msgstr "Node erstellen"
-
-#, fuzzy
-#~ msgid "Class Description:"
-#~ msgstr "Script hinzufügen"
-
-#, fuzzy
-#~ msgid "Property Descriptions:"
-#~ msgstr "Script hinzufügen"
-
-#, fuzzy
-#~ msgid "Method Descriptions:"
-#~ msgstr "Script hinzufügen"
-
-#~ msgid "Delete Node(s)?"
-#~ msgstr "Node(s) löschen?"
-
-#~ msgid "Faces contain no area!"
-#~ msgstr "Flächen enthalten keinen Bereich!"
-
-#~ msgid "No faces!"
-#~ msgstr "Keine Flächen!"
-
-#, fuzzy
-#~ msgid "Select Mode (Q)"
-#~ msgstr "Selektiere Node(s) zum Importieren aus"
-
-#, fuzzy
-#~ msgid "Snap Mode (%s)"
-#~ msgstr "Selektiere Node(s) zum Importieren aus"
-
-#, fuzzy
-#~ msgid "Error initializing FreeType."
-#~ msgstr "Fehler bei der FreeType Inizialisierung."
-
-#, fuzzy
-#~ msgid "Previous Folder"
-#~ msgstr "Node(s) löschen"
-
-#, fuzzy
-#~ msgid "Next Folder"
-#~ msgstr "Node erstellen"
-
-#, fuzzy
-#~ msgid "Build Project"
-#~ msgstr "Projektname:"
-
-#, fuzzy
-#~ msgid "View log"
-#~ msgstr "Datei(en) öffnen"
-
-#~ msgid "Path to Node:"
-#~ msgstr "Pfad zum Node:"
-
-#, fuzzy
-#~ msgid "Create folder"
-#~ msgstr "Node erstellen"
-
-#, fuzzy
-#~ msgid "Custom Node"
-#~ msgstr "Node erstellen"
-
-#, fuzzy
-#~ msgid "Create Area"
-#~ msgstr "Node erstellen"
-
-#, fuzzy
-#~ msgid "Create Exterior Connector"
-#~ msgstr "Neues Projekt erstellen"
-
-#, fuzzy
-#~ msgid "Insert keys."
-#~ msgstr "Bild einfügen"
-
-#, fuzzy
-#~ msgid "OrientedPathFollow only works when set as a child of a Path node."
-#~ msgstr ""
-#~ "PathFollow2D funktioniert nur, wenn sie als Unterobjekt eines Path2D "
-#~ "Nodes gesetzt wird."
-
-#, fuzzy
-#~ msgid "Add Split"
-#~ msgstr "Script hinzufügen"
-
-#, fuzzy
-#~ msgid "Remove Split"
-#~ msgstr "Ungültige Bilder löschen"
-
-#, fuzzy
-#~ msgid "Add Node.."
-#~ msgstr "Node"
-
-#, fuzzy
-#~ msgid "Show current scene file."
-#~ msgstr "Node(s) löschen"
-
-#~ msgid "Ok"
-#~ msgstr "Okay"
-
-#, fuzzy
-#~ msgid "Convert To Lowercase"
-#~ msgstr "Verbindung zu Node:"
-
-#~ msgid "Anim Add Key"
-#~ msgstr "Anim Bild hinzufügen"
-
-#~ msgid "Enable editing of individual keys by clicking them."
-#~ msgstr "Aktivieren des Bildeditors mit einem click auf die jenigen."
-
-#~ msgid "Key"
-#~ msgstr "Bild"
-
-#~ msgid "Call Functions in Which Node?"
-#~ msgstr "Im welchem Node soll die Funktion aufgerufen werden?"
-
-#~ msgid "Create new animation in player."
-#~ msgstr "Neue Animation erstellen."
-
-#, fuzzy
-#~ msgid "Set pivot at mouse position"
-#~ msgstr "Ungültige Bilder löschen"
-
-#~ msgid "OK :("
-#~ msgstr "Okay :("
-
-#, fuzzy
-#~ msgid "Can't contain '/' or ':'"
-#~ msgstr "Verbindung zu Node:"
-
-#, fuzzy
-#~ msgid "Can't write file."
-#~ msgstr "Neues Projekt erstellen"
-
-#, fuzzy
-#~ msgid "Couldn't get project.godot in project path."
-#~ msgstr "Die engine.cfg kann im Projektverzeichnis nicht erstellt werden."
-
-#, fuzzy
-#~ msgid "Couldn't get project.godot in the project path."
-#~ msgstr "Die engine.cfg kann im Projektverzeichnis nicht erstellt werden."
-
-#~ msgid "Move Add Key"
-#~ msgstr "Bild bewegen/einfügen"
-
-#~ msgid "Set Emission Mask"
-#~ msgstr "Emissions-Maske setzen"
-
-#~ msgid "Surface %d"
-#~ msgstr "Oberfläche %d"
-
-#~ msgid "Import Textures for Atlas (2D)"
-#~ msgstr "Importiere Texturen für Atlas (2D)"
-
-#~ msgid "Import Large Textures (2D)"
-#~ msgstr "Importiere Große Texturen (2D)"
-
-#~ msgid "Import Textures for 2D"
-#~ msgstr "Importiere Texturen für 2D"
-
-#, fuzzy
-#~ msgid ""
-#~ "NOTICE: Importing 2D textures is not mandatory. Just copy png/jpg files "
-#~ "to the project."
-#~ msgstr ""
-#~ "MERKE: Das importieren von 2D Texturen ist nicht zwingend notwendig. "
-#~ "Kopiere einfach png/jpg Dateien in das Projekt."
-
-#, fuzzy
-#~ msgid "Add to Project (project.godot)"
-#~ msgstr "Zum Projekt hinzufügen (engine.cfg)"
-
-#~ msgid "Invalid project path, the path must exist!"
-#~ msgstr "Ungültiger Projektpfad, Pfad existiert nicht!"
-
-#, fuzzy
-#~ msgid "Invalid project path, project.godot must not exist."
-#~ msgstr "Ungültiger Projektpfad, engine.cfg vorhanden!"
-
-#, fuzzy
-#~ msgid "Invalid project path, project.godot must exist."
-#~ msgstr "Ungültiger Projektpfad, engine.cfg nicht vorhanden!"
-
-#~ msgid "Project Path (Must Exist):"
-#~ msgstr "Projektpfad (muss existieren):"
-
-#~ msgid "Node From Scene"
-#~ msgstr "Node von Szene"
-
-#~ msgid "Import assets to the project."
-#~ msgstr "Assets zum Projekt importieren."
-
-#~ msgid "Export the project to many platforms."
-#~ msgstr "Exportiere das Projekt für viele Plattformen."
-
-#~ msgid "Path property must point to a valid Particles2D node to work."
-#~ msgstr ""
-#~ "Die Pfad-Variable muss auf einen gültigen Particles2D Node verweisen."
-
-#~ msgid "Surface"
-#~ msgstr "Oberfläche"
-
-#~ msgid ""
-#~ "A SampleLibrary resource must be created or set in the 'samples' property "
-#~ "in order for SamplePlayer to play sound."
-#~ msgstr ""
-#~ "Damit SamplePlayer einen Sound abspielen kann, muss eine SampleLibrary "
-#~ "Ressource in der 'samples' Property erzeugt oder definiert werden."
-
-#~ msgid ""
-#~ "A SampleLibrary resource must be created or set in the 'samples' property "
-#~ "in order for SpatialSamplePlayer to play sound."
-#~ msgstr ""
-#~ "Damit SpatialSamplePlayer einen Sound abspielen kann, muss eine "
-#~ "SampleLibrary Ressource in der 'samples' Eigenschaft erzeugt oder "
-#~ "definiert werden."
-
-#~ msgid "Error writing the project PCK!"
-#~ msgstr "Fehler beim Schreiben des Projekts PCK!"
-
-#~ msgid "Project Export Settings"
-#~ msgstr "Projektexport Einstellungen"
-
-#~ msgid "Export all files in the project directory."
-#~ msgstr "Exportiere alle Dateien in das Projektverzeichnis."
diff --git a/editor/translations/editor.pot b/editor/translations/editor.pot
index 1302e33e47..4dca7e4c5f 100644
--- a/editor/translations/editor.pot
+++ b/editor/translations/editor.pot
@@ -809,7 +809,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1409,16 +1408,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2338,11 +2329,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2608,10 +2601,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3217,6 +3206,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3801,6 +3794,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6672,11 +6669,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7146,6 +7143,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10063,7 +10069,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10221,6 +10227,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10267,11 +10280,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10391,6 +10404,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10431,6 +10448,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11455,6 +11476,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11478,6 +11503,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/el.po b/editor/translations/el.po
index b01976c477..127da8ec1f 100644
--- a/editor/translations/el.po
+++ b/editor/translations/el.po
@@ -11,8 +11,9 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-04-20 05:51+0000\n"
-"Last-Translator: George Tsiamasiotis <gtsiam@windowslive.com>\n"
+"PO-Revision-Date: 2020-05-10 12:37+0000\n"
+"Last-Translator: Overloaded @ Orama Interactive http://orama-interactive."
+"com/ <manoschool@yahoo.gr>\n"
"Language-Team: Greek <https://hosted.weblate.org/projects/godot-engine/godot/"
"el/>\n"
"Language: el\n"
@@ -20,7 +21,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0.2-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -845,7 +846,6 @@ msgstr "ΑδÏνατη η σÏνδεση σήματος"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1459,17 +1459,9 @@ msgstr "ΕνεÏγοποίηση"
msgid "Rearrange Autoloads"
msgstr "Αναδιάταξη των AutoLoad"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "ΆκυÏη διαδÏομή."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Το αÏχείο δεν υπάÏχει."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Δεν υπάÏχει στην διαδÏομή πόÏων."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2431,14 +2423,15 @@ msgstr ""
"Δεν είναι δυνατό να φοÏτώσετε εκ νέου μια σκηνή που δεν αποθηκεÏτηκε ποτέ."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "ΕπαναφοÏά"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "ΑποθηκεÏσετε σκηνής"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
-"Αυτή η ενέÏγεια δεν μποÏεί να αναιÏεθεί. Θέλετε να συνεχίσετε με την "
-"επαναφοÏά;"
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2733,10 +2726,6 @@ msgid "Redo"
msgstr "ΑκÏÏωση αναίÏεσης"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "ΕπαναφοÏά σκηνής"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Λοιπά έÏγα ή εÏγαλεία για όλη τη σκηνή."
@@ -2944,7 +2933,7 @@ msgstr "Αναζήτηση"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: editor/plugins/shader_editor_plugin.cpp
msgid "Online Docs"
-msgstr "ΗλεκτÏονική τεκμηÏίωση"
+msgstr "ΗλεκτÏονική τεκμηÏίωση"
#: editor/editor_node.cpp
msgid "Q&A"
@@ -3388,6 +3377,13 @@ msgstr "Αδυναμία εκτέλεσης δέσμης ενεÏγειών:"
msgid "Did you forget the '_run' method?"
msgstr "Μήπως ξεχάσατε τη μέθοδο '_run';"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Πατήστε παÏατεταμένα το Ctrl για να Ï€Ïοσθέσετε έναν Getter. Πατήστε "
+"παÏατεταμένα το Shift για να Ï€Ïοσθέσετε μία γενική υπογÏαφή."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Επιλέξτε κόμβους για εισαγωγή"
@@ -3989,6 +3985,10 @@ msgid "Error running post-import script:"
msgstr "Σφάλμα κατά την εκτέλεση της δέσμης ενεÏγειών μετεισαγωγής:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Αποθήκευση..."
@@ -6957,12 +6957,13 @@ msgstr ""
"κόμβο «%s»."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "ΓÏαμμή"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(ΠαÏάβλεψη)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ΠαÏάβλεψη)"
+msgid "Line"
+msgstr "ΓÏαμμή"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7441,6 +7442,15 @@ msgid "XForm Dialog"
msgstr "Διάλογος XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "ΚοÏμπωμα Κόμβων στο Δάπεδο"
@@ -10527,8 +10537,9 @@ msgid "Instance Child Scene"
msgstr "ΑÏχικοποίηση σκηνής ως παιδί"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "ΕκκαθάÏιση Δέσμης ΕνεÏγειών"
+#, fuzzy
+msgid "Detach Script"
+msgstr "ΣÏνδεση Δέσμης ΕνεÏγειών"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10699,6 +10710,13 @@ msgid "Open Documentation"
msgstr "Άνοιγμα ΤεκμηÏίωσης"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "ΠÏοσθήκη κόμβου ως παιδί"
@@ -10747,11 +10765,13 @@ msgstr ""
"υπάÏχει πηγαίος κόμβος."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "ΣÏνδεση νέας ή υπαÏκτής δέσμης ενεÏγειών για τον επιλεγμένο κόμβο."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "ΕκκαθάÏιση δέσμης ενεÏγειών για τον επιλεγμένο κόμβο."
#: editor/scene_tree_dock.cpp
@@ -10883,6 +10903,10 @@ msgid "A directory with the same name exists."
msgstr "ΥπαÏκτός ομώνυμος κατάλογος."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Το αÏχείο δεν υπάÏχει."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "ΆκυÏη επέκταση."
@@ -10923,6 +10947,10 @@ msgid "File exists, it will be reused."
msgstr "ΥπαÏκτό αÏχείο, θα επαναχÏησιμοποιηθεί."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "ΆκυÏη διαδÏομή."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "ΆκυÏο όνομα κλάσης."
@@ -11983,6 +12011,13 @@ msgstr ""
"διαμόÏφωση."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Το «debug keystore» δεν έχει καθοÏιστεί στις Ρυθμίσεις ΕπεξεÏγαστή ή την "
+"διαμόÏφωση."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Η Ï€ÏοσαÏμοσμένη δόμηση απαιτεί μια έγκυÏη διαδÏομή για το Android SDK στις "
@@ -12012,6 +12047,32 @@ msgstr "ΆκυÏο όνομα πακέτου:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12804,6 +12865,23 @@ msgstr "Τα «varying» μποÏοÏν να ανατεθοÏν μόνο στηÎ
msgid "Constants cannot be modified."
msgstr "Οι σταθεÏές δεν μποÏοÏν να Ï„ÏοποποιηθοÏν."
+#~ msgid "Not in resource path."
+#~ msgstr "Δεν υπάÏχει στην διαδÏομή πόÏων."
+
+#~ msgid "Revert"
+#~ msgstr "ΕπαναφοÏά"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr ""
+#~ "Αυτή η ενέÏγεια δεν μποÏεί να αναιÏεθεί. Θέλετε να συνεχίσετε με την "
+#~ "επαναφοÏά;"
+
+#~ msgid "Revert Scene"
+#~ msgstr "ΕπαναφοÏά σκηνής"
+
+#~ msgid "Clear Script"
+#~ msgstr "ΕκκαθάÏιση Δέσμης ΕνεÏγειών"
+
#~ msgid "Issue Tracker"
#~ msgstr "ΔιαχείÏιση Ï€Ïοβλημάτων"
diff --git a/editor/translations/eo.po b/editor/translations/eo.po
index d75cb88920..3addde45ce 100644
--- a/editor/translations/eo.po
+++ b/editor/translations/eo.po
@@ -8,18 +8,19 @@
# Brandon Dyer <brandondyer64@gmail.com>, 2019.
# Alejandro Sánchez Medina <alejandrosanchzmedina@gmail.com>, 2019.
# Sr Half <flavio05@outlook.com>, 2020.
+# Cristian Yepez <cristianyepez@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
-"PO-Revision-Date: 2020-05-01 11:43+0000\n"
-"Last-Translator: Sr Half <flavio05@outlook.com>\n"
+"PO-Revision-Date: 2020-05-22 21:01+0000\n"
+"Last-Translator: Cristian Yepez <cristianyepez@gmail.com>\n"
"Language-Team: Esperanto <https://hosted.weblate.org/projects/godot-engine/"
"godot/eo/>\n"
"Language: eo\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -640,9 +641,8 @@ msgid "Scale Ratio:"
msgstr "Skali RejÅo:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Select Tracks to Copy"
-msgstr "Elekti vojetojn por duplikati:"
+msgstr "Elekti vojetojn por duplikati"
#: editor/animation_track_editor.cpp editor/editor_log.cpp
#: editor/editor_properties.cpp
@@ -847,7 +847,6 @@ msgstr "Ne povas konekti signalo"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1342,12 +1341,13 @@ msgid "Open Audio Bus Layout"
msgstr ""
#: editor/editor_audio_buses.cpp
+#, fuzzy
msgid "There is no '%s' file."
-msgstr ""
+msgstr "Neniu '%s' dosiero."
#: editor/editor_audio_buses.cpp editor/plugins/canvas_item_editor_plugin.cpp
msgid "Layout"
-msgstr ""
+msgstr "AranÄo"
#: editor/editor_audio_buses.cpp
msgid "Invalid file, not an audio bus layout."
@@ -1360,7 +1360,7 @@ msgstr "Eraro dum Åargante tiparon."
#: editor/editor_audio_buses.cpp
msgid "Add Bus"
-msgstr ""
+msgstr "Aldoni Buso"
#: editor/editor_audio_buses.cpp
msgid "Add a new Audio Bus to this layout."
@@ -1370,7 +1370,7 @@ msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp editor/property_editor.cpp
#: editor/script_create_dialog.cpp
msgid "Load"
-msgstr ""
+msgstr "ÅœarÄi"
#: editor/editor_audio_buses.cpp
msgid "Load an existing Bus Layout."
@@ -1448,16 +1448,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Nevalida dosierindiko."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2405,12 +2397,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Ne povas reÅarÄi scenon, kiu konservis neniam."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Malfari"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Konservi scenon"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Tiun ĉi agon ne povos malfari. Certe daŭrigi?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2678,10 +2673,6 @@ msgid "Redo"
msgstr "Refari"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Malfari scenon"
-
-#: editor/editor_node.cpp
#, fuzzy
msgid "Miscellaneous project or scene-wide tools."
msgstr "Diversa projekto aÅ­ sceno-abundaj iloj."
@@ -3313,6 +3304,10 @@ msgstr "Ne povis ruli skripto:"
msgid "Did you forget the '_run' method?"
msgstr "Ĉu vi forgesis la '_run' metodo?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
#, fuzzy
msgid "Select Node(s) to Import"
@@ -3905,6 +3900,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6794,11 +6793,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7269,6 +7268,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10210,8 +10218,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Krei skripton"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10370,6 +10379,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10416,11 +10432,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10540,6 +10556,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Nevalida kromprogramo."
@@ -10580,6 +10600,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Nevalida dosierindiko."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11622,6 +11646,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11645,6 +11673,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12288,6 +12342,15 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Konstantoj ne povas esti modifitaj."
+#~ msgid "Revert"
+#~ msgstr "Malfari"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Tiun ĉi agon ne povos malfari. Certe daŭrigi?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Malfari scenon"
+
#, fuzzy
#~ msgid "Help improve the Godot documentation by giving feedback."
#~ msgstr "Helpi plibonigi la Godotan dokumentadon per doni reagon."
diff --git a/editor/translations/es.po b/editor/translations/es.po
index 8446ed2415..f8c4134d07 100644
--- a/editor/translations/es.po
+++ b/editor/translations/es.po
@@ -12,7 +12,7 @@
# David Couto <davidcouto@gmail.com>, 2017.
# Dharkael <izhe@hotmail.es>, 2017, 2019.
# Diego López <diegodario21@gmail.com>, 2017.
-# eon-s <emanuel.segretin@gmail.com>, 2018, 2019.
+# eon-s <emanuel.segretin@gmail.com>, 2018, 2019, 2020.
# Gustavo Leon <gleondiaz@gmail.com>, 2017-2018.
# Javier Ocampos <xavier.ocampos@gmail.com>, 2018, 2019, 2020.
# Jose Maria Martinez <josemar1992@hotmail.com>, 2018.
@@ -46,12 +46,15 @@
# Victor S. <victorstancioiu@gmail.com>, 2020.
# henry rujano herrera <rujhen@gmail.com>, 2020.
# Megamega53 <Christopher.Morales21@myhunter.cuny.edu>, 2020.
+# Serk Lintur <serk.lintur@gmail.com>, 2020.
+# Pedro J. Estébanez <pedrojrulez@gmail.com>, 2020.
+# paco <pacosoftfree@protonmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-04 15:11+0000\n"
-"Last-Translator: Javier Ocampos <xavier.ocampos@gmail.com>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: paco <pacosoftfree@protonmail.com>\n"
"Language-Team: Spanish <https://hosted.weblate.org/projects/godot-engine/"
"godot/es/>\n"
"Language: es\n"
@@ -886,7 +889,6 @@ msgstr "No se puede conectar la señal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1500,17 +1502,9 @@ msgstr "Activar"
msgid "Rearrange Autoloads"
msgstr "Reordenar Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Ruta inválida."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "El archivo no existe."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "No está en la ruta de recursos."
+msgid "Can't add autoload:"
+msgstr "No se puede añadir un autoload:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2028,7 +2022,7 @@ msgstr "Constantes"
#: editor/editor_help.cpp
msgid "Property Descriptions"
-msgstr "Descripción de Propiedades"
+msgstr "Descripciones de Propiedad"
#: editor/editor_help.cpp
msgid "(value)"
@@ -2051,11 +2045,8 @@ msgid ""
"There is currently no description for this method. Please help us by [color="
"$color][url=$url]contributing one[/url][/color]!"
msgstr ""
-"Actualmente no hay una descripción para este método. Por favor, ¡ayúdanos "
-"[color=$color][url=$url]aportando una[/url][/color]!\n"
-"\n"
-"Actualmente no existe descripción para este método. Por favor ¡ayúdanos "
-"[color=$color][url=$url]contribuyendo una[/url][/color]!"
+"Actualmente no existe descripción para este método. Por favor ¡ayúdanos con "
+"[color=$color][url=$url] contribuyendo con una[ /url][/color]!"
#: editor/editor_help_search.cpp editor/editor_node.cpp
#: editor/plugins/script_editor_plugin.cpp
@@ -2477,12 +2468,17 @@ msgid "Can't reload a scene that was never saved."
msgstr "No se puede volver a cargar una escena que nunca se guardó."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Revertir"
+msgid "Reload Saved Scene"
+msgstr "Recargar Escena Guardada"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Esta acción no se puede deshacer. ¿Revertir de todos modos?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"La escena actual tiene cambios sin guardar.\n"
+"¿Quieres recargar la escena guardada igualmente? Esta acción no puede "
+"deshacerse."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2777,10 +2773,6 @@ msgid "Redo"
msgstr "Rehacer"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Revertir Escena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Herramientas variadas de proyecto o escena."
@@ -3110,12 +3102,14 @@ msgid ""
"the \"Use Custom Build\" option should be enabled in the Android export "
"preset."
msgstr ""
-"Una vez hecho ésto puedes aplicar modificaciones y generar tu propio APK "
-"personalizado al exportar (agregar módulos, cambiar el AndroidManifest.xml, "
-"etc.).\n"
-"Ten en cuenta que para generar builds personalizados en vez de usar los APKs "
-"pregenerados, la opción \"Usar Build Personalizado\" debería estar activada "
-"en el preset de exportación de Android."
+"Esto configurará tu proyecto para las compilaciones personalizadas de "
+"Android instalando la plantilla base en \"res://android/build\".\n"
+"Luego podrás aplicar las modificaciones y compilar tu propio APK "
+"personalizado al exportarlo (agregando módulos, cambiando el AndroidManifest."
+"xml, etc.).\n"
+"Ten en cuenta que para realizar compilaciones personalizadas en lugar de "
+"usar APKs predefinidos, la opción \"Use Custom Build\" debería estar "
+"habilitada en la configuración de exportación de Android."
#: editor/editor_node.cpp
msgid ""
@@ -3431,6 +3425,12 @@ msgstr "No se pudo ejecutar el script:"
msgid "Did you forget the '_run' method?"
msgstr "Te olvidaste del método '_run'?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Mantén pulsado Ctrl para redondear a enteros. Mantén pulsado Shift para "
+"cambios más precisos."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selecciona nodo(s) a importar"
@@ -4031,6 +4031,10 @@ msgid "Error running post-import script:"
msgstr "Error ejecutando el script de posimportacion:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr "¿Devolviste un objeto derivado de Node en el método `post_import()`?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Guardando..."
@@ -6994,12 +6998,12 @@ msgstr ""
"'%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Línea"
+msgid "[Ignore]"
+msgstr "[Ignorar]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorar)"
+msgid "Line"
+msgstr "Línea"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7473,6 +7477,21 @@ msgid "XForm Dialog"
msgstr "Diálogo XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Haz clic para alternar entre los estados de visibilidad.\n"
+"\n"
+"Ojo abierto: El gizmo es visible.\n"
+"Ojo cerrado: El gizmo está oculto.\n"
+"Ojo medio abierto: El gizmo también es visible a través de superficies "
+"opacas (\"x-ray\")."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Ajustar Nodos al Suelo"
@@ -9373,7 +9392,7 @@ msgid ""
msgstr ""
"Los retornos decrecen en función del producto punto de la superficie normal "
"y de la dirección de visión de la cámara (pasando las entradas asociadas a "
-"esta)."
+"este)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -10568,8 +10587,8 @@ msgid "Instance Child Scene"
msgstr "Instanciar Escena Hija"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Eliminar Script"
+msgid "Detach Script"
+msgstr "Sustraer Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10735,6 +10754,16 @@ msgid "Open Documentation"
msgstr "Abrir Documentación"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"No se puede adjuntar el script: no hay ningún lenguaje registrado.\n"
+"Esto es probablemente porque este editor fue construido con todos los "
+"módulos de lenguaje desactivados."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Añadir Nodo Hijo"
@@ -10783,12 +10812,12 @@ msgstr ""
"existe ningún nodo raíz."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr "Añadir un script nuevo o existente al nodo seleccionado."
+msgid "Attach a new or existing script to the selected node."
+msgstr "Añadir un nuevo script o ya existente al nodo seleccionado."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Borrar el script del nodo seleccionado."
+msgid "Detach the script from the selected node."
+msgstr "Sustraer script del nodo seleccionado."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10827,7 +10856,7 @@ msgid ""
"Node has %s connection(s) and %s group(s).\n"
"Click to show signals dock."
msgstr ""
-"El nodo tiene %s conexión(es) y %(s) grupo(s).\n"
+"El nodo tiene %s conexión(es) y %s grupo(s).\n"
"Clic para mostrar el panel de señales."
#: editor/scene_tree_editor.cpp
@@ -10920,6 +10949,10 @@ msgid "A directory with the same name exists."
msgstr "Ya existe un directorio con el mismo nombre."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "El archivo no existe."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Extensión inválida."
@@ -10960,6 +10993,10 @@ msgid "File exists, it will be reused."
msgstr "El archivo ya existe, será reutilizado."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Ruta inválida."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nombre de clase inválido."
@@ -12015,6 +12052,12 @@ msgstr ""
"Debug keystore no configurada en Configuración del Editor ni en el preset."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Release keystore no está configurado correctamente en el preset de "
+"exportación."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"La compilación personalizada requiere una ruta de Android SDK válida en "
@@ -12044,6 +12087,39 @@ msgstr "Nombre de paquete inválido:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"El módulo \"GodotPaymentV3\" incluido en los ajustes del proyecto \"android/"
+"modules\" es inválido (cambiado en Godot 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr "\"Use Custom Build\" debe estar activado para usar los plugins."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"\"Degrees Of Freedom\" sólo es válido cuando \"Xr Mode\" es \"Oculus Mobile "
+"VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Hand Tracking\" sólo es válido cuando \"Xr Mode\" es \"Oculus Mobile VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Focus Awareness\" sólo es válido cuando \"Xr Mode\" es \"Oculus Mobile VR"
+"\"."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12846,6 +12922,21 @@ msgstr "Solo se pueden asignar variaciones en funciones de vértice."
msgid "Constants cannot be modified."
msgstr "Las constantes no pueden modificarse."
+#~ msgid "Not in resource path."
+#~ msgstr "No está en la ruta de recursos."
+
+#~ msgid "Revert"
+#~ msgstr "Revertir"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Esta acción no se puede deshacer. ¿Revertir de todos modos?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Revertir Escena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Eliminar Script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Registro de problemas"
diff --git a/editor/translations/es_AR.po b/editor/translations/es_AR.po
index 9136ac11c3..46cb219e14 100644
--- a/editor/translations/es_AR.po
+++ b/editor/translations/es_AR.po
@@ -14,12 +14,13 @@
# roger <616steam@gmail.com>, 2019, 2020.
# Francisco José Carllinni <panchopepe@protonmail.com>, 2019.
# Nicolas Zirulnik <nicolaszirulnik@gmail.com>, 2020.
+# Cristian Yepez <cristianyepez@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-02 01:48+0000\n"
-"Last-Translator: Anonymous <noreply@weblate.org>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: Lisandro Lorea <lisandrolorea@gmail.com>\n"
"Language-Team: Spanish (Argentina) <https://hosted.weblate.org/projects/"
"godot-engine/godot/es_AR/>\n"
"Language: es_AR\n"
@@ -852,7 +853,6 @@ msgstr "No se puede conectar la señal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1465,17 +1465,9 @@ msgstr "Activar"
msgid "Rearrange Autoloads"
msgstr "Reordenar Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Ruta inválida."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "El archivo existe."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "No está en la ruta de recursos."
+msgid "Can't add autoload:"
+msgstr "No se puede agregar autoload:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2438,12 +2430,17 @@ msgid "Can't reload a scene that was never saved."
msgstr "No se puede volver a cargar una escena que nunca se guardó."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Revertir"
+msgid "Reload Saved Scene"
+msgstr "Recargar Escena Guardada"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Esta acción no se puede deshacer. ¿Revertir de todos modos?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"La escena actual tiene cambios sin guardar.\n"
+"Querés recargar la escena guardada igualmente? Esta acción no se puede "
+"deshacer."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2738,10 +2735,6 @@ msgid "Redo"
msgstr "Rehacer"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Revertir Escena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Herramientas misceláneas a nivel proyecto o escena."
@@ -2822,7 +2815,7 @@ msgid ""
msgstr ""
"Cuando esta opción está activa, exportar o hacer deploy producirá un "
"ejecutable mínimo.\n"
-"El sistema de archivos sera proveido desde el proyecto por el editor sobre "
+"El sistema de archivos sera proveído desde el proyecto por el editor sobre "
"la red.\n"
"En Android, deploy usará el cable USB para mejor performance. Esta opción "
"acelera el testeo para juegos con footprint grande."
@@ -3392,6 +3385,12 @@ msgstr "No se pudo ejecutar el script:"
msgid "Did you forget the '_run' method?"
msgstr "Te olvidaste del método '_run'?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Mantené pulsado Ctrl para redondear a enteros. Mantené pulsado Shift para "
+"cambios más precisos."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Seleccionar Nodo(s) para Importar"
@@ -3991,6 +3990,10 @@ msgid "Error running post-import script:"
msgstr "Error ejecutando el script de post-importacion:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr "¿Devolviste un objeto derivado de Node en el método `post_import()`?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Guardando..."
@@ -5887,7 +5890,7 @@ msgstr "No se pudo crear una forma de colisión Trimesh."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Static Trimesh Body"
-msgstr "Crear Static Trimesh Body"
+msgstr "Crear Static Trimesh Body"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "This doesn't work on scene root!"
@@ -6950,12 +6953,12 @@ msgstr ""
"nodo '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Línea"
+msgid "[Ignore]"
+msgstr "[Ignorar]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorar)"
+msgid "Line"
+msgstr "Línea"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7429,6 +7432,21 @@ msgid "XForm Dialog"
msgstr "Dialogo XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Hacé clic para alternar entre los estados de visibilidad.\n"
+"\n"
+"Ojo abierto: El gizmo es visible.\n"
+"Ojo cerrado: El gizmo está oculto.\n"
+"Ojo medio abierto: El gizmo también es visible a través de superficies "
+"opacas (\"x-ray\")."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Ajustar Nodos al Suelo"
@@ -10523,8 +10541,8 @@ msgid "Instance Child Scene"
msgstr "Instanciar Escena Hija"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Quitar Script"
+msgid "Detach Script"
+msgstr "Desasignar Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10691,6 +10709,16 @@ msgid "Open Documentation"
msgstr "Abrir Documentación"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"No se puede asignar el script: no hay ningún lenguaje registrado.\n"
+"Esto es probablemente porque este editor fue compilado con todos los módulos "
+"de lenguaje desactivados."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Agregar Nodo Hijo"
@@ -10739,12 +10767,12 @@ msgstr ""
"existe ningún nodo raíz."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr "Adjuntar un script nuevo o existente para el nodo seleccionado."
+msgid "Attach a new or existing script to the selected node."
+msgstr "Asignar un script nuevo o existente al nodo seleccionado."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Restablecer un script para el nodo seleccionado."
+msgid "Detach the script from the selected node."
+msgstr "Desasignar el script del nodo seleccionado."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10876,6 +10904,10 @@ msgid "A directory with the same name exists."
msgstr "Existe un directorio con el mismo nombre."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "El archivo existe."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Extensión inválida."
@@ -10916,6 +10948,10 @@ msgid "File exists, it will be reused."
msgstr "El archivo existe, será reutilizado."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Ruta inválida."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nombre de clase inválido."
@@ -11879,7 +11915,7 @@ msgstr "La ruta no apunta a un Nodo!"
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Invalid index property name '%s' in node %s."
-msgstr "Nombre de propiedad índice '%s' inválido en nodo %s."
+msgstr "Nombre de propiedad índice '%s' inválido en nodo %s."
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid argument of type: "
@@ -11968,6 +12004,12 @@ msgstr ""
"Keystore debug no configurada en Configuración del Editor ni en el preset."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Release keystore no está configurado correctamente en el preset de "
+"exportación."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"La compilación personalizada requiere una ruta de Android SDK válida en "
@@ -11997,6 +12039,39 @@ msgstr "Nombre de paquete inválido:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"El módulo \"GodotPaymentV3\" incluido en el ajuste de proyecto \"android/"
+"modules\" es inválido (cambiado en Godot 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr "\"Use Custom Build\" debe estar activado para usar los plugins."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"\"Degrees Of Freedom\" sólo es válido cuando \"Xr Mode\" es \"Oculus Mobile "
+"VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Hand Tracking\" sólo es válido cuando \"Xr Mode\" es \"Oculus Mobile VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Focus Awareness\" sólo es válido cuando \"Xr Mode\" es \"Oculus Mobile VR"
+"\"."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12791,6 +12866,21 @@ msgstr "Solo se pueden asignar variaciones en funciones de vértice."
msgid "Constants cannot be modified."
msgstr "Las constantes no pueden modificarse."
+#~ msgid "Not in resource path."
+#~ msgstr "No está en la ruta de recursos."
+
+#~ msgid "Revert"
+#~ msgstr "Revertir"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Esta acción no se puede deshacer. ¿Revertir de todos modos?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Revertir Escena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Quitar Script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Registro de problemas"
diff --git a/editor/translations/et.po b/editor/translations/et.po
index 2ed8f83317..7be6996d69 100644
--- a/editor/translations/et.po
+++ b/editor/translations/et.po
@@ -4,18 +4,20 @@
# This file is distributed under the same license as the Godot source code.
# Jens <arrkiin@gmail.com>, 2019.
# Mattias Aabmets <mattias.aabmets@gmail.com>, 2019.
+# StReef <streef.gtx@gmail.com>, 2020.
+# René <renepiik@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
-"PO-Revision-Date: 2019-07-19 13:41+0000\n"
-"Last-Translator: Mattias Aabmets <mattias.aabmets@gmail.com>\n"
+"PO-Revision-Date: 2020-05-31 12:39+0000\n"
+"Last-Translator: René <renepiik@gmail.com>\n"
"Language-Team: Estonian <https://hosted.weblate.org/projects/godot-engine/"
"godot/et/>\n"
"Language: et\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 3.8-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -25,7 +27,7 @@ msgstr ""
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr ""
+msgstr "Eeldati sõne pikkusega 1 (trükimärk)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -63,31 +65,31 @@ msgstr "'%' kutsudes:"
#: core/ustring.cpp
msgid "B"
-msgstr ""
+msgstr "B"
#: core/ustring.cpp
msgid "KiB"
-msgstr ""
+msgstr "KiB"
#: core/ustring.cpp
msgid "MiB"
-msgstr ""
+msgstr "MiB"
#: core/ustring.cpp
msgid "GiB"
-msgstr ""
+msgstr "GiB"
#: core/ustring.cpp
msgid "TiB"
-msgstr ""
+msgstr "TiB"
#: core/ustring.cpp
msgid "PiB"
-msgstr ""
+msgstr "PiB"
#: core/ustring.cpp
msgid "EiB"
-msgstr ""
+msgstr "EiB"
#: editor/animation_bezier_editor.cpp
msgid "Free"
@@ -111,23 +113,23 @@ msgstr "Väärtus:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr "Sisesta Võti Siia"
+msgstr "Sisesta võti siia"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
-msgstr "Kopeeri Valitud Võti (Võtmed)"
+msgstr "Paljunda valitud võti (võtmed)"
#: editor/animation_bezier_editor.cpp
msgid "Delete Selected Key(s)"
-msgstr "Kustuta Valitud Võti (Võtmed)"
+msgstr "Kustuta valitud võti (võtmed)"
#: editor/animation_bezier_editor.cpp
msgid "Add Bezier Point"
-msgstr "Lisa Bezieri Punkt"
+msgstr "Lisa Bezieri punkt"
#: editor/animation_bezier_editor.cpp
msgid "Move Bezier Points"
-msgstr "Liiguta Bezieri Punkte"
+msgstr "Liiguta Bezieri punkte"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
@@ -179,20 +181,20 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Change Animation Length"
-msgstr "Muuda Animatsiooni Pikkust"
+msgstr "Muuda animatsiooni pikkust"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation Loop"
-msgstr "Muuda Animatsiooni Silmust"
+msgstr "Muuda animatsiooni silmust"
#: editor/animation_track_editor.cpp
msgid "Property Track"
-msgstr ""
+msgstr "Atribuudi rada"
#: editor/animation_track_editor.cpp
msgid "3D Transform Track"
-msgstr ""
+msgstr "3D muundus rada"
#: editor/animation_track_editor.cpp
msgid "Call Method Track"
@@ -200,31 +202,31 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Bezier Curve Track"
-msgstr ""
+msgstr "Bezieri kurvi rada"
#: editor/animation_track_editor.cpp
msgid "Audio Playback Track"
-msgstr ""
+msgstr "Heli taasesituse rada"
#: editor/animation_track_editor.cpp
msgid "Animation Playback Track"
-msgstr ""
+msgstr "Animatsiooni taasesituse rada"
#: editor/animation_track_editor.cpp
msgid "Animation length (frames)"
-msgstr ""
+msgstr "Animatsiooni pikkus (kaadrid)"
#: editor/animation_track_editor.cpp
msgid "Animation length (seconds)"
-msgstr ""
+msgstr "Animatsiooni pikkus (sekundid)"
#: editor/animation_track_editor.cpp
msgid "Add Track"
-msgstr ""
+msgstr "Lisa rada"
#: editor/animation_track_editor.cpp
msgid "Animation Looping"
-msgstr ""
+msgstr "Animatsiooni kordus"
#: editor/animation_track_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
@@ -237,39 +239,39 @@ msgstr "Heliklipid:"
#: editor/animation_track_editor.cpp
msgid "Anim Clips:"
-msgstr "Animatsiooni Klipid:"
+msgstr "Animatsiooni klipid:"
#: editor/animation_track_editor.cpp
msgid "Change Track Path"
-msgstr ""
+msgstr "Muuda raja teed"
#: editor/animation_track_editor.cpp
msgid "Toggle this track on/off."
-msgstr ""
+msgstr "Lülita see rada sisse/välja."
#: editor/animation_track_editor.cpp
msgid "Update Mode (How this property is set)"
-msgstr ""
+msgstr "Uuendusrežiim (kuidas see omadus on seatud)"
#: editor/animation_track_editor.cpp
msgid "Interpolation Mode"
-msgstr ""
+msgstr "Interpolatsiooni režiim"
#: editor/animation_track_editor.cpp
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
-msgstr ""
+msgstr "Korduse mähise režiim (nterpoleeri lõpp silmuse alguses)"
#: editor/animation_track_editor.cpp
msgid "Remove this track."
-msgstr ""
+msgstr "Eemalda see rada."
#: editor/animation_track_editor.cpp
msgid "Time (s): "
-msgstr "Aeg (Ajad): "
+msgstr "Aeg (sek): "
#: editor/animation_track_editor.cpp
msgid "Toggle Track Enabled"
-msgstr ""
+msgstr "Lülita rada sisse"
#: editor/animation_track_editor.cpp
msgid "Continuous"
@@ -285,7 +287,7 @@ msgstr "Päästik"
#: editor/animation_track_editor.cpp
msgid "Capture"
-msgstr ""
+msgstr "Jäädvusta"
#: editor/animation_track_editor.cpp
msgid "Nearest"
@@ -311,35 +313,35 @@ msgstr ""
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key"
-msgstr "Sisesta Võti"
+msgstr "Sisesta võti"
#: editor/animation_track_editor.cpp
msgid "Duplicate Key(s)"
-msgstr "Kopeeri Võti (Võtmed)"
+msgstr "Paljunda võti (võtmed)"
#: editor/animation_track_editor.cpp
msgid "Delete Key(s)"
-msgstr "Kustuta Võti (Võtmed)"
+msgstr "Kustuta võti (võtmed)"
#: editor/animation_track_editor.cpp
msgid "Change Animation Update Mode"
-msgstr "Muuda Animatsiooni Uuendamise Töörežiimi"
+msgstr "Muuda animatsiooni uuendamise režiimi"
#: editor/animation_track_editor.cpp
msgid "Change Animation Interpolation Mode"
-msgstr "Muuda Animatsiooni Interpolatsiooni Töörežiimi"
+msgstr "Muuda animatsiooni interpolatsiooni režiimi"
#: editor/animation_track_editor.cpp
msgid "Change Animation Loop Mode"
-msgstr "Muuda Animatsiooni Silmuse Töörežiimi"
+msgstr "Muuda animatsiooni silmuse režiimi"
#: editor/animation_track_editor.cpp
msgid "Remove Anim Track"
-msgstr ""
+msgstr "Eemalda animatsiooni rada"
#: editor/animation_track_editor.cpp
msgid "Create NEW track for %s and insert key?"
-msgstr ""
+msgstr "Loo uus rada %s-le ja sisesta võti?"
#: editor/animation_track_editor.cpp
msgid "Create %d NEW tracks and insert keys?"
@@ -359,19 +361,19 @@ msgstr "Loo"
#: editor/animation_track_editor.cpp
msgid "Anim Insert"
-msgstr ""
+msgstr "Animatsiooni sisestus"
#: editor/animation_track_editor.cpp
msgid "AnimationPlayer can't animate itself, only other players."
-msgstr ""
+msgstr "AnimationPlayer ei saa ennast animeerida, ainult teise mänijaid."
#: editor/animation_track_editor.cpp
msgid "Anim Create & Insert"
-msgstr ""
+msgstr "Loo ja sisesta animatsioon"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Track & Key"
-msgstr ""
+msgstr "Sisesta animatsiooni rada ja võti"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Key"
@@ -379,15 +381,15 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Change Animation Step"
-msgstr "Muuda Animatsiooni Sammu"
+msgstr "Muuda animatsiooni sammu"
#: editor/animation_track_editor.cpp
msgid "Rearrange Tracks"
-msgstr ""
+msgstr "Paiguta rajad ümber"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr ""
+msgstr "Radade muundamine rakendub ainult ruumilisele sõlmedele."
#: editor/animation_track_editor.cpp
msgid ""
@@ -396,6 +398,10 @@ msgid ""
"-AudioStreamPlayer2D\n"
"-AudioStreamPlayer3D"
msgstr ""
+"Helirajad võivad osutada ainult järgmistele sõlmetüüpidele:\n"
+"-AudioSteamPlayer\n"
+"-AudioStreamPlayer2D\n"
+"-AudioStreamPlayer3D"
#: editor/animation_track_editor.cpp
msgid "Animation tracks can only point to AnimationPlayer nodes."
@@ -416,7 +422,7 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Add Bezier Track"
-msgstr "Lisa Bezieri Rada"
+msgstr "Lisa Bezieri rada"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a key."
@@ -424,15 +430,15 @@ msgstr "Raja tee on kehtetu, mistõttu ei sa lisada võtit."
#: editor/animation_track_editor.cpp
msgid "Track is not of type Spatial, can't insert key"
-msgstr ""
+msgstr "Rada pole Spatial tüüpi, ei saa sisestada võtit"
#: editor/animation_track_editor.cpp
msgid "Add Transform Track Key"
-msgstr ""
+msgstr "Lisa muunda raja võtit"
#: editor/animation_track_editor.cpp
msgid "Add Track Key"
-msgstr "Lisa Raja Võti"
+msgstr "Lisa raja võti"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a method key."
@@ -440,7 +446,7 @@ msgstr "Raja tee on kehtetu, mistõttu ei saa lisada meetodi võtit."
#: editor/animation_track_editor.cpp
msgid "Add Method Track Key"
-msgstr "Lisa Meetodi Raja Võti"
+msgstr "Lisa meetodi raja võti"
#: editor/animation_track_editor.cpp
msgid "Method not found in object: "
@@ -456,7 +462,7 @@ msgstr "Lõikelaud on tühi"
#: editor/animation_track_editor.cpp
msgid "Paste Tracks"
-msgstr "Kleebi Rajad"
+msgstr "Kleebi rajad"
#: editor/animation_track_editor.cpp
msgid "Anim Scale Keys"
@@ -817,7 +823,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1309,73 +1314,73 @@ msgstr ""
#: editor/editor_audio_buses.cpp
msgid "Open Audio Bus Layout"
-msgstr ""
+msgstr "Ava heliliinide paigutus"
#: editor/editor_audio_buses.cpp
msgid "There is no '%s' file."
-msgstr ""
+msgstr "Faili '%s' ei ole eksisteeri."
#: editor/editor_audio_buses.cpp editor/plugins/canvas_item_editor_plugin.cpp
msgid "Layout"
-msgstr ""
+msgstr "Paigutus"
#: editor/editor_audio_buses.cpp
msgid "Invalid file, not an audio bus layout."
-msgstr ""
+msgstr "Vigane fial, ei ole heliliini paigutus."
#: editor/editor_audio_buses.cpp
msgid "Error saving file: %s"
-msgstr ""
+msgstr "Tõrge faili '%s' salvestamisel"
#: editor/editor_audio_buses.cpp
msgid "Add Bus"
-msgstr ""
+msgstr "Lisa siin"
#: editor/editor_audio_buses.cpp
msgid "Add a new Audio Bus to this layout."
-msgstr ""
+msgstr "Lisa uus helisiin sellele paigutusele."
#: editor/editor_audio_buses.cpp editor/editor_properties.cpp
#: editor/plugins/animation_player_editor_plugin.cpp editor/property_editor.cpp
#: editor/script_create_dialog.cpp
msgid "Load"
-msgstr ""
+msgstr "Lae"
#: editor/editor_audio_buses.cpp
msgid "Load an existing Bus Layout."
-msgstr ""
+msgstr "Lae olemasolev siini paigutus."
#: editor/editor_audio_buses.cpp
msgid "Save As"
-msgstr ""
+msgstr "Salvesta kui…"
#: editor/editor_audio_buses.cpp
msgid "Save this Bus Layout to a file."
-msgstr ""
+msgstr "Salvesta see siini paigutus faili."
#: editor/editor_audio_buses.cpp editor/import_dock.cpp
msgid "Load Default"
-msgstr ""
+msgstr "Laadi vaikimisi"
#: editor/editor_audio_buses.cpp
msgid "Load the default Bus Layout."
-msgstr ""
+msgstr "Lae vaikimise siini paigutus."
#: editor/editor_audio_buses.cpp
msgid "Create a new Bus Layout."
-msgstr ""
+msgstr "Loo uus siini paigutus."
#: editor/editor_autoload_settings.cpp
msgid "Invalid name."
-msgstr ""
+msgstr "Vigane nimi."
#: editor/editor_autoload_settings.cpp
msgid "Valid characters:"
-msgstr ""
+msgstr "Kehtivad märgid:"
#: editor/editor_autoload_settings.cpp
msgid "Must not collide with an existing engine class name."
-msgstr ""
+msgstr "Ei tohi kokkupõrkuda mängumootori juba olemasoleva klassi nimega."
#: editor/editor_autoload_settings.cpp
msgid "Must not collide with an existing built-in type name."
@@ -1387,7 +1392,7 @@ msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Keyword cannot be used as an autoload name."
-msgstr ""
+msgstr "Võtmesõnu ei saa kasutada automaatsete nimedena."
#: editor/editor_autoload_settings.cpp
msgid "Autoload '%s' already exists!"
@@ -1411,22 +1416,14 @@ msgstr ""
#: editor/editor_autoload_settings.cpp editor/editor_plugin_settings.cpp
msgid "Enable"
-msgstr ""
+msgstr "Luba"
#: editor/editor_autoload_settings.cpp
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -1438,17 +1435,17 @@ msgstr ""
#: editor/plugins/animation_tree_editor_plugin.cpp
#: editor/script_create_dialog.cpp scene/gui/file_dialog.cpp
msgid "Path:"
-msgstr ""
+msgstr "Tee:"
#: editor/editor_autoload_settings.cpp
msgid "Node Name:"
-msgstr ""
+msgstr "Sõlme nimi:"
#: editor/editor_autoload_settings.cpp editor/editor_help_search.cpp
#: editor/editor_profiler.cpp editor/project_manager.cpp
#: editor/settings_config_dialog.cpp
msgid "Name"
-msgstr ""
+msgstr "Nimi"
#: editor/editor_autoload_settings.cpp
msgid "Singleton"
@@ -1456,81 +1453,86 @@ msgstr ""
#: editor/editor_data.cpp editor/inspector_dock.cpp
msgid "Paste Params"
-msgstr ""
+msgstr "Kleebi parameetrid"
#: editor/editor_data.cpp
msgid "Updating Scene"
-msgstr ""
+msgstr "Värskendan stseeni"
#: editor/editor_data.cpp
msgid "Storing local changes..."
-msgstr ""
+msgstr "Salvestan kohalikud muudatused..."
#: editor/editor_data.cpp
msgid "Updating scene..."
-msgstr ""
+msgstr "Värskendan stseeni..."
#: editor/editor_data.cpp editor/editor_properties.cpp
msgid "[empty]"
-msgstr ""
+msgstr "[tühi]"
#: editor/editor_data.cpp
msgid "[unsaved]"
-msgstr ""
+msgstr "[salvestamata]"
#: editor/editor_dir_dialog.cpp
msgid "Please select a base directory first."
-msgstr ""
+msgstr "Palun valige kõigepealt baaskataloog."
#: editor/editor_dir_dialog.cpp
msgid "Choose a Directory"
-msgstr ""
+msgstr "Vali kataloog"
#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
#: editor/filesystem_dock.cpp editor/project_manager.cpp
#: scene/gui/file_dialog.cpp
msgid "Create Folder"
-msgstr ""
+msgstr "Loo kaust"
#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
#: editor/editor_plugin_settings.cpp editor/filesystem_dock.cpp
#: editor/plugins/theme_editor_plugin.cpp editor/project_export.cpp
#: modules/visual_script/visual_script_editor.cpp scene/gui/file_dialog.cpp
msgid "Name:"
-msgstr ""
+msgstr "Nimi:"
#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
#: editor/filesystem_dock.cpp scene/gui/file_dialog.cpp
msgid "Could not create folder."
-msgstr ""
+msgstr "Ei saanud luua kausta."
#: editor/editor_dir_dialog.cpp
msgid "Choose"
-msgstr ""
+msgstr "Vali"
#: editor/editor_export.cpp
+#, fuzzy
msgid "Storing File:"
-msgstr ""
+msgstr "Salvestan faili:"
#: editor/editor_export.cpp
msgid "No export template found at the expected path:"
-msgstr ""
+msgstr "Eeldataval teekonnal ei leitud ühtegi ekspordimalli:"
#: editor/editor_export.cpp
msgid "Packing"
-msgstr ""
+msgstr "Pakin"
#: editor/editor_export.cpp
msgid ""
"Target platform requires 'ETC' texture compression for GLES2. Enable 'Import "
"Etc' in Project Settings."
msgstr ""
+"Sihtplatvorm nõuab GLES2 jaoks 'ETC' tekstuuri tihendamist. Projekti "
+"seadetes lubage „Impordi ETCâ€."
#: editor/editor_export.cpp
msgid ""
"Target platform requires 'ETC2' texture compression for GLES3. Enable "
"'Import Etc 2' in Project Settings."
msgstr ""
+"Sihtplatvorm nõuab GLES3 jaoks 'ETC2' tekstuuri tihendamist. Projekti "
+"seadetes lubage „Impordi ETC2â€."
#: editor/editor_export.cpp
msgid ""
@@ -1539,6 +1541,9 @@ msgid ""
"Enable 'Import Etc' in Project Settings, or disable 'Driver Fallback "
"Enabled'."
msgstr ""
+"Sihtplatvorm nõuab juhi varundamiseks GLES2-ga 'ETC' tekstuuri tihendamist.\n"
+"Lülitage projekti sätetes sisse „Impordi ETC†või keelake „Draiveri "
+"tagasilangemine lubatudâ€."
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
@@ -1554,7 +1559,7 @@ msgstr ""
#: editor/editor_export.cpp platform/javascript/export/export.cpp
msgid "Template file not found:"
-msgstr ""
+msgstr "Mallifaili ei leitud:"
#: editor/editor_export.cpp
msgid "On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."
@@ -1562,11 +1567,11 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "3D Editor"
-msgstr ""
+msgstr "3D-redigeerija"
#: editor/editor_feature_profile.cpp
msgid "Script Editor"
-msgstr ""
+msgstr "Skriptiredaktor"
#: editor/editor_feature_profile.cpp
msgid "Asset Library"
@@ -1574,7 +1579,7 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Scene Tree Editing"
-msgstr ""
+msgstr "Stseenipuu redigeerimine"
#: editor/editor_feature_profile.cpp
msgid "Import Dock"
@@ -1595,26 +1600,27 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Profile must be a valid filename and must not contain '.'"
msgstr ""
+"Profiil peab olema kehtiv failinimi ja see ei tohi sisaldada '.' (punkti)"
#: editor/editor_feature_profile.cpp
msgid "Profile with this name already exists."
-msgstr ""
+msgstr "Selle nimega profiil on juba olemas."
#: editor/editor_feature_profile.cpp
msgid "(Editor Disabled, Properties Disabled)"
-msgstr ""
+msgstr "(Redaktor keelatud, atribuudid keelatud)"
#: editor/editor_feature_profile.cpp
msgid "(Properties Disabled)"
-msgstr ""
+msgstr "(Atribuudid keelatud)"
#: editor/editor_feature_profile.cpp
msgid "(Editor Disabled)"
-msgstr ""
+msgstr "(Redaktor keelatud)"
#: editor/editor_feature_profile.cpp
msgid "Class Options:"
-msgstr ""
+msgstr "Klassi valikud:"
#: editor/editor_feature_profile.cpp
msgid "Enable Contextual Editor"
@@ -1622,29 +1628,31 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Enabled Properties:"
-msgstr ""
+msgstr "Lubatud atribuudid:"
#: editor/editor_feature_profile.cpp
msgid "Enabled Features:"
-msgstr ""
+msgstr "Lubatud funktsioonid:"
#: editor/editor_feature_profile.cpp
msgid "Enabled Classes:"
-msgstr ""
+msgstr "Lubatud klassid:"
#: editor/editor_feature_profile.cpp
msgid "File '%s' format is invalid, import aborted."
-msgstr ""
+msgstr "Faili '% s' vorming on vale, import katkestati."
#: editor/editor_feature_profile.cpp
msgid ""
"Profile '%s' already exists. Remove it first before importing, import "
"aborted."
msgstr ""
+"Profiil '% s' on juba olemas. Enne importimist eemaldage see, import "
+"katkestati."
#: editor/editor_feature_profile.cpp
msgid "Error saving profile to path: '%s'."
-msgstr ""
+msgstr "Viga profiili salvestamisel teele: '% s'."
#: editor/editor_feature_profile.cpp
msgid "Unset"
@@ -1652,7 +1660,7 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Current Profile:"
-msgstr ""
+msgstr "Praegune profiil:"
#: editor/editor_feature_profile.cpp
msgid "Make Current"
@@ -1662,82 +1670,82 @@ msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/version_control_editor_plugin.cpp
msgid "New"
-msgstr ""
+msgstr "Uus"
#: editor/editor_feature_profile.cpp editor/editor_node.cpp
#: editor/project_manager.cpp
msgid "Import"
-msgstr ""
+msgstr "Impordi"
#: editor/editor_feature_profile.cpp editor/project_export.cpp
msgid "Export"
-msgstr ""
+msgstr "Ekspordi"
#: editor/editor_feature_profile.cpp
msgid "Available Profiles:"
-msgstr ""
+msgstr "Saadaolevad profiilid:"
#: editor/editor_feature_profile.cpp
msgid "Class Options"
-msgstr ""
+msgstr "Klassi valikud"
#: editor/editor_feature_profile.cpp
msgid "New profile name:"
-msgstr ""
+msgstr "Uus profiilinimi:"
#: editor/editor_feature_profile.cpp
msgid "Erase Profile"
-msgstr ""
+msgstr "Kustuta profiil"
#: editor/editor_feature_profile.cpp
msgid "Godot Feature Profile"
-msgstr ""
+msgstr "Godoti funktsiooniprofiil"
#: editor/editor_feature_profile.cpp
msgid "Import Profile(s)"
-msgstr ""
+msgstr "Impordi profiil(id)"
#: editor/editor_feature_profile.cpp
msgid "Export Profile"
-msgstr ""
+msgstr "Ekspordi profiil"
#: editor/editor_feature_profile.cpp
msgid "Manage Editor Feature Profiles"
-msgstr ""
+msgstr "Halda redigeerija funktsioonide profiile"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Select Current Folder"
-msgstr ""
+msgstr "Valige praegune kaust"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "File Exists, Overwrite?"
-msgstr ""
+msgstr "Fail on olemas, kirjutate üle?"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Select This Folder"
-msgstr ""
+msgstr "Vali see kaust"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "Copy Path"
-msgstr ""
+msgstr "Kopeeri tee"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "Open in File Manager"
-msgstr ""
+msgstr "Ava failihalduris"
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
#: editor/filesystem_dock.cpp editor/project_manager.cpp
msgid "Show in File Manager"
-msgstr ""
+msgstr "Kuva failihalduris"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "New Folder..."
-msgstr ""
+msgstr "Uus kaust..."
#: editor/editor_file_dialog.cpp editor/find_in_files.cpp
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Refresh"
-msgstr ""
+msgstr "Värskenda"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "All Recognized"
@@ -1745,50 +1753,50 @@ msgstr ""
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "All Files (*)"
-msgstr ""
+msgstr "Kõik failid (*)"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a File"
-msgstr ""
+msgstr "Ava fail"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open File(s)"
-msgstr ""
+msgstr "Ava fail(id)"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a Directory"
-msgstr ""
+msgstr "Ava kataloog"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a File or Directory"
-msgstr ""
+msgstr "Ava kaust või kataloog"
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
#: editor/editor_properties.cpp editor/inspector_dock.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp
msgid "Save"
-msgstr ""
+msgstr "Salvesta"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Save a File"
-msgstr ""
+msgstr "Salvesta fail"
#: editor/editor_file_dialog.cpp
msgid "Go Back"
-msgstr ""
+msgstr "Mine tagasi"
#: editor/editor_file_dialog.cpp
msgid "Go Forward"
-msgstr ""
+msgstr "Mine edasi"
#: editor/editor_file_dialog.cpp
msgid "Go Up"
-msgstr ""
+msgstr "Mine üles"
#: editor/editor_file_dialog.cpp
msgid "Toggle Hidden Files"
-msgstr ""
+msgstr "Lülita varjatud failid sisse/välja"
#: editor/editor_file_dialog.cpp
msgid "Toggle Favorite"
@@ -1800,15 +1808,15 @@ msgstr ""
#: editor/editor_file_dialog.cpp
msgid "Focus Path"
-msgstr ""
+msgstr "Fookuse tee"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Up"
-msgstr ""
+msgstr "Liiguta lemmikud üles"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Down"
-msgstr ""
+msgstr "Liiguta lemmikud alla"
#: editor/editor_file_dialog.cpp
#, fuzzy
@@ -1822,11 +1830,11 @@ msgstr "Mine Järgmisele Sammule"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Go to parent folder."
-msgstr ""
+msgstr "Mine vanema kausta."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Refresh files."
-msgstr ""
+msgstr "Värskenda faile."
#: editor/editor_file_dialog.cpp
msgid "(Un)favorite current folder."
@@ -1838,29 +1846,29 @@ msgstr ""
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a grid of thumbnails."
-msgstr ""
+msgstr "Kuva üksusi pisipiltide ruudustikuna."
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a list."
-msgstr ""
+msgstr "Kuva üksused loendina."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Directories & Files:"
-msgstr ""
+msgstr "Kataloogid ja failid:"
#: editor/editor_file_dialog.cpp editor/plugins/sprite_editor_plugin.cpp
#: editor/plugins/style_box_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Preview:"
-msgstr ""
+msgstr "Eelvaade:"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "File:"
-msgstr ""
+msgstr "Fail:"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Must use a valid extension."
-msgstr ""
+msgstr "Peab kasutama kehtivat laiendit."
#: editor/editor_file_system.cpp
msgid "ScanSources"
@@ -1871,39 +1879,42 @@ msgid ""
"There are multiple importers for different types pointing to file %s, import "
"aborted"
msgstr ""
+"Erinevat tüüpi importijaid on mitu, mis osutavad failile % s, import "
+"katkestati"
#: editor/editor_file_system.cpp
+#, fuzzy
msgid "(Re)Importing Assets"
-msgstr ""
+msgstr "(Taas)impordin varasid"
#: editor/editor_help.cpp editor/plugins/spatial_editor_plugin.cpp
msgid "Top"
-msgstr ""
+msgstr "Ãœlaosa"
#: editor/editor_help.cpp
msgid "Class:"
-msgstr ""
+msgstr "Klass:"
#: editor/editor_help.cpp editor/scene_tree_editor.cpp
#: editor/script_create_dialog.cpp
msgid "Inherits:"
-msgstr ""
+msgstr "Pärib:"
#: editor/editor_help.cpp
msgid "Inherited by:"
-msgstr ""
+msgstr "Päritud %s poolt"
#: editor/editor_help.cpp
msgid "Description"
-msgstr ""
+msgstr "Kirjeldus"
#: editor/editor_help.cpp
msgid "Online Tutorials"
-msgstr ""
+msgstr "Veebijuhendid"
#: editor/editor_help.cpp
msgid "Properties"
-msgstr ""
+msgstr "Atribuudid"
#: editor/editor_help.cpp
msgid "override:"
@@ -1911,32 +1922,31 @@ msgstr ""
#: editor/editor_help.cpp
msgid "default:"
-msgstr ""
+msgstr "vaikimisi:"
#: editor/editor_help.cpp
msgid "Methods"
-msgstr ""
+msgstr "Meetodid"
#: editor/editor_help.cpp
msgid "Theme Properties"
-msgstr ""
+msgstr "Teema atribuudid"
#: editor/editor_help.cpp
msgid "Enumerations"
-msgstr ""
+msgstr "Loetelu"
#: editor/editor_help.cpp
msgid "Constants"
-msgstr ""
+msgstr "Konstandid"
#: editor/editor_help.cpp
msgid "Property Descriptions"
-msgstr ""
+msgstr "Atribuutide kirjeldused"
#: editor/editor_help.cpp
-#, fuzzy
msgid "(value)"
-msgstr "Väärtus:"
+msgstr "(väärtus)"
#: editor/editor_help.cpp
msgid ""
@@ -1946,7 +1956,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Method Descriptions"
-msgstr ""
+msgstr "Meetodi kirjeldused"
#: editor/editor_help.cpp
msgid ""
@@ -1957,43 +1967,43 @@ msgstr ""
#: editor/editor_help_search.cpp editor/editor_node.cpp
#: editor/plugins/script_editor_plugin.cpp
msgid "Search Help"
-msgstr ""
+msgstr "Otsimise abi"
#: editor/editor_help_search.cpp
msgid "Case Sensitive"
-msgstr ""
+msgstr "Tõstutundlik"
#: editor/editor_help_search.cpp
msgid "Show Hierarchy"
-msgstr ""
+msgstr "Kuva hierarhia"
#: editor/editor_help_search.cpp
msgid "Display All"
-msgstr ""
+msgstr "Kuva kõik"
#: editor/editor_help_search.cpp
msgid "Classes Only"
-msgstr ""
+msgstr "Ainult klassid"
#: editor/editor_help_search.cpp
msgid "Methods Only"
-msgstr ""
+msgstr "Ainult meetodid"
#: editor/editor_help_search.cpp
msgid "Signals Only"
-msgstr ""
+msgstr "Ainult signaalid"
#: editor/editor_help_search.cpp
msgid "Constants Only"
-msgstr ""
+msgstr "Ainult konstandid"
#: editor/editor_help_search.cpp
msgid "Properties Only"
-msgstr ""
+msgstr "Ainult atribuudid"
#: editor/editor_help_search.cpp
msgid "Theme Properties Only"
-msgstr ""
+msgstr "Ainult teema atribuudid"
#: editor/editor_help_search.cpp
msgid "Member Type"
@@ -2001,47 +2011,47 @@ msgstr ""
#: editor/editor_help_search.cpp
msgid "Class"
-msgstr ""
+msgstr "Klass"
#: editor/editor_help_search.cpp
msgid "Method"
-msgstr ""
+msgstr "Meetod"
#: editor/editor_help_search.cpp editor/plugins/script_text_editor.cpp
msgid "Signal"
-msgstr ""
+msgstr "Signaal"
#: editor/editor_help_search.cpp editor/plugins/theme_editor_plugin.cpp
msgid "Constant"
-msgstr ""
+msgstr "Konstant"
#: editor/editor_help_search.cpp
msgid "Property"
-msgstr ""
+msgstr "Atribuut"
#: editor/editor_help_search.cpp
msgid "Theme Property"
-msgstr ""
+msgstr "Teema atribuut"
#: editor/editor_inspector.cpp editor/project_settings_editor.cpp
msgid "Property:"
-msgstr ""
+msgstr "Atribuut:"
#: editor/editor_inspector.cpp
msgid "Set"
-msgstr ""
+msgstr "Sea"
#: editor/editor_inspector.cpp
msgid "Set Multiple:"
-msgstr ""
+msgstr "Sea mitu:"
#: editor/editor_log.cpp
msgid "Output:"
-msgstr ""
+msgstr "Väljund:"
#: editor/editor_log.cpp editor/plugins/tile_map_editor_plugin.cpp
msgid "Copy Selection"
-msgstr ""
+msgstr "Kopeeri valik"
#: editor/editor_log.cpp editor/editor_network_profiler.cpp
#: editor/editor_profiler.cpp editor/editor_properties.cpp
@@ -2051,21 +2061,23 @@ msgstr ""
#: modules/gdnative/gdnative_library_editor_plugin.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
msgid "Clear"
-msgstr ""
+msgstr "Puhasta"
#: editor/editor_log.cpp
msgid "Clear Output"
-msgstr ""
+msgstr "Puhasta väljund"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
#: editor/editor_profiler.cpp
+#, fuzzy
msgid "Stop"
-msgstr ""
+msgstr "Peatu/Stopp"
#: editor/editor_network_profiler.cpp editor/editor_profiler.cpp
#: editor/plugins/animation_state_machine_editor.cpp editor/rename_dialog.cpp
+#, fuzzy
msgid "Start"
-msgstr ""
+msgstr "Start/Käivita"
#: editor/editor_network_profiler.cpp
msgid "%s/s"
@@ -2073,15 +2085,15 @@ msgstr ""
#: editor/editor_network_profiler.cpp
msgid "Down"
-msgstr ""
+msgstr "Alla"
#: editor/editor_network_profiler.cpp
msgid "Up"
-msgstr ""
+msgstr "Ãœles"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
msgid "Node"
-msgstr ""
+msgstr "Sõlm"
#: editor/editor_network_profiler.cpp
msgid "Incoming RPC"
@@ -2101,11 +2113,11 @@ msgstr ""
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "New Window"
-msgstr ""
+msgstr "Uus aken"
#: editor/editor_node.cpp
msgid "Imported resources can't be saved."
-msgstr ""
+msgstr "Imporditud ressursse ei saa salvestada."
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: scene/gui/dialogs.cpp
@@ -2114,21 +2126,23 @@ msgstr ""
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Error saving resource!"
-msgstr ""
+msgstr "Viga ressursi salvestamisel!"
#: editor/editor_node.cpp
msgid ""
"This resource can't be saved because it does not belong to the edited scene. "
"Make it unique first."
msgstr ""
+"Seda ressurssi ei saa salvestada, kuna see ei kuulu muudetud stseeni. Esmalt "
+"tehke see ainulaadseks."
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Save Resource As..."
-msgstr ""
+msgstr "Salvesta ressurss kui..."
#: editor/editor_node.cpp
msgid "Can't open file for writing:"
-msgstr ""
+msgstr "Faili ei saa kirjutamiseks avada:"
#: editor/editor_node.cpp
msgid "Requested file format unknown:"
@@ -2136,11 +2150,11 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Error while saving."
-msgstr ""
+msgstr "Viga salvestamisel."
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
msgid "Can't open '%s'. The file could have been moved or deleted."
-msgstr ""
+msgstr "'%si' ei saa avada. Faili võib olla teisaldatud või kustutatud."
#: editor/editor_node.cpp
msgid "Error while parsing '%s'."
@@ -2148,37 +2162,39 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Unexpected end of file '%s'."
-msgstr ""
+msgstr "Faili '%s' ootamatu lõpp."
#: editor/editor_node.cpp
msgid "Missing '%s' or its dependencies."
-msgstr ""
+msgstr "Puudub '%s' või selle sõltuvuspaketid."
#: editor/editor_node.cpp
msgid "Error while loading '%s'."
-msgstr ""
+msgstr "Viga faili '%s' laadimisel."
#: editor/editor_node.cpp
msgid "Saving Scene"
-msgstr ""
+msgstr "Stseeni salvestamine"
#: editor/editor_node.cpp
msgid "Analyzing"
-msgstr ""
+msgstr "Analüüsin"
#: editor/editor_node.cpp
msgid "Creating Thumbnail"
-msgstr ""
+msgstr "Loon pisipilti"
#: editor/editor_node.cpp
msgid "This operation can't be done without a tree root."
-msgstr ""
+msgstr "Seda toimingut ei saa teha ilma puu juureta."
#: editor/editor_node.cpp
msgid ""
"This scene can't be saved because there is a cyclic instancing inclusion.\n"
"Please resolve it and then attempt to save again."
msgstr ""
+"Seda stseeni ei saa salvestada, kuna toimub tsükliline sisestus.\n"
+"Lahenda see ja proovige siis uuesti salvestada."
#: editor/editor_node.cpp
msgid ""
@@ -2188,27 +2204,27 @@ msgstr ""
#: editor/editor_node.cpp editor/scene_tree_dock.cpp
msgid "Can't overwrite scene that is still open!"
-msgstr ""
+msgstr "Avatud stseeni ei saa üle kirjutada!"
#: editor/editor_node.cpp
msgid "Can't load MeshLibrary for merging!"
-msgstr ""
+msgstr "MeshLibrary ei saa ühendamiseks laadida!"
#: editor/editor_node.cpp
msgid "Error saving MeshLibrary!"
-msgstr ""
+msgstr "Viga MeshLibrary salvestamisel!"
#: editor/editor_node.cpp
msgid "Can't load TileSet for merging!"
-msgstr ""
+msgstr "TileSeti ei saa ühendamiseks laadida!"
#: editor/editor_node.cpp
msgid "Error saving TileSet!"
-msgstr ""
+msgstr "Viga TileSeti salvestamisel!"
#: editor/editor_node.cpp
msgid "Error trying to save layout!"
-msgstr ""
+msgstr "Viga paigutuse salvestamisel!"
#: editor/editor_node.cpp
msgid "Default editor layout overridden."
@@ -2216,11 +2232,11 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Layout name not found!"
-msgstr ""
+msgstr "Paigutuse nime ei leitud!"
#: editor/editor_node.cpp
msgid "Restored default layout to base settings."
-msgstr ""
+msgstr "Taastati vaikepaigutus baasseadetesse."
#: editor/editor_node.cpp
msgid ""
@@ -2349,11 +2365,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Stseeni salvestamine"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2620,10 +2639,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3229,6 +3244,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3814,6 +3833,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6691,11 +6714,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7166,6 +7189,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10086,7 +10118,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10246,6 +10278,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10292,11 +10331,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10416,6 +10455,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Faili ei ole olemas."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10456,6 +10499,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Kehtetu tee."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11486,6 +11533,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11509,6 +11560,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12119,23 +12196,23 @@ msgstr ""
#: scene/main/viewport.cpp
msgid "Viewport size must be greater than 0 to render anything."
-msgstr ""
+msgstr "Vaateakne suurus peab olema suurem kui 0, et kuvada."
#: scene/resources/visual_shader_nodes.cpp
msgid "Invalid source for preview."
-msgstr ""
+msgstr "Vigane eelvaate lähe."
#: scene/resources/visual_shader_nodes.cpp
msgid "Invalid source for shader."
-msgstr ""
+msgstr "Vigane varjutaja lähe."
#: scene/resources/visual_shader_nodes.cpp
msgid "Invalid comparison function for that type."
-msgstr ""
+msgstr "Vigane võrdlusfinktsioon selle tüübi jaoks."
#: servers/visual/shader_language.cpp
msgid "Assignment to function."
-msgstr ""
+msgstr "Funktsiooni määramine."
#: servers/visual/shader_language.cpp
msgid "Assignment to uniform."
@@ -12147,4 +12224,7 @@ msgstr ""
#: servers/visual/shader_language.cpp
msgid "Constants cannot be modified."
-msgstr ""
+msgstr "Konstante ei saa muuta."
+
+#~ msgid "Not in resource path."
+#~ msgstr "Ei ole ressursiteel."
diff --git a/editor/translations/eu.po b/editor/translations/eu.po
index f633f1c298..b47056d82b 100644
--- a/editor/translations/eu.po
+++ b/editor/translations/eu.po
@@ -3,11 +3,11 @@
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
# This file is distributed under the same license as the Godot source code.
# Julen Irazoki <rktzbkr.julen@gmail.com>, 2019.
-# Osoitz <oelkoro@gmail.com>, 2019.
+# Osoitz <oelkoro@gmail.com>, 2019, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
-"PO-Revision-Date: 2019-12-03 14:05+0000\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
"Last-Translator: Osoitz <oelkoro@gmail.com>\n"
"Language-Team: Basque <https://hosted.weblate.org/projects/godot-engine/"
"godot/eu/>\n"
@@ -15,7 +15,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 3.10-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -24,7 +24,7 @@ msgstr ""
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr ""
+msgstr "1 luzerako kate bat espero zen (karaktere bat)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -54,79 +54,79 @@ msgstr ""
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr ""
+msgstr "'%s' eraikitzeko argumentu baliogabeak"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr ""
+msgstr "'%s' deitzean:"
#: core/ustring.cpp
msgid "B"
-msgstr ""
+msgstr "B"
#: core/ustring.cpp
msgid "KiB"
-msgstr ""
+msgstr "KiB"
#: core/ustring.cpp
msgid "MiB"
-msgstr ""
+msgstr "MiB"
#: core/ustring.cpp
msgid "GiB"
-msgstr ""
+msgstr "GiB"
#: core/ustring.cpp
msgid "TiB"
-msgstr ""
+msgstr "TiB"
#: core/ustring.cpp
msgid "PiB"
-msgstr ""
+msgstr "PiB"
#: core/ustring.cpp
msgid "EiB"
-msgstr ""
+msgstr "EiB"
#: editor/animation_bezier_editor.cpp
msgid "Free"
-msgstr ""
+msgstr "Libre"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
-msgstr ""
+msgstr "Orekatua"
#: editor/animation_bezier_editor.cpp
msgid "Mirror"
-msgstr ""
+msgstr "Ispilua"
#: editor/animation_bezier_editor.cpp editor/editor_profiler.cpp
msgid "Time:"
-msgstr ""
+msgstr "Denbora:"
#: editor/animation_bezier_editor.cpp
msgid "Value:"
-msgstr ""
+msgstr "Balioa:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr ""
+msgstr "Txertatu gakoa hemen"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
-msgstr ""
+msgstr "Bikoiztu hautatutako gakoa(k)"
#: editor/animation_bezier_editor.cpp
msgid "Delete Selected Key(s)"
-msgstr ""
+msgstr "Ezabatu hautatutako gakoak"
#: editor/animation_bezier_editor.cpp
msgid "Add Bezier Point"
-msgstr ""
+msgstr "Gehitu Bezier puntua"
#: editor/animation_bezier_editor.cpp
msgid "Move Bezier Points"
-msgstr ""
+msgstr "Mugitu Bezier puntuak"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
@@ -178,12 +178,12 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Change Animation Length"
-msgstr ""
+msgstr "Aldatu animazioaren iraupena"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation Loop"
-msgstr ""
+msgstr "Aldatu animazioaren begizta"
#: editor/animation_track_editor.cpp
msgid "Property Track"
@@ -211,11 +211,11 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Animation length (frames)"
-msgstr ""
+msgstr "Animazioaren iraupena (fotogramak)"
#: editor/animation_track_editor.cpp
msgid "Animation length (seconds)"
-msgstr ""
+msgstr "Animazioaren iraupena (segundoak)"
#: editor/animation_track_editor.cpp
msgid "Add Track"
@@ -496,7 +496,7 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Snap:"
-msgstr ""
+msgstr "Atxikitzea:"
#: editor/animation_track_editor.cpp
msgid "Animation step value."
@@ -814,7 +814,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -950,32 +949,32 @@ msgstr ""
#: editor/dependency_editor.cpp
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Dependencies"
-msgstr ""
+msgstr "Mendekotasunak"
#: editor/dependency_editor.cpp
msgid "Resource"
-msgstr ""
+msgstr "Baliabidea"
#: editor/dependency_editor.cpp editor/editor_autoload_settings.cpp
#: editor/project_manager.cpp editor/project_settings_editor.cpp
msgid "Path"
-msgstr ""
+msgstr "Bidea"
#: editor/dependency_editor.cpp
msgid "Dependencies:"
-msgstr ""
+msgstr "Mendekotasunak:"
#: editor/dependency_editor.cpp
msgid "Fix Broken"
-msgstr ""
+msgstr "Konpondu hautsitakoa"
#: editor/dependency_editor.cpp
msgid "Dependency Editor"
-msgstr ""
+msgstr "Mendekotasun-editorea"
#: editor/dependency_editor.cpp
msgid "Search Replacement Resource:"
-msgstr ""
+msgstr "Bilatu ordezko baliabidea:"
#: editor/dependency_editor.cpp editor/editor_file_dialog.cpp
#: editor/editor_help_search.cpp editor/editor_node.cpp
@@ -985,15 +984,16 @@ msgstr ""
#: modules/visual_script/visual_script_property_selector.cpp
#: scene/gui/file_dialog.cpp
msgid "Open"
-msgstr ""
+msgstr "Ireki"
#: editor/dependency_editor.cpp
msgid "Owners Of:"
-msgstr ""
+msgstr "Hauen jabeak:"
#: editor/dependency_editor.cpp
msgid "Remove selected files from the project? (Can't be restored)"
msgstr ""
+"Kendu hautatutako fitxategiak proiektutik? (Ezin izango da berreskuratu)"
#: editor/dependency_editor.cpp
msgid ""
@@ -1001,46 +1001,49 @@ msgid ""
"work.\n"
"Remove them anyway? (no undo)"
msgstr ""
+"Kendu beharreko fitxategiak beste baliabide batzuek behar dituzte funtziona "
+"dezaten.\n"
+"Kendu, hala ere? (Ezin da desegin)"
#: editor/dependency_editor.cpp
msgid "Cannot remove:"
-msgstr ""
+msgstr "Ezin kendu:"
#: editor/dependency_editor.cpp
msgid "Error loading:"
-msgstr ""
+msgstr "Errorea kargatzean:"
#: editor/dependency_editor.cpp
msgid "Load failed due to missing dependencies:"
-msgstr ""
+msgstr "Kargak huts egin du mendekotasunak falta direlako:"
#: editor/dependency_editor.cpp editor/editor_node.cpp
msgid "Open Anyway"
-msgstr ""
+msgstr "Ireki dena den"
#: editor/dependency_editor.cpp
msgid "Which action should be taken?"
-msgstr ""
+msgstr "Zein ekintza egin behar da?"
#: editor/dependency_editor.cpp
msgid "Fix Dependencies"
-msgstr ""
+msgstr "Konpondu mendekotasunak"
#: editor/dependency_editor.cpp
msgid "Errors loading!"
-msgstr ""
+msgstr "Erroreak kargatzean!"
#: editor/dependency_editor.cpp
msgid "Permanently delete %d item(s)? (No undo!)"
-msgstr ""
+msgstr "%d elementu behin betiko ezabatu nahi duzu? (Ezin da desegin!)"
#: editor/dependency_editor.cpp
msgid "Show Dependencies"
-msgstr ""
+msgstr "Erakutsi mendekotasunak"
#: editor/dependency_editor.cpp
msgid "Orphan Resource Explorer"
-msgstr ""
+msgstr "Baliabide umezurtzen arakatzailea"
#: editor/dependency_editor.cpp editor/editor_audio_buses.cpp
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
@@ -1048,27 +1051,28 @@ msgstr ""
#: editor/plugins/sprite_frames_editor_plugin.cpp editor/project_export.cpp
#: editor/project_settings_editor.cpp editor/scene_tree_dock.cpp
msgid "Delete"
-msgstr ""
+msgstr "Ezabatu"
#: editor/dependency_editor.cpp
msgid "Owns"
-msgstr ""
+msgstr "Jabea"
#: editor/dependency_editor.cpp
msgid "Resources Without Explicit Ownership:"
-msgstr ""
+msgstr "Jabetza esplizitu gabeko baliabideak:"
#: editor/dictionary_property_edit.cpp
msgid "Change Dictionary Key"
-msgstr ""
+msgstr "Aldatu hiztegiaren gakoa"
#: editor/dictionary_property_edit.cpp
msgid "Change Dictionary Value"
-msgstr ""
+msgstr "Aldatu hiztegiaren balioa"
#: editor/editor_about.cpp
+#, fuzzy
msgid "Thanks from the Godot community!"
-msgstr ""
+msgstr "Eskerrik asko Godot komunitatearen partetik!"
#: editor/editor_about.cpp
msgid "Godot Engine contributors"
@@ -1076,59 +1080,59 @@ msgstr ""
#: editor/editor_about.cpp
msgid "Project Founders"
-msgstr ""
+msgstr "Proiektuaren sortzaileak"
#: editor/editor_about.cpp
msgid "Lead Developer"
-msgstr ""
+msgstr "Garatzaile nagusia"
#: editor/editor_about.cpp
msgid "Project Manager "
-msgstr ""
+msgstr "Proiektu-kudeatzailea "
#: editor/editor_about.cpp
msgid "Developers"
-msgstr ""
+msgstr "Garatzaileak"
#: editor/editor_about.cpp
msgid "Authors"
-msgstr ""
+msgstr "Egileak"
#: editor/editor_about.cpp
msgid "Platinum Sponsors"
-msgstr ""
+msgstr "Platinozko babesleak"
#: editor/editor_about.cpp
msgid "Gold Sponsors"
-msgstr ""
+msgstr "Urrezko babesleak"
#: editor/editor_about.cpp
msgid "Mini Sponsors"
-msgstr ""
+msgstr "Mini babesleak"
#: editor/editor_about.cpp
msgid "Gold Donors"
-msgstr ""
+msgstr "Urrezko emaileak"
#: editor/editor_about.cpp
msgid "Silver Donors"
-msgstr ""
+msgstr "Zilarrezko emaileak"
#: editor/editor_about.cpp
msgid "Bronze Donors"
-msgstr ""
+msgstr "Brontzezko emaileak"
#: editor/editor_about.cpp
msgid "Donors"
-msgstr ""
+msgstr "Emaileak"
#: editor/editor_about.cpp
msgid "License"
-msgstr ""
+msgstr "Lizentzia"
#: editor/editor_about.cpp
msgid "Third-party Licenses"
-msgstr ""
+msgstr "Hirugarrengoen lizentziak"
#: editor/editor_about.cpp
msgid ""
@@ -1140,27 +1144,27 @@ msgstr ""
#: editor/editor_about.cpp
msgid "All Components"
-msgstr ""
+msgstr "Osagai guztiak"
#: editor/editor_about.cpp
msgid "Components"
-msgstr ""
+msgstr "Osagaiak"
#: editor/editor_about.cpp
msgid "Licenses"
-msgstr ""
+msgstr "Lizentziak"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "Error opening package file, not in ZIP format."
-msgstr ""
+msgstr "Errorea pakete fitxategia irekitzean, ez dago ZIP formatuan."
#: editor/editor_asset_installer.cpp
msgid "%s (Already Exists)"
-msgstr ""
+msgstr "%s (jada existitzen da)"
#: editor/editor_asset_installer.cpp
msgid "Uncompressing Assets"
-msgstr ""
+msgstr "Aktiboak deskonprimatzen"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -1168,28 +1172,28 @@ msgstr ""
#: editor/editor_asset_installer.cpp
msgid "And %s more files."
-msgstr ""
+msgstr "Eta beste %s fitxategi."
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "Package installed successfully!"
-msgstr ""
+msgstr "Paketea ondo instalatu da!"
#: editor/editor_asset_installer.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Success!"
-msgstr ""
+msgstr "Arrakasta!"
#: editor/editor_asset_installer.cpp
msgid "Package Contents:"
-msgstr ""
+msgstr "Paketearen edukia:"
#: editor/editor_asset_installer.cpp editor/editor_node.cpp
msgid "Install"
-msgstr ""
+msgstr "Instalatu"
#: editor/editor_asset_installer.cpp
msgid "Package Installer"
-msgstr ""
+msgstr "Pakete instalatzailea"
#: editor/editor_audio_buses.cpp
msgid "Speakers"
@@ -1197,7 +1201,7 @@ msgstr ""
#: editor/editor_audio_buses.cpp
msgid "Add Effect"
-msgstr ""
+msgstr "Gehitu efektua"
#: editor/editor_audio_buses.cpp
msgid "Rename Audio Bus"
@@ -1237,7 +1241,7 @@ msgstr ""
#: editor/editor_audio_buses.cpp
msgid "Drag & drop to rearrange."
-msgstr ""
+msgstr "Arrastatu eta jaregin berrantolatzeko."
#: editor/editor_audio_buses.cpp
msgid "Solo"
@@ -1258,19 +1262,19 @@ msgstr ""
#: editor/editor_audio_buses.cpp editor/filesystem_dock.cpp
#: editor/plugins/animation_player_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "Duplicate"
-msgstr ""
+msgstr "Bikoiztu"
#: editor/editor_audio_buses.cpp
msgid "Reset Volume"
-msgstr ""
+msgstr "Berrezarri bolumena"
#: editor/editor_audio_buses.cpp
msgid "Delete Effect"
-msgstr ""
+msgstr "Ezabatu efektua"
#: editor/editor_audio_buses.cpp
msgid "Audio"
-msgstr ""
+msgstr "Audioa"
#: editor/editor_audio_buses.cpp
msgid "Add Audio Bus"
@@ -1336,7 +1340,7 @@ msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp editor/property_editor.cpp
#: editor/script_create_dialog.cpp
msgid "Load"
-msgstr ""
+msgstr "Kargatu"
#: editor/editor_audio_buses.cpp
msgid "Load an existing Bus Layout."
@@ -1344,7 +1348,7 @@ msgstr ""
#: editor/editor_audio_buses.cpp
msgid "Save As"
-msgstr ""
+msgstr "Gorde honela"
#: editor/editor_audio_buses.cpp
msgid "Save this Bus Layout to a file."
@@ -1414,16 +1418,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -1567,7 +1563,7 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Asset Library"
-msgstr ""
+msgstr "Aktiboen liburutegia"
#: editor/editor_feature_profile.cpp
msgid "Scene Tree Editing"
@@ -1668,35 +1664,35 @@ msgstr ""
#: editor/editor_feature_profile.cpp editor/project_export.cpp
msgid "Export"
-msgstr ""
+msgstr "Esportatu"
#: editor/editor_feature_profile.cpp
msgid "Available Profiles:"
-msgstr ""
+msgstr "Eskuragarri dauden profilak:"
#: editor/editor_feature_profile.cpp
msgid "Class Options"
-msgstr ""
+msgstr "Klaseko aukerak"
#: editor/editor_feature_profile.cpp
msgid "New profile name:"
-msgstr ""
+msgstr "Profilaren izen berria:"
#: editor/editor_feature_profile.cpp
msgid "Erase Profile"
-msgstr ""
+msgstr "Ezabatu profila"
#: editor/editor_feature_profile.cpp
msgid "Godot Feature Profile"
-msgstr ""
+msgstr "Godot ezaugarri profila"
#: editor/editor_feature_profile.cpp
msgid "Import Profile(s)"
-msgstr ""
+msgstr "Inportatu profila(k)"
#: editor/editor_feature_profile.cpp
msgid "Export Profile"
-msgstr ""
+msgstr "Esportatu profila"
#: editor/editor_feature_profile.cpp
msgid "Manage Editor Feature Profiles"
@@ -1704,32 +1700,32 @@ msgstr ""
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Select Current Folder"
-msgstr ""
+msgstr "Hautatu uneko karpeta"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "File Exists, Overwrite?"
-msgstr ""
+msgstr "Fitxategia badago aurretik, gainidatzi?"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Select This Folder"
-msgstr ""
+msgstr "Hautatu karpeta hau"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "Copy Path"
-msgstr ""
+msgstr "Kopiatu bidea"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "Open in File Manager"
-msgstr ""
+msgstr "Ireki fitxategi-kudeatzailean"
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
#: editor/filesystem_dock.cpp editor/project_manager.cpp
msgid "Show in File Manager"
-msgstr ""
+msgstr "Erakutsi fitxategi-kudeatzailean"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "New Folder..."
-msgstr ""
+msgstr "Karpeta berria..."
#: editor/editor_file_dialog.cpp editor/find_in_files.cpp
#: editor/plugins/version_control_editor_plugin.cpp
@@ -1742,58 +1738,58 @@ msgstr ""
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "All Files (*)"
-msgstr ""
+msgstr "Fitxategi guztiak (*)"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a File"
-msgstr ""
+msgstr "Ireki fitxategi bat"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open File(s)"
-msgstr ""
+msgstr "Ireki fitxategia(k)"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a Directory"
-msgstr ""
+msgstr "Ireki direktorioa"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a File or Directory"
-msgstr ""
+msgstr "Ireki fitxategia edo direktorioa"
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
#: editor/editor_properties.cpp editor/inspector_dock.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp
msgid "Save"
-msgstr ""
+msgstr "Gorde"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Save a File"
-msgstr ""
+msgstr "Gorde fitxategia"
#: editor/editor_file_dialog.cpp
msgid "Go Back"
-msgstr ""
+msgstr "Joan atzera"
#: editor/editor_file_dialog.cpp
msgid "Go Forward"
-msgstr ""
+msgstr "Joan aurrera"
#: editor/editor_file_dialog.cpp
msgid "Go Up"
-msgstr ""
+msgstr "Joan gora"
#: editor/editor_file_dialog.cpp
msgid "Toggle Hidden Files"
-msgstr ""
+msgstr "Txandakatu ezkutatutako fitxategiak"
#: editor/editor_file_dialog.cpp
msgid "Toggle Favorite"
-msgstr ""
+msgstr "Txandakatu gogokoa"
#: editor/editor_file_dialog.cpp
msgid "Toggle Mode"
-msgstr ""
+msgstr "Txandakatu modua"
#: editor/editor_file_dialog.cpp
msgid "Focus Path"
@@ -1801,27 +1797,27 @@ msgstr ""
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Up"
-msgstr ""
+msgstr "Eraman gogokoa gora"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Down"
-msgstr ""
+msgstr "Eraman gogoa behera"
#: editor/editor_file_dialog.cpp
msgid "Go to previous folder."
-msgstr ""
+msgstr "Joan aurreko karpetara."
#: editor/editor_file_dialog.cpp
msgid "Go to next folder."
-msgstr ""
+msgstr "Joan hurrengo karpetara."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Go to parent folder."
-msgstr ""
+msgstr "Joan guraso karpetara."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Refresh files."
-msgstr ""
+msgstr "Eguneratu fitxategiak."
#: editor/editor_file_dialog.cpp
msgid "(Un)favorite current folder."
@@ -1829,7 +1825,7 @@ msgstr ""
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Toggle the visibility of hidden files."
-msgstr ""
+msgstr "Txandakatu ezkutuko fitxategien ikusgaitasuna."
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a grid of thumbnails."
@@ -1837,25 +1833,25 @@ msgstr ""
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a list."
-msgstr ""
+msgstr "Ikusi elementuak zerrenda gisa."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Directories & Files:"
-msgstr ""
+msgstr "Direktorioak eta fitxategiak:"
#: editor/editor_file_dialog.cpp editor/plugins/sprite_editor_plugin.cpp
#: editor/plugins/style_box_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Preview:"
-msgstr ""
+msgstr "Aurrebista:"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "File:"
-msgstr ""
+msgstr "Fitxategia:"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Must use a valid extension."
-msgstr ""
+msgstr "Baliozko luzapena erabili behar du."
#: editor/editor_file_system.cpp
msgid "ScanSources"
@@ -1869,7 +1865,7 @@ msgstr ""
#: editor/editor_file_system.cpp
msgid "(Re)Importing Assets"
-msgstr ""
+msgstr "Aktiboak (bir)inportatzen"
#: editor/editor_help.cpp editor/plugins/spatial_editor_plugin.cpp
msgid "Top"
@@ -1877,20 +1873,20 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Class:"
-msgstr ""
+msgstr "Klasea:"
#: editor/editor_help.cpp editor/scene_tree_editor.cpp
#: editor/script_create_dialog.cpp
msgid "Inherits:"
-msgstr ""
+msgstr "Herentziak:"
#: editor/editor_help.cpp
msgid "Inherited by:"
-msgstr ""
+msgstr "Hauek heredatua:"
#: editor/editor_help.cpp
msgid "Description"
-msgstr ""
+msgstr "Deskripzioa"
#: editor/editor_help.cpp
msgid "Online Tutorials"
@@ -1898,31 +1894,31 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Properties"
-msgstr ""
+msgstr "Propietateak"
#: editor/editor_help.cpp
msgid "override:"
-msgstr ""
+msgstr "gainidatzi:"
#: editor/editor_help.cpp
msgid "default:"
-msgstr ""
+msgstr "lehenetsia:"
#: editor/editor_help.cpp
msgid "Methods"
-msgstr ""
+msgstr "Metodoak"
#: editor/editor_help.cpp
msgid "Theme Properties"
-msgstr ""
+msgstr "Azalaren propietateak"
#: editor/editor_help.cpp
msgid "Enumerations"
-msgstr ""
+msgstr "Enumerazioak"
#: editor/editor_help.cpp
msgid "Constants"
-msgstr ""
+msgstr "Konstanteak"
#: editor/editor_help.cpp
msgid "Property Descriptions"
@@ -1930,7 +1926,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "(value)"
-msgstr ""
+msgstr "(balioa)"
#: editor/editor_help.cpp
msgid ""
@@ -1940,7 +1936,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Method Descriptions"
-msgstr ""
+msgstr "Metodo-deskripzioak"
#: editor/editor_help.cpp
msgid ""
@@ -1951,63 +1947,63 @@ msgstr ""
#: editor/editor_help_search.cpp editor/editor_node.cpp
#: editor/plugins/script_editor_plugin.cpp
msgid "Search Help"
-msgstr ""
+msgstr "Bilatu laguntza"
#: editor/editor_help_search.cpp
msgid "Case Sensitive"
-msgstr ""
+msgstr "Maiuskulak eta minuskulak"
#: editor/editor_help_search.cpp
msgid "Show Hierarchy"
-msgstr ""
+msgstr "Erakutsi hierarkia"
#: editor/editor_help_search.cpp
msgid "Display All"
-msgstr ""
+msgstr "Erakutsi guztiak"
#: editor/editor_help_search.cpp
msgid "Classes Only"
-msgstr ""
+msgstr "Klaseak bakarrik"
#: editor/editor_help_search.cpp
msgid "Methods Only"
-msgstr ""
+msgstr "Metodoak bakarrik"
#: editor/editor_help_search.cpp
msgid "Signals Only"
-msgstr ""
+msgstr "Seinaleak bakarrik"
#: editor/editor_help_search.cpp
msgid "Constants Only"
-msgstr ""
+msgstr "Konstanteak bakarrik"
#: editor/editor_help_search.cpp
msgid "Properties Only"
-msgstr ""
+msgstr "Propietateak bakarrik"
#: editor/editor_help_search.cpp
msgid "Theme Properties Only"
-msgstr ""
+msgstr "Azalaren propietateak bakarrik"
#: editor/editor_help_search.cpp
msgid "Member Type"
-msgstr ""
+msgstr "Kide mota"
#: editor/editor_help_search.cpp
msgid "Class"
-msgstr ""
+msgstr "Klasea"
#: editor/editor_help_search.cpp
msgid "Method"
-msgstr ""
+msgstr "Metodoa"
#: editor/editor_help_search.cpp editor/plugins/script_text_editor.cpp
msgid "Signal"
-msgstr ""
+msgstr "Seinalea"
#: editor/editor_help_search.cpp editor/plugins/theme_editor_plugin.cpp
msgid "Constant"
-msgstr ""
+msgstr "Konstantea"
#: editor/editor_help_search.cpp
msgid "Property"
@@ -2015,7 +2011,7 @@ msgstr ""
#: editor/editor_help_search.cpp
msgid "Theme Property"
-msgstr ""
+msgstr "Azalaren propietatea"
#: editor/editor_inspector.cpp editor/project_settings_editor.cpp
msgid "Property:"
@@ -2343,11 +2339,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Birkargatu azala"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2605,16 +2604,12 @@ msgstr ""
#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Undo"
-msgstr ""
+msgstr "Desegin"
#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Redo"
-msgstr ""
-
-#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
+msgstr "Berregin"
#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
@@ -2623,27 +2618,27 @@ msgstr ""
#: editor/editor_node.cpp editor/project_manager.cpp
#: editor/script_create_dialog.cpp
msgid "Project"
-msgstr ""
+msgstr "Proiektua"
#: editor/editor_node.cpp
msgid "Project Settings..."
-msgstr ""
+msgstr "Proiektuaren ezarpenak..."
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
msgid "Version Control"
-msgstr ""
+msgstr "Bertsio kontrola"
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
msgid "Set Up Version Control"
-msgstr ""
+msgstr "Ezarri bertsio kontrola"
#: editor/editor_node.cpp
msgid "Shut Down Version Control"
-msgstr ""
+msgstr "Desgaitu bertsio kontrola"
#: editor/editor_node.cpp
msgid "Export..."
-msgstr ""
+msgstr "Esportatu..."
#: editor/editor_node.cpp
msgid "Install Android Build Template..."
@@ -2651,24 +2646,24 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Open Project Data Folder"
-msgstr ""
+msgstr "Ireki proiektuaren datu karpeta"
#: editor/editor_node.cpp editor/plugins/tile_set_editor_plugin.cpp
msgid "Tools"
-msgstr ""
+msgstr "Tresnak"
#: editor/editor_node.cpp
msgid "Orphan Resource Explorer..."
-msgstr ""
+msgstr "Baliabide umezurtzen arakatzailea..."
#: editor/editor_node.cpp
msgid "Quit to Project List"
-msgstr ""
+msgstr "Irten proiektuen zerrendara"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: editor/project_export.cpp
msgid "Debug"
-msgstr ""
+msgstr "Araztu"
#: editor/editor_node.cpp
msgid "Deploy with Remote Debug"
@@ -2696,7 +2691,7 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Visible Collision Shapes"
-msgstr ""
+msgstr "Talka formak ikusgai"
#: editor/editor_node.cpp
msgid ""
@@ -2760,11 +2755,11 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Toggle Fullscreen"
-msgstr ""
+msgstr "Txandakatu pantaila osoa"
#: editor/editor_node.cpp
msgid "Toggle System Console"
-msgstr ""
+msgstr "Txandakatu sistemaren kontsola"
#: editor/editor_node.cpp
msgid "Open Editor Data/Settings Folder"
@@ -2772,23 +2767,23 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Open Editor Data Folder"
-msgstr ""
+msgstr "Ireki editorearen datu karpeta"
#: editor/editor_node.cpp
msgid "Open Editor Settings Folder"
-msgstr ""
+msgstr "Ireki editorearen ezarpenen karpeta"
#: editor/editor_node.cpp
msgid "Manage Editor Features..."
-msgstr ""
+msgstr "Kudeatu editorearen ezaugarriak..."
#: editor/editor_node.cpp
msgid "Manage Export Templates..."
-msgstr ""
+msgstr "Kudeatu esportazio txantiloiak..."
#: editor/editor_node.cpp editor/plugins/shader_editor_plugin.cpp
msgid "Help"
-msgstr ""
+msgstr "Laguntza"
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
@@ -2797,20 +2792,20 @@ msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp editor/project_manager.cpp
#: editor/project_settings_editor.cpp editor/rename_dialog.cpp
msgid "Search"
-msgstr ""
+msgstr "Bilatu"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: editor/plugins/shader_editor_plugin.cpp
msgid "Online Docs"
-msgstr ""
+msgstr "Lineako dokumentuak"
#: editor/editor_node.cpp
msgid "Q&A"
-msgstr ""
+msgstr "Galdera-erantzunak"
#: editor/editor_node.cpp
msgid "Report a Bug"
-msgstr ""
+msgstr "Eman akats baten berri"
#: editor/editor_node.cpp
msgid "Send Docs Feedback"
@@ -2818,11 +2813,11 @@ msgstr ""
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
msgid "Community"
-msgstr ""
+msgstr "Komunitatea"
#: editor/editor_node.cpp
msgid "About"
-msgstr ""
+msgstr "Honi buruz"
#: editor/editor_node.cpp
msgid "Play the project."
@@ -2978,7 +2973,7 @@ msgstr ""
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
-msgstr ""
+msgstr "Ireki aktiboen liburutegia"
#: editor/editor_node.cpp
msgid "Open the next Editor"
@@ -3204,7 +3199,7 @@ msgstr ""
#: editor/editor_run_script.cpp
msgid "There is an edited scene already."
-msgstr ""
+msgstr "Badago editatutako eszena bat."
#: editor/editor_run_script.cpp
msgid "Couldn't instance script:"
@@ -3216,44 +3211,48 @@ msgstr ""
#: editor/editor_run_script.cpp
msgid "Couldn't run script:"
-msgstr ""
+msgstr "Ezin izan da scripta exekutatu:"
#: editor/editor_run_script.cpp
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
-msgstr ""
+msgstr "Hautatu inportatu nahi dituzun nodoak"
#: editor/editor_sub_scene.cpp editor/project_manager.cpp
msgid "Browse"
-msgstr ""
+msgstr "Arakatu"
#: editor/editor_sub_scene.cpp
msgid "Scene Path:"
-msgstr ""
+msgstr "Eszenaren bidea:"
#: editor/editor_sub_scene.cpp
msgid "Import From Node:"
-msgstr ""
+msgstr "Inportatu nodotik:"
#: editor/export_template_manager.cpp
msgid "Redownload"
-msgstr ""
+msgstr "Berriro jaitsi"
#: editor/export_template_manager.cpp
msgid "Uninstall"
-msgstr ""
+msgstr "Desinstalatu"
#: editor/export_template_manager.cpp
msgid "(Installed)"
-msgstr ""
+msgstr "(Instalatuta)"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Download"
-msgstr ""
+msgstr "Jaitsi"
#: editor/export_template_manager.cpp
msgid "Official export templates aren't available for development builds."
@@ -3261,11 +3260,11 @@ msgstr ""
#: editor/export_template_manager.cpp
msgid "(Missing)"
-msgstr ""
+msgstr "(Falta da)"
#: editor/export_template_manager.cpp
msgid "(Current)"
-msgstr ""
+msgstr "(Unekoa)"
#: editor/export_template_manager.cpp
msgid "Retrieving mirrors, please wait..."
@@ -3312,6 +3311,8 @@ msgid ""
"No download links found for this version. Direct download is only available "
"for official releases."
msgstr ""
+"Ez da bertsio hau jaisteko estekarik aurkitu. Deskarga zuzena bertsio "
+"ofizialentzat besterik ez dago."
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
@@ -3343,7 +3344,7 @@ msgstr ""
#: editor/export_template_manager.cpp
msgid "Download Complete."
-msgstr ""
+msgstr "Jaitsiera osatuta."
#: editor/export_template_manager.cpp
msgid "Cannot remove temporary file:"
@@ -3395,11 +3396,11 @@ msgstr ""
#: editor/export_template_manager.cpp
msgid "Downloading"
-msgstr ""
+msgstr "Jaisten"
#: editor/export_template_manager.cpp
msgid "Connection Error"
-msgstr ""
+msgstr "Konexio-errorea"
#: editor/export_template_manager.cpp
msgid "SSL Handshake Error"
@@ -3411,35 +3412,35 @@ msgstr ""
#: editor/export_template_manager.cpp
msgid "Current Version:"
-msgstr ""
+msgstr "Uneko bertsioa:"
#: editor/export_template_manager.cpp
msgid "Installed Versions:"
-msgstr ""
+msgstr "Instalatutako bertsioak:"
#: editor/export_template_manager.cpp
msgid "Install From File"
-msgstr ""
+msgstr "Instalatu fitxategitik"
#: editor/export_template_manager.cpp
msgid "Remove Template"
-msgstr ""
+msgstr "Kendu txantiloia"
#: editor/export_template_manager.cpp
msgid "Select Template File"
-msgstr ""
+msgstr "Hautatu txantiloi fitxategia"
#: editor/export_template_manager.cpp
msgid "Godot Export Templates"
-msgstr ""
+msgstr "Godot esportazio-txantiloiak"
#: editor/export_template_manager.cpp
msgid "Export Template Manager"
-msgstr ""
+msgstr "Esportazio-txantiloi kudeatzailea"
#: editor/export_template_manager.cpp
msgid "Download Templates"
-msgstr ""
+msgstr "Jaitsi txantiloiak"
#: editor/export_template_manager.cpp
msgid "Select mirror from list: (Shift+Click: Open in Browser)"
@@ -3584,7 +3585,7 @@ msgstr ""
#: editor/filesystem_dock.cpp
msgid "Next Folder/File"
-msgstr ""
+msgstr "Hurrengo karpeta/fitxategia"
#: editor/filesystem_dock.cpp
msgid "Re-Scan Filesystem"
@@ -3596,17 +3597,19 @@ msgstr ""
#: editor/filesystem_dock.cpp
msgid "Search files"
-msgstr ""
+msgstr "Bilatu fitxategiak"
#: editor/filesystem_dock.cpp
msgid ""
"Scanning Files,\n"
"Please Wait..."
msgstr ""
+"Fitxategiak arakatzen,\n"
+"Itxaron mesedez..."
#: editor/filesystem_dock.cpp
msgid "Move"
-msgstr ""
+msgstr "Mugitu"
#: editor/filesystem_dock.cpp
msgid "There is already file or folder with the same name in this location."
@@ -3806,12 +3809,16 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
#: editor/import_dock.cpp
msgid "%d Files"
-msgstr ""
+msgstr "%d fitxategi"
#: editor/import_dock.cpp
msgid "Set as Default for '%s'"
@@ -3835,7 +3842,7 @@ msgstr ""
#: editor/import_dock.cpp
msgid "Save Scenes, Re-Import, and Restart"
-msgstr ""
+msgstr "Gorde eszenak, berriro inportatu eta berrabiarazi"
#: editor/import_dock.cpp
msgid "Changing the type of an imported file requires editor restart."
@@ -3845,6 +3852,8 @@ msgstr ""
msgid ""
"WARNING: Assets exist that use this resource, they may stop loading properly."
msgstr ""
+"ABISUA: Baliabide hau darabiltzaten aktiboak daude, kargatzeari utzi "
+"liezaiokete."
#: editor/inspector_dock.cpp
msgid "Failed to load resource."
@@ -4040,7 +4049,7 @@ msgstr ""
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Add Animation Point"
-msgstr ""
+msgstr "Gehitu animazio puntua"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Remove BlendSpace1D Point"
@@ -4072,7 +4081,7 @@ msgstr ""
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp
msgid "Enable snap and show grid."
-msgstr ""
+msgstr "Gaitu atxikitzea eta erakutsi sareta."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4247,7 +4256,7 @@ msgstr ""
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "Enable Filtering"
-msgstr ""
+msgstr "Gaitu iragazkia"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Toggle Autoplay"
@@ -4255,38 +4264,38 @@ msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "New Animation Name:"
-msgstr ""
+msgstr "Animazio berriaren izena:"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "New Anim"
-msgstr ""
+msgstr "Animazio berria"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Change Animation Name:"
-msgstr ""
+msgstr "Aldatu animazioaren izena:"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Delete Animation?"
-msgstr ""
+msgstr "Ezabatu animazioa?"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Remove Animation"
-msgstr ""
+msgstr "Kendu animazioa"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Invalid animation name!"
-msgstr ""
+msgstr "Animazio izen baliogabea!"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Animation name already exists!"
-msgstr ""
+msgstr "Animazio izena existitzen da jada!"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Rename Animation"
-msgstr ""
+msgstr "Aldatu izena animazioari"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Blend Next Changed"
@@ -4298,31 +4307,31 @@ msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Load Animation"
-msgstr ""
+msgstr "Kargatu animazioa"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Duplicate Animation"
-msgstr ""
+msgstr "Bikoiztu animazioa"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "No animation to copy!"
-msgstr ""
+msgstr "Ez dago animaziorik kopiatzeko!"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "No animation resource on clipboard!"
-msgstr ""
+msgstr "Ez dago animazio baliabiderik arbelean!"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Pasted Animation"
-msgstr ""
+msgstr "Itsatsitako animazioa"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Paste Animation"
-msgstr ""
+msgstr "Itsatsi animazioa"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "No animation to edit!"
-msgstr ""
+msgstr "Ez dago animaziorik editatzeko!"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Play selected animation backwards from current pos. (A)"
@@ -4662,7 +4671,7 @@ msgstr ""
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend4 Node"
-msgstr ""
+msgstr "Blend4 nodoa"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "TimeScale Node"
@@ -4674,51 +4683,51 @@ msgstr ""
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Transition Node"
-msgstr ""
+msgstr "Trantsizio nodoa"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Import Animations..."
-msgstr ""
+msgstr "Inportatu animazioak..."
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Edit Node Filters"
-msgstr ""
+msgstr "Editatu nodo-iragazkiak"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Filters..."
-msgstr ""
+msgstr "Iragazkiak..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Contents:"
-msgstr ""
+msgstr "Edukiak:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "View Files"
-msgstr ""
+msgstr "Ikusi fitxategiak"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Connection error, please try again."
-msgstr ""
+msgstr "Konexio errorea, saiatu berriro."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't connect to host:"
-msgstr ""
+msgstr "Ezin da ostalariarekin konektatu:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "No response from host:"
-msgstr ""
+msgstr "Ostalariaren erantzunik ez:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't resolve hostname:"
-msgstr ""
+msgstr "Ezin duzu ostalariaren izena ebatzi:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Request failed, return code:"
-msgstr ""
+msgstr "Eskaerak huts egin du, itzulera-kodea:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Request failed."
-msgstr ""
+msgstr "Eskaerak huts egin du."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Cannot save response to:"
@@ -4746,7 +4755,7 @@ msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Bad download hash, assuming file has been tampered with."
-msgstr ""
+msgstr "Jaitsiera hash okerra, fitxategia aldatua izan delakoan."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Expected:"
@@ -4762,15 +4771,15 @@ msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Asset Download Error:"
-msgstr ""
+msgstr "Aktiboaren jaitsiera errorea:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Downloading (%s / %s)..."
-msgstr ""
+msgstr "Jaisten (%s / %s)"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Downloading..."
-msgstr ""
+msgstr "Jaisten..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Resolving..."
@@ -4794,11 +4803,11 @@ msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Download Error"
-msgstr ""
+msgstr "Jaitsiera errorea"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Download for this asset is already in progress!"
-msgstr ""
+msgstr "Aktibo honen jaitsiera abian da jada!"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Recently Updated"
@@ -4887,7 +4896,7 @@ msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Assets ZIP File"
-msgstr ""
+msgstr "Aktiboen ZIP fitxategia"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
msgid ""
@@ -4917,7 +4926,7 @@ msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Configure Snap"
-msgstr ""
+msgstr "Konfiguratu atxikitzea"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Grid Offset:"
@@ -5222,72 +5231,72 @@ msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Toggle smart snapping."
-msgstr ""
+msgstr "Txandakatu atxikitze adimentsua."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Smart Snap"
-msgstr ""
+msgstr "Erabili atxikitze adimentsua"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Toggle grid snapping."
-msgstr ""
+msgstr "Txandakatu saretara atxikitzea."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Grid Snap"
-msgstr ""
+msgstr "Erabili saretara atxikitzea"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snapping Options"
-msgstr ""
+msgstr "Atxikitze aukerak"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Rotation Snap"
-msgstr ""
+msgstr "Erabili biraketa atxikitzea"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Scale Snap"
-msgstr ""
+msgstr "Erabili eskala atxikitzea"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap Relative"
-msgstr ""
+msgstr "Atxikitze erlatiboa"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Pixel Snap"
-msgstr ""
+msgstr "Erabili pixel atxikitzea"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Smart Snapping"
-msgstr ""
+msgstr "Atxikitze adimentsua"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Configure Snap..."
-msgstr ""
+msgstr "Konfiguratu atxikitzea..."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap to Parent"
-msgstr ""
+msgstr "Atxikitu gurasora"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap to Node Anchor"
-msgstr ""
+msgstr "Atxikitu nodoaren aingurara"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap to Node Sides"
-msgstr ""
+msgstr "Atxikitu nodoaren ertzetara"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap to Node Center"
-msgstr ""
+msgstr "Atxikitu nodoaren zentrora"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap to Other Nodes"
-msgstr ""
+msgstr "Atxikitu beste nodoetara"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap to Guides"
-msgstr ""
+msgstr "Atxikitu gidalerroetara"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -6298,11 +6307,11 @@ msgstr ""
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Snap"
-msgstr ""
+msgstr "Atxikitu"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Enable Snap"
-msgstr ""
+msgstr "Gaitu atxikitzea"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid"
@@ -6416,7 +6425,7 @@ msgstr ""
#: editor/plugins/script_editor_plugin.cpp
msgid "Error while saving theme."
-msgstr ""
+msgstr "Errorea azala gordetzean."
#: editor/plugins/script_editor_plugin.cpp
msgid "Error Saving"
@@ -6424,7 +6433,7 @@ msgstr ""
#: editor/plugins/script_editor_plugin.cpp
msgid "Error importing theme."
-msgstr ""
+msgstr "Errorea azala inportatzean."
#: editor/plugins/script_editor_plugin.cpp
msgid "Error Importing"
@@ -6461,11 +6470,11 @@ msgstr ""
#: editor/plugins/script_editor_plugin.cpp
msgid "Import Theme"
-msgstr ""
+msgstr "Inportatu azala"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error while saving theme"
-msgstr ""
+msgstr "Errorea azala gordetzean"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error saving"
@@ -6473,7 +6482,7 @@ msgstr ""
#: editor/plugins/script_editor_plugin.cpp
msgid "Save Theme As..."
-msgstr ""
+msgstr "Gorde azala honela..."
#: editor/plugins/script_editor_plugin.cpp
msgid "%s Class Reference"
@@ -6560,19 +6569,19 @@ msgstr ""
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Theme"
-msgstr ""
+msgstr "Azala"
#: editor/plugins/script_editor_plugin.cpp
msgid "Import Theme..."
-msgstr ""
+msgstr "Inportatu azala..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Reload Theme"
-msgstr ""
+msgstr "Birkargatu azala"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save Theme"
-msgstr ""
+msgstr "Gorde azala"
#: editor/plugins/script_editor_plugin.cpp
msgid "Close All"
@@ -6677,11 +6686,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7151,12 +7160,21 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
-msgid "Snap Nodes To Floor"
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid "Snap Nodes To Floor"
+msgstr "Atxikitu nodoak lurrera"
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Couldn't find a solid floor to snap the selection to."
-msgstr ""
+msgstr "Ez da hautapena atxikitzeko lur trinkorik aurkitu."
#: editor/plugins/spatial_editor_plugin.cpp
msgid ""
@@ -7171,7 +7189,7 @@ msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Use Snap"
-msgstr ""
+msgstr "Erabili atxikitzea"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Bottom View"
@@ -7224,7 +7242,7 @@ msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Object to Floor"
-msgstr ""
+msgstr "Atxikitu objektua lurrera"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Transform Dialog..."
@@ -7273,19 +7291,19 @@ msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Settings"
-msgstr ""
+msgstr "Atxikitze ezarpenak"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Translate Snap:"
-msgstr ""
+msgstr "Translazio atzikitzea:"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rotate Snap (deg.):"
-msgstr ""
+msgstr "Biratze atxikitzea (graduak):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Scale Snap (%):"
-msgstr ""
+msgstr "Eskala atxikitzea (%):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Viewport Settings"
@@ -7553,7 +7571,7 @@ msgstr ""
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Snap Mode:"
-msgstr ""
+msgstr "Atxikitze modua:"
#: editor/plugins/texture_region_editor_plugin.cpp
#: scene/resources/visual_shader.cpp
@@ -7562,11 +7580,11 @@ msgstr ""
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Pixel Snap"
-msgstr ""
+msgstr "Pixel atxikitzea"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Grid Snap"
-msgstr ""
+msgstr "Sareta atxikitzea"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Auto Slice"
@@ -7598,19 +7616,19 @@ msgstr ""
#: editor/plugins/theme_editor_plugin.cpp
msgid "Remove All Items"
-msgstr ""
+msgstr "Kendu elementu guztiak"
#: editor/plugins/theme_editor_plugin.cpp editor/project_manager.cpp
msgid "Remove All"
-msgstr ""
+msgstr "Kendu guztiak"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Edit Theme"
-msgstr ""
+msgstr "Editatu azala"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Theme editing menu."
-msgstr ""
+msgstr "Azalaren edizio menua."
#: editor/plugins/theme_editor_plugin.cpp
msgid "Add Class Items"
@@ -7630,7 +7648,7 @@ msgstr ""
#: editor/plugins/theme_editor_plugin.cpp
msgid "Create From Current Editor Theme"
-msgstr ""
+msgstr "Sortu editorearen uneko azaletik"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Toggle Button"
@@ -7739,7 +7757,7 @@ msgstr ""
#: editor/plugins/theme_editor_plugin.cpp
msgid "Theme File"
-msgstr ""
+msgstr "Azal fitxategia"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Erase Selection"
@@ -7963,6 +7981,7 @@ msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Enable snap and show grid (configurable via the Inspector)."
msgstr ""
+"Gaitu atxikitzea eta erakutsi sareta (Inspektorearen bidez konfiguragarria)."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Display Tile Names (Hold Alt Key)"
@@ -9149,7 +9168,7 @@ msgstr ""
#: editor/project_export.cpp
msgid "Features"
-msgstr ""
+msgstr "Ezaugarriak"
#: editor/project_export.cpp
msgid "Custom (comma-separated):"
@@ -9157,11 +9176,11 @@ msgstr ""
#: editor/project_export.cpp
msgid "Feature List:"
-msgstr ""
+msgstr "Ezaugarri zerrenda:"
#: editor/project_export.cpp
msgid "Script"
-msgstr ""
+msgstr "Scripta"
#: editor/project_export.cpp
msgid "Script Export Mode:"
@@ -9169,11 +9188,11 @@ msgstr ""
#: editor/project_export.cpp
msgid "Text"
-msgstr ""
+msgstr "Testua"
#: editor/project_export.cpp
msgid "Compiled"
-msgstr ""
+msgstr "Konpilatuta"
#: editor/project_export.cpp
msgid "Encrypted (Provide Key Below)"
@@ -9229,7 +9248,7 @@ msgstr ""
#: editor/project_manager.cpp
msgid "Error opening package file (it's not in ZIP format)."
-msgstr ""
+msgstr "Errorea pakete fitxategia irekitzean (ez dago ZIP formatuan)."
#: editor/project_manager.cpp
msgid ""
@@ -9242,7 +9261,7 @@ msgstr ""
#: editor/project_manager.cpp
msgid "Please choose a \"project.godot\" or \".zip\" file."
-msgstr ""
+msgstr "Aukeratu \"project.godot\" edo \".zip\" fitxategia."
#: editor/project_manager.cpp
msgid "This directory already contains a Godot project."
@@ -9425,6 +9444,8 @@ msgid ""
"Can't run project: Assets need to be imported.\n"
"Please edit the project to trigger the initial import."
msgstr ""
+"Ezin da proiektua exekutatu: Aktiboak inportatu behar dira.\n"
+"Editatu proiektua hasierako inportazioa abiatzeko."
#: editor/project_manager.cpp
msgid "Are you sure to run %d projects at once?"
@@ -9505,6 +9526,8 @@ msgid ""
"You currently don't have any projects.\n"
"Would you like to explore official example projects in the Asset Library?"
msgstr ""
+"Orain ez duzu proiekturik.\n"
+"Adibide ofizialak arakatu nahi dituzu aktiboen liburutegian?"
#: editor/project_manager.cpp
msgid ""
@@ -9899,7 +9922,7 @@ msgstr ""
#: editor/rename_dialog.cpp
msgid "Use Regular Expressions"
-msgstr ""
+msgstr "Erabili adierazpen erregularrak"
#: editor/rename_dialog.cpp
msgid "Advanced Options"
@@ -9975,7 +9998,7 @@ msgstr ""
#: editor/rename_dialog.cpp
msgid "PascalCase to snake_case"
-msgstr ""
+msgstr "PascalCase snake_case-ra"
#: editor/rename_dialog.cpp
msgid "snake_case to PascalCase"
@@ -9999,7 +10022,7 @@ msgstr ""
#: editor/rename_dialog.cpp
msgid "Regular Expression Error"
-msgstr ""
+msgstr "Adierazpen erregularraren errorea"
#: editor/rename_dialog.cpp
msgid "At character %s"
@@ -10068,8 +10091,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Scripta"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10226,6 +10250,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10272,11 +10303,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10396,6 +10427,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10436,6 +10471,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -10445,7 +10484,7 @@ msgstr ""
#: editor/script_create_dialog.cpp
msgid "Script path/name is valid."
-msgstr ""
+msgstr "Scriptaren bidea/izena baliozkoa da."
#: editor/script_create_dialog.cpp
msgid "Allowed: a-z, A-Z, 0-9, _ and ."
@@ -10472,6 +10511,8 @@ msgid ""
"Note: Built-in scripts have some limitations and can't be edited using an "
"external editor."
msgstr ""
+"Oharra: Inkorporatutako gidoiek muga batzuk dituzte eta ezin dira editatu "
+"kanpoko editore batekin."
#: editor/script_create_dialog.cpp
msgid "Class Name:"
@@ -10595,7 +10636,7 @@ msgstr ""
#: editor/script_editor_debugger.cpp
msgid "Export list to a CSV file"
-msgstr ""
+msgstr "Esportatu zerrenda CSV fitxategi batera"
#: editor/script_editor_debugger.cpp
msgid "Resource Path"
@@ -10871,7 +10912,7 @@ msgstr ""
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Snap View"
-msgstr ""
+msgstr "Atxikitu ikuspegia"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clip Disabled"
@@ -11460,6 +11501,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11483,6 +11528,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/fa.po b/editor/translations/fa.po
index 2754720d3b..3f94d1112b 100644
--- a/editor/translations/fa.po
+++ b/editor/translations/fa.po
@@ -871,7 +871,6 @@ msgstr "اتصال سیگنال:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1503,18 +1502,9 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "مسیر نامعتبر."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "پرونده موجود نیست."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "در مسیر٠منبع نیست."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2493,11 +2483,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "باز کردن صحنه"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2773,10 +2766,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3413,6 +3402,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "انتخاب گره (ها) برای وارد شدن"
@@ -4045,6 +4038,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -7088,15 +7085,15 @@ msgid ""
msgstr "'s%' را از 's%' جدا کن"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "خط:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "اÙزودن وظیÙÙ‡"
@@ -7593,6 +7590,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10691,8 +10697,8 @@ msgstr "ارث‌بری صحنهٔ Ùرزند"
#: editor/scene_tree_dock.cpp
#, fuzzy
-msgid "Clear Script"
-msgstr "صحنه جدید"
+msgid "Detach Script"
+msgstr "پیوست کردن اسکریپت"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10861,6 +10867,13 @@ msgid "Open Documentation"
msgstr "شمارش ها"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "اÙزودن گره Ùرزند"
@@ -10910,11 +10923,13 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "پیوست کردن یک اسکریپت جدید یا از پیش موجود برای گره انتخابی."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "حذ٠یک اسکریپت برای گره انتخابی."
#: editor/scene_tree_dock.cpp
@@ -11043,6 +11058,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "پرونده موجود نیست."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "باید از یک پسوند معتبر استÙاده شود."
@@ -11091,6 +11110,11 @@ msgstr "Ùایل وجود دارد، آیا بازنویسی شود؟"
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "مسیر نامعتبر."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "نام نامعتبر."
@@ -12200,6 +12224,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12224,6 +12252,32 @@ msgstr "نام نامعتبر."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12952,6 +13006,13 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "در مسیر٠منبع نیست."
+
+#, fuzzy
+#~ msgid "Clear Script"
+#~ msgstr "صحنه جدید"
+
#~ msgid "Replaced %d occurrence(s)."
#~ msgstr "تعداد d% رخداد جایگزین شد."
diff --git a/editor/translations/fi.po b/editor/translations/fi.po
index 6695783866..a95c65be41 100644
--- a/editor/translations/fi.po
+++ b/editor/translations/fi.po
@@ -15,7 +15,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-01 11:42+0000\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
"Last-Translator: Tapani Niemi <tapani.niemi@kapsi.fi>\n"
"Language-Team: Finnish <https://hosted.weblate.org/projects/godot-engine/"
"godot/fi/>\n"
@@ -24,7 +24,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -839,7 +839,6 @@ msgstr "Ei voida yhdistää signaalia"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1453,17 +1452,9 @@ msgstr "Ota käyttöön"
msgid "Rearrange Autoloads"
msgstr "Järjestele uudelleen automaattiset lataukset"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Virheellinen polku."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Tiedostoa ei ole olemassa."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ei löytynyt resurssipolusta."
+msgid "Can't add autoload:"
+msgstr "Ei voida lisätä automaattisesti ladattavaa:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1579,8 +1570,8 @@ msgid ""
"Enable 'Import Etc' in Project Settings, or disable 'Driver Fallback "
"Enabled'."
msgstr ""
-"GLES2 vara-ajuri tarvitsee kohdealustalla 'ETC' tekstuuripakkausta. Kytke "
-"'Import Etc' päälle projektin asetuksista tai poista 'Driver Fallback "
+"GLES2 vara-ajuri tarvitsee kohdealustalla 'ETC' tekstuuripakkausta.\n"
+"Kytke 'Import Etc' päälle projektin asetuksista tai poista 'Driver Fallback "
"Enabled' asetus."
#: editor/editor_export.cpp platform/android/export/export.cpp
@@ -1970,7 +1961,7 @@ msgstr "Teeman ominaisuudet"
#: editor/editor_help.cpp
msgid "Enumerations"
-msgstr "Enumeraatiot"
+msgstr "Luetteloinnit"
#: editor/editor_help.cpp
msgid "Constants"
@@ -2421,12 +2412,17 @@ msgid "Can't reload a scene that was never saved."
msgstr "Ei voida ladata uudelleen skeneä, jota ei ole koskaan tallennettu."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Palauta"
+msgid "Reload Saved Scene"
+msgstr "Avaa uudelleen tallennettu skene"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Tätä toimintoa ei voida peruttaa. Palauta joka tapauksessa?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"Nykyisessä skenessä on tallentamattomia muutoksia.\n"
+"Avataanko tallennettu skene uudelleen siitä huolimatta? Tätä toimintoa ei "
+"voi perua."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2708,10 +2704,6 @@ msgid "Redo"
msgstr "Tee uudelleen"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Palauta skene"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Sekalaiset projekti- tai skenetyökalut."
@@ -3357,6 +3349,12 @@ msgstr "Skriptiä ei voitu suorittaa:"
msgid "Did you forget the '_run' method?"
msgstr "Unohditko '_run' metodin?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Pidä Ctrl pohjassa pyöristääksesi kokonaislukuun. Pidä Shift pohjassa "
+"tarkempia muutoksia varten."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Valitse tuotavat solmut"
@@ -3953,6 +3951,11 @@ msgid "Error running post-import script:"
msgstr "Virhe ajettaessa tuonnin jälkeistä skriptiä:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+"Palautitko Node-solmusta periytyvän objektin `post_import()` metodissa?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Tallennetaan..."
@@ -6905,12 +6908,12 @@ msgstr ""
"Yhdistetty metodi '%s' signaalille '%s' puuttuu solmusta '%s' solmuun '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Rivi"
+msgid "[Ignore]"
+msgstr "[Sivuuta]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(sivuuta)"
+msgid "Line"
+msgstr "Rivi"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7384,6 +7387,21 @@ msgid "XForm Dialog"
msgstr "XForm-ikkuna"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Napsauta vaihtaaksesi näkyvyystilojen välillä.\n"
+"\n"
+"Avoin silmä: muokkain on näkyvissä.\n"
+"Suljettu silmä: muokkain on piilotettu.\n"
+"Puoliavoin silmä: muokkain on näkyvissä myös läpikuultamattomien pintojen "
+"läpi (\"röntgen\")."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Tarraa solmut lattiaan"
@@ -8795,7 +8813,7 @@ msgstr "E-vakio (2.718282). Kuvastaa luonnollisen logaritmin kantalukua."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Epsilon constant (0.00001). Smallest possible scalar number."
-msgstr "Epsilon-vakio (0.00001). Pienin mahdollinen skaalariluku."
+msgstr "Epsilon-vakio (0.00001). Pienin mahdollinen skaalariluku."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Phi constant (1.618034). Golden ratio."
@@ -9277,7 +9295,7 @@ msgid ""
"direction of camera (pass associated inputs to it)."
msgstr ""
"Palauttaa valovähentymän perustuen pinnan normaalivektorin ja kameran "
-"suuntavektorin pistetuloon (välitä nämä syötteinä)."
+"suuntavektorin pistetuloon (välitä sille liittyvät syötteet)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -10468,8 +10486,8 @@ msgid "Instance Child Scene"
msgstr "Luo aliskenen ilmentymä"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Poista skripti"
+msgid "Detach Script"
+msgstr "Irrota skripti"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10637,6 +10655,16 @@ msgid "Open Documentation"
msgstr "Avaa dokumentaatio"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"Ei voida liittää skriptiä: yhtään kieltä ei ole rekisteröity.\n"
+"Tämä johtuu luultavasti siitä, että editori on käännetty ilman yhtäkään "
+"kielimoduulia."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Lisää alisolmu"
@@ -10685,12 +10713,12 @@ msgstr ""
"juurisolmua ei ole olemassa."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr "Liitä uusi tai olemassa oleva skripti valitulle solmulle."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Poista skripti valitulta solmulta."
+msgid "Detach the script from the selected node."
+msgstr "Irrota skripti valitusta solmusta."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10821,6 +10849,10 @@ msgid "A directory with the same name exists."
msgstr "Samanniminen hakemisto on jo olemassa."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Tiedostoa ei ole olemassa."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Virheellinen tiedostopääte."
@@ -10861,6 +10893,10 @@ msgid "File exists, it will be reused."
msgstr "Tiedosto on jo olemassa, se käytetään uudelleen."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Virheellinen polku."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Virheellinen luokan nimi."
@@ -11910,6 +11946,10 @@ msgstr ""
"Debug keystore ei ole määritettynä editorin asetuksissa eikä esiasetuksissa."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr "Release keystore on konfiguroitu väärin viennin esiasetuksissa."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Mukautettu käännös edellyttää kelvollista Android SDK -polkua editorin "
@@ -11939,6 +11979,42 @@ msgstr "Virheellinen paketin nimi:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"\"android/modules\" projektiasetukseen on liitetty virheellinen "
+"\"GodotPaymentV3\" moduuli (muuttunut Godotin versiossa 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+"\"Use Custom Build\" asetuksen täytyy olla päällä, jotta liittännäisiä voi "
+"käyttää."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"\"Degrees Of Freedom\" on käyttökelpoinen ainoastaan kun \"Xr Mode\" asetus "
+"on \"Oculus Mobile VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Hand Tracking\" on käyttökelpoinen ainoastaan kun \"Xr Mode\" asetus on "
+"\"Oculus Mobile VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Focus Awareness\" on käyttökelpoinen ainoastaan kun \"Xr Mode\" asetus on "
+"\"Oculus Mobile VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12669,8 +12745,8 @@ msgid ""
"Default Environment as specified in Project Settings (Rendering -> "
"Environment -> Default Environment) could not be loaded."
msgstr ""
-"Projektin asetuksissa määriteltyä oletusympäristöä (Rendering -> "
-"Environment -> Default Environment) ei voitu ladata."
+"Projektin asetuksissa määriteltyä oletusympäristöä (Rendering -> Environment "
+"-> Default Environment) ei voitu ladata."
#: scene/main/viewport.cpp
msgid ""
@@ -12717,6 +12793,21 @@ msgstr "Varying tyypin voi sijoittaa vain vertex-funktiossa."
msgid "Constants cannot be modified."
msgstr "Vakioita ei voi muokata."
+#~ msgid "Not in resource path."
+#~ msgstr "Ei löytynyt resurssipolusta."
+
+#~ msgid "Revert"
+#~ msgstr "Palauta"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Tätä toimintoa ei voida peruttaa. Palauta joka tapauksessa?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Palauta skene"
+
+#~ msgid "Clear Script"
+#~ msgstr "Poista skripti"
+
#~ msgid "Issue Tracker"
#~ msgstr "Ilmoita viasta"
diff --git a/editor/translations/fil.po b/editor/translations/fil.po
index 32405930ea..920b91a30c 100644
--- a/editor/translations/fil.po
+++ b/editor/translations/fil.po
@@ -822,7 +822,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1422,16 +1421,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2352,11 +2343,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2622,10 +2615,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3233,6 +3222,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3817,6 +3810,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6693,11 +6690,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7167,6 +7164,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10087,7 +10093,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10245,6 +10251,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10291,11 +10304,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10415,6 +10428,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10455,6 +10472,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11484,6 +11505,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11507,6 +11532,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/fr.po b/editor/translations/fr.po
index bb371b7674..fac3b9b84b 100644
--- a/editor/translations/fr.po
+++ b/editor/translations/fr.po
@@ -42,7 +42,7 @@
# Xananax <xananax@yelostudio.com>, 2017-2018.
# Perrier Mathis <mathis.perrier73@gmail.com>, 2018.
# Ewan Lehnebach <ewan.lehnebach@gmail.com>, 2018.
-# Hugo Locurcio <hugo.locurcio@hugo.pro>, 2018, 2019.
+# Hugo Locurcio <hugo.locurcio@hugo.pro>, 2018, 2019, 2020.
# Grigore Antoniuc <grisa181@gmail.com>, 2018.
# x2f <x.defoy@gmail.com>, 2018.
# LittleWhite <lw.demoscene@googlemail.com>, 2018.
@@ -72,12 +72,15 @@
# Pierre Caye <pierrecaye@laposte.net>, 2020.
# Kevin Bouancheau <kevin.bouancheau@gmail.com>, 2020.
# LaurentOngaro <laurent@gameamea.com>, 2020.
+# Julien Humbert <julroy67@gmail.com>, 2020.
+# Nathan <bonnemainsnathan@gmail.com>, 2020.
+# Léo Vincent <l009.vincent@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-05 14:01+0000\n"
-"Last-Translator: Anonymous <noreply@weblate.org>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: Nathan <bonnemainsnathan@gmail.com>\n"
"Language-Team: French <https://hosted.weblate.org/projects/godot-engine/"
"godot/fr/>\n"
"Language: fr\n"
@@ -101,7 +104,7 @@ msgstr "Une chaîne de caractères de longueur 1 est attendue (un caractère)."
#: modules/mono/glue/gd_glue.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr "Pas assez d'octets pour le décodage, ou format non valide."
+msgstr "Pas assez d’octets pour le décodage, ou format non valide."
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
@@ -109,7 +112,7 @@ msgstr "Entrée non valide %i (non transmise) dans l’expression"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr "self ne peut être utilisé car l'instance est nulle (non passée)"
+msgstr "self ne peut être utilisé car l’instance est nulle (non transmise)"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
@@ -129,7 +132,7 @@ msgstr "Arguments invalides pour construire '%s'"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr "Lors de l'appel à '%s' :"
+msgstr "Lors de l’appel à '%s' :"
#: core/ustring.cpp
msgid "B"
@@ -201,60 +204,60 @@ msgstr "Déplacer des points de Bézier"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
-msgstr "Dupliquer les clés d'animation"
+msgstr "Dupliquer les clés d’animation"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Delete Keys"
-msgstr "Supprimer les clés d'animation"
+msgstr "Supprimer les clés d’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Time"
-msgstr "Modifier le temps de l'image-clé"
+msgstr "Modifier le temps de l’image-clé"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transition"
-msgstr "Changer la transition de l'animation"
+msgstr "Changer la transition de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transform"
-msgstr "Changer la transformation de l'animation"
+msgstr "Changer la transformation de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Value"
-msgstr "Changer la valeur de l'image-clé de l'animation"
+msgstr "Changer la valeur de l’image-clé de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Change Call"
-msgstr "Changer l'appel de l'animation"
+msgstr "Changer l’appel de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Keyframe Time"
-msgstr "Modification du temps de l'image-clé"
+msgstr "Modification du temps de l’image-clé"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Transition"
-msgstr "Changer la transition de l'animation"
+msgstr "Changer la transition de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Transform"
-msgstr "Changer le Transform de l'animation"
+msgstr "Changer le Transform de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Keyframe Value"
-msgstr "Changer la valeur de l'image-clé de l'animation"
+msgstr "Changer la valeur de l’image-clé de l’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Call"
-msgstr "Changer l'appel de l'animation"
+msgstr "Changer l’appel de l’animation"
#: editor/animation_track_editor.cpp
msgid "Change Animation Length"
-msgstr "Modifier la durée de l'animation"
+msgstr "Modifier la durée de l’animation"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation Loop"
-msgstr "Changer la boucle d'animation"
+msgstr "Changer la boucle d’animation"
#: editor/animation_track_editor.cpp
msgid "Property Track"
@@ -266,7 +269,7 @@ msgstr "Piste de transformation 3D"
#: editor/animation_track_editor.cpp
msgid "Call Method Track"
-msgstr "Piste d'appel de méthode"
+msgstr "Piste d’appel de méthode"
#: editor/animation_track_editor.cpp
msgid "Bezier Curve Track"
@@ -278,15 +281,15 @@ msgstr "Piste de lecture audio"
#: editor/animation_track_editor.cpp
msgid "Animation Playback Track"
-msgstr "Piste de lecture d'animation"
+msgstr "Piste de lecture d’animation"
#: editor/animation_track_editor.cpp
msgid "Animation length (frames)"
-msgstr "Durée de l'animation (en images)"
+msgstr "Durée de l’animation (en images)"
#: editor/animation_track_editor.cpp
msgid "Animation length (seconds)"
-msgstr "Durée de l'animation (en secondes)"
+msgstr "Durée de l’animation (en secondes)"
#: editor/animation_track_editor.cpp
msgid "Add Track"
@@ -294,7 +297,7 @@ msgstr "Ajouter une piste"
#: editor/animation_track_editor.cpp
msgid "Animation Looping"
-msgstr "Bouclage de l'animation"
+msgstr "Bouclage de l’animation"
#: editor/animation_track_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
@@ -307,7 +310,7 @@ msgstr "Clips audio :"
#: editor/animation_track_editor.cpp
msgid "Anim Clips:"
-msgstr "Clips d'animation :"
+msgstr "Clips d’animation :"
#: editor/animation_track_editor.cpp
msgid "Change Track Path"
@@ -323,7 +326,7 @@ msgstr "Mode de mise à jour (comment cette propriété est définie)"
#: editor/animation_track_editor.cpp
msgid "Interpolation Mode"
-msgstr "Mode d'interpolation"
+msgstr "Mode d’interpolation"
#: editor/animation_track_editor.cpp
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
@@ -335,7 +338,7 @@ msgstr "Supprime cette piste."
#: editor/animation_track_editor.cpp
msgid "Time (s): "
-msgstr "Temps (s): "
+msgstr "Temps (s) : "
#: editor/animation_track_editor.cpp
msgid "Toggle Track Enabled"
@@ -372,11 +375,11 @@ msgstr "Cubique"
#: editor/animation_track_editor.cpp
msgid "Clamp Loop Interp"
-msgstr "Limiter l'interpolation de la boucle"
+msgstr "Limiter l’interpolation de la boucle"
#: editor/animation_track_editor.cpp
msgid "Wrap Loop Interp"
-msgstr "Envelopper l'interp. de la boucle"
+msgstr "Envelopper l’interp. de la boucle"
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
@@ -393,19 +396,19 @@ msgstr "Supprimer clé(s)"
#: editor/animation_track_editor.cpp
msgid "Change Animation Update Mode"
-msgstr "Modifier le mode de mise à jour de l'animation"
+msgstr "Modifier le mode de mise à jour de l’animation"
#: editor/animation_track_editor.cpp
msgid "Change Animation Interpolation Mode"
-msgstr "Modifier le mode d'interpolation de l'animation"
+msgstr "Modifier le mode d’interpolation de l’animation"
#: editor/animation_track_editor.cpp
msgid "Change Animation Loop Mode"
-msgstr "Modifier le mode de boucle d'animation"
+msgstr "Modifier le mode de boucle d’animation"
#: editor/animation_track_editor.cpp
msgid "Remove Anim Track"
-msgstr "Supprimer la piste d'animation"
+msgstr "Supprimer la piste d’animation"
#: editor/animation_track_editor.cpp
msgid "Create NEW track for %s and insert key?"
@@ -434,7 +437,7 @@ msgstr "Insérer une animation"
#: editor/animation_track_editor.cpp
msgid "AnimationPlayer can't animate itself, only other players."
msgstr ""
-"Un AnimationPlayer ne peut s'animer lui-même, seulement les autres lecteurs."
+"Un AnimationPlayer ne peut s’animer lui-même, seulement les autres lecteurs."
#: editor/animation_track_editor.cpp
msgid "Anim Create & Insert"
@@ -442,15 +445,15 @@ msgstr "Créer et insérer une animation"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Track & Key"
-msgstr "Insérer une piste et clé d'animation"
+msgstr "Insérer une piste et clé d’animation"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Key"
-msgstr "Insérer une clé d'animation"
+msgstr "Insérer une clé d’animation"
#: editor/animation_track_editor.cpp
msgid "Change Animation Step"
-msgstr "Modifier l'étape d'animation"
+msgstr "Modifier l’étape d’animation"
#: editor/animation_track_editor.cpp
msgid "Rearrange Tracks"
@@ -459,7 +462,7 @@ msgstr "Réorganiser les pistes"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
msgstr ""
-"Les pistes de transformation ne s'appliquent qu'aux nœuds basés sur Spatial."
+"Les pistes de transformation ne s’appliquent qu’aux nœuds basés sur Spatial."
#: editor/animation_track_editor.cpp
msgid ""
@@ -476,17 +479,17 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Animation tracks can only point to AnimationPlayer nodes."
msgstr ""
-"Les pistes d'animation ne peuvent pointer que sur des nœuds AnimationPlayer."
+"Les pistes d’animation ne peuvent pointer que sur des nœuds AnimationPlayer."
#: editor/animation_track_editor.cpp
msgid "An animation player can't animate itself, only other players."
msgstr ""
-"Un lecteur d'animation ne peut s'animer lui-même, seulement les autres "
+"Un lecteur d’animation ne peut s’animer lui-même, seulement les autres "
"lecteurs."
#: editor/animation_track_editor.cpp
msgid "Not possible to add a new track without a root"
-msgstr "Impossible d'ajouter une nouvelle piste sans racine"
+msgstr "Impossible d’ajouter une nouvelle piste sans racine"
#: editor/animation_track_editor.cpp
msgid "Invalid track for Bezier (no suitable sub-properties)"
@@ -498,11 +501,11 @@ msgstr "Ajouter une piste de Bézier"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a key."
-msgstr "Le chemin de la piste est invalide, impossible d'ajouter une clé."
+msgstr "Le chemin de la piste est invalide, impossible d’ajouter une clé."
#: editor/animation_track_editor.cpp
msgid "Track is not of type Spatial, can't insert key"
-msgstr "La piste n'est pas de type Spatial, impossible d'insérer une clé"
+msgstr "La piste n’est pas de type Spatial, impossible d’insérer une clé"
#: editor/animation_track_editor.cpp
msgid "Add Transform Track Key"
@@ -515,7 +518,7 @@ msgstr "Ajoutez une clé de piste"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a method key."
msgstr ""
-"Le chemin de la piste est invalide, impossible d'ajouter une clé d'appel de "
+"Le chemin de la piste est invalide, impossible d’ajouter une clé d’appel de "
"méthode."
#: editor/animation_track_editor.cpp
@@ -524,11 +527,11 @@ msgstr "Ajouter une clé de méthode"
#: editor/animation_track_editor.cpp
msgid "Method not found in object: "
-msgstr "Méthode introuvable dans l'objet : "
+msgstr "Méthode introuvable dans l’objet : "
#: editor/animation_track_editor.cpp
msgid "Anim Move Keys"
-msgstr "Déplacer les clés d'animation"
+msgstr "Déplacer les clés d’animation"
#: editor/animation_track_editor.cpp
msgid "Clipboard is empty"
@@ -540,14 +543,14 @@ msgstr "Coller pistes"
#: editor/animation_track_editor.cpp
msgid "Anim Scale Keys"
-msgstr "Mettre à l'échelle les clés d'animation"
+msgstr "Mettre à l’échelle les clés d’animation"
#: editor/animation_track_editor.cpp
msgid ""
"This option does not work for Bezier editing, as it's only a single track."
msgstr ""
-"Cette option ne fonctionne pas pour l'édition de courbes de Bézier car il ne "
-"s'agit que d'une seule piste."
+"Cette option ne fonctionne pas pour l’édition de courbes de Bézier car il ne "
+"s’agit que d’une seule piste."
#: editor/animation_track_editor.cpp
msgid ""
@@ -564,16 +567,16 @@ msgstr ""
"Cette animation appartient à une scène importée, donc les changements "
"apportés aux pistes importées ne seront pas sauvegardés.\n"
"\n"
-"Pour activer la possibilité d'ajouter des pistes personnalisées, naviguez "
-"dans les paramètres d'importation de la scène et définissez\n"
+"Pour activer la possibilité d’ajouter des pistes personnalisées, naviguez "
+"dans les paramètres d’importation de la scène et définissez\n"
"\"Animation > Stockage\" à \"Fichiers\", activez \"Animation > Garder Pistes "
"Courantes\" puis ré-importez.\n"
-"Alternativement, utilise un préréglage d'import qui importe les animations "
+"Alternativement, utilise un préréglage d’import qui importe les animations "
"dans des fichiers différents."
#: editor/animation_track_editor.cpp
msgid "Warning: Editing imported animation"
-msgstr "Avertissement : Édition d'une animation importée"
+msgstr "Avertissement : Édition d’une animation importée"
#: editor/animation_track_editor.cpp
msgid "Select an AnimationPlayer node to create and edit animations."
@@ -584,7 +587,7 @@ msgstr ""
msgid "Only show tracks from nodes selected in tree."
msgstr ""
"Afficher seulement les pistes provenant des nœuds sélectionnés dans "
-"l'arborescence."
+"l’arborescence."
#: editor/animation_track_editor.cpp
msgid "Group tracks by node or display them as plain list."
@@ -914,7 +917,6 @@ msgstr "Impossible de connecter le signal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1528,17 +1530,9 @@ msgstr "Activer"
msgid "Rearrange Autoloads"
msgstr "Ré-organiser les AutoLoads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Chemin invalide."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Le fichier n'existe pas."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Pas dans le chemin de la ressource."
+msgid "Can't add autoload:"
+msgstr "Impossible d'ajouter le chargement automatique :"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1766,7 +1760,7 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Error saving profile to path: '%s'."
-msgstr "Erreur lors de l'enregistrement du profil au chemin: '%s'."
+msgstr "Erreur lors de l'enregistrement du profil au chemin : « %s »."
#: editor/editor_feature_profile.cpp
msgid "Unset"
@@ -1898,7 +1892,7 @@ msgstr "Enregistrer un fichier"
#: editor/editor_file_dialog.cpp
msgid "Go Back"
-msgstr "Retour"
+msgstr "Retourner"
#: editor/editor_file_dialog.cpp
msgid "Go Forward"
@@ -1950,7 +1944,7 @@ msgstr "Rafraîchir les fichiers."
#: editor/editor_file_dialog.cpp
msgid "(Un)favorite current folder."
-msgstr "Ajouter ou supprimer des favoris le dossier courant."
+msgstr "Ajouter ou supprimer aux favoris le dossier courant."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Toggle the visibility of hidden files."
@@ -2126,7 +2120,7 @@ msgstr "Type de membre"
#: editor/editor_help_search.cpp
msgid "Class"
-msgstr "Classe :"
+msgstr "Classe"
#: editor/editor_help_search.cpp
msgid "Method"
@@ -2502,12 +2496,16 @@ msgid "Can't reload a scene that was never saved."
msgstr "Impossible de recharger une scène qui n'a jamais été sauvegardée."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Réinitialiser"
+msgid "Reload Saved Scene"
+msgstr "Recharger la scène sauvegardée"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Cette action ne peut être annulée. Réinitialiser quand même ?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"La scène actuelle contient des changements non sauvegardés.\n"
+"Recharger la scène quand même ? Cette action ne peut pas être annulée."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2806,10 +2804,6 @@ msgid "Redo"
msgstr "Refaire"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Réinitialiser la scène"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Outils divers liés au projet ou à la scène."
@@ -3461,6 +3455,12 @@ msgstr "Impossible d'exécuter le script :"
msgid "Did you forget the '_run' method?"
msgstr "Avez-vous oublié la méthode « _run » ?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Maintenir Ctrl pour arrondir à l'entier. Maintenir Maj pour des changements "
+"plus précis."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Sélectionner les nœuds à importer"
@@ -4063,6 +4063,11 @@ msgid "Error running post-import script:"
msgstr "Erreur d'exécution du script de post-importation :"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+"Avez-vous renvoyé un objet dérivé de Node dans la méthode `post_import()` ?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Enregistrement…"
@@ -4092,7 +4097,7 @@ msgstr "Réimporter"
#: editor/import_dock.cpp
msgid "Save Scenes, Re-Import, and Restart"
-msgstr "Sauvegarder les scènes, Réimporter, et Redémarrer"
+msgstr "Enregistrer les scènes, réimporter, puis redémarrer"
#: editor/import_dock.cpp
msgid "Changing the type of an imported file requires editor restart."
@@ -5039,7 +5044,7 @@ msgstr "Attendu :"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Got:"
-msgstr "A:"
+msgstr "A :"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Failed sha256 hash check"
@@ -6078,7 +6083,7 @@ msgstr ""
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Single Convex Collision Sibling"
-msgstr "Créer une unique collision convexe sœur"
+msgstr "Créer une seule collision convexe sœur"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
@@ -6091,7 +6096,7 @@ msgstr ""
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Multiple Convex Collision Siblings"
-msgstr "Créer une collision convexe multiple sœur(s)"
+msgstr "Créer plusieurs collisions convexes sœurs"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
@@ -6114,7 +6119,7 @@ msgid ""
msgstr ""
"Crée un maillage de contour statique. Le maillage de contour verra ses "
"normales inversées automatiquement.\n"
-"Cela peut être utilisé à la place de la propriété SpatialMaterial Grow "
+"Cela peut être utilisé à la place de la propriété Grow de SpatialMaterial "
"lorsque l'utilisation de cette propriété n'est pas possible."
#: editor/plugins/mesh_instance_editor_plugin.cpp
@@ -6341,7 +6346,7 @@ msgstr "Volume"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Emission Source: "
-msgstr "Source d'Émission: "
+msgstr "Source d'émission : "
#: editor/plugins/particles_editor_plugin.cpp
msgid "A processor material of type 'ParticlesMaterial' is required."
@@ -7037,12 +7042,12 @@ msgstr ""
"nœud '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Ligne"
+msgid "[Ignore]"
+msgstr "[Ignorer]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorer)"
+msgid "Line"
+msgstr "Ligne"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7412,7 +7417,7 @@ msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Auto Orthogonal Enabled"
-msgstr "Auto Orthogonal Activé"
+msgstr "Vue orthogonale automatique"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Lock View Rotation"
@@ -7520,6 +7525,21 @@ msgid "XForm Dialog"
msgstr "Dialogue XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Cliquez pour modifier l'état de visibilité.\n"
+"\n"
+"Å’il ouvert : Gizmo est visible.\n"
+"Œil fermé : Gizmo est masqué.\n"
+"Œil entrouvert : Gizmo est également visible à travers les surfaces opaques "
+"(« rayon x »)."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Aligner les nœuds avec le sol"
@@ -7759,7 +7779,7 @@ msgstr "Convertir en Mesh2D"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Invalid geometry, can't create polygon."
-msgstr "Géométrie invalide, impossible de créer le polygone."
+msgstr "Géométrie invalide, impossible de créer le polygone."
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Convert to Polygon2D"
@@ -9640,7 +9660,7 @@ msgstr "Fonctionnalités"
#: editor/project_export.cpp
msgid "Custom (comma-separated):"
-msgstr "Personnalisé (séparé par des virgules) :"
+msgstr "Personnalisé (séparé par des virgules) :"
#: editor/project_export.cpp
msgid "Feature List:"
@@ -9998,7 +10018,7 @@ msgid ""
msgstr ""
"Êtes vous certain de vouloir scanner %s dossiers à la recherche de projets "
"Godot existants ?\n"
-"Cela pourrait prendre prendre un moment."
+"Cela pourrait prendre un moment."
#: editor/project_manager.cpp
msgid "Project Manager"
@@ -10056,7 +10076,7 @@ msgid ""
msgstr ""
"La barre de recherche filtre les projets par leur nom et la dernière partie "
"de leur chemin d'accès.\n"
-"Pour filter les projects par leur nom et le chemin d'accès complet, la "
+"Pour filtrer les projets par leur nom et le chemin d'accès complet, la "
"recherche doit inclure au moins un caractère `/`."
#: editor/project_settings_editor.cpp
@@ -10553,11 +10573,11 @@ msgstr "Réinitialiser"
#: editor/rename_dialog.cpp
msgid "Regular Expression Error"
-msgstr "Erreur d'expression régulière"
+msgstr "Erreur dans l'expression régulière"
#: editor/rename_dialog.cpp
msgid "At character %s"
-msgstr "À caractère %s"
+msgstr "Au caractère %s"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
msgid "Reparent Node"
@@ -10624,8 +10644,8 @@ msgid "Instance Child Scene"
msgstr "Instancier une scène enfant"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Supprimer le script"
+msgid "Detach Script"
+msgstr "Détacher le script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10791,6 +10811,16 @@ msgid "Open Documentation"
msgstr "Ouvrir la documentation"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"Impossible de joindre un script : aucune langue n'est enregistrée.\n"
+"C'est probablement parce que cet éditeur a été construit avec tous les "
+"modules de langue désactivés."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Ajouter un nœud enfant"
@@ -10839,12 +10869,12 @@ msgstr ""
"nœud racine n'existe."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr "Attacher un script (nouveau ou existant) pour le nœud sélectionné."
+msgid "Attach a new or existing script to the selected node."
+msgstr "Attacher un nouveau script ou un script existant au nœud sélectionné."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Effacer un script pour le nœud sélectionné."
+msgid "Detach the script from the selected node."
+msgstr "Détacher le script du nœud sélectionné."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10975,6 +11005,10 @@ msgid "A directory with the same name exists."
msgstr "Un dossier du même nom existe déjà."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Le fichier n'existe pas."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Extension invalide."
@@ -11015,6 +11049,10 @@ msgid "File exists, it will be reused."
msgstr "Le fichier existe, il sera réutilisé."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Chemin invalide."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nom de classe invalide."
@@ -11124,7 +11162,7 @@ msgstr "Copier l'erreur"
#: editor/script_editor_debugger.cpp
msgid "Video RAM"
-msgstr "Vidéo RAM"
+msgstr "Mémoire vidéo"
#: editor/script_editor_debugger.cpp
msgid "Skip Breakpoints"
@@ -11177,7 +11215,7 @@ msgstr "Total :"
#: editor/script_editor_debugger.cpp
msgid "Export list to a CSV file"
-msgstr "Exporter la liste en fichier CSV"
+msgstr "Exporter la liste vers un fichier CSV"
#: editor/script_editor_debugger.cpp
msgid "Resource Path"
@@ -11365,7 +11403,7 @@ msgstr "Bibliothèque"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Libraries: "
-msgstr "Bibliothèques: "
+msgstr "Bibliothèques : "
#: modules/gdnative/register_types.cpp
msgid "GDNative"
@@ -11525,7 +11563,7 @@ msgstr "Remplir la sélection"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "GridMap Settings"
-msgstr "Paramètres GridMap"
+msgstr "Paramètres GridMap"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Pick Distance:"
@@ -11634,7 +11672,7 @@ msgstr ""
#: modules/visual_script/visual_script.cpp
msgid "Node returned an invalid sequence output: "
-msgstr "Le nœud a retourné une séquence de sortie invalide: "
+msgstr "Le nœud a retourné une séquence de sortie invalide : "
#: modules/visual_script/visual_script.cpp
msgid "Found sequence bit but not the node in the stack, report bug!"
@@ -11644,7 +11682,7 @@ msgstr ""
#: modules/visual_script/visual_script.cpp
msgid "Stack overflow with stack depth: "
-msgstr "Débordement de pile avec profondeur de pile: "
+msgstr "Débordement de pile avec profondeur de pile : "
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Signal Arguments"
@@ -11959,7 +11997,7 @@ msgstr "Modifier le membre"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Input type not iterable: "
-msgstr "Type d'entrée non itérable: "
+msgstr "Type d'entrée non itérable : "
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Iterator became invalid"
@@ -11967,7 +12005,7 @@ msgstr "L'itérateur est devenu invalide"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Iterator became invalid: "
-msgstr "L'itérateur est devenu invalide: "
+msgstr "L'itérateur est devenu invalide : "
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Invalid index property name."
@@ -11987,19 +12025,19 @@ msgstr "Nom de propriété invalide « %s » dans le nœud %s."
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid argument of type: "
-msgstr ": Argument invalide de type: "
+msgstr ": Argument invalide de type : "
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid arguments: "
-msgstr ": Arguments invalides: "
+msgstr ": Arguments invalides : "
#: modules/visual_script/visual_script_nodes.cpp
msgid "VariableGet not found in script: "
-msgstr "VariableGet introuvable dans le script: "
+msgstr "VariableGet introuvable dans le script : "
#: modules/visual_script/visual_script_nodes.cpp
msgid "VariableSet not found in script: "
-msgstr "VariableSet introuvable dans le script: "
+msgstr "VariableSet introuvable dans le script : "
#: modules/visual_script/visual_script_nodes.cpp
msgid "Custom node has no _step() method, can't process graph."
@@ -12076,6 +12114,12 @@ msgstr ""
"dans le préréglage."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"La clé de version n'est pas configurée correctement dans le préréglage "
+"d'exportation."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"La création d'une version personnalisée nécessite un chemin d'accès Android "
@@ -12105,6 +12149,40 @@ msgstr "Nom de paquet invalide :"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"Module \"GodotPaymentV3\" invalide inclus dans le paramétrage du projet "
+"\"android/modules\" (modifié dans Godot 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr "« Use Custom Build » doit être activé pour utiliser les plugins."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"« Degrés de liberté » est valide uniquement lorsque le « Mode Xr » est « "
+"Oculus Mobile VR »."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"« Suivi de la main » est valide uniquement lorsque le « Mode Xr » est « "
+"Oculus Mobile VR »."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"« Sensibilité de la mise au point » est valide uniquement lorsque le « Mode "
+"Xr » est « Oculus Mobile VR »."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12414,9 +12492,9 @@ msgid ""
"by the physics engine when running.\n"
"Change the size in children collision shapes instead."
msgstr ""
-"Les changements de taille pour RigidBody2D (en mode caractère ou rigide) "
-"seront remplacés par le moteur physique lors de l'exécution. Modifiez la "
-"taille des formes de collision enfants à la place."
+"Les modifications de taille pour RigidBody2D (en mode caractère ou rigide) "
+"seront remplacées par le moteur physique lors de l'exécution. \n"
+"Modifiez la taille des formes de collision enfant à la place."
#: scene/2d/remote_transform_2d.cpp
msgid "Path property must point to a valid Node2D node to work."
@@ -12497,7 +12575,7 @@ msgstr "%d%%"
#: scene/3d/baked_lightmap.cpp
msgid "(Time Left: %d:%02d s)"
-msgstr "(Temps restant: %d:%02d s)"
+msgstr "(Temps restant : %d:%02d s)"
#: scene/3d/baked_lightmap.cpp
msgid "Plotting Meshes: "
@@ -12661,9 +12739,9 @@ msgid ""
"by the physics engine when running.\n"
"Change the size in children collision shapes instead."
msgstr ""
-"Les changements de taille pour RigidBody (dans les modes caractère ou "
-"rigide) seront remplacés par le moteur physique lors de l'exécution. "
-"Modifiez la taille dans les formes de collision enfants à la place."
+"Les modifications de taille pour RigidBody (dans les modes caractère ou "
+"rigide) seront remplacées par le moteur physique lors de l'exécution.\n"
+"Modifiez la taille dans les formes de collision enfant à la place."
#: scene/3d/remote_transform.cpp
msgid ""
@@ -12912,6 +12990,21 @@ msgstr "Les variations ne peuvent être affectées que dans la fonction vertex."
msgid "Constants cannot be modified."
msgstr "Les constantes ne peuvent être modifiées."
+#~ msgid "Not in resource path."
+#~ msgstr "Pas dans le chemin de la ressource."
+
+#~ msgid "Revert"
+#~ msgstr "Réinitialiser"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Cette action ne peut être annulée. Réinitialiser quand même ?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Réinitialiser la scène"
+
+#~ msgid "Clear Script"
+#~ msgstr "Supprimer le script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Traqueur de problèmes"
diff --git a/editor/translations/ga.po b/editor/translations/ga.po
index 7b271f6a77..b9e6ba69c6 100644
--- a/editor/translations/ga.po
+++ b/editor/translations/ga.po
@@ -2,11 +2,11 @@
# Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
# This file is distributed under the same license as the Godot source code.
-# Rónán Quill <ronan085@gmail.com>, 2019.
+# Rónán Quill <ronan085@gmail.com>, 2019, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
-"PO-Revision-Date: 2019-08-04 14:22+0000\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
"Last-Translator: Rónán Quill <ronan085@gmail.com>\n"
"Language-Team: Irish <https://hosted.weblate.org/projects/godot-engine/godot/"
"ga/>\n"
@@ -15,7 +15,7 @@ msgstr ""
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=5; plural=n==1 ? 0 : n==2 ? 1 : (n>2 && n<7) ? 2 :"
"(n>6 && n<11) ? 3 : 4;\n"
-"X-Generator: Weblate 3.8-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -91,7 +91,7 @@ msgstr ""
#: editor/animation_bezier_editor.cpp
msgid "Free"
-msgstr ""
+msgstr "Saor"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
@@ -815,7 +815,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1416,16 +1415,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2346,11 +2337,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Cruthaigh"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2616,10 +2610,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3225,6 +3215,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3811,6 +3805,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6686,11 +6684,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7160,6 +7158,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10082,7 +10089,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10240,6 +10247,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10286,11 +10300,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10410,6 +10424,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10450,6 +10468,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11481,6 +11503,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11504,6 +11530,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/he.po b/editor/translations/he.po
index 69d8bcc3b5..56126249dc 100644
--- a/editor/translations/he.po
+++ b/editor/translations/he.po
@@ -12,12 +12,14 @@
# MordechaiHadad <Mordechai.hadad01@gmail.com>, 2019.
# Daniel <danielharush5252@gmail.com>, 2020.
# test test <ugbdvwpeikvyzwaadt@awdrt.org>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
+# Daniel Kariv <danielkariv98@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-05 14:01+0000\n"
-"Last-Translator: Yaron Shahrabani <sh.yaron@gmail.com>\n"
+"PO-Revision-Date: 2020-05-07 21:28+0000\n"
+"Last-Translator: Anonymous <noreply@weblate.org>\n"
"Language-Team: Hebrew <https://hosted.weblate.org/projects/godot-engine/"
"godot/he/>\n"
"Language: he\n"
@@ -49,7 +51,7 @@ msgstr "קלט שגוי %I (×œ× ×”×•×¢×‘×¨) בתוך הביטוי"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr ""
+msgstr "×œ× × ×™×ª×Ÿ להשתמש ב־self כיוון שהמופע ×”×•× ×פס (null - ×œ× ×”×•×¢×‘×¨)"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
@@ -60,51 +62,48 @@ msgid "Invalid index of type %s for base type %s"
msgstr "×©× ×ž×פיין ×”×ינדקס מסוג %s עבור בסיס %s שגוי"
#: core/math/expression.cpp
-#, fuzzy
msgid "Invalid named index '%s' for base type %s"
msgstr "×©× ×ינדקס ×œ× ×ª×§×™×Ÿ '%s' לסוג בסיס '%s'"
#: core/math/expression.cpp
-#, fuzzy
msgid "Invalid arguments to construct '%s'"
-msgstr ": ×רגומנט שגוי מסוג: "
+msgstr "×¤×¨×ž×˜×¨×™× ×©×’×•×™×™× ×œ×‘× ×™×™×ª 's%'"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr ""
+msgstr "בקרי××” ל־‚%s’:"
#: core/ustring.cpp
msgid "B"
-msgstr ""
+msgstr "ב׳"
#: core/ustring.cpp
msgid "KiB"
-msgstr ""
+msgstr "KiB"
#: core/ustring.cpp
msgid "MiB"
-msgstr ""
+msgstr "MiB"
#: core/ustring.cpp
msgid "GiB"
-msgstr ""
+msgstr "GiB"
#: core/ustring.cpp
msgid "TiB"
-msgstr ""
+msgstr "TiB"
#: core/ustring.cpp
msgid "PiB"
-msgstr ""
+msgstr "PiB"
#: core/ustring.cpp
msgid "EiB"
-msgstr ""
+msgstr "EiB"
#: editor/animation_bezier_editor.cpp
-#, fuzzy
msgid "Free"
-msgstr "×—×™× ×"
+msgstr "חופשי"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
@@ -143,62 +142,52 @@ msgid "Move Bezier Points"
msgstr "הזזת נקודות בזייה"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Duplicate Keys"
msgstr "שכפול מפתחות הנפשה"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Delete Keys"
msgstr "מחיקת מפתחות הנפשה"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Change Keyframe Time"
msgstr "שינוי זמן פריי×-מפתח ×נימציה"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Change Transition"
-msgstr "שינוי ×ž×™×§×•× ×נימציה"
+msgstr "החלפת הנפשת ×פקט החלפה"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transform"
-msgstr "שינוי ×ž×™×§×•× ×נימציה"
+msgstr "החלפת הנפשת ×פקט שינוי צורה"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Change Keyframe Value"
-msgstr "שינוי ערך ×§×™×¤×¨×™×™× ×נימציה"
+msgstr "שינוי ערך פריי×-מפתח ×נימציה"
#: editor/animation_track_editor.cpp
msgid "Anim Change Call"
-msgstr ""
+msgstr "שינוי קרי×ת ×נימציה"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Keyframe Time"
-msgstr "שינוי זמן פריי×-מפתח ×נימציה"
+msgstr "שינוי זמן פריי×-מפתח ×נימציה רבי×"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Transition"
-msgstr "שינוי ×ž×™×§×•× ×נימציה"
+msgstr "שינוי מיקומי ×נימציה רבי×"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Transform"
-msgstr "שינוי ×ž×™×§×•× ×נימציה"
+msgstr "שינוי מיקומי ×נימציה רבי×"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Keyframe Value"
-msgstr "שינוי ערך ×§×™×¤×¨×™×™× ×נימציה"
+msgstr "שינוי ערכי פריי×-מפתח ×נימציה רבי×"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Call"
-msgstr "שינוי ×ž×™×§×•× ×נימציה"
+msgstr "שינוי ×ž×™×§×•×ž×™× ×נימציה רבי×"
#: editor/animation_track_editor.cpp
msgid "Change Animation Length"
@@ -206,16 +195,14 @@ msgstr "שנה ×ורך ×נימציה"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Change Animation Loop"
-msgstr "שינוי לופ ×נימציה"
+msgstr "שינוי לול×ת ×נימציה"
#: editor/animation_track_editor.cpp
msgid "Property Track"
msgstr "רצועת מ×פיין"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "3D Transform Track"
msgstr "רצועת שינוי 3D"
@@ -229,12 +216,10 @@ msgid "Bezier Curve Track"
msgstr "רצועת ×¢×§×•× ×‘×–×™×™×”"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Audio Playback Track"
msgstr "רצועת שמע"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation Playback Track"
msgstr "רצועת הנפשה"
@@ -243,7 +228,6 @@ msgid "Animation length (frames)"
msgstr "משך ההנפשה (פריימי×)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (seconds)"
msgstr "משך ההנפשה (שניות)"
@@ -252,7 +236,6 @@ msgid "Add Track"
msgstr "הוספת רצועה"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation Looping"
msgstr "לול×ת הנפשה"
@@ -262,19 +245,16 @@ msgid "Functions:"
msgstr "פונקציות:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Audio Clips:"
-msgstr "מ×זין לשמע"
+msgstr "רצועות שמע:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Clips:"
msgstr "קטעי הנפשה:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Track Path"
-msgstr "החלפת ערך רצועה"
+msgstr "החלפת נתיב רצועה"
#: editor/animation_track_editor.cpp
msgid "Toggle this track on/off."
@@ -286,7 +266,7 @@ msgstr "עדכן מצב (×יך המ×פיין ×”×–×” נקבע)"
#: editor/animation_track_editor.cpp
msgid "Interpolation Mode"
-msgstr ""
+msgstr "מצב ×ינתרפולציה"
#: editor/animation_track_editor.cpp
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
@@ -310,11 +290,11 @@ msgstr "מתמשך"
#: editor/animation_track_editor.cpp
msgid "Discrete"
-msgstr ""
+msgstr "בדיד"
#: editor/animation_track_editor.cpp
msgid "Trigger"
-msgstr ""
+msgstr "הדק/מפעיל"
#: editor/animation_track_editor.cpp
msgid "Capture"
@@ -435,14 +415,18 @@ msgid ""
"-AudioStreamPlayer2D\n"
"-AudioStreamPlayer3D"
msgstr ""
+"רצועת ×ודיו יכולה להצביע על חוליות מסוג:\n"
+"- AudioStreamPlayer\n"
+"- AudioStreamPlayer2D\n"
+"- AudioStreamPlayer3D"
#: editor/animation_track_editor.cpp
msgid "Animation tracks can only point to AnimationPlayer nodes."
-msgstr ""
+msgstr "רצועות הנפשה יכולות להצביע רק על ×יברי AnimationPlayer."
#: editor/animation_track_editor.cpp
msgid "An animation player can't animate itself, only other players."
-msgstr ""
+msgstr "נגן הנפשה ×ינו יכול להנפיש ×ת עצמו, רק ×©×—×§× ×™× ×חרי×."
#: editor/animation_track_editor.cpp
msgid "Not possible to add a new track without a root"
@@ -758,7 +742,7 @@ msgstr "בחירה בלבד"
#: editor/code_editor.cpp editor/plugins/script_text_editor.cpp
#: editor/plugins/text_editor.cpp
msgid "Standard"
-msgstr ""
+msgstr "רגיל"
#: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp
msgid "Toggle Scripts Panel"
@@ -877,7 +861,6 @@ msgstr "שגי×ת חיבור"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1497,18 +1480,9 @@ msgstr "הפעלה"
msgid "Rearrange Autoloads"
msgstr "סידור טעינות ×וטומטית מחדש"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "נתיב שגוי."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "הקובץ ×œ× ×§×™×™×."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "×œ× ×‘× ×ª×™×‘ המש×ב."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2493,12 +2467,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "×œ× × ×™×ª×Ÿ לרענן סצנה ×©×ž×¢×•×œ× ×œ× × ×©×ž×¨×”."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "שחזור"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "שמירת סצנה"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "×œ× × ×™×ª×Ÿ לבטל פעולה זו. לשחזר בכל ×–×ת?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2773,10 +2750,6 @@ msgid "Redo"
msgstr "ביצוע חוזר"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "שחזור סצנה"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "×›×œ×™× ×©×•× ×™× ×œ×ž×™×–× ×ו למגוון סצנות."
@@ -3413,6 +3386,10 @@ msgstr "×œ× × ×™×ª×Ÿ להריץ ×ת הסקריפט:"
msgid "Did you forget the '_run' method?"
msgstr "שכחת ×ת השיטה ‚‎_run’?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "× × ×œ×‘×—×•×¨ ×ž×¤×¨×§×™× ×œ×™×™×¦×•×"
@@ -4040,6 +4017,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "שמירה…"
@@ -7071,15 +7052,15 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "שורה:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "מעבר לפונקציה…"
@@ -7573,6 +7554,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10651,8 +10641,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "יצירת סקריפט"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10819,6 +10810,13 @@ msgid "Open Documentation"
msgstr "פתיחת התיעוד המקוון של Godot"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10869,11 +10867,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -11003,6 +11001,10 @@ msgid "A directory with the same name exists."
msgstr "כבר ×§×™×™×ž×™× ×§×•×‘×¥ ×ו תיקייה ×‘×©× ×”×–×”."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "הקובץ ×œ× ×§×™×™×."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "יש להשתמש בסיומת תקנית."
@@ -11047,6 +11049,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "נתיב שגוי."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "×©× ×©×’×•×™."
@@ -12118,6 +12125,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12142,6 +12153,32 @@ msgstr "×©× ×©×’×•×™."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12801,6 +12838,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "×œ× ×‘× ×ª×™×‘ המש×ב."
+
+#~ msgid "Revert"
+#~ msgstr "שחזור"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "×œ× × ×™×ª×Ÿ לבטל פעולה זו. לשחזר בכל ×–×ת?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "שחזור סצנה"
+
#~ msgid "Issue Tracker"
#~ msgstr "עוקב תקלות"
diff --git a/editor/translations/hi.po b/editor/translations/hi.po
index 12cf8fd242..4782afecb0 100644
--- a/editor/translations/hi.po
+++ b/editor/translations/hi.po
@@ -837,7 +837,6 @@ msgstr "इशारा कनेकà¥à¤Ÿ नहीं कर सकते"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1446,17 +1445,9 @@ msgstr "सकà¥à¤°à¤¿à¤¯ करे"
msgid "Rearrange Autoloads"
msgstr "औटोलोड पà¥à¤¨à¤°à¥à¤µà¥à¤¯à¤µà¤¸à¥à¤¥à¤¿à¤¤ करें"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "अमानà¥à¤¯ रासà¥à¤¤à¤¾à¥¤"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "फ़ाइल नहीं मौजूद."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "रेसोरà¥à¤¸ पाथ में नहीं."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2403,12 +2394,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "à¤à¤• दृशà¥à¤¯ है कि कभी नहीं बचाया गया था फिर से लोड नहीं कर सकते ।"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "वापस लौटना"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "दृशà¥à¤¯ बचाओ"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "इस कारà¥à¤°à¤µà¤¾à¤ˆ को पूरà¥à¤µà¤µà¤¤ नहीं किया जा सकता । वैसे भी वापस?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2687,10 +2681,6 @@ msgid "Redo"
msgstr "दोहराà¤à¤"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "वापस दृशà¥à¤¯"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "विविध परियोजना या दृशà¥à¤¯-वà¥à¤¯à¤¾à¤ªà¥€ उपकरण।"
@@ -3329,6 +3319,10 @@ msgstr "सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ नहीं चला सका:"
msgid "Did you forget the '_run' method?"
msgstr "कà¥à¤¯à¤¾ आप '_run' विधि को भूल गà¤?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "आयात करने के लिठनोड (à¤à¤¸) का चयन करें"
@@ -3918,6 +3912,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6811,15 +6809,15 @@ msgid ""
msgstr "जà¥à¤¡à¤¿à¤¯à¥‡ '%s' to '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "रेखा:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "कारà¥à¤¯à¥‹à¤‚:"
@@ -7290,6 +7288,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10279,8 +10286,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "नई सà¥à¤•à¥à¤°à¤¿à¤ªà¥à¤Ÿ"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10442,6 +10450,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10490,11 +10505,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10617,6 +10632,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "फ़ाइल नहीं मौजूद."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "गलत फॉणà¥à¤Ÿ का आकार |"
@@ -10658,6 +10677,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "अमानà¥à¤¯ रासà¥à¤¤à¤¾à¥¤"
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid class name."
msgstr "गलत फॉणà¥à¤Ÿ का आकार |"
@@ -11710,6 +11733,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11734,6 +11761,32 @@ msgstr "गलत फॉणà¥à¤Ÿ का आकार |"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12385,6 +12438,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "रेसोरà¥à¤¸ पाथ में नहीं."
+
+#~ msgid "Revert"
+#~ msgstr "वापस लौटना"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "इस कारà¥à¤°à¤µà¤¾à¤ˆ को पूरà¥à¤µà¤µà¤¤ नहीं किया जा सकता । वैसे भी वापस?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "वापस दृशà¥à¤¯"
+
#~ msgid "Issue Tracker"
#~ msgstr "मà¥à¤¦à¥à¤¦à¤¾ पर नज़र रखने वाला"
diff --git a/editor/translations/hr.po b/editor/translations/hr.po
index 8627e7f239..ad095145b2 100644
--- a/editor/translations/hr.po
+++ b/editor/translations/hr.po
@@ -823,7 +823,6 @@ msgstr "Ne mogu spojiti signal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1431,16 +1430,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2363,11 +2354,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Stvori"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2633,10 +2627,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3245,6 +3235,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3830,6 +3824,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6719,11 +6717,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7193,6 +7191,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10129,8 +10136,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Spoji sa skriptom:"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10289,6 +10297,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10335,11 +10350,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10461,6 +10476,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10501,6 +10520,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11540,6 +11563,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11563,6 +11590,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/hu.po b/editor/translations/hu.po
index 620a2d4d5b..ef15f85977 100644
--- a/editor/translations/hu.po
+++ b/editor/translations/hu.po
@@ -878,7 +878,6 @@ msgstr "Csatlakoztató Jelzés:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1514,18 +1513,9 @@ msgstr "Engedélyezés"
msgid "Rearrange Autoloads"
msgstr "AutoLoad-ok Ãtrendezése"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Érvénytelen Elérési Út."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "A fájl nem létezik."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Nincs az erőforrás elérési útban."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2537,12 +2527,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Nem lehet újratölteni egy olyan jelenetet, amit soha nem mentett el."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Visszaállítás"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Scene mentés"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Ez a művelet nem vonható vissza. Visszaállítja mindenképp?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2845,10 +2838,6 @@ msgid "Redo"
msgstr "Mégis"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Scene visszaállítás"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Egyéb projekt- vagy Scene-szintű eszközök."
@@ -3507,6 +3496,10 @@ msgstr "Nem sikerült a szkript futtatása:"
msgid "Did you forget the '_run' method?"
msgstr "Nem felejtette el a '_run' metódust?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Válassza ki az importálandó Node-okat"
@@ -4141,6 +4134,10 @@ msgid "Error running post-import script:"
msgstr "Hiba történt az importálás utána szkript futtatásakor:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Mentés..."
@@ -7249,15 +7246,15 @@ msgid ""
msgstr "'%s' Lecsatlakoztatása '%s'-ról"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Sor:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Ugrás Funkcióra..."
@@ -7749,6 +7746,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "Rácshoz illesztés"
@@ -10844,8 +10850,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Szkript Létrehozása"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -11012,6 +11019,13 @@ msgid "Open Documentation"
msgstr "Godot online dokumentáció megnyitása"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -11062,12 +11076,13 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Detach the script from the selected node."
+msgstr "Kiválasztott Scene(k) példányosítása a kiválasztott Node gyermekeként."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -11196,6 +11211,10 @@ msgid "A directory with the same name exists."
msgstr "Egy fájl vagy mappa már létezik a megadott névvel."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "A fájl nem létezik."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Használjon érvényes kiterjesztést."
@@ -11240,6 +11259,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Érvénytelen Elérési Út."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Érvénytelen név."
@@ -12322,6 +12346,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12346,6 +12374,32 @@ msgstr "Érvénytelen név."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -13007,6 +13061,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Nincs az erőforrás elérési útban."
+
+#~ msgid "Revert"
+#~ msgstr "Visszaállítás"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Ez a művelet nem vonható vissza. Visszaállítja mindenképp?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Scene visszaállítás"
+
#~ msgid "Issue Tracker"
#~ msgstr "Problémakövető"
@@ -13210,10 +13276,6 @@ msgstr ""
#~ msgid "Insert keys."
#~ msgstr "Kulcsok Beszúrása"
-#~ msgid "Instance the selected scene(s) as child of the selected node."
-#~ msgstr ""
-#~ "Kiválasztott Scene(k) példányosítása a kiválasztott Node gyermekeként."
-
#, fuzzy
#~ msgid "Font Size:"
#~ msgstr "Körvonal Mérete:"
diff --git a/editor/translations/id.po b/editor/translations/id.po
index 54222d1aeb..f7a86197b6 100644
--- a/editor/translations/id.po
+++ b/editor/translations/id.po
@@ -30,8 +30,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-04-16 11:03+0000\n"
-"Last-Translator: Richard Urban <redasuio1@gmail.com>\n"
+"PO-Revision-Date: 2020-06-03 20:09+0000\n"
+"Last-Translator: Sofyan Sugianto <sofyanartem@gmail.com>\n"
"Language-Team: Indonesian <https://hosted.weblate.org/projects/godot-engine/"
"godot/id/>\n"
"Language: id\n"
@@ -39,7 +39,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.0.1-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -860,7 +860,6 @@ msgstr "Tidak dapat menghubungkan sinyal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -893,7 +892,7 @@ msgstr "Memutuskan semua dari sinyal '%s'"
#: editor/connections_dialog.cpp
msgid "Connect..."
-msgstr "Sambungkan..."
+msgstr "Hubungkan..."
#: editor/connections_dialog.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -914,7 +913,7 @@ msgstr "Anda yakin ingin menghapus semua hubungan dari sinyal '%s'?"
#: editor/connections_dialog.cpp editor/editor_help.cpp editor/node_dock.cpp
msgid "Signals"
-msgstr "Sinyal-sinyal"
+msgstr "Sinyal"
#: editor/connections_dialog.cpp
msgid "Are you sure you want to remove all connections from this signal?"
@@ -1471,17 +1470,9 @@ msgstr "Aktifkan"
msgid "Rearrange Autoloads"
msgstr "Mengatur kembali Autoload-autoload"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Path tidak valid."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "File tidak ada."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Tidak dalam lokasi resource."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1967,7 +1958,7 @@ msgstr "Tutorial Daring"
#: editor/editor_help.cpp
msgid "Properties"
-msgstr "Properti Objek"
+msgstr "Properti"
#: editor/editor_help.cpp
msgid "override:"
@@ -1979,11 +1970,11 @@ msgstr "baku:"
#: editor/editor_help.cpp
msgid "Methods"
-msgstr "Fungsi"
+msgstr "Method"
#: editor/editor_help.cpp
msgid "Theme Properties"
-msgstr "Properti-properti Tema"
+msgstr "Properti Tema"
#: editor/editor_help.cpp
msgid "Enumerations"
@@ -2011,7 +2002,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Method Descriptions"
-msgstr "Deskripsi Metode"
+msgstr "Deskripsi Method"
#: editor/editor_help.cpp
msgid ""
@@ -2440,12 +2431,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Tidak bisa memuat ulang skena yang belum pernah disimpan."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Pulihkan"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Simpan Skena"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Tindakan ini tidak dapat dibatalkan. Pulihkan saja?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2733,10 +2727,6 @@ msgid "Redo"
msgstr "Ulangi"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Kembalikan Skena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Perkakas macam-macam proyek atau lingkup skena."
@@ -2948,13 +2938,12 @@ msgid "Q&A"
msgstr "Tanya Jawab"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Report a Bug"
-msgstr "Impor ulang"
+msgstr "Laporkan Kutu"
#: editor/editor_node.cpp
msgid "Send Docs Feedback"
-msgstr ""
+msgstr "Kirim Tanggapan Dokumentasi"
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
msgid "Community"
@@ -3384,6 +3373,13 @@ msgstr "Tidak bisa menjalankan script:"
msgid "Did you forget the '_run' method?"
msgstr "Apakah anda lupa dengan fungsi '_run' ?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Tahan Ctrl untuk meletakkan Getter. Tahan Shift untuk meletakkan generic "
+"signature."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Pilih node untuk diimpor"
@@ -3978,6 +3974,10 @@ msgid "Error running post-import script:"
msgstr "Kesalahan saat menjalankan skrip post-import:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Menyimpan..."
@@ -4006,9 +4006,8 @@ msgid "Reimport"
msgstr "Impor ulang"
#: editor/import_dock.cpp
-#, fuzzy
msgid "Save Scenes, Re-Import, and Restart"
-msgstr "Simpan skena, impor ulang, dan mulai ulang"
+msgstr "Simpan Skena, Impor Ulang, dan Mulai Ulang"
#: editor/import_dock.cpp
msgid "Changing the type of an imported file requires editor restart."
@@ -6924,12 +6923,13 @@ msgstr ""
"'%s' ke node '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Baris"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(abaikan)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(abaikan)"
+msgid "Line"
+msgstr "Baris"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7297,9 +7297,8 @@ msgid "This operation requires a single selected node."
msgstr "Operasi ini membutuhkan satu node yang dipilih."
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Auto Orthogonal Enabled"
-msgstr "Ortogonal"
+msgstr "Ortogonal Otomatis Difungsikan"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Lock View Rotation"
@@ -7406,6 +7405,15 @@ msgid "XForm Dialog"
msgstr "Dialog XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Kancingkan Node ke Lantai"
@@ -9931,6 +9939,10 @@ msgid ""
"To filter projects by name and full path, the query must contain at least "
"one `/` character."
msgstr ""
+"Kotak filter pencarian proyek berdasarkan nama dan lokasi komponen "
+"terakhir.\n"
+"Untuk memfilter proyek berdasarkan nama dan lokasi penuhnya, kueri harus "
+"mengandung paling tidak satu karakter `/`."
#: editor/project_settings_editor.cpp
msgid "Key "
@@ -10497,8 +10509,9 @@ msgid "Instance Child Scene"
msgstr "Instansi Skena Anak"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Bersihkan Skrip"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Lampirkan Skrip"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10666,6 +10679,13 @@ msgid "Open Documentation"
msgstr "Buka Dokumentasi"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Tambah Node Anak"
@@ -10714,11 +10734,13 @@ msgstr ""
"akar."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Lampirkan skrip baru atau yang sudah ada untuk node yang dipilih."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Bersihkan skrip untuk node yang dipilih."
#: editor/scene_tree_dock.cpp
@@ -10850,6 +10872,10 @@ msgid "A directory with the same name exists."
msgstr "Sudah ada nama direktori seperti itu."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "File tidak ada."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Ekstensi tidak valid."
@@ -10890,6 +10916,10 @@ msgid "File exists, it will be reused."
msgstr "Berkas sudah ada, itu akan digunakan kembali."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Path tidak valid."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nama kelas tidak valid."
@@ -10926,6 +10956,8 @@ msgid ""
"Note: Built-in scripts have some limitations and can't be edited using an "
"external editor."
msgstr ""
+"Catatan: Skrip bawaan memiliki banyak keterbatasan dan tidak dapat disunting "
+"menggunakan editor eksternal."
#: editor/script_create_dialog.cpp
msgid "Class Name:"
@@ -11048,9 +11080,8 @@ msgid "Total:"
msgstr "Total:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Export list to a CSV file"
-msgstr "Ekspor Profil"
+msgstr "Ekspor daftar ke berkas CSV"
#: editor/script_editor_debugger.cpp
msgid "Resource Path"
@@ -11936,6 +11967,13 @@ msgstr ""
"prasetel proyek."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Berkas debug keystore belum dikonfigurasi dalam Pengaturan Editor maupun di "
+"prasetel proyek."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Membangun kustom APK memerlukan lokasi Android SDK yang valid dalam "
@@ -11965,6 +12003,32 @@ msgstr "Nama paket tidak valid:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12352,7 +12416,7 @@ msgstr "Plotting Lights:"
#: scene/3d/baked_lightmap.cpp scene/3d/gi_probe.cpp
msgid "Finishing Plot"
-msgstr ""
+msgstr "Menyelesaikan Pemetaan"
#: scene/3d/baked_lightmap.cpp
msgid "Lighting Meshes: "
@@ -12422,13 +12486,15 @@ msgstr ""
#: scene/3d/gi_probe.cpp
msgid "Plotting Meshes"
-msgstr ""
+msgstr "Memetakan Mesh"
#: scene/3d/gi_probe.cpp
msgid ""
"GIProbes are not supported by the GLES2 video driver.\n"
"Use a BakedLightmap instead."
msgstr ""
+"GIProbes tidak didukung oleh driver video GLES2.\n"
+"Gunakan BakedLightmap sebagai gantinya."
#: scene/3d/light.cpp
msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows."
@@ -12541,6 +12607,8 @@ msgid ""
"This WorldEnvironment is ignored. Either add a Camera (for 3D scenes) or set "
"this environment's Background Mode to Canvas (for 2D scenes)."
msgstr ""
+"WorldEnvironment ini diabaikan. Tambahkan Camera (untuk skena 3D) atau setel "
+"Mode Latar Belakang lingkungannya menjadi Canvas (untuk skena 2D)."
#: scene/animation/animation_blend_tree.cpp
msgid "On BlendTree node '%s', animation not found: '%s'"
@@ -12591,6 +12659,9 @@ msgid ""
"LMB: Set color\n"
"RMB: Remove preset"
msgstr ""
+"Warna:#%s\n"
+"LMB: Atur warna\n"
+"RMB: Cabut preset"
#: scene/gui/color_picker.cpp
msgid "Pick a color from the editor window."
@@ -12694,7 +12765,7 @@ msgstr ""
#: scene/main/viewport.cpp
msgid "Viewport size must be greater than 0 to render anything."
-msgstr ""
+msgstr "Ukuran viewport harus lebih besar dari 0 untuk me-render apa pun."
#: scene/resources/visual_shader_nodes.cpp
msgid "Invalid source for preview."
@@ -12724,6 +12795,21 @@ msgstr "Variasi hanya bisa ditetapkan dalam fungsi vertex."
msgid "Constants cannot be modified."
msgstr "Konstanta tidak dapat dimodifikasi."
+#~ msgid "Not in resource path."
+#~ msgstr "Tidak dalam lokasi resource."
+
+#~ msgid "Revert"
+#~ msgstr "Pulihkan"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Tindakan ini tidak dapat dibatalkan. Pulihkan saja?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Kembalikan Skena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Bersihkan Skrip"
+
#~ msgid "Issue Tracker"
#~ msgstr "Pelacak Isu"
diff --git a/editor/translations/is.po b/editor/translations/is.po
index e2943eb9cf..5a1ac9b73c 100644
--- a/editor/translations/is.po
+++ b/editor/translations/is.po
@@ -849,7 +849,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1451,16 +1450,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2384,11 +2375,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2656,10 +2649,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3269,6 +3258,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3856,6 +3849,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6756,11 +6753,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7231,6 +7228,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10193,7 +10199,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10354,6 +10360,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10400,11 +10413,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10525,6 +10538,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10565,6 +10582,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11603,6 +11624,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11626,6 +11651,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/it.po b/editor/translations/it.po
index 8e9432baac..eeec1e05eb 100644
--- a/editor/translations/it.po
+++ b/editor/translations/it.po
@@ -13,7 +13,7 @@
# Myself <whatamidoing.wt@gmail.com>, 2017-2018.
# RealAquilus <JamesHeller@live.it>, 2017.
# Samuele Zolfanelli <samdazel@gmail.com>, 2018, 2019.
-# Sean Bone <seanbone@zumguy.com>, 2017.
+# Sean Bone <seanbone@zumguy.com>, 2017, 2020.
# Red Pill <redpill902@gmail.com>, 2018.
# iRadEntertainment <devitadario@gmail.com>, 2018, 2019.
# ondsinet _ (nik man) <nikman00@gmail.com>, 2018.
@@ -30,7 +30,7 @@
# RHC <rhc.throwaway@gmail.com>, 2019.
# Antonio Giungato <antonio.giungato@gmail.com>, 2019.
# Marco Galli <mrcgll98@gmail.com>, 2019.
-# MassiminoilTrace <omino.gis@gmail.com>, 2019.
+# MassiminoilTrace <omino.gis@gmail.com>, 2019, 2020.
# MARCO BANFI <mbanfi@gmail.com>, 2019.
# Marco <rodomar705@gmail.com>, 2019.
# Davide Giuliano <davidegiuliano00@gmail.com>, 2019.
@@ -48,12 +48,14 @@
# Giuseppe Lucido <giuseppe.lucido@gmail.com>, 2020.
# Mirko Proto <mirko7@protonmail.com>, 2020.
# J. Lavoie <j.lavoie@net-c.ca>, 2020.
+# Andrea Terenziani <andrea.terenziani.at@gmail.com>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-04 15:12+0000\n"
-"Last-Translator: J. Lavoie <j.lavoie@net-c.ca>\n"
+"PO-Revision-Date: 2020-05-07 21:28+0000\n"
+"Last-Translator: Sean Bone <seanbone@zumguy.com>\n"
"Language-Team: Italian <https://hosted.weblate.org/projects/godot-engine/"
"godot/it/>\n"
"Language: it\n"
@@ -77,8 +79,8 @@ msgstr "Prevista una stringa di lunghezza 1 (singolo carattere)."
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
msgstr ""
-"Non vi sono abbastanza byte per i byte di decodifica, oppure il formato non "
-"è valido."
+"Non vi sono abbastanza byte per riuscire a decodificarli, oppure il formato "
+"non è valido."
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
@@ -679,7 +681,7 @@ msgstr "Pulisci"
#: editor/animation_track_editor.cpp
msgid "Scale Ratio:"
-msgstr "Fattore di scalatura:"
+msgstr "Fattore di scala:"
#: editor/animation_track_editor.cpp
msgid "Select Tracks to Copy"
@@ -752,7 +754,7 @@ msgstr "Parole intere"
#: editor/code_editor.cpp editor/rename_dialog.cpp
msgid "Replace"
-msgstr "Rimpiazza"
+msgstr "Sostituisci"
#: editor/code_editor.cpp
msgid "Replace All"
@@ -769,7 +771,7 @@ msgstr "Standard"
#: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp
msgid "Toggle Scripts Panel"
-msgstr "Attiva Pannello Scripts"
+msgstr "Commuta pannello degli script"
#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
@@ -785,7 +787,7 @@ msgstr "Rimpicciolisci"
#: editor/code_editor.cpp
msgid "Reset Zoom"
-msgstr "Azzera ingrandimento"
+msgstr "Resetta ingrandimento"
#: editor/code_editor.cpp
msgid "Warnings"
@@ -883,7 +885,6 @@ msgstr "Impossibile connettere il segnale"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1496,17 +1497,9 @@ msgstr "Abilita"
msgid "Rearrange Autoloads"
msgstr "Riordina gli Autoload"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Percorso non valido."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "File inesistente."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Non è nel percorso risorse."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1654,7 +1647,7 @@ msgstr "Editor 3D"
#: editor/editor_feature_profile.cpp
msgid "Script Editor"
-msgstr "Editor degli script"
+msgstr "Editor script"
#: editor/editor_feature_profile.cpp
msgid "Asset Library"
@@ -1878,7 +1871,7 @@ msgstr "Va' su"
#: editor/editor_file_dialog.cpp
msgid "Toggle Hidden Files"
-msgstr "Attiva/disattiva file nascosti"
+msgstr "Mostra/nascondi file nascosti"
#: editor/editor_file_dialog.cpp
msgid "Toggle Favorite"
@@ -1886,11 +1879,11 @@ msgstr "Attiva/disattiva preferito"
#: editor/editor_file_dialog.cpp
msgid "Toggle Mode"
-msgstr "Modalità Attivazione/Disattivazione"
+msgstr "Modalità di Attivazione/Disattivazione"
#: editor/editor_file_dialog.cpp
msgid "Focus Path"
-msgstr "Percorso di Focus"
+msgstr "Metti a fuoco il percorso"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Up"
@@ -2009,7 +2002,7 @@ msgstr "Metodi"
#: editor/editor_help.cpp
msgid "Theme Properties"
-msgstr "Proprietà del tema"
+msgstr "Proprietà Tema"
#: editor/editor_help.cpp
msgid "Enumerations"
@@ -2021,7 +2014,7 @@ msgstr "Costanti"
#: editor/editor_help.cpp
msgid "Property Descriptions"
-msgstr "Descrizioni delle proprietà"
+msgstr "Descrizioni Proprietà"
#: editor/editor_help.cpp
msgid "(value)"
@@ -2037,7 +2030,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Method Descriptions"
-msgstr "Descrizioni dei metodi"
+msgstr "Descrizioni Metodo"
#: editor/editor_help.cpp
msgid ""
@@ -2470,12 +2463,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Impossibile ricaricare una scena che non è mai stata salvata."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Ripristina"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Salva Scena"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Questa azione non può essere annullata. Ripristinare comunque?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2525,7 +2521,7 @@ msgstr "Chiudi scena"
#: editor/editor_node.cpp
msgid "Reopen Closed Scene"
-msgstr "Riapri Scena Chiusa"
+msgstr "Riapri la scena chiusa"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
@@ -2622,11 +2618,11 @@ msgstr ""
#: editor/editor_node.cpp
msgid "Save Layout"
-msgstr "Salva layout"
+msgstr "Salva disposizione"
#: editor/editor_node.cpp
msgid "Delete Layout"
-msgstr "Elimina Layout"
+msgstr "Elimina disposizione"
#: editor/editor_node.cpp editor/import_dock.cpp
#: editor/script_create_dialog.cpp
@@ -2740,7 +2736,7 @@ msgstr "Apri recente"
#: editor/editor_node.cpp
msgid "Save Scene"
-msgstr "Salva scena"
+msgstr "Salva Scena"
#: editor/editor_node.cpp
msgid "Save All Scenes"
@@ -2769,10 +2765,6 @@ msgid "Redo"
msgstr "Rifai"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Ripristina scena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Strumenti di progetto o scena vari."
@@ -2783,7 +2775,7 @@ msgstr "Progetto"
#: editor/editor_node.cpp
msgid "Project Settings..."
-msgstr "Impostazioni Progetto…"
+msgstr "Impostazioni progetto…"
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
msgid "Version Control"
@@ -2925,11 +2917,11 @@ msgstr "Impostazioni editor…"
#: editor/editor_node.cpp
msgid "Editor Layout"
-msgstr "Layout dell'editor"
+msgstr "Disposizione dell'editor"
#: editor/editor_node.cpp
msgid "Take Screenshot"
-msgstr "Acquisisci screenshot"
+msgstr "Acquisisci una schermata"
#: editor/editor_node.cpp
msgid "Screenshots are stored in the Editor Data/Settings Folder."
@@ -3000,7 +2992,7 @@ msgstr "Comunità"
#: editor/editor_node.cpp
msgid "About"
-msgstr "Riguardo a"
+msgstr "Informazioni su Godot"
#: editor/editor_node.cpp
msgid "Play the project."
@@ -3016,7 +3008,7 @@ msgstr "Metti in pausa l'esecuzione della scena per eseguire il debug."
#: editor/editor_node.cpp
msgid "Pause Scene"
-msgstr "Pausa Scena"
+msgstr "Pausa scena"
#: editor/editor_node.cpp
msgid "Stop the scene."
@@ -3158,15 +3150,15 @@ msgstr "Seleziona"
#: editor/editor_node.cpp
msgid "Open 2D Editor"
-msgstr "Apri editor 2D"
+msgstr "Apri Editor 2D"
#: editor/editor_node.cpp
msgid "Open 3D Editor"
-msgstr "Apri Editor 3D"
+msgstr "Apri editor 3D"
#: editor/editor_node.cpp
msgid "Open Script Editor"
-msgstr "Apri Editor Script"
+msgstr "Apri editor degli script"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
@@ -3425,6 +3417,13 @@ msgstr "Impossibile eseguire lo script:"
msgid "Did you forget the '_run' method?"
msgstr "Hai dimenticato il metodo '_run'?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Mantieni premuto Control per rilasciare un Getter. Mantieni premuto Shift "
+"per rilasciare una firma generica."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Scegli Nodo(i) da Importare"
@@ -3841,7 +3840,7 @@ msgstr "Crea Script"
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
msgid "Find in Files"
-msgstr "Trova nei File"
+msgstr "Trova nei file"
#: editor/find_in_files.cpp
msgid "Find:"
@@ -4023,6 +4022,10 @@ msgid "Error running post-import script:"
msgstr "Errore di esecuzione dello script di post-import:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Salvataggio..."
@@ -4623,7 +4626,7 @@ msgstr "Opzioni dell'onion skinning"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Directions"
-msgstr "Direzioni"
+msgstr "Indicazioni"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Past"
@@ -4643,11 +4646,11 @@ msgstr "1 passo"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "2 steps"
-msgstr "2 passaggi"
+msgstr "2 passi"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "3 steps"
-msgstr "3 passaggi"
+msgstr "3 passi"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Differences Only"
@@ -5175,7 +5178,7 @@ msgstr "Offset Griglia:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Grid Step:"
-msgstr "Step Griglia:"
+msgstr "Passo della griglia:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Primary Line Every:"
@@ -5183,7 +5186,7 @@ msgstr "Line Primaria Ogni:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "steps"
-msgstr "passaggi"
+msgstr "passi"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation Offset:"
@@ -5191,11 +5194,11 @@ msgstr "Offset Rotazione:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation Step:"
-msgstr "Step Rotazione:"
+msgstr "Passo di rotazione:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Scale Step:"
-msgstr "Intervallo:"
+msgstr "Passo di scala:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Move Vertical Guide"
@@ -5393,7 +5396,7 @@ msgstr "Incolla Posa"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Clear Guides"
-msgstr "Rimuvi Guide"
+msgstr "Rimuovi guide"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Create Custom Bone(s) from Node(s)"
@@ -5423,12 +5426,12 @@ msgstr ""
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom Reset"
-msgstr "Ripristino Zoom"
+msgstr "Ripristina ingrandimento"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Select Mode"
-msgstr "Modalità di Selezione"
+msgstr "Modalità di selezione"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Drag: Rotate"
@@ -5451,17 +5454,17 @@ msgstr "Alt+RMB: Selezione Lista Profondità"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Move Mode"
-msgstr "Modalità Movimento"
+msgstr "Modalità spostamento"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rotate Mode"
-msgstr "Modalità Rotazione"
+msgstr "Modalità rotazione"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Scale Mode"
-msgstr "Modalità Scala"
+msgstr "Modalità scala"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5482,7 +5485,7 @@ msgstr "Modalità di Pan"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Ruler Mode"
-msgstr "Modalità Righello"
+msgstr "Modalità righello"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Toggle smart snapping."
@@ -5490,7 +5493,7 @@ msgstr "Abilita snapping intelligente."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Smart Snap"
-msgstr "Usa lo Snap Intelligente"
+msgstr "Usa lo Snap intelligente"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Toggle grid snapping."
@@ -5498,7 +5501,7 @@ msgstr "Abilita/Disabilita snapping magnetico."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Grid Snap"
-msgstr "Usa snap magnetico"
+msgstr "Usa Griglia Magnetica"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snapping Options"
@@ -5600,7 +5603,7 @@ msgstr "Mostra Sempre Griglia"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Helpers"
-msgstr "Mostra Guide"
+msgstr "Mostra guide"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Rulers"
@@ -5608,7 +5611,7 @@ msgstr "Mostra Righelli"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Guides"
-msgstr "Mostra guide"
+msgstr "Mostra Guide"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Origin"
@@ -5624,15 +5627,15 @@ msgstr "Mostra Gruppo e Blocca Icone"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Center Selection"
-msgstr "Centra Selezione"
+msgstr "Centra selezione"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Frame Selection"
-msgstr "Selezione Frame"
+msgstr "Selezione frame"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Preview Canvas Scale"
-msgstr "Anteprima dimensione canvas"
+msgstr "Anteprima Dimensione Canvas"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Translation mask for inserting keys."
@@ -5673,7 +5676,7 @@ msgstr "Chiavi d'Animazione e Opzioni Posa"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key (Existing Tracks)"
-msgstr "Inserisci Key (Tracce Esistenti)"
+msgstr "Inserisci chiave (tracce esistenti)"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Copy Pose"
@@ -5681,7 +5684,7 @@ msgstr "Copia Posa"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Clear Pose"
-msgstr "Pulisci Posa"
+msgstr "Azzera posa"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Multiply grid step by 2"
@@ -5693,7 +5696,7 @@ msgstr "Dividi per 2 il passo della griglia"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Pan View"
-msgstr "Vista panoramica"
+msgstr "Trasla Visuale"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Add %s"
@@ -6633,11 +6636,11 @@ msgstr "Offset Y Griglia:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Step X:"
-msgstr "Step X Griglia:"
+msgstr "Passo X della griglia:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Step Y:"
-msgstr "Step Y Griglia:"
+msgstr "Passo Y della griglia:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Sync Bones to Polygon"
@@ -6791,12 +6794,12 @@ msgstr "%s Riferimento di Classe"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
msgid "Find Next"
-msgstr "Trova Successivo"
+msgstr "Trova successivo"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
msgid "Find Previous"
-msgstr "Trova Precedente"
+msgstr "Trova precedente"
#: editor/plugins/script_editor_plugin.cpp
msgid "Filter scripts"
@@ -6818,13 +6821,13 @@ msgstr "Ordina"
#: editor/plugins/script_text_editor.cpp editor/scene_tree_dock.cpp
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Move Up"
-msgstr "Sposta Su"
+msgstr "Sposta in su"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp editor/scene_tree_dock.cpp
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Move Down"
-msgstr "Sposta giù"
+msgstr "Sposta in giù"
#: editor/plugins/script_editor_plugin.cpp
msgid "Next script"
@@ -6844,15 +6847,15 @@ msgstr "Apri..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Reopen Closed Script"
-msgstr "Riapri Script Chiuso"
+msgstr "Riapri lo script chiuso"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save All"
-msgstr "Salva Tutto"
+msgstr "Salva tutto"
#: editor/plugins/script_editor_plugin.cpp
msgid "Soft Reload Script"
-msgstr "Ricarica Script Soft"
+msgstr "Ricarica Soft Script"
#: editor/plugins/script_editor_plugin.cpp
msgid "Copy Script Path"
@@ -6897,11 +6900,11 @@ msgstr "Esegui"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Step Into"
-msgstr "Passo Precedente"
+msgstr "Passo dentro all'istruzione"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Step Over"
-msgstr "Passo Successivo"
+msgstr "Passo successivo"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Break"
@@ -6989,16 +6992,17 @@ msgstr ""
"Manca il metodo '%s' connesso per il segnale '%s' dal nodo '%s' al nodo '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Linea"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(ignora)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignora)"
+msgid "Line"
+msgstr "Linea"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
-msgstr "Vai a Funzione"
+msgstr "Va' alla funzione"
#: editor/plugins/script_text_editor.cpp
msgid "Only resources from filesystem can be dropped."
@@ -7032,7 +7036,7 @@ msgstr "Minuscolo"
#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
msgid "Capitalize"
-msgstr "Aggiungi maiuscola iniziale"
+msgstr "Rendi prima lettera maiuscola"
#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
msgid "Syntax Highlighter"
@@ -7050,7 +7054,7 @@ msgstr "Segnalibri"
#: editor/plugins/script_text_editor.cpp
msgid "Breakpoints"
-msgstr "Punti di rottura"
+msgstr "Breakpoint"
#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
@@ -7060,11 +7064,11 @@ msgstr "Taglia"
#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
msgid "Select All"
-msgstr "Seleziona tutti"
+msgstr "Seleziona tutto"
#: editor/plugins/script_text_editor.cpp
msgid "Delete Line"
-msgstr "Elimina Linea"
+msgstr "Elimina linea"
#: editor/plugins/script_text_editor.cpp
msgid "Indent Left"
@@ -7076,11 +7080,11 @@ msgstr "Indenta Destra"
#: editor/plugins/script_text_editor.cpp
msgid "Toggle Comment"
-msgstr "Cambia a Commento"
+msgstr "Commuta commento"
#: editor/plugins/script_text_editor.cpp
msgid "Fold/Unfold Line"
-msgstr "Piega/Dispiega Linea"
+msgstr "Espandi/comprimi linea"
#: editor/plugins/script_text_editor.cpp
msgid "Fold All Lines"
@@ -7092,31 +7096,31 @@ msgstr "Dispiegare Tutte le Linee"
#: editor/plugins/script_text_editor.cpp
msgid "Clone Down"
-msgstr "Clona Sotto"
+msgstr "Clona sotto"
#: editor/plugins/script_text_editor.cpp
msgid "Complete Symbol"
-msgstr "Completa Simbolo"
+msgstr "Completa simbolo"
#: editor/plugins/script_text_editor.cpp
msgid "Evaluate Selection"
-msgstr "Valuta Selezione"
+msgstr "Valuta selezione"
#: editor/plugins/script_text_editor.cpp
msgid "Trim Trailing Whitespace"
-msgstr "Taglia Spazi in Coda"
+msgstr "Taglia spazi in coda"
#: editor/plugins/script_text_editor.cpp
msgid "Convert Indent to Spaces"
-msgstr "Converti Indentazione in Spazi"
+msgstr "Converti l'indentazione in spazi"
#: editor/plugins/script_text_editor.cpp
msgid "Convert Indent to Tabs"
-msgstr "Converti Indentazione in Tabulazioni"
+msgstr "Converti l'indentazione in tabulazioni"
#: editor/plugins/script_text_editor.cpp
msgid "Auto Indent"
-msgstr "Auto Indenta"
+msgstr "Indenta automaticamente"
#: editor/plugins/script_text_editor.cpp
msgid "Find in Files..."
@@ -7124,19 +7128,19 @@ msgstr "Cerca nei File..."
#: editor/plugins/script_text_editor.cpp
msgid "Contextual Help"
-msgstr "Aiuto Contestuale"
+msgstr "Aiuto contestuale"
#: editor/plugins/script_text_editor.cpp
msgid "Toggle Bookmark"
-msgstr "Abilita/Disabilita Segnalibri"
+msgstr "Abilita/Disabilita segnalibri"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Next Bookmark"
-msgstr "Vai al Segnalibri Successivo"
+msgstr "Va' al segnalibro successivo"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Previous Bookmark"
-msgstr "Vai al Segnalibri Precedente"
+msgstr "Va' al segnalibro precedente"
#: editor/plugins/script_text_editor.cpp
msgid "Remove All Bookmarks"
@@ -7153,19 +7157,19 @@ msgstr "Vai a Linea..."
#: editor/plugins/script_text_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Toggle Breakpoint"
-msgstr "Abilita Breakpoint"
+msgstr "Commuta breakpoint"
#: editor/plugins/script_text_editor.cpp
msgid "Remove All Breakpoints"
-msgstr "Rimuovi Tutti i Breakpoints"
+msgstr "Rimuovi tutti i breakpoint"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Next Breakpoint"
-msgstr "Vai a Breakpoint Successivo"
+msgstr "Vai al breakpoint successivo"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Previous Breakpoint"
-msgstr "Vai a Breakpoint Precedente"
+msgstr "Vai al breakpoint precedente"
#: editor/plugins/shader_editor_plugin.cpp
msgid ""
@@ -7345,11 +7349,11 @@ msgstr "Retro"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Align Transform with View"
-msgstr "Allinea Trasformazione con la Vista"
+msgstr "Allinea trasformazione con la vista"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Align Rotation with View"
-msgstr "Allinea Rotazione con la Vista"
+msgstr "Allinea rotazione con la vista"
#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "No parent to instance a child at."
@@ -7469,6 +7473,15 @@ msgid "XForm Dialog"
msgstr "Finestra di XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Sposta i Nodi sul Pavimento"
@@ -7488,51 +7501,51 @@ msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Use Local Space"
-msgstr "Usa lo Spazio Locale"
+msgstr "Usa Spazio Locale"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Use Snap"
-msgstr "Usa lo Snap"
+msgstr "Usa Snap"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Bottom View"
-msgstr "Vista dal Basso"
+msgstr "Vista dal basso"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Top View"
-msgstr "Vista dall'Alto"
+msgstr "Vista dall'alto"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rear View"
-msgstr "Vista dal Retro"
+msgstr "Vista dal retro"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Front View"
-msgstr "Vista Frontale"
+msgstr "Vista frontale"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Left View"
-msgstr "Vista Sinistra"
+msgstr "Vista laterale sinistra"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Right View"
-msgstr "Vista Destra"
+msgstr "Vista laterale destra"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Switch Perspective/Orthogonal View"
-msgstr "Cambia tra Vista Prospettiva/Ortogonale"
+msgstr "Cambia tra vista prospettica/ortogonale"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Insert Animation Key"
-msgstr "Inserisci Key Animazione"
+msgstr "Inserisci chiave animazione"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Focus Origin"
-msgstr "Focalizza su Origine"
+msgstr "Centra Origine"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Focus Selection"
-msgstr "Centra a Selezione"
+msgstr "Centra la Selezione"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Toggle Freelook"
@@ -7901,7 +7914,7 @@ msgstr "Offset:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Step:"
-msgstr "Step:"
+msgstr "Passo:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Sep.:"
@@ -8066,7 +8079,7 @@ msgstr "File Tema"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Erase Selection"
-msgstr "Cancella Selezione"
+msgstr "Cancella selezione"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Fix Invalid Tiles"
@@ -8075,7 +8088,7 @@ msgstr "Correggi le Tile non Valide"
#: editor/plugins/tile_map_editor_plugin.cpp
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cut Selection"
-msgstr "Taglia Selezione"
+msgstr "Taglia selezione"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Paint TileMap"
@@ -8099,7 +8112,7 @@ msgstr "Cancella TileMap"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Find Tile"
-msgstr "Trova Tile"
+msgstr "Trova tile"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Transpose"
@@ -8124,7 +8137,7 @@ msgstr ""
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Paint Tile"
-msgstr "Disegna Tile"
+msgstr "Disegna tile"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid ""
@@ -8136,7 +8149,7 @@ msgstr ""
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Pick Tile"
-msgstr "Preleva Tile"
+msgstr "Preleva tile"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Rotate Left"
@@ -8156,7 +8169,7 @@ msgstr "Ribalta verticalmente"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Clear Transform"
-msgstr "Cancella la trasformazione"
+msgstr "Azzera la trasformazione"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Add Texture(s) to TileSet."
@@ -8188,7 +8201,7 @@ msgstr "Nuova Atlas"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Next Coordinate"
-msgstr "Prossima Coordinata"
+msgstr "Coordinata successiva"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Select the next shape, subtile, or Tile."
@@ -8196,7 +8209,7 @@ msgstr "Seleziona la prossima forma, sottotile, o Tile."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Previous Coordinate"
-msgstr "Coordinata Precedente"
+msgstr "Coordinata precedente"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Select the previous shape, subtile, or Tile."
@@ -8232,27 +8245,27 @@ msgstr "Indice Z"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Region Mode"
-msgstr "Modalità regione"
+msgstr "Modalità Regione"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Collision Mode"
-msgstr "Modalità di Collisione"
+msgstr "Modalità di collisione"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Occlusion Mode"
-msgstr "Modalità di occlusione"
+msgstr "Modalità Occlusione"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Navigation Mode"
-msgstr "Modalità di navigazione"
+msgstr "Modalità Navigazione"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Bitmask Mode"
-msgstr "Modalità Maschera di Bit"
+msgstr "Modalità Bitmask"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Priority Mode"
-msgstr "Modalità prioritaria"
+msgstr "Modalità Prioritaria"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Icon Mode"
@@ -8260,7 +8273,7 @@ msgstr "Modalità Icona"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Z Index Mode"
-msgstr "Modalità indice Z"
+msgstr "Modalità Indice Z"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Copy bitmask."
@@ -8661,7 +8674,7 @@ msgstr "Duplica Nodi"
#: editor/plugins/visual_shader_editor_plugin.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Paste Nodes"
-msgstr "Incolla Nodi"
+msgstr "Incolla nodi"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Delete Nodes"
@@ -9996,6 +10009,10 @@ msgid ""
"To filter projects by name and full path, the query must contain at least "
"one `/` character."
msgstr ""
+"La casella di ricerca filtra i progetti per nome e l'ultimo componente del "
+"percorso.\n"
+"Per filtrare i progetti per nome e percorso completo, la query deve "
+"contenere almeno un carattere `/`."
#: editor/project_settings_editor.cpp
msgid "Key "
@@ -10375,7 +10392,7 @@ msgstr "Seleziona Metodo"
#: editor/rename_dialog.cpp editor/scene_tree_dock.cpp
msgid "Batch Rename"
-msgstr "Rinomina in Blocco"
+msgstr "Rinomina in blocco"
#: editor/rename_dialog.cpp
msgid "Prefix"
@@ -10562,8 +10579,9 @@ msgid "Instance Child Scene"
msgstr "Istanzia Scena Figlia"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Svuota Script"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Allega Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10729,8 +10747,15 @@ msgid "Open Documentation"
msgstr "Apri la documentazione"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
-msgstr "Aggiungi Nodo Figlio"
+msgstr "Aggiungi un nodo figlio"
#: editor/scene_tree_dock.cpp
msgid "Expand/Collapse All"
@@ -10758,7 +10783,7 @@ msgstr "Salva Ramo come Scena"
#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
msgid "Copy Node Path"
-msgstr "Copia Percorso Nodo"
+msgstr "Copia percorso del nodo"
#: editor/scene_tree_dock.cpp
msgid "Delete (No Confirm)"
@@ -10777,11 +10802,13 @@ msgstr ""
"root esiste."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Allega un nuovo script o uno esistente al nodo selezionato."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Svuota uno script per il nodo selezionato."
#: editor/scene_tree_dock.cpp
@@ -10913,6 +10940,10 @@ msgid "A directory with the same name exists."
msgstr "Esiste già una directory con lo stesso nome."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "File inesistente."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Estensione non valida."
@@ -10953,6 +10984,10 @@ msgid "File exists, it will be reused."
msgstr "Il file è già esistente, quindi, verrà riutilizzato."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Percorso non valido."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nome classe non valido."
@@ -11058,7 +11093,7 @@ msgstr "Processo Figlio Connesso."
#: editor/script_editor_debugger.cpp
msgid "Copy Error"
-msgstr "Errore di Copia"
+msgstr "Copia messaggio di errore"
#: editor/script_editor_debugger.cpp
msgid "Video RAM"
@@ -11066,7 +11101,7 @@ msgstr "RAM Video"
#: editor/script_editor_debugger.cpp
msgid "Skip Breakpoints"
-msgstr "Salta Punti di rottura"
+msgstr "Salta i breakpoint"
#: editor/script_editor_debugger.cpp
msgid "Inspect Previous Instance"
@@ -11860,31 +11895,31 @@ msgstr "Seleziona o crea una funzione per modificarne il grafico."
#: modules/visual_script/visual_script_editor.cpp
msgid "Delete Selected"
-msgstr "Elimina selezionati"
+msgstr "Elimina Selezionati"
#: modules/visual_script/visual_script_editor.cpp
msgid "Find Node Type"
-msgstr "Trova Tipo Nodo"
+msgstr "Trova tipo del nodo"
#: modules/visual_script/visual_script_editor.cpp
msgid "Copy Nodes"
-msgstr "Copia Nodi"
+msgstr "Copia nodi"
#: modules/visual_script/visual_script_editor.cpp
msgid "Cut Nodes"
-msgstr "Taglia Nodi"
+msgstr "Taglia nodi"
#: modules/visual_script/visual_script_editor.cpp
msgid "Make Function"
-msgstr "Crea Funzione"
+msgstr "Crea funzione"
#: modules/visual_script/visual_script_editor.cpp
msgid "Refresh Graph"
-msgstr "Aggiorna Grafico"
+msgstr "Aggiorna grafico"
#: modules/visual_script/visual_script_editor.cpp
msgid "Edit Member"
-msgstr "Modifica Membro"
+msgstr "Modifica membro"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Input type not iterable: "
@@ -11933,16 +11968,16 @@ msgstr "VariableSet non trovato nello script: "
#: modules/visual_script/visual_script_nodes.cpp
msgid "Custom node has no _step() method, can't process graph."
msgstr ""
-"Il nodo personalizato non ha un metodo _step(), impossibile processare il "
-"grafico."
+"Il nodo personalizzato non ha alcun metodo _step(), impossibile processare "
+"il grafico."
#: modules/visual_script/visual_script_nodes.cpp
msgid ""
"Invalid return value from _step(), must be integer (seq out), or string "
"(error)."
msgstr ""
-"Valore di return invalido da _step(), deve esere intero (seq out), oppure "
-"stringa (errore)."
+"Valore di ritorno di _step() non valido, deve essere un intero (seq out), "
+"oppure una stringa (errore)."
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Search VisualScript"
@@ -12003,6 +12038,12 @@ msgstr ""
"Debug keystore non configurato nelle Impostazioni dell'Editor né nel preset."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Debug keystore non configurato nelle Impostazioni dell'Editor né nel preset."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Le build personalizzate richiedono un percorso per un Android SDK valido "
@@ -12032,6 +12073,32 @@ msgstr "Nome del pacchetto non valido:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12831,6 +12898,21 @@ msgstr "Varyings può essere assegnato soltanto nella funzione del vertice."
msgid "Constants cannot be modified."
msgstr "Le constanti non possono essere modificate."
+#~ msgid "Not in resource path."
+#~ msgstr "Non è nel percorso risorse."
+
+#~ msgid "Revert"
+#~ msgstr "Ripristina"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Questa azione non può essere annullata. Ripristinare comunque?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Ripristina scena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Svuota Script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Tracciatore segnalazioni"
diff --git a/editor/translations/ja.po b/editor/translations/ja.po
index 8aef04db94..7d4aed4b29 100644
--- a/editor/translations/ja.po
+++ b/editor/translations/ja.po
@@ -31,12 +31,13 @@
# Akihiro Ogoshi <technical@palsystem-game.com>, 2019, 2020.
# Wataru Onuki <bettawat@yahoo.co.jp>, 2020.
# sporeball <sporeballdev@gmail.com>, 2020.
+# BinotaLIU <me@binota.org>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-04 15:12+0000\n"
-"Last-Translator: Wataru Onuki <bettawat@yahoo.co.jp>\n"
+"PO-Revision-Date: 2020-06-03 20:09+0000\n"
+"Last-Translator: BinotaLIU <me@binota.org>\n"
"Language-Team: Japanese <https://hosted.weblate.org/projects/godot-engine/"
"godot/ja/>\n"
"Language: ja\n"
@@ -866,7 +867,6 @@ msgstr "シグナルã«æŽ¥ç¶šã§ãã¾ã›ã‚“"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1476,17 +1476,9 @@ msgstr "有効"
msgid "Rearrange Autoloads"
msgstr "自動読込ã¿ã®ä¸¦ã¹æ›¿ãˆ"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "パスãŒç„¡åŠ¹ã§ã™ã€‚"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "ファイルãŒå­˜åœ¨ã—ã¾ã›ã‚“。"
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "リソースパスã«ã‚ã‚Šã¾ã›ã‚“。"
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2444,12 +2436,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "ä¿å­˜ã•ã‚Œã¦ã„ãªã„シーンを読ã¿è¾¼ã‚€ã“ã¨ã¯ã§ãã¾ã›ã‚“。"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "å…ƒã«æˆ»ã™"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "シーンをä¿å­˜"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "ã“ã®æ“作ã¯å–り消ã›ã¾ã›ã‚“。ãã‚Œã§ã‚‚å…ƒã«æˆ»ã—ã¾ã™ã‹?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2737,10 +2732,6 @@ msgid "Redo"
msgstr "ã‚„ã‚Šç›´ã™"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "シーンを元ã«æˆ»ã™"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "ãã®ä»–ã®ãƒ—ロジェクトã¾ãŸã¯ã‚·ãƒ¼ãƒ³å…¨ä½“ã®ãƒ„ール。"
@@ -3386,6 +3377,13 @@ msgstr "スクリプトを実行ã§ãã¾ã›ã‚“ã§ã—ãŸ:"
msgid "Did you forget the '_run' method?"
msgstr "'_run' メソッドを忘れã¦ã„ã¾ã›ã‚“ã‹ï¼Ÿ"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Ctrlを押ã—ãŸã¾ã¾Getterã‚’(ドラッグ&)ドロップã™ã‚‹ã€‚Shiftを押ã—ãŸã¾ã¾æ±Žç”¨ã‚·ã‚°ãƒ"
+"ãƒãƒ£ã‚’(ドラッグ&)ドロップã™ã‚‹."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "インãƒãƒ¼ãƒˆã™ã‚‹ãƒŽãƒ¼ãƒ‰ã‚’é¸æŠž"
@@ -3979,6 +3977,10 @@ msgid "Error running post-import script:"
msgstr "インãƒãƒ¼ãƒˆæ¸ˆã‚¹ã‚¯ãƒªãƒ—トã®å®Ÿè¡Œä¸­ã«ã‚¨ãƒ©ãƒ¼:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "ä¿å­˜ä¸­..."
@@ -4051,9 +4053,8 @@ msgid "Copy Resource"
msgstr "リソースをコピー"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Make Built-In"
-msgstr "ビルトインを作æˆ"
+msgstr "組ã¿è¾¼ã¿ã«ã™ã‚‹"
#: editor/inspector_dock.cpp
msgid "Make Sub-Resources Unique"
@@ -5692,7 +5693,7 @@ msgstr "ãƒãƒ³ãƒ‰ãƒ«ã‚’設定ã™ã‚‹"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Load Emission Mask"
-msgstr "放射マスクを読ã¿è¾¼ã‚€"
+msgstr "放出マスクを読ã¿è¾¼ã‚€"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/cpu_particles_editor_plugin.cpp
@@ -5704,7 +5705,7 @@ msgstr "å†èµ·å‹•"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Clear Emission Mask"
-msgstr "発光(Emission)マスクをクリア"
+msgstr "放出マスクをクリア"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
@@ -5720,7 +5721,7 @@ msgstr "生æˆã—ãŸãƒã‚¤ãƒ³ãƒˆã®æ•°:"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Emission Mask"
-msgstr "\\ Emission Mask"
+msgstr "放出マスク"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
@@ -5745,7 +5746,7 @@ msgstr "ピクセルã‹ã‚‰ã‚­ãƒ£ãƒ—ãƒãƒ£"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Emission Colors"
-msgstr "発光(Emission)色"
+msgstr "放出色"
#: editor/plugins/cpu_particles_editor_plugin.cpp
msgid "CPUParticles"
@@ -6210,7 +6211,7 @@ msgstr "\"%s\" ã¯ãƒ•ã‚§ã‚¤ã‚¹ã‚¸ã‚ªãƒ¡ãƒˆãƒªãƒ¼ã‚’å«ã‚“ã§ã„ã¾ã›ã‚“。"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Create Emitter"
-msgstr "放出器を作æˆ"
+msgstr "放出æºã‚’作æˆ"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Emission Points:"
@@ -6923,12 +6924,13 @@ msgstr ""
"ド'%s'ã¸ã®ã‚·ã‚°ãƒŠãƒ«ç”¨ã§ã™ã€‚"
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "ライン"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(無視)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(無視)"
+msgid "Line"
+msgstr "ライン"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7403,6 +7405,15 @@ msgid "XForm Dialog"
msgstr "XFormダイアログ"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "ノードをフロアã«ã‚¹ãƒŠãƒƒãƒ—"
@@ -8815,27 +8826,27 @@ msgstr "ãƒã‚¤ãƒ”ア数(2.718282)。自然対数ã®ãƒ™ãƒ¼ã‚¹ã‚’表ã—ã¾ã™ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Epsilon constant (0.00001). Smallest possible scalar number."
-msgstr "Î¥(イプシロン)定数(0.00001)。使用å¯èƒ½ãªæœ€å°ã®ã‚¹ã‚«ãƒ©ãƒ¼æ•°ã€‚"
+msgstr "ε(イプシロン)定数(0.00001)。使用å¯èƒ½ãªæœ€å°ã®ã‚¹ã‚«ãƒ©ãƒ¼æ•°ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Phi constant (1.618034). Golden ratio."
-msgstr "Φ(ファイ)定数 (1.618034)。黄金比。"
+msgstr "φ(ファイ)定数 (1.618034)。黄金比。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Pi/4 constant (0.785398) or 45 degrees."
-msgstr "Π(パイ)/4定数 (0.785398) ã¾ãŸã¯45度。"
+msgstr "Ï€(パイ)/4定数 (0.785398) ã¾ãŸã¯45度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Pi/2 constant (1.570796) or 90 degrees."
-msgstr "Π(パイ)/2 定数(1.570796)ã¾ãŸã¯90度。"
+msgstr "Ï€(パイ)/2 定数(1.570796)ã¾ãŸã¯90度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Pi constant (3.141593) or 180 degrees."
-msgstr "Π(パイ)定数(3.141593)ã¾ãŸã¯180度。"
+msgstr "Ï€(パイ)定数(3.141593)ã¾ãŸã¯180度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Tau constant (6.283185) or 360 degrees."
-msgstr "Τ(タウ)定数(6.283185)ã¾ãŸã¯360度。"
+msgstr "Ï„(タウ)定数(6.283185)ã¾ãŸã¯360度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Sqrt2 constant (1.414214). Square root of 2."
@@ -9286,7 +9297,6 @@ msgstr ""
"ãŸã‚ã«ãれを使用ã—ãªã„ã§ãã ã•ã„。"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid ""
"Returns falloff based on the dot product of surface normal and view "
"direction of camera (pass associated inputs to it)."
@@ -9885,7 +9895,7 @@ msgstr "æ–°è¦ãƒ—ロジェクト"
#: editor/project_manager.cpp
msgid "Remove Missing"
-msgstr "存在ã—ãªã„ã‚‚ã®ã‚’削除"
+msgstr "存在ã—ãªã„ã‚‚ã®ã‚’除去"
#: editor/project_manager.cpp
msgid "Templates"
@@ -9939,8 +9949,8 @@ msgid ""
"Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'"
msgstr ""
-"アクションåãŒç„¡åŠ¹ã§ã™ã€‚空ã«ã—ãŸã‚Šã€'/'ã€':'ã€'='ã€'\\'等をå«ã‚ã‚‹ã“ã¨ã¯ã§ãã¾"
-"ã›ã‚“"
+"アクションåãŒç„¡åŠ¹ã§ã™ã€‚空ã«ã—ãŸã‚Šã€'/'ã€':'ã€'='ã€'\\'ã€'\"'ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§"
+"ãã¾ã›ã‚“"
#: editor/project_settings_editor.cpp
msgid "An action with the name '%s' already exists."
@@ -10083,8 +10093,8 @@ msgid ""
"Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'."
msgstr ""
-"無効ãªã‚¢ã‚¯ã‚·ãƒ§ãƒ³åã§ã™ã€‚空もã—ãã¯'/'ã€':'ã€'='ã€'\\' ã€'\"'等をå«ã‚ã‚‹ã“ã¨ã¯"
-"ã§ãã¾ã›ã‚“。"
+"無効ãªã‚¢ã‚¯ã‚·ãƒ§ãƒ³åã§ã™ã€‚空もã—ãã¯'/'ã€':'ã€'='ã€'\\' ã€'\"'ã‚’å«ã‚ã‚‹ã“ã¨ã¯ã§"
+"ãã¾ã›ã‚“。"
#: editor/project_settings_editor.cpp
msgid "Add Input Action"
@@ -10483,8 +10493,9 @@ msgid "Instance Child Scene"
msgstr "å­ã‚·ãƒ¼ãƒ³ã‚’インスタンス化"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "スクリプトをクリア"
+#, fuzzy
+msgid "Detach Script"
+msgstr "スクリプトをアタッãƒ"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10648,6 +10659,13 @@ msgid "Open Documentation"
msgstr "ドキュメントを開ã"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "å­ãƒŽãƒ¼ãƒ‰ã‚’追加"
@@ -10696,11 +10714,13 @@ msgstr ""
"åˆã¯ã€ç¶™æ‰¿ã•ã‚ŒãŸã‚·ãƒ¼ãƒ³ã‚’作æˆã—ã¾ã™ã€‚"
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "é¸æŠžã—ãŸãƒŽãƒ¼ãƒ‰ã«æ–°è¦ã¾ãŸã¯æ—¢å­˜ã®ã‚¹ã‚¯ãƒªãƒ—トをアタッãƒã™ã‚‹ã€‚"
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "é¸æŠžã—ãŸãƒŽãƒ¼ãƒ‰ã®ã‚¹ã‚¯ãƒªãƒ—トをクリアã™ã‚‹ã€‚"
#: editor/scene_tree_dock.cpp
@@ -10832,6 +10852,10 @@ msgid "A directory with the same name exists."
msgstr "åŒåã®ãƒ•ã‚©ãƒ«ãƒ€ãŒå­˜åœ¨ã—ã¾ã™ã€‚"
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "ファイルãŒå­˜åœ¨ã—ã¾ã›ã‚“。"
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "無効ãªæ‹¡å¼µå­ã§ã™ã€‚"
@@ -10872,6 +10896,10 @@ msgid "File exists, it will be reused."
msgstr "ファイルãŒæ—¢ã«å­˜åœ¨ã—ã¾ã™ã€‚ãã¡ã‚‰ã‚’å†åˆ©ç”¨ã—ã¾ã™ã€‚"
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "パスãŒç„¡åŠ¹ã§ã™ã€‚"
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "無効ãªã‚¯ãƒ©ã‚¹å。"
@@ -10973,7 +11001,7 @@ msgstr "エラー"
#: editor/script_editor_debugger.cpp
msgid "Child process connected."
-msgstr "å­ãƒ—ロセスãŒæŽ¥ç¶šã•ã‚ŒãŸã€‚"
+msgstr "å­ãƒ—ロセスãŒæŽ¥ç¶šã•ã‚Œã¾ã—ãŸã€‚"
#: editor/script_editor_debugger.cpp
msgid "Copy Error"
@@ -11919,6 +11947,11 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr "デãƒãƒƒã‚°ã‚­ãƒ¼ã‚¹ãƒˆã‚¢ãŒã‚¨ãƒ‡ã‚£ã‚¿è¨­å®šã«ã‚‚プリセットã«ã‚‚設定ã•ã‚Œã¦ã„ã¾ã›ã‚“。"
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr "デãƒãƒƒã‚°ã‚­ãƒ¼ã‚¹ãƒˆã‚¢ãŒã‚¨ãƒ‡ã‚£ã‚¿è¨­å®šã«ã‚‚プリセットã«ã‚‚設定ã•ã‚Œã¦ã„ã¾ã›ã‚“。"
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr "カスタムビルドã«ã¯ã‚¨ãƒ‡ã‚£ã‚¿è¨­å®šã§æœ‰åŠ¹ãªAndroid SDKパスãŒå¿…è¦ã§ã™ã€‚"
@@ -11944,6 +11977,32 @@ msgstr "無効ãªãƒ‘ッケージå:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12724,6 +12783,21 @@ msgstr "Varying変数ã¯é ‚点関数ã«ã®ã¿å‰²ã‚Šå½“ã¦ã‚‹ã“ã¨ãŒã§ãã¾ã
msgid "Constants cannot be modified."
msgstr "定数ã¯å¤‰æ›´ã§ãã¾ã›ã‚“。"
+#~ msgid "Not in resource path."
+#~ msgstr "リソースパスã«ã‚ã‚Šã¾ã›ã‚“。"
+
+#~ msgid "Revert"
+#~ msgstr "å…ƒã«æˆ»ã™"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "ã“ã®æ“作ã¯å–り消ã›ã¾ã›ã‚“。ãã‚Œã§ã‚‚å…ƒã«æˆ»ã—ã¾ã™ã‹?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "シーンを元ã«æˆ»ã™"
+
+#~ msgid "Clear Script"
+#~ msgstr "スクリプトをクリア"
+
#~ msgid "Issue Tracker"
#~ msgstr "課題管ç†ã‚·ã‚¹ãƒ†ãƒ "
diff --git a/editor/translations/ka.po b/editor/translations/ka.po
index 07eeeb5377..2435a50898 100644
--- a/editor/translations/ka.po
+++ b/editor/translations/ka.po
@@ -876,7 +876,6 @@ msgstr "დáƒáƒ›áƒáƒ™áƒáƒ•áƒ¨áƒ˜áƒ áƒ”ბელი სიგნáƒáƒšáƒ˜:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1503,17 +1502,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "áƒáƒ áƒáƒ¡áƒ¬áƒáƒ áƒ˜ ფáƒáƒœáƒ¢áƒ˜áƒ¡ ზáƒáƒ›áƒ."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2459,11 +2449,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "გáƒáƒ®áƒ¡áƒœáƒ˜áƒšáƒ˜"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2734,10 +2727,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3350,6 +3339,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3954,6 +3947,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6906,15 +6903,15 @@ msgid ""
msgstr "'%s' დრ'%s' შáƒáƒ áƒ˜áƒ¡ კáƒáƒ•áƒ¨áƒ˜áƒ áƒ˜áƒ¡ გáƒáƒ¬áƒ§áƒ•áƒ”ტáƒ"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "ხáƒáƒ–ი:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "ფუნქციის შექმნáƒ"
@@ -7391,6 +7388,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10392,8 +10398,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "დáƒáƒ›áƒáƒ™áƒ˜áƒ“ებულებების შემსწáƒáƒ áƒ”ბელი"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10554,6 +10561,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10603,11 +10617,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10732,6 +10746,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "áƒáƒ áƒáƒ¡áƒ¬áƒáƒ áƒ˜ ფáƒáƒœáƒ¢áƒ˜áƒ¡ ზáƒáƒ›áƒ."
@@ -10774,6 +10792,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "áƒáƒ áƒáƒ¡áƒ¬áƒáƒ áƒ˜ ფáƒáƒœáƒ¢áƒ˜áƒ¡ ზáƒáƒ›áƒ."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "áƒáƒ áƒáƒ¡áƒ¬áƒáƒ áƒ˜ ფáƒáƒœáƒ¢áƒ˜áƒ¡ ზáƒáƒ›áƒ."
@@ -11827,6 +11850,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11851,6 +11878,32 @@ msgstr "áƒáƒ áƒáƒ¡áƒ¬áƒáƒ áƒ˜ ფáƒáƒœáƒ¢áƒ˜áƒ¡ ზáƒáƒ›áƒ."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/ko.po b/editor/translations/ko.po
index f25550709a..c568dc19b8 100644
--- a/editor/translations/ko.po
+++ b/editor/translations/ko.po
@@ -17,12 +17,13 @@
# Ervin <zetsmart@gmail.com>, 2019.
# Tilto_ <tilto0822@develable.xyz>, 2020.
# Myeongjin Lee <aranet100@gmail.com>, 2020.
+# Doyun Kwon <caen4516@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-01 11:42+0000\n"
-"Last-Translator: Ch. <ccwpc@hanmail.net>\n"
+"PO-Revision-Date: 2020-05-22 21:01+0000\n"
+"Last-Translator: Doyun Kwon <caen4516@gmail.com>\n"
"Language-Team: Korean <https://hosted.weblate.org/projects/godot-engine/"
"godot/ko/>\n"
"Language: ko\n"
@@ -30,7 +31,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -850,7 +851,6 @@ msgstr "시그ë„ì„ ì—°ê²°í•  수 ì—†ìŒ"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1459,17 +1459,9 @@ msgstr "켜기"
msgid "Rearrange Autoloads"
msgstr "오토로드 다시 정렬"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "올바르지 ì•Šì€ ê²½ë¡œìž…ë‹ˆë‹¤."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "파ì¼ì´ 존재하지 않습니다."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "리소스 ê²½ë¡œì— ì—†ìŠµë‹ˆë‹¤."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1586,8 +1578,9 @@ msgid ""
"Enabled'."
msgstr ""
"ëŒ€ìƒ í”Œëž«í¼ì—ì„œ ë“œë¼ì´ë²„ê°€ GLES2ë¡œ í´ë°±í•˜ê¸° 위해 'ETC' í…스처 ì••ì¶•ì´ í•„ìš”í•©ë‹ˆ"
-"다. 프로ì íŠ¸ 설정ì—ì„œ 'Import Etc' ì„¤ì •ì„ ì¼œê±°ë‚˜, 'Driver Fallback Enabled' "
-"ì„¤ì •ì„ ë„세요."
+"다.\n"
+"프로ì íŠ¸ 설정ì—ì„œ 'Import Etc' ì„¤ì •ì„ í™œì„±í™” 하거나, 'Driver Fallback "
+"Enabled' ì„¤ì •ì„ ë¹„í™œì„±í™” 하세요."
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
@@ -1968,7 +1961,7 @@ msgstr "메서드"
#: editor/editor_help.cpp
msgid "Theme Properties"
-msgstr "테마 ì†ì„±"
+msgstr "테마 ì†ì„±ë“¤"
#: editor/editor_help.cpp
msgid "Enumerations"
@@ -2420,12 +2413,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "저장하지 ì•Šì€ ì”¬ì€ ìƒˆë¡œê³ ì¹¨í•  수 없습니다."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "ë˜ëŒë¦¬ê¸°"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "씬 저장"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "ì´ í–‰ë™ì€ 취소할 수 없습니다. 무시하고 ë˜ëŒë¦´ê¹Œìš”?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2710,10 +2706,6 @@ msgid "Redo"
msgstr "다시 실행"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "씬 ë˜ëŒë¦¬ê¸°"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "프로ì íŠ¸ ë˜ëŠ” 씬 관련 여러가지 ë„구들."
@@ -3354,6 +3346,13 @@ msgstr "스í¬ë¦½íŠ¸ë¥¼ 실행할 수 ì—†ìŒ:"
msgid "Did you forget the '_run' method?"
msgstr "'_run' 메서드를 잊었나요?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Ctrlì„ ëˆ„ë¥´ê³  있으면 Getter를 드롭합니다. Shift를 누르고 있으면 ì¼ë°˜ì ì¸ 시그"
+"니처를 드롭합니다."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "가져올 노드 ì„ íƒ"
@@ -3948,6 +3947,10 @@ msgid "Error running post-import script:"
msgstr "후 가져오기 스í¬ë¦½íŠ¸ 실행 중 오류:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "저장 중..."
@@ -6878,12 +6881,13 @@ msgstr ""
"다."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "í–‰"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(무시함)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(무시함)"
+msgid "Line"
+msgstr "í–‰"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7357,6 +7361,15 @@ msgid "XForm Dialog"
msgstr "XForm 대화 ìƒìž"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "노드를 ë°”ë‹¥ì— ìŠ¤ëƒ…"
@@ -9233,8 +9246,8 @@ msgid ""
"Returns falloff based on the dot product of surface normal and view "
"direction of camera (pass associated inputs to it)."
msgstr ""
-"ì¹´ë©”ë¼ì˜ 화면 방향과 표면 ë…¸ë©€ì˜ ìŠ¤ì¹¼ë¼ê³±ì„ 기반으로 하는 í´ì˜¤í”„를 반환합니"
-"다 (í´ì˜¤í”„와 ê´€ë ¨ëœ ìž…ë ¥ì„ ì „ë‹¬í•¨)."
+"í‘œë©´ì˜ ë²•ì„  벡터와 ì¹´ë©”ë¼ê°€ ë°”ë¼ë³´ëŠ” ë°©í–¥ ë²¡í„°ì˜ ë‚´ì ì„ 기반으로 í•œ í´ì˜¤í”„를 "
+"반환합니다. (í´ì˜¤í”„와 ê´€ë ¨ëœ ìž…ë ¥ì„ ì „ë‹¬í•¨)."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9407,15 +9420,16 @@ msgid ""
"Filters to export non-resource files/folders\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
msgstr ""
-"리소스가 ì•„ë‹Œ 파ì¼/í´ë” 내보내기 í•„í„° (쉼표로 구분, 예: *.json, *.txt, docs/"
-"*)"
+"리소스가 ì•„ë‹Œ 파ì¼/í´ë” 내보내기 í•„í„°\n"
+"(쉼표로 구분, 예: *.json, *.txt, docs/*)"
#: editor/project_export.cpp
msgid ""
"Filters to exclude files/folders from project\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
msgstr ""
-"프로ì íŠ¸ì—ì„œ 제외할 파ì¼/í´ë” í•„í„° (쉼표로 구분, 예: *.json, *.txt, docs/*)"
+"프로ì íŠ¸ì—ì„œ 제외할 파ì¼/í´ë” í•„í„°\n"
+"(쉼표로 구분, 예: *.json, *.txt, docs/*)"
#: editor/project_export.cpp
msgid "Patches"
@@ -10405,8 +10419,9 @@ msgid "Instance Child Scene"
msgstr "ìžì‹ 씬 ì¸ìŠ¤í„´ìŠ¤í™”"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "스í¬ë¦½íŠ¸ ì‚­ì œ"
+#, fuzzy
+msgid "Detach Script"
+msgstr "스í¬ë¦½íŠ¸ 붙ì´ê¸°"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10569,6 +10584,13 @@ msgid "Open Documentation"
msgstr "문서 열기"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "ìžì‹ 노드 추가"
@@ -10616,11 +10638,13 @@ msgstr ""
"씬 파ì¼ì„ 노드로 ì¸ìŠ¤í„´ìŠ¤í•©ë‹ˆë‹¤. 루트 노드가 없으면 ìƒì†ëœ ì”¬ì„ ë§Œë“­ë‹ˆë‹¤."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "ì„ íƒí•œ ë…¸ë“œì— ìƒˆë¡œìš´ í˜¹ì€ ì¡´ìž¬í•˜ëŠ” 스í¬ë¦½íŠ¸ë¥¼ 붙입니다."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "ì„ íƒí•œ ë…¸ë“œì˜ ìŠ¤í¬ë¦½íŠ¸ë¥¼ 삭제합니다."
#: editor/scene_tree_dock.cpp
@@ -10752,6 +10776,10 @@ msgid "A directory with the same name exists."
msgstr "ê°™ì€ ì´ë¦„ì˜ ë””ë ‰í† ë¦¬ê°€ 있습니다."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "파ì¼ì´ 존재하지 않습니다."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "ìž˜ëª»ëœ í™•ìž¥ìž."
@@ -10792,6 +10820,10 @@ msgid "File exists, it will be reused."
msgstr "파ì¼ì´ 있습니다. 다시 사용할 것입니다."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "올바르지 ì•Šì€ ê²½ë¡œìž…ë‹ˆë‹¤."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "ìž˜ëª»ëœ í´ëž˜ìŠ¤ ì´ë¦„."
@@ -11834,6 +11866,11 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr "Debug keystore를 편집기 설정과 í”„ë¦¬ì…‹ì— ì„¤ì •í•˜ì§€ 않았습니다."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr "Debug keystore를 편집기 설정과 í”„ë¦¬ì…‹ì— ì„¤ì •í•˜ì§€ 않았습니다."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr "맞춤 빌드ì—는 편집기 설정ì—ì„œ 올바른 안드로ì´ë“œ SDK 경로가 필요합니다."
@@ -11859,6 +11896,32 @@ msgstr "ìž˜ëª»ëœ íŒ¨í‚¤ì§€ ì´ë¦„:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12616,6 +12679,21 @@ msgstr "Varyingì€ ê¼­ì§“ì  í•¨ìˆ˜ì—만 지정할 수 있습니다."
msgid "Constants cannot be modified."
msgstr "ìƒìˆ˜ëŠ” 수정할 수 없습니다."
+#~ msgid "Not in resource path."
+#~ msgstr "리소스 ê²½ë¡œì— ì—†ìŠµë‹ˆë‹¤."
+
+#~ msgid "Revert"
+#~ msgstr "ë˜ëŒë¦¬ê¸°"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "ì´ í–‰ë™ì€ 취소할 수 없습니다. 무시하고 ë˜ëŒë¦´ê¹Œìš”?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "씬 ë˜ëŒë¦¬ê¸°"
+
+#~ msgid "Clear Script"
+#~ msgstr "스í¬ë¦½íŠ¸ ì‚­ì œ"
+
#~ msgid "Issue Tracker"
#~ msgstr "ì´ìŠˆ 트래커"
diff --git a/editor/translations/lt.po b/editor/translations/lt.po
index 57c377b571..bbbe630d4a 100644
--- a/editor/translations/lt.po
+++ b/editor/translations/lt.po
@@ -858,7 +858,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1465,17 +1464,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Netinkamas Å¡rifto dydis."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2424,11 +2414,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Atidaryti Skriptų Editorių"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2699,10 +2692,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3320,6 +3309,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr "Galbūt jūs pamiršote '_run' metodą?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Pasirinkite Nodus, kuriuos norite importuoti"
@@ -3927,6 +3920,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6888,15 +6885,15 @@ msgid ""
msgstr "Prijungti '%s' prie '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Linija:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
msgstr ""
@@ -7367,6 +7364,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10378,8 +10384,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Atidaryti Skriptų Editorių"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10540,6 +10547,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10588,11 +10602,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10715,6 +10729,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Netinkamas Å¡rifto dydis."
@@ -10759,6 +10777,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Netinkamas Å¡rifto dydis."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Netinkamas Å¡rifto dydis."
@@ -11812,6 +11835,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11836,6 +11863,32 @@ msgstr "Netinkamas Å¡rifto dydis."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/lv.po b/editor/translations/lv.po
index 642050468b..b69ecf7eef 100644
--- a/editor/translations/lv.po
+++ b/editor/translations/lv.po
@@ -3,14 +3,16 @@
# Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
# This file is distributed under the same license as the Godot source code.
# Gustavs Porietis (pg829-) <porietisgustavs@gmail.com>, 2018.
-# Martch Zagorski <martchzagorski@gmail.com>, 2018.
+# Martch Zagorski <martchzagorski@gmail.com>, 2018, 2020.
# JÄnis Ondzuls <janisond@inbox.lv>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
+# StiLins <aigars.skilins@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-03-11 12:20+0000\n"
-"Last-Translator: JÄnis Ondzuls <janisond@inbox.lv>\n"
+"PO-Revision-Date: 2020-06-04 18:34+0000\n"
+"Last-Translator: StiLins <aigars.skilins@gmail.com>\n"
"Language-Team: Latvian <https://hosted.weblate.org/projects/godot-engine/"
"godot/lv/>\n"
"Language: lv\n"
@@ -19,16 +21,17 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n % 10 == 0 || n % 100 >= 11 && n % 100 <= "
"19) ? 0 : ((n % 10 == 1 && n % 100 != 11) ? 1 : 2);\n"
-"X-Generator: Weblate 4.0-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
msgstr ""
+"Nepareizs argumenta tips convert() izsaukšanai, lietojiet TYPE_* konstantes."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr ""
+msgstr "JÄlieto teksta rinda ar garumu 1 (simbols)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -42,7 +45,7 @@ msgstr "NederÄ«ga ievade %i (nav padota) izteikumÄ"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr ""
+msgstr "'self' nevar izmantot, jo instance ir 'null' (nav padota)"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
@@ -58,11 +61,11 @@ msgstr "NederÄ«gs nosaukts indekss '%s' bÄzes tipam %s"
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr "Nderīgs arguments, lai izveidotu '%s'"
+msgstr "Nederīgs arguments, lai izveidotu '%s'"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr ""
+msgstr "'%s' izsaukumÄ:"
#: core/ustring.cpp
msgid "B"
@@ -98,7 +101,7 @@ msgstr "Bezmaksas"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
-msgstr "Balancēts"
+msgstr "Balansēts"
#: editor/animation_bezier_editor.cpp
msgid "Mirror"
@@ -114,97 +117,96 @@ msgstr "Vērtība:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr "Ievadiet vērtību šeit"
+msgstr "Ievadiet Atslēgu Šeit"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
-msgstr "DublikÄta VÄ“rtÄ«bas"
+msgstr "Izveidot DublikÄtu IzvÄ“lÄ“tajai(Äm) AtslÄ“gai(Äm)"
#: editor/animation_bezier_editor.cpp
msgid "Delete Selected Key(s)"
-msgstr "IzdzÄ“st izvÄ“lÄ“to(Äs) vÄ“rtÄ«bu(as)?"
+msgstr "IzdzÄ“st IzvÄ“lÄ“to(Äs) AtslÄ“gu(as)"
#: editor/animation_bezier_editor.cpp
msgid "Add Bezier Point"
-msgstr ""
+msgstr "Pievienot Bezjē Punktu"
#: editor/animation_bezier_editor.cpp
msgid "Move Bezier Points"
-msgstr ""
+msgstr "PÄrvietot BezjÄ“ Punktus"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
-msgstr ""
+msgstr "Anim Izveidot AtslÄ“gu DublikÄtu"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Delete Keys"
-msgstr ""
+msgstr "Anim Izdzēst Atslēgas"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Time"
-msgstr ""
+msgstr "Anim Izmainīt Atslēgkadra Laiku"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transition"
-msgstr ""
+msgstr "Anim IzmainÄ«t PÄreju"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transform"
-msgstr ""
+msgstr "Anim IzmainÄ«t TransformÄciju"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Value"
-msgstr ""
+msgstr "Anim Izmainīt Atslēgkadra Vērtību"
#: editor/animation_track_editor.cpp
msgid "Anim Change Call"
-msgstr ""
+msgstr "Anim Izmainīt Izsaukumu"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Keyframe Time"
-msgstr ""
+msgstr "Anim VairÄkkÄrt IzmainÄ«t AtslÄ“gkadra Laiku"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Transition"
-msgstr ""
+msgstr "Anim VairÄkkÄrt IzmainÄ«t PÄreju"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Transform"
-msgstr ""
+msgstr "Anim VairÄkkÄrt IzmainÄ«t TransformÄciju"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Keyframe Value"
-msgstr ""
+msgstr "Anim VairÄkkÄrt IzmainÄ«t AtslÄ“gkadra VÄ“rtÄ«bu"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Call"
-msgstr ""
+msgstr "Anim VairÄkkÄrt IzmainÄ«t Izsaukumu"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Length"
-msgstr "AnimÄciju Cilpa"
+msgstr "IzmainÄ«t AnimÄcijas Garumu"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation Loop"
-msgstr ""
+msgstr "IzmainÄ«t AnimÄcijas AtkÄrtoÅ¡anos"
#: editor/animation_track_editor.cpp
msgid "Property Track"
-msgstr ""
+msgstr "Mainīgo Celiņš"
#: editor/animation_track_editor.cpp
msgid "3D Transform Track"
-msgstr ""
+msgstr "3D TransformÄcijas Celiņš"
#: editor/animation_track_editor.cpp
msgid "Call Method Track"
-msgstr ""
+msgstr "Izsaukt Metožu Celiņu"
#: editor/animation_track_editor.cpp
msgid "Bezier Curve Track"
-msgstr ""
+msgstr "Bezjē Līkņu Celiņš"
#: editor/animation_track_editor.cpp
msgid "Audio Playback Track"
@@ -215,14 +217,12 @@ msgid "Animation Playback Track"
msgstr "AnimÄcijas atskaņoÅ¡anas celiņs"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (frames)"
-msgstr "AnimÄcijas Garums (sekundes)"
+msgstr "AnimÄcijas garums (kadri)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (seconds)"
-msgstr "AnimÄcijas Garums (sekundes)"
+msgstr "AnimÄcijas garums (sekundes)"
#: editor/animation_track_editor.cpp
msgid "Add Track"
@@ -247,15 +247,15 @@ msgstr "AnimÄcijas klipi:"
#: editor/animation_track_editor.cpp
msgid "Change Track Path"
-msgstr ""
+msgstr "Izmainīt Ceļu uz Celiņa"
#: editor/animation_track_editor.cpp
msgid "Toggle this track on/off."
-msgstr ""
+msgstr "PÄrslÄ“gt Å¡o celiņu ieslÄ“gts/izslÄ“gts."
#: editor/animation_track_editor.cpp
msgid "Update Mode (How this property is set)"
-msgstr ""
+msgstr "AtjaunoÅ¡anas Režīms (KÄ Å¡is mainÄ«gais tiek iestatÄ«ts)"
#: editor/animation_track_editor.cpp
msgid "Interpolation Mode"
@@ -263,7 +263,7 @@ msgstr "InterpolÄcijas režīms"
#: editor/animation_track_editor.cpp
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
-msgstr ""
+msgstr "AtkÄrtoÅ¡anÄs AptÄ«Å¡anas Režīms (InterpolÄ“ beigas ar cilpas sÄkumu)"
#: editor/animation_track_editor.cpp
msgid "Remove this track."
@@ -275,7 +275,7 @@ msgstr "Laiks (s): "
#: editor/animation_track_editor.cpp
msgid "Toggle Track Enabled"
-msgstr ""
+msgstr "PÄrslÄ“gt Celiņu uz IespÄ“jotu"
#: editor/animation_track_editor.cpp
msgid "Continuous"
@@ -308,16 +308,16 @@ msgstr "Kubisks"
#: editor/animation_track_editor.cpp
msgid "Clamp Loop Interp"
-msgstr ""
+msgstr "Apgriezt Cilpas InterpolÄciju"
#: editor/animation_track_editor.cpp
msgid "Wrap Loop Interp"
-msgstr ""
+msgstr "AptÄ«t Cilpas InterpolÄciju"
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key"
-msgstr "Ievietot atslēgievietni"
+msgstr "Ievietot Atslēgu"
#: editor/animation_track_editor.cpp
msgid "Duplicate Key(s)"
@@ -328,23 +328,20 @@ msgid "Delete Key(s)"
msgstr "Izdzēst atslēgvietnes"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Update Mode"
-msgstr "AnimÄcijas tÄlummaiņa."
+msgstr "IzmainÄ«t AnimÄcijas AtjaunoÅ¡anas Režīmu"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Interpolation Mode"
-msgstr "InterpolÄcijas režīms"
+msgstr "IzmainÄ«t AnimÄcijas InterpolÄcijas Režīmu"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Loop Mode"
-msgstr "AnimÄcijas tÄlummaiņa."
+msgstr "IzmainÄ«t AnimÄcijas AtkÄrtoÅ¡anÄs Režīmu"
#: editor/animation_track_editor.cpp
msgid "Remove Anim Track"
-msgstr "Noņemt animÄcijas celiņu"
+msgstr "Noņemt Anim. Celiņu"
#: editor/animation_track_editor.cpp
msgid "Create NEW track for %s and insert key?"
@@ -372,33 +369,31 @@ msgstr "Anim ievietot"
#: editor/animation_track_editor.cpp
msgid "AnimationPlayer can't animate itself, only other players."
-msgstr "AnimationPlayer nevar animÄ“t pats sevi, tikai citi spÄ“lÄ“tÄji."
+msgstr "AnimationPlayer nevar animÄ“t pats sevi, tikai citus spÄ“lÄ“tÄjus."
#: editor/animation_track_editor.cpp
msgid "Anim Create & Insert"
-msgstr "Anim izveidot un ievietot"
+msgstr "Anim Izveidot un Ievietot"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Track & Key"
-msgstr "Anim ievietot celiņu un atslēgvietni"
+msgstr "Anim Ievietot Celiņu un Atslēgu"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Key"
-msgstr "Anim ievietot atslēgievietni"
+msgstr "Anim Ievietot Atslēgu"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Step"
-msgstr "AnimÄcijas tÄlummaiņa."
+msgstr "IzmainÄ«t AnimÄcijas Soli"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Rearrange Tracks"
-msgstr "Ielīmēt celiņus"
+msgstr "PÄrkÄrtot Celiņus"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr ""
+msgstr "TransformÄcijas celiņi tiek tikai pievienoti TelpiskajÄm mezgliem."
#: editor/animation_track_editor.cpp
msgid ""
@@ -407,7 +402,7 @@ msgid ""
"-AudioStreamPlayer2D\n"
"-AudioStreamPlayer3D"
msgstr ""
-"Audio celiņu var tikai rÄdÄ«t uz Å¡Äda tipa mezgliem:\n"
+"Audio celiņu var tikai norÄdÄ«t uz Å¡Äda tipa mezgliem:\n"
"-AudioStreamPlayer\n"
"-AudioStreamPlayer2D\n"
"-AudioStreamPlayer3D"
@@ -426,47 +421,43 @@ msgstr "Nevar izveidot jaunu celiņu bez saknes"
#: editor/animation_track_editor.cpp
msgid "Invalid track for Bezier (no suitable sub-properties)"
-msgstr ""
+msgstr "Neatbilstošs celiņš priekš Bezjē (nav piemērotu apakš-mainīgo)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Bezier Track"
-msgstr "Pievienot celiņu"
+msgstr "Pievienot Bezjē Celiņu"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a key."
-msgstr ""
+msgstr "Ceļš uz Celiņu nav derÄ«gs, tÄpÄ“c nevar pievienot atslÄ“gu."
#: editor/animation_track_editor.cpp
msgid "Track is not of type Spatial, can't insert key"
-msgstr ""
+msgstr "Celiņš nepieder Telpiskajam tipam, nevar ievietot atslēgu"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Transform Track Key"
-msgstr "Anim ievietot celiņu un atslēgvietni"
+msgstr "Pievienot AtslÄ“gu TransformÄcijas Celiņam"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Track Key"
-msgstr "Pievienot celiņu"
+msgstr "Pievienot Celiņa Atslēgu"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a method key."
-msgstr ""
+msgstr "Ceļš uz Celiņu nav derÄ«gs, tÄpÄ“c nevar pievienot metodes atslÄ“gu."
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Method Track Key"
-msgstr "Anim ievietot celiņu un atslēgvietni"
+msgstr "Pievienot Celiņa Metodes Atslēgu"
#: editor/animation_track_editor.cpp
msgid "Method not found in object: "
-msgstr "Metode netika atrasta objektÄ: "
+msgstr "Metode objektÄ netika atrasta: "
#: editor/animation_track_editor.cpp
msgid "Anim Move Keys"
-msgstr "Anim pÄrvietot atslÄ“gievietnes"
+msgstr "Anim PÄrvietot AtslÄ“gas"
#: editor/animation_track_editor.cpp
msgid "Clipboard is empty"
@@ -478,12 +469,12 @@ msgstr "Ielīmēt celiņus"
#: editor/animation_track_editor.cpp
msgid "Anim Scale Keys"
-msgstr "Anim pÄrvietot atslÄ“gievietnes"
+msgstr "Anim Mainīt Atslēgas Izmēru"
#: editor/animation_track_editor.cpp
msgid ""
"This option does not work for Bezier editing, as it's only a single track."
-msgstr ""
+msgstr "Å Ä« iespÄ“ja nestrÄdÄ ar BazjÄ“ rediģēšanu, jo tai ir tikai viens celiņš."
#: editor/animation_track_editor.cpp
msgid ""
@@ -497,14 +488,24 @@ msgid ""
"Alternatively, use an import preset that imports animations to separate "
"files."
msgstr ""
+"Å Ä« animÄcija pieder importÄ“tajai ainai, tÄpÄ“c importÄ“tÄ celiņa izmaiņas "
+"netiks saglabÄtas.\n"
+"\n"
+"Lai iespÄ“jotu pielÄgotu celiņu pievienoÅ¡anu, atrodiet ainu importÄ“Å¡anas "
+"iespÄ“jas un iestÄdiet\n"
+"\"Animation > Storage\" uz \"Files\", iespējojiet \"Animation > Keep Custom "
+"Tracks\", tad nospiediet 're-import'.\n"
+"AlternatÄ«vi, izmantojiet 'import preset', kas importÄ“ animÄcijas uz "
+"atsevišķiem failiem."
#: editor/animation_track_editor.cpp
msgid "Warning: Editing imported animation"
-msgstr ""
+msgstr "BrÄ«dinÄjums: Rediģējat importÄ“to animÄciju"
#: editor/animation_track_editor.cpp
msgid "Select an AnimationPlayer node to create and edit animations."
msgstr ""
+"IzvÄ“lieties 'AnimationPlayer' mezglu, lai izveidotu un rediģētu animÄcijas."
#: editor/animation_track_editor.cpp
msgid "Only show tracks from nodes selected in tree."
@@ -516,9 +517,8 @@ msgstr ""
"SagrupÄ“t celiņus atkarÄ«bÄ no mezgliem vai rÄdÄ«t tos vienkÄrÅ¡Ä sarakstÄ."
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Snap:"
-msgstr "Solis (s): "
+msgstr "Pievilkt:"
#: editor/animation_track_editor.cpp
msgid "Animation step value."
@@ -526,11 +526,11 @@ msgstr "AnimÄcijas soļa vÄ“rtÄ«ba."
#: editor/animation_track_editor.cpp
msgid "Seconds"
-msgstr ""
+msgstr "Sekundes"
#: editor/animation_track_editor.cpp
msgid "FPS"
-msgstr ""
+msgstr "FPS"
#: editor/animation_track_editor.cpp editor/editor_properties.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
@@ -560,7 +560,7 @@ msgstr "Skala No Kursora"
#: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp
msgid "Duplicate Selection"
-msgstr "DublikÄta IzvÄ“le"
+msgstr "Izveidot DublikÄtu IzvÄ“lÄ“tajam"
#: editor/animation_track_editor.cpp
msgid "Duplicate Transposed"
@@ -571,14 +571,12 @@ msgid "Delete Selection"
msgstr "Dzēst izvēlētos"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Go to Next Step"
-msgstr "Doties uz nÄkamo soli"
+msgstr "Doties uz NÄkamo Soli"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Go to Previous Step"
-msgstr "Doties uz iepriekšējo soli"
+msgstr "Doties uz Iepriekšējo Soli"
#: editor/animation_track_editor.cpp
msgid "Optimize Animation"
@@ -586,7 +584,7 @@ msgstr "OptimizÄ“t animÄciju"
#: editor/animation_track_editor.cpp
msgid "Clean-Up Animation"
-msgstr ""
+msgstr "IztÄ«rÄ«Å¡anas AnimÄcija"
#: editor/animation_track_editor.cpp
msgid "Pick the node that will be animated:"
@@ -594,7 +592,7 @@ msgstr "IzvÄ“lies mezglu, kurÄ tiks animÄ“ta:"
#: editor/animation_track_editor.cpp
msgid "Use Bezier Curves"
-msgstr ""
+msgstr "Izmanto Bezjē Līknes"
#: editor/animation_track_editor.cpp
msgid "Anim. Optimizer"
@@ -602,15 +600,15 @@ msgstr "Anim. OptimizÄ“tÄjs"
#: editor/animation_track_editor.cpp
msgid "Max. Linear Error:"
-msgstr ""
+msgstr "Maks. LineÄrÄ Kļūda:"
#: editor/animation_track_editor.cpp
msgid "Max. Angular Error:"
-msgstr ""
+msgstr "Maks. RotÄcijas Kļūda:"
#: editor/animation_track_editor.cpp
msgid "Max Optimizable Angle:"
-msgstr ""
+msgstr "Max. Optimizējamais Leņķis:"
#: editor/animation_track_editor.cpp
msgid "Optimize"
@@ -618,23 +616,23 @@ msgstr "Optimizēt"
#: editor/animation_track_editor.cpp
msgid "Remove invalid keys"
-msgstr ""
+msgstr "Noņemt nederÄ«gÄs atslÄ“gas"
#: editor/animation_track_editor.cpp
msgid "Remove unresolved and empty tracks"
-msgstr ""
+msgstr "Noņemt neatrisinÄtos un nedefinÄ“tos celiņus"
#: editor/animation_track_editor.cpp
msgid "Clean-up all animations"
-msgstr ""
+msgstr "IztÄ«rÄ«t visas animÄcijas"
#: editor/animation_track_editor.cpp
msgid "Clean-Up Animation(s) (NO UNDO!)"
-msgstr ""
+msgstr "IztÄ«rÄ«t AnimÄciju(as) (NEATGRIEZENISKI!)"
#: editor/animation_track_editor.cpp
msgid "Clean-Up"
-msgstr ""
+msgstr "Iztīrit"
#: editor/animation_track_editor.cpp
msgid "Scale Ratio:"
@@ -642,7 +640,7 @@ msgstr "Mēroga Attiecība:"
#: editor/animation_track_editor.cpp
msgid "Select Tracks to Copy"
-msgstr ""
+msgstr "Izvēlēties Celiņus ko Kopēt"
#: editor/animation_track_editor.cpp editor/editor_log.cpp
#: editor/editor_properties.cpp
@@ -651,33 +649,31 @@ msgstr ""
#: editor/plugins/sprite_frames_editor_plugin.cpp editor/property_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Copy"
-msgstr ""
+msgstr "Kopēt"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Select All/None"
-msgstr "Dzēst izvēlētos"
+msgstr "Izvēlēties Visus/Nevienu"
#: editor/animation_track_editor_plugins.cpp
-#, fuzzy
msgid "Add Audio Track Clip"
-msgstr "Audio klipi:"
+msgstr "Pievienot Audio Celiņa Klipu"
#: editor/animation_track_editor_plugins.cpp
msgid "Change Audio Track Clip Start Offset"
-msgstr ""
+msgstr "MainÄ«t Audio Celiņa ApgrieÅ¡anas SÄkuma KompensÄciju"
#: editor/animation_track_editor_plugins.cpp
msgid "Change Audio Track Clip End Offset"
-msgstr ""
+msgstr "MainÄ«t Audio Celiņa ApgrieÅ¡anas Beigu KompensÄciju"
#: editor/array_property_edit.cpp
msgid "Resize Array"
-msgstr ""
+msgstr "Mainīt Masīva Lielumu"
#: editor/array_property_edit.cpp
msgid "Change Array Value Type"
-msgstr ""
+msgstr "Mainīt Masīva Vērtības Tipu"
#: editor/array_property_edit.cpp
msgid "Change Array Value"
@@ -705,11 +701,11 @@ msgstr "%d sakritības."
#: editor/code_editor.cpp editor/find_in_files.cpp
msgid "Match Case"
-msgstr ""
+msgstr "Atrast Gadījumu"
#: editor/code_editor.cpp editor/find_in_files.cpp
msgid "Whole Words"
-msgstr ""
+msgstr "Visu VÄrdu"
#: editor/code_editor.cpp editor/rename_dialog.cpp
msgid "Replace"
@@ -730,13 +726,13 @@ msgstr "Standarts"
#: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp
msgid "Toggle Scripts Panel"
-msgstr ""
+msgstr "PÄrslÄ“gt Skriptu Paneli"
#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom In"
-msgstr "PietuvinÄt"
+msgstr "PalielinÄt"
#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
@@ -746,44 +742,43 @@ msgstr "AttÄlinÄt"
#: editor/code_editor.cpp
msgid "Reset Zoom"
-msgstr "AtiestatÄ«t tÄlummaiņu"
+msgstr "AtiestatÄ«t TÄlummaiņu"
#: editor/code_editor.cpp
msgid "Warnings"
-msgstr ""
+msgstr "BrÄ«dinÄjumi"
#: editor/code_editor.cpp
msgid "Line and column numbers."
-msgstr ""
+msgstr "Rindu un kolonnu numuri."
#: editor/connections_dialog.cpp
msgid "Method in target node must be specified."
-msgstr ""
+msgstr "Metodi mÄ“rÄ·a mezglÄ nepiecieÅ¡ams specificÄ“t."
#: editor/connections_dialog.cpp
msgid ""
"Target method not found. Specify a valid method or attach a script to the "
"target node."
msgstr ""
+"Mērķa metode netika atrasta. Specificējiet derīgu metodi vai pievienojiet "
+"skriptu mērķa mezglam."
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Connect to Node:"
-msgstr "Savienot"
+msgstr "Savienot ar Mezglu:"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Connect to Script:"
-msgstr "Savieno SignÄlu:"
+msgstr "Savieno ar Skriptu:"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "From Signal:"
-msgstr "Savieno SignÄlu:"
+msgstr "No SignÄla:"
#: editor/connections_dialog.cpp
msgid "Scene does not contain any script."
-msgstr ""
+msgstr "Aina nesatur skriptu."
#: editor/connections_dialog.cpp editor/editor_autoload_settings.cpp
#: editor/groups_editor.cpp editor/plugins/item_list_editor_plugin.cpp
@@ -804,48 +799,45 @@ msgstr "Noņemt"
#: editor/connections_dialog.cpp
msgid "Add Extra Call Argument:"
-msgstr ""
+msgstr "Pievienot Ekstra Izsaukuma Argumentu:"
#: editor/connections_dialog.cpp
msgid "Extra Call Arguments:"
-msgstr ""
+msgstr "Ekstra Izsaukuma Argumenti:"
#: editor/connections_dialog.cpp
msgid "Receiver Method:"
-msgstr ""
+msgstr "Saņemšanas Metode:"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Advanced"
-msgstr "Balancēts"
+msgstr "Papildus"
#: editor/connections_dialog.cpp
msgid "Deferred"
-msgstr ""
+msgstr "Atlikts"
#: editor/connections_dialog.cpp
msgid ""
"Defers the signal, storing it in a queue and only firing it at idle time."
-msgstr ""
+msgstr "Atliek signÄlu, glabÄjot to rindÄ, un to izstaro tikai dÄ«kstÄvÄ“."
#: editor/connections_dialog.cpp
msgid "Oneshot"
-msgstr ""
+msgstr "Vienreiz"
#: editor/connections_dialog.cpp
msgid "Disconnects the signal after its first emission."
-msgstr ""
+msgstr "Atvieno signÄlu pÄ“c tÄ pirmÄs izstaroÅ¡anas."
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Cannot connect signal"
-msgstr "Savieno SignÄlu:"
+msgstr "Nevar savienot signÄlu"
#: editor/connections_dialog.cpp editor/dependency_editor.cpp
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -861,9 +853,8 @@ msgid "Connect"
msgstr "Savienot"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Signal:"
-msgstr "SignÄli"
+msgstr "SignÄls:"
#: editor/connections_dialog.cpp
msgid "Connect '%s' to '%s'"
@@ -874,32 +865,30 @@ msgid "Disconnect '%s' from '%s'"
msgstr "Atvienot '%s' no '%s'"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Disconnect all from signal: '%s'"
-msgstr "Atvienot '%s' no '%s'"
+msgstr "Atvienot visus no signÄla: '%s'"
#: editor/connections_dialog.cpp
msgid "Connect..."
-msgstr ""
+msgstr "Savieno..."
#: editor/connections_dialog.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Disconnect"
-msgstr ""
+msgstr "Atvieno"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Connect a Signal to a Method"
-msgstr "Savieno SignÄlu:"
+msgstr "Savienot SignÄlu ar Metodi"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Edit Connection:"
-msgstr "Savieno SignÄlu:"
+msgstr "Izmainīt Savienojumu:"
#: editor/connections_dialog.cpp
msgid "Are you sure you want to remove all connections from the \"%s\" signal?"
msgstr ""
+"Vai esat droÅ¡s(Å¡a), ka vÄ“laties noņemt visus savienojumus no \"%s\" signÄla?"
#: editor/connections_dialog.cpp editor/editor_help.cpp editor/node_dock.cpp
msgid "Signals"
@@ -908,18 +897,19 @@ msgstr "SignÄli"
#: editor/connections_dialog.cpp
msgid "Are you sure you want to remove all connections from this signal?"
msgstr ""
+"Vai esat droÅ¡s(Å¡a), ka vÄ“laties noņemt visus savienojumus no Å¡Ä« signÄla?"
#: editor/connections_dialog.cpp
msgid "Disconnect All"
-msgstr ""
+msgstr "Atvienot Visu"
#: editor/connections_dialog.cpp
msgid "Edit..."
-msgstr ""
+msgstr "Rediģēt..."
#: editor/connections_dialog.cpp
msgid "Go To Method"
-msgstr ""
+msgstr "Doties Uz Metodi"
#: editor/create_dialog.cpp
msgid "Change %s Type"
@@ -952,7 +942,7 @@ msgstr "Meklēt:"
#: editor/property_selector.cpp editor/quick_open.cpp
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Matches:"
-msgstr ""
+msgstr "Sakritības:"
#: editor/create_dialog.cpp editor/editor_plugin_settings.cpp
#: editor/plugin_config_dialog.cpp
@@ -964,28 +954,32 @@ msgstr "Apraksts:"
#: editor/dependency_editor.cpp
msgid "Search Replacement For:"
-msgstr ""
+msgstr "MeklÄ“t AizstÄjÄ“ju PriekÅ¡:"
#: editor/dependency_editor.cpp
msgid "Dependencies For:"
-msgstr ""
+msgstr "Atkarības Priekš:"
#: editor/dependency_editor.cpp
msgid ""
"Scene '%s' is currently being edited.\n"
"Changes will only take effect when reloaded."
msgstr ""
+"Aina '%s' pašlaik tiek rediģēta.\n"
+"Izmaiņas stÄsies spÄ“kÄ, kad tÄ tiks pÄrlÄdÄ“ta."
#: editor/dependency_editor.cpp
msgid ""
"Resource '%s' is in use.\n"
"Changes will only take effect when reloaded."
msgstr ""
+"Resurss '%s' tiek izmantots.\n"
+"Izmaiņas stÄsies spÄ“kÄ, kad tas tiks pÄrlÄdÄ“ts."
#: editor/dependency_editor.cpp
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Dependencies"
-msgstr ""
+msgstr "Atkarības"
#: editor/dependency_editor.cpp
msgid "Resource"
@@ -994,23 +988,23 @@ msgstr "Resurs"
#: editor/dependency_editor.cpp editor/editor_autoload_settings.cpp
#: editor/project_manager.cpp editor/project_settings_editor.cpp
msgid "Path"
-msgstr ""
+msgstr "Ceļš"
#: editor/dependency_editor.cpp
msgid "Dependencies:"
-msgstr ""
+msgstr "Atkarības:"
#: editor/dependency_editor.cpp
msgid "Fix Broken"
-msgstr ""
+msgstr "Labot Salauzto"
#: editor/dependency_editor.cpp
msgid "Dependency Editor"
-msgstr ""
+msgstr "Atkarību Redaktors"
#: editor/dependency_editor.cpp
msgid "Search Replacement Resource:"
-msgstr ""
+msgstr "MeklÄ“t AizstÄjÄ“ja Resursu:"
#: editor/dependency_editor.cpp editor/editor_file_dialog.cpp
#: editor/editor_help_search.cpp editor/editor_node.cpp
@@ -1028,7 +1022,7 @@ msgstr "Īpašnieki:"
#: editor/dependency_editor.cpp
msgid "Remove selected files from the project? (Can't be restored)"
-msgstr ""
+msgstr "Vai noņemt izvēlētos failus no projekta? (Netiks atjaunoti)"
#: editor/dependency_editor.cpp
msgid ""
@@ -1049,9 +1043,8 @@ msgid "Error loading:"
msgstr "Kļūme lÄdÄ“jot:"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid "Load failed due to missing dependencies:"
-msgstr "Ainu nevarÄ“ja ielÄdÄ“t dēļ neatrastiem dependencÄ«em:"
+msgstr "IelÄdÄ“Å¡ana apturÄ“ta, jo trÅ«kst ceļu uz pamata failiem:"
#: editor/dependency_editor.cpp editor/editor_node.cpp
msgid "Open Anyway"
@@ -1062,9 +1055,8 @@ msgid "Which action should be taken?"
msgstr "Kuru darbību izdarīt?"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid "Fix Dependencies"
-msgstr "Salabot dependecīju"
+msgstr "Salabot Atkarības"
#: editor/dependency_editor.cpp
msgid "Errors loading!"
@@ -1072,16 +1064,15 @@ msgstr "Kļūmes lÄdÄ“jot!"
#: editor/dependency_editor.cpp
msgid "Permanently delete %d item(s)? (No undo!)"
-msgstr ""
+msgstr "Vai neatgriezeniski izdzēst %d priekšmetu(us)? (NEATGRIEZENISKI!)"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid "Show Dependencies"
-msgstr "Salabot dependecīju"
+msgstr "RÄdÄ«t Ceļus uz Pamata Failiem"
#: editor/dependency_editor.cpp
msgid "Orphan Resource Explorer"
-msgstr ""
+msgstr "BÄreņu Resursu PÄrlÅ«ks"
#: editor/dependency_editor.cpp editor/editor_audio_buses.cpp
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
@@ -1097,15 +1088,15 @@ msgstr "Pieder"
#: editor/dependency_editor.cpp
msgid "Resources Without Explicit Ownership:"
-msgstr ""
+msgstr "Resursi Bez Skaidra Īpašnieka:"
#: editor/dictionary_property_edit.cpp
msgid "Change Dictionary Key"
-msgstr ""
+msgstr "MainÄ«t VÄrdnÄ«cas AtslÄ“gu"
#: editor/dictionary_property_edit.cpp
msgid "Change Dictionary Value"
-msgstr ""
+msgstr "MainÄ«t VÄrdnÄ«cas VÄ“rtÄ«bu"
#: editor/editor_about.cpp
msgid "Thanks from the Godot community!"
@@ -1168,22 +1159,20 @@ msgid "License"
msgstr "Licence"
#: editor/editor_about.cpp
-#, fuzzy
msgid "Third-party Licenses"
-msgstr "TreÅ¡Äs partijas Licence"
+msgstr "TreÅ¡Äs partijas Licences"
#: editor/editor_about.cpp
-#, fuzzy
msgid ""
"Godot Engine relies on a number of third-party free and open source "
"libraries, all compatible with the terms of its MIT license. The following "
"is an exhaustive list of all such third-party components with their "
"respective copyright statements and license terms."
msgstr ""
-"Godot DzinÄ“js paļaujas uz citiem treÅ¡Äs partijas brÄ«vajÄm un atvÄ“rtÄ avota "
-"bibliotÄ“kÄm, kuri visi sader ar to MIT licences nosacÄ«jumiem. SekojoÅ¡ais ir "
-"saraksts ar Å¡Ä«m treÅ¡Äs partijas komponentÄ“m ar to autortiesÄ«bu apgalvojumiem "
-"un licences nosacījumiem."
+"Godot Konstruktors paļaujas uz citiem treÅ¡Äs partijas brÄ«vajÄm un atvÄ“rtÄ "
+"avota bibliotÄ“kÄm, kuras ir saderÄ«gas ar to MIT licences nosacÄ«jumiem. "
+"SekojoÅ¡ais ir saraksts ar Å¡Ä«m treÅ¡Äs partijas komponentÄ“m ar to autortiesÄ«bu "
+"apgalvojumiem un licences nosacījumiem."
#: editor/editor_about.cpp
msgid "All Components"
@@ -1198,38 +1187,37 @@ msgid "Licenses"
msgstr "Licences"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
-#, fuzzy
msgid "Error opening package file, not in ZIP format."
-msgstr "Kļūme atverot arhÄ«vu failu, nav ZIP formÄtÄ."
+msgstr "Kļūda atverot failu arhÄ«vu, nav ZIP formÄtÄ."
#: editor/editor_asset_installer.cpp
msgid "%s (Already Exists)"
-msgstr ""
+msgstr "%s (Jau Eksistē)"
#: editor/editor_asset_installer.cpp
msgid "Uncompressing Assets"
-msgstr ""
+msgstr "Nekompresēti Līdzekļi"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "The following files failed extraction from package:"
-msgstr ""
+msgstr "Sekojošie faili netika izvilkti no paketes:"
#: editor/editor_asset_installer.cpp
msgid "And %s more files."
-msgstr ""
+msgstr "Un %s vēl faili."
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "Package installed successfully!"
-msgstr ""
+msgstr "Pakete instalēta sekmīgi!"
#: editor/editor_asset_installer.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Success!"
-msgstr "IzdevÄs!"
+msgstr "MÄ“rÄ·is sasniegts!"
#: editor/editor_asset_installer.cpp
msgid "Package Contents:"
-msgstr ""
+msgstr "Paketes Saturs:"
#: editor/editor_asset_installer.cpp editor/editor_node.cpp
msgid "Install"
@@ -1237,7 +1225,7 @@ msgstr "Ieinstalēt"
#: editor/editor_asset_installer.cpp
msgid "Package Installer"
-msgstr ""
+msgstr "Paketes InstalÄ“tÄjs"
#: editor/editor_audio_buses.cpp
msgid "Speakers"
@@ -1257,47 +1245,47 @@ msgstr "Nomainīt Audio Kopnes Skaļumu"
#: editor/editor_audio_buses.cpp
msgid "Toggle Audio Bus Solo"
-msgstr ""
+msgstr "PÄrslÄ“gt Audio Busa Solo"
#: editor/editor_audio_buses.cpp
msgid "Toggle Audio Bus Mute"
-msgstr ""
+msgstr "PÄrslÄ“gt Audio Busa ApklusinÄÅ¡anu"
#: editor/editor_audio_buses.cpp
msgid "Toggle Audio Bus Bypass Effects"
-msgstr ""
+msgstr "PÄrslÄ“gt Audio Busa Å untÄ“Å¡anas Efektu"
#: editor/editor_audio_buses.cpp
msgid "Select Audio Bus Send"
-msgstr ""
+msgstr "Izvēlēties Audio Busa Sūtīšanu"
#: editor/editor_audio_buses.cpp
msgid "Add Audio Bus Effect"
-msgstr ""
+msgstr "Pievienot Audio Busa Efektu"
#: editor/editor_audio_buses.cpp
msgid "Move Bus Effect"
-msgstr ""
+msgstr "PÄrvietot Busa Efektu"
#: editor/editor_audio_buses.cpp
msgid "Delete Bus Effect"
-msgstr ""
+msgstr "Izdzēst Busa Efektu"
#: editor/editor_audio_buses.cpp
msgid "Drag & drop to rearrange."
-msgstr ""
+msgstr "Velc un atlaid, lai pÄrkÄrtotu."
#: editor/editor_audio_buses.cpp
msgid "Solo"
-msgstr ""
+msgstr "Solo"
#: editor/editor_audio_buses.cpp
msgid "Mute"
-msgstr ""
+msgstr "ApklusinÄt"
#: editor/editor_audio_buses.cpp
msgid "Bypass"
-msgstr ""
+msgstr "Å unts"
#: editor/editor_audio_buses.cpp
msgid "Bus options"
@@ -1306,7 +1294,7 @@ msgstr "Kopnes iestatījumi"
#: editor/editor_audio_buses.cpp editor/filesystem_dock.cpp
#: editor/plugins/animation_player_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "Duplicate"
-msgstr ""
+msgstr "Izveidot DublikÄtu"
#: editor/editor_audio_buses.cpp
msgid "Reset Volume"
@@ -1369,9 +1357,8 @@ msgid "Invalid file, not an audio bus layout."
msgstr ""
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Error saving file: %s"
-msgstr "Kļūmes lÄdÄ“jot!"
+msgstr "Kļūda saglabÄjot failu: %s"
#: editor/editor_audio_buses.cpp
msgid "Add Bus"
@@ -1420,25 +1407,18 @@ msgid "Valid characters:"
msgstr "Derīgie simboli:"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Must not collide with an existing engine class name."
msgstr ""
-"Nederīgs nosaukums. Nedrīkst sadurties ar eksistējošu dzinēja klases "
-"nosaukumu."
+"Nosaukums nedrÄ«kst bÅ«t vienÄds ar eksistÄ“joÅ¡u konstruktora klases nosaukumu."
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Must not collide with an existing built-in type name."
-msgstr ""
-"Nederīgs nosaukums. Nedrīkst sadurties ar eksistējošu iebūvēto tipa "
-"nosaukumu."
+msgstr "Nosaukums nedrÄ«kst bÅ«t vienÄds ar eksistÄ“joÅ¡u iebÅ«vÄ“ta tipa nosaukumu."
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Must not collide with an existing global constant name."
msgstr ""
-"Nederīgs nosaukums. Nedrīkst sadurties ar eksistējošu dzinēja klases "
-"nosaukumu."
+"Nosaukums nedrÄ«kst bÅ«t vienÄds ar eksistÄ“joÅ¡u globÄlo konstantes nosaukumu."
#: editor/editor_autoload_settings.cpp
msgid "Keyword cannot be used as an autoload name."
@@ -1472,17 +1452,8 @@ msgstr "Iespējot"
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Nederīgs nosaukums."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -1617,9 +1588,8 @@ msgid "On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."
msgstr ""
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "3D Editor"
-msgstr "Rediģēt"
+msgstr "3D Redaktors"
#: editor/editor_feature_profile.cpp
msgid "Script Editor"
@@ -1666,23 +1636,20 @@ msgid "(Properties Disabled)"
msgstr ""
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "(Editor Disabled)"
-msgstr "Atspējots"
+msgstr "(Redaktors Izslēgts)"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Class Options:"
-msgstr "Apraksts:"
+msgstr "Klases Iespējas:"
#: editor/editor_feature_profile.cpp
msgid "Enable Contextual Editor"
msgstr ""
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Enabled Properties:"
-msgstr "AnimÄcijas Ä«paÅ¡Ä«bas."
+msgstr "Ieslēgtie Mainīgie:"
#: editor/editor_feature_profile.cpp
msgid "Enabled Features:"
@@ -1703,9 +1670,8 @@ msgid ""
msgstr ""
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Error saving profile to path: '%s'."
-msgstr "Kļūmes lÄdÄ“jot!"
+msgstr "Kļūda saglabÄjot profilu uz ceļu: '%s'."
#: editor/editor_feature_profile.cpp
msgid "Unset"
@@ -1716,9 +1682,8 @@ msgid "Current Profile:"
msgstr ""
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Make Current"
-msgstr "Izveidot Funkciju"
+msgstr "Aktualizēt"
#: editor/editor_feature_profile.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
@@ -1736,14 +1701,12 @@ msgid "Export"
msgstr ""
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Available Profiles:"
-msgstr "AnimÄcijas Ä«paÅ¡Ä«bas."
+msgstr "Pieejamie Profili:"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Class Options"
-msgstr "Apraksts:"
+msgstr "Klases Iespējas"
#: editor/editor_feature_profile.cpp
msgid "New profile name:"
@@ -1778,18 +1741,16 @@ msgid "File Exists, Overwrite?"
msgstr ""
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Select This Folder"
-msgstr "Izvēlēties šo Mapi"
+msgstr "Izvēlēties Šo Mapi"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "Copy Path"
msgstr ""
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-#, fuzzy
msgid "Open in File Manager"
-msgstr "Atvērt"
+msgstr "AtvÄ“rt Failu PÄrlÅ«kÄ"
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
#: editor/filesystem_dock.cpp editor/project_manager.cpp
@@ -1877,23 +1838,20 @@ msgid "Move Favorite Down"
msgstr ""
#: editor/editor_file_dialog.cpp
-#, fuzzy
msgid "Go to previous folder."
-msgstr "Doties uz iepriekšējo soli"
+msgstr "Doties uz iepriekšējo mapi."
#: editor/editor_file_dialog.cpp
-#, fuzzy
msgid "Go to next folder."
-msgstr "Doties uz nÄkamo soli"
+msgstr "Doties uz nÄkamo mapi."
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Go to parent folder."
msgstr ""
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Refresh files."
-msgstr "Meklēt:"
+msgstr "Atjaunot failus."
#: editor/editor_file_dialog.cpp
msgid "(Un)favorite current folder."
@@ -1961,9 +1919,8 @@ msgid "Inherited by:"
msgstr ""
#: editor/editor_help.cpp
-#, fuzzy
msgid "Description"
-msgstr "Apraksts:"
+msgstr "Apraksts"
#: editor/editor_help.cpp
msgid "Online Tutorials"
@@ -1978,9 +1935,8 @@ msgid "override:"
msgstr ""
#: editor/editor_help.cpp
-#, fuzzy
msgid "default:"
-msgstr "IelÄdÄ“t NoklusÄ“jumu"
+msgstr "pēc noklusējuma:"
#: editor/editor_help.cpp
msgid "Methods"
@@ -1999,9 +1955,8 @@ msgid "Constants"
msgstr ""
#: editor/editor_help.cpp
-#, fuzzy
msgid "Property Descriptions"
-msgstr "Apraksts:"
+msgstr "Mainīgo Apraksts"
#: editor/editor_help.cpp
msgid "(value)"
@@ -2014,9 +1969,8 @@ msgid ""
msgstr ""
#: editor/editor_help.cpp
-#, fuzzy
msgid "Method Descriptions"
-msgstr "Apraksts:"
+msgstr "Metožu Apraksts"
#: editor/editor_help.cpp
msgid ""
@@ -2050,9 +2004,8 @@ msgid "Methods Only"
msgstr ""
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Signals Only"
-msgstr "SignÄli"
+msgstr "Tikai SignÄli"
#: editor/editor_help_search.cpp
msgid "Constants Only"
@@ -2079,9 +2032,8 @@ msgid "Method"
msgstr ""
#: editor/editor_help_search.cpp editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Signal"
-msgstr "SignÄli"
+msgstr "SignÄls"
#: editor/editor_help_search.cpp editor/plugins/theme_editor_plugin.cpp
msgid "Constant"
@@ -2112,9 +2064,8 @@ msgid "Output:"
msgstr ""
#: editor/editor_log.cpp editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Copy Selection"
-msgstr "Noņemt Izvēlēto"
+msgstr "Kopēt Izvēlēto"
#: editor/editor_log.cpp editor/editor_network_profiler.cpp
#: editor/editor_profiler.cpp editor/editor_properties.cpp
@@ -2350,9 +2301,8 @@ msgid "Open Base Scene"
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Quick Open..."
-msgstr "Atvērt"
+msgstr "Ātri Atvērt..."
#: editor/editor_node.cpp
msgid "Quick Open Scene..."
@@ -2423,11 +2373,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Atvērt Aizvērto Ainu"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2473,9 +2426,8 @@ msgid "Close Scene"
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Reopen Closed Scene"
-msgstr "Atjaunina Ainu"
+msgstr "Atvērt Aizvērto Ainu"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
@@ -2568,14 +2520,12 @@ msgid "Play This Scene"
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Close Tab"
-msgstr "Aizvērt"
+msgstr "Aizvērt Cilni"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Undo Close Tab"
-msgstr "Aizvērt"
+msgstr "Atcelt Cilnes Aizvēršanu"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
msgid "Close Other Tabs"
@@ -2586,9 +2536,8 @@ msgid "Close Tabs to the Right"
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Close All Tabs"
-msgstr "Aizvērt"
+msgstr "Aizvērt Visas Cilnes"
#: editor/editor_node.cpp
msgid "Switch Scene Tab"
@@ -2631,9 +2580,8 @@ msgid "Go to previously opened scene."
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Copy Text"
-msgstr "Noņemt Izvēlēto"
+msgstr "Kopēt Tekstu"
#: editor/editor_node.cpp
msgid "Next tab"
@@ -2672,9 +2620,8 @@ msgid "Save Scene"
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Save All Scenes"
-msgstr "SaglabÄt KÄ"
+msgstr "SaglabÄt Visas Ainas"
#: editor/editor_node.cpp
msgid "Convert To..."
@@ -2699,10 +2646,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -2736,9 +2679,8 @@ msgid "Install Android Build Template..."
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Open Project Data Folder"
-msgstr "Projekta DibinÄtÄji"
+msgstr "Atvērt Projekta Datu Mapi"
#: editor/editor_node.cpp editor/plugins/tile_set_editor_plugin.cpp
msgid "Tools"
@@ -2905,11 +2847,11 @@ msgstr ""
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
msgid "Community"
-msgstr ""
+msgstr "Sabiedrība"
#: editor/editor_node.cpp
msgid "About"
-msgstr ""
+msgstr "Par"
#: editor/editor_node.cpp
msgid "Play the project."
@@ -2961,9 +2903,8 @@ msgid "Spins when the editor window redraws."
msgstr ""
#: editor/editor_node.cpp
-#, fuzzy
msgid "Update Continuously"
-msgstr "NepÄrtraukti"
+msgstr "NepÄrtraukti Atjaunot"
#: editor/editor_node.cpp
msgid "Update When Changed"
@@ -3093,9 +3034,8 @@ msgid "Thumbnail..."
msgstr ""
#: editor/editor_plugin_settings.cpp
-#, fuzzy
msgid "Main Script:"
-msgstr "Savieno SignÄlu:"
+msgstr "Galvenais Skripts:"
#: editor/editor_plugin_settings.cpp
msgid "Edit Plugin"
@@ -3167,9 +3107,8 @@ msgid "Calls"
msgstr ""
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Edit Text:"
-msgstr "Savieno SignÄlu:"
+msgstr "Rediģēt Tekstu:"
#: editor/editor_properties.cpp editor/script_create_dialog.cpp
msgid "On"
@@ -3192,9 +3131,8 @@ msgid "Assign..."
msgstr ""
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Invalid RID"
-msgstr "Nederīgs nosaukums."
+msgstr "Nederīgs RID"
#: editor/editor_properties.cpp
msgid ""
@@ -3313,6 +3251,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3437,9 +3379,8 @@ msgid "Download Complete."
msgstr ""
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Cannot remove temporary file:"
-msgstr "Nevar noņemt:"
+msgstr "Nevar noņemt pagaidu failu:"
#: editor/export_template_manager.cpp
msgid ""
@@ -3448,9 +3389,8 @@ msgid ""
msgstr ""
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Error requesting URL:"
-msgstr "Kļūme lÄdÄ“jot:"
+msgstr "Kļūda pieprasot URL:"
#: editor/export_template_manager.cpp
msgid "Connecting to Mirror..."
@@ -3519,9 +3459,8 @@ msgid "Remove Template"
msgstr ""
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Select Template File"
-msgstr "Izvēlēties šo Mapi"
+msgstr "Izvēlēties Šablona Failu"
#: editor/export_template_manager.cpp
msgid "Godot Export Templates"
@@ -3540,9 +3479,8 @@ msgid "Select mirror from list: (Shift+Click: Open in Browser)"
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Favorites"
-msgstr "Favorīti:"
+msgstr "Favorīti"
#: editor/filesystem_dock.cpp
msgid "Status: Import of file failed. Please fix file and reimport manually."
@@ -3605,28 +3543,24 @@ msgid "New Inherited Scene"
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Set As Main Scene"
-msgstr "SaglabÄt KÄ"
+msgstr "IestatÄ«t KÄ Galveno Ainu"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Open Scenes"
-msgstr "Atjaunina Ainu"
+msgstr "Atvērt Ainas"
#: editor/filesystem_dock.cpp
msgid "Instance"
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Add to Favorites"
-msgstr "Favorīti:"
+msgstr "Pievienot Favorītiem"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Remove from Favorites"
-msgstr "Favorīti:"
+msgstr "Noņemt no Favorītiem"
#: editor/filesystem_dock.cpp
msgid "Edit Dependencies..."
@@ -3649,18 +3583,16 @@ msgid "Move To..."
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Scene..."
-msgstr "Resurs"
+msgstr "Jauna Aina..."
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
msgid "New Script..."
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Resource..."
-msgstr "Resurs"
+msgstr "Jauns Resurss..."
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
@@ -3680,14 +3612,12 @@ msgid "Rename"
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Previous Folder/File"
-msgstr "Izvēlēties šo Mapi"
+msgstr "IepriekÅ¡Ä“jÄ Mape/Fails"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Next Folder/File"
-msgstr "Izvēlēties šo Mapi"
+msgstr "NÄkamÄ Mape/Fails"
#: editor/filesystem_dock.cpp
msgid "Re-Scan Filesystem"
@@ -3698,9 +3628,8 @@ msgid "Toggle Split Mode"
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Search files"
-msgstr "Meklēt:"
+msgstr "Meklēt failus"
#: editor/filesystem_dock.cpp
msgid ""
@@ -3721,18 +3650,16 @@ msgid "Overwrite"
msgstr ""
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Create Scene"
-msgstr "Izveidot"
+msgstr "Izveidot Ainu"
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
msgid "Create Script"
msgstr ""
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Find in Files"
-msgstr "Nederīgs nosaukums."
+msgstr "Atrast Failos"
#: editor/find_in_files.cpp
msgid "Find:"
@@ -3770,18 +3697,16 @@ msgid "Find: "
msgstr ""
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Replace: "
-msgstr "Aizvietot"
+msgstr "Aizvietot: "
#: editor/find_in_files.cpp
msgid "Replace all (no undo)"
msgstr ""
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Searching..."
-msgstr "Meklēt:"
+msgstr "Meklē..."
#: editor/find_in_files.cpp
msgid "Search complete"
@@ -3800,19 +3725,16 @@ msgid "Group name already exists."
msgstr ""
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Invalid group name."
-msgstr "Nederīgs nosaukums."
+msgstr "Nederīgs grupas nosaukums."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Rename Group"
-msgstr "PÄrsaukt Audio Kopni"
+msgstr "PÄrsaukt Grupu"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Delete Group"
-msgstr "Izdzēst"
+msgstr "Izdzēst Grupu"
#: editor/groups_editor.cpp editor/node_dock.cpp
msgid "Groups"
@@ -3836,9 +3758,8 @@ msgid "Empty groups will be automatically removed."
msgstr ""
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Group Editor"
-msgstr "Rediģēt"
+msgstr "Grupas Redaktors"
#: editor/groups_editor.cpp
msgid "Manage Groups"
@@ -3918,13 +3839,16 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
#: editor/import_dock.cpp
-#, fuzzy
msgid "%d Files"
-msgstr "Nederīgs nosaukums."
+msgstr "%d FailÄ"
#: editor/import_dock.cpp
msgid "Set as Default for '%s'"
@@ -3939,9 +3863,8 @@ msgid "Import As:"
msgstr ""
#: editor/import_dock.cpp
-#, fuzzy
msgid "Preset"
-msgstr "AtiestatÄ«t tÄlummaiņu"
+msgstr "Sagatave"
#: editor/import_dock.cpp
msgid "Reimport"
@@ -4075,16 +3998,14 @@ msgstr ""
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Create Polygon"
-msgstr "Izveidot"
+msgstr "Izveidot Daudzstūri"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Create points."
-msgstr "Izveidot"
+msgstr "Izveidot punktus."
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid ""
@@ -4099,9 +4020,8 @@ msgid "Erase points."
msgstr ""
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Edit Polygon"
-msgstr "Izveidot"
+msgstr "Rediģēt Daudzstūri"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid "Insert Point"
@@ -4127,9 +4047,8 @@ msgstr ""
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Load..."
-msgstr "IelÄdÄ“t"
+msgstr "IelÄdÄ“..."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4152,15 +4071,13 @@ msgstr ""
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Node Point"
-msgstr "Favorīti:"
+msgstr "Pievienot Mezgla Punktu"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Animation Point"
-msgstr "AnimÄciju Cilpa"
+msgstr "Pievienot AnimÄcijas Punktu"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Remove BlendSpace1D Point"
@@ -4209,18 +4126,16 @@ msgstr ""
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Open Animation Node"
-msgstr "AnimÄcijas tÄlummaiņa."
+msgstr "AtvÄ“rt AnimÄcijas Mezglu"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Triangle already exists."
msgstr ""
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Triangle"
-msgstr "Pievienot celiņu"
+msgstr "Pievienot Trijstūri"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Change BlendSpace2D Limits"
@@ -4295,9 +4210,8 @@ msgstr ""
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Nodes Connected"
-msgstr "Savienot"
+msgstr "Mezgli Savienoti"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
@@ -4305,15 +4219,13 @@ msgid "Nodes Disconnected"
msgstr ""
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Set Animation"
-msgstr "OptimizÄ“t animÄciju"
+msgstr "IestatÄ«t AnimÄciju"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Delete Node"
-msgstr "Izdzēst"
+msgstr "Izdzēst Mezglu"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/scene_tree_dock.cpp
@@ -4325,9 +4237,8 @@ msgid "Toggle Filter On/Off"
msgstr ""
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Change Filter"
-msgstr "Nomainīt"
+msgstr "Nomainīt Filtru"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "No animation player set, so unable to retrieve track names."
@@ -4345,19 +4256,16 @@ msgid ""
msgstr ""
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Anim Clips"
-msgstr "AnimÄcijas klipi:"
+msgstr "Anim. Klipi"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Audio Clips"
-msgstr "Audio klipi:"
+msgstr "Audio Klipi"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Functions"
-msgstr "Funkcijas:"
+msgstr "Funkcijas"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
@@ -4375,9 +4283,8 @@ msgid "Edit Filtered Tracks:"
msgstr ""
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Enable Filtering"
-msgstr "Nomainīt"
+msgstr "Ieslēgt Filtrēšanu"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Toggle Autoplay"
@@ -4406,9 +4313,8 @@ msgid "Remove Animation"
msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Invalid animation name!"
-msgstr "Nederīgs nosaukums."
+msgstr "NederÄ«gs animÄcijas nosaukums!"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Animation name already exists!"
@@ -4436,9 +4342,8 @@ msgid "Duplicate Animation"
msgstr ""
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "No animation to copy!"
-msgstr "AnimÄcijas tÄlummaiņa."
+msgstr "Nav animÄcijas ko kopÄ“t!"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "No animation resource on clipboard!"
@@ -4592,14 +4497,12 @@ msgid "Move Node"
msgstr ""
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Transition exists!"
-msgstr "Pievienot celiņu"
+msgstr "PÄreja eksistÄ“!"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Add Transition"
-msgstr "Pievienot celiņu"
+msgstr "Pievienot PÄreju"
#: editor/plugins/animation_state_machine_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
@@ -4635,9 +4538,8 @@ msgid "No playback resource set at path: %s."
msgstr ""
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Node Removed"
-msgstr "Noņemt"
+msgstr "Mezgls Noņemts"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Transition Removed"
@@ -4655,19 +4557,16 @@ msgid ""
msgstr ""
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Create new nodes."
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot jaunus mezglus."
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Connect nodes."
-msgstr "Savienot"
+msgstr "Savienot mezglus."
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Remove selected node or transition."
-msgstr "Noņemt Izvēlēto"
+msgstr "Noņemt izvÄ“lÄ“to mezglu vai pÄreju."
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Toggle autoplay this animation on start, restart or seek to zero."
@@ -4682,9 +4581,8 @@ msgid "Transition: "
msgstr ""
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Play Mode:"
-msgstr "Mēroga Attiecība:"
+msgstr "Atskaņošanas Režīms:"
#: editor/plugins/animation_tree_editor_plugin.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -4860,9 +4758,8 @@ msgid "Request failed."
msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Cannot save response to:"
-msgstr "Nevar noņemt:"
+msgstr "Nevar saglabÄt atbildi uz:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Write error."
@@ -4925,9 +4822,8 @@ msgid "Idle"
msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Install..."
-msgstr "Ieinstalēt"
+msgstr "Instalēt..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Retry"
@@ -4958,14 +4854,12 @@ msgid "Name (Z-A)"
msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "License (A-Z)"
-msgstr "Licence"
+msgstr "Licence (A-Z)"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "License (Z-A)"
-msgstr "Licence"
+msgstr "Licence (Z-A)"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "First"
@@ -5025,9 +4919,8 @@ msgid "Testing"
msgstr ""
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Loading..."
-msgstr "IelÄdÄ“t"
+msgstr "IelÄdÄ“t..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Assets ZIP File"
@@ -5088,37 +4981,32 @@ msgid "Rotation Step:"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Scale Step:"
-msgstr "Mēroga Attiecība:"
+msgstr "Mainīt Soļa Mērogu:"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Move Vertical Guide"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Create Vertical Guide"
-msgstr "Izveidot"
+msgstr "Izveidot VertikÄlu Vadotni"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Remove Vertical Guide"
-msgstr "Noņemt Izvēlēto"
+msgstr "Noņemt VertikÄlo Vadotni"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Move Horizontal Guide"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Create Horizontal Guide"
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot HorizontÄlu Vadotni"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Remove Horizontal Guide"
-msgstr "Noņemt Izvēlēto"
+msgstr "Noņemt HorizontÄlo Vadotni"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Create Horizontal and Vertical Guides"
@@ -5201,18 +5089,16 @@ msgid "Center"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Left Wide"
-msgstr "LineÄrs"
+msgstr "Pa Kreisi, Plašs"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Top Wide"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Right Wide"
-msgstr "LineÄrs"
+msgstr "Pa labi, Plašs"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Bottom Wide"
@@ -5231,9 +5117,8 @@ msgid "Full Rect"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Keep Ratio"
-msgstr "Mēroga Attiecība:"
+msgstr "Ievērot Attiecību"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Anchors only"
@@ -5273,24 +5158,21 @@ msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Group Selected"
-msgstr "Noņemt Izvēlēto"
+msgstr "Grupa Izvēlēta"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Ungroup Selected"
-msgstr "Noņemt Izvēlēto"
+msgstr "PÄrtraukt IzvÄ“lÄ“tÄ GrupÄ“Å¡anu"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Paste Pose"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Clear Guides"
-msgstr "Izveidot"
+msgstr "Notīrīt Vadotnes"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Create Custom Bone(s) from Node(s)"
@@ -5317,9 +5199,8 @@ msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
-#, fuzzy
msgid "Zoom Reset"
-msgstr "AttÄlinÄt"
+msgstr "AtiestatÄ«t TuvinÄjumu"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5354,9 +5235,8 @@ msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Scale Mode"
-msgstr "Mēroga Attiecība:"
+msgstr "Mēroga Režīms"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5374,9 +5254,8 @@ msgid "Pan Mode"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Ruler Mode"
-msgstr "Mēroga Attiecība:"
+msgstr "LineÄla Režīms"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Toggle smart snapping."
@@ -5553,14 +5432,12 @@ msgid ""
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Auto Insert Key"
-msgstr "Anim ievietot atslēgievietni"
+msgstr "AutomÄtiski Ievietot AtslÄ“gu"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Animation Key and Pose Options"
-msgstr "AnimÄcijas Garums (sekundes)"
+msgstr "AnimÄcijas AtslÄ“ga un Pozas IestatÄ«jumi"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key (Existing Tracks)"
@@ -5609,9 +5486,8 @@ msgid "Error instancing scene from %s"
msgstr ""
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Change Default Type"
-msgstr "Nomainīt %s Tipu"
+msgstr "Nomainīt Noklusējuma Tipu"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid ""
@@ -5620,9 +5496,8 @@ msgid ""
msgstr ""
#: editor/plugins/collision_polygon_editor_plugin.cpp
-#, fuzzy
msgid "Create Polygon3D"
-msgstr "Izveidot"
+msgstr "Izveidot Daudzstūris3D"
#: editor/plugins/collision_polygon_editor_plugin.cpp
msgid "Edit Poly"
@@ -5741,29 +5616,24 @@ msgid "Load Curve Preset"
msgstr ""
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Add Point"
-msgstr "Favorīti:"
+msgstr "Pievienot Punktu"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Remove Point"
-msgstr "Noņemt Izvēlēto"
+msgstr "Noņemt Punktu"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Left Linear"
-msgstr "LineÄrs"
+msgstr "Pa Kreisi, LineÄrs"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Right Linear"
-msgstr "LineÄrs"
+msgstr "Pa Labi, LineÄrs"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Load Preset"
-msgstr "IelÄdÄ“t NoklusÄ“jumu"
+msgstr "IelÄdÄ“t Sagatavi"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Remove Curve Point"
@@ -5834,9 +5704,8 @@ msgid "Couldn't create a single convex collision shape."
msgstr ""
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Single Convex Shape"
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot Vienu Izliektu Formu"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Can't create multiple convex collision shapes for the scene root."
@@ -5847,9 +5716,8 @@ msgid "Couldn't create any collision shapes."
msgstr ""
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Multiple Convex Shapes"
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot VairÄkas Izliektas Formas"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Navigation Mesh"
@@ -5917,9 +5785,8 @@ msgid ""
msgstr ""
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Single Convex Collision Sibling"
-msgstr "Izveidot"
+msgstr "Izveidot Vienu Izliektu Sadursmes Uzmavu"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
@@ -5928,9 +5795,8 @@ msgid ""
msgstr ""
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Multiple Convex Collision Siblings"
-msgstr "Izveidot"
+msgstr "Izveidot VairÄkas Izliektas Sadursmes Uzmavas"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
@@ -6591,14 +6457,12 @@ msgid "Error saving file!"
msgstr "Kļūmes lÄdÄ“jot!"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error while saving theme."
-msgstr "Kļūmes lÄdÄ“jot!"
+msgstr "Kļūda saglabÄjot motÄ«vu."
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error Saving"
-msgstr "Kļūme lÄdÄ“jot:"
+msgstr "Kļūda SaglabÄjot"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
@@ -6606,9 +6470,8 @@ msgid "Error importing theme."
msgstr "Kļūda lÄdÄ“jot fontu."
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error Importing"
-msgstr "Kļūme lÄdÄ“jot:"
+msgstr "Kļūda Importējot"
#: editor/plugins/script_editor_plugin.cpp
msgid "New Text File..."
@@ -6620,9 +6483,8 @@ msgid "Open File"
msgstr "Atvērt"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Save File As..."
-msgstr "SaglabÄt KÄ"
+msgstr "SaglabÄt Failu KÄ..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Can't obtain the script for running."
@@ -6712,9 +6574,8 @@ msgid "File"
msgstr ""
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Open..."
-msgstr "Atvērt"
+msgstr "Atvērt..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Reopen Closed Script"
@@ -6835,9 +6696,8 @@ msgid "Debugger"
msgstr ""
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Search Results"
-msgstr "Meklēt:"
+msgstr "MeklÄ“Å¡anas RezultÄti"
#: editor/plugins/script_editor_plugin.cpp
msgid "Clear Recent Scripts"
@@ -6857,19 +6717,18 @@ msgid "Target"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid ""
"Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."
-msgstr "Atvienot '%s' no '%s'"
+msgstr ""
+"TrÅ«kst savienoÅ¡anas metode '%s' signÄlam '%s' no mezgla '%s' uz mezglu '%s'."
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Line"
-msgstr "Rinda:"
+msgid "[Ignore]"
+msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
+msgid "Line"
+msgstr "Rinda"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
@@ -7022,14 +6881,12 @@ msgid "Remove All Bookmarks"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Function..."
-msgstr "Izveidot Funkciju"
+msgstr "Doties uz Funkciju..."
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Line..."
-msgstr "Doties uz Rindu"
+msgstr "Doties uz Rindu..."
#: editor/plugins/script_text_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
@@ -7348,6 +7205,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -7700,9 +7566,8 @@ msgid "Loop"
msgstr ""
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Animation Frames:"
-msgstr "AnimÄcijas Ä«paÅ¡Ä«bas."
+msgstr "AnimÄcijas Kadri:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
#, fuzzy
@@ -7960,9 +7825,8 @@ msgid "Erase Selection"
msgstr ""
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Fix Invalid Tiles"
-msgstr "Nederīgs nosaukums."
+msgstr "Salabot NederÄ«gÄs FlÄ«zes"
#: editor/plugins/tile_map_editor_plugin.cpp
#: modules/gridmap/grid_map_editor_plugin.cpp
@@ -8053,9 +7917,8 @@ msgid "Add Texture(s) to TileSet."
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Remove selected Texture from TileSet."
-msgstr "Noņemt Izvēlēto"
+msgstr "Noņemt izvÄ“lÄ“tÄs TekstÅ«ras no Flīžu Komplekta."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Create from Scene"
@@ -8154,9 +8017,8 @@ msgid "Priority Mode"
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Icon Mode"
-msgstr "Mēroga Attiecība:"
+msgstr "Ikonu Režīms"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Z Index Mode"
@@ -8167,23 +8029,20 @@ msgid "Copy bitmask."
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Paste bitmask."
-msgstr "Ielīmēt celiņus"
+msgstr "Ielīmēt bitu masku."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Erase bitmask."
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create a new rectangle."
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot jaunu taisnstūri."
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create a new polygon."
-msgstr "Izveidot"
+msgstr "Izveidot jaunu daudzstūri."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Keep polygon inside region Rect."
@@ -8203,9 +8062,9 @@ msgid ""
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Remove selected texture? This will remove all tiles which use it."
-msgstr "Noņemt Izvēlēto"
+msgstr ""
+"Noņemt Izvēlēto tekstūru? Šī darbība noņems visas flīzes, kas to izmanto."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "You haven't selected a texture to remove."
@@ -8235,9 +8094,8 @@ msgid ""
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Delete selected Rect."
-msgstr "Izdzēst izvēlētos failus?"
+msgstr "Izdzēst izvēlēto Taisnstūri."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
@@ -8246,9 +8104,8 @@ msgid ""
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Delete polygon."
-msgstr "Izveidot"
+msgstr "Izdzēst daudzstūri."
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
@@ -8485,9 +8342,8 @@ msgid "(GLES3 only)"
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Add Output"
-msgstr "Favorīti:"
+msgstr "Pievienot Izeju"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Scalar"
@@ -8506,9 +8362,8 @@ msgid "Sampler"
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Add input port"
-msgstr "Favorīti:"
+msgstr "Pievienot ieejas pieslēgvietu"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Add output port"
@@ -8593,9 +8448,8 @@ msgid "Light"
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Show resulted shader code."
-msgstr "Izveidot Jaunu %s"
+msgstr "AttÄ“lot rezultÄ“joÅ¡o Ä“notÄja kodu."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -8603,18 +8457,16 @@ msgid "Create Shader Node"
msgstr "Izveidot Jaunu %s"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Color function."
-msgstr "Izveidot Funkciju"
+msgstr "KrÄsas funkcija."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Color operator."
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Grayscale function."
-msgstr "Izveidot Funkciju"
+msgstr "Pelēktoņu funkcija."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Converts HSV vector to RGB equivalent."
@@ -8625,9 +8477,8 @@ msgid "Converts RGB vector to HSV equivalent."
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Sepia function."
-msgstr "Izveidot Funkciju"
+msgstr "SÄ“pija funkcija."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Burn operator."
@@ -8780,9 +8631,8 @@ msgid "'%s' input parameter for vertex and fragment shader mode."
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar function."
-msgstr "Mēroga Izvēle"
+msgstr "SkalÄra funkcija."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Scalar operator."
@@ -9039,9 +8889,8 @@ msgid "2D texture uniform lookup with triplanar."
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Transform function."
-msgstr "Izveidot"
+msgstr "Transformēšanas funkcija."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9083,19 +8932,16 @@ msgid "Multiplies vector by transform."
msgstr ""
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Transform constant."
-msgstr "Izveidot"
+msgstr "Transformēt konstanti."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Transform uniform."
-msgstr "Izveidot"
+msgstr "Transformēt vienmērīgo."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Vector function."
-msgstr "Izveidot Funkciju"
+msgstr "Vektora funkcija."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector operator."
@@ -9305,9 +9151,8 @@ msgid "Runnable"
msgstr ""
#: editor/project_export.cpp
-#, fuzzy
msgid "Add initial export..."
-msgstr "Favorīti:"
+msgstr "Pievienot sÄkuma eksportu..."
#: editor/project_export.cpp
msgid "Add previous patches..."
@@ -10011,7 +9856,7 @@ msgstr ""
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
msgid "General"
-msgstr ""
+msgstr "VispÄrÄ“ji"
#: editor/project_settings_editor.cpp
msgid "Override For..."
@@ -10221,9 +10066,8 @@ msgid "Initial value for the counter"
msgstr ""
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Step"
-msgstr "Solis (ļi):"
+msgstr "Solis"
#: editor/rename_dialog.cpp
msgid "Amount by which counter is incremented for each node"
@@ -10277,9 +10121,8 @@ msgid "Regular Expression Error"
msgstr ""
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "At character %s"
-msgstr "Derīgie simboli:"
+msgstr "Pie rakstzīmes %s"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
msgid "Reparent Node"
@@ -10344,8 +10187,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Galvenais Skripts:"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10380,9 +10224,8 @@ msgid "Make node as Root"
msgstr ""
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete %d nodes?"
-msgstr "Izdzēst"
+msgstr "Izdzēst %d mezglus?"
#: editor/scene_tree_dock.cpp
msgid "Delete the root node \"%s\"?"
@@ -10393,9 +10236,8 @@ msgid "Delete node \"%s\" and its children?"
msgstr ""
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete node \"%s\"?"
-msgstr "Izdzēst"
+msgstr "Izdzēst mezglu \"%s\"?"
#: editor/scene_tree_dock.cpp
msgid "Can not perform with the root node."
@@ -10430,9 +10272,8 @@ msgid "New Scene Root"
msgstr ""
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Create Root Node:"
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot Cilmes Mezglu:"
#: editor/scene_tree_dock.cpp
msgid "2D Scene"
@@ -10506,6 +10347,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10543,9 +10391,8 @@ msgid "Delete (No Confirm)"
msgstr ""
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Add/Create a New Node."
-msgstr "Izveidot Jaunu %s"
+msgstr "Pievienot/Izveidot Jaunu Mezglu."
#: editor/scene_tree_dock.cpp
msgid ""
@@ -10554,11 +10401,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10586,9 +10433,8 @@ msgid "Button Group"
msgstr ""
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "(Connecting From)"
-msgstr "Savieno SignÄlu:"
+msgstr "(Savienojas No)"
#: editor/scene_tree_editor.cpp
msgid "Node configuration warning:"
@@ -10659,14 +10505,12 @@ msgid "Select a Node"
msgstr ""
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Path is empty."
-msgstr "Starpliktuve ir tukša"
+msgstr "Ceļš nav definēts."
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Filename is empty."
-msgstr "Starpliktuve ir tukša"
+msgstr "Faila Nosaukums nav definēts."
#: editor/script_create_dialog.cpp
msgid "Path is not local."
@@ -10682,6 +10526,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Nederīgs fonta izmērs."
@@ -10723,6 +10571,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Nederīgs ceļš."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid class name."
msgstr "Nederīgs nosaukums."
@@ -10744,9 +10596,8 @@ msgid "Built-in script (into scene file)."
msgstr ""
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Will create a new script file."
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidos jaunu skripta failu."
#: editor/script_create_dialog.cpp
#, fuzzy
@@ -10811,14 +10662,12 @@ msgid "C++ Source"
msgstr "Resurs"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Source:"
-msgstr "Resurs"
+msgstr "Avots:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "C++ Source:"
-msgstr "Resurs"
+msgstr "C++ Avots:"
#: editor/script_editor_debugger.cpp
msgid "Stack Trace"
@@ -10829,9 +10678,8 @@ msgid "Errors"
msgstr ""
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Child process connected."
-msgstr "Savienot"
+msgstr "BÄ“rna process savienots."
#: editor/script_editor_debugger.cpp
msgid "Copy Error"
@@ -11373,14 +11221,12 @@ msgid "Set Variable Type"
msgstr ""
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Input Port"
-msgstr "Favorīti:"
+msgstr "Pievienot Ieejas Pieslēgvietu"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Output Port"
-msgstr "Favorīti:"
+msgstr "Pievienot Izejas Pieslēgvietu"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
@@ -11390,27 +11236,24 @@ msgstr ""
"nosaukumu."
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create a new function."
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot jaunu funkciju."
#: modules/visual_script/visual_script_editor.cpp
msgid "Variables:"
msgstr ""
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create a new variable."
-msgstr "Izveidot Jaunu %s"
+msgstr "Izveidot jaunu mainīgo."
#: modules/visual_script/visual_script_editor.cpp
msgid "Signals:"
msgstr ""
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create a new signal."
-msgstr "Izveidot"
+msgstr "Izveidot jaunu signÄlu."
#: modules/visual_script/visual_script_editor.cpp
msgid "Name is not a valid identifier:"
@@ -11620,24 +11463,20 @@ msgid "Members:"
msgstr ""
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Change Base Type:"
-msgstr "Nomainīt %s Tipu"
+msgstr "NomainÄ«t BÄzes Tipu:"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Nodes..."
-msgstr "Favorīti:"
+msgstr "Pievienot Mezglus..."
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Function..."
-msgstr "Izveidot Funkciju"
+msgstr "Pievienot Funkciju..."
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "function_name"
-msgstr "Funkcijas:"
+msgstr "funkcijas_nosaukums"
#: modules/visual_script/visual_script_editor.cpp
msgid "Select or create a function to edit its graph."
@@ -11660,9 +11499,8 @@ msgid "Cut Nodes"
msgstr ""
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Make Function"
-msgstr "Funkcijas:"
+msgstr "Izveidot Funkciju"
#: modules/visual_script/visual_script_editor.cpp
msgid "Refresh Graph"
@@ -11779,6 +11617,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11797,9 +11639,34 @@ msgid "Invalid public key for APK expansion."
msgstr ""
#: platform/android/export/export.cpp
-#, fuzzy
msgid "Invalid package name:"
-msgstr "Nederīgs nosaukums."
+msgstr "Nederīgs paketes nosaukums:"
+
+#: platform/android/export/export.cpp
+msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
#: platform/android/export/export.cpp
msgid ""
@@ -11842,9 +11709,8 @@ msgid "App Store Team ID not specified - cannot configure the project."
msgstr ""
#: platform/iphone/export/export.cpp
-#, fuzzy
msgid "Invalid Identifier:"
-msgstr "Nederīgs fonta izmērs."
+msgstr "Nederīgs Identifikators:"
#: platform/iphone/export/export.cpp
msgid "Required icon is not specified in the preset."
@@ -12299,9 +12165,8 @@ msgid "On BlendTree node '%s', animation not found: '%s'"
msgstr ""
#: scene/animation/animation_blend_tree.cpp
-#, fuzzy
msgid "Animation not found: '%s'"
-msgstr "AnimÄcijas garums (sekundÄ“s)."
+msgstr "AnimÄcija netika atrasta: '%s'"
#: scene/animation/animation_tree.cpp
msgid "In node '%s', invalid animation: '%s'."
@@ -12313,9 +12178,8 @@ msgid "Invalid animation: '%s'."
msgstr "Nederīgs fonta izmērs."
#: scene/animation/animation_tree.cpp
-#, fuzzy
msgid "Nothing connected to input '%s' of node '%s'."
-msgstr "Atvienot '%s' no '%s'"
+msgstr "Nekas nav savienots ar ieeju '%s' mezglam '%s'."
#: scene/animation/animation_tree.cpp
msgid "No root AnimationNode for the graph is set."
@@ -12361,9 +12225,8 @@ msgid "Switch between hexadecimal and code values."
msgstr ""
#: scene/gui/color_picker.cpp
-#, fuzzy
msgid "Add current color as a preset."
-msgstr "Pievienot paÅ¡reizÄ“jo krÄsu kÄ iepriekÅ¡noteiktu krÄsu"
+msgstr "Pievienot paÅ¡reizÄ“jo krÄsu kÄ iepriekÅ¡noteiktu krÄsu."
#: scene/gui/container.cpp
msgid ""
diff --git a/editor/translations/mi.po b/editor/translations/mi.po
index 5c33f2e72e..fbf4bce3d6 100644
--- a/editor/translations/mi.po
+++ b/editor/translations/mi.po
@@ -807,7 +807,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1407,16 +1406,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2336,11 +2327,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2606,10 +2599,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3215,6 +3204,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3799,6 +3792,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6670,11 +6667,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7144,6 +7141,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10061,7 +10067,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10219,6 +10225,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10265,11 +10278,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10389,6 +10402,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10429,6 +10446,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11453,6 +11474,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11476,6 +11501,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/ml.po b/editor/translations/ml.po
index e46fd5a10d..77ac327f71 100644
--- a/editor/translations/ml.po
+++ b/editor/translations/ml.po
@@ -817,7 +817,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1417,16 +1416,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2348,11 +2339,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2618,10 +2611,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3227,6 +3216,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3811,6 +3804,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6686,11 +6683,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7160,6 +7157,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10077,7 +10083,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10235,6 +10241,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10281,11 +10294,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10405,6 +10418,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10445,6 +10462,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11470,6 +11491,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11493,6 +11518,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/mr.po b/editor/translations/mr.po
index 902c243d16..38e3ee7185 100644
--- a/editor/translations/mr.po
+++ b/editor/translations/mr.po
@@ -814,7 +814,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1414,16 +1413,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2343,11 +2334,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2613,10 +2606,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3222,6 +3211,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3806,6 +3799,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6677,11 +6674,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7151,6 +7148,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10068,7 +10074,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10226,6 +10232,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10272,11 +10285,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10396,6 +10409,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10436,6 +10453,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11460,6 +11481,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11483,6 +11508,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/ms.po b/editor/translations/ms.po
index 09e2bcc096..233b5cb428 100644
--- a/editor/translations/ms.po
+++ b/editor/translations/ms.po
@@ -837,7 +837,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1437,16 +1436,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2368,11 +2359,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2639,10 +2632,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3249,6 +3238,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3834,6 +3827,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6724,11 +6721,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7199,6 +7196,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10135,7 +10141,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10296,6 +10302,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10342,11 +10355,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10466,6 +10479,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10506,6 +10523,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11540,6 +11561,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11563,6 +11588,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/nb.po b/editor/translations/nb.po
index 34d6e9dc76..5c80321d03 100644
--- a/editor/translations/nb.po
+++ b/editor/translations/nb.po
@@ -19,8 +19,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-04-16 11:03+0000\n"
-"Last-Translator: Petter Reinholdtsen <pere-weblate@hungry.com>\n"
+"PO-Revision-Date: 2020-06-03 20:09+0000\n"
+"Last-Translator: Allan Nordhøy <epost@anotheragency.no>\n"
"Language-Team: Norwegian Bokmål <https://hosted.weblate.org/projects/godot-"
"engine/godot/nb_NO/>\n"
"Language: nb\n"
@@ -28,7 +28,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0.1-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -883,7 +883,6 @@ msgstr "Kobler Til Signal:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1527,18 +1526,9 @@ msgstr "Aktiver"
msgid "Rearrange Autoloads"
msgstr "Omorganiser Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Ugyldig Filsti."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Fil eksisterer ikke."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ikke i resource path."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2556,12 +2546,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Kan ikke laste en scene som aldri ble lagret."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "GÃ¥ tilbake"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Lagre Scene"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Denne handlingen kan ikke angres. GÃ¥ tilbake likevel?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2856,10 +2849,6 @@ msgid "Redo"
msgstr "Gjenta"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Tilbakestille Scene"
-
-#: editor/editor_node.cpp
#, fuzzy
msgid "Miscellaneous project or scene-wide tools."
msgstr "Diverse prosjekt- eller scene-relaterte verktøy"
@@ -3401,9 +3390,8 @@ msgid "Assign..."
msgstr "Tilordne..."
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Invalid RID"
-msgstr ": Ugyldige argumenter: "
+msgstr "Ugyldig RID"
#: editor/editor_properties.cpp
#, fuzzy
@@ -3533,6 +3521,10 @@ msgstr "Kunne ikke kjøre skript:"
msgid "Did you forget the '_run' method?"
msgstr "Glemte du '_run'-metoden?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Velg Node(r) for Importering"
@@ -3678,9 +3670,8 @@ msgid ""
msgstr ""
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Error requesting URL:"
-msgstr "Error ved forespørsel av url: "
+msgstr "Feil ved nettadresse-forespørsel:"
#: editor/export_template_manager.cpp
msgid "Connecting to Mirror..."
@@ -3772,9 +3763,8 @@ msgid "Download Templates"
msgstr "Last ned Mal"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Select mirror from list: (Shift+Click: Open in Browser)"
-msgstr "Velg fillager fra liste: "
+msgstr "Velg speil fra liste: (Shift+Klikk: Ã…pne i nettleser)"
#: editor/filesystem_dock.cpp
#, fuzzy
@@ -4027,14 +4017,12 @@ msgid "Cancel"
msgstr "Avbryt"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Find: "
-msgstr "Finn"
+msgstr "Finn: "
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Replace: "
-msgstr "Erstatt"
+msgstr "Erstatt: "
#: editor/find_in_files.cpp
#, fuzzy
@@ -4188,6 +4176,10 @@ msgid "Error running post-import script:"
msgstr "Error ved kjøring av post-import script:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Lagrer..."
@@ -5002,9 +4994,8 @@ msgid "Set the end animation. This is useful for sub-transitions."
msgstr ""
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Transition: "
-msgstr "Overgang"
+msgstr "Overgang: "
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
@@ -7313,15 +7304,15 @@ msgid ""
msgstr "Koble '%s' fra '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Linje:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Fjern Funksjon"
@@ -7816,6 +7807,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "Snap til rutenett"
@@ -10937,8 +10937,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Nytt Skript"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -11105,6 +11106,13 @@ msgid "Open Documentation"
msgstr "Ã…pne Godots nettbaserte dokumentasjon"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -11158,12 +11166,13 @@ msgstr ""
"finnes en rot-node."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Detach the script from the selected node."
+msgstr "Instanser den valgte scene(r) som barn av den valgte noden."
#: editor/scene_tree_dock.cpp
#, fuzzy
@@ -11293,6 +11302,10 @@ msgid "A directory with the same name exists."
msgstr "En fil eller mappe med dette navnet eksisterer allerede."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Fil eksisterer ikke."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "MÃ¥ ha en gyldig filutvidelse."
@@ -11338,6 +11351,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Ugyldig Filsti."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Ugyldig navn."
@@ -11403,7 +11421,7 @@ msgstr ""
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Remote "
-msgstr "Fjern Funksjon"
+msgstr "Fjern-funksjon "
#: editor/script_editor_debugger.cpp
msgid "Bytes:"
@@ -12440,6 +12458,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12464,6 +12486,32 @@ msgstr "Ugyldig navn."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12575,7 +12623,7 @@ msgstr "Prosjektnavn:"
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid publisher GUID."
-msgstr ": Ugyldige argumenter: "
+msgstr "Ugyldig forlags-GUID."
#: platform/uwp/export/export.cpp
#, fuzzy
@@ -13123,6 +13171,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Konstanter kan ikke endres."
+#~ msgid "Not in resource path."
+#~ msgstr "Ikke i resource path."
+
+#~ msgid "Revert"
+#~ msgstr "GÃ¥ tilbake"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Denne handlingen kan ikke angres. GÃ¥ tilbake likevel?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Tilbakestille Scene"
+
#~ msgid "Issue Tracker"
#~ msgstr "Problemtracker"
@@ -13369,10 +13429,6 @@ msgstr "Konstanter kan ikke endres."
#~ msgstr "Sett inn Nøkler"
#, fuzzy
-#~ msgid "Instance the selected scene(s) as child of the selected node."
-#~ msgstr "Instanser den valgte scene(r) som barn av den valgte noden."
-
-#, fuzzy
#~ msgid "Font Size:"
#~ msgstr "Frontvisning"
diff --git a/editor/translations/nl.po b/editor/translations/nl.po
index 93219f8bfc..8e6c4bcfa4 100644
--- a/editor/translations/nl.po
+++ b/editor/translations/nl.po
@@ -44,7 +44,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-04 15:12+0000\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
"Last-Translator: Stijn Hinlopen <f.a.hinlopen@gmail.com>\n"
"Language-Team: Dutch <https://hosted.weblate.org/projects/godot-engine/godot/"
"nl/>\n"
@@ -873,7 +873,6 @@ msgstr "Kan signaal niet verbinden"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1488,17 +1487,9 @@ msgstr "Inschakelen"
msgid "Rearrange Autoloads"
msgstr "Autoloads opnieuw ordenen"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Ongeldig pad."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Bestand bestaat niet."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Niet in bronpad."
+msgid "Can't add autoload:"
+msgstr "Autoload kon niet toevoegd worden:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2458,13 +2449,16 @@ msgid "Can't reload a scene that was never saved."
msgstr "Een scène die nooit opgeslagen is kan niet opnieuw laden worden."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Herstellen"
+msgid "Reload Saved Scene"
+msgstr "Opgeslagen scène herladen"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
-"Deze actie kan niet ongedaan gemaakt worden. WIlt u desondanks terugzetten?"
+"De huidige scène bevat niet opgeslagen veranderingen.\n"
+"Scène desondanks herladen? Dit kan niet ongedaan gemaakt worden."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2751,10 +2745,6 @@ msgid "Redo"
msgstr "Opnieuw"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Scène terugzetten"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Overig project of scène-brede hulpmiddelen."
@@ -3404,6 +3394,12 @@ msgstr "Script kon niet uitgevoerd worden:"
msgid "Did you forget the '_run' method?"
msgstr "Ben je de '_run' methode vergeten?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Houdt Ctrl ingedrukt om op gehele getallen af te ronden. Houdt Shift "
+"ingedrukt voor preciezere veranderingen."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selecteer een of meer knopen om te importeren"
@@ -4001,6 +3997,11 @@ msgid "Error running post-import script:"
msgstr "Fout bij uitvoeren post-import script:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+"Gaf je een van Node afstammend object terug in de `post_import()`-methode?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Opslaan..."
@@ -6955,12 +6956,12 @@ msgid ""
msgstr "Ontbrekende verbonden methode '%s' voor signaal '%s' naar knoop '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Regel"
+msgid "[Ignore]"
+msgstr "[Negeren]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(negeren)"
+msgid "Line"
+msgstr "Regel"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7435,6 +7436,20 @@ msgid "XForm Dialog"
msgstr "XForm Dialoog"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Klik om te wisselen tussen zichtbaarheidsweergaven.\n"
+"\n"
+"Open oog: handvat is zichtbaar.\n"
+"Gesloten oog: handvat is verborgen.\n"
+"Half open oog: handvat is ook zichtbaar door ondoorzichtige oppervlaktes."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Knopen aan vloer kleven"
@@ -10538,8 +10553,8 @@ msgid "Instance Child Scene"
msgstr "Scène instantiëren"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Script wissen"
+msgid "Detach Script"
+msgstr "Script losmaken"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10705,6 +10720,15 @@ msgid "Open Documentation"
msgstr "Open Godot online documentatie"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"Script kon niet aangebracht worden: er zijn geen talen ingesteld.\n"
+"Dit is waarschijnlijk omdat deze editor zonder taalmodules was gecompileerd."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Knoop hieronder toevoegen"
@@ -10753,12 +10777,12 @@ msgstr ""
"wortelknoop bestaat."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr "Verbind een nieuw of bestaand script aan de geselecteerde knoop."
+msgid "Attach a new or existing script to the selected node."
+msgstr "Een nieuw of bestaand script verbinden aan de geselecteerde knoop."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Script van geselecteerde knopen wissen."
+msgid "Detach the script from the selected node."
+msgstr "Script van geselecteerde knoop losmaken."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10889,6 +10913,10 @@ msgid "A directory with the same name exists."
msgstr "Een map met dezelfde naam bestaat al."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Bestand bestaat niet."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Ongeldige extentie."
@@ -10929,6 +10957,10 @@ msgid "File exists, it will be reused."
msgstr "Bestand Bestaat, zal hergebruikt worden."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Ongeldig pad."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Ongeldige klassenaam."
@@ -11978,6 +12010,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr "Debug Keystore is niet ingesteld of aanwezig in de Editor Settings."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr "Release-Keystore is verkeerd ingesteld in de exportinstelingen."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Eigen build vereist een geldige Android SDK pad in de Editorinstellingen."
@@ -12004,6 +12040,40 @@ msgstr "Ongeldige pakketnaam:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"Ongeldige \"GodotPaymentV3\" module ingesloten in de projectinstelling "
+"\"android/modules\" (veranderd in Godot 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr "\"Use Custom Build\" moet geactiveerd zijn om plugins te gebruiken."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"\"Degrees Of Freedom\" is alleen geldig als \"Xr Mode\" op \"Oculus Mobile VR"
+"\" staat."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Hand Tracking\" is alleen geldig als \"Xr Mode\" op \"Oculus Mobile VR\" "
+"staat."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Focus Awareness\" is alleen geldig als \"Xr Mode\" op \"Oculus Mobile VR\" "
+"staat."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12787,6 +12857,23 @@ msgstr "Varyings kunnen alleen worden toegewezenin vertex functies."
msgid "Constants cannot be modified."
msgstr "Constanten kunnen niet worden aangepast."
+#~ msgid "Not in resource path."
+#~ msgstr "Niet in bronpad."
+
+#~ msgid "Revert"
+#~ msgstr "Herstellen"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr ""
+#~ "Deze actie kan niet ongedaan gemaakt worden. WIlt u desondanks "
+#~ "terugzetten?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Scène terugzetten"
+
+#~ msgid "Clear Script"
+#~ msgstr "Script wissen"
+
#~ msgid "Issue Tracker"
#~ msgstr "Issue Tracker"
diff --git a/editor/translations/or.po b/editor/translations/or.po
index 2ce05efe5d..afff834dee 100644
--- a/editor/translations/or.po
+++ b/editor/translations/or.po
@@ -813,7 +813,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1413,16 +1412,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2342,11 +2333,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2612,10 +2605,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3221,6 +3210,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3805,6 +3798,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6676,11 +6673,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7150,6 +7147,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10067,7 +10073,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10225,6 +10231,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10271,11 +10284,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10395,6 +10408,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10435,6 +10452,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11459,6 +11480,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11482,6 +11507,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/pl.po b/editor/translations/pl.po
index a7b57f31ba..414e66685a 100644
--- a/editor/translations/pl.po
+++ b/editor/translations/pl.po
@@ -19,7 +19,7 @@
# NeverK <neverkoxu@gmail.com>, 2018, 2019.
# Rafal Brozio <rafal.brozio@gmail.com>, 2016, 2019.
# Rafał Ziemniak <synaptykq@gmail.com>, 2017.
-# RM <synaptykq@gmail.com>, 2018.
+# RM <synaptykq@gmail.com>, 2018, 2020.
# Sebastian Krzyszkowiak <dos@dosowisko.net>, 2017.
# Sebastian Pasich <sebastian.pasich@gmail.com>, 2017, 2019.
# siatek papieros <sbigneu@gmail.com>, 2016.
@@ -38,11 +38,12 @@
# Myver <igormakarowicz@gmail.com>, 2019.
# Maciej Chamera <chameramaciej@gmail.com>, 2019.
# Cezary Stasiak <cezary.p.stasiak@gmail.com>, 2019.
+# Jan Ligudziński <jan.ligudzinski@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-01 11:42+0000\n"
+"PO-Revision-Date: 2020-06-06 10:15+0000\n"
"Last-Translator: Tomek <kobewi4e@gmail.com>\n"
"Language-Team: Polish <https://hosted.weblate.org/projects/godot-engine/"
"godot/pl/>\n"
@@ -52,7 +53,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -177,11 +178,11 @@ msgstr "Usuń klucze animacji"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Time"
-msgstr "Zmiana czasu klatki kluczowej"
+msgstr "Zmień wartość czasu klatki kluczowej"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transition"
-msgstr "Zmiana przejścia"
+msgstr "Przejście zmiany animacji"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transform"
@@ -872,7 +873,6 @@ msgstr "Nie można połączyć sygnału"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1482,17 +1482,9 @@ msgstr "WÅ‚Ä…cz"
msgid "Rearrange Autoloads"
msgstr "Przestaw Autoloady"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Niepoprawna ścieżka."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Plik nie istnieje."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Nie znaleziono w ścieżce zasobów."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2448,12 +2440,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Nie można przeładować sceny która nie została zapisana."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Przywróć"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Zapisz scenÄ™"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Tego nie można cofnąć. Przywrócić mimo to?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2740,10 +2735,6 @@ msgid "Redo"
msgstr "Ponów"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Przywróć scenę"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Różne narzędzia dla scen lub projektu."
@@ -3111,7 +3102,7 @@ msgstr "Nowa dziedziczÄ…ca scena"
#: editor/editor_node.cpp
msgid "Load Errors"
-msgstr "Wczytaj błędy"
+msgstr "Błędy wczytywania"
#: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp
msgid "Select"
@@ -3386,6 +3377,13 @@ msgstr "Nie można uruchomić skryptu:"
msgid "Did you forget the '_run' method?"
msgstr "Zapomniano metody \"_run\"?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Przytrzymaj Ctrl, by upuścić pobieracz (Getter). Przytrzymaj Shift, by "
+"upuścić generyczną sygnaturę."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Wybierz węzły do importu"
@@ -3627,7 +3625,7 @@ msgstr ""
#: editor/filesystem_dock.cpp
msgid "Cannot move/rename resources root."
-msgstr "Nie można przenieść/zmienić nazwy źródłowego zasobu."
+msgstr "Nie można przenieść/zmienić nazwy korzenia zasobów."
#: editor/filesystem_dock.cpp
msgid "Cannot move a folder into itself."
@@ -3984,6 +3982,10 @@ msgid "Error running post-import script:"
msgstr "BÅ‚Ä…d podczas uruchamiania skryptu po imporcie:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Zapisywanie..."
@@ -5701,7 +5703,7 @@ msgstr "Edytuj wielokąt (usuń punkty)"
#: editor/plugins/collision_shape_2d_editor_plugin.cpp
msgid "Set Handle"
-msgstr "Ustaw Uchwyt"
+msgstr "Ustaw uchwyt"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
@@ -6936,12 +6938,13 @@ msgstr ""
"\"%s\"."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Linia"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(ignoruj)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignoruj)"
+msgid "Line"
+msgstr "Linia"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7415,6 +7418,15 @@ msgid "XForm Dialog"
msgstr "Okno dialogowe XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Przyciągnij węzły do podłogi"
@@ -10503,8 +10515,9 @@ msgid "Instance Child Scene"
msgstr "Dodaj instancjÄ™ sceny"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Usuń skrypt"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Dodaj skrypt"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10669,6 +10682,13 @@ msgid "Open Documentation"
msgstr "Otwórz dokumentację"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Dodaj węzeł"
@@ -10717,11 +10737,13 @@ msgstr ""
"główny nie istnieje."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Dołącz nowy lub istniejący skrypt do zaznaczonego węzła."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Wyczyść skrypt dla zaznaczonego węzła."
#: editor/scene_tree_dock.cpp
@@ -10853,6 +10875,10 @@ msgid "A directory with the same name exists."
msgstr "Katalog o tej nazwie już istnieje."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Plik nie istnieje."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Niepoprawne rozszerzenie."
@@ -10893,6 +10919,10 @@ msgid "File exists, it will be reused."
msgstr "Plik istnieje, zostanie użyty ponownie."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Niepoprawna ścieżka."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Niepoprawna nazwa klasy."
@@ -11939,6 +11969,13 @@ msgstr ""
"eksportu."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Debugowy keystore nieskonfigurowany w Ustawieniach Edytora ani w profilu "
+"eksportu."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Własny build wymaga poprawnej ścieżki do SDK Androida w Ustawieniach Edytora."
@@ -11967,6 +12004,32 @@ msgstr "Niepoprawna nazwa paczki:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12752,6 +12815,21 @@ msgstr "Varying może być przypisane tylko w funkcji wierzchołków."
msgid "Constants cannot be modified."
msgstr "Stałe nie mogą być modyfikowane."
+#~ msgid "Not in resource path."
+#~ msgstr "Nie znaleziono w ścieżce zasobów."
+
+#~ msgid "Revert"
+#~ msgstr "Przywróć"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Tego nie można cofnąć. Przywrócić mimo to?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Przywróć scenę"
+
+#~ msgid "Clear Script"
+#~ msgstr "Usuń skrypt"
+
#~ msgid "Issue Tracker"
#~ msgstr "Lista problemów"
diff --git a/editor/translations/pr.po b/editor/translations/pr.po
index 646d14c2cf..9d46edcbae 100644
--- a/editor/translations/pr.po
+++ b/editor/translations/pr.po
@@ -851,7 +851,6 @@ msgstr "Slit th' Node"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1461,17 +1460,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr ": Evil arguments: "
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2421,11 +2411,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Yar, Blow th' Selected Down!"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2696,10 +2689,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3319,6 +3308,13 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Smash yer Ctrl key t' sink yer Getter. Smash yer Shift t' sink a generic "
+"signature."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3931,6 +3927,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6890,11 +6890,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7380,6 +7380,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10400,8 +10409,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Discharge ye' Variable"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10562,6 +10572,13 @@ msgid "Open Documentation"
msgstr "Yer functions:"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10611,11 +10628,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10742,6 +10759,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Yer Calligraphy be wrongly sized."
@@ -10785,6 +10806,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr ": Evil arguments: "
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Yer unique name be evil."
@@ -11879,6 +11905,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11903,6 +11933,32 @@ msgstr "Yer unique name be evil."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/pt_BR.po b/editor/translations/pt_BR.po
index d38c4186c7..199d828897 100644
--- a/editor/translations/pt_BR.po
+++ b/editor/translations/pt_BR.po
@@ -88,12 +88,17 @@
# Lucas Araujo <lucassants2808@gmail.com>, 2020.
# Sr Half <flavio05@outlook.com>, 2020.
# Matheus Pesegoginski <pese.ek.tk@outlook.com>, 2020.
+# DeeJayLSP <djlsplays@gmail.com>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
+# André Sousa <andrelvsousa@gmail.com>, 2020.
+# Kleyton Luiz de Sousa Vieira <kleytonluizdesouzavieira@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: 2016-05-30\n"
-"PO-Revision-Date: 2020-05-04 15:12+0000\n"
-"Last-Translator: Anonymous <noreply@weblate.org>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: Kleyton Luiz de Sousa Vieira "
+"<kleytonluizdesouzavieira@gmail.com>\n"
"Language-Team: Portuguese (Brazil) <https://hosted.weblate.org/projects/"
"godot-engine/godot/pt_BR/>\n"
"Language: pt_BR\n"
@@ -106,11 +111,11 @@ msgstr ""
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr "Tipo de argumento inválido para converter(), use TYPE_* constantes."
+msgstr "Tipo de argumento inválido para convert(), use constantes TYPE_*."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "Esperado uma corda de comprimento 1 (um caractere)."
+msgstr "Esperado uma string de comprimento 1 (um caractere)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -920,7 +925,6 @@ msgstr "Não foi possível conectar o sinal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1531,17 +1535,9 @@ msgstr "Habilitar"
msgid "Rearrange Autoloads"
msgstr "Reordenar Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Caminho inválido."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "O arquivo não existe."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Não está no caminho de recursos."
+msgid "Can't add autoload:"
+msgstr "Não pode adicionar autoload:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2497,12 +2493,16 @@ msgid "Can't reload a scene that was never saved."
msgstr "Não foi possível recarregar a cena pois nunca foi salva."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Reverter"
+msgid "Reload Saved Scene"
+msgstr "Recarregar Cena Salva"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Esta ação não pode ser desfeita. Reverter mesmo assim?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"A cena atual possui alterações não salvas.\n"
+"Recarregar a cena salva mesmo assim? Essa ação não poderá ser desfeita."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2733,11 +2733,11 @@ msgstr "Copiar Texto"
#: editor/editor_node.cpp
msgid "Next tab"
-msgstr "Próxima guia"
+msgstr "Próxima aba"
#: editor/editor_node.cpp
msgid "Previous tab"
-msgstr "Guia anterior"
+msgstr "Aba anterior"
#: editor/editor_node.cpp
msgid "Filter Files..."
@@ -2794,10 +2794,6 @@ msgid "Redo"
msgstr "Refazer"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Reverter Cena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Ferramentas diversas atuantes no projeto ou cena."
@@ -2849,7 +2845,7 @@ msgstr "Sair para a Lista de Projetos"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: editor/project_export.cpp
msgid "Debug"
-msgstr "Depurar"
+msgstr "Depuração"
#: editor/editor_node.cpp
msgid "Deploy with Remote Debug"
@@ -2960,7 +2956,7 @@ msgstr "Capturas de Telas ficam salvas na Pasta Editor Data/Settings."
#: editor/editor_node.cpp
msgid "Toggle Fullscreen"
-msgstr "Alternar Tela-Cheia"
+msgstr "Alternar Tela Cheia"
#: editor/editor_node.cpp
msgid "Toggle System Console"
@@ -3030,7 +3026,7 @@ msgstr "Roda o projeto."
#: editor/editor_node.cpp
msgid "Play"
-msgstr "Tocar"
+msgstr "Rodar"
#: editor/editor_node.cpp
msgid "Pause the scene execution for debugging."
@@ -3038,7 +3034,7 @@ msgstr "Pausar a execução da cena para depuração."
#: editor/editor_node.cpp
msgid "Pause Scene"
-msgstr "Pausa a cena"
+msgstr "Pausar Cena"
#: editor/editor_node.cpp
msgid "Stop the scene."
@@ -3186,7 +3182,7 @@ msgstr "Abrir Editor 3D"
#: editor/editor_node.cpp
msgid "Open Script Editor"
-msgstr "Abrir Editor de Scripts"
+msgstr "Abrir Editor de Script"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
@@ -3446,6 +3442,12 @@ msgstr "Não foi possível rodar o script:"
msgid "Did you forget the '_run' method?"
msgstr "Você esqueceu o método '_run'?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Segure Ctrl para arredondar para números inteiros. Segure Shift para aplicar "
+"mudanças mais precisas."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selecione Nó(s) para Importar"
@@ -4044,6 +4046,10 @@ msgid "Error running post-import script:"
msgstr "Erro ao rodar script pós-importação:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Salvando..."
@@ -5376,7 +5382,7 @@ msgid ""
"Game Camera Override\n"
"Overrides game camera with editor viewport camera."
msgstr ""
-"Sobrepor câmera de Jogo\n"
+"Sobrepor Câmera de Jogo\n"
"Sobrepõe a câmera de jogo com a janela de exibição da câmera."
#: editor/plugins/canvas_item_editor_plugin.cpp
@@ -5385,8 +5391,8 @@ msgid ""
"Game Camera Override\n"
"No game instance running."
msgstr ""
-"Sobrepor câmera de Jogo\n"
-"Sem instancia de jogo rodando."
+"Sobrepor Câmera de Jogo\n"
+"Sem instância de jogo em execução."
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5472,17 +5478,17 @@ msgstr "Alt + botão direito do mouse: Lista de seleção de profundidade"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Move Mode"
-msgstr "Modo Mover"
+msgstr "Modo de Movimentação"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rotate Mode"
-msgstr "Modo Rotacionar"
+msgstr "Modo de Rotação"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Scale Mode"
-msgstr "Modo Escala"
+msgstr "Modo de Escalonamento"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5503,7 +5509,7 @@ msgstr "Modo Panorâmico"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Ruler Mode"
-msgstr "Modo Régua"
+msgstr "Modo de Régua"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Toggle smart snapping."
@@ -5617,7 +5623,7 @@ msgstr "Visualizar"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Always Show Grid"
-msgstr "Sempre Mostrar a Grade"
+msgstr "Sempre Mostrar Grade"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Helpers"
@@ -5645,11 +5651,11 @@ msgstr "Exibir grupo e travar ícones"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Center Selection"
-msgstr "Centralizar Seleção"
+msgstr "Seleção Central"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Frame Selection"
-msgstr "Seleção de Quadros"
+msgstr "Seleção de Frame"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Preview Canvas Scale"
@@ -5657,7 +5663,7 @@ msgstr "Visualizar Canvas Scale"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Translation mask for inserting keys."
-msgstr "Máscara de tradução para inserção de chaves"
+msgstr "Máscara de tradução para inserção de chaves."
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation mask for inserting keys."
@@ -5714,7 +5720,7 @@ msgstr "Dividir o passo da grade por 2"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Pan View"
-msgstr "Vista Panorâmica"
+msgstr "Deslocar Visão"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Add %s"
@@ -6999,12 +7005,13 @@ msgid ""
msgstr "Falta método conectado '%s' para sinal '%s' do nó '%s' para nó '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Linha"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(ignore)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignore)"
+msgid "Line"
+msgstr "Linha"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7478,6 +7485,15 @@ msgid "XForm Dialog"
msgstr "Diálogo XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Encaixar Nó(s) no Chão"
@@ -7533,7 +7549,7 @@ msgstr "Alternar Visão Perspectiva/Ortogonal"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Insert Animation Key"
-msgstr "Inserir Chanve de Animação"
+msgstr "Inserir Chave de Animação"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Focus Origin"
@@ -8508,7 +8524,7 @@ msgstr "Confirmação"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "VCS Addon is not initialized"
-msgstr "Extensão VCS não inicializado"
+msgstr "Extensão VCS não está inicializada"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Version Control System"
@@ -8983,7 +8999,7 @@ msgstr "Encontra o inteiro mais próximo que é menor ou igual ao parâmetro."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Computes the fractional part of the argument."
-msgstr "Calcula a parte decimal do argumento."
+msgstr "Calcula a parte fracional do argumento."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the inverse of the square root of the parameter."
@@ -9036,7 +9052,7 @@ msgstr "Encontra o inteiro mais próximo do parâmetro."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Finds the nearest even integer to the parameter."
-msgstr "Encontra o inteiro par mais próximo do parâmetro."
+msgstr "Encontra o número inteiro par mais próximo do parâmetro."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Clamps the value between 0.0 and 1.0."
@@ -9194,11 +9210,11 @@ msgstr "Multiplica vetor por transformação."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Transform constant."
-msgstr "Constante da transformada."
+msgstr "Constante de transformação."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Transform uniform."
-msgstr "Transformada uniforme."
+msgstr "Uniforme de transformação."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector function."
@@ -10296,11 +10312,11 @@ msgstr "Filtro de Idiomas"
#: editor/project_settings_editor.cpp
msgid "Show All Locales"
-msgstr "Mostrar todos os idiomas"
+msgstr "Mostrar todos os Locales"
#: editor/project_settings_editor.cpp
msgid "Show Selected Locales Only"
-msgstr "Mostrar apenas os idiomas selecionados"
+msgstr "Mostrar apenas os Locales selecionados"
#: editor/project_settings_editor.cpp
msgid "Filter mode:"
@@ -10563,8 +10579,9 @@ msgid "Instance Child Scene"
msgstr "Instânciar Cena Filha"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Remover Script"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Adicionar Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10729,12 +10746,19 @@ msgid "Open Documentation"
msgstr "Abrir Documentação"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Adicionar Nó Filho"
#: editor/scene_tree_dock.cpp
msgid "Expand/Collapse All"
-msgstr "Expandir/Colapsar Tudo"
+msgstr "Expandir/Recolher Tudo"
#: editor/scene_tree_dock.cpp
msgid "Change Type"
@@ -10777,11 +10801,13 @@ msgstr ""
"existir um nó raiz."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Adicionar um script novo ou existente para o nó selecionado."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Remove um script do nó selecionado."
#: editor/scene_tree_dock.cpp
@@ -10913,6 +10939,10 @@ msgid "A directory with the same name exists."
msgstr "Existe um diretório com o mesmo nome."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "O arquivo não existe."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Extensão inválida."
@@ -10953,6 +10983,10 @@ msgid "File exists, it will be reused."
msgstr "O arquivo existe, será reaproveitado."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Caminho inválido."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nome da classe inválido."
@@ -10989,7 +11023,7 @@ msgid ""
"Note: Built-in scripts have some limitations and can't be edited using an "
"external editor."
msgstr ""
-"Nota: Os scripts internos têm algumas limitações e não podem ser editados "
+"Nota: Scripts embutidos possuem algumas limitações e não podem ser editados "
"usando um editor externo."
#: editor/script_create_dialog.cpp
@@ -11858,7 +11892,7 @@ msgstr "function_name"
#: modules/visual_script/visual_script_editor.cpp
msgid "Select or create a function to edit its graph."
-msgstr "Selecione ou crie uma função para editar o grafo."
+msgstr "Selecione ou crie uma função para editar seu gráfico."
#: modules/visual_script/visual_script_editor.cpp
msgid "Delete Selected"
@@ -12004,9 +12038,16 @@ msgstr ""
"na predefinição."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Porta-chaves de depuração não configurado nas Configurações do Editor e nem "
+"na predefinição."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
-"Compilação personalizada requer um caminho do Android SDK válido para as "
+"A compilação personalizada requer um caminho SDK do Android válido nas "
"Configurações do Editor."
#: platform/android/export/export.cpp
@@ -12033,6 +12074,32 @@ msgstr "Nome de pacote inválido:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12811,6 +12878,21 @@ msgstr "Variáveis só podem ser atribuídas na função de vértice."
msgid "Constants cannot be modified."
msgstr "Constantes não podem serem modificadas."
+#~ msgid "Not in resource path."
+#~ msgstr "Não está no caminho de recursos."
+
+#~ msgid "Revert"
+#~ msgstr "Reverter"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Esta ação não pode ser desfeita. Reverter mesmo assim?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Reverter Cena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Remover Script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Rastreador de Problemas"
diff --git a/editor/translations/pt_PT.po b/editor/translations/pt_PT.po
index 6314d31908..40a83eaa87 100644
--- a/editor/translations/pt_PT.po
+++ b/editor/translations/pt_PT.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-01 11:42+0000\n"
+"PO-Revision-Date: 2020-06-15 12:01+0000\n"
"Last-Translator: João Lopes <linux-man@hotmail.com>\n"
"Language-Team: Portuguese (Portugal) <https://hosted.weblate.org/projects/"
"godot-engine/godot/pt_PT/>\n"
@@ -29,7 +29,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -851,7 +851,6 @@ msgstr "Não consigo conectar sinal"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -893,7 +892,7 @@ msgstr "Desligar"
#: editor/connections_dialog.cpp
msgid "Connect a Signal to a Method"
-msgstr "Conectar Sinal a Método"
+msgstr "Conectar Sinal a Método"
#: editor/connections_dialog.cpp
msgid "Edit Connection:"
@@ -1212,7 +1211,7 @@ msgstr "A Descomprimir Ativos"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "The following files failed extraction from package:"
-msgstr "Falhou a extração dos seguintes Ficheiros do pacote:"
+msgstr "Falhou a extração dos seguintes Ficheiros do pacote:"
#: editor/editor_asset_installer.cpp
msgid "And %s more files."
@@ -1253,7 +1252,7 @@ msgstr "Renomear o barramento de áudio"
#: editor/editor_audio_buses.cpp
msgid "Change Audio Bus Volume"
-msgstr "Alterar Volume do barramento de áudio"
+msgstr "Alterar Volume do Barramento de Ãudio"
#: editor/editor_audio_buses.cpp
msgid "Toggle Audio Bus Solo"
@@ -1463,17 +1462,9 @@ msgstr "Ativar"
msgid "Rearrange Autoloads"
msgstr "Reorganizar Carregamentos Automáticos"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Caminho inválido."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "O Ficheiro não existe."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Não está no caminho do recurso."
+msgid "Can't add autoload:"
+msgstr "Não consigo adicionar carregamento automático:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2431,12 +2422,16 @@ msgid "Can't reload a scene that was never saved."
msgstr "Não consigo recarregar uma cena que nunca foi guardada."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Reverter"
+msgid "Reload Saved Scene"
+msgstr "Recarregar Cena Guardada"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Esta acção não pode ser desfeita. Reverter na mesma?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"A cena atual tem alterações não guardadas.\n"
+"Recarregar a cena guardada? Esta ação não pode ser revertida."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2725,10 +2720,6 @@ msgid "Redo"
msgstr "Refazer"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Reverter Cena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Ferramentas diversas de projeto ou cena."
@@ -3374,6 +3365,12 @@ msgstr "Não consegui executar o script:"
msgid "Did you forget the '_run' method?"
msgstr "Esqueceu-se do médodo '_run'?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Pressione Ctrl para arredondar para inteiro. Pressione Shift para mudanças "
+"mais precisas."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selecionar Nó(s) para Importar"
@@ -3971,6 +3968,10 @@ msgid "Error running post-import script:"
msgstr "Erro na execução do Script de pós-importação:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr "Devolveu um objeto derivado de Nó no método `post_import()`?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "A guardar..."
@@ -4023,7 +4024,7 @@ msgstr "Expandir Todas as Propriedades"
#: editor/inspector_dock.cpp
msgid "Collapse All Properties"
-msgstr "Colapsar Todas as Propriedades"
+msgstr "Colapsar Todas as Propriedades"
#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
@@ -4602,7 +4603,7 @@ msgstr "Forçar modulação branca"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Include Gizmos (3D)"
-msgstr "Incluir ferramentas (3D)"
+msgstr "Incluir Bugigangas (3D)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Pin AnimationPlayer"
@@ -5193,7 +5194,7 @@ msgid ""
"Children of containers have their anchors and margins values overridden by "
"their parent."
msgstr ""
-"As âncoras e margens de filhos de um contentores são sobrescritas pelo seu "
+"As âncoras e margens de filhos de um contentores são sobrescritas pelo seu "
"pai."
#: editor/plugins/canvas_item_editor_plugin.cpp
@@ -6912,12 +6913,12 @@ msgid ""
msgstr "Falta método conectado '%s' para sinal '%s' do nó '%s' para nó '%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Linha"
+msgid "[Ignore]"
+msgstr "[Ignorar]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ignorar)"
+msgid "Line"
+msgstr "Linha"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7311,7 +7312,7 @@ msgstr "Ver ambiente"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Gizmos"
-msgstr "Ver ferramentas"
+msgstr "Ver Bugigangas"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Information"
@@ -7390,6 +7391,21 @@ msgid "XForm Dialog"
msgstr "Diálogo XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Clique para alternar entre estados de visibilidade.\n"
+"\n"
+"Olho aberto: Bugiganga é visível.\n"
+"Olho fechado: Bugiganga está escondida.\n"
+"Olho meio-aberto: Bugiganga também é visível através de superfícies opacas "
+"(\"raios X\")."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Ajustar Nós ao Fundo"
@@ -10472,8 +10488,8 @@ msgid "Instance Child Scene"
msgstr "Instanciar Cena Filha"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Limpar Script"
+msgid "Detach Script"
+msgstr "Separar Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10637,6 +10653,16 @@ msgid "Open Documentation"
msgstr "Abrir documentação"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"Não consigo anexar um script: não há linguagens registadas.\n"
+"Isto provavelmente acontece porque o editor foi compilado com todos os "
+"módulos de linguagem desativados."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Adicionar Nó Filho"
@@ -10685,12 +10711,12 @@ msgstr ""
"existir nó raiz."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr "Anexar script novo ou existente ao nó selecionado."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Limpar script do nó selecionado."
+msgid "Detach the script from the selected node."
+msgstr "Separar o script do nó selecionado."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10821,6 +10847,10 @@ msgid "A directory with the same name exists."
msgstr "Já existe diretoria com o mesmo nome."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "O Ficheiro não existe."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Extensão inválida."
@@ -10861,6 +10891,10 @@ msgid "File exists, it will be reused."
msgstr "O Ficheiro já existe, será reutilizado."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Caminho inválido."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Nome de classe inválido."
@@ -10874,7 +10908,7 @@ msgstr "Caminho/nome de script é válido."
#: editor/script_create_dialog.cpp
msgid "Allowed: a-z, A-Z, 0-9, _ and ."
-msgstr "Permitido: a-z, A-Z, 0-9, _ e ."
+msgstr "Permitido: a-z, A-Z, 0-9, _ e ."
#: editor/script_create_dialog.cpp
msgid "Built-in script (into scene file)."
@@ -11906,10 +11940,15 @@ msgstr "O jarsigner do OpenJDK não está configurado nas Definições do Editor
#: platform/android/export/export.cpp
msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
-"Depuração de keystore não configurado nas Configurações do Editor e nem na "
+"Depuração de keystore não configurada nas Configurações do Editor e nem na "
"predefinição."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Lançamento de keystore configurado incorretamente na predefinição exportada."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Compilação personalizada necessita de um caminho válido para Android SDK no "
@@ -11939,6 +11978,40 @@ msgstr "Nome de pacote inválido:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"Módulo inválido \"GodotPaymentV3\" incluído na configuração do projeto "
+"\"android/modules\" (alterado em Godot 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+"\"Usar Compilação Personalizada\" têm de estar ativa para usar os plugins."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"\"Graus de Liberdade\" só é válido quando \"Modo Xr\" é \"Oculus Mobile VR\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Rastreamento de Mão\" só é válido quando \"Modo Xr\" é \"Oculus Mobile VR"
+"\"."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"\"Consciência do Foco\" só é válido quando \"Modo Xr\" é \"Oculus Mobile VR"
+"\"."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12504,7 +12577,7 @@ msgid ""
"order for AnimatedSprite3D to display frames."
msgstr ""
"Um recurso SpriteFrames tem de ser criado ou definido na Propriedade \"Frames"
-"\" de forma a que AnimatedSprite3D mostre frames."
+"\" de forma a que AnimatedSprite3D mostre frames."
#: scene/3d/vehicle_body.cpp
msgid ""
@@ -12535,7 +12608,7 @@ msgid ""
"this environment's Background Mode to Canvas (for 2D scenes)."
msgstr ""
"Este WorldEnvironment Ä— ignorado. Pode adicionar uma Camera (para cenas 3D) "
-"ou definir o Modo Background deste ambiente como Canvas (para cenas 2D)."
+"ou definir o Modo Background deste ambiente como Canvas (para cenas 2D)."
#: scene/animation/animation_blend_tree.cpp
msgid "On BlendTree node '%s', animation not found: '%s'"
@@ -12716,6 +12789,21 @@ msgstr "Variações só podem ser atribuídas na função vértice."
msgid "Constants cannot be modified."
msgstr "Constantes não podem ser modificadas."
+#~ msgid "Not in resource path."
+#~ msgstr "Não está no caminho do recurso."
+
+#~ msgid "Revert"
+#~ msgstr "Reverter"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Esta acção não pode ser desfeita. Reverter na mesma?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Reverter Cena"
+
+#~ msgid "Clear Script"
+#~ msgstr "Limpar Script"
+
#~ msgid "Issue Tracker"
#~ msgstr "Rastreador de Problemas"
diff --git a/editor/translations/ro.po b/editor/translations/ro.po
index 624ae005f2..5e362de330 100644
--- a/editor/translations/ro.po
+++ b/editor/translations/ro.po
@@ -830,7 +830,6 @@ msgstr "Nu se poate conecta semnalul"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1445,17 +1444,9 @@ msgstr "Activați"
msgid "Rearrange Autoloads"
msgstr "Rearanjați Autoload-urile"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Cale nevalidă."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Fișierul nu există."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Nu în calea de resurse."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2404,12 +2395,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Nu se poate reîncărca o scenă care nu a fost salvată niciodată."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "ÃŽntoarcere"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Salvează Scena"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Această acțiune nu poate fi recuperată. Te reîntorci oricum?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2707,10 +2701,6 @@ msgid "Redo"
msgstr "Reîntoarcere"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Restabilește Scena"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Proiect Divers sau unelte pentru scenă."
@@ -3368,6 +3358,10 @@ msgstr "Nu a putut fi executat scriptul:"
msgid "Did you forget the '_run' method?"
msgstr "Ai uitat cumva metoda '_run' ?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Selectează Nodul(rile) pentru Importare"
@@ -4001,6 +3995,10 @@ msgid "Error running post-import script:"
msgstr "Eroare la executarea scripyului post-importare:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Se Salvează..."
@@ -7101,15 +7099,15 @@ msgid ""
msgstr "Deconectați '%s' de la '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Linie:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Faceți Funcția"
@@ -7596,6 +7594,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "Snap pe grilă"
@@ -10682,7 +10689,8 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+#, fuzzy
+msgid "Detach Script"
msgstr "Curăță Scriptul"
#: editor/scene_tree_dock.cpp
@@ -10851,6 +10859,13 @@ msgid "Open Documentation"
msgstr "Deschide Recente"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10901,11 +10916,13 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
+msgstr "Curăță un script pentru nodul selectat."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Curăță un script pentru nodul selectat."
#: editor/scene_tree_dock.cpp
@@ -11034,6 +11051,10 @@ msgid "A directory with the same name exists."
msgstr "Un fișier sau un director cu acest nume există deja."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Fișierul nu există."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Trebuie să utilizaţi o extensie valida."
@@ -11077,6 +11098,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Cale nevalidă."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid class name."
msgstr "Nume nevalid."
@@ -12154,6 +12179,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12178,6 +12207,32 @@ msgstr "Nume nevalid."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12830,6 +12885,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Nu în calea de resurse."
+
+#~ msgid "Revert"
+#~ msgstr "ÃŽntoarcere"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Această acțiune nu poate fi recuperată. Te reîntorci oricum?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Restabilește Scena"
+
#~ msgid "Issue Tracker"
#~ msgstr "Agent de Monitorizare al Problemelor"
diff --git a/editor/translations/ru.po b/editor/translations/ru.po
index d8c55d825e..8bae9207d0 100644
--- a/editor/translations/ru.po
+++ b/editor/translations/ru.po
@@ -71,12 +71,17 @@
# Super Pracion <superpracion2@gmail.com>, 2020.
# PizzArt <7o7goo7o7@gmail.com>, 2020.
# TheGracekale <mrsmailbot.lg@gmail.com>, 2020.
+# Климентий Титов <titoffklim@cclc.tech>, 2020.
+# Richard Urban <redasuio1@gmail.com>, 2020.
+# Nikita <Kulacnikita@ya.ru>, 2020.
+# Alexander <ramzi7208@gmail.com>, 2020.
+# Alex Tern <ternvein@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-05 14:01+0000\n"
-"Last-Translator: Super Pracion <superpracion2@gmail.com>\n"
+"PO-Revision-Date: 2020-06-15 12:01+0000\n"
+"Last-Translator: Alex Tern <ternvein@gmail.com>\n"
"Language-Team: Russian <https://hosted.weblate.org/projects/godot-engine/"
"godot/ru/>\n"
"Language: ru\n"
@@ -85,12 +90,12 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
-"X-Generator: Weblate 4.1-dev\n"
+"X-Generator: Weblate 4.1\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr "Ðеверный тип аргумента Ð´Ð»Ñ convert(), иÑпользуйте TYPE_* конÑтанты."
+msgstr "Ðеверный тип аргумента Ð´Ð»Ñ convert(), иÑпользуйте конÑтанты TYPE_*."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
@@ -129,7 +134,7 @@ msgstr "ÐедопуÑтимые аргументы Ð´Ð»Ñ Ð¿Ð¾ÑтроениÑ
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr "Ðа вызове '%s':"
+msgstr "Ðа вызове '%s':"
#: core/ustring.cpp
msgid "B"
@@ -340,7 +345,7 @@ msgstr "Ð’Ñ€ÐµÐ¼Ñ (Ñек.): "
#: editor/animation_track_editor.cpp
msgid "Toggle Track Enabled"
-msgstr "Переключатель дорожки включен"
+msgstr "Включить/выключить дорожку"
#: editor/animation_track_editor.cpp
msgid "Continuous"
@@ -906,7 +911,6 @@ msgstr "Ðе удаетÑÑ Ð¿Ð¾Ð´ÐºÐ»ÑŽÑ‡Ð¸Ñ‚ÑŒ Ñигнал"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1516,17 +1520,9 @@ msgstr "Включить"
msgid "Rearrange Autoloads"
msgstr "ПереÑтановка автозагрузок"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "ÐедопуÑтимый путь."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Файл не ÑущеÑтвует."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ðе в пути реÑурÑов."
+msgid "Can't add autoload:"
+msgstr "ÐÐµÐ»ÑŒÐ·Ñ Ð´Ð¾Ð±Ð²Ð°Ð¸Ñ‚ÑŒ автозагрузку:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2041,7 +2037,7 @@ msgstr "КонÑтанты"
#: editor/editor_help.cpp
msgid "Property Descriptions"
-msgstr "ОпиÑание ÑвойÑтв"
+msgstr "ОпиÑÐ°Ð½Ð¸Ñ ÑвойÑтв"
#: editor/editor_help.cpp
msgid "(value)"
@@ -2057,7 +2053,7 @@ msgstr ""
#: editor/editor_help.cpp
msgid "Method Descriptions"
-msgstr "ОпиÑание методов"
+msgstr "ОпиÑÐ°Ð½Ð¸Ñ Ð¼ÐµÑ‚Ð¾Ð´Ð¾Ð²"
#: editor/editor_help.cpp
msgid ""
@@ -2485,12 +2481,16 @@ msgid "Can't reload a scene that was never saved."
msgstr "Ðе возможно загрузить Ñцену, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð½Ðµ была Ñохранена."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "ВоÑÑтановить"
+msgid "Reload Saved Scene"
+msgstr "Перезагрузить Ñохранённую Ñцену"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Это дейÑтвие Ð½ÐµÐ»ÑŒÐ·Ñ Ð¾Ñ‚Ð¼ÐµÐ½Ð¸Ñ‚ÑŒ. ВоÑÑтановить в любом Ñлучае?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"Ð¢ÐµÐºÑƒÑ‰Ð°Ñ Ñцена имеет неÑохраненные изменениÑ. \n"
+"Ð’ÑÑ‘ равно перезагрузить Ñцену? Это дейÑтвие Ð½ÐµÐ»ÑŒÐ·Ñ Ð¾Ñ‚Ð¼ÐµÐ½Ð¸Ñ‚ÑŒ."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2539,7 +2539,7 @@ msgstr "Закрыть Ñцену"
#: editor/editor_node.cpp
msgid "Reopen Closed Scene"
-msgstr "Открыть ранее закрытую Ñцену"
+msgstr "Открыть закрытую Ñцену"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
@@ -2776,10 +2776,6 @@ msgid "Redo"
msgstr "Повторить"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "ВоÑÑтановить Ñцену"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Прочие инÑтрументы."
@@ -2861,8 +2857,8 @@ msgstr ""
"Когда Ñта Ð¾Ð¿Ñ†Ð¸Ñ Ð²ÐºÐ»ÑŽÑ‡ÐµÐ½Ð°, ÑкÑпорт или развёртывание будет Ñоздавать "
"минимальный иÑполнÑемый файл.\n"
"Ð¤Ð°Ð¹Ð»Ð¾Ð²Ð°Ñ ÑиÑтема проекта будет предоÑтавлÑÑ‚ÑŒÑÑ Ñ€ÐµÐ´Ð°ÐºÑ‚Ð¾Ñ€Ð¾Ð¼ через Ñеть.\n"
-"Ðа Android развёртывание будет быÑтрее при подключении через USB.\n"
-"Эта Ð¾Ð¿Ñ†Ð¸Ñ ÑƒÑкорÑет теÑтирование больших проектов."
+"Ðа Android развёртывание будет быÑтрее при подключении через USB. Эта Ð¾Ð¿Ñ†Ð¸Ñ "
+"уÑкорÑет теÑтирование игр Ñ Ð±Ð¾Ð»ÑŒÑˆÐ¸Ð¼ объемом памÑти."
#: editor/editor_node.cpp
msgid "Visible Collision Shapes"
@@ -3161,11 +3157,11 @@ msgstr "Выделение"
#: editor/editor_node.cpp
msgid "Open 2D Editor"
-msgstr "Открыть 2D редактор"
+msgstr "Открыть 2D-редактор"
#: editor/editor_node.cpp
msgid "Open 3D Editor"
-msgstr "Открыть 3D редактор"
+msgstr "Открыть 3D-редактор"
#: editor/editor_node.cpp
msgid "Open Script Editor"
@@ -3427,6 +3423,12 @@ msgstr "Ðевозможно запуÑтить Ñкрипт:"
msgid "Did you forget the '_run' method?"
msgstr "Быть может вы забыли метод _run()?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Зажмите Ctrl, чтобы округлить до целых. Зажмите Shift Ð´Ð»Ñ Ð±Ð¾Ð»ÐµÐµ точных "
+"изменений."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Выберите узлы Ð´Ð»Ñ Ð¸Ð¼Ð¿Ð¾Ñ€Ñ‚Ð°"
@@ -4022,6 +4024,10 @@ msgid "Error running post-import script:"
msgstr "Ошибка запуÑка поÑÑ‚-импорт Ñкрипта:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Сохранение..."
@@ -6044,17 +6050,16 @@ msgid "Create Outline Mesh..."
msgstr "Создать полиÑетку обводки..."
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid ""
"Creates a static outline mesh. The outline mesh will have its normals "
"flipped automatically.\n"
"This can be used instead of the SpatialMaterial Grow property when using "
"that property isn't possible."
msgstr ""
-"Создаёт Ñтатичную контурную полиÑетку. Её нормали будут перевёрнуты "
+"Создаёт Ñтатичную обводочную полиÑетку. Её нормали переворачиваютÑÑ "
"автоматичеÑки.\n"
-"Она может быть заменой ÑвойÑтву Grow реÑурÑа SpatialMaterial, когда Ñто "
-"ÑвойÑтво невозможно иÑпользовать."
+"Она может быть иÑпользована в Ñлучае, еÑли иÑпользовать ÑвойÑтво Grow "
+"материала SpatialMaterial не предÑтавлÑетÑÑ Ð²Ð¾Ð·Ð¼Ð¾Ð¶Ð½Ñ‹Ð¼."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "View UV1"
@@ -6678,7 +6683,7 @@ msgstr "AnimationTree - не задан путь к AnimationPlayer"
#: editor/plugins/root_motion_editor_plugin.cpp
msgid "Path to AnimationPlayer is invalid"
-msgstr "Путь к AnimationPlayer недейÑтвительный"
+msgstr "Путь к AnimationPlayer недейÑтвительный"
#: editor/plugins/script_editor_plugin.cpp
msgid "Clear Recent Files"
@@ -6969,12 +6974,13 @@ msgstr ""
"'%s'."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Строка"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(игнорировать)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(игнорировать)"
+msgid "Line"
+msgstr "Строка"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7340,7 +7346,6 @@ msgid "This operation requires a single selected node."
msgstr "Эта Ð¾Ð¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ñ‚Ñ€ÐµÐ±ÑƒÐµÑ‚ одного выбранного узла."
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Auto Orthogonal Enabled"
msgstr "Ортогональный"
@@ -7450,6 +7455,15 @@ msgid "XForm Dialog"
msgstr "XForm диалоговое окно"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "ПривÑзать узлы к полу"
@@ -9113,9 +9127,8 @@ msgid "2D texture uniform lookup."
msgstr "Равномерный поиÑк 2D-текÑтур."
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "2D texture uniform lookup with triplanar."
-msgstr "Форменный поиÑк 2d текÑтуры Ñ Ñ‚Ñ€Ð¸Ð¿Ð»Ð°Ð½Ð°Ñ€Ð¾Ð¼."
+msgstr "Равномерный поиÑк 2d текÑтуры Ñ Ñ‚Ñ€Ð¸Ð¿Ð»Ð°Ð½Ð°Ñ€Ð¾Ð¼."
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Transform function."
@@ -10152,7 +10165,6 @@ msgid "Settings saved OK."
msgstr "ÐаÑтройки Ñохранены нормально."
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Moved Input Action Event"
msgstr "Событие ввода дейÑÑ‚Ð²Ð¸Ñ Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¾"
@@ -10471,7 +10483,6 @@ msgid "Regular Expression Error"
msgstr "Ошибка в регулÑрном выражении"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "At character %s"
msgstr "Ðа Ñимволе %s"
@@ -10540,8 +10551,9 @@ msgid "Instance Child Scene"
msgstr "Добавить дочернюю Ñцену"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Убрать Ñкрипт"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Прикрепить Ñкрипт"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10707,6 +10719,13 @@ msgid "Open Documentation"
msgstr "Открыть документацию"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Добавить дочерний узел"
@@ -10755,11 +10774,13 @@ msgstr ""
"не ÑущеÑтвует."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Прикрепить новый или ÑущеÑтвующий Ñкрипт к выбранному узлу."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Убрать Ñкрипт у выбранного узла."
#: editor/scene_tree_dock.cpp
@@ -10891,6 +10912,10 @@ msgid "A directory with the same name exists."
msgstr "Каталог Ñ Ñ‚Ð°ÐºÐ¸Ð¼ же именем ÑущеÑтвует."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Файл не ÑущеÑтвует."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "ÐедопуÑтимое раÑширение."
@@ -10931,6 +10956,10 @@ msgid "File exists, it will be reused."
msgstr "Файл ÑущеÑтвует, будет иÑпользован повторно."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "ÐедопуÑтимый путь."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "ÐедопуÑтимое Ð¸Ð¼Ñ ÐºÐ»Ð°ÑÑа."
@@ -11979,6 +12008,13 @@ msgstr ""
"предуÑтановках."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"ÐžÑ‚Ð»Ð°Ð´Ð¾Ñ‡Ð½Ð°Ñ ÐºÐ»Ð°Ð²Ð¸Ð°Ñ‚ÑƒÑ€Ð° не наÑтроена ни в наÑтройках редактора, ни в "
+"предуÑтановках."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"ПользовательÑÐºÐ°Ñ Ñборка требует Ð½Ð°Ð»Ð¸Ñ‡Ð¸Ñ Ð¿Ñ€Ð°Ð²Ð¸Ð»ÑŒÐ½Ð¾Ð³Ð¾ пути к Android SDK в "
@@ -12007,6 +12043,32 @@ msgstr "ÐедопуÑтимое Ð¸Ð¼Ñ Ð¿Ð°ÐºÐµÑ‚Ð°:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12039,7 +12101,6 @@ msgstr ""
"Android."
#: platform/android/export/export.cpp
-#, fuzzy
msgid "No build apk generated at: "
msgstr "Ðет Ñборки apk в: "
@@ -12235,10 +12296,9 @@ msgstr ""
"чтобы работать."
#: scene/2d/light_occluder_2d.cpp
-#, fuzzy
msgid "The occluder polygon for this occluder is empty. Please draw a polygon."
msgstr ""
-"ЗаÑлонÑющий полигон Ð´Ð»Ñ Ñтого окклюдера пуÑÑ‚. ПожалуйÑта, нариÑуйте полигон!"
+"ЗаÑлонÑющий полигон Ð´Ð»Ñ Ñтого окклюдера пуÑÑ‚. ПожалуйÑта, нариÑуйте полигон."
#: scene/2d/navigation_polygon.cpp
msgid ""
@@ -12725,8 +12785,7 @@ msgid ""
msgstr ""
"ScrollContainer предназначен Ð´Ð»Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹ Ñ Ð¾Ð´Ð½Ð¸Ð¼ дочерним Ñлементом "
"управлениÑ.\n"
-"ИÑпользуйте дочерний контейнер (VBox, HBox и Ñ‚.д.), или Control и "
-"уÑтановите\n"
+"ИÑпользуйте дочерний контейнер (VBox, HBox и Ñ‚.д.), или Control и уÑтановите "
"минимальный размер вручную."
#: scene/gui/tree.cpp
@@ -12786,6 +12845,21 @@ msgstr "Ð˜Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð¼Ð¾Ð³ÑƒÑ‚ быть назначены только Ð
msgid "Constants cannot be modified."
msgstr "КонÑтанты не могут быть изменены."
+#~ msgid "Not in resource path."
+#~ msgstr "Ðе в пути реÑурÑов."
+
+#~ msgid "Revert"
+#~ msgstr "ВоÑÑтановить"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Это дейÑтвие Ð½ÐµÐ»ÑŒÐ·Ñ Ð¾Ñ‚Ð¼ÐµÐ½Ð¸Ñ‚ÑŒ. ВоÑÑтановить в любом Ñлучае?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "ВоÑÑтановить Ñцену"
+
+#~ msgid "Clear Script"
+#~ msgstr "Убрать Ñкрипт"
+
#~ msgid "Issue Tracker"
#~ msgstr "СиÑтема отÑÐ»ÐµÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð¾ÑˆÐ¸Ð±Ð¾Ðº"
diff --git a/editor/translations/si.po b/editor/translations/si.po
index 2eb9cad3f8..4d252a53d6 100644
--- a/editor/translations/si.po
+++ b/editor/translations/si.po
@@ -836,7 +836,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1436,16 +1435,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2366,11 +2357,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "à·ƒà·à¶¯à¶±à·Šà¶±"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2636,10 +2630,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3246,6 +3236,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3832,6 +3826,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6727,11 +6725,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7202,6 +7200,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10143,7 +10150,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10304,6 +10311,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10350,11 +10364,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10474,6 +10488,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10514,6 +10532,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11551,6 +11573,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11574,6 +11600,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/sk.po b/editor/translations/sk.po
index 295b7ac429..a341552d1c 100644
--- a/editor/translations/sk.po
+++ b/editor/translations/sk.po
@@ -9,11 +9,12 @@
# Michal <alladinsiffon@gmail.com>, 2019.
# Richard <rgarlik@gmail.com>, 2019.
# Richard Urban <redasuio1@gmail.com>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-01 11:42+0000\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
"Last-Translator: Richard Urban <redasuio1@gmail.com>\n"
"Language-Team: Slovak <https://hosted.weblate.org/projects/godot-engine/"
"godot/sk/>\n"
@@ -22,7 +23,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -31,17 +32,17 @@ msgstr "Chybný argument convert(), použite TYPE_* konštanty."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "OÄakávaná dĺžka stringu 1 (písmeno)."
+msgstr "dĺžka oÄakávaného stringu 1 (písmeno)"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr "Nedostatok bajtov na dekódovanie, možný chybný formát."
+msgstr "Nedostatok bajtov na dekódovanie, alebo chybný formát."
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
-msgstr "Nesprávny vstup %i (chýba) vo výraze"
+msgstr "Neplatný vstup %i (neprešlo) vo výraze"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
@@ -97,7 +98,7 @@ msgstr "EiB"
#: editor/animation_bezier_editor.cpp
msgid "Free"
-msgstr "Voľné"
+msgstr "zadarmo"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
@@ -117,7 +118,7 @@ msgstr "Hodnota:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr "VložiÅ¥ tu kľúÄ"
+msgstr "Sem Vložte KľúÄ"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
@@ -125,7 +126,7 @@ msgstr "DuplikovaÅ¥ kľúÄ(e)"
#: editor/animation_bezier_editor.cpp
msgid "Delete Selected Key(s)"
-msgstr "ZmazaÅ¥ kľúÄ(e)"
+msgstr "ZmazaÅ¥ oznaÄené kľúÄ(e)"
#: editor/animation_bezier_editor.cpp
msgid "Add Bezier Point"
@@ -133,64 +134,64 @@ msgstr "Pridať Bezierov bod"
#: editor/animation_bezier_editor.cpp
msgid "Move Bezier Points"
-msgstr "Presunúť Vybraté Body"
+msgstr "Presunúť Bazier Points"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
-msgstr "Animácia DuplikovaÅ¥ KľúÄe"
+msgstr "Anim DuplikovaÅ¥ KľúÄe"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Delete Keys"
-msgstr "Animácia VymazaÅ¥ KľúÄe"
+msgstr "Anim ZmazaÅ¥ KľúÄe"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Time"
-msgstr "Animácia Zmeniť Keyframe Čas"
+msgstr "Anim Zmeniť Keyframe Čas"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transition"
-msgstr "Animácia zmeniť prechod"
+msgstr "Anim zmeniť prechod"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transform"
-msgstr "Zmeniť Veľkosť Animácie"
+msgstr "Anim Zmeniť Veľkosť"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Value"
-msgstr "Animácia Zmeniť Keyframe Hodnotu"
+msgstr "Anim Zmeniť Hodnotu Keyframe"
#: editor/animation_track_editor.cpp
msgid "Anim Change Call"
-msgstr "Animácia zmenila Hovor"
+msgstr "Anim Change Call"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Keyframe Time"
-msgstr "Animácia ZmeniÅ¥ Äas Keyframe-u"
+msgstr "Anim ZmeniÅ¥ Äas Keyframe-u"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Transition"
-msgstr "Zmeniť Transition Animácie"
+msgstr "Animácia zmeniť prechod(Anim Multi Change Transition)"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Transform"
-msgstr "Animácia zmeniť Transform"
+msgstr "Anim zmeniť Transform"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Keyframe Value"
-msgstr "Animácia Zmeniť hodnotu Keyframe-u"
+msgstr "Animácia Zmeniť Keyframe Hodnotu (Anim Multi Change Keyframe Value)"
#: editor/animation_track_editor.cpp
msgid "Anim Multi Change Call"
-msgstr "Animácia Zmenila Hovor"
+msgstr "Animácia Zmeniť Hovor (Anim Multi Change Call)"
#: editor/animation_track_editor.cpp
msgid "Change Animation Length"
-msgstr "Zmeniť Dĺžku Animácie"
+msgstr "Zmeniť Dĺžku Animácie (Change Animation Length)"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation Loop"
-msgstr "Zmeniť Dĺžku Animácie"
+msgstr "Zmeniť opakovanie Animácie (Change Animation Loop)"
#: editor/animation_track_editor.cpp
msgid "Property Track"
@@ -206,7 +207,7 @@ msgstr "Call Method Track"
#: editor/animation_track_editor.cpp
msgid "Bezier Curve Track"
-msgstr "Krivka Bezier Track"
+msgstr "Bezier Curve Track"
#: editor/animation_track_editor.cpp
msgid "Audio Playback Track"
@@ -214,7 +215,7 @@ msgstr "Audio Playback Track"
#: editor/animation_track_editor.cpp
msgid "Animation Playback Track"
-msgstr "Playback Track Animácie"
+msgstr "Animation Playback Track"
#: editor/animation_track_editor.cpp
msgid "Animation length (frames)"
@@ -836,7 +837,6 @@ msgstr "Nedá sa pripojiť signál"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1446,17 +1446,9 @@ msgstr "Povoliť"
msgid "Rearrange Autoloads"
msgstr "Rearandžovať AutoLoad-y"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Neplatná cesta."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Súbor neexistuje."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Nieje v resource path."
+msgid "Can't add autoload:"
+msgstr "Nepodarilo sa pridať autoload:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2414,12 +2406,16 @@ msgid "Can't reload a scene that was never saved."
msgstr "Nemožno naÄítaÅ¥ scénu, ktorá nikdy nebola uložená."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Revert"
+msgid "Reload Saved Scene"
+msgstr "Reloadnuť Uloženú Scénu"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Túto akciu nie je možné vrátiť späť. Chcete Revertovatť aj tak?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"Táto scéna má neuložené zmeny.\n"
+"Aj tak chcete scény reloadnuÅ¥? Táto akcia nomôže byÅ¥ nedokonÄená."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2705,10 +2701,6 @@ msgid "Redo"
msgstr "Prerobiť"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Vrátiť Scénu"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Zmiešanosti projektových alebo scénových wide tool-ov."
@@ -3075,176 +3067,172 @@ msgid "Open & Run a Script"
msgstr "Otvoriť & Spustiť Script"
#: editor/editor_node.cpp
-#, fuzzy
msgid "New Inherited"
-msgstr "Popis:"
+msgstr "Novo Zdedené"
#: editor/editor_node.cpp
msgid "Load Errors"
-msgstr ""
+msgstr "NaÄítaÅ¥ Chyby"
#: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp
msgid "Select"
-msgstr ""
+msgstr "Zvoliť"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Open 2D Editor"
-msgstr "Otvorit prieÄinok"
+msgstr "Otvoriť 2D Editor"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Open 3D Editor"
-msgstr "Otvorit prieÄinok"
+msgstr "Otvoriť 3D Editor"
#: editor/editor_node.cpp
msgid "Open Script Editor"
-msgstr ""
+msgstr "Otvoriť Editor Skriptov"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
-msgstr ""
+msgstr "Otvoriť Knižnicu \"Assetov\""
#: editor/editor_node.cpp
msgid "Open the next Editor"
-msgstr ""
+msgstr "Otvoriť následujúci Editor"
#: editor/editor_node.cpp
msgid "Open the previous Editor"
-msgstr ""
+msgstr "Otvoriť predchádzajúci Editor"
#: editor/editor_node.h
msgid "Warning!"
-msgstr ""
+msgstr "Varovanie!"
#: editor/editor_path.cpp
msgid "No sub-resources found."
-msgstr ""
+msgstr "Nenašli sa žiadne \"sub-resources\"."
#: editor/editor_plugin.cpp
msgid "Creating Mesh Previews"
-msgstr ""
+msgstr "Vytváranie Zobrazenia \"Mesh-u\""
#: editor/editor_plugin.cpp
msgid "Thumbnail..."
-msgstr ""
+msgstr "\"Thumbnail\"..."
#: editor/editor_plugin_settings.cpp
-#, fuzzy
msgid "Main Script:"
-msgstr "Popis:"
+msgstr "Hlavný Script:"
#: editor/editor_plugin_settings.cpp
-#, fuzzy
msgid "Edit Plugin"
-msgstr "Signály:"
+msgstr "Editovať Plugin"
#: editor/editor_plugin_settings.cpp
msgid "Installed Plugins:"
-msgstr ""
+msgstr "Nainštalované Plugins:"
#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
msgid "Update"
-msgstr ""
+msgstr "Update"
#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Version:"
-msgstr ""
+msgstr "Verzia:"
#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
msgid "Author:"
-msgstr ""
+msgstr "Autor:"
#: editor/editor_plugin_settings.cpp
msgid "Status:"
-msgstr ""
+msgstr "Status:"
#: editor/editor_plugin_settings.cpp
msgid "Edit:"
-msgstr ""
+msgstr "Edit:"
#: editor/editor_profiler.cpp
msgid "Measure:"
-msgstr ""
+msgstr "Opatrenia:"
#: editor/editor_profiler.cpp
msgid "Frame Time (sec)"
-msgstr ""
+msgstr "Čas Snímky (v sek.)"
#: editor/editor_profiler.cpp
msgid "Average Time (sec)"
-msgstr ""
+msgstr "Priemerný Čas (v sek.)"
#: editor/editor_profiler.cpp
msgid "Frame %"
-msgstr ""
+msgstr "Snímka %"
#: editor/editor_profiler.cpp
msgid "Physics Frame %"
-msgstr ""
+msgstr "Fyzická Snímka %"
#: editor/editor_profiler.cpp
msgid "Inclusive"
-msgstr ""
+msgstr "Inkluzívne"
#: editor/editor_profiler.cpp
msgid "Self"
-msgstr ""
+msgstr "Vlastné"
#: editor/editor_profiler.cpp
msgid "Frame #:"
-msgstr ""
+msgstr "Snímka #:"
#: editor/editor_profiler.cpp
msgid "Time"
-msgstr ""
+msgstr "ÄŒas"
#: editor/editor_profiler.cpp
msgid "Calls"
-msgstr ""
+msgstr "Volania"
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Edit Text:"
-msgstr "Súbor:"
+msgstr "Editovať Text:"
#: editor/editor_properties.cpp editor/script_create_dialog.cpp
msgid "On"
-msgstr ""
+msgstr "Zapnúť"
#: editor/editor_properties.cpp
msgid "Layer"
-msgstr ""
+msgstr "Vrstva"
#: editor/editor_properties.cpp
msgid "Bit %d, value %d"
-msgstr ""
+msgstr "Bit %d, hodnota %d"
#: editor/editor_properties.cpp
msgid "[Empty]"
-msgstr ""
+msgstr "[Prázdne]"
#: editor/editor_properties.cpp editor/plugins/root_motion_editor_plugin.cpp
msgid "Assign..."
-msgstr ""
+msgstr "Priradiť..."
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Invalid RID"
-msgstr "Nesprávna veľkosť písma."
+msgstr "Nesprávny \"RID\""
#: editor/editor_properties.cpp
msgid ""
"The selected resource (%s) does not match any type expected for this "
"property (%s)."
msgstr ""
+"Vybraný prostriedok (%s) sa nezhoduje žiadnemu typu pre túto vlastnosť (%s)."
#: editor/editor_properties.cpp
msgid ""
"Can't create a ViewportTexture on resources saved as a file.\n"
"Resource needs to belong to a scene."
msgstr ""
+"Nepodarilo sa vytvoriť ViewportTextúru na zdroj uložený ako súbor.\n"
+"Zdroj musí patriť scéne."
#: editor/editor_properties.cpp
msgid ""
@@ -3253,28 +3241,30 @@ msgid ""
"Please switch on the 'local to scene' property on it (and all resources "
"containing it up to a node)."
msgstr ""
+"Nepodarilo sa vytvoriť ViewportTextúru na tomto zdroji lebo není nastavený "
+"ako lokálna scéna.\n"
+"Prosím zmeňte ho vo vlastnosti 'local to scene' (a všetky zdroje ktoré ho "
+"obsahujú hore v node-e)."
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Pick a Viewport"
-msgstr ""
+msgstr "Vybrať Viewport"
#: editor/editor_properties.cpp editor/property_editor.cpp
-#, fuzzy
msgid "New Script"
-msgstr "Popis:"
+msgstr "Nový Script"
#: editor/editor_properties.cpp editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Extend Script"
-msgstr "Popis:"
+msgstr "\"Extendovaný\" Script"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "New %s"
-msgstr ""
+msgstr "Nový %s"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Make Unique"
-msgstr ""
+msgstr "SpraviÅ¥ JedineÄným"
#: editor/editor_properties.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
@@ -3292,845 +3282,837 @@ msgstr "Vložiť"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Convert To %s"
-msgstr ""
+msgstr "Konvertovať Do %s"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Selected node is not a Viewport!"
-msgstr ""
+msgstr "Vybraný node není Viewport!"
#: editor/editor_properties_array_dict.cpp
msgid "Size: "
-msgstr ""
+msgstr "Veľkosť: "
#: editor/editor_properties_array_dict.cpp
msgid "Page: "
-msgstr ""
+msgstr "Strana: "
#: editor/editor_properties_array_dict.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Remove Item"
-msgstr ""
+msgstr "Vymazať Predmet"
#: editor/editor_properties_array_dict.cpp
msgid "New Key:"
-msgstr ""
+msgstr "Nový KľúÄ:"
#: editor/editor_properties_array_dict.cpp
msgid "New Value:"
-msgstr ""
+msgstr "Nová Hodnota:"
#: editor/editor_properties_array_dict.cpp
msgid "Add Key/Value Pair"
-msgstr ""
+msgstr "PridaÅ¥ KľúÄ/Hodnota \"Pair\""
#: editor/editor_run_native.cpp
msgid ""
"No runnable export preset found for this platform.\n"
"Please add a runnable preset in the export menu."
msgstr ""
+"Pre túto platformu sa nenašiel žiadny spustiteľný \"export preset\" .\n"
+"Prosím pridajte spustiteľný \"preset\" v export menu."
#: editor/editor_run_script.cpp
msgid "Write your logic in the _run() method."
-msgstr ""
+msgstr "Napíšte svoju logiku v metóde _run()."
#: editor/editor_run_script.cpp
msgid "There is an edited scene already."
-msgstr ""
+msgstr "Už tu je editovaná scéna."
#: editor/editor_run_script.cpp
msgid "Couldn't instance script:"
-msgstr ""
+msgstr "Nepodarilo sa inštancovať script:"
#: editor/editor_run_script.cpp
msgid "Did you forget the 'tool' keyword?"
-msgstr ""
+msgstr "Zabudli ste skratku pre 'tool'?"
#: editor/editor_run_script.cpp
msgid "Couldn't run script:"
-msgstr ""
+msgstr "Nepodarilo sa spustiť script:"
#: editor/editor_run_script.cpp
msgid "Did you forget the '_run' method?"
+msgstr "Nezabudli ste na metódu '_run'?"
+
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
msgstr ""
+"Podržte Ctrl na zaokrúhlenie na celé Äísla. Podržte Shift pre viac precízne "
+"zmeny."
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
-msgstr ""
+msgstr "Vyberte Node(y) pre Importovanie"
#: editor/editor_sub_scene.cpp editor/project_manager.cpp
msgid "Browse"
-msgstr ""
+msgstr "Vyhladať"
#: editor/editor_sub_scene.cpp
msgid "Scene Path:"
-msgstr ""
+msgstr "Cesta Scény:"
#: editor/editor_sub_scene.cpp
msgid "Import From Node:"
-msgstr ""
+msgstr "Importovať Z Node-u:"
#: editor/export_template_manager.cpp
msgid "Redownload"
-msgstr ""
+msgstr "Preinštalovať"
#: editor/export_template_manager.cpp
msgid "Uninstall"
-msgstr ""
+msgstr "Odinštalovať"
#: editor/export_template_manager.cpp
msgid "(Installed)"
-msgstr ""
+msgstr "(Nainštalované)"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Download"
-msgstr ""
+msgstr "Stiahnuté"
#: editor/export_template_manager.cpp
msgid "Official export templates aren't available for development builds."
-msgstr ""
+msgstr "Oficiálne export šablóny niesu dostupné pre \"development builds\"."
#: editor/export_template_manager.cpp
msgid "(Missing)"
-msgstr ""
+msgstr "(Chýba)"
#: editor/export_template_manager.cpp
msgid "(Current)"
-msgstr ""
+msgstr "(Aktuálny)"
#: editor/export_template_manager.cpp
msgid "Retrieving mirrors, please wait..."
-msgstr ""
+msgstr "NaÄítavanie zrkadiel, prosím Äakajte..."
#: editor/export_template_manager.cpp
msgid "Remove template version '%s'?"
-msgstr ""
+msgstr "Vymazať verziu šablóny '%s'?"
#: editor/export_template_manager.cpp
msgid "Can't open export templates zip."
-msgstr ""
+msgstr "Nedá sa otvoriť export templates zip."
#: editor/export_template_manager.cpp
msgid "Invalid version.txt format inside templates: %s."
-msgstr ""
+msgstr "Neplatný version.txt formát vo vnútri šablón: %s."
#: editor/export_template_manager.cpp
msgid "No version.txt found inside templates."
-msgstr ""
+msgstr "Nenašla sa žiadny version.txt vo vnútri šablón."
#: editor/export_template_manager.cpp
msgid "Error creating path for templates:"
-msgstr ""
+msgstr "Chyba pri vytváraní cesty pre šablóny:"
#: editor/export_template_manager.cpp
msgid "Extracting Export Templates"
-msgstr ""
+msgstr "Extrahovanie exportných šablón"
#: editor/export_template_manager.cpp
msgid "Importing:"
-msgstr ""
+msgstr "Importovanie:"
#: editor/export_template_manager.cpp
msgid "Error getting the list of mirrors."
-msgstr ""
+msgstr "Chyba pri získavaní listu zrkadiel."
#: editor/export_template_manager.cpp
msgid "Error parsing JSON of mirror list. Please report this issue!"
-msgstr ""
+msgstr "Chyba pri rozbore JSON listu zrkadiel. Prosím nahláste túto chybu!"
#: editor/export_template_manager.cpp
msgid ""
"No download links found for this version. Direct download is only available "
"for official releases."
msgstr ""
+"Nenašli sa žiadne download linky pre túto verziu. Priame stiahnutie je "
+"dostupný iba pre \"official releases\"."
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't resolve."
-msgstr ""
+msgstr "Nerozpoznané."
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't connect."
-msgstr ""
+msgstr "Nedá sa pripojiť."
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "No response."
-msgstr ""
+msgstr "Žiadna odozva."
#: editor/export_template_manager.cpp
msgid "Request Failed."
-msgstr ""
+msgstr "Žiadosť Zlihala."
#: editor/export_template_manager.cpp
msgid "Redirect Loop."
-msgstr ""
+msgstr "Presmerovanie \"Loop-u\"."
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Failed:"
-msgstr ""
+msgstr "Zlihalo:"
#: editor/export_template_manager.cpp
msgid "Download Complete."
-msgstr ""
+msgstr "InÅ¡talácia je DokonÄená."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Cannot remove temporary file:"
-msgstr "Nemôžete odstrániť:"
+msgstr "Nepodarilo sa vymazaÅ¥ doÄasné súbory:"
#: editor/export_template_manager.cpp
msgid ""
"Templates installation failed.\n"
"The problematic templates archives can be found at '%s'."
msgstr ""
+"Inštalácia šablón zlihala.\n"
+"Archívy problémových šablón nájdete v '%s'."
#: editor/export_template_manager.cpp
msgid "Error requesting URL:"
-msgstr ""
+msgstr "Chyba pri zadávaní URL:"
#: editor/export_template_manager.cpp
msgid "Connecting to Mirror..."
-msgstr ""
+msgstr "Prebieha Pripájanie do Zrkadla..."
#: editor/export_template_manager.cpp
msgid "Disconnected"
-msgstr ""
+msgstr "Odpojené"
#: editor/export_template_manager.cpp
msgid "Resolving"
-msgstr ""
+msgstr "Riešenie"
#: editor/export_template_manager.cpp
msgid "Can't Resolve"
-msgstr ""
+msgstr "Nepodarilo sa Vyriešiť"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Connecting..."
-msgstr ""
+msgstr "Pripájanie..."
#: editor/export_template_manager.cpp
msgid "Can't Connect"
-msgstr ""
+msgstr "Nepodarilo sa pripojiť"
#: editor/export_template_manager.cpp
msgid "Connected"
-msgstr ""
+msgstr "Pripojené"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Requesting..."
-msgstr ""
+msgstr "Requestuje sa..."
#: editor/export_template_manager.cpp
msgid "Downloading"
-msgstr ""
+msgstr "Inštalovanie"
#: editor/export_template_manager.cpp
msgid "Connection Error"
-msgstr ""
+msgstr "Chyba pri Pripájaní"
#: editor/export_template_manager.cpp
msgid "SSL Handshake Error"
-msgstr ""
+msgstr "Chyba SSL Handshake"
#: editor/export_template_manager.cpp
msgid "Uncompressing Android Build Sources"
-msgstr ""
+msgstr "Nekompresované \"Android Build Sources\""
#: editor/export_template_manager.cpp
msgid "Current Version:"
-msgstr ""
+msgstr "Aktuálna Verzia:"
#: editor/export_template_manager.cpp
msgid "Installed Versions:"
-msgstr ""
+msgstr "Inštalované Verzie:"
#: editor/export_template_manager.cpp
msgid "Install From File"
-msgstr ""
+msgstr "Inštalovať Zo Súboru"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Remove Template"
-msgstr "Všetky vybrané"
+msgstr "Vymazať Šablónu"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Select Template File"
-msgstr "Vytvoriť adresár"
+msgstr "Vybrať Súbor Šablóny"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Godot Export Templates"
-msgstr "Všetky vybrané"
+msgstr "Godot Exportovanie Šablón"
#: editor/export_template_manager.cpp
msgid "Export Template Manager"
-msgstr ""
+msgstr "Exportovať Manažera Šablón"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Download Templates"
-msgstr "Všetky vybrané"
+msgstr "Stiahnuť Šablónu"
#: editor/export_template_manager.cpp
msgid "Select mirror from list: (Shift+Click: Open in Browser)"
-msgstr ""
+msgstr "Vybrať zrkadlo z listu: (Shift+Click: Open in Browser)"
#: editor/filesystem_dock.cpp
msgid "Favorites"
-msgstr ""
+msgstr "Obľúbené"
#: editor/filesystem_dock.cpp
msgid "Status: Import of file failed. Please fix file and reimport manually."
msgstr ""
+"Status:Import súboru zlihal. Prosím opravte súbor a manuálne reimportujte."
#: editor/filesystem_dock.cpp
msgid "Cannot move/rename resources root."
-msgstr ""
+msgstr "Nedá sa presunúť/premenovať \"resources root\"."
#: editor/filesystem_dock.cpp
msgid "Cannot move a folder into itself."
-msgstr ""
+msgstr "Nadá sa presunúť priÄinok do toho istého prieÄinku."
#: editor/filesystem_dock.cpp
msgid "Error moving:"
-msgstr ""
+msgstr "Chyba pri presúvaní:"
#: editor/filesystem_dock.cpp
msgid "Error duplicating:"
-msgstr ""
+msgstr "Chyba pri duplikovaní:"
#: editor/filesystem_dock.cpp
msgid "Unable to update dependencies:"
-msgstr ""
+msgstr "Nepodarilo sa update-nuť závislosti:"
#: editor/filesystem_dock.cpp editor/scene_tree_editor.cpp
msgid "No name provided."
-msgstr ""
+msgstr "Nieje uvedené žiadne meno."
#: editor/filesystem_dock.cpp
msgid "Provided name contains invalid characters."
-msgstr ""
+msgstr "Toto meno obsahuje nepodporované písmená."
#: editor/filesystem_dock.cpp
msgid "A file or folder with this name already exists."
-msgstr ""
+msgstr "Súbor alebo prieÄinok s tímto menom už existuje."
#: editor/filesystem_dock.cpp
msgid "Name contains invalid characters."
-msgstr ""
+msgstr "Meno obsahuje neplatné písmená."
#: editor/filesystem_dock.cpp
msgid "Renaming file:"
-msgstr ""
+msgstr "Zostávajúce súbory:"
#: editor/filesystem_dock.cpp
msgid "Renaming folder:"
-msgstr ""
+msgstr "Zostávajúce prieÄinky:"
#: editor/filesystem_dock.cpp
msgid "Duplicating file:"
-msgstr ""
+msgstr "Duplikovanie súborov:"
#: editor/filesystem_dock.cpp
msgid "Duplicating folder:"
-msgstr ""
+msgstr "Duplikovanie prieÄinka:"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Inherited Scene"
-msgstr "Popis:"
+msgstr "Nová Zdedená Scéna"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Set As Main Scene"
-msgstr "Uložiť súbor"
+msgstr "Nastaviť ako Hlavnú Scénu"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Open Scenes"
-msgstr "Otvoriť súbor(y)"
+msgstr "Otvoriť Scény"
#: editor/filesystem_dock.cpp
msgid "Instance"
-msgstr ""
+msgstr "Inštancie"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Add to Favorites"
-msgstr "Obľúbené:"
+msgstr "Pridať do Obľúbených"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Remove from Favorites"
-msgstr "Všetky vybrané"
+msgstr "Odstrániť z Obľúbených"
#: editor/filesystem_dock.cpp
msgid "Edit Dependencies..."
-msgstr ""
+msgstr "Editovať Závislosti..."
#: editor/filesystem_dock.cpp
msgid "View Owners..."
-msgstr ""
+msgstr "Zobraziť Majiteľov..."
#: editor/filesystem_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Rename..."
-msgstr ""
+msgstr "Premenovať..."
#: editor/filesystem_dock.cpp
msgid "Duplicate..."
-msgstr ""
+msgstr "Duplikovať..."
#: editor/filesystem_dock.cpp
msgid "Move To..."
-msgstr ""
+msgstr "Presunúť Do..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Scene..."
-msgstr "Popis:"
+msgstr "Nová Scéna..."
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "New Script..."
-msgstr "Popis:"
+msgstr "Nový Script..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Resource..."
-msgstr "Vytvoriť adresár"
+msgstr "Nový Prostriedok..."
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
msgid "Expand All"
-msgstr ""
+msgstr "Expandovať Všetky"
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
msgid "Collapse All"
-msgstr ""
+msgstr "Collapse All"
#: editor/filesystem_dock.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
#: editor/project_manager.cpp editor/rename_dialog.cpp
#: editor/scene_tree_dock.cpp
msgid "Rename"
-msgstr ""
+msgstr "Premenovať"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Previous Folder/File"
-msgstr "Vytvoriť adresár"
+msgstr "Minulý PrieÄinok/Súbor"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Next Folder/File"
-msgstr "Vytvoriť adresár"
+msgstr "ÄŽalší PrieÄinok/Súbor"
#: editor/filesystem_dock.cpp
msgid "Re-Scan Filesystem"
-msgstr ""
+msgstr "Preskenovať Filesystem"
#: editor/filesystem_dock.cpp
msgid "Toggle Split Mode"
-msgstr ""
+msgstr "Prepnúť Split Mode"
#: editor/filesystem_dock.cpp
msgid "Search files"
-msgstr ""
+msgstr "Vyhľadať súbory"
#: editor/filesystem_dock.cpp
msgid ""
"Scanning Files,\n"
"Please Wait..."
msgstr ""
+"Skenujem Súbory,\n"
+"PoÄkajte Prosím..."
#: editor/filesystem_dock.cpp
msgid "Move"
-msgstr ""
+msgstr "Presunúť"
#: editor/filesystem_dock.cpp
msgid "There is already file or folder with the same name in this location."
-msgstr ""
+msgstr "Už tu je súbor alebo prieÄinok pomenovaný rovnako."
#: editor/filesystem_dock.cpp
msgid "Overwrite"
-msgstr ""
+msgstr "Prepísať"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Create Scene"
-msgstr "Vytvoriť adresár"
+msgstr "Vytvoriť Scénu"
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
msgid "Create Script"
-msgstr ""
+msgstr "Vytvoriť Script"
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Find in Files"
-msgstr "Súbor:"
+msgstr "Nájsť v Súboroch"
#: editor/find_in_files.cpp
msgid "Find:"
-msgstr ""
+msgstr "Nájsť:"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Folder:"
-msgstr "Vytvoriť adresár"
+msgstr "PrieÄinok:"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Filters:"
-msgstr "Filter:"
+msgstr "Filtre:"
#: editor/find_in_files.cpp
msgid ""
"Include the files with the following extensions. Add or remove them in "
"ProjectSettings."
msgstr ""
+"Obsahuje súbory s následujúcimi extensiami. Pridajte ich alebo Odstránte v "
+"NastaveniachProjektu."
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
msgid "Find..."
-msgstr ""
+msgstr "Nájsť..."
#: editor/find_in_files.cpp editor/plugins/script_text_editor.cpp
msgid "Replace..."
-msgstr ""
+msgstr "Nahradiť..."
#: editor/find_in_files.cpp editor/progress_dialog.cpp scene/gui/dialogs.cpp
msgid "Cancel"
-msgstr ""
+msgstr "Zrušiť"
#: editor/find_in_files.cpp
msgid "Find: "
-msgstr ""
+msgstr "Nájsť: "
#: editor/find_in_files.cpp
msgid "Replace: "
-msgstr ""
+msgstr "Nahradiť: "
#: editor/find_in_files.cpp
msgid "Replace all (no undo)"
-msgstr ""
+msgstr "Nahradiť všetky (nedá sa vrátiť späť)"
#: editor/find_in_files.cpp
msgid "Searching..."
-msgstr ""
+msgstr "Vyhľadávam..."
#: editor/find_in_files.cpp
msgid "Search complete"
-msgstr ""
+msgstr "Vyhľadávanie bolo dokonÄené"
#: editor/groups_editor.cpp
msgid "Add to Group"
-msgstr ""
+msgstr "Pridať do Skupiny"
#: editor/groups_editor.cpp
msgid "Remove from Group"
-msgstr ""
+msgstr "Vymazať zo Skupiny"
#: editor/groups_editor.cpp
msgid "Group name already exists."
-msgstr ""
+msgstr "Meno skupiny už existuje."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Invalid group name."
-msgstr "Nesprávna veľkosť písma."
+msgstr "Neplatné meno skupiny."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Rename Group"
-msgstr "Všetky vybrané"
+msgstr "Premenovať Skupinu"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Delete Group"
-msgstr "Všetky vybrané"
+msgstr "Zmazať Skupinu"
#: editor/groups_editor.cpp editor/node_dock.cpp
msgid "Groups"
-msgstr ""
+msgstr "Skupiny"
#: editor/groups_editor.cpp
msgid "Nodes Not in Group"
-msgstr ""
+msgstr "Node-y Nie sú v Skupine"
#: editor/groups_editor.cpp editor/scene_tree_dock.cpp
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Filter nodes"
-msgstr "Filter:"
+msgstr "Filter Node-y"
#: editor/groups_editor.cpp
msgid "Nodes in Group"
-msgstr ""
+msgstr "Node-y v Skupine"
#: editor/groups_editor.cpp
msgid "Empty groups will be automatically removed."
-msgstr ""
+msgstr "Prázdne Skupiny budú automaticky zmazané."
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Group Editor"
-msgstr "Otvorit prieÄinok"
+msgstr "Editor Skupín"
#: editor/groups_editor.cpp
msgid "Manage Groups"
-msgstr ""
+msgstr "Spravovať Skupiny"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Single Scene"
-msgstr ""
+msgstr "Importovať ako Samostatnú Scénu"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Animations"
-msgstr ""
+msgstr "Importovať z Oddelenými Animáciami"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Materials"
-msgstr ""
+msgstr "Importovať z Oddelenými Materiálmi"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects"
-msgstr ""
+msgstr "Importovať z Oddelenými Objektami"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects+Materials"
-msgstr ""
+msgstr "Importovať z Oddelenými Objektami+Materiálmi"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects+Animations"
-msgstr ""
+msgstr "Importovať z Oddelenými Objektami+Animáciami"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Materials+Animations"
-msgstr ""
+msgstr "Importovať z Oddelenými Materiálmi+Animáciami"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects+Materials+Animations"
-msgstr ""
+msgstr "Importovať z Oddelenými Objektami+Materiálmi+Animáciami"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Multiple Scenes"
-msgstr ""
+msgstr "Importovať ako Dvojité Scény"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Multiple Scenes+Materials"
-msgstr ""
+msgstr "Importovať ako Dvojité Scény+Materiály"
#: editor/import/resource_importer_scene.cpp
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Import Scene"
-msgstr ""
+msgstr "Importovať Scénu"
#: editor/import/resource_importer_scene.cpp
msgid "Importing Scene..."
-msgstr ""
+msgstr "Importujem Scénu..."
#: editor/import/resource_importer_scene.cpp
msgid "Generating Lightmaps"
-msgstr ""
+msgstr "Generovanie Lightmaps"
#: editor/import/resource_importer_scene.cpp
msgid "Generating for Mesh: "
-msgstr ""
+msgstr "Generovanie pre Mesh: "
#: editor/import/resource_importer_scene.cpp
msgid "Running Custom Script..."
-msgstr ""
+msgstr "Spustiť Vlastný Script..."
#: editor/import/resource_importer_scene.cpp
msgid "Couldn't load post-import script:"
-msgstr ""
+msgstr "Nepodarilo sa naÄítaÅ¥ post-import script:"
#: editor/import/resource_importer_scene.cpp
msgid "Invalid/broken script for post-import (check console):"
-msgstr ""
+msgstr "Neplatný/rozbitý script pre post-import (prezrite konzolu):"
#: editor/import/resource_importer_scene.cpp
msgid "Error running post-import script:"
-msgstr ""
+msgstr "Chyba pri spustení post-import scriptu:"
+
+#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr "Vrátili ste Node-derived objekt v `post_import()` metóde?"
#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
-msgstr ""
+msgstr "Ukladám..."
#: editor/import_dock.cpp
-#, fuzzy
msgid "%d Files"
-msgstr "Súbor:"
+msgstr "%d Súbory"
#: editor/import_dock.cpp
msgid "Set as Default for '%s'"
-msgstr ""
+msgstr "Nastaviť ako Štandardné pre '%s'"
#: editor/import_dock.cpp
msgid "Clear Default for '%s'"
-msgstr ""
+msgstr "VyÄistiÅ¥ Å tandardné pre '%s'"
#: editor/import_dock.cpp
msgid "Import As:"
-msgstr ""
+msgstr "Importovať Ako:"
#: editor/import_dock.cpp
-#, fuzzy
msgid "Preset"
-msgstr "NaÄítaÅ¥ predvolené"
+msgstr "Preset"
#: editor/import_dock.cpp
msgid "Reimport"
-msgstr ""
+msgstr "Reimportovať"
#: editor/import_dock.cpp
msgid "Save Scenes, Re-Import, and Restart"
-msgstr ""
+msgstr "Uložiť Scény, Re-Importovať, a Reštartovať"
#: editor/import_dock.cpp
msgid "Changing the type of an imported file requires editor restart."
-msgstr ""
+msgstr "Mení sa typ impotovaného súboru, treba reštartovať editor."
#: editor/import_dock.cpp
msgid ""
"WARNING: Assets exist that use this resource, they may stop loading properly."
msgstr ""
+"VAROVANIE: Položky ktoré existujú v tomto prostriedku, Sa nemusia naÄitaÅ¥ "
+"správne."
#: editor/inspector_dock.cpp
msgid "Failed to load resource."
-msgstr ""
+msgstr "Nepodarilo sa naÄítaÅ¥ prostriedok."
#: editor/inspector_dock.cpp
msgid "Expand All Properties"
-msgstr ""
+msgstr "Expandovať Všetky Vlastnosti"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Collapse All Properties"
-msgstr "Filter:"
+msgstr "Collapsovať Všetky Vlastnosti"
#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
msgid "Save As..."
-msgstr ""
+msgstr "Uložiť Ako..."
#: editor/inspector_dock.cpp
msgid "Copy Params"
-msgstr ""
+msgstr "Skopírovať Parametre"
#: editor/inspector_dock.cpp
msgid "Edit Resource Clipboard"
-msgstr ""
+msgstr "Editovať Clipboard Prostriedku"
#: editor/inspector_dock.cpp
msgid "Copy Resource"
-msgstr ""
+msgstr "Skopírovať Prostriedok"
#: editor/inspector_dock.cpp
msgid "Make Built-In"
-msgstr ""
+msgstr "Spraviť Built-In"
#: editor/inspector_dock.cpp
msgid "Make Sub-Resources Unique"
-msgstr ""
+msgstr "Spraviť Sub-Prostriedky Unikátne"
#: editor/inspector_dock.cpp
msgid "Open in Help"
-msgstr ""
+msgstr "Otvoriť v Pomoci"
#: editor/inspector_dock.cpp
msgid "Create a new resource in memory and edit it."
-msgstr ""
+msgstr "Vytvoriť nový prostriedok v pamäti a upraviť ho."
#: editor/inspector_dock.cpp
msgid "Load an existing resource from disk and edit it."
-msgstr ""
+msgstr "NaÄítaÅ¥ existujúci prostriedok z disku a upraviÅ¥ ho."
#: editor/inspector_dock.cpp
msgid "Save the currently edited resource."
-msgstr ""
+msgstr "Uložiť aktuálne upravený prostriedok."
#: editor/inspector_dock.cpp
msgid "Go to the previous edited object in history."
-msgstr ""
+msgstr "ÃsÅ¥ do histórie predchádzajúceho upravovaného objekta."
#: editor/inspector_dock.cpp
msgid "Go to the next edited object in history."
-msgstr ""
+msgstr "ÃsÅ¥ do ÄalÅ¡ej histórie upraveného objekta."
#: editor/inspector_dock.cpp
msgid "History of recently edited objects."
-msgstr ""
+msgstr "História upravených objektov."
#: editor/inspector_dock.cpp
msgid "Object properties."
-msgstr ""
+msgstr "Vlastnosti Objekta."
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Filter properties"
-msgstr "Filter:"
+msgstr "Vlastnosti Filtra"
#: editor/inspector_dock.cpp
msgid "Changes may be lost!"
-msgstr ""
+msgstr "Zmeny môžu byť stratené!"
#: editor/multi_node_edit.cpp
msgid "MultiNode Set"
-msgstr ""
+msgstr "MultiNode Set"
#: editor/node_dock.cpp
msgid "Select a single node to edit its signals and groups."
-msgstr ""
+msgstr "Vyberte jeden node aby ste mohli upraviť jeho signály a skupiny."
#: editor/plugin_config_dialog.cpp
msgid "Edit a Plugin"
-msgstr ""
+msgstr "Upraviť Plugin"
#: editor/plugin_config_dialog.cpp
-#, fuzzy
msgid "Create a Plugin"
-msgstr "Vytvoriť adresár"
+msgstr "Vytvoriť Plugin"
#: editor/plugin_config_dialog.cpp
msgid "Plugin Name:"
-msgstr ""
+msgstr "Meno Pluginu:"
#: editor/plugin_config_dialog.cpp
msgid "Subfolder:"
-msgstr ""
+msgstr "Subfolder:"
#: editor/plugin_config_dialog.cpp editor/script_create_dialog.cpp
msgid "Language:"
-msgstr ""
+msgstr "Jazyk:"
#: editor/plugin_config_dialog.cpp
msgid "Script Name:"
-msgstr ""
+msgstr "Meno Skriptu:"
#: editor/plugin_config_dialog.cpp
msgid "Activate now?"
-msgstr ""
+msgstr "Aktivovať teraz?"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Create Polygon"
-msgstr "Vytvoriť adresár"
+msgstr "Vytvoriť Polygon"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Create points."
-msgstr "Všetky vybrané"
+msgstr "Vytvoriť body."
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid ""
@@ -4138,30 +4120,30 @@ msgid ""
"LMB: Move Point\n"
"RMB: Erase Point"
msgstr ""
+"Upraviť body.\n"
+"LMB: Presunúť Bod\n"
+"RMB: Zmazať Bod"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
msgid "Erase points."
-msgstr "Všetky vybrané"
+msgstr "Zmazať body."
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Edit Polygon"
-msgstr "Signály:"
+msgstr "Upraviť Polygon"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid "Insert Point"
-msgstr ""
+msgstr "Vložiť Bod"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid "Edit Polygon (Remove Point)"
-msgstr ""
+msgstr "Upraviť Polygon (Zmazať Bod)"
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Remove Polygon And Point"
-msgstr "Všetky vybrané"
+msgstr "Zmazať Polygon A Bod"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4169,55 +4151,51 @@ msgstr "Všetky vybrané"
#: editor/plugins/animation_state_machine_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Add Animation"
-msgstr ""
+msgstr "Pridať Animáciu"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Load..."
-msgstr ""
+msgstr "NaÄítaÅ¥..."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Move Node Point"
-msgstr "Všetky vybrané"
+msgstr "Presunúť Bod Node-u"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Change BlendSpace1D Limits"
-msgstr ""
+msgstr "Zmeniť BlendSpace1D Limity"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Change BlendSpace1D Labels"
-msgstr ""
+msgstr "ZmeniÅ¥ BlendSpace1D OznaÄenia"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_state_machine_editor.cpp
msgid "This type of node can't be used. Only root nodes are allowed."
-msgstr ""
+msgstr "Tento typ node-u nemôže byť použitý. Iba ak povolíte root node-y."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Node Point"
-msgstr "Signály:"
+msgstr "Pridať Bod Node-u"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Animation Point"
-msgstr "Popis:"
+msgstr "Pridať Bod Animácie"
#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
msgid "Remove BlendSpace1D Point"
-msgstr "Všetky vybrané"
+msgstr "Zmazať BlendSpace1D Bod"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Move BlendSpace1D Node Point"
-msgstr ""
+msgstr "Presunúť BlendSpace1D Node Bod"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4227,49 +4205,50 @@ msgid ""
"AnimationTree is inactive.\n"
"Activate to enable playback, check node warnings if activation fails."
msgstr ""
+"StromAnimácie je neaktívny.\n"
+"Aktivujte aby ste povolili playback, zaškrtnite node warnings ak aktívacia "
+"nepôjde."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Set the blending position within the space"
-msgstr ""
+msgstr "Nastaviť pozíciu blending v priestore"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Select and move points, create points with RMB."
-msgstr ""
+msgstr "Vyberte a premiestnite body, vytvorte body z RMB."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp
msgid "Enable snap and show grid."
-msgstr ""
+msgstr "Povoliť snap a show grid."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Point"
-msgstr ""
+msgstr "Bod"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Open Editor"
-msgstr "Otvorit prieÄinok"
+msgstr "Otvorit Editor"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Open Animation Node"
-msgstr ""
+msgstr "Otvoriť Node Animácie"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Triangle already exists."
-msgstr ""
+msgstr "Trojuholník už existuje."
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Triangle"
-msgstr "Signály:"
+msgstr "Pridať Trojuholník"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Change BlendSpace2D Limits"
@@ -6942,11 +6921,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7429,6 +7408,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10463,7 +10451,7 @@ msgstr ""
#: editor/scene_tree_dock.cpp
#, fuzzy
-msgid "Clear Script"
+msgid "Detach Script"
msgstr "Popis:"
#: editor/scene_tree_dock.cpp
@@ -10627,6 +10615,13 @@ msgid "Open Documentation"
msgstr "Popis:"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10675,11 +10670,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10805,6 +10800,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Súbor neexistuje."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Nesprávna veľkosť písma."
@@ -10847,6 +10846,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Neplatná cesta."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid class name."
msgstr "Neplatný Názov."
@@ -11920,6 +11923,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11944,6 +11951,32 @@ msgstr "Nesprávna veľkosť písma."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12610,6 +12643,22 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Nieje v resource path."
+
+#~ msgid "Revert"
+#~ msgstr "Revert"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Túto akciu nie je možné vrátiť späť. Chcete Revertovatť aj tak?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Vrátiť Scénu"
+
+#, fuzzy
+#~ msgid "Clear Script"
+#~ msgstr "Popis:"
+
#, fuzzy
#~ msgid "Brief Description"
#~ msgstr "Popis:"
diff --git a/editor/translations/sl.po b/editor/translations/sl.po
index a4a668f76b..faec304f67 100644
--- a/editor/translations/sl.po
+++ b/editor/translations/sl.po
@@ -886,7 +886,6 @@ msgstr "Povezovanje Signala:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1523,18 +1522,9 @@ msgstr "OmogoÄi"
msgid "Rearrange Autoloads"
msgstr "Preuredi SamodejnoNalaganje"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Neveljavna Pot."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Datoteka ne obstaja."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ni na poti virov."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2538,12 +2528,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Ni mogoÄe osvežiti scene, ki ni bila shranjena."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Povrni"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Shrani Prizor"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Tega dejanja ni mogoÄe razveljaviti. Vseeno povrni?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2840,10 +2833,6 @@ msgid "Redo"
msgstr "Ponovi"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Povrni Prizor"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "RazliÄna projektna ali prizorska orodja."
@@ -3498,6 +3487,10 @@ msgstr "Ni mogoÄe zagnati skripte:"
msgid "Did you forget the '_run' method?"
msgstr "Ali si pozabil metodo '_run' ?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Izberi Gradnik(e) za Uvoz"
@@ -4130,6 +4123,10 @@ msgid "Error running post-import script:"
msgstr "Napaka pri zagonu skripte po uvozu:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Shranjevanje..."
@@ -7211,15 +7208,15 @@ msgid ""
msgstr "Odklopite '%s' iz '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Vrstica:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Dodaj Funkcijo"
@@ -7704,6 +7701,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "Pripni na mrežo"
@@ -10790,8 +10796,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Odstrani Gradnik VizualnaSkripta"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10957,6 +10964,13 @@ msgid "Open Documentation"
msgstr "Odpri Nedavne"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -11007,12 +11021,14 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr ""
+"Naredi primer iz izbranih prizorov, ki bo naslednik izbranega gradnika."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -11141,6 +11157,10 @@ msgid "A directory with the same name exists."
msgstr "Datoteka ali mapa s tem imenom že obstaja."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Datoteka ne obstaja."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Uporabiti moraš valjavno razširitev."
@@ -11185,6 +11205,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Neveljavna Pot."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Neveljavno ime."
@@ -12273,6 +12298,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12297,6 +12326,32 @@ msgstr "Neveljavno ime."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12979,6 +13034,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Konstante ni možno spreminjati."
+#~ msgid "Not in resource path."
+#~ msgstr "Ni na poti virov."
+
+#~ msgid "Revert"
+#~ msgstr "Povrni"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Tega dejanja ni mogoÄe razveljaviti. Vseeno povrni?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Povrni Prizor"
+
#~ msgid "Issue Tracker"
#~ msgstr "Sledilnik Napak"
@@ -13179,10 +13246,6 @@ msgstr "Konstante ni možno spreminjati."
#~ msgid "Edit Variable:"
#~ msgstr "Uredi Spremenljivko:"
-#~ msgid "Instance the selected scene(s) as child of the selected node."
-#~ msgstr ""
-#~ "Naredi primer iz izbranih prizorov, ki bo naslednik izbranega gradnika."
-
#~ msgid "Line:"
#~ msgstr "Vrstica:"
diff --git a/editor/translations/sq.po b/editor/translations/sq.po
index f24645059a..5bcf15eb82 100644
--- a/editor/translations/sq.po
+++ b/editor/translations/sq.po
@@ -829,7 +829,6 @@ msgstr "Lidh Sinjalin: "
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1460,18 +1459,9 @@ msgstr "Lejo"
msgid "Rearrange Autoloads"
msgstr "Riorganizo Autoload-et"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Rruga e pasaktë."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Skedari nuk egziston."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Jo në rrugën e resurseve."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2468,12 +2458,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Nuk mund të ringarkojë një skenë që nuk është ruajtur më parë."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Rikthe"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Ruaj Skenën"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Ky veprim nuk mund të çbëhet. Rikthe gjithsesi?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2768,10 +2761,6 @@ msgid "Redo"
msgstr "Ribëj"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Rikthe Skenën"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Vegla të ndryshme për projektin ose skenën."
@@ -3424,6 +3413,10 @@ msgstr "Nuk mund të ekzekutonte shkrimin:"
msgid "Did you forget the '_run' method?"
msgstr "A mos harrove metodën '_run'?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Zgjidh Nyjet Për ti Importuar"
@@ -4041,6 +4034,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Duke Ruajtur..."
@@ -6967,11 +6964,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7448,6 +7445,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10425,8 +10431,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Shkrim i Ri"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10587,6 +10594,13 @@ msgid "Open Documentation"
msgstr "Hap të Fundit"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10636,11 +10650,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10767,6 +10781,10 @@ msgid "A directory with the same name exists."
msgstr "Një skedar ose folder me këtë emër ekziston që më parë."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Skedari nuk egziston."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Duhet të perdorësh një shtesë të lejuar."
@@ -10810,6 +10828,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Rruga e pasaktë."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Emër i palejuar."
@@ -11868,6 +11891,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11891,6 +11918,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12533,6 +12586,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Jo në rrugën e resurseve."
+
+#~ msgid "Revert"
+#~ msgstr "Rikthe"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Ky veprim nuk mund të çbëhet. Rikthe gjithsesi?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Rikthe Skenën"
+
#~ msgid "Issue Tracker"
#~ msgstr "Gjurmuesi i Problemeve"
diff --git a/editor/translations/sr_Cyrl.po b/editor/translations/sr_Cyrl.po
index 52639bbeeb..4e7064f00c 100644
--- a/editor/translations/sr_Cyrl.po
+++ b/editor/translations/sr_Cyrl.po
@@ -4,12 +4,13 @@
# This file is distributed under the same license as the Godot source code.
#
# ÐлекÑандар Урошевић <nicecubedude@gmail.com>, 2017.
-#
+# Младен Габић <cupakabra@protonmail.com>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
-"PO-Revision-Date: 2017-12-14 23:08+0000\n"
-"Last-Translator: ÐлекÑандар Урошевић <alek.sandar0@yandex.com>\n"
+"PO-Revision-Date: 2020-05-22 21:01+0000\n"
+"Last-Translator: Младен Габић <cupakabra@protonmail.com>\n"
"Language-Team: Serbian (cyrillic) <https://hosted.weblate.org/projects/godot-"
"engine/godot/sr_Cyrl/>\n"
"Language: sr_Cyrl\n"
@@ -17,79 +18,78 @@ msgstr ""
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
-"X-Generator: Weblate 2.18-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr ""
+msgstr "Погрешан тип аргумента за функију convert(), кориÑти TYPE_* конÑтанте."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr ""
+msgstr "Очекиван Ñтринг дужине 1 (карактер)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr ""
+msgstr "Ðедовољно бајтова за дешифровање бајтова, или неважећи формат."
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
-msgstr ""
+msgstr "Ðеважећи ÑƒÐ½Ð¾Ñ %i (није прошао) у изразу"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr ""
+msgstr "self не може бити примењен јер је инÑтанца нула(није прошао)"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
-msgstr ""
+msgstr "Ðеважећи поÑтупци оператора %s, %s и %s."
#: core/math/expression.cpp
msgid "Invalid index of type %s for base type %s"
-msgstr ""
+msgstr "Ðеважећи Ð¸Ð½Ð´ÐµÐºÑ Ð²Ñ€Ñте %s за оÑновну врÑту %s"
#: core/math/expression.cpp
msgid "Invalid named index '%s' for base type %s"
-msgstr ""
+msgstr "Ðеважећи именовани Ð¸Ð½Ð´ÐµÐºÑ '%s' за оÑновну врÑту %s"
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr ""
+msgstr "Ðеважећи аргументи ка конÑтрукту '%s'"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr ""
+msgstr "Ðа позиву за '%s':"
#: core/ustring.cpp
msgid "B"
-msgstr ""
+msgstr "Б"
#: core/ustring.cpp
msgid "KiB"
-msgstr ""
+msgstr "КиБ"
#: core/ustring.cpp
-#, fuzzy
msgid "MiB"
-msgstr "МикÑ"
+msgstr "МиБ"
#: core/ustring.cpp
msgid "GiB"
-msgstr ""
+msgstr "ГиБ"
#: core/ustring.cpp
msgid "TiB"
-msgstr ""
+msgstr "ТиБ"
#: core/ustring.cpp
msgid "PiB"
-msgstr ""
+msgstr "ПиБ"
#: core/ustring.cpp
msgid "EiB"
-msgstr ""
+msgstr "ЕиБ"
#: editor/animation_bezier_editor.cpp
msgid "Free"
@@ -97,12 +97,12 @@ msgstr "Слободно"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
-msgstr ""
+msgstr "БаланÑирано"
#: editor/animation_bezier_editor.cpp
#, fuzzy
msgid "Mirror"
-msgstr "Огледало X оÑе"
+msgstr "Огледало"
#: editor/animation_bezier_editor.cpp editor/editor_profiler.cpp
msgid "Time:"
@@ -111,32 +111,30 @@ msgstr "Време:"
#: editor/animation_bezier_editor.cpp
#, fuzzy
msgid "Value:"
-msgstr "Ðово име:"
+msgstr "ВредноÑÑ‚:"
#: editor/animation_bezier_editor.cpp
#, fuzzy
msgid "Insert Key Here"
-msgstr "Убаци кључеве"
+msgstr "Убаци кључ"
#: editor/animation_bezier_editor.cpp
#, fuzzy
msgid "Duplicate Selected Key(s)"
-msgstr "Дуплирај одабрано"
+msgstr "Дуплирај одабрани Кључ/еве"
#: editor/animation_bezier_editor.cpp
-#, fuzzy
msgid "Delete Selected Key(s)"
-msgstr "Обриши одабране датотеке?"
+msgstr "Обриши одабрани Кључ/еве"
#: editor/animation_bezier_editor.cpp
#, fuzzy
msgid "Add Bezier Point"
-msgstr "Додај тачку"
+msgstr "Додај Безиер Тачку"
#: editor/animation_bezier_editor.cpp
-#, fuzzy
msgid "Move Bezier Points"
-msgstr "Помери тачку"
+msgstr "Помери Безиер Тачку"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
@@ -149,7 +147,7 @@ msgstr "Уколни кључеве"
#: editor/animation_track_editor.cpp
#, fuzzy
msgid "Anim Change Keyframe Time"
-msgstr "Промени вредноÑÑ‚"
+msgstr "Промени време КључОквира"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transition"
@@ -204,25 +202,29 @@ msgid "Change Animation Loop"
msgstr "Промени Ñ†Ð¸ÐºÐ»ÑƒÑ Ð°Ð½Ð¸Ð¼Ð°Ñ†Ð¸Ñ˜Ðµ"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Property Track"
-msgstr ""
+msgstr "ОÑобине Трака"
#: editor/animation_track_editor.cpp
#, fuzzy
msgid "3D Transform Track"
-msgstr "Тип транÑформације"
+msgstr "3Д Трака ТранÑформа"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Call Method Track"
-msgstr ""
+msgstr "Метод Позива Трака"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Bezier Curve Track"
-msgstr ""
+msgstr "Безиер Крива Трака"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Audio Playback Track"
-msgstr ""
+msgstr "Ðудио Репродукција Трака"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -251,8 +253,9 @@ msgstr "Скала анимације."
#: editor/animation_track_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Functions:"
-msgstr ""
+msgstr "Функције:"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -261,7 +264,7 @@ msgstr "Звучни Ñлушалац"
#: editor/animation_track_editor.cpp
msgid "Anim Clips:"
-msgstr ""
+msgstr "Ðним Клипови:"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -274,8 +277,9 @@ msgid "Toggle this track on/off."
msgstr "Укљ./ИÑкљ. режим без Ñметње."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Update Mode (How this property is set)"
-msgstr ""
+msgstr "Режим ажурирања (Како је поÑтављена ова оÑобина)"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -283,8 +287,9 @@ msgid "Interpolation Mode"
msgstr "Ðнимациони чвор"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
-msgstr ""
+msgstr "Круг Увијени Режим( Интерполирај крај Ñа почетком на кругу)"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -319,8 +324,9 @@ msgid "Capture"
msgstr "КарактериÑтике"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Nearest"
-msgstr ""
+msgstr "Ðајближи"
#: editor/animation_track_editor.cpp editor/plugins/curve_editor_plugin.cpp
#: editor/property_editor.cpp
@@ -328,16 +334,19 @@ msgid "Linear"
msgstr "Линеаран"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Cubic"
-msgstr ""
+msgstr "Кубни"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Clamp Loop Interp"
-msgstr ""
+msgstr "Притегнут Круг Интерп"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Wrap Loop Interp"
-msgstr ""
+msgstr "Увијен Круг Интерп"
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
@@ -398,8 +407,9 @@ msgid "Anim Insert"
msgstr "Ðалепи"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "AnimationPlayer can't animate itself, only other players."
-msgstr ""
+msgstr "AnimationPlayer не може Ñам Ñебе да анимира, Ñамо друге плејере."
#: editor/animation_track_editor.cpp
msgid "Anim Create & Insert"
@@ -425,31 +435,40 @@ msgstr "Преуреди аутоматÑка учитавања"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr ""
+msgstr "ТранÑформа траке Ñамо важи за ПроÑторно-базиране нодове."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid ""
"Audio tracks can only point to nodes of type:\n"
"-AudioStreamPlayer\n"
"-AudioStreamPlayer2D\n"
"-AudioStreamPlayer3D"
msgstr ""
+"Ðудио траке могу Ñамо уÑмеравати ка нодовима врÑте:\n"
+"-AudioStreamPlayer\n"
+"-AudioStreamPlayer2D\n"
+"-AudioStreamPlayer3D"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Animation tracks can only point to AnimationPlayer nodes."
-msgstr ""
+msgstr "Ðнимационе траке могу Ñамо уÑмеравати ка AnimationPlayer нодовима"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "An animation player can't animate itself, only other players."
-msgstr ""
+msgstr "Ðнимациони плејер не може анимирати Ñамог Ñебе, Ñамо друге плејере."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Not possible to add a new track without a root"
-msgstr ""
+msgstr "Ðије могуже додати нову траку без корена"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Invalid track for Bezier (no suitable sub-properties)"
-msgstr ""
+msgstr "Ðеважећа трака за Безиер ( нема прикладних под-оÑобина)"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -457,12 +476,14 @@ msgid "Add Bezier Track"
msgstr "Додај нову траку"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Track path is invalid, so can't add a key."
-msgstr ""
+msgstr "Путања траке је неважећа, па је кључ немогуће додати."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Track is not of type Spatial, can't insert key"
-msgstr ""
+msgstr "Трака није врÑте ПроÑторна, немогуће убацити кључ."
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -475,8 +496,9 @@ msgid "Add Track Key"
msgstr "Додај нову траку"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Track path is invalid, so can't add a method key."
-msgstr ""
+msgstr "Трака путање је неважећа, немогуће додати кључ методе."
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -484,8 +506,9 @@ msgid "Add Method Track Key"
msgstr "Уметни траку и кључ"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Method not found in object: "
-msgstr ""
+msgstr "Метода није нађена у објекту:"
#: editor/animation_track_editor.cpp
msgid "Anim Move Keys"
@@ -506,11 +529,13 @@ msgid "Anim Scale Keys"
msgstr "Увећај кључеве"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid ""
"This option does not work for Bezier editing, as it's only a single track."
-msgstr ""
+msgstr "Ова операција не ради за Безиер уређивање, пошто је Ñамо једна трака."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid ""
"This animation belongs to an imported scene, so changes to imported tracks "
"will not be saved.\n"
@@ -522,10 +547,20 @@ msgid ""
"Alternatively, use an import preset that imports animations to separate "
"files."
msgstr ""
+"Ова анимација припада увезеној Ñцени, па промене на увезеној траци неће бити "
+"Ñачуване.\n"
+"\n"
+"Да омогућиш ÑпоÑобноÑÑ‚ додавања прилагођених трака, упути Ñе ка увозним "
+"подешавањима Ñцене и поÑтави\n"
+"\"Ðнимација > Складиште\" у \"Фајлови\", омогући \"Ðнимација > Сачувај "
+"прилагођене траке\", онда поново увези.\n"
+"Ðлтернативно, кориÑти увозна подешавања која увозе анимације у заÑебне "
+"фајлове."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Warning: Editing imported animation"
-msgstr ""
+msgstr "Упозорење: Уређивање увезене анимације"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -533,12 +568,14 @@ msgid "Select an AnimationPlayer node to create and edit animations."
msgstr "Одабери AnimationPlayer из дрвета Ñцене за уређивање анимација."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Only show tracks from nodes selected in tree."
-msgstr ""
+msgstr "Прикажи Ñамо траке из нодова одабраних у Ñтаблу"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Group tracks by node or display them as plain list."
-msgstr ""
+msgstr "Групиши траке по нодовима или их прикажи као чиÑÑ‚ текÑÑ‚."
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -551,8 +588,9 @@ msgid "Animation step value."
msgstr "Ðнимационо дрво је важеће."
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Seconds"
-msgstr ""
+msgstr "Секунди"
#: editor/animation_track_editor.cpp
msgid "FPS"
@@ -618,12 +656,14 @@ msgid "Clean-Up Animation"
msgstr "ОчиÑтите анимацију"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Pick the node that will be animated:"
-msgstr ""
+msgstr "Одабери нод који ће бити анимиран:"
#: editor/animation_track_editor.cpp
+#, fuzzy
msgid "Use Bezier Curves"
-msgstr ""
+msgstr "КориÑти Безиер Криве"
#: editor/animation_track_editor.cpp
msgid "Anim. Optimizer"
@@ -694,12 +734,14 @@ msgid "Add Audio Track Clip"
msgstr "Звучни Ñлушалац"
#: editor/animation_track_editor_plugins.cpp
+#, fuzzy
msgid "Change Audio Track Clip Start Offset"
-msgstr ""
+msgstr "Промени Размак Ðудио Траке од Почетка"
#: editor/animation_track_editor_plugins.cpp
+#, fuzzy
msgid "Change Audio Track Clip End Offset"
-msgstr ""
+msgstr "Промени Размак Ðудио Траке од Краја"
#: editor/array_property_edit.cpp
msgid "Resize Array"
@@ -727,13 +769,14 @@ msgid "%d replaced."
msgstr "Замени..."
#: editor/code_editor.cpp editor/editor_help.cpp
+#, fuzzy
msgid "%d match."
-msgstr ""
+msgstr "%d подударања."
#: editor/code_editor.cpp editor/editor_help.cpp
#, fuzzy
msgid "%d matches."
-msgstr "Ðема подудара"
+msgstr "Ðема подударања."
#: editor/code_editor.cpp editor/find_in_files.cpp
msgid "Match Case"
@@ -757,8 +800,9 @@ msgstr "Само одабрано"
#: editor/code_editor.cpp editor/plugins/script_text_editor.cpp
#: editor/plugins/text_editor.cpp
+#, fuzzy
msgid "Standard"
-msgstr ""
+msgstr "Стандард"
#: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp
msgid "Toggle Scripts Panel"
@@ -781,12 +825,14 @@ msgid "Reset Zoom"
msgstr "РеÑетуј увеличање"
#: editor/code_editor.cpp
+#, fuzzy
msgid "Warnings"
-msgstr ""
+msgstr "Упозорење"
#: editor/code_editor.cpp
+#, fuzzy
msgid "Line and column numbers."
-msgstr ""
+msgstr "Линија и колона бројева."
#: editor/connections_dialog.cpp
#, fuzzy
@@ -862,17 +908,19 @@ msgid "Deferred"
msgstr "Одложен"
#: editor/connections_dialog.cpp
+#, fuzzy
msgid ""
"Defers the signal, storing it in a queue and only firing it at idle time."
-msgstr ""
+msgstr "Одлаже Ñигнал, памти га у ред и пали га Ñамо за време чекања."
#: editor/connections_dialog.cpp
msgid "Oneshot"
msgstr "Једном"
#: editor/connections_dialog.cpp
+#, fuzzy
msgid "Disconnects the signal after its first emission."
-msgstr ""
+msgstr "Одкачиње Ñигнал поÑле првог емитовања."
#: editor/connections_dialog.cpp
#, fuzzy
@@ -883,7 +931,6 @@ msgstr "Везујући Ñигнал:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -937,16 +984,18 @@ msgid "Edit Connection:"
msgstr "Повезивање не уÑпешно"
#: editor/connections_dialog.cpp
+#, fuzzy
msgid "Are you sure you want to remove all connections from the \"%s\" signal?"
-msgstr ""
+msgstr "Сигурно желиш да уклониш Ñве везе Ñа \"%s\" Ñигналом?"
#: editor/connections_dialog.cpp editor/editor_help.cpp editor/node_dock.cpp
msgid "Signals"
msgstr "Сигнали"
#: editor/connections_dialog.cpp
+#, fuzzy
msgid "Are you sure you want to remove all connections from this signal?"
-msgstr ""
+msgstr "Сугурно желиш да уклониш Ñве везе Ñа овог Ñигнала?"
#: editor/connections_dialog.cpp
#, fuzzy
@@ -969,8 +1018,9 @@ msgid "Change %s Type"
msgstr "Измени уобичајен тип"
#: editor/create_dialog.cpp editor/project_settings_editor.cpp
+#, fuzzy
msgid "Change"
-msgstr ""
+msgstr "Промени"
#: editor/create_dialog.cpp
#, fuzzy
@@ -1263,8 +1313,9 @@ msgid "Uncompressing Assets"
msgstr "ДекомпреÑија ÑредÑтва"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
+#, fuzzy
msgid "The following files failed extraction from package:"
-msgstr ""
+msgstr "ÐеуÑпело извлачење Ñледећих фалова из паковања:"
#: editor/editor_asset_installer.cpp
#, fuzzy
@@ -1374,8 +1425,9 @@ msgid "Delete Effect"
msgstr "Обриши ефекат"
#: editor/editor_audio_buses.cpp
+#, fuzzy
msgid "Audio"
-msgstr ""
+msgstr "Ðудио"
#: editor/editor_audio_buses.cpp
msgid "Add Audio Bus"
@@ -1414,8 +1466,9 @@ msgid "Open Audio Bus Layout"
msgstr "Отвори раÑпоред звучног баÑа"
#: editor/editor_audio_buses.cpp
+#, fuzzy
msgid "There is no '%s' file."
-msgstr ""
+msgstr "Ðема '%s' фајла."
#: editor/editor_audio_buses.cpp editor/plugins/canvas_item_editor_plugin.cpp
msgid "Layout"
@@ -1493,8 +1546,9 @@ msgid "Must not collide with an existing global constant name."
msgstr "Ðеважеће име. Име је резервиÑано за поÑтојећу глобалну конÑтанту."
#: editor/editor_autoload_settings.cpp
+#, fuzzy
msgid "Keyword cannot be used as an autoload name."
-msgstr ""
+msgstr "Кључна реч не може бити употребљена као ауто-учитавајуће име"
#: editor/editor_autoload_settings.cpp
msgid "Autoload '%s' already exists!"
@@ -1524,18 +1578,9 @@ msgstr "Укључи"
msgid "Rearrange Autoloads"
msgstr "Преуреди аутоматÑка учитавања"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Ðеважећи пут."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Датотека не поÑтоји."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ðије на пут реÑурÑа."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1584,8 +1629,9 @@ msgid "[empty]"
msgstr "(празно)"
#: editor/editor_data.cpp
+#, fuzzy
msgid "[unsaved]"
-msgstr ""
+msgstr "[неÑачувано]"
#: editor/editor_dir_dialog.cpp
#, fuzzy
@@ -1623,32 +1669,44 @@ msgid "Storing File:"
msgstr "Складиштење датотеке:"
#: editor/editor_export.cpp
+#, fuzzy
msgid "No export template found at the expected path:"
-msgstr ""
+msgstr "Извозни образац није нађен на очекиваној путањи:"
#: editor/editor_export.cpp
msgid "Packing"
msgstr "Паковање"
#: editor/editor_export.cpp
+#, fuzzy
msgid ""
"Target platform requires 'ETC' texture compression for GLES2. Enable 'Import "
"Etc' in Project Settings."
msgstr ""
+"Циљана платформа захтева 'ETC' компреÑију текÑтуре за GLES2. Омогући 'Увоз "
+"Etc' у подешавањима пројекта."
#: editor/editor_export.cpp
+#, fuzzy
msgid ""
"Target platform requires 'ETC2' texture compression for GLES3. Enable "
"'Import Etc 2' in Project Settings."
msgstr ""
+"Циљана платформа захтева 'ETC2 компреÑију текÑтуре за GLES3. Омогући 'Увоз "
+"Etc 2' у подешавањима пројекта."
#: editor/editor_export.cpp
+#, fuzzy
msgid ""
"Target platform requires 'ETC' texture compression for the driver fallback "
"to GLES2.\n"
"Enable 'Import Etc' in Project Settings, or disable 'Driver Fallback "
"Enabled'."
msgstr ""
+"Циљана платформа захтева 'ETC' компреÑију текÑтуре за повратак управљача "
+"GLES2.\n"
+"Омогући 'Увоз Etc' у подешавањима пројекта, или онемогући 'Поваратак "
+"Управљача Омогућен'."
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
@@ -1660,8 +1718,9 @@ msgstr "ШаблонÑка датотека није пронађена:\n"
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
#: platform/osx/export/export.cpp platform/uwp/export/export.cpp
+#, fuzzy
msgid "Custom release template not found."
-msgstr ""
+msgstr "Прилагођени образци објаве ниÑу пронађени."
#: editor/editor_export.cpp platform/javascript/export/export.cpp
#, fuzzy
@@ -1669,8 +1728,9 @@ msgid "Template file not found:"
msgstr "ШаблонÑка датотека није пронађена:\n"
#: editor/editor_export.cpp
+#, fuzzy
msgid "On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."
-msgstr ""
+msgstr "Ðа 32-битним извозима уграђени PCK не може бити већи од 4 GiB."
#: editor/editor_feature_profile.cpp
#, fuzzy
@@ -1688,8 +1748,9 @@ msgid "Asset Library"
msgstr "Отвори библиотеку ÑредÑтва"
#: editor/editor_feature_profile.cpp
+#, fuzzy
msgid "Scene Tree Editing"
-msgstr ""
+msgstr "Едитовање Стабла Сцене"
#: editor/editor_feature_profile.cpp
#, fuzzy
@@ -1712,8 +1773,9 @@ msgid "Erase profile '%s'? (no undo)"
msgstr "Замени Ñве"
#: editor/editor_feature_profile.cpp
+#, fuzzy
msgid "Profile must be a valid filename and must not contain '.'"
-msgstr ""
+msgstr "Профил мора имати важеће име фајла и не Ñме Ñадржати '.'"
#: editor/editor_feature_profile.cpp
#, fuzzy
@@ -1721,8 +1783,9 @@ msgid "Profile with this name already exists."
msgstr "Датотека или директоријум Ñа овим именом већ поÑтоји."
#: editor/editor_feature_profile.cpp
+#, fuzzy
msgid "(Editor Disabled, Properties Disabled)"
-msgstr ""
+msgstr "(Уређивач Онемогућен, СвојÑтва Омогућена)"
#: editor/editor_feature_profile.cpp
#, fuzzy
@@ -1760,14 +1823,16 @@ msgid "Enabled Classes:"
msgstr "Потражи клаÑе"
#: editor/editor_feature_profile.cpp
+#, fuzzy
msgid "File '%s' format is invalid, import aborted."
-msgstr ""
+msgstr "Фајл '%s' формат је неважећи, увоз отказан."
#: editor/editor_feature_profile.cpp
+#, fuzzy
msgid ""
"Profile '%s' already exists. Remove it first before importing, import "
"aborted."
-msgstr ""
+msgstr "Профил '%s' већ поÑтоји. Уклони га пре увоза, увоз отказан."
#: editor/editor_feature_profile.cpp
#, fuzzy
@@ -1775,8 +1840,9 @@ msgid "Error saving profile to path: '%s'."
msgstr "Грешка при чувању TileSet!"
#: editor/editor_feature_profile.cpp
+#, fuzzy
msgid "Unset"
-msgstr ""
+msgstr "Поништи"
#: editor/editor_feature_profile.cpp
#, fuzzy
@@ -2014,10 +2080,13 @@ msgid "ScanSources"
msgstr "Скенирање извора"
#: editor/editor_file_system.cpp
+#, fuzzy
msgid ""
"There are multiple importers for different types pointing to file %s, import "
"aborted"
msgstr ""
+"ПоÑтоји више увозника за различите врÑте који показују на фајл %s, увоз "
+"отказан"
#: editor/editor_file_system.cpp
msgid "(Re)Importing Assets"
@@ -2055,8 +2124,9 @@ msgid "Properties"
msgstr "ОÑобине"
#: editor/editor_help.cpp
+#, fuzzy
msgid "override:"
-msgstr ""
+msgstr "препиши"
#: editor/editor_help.cpp
#, fuzzy
@@ -2195,16 +2265,19 @@ msgid "Theme Property"
msgstr "ОÑобине"
#: editor/editor_inspector.cpp editor/project_settings_editor.cpp
+#, fuzzy
msgid "Property:"
-msgstr ""
+msgstr "ОÑобина:"
#: editor/editor_inspector.cpp
+#, fuzzy
msgid "Set"
-msgstr ""
+msgstr "ПоÑтави"
#: editor/editor_inspector.cpp
+#, fuzzy
msgid "Set Multiple:"
-msgstr ""
+msgstr "ПоÑтави Више:"
#: editor/editor_log.cpp
msgid "Output:"
@@ -2242,8 +2315,9 @@ msgid "Start"
msgstr "Започни!"
#: editor/editor_network_profiler.cpp
+#, fuzzy
msgid "%s/s"
-msgstr ""
+msgstr "%s/s"
#: editor/editor_network_profiler.cpp
#, fuzzy
@@ -2251,51 +2325,62 @@ msgid "Down"
msgstr "Преучми"
#: editor/editor_network_profiler.cpp
+#, fuzzy
msgid "Up"
-msgstr ""
+msgstr "Горе"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
msgid "Node"
msgstr "Чвор"
#: editor/editor_network_profiler.cpp
+#, fuzzy
msgid "Incoming RPC"
-msgstr ""
+msgstr "Долазећи RPC"
#: editor/editor_network_profiler.cpp
+#, fuzzy
msgid "Incoming RSET"
-msgstr ""
+msgstr "Долазећи RSET"
#: editor/editor_network_profiler.cpp
+#, fuzzy
msgid "Outgoing RPC"
-msgstr ""
+msgstr "Одлазећи RPC"
#: editor/editor_network_profiler.cpp
+#, fuzzy
msgid "Outgoing RSET"
-msgstr ""
+msgstr "Одлазећи RSET"
#: editor/editor_node.cpp editor/project_manager.cpp
+#, fuzzy
msgid "New Window"
-msgstr ""
+msgstr "Ðов Прозор"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Imported resources can't be saved."
-msgstr ""
+msgstr "Увезени реÑурÑи не могу бити упамћени."
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: scene/gui/dialogs.cpp
+#, fuzzy
msgid "OK"
-msgstr ""
+msgstr "ОК"
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Error saving resource!"
msgstr "Грешка при чувању реÑурÑа!"
#: editor/editor_node.cpp
+#, fuzzy
msgid ""
"This resource can't be saved because it does not belong to the edited scene. "
"Make it unique first."
msgstr ""
+"Овај реÑÑƒÑ€Ñ Ð½Ðµ може бити упамћен пошто не припада едитованој Ñцени. Прво га "
+"учини јединÑтвеним."
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Save Resource As..."
@@ -2314,8 +2399,9 @@ msgid "Error while saving."
msgstr "Грешка при чувању."
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
+#, fuzzy
msgid "Can't open '%s'. The file could have been moved or deleted."
-msgstr ""
+msgstr "ÐеуÑпело отварање '%s'. Фајл је можда померен или обриÑан."
#: editor/editor_node.cpp
msgid "Error while parsing '%s'."
@@ -2350,10 +2436,13 @@ msgid "This operation can't be done without a tree root."
msgstr "Ова операција Ñе не може обавити без корена дрвета."
#: editor/editor_node.cpp
+#, fuzzy
msgid ""
"This scene can't be saved because there is a cyclic instancing inclusion.\n"
"Please resolve it and then attempt to save again."
msgstr ""
+"Ова Ñцена не може бити упамћена зато што има укључење кружног инÑтанцирања\n"
+"Прво га отклони и онда поново пробај да упамтиш."
#: editor/editor_node.cpp
#, fuzzy
@@ -2363,8 +2452,9 @@ msgid ""
msgstr "Ðе могу Ñачувати Ñцену. Вероватно завиÑноÑти ниÑу задовољене."
#: editor/editor_node.cpp editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Can't overwrite scene that is still open!"
-msgstr ""
+msgstr "Ðемогуће препиÑивање Ñцене која је и даље отворена!"
#: editor/editor_node.cpp
msgid "Can't load MeshLibrary for merging!"
@@ -2496,8 +2586,9 @@ msgid "Saved %s modified resource(s)."
msgstr "Грешка при учитавању реÑурÑа."
#: editor/editor_node.cpp
+#, fuzzy
msgid "A root node is required to save the scene."
-msgstr ""
+msgstr "За памћене Ñцене неопходан је корени нод."
#: editor/editor_node.cpp
msgid "Save Scene As..."
@@ -2544,12 +2635,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Ðе могу поново учитати Ñцену која није Ñачувана."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Врати"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Сачувај Ñцену"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Ова акција Ñе не може опозвати. ÐаÑтави?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2728,8 +2822,9 @@ msgid "Close Other Tabs"
msgstr "Затвори оÑтале зупчанике"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Close Tabs to the Right"
-msgstr ""
+msgstr "Затвори Табове Ñа ДеÑна"
#: editor/editor_node.cpp
#, fuzzy
@@ -2845,10 +2940,6 @@ msgid "Redo"
msgstr "Поново уради"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Поврати Ñцену"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Разни алати за пројекат или Ñцену."
@@ -2868,12 +2959,14 @@ msgid "Version Control"
msgstr "Верзија:"
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Set Up Version Control"
-msgstr ""
+msgstr "ПоÑтави Контролу Верзије"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Shut Down Version Control"
-msgstr ""
+msgstr "УгаÑи Контролу Верзије"
#: editor/editor_node.cpp
#, fuzzy
@@ -2881,8 +2974,9 @@ msgid "Export..."
msgstr "Извоз"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Install Android Build Template..."
-msgstr ""
+msgstr "ИнÑталирај Android образце градње"
#: editor/editor_node.cpp
#, fuzzy
@@ -3032,8 +3126,9 @@ msgid "Open Editor Data/Settings Folder"
msgstr "ПоÑтавке уредника"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Open Editor Data Folder"
-msgstr ""
+msgstr "Отвори Фолдер Уређивача Података"
#: editor/editor_node.cpp
#, fuzzy
@@ -3078,8 +3173,9 @@ msgid "Report a Bug"
msgstr "Поново увези"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Send Docs Feedback"
-msgstr ""
+msgstr "Пошаљи Подржку о Документацији"
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
msgid "Community"
@@ -3087,7 +3183,7 @@ msgstr "Заједница"
#: editor/editor_node.cpp
msgid "About"
-msgstr "О програму"
+msgstr "О"
#: editor/editor_node.cpp
msgid "Play the project."
@@ -3098,8 +3194,9 @@ msgid "Play"
msgstr "Покрени"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Pause the scene execution for debugging."
-msgstr ""
+msgstr "Паузирај извршење Ñцене зарад отклањања грешки."
#: editor/editor_node.cpp
msgid "Pause Scene"
@@ -3126,8 +3223,9 @@ msgid "Play Custom Scene"
msgstr "Покрени Ñпецифичну Ñцену"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Changing the video driver requires restarting the editor."
-msgstr ""
+msgstr "Промена видео управљача захтева реÑтартовање уређивача."
#: editor/editor_node.cpp editor/project_settings_editor.cpp
#: editor/settings_config_dialog.cpp
@@ -3177,8 +3275,9 @@ msgid "Don't Save"
msgstr "Ðемој Ñачувати"
#: editor/editor_node.cpp
+#, fuzzy
msgid "Android build template is missing, please install relevant templates."
-msgstr ""
+msgstr "ÐедоÑтаје Android образац за изградњу, инÑталирај релевантне обраÑце."
#: editor/editor_node.cpp
#, fuzzy
@@ -3186,6 +3285,7 @@ msgid "Manage Templates"
msgstr "Управљај извозним шаблонима"
#: editor/editor_node.cpp
+#, fuzzy
msgid ""
"This will set up your project for custom Android builds by installing the "
"source template to \"res://android/build\".\n"
@@ -3195,14 +3295,26 @@ msgid ""
"the \"Use Custom Build\" option should be enabled in the Android export "
"preset."
msgstr ""
+"Ово ће подеÑити твој пројекат за произвољну Android грању инÑталирајући "
+"изворни образац у \"res://android/build\".\n"
+"Затим можеш применити измене и изградити ÑопÑтвени APK на извозу (додајући "
+"модуле, променом AndroidManifest.xml, итд.).\n"
+"Имај на уму да за произвољну градњу умеÑто коришћења изграђеног APK-а, "
+"\"КориÑти Произвољну Градњу\" опција треба бити омогућена у Android извозним "
+"подешавањима."
#: editor/editor_node.cpp
+#, fuzzy
msgid ""
"The Android build template is already installed in this project and it won't "
"be overwritten.\n"
"Remove the \"res://android/build\" directory manually before attempting this "
"operation again."
msgstr ""
+"Android образац градње је већ инÑталиран у овај пројекат и неће бити "
+"препиÑан.\n"
+"Уклони \"res://android/build\" директоријум ручно пре поновног покушавања "
+"ове операције."
#: editor/editor_node.cpp
msgid "Import Templates From ZIP File"
@@ -3262,8 +3374,9 @@ msgid "Open the previous Editor"
msgstr "Отвори претходни уредник"
#: editor/editor_node.h
+#, fuzzy
msgid "Warning!"
-msgstr ""
+msgstr "Упозорење!"
#: editor/editor_path.cpp
#, fuzzy
@@ -3366,12 +3479,14 @@ msgid "On"
msgstr ""
#: editor/editor_properties.cpp
+#, fuzzy
msgid "Layer"
-msgstr ""
+msgstr "Лајер"
#: editor/editor_properties.cpp
+#, fuzzy
msgid "Bit %d, value %d"
-msgstr ""
+msgstr "Бит %d, вредноÑÑ‚ %d"
#: editor/editor_properties.cpp
#, fuzzy
@@ -3379,8 +3494,9 @@ msgid "[Empty]"
msgstr "Додај празан"
#: editor/editor_properties.cpp editor/plugins/root_motion_editor_plugin.cpp
+#, fuzzy
msgid "Assign..."
-msgstr ""
+msgstr "Додели..."
#: editor/editor_properties.cpp
#, fuzzy
@@ -3388,45 +3504,60 @@ msgid "Invalid RID"
msgstr "Ðеважеће име."
#: editor/editor_properties.cpp
+#, fuzzy
msgid ""
"The selected resource (%s) does not match any type expected for this "
"property (%s)."
msgstr ""
+"Одабрани реÑÑƒÑ€Ñ (%s) не одговара ни једној очекиваној врÑти за ову оÑобину "
+"(%s)."
#: editor/editor_properties.cpp
+#, fuzzy
msgid ""
"Can't create a ViewportTexture on resources saved as a file.\n"
"Resource needs to belong to a scene."
msgstr ""
+"ÐеуÑпело креирање ViewportTexture на реÑурÑима упамћеним као фајл\n"
+"РеÑурÑи морају припадати Ñцени."
#: editor/editor_properties.cpp
+#, fuzzy
msgid ""
"Can't create a ViewportTexture on this resource because it's not set as "
"local to scene.\n"
"Please switch on the 'local to scene' property on it (and all resources "
"containing it up to a node)."
msgstr ""
+"ÐеуÑпело креирање ViewportTexture на реÑурÑима, није поÑтављено као локално "
+"према Ñцени\n"
+"Пребаци на 'локално према Ñцени' оÑобину ( и Ñви реÑурÑи који их Ñадрже "
+"Ñве до нода)."
#: editor/editor_properties.cpp editor/property_editor.cpp
+#, fuzzy
msgid "Pick a Viewport"
-msgstr ""
+msgstr "Одабери Viewport"
#: editor/editor_properties.cpp editor/property_editor.cpp
+#, fuzzy
msgid "New Script"
-msgstr ""
+msgstr "Ðова Скрипта"
#: editor/editor_properties.cpp editor/scene_tree_dock.cpp
#, fuzzy
msgid "Extend Script"
-msgstr "Покрени Ñкриптицу"
+msgstr "Ðадовежи Скрипту"
#: editor/editor_properties.cpp editor/property_editor.cpp
+#, fuzzy
msgid "New %s"
-msgstr ""
+msgstr "Ðов %s"
#: editor/editor_properties.cpp editor/property_editor.cpp
+#, fuzzy
msgid "Make Unique"
-msgstr ""
+msgstr "Учини ЈединÑтвеним"
#: editor/editor_properties.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
@@ -3443,20 +3574,24 @@ msgid "Paste"
msgstr "Ðалепи"
#: editor/editor_properties.cpp editor/property_editor.cpp
+#, fuzzy
msgid "Convert To %s"
-msgstr ""
+msgstr "Пребаци у %s"
#: editor/editor_properties.cpp editor/property_editor.cpp
+#, fuzzy
msgid "Selected node is not a Viewport!"
-msgstr ""
+msgstr "Одабрани нод није Viewport!"
#: editor/editor_properties_array_dict.cpp
+#, fuzzy
msgid "Size: "
-msgstr ""
+msgstr "Величина:"
#: editor/editor_properties_array_dict.cpp
+#, fuzzy
msgid "Page: "
-msgstr ""
+msgstr "Страна:"
#: editor/editor_properties_array_dict.cpp
#: editor/plugins/theme_editor_plugin.cpp
@@ -3466,16 +3601,17 @@ msgstr "Обриши Ñтавку"
#: editor/editor_properties_array_dict.cpp
#, fuzzy
msgid "New Key:"
-msgstr "Ðово име:"
+msgstr "Ðов кључ:"
#: editor/editor_properties_array_dict.cpp
#, fuzzy
msgid "New Value:"
-msgstr "Ðово име:"
+msgstr "Ðова вредноÑÑ‚:"
#: editor/editor_properties_array_dict.cpp
+#, fuzzy
msgid "Add Key/Value Pair"
-msgstr ""
+msgstr "Додај Кључ/ВредноÑÑ‚ пар"
#: editor/editor_run_native.cpp
msgid ""
@@ -3509,13 +3645,19 @@ msgstr "ÐеуÑпех при покретању Ñкриптице:"
msgid "Did you forget the '_run' method?"
msgstr "Да ли Ñте заборавили методу „_run“?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr "Држи Ctrl да иÑпуÑтиш Узимача. Држи Shift да иÑпуÑтиш општи потпиÑ."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Одабери чвор/ове за увоз"
#: editor/editor_sub_scene.cpp editor/project_manager.cpp
+#, fuzzy
msgid "Browse"
-msgstr ""
+msgstr "Потражи"
#: editor/editor_sub_scene.cpp
msgid "Scene Path:"
@@ -3544,8 +3686,9 @@ msgid "Download"
msgstr "Преучми"
#: editor/export_template_manager.cpp
+#, fuzzy
msgid "Official export templates aren't available for development builds."
-msgstr ""
+msgstr "Званични извозни нацрти ниÑу доÑтупни за развојну градњу."
#: editor/export_template_manager.cpp
msgid "(Missing)"
@@ -3590,12 +3733,15 @@ msgid "Importing:"
msgstr "Увожење:"
#: editor/export_template_manager.cpp
+#, fuzzy
msgid "Error getting the list of mirrors."
-msgstr ""
+msgstr "Грешка у добијању лиÑте огледала."
#: editor/export_template_manager.cpp
+#, fuzzy
msgid "Error parsing JSON of mirror list. Please report this issue!"
msgstr ""
+"Грешка при JSON обради Ñа лиÑте огледала. Молимо пријавите овај проблем!"
#: editor/export_template_manager.cpp
msgid ""
@@ -3644,10 +3790,13 @@ msgid "Cannot remove temporary file:"
msgstr "ÐеуÑпех при чувању теме:"
#: editor/export_template_manager.cpp
+#, fuzzy
msgid ""
"Templates installation failed.\n"
"The problematic templates archives can be found at '%s'."
msgstr ""
+"ИнÑталација нацрта неуÑпешна.\n"
+"Ðрхиве проблематичних нацрта могу би нађене на '%s'."
#: editor/export_template_manager.cpp
#, fuzzy
@@ -3943,8 +4092,9 @@ msgid "There is already file or folder with the same name in this location."
msgstr "Датотека или директоријум Ñа овим именом већ поÑтоји."
#: editor/filesystem_dock.cpp
+#, fuzzy
msgid "Overwrite"
-msgstr ""
+msgstr "Препиши"
#: editor/filesystem_dock.cpp
#, fuzzy
@@ -3976,10 +4126,13 @@ msgid "Filters:"
msgstr "Филтери..."
#: editor/find_in_files.cpp
+#, fuzzy
msgid ""
"Include the files with the following extensions. Add or remove them in "
"ProjectSettings."
msgstr ""
+"Урачунај фајлове Ñа Ñледећим екÑтензијама. Додај или обриши их у "
+"ПодешавањимаПројекта"
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
@@ -3991,8 +4144,9 @@ msgid "Replace..."
msgstr "Замени..."
#: editor/find_in_files.cpp editor/progress_dialog.cpp scene/gui/dialogs.cpp
+#, fuzzy
msgid "Cancel"
-msgstr ""
+msgstr "Откажи"
#: editor/find_in_files.cpp
#, fuzzy
@@ -4058,8 +4212,9 @@ msgstr "Додај у групу"
#: editor/groups_editor.cpp editor/scene_tree_dock.cpp
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Filter nodes"
-msgstr ""
+msgstr "Филтрирај чворове"
#: editor/groups_editor.cpp
#, fuzzy
@@ -4067,8 +4222,9 @@ msgid "Nodes in Group"
msgstr "Додај у групу"
#: editor/groups_editor.cpp
+#, fuzzy
msgid "Empty groups will be automatically removed."
-msgstr ""
+msgstr "Празне групе биће аутоматÑки уклоњене."
#: editor/groups_editor.cpp
#, fuzzy
@@ -4156,13 +4312,17 @@ msgid "Error running post-import script:"
msgstr "Грешка при обрађивању поÑÑ‚-увозне Ñкриптице:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Чување..."
#: editor/import_dock.cpp
#, fuzzy
msgid "%d Files"
-msgstr " Датотеке"
+msgstr " %d Датотеке"
#: editor/import_dock.cpp
msgid "Set as Default for '%s'"
@@ -4186,17 +4346,22 @@ msgid "Reimport"
msgstr "Поново увези"
#: editor/import_dock.cpp
+#, fuzzy
msgid "Save Scenes, Re-Import, and Restart"
-msgstr ""
+msgstr "Упамти Сцену, Опет Увези, и РеÑтартуј"
#: editor/import_dock.cpp
+#, fuzzy
msgid "Changing the type of an imported file requires editor restart."
-msgstr ""
+msgstr "Промена врÑте увезених фајлова захтева реÑтарт уређивача."
#: editor/import_dock.cpp
+#, fuzzy
msgid ""
"WARNING: Assets exist that use this resource, they may stop loading properly."
msgstr ""
+"УПОЗОРЕЊЕ: ПоÑтоје ÑредÑтва која кориÑте овај реÑурÑ, могу преÑтати да Ñе "
+"учитавају правилно."
#: editor/inspector_dock.cpp
msgid "Failed to load resource."
@@ -4273,7 +4438,7 @@ msgstr "ПоÑтавке објекта."
#: editor/inspector_dock.cpp
#, fuzzy
msgid "Filter properties"
-msgstr "ПоÑтавке објекта."
+msgstr "ПречиÑти оÑобине"
#: editor/inspector_dock.cpp
msgid "Changes may be lost!"
@@ -4291,33 +4456,37 @@ msgstr "Одабери чвор за мењање Ñигнала и група."
#: editor/plugin_config_dialog.cpp
#, fuzzy
msgid "Edit a Plugin"
-msgstr "Измени полигон"
+msgstr "Измени Прикључак"
#: editor/plugin_config_dialog.cpp
#, fuzzy
msgid "Create a Plugin"
-msgstr "Ðаправи ивице"
+msgstr "Ðаправи Прикључак"
#: editor/plugin_config_dialog.cpp
#, fuzzy
msgid "Plugin Name:"
-msgstr "Прикључци"
+msgstr "Име Прикључка :"
#: editor/plugin_config_dialog.cpp
+#, fuzzy
msgid "Subfolder:"
-msgstr ""
+msgstr "ПодФолдер:"
#: editor/plugin_config_dialog.cpp editor/script_create_dialog.cpp
+#, fuzzy
msgid "Language:"
-msgstr ""
+msgstr "Језик:"
#: editor/plugin_config_dialog.cpp
+#, fuzzy
msgid "Script Name:"
-msgstr ""
+msgstr "Име Скрипте:"
#: editor/plugin_config_dialog.cpp
+#, fuzzy
msgid "Activate now?"
-msgstr ""
+msgstr "Ðктивирај Ñад?"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
@@ -4330,7 +4499,7 @@ msgstr "Ðаправи полигон"
#: editor/plugins/animation_blend_space_2d_editor.cpp
#, fuzzy
msgid "Create points."
-msgstr "Обриши тачке"
+msgstr "Ðаправи тачке."
#: editor/plugins/abstract_polygon_2d_editor.cpp
#, fuzzy
@@ -4404,8 +4573,10 @@ msgstr "Промени време мешања"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "This type of node can't be used. Only root nodes are allowed."
msgstr ""
+"Ова врÑта чвора Ñе не може кориÑтити. Само корени чворови Ñу дозвољени."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4425,32 +4596,40 @@ msgid "Remove BlendSpace1D Point"
msgstr "Обриши тачку путање"
#: editor/plugins/animation_blend_space_1d_editor.cpp
+#, fuzzy
msgid "Move BlendSpace1D Node Point"
-msgstr ""
+msgstr "Помери BlendSpace1D Чворну Тачку"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid ""
"AnimationTree is inactive.\n"
"Activate to enable playback, check node warnings if activation fails."
msgstr ""
+"AnimationTree је неактивно.\n"
+"Ðктивирај да омогућиш репродукцију, провери чвор упозорења ако активација не "
+"уÑпе."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "Set the blending position within the space"
-msgstr ""
+msgstr "ПоÑтави Ñтопљиву позицију Ñа размаком"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "Select and move points, create points with RMB."
-msgstr ""
+msgstr "Одабери и помери тачке, направи тачке Ñа RMB."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp
+#, fuzzy
msgid "Enable snap and show grid."
-msgstr ""
+msgstr "Омогући лепљење и прикажи мрежу."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4476,12 +4655,12 @@ msgstr "Ðнимациони чвор"
#: editor/plugins/animation_blend_space_2d_editor.cpp
#, fuzzy
msgid "Triangle already exists."
-msgstr "Грешка: име анимације већ поÑтоји!"
+msgstr "Троугао већ поÑтоји."
#: editor/plugins/animation_blend_space_2d_editor.cpp
#, fuzzy
msgid "Add Triangle"
-msgstr "Додај нову траку"
+msgstr "Додај Троугао"
#: editor/plugins/animation_blend_space_2d_editor.cpp
#, fuzzy
@@ -4499,33 +4678,39 @@ msgid "Remove BlendSpace2D Point"
msgstr "Обриши тачку путање"
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "Remove BlendSpace2D Triangle"
-msgstr ""
+msgstr "Уклони BlendSpace2D Троугао"
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "BlendSpace2D does not belong to an AnimationTree node."
-msgstr ""
+msgstr "BlendSpace2D не припада AnimationTree чвору."
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "No triangles exist, so no blending can take place."
-msgstr ""
+msgstr "Троуглови не поÑтоје, па Ñе утапање не може догодити."
#: editor/plugins/animation_blend_space_2d_editor.cpp
#, fuzzy
msgid "Toggle Auto Triangles"
-msgstr "Укљ./ИÑкљ. глобале аутоматÑког учитавања"
+msgstr "Укљ./ИÑкљ. Троуглове"
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "Create triangles by connecting points."
-msgstr ""
+msgstr "Ðаправи троуглове Ñпајајући тачке."
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "Erase points and triangles."
-msgstr ""
+msgstr "Обриши тачке и троуглове."
#: editor/plugins/animation_blend_space_2d_editor.cpp
+#, fuzzy
msgid "Generate blend triangles automatically (instead of manually)"
-msgstr ""
+msgstr "Произведи Ñтопљене троуглове аутоматÑки (умеÑто ручно)"
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -4543,34 +4728,37 @@ msgid "Edit Filters"
msgstr "Уреди филтере"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
+#, fuzzy
msgid "Output node can't be added to the blend tree."
-msgstr ""
+msgstr "Излазни чвор не може бити додат утапајућем Ñтаблу."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
+#, fuzzy
msgid "Add Node to BlendTree"
-msgstr ""
+msgstr "Додај Чвор УтапајућемСтаблу"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Node Moved"
-msgstr "Режим померања"
+msgstr "Чвор Поморен"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
+#, fuzzy
msgid "Unable to connect, port may be in use or connection may be invalid."
-msgstr ""
+msgstr "ÐеуÑпела веза, порт може бити заузет или не важећи."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Nodes Connected"
-msgstr "Повезан"
+msgstr "Чворови Спојени"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Nodes Disconnected"
-msgstr "Веза прекинута"
+msgstr "Чворови Раздвојени"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#, fuzzy
@@ -4581,37 +4769,43 @@ msgstr "Ðнимација"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Delete Node"
-msgstr "Ðаправи чвор"
+msgstr "Обриши Чвор"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Delete Node(s)"
-msgstr ""
+msgstr "Обриши Чвор(ове)"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#, fuzzy
msgid "Toggle Filter On/Off"
-msgstr "Укљ./ИÑкљ. режим без Ñметње."
+msgstr "Укљ./ИÑкљ. филтере."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#, fuzzy
msgid "Change Filter"
-msgstr "Измени дужину анимације"
+msgstr "Измени Филтер"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
+#, fuzzy
msgid "No animation player set, so unable to retrieve track names."
-msgstr ""
+msgstr "Ðнимациони плејер није поÑтављен, неуÑпешно повлачење имена трака."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
+#, fuzzy
msgid "Player path set is invalid, so unable to retrieve track names."
-msgstr ""
+msgstr "Ðеважећа путања плејера, неуÑпешно повлачење имена трака."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/root_motion_editor_plugin.cpp
+#, fuzzy
msgid ""
"Animation player has no valid root node path, so unable to retrieve track "
"names."
msgstr ""
+"Ðнимациони плејер нема правилну путању кореног чвора, неуÑпешно повлачење "
+"имена трака."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#, fuzzy
@@ -4636,8 +4830,9 @@ msgstr "Име чвора:"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Add Node..."
-msgstr ""
+msgstr "Додај Чвор..."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/root_motion_editor_plugin.cpp
@@ -4785,13 +4980,14 @@ msgid "Autoplay on Load"
msgstr "ÐутоматÑко пуштање након учитавања"
#: editor/plugins/animation_player_editor_plugin.cpp
+#, fuzzy
msgid "Enable Onion Skinning"
-msgstr ""
+msgstr "Омогући Слојевито Обмотавање"
#: editor/plugins/animation_player_editor_plugin.cpp
#, fuzzy
msgid "Onion Skinning Options"
-msgstr "ПоÑтавке залепљавања"
+msgstr "Опције Слојевитог Обмотавања"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Directions"
@@ -4868,105 +5064,121 @@ msgstr "Вишеанимационо време мешања"
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Move Node"
-msgstr "Режим померања"
+msgstr "Помери Чвор"
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Transition exists!"
-msgstr "Померај"
+msgstr "Прелаз поÑтоји!"
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Add Transition"
-msgstr "Померај"
+msgstr "Додај Прелаз"
#: editor/plugins/animation_state_machine_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Add Node"
-msgstr ""
+msgstr "Додај Чвор"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "End"
-msgstr ""
+msgstr "Крај"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Immediate"
-msgstr ""
+msgstr "ÐепоÑредан"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Sync"
-msgstr ""
+msgstr "УÑклади"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "At End"
-msgstr ""
+msgstr "Ðа Крај"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Travel"
-msgstr ""
+msgstr "Путуј"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Start and end nodes are needed for a sub-transition."
-msgstr ""
+msgstr "Почетни и крајњи чвор Ñу потребни за под-прелаз."
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "No playback resource set at path: %s."
-msgstr "Ðије на пут реÑурÑа."
+msgstr "Ðема репородуктивних реÑурÑа поÑтављених као путања: %s."
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Node Removed"
-msgstr "Обриши"
+msgstr "Чвор Уклоњен"
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Transition Removed"
-msgstr "Transition чвор"
+msgstr "Прелаз Уклољен"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Set Start Node (Autoplay)"
-msgstr ""
+msgstr "ПоÑтави Почетни Чвор(ауто-покретање)"
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid ""
"Select and move nodes.\n"
"RMB to add new nodes.\n"
"Shift+LMB to create connections."
msgstr ""
+"Одабери и помери чворове.\n"
+"RMB да додаш нове чворове.\n"
+"Shift+LMB да креираш конекције."
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Create new nodes."
-msgstr "Ðаправи нов"
+msgstr "Ðаправи нов."
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Connect nodes."
-msgstr "Повежи Ñа чвором:"
+msgstr "Повежи чворове."
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Remove selected node or transition."
-msgstr "Обриши одабрану траку."
+msgstr "Обриши одабрани чвор или прелаз."
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Toggle autoplay this animation on start, restart or seek to zero."
msgstr ""
+"ИÑкљ/Укљ ауто-покретање ове анимације на почетак, поновни почетак или "
+"претрагу нуле."
#: editor/plugins/animation_state_machine_editor.cpp
+#, fuzzy
msgid "Set the end animation. This is useful for sub-transitions."
-msgstr ""
+msgstr "ПоÑтави крај анимације. Ово је кориÑно за под-прелазе."
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Transition: "
-msgstr "Померај"
+msgstr "Прелаз:"
#: editor/plugins/animation_state_machine_editor.cpp
#, fuzzy
msgid "Play Mode:"
-msgstr "Режим инÑпекције"
+msgstr "Режим Игре:"
#: editor/plugins/animation_tree_editor_plugin.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -5149,8 +5361,9 @@ msgid "Cannot save response to:"
msgstr "ÐеуÑпех при чувању теме:"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "Write error."
-msgstr ""
+msgstr "Грешка при упиÑивању."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Request failed, too many redirects"
@@ -5199,7 +5412,7 @@ msgstr "Преузимање у току"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "Downloading..."
-msgstr "Преузимање у току"
+msgstr "Преузимање..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Resolving..."
@@ -5216,7 +5429,7 @@ msgstr "Ðеактиван"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "Install..."
-msgstr "ИнÑталирај"
+msgstr "ИнÑталирај..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Retry"
@@ -5231,35 +5444,39 @@ msgid "Download for this asset is already in progress!"
msgstr "Преузимање овог реÑурÑа је у току!"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "Recently Updated"
-msgstr ""
+msgstr "Ðедавно Ðжурирано"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "Least Recently Updated"
-msgstr ""
+msgstr "ПоÑледње Ðедавно Ðжурирано"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "Name (A-Z)"
-msgstr ""
+msgstr "Име (A-Z)"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "Name (Z-A)"
-msgstr ""
+msgstr "Име (Z-A)"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "License (A-Z)"
-msgstr "ЛиценÑа"
+msgstr "ЛиценÑа (A-Z)"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "License (Z-A)"
-msgstr "ЛиценÑа"
+msgstr "ЛиценÑа (Z-A)"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "First"
-msgstr "први"
+msgstr "Први"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
@@ -5271,16 +5488,18 @@ msgid "Next"
msgstr "Следеће"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "Last"
-msgstr ""
+msgstr "ПоÑледњи"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "All"
msgstr "Ñви"
#: editor/plugins/asset_library_editor_plugin.cpp
+#, fuzzy
msgid "No results for \"%s\"."
-msgstr ""
+msgstr "Ðема резултата за \"%s\"."
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
@@ -5321,32 +5540,42 @@ msgstr "ТеÑтирање"
#: editor/plugins/asset_library_editor_plugin.cpp
#, fuzzy
msgid "Loading..."
-msgstr "Учитај"
+msgstr "Учитај..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Assets ZIP File"
msgstr "РеÑурÑи ЗИП датотека"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
+#, fuzzy
msgid ""
"Can't determine a save path for lightmap images.\n"
"Save your scene (for images to be saved in the same dir), or pick a save "
"path from the BakedLightmap properties."
msgstr ""
+"ÐеуÑпело одређивање путање памћења за Ñлике МапеСенчења.\n"
+"Упамти Ñцену (за Ñлике да буду Ñачуване у иÑтом директоријуму), или одабери "
+"путању памћења из оÑобина изпечене МапеСенчења."
#: editor/plugins/baked_lightmap_editor_plugin.cpp
+#, fuzzy
msgid ""
"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake "
"Light' flag is on."
msgstr ""
+"Ðема мрежа за печење. Провери да ли Ñадрже UV2 канал и да је опција 'Изпеци "
+"Светла' укључена."
#: editor/plugins/baked_lightmap_editor_plugin.cpp
+#, fuzzy
msgid "Failed creating lightmap images, make sure path is writable."
msgstr ""
+"ÐеуÑпешно креирање Ñлике МапеСенчења, провери да ли могуће упиÑивање путање."
#: editor/plugins/baked_lightmap_editor_plugin.cpp
+#, fuzzy
msgid "Bake Lightmaps"
-msgstr ""
+msgstr "Изпеци МапеСенчења"
#: editor/plugins/camera_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp editor/rename_dialog.cpp
@@ -5366,13 +5595,14 @@ msgid "Grid Step:"
msgstr "Корак мреже:"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Primary Line Every:"
-msgstr ""
+msgstr "Примарна Линија Сваки:"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "steps"
-msgstr "2 корака"
+msgstr "корака"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation Offset:"
@@ -5385,7 +5615,7 @@ msgstr "Ротације корака:"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Scale Step:"
-msgstr "Скала:"
+msgstr "Корак Увећања:"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
@@ -5453,64 +5683,70 @@ msgid "Move CanvasItem"
msgstr "Уреди CanvasItem"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid ""
"Children of containers have their anchors and margins values overridden by "
"their parent."
-msgstr ""
+msgstr "Деца наÑлеђују Ñидра и граничне вредноÑти од Ñвојих родитеља."
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Presets for the anchors and margins values of a Control node."
-msgstr ""
+msgstr "ПоÑтавке Ñидара и граничних вредноÑти Контролног чвора."
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid ""
"When active, moving Control nodes changes their anchors instead of their "
"margins."
msgstr ""
+"Када Ñу активни, померање Контролних чворова мења њихова Ñидра умеÑто "
+"маргина."
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Top Left"
-msgstr "Лево"
+msgstr "Горе Лево"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Top Right"
-msgstr "деÑно"
+msgstr "Горе ДеÑно"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Bottom Right"
-msgstr "Ротирај полигон"
+msgstr "Доле ДеÑно"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Bottom Left"
-msgstr "Поглед одоздо"
+msgstr "Доле Лево"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Center Left"
-msgstr "Увучи лево"
+msgstr "Средина Лево"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Center Top"
-msgstr "Центрирај одабрано"
+msgstr "Средина Горе"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Center Right"
-msgstr "Увучи деÑно"
+msgstr "Средина ДеÑно"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Center Bottom"
-msgstr "Доле"
+msgstr "Средина Доле"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Center"
-msgstr ""
+msgstr "Средина"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
@@ -5533,21 +5769,24 @@ msgid "Bottom Wide"
msgstr "Поглед одоздо"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "VCenter Wide"
-msgstr ""
+msgstr "Вертикална Средина Широко"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "HCenter Wide"
-msgstr ""
+msgstr "Хоризонтална Средина Широко"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Full Rect"
-msgstr ""
+msgstr "Пун Правоугаоник"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Keep Ratio"
-msgstr "Размера Ñкале:"
+msgstr "Задржи одноÑ"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Anchors only"
@@ -5563,41 +5802,47 @@ msgstr "Промени Ñидра"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid ""
"Game Camera Override\n"
"Overrides game camera with editor viewport camera."
msgstr ""
+"Препиши Играчку Камеру\n"
+"Препиши играчку камеру Ñа камером уређивача viewport-а."
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid ""
"Game Camera Override\n"
"No game instance running."
msgstr ""
+"Препиши Играчку Камеру\n"
+"ИнÑтанца игре није покренута."
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Lock Selected"
-msgstr "Избор алатки"
+msgstr "Закључај одабрано"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Unlock Selected"
-msgstr "Избор алатки"
+msgstr "Откључај одабрано"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Group Selected"
-msgstr "Обриши одабрано"
+msgstr "Групиши Одабрано"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Ungroup Selected"
-msgstr "Обриши одабрано"
+msgstr "Разгрупиши Одабрано"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Paste Pose"
@@ -5627,10 +5872,11 @@ msgid "Clear IK Chain"
msgstr "ОчиÑти IK ланац"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid ""
"Warning: Children of a container get their position and size determined only "
"by their parent."
-msgstr ""
+msgstr "Упозорење: Деца наÑлеђују позицију и величину Ñамо од Ñвојих родитеља."
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
@@ -5675,7 +5921,7 @@ msgstr "Режим ротације"
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Scale Mode"
-msgstr "Режим Ñкалирања (R)"
+msgstr "Режим Увећања"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5697,32 +5943,32 @@ msgstr "Режим инÑпекције"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Ruler Mode"
-msgstr "Режим Ñкалирања (R)"
+msgstr "Режим Мерења"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Toggle smart snapping."
-msgstr "Укљ./ИÑкљ. лепљења"
+msgstr "Укљ./ИÑкљ. лепљења."
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Use Smart Snap"
-msgstr "КориÑти лепљење"
+msgstr "КориÑти паметно лепљење"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Toggle grid snapping."
-msgstr "Укљ./ИÑкљ. лепљења"
+msgstr "Укљ./ИÑкљ. лепљење за мрежу."
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Use Grid Snap"
-msgstr "Лепљење по мрежи"
+msgstr "Лепљење за мрежу"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Snapping Options"
-msgstr "ПоÑтавке залепљавања"
+msgstr "ПоÑтавке Залепљавања"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Use Rotation Snap"
@@ -5731,7 +5977,7 @@ msgstr "КориÑти лепљење ротације"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Use Scale Snap"
-msgstr "КориÑти лепљење"
+msgstr "КориÑти ЛеÑтвично Лепљење"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snap Relative"
@@ -5744,7 +5990,7 @@ msgstr "КориÑти лепљење за пикÑеле"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Smart Snapping"
-msgstr "Паметно лепљење"
+msgstr "Паметно Лепљење"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5754,22 +6000,22 @@ msgstr "ПоÑтавке лепљења..."
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Snap to Parent"
-msgstr "Лепи за родитеља"
+msgstr "Лепи за Родитеља"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Snap to Node Anchor"
-msgstr "Лепи за Ñидро чвора"
+msgstr "Лепи за Сидро Чвора"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Snap to Node Sides"
-msgstr "Лепи за Ñтране чвора"
+msgstr "Лепи за Стране Чвора"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Snap to Node Center"
-msgstr "Лепи за Ñидро чвора"
+msgstr "Лепи за Сидро Чвора"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
@@ -5811,13 +6057,14 @@ msgid "Show Bones"
msgstr "Покажи коÑти"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Make Custom Bone(s) from Node(s)"
-msgstr ""
+msgstr "Ðаправи Произвољне КоÑти од Чворова"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Clear Custom Bones"
-msgstr "Обриши коÑти"
+msgstr "Обриши КоÑти"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5852,8 +6099,9 @@ msgid "Show Viewport"
msgstr "1 прозор"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Show Group And Lock Icons"
-msgstr ""
+msgstr "Прикажи Групу и Закључане Иконице"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Center Selection"
@@ -5864,43 +6112,52 @@ msgid "Frame Selection"
msgstr "Ибор рама"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Preview Canvas Scale"
-msgstr ""
+msgstr "Преглед Величине Платна"
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Translation mask for inserting keys."
-msgstr ""
+msgstr "Преводна маÑка за убацивање кључева."
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Rotation mask for inserting keys."
-msgstr ""
+msgstr "Ротациона маÑка за убацивање кључева."
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Scale mask for inserting keys."
-msgstr ""
+msgstr "ЛеÑтвична маÑка за убацивање кључева."
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Insert keys (based on mask)."
-msgstr "Убаци кључ (поÑтојеће траке)"
+msgstr "Убаци кључеве (базиране на маÑци)."
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid ""
"Auto insert keys when objects are translated, rotated or scaled (based on "
"mask).\n"
"Keys are only added to existing tracks, no new tracks will be created.\n"
"Keys must be inserted manually for the first time."
msgstr ""
+"ÐутоматÑки убаци кључеве где Ñу објекти преведени, ротирирани или увећани "
+"(базирано на маÑци).\n"
+"Кључеви Ñу додани Ñамо поÑтојећим тракама, нове траке неће бити креиране.\n"
+"Кључеви први пут морају бити убачени ручно."
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Auto Insert Key"
-msgstr "Уметни кључ"
+msgstr "Ðуто-Уметни кључ"
#: editor/plugins/canvas_item_editor_plugin.cpp
#, fuzzy
msgid "Animation Key and Pose Options"
-msgstr "Ðнимациони кључ убачен."
+msgstr "Опције Ðнимациононг кључа и Позе"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key (Existing Tracks)"
@@ -5936,8 +6193,9 @@ msgid "Adding %s..."
msgstr "Додавање %s..."
#: editor/plugins/canvas_item_editor_plugin.cpp
+#, fuzzy
msgid "Cannot instantiate multiple nodes without root."
-msgstr ""
+msgstr "ÐеуÑпело инÑтанцирање више чворова без корена."
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
@@ -6015,19 +6273,21 @@ msgstr "МаÑка емиÑије"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
+#, fuzzy
msgid "Solid Pixels"
-msgstr ""
+msgstr "ПикÑели Тела"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
+#, fuzzy
msgid "Border Pixels"
-msgstr ""
+msgstr "ПикÑели Оквира"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
#, fuzzy
msgid "Directed Border Pixels"
-msgstr "Директоријуми и датотеке:"
+msgstr "ПикÑели УÑмерених Оквира"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
@@ -6042,7 +6302,7 @@ msgstr "Боје емиÑије"
#: editor/plugins/cpu_particles_editor_plugin.cpp
#, fuzzy
msgid "CPUParticles"
-msgstr "ЧеÑтице"
+msgstr "CPU ЧеÑтице"
#: editor/plugins/cpu_particles_editor_plugin.cpp
#: editor/plugins/particles_editor_plugin.cpp
@@ -6065,12 +6325,14 @@ msgid "Flat 1"
msgstr "Раван1"
#: editor/plugins/curve_editor_plugin.cpp editor/property_editor.cpp
+#, fuzzy
msgid "Ease In"
-msgstr ""
+msgstr "Благ Почетак"
#: editor/plugins/curve_editor_plugin.cpp editor/property_editor.cpp
+#, fuzzy
msgid "Ease Out"
-msgstr ""
+msgstr "Благ Крај"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Smoothstep"
@@ -6135,8 +6397,9 @@ msgid "Bake GI Probe"
msgstr "ИÑпечи Ñонде глобалног оÑветљења (GI)"
#: editor/plugins/gradient_editor_plugin.cpp
+#, fuzzy
msgid "Gradient Edited"
-msgstr ""
+msgstr "Ðагиб Измењен"
#: editor/plugins/item_list_editor_plugin.cpp
msgid "Item %d"
@@ -6161,7 +6424,7 @@ msgstr "Мрежа је празна!"
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "Couldn't create a Trimesh collision shape."
-msgstr "Ðаправи троуглаÑтог Ñударног брата"
+msgstr "ÐеуÑпело креирање три-мрежног Ñударног облика."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Static Trimesh Body"
@@ -6174,54 +6437,61 @@ msgstr "Ово не ради на корену Ñцене!"
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "Create Trimesh Static Shape"
-msgstr "Ðаправи фигуру од троуглова"
+msgstr "Ðаправи облик од троуглова"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Can't create a single convex collision shape for the scene root."
-msgstr ""
+msgstr "ÐеуÑпело креирање једног конвекÑног Ñудардног облика за корен Ñцене."
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Couldn't create a single convex collision shape."
-msgstr ""
+msgstr "ÐеуÑпело креирање једног конвекÑног Ñударног облика."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "Create Single Convex Shape"
-msgstr "Ðаправи конвекÑну фигуру"
+msgstr "Ðаправи конвекÑну облик"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Can't create multiple convex collision shapes for the scene root."
-msgstr ""
+msgstr "ÐеуÑпело креирање више конвекÑних Ñударних облика за корен Ñцене."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "Couldn't create any collision shapes."
-msgstr "ÐеуÑпех при прављењу директоријума."
+msgstr "ÐеуÑпело креирање Ñударног облика."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "Create Multiple Convex Shapes"
-msgstr "Ðаправи конвекÑну фигуру"
+msgstr "Ðаправи конвекÑни облик"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Navigation Mesh"
msgstr "Ðаправи навигациону мрежу"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Contained Mesh is not of type ArrayMesh."
-msgstr ""
+msgstr "Садржана-Мрежа није од врÑте Ðиз-Мрежа."
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "UV Unwrap failed, mesh may not be manifold?"
-msgstr ""
+msgstr "ÐеуÑпешно UV одмотавање, можда мрежа није многоÑтрука?"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "No mesh to debug."
-msgstr ""
+msgstr "Ðема мреже за проверу."
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Model has no UV in this layer"
-msgstr ""
+msgstr "Модел нема UV мапу на овом Ñлоју"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "MeshInstance lacks a Mesh!"
@@ -6232,8 +6502,9 @@ msgid "Mesh has not surface to create outlines from!"
msgstr "Мрежа нема површине за прављење ивица!"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Mesh primitive type is not PRIMITIVE_TRIANGLES!"
-msgstr ""
+msgstr "Примитивна врÑта Мреже није ПРИМИТИВÐИ_ТРОУГЛОВИ!"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Could not create outline!"
@@ -6252,21 +6523,27 @@ msgid "Create Trimesh Static Body"
msgstr "Ðаправи троуглаÑто Ñтатично тело"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid ""
"Creates a StaticBody and assigns a polygon-based collision shape to it "
"automatically.\n"
"This is the most accurate (but slowest) option for collision detection."
msgstr ""
+" Креира ÐепомичноТело и додељује му Ñударни облик на бази многоугла "
+"аутоматÑки."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Trimesh Collision Sibling"
msgstr "Ðаправи троуглаÑтог Ñударног брата"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid ""
"Creates a polygon-based collision shape.\n"
"This is the most accurate (but slowest) option for collision detection."
msgstr ""
+"Креира Ñударни облик на бази моногоугла.\n"
+"Ово је најпрецизнија(али и најÑпорија) опција за препознавање Ñудара."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
@@ -6274,10 +6551,13 @@ msgid "Create Single Convex Collision Sibling"
msgstr "Ðаправи конвекÑног Ñударног брата"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid ""
"Creates a single convex collision shape.\n"
"This is the fastest (but least accurate) option for collision detection."
msgstr ""
+"Креира један конвекÑни Ñударни облик.\n"
+"Ово је најбржа(али и најнепрецизнија) опција за препознавање Ñудара."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
@@ -6285,36 +6565,45 @@ msgid "Create Multiple Convex Collision Siblings"
msgstr "Ðаправи конвекÑног Ñударног брата"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid ""
"Creates a polygon-based collision shape.\n"
"This is a performance middle-ground between the two above options."
msgstr ""
+"Креира Ñударни облик на бази многоугла.\n"
+"Ова опција поÑтиже Ñредињи учинак између 2 горе наведене."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Outline Mesh..."
msgstr "Ðаправи ивичну мрежу..."
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid ""
"Creates a static outline mesh. The outline mesh will have its normals "
"flipped automatically.\n"
"This can be used instead of the SpatialMaterial Grow property when using "
"that property isn't possible."
msgstr ""
+"Креира непомични оквир мреже. Оквир мреже ће имати обрнуте нормале "
+"аутоматÑки.\n"
+"Ово може бити коришћено умеÑто РаÑÑ‚ оÑобине РаÑтућегМатеријала кад коришћење "
+"те оÑобине није могуће."
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "View UV1"
-msgstr "Поглед"
+msgstr "Види UV1"
#: editor/plugins/mesh_instance_editor_plugin.cpp
#, fuzzy
msgid "View UV2"
-msgstr "Поглед"
+msgstr "Види UV2"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "Unwrap UV2 for Lightmap/AO"
-msgstr ""
+msgstr "Одмотај UV2 за МапуСенки/Упијање Окружења"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Outline Mesh"
@@ -6325,8 +6614,9 @@ msgid "Outline Size:"
msgstr "Величина ивице:"
#: editor/plugins/mesh_instance_editor_plugin.cpp
+#, fuzzy
msgid "UV Channel Debug"
-msgstr ""
+msgstr "UV Канал ПИП (Проналажење и ИÑправка Проблема)"
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Remove item %d?"
@@ -6337,12 +6627,14 @@ msgstr "Обриши Ñтвар %d?"
msgid ""
"Update from existing scene?:\n"
"%s"
-msgstr "Ðжурирај из Ñцене"
+msgstr ""
+"Ðжурирај из Ñцене? :\n"
+"%s"
#: editor/plugins/mesh_library_editor_plugin.cpp
#, fuzzy
msgid "Mesh Library"
-msgstr "MeshLibrary..."
+msgstr "Библиотека Мрежа..."
#: editor/plugins/mesh_library_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
@@ -6462,12 +6754,12 @@ msgstr "Ðаправи навигациони полигон"
#: editor/plugins/particles_editor_plugin.cpp
#, fuzzy
msgid "Convert to CPUParticles"
-msgstr "Претвори у велика Ñлова"
+msgstr "Претвори у CPU чеÑтице"
#: editor/plugins/particles_2d_editor_plugin.cpp
#, fuzzy
msgid "Generating Visibility Rect"
-msgstr "Генериши правоугаоник видљивоÑти"
+msgstr "Генерација Правоугаоника ВидљивоÑти"
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Generate Visibility Rect"
@@ -6483,17 +6775,19 @@ msgid "Generation Time (sec):"
msgstr "Време генериÑања (Ñек.):"
#: editor/plugins/particles_editor_plugin.cpp
+#, fuzzy
msgid "The geometry's faces don't contain any area."
-msgstr ""
+msgstr "Лица геометрије не Ñадржи ни једну облаÑÑ‚."
#: editor/plugins/particles_editor_plugin.cpp
#, fuzzy
msgid "The geometry doesn't contain any faces."
-msgstr "Чвор не Ñадржи геометрију (Ñтране)."
+msgstr "Геометрија не Ñадржи ни једно лице."
#: editor/plugins/particles_editor_plugin.cpp
+#, fuzzy
msgid "\"%s\" doesn't inherit from Spatial."
-msgstr ""
+msgstr "\"%s\" не наÑлеђује од ПроÑторног."
#: editor/plugins/particles_editor_plugin.cpp
#, fuzzy
@@ -6565,7 +6859,7 @@ msgstr "Уметни тачку у криву"
#: editor/plugins/path_2d_editor_plugin.cpp
#, fuzzy
msgid "Split Curve"
-msgstr "Затвори криву"
+msgstr "Подели Криву"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Move Point in Curve"
@@ -6631,13 +6925,15 @@ msgstr "Опција"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
+#, fuzzy
msgid "Mirror Handle Angles"
-msgstr ""
+msgstr "Углови Дршке Огледала"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
+#, fuzzy
msgid "Mirror Handle Lengths"
-msgstr ""
+msgstr "Дужине Дршке Огледала"
#: editor/plugins/path_editor_plugin.cpp
msgid "Curve Point #"
@@ -6681,30 +6977,36 @@ msgid "Move Joint"
msgstr "Помери тачку"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid ""
"The skeleton property of the Polygon2D does not point to a Skeleton2D node"
-msgstr ""
+msgstr "КоÑтур оÑобина 2Д полигона не упире ка 2Д КоÑтур чвору"
#: editor/plugins/polygon_2d_editor_plugin.cpp
#, fuzzy
msgid "Sync Bones"
-msgstr "Покажи коÑти"
+msgstr "УÑклади КоÑке"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid ""
"No texture in this polygon.\n"
"Set a texture to be able to edit UV."
msgstr ""
+"Ðема текÑтуре у овом многоуглу.\n"
+"ПоÑтави текÑтуру да би едитовао UV."
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Create UV Map"
msgstr "Ðаправи UV мапу"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid ""
"Polygon 2D has internal vertices, so it can no longer be edited in the "
"viewport."
msgstr ""
+"2Д многоугао има унутрашње тачке, па не може више бити едитован у viewport-у."
#: editor/plugins/polygon_2d_editor_plugin.cpp
#, fuzzy
@@ -6722,8 +7024,9 @@ msgid "Remove Internal Vertex"
msgstr "Обриши тачку контроле улаза"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "Invalid Polygon (need 3 different vertices)"
-msgstr ""
+msgstr "Ðеважећи Многоугао(потребне 3 различите тачке)"
#: editor/plugins/polygon_2d_editor_plugin.cpp
#, fuzzy
@@ -6745,8 +7048,9 @@ msgid "Transform Polygon"
msgstr "Тип транÑформације"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "Paint Bone Weights"
-msgstr ""
+msgstr "Боји Тежине КоÑтура"
#: editor/plugins/polygon_2d_editor_plugin.cpp
#, fuzzy
@@ -6758,8 +7062,9 @@ msgid "Polygon 2D UV Editor"
msgstr "Уредник UV 2Д полигона"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "UV"
-msgstr ""
+msgstr "UV"
#: editor/plugins/polygon_2d_editor_plugin.cpp
#, fuzzy
@@ -6806,26 +7111,34 @@ msgid "Scale Polygon"
msgstr "Скалирај полигон"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "Create a custom polygon. Enables custom polygon rendering."
msgstr ""
+"Креирај произвољни многоугао. Омогућује изцртавање произвољног многоугла."
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid ""
"Remove a custom polygon. If none remain, custom polygon rendering is "
"disabled."
msgstr ""
+"Уклони произвољни многоугао. Ðко ни један није оÑтао, изцртавање произв. "
+"многоугла је онемогућено."
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "Paint weights with specified intensity."
-msgstr ""
+msgstr "Боји тежине Ñа наведеном Ñнагом"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "Unpaint weights with specified intensity."
-msgstr ""
+msgstr "Обриши обојене тежине наведене Ñнаге"
#: editor/plugins/polygon_2d_editor_plugin.cpp
+#, fuzzy
msgid "Radius:"
-msgstr ""
+msgstr " ОпÑег:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Polygon->UV"
@@ -6917,8 +7230,9 @@ msgstr "Ðалепи реÑурÑе"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Instance:"
-msgstr ""
+msgstr "ИнÑтанца:"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp editor/project_settings_editor.cpp
@@ -6929,8 +7243,9 @@ msgstr "Тип:"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/scene_tree_dock.cpp editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Open in Editor"
-msgstr ""
+msgstr "Отвори у Уреднику"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "Load Resource"
@@ -6942,13 +7257,14 @@ msgid "ResourcePreloader"
msgstr "РеÑурÑ"
#: editor/plugins/root_motion_editor_plugin.cpp
+#, fuzzy
msgid "AnimationTree has no path set to an AnimationPlayer"
-msgstr ""
+msgstr "AnimationTree нема путању поÑтављену ка AnimationPlayer-у"
#: editor/plugins/root_motion_editor_plugin.cpp
#, fuzzy
msgid "Path to AnimationPlayer is invalid"
-msgstr "Ðнимационо дрво није важеће."
+msgstr "Путања до AnimationPlayer није важећа."
#: editor/plugins/script_editor_plugin.cpp
msgid "Clear Recent Files"
@@ -7012,21 +7328,27 @@ msgid "Save File As..."
msgstr "Сачувај као..."
#: editor/plugins/script_editor_plugin.cpp
+#, fuzzy
msgid "Can't obtain the script for running."
-msgstr ""
+msgstr "ÐеуÑпело добијање Ñкрипте за покретање"
#: editor/plugins/script_editor_plugin.cpp
+#, fuzzy
msgid "Script failed reloading, check console for errors."
-msgstr ""
+msgstr "ÐеуÑпело учитавање Скрипте, провери конзолу за могуће грешке."
#: editor/plugins/script_editor_plugin.cpp
+#, fuzzy
msgid "Script is not in tool mode, will not be able to run."
-msgstr ""
+msgstr "Скрипта није у Ðлат Режиму, неће бити покренута."
#: editor/plugins/script_editor_plugin.cpp
+#, fuzzy
msgid ""
"To run this script, it must inherit EditorScript and be set to tool mode."
msgstr ""
+"За покретање Ñкрипте, мора наÑледити УредникСкрипту и бити поÑтављена у Ðлат "
+"Режим."
#: editor/plugins/script_editor_plugin.cpp
msgid "Import Theme"
@@ -7062,16 +7384,17 @@ msgstr "Ðађи претходни"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Filter scripts"
-msgstr "ПоÑтавке објекта."
+msgstr "Филтрирај Ñкрипте"
#: editor/plugins/script_editor_plugin.cpp
+#, fuzzy
msgid "Toggle alphabetical sorting of the method list."
-msgstr ""
+msgstr "Укљ/ИÑкљ алфабет Ñортирање ÑпиÑка метода."
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Filter methods"
-msgstr "ПоÑтавке објекта."
+msgstr "Филтрирај методе"
#: editor/plugins/script_editor_plugin.cpp
msgid "Sort"
@@ -7104,12 +7427,12 @@ msgstr "Датотека"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Open..."
-msgstr "Отвори"
+msgstr "Отвори..."
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Reopen Closed Script"
-msgstr "Покрени Ñкриптицу"
+msgstr "Покрени Затворену Скрипту"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save All"
@@ -7122,7 +7445,7 @@ msgstr "Мекано оÑвежење Ñкриптице"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Copy Script Path"
-msgstr "Копирај пут"
+msgstr "Копирај Путању Скрипте"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
@@ -7137,12 +7460,12 @@ msgstr "ИÑторија Ñледеће"
#: editor/plugins/theme_editor_plugin.cpp
#, fuzzy
msgid "Theme"
-msgstr "Сачувај тему"
+msgstr "Тема"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Import Theme..."
-msgstr "Увези тему"
+msgstr "Увези тему..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Reload Theme"
@@ -7193,7 +7516,7 @@ msgstr "Дебагуј Ñа Ñпољашњим уредником"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Open Godot online documentation."
-msgstr "Отвори Godot онлајн документацију"
+msgstr "Отвори Godot документацију Ñа мреже"
#: editor/plugins/script_editor_plugin.cpp
msgid "Search the reference documentation."
@@ -7236,28 +7559,27 @@ msgstr "Дебагер"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Search Results"
-msgstr "Потражи помоћ"
+msgstr "Потражи Ретултате"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
msgid "Clear Recent Scripts"
-msgstr "ОчиÑти недавне Ñцене"
+msgstr "ОчиÑти Ðедавне Скрипте"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Connections to method:"
-msgstr "Повежи Ñа чвором:"
+msgstr "Везе Ñа методом:"
#: editor/plugins/script_text_editor.cpp editor/script_editor_debugger.cpp
#, fuzzy
msgid "Source"
-msgstr ""
-"\n"
-"Извор: "
+msgstr "Извор"
#: editor/plugins/script_text_editor.cpp
+#, fuzzy
msgid "Target"
-msgstr ""
+msgstr "Мета"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
@@ -7267,12 +7589,13 @@ msgstr "Повежи '%s' Ñа '%s'"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
-msgid "Line"
-msgstr "Линија:"
+msgid "[Ignore]"
+msgstr "(игнориши)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
+#, fuzzy
+msgid "Line"
+msgstr "Линија:"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
@@ -7285,8 +7608,9 @@ msgstr "Само реÑурÑи из датотечног ÑиÑтема Ñе м
#: editor/plugins/script_text_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Can't drop nodes because script '%s' is not used in this scene."
-msgstr ""
+msgstr "ÐеуÑпешно иÑпуштање чворова јер Ñкрипта'%s' није део ове Ñцене."
#: editor/plugins/script_text_editor.cpp
#, fuzzy
@@ -7314,23 +7638,26 @@ msgid "Capitalize"
msgstr "Велика Ñлова"
#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
+#, fuzzy
msgid "Syntax Highlighter"
-msgstr ""
+msgstr "Изтицање СинтакÑе"
#: editor/plugins/script_text_editor.cpp
#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
+#, fuzzy
msgid "Go To"
-msgstr ""
+msgstr "Иди Ðа"
#: editor/plugins/script_text_editor.cpp
#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
+#, fuzzy
msgid "Bookmarks"
-msgstr ""
+msgstr "Белешке"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Breakpoints"
-msgstr "Обриши тачке"
+msgstr "Тачке прекида"
#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
@@ -7361,7 +7688,7 @@ msgstr "Коментариши"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Fold/Unfold Line"
-msgstr "Откриј линију"
+msgstr "Сакриј/Отркиј Линију"
#: editor/plugins/script_text_editor.cpp
msgid "Fold All Lines"
@@ -7382,7 +7709,7 @@ msgstr "Потпун Ñимбол"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Evaluate Selection"
-msgstr "Увећај одабрано"
+msgstr "Процени Одабрано"
#: editor/plugins/script_text_editor.cpp
msgid "Trim Trailing Whitespace"
@@ -7466,7 +7793,7 @@ msgid ""
"This shader has been modified on on disk.\n"
"What action should be taken?"
msgstr ""
-"Следеће датотеке Ñу нове на диÑку.\n"
+"Овај Цртач је измењен на диÑку.\n"
"Која акција Ñе треба предузети?:"
#: editor/plugins/shader_editor_plugin.cpp
@@ -7474,8 +7801,9 @@ msgid "Shader"
msgstr "Шејдер"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
+#, fuzzy
msgid "This skeleton has no bones, create some children Bone2D nodes."
-msgstr ""
+msgstr "Овај коÑтур нема коÑти, креирај му децу КоÑка2Д чворове."
#: editor/plugins/skeleton_2d_editor_plugin.cpp
#, fuzzy
@@ -7483,21 +7811,24 @@ msgid "Create Rest Pose from Bones"
msgstr "Ðаправи тачке емиÑије од мреже"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
+#, fuzzy
msgid "Set Rest Pose to Bones"
-msgstr ""
+msgstr "ПоÑтави Одмор Позу на КоÑке"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
#, fuzzy
msgid "Skeleton2D"
-msgstr "Синглетон"
+msgstr "Синглетон2Д"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
+#, fuzzy
msgid "Make Rest Pose (From Bones)"
-msgstr ""
+msgstr "Ðаправи Одмор Позу(од КоÑтију)"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
+#, fuzzy
msgid "Set Bones to Rest Pose"
-msgstr ""
+msgstr "ПоÑтави КоÑке у Одмор Позу"
#: editor/plugins/skeleton_editor_plugin.cpp
#, fuzzy
@@ -7568,12 +7899,14 @@ msgid "Animation Key Inserted."
msgstr "Ðнимациони кључ убачен."
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid "Pitch"
-msgstr ""
+msgstr "Лево-ДеÑно"
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid "Yaw"
-msgstr ""
+msgstr "Горе-Доле"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Objects Drawn"
@@ -7722,8 +8055,9 @@ msgid "Cinematic Preview"
msgstr "Ðаправи приказ мрежа"
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid "Not available when using the GLES2 renderer."
-msgstr ""
+msgstr "ÐедоÑтупно кад кориÑтиш GLES2 изцртавање."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Freelook Left"
@@ -7764,23 +8098,36 @@ msgid "View Rotation Locked"
msgstr "Прикажи информације"
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid ""
"Note: The FPS value displayed is the editor's framerate.\n"
"It cannot be used as a reliable indication of in-game performance."
msgstr ""
+"Белешка: FPS вредноÑÑ‚ приказана је FPS вредноÑÑ‚ Уредника.\n"
+"Ðе може бити коришћена као поуздана оцена учинка у игри."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "XForm Dialog"
msgstr "XForm дијалог"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "Залепи за мрежу"
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid "Couldn't find a solid floor to snap the selection to."
-msgstr ""
+msgstr "Ðије пронађен чврÑÑ‚ под где ће Ñе одабир прилепити"
#: editor/plugins/spatial_editor_plugin.cpp
msgid ""
@@ -7854,7 +8201,7 @@ msgstr "ТранÑформација"
#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Object to Floor"
-msgstr "Залепи за мрежу"
+msgstr "Залепи Објекат за Под"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Transform Dialog..."
@@ -7936,8 +8283,9 @@ msgid "View Z-Far:"
msgstr "МакÑимум Z за приказ:"
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid "Transform Change"
-msgstr ""
+msgstr "Промена ТранÑформације"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Translate:"
@@ -7964,8 +8312,9 @@ msgid "Post"
msgstr "ПоÑле"
#: editor/plugins/spatial_editor_plugin.cpp
+#, fuzzy
msgid "Nameless gizmo"
-msgstr ""
+msgstr "Безимена ручка"
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -7983,8 +8332,9 @@ msgid "Create Polygon2D"
msgstr "Ðаправи полигон"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Polygon2D Preview"
-msgstr ""
+msgstr "Приказ Polygon2D"
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -8012,12 +8362,14 @@ msgid "Sprite is empty!"
msgstr "Мрежа је празна!"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Can't convert a sprite using animation frames to mesh."
-msgstr ""
+msgstr "ÐеуÑпело претварање Ñпрајта кориÑтећи анимационе оквире у мрежу."
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Invalid geometry, can't replace by mesh."
-msgstr ""
+msgstr "Ðеважећа геометрија, неуÑпеша замена Ñа мрежом."
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -8025,8 +8377,9 @@ msgid "Convert to Mesh2D"
msgstr "Претвори у велика Ñлова"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Invalid geometry, can't create polygon."
-msgstr ""
+msgstr "Ðеважећа геометрија, неуÑпешно креирање многоугла."
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -8034,8 +8387,9 @@ msgid "Convert to Polygon2D"
msgstr "Помери полигон"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Invalid geometry, can't create collision polygon."
-msgstr ""
+msgstr "Ðеважећа геометрија, неуÑпело креирање Ñударног многоугла."
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -8043,8 +8397,9 @@ msgid "Create CollisionPolygon2D Sibling"
msgstr "Ðаправи навигациони полигон"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Invalid geometry, can't create light occluder."
-msgstr ""
+msgstr "Ðеважећа геометрија, неуÑпело креирање затамљивача Ñветла."
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -8057,16 +8412,19 @@ msgid "Sprite"
msgstr "Ðалепи оквир"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Simplification: "
-msgstr ""
+msgstr "ПоједноÑтављено:"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Shrink (Pixels): "
-msgstr ""
+msgstr "Умањи (ПикÑели):"
#: editor/plugins/sprite_editor_plugin.cpp
+#, fuzzy
msgid "Grow (Pixels): "
-msgstr ""
+msgstr "Увећај (ПикÑели):"
#: editor/plugins/sprite_editor_plugin.cpp
#, fuzzy
@@ -8156,8 +8514,9 @@ msgid "Add a Texture from File"
msgstr "Сними од пикÑела"
#: editor/plugins/sprite_frames_editor_plugin.cpp
+#, fuzzy
msgid "Add Frames from a Sprite Sheet"
-msgstr ""
+msgstr "Додај Рамове Ñа Спрајт ЛиÑте"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Insert Empty (Before)"
@@ -8181,13 +8540,14 @@ msgid "Select Frames"
msgstr "Одабери режим"
#: editor/plugins/sprite_frames_editor_plugin.cpp
+#, fuzzy
msgid "Horizontal:"
-msgstr ""
+msgstr "Хоризонтално:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
#, fuzzy
msgid "Vertical:"
-msgstr "Тачке"
+msgstr "Вертикално:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
#, fuzzy
@@ -8244,8 +8604,9 @@ msgid "Step:"
msgstr "Корак:"
#: editor/plugins/texture_region_editor_plugin.cpp
+#, fuzzy
msgid "Sep.:"
-msgstr ""
+msgstr "Сеп.:"
#: editor/plugins/texture_region_editor_plugin.cpp
#, fuzzy
@@ -8317,12 +8678,14 @@ msgid "Disabled Item"
msgstr "Онемогућено"
#: editor/plugins/theme_editor_plugin.cpp
+#, fuzzy
msgid "Check Item"
-msgstr ""
+msgstr "Провери Предмет"
#: editor/plugins/theme_editor_plugin.cpp
+#, fuzzy
msgid "Checked Item"
-msgstr ""
+msgstr "Предмет проверен"
#: editor/plugins/theme_editor_plugin.cpp
#, fuzzy
@@ -8335,12 +8698,14 @@ msgid "Checked Radio Item"
msgstr "CheckBox Radio1"
#: editor/plugins/theme_editor_plugin.cpp
+#, fuzzy
msgid "Named Sep."
-msgstr ""
+msgstr "Иманован Сеп."
#: editor/plugins/theme_editor_plugin.cpp
+#, fuzzy
msgid "Submenu"
-msgstr ""
+msgstr "Под-мени"
#: editor/plugins/theme_editor_plugin.cpp
#, fuzzy
@@ -8385,8 +8750,9 @@ msgid "Editable Item"
msgstr "Измени тему..."
#: editor/plugins/theme_editor_plugin.cpp
+#, fuzzy
msgid "Subtree"
-msgstr ""
+msgstr "Под-Ñтабло"
#: editor/plugins/theme_editor_plugin.cpp
#, fuzzy
@@ -8461,8 +8827,9 @@ msgid "Find Tile"
msgstr "Ðађи плочицу"
#: editor/plugins/tile_map_editor_plugin.cpp
+#, fuzzy
msgid "Transpose"
-msgstr ""
+msgstr "Преокрени"
#: editor/plugins/tile_map_editor_plugin.cpp
#, fuzzy
@@ -8480,18 +8847,22 @@ msgid "Filter tiles"
msgstr "Филтрирај датотеке..."
#: editor/plugins/tile_map_editor_plugin.cpp
+#, fuzzy
msgid "Give a TileSet resource to this TileMap to use its tiles."
-msgstr ""
+msgstr "Дај КомплетПлочица реÑÑƒÑ€Ñ Ð¾Ð²Ð¾Ð¼ КомплетуМапа да кориÑте његове плочице."
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Paint Tile"
msgstr "Цртај полчице"
#: editor/plugins/tile_map_editor_plugin.cpp
+#, fuzzy
msgid ""
"Shift+LMB: Line Draw\n"
"Shift+Ctrl+LMB: Rectangle Paint"
msgstr ""
+"Shift+LMB: Цртање Линије\n"
+"Shift+Ctrl+LMB: Бојење Четвороугла"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Pick Tile"
@@ -8508,21 +8879,24 @@ msgid "Rotate Right"
msgstr "Ротирај полигон"
#: editor/plugins/tile_map_editor_plugin.cpp
+#, fuzzy
msgid "Flip Horizontally"
-msgstr ""
+msgstr "Обрни Хоризонтално"
#: editor/plugins/tile_map_editor_plugin.cpp
+#, fuzzy
msgid "Flip Vertically"
-msgstr ""
+msgstr "Обрни Вертикално"
#: editor/plugins/tile_map_editor_plugin.cpp
#, fuzzy
msgid "Clear Transform"
-msgstr "ТранÑформација"
+msgstr "ОчиÑти ТранÑформацију"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Add Texture(s) to TileSet."
-msgstr ""
+msgstr "Додај ТекÑтуру(е) КомплетуПлочица."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8539,8 +8913,9 @@ msgid "Merge from Scene"
msgstr "Споји од Ñцене"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "New Single Tile"
-msgstr ""
+msgstr "Ðова Једна Плочица"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8548,8 +8923,9 @@ msgid "New Autotile"
msgstr "ÐутоматÑки рез"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "New Atlas"
-msgstr ""
+msgstr "Ðов ÐтлаÑ"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8557,8 +8933,9 @@ msgid "Next Coordinate"
msgstr "Следећа Ñкриптица"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Select the next shape, subtile, or Tile."
-msgstr ""
+msgstr "Одабери Ñледећи облик, под-плочицу, или плочицу."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8566,8 +8943,9 @@ msgid "Previous Coordinate"
msgstr "Претодни Ñпрат"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Select the previous shape, subtile, or Tile."
-msgstr ""
+msgstr "Одабери претходни облик, под-плочицу, или плочицу."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8645,8 +9023,9 @@ msgid "Z Index Mode"
msgstr "Режим инÑпекције"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Copy bitmask."
-msgstr ""
+msgstr "Копирај БитМаÑку."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8669,21 +9048,26 @@ msgid "Create a new polygon."
msgstr "Ðаправи нови полигон од почетка."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Keep polygon inside region Rect."
-msgstr ""
+msgstr "Задржи многоугао унутар региона Четвороугла."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Enable snap and show grid (configurable via the Inspector)."
-msgstr ""
+msgstr "Омогући лепљење и прикажи мрежу ( подеÑива преко инÑпектора)."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Display Tile Names (Hold Alt Key)"
-msgstr ""
+msgstr "Прикажи Имена Плочица (Држи Alt дугмић)"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid ""
"Add or select a texture on the left panel to edit the tiles bound to it."
msgstr ""
+"Додај или одабери текÑтуру на левом панелу да измениш њену везану плочицу."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8691,12 +9075,14 @@ msgid "Remove selected texture? This will remove all tiles which use it."
msgstr "Обриши тачку криве"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "You haven't selected a texture to remove."
-msgstr ""
+msgstr "ТекÑтура за уклањање није одабрана."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Create from scene? This will overwrite all current tiles."
-msgstr ""
+msgstr "Креирај од Ñцене? Ово ће препиÑати Ñве тренутне плочице."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8709,14 +9095,18 @@ msgid "Remove Texture"
msgstr "Обриши шаблон"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "%s file(s) were not added because was already on the list."
-msgstr ""
+msgstr "%s фајл(ови) ниÑу додани јер Ñу већ на лиÑти."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid ""
"Drag handles to edit Rect.\n"
"Click on another Tile to edit it."
msgstr ""
+"Вуци ручице да изениш Правоугаоник.\n"
+"Кликни на другу плочицу да је измениш."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8745,17 +9135,24 @@ msgid ""
msgstr "Сачувај тренутно измењени реÑурÑ."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid ""
"Select sub-tile to use as icon, this will be also used on invalid autotile "
"bindings.\n"
"Click on another Tile to edit it."
msgstr ""
+"Одабери под-плочицу као иконицу, ово ће такође бити изкоришћено на неважећим "
+"Ñпојевима ауто-плочицица.\n"
+"Кликни на другу плочицу да је измениш."
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid ""
"Select sub-tile to change its priority.\n"
"Click on another Tile to edit it."
msgstr ""
+"Одабери под-плочицу да измениш њен приоритет.\n"
+"Кликни на другу плочицу да је измениш."
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8775,8 +9172,9 @@ msgid "Create Tile"
msgstr "Ðаправи директоријум"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Set Tile Icon"
-msgstr ""
+msgstr "ПоÑтави иконицу Плочице"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8804,8 +9202,9 @@ msgid "Paste Tile Bitmask"
msgstr "Ðалепи анимацију"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Clear Tile Bitmask"
-msgstr ""
+msgstr "ОчиÑти БитМаÑке Ñа Плочице"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8843,8 +9242,9 @@ msgid "Edit Tile Priority"
msgstr "Уреди филтере"
#: editor/plugins/tile_set_editor_plugin.cpp
+#, fuzzy
msgid "Edit Tile Z Index"
-msgstr ""
+msgstr "Измени Z Ð¸Ð½Ð´ÐµÐºÑ ÐŸÐ»Ð¾Ñ‡Ð¸Ñ†Ðµ"
#: editor/plugins/tile_set_editor_plugin.cpp
#, fuzzy
@@ -8877,8 +9277,9 @@ msgid "TileSet"
msgstr "TileSet..."
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "No VCS addons are available."
-msgstr ""
+msgstr " VCS додатци ниÑу доÑтупни."
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Error"
@@ -8890,8 +9291,9 @@ msgid "No commit message was provided"
msgstr "Име није дато"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "No files added to stage"
-msgstr ""
+msgstr "Ðи један фајл није додат на позорницу"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8899,12 +9301,14 @@ msgid "Commit"
msgstr "Заједница"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "VCS Addon is not initialized"
-msgstr ""
+msgstr "VCS додатак није иницијализован"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Version Control System"
-msgstr ""
+msgstr "VCS(СиÑтем Контроле Верзије)"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8912,8 +9316,9 @@ msgid "Initialize"
msgstr "Велика Ñлова"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Staging area"
-msgstr ""
+msgstr "СценÑки проÑтор"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8926,8 +9331,9 @@ msgid "Changes"
msgstr "Промене шејдера"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Modified"
-msgstr ""
+msgstr "Измењено"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8940,8 +9346,9 @@ msgid "Deleted"
msgstr "Обриши"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Typechange"
-msgstr ""
+msgstr "Промена типа"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8954,8 +9361,9 @@ msgid "Stage All"
msgstr "Сачувај Ñве"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Add a commit message"
-msgstr ""
+msgstr "Додај предајну поруку"
#: editor/plugins/version_control_editor_plugin.cpp
#, fuzzy
@@ -8964,24 +9372,29 @@ msgstr "Синхронизуј промене Ñкриптица"
#: editor/plugins/version_control_editor_plugin.cpp
#: modules/gdnative/gdnative_library_singleton_editor.cpp
+#, fuzzy
msgid "Status"
-msgstr ""
+msgstr "СтатуÑ"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "View file diffs before committing them to the latest version"
-msgstr ""
+msgstr "Погледај фајл разлике пре него га предаш задњој верзији."
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "No file diff is active"
-msgstr ""
+msgstr "Ðи једна фајл разлика није активна"
#: editor/plugins/version_control_editor_plugin.cpp
+#, fuzzy
msgid "Detect changes in file diff"
-msgstr ""
+msgstr "Пронађене промене у фајл разликама"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "(GLES3 only)"
-msgstr ""
+msgstr "(Ñамо GLES3)"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -8999,12 +9412,14 @@ msgid "Vector"
msgstr "ИнÑпектор"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Boolean"
-msgstr ""
+msgstr "Тачница"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Sampler"
-msgstr ""
+msgstr "Узрокотвор"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9012,8 +9427,9 @@ msgid "Add input port"
msgstr "Додај улаз"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Add output port"
-msgstr ""
+msgstr "Додај одлазни порт"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9056,8 +9472,9 @@ msgid "Resize VisualShader node"
msgstr "Шејдер"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Set Uniform Name"
-msgstr ""
+msgstr "ПоÑтави ЈединÑтвено Име"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9076,17 +9493,19 @@ msgstr "Дуплирај чвор/ове графа"
#: editor/plugins/visual_shader_editor_plugin.cpp
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Paste Nodes"
-msgstr ""
+msgstr "Ðалепи Чворове"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Delete Nodes"
-msgstr "Ðаправи чвор"
+msgstr "Обриши Чворове"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Visual Shader Input Type Changed"
-msgstr ""
+msgstr "Улазна Ð’Ñ€Ñта Визуелног Цртача промењена"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9094,8 +9513,9 @@ msgid "Vertex"
msgstr "Тачке"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Fragment"
-msgstr ""
+msgstr "Део"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9118,8 +9538,9 @@ msgid "Color function."
msgstr "Иди на функцију..."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Color operator."
-msgstr ""
+msgstr "Операције боје."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9127,359 +9548,441 @@ msgid "Grayscale function."
msgstr "Ðаправи функцију"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Converts HSV vector to RGB equivalent."
-msgstr ""
+msgstr "Претвара HSV вектор у RGB."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Converts RGB vector to HSV equivalent."
-msgstr ""
+msgstr "Претвара RGB вектор у HSV."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Sepia function."
-msgstr "Ðаправи функцију"
+msgstr "Sepia функција."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Burn operator."
-msgstr ""
+msgstr "Ðагорено оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Darken operator."
-msgstr ""
+msgstr "Затамњење оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Difference operator."
-msgstr "Само разлике"
+msgstr "РазличитоÑти оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Dodge operator."
-msgstr ""
+msgstr "Упијање оперетор."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "HardLight operator."
-msgstr "Промени Ñкаларни оператор"
+msgstr "ЈакаСветла оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Lighten operator."
-msgstr ""
+msgstr "ПоÑветли оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Overlay operator."
-msgstr ""
+msgstr "Прекриј оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Screen operator."
-msgstr ""
+msgstr "ЗаÑлон оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "SoftLight operator."
-msgstr ""
+msgstr "МекоСветло оператор."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Color constant."
-msgstr "КонÑтантан"
+msgstr "Боја конÑтантна."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Color uniform."
-msgstr "ТранÑформација"
+msgstr "Боја хомогена."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the boolean result of the %s comparison between two parameters."
-msgstr ""
+msgstr "Враћа Булов резултат од %s порећења између 2 параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Equal (==)"
-msgstr ""
+msgstr "Једнако (==)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Greater Than (>)"
-msgstr ""
+msgstr "Веће од (>)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Greater Than or Equal (>=)"
-msgstr ""
+msgstr "Веће или Једнако (>=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns an associated vector if the provided scalars are equal, greater or "
"less."
msgstr ""
+"Враћа аÑоцијативни вектор ако Ñу Ñнабдевени Ñкалари једнаки, већи или мањи."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns the boolean result of the comparison between INF and a scalar "
"parameter."
-msgstr ""
+msgstr "Враћа Булов резултат након поређења измђу INF и Ñкаларног параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns the boolean result of the comparison between NaN and a scalar "
"parameter."
-msgstr ""
+msgstr "Враћа Булов резултат након поређења NaN и Ñкаларног параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Less Than (<)"
-msgstr ""
+msgstr "Мање од (<)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Less Than or Equal (<=)"
-msgstr ""
+msgstr "Мање или Једнако (<=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Not Equal (!=)"
-msgstr ""
+msgstr "Ðеједнако (!=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns an associated vector if the provided boolean value is true or false."
msgstr ""
+"Враћа аÑоцијативни вектор ако је Ñнабдевена Булова вредноÑÑ‚ тачна или "
+"нетачна."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns an associated scalar if the provided boolean value is true or false."
msgstr ""
+"Враћа аÑоцијативни Ñкалар ако је Ñнабдевена Булова вредноÑÑ‚ тачна или "
+"нетачна."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the boolean result of the comparison between two parameters."
-msgstr ""
+msgstr "Враћа Булов резултат након поређења 2 параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns the boolean result of the comparison between INF (or NaN) and a "
"scalar parameter."
msgstr ""
+"Враћа Булов резултат након поређења између INF (или NaN) и Ñкаларног "
+"параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Boolean constant."
-msgstr "Промени векторÑку конÑтанту"
+msgstr "Бул конÑтантан."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Boolean uniform."
-msgstr ""
+msgstr "Бул уједначен."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for all shader modes."
-msgstr ""
+msgstr "'%s' улазни параметар за Ñве Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Input parameter."
-msgstr "Лепи за родитеља"
+msgstr "Улазни параметар"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for vertex and fragment shader modes."
-msgstr ""
+msgstr "'%s' улазни параметар за тачкаÑте и раздељене Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for fragment and light shader modes."
-msgstr ""
+msgstr "'%s' улазни параметар за раздељене и Ñветле Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for fragment shader mode."
-msgstr ""
+msgstr "'%s' улазни параметар за раздељене Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for light shader mode."
-msgstr ""
+msgstr "'%s' улазни параметар за Ñветле Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for vertex shader mode."
-msgstr ""
+msgstr "'%s' улазни параметар за тачкаÑте Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "'%s' input parameter for vertex and fragment shader mode."
-msgstr ""
+msgstr "'%s' улазни параметар за тачкаÑте и раздељене Цртачке Режиме."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Scalar function."
-msgstr "Промени Ñкаларну функцију"
+msgstr "Скаларна функција."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Scalar operator."
-msgstr "Промени Ñкаларни оператор"
+msgstr "Скаларни опреатор."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "E constant (2.718282). Represents the base of the natural logarithm."
-msgstr ""
+msgstr "E конÑтанта (2.718282). ПредÑтавља базу природног логаритма."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Epsilon constant (0.00001). Smallest possible scalar number."
-msgstr ""
+msgstr "ЕпÑилон конÑтанта (0.00001). Ðајмањи могући Ñкаларни број."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Phi constant (1.618034). Golden ratio."
-msgstr ""
+msgstr " Phi конÑтанта (1.618034). Златни преÑек."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Pi/4 constant (0.785398) or 45 degrees."
-msgstr ""
+msgstr "Pi/4 конÑтанта (0.785398) или 45 Ñтепени."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Pi/2 constant (1.570796) or 90 degrees."
-msgstr ""
+msgstr "Pi/2 конÑтанта (1.570796) или 90 Ñтепени."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Pi constant (3.141593) or 180 degrees."
-msgstr ""
+msgstr "Pi конÑтанта (3.141593) или 180 Ñтепени."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Tau constant (6.283185) or 360 degrees."
-msgstr ""
+msgstr "Tau конÑтанта (6.283185) или 360 Ñтепни."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Sqrt2 constant (1.414214). Square root of 2."
-msgstr ""
+msgstr "Sqrt2 конÑтанта (1.414214). Корен од 2."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the absolute value of the parameter."
-msgstr ""
+msgstr "Враћа абÑолутну вредноÑÑ‚ параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the arc-cosine of the parameter."
-msgstr ""
+msgstr "Враћа арк-коÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the inverse hyperbolic cosine of the parameter."
-msgstr ""
+msgstr "Враћа обрнут хиперболични коÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the arc-sine of the parameter."
-msgstr ""
+msgstr "Враћа арк-ÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the inverse hyperbolic sine of the parameter."
-msgstr ""
+msgstr "Враћа обрнут хиперболични ÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the arc-tangent of the parameter."
-msgstr ""
+msgstr "Враћа арк-тангенту параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the arc-tangent of the parameters."
-msgstr ""
+msgstr "Враћа арк-тангенту параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the inverse hyperbolic tangent of the parameter."
-msgstr ""
+msgstr "Враћа обрнуту хиперболичну тангенту параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Finds the nearest integer that is greater than or equal to the parameter."
-msgstr ""
+msgstr "Ðалази најближи интиџер који је већи или једнак параметру."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Constrains a value to lie between two further values."
-msgstr ""
+msgstr "Ограђује вредноÑÑ‚ између 2 наредне вредноÑти."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the cosine of the parameter."
-msgstr ""
+msgstr "Враћа коÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the hyperbolic cosine of the parameter."
-msgstr ""
+msgstr "Враћа хиперболички коÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Converts a quantity in radians to degrees."
-msgstr ""
+msgstr "Претвара количину из радијана у Ñтепене."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Base-e Exponential."
-msgstr ""
+msgstr "База-е ЕкÑпоненцијал."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Base-2 Exponential."
-msgstr ""
+msgstr "База-е ЕкÑпоненцијал."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Finds the nearest integer less than or equal to the parameter."
-msgstr ""
+msgstr "Ðалази најближи интиџер мањи или једнак параметру."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Computes the fractional part of the argument."
-msgstr ""
+msgstr "Прорачунава фракциони део аргумента."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the inverse of the square root of the parameter."
-msgstr ""
+msgstr "Враћа обрнути квадратни корен параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Natural logarithm."
-msgstr ""
+msgstr "Природни логаритам."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Base-2 logarithm."
-msgstr ""
+msgstr "База-2 логаритам."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the greater of two values."
-msgstr ""
+msgstr "Враћа већу од 2 понуђене вредноÑти."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the lesser of two values."
-msgstr ""
+msgstr "Враћа мању од 2 понуђене вредноÑти."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Linear interpolation between two scalars."
-msgstr ""
+msgstr "Линеарно уметање између 2 Ñкалара."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the opposite value of the parameter."
-msgstr ""
+msgstr "Враћа Ñупротну вредноÑÑ‚ параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "1.0 - scalar"
-msgstr ""
+msgstr "1.0 - Ñкалар"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns the value of the first parameter raised to the power of the second."
-msgstr ""
+msgstr "Враћа вредноÑÑ‚ првог параметра увећану за вредноÑÑ‚ другог."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Converts a quantity in degrees to radians."
-msgstr ""
+msgstr "Претвара количину из Ñтепена у радијане."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "1.0 / scalar"
-msgstr ""
+msgstr "1.0 / Ñкалар"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Finds the nearest integer to the parameter."
-msgstr ""
+msgstr "Ðалази најближи интиџер параметру."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Finds the nearest even integer to the parameter."
-msgstr ""
+msgstr "Ðалази најближи једнак интиџер параметру."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Clamps the value between 0.0 and 1.0."
-msgstr ""
+msgstr "Притеже вредноÑÑ‚ између 0.0 и 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Extracts the sign of the parameter."
-msgstr ""
+msgstr "Извлачи знак параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the sine of the parameter."
-msgstr ""
+msgstr "Враћа ÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the hyperbolic sine of the parameter."
-msgstr ""
+msgstr "Враћа хиперболичи ÑÐ¸Ð½ÑƒÑ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð°."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the square root of the parameter."
-msgstr ""
+msgstr "Враћа квадратни корен параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n"
"\n"
@@ -9487,45 +9990,60 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"УглађенКорак функција ( Ñкалар(ивица0), Ñкалар(ивица1), Ñкалар(x) ).\n"
+"Враћа 0.0 ако је 'x' мање од 'ивице0' и 1.0 ако је x веће од 'edge1'. Иначе "
+"враћена вредноÑÑ‚ је уметнутута између 0.0 и 1.0 кориÑтећи Хермитове полиноме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Step function( scalar(edge), scalar(x) ).\n"
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Корак функција ( scalar(edge), scalar(x) ).\n"
+"\n"
+"Враћа 0.0 ако је 'x' мање од 'ивице' иначе враћа 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the tangent of the parameter."
-msgstr ""
+msgstr "Враћа танкгенту параметра"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the hyperbolic tangent of the parameter."
-msgstr ""
+msgstr "Враћа хипероболичну тангенту параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Finds the truncated value of the parameter."
-msgstr ""
+msgstr "Ðалази Ñкраћену вредноÑÑ‚ параметра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Adds scalar to scalar."
-msgstr ""
+msgstr "Додаје Ñкалар Ñкалару."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Divides scalar by scalar."
-msgstr ""
+msgstr "Дели Ñкалар Ñа Ñкаларом."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Multiplies scalar by scalar."
-msgstr ""
+msgstr "Множи Ñкалар Ñа Ñкаларом."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the remainder of the two scalars."
-msgstr ""
+msgstr "Враћа оÑтатак 2 Ñкалара."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Subtracts scalar from scalar."
-msgstr ""
+msgstr "Одузима Ñкалар од Ñкалара."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9538,12 +10056,14 @@ msgid "Scalar uniform."
msgstr "Промени Ñкаларну униформу (uniform)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Perform the cubic texture lookup."
-msgstr ""
+msgstr "Извршава претрагу кубичне текÑтуре."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Perform the texture lookup."
-msgstr ""
+msgstr "Извршава претрагу текÑтуре."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9566,6 +10086,7 @@ msgid "Transform function."
msgstr "Прозор транÑформације..."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Calculate the outer product of a pair of vectors.\n"
"\n"
@@ -9575,34 +10096,47 @@ msgid ""
"whose number of rows is the number of components in 'c' and whose number of "
"columns is the number of components in 'r'."
msgstr ""
+"Прорачунава Ñпољашњи продукт векторÑког пара.\n"
+"СпољашњиПродукт третира први параметар 'c' као вектор колону (матрица Ñа "
+"једном колоном) и други параметар 'r' као ред вектор (матрица Ñа једним "
+"редом) и одрађује линеарно алгебарÑко множење матрица 'c * r', приноÑећи "
+"матрицу чији број редова је број компоненти у 'c' и број колона је број "
+"компоненти у 'r'."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Composes transform from four vectors."
-msgstr ""
+msgstr "СаÑтавља транÑформу од четири вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Decomposes transform to four vectors."
-msgstr ""
+msgstr "РаÑтавља транÑформу у четри вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the determinant of a transform."
-msgstr ""
+msgstr "Прорачунава детерминанту транÑформе."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the inverse of a transform."
-msgstr ""
+msgstr "Прорачунава инверзију транÑформе."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the transpose of a transform."
-msgstr ""
+msgstr "Прорачунава Ð¿Ñ€ÐµÐ½Ð¾Ñ Ñ‚Ñ€Ð°Ð½Ñформе."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Multiplies transform by transform."
-msgstr ""
+msgstr "Множи транÑформу транÑформом."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Multiplies vector by transform."
-msgstr ""
+msgstr "Множи вектор Ñа транÑформом."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9625,68 +10159,89 @@ msgid "Vector operator."
msgstr "Промени векторÑки оператор"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Composes vector from three scalars."
-msgstr ""
+msgstr "СаÑтавља вектор од 3 Ñкалара."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Decomposes vector to three scalars."
-msgstr ""
+msgstr "РаÑтавља вектор у 3 Ñкалара."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the cross product of two vectors."
-msgstr ""
+msgstr "Прорачунава векторÑки производ 2 вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the distance between two points."
-msgstr ""
+msgstr "Враћа раÑтојање између 2 тачке."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the dot product of two vectors."
-msgstr ""
+msgstr "Прорачунава Ñкаларни производ 2 вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns the vector that points in the same direction as a reference vector. "
"The function has three vector parameters : N, the vector to orient, I, the "
"incident vector, and Nref, the reference vector. If the dot product of I and "
"Nref is smaller than zero the return value is N. Otherwise -N is returned."
msgstr ""
+"Враћа вектор који упућује у иÑтом правцу као и дати вектор. Функција има три "
+"вектор параметра: N, оријнтациони вектор, I, вектор инцидента, и Nref , "
+"референтни вектор. Ðко је Ñкаларни продукт од I и Nref мањи од 0 повратна "
+"вредноÑÑ‚ је N. У Ñупротном враћа -N."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the length of a vector."
-msgstr ""
+msgstr "Прорачунава дужину вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Linear interpolation between two vectors."
-msgstr ""
+msgstr "Линерно уметање између 2 вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Linear interpolation between two vectors using scalar."
-msgstr ""
+msgstr "Линерно уметање између 2 вектора кориÑтећи Ñкалар."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Calculates the normalize product of vector."
-msgstr ""
+msgstr "Прорачунава нормализовани векторÑки продукт."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "1.0 - vector"
-msgstr ""
+msgstr "1.0 - вектор"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "1.0 / vector"
-msgstr ""
+msgstr "1.0 / вектор"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns the vector that points in the direction of reflection ( a : incident "
"vector, b : normal vector )."
msgstr ""
+"Враћа вектор који указује у правцу одраза ( a : вектор инцидента, b : "
+"нормални вектор )."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the vector that points in the direction of refraction."
-msgstr ""
+msgstr "Враћа вектор који указује у правцу преламања."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n"
"\n"
@@ -9694,8 +10249,14 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"ГлаткиКорак функција ( вектор(ивица0), вектор(ивица1), вектор(x) ).\n"
+"\n"
+"Враћа 0.0 ако је 'x' мање од 'ивице0' и 1.0 ако је 'x' веће од 'ивице1'. У "
+"Ñупротном повратна вредноÑÑ‚ уметнута између 0.0 и 1.0 кориÑтећи Хермитове "
+"полиноме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n"
"\n"
@@ -9703,40 +10264,58 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"ГлаткиКорак функција ( Ñкалар(ивица0), Ñкалар(ивица1), вектор(x) ).\n"
+"\n"
+"Враћа 0.0 ако је 'x' мање од 'ивице0' и 1.0 ако је 'x' веће од 'ивице1'. У "
+"Ñупротном повратна вредноÑÑ‚ је уметнута између 0.0 и 1.0 кориÑтећи Хермитове "
+"полиноме."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Step function( vector(edge), vector(x) ).\n"
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Корак функција ( вектор(ивица), вектор(x) ).\n"
+"\n"
+"Враћа 0.0 ако је 'x' мање од 'ивице' у Ñупротном 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Step function( scalar(edge), vector(x) ).\n"
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Корак функција ( акалар(ивица), вектор(x) ).\n"
+"\n"
+"Враћа 0.0 ако је 'x' мање од 'ивице' у Ñупротном 1.0."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Adds vector to vector."
-msgstr ""
+msgstr "Додаје вектор вектору."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Divides vector by vector."
-msgstr ""
+msgstr "Дели вектор Ñа вектором."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Multiplies vector by vector."
-msgstr ""
+msgstr "Множи вектор Ñа вектором."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Returns the remainder of the two vectors."
-msgstr ""
+msgstr "Враћа оÑтатак 2 вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "Subtracts vector from vector."
-msgstr ""
+msgstr "Одузима вектор од вектора."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
@@ -9749,84 +10328,112 @@ msgid "Vector uniform."
msgstr "Промени векторÑку униформу (uniform)"
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Custom Godot Shader Language expression, with custom amount of input and "
"output ports. This is a direct injection of code into the vertex/fragment/"
"light function, do not use it to write the function declarations inside."
msgstr ""
+"Произвољни израз за Годот Цртачки Језик, Ñа произвољном количином улазних и "
+"излазних портова. Ово је директно убризгавање кода у тачка/део/Ñветло "
+"функцију, не кориÑти за пиÑање декларација функција унутра."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Returns falloff based on the dot product of surface normal and view "
"direction of camera (pass associated inputs to it)."
msgstr ""
+"Враћа Ñмањење базирано на Ñкаларном продукту нормале површине и правца "
+"гледања камере (проÑлеђује удружене улазе)."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"Custom Godot Shader Language expression, which is placed on top of the "
"resulted shader. You can place various function definitions inside and call "
"it later in the Expressions. You can also declare varyings, uniforms and "
"constants."
msgstr ""
+"Произвољни израз Годот Цртачког Језика, који је поÑтављен на врх "
+"резултирајућег цртача. Можеш поÑтавити разне дефиниције функција унутра и "
+"позвати их каÑније у Изразу. Такође можеш даклариÑати варијације, униформе и "
+"конÑтанте."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "(Fragment/Light mode only) Scalar derivative function."
-msgstr ""
+msgstr "(Ñамо Део/Светло режим) Функција Ñкаларне деривације."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid "(Fragment/Light mode only) Vector derivative function."
-msgstr ""
+msgstr "(Ñамо Део/Светло режим) Вектор Ñкаларне деривације."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"(Fragment/Light mode only) (Vector) Derivative in 'x' using local "
"differencing."
msgstr ""
+"(Ñамо Део/Светло режим) (Вектор) Дериват у 'x' кориÑтећи локалну "
+"диференцијацију."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"(Fragment/Light mode only) (Scalar) Derivative in 'x' using local "
"differencing."
msgstr ""
+"(Ñамо Део/Светло режим) (Скалар) Дериват у 'x' кориÑтећи локалну "
+"диференцијацију."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"(Fragment/Light mode only) (Vector) Derivative in 'y' using local "
"differencing."
msgstr ""
+"(Ñамо Део/Светло режим) (Вектор) Дериват у 'y' кориÑтећи локалну "
+"диференцијацију."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"(Fragment/Light mode only) (Scalar) Derivative in 'y' using local "
"differencing."
msgstr ""
+"(Ñамо Део/Светло режим) (Скалар) Дериват у 'y' кориÑтећи локалну "
+"диференцијацију."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and "
"'y'."
-msgstr ""
+msgstr "(Ñамо Део/Светло режим) (Вектор) Сума абÑолутних деривата у 'x' и 'y'."
#: editor/plugins/visual_shader_editor_plugin.cpp
+#, fuzzy
msgid ""
"(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and "
"'y'."
-msgstr ""
+msgstr "(Ñамо Део/Светло режим) (Скалар) Сума абÑолутних деривата у 'x' и 'y'."
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "VisualShader"
-msgstr "Шејдер"
+msgstr "ВизуелниЦртач"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Edit Visual Property"
-msgstr "Уреди филтере"
+msgstr "Уреди Визуелне ОÑобине"
#: editor/plugins/visual_shader_editor_plugin.cpp
#, fuzzy
msgid "Visual Shader Mode Changed"
-msgstr "Промене шејдера"
+msgstr "Визуелни Цртач Режим промењен"
#: editor/project_export.cpp
msgid "Runnable"
@@ -9835,11 +10442,12 @@ msgstr "Покретљива"
#: editor/project_export.cpp
#, fuzzy
msgid "Add initial export..."
-msgstr "Додај улаз"
+msgstr "Додај почетни извоз..."
#: editor/project_export.cpp
+#, fuzzy
msgid "Add previous patches..."
-msgstr ""
+msgstr "Додај претходне закрпе..."
#: editor/project_export.cpp
msgid "Delete patch '%s' from list?"
@@ -9851,21 +10459,29 @@ msgid "Delete preset '%s'?"
msgstr "Обриши поÑтавку „%s“?"
#: editor/project_export.cpp
+#, fuzzy
msgid ""
"Failed to export the project for platform '%s'.\n"
"Export templates seem to be missing or invalid."
msgstr ""
+"ÐеуÑпешан извоз пројекта за плазформу '%s'.\n"
+"Изгледа да недоÑтају извозни нацрти или ниÑу иÑправни."
#: editor/project_export.cpp
+#, fuzzy
msgid ""
"Failed to export the project for platform '%s'.\n"
"This might be due to a configuration issue in the export preset or your "
"export settings."
msgstr ""
+"ÐеуÑпешан извоз пројекта за платформу '%s'.\n"
+"Ово може бити због проблема Ñа подешавањима у извозним поÑтавкама или твојим "
+"извозним подешавањима."
#: editor/project_export.cpp
+#, fuzzy
msgid "Release"
-msgstr ""
+msgstr "Издање"
#: editor/project_export.cpp
#, fuzzy
@@ -9891,10 +10507,12 @@ msgid "Add..."
msgstr "Додај..."
#: editor/project_export.cpp
+#, fuzzy
msgid ""
"If checked, the preset will be available for use in one-click deploy.\n"
"Only one preset per platform may be marked as runnable."
msgstr ""
+"Ðко је означено, поÑтавке ће бити омогућене за коришћење у један-клик развој."
#: editor/project_export.cpp
#, fuzzy
@@ -9961,8 +10579,9 @@ msgid "Features"
msgstr "КарактериÑтике"
#: editor/project_export.cpp
+#, fuzzy
msgid "Custom (comma-separated):"
-msgstr ""
+msgstr "Произвољно (одвојено зарезом):"
#: editor/project_export.cpp
msgid "Feature List:"
@@ -9979,24 +10598,29 @@ msgid "Script Export Mode:"
msgstr "Режим извоза:"
#: editor/project_export.cpp
+#, fuzzy
msgid "Text"
-msgstr ""
+msgstr "ТекÑÑ‚"
#: editor/project_export.cpp
+#, fuzzy
msgid "Compiled"
-msgstr ""
+msgstr "СаÑтављено"
#: editor/project_export.cpp
+#, fuzzy
msgid "Encrypted (Provide Key Below)"
-msgstr ""
+msgstr "Шифровано (Одабери Кључ ИÑпод)"
#: editor/project_export.cpp
+#, fuzzy
msgid "Invalid Encryption Key (must be 64 characters long)"
-msgstr ""
+msgstr "Ðеважећи Кључ за Шифровање(мора бити 64 карактера дуг)"
#: editor/project_export.cpp
+#, fuzzy
msgid "Script Encryption Key (256-bits as hex):"
-msgstr ""
+msgstr "Кључ Шифровања Скрипте (256-бајтова као хекÑ)"
#: editor/project_export.cpp
msgid "Export PCK/Zip"
@@ -10022,8 +10646,9 @@ msgid "ZIP File"
msgstr " Датотеке"
#: editor/project_export.cpp
+#, fuzzy
msgid "Godot Game Pack"
-msgstr ""
+msgstr "Годот Игра Паковање"
#: editor/project_export.cpp
msgid "Export templates for this platform are missing:"
@@ -10034,8 +10659,9 @@ msgid "Manage Export Templates"
msgstr "Управљај извозним шаблонима"
#: editor/project_export.cpp
+#, fuzzy
msgid "Export With Debug"
-msgstr ""
+msgstr "Извези Ñа ИнÑектицидом"
#: editor/project_manager.cpp
#, fuzzy
@@ -10048,29 +10674,35 @@ msgid "Error opening package file (it's not in ZIP format)."
msgstr "Грешка при отварању датотеку пакета. Датотека није zip формата."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."
-msgstr ""
+msgstr "Ðеважећи \".zip\" пројекат фајл; не Ñадржи \"project.godot\" фајл."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Please choose an empty folder."
-msgstr ""
+msgstr "Одабери празан фолдер."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Please choose a \"project.godot\" or \".zip\" file."
-msgstr ""
+msgstr "Одабери \"project.godot\" или \".zip\" фајл."
#: editor/project_manager.cpp
+#, fuzzy
msgid "This directory already contains a Godot project."
-msgstr ""
+msgstr "Овај директоријум већ Ñадржи Годот пројекат."
#: editor/project_manager.cpp
+#, fuzzy
msgid "New Game Project"
-msgstr ""
+msgstr "Ðова Игра Пројекат"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Imported Project"
-msgstr ""
+msgstr "Увезен Пројекат"
#: editor/project_manager.cpp
#, fuzzy
@@ -10083,118 +10715,149 @@ msgid "Couldn't create folder."
msgstr "ÐеуÑпех при прављењу директоријума."
#: editor/project_manager.cpp
+#, fuzzy
msgid "There is already a folder in this path with the specified name."
-msgstr ""
+msgstr "Ðа овој путањи већ поÑтоји фолдер Ñа овим именом."
#: editor/project_manager.cpp
+#, fuzzy
msgid "It would be a good idea to name your project."
-msgstr ""
+msgstr "Била би добра идеја да именујеш Ñвој пројекат."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Invalid project path (changed anything?)."
-msgstr ""
+msgstr "Ðеважећа путања пројекта(нешто је измењено?)."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Couldn't load project.godot in project path (error %d). It may be missing or "
"corrupted."
msgstr ""
+"ÐеуÑпешно учитавање project.godot-а у његовој путањи (грешка %d). Могуће да "
+"нешто недоÑтаје или је корумпирано."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Couldn't edit project.godot in project path."
-msgstr ""
+msgstr "ÐеуÑпешна измена project.godot-а у путањи пројекта."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Couldn't create project.godot in project path."
-msgstr ""
+msgstr "ÐеуÑпешно креирање project.godot у путањи пројекта."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Rename Project"
-msgstr ""
+msgstr "Преимениуј Пројекат"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Import Existing Project"
-msgstr ""
+msgstr "Увези ПоÑтојећи Пројекат"
#: editor/project_manager.cpp
#, fuzzy
msgid "Import & Edit"
-msgstr "Увоз"
+msgstr "Увези и Измени"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Create New Project"
-msgstr ""
+msgstr "Креирај Ðов Пројекат"
#: editor/project_manager.cpp
#, fuzzy
msgid "Create & Edit"
-msgstr "Ðаправи емитер"
+msgstr "Креирај и Измени"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Install Project:"
-msgstr ""
+msgstr "ИнÑталирај Пројекат:"
#: editor/project_manager.cpp
#, fuzzy
msgid "Install & Edit"
-msgstr "ИнÑталирај"
+msgstr "ИнÑталирај и Измени"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Project Name:"
-msgstr ""
+msgstr "Има Пројекта:"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Project Path:"
-msgstr ""
+msgstr "Путања Пројекта:"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Project Installation Path:"
-msgstr ""
+msgstr "ИнÑталациона Путања Пројекта:"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Renderer:"
-msgstr ""
+msgstr "Цртач:"
#: editor/project_manager.cpp
+#, fuzzy
msgid "OpenGL ES 3.0"
-msgstr ""
+msgstr "OpenGL ES 3.0"
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Higher visual quality\n"
"All features available\n"
"Incompatible with older hardware\n"
"Not recommended for web games"
msgstr ""
+"Виши визуелни квалитет\n"
+"Свe карактериÑтике доÑтупне\n"
+"Ðекомпатибилно Ñа Ñтаријим хардвером\n"
+"Ðије препоручљиво за веб игрице"
#: editor/project_manager.cpp
+#, fuzzy
msgid "OpenGL ES 2.0"
-msgstr ""
+msgstr "OpenGL ES 2.0"
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Lower visual quality\n"
"Some features not available\n"
"Works on most hardware\n"
"Recommended for web games"
msgstr ""
+"Ðижи визуелни квалитет\n"
+"Ðеке карактериÑтике ниÑу доÑтупне\n"
+"Ради на Ñкоро Ñваком хардверу\n"
+"Пропоручљиво за веб игрице"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Renderer can be changed later, but scenes may need to be adjusted."
-msgstr ""
+msgstr "Цртач може бити промењен каÑније, али Ñцене морају бити прилагођене."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Unnamed Project"
-msgstr ""
+msgstr "Ðеименован Пројекат"
#: editor/project_manager.cpp
#, fuzzy
msgid "Missing Project"
-msgstr "Пројекат"
+msgstr "ÐедоÑтаје Пројекат"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Error: Project is missing on the filesystem."
-msgstr ""
+msgstr "Грешка: Пројекат недоÑтаје у фајл ÑиÑтему."
#: editor/project_manager.cpp
#, fuzzy
@@ -10202,10 +10865,12 @@ msgid "Can't open project at '%s'."
msgstr "Ðе могу отворити '%s'."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Are you sure to open more than one project?"
-msgstr ""
+msgstr "Да ли Ñигурно желиш да отвориш више одједног пројекта?"
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"The following project settings file does not specify the version of Godot "
"through which it was created.\n"
@@ -10217,8 +10882,18 @@ msgid ""
"Warning: You won't be able to open the project with previous versions of the "
"engine anymore."
msgstr ""
+"Ðаредни фајл Ñа подешавањима пројекта нема наведену верзију Годот-а Ñа у "
+"којем је креиран.\n"
+"\n"
+"%s\n"
+"\n"
+"Ðко наÑтавиш Ñа отварањем, биће пребачен у тренутни Годот фајл формат за "
+"подешавања.\n"
+"Упозорење: Више нећеш бити у Ñтању да отвориш пројекат у претходним "
+"верзијама Годот-а."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"The following project settings file was generated by an older engine "
"version, and needs to be converted for this version:\n"
@@ -10229,12 +10904,23 @@ msgid ""
"Warning: You won't be able to open the project with previous versions of the "
"engine anymore."
msgstr ""
+"Ðаведени фајл Ñа подешавањима пројекта је креиран од Ñтране Ñтарије верзује "
+"Годот-а, и треба га пребацити у ову верзију:\n"
+"\n"
+"%s\n"
+"\n"
+"Желиш то да извршиш пребацивање?\n"
+"Упозорење: Више нећеш бити у Ñтању да отвориш пројекат Ñа преходном верзијом "
+"Годот-а."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"The project settings were created by a newer engine version, whose settings "
"are not compatible with this version."
msgstr ""
+"Подешавања пројекта Ñу креирана Ñа новијом верзијом Годот-а, која ниÑу "
+"доÑтупна у овој верзији."
#: editor/project_manager.cpp
#, fuzzy
@@ -10248,44 +10934,64 @@ msgstr ""
"„апликација“."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Can't run project: Assets need to be imported.\n"
"Please edit the project to trigger the initial import."
msgstr ""
+"Пројекат није могуће покренути: СредÑтва морају бити увезена.\n"
+"Молимо измени пројекат да активираш иницијални увоз."
#: editor/project_manager.cpp
+#, fuzzy
msgid "Are you sure to run %d projects at once?"
-msgstr ""
+msgstr "Да ли Ñигурно желиш да покренеш %d пројеката одједном?"
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Remove %d projects from the list?\n"
"The project folders' contents won't be modified."
msgstr ""
+"Уклони %d пројекте Ñа лиÑте?\n"
+"Садржај фолдера пројекта неће бити измењен."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Remove this project from the list?\n"
"The project folder's contents won't be modified."
msgstr ""
+"Уклони овај пројекат Ñа лиÑте?\n"
+"Садржај фолдера пројекта неће бити измењен."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Remove all missing projects from the list?\n"
"The project folders' contents won't be modified."
msgstr ""
+"Уклони Ñве изгубљене пројекте Ñа лиÑте?\n"
+"Садржај фолдера пројекта неће бити измењен."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Language changed.\n"
"The interface will update after restarting the editor or project manager."
msgstr ""
+"Језик промењен.\n"
+"Изглед ће бити ажуриран поÑле реÑтартовања уредника или менеџера пројекта."
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"Are you sure to scan %s folders for existing Godot projects?\n"
"This could take a while."
msgstr ""
+"Да ли Ñигурно желиш да прегледаш %s фолдере у потрази за поÑтојећим Годот "
+"пројектима?\n"
+"Ово може потрајати."
#: editor/project_manager.cpp
msgid "Project Manager"
@@ -10294,350 +11000,434 @@ msgstr "Менаџер пројекта"
#: editor/project_manager.cpp
#, fuzzy
msgid "Projects"
-msgstr "Пројекат"
+msgstr "Пројекти"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Last Modified"
-msgstr ""
+msgstr "Задњи Измењен"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Scan"
-msgstr ""
+msgstr "Претрага"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Select a Folder to Scan"
-msgstr ""
+msgstr "Одабери Фолдер за Претрагу"
#: editor/project_manager.cpp
+#, fuzzy
msgid "New Project"
-msgstr ""
+msgstr "Ðов Порјекат"
#: editor/project_manager.cpp
#, fuzzy
msgid "Remove Missing"
-msgstr "Обриши тачку"
+msgstr "Обриши Изгубњено"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Templates"
-msgstr ""
+msgstr "ОбразÑи"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Restart Now"
-msgstr ""
+msgstr "РеÑтартуј Сада"
#: editor/project_manager.cpp
+#, fuzzy
msgid "Can't run project"
-msgstr ""
+msgstr "Пројекат није могуће покренути"
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"You currently don't have any projects.\n"
"Would you like to explore official example projects in the Asset Library?"
msgstr ""
+"Тренутно немаш ни један пројекат.\n"
+"Желиш ли да изтражиш званичне примере пројеката из Библиотеке СредÑтава?"
#: editor/project_manager.cpp
+#, fuzzy
msgid ""
"The search box filters projects by name and last path component.\n"
"To filter projects by name and full path, the query must contain at least "
"one `/` character."
msgstr ""
+"Оквир за претрагу пробира пројекте на оÑнову имена и поÑледњег дела путање.\n"
+"За пробирање на оÑнову имену и целе путање, упит мора Ñадржати бар један `/` "
+"карактер."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Key "
-msgstr ""
+msgstr "Кључ"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Joy Button"
-msgstr ""
+msgstr "ÐÐ¾Ñ˜Ñ Ð´ÑƒÐ³Ð¼Ð¸Ð¶"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Joy Axis"
-msgstr ""
+msgstr "ÐÐ¾Ñ˜Ñ ÐžÑе"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Mouse Button"
-msgstr ""
+msgstr "Миш Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid ""
"Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'"
msgstr ""
+"Ðеважеће име акције. Ðе може бити празно или Ñадржати '/', ':', '=', '\\' "
+"или '\"'"
#: editor/project_settings_editor.cpp
#, fuzzy
msgid "An action with the name '%s' already exists."
-msgstr "Грешка: име анимације већ поÑтоји!"
+msgstr "Радња Ñа именом '%s' већ поÑтоји."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Rename Input Action Event"
-msgstr ""
+msgstr "Преименуј Догађај Улазне Радње"
#: editor/project_settings_editor.cpp
#, fuzzy
msgid "Change Action deadzone"
-msgstr "Измени име анимације:"
+msgstr "Измени мртву-зону Радње"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Add Input Action Event"
-msgstr ""
+msgstr "Додај Догађај Улазне Радње"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "All Devices"
-msgstr ""
+msgstr "Сви Уређаји"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Device"
-msgstr ""
+msgstr "Уређаји"
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
+#, fuzzy
msgid "Press a Key..."
-msgstr ""
+msgstr "СтиÑни Дугме..."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Mouse Button Index:"
-msgstr ""
+msgstr "Миш Дугме ИндекÑ"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Left Button"
-msgstr ""
+msgstr "Лево Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Right Button"
-msgstr ""
+msgstr "ДеÑно Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Middle Button"
-msgstr ""
+msgstr "Средње Дугма"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Wheel Up Button"
-msgstr ""
+msgstr "Точкић Горе Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Wheel Down Button"
-msgstr ""
+msgstr "Точкић Доле Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Wheel Left Button"
-msgstr ""
+msgstr "Точкић Лево Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Wheel Right Button"
-msgstr ""
+msgstr "Точкић ДеÑно Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "X Button 1"
-msgstr ""
+msgstr "X Дугме 1"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "X Button 2"
-msgstr ""
+msgstr "X Дугме 2"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Joypad Axis Index:"
-msgstr ""
+msgstr "Ðојпад ОÑа ИндекÑ:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Axis"
-msgstr ""
+msgstr "ОÑе"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Joypad Button Index:"
-msgstr ""
+msgstr "Ðојпад Дугме ИндекÑ:"
#: editor/project_settings_editor.cpp
#, fuzzy
msgid "Erase Input Action"
-msgstr "Обриши одабрано"
+msgstr "Обриши Улазну Радњу"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Erase Input Action Event"
-msgstr ""
+msgstr "Обриши Догађај Улазне Радње"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Add Event"
-msgstr ""
+msgstr "Додај Догађај"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Button"
-msgstr ""
+msgstr "Дугме"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Left Button."
-msgstr ""
+msgstr "Лево Дугме."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Right Button."
-msgstr ""
+msgstr "ДеÑно Дугме."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Middle Button."
-msgstr ""
+msgstr "Средње Дугме."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Wheel Up."
-msgstr ""
+msgstr "Точкић Горе."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Wheel Down."
-msgstr ""
+msgstr "Точкић Доле."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Add Global Property"
-msgstr ""
+msgstr "Додај Глобалну ОÑобину"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Select a setting item first!"
-msgstr ""
+msgstr "Прво одабери подешавање предмета!"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "No property '%s' exists."
-msgstr ""
+msgstr "ОÑобина %s' не поÑтоји."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Setting '%s' is internal, and it can't be deleted."
-msgstr ""
+msgstr "Подешавање '%s' је унутрашње, и не може бити обриÑано."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Delete Item"
-msgstr ""
+msgstr "Обриши Предмет"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid ""
"Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'."
msgstr ""
+"Ðеважеће име радње. Ðе може бити празно или Ñадржати '/', ':', '=', '\\' или "
+"'\"'."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Add Input Action"
-msgstr ""
+msgstr "Додај Улазну Радњу"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Error saving settings."
-msgstr ""
+msgstr "Грешка при памћењу подешавања."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Settings saved OK."
-msgstr ""
+msgstr "Подешавања уÑпешно упамћена."
#: editor/project_settings_editor.cpp
#, fuzzy
msgid "Moved Input Action Event"
-msgstr "Обриши одабрано"
+msgstr "Померен Догађај Улазне Радње"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Override for Feature"
-msgstr ""
+msgstr "Препиши за ОÑобину"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Add Translation"
-msgstr ""
+msgstr "Додај Превод"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Remove Translation"
-msgstr ""
+msgstr "Обриши Превод"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Add Remapped Path"
-msgstr ""
+msgstr "Додај Преправљену Путању"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Resource Remap Add Remap"
-msgstr ""
+msgstr "РеÑÑƒÑ€Ñ ÐŸÑ€ÐµÐ¿Ñ€Ð°Ð²ÐºÐ° Додај Преправку"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Change Resource Remap Language"
-msgstr ""
+msgstr "Промени Језик РеÑÑƒÑ€Ñ ÐŸÑ€ÐµÐ¿Ñ€Ð°Ð²ÐºÐµ"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Remove Resource Remap"
-msgstr ""
+msgstr "Уклони РеÑÑƒÑ€Ñ ÐŸÑ€ÐµÐ¿Ñ€Ð°Ð²ÐºÑƒ"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Remove Resource Remap Option"
-msgstr ""
+msgstr "Уклони Опцију РеÑÑƒÑ€Ñ ÐŸÑ€ÐµÐ¿Ñ€Ð°Ð²ÐºÐµ"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Changed Locale Filter"
-msgstr ""
+msgstr "Измењен Локални Пробирач"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Changed Locale Filter Mode"
-msgstr ""
+msgstr "Измењен Локални Режим Пробирања"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Project Settings (project.godot)"
-msgstr ""
+msgstr "Подешавања Пројекта (project.godot)"
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
msgid "General"
-msgstr ""
+msgstr "Генерална"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Override For..."
-msgstr ""
+msgstr "Препиши За..."
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
+#, fuzzy
msgid "The editor must be restarted for changes to take effect."
-msgstr ""
+msgstr "Уредник мора бити реÑтартован да би наÑтупиле промене."
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Input Map"
-msgstr ""
+msgstr "Мапа Улаза"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Action:"
-msgstr ""
+msgstr "Радња:"
#: editor/project_settings_editor.cpp
#, fuzzy
msgid "Action"
-msgstr "Помери акцију"
+msgstr "Радња"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Deadzone"
-msgstr ""
+msgstr "Мртва-зона"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Device:"
-msgstr ""
+msgstr "Уређај:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Index:"
-msgstr ""
+msgstr "ИндекÑ:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Localization"
-msgstr ""
+msgstr "Локализација"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Translations"
-msgstr ""
+msgstr "Превод"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Translations:"
-msgstr ""
+msgstr "Преводи:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Remaps"
-msgstr ""
+msgstr "Преправке"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Resources:"
-msgstr ""
+msgstr "РеÑурÑи:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Remaps by Locale:"
-msgstr ""
+msgstr "Локалне Преправке:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Locale"
-msgstr ""
+msgstr "Локал"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Locales Filter"
-msgstr ""
+msgstr "Локални Пробирачи"
#: editor/project_settings_editor.cpp
#, fuzzy
@@ -10650,16 +11440,19 @@ msgid "Show Selected Locales Only"
msgstr "Само одабрано"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Filter mode:"
-msgstr ""
+msgstr "Режим Пробирања:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "Locales:"
-msgstr ""
+msgstr "Локал:"
#: editor/project_settings_editor.cpp
+#, fuzzy
msgid "AutoLoad"
-msgstr ""
+msgstr "Ðуто-Учитавање"
#: editor/project_settings_editor.cpp
msgid "Plugins"
@@ -10670,125 +11463,146 @@ msgid "Preset..."
msgstr "ПоÑтавке..."
#: editor/property_editor.cpp
+#, fuzzy
msgid "Zero"
-msgstr ""
+msgstr "Ðула"
#: editor/property_editor.cpp
+#, fuzzy
msgid "Easing In-Out"
-msgstr ""
+msgstr "Ублажавање У-Од"
#: editor/property_editor.cpp
+#, fuzzy
msgid "Easing Out-In"
-msgstr ""
+msgstr "Ублажавање Од-У"
#: editor/property_editor.cpp
+#, fuzzy
msgid "File..."
-msgstr ""
+msgstr "Фајл..."
#: editor/property_editor.cpp
+#, fuzzy
msgid "Dir..."
-msgstr ""
+msgstr "Дир..."
#: editor/property_editor.cpp
+#, fuzzy
msgid "Assign"
-msgstr ""
+msgstr "Додели"
#: editor/property_editor.cpp
+#, fuzzy
msgid "Select Node"
-msgstr ""
+msgstr "Одабери Чвор"
#: editor/property_editor.cpp
+#, fuzzy
msgid "Error loading file: Not a resource!"
-msgstr ""
+msgstr "Гречка при учитавању фајла: Ðије реÑурÑ!"
#: editor/property_editor.cpp
+#, fuzzy
msgid "Pick a Node"
-msgstr ""
+msgstr "Одабери Чвор"
#: editor/property_editor.cpp
+#, fuzzy
msgid "Bit %d, val %d."
-msgstr ""
+msgstr "Бит %d, вредноÑÑ‚ %d."
#: editor/property_selector.cpp
+#, fuzzy
msgid "Select Property"
-msgstr ""
+msgstr "Одабери ОÑобину"
#: editor/property_selector.cpp
+#, fuzzy
msgid "Select Virtual Method"
-msgstr ""
+msgstr "Одабери Виртуелну Методу"
#: editor/property_selector.cpp
+#, fuzzy
msgid "Select Method"
-msgstr ""
+msgstr "Одабери Методу"
#: editor/rename_dialog.cpp editor/scene_tree_dock.cpp
#, fuzzy
msgid "Batch Rename"
-msgstr "Преименуј"
+msgstr "Преименуј Гомилу"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Prefix"
-msgstr ""
+msgstr "Предметак"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Suffix"
-msgstr ""
+msgstr "ÐаÑтавак"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "Use Regular Expressions"
-msgstr "ПоÑтави правоугаони регион"
+msgstr "КориÑти Регуларне Изразе"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "Advanced Options"
-msgstr "ПоÑтавке залепљавања"
+msgstr "Ðапредне ПоÑтавке"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Substitute"
-msgstr ""
+msgstr "Замена"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "Node name"
-msgstr "Име чвора:"
+msgstr "Име Чвора"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Node's parent name, if available"
-msgstr ""
+msgstr "Чворово име оца, ако је доÑтупно"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "Node type"
-msgstr "Име чвора:"
+msgstr "Ð’Ñ€Ñта Чвора"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "Current scene name"
-msgstr "Тренутна Ñцена није Ñачувана. Ипак отвори?"
+msgstr "Име тренутне Ñцене"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "Root node name"
-msgstr "Преименуј"
+msgstr "Име кореног нода"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid ""
"Sequential integer counter.\n"
"Compare counter options."
-msgstr ""
+msgstr "Редни бројач интиџера"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Per-level Counter"
-msgstr ""
+msgstr "Пред-Ðиво Бројач"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "If set the counter restarts for each group of child nodes"
-msgstr ""
+msgstr "Ðко је поÑтављен, бројач Ñе реÑтартује за Ñваку групу деце чворова"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Initial value for the counter"
-msgstr ""
+msgstr "Иницијална вредноÑÑ‚ бројача"
#: editor/rename_dialog.cpp
#, fuzzy
@@ -10796,38 +11610,48 @@ msgid "Step"
msgstr "Корак:"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Amount by which counter is incremented for each node"
-msgstr ""
+msgstr "Ð˜Ð·Ð½Ð¾Ñ Ð·Ð° који је бројач увећан за Ñваки Чвор"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Padding"
-msgstr ""
+msgstr " Пуњење"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid ""
"Minimum number of digits for the counter.\n"
"Missing digits are padded with leading zeros."
msgstr ""
+"Ðајмањи број цифара за Ñваки бројач.\n"
+"ÐедоÑтатак цифара је попуњен водећим нулама."
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Post-Process"
-msgstr ""
+msgstr "Ðакон-Обраде"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Keep"
-msgstr ""
+msgstr "Задржи"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "PascalCase to snake_case"
-msgstr ""
+msgstr "ПаÑÐºÐ°Ð»Ð—Ð°Ð¿Ð¸Ñ Ñƒ змија_запиÑ"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "snake_case to PascalCase"
-msgstr ""
+msgstr "змија_Ð·Ð°Ð¿Ð¸Ñ Ñƒ ПаÑкалЗапиÑ"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Case"
-msgstr ""
+msgstr "ЗапиÑ"
#: editor/rename_dialog.cpp
#, fuzzy
@@ -10845,155 +11669,193 @@ msgid "Reset"
msgstr "РеÑетуј увеличање"
#: editor/rename_dialog.cpp
+#, fuzzy
msgid "Regular Expression Error"
-msgstr ""
+msgstr "Регуларни Израз Грешка"
#: editor/rename_dialog.cpp
#, fuzzy
msgid "At character %s"
-msgstr "Важећа Ñлова:"
+msgstr "Код карактера %s"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Reparent Node"
-msgstr ""
+msgstr "Промени оца Чвору"
#: editor/reparent_dialog.cpp
+#, fuzzy
msgid "Reparent Location (Select new Parent):"
-msgstr ""
+msgstr "Промени оца Локацији (Одабери новог Оца):"
#: editor/reparent_dialog.cpp
+#, fuzzy
msgid "Keep Global Transform"
-msgstr ""
+msgstr "Сачувај Глобалну ТранÑформу"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Reparent"
-msgstr ""
+msgstr "Промени оца"
#: editor/run_settings_dialog.cpp
+#, fuzzy
msgid "Run Mode:"
-msgstr ""
+msgstr "Режим Кретања:"
#: editor/run_settings_dialog.cpp
+#, fuzzy
msgid "Current Scene"
-msgstr ""
+msgstr "Тренутна Сцена"
#: editor/run_settings_dialog.cpp
+#, fuzzy
msgid "Main Scene"
-msgstr ""
+msgstr "Главна Сцена"
#: editor/run_settings_dialog.cpp
+#, fuzzy
msgid "Main Scene Arguments:"
-msgstr ""
+msgstr "Ðргументи Главне Сцене"
#: editor/run_settings_dialog.cpp
+#, fuzzy
msgid "Scene Run Settings"
-msgstr ""
+msgstr "Подешавања Сцене Кретања"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "No parent to instance the scenes at."
-msgstr ""
+msgstr "Ðема оца где би Ñцена била инÑтанцирана"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Error loading scene from %s"
-msgstr ""
+msgstr "Грешка при учитавању Ñцене из %s"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid ""
"Cannot instance the scene '%s' because the current scene exists within one "
"of its nodes."
msgstr ""
+"Ðемогуће инÑтанцирање Ñцене '%s' јер трентутна Ñцене поÑтоји унутар једаног "
+"од њених Чворова."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Instance Scene(s)"
-msgstr ""
+msgstr "Сцена/е ИнÑтанца"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Replace with Branch Scene"
-msgstr ""
+msgstr "Замени Ñа Граном Сцене"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Instance Child Scene"
-msgstr ""
+msgstr "ИнÑтанца Сцена Дете"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Припој Скрипту"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "This operation can't be done on the tree root."
-msgstr ""
+msgstr "Операције не може бити извржена над кореном дрвета."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Move Node In Parent"
-msgstr ""
+msgstr "Пребаци Чвор код Родитеља"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Move Nodes In Parent"
-msgstr ""
+msgstr "Пребаци Чворове код Родитеља"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Duplicate Node(s)"
-msgstr ""
+msgstr "УдвоÑтручи Чвор/ове"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Can't reparent nodes in inherited scenes, order of nodes can't change."
msgstr ""
+"ÐеуÑпело додељивање родитеља чвору у наÑлеђеним Ñценама, редоÑлед чворова Ñе "
+"не може мењати."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Node must belong to the edited scene to become root."
-msgstr ""
+msgstr "Чвор мора припадати измењеној Ñцени да би поÑтао корен."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Instantiated scenes can't become root"
-msgstr ""
+msgstr "ИнÑтанциране Ñцене не могу бити корен"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Make node as Root"
-msgstr "Сачувај Ñцену"
+msgstr "Ðаправи Корен од чвора"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Delete %d nodes?"
-msgstr "Ðаправи чвор"
+msgstr "Обриши %d чворове?"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Delete the root node \"%s\"?"
-msgstr "Обриши чвор/ове графа шејдера"
+msgstr "Обриши корени чвор \"%s\"?"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Delete node \"%s\" and its children?"
-msgstr ""
+msgstr "Обриши чвор \"%s\" и његову децу?"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Delete node \"%s\"?"
-msgstr "Ðаправи чвор"
+msgstr "Обриши чвор \"%s\"?"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Can not perform with the root node."
-msgstr ""
+msgstr "Ðемогуће извршити Ñа кореним чвором."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "This operation can't be done on instanced scenes."
-msgstr ""
+msgstr "Операција не може бити извршена на инÑтанцираној Ñцени."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Save New Scene As..."
-msgstr ""
+msgstr "Упамти Ðову Сцену Као..."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid ""
"Disabling \"editable_instance\" will cause all properties of the node to be "
"reverted to their default."
msgstr ""
+"Онемогућивање \"измењиве_инÑтанце\" ће проузроковати да Ñва подешавања чвора "
+"буду повраћена на уобичајена."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid ""
"Enabling \"Load As Placeholder\" will disable \"Editable Children\" and "
"cause all properties of the node to be reverted to their default."
msgstr ""
+"Омогућавање \"Учитај Као МеÑточувца\" ће онемогућити \"Измељива Деца\" и "
+"проузтоковати Ñва подешавања чвора да буду враћена на уобичајена."
#: editor/scene_tree_dock.cpp
#, fuzzy
@@ -11003,272 +11865,333 @@ msgstr "Ðаправи коÑти"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "New Scene Root"
-msgstr "Сачувај Ñцену"
+msgstr "Ðови Корен Сцене"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Create Root Node:"
-msgstr "Ðаправи чвор"
+msgstr "Ðаправи корени чвор:"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "2D Scene"
-msgstr "Сцена"
+msgstr "2Д Сцена"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "3D Scene"
-msgstr "Сцена"
+msgstr "3Д Сцена"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "User Interface"
-msgstr ""
+msgstr "КориÑнички ИнтерфејÑ"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Other Node"
-msgstr "Ðаправи чвор"
+msgstr "Други Чвор"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Can't operate on nodes from a foreign scene!"
-msgstr ""
+msgstr "Ðемогуће опериÑати на чвору из Ñтране Ñцене!"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Can't operate on nodes the current scene inherits from!"
-msgstr ""
+msgstr "Ðемогуће опериÑати на чворовима од којих тренутна Ñцена наÑлеђује!"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Attach Script"
-msgstr ""
+msgstr "Припој Скрипту"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Remove Node(s)"
-msgstr ""
+msgstr "Уклони Чвор/ове"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Change type of node(s)"
-msgstr "Промени улазно име"
+msgstr "Промени врÑту чвора/ова"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid ""
"Couldn't save new scene. Likely dependencies (instances) couldn't be "
"satisfied."
msgstr ""
+"ÐеуÑпело памћене Ñцене. Вероватно завиÑноÑти (инÑтанце) ниÑу задовољени."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Error saving scene."
-msgstr ""
+msgstr "Грешка памћена Ñцена."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Error duplicating scene to save it."
-msgstr ""
+msgstr "Грешка удвоÑтручивање Ñцене ради памћења."
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Sub-Resources"
-msgstr "РеÑурÑи"
+msgstr "Под-РеÑурÑи"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Clear Inheritance"
-msgstr ""
+msgstr "ОчиÑти ÐаÑлеђивања"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Editable Children"
-msgstr ""
+msgstr "Измењиа Деца"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Load As Placeholder"
-msgstr ""
+msgstr "Учитај као МеÑточувца"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Open Documentation"
-msgstr "Отвори Godot онлајн документацију"
+msgstr "Отвори Документацију"
#: editor/scene_tree_dock.cpp
-msgid "Add Child Node"
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
msgstr ""
#: editor/scene_tree_dock.cpp
#, fuzzy
+msgid "Add Child Node"
+msgstr "Додај Дете Члан"
+
+#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Expand/Collapse All"
-msgstr "Умањи Ñве"
+msgstr "Откриј/Сакриј Све"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Change Type"
-msgstr ""
+msgstr "Промени Тип"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Reparent to New Node"
-msgstr "Ðаправи нов"
+msgstr "Промени Родитеља Ðовом Чвору"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Make Scene Root"
-msgstr "Сачувај Ñцену"
+msgstr "Ðаправи Корен Сцене"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Merge From Scene"
-msgstr ""
+msgstr "Припоји из Сцене"
#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Save Branch as Scene"
-msgstr ""
+msgstr "Упамти Грану као Сцену"
#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Copy Node Path"
-msgstr ""
+msgstr "Копирај Путању Чвора"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Delete (No Confirm)"
-msgstr ""
+msgstr "Обриши (Без Потврде)"
#: editor/scene_tree_dock.cpp
#, fuzzy
msgid "Add/Create a New Node."
-msgstr "Ðаправи нов"
+msgstr "Додај/Ðаправи Ðов Члан."
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid ""
"Instance a scene file as a Node. Creates an inherited scene if no root node "
"exists."
msgstr ""
+"ИнÑтанцирај ÑценÑке фајлова као Чвор. Креирај наÑлеђену Ñцену ако корени "
+"чвор поÑтоји."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
+msgstr "Припој нову или поÑтојећу Ñкрпту за одабрани чвор."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Detach the script from the selected node."
+msgstr "ОчиÑти Ñкрипту за одабрани чвор."
#: editor/scene_tree_dock.cpp
msgid "Remote"
msgstr "Удаљени уређај"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Local"
-msgstr ""
+msgstr "Локално"
#: editor/scene_tree_dock.cpp
+#, fuzzy
msgid "Clear Inheritance? (No Undo!)"
-msgstr ""
+msgstr "ОчиÑти ÐаÑледÑтва? (Ðема Ðазад!)"
#: editor/scene_tree_editor.cpp
#, fuzzy
msgid "Toggle Visible"
-msgstr "Прикажи Ñакривене датотеке"
+msgstr "Прикажи Сакривене"
#: editor/scene_tree_editor.cpp
#, fuzzy
msgid "Unlock Node"
-msgstr "OneShot чвор"
+msgstr "Откључај Чвор"
#: editor/scene_tree_editor.cpp
#, fuzzy
msgid "Button Group"
-msgstr "Додај у групу"
+msgstr "Група Дугмића"
#: editor/scene_tree_editor.cpp
#, fuzzy
msgid "(Connecting From)"
-msgstr "Повезивање не уÑпешно"
+msgstr "(Повезивање од)"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Node configuration warning:"
-msgstr ""
+msgstr "Подешавања чвора упозорење:"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid ""
"Node has %s connection(s) and %s group(s).\n"
"Click to show signals dock."
msgstr ""
+"Чвор има %s конекцију/је и %s групу(е).\n"
+"Кликни да прикажеш приÑтаниште Ñигнала."
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid ""
"Node has %s connection(s).\n"
"Click to show signals dock."
msgstr ""
+"Чвор има %s конекцију(е).\n"
+"Кликни да прикажеш приÑтаниште Ñигнала."
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid ""
"Node is in %s group(s).\n"
"Click to show groups dock."
msgstr ""
+"Чвор је у %s групи/ама.\n"
+"Кликни да прикажеш приÑтаниште групе."
#: editor/scene_tree_editor.cpp
#, fuzzy
msgid "Open Script:"
-msgstr "Покрени Ñкриптицу"
+msgstr "Отвори Скрипту:"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid ""
"Node is locked.\n"
"Click to unlock it."
msgstr ""
+"Чвор је закључан.\n"
+"Кликни да га откључаш."
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid ""
"Children are not selectable.\n"
"Click to make selectable."
msgstr ""
+"Деца ниÑу одабирљива.\n"
+"Кликни да их начиниш одабирљивим."
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Toggle Visibility"
-msgstr ""
+msgstr "Укљ/ИÑкљ ВидљивоÑÑ‚"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid ""
"AnimationPlayer is pinned.\n"
"Click to unpin."
msgstr ""
+"ÐнимациониПлејер је закачен.\n"
+"Кликни да га откачиш."
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Invalid node name, the following characters are not allowed:"
-msgstr ""
+msgstr "Ðеважеће име чвора, Ñледећи карактери ниÑу дозвољени:"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Rename Node"
-msgstr ""
+msgstr "Преименуј Чвор"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Scene Tree (Nodes):"
-msgstr ""
+msgstr "Стабло Сцене (Чворови):"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Node Configuration Warning!"
-msgstr ""
+msgstr "Чворови Конфигурација Упозорење!"
#: editor/scene_tree_editor.cpp
+#, fuzzy
msgid "Select a Node"
-msgstr ""
+msgstr "Одабери Чвор"
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Path is empty."
-msgstr "Мрежа је празна!"
+msgstr "Путања је празна."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Filename is empty."
-msgstr "Мрежа је празна!"
+msgstr "Име фајла је празно."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Path is not local."
-msgstr "Путања не води ка чвору!"
+msgstr "Путања није локална."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid base path."
-msgstr "Ðеважећи пут."
+msgstr "Ðеважећа оÑновна путања."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "A directory with the same name exists."
-msgstr "Датотека или директоријум Ñа овим именом већ поÑтоји."
+msgstr "Већ поÑтоји директоријум Ñа овим именом."
+
+#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Датотека не поÑтоји."
#: editor/script_create_dialog.cpp
#, fuzzy
@@ -11276,575 +12199,670 @@ msgid "Invalid extension."
msgstr "Мора Ñе кориÑтити важећа екÑтензија."
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Wrong extension chosen."
-msgstr ""
+msgstr "Одабарна погрешна екÑтензија."
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Error loading template '%s'"
-msgstr ""
+msgstr "Грешка при учитавању нацрта '%s'"
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Error - Could not create script in filesystem."
-msgstr ""
+msgstr "Грешка - ÐеуÑпело креирање Ñкрипте у фајл ÑиÑтему."
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Error loading script from %s"
-msgstr ""
+msgstr "Грешка при учитавању Ñкрипте из %s"
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Overrides"
-msgstr ""
+msgstr "ПрепиÑке"
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "N/A"
-msgstr ""
+msgstr "Ðије ДоÑтупно"
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Open Script / Choose Location"
-msgstr "Отвори уредник Ñкриптица"
+msgstr "Отвори Скрипту / Одабери Локацију"
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Open Script"
-msgstr "Покрени Ñкриптицу"
+msgstr "Отвори Скрипту"
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "File exists, it will be reused."
-msgstr ""
+msgstr "Фајл поÑтоји, биће поново употребљен."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
+msgid "Invalid path."
+msgstr "Ðеважећи пут."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid class name."
-msgstr "Ðеважеће име."
+msgstr "Ðеважеће име клаÑе."
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid inherited parent name or path."
-msgstr ""
+msgstr "Ðеважеће наÑлеђено име од родитеља или путање."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Script path/name is valid."
-msgstr "Ðнимационо дрво је важеће."
+msgstr "Важеће име/путања Ñкрипте."
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Allowed: a-z, A-Z, 0-9, _ and ."
-msgstr ""
+msgstr "Дозвољено: a-z, A-Z, 0-9, _ и ."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Built-in script (into scene file)."
-msgstr "Операције Ñа датотекама Ñцена."
+msgstr "Уграђена Ñкрипта (у фајл Ñцене)."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Will create a new script file."
-msgstr "Ðаправи нов"
+msgstr "Биће креиран нов фајл Ñкирпте."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Will load an existing script file."
-msgstr "Учитај поÑтојећи Ð±Ð°Ñ Ñ€Ð°Ñпоред."
+msgstr "Биће учитан поÑтојећи фајл Ñкрипте."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Script file already exists."
-msgstr "ÐутоматÑко учитавање '%s' већ поÑтоји!"
+msgstr "Фајл Ñкрипте већ поÑтоји."
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid ""
"Note: Built-in scripts have some limitations and can't be edited using an "
"external editor."
msgstr ""
+"Ðапомена: Уграђене Ñкрипте имају неке границе и не могу бити измењене "
+"кориÑтећи уредник."
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Class Name:"
-msgstr "КлаÑа:"
+msgstr "Име КлаÑе:"
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Template:"
-msgstr "Обриши шаблон"
+msgstr "Ðацрт:"
#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Built-in Script:"
-msgstr "Покрени Ñкриптицу"
+msgstr "Уграђена Скрипта:"
#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Attach Node Script"
-msgstr ""
+msgstr "Припој Чвор Скрипту"
#: editor/script_editor_debugger.cpp
msgid "Remote "
msgstr "Удаљени уређај "
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Bytes:"
-msgstr ""
+msgstr "Бајтови:"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Warning:"
-msgstr ""
+msgstr "Упозорење:"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Error:"
-msgstr "Грешка"
+msgstr "Грешка:"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "C++ Error"
-msgstr "Учитај грешке"
+msgstr "C++ Грешке"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "C++ Error:"
-msgstr "Учитај грешке"
+msgstr "C++ Грешке:"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "C++ Source"
-msgstr ""
-"\n"
-"Извор: "
+msgstr "C++ Извор"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Source:"
-msgstr ""
-"\n"
-"Извор: "
+msgstr "Извор:"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "C++ Source:"
-msgstr ""
-"\n"
-"Извор: "
+msgstr "C++ Извор:"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Stack Trace"
-msgstr ""
+msgstr "Потражна ÐаÑлага"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Errors"
-msgstr ""
+msgstr "Грешке"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Child process connected."
-msgstr "Веза прекинута"
+msgstr "Дете процез повезан."
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Copy Error"
-msgstr "Учитај грешке"
+msgstr "Копирај Грешку"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Video RAM"
-msgstr ""
+msgstr "Видео RAM"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Skip Breakpoints"
-msgstr "Обриши тачке"
+msgstr "ПреÑкочи тачке-прекида"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Inspect Previous Instance"
-msgstr ""
+msgstr "ИÑтражи Претходну ИнÑтанцу"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Inspect Next Instance"
-msgstr ""
+msgstr "ИÑтражи Ðаредну ИнÑтанцу"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Stack Frames"
-msgstr ""
+msgstr "ÐаÑлага Фрејмова"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Profiler"
-msgstr ""
+msgstr "ОÑматрач"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Network Profiler"
-msgstr "Извези пројекат"
+msgstr "Мрежни ОÑматрач"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Monitor"
-msgstr ""
+msgstr "Монитор"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Value"
-msgstr ""
+msgstr "ВредноÑÑ‚"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Monitors"
-msgstr ""
+msgstr "Монитори"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Pick one or more items from the list to display the graph."
-msgstr ""
+msgstr "Одабери један или више предмета Ñа лиÑте за приказ графикона."
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "List of Video Memory Usage by Resource:"
-msgstr ""
+msgstr "ЛиÑта Видео Утрошка Меморије од Ñтране РеÑурÑа:"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Total:"
-msgstr ""
+msgstr "Укупно:"
#: editor/script_editor_debugger.cpp
#, fuzzy
msgid "Export list to a CSV file"
-msgstr "Извези пројекат"
+msgstr "Извези лиÑту у CSV фајл"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Resource Path"
-msgstr ""
+msgstr "Путања РеÑурÑа"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Type"
-msgstr ""
+msgstr "Ð’Ñ€Ñта"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Format"
-msgstr ""
+msgstr "Формат"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Usage"
-msgstr ""
+msgstr "ИÑкориштеноÑÑ‚"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Misc"
-msgstr ""
+msgstr "ÐеÑврÑтано"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Clicked Control:"
-msgstr ""
+msgstr "Контрола Кликног:"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Clicked Control Type:"
-msgstr ""
+msgstr "Ð’Ñ€Ñта Контроле Кликнутог:"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Live Edit Root:"
-msgstr ""
+msgstr "Измена Корена Уживо:"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Set From Tree"
-msgstr ""
+msgstr "ПоÑтави Ñа Стабла"
#: editor/script_editor_debugger.cpp
+#, fuzzy
msgid "Export measures as CSV"
-msgstr ""
+msgstr "Извези мере као CSV"
#: editor/settings_config_dialog.cpp
#, fuzzy
msgid "Erase Shortcut"
-msgstr "Излазна транзиција"
+msgstr "Обриши Пречицу"
#: editor/settings_config_dialog.cpp
+#, fuzzy
msgid "Restore Shortcut"
-msgstr ""
+msgstr "Поврати Пречицу"
#: editor/settings_config_dialog.cpp
#, fuzzy
msgid "Change Shortcut"
-msgstr "Промени Ñидра"
+msgstr "Измени Пречицу"
#: editor/settings_config_dialog.cpp
msgid "Editor Settings"
msgstr "ПоÑтавке уредника"
#: editor/settings_config_dialog.cpp
+#, fuzzy
msgid "Shortcuts"
-msgstr ""
+msgstr "Пречице"
#: editor/settings_config_dialog.cpp
+#, fuzzy
msgid "Binding"
-msgstr ""
+msgstr "Спојеви"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Light Radius"
-msgstr ""
+msgstr "Промени ОпÑег Светла"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change AudioStreamPlayer3D Emission Angle"
-msgstr ""
+msgstr "Промени AudioStreamPlayer3D Угао Емитовања"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Camera FOV"
-msgstr ""
+msgstr "Промени FOV Камере"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Camera Size"
-msgstr ""
+msgstr "Проемени Велићину Камере"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Notifier AABB"
-msgstr ""
+msgstr "Промени AABB Обавештајца"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Particles AABB"
-msgstr ""
+msgstr "Промени AABB ЧеÑтица"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Probe Extents"
-msgstr ""
+msgstr "Промени ÐаÑтавке Сонде"
#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
+#, fuzzy
msgid "Change Sphere Shape Radius"
-msgstr ""
+msgstr "Промени ОпÑег ЛоптаÑтог Облика"
#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
+#, fuzzy
msgid "Change Box Shape Extents"
-msgstr ""
+msgstr "Промени ÐаÑтавке Кутија Облика"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Capsule Shape Radius"
-msgstr ""
+msgstr "Промени ОпÑег КапÑула Облика"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Capsule Shape Height"
-msgstr ""
+msgstr "Промени ВиÑину КапÑула Облика"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Cylinder Shape Radius"
-msgstr ""
+msgstr "Промени ОпÑег Цилиндар Облика"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Cylinder Shape Height"
-msgstr ""
+msgstr "Промени ВиÑину Цилиндар Облика"
#: editor/spatial_editor_gizmos.cpp
+#, fuzzy
msgid "Change Ray Shape Length"
-msgstr ""
+msgstr "Промени Дужину Зрак Облика"
#: modules/csg/csg_gizmos.cpp
#, fuzzy
msgid "Change Cylinder Radius"
-msgstr "Промени време мешања"
+msgstr "Промени ОпÑег Цилиндра"
#: modules/csg/csg_gizmos.cpp
#, fuzzy
msgid "Change Cylinder Height"
-msgstr "Промени време мешања"
+msgstr "Промени ВиÑину Цилиндра"
#: modules/csg/csg_gizmos.cpp
#, fuzzy
msgid "Change Torus Inner Radius"
-msgstr "Промени Ñидра и ивице"
+msgstr "Промени Унутрашњи ОпÑег ТоруÑа"
#: modules/csg/csg_gizmos.cpp
+#, fuzzy
msgid "Change Torus Outer Radius"
-msgstr ""
+msgstr "Промени Спољашњи ОпÑег ТоруÑа"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Select the dynamic library for this entry"
-msgstr ""
+msgstr "Одабери динамичку библиотеку за овај уноÑ"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Select dependencies of the library for this entry"
-msgstr ""
+msgstr "Одабери завиÑноÑти од библиотеке за овај уноÑ"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
#, fuzzy
msgid "Remove current entry"
-msgstr "Обриши тачку криве"
+msgstr "Обриши тренутни уноÑ"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Double click to create a new entry"
-msgstr ""
+msgstr "Дупли клик да креираш нов уноÑ"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Platform:"
-msgstr ""
+msgstr "Платформа:"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Platform"
-msgstr ""
+msgstr "Платформа"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Dynamic Library"
-msgstr ""
+msgstr "Динамичка Библиотека"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "Add an architecture entry"
-msgstr ""
+msgstr "Додај архитектуру уноÑ"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
+#, fuzzy
msgid "GDNativeLibrary"
-msgstr ""
+msgstr "GDNativeLibrary"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
+#, fuzzy
msgid "Enabled GDNative Singleton"
-msgstr ""
+msgstr "Омогућен GDNative Singleton"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
#, fuzzy
msgid "Disabled GDNative Singleton"
-msgstr "ИÑкључи индикатор ажурирања"
+msgstr "Онемогућен GDNative Singleton"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
+#, fuzzy
msgid "Library"
-msgstr ""
+msgstr "Библиотека"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
+#, fuzzy
msgid "Libraries: "
-msgstr ""
+msgstr "Библиотеке:"
#: modules/gdnative/register_types.cpp
+#, fuzzy
msgid "GDNative"
-msgstr ""
+msgstr "GDNative"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Step argument is zero!"
-msgstr ""
+msgstr "Корак аргуменат је нула!"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Not a script with an instance"
-msgstr ""
+msgstr "Ðије Ñкрипта Ñа инÑтанцом"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Not based on a script"
-msgstr ""
+msgstr "Ðије базирано на Ñкрипти"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Not based on a resource file"
-msgstr ""
+msgstr "Ðије базирано на реÑÑƒÑ€Ñ Ñ„Ð°Ñ˜Ð»Ñƒ"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Invalid instance dictionary format (missing @path)"
-msgstr ""
+msgstr "Ðеважећа инÑтанца речник формата (недоÑтаје @путања)"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Invalid instance dictionary format (can't load script at @path)"
msgstr ""
+"Ðеважећа инÑтанца речник формата (неуÑпешно учитавање Ñкрипте код @путање)"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Invalid instance dictionary format (invalid script at @path)"
-msgstr ""
+msgstr "Ðеважећа инÑтанца речник формата (неважећа Ñкрипта на @путања)"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Invalid instance dictionary (invalid subclasses)"
-msgstr ""
+msgstr "Ðеважећа инÑтанца речника (неважеће клаÑе)"
#: modules/gdscript/gdscript_functions.cpp
+#, fuzzy
msgid "Object can't provide a length."
-msgstr ""
+msgstr "Објекат не може Ñнабдети дужину."
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "Next Plane"
-msgstr "Следећи таб"
+msgstr "Следећа Раван"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "Previous Plane"
-msgstr "Претходни таб"
+msgstr "Претходна Раван"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Plane:"
-msgstr ""
+msgstr "Раван:"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Next Floor"
-msgstr ""
+msgstr "Следећи Спрат"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Previous Floor"
msgstr "Претодни Ñпрат"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Floor:"
-msgstr ""
+msgstr "Спрат:"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "GridMap Delete Selection"
-msgstr ""
+msgstr "МапаМреже Обриши Одабир"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "GridMap Fill Selection"
-msgstr "Све одабрано"
+msgstr "МапаМреже ИÑпуни Одабрано"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "GridMap Paste Selection"
-msgstr "Све одабрано"
+msgstr "МапаМреже налепи Одабрано"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "GridMap Paint"
-msgstr "Мапа мреже"
+msgstr "МапаМреже Боји"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Grid Map"
msgstr "Мапа мреже"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Snap View"
-msgstr ""
+msgstr "Залепљив Поглед"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Clip Disabled"
-msgstr ""
+msgstr "Клип Онемогућен"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Clip Above"
-msgstr ""
+msgstr "Клип Изнад"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Clip Below"
-msgstr ""
+msgstr "Клип ИÑпод"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Edit X Axis"
-msgstr ""
+msgstr "Измени X ОÑу"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Edit Y Axis"
-msgstr ""
+msgstr "Измени Y ОÑу"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Edit Z Axis"
-msgstr ""
+msgstr "Измени Z ОÑу"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Rotate X"
-msgstr ""
+msgstr "КурÑор Ротација X"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Rotate Y"
-msgstr ""
+msgstr "КурÑор Ротација Y"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Rotate Z"
-msgstr ""
+msgstr "КурÑор Ротација Z"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Back Rotate X"
-msgstr ""
+msgstr "КурÑор Ротација Уназад X"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Back Rotate Y"
-msgstr ""
+msgstr "КурÑор Ротација Уназад Y"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Back Rotate Z"
-msgstr ""
+msgstr "КурÑор Ротација Уназад Z"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Cursor Clear Rotation"
-msgstr ""
+msgstr "КурÑор Обриши Ротацију"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "Paste Selects"
-msgstr "Обриши одабрано"
+msgstr "Ðалепи Одабрано"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clear Selection"
@@ -11853,36 +12871,42 @@ msgstr "Обриши избор"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "Fill Selection"
-msgstr "Све одабрано"
+msgstr "ИÑпуни одабрано"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "GridMap Settings"
-msgstr ""
+msgstr "МапаМреже Подешавања"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Pick Distance:"
-msgstr ""
+msgstr "Одабери ОдÑтојање:"
#: modules/gridmap/grid_map_editor_plugin.cpp
#, fuzzy
msgid "Filter meshes"
-msgstr "ПоÑтавке објекта."
+msgstr "Пробери мреже"
#: modules/gridmap/grid_map_editor_plugin.cpp
+#, fuzzy
msgid "Give a MeshLibrary resource to this GridMap to use its meshes."
-msgstr ""
+msgstr "Дај БиблиотециМрежа реÑÑƒÑ€Ñ Ð¾Ð²Ðµ МапеМреже да кориÑти њене мреже."
#: modules/mono/csharp_script.cpp
+#, fuzzy
msgid "Class name can't be a reserved keyword"
-msgstr ""
+msgstr "Има КлаÑе не може бити резервиÑана кључна реч"
#: modules/mono/mono_gd/gd_mono_utils.cpp
+#, fuzzy
msgid "End of inner exception stack trace"
-msgstr ""
+msgstr "Крај Унутрашњег израза потражне наÑлаге"
#: modules/recast/navigation_mesh_editor_plugin.cpp
+#, fuzzy
msgid "Bake NavMesh"
-msgstr ""
+msgstr "ИÑпеци ÐавМрежу"
#: modules/recast/navigation_mesh_editor_plugin.cpp
msgid "Clear the navigation mesh."
@@ -11941,83 +12965,99 @@ msgid "Done!"
msgstr "Готово!"
#: modules/visual_script/visual_script.cpp
+#, fuzzy
msgid ""
"A node yielded without working memory, please read the docs on how to yield "
"properly!"
msgstr ""
+"Чвор попуÑтио без радне меморије, молимо прочитајте докуметацију како "
+"попуÑтити правило!"
#: modules/visual_script/visual_script.cpp
+#, fuzzy
msgid ""
"Node yielded, but did not return a function state in the first working "
"memory."
-msgstr ""
+msgstr "Чвор попуÑтио, али није вратио Ñтање функције у првој радној меморији."
#: modules/visual_script/visual_script.cpp
+#, fuzzy
msgid ""
"Return value must be assigned to first element of node working memory! Fix "
"your node please."
msgstr ""
+"Враћена вредноÑÑ‚ мора бити додељена првом елементу члана радне меморије! "
+"Молимо поправи чвор."
#: modules/visual_script/visual_script.cpp
+#, fuzzy
msgid "Node returned an invalid sequence output: "
-msgstr ""
+msgstr "Члан вратио неважећи излаз Ñеквенце:"
#: modules/visual_script/visual_script.cpp
+#, fuzzy
msgid "Found sequence bit but not the node in the stack, report bug!"
-msgstr ""
+msgstr "Пронађена Ñеквенца битова али не члан наÑлаге, пријави грешку!"
#: modules/visual_script/visual_script.cpp
+#, fuzzy
msgid "Stack overflow with stack depth: "
-msgstr ""
+msgstr "Преоптерећење наÑлаге Ñа дубином наÑлаге:"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Change Signal Arguments"
-msgstr ""
+msgstr "Измени Ðргументе Сигнала"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Change Argument Type"
-msgstr ""
+msgstr "Измени Ð’Ñ€Ñту Ðргумента"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Change Argument name"
-msgstr ""
+msgstr "Измени име Ðргумента"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Set Variable Default Value"
-msgstr ""
+msgstr "ПоÑтави Уобичајену ВредноÑÑ‚ Променљиве"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Set Variable Type"
-msgstr ""
+msgstr "ПоÑтави Ð’Ñ€Ñту Променљиве"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Add Input Port"
-msgstr "Додај улаз"
+msgstr "Додај улазни порт"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Add Output Port"
-msgstr "Додај улаз"
+msgstr "Додај излазни порт"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Override an existing built-in function."
-msgstr "Ðеважеће име. Име је резервиÑано за поÑтојећи уграђени тип."
+msgstr "Препиши поÑтојећу уграђену функцију."
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Create a new function."
-msgstr "Ðаправи нов"
+msgstr "Ðаправи нову функцију."
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Variables:"
-msgstr ""
+msgstr "Променљиве:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Create a new variable."
-msgstr "Ðаправи нов"
+msgstr "Ðаправи нову променљиву."
#: modules/visual_script/visual_script_editor.cpp
msgid "Signals:"
@@ -12026,82 +13066,97 @@ msgstr "Сигнали:"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Create a new signal."
-msgstr "Ðаправи нови полигон од почетка."
+msgstr "Ðаправи нови Ñигнал."
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Name is not a valid identifier:"
-msgstr ""
+msgstr "Име није важећи идентификатор:"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Name already in use by another func/var/signal:"
-msgstr ""
+msgstr "Име је већ у употреби у функ/пром/Ñигналу:"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Rename Function"
-msgstr ""
+msgstr "Преименуј Функцију"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Rename Variable"
-msgstr ""
+msgstr "Преименуј Променљиву"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Rename Signal"
-msgstr ""
+msgstr "Преименуј Сигнал"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Add Function"
-msgstr ""
+msgstr "Додај Функцију"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Delete input port"
-msgstr "Обриши тачку"
+msgstr "Обриши улазни порт"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Add Variable"
-msgstr ""
+msgstr "Додај Промељиву"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Add Signal"
-msgstr ""
+msgstr "Додај Сигнал"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Remove Input Port"
-msgstr "Обриши тачку"
+msgstr "Обриши Улазни Порт"
#: modules/visual_script/visual_script_editor.cpp
#, fuzzy
msgid "Remove Output Port"
-msgstr "Обриши тачку"
+msgstr "Обриши Излазни Порт"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Change Expression"
-msgstr ""
+msgstr "Измени Израз"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Remove VisualScript Nodes"
-msgstr ""
+msgstr "Уклони ВизуелнаСкрипта Чланове"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Duplicate VisualScript Nodes"
-msgstr ""
+msgstr "УдвоÑтручи ВизуелнаСкрипта Чланове"
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Hold %s to drop a Getter. Hold Shift to drop a generic signature."
-msgstr ""
+msgstr "Држи %s да иÑпуÑтиш Узимача. Држи Shift да иÑпуÑтиш општи потпиÑ."
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."
-msgstr ""
+msgstr "Држи Ctrl да иÑпуÑтиш Узимача. Држи Shift да иÑпуÑтиш општи потпиÑ."
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Hold %s to drop a simple reference to the node."
-msgstr ""
+msgstr "Држи %s да иÑпуÑтиш једноÑтавну референцу ка члану."
#: modules/visual_script/visual_script_editor.cpp
+#, fuzzy
msgid "Hold Ctrl to drop a simple reference to the node."
-msgstr ""
+msgstr "Држи Ctrl да иÑпуÑтиш једноÑтавну референцу ка члану"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a Variable Setter."
@@ -12334,629 +13389,874 @@ msgid "VariableGet not found in script: "
msgstr ""
#: modules/visual_script/visual_script_nodes.cpp
+#, fuzzy
msgid "VariableSet not found in script: "
-msgstr ""
+msgstr "СкупПроменљивих није нађен у Ñкрипти:"
#: modules/visual_script/visual_script_nodes.cpp
+#, fuzzy
msgid "Custom node has no _step() method, can't process graph."
-msgstr ""
+msgstr "Произвољни чвор нема _step() методу, граф не моће бити обрађен."
#: modules/visual_script/visual_script_nodes.cpp
+#, fuzzy
msgid ""
"Invalid return value from _step(), must be integer (seq out), or string "
"(error)."
msgstr ""
+"Ðеважећа повратна вредноÑÑ‚ од _step(), мора бити интиџер (seq out), или "
+"Ñтринг (грешка)."
#: modules/visual_script/visual_script_property_selector.cpp
#, fuzzy
msgid "Search VisualScript"
-msgstr "Потражи помоћ"
+msgstr "Потражи VisualScript"
#: modules/visual_script/visual_script_property_selector.cpp
+#, fuzzy
msgid "Get %s"
-msgstr ""
+msgstr "Повуци %s"
#: modules/visual_script/visual_script_property_selector.cpp
+#, fuzzy
msgid "Set %s"
-msgstr ""
+msgstr "ПоÑтави %s"
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Package name is missing."
-msgstr ""
+msgstr "ÐедоÑтаје име паковања."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Package segments must be of non-zero length."
-msgstr ""
+msgstr "Одломци паковања не могу бити нулте дужине."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "The character '%s' is not allowed in Android application package names."
-msgstr ""
+msgstr "Карактер '%s' није дозвољен у именима паковања Android апликације."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "A digit cannot be the first character in a package segment."
-msgstr ""
+msgstr "Цифра не може бити први карактер у одломку паковања."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "The character '%s' cannot be the first character in a package segment."
-msgstr ""
+msgstr "Карактер '%s' не може бити први карактер у одломку паковања."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "The package must have at least one '.' separator."
-msgstr ""
+msgstr "Паковање мора имати бар један '.' раздвојник."
#: platform/android/export/export.cpp
msgid "Select device from the list"
msgstr "Одабери уређај Ñа лиÑте"
#: platform/android/export/export.cpp
+#, fuzzy
msgid "ADB executable not configured in the Editor Settings."
-msgstr ""
+msgstr "ADB извршна датотека није подешена у Подешавањима Уредника."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "OpenJDK jarsigner not configured in the Editor Settings."
-msgstr ""
+msgstr "OpenJDK jar потпиÑник није подешен у Подешавањима Уредника."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
+"Сладиште кључева Разгрешеника није подешено у Подешавањима Уредника ни у "
+"поÑтавкама."
+
+#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Сладиште кључева Разгрешеника није подешено у Подешавањима Уредника ни у "
+"поÑтавкама."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
+"Произвољна изградња захтева важећу путању до Android SDK у Подешавањима "
+"Уредника."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Invalid Android SDK path for custom build in Editor Settings."
msgstr ""
+"Ðеважећа Android SDK путања за произвољну изградњу у Подешавањима Уредника."
#: platform/android/export/export.cpp
+#, fuzzy
msgid ""
"Android build template not installed in the project. Install it from the "
"Project menu."
msgstr ""
+"Android нацрт изградње није инÑталиран у пројекат. ИнÑталирај га из Пројекат "
+"менија."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Invalid public key for APK expansion."
-msgstr ""
+msgstr "Ðеважећи јавни кључ за ÐПК проширење."
#: platform/android/export/export.cpp
#, fuzzy
msgid "Invalid package name:"
-msgstr "Ðеважеће име."
+msgstr "Ðеважеће име паковања:"
+
+#: platform/android/export/export.cpp
+msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
#: platform/android/export/export.cpp
+#, fuzzy
msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
+"Покушај изградње за произвољни нацрт изградње, али не поÑтоји инфо о "
+"верзији. Молимо реинÑталирај из \"Пројекат\" менија."
#: platform/android/export/export.cpp
+#, fuzzy
msgid ""
"Android build version mismatch:\n"
" Template installed: %s\n"
" Godot Version: %s\n"
"Please reinstall Android build template from 'Project' menu."
msgstr ""
+"Верзија Android изградње Ñе не подудара:\n"
+" Ðацрт инÑталиран: %s\n"
+" Годот Верзија: %s\n"
+"Молимо реинÑталирајте Android нацрт изградње из \"Пројекат\" менија."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "Building Android Project (gradle)"
-msgstr ""
+msgstr "Изградња Android Пројекта (gradle)"
#: platform/android/export/export.cpp
+#, fuzzy
msgid ""
"Building of Android project failed, check output for the error.\n"
"Alternatively visit docs.godotengine.org for Android build documentation."
msgstr ""
+"Изградња Android пројекта неуÑпешна, провери излаз за грешке.\n"
+"Ðлтернативно поÑети docs.godotengine.org за Android документацију изградње."
#: platform/android/export/export.cpp
+#, fuzzy
msgid "No build apk generated at: "
-msgstr ""
+msgstr "Ðема градње apk произведеног код:"
#: platform/iphone/export/export.cpp
+#, fuzzy
msgid "Identifier is missing."
-msgstr ""
+msgstr "Идентификатор недоÑтаје."
#: platform/iphone/export/export.cpp
+#, fuzzy
msgid "The character '%s' is not allowed in Identifier."
-msgstr ""
+msgstr "Карактер '%s' није дозвољен као идентификатор."
#: platform/iphone/export/export.cpp
+#, fuzzy
msgid "App Store Team ID not specified - cannot configure the project."
msgstr ""
+"ТимÑки ИД Продавнице Ðпликација није наведен - неуÑпешно подешавање пројекта."
#: platform/iphone/export/export.cpp
#, fuzzy
msgid "Invalid Identifier:"
-msgstr "Ðеважећа величина фонта."
+msgstr "Ðеважећи идентификатор:"
#: platform/iphone/export/export.cpp
+#, fuzzy
msgid "Required icon is not specified in the preset."
-msgstr ""
+msgstr "Ðеопходна иконица није наведена у подешавању."
#: platform/javascript/export/export.cpp
+#, fuzzy
msgid "Stop HTTP Server"
-msgstr ""
+msgstr "ЗауÑтави HTTP Сервер"
#: platform/javascript/export/export.cpp
+#, fuzzy
msgid "Run in Browser"
-msgstr ""
+msgstr "Покрени у Претраживачу"
#: platform/javascript/export/export.cpp
+#, fuzzy
msgid "Run exported HTML in the system's default browser."
-msgstr ""
+msgstr "Покрени извезени HTML у уобичајеном претраживачу ÑиÑтема."
#: platform/javascript/export/export.cpp
#, fuzzy
msgid "Could not write file:"
-msgstr "ÐеуÑпех при тражењу плочице:"
+msgstr "ÐеуÑпело упиÑивање фајла:"
#: platform/javascript/export/export.cpp
#, fuzzy
msgid "Could not open template for export:"
-msgstr "ÐеуÑпех при прављењу директоријума."
+msgstr "ÐеуÑпешно отварање нацрта за извоз:"
#: platform/javascript/export/export.cpp
#, fuzzy
msgid "Invalid export template:"
-msgstr "Ðеважећи извозни шаблон:\n"
+msgstr "Ðеважећи извозни нацрт:"
#: platform/javascript/export/export.cpp
#, fuzzy
msgid "Could not read custom HTML shell:"
-msgstr "ÐеуÑпех при учитавању датотеке Ñа Ñличицом учитавања:\n"
+msgstr "ÐеуÑпешно читаље произвољне HTML шкољке:"
#: platform/javascript/export/export.cpp
#, fuzzy
msgid "Could not read boot splash image file:"
-msgstr "ÐеуÑпех при учитавању датотеке Ñа Ñличицом учитавања:\n"
+msgstr "ÐеуÑпешно читаље фајла уводне Ñлике:"
#: platform/javascript/export/export.cpp
#, fuzzy
msgid "Using default boot splash image."
-msgstr "ÐеуÑпех при учитавању датотеке Ñа Ñличицом учитавања:\n"
+msgstr "Коришћење уобичајне уводне Ñлике."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid package short name."
-msgstr "Ðеважеће име."
+msgstr "Ðеважеће кратко име паковања."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid package unique name."
-msgstr "Ðеважеће име."
+msgstr "Ðеважеће јединÑтвено име паковања."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid package publisher display name."
-msgstr "Ðеважеће име."
+msgstr "Ðеважеће приказно име издавача паковања."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid product GUID."
-msgstr "Ðеважеће име."
+msgstr "Ðеважећи GUID продукт."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid publisher GUID."
-msgstr "Ðеважећи пут."
+msgstr "Ðеважећи GUID итдавача."
#: platform/uwp/export/export.cpp
#, fuzzy
msgid "Invalid background color."
-msgstr "Ðеважеће име."
+msgstr "Ðеважећа боја позадине."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid Store Logo image dimensions (should be 50x50)."
-msgstr ""
+msgstr "Ðеважеће димензије Логотипа Продавнице (треба да буде 50*50)."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid square 44x44 logo image dimensions (should be 44x44)."
-msgstr ""
+msgstr "Ðеважеће димензије Ñлике за квадрат логотип (треба да буде 44*44)."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid square 71x71 logo image dimensions (should be 71x71)."
-msgstr ""
+msgstr "Ðеважеће димензије Ñлике за квадрат логотип (треба да буде 71*71)."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid square 150x150 logo image dimensions (should be 150x150)."
-msgstr ""
+msgstr "Ðеважеће димензије Ñлике за квадрат логотип (треба да буде 150*150)."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid square 310x310 logo image dimensions (should be 310x310)."
-msgstr ""
+msgstr "Ðеважеће димензије Ñлике за квадрат логотип (треба да буде 310*310)."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid wide 310x150 logo image dimensions (should be 310x150)."
-msgstr ""
+msgstr "Ðеважеће димензије Ñлике за широки логотип (треба да буде 310*150)."
#: platform/uwp/export/export.cpp
+#, fuzzy
msgid "Invalid splash screen image dimensions (should be 620x300)."
-msgstr ""
+msgstr "Ðеважеће димензије Ñлике за уводни екран (треба да буде 620*300)."
#: scene/2d/animated_sprite.cpp
+#, fuzzy
msgid ""
"A SpriteFrames resource must be created or set in the \"Frames\" property in "
"order for AnimatedSprite to display frames."
msgstr ""
+"СпрајтРамови реÑÑƒÑ€Ñ Ð¼Ð¾Ñ€Ð° бити креиран или поÑтавњен у \"Рамови\" оÑобини да "
+"би ÐнимациониСпрајт приказао фрејмове."
#: scene/2d/canvas_modulate.cpp
+#, fuzzy
msgid ""
"Only one visible CanvasModulate is allowed per scene (or set of instanced "
"scenes). The first created one will work, while the rest will be ignored."
msgstr ""
+"Само један видљив CanvasModulate је дозвољен по Ñцени (или групи "
+"инÑтанцираних Ñцена). Први креиран ће радити, док ће оÑтали бити занемарени."
#: scene/2d/collision_object_2d.cpp
+#, fuzzy
msgid ""
"This node has no shape, so it can't collide or interact with other objects.\n"
"Consider adding a CollisionShape2D or CollisionPolygon2D as a child to "
"define its shape."
msgstr ""
+"Овај члан нема облик, тако да Ñе не моће Ñударати Ñа оÑталим објектима.\n"
+"Размотри додавање СударнихОблика2Д или СударнихМногоуглова2Д као деце да "
+"дефинишеш његов облик."
#: scene/2d/collision_polygon_2d.cpp
+#, fuzzy
msgid ""
"CollisionPolygon2D only serves to provide a collision shape to a "
"CollisionObject2D derived node. Please only use it as a child of Area2D, "
"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
msgstr ""
+"СударниМногоугао2Д Ñамо Ñлужи да обезбеди Ñударни облик изведеном члану од "
+"СударномОбјекту2Д. Молимо кориÑти га Ñамо као дете од ОблаÑти2Д, "
+"ÐепомичногТела2Д, ЧврÑтогТела2Д, КинематичкогТела2Д итд. да им даш облик."
#: scene/2d/collision_polygon_2d.cpp
+#, fuzzy
msgid "An empty CollisionPolygon2D has no effect on collision."
-msgstr ""
+msgstr "Ðепријатењ СударниМногоугао2Д нема утицаја на Ñудар."
#: scene/2d/collision_shape_2d.cpp
+#, fuzzy
msgid ""
"CollisionShape2D only serves to provide a collision shape to a "
"CollisionObject2D derived node. Please only use it as a child of Area2D, "
"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
msgstr ""
+"СударниОблик2Д Ñамо Ñлужи да обезбеди Ñударни облик за изведени чвор од "
+"СударниОбјекат2Д. Молимо Ñамо га кориÑти као дете ОблаÑти2Д, "
+"ÐепомичногТела2Д, ЧврÑтогТела2Д, КинематичкогТела2Д, итд. да им даш облик."
#: scene/2d/collision_shape_2d.cpp
+#, fuzzy
msgid ""
"A shape must be provided for CollisionShape2D to function. Please create a "
"shape resource for it!"
msgstr ""
+"Облик мора бити Ñнабдевен за СударниОблик2Д да би радио. Молимо креирај "
+"облик реÑÑƒÑ€Ñ Ð·Ð° њега!"
#: scene/2d/cpu_particles_2d.cpp
+#, fuzzy
msgid ""
"CPUParticles2D animation requires the usage of a CanvasItemMaterial with "
"\"Particles Animation\" enabled."
msgstr ""
+"ПроцеÑорЧеÑтице2Д анимација захтева коришћење ПлатноПредметМатеријала Ñа "
+"омогућеном \"Ðнимациом ЧеÑтица\"."
#: scene/2d/light_2d.cpp
+#, fuzzy
msgid ""
"A texture with the shape of the light must be supplied to the \"Texture\" "
"property."
msgstr ""
+"ТекÑтура Ñа обликом Ñветла мора бити Ñнабдевена у \"ТекÑтура\" оÑобини."
#: scene/2d/light_occluder_2d.cpp
+#, fuzzy
msgid ""
"An occluder polygon must be set (or drawn) for this occluder to take effect."
msgstr ""
+"Многоугао Затамљивач мора бити поÑтављен (или иÑцртан) да би затамљивач имао "
+"утицаја."
#: scene/2d/light_occluder_2d.cpp
+#, fuzzy
msgid "The occluder polygon for this occluder is empty. Please draw a polygon."
msgstr ""
+"Многоугао затамљивач за овај затамљивач је празан. Молимо нацртај моногоугао."
#: scene/2d/navigation_polygon.cpp
+#, fuzzy
msgid ""
"A NavigationPolygon resource must be set or created for this node to work. "
"Please set a property or draw a polygon."
msgstr ""
+"ÐавигациониПолигон реÑÑƒÑ€Ñ Ð¼Ð¾Ñ€Ð° бити поÑтављен или креиран да би овај чвор "
+"радио. Молимо поÑтави оÑобину или нацртај многоугао."
#: scene/2d/navigation_polygon.cpp
+#, fuzzy
msgid ""
"NavigationPolygonInstance must be a child or grandchild to a Navigation2D "
"node. It only provides navigation data."
msgstr ""
+"ИнÑтанцаÐавигационогМногоугла мора бити дете или прадете Ðавигација2Д чвору. "
+"Само обезбеђује навигационе податке."
#: scene/2d/parallax_layer.cpp
+#, fuzzy
msgid ""
"ParallaxLayer node only works when set as child of a ParallaxBackground node."
-msgstr ""
+msgstr "ПаралакÑСлој чвор Ñамо ради кад је дете од ПаралакÑПозадина чвора."
#: scene/2d/particles_2d.cpp
+#, fuzzy
msgid ""
"GPU-based particles are not supported by the GLES2 video driver.\n"
"Use the CPUParticles2D node instead. You can use the \"Convert to "
"CPUParticles\" option for this purpose."
msgstr ""
+"ЧеÑтице базиране на графичкој ниÑу подржане од Ñтране GLES2 видео "
+"управљача.\n"
+"УмеÑто тога кориÑти ПроцеÑорЧеÑтице2Д чвор."
#: scene/2d/particles_2d.cpp scene/3d/particles.cpp
+#, fuzzy
msgid ""
"A material to process the particles is not assigned, so no behavior is "
"imprinted."
msgstr ""
+"Материјал за извршавање чеÑтица није додељен. па ни једно понашање није "
+"утиÑнуто."
#: scene/2d/particles_2d.cpp
+#, fuzzy
msgid ""
"Particles2D animation requires the usage of a CanvasItemMaterial with "
"\"Particles Animation\" enabled."
msgstr ""
+"ЧеÑтице2Д анимација захтева корићење ПозориштеПредметМатеријала Ñа "
+"омогућеном \"Ðнимација ЧеÑтица\"."
#: scene/2d/path_2d.cpp
+#, fuzzy
msgid "PathFollow2D only works when set as a child of a Path2D node."
-msgstr ""
+msgstr "ПутањаПраћења2Д Ñамо ради кад је дете Путање2Д чвора."
#: scene/2d/physics_body_2d.cpp
+#, fuzzy
msgid ""
"Size changes to RigidBody2D (in character or rigid modes) will be overridden "
"by the physics engine when running.\n"
"Change the size in children collision shapes instead."
msgstr ""
+"Промена величине ЧврÑтогТела2Д (у карактеру или чврÑтом режиму) биће "
+"препиÑана од Ñтране физичког мотора током рада.\n"
+"УмеÑто тога промени величину у детету Ñударног облика."
#: scene/2d/remote_transform_2d.cpp
+#, fuzzy
msgid "Path property must point to a valid Node2D node to work."
-msgstr ""
+msgstr "Путања оÑобина мора показивати ка важећем Чвор2Д чвор да би радила."
#: scene/2d/skeleton_2d.cpp
+#, fuzzy
msgid "This Bone2D chain should end at a Skeleton2D node."
-msgstr ""
+msgstr "Овај КоÑка2Д ланац треба да Ñе заврши код КоÑтур2Д чвора."
#: scene/2d/skeleton_2d.cpp
+#, fuzzy
msgid "A Bone2D only works with a Skeleton2D or another Bone2D as parent node."
msgstr ""
+"КоÑка2Д ради Ñамо Ñа КоÑтуром2Д или другом КоÑка2Д као родитељÑким чвором."
#: scene/2d/skeleton_2d.cpp
+#, fuzzy
msgid ""
"This bone lacks a proper REST pose. Go to the Skeleton2D node and set one."
msgstr ""
+"Овај коÑки недоÑтаје одговарајућа Одмор поза. Иди у КоÑтур2Д чвор и поÑтави "
+"је."
#: scene/2d/tile_map.cpp
+#, fuzzy
msgid ""
"TileMap with Use Parent on needs a parent CollisionObject2D to give shapes "
"to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, "
"KinematicBody2D, etc. to give them a shape."
msgstr ""
+"МапаПлочица Ñа КориÑти Родитеља укљученим треба да има као родитеља "
+"СударниОблик2Д да му да облик. Молимо кориÑти је као дете од ОблаÑÑ‚2Д, "
+"ЧврÑтоТело2Д, КинематикоТело2Д, итд. да им даш облик."
#: scene/2d/visibility_notifier_2d.cpp
+#, fuzzy
msgid ""
"VisibilityEnabler2D works best when used with the edited scene root directly "
"as parent."
msgstr ""
+"ВидљивоÑтОмогућивач2Д ради најбоље кад Ñе кориÑти Ñа измењеним кореном Ñцене "
+"као родитељем."
#: scene/3d/arvr_nodes.cpp
+#, fuzzy
msgid "ARVRCamera must have an ARVROrigin node as its parent."
-msgstr ""
+msgstr "ARVRCamera мора имати ARVROrigin члан као родитеља."
#: scene/3d/arvr_nodes.cpp
+#, fuzzy
msgid "ARVRController must have an ARVROrigin node as its parent."
-msgstr ""
+msgstr "ARVRController мора имати ARVROrigin члан као родитеља."
#: scene/3d/arvr_nodes.cpp
+#, fuzzy
msgid ""
"The controller ID must not be 0 or this controller won't be bound to an "
"actual controller."
msgstr ""
+"ИД Контролора не Ñме бити 0 или овај контролор неће бити везан за актуелнонг "
+"контролора."
#: scene/3d/arvr_nodes.cpp
+#, fuzzy
msgid "ARVRAnchor must have an ARVROrigin node as its parent."
-msgstr ""
+msgstr "ARVRAnchor мора имати ARVROrigin чвор као родитеља."
#: scene/3d/arvr_nodes.cpp
+#, fuzzy
msgid ""
"The anchor ID must not be 0 or this anchor won't be bound to an actual "
"anchor."
msgstr ""
+"Чвор ИД не Ñме биди 0 или ово Ñидро неће бити везано за актуелно Ñидро."
#: scene/3d/arvr_nodes.cpp
+#, fuzzy
msgid "ARVROrigin requires an ARVRCamera child node."
-msgstr ""
+msgstr "ARVROrigin захтева ARVRCamera дете чвор."
#: scene/3d/baked_lightmap.cpp
+#, fuzzy
msgid "%d%%"
-msgstr ""
+msgstr "%d%%"
#: scene/3d/baked_lightmap.cpp
+#, fuzzy
msgid "(Time Left: %d:%02d s)"
-msgstr ""
+msgstr "(Време преоÑтало: %d:%02d Ñ)"
#: scene/3d/baked_lightmap.cpp
+#, fuzzy
msgid "Plotting Meshes: "
-msgstr ""
+msgstr "Сковане Мреже:"
#: scene/3d/baked_lightmap.cpp
+#, fuzzy
msgid "Plotting Lights:"
-msgstr ""
+msgstr "Скована Светла:"
#: scene/3d/baked_lightmap.cpp scene/3d/gi_probe.cpp
+#, fuzzy
msgid "Finishing Plot"
-msgstr ""
+msgstr "Завршни Ков"
#: scene/3d/baked_lightmap.cpp
+#, fuzzy
msgid "Lighting Meshes: "
-msgstr ""
+msgstr "СветлоÑне Мреже:"
#: scene/3d/collision_object.cpp
+#, fuzzy
msgid ""
"This node has no shape, so it can't collide or interact with other objects.\n"
"Consider adding a CollisionShape or CollisionPolygon as a child to define "
"its shape."
msgstr ""
+"Овај чвор нема облик, па Ñе не може Ñударати Ñа оÑталим објектима.\n"
+"Размотри додавање СударногОблика или СударногМногоугла као детета да би "
+"дефиниÑао облик."
#: scene/3d/collision_polygon.cpp
+#, fuzzy
msgid ""
"CollisionPolygon only serves to provide a collision shape to a "
"CollisionObject derived node. Please only use it as a child of Area, "
"StaticBody, RigidBody, KinematicBody, etc. to give them a shape."
msgstr ""
+"СуадрниМногоугао Ñамо Ñлужи да обезбеди Ñударни облик чвуру изведеном од "
+"СуадрниОбјекат. Молимо кориÑи га Ñамо као дете ОблаÑти, ÐепомичногТела, "
+"ЧврÑтогТела, итд. да им даш облик."
#: scene/3d/collision_polygon.cpp
+#, fuzzy
msgid "An empty CollisionPolygon has no effect on collision."
-msgstr ""
+msgstr "Празан СударниМногоугао нема утицаја на Ñудар."
#: scene/3d/collision_shape.cpp
+#, fuzzy
msgid ""
"CollisionShape only serves to provide a collision shape to a CollisionObject "
"derived node. Please only use it as a child of Area, StaticBody, RigidBody, "
"KinematicBody, etc. to give them a shape."
msgstr ""
+"СударниОблик Ñамо Ñлужи да обезбеди Ñударни облик чвору изведеном Ð¸Ñ "
+"СударниОбјекат. Молимо Ñамо га кориÑти као дете ОблаÑти, ÐепомичногТела, "
+"ЧврÑтогТела, итд. да им даш облик."
#: scene/3d/collision_shape.cpp
+#, fuzzy
msgid ""
"A shape must be provided for CollisionShape to function. Please create a "
"shape resource for it."
msgstr ""
+"Облик мора бити Ñнабдевен за СударниОблик да би радио. Молимо креирајте "
+"облик реÑÑƒÑ€Ñ Ð·Ð° њега."
#: scene/3d/collision_shape.cpp
+#, fuzzy
msgid ""
"Plane shapes don't work well and will be removed in future versions. Please "
"don't use them."
msgstr ""
+"Облици равни не раде добро и биће уклоњени у будућим верзија. Молимо не "
+"кориÑтите их."
#: scene/3d/collision_shape.cpp
+#, fuzzy
msgid ""
"ConcavePolygonShape doesn't support RigidBody in another mode than static."
msgstr ""
+"УдубљениМоногоугаониОблик не подржава ЧврÑтоТело у другом рећим оÑим "
+"непокретног."
#: scene/3d/cpu_particles.cpp
+#, fuzzy
msgid "Nothing is visible because no mesh has been assigned."
-msgstr ""
+msgstr "Ðишта није видљиво пошто мрежа није била додељена."
#: scene/3d/cpu_particles.cpp
+#, fuzzy
msgid ""
"CPUParticles animation requires the usage of a SpatialMaterial whose "
"Billboard Mode is set to \"Particle Billboard\"."
msgstr ""
+"ПроцеÑорЧеÑтице анимација захтева коришћење ПроÑторногМатеријала чији Режим "
+"ОглаÑнеТабле је поÑтављен као \"ОглаÑнаТабла ЧеÑтице\"."
#: scene/3d/gi_probe.cpp
+#, fuzzy
msgid "Plotting Meshes"
-msgstr ""
+msgstr "Сковане Мреже"
#: scene/3d/gi_probe.cpp
+#, fuzzy
msgid ""
"GIProbes are not supported by the GLES2 video driver.\n"
"Use a BakedLightmap instead."
msgstr ""
+"СондеГлобалногОÑветљења ниÑу подржане од Ñтране GLES2 видео управљача.\n"
+" \n"
+"Као замену кориÑти ИÑпеченеСенкеМапу."
#: scene/3d/light.cpp
+#, fuzzy
msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows."
-msgstr ""
+msgstr "ТачкаСветло Ñа углом ширим од 90 Ñтепени не може бацати Ñенке."
#: scene/3d/navigation_mesh.cpp
+#, fuzzy
msgid "A NavigationMesh resource must be set or created for this node to work."
msgstr ""
+"ÐавигационаМрежа реÑÑƒÑ€Ñ Ð¼Ð¾Ñ€Ð° бити поÑтављен или креиран да би овај чвор "
+"радио."
#: scene/3d/navigation_mesh.cpp
+#, fuzzy
msgid ""
"NavigationMeshInstance must be a child or grandchild to a Navigation node. "
"It only provides navigation data."
msgstr ""
+"ÐавМрежнаИнÑтанца мора бити дете или прадете Ðавигационог чвора. Само "
+"обезбећује навигационе податке."
#: scene/3d/particles.cpp
+#, fuzzy
msgid ""
"GPU-based particles are not supported by the GLES2 video driver.\n"
"Use the CPUParticles node instead. You can use the \"Convert to CPUParticles"
"\" option for this purpose."
-msgstr ""
+msgstr "GPU-базиране чеÑтице ниÑу подржане од Ñтране GLES2 видео управљача."
#: scene/3d/particles.cpp
+#, fuzzy
msgid ""
"Nothing is visible because meshes have not been assigned to draw passes."
-msgstr ""
+msgstr "Ðишта није видљиво пошто мрежама није било додељено да цртају пролазе."
#: scene/3d/particles.cpp
+#, fuzzy
msgid ""
"Particles animation requires the usage of a SpatialMaterial whose Billboard "
"Mode is set to \"Particle Billboard\"."
msgstr ""
+"ЧеÑтице анимација захтева коришћење ПроÑторногМатеријала чије је Режим "
+"ОглаÑнеТабле поÑтављен као \"ЧеÑтице ОглаÑнеТабле\"."
#: scene/3d/path.cpp
+#, fuzzy
msgid "PathFollow only works when set as a child of a Path node."
-msgstr ""
+msgstr "ПутањаПраћења ради Ñамо кад је поÑтављена као дете Путања чвора."
#: scene/3d/path.cpp
+#, fuzzy
msgid ""
"PathFollow's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its "
"parent Path's Curve resource."
msgstr ""
+"ОРИЈЕÐТИСÐÐÐ_РОТÐЦИЈРПутањеПраћења захтева \"Горе Вектор\" да би била "
+"омогућена у Ñвом родитељ реÑурÑу Путања Криве."
#: scene/3d/physics_body.cpp
+#, fuzzy
msgid ""
"Size changes to RigidBody (in character or rigid modes) will be overridden "
"by the physics engine when running.\n"
"Change the size in children collision shapes instead."
msgstr ""
+"Промена величине у ТврдомТелу (у карактеру или трвдом моду) ће бити "
+"препиÑана од Ñтране физичког мотора у раду."
#: scene/3d/remote_transform.cpp
+#, fuzzy
msgid ""
"The \"Remote Path\" property must point to a valid Spatial or Spatial-"
"derived node to work."
msgstr ""
+"\"ДаљинÑка Путања\" подешавање да би радило мора упирати ка важећем "
+"ПроÑторном или ПроÑторно-изведеном чвору."
#: scene/3d/soft_body.cpp
+#, fuzzy
msgid "This body will be ignored until you set a mesh."
-msgstr ""
+msgstr "Ово тело ће бити занемарено док не поÑтавиш мрежу."
#: scene/3d/soft_body.cpp
+#, fuzzy
msgid ""
"Size changes to SoftBody will be overridden by the physics engine when "
"running.\n"
"Change the size in children collision shapes instead."
msgstr ""
+"Промене величине МекогТела ће бити препиÑане од Ñтране фитичког мотора током "
+"рада."
#: scene/3d/sprite_3d.cpp
+#, fuzzy
msgid ""
"A SpriteFrames resource must be created or set in the \"Frames\" property in "
"order for AnimatedSprite3D to display frames."
msgstr ""
+"СпрајтРам реÑурÑи морају бити креирани или подешени у \"Рамови\" оÑобини да "
+"би ÐнимираниСпрајт3Д приказао рамове."
#: scene/3d/vehicle_body.cpp
+#, fuzzy
msgid ""
"VehicleWheel serves to provide a wheel system to a VehicleBody. Please use "
"it as a child of a VehicleBody."
msgstr ""
+"ТочакВозила Ñлужи да Ñнабде точак ÑиÑтем ТелуВозила. Молимо кориÑтите га као "
+"детете од ТелаВозила."
#: scene/3d/world_environment.cpp
+#, fuzzy
msgid ""
"WorldEnvironment requires its \"Environment\" property to contain an "
"Environment to have a visible effect."
msgstr ""
+"СветÑкоОкружење изиÑкује Ñвоју \"Окружење\" оÑобину да Ñадржи Окружење да би "
+"било видљиво."
#: scene/3d/world_environment.cpp
+#, fuzzy
msgid ""
"Only one WorldEnvironment is allowed per scene (or set of instanced scenes)."
msgstr ""
+"Само једно СветÑкоОкружење је дозвољено за Ñцену (или групу инÑтанцираних "
+"Ñцена)."
#: scene/3d/world_environment.cpp
+#, fuzzy
msgid ""
"This WorldEnvironment is ignored. Either add a Camera (for 3D scenes) or set "
"this environment's Background Mode to Canvas (for 2D scenes)."
-msgstr ""
+msgstr "СветÑкоОкружење је занемарено."
#: scene/animation/animation_blend_tree.cpp
+#, fuzzy
msgid "On BlendTree node '%s', animation not found: '%s'"
-msgstr ""
+msgstr "Ðа BlendTree чвору '%s', анимација није нађена: '%s'"
#: scene/animation/animation_blend_tree.cpp
#, fuzzy
msgid "Animation not found: '%s'"
-msgstr "Ðнимационе алатке"
+msgstr "Ðнимација није нађена: '%s'"
#: scene/animation/animation_tree.cpp
+#, fuzzy
msgid "In node '%s', invalid animation: '%s'."
-msgstr ""
+msgstr "У чвору '%s', неважећа анимација: '%s'."
#: scene/animation/animation_tree.cpp
#, fuzzy
msgid "Invalid animation: '%s'."
-msgstr "Грешка: неважеће име анимације!"
+msgstr "Ðеважећа анимација: '%s'."
#: scene/animation/animation_tree.cpp
#, fuzzy
msgid "Nothing connected to input '%s' of node '%s'."
-msgstr "Повежи '%s' Ñа '%s'"
+msgstr "Ðишта није позевано Ñа улазом '%s' од чвора '%s'."
#: scene/animation/animation_tree.cpp
+#, fuzzy
msgid "No root AnimationNode for the graph is set."
-msgstr ""
+msgstr "AnimationNode без корена за графикон је поÑтављено."
#: scene/animation/animation_tree.cpp
#, fuzzy
msgid "Path to an AnimationPlayer node containing animations is not set."
-msgstr "Одабери AnimationPlayer из дрвета Ñцене за уређивање анимација."
+msgstr "Путања ка AnimationPlayer чвору који Ñадржи анимацију није поÑтављена."
#: scene/animation/animation_tree.cpp
+#, fuzzy
msgid "Path set for AnimationPlayer does not lead to an AnimationPlayer node."
-msgstr ""
+msgstr "Путања поÑтављена за AnimationPlayer не води ка AnimationPlayer чвору."
#: scene/animation/animation_tree.cpp
#, fuzzy
@@ -12964,127 +14264,187 @@ msgid "The AnimationPlayer root node is not a valid node."
msgstr "Ðнимационо дрво није важеће."
#: scene/animation/animation_tree_player.cpp
+#, fuzzy
msgid "This node has been deprecated. Use AnimationTree instead."
-msgstr ""
+msgstr "Овај члан је заÑтарео. КориÑти AnimationTree као замену."
#: scene/gui/color_picker.cpp
+#, fuzzy
msgid ""
"Color: #%s\n"
"LMB: Set color\n"
"RMB: Remove preset"
msgstr ""
+"Боја: #%s\n"
+"LMB: ПоÑтави боју\n"
+"RMB: Уклони поÑтавку"
#: scene/gui/color_picker.cpp
+#, fuzzy
msgid "Pick a color from the editor window."
-msgstr ""
+msgstr "Одабери боју из прозора уредника."
#: scene/gui/color_picker.cpp
+#, fuzzy
msgid "HSV"
-msgstr ""
+msgstr "ÐијанÑа ЗаÑићење ВредноÑÑ‚"
#: scene/gui/color_picker.cpp
+#, fuzzy
msgid "Raw"
-msgstr ""
+msgstr "Сиров"
#: scene/gui/color_picker.cpp
+#, fuzzy
msgid "Switch between hexadecimal and code values."
-msgstr ""
+msgstr "Пребаци између хекÑадецималних и кодних вредноÑти."
#: scene/gui/color_picker.cpp
+#, fuzzy
msgid "Add current color as a preset."
-msgstr ""
+msgstr "Додај тренутну боју као поÑтавку."
#: scene/gui/container.cpp
+#, fuzzy
msgid ""
"Container by itself serves no purpose unless a script configures its "
"children placement behavior.\n"
"If you don't intend to add a script, use a plain Control node instead."
msgstr ""
+"Контејнер као такав није употревљив оÑим ако Ñкрипта подеÑи позиционо "
+"понашање Ñвоје деце.\n"
+"Ðко не намераваш да додаш Ñкрипту, онда кориÑти проÑти Контрол чвор."
#: scene/gui/control.cpp
+#, fuzzy
msgid ""
"The Hint Tooltip won't be displayed as the control's Mouse Filter is set to "
"\"Ignore\". To solve this, set the Mouse Filter to \"Stop\" or \"Pass\"."
msgstr ""
+"Савет-Кутије неће бити приказане као контроле, Миш Пробирач је поÑтављен на "
+"\"Занемари\". Да решиш ово, поÑтави Миш Пробирач на \"ЗауÑтави\" или "
+"\"ПроÑледи\"."
#: scene/gui/dialogs.cpp
+#, fuzzy
msgid "Alert!"
-msgstr ""
+msgstr "Узбуна!"
#: scene/gui/dialogs.cpp
+#, fuzzy
msgid "Please Confirm..."
-msgstr ""
+msgstr "Молимо Потврди..."
#: scene/gui/popup.cpp
+#, fuzzy
msgid ""
"Popups will hide by default unless you call popup() or any of the popup*() "
"functions. Making them visible for editing is fine, but they will hide upon "
"running."
msgstr ""
+"Скок-Прозори биће Ñкривени оÑим ако позовеш popup() или било коју од "
+"popup*() функција. Чинити их видљивим за измену је добро, али ће Ñе Ñакрити "
+"након покретања."
#: scene/gui/range.cpp
+#, fuzzy
msgid "If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0."
msgstr ""
+"Ðко је \"ЕкÑп Измена\" омогућена, \"Ðајмања ВредноÑÑ‚\" мора бити већа од 0."
#: scene/gui/scroll_container.cpp
+#, fuzzy
msgid ""
"ScrollContainer is intended to work with a single child control.\n"
"Use a container as child (VBox, HBox, etc.), or a Control and set the custom "
"minimum size manually."
msgstr ""
+"ScrollContainer је намењен да ради Ñа једном дете контролом.\n"
+"КориÑти контејнер као дете (ВКутија, ХКутија, итд.), или Контролу и подеÑи "
+"ручно произвољну најмању величину."
#: scene/gui/tree.cpp
+#, fuzzy
msgid "(Other)"
-msgstr ""
+msgstr "(ОÑтатак)"
#: scene/main/scene_tree.cpp
+#, fuzzy
msgid ""
"Default Environment as specified in Project Settings (Rendering -> "
"Environment -> Default Environment) could not be loaded."
msgstr ""
+"Уобичајено Окружење наведено у Подешавањима Пројекта (ИÑцртавање -> Окружење "
+"-> Уобичајено Окружење) није уÑпешно учитано."
#: scene/main/viewport.cpp
+#, fuzzy
msgid ""
"This viewport is not set as render target. If you intend for it to display "
"its contents directly to the screen, make it a child of a Control so it can "
"obtain a size. Otherwise, make it a RenderTarget and assign its internal "
"texture to some node for display."
msgstr ""
+"Овај viewport није поÑтављен као мета за иÑцртавање. Ðко намераваш да "
+"прикаже Ñадржај директно на екран, учини га дететом Контроле да може да "
+"добави величину. У Ñупротном, учини га МетомИÑцртавања и додели његову "
+"унутрашњу текÑтуру неком чвору за приказ."
#: scene/main/viewport.cpp
+#, fuzzy
msgid "Viewport size must be greater than 0 to render anything."
-msgstr ""
+msgstr "Величина Viewport-а мора бити већа од 0 да би Ñе нешто иÑцртало."
#: scene/resources/visual_shader_nodes.cpp
#, fuzzy
msgid "Invalid source for preview."
-msgstr "Ðеважећа величина фонта."
+msgstr "Ðеважећи извор за преглед."
#: scene/resources/visual_shader_nodes.cpp
#, fuzzy
msgid "Invalid source for shader."
-msgstr "Ðеважећа величина фонта."
+msgstr "Ðеважећи извор за цртач"
#: scene/resources/visual_shader_nodes.cpp
#, fuzzy
msgid "Invalid comparison function for that type."
-msgstr "Ðеважећа величина фонта."
+msgstr "Ðеважећа упоредна функција за зај тип"
#: servers/visual/shader_language.cpp
+#, fuzzy
msgid "Assignment to function."
-msgstr ""
+msgstr "Додељивање функцији."
#: servers/visual/shader_language.cpp
+#, fuzzy
msgid "Assignment to uniform."
-msgstr ""
+msgstr "Додељивање унформи."
#: servers/visual/shader_language.cpp
+#, fuzzy
msgid "Varyings can only be assigned in vertex function."
-msgstr ""
+msgstr "Варијације могу Ñамо бити одређене у функцији тачке."
#: servers/visual/shader_language.cpp
+#, fuzzy
msgid "Constants cannot be modified."
-msgstr ""
+msgstr "КонÑтанте није могуће мењати."
+
+#~ msgid "Not in resource path."
+#~ msgstr "Ðије на пут реÑурÑа."
+
+#~ msgid "Revert"
+#~ msgstr "Врати"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Ова акција Ñе не може опозвати. ÐаÑтави?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Поврати Ñцену"
+
+#, fuzzy
+#~ msgid "Clear Script"
+#~ msgstr "ИÑпразни Скрипту"
#~ msgid "Issue Tracker"
#~ msgstr "Пратилац грешака"
diff --git a/editor/translations/sr_Latn.po b/editor/translations/sr_Latn.po
index a2ae9fccea..e62d152c45 100644
--- a/editor/translations/sr_Latn.po
+++ b/editor/translations/sr_Latn.po
@@ -844,7 +844,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1445,16 +1444,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2380,11 +2371,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Napravi"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2651,10 +2645,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3263,6 +3253,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3849,6 +3843,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6763,15 +6761,15 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Linearna"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
msgstr ""
@@ -7244,6 +7242,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10222,7 +10229,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10383,6 +10390,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10431,11 +10445,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10555,6 +10569,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10595,6 +10613,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11639,6 +11661,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11662,6 +11688,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/sv.po b/editor/translations/sv.po
index a03a37b533..e316c74160 100644
--- a/editor/translations/sv.po
+++ b/editor/translations/sv.po
@@ -12,12 +12,15 @@
# Toiya <elviraa98@gmail.com>, 2019.
# Fredrik Welin <figgemail@gmail.com>, 2019.
# Mattias Münster <mattiasmun@gmail.com>, 2019.
+# Anonymous <noreply@weblate.org>, 2020.
+# Joakim Lundberg <joakim@joakimlundberg.com>, 2020.
+# Kristoffer Grundström <swedishsailfishosuser@tutanota.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2019-11-25 04:05+0000\n"
-"Last-Translator: Mattias Münster <mattiasmun@gmail.com>\n"
+"PO-Revision-Date: 2020-06-03 20:09+0000\n"
+"Last-Translator: Kristoffer Grundström <swedishsailfishosuser@tutanota.com>\n"
"Language-Team: Swedish <https://hosted.weblate.org/projects/godot-engine/"
"godot/sv/>\n"
"Language: sv\n"
@@ -25,7 +28,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 3.10-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -34,7 +37,7 @@ msgstr "Ogiltligt typargument till convert(), använd TYPE_* konstanter."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr ""
+msgstr "Förväntade en sträng med längden 1 (en karaktär)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -73,31 +76,31 @@ msgstr "I anrop till '%s':"
#: core/ustring.cpp
msgid "B"
-msgstr ""
+msgstr "B"
#: core/ustring.cpp
msgid "KiB"
-msgstr ""
+msgstr "KiB"
#: core/ustring.cpp
msgid "MiB"
-msgstr ""
+msgstr "MiB"
#: core/ustring.cpp
msgid "GiB"
-msgstr ""
+msgstr "GiB"
#: core/ustring.cpp
msgid "TiB"
-msgstr ""
+msgstr "TiB"
#: core/ustring.cpp
msgid "PiB"
-msgstr ""
+msgstr "PiB"
#: core/ustring.cpp
msgid "EiB"
-msgstr ""
+msgstr "EiB"
#: editor/animation_bezier_editor.cpp
msgid "Free"
@@ -168,29 +171,24 @@ msgid "Anim Change Call"
msgstr "Anim Ändra Anrop"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Keyframe Time"
-msgstr "Anim Ändra Tid för Nyckebild"
+msgstr "Anim multi-ändring nyckelbildstid"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Transition"
-msgstr "Anim Ändra Övergång"
+msgstr "Anim Fler-Ändra Övergång"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Transform"
-msgstr "Anim Ändra Transformation"
+msgstr "Anim Fler-Ändra Transformation"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Keyframe Value"
-msgstr "Anim Ändra Värde På Nyckelbild"
+msgstr "Anim Fler-Ändra Nyckelbildsvärde"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Call"
-msgstr "Anim Ändra Anrop"
+msgstr "Anim Fler-Ändra Anrop"
#: editor/animation_track_editor.cpp
msgid "Change Animation Length"
@@ -203,43 +201,39 @@ msgstr "Ändra Animationsloop"
#: editor/animation_track_editor.cpp
msgid "Property Track"
-msgstr ""
+msgstr "Egenskapsspår"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "3D Transform Track"
-msgstr "Transformera"
+msgstr "3D Transformationsspår"
#: editor/animation_track_editor.cpp
msgid "Call Method Track"
-msgstr ""
+msgstr "Anropa Metod Spår"
#: editor/animation_track_editor.cpp
msgid "Bezier Curve Track"
-msgstr ""
+msgstr "Bezier kurvspår"
#: editor/animation_track_editor.cpp
msgid "Audio Playback Track"
-msgstr ""
+msgstr "Ljuduppspelningsspår"
#: editor/animation_track_editor.cpp
msgid "Animation Playback Track"
-msgstr ""
+msgstr "Animationsuppspelningsspår"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (frames)"
-msgstr "Animation längd (i sekunder)."
+msgstr "Animation längd (bildrutor)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (seconds)"
-msgstr "Animation längd (i sekunder)."
+msgstr "Animationslängd (i sekunder)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Track"
-msgstr "Anim Lägg till spår"
+msgstr "Lägg till spår"
#: editor/animation_track_editor.cpp
msgid "Animation Looping"
@@ -259,9 +253,8 @@ msgid "Anim Clips:"
msgstr "Animklipp:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Track Path"
-msgstr "Ändra Arrays Värde"
+msgstr "Ändra spårväg"
#: editor/animation_track_editor.cpp
msgid "Toggle this track on/off."
@@ -269,21 +262,19 @@ msgstr "Ändra spårets läge till på/av."
#: editor/animation_track_editor.cpp
msgid "Update Mode (How this property is set)"
-msgstr ""
+msgstr "Uppdateringsläge (Hur denna egenskap sätts)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Interpolation Mode"
-msgstr "Animations-Node"
+msgstr "Interpolationsläge"
#: editor/animation_track_editor.cpp
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
-msgstr ""
+msgstr "Återgående slingläge (Interpolerar slutet med början på slingan)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Remove this track."
-msgstr "Ta bort valt spår."
+msgstr "Ta bort detta spår."
#: editor/animation_track_editor.cpp
msgid "Time (s): "
@@ -291,7 +282,7 @@ msgstr "Tid (s): "
#: editor/animation_track_editor.cpp
msgid "Toggle Track Enabled"
-msgstr ""
+msgstr "Växla Spår På"
#: editor/animation_track_editor.cpp
msgid "Continuous"
@@ -324,11 +315,11 @@ msgstr "Kubik"
#: editor/animation_track_editor.cpp
msgid "Clamp Loop Interp"
-msgstr ""
+msgstr "Begränsa Sling Interpolering"
#: editor/animation_track_editor.cpp
msgid "Wrap Loop Interp"
-msgstr ""
+msgstr "Återgåendeslinginterpolering"
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
@@ -348,14 +339,12 @@ msgid "Change Animation Update Mode"
msgstr "Ändra Animationens Uppdateringsläge"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Interpolation Mode"
-msgstr "Animations-Node"
+msgstr "Ändra Animationsinterpoleringsläge"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Loop Mode"
-msgstr "Ändra Anim Loop"
+msgstr "Ändra Animationsslingläge"
#: editor/animation_track_editor.cpp
msgid "Remove Anim Track"
@@ -388,6 +377,7 @@ msgstr "Anim Infoga"
#: editor/animation_track_editor.cpp
msgid "AnimationPlayer can't animate itself, only other players."
msgstr ""
+"Animationsspelaren kan inte animera sig själv, utan bara andra spelare."
#: editor/animation_track_editor.cpp
msgid "Anim Create & Insert"
@@ -402,18 +392,16 @@ msgid "Anim Insert Key"
msgstr "Anim Infoga Nyckel"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Step"
-msgstr "Ändra Animationsnamn:"
+msgstr "Ändra Animationssteg"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Rearrange Tracks"
-msgstr "Ändra ordning på Autoloads"
+msgstr "Ändra ordning på spår"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr ""
+msgstr "Applicera Transformationsspår enbart på 3D-noder."
#: editor/animation_track_editor.cpp
msgid ""
@@ -422,22 +410,27 @@ msgid ""
"-AudioStreamPlayer2D\n"
"-AudioStreamPlayer3D"
msgstr ""
+"Ljudspår kan bara peka på noder av typ:\n"
+"-LjudStrömsSpelare\n"
+"-LjudStrömsSpelare2D\n"
+"-LjudStrömsSpelare3D"
#: editor/animation_track_editor.cpp
msgid "Animation tracks can only point to AnimationPlayer nodes."
-msgstr ""
+msgstr "Animationsspår kan bara peka på AnimationsSpelar noder."
#: editor/animation_track_editor.cpp
msgid "An animation player can't animate itself, only other players."
msgstr ""
+"En animationsspelare kan inte animera sig själv, utan bara andra spelare."
#: editor/animation_track_editor.cpp
msgid "Not possible to add a new track without a root"
-msgstr ""
+msgstr "Det är inte möjligt att lägga till ett nytt spår utan en rot-nod"
#: editor/animation_track_editor.cpp
msgid "Invalid track for Bezier (no suitable sub-properties)"
-msgstr ""
+msgstr "Felaktigt spår för Bezier (ej lämplig delegenskap)"
#: editor/animation_track_editor.cpp
msgid "Add Bezier Track"
@@ -456,37 +449,32 @@ msgid "Add Transform Track Key"
msgstr "Lägg till kurvförändringsnyckel"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Track Key"
-msgstr "Anim Lägg till spår"
+msgstr "Lägg till spårnyckel"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a method key."
-msgstr ""
+msgstr "Spårväg ogiltig, kan således inte lägga till en metod nyckel."
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Method Track Key"
-msgstr "Anim Infoga Spår & Nyckel"
+msgstr "Lägg till metodspårnyckel"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Method not found in object: "
-msgstr "VariableGet hittades inte i Skript: "
+msgstr "Metoden hittades inte i objektet: "
#: editor/animation_track_editor.cpp
msgid "Anim Move Keys"
msgstr "Anim Flytta Nycklar"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Clipboard is empty"
-msgstr "Sökvägen är tom"
+msgstr "Urklipp är tomt"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Paste Tracks"
-msgstr "Klistra in Params"
+msgstr "Klistra in spår"
#: editor/animation_track_editor.cpp
msgid "Anim Scale Keys"
@@ -496,6 +484,8 @@ msgstr "Anim Skala Nycklar"
msgid ""
"This option does not work for Bezier editing, as it's only a single track."
msgstr ""
+"Detta alternativ fungerar ej för att redigera Bezier, då det enbart är ett "
+"spår."
#: editor/animation_track_editor.cpp
msgid ""
@@ -512,16 +502,15 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Warning: Editing imported animation"
-msgstr ""
+msgstr "Varning: Redigerar importerad animation"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Select an AnimationPlayer node to create and edit animations."
-msgstr "Välj en AnimationPlayer från Scenträdet för att redigera animationer."
+msgstr "Välj en AnimationsSpelar-nod för att skapa och redigera animationer."
#: editor/animation_track_editor.cpp
msgid "Only show tracks from nodes selected in tree."
-msgstr ""
+msgstr "Visa enbart spår från valda noder i trädet."
#: editor/animation_track_editor.cpp
msgid "Group tracks by node or display them as plain list."
@@ -539,7 +528,7 @@ msgstr "Animation"
#: editor/animation_track_editor.cpp
msgid "Seconds"
-msgstr ""
+msgstr "Sekunder"
#: editor/animation_track_editor.cpp
msgid "FPS"
@@ -575,11 +564,11 @@ msgstr "Skala Från Muspekare"
#: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp
msgid "Duplicate Selection"
-msgstr "Duplicera urval"
+msgstr "Fördubbla val"
#: editor/animation_track_editor.cpp
msgid "Duplicate Transposed"
-msgstr "Duplicera Transponerade"
+msgstr "Fördubbla Transponerade"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -606,11 +595,11 @@ msgstr "Städa upp Animation"
#: editor/animation_track_editor.cpp
msgid "Pick the node that will be animated:"
-msgstr ""
+msgstr "Välj noden som ska animeras:"
#: editor/animation_track_editor.cpp
msgid "Use Bezier Curves"
-msgstr ""
+msgstr "Använd Bezier-kurvor"
#: editor/animation_track_editor.cpp
msgid "Anim. Optimizer"
@@ -870,7 +859,6 @@ msgstr "Ansluter Signal:"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1515,18 +1503,9 @@ msgstr "Aktivera"
msgid "Rearrange Autoloads"
msgstr "Ändra ordning på Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "Ogiltig Sökväg."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Fil existerar inte."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Inte i resursens sökväg."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2533,12 +2512,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Kan inte ladda om en scen som aldrig har sparats."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Återställ"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Spara Scen"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Åtgärden kan inte ångras. Återställ ändå?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
#, fuzzy
@@ -2838,10 +2820,6 @@ msgid "Redo"
msgstr "Ã…ngra"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Återställ Scen"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3476,6 +3454,10 @@ msgstr "Kunde inte köra Skript:"
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Välj Nod(er) att Importera"
@@ -4115,6 +4097,10 @@ msgid "Error running post-import script:"
msgstr "Fel uppstod efter importering av skript:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Sparar..."
@@ -7157,15 +7143,15 @@ msgid ""
msgstr "Anslut '%s' till '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Rad:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Funktion:"
@@ -7656,6 +7642,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10735,8 +10730,9 @@ msgid "Instance Child Scene"
msgstr "Instansiera Barn-Scen"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Fäst Skript"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10906,6 +10902,13 @@ msgid "Open Documentation"
msgstr "Öppna Senaste"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Lägg till Barn-Node"
@@ -10956,12 +10959,14 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Koppla på ett nytt eller befintligt Skript till vald Node."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
+#, fuzzy
+msgid "Detach the script from the selected node."
+msgstr "Koppla på ett nytt eller befintligt Skript till vald Node."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -11092,6 +11097,10 @@ msgid "A directory with the same name exists."
msgstr "Katalog med samma namn finns redan"
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Fil existerar inte."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Måste använda en giltigt filändelse."
@@ -11136,6 +11145,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "Ogiltig Sökväg."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Ogiltigt namn."
@@ -12216,6 +12230,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12240,6 +12258,32 @@ msgstr "Ogiltigt namn."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12925,6 +12969,18 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr ""
+#~ msgid "Not in resource path."
+#~ msgstr "Inte i resursens sökväg."
+
+#~ msgid "Revert"
+#~ msgstr "Återställ"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Åtgärden kan inte ångras. Återställ ändå?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Återställ Scen"
+
#~ msgid "Replaced %d occurrence(s)."
#~ msgstr "Ersatte %d förekomst(er)."
diff --git a/editor/translations/ta.po b/editor/translations/ta.po
index 7dd9f5f38c..b8ea8d3538 100644
--- a/editor/translations/ta.po
+++ b/editor/translations/ta.po
@@ -836,7 +836,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1437,16 +1436,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2368,11 +2359,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2639,10 +2632,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3250,6 +3239,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3836,6 +3829,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6728,11 +6725,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7203,6 +7200,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10140,7 +10146,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10301,6 +10307,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10347,11 +10360,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10472,6 +10485,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10512,6 +10529,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11546,6 +11567,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11569,6 +11594,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/te.po b/editor/translations/te.po
index a6c727fe89..589064278d 100644
--- a/editor/translations/te.po
+++ b/editor/translations/te.po
@@ -815,7 +815,6 @@ msgstr ""
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1415,16 +1414,8 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2344,11 +2335,13 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
+msgid "Reload Saved Scene"
msgstr ""
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2614,10 +2607,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3223,6 +3212,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3807,6 +3800,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6678,11 +6675,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7152,6 +7149,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10070,7 +10076,7 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
+msgid "Detach Script"
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10228,6 +10234,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10274,11 +10287,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10398,6 +10411,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10438,6 +10455,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11462,6 +11483,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11485,6 +11510,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
diff --git a/editor/translations/th.po b/editor/translations/th.po
index e908dde33c..db7fd6adea 100644
--- a/editor/translations/th.po
+++ b/editor/translations/th.po
@@ -5,11 +5,12 @@
# Kaveeta Vivatchai <goodytong@gmail.com>, 2017.
# Poommetee Ketson (Noshyaar) <poommetee@protonmail.com>, 2017-2018.
# Thanachart Monpassorn <nunf_2539@hotmail.com>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-03-31 02:26+0000\n"
+"PO-Revision-Date: 2020-05-26 13:41+0000\n"
"Last-Translator: Thanachart Monpassorn <nunf_2539@hotmail.com>\n"
"Language-Team: Thai <https://hosted.weblate.org/projects/godot-engine/godot/"
"th/>\n"
@@ -18,7 +19,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.0-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -41,7 +42,7 @@ msgstr "ค่าอินพุตผิดพลาด %i (ไม่ผ่าà
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr "self ไม่สามารถใช้ได้เนื่องจาà¸à¸­à¸´à¸™à¸ªà¹à¸•à¸™à¸‹à¹Œà¸¡à¸µà¸„่า null (ไม่ผ่าน)"
+msgstr "self ไม่สามารถใช้ได้เนื่องจาภinstance ว่าง (ไม่ผ่าน)"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
@@ -57,7 +58,7 @@ msgstr "ชื่อดัชนีของ '%s' ผิดพลาด สำà¸
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr "อาà¸à¸´à¸§à¹€à¸¡à¸™à¸•à¹Œà¹„ม่ถูà¸à¸•à¹‰à¸­à¸‡à¹ƒà¸™à¸„อนสตรัภ'%s'"
+msgstr "อาร์à¸à¸´à¸§à¹€à¸¡à¸™à¸•à¹Œà¸‚องคอนสตรัค '%s' ผิดพลาด"
#: core/math/expression.cpp
msgid "On call to '%s':"
@@ -97,7 +98,7 @@ msgstr "อิสระ"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
-msgstr "สมดุล"
+msgstr "ความสมดุล"
#: editor/animation_bezier_editor.cpp
msgid "Mirror"
@@ -113,7 +114,7 @@ msgstr "ค่า:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr "เพิ่มคีย์ที่นี่"
+msgstr "เพิ่มปุ่มที่นี่"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
@@ -235,7 +236,7 @@ msgstr "ฟังà¸à¹Œà¸Šà¸±à¸™:"
#: editor/animation_track_editor.cpp
msgid "Audio Clips:"
-msgstr "คลิปเสียง:"
+msgstr "คลิปเสียง"
#: editor/animation_track_editor.cpp
msgid "Anim Clips:"
@@ -328,9 +329,8 @@ msgid "Change Animation Update Mode"
msgstr "เปลี่ยนโหมดà¸à¸²à¸£à¸­à¸±à¸žà¹€à¸”ทà¹à¸­à¸™à¸´à¹€à¸¡à¸Šà¸±à¸™"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Interpolation Mode"
-msgstr "โหนดà¹à¸­à¸™à¸´à¹€à¸¡à¸Šà¸±à¸™"
+msgstr "เปลี่ยนโหมดà¸à¸²à¸£à¸›à¸£à¸°à¸¡à¸²à¸“ค่าช่วงของà¹à¸­à¸™à¸´à¹€à¸¡à¸Šà¸±à¸™"
#: editor/animation_track_editor.cpp
msgid "Change Animation Loop Mode"
@@ -381,9 +381,8 @@ msgid "Anim Insert Key"
msgstr "à¹à¸—รà¸à¸„ีย์à¹à¸­à¸™à¸´à¹€à¸¡à¸Šà¸±à¸™"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Step"
-msgstr "à¹à¸à¹‰à¹„ขความเร็วà¹à¸­à¸™à¸´à¹€à¸¡à¸Šà¸±à¸™"
+msgstr "à¹à¸à¹‰à¹„ขช่วงของà¹à¸­à¸™à¸´à¹€à¸¡à¸Šà¸±à¸™"
#: editor/animation_track_editor.cpp
msgid "Rearrange Tracks"
@@ -391,7 +390,7 @@ msgstr "จัดเรียงà¹à¸—ร็à¸"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr ""
+msgstr "à¹à¸›à¸¥à¸‡à¹à¸—ร็à¸à¹€à¸‰à¸žà¸²à¸°à¸—ี่ Spatial-based nodes"
#: editor/animation_track_editor.cpp
msgid ""
@@ -504,9 +503,8 @@ msgid "Group tracks by node or display them as plain list."
msgstr ""
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Snap:"
-msgstr "จำà¸à¸±à¸”à¸à¸²à¸£à¹€à¸„ลื่อนย้าย"
+msgstr "สà¹à¸™à¸›:"
#: editor/animation_track_editor.cpp
#, fuzzy
@@ -825,7 +823,6 @@ msgstr "ไม่สามารถเชื่อมต่อสัà¸à¸à¸²à¸“
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1434,17 +1431,9 @@ msgstr "เปิด"
msgid "Rearrange Autoloads"
msgstr "จัดลำดับออโต้โหลด"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "ตำà¹à¸«à¸™à¹ˆà¸‡à¸œà¸´à¸”พลาด"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "ไม่พบไฟล์"
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "ไม่อยู่ในโฟลเดอร์รีซอร์ส"
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1940,7 +1929,7 @@ msgstr "ค่าเริ่มต้น:"
#: editor/editor_help.cpp
msgid "Methods"
-msgstr "รายชื่อเมท็อด"
+msgstr "เมท็อด"
#: editor/editor_help.cpp
msgid "Theme Properties"
@@ -2384,12 +2373,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "ฉาà¸à¸¢à¸±à¸‡à¹„ม่ได้บันทึภไม่สามารถโหลดใหม่ได้"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "คืนà¸à¸¥à¸±à¸š"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "บันทึà¸à¸‰à¸²à¸"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "à¸à¸²à¸£à¸„ืนà¸à¸¥à¸±à¸šà¹„ม่สามารถยà¸à¹€à¸¥à¸´à¸à¹„ด้ คืนà¸à¸¥à¸±à¸š?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2667,10 +2659,6 @@ msgid "Redo"
msgstr "ทำซ้ำ"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "คืนà¸à¸¥à¸±à¸šà¸‰à¸²à¸"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "โปรเจà¸à¸•à¹Œà¹à¸¥à¸°à¹€à¸„รื่องมืออื่น ๆ"
@@ -3288,6 +3276,11 @@ msgstr "รันสคริปต์ไม่ได้:"
msgid "Did you forget the '_run' method?"
msgstr "ลืมใส่เมท็อด '_run' หรือไม่?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr "à¸à¸” Ctrl ค้างเพื่อวาง Getter à¸à¸” Shift ค้างเพื่อวาง generic signature"
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "เลือà¸à¹‚หนดเพื่อนำเข้า"
@@ -3878,6 +3871,10 @@ msgid "Error running post-import script:"
msgstr "ผิดพลาดขณะรันสคริปต์หลังนำเข้า:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "à¸à¸³à¸¥à¸±à¸‡à¸šà¸±à¸™à¸—ึà¸..."
@@ -4636,9 +4633,8 @@ msgid "Set the end animation. This is useful for sub-transitions."
msgstr ""
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Transition: "
-msgstr "ทรานสิชัน"
+msgstr "ทรานสิชัน: "
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Play Mode:"
@@ -5270,9 +5266,8 @@ msgid "Create Custom Bone(s) from Node(s)"
msgstr "สร้างจุดปะทุจาภMesh"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Clear Bones"
-msgstr "ลบท่าทาง"
+msgstr "ลบโครง"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Make IK Chain"
@@ -5979,11 +5974,12 @@ msgid "Remove item %d?"
msgstr "ลบไอเทม %d?"
#: editor/plugins/mesh_library_editor_plugin.cpp
-#, fuzzy
msgid ""
"Update from existing scene?:\n"
"%s"
-msgstr "อัพเดตจาà¸à¸‰à¸²à¸"
+msgstr ""
+"อัพเดตจาà¸à¸‰à¸²à¸à¸—ี่มีอยู่หรือไม่\n"
+"%s"
#: editor/plugins/mesh_library_editor_plugin.cpp
#, fuzzy
@@ -6601,9 +6597,8 @@ msgid "Close and save changes?"
msgstr "ปิดà¹à¸¥à¸°à¸šà¸±à¸™à¸—ึà¸?"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error writing TextFile:"
-msgstr "ผิดพลาดขณะย้ายไฟล์:\n"
+msgstr "ผิดพลาดขณะย้ายไฟล์:"
#: editor/plugins/script_editor_plugin.cpp
#, fuzzy
@@ -6887,12 +6882,13 @@ msgstr "ลบà¸à¸²à¸£à¹€à¸Šà¸·à¹ˆà¸­à¸¡à¹‚ยง '%s' à¸à¸±à¸š '%s'"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
-msgid "Line"
-msgstr "บรรทัด:"
+msgid "[Ignore]"
+msgstr "(ละเว้น)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ละเว้น)"
+#, fuzzy
+msgid "Line"
+msgstr "บรรทัด:"
#: editor/plugins/script_text_editor.cpp
#, fuzzy
@@ -7080,13 +7076,12 @@ msgid "Go to Previous Breakpoint"
msgstr "ไปจุดพัà¸à¸à¹ˆà¸­à¸™à¸«à¸™à¹‰à¸²"
#: editor/plugins/shader_editor_plugin.cpp
-#, fuzzy
msgid ""
"This shader has been modified on on disk.\n"
"What action should be taken?"
msgstr ""
-"ไฟล์ต่อไปนี้ในดิสà¸à¹Œà¹ƒà¸«à¸¡à¹ˆà¸à¸§à¹ˆà¸²\n"
-"จะทำอย่างไรต่อไป?:"
+"เชดเดอร์ถูà¸à¹à¸à¹‰à¹„ขบนดิสà¸à¹Œ\n"
+"จะทำอย่างไรต่อไป?"
#: editor/plugins/shader_editor_plugin.cpp
msgid "Shader"
@@ -7393,6 +7388,15 @@ msgid "XForm Dialog"
msgstr "เครื่องมือเคลื่อนย้าย"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
#, fuzzy
msgid "Snap Nodes To Floor"
msgstr "จำà¸à¸±à¸”ด้วยเส้นตาราง"
@@ -8260,17 +8264,16 @@ msgid ""
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Remove selected texture? This will remove all tiles which use it."
-msgstr "ลบรายà¸à¸²à¸£"
+msgstr "ลบเทà¸à¹€à¸ˆà¸­à¸£à¹Œà¸«à¸£à¸·à¸­à¹„ม่ โดยจะลบไทล์ทุà¸à¸­à¸±à¸™à¸—ี่ใช้เทà¸à¹€à¸ˆà¸­à¸£à¹Œà¸™à¸µà¹‰"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "You haven't selected a texture to remove."
-msgstr ""
+msgstr "คุณยังไม่ได้เลือà¸à¹€à¸—à¸à¹€à¸ˆà¸­à¸£à¹Œà¸—ี่จะลบ"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Create from scene? This will overwrite all current tiles."
-msgstr ""
+msgstr "สร้างจาà¸à¸ªà¸à¸£à¸µà¸™ นี่จะสร้างทับไทล์เดิม"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Merge from scene?"
@@ -8291,16 +8294,16 @@ msgid ""
msgstr ""
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Delete selected Rect."
-msgstr "ลบไฟล์ที่เลือ�"
+msgstr "ลบสี่เหลี่ยมที่เลือà¸"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid ""
"Select current edited sub-tile.\n"
"Click on another Tile to edit it."
-msgstr "เลือà¸à¹„ทล์ย่อยที่à¸à¸³à¸¥à¸±à¸‡à¸›à¸£à¸±à¸šà¹à¸•à¹ˆà¸‡"
+msgstr ""
+"เลือà¸à¹„ทล์ย่อยอันปัจจุบันเพื่อปรับà¹à¸•à¹ˆà¸‡\n"
+"คลิà¸à¸—ี่ไทล์อันอื่นพื่อปรับà¹à¸•à¹ˆà¸‡"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Delete polygon."
@@ -8319,12 +8322,13 @@ msgstr ""
"คลิà¸à¹„ทล์อันอื่นเพื่อปรับà¹à¸•à¹ˆà¸‡"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid ""
"Select sub-tile to use as icon, this will be also used on invalid autotile "
"bindings.\n"
"Click on another Tile to edit it."
-msgstr "เลือà¸à¸£à¸¹à¸›à¸ à¸²à¸žà¸¢à¹ˆà¸­à¸¢à¹€à¸žà¸·à¹ˆà¸­à¸—ำเป็นไอคอน ภาพนี้จะใช้à¹à¸ªà¸”งเมื่อà¸à¸²à¸£"
+msgstr ""
+"เลือà¸à¹„ทล์ย่อยเพื่อใช้เป็นไอคอน สามารถใช้เมื่อ autotile bindings มีความผิดพลาด\n"
+"คลิà¸à¹„ทล์อันอื่นเพื่อà¹à¸à¹‰à¹„ขไทล์นั้น"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
@@ -8335,11 +8339,12 @@ msgstr ""
"คลิà¸à¹„ทล์อันอื่นเพื่อà¹à¸à¹‰à¹„ขไทล์นั้น"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid ""
"Select sub-tile to change its z index.\n"
"Click on another Tile to edit it."
-msgstr "เลือà¸à¹„ทล์ย่อยเพื่อจัดลำดับความสำคัà¸"
+msgstr ""
+"เลือà¸à¹„ทล์ย่อยเพื่อเปลี่ยน z index\n"
+"คลิà¸à¸—ี่ไทล์อื่นเพื่อà¹à¸à¹‰à¹„ขไทล์นั้น"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Set Tile Region"
@@ -9477,11 +9482,12 @@ msgid "Resources to export:"
msgstr "รีซอร์สที่จะส่งออà¸:"
#: editor/project_export.cpp
-#, fuzzy
msgid ""
"Filters to export non-resource files/folders\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
-msgstr "ตัวà¸à¸£à¸­à¸‡à¹„ฟล์ที่จะส่งออà¸à¹€à¸žà¸´à¹ˆà¸¡à¹€à¸•à¸´à¸¡ (คั่นด้วยจุลภาค ตัวอย่างเช่น: *.json, *.txt)"
+msgstr ""
+"ตัวà¸à¸£à¸­à¸‡à¹„ฟล์ที่จะส่งออà¸à¹€à¸žà¸´à¹ˆà¸¡à¹€à¸•à¸´à¸¡\n"
+"(คั่นด้วยจุลภาค ตัวอย่างเช่น: *.json, *.txt, docs/)"
#: editor/project_export.cpp
#, fuzzy
@@ -9499,9 +9505,8 @@ msgid "Make Patch"
msgstr "สร้างà¹à¸žà¸•à¸Šà¹Œ"
#: editor/project_export.cpp
-#, fuzzy
msgid "Pack File"
-msgstr " ไฟล์"
+msgstr "ไฟล์"
#: editor/project_export.cpp
msgid "Features"
@@ -10461,8 +10466,9 @@ msgid "Instance Child Scene"
msgstr "อินสà¹à¸•à¸™à¸‹à¹Œà¸‰à¸²à¸à¸¥à¸¹à¸"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "ลบสคริปต์"
+#, fuzzy
+msgid "Detach Script"
+msgstr "à¹à¸™à¸šà¸ªà¸„ริปต์"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10620,6 +10626,13 @@ msgid "Open Documentation"
msgstr "เปิดคู่มือ"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "เพิ่มโหนดลูà¸"
@@ -10666,11 +10679,13 @@ msgid ""
msgstr "อินสà¹à¸•à¸™à¸‹à¹Œà¸‰à¸²à¸à¹€à¸›à¹‡à¸™à¹‚หนด สร้างฉาà¸à¸ªà¸·à¸šà¸—อดถ้าไม่มีโหนดราà¸"
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "สร้างสคริปต์ให้โหนดที่เลือà¸"
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "ลบสคริปต์ของโหนดที่เลือà¸"
#: editor/scene_tree_dock.cpp
@@ -10810,6 +10825,10 @@ msgid "A directory with the same name exists."
msgstr "มีไดเรà¸à¸—อรีชื่อนี้อยู่à¹à¸¥à¹‰à¸§"
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "ไม่พบไฟล์"
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "นามสà¸à¸¸à¸¥à¹„ม่ถูà¸à¸•à¹‰à¸­à¸‡"
@@ -10853,6 +10872,10 @@ msgid "File exists, it will be reused."
msgstr "มีไฟล์นี้อยู่à¹à¸¥à¹‰à¸§ จะนำมาใช้"
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "ตำà¹à¸«à¸™à¹ˆà¸‡à¸œà¸´à¸”พลาด"
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "ชื่อคลาสไม่ถูà¸à¸•à¹‰à¸­à¸‡"
@@ -11894,6 +11917,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11917,6 +11944,32 @@ msgstr "ชื่อà¹à¸žà¹‡à¸„เà¸à¸ˆà¸œà¸´à¸”พลาด:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12631,6 +12684,21 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "ค่าคงที่ไม่สามารถà¹à¸à¹‰à¹„ขได้"
+#~ msgid "Not in resource path."
+#~ msgstr "ไม่อยู่ในโฟลเดอร์รีซอร์ส"
+
+#~ msgid "Revert"
+#~ msgstr "คืนà¸à¸¥à¸±à¸š"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "à¸à¸²à¸£à¸„ืนà¸à¸¥à¸±à¸šà¹„ม่สามารถยà¸à¹€à¸¥à¸´à¸à¹„ด้ คืนà¸à¸¥à¸±à¸š?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "คืนà¸à¸¥à¸±à¸šà¸‰à¸²à¸"
+
+#~ msgid "Clear Script"
+#~ msgstr "ลบสคริปต์"
+
#~ msgid "Issue Tracker"
#~ msgstr "ติดตามปัà¸à¸«à¸²"
diff --git a/editor/translations/tr.po b/editor/translations/tr.po
index fdb8f76605..277cc2c807 100644
--- a/editor/translations/tr.po
+++ b/editor/translations/tr.po
@@ -44,12 +44,15 @@
# Zsosu Ktosu <zktosu@gmail.com>, 2020.
# Mesut Aslan <kontinyu@gmail.com>, 2020.
# Kaan Genç <kaan@kaangenc.me>, 2020.
+# Anonymous <noreply@weblate.org>, 2020.
+# Güneş Gümüş <gunes.gumus.001@gmail.com>, 2020.
+# OÄŸuz Ersen <oguzersen@protonmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-04-23 20:21+0000\n"
-"Last-Translator: Anonymous <noreply@weblate.org>\n"
+"PO-Revision-Date: 2020-05-22 21:01+0000\n"
+"Last-Translator: Güneş Gümüş <gunes.gumus.001@gmail.com>\n"
"Language-Team: Turkish <https://hosted.weblate.org/projects/godot-engine/"
"godot/tr/>\n"
"Language: tr\n"
@@ -57,18 +60,16 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.0.2-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr ""
-"\"convert ()\" için geçersiz tür bağımsız değişkeni, \"TYPE_ *\" sabitlerini "
-"kullanın."
+msgstr "convert() için geçersiz türde argüman, TYPE_* sabitlerini kullanın."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "1 (karakter) uzunlukta metin bekleniyor."
+msgstr "1 uzunluÄŸunda bir metin (bir karakter) bekleniyor."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
@@ -354,7 +355,7 @@ msgstr "Döngü Aradeğerlemesin Sar"
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key"
-msgstr "Yeni Anahtar"
+msgstr "Anahtar Ekle"
#: editor/animation_track_editor.cpp
msgid "Duplicate Key(s)"
@@ -532,12 +533,12 @@ msgstr ""
"Bu animasyon içe aktarılmış bir sahneye ait, bu yüzden içe aktarılan "
"parçalara yapılan değişiklikler kaydedilmeyecek.\n"
"\n"
-"Özel parça ekleme özelliğini aktif etmek için, sahnenin içe aktarma "
-"ayarlarına gidin ve \"Animasyon > Depolama\" ayarını \"Dosyalama\" olarak "
-"ayarlayın, \"Animasyon > Özel Parçaları Sakla\"ayarını aktif edin ve sonra "
-"tekrar içe aktarın.\n"
-"Alternatif olarak, animasyonları ayrı dosyalara aktaran bir içe aktarma "
-"hazır ayarı kullanabilirsiniz."
+"Özel parça ekleme özelliğini etkinleştirmek için, sahnenin içe aktarma "
+"ayarlarına gidin ve \"Animasyon > Depolama\"\n"
+"ayarını \"Dosyalama\" olarak ayarlayın, \"Animasyon > Özel Parçaları Sakla\" "
+"ayarını etkinleştirin ve sonra tekrar içe aktarın.\n"
+"Alternatif olarak, animasyonları ayrı dosyalara aktaran bir içe aktarma ön "
+"ayarı kullanabilirsiniz."
#: editor/animation_track_editor.cpp
msgid "Warning: Editing imported animation"
@@ -878,7 +879,6 @@ msgstr "Sinyale bağlanamıyor"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -899,7 +899,7 @@ msgstr "Sinyal:"
#: editor/connections_dialog.cpp
msgid "Connect '%s' to '%s'"
-msgstr "Bunu '%s' ÅŸuna '%s' baÄŸla"
+msgstr "'%s' sinyalini '%s' yöntemine bağla"
#: editor/connections_dialog.cpp
msgid "Disconnect '%s' from '%s'"
@@ -1216,7 +1216,7 @@ msgstr ""
#: editor/editor_about.cpp
msgid "All Components"
-msgstr "Tüm Bileşenler"
+msgstr "Tüm Bileşenler"
#: editor/editor_about.cpp
msgid "Components"
@@ -1490,17 +1490,9 @@ msgstr "Etkin"
msgid "Rearrange Autoloads"
msgstr "KendindenYüklenme'leri Yeniden Sırala"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Geçersiz yol."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Dosya yok."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Kaynak yolunda deÄŸil."
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1726,7 +1718,7 @@ msgstr ""
#: editor/editor_feature_profile.cpp
msgid "Error saving profile to path: '%s'."
-msgstr "Profil yolu kaydetme hatası: '%s'."
+msgstr "Profil '%s' yoluna kaydedilirken hata oluÅŸtu."
#: editor/editor_feature_profile.cpp
msgid "Unset"
@@ -2432,7 +2424,7 @@ msgstr "Bu işlem bir sahne olmadan yapılamaz."
#: editor/editor_node.cpp
msgid "Export Mesh Library"
-msgstr "Örüntü Betikevini Dışa Aktar"
+msgstr "Örüntü Kütüphanesini Dışa Aktar"
#: editor/editor_node.cpp
msgid "This operation can't be done without a root node."
@@ -2455,12 +2447,15 @@ msgid "Can't reload a scene that was never saved."
msgstr "Hiç kaydedilmemiş bir sahne yeniden yüklenemiyor."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "Geri dön"
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "Sahne Kaydet"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Bu eylem geri alınamaz. Yine de geri dönsün mü?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2484,7 +2479,7 @@ msgstr "Kaydet & Çık"
#: editor/editor_node.cpp
msgid "Save changes to the following scene(s) before quitting?"
-msgstr "Çıkmadan önce değişiklikler aşağıdaki sahneye(lere) kaydedilsin mi?"
+msgstr "Çıkmadan önce değişiklikler aşağıdaki sahne(ler)e kaydedilsin mi?"
#: editor/editor_node.cpp
msgid "Save changes the following scene(s) before opening Project Manager?"
@@ -2497,8 +2492,8 @@ msgid ""
"This option is deprecated. Situations where refresh must be forced are now "
"considered a bug. Please report."
msgstr ""
-"Bu seçenek artık kullanılmıyor. Yenilemeye zorlayan durumlar bug olarak "
-"değerlendirilir. Lütfen bildirin."
+"Bu seçenek artık kullanılmıyor. Yenilemenin zorlanması gereken durumlar "
+"artık hata olarak değerlendiriliyor. Lütfen bildirin."
#: editor/editor_node.cpp
msgid "Pick a Main Scene"
@@ -2739,16 +2734,12 @@ msgstr "TileSet ..."
#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Undo"
-msgstr "Geri"
+msgstr "Geri al"
#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Redo"
-msgstr "Geri"
-
-#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Sahneyi Eski Durumuna Çevir"
+msgstr "Yeniden yap"
#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
@@ -2913,7 +2904,7 @@ msgstr "Ekran Görüntüleri Düzenleyici Verileri/Ayarları Klasöründe saklan
#: editor/editor_node.cpp
msgid "Toggle Fullscreen"
-msgstr "Tam Ekran Aç / Kapat"
+msgstr "Tam Ekranı Aç/Kapat"
#: editor/editor_node.cpp
msgid "Toggle System Console"
@@ -3077,8 +3068,14 @@ msgid ""
"the \"Use Custom Build\" option should be enabled in the Android export "
"preset."
msgstr ""
-"Bu, kaynak şablonlarını \"res://android/build\" yoluna yükleyerek, projenizi "
-"isteğe dayalı Android inşasına ayarlayacaktır."
+"Bu, kaynak şablonunu \"res://android/build\" dizinine kurarak projenizi özel "
+"Android derlemeleri için ayarlayacaktır.\n"
+"Daha sonra dışa aktarırken değişiklikleri uygulayabilir ve kendi özel "
+"APK'nızı oluşturabilirsiniz (modül ekleme, AndroidManifest.xml dosyasını "
+"deÄŸiÅŸtirme vb.).\n"
+"Önceden oluşturulmuş APK'ları kullanmak yerine özel derlemeler yapmak için "
+"Android dışa aktarma ön ayarında \"Özel Derleme Kullan\" seçeneğinin "
+"etkinleştirilmesi gerektiğini unutmayın."
#: editor/editor_node.cpp
msgid ""
@@ -3125,11 +3122,11 @@ msgstr "Seç"
#: editor/editor_node.cpp
msgid "Open 2D Editor"
-msgstr "Düzenleyicide Aç"
+msgstr "2B Düzenleyiciyi Aç"
#: editor/editor_node.cpp
msgid "Open 3D Editor"
-msgstr "3B Düzenleyicide Aç"
+msgstr "3B Düzenleyiciyi Aç"
#: editor/editor_node.cpp
msgid "Open Script Editor"
@@ -3250,7 +3247,7 @@ msgstr "Katman"
#: editor/editor_properties.cpp
msgid "Bit %d, value %d"
-msgstr "Bit %d, deÄŸer %d"
+msgstr "Bit %d, deÄŸer %d"
#: editor/editor_properties.cpp
msgid "[Empty]"
@@ -3392,6 +3389,13 @@ msgstr "Betik çalıştırılamadı:"
msgid "Did you forget the '_run' method?"
msgstr "'_run()' metodunu unuttunuz mu?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Alıcı bırakmak için Ctrl'e basılı tutun. Genel imza bırakmak için Shift'e "
+"basılı tutun."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Düğüm(leri) içe Aktarmak için Seç"
@@ -3990,6 +3994,10 @@ msgid "Error running post-import script:"
msgstr "sonradan-içe aktarılmış betik çalıştırılırken hata:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Kaydediliyor..."
@@ -4444,7 +4452,7 @@ msgstr "Süzgeçlenmiş Parçaları Düzenle:"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "Enable Filtering"
-msgstr "Süzgeçlemeyi Aç"
+msgstr "Süzgeçlemeyi Aç"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Toggle Autoplay"
@@ -5384,7 +5392,7 @@ msgstr ""
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom Reset"
-msgstr "Yakınlaşmayı Sıfırla"
+msgstr "Yakınlaştırmayı Sıfırla"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5839,7 +5847,7 @@ msgstr "Eğri Doğrusal Tanjantını Aç/Kapa"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Hold Shift to edit tangents individually"
-msgstr "Tanjantları tek tek düzenlemek için Shift'e basılı tut"
+msgstr "Tanjantları bireysel olarak düzenlemek için Shift tuşuna basılı tutun"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Right click to add point"
@@ -5875,7 +5883,7 @@ msgstr "Örüntü boş!"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Couldn't create a Trimesh collision shape."
-msgstr "Trimesh çarpışma şekli oluşturulamadı."
+msgstr "Üçlü Örüntü çarpışma yüzeyi oluşturulamadı."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Static Trimesh Body"
@@ -5911,7 +5919,7 @@ msgstr "Herhangi bir çarpışma şekli oluşturulamadı."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Multiple Convex Shapes"
-msgstr "Dışbükey Şekilleri Oluştur"
+msgstr "Çoklu Dışbükey Şekiller Oluştur"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Navigation Mesh"
@@ -6934,12 +6942,13 @@ msgstr ""
"'%s' düğümünden '%s' düğümüne, '%s' sinyali için '%s' bağlantı metodu eksik."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "Satır"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(gözardı et)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(gözardı et)"
+msgid "Line"
+msgstr "Satır"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7413,6 +7422,15 @@ msgid "XForm Dialog"
msgstr "XForm Ä°letiÅŸim Kutusu"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Düğümleri zemine hizala"
@@ -9927,6 +9945,9 @@ msgid ""
"To filter projects by name and full path, the query must contain at least "
"one `/` character."
msgstr ""
+"Arama kutusu, projeleri adına ve son yol bileşenine göre filtreler.\n"
+"Projeleri adına ve tam yoluna göre filtrelemek için, sorgunun en az bir `/` "
+"karakteri içermesi gereklidir."
#: editor/project_settings_editor.cpp
msgid "Key "
@@ -10081,7 +10102,7 @@ msgstr "'%s' özelliği mevcut değil."
#: editor/project_settings_editor.cpp
msgid "Setting '%s' is internal, and it can't be deleted."
-msgstr "Ayar '%s' dahilidir silinemez."
+msgstr "'%s' ayarı dahilidir ve silinemez."
#: editor/project_settings_editor.cpp
msgid "Delete Item"
@@ -10290,7 +10311,7 @@ msgstr "Bir Düğüm Seç"
#: editor/property_editor.cpp
msgid "Bit %d, val %d."
-msgstr "Bit %d, val %d."
+msgstr "Bit %d, deÄŸer %d."
#: editor/property_selector.cpp
msgid "Select Property"
@@ -10425,9 +10446,8 @@ msgid "Regular Expression Error"
msgstr "Düzenli İfade Hatası"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "At character %s"
-msgstr "Geçerli karakterler:"
+msgstr "%s karakterinde"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
msgid "Reparent Node"
@@ -10494,8 +10514,9 @@ msgid "Instance Child Scene"
msgstr "Çocuk Sahnesini Örnekle"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "BetiÄŸi Temizle"
+#, fuzzy
+msgid "Detach Script"
+msgstr "Betik Ä°liÅŸtir"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10660,6 +10681,13 @@ msgid "Open Documentation"
msgstr "Klavuzu Aç"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Çocuk Düğüm Ekle"
@@ -10708,11 +10736,13 @@ msgstr ""
"alınmış bir sahne oluşturur."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Seçili düğüm için yeni veya mevcut bir betik iliştir."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Seçilen düğüm için betik temizle."
#: editor/scene_tree_dock.cpp
@@ -10844,6 +10874,10 @@ msgid "A directory with the same name exists."
msgstr "Aynı isimde dizin zaten var."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Dosya yok."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Geçersiz uzantı."
@@ -10884,6 +10918,10 @@ msgid "File exists, it will be reused."
msgstr "Dosya mevcut, yeniden kullanılacak."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Geçersiz yol."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Geçersiz sınıf ismi."
@@ -11044,9 +11082,8 @@ msgid "Total:"
msgstr "Toplam:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Export list to a CSV file"
-msgstr "Profil Dışa Aktar"
+msgstr "Listeyi CSV dosyasına aktar"
#: editor/script_editor_debugger.cpp
msgid "Resource Path"
@@ -11928,6 +11965,13 @@ msgstr ""
"yapılandırılmamış."
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"Anahtar deposunda Hata Ayıklayıcı Ayarları'nda veya ön ayarda "
+"yapılandırılmamış."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Özel derleme için Editör Ayarları'nda geçerli bir Android SDK yolu gerekir."
@@ -11953,6 +11997,32 @@ msgstr "Geçersiz paket ismi:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12733,6 +12803,21 @@ msgstr "varyings yalnızca vertex işlevinde atanabilir."
msgid "Constants cannot be modified."
msgstr "Sabit deÄŸerler deÄŸiÅŸtirilemez."
+#~ msgid "Not in resource path."
+#~ msgstr "Kaynak yolunda deÄŸil."
+
+#~ msgid "Revert"
+#~ msgstr "Geri dön"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Bu eylem geri alınamaz. Yine de geri dönsün mü?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Sahneyi Eski Durumuna Çevir"
+
+#~ msgid "Clear Script"
+#~ msgstr "BetiÄŸi Temizle"
+
#~ msgid "Issue Tracker"
#~ msgstr "Sorun Ä°zleyici"
diff --git a/editor/translations/uk.po b/editor/translations/uk.po
index e713e79a4c..75cce04e0e 100644
--- a/editor/translations/uk.po
+++ b/editor/translations/uk.po
@@ -13,11 +13,12 @@
# ÐлекÑандр <ol-vin@mail.ru>, 2018.
# Богдан Матвіїв <bomtvv@gmail.com>, 2019.
# Tymofij Lytvynenko <till.svit@gmail.com>, 2020.
+# Vladislav Glinsky <cl0ne@mithril.org.ua>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Ukrainian (Godot Engine)\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-05-01 11:43+0000\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
"Language-Team: Ukrainian <https://hosted.weblate.org/projects/godot-engine/"
"godot/uk/>\n"
@@ -27,24 +28,24 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
msgstr ""
-"Ðекоректний тип аргументу Ð´Ð»Ñ convert(), Ñлід викориÑтовувати конÑтанту "
+"Ðекоректний тип аргументу Ð´Ð»Ñ convert(), Ñлід викориÑтовувати конÑтанти "
"TYPE_*."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "Мало бути вказано Ñ€Ñдок довжини 1 (Ñимвол)."
+msgstr "ОчікувавÑÑ Ñ€Ñдок довжиною 1 (Ñимвол)."
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr "ÐедоÑтатньо байтів Ð´Ð»Ñ Ð´ÐµÐºÐ¾Ð´ÑƒÐ²Ð°Ð½Ð½Ñ Ð°Ð±Ð¾ вказано некоректний формат."
+msgstr "ÐедоÑтатньо байтів Ð´Ð»Ñ Ñ—Ñ… Ð´ÐµÐºÐ¾Ð´ÑƒÐ²Ð°Ð½Ð½Ñ Ð°Ð±Ð¾ вказано некоректний формат."
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
@@ -53,7 +54,8 @@ msgstr "Ðекоректні вхідні дані %i (не передано) у
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
msgstr ""
-"не можна викориÑтовувати self, оÑкільки екземплÑÑ€ Ñ” порожнім (не передано)"
+"неможливо викориÑтовувати self, оÑкільки екземплÑÑ€ має Ð·Ð½Ð°Ñ‡ÐµÐ½Ð½Ñ null (не "
+"передано)"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
@@ -65,15 +67,15 @@ msgstr "Ðекоректний Ñ–Ð½Ð´ÐµÐºÑ Ñ‚Ð¸Ð¿Ñƒ %s Ð´Ð»Ñ Ð±Ð°Ð·Ð¾Ð²Ð¾Ð³Ð¾
#: core/math/expression.cpp
msgid "Invalid named index '%s' for base type %s"
-msgstr "Ðекоректний іменований Ñ–Ð½Ð´ÐµÐºÑ Â«%s» Ð´Ð»Ñ Ð±Ð°Ð·Ð¾Ð²Ð¾Ð³Ð¾ типу %s"
+msgstr "Ðекоректний іменований Ñ–Ð½Ð´ÐµÐºÑ \"%s\" Ð´Ð»Ñ Ð±Ð°Ð·Ð¾Ð²Ð¾Ð³Ð¾ типу %s"
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr "Ðекоректні аргументи Ð´Ð»Ñ Ð¿Ð¾Ð±ÑƒÐ´Ð¾Ð²Ð¸ «%s»"
+msgstr "Ðекоректні аргументи Ð´Ð»Ñ ÑÑ‚Ð²Ð¾Ñ€ÐµÐ½Ð½Ñ \"%s\""
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr "При виклику «%s»:"
+msgstr "При виклику \"%s\":"
#: core/ustring.cpp
msgid "B"
@@ -105,15 +107,15 @@ msgstr "ЕіБ"
#: editor/animation_bezier_editor.cpp
msgid "Free"
-msgstr "Вивільнити"
+msgstr "Вільні"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
-msgstr "ЗбаланÑована"
+msgstr "БаланÑовані"
#: editor/animation_bezier_editor.cpp
msgid "Mirror"
-msgstr "Віддзеркалити"
+msgstr "Віддзеркалені"
#: editor/animation_bezier_editor.cpp editor/editor_profiler.cpp
msgid "Time:"
@@ -125,7 +127,7 @@ msgstr "ЗначеннÑ:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr "Тут Ñлід вÑтавити ключ"
+msgstr "Ð’Ñтавити ключ тут"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
@@ -574,7 +576,7 @@ msgstr "МаÑштаб від курÑору"
#: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp
msgid "Duplicate Selection"
-msgstr "Дублювати виділене"
+msgstr "Дублювати позначене"
#: editor/animation_track_editor.cpp
msgid "Duplicate Transposed"
@@ -854,7 +856,6 @@ msgstr "Ðе вдалоÑÑ Ð·'єднати Ñигнал"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1212,7 +1213,7 @@ msgstr "%s (вже Ñ–Ñнує)"
#: editor/editor_asset_installer.cpp
msgid "Uncompressing Assets"
-msgstr "Ð Ð¾Ð·Ð¿Ð°ÐºÐ¾Ð²ÑƒÐ²Ð°Ð½Ð½Ñ Ð°ÐºÑ‚Ð¸Ð²Ñ–Ð²"
+msgstr "Ð Ð¾Ð·Ð¿Ð°ÐºÐ¾Ð²ÑƒÐ²Ð°Ð½Ð½Ñ Ñ€ÐµÑурÑів"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -1448,7 +1449,7 @@ msgstr "Перейменувати автозавантаженнÑ"
#: editor/editor_autoload_settings.cpp
msgid "Toggle AutoLoad Globals"
-msgstr "Увімкнути Ð°Ð²Ñ‚Ð¾Ð·Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ð³Ð»Ð¾Ð±Ð°Ð»ÑŒÐ½Ð¸Ñ… Ñкриптів"
+msgstr "Увімкнути Ð°Ð²Ñ‚Ð¾Ð·Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ð³Ð»Ð¾Ð±Ð°Ð»ÑŒÐ½Ð¸Ñ… Ñкриптів"
#: editor/editor_autoload_settings.cpp
msgid "Move Autoload"
@@ -1460,23 +1461,15 @@ msgstr "Видалити автозавантаженнÑ"
#: editor/editor_autoload_settings.cpp editor/editor_plugin_settings.cpp
msgid "Enable"
-msgstr "Ðктивувати"
+msgstr "Увімкнути"
#: editor/editor_autoload_settings.cpp
msgid "Rearrange Autoloads"
msgstr "Змінити порÑдок автозавантажень"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "Ðеправильний шлÑÑ…."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Файл не Ñ–Ñнує."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "Ðе в реÑурÑному шлÑху."
+msgid "Can't add autoload:"
+msgstr "Ðе вдалоÑÑ Ð´Ð¾Ð´Ð°Ñ‚Ð¸ автозавантаженнÑ:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1628,7 +1621,7 @@ msgstr "Редактор Ñкриптів"
#: editor/editor_feature_profile.cpp
msgid "Asset Library"
-msgstr "Бібліотека активів"
+msgstr "Бібліотека реÑурÑів"
#: editor/editor_feature_profile.cpp
msgid "Scene Tree Editing"
@@ -1934,7 +1927,7 @@ msgstr ""
#: editor/editor_file_system.cpp
msgid "(Re)Importing Assets"
-msgstr "Ð†Ð¼Ð¿Ð¾Ñ€Ñ‚ÑƒÐ²Ð°Ð½Ð½Ñ Ð°ÐºÑ‚Ð¸Ð²Ñ–Ð²"
+msgstr "Ð†Ð¼Ð¿Ð¾Ñ€Ñ‚ÑƒÐ²Ð°Ð½Ð½Ñ Ñ€ÐµÑурÑів"
#: editor/editor_help.cpp editor/plugins/spatial_editor_plugin.cpp
msgid "Top"
@@ -2434,12 +2427,17 @@ msgid "Can't reload a scene that was never saved."
msgstr "Ðеможливо перезавантажити Ñцену, Ñку ніколи не зберігали."
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "ПовернутиÑÑ"
+msgid "Reload Saved Scene"
+msgstr "ÐŸÐµÑ€ÐµÐ·Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ð·Ð±ÐµÑ€ÐµÐ¶ÐµÐ½Ð¾Ñ— Ñцени"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Цю дію не можна ÑкаÑувати. ПовернутиÑÑ Ð² будь-Ñкому випадку?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"Зміни до поточної Ñцени не збережено.\n"
+"Перезавантажити збережену Ñцену попри це? ÐаÑлідки Ð¿ÐµÑ€ÐµÐ·Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ð½Ðµ можна "
+"буде ÑкаÑувати."
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2493,8 +2491,8 @@ msgstr "Повторно відкрити закриту Ñцену"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
msgstr ""
-"Ðе вдаєтьÑÑ Ð²Ð²Ñ–Ð¼ÐºÐ½ÑƒÑ‚Ð¸ плагін addon: '%s' не вдалоÑÑ Ð¿Ñ€Ð¾Ð°Ð½Ð°Ð»Ñ–Ð·ÑƒÐ²Ð°Ñ‚Ð¸ "
-"Ð½Ð°Ð»Ð°ÑˆÑ‚ÑƒÐ²Ð°Ð½Ð½Ñ ÐºÐ¾Ð½Ñ„Ñ–Ð³ÑƒÑ€Ð°Ñ†Ñ–Ñ—."
+"Ðе вдалоÑÑ Ð²Ð²Ñ–Ð¼ÐºÐ½ÑƒÑ‚Ð¸ додаток addon: «%s» не вдалоÑÑ Ð¿Ñ€Ð¾Ð°Ð½Ð°Ð»Ñ–Ð·ÑƒÐ²Ð°Ñ‚Ð¸ "
+"налаштуваннÑ."
#: editor/editor_node.cpp
msgid "Unable to find script field for addon plugin at: 'res://addons/%s'."
@@ -2730,10 +2728,6 @@ msgid "Redo"
msgstr "Повернути"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "Повернути Ñцену"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "Різні проєктні або Ñценографічні інÑтрументи."
@@ -3126,7 +3120,7 @@ msgstr "Відкрити редактор Ñкриптів"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
-msgstr "Відкрити бібліотеку активів"
+msgstr "Відкрити бібліотеку реÑурÑів"
#: editor/editor_node.cpp
msgid "Open the next Editor"
@@ -3381,6 +3375,12 @@ msgstr "Ðе вдалоÑÑ Ð·Ð°Ð¿ÑƒÑтити Ñкрипт:"
msgid "Did you forget the '_run' method?"
msgstr "Ви забули метод '_run'?"
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+"Утримуйте натиÑнутою Ctrl, щоб заокруглити до цілих. Утримуйте натиÑнутою "
+"Shift, щоб зміни були точнішими."
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Виберіть вузол(вузли) Ð´Ð»Ñ Ñ–Ð¼Ð¿Ð¾Ñ€Ñ‚Ñƒ"
@@ -3977,6 +3977,10 @@ msgid "Error running post-import script:"
msgstr "Помилка запуÑку піÑÐ»Ñ Ñ–Ð¼Ð¿Ð¾Ñ€Ñ‚Ñƒ Ñкрипту:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr "Повернули об'єкт, що походить від Node, у методі «post_import()»?"
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "ЗбереженнÑ..."
@@ -4016,8 +4020,8 @@ msgstr "Зміна типу імпортованого файла потребу
msgid ""
"WARNING: Assets exist that use this resource, they may stop loading properly."
msgstr ""
-"Увага: Ñ–Ñують об'єкти, Ñкі викориÑтовують цей реÑурÑ, — вони можуть "
-"припинити завантажуватиÑÑ Ð½Ð°Ð»ÐµÐ¶Ð½Ð¸Ð¼ чином."
+"УВÐГÐ: Ñ–Ñнують об'єкти, що викориÑтовують цей реÑÑƒÑ€Ñ Ñ‚Ð° можуть припинити "
+"завантажуватиÑÑ Ð½Ð°Ð»ÐµÐ¶Ð½Ð¸Ð¼ чином."
#: editor/inspector_dock.cpp
msgid "Failed to load resource."
@@ -4958,7 +4962,7 @@ msgstr "Помилка перевірки Ñ…ÐµÑˆÑƒÐ²Ð°Ð½Ð½Ñ sha256"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Asset Download Error:"
-msgstr "Помилка Ð·Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ð°ÐºÑ‚Ð¸Ð²Ñƒ:"
+msgstr "Помилка Ð·Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ñ€ÐµÑурÑу:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Downloading (%s / %s)..."
@@ -4994,7 +4998,7 @@ msgstr "Помилка завантаженнÑ"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Download for this asset is already in progress!"
-msgstr "Ð—Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ñ†ÑŒÐ¾Ð³Ð¾ активу вже виконуєтьÑÑ!"
+msgstr "Ð—Ð°Ð²Ð°Ð½Ñ‚Ð°Ð¶ÐµÐ½Ð½Ñ Ñ†ÑŒÐ¾Ð³Ð¾ реÑурÑу вже виконуєтьÑÑ!"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Recently Updated"
@@ -5083,7 +5087,7 @@ msgstr "ЗавантаженнÑ…"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Assets ZIP File"
-msgstr "ZIP файл активів"
+msgstr "ZIP файл реÑурÑів"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
msgid ""
@@ -6933,12 +6937,12 @@ msgstr ""
"«%s»."
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "РÑдок"
+msgid "[Ignore]"
+msgstr "[Ігнорувати]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(ігнорувати)"
+msgid "Line"
+msgstr "РÑдок"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7414,6 +7418,20 @@ msgid "XForm Dialog"
msgstr "Вікно XForm"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"Клацніть Ð´Ð»Ñ Ð¿ÐµÑ€ÐµÐ¼Ð¸ÐºÐ°Ð½Ð½Ñ Ð¼Ñ–Ð¶ Ñтанами видимоÑÑ‚Ñ–.\n"
+"\n"
+"Відкрите око: Gizmo є видимим.\n"
+"Закрите око: Gizmo приховано.\n"
+"Ðапівзакрите око: Gizmo Ñ” також видимим крізь непрозорі поверхні («рентген»)."
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Приліпити вузли до підлоги"
@@ -9835,8 +9853,9 @@ msgid ""
"Can't run project: Assets need to be imported.\n"
"Please edit the project to trigger the initial import."
msgstr ""
-"Ðе вдалоÑÑ Ð·Ð°Ð¿ÑƒÑтити проєкт: Ñлід імпортувати вміÑÑ‚.\n"
-"Будь лаÑка, змініть проєкт так, щоб увімкнути початкове імпортуваннÑ."
+"Ðе вдалоÑÑ Ð·Ð°Ð¿ÑƒÑтити проєкт: Ñлід імпортувати реÑурÑи.\n"
+"Будь лаÑка, відкрийте проєкт на редагуваннÑ, щоб запуÑтити початкове "
+"імпортуваннÑ."
#: editor/project_manager.cpp
msgid "Are you sure to run %d projects at once?"
@@ -9928,8 +9947,8 @@ msgid ""
"You currently don't have any projects.\n"
"Would you like to explore official example projects in the Asset Library?"
msgstr ""
-"Зараз проєктів немає.\n"
-"Хочете вивчити проєкти офіційних прикладів з бібліотеки даних?"
+"Ðаразі у Ð²Ð°Ñ Ð½ÐµÐ¼Ð°Ñ” проєктів.\n"
+"Бажаєте переглÑнути офіційні приклади проєктів з бібліотеки реÑурÑів?"
#: editor/project_manager.cpp
msgid ""
@@ -10508,8 +10527,8 @@ msgid "Instance Child Scene"
msgstr "Створити екземплÑÑ€ дочірньої Ñцени"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "Вилучити Ñкрипт"
+msgid "Detach Script"
+msgstr "Від'єднати Ñкрипт"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10674,6 +10693,16 @@ msgid "Open Documentation"
msgstr "Відкрити документацію"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+"Ðе вдалоÑÑ Ð´Ð¾Ð»ÑƒÑ‡Ð¸Ñ‚Ð¸ Ñкрипт: не зареєÑтровано жодної мови.\n"
+"Ймовірно, причиною Ñ” те, що цей редактор було зібрано із вимкненими модулÑми "
+"уÑÑ–Ñ… мов."
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Додати дочірній вузол"
@@ -10722,12 +10751,12 @@ msgstr ""
"кореневого вузла не Ñ–Ñнує."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr "Долучити новий або наÑвний Ñкрипт до позначеного вузла."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr "Вилучити Ñкрипт Ð´Ð»Ñ Ð¿Ð¾Ð·Ð½Ð°Ñ‡ÐµÐ½Ð¾Ð³Ð¾ вузла."
+msgid "Detach the script from the selected node."
+msgstr "Від'єднати Ñкрипт від позначеного вузла."
#: editor/scene_tree_dock.cpp
msgid "Remote"
@@ -10858,6 +10887,10 @@ msgid "A directory with the same name exists."
msgstr "Каталог із такою назвою вже Ñ–Ñнує."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Файл не Ñ–Ñнує."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "Ðекоректний ÑуфікÑ."
@@ -10898,6 +10931,10 @@ msgid "File exists, it will be reused."
msgstr "Файл вже Ñ–Ñнує, його буде викориÑтано повторно."
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "Ðеправильний шлÑÑ…."
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "Ðекоректна назва клаÑу."
@@ -11948,6 +11985,11 @@ msgstr ""
"ключів."
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+"У шаблоні екÑÐ¿Ð¾Ñ€Ñ‚ÑƒÐ²Ð°Ð½Ð½Ñ Ð½ÐµÐ¿Ñ€Ð°Ð²Ð¸Ð»ÑŒÐ½Ð¾ налаштовано Ñховище ключів випуÑку."
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
"Ðетипове Ð·Ð±Ð¸Ñ€Ð°Ð½Ð½Ñ Ð¿Ð¾Ñ‚Ñ€ÐµÐ±ÑƒÑ” коректного шлÑху до SDK Ð´Ð»Ñ Android у параметрах "
@@ -11977,6 +12019,42 @@ msgstr "Ðекоректна назва пакунка:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"Ðекоректний модуль «GodotPaymentV3» включено до параметрів проєкту «android/"
+"modules» (змінено у Godot 3.2.2).\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+"Щоб можна було кориÑтуватиÑÑ Ð´Ð¾Ð´Ð°Ñ‚ÐºÐ°Ð¼Ð¸, Ñлід позначити пункт "
+"«ВикориÑтовувати нетипову збірку»."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"«.Степені Ñвободи» працюють, лише Ñкщо «Режим Xr» має Ð·Ð½Ð°Ñ‡ÐµÐ½Ð½Ñ Â«Oculus "
+"Mobile VR»."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"«СтеженнÑм за руками» можна ÑкориÑтатиÑÑ, лише Ñкщо «Режим Xr» дорівнює "
+"«Oculus Mobile VR»."
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"«ВрахуваннÑм фокуÑа» можна ÑкориÑтатиÑÑ, лише Ñкщо «Режим Xr» дорівнює "
+"«Oculus Mobile VR»."
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12772,6 +12850,21 @@ msgstr "Змінні величини можна пов'Ñзувати лише
msgid "Constants cannot be modified."
msgstr "Сталі не можна змінювати."
+#~ msgid "Not in resource path."
+#~ msgstr "Ðе в реÑурÑному шлÑху."
+
+#~ msgid "Revert"
+#~ msgstr "ПовернутиÑÑ"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Цю дію не можна ÑкаÑувати. ПовернутиÑÑ Ð² будь-Ñкому випадку?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "Повернути Ñцену"
+
+#~ msgid "Clear Script"
+#~ msgstr "Вилучити Ñкрипт"
+
#~ msgid "Issue Tracker"
#~ msgstr "ВідÑÑ‚ÐµÐ¶ÐµÐ½Ð½Ñ Ð¿Ð¾Ð¼Ð¸Ð»Ð¾Ðº"
diff --git a/editor/translations/ur_PK.po b/editor/translations/ur_PK.po
index 432a8d1137..10558ad98e 100644
--- a/editor/translations/ur_PK.po
+++ b/editor/translations/ur_PK.po
@@ -829,7 +829,6 @@ msgstr ".تمام کا انتخاب"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1437,18 +1436,9 @@ msgstr ""
msgid "Rearrange Autoloads"
msgstr ""
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr ""
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr ""
-
#: editor/editor_autoload_settings.cpp
-#, fuzzy
-msgid "Not in resource path."
-msgstr ".ÛŒÛ Ø±ÛŒØ³ÙˆØ±Ø³ Ùائل پر مبنی Ù†ÛÛŒ ÛÛ’"
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -2390,11 +2380,14 @@ msgid "Can't reload a scene that was never saved."
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "سب سکریپشن بنائیں"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2664,10 +2657,6 @@ msgid "Redo"
msgstr ""
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3282,6 +3271,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr ""
@@ -3882,6 +3875,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr ""
@@ -6829,11 +6826,11 @@ msgid ""
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
+msgid "[Ignore]"
msgstr ""
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
+msgid "Line"
msgstr ""
#: editor/plugins/script_text_editor.cpp
@@ -7312,6 +7309,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10312,7 +10318,7 @@ msgstr ""
#: editor/scene_tree_dock.cpp
#, fuzzy
-msgid "Clear Script"
+msgid "Detach Script"
msgstr "سب سکریپشن بنائیں"
#: editor/scene_tree_dock.cpp
@@ -10475,6 +10481,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10523,11 +10536,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -10651,6 +10664,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr ""
@@ -10692,6 +10709,10 @@ msgid "File exists, it will be reused."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr ""
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr ""
@@ -11755,6 +11776,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11778,6 +11803,32 @@ msgstr ""
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12420,6 +12471,14 @@ msgid "Constants cannot be modified."
msgstr ""
#, fuzzy
+#~ msgid "Not in resource path."
+#~ msgstr ".ÛŒÛ Ø±ÛŒØ³ÙˆØ±Ø³ Ùائل پر مبنی Ù†ÛÛŒ ÛÛ’"
+
+#, fuzzy
+#~ msgid "Clear Script"
+#~ msgstr "سب سکریپشن بنائیں"
+
+#, fuzzy
#~ msgid "Class Description"
#~ msgstr "سب سکریپشن بنائیں"
diff --git a/editor/translations/vi.po b/editor/translations/vi.po
index a52a3dedf3..fe846d5e08 100644
--- a/editor/translations/vi.po
+++ b/editor/translations/vi.po
@@ -846,7 +846,6 @@ msgstr "Không thể kết nối tín hiệu"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1463,17 +1462,8 @@ msgstr "Mở"
msgid "Rearrange Autoloads"
msgstr "Sắp xếp lại Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "ÄÆ°á»ng dẫn sai."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "Tệp không tồn tại."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
+msgid "Can't add autoload:"
msgstr ""
#: editor/editor_autoload_settings.cpp
@@ -2434,12 +2424,14 @@ msgstr "Không thể nạp má»™t cảnh mà chÆ°a lÆ°u bao giá»."
#: editor/editor_node.cpp
#, fuzzy
-msgid "Revert"
-msgstr "Trở lại"
+msgid "Reload Saved Scene"
+msgstr "Lưu Cảnh"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "Hành động này không thể hoàn tác. Trở lại luôn?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2719,10 +2711,6 @@ msgid "Redo"
msgstr "Làm lại"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3349,6 +3337,10 @@ msgstr ""
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "Chá»n Nút để Nhập"
@@ -3949,6 +3941,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "Äang lÆ°u ..."
@@ -6919,15 +6915,15 @@ msgstr ""
"Không có phương thức kết nối '%s' của tín hiệu '%s' từ nút '%s' đến nút '%s'."
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "Dòng:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "Thêm Hàm"
@@ -7408,6 +7404,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "Snap các nút đến Floor"
@@ -10439,8 +10444,9 @@ msgid "Instance Child Scene"
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+#, fuzzy
+msgid "Detach Script"
+msgstr "Äính kèm Script"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10603,6 +10609,13 @@ msgid "Open Documentation"
msgstr ""
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "Thêm nút con"
@@ -10651,11 +10664,13 @@ msgstr ""
"Tệp tin cảnh giống như một nút. Tạo một cảnh kế thừa nếu nó không có nút gốc."
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "Äính kèm má»™t tệp lệnh cho nút đã chá»n."
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "Xoá tệp lệnh khá»i nút đã chá»n."
#: editor/scene_tree_dock.cpp
@@ -10788,6 +10803,10 @@ msgid "A directory with the same name exists."
msgstr "Äã có má»™t file hoặc folder trùng tên."
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "Tệp không tồn tại."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "Phải sử dụng extension có hiệu lực"
@@ -10832,6 +10851,11 @@ msgstr ""
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "ÄÆ°á»ng dẫn sai."
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "Kích thước font không hợp lệ."
@@ -11896,6 +11920,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -11920,6 +11948,32 @@ msgstr "Kích thước font không hợp lệ."
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12574,6 +12628,13 @@ msgstr ""
msgid "Constants cannot be modified."
msgstr "Không thể chỉnh sửa hằng số."
+#, fuzzy
+#~ msgid "Revert"
+#~ msgstr "Trở lại"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "Hành động này không thể hoàn tác. Trở lại luôn?"
+
#~ msgid "Issue Tracker"
#~ msgstr "Theo dõi vấn Ä‘á»"
diff --git a/editor/translations/zh_CN.po b/editor/translations/zh_CN.po
index 538e017a5d..5dc2b5948f 100644
--- a/editor/translations/zh_CN.po
+++ b/editor/translations/zh_CN.po
@@ -60,12 +60,16 @@
# silentbird <silentbird520@outlook.com>, 2019.
# Haoyu Qiu <timothyqiu32@gmail.com>, 2019, 2020.
# Revan Ji <jiruifancr@gmail.com>, 2020.
+# nieyuanhong <15625988003@163.com>, 2020.
+# binotaliu <binota@protonmail.ch>, 2020.
+# BinotaLIU <binota@protonmail.ch>, 2020.
+# Tim Bao <honiebao@gmail.com>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Chinese (Simplified) (Godot Engine)\n"
"POT-Creation-Date: 2018-01-20 12:15+0200\n"
-"PO-Revision-Date: 2020-05-01 11:42+0000\n"
-"Last-Translator: Haoyu Qiu <timothyqiu32@gmail.com>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: Tim Bao <honiebao@gmail.com>\n"
"Language-Team: Chinese (Simplified) <https://hosted.weblate.org/projects/"
"godot-engine/godot/zh_Hans/>\n"
"Language: zh_CN\n"
@@ -73,7 +77,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.0.2\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
@@ -82,25 +86,25 @@ msgstr "convert()çš„å‚数类型无效,请使用TYPE_*常é‡ã€‚"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "预期为长度为1的字符串(一个字符)。"
+msgstr "仅需è¦é•¿åº¦ä¸º1的字符串(1字符)。"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr "解ç çš„字节ä¸è¶³ï¼Œæˆ–æ ¼å¼æ— æ•ˆã€‚"
+msgstr "没有足够的字节æ¥è§£ç ï¼Œæˆ–æ ¼å¼æ— æ•ˆã€‚"
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
-msgstr "表达å¼ä¸­çš„输入 %i 无效(未传递)"
+msgstr "表达å¼ä¸­åŒ…å«å¾—%i无效(未传递)"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr "self 无法使用,因为实例为空(未传递)"
+msgstr "实例为null(未传递),无法传递自身self"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
-msgstr "æ“作符 %s çš„æ“作数 %s å’Œ %s 无效。"
+msgstr "æ“作符 %s ,%s å’Œ %s çš„æ“作数无效。"
#: core/math/expression.cpp
msgid "Invalid index of type %s for base type %s"
@@ -108,15 +112,15 @@ msgstr "将 %s 类型作为 %s 基础类型的索引无效"
#: core/math/expression.cpp
msgid "Invalid named index '%s' for base type %s"
-msgstr "将“%sâ€ä½œä¸º %s 基础类型的具å索引无效"
+msgstr "å°† '%s' 作为 %s 基础类型的具å索引无效"
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr "构造“%sâ€çš„å‚数无效"
+msgstr "构造 '%s' çš„å‚数无效"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr "调用“%sâ€æ—¶ï¼š"
+msgstr "在调用'%s'时:"
#: core/ustring.cpp
msgid "B"
@@ -881,7 +885,6 @@ msgstr "无法连接信å·"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1489,17 +1492,9 @@ msgstr "å¯ç”¨"
msgid "Rearrange Autoloads"
msgstr "é‡æŽ’åºAutoload"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "Invalid path."
-msgstr "路径无效。"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "文件ä¸å­˜åœ¨ã€‚"
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "ä¸åœ¨èµ„æºè·¯å¾„下。"
+msgid "Can't add autoload:"
+msgstr "无法加载autoload:"
#: editor/editor_autoload_settings.cpp
msgid "Add AutoLoad"
@@ -1874,7 +1869,7 @@ msgstr "切æ¢æ¨¡å¼"
#: editor/editor_file_dialog.cpp
msgid "Focus Path"
-msgstr "设置路径焦点"
+msgstr "èšç„¦è·¯å¾„"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Up"
@@ -2435,12 +2430,14 @@ msgid "Can't reload a scene that was never saved."
msgstr "无法é‡æ–°åŠ è½½æœªä¿å­˜çš„场景。"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "æ¢å¤"
+msgid "Reload Saved Scene"
+msgstr "é‡è½½å·²ä¿å­˜åœºæ™¯"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "æ­¤æ“作无法撤销,是å¦ç»§ç»­ï¼Ÿ"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2715,10 +2712,6 @@ msgid "Redo"
msgstr "é‡åš"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "æ¢å¤åœºæ™¯"
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr "其他项目或全场景工具。"
@@ -3345,6 +3338,11 @@ msgstr "无法执行脚本:"
msgid "Did you forget the '_run' method?"
msgstr "您是å¦é—æ¼äº†_run()方法?"
+#: editor/editor_spin_slider.cpp
+#, fuzzy
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr "按ä½Ctrl键放置一个Getter节点。按ä½Shift键放置一个通用签å。"
+
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
msgstr "选择è¦å¯¼å…¥çš„节点"
@@ -3933,6 +3931,10 @@ msgid "Error running post-import script:"
msgstr "åŽå¤„ç†è„šæœ¬è¿è¡Œå‘生错误:"
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "ä¿å­˜ä¸­..."
@@ -6319,7 +6321,9 @@ msgstr "åŒæ­¥éª¨éª¼"
msgid ""
"No texture in this polygon.\n"
"Set a texture to be able to edit UV."
-msgstr "此多边形没有贴图,请先为它设置贴图åŽå†å°è¯•ç¼–辑UV。"
+msgstr ""
+"此多边形没有贴图。\n"
+"请先为它设置贴图åŽå†å°è¯•ç¼–辑UV。"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Create UV Map"
@@ -6840,12 +6844,13 @@ msgid ""
msgstr "未找到方法“%sâ€ï¼ˆè¿žæŽ¥äºŽä¿¡å·â€œ%sâ€ã€æ¥è‡ªèŠ‚点“%sâ€ã€ç›®æ ‡èŠ‚点“%sâ€ï¼‰ã€‚"
#: editor/plugins/script_text_editor.cpp
-msgid "Line"
-msgstr "行"
+#, fuzzy
+msgid "[Ignore]"
+msgstr "(忽略)"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(忽略)"
+msgid "Line"
+msgstr "行"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function"
@@ -7318,6 +7323,15 @@ msgid "XForm Dialog"
msgstr "XForm对è¯æ¡†"
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr "将节点å¸é™„至地é¢"
@@ -8174,7 +8188,7 @@ msgid ""
"Drag handles to edit Rect.\n"
"Click on another Tile to edit it."
msgstr ""
-"拖拽手柄以编辑举行。\n"
+"拖拽手柄以编辑矩形。\n"
"点击å¦ä¸€ä¸ªå›¾å—进行编辑。"
#: editor/plugins/tile_set_editor_plugin.cpp
@@ -8336,7 +8350,7 @@ msgstr "没有æä¾›æ交消æ¯"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "No files added to stage"
-msgstr "没有文件添加到舞å°"
+msgstr "没有文件被添加到暂存区"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Commit"
@@ -8384,11 +8398,11 @@ msgstr "类型更改"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Stage Selected"
-msgstr "舞å°é€‰å®š"
+msgstr "将选定放入暂存区"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Stage All"
-msgstr "所有舞å°"
+msgstr "暂存全部"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Add a commit message"
@@ -8632,7 +8646,7 @@ msgstr "返回NaN和标é‡å‚数之间比较的布尔结果。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Less Than (<)"
-msgstr "å°äºŽ (*)"
+msgstr "å°äºŽ (<)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Less Than or Equal (<=)"
@@ -8640,7 +8654,7 @@ msgstr "å°äºŽæˆ–等于(<=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Not Equal (!=)"
-msgstr "ä¸ç­‰äºŽï¼ˆï¼=)"
+msgstr "ä¸ç­‰äºŽï¼ˆ!=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -8650,7 +8664,7 @@ msgstr "如果æ供的布尔值是true或false,则返回关è”çš„å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns an associated scalar if the provided boolean value is true or false."
-msgstr "如果æ供的布尔值是true或false,则返回关è”çš„å‘é‡ã€‚"
+msgstr "如果æ供的布尔值是true或false,则返回关è”çš„æ ‡é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the boolean result of the comparison between two parameters."
@@ -8953,7 +8967,7 @@ msgstr "执行立方体纹ç†æŸ¥æ‰¾ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Perform the texture lookup."
-msgstr "执行立方体纹ç†æŸ¥æ‰¾ã€‚"
+msgstr "执行纹ç†æŸ¥æ‰¾ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Cubic texture uniform lookup."
@@ -8981,9 +8995,11 @@ msgid ""
"whose number of rows is the number of components in 'c' and whose number of "
"columns is the number of components in 'r'."
msgstr ""
-"计算一对矢é‡çš„外部乘积。 OuterProduct 将第一个å‚æ•°\"c\"视为列矢é‡ï¼ˆåŒ…å«ä¸€åˆ—çš„"
-"矩阵),将第二个å‚æ•°\"r\"视为行矢é‡ï¼ˆå…·æœ‰ä¸€è¡Œçš„矩阵),并执行线性代数矩阵乘以"
-"\"c = r\",生æˆè¡Œæ•°ä¸º\"c\"中的组件,其列数是\"r\"中的组件数。"
+"计算一对矢é‡çš„外积。\n"
+"\n"
+"OuterProduct 将第一个å‚æ•°\"c\"视为列矢é‡ï¼ˆåŒ…å«ä¸€åˆ—的矩阵),将第二个å‚æ•°\"r"
+"\"视为行矢é‡ï¼ˆå…·æœ‰ä¸€è¡Œçš„矩阵),并执行线性代数矩阵乘以\"c * r\",生æˆè¡Œæ•°ä¸º"
+"\"c\"中的组件,其列数是\"r\"中的组件数。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Composes transform from four vectors."
@@ -9101,9 +9117,10 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
-"平滑步函数(矢é‡ï¼ˆè¾¹ç¼˜0)ã€çŸ¢é‡ï¼ˆè¾¹ç¼˜1)ã€çŸ¢é‡ï¼ˆx))。 如果\"x\"å°äºŽ"
-"\"edge0\",则返回 0.0;如果\"x\"大于\"edge1\",则返回 0.0。å¦åˆ™ï¼Œè¿”回值将使用"
-"赫密特多项å¼åœ¨ 0.0 å’Œ 1.0 之间æ’值。"
+"SmoothStep 函数(矢é‡ï¼ˆedge0)ã€çŸ¢é‡ï¼ˆedge1)ã€çŸ¢é‡ï¼ˆx))。 \n"
+"\n"
+"如果\"x\"å°äºŽ\"edge0\",则返回 0.0;如果\"x\"大于\"edge1\",则返回 0.0。å¦åˆ™ï¼Œ"
+"返回值将使用赫密特多项å¼åœ¨ 0.0 å’Œ 1.0 之间æ’值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9708,7 +9725,9 @@ msgstr ""
msgid ""
"Language changed.\n"
"The interface will update after restarting the editor or project manager."
-msgstr "语言已更改。 é‡æ–°å¯åŠ¨ç¼–辑器或项目管ç†å™¨åŽï¼Œç•Œé¢å°†æ›´æ–°ã€‚"
+msgstr ""
+"语言已更改。\n"
+"ç•Œé¢å°†åœ¨é‡æ–°å¯åŠ¨ç¼–辑器或项目管ç†å™¨åŽæ›´æ–°ã€‚"
#: editor/project_manager.cpp
msgid ""
@@ -9916,7 +9935,7 @@ msgstr "滚轮å‘下滚动。"
#: editor/project_settings_editor.cpp
msgid "Add Global Property"
-msgstr "添加Getter属性"
+msgstr "添加全局属性"
#: editor/project_settings_editor.cpp
msgid "Select a setting item first!"
@@ -10310,7 +10329,7 @@ msgstr "场景è¿è¡Œè®¾ç½®"
#: editor/scene_tree_dock.cpp
msgid "No parent to instance the scenes at."
-msgstr "没有选中节点æ¥æ·»åŠ å®žä¾‹ã€‚"
+msgstr "没有å¯å®žä¾‹åŒ–场景的父节点。"
#: editor/scene_tree_dock.cpp
msgid "Error loading scene from %s"
@@ -10335,8 +10354,9 @@ msgid "Instance Child Scene"
msgstr "实例化å­åœºæ™¯"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr "清除脚本"
+#, fuzzy
+msgid "Detach Script"
+msgstr "添加脚本"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10494,6 +10514,13 @@ msgid "Open Documentation"
msgstr "打开文档"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr "添加å­èŠ‚点"
@@ -10540,11 +10567,13 @@ msgid ""
msgstr "实例化场景文件为一个节点,如果没有根节点则创建一个继承自该文件的场景。"
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+#, fuzzy
+msgid "Attach a new or existing script to the selected node."
msgstr "为选中节点创建或设置脚本。"
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+#, fuzzy
+msgid "Detach the script from the selected node."
msgstr "清除选中节点的脚本。"
#: editor/scene_tree_dock.cpp
@@ -10676,6 +10705,10 @@ msgid "A directory with the same name exists."
msgstr "存在åŒå目录。"
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "文件ä¸å­˜åœ¨ã€‚"
+
+#: editor/script_create_dialog.cpp
msgid "Invalid extension."
msgstr "扩展å无效。"
@@ -10716,6 +10749,10 @@ msgid "File exists, it will be reused."
msgstr "文件存在,将被é‡ç”¨ã€‚"
#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "路径无效。"
+
+#: editor/script_create_dialog.cpp
msgid "Invalid class name."
msgstr "无效的类别å称。"
@@ -10729,7 +10766,7 @@ msgstr "脚本路径/å称有效。"
#: editor/script_create_dialog.cpp
msgid "Allowed: a-z, A-Z, 0-9, _ and ."
-msgstr "å…许:a-z,a-z,0-9,u和。"
+msgstr "å…许:a-z,a-z,0-9,_ å’Œ ."
#: editor/script_create_dialog.cpp
msgid "Built-in script (into scene file)."
@@ -10979,19 +11016,19 @@ msgstr "改å˜æ–¹æ¡†å¤§å°"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Capsule Shape Radius"
-msgstr "修改胶囊体åŠå¾„"
+msgstr "修改椭圆形åŠå¾„"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Capsule Shape Height"
-msgstr "修改胶囊体高度"
+msgstr "修改椭圆形高度"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Cylinder Shape Radius"
-msgstr "修改胶囊体åŠå¾„"
+msgstr "修改圆柱形åŠå¾„"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Cylinder Shape Height"
-msgstr "修改胶囊体高度"
+msgstr "修改圆柱形高度"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Ray Shape Length"
@@ -11003,7 +11040,7 @@ msgstr "改å˜åœ†æŸ±ä½“åŠå¾„"
#: modules/csg/csg_gizmos.cpp
msgid "Change Cylinder Height"
-msgstr "修改胶囊体高度"
+msgstr "修改圆柱体高度"
#: modules/csg/csg_gizmos.cpp
msgid "Change Torus Inner Radius"
@@ -11696,7 +11733,7 @@ msgstr "æœç´¢å¯è§†åŒ–脚本节点"
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Get %s"
-msgstr "得到 %s"
+msgstr "èŽ·å– %s"
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Set %s"
@@ -11743,6 +11780,11 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr "未在编辑器设置或预设中é…置调试密钥库。"
#: platform/android/export/export.cpp
+#, fuzzy
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr "未在编辑器设置或预设中é…置调试密钥库。"
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr "自定义构建需è¦åœ¨â€œç¼–辑器设置â€ä¸­ä½¿ç”¨æœ‰æ•ˆçš„Android SDK路径。"
@@ -11766,6 +11808,32 @@ msgstr "无效的包å称:"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12384,15 +12452,15 @@ msgid ""
"children placement behavior.\n"
"If you don't intend to add a script, use a plain Control node instead."
msgstr ""
-"除éžè„šæœ¬é…置其å­ä»£æ”¾ç½®è¡Œä¸ºï¼Œå¦åˆ™å®¹å™¨æœ¬èº«æ²¡æœ‰ä»»ä½•ä½œç”¨ã€‚ 如果您ä¸æƒ³æ·»åŠ è„šæœ¬ï¼Œè¯·"
-"改用普通的Control节点。"
+"除éžè„šæœ¬é…置其å­ä»£æ”¾ç½®è¡Œä¸ºï¼Œå¦åˆ™å®¹å™¨æœ¬èº«æ²¡æœ‰ä»»ä½•ä½œç”¨ã€‚\n"
+"如果您ä¸æƒ³æ·»åŠ è„šæœ¬ï¼Œè¯·æ”¹ç”¨æ™®é€šçš„Control节点。"
#: scene/gui/control.cpp
msgid ""
"The Hint Tooltip won't be displayed as the control's Mouse Filter is set to "
"\"Ignore\". To solve this, set the Mouse Filter to \"Stop\" or \"Pass\"."
msgstr ""
-"由于该控件的 Mouse Filter 设置为 \"Ignore\" 因此它的 Hint Tooltip å°†ä¸ä¼šå±•"
+"由于该控件的 Mouse Filter 设置为 \"Ignore\" 因此它的 Hint Tooltip å°†ä¸ä¼šå±•"
"示。将 Mouse Filter 设置为 \"Stop\" 或 \"Pass\" å¯ä¿®æ­£æ­¤é—®é¢˜ã€‚"
#: scene/gui/dialogs.cpp
@@ -12422,8 +12490,9 @@ msgid ""
"Use a container as child (VBox, HBox, etc.), or a Control and set the custom "
"minimum size manually."
msgstr ""
-"ScrollContainer旨在与å•ä¸ªå­æŽ§ä»¶ä¸€èµ·ä½¿ç”¨ã€‚ 使用容器作为å­å®¹å™¨ï¼ˆVBox,HBox等)"
-"或控件,并手动设置自定义最å°å°ºå¯¸ã€‚"
+"ScrollContainer旨在与å•ä¸ªå­æŽ§ä»¶ä¸€èµ·ä½¿ç”¨ã€‚\n"
+"å­èŠ‚点应该是å•ä¸ªå®¹å™¨ï¼ˆVBoxã€HBox等)或者使用å•ä¸ªæŽ§ä»¶å¹¶æ‰‹åŠ¨è®¾ç½®å…¶è‡ªå®šä¹‰æœ€å°å°º"
+"寸。"
#: scene/gui/tree.cpp
msgid "(Other)"
@@ -12478,6 +12547,21 @@ msgstr "å˜é‡åªèƒ½åœ¨é¡¶ç‚¹å‡½æ•°ä¸­æŒ‡å®šã€‚"
msgid "Constants cannot be modified."
msgstr "ä¸å…许修改常é‡ã€‚"
+#~ msgid "Not in resource path."
+#~ msgstr "ä¸åœ¨èµ„æºè·¯å¾„下。"
+
+#~ msgid "Revert"
+#~ msgstr "æ¢å¤"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "æ­¤æ“作无法撤销,是å¦ç»§ç»­ï¼Ÿ"
+
+#~ msgid "Revert Scene"
+#~ msgstr "æ¢å¤åœºæ™¯"
+
+#~ msgid "Clear Script"
+#~ msgstr "清除脚本"
+
#~ msgid "Issue Tracker"
#~ msgstr "问题跟踪器"
diff --git a/editor/translations/zh_HK.po b/editor/translations/zh_HK.po
index 770b4d38f2..4832307ce5 100644
--- a/editor/translations/zh_HK.po
+++ b/editor/translations/zh_HK.po
@@ -873,7 +873,6 @@ msgstr "無法連接訊號"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1513,19 +1512,9 @@ msgstr "啟用"
msgid "Rearrange Autoloads"
msgstr "é‡æ–°æŽ’例Autoloads"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "有效的路徑"
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "檔案ä¸å­˜åœ¨."
-
#: editor/editor_autoload_settings.cpp
-#, fuzzy
-msgid "Not in resource path."
-msgstr "ä¸åœ¨è³‡æºè·¯å¾‘。"
+msgid "Can't add autoload:"
+msgstr ""
#: editor/editor_autoload_settings.cpp
#, fuzzy
@@ -2505,11 +2494,14 @@ msgid "Can't reload a scene that was never saved."
msgstr "ä¸èƒ½é‡æ–°è¼‰å…¥å¾žæœªå„²å­˜çš„場景。"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr ""
+#, fuzzy
+msgid "Reload Saved Scene"
+msgstr "儲存場景"
#: editor/editor_node.cpp
-msgid "This action cannot be undone. Revert anyway?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
msgstr ""
#: editor/editor_node.cpp
@@ -2805,10 +2797,6 @@ msgid "Redo"
msgstr "é‡è£½"
#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr ""
-
-#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
msgstr ""
@@ -3455,6 +3443,10 @@ msgstr "ä¸èƒ½åŸ·è¡Œè…³æœ¬ï¼š"
msgid "Did you forget the '_run' method?"
msgstr ""
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr ""
+
#: editor/editor_sub_scene.cpp
#, fuzzy
msgid "Select Node(s) to Import"
@@ -4100,6 +4092,10 @@ msgid "Error running post-import script:"
msgstr ""
#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr ""
+
+#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
msgstr "儲存中..."
@@ -7160,15 +7156,15 @@ msgid ""
msgstr "由 '%s' 連到 '%s'"
#: editor/plugins/script_text_editor.cpp
+msgid "[Ignore]"
+msgstr ""
+
+#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Line"
msgstr "行:"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr ""
-
-#: editor/plugins/script_text_editor.cpp
#, fuzzy
msgid "Go to Function"
msgstr "行為"
@@ -7666,6 +7662,15 @@ msgid "XForm Dialog"
msgstr ""
#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+
+#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
msgstr ""
@@ -10765,8 +10770,8 @@ msgstr ""
#: editor/scene_tree_dock.cpp
#, fuzzy
-msgid "Clear Script"
-msgstr "下一個腳本"
+msgid "Detach Script"
+msgstr "腳本"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
@@ -10938,6 +10943,13 @@ msgid "Open Documentation"
msgstr "開啓最近的"
#: editor/scene_tree_dock.cpp
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
+msgstr ""
+
+#: editor/scene_tree_dock.cpp
msgid "Add Child Node"
msgstr ""
@@ -10989,11 +11001,11 @@ msgid ""
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
+msgid "Attach a new or existing script to the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
+msgid "Detach the script from the selected node."
msgstr ""
#: editor/scene_tree_dock.cpp
@@ -11122,6 +11134,10 @@ msgid "A directory with the same name exists."
msgstr ""
#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "檔案ä¸å­˜åœ¨."
+
+#: editor/script_create_dialog.cpp
#, fuzzy
msgid "Invalid extension."
msgstr "無效副檔å"
@@ -11169,6 +11185,11 @@ msgstr "檔案已存在, è¦è¦†è“‹å—Ž?"
#: editor/script_create_dialog.cpp
#, fuzzy
+msgid "Invalid path."
+msgstr "有效的路徑"
+
+#: editor/script_create_dialog.cpp
+#, fuzzy
msgid "Invalid class name."
msgstr "無效å稱"
@@ -12263,6 +12284,10 @@ msgid "Debug keystore not configured in the Editor Settings nor in the preset."
msgstr ""
#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr ""
+
+#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
msgstr ""
@@ -12287,6 +12312,32 @@ msgstr "無效å稱"
#: platform/android/export/export.cpp
msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+
+#: platform/android/export/export.cpp
+msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
@@ -12948,6 +12999,14 @@ msgid "Constants cannot be modified."
msgstr ""
#, fuzzy
+#~ msgid "Not in resource path."
+#~ msgstr "ä¸åœ¨è³‡æºè·¯å¾‘。"
+
+#, fuzzy
+#~ msgid "Clear Script"
+#~ msgstr "下一個腳本"
+
+#, fuzzy
#~ msgid "Replaced %d occurrence(s)."
#~ msgstr "å–代了 %d 個。"
diff --git a/editor/translations/zh_TW.po b/editor/translations/zh_TW.po
index 6b3651b5f6..22051058ad 100644
--- a/editor/translations/zh_TW.po
+++ b/editor/translations/zh_TW.po
@@ -14,18 +14,22 @@
# ken l <macauhome@gmail.com>, 2018.
# Eric K <eric900601@gmail.com>, 2019.
# cnieFIT <dtotncq@gmail.com>, 2019.
-# Bluesir Bruce <a5566740293@gmail.com>, 2019.
+# Bluesir Bruce <a5566740293@gmail.com>, 2019, 2020.
# leela <53352@protonmail.com>, 2019.
# Kenneth Lo <closer.tw@gmail.com>, 2019.
# SIYU FU <1002492607@qq.com>, 2019.
# 鄭惟中 <biglionlion06@gmail.com>, 2020.
# Alexander Wang <zxcvb22217@gmail.com>, 2020.
+# binotaliu <binota@protonmail.ch>, 2020.
+# Allen H. <w84miracle@gmail.com>, 2020.
+# BinotaLIU <binota@protonmail.ch>, 2020.
+# BinotaLIU <me@binota.org>, 2020.
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine editor\n"
"POT-Creation-Date: \n"
-"PO-Revision-Date: 2020-03-01 19:57+0000\n"
-"Last-Translator: Alexander Wang <zxcvb22217@gmail.com>\n"
+"PO-Revision-Date: 2020-06-15 01:48+0000\n"
+"Last-Translator: BinotaLIU <me@binota.org>\n"
"Language-Team: Chinese (Traditional) <https://hosted.weblate.org/projects/"
"godot-engine/godot/zh_Hant/>\n"
"Language: zh_TW\n"
@@ -33,58 +37,58 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.0-dev\n"
+"X-Generator: Weblate 4.1-dev\n"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Invalid type argument to convert(), use TYPE_* constants."
-msgstr "Convert()函數所收到的åƒæ•¸éŒ¯èª¤ï¼Œè«‹ç”¨ TYPE_* 常數。"
+msgstr "convert() 函å¼æ”¶åˆ°äº†ç„¡æ•ˆçš„引數,請使用 TYPE_* 常數。"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
msgid "Expected a string of length 1 (a character)."
-msgstr "應為一個長度是1(一個字元)的字串。"
+msgstr "應為一個長度為 1(一個字元)的字串。"
#: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp
#: modules/mono/glue/gd_glue.cpp
#: modules/visual_script/visual_script_builtin_funcs.cpp
msgid "Not enough bytes for decoding bytes, or invalid format."
-msgstr "輸入的解碼字節ä¸è¶³ã€æˆ–為無效格å¼ã€‚"
+msgstr "欲解碼的ä½å…ƒçµ„ä¸è¶³æˆ–æ ¼å¼ç„¡æ•ˆã€‚"
#: core/math/expression.cpp
msgid "Invalid input %i (not passed) in expression"
-msgstr "é‹ç®—å¼ä¸­çš„輸入 %i 無效 (未傳éž)"
+msgstr "é‹ç®—å¼ä¸­çš„輸入 %i 無效 (未傳éžï¼‰"
#: core/math/expression.cpp
msgid "self can't be used because instance is null (not passed)"
-msgstr "因該實例(instance)為空,self 無法被使用"
+msgstr "該實體爲 null,無法使用 self"
#: core/math/expression.cpp
msgid "Invalid operands to operator %s, %s and %s."
-msgstr "此數值無法被 %sã€%s 和与%s é‹ç®—。"
+msgstr "該é‹ç®—元無法由é‹ç®—å­ %sã€%sã€èˆ‡ %s é‹ç®—。"
#: core/math/expression.cpp
msgid "Invalid index of type %s for base type %s"
-msgstr "無效的內存地å€é¡žåž‹ %sï¼ŒåŸºç¤Žåž‹å¼ %s"
+msgstr "在型別 %s ã€åŸºç¤Žé¡žåž‹ %s 上存å–了無效的索引"
#: core/math/expression.cpp
msgid "Invalid named index '%s' for base type %s"
-msgstr "基本類型 %s 的命å索引 '%s' 無效"
+msgstr "命å索引「%sã€å°åŸºç¤Žåž‹åˆ¥ %s 無效"
#: core/math/expression.cpp
msgid "Invalid arguments to construct '%s'"
-msgstr "無效åƒæ•¸é¡žåž‹: '%s'"
+msgstr "用了無效的引數來建構「%sã€"
#: core/math/expression.cpp
msgid "On call to '%s':"
-msgstr "調用“%sâ€æ™‚:"
+msgstr "呼å«ã€Œ%sã€æ™‚:"
#: core/ustring.cpp
msgid "B"
-msgstr "Byte"
+msgstr "B"
#: core/ustring.cpp
msgid "KiB"
-msgstr "基布"
+msgstr "KiB"
#: core/ustring.cpp
msgid "MiB"
@@ -92,23 +96,23 @@ msgstr "MiB"
#: core/ustring.cpp
msgid "GiB"
-msgstr ""
+msgstr "GiB"
#: core/ustring.cpp
msgid "TiB"
-msgstr ""
+msgstr "TiB"
#: core/ustring.cpp
msgid "PiB"
-msgstr ""
+msgstr "PiB"
#: core/ustring.cpp
msgid "EiB"
-msgstr ""
+msgstr "EiB"
#: editor/animation_bezier_editor.cpp
msgid "Free"
-msgstr "釋放"
+msgstr "ä¸å—é™"
#: editor/animation_bezier_editor.cpp
msgid "Balanced"
@@ -124,90 +128,84 @@ msgstr "時間:"
#: editor/animation_bezier_editor.cpp
msgid "Value:"
-msgstr "數值:"
+msgstr "數值:"
#: editor/animation_bezier_editor.cpp
msgid "Insert Key Here"
-msgstr "在此æ’入畫格"
+msgstr "在此æ’入關éµç•«æ ¼"
#: editor/animation_bezier_editor.cpp
msgid "Duplicate Selected Key(s)"
-msgstr "複製所é¸ç•«æ ¼"
+msgstr "é‡è¤‡æ‰€é¸é—œéµç•«æ ¼"
#: editor/animation_bezier_editor.cpp
msgid "Delete Selected Key(s)"
-msgstr "刪除所é¸ç•«æ ¼"
+msgstr "刪除所é¸é—œéµç•«æ ¼"
#: editor/animation_bezier_editor.cpp
msgid "Add Bezier Point"
-msgstr "添加è²å¡žçˆ¾é»ž"
+msgstr "新增è²èŒ²æ›²ç·šæŽ§åˆ¶é»ž"
#: editor/animation_bezier_editor.cpp
msgid "Move Bezier Points"
-msgstr "移動Bezier點"
+msgstr "移動è²èŒ²æ›²ç·šæŽ§åˆ¶é»ž"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Duplicate Keys"
-msgstr "複製關éµç•«æ ¼"
+msgstr "é‡è¤‡å‹•ç•«é—œéµç•«æ ¼"
#: editor/animation_bezier_editor.cpp editor/animation_track_editor.cpp
msgid "Anim Delete Keys"
-msgstr "刪除關éµç•«æ ¼"
+msgstr "刪除動畫關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Time"
-msgstr "變更關éµç•«æ ¼çš„時間"
+msgstr "更改動畫關éµç•«æ ¼æ™‚é–“"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transition"
-msgstr "變更轉場效果"
+msgstr "更改動畫轉場效果"
#: editor/animation_track_editor.cpp
msgid "Anim Change Transform"
-msgstr "變更動畫變æ›"
+msgstr "更改動畫變æ›"
#: editor/animation_track_editor.cpp
msgid "Anim Change Keyframe Value"
-msgstr "變更關éµç•«æ ¼çš„數值"
+msgstr "更改動畫關éµç•«æ ¼æ•¸å€¼"
#: editor/animation_track_editor.cpp
msgid "Anim Change Call"
-msgstr "更改回調"
+msgstr "更改動畫呼å«"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Keyframe Time"
-msgstr "變更關éµç•«æ ¼çš„時間"
+msgstr "更改多個動畫的關éµç•«æ ¼æ™‚é–“"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Transition"
-msgstr "變更轉場效果"
+msgstr "更改多個動畫的轉場效果"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Transform"
-msgstr "變更動畫變æ›"
+msgstr "更改多個動畫的變æ›"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Keyframe Value"
-msgstr "變更關éµç•«æ ¼çš„數值"
+msgstr "更改多個動畫的關éµç•«æ ¼æ•¸å€¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Anim Multi Change Call"
-msgstr "更改回調"
+msgstr "更改多個動畫的回調"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Length"
-msgstr "變更動畫長度"
+msgstr "更改動畫長度"
#: editor/animation_track_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation Loop"
-msgstr "變更動畫循環"
+msgstr "更改動畫循環"
#: editor/animation_track_editor.cpp
msgid "Property Track"
@@ -219,11 +217,11 @@ msgstr "3D 變æ›è»Œé“"
#: editor/animation_track_editor.cpp
msgid "Call Method Track"
-msgstr "調用方法軌é“"
+msgstr "呼å«æ–¹æ³•è»Œé“"
#: editor/animation_track_editor.cpp
msgid "Bezier Curve Track"
-msgstr "è²å¡žçˆ¾æ›²ç·šè»Œè·¡"
+msgstr "è²èŒ²æ›²ç·šè»Œé“"
#: editor/animation_track_editor.cpp
msgid "Audio Playback Track"
@@ -234,50 +232,45 @@ msgid "Animation Playback Track"
msgstr "動畫回放軌é“"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (frames)"
-msgstr "動畫長度(秒)"
+msgstr "動畫長度(幀)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation length (seconds)"
msgstr "動畫長度(秒)"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Track"
-msgstr "添加動畫軌"
+msgstr "新增動畫軌"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation Looping"
-msgstr "動畫空間。"
+msgstr "é‡è¤‡å‹•ç•«"
#: editor/animation_track_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Functions:"
-msgstr "函數:"
+msgstr "函å¼ï¼š"
#: editor/animation_track_editor.cpp
msgid "Audio Clips:"
-msgstr "音訊剪輯:"
+msgstr "音訊片段:"
#: editor/animation_track_editor.cpp
msgid "Anim Clips:"
-msgstr "動畫剪輯:"
+msgstr "動畫片段:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Track Path"
-msgstr "調整陣列資料"
+msgstr "調整軌é“路徑"
#: editor/animation_track_editor.cpp
msgid "Toggle this track on/off."
-msgstr "打開/關閉此軌é“."
+msgstr "打開ï¼é—œé–‰æ­¤è»Œé“。"
#: editor/animation_track_editor.cpp
msgid "Update Mode (How this property is set)"
-msgstr "æ›´æ–°æ¨¡å¼ (如何設置此屬性)"
+msgstr "更新模å¼ï¼ˆå±¬æ€§è¨­å®šæ–¹æ³•ï¼‰"
#: editor/animation_track_editor.cpp
msgid "Interpolation Mode"
@@ -285,22 +278,19 @@ msgstr "æ’值模å¼"
#: editor/animation_track_editor.cpp
msgid "Loop Wrap Mode (Interpolate end with beginning on loop)"
-msgstr "循環包裹模å¼ï¼ˆå¾žå¾ªç’°é–‹å§‹æ’å…¥çµæŸï¼‰"
+msgstr "無縫循環模å¼ï¼ˆå¾žå¾ªç’°é–‹å§‹æ’å…¥çµæŸï¼‰"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Remove this track."
-msgstr "移除é¸æ“‡çš„動畫軌。"
+msgstr "移除該動畫軌。"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Time (s): "
-msgstr "步驟 :"
+msgstr "時間(秒) : "
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Toggle Track Enabled"
-msgstr "啟用"
+msgstr "啟用ï¼ç¦ç”¨è»Œé“"
#: editor/animation_track_editor.cpp
msgid "Continuous"
@@ -316,7 +306,7 @@ msgstr "觸發器"
#: editor/animation_track_editor.cpp
msgid "Capture"
-msgstr "æ•ç²"
+msgstr "截圖"
#: editor/animation_track_editor.cpp
msgid "Nearest"
@@ -333,40 +323,36 @@ msgstr "立方體"
#: editor/animation_track_editor.cpp
msgid "Clamp Loop Interp"
-msgstr "Clampå¼å…§æ’循環"
+msgstr "Clamp å¼å…§æ’循環"
#: editor/animation_track_editor.cpp
msgid "Wrap Loop Interp"
-msgstr "Wrapå¼å…§æ’循環"
+msgstr "Wrap å¼å…§æ’循環"
#: editor/animation_track_editor.cpp
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key"
-msgstr "æ’入畫格"
+msgstr "æ’入關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Duplicate Key(s)"
-msgstr "複製動畫關éµç•«æ ¼"
+msgstr "é‡è¤‡é—œéµç•«æ ¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Delete Key(s)"
-msgstr "刪除動畫關éµç•«æ ¼"
+msgstr "刪除關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Change Animation Update Mode"
-msgstr "變更動畫更新模å¼"
+msgstr "更改動畫更新模å¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Interpolation Mode"
-msgstr "變更動畫內æ’模å¼"
+msgstr "更改動畫æ’值模å¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Loop Mode"
-msgstr "變更動畫循環模å¼"
+msgstr "更改動畫循環模å¼"
#: editor/animation_track_editor.cpp
msgid "Remove Anim Track"
@@ -374,11 +360,11 @@ msgstr "刪除動畫軌"
#: editor/animation_track_editor.cpp
msgid "Create NEW track for %s and insert key?"
-msgstr "為 %s 新增動畫軌並æ’入畫格?"
+msgstr "確定è¦ç‚º %s 建立動畫軌並æ’入關éµç•«æ ¼å—Žï¼Ÿ"
#: editor/animation_track_editor.cpp
msgid "Create %d NEW tracks and insert keys?"
-msgstr "新增 %d 個動畫軌並æ’入畫格?"
+msgstr "確定è¦å»ºç«‹ %d 個動畫軌並æ’入畫格嗎?"
#: editor/animation_track_editor.cpp editor/create_dialog.cpp
#: editor/editor_audio_buses.cpp editor/editor_feature_profile.cpp
@@ -390,7 +376,7 @@ msgstr "新增 %d 個動畫軌並æ’入畫格?"
#: editor/script_create_dialog.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Create"
-msgstr "新增"
+msgstr "建立"
#: editor/animation_track_editor.cpp
msgid "Anim Insert"
@@ -398,11 +384,11 @@ msgstr "æ’入動畫"
#: editor/animation_track_editor.cpp
msgid "AnimationPlayer can't animate itself, only other players."
-msgstr "AnimationPlayerä¸èƒ½è¢«è‡ªå·±æ‰€å•Ÿå‹•ï¼Œå¿…須由其他player啟動。"
+msgstr "AnimationPlayer ä¸èƒ½æ’­æ”¾è‡ªå·±ï¼Œåªå¯æ’­æ”¾å…¶ä»– Player。"
#: editor/animation_track_editor.cpp
msgid "Anim Create & Insert"
-msgstr "新增/æ’入動畫"
+msgstr "新增ï¼æ’入動畫"
#: editor/animation_track_editor.cpp
msgid "Anim Insert Track & Key"
@@ -413,18 +399,16 @@ msgid "Anim Insert Key"
msgstr "新增關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Change Animation Step"
-msgstr "變更動畫長度"
+msgstr "更改動畫步長"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Rearrange Tracks"
-msgstr "é‡æ–°æŽ’列 Autoload"
+msgstr "é‡æ–°æŽ’列軌é“"
#: editor/animation_track_editor.cpp
msgid "Transform tracks only apply to Spatial-based nodes."
-msgstr "Transform軌åªèƒ½æ·»åŠ åœ¨spatial為主的節點。"
+msgstr "變形軌åªèƒ½å¥—用至 Spatial 節點。"
#: editor/animation_track_editor.cpp
msgid ""
@@ -440,80 +424,74 @@ msgstr ""
#: editor/animation_track_editor.cpp
msgid "Animation tracks can only point to AnimationPlayer nodes."
-msgstr "動畫軌跡åªèƒ½æŒ‡å‘ AnimationPlayer 節點."
+msgstr "動畫軌åªèƒ½æŒ‡å‘ AnimationPlayer 節點。"
#: editor/animation_track_editor.cpp
msgid "An animation player can't animate itself, only other players."
-msgstr ""
+msgstr "å‹•ç•« Player 無法播放自己,åªèƒ½æ’­æ”¾å…¶ä»– Player。"
#: editor/animation_track_editor.cpp
msgid "Not possible to add a new track without a root"
-msgstr "無法添加沒有根目錄的新曲目"
+msgstr "沒有根節點時無法新增軌é“"
#: editor/animation_track_editor.cpp
msgid "Invalid track for Bezier (no suitable sub-properties)"
-msgstr "此軌ä¸èƒ½ç”¨æ–¼Bezier(å­å±¬æ€§ä¸é©åˆ)"
+msgstr "å°æ–¼è²èŒ²æ›²ç·šç„¡æ•ˆçš„軌é“(éžé©ç”¨ä¹‹å­å±¬æ€§ï¼‰"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Bezier Track"
-msgstr "添加動畫軌"
+msgstr "新增è²èŒ²æ›²ç·šè»Œ"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a key."
-msgstr "軌é“路徑無效, 因此無法添加éµã€‚"
+msgstr "無效的軌é“路徑,無法新增關éµç•«æ ¼ã€‚"
#: editor/animation_track_editor.cpp
msgid "Track is not of type Spatial, can't insert key"
-msgstr "軌é“ä¸æ˜¯ç©ºé–“é¡žåž‹, ä¸èƒ½æ’å…¥éµ"
+msgstr "éž Spatial 類型之軌é“,無法æ’入關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Transform Track Key"
-msgstr "動畫新增軌跡與按éµ"
+msgstr "新增變形軌關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Track Key"
-msgstr "添加動畫軌"
+msgstr "添加軌é“é—œéµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Track path is invalid, so can't add a method key."
-msgstr "跟蹤路徑無效, 因此無法添加方法éµã€‚"
+msgstr "無效的軌é“路徑,無法新增方法關éµç•«æ ¼ã€‚"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Add Method Track Key"
-msgstr "動畫新增軌跡與按éµ"
+msgstr "新增方法軌é“é—œéµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Method not found in object: "
-msgstr "在å°è±¡ä¸­æ‰¾ä¸åˆ°æ–¹æ³•ï¼š "
+msgstr "在物件中找ä¸åˆ°æ–¹æ³•ï¼š "
#: editor/animation_track_editor.cpp
msgid "Anim Move Keys"
-msgstr "移動關éµç•«æ ¼"
+msgstr "移動動畫關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Clipboard is empty"
-msgstr "剪貼æ¿ç‚ºç©º"
+msgstr "空白剪貼æ¿"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Paste Tracks"
-msgstr "貼上åƒæ•¸"
+msgstr "貼上關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Anim Scale Keys"
-msgstr "縮尺éµ"
+msgstr "動畫縮放關éµå½±æ ¼"
#: editor/animation_track_editor.cpp
msgid ""
"This option does not work for Bezier editing, as it's only a single track."
-msgstr "這個é¸é …ä¸é©ç”¨æ–¼è²å¡žçˆ¾ç·¨è¼¯ï¼Œå› ç‚ºå®ƒåªæ˜¯ä¸€å€‹å–®è»Œã€‚"
+msgstr "該é¸é …ä¸é©ç”¨æ–¼ç·¨è¼¯è²èŒ²æ›²ç·šï¼Œå…¶åƒ…有單一軌é“。"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid ""
"This animation belongs to an imported scene, so changes to imported tracks "
"will not be saved.\n"
@@ -525,22 +503,19 @@ msgid ""
"Alternatively, use an import preset that imports animations to separate "
"files."
msgstr ""
-"這個動畫存在於匯入的場景中,因此å°åŒ¯å…¥è»Œæ‰€åšçš„變更ä¸æœƒè¢«å„²å­˜ã€‚\n"
+"這個動畫是由外部匯入之場景æ供,套用於匯入軌é“的修改將ä¸æœƒè¢«ä¿å­˜ã€‚\n"
"\n"
-"若是è¦é–‹å•Ÿã€ŒåŠ å…¥å®¢åˆ¶è»Œã€çš„功能,請在場景的匯入設定中將「動畫 -> 存放ã€è¨­å®š"
-"為\n"
-"「檔案ã€ï¼Œé–‹å•Ÿã€Œå‹•ç•« -> ä¿å­˜å®¢åˆ¶è»Œã€ï¼Œç„¶å¾Œé‡æ–°å…¥åŒ¯å…¥ã€‚\n"
-"或者,你å¯ä»¥åœ¨åŒ¯å…¥æ™‚,將動畫資料匯入單ç¨çš„檔案之中。"
+"è‹¥è¦é–‹å•Ÿã€ŒåŠ å…¥å®¢åˆ¶è»Œã€çš„功能,請在場景在匯入設定中將「動畫 -> 儲存ã€è¨­å®šç‚º\n"
+"「檔案ã€ï¼Œä¸¦å•Ÿç”¨ã€Œå‹•ç•« -> ä¿å­˜å®¢åˆ¶è»Œã€ï¼Œç„¶å¾Œé‡æ–°åŒ¯å…¥ã€‚\n"
+"或者也å¯ä½¿ç”¨æœƒå°‡å‹•ç•«åŒ¯å…¥ç¨ç«‹æª”案的匯入 Preset。"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Warning: Editing imported animation"
msgstr "警告:正在編輯匯入的動畫"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Select an AnimationPlayer node to create and edit animations."
-msgstr "從場景樹中é¸æ“‡ä¸€å€‹ AnimationPlayer 來編輯動畫。"
+msgstr "é¸æ“‡ AnimationPlayer 節點以建立並編輯動畫。"
#: editor/animation_track_editor.cpp
msgid "Only show tracks from nodes selected in tree."
@@ -548,26 +523,23 @@ msgstr "僅顯示樹中所é¸ç¯€é»žçš„軌跡。"
#: editor/animation_track_editor.cpp
msgid "Group tracks by node or display them as plain list."
-msgstr "按節點å°è»Œè·¡åˆ†çµ„或將其顯示為普通清單。"
+msgstr "ä¾ç¯€é»žåˆ†çµ„軌跡或將其顯示為普通清單。"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Snap:"
-msgstr "步驟 :"
+msgstr "å¸é™„:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation step value."
-msgstr "動畫空間。"
+msgstr "動畫步進值。"
#: editor/animation_track_editor.cpp
msgid "Seconds"
msgstr "秒"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "FPS"
-msgstr "æ¯ç§’張數"
+msgstr "FPS"
#: editor/animation_track_editor.cpp editor/editor_properties.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
@@ -580,14 +552,12 @@ msgid "Edit"
msgstr "編輯"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Animation properties."
-msgstr "動畫空間。"
+msgstr "動畫屬性。"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Copy Tracks"
-msgstr "複製åƒæ•¸"
+msgstr "複製軌é“"
#: editor/animation_track_editor.cpp
msgid "Scale Selection"
@@ -595,34 +565,31 @@ msgstr "縮放所é¸"
#: editor/animation_track_editor.cpp
msgid "Scale From Cursor"
-msgstr "由游標縮放"
+msgstr "以游標縮放"
#: editor/animation_track_editor.cpp modules/gridmap/grid_map_editor_plugin.cpp
msgid "Duplicate Selection"
-msgstr "複製所é¸"
+msgstr "é‡è¤‡æ‰€é¸"
#: editor/animation_track_editor.cpp
msgid "Duplicate Transposed"
-msgstr "複製並轉置"
+msgstr "轉置並é‡è¤‡"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Delete Selection"
-msgstr "複製所é¸"
+msgstr "刪除所é¸"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Go to Next Step"
-msgstr "往下一步"
+msgstr "跳至下一步"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Go to Previous Step"
-msgstr "往上一步"
+msgstr "跳至上一步"
#: editor/animation_track_editor.cpp
msgid "Optimize Animation"
-msgstr "動畫最佳化"
+msgstr "最佳化動畫"
#: editor/animation_track_editor.cpp
msgid "Clean-Up Animation"
@@ -634,23 +601,23 @@ msgstr "é¸æ“‡è¦è¨­å®šå‹•ç•«çš„節點:"
#: editor/animation_track_editor.cpp
msgid "Use Bezier Curves"
-msgstr "使用è²å¡žçˆ¾æ›²ç·š"
+msgstr "使用è²èŒ²æ›²ç·š"
#: editor/animation_track_editor.cpp
msgid "Anim. Optimizer"
-msgstr "動畫最佳化"
+msgstr "最佳化動畫工具"
#: editor/animation_track_editor.cpp
msgid "Max. Linear Error:"
-msgstr "最大線性錯誤:"
+msgstr "最大線性錯誤:"
#: editor/animation_track_editor.cpp
msgid "Max. Angular Error:"
-msgstr "最大角度錯誤:"
+msgstr "最大角度錯誤:"
#: editor/animation_track_editor.cpp
msgid "Max Optimizable Angle:"
-msgstr "最大å¯å„ªåŒ–角度:"
+msgstr "最大å¯æœ€ä½³åŒ–角度:"
#: editor/animation_track_editor.cpp
msgid "Optimize"
@@ -662,7 +629,7 @@ msgstr "移除無效的關éµç•«æ ¼"
#: editor/animation_track_editor.cpp
msgid "Remove unresolved and empty tracks"
-msgstr "刪除未處ç†çš„空白軌é“"
+msgstr "刪除未處ç†èˆ‡ç©ºç™½çš„軌é“"
#: editor/animation_track_editor.cpp
msgid "Clean-up all animations"
@@ -678,12 +645,11 @@ msgstr "清除"
#: editor/animation_track_editor.cpp
msgid "Scale Ratio:"
-msgstr "縮放比例:"
+msgstr "縮放比例:"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Select Tracks to Copy"
-msgstr "é¸æ“‡è¦è¤‡è£½çš„軌é“:"
+msgstr "é¸æ“‡è»Œé“以複製"
#: editor/animation_track_editor.cpp editor/editor_log.cpp
#: editor/editor_properties.cpp
@@ -695,22 +661,20 @@ msgid "Copy"
msgstr "複製"
#: editor/animation_track_editor.cpp
-#, fuzzy
msgid "Select All/None"
-msgstr "é¸æ“‡æ¨¡å¼"
+msgstr "é¸æ“‡å…¨éƒ¨ï¼å–消é¸æ“‡"
#: editor/animation_track_editor_plugins.cpp
-#, fuzzy
msgid "Add Audio Track Clip"
-msgstr "添加動畫軌"
+msgstr "新增音訊軌片段"
#: editor/animation_track_editor_plugins.cpp
msgid "Change Audio Track Clip Start Offset"
-msgstr "更改音訊軌é“剪輯起始å移"
+msgstr "更改音訊軌片段起始å移"
#: editor/animation_track_editor_plugins.cpp
msgid "Change Audio Track Clip End Offset"
-msgstr "更改音訊曲目剪輯çµæŸå移"
+msgstr "更改音訊軌片段çµæŸå移"
#: editor/array_property_edit.cpp
msgid "Resize Array"
@@ -718,42 +682,39 @@ msgstr "調整陣列大å°"
#: editor/array_property_edit.cpp
msgid "Change Array Value Type"
-msgstr "調整陣列資料型態"
+msgstr "更改陣列資料型別"
#: editor/array_property_edit.cpp
msgid "Change Array Value"
-msgstr "調整陣列資料"
+msgstr "更改陣列資料"
#: editor/code_editor.cpp
msgid "Go to Line"
-msgstr "å‰å¾€ç¬¬...è¡Œ"
+msgstr "跳至第 ... 行"
#: editor/code_editor.cpp
msgid "Line Number:"
-msgstr "行號:"
+msgstr "行號:"
#: editor/code_editor.cpp
-#, fuzzy
msgid "%d replaced."
-msgstr "替æ›â€¦"
+msgstr "å·²å–代了 %d 件。"
#: editor/code_editor.cpp editor/editor_help.cpp
-#, fuzzy
msgid "%d match."
-msgstr "找到 %d 件符åˆçµæžœã€‚"
+msgstr "%d 件相符åˆçš„çµæžœã€‚"
#: editor/code_editor.cpp editor/editor_help.cpp
-#, fuzzy
msgid "%d matches."
-msgstr "找到 %d 件符åˆçµæžœã€‚"
+msgstr "%d 件相符åˆçš„çµæžœã€‚"
#: editor/code_editor.cpp editor/find_in_files.cpp
msgid "Match Case"
-msgstr "符åˆå¤§å°å¯«"
+msgstr "å€åˆ†å¤§å°å¯«"
#: editor/code_editor.cpp editor/find_in_files.cpp
msgid "Whole Words"
-msgstr "符åˆå®Œæ•´å–®å­—"
+msgstr "æœå°‹å®Œæ•´å–®å­—"
#: editor/code_editor.cpp editor/rename_dialog.cpp
msgid "Replace"
@@ -765,7 +726,7 @@ msgstr "å–代全部"
#: editor/code_editor.cpp
msgid "Selection Only"
-msgstr "僅é¸æ“‡å€åŸŸ"
+msgstr "僅æœå°‹æ‰€é¸å€åŸŸ"
#: editor/code_editor.cpp editor/plugins/script_text_editor.cpp
#: editor/plugins/text_editor.cpp
@@ -774,7 +735,7 @@ msgstr "標準"
#: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp
msgid "Toggle Scripts Panel"
-msgstr "\"切æ›è…³æœ¬\" é¢æ¿"
+msgstr "é–‹å•Ÿï¼é—œé–‰è…³æœ¬é¢æ¿"
#: editor/code_editor.cpp editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
@@ -801,35 +762,30 @@ msgid "Line and column numbers."
msgstr "行號和列號。"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Method in target node must be specified."
-msgstr "必須指定å°ç›®æ¨™ç¯€é»žçš„行為ï¼"
+msgstr "必須指定目標節點的方法。"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid ""
"Target method not found. Specify a valid method or attach a script to the "
"target node."
-msgstr "找ä¸åˆ°ç›®æ¨™æ–¹æ³•ï¼è«‹æŒ‡å®šæœ‰æ•ˆæ–¹æ³•ã€æˆ–將腳本附加至目標節點上。"
+msgstr "找ä¸åˆ°ç›®æ¨™æ–¹æ³•ï¼è«‹æŒ‡å®šä¸€å€‹æœ‰æ•ˆçš„方法ã€æˆ–將腳本附加至目標節點上。"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Connect to Node:"
-msgstr "連接到節點:"
+msgstr "連接至節點:"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Connect to Script:"
-msgstr "無法連接到主機:"
+msgstr "連接至腳本:"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "From Signal:"
-msgstr "訊號:"
+msgstr "自訊號:"
#: editor/connections_dialog.cpp
msgid "Scene does not contain any script."
-msgstr "場景中沒有任何的腳本。"
+msgstr "場景中無任何的腳本。"
#: editor/connections_dialog.cpp editor/editor_autoload_settings.cpp
#: editor/groups_editor.cpp editor/plugins/item_list_editor_plugin.cpp
@@ -850,39 +806,36 @@ msgstr "移除"
#: editor/connections_dialog.cpp
msgid "Add Extra Call Argument:"
-msgstr "新增é¡å¤–呼å«åƒæ•¸:"
+msgstr "新增é¡å¤–呼å«å¼•æ•¸ï¼š"
#: editor/connections_dialog.cpp
msgid "Extra Call Arguments:"
-msgstr "é¡å¤–呼å«åƒæ•¸:"
+msgstr "é¡å¤–呼å«å¼•æ•¸ï¼š"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Receiver Method:"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "Receiver 方法:"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Advanced"
-msgstr "進階設定"
+msgstr "進階"
#: editor/connections_dialog.cpp
-#, fuzzy
msgid "Deferred"
msgstr "延é²"
#: editor/connections_dialog.cpp
msgid ""
"Defers the signal, storing it in a queue and only firing it at idle time."
-msgstr "延後é€å‡ºè¨Šè™Ÿï¼Œå°‡è¨Šè™Ÿæš«å­˜è‡³ä½‡åˆ—中,等到閒置時å†é€å‡ºã€‚"
+msgstr "延後é€å‡ºè¨Šè™Ÿï¼Œå°‡å…¶å­˜æ”¾æ–¼ä½‡åˆ—中並待閒置時å†é€å‡ºã€‚"
#: editor/connections_dialog.cpp
msgid "Oneshot"
-msgstr "一次性"
+msgstr "單次"
#: editor/connections_dialog.cpp
msgid "Disconnects the signal after its first emission."
-msgstr "第一次é€å‡ºè¨Šè™Ÿå¾Œå³ä¸­æ–·é€£æŽ¥ã€‚"
+msgstr "首次發é€è¨Šè™Ÿå¾Œä¸­æ–·é€£æŽ¥ã€‚"
#: editor/connections_dialog.cpp
msgid "Cannot connect signal"
@@ -892,7 +845,6 @@ msgstr "無法連接訊號"
#: editor/export_template_manager.cpp editor/groups_editor.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -913,15 +865,15 @@ msgstr "訊號:"
#: editor/connections_dialog.cpp
msgid "Connect '%s' to '%s'"
-msgstr "將 '%s' 連接到 '%s'"
+msgstr "將「%sã€é€£æŽ¥è‡³ã€Œ%sã€"
#: editor/connections_dialog.cpp
msgid "Disconnect '%s' from '%s'"
-msgstr "將 '%s' 從 '%s' 中斷連接"
+msgstr "將「%sã€è‡ªã€Œ%sã€æ–·é–‹"
#: editor/connections_dialog.cpp
msgid "Disconnect all from signal: '%s'"
-msgstr "中斷所有來自 '%s' 的訊號連接"
+msgstr "中斷所有來自「%sã€çš„訊號"
#: editor/connections_dialog.cpp
msgid "Connect..."
@@ -930,7 +882,7 @@ msgstr "連接..."
#: editor/connections_dialog.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Disconnect"
-msgstr "æ–·ç·š"
+msgstr "斷開訊號連接"
#: editor/connections_dialog.cpp
msgid "Connect a Signal to a Method"
@@ -942,7 +894,7 @@ msgstr "編輯連接內容:"
#: editor/connections_dialog.cpp
msgid "Are you sure you want to remove all connections from the \"%s\" signal?"
-msgstr "確定è¦åˆ é™¤æ‰€æœ‰ä¾†è‡ª \"%s\" 的訊號連接嗎?"
+msgstr "確定è¦åˆ é™¤æ‰€æœ‰ä¾†è‡ªè¨Šè™Ÿã€Œ%sã€çš„連接嗎?"
#: editor/connections_dialog.cpp editor/editor_help.cpp editor/node_dock.cpp
msgid "Signals"
@@ -954,7 +906,7 @@ msgstr "確定è¦åˆªé™¤æ‰€æœ‰ä¾†è‡ªæ­¤è¨Šè™Ÿçš„連接嗎?"
#: editor/connections_dialog.cpp
msgid "Disconnect All"
-msgstr "中斷所有連接"
+msgstr "中斷全部"
#: editor/connections_dialog.cpp
msgid "Edit..."
@@ -962,40 +914,40 @@ msgstr "編輯…"
#: editor/connections_dialog.cpp
msgid "Go To Method"
-msgstr "å‰å¾€æ–¹æ³•"
+msgstr "跳至方法"
#: editor/create_dialog.cpp
msgid "Change %s Type"
-msgstr "變更 %s 種類"
+msgstr "更改 %s 型別"
#: editor/create_dialog.cpp editor/project_settings_editor.cpp
msgid "Change"
-msgstr "æ›´æ›"
+msgstr "更改"
#: editor/create_dialog.cpp
msgid "Create New %s"
-msgstr "新增 %s"
+msgstr "建立新的 %s"
#: editor/create_dialog.cpp editor/editor_file_dialog.cpp
#: editor/filesystem_dock.cpp
msgid "Favorites:"
-msgstr "我的最愛:"
+msgstr "我的最愛:"
#: editor/create_dialog.cpp editor/editor_file_dialog.cpp
msgid "Recent:"
-msgstr "最近存å–:"
+msgstr "最近存å–:"
#: editor/create_dialog.cpp editor/plugins/script_editor_plugin.cpp
#: editor/property_selector.cpp editor/quick_open.cpp
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Search:"
-msgstr "æœå°‹:"
+msgstr "æœå°‹ï¼š"
#: editor/create_dialog.cpp editor/plugins/script_editor_plugin.cpp
#: editor/property_selector.cpp editor/quick_open.cpp
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Matches:"
-msgstr "符åˆæ¢ä»¶:"
+msgstr "符åˆæ¢ä»¶ï¼š"
#: editor/create_dialog.cpp editor/editor_plugin_settings.cpp
#: editor/plugin_config_dialog.cpp
@@ -1003,37 +955,36 @@ msgstr "符åˆæ¢ä»¶:"
#: editor/plugins/visual_shader_editor_plugin.cpp editor/property_selector.cpp
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Description:"
-msgstr "æè¿°:"
+msgstr "æ述:"
#: editor/dependency_editor.cpp
msgid "Search Replacement For:"
-msgstr "尋找å–代目標:"
+msgstr "尋找å–代目標:"
#: editor/dependency_editor.cpp
msgid "Dependencies For:"
-msgstr "相ä¾æ–¼:"
+msgstr "相ä¾æ–¼ï¼š"
#: editor/dependency_editor.cpp
msgid ""
"Scene '%s' is currently being edited.\n"
"Changes will only take effect when reloaded."
msgstr ""
-"場景 '%s' 正在編譯中。\n"
-"需é‡æ–°è¼‰å…¥æ‰èƒ½ä½¿è®Šæ›´ç”Ÿæ•ˆã€‚"
+"場景「%sã€æ­£åœ¨ç·¨è¼¯ä¸­ã€‚\n"
+"變更會在é‡æ–°è¼‰å…¥æ™‚套用。"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid ""
"Resource '%s' is in use.\n"
"Changes will only take effect when reloaded."
msgstr ""
-"'%s' 資æºæ­£åœ¨ä½¿ç”¨ä¸­ã€‚\n"
+"資æºã€Œ%sã€æ­£åœ¨ä½¿ç”¨ä¸­ã€‚\n"
"變更會在é‡æ–°è¼‰å…¥æ™‚套用。"
#: editor/dependency_editor.cpp
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Dependencies"
-msgstr "相ä¾"
+msgstr "相ä¾æ€§"
#: editor/dependency_editor.cpp
msgid "Resource"
@@ -1046,7 +997,7 @@ msgstr "路徑"
#: editor/dependency_editor.cpp
msgid "Dependencies:"
-msgstr "相ä¾:"
+msgstr "相ä¾æ–¼ï¼š"
#: editor/dependency_editor.cpp
msgid "Fix Broken"
@@ -1058,7 +1009,7 @@ msgstr "相ä¾æ€§ç·¨è¼¯å™¨"
#: editor/dependency_editor.cpp
msgid "Search Replacement Resource:"
-msgstr "æœå°‹æ›¿ä»£è³‡æºï¼š"
+msgstr "æœå°‹ä¸¦å–代資æºï¼š"
#: editor/dependency_editor.cpp editor/editor_file_dialog.cpp
#: editor/editor_help_search.cpp editor/editor_node.cpp
@@ -1072,12 +1023,11 @@ msgstr "é–‹å•Ÿ"
#: editor/dependency_editor.cpp
msgid "Owners Of:"
-msgstr "æ“有者:"
+msgstr "æ“有者:"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid "Remove selected files from the project? (Can't be restored)"
-msgstr "此動作無法復原, 確定è¦å¾žå°ˆæ¡ˆä¸­åˆªé™¤æ‰€é¸çš„檔案?"
+msgstr "確定è¦å°‡æ‰€é¸æª”案自專案中移除嗎?(無法復原)"
#: editor/dependency_editor.cpp
msgid ""
@@ -1085,21 +1035,20 @@ msgid ""
"work.\n"
"Remove them anyway? (no undo)"
msgstr ""
-"刪除這些檔案å¯èƒ½é€ æˆå…¶ä»–資æºç„¡æ³•æ­£å¸¸é‹ä½œ\n"
-"此動作無法復原, 確定è¦åˆªé™¤å—Ž?"
+"有其他資æºéœ€è¦æ­£åœ¨åˆªé™¤çš„檔案以正常é‹ä½œã€‚\n"
+"ä¾ç„¶è¦ç§»é™¤å—Žï¼Ÿï¼ˆç„¡æ³•å¾©åŽŸï¼‰"
#: editor/dependency_editor.cpp
msgid "Cannot remove:"
-msgstr "無法移除:"
+msgstr "無法移除:"
#: editor/dependency_editor.cpp
msgid "Error loading:"
-msgstr "載入時發生錯誤:"
+msgstr "載入時發生錯誤:"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid "Load failed due to missing dependencies:"
-msgstr "場景缺少了æŸäº›è³‡æºä»¥è‡³æ–¼ç„¡æ³•è¼‰å…¥"
+msgstr "由於缺ä¹ä¸‹åˆ—相ä¾æ€§å…§å®¹è€Œç„¡æ³•è¼‰å…¥ï¼š"
#: editor/dependency_editor.cpp editor/editor_node.cpp
msgid "Open Anyway"
@@ -1107,7 +1056,7 @@ msgstr "強制開啟"
#: editor/dependency_editor.cpp
msgid "Which action should be taken?"
-msgstr "該執行什麼æ“作呢?"
+msgstr "該執行什麼æ“作?"
#: editor/dependency_editor.cpp
msgid "Fix Dependencies"
@@ -1115,20 +1064,19 @@ msgstr "修復相ä¾æ€§"
#: editor/dependency_editor.cpp
msgid "Errors loading!"
-msgstr "載入錯誤!"
+msgstr "載入錯誤ï¼"
#: editor/dependency_editor.cpp
msgid "Permanently delete %d item(s)? (No undo!)"
-msgstr "確定è¦æ°¸ä¹…刪除 %d 個物件 ? (無法復原)"
+msgstr "是å¦è¦æ°¸ä¹…刪除「%dã€å€‹é …目?(無法復原ï¼ï¼‰"
#: editor/dependency_editor.cpp
-#, fuzzy
msgid "Show Dependencies"
-msgstr "相ä¾"
+msgstr "顯示相ä¾æ€§"
#: editor/dependency_editor.cpp
msgid "Orphan Resource Explorer"
-msgstr "孤立資料管ç†å™¨"
+msgstr "孤立資æºç€è¦½å™¨"
#: editor/dependency_editor.cpp editor/editor_audio_buses.cpp
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
@@ -1144,21 +1092,19 @@ msgstr "æ“有"
#: editor/dependency_editor.cpp
msgid "Resources Without Explicit Ownership:"
-msgstr "沒有明定æ“有者的資æºï¼š"
+msgstr "沒有明確從屬關係的資æºï¼š"
#: editor/dictionary_property_edit.cpp
-#, fuzzy
msgid "Change Dictionary Key"
-msgstr "改變字典 key"
+msgstr "改變字典éµ"
#: editor/dictionary_property_edit.cpp
-#, fuzzy
msgid "Change Dictionary Value"
-msgstr "改變字典 value"
+msgstr "改變字典值"
#: editor/editor_about.cpp
msgid "Thanks from the Godot community!"
-msgstr "Godot 社群感è¬ä½ !"
+msgstr "Godot 社群感è¬ä½ ï¼"
#: editor/editor_about.cpp
msgid "Godot Engine contributors"
@@ -1170,11 +1116,11 @@ msgstr "專案創始人"
#: editor/editor_about.cpp
msgid "Lead Developer"
-msgstr "主開發者"
+msgstr "主è¦é–‹ç™¼è€…"
#: editor/editor_about.cpp
msgid "Project Manager "
-msgstr "專案管ç†äºº "
+msgstr "專案管ç†å“¡ "
#: editor/editor_about.cpp
msgid "Developers"
@@ -1214,23 +1160,21 @@ msgstr "æ贈者"
#: editor/editor_about.cpp
msgid "License"
-msgstr "授權"
+msgstr "授權æ¢æ¬¾"
#: editor/editor_about.cpp
-#, fuzzy
msgid "Third-party Licenses"
msgstr "第三方授權æ¢æ¬¾"
#: editor/editor_about.cpp
-#, fuzzy
msgid ""
"Godot Engine relies on a number of third-party free and open source "
"libraries, all compatible with the terms of its MIT license. The following "
"is an exhaustive list of all such third-party components with their "
"respective copyright statements and license terms."
msgstr ""
-"Godot Engine ä¾è³´è‘—許多與 MIT 授權æ¢æ¬¾ç›¸å®¹ã€è‡ªç”±é–‹æºçš„第三方函å¼åº«ã€‚以下是這"
-"些第三方元件的完整列表,附有它們å„自的著作權宣示與授權æ¢æ¬¾ã€‚"
+"Godot Engine ä¾è³´æ•¸å€‹è‡ªç”±ä¸”開放原始碼的第三方函å¼åº«ï¼Œæ‰€æœ‰å‡½å¼åº«çš†ç›¸å®¹æ–¼ MIT "
+"授權æ¢æ¬¾ã€‚以下是這些第三方元件的完整列表於其å„自之著作權宣告與授權æ¢æ¬¾ã€‚"
#: editor/editor_about.cpp
msgid "All Components"
@@ -1242,17 +1186,15 @@ msgstr "元件"
#: editor/editor_about.cpp
msgid "Licenses"
-msgstr "授權"
+msgstr "授權æ¢æ¬¾"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
-#, fuzzy
msgid "Error opening package file, not in ZIP format."
-msgstr "é–‹å•Ÿå¥—ä»¶æª”æ¡ˆå‡ºéŒ¯ï¼Œéž zip æ ¼å¼ã€‚"
+msgstr "ç„¡æ³•é–‹å•Ÿå¥—ä»¶æª”æ¡ˆï¼Œéž ZIP æ ¼å¼ã€‚"
#: editor/editor_asset_installer.cpp
-#, fuzzy
msgid "%s (Already Exists)"
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "%s(已經存在)"
#: editor/editor_asset_installer.cpp
msgid "Uncompressing Assets"
@@ -1260,27 +1202,24 @@ msgstr "正在解壓縮素æ"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
msgid "The following files failed extraction from package:"
-msgstr "æå–以下檔案失敗:"
+msgstr "自套件中å–得下列檔案失敗:"
#: editor/editor_asset_installer.cpp
-#, fuzzy
msgid "And %s more files."
-msgstr "還有 %d 個檔案"
+msgstr "與其他 %d 個檔案。"
#: editor/editor_asset_installer.cpp editor/project_manager.cpp
-#, fuzzy
msgid "Package installed successfully!"
-msgstr "套件安è£æˆåŠŸ!"
+msgstr "套件安è£æˆåŠŸï¼"
#: editor/editor_asset_installer.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Success!"
-msgstr "æˆåŠŸ!"
+msgstr "æˆåŠŸï¼"
#: editor/editor_asset_installer.cpp
-#, fuzzy
msgid "Package Contents:"
-msgstr "內容:"
+msgstr "套件內容:"
#: editor/editor_asset_installer.cpp editor/editor_node.cpp
msgid "Install"
@@ -1292,7 +1231,7 @@ msgstr "套件安è£"
#: editor/editor_audio_buses.cpp
msgid "Speakers"
-msgstr "å–‡å­"
+msgstr "æšè²å™¨"
#: editor/editor_audio_buses.cpp
msgid "Add Effect"
@@ -1300,34 +1239,31 @@ msgstr "新增效果"
#: editor/editor_audio_buses.cpp
msgid "Rename Audio Bus"
-msgstr "é‡æ–°å‘½å Audio Bus"
+msgstr "é‡æ–°å‘½å音訊 Bus"
#: editor/editor_audio_buses.cpp
msgid "Change Audio Bus Volume"
-msgstr "變更 Audio Bus 音é‡"
+msgstr "更改音訊 Bus 音é‡"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Toggle Audio Bus Solo"
-msgstr "åˆ‡æ› Audio Bus çš„ Solo"
+msgstr "切æ›éŸ³è¨Š Bus çš„ Solo"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Toggle Audio Bus Mute"
-msgstr "åˆ‡æ› Audio Bus çš„ Mute"
+msgstr "éœéŸ³ï¼å–消éœéŸ³éŸ³è¨Š Bus"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Toggle Audio Bus Bypass Effects"
-msgstr "åˆ‡æ› Audio Bus 忽略效果"
+msgstr "忽略ï¼å–消忽略音訊 Bus 效果"
#: editor/editor_audio_buses.cpp
msgid "Select Audio Bus Send"
-msgstr "é¸æ“‡ Audio Bus 輸出地點"
+msgstr "é¸æ“‡ Bus 輸出地點"
#: editor/editor_audio_buses.cpp
msgid "Add Audio Bus Effect"
-msgstr "新增 Audio Bus 效果"
+msgstr "新增音效 Bus 效果"
#: editor/editor_audio_buses.cpp
msgid "Move Bus Effect"
@@ -1338,12 +1274,10 @@ msgid "Delete Bus Effect"
msgstr "刪除 Bus 效果"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Drag & drop to rearrange."
-msgstr "Audio Bus。拖放以é‡æ–°æŽ’列。"
+msgstr "拖放以é‡æ–°æŽ’列。"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Solo"
msgstr "Solo"
@@ -1352,9 +1286,8 @@ msgid "Mute"
msgstr "éœéŸ³"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Bypass"
-msgstr "忽略效果 (Bypass)"
+msgstr "忽略效果"
#: editor/editor_audio_buses.cpp
msgid "Bus options"
@@ -1363,7 +1296,7 @@ msgstr "Bus é¸é …"
#: editor/editor_audio_buses.cpp editor/filesystem_dock.cpp
#: editor/plugins/animation_player_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "Duplicate"
-msgstr "製作複本"
+msgstr "é‡è¤‡"
#: editor/editor_audio_buses.cpp
msgid "Reset Volume"
@@ -1375,23 +1308,23 @@ msgstr "刪除效果"
#: editor/editor_audio_buses.cpp
msgid "Audio"
-msgstr "è²éŸ³"
+msgstr "音訊"
#: editor/editor_audio_buses.cpp
msgid "Add Audio Bus"
-msgstr "新增 Audio Bus"
+msgstr "新增音訊 Bus"
#: editor/editor_audio_buses.cpp
msgid "Master bus can't be deleted!"
-msgstr "Master Bus ä¸èƒ½è¢«åˆªé™¤!"
+msgstr "Master Bus ä¸å¯åˆªé™¤ï¼"
#: editor/editor_audio_buses.cpp
msgid "Delete Audio Bus"
-msgstr "刪除 Audio Bus"
+msgstr "刪除音訊 Bus"
#: editor/editor_audio_buses.cpp
msgid "Duplicate Audio Bus"
-msgstr "製作 Audio Bus 的複本"
+msgstr "é‡è¤‡éŸ³è¨Š Bus"
#: editor/editor_audio_buses.cpp
msgid "Reset Bus Volume"
@@ -1399,46 +1332,43 @@ msgstr "é‡è¨­ Bus 音é‡"
#: editor/editor_audio_buses.cpp
msgid "Move Audio Bus"
-msgstr "移動 Audio Bus"
+msgstr "移動音訊 Bus"
#: editor/editor_audio_buses.cpp
msgid "Save Audio Bus Layout As..."
-msgstr "å¦å­˜ Audio Bus é…置為..."
+msgstr "å¦å­˜éŸ³è¨Š Bus é…置為..."
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Location for New Layout..."
msgstr "æ–°é…置的ä½ç½®..."
#: editor/editor_audio_buses.cpp
msgid "Open Audio Bus Layout"
-msgstr "é–‹å•Ÿ Audio Bus é…ç½®"
+msgstr "開啟音訊 Bus é…ç½®"
#: editor/editor_audio_buses.cpp
msgid "There is no '%s' file."
-msgstr "'%s' 這個檔案ä¸å­˜åœ¨ã€‚"
+msgstr "檔案「%sã€ä¸å­˜åœ¨ã€‚"
#: editor/editor_audio_buses.cpp editor/plugins/canvas_item_editor_plugin.cpp
msgid "Layout"
-msgstr "佈局"
+msgstr "ç•«é¢é…ç½®"
#: editor/editor_audio_buses.cpp
msgid "Invalid file, not an audio bus layout."
-msgstr "檔案格å¼ä¸æ­£ç¢ºï¼Œä¸æ˜¯ Audio Bus é…置檔。"
+msgstr "無效的檔案,或該檔案ä¸æ˜¯éŸ³è¨Š Bus é…置檔。"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Error saving file: %s"
-msgstr "儲存資æºéŒ¯èª¤!"
+msgstr "無法ä¿å­˜æª”案:%s"
#: editor/editor_audio_buses.cpp
msgid "Add Bus"
msgstr "新增 Bus"
#: editor/editor_audio_buses.cpp
-#, fuzzy
msgid "Add a new Audio Bus to this layout."
-msgstr "å¦å­˜ Audio Bus é…置為..."
+msgstr "新增一個新的音訊 Bus 至該é…置。"
#: editor/editor_audio_buses.cpp editor/editor_properties.cpp
#: editor/plugins/animation_player_editor_plugin.cpp editor/property_editor.cpp
@@ -1456,11 +1386,11 @@ msgstr "å¦å­˜æ–°æª”"
#: editor/editor_audio_buses.cpp
msgid "Save this Bus Layout to a file."
-msgstr "儲存目å‰çš„ Bus é…置到檔案裡。"
+msgstr "將該 Bus é…ç½®ä¿å­˜è‡³æª”案。"
#: editor/editor_audio_buses.cpp editor/import_dock.cpp
msgid "Load Default"
-msgstr "載入é è¨­å€¼"
+msgstr "載入é è¨­"
#: editor/editor_audio_buses.cpp
msgid "Load the default Bus Layout."
@@ -1472,52 +1402,45 @@ msgstr "建立新的 Bus é…置。"
#: editor/editor_autoload_settings.cpp
msgid "Invalid name."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的å稱。"
#: editor/editor_autoload_settings.cpp
msgid "Valid characters:"
-msgstr "åˆæ³•å­—å…ƒ:"
+msgstr "å¯ä½¿ç”¨çš„字元:"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Must not collide with an existing engine class name."
-msgstr "ä¸æ­£ç¢ºçš„å字。åå­—ä¸èƒ½èˆ‡ç¾æœ‰çš„ engine class åè¡çªã€‚"
+msgstr "ä¸å¯èˆ‡ç¾å­˜çš„引擎類別å稱è¡çªã€‚"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Must not collide with an existing built-in type name."
-msgstr "無效å稱.ä¸èƒ½èˆ‡ç¾æœ‰çš„內置類型å稱沖çª."
+msgstr "ä¸å¯èˆ‡å…§å»ºçš„列表å稱è¡çªã€‚"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Must not collide with an existing global constant name."
-msgstr "無效å稱.ä¸èƒ½è·Ÿå·²ç¶“存在的全局常é‡å稱é‡è¤‡."
+msgstr "ä¸å¯èˆ‡ç¾å­˜çš„全域常數å稱è¡çªã€‚"
#: editor/editor_autoload_settings.cpp
msgid "Keyword cannot be used as an autoload name."
-msgstr "無法使用關éµå­—當作自動載入的å稱。"
+msgstr "é—œéµå­—無法作為 Autoload å稱。"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Autoload '%s' already exists!"
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "Autoload「%sã€å·²ç¶“存在ï¼"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Rename Autoload"
msgstr "é‡æ–°å‘½å Autoload"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Toggle AutoLoad Globals"
-msgstr "åˆ‡æ› AutoLoad 的全域變數"
+msgstr "觸發全域 AutoLoad"
#: editor/editor_autoload_settings.cpp
msgid "Move Autoload"
msgstr "移動 Autoload"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Remove Autoload"
msgstr "刪除 Autoload"
@@ -1526,38 +1449,27 @@ msgid "Enable"
msgstr "啟用"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Rearrange Autoloads"
msgstr "é‡æ–°æŽ’列 Autoload"
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-#, fuzzy
-msgid "Invalid path."
-msgstr "無效的路徑."
-
-#: editor/editor_autoload_settings.cpp editor/script_create_dialog.cpp
-msgid "File does not exist."
-msgstr "檔案ä¸å­˜åœ¨."
-
#: editor/editor_autoload_settings.cpp
-msgid "Not in resource path."
-msgstr "ä¸åœ¨è³‡æºè·¯å¾‘中。"
+msgid "Can't add autoload:"
+msgstr "無法新增 Autoload:"
#: editor/editor_autoload_settings.cpp
-#, fuzzy
msgid "Add AutoLoad"
-msgstr "新增 AutoLoad"
+msgstr "新增 Autoload"
#: editor/editor_autoload_settings.cpp editor/editor_file_dialog.cpp
#: editor/editor_plugin_settings.cpp
#: editor/plugins/animation_tree_editor_plugin.cpp
#: editor/script_create_dialog.cpp scene/gui/file_dialog.cpp
msgid "Path:"
-msgstr "路徑:"
+msgstr "路徑:"
#: editor/editor_autoload_settings.cpp
msgid "Node Name:"
-msgstr "節點å稱:"
+msgstr "節點å稱:"
#: editor/editor_autoload_settings.cpp editor/editor_help_search.cpp
#: editor/editor_profiler.cpp editor/project_manager.cpp
@@ -1567,7 +1479,7 @@ msgstr "å稱"
#: editor/editor_autoload_settings.cpp
msgid "Singleton"
-msgstr "單例"
+msgstr "單例 (Singleton)"
#: editor/editor_data.cpp editor/inspector_dock.cpp
msgid "Paste Params"
@@ -1583,21 +1495,19 @@ msgstr "正在儲存變更..."
#: editor/editor_data.cpp
msgid "Updating scene..."
-msgstr "場景更新中…"
+msgstr "正在更新場景…"
#: editor/editor_data.cpp editor/editor_properties.cpp
-#, fuzzy
msgid "[empty]"
-msgstr "(空)"
+msgstr "[空]"
#: editor/editor_data.cpp
msgid "[unsaved]"
-msgstr "(未儲存)"
+msgstr "[未ä¿å­˜]"
#: editor/editor_dir_dialog.cpp
-#, fuzzy
msgid "Please select a base directory first."
-msgstr "è«‹å…ˆé¸æ“‡ä¸€å€‹åŸºåº•çš„資料夾"
+msgstr "è«‹å…ˆé¸æ“‡ä¸€å€‹åŸºç¤Žçš„資料夾。"
#: editor/editor_dir_dialog.cpp
msgid "Choose a Directory"
@@ -1607,19 +1517,19 @@ msgstr "é¸æ“‡è³‡æ–™å¤¾"
#: editor/filesystem_dock.cpp editor/project_manager.cpp
#: scene/gui/file_dialog.cpp
msgid "Create Folder"
-msgstr "新增資料夾"
+msgstr "建立資料夾"
#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
#: editor/editor_plugin_settings.cpp editor/filesystem_dock.cpp
#: editor/plugins/theme_editor_plugin.cpp editor/project_export.cpp
#: modules/visual_script/visual_script_editor.cpp scene/gui/file_dialog.cpp
msgid "Name:"
-msgstr "å稱:"
+msgstr "å稱:"
#: editor/editor_dir_dialog.cpp editor/editor_file_dialog.cpp
#: editor/filesystem_dock.cpp scene/gui/file_dialog.cpp
msgid "Could not create folder."
-msgstr "無法新增資料夾."
+msgstr "無法新增資料夾。"
#: editor/editor_dir_dialog.cpp
msgid "Choose"
@@ -1627,181 +1537,158 @@ msgstr "é¸æ“‡"
#: editor/editor_export.cpp
msgid "Storing File:"
-msgstr "儲存檔案:"
+msgstr "儲存檔案:"
#: editor/editor_export.cpp
msgid "No export template found at the expected path:"
-msgstr "在é æœŸçš„路徑中找ä¸åˆ°åŒ¯å…¥æ¨¡æ¿ï¼š"
+msgstr "在é æœŸçš„路徑中找ä¸åˆ°åŒ¯å‡ºæ¨£æ¿ï¼š"
#: editor/editor_export.cpp
msgid "Packing"
-msgstr "包è£ä¸­"
+msgstr "正在打包"
#: editor/editor_export.cpp
msgid ""
"Target platform requires 'ETC' texture compression for GLES2. Enable 'Import "
"Etc' in Project Settings."
msgstr ""
-"使用 GLES2 時,目標平å°è¦æ±‚使用 'ETC' æ質壓縮。請在「專案設定ã€ä¸­é–‹å•Ÿã€ŒåŒ¯å…¥ "
-"Etcã€ã€‚"
+"目標平å°ä¸Šçš„ GLES2 必須使用「ETCã€ç´‹ç†å£“縮。請在專案設定中啟用「匯入 ETCã€ã€‚"
#: editor/editor_export.cpp
msgid ""
"Target platform requires 'ETC2' texture compression for GLES3. Enable "
"'Import Etc 2' in Project Settings."
msgstr ""
-"使用 GLES3 時,目標平å°è¦æ±‚使用 'ETC2' æ質壓縮。請在「專案設定ã€ä¸­é–‹å•Ÿã€ŒåŒ¯"
-"å…¥ Etc 2ã€ã€‚"
+"目標平å°ä¸Šçš„ GLES3 必須使用「ETC2ã€ç´‹ç†å£“縮。請在專案設定中啟用「匯入 "
+"ETC2ã€ã€‚"
#: editor/editor_export.cpp
-#, fuzzy
msgid ""
"Target platform requires 'ETC' texture compression for the driver fallback "
"to GLES2.\n"
"Enable 'Import Etc' in Project Settings, or disable 'Driver Fallback "
"Enabled'."
msgstr ""
-"使用「回退至 GLES2ã€çš„驅動器時,目標平å°è¦æ±‚使用 'ETC' 貼圖壓縮。\n"
-"請在「專案設定ã€ä¸­é–‹å•Ÿã€ŒåŒ¯å…¥ Etcã€ï¼Œæˆ–是關閉「開啟驅動器回退ã€é¸é …。"
+"目標平å°ä¸Šçš„ GLES2 回退驅動器功能必須使用「ETCã€ç´‹ç†å£“縮。\n"
+"請在專案設定中啟用「匯入 ETCã€æˆ–是ç¦ç”¨ã€Œå•Ÿç”¨é©…動器回退ã€ã€‚"
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
#: platform/osx/export/export.cpp platform/uwp/export/export.cpp
msgid "Custom debug template not found."
-msgstr "找ä¸åˆ°è‡ªå®šç¾©èª¿è©¦ç¯„本。"
+msgstr "找ä¸åˆ°è‡ªå®šç¾©åµéŒ¯æ¨£æ¿ã€‚"
#: editor/editor_export.cpp platform/android/export/export.cpp
#: platform/iphone/export/export.cpp platform/javascript/export/export.cpp
#: platform/osx/export/export.cpp platform/uwp/export/export.cpp
msgid "Custom release template not found."
-msgstr "找ä¸åˆ°è‡ªå®šç¾©ç™¼ä½ˆç¯„本。"
+msgstr "找ä¸åˆ°è‡ªå®šç¾©é‡‹å‡ºæ¨£æ¿ã€‚"
#: editor/editor_export.cpp platform/javascript/export/export.cpp
msgid "Template file not found:"
-msgstr "找ä¸åˆ°ç¯„本檔案:"
+msgstr "找ä¸åˆ°æ¨£æ¿æª”案:"
#: editor/editor_export.cpp
msgid "On 32-bit exports the embedded PCK cannot be bigger than 4 GiB."
-msgstr "匯出為 32 ä½å…ƒåŸ·è¡Œæª”時,內嵌的 PCK 大å°ä¸å¾—è¶…éŽ 4 GB。"
+msgstr "匯出 32 ä½å…ƒæª”時,內嵌的 PCK 大å°ä¸å¾—è¶…éŽ 4 GB。"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "3D Editor"
-msgstr "編輯器"
+msgstr "3D 編輯器"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Script Editor"
-msgstr "開啟腳本編輯器"
+msgstr "腳本編輯器"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Asset Library"
-msgstr "é–‹å•Ÿç´ æ倉庫"
+msgstr "ç´ æ庫"
#: editor/editor_feature_profile.cpp
msgid "Scene Tree Editing"
-msgstr "正在編譯場景樹"
+msgstr "正在編輯場景樹"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Import Dock"
-msgstr "å°Žå…¥"
+msgstr "匯入 Dock"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Node Dock"
-msgstr "節點å稱:"
+msgstr "節點 Dock"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "FileSystem and Import Docks"
-msgstr "文件系統"
+msgstr "檔案系統與匯入 Dock"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Erase profile '%s'? (no undo)"
-msgstr "å–代全部"
+msgstr "確定è¦æ¸…除 Profile「%sã€å—Žï¼Ÿï¼ˆç„¡æ³•å¾©åŽŸï¼‰"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Profile must be a valid filename and must not contain '.'"
-msgstr "Profile 必須為有效的檔å,而且其中ä¸å¾—åŒ…å« '.' 字元。"
+msgstr "Profile 必須為一個有效的檔案å稱,並且ä¸åŒ…å«ã€Œ.ã€"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Profile with this name already exists."
-msgstr "具有此å稱的檔或資料夾已存在。"
+msgstr "已有相åŒå稱的 Profile 存在。"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "(Editor Disabled, Properties Disabled)"
-msgstr "(編譯已關閉,屬性已關閉)"
+msgstr "(已ç¦ç”¨ç·¨è¼¯å™¨ï¼Œå·²ç¦ç”¨å±¬æ€§ï¼‰"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "(Properties Disabled)"
-msgstr "僅屬性"
+msgstr "(已ç¦ç”¨å±¬æ€§ï¼‰"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "(Editor Disabled)"
-msgstr "å·²åœç”¨"
+msgstr "(已ç¦ç”¨ç·¨è¼¯å™¨ï¼‰"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Class Options:"
-msgstr "æè¿°:"
+msgstr "類別é¸é …:"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Enable Contextual Editor"
-msgstr "開啟下一個編輯器"
+msgstr "啟用上下文編輯器"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Enabled Properties:"
-msgstr "效能:"
+msgstr "啟用屬性:"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Enabled Features:"
-msgstr "功能"
+msgstr "啟用功能:"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Enabled Classes:"
-msgstr "æœå°‹ Class"
+msgstr "啟用類別:"
#: editor/editor_feature_profile.cpp
msgid "File '%s' format is invalid, import aborted."
-msgstr "檔案 '%s' 的內容格å¼éŒ¯èª¤ï¼Œä¸­æ­¢åŒ¯å…¥ã€‚"
+msgstr "檔案「%sã€çš„æ ¼å¼ç„¡æ•ˆï¼Œå·²ä¸­æ­¢åŒ¯å…¥ã€‚"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid ""
"Profile '%s' already exists. Remove it first before importing, import "
"aborted."
-msgstr "Profile '%s' 已經存在。在匯入的å‰è«‹å…ˆç§»é™¤ã€‚中止匯入。"
+msgstr "Profile「%sã€å·²ç¶“存在。匯入å‰è«‹å…ˆå°‡å…¶ç§»é™¤ã€‚已中止匯入。"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Error saving profile to path: '%s'."
-msgstr "載入場景時發生錯誤"
+msgstr "ä¿å­˜ Profile 至路徑「%sã€æ™‚發生錯誤。"
#: editor/editor_feature_profile.cpp
msgid "Unset"
msgstr "未設定"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Current Profile:"
-msgstr "當å‰ç‰ˆæœ¬:"
+msgstr "ç›®å‰ç‰ˆæœ¬ï¼š"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Make Current"
-msgstr "當å‰ï¼š"
+msgstr "設為目å‰çš„"
#: editor/editor_feature_profile.cpp
#: editor/plugins/animation_player_editor_plugin.cpp
@@ -1812,51 +1699,43 @@ msgstr "新增"
#: editor/editor_feature_profile.cpp editor/editor_node.cpp
#: editor/project_manager.cpp
msgid "Import"
-msgstr "å°Žå…¥"
+msgstr "匯入"
#: editor/editor_feature_profile.cpp editor/project_export.cpp
msgid "Export"
-msgstr "輸出"
+msgstr "匯出"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Available Profiles:"
-msgstr "效能:"
+msgstr "å¯ç”¨çš„ Profile:"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Class Options"
-msgstr "æè¿°:"
+msgstr "類別é¸é …"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "New profile name:"
-msgstr "æ–°å稱:"
+msgstr "新增 Profile å稱:"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Erase Profile"
-msgstr "擦除磚塊地圖"
+msgstr "清除 Profile"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Godot Feature Profile"
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "Godot 功能 Profile"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Import Profile(s)"
-msgstr "已導入的項目"
+msgstr "匯入 Profile"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Export Profile"
-msgstr "輸出專案"
+msgstr "匯出 Profile"
#: editor/editor_feature_profile.cpp
-#, fuzzy
msgid "Manage Editor Feature Profiles"
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "管ç†ç·¨è¼¯å™¨åŠŸèƒ½ Profile"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Select Current Folder"
@@ -1864,10 +1743,9 @@ msgstr "é¸æ“‡ç›®å‰çš„資料夾"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "File Exists, Overwrite?"
-msgstr "檔案已經存在, è¦è¦†å¯«å—Ž?"
+msgstr "檔案已存在,是å¦è¦†è“‹ï¼Ÿ"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Select This Folder"
msgstr "é¸æ“‡æ­¤è³‡æ–™å¤¾"
@@ -1876,15 +1754,13 @@ msgid "Copy Path"
msgstr "複製路徑"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
-#, fuzzy
msgid "Open in File Manager"
-msgstr "在檔案管ç†å“¡å…§é¡¯ç¤º"
+msgstr "在檔案總管中開啟"
#: editor/editor_file_dialog.cpp editor/editor_node.cpp
#: editor/filesystem_dock.cpp editor/project_manager.cpp
-#, fuzzy
msgid "Show in File Manager"
-msgstr "在檔案管ç†å“¡å…§é¡¯ç¤º"
+msgstr "在檔案總管中顯示"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "New Folder..."
@@ -1897,11 +1773,11 @@ msgstr "é‡æ–°æ•´ç†"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "All Recognized"
-msgstr "å¯èªå¾—全部"
+msgstr "支æ´çš„é¡žåž‹"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "All Files (*)"
-msgstr "所有類型檔案"
+msgstr "所有類型的檔案 (*)"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Open a File"
@@ -1924,32 +1800,31 @@ msgstr "開啟檔案或資料夾"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp scene/gui/file_dialog.cpp
msgid "Save"
-msgstr "儲存"
+msgstr "ä¿å­˜"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Save a File"
-msgstr "儲存檔案"
+msgstr "ä¿å­˜æª”案"
#: editor/editor_file_dialog.cpp
msgid "Go Back"
-msgstr "往後"
+msgstr "上一é "
#: editor/editor_file_dialog.cpp
msgid "Go Forward"
-msgstr "å¾€å‰"
+msgstr "下一é "
#: editor/editor_file_dialog.cpp
msgid "Go Up"
-msgstr "往上"
+msgstr "上一層"
#: editor/editor_file_dialog.cpp
msgid "Toggle Hidden Files"
-msgstr "切æ›é¡¯ç¤ºéš±è—檔案"
+msgstr "顯示ï¼éš±è—éš±è—檔案"
#: editor/editor_file_dialog.cpp
-#, fuzzy
msgid "Toggle Favorite"
-msgstr "切æ›æœ€æ„›"
+msgstr "新增ï¼å–消我的最愛"
#: editor/editor_file_dialog.cpp
msgid "Toggle Mode"
@@ -1961,214 +1836,191 @@ msgstr "èšç„¦è·¯å¾‘"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Up"
-msgstr "å‘上移動收è—"
+msgstr "å‘上移動我的最愛"
#: editor/editor_file_dialog.cpp
msgid "Move Favorite Down"
-msgstr "å‘下移動收è—"
+msgstr "å‘下移動我的最愛"
#: editor/editor_file_dialog.cpp
-#, fuzzy
msgid "Go to previous folder."
-msgstr "無法新增資料夾"
+msgstr "å‰å¾€ä¸Šä¸€å€‹è³‡æ–™å¤¾ã€‚"
#: editor/editor_file_dialog.cpp
-#, fuzzy
msgid "Go to next folder."
-msgstr "無法新增資料夾"
+msgstr "å‰å¾€ä¸‹ä¸€å€‹è³‡æ–™å¤¾ã€‚"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Go to parent folder."
-msgstr "無法新增資料夾"
+msgstr "å‰å¾€ä¸Šå±¤è³‡æ–™å¤¾ã€‚"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Refresh files."
-msgstr "æœå°‹ Class"
+msgstr "é‡æ–°æ•´ç†æª”案。"
#: editor/editor_file_dialog.cpp
-#, fuzzy
msgid "(Un)favorite current folder."
-msgstr "無法新增資料夾"
+msgstr "將目å‰çš„資料夾新增或移除我的最愛。"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Toggle the visibility of hidden files."
-msgstr "切æ›é¡¯ç¤ºéš±è—檔案"
+msgstr "顯示ï¼å–消顯示隱è—檔案。"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a grid of thumbnails."
-msgstr "以縮略圖網格形å¼æŸ¥çœ‹é …目。"
+msgstr "以網格縮圖方å¼é¡¯ç¤ºé …目。"
#: editor/editor_file_dialog.cpp editor/filesystem_dock.cpp
msgid "View items as a list."
-msgstr "以清單形å¼æŸ¥çœ‹é …目。"
+msgstr "以清單方å¼é¡¯ç¤ºé …目。"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "Directories & Files:"
-msgstr "資料夾 & 檔案:"
+msgstr "資料夾與檔案:"
#: editor/editor_file_dialog.cpp editor/plugins/sprite_editor_plugin.cpp
#: editor/plugins/style_box_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Preview:"
-msgstr "é è¦½:"
+msgstr "é è¦½ï¼š"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
msgid "File:"
-msgstr "檔案:"
+msgstr "檔案:"
#: editor/editor_file_dialog.cpp scene/gui/file_dialog.cpp
-#, fuzzy
msgid "Must use a valid extension."
msgstr "必須使用有效的副檔å。"
#: editor/editor_file_system.cpp
msgid "ScanSources"
-msgstr "掃ææº"
+msgstr "掃æ原始檔"
#: editor/editor_file_system.cpp
msgid ""
"There are multiple importers for different types pointing to file %s, import "
"aborted"
-msgstr "因為有多個ä¸åŒç¨®é¡žimporter指å‘檔案 %s,導入失敗"
+msgstr "由於多個匯入器以ä¸åŒçš„型別指å‘檔案 %s,已中止匯入"
#: editor/editor_file_system.cpp
msgid "(Re)Importing Assets"
-msgstr "(é‡æ–°)載入素æ"
+msgstr "(é‡æ–°ï¼‰åŒ¯å…¥ç´ æ"
#: editor/editor_help.cpp editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Top"
-msgstr "上é¢"
+msgstr "上"
#: editor/editor_help.cpp
msgid "Class:"
-msgstr "Class:"
+msgstr "類別:"
#: editor/editor_help.cpp editor/scene_tree_editor.cpp
#: editor/script_create_dialog.cpp
msgid "Inherits:"
-msgstr "繼承:"
+msgstr "繼承:"
#: editor/editor_help.cpp
msgid "Inherited by:"
-msgstr "繼承:"
+msgstr "被繼承:"
#: editor/editor_help.cpp
-#, fuzzy
msgid "Description"
-msgstr "æè¿°:"
+msgstr "說明"
#: editor/editor_help.cpp
-#, fuzzy
msgid "Online Tutorials"
-msgstr "線上教學:"
+msgstr "線上教學"
#: editor/editor_help.cpp
msgid "Properties"
-msgstr "性質"
+msgstr "屬性"
#: editor/editor_help.cpp
-#, fuzzy
msgid "override:"
-msgstr "覆蓋"
+msgstr "複寫:"
#: editor/editor_help.cpp
-#, fuzzy
msgid "default:"
-msgstr "é è¨­"
+msgstr "é è¨­ï¼š"
#: editor/editor_help.cpp
msgid "Methods"
msgstr "方法"
#: editor/editor_help.cpp
-#, fuzzy
msgid "Theme Properties"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "主題屬性"
#: editor/editor_help.cpp
msgid "Enumerations"
-msgstr "枚舉"
+msgstr "列舉類型"
#: editor/editor_help.cpp
msgid "Constants"
-msgstr "定數"
+msgstr "常數"
#: editor/editor_help.cpp
-#, fuzzy
msgid "Property Descriptions"
-msgstr "Property 說明:"
+msgstr "屬性說明"
#: editor/editor_help.cpp
-#, fuzzy
msgid "(value)"
-msgstr "數值"
+msgstr "(數值)"
#: editor/editor_help.cpp
msgid ""
"There is currently no description for this property. Please help us by "
"[color=$color][url=$url]contributing one[/url][/color]!"
msgstr ""
-"ç›®å‰æ²’有這個 property 的說明。請幫我們[color=$color][url=$url]è²¢ç»[/url][/"
-"color]一個!"
+"該屬性目å‰ç„¡èªªæ˜Žã€‚請幫助我們[color=$color][url=$url]è²¢ç»ä¸€å€‹[/url][/color]ï¼"
#: editor/editor_help.cpp
-#, fuzzy
msgid "Method Descriptions"
-msgstr "Method 說明:"
+msgstr "方法說明"
#: editor/editor_help.cpp
msgid ""
"There is currently no description for this method. Please help us by [color="
"$color][url=$url]contributing one[/url][/color]!"
msgstr ""
-"ç›®å‰æ²’有這個 method 的說明。請幫我們[color=$color][url=$url]è²¢ç»[/url][/"
-"color]一個!"
+"該方法目å‰æ²’有說明。請幫我們[color=$color][url=$url]è²¢ç»ä¸€å€‹[/url][/color]ï¼"
#: editor/editor_help_search.cpp editor/editor_node.cpp
#: editor/plugins/script_editor_plugin.cpp
msgid "Search Help"
-msgstr "æœå°‹å¹«åŠ©"
+msgstr "æœå°‹èªªæ˜Ž"
#: editor/editor_help_search.cpp
msgid "Case Sensitive"
msgstr "å€åˆ†å¤§å°å¯«"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Show Hierarchy"
-msgstr "顯示輔助線"
+msgstr "以樹狀顯示"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Display All"
-msgstr "å–代全部"
+msgstr "全部顯示"
#: editor/editor_help_search.cpp
msgid "Classes Only"
-msgstr "僅é™é¡ž"
+msgstr "僅é™é¡žåˆ¥"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Methods Only"
-msgstr "方法"
+msgstr "僅é™æ–¹æ³•"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Signals Only"
-msgstr "信號"
+msgstr "僅é™ä¿¡è™Ÿ"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Constants Only"
-msgstr "定數"
+msgstr "僅é™å¸¸æ•¸"
#: editor/editor_help_search.cpp
msgid "Properties Only"
-msgstr "僅屬性"
+msgstr "僅é™å±¬æ€§"
#: editor/editor_help_search.cpp
msgid "Theme Properties Only"
@@ -2176,36 +2028,31 @@ msgstr "僅é™ä¸»é¡Œå±¬æ€§"
#: editor/editor_help_search.cpp
msgid "Member Type"
-msgstr "æˆå“¡é¡žåž‹"
+msgstr "æˆå“¡åž‹åˆ¥"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Class"
-msgstr "Class:"
+msgstr "類別"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Method"
msgstr "方法"
#: editor/editor_help_search.cpp editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Signal"
-msgstr "信號"
+msgstr "訊號"
#: editor/editor_help_search.cpp editor/plugins/theme_editor_plugin.cpp
msgid "Constant"
-msgstr "固定"
+msgstr "常數"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Property"
-msgstr "屬性:"
+msgstr "屬性"
#: editor/editor_help_search.cpp
-#, fuzzy
msgid "Theme Property"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "主題屬性"
#: editor/editor_inspector.cpp editor/project_settings_editor.cpp
msgid "Property:"
@@ -2213,21 +2060,19 @@ msgstr "屬性:"
#: editor/editor_inspector.cpp
msgid "Set"
-msgstr "集åˆ"
+msgstr "設定"
#: editor/editor_inspector.cpp
-#, fuzzy
msgid "Set Multiple:"
-msgstr "複數設定:"
+msgstr "設定多個:"
#: editor/editor_log.cpp
msgid "Output:"
-msgstr "輸出:"
+msgstr "輸出:"
#: editor/editor_log.cpp editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Copy Selection"
-msgstr "複製é¸æ“‡"
+msgstr "複製所é¸"
#: editor/editor_log.cpp editor/editor_network_profiler.cpp
#: editor/editor_profiler.cpp editor/editor_properties.cpp
@@ -2240,9 +2085,8 @@ msgid "Clear"
msgstr "清除"
#: editor/editor_log.cpp
-#, fuzzy
msgid "Clear Output"
-msgstr "輸出:"
+msgstr "清除輸出"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
#: editor/editor_profiler.cpp
@@ -2255,39 +2099,36 @@ msgid "Start"
msgstr "開始"
#: editor/editor_network_profiler.cpp
-#, fuzzy
msgid "%s/s"
-msgstr "%s/s"
+msgstr "%s/秒"
#: editor/editor_network_profiler.cpp
-#, fuzzy
msgid "Down"
-msgstr "下載"
+msgstr "下行"
#: editor/editor_network_profiler.cpp
msgid "Up"
-msgstr "上"
+msgstr "上行"
#: editor/editor_network_profiler.cpp editor/editor_node.cpp
-#, fuzzy
msgid "Node"
msgstr "節點"
#: editor/editor_network_profiler.cpp
msgid "Incoming RPC"
-msgstr "進來的Rpc"
+msgstr "連入 RPC"
#: editor/editor_network_profiler.cpp
msgid "Incoming RSET"
-msgstr "進來的Rset"
+msgstr "連入 RSET"
#: editor/editor_network_profiler.cpp
msgid "Outgoing RPC"
-msgstr "出去的 RPC"
+msgstr "連出 RPC"
#: editor/editor_network_profiler.cpp
msgid "Outgoing RSET"
-msgstr "出去的 RSET"
+msgstr "連出 RSET"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "New Window"
@@ -2295,96 +2136,92 @@ msgstr "新視窗"
#: editor/editor_node.cpp
msgid "Imported resources can't be saved."
-msgstr "無法ä¿å­˜å°Žå…¥çš„資æºã€‚"
+msgstr "匯入的資æºç„¡æ³•ä¿å­˜ã€‚"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: scene/gui/dialogs.cpp
msgid "OK"
-msgstr "確定"
+msgstr "好"
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Error saving resource!"
-msgstr "儲存資æºéŒ¯èª¤!"
+msgstr "ä¿å­˜è³‡æºéŒ¯èª¤ï¼"
#: editor/editor_node.cpp
-#, fuzzy
msgid ""
"This resource can't be saved because it does not belong to the edited scene. "
"Make it unique first."
-msgstr "無法儲存此資æºï¼Œå› ç‚ºå®ƒä¸å±¬æ–¼å·²ç·¨è¼¯çš„場景。請先讓它æˆç‚ºå”¯ä¸€ã€‚"
+msgstr "由於該資æºä¸å±¬æ–¼å·²ç·¨è¼¯çš„場景,無法ä¿å­˜è©²è³‡æºã€‚請先確ä¿å…¶ç¨ç«‹ã€‚"
#: editor/editor_node.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Save Resource As..."
msgstr "å¦å­˜è³‡æºç‚º..."
#: editor/editor_node.cpp
-#, fuzzy
msgid "Can't open file for writing:"
-msgstr "無法以寫入模å¼é–‹å•Ÿæª”案:"
+msgstr "無法開啟欲寫入的檔案:"
#: editor/editor_node.cpp
msgid "Requested file format unknown:"
-msgstr "è¦æ±‚了ä¸æ˜Žçš„檔案格å¼:"
+msgstr "è¦æ±‚的檔案格å¼æœªçŸ¥ï¼š"
#: editor/editor_node.cpp
msgid "Error while saving."
-msgstr "儲存中發生了錯誤。"
+msgstr "ä¿å­˜æ™‚發生錯誤。"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
msgid "Can't open '%s'. The file could have been moved or deleted."
-msgstr "無法打開“%sâ€ã€‚檔案å¯èƒ½å·²è¢«ç§»å‹•æˆ–删除。"
+msgstr "無法開啟「%sã€ã€‚該檔案å¯èƒ½å·²è¢«ç§»å‹•æˆ–刪除。"
#: editor/editor_node.cpp
msgid "Error while parsing '%s'."
-msgstr "åˆ†æž \"%s\" 時發生錯誤。"
+msgstr "無法解æžã€Œ%sã€ã€‚"
#: editor/editor_node.cpp
msgid "Unexpected end of file '%s'."
-msgstr "æ„料外的檔案çµå°¾ (EOF) '%s'。"
+msgstr "未é æœŸçš„檔案çµå°¾ (EOF)「%sã€ã€‚"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Missing '%s' or its dependencies."
-msgstr "缺失 '%s' 或它的ä¾å­˜ã€‚"
+msgstr "缺少「%sã€æˆ–其相ä¾æ€§ã€‚"
#: editor/editor_node.cpp
msgid "Error while loading '%s'."
-msgstr "載入 \"%s\" 時發生錯誤。"
+msgstr "載入「%sã€æ™‚發生錯誤。"
#: editor/editor_node.cpp
msgid "Saving Scene"
-msgstr "正在儲存場景"
+msgstr "正在ä¿å­˜å ´æ™¯"
#: editor/editor_node.cpp
msgid "Analyzing"
-msgstr "分æžä¸­"
+msgstr "正在分æž"
#: editor/editor_node.cpp
msgid "Creating Thumbnail"
msgstr "正在建立縮圖"
#: editor/editor_node.cpp
-#, fuzzy
msgid "This operation can't be done without a tree root."
-msgstr "æ­¤æ“作無法復原, 確定è¦é‚„原嗎?"
+msgstr "無樹狀根目錄無法進行此æ“作。"
#: editor/editor_node.cpp
msgid ""
"This scene can't be saved because there is a cyclic instancing inclusion.\n"
"Please resolve it and then attempt to save again."
msgstr ""
-"åµæ¸¬åˆ°æ­¤å ´æ™¯ä¸­æœ‰å¾ªç’°å¯¦ä¾‹åŒ–引入ç¾è±¡ï¼Œå› æ­¤ç„¡æ³•å„²å­˜ã€‚\n"
+"該場景有循環性實體化å•é¡Œï¼Œç„¡æ³•ä¿å­˜ã€‚\n"
"請先解決此å•é¡Œå¾Œå†è©¦ä¸€æ¬¡ã€‚"
#: editor/editor_node.cpp
msgid ""
"Couldn't save scene. Likely dependencies (instances or inheritance) couldn't "
"be satisfied."
-msgstr "無法儲存此場景。å¯èƒ½æœ‰ä¸å®Œæ•´çš„ä¾å­˜é—œä¿‚(實例化或是繼承上的)。"
+msgstr "無法ä¿å­˜å ´æ™¯ã€‚å¯èƒ½æ˜¯ç”±æ–¼ç›¸ä¾æ€§ï¼ˆå¯¦é«”或繼承)無法滿足。"
#: editor/editor_node.cpp editor/scene_tree_dock.cpp
msgid "Can't overwrite scene that is still open!"
-msgstr "無法覆寫ä»è™•æ–¼é–‹å•Ÿç‹€æ…‹çš„場景ï¼"
+msgstr "無法複寫開啟中的場景ï¼"
#: editor/editor_node.cpp
msgid "Can't load MeshLibrary for merging!"
@@ -2392,31 +2229,31 @@ msgstr "無法加載è¦åˆä½µçš„網格庫ï¼"
#: editor/editor_node.cpp
msgid "Error saving MeshLibrary!"
-msgstr "ä¿å­˜MeshLibrary時出錯ï¼"
+msgstr "ä¿å­˜ç¶²æ ¼åº«æ™‚出錯ï¼"
#: editor/editor_node.cpp
msgid "Can't load TileSet for merging!"
-msgstr "無法加載Tileset進行åˆä½µï¼"
+msgstr "無法加載è¦åˆä½µçš„圖塊集ï¼"
#: editor/editor_node.cpp
msgid "Error saving TileSet!"
-msgstr "ä¿å­˜tileset時出錯ï¼"
+msgstr "ä¿å­˜ä¿å­˜åœ–塊集時發生錯誤ï¼"
#: editor/editor_node.cpp
msgid "Error trying to save layout!"
-msgstr "嘗試ä¿å­˜ä½ˆå±€æ™‚出錯ï¼"
+msgstr "嘗試ä¿å­˜é…置時出錯ï¼"
#: editor/editor_node.cpp
msgid "Default editor layout overridden."
-msgstr "覆蓋默èªç·¨è¼¯å™¨ä½ˆå±€ã€‚"
+msgstr "已覆蓋é è¨­çš„編輯器é…置。"
#: editor/editor_node.cpp
msgid "Layout name not found!"
-msgstr "找ä¸åˆ°ä½ˆå±€å稱ï¼"
+msgstr "找ä¸åˆ°é…ç½®å稱ï¼"
#: editor/editor_node.cpp
msgid "Restored default layout to base settings."
-msgstr "已將默èªä½ˆå±€é‚„原為基本設定。"
+msgstr "已將é è¨­é…置還原至基本設定。"
#: editor/editor_node.cpp
msgid ""
@@ -2424,24 +2261,22 @@ msgid ""
"Please read the documentation relevant to importing scenes to better "
"understand this workflow."
msgstr ""
-"此資æºå±¬æ–¼åŒ¯å…¥çš„場景,因此ä¸å¯ç·¨è¼¯ã€‚\n"
-"請閱讀與匯入場景相關的文件,以便更加瞭解工作æµç¨‹ã€‚"
+"該資æºå±¬æ–¼å·²åŒ¯å…¥çš„場景,因此ä¸å¯ç·¨è¼¯ã€‚ \n"
+"請閱讀有關匯入場景的說明文件以更瞭解該æµç¨‹ã€‚"
#: editor/editor_node.cpp
msgid ""
"This resource belongs to a scene that was instanced or inherited.\n"
"Changes to it won't be kept when saving the current scene."
msgstr ""
-"此資æºå±¬æ–¼è¢«å¯¦ä¾‹åŒ–或被繼承的場景。\n"
-"儲存場景時,此資æºçš„變更ä¸æœƒè¢«ä¿å­˜ã€‚"
+"此資æºå±¬æ–¼å·²è¢«å¯¦ä¾‹åŒ–或被繼承的場景。\n"
+"儲存目å‰å ´æ™¯æ™‚,套用的改動將ä¸æœƒè¢«ä¿å­˜ã€‚"
#: editor/editor_node.cpp
msgid ""
"This resource was imported, so it's not editable. Change its settings in the "
"import panel and then re-import."
-msgstr ""
-"這個資æºæ˜¯åŒ¯å…¥é€²ä¾†çš„,因此無法編譯。請修改匯入控制é¢æ¿ä¸Šçš„設定,å†é‡æ–°åŒ¯å…¥ä¸€"
-"次。"
+msgstr "該資æºè‡ªå¤–部匯入,無法編輯。請在匯入é¢æ¿ä¸­ä¿®æ”¹è¨­å®šä¸¦é‡æ–°åŒ¯å…¥ã€‚"
#: editor/editor_node.cpp
msgid ""
@@ -2450,31 +2285,30 @@ msgid ""
"Please read the documentation relevant to importing scenes to better "
"understand this workflow."
msgstr ""
-"此場景是匯入進來的,因此變更ä¸æœƒè¢«ä¿å­˜ã€‚\n"
-"需經éŽå¯¦ä¾‹åŒ–或是繼承,æ‰èƒ½è®Šæ›´å…¶å…§å®¹ã€‚\n"
-"請閱讀與匯入場景相關的文件,以便更加瞭解工作æµç¨‹ã€‚"
+"該場景自外部匯入,因此åšå‡ºçš„改動將ä¸æœƒä¿å­˜ã€‚\n"
+"實例化或繼承後將å¯å°å…¶åšå‡ºä¿®æ”¹ã€‚\n"
+"請閱讀與匯入相關的說明文件以更加瞭解該工作æµç¨‹ã€‚"
#: editor/editor_node.cpp
-#, fuzzy
msgid ""
"This is a remote object, so changes to it won't be kept.\n"
"Please read the documentation relevant to debugging to better understand "
"this workflow."
msgstr ""
-"此資æºå±¬æ–¼å·²å°Žå…¥çš„場景, å› æ­¤ä¸å¯ç·¨è¼¯ã€‚\n"
-"請閱讀與導入場景相關的文檔, 以便更好地瞭解此工作æµã€‚"
+"該資æºè‡ªå¤–部匯入,因此åšå‡ºçš„改動將ä¸æœƒä¿å­˜ã€‚\n"
+"請閱讀有關åµéŒ¯çš„說明文件以更瞭解該æµç¨‹ã€‚"
#: editor/editor_node.cpp
msgid "There is no defined scene to run."
-msgstr "沒有已定義的場景å¯é‹è¡Œã€‚"
+msgstr "沒有已定義的場景å¯åŸ·è¡Œã€‚"
#: editor/editor_node.cpp
msgid "Current scene was never saved, please save it prior to running."
-msgstr "ç›®å‰çš„場景從未被儲存,在é‹è¡Œå ´æ™¯å‰è«‹å…ˆå­˜æª”。"
+msgstr "ç›®å‰çš„場景從未被ä¿å­˜ï¼Œè«‹å…ˆä¿å­˜ä»¥åŸ·è¡Œã€‚"
#: editor/editor_node.cpp
msgid "Could not start subprocess!"
-msgstr "無法啟動å­é€²ç¨‹!"
+msgstr "無法啟動å­è™•ç†ç¨‹åºï¼"
#: editor/editor_node.cpp editor/filesystem_dock.cpp
msgid "Open Scene"
@@ -2485,9 +2319,8 @@ msgid "Open Base Scene"
msgstr "開啟基本場景"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Quick Open..."
-msgstr "快速開啟場景..."
+msgstr "快速開啟..."
#: editor/editor_node.cpp
msgid "Quick Open Scene..."
@@ -2495,24 +2328,23 @@ msgstr "快速開啟場景…"
#: editor/editor_node.cpp
msgid "Quick Open Script..."
-msgstr "快速打開腳本…"
+msgstr "快速開啟腳本…"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Save & Close"
-msgstr "å¦å­˜æ–°æª”"
+msgstr "ä¿å­˜ä¸¦é—œé–‰"
#: editor/editor_node.cpp
msgid "Save changes to '%s' before closing?"
-msgstr "關閉å‰æ˜¯å¦ä¿å­˜å°â€œ%sâ€çš„更改?"
+msgstr "關閉å‰æ˜¯å¦ä¿å­˜å°ã€Œ%sã€çš„更改?"
#: editor/editor_node.cpp
msgid "Saved %s modified resource(s)."
-msgstr "å·²ä¿å­˜%s個已修改的資æºã€‚"
+msgstr "å·²ä¿å­˜ %s 個已修改的資æºã€‚"
#: editor/editor_node.cpp
msgid "A root node is required to save the scene."
-msgstr "儲存場景需è¦æ ¹ç¯€é»žã€‚"
+msgstr "ä¿å­˜å ´æ™¯éœ€è¦æ ¹ç¯€é»žã€‚"
#: editor/editor_node.cpp
msgid "Save Scene As..."
@@ -2520,7 +2352,7 @@ msgstr "å¦å­˜å ´æ™¯ç‚ºâ€¦"
#: editor/editor_node.cpp
msgid "No"
-msgstr "ä¸æ˜¯"
+msgstr "å¦"
#: editor/editor_node.cpp
msgid "Yes"
@@ -2528,44 +2360,47 @@ msgstr "是"
#: editor/editor_node.cpp
msgid "This scene has never been saved. Save before running?"
-msgstr "此場景從未被儲存。執行å‰å…ˆå­˜æª”?"
+msgstr "此場景從未被ä¿å­˜ã€‚是å¦è¦åœ¨åŸ·è¡Œå‰å…ˆä¿å­˜ï¼Ÿ"
#: editor/editor_node.cpp editor/scene_tree_dock.cpp
msgid "This operation can't be done without a scene."
-msgstr "這項æ“作必須è¦æœ‰å ´æ™¯å­˜åœ¨ã€‚"
+msgstr "該æ“作必須è¦æœ‰å ´æ™¯æ‰å¯å®Œæˆã€‚"
#: editor/editor_node.cpp
msgid "Export Mesh Library"
-msgstr "導出網格庫"
+msgstr "匯出網格庫"
#: editor/editor_node.cpp
msgid "This operation can't be done without a root node."
-msgstr "在設置根節點(root node)å‰ï¼Œç„¡æ³•å®Œæˆè©²æŒ‡å®šæ“作。"
+msgstr "該æ“作必須è¦æœ‰è·Ÿç¯€é»žæ‰å¯å®Œæˆã€‚"
#: editor/editor_node.cpp
msgid "Export Tile Set"
-msgstr "導出ç£è²¼é›†"
+msgstr "匯出 Tile Set"
#: editor/editor_node.cpp
msgid "This operation can't be done without a selected node."
-msgstr "在設置著節點(selected node)å‰ï¼Œç„¡æ³•å®Œæˆè©²æŒ‡å®šæ“作。"
+msgstr "該æ“作必須è¦æœ‰å·²é¸æ“‡çš„節點æ‰å¯å®Œæˆã€‚"
#: editor/editor_node.cpp
msgid "Current scene not saved. Open anyway?"
-msgstr "ç›®å‰çš„場景尚未儲存。還是è¦é–‹å•Ÿå—Žï¼Ÿ"
+msgstr "ç›®å‰çš„場景尚未ä¿å­˜ã€‚ä»ç„¶è¦é–‹å•Ÿå—Žï¼Ÿ"
#: editor/editor_node.cpp
msgid "Can't reload a scene that was never saved."
-msgstr "無法é‡æ–°è¼‰å…¥å¾žæœªå­˜æª”的場景。"
+msgstr "無法é‡æ–°è¼‰å…¥å¾žæœªä¿å­˜éŽçš„場景。"
#: editor/editor_node.cpp
-msgid "Revert"
-msgstr "還原"
+msgid "Reload Saved Scene"
+msgstr "é‡æ–°è¼‰å…¥å·²ä¿å­˜çš„場景"
#: editor/editor_node.cpp
-#, fuzzy
-msgid "This action cannot be undone. Revert anyway?"
-msgstr "æ­¤æ“作無法被, 確定è¦é‚„原嗎?"
+msgid ""
+"The current scene has unsaved changes.\n"
+"Reload the saved scene anyway? This action cannot be undone."
+msgstr ""
+"ç›®å‰çš„場景有未ä¿å­˜çš„改動。\n"
+"ä»ç„¶è¦é‡æ–°è¼‰å…¥å ´æ™¯å—Žï¼Ÿé€™å€‹æ“作將無法復原。"
#: editor/editor_node.cpp
msgid "Quick Run Scene..."
@@ -2581,25 +2416,27 @@ msgstr "è¦çµæŸç·¨è¼¯å™¨å—Žï¼Ÿ"
#: editor/editor_node.cpp
msgid "Open Project Manager?"
-msgstr "è¦é–‹å•Ÿå°ˆæ¡ˆç®¡ç†å—Žï¼Ÿ"
+msgstr "è¦é–‹å•Ÿå°ˆæ¡ˆç®¡ç†å“¡å—Žï¼Ÿ"
#: editor/editor_node.cpp
msgid "Save & Quit"
-msgstr "儲存並離開"
+msgstr "ä¿å­˜ä¸¦é€€å‡º"
#: editor/editor_node.cpp
msgid "Save changes to the following scene(s) before quitting?"
-msgstr "退出程å¼å‰ï¼Œè¦å„²å­˜ä»¥ä¸‹ä¿®æ”¹éŽçš„場景嗎?"
+msgstr "退出å‰è¦å…ˆä¿å­˜ä¸‹åˆ—場景嗎?"
#: editor/editor_node.cpp
msgid "Save changes the following scene(s) before opening Project Manager?"
-msgstr "開啟專案管ç†å‰ï¼Œè¦å„²å­˜ä»¥ä¸‹ä¿®æ”¹éŽçš„場景嗎?"
+msgstr "開啟專案管ç†å“¡å‰è¦å…ˆä¿å­˜ä»¥ä¸‹å ´æ™¯å—Žï¼Ÿ"
#: editor/editor_node.cpp
msgid ""
"This option is deprecated. Situations where refresh must be forced are now "
"considered a bug. Please report."
-msgstr "ä¸æŽ¨è–¦æ­¤é¸é …。被強制é‡æ–°æ•´ç†çš„情形,å¯èƒ½æ˜¯å› ç¨‹å¼éŒ¯èª¤å°Žè‡´ã€‚請回報。"
+msgstr ""
+"該é¸é …å·²åœæ­¢ç¶­è­·ã€‚é‡åˆ°éœ€è¦å¼·åˆ¶é‡æ–°æ•´ç†çš„ç‹€æ³ç¾åœ¨å·²è¢«è¦–為程å¼éŒ¯èª¤ã€‚請回報該å•"
+"題。"
#: editor/editor_node.cpp
msgid "Pick a Main Scene"
@@ -2610,56 +2447,55 @@ msgid "Close Scene"
msgstr "關閉場景"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Reopen Closed Scene"
-msgstr "關閉場景"
+msgstr "é‡æ–°é–‹å•Ÿå·²é—œé–‰çš„場景"
#: editor/editor_node.cpp
msgid "Unable to enable addon plugin at: '%s' parsing of config failed."
-msgstr "無法在: \"%s\" 上啟動擴充功能,設定解æžå¤±æ•—。"
+msgstr "無法在「%sã€ä¸Šå•Ÿç”¨æ“´å……功能,解æžçµ„態設定失敗。"
#: editor/editor_node.cpp
msgid "Unable to find script field for addon plugin at: 'res://addons/%s'."
-msgstr "在æ’件目錄 'res://addons/%s' 中,找ä¸åˆ°è…³æœ¬ã€‚"
+msgstr "無法在擴充功能「res://addons/%sã€ä¸­ç„¡æ³•æ‰¾åˆ°è…³æœ¬æ¬„ä½ã€‚"
#: editor/editor_node.cpp
msgid "Unable to load addon script from path: '%s'."
-msgstr "無法從 '%s' 中順利讀å–腳本。"
+msgstr "無法自路徑「%sã€è¼‰å…¥æ“´å……腳本。"
#: editor/editor_node.cpp
msgid ""
"Unable to load addon script from path: '%s' There seems to be an error in "
"the code, please check the syntax."
-msgstr "無法從 '%s' 中順利讀å–腳本。å¯èƒ½å‡ºè‡ªç·¨ç¢¼éŒ¯èª¤ï¼Œè«‹æª¢å¯Ÿèªžæ³•æ˜¯å¦æ­£ç¢ºã€‚"
+msgstr "無法從路徑「%sã€è¼‰å…¥æ“´å……腳本。看樣å­æ˜¯ç¨‹å¼ç¢¼ä¸­æœ‰éŒ¯èª¤ï¼Œè«‹æª¢æŸ¥èªžæ³•ã€‚"
#: editor/editor_node.cpp
msgid ""
"Unable to load addon script from path: '%s' Base type is not EditorPlugin."
-msgstr "無法從 '%s' 中順利讀å–腳本。基本類型 的腳本並ä¸å±¬æ–¼ 編輯類æ’件。"
+msgstr "無法自路徑「%sã€è¼‰å…¥æ“´å……腳本,基礎型別ä¸æ˜¯ EditorPlugin。"
#: editor/editor_node.cpp
msgid "Unable to load addon script from path: '%s' Script is not in tool mode."
-msgstr "無法從 '%s' 中順利讀å–腳本。此腳本並ä¸è™•æ–¼å·¥å…·æ¨¡å¼ä¸‹ã€‚"
+msgstr "無法自路徑載入擴充腳本「%sã€ï¼Œè…³æœ¬ä¸åœ¨å·¥å…·æ¨¡å¼ä¸‹ã€‚"
#: editor/editor_node.cpp
msgid ""
"Scene '%s' was automatically imported, so it can't be modified.\n"
"To make changes to it, a new inherited scene can be created."
msgstr ""
-"場景 '%s' 為自動匯入的,ä¸èƒ½è¢«ä¿®æ”¹ã€‚\n"
-"è‹¥è¦é€²è¡Œæ›´æ”¹ï¼Œè«‹å»ºç«‹æ–°çš„繼承的場景。"
+"「%sã€ç‚ºè‡ªå‹•åŒ¯å…¥çš„場景,將無法修改。\n"
+"è‹¥è¦å°å…¶é€²è¡Œæ”¹å‹•ï¼Œå¯å»ºç«‹æ–°ç¹¼æ‰¿å ´æ™¯ã€‚"
#: editor/editor_node.cpp
msgid ""
"Error loading scene, it must be inside the project path. Use 'Import' to "
"open the scene, then save it inside the project path."
msgstr ""
-"讀å–場景時發生錯誤,場景必須放置於專案資料夾中。請用「導入ã€é–‹å•Ÿè©²å ´æ™¯å¾Œï¼Œå†"
-"儲存於專案資料夾。"
+"載入場景時發生錯誤,場景必須置於專案路徑內。請使用「匯入ã€ä¾†é–‹å•Ÿè©²å ´æ™¯ï¼Œä¸¦å°‡"
+"å…¶ä¿å­˜æ–¼å°ˆæ¡ˆè·¯å¾‘內。"
#: editor/editor_node.cpp
msgid "Scene '%s' has broken dependencies:"
-msgstr "場景 '%s' çš„ä¾å­˜é—œä¿‚已被破壞:"
+msgstr "場景「%sã€çš„相ä¾æ€§æ壞:"
#: editor/editor_node.cpp
msgid "Clear Recent Scenes"
@@ -2672,7 +2508,7 @@ msgid ""
"category."
msgstr ""
"尚未定義主場景。è¦é¸æ“‡ä¸€å€‹å ´æ™¯å—Žï¼Ÿ\n"
-"你之後å¯ä»¥åœ¨ã€Œæ‡‰ç”¨ç¨‹å¼ã€åˆ†é¡žä¸­çš„「專案設定ã€è®Šæ›´é€™è¨­å®šã€‚"
+"ç¨å¾Œå¯åœ¨ã€Œæ‡‰ç”¨ç¨‹å¼ã€åˆ†é¡žä¸­çš„「專案設定ã€ä¿®æ”¹ã€‚"
#: editor/editor_node.cpp
msgid ""
@@ -2680,8 +2516,8 @@ msgid ""
"You can change it later in \"Project Settings\" under the 'application' "
"category."
msgstr ""
-"é¸æ“‡å ´æ™¯'%s'ä¸å­˜åœ¨ï¼Œé¸æ“‡å¦ä¸€å€‹å ´æ™¯ï¼Ÿ\n"
-"你之後å¯ä»¥åœ¨ã€Œæ‡‰ç”¨ç¨‹å¼ã€åˆ†é¡žä¸­çš„「專案設定ã€è®Šæ›´é€™è¨­å®šã€‚"
+"所é¸çš„場景「%sã€ä¸å­˜åœ¨ï¼Œæ˜¯å¦è¦é¸æ“‡ä¸€å€‹æœ‰æ•ˆçš„場景?\n"
+"ç¨å¾Œå¯åœ¨ã€Œæ‡‰ç”¨ç¨‹å¼ã€åˆ†é¡žä¸­çš„「專案設定ã€ä¸­ä¿®æ”¹ã€‚"
#: editor/editor_node.cpp
msgid ""
@@ -2689,16 +2525,16 @@ msgid ""
"You can change it later in \"Project Settings\" under the 'application' "
"category."
msgstr ""
-"é¸æ“‡çš„場景'%s'ä¸æ˜¯ä¸€å€‹å ´æ™¯æª”案,è¦é¸æ“‡å¦ä¸€å€‹å ´æ™¯å—Žï¼Ÿ\n"
-"你之後å¯ä»¥åœ¨ã€Œæ‡‰ç”¨ç¨‹å¼ã€åˆ†é¡žä¸­çš„「專案設定ã€è®Šæ›´é€™è¨­å®šã€‚"
+"所é¸çš„場景「%sã€ä¸æ˜¯å ´æ™¯æª”案,是å¦è¦é¸æ“‡å¦ä¸€å€‹æœ‰æ•ˆçš„場景?\n"
+"ç¨å¾Œå¯åœ¨ã€Œæ‡‰ç”¨ç¨‹å¼ã€åˆ†é¡žä¸­çš„「專案設定ã€ä¸­ä¿®æ”¹ã€‚"
#: editor/editor_node.cpp
msgid "Save Layout"
-msgstr "儲存佈局"
+msgstr "儲存é…ç½®"
#: editor/editor_node.cpp
msgid "Delete Layout"
-msgstr "刪除佈局"
+msgstr "刪除é…ç½®"
#: editor/editor_node.cpp editor/import_dock.cpp
#: editor/script_create_dialog.cpp
@@ -2712,29 +2548,27 @@ msgstr "在檔案系統中顯示"
#: editor/editor_node.cpp
msgid "Play This Scene"
-msgstr "é‹è¡Œæ­¤å ´æ™¯"
+msgstr "執行此場景"
#: editor/editor_node.cpp
msgid "Close Tab"
msgstr "關閉分é "
#: editor/editor_node.cpp
-#, fuzzy
msgid "Undo Close Tab"
-msgstr "關閉分é "
+msgstr "å–消關閉分é "
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
msgid "Close Other Tabs"
-msgstr "關閉其他é¸é …å¡"
+msgstr "關閉其他分é "
#: editor/editor_node.cpp
msgid "Close Tabs to the Right"
-msgstr "關閉å³æ–¹æ‰€æœ‰çš„分é "
+msgstr "關閉å³å´åˆ†é "
#: editor/editor_node.cpp
-#, fuzzy
msgid "Close All Tabs"
-msgstr "全部關閉"
+msgstr "全部所有分é "
#: editor/editor_node.cpp
msgid "Switch Scene Tab"
@@ -2742,12 +2576,11 @@ msgstr "切æ›å ´æ™¯åˆ†é "
#: editor/editor_node.cpp
msgid "%d more files or folders"
-msgstr "還有 %d 個檔案/資料夾"
+msgstr "還有 %d 個檔案ï¼è³‡æ–™å¤¾"
#: editor/editor_node.cpp
-#, fuzzy
msgid "%d more folders"
-msgstr "還有 %d 個檔案"
+msgstr "還有 %d 個資料夾"
#: editor/editor_node.cpp
msgid "%d more files"
@@ -2755,33 +2588,31 @@ msgstr "還有 %d 個檔案"
#: editor/editor_node.cpp
msgid "Dock Position"
-msgstr "版é¢ä½ç½®"
+msgstr "Dock ä½ç½®"
#: editor/editor_node.cpp
msgid "Distraction Free Mode"
-msgstr "無干擾模å¼"
+msgstr "專注模å¼"
#: editor/editor_node.cpp
msgid "Toggle distraction-free mode."
-msgstr "切æ›ç‚ºç„¡å¹²æ“¾æ¨¡å¼ã€‚"
+msgstr "切æ›ï¼å–消專注模å¼ã€‚"
#: editor/editor_node.cpp
msgid "Add a new scene."
msgstr "新增場景。"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Scene"
msgstr "場景"
#: editor/editor_node.cpp
msgid "Go to previously opened scene."
-msgstr "å‰å¾€ä¸Šæ¬¡é–‹å•Ÿçš„場景。"
+msgstr "跳至上一個開啟的場景。"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Copy Text"
-msgstr "複製路徑"
+msgstr "複製文字"
#: editor/editor_node.cpp
msgid "Next tab"
@@ -2805,7 +2636,7 @@ msgstr "新場景"
#: editor/editor_node.cpp
msgid "New Inherited Scene..."
-msgstr "從ç¾æœ‰å ´æ™¯ä¸­å»ºç«‹â€¦"
+msgstr "新增繼承場景…"
#: editor/editor_node.cpp
msgid "Open Scene..."
@@ -2817,12 +2648,11 @@ msgstr "最近開啟的場景"
#: editor/editor_node.cpp
msgid "Save Scene"
-msgstr "儲存場景"
+msgstr "ä¿å­˜å ´æ™¯"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Save All Scenes"
-msgstr "儲存全部場景"
+msgstr "ä¿å­˜æ‰€æœ‰å ´æ™¯"
#: editor/editor_node.cpp
msgid "Convert To..."
@@ -2830,29 +2660,25 @@ msgstr "轉æ›æˆâ€¦"
#: editor/editor_node.cpp
msgid "MeshLibrary..."
-msgstr "網狀資料庫(MeshLibrary)…"
+msgstr "網格庫…"
#: editor/editor_node.cpp
msgid "TileSet..."
-msgstr "å€å¡Šç´ æ…"
+msgstr "圖塊集…"
#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Undo"
-msgstr "還原"
+msgstr "復原"
#: editor/editor_node.cpp editor/plugins/script_text_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Redo"
-msgstr "é‡ä½œ"
-
-#: editor/editor_node.cpp
-msgid "Revert Scene"
-msgstr "æ¢å¾©å ´æ™¯"
+msgstr "å–消復原"
#: editor/editor_node.cpp
msgid "Miscellaneous project or scene-wide tools."
-msgstr "其他專案或全螢幕工具。"
+msgstr "其他專案或全場景共通工具。"
#: editor/editor_node.cpp editor/project_manager.cpp
#: editor/script_create_dialog.cpp
@@ -2860,44 +2686,40 @@ msgid "Project"
msgstr "專案"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Project Settings..."
-msgstr "專案設定"
+msgstr "專案設定..."
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Version Control"
-msgstr "版本:"
+msgstr "版本控制"
#: editor/editor_node.cpp editor/plugins/version_control_editor_plugin.cpp
msgid "Set Up Version Control"
-msgstr ""
+msgstr "設定版本控制"
#: editor/editor_node.cpp
msgid "Shut Down Version Control"
-msgstr ""
+msgstr "終止版本控制"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Export..."
-msgstr "輸出"
+msgstr "匯出..."
#: editor/editor_node.cpp
msgid "Install Android Build Template..."
-msgstr ""
+msgstr "å®‰è£ Android 建構樣æ¿..."
#: editor/editor_node.cpp
msgid "Open Project Data Folder"
-msgstr "開啟專案資料夾"
+msgstr "開啟專案資料目錄"
#: editor/editor_node.cpp editor/plugins/tile_set_editor_plugin.cpp
msgid "Tools"
msgstr "工具"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Orphan Resource Explorer..."
-msgstr "孤立資料管ç†å™¨"
+msgstr "孤立資æºç€è¦½å™¨..."
#: editor/editor_node.cpp
msgid "Quit to Project List"
@@ -2910,17 +2732,18 @@ msgstr "åµéŒ¯"
#: editor/editor_node.cpp
msgid "Deploy with Remote Debug"
-msgstr "使用é ç«¯åµéŒ¯"
+msgstr "部署並啟用é ç«¯åµéŒ¯"
#: editor/editor_node.cpp
msgid ""
"When exporting or deploying, the resulting executable will attempt to "
"connect to the IP of this computer in order to be debugged."
-msgstr "當輸出或發布專案後,å¯åŸ·è¡Œæ–‡ä»¶(exe)將會嘗試連çµæœ¬æ©Ÿï¼©ï¼°ï¼Œä»¥é€²è¡ŒåµéŒ¯ã€‚"
+msgstr ""
+"匯出或部署時,輸出的å¯åŸ·è¡Œæª”將會嘗試連接到這å°é›»è…¦çš„ IP ä½ç½®ä»¥é€²è¡Œé™¤éŒ¯ã€‚"
#: editor/editor_node.cpp
msgid "Small Deploy with Network FS"
-msgstr "å°åž‹éƒ¨å±¬ & 網路文件系統(NFS)"
+msgstr "使用網路檔案系統進行å°åž‹éƒ¨ç½²"
#: editor/editor_node.cpp
msgid ""
@@ -2931,34 +2754,34 @@ msgid ""
"On Android, deploy will use the USB cable for faster performance. This "
"option speeds up testing for games with a large footprint."
msgstr ""
-"啟用此é¸é …後,在輸出/發布項目時,執行檔會壓縮至最å°ã€‚\n"
-"至於文件系統,則以網路與編輯器的連çµä¾†ä¾›çµ¦ã€‚\n"
-"在Androidå¹³å°ï¼Œé€éŽUSB發布能ç²å¾—更快的效率。\n"
-"æ­¤é¸é …用於加速éŠæˆ²(尤其是檔案ç¹å¤š)的測試。"
+"當該é¸é …啟用後,匯出或部署將會產生最å°åŒ–çš„å¯åŸ·è¡Œæª”。\n"
+"檔案系統將由這個編輯器在網路上æ供。\n"
+"Android å¹³å°ä¸Šï¼Œéƒ¨ç½²éœ€è¦ä½¿ç”¨ USB 線以ç²å¾—更快速的效能。該é¸é …å°æ–¼å¤§åž‹éŠæˆ²èƒ½åŠ "
+"速測試。"
#: editor/editor_node.cpp
msgid "Visible Collision Shapes"
-msgstr "碰撞å€åŸŸçš„顯示"
+msgstr "顯示碰撞å€åŸŸ"
#: editor/editor_node.cpp
msgid ""
"Collision shapes and raycast nodes (for 2D and 3D) will be visible on the "
"running game if this option is turned on."
-msgstr "啟用此é¸é …後,碰撞å€åŸŸ/射線節點 將會於éŠæˆ²ä¸­é¡¯ç¤ºã€‚"
+msgstr "該é¸é …開啟後,執行éŠæˆ²æ™‚å°‡å¯çœ‹è¦‹ç¢°æ’žå€åŸŸèˆ‡ï¼ˆ2D 或 3D 的)射線節點。"
#: editor/editor_node.cpp
msgid "Visible Navigation"
-msgstr "導航的顯示"
+msgstr "顯示導航"
#: editor/editor_node.cpp
msgid ""
"Navigation meshes and polygons will be visible on the running game if this "
"option is turned on."
-msgstr "啟用此é¸é …後,導航所用的網線/多邊形 將會於éŠæˆ²ä¸­é¡¯ç¤ºã€‚"
+msgstr "該é¸é …開啟後,執行éŠæˆ²æ™‚å°‡å¯çœ‹è¦‹å°Žèˆªç¶²æ ¼ (mesh) 與多邊形。"
#: editor/editor_node.cpp
msgid "Sync Scene Changes"
-msgstr "åŒæ­¥å ´æ™¯çš„變更"
+msgstr "åŒæ­¥å ´æ™¯æ”¹å‹•"
#: editor/editor_node.cpp
msgid ""
@@ -2967,12 +2790,12 @@ msgid ""
"When used remotely on a device, this is more efficient with network "
"filesystem."
msgstr ""
-"啟用此é¸é …後,編輯器中的所有修改,都會立å³å映於é‹è¡Œä¸­çš„éŠæˆ²ã€‚\n"
-"在é ç«¯è£ç½®æ¸¬è©¦æ™‚,é…åˆç¶²è·¯æ–‡ä»¶ç³»çµ±(NFS)使用能更æ高效率。"
+"開啟該é¸é …後,編輯器中å°è©²å ´æ™¯çš„所有改動都將被套用至執行中的éŠæˆ²ã€‚\n"
+"若在é ç«¯è£ç½®ä¸Šä½¿ç”¨ï¼Œå¯ä½¿ç”¨ç¶²è·¯æª”案系統 NFS 以ç²å¾—最佳效能。"
#: editor/editor_node.cpp
msgid "Sync Script Changes"
-msgstr "åŒæ­¥è…³æœ¬çš„變更"
+msgstr "åŒæ­¥è…³æœ¬æ”¹å‹•"
#: editor/editor_node.cpp
msgid ""
@@ -2981,66 +2804,60 @@ msgid ""
"When used remotely on a device, this is more efficient with network "
"filesystem."
msgstr ""
-"啟用此é¸é …後,腳本的所有修改,都會立å³å映於é‹è¡Œä¸­çš„éŠæˆ²ã€‚\n"
-"在é ç«¯è£ç½®æ¸¬è©¦æ™‚,é…åˆç¶²è·¯æ–‡ä»¶ç³»çµ±(NFS)使用能更æ高效率。"
+"當開啟該é¸é …後,ä¿å­˜çš„腳本都將在執行中的éŠæˆ²é‡æ–°è¼‰å…¥ã€‚\n"
+"若在é ç«¯è£ç½®ä¸Šä½¿ç”¨ï¼Œå¯ä½¿ç”¨ç¶²è·¯æª”案系統 NFS 以ç²å¾—最佳效能。"
#: editor/editor_node.cpp editor/script_create_dialog.cpp
msgid "Editor"
msgstr "編輯器"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Editor Settings..."
-msgstr "編輯器設定"
+msgstr "編輯器設定..."
#: editor/editor_node.cpp
msgid "Editor Layout"
-msgstr "編輯器佈局"
+msgstr "編輯器é…ç½®"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Take Screenshot"
-msgstr "儲存場景"
+msgstr "螢幕截圖"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Screenshots are stored in the Editor Data/Settings Folder."
-msgstr "開啟 編輯器數據/設定 資料夾"
+msgstr "截圖將被儲存於編輯器資料或編輯器設定資料夾內。"
#: editor/editor_node.cpp
msgid "Toggle Fullscreen"
-msgstr "全螢幕顯示"
+msgstr "é–‹å•Ÿï¼å–消全螢幕顯示"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Toggle System Console"
-msgstr "切æ›æ¨¡å¼"
+msgstr "é–‹å•Ÿï¼é—œé–‰ç³»çµ±ä¸»æŽ§å°"
#: editor/editor_node.cpp
msgid "Open Editor Data/Settings Folder"
-msgstr "開啟 編輯器數據/設定 資料夾"
+msgstr "開啟「編輯器資料ï¼ç·¨è¼¯å™¨è¨­å®šã€è³‡æ–™å¤¾"
#: editor/editor_node.cpp
msgid "Open Editor Data Folder"
-msgstr "開啟 編輯器數據 資料夾"
+msgstr "開啟編輯器資料目錄"
#: editor/editor_node.cpp
msgid "Open Editor Settings Folder"
-msgstr "開啟 編輯器設定 資料夾"
+msgstr "開啟編輯器設定目錄"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Manage Editor Features..."
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "管ç†ç·¨è¼¯å™¨åŠŸèƒ½..."
#: editor/editor_node.cpp
-#, fuzzy
msgid "Manage Export Templates..."
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "管ç†åŒ¯å‡ºæ¨£æ¿..."
#: editor/editor_node.cpp editor/plugins/shader_editor_plugin.cpp
msgid "Help"
-msgstr "幫助"
+msgstr "說明"
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
@@ -3054,24 +2871,23 @@ msgstr "æœå°‹"
#: editor/editor_node.cpp editor/plugins/script_editor_plugin.cpp
#: editor/plugins/shader_editor_plugin.cpp
msgid "Online Docs"
-msgstr "線上文件"
+msgstr "線上說明文件"
#: editor/editor_node.cpp
msgid "Q&A"
msgstr "Q&A"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Report a Bug"
-msgstr "é‡æ–°å°Žå…¥"
+msgstr "回報錯誤"
#: editor/editor_node.cpp
msgid "Send Docs Feedback"
-msgstr ""
+msgstr "傳é€èªªæ˜Žæ–‡ä»¶å›žé¥‹"
#: editor/editor_node.cpp editor/plugins/asset_library_editor_plugin.cpp
msgid "Community"
-msgstr "社å€"
+msgstr "社群"
#: editor/editor_node.cpp
msgid "About"
@@ -3079,15 +2895,15 @@ msgstr "關於"
#: editor/editor_node.cpp
msgid "Play the project."
-msgstr "é‹è¡Œæ­¤å°ˆæ¡ˆã€‚"
+msgstr "執行該專案。"
#: editor/editor_node.cpp
msgid "Play"
-msgstr "é‹è¡Œ"
+msgstr "執行"
#: editor/editor_node.cpp
msgid "Pause the scene execution for debugging."
-msgstr ""
+msgstr "æš«åœè©²å ´æ™¯ä»¥é€²è¡Œé™¤éŒ¯ã€‚"
#: editor/editor_node.cpp
msgid "Pause Scene"
@@ -3095,56 +2911,52 @@ msgstr "æš«åœå ´æ™¯"
#: editor/editor_node.cpp
msgid "Stop the scene."
-msgstr "åœæ­¢æ­¤å ´æ™¯."
+msgstr "åœæ­¢å ´æ™¯ã€‚"
#: editor/editor_node.cpp
msgid "Play the edited scene."
-msgstr "é‹è¡Œç·¨è¼¯éŽçš„場景。"
+msgstr "執行已編輯的場景。"
#: editor/editor_node.cpp
msgid "Play Scene"
-msgstr "é‹è¡Œå ´æ™¯"
+msgstr "執行場景"
#: editor/editor_node.cpp
msgid "Play custom scene"
-msgstr "é‹è¡Œè‡ªå®šç¾©å ´æ™¯"
+msgstr "執行自定義場景"
#: editor/editor_node.cpp
msgid "Play Custom Scene"
-msgstr "é‹è¡Œè‡ªå®šç¾©å ´æ™¯"
+msgstr "執行自定義場景"
#: editor/editor_node.cpp
msgid "Changing the video driver requires restarting the editor."
-msgstr "在更動顯示驅動後,必須é‡æ–°é–‹å•Ÿç·¨è¼¯å™¨ã€‚"
+msgstr "更改視訊驅動程å¼éœ€è¦é‡æ–°å•Ÿå‹•ç·¨è¼¯å™¨ã€‚"
#: editor/editor_node.cpp editor/project_settings_editor.cpp
#: editor/settings_config_dialog.cpp
msgid "Save & Restart"
-msgstr "儲存並é‡å•Ÿ"
+msgstr "ä¿å­˜ä¸¦é‡æ–°å•Ÿå‹•"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Spins when the editor window redraws."
-msgstr "在é‡æ–°ç¹ªè£½(repaint)編輯器視窗時,來個旋轉ï¼"
+msgstr "編輯器視窗é‡æ–°ç¹ªè£½æ™‚旋轉。"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Update Continuously"
-msgstr "連續"
+msgstr "æŒçºŒæ›´æ–°"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Update When Changed"
-msgstr "有更動時自動更新"
+msgstr "更改時更新"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Hide Update Spinner"
-msgstr "ç¦æ­¢è‡ªå‹•æ›´æ–°"
+msgstr "éš±è—更新旋轉圖"
#: editor/editor_node.cpp
msgid "FileSystem"
-msgstr "文件系統"
+msgstr "檔案系統"
#: editor/editor_node.cpp
msgid "Inspector"
@@ -3156,20 +2968,19 @@ msgstr "展開底部é¢æ¿"
#: editor/editor_node.cpp
msgid "Output"
-msgstr "輸出(output)"
+msgstr "輸出"
#: editor/editor_node.cpp
msgid "Don't Save"
-msgstr "ä¸è¦å„²å­˜"
+msgstr "ä¸ä¿å­˜"
#: editor/editor_node.cpp
msgid "Android build template is missing, please install relevant templates."
-msgstr ""
+msgstr "缺少 Android 建構樣æ¿ï¼Œè«‹å…ˆå®‰è£å°æ‡‰çš„樣æ¿ã€‚"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Manage Templates"
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "管ç†æ¨£æ¿"
#: editor/editor_node.cpp
msgid ""
@@ -3181,6 +2992,12 @@ msgid ""
"the \"Use Custom Build\" option should be enabled in the Android export "
"preset."
msgstr ""
+"將通éŽåœ¨ã€Œres://android/buildã€ä¸­å®‰è£åŽŸå§‹æ¨£æ¿ä»¥ç‚ºè©²é …目設定自定 Android 建構"
+"樣æ¿ã€‚\n"
+"輸出時å¯ä»¥å¥—用修改並建構自定 APK(如新增模組ã€ä¿®æ”¹ AndroidManifest.xml …"
+"等)。\n"
+"請注æ„,若è¦ä½¿ç”¨è‡ªå®šå»ºæ§‹è€Œéžä½¿ç”¨é å…ˆå»ºæ§‹å¥½çš„ APK,請啟用 Android 匯出 Preset "
+"中的「使用自定建構ã€é¸é …。"
#: editor/editor_node.cpp
msgid ""
@@ -3189,35 +3006,36 @@ msgid ""
"Remove the \"res://android/build\" directory manually before attempting this "
"operation again."
msgstr ""
+"è©²å°ˆæ¡ˆä¸­å·²å®‰è£ Android 建構樣æ¿ï¼Œå°‡ä¸æœƒè¦†è“‹ã€‚\n"
+"è‹¥è¦å†æ¬¡åŸ·è¡Œæ­¤æ“作,請先手動移除「res://android/buildã€ç›®éŒ„。"
#: editor/editor_node.cpp
msgid "Import Templates From ZIP File"
-msgstr "導入模æ¿ï¼ˆé€éŽZIP檔案)"
+msgstr "自 ZIP 檔匯入樣æ¿"
#: editor/editor_node.cpp
-#, fuzzy
msgid "Template Package"
-msgstr "導出範本管ç†å™¨"
+msgstr "樣æ¿åŒ…"
#: editor/editor_node.cpp
msgid "Export Library"
-msgstr "輸出函å¼åº«"
+msgstr "匯出函å¼åº«"
#: editor/editor_node.cpp
msgid "Merge With Existing"
-msgstr "與ç¾æœ‰å‡½å¼åº«åˆä½µ"
+msgstr "與ç¾æœ‰çš„åˆä½µ"
#: editor/editor_node.cpp
msgid "Open & Run a Script"
-msgstr "開啟並é‹è¡Œè…³æœ¬"
+msgstr "開啟並執行腳本"
#: editor/editor_node.cpp
msgid "New Inherited"
-msgstr "從ç¾æœ‰å ´æ™¯ä¸­å»ºç«‹"
+msgstr "新增繼承"
#: editor/editor_node.cpp
msgid "Load Errors"
-msgstr "讀å–時出ç¾éŒ¯èª¤"
+msgstr "載入錯誤"
#: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp
msgid "Select"
@@ -3225,11 +3043,11 @@ msgstr "é¸æ“‡"
#: editor/editor_node.cpp
msgid "Open 2D Editor"
-msgstr "開啟2D編輯器"
+msgstr "開啟 2D 編輯器"
#: editor/editor_node.cpp
msgid "Open 3D Editor"
-msgstr "開啟3D編輯器"
+msgstr "開啟 3D 編輯器"
#: editor/editor_node.cpp
msgid "Open Script Editor"
@@ -3237,7 +3055,7 @@ msgstr "開啟腳本編輯器"
#: editor/editor_node.cpp editor/project_manager.cpp
msgid "Open Asset Library"
-msgstr "é–‹å•Ÿç´ æ倉庫"
+msgstr "é–‹å•Ÿç´ æ庫"
#: editor/editor_node.cpp
msgid "Open the next Editor"
@@ -3248,35 +3066,32 @@ msgid "Open the previous Editor"
msgstr "開啟上一個編輯器"
#: editor/editor_node.h
-#, fuzzy
msgid "Warning!"
-msgstr "警告"
+msgstr "警告ï¼"
#: editor/editor_path.cpp
-#, fuzzy
msgid "No sub-resources found."
-msgstr "未指定表é¢æºã€‚"
+msgstr "未找到å­è³‡æºã€‚"
#: editor/editor_plugin.cpp
msgid "Creating Mesh Previews"
-msgstr "創建網格é è¦½"
+msgstr "建立網格é è¦½"
#: editor/editor_plugin.cpp
msgid "Thumbnail..."
msgstr "縮圖…"
#: editor/editor_plugin_settings.cpp
-#, fuzzy
msgid "Main Script:"
-msgstr "開啟最近存å–"
+msgstr "主腳本:"
#: editor/editor_plugin_settings.cpp
msgid "Edit Plugin"
-msgstr "編輯擴充功能"
+msgstr "編輯外掛"
#: editor/editor_plugin_settings.cpp
msgid "Installed Plugins:"
-msgstr "已安è£çš„擴充功能:"
+msgstr "已安è£çš„外掛:"
#: editor/editor_plugin_settings.cpp editor/plugin_config_dialog.cpp
msgid "Update"
@@ -3301,11 +3116,11 @@ msgstr "編輯:"
#: editor/editor_profiler.cpp
msgid "Measure:"
-msgstr "措施:"
+msgstr "測é‡ï¼š"
#: editor/editor_profiler.cpp
msgid "Frame Time (sec)"
-msgstr "幀時間 (秒)"
+msgstr "影格長度 (秒)"
#: editor/editor_profiler.cpp
msgid "Average Time (sec)"
@@ -3313,19 +3128,19 @@ msgstr "å¹³å‡æ™‚é–“ (秒)"
#: editor/editor_profiler.cpp
msgid "Frame %"
-msgstr "å¹€%"
+msgstr "影格 %"
#: editor/editor_profiler.cpp
msgid "Physics Frame %"
-msgstr "物ç†å¹€%"
+msgstr "物ç†å½±æ ¼ %"
#: editor/editor_profiler.cpp
msgid "Inclusive"
-msgstr "包容"
+msgstr "全部"
#: editor/editor_profiler.cpp
msgid "Self"
-msgstr "自身"
+msgstr "僅自己"
#: editor/editor_profiler.cpp
msgid "Frame #:"
@@ -3337,24 +3152,23 @@ msgstr "時間"
#: editor/editor_profiler.cpp
msgid "Calls"
-msgstr "調用"
+msgstr "呼å«"
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Edit Text:"
-msgstr "編輯主題…"
+msgstr "編輯文字:"
#: editor/editor_properties.cpp editor/script_create_dialog.cpp
msgid "On"
-msgstr "啟用"
+msgstr "é–‹å•Ÿ"
#: editor/editor_properties.cpp
msgid "Layer"
-msgstr "層"
+msgstr "圖層"
#: editor/editor_properties.cpp
msgid "Bit %d, value %d"
-msgstr "ä½ %d, 值 %d"
+msgstr "ä½ %d,值 %d"
#: editor/editor_properties.cpp
msgid "[Empty]"
@@ -3365,21 +3179,22 @@ msgid "Assign..."
msgstr "指派..."
#: editor/editor_properties.cpp
-#, fuzzy
msgid "Invalid RID"
-msgstr "無效的路徑"
+msgstr "無效的 RID"
#: editor/editor_properties.cpp
msgid ""
"The selected resource (%s) does not match any type expected for this "
"property (%s)."
-msgstr "所é¸è³‡æºï¼ˆ%s)與此内容(%s)所需的任何類型都ä¸åŒ¹é…。"
+msgstr "所é¸çš„資æºï¼ˆ%s)並ä¸ç¬¦åˆä»»è©²å±¬æ€§ï¼ˆ%s)的任何型別。"
#: editor/editor_properties.cpp
msgid ""
"Can't create a ViewportTexture on resources saved as a file.\n"
"Resource needs to belong to a scene."
msgstr ""
+"無法為è¦ä¿å­˜ç‚ºæª”案的資æºå»ºç«‹æª¢è¦–å€ç´‹ç† (ViewportTexture)。\n"
+"資æºå¿…須屬於一個場景。"
#: editor/editor_properties.cpp
msgid ""
@@ -3388,27 +3203,28 @@ msgid ""
"Please switch on the 'local to scene' property on it (and all resources "
"containing it up to a node)."
msgstr ""
+"無法為該資æºå»ºç«‹æª¢è¦–å€ç´‹ç† (ViewportTexture),因其未設定å°æ‡‰çš„本地場景。\n"
+"請開啟其(與其至節點的所有資æºï¼‰çš„「本地化場景ã€å±¬æ€§ã€‚"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Pick a Viewport"
-msgstr "é¸æ“‡ä¸€å€‹è¦–å£"
+msgstr "é¸æ“‡æª¢è¦–å€"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "New Script"
-msgstr "新建腳本"
+msgstr "新增腳本"
#: editor/editor_properties.cpp editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Extend Script"
-msgstr "開啟最近存å–"
+msgstr "擴充腳本"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "New %s"
-msgstr "新建 %s"
+msgstr "新增 %s"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Make Unique"
-msgstr "轉æ›ç‚ºç¨ç«‹è³‡æº"
+msgstr "ç¨ç«‹åŒ–"
#: editor/editor_properties.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
@@ -3422,24 +3238,23 @@ msgstr "轉æ›ç‚ºç¨ç«‹è³‡æº"
#: editor/plugins/tile_map_editor_plugin.cpp editor/property_editor.cpp
#: scene/gui/line_edit.cpp scene/gui/text_edit.cpp
msgid "Paste"
-msgstr "粘貼"
+msgstr "貼上"
#: editor/editor_properties.cpp editor/property_editor.cpp
-#, fuzzy
msgid "Convert To %s"
-msgstr "轉æ›æˆ..."
+msgstr "轉æ›æˆ %s"
#: editor/editor_properties.cpp editor/property_editor.cpp
msgid "Selected node is not a Viewport!"
-msgstr "é¸å®šçš„節點ä¸æ˜¯è¦–å£!"
+msgstr "所é¸ç¯€é»žä¸æ˜¯æª¢è¦–å€ (Viewport)ï¼"
#: editor/editor_properties_array_dict.cpp
msgid "Size: "
-msgstr "尺寸: "
+msgstr "大å°ï¼š "
#: editor/editor_properties_array_dict.cpp
msgid "Page: "
-msgstr "页: "
+msgstr "é ï¼š "
#: editor/editor_properties_array_dict.cpp
#: editor/plugins/theme_editor_plugin.cpp
@@ -3448,50 +3263,55 @@ msgstr "移除項目"
#: editor/editor_properties_array_dict.cpp
msgid "New Key:"
-msgstr "新建帧:"
+msgstr "新增éµå€¼ï¼š"
#: editor/editor_properties_array_dict.cpp
-#, fuzzy
msgid "New Value:"
-msgstr "數值"
+msgstr "新增數值:"
#: editor/editor_properties_array_dict.cpp
msgid "Add Key/Value Pair"
-msgstr ""
+msgstr "新增éµï¼å€¼é…å°"
#: editor/editor_run_native.cpp
msgid ""
"No runnable export preset found for this platform.\n"
"Please add a runnable preset in the export menu."
msgstr ""
+"該平å°æ²’有å¯åŸ·è¡Œçš„匯出 Preset。\n"
+"請在匯出é¸å–®ä¸­æ–°å¢žä¸€å€‹å¯åŸ·è¡Œçš„ Preset。"
#: editor/editor_run_script.cpp
msgid "Write your logic in the _run() method."
-msgstr "將您的é‚輯寫在_run()方法中。"
+msgstr "在 _run() 方法中填寫é‚輯。"
#: editor/editor_run_script.cpp
msgid "There is an edited scene already."
-msgstr "已經有一個正在編輯的場景。"
+msgstr "已有一個已編輯的場景。"
#: editor/editor_run_script.cpp
msgid "Couldn't instance script:"
-msgstr "無法實例腳本:"
+msgstr "無法實體化腳本:"
#: editor/editor_run_script.cpp
msgid "Did you forget the 'tool' keyword?"
-msgstr "您是å¦éºæ¼äº† 'tool' 关键字?"
+msgstr "是å¦éºæ¼ã€Œtoolã€é—œéµå­—?"
#: editor/editor_run_script.cpp
msgid "Couldn't run script:"
-msgstr "無法é‹è¡Œè…³æœ¬:"
+msgstr "無法執行腳本:"
#: editor/editor_run_script.cpp
msgid "Did you forget the '_run' method?"
-msgstr "您是å¦éºæ¼äº† '_run' 方法?"
+msgstr "是å¦éºæ¼äº†ã€Œ_runã€æ–¹æ³•ï¼Ÿ"
+
+#: editor/editor_spin_slider.cpp
+msgid "Hold Ctrl to round to integers. Hold Shift for more precise changes."
+msgstr "æŒ‰ä½ Ctrl 以å–æ•´æ•¸ã€‚æŒ‰ä½ Shift 以使用更精確的改動。"
#: editor/editor_sub_scene.cpp
msgid "Select Node(s) to Import"
-msgstr "é¸æ“‡è¦å°Žå…¥çš„節點"
+msgstr "é¸æ“‡è¦åŒ¯å…¥çš„節點"
#: editor/editor_sub_scene.cpp editor/project_manager.cpp
msgid "Browse"
@@ -3499,24 +3319,23 @@ msgstr "ç€è¦½"
#: editor/editor_sub_scene.cpp
msgid "Scene Path:"
-msgstr "場景路徑:"
+msgstr "場景路徑:"
#: editor/editor_sub_scene.cpp
msgid "Import From Node:"
-msgstr "從節點導入:"
+msgstr "自節點中匯入:"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Redownload"
msgstr "é‡æ–°ä¸‹è¼‰"
#: editor/export_template_manager.cpp
msgid "Uninstall"
-msgstr "å¸è¼‰"
+msgstr "å–消安è£"
#: editor/export_template_manager.cpp
msgid "(Installed)"
-msgstr "(已安è£)"
+msgstr "(已安è£ï¼‰"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
@@ -3525,73 +3344,71 @@ msgstr "下載"
#: editor/export_template_manager.cpp
msgid "Official export templates aren't available for development builds."
-msgstr ""
+msgstr "開發建構 (Development Build) 下無法使用官方匯出樣æ¿ã€‚"
#: editor/export_template_manager.cpp
msgid "(Missing)"
-msgstr "(缺少)"
+msgstr "(éºå¤±ï¼‰"
#: editor/export_template_manager.cpp
msgid "(Current)"
-msgstr "(當å‰)"
+msgstr "(目å‰ï¼‰"
#: editor/export_template_manager.cpp
msgid "Retrieving mirrors, please wait..."
-msgstr "正在檢索é¡åƒï¼Œè«‹ç¨å€™â€¦"
+msgstr "正在å–å¾—é¡åƒï¼Œè«‹ç¨å¾Œ..."
#: editor/export_template_manager.cpp
msgid "Remove template version '%s'?"
-msgstr "是å¦åˆ é™¤ç‰ˆæœ¬ç‚ºâ€œ%sâ€çš„範本?"
+msgstr "是å¦åˆªé™¤æ¨£æ¿ç‰ˆæœ¬ã€Œ%sã€ï¼Ÿ"
#: editor/export_template_manager.cpp
msgid "Can't open export templates zip."
-msgstr "無法打開zip導出範本。"
+msgstr "ç„¡æ³•é–‹å•ŸåŒ¯å‡ºæ¨£æ¿ ZIP 檔。"
#: editor/export_template_manager.cpp
msgid "Invalid version.txt format inside templates: %s."
-msgstr "範本文件: %s 中的 version.txt 無效."
+msgstr "æ¨£æ¿ %s 中的 version.txt æ ¼å¼ç„¡æ•ˆã€‚"
#: editor/export_template_manager.cpp
msgid "No version.txt found inside templates."
-msgstr "範本中沒有找到version.txt文件。"
+msgstr "樣æ¿ä¸­æœªæ‰¾åˆ° version.txt。"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Error creating path for templates:"
-msgstr "載入場景時發生錯誤"
+msgstr "為樣æ¿å»ºç«‹è·¯å¾‘時發生錯誤:"
#: editor/export_template_manager.cpp
msgid "Extracting Export Templates"
-msgstr "正在解壓導出範本"
+msgstr "正在解壓縮匯出樣æ¿"
#: editor/export_template_manager.cpp
msgid "Importing:"
-msgstr "å°Žå…¥:"
+msgstr "正在匯入:"
#: editor/export_template_manager.cpp
msgid "Error getting the list of mirrors."
-msgstr ""
+msgstr "å–å¾—é¡åƒåˆ—表時發生錯誤。"
#: editor/export_template_manager.cpp
msgid "Error parsing JSON of mirror list. Please report this issue!"
-msgstr ""
+msgstr "解æžé¡åƒåˆ—表的 JSON 時發生錯誤。請回報此å•é¡Œï¼"
#: editor/export_template_manager.cpp
msgid ""
"No download links found for this version. Direct download is only available "
"for official releases."
-msgstr "沒有找到這個版本的下載éˆæŽ¥. 直接下載é©ç”¨äºŽæ­£å¼ç‰ˆæœ¬."
+msgstr "為找到該版本的下載éˆæŽ¥ã€‚直接下載僅é©ç”¨æ–¼æ­£å¼ç‰ˆæœ¬ã€‚"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't resolve."
-msgstr "無法解æž."
+msgstr "無法解æžã€‚"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Can't connect."
-msgstr "連接..."
+msgstr "無法連線。"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
@@ -3600,11 +3417,11 @@ msgstr "沒有回應。"
#: editor/export_template_manager.cpp
msgid "Request Failed."
-msgstr "請求失敗."
+msgstr "請求失敗。"
#: editor/export_template_manager.cpp
msgid "Redirect Loop."
-msgstr "é‡æ–°å®šå‘循環."
+msgstr "é‡æ–°å°Žå‘循環。"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
@@ -3616,35 +3433,32 @@ msgid "Download Complete."
msgstr "下載完æˆã€‚"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Cannot remove temporary file:"
-msgstr "無法將主題ä¿å­˜åˆ°æª”案:"
+msgstr "無法移除臨時檔案:"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid ""
"Templates installation failed.\n"
"The problematic templates archives can be found at '%s'."
-msgstr "範本安è£å¤±æ•—。有å•é¡Œçš„範本存檔å¯ä»¥åœ¨ \"%s\" 中找到。"
+msgstr ""
+"未找到樣æ¿å®‰è£ã€‚\n"
+"有å•é¡Œçš„樣æ¿æª”案存放於「%sã€ã€‚"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Error requesting URL:"
-msgstr "載入場景時發生錯誤"
+msgstr "請求 URL 時發生錯誤:"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Connecting to Mirror..."
-msgstr "連接..."
+msgstr "正在連線到é¡åƒ..."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Disconnected"
-msgstr "æ–·ç·š"
+msgstr "已斷開連線"
#: editor/export_template_manager.cpp
msgid "Resolving"
-msgstr "解æžä¸­"
+msgstr "正在解æž"
#: editor/export_template_manager.cpp
msgid "Can't Resolve"
@@ -3652,19 +3466,16 @@ msgstr "無法解æž"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Connecting..."
-msgstr "連接..."
+msgstr "正在連線..."
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Can't Connect"
-msgstr "連接..."
+msgstr "無法連線"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Connected"
-msgstr "連接..."
+msgstr "已連線"
#: editor/export_template_manager.cpp
#: editor/plugins/asset_library_editor_plugin.cpp
@@ -3672,242 +3483,217 @@ msgid "Requesting..."
msgstr "正在請求…"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Downloading"
-msgstr "載入時發生錯誤:"
+msgstr "正在下載"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Connection Error"
-msgstr "連接..."
+msgstr "連線錯誤"
#: editor/export_template_manager.cpp
msgid "SSL Handshake Error"
-msgstr "SSLæ¡æ‰‹éŒ¯èª¤"
+msgstr "SSL 交æ¡éŒ¯èª¤"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Uncompressing Android Build Sources"
-msgstr "正在解壓縮素æ"
+msgstr "正在解壓縮 Android 建構來æº"
#: editor/export_template_manager.cpp
msgid "Current Version:"
-msgstr "當å‰ç‰ˆæœ¬:"
+msgstr "ç›®å‰ç‰ˆæœ¬ï¼š"
#: editor/export_template_manager.cpp
msgid "Installed Versions:"
-msgstr "已安è£ç‰ˆæœ¬:"
+msgstr "已安è£ç‰ˆæœ¬ï¼š"
#: editor/export_template_manager.cpp
msgid "Install From File"
-msgstr "從檔案中安è£"
+msgstr "自檔案安è£"
#: editor/export_template_manager.cpp
msgid "Remove Template"
-msgstr "移除範本"
+msgstr "移除樣æ¿"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Select Template File"
-msgstr "é¸æ“‡ç¯„本檔案"
+msgstr "é¸æ“‡æ¨£æ¿æª”案"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Godot Export Templates"
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "Godot 匯出樣æ¿"
#: editor/export_template_manager.cpp
msgid "Export Template Manager"
-msgstr "導出範本管ç†å™¨"
+msgstr "匯出樣æ¿ç®¡ç†å“¡"
#: editor/export_template_manager.cpp
-#, fuzzy
msgid "Download Templates"
-msgstr "載入場景時發生錯誤"
+msgstr "下載樣æ¿"
#: editor/export_template_manager.cpp
msgid "Select mirror from list: (Shift+Click: Open in Browser)"
-msgstr "從清單中é¸æ“‡é¡åƒ: (Shift + 單擊: 在ç€è¦½å™¨ä¸­æ‰“é–‹)"
+msgstr "自列表中é¸æ“‡é¡åƒï¼šï¼ˆShift+點擊:在ç€è¦½å™¨ä¸­é–‹å•Ÿï¼‰"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Favorites"
-msgstr "我的最愛:"
+msgstr "我的最愛"
#: editor/filesystem_dock.cpp
msgid "Status: Import of file failed. Please fix file and reimport manually."
-msgstr ""
+msgstr "狀態:檔案匯入失敗。請修正檔案並手動é‡æ–°åŒ¯å…¥ã€‚"
#: editor/filesystem_dock.cpp
msgid "Cannot move/rename resources root."
-msgstr "無法移動/é‡å‘½å資æºæ ¹ç›®éŒ„。"
+msgstr "無法移動ï¼é‡æ–°å‘½å根資æºã€‚"
#: editor/filesystem_dock.cpp
msgid "Cannot move a folder into itself."
-msgstr "無法將資料夾移動到其自身。"
+msgstr "無法移動資料夾至該資料夾自己。"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Error moving:"
-msgstr "載入時發生錯誤:"
+msgstr "移動時發生錯誤:"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Error duplicating:"
-msgstr "載入時發生錯誤:"
+msgstr "複製時發生錯誤:"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Unable to update dependencies:"
-msgstr "場景缺少了æŸäº›è³‡æºä»¥è‡³æ–¼ç„¡æ³•è¼‰å…¥"
+msgstr "無法更新相ä¾æ€§ï¼š"
#: editor/filesystem_dock.cpp editor/scene_tree_editor.cpp
msgid "No name provided."
msgstr "未æä¾›å稱。"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Provided name contains invalid characters."
-msgstr "æ供的å稱包å«ç„¡æ•ˆå­—å…ƒ"
+msgstr "æ供的å稱包å«äº†ç„¡æ•ˆçš„字元。"
#: editor/filesystem_dock.cpp
msgid "A file or folder with this name already exists."
-msgstr "具有此å稱的檔或資料夾已存在。"
+msgstr "已有相åŒå稱的檔案或資料夾存在。"
#: editor/filesystem_dock.cpp
msgid "Name contains invalid characters."
-msgstr "å稱包å«ç„¡æ•ˆå­—元。"
+msgstr "å稱包å«äº†ç„¡æ•ˆçš„字元。"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Renaming file:"
-msgstr "載入時發生錯誤:"
+msgstr "é‡æ–°å‘½å檔案:"
#: editor/filesystem_dock.cpp
msgid "Renaming folder:"
-msgstr "é‡å‘½å資料夾:"
+msgstr "é‡æ–°å‘½å資料夾:"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Duplicating file:"
-msgstr "載入時發生錯誤:"
+msgstr "複製檔案:"
#: editor/filesystem_dock.cpp
msgid "Duplicating folder:"
-msgstr "複製資料夾:"
+msgstr "複製資料夾:"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Inherited Scene"
-msgstr "從ç¾æœ‰å ´æ™¯ä¸­å»ºç«‹â€¦"
+msgstr "新增繼承場景"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Set As Main Scene"
-msgstr "é¸å–主è¦å ´æ™¯"
+msgstr "設為主場景"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Open Scenes"
msgstr "開啟場景"
#: editor/filesystem_dock.cpp
msgid "Instance"
-msgstr "實例"
+msgstr "實體"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Add to Favorites"
-msgstr "我的最愛:"
+msgstr "新增到我的最愛"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Remove from Favorites"
-msgstr "移除"
+msgstr "自我的最愛中移除"
#: editor/filesystem_dock.cpp
msgid "Edit Dependencies..."
-msgstr "編輯ä¾è³´é ……"
+msgstr "編輯相ä¾æ€§..."
#: editor/filesystem_dock.cpp
msgid "View Owners..."
-msgstr "查看所有者…"
+msgstr "檢視æ“有者..."
#: editor/filesystem_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
msgid "Rename..."
-msgstr "é‡å‘½å…"
+msgstr "é‡æ–°å‘½å..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Duplicate..."
-msgstr "複製動畫關éµç•«æ ¼"
+msgstr "é‡è¤‡..."
#: editor/filesystem_dock.cpp
msgid "Move To..."
-msgstr "移動到..。"
+msgstr "移動至..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Scene..."
-msgstr "新場景"
+msgstr "新增場景..."
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "New Script..."
-msgstr "新增資料夾..."
+msgstr "新增腳本..."
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "New Resource..."
-msgstr "å¦å­˜è³‡æºç‚º..."
+msgstr "新增資æº..."
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
msgid "Expand All"
-msgstr "展開所有"
+msgstr "展開全部"
#: editor/filesystem_dock.cpp editor/plugins/visual_shader_editor_plugin.cpp
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Collapse All"
-msgstr "å–代全部"
+msgstr "收åˆå…¨éƒ¨"
#: editor/filesystem_dock.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
#: editor/project_manager.cpp editor/rename_dialog.cpp
#: editor/scene_tree_dock.cpp
msgid "Rename"
-msgstr "é‡å‘½å"
+msgstr "é‡æ–°å‘½å"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Previous Folder/File"
-msgstr "上個分é "
+msgstr "上一個資料夾ï¼æª”案"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Next Folder/File"
-msgstr "新增資料夾"
+msgstr "下一個資料夾ï¼æª”案"
#: editor/filesystem_dock.cpp
msgid "Re-Scan Filesystem"
msgstr "é‡æ–°æŽƒæ檔案系統"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Toggle Split Mode"
-msgstr "切æ›æ¨¡å¼"
+msgstr "é–‹å•Ÿï¼é—œé–‰åˆ†å‰²æ¨¡å¼"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Search files"
-msgstr "æœå°‹ Class"
+msgstr "æœå°‹æª”案"
#: editor/filesystem_dock.cpp
msgid ""
"Scanning Files,\n"
"Please Wait..."
-msgstr "正在掃æ檔, è«‹ç¨å€™..。"
+msgstr ""
+"正在掃æ檔案,\n"
+"è«‹ç¨å¾Œ..."
#: editor/filesystem_dock.cpp
msgid "Move"
@@ -3915,290 +3701,270 @@ msgstr "移動"
#: editor/filesystem_dock.cpp
msgid "There is already file or folder with the same name in this location."
-msgstr "æ­¤ä½ç½®å·²å­˜åœ¨åŒå的檔案或資料夾。"
+msgstr "該ä½ç½®å·²æœ‰ç›¸åŒå稱的檔案或資料夾。"
#: editor/filesystem_dock.cpp
msgid "Overwrite"
-msgstr "覆蓋"
+msgstr "複寫"
#: editor/filesystem_dock.cpp
-#, fuzzy
msgid "Create Scene"
-msgstr "從場景創建"
+msgstr "建立場景"
#: editor/filesystem_dock.cpp editor/plugins/script_editor_plugin.cpp
msgid "Create Script"
-msgstr "創建腳本"
+msgstr "建立腳本"
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Find in Files"
-msgstr "還有 %d 個檔案"
+msgstr "在檔案中æœå°‹"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Find:"
-msgstr "尋找"
+msgstr "æœå°‹ï¼š"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Folder:"
-msgstr "新增資料夾"
+msgstr "資料夾:"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Filters:"
-msgstr "éŽæ¿¾å™¨:"
+msgstr "篩é¸ï¼š"
#: editor/find_in_files.cpp
msgid ""
"Include the files with the following extensions. Add or remove them in "
"ProjectSettings."
-msgstr ""
+msgstr "包å«æœ‰ä¸‹åˆ—副檔å的檔案。å¯åœ¨å°ˆæ¡ˆè¨­å®šä¸­æ–°å¢žæˆ–移除。"
#: editor/find_in_files.cpp editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
msgid "Find..."
-msgstr "尋找..."
+msgstr "æœå°‹..."
#: editor/find_in_files.cpp editor/plugins/script_text_editor.cpp
msgid "Replace..."
-msgstr "替æ›â€¦"
+msgstr "å–代..."
#: editor/find_in_files.cpp editor/progress_dialog.cpp scene/gui/dialogs.cpp
msgid "Cancel"
msgstr "å–消"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Find: "
-msgstr "尋找"
+msgstr "æœå°‹ï¼š "
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Replace: "
-msgstr "å–代"
+msgstr "å–代: "
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Replace all (no undo)"
-msgstr "å–代全部"
+msgstr "全部å–代(無法復原)"
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Searching..."
-msgstr "æœå°‹"
+msgstr "正在æœå°‹..."
#: editor/find_in_files.cpp
-#, fuzzy
msgid "Search complete"
-msgstr "æœå°‹è©žå½™"
+msgstr "æœå°‹å®Œæˆ"
#: editor/groups_editor.cpp
msgid "Add to Group"
-msgstr "添加到組"
+msgstr "新增到群組"
#: editor/groups_editor.cpp
msgid "Remove from Group"
-msgstr "從群組移除"
+msgstr "自群組中移除"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Group name already exists."
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "群組å稱已存在。"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Invalid group name."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的群組å稱。"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Rename Group"
-msgstr "管ç†çµ„"
+msgstr "é‡æ–°å‘½å群組"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Delete Group"
-msgstr "刪除佈局"
+msgstr "刪除群組"
#: editor/groups_editor.cpp editor/node_dock.cpp
msgid "Groups"
-msgstr "組"
+msgstr "群組"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Nodes Not in Group"
-msgstr "ä¸åœ¨çµ„中的節點"
+msgstr "節點ä¸åœ¨ç¾¤çµ„中"
#: editor/groups_editor.cpp editor/scene_tree_dock.cpp
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Filter nodes"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "篩é¸ç¯€é»ž"
#: editor/groups_editor.cpp
msgid "Nodes in Group"
-msgstr "組中的節點"
+msgstr "群組中的節點"
#: editor/groups_editor.cpp
msgid "Empty groups will be automatically removed."
-msgstr ""
+msgstr "空群組將被自動移除。"
#: editor/groups_editor.cpp
-#, fuzzy
msgid "Group Editor"
-msgstr "開啟腳本編輯器"
+msgstr "群組編輯器"
#: editor/groups_editor.cpp
msgid "Manage Groups"
-msgstr "管ç†çµ„"
+msgstr "管ç†ç¾¤çµ„"
#: editor/import/resource_importer_scene.cpp
-#, fuzzy
msgid "Import as Single Scene"
-msgstr "更新場景"
+msgstr "匯入為單一場景"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Animations"
-msgstr "使用單ç¨çš„動畫一åŒå°Žå…¥"
+msgstr "與動畫分別匯入"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Materials"
-msgstr "使用單ç¨çš„æ 一åŒå°Žå…¥"
+msgstr "與素æ分別匯入"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects"
-msgstr "使用單ç¨çš„物件導入"
+msgstr "與物件單ç¨åŒ¯å…¥"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects+Materials"
-msgstr "使用單ç¨çš„å°è±¡+æ質導入"
+msgstr "與物件 + ç´ æ分別匯入"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects+Animations"
-msgstr "使用單ç¨çš„å°è±¡+å‹•ç•«å°Žå…¥"
+msgstr "與物件 + 動畫分別匯入"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Materials+Animations"
-msgstr "使用單ç¨çš„æ質+å‹•ç•«å°Žå…¥"
+msgstr "與素æ + 動畫分別匯入"
#: editor/import/resource_importer_scene.cpp
msgid "Import with Separate Objects+Materials+Animations"
-msgstr "使用單ç¨çš„å°è±¡+æ質+å‹•ç•«å°Žå…¥"
+msgstr "與物件 + ç´ æ + 動畫分別匯入"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Multiple Scenes"
-msgstr "作為多個場景導入"
+msgstr "匯入為多個場景"
#: editor/import/resource_importer_scene.cpp
msgid "Import as Multiple Scenes+Materials"
-msgstr "導入為多個場景+æ質"
+msgstr "匯入為多個場景 + ç´ æ"
#: editor/import/resource_importer_scene.cpp
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Import Scene"
-msgstr "導入場景"
+msgstr "匯入場景"
#: editor/import/resource_importer_scene.cpp
msgid "Importing Scene..."
-msgstr "正在導入場景…"
+msgstr "正在匯入場景..."
#: editor/import/resource_importer_scene.cpp
msgid "Generating Lightmaps"
-msgstr "生æˆå…‰ç…§åœ–"
+msgstr "正在產生光照圖"
#: editor/import/resource_importer_scene.cpp
msgid "Generating for Mesh: "
-msgstr "為網格生æˆï¼š "
+msgstr "正在產生網格: "
#: editor/import/resource_importer_scene.cpp
msgid "Running Custom Script..."
-msgstr "正在é‹è¡Œè‡ªå®šç¾©è…³æœ¬â€¦"
+msgstr "正在執行自定腳本..."
#: editor/import/resource_importer_scene.cpp
msgid "Couldn't load post-import script:"
-msgstr "無法加載導入後腳本:"
+msgstr "無法載入匯入後腳本:"
#: editor/import/resource_importer_scene.cpp
msgid "Invalid/broken script for post-import (check console):"
-msgstr "導入後腳本無效/å·²æ壞(檢查控制å°ï¼‰ï¼š"
+msgstr "匯入後腳本無效或æ毀(請檢查主控å°ï¼‰ï¼š"
#: editor/import/resource_importer_scene.cpp
msgid "Error running post-import script:"
-msgstr "é‹è¡Œå°Žå…¥å¾Œè…³æœ¬æ™‚出錯:"
+msgstr "執行匯入後腳本時發生錯誤:"
+
+#: editor/import/resource_importer_scene.cpp
+msgid "Did you return a Node-derived object in the `post_import()` method?"
+msgstr "是å¦æœ‰åœ¨ `post_import()` 方法內回傳 Node è¡ç”Ÿä¹‹ç‰©ä»¶ï¼Ÿ"
#: editor/import/resource_importer_scene.cpp
msgid "Saving..."
-msgstr "儲存中……"
+msgstr "正在ä¿å­˜..."
#: editor/import_dock.cpp
-#, fuzzy
msgid "%d Files"
-msgstr " 資料夾"
+msgstr "%d 個檔案"
#: editor/import_dock.cpp
msgid "Set as Default for '%s'"
-msgstr "設定為“%sâ€çš„é è¨­å€¼"
+msgstr "設為「%sã€çš„é è¨­"
#: editor/import_dock.cpp
msgid "Clear Default for '%s'"
-msgstr "清除“%sâ€çš„é è¨­å€¼"
+msgstr "清除「%sã€çš„é è¨­"
#: editor/import_dock.cpp
msgid "Import As:"
-msgstr "導入為:"
+msgstr "匯入為:"
#: editor/import_dock.cpp
-#, fuzzy
msgid "Preset"
-msgstr "é è¨­"
+msgstr "Preset"
#: editor/import_dock.cpp
msgid "Reimport"
-msgstr "é‡æ–°å°Žå…¥"
+msgstr "é‡æ–°åŒ¯å…¥"
#: editor/import_dock.cpp
-#, fuzzy
msgid "Save Scenes, Re-Import, and Restart"
-msgstr "ä¿å­˜å ´æ™¯ï¼Œé‡æ–°å°Žå…¥ä¸¦é‡æ–°å•Ÿå‹•"
+msgstr "ä¿å­˜å ´æ™¯ã€é‡æ–°åŒ¯å…¥ã€ä¸¦é‡æ–°å•Ÿå‹•"
#: editor/import_dock.cpp
msgid "Changing the type of an imported file requires editor restart."
-msgstr ""
+msgstr "修改匯入檔案的型別需è¦é‡æ–°å•Ÿå‹•ç·¨è¼¯å™¨ã€‚"
#: editor/import_dock.cpp
msgid ""
"WARNING: Assets exist that use this resource, they may stop loading properly."
-msgstr ""
+msgstr "警告:有素æ使用該資æºï¼Œå°‡æœƒç„¡æ³•æ­£ç¢ºåŠ è¼‰ã€‚"
#: editor/inspector_dock.cpp
msgid "Failed to load resource."
-msgstr "載入資æºå¤±æ•—。"
+msgstr "加載資æºå¤±æ•—。"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Expand All Properties"
msgstr "展開所有屬性"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Collapse All Properties"
-msgstr "展開所有屬性"
+msgstr "收åˆæ‰€æœ‰å±¬æ€§"
#: editor/inspector_dock.cpp editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/script_editor_plugin.cpp
msgid "Save As..."
-msgstr "å¦å­˜ç‚º..。"
+msgstr "å¦å­˜ç‚º..."
#: editor/inspector_dock.cpp
msgid "Copy Params"
msgstr "複製åƒæ•¸"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Edit Resource Clipboard"
-msgstr "資æºè·¯å¾‘"
+msgstr "編輯資æºå‰ªè²¼ç°¿"
#: editor/inspector_dock.cpp
msgid "Copy Resource"
@@ -4206,78 +3972,75 @@ msgstr "複製資æº"
#: editor/inspector_dock.cpp
msgid "Make Built-In"
-msgstr "內置"
+msgstr "轉為內建"
#: editor/inspector_dock.cpp
msgid "Make Sub-Resources Unique"
-msgstr "使å­è³‡æºå”¯ä¸€"
+msgstr "ç¨ç«‹åŒ–å­è³‡æº"
#: editor/inspector_dock.cpp
msgid "Open in Help"
-msgstr "在幫助界é¢ä¸­é–‹å•Ÿ"
+msgstr "在說明中開啟"
#: editor/inspector_dock.cpp
msgid "Create a new resource in memory and edit it."
-msgstr "在記憶體中創建一個新資æºä¸¦å°å…¶é€²è¡Œç·¨è¼¯ã€‚"
+msgstr "在記憶體中建立一個新的資æºå編輯。"
#: editor/inspector_dock.cpp
msgid "Load an existing resource from disk and edit it."
-msgstr "從ç£ç‰‡åŠ è¼‰ç¾æœ‰è³‡æºä¸¦å°å…¶é€²è¡Œç·¨è¼¯ã€‚"
+msgstr "從ç£ç¢Ÿä¸­è¼‰å…¥ç¾æœ‰çš„資æºä¸¦ç·¨è¼¯ã€‚"
#: editor/inspector_dock.cpp
msgid "Save the currently edited resource."
-msgstr "ä¿å­˜ç•¶å‰ç·¨è¼¯çš„資æºã€‚"
+msgstr "ä¿å­˜ç›®å‰ç·¨è¼¯çš„資æºã€‚"
#: editor/inspector_dock.cpp
msgid "Go to the previous edited object in history."
-msgstr "轉到歷å²è¨˜éŒ„中以å‰ç·¨è¼¯çš„å°è±¡ã€‚"
+msgstr "在歷å²è¨˜éŒ„中跳至上一個編輯的物件。"
#: editor/inspector_dock.cpp
msgid "Go to the next edited object in history."
-msgstr "轉到歷å²è¨˜éŒ„中的下一個編輯å°è±¡ã€‚"
+msgstr "在歷å²è¨˜éŒ„中跳至下一個編輯的物件。"
#: editor/inspector_dock.cpp
msgid "History of recently edited objects."
-msgstr "最近編輯å°è±¡çš„æ­·å²è¨˜éŒ„。"
+msgstr "最近編輯的物件歷å²è¨˜éŒ„。"
#: editor/inspector_dock.cpp
msgid "Object properties."
-msgstr "å°è±¡å†…容。"
+msgstr "物件屬性。"
#: editor/inspector_dock.cpp
-#, fuzzy
msgid "Filter properties"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "éŽæ¿¾å±¬æ€§"
#: editor/inspector_dock.cpp
msgid "Changes may be lost!"
-msgstr "更改å¯èƒ½æœƒä¸Ÿå¤±!"
+msgstr "改動å¯èƒ½æœƒéºå¤±ï¼"
#: editor/multi_node_edit.cpp
msgid "MultiNode Set"
-msgstr "多節點集"
+msgstr "多節點組"
#: editor/node_dock.cpp
-#, fuzzy
msgid "Select a single node to edit its signals and groups."
-msgstr "é¸æ“‡è¦ç·¨è¼¯è¨Šè™Ÿå’Œçµ„的節點。"
+msgstr "é¸æ“‡å–®ä¸€ç¯€é»žä»¥ç·¨è¼¯å…¶è¨Šè™Ÿèˆ‡ç¾¤çµ„。"
#: editor/plugin_config_dialog.cpp
msgid "Edit a Plugin"
-msgstr "編輯挿件"
+msgstr "編輯外掛"
#: editor/plugin_config_dialog.cpp
-#, fuzzy
msgid "Create a Plugin"
-msgstr "新增"
+msgstr "建立外掛"
#: editor/plugin_config_dialog.cpp
msgid "Plugin Name:"
-msgstr "挿件å稱:"
+msgstr "外掛å稱:"
#: editor/plugin_config_dialog.cpp
msgid "Subfolder:"
-msgstr "å­è³‡æ–™å¤¾:"
+msgstr "å­è³‡æ–™å¤¾ï¼š"
#: editor/plugin_config_dialog.cpp editor/script_create_dialog.cpp
msgid "Language:"
@@ -4293,16 +4056,14 @@ msgstr "ç¾åœ¨å•Ÿå‹•ï¼Ÿ"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Create Polygon"
-msgstr "新增資料夾"
+msgstr "新增多邊形"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Create points."
-msgstr "刪除"
+msgstr "建立頂點。"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid ""
@@ -4310,30 +4071,30 @@ msgid ""
"LMB: Move Point\n"
"RMB: Erase Point"
msgstr ""
+"編輯頂點。\n"
+"å·¦éµé»žæ“Šï¼šç§»å‹•é ‚點\n"
+"å³éµé»žæ“Šï¼šåˆªé™¤é ‚點"
#: editor/plugins/abstract_polygon_2d_editor.cpp
#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
msgid "Erase points."
-msgstr "所有的é¸æ“‡"
+msgstr "移除頂點。"
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Edit Polygon"
-msgstr "新增資料夾"
+msgstr "編輯多邊形"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid "Insert Point"
-msgstr "æ’入點"
+msgstr "æ’入頂點"
#: editor/plugins/abstract_polygon_2d_editor.cpp
msgid "Edit Polygon (Remove Point)"
-msgstr "編輯多邊形 (刪除點)"
+msgstr "編輯多邊形(移除頂點)"
#: editor/plugins/abstract_polygon_2d_editor.cpp
-#, fuzzy
msgid "Remove Polygon And Point"
-msgstr "移除"
+msgstr "移除多邊形與頂點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4341,56 +4102,51 @@ msgstr "移除"
#: editor/plugins/animation_state_machine_editor.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Add Animation"
-msgstr "添加動畫"
+msgstr "新增動畫"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Load..."
-msgstr "載入"
+msgstr "載入..."
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Move Node Point"
-msgstr "移除"
+msgstr "移動節點頂點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Change BlendSpace1D Limits"
-msgstr "更改 BlendSpace1D é™åˆ¶"
+msgstr "修改混åˆç©ºé–“ 1D é™åˆ¶"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Change BlendSpace1D Labels"
-msgstr "更改Blendspace1d標籤"
+msgstr "修改混åˆç©ºé–“ 1D 標籤"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_state_machine_editor.cpp
msgid "This type of node can't be used. Only root nodes are allowed."
-msgstr "無法使用此類型的節點。åªå…許根節點。"
+msgstr "無法使用該類型的節點。僅å…許根節點。"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Node Point"
-msgstr "移除"
+msgstr "新增節點頂點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Animation Point"
-msgstr "動畫空間。"
+msgstr "新增動畫頂點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
-#, fuzzy
msgid "Remove BlendSpace1D Point"
-msgstr "移除"
+msgstr "移除混åˆç©ºé–“ 1D 頂點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
msgid "Move BlendSpace1D Node Point"
-msgstr "移動 BlendSpace1D 節點點"
+msgstr "移動混åˆç©ºé–“ 1D 節點頂點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4400,23 +4156,23 @@ msgid ""
"AnimationTree is inactive.\n"
"Activate to enable playback, check node warnings if activation fails."
msgstr ""
-"動畫樹處於éžæ´»å‹•ç‹€æ…‹ã€‚\n"
-"激活以啟用播放, 如果啟動失敗, 請檢查節點警告。"
+"動畫樹未啟用。\n"
+"請先啟用以播放,若啟用失敗請檢查節點警告訊æ¯ã€‚"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Set the blending position within the space"
-msgstr "設置空間內的混åˆä½ç½®"
+msgstr "在此空間中設定混åˆä½ç½®"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Select and move points, create points with RMB."
-msgstr ""
+msgstr "é¸æ“‡èˆ‡ç§»å‹•é ‚點,使用滑鼠å³éµå»ºç«‹é ‚點。"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp
msgid "Enable snap and show grid."
-msgstr "啟用æ•æ‰ä¸¦é¡¯ç¤ºç¶²æ ¼ã€‚"
+msgstr "啟用å¸é™„並顯示網格。"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
@@ -4426,69 +4182,63 @@ msgstr "點"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Open Editor"
-msgstr "相ä¾æ€§ç·¨è¼¯å™¨"
+msgstr "開啟編輯器"
#: editor/plugins/animation_blend_space_1d_editor.cpp
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Open Animation Node"
-msgstr "最佳化動畫"
+msgstr "開啟動畫節點"
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Triangle already exists."
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "已存在三角形。"
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Add Triangle"
-msgstr "添加動畫軌"
+msgstr "新增三角形"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Change BlendSpace2D Limits"
-msgstr "更改Blendspace2dé™åˆ¶"
+msgstr "修改混åˆç©ºé–“ 2D é™åˆ¶"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Change BlendSpace2D Labels"
-msgstr "更改Blendspace2d標籤"
+msgstr "修改混åˆç©ºé–“ 2D 標籤"
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Remove BlendSpace2D Point"
-msgstr "移除"
+msgstr "移除混åˆç©ºé–“ 2D 頂點"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Remove BlendSpace2D Triangle"
-msgstr "删除Blendspace2d三角形"
+msgstr "移除混åˆç©ºé–“ 2D 三角形"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "BlendSpace2D does not belong to an AnimationTree node."
-msgstr "Blendspace2dä¸å±¬æ–¼AnimationTree節點。"
+msgstr "æ··åˆç©ºé–“ 2D ä¸å±¬æ–¼ä»»ä½•å‹•ç•«æ¨¹ç¯€é»žã€‚"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "No triangles exist, so no blending can take place."
-msgstr "ä¸å­˜åœ¨ä¸‰è§’å½¢, å› æ­¤ä¸èƒ½é€²è¡Œæ··åˆã€‚"
+msgstr "無三角形,將ä¸æœƒé€²è¡Œæ··åˆã€‚"
#: editor/plugins/animation_blend_space_2d_editor.cpp
-#, fuzzy
msgid "Toggle Auto Triangles"
-msgstr "切æ›æœ€æ„›"
+msgstr "é–‹å•Ÿï¼å–消自動三角形"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Create triangles by connecting points."
-msgstr "通éŽé€£æŽ¥é»žå‰µå»ºä¸‰è§’形。"
+msgstr "通éŽé€£æŽ¥é ‚點來建立三角形。"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Erase points and triangles."
-msgstr "删除點和三角形。"
+msgstr "刪除頂點與三角形。"
#: editor/plugins/animation_blend_space_2d_editor.cpp
msgid "Generate blend triangles automatically (instead of manually)"
-msgstr "自動生æˆæ··åˆä¸‰è§’å½¢ (而ä¸æ˜¯æ‰‹å‹•ç”Ÿæˆ)"
+msgstr "自動產生混åˆä¸‰è§’形(而éžæ‰‹å‹•ï¼‰"
#: editor/plugins/animation_blend_space_2d_editor.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -4496,131 +4246,116 @@ msgid "Blend:"
msgstr "æ··åˆï¼š"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Parameter Changed"
-msgstr "正在儲存變更..."
+msgstr "已更改åƒæ•¸"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
-#, fuzzy
msgid "Edit Filters"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "編輯篩é¸"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "Output node can't be added to the blend tree."
-msgstr "無法將輸出節點添加到混åˆæ¨¹ä¸­ã€‚"
+msgstr "輸出節點無法被新增到混åˆæ¨¹ã€‚"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "Add Node to BlendTree"
-msgstr "將節點添加到BlendTree"
+msgstr "新增節點至混åˆæ¨¹"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Node Moved"
-msgstr "節點å稱:"
+msgstr "已移動節點"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "Unable to connect, port may be in use or connection may be invalid."
-msgstr "無法連接,埠å¯èƒ½æ­£åœ¨ä½¿ç”¨ï¼Œæˆ–者連接å¯èƒ½ç„¡æ•ˆã€‚"
+msgstr "無法連線,該連接埠å¯èƒ½å·²è¢«ä½”用或連線無效。"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Nodes Connected"
-msgstr "連接..."
+msgstr "已連接節點"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Nodes Disconnected"
-msgstr "æ–·ç·š"
+msgstr "已斷開節點連接"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Set Animation"
-msgstr "動畫最佳化"
+msgstr "設定動畫"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Delete Node"
-msgstr "刪除"
+msgstr "刪除節點"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/scene_tree_dock.cpp
msgid "Delete Node(s)"
-msgstr ""
+msgstr "刪除節點"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Toggle Filter On/Off"
-msgstr "切æ›æœ€æ„›"
+msgstr "é–‹å•Ÿï¼é—œé–‰éŽæ¿¾"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Change Filter"
-msgstr "變更é¡é ­å°ºå¯¸"
+msgstr "更改éŽæ¿¾"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "No animation player set, so unable to retrieve track names."
-msgstr "沒有設定動畫播放機,囙此無法檢索曲目å稱。"
+msgstr "未設定動畫播放器,無法å–得軌é“å稱。"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
msgid "Player path set is invalid, so unable to retrieve track names."
-msgstr ""
+msgstr "播放器ä½ç½®ç„¡æ•ˆï¼Œç„¡æ³•å–得軌é“å稱。"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/root_motion_editor_plugin.cpp
msgid ""
"Animation player has no valid root node path, so unable to retrieve track "
"names."
-msgstr ""
+msgstr "動畫播放器的根節點ä½ç½®ç„¡æ•ˆï¼Œç„¡æ³•å–得軌é“å稱。"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Anim Clips"
-msgstr "動畫剪輯:"
+msgstr "動畫片段"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Audio Clips"
-msgstr "音訊剪輯:"
+msgstr "音訊片段"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Functions"
-msgstr "函數:"
+msgstr "函å¼"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Node Renamed"
-msgstr "節點å稱:"
+msgstr "å·²é‡æ–°å‘½å節點"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Add Node..."
-msgstr "添加節點..。"
+msgstr "新增節點..."
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
#: editor/plugins/root_motion_editor_plugin.cpp
-#, fuzzy
msgid "Edit Filtered Tracks:"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "編輯已篩é¸çš„軌é“:"
#: editor/plugins/animation_blend_tree_editor_plugin.cpp
-#, fuzzy
msgid "Enable Filtering"
msgstr "啟用篩é¸"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Toggle Autoplay"
-msgstr "切æ›è‡ªå‹•æ’­æ”¾"
+msgstr "é–‹å•Ÿï¼é—œé–‰è‡ªå‹•æ’­æ”¾"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "New Animation Name:"
-msgstr "æ–°å‹•ç•«å稱:"
+msgstr "新增動畫å稱:"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "New Anim"
@@ -4628,12 +4363,12 @@ msgstr "新增動畫"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Change Animation Name:"
-msgstr "更改動畫å稱:"
+msgstr "更改動畫å稱:"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Delete Animation?"
-msgstr "刪除動畫?"
+msgstr "是å¦åˆªé™¤å‹•ç•«ï¼Ÿ"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
@@ -4641,27 +4376,25 @@ msgid "Remove Animation"
msgstr "移除動畫"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Invalid animation name!"
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的動畫å稱ï¼"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Animation name already exists!"
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "å‹•ç•«å稱已存在ï¼"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Rename Animation"
-msgstr "é‡å‘½åå‹•ç•«"
+msgstr "é‡æ–°å‘½åå‹•ç•«"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Blend Next Changed"
-msgstr "æ··åˆä¸‹ä¸€å€‹æ›´æ”¹"
+msgstr "æ··åˆä¸‹ä¸€å€‹æ”¹å‹•"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Change Blend Time"
-msgstr "更改混åˆæ™‚é–“"
+msgstr "修改混åˆæ™‚é–“"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Load Animation"
@@ -4669,49 +4402,47 @@ msgstr "載入動畫"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Duplicate Animation"
-msgstr "複製動畫"
+msgstr "é‡è¤‡å‹•ç•«"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "No animation to copy!"
-msgstr "動畫空間。"
+msgstr "ç„¡å‹•ç•«å¯è¤‡è£½ï¼"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "No animation resource on clipboard!"
-msgstr "在資æºè·¯å¾‘中找ä¸åˆ°"
+msgstr "剪貼簿中沒有動畫資æºï¼"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Pasted Animation"
-msgstr "粘貼的動畫"
+msgstr "已貼上的動畫"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Paste Animation"
-msgstr "粘貼動畫"
+msgstr "貼上動畫"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "No animation to edit!"
-msgstr "沒有è¦ç·¨è¼¯çš„å‹•ç•«!"
+msgstr "ç„¡å‹•ç•«å¯ç·¨è¼¯ï¼"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Play selected animation backwards from current pos. (A)"
-msgstr "從當å‰ä½ç½®å‘後播放所é¸å‹•ç•«ã€‚(A)"
+msgstr "自目å‰ä½ç½®é–‹å§‹å€’放所é¸çš„動畫。 (A)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Play selected animation backwards from end. (Shift+A)"
-msgstr "從çµå°¾å‘後播放é¸å®šçš„動畫。(Shift+a)"
+msgstr "自çµå°¾å€’放所é¸å‹•ç•«ã€‚(Shift+A)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Stop animation playback. (S)"
-msgstr "åœæ­¢å‹•ç•«å›žæ”¾ã€‚(S)"
+msgstr "åœæ­¢æ’­æ”¾å‹•ç•«ã€‚(S)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Play selected animation from start. (Shift+D)"
-msgstr "從頭開始播放é¸å–中的動畫。(Shift+D)"
+msgstr "從頭播放所é¸å‹•ç•«ã€‚(Shift+D)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Play selected animation from current pos. (D)"
-msgstr "從當å‰ä½ç½®æ’­æ”¾é¸å®šçš„動畫。(D)"
+msgstr "自目å‰ä½ç½®é–‹å§‹æ’­æ”¾æ‰€é¸å‹•ç•«ã€‚(D)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Animation position (in seconds)."
@@ -4719,7 +4450,7 @@ msgstr "å‹•ç•«ä½ç½®ï¼ˆç§’)。"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Scale animation playback globally for the node."
-msgstr "在全域範åœå…§ç¸®æ”¾ç¯€é»žçš„動畫播放。"
+msgstr "為節點全域縮放動畫播放。"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Animation Tools"
@@ -4730,40 +4461,36 @@ msgid "Animation"
msgstr "å‹•ç•«"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Edit Transitions..."
-msgstr "轉場動畫"
+msgstr "編輯轉場..."
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Open in Inspector"
-msgstr "開啟資料夾"
+msgstr "在屬性é¢æ¿ä¸­é–‹å•Ÿ"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Display list of animations in player."
-msgstr "在播放機中顯示動畫清單。"
+msgstr "在播放器中顯示動畫列表。"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Autoplay on Load"
-msgstr "載入åŽè‡ªå‹•æ’­æ”¾"
+msgstr "載入後自動播放"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Enable Onion Skinning"
-msgstr "啟用洋葱皮"
+msgstr "啟用洋蔥皮化 (Onion Skinning)"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Onion Skinning Options"
-msgstr "洋葱皮"
+msgstr "洋蔥皮化é¸é …"
#: editor/plugins/animation_player_editor_plugin.cpp
-#, fuzzy
msgid "Directions"
-msgstr "æè¿°:"
+msgstr "æ–¹å‘"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Past"
-msgstr "è·³éŽ"
+msgstr "éŽåŽ»"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Future"
@@ -4775,39 +4502,39 @@ msgstr "深度"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "1 step"
-msgstr "1æ­¥"
+msgstr "1 æ­¥"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "2 steps"
-msgstr "2æ­¥"
+msgstr "2 æ­¥"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "3 steps"
-msgstr "3æ­¥"
+msgstr "3 æ­¥"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Differences Only"
-msgstr "僅差異"
+msgstr "僅顯示差異"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Force White Modulate"
-msgstr "強制白色調節"
+msgstr "強制使用白色調整"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Include Gizmos (3D)"
-msgstr "包括3D控制器"
+msgstr "åŒ…å« Gizmo (3D)"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Pin AnimationPlayer"
-msgstr ""
+msgstr "固定動畫播放器"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Create New Animation"
-msgstr "創建新動畫"
+msgstr "建立新動畫"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Animation Name:"
-msgstr "å‹•ç•«å稱:"
+msgstr "å‹•ç•«å稱:"
#: editor/plugins/animation_player_editor_plugin.cpp
#: editor/plugins/resource_preloader_editor_plugin.cpp
@@ -4818,35 +4545,32 @@ msgstr "錯誤ï¼"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Blend Times:"
-msgstr "æ··åˆæ™‚é–“:"
+msgstr "æ··åˆæ™‚間:"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Next (Auto Queue):"
-msgstr "下一個(自動隊列):"
+msgstr "下一個(自動佇列):"
#: editor/plugins/animation_player_editor_plugin.cpp
msgid "Cross-Animation Blend Times"
msgstr "跨動畫混åˆæ™‚é–“"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Move Node"
msgstr "移動節點"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Transition exists!"
-msgstr "轉場: "
+msgstr "轉場已存在ï¼"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Add Transition"
-msgstr "添加轉æ›"
+msgstr "新增轉場"
#: editor/plugins/animation_state_machine_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Node"
-msgstr "添加節點"
+msgstr "新增節點"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "End"
@@ -4862,7 +4586,7 @@ msgstr "åŒæ­¥"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "At End"
-msgstr "在末尾"
+msgstr "在çµå°¾"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Travel"
@@ -4870,26 +4594,23 @@ msgstr "行程"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Start and end nodes are needed for a sub-transition."
-msgstr ""
+msgstr "å­è½‰å ´å¿…é ˆè¦æœ‰é–‹å§‹èˆ‡çµæŸç¯€é»žã€‚"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "No playback resource set at path: %s."
-msgstr "在資æºè·¯å¾‘中找ä¸åˆ°"
+msgstr "路徑 %s 中沒有å¯æ’­æ”¾çš„資æºã€‚"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Node Removed"
msgstr "已刪除節點"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Transition Removed"
-msgstr "已刪除轉æ›"
+msgstr "已刪除轉場"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Set Start Node (Autoplay)"
-msgstr ""
+msgstr "設定開始節點(自動播放)"
#: editor/plugins/animation_state_machine_editor.cpp
msgid ""
@@ -4897,38 +4618,37 @@ msgid ""
"RMB to add new nodes.\n"
"Shift+LMB to create connections."
msgstr ""
+"é¸æ“‡èˆ‡ç§»å‹•ç¯€é»žã€‚\n"
+"å³éµé»žæ“Šä»¥æ–°å¢žç¯€é»žã€‚\n"
+"Shift+å·¦éµé»žæ“Šä»¥å»ºç«‹é€£æŽ¥ã€‚"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Create new nodes."
-msgstr "新增 %s"
+msgstr "建立新節點。"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Connect nodes."
-msgstr "連接..."
+msgstr "連接節點。"
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Remove selected node or transition."
-msgstr "移除é¸æ“‡çš„動畫軌。"
+msgstr "移除所é¸çš„節點或轉場。"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Toggle autoplay this animation on start, restart or seek to zero."
-msgstr ""
+msgstr "é–‹å•Ÿï¼é—œé–‰è©²å‹•ç•«åœ¨é–‹å§‹ã€é‡æ–°å•Ÿå‹•æˆ–尋覓至 0 時的自動播放。"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Set the end animation. This is useful for sub-transitions."
-msgstr ""
+msgstr "設定çµå°¾å‹•ç•«ã€‚å°æ–¼å­è½‰å ´å¾ˆæœ‰ç”¨ã€‚"
#: editor/plugins/animation_state_machine_editor.cpp
msgid "Transition: "
-msgstr "轉場: "
+msgstr "轉場: "
#: editor/plugins/animation_state_machine_editor.cpp
-#, fuzzy
msgid "Play Mode:"
-msgstr "平移模å¼"
+msgstr "播放模å¼ï¼š"
#: editor/plugins/animation_tree_editor_plugin.cpp
#: editor/plugins/animation_tree_player_editor_plugin.cpp
@@ -4937,16 +4657,16 @@ msgstr "動畫樹"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "New name:"
-msgstr "æ–°å稱:"
+msgstr "æ–°å稱:"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Scale:"
-msgstr "縮放:"
+msgstr "縮放:"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Fade In (s):"
-msgstr "淡入(秒):"
+msgstr "淡入(秒):"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Fade Out (s):"
@@ -4954,23 +4674,23 @@ msgstr "淡出(秒):"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend"
-msgstr "æ··åˆ"
+msgstr "æ··åˆ (Blend)"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Mix"
-msgstr "æ··åˆ"
+msgstr "æ··åˆ (Mix)"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Auto Restart:"
-msgstr "自動é‡æ–°é–‹å§‹:"
+msgstr "自動é‡æ–°é–‹å§‹ï¼š"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Restart (s):"
-msgstr "é‡æ–°é–‹å§‹(秒):"
+msgstr "é‡æ–°é–‹å§‹ï¼ˆç§’):"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Random Restart (s):"
-msgstr "隨機é‡æ–°é–‹å§‹(秒):"
+msgstr "隨機é‡æ–°é–‹å§‹ï¼ˆç§’):"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Start!"
@@ -4983,45 +4703,45 @@ msgstr "數é‡ï¼š"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend 0:"
-msgstr "æ··åˆ 0:"
+msgstr "æ··åˆ 0:"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend 1:"
-msgstr "æ··åˆ 1:"
+msgstr "æ··åˆ 1:"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "X-Fade Time (s):"
-msgstr ""
+msgstr "交å‰æ·¡åŒ– (X-Fade) 時間(秒):"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Current:"
-msgstr "當å‰ï¼š"
+msgstr "ç›®å‰ï¼š"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Input"
-msgstr "添加輸入"
+msgstr "新增輸入"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Clear Auto-Advance"
-msgstr "清除Auto-Advance"
+msgstr "清除自動 Advance"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Set Auto-Advance"
-msgstr "設定自動å‰é€²"
+msgstr "設定自動 Advance"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Delete Input"
-msgstr "刪除輸入事件"
+msgstr "刪除輸入"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Animation tree is valid."
-msgstr "動畫樹有效。"
+msgstr "有效動畫樹。"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Animation tree is invalid."
-msgstr "動畫樹無效。"
+msgstr "無效的動畫樹。"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Animation Node"
@@ -5037,23 +4757,23 @@ msgstr "æ··åˆç¯€é»ž"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend2 Node"
-msgstr "æ··åˆ2 節點"
+msgstr "æ··åˆ 2 節點"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend3 Node"
-msgstr "æ··åˆ3 節點"
+msgstr "æ··åˆ 3 節點"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Blend4 Node"
-msgstr "æ··åˆ4 節點"
+msgstr "æ··åˆ 4 節點"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "TimeScale Node"
-msgstr "時間尺度節點"
+msgstr "時間縮放節點"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "TimeSeek Node"
-msgstr "時間æœç´¢ç¯€é»ž"
+msgstr "時間尋覓節點"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Transition Node"
@@ -5061,123 +4781,115 @@ msgstr "轉場節點"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Import Animations..."
-msgstr "導入動畫…"
+msgstr "匯入動畫…"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Edit Node Filters"
-msgstr "編輯節點篩é¸"
+msgstr "編輯節點éŽæ¿¾"
#: editor/plugins/animation_tree_player_editor_plugin.cpp
msgid "Filters..."
-msgstr "篩é¸â€¦"
+msgstr "éŽæ¿¾..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Contents:"
msgstr "內容:"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "View Files"
-msgstr "查看檔案"
+msgstr "檢視檔案"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Connection error, please try again."
-msgstr "連接錯誤, è«‹é‡è©¦ã€‚"
+msgstr "連線錯誤,請é‡è©¦ã€‚"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't connect to host:"
-msgstr "無法連接到主機:"
+msgstr "無法連線至主機:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "No response from host:"
-msgstr "主機沒有響應:"
+msgstr "主機沒有回應:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Can't resolve hostname:"
-msgstr "無法解æžä¸»æ©Ÿå稱:"
+msgstr "無法解æžä¸»æ©Ÿå稱:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Request failed, return code:"
-msgstr "請求失敗, 返回代碼:"
+msgstr "請求失敗,回傳代碼:"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Request failed."
-msgstr "請求失敗."
+msgstr "請求失敗。"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Cannot save response to:"
-msgstr "無法將主題ä¿å­˜åˆ°æª”案:"
+msgstr "無法ä¿å­˜å›žè¦†è‡³ï¼š"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Write error."
-msgstr ""
+msgstr "寫入錯誤。"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Request failed, too many redirects"
-msgstr "請求失敗, é‡å®šå‘次數太多"
+msgstr "請求失敗,éŽå¤šé‡æ–°å°Žå‘"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Redirect loop."
-msgstr "é‡æ–°å®šå‘循環."
+msgstr "é‡æ–°å°Žå‘循環。"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Request failed, timeout"
-msgstr "請求失敗, 返回代碼:"
+msgstr "請求失敗,逾時"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Timeout."
-msgstr "時間"
+msgstr "逾時。"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Bad download hash, assuming file has been tampered with."
-msgstr ""
+msgstr "下載雜湊錯誤,檔案å¯èƒ½è¢«ç¯¡æ”¹ã€‚"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Expected:"
-msgstr "é æœŸï¼š"
+msgstr "é è¨ˆï¼š"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Got:"
-msgstr "ç²å¾—:"
+msgstr "ç²å¾—:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Failed sha256 hash check"
-msgstr "sha256哈希值檢查失敗"
+msgstr "SHA-256 雜湊檢查失敗"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Asset Download Error:"
-msgstr "資æºä¸‹è¼‰éŒ¯èª¤:"
+msgstr "ç´ æ下載錯誤:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Downloading (%s / %s)..."
msgstr "正在下載 (%s / %s)…"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Downloading..."
-msgstr "正在下載……"
+msgstr "正在下載..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Resolving..."
-msgstr "解æžä¸­â€¦"
+msgstr "正在解æž..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Error making request"
-msgstr "請求時發生錯誤"
+msgstr "建立請求時發生錯誤"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Idle"
-msgstr "空閒"
+msgstr "待命"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Install..."
-msgstr "安è£"
+msgstr "安è£..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Retry"
@@ -5189,46 +4901,43 @@ msgstr "下載錯誤"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Download for this asset is already in progress!"
-msgstr "此資æºæ–‡æª”正在下載中!"
+msgstr "該素æ已在下載中ï¼"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Recently Updated"
-msgstr ""
+msgstr "最近更新"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Least Recently Updated"
-msgstr ""
+msgstr "最近更新(倒åºï¼‰"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Name (A-Z)"
-msgstr ""
+msgstr "å稱(A-Z)"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Name (Z-A)"
-msgstr ""
+msgstr "å稱(Z-A)"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "License (A-Z)"
-msgstr "授權"
+msgstr "授權(A-Z)"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "License (Z-A)"
-msgstr "授權"
+msgstr "授權(Z-A)"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "First"
-msgstr "第一項"
+msgstr "首é "
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Previous"
-msgstr "上個分é "
+msgstr "上一é "
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Next"
-msgstr "下一個"
+msgstr "下一é "
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Last"
@@ -5240,35 +4949,32 @@ msgstr "全部"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "No results for \"%s\"."
-msgstr ""
+msgstr "無「%sã€ç›¸é—œçš„çµæžœã€‚"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Import..."
-msgstr "å°Žå…¥"
+msgstr "匯入..."
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Plugins..."
-msgstr "挿件"
+msgstr "外掛..."
#: editor/plugins/asset_library_editor_plugin.cpp editor/project_manager.cpp
msgid "Sort:"
-msgstr "排åº:"
+msgstr "排åºï¼š"
#: editor/plugins/asset_library_editor_plugin.cpp
#: editor/project_settings_editor.cpp
msgid "Category:"
-msgstr "類別:"
+msgstr "分類:"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Site:"
-msgstr "地å€:"
+msgstr "網站:"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Support"
-msgstr "支æŒâ€¦"
+msgstr "支æ´"
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Official"
@@ -5279,13 +4985,12 @@ msgid "Testing"
msgstr "測試"
#: editor/plugins/asset_library_editor_plugin.cpp
-#, fuzzy
msgid "Loading..."
-msgstr "載入"
+msgstr "正在載入..."
#: editor/plugins/asset_library_editor_plugin.cpp
msgid "Assets ZIP File"
-msgstr "ZIP資æºåŒ…"
+msgstr "ç´ æ ZIP 檔"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
msgid ""
@@ -5293,21 +4998,23 @@ msgid ""
"Save your scene (for images to be saved in the same dir), or pick a save "
"path from the BakedLightmap properties."
msgstr ""
+"無法判斷光照圖的ä¿å­˜è·¯å¾‘。\n"
+"請將場景ä¿å­˜ï¼ˆåœ–片將ä¿å­˜æ–¼ç›¸åŒè³‡æ–™å¤¾ï¼‰ï¼Œæˆ–是在 BackedLightmap 屬性內é¸æ“‡ä¸€å€‹"
+"ä¿å­˜è·¯å¾‘。"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
-#, fuzzy
msgid ""
"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake "
"Light' flag is on."
-msgstr "沒有å¯ä¾›æ¸²æŸ“çš„Meshes,請確ä¿Mesh包å«UV2通é“並且勾é¸'Bake Light'é¸é …"
+msgstr "æ²’æœ‰å¯ Bake 的網格。請確ä¿ç¶²æ ¼åŒ…å« UV2 通é“並已開啟「Bake 光照ã€æ——標。"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
msgid "Failed creating lightmap images, make sure path is writable."
-msgstr "創建光圖圖åƒå¤±æ•—, 請確ä¿è·¯å¾‘是å¯å¯«çš„。"
+msgstr "建立光照圖失敗,請確ä¿è©²è·¯å¾‘å¯å¯«å…¥ã€‚"
#: editor/plugins/baked_lightmap_editor_plugin.cpp
msgid "Bake Lightmaps"
-msgstr "渲染光圖"
+msgstr "Bake 光照圖"
#: editor/plugins/camera_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp editor/rename_dialog.cpp
@@ -5316,81 +5023,71 @@ msgstr "é è¦½"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Configure Snap"
-msgstr "é…ç½®å¸é™„"
+msgstr "設定å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Grid Offset:"
-msgstr "網格å移é‡:"
+msgstr "網格å移é‡ï¼š"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Grid Step:"
-msgstr "網格大å°:"
+msgstr "網格大å°ï¼š"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Primary Line Every:"
-msgstr ""
+msgstr "主è¦ç·šæ¢é–“隔:"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "steps"
-msgstr "2æ­¥"
+msgstr "步長"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation Offset:"
-msgstr "旋轉å移é‡:"
+msgstr "旋轉å移é‡ï¼š"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation Step:"
-msgstr "旋轉步驟:"
+msgstr "旋轉步長:"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Scale Step:"
-msgstr "縮放:"
+msgstr "縮放步長:"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Move Vertical Guide"
-msgstr "垂直移動尺標"
+msgstr "移動垂直åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Create Vertical Guide"
-msgstr "創建新的垂直尺標"
+msgstr "建立垂直åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Remove Vertical Guide"
-msgstr "刪除垂直尺標"
+msgstr "移除垂直åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Move Horizontal Guide"
-msgstr "移動水平尺標"
+msgstr "移動水平åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Create Horizontal Guide"
-msgstr "創建新的水平尺標"
+msgstr "建立水平åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Remove Horizontal Guide"
-msgstr "移除水平尺標"
+msgstr "移除水平åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Create Horizontal and Vertical Guides"
-msgstr "創建新的水平和垂直尺標"
+msgstr "建立水平與垂直åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Move pivot"
-msgstr "移動樞軸"
+msgstr "移動軸心"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotate CanvasItem"
-msgstr "旋轉CanvasItem"
+msgstr "旋轉畫布項目"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Move anchor"
@@ -5398,112 +5095,99 @@ msgstr "移動錨點"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Resize CanvasItem"
-msgstr "調整CanvasItem的大å°"
+msgstr "調整畫布項目大å°"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Scale CanvasItem"
-msgstr "縮放CanvasItem"
+msgstr "縮放畫布項目"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Move CanvasItem"
-msgstr "移動CanvasItem"
+msgstr "移動畫布項目"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid ""
"Children of containers have their anchors and margins values overridden by "
"their parent."
-msgstr "容器的å­ç´šçš„錨定值和é é‚Šè·å€¼è¢«å…¶çˆ¶ç´šè¦†è“‹ã€‚"
+msgstr "容器å­é …ç›®çš„éŒ¨é»žèˆ‡å¤–é‚Šè· (margin) 值被其æ¯é …目複寫。"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Presets for the anchors and margins values of a Control node."
-msgstr ""
+msgstr "控制節點的錨點與外邊è·çš„ Preset。"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid ""
"When active, moving Control nodes changes their anchors instead of their "
"margins."
-msgstr ""
+msgstr "啟用時,移動控制節點將修改錨點而éžå¤–é‚Šè·ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Top Left"
-msgstr "å·¦"
+msgstr "左上"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Top Right"
-msgstr "å³"
+msgstr "å³ä¸Š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Bottom Right"
-msgstr "å‘å³æ—‹è½‰"
+msgstr "å³ä¸‹"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Bottom Left"
-msgstr "底部視圖"
+msgstr "左下"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Center Left"
-msgstr "å‘左縮進"
+msgstr "中左"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Center Top"
-msgstr "居中é¸æ“‡"
+msgstr "中上"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Center Right"
-msgstr "å‘å³ç¸®é€²"
+msgstr "中å³"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Center Bottom"
-msgstr "底部"
+msgstr "中下"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Center"
-msgstr ""
+msgstr "中央"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Left Wide"
-msgstr "左視圖"
+msgstr "左延長"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Top Wide"
-msgstr "俯視圖"
+msgstr "上延長"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Right Wide"
-msgstr "å³è¦–圖"
+msgstr "å³å»¶é•·"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Bottom Wide"
-msgstr "底部視圖"
+msgstr "下延長"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "VCenter Wide"
-msgstr ""
+msgstr "垂直中央延長"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "HCenter Wide"
-msgstr ""
+msgstr "水平中央延長"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Full Rect"
-msgstr ""
+msgstr "全矩形"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Keep Ratio"
-msgstr "縮放比例:"
+msgstr "ä¿æŒæ¯”例"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Anchors only"
@@ -5511,11 +5195,11 @@ msgstr "僅é™éŒ¨é»ž"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Change Anchors and Margins"
-msgstr "改變錨點和邊è·"
+msgstr "修改錨點與外邊è·"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Change Anchors"
-msgstr "改變錨點"
+msgstr "修改錨點"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5523,6 +5207,8 @@ msgid ""
"Game Camera Override\n"
"Overrides game camera with editor viewport camera."
msgstr ""
+"éŠæˆ²ç›¸æ©Ÿè¦†è“‹\n"
+"以檢視å€ç›¸æ©Ÿå–代éŠæˆ²ç›¸æ©Ÿã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5530,69 +5216,64 @@ msgid ""
"Game Camera Override\n"
"No game instance running."
msgstr ""
+"éŠæˆ²ç›¸æ©Ÿè¦†è“‹\n"
+"無正在執行的éŠæˆ²å¯¦é«”。"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Lock Selected"
-msgstr "工具é¸æ“‡"
+msgstr "鎖定所é¸"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Unlock Selected"
-msgstr "工具é¸æ“‡"
+msgstr "å–消鎖定所é¸"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Group Selected"
-msgstr "複製é¸æ“‡"
+msgstr "為所é¸çš„項目建立群組"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Ungroup Selected"
-msgstr "複製é¸æ“‡"
+msgstr "移除所é¸é …目的群組"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Paste Pose"
-msgstr "粘貼姿勢"
+msgstr "貼上姿勢"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Clear Guides"
-msgstr "清除姿勢"
+msgstr "清除åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Create Custom Bone(s) from Node(s)"
-msgstr "從節點製作自定義骨骼"
+msgstr "å­ç¯€é»žå»ºç«‹è‡ªå®šéª¨éª¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Clear Bones"
-msgstr "清除姿勢"
+msgstr "清除骨骼"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Make IK Chain"
-msgstr "製作IKéˆ"
+msgstr "建立 IK éˆ"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Clear IK Chain"
-msgstr "清除IKéˆ"
+msgstr "清除 IK éˆ"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid ""
"Warning: Children of a container get their position and size determined only "
"by their parent."
-msgstr "警告:容器的å­ç´šåªèƒ½ç”±å…¶çˆ¶ç´šç¢ºå®šå…¶ä½ç½®å’Œå¤§å°ã€‚"
+msgstr "警告:容器的å­é …目的ä½ç½®èˆ‡å¤§å°æœ‰å…¶æ¯é …目決定。"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/texture_region_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp scene/gui/graph_edit.cpp
msgid "Zoom Reset"
-msgstr "é‡ç½®ç¸®æ”¾"
+msgstr "é‡è¨­ç¸®æ”¾"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5601,19 +5282,19 @@ msgstr "é¸æ“‡æ¨¡å¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Drag: Rotate"
-msgstr "拖動: 旋轉"
+msgstr "拖移:旋轉"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Alt+Drag: Move"
-msgstr "Alt+Drag:移動"
+msgstr "Alt+拖移:移動"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving)."
-msgstr "按 \"v\" 更改樞軸, \"Shift + v\" 以拖動樞軸 (移動時)。"
+msgstr "按「vã€ä»¥ä¿®æ”¹æ¨žç´ï¼Œã€ŒShift+vã€ä»¥ç§»å‹•æ¨žç´ï¼ˆç§»å‹•æ™‚)。"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Alt+RMB: Depth list selection"
-msgstr "Alt+滑鼠å³éµ:顯示鼠標點擊ä½ç½®ä¸‹æ‰€æœ‰çš„節點清單"
+msgstr "Alt+滑鼠å³éµï¼šå±•é–‹æ‰€é¸æ¸…å–®"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
@@ -5627,7 +5308,6 @@ msgstr "旋轉模å¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Scale Mode"
msgstr "縮放模å¼"
@@ -5636,129 +5316,112 @@ msgstr "縮放模å¼"
msgid ""
"Show a list of all objects at the position clicked\n"
"(same as Alt+RMB in select mode)."
-msgstr "在按一下的ä½ç½®é¡¯ç¤ºæ‰€æœ‰ç‰©ä»¶çš„清單 (在é¸æ“‡æ¨¡å¼ä¸‹èˆ‡ Alt + RMB 相åŒ)。"
+msgstr ""
+"顯示該點擊ä½ç½®æ‰€æœ‰ç‰©ä»¶çš„列表\n"
+"(åŒé¸æ“‡æ¨¡å¼ä¸­çš„ Alt+滑鼠å³éµï¼‰ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Click to change object's rotation pivot."
-msgstr "點擊以更改物件的旋轉樞軸。"
+msgstr "點擊以更改物件的旋轉樞ç´ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Pan Mode"
msgstr "平移模å¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Ruler Mode"
-msgstr "縮放模å¼"
+msgstr "å°ºè¦æ¨¡å¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Toggle smart snapping."
-msgstr "切æ›å¸é™„。"
+msgstr "é–‹å•Ÿï¼é—œé–‰æ™ºæ…§åž‹å¸é™„。"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Use Smart Snap"
-msgstr "使用å¸é™„"
+msgstr "使用智慧型å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Toggle grid snapping."
-msgstr "切æ›å¸é™„。"
+msgstr "é–‹å•Ÿï¼é—œé–‰ç¶²æ ¼å¸é™„。"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Use Grid Snap"
-msgstr "網格å¸é™„"
+msgstr "使用網格å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Snapping Options"
msgstr "å¸é™„é¸é …"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Use Rotation Snap"
msgstr "使用旋轉å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Use Scale Snap"
-msgstr "使用å¸é™„"
+msgstr "使用縮放å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap Relative"
msgstr "相å°å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Use Pixel Snap"
msgstr "使用åƒç´ å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Smart Snapping"
-msgstr "智慧å¸é™„"
+msgstr "智慧型å¸é™„"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Configure Snap..."
-msgstr "é…ç½®å¸é™„…"
+msgstr "設定å¸é™„..."
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap to Parent"
-msgstr "å¸é™„到父級節點"
+msgstr "å¸é™„至æ¯ç´š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap to Node Anchor"
-msgstr "å¸é™„到節點的錨點"
+msgstr "å¸é™„至節點錨點"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap to Node Sides"
-msgstr "æ•æ‰åˆ°ç¯€é»žé‚Š"
+msgstr "å¸é™„至節點å´é‚Š"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap to Node Center"
-msgstr "å¸é™„到節點的中心"
+msgstr "å¸é™„至節點中央"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap to Other Nodes"
-msgstr "å¸é™„到其他的節點"
+msgstr "å¸é™„至其他節點"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Snap to Guides"
-msgstr "å¸é™„到尺標"
+msgstr "å¸é™„至åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Lock the selected object in place (can't be moved)."
-msgstr "將所é¸ç‰©ä»¶éŽ–定到中心 (無法移動)。"
+msgstr "在其ä½ç½®ä¸ŠéŽ–定所é¸ç‰©ä»¶ï¼ˆç„¡æ³•ç§»å‹•ï¼‰ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Unlock the selected object (can be moved)."
-msgstr "解鎖所é¸ç‰©ä»¶ (å¯ä»¥ç§»å‹•)。"
+msgstr "解鎖所é¸ç‰©ä»¶ï¼ˆå¯ç§»å‹•ï¼‰ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Makes sure the object's children are not selectable."
-msgstr "確ä¿å°è±¡çš„å­ç´šä¸å¯é¸ã€‚"
+msgstr "確ä¿ç‰©ä»¶çš„å­ç´šé …目無法被é¸æ“‡ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Restores the object's children's ability to be selected."
-msgstr "æ¢å¾©å°è±¡çš„å­ç´šé¸æ“‡èƒ½åŠ›ã€‚"
+msgstr "æ¢å¾©è®“物件的å­ç´šé …ç›®å¯é¸æ“‡ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Skeleton Options"
msgstr "骨架é¸é …"
@@ -5768,7 +5431,7 @@ msgstr "顯示骨骼"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Make Custom Bone(s) from Node(s)"
-msgstr "從節點製作自定義骨骼"
+msgstr "自節點建立自定骨骼"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Clear Custom Bones"
@@ -5777,16 +5440,15 @@ msgstr "清除自定義骨骼"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View"
-msgstr "視圖"
+msgstr "檢視"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Always Show Grid"
-msgstr "顯示網格"
+msgstr "æ°¸é é¡¯ç¤ºç¶²æ ¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Helpers"
-msgstr "顯示輔助線"
+msgstr "顯示輔助資訊"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Rulers"
@@ -5794,7 +5456,7 @@ msgstr "顯示尺è¦"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Guides"
-msgstr "顯示引導"
+msgstr "顯示åƒè€ƒç·š"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Origin"
@@ -5802,40 +5464,39 @@ msgstr "顯示原點"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Viewport"
-msgstr "顯示視å£"
+msgstr "顯示檢視å€"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Show Group And Lock Icons"
-msgstr "顯示組和鎖定圖標"
+msgstr "顯示群組與鎖定圖示"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Center Selection"
-msgstr "居中é¸æ“‡"
+msgstr "置中所é¸"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Frame Selection"
-msgstr "å¹€é¸æ“‡"
+msgstr "完整顯示所é¸"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Preview Canvas Scale"
-msgstr ""
+msgstr "é è¦½ç•«å¸ƒæ¯”例"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Translation mask for inserting keys."
-msgstr ""
+msgstr "轉æ›é®ç½©ä»¥æ’入關éµå½±æ ¼ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Rotation mask for inserting keys."
-msgstr ""
+msgstr "旋轉é®ç½©ä»¥æ’入關éµå½±æ ¼ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Scale mask for inserting keys."
-msgstr ""
+msgstr "縮放é®ç½©ä»¥æ’入關éµå½±æ ¼ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Insert keys (based on mask)."
-msgstr "æ’入幀 (ç¾æœ‰è»Œé“)"
+msgstr "(基於é®ç½©ï¼‰æ’入關éµå½±æ ¼ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid ""
@@ -5844,20 +5505,21 @@ msgid ""
"Keys are only added to existing tracks, no new tracks will be created.\n"
"Keys must be inserted manually for the first time."
msgstr ""
+"檔物件被轉æ›ã€æ—‹è½‰ã€æˆ–(基於é®ç½©ï¼‰ç¸®æ”¾æ™‚自動æ’入關éµå½±æ ¼ã€‚\n"
+"é—œéµå½±æ ¼åªæœƒè¢«æ–°å¢žè‡³ç¾å­˜çš„軌é“,將ä¸æœƒå»ºç«‹æ–°çš„軌é“。\n"
+"第一次必須先手動æ’入關éµå½±æ ¼ã€‚"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Auto Insert Key"
-msgstr "新增關éµç•«æ ¼"
+msgstr "自動æ’入關éµå½±æ ¼"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Animation Key and Pose Options"
-msgstr "動畫長度(秒)"
+msgstr "å‹•ç•«é—œéµå½±æ ¼èˆ‡å§¿å‹¢é¸é …"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Insert Key (Existing Tracks)"
-msgstr "æ’入幀 (ç¾æœ‰è»Œé“)"
+msgstr "æ’入關éµå½±æ ¼ï¼ˆåœ¨ç¾æœ‰è»Œé“)"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Copy Pose"
@@ -5869,53 +5531,53 @@ msgstr "清除姿勢"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Multiply grid step by 2"
-msgstr "將網格步數乘以2"
+msgstr "將網格步數乘以 2"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Divide grid step by 2"
-msgstr "將網格步數除以2"
+msgstr "將網格步數除以 2"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Pan View"
-msgstr "後視圖"
+msgstr "平移檢視"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Add %s"
-msgstr "添加 %s"
+msgstr "新增 %"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Adding %s..."
-msgstr "添加 %s…"
+msgstr "正在新增 %s…"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid "Cannot instantiate multiple nodes without root."
-msgstr "無法具ç¾åŒ–沒有根的多個節點。"
+msgstr "沒有根節點無法實體化多個節點。"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "Create Node"
-msgstr "創建節點"
+msgstr "建立節點"
#: editor/plugins/canvas_item_editor_plugin.cpp
#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "Error instancing scene from %s"
-msgstr "%s 中的具ç¾åŒ–場景出錯"
+msgstr "自 %s 實體化場景時發生錯誤"
#: editor/plugins/canvas_item_editor_plugin.cpp
-#, fuzzy
msgid "Change Default Type"
-msgstr "更改é è¨­é¡žåž‹"
+msgstr "更改é è¨­åž‹åˆ¥"
#: editor/plugins/canvas_item_editor_plugin.cpp
msgid ""
"Drag & drop + Shift : Add node as sibling\n"
"Drag & drop + Alt : Change node type"
msgstr ""
+"拖放 + Shift:新增åŒç´šç¯€é»ž\n"
+"拖放 + Alt:修改節點型別"
#: editor/plugins/collision_polygon_editor_plugin.cpp
msgid "Create Polygon3D"
-msgstr "創建3D多邊形"
+msgstr "建立多邊形 3D"
#: editor/plugins/collision_polygon_editor_plugin.cpp
msgid "Edit Poly"
@@ -5923,29 +5585,28 @@ msgstr "編輯多邊形"
#: editor/plugins/collision_polygon_editor_plugin.cpp
msgid "Edit Poly (Remove Point)"
-msgstr "編輯多邊形 (刪除頂點)"
+msgstr "編輯多邊形(移除頂點)"
#: editor/plugins/collision_shape_2d_editor_plugin.cpp
msgid "Set Handle"
-msgstr "設置控制程åº"
+msgstr "設定處ç†ç¨‹å¼"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Load Emission Mask"
-msgstr ""
+msgstr "載入發射é®ç½©"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/cpu_particles_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
msgid "Restart"
-msgstr "é‡æ–°é–‹å§‹(秒):"
+msgstr "é‡æ–°å•Ÿå‹•"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Clear Emission Mask"
-msgstr ""
+msgstr "清除發射é®ç½©"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
@@ -5956,141 +5617,131 @@ msgstr "ç²’å­"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Generated Point Count:"
-msgstr ""
+msgstr "已產生的頂點數é‡ï¼š"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Emission Mask"
-msgstr ""
+msgstr "發射é®ç½©"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
-#, fuzzy
msgid "Solid Pixels"
-msgstr "擴展(åƒç´ ï¼‰: "
+msgstr "實體åƒç´ "
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Border Pixels"
-msgstr ""
+msgstr "é‚Šç•Œåƒç´ "
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
-#, fuzzy
msgid "Directed Border Pixels"
-msgstr "資料夾 & 檔案:"
+msgstr "有å‘é‚Šç•Œåƒç´ "
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Capture from Pixel"
-msgstr ""
+msgstr "自åƒç´ ä¸­æ•æ‰"
#: editor/plugins/cpu_particles_2d_editor_plugin.cpp
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Emission Colors"
-msgstr ""
+msgstr "發射色彩"
#: editor/plugins/cpu_particles_editor_plugin.cpp
msgid "CPUParticles"
-msgstr "CPUç²’å­"
+msgstr "CPUParticles"
#: editor/plugins/cpu_particles_editor_plugin.cpp
#: editor/plugins/particles_editor_plugin.cpp
msgid "Create Emission Points From Mesh"
-msgstr "從網格創建發射點"
+msgstr "自網格建立發射點"
#: editor/plugins/cpu_particles_editor_plugin.cpp
#: editor/plugins/particles_editor_plugin.cpp
msgid "Create Emission Points From Node"
-msgstr "從節點創建發射點"
+msgstr "自節點建立發射點"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Flat 0"
-msgstr "å¹³é¢0"
+msgstr "Flat 0"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Flat 1"
-msgstr "å¹³é¢1"
+msgstr "Flat 1"
#: editor/plugins/curve_editor_plugin.cpp editor/property_editor.cpp
msgid "Ease In"
-msgstr ""
+msgstr "ç·©å…¥"
#: editor/plugins/curve_editor_plugin.cpp editor/property_editor.cpp
msgid "Ease Out"
-msgstr ""
+msgstr "緩出"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Smoothstep"
-msgstr "平滑步長"
+msgstr "平滑æ’值"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Modify Curve Point"
-msgstr "修改曲線點"
+msgstr "修改曲線控制點"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Modify Curve Tangent"
-msgstr "修改曲線切角"
+msgstr "修改曲線切線"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Load Curve Preset"
-msgstr "加載曲線é è¨­"
+msgstr "加載曲線 Preset"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Add Point"
-msgstr "添加點"
+msgstr "新增控制點"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Remove Point"
-msgstr "刪除點"
+msgstr "移除控制點"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Left Linear"
msgstr "左線性"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Right Linear"
msgstr "å³ç·šæ€§"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Load Preset"
-msgstr "載入é è¨­"
+msgstr "載入 Preset"
#: editor/plugins/curve_editor_plugin.cpp
-#, fuzzy
msgid "Remove Curve Point"
-msgstr "刪除曲線點"
+msgstr "移除曲線控制點"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Toggle Curve Linear Tangent"
-msgstr "切æ›æ›²ç·šç›´ç·šåˆ‡ç·š"
+msgstr "é–‹å•Ÿï¼é—œé–‰æ›²ç·šç·šæ€§åˆ‡ç·š"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Hold Shift to edit tangents individually"
-msgstr "æŒ‰ä½ Shift éµå¯å–®ç¨ç·¨è¼¯åˆ‡ç·š"
+msgstr "æŒ‰ä½ Shift éµä»¥å–®ç¨ç·¨è¼¯åˆ‡ç·š"
#: editor/plugins/curve_editor_plugin.cpp
msgid "Right click to add point"
-msgstr ""
+msgstr "å³éµé»žæ“Šä»¥æ–°å¢žæŽ§åˆ¶é»ž"
#: editor/plugins/gi_probe_editor_plugin.cpp
msgid "Bake GI Probe"
-msgstr "渲染 GI Probe"
+msgstr "Bake GI 探é‡"
#: editor/plugins/gradient_editor_plugin.cpp
msgid "Gradient Edited"
-msgstr "漸變編輯"
+msgstr "漸層編輯"
#: editor/plugins/item_list_editor_plugin.cpp
msgid "Item %d"
-msgstr "é …ç›® %d"
+msgstr "第 %d 項"
#: editor/plugins/item_list_editor_plugin.cpp
msgid "Items"
@@ -6098,100 +5749,95 @@ msgstr "é …ç›®"
#: editor/plugins/item_list_editor_plugin.cpp
msgid "Item List Editor"
-msgstr "項目清單編輯器"
+msgstr "項目列表編輯器"
#: editor/plugins/light_occluder_2d_editor_plugin.cpp
msgid "Create Occluder Polygon"
-msgstr "創建é®å…‰å¤šé‚Šå½¢"
+msgstr "建立é®å…‰å¤šé‚Šå½¢"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Mesh is empty!"
-msgstr "網格是空的ï¼"
+msgstr "空網格ï¼"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Couldn't create a Trimesh collision shape."
-msgstr "無法新增資料夾."
+msgstr "無法建立三角網格碰撞形狀。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Static Trimesh Body"
-msgstr ""
+msgstr "建立éœæ…‹ä¸‰è§’網格形體"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "This doesn't work on scene root!"
-msgstr "這å°å ´æ™¯æ ¹ç›®éŒ„ä¸èµ·ä½œç”¨ï¼"
+msgstr "無法用於場景根節點ï¼"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Trimesh Static Shape"
-msgstr "創建凸形éœæ…‹é«”"
+msgstr "建立三角網格éœæ…‹å½¢ç‹€"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Can't create a single convex collision shape for the scene root."
-msgstr ""
+msgstr "無法為該場景根節點建立單一凸碰撞形狀。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Couldn't create a single convex collision shape."
-msgstr ""
+msgstr "無法建立單一凸碰撞形狀。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Single Convex Shape"
-msgstr "創建凸é¢å½¢ç‹€"
+msgstr "建立單一凸é¢å½¢ç‹€"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Can't create multiple convex collision shapes for the scene root."
-msgstr ""
+msgstr "無法為場景根節點建立多個凸碰撞形狀。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Couldn't create any collision shapes."
-msgstr "無法新增資料夾."
+msgstr "無法建立任何碰撞形狀。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Multiple Convex Shapes"
-msgstr "創建凸é¢å½¢ç‹€"
+msgstr "建立多個凸é¢å½¢ç‹€"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Navigation Mesh"
-msgstr "創建導航網格"
+msgstr "建立導航網格"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Contained Mesh is not of type ArrayMesh."
-msgstr "包å«çš„網格ä¸æ˜¯ArrayMesh類型。"
+msgstr "包å«çš„網格的型別ä¸æ˜¯é™£åˆ—網格 (ArrayMesh)。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "UV Unwrap failed, mesh may not be manifold?"
-msgstr ""
+msgstr "UV 展開失敗,該網格å¯èƒ½ä¸¦éžæµå½¢ï¼Ÿ"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "No mesh to debug."
-msgstr "沒有è¦èª¿è©¦çš„網格。"
+msgstr "沒有å¯é™¤éŒ¯çš„網格。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Model has no UV in this layer"
-msgstr ""
+msgstr "模型在該圖層上無 UV"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "MeshInstance lacks a Mesh!"
-msgstr "網格實例缺少網格ï¼"
+msgstr "網格實體 (MeshInstance) 缺ä¹ç¶²æ ¼ï¼"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Mesh has not surface to create outlines from!"
-msgstr "網格沒有表é¢ä¾†å‰µå»ºè¼ªå»“ï¼"
+msgstr "網格未包å«å¯å»ºç«‹è¼ªå»“的表é¢ï¼"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Mesh primitive type is not PRIMITIVE_TRIANGLES!"
-msgstr ""
+msgstr "網格的原始類型ä¸æ˜¯ PRIMITIVE_TRIANGLESï¼"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Could not create outline!"
-msgstr ""
+msgstr "無法建立輪廓ï¼"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Outline"
-msgstr "創建輪廓"
+msgstr "建立輪廓"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Mesh"
@@ -6199,7 +5845,7 @@ msgstr "網格"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Trimesh Static Body"
-msgstr ""
+msgstr "建立三角網格éœæ…‹å½¢é«”"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
@@ -6207,42 +5853,48 @@ msgid ""
"automatically.\n"
"This is the most accurate (but slowest) option for collision detection."
msgstr ""
+"建立éœæ…‹å½¢é«” (StaticBody) 並自動指派一個基於多邊形的碰撞形體。\n"
+"å°æ–¼ç¢°æ’žåµæ¸¬ï¼Œé€™æ˜¯æœ€ç²¾ç¢ºï¼ˆä½†æœ€æ…¢ï¼‰çš„é¸é …。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Trimesh Collision Sibling"
-msgstr ""
+msgstr "建立三角網格碰撞åŒç´š"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
"Creates a polygon-based collision shape.\n"
"This is the most accurate (but slowest) option for collision detection."
msgstr ""
+"建立基於多邊形的碰撞形狀。\n"
+"å°æ–¼ç¢°æ’žåµæ¸¬ï¼Œé€™æ˜¯æœ€ç²¾ç¢ºï¼ˆä½†æœ€æ…¢ï¼‰çš„é¸é …。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Single Convex Collision Sibling"
-msgstr "創建碰撞多邊形"
+msgstr "建立單一凸é¢ç¢°æ’žåŒç´š"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
"Creates a single convex collision shape.\n"
"This is the fastest (but least accurate) option for collision detection."
msgstr ""
+"建立單一凸é¢ç¢°æ’žå½¢ç‹€ã€‚\n"
+"å°æ–¼ç¢°æ’žåµæ¸¬ï¼Œé€™æ˜¯æœ€å¿«ï¼ˆä½†æœ€ä¸ç²¾ç¢ºï¼‰çš„é¸é …。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "Create Multiple Convex Collision Siblings"
-msgstr "創建碰撞多邊形"
+msgstr "建立碰撞多邊形åŒç´š"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
"Creates a polygon-based collision shape.\n"
"This is a performance middle-ground between the two above options."
msgstr ""
+"建立基於多邊形的碰撞å€åŸŸã€‚\n"
+"這是效能ä½æ–¼ä¸Šé¢å…©å€‹æ–¹æ³•ä¸­é–“çš„é¸é …。"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Outline Mesh..."
-msgstr "創建輪廓網格…"
+msgstr "建立輪廓網格..."
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid ""
@@ -6251,24 +5903,24 @@ msgid ""
"This can be used instead of the SpatialMaterial Grow property when using "
"that property isn't possible."
msgstr ""
+"建立éœæ…‹è¼ªå»“網格。輪廓網格的法線會自動翻轉。\n"
+"當無法使用 SpatialMetarial çš„ Grow 屬性時å¯ä»¥ä½¿ç”¨é€™å€‹ã€‚"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "View UV1"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "檢視 UV1"
#: editor/plugins/mesh_instance_editor_plugin.cpp
-#, fuzzy
msgid "View UV2"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "檢視 UV2"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Unwrap UV2 for Lightmap/AO"
-msgstr ""
+msgstr "為光照圖ï¼AO 打開 UV2"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Create Outline Mesh"
-msgstr "創建輪廓網格"
+msgstr "建立輪廓網格"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "Outline Size:"
@@ -6276,100 +5928,100 @@ msgstr "輪廓尺寸:"
#: editor/plugins/mesh_instance_editor_plugin.cpp
msgid "UV Channel Debug"
-msgstr ""
+msgstr "UV 通é“åµéŒ¯"
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Remove item %d?"
-msgstr "删除項目%d?"
+msgstr "是å¦ç§»é™¤é …ç›® %d?"
#: editor/plugins/mesh_library_editor_plugin.cpp
-#, fuzzy
msgid ""
"Update from existing scene?:\n"
"%s"
-msgstr "從場景更新"
+msgstr ""
+"自ç¾æœ‰å ´æ™¯ä¸­æ›´æ–°ï¼Ÿ\n"
+"%s"
#: editor/plugins/mesh_library_editor_plugin.cpp
-#, fuzzy
msgid "Mesh Library"
-msgstr "網狀資料庫(MeshLibrary)…"
+msgstr "網格庫 (Mesh Library)"
#: editor/plugins/mesh_library_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
msgid "Add Item"
-msgstr "添加項目"
+msgstr "新增項目"
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Remove Selected Item"
-msgstr "删除所é¸é …"
+msgstr "移除所é¸é …ç›®"
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Import from Scene"
-msgstr "從場景導入"
+msgstr "自場景匯入"
#: editor/plugins/mesh_library_editor_plugin.cpp
msgid "Update from Scene"
-msgstr "從場景更新"
+msgstr "自場景更新"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "No mesh source specified (and no MultiMesh set in node)."
-msgstr "未指定網格æºï¼ˆç¯€é»žä¸­æ²’有多網格集)。"
+msgstr "未指定網格來æºï¼ˆä¸”節點中沒有多網格集 (MultiMesh Set))。"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "No mesh source specified (and MultiMesh contains no Mesh)."
-msgstr ""
+msgstr "未指定網格來æºï¼ˆä¸”多網格 (MultiMesh) 未包å«ç¶²æ ¼ (Mesh))。"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Mesh source is invalid (invalid path)."
-msgstr "網格æºç„¡æ•ˆï¼ˆè·¯å¾‘無效)。"
+msgstr "網格來æºç„¡æ•ˆï¼ˆç„¡æ•ˆçš„路徑)。"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Mesh source is invalid (not a MeshInstance)."
-msgstr "網格æºç„¡æ•ˆ (ä¸æ˜¯ç¶²æ ¼å¯¦ä¾‹)。"
+msgstr "網格來æºç„¡æ•ˆï¼ˆä¸æ˜¯ç¶²æ ¼å¯¦é«” (MeshInstance))。"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Mesh source is invalid (contains no Mesh resource)."
-msgstr "網格æºç„¡æ•ˆï¼ˆä¸åŒ…å«ç¶²æ ¼è³‡æºï¼‰ã€‚"
+msgstr "網格來æºç„¡æ•ˆï¼ˆæœªåŒ…å«ç¶²æ ¼ (Mesh) 資æºï¼‰ã€‚"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "No surface source specified."
-msgstr "未指定表é¢æºã€‚"
+msgstr "未指定表é¢ä¾†æºã€‚"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Surface source is invalid (invalid path)."
-msgstr "表é¢æºç„¡æ•ˆï¼ˆè·¯å¾‘無效)。"
+msgstr "表é¢ä¾†æºç„¡æ•ˆï¼ˆç„¡æ•ˆçš„路徑)。"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Surface source is invalid (no geometry)."
-msgstr "表é¢æºç„¡æ•ˆï¼ˆæ²’有幾何圖形)。"
+msgstr "表é¢ä¾†æºç„¡æ•ˆï¼ˆç„¡å¹¾ä½•ï¼‰ã€‚"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Surface source is invalid (no faces)."
-msgstr "表é¢æºç„¡æ•ˆï¼ˆæ²’有é¢ï¼‰ã€‚"
+msgstr "表é¢ä¾†æºç„¡æ•ˆï¼ˆç„¡é¢ï¼‰ã€‚"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Select a Source Mesh:"
-msgstr "é¸æ“‡æºç¶²æ ¼ï¼š"
+msgstr "é¸æ“‡ä¾†æºç¶²æ ¼ï¼š"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Select a Target Surface:"
-msgstr "é¸æ“‡ç›®æ¨™æ›²é¢ï¼š"
+msgstr "é¸æ“‡ç›®æ¨™ç¶²æ ¼ï¼š"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Populate Surface"
-msgstr "填充曲é¢"
+msgstr "填充表é¢"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Populate MultiMesh"
-msgstr "填充多網格"
+msgstr "填充多網格 (MultiMesh)"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Target Surface:"
-msgstr "目標表é¢:"
+msgstr "目標表é¢ï¼š"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Source Mesh:"
-msgstr "æºç¶²æ ¼:"
+msgstr "來æºç¶²æ ¼ï¼š"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "X-Axis"
@@ -6385,7 +6037,7 @@ msgstr "Z 軸"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Mesh Up Axis:"
-msgstr ""
+msgstr "網格上軸:"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Random Rotation:"
@@ -6397,7 +6049,7 @@ msgstr "隨機傾斜:"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Random Scale:"
-msgstr "隨機縮放:"
+msgstr "隨機縮放:"
#: editor/plugins/multimesh_editor_plugin.cpp
msgid "Populate"
@@ -6406,69 +6058,65 @@ msgstr "å¡«å……"
#: editor/plugins/navigation_polygon_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Create Navigation Polygon"
-msgstr "創建導航多邊形"
+msgstr "建立導航多邊形"
#: editor/plugins/particles_2d_editor_plugin.cpp
#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
msgid "Convert to CPUParticles"
-msgstr "轉æ›æˆ..."
+msgstr "轉æ›ç‚º CPUParticles"
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Generating Visibility Rect"
-msgstr "生æˆå¯è¦‹æ€§çŸ©å½¢"
+msgstr "正在產生矩形å¯è¦‹æ€§"
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Generate Visibility Rect"
-msgstr "生æˆå¯è¦‹æ€§çŸ©å½¢"
+msgstr "產生矩形å¯è¦‹æ€§"
#: editor/plugins/particles_2d_editor_plugin.cpp
msgid "Can only set point into a ParticlesMaterial process material"
-msgstr ""
+msgstr "僅é™æŒ‡å‘ç²’å­æ料的處ç†ææ–™ (ParticlesMaterial Process Material)"
#: editor/plugins/particles_2d_editor_plugin.cpp
#: editor/plugins/particles_editor_plugin.cpp
msgid "Generation Time (sec):"
-msgstr "生æˆæ™‚é–“ (秒):"
+msgstr "產生時間(秒):"
#: editor/plugins/particles_editor_plugin.cpp
msgid "The geometry's faces don't contain any area."
-msgstr ""
+msgstr "幾何體的é¢æœªåŒ…å«ä»»ä½•å€åŸŸã€‚"
#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
msgid "The geometry doesn't contain any faces."
-msgstr "節點ä¸åŒ…å«å¹¾ä½•åœ–å½¢ (é¢)。"
+msgstr "幾何體未包å«ä»»ä½•é¢ã€‚"
#: editor/plugins/particles_editor_plugin.cpp
msgid "\"%s\" doesn't inherit from Spatial."
-msgstr ""
+msgstr "「%sã€éžè‡ª Spatial 繼承。"
#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
msgid "\"%s\" doesn't contain geometry."
-msgstr "節點ä¸åŒ…å«å¹¾ä½•åœ–形。"
+msgstr "「%sã€æœªåŒ…å«å¹¾ä½•é«”。"
#: editor/plugins/particles_editor_plugin.cpp
-#, fuzzy
msgid "\"%s\" doesn't contain face geometry."
-msgstr "節點ä¸åŒ…å«å¹¾ä½•åœ–形。"
+msgstr "「%sã€æœªåŒ…å«é¢å¹¾ä½•é«”。"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Create Emitter"
-msgstr "創建發射器"
+msgstr "建立發射器"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Emission Points:"
-msgstr "排放點:"
+msgstr "發射點:"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Surface Points"
-msgstr "表é¢é»ž"
+msgstr "表é¢é ‚點"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Surface Points+Normal (Directed)"
-msgstr "表é¢é»ž + 法線 (定å‘)"
+msgstr "表é¢é»ž + 法線(有å‘)"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Volume"
@@ -6476,330 +6124,320 @@ msgstr "é«”ç©"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Emission Source: "
-msgstr "排放æºï¼š "
+msgstr "發射æºï¼š "
#: editor/plugins/particles_editor_plugin.cpp
msgid "A processor material of type 'ParticlesMaterial' is required."
-msgstr "需è¦â€œé¡†ç²’資料â€é¡žåž‹çš„處ç†å™¨è³‡æ–™ã€‚"
+msgstr "需è¦ã€Œç²’å­ææ–™ (ParticlesMaterial)ã€åž‹åˆ¥çš„處ç†å™¨æ料。"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Generating AABB"
-msgstr "ç”Ÿæˆ AABB"
+msgstr "正在產生 AABB"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Generate Visibility AABB"
-msgstr "生æˆå¯è¦‹æ€§AABB"
+msgstr "產生å¯è¦‹æ€§ AABB"
#: editor/plugins/particles_editor_plugin.cpp
msgid "Generate AABB"
-msgstr "ç”Ÿæˆ AABB"
+msgstr "產生 AABB"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Remove Point from Curve"
-msgstr "從曲線中删除點"
+msgstr "自曲線中刪除控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Remove Out-Control from Curve"
-msgstr ""
+msgstr "自曲線移除外控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Remove In-Control from Curve"
-msgstr ""
+msgstr "自曲線移除內控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Add Point to Curve"
-msgstr ""
+msgstr "新增控制點至曲線"
#: editor/plugins/path_2d_editor_plugin.cpp
-#, fuzzy
msgid "Split Curve"
-msgstr "編輯節點曲線"
+msgstr "拆分控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Move Point in Curve"
-msgstr ""
+msgstr "移動控制點至曲線"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Move In-Control in Curve"
-msgstr ""
+msgstr "移動曲線的內控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Move Out-Control in Curve"
-msgstr ""
+msgstr "移動曲線的外控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Select Points"
-msgstr ""
+msgstr "é¸æ“‡æŽ§åˆ¶é»ž"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Shift+Drag: Select Control Points"
-msgstr ""
+msgstr "Shift+拖移:é¸æ“‡æŽ§åˆ¶é»ž"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Click: Add Point"
-msgstr ""
+msgstr "點擊:新增控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Left Click: Split Segment (in curve)"
-msgstr ""
+msgstr "å·¦éµé»žæ“Šï¼šï¼ˆåœ¨æ›²ç·šå…§ï¼‰æ‹†åˆ†ç·šæ®µ"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Right Click: Delete Point"
-msgstr ""
+msgstr "å³éµé»žæ“Šï¼šåˆªé™¤æŽ§åˆ¶é»ž"
#: editor/plugins/path_2d_editor_plugin.cpp
msgid "Select Control Points (Shift+Drag)"
-msgstr ""
+msgstr "é¸æ“‡æŽ§åˆ¶é»žï¼ˆShift+拖移)"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Add Point (in empty space)"
-msgstr ""
+msgstr "新增控制點(在空白處)"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Delete Point"
-msgstr ""
+msgstr "刪除控制點"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Close Curve"
-msgstr ""
+msgstr "關閉曲線"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp editor/plugins/theme_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp editor/project_export.cpp
msgid "Options"
-msgstr ""
+msgstr "é¸é …"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Mirror Handle Angles"
-msgstr ""
+msgstr "é¡åƒæ‰‹æŸ„角度"
#: editor/plugins/path_2d_editor_plugin.cpp
#: editor/plugins/path_editor_plugin.cpp
msgid "Mirror Handle Lengths"
-msgstr ""
+msgstr "é¡åƒæ‰‹æŸ„長度"
#: editor/plugins/path_editor_plugin.cpp
msgid "Curve Point #"
-msgstr ""
+msgstr "曲線控制點 #"
#: editor/plugins/path_editor_plugin.cpp
-#, fuzzy
msgid "Set Curve Point Position"
-msgstr "移除"
+msgstr "設定曲線控制點的ä½ç½®"
#: editor/plugins/path_editor_plugin.cpp
-#, fuzzy
msgid "Set Curve In Position"
-msgstr "移除"
+msgstr "設定曲線的內控制點ä½ç½®"
#: editor/plugins/path_editor_plugin.cpp
-#, fuzzy
msgid "Set Curve Out Position"
-msgstr "移除"
+msgstr "設定曲線的外控制點ä½ç½®"
#: editor/plugins/path_editor_plugin.cpp
msgid "Split Path"
-msgstr ""
+msgstr "拆分路徑"
#: editor/plugins/path_editor_plugin.cpp
msgid "Remove Path Point"
-msgstr ""
+msgstr "移除路徑控制點"
#: editor/plugins/path_editor_plugin.cpp
msgid "Remove Out-Control Point"
-msgstr ""
+msgstr "移除外控制點"
#: editor/plugins/path_editor_plugin.cpp
msgid "Remove In-Control Point"
-msgstr ""
+msgstr "移除內控制點"
#: editor/plugins/path_editor_plugin.cpp
msgid "Split Segment (in curve)"
-msgstr ""
+msgstr "拆分線段(在曲線中)"
#: editor/plugins/physical_bone_plugin.cpp
-#, fuzzy
msgid "Move Joint"
-msgstr "移除"
+msgstr "移動關節"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid ""
"The skeleton property of the Polygon2D does not point to a Skeleton2D node"
-msgstr ""
+msgstr "多邊形 2D (Polygon2D) 的骨架屬性未指å‘骨架 2D (Skeleton2D) 節點"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Sync Bones"
-msgstr ""
+msgstr "åŒæ­¥éª¨éª¼"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid ""
"No texture in this polygon.\n"
"Set a texture to be able to edit UV."
msgstr ""
+"該多邊形沒有紋ç†è²¼åœ–。\n"
+"請先設定紋ç†ä»¥ç·¨è¼¯ UV。"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Create UV Map"
-msgstr ""
+msgstr "建立 UV Map"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid ""
"Polygon 2D has internal vertices, so it can no longer be edited in the "
"viewport."
-msgstr ""
+msgstr "多邊形 2D 有內部頂點,將無法在檢視å€ç·¨è¼¯ã€‚"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Create Polygon & UV"
-msgstr ""
+msgstr "建立多邊形與 UV"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Create Internal Vertex"
-msgstr ""
+msgstr "建立內部頂點"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Remove Internal Vertex"
-msgstr ""
+msgstr "移除內部頂點"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Invalid Polygon (need 3 different vertices)"
-msgstr ""
+msgstr "無效的多邊形(需è¦ä¸‰å€‹ä¸åŒçš„頂點)"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Add Custom Polygon"
-msgstr "新增資料夾"
+msgstr "新增自定多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Remove Custom Polygon"
-msgstr "移除"
+msgstr "移除自定多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Transform UV Map"
-msgstr ""
+msgstr "è½‰æ› UV Map"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Transform Polygon"
-msgstr "新增資料夾"
+msgstr "轉æ›å¤šé‚Šå½¢"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Paint Bone Weights"
-msgstr ""
+msgstr "æ繪骨骼權é‡"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Open Polygon 2D UV editor."
-msgstr ""
+msgstr "開啟多邊形 2D UV 編輯器。"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Polygon 2D UV Editor"
-msgstr ""
+msgstr "多邊形 2D UV 編輯器"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "UV"
-msgstr ""
+msgstr "UV"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Points"
-msgstr "移除"
+msgstr "點"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Polygons"
-msgstr "新增資料夾"
+msgstr "多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Bones"
-msgstr ""
+msgstr "骨骼"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Move Points"
-msgstr "移除"
+msgstr "移動點"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Ctrl: Rotate"
-msgstr ""
+msgstr "Ctrl:旋轉"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Shift: Move All"
-msgstr ""
+msgstr "Shift:移動全部"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Shift+Ctrl: Scale"
-msgstr ""
+msgstr "Shift+Ctrl:縮放"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Move Polygon"
-msgstr ""
+msgstr "移動多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Rotate Polygon"
-msgstr ""
+msgstr "旋轉多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Scale Polygon"
-msgstr ""
+msgstr "縮放多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Create a custom polygon. Enables custom polygon rendering."
-msgstr ""
+msgstr "建立自定多邊形。啟用自定多邊形算圖。"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid ""
"Remove a custom polygon. If none remain, custom polygon rendering is "
"disabled."
-msgstr ""
+msgstr "移除自定多邊形。若無剩餘多邊形,將ç¦ç”¨è‡ªå®šå¤šé‚Šå½¢ç®—圖。"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Paint weights with specified intensity."
-msgstr ""
+msgstr "以指定的強度來繪製權é‡ã€‚"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Unpaint weights with specified intensity."
-msgstr ""
+msgstr "以指定的強度來å–消繪製權é‡ã€‚"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Radius:"
-msgstr ""
+msgstr "åŠå¾‘:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Polygon->UV"
-msgstr ""
+msgstr "多邊形 -> UV"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "UV->Polygon"
-msgstr ""
+msgstr "UV -> 多邊形"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Clear UV"
-msgstr ""
+msgstr "清除 UV"
#: editor/plugins/polygon_2d_editor_plugin.cpp
-#, fuzzy
msgid "Grid Settings"
-msgstr "專案設定"
+msgstr "網格設定"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Snap"
-msgstr ""
+msgstr "å¸é™„"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Enable Snap"
-msgstr ""
+msgstr "啟用å¸é™„"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid"
-msgstr ""
+msgstr "網格"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Show Grid"
@@ -6807,48 +6445,48 @@ msgstr "顯示網格"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Configure Grid:"
-msgstr ""
+msgstr "設定網格:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Offset X:"
-msgstr ""
+msgstr "網格 X å移:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Offset Y:"
-msgstr ""
+msgstr "網格 Y å移:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Step X:"
-msgstr ""
+msgstr "網格 X 步進值:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Grid Step Y:"
-msgstr ""
+msgstr "網格 Y 步進值:"
#: editor/plugins/polygon_2d_editor_plugin.cpp
msgid "Sync Bones to Polygon"
-msgstr ""
+msgstr "åŒæ­¥éª¨éª¼åˆ°å¤šé‚Šå½¢"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "ERROR: Couldn't load resource!"
-msgstr ""
+msgstr "錯誤:無法載入資æºï¼"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "Add Resource"
-msgstr ""
+msgstr "新增資æº"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "Rename Resource"
-msgstr ""
+msgstr "é‡æ–°å‘½å資æº"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Delete Resource"
-msgstr ""
+msgstr "刪除資æº"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "Resource clipboard is empty!"
-msgstr ""
+msgstr "資æºå‰ªè²¼æ¿ç‚ºç©ºï¼"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "Paste Resource"
@@ -6857,119 +6495,108 @@ msgstr "貼上資æº"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/scene_tree_editor.cpp
msgid "Instance:"
-msgstr ""
+msgstr "實體:"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp editor/project_settings_editor.cpp
#: editor/scene_tree_editor.cpp editor/script_editor_debugger.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Type:"
-msgstr ""
+msgstr "型別:"
#: editor/plugins/resource_preloader_editor_plugin.cpp
#: editor/scene_tree_dock.cpp editor/scene_tree_editor.cpp
msgid "Open in Editor"
-msgstr ""
+msgstr "在編輯器中開啟"
#: editor/plugins/resource_preloader_editor_plugin.cpp
msgid "Load Resource"
-msgstr ""
+msgstr "載入資æº"
#: editor/plugins/resource_preloader_editor_plugin.cpp
-#, fuzzy
msgid "ResourcePreloader"
-msgstr "資æºè·¯å¾‘"
+msgstr "資æºé åŠ è¼‰ (ResourcePreloader)"
#: editor/plugins/root_motion_editor_plugin.cpp
msgid "AnimationTree has no path set to an AnimationPlayer"
-msgstr ""
+msgstr "動畫樹 (AnimationTree) 未設定至動畫播放器 (AnimationPlayer) 的路徑"
#: editor/plugins/root_motion_editor_plugin.cpp
msgid "Path to AnimationPlayer is invalid"
-msgstr ""
+msgstr "至 AnimationPlayer 的路徑無效"
#: editor/plugins/script_editor_plugin.cpp
msgid "Clear Recent Files"
-msgstr ""
+msgstr "清除最近的檔案"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Close and save changes?"
-msgstr "沒有儲存的變更都會éºå¤±, 確定è¦é—œé–‰?"
+msgstr "關閉並ä¿å­˜ä¿®æ”¹å—Žï¼Ÿ"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error writing TextFile:"
-msgstr "載入場景時發生錯誤"
+msgstr "寫入文字檔案 (TextFile) 時發生錯誤:"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Could not load file at:"
-msgstr "無法新增資料夾"
+msgstr "無法載入檔案於:"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error saving file!"
-msgstr "儲存資æºéŒ¯èª¤!"
+msgstr "ä¿å­˜æª”案時發生錯誤ï¼"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error while saving theme."
-msgstr "儲存中發生了錯誤。"
+msgstr "ä¿å­˜ä¸»é¡Œæ™‚發生錯誤。"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error Saving"
-msgstr "ä¿å­˜éŒ¯èª¤"
+msgstr "ä¿å­˜æ™‚發生錯誤"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error importing theme."
-msgstr "導入主題時出錯。"
+msgstr "ä¿å­˜åŒ¯å…¥çš„主題時發生錯誤。"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Error Importing"
-msgstr "載入時發生錯誤:"
+msgstr "匯入時發生錯誤"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "New Text File..."
-msgstr "新增資料夾..."
+msgstr "新增文字檔案..."
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Open File"
msgstr "開啟檔案"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Save File As..."
-msgstr "å¦å­˜å ´æ™¯ç‚º..."
+msgstr "å¦å­˜æª”案為..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Can't obtain the script for running."
-msgstr ""
+msgstr "無法å–å¾—è¦åŸ·è¡Œçš„腳本。"
#: editor/plugins/script_editor_plugin.cpp
msgid "Script failed reloading, check console for errors."
-msgstr ""
+msgstr "腳本é‡æ–°è¼‰å…¥å¤±æ•—,請檢查主控å°ä»¥ç¢ºèªéŒ¯èª¤ã€‚"
#: editor/plugins/script_editor_plugin.cpp
msgid "Script is not in tool mode, will not be able to run."
-msgstr ""
+msgstr "腳本ä¸åœ¨å·¥å…·æ¨¡å¼ä¸‹ï¼Œç„¡æ³•åŸ·è¡Œã€‚"
#: editor/plugins/script_editor_plugin.cpp
msgid ""
"To run this script, it must inherit EditorScript and be set to tool mode."
-msgstr ""
+msgstr "欲執行該腳本,其必須繼承自編輯器腳本 (EditorScript) 並設為工具模å¼ã€‚"
#: editor/plugins/script_editor_plugin.cpp
msgid "Import Theme"
-msgstr "導入主題"
+msgstr "匯入主題"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error while saving theme"
-msgstr "ä¿å­˜ä¸»é¡Œæ™‚出錯"
+msgstr "ä¿å­˜ä¸»é¡Œæ™‚發生錯誤"
#: editor/plugins/script_editor_plugin.cpp
msgid "Error saving"
@@ -6977,41 +6604,37 @@ msgstr "ä¿å­˜éŒ¯èª¤"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save Theme As..."
-msgstr "將主題å¦å­˜ç‚º..。"
+msgstr "ä¿å­˜ä¸»é¡Œç‚º..."
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "%s Class Reference"
-msgstr " 類引用"
+msgstr "%s 類別åƒç…§"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
msgid "Find Next"
-msgstr "查找下一個"
+msgstr "尋找下一個"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp
msgid "Find Previous"
-msgstr "查找上一個"
+msgstr "尋找上一個"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Filter scripts"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "éŽæ¿¾è…³æœ¬"
#: editor/plugins/script_editor_plugin.cpp
msgid "Toggle alphabetical sorting of the method list."
-msgstr ""
+msgstr "é–‹å•Ÿï¼é—œé–‰æŒ‰ç…§å­—æ¯é †åºæŽ’列方法列表。"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Filter methods"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "éŽæ¿¾æ–¹æ³•"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Sort"
-msgstr "排åº:"
+msgstr "排åº"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/script_text_editor.cpp editor/scene_tree_dock.cpp
@@ -7038,14 +6661,12 @@ msgid "File"
msgstr "檔案"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Open..."
msgstr "開啟…"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Reopen Closed Script"
-msgstr "開啟最近存å–"
+msgstr "é‡æ–°æ‰“開關閉的腳本"
#: editor/plugins/script_editor_plugin.cpp
msgid "Save All"
@@ -7053,20 +6674,19 @@ msgstr "全部ä¿å­˜"
#: editor/plugins/script_editor_plugin.cpp
msgid "Soft Reload Script"
-msgstr "軟é‡æ–°åŠ è¼‰è…³æœ¬"
+msgstr "軟é‡æ–°è¼‰å…¥è…³æœ¬"
#: editor/plugins/script_editor_plugin.cpp
msgid "Copy Script Path"
msgstr "複製腳本路徑"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "History Previous"
-msgstr "上個分é "
+msgstr "上一個歷å²è¨˜éŒ„"
#: editor/plugins/script_editor_plugin.cpp
msgid "History Next"
-msgstr ""
+msgstr "下一個歷å²è¨˜éŒ„"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/theme_editor_plugin.cpp
@@ -7074,9 +6694,8 @@ msgid "Theme"
msgstr "主題"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Import Theme..."
-msgstr "導入主題..。"
+msgstr "匯入主題..."
#: editor/plugins/script_editor_plugin.cpp
msgid "Reload Theme"
@@ -7092,11 +6711,11 @@ msgstr "全部關閉"
#: editor/plugins/script_editor_plugin.cpp
msgid "Close Docs"
-msgstr "關閉檔案"
+msgstr "關閉說明文件"
#: editor/plugins/script_editor_plugin.cpp editor/project_manager.cpp
msgid "Run"
-msgstr "é‹è¡Œ"
+msgstr "執行"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Step Into"
@@ -7104,11 +6723,11 @@ msgstr "步入"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Step Over"
-msgstr "è·¨éŽ"
+msgstr "æ­¥éŽ"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Break"
-msgstr "è·³éŽ"
+msgstr "中斷"
#: editor/plugins/script_editor_plugin.cpp editor/project_manager.cpp
#: editor/script_editor_debugger.cpp
@@ -7117,39 +6736,39 @@ msgstr "繼續"
#: editor/plugins/script_editor_plugin.cpp
msgid "Keep Debugger Open"
-msgstr "ä¿æŒèª¿è©¦å™¨æ‰“é–‹"
+msgstr "ä¿æŒé–‹å•Ÿé™¤éŒ¯å·¥å…·"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Debug with External Editor"
-msgstr "使用外部編輯器進行調試"
+msgstr "使用外部編輯器進行除錯"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Open Godot online documentation."
-msgstr "打開 Godot 線上文檔"
+msgstr "打開 Godot 線上說明文件。"
#: editor/plugins/script_editor_plugin.cpp
msgid "Search the reference documentation."
-msgstr "æœç´¢åƒè€ƒæ–‡æª”。"
+msgstr "æœå°‹åƒç…§æ–‡ä»¶ã€‚"
#: editor/plugins/script_editor_plugin.cpp
msgid "Go to previous edited document."
-msgstr "轉到上一個編輯的檔案。"
+msgstr "跳至上一個編輯的文件。"
#: editor/plugins/script_editor_plugin.cpp
msgid "Go to next edited document."
-msgstr "轉到下一個編輯的檔案。"
+msgstr "跳至下一個編輯的文件。"
#: editor/plugins/script_editor_plugin.cpp
msgid "Discard"
-msgstr "棄置"
+msgstr "放棄"
#: editor/plugins/script_editor_plugin.cpp
msgid ""
"The following files are newer on disk.\n"
"What action should be taken?:"
msgstr ""
+"ç£ç¢Ÿä¸­çš„下列檔案已更新。\n"
+"è¦åŸ·è¡Œä»€éº¼ï¼Ÿï¼š"
#: editor/plugins/script_editor_plugin.cpp
#: editor/plugins/shader_editor_plugin.cpp
@@ -7163,73 +6782,65 @@ msgstr "é‡æ–°ä¿å­˜"
#: editor/plugins/script_editor_plugin.cpp editor/script_editor_debugger.cpp
msgid "Debugger"
-msgstr "調試器"
+msgstr "除錯工具"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Search Results"
msgstr "æœå°‹çµæžœ"
#: editor/plugins/script_editor_plugin.cpp
-#, fuzzy
msgid "Clear Recent Scripts"
-msgstr "清除最近開啟的場景"
+msgstr "清除最近開啟的腳本"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Connections to method:"
-msgstr "連接到節點:"
+msgstr "連接至方法:"
#: editor/plugins/script_text_editor.cpp editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Source"
-msgstr "資æº"
+msgstr "來æº"
#: editor/plugins/script_text_editor.cpp
msgid "Target"
-msgstr ""
+msgstr "目標"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid ""
"Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."
-msgstr "將 '%s' 從 '%s' 中斷連接"
+msgstr "找ä¸åˆ°æ–¹æ³•ã€Œ%sã€ï¼ˆè‡ªè¨Šè™Ÿã€Œ%sã€ï¼‰ï¼Œç¯€é»žã€Œ%sã€è‡³ã€Œ%sã€çš„連接已中斷。"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
-msgid "Line"
-msgstr "行:"
+msgid "[Ignore]"
+msgstr "[忽略]"
#: editor/plugins/script_text_editor.cpp
-msgid "(ignore)"
-msgstr "(忽略)"
+msgid "Line"
+msgstr "行"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Function"
-msgstr "轉到函數"
+msgstr "跳至函å¼"
#: editor/plugins/script_text_editor.cpp
msgid "Only resources from filesystem can be dropped."
-msgstr "åªèƒ½æ‹–拽檔案系統中的資æºã€‚"
+msgstr "åªå¯æ‹–移來自檔案系統的資æºã€‚"
#: editor/plugins/script_text_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't drop nodes because script '%s' is not used in this scene."
-msgstr ""
+msgstr "無法防止節點,由於腳本「%sã€ä¸¦æœªåœ¨è©²å ´æ™¯ä¸­ä½¿ç”¨ã€‚"
#: editor/plugins/script_text_editor.cpp
msgid "Lookup Symbol"
-msgstr "查找符號"
+msgstr "æœå°‹ç¬¦è™Ÿ"
#: editor/plugins/script_text_editor.cpp
msgid "Pick Color"
msgstr "é¸æ“‡é¡è‰²"
#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
-#, fuzzy
msgid "Convert Case"
-msgstr "轉æ›æˆ..."
+msgstr "轉æ›å¤§å°å¯«"
#: editor/plugins/script_text_editor.cpp editor/plugins/text_editor.cpp
msgid "Uppercase"
@@ -7250,53 +6861,50 @@ msgstr "高亮顯示語法"
#: editor/plugins/script_text_editor.cpp
#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
msgid "Go To"
-msgstr ""
+msgstr "跳至"
#: editor/plugins/script_text_editor.cpp
#: editor/plugins/shader_editor_plugin.cpp editor/plugins/text_editor.cpp
msgid "Bookmarks"
-msgstr ""
+msgstr "書籤"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Breakpoints"
-msgstr "刪除"
+msgstr "中斷點"
#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
msgid "Cut"
-msgstr "剪切"
+msgstr "剪下"
#: editor/plugins/script_text_editor.cpp scene/gui/line_edit.cpp
#: scene/gui/text_edit.cpp
msgid "Select All"
-msgstr "é¸æ“‡å…¨éƒ¨"
+msgstr "全部é¸æ“‡"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Delete Line"
msgstr "删除行"
#: editor/plugins/script_text_editor.cpp
msgid "Indent Left"
-msgstr "å‘左縮進"
+msgstr "å‘左縮排"
#: editor/plugins/script_text_editor.cpp
msgid "Indent Right"
-msgstr "å‘å³ç¸®é€²"
+msgstr "å‘å³ç¸®æŽ’"
#: editor/plugins/script_text_editor.cpp
msgid "Toggle Comment"
-msgstr "切æ›æ³¨é‡‹"
+msgstr "展開ï¼æ”¶èµ·è¨»è§£"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Fold/Unfold Line"
-msgstr "å‰å¾€ç¬¬...è¡Œ"
+msgstr "展開ï¼æ”¶èµ·è¡Œ"
#: editor/plugins/script_text_editor.cpp
msgid "Fold All Lines"
-msgstr "折疊所有行"
+msgstr "收起所有行"
#: editor/plugins/script_text_editor.cpp
msgid "Unfold All Lines"
@@ -7304,97 +6912,88 @@ msgstr "展開所有行"
#: editor/plugins/script_text_editor.cpp
msgid "Clone Down"
-msgstr "æ‹·è²åˆ°ä¸‹ä¸€è¡Œ"
+msgstr "複製到下一行"
#: editor/plugins/script_text_editor.cpp
msgid "Complete Symbol"
-msgstr ""
+msgstr "補全符號"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Evaluate Selection"
-msgstr "縮放所é¸"
+msgstr "å–值所é¸å…§å®¹"
#: editor/plugins/script_text_editor.cpp
msgid "Trim Trailing Whitespace"
-msgstr ""
+msgstr "移除後方空白字元"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Convert Indent to Spaces"
-msgstr "轉æ›æˆ..."
+msgstr "轉æ›ç¸®æŽ’為空白"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Convert Indent to Tabs"
-msgstr "轉æ›æˆ..."
+msgstr "轉æ›ç¸®æŽ’為 Tab"
#: editor/plugins/script_text_editor.cpp
msgid "Auto Indent"
-msgstr "自動縮進"
+msgstr "自動縮排"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Find in Files..."
-msgstr "在檔中查找..。"
+msgstr "在檔案中æœå°‹..."
#: editor/plugins/script_text_editor.cpp
msgid "Contextual Help"
-msgstr ""
+msgstr "上下文說明"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Toggle Bookmark"
-msgstr "切æ›è‡ªç”±è§€å¯Ÿæ¨¡å¼"
+msgstr "新增ï¼ç§»é™¤æ›¸ç±¤"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Next Bookmark"
-msgstr "轉到下一個中斷點"
+msgstr "跳至下一個書籤"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Previous Bookmark"
-msgstr "轉到上一個中斷點"
+msgstr "跳至上一個書籤"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Remove All Bookmarks"
-msgstr "删除所有項目"
+msgstr "刪除所有書籤"
#: editor/plugins/script_text_editor.cpp
msgid "Go to Function..."
-msgstr "轉到函數…"
+msgstr "跳至函å¼..."
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Line..."
-msgstr "å‰å¾€ç¬¬...è¡Œ"
+msgstr "跳至第...行"
#: editor/plugins/script_text_editor.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Toggle Breakpoint"
-msgstr "設置中斷點"
+msgstr "設定ï¼ç§»é™¤ä¸­æ–·é»ž"
#: editor/plugins/script_text_editor.cpp
msgid "Remove All Breakpoints"
-msgstr "刪除所有中斷點"
+msgstr "移除所有中斷點"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Next Breakpoint"
-msgstr "轉到下一個中斷點"
+msgstr "跳至下一個中斷點"
#: editor/plugins/script_text_editor.cpp
-#, fuzzy
msgid "Go to Previous Breakpoint"
-msgstr "轉到上一個中斷點"
+msgstr "跳至上一個中斷點"
#: editor/plugins/shader_editor_plugin.cpp
msgid ""
"This shader has been modified on on disk.\n"
"What action should be taken?"
msgstr ""
+"ç£ç¢Ÿä¸Šè©²è‘—色器已被修改。\n"
+"該執行什麼?"
#: editor/plugins/shader_editor_plugin.cpp
msgid "Shader"
@@ -7402,45 +7001,43 @@ msgstr "著色器"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
msgid "This skeleton has no bones, create some children Bone2D nodes."
-msgstr "此骨架沒有骨骼ç¶å®šï¼Œè«‹å‰µå»ºä¸€äº› Bone2d 骨骼å­ç¯€é»žã€‚"
+msgstr "此骨架未包å«éª¨éª¼ï¼Œè«‹å»ºç«‹ä¸€äº›å­éª¨éª¼ 2D (Bone2D) 節點。"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
msgid "Create Rest Pose from Bones"
-msgstr "從骨骼創建休æ¯å§¿å‹¢"
+msgstr "自骨骼建立放鬆姿勢"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
msgid "Set Rest Pose to Bones"
-msgstr "將休æ¯å§¿å‹¢è¨­ç½®ç‚ºéª¨éª¼"
+msgstr "設定放鬆姿勢至骨骼"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
msgid "Skeleton2D"
-msgstr "2D骨骼節點"
+msgstr "骨架2D (Sekeleton2D)"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
msgid "Make Rest Pose (From Bones)"
-msgstr "創建休æ¯å§¿å‹¢ (從骨骼)"
+msgstr "製作放鬆姿勢(自骨骼)"
#: editor/plugins/skeleton_2d_editor_plugin.cpp
msgid "Set Bones to Rest Pose"
-msgstr "將骨骼設定為éœæ­¢å§¿å‹¢"
+msgstr "設定骨骼為放鬆姿勢"
#: editor/plugins/skeleton_editor_plugin.cpp
msgid "Create physical bones"
-msgstr "創建物ç†éª¨éª¼"
+msgstr "建立物ç†éª¨éª¼"
#: editor/plugins/skeleton_editor_plugin.cpp
-#, fuzzy
msgid "Skeleton"
msgstr "骨架"
#: editor/plugins/skeleton_editor_plugin.cpp
msgid "Create physical skeleton"
-msgstr "創建物ç†éª¨æž¶"
+msgstr "建立物ç†éª¨æž¶"
#: editor/plugins/skeleton_ik_editor_plugin.cpp
-#, fuzzy
msgid "Play IK"
-msgstr "播放 IK"
+msgstr "執行 IK"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Orthogonal"
@@ -7452,15 +7049,15 @@ msgstr "é€è¦–"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Transform Aborted."
-msgstr ""
+msgstr "已中止變æ›ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "X-Axis Transform."
-msgstr "X軸變æ›ã€‚"
+msgstr "X 軸變æ›ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Y-Axis Transform."
-msgstr "Y軸變æ›ã€‚"
+msgstr "Y 軸變æ›ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Z-Axis Transform."
@@ -7468,7 +7065,7 @@ msgstr "Z 軸變æ›ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Plane Transform."
-msgstr "查看平é¢è½‰æ›ã€‚"
+msgstr "檢視平é¢è½‰æ›ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Scaling: "
@@ -7476,7 +7073,7 @@ msgstr "縮放: "
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Translating: "
-msgstr "翻譯: "
+msgstr "移動: "
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rotating %s degrees."
@@ -7484,15 +7081,15 @@ msgstr "旋轉 %s 度。"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Keying is disabled (no key inserted)."
-msgstr ""
+msgstr "éµå·²è¢«ç¦ç”¨ï¼ˆæœªæ’å…¥éµï¼‰ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Animation Key Inserted."
-msgstr ""
+msgstr "å·²æ’入動畫éµã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Pitch"
-msgstr ""
+msgstr "仰角"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Yaw"
@@ -7516,7 +7113,7 @@ msgstr "表é¢è®Šæ›´"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Draw Calls"
-msgstr "繪製調用"
+msgstr "繪製呼å«"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Vertices"
@@ -7528,7 +7125,7 @@ msgstr "俯視圖。"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Bottom View."
-msgstr "底視圖。"
+msgstr "仰視圖。"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Bottom"
@@ -7567,35 +7164,32 @@ msgid "Rear"
msgstr "後"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Align Transform with View"
-msgstr "與視圖å°é½Š"
+msgstr "將變æ›èˆ‡è¦–圖å°é½Š"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Align Rotation with View"
-msgstr "將所é¸å…§å®¹èˆ‡è¦–圖å°é½Š"
+msgstr "將旋轉與視圖å°é½Š"
#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "No parent to instance a child at."
-msgstr ""
+msgstr "ç„¡æ¯ç¯€é»žå¯ç”¨ä¾†å¯¦é«”化å­ç¯€é»žã€‚"
#: editor/plugins/spatial_editor_plugin.cpp editor/scene_tree_dock.cpp
msgid "This operation requires a single selected node."
msgstr "æ­¤æ“作需è¦å–®å€‹é¸å®šçš„節點。"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Auto Orthogonal Enabled"
-msgstr "正交"
+msgstr "已啟用自動正交"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Lock View Rotation"
-msgstr "鎖定視圖旋轉"
+msgstr "鎖定視角旋轉"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Display Normal"
-msgstr ""
+msgstr "顯示法線"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Display Wireframe"
@@ -7611,41 +7205,39 @@ msgstr "顯示無陰影"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Environment"
-msgstr "查看環境"
+msgstr "檢視環境"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Gizmos"
-msgstr "查看 Gizmos"
+msgstr "檢視 Gizmo"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Information"
-msgstr "查看資訊"
+msgstr "檢視資訊"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "View FPS"
-msgstr "查看FPS"
+msgstr "檢視 FPS"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Half Resolution"
-msgstr "åŠåˆ†è¾¯çŽ‡"
+msgstr "åŠè§£æžåº¦"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Audio Listener"
msgstr "音訊監è½å™¨"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Enable Doppler"
-msgstr "啟用篩é¸"
+msgstr "啟用都åœå‹’效應"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Cinematic Preview"
-msgstr "影片é è¦½"
+msgstr "效果é è¦½"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Not available when using the GLES2 renderer."
-msgstr ""
+msgstr "使用 GLES2 算圖器時無法使用。"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Freelook Left"
@@ -7661,7 +7253,7 @@ msgstr "自由視圖 å‰"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Freelook Backwards"
-msgstr "自由視圖 åŽ"
+msgstr "自由視圖 後"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Freelook Up"
@@ -7673,12 +7265,11 @@ msgstr "自由視圖 下"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Freelook Speed Modifier"
-msgstr "自由視圖速度調節"
+msgstr "加速自由視圖速度"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Freelook Slow Modifier"
-msgstr "自由視圖速度調節"
+msgstr "放慢自由視圖速度"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Rotation Locked"
@@ -7688,19 +7279,35 @@ msgstr "視圖旋轉已鎖定"
msgid ""
"Note: The FPS value displayed is the editor's framerate.\n"
"It cannot be used as a reliable indication of in-game performance."
-msgstr "注æ„: 顯示的FPS值是編輯器的幀率。 它ä¸èƒ½ç”¨äºŽè¡¨ç¾éŠæˆ²å…§çš„實際性能"
+msgstr ""
+"注æ„:顯示的 FPS 值時編輯器的畫é¢é€ŸçŽ‡ã€‚\n"
+"無法實際å映為éŠæˆ²ä¸­çš„效能。"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "XForm Dialog"
-msgstr "XFormå°è©±æ¡†"
+msgstr "XForm å°è©±æ¡†"
+
+#: editor/plugins/spatial_editor_plugin.cpp
+msgid ""
+"Click to toggle between visibility states.\n"
+"\n"
+"Open eye: Gizmo is visible.\n"
+"Closed eye: Gizmo is hidden.\n"
+"Half-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\")."
+msgstr ""
+"點擊以切æ›è¦–覺狀態。\n"
+"\n"
+"眼é¡åœ–示:Gizmo å¯è¦‹ã€‚\n"
+"眼é¡åœ–示:Gizmo éš±è—。\n"
+"åŠé–‹çœ¼é¡ï¼šGizmo 也å¯ä»¥é€šéŽ Opaque Surface(「X-Ray - Xå…‰ã€ï¼‰å¯è¦‹ã€‚"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Nodes To Floor"
-msgstr "將節點æ•æ‰åˆ°åœ°é¢"
+msgstr "å¸é™„節點至地é¢"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Couldn't find a solid floor to snap the selection to."
-msgstr ""
+msgstr "找ä¸åˆ°å¯å¸é™„所é¸é …ç›®çš„å …å›ºåœ°æ¿ (Solid Floor)。"
#: editor/plugins/spatial_editor_plugin.cpp
msgid ""
@@ -7708,11 +7315,13 @@ msgid ""
"Alt+Drag: Move\n"
"Alt+RMB: Depth list selection"
msgstr ""
+"拖移:旋轉\n"
+"Alt+拖移:移動\n"
+"Alt+å³éµé»žæ“Šï¼šå±•é–‹é¸æ“‡åˆ—表"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Use Local Space"
-msgstr "本地空間模å¼ï¼ˆ%s)"
+msgstr "使用本機空間"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Use Snap"
@@ -7720,7 +7329,7 @@ msgstr "使用å¸é™„"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Bottom View"
-msgstr "底部視圖"
+msgstr "仰視圖"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Top View"
@@ -7743,25 +7352,24 @@ msgid "Right View"
msgstr "å³è¦–圖"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Switch Perspective/Orthogonal View"
-msgstr "åˆ‡æ› æŠ•å½±/正交 視圖"
+msgstr "切æ›æŠ•å½±æˆ–正交視圖"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Insert Animation Key"
-msgstr "æ’入動畫幀"
+msgstr "æ’入動畫關éµå½±æ ¼"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Focus Origin"
-msgstr ""
+msgstr "èšç„¦åŽŸé»ž"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Focus Selection"
-msgstr ""
+msgstr "èšç„¦æ‰€é¸"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Toggle Freelook"
-msgstr "切æ›è‡ªç”±è§€å¯Ÿæ¨¡å¼"
+msgstr "é–‹å•Ÿï¼é—œé–‰è‡ªç”±è¦–圖"
#: editor/plugins/spatial_editor_plugin.cpp
#: editor/plugins/visual_shader_editor_plugin.cpp
@@ -7769,41 +7377,40 @@ msgid "Transform"
msgstr "變æ›"
#: editor/plugins/spatial_editor_plugin.cpp
-#, fuzzy
msgid "Snap Object to Floor"
-msgstr "å°‡å°è±¡å¸é™„到地æ¿"
+msgstr "å¸é™„物件至地æ¿"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Transform Dialog..."
-msgstr "轉æ›å°è©±æ¡†..。"
+msgstr "變æ›å°è©±æ¡†..."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "1 Viewport"
-msgstr "1個視å£"
+msgstr "1 個檢視å€"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "2 Viewports"
-msgstr "2個視å£"
+msgstr "2 個檢視å€"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "2 Viewports (Alt)"
-msgstr "2å€‹è¦–å£ (Alt)"
+msgstr "2 個檢視å€ï¼ˆæ›¿ä»£ï¼‰"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "3 Viewports"
-msgstr "3個視å£"
+msgstr "3 個檢視å€"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "3 Viewports (Alt)"
-msgstr "3å€‹è¦–å£ (Alt)"
+msgstr "3 個檢視å€ï¼ˆæ›¿ä»£ï¼‰"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "4 Viewports"
-msgstr "4個視å£"
+msgstr "4 個檢視å€"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Gizmos"
-msgstr ""
+msgstr "Gizmo"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Origin"
@@ -7815,9 +7422,8 @@ msgstr "顯示網格"
#: editor/plugins/spatial_editor_plugin.cpp
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Settings..."
-msgstr "設定"
+msgstr "設定..."
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Snap Settings"
@@ -7825,7 +7431,7 @@ msgstr "å¸é™„設定"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Translate Snap:"
-msgstr "移動å¸é™„"
+msgstr "移動å¸é™„:"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rotate Snap (deg.):"
@@ -7833,11 +7439,11 @@ msgstr "旋轉å¸é™„(度):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Scale Snap (%):"
-msgstr "縮放å¸é™„ (%):"
+msgstr "縮放å¸é™„(%):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Viewport Settings"
-msgstr "視å€è¨­å®š"
+msgstr "檢視å€è¨­å®š"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Perspective FOV (deg.):"
@@ -7845,27 +7451,27 @@ msgstr "é€è¦–視角(度):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Z-Near:"
-msgstr "查看Z-Near:"
+msgstr "檢視 Z-Near:"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "View Z-Far:"
-msgstr "查看 Z-Far:"
+msgstr "檢視 Z-Far:"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Transform Change"
-msgstr ""
+msgstr "修改變æ›"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Translate:"
-msgstr ""
+msgstr "移動:"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Rotate (deg.):"
-msgstr "旋轉 (度):"
+msgstr "旋轉(度):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Scale (ratio):"
-msgstr "縮放(比例):"
+msgstr "縮放(比例):"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Transform Type"
@@ -7873,186 +7479,163 @@ msgstr "轉æ›é¡žåž‹"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Pre"
-msgstr "å‰"
+msgstr "å‰ç½®"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Post"
-msgstr "發佈"
+msgstr "後置"
#: editor/plugins/spatial_editor_plugin.cpp
msgid "Nameless gizmo"
-msgstr "未命åçš„gizmo"
+msgstr "未命åçš„ Gizmo"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Create Mesh2D"
-msgstr "創建2D網格"
+msgstr "建立網格 2D (Mesh2D)"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Mesh2D Preview"
-msgstr "創建網格é è¦½"
+msgstr "建立網格 2D (Mesh2D) é è¦½"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Create Polygon2D"
-msgstr "創建3D多邊形"
+msgstr "建立多邊形 2D (Polygon2D)"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Polygon2D Preview"
-msgstr ""
+msgstr "é è¦½å¤šé‚Šå½¢ 2D (Polygon2D)"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Create CollisionPolygon2D"
-msgstr "創建碰撞多邊形"
+msgstr "建立碰撞多邊形 2D (CollisionPolygon2D)"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "CollisionPolygon2D Preview"
-msgstr "創建碰撞多邊形"
+msgstr "碰撞多邊形 2D (CollisionPolygon2D) é è¦½"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Create LightOccluder2D"
-msgstr "創建é®å…‰å¤šé‚Šå½¢"
+msgstr "建立é®å…‰ 2D (LightOccluder2D)"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "LightOccluder2D Preview"
-msgstr "創建é®å…‰å¤šé‚Šå½¢"
+msgstr "é®å…‰ 2D (LightOccluder2D) é è¦½"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Sprite is empty!"
-msgstr "Sprite 是空的ï¼"
+msgstr "Sprite 為空ï¼"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Can't convert a sprite using animation frames to mesh."
-msgstr ""
+msgstr "無法使用動畫影格將 Sprite 轉æ›ç‚ºç¶²æ ¼ã€‚"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Invalid geometry, can't replace by mesh."
-msgstr "無效的幾何圖形,無法用網格替æ›ã€‚"
+msgstr "無效的幾何圖形,無法以網格å–代。"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Convert to Mesh2D"
-msgstr "轉æ›ç‚º2D網格"
+msgstr "轉æ›ç‚ºç¶²æ ¼ 2D (Mesh2D)"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Invalid geometry, can't create polygon."
-msgstr "無效的幾何圖形,無法用網格替æ›ã€‚"
+msgstr "無效的幾何圖形,無法建立多邊形。"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Convert to Polygon2D"
-msgstr "轉æ›ç‚º2D網格"
+msgstr "轉æ›ç‚ºå¤šé‚Šå½¢ 2D (Polygon2D)"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Invalid geometry, can't create collision polygon."
-msgstr "無效的幾何圖形,無法用網格替æ›ã€‚"
+msgstr "無效的幾何圖形,無法建立碰撞多邊形。"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Create CollisionPolygon2D Sibling"
-msgstr "創建碰撞多邊形"
+msgstr "建立碰撞多邊形 2D (CollisionPolygon2D) åŒç´š"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Invalid geometry, can't create light occluder."
-msgstr "無效的幾何圖形,無法用網格替æ›ã€‚"
+msgstr "無效的幾何圖形,無法建立é®å…‰ã€‚"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Create LightOccluder2D Sibling"
-msgstr "創建é®å…‰å¤šé‚Šå½¢"
+msgstr "建立é®å…‰ 2D (LightOccluder2D) åŒç´š"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Sprite"
-msgstr ""
+msgstr "Sprite"
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Simplification: "
msgstr "簡化: "
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Shrink (Pixels): "
-msgstr "擴展(åƒç´ ï¼‰: "
+msgstr "收縮(åƒç´ ï¼‰ï¼š "
#: editor/plugins/sprite_editor_plugin.cpp
msgid "Grow (Pixels): "
-msgstr "擴展(åƒç´ ï¼‰: "
+msgstr "擴展(åƒç´ ï¼‰ï¼š "
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Update Preview"
msgstr "æ›´æ–°é è¦½"
#: editor/plugins/sprite_editor_plugin.cpp
-#, fuzzy
msgid "Settings:"
msgstr "設定:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "No Frames Selected"
-msgstr "å¹€é¸æ“‡"
+msgstr "未é¸æ“‡å½±æ ¼"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Add %d Frame(s)"
-msgstr "添加幀"
+msgstr "新增 %d 個影格"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Add Frame"
-msgstr "添加幀"
+msgstr "新增幀"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Unable to load images"
-msgstr "載入資æºå¤±æ•—。"
+msgstr "無法載入圖片"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "ERROR: Couldn't load frame resource!"
-msgstr "錯誤:無法加載幀資æºï¼"
+msgstr "錯誤:無法載入影格資æºï¼"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Resource clipboard is empty or not a texture!"
-msgstr "資æºå‰ªè²¼æ¿ç‚ºç©ºæˆ–ä¸æ˜¯ç´‹ç†ï¼"
+msgstr "資æºå‰ªè²¼ç°¿ç‚ºç©ºæˆ–éžç´‹ç†è²¼åœ–ï¼"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Paste Frame"
-msgstr "粘貼幀"
+msgstr "貼上影格"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Add Empty"
-msgstr "添加空白幀"
+msgstr "新增空白"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Change Animation FPS"
-msgstr "更改動畫fps"
+msgstr "更改動畫 FPS"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "(empty)"
msgstr "(空)"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Move Frame"
-msgstr "粘貼幀"
+msgstr "貼上影格"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Animations:"
msgstr "動畫:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "New Animation"
-msgstr "æ–°å‹•ç•«"
+msgstr "新增動畫"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Speed (FPS):"
@@ -8063,75 +7646,68 @@ msgid "Loop"
msgstr "循環"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Animation Frames:"
msgstr "動畫幀:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Add a Texture from File"
-msgstr "將紋ç†æ·»åŠ åˆ°ç£è²¼é›†ã€‚"
+msgstr "自檔案新增紋ç†"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Add Frames from a Sprite Sheet"
-msgstr ""
+msgstr "自 Sprite 表新增影格"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Insert Empty (Before)"
-msgstr "æ’入空白幀(之å‰ï¼‰"
+msgstr "在å‰é¢æ’入空白"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Insert Empty (After)"
-msgstr "æ’入空白幀(之åŽï¼‰"
+msgstr "在後é¢æ’入空白"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Move (Before)"
-msgstr "移動(以å‰ï¼‰"
+msgstr "å‘å‰ç§»å‹•"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "Move (After)"
-msgstr "移動(之後)"
+msgstr "å‘後移動"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Select Frames"
-msgstr "é¸æ“‡æ¨¡å¼"
+msgstr "é¸æ“‡å½±æ ¼"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Horizontal:"
-msgstr "水平翻轉"
+msgstr "水平:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Vertical:"
-msgstr "頂點"
+msgstr "垂直:"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Select/Clear All Frames"
-msgstr "é¸æ“‡å…¨éƒ¨"
+msgstr "é¸æ“‡ï¼æ¸…除所有影格"
#: editor/plugins/sprite_frames_editor_plugin.cpp
-#, fuzzy
msgid "Create Frames from Sprite Sheet"
-msgstr "從場景創建"
+msgstr "自 Sprite 表建立幀"
#: editor/plugins/sprite_frames_editor_plugin.cpp
msgid "SpriteFrames"
-msgstr ""
+msgstr "SpriteFrames(Sprite 影格)"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Set Region Rect"
-msgstr "設置紋ç†å€åŸŸ"
+msgstr "設定å€åŸŸçŸ©å½¢ (Region Rect)"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Set Margin"
-msgstr "設置邊è·"
+msgstr "設置外邊è·"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Snap Mode:"
-msgstr "å¸é™„模å¼:"
+msgstr "å¸é™„模å¼ï¼š"
#: editor/plugins/texture_region_editor_plugin.cpp
#: scene/resources/visual_shader.cpp
@@ -8148,11 +7724,11 @@ msgstr "網格å¸é™„"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Auto Slice"
-msgstr "自動剪切"
+msgstr "自動剪è£"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Offset:"
-msgstr ""
+msgstr "å移:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Step:"
@@ -8160,76 +7736,71 @@ msgstr "步驟:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "Sep.:"
-msgstr ""
+msgstr "分隔線:"
#: editor/plugins/texture_region_editor_plugin.cpp
msgid "TextureRegion"
-msgstr ""
+msgstr "ç´‹ç†å€åŸŸ (TextureRegion)"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Add All Items"
-msgstr "添加所有項目"
+msgstr "新增所有項目"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Add All"
-msgstr "全部添加"
+msgstr "新增全部"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Remove All Items"
-msgstr "删除所有項目"
+msgstr "移除所有項目"
#: editor/plugins/theme_editor_plugin.cpp editor/project_manager.cpp
-#, fuzzy
msgid "Remove All"
-msgstr "全部删除"
+msgstr "移除全部"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Edit Theme"
-msgstr "編輯主題…"
+msgstr "編輯主題"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Theme editing menu."
-msgstr "主題編輯èœå–®ã€‚"
+msgstr "主題編輯é¸å–®ã€‚"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Add Class Items"
-msgstr "添加類項"
+msgstr "新增類別項目"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Remove Class Items"
-msgstr "删除類項"
+msgstr "刪除類別項目"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Create Empty Template"
-msgstr ""
+msgstr "建立空白樣æ¿"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Create Empty Editor Template"
-msgstr ""
+msgstr "建立空白編輯器樣æ¿"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Create From Current Editor Theme"
-msgstr "從當å‰ç·¨è¼¯å™¨ä¸»é¡Œæ¨¡æ¿å‰µå»º"
+msgstr "自目å‰ç·¨è¼¯å™¨ä¸»é¡Œå»ºç«‹"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Toggle Button"
-msgstr "切æ›è‡ªå‹•æ’­æ”¾"
+msgstr "é–‹å•Ÿï¼é—œé–‰æŒ‰éˆ•"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Disabled Button"
-msgstr "å·²åœç”¨"
+msgstr "å·²åœç”¨çš„按鈕"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Item"
msgstr "é …ç›®"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Disabled Item"
-msgstr "å·²åœç”¨"
+msgstr "å·²åœç”¨çš„é …ç›®"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Check Item"
@@ -8241,29 +7812,27 @@ msgstr "已檢查的項目"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Radio Item"
-msgstr "å–®é¸é …ç›®"
+msgstr "å–®é¸é …"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Checked Radio Item"
-msgstr "é¸ä¸­çš„å–®é¸é …ç›®"
+msgstr "å·²é¸ä¸­çš„å–®é¸é …"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Named Sep."
-msgstr ""
+msgstr "帶å稱的分隔線"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Submenu"
-msgstr ""
+msgstr "å­é¸å–®"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Subitem 1"
-msgstr "é …ç›®"
+msgstr "å­é …ç›® 1"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Subitem 2"
-msgstr "é …ç›®"
+msgstr "å­é …ç›® 2"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Has"
@@ -8274,9 +7843,8 @@ msgid "Many"
msgstr "許多"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Disabled LineEdit"
-msgstr "å·²åœç”¨"
+msgstr "å·²åœç”¨çš„行編輯"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Tab 1"
@@ -8291,13 +7859,12 @@ msgid "Tab 3"
msgstr "標籤 3"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Editable Item"
-msgstr "編輯主題…"
+msgstr "å¯ç·¨è¼¯çš„é …ç›®"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Subtree"
-msgstr ""
+msgstr "å­æ¨¹"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Has,Many,Options"
@@ -8305,12 +7872,12 @@ msgstr "有, 許多, é¸é …"
#: editor/plugins/theme_editor_plugin.cpp
msgid "Data Type:"
-msgstr "數據類型:"
+msgstr "資料類型:"
#: editor/plugins/theme_editor_plugin.cpp
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Icon"
-msgstr "圖標"
+msgstr "圖示"
#: editor/plugins/theme_editor_plugin.cpp editor/rename_dialog.cpp
msgid "Style"
@@ -8325,27 +7892,25 @@ msgid "Color"
msgstr "é¡è‰²"
#: editor/plugins/theme_editor_plugin.cpp
-#, fuzzy
msgid "Theme File"
-msgstr "主題"
+msgstr "主題檔"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Erase Selection"
-msgstr "擦除é¸ä¸­"
+msgstr "清除所é¸"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Fix Invalid Tiles"
-msgstr "修復無效的ç£è²¼"
+msgstr "修正無效的圖塊"
#: editor/plugins/tile_map_editor_plugin.cpp
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cut Selection"
-msgstr "切割é¸æ“‡"
+msgstr "剪下所é¸"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Paint TileMap"
-msgstr "繪製磚塊地圖"
+msgstr "繪製圖塊地圖"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Line Draw"
@@ -8353,111 +7918,103 @@ msgstr "線性繪製"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Rectangle Paint"
-msgstr "繪製矩形"
+msgstr "矩形繪製"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Bucket Fill"
-msgstr "油漆桶填充"
+msgstr "油漆桶填滿"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Erase TileMap"
-msgstr "擦除磚塊地圖"
+msgstr "清除圖塊地圖"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Find Tile"
-msgstr "查找ç£è²¼"
+msgstr "æœå°‹åœ–å¡Š"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Transpose"
-msgstr "轉置"
+msgstr "切æ›è¡Œåˆ—(縱橫)顯示"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Disable Autotile"
-msgstr ""
+msgstr "ç¦ç”¨è‡ªå‹•åœ–å¡Š"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Enable Priority"
-msgstr "編輯ç£è²¼å„ªå…ˆç´š"
+msgstr "啟用優先級"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Filter tiles"
-msgstr "篩é¸æª”案..."
+msgstr "éŽæ¿¾åœ–å¡Š"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Give a TileSet resource to this TileMap to use its tiles."
-msgstr ""
+msgstr "為圖塊地圖設定圖塊集資æºä»¥ä½¿ç”¨å…¶åœ–塊。"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Paint Tile"
-msgstr "繪製ç£è²¼"
+msgstr "繪製圖塊"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid ""
"Shift+LMB: Line Draw\n"
"Shift+Ctrl+LMB: Rectangle Paint"
msgstr ""
+"Shift+å·¦éµï¼šç›´ç·šç¹ªè£½\n"
+"Shift+Ctrl+å·¦éµï¼šçŸ©å½¢ç¹ªåœ–"
#: editor/plugins/tile_map_editor_plugin.cpp
msgid "Pick Tile"
-msgstr "é¸æ“‡ç£è²¼"
+msgstr "é¸æ“‡åœ–å¡Š"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Rotate Left"
msgstr "å‘左旋轉"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Rotate Right"
msgstr "å‘å³æ—‹è½‰"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Flip Horizontally"
msgstr "水平翻轉"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Flip Vertically"
msgstr "垂直翻轉"
#: editor/plugins/tile_map_editor_plugin.cpp
-#, fuzzy
msgid "Clear Transform"
msgstr "清除變æ›"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Add Texture(s) to TileSet."
-msgstr "將紋ç†æ·»åŠ åˆ°ç£è²¼é›†ã€‚"
+msgstr "新增紋ç†è‡³åœ–塊集。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Remove selected Texture from TileSet."
-msgstr "從ç£è²¼é›†ä¸­åˆªé™¤é¸å®šçš„ç´‹ç†ã€‚"
+msgstr "自圖塊集移除所é¸çš„ç´‹ç†ã€‚"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Create from Scene"
-msgstr "從場景創建"
+msgstr "自場景建立"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Merge from Scene"
-msgstr "從場景åˆä½µ"
+msgstr "自場景åˆä½µ"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "New Single Tile"
-msgstr ""
+msgstr "新增單一圖塊"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "New Autotile"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "新增自動圖塊"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "New Atlas"
-msgstr "新建 %s"
+msgstr "新增åˆé›†"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Next Coordinate"
@@ -8465,188 +8022,172 @@ msgstr "下一個座標"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Select the next shape, subtile, or Tile."
-msgstr "é¸æ“‡ä¸‹ä¸€å€‹å½¢ç‹€ã€å­ç£è²¼æˆ–ç£è²¼ã€‚"
+msgstr "é¸æ“‡ä¸‹ä¸€å€‹å½¢ç‹€ã€å­åœ–å¡Šã€æˆ–圖塊。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Previous Coordinate"
msgstr "上一個座標"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Select the previous shape, subtile, or Tile."
-msgstr "é¸æ“‡ä¸Šä¸€å€‹å½¢ç‹€ã€å­ç£è²¼æˆ–ç£è²¼ã€‚"
+msgstr "é¸æ“‡å‰ä¸€å€‹å½¢ç‹€ã€å­åœ–å¡Šã€æˆ–圖塊。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Region"
-msgstr "旋轉模å¼"
+msgstr "å€åŸŸ"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Collision"
-msgstr "æ’值模å¼"
+msgstr "碰撞"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Occlusion"
-msgstr "編輯é®æ“‹å¤šé‚Šå½¢"
+msgstr "é®æ“‹"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Navigation"
-msgstr "創建導航網格"
+msgstr "導航"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Bitmask"
-msgstr "旋轉模å¼"
+msgstr "é®ç½©"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Priority"
-msgstr "導出模å¼:"
+msgstr "優先級"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Z Index"
-msgstr "平移模å¼"
+msgstr "Z 索引"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Region Mode"
-msgstr "旋轉模å¼"
+msgstr "å€åŸŸæ¨¡å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Collision Mode"
-msgstr "æ’值模å¼"
+msgstr "碰撞模å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Occlusion Mode"
-msgstr "編輯é®æ“‹å¤šé‚Šå½¢"
+msgstr "é®æ“‹æ¨¡å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Navigation Mode"
-msgstr "創建導航網格"
+msgstr "導航模å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Bitmask Mode"
-msgstr "旋轉模å¼"
+msgstr "優先模å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Priority Mode"
-msgstr "導出模å¼:"
+msgstr "優先模å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Icon Mode"
-msgstr "平移模å¼"
+msgstr "圖示模å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Z Index Mode"
-msgstr "平移模å¼"
+msgstr "Z 索引模å¼"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Copy bitmask."
-msgstr "複製ä½æŽ©ç¢¼ã€‚"
+msgstr "複製ä½å…ƒé®ç½©ã€‚"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Paste bitmask."
-msgstr "貼上åƒæ•¸"
+msgstr "貼上ä½å…ƒé®ç½©ã€‚"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Erase bitmask."
-msgstr "擦除ä½æŽ©ç¢¼."
+msgstr "清除ä½å…ƒé®ç½©ã€‚"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create a new rectangle."
-msgstr "創建新矩形。"
+msgstr "建立新矩形。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create a new polygon."
-msgstr "創建新多邊形。"
+msgstr "建立新多邊形。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Keep polygon inside region Rect."
-msgstr "將多邊形ä¿ç•™åœ¨å€åŸŸå…§ã€‚"
+msgstr "ä¿æŒå¤šé‚Šå½¢åœ¨å€åŸŸçŸ©å½¢ (Rect) 內。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Enable snap and show grid (configurable via the Inspector)."
-msgstr "啟用å¸é™„和顯示網格 (å¯é€šéŽå±¬æ€§é¢æ¿é…ç½®)。"
+msgstr "啟用å¸é™„與顯示網格(å¯é€šéŽå±¬æ€§é¢æ¿è¨­å®šï¼‰ã€‚"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Display Tile Names (Hold Alt Key)"
-msgstr "顯示ç£è²¼å稱 (æŒ‰ä½ ALT éµ)"
+msgstr "顯示圖塊åç¨±ï¼ˆæŒ‰ä½ Alt éµï¼‰"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
"Add or select a texture on the left panel to edit the tiles bound to it."
-msgstr ""
+msgstr "在左å´é¢æ¿æ–°å¢žæˆ–é¸æ“‡ç´‹ç†ä»¥ç·¨è¼¯èˆ‡å…¶ç¶å®šçš„圖塊。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Remove selected texture? This will remove all tiles which use it."
-msgstr "刪除é¸å®šçš„ç´‹ç†ï¼Ÿé€™å°‡åˆªé™¤ä½¿ç”¨å®ƒçš„所有ç£è²¼ã€‚"
+msgstr "是å¦åˆªé™¤æ‰€é¸ç´‹ç†ï¼Ÿå°‡ä¸€ä½µç§»é™¤æ‰€æœ‰ä½¿ç”¨å…¶ä¹‹åœ–塊。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "You haven't selected a texture to remove."
-msgstr "您尚未é¸æ“‡è¦åˆªé™¤çš„ç´‹ç†ã€‚"
+msgstr "尚未é¸æ“‡æ¬²ç§»é™¤ä¹‹ç´‹ç†ã€‚"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Create from scene? This will overwrite all current tiles."
-msgstr "從場景創建?這將覆蓋所有當å‰ç£è²¼ã€‚"
+msgstr "è¦è‡ªå ´æ™¯å»ºç«‹å—Žï¼Ÿå°‡è¤‡å¯«ç›®å‰çš„圖塊。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Merge from scene?"
-msgstr "確定åˆä½µå ´æ™¯ï¼Ÿ"
+msgstr "è¦è‡ªå ´æ™¯åˆä½µå—Žï¼Ÿ"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Remove Texture"
-msgstr "刪除紋ç†"
+msgstr "移除紋ç†"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "%s file(s) were not added because was already on the list."
-msgstr ""
+msgstr "由於有 %s 個檔案已在列表上,未被新增。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
"Drag handles to edit Rect.\n"
"Click on another Tile to edit it."
msgstr ""
+"拖移手柄以編輯矩形 (Rect)。\n"
+"點擊其他圖塊以進行編輯。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Delete selected Rect."
-msgstr "删除所é¸çš„Rect。"
+msgstr "删除所é¸çš„矩形 (Rect)。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid ""
"Select current edited sub-tile.\n"
"Click on another Tile to edit it."
-msgstr "新增資料夾"
+msgstr ""
+"é¸æ“‡ç›®å‰ç·¨è¼¯çš„å­åœ–塊。\n"
+"點擊å¦ä¸€å€‹åœ–塊以進行編輯。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Delete polygon."
msgstr "刪除多邊形。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid ""
"LMB: Set bit on.\n"
"RMB: Set bit off.\n"
"Shift+LMB: Set wildcard bit.\n"
"Click on another Tile to edit it."
-msgstr "新增資料夾"
+msgstr ""
+"å·¦éµé»žæ“Šï¼šé–‹å•Ÿä½å…ƒã€‚\n"
+"å³éµé»žæ“Šï¼šé—œé–‰ä½å…ƒã€‚\n"
+"Shift+å·¦éµé»žæ“Šï¼šè¨­å®šé€šé…ä½å…ƒã€‚\n"
+"點擊å¦ä¸€å€‹åœ–塊以進行編輯。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
@@ -8654,59 +8195,60 @@ msgid ""
"bindings.\n"
"Click on another Tile to edit it."
msgstr ""
+"é¸æ“‡æ¬²ä½œç‚ºåœ–示使用的å­åœ–塊,亦將用於無效的自動圖塊ç¶å®šä¸Šã€‚\n"
+"點擊å¦ä¸€å€‹åœ–塊以進行編輯。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid ""
"Select sub-tile to change its priority.\n"
"Click on another Tile to edit it."
msgstr ""
+"é¸æ“‡å­åœ–塊以更改其優先級。\n"
+"點擊å¦ä¸€å€‹åœ–塊以進行編輯。"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid ""
"Select sub-tile to change its z index.\n"
"Click on another Tile to edit it."
-msgstr "新增資料夾"
+msgstr ""
+"é¸æ“‡å­åœ–塊以修改其 Z 索引。\n"
+"點擊å¦ä¸€å€‹åœ–塊以進行編輯。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Set Tile Region"
-msgstr "設置ç£è²¼å€åŸŸ"
+msgstr "é¸æ“‡åœ–å¡Šå€åŸŸ"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create Tile"
-msgstr "創建ç£è²¼"
+msgstr "建立圖塊"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Set Tile Icon"
-msgstr "設定ç£è²¼åœ–標"
+msgstr "設定ç£è²¼åœ–示"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Edit Tile Bitmask"
-msgstr "編輯ç£è²¼ä½æŽ©ç¢¼"
+msgstr "編輯圖塊ä½å…ƒé®ç½©"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Edit Collision Polygon"
msgstr "編輯碰撞多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Edit Occlusion Polygon"
msgstr "編輯é®æ“‹å¤šé‚Šå½¢"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Edit Navigation Polygon"
-msgstr "新增資料夾"
+msgstr "編輯導航多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Paste Tile Bitmask"
-msgstr "粘貼ç£è²¼ä½æŽ©ç¢¼"
+msgstr "貼上圖塊ä½å…ƒé®ç½©"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Clear Tile Bitmask"
-msgstr "清除ç£è²¼ä½æŽ©ç¢¼"
+msgstr "清除圖塊ä½å…ƒé®ç½©"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Make Polygon Concave"
@@ -8718,12 +8260,11 @@ msgstr "使多邊形凸起"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Remove Tile"
-msgstr "移除ç£è²¼"
+msgstr "移除圖塊"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Remove Collision Polygon"
-msgstr "刪除碰撞多邊形"
+msgstr "移除碰撞多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Remove Occlusion Polygon"
@@ -8735,255 +8276,227 @@ msgstr "刪除導航多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Edit Tile Priority"
-msgstr "編輯ç£è²¼å„ªå…ˆç´š"
+msgstr "編輯圖塊優先級"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "Edit Tile Z Index"
-msgstr ""
+msgstr "編輯圖塊 Z 索引"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Make Convex"
-msgstr "使多邊形凸起"
+msgstr "製作凸多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Make Concave"
-msgstr "使多邊形塌陷"
+msgstr "製作凹多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create Collision Polygon"
-msgstr "創建碰撞多邊形"
+msgstr "建立碰撞多邊形"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "Create Occlusion Polygon"
-msgstr "創建é®æ“‹å¤šé‚Šå½¢"
+msgstr "建立é®æ“‹å¤šé‚Šå½¢"
#: editor/plugins/tile_set_editor_plugin.cpp
-#, fuzzy
msgid "This property can't be changed."
-msgstr "無法更改此屬性。"
+msgstr "該屬性無法修改。"
#: editor/plugins/tile_set_editor_plugin.cpp
msgid "TileSet"
-msgstr ""
+msgstr "圖塊集"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "No VCS addons are available."
-msgstr ""
+msgstr "ç„¡å¯ç”¨çš„版本控制 (VCS) 擴充功能。"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Error"
-msgstr ""
+msgstr "錯誤"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "No commit message was provided"
-msgstr ""
+msgstr "未æä¾›æ交訊æ¯"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "No files added to stage"
-msgstr ""
+msgstr "é å­˜å€ç„¡æª”案"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Commit"
-msgstr "社å€"
+msgstr "æ交"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "VCS Addon is not initialized"
-msgstr ""
+msgstr "VCS 擴充功能尚未åˆå§‹åŒ–"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Version Control System"
-msgstr ""
+msgstr "版本控制系統 (VCS)"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Initialize"
-msgstr "首字æ¯å¤§å¯«"
+msgstr "åˆå§‹åŒ–"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Staging area"
-msgstr ""
+msgstr "é å­˜å€"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Detect new changes"
-msgstr "創建新矩形。"
+msgstr "åµæ¸¬æ–°æ”¹å‹•"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Changes"
-msgstr "æ›´æ›"
+msgstr "改動"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Modified"
-msgstr ""
+msgstr "已修改"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Renamed"
-msgstr "é‡å‘½å"
+msgstr "é‡æ–°å‘½å"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Deleted"
-msgstr "刪除"
+msgstr "已刪除"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Typechange"
-msgstr "æ›´æ›"
+msgstr "æ ¼å¼æ›´æ”¹"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Stage Selected"
-msgstr "縮放所é¸"
+msgstr "é å­˜æ‰€é¸"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Stage All"
-msgstr "全部ä¿å­˜"
+msgstr "é å­˜å…¨éƒ¨"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Add a commit message"
-msgstr ""
+msgstr "新增一個æ交訊æ¯"
#: editor/plugins/version_control_editor_plugin.cpp
-#, fuzzy
msgid "Commit Changes"
-msgstr "åŒæ­¥è…³æœ¬çš„變更"
+msgstr "æ交改動"
#: editor/plugins/version_control_editor_plugin.cpp
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Status"
-msgstr ""
+msgstr "狀態"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "View file diffs before committing them to the latest version"
-msgstr ""
+msgstr "在æ交至最新版本å‰æª¢è¦–檔案的差異"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "No file diff is active"
-msgstr ""
+msgstr "無有效的檔案差異"
#: editor/plugins/version_control_editor_plugin.cpp
msgid "Detect changes in file diff"
-msgstr ""
+msgstr "在檔案差異中åµæ¸¬æ”¹å‹•"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "(GLES3 only)"
-msgstr ""
+msgstr "ï¼ˆåƒ…é™ GLES3)"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Add Output"
-msgstr "添加輸入"
+msgstr "新增輸出"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar"
-msgstr "縮放:"
+msgstr "ç´”é‡ Scalar"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Vector"
-msgstr "屬性é¢æ¿"
+msgstr "å‘é‡ Vector"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Boolean"
-msgstr ""
+msgstr "布林 Boolean"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Sampler"
-msgstr ""
+msgstr "採樣 Sampler"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Add input port"
-msgstr "添加輸入"
+msgstr "新增輸入埠å£"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Add output port"
-msgstr ""
+msgstr "新增輸出埠å£"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Change input port type"
-msgstr "更改é è¨­é¡žåž‹"
+msgstr "修改輸入埠å£é¡žåž‹"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Change output port type"
-msgstr "更改é è¨­é¡žåž‹"
+msgstr "修改輸出埠å£é¡žåž‹"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Change input port name"
-msgstr "更改動畫å稱:"
+msgstr "修改輸入埠å£å稱"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Change output port name"
-msgstr ""
+msgstr "修改輸出埠å£å稱"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Remove input port"
-msgstr "刪除點"
+msgstr "移除輸入埠å£"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Remove output port"
-msgstr "刪除點"
+msgstr "移除輸出埠å£"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Set expression"
-msgstr "設置ç£è²¼å€åŸŸ"
+msgstr "設定表示å¼"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Resize VisualShader node"
-msgstr "視覺化著色器"
+msgstr "調整視覺著色器 (VisualShader) 節點大å°"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Set Uniform Name"
-msgstr "設置統一å稱"
+msgstr "設定å‡å‹»å稱"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Set Input Default Port"
-msgstr "設置輸入é è¨­ç«¯å£"
+msgstr "設定輸入é è¨­åŸ å£"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Add Node to Visual Shader"
-msgstr "將節點添加到å¯è¦–化著色器"
+msgstr "將節點新增至視覺著色器"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Duplicate Nodes"
-msgstr "複製節點"
+msgstr "é‡è¤‡ç¯€é»ž"
#: editor/plugins/visual_shader_editor_plugin.cpp
#: modules/visual_script/visual_script_editor.cpp
msgid "Paste Nodes"
-msgstr ""
+msgstr "貼上節點"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Delete Nodes"
-msgstr "刪除"
+msgstr "刪除節點"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Visual Shader Input Type Changed"
-msgstr "視覺著色器輸入類型已更改"
+msgstr "已修改視覺著色器輸入類型"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vertex"
msgstr "頂點"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Fragment"
msgstr "片段"
@@ -8992,380 +8505,368 @@ msgid "Light"
msgstr "燈光"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Show resulted shader code."
-msgstr "創建節點"
+msgstr "顯示產生的著色器程å¼ç¢¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Create Shader Node"
-msgstr "創建節點"
+msgstr "建立著色器節點"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Color function."
-msgstr "轉到函數"
+msgstr "é¡è‰²å‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Color operator."
-msgstr ""
+msgstr "色彩é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Grayscale function."
-msgstr "建立函å¼"
+msgstr "ç°éšŽå‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Converts HSV vector to RGB equivalent."
-msgstr ""
+msgstr "å°‡ HSV å‘é‡è½‰ç‚ºåŒç­‰ä¹‹ RGB。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Converts RGB vector to HSV equivalent."
-msgstr ""
+msgstr "å°‡ RGB å‘é‡è½‰ç‚ºåŒç­‰è‡³ HSV。"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Sepia function."
-msgstr "建立函å¼"
+msgstr "æ·±è¤å‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Burn operator."
-msgstr ""
+msgstr "加深 (Burn) é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Darken operator."
-msgstr ""
+msgstr "暗化é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Difference operator."
-msgstr "僅差異"
+msgstr "差異é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Dodge operator."
-msgstr ""
+msgstr "加亮 (Dodge) é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "HardLight operator."
-msgstr "縮放(比例):"
+msgstr "å¼·å…‰ (HardLight) é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Lighten operator."
-msgstr ""
+msgstr "亮化é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Overlay operator."
-msgstr ""
+msgstr "疊加é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Screen operator."
-msgstr ""
+msgstr "濾色é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "SoftLight operator."
-msgstr ""
+msgstr "柔光é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Color constant."
-msgstr "固定"
+msgstr "色彩常數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Color uniform."
-msgstr "清除變æ›"
+msgstr "色彩å‡å‹»ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the boolean result of the %s comparison between two parameters."
-msgstr ""
+msgstr "回傳兩個åƒæ•¸é–“ %s 比較的布林çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Equal (==)"
-msgstr ""
+msgstr "等於 (==)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Greater Than (>)"
-msgstr ""
+msgstr "大於 (>)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Greater Than or Equal (>=)"
-msgstr ""
+msgstr "大於等於 (>=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns an associated vector if the provided scalars are equal, greater or "
"less."
-msgstr ""
+msgstr "è‹¥æ供的純é‡ç›¸ç­‰ã€å¤§æ–¼ã€æˆ–å°æ–¼ï¼Œå‰‡å›žå‚³ç›¸é—œçš„å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns the boolean result of the comparison between INF and a scalar "
"parameter."
-msgstr ""
+msgstr "回傳在 INF 與純é‡åƒæ•¸é–“比較的布林çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns the boolean result of the comparison between NaN and a scalar "
"parameter."
-msgstr ""
+msgstr "回傳在 NaN 與純é‡åƒæ•¸é–“比較的布林çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Less Than (<)"
-msgstr ""
+msgstr "å°æ–¼ (<)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Less Than or Equal (<=)"
-msgstr ""
+msgstr "å°æ–¼ç­‰æ–¼ (<=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Not Equal (!=)"
-msgstr ""
+msgstr "ä¸ç­‰æ–¼ (!=)"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns an associated vector if the provided boolean value is true or false."
-msgstr ""
+msgstr "è‹¥æ供的布林值為 true 或 false,則回傳相關的å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns an associated scalar if the provided boolean value is true or false."
-msgstr ""
+msgstr "è‹¥æ供的布林值為 true 或 false,則回傳相關的純é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the boolean result of the comparison between two parameters."
-msgstr ""
+msgstr "回傳兩個åƒæ•¸é–“比較的布林çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns the boolean result of the comparison between INF (or NaN) and a "
"scalar parameter."
-msgstr ""
+msgstr "回傳 INF(或 NaN)與一個純é‡é–“比較的布林çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Boolean constant."
-msgstr ""
+msgstr "布林常數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Boolean uniform."
-msgstr ""
+msgstr "布林å‡å‹»ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for all shader modes."
-msgstr ""
+msgstr "所有的著色器模å¼çš„「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Input parameter."
-msgstr "å¸é™„到父級節點"
+msgstr "輸入åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for vertex and fragment shader modes."
-msgstr ""
+msgstr "頂點與片段模å¼çš„「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for fragment and light shader modes."
-msgstr ""
+msgstr "片段與燈光著色器模å¼çš„「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for fragment shader mode."
-msgstr ""
+msgstr "片段著色器模å¼çš„「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for light shader mode."
-msgstr ""
+msgstr "燈光著色器模å¼çš„「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for vertex shader mode."
-msgstr ""
+msgstr "頂點著色器的「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "'%s' input parameter for vertex and fragment shader mode."
-msgstr ""
+msgstr "頂點或片段著色器的「%sã€è¼¸å…¥åƒæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar function."
-msgstr "縮放所é¸"
+msgstr "ç´”é‡å‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar operator."
-msgstr "縮放(比例):"
+msgstr "ç´”é‡é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "E constant (2.718282). Represents the base of the natural logarithm."
-msgstr ""
+msgstr "E 常數(2.718282)。表示自然å°æ•¸çš„底數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Epsilon constant (0.00001). Smallest possible scalar number."
-msgstr ""
+msgstr "ε (eplison) 常數 (0.00001)。最å°å¯ç”¨çš„ç´”é‡æ•¸å­—。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Phi constant (1.618034). Golden ratio."
-msgstr ""
+msgstr "Φ(Phi) 常數 (1.618034)。黃金比例。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Pi/4 constant (0.785398) or 45 degrees."
-msgstr ""
+msgstr "π (Pi)/4 常數 (0.785398) 或 45 度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Pi/2 constant (1.570796) or 90 degrees."
-msgstr ""
+msgstr "π (Pi)/2 常數 (1.570796) 或 95 度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Pi constant (3.141593) or 180 degrees."
-msgstr ""
+msgstr "π (Pi) 常數 (3.141593) 或 180 度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Tau constant (6.283185) or 360 degrees."
-msgstr ""
+msgstr "τ 常數 (6.283185) 或 360 度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Sqrt2 constant (1.414214). Square root of 2."
-msgstr ""
+msgstr "Sqrt2 常數 (1.414214)。2 的平方根。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the absolute value of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„絕å°å€¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the arc-cosine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å餘弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the inverse hyperbolic cosine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å雙曲餘弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the arc-sine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å正弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the inverse hyperbolic sine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å雙曲正弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the arc-tangent of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å正切值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the arc-tangent of the parameters."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å正切值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the inverse hyperbolic tangent of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„å雙曲正切值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Finds the nearest integer that is greater than or equal to the parameter."
-msgstr ""
+msgstr "尋找大於或等於該åƒæ•¸æœ€è¿‘的整數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Constrains a value to lie between two further values."
-msgstr ""
+msgstr "將值é™åˆ¶æ¬²å…©å€‹å€¼ä¹‹é–“。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the cosine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„餘弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the hyperbolic cosine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„雙曲餘弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Converts a quantity in radians to degrees."
-msgstr ""
+msgstr "將弧度轉æ›ç‚ºåº¦ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Base-e Exponential."
-msgstr ""
+msgstr "e 為底數的指數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Base-2 Exponential."
-msgstr ""
+msgstr "2 為底數的指數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Finds the nearest integer less than or equal to the parameter."
-msgstr ""
+msgstr "尋找å°æ–¼æˆ–等於åƒæ•¸æœ€è¿‘的整數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Computes the fractional part of the argument."
-msgstr ""
+msgstr "計算引數的å°æ•¸éƒ¨åˆ†ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the inverse of the square root of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„平方根的倒數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Natural logarithm."
-msgstr ""
+msgstr "自然å°æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Base-2 logarithm."
-msgstr ""
+msgstr "2 為底數的å°æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the greater of two values."
-msgstr ""
+msgstr "回傳兩個值中較大的值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the lesser of two values."
-msgstr ""
+msgstr "回傳兩個值中較å°çš„值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Linear interpolation between two scalars."
-msgstr ""
+msgstr "在兩個純é‡é–“åšç·šæ€§æ’值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the opposite value of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„相å值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "1.0 - scalar"
-msgstr ""
+msgstr "1.0 - ç´”é‡"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns the value of the first parameter raised to the power of the second."
-msgstr ""
+msgstr "回傳第一個åƒæ•¸çš„第二個åƒæ•¸å†ªæ¬¡çš„值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Converts a quantity in degrees to radians."
-msgstr ""
+msgstr "將度數轉æ›ç‚ºå¼§åº¦ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "1.0 / scalar"
-msgstr ""
+msgstr "1.0 / ç´”é‡"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Finds the nearest integer to the parameter."
-msgstr ""
+msgstr "尋找åƒæ•¸æœ€è¿‘的整數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Finds the nearest even integer to the parameter."
-msgstr ""
+msgstr "尋找åƒæ•¸æœ€è¿‘的整數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Clamps the value between 0.0 and 1.0."
-msgstr ""
+msgstr "將數值é™åˆ¶åœ¨ 0.0 與 1.0 之間。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Extracts the sign of the parameter."
-msgstr ""
+msgstr "抽å–åƒæ•¸çš„號(正號ï¼è² è™Ÿï¼‰ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the sine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„正弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the hyperbolic sine of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„雙曲正弦值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the square root of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„平方根。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9375,6 +8876,10 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"SmoothStep 函å¼( scalar(edge0),scalar(edge1),scalar(x) )。\n"
+"\n"
+"若「xã€å°æ–¼ã€Œedge0ã€å‰‡å›žå‚³ 0.0,若 x 大於「edge1ã€å‰‡å›žå‚³ 1.0。其餘值則回傳在 "
+"0.0 與 1.0 之間使用厄米多項å¼é€²è¡Œæ’值的çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9382,72 +8887,73 @@ msgid ""
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Step 函å¼( scalar(edge), scalar(x) )。\n"
+"\n"
+"若「xã€å°æ–¼ã€Œedgeã€å‰‡å›žå‚³ 0.0,å¦å‰‡å›žå‚³ 1.0。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the tangent of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„正切值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the hyperbolic tangent of the parameter."
-msgstr ""
+msgstr "回傳åƒæ•¸çš„雙曲正切值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Finds the truncated value of the parameter."
-msgstr ""
+msgstr "尋找åƒæ•¸çš„截斷值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Adds scalar to scalar."
-msgstr ""
+msgstr "將純é‡æ–°å¢žè‡³ç´”é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Divides scalar by scalar."
-msgstr ""
+msgstr "以純é‡é™¤ä»¥ç´”é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Multiplies scalar by scalar."
-msgstr ""
+msgstr "以純é‡ä¹˜ä»¥ç´”é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the remainder of the two scalars."
-msgstr ""
+msgstr "回傳兩個純é‡ç›¸é™¤çš„餘數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Subtracts scalar from scalar."
-msgstr ""
+msgstr "以純é‡æ¸›åŽ»ç´”é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Scalar constant."
-msgstr ""
+msgstr "ç´”é‡å¸¸æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Scalar uniform."
-msgstr "清除變æ›"
+msgstr "ç´”é‡å‡å‹»ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Perform the cubic texture lookup."
-msgstr ""
+msgstr "進行立方體紋ç†æœå°‹ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Perform the texture lookup."
-msgstr ""
+msgstr "進行紋ç†æœå°‹ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Cubic texture uniform lookup."
-msgstr ""
+msgstr "立方體紋ç†å‡å‹»æœå°‹ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "2D texture uniform lookup."
-msgstr ""
+msgstr "2D ç´‹ç†å‡å‹»æœå°‹ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "2D texture uniform lookup with triplanar."
-msgstr ""
+msgstr "以三平é¢é€²è¡Œ 2D ç´‹ç†å‡å‹»å°‹æ‰¾ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Transform function."
-msgstr "轉æ›å°è©±æ¡†..。"
+msgstr "轉æ›å‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9459,73 +8965,75 @@ msgid ""
"whose number of rows is the number of components in 'c' and whose number of "
"columns is the number of components in 'r'."
msgstr ""
+"計算一å°å‘é‡çš„外ç©ã€‚\n"
+"\n"
+"OuterProduct 將第一個åƒæ•¸ã€Œcã€è¦–為列å‘é‡ï¼ˆç”±ä¸€å€‹åˆ—的矩陣),第二個åƒæ•¸ã€Œrã€è¦–"
+"為行å‘é‡ï¼ˆç”±ä¸€å€‹è¡Œçš„矩陣),並ä¾ç·šæ€§ä»£æ•¸çŸ©é™£ä¹˜ä»¥ã€Œc * rã€ï¼Œç”¢ç”Ÿä¸€å€‹çŸ©é™£å…¶è¡Œæ•¸"
+"為「cã€ä¸­çš„組件,列數為「rã€çš„組件。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Composes transform from four vectors."
-msgstr ""
+msgstr "由四個å‘é‡æ§‹æˆè®Šæ›ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Decomposes transform to four vectors."
-msgstr ""
+msgstr "由四個å‘é‡åˆ†è§£è®Šæ›ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the determinant of a transform."
-msgstr ""
+msgstr "計算變æ›çš„行列å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the inverse of a transform."
-msgstr ""
+msgstr "計算變æ›çš„逆矩陣。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the transpose of a transform."
-msgstr ""
+msgstr "計算一個變æ›çš„轉置。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Multiplies transform by transform."
-msgstr ""
+msgstr "變æ›ä¹˜ä»¥è®Šæ›ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Multiplies vector by transform."
-msgstr ""
+msgstr "å‘é‡ä¹˜ä»¥è®Šæ›ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Transform constant."
-msgstr "新增資料夾"
+msgstr "變æ›å¸¸æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Transform uniform."
-msgstr "轉æ›å°è©±æ¡†..。"
+msgstr "變æ›å‡å‹»ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Vector function."
-msgstr "轉到函數…"
+msgstr "å‘é‡å‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector operator."
-msgstr ""
+msgstr "å‘é‡é‹ç®—å­ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Composes vector from three scalars."
-msgstr ""
+msgstr "由三個純é‡çµ„æˆå‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Decomposes vector to three scalars."
-msgstr ""
+msgstr "將一個å‘é‡æ‹†è§£ç‚ºä¸‰å€‹ç´”é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the cross product of two vectors."
-msgstr ""
+msgstr "計算兩個å‘é‡çš„外ç©ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the distance between two points."
-msgstr ""
+msgstr "回傳兩個點間的è·é›¢ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the dot product of two vectors."
-msgstr ""
+msgstr "計算兩個å‘é‡çš„å…§ç©ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9534,40 +9042,43 @@ msgid ""
"incident vector, and Nref, the reference vector. If the dot product of I and "
"Nref is smaller than zero the return value is N. Otherwise -N is returned."
msgstr ""
+"回傳一個與åƒç…§å‘é‡æŒ‡å‘相åŒæ–¹å‘çš„å‘é‡ã€‚該函å¼ç”±ä¸‰å€‹å‘é‡åƒæ•¸ï¼šN,方å‘å‘é‡ï¼›I,"
+"入射å‘é‡ï¼Œä»¥åŠ Nref,åƒç…§å‘é‡ã€‚è‹¥ I 與 Nref çš„å…§ç©å°æ–¼ 0,則回傳值為 N。å¦å‰‡"
+"將回傳 -N。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the length of a vector."
-msgstr ""
+msgstr "計算å‘é‡çš„長度。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Linear interpolation between two vectors."
-msgstr ""
+msgstr "在兩個å‘é‡é–“åšç·šæ€§æ’值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Linear interpolation between two vectors using scalar."
-msgstr ""
+msgstr "使用純é‡åœ¨å…©å€‹å‘é‡é–“åšç·šæ€§æ’值。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Calculates the normalize product of vector."
-msgstr ""
+msgstr "計算å‘é‡çš„æ­£è¦åŒ–ç©ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "1.0 - vector"
-msgstr ""
+msgstr "1.0 - å‘é‡"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "1.0 / vector"
-msgstr ""
+msgstr "1.0 / å‘é‡"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns the vector that points in the direction of reflection ( a : incident "
"vector, b : normal vector )."
-msgstr ""
+msgstr "回傳指å‘åå°„æ–¹å‘çš„å‘é‡ï¼ˆa:入射å‘é‡ï¼Œb:法å‘é‡ï¼‰ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the vector that points in the direction of refraction."
-msgstr ""
+msgstr "回傳指å‘折射方å‘çš„å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9577,6 +9088,10 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"SmoothStep 函å¼( vector(edge0), vector(edge1), vector(x) ).\n"
+"\n"
+"若「xã€å°æ–¼ã€Œedge0ã€å‰‡å›žå‚³ 0.0,若「xã€å¤§æ–¼ã€Œedge1ã€å‰‡å›žå‚³ 1.0。其餘值則回傳"
+"在 0.0 與 1.0 之間使用厄米多項å¼é€²è¡Œæ’值的çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9586,6 +9101,10 @@ msgid ""
"'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 "
"using Hermite polynomials."
msgstr ""
+"SmoothStep 函å¼( scalar(edge0), scalar(edge1), vector(x) ).\n"
+"\n"
+"若「xã€å°æ–¼ã€Œedge0ã€å‰‡å›žå‚³ 0.0,若「xã€å¤§æ–¼ã€Œedge1ã€å‰‡å›žå‚³ 1.0。其餘值則回傳"
+"在 0.0 與 1.0 之間使用厄米多項å¼é€²è¡Œæ’值的çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9593,6 +9112,9 @@ msgid ""
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Step 函å¼( vector(edge), vector(x) ).\n"
+"\n"
+"若「xã€å°æ–¼ã€Œedgeã€å‰‡å›žå‚³ 0.0,å¦å‰‡å›žå‚³ 1.0。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9600,34 +9122,37 @@ msgid ""
"\n"
"Returns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."
msgstr ""
+"Step 函å¼( scalar(edge), vector(x) ).\n"
+"\n"
+"若「xã€å°æ–¼ã€Œedgeã€å‰‡å›žå‚³ 1.0,å¦å‰‡å›žå‚³ 1.0。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Adds vector to vector."
-msgstr ""
+msgstr "å°‡å‘é‡åŠ ä¸Šå‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Divides vector by vector."
-msgstr ""
+msgstr "以å‘é‡é™¤ä»¥å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Multiplies vector by vector."
-msgstr ""
+msgstr "以å‘é‡ä¹˜ä»¥å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Returns the remainder of the two vectors."
-msgstr ""
+msgstr "回傳兩個å‘é‡ç›¸é™¤çš„餘數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Subtracts vector from vector."
-msgstr ""
+msgstr "å°‡å‘é‡æ¸›åŽ»å‘é‡ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector constant."
-msgstr ""
+msgstr "å‘é‡å¸¸æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Vector uniform."
-msgstr ""
+msgstr "å‘é‡å‡å‹»ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9635,12 +9160,14 @@ msgid ""
"output ports. This is a direct injection of code into the vertex/fragment/"
"light function, do not use it to write the function declarations inside."
msgstr ""
+"自定 Godot 著色器語言表示å¼ï¼Œä½¿ç”¨è‡ªå®šæ•¸é‡çš„輸入與輸出埠å£ã€‚這是通éŽç›´æŽ¥æ’å‘é ‚"
+"點ï¼ç‰‡æ®µï¼å…‰ç…§å‡½å¼æ’入程å¼ç¢¼ä¾†å¯¦ç¾çš„,請勿在其中è²æ˜Žå‡½å¼ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"Returns falloff based on the dot product of surface normal and view "
"direction of camera (pass associated inputs to it)."
-msgstr ""
+msgstr "ä¾æ“šè¡¨é¢æ³•ç·šèˆ‡ç›¸æ©Ÿæª¢è¦–æ–¹å‘çš„å…§ç©ä¾†å›žå‚³ä¸‹é™çŽ‡ï¼ˆå°‡å…¶ç›¸é—œè¼¸å…¥å‚³å…¥ï¼‰ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
@@ -9649,90 +9176,92 @@ msgid ""
"it later in the Expressions. You can also declare varyings, uniforms and "
"constants."
msgstr ""
+"自定 Godot 著色器語言表示å¼ï¼Œå°‡è¢«æ”¾å…¥æœ€çµ‚的著色器頂部。å¯ä»¥æ”¾å…¥æ•¸å€‹å‡½æ•¸è²æ˜Žåœ¨"
+"裡é¢ï¼Œä¸¦æ–¼ç¨å¾Œåœ¨è¡¨ç¤ºå¼ä¸­å‘¼å«ã€‚也å¯ä»¥è²æ˜Ž Varyingã€Uniform 與常數。"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "(Fragment/Light mode only) Scalar derivative function."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ç´”é‡å°Žå‡½æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "(Fragment/Light mode only) Vector derivative function."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰å‘é‡å°Žå‡½æ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Vector) Derivative in 'x' using local "
"differencing."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ï¼ˆå‘é‡ï¼‰ä»¥ä½¿ç”¨å±€éƒ¨å·®åˆ†çš„「xã€é€²è¡Œå°Žæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Scalar) Derivative in 'x' using local "
"differencing."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ï¼ˆç´”é‡ï¼‰ä»¥ä½¿ç”¨å±€éƒ¨å·®åˆ†çš„「xã€é€²è¡Œå°Žæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Vector) Derivative in 'y' using local "
"differencing."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ï¼ˆå‘é‡ï¼‰ä»¥ä½¿ç”¨å±€éƒ¨å·®åˆ†çš„「yã€é€²è¡Œå°Žæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Scalar) Derivative in 'y' using local "
"differencing."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ï¼ˆç´”é‡ï¼‰ä»¥ä½¿ç”¨å±€éƒ¨å·®åˆ†çš„「yã€é€²è¡Œå°Žæ•¸ã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and "
"'y'."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ï¼ˆå‘é‡ï¼‰åŠ ç¸½ã€Œxã€èˆ‡ã€Œyã€é€²è¡Œçµ•å°å°Žæ•¸çš„çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid ""
"(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and "
"'y'."
-msgstr ""
+msgstr "(é™ç‰‡æ®µï¼å…‰ç…§æ¨¡å¼ï¼‰ï¼ˆç´”é‡ï¼‰åŠ ç¸½ã€Œxã€èˆ‡ã€Œyã€é€²è¡Œçµ•å°å°Žæ•¸çš„çµæžœã€‚"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "VisualShader"
-msgstr "視覺化著色器"
+msgstr "視覺著色器 (VisualShader)"
#: editor/plugins/visual_shader_editor_plugin.cpp
-#, fuzzy
msgid "Edit Visual Property"
-msgstr "編輯å¯è¦–屬性"
+msgstr "編輯視覺屬性"
#: editor/plugins/visual_shader_editor_plugin.cpp
msgid "Visual Shader Mode Changed"
-msgstr "視覺著色器模å¼å·²æ›´æ”¹"
+msgstr "已修改視覺著色器模å¼"
#: editor/project_export.cpp
msgid "Runnable"
-msgstr "å¯é‹è¡Œçš„"
+msgstr "å¯åŸ·è¡Œ"
#: editor/project_export.cpp
-#, fuzzy
msgid "Add initial export..."
-msgstr "添加輸入"
+msgstr "新增åˆå§‹åŒ¯å‡º..."
#: editor/project_export.cpp
msgid "Add previous patches..."
-msgstr ""
+msgstr "新增上回修正檔..."
#: editor/project_export.cpp
msgid "Delete patch '%s' from list?"
-msgstr ""
+msgstr "是å¦è¦è‡ªåˆ—表中刪除「%sã€ä¿®æ­£æª”?"
#: editor/project_export.cpp
msgid "Delete preset '%s'?"
-msgstr "是å¦åˆ é™¤é è¨­â€œ%sâ€ï¼Ÿ"
+msgstr "確定è¦åˆªé™¤ Preset「%sã€ï¼Ÿ"
#: editor/project_export.cpp
msgid ""
"Failed to export the project for platform '%s'.\n"
"Export templates seem to be missing or invalid."
msgstr ""
+"為平å°ã€Œ%sã€åŒ¯å‡ºå°ˆæ¡ˆå¤±æ•—。\n"
+"匯出樣æ¿ä¼¼ä¹Žå·²éºå¤±æˆ–無效。"
#: editor/project_export.cpp
msgid ""
@@ -9740,40 +9269,44 @@ msgid ""
"This might be due to a configuration issue in the export preset or your "
"export settings."
msgstr ""
+"為平å°ã€Œ%sã€åŒ¯å‡ºå°ˆæ¡ˆå¤±æ•—。\n"
+"å¯èƒ½ä½¿ç”±æ–¼åŒ¯å‡º Preset 或匯出設定中的組態設定有å•é¡Œå°Žè‡´ã€‚"
#: editor/project_export.cpp
msgid "Release"
-msgstr "釋放"
+msgstr "釋出"
#: editor/project_export.cpp
msgid "Exporting All"
-msgstr "全部導出"
+msgstr "全部匯出"
#: editor/project_export.cpp
msgid "The given export path doesn't exist:"
-msgstr "給定的導出路徑ä¸å­˜åœ¨:"
+msgstr "給定的匯出路徑ä¸å­˜åœ¨ï¼š"
#: editor/project_export.cpp
msgid "Export templates for this platform are missing/corrupted:"
-msgstr "無此平臺的導出範本:"
+msgstr "該平å°çš„匯出範本éºå¤±ï¼æ毀:"
#: editor/project_export.cpp
msgid "Presets"
-msgstr "é è¨­"
+msgstr "Preset"
#: editor/project_export.cpp editor/project_settings_editor.cpp
msgid "Add..."
-msgstr "添加…"
+msgstr "新增…"
#: editor/project_export.cpp
msgid ""
"If checked, the preset will be available for use in one-click deploy.\n"
"Only one preset per platform may be marked as runnable."
msgstr ""
+"è‹¥é¸ä¸­ï¼Œå‰‡ Preset å°‡å¯ä½¿ç”¨ä¸€éµéƒ¨ç½²ã€‚\n"
+"æ¯å€‹å¹³å°åªå¯å°‡ä¸€å€‹ Preset 設為å¯åŸ·è¡Œã€‚"
#: editor/project_export.cpp
msgid "Export Path"
-msgstr "導出路徑"
+msgstr "匯出路徑"
#: editor/project_export.cpp
msgid "Resources"
@@ -9781,48 +9314,51 @@ msgstr "資æº"
#: editor/project_export.cpp
msgid "Export all resources in the project"
-msgstr "導出項目中的所有資æº"
+msgstr "匯出專案內所有資æº"
#: editor/project_export.cpp
msgid "Export selected scenes (and dependencies)"
-msgstr "導出é¸å®šçš„場景 (å’Œä¾è³´é …)"
+msgstr "匯出所é¸å ´æ™¯ï¼ˆèˆ‡å…¶æ‰€æœ‰ç›¸ä¾æ€§ï¼‰"
#: editor/project_export.cpp
msgid "Export selected resources (and dependencies)"
-msgstr "導出é¸å®šçš„è³‡æº (å’Œä¾è³´é …)"
+msgstr "匯出所é¸è³‡æºï¼ˆèˆ‡å…¶æ‰€æœ‰ç›¸ä¾æ€§ï¼‰"
#: editor/project_export.cpp
msgid "Export Mode:"
-msgstr "導出模å¼:"
+msgstr "匯出模å¼ï¼š"
#: editor/project_export.cpp
msgid "Resources to export:"
-msgstr "è¦è¼¸å‡ºçš„資æº:"
+msgstr "匯出的資æºï¼š"
#: editor/project_export.cpp
msgid ""
"Filters to export non-resource files/folders\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
msgstr ""
+"éŽæ¿¾éžè³‡æºçš„檔案ï¼è³‡æ–™å¤¾ä»¥åŒ¯å‡º\n"
+"(以åŠå½¢é€—號å€åˆ†ï¼Œå¦‚: *.json, *.txt, docs/*)"
#: editor/project_export.cpp
msgid ""
"Filters to exclude files/folders from project\n"
"(comma-separated, e.g: *.json, *.txt, docs/*)"
msgstr ""
+"éŽæ¿¾ä»¥åœ¨å°ˆæ¡ˆå…§æŽ’除檔案ï¼è³‡æ–™å¤¾\n"
+"(以åŠå½¢é€—號å€åˆ†ï¼Œå¦‚: *.json, *.txt, docs/*)"
#: editor/project_export.cpp
msgid "Patches"
-msgstr "補ä¸"
+msgstr "修正檔"
#: editor/project_export.cpp
msgid "Make Patch"
-msgstr "製作補ä¸"
+msgstr "製作修正檔"
#: editor/project_export.cpp
-#, fuzzy
msgid "Pack File"
-msgstr " 資料夾"
+msgstr "打包檔案"
#: editor/project_export.cpp
msgid "Features"
@@ -9830,25 +9366,23 @@ msgstr "功能"
#: editor/project_export.cpp
msgid "Custom (comma-separated):"
-msgstr "自訂 (逗號分隔):"
+msgstr "自訂(以逗號分隔):"
#: editor/project_export.cpp
-#, fuzzy
msgid "Feature List:"
-msgstr "功能清單:"
+msgstr "功能清單:"
#: editor/project_export.cpp
-#, fuzzy
msgid "Script"
msgstr "腳本"
#: editor/project_export.cpp
msgid "Script Export Mode:"
-msgstr "腳本導出模å¼:"
+msgstr "腳本匯出模å¼ï¼š"
#: editor/project_export.cpp
msgid "Text"
-msgstr "文本"
+msgstr "純文字"
#: editor/project_export.cpp
msgid "Compiled"
@@ -9856,173 +9390,162 @@ msgstr "編譯"
#: editor/project_export.cpp
msgid "Encrypted (Provide Key Below)"
-msgstr "加密 (使用以下密碼)"
+msgstr "加密(使用以下密鑰)"
#: editor/project_export.cpp
msgid "Invalid Encryption Key (must be 64 characters long)"
-msgstr "ä¸æ­£ç¢ºåŠ å¯†é‡‘é‘° (長度必須為64個字元)"
+msgstr "無效的加密密鑰(長度需為 64 個字元)"
#: editor/project_export.cpp
msgid "Script Encryption Key (256-bits as hex):"
-msgstr "腳本加密金鑰 (256ä½å六進ä½ç¢¼):"
+msgstr "腳本加密密鑰(256 ä½å…ƒçš„ 16 進ä½ï¼‰ï¼š"
#: editor/project_export.cpp
msgid "Export PCK/Zip"
-msgstr "導出 PCK/ZIP"
+msgstr "匯出 PCK/ZIP"
#: editor/project_export.cpp
msgid "Export Project"
-msgstr "輸出專案"
+msgstr "匯出專案"
#: editor/project_export.cpp
-#, fuzzy
msgid "Export mode?"
-msgstr "導出模å¼:"
+msgstr "匯出模å¼ï¼Ÿ"
#: editor/project_export.cpp
-#, fuzzy
msgid "Export All"
-msgstr "全部導出"
+msgstr "全部匯出"
#: editor/project_export.cpp editor/project_manager.cpp
-#, fuzzy
msgid "ZIP File"
-msgstr " 資料夾"
+msgstr "ZIP 檔案"
#: editor/project_export.cpp
msgid "Godot Game Pack"
-msgstr ""
+msgstr "Godot éŠæˆ²åŒ…"
#: editor/project_export.cpp
msgid "Export templates for this platform are missing:"
-msgstr "缺少此平臺的導出範本:"
+msgstr "缺少匯出該平å°ç”¨çš„樣æ¿ï¼š"
#: editor/project_export.cpp
msgid "Manage Export Templates"
-msgstr "管ç†è¼¸å‡ºæ¨¡æ¿"
+msgstr "管ç†åŒ¯å‡ºæ¨£æ¿"
#: editor/project_export.cpp
msgid "Export With Debug"
-msgstr "導出為調試"
+msgstr "以åµéŒ¯æ¨¡å¼åŒ¯å‡º"
#: editor/project_manager.cpp
-#, fuzzy
msgid "The path specified doesn't exist."
-msgstr "路徑ä¸å­˜åœ¨."
+msgstr "指定的路徑ä¸å­˜åœ¨ã€‚"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Error opening package file (it's not in ZIP format)."
-msgstr "é–‹å•Ÿå¥—ä»¶æª”æ¡ˆå‡ºéŒ¯ï¼Œéž zip æ ¼å¼ã€‚"
+msgstr "é–‹å•Ÿå¥—ä»¶æª”æ¡ˆæ™‚ç™¼ç”ŸéŒ¯èª¤ï¼ˆéž ZIP æ ¼å¼ï¼‰ã€‚"
#: editor/project_manager.cpp
-#, fuzzy
msgid ""
"Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."
-msgstr "“.zipâ€é …目檔案無效,ä¸åŒ…å«â€œproject.godotâ€æª”案。"
+msgstr "無效的「.zipã€å°ˆæ¡ˆæª”;未包å«ã€Œproject.godotã€æª”案。"
#: editor/project_manager.cpp
msgid "Please choose an empty folder."
msgstr "è«‹é¸æ“‡ä¸€å€‹ç©ºè³‡æ–™å¤¾ã€‚"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Please choose a \"project.godot\" or \".zip\" file."
-msgstr "è«‹é¸æ“‡â€œproject.godotâ€æˆ–“.zipâ€æª”案。"
+msgstr "è«‹é¸æ“‡ä¸€å€‹ã€Œproject.godotã€æˆ–「.zipã€æª”案。"
#: editor/project_manager.cpp
-#, fuzzy
msgid "This directory already contains a Godot project."
-msgstr "目錄已包å«ä¸€å€‹godot項目。"
+msgstr "該目錄已經包å«äº†ä¸€å€‹ Godot 專案。"
#: editor/project_manager.cpp
msgid "New Game Project"
-msgstr "æ–°éŠæˆ²é …ç›®"
+msgstr "æ–°éŠæˆ²å°ˆæ¡ˆ"
#: editor/project_manager.cpp
msgid "Imported Project"
-msgstr "已導入的項目"
+msgstr "已匯入的項目"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Invalid Project Name."
-msgstr "é …ç›®å稱無效。"
+msgstr "無效的專案å。"
#: editor/project_manager.cpp
msgid "Couldn't create folder."
-msgstr "無法新增資料夾."
+msgstr "無法建立資料夾。"
#: editor/project_manager.cpp
msgid "There is already a folder in this path with the specified name."
-msgstr "此路徑中已存在具有指定å稱的資料夾。"
+msgstr "該路徑下已有相åŒå稱的資料夾。"
#: editor/project_manager.cpp
msgid "It would be a good idea to name your project."
-msgstr "給你的項目命å是個好主æ„。"
+msgstr "最好幫你的專案起個å字。"
#: editor/project_manager.cpp
msgid "Invalid project path (changed anything?)."
-msgstr "ä¸æ­£ç¢ºé …目路徑 (更改了任何內容?)。"
+msgstr "ä¸æ­£ç¢ºçš„專案路徑(有修改了什麼嗎?)。"
#: editor/project_manager.cpp
msgid ""
"Couldn't load project.godot in project path (error %d). It may be missing or "
"corrupted."
-msgstr "無法在項目路徑中加載project.godot(錯誤%d)。它å¯èƒ½éºå¤±æˆ–æ壞。"
+msgstr "無法自專案路徑內載入 project.godot(錯誤 %d)。檔案å¯èƒ½éºå¤±æˆ–æ毀。"
#: editor/project_manager.cpp
msgid "Couldn't edit project.godot in project path."
-msgstr "無法在項目路徑中編輯project.godot。"
+msgstr "無法在專案路徑中編輯 project.godot。"
#: editor/project_manager.cpp
msgid "Couldn't create project.godot in project path."
-msgstr "無法在項目路徑中創建project.godot。"
+msgstr "無法在項目路徑中建立 project.godot。"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Rename Project"
-msgstr "é‡å‘½åé …ç›®"
+msgstr "é‡æ–°å‘½åé …ç›®"
#: editor/project_manager.cpp
msgid "Import Existing Project"
-msgstr "å°Žå…¥ç¾æœ‰é …ç›®"
+msgstr "匯入ç¾æœ‰å°ˆæ¡ˆ"
#: editor/project_manager.cpp
msgid "Import & Edit"
-msgstr "導入與編輯"
+msgstr "匯入並編輯"
#: editor/project_manager.cpp
msgid "Create New Project"
-msgstr "創建新項目"
+msgstr "建立新專案"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Create & Edit"
-msgstr "創建和編輯"
+msgstr "建立並編輯"
#: editor/project_manager.cpp
msgid "Install Project:"
-msgstr "安è£é …目:"
+msgstr "安è£å°ˆæ¡ˆï¼š"
#: editor/project_manager.cpp
msgid "Install & Edit"
-msgstr "安è£å’Œç·¨è¼¯"
+msgstr "安è£ä¸¦ç·¨è¼¯"
#: editor/project_manager.cpp
msgid "Project Name:"
-msgstr "é …ç›®å稱:"
+msgstr "專案å稱:"
#: editor/project_manager.cpp
msgid "Project Path:"
-msgstr "項目路徑:"
+msgstr "專案路徑:"
#: editor/project_manager.cpp
msgid "Project Installation Path:"
-msgstr "項目安è£è·¯å¾‘:"
+msgstr "專案安è£è·¯å¾‘:"
#: editor/project_manager.cpp
msgid "Renderer:"
-msgstr "渲染器:"
+msgstr "算圖器:"
#: editor/project_manager.cpp
msgid "OpenGL ES 3.0"
@@ -10035,6 +9558,10 @@ msgid ""
"Incompatible with older hardware\n"
"Not recommended for web games"
msgstr ""
+"更好的視覺å“質\n"
+"所有功能å¯ç”¨\n"
+"與舊硬體ä¸ç›¸å®¹\n"
+"ä¸æŽ¨è–¦ç”¨æ–¼ç¶²é éŠæˆ²"
#: editor/project_manager.cpp
msgid "OpenGL ES 2.0"
@@ -10047,34 +9574,36 @@ msgid ""
"Works on most hardware\n"
"Recommended for web games"
msgstr ""
+"較低的視覺å“質\n"
+"有些功能ä¸å¯ç”¨\n"
+"在大多數硬體上å¯ç”¨\n"
+"推薦用於網é éŠæˆ²"
#: editor/project_manager.cpp
msgid "Renderer can be changed later, but scenes may need to be adjusted."
-msgstr "渲染器å¯ä»¥ç„¶å¾Œæ›´æ”¹, 但場景å¯èƒ½éœ€è¦èª¿æ•´ã€‚"
+msgstr "ç¨å¾Œä»å¯æ›´æ”¹ç®—圖器,但å¯èƒ½éœ€è¦å°å ´æ™¯é€²è¡Œèª¿æ•´ã€‚"
#: editor/project_manager.cpp
msgid "Unnamed Project"
-msgstr "未命åé …ç›®"
+msgstr "未命å專案"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Missing Project"
-msgstr "å°Žå…¥ç¾æœ‰é …ç›®"
+msgstr "éºå¤±å°ˆæ¡ˆ"
#: editor/project_manager.cpp
msgid "Error: Project is missing on the filesystem."
-msgstr ""
+msgstr "錯誤:專案在檔案系統上éºå¤±ã€‚"
#: editor/project_manager.cpp
msgid "Can't open project at '%s'."
-msgstr "無法打開ä½æ–¼'%s'的項目。"
+msgstr "無法在「%sã€ä¸­æ‰“開專案。"
#: editor/project_manager.cpp
msgid "Are you sure to open more than one project?"
-msgstr "您確定è¦æ‰“開多個項目嗎?"
+msgstr "確定è¦æ‰“開多個專案嗎?"
#: editor/project_manager.cpp
-#, fuzzy
msgid ""
"The following project settings file does not specify the version of Godot "
"through which it was created.\n"
@@ -10086,15 +9615,14 @@ msgid ""
"Warning: You won't be able to open the project with previous versions of the "
"engine anymore."
msgstr ""
-"以下項目設定檔案未指定通éŽå…¶å‰µå»ºçš„Godot的版本。\n"
+"下列專案設定檔未指定建立其之 Godot 版本。\n"
"\n"
"%s\n"
"\n"
-"如果繼續打開它, 它將被轉æ›ç‚º Godot 的當å‰é…置檔案格å¼ã€‚ \n"
-"警告: 您將無法å†ä½¿ç”¨ä»¥å‰ç‰ˆæœ¬çš„引擎打開項目。"
+"若您繼續開啟,會將其轉æ›ç‚ºç›®å‰ Godot 版本的組態設定檔案格å¼ã€‚\n"
+"警告:您將ä¸å†å¯ä½¿ç”¨éŽå¾€ç‰ˆæœ¬çš„引擎開啟該專案。"
#: editor/project_manager.cpp
-#, fuzzy
msgid ""
"The following project settings file was generated by an older engine "
"version, and needs to be converted for this version:\n"
@@ -10105,18 +9633,18 @@ msgid ""
"Warning: You won't be able to open the project with previous versions of the "
"engine anymore."
msgstr ""
-"以下項目設置檔案是由較舊的引擎版本生æˆçš„, 需è¦ç‚ºæ­¤ç‰ˆæœ¬é€²è¡Œè½‰æ›:\n"
+"下列專案設定檔時由較舊版本的引擎所產生,且需è¦å°‡å…¶è½‰æ›ç‚ºç›®å‰çš„版本:\n"
"\n"
"%s\n"
"\n"
-"是å¦è¦å°‡å…¶è½‰æ›ï¼Ÿ\n"
-"警告: 您將無法å†ä½¿ç”¨ä»¥å‰ç‰ˆæœ¬çš„引擎打開專案。"
+"è¦é€²è¡Œè½‰æ›å—Žï¼Ÿ\n"
+"警告:您將ä¸å†å¯ä½¿ç”¨éŽå¾€ç‰ˆæœ¬çš„引擎開啟該專案。"
#: editor/project_manager.cpp
msgid ""
"The project settings were created by a newer engine version, whose settings "
"are not compatible with this version."
-msgstr "此項目設置是由較新的引擎版本創建的, 其設置與此版本ä¸ç›¸å®¹ã€‚"
+msgstr "該專案設定是由新版本的引擎所建立,其設定無法相容於這個版本。"
#: editor/project_manager.cpp
msgid ""
@@ -10124,57 +9652,66 @@ msgid ""
"Please edit the project and set the main scene in the Project Settings under "
"the \"Application\" category."
msgstr ""
+"無法執行專案:未定義主場景。\n"
+"請編輯專案並在「應用程å¼ã€åˆ†é¡žä¸­çš„專案設定內設定主場景。"
#: editor/project_manager.cpp
msgid ""
"Can't run project: Assets need to be imported.\n"
"Please edit the project to trigger the initial import."
msgstr ""
+"無法執行專案:需è¦åŒ¯å…¥ç´ æ\n"
+"請編輯專案以觸發åˆå§‹åŒ¯å…¥ã€‚"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Are you sure to run %d projects at once?"
-msgstr "您確定è¦é‹è¡Œå¤šå€‹é …目嗎?"
+msgstr "確定è¦ä¸€æ¬¡åŸ·è¡Œ %d 個專案?"
#: editor/project_manager.cpp
-#, fuzzy
msgid ""
"Remove %d projects from the list?\n"
"The project folders' contents won't be modified."
-msgstr "是å¦å¾žæ¸…單中删除項目?(資料夾內容將ä¸è¢«ä¿®æ”¹ï¼‰"
+msgstr ""
+"確定è¦è‡ªæ¸…單中移除 %d 個專案嗎?\n"
+"專案資料夾的內容ä¸æœƒè¢«ä¿®æ”¹ã€‚"
#: editor/project_manager.cpp
-#, fuzzy
msgid ""
"Remove this project from the list?\n"
"The project folder's contents won't be modified."
-msgstr "是å¦å¾žæ¸…單中删除項目?(資料夾內容將ä¸è¢«ä¿®æ”¹ï¼‰"
+msgstr ""
+"確定è¦è‡ªåˆ—表移除該專案嗎?\n"
+"專案資料夾的內容ä¸æœƒè¢«ä¿®æ”¹ã€‚"
#: editor/project_manager.cpp
-#, fuzzy
msgid ""
"Remove all missing projects from the list?\n"
"The project folders' contents won't be modified."
-msgstr "是å¦å¾žæ¸…單中删除項目?(資料夾內容將ä¸è¢«ä¿®æ”¹ï¼‰"
+msgstr ""
+"確定自清單移除所有éºå¤±çš„專案嗎?\n"
+"專案資料夾的內容ä¸æœƒè¢«ä¿®æ”¹ã€‚"
#: editor/project_manager.cpp
msgid ""
"Language changed.\n"
"The interface will update after restarting the editor or project manager."
msgstr ""
+"語言已更改。\n"
+"ç•Œé¢å°‡æœƒåœ¨é‡æ–°å•Ÿå‹•ç·¨è¼¯å™¨æˆ–專案管ç†å“¡å¾Œæ›´æ–°ã€‚"
#: editor/project_manager.cpp
msgid ""
"Are you sure to scan %s folders for existing Godot projects?\n"
"This could take a while."
msgstr ""
+"確定è¦ç‚ºç¾å­˜çš„ Godot 專案掃æ %s 資料夾嗎?\n"
+"這å¯èƒ½éœ€è¦ä¸€æ®µæ™‚間。"
#: editor/project_manager.cpp
msgid "Project Manager"
-msgstr ""
+msgstr "專案管ç†å“¡"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Projects"
msgstr "專案"
@@ -10188,35 +9725,35 @@ msgstr "掃æ"
#: editor/project_manager.cpp
msgid "Select a Folder to Scan"
-msgstr "é¸æ“‡ä¸€å€‹è³‡æ–™å¤¾ä¾†æŽƒæ"
+msgstr "é¸æ“‡è³‡æ–™å¤¾ä»¥é€²è¡ŒæŽƒæ"
#: editor/project_manager.cpp
msgid "New Project"
-msgstr ""
+msgstr "新增專案"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Remove Missing"
-msgstr "刪除點"
+msgstr "刪除éºå¤±"
#: editor/project_manager.cpp
msgid "Templates"
-msgstr "模æ¿"
+msgstr "樣æ¿"
#: editor/project_manager.cpp
msgid "Restart Now"
-msgstr ""
+msgstr "ç«‹å³é‡æ–°å•Ÿå‹•"
#: editor/project_manager.cpp
-#, fuzzy
msgid "Can't run project"
-msgstr "連接..."
+msgstr "無法執行專案"
#: editor/project_manager.cpp
msgid ""
"You currently don't have any projects.\n"
"Would you like to explore official example projects in the Asset Library?"
msgstr ""
+"ç›®å‰æ²’有任何專案。\n"
+"è¦åœ¨ç´ æ庫中ç€è¦½å®˜æ–¹ç¯„例專案嗎?"
#: editor/project_manager.cpp
msgid ""
@@ -10224,237 +9761,232 @@ msgid ""
"To filter projects by name and full path, the query must contain at least "
"one `/` character."
msgstr ""
+"æœå°‹æ¡†å¯ä»¥ç”¨ä¾†ä¾æ“šå稱與路徑中的最後一部分來éŽæ¿¾å°ˆæ¡ˆã€‚\n"
+"è‹¥è¦ä»¥å稱與完整路徑來éŽæ¿¾å°ˆæ¡ˆï¼Œæœå°‹å…§å®¹æ‡‰è©²è‡³å°‘包å«ä¸€å€‹ã€Œ/ã€å­—元。"
#: editor/project_settings_editor.cpp
msgid "Key "
-msgstr ""
+msgstr "éµ "
#: editor/project_settings_editor.cpp
msgid "Joy Button"
-msgstr ""
+msgstr "控制器按鈕"
#: editor/project_settings_editor.cpp
msgid "Joy Axis"
-msgstr ""
+msgstr "控制器類比軸"
#: editor/project_settings_editor.cpp
msgid "Mouse Button"
-msgstr ""
+msgstr "滑鼠按鈕"
#: editor/project_settings_editor.cpp
msgid ""
"Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'"
-msgstr ""
+msgstr "無效的æ“作å稱。ä¸èƒ½ç‚ºç©ºæˆ–包å«ã€Œ/ã€ã€ã€Œ:ã€ã€ã€Œ=ã€ã€ã€Œ\\ã€æˆ–「\"ã€"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "An action with the name '%s' already exists."
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "已有å稱「%sã€çš„æ“作。"
#: editor/project_settings_editor.cpp
msgid "Rename Input Action Event"
-msgstr ""
+msgstr "é‡æ–°å‘½å輸入æ“作事件"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Change Action deadzone"
-msgstr "改變字典 value"
+msgstr "修改æ“作盲å€"
#: editor/project_settings_editor.cpp
msgid "Add Input Action Event"
-msgstr ""
+msgstr "新增輸入æ“作事件"
#: editor/project_settings_editor.cpp
msgid "All Devices"
-msgstr ""
+msgstr "所有è£ç½®"
#: editor/project_settings_editor.cpp
msgid "Device"
-msgstr ""
+msgstr "è£ç½®"
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
msgid "Press a Key..."
-msgstr ""
+msgstr "請按下按éµ..."
#: editor/project_settings_editor.cpp
msgid "Mouse Button Index:"
-msgstr ""
+msgstr "滑鼠按éµç´¢å¼•ï¼š"
#: editor/project_settings_editor.cpp
msgid "Left Button"
-msgstr ""
+msgstr "å·¦éµ"
#: editor/project_settings_editor.cpp
msgid "Right Button"
-msgstr ""
+msgstr "å³éµ"
#: editor/project_settings_editor.cpp
msgid "Middle Button"
-msgstr ""
+msgstr "中éµ"
#: editor/project_settings_editor.cpp
msgid "Wheel Up Button"
-msgstr ""
+msgstr "滾輪å‘上按éµ"
#: editor/project_settings_editor.cpp
msgid "Wheel Down Button"
-msgstr ""
+msgstr "滾輪å‘下按éµ"
#: editor/project_settings_editor.cpp
msgid "Wheel Left Button"
-msgstr ""
+msgstr "滾輪å‘左按éµ"
#: editor/project_settings_editor.cpp
msgid "Wheel Right Button"
-msgstr ""
+msgstr "滾輪å‘å³æŒ‰éµ"
#: editor/project_settings_editor.cpp
msgid "X Button 1"
-msgstr ""
+msgstr "X æŒ‰éµ 1"
#: editor/project_settings_editor.cpp
msgid "X Button 2"
-msgstr ""
+msgstr "X æŒ‰éµ 2"
#: editor/project_settings_editor.cpp
msgid "Joypad Axis Index:"
-msgstr ""
+msgstr "控制器類比æ–桿索引:"
#: editor/project_settings_editor.cpp
msgid "Axis"
-msgstr ""
+msgstr "類比軸"
#: editor/project_settings_editor.cpp
msgid "Joypad Button Index:"
-msgstr ""
+msgstr "控制器按鈕索引:"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Erase Input Action"
-msgstr "所有的é¸æ“‡"
+msgstr "清除輸入æ“作"
#: editor/project_settings_editor.cpp
msgid "Erase Input Action Event"
-msgstr ""
+msgstr "清除輸入æ“作事件"
#: editor/project_settings_editor.cpp
msgid "Add Event"
-msgstr ""
+msgstr "新增事件"
#: editor/project_settings_editor.cpp
msgid "Button"
-msgstr ""
+msgstr "Button(按鈕)"
#: editor/project_settings_editor.cpp
msgid "Left Button."
-msgstr ""
+msgstr "å·¦éµã€‚"
#: editor/project_settings_editor.cpp
msgid "Right Button."
-msgstr ""
+msgstr "å³éµã€‚"
#: editor/project_settings_editor.cpp
msgid "Middle Button."
-msgstr ""
+msgstr "中éµã€‚"
#: editor/project_settings_editor.cpp
msgid "Wheel Up."
-msgstr ""
+msgstr "滾輪å‘上。"
#: editor/project_settings_editor.cpp
msgid "Wheel Down."
-msgstr ""
+msgstr "滾輪å‘下。"
#: editor/project_settings_editor.cpp
msgid "Add Global Property"
-msgstr ""
+msgstr "新增全域屬性"
#: editor/project_settings_editor.cpp
msgid "Select a setting item first!"
-msgstr ""
+msgstr "è«‹å…ˆé¸æ“‡ä¸€å€‹è¨­å®šé …ç›®ï¼"
#: editor/project_settings_editor.cpp
msgid "No property '%s' exists."
-msgstr ""
+msgstr "屬性「%sã€ä¸å­˜åœ¨ã€‚"
#: editor/project_settings_editor.cpp
msgid "Setting '%s' is internal, and it can't be deleted."
-msgstr ""
+msgstr "「%sã€ç‚ºå…§éƒ¨è¨­å®šï¼Œç„¡æ³•åˆªé™¤ã€‚"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Delete Item"
-msgstr "刪除"
+msgstr "刪除項目"
#: editor/project_settings_editor.cpp
msgid ""
"Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or "
"'\"'."
-msgstr ""
+msgstr "無效的æ“作å稱。ä¸èƒ½ç‚ºç©ºæˆ–包å«ã€Œ/ã€ã€ã€Œ:ã€ã€ã€Œ=ã€ã€ã€Œ\\ã€æˆ–「\"ã€ã€‚"
#: editor/project_settings_editor.cpp
msgid "Add Input Action"
-msgstr ""
+msgstr "新增輸入æ“作"
#: editor/project_settings_editor.cpp
msgid "Error saving settings."
-msgstr ""
+msgstr "ä¿å­˜è¨­å®šæ™‚發生錯誤。"
#: editor/project_settings_editor.cpp
msgid "Settings saved OK."
-msgstr ""
+msgstr "設定ä¿å­˜æˆåŠŸã€‚"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Moved Input Action Event"
-msgstr "所有的é¸æ“‡"
+msgstr "移動輸入æ“作事件"
#: editor/project_settings_editor.cpp
msgid "Override for Feature"
-msgstr ""
+msgstr "複寫功能"
#: editor/project_settings_editor.cpp
msgid "Add Translation"
-msgstr ""
+msgstr "新增翻譯"
#: editor/project_settings_editor.cpp
msgid "Remove Translation"
-msgstr ""
+msgstr "移除翻譯"
#: editor/project_settings_editor.cpp
msgid "Add Remapped Path"
-msgstr ""
+msgstr "新增é‡æ˜ å°„路徑"
#: editor/project_settings_editor.cpp
msgid "Resource Remap Add Remap"
-msgstr ""
+msgstr "資æºé‡æ˜ å°„新增é‡æ˜ å°„"
#: editor/project_settings_editor.cpp
msgid "Change Resource Remap Language"
-msgstr ""
+msgstr "更改資æºé‡æ˜ å°„語言"
#: editor/project_settings_editor.cpp
msgid "Remove Resource Remap"
-msgstr ""
+msgstr "移除資æºé‡æ˜ å°„"
#: editor/project_settings_editor.cpp
msgid "Remove Resource Remap Option"
-msgstr ""
+msgstr "移除資æºé‡æ˜ å°„é¸é …"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Changed Locale Filter"
-msgstr "變更é¡é ­å°ºå¯¸"
+msgstr "更改å€åŸŸéŽæ¿¾"
#: editor/project_settings_editor.cpp
msgid "Changed Locale Filter Mode"
-msgstr ""
+msgstr "更改å€åŸŸéŽæ¿¾æ¨¡å¼"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Project Settings (project.godot)"
-msgstr "專案設定"
+msgstr "專案設定 (project.godot)"
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
msgid "General"
@@ -10462,929 +9994,893 @@ msgstr "一般"
#: editor/project_settings_editor.cpp
msgid "Override For..."
-msgstr ""
+msgstr "複寫..."
#: editor/project_settings_editor.cpp editor/settings_config_dialog.cpp
msgid "The editor must be restarted for changes to take effect."
-msgstr ""
+msgstr "å¿…é ˆé‡æ–°å•Ÿå‹•ç·¨è¼¯å™¨æ‰æœƒä½¿æ”¹å‹•ç”Ÿæ•ˆã€‚"
#: editor/project_settings_editor.cpp
msgid "Input Map"
-msgstr ""
+msgstr "輸入映射"
#: editor/project_settings_editor.cpp
msgid "Action:"
-msgstr ""
+msgstr "æ“作:"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Action"
-msgstr "所有的é¸æ“‡"
+msgstr "æ“作"
#: editor/project_settings_editor.cpp
msgid "Deadzone"
-msgstr ""
+msgstr "盲å€"
#: editor/project_settings_editor.cpp
msgid "Device:"
-msgstr ""
+msgstr "設備:"
#: editor/project_settings_editor.cpp
msgid "Index:"
-msgstr ""
+msgstr "索引:"
#: editor/project_settings_editor.cpp
msgid "Localization"
-msgstr ""
+msgstr "本地化"
#: editor/project_settings_editor.cpp
msgid "Translations"
-msgstr ""
+msgstr "翻譯"
#: editor/project_settings_editor.cpp
msgid "Translations:"
-msgstr ""
+msgstr "翻譯:"
#: editor/project_settings_editor.cpp
msgid "Remaps"
-msgstr ""
+msgstr "é‡æ˜ å°„"
#: editor/project_settings_editor.cpp
msgid "Resources:"
-msgstr ""
+msgstr "資æºï¼š"
#: editor/project_settings_editor.cpp
msgid "Remaps by Locale:"
-msgstr ""
+msgstr "ä¾èªžè¨€é‡æ˜ å°„:"
#: editor/project_settings_editor.cpp
msgid "Locale"
-msgstr ""
+msgstr "語言"
#: editor/project_settings_editor.cpp
msgid "Locales Filter"
-msgstr ""
+msgstr "語言éŽæ¿¾"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Show All Locales"
-msgstr "顯示骨骼"
+msgstr "顯示所有語言"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Show Selected Locales Only"
-msgstr "僅é¸æ“‡å€åŸŸ"
+msgstr "僅顯示é¸å®šçš„語言"
#: editor/project_settings_editor.cpp
-#, fuzzy
msgid "Filter mode:"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "éŽæ¿¾æ¨¡å¼ï¼š"
#: editor/project_settings_editor.cpp
msgid "Locales:"
-msgstr ""
+msgstr "語言:"
#: editor/project_settings_editor.cpp
msgid "AutoLoad"
-msgstr ""
+msgstr "Autoload"
#: editor/project_settings_editor.cpp
msgid "Plugins"
-msgstr "挿件"
+msgstr "外掛"
#: editor/property_editor.cpp
msgid "Preset..."
-msgstr "é è¨­ã€‚。。"
+msgstr "Preset..."
#: editor/property_editor.cpp
msgid "Zero"
-msgstr ""
+msgstr "ç„¡"
#: editor/property_editor.cpp
msgid "Easing In-Out"
-msgstr ""
+msgstr "緩入緩出"
#: editor/property_editor.cpp
msgid "Easing Out-In"
-msgstr ""
+msgstr "緩入緩出(åå‘)"
#: editor/property_editor.cpp
msgid "File..."
-msgstr ""
+msgstr "檔案..."
#: editor/property_editor.cpp
msgid "Dir..."
-msgstr ""
+msgstr "資料夾..."
#: editor/property_editor.cpp
msgid "Assign"
-msgstr ""
+msgstr "指派"
#: editor/property_editor.cpp
msgid "Select Node"
-msgstr ""
+msgstr "é¸æ“‡ç¯€é»ž"
#: editor/property_editor.cpp
msgid "Error loading file: Not a resource!"
-msgstr ""
+msgstr "載入檔案時發生錯誤:éžè³‡æºï¼"
#: editor/property_editor.cpp
msgid "Pick a Node"
-msgstr ""
+msgstr "é¸æ“‡ä¸€å€‹ç¯€é»ž"
#: editor/property_editor.cpp
msgid "Bit %d, val %d."
-msgstr ""
+msgstr "ä½å…ƒ %d,值 %d。"
#: editor/property_selector.cpp
msgid "Select Property"
-msgstr ""
+msgstr "é¸æ“‡å±¬æ€§"
#: editor/property_selector.cpp
msgid "Select Virtual Method"
-msgstr ""
+msgstr "é¸æ“‡è™›æ“¬æ–¹æ³•"
#: editor/property_selector.cpp
msgid "Select Method"
-msgstr ""
+msgstr "é¸æ“‡æ–¹æ³•"
#: editor/rename_dialog.cpp editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Batch Rename"
-msgstr "符åˆå¤§å°å¯«"
+msgstr "批次é‡æ–°å‘½å"
#: editor/rename_dialog.cpp
msgid "Prefix"
-msgstr ""
+msgstr "å‰ç½®"
#: editor/rename_dialog.cpp
msgid "Suffix"
-msgstr ""
+msgstr "後置"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Use Regular Expressions"
-msgstr "設置ç£è²¼å€åŸŸ"
+msgstr "使用正è¦è¡¨ç¤ºå¼"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Advanced Options"
-msgstr "å¸é™„é¸é …"
+msgstr "進階é¸é …"
#: editor/rename_dialog.cpp
msgid "Substitute"
-msgstr ""
+msgstr "å–代"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Node name"
-msgstr "節點å稱:"
+msgstr "節點å稱"
#: editor/rename_dialog.cpp
msgid "Node's parent name, if available"
-msgstr ""
+msgstr "節點的æ¯ç´šç¯€é»žå(若有的話)"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Node type"
-msgstr "節點å稱:"
+msgstr "節點型別"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Current scene name"
-msgstr "ç›®å‰çš„場景尚未存檔, ä¾ç„¶è¦é–‹å•Ÿå—Ž?"
+msgstr "ç›®å‰å ´æ™¯å稱"
#: editor/rename_dialog.cpp
msgid "Root node name"
-msgstr ""
+msgstr "根節點å稱"
#: editor/rename_dialog.cpp
msgid ""
"Sequential integer counter.\n"
"Compare counter options."
msgstr ""
+"åºåˆ—整數計數器。\n"
+"比較計數器é¸é …。"
#: editor/rename_dialog.cpp
msgid "Per-level Counter"
-msgstr ""
+msgstr "å„級別分別計數器"
#: editor/rename_dialog.cpp
msgid "If set the counter restarts for each group of child nodes"
-msgstr ""
+msgstr "若啟用則計數器將ä¾æ“šæ¯çµ„å­ç¯€é»žé‡æ–°å•Ÿå‹•"
#: editor/rename_dialog.cpp
msgid "Initial value for the counter"
-msgstr ""
+msgstr "計數器起始值"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Step"
-msgstr "步驟 :"
+msgstr "步長"
#: editor/rename_dialog.cpp
msgid "Amount by which counter is incremented for each node"
-msgstr ""
+msgstr "å„節點的計數器的增加é‡"
#: editor/rename_dialog.cpp
msgid "Padding"
-msgstr ""
+msgstr "å¡«å……"
#: editor/rename_dialog.cpp
msgid ""
"Minimum number of digits for the counter.\n"
"Missing digits are padded with leading zeros."
msgstr ""
+"計數器的最å°ä½æ•¸ã€‚\n"
+"缺少的ä½æ•¸æœƒä»¥å‰ç½® 0 填充。"
#: editor/rename_dialog.cpp
msgid "Post-Process"
-msgstr ""
+msgstr "後處ç†"
#: editor/rename_dialog.cpp
msgid "Keep"
-msgstr ""
+msgstr "ä¿æŒ"
#: editor/rename_dialog.cpp
msgid "PascalCase to snake_case"
-msgstr ""
+msgstr "將大é§å³°æ³• (PascalCase) 轉為底線 (snake_case)"
#: editor/rename_dialog.cpp
msgid "snake_case to PascalCase"
-msgstr ""
+msgstr "將底線 (snake_case) 轉為é§å³°æ³• (PascalCase)"
#: editor/rename_dialog.cpp
msgid "Case"
-msgstr ""
+msgstr "大å°å¯«"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "To Lowercase"
-msgstr "轉æ›æˆ..."
+msgstr "轉為å°å¯«"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "To Uppercase"
-msgstr "轉æ›æˆ..."
+msgstr "轉為大寫"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "Reset"
-msgstr "é‡è¨­ç¸®æ”¾å¤§å°"
+msgstr "é‡è¨­"
#: editor/rename_dialog.cpp
msgid "Regular Expression Error"
-msgstr ""
+msgstr "æ­£è¦è¡¨ç¤ºå¼éŒ¯èª¤"
#: editor/rename_dialog.cpp
-#, fuzzy
msgid "At character %s"
-msgstr "åˆæ³•å­—å…ƒ:"
+msgstr "ä½æ–¼å­—å…ƒ %s"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
msgid "Reparent Node"
-msgstr ""
+msgstr "é‡è¨­æ¯ç¯€é»ž"
#: editor/reparent_dialog.cpp
msgid "Reparent Location (Select new Parent):"
-msgstr ""
+msgstr "é‡è¨­æ¯ä½ç½®ï¼ˆé¸æ“‡æ–°çš„æ¯ç¯€é»žï¼‰ï¼š"
#: editor/reparent_dialog.cpp
msgid "Keep Global Transform"
-msgstr ""
+msgstr "ä¿æŒå…¨åŸŸè®Šæ›"
#: editor/reparent_dialog.cpp editor/scene_tree_dock.cpp
msgid "Reparent"
-msgstr ""
+msgstr "é‡è¨­æ¯ç¯€é»ž"
#: editor/run_settings_dialog.cpp
msgid "Run Mode:"
-msgstr ""
+msgstr "執行模å¼ï¼š"
#: editor/run_settings_dialog.cpp
msgid "Current Scene"
-msgstr ""
+msgstr "ç›®å‰å ´æ™¯"
#: editor/run_settings_dialog.cpp
msgid "Main Scene"
-msgstr ""
+msgstr "主場景"
#: editor/run_settings_dialog.cpp
msgid "Main Scene Arguments:"
-msgstr ""
+msgstr "主場景引數:"
#: editor/run_settings_dialog.cpp
msgid "Scene Run Settings"
-msgstr ""
+msgstr "場景執行設定"
#: editor/scene_tree_dock.cpp
msgid "No parent to instance the scenes at."
-msgstr ""
+msgstr "ç„¡å¯å¯¦é«”化場景的æ¯ç¯€é»žã€‚"
#: editor/scene_tree_dock.cpp
msgid "Error loading scene from %s"
-msgstr ""
+msgstr "自 %s 中載入場景時發生錯誤"
#: editor/scene_tree_dock.cpp
msgid ""
"Cannot instance the scene '%s' because the current scene exists within one "
"of its nodes."
-msgstr ""
+msgstr "無法實體化場景「%sã€ï¼Œç”±æ–¼å…¶å·²å­˜åœ¨æ–¼å…¶ä¸€å­ç¯€é»žä¸­ã€‚"
#: editor/scene_tree_dock.cpp
msgid "Instance Scene(s)"
-msgstr ""
+msgstr "實體化場景"
#: editor/scene_tree_dock.cpp
msgid "Replace with Branch Scene"
-msgstr ""
+msgstr "å–代分支場景"
#: editor/scene_tree_dock.cpp
msgid "Instance Child Scene"
-msgstr ""
+msgstr "實體化å­å ´æ™¯"
#: editor/scene_tree_dock.cpp
-msgid "Clear Script"
-msgstr ""
+msgid "Detach Script"
+msgstr "å–消附加腳本"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on the tree root."
-msgstr ""
+msgstr "æ­¤æ“作無法在樹狀根執行。"
#: editor/scene_tree_dock.cpp
msgid "Move Node In Parent"
-msgstr ""
+msgstr "移動節點至其æ¯ç¯€é»ž"
#: editor/scene_tree_dock.cpp
msgid "Move Nodes In Parent"
-msgstr ""
+msgstr "移動節點至æ¯ç¯€é»ž"
#: editor/scene_tree_dock.cpp
msgid "Duplicate Node(s)"
-msgstr ""
+msgstr "é‡è¤‡ç¯€é»ž"
#: editor/scene_tree_dock.cpp
msgid "Can't reparent nodes in inherited scenes, order of nodes can't change."
-msgstr ""
+msgstr "無法é‡æ–°è¨­å®šç¹¼æ‰¿å ´æ™¯ç¯€é»žçš„æ¯ç¯€é»žï¼Œç¯€é»žçš„é †åºç„¡æ³•æ›´æ”¹ã€‚"
#: editor/scene_tree_dock.cpp
msgid "Node must belong to the edited scene to become root."
-msgstr ""
+msgstr "節點必須屬於已編輯的場景æ‰èƒ½è½‰ç‚ºæ ¹ç¯€é»žã€‚"
#: editor/scene_tree_dock.cpp
msgid "Instantiated scenes can't become root"
-msgstr ""
+msgstr "實體化的場景無法轉為根節點"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Make node as Root"
-msgstr "儲存場景"
+msgstr "將節點設為根節點"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete %d nodes?"
-msgstr "刪除"
+msgstr "刪除 %d 個節點?"
#: editor/scene_tree_dock.cpp
msgid "Delete the root node \"%s\"?"
-msgstr ""
+msgstr "確定è¦åˆªé™¤æ ¹ç¯€é»žã€Œ%sã€å—Žï¼Ÿ"
#: editor/scene_tree_dock.cpp
msgid "Delete node \"%s\" and its children?"
-msgstr ""
+msgstr "確定è¦åˆªé™¤ç¯€é»žã€Œ%sã€èˆ‡å…¶å­ç¯€é»žå—Žï¼Ÿ"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Delete node \"%s\"?"
-msgstr "刪除"
+msgstr "確定è¦åˆªé™¤ç¯€é»žã€Œ%sã€å—Žï¼Ÿ"
#: editor/scene_tree_dock.cpp
msgid "Can not perform with the root node."
-msgstr ""
+msgstr "無法在根節點執行此æ“作。"
#: editor/scene_tree_dock.cpp
msgid "This operation can't be done on instanced scenes."
-msgstr ""
+msgstr "該æ“作無法在已實體化場景中執行。"
#: editor/scene_tree_dock.cpp
msgid "Save New Scene As..."
-msgstr ""
+msgstr "å¦å­˜æ–°å ´æ™¯ç‚º..."
#: editor/scene_tree_dock.cpp
msgid ""
"Disabling \"editable_instance\" will cause all properties of the node to be "
"reverted to their default."
-msgstr ""
+msgstr "ç¦ç”¨ã€Œeditable_instanceã€å°‡å°Žè‡´ç¯€é»žçš„所有屬性都被還原為其é è¨­å€¼ã€‚"
#: editor/scene_tree_dock.cpp
msgid ""
"Enabling \"Load As Placeholder\" will disable \"Editable Children\" and "
"cause all properties of the node to be reverted to their default."
msgstr ""
+"啟用「載入為佔ä½ã€å°‡ç¦ç”¨ã€Œå¯ç·¨è¼¯å­ç¯€é»žã€ä¸¦å°Žè‡´å…¶æ‰€æœ‰ç¯€é»žéƒ½è¢«é‚„原為其é è¨­å€¼ã€‚"
#: editor/scene_tree_dock.cpp
msgid "Make Local"
-msgstr ""
+msgstr "轉為本地"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "New Scene Root"
-msgstr "儲存場景"
+msgstr "新場景根"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Create Root Node:"
-msgstr "新增資料夾"
+msgstr "建立根節點:"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "2D Scene"
-msgstr "場景"
+msgstr "2D 場景"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "3D Scene"
-msgstr "場景"
+msgstr "3D 場景"
#: editor/scene_tree_dock.cpp
msgid "User Interface"
-msgstr ""
+msgstr "使用者界é¢"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Other Node"
-msgstr "刪除"
+msgstr "其他節點"
#: editor/scene_tree_dock.cpp
msgid "Can't operate on nodes from a foreign scene!"
-msgstr ""
+msgstr "無法å°å¤–部場景的節點進行æ“作ï¼"
#: editor/scene_tree_dock.cpp
msgid "Can't operate on nodes the current scene inherits from!"
-msgstr ""
+msgstr "無法å°ç›®å‰å ´æ™¯ç¹¼æ‰¿ä¾†æºçš„節點進行æ“作ï¼"
#: editor/scene_tree_dock.cpp
msgid "Attach Script"
-msgstr ""
+msgstr "附加腳本"
#: editor/scene_tree_dock.cpp
msgid "Remove Node(s)"
-msgstr ""
+msgstr "移除節點"
#: editor/scene_tree_dock.cpp
msgid "Change type of node(s)"
-msgstr ""
+msgstr "更改節點的型別"
#: editor/scene_tree_dock.cpp
msgid ""
"Couldn't save new scene. Likely dependencies (instances) couldn't be "
"satisfied."
-msgstr ""
+msgstr "無法ä¿å­˜æ–°å ´æ™¯ã€‚很å¯èƒ½ç”±æ–¼ç„¡æ³•æ»¿è¶³å…¶ä¾è³´æ€§ï¼ˆå¯¦é«”)。"
#: editor/scene_tree_dock.cpp
msgid "Error saving scene."
-msgstr ""
+msgstr "ä¿å­˜å ´æ™¯æ™‚發生錯誤。"
#: editor/scene_tree_dock.cpp
msgid "Error duplicating scene to save it."
-msgstr ""
+msgstr "複製場景以進行ä¿å­˜æ™‚發生錯誤。"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Sub-Resources"
-msgstr "複製資æº"
+msgstr "å­è³‡æº"
#: editor/scene_tree_dock.cpp
msgid "Clear Inheritance"
-msgstr ""
+msgstr "清除繼承"
#: editor/scene_tree_dock.cpp
msgid "Editable Children"
-msgstr ""
+msgstr "å¯ç·¨è¼¯å­ç¯€é»ž"
#: editor/scene_tree_dock.cpp
msgid "Load As Placeholder"
-msgstr ""
+msgstr "載入為佔ä½"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Open Documentation"
-msgstr "開啟最近存å–"
+msgstr "開啟說明文件"
#: editor/scene_tree_dock.cpp
-msgid "Add Child Node"
+msgid ""
+"Cannot attach a script: there are no languages registered.\n"
+"This is probably because this editor was built with all language modules "
+"disabled."
msgstr ""
+"無法附加腳本:未註冊任何語言。\n"
+"有å¯èƒ½æ˜¯ç”±æ–¼ç·¨è¼¯å™¨åœ¨å»ºæ§‹æ™‚未啟用任何語言模組。"
+
+#: editor/scene_tree_dock.cpp
+msgid "Add Child Node"
+msgstr "新增å­ç¯€é»ž"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Expand/Collapse All"
-msgstr "å–代全部"
+msgstr "展開ï¼æ”¶åˆå…¨éƒ¨"
#: editor/scene_tree_dock.cpp
msgid "Change Type"
-msgstr ""
+msgstr "更改型別"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Reparent to New Node"
-msgstr "新增 %s"
+msgstr "é‡æ–°è¨­å®šæ¯ç¯€é»žç‚ºæ–°ç¯€é»ž"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Make Scene Root"
-msgstr "儲存場景"
+msgstr "設為場景根節點"
#: editor/scene_tree_dock.cpp
msgid "Merge From Scene"
-msgstr ""
+msgstr "åˆä½µè‡ªå ´æ™¯"
#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
msgid "Save Branch as Scene"
-msgstr ""
+msgstr "ä¿å­˜åˆ†æ”¯ç‚ºå ´æ™¯"
#: editor/scene_tree_dock.cpp editor/script_editor_debugger.cpp
msgid "Copy Node Path"
-msgstr ""
+msgstr "複製節點路徑"
#: editor/scene_tree_dock.cpp
msgid "Delete (No Confirm)"
-msgstr ""
+msgstr "刪除(無確èªï¼‰"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Add/Create a New Node."
-msgstr "新增 %s"
+msgstr "新增ï¼å»ºç«‹æ–°ç¯€é»žã€‚"
#: editor/scene_tree_dock.cpp
msgid ""
"Instance a scene file as a Node. Creates an inherited scene if no root node "
"exists."
-msgstr ""
+msgstr "將場景檔案實體化為節點。若無根節點則建立一個繼承場景。"
#: editor/scene_tree_dock.cpp
-msgid "Attach a new or existing script for the selected node."
-msgstr ""
+msgid "Attach a new or existing script to the selected node."
+msgstr "附加新的或已存在之腳本至所é¸ç¯€é»žã€‚"
#: editor/scene_tree_dock.cpp
-msgid "Clear a script for the selected node."
-msgstr ""
+msgid "Detach the script from the selected node."
+msgstr "自所é¸ç¯€é»žå–消附加腳本。"
#: editor/scene_tree_dock.cpp
-#, fuzzy
msgid "Remote"
-msgstr "移除"
+msgstr "é ç«¯"
#: editor/scene_tree_dock.cpp
msgid "Local"
-msgstr ""
+msgstr "本機"
#: editor/scene_tree_dock.cpp
msgid "Clear Inheritance? (No Undo!)"
-msgstr ""
+msgstr "確定è¦æ¸…除繼承嗎?(無法復原ï¼ï¼‰"
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Toggle Visible"
-msgstr "切æ›é¡¯ç¤ºéš±è—檔案"
+msgstr "切æ›å¯è¦‹ï¼éš±è—"
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Unlock Node"
-msgstr "單項節點"
+msgstr "解鎖節點"
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Button Group"
-msgstr "添加到組"
+msgstr "按éµåˆ†çµ„"
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "(Connecting From)"
-msgstr "連接..."
+msgstr "(連接自)"
#: editor/scene_tree_editor.cpp
msgid "Node configuration warning:"
-msgstr ""
+msgstr "節點組態設定警告:"
#: editor/scene_tree_editor.cpp
msgid ""
"Node has %s connection(s) and %s group(s).\n"
"Click to show signals dock."
msgstr ""
+"節點有 %s 連接與 %s 分組。\n"
+"點擊以顯示訊號 Dock。"
#: editor/scene_tree_editor.cpp
msgid ""
"Node has %s connection(s).\n"
"Click to show signals dock."
msgstr ""
+"節點有 %s 連接。\n"
+"點擊以顯示訊號 Dock。"
#: editor/scene_tree_editor.cpp
msgid ""
"Node is in %s group(s).\n"
"Click to show groups dock."
msgstr ""
+"節點ä½æ–¼ %s 個群組中。\n"
+"點擊以顯示群組 Dock。"
#: editor/scene_tree_editor.cpp
-#, fuzzy
msgid "Open Script:"
-msgstr "開啟最近存å–"
+msgstr "開啟腳本:"
#: editor/scene_tree_editor.cpp
msgid ""
"Node is locked.\n"
"Click to unlock it."
msgstr ""
+"節點已鎖定。\n"
+"點擊以解鎖。"
#: editor/scene_tree_editor.cpp
msgid ""
"Children are not selectable.\n"
"Click to make selectable."
msgstr ""
+"å­ç¯€é»žä¸å¯é¸æ“‡ã€‚\n"
+"點擊以令其å¯è¢«é¸æ“‡ã€‚"
#: editor/scene_tree_editor.cpp
msgid "Toggle Visibility"
-msgstr ""
+msgstr "切æ›å¯è¦‹ï¼éš±è—"
#: editor/scene_tree_editor.cpp
msgid ""
"AnimationPlayer is pinned.\n"
"Click to unpin."
msgstr ""
+"已固定動畫播放器 (AnimationPlayer)。\n"
+"點擊以å–消固定。"
#: editor/scene_tree_editor.cpp
msgid "Invalid node name, the following characters are not allowed:"
-msgstr ""
+msgstr "無效的節點å稱,å稱ä¸å¯åŒ…å«ä¸‹åˆ—字元:"
#: editor/scene_tree_editor.cpp
msgid "Rename Node"
-msgstr ""
+msgstr "é‡æ–°å‘½å節點"
#: editor/scene_tree_editor.cpp
msgid "Scene Tree (Nodes):"
-msgstr "場景樹 (節點):"
+msgstr "場景樹(節點):"
#: editor/scene_tree_editor.cpp
msgid "Node Configuration Warning!"
-msgstr ""
+msgstr "節點組態設定警告ï¼"
#: editor/scene_tree_editor.cpp
msgid "Select a Node"
-msgstr ""
+msgstr "é¸æ“‡ä¸€å€‹ç¯€é»ž"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Path is empty."
-msgstr "網格是空的ï¼"
+msgstr "路徑為空。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Filename is empty."
-msgstr "Sprite 是空的ï¼"
+msgstr "檔案å稱為空。"
#: editor/script_create_dialog.cpp
msgid "Path is not local."
-msgstr ""
+msgstr "路徑ä¸åœ¨æœ¬æ©Ÿã€‚"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Invalid base path."
-msgstr "無效的路徑."
+msgstr "無效的基礎路徑。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "A directory with the same name exists."
-msgstr "具有此å稱的檔或資料夾已存在。"
+msgstr "已有資料夾具有相åŒå稱。"
+
+#: editor/script_create_dialog.cpp
+msgid "File does not exist."
+msgstr "檔案ä¸å­˜åœ¨ã€‚"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Invalid extension."
-msgstr "必須使用有效的副檔å。"
+msgstr "無效的副檔å。"
#: editor/script_create_dialog.cpp
msgid "Wrong extension chosen."
-msgstr ""
+msgstr "é¸æ“‡äº†éŒ¯èª¤çš„副檔å。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Error loading template '%s'"
-msgstr "載入場景時發生錯誤"
+msgstr "載入樣æ¿ã€Œ%sã€æ™‚發生錯誤"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Error - Could not create script in filesystem."
-msgstr "無法新增資料夾"
+msgstr "錯誤 - 無法在檔案系統中建立腳本。"
#: editor/script_create_dialog.cpp
msgid "Error loading script from %s"
-msgstr ""
+msgstr "自 %s 載入腳本時發生錯誤"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Overrides"
-msgstr "覆蓋"
+msgstr "複寫"
#: editor/script_create_dialog.cpp
msgid "N/A"
-msgstr ""
+msgstr "N/A"
#: editor/script_create_dialog.cpp
msgid "Open Script / Choose Location"
-msgstr ""
+msgstr "開啟腳本ï¼é¸æ“‡ä½ç½®"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Open Script"
-msgstr "開啟最近存å–"
+msgstr "開啟腳本"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "File exists, it will be reused."
-msgstr "檔案已經存在, è¦è¦†å¯«å—Ž?"
+msgstr "檔案已存在,將被é‡è¤‡ä½¿ç”¨ã€‚"
+
+#: editor/script_create_dialog.cpp
+msgid "Invalid path."
+msgstr "無效的路徑。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Invalid class name."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的類型å稱。"
#: editor/script_create_dialog.cpp
msgid "Invalid inherited parent name or path."
-msgstr ""
+msgstr "繼承æ¯çš„å稱或路徑無效。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Script path/name is valid."
-msgstr "動畫樹有效。"
+msgstr "å¯ç”¨çš„腳本路徑ï¼å稱。"
#: editor/script_create_dialog.cpp
msgid "Allowed: a-z, A-Z, 0-9, _ and ."
-msgstr ""
+msgstr "å¯ä½¿ç”¨ï¼ša-zã€A-Zã€0-9ã€_ ä»¥åŠ ."
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Built-in script (into scene file)."
-msgstr "æ“作場景文件。"
+msgstr "內建腳本(到場景檔案中)。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Will create a new script file."
-msgstr "創建新矩形。"
+msgstr "將建立一個新的腳本檔案。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Will load an existing script file."
-msgstr "讀å–ç¾å­˜çš„ Bus é…置。"
+msgstr "將讀å–一個ç¾å­˜çš„腳本檔案。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Script file already exists."
-msgstr "Autoload「%sã€å·²ç¶“存在!"
+msgstr "腳本檔案已存在。"
#: editor/script_create_dialog.cpp
msgid ""
"Note: Built-in scripts have some limitations and can't be edited using an "
"external editor."
-msgstr ""
+msgstr "注æ„:內置腳本有些é™åˆ¶ï¼Œä¸”無法使用外部編輯器來編輯。"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Class Name:"
-msgstr "Class:"
+msgstr "類別å稱:"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Template:"
-msgstr "移除範本"
+msgstr "樣æ¿ï¼š"
#: editor/script_create_dialog.cpp
-#, fuzzy
msgid "Built-in Script:"
-msgstr "開啟最近存å–"
+msgstr "內建腳本:"
#: editor/script_create_dialog.cpp
msgid "Attach Node Script"
-msgstr ""
+msgstr "附加節點腳本"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Remote "
-msgstr "移除"
+msgstr "é ç«¯ "
#: editor/script_editor_debugger.cpp
msgid "Bytes:"
-msgstr ""
+msgstr "ä½å…ƒçµ„:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Warning:"
-msgstr "警告"
+msgstr "警告:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Error:"
-msgstr "錯誤ï¼"
+msgstr "錯誤:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "C++ Error"
-msgstr "連接..."
+msgstr "C++ 錯誤"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "C++ Error:"
-msgstr "連接..."
+msgstr "C++ 錯誤:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "C++ Source"
-msgstr "資æº"
+msgstr "C++ 原始檔"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Source:"
-msgstr "資æº"
+msgstr "原始檔:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "C++ Source:"
-msgstr "資æº"
+msgstr "C++ 原始檔:"
#: editor/script_editor_debugger.cpp
msgid "Stack Trace"
-msgstr ""
+msgstr "堆疊回溯"
#: editor/script_editor_debugger.cpp
msgid "Errors"
-msgstr ""
+msgstr "錯誤"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Child process connected."
-msgstr "æ–·ç·š"
+msgstr "已連線至å­è™•ç†ç¨‹åºã€‚"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Copy Error"
-msgstr "連接..."
+msgstr "複製錯誤"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Video RAM"
-msgstr "影片記憶體"
+msgstr "視訊記憶體"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Skip Breakpoints"
-msgstr "刪除"
+msgstr "è·³éŽä¸­æ–·é»ž"
#: editor/script_editor_debugger.cpp
msgid "Inspect Previous Instance"
-msgstr ""
+msgstr "åµæŸ¥å‰ä¸€å€‹å¯¦é«”"
#: editor/script_editor_debugger.cpp
msgid "Inspect Next Instance"
-msgstr ""
+msgstr "åµæŸ¥ä¸‹ä¸€å€‹å¯¦é«”"
#: editor/script_editor_debugger.cpp
msgid "Stack Frames"
-msgstr ""
+msgstr "堆疊框"
#: editor/script_editor_debugger.cpp
msgid "Profiler"
-msgstr ""
+msgstr "分æžå·¥å…·"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Network Profiler"
-msgstr "輸出專案"
+msgstr "網路分æžå·¥å…·"
#: editor/script_editor_debugger.cpp
msgid "Monitor"
-msgstr ""
+msgstr "檢視程å¼"
#: editor/script_editor_debugger.cpp
msgid "Value"
msgstr "數值"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Monitors"
-msgstr "監看畫é¢"
+msgstr "監視程å¼"
#: editor/script_editor_debugger.cpp
msgid "Pick one or more items from the list to display the graph."
-msgstr ""
+msgstr "å­åˆ—表中é¸æ“‡ä¸€å€‹æˆ–多個項目以顯示圖表。"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "List of Video Memory Usage by Resource:"
-msgstr "影片記憶體使用容é‡åˆ—表(ä¾è³‡æºåˆ¥):"
+msgstr "ä¾æ“šè³‡æºåˆ—出視訊記憶體佔用:"
#: editor/script_editor_debugger.cpp
msgid "Total:"
msgstr "總計:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Export list to a CSV file"
-msgstr "輸出專案"
+msgstr "匯出列表至 CSV 檔案"
#: editor/script_editor_debugger.cpp
msgid "Resource Path"
@@ -11392,11 +10888,11 @@ msgstr "資æºè·¯å¾‘"
#: editor/script_editor_debugger.cpp
msgid "Type"
-msgstr "é¡žåž‹"
+msgstr "型別"
#: editor/script_editor_debugger.cpp
msgid "Format"
-msgstr ""
+msgstr "æ ¼å¼"
#: editor/script_editor_debugger.cpp
msgid "Usage"
@@ -11407,41 +10903,36 @@ msgid "Misc"
msgstr "雜項"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Clicked Control:"
-msgstr "點擊控制:"
+msgstr "已點擊的 Control:"
#: editor/script_editor_debugger.cpp
-#, fuzzy
msgid "Clicked Control Type:"
-msgstr "點擊控制類型:"
+msgstr "已點擊的 Control 型別:"
#: editor/script_editor_debugger.cpp
msgid "Live Edit Root:"
-msgstr ""
+msgstr "å³æ™‚編輯根節點:"
#: editor/script_editor_debugger.cpp
msgid "Set From Tree"
-msgstr ""
+msgstr "自場景樹中設定"
#: editor/script_editor_debugger.cpp
msgid "Export measures as CSV"
-msgstr ""
+msgstr "匯出測é‡è³‡æ–™ç‚º CSV"
#: editor/settings_config_dialog.cpp
-#, fuzzy
msgid "Erase Shortcut"
-msgstr "æ·å¾‘"
+msgstr "清除快æ·éµ"
#: editor/settings_config_dialog.cpp
-#, fuzzy
msgid "Restore Shortcut"
-msgstr "æ·å¾‘"
+msgstr "é‡è¨­å¿«æ·éµ"
#: editor/settings_config_dialog.cpp
-#, fuzzy
msgid "Change Shortcut"
-msgstr "æ·å¾‘"
+msgstr "更改快æ·éµ"
#: editor/settings_config_dialog.cpp
msgid "Editor Settings"
@@ -11449,892 +10940,880 @@ msgstr "編輯器設定"
#: editor/settings_config_dialog.cpp
msgid "Shortcuts"
-msgstr "æ·å¾‘"
+msgstr "å¿«æ·éµ"
#: editor/settings_config_dialog.cpp
msgid "Binding"
-msgstr ""
+msgstr "ç¶å®š"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Light Radius"
-msgstr "變更光æºåŠå¾‘"
+msgstr "更改光照åŠå¾‘"
#: editor/spatial_editor_gizmos.cpp
msgid "Change AudioStreamPlayer3D Emission Angle"
-msgstr ""
+msgstr "更改音訊串æµæ’­æ”¾å™¨ 3D (AudioStreamPlayer3D) 發射角"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Camera FOV"
-msgstr "變更é¡é ­è¦–野(FOV)"
+msgstr "更改相機視角"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Camera Size"
-msgstr "變更é¡é ­å°ºå¯¸"
+msgstr "更改相機尺寸"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Notifier AABB"
-msgstr ""
+msgstr "更改通知器 AABB"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Particles AABB"
-msgstr ""
+msgstr "æ›´æ”¹ç²’å­ AABB"
#: editor/spatial_editor_gizmos.cpp
-#, fuzzy
msgid "Change Probe Extents"
-msgstr "變更框型範åœ"
+msgstr "更改探é‡ç¯„åœ"
#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
msgid "Change Sphere Shape Radius"
-msgstr "變更çƒåž‹åŠå¾‘"
+msgstr "更改çƒå½¢åŠå¾‘"
#: editor/spatial_editor_gizmos.cpp modules/csg/csg_gizmos.cpp
msgid "Change Box Shape Extents"
-msgstr "變更框型範åœ"
+msgstr "更改框形範åœ"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Capsule Shape Radius"
-msgstr "變更楕圓體åŠå¾‘"
+msgstr "更改楕圓形åŠå¾‘"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Capsule Shape Height"
-msgstr "變更楕圓體高度"
+msgstr "更改楕圓形高度"
#: editor/spatial_editor_gizmos.cpp
-#, fuzzy
msgid "Change Cylinder Shape Radius"
-msgstr "變更楕圓體åŠå¾‘"
+msgstr "更改圓柱形åŠå¾‘"
#: editor/spatial_editor_gizmos.cpp
-#, fuzzy
msgid "Change Cylinder Shape Height"
-msgstr "變更楕圓體高度"
+msgstr "更改圓柱形高度"
#: editor/spatial_editor_gizmos.cpp
msgid "Change Ray Shape Length"
-msgstr ""
+msgstr "更改射線形長度"
#: modules/csg/csg_gizmos.cpp
-#, fuzzy
msgid "Change Cylinder Radius"
-msgstr "變更光æºåŠå¾‘"
+msgstr "更改圓柱體åŠå¾‘"
#: modules/csg/csg_gizmos.cpp
-#, fuzzy
msgid "Change Cylinder Height"
-msgstr "變更楕圓體高度"
+msgstr "更改圓柱體高度"
#: modules/csg/csg_gizmos.cpp
-#, fuzzy
msgid "Change Torus Inner Radius"
-msgstr "變更çƒåž‹åŠå¾‘"
+msgstr "更改環é¢å…§åŠå¾‘"
#: modules/csg/csg_gizmos.cpp
-#, fuzzy
msgid "Change Torus Outer Radius"
-msgstr "變更光æºåŠå¾‘"
+msgstr "更改環é¢å¤–åŠå¾‘"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Select the dynamic library for this entry"
-msgstr ""
+msgstr "é¸æ“‡è©²é …目使用的動態函å¼åº«"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Select dependencies of the library for this entry"
-msgstr ""
+msgstr "é¸æ“‡è©²é …目的函å¼åº«ç›¸ä¾æ€§"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
-#, fuzzy
msgid "Remove current entry"
-msgstr "移除"
+msgstr "移除目å‰çš„é …ç›®"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Double click to create a new entry"
-msgstr ""
+msgstr "點兩下以建立新項目"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Platform:"
-msgstr ""
+msgstr "å¹³å°ï¼š"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Platform"
-msgstr ""
+msgstr "å¹³å°"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Dynamic Library"
-msgstr ""
+msgstr "動態函å¼åº«"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "Add an architecture entry"
-msgstr ""
+msgstr "新增一個架構項目"
#: modules/gdnative/gdnative_library_editor_plugin.cpp
msgid "GDNativeLibrary"
-msgstr ""
+msgstr "GDNative 函å¼åº«"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Enabled GDNative Singleton"
-msgstr ""
+msgstr "啟用 GDNative 單例"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
-#, fuzzy
msgid "Disabled GDNative Singleton"
-msgstr "ç¦æ­¢è‡ªå‹•æ›´æ–°"
+msgstr "ç¦ç”¨ GDNative 單例"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Library"
-msgstr ""
+msgstr "函å¼åº«"
#: modules/gdnative/gdnative_library_singleton_editor.cpp
msgid "Libraries: "
-msgstr ""
+msgstr "函å¼åº«ï¼š "
#: modules/gdnative/register_types.cpp
msgid "GDNative"
-msgstr ""
+msgstr "GDNative"
#: modules/gdscript/gdscript_functions.cpp
-#, fuzzy
msgid "Step argument is zero!"
-msgstr "step引數為0!"
+msgstr "Step 引數為 0ï¼"
#: modules/gdscript/gdscript_functions.cpp
msgid "Not a script with an instance"
-msgstr "éžç‚ºå–®ä¸€äº‹ä»¶è…³æœ¬"
+msgstr "腳本沒有實體"
#: modules/gdscript/gdscript_functions.cpp
-#, fuzzy
msgid "Not based on a script"
-msgstr "未ä¾æ“šè…³æœ¬"
+msgstr "éžåŸºæ–¼è…³æœ¬"
#: modules/gdscript/gdscript_functions.cpp
-#, fuzzy
msgid "Not based on a resource file"
-msgstr "未ä¾æ“šè³‡æºæª”案"
+msgstr "éžåŸºæ–¼è³‡æºæª”案"
#: modules/gdscript/gdscript_functions.cpp
-#, fuzzy
msgid "Invalid instance dictionary format (missing @path)"
-msgstr "無效的事件詞典格å¼(éºå¤± @path)"
+msgstr "無效的實體字典格å¼ï¼ˆç¼ºå°‘ @path)"
#: modules/gdscript/gdscript_functions.cpp
-#, fuzzy
msgid "Invalid instance dictionary format (can't load script at @path)"
-msgstr "無效的事件詞典格å¼(無法載入腳本 @path)"
+msgstr "無效的實體字典格å¼ï¼ˆç„¡æ³•è‡ª @path 載入腳本)"
#: modules/gdscript/gdscript_functions.cpp
-#, fuzzy
msgid "Invalid instance dictionary format (invalid script at @path)"
-msgstr "無效的事件詞典格å¼(無效的腳本 @path)"
+msgstr "無效的實體字典格å¼ï¼ˆä½æ–¼ @path 的腳本無效)"
#: modules/gdscript/gdscript_functions.cpp
msgid "Invalid instance dictionary (invalid subclasses)"
-msgstr ""
+msgstr "無效的實體字典(無效的å­é¡žåž‹ï¼‰"
#: modules/gdscript/gdscript_functions.cpp
msgid "Object can't provide a length."
-msgstr ""
+msgstr "物件無法æ供長度。"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Next Plane"
-msgstr "下個分é "
+msgstr "下一個平é¢"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Previous Plane"
-msgstr "上個分é "
+msgstr "上一個平é¢"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Plane:"
-msgstr ""
+msgstr "å¹³é¢ï¼š"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Next Floor"
-msgstr ""
+msgstr "下一個地æ¿"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Previous Floor"
-msgstr "上個分é "
+msgstr "上一個地æ¿"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Floor:"
-msgstr ""
+msgstr "地æ¿ï¼š"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "GridMap Delete Selection"
-msgstr "複製所é¸"
+msgstr "網格地圖刪除所é¸ç¯„åœ"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "GridMap Fill Selection"
-msgstr "複製所é¸"
+msgstr "網格地圖填充所é¸ç¯„åœ"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "GridMap Paste Selection"
-msgstr "複製所é¸"
+msgstr "網格地圖貼上所é¸ç¯„åœ"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "GridMap Paint"
-msgstr "專案設定"
+msgstr "網格地圖繪圖"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Grid Map"
-msgstr ""
+msgstr "網格地圖"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Snap View"
-msgstr ""
+msgstr "å¸é™„檢視"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Clip Disabled"
-msgstr "å·²åœç”¨"
+msgstr "剪è£å·²ç¦ç”¨"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clip Above"
-msgstr ""
+msgstr "剪è£ä¸Šæ–¹"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Clip Below"
-msgstr ""
+msgstr "剪è£ä¸‹æ–¹"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Edit X Axis"
-msgstr ""
+msgstr "編輯 X 軸"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Edit Y Axis"
-msgstr ""
+msgstr "編輯 Y 軸"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Edit Z Axis"
-msgstr ""
+msgstr "編輯 Z 軸"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Rotate X"
-msgstr ""
+msgstr "以éŠæ¨™æ²¿ X 軸旋轉"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Rotate Y"
-msgstr ""
+msgstr "以éŠæ¨™æ²¿ Y 軸旋轉"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Rotate Z"
-msgstr ""
+msgstr "以éŠæ¨™æ²¿ Z 軸旋轉"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Back Rotate X"
-msgstr ""
+msgstr "以éŠæ¨™æ²¿ X 軸åå‘旋轉"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Back Rotate Y"
-msgstr ""
+msgstr "以éŠæ¨™æ²¿ Y 軸åå‘旋轉"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Back Rotate Z"
-msgstr ""
+msgstr "以éŠæ¨™æ²¿ Z 軸åå‘旋轉"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Cursor Clear Rotation"
-msgstr ""
+msgstr "清除éŠæ¨™æ—‹è½‰"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Paste Selects"
-msgstr "擦除é¸ä¸­"
+msgstr "貼上所é¸"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Clear Selection"
-msgstr "所有的é¸æ“‡"
+msgstr "清除所é¸"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Fill Selection"
-msgstr "所有的é¸æ“‡"
+msgstr "填充所é¸"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "GridMap Settings"
-msgstr "專案設定"
+msgstr "網格地圖設定"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Pick Distance:"
-msgstr ""
+msgstr "é¸æ“‡è·é›¢ï¼š"
#: modules/gridmap/grid_map_editor_plugin.cpp
-#, fuzzy
msgid "Filter meshes"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "éŽæ¿¾ç¶²æ ¼"
#: modules/gridmap/grid_map_editor_plugin.cpp
msgid "Give a MeshLibrary resource to this GridMap to use its meshes."
-msgstr ""
+msgstr "æ供網格庫資æºäºˆè©²ç¶²æ ¼åœ°åœ–以使用其網格。"
#: modules/mono/csharp_script.cpp
msgid "Class name can't be a reserved keyword"
-msgstr ""
+msgstr "類別å稱ä¸èƒ½ç‚ºä¿ç•™é—œéµå­—"
#: modules/mono/mono_gd/gd_mono_utils.cpp
msgid "End of inner exception stack trace"
-msgstr ""
+msgstr "內部異常堆疊回溯çµæŸ"
#: modules/recast/navigation_mesh_editor_plugin.cpp
msgid "Bake NavMesh"
-msgstr "渲染NavMesh"
+msgstr "Bake 導航網格 (NavMesh)"
#: modules/recast/navigation_mesh_editor_plugin.cpp
msgid "Clear the navigation mesh."
-msgstr ""
+msgstr "清除導航網格 (Navigation Mesh)。"
#: modules/recast/navigation_mesh_generator.cpp
msgid "Setting up Configuration..."
-msgstr ""
+msgstr "正在設定組態..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Calculating grid size..."
-msgstr ""
+msgstr "正在計算網格大å°..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Creating heightfield..."
-msgstr ""
+msgstr "正在建立 Heightfield..."
#: modules/recast/navigation_mesh_generator.cpp
-#, fuzzy
msgid "Marking walkable triangles..."
-msgstr "正在儲存變更..."
+msgstr "正在標記å¯ç§»å‹•çš„三角形..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Constructing compact heightfield..."
-msgstr ""
+msgstr "正在建構緊湊 Heightfield..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Eroding walkable area..."
-msgstr ""
+msgstr "正在建立å¯ç§»å‹•å€åŸŸ..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Partitioning..."
-msgstr ""
+msgstr "正在分割..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Creating contours..."
-msgstr ""
+msgstr "正在建立輪廓..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Creating polymesh..."
-msgstr ""
+msgstr "正在建立多邊形網格 (Polymesh)..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Converting to native navigation mesh..."
-msgstr ""
+msgstr "正在轉æ›ç‚ºåŽŸç”Ÿå°Žèˆªç¶²æ ¼ (Native Navigation Mesh)..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Navigation Mesh Generator Setup:"
-msgstr ""
+msgstr "導航網格 (Navigation Mesh) 產生器設定:"
#: modules/recast/navigation_mesh_generator.cpp
msgid "Parsing Geometry..."
-msgstr ""
+msgstr "正在解æžå¤šé‚Šå½¢..."
#: modules/recast/navigation_mesh_generator.cpp
msgid "Done!"
-msgstr ""
+msgstr "完æˆï¼"
#: modules/visual_script/visual_script.cpp
msgid ""
"A node yielded without working memory, please read the docs on how to yield "
"properly!"
-msgstr ""
+msgstr "節點在無工作記憶體的情æ³ä¸‹è¢«ç”¢ç”Ÿã€‚請閱讀說明文件以瞭解如何正確產生ï¼"
#: modules/visual_script/visual_script.cpp
msgid ""
"Node yielded, but did not return a function state in the first working "
"memory."
-msgstr ""
+msgstr "已產生節點,但未在最åˆçš„工作記憶體內回傳函å¼ç‹€æ…‹ã€‚"
#: modules/visual_script/visual_script.cpp
-#, fuzzy
msgid ""
"Return value must be assigned to first element of node working memory! Fix "
"your node please."
-msgstr "回傳值需被指定為é‹ç®—記憶體節點的第一è¦ç´ !請修正該節點。"
+msgstr "回傳值需被指定為é‹ç®—記憶體節點的第一個元素ï¼è«‹ä¿®æ­£è©²ç¯€é»žã€‚"
#: modules/visual_script/visual_script.cpp
-#, fuzzy
msgid "Node returned an invalid sequence output: "
-msgstr "節點回傳一個無效的連續輸出: "
+msgstr "節點回傳了一個無效的連續輸出: "
#: modules/visual_script/visual_script.cpp
msgid "Found sequence bit but not the node in the stack, report bug!"
-msgstr ""
+msgstr "發ç¾äº†é€£çºŒä½å…ƒ (Sequance Bit) 但並éžåœ¨å †ç–Šä¸­çš„節點,請回報該錯誤ï¼"
#: modules/visual_script/visual_script.cpp
msgid "Stack overflow with stack depth: "
-msgstr ""
+msgstr "堆疊深度的堆疊溢出: "
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Signal Arguments"
-msgstr ""
+msgstr "更改訊號引數"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Argument Type"
-msgstr ""
+msgstr "更改引數型別"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Argument name"
-msgstr ""
+msgstr "更改引數å稱"
#: modules/visual_script/visual_script_editor.cpp
msgid "Set Variable Default Value"
-msgstr ""
+msgstr "設定變數é è¨­å€¼"
#: modules/visual_script/visual_script_editor.cpp
msgid "Set Variable Type"
-msgstr ""
+msgstr "設定變數型別"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Input Port"
-msgstr "添加輸入"
+msgstr "新增輸入埠å£"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Output Port"
-msgstr "添加輸入"
+msgstr "新增輸出埠å£"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Override an existing built-in function."
-msgstr "無效å稱.ä¸èƒ½èˆ‡ç¾æœ‰çš„內置類型å稱沖çª."
+msgstr "複寫一個ç¾æœ‰çš„內建函å¼ã€‚"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create a new function."
-msgstr "創建新矩形。"
+msgstr "建立新函å¼ã€‚"
#: modules/visual_script/visual_script_editor.cpp
msgid "Variables:"
-msgstr ""
+msgstr "變數:"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create a new variable."
-msgstr "創建新矩形。"
+msgstr "建立新變數。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Signals:"
-msgstr "訊號:"
+msgstr "訊號:"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create a new signal."
-msgstr "創建新多邊形。"
+msgstr "建立一個新的訊號。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Name is not a valid identifier:"
-msgstr ""
+msgstr "å稱ä¸æ˜¯ä¸€å€‹æœ‰æ•ˆçš„識別符:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Name already in use by another func/var/signal:"
-msgstr ""
+msgstr "å稱已被用於å¦ä¸€å€‹å‡½å¼ï¼è®Šæ•¸ï¼ä¿¡è™Ÿï¼š"
#: modules/visual_script/visual_script_editor.cpp
msgid "Rename Function"
-msgstr ""
+msgstr "é‡æ–°å‘½å函å¼"
#: modules/visual_script/visual_script_editor.cpp
msgid "Rename Variable"
-msgstr ""
+msgstr "é‡æ–°å‘½å變數"
#: modules/visual_script/visual_script_editor.cpp
msgid "Rename Signal"
-msgstr ""
+msgstr "é‡æ–°å‘½å訊號"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Function"
-msgstr ""
+msgstr "新增函å¼"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Delete input port"
-msgstr "刪除點"
+msgstr "刪除輸入埠å£"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Variable"
-msgstr ""
+msgstr "新增變數"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Signal"
-msgstr ""
+msgstr "新增訊號"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Remove Input Port"
-msgstr "刪除點"
+msgstr "移除輸入埠å£"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Remove Output Port"
-msgstr "刪除點"
+msgstr "移除輸出埠å£"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Expression"
-msgstr ""
+msgstr "更改表示å¼"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove VisualScript Nodes"
-msgstr ""
+msgstr "更改視覺腳本 (VisualScript) 節點"
#: modules/visual_script/visual_script_editor.cpp
msgid "Duplicate VisualScript Nodes"
-msgstr ""
+msgstr "é‡è¤‡è¦–覺腳本 (VisualScript) 節點"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a Getter. Hold Shift to drop a generic signature."
msgstr ""
+"æŒ‰ä½ %s 以拖移 Getter ç¯€é»žã€‚æŒ‰ä½ Shift 以拖移一個通用的簽章 (Signature)。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."
msgstr ""
+"æŒ‰ä½ Ctrl 以拖移 Getter ç¯€é»žã€‚æŒ‰ä½ Shift 以拖移一個通用的簽å (Signature)。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a simple reference to the node."
-msgstr ""
+msgstr "æŒ‰ä½ %s 以拖移一個簡單åƒç…§ (Simple Reference) 至該節點。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold Ctrl to drop a simple reference to the node."
-msgstr ""
+msgstr "æŒ‰ä½ Ctrl 以拖移一個簡單åƒç…§ (Simple Reference) 至該節點。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold %s to drop a Variable Setter."
-msgstr ""
+msgstr "æŒ‰ä½ %s 以拖移一個變數 Setter 節點。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Hold Ctrl to drop a Variable Setter."
-msgstr ""
+msgstr "æŒ‰ä½ Ctrl 以拖動一個變數 Setter 節點。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Preload Node"
-msgstr ""
+msgstr "新增餘載 (Preload) 節點"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Node(s) From Tree"
-msgstr ""
+msgstr "自樹中新增節點"
#: modules/visual_script/visual_script_editor.cpp
msgid ""
"Can't drop properties because script '%s' is not used in this scene.\n"
"Drop holding 'Shift' to just copy the signature."
msgstr ""
+"由於「%sã€æœªåœ¨è©²å ´æ™¯å…§ä½¿ç”¨ï¼Œç„¡æ³•æ‹–移屬性。\n"
+"按ä½ã€ŒShiftã€æ‹–移以複製簽å (Signature)。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Getter Property"
-msgstr ""
+msgstr "新增 Getter 屬性"
#: modules/visual_script/visual_script_editor.cpp
msgid "Add Setter Property"
-msgstr ""
+msgstr "新增 Setter 屬性"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Change Base Type"
-msgstr "變更é¡é ­å°ºå¯¸"
+msgstr "更改基礎型別"
#: modules/visual_script/visual_script_editor.cpp
msgid "Move Node(s)"
-msgstr ""
+msgstr "移動節點"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove VisualScript Node"
-msgstr ""
+msgstr "移除視覺腳本 (VisualScript) 節點"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Connect Nodes"
-msgstr "連接..."
+msgstr "連接節點"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Disconnect Nodes"
-msgstr "連接..."
+msgstr "斷開節點連接"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Connect Node Data"
-msgstr "連接..."
+msgstr "連接節點資料"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Connect Node Sequence"
-msgstr "連接..."
+msgstr "連接節點åºåˆ—"
#: modules/visual_script/visual_script_editor.cpp
msgid "Script already has function '%s'"
-msgstr ""
+msgstr "腳本已有函å¼ã€Œ%sã€"
#: modules/visual_script/visual_script_editor.cpp
msgid "Change Input Value"
-msgstr ""
+msgstr "更改輸入值"
#: modules/visual_script/visual_script_editor.cpp
msgid "Resize Comment"
-msgstr ""
+msgstr "調整註解尺寸"
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't copy the function node."
-msgstr ""
+msgstr "無法複製函å¼ç¯€é»žã€‚"
#: modules/visual_script/visual_script_editor.cpp
msgid "Clipboard is empty!"
-msgstr ""
+msgstr "剪貼簿為空ï¼"
#: modules/visual_script/visual_script_editor.cpp
msgid "Paste VisualScript Nodes"
-msgstr ""
+msgstr "貼上視覺腳本 (VisualScript) 節點"
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't create function with a function node."
-msgstr ""
+msgstr "無法通éŽå‡½å¼ç¯€é»žå»ºç«‹å‡½å¼ã€‚"
#: modules/visual_script/visual_script_editor.cpp
msgid "Can't create function of nodes from nodes of multiple functions."
-msgstr ""
+msgstr "無法自多個函å¼ç¯€é»žå»ºç«‹å‡½å¼ç¯€é»žã€‚"
#: modules/visual_script/visual_script_editor.cpp
msgid "Select at least one node with sequence port."
-msgstr ""
+msgstr "é¸æ“‡è‡³å°‘一個有åºåˆ—埠å£çš„節點。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Try to only have one sequence input in selection."
-msgstr ""
+msgstr "è«‹åªé¸æ“‡ä¸€å€‹åºåˆ—輸入。"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Create Function"
-msgstr "創建輪廓"
+msgstr "建立函å¼"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove Function"
-msgstr ""
+msgstr "移除函å¼"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove Variable"
-msgstr ""
+msgstr "移除變數"
#: modules/visual_script/visual_script_editor.cpp
msgid "Editing Variable:"
-msgstr ""
+msgstr "編輯變數:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Remove Signal"
-msgstr ""
+msgstr "移除訊號"
#: modules/visual_script/visual_script_editor.cpp
msgid "Editing Signal:"
-msgstr ""
+msgstr "編輯訊號:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Make Tool:"
-msgstr ""
+msgstr "製作工具:"
#: modules/visual_script/visual_script_editor.cpp
msgid "Members:"
-msgstr ""
+msgstr "æˆå“¡ï¼š"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Change Base Type:"
-msgstr "變更é¡é ­å°ºå¯¸"
+msgstr "更改基本型別:"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Nodes..."
-msgstr "添加節點..。"
+msgstr "新增節點..."
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Add Function..."
-msgstr "轉到函數…"
+msgstr "新增函å¼â€¦"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "function_name"
-msgstr "函數:"
+msgstr "function_name"
#: modules/visual_script/visual_script_editor.cpp
msgid "Select or create a function to edit its graph."
-msgstr ""
+msgstr "é¸æ“‡æˆ–建立一個函å¼ä»¥ç·¨è¼¯å…¶åœ–表。"
#: modules/visual_script/visual_script_editor.cpp
msgid "Delete Selected"
-msgstr ""
+msgstr "刪除所é¸"
#: modules/visual_script/visual_script_editor.cpp
msgid "Find Node Type"
-msgstr ""
+msgstr "尋找節點型別"
#: modules/visual_script/visual_script_editor.cpp
msgid "Copy Nodes"
-msgstr ""
+msgstr "複製節點"
#: modules/visual_script/visual_script_editor.cpp
msgid "Cut Nodes"
-msgstr ""
+msgstr "剪下節點"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Make Function"
-msgstr "函數:"
+msgstr "產生函å¼"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Refresh Graph"
-msgstr "é‡æ–°æ•´ç†"
+msgstr "é‡æ–°æ•´ç†åœ–表"
#: modules/visual_script/visual_script_editor.cpp
-#, fuzzy
msgid "Edit Member"
-msgstr "éŽæ¿¾æª”案..."
+msgstr "編輯æˆå“¡"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Input type not iterable: "
-msgstr ""
+msgstr "輸入型別éžå¯è¿­ä»£åž‹åˆ¥ï¼š "
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Iterator became invalid"
-msgstr ""
+msgstr "迭代器已ä¸å¯ç”¨"
#: modules/visual_script/visual_script_flow_control.cpp
msgid "Iterator became invalid: "
-msgstr ""
+msgstr "迭代器已ä¸å¯ç”¨ï¼š "
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Invalid index property name."
-msgstr ""
+msgstr "無效的索引屬性å稱。"
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Base object is not a Node!"
-msgstr ""
+msgstr "基礎物件ä¸æ˜¯ä¸€å€‹ç¯€é»žï¼"
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Path does not lead Node!"
-msgstr ""
+msgstr "路徑未指å‘節點ï¼"
#: modules/visual_script/visual_script_func_nodes.cpp
msgid "Invalid index property name '%s' in node %s."
-msgstr ""
+msgstr "無效的索引屬性å稱「%sã€ï¼Œæ–¼ç¯€é»žã€Œ%sã€ã€‚"
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid argument of type: "
-msgstr ""
+msgstr ": 無效的引數型別 : "
#: modules/visual_script/visual_script_nodes.cpp
msgid ": Invalid arguments: "
-msgstr ""
+msgstr ": 無效的引數 : "
#: modules/visual_script/visual_script_nodes.cpp
msgid "VariableGet not found in script: "
-msgstr ""
+msgstr "腳本中未找到 VariableGet(å–得變數): "
#: modules/visual_script/visual_script_nodes.cpp
msgid "VariableSet not found in script: "
-msgstr ""
+msgstr "腳本中未找到 VariableSet(設定變數): "
#: modules/visual_script/visual_script_nodes.cpp
msgid "Custom node has no _step() method, can't process graph."
-msgstr ""
+msgstr "自定節點沒有 _step() 方法,無法產生圖表。"
#: modules/visual_script/visual_script_nodes.cpp
msgid ""
"Invalid return value from _step(), must be integer (seq out), or string "
"(error)."
-msgstr ""
+msgstr "_step() 的回傳值無效,必須為整數 (Seq Out) 或字串 (Error)。"
#: modules/visual_script/visual_script_property_selector.cpp
-#, fuzzy
msgid "Search VisualScript"
-msgstr "æœå°‹å¹«åŠ©"
+msgstr "æœå°‹è¦–覺腳本 (VisualScript)"
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Get %s"
-msgstr ""
+msgstr "å–å¾— %s"
#: modules/visual_script/visual_script_property_selector.cpp
msgid "Set %s"
-msgstr ""
+msgstr "設定 %s"
#: platform/android/export/export.cpp
msgid "Package name is missing."
-msgstr ""
+msgstr "缺少套件å稱。"
#: platform/android/export/export.cpp
msgid "Package segments must be of non-zero length."
-msgstr ""
+msgstr "套件片段 (Segment) 的長度ä¸å¯ç‚º 0。"
#: platform/android/export/export.cpp
msgid "The character '%s' is not allowed in Android application package names."
-msgstr ""
+msgstr "Android 應用程å¼å¥—件å稱ä¸å¯ä½¿ç”¨å­—元「%sã€ã€‚"
#: platform/android/export/export.cpp
msgid "A digit cannot be the first character in a package segment."
-msgstr ""
+msgstr "套件片段 (Segment) 的第一個字元ä¸å¯ç‚ºæ•¸å­—。"
#: platform/android/export/export.cpp
msgid "The character '%s' cannot be the first character in a package segment."
-msgstr ""
+msgstr "套件片段 (Segment) 的第一個字元ä¸å¯ç‚ºã€Œ%sã€ã€‚"
#: platform/android/export/export.cpp
msgid "The package must have at least one '.' separator."
-msgstr ""
+msgstr "套件必須至少有一個「.ã€åˆ†éš”字元。"
#: platform/android/export/export.cpp
msgid "Select device from the list"
-msgstr "從清單中é¸æ“‡è¨­å‚™"
+msgstr "自清單中é¸æ“‡è£ç½®"
#: platform/android/export/export.cpp
msgid "ADB executable not configured in the Editor Settings."
-msgstr ""
+msgstr "尚未於編輯器設定中設定 ADB å¯åŸ·è¡Œæª”。"
#: platform/android/export/export.cpp
msgid "OpenJDK jarsigner not configured in the Editor Settings."
-msgstr ""
+msgstr "尚未於編輯器設定中設定 OpenJDK Jarsigner。"
#: platform/android/export/export.cpp
msgid "Debug keystore not configured in the Editor Settings nor in the preset."
-msgstr ""
+msgstr "尚未於編輯器設定或 Preset 中設定除錯鑰匙圈 (Keystore)。"
+
+#: platform/android/export/export.cpp
+msgid "Release keystore incorrectly configured in the export preset."
+msgstr "釋出 Keystore 中ä¸æ­£ç¢ºä¹‹çµ„態設定至匯出 Preset。"
#: platform/android/export/export.cpp
msgid "Custom build requires a valid Android SDK path in Editor Settings."
-msgstr ""
+msgstr "自定建構需è¦æœ‰åœ¨ç·¨è¼¯å™¨è¨­å®šä¸­è¨­å®šä¸€å€‹æœ‰æ•ˆçš„ Android SDK ä½ç½®ã€‚"
#: platform/android/export/export.cpp
msgid "Invalid Android SDK path for custom build in Editor Settings."
-msgstr ""
+msgstr "編輯器設定中用於自定義設定之 Android SDK 路徑無效。"
#: platform/android/export/export.cpp
msgid ""
"Android build template not installed in the project. Install it from the "
"Project menu."
-msgstr ""
+msgstr "å°šæœªæ–¼å°ˆæ¡ˆä¸­å®‰è£ Android 建構樣æ¿ã€‚請先於專案目錄中進行安è£ã€‚"
#: platform/android/export/export.cpp
msgid "Invalid public key for APK expansion."
-msgstr ""
+msgstr "無效的 APK Expansion 公鑰。"
#: platform/android/export/export.cpp
-#, fuzzy
msgid "Invalid package name:"
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的套件å稱:"
+
+#: platform/android/export/export.cpp
+msgid ""
+"Invalid \"GodotPaymentV3\" module included in the \"android/modules\" "
+"project setting (changed in Godot 3.2.2).\n"
+msgstr ""
+"「andoird/modulesã€å°ˆæ¡ˆè¨­å®šä¸­åŒ…å«äº†ç„¡æ•ˆçš„「GodotPaymentV3ã€æ¨¡çµ„(更改於 "
+"Godot 3.2.2)。\n"
+
+#: platform/android/export/export.cpp
+msgid "\"Use Custom Build\" must be enabled to use the plugins."
+msgstr "「使用自定建構ã€å¿…須啟用以使用本外掛。"
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR"
+"\"."
+msgstr ""
+"「Degrees Of Freedomã€ï¼ˆè‡ªç”±è§’度)僅å¯åœ¨ã€ŒXr Modeã€ï¼ˆXR 模å¼ï¼‰è¨­ç‚ºã€ŒOculus "
+"Mobile VRã€æ™‚å¯ç”¨ã€‚"
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"「Hand Trackingã€ï¼ˆæ‰‹éƒ¨è¿½è¹¤ï¼‰åƒ…å¯åœ¨ã€ŒXr Modeã€ï¼ˆXR 模å¼ï¼‰è¨­ç‚ºã€ŒOculus Mobile "
+"VRã€æ™‚å¯ç”¨ã€‚"
+
+#: platform/android/export/export.cpp
+msgid ""
+"\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."
+msgstr ""
+"「Focus Awarenessã€ï¼ˆæ高關注度)僅å¯åœ¨ã€ŒXr Modeã€ï¼ˆXR 模å¼ï¼‰è¨­ç‚ºã€ŒOculus "
+"Mobile VRã€æ™‚å¯ç”¨ã€‚"
#: platform/android/export/export.cpp
msgid ""
"Trying to build from a custom built template, but no version info for it "
"exists. Please reinstall from the 'Project' menu."
msgstr ""
+"嘗試自自定建構樣æ¿é€²è¡Œå»ºæ§‹ï¼Œä½†ç„¡ç‰ˆæœ¬è³‡è¨Šå¯ç”¨ã€‚請自「專案ã€é¸å–®ä¸­é‡æ–°å®‰è£ã€‚"
#: platform/android/export/export.cpp
msgid ""
@@ -12343,155 +11822,150 @@ msgid ""
" Godot Version: %s\n"
"Please reinstall Android build template from 'Project' menu."
msgstr ""
+"Android 建構版本ä¸ç¬¦åˆï¼š\n"
+" 已安è£çš„樣æ¿ï¼š%s\n"
+" Godot 版本:%s\n"
+"請自「專案ã€ç›®éŒ„中é‡æ–°å®‰è£ Android 建構樣æ¿ã€‚"
#: platform/android/export/export.cpp
msgid "Building Android Project (gradle)"
-msgstr ""
+msgstr "建構 Android 專案(Gradle)"
#: platform/android/export/export.cpp
msgid ""
"Building of Android project failed, check output for the error.\n"
"Alternatively visit docs.godotengine.org for Android build documentation."
msgstr ""
+"建構 Android 專案失敗,請檢查輸出以確èªéŒ¯èª¤ã€‚\n"
+"也å¯ä»¥ç€è¦½ docs.godotengine.org 以ç€è¦½ Android 建構說明文件。"
#: platform/android/export/export.cpp
msgid "No build apk generated at: "
-msgstr ""
+msgstr "無建構 APK 產生於: "
#: platform/iphone/export/export.cpp
msgid "Identifier is missing."
-msgstr ""
+msgstr "缺少識別符。"
#: platform/iphone/export/export.cpp
msgid "The character '%s' is not allowed in Identifier."
-msgstr ""
+msgstr "字元「%sã€ä¸å¯ç”¨æ–¼è­˜åˆ¥ç¬¦ä¸­ã€‚"
#: platform/iphone/export/export.cpp
msgid "App Store Team ID not specified - cannot configure the project."
-msgstr ""
+msgstr "尚未設定 App Store Team ID - 無法設定專案。"
#: platform/iphone/export/export.cpp
-#, fuzzy
msgid "Invalid Identifier:"
-msgstr "無效的字體大å°ã€‚"
+msgstr "無效的識別符:"
#: platform/iphone/export/export.cpp
msgid "Required icon is not specified in the preset."
-msgstr ""
+msgstr "必須在 Preset 中指定必填圖示。"
#: platform/javascript/export/export.cpp
msgid "Stop HTTP Server"
-msgstr ""
+msgstr "åœæ­¢ HTTP 伺æœå™¨"
#: platform/javascript/export/export.cpp
msgid "Run in Browser"
-msgstr ""
+msgstr "在ç€è¦½å™¨ä¸­åŸ·è¡Œ"
#: platform/javascript/export/export.cpp
msgid "Run exported HTML in the system's default browser."
-msgstr ""
+msgstr "在系統的é è¨­ç€è¦½å™¨ä¸­åŸ·è¡Œå·²åŒ¯å‡ºçš„ HTML。"
#: platform/javascript/export/export.cpp
-#, fuzzy
msgid "Could not write file:"
-msgstr "無法新增資料夾"
+msgstr "無法寫入檔案:"
#: platform/javascript/export/export.cpp
-#, fuzzy
msgid "Could not open template for export:"
-msgstr "無法新增資料夾"
+msgstr "無法開啟樣æ¿ä»¥è¼¸å‡ºï¼š"
#: platform/javascript/export/export.cpp
msgid "Invalid export template:"
-msgstr ""
+msgstr "無效的輸出樣æ¿ï¼š"
#: platform/javascript/export/export.cpp
-#, fuzzy
msgid "Could not read custom HTML shell:"
-msgstr "無法新增資料夾"
+msgstr "無法讀å–自定 HTML Shell:"
#: platform/javascript/export/export.cpp
-#, fuzzy
msgid "Could not read boot splash image file:"
-msgstr "無法新增資料夾"
+msgstr "無法讀å–å•Ÿå‹•ç•«é¢åœ–檔:"
#: platform/javascript/export/export.cpp
-#, fuzzy
msgid "Using default boot splash image."
-msgstr "無法新增資料夾"
+msgstr "使用é è¨­å•Ÿå‹•ç•«é¢åœ–檔。"
#: platform/uwp/export/export.cpp
-#, fuzzy
msgid "Invalid package short name."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的套件段å稱。"
#: platform/uwp/export/export.cpp
-#, fuzzy
msgid "Invalid package unique name."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的套件唯一å稱。"
#: platform/uwp/export/export.cpp
-#, fuzzy
msgid "Invalid package publisher display name."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的套件發佈者顯示å稱。"
#: platform/uwp/export/export.cpp
-#, fuzzy
msgid "Invalid product GUID."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "ç„¡æ•ˆçš„ç”¢å“ GUID。"
#: platform/uwp/export/export.cpp
-#, fuzzy
msgid "Invalid publisher GUID."
-msgstr "無效的路徑"
+msgstr "無效的發佈者 GUID。"
#: platform/uwp/export/export.cpp
-#, fuzzy
msgid "Invalid background color."
-msgstr "ä¸èƒ½ä½¿ç”¨çš„å稱。"
+msgstr "無效的背景é¡è‰²ã€‚"
#: platform/uwp/export/export.cpp
msgid "Invalid Store Logo image dimensions (should be 50x50)."
-msgstr ""
+msgstr "無效的商店 LOGO 圖片尺寸(需為 50x50)。"
#: platform/uwp/export/export.cpp
msgid "Invalid square 44x44 logo image dimensions (should be 44x44)."
-msgstr ""
+msgstr "無效的矩形 44x44 LOGO 圖片尺寸(需為 44x44)。"
#: platform/uwp/export/export.cpp
msgid "Invalid square 71x71 logo image dimensions (should be 71x71)."
-msgstr ""
+msgstr "無效的矩形 71x71 LOGO 圖片尺寸(需為 71x71)。"
#: platform/uwp/export/export.cpp
msgid "Invalid square 150x150 logo image dimensions (should be 150x150)."
-msgstr ""
+msgstr "無效的矩形 150x150 LOGO 圖片尺寸(需為 150x150)。"
#: platform/uwp/export/export.cpp
msgid "Invalid square 310x310 logo image dimensions (should be 310x310)."
-msgstr ""
+msgstr "無效的矩形 310x310 LOGO 圖片尺寸(需為 310x310)。"
#: platform/uwp/export/export.cpp
msgid "Invalid wide 310x150 logo image dimensions (should be 310x150)."
-msgstr ""
+msgstr "無效的寬 310x150 LOGO 圖片尺寸(需為 310x150)。"
#: platform/uwp/export/export.cpp
msgid "Invalid splash screen image dimensions (should be 620x300)."
-msgstr ""
+msgstr "無效的啟動畫é¢åœ–片尺寸(應為 620x300)。"
#: scene/2d/animated_sprite.cpp
-#, fuzzy
msgid ""
"A SpriteFrames resource must be created or set in the \"Frames\" property in "
"order for AnimatedSprite to display frames."
-msgstr "SpriteFrames資æºå¿…須在Frames屬性中被創建或設置æ‰èƒ½å¤ é¡¯ç¤ºå‹•ç•«æ ¼ã€‚"
+msgstr ""
+"必須先為「Framesã€å±¬æ€§å»ºç«‹æˆ–設定 SpriteFrames 資æºä»¥ä»¤ AnimatedSprite 顯示影"
+"格。"
#: scene/2d/canvas_modulate.cpp
msgid ""
"Only one visible CanvasModulate is allowed per scene (or set of instanced "
"scenes). The first created one will work, while the rest will be ignored."
msgstr ""
-"æ¯å€‹å ´æ™¯ä¸­åƒ…å…許一個å¯è¦‹çš„CanvasModulate,åªæœ‰ç¬¬ä¸€å€‹CanvasModulate會有作用,"
-"其餘的將被忽略。"
+"æ¯å€‹å ´æ™¯ï¼ˆæˆ–實體化的場景集)中僅å…許一個å¯è¦‹çš„ CanvasModulate。åªæœ‰ç¬¬ä¸€å€‹å»ºç«‹"
+"的 CanvasModulate 有用,其餘的將被忽略。"
#: scene/2d/collision_object_2d.cpp
msgid ""
@@ -12499,6 +11973,9 @@ msgid ""
"Consider adding a CollisionShape2D or CollisionPolygon2D as a child to "
"define its shape."
msgstr ""
+"該節點無形狀,故無法與其他物件碰撞或互動。\n"
+"請考慮新增一個 CollisionShape2D 或 CollisionPolygon2D 為其å­ç¯€é»žä»¥å®šç¾©å…¶å½¢"
+"狀。"
#: scene/2d/collision_polygon_2d.cpp
msgid ""
@@ -12506,12 +11983,13 @@ msgid ""
"CollisionObject2D derived node. Please only use it as a child of Area2D, "
"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
msgstr ""
-"CollisionPolygon2Dåªèƒ½ç‚ºCollisionObject2Dè¡ç”Ÿçš„節點æ供碰撞形狀資訊,請將其使"
-"用於Area2Dã€StaticBody2Dã€RigidBody2Dã€KinematicBody2D這類的節點下。"
+"CollisionPolygon2D åªèƒ½ç‚º CollisionObject2D è¡ç”Ÿçš„節點æ供碰撞形狀資訊。請僅"
+"æ–¼ Area2Dã€StaticBody2Dã€RigidBody2Dã€KinematicBody2D…等節點下作為å­ç¯€é»žä½¿"
+"用。"
#: scene/2d/collision_polygon_2d.cpp
msgid "An empty CollisionPolygon2D has no effect on collision."
-msgstr "空白的CollisionPolygon2Dä¸èµ·ç¢°æ’žåµæ¸¬çš„作用。"
+msgstr "空白的 CollisionPolygon2D ä¸æœƒç”¢ç”Ÿä»»ä½•ç¢°æ’žæ•ˆæžœã€‚"
#: scene/2d/collision_shape_2d.cpp
msgid ""
@@ -12519,54 +11997,59 @@ msgid ""
"CollisionObject2D derived node. Please only use it as a child of Area2D, "
"StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."
msgstr ""
-"CollisionShape2Dåªèƒ½ç‚ºCollisionObject2Dè¡ç”Ÿçš„節點æ供碰撞形狀資訊,請將其使用"
-"æ–¼Area2Dã€StaticBody2Dã€RigidBody2Dã€KinematicBody2D這類的節點下。"
+"CollisionShape2D åªèƒ½ç‚º CollisionObject2D è¡ç”Ÿçš„節點æ供碰撞形狀資訊。請僅於 "
+"Area2Dã€StaticBody2Dã€RigidBody2Dã€KinematicBody2D…等節點下作為å­ç¯€é»žä½¿ç”¨ä»¥æ"
+"供形狀。"
#: scene/2d/collision_shape_2d.cpp
msgid ""
"A shape must be provided for CollisionShape2D to function. Please create a "
"shape resource for it!"
-msgstr "CollisionShape2D必須被賦予形狀æ‰èƒ½é‹ä½œï¼Œè«‹ç‚ºå®ƒå»ºç«‹å€‹å½¢ç‹€å§ï¼"
+msgstr "CollisionShape2D 必須被賦予形狀æ‰èƒ½é‹ä½œã€‚請先建立形狀ï¼"
#: scene/2d/cpu_particles_2d.cpp
msgid ""
"CPUParticles2D animation requires the usage of a CanvasItemMaterial with "
"\"Particles Animation\" enabled."
msgstr ""
+"CPUParticles2D 動畫需è¦ä½¿ç”¨æœ‰å•Ÿç”¨ã€ŒParticles Animation(粒å­å‹•ç•«ï¼‰ã€çš„ "
+"CanvasItemMaterial。"
#: scene/2d/light_2d.cpp
-#, fuzzy
msgid ""
"A texture with the shape of the light must be supplied to the \"Texture\" "
"property."
-msgstr "光照形狀的æ質必須被賦與在æ質的屬性中。"
+msgstr "有光照形狀的紋ç†å¿…é ˆæ供「紋ç†ã€å±¬æ€§ã€‚"
#: scene/2d/light_occluder_2d.cpp
msgid ""
"An occluder polygon must be set (or drawn) for this occluder to take effect."
-msgstr "æ­¤é®å…‰é«”必須被建立或設置é®è”½å½¢ç‹€æ‰èƒ½ç™¼æ®é®è”½ä½œç”¨ã€‚"
+msgstr "該é®å…‰é«”å¿…é ˆè¦æœ‰è¨­å®šï¼ˆæˆ–繪製)é®å…‰é«”形狀æ‰æœƒæœ‰ä½œç”¨ã€‚"
#: scene/2d/light_occluder_2d.cpp
-#, fuzzy
msgid "The occluder polygon for this occluder is empty. Please draw a polygon."
-msgstr "æ­¤é®å…‰é«”沒有被賦予形狀,請繪製一個å§ï¼"
+msgstr "é®å…‰é«”ç„¡é®å…‰é«”多邊形。請先繪製一個多邊形。"
#: scene/2d/navigation_polygon.cpp
msgid ""
"A NavigationPolygon resource must be set or created for this node to work. "
"Please set a property or draw a polygon."
msgstr ""
+"必須先在該節點上設定或建立 NavigationPolygon æ‰å¯ä»¥ä½¿ç”¨ã€‚請設定一個屬性或繪製"
+"多邊形。"
#: scene/2d/navigation_polygon.cpp
msgid ""
"NavigationPolygonInstance must be a child or grandchild to a Navigation2D "
"node. It only provides navigation data."
msgstr ""
+"NavigationPolygonInstance 必須是 Navigation2D 節點的å­ç´šæˆ–次å­ç´šã€‚其僅æ供導"
+"航資料。"
#: scene/2d/parallax_layer.cpp
msgid ""
"ParallaxLayer node only works when set as child of a ParallaxBackground node."
-msgstr ""
+msgstr "ParallaxLayer 節點僅在當其被設為 ParallaxBackground çš„å­ç¯€é»žæ™‚有效。"
#: scene/2d/particles_2d.cpp
msgid ""
@@ -12574,22 +12057,24 @@ msgid ""
"Use the CPUParticles2D node instead. You can use the \"Convert to "
"CPUParticles\" option for this purpose."
msgstr ""
+"GLES2 視訊驅動程å¼ç›®å‰ä¸æ”¯æ´åŸºæ–¼ GPU çš„ç²’å­ã€‚\n"
+"請改為使用 CPUParticles2D 節點。你å¯ä»¥ä½¿ç”¨ã€Œè½‰æ›ç‚º CPUParticlesã€é¸é …。"
#: scene/2d/particles_2d.cpp scene/3d/particles.cpp
msgid ""
"A material to process the particles is not assigned, so no behavior is "
"imprinted."
-msgstr ""
+msgstr "尚未指定è¦è™•ç†ç²’å­çš„æ料,故未產生任何行為。"
#: scene/2d/particles_2d.cpp
msgid ""
"Particles2D animation requires the usage of a CanvasItemMaterial with "
"\"Particles Animation\" enabled."
-msgstr ""
+msgstr "Particles2D 動畫需è¦ä½¿ç”¨é–‹å•Ÿäº†ã€Œç²’å­å‹•ç•«ã€çš„ CanvasItemMaterial。"
#: scene/2d/path_2d.cpp
msgid "PathFollow2D only works when set as a child of a Path2D node."
-msgstr ""
+msgstr "PathFollow2D 僅在其為 Path2D çš„å­ç¯€é»žæ™‚有效。"
#: scene/2d/physics_body_2d.cpp
msgid ""
@@ -12597,91 +12082,94 @@ msgid ""
"by the physics engine when running.\n"
"Change the size in children collision shapes instead."
msgstr ""
+"(在 Character 或 Rigid Mode 下)更改 RigidBody2D 的大å°å°‡æœƒåœ¨åŸ·è¡Œæ™‚被物ç†å¼•"
+"擎複寫。\n"
+"請改為修改其å­ç¯€é»žçš„碰撞形狀之大å°ã€‚"
#: scene/2d/remote_transform_2d.cpp
msgid "Path property must point to a valid Node2D node to work."
-msgstr ""
+msgstr "路徑屬性必須指å‘一個有效的 Node2D æ‰å¯ç”¨ã€‚"
#: scene/2d/skeleton_2d.cpp
msgid "This Bone2D chain should end at a Skeleton2D node."
-msgstr ""
+msgstr "該 Bone2D éˆå¿…須以 Skeleton2D 節點çµå°¾ã€‚"
#: scene/2d/skeleton_2d.cpp
msgid "A Bone2D only works with a Skeleton2D or another Bone2D as parent node."
-msgstr ""
+msgstr "Bone2D 僅在其為 Skeleton2D 或å¦ä¸€å€‹ Bone2D çš„å­ç¯€é»žæ™‚有效。"
#: scene/2d/skeleton_2d.cpp
msgid ""
"This bone lacks a proper REST pose. Go to the Skeleton2D node and set one."
-msgstr ""
+msgstr "該骨骼缺少é©ç•¶çš„ REST 姿勢。請跳至 Skeleton2D 節點並進行設定。"
#: scene/2d/tile_map.cpp
-#, fuzzy
msgid ""
"TileMap with Use Parent on needs a parent CollisionObject2D to give shapes "
"to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, "
"KinematicBody2D, etc. to give them a shape."
msgstr ""
-"CollisionShape2Dåªèƒ½ç‚ºCollisionObject2Dè¡ç”Ÿçš„節點æ供碰撞形狀資訊,請將其使用"
-"æ–¼Area2Dã€StaticBody2Dã€RigidBody2Dã€KinematicBody2D這類的節點下。"
+"CollisionShape2D åªèƒ½ç‚º CollisionObject2D è¡ç”Ÿçš„節點æ供碰撞形狀資訊。請將其"
+"設為 Area2Dã€StaticBody2Dã€RigidBody2Dã€KinematicBody2D… çš„å­ç¯€é»žä»¥è³¦äºˆå…¶å½¢"
+"狀。"
#: scene/2d/visibility_notifier_2d.cpp
msgid ""
"VisibilityEnabler2D works best when used with the edited scene root directly "
"as parent."
-msgstr ""
+msgstr "VisibilityEnabler2D 在直接作為已編輯場景的根節點的æ¯ç´šç¯€é»žæ™‚效果最佳。"
#: scene/3d/arvr_nodes.cpp
msgid "ARVRCamera must have an ARVROrigin node as its parent."
-msgstr ""
+msgstr "ARVRCamera 必須有 ARVROrigin 節點作為æ¯ç¯€é»žã€‚"
#: scene/3d/arvr_nodes.cpp
msgid "ARVRController must have an ARVROrigin node as its parent."
-msgstr ""
+msgstr "ARVRController 必須有 ARVROrigin 節點作為æ¯ç¯€é»žã€‚"
#: scene/3d/arvr_nodes.cpp
msgid ""
"The controller ID must not be 0 or this controller won't be bound to an "
"actual controller."
-msgstr ""
+msgstr "控制器 ID ä¸å¯ç‚º 0,å¦å‰‡è©²æŽ§åˆ¶å™¨å°‡ä¸æœƒç¶å®šè‡³å¯¦éš›çš„控制器。"
#: scene/3d/arvr_nodes.cpp
msgid "ARVRAnchor must have an ARVROrigin node as its parent."
-msgstr ""
+msgstr "ARVRAnchor 必須有 ARVROrigin 節點作為æ¯ç¯€é»žã€‚"
#: scene/3d/arvr_nodes.cpp
msgid ""
"The anchor ID must not be 0 or this anchor won't be bound to an actual "
"anchor."
-msgstr ""
+msgstr "錨點 ID ä¸å¯ç‚º 0,å¦å‰‡è©²éŒ¨é»žå°‡ä¸æœƒè¢«ç¶å®šè‡³å¯¦éš›çš„錨點。"
#: scene/3d/arvr_nodes.cpp
msgid "ARVROrigin requires an ARVRCamera child node."
-msgstr ""
+msgstr "ARVROrigin 必須有一個 ARVRCamera å­ç¯€é»žã€‚"
#: scene/3d/baked_lightmap.cpp
msgid "%d%%"
-msgstr ""
+msgstr "%d%%"
#: scene/3d/baked_lightmap.cpp
msgid "(Time Left: %d:%02d s)"
-msgstr ""
+msgstr "(剩餘時間:%d:%02d 秒)"
#: scene/3d/baked_lightmap.cpp
msgid "Plotting Meshes: "
-msgstr ""
+msgstr "正在繪製網格: "
#: scene/3d/baked_lightmap.cpp
msgid "Plotting Lights:"
-msgstr ""
+msgstr "正在繪製光照:"
#: scene/3d/baked_lightmap.cpp scene/3d/gi_probe.cpp
msgid "Finishing Plot"
-msgstr ""
+msgstr "繪製完æˆ"
#: scene/3d/baked_lightmap.cpp
msgid "Lighting Meshes: "
-msgstr ""
+msgstr "正在照明網格: "
#: scene/3d/collision_object.cpp
msgid ""
@@ -12689,6 +12177,8 @@ msgid ""
"Consider adding a CollisionShape or CollisionPolygon as a child to define "
"its shape."
msgstr ""
+"該節點沒有形狀,故無法與其他物件碰撞或互動。\n"
+"請考慮新增一個 CollisionShape 或 CollisionPolygon 作為其å­ç¯€é»žä»¥å®šç¾©å…¶å½¢ç‹€ã€‚"
#: scene/3d/collision_polygon.cpp
msgid ""
@@ -12696,10 +12186,12 @@ msgid ""
"CollisionObject derived node. Please only use it as a child of Area, "
"StaticBody, RigidBody, KinematicBody, etc. to give them a shape."
msgstr ""
+"CollisionPolygon åªèƒ½ç‚º CollisionObject è¡ç”Ÿçš„節點æ供碰撞形狀資訊。請僅於 "
+"Areaã€StaticBodyã€RigidBodyã€KinematicBody…等節點下作為å­ç¯€é»žä½¿ç”¨ã€‚"
#: scene/3d/collision_polygon.cpp
msgid "An empty CollisionPolygon has no effect on collision."
-msgstr ""
+msgstr "空白的 CollisionPolygon 節點將ä¸æœƒç”¢ç”Ÿç¢°æ’žæ•ˆæžœã€‚"
#: scene/3d/collision_shape.cpp
msgid ""
@@ -12707,58 +12199,65 @@ msgid ""
"derived node. Please only use it as a child of Area, StaticBody, RigidBody, "
"KinematicBody, etc. to give them a shape."
msgstr ""
+"CollisionShape åªèƒ½ç‚º CollisionObject è¡ç”Ÿçš„節點æ供碰撞形狀資訊。請僅於 "
+"Areaã€StaticBodyã€RigidBodyã€KinematicBody…等節點下作為å­ç¯€é»žä½¿ç”¨ã€‚"
#: scene/3d/collision_shape.cpp
-#, fuzzy
msgid ""
"A shape must be provided for CollisionShape to function. Please create a "
"shape resource for it."
-msgstr "CollisionShape2D必須被賦予形狀æ‰èƒ½é‹ä½œï¼Œè«‹ç‚ºå®ƒå»ºç«‹å€‹å½¢ç‹€å§ï¼"
+msgstr "CollisionShape 必須被賦予形狀æ‰èƒ½é‹ä½œã€‚請先建立形狀。"
#: scene/3d/collision_shape.cpp
msgid ""
"Plane shapes don't work well and will be removed in future versions. Please "
"don't use them."
-msgstr ""
+msgstr "å¹³é¢å½¢ç‹€çš„é‹ä½œä¸å¤ªæ­£å¸¸ï¼Œä¸”將在未來的版本移除。請勿使用。"
#: scene/3d/collision_shape.cpp
msgid ""
"ConcavePolygonShape doesn't support RigidBody in another mode than static."
-msgstr ""
+msgstr "ConcavePolygonShape ä¸æ”¯æ´éœæ…‹æ¨¡å¼ä»¥å¤–çš„ RigidBody。"
#: scene/3d/cpu_particles.cpp
msgid "Nothing is visible because no mesh has been assigned."
-msgstr ""
+msgstr "由於尚未指定網格,未顯示任何æ±è¥¿ã€‚"
#: scene/3d/cpu_particles.cpp
msgid ""
"CPUParticles animation requires the usage of a SpatialMaterial whose "
"Billboard Mode is set to \"Particle Billboard\"."
msgstr ""
+"CPUParticles 動畫需è¦ä½¿ç”¨ Billboard Mode 為「Particle Billboardã€çš„ "
+"SpatialMaterial。"
#: scene/3d/gi_probe.cpp
msgid "Plotting Meshes"
-msgstr ""
+msgstr "正在繪製網格"
#: scene/3d/gi_probe.cpp
msgid ""
"GIProbes are not supported by the GLES2 video driver.\n"
"Use a BakedLightmap instead."
msgstr ""
+"GLES2 視訊驅動程å¼ä¸æ”¯æ´ GIProbs。\n"
+"請改為使用 BakedLightmap。"
#: scene/3d/light.cpp
msgid "A SpotLight with an angle wider than 90 degrees cannot cast shadows."
-msgstr ""
+msgstr "角度大於 90 度的 SpotLight 無法投射出陰影。"
#: scene/3d/navigation_mesh.cpp
msgid "A NavigationMesh resource must be set or created for this node to work."
-msgstr ""
+msgstr "必須先為該節點建立 NavigationMesh 資æºæ‰å¯é‹ä½œã€‚"
#: scene/3d/navigation_mesh.cpp
msgid ""
"NavigationMeshInstance must be a child or grandchild to a Navigation node. "
"It only provides navigation data."
msgstr ""
+"NavigationMeshInstance 必須為 Navigation 節點的å­ç¯€é»žæˆ–次級å­ç¯€é»žã€‚其僅æ供導"
+"航資料。"
#: scene/3d/particles.cpp
msgid ""
@@ -12766,27 +12265,33 @@ msgid ""
"Use the CPUParticles node instead. You can use the \"Convert to CPUParticles"
"\" option for this purpose."
msgstr ""
+"GLES2 視訊驅動程å¼ä¸æ”¯æ´åŸºæ–¼ GPU çš„ç²’å­ã€‚\n"
+"請改為使用 CPUParticles 節點。為此您å¯ä»¥ä½¿ç”¨ã€Œè½‰æ›ç‚º CPUParticlesã€é¸é …。"
#: scene/3d/particles.cpp
msgid ""
"Nothing is visible because meshes have not been assigned to draw passes."
-msgstr ""
+msgstr "由於網格尚未被指派至æ繪路徑(Draw Pass),未顯示任何æ±è¥¿ã€‚"
#: scene/3d/particles.cpp
msgid ""
"Particles animation requires the usage of a SpatialMaterial whose Billboard "
"Mode is set to \"Particle Billboard\"."
msgstr ""
+"ç²’å­å‹•ç•«éœ€è¦ä½¿ç”¨ Billboard Mode 設定為「Particle Billboardã€çš„ "
+"SpatialMaterial。"
#: scene/3d/path.cpp
msgid "PathFollow only works when set as a child of a Path node."
-msgstr ""
+msgstr "PathFollow 僅在其為 Path 節點的å­ç¯€é»žæ™‚æ‰å¯é‹ä½œã€‚"
#: scene/3d/path.cpp
msgid ""
"PathFollow's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its "
"parent Path's Curve resource."
msgstr ""
+"PathFollow çš„ ROTATION_ORIENTED 需è¦åœ¨å…¶æ¯ç¯€é»ž Path çš„ Curve 資æºå…§å•Ÿç”¨ã€Œä¸Šå‘"
+"é‡ (Up Vector)ã€ã€‚"
#: scene/3d/physics_body.cpp
msgid ""
@@ -12794,16 +12299,20 @@ msgid ""
"by the physics engine when running.\n"
"Change the size in children collision shapes instead."
msgstr ""
+"(在 Character 或 Rigid Mode 下)更改 RigidBody 的大å°å°‡æœƒåœ¨åŸ·è¡Œæ™‚被物ç†å¼•æ“Ž"
+"複寫。\n"
+"請改為修改其å­ç¯€é»žçš„碰撞形狀之大å°ã€‚"
#: scene/3d/remote_transform.cpp
msgid ""
"The \"Remote Path\" property must point to a valid Spatial or Spatial-"
"derived node to work."
msgstr ""
+"「é ç«¯è·¯å¾‘ã€å±¬æ€§å¿…須指å‘一個有效的 Spatial 或 Spatial è¡ç”Ÿä¹‹ç¯€é»žæ‰å¯é‹ä½œã€‚"
#: scene/3d/soft_body.cpp
msgid "This body will be ignored until you set a mesh."
-msgstr ""
+msgstr "該形體在設定網格å‰éƒ½å°‡è¢«å¿½ç•¥ã€‚"
#: scene/3d/soft_body.cpp
msgid ""
@@ -12811,81 +12320,85 @@ msgid ""
"running.\n"
"Change the size in children collision shapes instead."
msgstr ""
+"更改 SoftBody 的大å°å°‡æœƒåœ¨åŸ·è¡Œæ™‚被物ç†å¼•æ“Žè¤‡å¯«ã€‚\n"
+"請改為修改其å­ç¯€é»žçš„碰撞形狀之大å°ã€‚"
#: scene/3d/sprite_3d.cpp
-#, fuzzy
msgid ""
"A SpriteFrames resource must be created or set in the \"Frames\" property in "
"order for AnimatedSprite3D to display frames."
-msgstr "SpriteFrames資æºå¿…須在Frames屬性中被創建或設置æ‰èƒ½å¤ é¡¯ç¤ºå‹•ç•«æ ¼ã€‚"
+msgstr ""
+"必須先為「Framesã€å±¬æ€§å»ºç«‹æˆ–設定 SpriteFrames 資æºä»¥ä»¤ AnimatedSprite3D 顯示"
+"影格。"
#: scene/3d/vehicle_body.cpp
msgid ""
"VehicleWheel serves to provide a wheel system to a VehicleBody. Please use "
"it as a child of a VehicleBody."
msgstr ""
+"VehicleWheel 旨在為 VehicleBody æä¾› Wheel System。請將其作為 VehicleBody çš„"
+"å­ç¯€é»žã€‚"
#: scene/3d/world_environment.cpp
msgid ""
"WorldEnvironment requires its \"Environment\" property to contain an "
"Environment to have a visible effect."
msgstr ""
+"必須先將 WorldEnvironment 之「Environmentã€å±¬æ€§è¨­ç‚ºåŒ…å« Environment æ‰å¯ç”¢ç”Ÿ"
+"視覺效果。"
#: scene/3d/world_environment.cpp
msgid ""
"Only one WorldEnvironment is allowed per scene (or set of instanced scenes)."
-msgstr ""
+msgstr "æ¯å€‹å ´æ™¯ï¼ˆæˆ–實體化場景集)僅å¯æœ‰ä¸€å€‹ WorldEnvironment。"
#: scene/3d/world_environment.cpp
msgid ""
"This WorldEnvironment is ignored. Either add a Camera (for 3D scenes) or set "
"this environment's Background Mode to Canvas (for 2D scenes)."
msgstr ""
+"已忽略該 WorldEnvironment。請(為 3D 場景)新增一個相機或(為 2D 場景)設定環"
+"å¢ƒä¹‹èƒŒæ™¯æ¨¡å¼ (Background Mode) 為畫布 (Canvas)。"
#: scene/animation/animation_blend_tree.cpp
msgid "On BlendTree node '%s', animation not found: '%s'"
-msgstr ""
+msgstr "æ–¼ BlendTree 節點「%sã€ä¸Šæœªæ‰¾åˆ°å‹•ç•«ï¼šã€Œ%sã€"
#: scene/animation/animation_blend_tree.cpp
-#, fuzzy
msgid "Animation not found: '%s'"
-msgstr "動畫長度 (秒)。"
+msgstr "未找到動畫:「%sã€"
#: scene/animation/animation_tree.cpp
msgid "In node '%s', invalid animation: '%s'."
-msgstr ""
+msgstr "於節點「%sã€å…§å‹•ç•«ç„¡æ•ˆï¼šã€Œ%sã€ã€‚"
#: scene/animation/animation_tree.cpp
-#, fuzzy
msgid "Invalid animation: '%s'."
-msgstr "無效的字體大å°ã€‚"
+msgstr "無效的動畫:「%sã€ã€‚"
#: scene/animation/animation_tree.cpp
-#, fuzzy
msgid "Nothing connected to input '%s' of node '%s'."
-msgstr "將 '%s' 從 '%s' 中斷連接"
+msgstr "節點「%sã€çš„輸入「%sã€æœªæœ‰ä»»ä½•é€£æŽ¥ã€‚"
#: scene/animation/animation_tree.cpp
msgid "No root AnimationNode for the graph is set."
-msgstr ""
+msgstr "尚未為圖表設定根 AnimationNode。"
#: scene/animation/animation_tree.cpp
-#, fuzzy
msgid "Path to an AnimationPlayer node containing animations is not set."
-msgstr "從場景樹中é¸æ“‡ä¸€å€‹ AnimationPlayer 來編輯動畫。"
+msgstr "尚未設定一個連接包å«å‹•ç•«ä¸”連接至 AnimationPlayer 節點的路徑。"
#: scene/animation/animation_tree.cpp
msgid "Path set for AnimationPlayer does not lead to an AnimationPlayer node."
-msgstr ""
+msgstr "連接至 AnimationPlayer 的路徑並未連接至 AnimationPlayer 節點。"
#: scene/animation/animation_tree.cpp
-#, fuzzy
msgid "The AnimationPlayer root node is not a valid node."
-msgstr "動畫樹無效。"
+msgstr "AnimationPlayer 的根節點並éžæœ‰æ•ˆç¯€é»žã€‚"
#: scene/animation/animation_tree_player.cpp
msgid "This node has been deprecated. Use AnimationTree instead."
-msgstr ""
+msgstr "該節點已åœæ­¢ç¶­è­·ï¼Œè«‹æ”¹ç‚ºä½¿ç”¨ AnimationTree。"
#: scene/gui/color_picker.cpp
msgid ""
@@ -12893,28 +12406,29 @@ msgid ""
"LMB: Set color\n"
"RMB: Remove preset"
msgstr ""
+"色彩: #%s\n"
+"å·¦éµé»žæ“Šï¼šè¨­å®šè‰²å½©\n"
+"å³éµé»žæ“Šï¼šåˆªé™¤ Preset"
#: scene/gui/color_picker.cpp
msgid "Pick a color from the editor window."
-msgstr ""
+msgstr "請自編輯器視窗é¸æ“‡ä¸€å€‹é¡è‰²ã€‚"
#: scene/gui/color_picker.cpp
msgid "HSV"
-msgstr ""
+msgstr "HSV"
#: scene/gui/color_picker.cpp
-#, fuzzy
msgid "Raw"
-msgstr "å航"
+msgstr "原始"
#: scene/gui/color_picker.cpp
msgid "Switch between hexadecimal and code values."
-msgstr ""
+msgstr "在 16 進ä½èˆ‡ä»£ç¢¼å€¼ä¹‹é–“切æ›ã€‚"
#: scene/gui/color_picker.cpp
-#, fuzzy
msgid "Add current color as a preset."
-msgstr "將目å‰é¡è‰²è¨­ç‚ºé è¨­"
+msgstr "將目å‰çš„é¡è‰²åŠ å…¥ Preset。"
#: scene/gui/container.cpp
msgid ""
@@ -12922,16 +12436,21 @@ msgid ""
"children placement behavior.\n"
"If you don't intend to add a script, use a plain Control node instead."
msgstr ""
+"除éžæœ‰è…³æœ¬è¨­å®šäº† Container å­ç¯€é»žä½”ä½è¡Œç‚º (Placement Behavior),其本身將無作"
+"用。\n"
+"若您未計劃新增腳本,請改為使用普通的 Control 節點。"
#: scene/gui/control.cpp
msgid ""
"The Hint Tooltip won't be displayed as the control's Mouse Filter is set to "
"\"Ignore\". To solve this, set the Mouse Filter to \"Stop\" or \"Pass\"."
msgstr ""
+"ç”±æ–¼è¨­å®šçš„æ»‘é¼ ç¯©é¸ (Mouse Filter) 設定為「忽略 (Ignore)ã€ï¼Œå°‡ä¸æœƒé¡¯ç¤ºæ示 "
+"Tooltip 。è¦è§£æ±ºè©²å•é¡Œï¼Œè«‹å°‡æ»‘鼠篩é¸è¨­ç‚ºã€Œåœæ­¢ (Stop)ã€æˆ–ã€Œé€šéŽ (Pass)ã€ã€‚"
#: scene/gui/dialogs.cpp
msgid "Alert!"
-msgstr "警告!"
+msgstr "警告ï¼"
#: scene/gui/dialogs.cpp
msgid "Please Confirm..."
@@ -12943,10 +12462,12 @@ msgid ""
"functions. Making them visible for editing is fine, but they will hide upon "
"running."
msgstr ""
+"彈出視窗é è¨­æœƒéš±è—,除éžå‘¼å« popup() 或任何一個 popup*() 函å¼ã€‚å¯ä»¥å°‡å…¶è¨­ç‚ºå¯"
+"見來進行編輯,但在執行的時候會隱è—。"
#: scene/gui/range.cpp
msgid "If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0."
-msgstr ""
+msgstr "若啟用「表示å¼ç·¨è¼¯ã€ï¼Œå‰‡ã€Œæœ€å°å€¼ã€å¿…須大於 0。"
#: scene/gui/scroll_container.cpp
msgid ""
@@ -12954,18 +12475,19 @@ msgid ""
"Use a container as child (VBox, HBox, etc.), or a Control and set the custom "
"minimum size manually."
msgstr ""
+"ScrollContainer 旨在於單一å­æŽ§åˆ¶é…åˆä½¿ç”¨ã€‚\n"
+"使用容器作為å­ç¯€é»žï¼ˆVBoxã€HBox…等),或是使用 Control 並手動設定其自定最å°"
+"值。"
#: scene/gui/tree.cpp
msgid "(Other)"
-msgstr "(其它)"
+msgstr "(其它)"
#: scene/main/scene_tree.cpp
msgid ""
"Default Environment as specified in Project Settings (Rendering -> "
"Environment -> Default Environment) could not be loaded."
-msgstr ""
-"在專案設定中的é è¨­ç’°å¢ƒ(Rendering -> Environment -> Default Environment)ä¸èƒ½è¢«"
-"載入"
+msgstr "無法載入專案設定中指定的é è¨­ç’°å¢ƒï¼ˆç®—圖 -> 環境 -> é è¨­ç’°å¢ƒï¼‰ã€‚"
#: scene/main/viewport.cpp
msgid ""
@@ -12974,41 +12496,56 @@ msgid ""
"obtain a size. Otherwise, make it a RenderTarget and assign its internal "
"texture to some node for display."
msgstr ""
+"該 Viewport 尚未被設定為算圖目標。若你想直接將其內容顯示於畫é¢ä¸Šï¼Œè«‹å°‡å…¶è¨­ç‚º "
+"Control çš„å­ç¯€é»žä»¥è®“å…¶å–得大å°ã€‚å¦å‰‡è«‹å°‡å…¶è¨­ç‚º RenderTarget 並指派其內部紋ç†"
+"為其他節點以顯示。"
#: scene/main/viewport.cpp
msgid "Viewport size must be greater than 0 to render anything."
-msgstr ""
+msgstr "Viewport 大å°å¿…須大於 0 æ‰å¯é€²è¡Œç®—圖。"
#: scene/resources/visual_shader_nodes.cpp
-#, fuzzy
msgid "Invalid source for preview."
-msgstr "無效的字體大å°ã€‚"
+msgstr "無效的é è¦½ä¾†æºã€‚"
#: scene/resources/visual_shader_nodes.cpp
-#, fuzzy
msgid "Invalid source for shader."
-msgstr "無效的字體大å°ã€‚"
+msgstr "無效的著色器來æºã€‚"
#: scene/resources/visual_shader_nodes.cpp
-#, fuzzy
msgid "Invalid comparison function for that type."
-msgstr "無效的字體大å°ã€‚"
+msgstr "該型別的比較函å¼ç„¡æ•ˆã€‚"
#: servers/visual/shader_language.cpp
msgid "Assignment to function."
-msgstr ""
+msgstr "指派至函å¼ã€‚"
#: servers/visual/shader_language.cpp
msgid "Assignment to uniform."
-msgstr ""
+msgstr "指派至å‡å‹»ã€‚"
#: servers/visual/shader_language.cpp
msgid "Varyings can only be assigned in vertex function."
-msgstr ""
+msgstr "Varying 變數åªå¯åœ¨é ‚點函å¼ä¸­æŒ‡æ´¾ã€‚"
#: servers/visual/shader_language.cpp
msgid "Constants cannot be modified."
-msgstr ""
+msgstr "ä¸å¯ä¿®æ”¹å¸¸æ•¸ã€‚"
+
+#~ msgid "Not in resource path."
+#~ msgstr "ä¸åœ¨è³‡æºè·¯å¾‘中。"
+
+#~ msgid "Revert"
+#~ msgstr "還原"
+
+#~ msgid "This action cannot be undone. Revert anyway?"
+#~ msgstr "該æ“作無法還原。ä¾ç„¶è¦é‚„原嗎?"
+
+#~ msgid "Revert Scene"
+#~ msgstr "æ¢å¾©å ´æ™¯"
+
+#~ msgid "Clear Script"
+#~ msgstr "清除腳本"
#, fuzzy
#~ msgid "Issue Tracker"
diff --git a/gles_builders.py b/gles_builders.py
index 85a8d7aa15..85d0112c9a 100644
--- a/gles_builders.py
+++ b/gles_builders.py
@@ -36,14 +36,14 @@ def include_file_in_legacygl_header(filename, header_data, depth):
while line:
- if line.find("[vertex]") != -1:
+ if line.find("#[vertex]") != -1:
header_data.reading = "vertex"
line = fs.readline()
header_data.line_offset += 1
header_data.vertex_offset = header_data.line_offset
continue
- if line.find("[fragment]") != -1:
+ if line.find("#[fragment]") != -1:
header_data.reading = "fragment"
line = fs.readline()
header_data.line_offset += 1
@@ -612,21 +612,21 @@ def include_file_in_rd_header(filename, header_data, depth):
while line:
- if line.find("[vertex]") != -1:
+ if line.find("#[vertex]") != -1:
header_data.reading = "vertex"
line = fs.readline()
header_data.line_offset += 1
header_data.vertex_offset = header_data.line_offset
continue
- if line.find("[fragment]") != -1:
+ if line.find("#[fragment]") != -1:
header_data.reading = "fragment"
line = fs.readline()
header_data.line_offset += 1
header_data.fragment_offset = header_data.line_offset
continue
- if line.find("[compute]") != -1:
+ if line.find("#[compute]") != -1:
header_data.reading = "compute"
line = fs.readline()
header_data.line_offset += 1
diff --git a/main/main.cpp b/main/main.cpp
index 958d964b35..92b07dc83b 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -139,7 +139,6 @@ static DisplayServer::ScreenOrientation window_orientation = DisplayServer::SCRE
static uint32_t window_flags = 0;
static Size2i window_size = Size2i(1024, 600);
static bool window_vsync_via_compositor = false;
-static bool disable_wintab = false;
static int init_screen = -1;
static bool init_fullscreen = false;
@@ -177,8 +176,9 @@ static String unescape_cmdline(const String &p_str) {
static String get_full_version_string() {
String hash = String(VERSION_HASH);
- if (hash.length() != 0)
+ if (hash.length() != 0) {
hash = "." + hash.left(9);
+ }
return String(VERSION_FULL_BUILD) + hash;
}
@@ -205,7 +205,6 @@ void initialize_physics() {
}
void finalize_physics() {
-
physics_server->finish();
memdelete(physics_server);
@@ -214,7 +213,6 @@ void finalize_physics() {
}
void finalize_display() {
-
rendering_server->finish();
memdelete(rendering_server);
@@ -244,7 +242,6 @@ void finalize_navigation_server() {
#endif
void Main::print_help(const char *p_binary) {
-
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
OS::get_singleton()->print("Free and open source software under the terms of the MIT license.\n");
OS::get_singleton()->print("(c) 2007-2020 Juan Linietsky, Ariel Manzur.\n");
@@ -315,7 +312,13 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --enable-vsync-via-compositor When vsync is enabled, vsync via the OS' window compositor (Windows only).\n");
OS::get_singleton()->print(" --disable-vsync-via-compositor Disable vsync via the OS' window compositor (Windows only).\n");
OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n");
- OS::get_singleton()->print(" --disable-wintab Disable WinTab API and always use Windows Ink API for the pen input (Windows only).\n");
+ OS::get_singleton()->print(" --tablet-driver Tablet input driver (");
+ for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) {
+ if (i != 0)
+ OS::get_singleton()->print(", ");
+ OS::get_singleton()->print("'%s'", OS::get_singleton()->get_tablet_driver_name(i).utf8().get_data());
+ }
+ OS::get_singleton()->print(") (Windows only).\n");
OS::get_singleton()->print("\n");
#endif
@@ -390,7 +393,6 @@ void Main::print_help(const char *p_binary) {
*/
Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
-
OS::get_singleton()->initialize();
engine = memnew(Engine);
@@ -425,7 +427,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
List<String> main_args;
for (int i = 0; i < argc; i++) {
-
args.push_back(String::utf8(argv[i]));
}
@@ -434,7 +435,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = args.front();
while (I) {
-
I->get() = unescape_cmdline(I->get().strip_edges());
I = I->next();
}
@@ -443,6 +443,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
String display_driver = "";
String audio_driver = "";
+ String tablet_driver = "";
String project_path = ".";
bool upwards = false;
String debug_uri = "";
@@ -464,8 +465,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
bool use_vsync = false;
packed_data = PackedData::get_singleton();
- if (!packed_data)
+ if (!packed_data) {
packed_data = memnew(PackedData);
+ }
#ifdef MINIZIP_ENABLED
@@ -498,7 +500,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
goto error;
} else if (I->get() == "--version") {
-
print_line(get_full_version_string());
goto error;
@@ -512,7 +513,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--audio-driver") { // audio driver
if (I->next()) {
-
audio_driver = I->next()->get();
bool found = false;
@@ -549,7 +549,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--display-driver") { // force video driver
if (I->next()) {
-
display_driver = I->next()->get();
bool found = false;
@@ -597,9 +596,26 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--gpu-abort") { // force windowed window
Engine::singleton->abort_on_gpu_errors = true;
- } else if (I->get() == "--disable-wintab") {
+ } else if (I->get() == "--tablet-driver") {
+ if (I->next()) {
+ tablet_driver = I->next()->get();
+ bool found = false;
+ for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) {
+ if (tablet_driver == OS::get_singleton()->get_tablet_driver_name(i)) {
+ found = true;
+ }
+ }
- disable_wintab = true;
+ if (!found) {
+ OS::get_singleton()->print("Unknown tablet driver '%s', aborting.\n", tablet_driver.utf8().get_data());
+ goto error;
+ }
+
+ N = I->next()->next();
+ } else {
+ OS::get_singleton()->print("Missing tablet driver argument, aborting.\n");
+ goto error;
+ }
} else if (I->get() == "--single-window") { // force single window
single_window = true;
@@ -609,7 +625,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--resolution") { // force resolution
if (I->next()) {
-
String vm = I->next()->get();
if (vm.find("x") == -1) { // invalid parameter format
@@ -622,7 +637,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
int h = vm.get_slice("x", 1).to_int();
if (w <= 0 || h <= 0) {
-
OS::get_singleton()->print("Invalid resolution '%s', width and height must be above 0.\n", vm.utf8().get_data());
goto error;
}
@@ -640,7 +654,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--position") { // set window position
if (I->next()) {
-
String vm = I->next()->get();
if (vm.find(",") == -1) { // invalid parameter format
@@ -668,11 +681,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->set_no_window_mode(true);
} else if (I->get() == "--enable-vsync-via-compositor") {
-
window_vsync_via_compositor = true;
saw_vsync_via_compositor_override = true;
} else if (I->get() == "--disable-vsync-via-compositor") {
-
window_vsync_via_compositor = false;
saw_vsync_via_compositor_override = true;
#endif
@@ -683,7 +694,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-l" || I->get() == "--language") { // language
if (I->next()) {
-
locale = I->next()->get();
N = I->next()->next();
} else {
@@ -694,7 +704,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--remote-fs") { // remote filesystem
if (I->next()) {
-
remotefs = I->next()->get();
N = I->next()->next();
} else {
@@ -704,7 +713,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--remote-fs-password") { // remote filesystem password
if (I->next()) {
-
remotefs_pass = I->next()->get();
N = I->next()->next();
} else {
@@ -714,13 +722,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--render-thread") { // render thread mode
if (I->next()) {
-
- if (I->next()->get() == "safe")
+ if (I->next()->get() == "safe") {
rtm = OS::RENDER_THREAD_SAFE;
- else if (I->next()->get() == "unsafe")
+ } else if (I->next()->get() == "unsafe") {
rtm = OS::RENDER_THREAD_UNSAFE;
- else if (I->next()->get() == "separate")
+ } else if (I->next()->get() == "separate") {
rtm = OS::RENDER_SEPARATE_THREAD;
+ }
N = I->next()->next();
} else {
@@ -754,7 +762,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--path") { // set path of project to start or edit
if (I->next()) {
-
String p = I->next()->get();
if (OS::get_singleton()->set_cwd(p) == OK) {
//nothing
@@ -774,9 +781,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
String path;
String file = I->get();
int sep = MAX(file.find_last("/"), file.find_last("\\"));
- if (sep == -1)
+ if (sep == -1) {
path = ".";
- else {
+ } else {
path = file.substr(0, sep);
}
if (OS::get_singleton()->set_cwd(path) == OK) {
@@ -790,7 +797,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-b" || I->get() == "--breakpoints") { // add breakpoints
if (I->next()) {
-
String bplist = I->next()->get();
breakpoints = bplist.split(",");
N = I->next()->next();
@@ -802,7 +808,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--frame-delay") { // force frame delay
if (I->next()) {
-
frame_delay = I->next()->get().to_int();
N = I->next()->next();
} else {
@@ -813,7 +818,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--time-scale") { // force time scale
if (I->next()) {
-
Engine::get_singleton()->set_time_scale(I->next()->get().to_double());
N = I->next()->next();
} else {
@@ -822,9 +826,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (I->get() == "--main-pack") {
-
if (I->next()) {
-
main_pack = I->next()->get();
N = I->next()->next();
} else {
@@ -842,7 +844,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#endif
} else if (I->get() == "--remote-debug") {
if (I->next()) {
-
debug_uri = I->next()->get();
if (debug_uri.find("://") == -1) { // wrong address
OS::get_singleton()->print("Invalid debug host address, it should be of the form <protocol>://<host/IP>:<port>.\n");
@@ -855,7 +856,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (I->get() == "--allow_focus_steal_pid") { // not exposed to user
if (I->next()) {
-
allow_focus_steal_pid = I->next()->get().to_int64();
N = I->next()->next();
} else {
@@ -896,7 +896,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// 'project.godot' file which will only be available through the network if this is enabled
FileAccessNetwork::configure();
if (remotefs != "") {
-
file_access_network_client = memnew(FileAccessNetworkClient);
int port;
if (remotefs.find(":") != -1) {
@@ -920,7 +919,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
found_project = true;
#endif
} else {
-
#ifdef TOOLS_ENABLED
editor = false;
#else
@@ -932,6 +930,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#endif
}
+ // Initialize user data dir.
+ OS::get_singleton()->ensure_user_data_dir();
+
GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60);
ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/multithreaded_server/rid_pool_prealloc", PropertyInfo(Variant::INT, "memory/limits/multithreaded_server/rid_pool_prealloc", PROPERTY_HINT_RANGE, "0,500,1")); // No negative and limit to 500 due to crashes
GLOBAL_DEF("network/limits/debugger/max_chars_per_second", 32768);
@@ -950,7 +951,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
packed_data->set_disabled(true);
globals->set_disable_feature_overrides(true);
}
-
#endif
GLOBAL_DEF("logging/file_logging/enable_file_logging", false);
@@ -1005,8 +1005,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
_print_error_enabled = false;
};
- if (quiet_stdout)
+ if (quiet_stdout) {
_print_line_enabled = false;
+ }
OS::get_singleton()->set_cmdline(execpath, main_args);
@@ -1033,13 +1034,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/test_height", PropertyInfo(Variant::INT, "display/window/size/test_height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution
if (use_custom_res) {
-
if (!force_res) {
window_size.width = GLOBAL_GET("display/window/size/width");
window_size.height = GLOBAL_GET("display/window/size/height");
if (globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) {
-
int tw = globals->get("display/window/size/test_width");
if (tw > 0) {
window_size.width = tw;
@@ -1083,12 +1082,20 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->_vsync_via_compositor = window_vsync_via_compositor;
- if (!disable_wintab) {
- // No "--disable_wintab" option
- disable_wintab = GLOBAL_DEF("display/window/disable_wintab_api", false);
+ if (tablet_driver == "") { // specified in project.godot
+ tablet_driver = GLOBAL_DEF_RST("display/window/tablet_driver", OS::get_singleton()->get_tablet_driver_name(0));
+ }
+
+ for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) {
+ if (tablet_driver == OS::get_singleton()->get_tablet_driver_name(i)) {
+ OS::get_singleton()->set_current_tablet_driver(OS::get_singleton()->get_tablet_driver_name(i));
+ break;
+ }
}
- OS::get_singleton()->_disable_wintab = disable_wintab;
+ if (tablet_driver == "") {
+ OS::get_singleton()->set_current_tablet_driver(OS::get_singleton()->get_tablet_driver_name(0));
+ }
/* todo restore
OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false);
@@ -1119,9 +1126,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
/* Determine audio and video drivers */
for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
-
if (display_driver == DisplayServer::get_create_function_name(i)) {
-
display_driver_idx = i;
break;
}
@@ -1136,9 +1141,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
-
if (audio_driver == AudioDriverManager::get_driver(i)->get_name()) {
-
audio_driver_idx = i;
break;
}
@@ -1151,20 +1154,21 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
{
String orientation = GLOBAL_DEF("display/window/handheld/orientation", "landscape");
- if (orientation == "portrait")
+ if (orientation == "portrait") {
window_orientation = DisplayServer::SCREEN_PORTRAIT;
- else if (orientation == "reverse_landscape")
+ } else if (orientation == "reverse_landscape") {
window_orientation = DisplayServer::SCREEN_REVERSE_LANDSCAPE;
- else if (orientation == "reverse_portrait")
+ } else if (orientation == "reverse_portrait") {
window_orientation = DisplayServer::SCREEN_REVERSE_PORTRAIT;
- else if (orientation == "sensor_landscape")
+ } else if (orientation == "sensor_landscape") {
window_orientation = DisplayServer::SCREEN_SENSOR_LANDSCAPE;
- else if (orientation == "sensor_portrait")
+ } else if (orientation == "sensor_portrait") {
window_orientation = DisplayServer::SCREEN_SENSOR_PORTRAIT;
- else if (orientation == "sensor")
+ } else if (orientation == "sensor") {
window_orientation = DisplayServer::SCREEN_SENSOR;
- else
+ } else {
window_orientation = DisplayServer::SCREEN_LANDSCAPE;
+ }
}
Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/physics_fps", 60));
@@ -1195,8 +1199,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
message_queue = memnew(MessageQueue);
- if (p_second_phase)
+ if (p_second_phase) {
return setup2();
+ }
return OK;
@@ -1204,38 +1209,48 @@ error:
display_driver = "";
audio_driver = "";
+ tablet_driver = "";
project_path = "";
args.clear();
main_args.clear();
- if (show_help)
+ if (show_help) {
print_help(execpath);
+ }
EngineDebugger::deinitialize();
- if (performance)
+ if (performance) {
memdelete(performance);
- if (input_map)
+ }
+ if (input_map) {
memdelete(input_map);
- if (translation_server)
+ }
+ if (translation_server) {
memdelete(translation_server);
- if (globals)
+ }
+ if (globals) {
memdelete(globals);
- if (engine)
+ }
+ if (engine) {
memdelete(engine);
- if (packed_data)
+ }
+ if (packed_data) {
memdelete(packed_data);
- if (file_access_network_client)
+ }
+ if (file_access_network_client) {
memdelete(file_access_network_client);
+ }
unregister_core_driver_types();
unregister_core_types();
OS::get_singleton()->_cmdline.clear();
- if (message_queue)
+ if (message_queue) {
memdelete(message_queue);
+ }
OS::get_singleton()->finalize_core();
locale = String();
@@ -1243,7 +1258,6 @@ error:
}
Error Main::setup2(Thread::ID p_main_tid_override) {
-
preregister_module_types();
preregister_server_types();
@@ -1254,10 +1268,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Thread::_main_thread_id = p_main_tid_override;
}
- /* Initialize user data dir */
-
- OS::get_singleton()->ensure_user_data_dir();
-
/* Initialize Input */
input = memnew(Input);
@@ -1265,7 +1275,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
/* Iniitalize Display Server */
{
-
String rendering_driver; // temp broken
Error err;
@@ -1301,6 +1310,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
}
rendering_server->init();
+ rendering_server->set_render_loop_enabled(!disable_render_loop);
OS::get_singleton()->initialize_joypads();
@@ -1370,8 +1380,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
if (boot_logo_path != String()) {
boot_logo.instance();
Error load_err = ImageLoader::load_image(boot_logo_path, boot_logo);
- if (load_err)
+ if (load_err) {
ERR_PRINT("Non-existing or invalid boot splash at '" + boot_logo_path + "'. Loading default splash.");
+ }
}
Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color);
@@ -1417,7 +1428,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Input *id = Input::get_singleton();
if (id) {
if (bool(GLOBAL_DEF("input_devices/pointing/emulate_touch_from_mouse", false)) && !(editor || project_manager)) {
-
bool found_touchscreen = false;
for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) {
@@ -1445,7 +1455,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
ProjectSettings::get_singleton()->set_custom_property_info("display/mouse_cursor/custom_image", PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"));
if (String(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) {
-
Ref<Texture2D> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
@@ -1480,7 +1489,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
translation_server->setup(); //register translations, load them, etc.
if (locale != "") {
-
translation_server->set_locale(locale);
}
translation_server->load_translations();
@@ -1520,7 +1528,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
static MainTimerSync main_timer_sync;
bool Main::start() {
-
ERR_FAIL_COND_V(!_start_success, false);
bool hasicon = false;
@@ -1557,7 +1564,11 @@ bool Main::start() {
} else if (args[i].length() && args[i][0] != '-' && positional_arg == "") {
positional_arg = args[i];
- if (args[i].ends_with(".scn") || args[i].ends_with(".tscn") || args[i].ends_with(".escn")) {
+ if (args[i].ends_with(".scn") ||
+ args[i].ends_with(".tscn") ||
+ args[i].ends_with(".escn") ||
+ args[i].ends_with(".res") ||
+ args[i].ends_with(".tres")) {
// Only consider the positional argument to be a scene path if it ends with
// a file extension associated with Godot scenes. This makes it possible
// for projects to parse command-line arguments for custom CLI arguments
@@ -1577,8 +1588,9 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
} else if (args[i] == "--doctool") {
doc_tool = args[i + 1];
- for (int j = i + 2; j < args.size(); j++)
+ for (int j = i + 2; j < args.size(); j++) {
removal_docs.push_back(args[j]);
+ }
} else if (args[i] == "--export") {
editor = true; //needs editor
_export_preset = args[i + 1];
@@ -1604,7 +1616,6 @@ bool Main::start() {
String main_loop_type;
#ifdef TOOLS_ENABLED
if (doc_tool != "") {
-
Engine::get_singleton()->set_editor_hint(true); // Needed to instance editor-only classes for their default values
{
@@ -1633,7 +1644,11 @@ bool Main::start() {
print_line("Loading docs...");
for (int i = 0; i < _doc_data_class_path_count; i++) {
- String path = doc_tool.plus_file(_doc_data_class_paths[i].path);
+ // Custom modules are always located by absolute path.
+ String path = _doc_data_class_paths[i].path;
+ if (path.is_rel_path()) {
+ path = doc_tool.plus_file(path);
+ }
String name = _doc_data_class_paths[i].name;
doc_data_classes[name] = path;
if (!checked_paths.has(path)) {
@@ -1695,12 +1710,12 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
main_loop = test_main(test, args);
- if (!main_loop)
+ if (!main_loop) {
return false;
+ }
#endif
} else if (script != "") {
-
Ref<Script> script_res = ResourceLoader::load(script);
ERR_FAIL_COND_V_MSG(script_res.is_null(), false, "Can't load script: " + script);
@@ -1712,20 +1727,19 @@ bool Main::start() {
}
if (script_res->can_instance()) {
-
StringName instance_type = script_res->get_instance_base_type();
Object *obj = ClassDB::instance(instance_type);
MainLoop *script_loop = Object::cast_to<MainLoop>(obj);
if (!script_loop) {
- if (obj)
+ if (obj) {
memdelete(obj);
+ }
ERR_FAIL_V_MSG(false, vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.", script));
}
script_loop->set_init_script(script_res);
main_loop = script_loop;
} else {
-
return false;
}
@@ -1733,21 +1747,20 @@ bool Main::start() {
main_loop_type = GLOBAL_DEF("application/run/main_loop_type", "");
}
- if (!main_loop && main_loop_type == "")
+ if (!main_loop && main_loop_type == "") {
main_loop_type = "SceneTree";
+ }
if (!main_loop) {
if (!ClassDB::class_exists(main_loop_type)) {
DisplayServer::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
return false;
} else {
-
Object *ml = ClassDB::instance(main_loop_type);
ERR_FAIL_COND_V_MSG(!ml, false, "Can't instance MainLoop type.");
main_loop = Object::cast_to<MainLoop>(ml);
if (!main_loop) {
-
memdelete(ml);
ERR_FAIL_V_MSG(false, "Invalid MainLoop type.");
}
@@ -1755,7 +1768,6 @@ bool Main::start() {
}
if (main_loop->is_class("SceneTree")) {
-
SceneTree *sml = Object::cast_to<SceneTree>(main_loop);
#ifdef DEBUG_ENABLED
@@ -1783,10 +1795,10 @@ bool Main::start() {
//first pass, add the constants so they exist before any script is loaded
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String s = E->get().name;
- if (!s.begins_with("autoload/"))
+ if (!s.begins_with("autoload/")) {
continue;
+ }
String name = s.get_slicec('/', 1);
String path = ProjectSettings::get_singleton()->get(s);
bool global_var = false;
@@ -1804,10 +1816,10 @@ bool Main::start() {
//second pass, load into global constants
List<Node *> to_add;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String s = E->get().name;
- if (!s.begins_with("autoload/"))
+ if (!s.begins_with("autoload/")) {
continue;
+ }
String name = s.get_slicec('/', 1);
String path = ProjectSettings::get_singleton()->get(s);
bool global_var = false;
@@ -1850,7 +1862,6 @@ bool Main::start() {
}
for (List<Node *>::Element *E = to_add.front(); E; E = E->next()) {
-
sml->get_root()->add_child(E->get());
}
}
@@ -1870,7 +1881,6 @@ bool Main::start() {
#endif
{
-
int directional_atlas_size = GLOBAL_GET("rendering/quality/directional_shadow/size");
RenderingServer::get_singleton()->directional_shadow_atlas_set_size(directional_atlas_size);
}
@@ -1883,20 +1893,22 @@ bool Main::start() {
Size2i stretch_size = Size2(GLOBAL_DEF("display/window/size/width", 0), GLOBAL_DEF("display/window/size/height", 0));
Window::ContentScaleMode cs_sm = Window::CONTENT_SCALE_MODE_DISABLED;
- if (stretch_mode == "objects")
+ if (stretch_mode == "objects") {
cs_sm = Window::CONTENT_SCALE_MODE_OBJECTS;
- else if (stretch_mode == "pixels")
+ } else if (stretch_mode == "pixels") {
cs_sm = Window::CONTENT_SCALE_MODE_PIXELS;
+ }
Window::ContentScaleAspect cs_aspect = Window::CONTENT_SCALE_ASPECT_IGNORE;
- if (stretch_aspect == "keep")
+ if (stretch_aspect == "keep") {
cs_aspect = Window::CONTENT_SCALE_ASPECT_KEEP;
- else if (stretch_aspect == "keep_width")
+ } else if (stretch_aspect == "keep_width") {
cs_aspect = Window::CONTENT_SCALE_ASPECT_KEEP_WIDTH;
- else if (stretch_aspect == "keep_height")
+ } else if (stretch_aspect == "keep_height") {
cs_aspect = Window::CONTENT_SCALE_ASPECT_KEEP_HEIGHT;
- else if (stretch_aspect == "expand")
+ } else if (stretch_aspect == "expand") {
cs_aspect = Window::CONTENT_SCALE_ASPECT_EXPAND;
+ }
sml->get_root()->set_content_scale_mode(cs_sm);
sml->get_root()->set_content_scale_aspect(cs_aspect);
@@ -1906,7 +1918,14 @@ bool Main::start() {
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
String appname = ProjectSettings::get_singleton()->get("application/config/name");
appname = TranslationServer::get_singleton()->translate(appname);
+#ifdef DEBUG_ENABLED
+ // Append a suffix to the window title to denote that the project is running
+ // from a debug build (including the editor). Since this results in lower performance,
+ // this should be clearly presented to the user.
+ DisplayServer::get_singleton()->window_set_title(vformat("%s (DEBUG)", appname));
+#else
DisplayServer::get_singleton()->window_set_title(appname);
+#endif
int shadow_atlas_size = GLOBAL_GET("rendering/quality/shadow_atlas/size");
int shadow_atlas_q0_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_0_subdiv");
@@ -1932,7 +1951,6 @@ bool Main::start() {
sml->get_root()->set_default_canvas_item_texture_repeat(Viewport::DefaultCanvasItemTextureRepeat(texture_repeat));
} else {
-
GLOBAL_DEF("display/window/stretch/mode", "disabled");
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/mode", PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,2d,viewport"));
GLOBAL_DEF("display/window/stretch/aspect", "ignore");
@@ -1950,18 +1968,25 @@ bool Main::start() {
ProjectSettings::get_singleton()->set_custom_property_info("rendering/canvas_textures/default_texture_repeat", PropertyInfo(Variant::INT, "rendering/canvas_textures/default_texture_repeat", PROPERTY_HINT_ENUM, "Disable,Enable,Mirror"));
}
+#ifdef TOOLS_ENABLED
+ if (editor) {
+ bool editor_embed_subwindows = EditorSettings::get_singleton()->get_setting("interface/editor/single_window_mode");
+
+ if (editor_embed_subwindows) {
+ sml->get_root()->set_embed_subwindows_hint(true);
+ }
+ }
+#endif
+
String local_game_path;
if (game_path != "" && !project_manager) {
-
local_game_path = game_path.replace("\\", "/");
if (!local_game_path.begins_with("res://")) {
bool absolute = (local_game_path.size() > 1) && (local_game_path[0] == '/' || local_game_path[1] == ':');
if (!absolute) {
-
if (ProjectSettings::get_singleton()->is_using_datapack()) {
-
local_game_path = "res://" + local_game_path;
} else {
@@ -1972,7 +1997,6 @@ bool Main::start() {
local_game_path = da->get_current_dir().plus_file(local_game_path);
memdelete(da);
} else {
-
DirAccess *da = DirAccess::open(local_game_path.substr(0, sep));
if (da) {
local_game_path = da->get_current_dir().plus_file(local_game_path.substr(sep + 1, local_game_path.length()));
@@ -1987,17 +2011,11 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (editor) {
-
- bool editor_embed_subwindows = EditorSettings::get_singleton()->get_setting("interface/editor/single_window_mode");
-
- if (editor_embed_subwindows) {
- sml->get_root()->set_embed_subwindows_hint(true);
- }
-
if (game_path != GLOBAL_GET("application/run/main_scene") || !editor_node->has_scenes_in_session()) {
Error serr = editor_node->load_scene(local_game_path);
- if (serr != OK)
+ if (serr != OK) {
ERR_PRINT("Failed to load scene");
+ }
}
DisplayServer::get_singleton()->set_context(DisplayServer::CONTEXT_EDITOR);
}
@@ -2015,8 +2033,9 @@ bool Main::start() {
if (game_path != "") {
Node *scene = nullptr;
Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path);
- if (scenedata.is_valid())
+ if (scenedata.is_valid()) {
scene = scenedata->instance();
+ }
ERR_FAIL_COND_V_MSG(!scene, false, "Failed loading scene: " + local_game_path);
sml->add_current_scene(scene);
@@ -2051,7 +2070,6 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (project_manager || (script == "" && test == "" && game_path == "" && !editor)) {
-
Engine::get_singleton()->set_editor_hint(true);
ProjectManager *pmanager = memnew(ProjectManager);
ProgressDialog *progress_dialog = memnew(ProgressDialog);
@@ -2109,7 +2127,6 @@ static uint64_t physics_process_max = 0;
static uint64_t idle_process_max = 0;
bool Main::iteration() {
-
//for now do not error on this
//ERR_FAIL_COND_V(iterating, false);
@@ -2152,7 +2169,6 @@ bool Main::iteration() {
Engine::get_singleton()->_in_physics = true;
for (int iters = 0; iters < advance.physics_steps; ++iters) {
-
uint64_t physics_begin = OS::get_singleton()->get_ticks_usec();
PhysicsServer3D::get_singleton()->sync();
@@ -2193,8 +2209,7 @@ bool Main::iteration() {
RenderingServer::get_singleton()->sync(); //sync if still drawing from previous frames.
- if (DisplayServer::get_singleton()->can_any_window_draw() && !disable_render_loop) {
-
+ if (DisplayServer::get_singleton()->can_any_window_draw() && RenderingServer::get_singleton()->is_render_loop_enabled()) {
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) {
if (RenderingServer::get_singleton()->has_changed()) {
RenderingServer::get_singleton()->draw(true, scaled_step); // flush visual commands
@@ -2217,14 +2232,14 @@ bool Main::iteration() {
AudioServer::get_singleton()->update();
- if (EngineDebugger::is_active())
+ if (EngineDebugger::is_active()) {
EngineDebugger::get_singleton()->iteration(frame_time, idle_process_ticks, physics_process_ticks, frame_slice);
+ }
frames++;
Engine::get_singleton()->_idle_frames++;
if (frame > 1000000) {
-
if (editor || project_manager) {
if (print_fps) {
print_line("Editor FPS: " + itos(frames));
@@ -2245,15 +2260,17 @@ bool Main::iteration() {
iterating--;
- if (fixed_fps != -1)
+ if (fixed_fps != -1) {
return exit;
+ }
- if (OS::get_singleton()->is_in_low_processor_usage_mode() || !DisplayServer::get_singleton()->can_any_window_draw())
+ if (OS::get_singleton()->is_in_low_processor_usage_mode() || !DisplayServer::get_singleton()->can_any_window_draw()) {
OS::get_singleton()->delay_usec(OS::get_singleton()->get_low_processor_usage_mode_sleep_usec()); //apply some delay to force idle time
- else {
+ } else {
uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
- if (frame_delay)
+ if (frame_delay) {
OS::get_singleton()->delay_usec(Engine::get_singleton()->get_frame_delay() * 1000);
+ }
}
int target_fps = Engine::get_singleton()->get_target_fps();
@@ -2261,8 +2278,9 @@ bool Main::iteration() {
uint64_t time_step = 1000000L / target_fps;
target_ticks += time_step;
uint64_t current_ticks = OS::get_singleton()->get_ticks_usec();
- if (current_ticks < target_ticks)
+ if (current_ticks < target_ticks) {
OS::get_singleton()->delay_usec(target_ticks - current_ticks);
+ }
current_ticks = OS::get_singleton()->get_ticks_usec();
target_ticks = MIN(MAX(target_ticks, current_ticks - time_step), current_ticks + time_step);
}
@@ -2294,7 +2312,6 @@ void Main::force_redraw() {
* The order matters as some of those steps are linked with each other.
*/
void Main::cleanup() {
-
ERR_FAIL_COND(!_start_success);
EngineDebugger::deinitialize();
@@ -2358,20 +2375,27 @@ void Main::cleanup() {
memdelete(input);
}
- if (packed_data)
+ if (packed_data) {
memdelete(packed_data);
- if (file_access_network_client)
+ }
+ if (file_access_network_client) {
memdelete(file_access_network_client);
- if (performance)
+ }
+ if (performance) {
memdelete(performance);
- if (input_map)
+ }
+ if (input_map) {
memdelete(input_map);
- if (translation_server)
+ }
+ if (translation_server) {
memdelete(translation_server);
- if (globals)
+ }
+ if (globals) {
memdelete(globals);
- if (engine)
+ }
+ if (engine) {
memdelete(engine);
+ }
if (OS::get_singleton()->is_restart_on_exit_set()) {
//attempt to restart with arguments
diff --git a/main/main.h b/main/main.h
index e8f8357518..ab6917a65c 100644
--- a/main/main.h
+++ b/main/main.h
@@ -36,7 +36,6 @@
#include "core/typedefs.h"
class Main {
-
static void print_help(const char *p_binary);
static uint64_t last_ticks;
static uint64_t target_ticks;
diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp
index 9e23a1f5cb..5252ea005b 100644
--- a/main/main_timer_sync.cpp
+++ b/main/main_timer_sync.cpp
@@ -56,15 +56,17 @@ int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) {
for (int i = 1; i < CONTROL_STEPS; ++i) {
const float typical_lower = typical_physics_steps[i];
const float current_min = typical_lower / (i + 1);
- if (current_min > p_max)
+ if (current_min > p_max) {
return i; // bail out of further restrictions would void the interval
- else if (current_min > p_min)
+ } else if (current_min > p_min) {
p_min = current_min;
+ }
const float current_max = (typical_lower + 1) / (i + 1);
- if (current_max < p_min)
+ if (current_max < p_min) {
return i;
- else if (current_max < p_max)
+ } else if (current_max < p_max) {
p_max = current_max;
+ }
}
return CONTROL_STEPS;
@@ -95,10 +97,12 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
break;
}
- if (steps_left_to_match_typical > min_typical_steps)
+ if (steps_left_to_match_typical > min_typical_steps) {
min_typical_steps = steps_left_to_match_typical;
- if (steps_left_to_match_typical + 1 < max_typical_steps)
+ }
+ if (steps_left_to_match_typical + 1 < max_typical_steps) {
max_typical_steps = steps_left_to_match_typical + 1;
+ }
}
// try to keep it consistent with previous iterations
@@ -143,8 +147,9 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
MainFrameTime MainTimerSync::advance_checked(float p_frame_slice, int p_iterations_per_second, float p_idle_step) {
- if (fixed_fps != -1)
+ if (fixed_fps != -1) {
p_idle_step = 1.0 / fixed_fps;
+ }
// compensate for last deficit
p_idle_step += time_deficit;
@@ -193,12 +198,7 @@ float MainTimerSync::get_cpu_idle_step() {
return cpu_ticks_elapsed / 1000000.0;
}
-MainTimerSync::MainTimerSync() :
- last_cpu_ticks_usec(0),
- current_cpu_ticks_usec(0),
- time_accum(0),
- time_deficit(0),
- fixed_fps(0) {
+MainTimerSync::MainTimerSync() {
for (int i = CONTROL_STEPS - 1; i >= 0; --i) {
typical_physics_steps[i] = i;
accumulated_physics_steps[i] = i;
diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h
index 620d1c747d..2126381c7c 100644
--- a/main/main_timer_sync.h
+++ b/main/main_timer_sync.h
@@ -43,14 +43,14 @@ struct MainFrameTime {
class MainTimerSync {
// wall clock time measured on the main thread
- uint64_t last_cpu_ticks_usec;
- uint64_t current_cpu_ticks_usec;
+ uint64_t last_cpu_ticks_usec = 0;
+ uint64_t current_cpu_ticks_usec = 0;
// logical game time since last physics timestep
- float time_accum;
+ float time_accum = 0;
// current difference between wall clock time and reported sum of idle_steps
- float time_deficit;
+ float time_deficit = 0;
// number of frames back for keeping accumulated physics steps roughly constant.
// value of 12 chosen because that is what is required to make 144 Hz monitors
@@ -64,7 +64,7 @@ class MainTimerSync {
// typical value for accumulated_physics_steps[i] is either this or this plus one
int typical_physics_steps[CONTROL_STEPS];
- int fixed_fps;
+ int fixed_fps = 0;
protected:
// returns the fraction of p_frame_slice required for the timer to overshoot
diff --git a/main/performance.cpp b/main/performance.cpp
index 3de2cba125..7e6b9fca64 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -42,7 +42,6 @@
Performance *Performance::singleton = nullptr;
void Performance::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_monitor", "monitor"), &Performance::get_monitor);
BIND_ENUM_CONSTANT(TIME_FPS);
@@ -79,13 +78,13 @@ void Performance::_bind_methods() {
float Performance::_get_node_count() const {
MainLoop *ml = OS::get_singleton()->get_main_loop();
SceneTree *sml = Object::cast_to<SceneTree>(ml);
- if (!sml)
+ if (!sml) {
return 0;
+ }
return sml->get_node_count();
}
String Performance::get_monitor_name(Monitor p_monitor) const {
-
ERR_FAIL_INDEX_V(p_monitor, MONITOR_MAX, String());
static const char *names[MONITOR_MAX] = {
@@ -123,7 +122,6 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
}
float Performance::get_monitor(Monitor p_monitor) const {
-
switch (p_monitor) {
case TIME_FPS:
return Engine::get_singleton()->get_frames_per_second();
@@ -226,17 +224,14 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const
}
void Performance::set_process_time(float p_pt) {
-
_process_time = p_pt;
}
void Performance::set_physics_process_time(float p_pt) {
-
_physics_process_time = p_pt;
}
Performance::Performance() {
-
_process_time = 0;
_physics_process_time = 0;
singleton = this;
diff --git a/main/performance.h b/main/performance.h
index c0f6044ea0..ddbe45fa00 100644
--- a/main/performance.h
+++ b/main/performance.h
@@ -37,7 +37,6 @@
#define PERF_WARN_PROCESS_SYNC
class Performance : public Object {
-
GDCLASS(Performance, Object);
static Performance *singleton;
diff --git a/main/tests/test_astar.cpp b/main/tests/test_astar.cpp
index 66f9aa8ad6..fe335589b0 100644
--- a/main/tests/test_astar.cpp
+++ b/main/tests/test_astar.cpp
@@ -173,8 +173,9 @@ bool test_add_remove() {
for (int i = 0; i < 20000; i++) {
int u = Math::rand() % 5;
int v = Math::rand() % 4;
- if (u == v)
+ if (u == v) {
v = 4;
+ }
if (Math::rand() % 2 == 1) {
// Add a (possibly existing) directed edge and confirm connectivity
a.connect_points(u, v, false);
@@ -189,19 +190,22 @@ bool test_add_remove() {
// Random tests for point removal
for (int i = 0; i < 20000; i++) {
a.clear();
- for (int j = 0; j < 5; j++)
+ for (int j = 0; j < 5; j++) {
a.add_point(j, Vector3(0, 0, 0));
+ }
// Add or remove random edges
for (int j = 0; j < 10; j++) {
int u = Math::rand() % 5;
int v = Math::rand() % 4;
- if (u == v)
+ if (u == v) {
v = 4;
- if (Math::rand() % 2 == 1)
+ }
+ if (Math::rand() % 2 == 1) {
a.connect_points(u, v, false);
- else
+ } else {
a.disconnect_points(u, v, false);
+ }
}
// Remove point 0
@@ -241,8 +245,9 @@ bool test_solutions() {
int u, v;
u = Math::rand() % N;
v = Math::rand() % (N - 1);
- if (u == v)
+ if (u == v) {
v = N - 1;
+ }
// Pick a random operation
int op = Math::rand();
@@ -256,16 +261,18 @@ bool test_solutions() {
// Add edge (u, v); possibly bidirectional
a.connect_points(u, v, op % 2);
adj[u][v] = true;
- if (op % 2)
+ if (op % 2) {
adj[v][u] = true;
+ }
break;
case 6:
case 7:
// Remove edge (u, v); possibly bidirectional
a.disconnect_points(u, v, op % 2);
adj[u][v] = false;
- if (op % 2)
+ if (op % 2) {
adj[v][u] = false;
+ }
break;
case 8:
// Remove point u and add it back; clears adjacent edges and changes coordinates
@@ -274,42 +281,55 @@ bool test_solutions() {
p[u].y = Math::rand() % 100;
p[u].z = Math::rand() % 100;
a.add_point(u, p[u]);
- for (v = 0; v < N; v++)
+ for (v = 0; v < N; v++) {
adj[u][v] = adj[v][u] = false;
+ }
break;
}
}
// Floyd-Warshall
float d[N][N];
- for (int u = 0; u < N; u++)
- for (int v = 0; v < N; v++)
+ for (int u = 0; u < N; u++) {
+ for (int v = 0; v < N; v++) {
d[u][v] = (u == v || adj[u][v]) ? p[u].distance_to(p[v]) : INFINITY;
+ }
+ }
- for (int w = 0; w < N; w++)
- for (int u = 0; u < N; u++)
- for (int v = 0; v < N; v++)
- if (d[u][v] > d[u][w] + d[w][v])
+ for (int w = 0; w < N; w++) {
+ for (int u = 0; u < N; u++) {
+ for (int v = 0; v < N; v++) {
+ if (d[u][v] > d[u][w] + d[w][v]) {
d[u][v] = d[u][w] + d[w][v];
+ }
+ }
+ }
+ }
// Display statistics
int count = 0;
- for (int u = 0; u < N; u++)
- for (int v = 0; v < N; v++)
- if (adj[u][v])
+ for (int u = 0; u < N; u++) {
+ for (int v = 0; v < N; v++) {
+ if (adj[u][v]) {
count++;
+ }
+ }
+ }
printf("Test #%4d: %3d edges, ", test + 1, count);
count = 0;
- for (int u = 0; u < N; u++)
- for (int v = 0; v < N; v++)
- if (!Math::is_inf(d[u][v]))
+ for (int u = 0; u < N; u++) {
+ for (int v = 0; v < N; v++) {
+ if (!Math::is_inf(d[u][v])) {
count++;
+ }
+ }
+ }
printf("%3d/%d pairs of reachable points\n", count - N, N * (N - 1));
// Check A*'s output
bool match = true;
- for (int u = 0; u < N; u++)
- for (int v = 0; v < N; v++)
+ for (int u = 0; u < N; u++) {
+ for (int v = 0; v < N; v++) {
if (u != v) {
Vector<int> route = a.get_id_path(u, v);
if (!Math::is_inf(d[u][v])) {
@@ -344,15 +364,18 @@ bool test_solutions() {
}
}
}
+ }
+ }
exit:
- if (!match)
+ if (!match) {
return false;
+ }
}
return true;
}
-typedef bool (*TestFunc)(void);
+typedef bool (*TestFunc)();
TestFunc test_funcs[] = {
test_abc,
@@ -367,11 +390,13 @@ MainLoop *test() {
int passed = 0;
while (true) {
- if (!test_funcs[count])
+ if (!test_funcs[count]) {
break;
+ }
bool pass = test_funcs[count]();
- if (pass)
+ if (pass) {
passed++;
+ }
OS::get_singleton()->print("\t%s\n", pass ? "PASS" : "FAILED");
count++;
diff --git a/main/tests/test_basis.cpp b/main/tests/test_basis.cpp
new file mode 100644
index 0000000000..ac25151fd8
--- /dev/null
+++ b/main/tests/test_basis.cpp
@@ -0,0 +1,325 @@
+/*************************************************************************/
+/* test_fbx.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 "test_basis.h"
+
+#include "core/math/random_number_generator.h"
+#include "core/os/os.h"
+#include "core/ustring.h"
+
+namespace TestBasis {
+
+enum RotOrder {
+ EulerXYZ,
+ EulerXZY,
+ EulerYZX,
+ EulerYXZ,
+ EulerZXY,
+ EulerZYX
+};
+
+Vector3 deg2rad(const Vector3 &p_rotation) {
+ return p_rotation / 180.0 * Math_PI;
+}
+
+Vector3 rad2deg(const Vector3 &p_rotation) {
+ return p_rotation / Math_PI * 180.0;
+}
+
+Basis EulerToBasis(RotOrder mode, const Vector3 &p_rotation) {
+ Basis ret;
+ switch (mode) {
+ case EulerXYZ:
+ ret.set_euler_xyz(p_rotation);
+ break;
+
+ case EulerXZY:
+ ret.set_euler_xzy(p_rotation);
+ break;
+
+ case EulerYZX:
+ ret.set_euler_yzx(p_rotation);
+ break;
+
+ case EulerYXZ:
+ ret.set_euler_yxz(p_rotation);
+ break;
+
+ case EulerZXY:
+ ret.set_euler_zxy(p_rotation);
+ break;
+
+ case EulerZYX:
+ ret.set_euler_zyx(p_rotation);
+ break;
+
+ default:
+ // If you land here, Please integrate all rotation orders.
+ CRASH_NOW_MSG("This is not unreachable.");
+ }
+
+ return ret;
+}
+
+Vector3 BasisToEuler(RotOrder mode, const Basis &p_rotation) {
+ switch (mode) {
+ case EulerXYZ:
+ return p_rotation.get_euler_xyz();
+
+ case EulerXZY:
+ return p_rotation.get_euler_xzy();
+
+ case EulerYZX:
+ return p_rotation.get_euler_yzx();
+
+ case EulerYXZ:
+ return p_rotation.get_euler_yxz();
+
+ case EulerZXY:
+ return p_rotation.get_euler_zxy();
+
+ case EulerZYX:
+ return p_rotation.get_euler_zyx();
+
+ default:
+ // If you land here, Please integrate all rotation orders.
+ CRASH_NOW_MSG("This is not unreachable.");
+ return Vector3();
+ }
+}
+
+String get_rot_order_name(RotOrder ro) {
+ switch (ro) {
+ case EulerXYZ:
+ return "XYZ";
+ case EulerXZY:
+ return "XZY";
+ case EulerYZX:
+ return "YZX";
+ case EulerYXZ:
+ return "YXZ";
+ case EulerZXY:
+ return "ZXY";
+ case EulerZYX:
+ return "ZYX";
+ default:
+ return "[Not supported]";
+ }
+}
+
+bool test_rotation(Vector3 deg_original_euler, RotOrder rot_order) {
+ // This test:
+ // 1. Converts the rotation vector from deg to rad.
+ // 2. Converts euler to basis.
+ // 3. Converts the above basis back into euler.
+ // 4. Converts the above euler into basis again.
+ // 5. Compares the basis obtained in step 2 with the basis of step 4
+ //
+ // The conversion "basis to euler", done in the step 3, may be different from
+ // the original euler, even if the final rotation are the same.
+ // This happens because there are more ways to represents the same rotation,
+ // both valid, using eulers.
+ // For this reason is necessary to convert that euler back to basis and finally
+ // compares it.
+ //
+ // In this way we can assert that both functions: basis to euler / euler to basis
+ // are correct.
+
+ bool pass = true;
+
+ // Euler to rotation
+ const Vector3 original_euler = deg2rad(deg_original_euler);
+ const Basis to_rotation = EulerToBasis(rot_order, original_euler);
+
+ // Euler from rotation
+ const Vector3 euler_from_rotation = BasisToEuler(rot_order, to_rotation);
+ const Basis rotation_from_computed_euler = EulerToBasis(rot_order, euler_from_rotation);
+
+ Basis res = to_rotation.inverse() * rotation_from_computed_euler;
+
+ if ((res.get_axis(0) - Vector3(1.0, 0.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Fail due to X %ls\n", String(res.get_axis(0)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(1) - Vector3(0.0, 1.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Fail due to Y %ls\n", String(res.get_axis(1)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(2) - Vector3(0.0, 0.0, 1.0)).length() > 0.1) {
+ OS::get_singleton()->print("Fail due to Z %ls\n", String(res.get_axis(2)).c_str());
+ pass = false;
+ }
+
+ if (pass) {
+ // Double check `to_rotation` decomposing with XYZ rotation order.
+ const Vector3 euler_xyz_from_rotation = to_rotation.get_euler_xyz();
+ Basis rotation_from_xyz_computed_euler;
+ rotation_from_xyz_computed_euler.set_euler_xyz(euler_xyz_from_rotation);
+
+ res = to_rotation.inverse() * rotation_from_xyz_computed_euler;
+
+ if ((res.get_axis(0) - Vector3(1.0, 0.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Double check with XYZ rot order failed, due to X %ls\n", String(res.get_axis(0)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(1) - Vector3(0.0, 1.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Double check with XYZ rot order failed, due to Y %ls\n", String(res.get_axis(1)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(2) - Vector3(0.0, 0.0, 1.0)).length() > 0.1) {
+ OS::get_singleton()->print("Double check with XYZ rot order failed, due to Z %ls\n", String(res.get_axis(2)).c_str());
+ pass = false;
+ }
+ }
+
+ if (pass == false) {
+ // Print phase only if not pass.
+ OS *os = OS::get_singleton();
+ os->print("Rotation order: %ls\n.", get_rot_order_name(rot_order).c_str());
+ os->print("Original Rotation: %ls\n", String(deg_original_euler).c_str());
+ os->print("Quaternion to rotation order: %ls\n", String(rad2deg(euler_from_rotation)).c_str());
+ }
+
+ return pass;
+}
+
+void test_euler_conversion() {
+ Vector<RotOrder> rotorder_to_test;
+ rotorder_to_test.push_back(EulerXYZ);
+ rotorder_to_test.push_back(EulerXZY);
+ rotorder_to_test.push_back(EulerYZX);
+ rotorder_to_test.push_back(EulerYXZ);
+ rotorder_to_test.push_back(EulerZXY);
+ rotorder_to_test.push_back(EulerZYX);
+
+ Vector<Vector3> vectors_to_test;
+
+ // Test the special cases.
+ vectors_to_test.push_back(Vector3(0.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.5, 0.5, 0.5));
+ vectors_to_test.push_back(Vector3(-0.5, -0.5, -0.5));
+ vectors_to_test.push_back(Vector3(40.0, 40.0, 40.0));
+ vectors_to_test.push_back(Vector3(-40.0, -40.0, -40.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, -90.0));
+ vectors_to_test.push_back(Vector3(0.0, -90.0, 0.0));
+ vectors_to_test.push_back(Vector3(-90.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, 90.0));
+ vectors_to_test.push_back(Vector3(0.0, 90.0, 0.0));
+ vectors_to_test.push_back(Vector3(90.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, -30.0));
+ vectors_to_test.push_back(Vector3(0.0, -30.0, 0.0));
+ vectors_to_test.push_back(Vector3(-30.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, 30.0));
+ vectors_to_test.push_back(Vector3(0.0, 30.0, 0.0));
+ vectors_to_test.push_back(Vector3(30.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.5, 50.0, 20.0));
+ vectors_to_test.push_back(Vector3(-0.5, -50.0, -20.0));
+ vectors_to_test.push_back(Vector3(0.5, 0.0, 90.0));
+ vectors_to_test.push_back(Vector3(0.5, 0.0, -90.0));
+ vectors_to_test.push_back(Vector3(360.0, 360.0, 360.0));
+ vectors_to_test.push_back(Vector3(-360.0, -360.0, -360.0));
+ vectors_to_test.push_back(Vector3(-90.0, 60.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, 60.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, -60.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, -60.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, 60.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, 60.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, -60.0, 90.0));
+ vectors_to_test.push_back(Vector3(-90.0, -60.0, 90.0));
+ vectors_to_test.push_back(Vector3(60.0, 90.0, -40.0));
+ vectors_to_test.push_back(Vector3(60.0, -90.0, -40.0));
+ vectors_to_test.push_back(Vector3(-60.0, -90.0, -40.0));
+ vectors_to_test.push_back(Vector3(-60.0, 90.0, 40.0));
+ vectors_to_test.push_back(Vector3(60.0, 90.0, 40.0));
+ vectors_to_test.push_back(Vector3(60.0, -90.0, 40.0));
+ vectors_to_test.push_back(Vector3(-60.0, -90.0, 40.0));
+ vectors_to_test.push_back(Vector3(-90.0, 90.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, 90.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, -90.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, -90.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, 90.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, 90.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, -90.0, 90.0));
+ vectors_to_test.push_back(Vector3(20.0, 150.0, 30.0));
+ vectors_to_test.push_back(Vector3(20.0, -150.0, 30.0));
+ vectors_to_test.push_back(Vector3(-120.0, -150.0, 30.0));
+ vectors_to_test.push_back(Vector3(-120.0, -150.0, -130.0));
+ vectors_to_test.push_back(Vector3(120.0, -150.0, -130.0));
+ vectors_to_test.push_back(Vector3(120.0, 150.0, -130.0));
+ vectors_to_test.push_back(Vector3(120.0, 150.0, 130.0));
+
+ // Add 1000 random vectors with weirds numbers.
+ RandomNumberGenerator rng;
+ for (int _ = 0; _ < 1000; _ += 1) {
+ vectors_to_test.push_back(Vector3(
+ rng.randf_range(-1800, 1800),
+ rng.randf_range(-1800, 1800),
+ rng.randf_range(-1800, 1800)));
+ }
+
+ bool success = true;
+ for (int h = 0; h < rotorder_to_test.size(); h += 1) {
+ int passed = 0;
+ int failed = 0;
+ for (int i = 0; i < vectors_to_test.size(); i += 1) {
+ if (test_rotation(vectors_to_test[i], rotorder_to_test[h])) {
+ //OS::get_singleton()->print("Success. \n\n");
+ passed += 1;
+ } else {
+ OS::get_singleton()->print("FAILED FAILED FAILED. \n\n");
+ OS::get_singleton()->print("------------>\n");
+ OS::get_singleton()->print("------------>\n");
+ failed += 1;
+ success = false;
+ }
+ }
+
+ if (failed == 0) {
+ OS::get_singleton()->print("%i passed tests for rotation order: %ls.\n", passed, get_rot_order_name(rotorder_to_test[h]).c_str());
+ } else {
+ OS::get_singleton()->print("%i FAILED tests for rotation order: %ls.\n", failed, get_rot_order_name(rotorder_to_test[h]).c_str());
+ }
+ }
+
+ if (success) {
+ OS::get_singleton()->print("Euler conversion checks passed.\n");
+ } else {
+ OS::get_singleton()->print("Euler conversion checks FAILED.\n");
+ }
+}
+
+MainLoop *test() {
+ OS::get_singleton()->print("Start euler conversion checks.\n");
+ test_euler_conversion();
+
+ return NULL;
+}
+
+} // namespace TestBasis
diff --git a/core/path_remap.h b/main/tests/test_basis.h
index 1580e88625..67c9db8877 100644
--- a/core/path_remap.h
+++ b/main/tests/test_basis.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path_remap.h */
+/* test_fbx.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PATH_REMAP_H
-#define PATH_REMAP_H
+#ifndef TEST_BASIS_H
+#define TEST_BASIS_H
-#endif // PATH_REMAP_H
+#include "core/os/main_loop.h"
+
+namespace TestBasis {
+MainLoop *test();
+}
+
+#endif
diff --git a/main/tests/test_class_db.cpp b/main/tests/test_class_db.cpp
new file mode 100644
index 0000000000..3171091402
--- /dev/null
+++ b/main/tests/test_class_db.cpp
@@ -0,0 +1,882 @@
+/*************************************************************************/
+/* test_class_db.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 "test_class_db.h"
+
+#include "core/global_constants.h"
+#include "core/ordered_hash_map.h"
+#include "core/os/os.h"
+#include "core/string_name.h"
+#include "core/ustring.h"
+#include "core/variant.h"
+
+namespace TestClassDB {
+
+enum class [[nodiscard]] TestResult{
+ FAILED,
+ PASS
+};
+
+#define TEST_FAIL_COND(m_cond, m_msg) \
+ if (unlikely(m_cond)) { \
+ ERR_PRINT(m_msg); \
+ return TestResult::FAILED; \
+ } else \
+ ((void)0)
+
+#define TEST_COND(m_cond, m_msg) \
+ if (unlikely(m_cond)) { \
+ ERR_PRINT(m_msg); \
+ __test_result__ = TestResult::FAILED; \
+ } else \
+ ((void)0)
+
+#define TEST_FAIL_CHECK(m_test_expr) \
+ if (unlikely((m_test_expr) == TestResult::FAILED)) { \
+ return TestResult::FAILED; \
+ } else \
+ ((void)0)
+
+#define TEST_CHECK(m_test_expr) \
+ if (unlikely((m_test_expr) == TestResult::FAILED)) { \
+ __test_result__ = TestResult::FAILED; \
+ } else \
+ ((void)0)
+
+#define TEST_START() \
+ TestResult __test_result__ = TestResult::PASS; \
+ ((void)0)
+
+#define TEST_END() return __test_result__;
+
+struct TypeReference {
+ StringName name;
+ bool is_enum = false;
+};
+
+struct ConstantData {
+ String name;
+ int value = 0;
+};
+
+struct EnumData {
+ StringName name;
+ List<ConstantData> constants;
+
+ _FORCE_INLINE_ bool operator==(const EnumData &p_enum) const {
+ return p_enum.name == name;
+ }
+};
+
+struct PropertyData {
+ StringName name;
+ int index = 0;
+
+ StringName getter;
+ StringName setter;
+};
+
+struct ArgumentData {
+ TypeReference type;
+ String name;
+ bool has_defval = false;
+ Variant defval;
+};
+
+struct MethodData {
+ StringName name;
+ TypeReference return_type;
+ List<ArgumentData> arguments;
+ bool is_virtual = false;
+ bool is_vararg = false;
+};
+
+struct SignalData {
+ StringName name;
+ List<ArgumentData> arguments;
+};
+
+struct ExposedClass {
+ StringName name;
+ StringName base;
+
+ bool is_singleton = false;
+ bool is_instantiable = false;
+ bool is_reference = false;
+
+ ClassDB::APIType api_type;
+
+ List<ConstantData> constants;
+ List<EnumData> enums;
+ List<PropertyData> properties;
+ List<MethodData> methods;
+ List<SignalData> signals_;
+
+ const PropertyData *find_property_by_name(const StringName &p_name) const {
+ for (const List<PropertyData>::Element *E = properties.front(); E; E = E->next()) {
+ if (E->get().name == p_name) {
+ return &E->get();
+ }
+ }
+
+ return nullptr;
+ }
+
+ const MethodData *find_method_by_name(const StringName &p_name) const {
+ for (const List<MethodData>::Element *E = methods.front(); E; E = E->next()) {
+ if (E->get().name == p_name) {
+ return &E->get();
+ }
+ }
+
+ return nullptr;
+ }
+};
+
+struct NamesCache {
+ StringName variant_type = StaticCString::create("Variant");
+ StringName object_class = StaticCString::create("Object");
+ StringName reference_class = StaticCString::create("Reference");
+ StringName string_type = StaticCString::create("String");
+ StringName string_name_type = StaticCString::create("StringName");
+ StringName node_path_type = StaticCString::create("NodePath");
+ StringName bool_type = StaticCString::create("bool");
+ StringName int_type = StaticCString::create("int");
+ StringName float_type = StaticCString::create("float");
+ StringName void_type = StaticCString::create("void");
+ StringName vararg_stub_type = StaticCString::create("@VarArg@");
+ StringName vector2_type = StaticCString::create("Vector2");
+ StringName rect2_type = StaticCString::create("Rect2");
+ StringName vector3_type = StaticCString::create("Vector3");
+
+ // Object not included as it must be checked for all derived classes
+ static constexpr int nullable_types_count = 17;
+ StringName nullable_types[nullable_types_count] = {
+ string_type,
+ string_name_type,
+ node_path_type,
+
+ StaticCString::create(_STR(Array)),
+ StaticCString::create(_STR(Dictionary)),
+ StaticCString::create(_STR(Callable)),
+ StaticCString::create(_STR(Signal)),
+
+ StaticCString::create(_STR(PackedByteArray)),
+ StaticCString::create(_STR(PackedInt32Array)),
+ StaticCString::create(_STR(PackedInt64rray)),
+ StaticCString::create(_STR(PackedFloat32Array)),
+ StaticCString::create(_STR(PackedFloat64Array)),
+ StaticCString::create(_STR(PackedStringArray)),
+ StaticCString::create(_STR(PackedVector2Array)),
+ StaticCString::create(_STR(PackedVector3Array)),
+ StaticCString::create(_STR(PackedColorArray)),
+ };
+
+ bool is_nullable_type(const StringName &p_type) const {
+ for (int i = 0; i < nullable_types_count; i++) {
+ if (p_type == nullable_types[i]) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+};
+
+typedef OrderedHashMap<StringName, ExposedClass> ExposedClasses;
+
+struct Context {
+ Vector<StringName> enum_types;
+ Vector<StringName> builtin_types;
+ ExposedClasses exposed_classes;
+ List<EnumData> global_enums;
+ NamesCache names_cache;
+
+ const ExposedClass *find_exposed_class(const StringName &p_name) const {
+ ExposedClasses::ConstElement elem = exposed_classes.find(p_name);
+ return elem ? &elem.value() : nullptr;
+ }
+
+ const ExposedClass *find_exposed_class(const TypeReference &p_type_ref) const {
+ ExposedClasses::ConstElement elem = exposed_classes.find(p_type_ref.name);
+ return elem ? &elem.value() : nullptr;
+ }
+
+ bool has_type(const TypeReference &p_type_ref) const {
+ if (builtin_types.find(p_type_ref.name) >= 0) {
+ return true;
+ }
+
+ if (p_type_ref.is_enum) {
+ if (enum_types.find(p_type_ref.name) >= 0) {
+ return true;
+ }
+
+ // Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead.
+ return builtin_types.find(names_cache.int_type);
+ }
+
+ return false;
+ }
+};
+
+bool arg_default_value_is_assignable_to_type(const Context &p_context, const Variant &p_val, const TypeReference &p_arg_type) {
+ if (p_arg_type.name == p_context.names_cache.variant_type) {
+ // Variant can take anything
+ return true;
+ }
+
+ switch (p_val.get_type()) {
+ case Variant::NIL:
+ return p_context.find_exposed_class(p_arg_type) ||
+ p_context.names_cache.is_nullable_type(p_arg_type.name);
+ case Variant::BOOL:
+ return p_arg_type.name == p_context.names_cache.bool_type;
+ case Variant::INT:
+ return p_arg_type.name == p_context.names_cache.int_type ||
+ p_arg_type.name == p_context.names_cache.float_type ||
+ p_arg_type.is_enum;
+ case Variant::FLOAT:
+ return p_arg_type.name == p_context.names_cache.float_type;
+ case Variant::STRING:
+ case Variant::STRING_NAME:
+ return p_arg_type.name == p_context.names_cache.string_type ||
+ p_arg_type.name == p_context.names_cache.string_name_type ||
+ p_arg_type.name == p_context.names_cache.node_path_type;
+ case Variant::NODE_PATH:
+ return p_arg_type.name == p_context.names_cache.node_path_type;
+ case Variant::TRANSFORM:
+ case Variant::TRANSFORM2D:
+ case Variant::BASIS:
+ case Variant::QUAT:
+ case Variant::PLANE:
+ case Variant::AABB:
+ case Variant::COLOR:
+ case Variant::VECTOR2:
+ case Variant::RECT2:
+ case Variant::VECTOR3:
+ case Variant::_RID:
+ case Variant::ARRAY:
+ case Variant::DICTIONARY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
+ case Variant::CALLABLE:
+ case Variant::SIGNAL:
+ return p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ case Variant::OBJECT:
+ return p_context.find_exposed_class(p_arg_type);
+ case Variant::VECTOR2I:
+ return p_arg_type.name == p_context.names_cache.vector2_type ||
+ p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ case Variant::RECT2I:
+ return p_arg_type.name == p_context.names_cache.rect2_type ||
+ p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ case Variant::VECTOR3I:
+ return p_arg_type.name == p_context.names_cache.vector3_type ||
+ p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ default:
+ ERR_PRINT("Unexpected Variant type: " + itos(p_val.get_type()));
+ break;
+ }
+
+ return false;
+}
+
+TestResult validate_property(const Context &p_context, const ExposedClass &p_class, const PropertyData &p_prop) {
+ TEST_START();
+
+ const MethodData *setter = p_class.find_method_by_name(p_prop.setter);
+
+ // Search it in base classes too
+ const ExposedClass *top = &p_class;
+ while (!setter && top->base != StringName()) {
+ top = p_context.find_exposed_class(top->base);
+ TEST_FAIL_COND(!top, "Class not found '" + top->base + "'. Inherited by '" + top->name + "'.");
+ setter = top->find_method_by_name(p_prop.setter);
+ }
+
+ const MethodData *getter = p_class.find_method_by_name(p_prop.getter);
+
+ // Search it in base classes too
+ top = &p_class;
+ while (!getter && top->base != StringName()) {
+ top = p_context.find_exposed_class(top->base);
+ TEST_FAIL_COND(!top, "Class not found '" + top->base + "'. Inherited by '" + top->name + "'.");
+ getter = top->find_method_by_name(p_prop.getter);
+ }
+
+ TEST_FAIL_COND(!setter && !getter,
+ "Couldn't find neither the setter nor the getter for property: '" + p_class.name + "." + String(p_prop.name) + "'.");
+
+ if (setter) {
+ int setter_argc = p_prop.index != -1 ? 2 : 1;
+ TEST_FAIL_COND(setter->arguments.size() != setter_argc,
+ "Invalid property setter argument count: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ }
+
+ if (getter) {
+ int getter_argc = p_prop.index != -1 ? 1 : 0;
+ TEST_FAIL_COND(getter->arguments.size() != getter_argc,
+ "Invalid property setter argument count: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ }
+
+ if (getter && setter) {
+ const ArgumentData &setter_first_arg = setter->arguments.back()->get();
+ if (getter->return_type.name != setter_first_arg.type.name) {
+ // Special case for Node::set_name
+ bool whitelisted = getter->return_type.name == p_context.names_cache.string_name_type &&
+ setter_first_arg.type.name == p_context.names_cache.string_type;
+
+ TEST_FAIL_COND(!whitelisted,
+ "Return type from getter doesn't match first argument of setter, for property: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ }
+ }
+
+ const TypeReference &prop_type_ref = getter ? getter->return_type : setter->arguments.back()->get().type;
+
+ const ExposedClass *prop_class = p_context.find_exposed_class(prop_type_ref);
+ if (prop_class) {
+ TEST_COND(prop_class->is_singleton,
+ "Property type is a singleton: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ } else {
+ TEST_FAIL_COND(!p_context.has_type(prop_type_ref),
+ "Property type '" + prop_type_ref.name + "' not found: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ }
+
+ if (getter) {
+ if (p_prop.index != -1) {
+ const ArgumentData &idx_arg = getter->arguments.front()->get();
+ if (idx_arg.type.name != p_context.names_cache.int_type) {
+ // If not an int, it can be an enum
+ TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
+ "Invalid type '" + idx_arg.type.name + "' for index argument of property getter: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ }
+ }
+ }
+
+ if (setter) {
+ if (p_prop.index != -1) {
+ const ArgumentData &idx_arg = setter->arguments.front()->get();
+ if (idx_arg.type.name != p_context.names_cache.int_type) {
+ // Assume the index parameter is an enum
+ // If not an int, it can be an enum
+ TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
+ "Invalid type '" + idx_arg.type.name + "' for index argument of property setter: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ }
+ }
+ }
+
+ TEST_END();
+}
+
+TestResult validate_method(const Context &p_context, const ExposedClass &p_class, const MethodData &p_method) {
+ TEST_START();
+
+ const ExposedClass *return_class = p_context.find_exposed_class(p_method.return_type);
+ if (return_class) {
+ TEST_COND(return_class->is_singleton,
+ "Method return type is a singleton: '" + p_class.name + "." + p_method.name + "'.");
+ }
+
+ for (const List<ArgumentData>::Element *F = p_method.arguments.front(); F; F = F->next()) {
+ const ArgumentData &arg = F->get();
+
+ const ExposedClass *arg_class = p_context.find_exposed_class(arg.type);
+ if (arg_class) {
+ TEST_COND(arg_class->is_singleton,
+ "Argument type is a singleton: '" + arg.name + "' of method '" + p_class.name + "." + p_method.name + "'.");
+ } else {
+ TEST_FAIL_COND(!p_context.has_type(arg.type),
+ "Argument type '" + arg.type.name + "' not found: '" + arg.name + "' of method" + p_class.name + "." + p_method.name + "'.");
+ }
+
+ if (arg.has_defval) {
+ TEST_COND(!arg_default_value_is_assignable_to_type(p_context, arg.defval, arg.type),
+ "Invalid default value for parameter '" + arg.name + "' of method '" + p_class.name + "." + p_method.name + "'.");
+ }
+ }
+
+ TEST_END();
+}
+
+TestResult validate_signal(const Context &p_context, const ExposedClass &p_class, const SignalData &p_signal) {
+ TEST_START();
+
+ for (const List<ArgumentData>::Element *F = p_signal.arguments.front(); F; F = F->next()) {
+ const ArgumentData &arg = F->get();
+
+ const ExposedClass *arg_class = p_context.find_exposed_class(arg.type);
+ if (arg_class) {
+ TEST_COND(arg_class->is_singleton,
+ "Argument class is a singleton: '" + arg.name + "' of signal" + p_class.name + "." + p_signal.name + "'.");
+ } else {
+ TEST_FAIL_COND(!p_context.has_type(arg.type),
+ "Argument type '" + arg.type.name + "' not found: '" + arg.name + "' of signal" + p_class.name + "." + p_signal.name + "'.");
+ }
+ }
+
+ TEST_END();
+}
+
+TestResult validate_class(const Context &p_context, const ExposedClass &p_exposed_class) {
+ TEST_START();
+
+ bool is_derived_type = p_exposed_class.base != StringName();
+
+ if (!is_derived_type) {
+ // Asserts about the base Object class
+ TEST_FAIL_COND(p_exposed_class.name != p_context.names_cache.object_class,
+ "Class '" + p_exposed_class.name + "' has no base class.");
+ TEST_FAIL_COND(!p_exposed_class.is_instantiable,
+ "Object class is not instantiable.");
+ TEST_FAIL_COND(p_exposed_class.api_type != ClassDB::API_CORE,
+ "Object class is API is not API_CORE.");
+ TEST_FAIL_COND(p_exposed_class.is_singleton,
+ "Object class is registered as a singleton.");
+ }
+
+ TEST_FAIL_COND(p_exposed_class.is_singleton && p_exposed_class.base != p_context.names_cache.object_class,
+ "Singleton base class '" + String(p_exposed_class.base) + "' is not Object, for class '" + p_exposed_class.name + "'.");
+
+ TEST_FAIL_COND(is_derived_type && !p_context.exposed_classes.has(p_exposed_class.base),
+ "Base type '" + p_exposed_class.base.operator String() + "' does not exist, for class '" + p_exposed_class.name + "'.");
+
+ for (const List<PropertyData>::Element *F = p_exposed_class.properties.front(); F; F = F->next()) {
+ TEST_CHECK(validate_property(p_context, p_exposed_class, F->get()));
+ }
+
+ for (const List<MethodData>::Element *F = p_exposed_class.methods.front(); F; F = F->next()) {
+ TEST_CHECK(validate_method(p_context, p_exposed_class, F->get()));
+ }
+
+ for (const List<SignalData>::Element *F = p_exposed_class.signals_.front(); F; F = F->next()) {
+ TEST_CHECK(validate_signal(p_context, p_exposed_class, F->get()));
+ }
+
+ TEST_END();
+}
+
+TestResult add_exposed_classes(Context &r_context) {
+ TEST_START();
+
+ List<StringName> class_list;
+ ClassDB::get_class_list(&class_list);
+ class_list.sort_custom<StringName::AlphCompare>();
+
+ while (class_list.size()) {
+ StringName class_name = class_list.front()->get();
+
+ ClassDB::APIType api_type = ClassDB::get_api_type(class_name);
+
+ if (api_type == ClassDB::API_NONE) {
+ class_list.pop_front();
+ continue;
+ }
+
+ if (!ClassDB::is_class_exposed(class_name)) {
+ OS::get_singleton()->print("Ignoring class '%s' because it's not exposed\n", String(class_name).utf8().get_data());
+ class_list.pop_front();
+ continue;
+ }
+
+ if (!ClassDB::is_class_enabled(class_name)) {
+ OS::get_singleton()->print("Ignoring class '%s' because it's not enabled\n", String(class_name).utf8().get_data());
+ class_list.pop_front();
+ continue;
+ }
+
+ ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name);
+
+ ExposedClass exposed_class;
+ exposed_class.name = class_name;
+ exposed_class.api_type = api_type;
+ exposed_class.is_singleton = Engine::get_singleton()->has_singleton(class_name);
+ exposed_class.is_instantiable = class_info->creation_func && !exposed_class.is_singleton;
+ exposed_class.is_reference = ClassDB::is_parent_class(class_name, "Reference");
+ exposed_class.base = ClassDB::get_parent_class(class_name);
+
+ // Add properties
+
+ List<PropertyInfo> property_list;
+ ClassDB::get_property_list(class_name, &property_list, true);
+
+ Map<StringName, StringName> accessor_methods;
+
+ for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
+ const PropertyInfo &property = E->get();
+
+ if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) {
+ continue;
+ }
+
+ PropertyData prop;
+ prop.name = property.name;
+ prop.setter = ClassDB::get_property_setter(class_name, prop.name);
+ prop.getter = ClassDB::get_property_getter(class_name, prop.name);
+
+ if (prop.setter != StringName()) {
+ accessor_methods[prop.setter] = prop.name;
+ }
+ if (prop.getter != StringName()) {
+ accessor_methods[prop.getter] = prop.name;
+ }
+
+ bool valid = false;
+ prop.index = ClassDB::get_property_index(class_name, prop.name, &valid);
+ TEST_FAIL_COND(!valid, "Invalid property: '" + exposed_class.name + "." + String(prop.name) + "'.");
+
+ exposed_class.properties.push_back(prop);
+ }
+
+ // Add methods
+
+ List<MethodInfo> virtual_method_list;
+ ClassDB::get_virtual_methods(class_name, &virtual_method_list, true);
+
+ List<MethodInfo> method_list;
+ ClassDB::get_method_list(class_name, &method_list, true);
+ method_list.sort();
+
+ for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
+ const MethodInfo &method_info = E->get();
+
+ int argc = method_info.arguments.size();
+
+ if (method_info.name.empty()) {
+ continue;
+ }
+
+ MethodData method;
+ method.name = method_info.name;
+
+ if (method_info.flags & METHOD_FLAG_VIRTUAL) {
+ method.is_virtual = true;
+ }
+
+ PropertyInfo return_info = method_info.return_val;
+
+ MethodBind *m = method.is_virtual ? nullptr : ClassDB::get_method(class_name, method_info.name);
+
+ method.is_vararg = m && m->is_vararg();
+
+ if (!m && !method.is_virtual) {
+ TEST_FAIL_COND(!virtual_method_list.find(method_info),
+ "Missing MethodBind for non-virtual method: '" + exposed_class.name + "." + method.name + "'.");
+
+ // A virtual method without the virtual flag. This is a special case.
+
+ // The method Object.free is registered as a virtual method, but without the virtual flag.
+ // This is because this method is not supposed to be overridden, but called.
+ // We assume the return type is void.
+ method.return_type.name = r_context.names_cache.void_type;
+
+ // Actually, more methods like this may be added in the future, which could return
+ // something different. Let's put this check to notify us if that ever happens.
+ if (exposed_class.name != r_context.names_cache.object_class || String(method.name) != "free") {
+ WARN_PRINT("Notification: New unexpected virtual non-overridable method found."
+ " We only expected Object.free, but found '" +
+ exposed_class.name + "." + method.name + "'.");
+ }
+ } else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ method.return_type.name = return_info.class_name;
+ method.return_type.is_enum = true;
+ } else if (return_info.class_name != StringName()) {
+ method.return_type.name = return_info.class_name;
+
+ bool bad_reference_hint = !method.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE &&
+ ClassDB::is_parent_class(return_info.class_name, r_context.names_cache.reference_class);
+ TEST_COND(bad_reference_hint, String() + "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." +
+ " Are you returning a reference type by pointer? Method: '" +
+ exposed_class.name + "." + method.name + "'.");
+ } else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ method.return_type.name = return_info.hint_string;
+ } else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
+ method.return_type.name = r_context.names_cache.variant_type;
+ } else if (return_info.type == Variant::NIL) {
+ method.return_type.name = r_context.names_cache.void_type;
+ } else {
+ // NOTE: We don't care about the size and sign of int and float in these tests
+ method.return_type.name = Variant::get_type_name(return_info.type);
+ }
+
+ for (int i = 0; i < argc; i++) {
+ PropertyInfo arg_info = method_info.arguments[i];
+
+ String orig_arg_name = arg_info.name;
+
+ ArgumentData arg;
+ arg.name = orig_arg_name;
+
+ if (arg_info.type == Variant::INT && arg_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ arg.type.name = arg_info.class_name;
+ arg.type.is_enum = true;
+ } else if (arg_info.class_name != StringName()) {
+ arg.type.name = arg_info.class_name;
+ } else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ arg.type.name = arg_info.hint_string;
+ } else if (arg_info.type == Variant::NIL) {
+ arg.type.name = r_context.names_cache.variant_type;
+ } else {
+ // NOTE: We don't care about the size and sign of int and float in these tests
+ arg.type.name = Variant::get_type_name(arg_info.type);
+ }
+
+ if (m && m->has_default_argument(i)) {
+ arg.has_defval = true;
+ arg.defval = m->get_default_argument(i);
+ }
+
+ method.arguments.push_back(arg);
+ }
+
+ if (method.is_vararg) {
+ ArgumentData vararg;
+ vararg.type.name = r_context.names_cache.vararg_stub_type;
+ vararg.name = "@varargs@";
+ method.arguments.push_back(vararg);
+ }
+
+ TEST_COND(exposed_class.find_property_by_name(method.name),
+ "Method name conflicts with property: '" + String(class_name) + "." + String(method.name) + "'.");
+
+ // Classes starting with an underscore are ignored unless they're used as a property setter or getter
+ if (!method.is_virtual && String(method.name)[0] == '_') {
+ for (const List<PropertyData>::Element *F = exposed_class.properties.front(); F; F = F->next()) {
+ const PropertyData &prop = F->get();
+
+ if (prop.setter == method.name || prop.getter == method.name) {
+ exposed_class.methods.push_back(method);
+ break;
+ }
+ }
+ } else {
+ exposed_class.methods.push_back(method);
+ }
+ }
+
+ // Add signals
+
+ const HashMap<StringName, MethodInfo> &signal_map = class_info->signal_map;
+ const StringName *k = nullptr;
+
+ while ((k = signal_map.next(k))) {
+ SignalData signal;
+
+ const MethodInfo &method_info = signal_map.get(*k);
+
+ signal.name = method_info.name;
+
+ int argc = method_info.arguments.size();
+
+ for (int i = 0; i < argc; i++) {
+ PropertyInfo arg_info = method_info.arguments[i];
+
+ String orig_arg_name = arg_info.name;
+
+ ArgumentData arg;
+ arg.name = orig_arg_name;
+
+ if (arg_info.type == Variant::INT && arg_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ arg.type.name = arg_info.class_name;
+ arg.type.is_enum = true;
+ } else if (arg_info.class_name != StringName()) {
+ arg.type.name = arg_info.class_name;
+ } else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ arg.type.name = arg_info.hint_string;
+ } else if (arg_info.type == Variant::NIL) {
+ arg.type.name = r_context.names_cache.variant_type;
+ } else {
+ // NOTE: We don't care about the size and sign of int and float in these tests
+ arg.type.name = Variant::get_type_name(arg_info.type);
+ }
+
+ signal.arguments.push_back(arg);
+ }
+
+ bool method_conflict = exposed_class.find_property_by_name(signal.name);
+
+ if (method_conflict || exposed_class.find_method_by_name(signal.name)) {
+ // TODO:
+ // ClassDB allows signal names that conflict with method or property names.
+ // However registering a signal with a conflicting name is still considered wrong.
+ // Unfortunately there are some existing cases that are yet to be fixed.
+ // Until those are fixed we will print a warning instead of failing the test.
+ WARN_PRINT("Signal name conflicts with " + String(method_conflict ? "method" : "property") +
+ ": '" + String(class_name) + "." + String(signal.name) + "'.");
+ }
+
+ exposed_class.signals_.push_back(signal);
+ }
+
+ // Add enums and constants
+
+ List<String> constants;
+ ClassDB::get_integer_constant_list(class_name, &constants, true);
+
+ const HashMap<StringName, List<StringName>> &enum_map = class_info->enum_map;
+ k = nullptr;
+
+ while ((k = enum_map.next(k))) {
+ EnumData enum_;
+ enum_.name = *k;
+
+ const List<StringName> &enum_constants = enum_map.get(*k);
+ for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) {
+ const StringName &constant_name = E->get();
+ int *value = class_info->constant_map.getptr(constant_name);
+ TEST_FAIL_COND(!value, "Missing enum constant value: '" +
+ String(class_name) + "." + String(enum_.name) + "." + String(constant_name) + "'.");
+ constants.erase(constant_name);
+
+ ConstantData constant;
+ constant.name = constant_name;
+ constant.value = *value;
+
+ enum_.constants.push_back(constant);
+ }
+
+ exposed_class.enums.push_back(enum_);
+
+ r_context.enum_types.push_back(String(class_name) + "." + String(*k));
+ }
+
+ for (const List<String>::Element *E = constants.front(); E; E = E->next()) {
+ const String &constant_name = E->get();
+ int *value = class_info->constant_map.getptr(StringName(E->get()));
+ TEST_FAIL_COND(!value, "Missing enum constant value: '" + String(class_name) + "." + String(constant_name) + "'.");
+
+ ConstantData constant;
+ constant.name = constant_name;
+ constant.value = *value;
+
+ exposed_class.constants.push_back(constant);
+ }
+
+ r_context.exposed_classes.insert(class_name, exposed_class);
+ class_list.pop_front();
+ }
+
+ TEST_END();
+}
+
+void add_builtin_types(Context &r_context) {
+ // NOTE: We don't care about the size and sign of int and float in these tests
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ r_context.builtin_types.push_back(Variant::get_type_name(Variant::Type(i)));
+ }
+
+ r_context.builtin_types.push_back(_STR(Variant));
+ r_context.builtin_types.push_back(r_context.names_cache.vararg_stub_type);
+ r_context.builtin_types.push_back("void");
+}
+
+void add_global_enums(Context &r_context) {
+ int global_constants_count = GlobalConstants::get_global_constant_count();
+
+ if (global_constants_count > 0) {
+ for (int i = 0; i < global_constants_count; i++) {
+ StringName enum_name = GlobalConstants::get_global_constant_enum(i);
+
+ if (enum_name != StringName()) {
+ ConstantData constant;
+ constant.name = GlobalConstants::get_global_constant_name(i);
+ constant.value = GlobalConstants::get_global_constant_value(i);
+
+ EnumData enum_;
+ enum_.name = enum_name;
+ List<EnumData>::Element *enum_match = r_context.global_enums.find(enum_);
+ if (enum_match) {
+ enum_match->get().constants.push_back(constant);
+ } else {
+ enum_.constants.push_back(constant);
+ r_context.global_enums.push_back(enum_);
+ }
+ }
+ }
+
+ for (List<EnumData>::Element *E = r_context.global_enums.front(); E; E = E->next()) {
+ r_context.enum_types.push_back(E->get().name);
+ }
+ }
+
+ // HARDCODED
+ List<StringName> hardcoded_enums;
+ hardcoded_enums.push_back("Vector2.Axis");
+ hardcoded_enums.push_back("Vector2i.Axis");
+ hardcoded_enums.push_back("Vector3.Axis");
+ hardcoded_enums.push_back("Vector3i.Axis");
+ for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) {
+ // These enums are not generated and must be written manually (e.g.: Vector3.Axis)
+ // Here, we assume core types do not begin with underscore
+ r_context.enum_types.push_back(E->get());
+ }
+}
+
+TestResult run_class_db_tests() {
+ TEST_START();
+
+ Context context;
+
+ TEST_FAIL_CHECK(add_exposed_classes(context));
+ add_builtin_types(context);
+ add_global_enums(context);
+
+ const ExposedClass *object_class = context.find_exposed_class(context.names_cache.object_class);
+ TEST_FAIL_COND(!object_class, "Object class not found.");
+ TEST_FAIL_COND(object_class->base != StringName(),
+ "Object class derives from another class: '" + object_class->base + "'.");
+
+ for (ExposedClasses::Element E = context.exposed_classes.front(); E; E = E.next()) {
+ TEST_CHECK(validate_class(context, E.value()));
+ }
+
+ TEST_END();
+}
+
+MainLoop *test() {
+ TestResult pass = run_class_db_tests();
+
+ OS::get_singleton()->print("ClassDB tests: %s\n", pass == TestResult::PASS ? "PASS" : "FAILED");
+
+ if (pass == TestResult::FAILED) {
+ OS::get_singleton()->set_exit_code(pass == TestResult::PASS ? 0 : 1);
+ }
+
+ return nullptr;
+}
+
+} // namespace TestClassDB
diff --git a/core/math/audio_frame.cpp b/main/tests/test_class_db.h
index c565ea9b13..1a31cfb01b 100644
--- a/core/math/audio_frame.cpp
+++ b/main/tests/test_class_db.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* audio_frame.cpp */
+/* test_class_db.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,4 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "audio_frame.h"
+#ifndef GODOT_TEST_CLASS_DB_H
+#define GODOT_TEST_CLASS_DB_H
+
+#include "core/os/main_loop.h"
+
+namespace TestClassDB {
+
+MainLoop *test();
+
+}
+
+#endif //GODOT_TEST_CLASS_DB_H
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index 971460c655..10586c6495 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -45,7 +45,6 @@
namespace TestGDScript {
static void _print_indent(int p_ident, const String &p_text) {
-
String txt;
for (int i = 0; i < p_ident; i++) {
txt += '\t';
@@ -55,18 +54,18 @@ static void _print_indent(int p_ident, const String &p_text) {
}
static String _parser_extends(const GDScriptParser::ClassNode *p_class) {
-
String txt = "extends ";
if (String(p_class->extends_file) != "") {
txt += "\"" + p_class->extends_file + "\"";
- if (p_class->extends_class.size())
+ if (p_class->extends_class.size()) {
txt += ".";
+ }
}
for (int i = 0; i < p_class->extends_class.size(); i++) {
-
- if (i != 0)
+ if (i != 0) {
txt += ".";
+ }
txt += p_class->extends_class[i];
}
@@ -75,21 +74,19 @@ static String _parser_extends(const GDScriptParser::ClassNode *p_class) {
}
static String _parser_expr(const GDScriptParser::Node *p_expr) {
-
String txt;
switch (p_expr->type) {
-
case GDScriptParser::Node::TYPE_IDENTIFIER: {
-
const GDScriptParser::IdentifierNode *id_node = static_cast<const GDScriptParser::IdentifierNode *>(p_expr);
txt = id_node->name;
} break;
case GDScriptParser::Node::TYPE_CONSTANT: {
const GDScriptParser::ConstantNode *c_node = static_cast<const GDScriptParser::ConstantNode *>(p_expr);
- if (c_node->value.get_type() == Variant::STRING)
+ if (c_node->value.get_type() == Variant::STRING) {
txt = "\"" + String(c_node->value) + "\"";
- else
+ } else {
txt = c_node->value;
+ }
} break;
case GDScriptParser::Node::TYPE_SELF: {
@@ -99,9 +96,9 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
const GDScriptParser::ArrayNode *arr_node = static_cast<const GDScriptParser::ArrayNode *>(p_expr);
txt += "[";
for (int i = 0; i < arr_node->elements.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += _parser_expr(arr_node->elements[i]);
}
txt += "]";
@@ -110,9 +107,9 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(p_expr);
txt += "{";
for (int i = 0; i < dict_node->elements.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
const GDScriptParser::DictionaryNode::Pair &p = dict_node->elements[i];
txt += _parser_expr(p.key);
@@ -122,37 +119,32 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
txt += "}";
} break;
case GDScriptParser::Node::TYPE_OPERATOR: {
-
const GDScriptParser::OperatorNode *c_node = static_cast<const GDScriptParser::OperatorNode *>(p_expr);
switch (c_node->op) {
-
case GDScriptParser::OperatorNode::OP_PARENT_CALL:
txt += ".";
[[fallthrough]];
case GDScriptParser::OperatorNode::OP_CALL: {
-
ERR_FAIL_COND_V(c_node->arguments.size() < 1, "");
String func_name;
const GDScriptParser::Node *nfunc = c_node->arguments[0];
int arg_ofs = 0;
if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
-
const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast<const GDScriptParser::BuiltInFunctionNode *>(nfunc);
func_name = GDScriptFunctions::get_func_name(bif_node->function);
arg_ofs = 1;
} else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) {
-
const GDScriptParser::TypeNode *t_node = static_cast<const GDScriptParser::TypeNode *>(nfunc);
func_name = Variant::get_type_name(t_node->vtype);
arg_ofs = 1;
} else {
-
ERR_FAIL_COND_V(c_node->arguments.size() < 2, "");
nfunc = c_node->arguments[1];
ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, "");
- if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF)
+ if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF) {
func_name = _parser_expr(c_node->arguments[0]) + ".";
+ }
func_name += _parser_expr(nfunc);
arg_ofs = 2;
@@ -161,10 +153,10 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
txt += func_name + "(";
for (int i = arg_ofs; i < c_node->arguments.size(); i++) {
-
const GDScriptParser::Node *arg = c_node->arguments[i];
- if (i > arg_ofs)
+ if (i > arg_ofs) {
txt += ", ";
+ }
txt += _parser_expr(arg);
}
@@ -172,7 +164,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
} break;
case GDScriptParser::OperatorNode::OP_INDEX: {
-
ERR_FAIL_COND_V(c_node->arguments.size() != 2, "");
//index with []
@@ -180,7 +171,6 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
} break;
case GDScriptParser::OperatorNode::OP_INDEX_NAMED: {
-
ERR_FAIL_COND_V(c_node->arguments.size() != 2, "");
txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]);
@@ -296,11 +286,9 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
} break;
case GDScriptParser::Node::TYPE_NEWLINE: {
-
//skippie
} break;
default: {
-
ERR_FAIL_V_MSG("", "Parser bug at " + itos(p_expr->line) + ", invalid expression type: " + itos(p_expr->type));
}
}
@@ -309,20 +297,14 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) {
}
static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) {
-
for (int i = 0; i < p_block->statements.size(); i++) {
-
const GDScriptParser::Node *statement = p_block->statements[i];
switch (statement->type) {
-
case GDScriptParser::Node::TYPE_CONTROL_FLOW: {
-
const GDScriptParser::ControlFlowNode *cf_node = static_cast<const GDScriptParser::ControlFlowNode *>(statement);
switch (cf_node->cf_type) {
-
case GDScriptParser::ControlFlowNode::CF_IF: {
-
ERR_FAIL_COND(cf_node->arguments.size() != 1);
String txt;
txt += "if ";
@@ -351,7 +333,6 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i
} break;
case GDScriptParser::ControlFlowNode::CF_WHILE: {
-
ERR_FAIL_COND(cf_node->arguments.size() != 1);
String txt;
txt += "while ";
@@ -366,25 +347,22 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i
// FIXME: Implement
} break;
case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
-
_print_indent(p_indent, "continue");
} break;
case GDScriptParser::ControlFlowNode::CF_BREAK: {
-
_print_indent(p_indent, "break");
} break;
case GDScriptParser::ControlFlowNode::CF_RETURN: {
-
- if (cf_node->arguments.size())
+ if (cf_node->arguments.size()) {
_print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0]));
- else
+ } else {
_print_indent(p_indent, "return ");
+ }
} break;
}
} break;
case GDScriptParser::Node::TYPE_LOCAL_VAR: {
-
const GDScriptParser::LocalVarNode *lv_node = static_cast<const GDScriptParser::LocalVarNode *>(statement);
_print_indent(p_indent, "var " + String(lv_node->name));
} break;
@@ -397,21 +375,22 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i
}
static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = nullptr) {
-
String txt;
- if (p_func->_static)
+ if (p_func->_static) {
txt = "static ";
+ }
txt += "func ";
- if (p_func->name == "") // initializer
+ if (p_func->name == "") { // initializer
txt += "[built-in-initializer]";
- else
+ } else {
txt += String(p_func->name);
+ }
txt += "(";
for (int i = 0; i < p_func->arguments.size(); i++) {
-
- if (i != 0)
+ if (i != 0) {
txt += ", ";
+ }
txt += "var " + String(p_func->arguments[i]);
if (i >= (p_func->arguments.size() - p_func->default_values.size())) {
int defarg = i - (p_func->arguments.size() - p_func->default_values.size());
@@ -427,25 +406,24 @@ static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, in
txt += ":";
_print_indent(p_indent, txt);
- if (p_initializer)
+ if (p_initializer) {
_parser_show_block(p_initializer, p_indent + 1);
+ }
_parser_show_block(p_func->body, p_indent + 1);
}
static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) {
-
if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) {
-
_print_indent(p_indent, _parser_extends(p_class));
print_line("\n");
}
for (int i = 0; i < p_class->subclasses.size(); i++) {
-
const GDScriptParser::ClassNode *subclass = p_class->subclasses[i];
String line = "class " + subclass->name;
- if (String(subclass->extends_file) != "" || subclass->extends_class.size())
+ if (String(subclass->extends_file) != "" || subclass->extends_class.size()) {
line += " " + _parser_extends(subclass);
+ }
line += ":";
_print_indent(p_indent, line);
_parser_show_class(subclass, p_indent + 1, p_code);
@@ -458,7 +436,6 @@ static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_i
}
for (int i = 0; i < p_class->variables.size(); i++) {
-
const GDScriptParser::ClassNode::Member &m = p_class->variables[i];
_print_indent(p_indent, "var " + String(m.identifier));
@@ -467,17 +444,16 @@ static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_i
print_line("\n");
for (int i = 0; i < p_class->static_functions.size(); i++) {
-
_parser_show_function(p_class->static_functions[i], p_indent);
print_line("\n");
}
for (int i = 0; i < p_class->functions.size(); i++) {
-
if (String(p_class->functions[i]->name) == "_init") {
_parser_show_function(p_class->functions[i], p_indent, p_class->initializer);
- } else
+ } else {
_parser_show_function(p_class->functions[i], p_indent);
+ }
print_line("\n");
}
//_parser_show_function(p_class->initializer,p_indent);
@@ -485,11 +461,9 @@ static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_i
}
static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFunction &func, int p_addr) {
-
int addr = p_addr & GDScriptFunction::ADDR_MASK;
switch (p_addr >> GDScriptFunction::ADDR_BITS) {
-
case GDScriptFunction::ADDR_TYPE_SELF: {
return "self";
} break;
@@ -497,33 +471,28 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFun
return "class";
} break;
case GDScriptFunction::ADDR_TYPE_MEMBER: {
-
return "member(" + p_script->debug_get_member_by_index(addr) + ")";
} break;
case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: {
-
return "class_const(" + func.get_global_name(addr) + ")";
} break;
case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: {
-
Variant v = func.get_constant(addr);
String txt;
- if (v.get_type() == Variant::STRING || v.get_type() == Variant::NODE_PATH)
+ if (v.get_type() == Variant::STRING || v.get_type() == Variant::NODE_PATH) {
txt = "\"" + String(v) + "\"";
- else
+ } else {
txt = v;
+ }
return "const(" + txt + ")";
} break;
case GDScriptFunction::ADDR_TYPE_STACK: {
-
return "stack(" + itos(addr) + ")";
} break;
case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: {
-
return "var_stack(" + itos(addr) + ")";
} break;
case GDScriptFunction::ADDR_TYPE_GLOBAL: {
-
return "global(" + func.get_global_name(addr) + ")";
} break;
case GDScriptFunction::ADDR_TYPE_NIL: {
@@ -535,11 +504,9 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFun
}
static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String> &p_code) {
-
const Map<StringName, GDScriptFunction *> &mf = p_class->debug_get_member_functions();
for (const Map<StringName, GDScriptFunction *>::Element *E = mf.front(); E; E = E->next()) {
-
const GDScriptFunction &func = *E->get();
const int *code = func.get_code();
int codelen = func.get_code_size();
@@ -547,9 +514,9 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
if (func.get_default_argument_count()) {
defargs = "defarg at: ";
for (int i = 0; i < func.get_default_argument_count(); i++) {
-
- if (i > 0)
+ if (i > 0) {
defargs += ",";
+ }
defargs += itos(func.get_default_argument_addr(i));
}
defargs += " ";
@@ -559,14 +526,11 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
#define DADDR(m_ip) (_disassemble_addr(p_class, func, code[ip + m_ip]))
for (int ip = 0; ip < codelen;) {
-
int incr = 0;
String txt = itos(ip) + " ";
switch (code[ip]) {
-
case GDScriptFunction::OPCODE_OPERATOR: {
-
int op = code[ip + 1];
txt += " op ";
@@ -581,7 +545,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_SET: {
-
txt += "set ";
txt += DADDR(1);
txt += "[";
@@ -592,7 +555,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_GET: {
-
txt += " get ";
txt += DADDR(3);
txt += "=";
@@ -604,7 +566,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_SET_NAMED: {
-
txt += " set_named ";
txt += DADDR(1);
txt += "[\"";
@@ -615,7 +576,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_GET_NAMED: {
-
txt += " get_named ";
txt += DADDR(3);
txt += "=";
@@ -627,7 +587,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_SET_MEMBER: {
-
txt += " set_member ";
txt += "[\"";
txt += func.get_global_name(code[ip + 1]);
@@ -637,7 +596,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_GET_MEMBER: {
-
txt += " get_member ";
txt += DADDR(2);
txt += "=";
@@ -648,7 +606,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_ASSIGN: {
-
txt += " assign ";
txt += DADDR(1);
txt += "=";
@@ -657,7 +614,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_ASSIGN_TRUE: {
-
txt += " assign ";
txt += DADDR(1);
txt += "= true";
@@ -665,7 +621,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_ASSIGN_FALSE: {
-
txt += " assign ";
txt += DADDR(1);
txt += "= false";
@@ -673,7 +628,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_ASSIGN_TYPED_BUILTIN: {
-
txt += " assign typed builtin (";
txt += Variant::get_type_name((Variant::Type)code[ip + 1]);
txt += ") ";
@@ -697,7 +651,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_CAST_TO_SCRIPT: {
-
txt += " cast ";
txt += DADDR(3);
txt += "=";
@@ -708,7 +661,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_CONSTRUCT: {
-
Variant::Type t = Variant::Type(code[ip + 1]);
int argc = code[ip + 2];
@@ -718,9 +670,9 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt += Variant::get_type_name(t) + "(";
for (int i = 0; i < argc; i++) {
-
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += DADDR(i + 3);
}
txt += ")";
@@ -729,15 +681,15 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_CONSTRUCT_ARRAY: {
-
int argc = code[ip + 1];
txt += " make_array ";
txt += DADDR(2 + argc);
txt += " = [ ";
for (int i = 0; i < argc; i++) {
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += DADDR(2 + i);
}
@@ -747,15 +699,15 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY: {
-
int argc = code[ip + 1];
txt += " make_dict ";
txt += DADDR(2 + argc * 2);
txt += " = { ";
for (int i = 0; i < argc; i++) {
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += DADDR(2 + i * 2 + 0);
txt += ":";
txt += DADDR(2 + i * 2 + 1);
@@ -769,13 +721,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
case GDScriptFunction::OPCODE_CALL:
case GDScriptFunction::OPCODE_CALL_RETURN: {
-
bool ret = code[ip] == GDScriptFunction::OPCODE_CALL_RETURN;
- if (ret)
+ if (ret) {
txt += " call-ret ";
- else
+ } else {
txt += " call ";
+ }
int argc = code[ip + 1];
if (ret) {
@@ -787,8 +739,9 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt += "(";
for (int i = 0; i < argc; i++) {
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += DADDR(4 + i);
}
txt += ")";
@@ -797,7 +750,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_CALL_BUILT_IN: {
-
txt += " call-built-in ";
int argc = code[ip + 2];
@@ -807,8 +759,9 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt += "(";
for (int i = 0; i < argc; i++) {
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += DADDR(3 + i);
}
txt += ")";
@@ -817,7 +770,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_CALL_SELF_BASE: {
-
txt += " call-self-base ";
int argc = code[ip + 2];
@@ -827,8 +779,9 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt += "(";
for (int i = 0; i < argc; i++) {
- if (i > 0)
+ if (i > 0) {
txt += ", ";
+ }
txt += DADDR(3 + i);
}
txt += ")";
@@ -837,13 +790,11 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_YIELD: {
-
txt += " yield ";
incr = 1;
} break;
case GDScriptFunction::OPCODE_YIELD_SIGNAL: {
-
txt += " yield_signal ";
txt += DADDR(1);
txt += ",";
@@ -851,13 +802,11 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
case GDScriptFunction::OPCODE_YIELD_RESUME: {
-
txt += " yield resume: ";
txt += DADDR(1);
incr = 2;
} break;
case GDScriptFunction::OPCODE_JUMP: {
-
txt += " jump ";
txt += itos(code[ip + 1]);
@@ -865,7 +814,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_JUMP_IF: {
-
txt += " jump-if ";
txt += DADDR(1);
txt += " to ";
@@ -874,7 +822,6 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
case GDScriptFunction::OPCODE_JUMP_IF_NOT: {
-
txt += " jump-if-not ";
txt += DADDR(1);
txt += " to ";
@@ -883,12 +830,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
case GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: {
-
txt += " jump-to-default-argument ";
incr = 1;
} break;
case GDScriptFunction::OPCODE_RETURN: {
-
txt += " return ";
txt += DADDR(1);
@@ -896,33 +841,29 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
case GDScriptFunction::OPCODE_ITERATE_BEGIN: {
-
txt += " for-init " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]);
incr += 5;
} break;
case GDScriptFunction::OPCODE_ITERATE: {
-
txt += " for-loop " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]);
incr += 5;
} break;
case GDScriptFunction::OPCODE_LINE: {
-
int line = code[ip + 1] - 1;
- if (line >= 0 && line < p_code.size())
+ if (line >= 0 && line < p_code.size()) {
txt = "\n" + itos(line + 1) + ": " + p_code[line] + "\n";
- else
+ } else {
txt = "";
+ }
incr += 2;
} break;
case GDScriptFunction::OPCODE_END: {
-
txt += " end";
incr += 1;
} break;
case GDScriptFunction::OPCODE_ASSERT: {
-
txt += " assert ";
txt += DADDR(1);
incr += 2;
@@ -931,19 +872,18 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
}
if (incr == 0) {
-
ERR_BREAK_MSG(true, "Unhandled opcode: " + itos(code[ip]));
}
ip += incr;
- if (txt != "")
+ if (txt != "") {
print_line(txt);
+ }
}
}
}
MainLoop *test(TestType p_type) {
-
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
if (cmdlargs.empty()) {
@@ -972,40 +912,38 @@ MainLoop *test(TestType p_type) {
int last = 0;
for (int i = 0; i <= code.length(); i++) {
-
if (code[i] == '\n' || code[i] == 0) {
-
lines.push_back(code.substr(last, i - last));
last = i + 1;
}
}
if (p_type == TEST_TOKENIZER) {
-
GDScriptTokenizerText tk;
tk.set_code(code);
int line = -1;
while (tk.get_token() != GDScriptTokenizer::TK_EOF) {
-
String text;
- if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER)
+ if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER) {
text = "'" + tk.get_token_identifier() + "' (identifier)";
- else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) {
+ } else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) {
const Variant &c = tk.get_token_constant();
- if (c.get_type() == Variant::STRING)
+ if (c.get_type() == Variant::STRING) {
text = "\"" + String(c) + "\"";
- else
+ } else {
text = c;
+ }
text = text + " (" + Variant::get_type_name(c.get_type()) + " constant)";
- } else if (tk.get_token() == GDScriptTokenizer::TK_ERROR)
+ } else if (tk.get_token() == GDScriptTokenizer::TK_ERROR) {
text = "ERROR: " + tk.get_token_error();
- else if (tk.get_token() == GDScriptTokenizer::TK_NEWLINE)
+ } else if (tk.get_token() == GDScriptTokenizer::TK_NEWLINE) {
text = "newline (" + itos(tk.get_token_line()) + ") + indent: " + itos(tk.get_token_line_indent());
- else if (tk.get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC)
+ } else if (tk.get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
text = "'" + String(GDScriptFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)";
- else
+ } else {
text = tk.get_token_name(tk.get_token());
+ }
if (tk.get_token_line() != line) {
int from = line + 1;
@@ -1024,7 +962,6 @@ MainLoop *test(TestType p_type) {
}
if (p_type == TEST_PARSER) {
-
GDScriptParser parser;
Error err = parser.parse(code);
if (err) {
@@ -1041,7 +978,6 @@ MainLoop *test(TestType p_type) {
}
if (p_type == TEST_COMPILER) {
-
GDScriptParser parser;
Error err = parser.parse(code);
@@ -1057,7 +993,6 @@ MainLoop *test(TestType p_type) {
GDScriptCompiler gdc;
err = gdc.compile(&parser, gds.ptr());
if (err) {
-
print_line("Compile Error:\n" + itos(gdc.get_error_line()) + ":" + itos(gdc.get_error_column()) + ":" + gdc.get_error());
return nullptr;
}
@@ -1065,7 +1000,6 @@ MainLoop *test(TestType p_type) {
Ref<GDScript> current = gds;
while (current.is_valid()) {
-
print_line("** CLASS **");
_disassemble_class(current, lines);
@@ -1073,7 +1007,6 @@ MainLoop *test(TestType p_type) {
}
} else if (p_type == TEST_BYTECODE) {
-
Vector<uint8_t> buf2 = GDScriptTokenizerBuffer::parse_code_string(code);
String dst = test.get_basename() + ".gdc";
FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE);
@@ -1085,6 +1018,7 @@ MainLoop *test(TestType p_type) {
return nullptr;
}
+
} // namespace TestGDScript
#else
@@ -1095,6 +1029,7 @@ MainLoop *test(TestType p_type) {
ERR_PRINT("The GDScript module is disabled, therefore GDScript tests cannot be used.");
return nullptr;
}
+
} // namespace TestGDScript
#endif
diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp
index c5c8917a51..d46a13d2c0 100644
--- a/main/tests/test_gui.cpp
+++ b/main/tests/test_gui.cpp
@@ -59,14 +59,11 @@
namespace TestGUI {
class TestMainLoop : public SceneTree {
-
public:
virtual void request_quit() {
-
quit();
}
virtual void init() {
-
SceneTree::init();
Panel *frame = memnew(Panel);
@@ -266,9 +263,9 @@ public:
};
MainLoop *test() {
-
return memnew(TestMainLoop);
}
+
} // namespace TestGUI
#endif
diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp
index 922a55b88e..5ebdaf1741 100644
--- a/main/tests/test_main.cpp
+++ b/main/tests/test_main.cpp
@@ -35,6 +35,8 @@
#ifdef DEBUG_ENABLED
#include "test_astar.h"
+#include "test_basis.h"
+#include "test_class_db.h"
#include "test_gdscript.h"
#include "test_gui.h"
#include "test_math.h"
@@ -47,14 +49,15 @@
#include "test_string.h"
const char **tests_get_names() {
-
static const char *test_names[] = {
"string",
"math",
+ "basis",
"physics_2d",
"physics_3d",
"render",
"oa_hash_map",
+ "class_db",
"gui",
"shaderlang",
"gd_tokenizer",
@@ -70,76 +73,69 @@ const char **tests_get_names() {
}
MainLoop *test_main(String p_test, const List<String> &p_args) {
-
if (p_test == "string") {
-
return TestString::test();
}
if (p_test == "math") {
-
return TestMath::test();
}
- if (p_test == "physics_2d") {
+ if (p_test == "basis") {
+ return TestBasis::test();
+ }
+ if (p_test == "physics_2d") {
return TestPhysics2D::test();
}
if (p_test == "physics_3d") {
-
return TestPhysics3D::test();
}
if (p_test == "render") {
-
return TestRender::test();
}
if (p_test == "oa_hash_map") {
-
return TestOAHashMap::test();
}
+ if (p_test == "class_db") {
+ return TestClassDB::test();
+ }
+
#ifndef _3D_DISABLED
if (p_test == "gui") {
-
return TestGUI::test();
}
#endif
if (p_test == "shaderlang") {
-
return TestShaderLang::test();
}
if (p_test == "gd_tokenizer") {
-
return TestGDScript::test(TestGDScript::TEST_TOKENIZER);
}
if (p_test == "gd_parser") {
-
return TestGDScript::test(TestGDScript::TEST_PARSER);
}
if (p_test == "gd_compiler") {
-
return TestGDScript::test(TestGDScript::TEST_COMPILER);
}
if (p_test == "gd_bytecode") {
-
return TestGDScript::test(TestGDScript::TEST_BYTECODE);
}
if (p_test == "ordered_hash_map") {
-
return TestOrderedHashMap::test();
}
if (p_test == "astar") {
-
return TestAStar::test();
}
@@ -150,7 +146,6 @@ MainLoop *test_main(String p_test, const List<String> &p_args) {
#else
const char **tests_get_names() {
-
static const char *test_names[] = {
nullptr
};
@@ -159,7 +154,6 @@ const char **tests_get_names() {
}
MainLoop *test_main(String p_test, const List<String> &p_args) {
-
return nullptr;
}
diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp
index fbd1aa275a..5f84bad4e9 100644
--- a/main/tests/test_math.cpp
+++ b/main/tests/test_math.cpp
@@ -33,6 +33,7 @@
#include "core/math/basis.h"
#include "core/math/camera_matrix.h"
#include "core/math/delaunay_3d.h"
+#include "core/math/geometry_2d.h"
#include "core/math/math_funcs.h"
#include "core/math/transform.h"
#include "core/method_ptrcall.h"
@@ -50,7 +51,6 @@
namespace TestMath {
class GetClassAndNamespace {
-
String code;
int idx;
int line;
@@ -77,12 +77,9 @@ class GetClassAndNamespace {
};
Token get_token() {
-
while (true) {
switch (code[idx]) {
-
case '\n': {
-
line++;
idx++;
break;
@@ -92,37 +89,30 @@ class GetClassAndNamespace {
} break;
case '{': {
-
idx++;
return TK_CURLY_BRACKET_OPEN;
};
case '}': {
-
idx++;
return TK_CURLY_BRACKET_CLOSE;
};
case '[': {
-
idx++;
return TK_BRACKET_OPEN;
};
case ']': {
-
idx++;
return TK_BRACKET_CLOSE;
};
case ':': {
-
idx++;
return TK_COLON;
};
case ',': {
-
idx++;
return TK_COMMA;
};
case '.': {
-
idx++;
return TK_PERIOD;
};
@@ -134,7 +124,6 @@ class GetClassAndNamespace {
continue;
} break;
case '/': {
-
switch (code[idx + 1]) {
case '*': { // block comment
@@ -145,7 +134,6 @@ class GetClassAndNamespace {
error = true;
return TK_ERROR;
} else if (code[idx] == '*' && code[idx + 1] == '/') {
-
idx += 2;
break;
} else if (code[idx] == '\n') {
@@ -174,7 +162,6 @@ class GetClassAndNamespace {
} break;
case '\'':
case '"': {
-
CharType begin_str = code[idx];
idx++;
String tk_string = String();
@@ -198,7 +185,6 @@ class GetClassAndNamespace {
CharType res = 0;
switch (next) {
-
case 'b':
res = 8;
break;
@@ -228,8 +214,9 @@ class GetClassAndNamespace {
tk_string += res;
} else {
- if (code[idx] == '\n')
+ if (code[idx] == '\n') {
line++;
+ }
tk_string += code[idx];
}
idx++;
@@ -241,7 +228,6 @@ class GetClassAndNamespace {
} break;
default: {
-
if (code[idx] <= 32) {
idx++;
break;
@@ -262,11 +248,9 @@ class GetClassAndNamespace {
return TK_NUMBER;
} else if ((code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) {
-
String id;
while ((code[idx] >= 'A' && code[idx] <= 'Z') || (code[idx] >= 'a' && code[idx] <= 'z') || code[idx] > 127) {
-
id += code[idx];
idx++;
}
@@ -285,7 +269,6 @@ class GetClassAndNamespace {
public:
Error parse(const String &p_code, const String &p_known_class_name = String()) {
-
code = p_code;
idx = 0;
line = 0;
@@ -301,7 +284,6 @@ public:
int curly_stack = 0;
while (!error || tk != TK_EOF) {
-
if (tk == TK_BRACKET_OPEN) {
tk = get_token();
if (tk == TK_IDENTIFIER && String(value) == "ScriptClass") {
@@ -358,8 +340,9 @@ public:
tk = get_token();
}
- if (error)
+ if (error) {
return ERR_PARSE_ERROR;
+ }
return OK;
}
@@ -374,7 +357,6 @@ public:
};
void test_vec(Plane p_vec) {
-
CameraMatrix cm;
cm.set_perspective(45, 1, 0, 100);
Plane v0 = cm.xform4(p_vec);
@@ -413,7 +395,6 @@ uint32_t ihash3(uint32_t a) {
}
MainLoop *test() {
-
{
Vector<Vector3> points;
points.push_back(Vector3(0, 0, 0));
@@ -502,7 +483,7 @@ MainLoop *test() {
float gb = (rgbe >> 9) & 0x1ff;
float bb = (rgbe >> 18) & 0x1ff;
float eb = (rgbe >> 27);
- float mb = Math::pow(2, eb - 15.0 - 9.0);
+ float mb = Math::pow(2.0, eb - 15.0 - 9.0);
float rd = rb * mb;
float gd = gb * mb;
float bd = bb * mb;
@@ -564,26 +545,22 @@ MainLoop *test() {
}
{
-
Vector<int> hashes;
List<StringName> tl;
ClassDB::get_class_list(&tl);
for (List<StringName>::Element *E = tl.front(); E; E = E->next()) {
-
Vector<uint8_t> m5b = E->get().operator String().md5_buffer();
hashes.push_back(hashes.size());
}
for (int i = nearest_shift(hashes.size()); i < 20; i++) {
-
bool success = true;
for (int s = 0; s < 10000; s++) {
Set<uint32_t> existing;
success = true;
for (int j = 0; j < hashes.size(); j++) {
-
uint32_t eh = ihash2(ihash3(hashes[j] + ihash(s) + s)) & ((1 << i) - 1);
if (existing.has(eh)) {
success = false;
@@ -597,8 +574,9 @@ MainLoop *test() {
break;
}
}
- if (success)
+ if (success) {
break;
+ }
}
print_line("DONE");
@@ -658,7 +636,7 @@ MainLoop *test() {
b["44"] = 4;
}
- print_line("inters: " + rtos(Geometry::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0)));
+ print_line("inters: " + rtos(Geometry2D::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0)));
print_line("cross: " + Vector3(1, 2, 3).cross(Vector3(4, 5, 7)));
print_line("dot: " + rtos(Vector3(1, 2, 3).dot(Vector3(4, 5, 7))));
@@ -721,4 +699,5 @@ MainLoop *test() {
return nullptr;
}
+
} // namespace TestMath
diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp
index cffec7fa77..9182f66b61 100644
--- a/main/tests/test_oa_hash_map.cpp
+++ b/main/tests/test_oa_hash_map.cpp
@@ -35,8 +35,38 @@
namespace TestOAHashMap {
-MainLoop *test() {
+struct CountedItem {
+ static int count;
+
+ int id = -1;
+ bool destroyed = false;
+
+ CountedItem() {
+ count++;
+ }
+
+ CountedItem(int p_id) :
+ id(p_id) {
+ count++;
+ }
+
+ CountedItem(const CountedItem &p_other) :
+ id(p_other.id) {
+ count++;
+ }
+
+ CountedItem &operator=(const CountedItem &p_other) = default;
+
+ ~CountedItem() {
+ CRASH_COND(destroyed);
+ count--;
+ destroyed = true;
+ }
+};
+
+int CountedItem::count;
+MainLoop *test() {
OS::get_singleton()->print("\n\n\nHello from test\n");
// test element tracking.
@@ -71,8 +101,9 @@ MainLoop *test() {
uint32_t num_elems = 0;
for (int i = 0; i < 500; i++) {
int tmp;
- if (map.lookup(i, tmp) && tmp == i * 2)
+ if (map.lookup(i, tmp) && tmp == i * 2) {
num_elems++;
+ }
}
OS::get_singleton()->print("elements %d == %d.\n", map.get_num_elements(), num_elems);
@@ -105,8 +136,9 @@ MainLoop *test() {
keys[i] = Math::rand();
map.set(keys[i], dummy);
- if (!map.lookup(keys[i], dummy))
+ if (!map.lookup(keys[i], dummy)) {
OS::get_singleton()->print("could not find 0x%X despite it was just inserted!\n", unsigned(keys[i]));
+ }
}
// check whether the keys are still present
@@ -122,7 +154,6 @@ MainLoop *test() {
// regression test / test for issue related to #31402
{
-
OS::get_singleton()->print("test for issue #31402 started...\n");
const int num_test_values = 12;
@@ -152,6 +183,117 @@ MainLoop *test() {
map.set(5, 1);
}
+ // test memory management of items, should not crash or leak items
+ {
+ // Exercise different patterns of removal
+ for (int i = 0; i < 4; ++i) {
+ {
+ OAHashMap<String, CountedItem> map;
+ int id = 0;
+ for (int j = 0; j < 100; ++j) {
+ map.insert(itos(j), CountedItem(id));
+ }
+ if (i <= 1) {
+ for (int j = 0; j < 100; ++j) {
+ map.remove(itos(j));
+ }
+ }
+ if (i % 2 == 0) {
+ map.clear();
+ }
+ }
+
+ if (CountedItem::count != 0) {
+ OS::get_singleton()->print("%d != 0 (not performing the other test sub-cases, breaking...)\n", CountedItem::count);
+ break;
+ }
+ }
+ }
+
+ // Test map with 0 capacity.
+ {
+ OAHashMap<int, String> original_map(0);
+ original_map.set(1, "1");
+ OS::get_singleton()->print("OAHashMap 0 capacity initialization passed.\n");
+ }
+
+ // Test copy constructor.
+ {
+ OAHashMap<int, String> original_map;
+ original_map.set(1, "1");
+ original_map.set(2, "2");
+ original_map.set(3, "3");
+ original_map.set(4, "4");
+ original_map.set(5, "5");
+
+ OAHashMap<int, String> map_copy(original_map);
+
+ bool pass = true;
+ for (
+ OAHashMap<int, String>::Iterator it = original_map.iter();
+ it.valid;
+ it = original_map.next_iter(it)) {
+ if (map_copy.lookup_ptr(*it.key) == nullptr) {
+ pass = false;
+ }
+ if (*it.value != *map_copy.lookup_ptr(*it.key)) {
+ pass = false;
+ }
+ }
+ if (pass) {
+ OS::get_singleton()->print("OAHashMap copy constructor test passed.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap copy constructor test FAILED.\n");
+ }
+
+ map_copy.set(1, "Random String");
+ if (*map_copy.lookup_ptr(1) == *original_map.lookup_ptr(1)) {
+ OS::get_singleton()->print("OAHashMap copy constructor, atomic copy test FAILED.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap copy constructor, atomic copy test passed.\n");
+ }
+ }
+
+ // Test assign operator.
+ {
+ OAHashMap<int, String> original_map;
+ original_map.set(1, "1");
+ original_map.set(2, "2");
+ original_map.set(3, "3");
+ original_map.set(4, "4");
+ original_map.set(5, "5");
+
+ OAHashMap<int, String> map_copy(100000);
+ map_copy.set(1, "Just a string.");
+ map_copy = original_map;
+
+ bool pass = true;
+ for (
+ OAHashMap<int, String>::Iterator it = map_copy.iter();
+ it.valid;
+ it = map_copy.next_iter(it)) {
+ if (original_map.lookup_ptr(*it.key) == nullptr) {
+ pass = false;
+ }
+ if (*it.value != *original_map.lookup_ptr(*it.key)) {
+ pass = false;
+ }
+ }
+ if (pass) {
+ OS::get_singleton()->print("OAHashMap assign operation test passed.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap assign operation test FAILED.\n");
+ }
+
+ map_copy.set(1, "Random String");
+ if (*map_copy.lookup_ptr(1) == *original_map.lookup_ptr(1)) {
+ OS::get_singleton()->print("OAHashMap assign operation atomic copy test FAILED.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap assign operation atomic copy test passed.\n");
+ }
+ }
+
return nullptr;
}
+
} // namespace TestOAHashMap
diff --git a/main/tests/test_ordered_hash_map.cpp b/main/tests/test_ordered_hash_map.cpp
index 0720eebaf9..d18a3784be 100644
--- a/main/tests/test_ordered_hash_map.cpp
+++ b/main/tests/test_ordered_hash_map.cpp
@@ -130,7 +130,7 @@ bool test_const_iteration() {
return test_const_iteration(map);
}
-typedef bool (*TestFunc)(void);
+typedef bool (*TestFunc)();
TestFunc test_funcs[] = {
@@ -146,16 +146,17 @@ TestFunc test_funcs[] = {
};
MainLoop *test() {
-
int count = 0;
int passed = 0;
while (true) {
- if (!test_funcs[count])
+ if (!test_funcs[count]) {
break;
+ }
bool pass = test_funcs[count]();
- if (pass)
+ if (pass) {
passed++;
+ }
OS::get_singleton()->print("\t%s\n", pass ? "PASS" : "FAILED");
count++;
@@ -170,4 +171,5 @@ MainLoop *test() {
return nullptr;
}
+
} // namespace TestOrderedHashMap
diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp
index 6feff3b0a9..6cb9bf7b60 100644
--- a/main/tests/test_physics_2d.cpp
+++ b/main/tests/test_physics_2d.cpp
@@ -44,7 +44,6 @@ static const unsigned char convex_png[] = {
};
class TestPhysics2DMainLoop : public MainLoop {
-
GDCLASS(TestPhysics2DMainLoop, MainLoop);
RID circle_img;
@@ -58,7 +57,6 @@ class TestPhysics2DMainLoop : public MainLoop {
Vector2 ray_from, ray_to;
struct BodyShapeData {
-
RID image;
RID shape;
};
@@ -72,13 +70,10 @@ class TestPhysics2DMainLoop : public MainLoop {
// SEGMENT
{
-
Vector<uint8_t> pixels;
pixels.resize(32 * 2 * 2);
for (int i = 0; i < 2; i++) {
-
for (int j = 0; j < 32; j++) {
-
pixels.set(i * 32 * 2 + j * 2 + 0, (j == 0) ? 255 : 0);
pixels.set(i * 32 * 2 + j * 2 + 1, 255);
}
@@ -97,13 +92,10 @@ class TestPhysics2DMainLoop : public MainLoop {
// CIRCLE
{
-
Vector<uint8_t> pixels;
pixels.resize(32 * 32 * 2);
for (int i = 0; i < 32; i++) {
-
for (int j = 0; j < 32; j++) {
-
bool black = Vector2(i - 16, j - 16).length_squared() < 16 * 16;
pixels.set(i * 32 * 2 + j * 2 + 0, (i == 16 || j == 16) ? 255 : 0);
@@ -124,13 +116,10 @@ class TestPhysics2DMainLoop : public MainLoop {
// BOX
{
-
Vector<uint8_t> pixels;
pixels.resize(32 * 32 * 2);
for (int i = 0; i < 32; i++) {
-
for (int j = 0; j < 32; j++) {
-
bool black = i > 0 && i < 31 && j > 0 && j < 31;
pixels.set(i * 32 * 2 + j * 2 + 0, black ? 0 : 255);
@@ -151,13 +140,10 @@ class TestPhysics2DMainLoop : public MainLoop {
// CAPSULE
{
-
Vector<uint8_t> pixels;
pixels.resize(32 * 64 * 2);
for (int i = 0; i < 64; i++) {
-
for (int j = 0; j < 32; j++) {
-
int si = i > 48 ? i - 32 : (i < 16 ? i : 16);
bool black = Vector2(si - 16, j - 16).length_squared() < 16 * 16;
@@ -179,7 +165,6 @@ class TestPhysics2DMainLoop : public MainLoop {
// CONVEX
{
-
Ref<Image> image = memnew(Image(convex_png));
body_shape_data[PhysicsServer2D::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image);
@@ -202,7 +187,6 @@ class TestPhysics2DMainLoop : public MainLoop {
}
void _do_ray_query() {
-
/*
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
ps->query_intersection_segment(ray_query,ray_from,ray_to);
@@ -211,13 +195,10 @@ class TestPhysics2DMainLoop : public MainLoop {
protected:
void input_event(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->is_pressed()) {
-
Point2 p(mb->get_position().x, mb->get_position().y);
if (mb->get_button_index() == 1) {
@@ -233,7 +214,6 @@ protected:
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
Point2 p = mm->get_position();
if (mm->get_button_mask() & BUTTON_MASK_LEFT) {
@@ -247,7 +227,6 @@ protected:
}
RID _add_body(PhysicsServer2D::ShapeType p_shape, const Transform2D &p_xform) {
-
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
@@ -272,7 +251,6 @@ protected:
}
void _add_plane(const Vector2 &p_normal, real_t p_d) {
-
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
Array arr;
@@ -289,7 +267,6 @@ protected:
}
void _add_concave(const Vector<Vector2> &p_points, const Transform2D &p_xform = Transform2D()) {
-
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
RenderingServer *vs = RenderingServer::get_singleton();
@@ -315,7 +292,6 @@ protected:
}
void _ray_query_callback(const RID &p_rid, ObjectID p_id, int p_shape, const Vector2 &p_point, const Vector2 &p_normal) {
-
Vector2 ray_end;
if (p_rid.is_valid()) {
@@ -328,19 +304,18 @@ protected:
vs->canvas_item_clear(ray);
vs->canvas_item_add_line(ray, ray_from, ray_end, p_rid.is_valid() ? Color(0, 1, 0.4) : Color(1, 0.4, 0), 2);
- if (p_rid.is_valid())
+ if (p_rid.is_valid()) {
vs->canvas_item_add_line(ray, ray_end, ray_end + p_normal * 20, p_rid.is_valid() ? Color(0, 1, 0.4) : Color(1, 0.4, 0), 2);
+ }
}
static void _bind_methods() {
-
ClassDB::bind_method(D_METHOD("_body_moved"), &TestPhysics2DMainLoop::_body_moved);
ClassDB::bind_method(D_METHOD("_ray_query_callback"), &TestPhysics2DMainLoop::_ray_query_callback);
}
public:
virtual void init() {
-
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
@@ -351,7 +326,6 @@ public:
ps->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, 98);
{
-
RID vp = vs->viewport_create();
canvas = vs->canvas_create();
@@ -377,7 +351,6 @@ public:
_create_body_shape_data();
for (int i = 0; i < 32; i++) {
-
PhysicsServer2D::ShapeType types[4] = {
PhysicsServer2D::SHAPE_CIRCLE,
PhysicsServer2D::SHAPE_CAPSULE,
@@ -402,7 +375,6 @@ public:
Vector<Point2> parr;
for (int i = 0; i < 30; i++) {
-
Point2 p(i * 60, Math::randf() * 70 + 340);
if (i > 0) {
parr.push_back(prev);
@@ -418,7 +390,6 @@ public:
}
virtual bool idle(float p_time) {
-
return false;
}
virtual void finish() {
@@ -430,7 +401,7 @@ public:
namespace TestPhysics2D {
MainLoop *test() {
-
return memnew(TestPhysics2DMainLoop);
}
+
} // namespace TestPhysics2D
diff --git a/main/tests/test_physics_3d.cpp b/main/tests/test_physics_3d.cpp
index 2d208ee317..dfe2e946cf 100644
--- a/main/tests/test_physics_3d.cpp
+++ b/main/tests/test_physics_3d.cpp
@@ -41,7 +41,6 @@
#include "servers/rendering_server.h"
class TestPhysics3DMainLoop : public MainLoop {
-
GDCLASS(TestPhysics3DMainLoop, MainLoop);
enum {
@@ -69,7 +68,6 @@ class TestPhysics3DMainLoop : public MainLoop {
Map<PhysicsServer3D::ShapeType, RID> type_mesh_map;
void body_changed_transform(Object *p_state, RID p_visual_instance) {
-
PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state;
RenderingServer *vs = RenderingServer::get_singleton();
Transform t = state->get_transform();
@@ -80,12 +78,10 @@ class TestPhysics3DMainLoop : public MainLoop {
protected:
static void _bind_methods() {
-
ClassDB::bind_method("body_changed_transform", &TestPhysics3DMainLoop::body_changed_transform);
}
RID create_body(PhysicsServer3D::ShapeType p_shape, PhysicsServer3D::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) {
-
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
@@ -101,14 +97,12 @@ protected:
bodies.push_back(body);
if (p_body == PhysicsServer3D::BODY_MODE_STATIC) {
-
vs->instance_set_transform(mesh_instance, p_location);
}
return body;
}
RID create_static_plane(const Plane &p_plane) {
-
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
RID world_margin_shape = ps->shape_create(PhysicsServer3D::SHAPE_PLANE);
@@ -122,7 +116,6 @@ protected:
}
void configure_body(RID p_body, float p_mass, float p_friction, float p_bounce) {
-
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_MASS, p_mass);
ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_FRICTION, p_friction);
@@ -130,7 +123,6 @@ protected:
}
void init_shapes() {
-
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
@@ -144,9 +136,9 @@ protected:
/* BOX SHAPE */
- Vector<Plane> box_planes = Geometry::build_box_planes(Vector3(0.5, 0.5, 0.5));
+ Vector<Plane> box_planes = Geometry3D::build_box_planes(Vector3(0.5, 0.5, 0.5));
RID box_mesh = vs->mesh_create();
- Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
+ Geometry3D::MeshData box_data = Geometry3D::build_convex_mesh(box_planes);
vs->mesh_add_surface_from_mesh_data(box_mesh, box_data);
type_mesh_map[PhysicsServer3D::SHAPE_BOX] = box_mesh;
@@ -156,10 +148,10 @@ protected:
/* CAPSULE SHAPE */
- Vector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5, 0.7, 12, Vector3::AXIS_Z);
+ Vector<Plane> capsule_planes = Geometry3D::build_capsule_planes(0.5, 0.7, 12, Vector3::AXIS_Z);
RID capsule_mesh = vs->mesh_create();
- Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
+ Geometry3D::MeshData capsule_data = Geometry3D::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data);
type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh;
@@ -173,10 +165,10 @@ protected:
/* CONVEX SHAPE */
- Vector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5, 0.7, 5, Vector3::AXIS_Z);
+ Vector<Plane> convex_planes = Geometry3D::build_cylinder_planes(0.5, 0.7, 5, Vector3::AXIS_Z);
RID convex_mesh = vs->mesh_create();
- Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
+ Geometry3D::MeshData convex_data = Geometry3D::build_convex_mesh(convex_planes);
QuickHull::build(convex_data.vertices, convex_data);
vs->mesh_add_surface_from_mesh_data(convex_mesh, convex_data);
@@ -188,7 +180,6 @@ protected:
}
void make_trimesh(Vector<Vector3> p_faces, const Transform &p_xform = Transform()) {
-
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
RID trimesh_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON);
@@ -196,7 +187,6 @@ protected:
p_faces = ps->shape_get_data(trimesh_shape); // optimized one
Vector<Vector3> normals; // for drawing
for (int i = 0; i < p_faces.size() / 3; i++) {
-
Plane p(p_faces[i * 3 + 0], p_faces[i * 3 + 1], p_faces[i * 3 + 2]);
normals.push_back(p.normal);
normals.push_back(p.normal);
@@ -222,17 +212,14 @@ protected:
}
void make_grid(int p_width, int p_height, float p_cellsize, float p_cellheight, const Transform &p_xform = Transform()) {
-
Vector<Vector<float>> grid;
grid.resize(p_width);
for (int i = 0; i < p_width; i++) {
-
grid.write[i].resize(p_height);
for (int j = 0; j < p_height; j++) {
-
grid.write[i].write[j] = 1.0 + Math::random(-p_cellheight, p_cellheight);
}
}
@@ -240,9 +227,7 @@ protected:
Vector<Vector3> faces;
for (int i = 1; i < p_width; i++) {
-
for (int j = 1; j < p_height; j++) {
-
#define MAKE_VERTEX(m_x, m_z) \
faces.push_back(Vector3((m_x - p_width / 2) * p_cellsize, grid[m_x][m_z], (m_z - p_height / 2) * p_cellsize))
@@ -261,21 +246,17 @@ protected:
public:
virtual void input_event(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & 4) {
-
ofs_y -= mm->get_relative().y / 200.0;
ofs_x += mm->get_relative().x / 200.0;
}
if (mm.is_valid() && mm->get_button_mask() & 1) {
-
float y = -mm->get_relative().y / 20.0;
float x = mm->get_relative().x / 20.0;
if (mover.is_valid()) {
-
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM);
t.origin += Vector3(x, y, 0);
@@ -286,11 +267,9 @@ public:
}
virtual void request_quit() {
-
quit = true;
}
virtual void init() {
-
ofs_x = ofs_y = 0;
init_shapes();
@@ -332,7 +311,6 @@ public:
quit = false;
}
virtual bool iteration(float p_time) {
-
if (mover.is_valid()) {
static float joy_speed = 10;
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
@@ -360,14 +338,13 @@ public:
}
void test_character() {
-
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
- Vector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5, 1, 12, 5, Vector3::AXIS_Y);
+ Vector<Plane> capsule_planes = Geometry3D::build_capsule_planes(0.5, 1, 12, 5, Vector3::AXIS_Y);
RID capsule_mesh = vs->mesh_create();
- Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
+ Geometry3D::MeshData capsule_data = Geometry3D::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data);
type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh;
@@ -393,9 +370,7 @@ public:
}
void test_fall() {
-
for (int i = 0; i < 35; i++) {
-
static const PhysicsServer3D::ShapeType shape_idx[] = {
PhysicsServer3D::SHAPE_CAPSULE,
PhysicsServer3D::SHAPE_BOX,
@@ -417,7 +392,6 @@ public:
}
void test_activate() {
-
create_body(PhysicsServer3D::SHAPE_BOX, PhysicsServer3D::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true);
create_static_plane(Plane(Vector3(0, 1, 0), -1));
}
@@ -433,7 +407,7 @@ public:
namespace TestPhysics3D {
MainLoop *test() {
-
return memnew(TestPhysics3DMainLoop);
}
+
} // namespace TestPhysics3D
diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp
index bcfcf61e25..d936dd72e7 100644
--- a/main/tests/test_render.cpp
+++ b/main/tests/test_render.cpp
@@ -44,7 +44,6 @@
namespace TestRender {
class TestMainLoop : public MainLoop {
-
RID test_cube;
RID instance;
RID camera;
@@ -53,7 +52,6 @@ class TestMainLoop : public MainLoop {
RID scenario;
struct InstanceInfo {
-
RID instance;
Transform base;
Vector3 rot_axis;
@@ -67,13 +65,12 @@ class TestMainLoop : public MainLoop {
protected:
public:
virtual void input_event(const Ref<InputEvent> &p_event) {
-
- if (p_event->is_pressed())
+ if (p_event->is_pressed()) {
quit = true;
+ }
}
virtual void init() {
-
print_line("INITIALIZING TEST RENDER");
RenderingServer *vs = RenderingServer::get_singleton();
test_cube = vs->get_test_cube();
@@ -82,8 +79,8 @@ public:
Vector<Vector3> vts;
/*
- Vector<Plane> sp = Geometry::build_sphere_planes(2,5,5);
- Geometry::MeshData md2 = Geometry::build_convex_mesh(sp);
+ Vector<Plane> sp = Geometry3D::build_sphere_planes(2,5,5);
+ Geometry3D::MeshData md2 = Geometry3D::build_convex_mesh(sp);
vts=md2.vertices;
*/
/*
@@ -121,7 +118,7 @@ public:
vts.push_back(Vector3(-1, 1, -1));
vts.push_back(Vector3(-1, -1, -1));
- Geometry::MeshData md;
+ Geometry3D::MeshData md;
Error err = QuickHull::build(vts, md);
print_line("ERR: " + itos(err));
test_cube = vs->mesh_create();
@@ -144,7 +141,6 @@ public:
};
for (int i = 0; i < object_count; i++) {
-
InstanceInfo ii;
ii.instance = vs->instance_create2(test_cube, scenario);
@@ -205,7 +201,6 @@ public:
quit = false;
}
virtual bool iteration(float p_time) {
-
RenderingServer *vs = RenderingServer::get_singleton();
//Transform t;
//t.rotate(Vector3(0, 1, 0), ofs);
@@ -217,7 +212,6 @@ public:
//return quit;
for (List<InstanceInfo>::Element *E = instances.front(); E; E = E->next()) {
-
Transform pre(Basis(E->get().rot_axis, ofs), Vector3());
vs->instance_set_transform(E->get().instance, pre * E->get().base);
/*
@@ -240,7 +234,7 @@ public:
};
MainLoop *test() {
-
return memnew(TestMainLoop);
}
+
} // namespace TestRender
diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp
index b7967238a2..34ee3e3210 100644
--- a/main/tests/test_shader_lang.cpp
+++ b/main/tests/test_shader_lang.cpp
@@ -44,7 +44,6 @@ typedef ShaderLanguage SL;
namespace TestShaderLang {
static String _mktab(int p_level) {
-
String tb;
for (int i = 0; i < p_level; i++) {
tb += "\t";
@@ -54,12 +53,10 @@ static String _mktab(int p_level) {
}
static String _typestr(SL::DataType p_type) {
-
return ShaderLanguage::get_datatype_name(p_type);
}
static String _prestr(SL::DataPrecision p_pres) {
-
switch (p_pres) {
case SL::PRECISION_LOWP:
return "lowp ";
@@ -74,12 +71,10 @@ static String _prestr(SL::DataPrecision p_pres) {
}
static String _opstr(SL::Operator p_op) {
-
return ShaderLanguage::get_operator_text(p_op);
}
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
-
switch (p_type) {
case SL::TYPE_BOOL:
return p_values[0].boolean ? "true" : "false";
@@ -119,17 +114,13 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
}
static String dump_node_code(SL::Node *p_node, int p_level) {
-
String code;
switch (p_node->type) {
-
case SL::Node::TYPE_SHADER: {
-
SL::ShaderNode *pnode = (SL::ShaderNode *)p_node;
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
-
String ucode = "uniform ";
ucode += _prestr(E->get().precision);
ucode += _typestr(E->get().type);
@@ -149,14 +140,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
"white"
};
- if (E->get().hint)
+ if (E->get().hint) {
ucode += " : " + String(hint_name[E->get().hint]);
+ }
code += ucode + "\n";
}
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
-
String vcode = "varying ";
vcode += _prestr(E->get().precision);
vcode += _typestr(E->get().type);
@@ -165,15 +156,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
code += vcode + "\n";
}
for (int i = 0; i < pnode->functions.size(); i++) {
-
SL::FunctionNode *fnode = pnode->functions[i].function;
String header;
header = _typestr(fnode->return_type) + " " + fnode->name + "(";
for (int j = 0; j < fnode->arguments.size(); j++) {
-
- if (j > 0)
+ if (j > 0) {
header += ", ";
+ }
header += _prestr(fnode->arguments[j].precision) + _typestr(fnode->arguments[j].type) + " " + fnode->arguments[j].name;
}
@@ -185,10 +175,8 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
//code+=dump_node_code(pnode->body,p_level);
} break;
case SL::Node::TYPE_STRUCT: {
-
} break;
case SL::Node::TYPE_FUNCTION: {
-
} break;
case SL::Node::TYPE_BLOCK: {
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
@@ -196,12 +184,10 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
//variables
code += _mktab(p_level - 1) + "{\n";
for (Map<StringName, SL::BlockNode::Variable>::Element *E = bnode->variables.front(); E; E = E->next()) {
-
code += _mktab(p_level) + _prestr(E->get().precision) + _typestr(E->get().type) + " " + E->key() + ";\n";
}
for (int i = 0; i < bnode->statements.size(); i++) {
-
String scode = dump_node_code(bnode->statements[i], p_level);
if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
@@ -240,7 +226,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
SL::OperatorNode *onode = (SL::OperatorNode *)p_node;
switch (onode->op) {
-
case SL::OP_ASSIGN:
case SL::OP_ASSIGN_ADD:
case SL::OP_ASSIGN_SUB:
@@ -269,14 +254,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
case SL::OP_CONSTRUCT:
code = dump_node_code(onode->arguments[0], p_level) + "(";
for (int i = 1; i < onode->arguments.size(); i++) {
- if (i > 1)
+ if (i > 1) {
code += ", ";
+ }
code += dump_node_code(onode->arguments[i], p_level);
}
code += ")";
break;
default: {
-
code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")";
break;
}
@@ -286,17 +271,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
case SL::Node::TYPE_CONTROL_FLOW: {
SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node;
if (cfnode->flow_op == SL::FLOW_OP_IF) {
-
code += _mktab(p_level) + "if (" + dump_node_code(cfnode->expressions[0], p_level) + ")\n";
code += dump_node_code(cfnode->blocks[0], p_level + 1);
if (cfnode->blocks.size() == 2) {
-
code += _mktab(p_level) + "else\n";
code += dump_node_code(cfnode->blocks[1], p_level + 1);
}
} else if (cfnode->flow_op == SL::FLOW_OP_RETURN) {
-
if (cfnode->blocks.size()) {
code = "return " + dump_node_code(cfnode->blocks[0], p_level);
} else {
@@ -316,7 +298,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
}
static Error recreate_code(void *p_str, SL::ShaderNode *p_program) {
-
String *str = (String *)p_str;
*str = dump_node_code(p_program, 0);
@@ -325,7 +306,6 @@ static Error recreate_code(void *p_str, SL::ShaderNode *p_program) {
}
MainLoop *test() {
-
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
if (cmdlargs.empty()) {
@@ -346,8 +326,9 @@ MainLoop *test() {
while (true) {
CharType c = fa->get_8();
- if (fa->eof_reached())
+ if (fa->eof_reached()) {
break;
+ }
code += c;
}
@@ -363,10 +344,9 @@ MainLoop *test() {
Set<String> types;
types.insert("spatial");
- Error err = sl.compile(code, dt, rm, types, NULL);
+ Error err = sl.compile(code, dt, rm, types, nullptr);
if (err) {
-
print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text());
return nullptr;
} else {
@@ -377,4 +357,5 @@ MainLoop *test() {
return nullptr;
}
+
} // namespace TestShaderLang
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index 34087c7204..775c039282 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -45,7 +45,6 @@
namespace TestString {
bool test_1() {
-
OS::get_singleton()->print("\n\nTest 1: Assign from cstr\n");
String s = "Hello";
@@ -57,7 +56,6 @@ bool test_1() {
}
bool test_2() {
-
OS::get_singleton()->print("\n\nTest 2: Assign from string (operator=)\n");
String s = "Dolly";
@@ -70,7 +68,6 @@ bool test_2() {
}
bool test_3() {
-
OS::get_singleton()->print("\n\nTest 3: Assign from c-string (copycon)\n");
String s("Sheep");
@@ -83,7 +80,6 @@ bool test_3() {
}
bool test_4() {
-
OS::get_singleton()->print("\n\nTest 4: Assign from c-widechar (operator=)\n");
String s(L"Give me");
@@ -95,7 +91,6 @@ bool test_4() {
}
bool test_5() {
-
OS::get_singleton()->print("\n\nTest 5: Assign from c-widechar (copycon)\n");
String s(L"Wool");
@@ -107,67 +102,72 @@ bool test_5() {
}
bool test_6() {
-
OS::get_singleton()->print("\n\nTest 6: comparisons (equal)\n");
String s = "Test Compare";
OS::get_singleton()->print("\tComparing to \"Test Compare\"\n");
- if (!(s == "Test Compare"))
+ if (!(s == "Test Compare")) {
return false;
+ }
- if (!(s == L"Test Compare"))
+ if (!(s == L"Test Compare")) {
return false;
+ }
- if (!(s == String("Test Compare")))
+ if (!(s == String("Test Compare"))) {
return false;
+ }
return true;
}
bool test_7() {
-
OS::get_singleton()->print("\n\nTest 7: comparisons (unequal)\n");
String s = "Test Compare";
OS::get_singleton()->print("\tComparing to \"Test Compare\"\n");
- if (!(s != "Peanut"))
+ if (!(s != "Peanut")) {
return false;
+ }
- if (!(s != L"Coconut"))
+ if (!(s != L"Coconut")) {
return false;
+ }
- if (!(s != String("Butter")))
+ if (!(s != String("Butter"))) {
return false;
+ }
return true;
}
bool test_8() {
-
OS::get_singleton()->print("\n\nTest 8: comparisons (operator<)\n");
String s = "Bees";
OS::get_singleton()->print("\tComparing to \"Bees\"\n");
- if (!(s < "Elephant"))
+ if (!(s < "Elephant")) {
return false;
+ }
- if (s < L"Amber")
+ if (s < L"Amber") {
return false;
+ }
- if (s < String("Beatrix"))
+ if (s < String("Beatrix")) {
return false;
+ }
return true;
}
bool test_9() {
-
OS::get_singleton()->print("\n\nTest 9: Concatenation\n");
String s;
@@ -186,23 +186,24 @@ bool test_9() {
}
bool test_10() {
-
OS::get_singleton()->print("\n\nTest 10: Misc funcs (size/length/empty/etc)\n");
- if (!String("").empty())
+ if (!String("").empty()) {
return false;
+ }
- if (String("Mellon").size() != 7)
+ if (String("Mellon").size() != 7) {
return false;
+ }
- if (String("Oranges").length() != 7)
+ if (String("Oranges").length() != 7) {
return false;
+ }
return true;
}
bool test_11() {
-
OS::get_singleton()->print("\n\nTest 11: Operator[]\n");
String a = "Kugar Sane";
@@ -210,32 +211,34 @@ bool test_11() {
a[0] = 'S';
a[6] = 'C';
- if (a != "Sugar Cane")
+ if (a != "Sugar Cane") {
return false;
+ }
- if (a[1] != 'u')
+ if (a[1] != 'u') {
return false;
+ }
return true;
}
bool test_12() {
-
OS::get_singleton()->print("\n\nTest 12: case functions\n");
String a = "MoMoNgA";
- if (a.to_upper() != "MOMONGA")
+ if (a.to_upper() != "MOMONGA") {
return false;
+ }
- if (a.nocasecmp_to("momonga") != 0)
+ if (a.nocasecmp_to("momonga") != 0) {
return false;
+ }
return true;
}
bool test_13() {
-
OS::get_singleton()->print("\n\nTest 13: UTF8\n");
/* how can i embed UTF in here? */
@@ -252,7 +255,6 @@ bool test_13() {
}
bool test_14() {
-
OS::get_singleton()->print("\n\nTest 14: ASCII\n");
String s = L"Primero Leche";
@@ -263,7 +265,6 @@ bool test_14() {
}
bool test_15() {
-
OS::get_singleton()->print("\n\nTest 15: substr\n");
String s = "Killer Baby";
@@ -273,7 +274,6 @@ bool test_15() {
}
bool test_16() {
-
OS::get_singleton()->print("\n\nTest 16: find\n");
String s = "Pretty Woman";
@@ -281,17 +281,18 @@ bool test_16() {
OS::get_singleton()->print("\t\"tty\" is at %i pos.\n", s.find("tty"));
OS::get_singleton()->print("\t\"Revenge of the Monster Truck\" is at %i pos.\n", s.find("Revenge of the Monster Truck"));
- if (s.find("tty") != 3)
+ if (s.find("tty") != 3) {
return false;
+ }
- if (s.find("Revenge of the Monster Truck") != -1)
+ if (s.find("Revenge of the Monster Truck") != -1) {
return false;
+ }
return true;
}
bool test_17() {
-
OS::get_singleton()->print("\n\nTest 17: find no case\n");
String s = "Pretty Whale";
@@ -299,17 +300,18 @@ bool test_17() {
OS::get_singleton()->print("\t\"WHA\" is at %i pos.\n", s.findn("WHA"));
OS::get_singleton()->print("\t\"Revenge of the Monster SawFish\" is at %i pos.\n", s.findn("Revenge of the Monster Truck"));
- if (s.findn("WHA") != 7)
+ if (s.findn("WHA") != 7) {
return false;
+ }
- if (s.findn("Revenge of the Monster SawFish") != -1)
+ if (s.findn("Revenge of the Monster SawFish") != -1) {
return false;
+ }
return true;
}
bool test_18() {
-
OS::get_singleton()->print("\n\nTest 18: find no case\n");
String s = "Pretty Whale";
@@ -317,17 +319,18 @@ bool test_18() {
OS::get_singleton()->print("\t\"WHA\" is at %i pos.\n", s.findn("WHA"));
OS::get_singleton()->print("\t\"Revenge of the Monster SawFish\" is at %i pos.\n", s.findn("Revenge of the Monster Truck"));
- if (s.findn("WHA") != 7)
+ if (s.findn("WHA") != 7) {
return false;
+ }
- if (s.findn("Revenge of the Monster SawFish") != -1)
+ if (s.findn("Revenge of the Monster SawFish") != -1) {
return false;
+ }
return true;
}
bool test_19() {
-
OS::get_singleton()->print("\n\nTest 19: Search & replace\n");
String s = "Happy Birthday, Anna!";
@@ -340,7 +343,6 @@ bool test_19() {
}
bool test_20() {
-
OS::get_singleton()->print("\n\nTest 20: Insertion\n");
String s = "Who is Frederic?";
@@ -353,7 +355,6 @@ bool test_20() {
}
bool test_21() {
-
OS::get_singleton()->print("\n\nTest 21: Number -> String\n");
OS::get_singleton()->print("\tPi is %f\n", 33.141593);
@@ -363,7 +364,6 @@ bool test_21() {
}
bool test_22() {
-
OS::get_singleton()->print("\n\nTest 22: String -> Int\n");
static const char *nums[4] = { "1237461283", "- 22", "0", " - 1123412" };
@@ -372,15 +372,15 @@ bool test_22() {
for (int i = 0; i < 4; i++) {
OS::get_singleton()->print("\tString: \"%s\" as Int is %i\n", nums[i], String(nums[i]).to_int());
- if (String(nums[i]).to_int() != num[i])
+ if (String(nums[i]).to_int() != num[i]) {
return false;
+ }
}
return true;
}
bool test_23() {
-
OS::get_singleton()->print("\n\nTest 23: String -> Float\n");
static const char *nums[4] = { "-12348298412.2", "0.05", "2.0002", " -0.0001" };
@@ -389,15 +389,15 @@ bool test_23() {
for (int i = 0; i < 4; i++) {
OS::get_singleton()->print("\tString: \"%s\" as Float is %f\n", nums[i], String(nums[i]).to_double());
- if (ABS(String(nums[i]).to_double() - num[i]) > 0.00001)
+ if (ABS(String(nums[i]).to_double() - num[i]) > 0.00001) {
return false;
+ }
}
return true;
}
bool test_24() {
-
OS::get_singleton()->print("\n\nTest 24: Slicing\n");
String s = "Mars,Jupiter,Saturn,Uranus";
@@ -407,18 +407,17 @@ bool test_24() {
OS::get_singleton()->print("\tSlicing \"%ls\" by \"%s\"..\n", s.c_str(), ",");
for (int i = 0; i < s.get_slice_count(","); i++) {
-
OS::get_singleton()->print("\t\t%i- %ls\n", i + 1, s.get_slice(",", i).c_str());
- if (s.get_slice(",", i) != slices[i])
+ if (s.get_slice(",", i) != slices[i]) {
return false;
+ }
}
return true;
}
bool test_25() {
-
OS::get_singleton()->print("\n\nTest 25: Erasing\n");
String s = "Josephine is such a cute girl!";
@@ -433,7 +432,6 @@ bool test_25() {
}
bool test_26() {
-
OS::get_singleton()->print("\n\nTest 26: RegEx substitution\n");
#ifndef MODULE_REGEX_ENABLED
@@ -461,7 +459,6 @@ struct test_27_data {
};
bool test_27() {
-
OS::get_singleton()->print("\n\nTest 27: begins_with\n");
test_27_data tc[] = {
{ "res://foobar", "res://", true },
@@ -486,7 +483,6 @@ bool test_27() {
};
bool test_28() {
-
OS::get_singleton()->print("\n\nTest 28: sprintf\n");
bool success, state = true;
@@ -822,7 +818,6 @@ bool test_28() {
}
bool test_29() {
-
bool state = true;
IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
@@ -972,32 +967,35 @@ bool test_31() {
String a = "";
success = a[0] == 0;
OS::get_singleton()->print("Is 0 String[0]:, %s\n", success ? "OK" : "FAIL");
- if (!success)
+ if (!success) {
state = false;
+ }
String b = "Godot";
success = b[b.size()] == 0;
OS::get_singleton()->print("Is 0 String[size()]:, %s\n", success ? "OK" : "FAIL");
- if (!success)
+ if (!success) {
state = false;
+ }
const String c = "";
success = c[0] == 0;
OS::get_singleton()->print("Is 0 const String[0]:, %s\n", success ? "OK" : "FAIL");
- if (!success)
+ if (!success) {
state = false;
+ }
const String d = "Godot";
success = d[d.size()] == 0;
OS::get_singleton()->print("Is 0 const String[size()]:, %s\n", success ? "OK" : "FAIL");
- if (!success)
+ if (!success) {
state = false;
+ }
return state;
};
bool test_32() {
-
#define STRIP_TEST(x) \
{ \
bool success = x; \
@@ -1129,7 +1127,7 @@ bool test_35() {
return state;
}
-typedef bool (*TestFunc)(void);
+typedef bool (*TestFunc)();
TestFunc test_funcs[] = {
@@ -1173,7 +1171,6 @@ TestFunc test_funcs[] = {
};
MainLoop *test() {
-
/** A character length != wchar_t may be forced, so the tests won't work */
static_assert(sizeof(CharType) == sizeof(wchar_t));
@@ -1182,11 +1179,13 @@ MainLoop *test() {
int passed = 0;
while (true) {
- if (!test_funcs[count])
+ if (!test_funcs[count]) {
break;
+ }
bool pass = test_funcs[count]();
- if (pass)
+ if (pass) {
passed++;
+ }
OS::get_singleton()->print("\t%s\n", pass ? "PASS" : "FAILED");
count++;
@@ -1201,4 +1200,5 @@ MainLoop *test() {
return nullptr;
}
+
} // namespace TestString
diff --git a/methods.py b/methods.py
index 805ae256c3..ca6756f95f 100644
--- a/methods.py
+++ b/methods.py
@@ -2,6 +2,7 @@ import os
import re
import glob
import subprocess
+from collections import OrderedDict
def add_source_files(self, sources, files, warn_duplicates=True):
@@ -137,37 +138,47 @@ def parse_cg_file(fname, uniforms, sizes, conditionals):
fs.close()
-def detect_modules():
+def detect_modules(at_path):
+ module_list = OrderedDict() # name : path
- module_list = []
+ modules_glob = os.path.join(at_path, "*")
+ files = glob.glob(modules_glob)
+ files.sort() # so register_module_types does not change that often, and also plugins are registered in alphabetic order
+
+ for x in files:
+ if not is_module(x):
+ continue
+ name = os.path.basename(x)
+ path = x.replace("\\", "/") # win32
+ module_list[name] = path
+
+ return module_list
+
+
+def is_module(path):
+ return os.path.isdir(path) and os.path.exists(os.path.join(path, "SCsub"))
+
+
+def write_modules(module_list):
includes_cpp = ""
+ preregister_cpp = ""
register_cpp = ""
unregister_cpp = ""
- preregister_cpp = ""
- files = glob.glob("modules/*")
- files.sort() # so register_module_types does not change that often, and also plugins are registered in alphabetic order
- for x in files:
- if not os.path.isdir(x):
- continue
- if not os.path.exists(x + "/config.py"):
- continue
- x = x.replace("modules/", "") # rest of world
- x = x.replace("modules\\", "") # win32
- module_list.append(x)
+ for name, path in module_list.items():
try:
- with open("modules/" + x + "/register_types.h"):
- includes_cpp += '#include "modules/' + x + '/register_types.h"\n'
- register_cpp += "#ifdef MODULE_" + x.upper() + "_ENABLED\n"
- register_cpp += "\tregister_" + x + "_types();\n"
- register_cpp += "#endif\n"
- preregister_cpp += "#ifdef MODULE_" + x.upper() + "_ENABLED\n"
- preregister_cpp += "#ifdef MODULE_" + x.upper() + "_HAS_PREREGISTER\n"
- preregister_cpp += "\tpreregister_" + x + "_types();\n"
+ with open(os.path.join(path, "register_types.h")):
+ includes_cpp += '#include "' + path + '/register_types.h"\n'
+ preregister_cpp += "#ifdef MODULE_" + name.upper() + "_ENABLED\n"
+ preregister_cpp += "#ifdef MODULE_" + name.upper() + "_HAS_PREREGISTER\n"
+ preregister_cpp += "\tpreregister_" + name + "_types();\n"
preregister_cpp += "#endif\n"
preregister_cpp += "#endif\n"
- unregister_cpp += "#ifdef MODULE_" + x.upper() + "_ENABLED\n"
- unregister_cpp += "\tunregister_" + x + "_types();\n"
+ register_cpp += "#ifdef MODULE_" + name.upper() + "_ENABLED\n"
+ register_cpp += "\tregister_" + name + "_types();\n"
+ register_cpp += "#endif\n"
+ unregister_cpp += "#ifdef MODULE_" + name.upper() + "_ENABLED\n"
+ unregister_cpp += "\tunregister_" + name + "_types();\n"
unregister_cpp += "#endif\n"
except IOError:
pass
@@ -202,13 +213,48 @@ void unregister_module_types() {
with open("modules/register_module_types.gen.cpp", "w") as f:
f.write(modules_cpp)
- return module_list
+
+def convert_custom_modules_path(path):
+ if not path:
+ return path
+ err_msg = "Build option 'custom_modules' must %s"
+ if not os.path.isdir(path):
+ raise ValueError(err_msg % "point to an existing directory.")
+ if os.path.realpath(path) == os.path.realpath("modules"):
+ raise ValueError(err_msg % "be a directory other than built-in `modules` directory.")
+ if is_module(path):
+ raise ValueError(err_msg % "point to a directory with modules, not a single module.")
+ return os.path.realpath(os.path.expanduser(path))
def disable_module(self):
self.disabled_modules.append(self.current_module)
+def module_check_dependencies(self, module, dependencies):
+ """
+ Checks if module dependencies are enabled for a given module,
+ and prints a warning if they aren't.
+ Meant to be used in module `can_build` methods.
+ Returns a boolean (True if dependencies are satisfied).
+ """
+ missing_deps = []
+ for dep in dependencies:
+ opt = "module_{}_enabled".format(dep)
+ if not opt in self or not self[opt]:
+ missing_deps.append(dep)
+
+ if missing_deps != []:
+ print(
+ "Disabling '{}' module as the following dependencies are not satisfied: {}".format(
+ module, ", ".join(missing_deps)
+ )
+ )
+ return False
+ else:
+ return True
+
+
def use_windows_spawn_fix(self, platform=None):
if os.name != "nt":
@@ -634,3 +680,137 @@ def using_gcc(env):
def using_clang(env):
return "clang" in os.path.basename(env["CC"])
+
+
+def show_progress(env):
+ import sys
+ from SCons.Script import Progress, Command, AlwaysBuild
+
+ screen = sys.stdout
+ # Progress reporting is not available in non-TTY environments since it
+ # messes with the output (for example, when writing to a file)
+ show_progress = env["progress"] and sys.stdout.isatty()
+ node_count = 0
+ node_count_max = 0
+ node_count_interval = 1
+ node_count_fname = str(env.Dir("#")) + "/.scons_node_count"
+
+ import time, math
+
+ class cache_progress:
+ # The default is 1 GB cache and 12 hours half life
+ def __init__(self, path=None, limit=1073741824, half_life=43200):
+ self.path = path
+ self.limit = limit
+ self.exponent_scale = math.log(2) / half_life
+ if env["verbose"] and path != None:
+ screen.write(
+ "Current cache limit is {} (used: {})\n".format(
+ self.convert_size(limit), self.convert_size(self.get_size(path))
+ )
+ )
+ self.delete(self.file_list())
+
+ def __call__(self, node, *args, **kw):
+ nonlocal node_count, node_count_max, node_count_interval, node_count_fname, show_progress
+ if show_progress:
+ # Print the progress percentage
+ node_count += node_count_interval
+ if node_count_max > 0 and node_count <= node_count_max:
+ screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max))
+ screen.flush()
+ elif node_count_max > 0 and node_count > node_count_max:
+ screen.write("\r[100%] ")
+ screen.flush()
+ else:
+ screen.write("\r[Initial build] ")
+ screen.flush()
+
+ def delete(self, files):
+ if len(files) == 0:
+ return
+ if env["verbose"]:
+ # Utter something
+ screen.write("\rPurging %d %s from cache...\n" % (len(files), len(files) > 1 and "files" or "file"))
+ [os.remove(f) for f in files]
+
+ def file_list(self):
+ if self.path is None:
+ # Nothing to do
+ return []
+ # Gather a list of (filename, (size, atime)) within the
+ # cache directory
+ file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, "*", "*"))]
+ if file_stat == []:
+ # Nothing to do
+ return []
+ # Weight the cache files by size (assumed to be roughly
+ # proportional to the recompilation time) times an exponential
+ # decay since the ctime, and return a list with the entries
+ # (filename, size, weight).
+ current_time = time.time()
+ file_stat = [(x[0], x[1][0], (current_time - x[1][1])) for x in file_stat]
+ # Sort by the most recently accessed files (most sensible to keep) first
+ file_stat.sort(key=lambda x: x[2])
+ # Search for the first entry where the storage limit is
+ # reached
+ sum, mark = 0, None
+ for i, x in enumerate(file_stat):
+ sum += x[1]
+ if sum > self.limit:
+ mark = i
+ break
+ if mark is None:
+ return []
+ else:
+ return [x[0] for x in file_stat[mark:]]
+
+ def convert_size(self, size_bytes):
+ if size_bytes == 0:
+ return "0 bytes"
+ size_name = ("bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
+ i = int(math.floor(math.log(size_bytes, 1024)))
+ p = math.pow(1024, i)
+ s = round(size_bytes / p, 2)
+ return "%s %s" % (int(s) if i == 0 else s, size_name[i])
+
+ def get_size(self, start_path="."):
+ total_size = 0
+ for dirpath, dirnames, filenames in os.walk(start_path):
+ for f in filenames:
+ fp = os.path.join(dirpath, f)
+ total_size += os.path.getsize(fp)
+ return total_size
+
+ def progress_finish(target, source, env):
+ nonlocal node_count, progressor
+ with open(node_count_fname, "w") as f:
+ f.write("%d\n" % node_count)
+ progressor.delete(progressor.file_list())
+
+ try:
+ with open(node_count_fname) as f:
+ node_count_max = int(f.readline())
+ except:
+ pass
+
+ cache_directory = os.environ.get("SCONS_CACHE")
+ # Simple cache pruning, attached to SCons' progress callback. Trim the
+ # cache directory to a size not larger than cache_limit.
+ cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
+ progressor = cache_progress(cache_directory, cache_limit)
+ Progress(progressor, interval=node_count_interval)
+
+ progress_finish_command = Command("progress_finish", [], progress_finish)
+ AlwaysBuild(progress_finish_command)
+
+
+def dump(env):
+ # Dumps latest build information for debugging purposes and external tools.
+ from json import dump
+
+ def non_serializable(obj):
+ return "<<non-serializable: %s>>" % (type(obj).__qualname__)
+
+ with open(".scons_env.json", "w") as f:
+ dump(env.Dictionary(), f, indent=4, default=non_serializable)
diff --git a/misc/scons/site_tools/compilation_db.py b/misc/scons/compilation_db.py
index 87db32adc9..87db32adc9 100644
--- a/misc/scons/site_tools/compilation_db.py
+++ b/misc/scons/compilation_db.py
diff --git a/modules/SCsub b/modules/SCsub
index fb46c5f877..9155a53eaf 100644
--- a/modules/SCsub
+++ b/modules/SCsub
@@ -3,6 +3,7 @@
Import("env")
import modules_builders
+import os
env_modules = env.Clone()
@@ -13,16 +14,20 @@ env.CommandNoCache("modules_enabled.gen.h", Value(env.module_list), modules_buil
vs_sources = []
# libmodule_<name>.a for each active module.
-for module in env.module_list:
+for name, path in env.module_list.items():
env.modules_sources = []
- SConscript(module + "/SCsub")
+
+ if not os.path.isabs(path):
+ SConscript(name + "/SCsub") # Built-in.
+ else:
+ SConscript(path + "/SCsub") # Custom.
# Some modules are not linked automatically but can be enabled optionally
# on iOS, so we handle those specially.
- if env["platform"] == "iphone" and module in ["arkit", "camera"]:
+ if env["platform"] == "iphone" and name in ["arkit", "camera"]:
continue
- lib = env_modules.add_library("module_%s" % module, env.modules_sources)
+ lib = env_modules.add_library("module_%s" % name, env.modules_sources)
env.Prepend(LIBS=[lib])
if env["vsproj"]:
vs_sources += env.modules_sources
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index cc74674eff..aedc4b690a 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -44,7 +44,6 @@
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/LogStream.hpp>
-#include <string>
// move into assimp
aiBone *get_bone_by_name(const aiScene *scene, aiString bone_name) {
@@ -53,7 +52,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 +64,6 @@ aiBone *get_bone_by_name(const aiScene *scene, aiString bone_name) {
}
void EditorSceneImporterAssimp::get_extensions(List<String> *r_extensions) const {
-
const String import_setting_string = "filesystem/import/open_asset_import/";
Map<String, ImportFormat> import_format;
@@ -104,8 +101,6 @@ void EditorSceneImporterAssimp::_bind_methods() {
Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps,
List<String> *r_missing_deps, Error *r_err) {
Assimp::Importer importer;
- std::wstring w_path = ProjectSettings::get_singleton()->globalize_path(p_path).c_str();
- std::string s_path(w_path.begin(), w_path.end());
importer.SetPropertyBool(AI_CONFIG_PP_FD_REMOVE, true);
// Cannot remove pivot points because the static mesh will be in the wrong place
importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);
@@ -147,7 +142,8 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f
// aiProcess_EmbedTextures |
//aiProcess_SplitByBoneCount |
0;
- aiScene *scene = (aiScene *)importer.ReadFile(s_path.c_str(), post_process_Steps);
+ String g_path = ProjectSettings::get_singleton()->globalize_path(p_path);
+ aiScene *scene = (aiScene *)importer.ReadFile(g_path.utf8().ptr(), post_process_Steps);
ERR_FAIL_COND_V_MSG(scene == nullptr, nullptr, String("Open Asset Import failed to open: ") + String(importer.GetErrorString()));
@@ -156,14 +152,11 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f
template <class T>
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 +178,6 @@ struct EditorSceneImporterAssetImportInterpolate {
//thank you for existing, partial specialization
template <>
struct EditorSceneImporterAssetImportInterpolate<Quat> {
-
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.");
@@ -214,8 +206,9 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &p_times, co
//could use binary search, worth it?
int idx = -1;
for (int i = 0; i < p_times.size(); i++) {
- if (p_times[i] > p_time)
+ if (p_times[i] > p_time) {
break;
+ }
idx++;
}
@@ -223,7 +216,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &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 +228,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &p_times, co
} break;
case AssetImportAnimation::INTERP_STEP: {
-
if (idx == -1) {
return p_values[0];
} else if (idx >= p_times.size() - 1) {
@@ -247,7 +238,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &p_times, co
} break;
case AssetImportAnimation::INTERP_CATMULLROMSPLINE: {
-
if (idx == -1) {
return p_values[1];
} else if (idx >= p_times.size() - 1) {
@@ -260,7 +250,6 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &p_times, co
} break;
case AssetImportAnimation::INTERP_CUBIC_SPLINE: {
-
if (idx == -1) {
return p_values[1];
} else if (idx >= p_times.size() - 1) {
@@ -307,10 +296,10 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
state.assimp_scene = scene;
state.max_bone_weights = p_max_bone_weights;
state.animation_player = nullptr;
+ state.import_flags = p_flags;
// 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];
@@ -836,6 +817,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
state.animation_player->add_animation(name, animation);
}
}
+
//
// Mesh Generation from indices ? why do we need so much mesh code
// [debt needs looked into]
@@ -843,10 +825,11 @@ Ref<Mesh>
EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &state, const Vector<int> &p_surface_indices,
const aiNode *assimp_node, Ref<Skin> &skin,
Skeleton3D *&skeleton_assigned) {
-
Ref<ArrayMesh> mesh;
mesh.instance();
bool has_uvs = false;
+ bool compress_vert_data = state.import_flags & IMPORT_USE_COMPRESSION;
+ uint32_t mesh_flags = compress_vert_data ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
Map<String, uint32_t> morph_mesh_string_lookup;
@@ -894,7 +877,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 +902,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 +937,6 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// We have vertex weights right?
if (vertex_weights.has(j)) {
-
Vector<BoneInfo> bone_info = vertex_weights[j];
Vector<int> bones;
bones.resize(bone_info.size());
@@ -1200,7 +1180,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()) {
@@ -1288,7 +1267,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
morphs[j] = array_copy;
}
- mesh->add_surface_from_arrays(primitive, array_mesh, morphs);
+ mesh->add_surface_from_arrays(primitive, array_mesh, morphs, Dictionary(), mesh_flags);
mesh->surface_set_material(i, mat);
mesh->surface_set_name(i, AssimpUtils::get_assimp_string(ai_mesh->mName));
}
@@ -1482,7 +1461,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..ee22800ac4 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;
@@ -88,6 +87,9 @@ struct ImportState {
// this means we can detect
// what bones are for other armatures
List<aiBone *> bone_stack;
+
+ // EditorSceneImporter::ImportFlags
+ uint32_t import_flags;
};
struct AssimpImageData {
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<Image> load_image(ImportState &state, const aiScene *p_scene, String p_path) {
-
Map<String, Ref<Image>>::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..27b299a65d 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<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedChannels p_channels) {
-
Vector<uint8_t> budata;
{
@@ -163,7 +162,6 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &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<Image> basis_universal_unpacker(const Vector<uint8_t> &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 {
@@ -243,13 +240,13 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
{
uint8_t *w = gpudata.ptrw();
uint8_t *dst = w;
- for (int i = 0; i < gpudata.size(); i++)
+ for (int i = 0; i < gpudata.size(); i++) {
dst[i] = 0x00;
+ }
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 +276,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 ea2b2b548f..ac4e534983 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -35,11 +35,11 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> 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)
+ if (p_buffer == nullptr) {
err = FAILED;
+ }
if (err == OK) {
size_t index = 0;
@@ -60,7 +60,6 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
ERR_FAIL_COND_V(height % 2 != 0, ERR_UNAVAILABLE);
} else if (bits_per_pixel == 16) {
-
ERR_FAIL_V(ERR_UNAVAILABLE);
}
@@ -153,7 +152,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
if (p_color_buffer == nullptr || color_table_size == 0) { // regular pixels
- p_image->create(width, height, 0, Image::FORMAT_RGBA8, data);
+ p_image->create(width, height, false, Image::FORMAT_RGBA8, data);
} else { // data is in indexed format, extend it
@@ -193,7 +192,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
dest += 4;
}
- p_image->create(width, height, 0, Image::FORMAT_RGBA8, extended_data);
+ p_image->create(width, height, false, Image::FORMAT_RGBA8, extended_data);
}
}
return err;
@@ -201,7 +200,6 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
bool p_force_linear, float p_scale) {
-
bmp_header_s bmp_header;
Error err = ERR_INVALID_DATA;
@@ -290,7 +288,6 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
void ImageLoaderBMP::get_recognized_extensions(
List<String> *p_extensions) const {
-
p_extensions->push_back("bmp");
}
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index 4d727529ef..79d8e252f0 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -44,19 +44,7 @@
*/
AreaBullet::AreaBullet() :
- RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA),
- monitorable(true),
- spOv_mode(PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED),
- spOv_gravityPoint(false),
- spOv_gravityPointDistanceScale(0),
- spOv_gravityPointAttenuation(1),
- spOv_gravityVec(0, -1, 0),
- spOv_gravityMag(10),
- spOv_linearDump(0.1),
- spOv_angularDump(1),
- spOv_priority(0),
- isScratched(false) {
-
+ RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA) {
btGhost = bulletnew(btGhostObject);
reload_shapes();
setupBulletCollisionObject(btGhost);
@@ -64,19 +52,22 @@ AreaBullet::AreaBullet() :
/// In order to use collision objects as trigger, you have to disable the collision response.
set_collision_enabled(false);
- for (int i = 0; i < 5; ++i)
+ for (int i = 0; i < 5; ++i) {
call_event_res_ptr[i] = &call_event_res[i];
+ }
}
AreaBullet::~AreaBullet() {
// signal are handled by godot, so just clear without notify
- for (int i = overlappingObjects.size() - 1; 0 <= i; --i)
+ for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
overlappingObjects[i].object->on_exit_area(this);
+ }
}
void AreaBullet::dispatch_callbacks() {
- if (!isScratched)
+ if (!isScratched) {
return;
+ }
isScratched = false;
// Reverse order because I've to remove EXIT objects
@@ -102,7 +93,6 @@ void AreaBullet::dispatch_callbacks() {
}
void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status) {
-
InOutEventCallback &event = eventsCallbacks[static_cast<int>(p_otherObject->getType())];
Object *areaGodoObject = ObjectDB::get_instance(event.event_callback_id);
@@ -122,15 +112,17 @@ void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3
}
void AreaBullet::scratch() {
- if (isScratched)
+ if (isScratched) {
return;
+ }
isScratched = true;
}
void AreaBullet::clear_overlaps(bool p_notify) {
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
- if (p_notify)
+ if (p_notify) {
call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED);
+ }
overlappingObjects[i].object->on_exit_area(this);
}
overlappingObjects.clear();
@@ -139,8 +131,9 @@ void AreaBullet::clear_overlaps(bool p_notify) {
void AreaBullet::remove_overlap(CollisionObjectBullet *p_object, bool p_notify) {
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
if (overlappingObjects[i].object == p_object) {
- if (p_notify)
+ if (p_notify) {
call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED);
+ }
overlappingObjects[i].object->on_exit_area(this);
overlappingObjects.remove(i);
break;
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index 0272350510..c0bcc858fe 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -61,12 +61,10 @@ public:
};
struct OverlappingObjectData {
- CollisionObjectBullet *object;
- OverlapState state;
+ CollisionObjectBullet *object = nullptr;
+ OverlapState state = OVERLAP_STATE_ENTER;
- OverlappingObjectData() :
- object(nullptr),
- state(OVERLAP_STATE_ENTER) {}
+ OverlappingObjectData() {}
OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) :
object(p_object),
state(p_state) {}
@@ -86,19 +84,19 @@ private:
btGhostObject *btGhost;
Vector<OverlappingObjectData> overlappingObjects;
- bool monitorable;
-
- PhysicsServer3D::AreaSpaceOverrideMode spOv_mode;
- bool spOv_gravityPoint;
- real_t spOv_gravityPointDistanceScale;
- real_t spOv_gravityPointAttenuation;
- Vector3 spOv_gravityVec;
- real_t spOv_gravityMag;
- real_t spOv_linearDump;
- real_t spOv_angularDump;
- int spOv_priority;
-
- bool isScratched;
+ bool monitorable = true;
+
+ PhysicsServer3D::AreaSpaceOverrideMode spOv_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
+ bool spOv_gravityPoint = false;
+ real_t spOv_gravityPointDistanceScale = 0;
+ real_t spOv_gravityPointAttenuation = 1;
+ Vector3 spOv_gravityVec = Vector3(0, -1, 0);
+ real_t spOv_gravityMag = 10;
+ real_t spOv_linearDump = 0.1;
+ real_t spOv_angularDump = 0.1;
+ int spOv_priority = 0;
+
+ bool isScratched = false;
InOutEventCallback eventsCallbacks[2];
diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp
index 0f54f848dc..a754ca6a89 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;
}
@@ -70,10 +68,11 @@ btVector3 btRayShape::localGetSupportingVertex(const btVector3 &vec) const {
}
btVector3 btRayShape::localGetSupportingVertexWithoutMargin(const btVector3 &vec) const {
- if (vec.z() > 0)
+ if (vec.z() > 0) {
return m_shapeAxis * m_cacheScaledLength;
- else
+ } else {
return btVector3(0, 0, 0);
+ }
}
void btRayShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const {
@@ -101,7 +100,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 2705c749a2..55686543f3 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -79,9 +79,7 @@ void BulletPhysicsServer3D::_bind_methods() {
}
BulletPhysicsServer3D::BulletPhysicsServer3D() :
- PhysicsServer3D(),
- active(true),
- active_spaces_count(0) {}
+ PhysicsServer3D() {}
BulletPhysicsServer3D::~BulletPhysicsServer3D() {}
@@ -90,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: {
@@ -178,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);
@@ -337,8 +326,9 @@ void BulletPhysicsServer3D::area_clear_shapes(RID p_area) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- for (int i = area->get_shape_count(); 0 < i; --i)
+ for (int i = area->get_shape_count(); 0 < i; --i) {
area->remove_shape_full(0);
+ }
}
void BulletPhysicsServer3D::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
@@ -373,7 +363,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);
@@ -455,8 +444,9 @@ RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) {
body->set_mode(p_mode);
body->set_collision_layer(1);
body->set_collision_mask(1);
- if (p_init_sleeping)
+ if (p_init_sleeping) {
body->set_state(BODY_STATE_SLEEPING, p_init_sleeping);
+ }
CreateThenReturnRID(rigid_body_owner, body);
}
@@ -470,8 +460,9 @@ void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) {
ERR_FAIL_COND(!space);
}
- if (body->get_space() == space)
+ if (body->get_space() == space) {
return; //pointles
+ }
body->set_space(space);
}
@@ -481,8 +472,9 @@ RID BulletPhysicsServer3D::body_get_space(RID p_body) const {
ERR_FAIL_COND_V(!body, RID());
SpaceBullet *space = body->get_space();
- if (!space)
+ if (!space) {
return RID();
+ }
return space->get_self();
}
@@ -499,7 +491,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);
@@ -653,7 +644,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);
}
}
@@ -663,7 +653,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;
}
@@ -885,8 +874,9 @@ RID BulletPhysicsServer3D::soft_body_create(bool p_init_sleeping) {
SoftBodyBullet *body = bulletnew(SoftBodyBullet);
body->set_collision_layer(1);
body->set_collision_mask(1);
- if (p_init_sleeping)
+ if (p_init_sleeping) {
body->set_activation_state(false);
+ }
CreateThenReturnRID(soft_body_owner, body);
}
@@ -907,8 +897,9 @@ void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) {
ERR_FAIL_COND(!space);
}
- if (body->get_space() == space)
+ if (body->get_space() == space) {
return; //pointles
+ }
body->set_space(space);
}
@@ -918,8 +909,9 @@ RID BulletPhysicsServer3D::soft_body_get_space(RID p_body) const {
ERR_FAIL_COND_V(!body, RID());
SpaceBullet *space = body->get_space();
- if (!space)
+ if (!space) {
return RID();
+ }
return space->get_self();
}
@@ -1489,7 +1481,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
@@ -1500,7 +1491,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);
@@ -1511,7 +1501,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);
@@ -1520,7 +1509,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);
@@ -1531,14 +1519,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();
@@ -1547,7 +1533,6 @@ void BulletPhysicsServer3D::free(RID p_rid) {
space_owner.free(p_rid);
bulletdelete(space);
} else {
-
ERR_FAIL_MSG("Invalid ID.");
}
}
@@ -1557,13 +1542,13 @@ void BulletPhysicsServer3D::init() {
}
void BulletPhysicsServer3D::step(float p_deltaTime) {
- if (!active)
+ if (!active) {
return;
+ }
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/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index ea9c5e589e..558d1ce5f7 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -40,6 +40,7 @@
#include "shape_bullet.h"
#include "soft_body_bullet.h"
#include "space_bullet.h"
+
/**
@author AndreaCatania
*/
@@ -49,8 +50,8 @@ class BulletPhysicsServer3D : public PhysicsServer3D {
friend class BulletPhysicsDirectSpaceState;
- bool active;
- char active_spaces_count;
+ bool active = true;
+ char active_spaces_count = 0;
Vector<SpaceBullet *> active_spaces;
mutable RID_PtrOwner<SpaceBullet> space_owner;
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 1b72c2f577..a3158a15e5 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -80,27 +80,17 @@ btTransform CollisionObjectBullet::ShapeWrapper::get_adjusted_transform() const
void CollisionObjectBullet::ShapeWrapper::claim_bt_shape(const btVector3 &body_scale) {
if (!bt_shape) {
- if (active)
+ if (active) {
bt_shape = shape->create_bt_shape(scale * body_scale);
- else
+ } else {
bt_shape = ShapeBullet::create_shape_empty();
+ }
}
}
CollisionObjectBullet::CollisionObjectBullet(Type p_type) :
RIDBullet(),
- type(p_type),
- instance_id(ObjectID()),
- collisionLayer(0),
- collisionMask(0),
- collisionsEnabled(true),
- m_isStatic(false),
- ray_pickable(false),
- bt_collision_object(nullptr),
- body_scale(1., 1., 1.),
- force_shape_reset(false),
- space(nullptr),
- isTransformChanged(false) {}
+ type(p_type) {}
CollisionObjectBullet::~CollisionObjectBullet() {
// Remove all overlapping, notify is not required since godot take care of it
@@ -147,18 +137,21 @@ void CollisionObjectBullet::setupBulletCollisionObject(btCollisionObject *p_coll
void CollisionObjectBullet::add_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) {
exceptions.insert(p_ignoreCollisionObject->get_self());
- if (!bt_collision_object)
+ if (!bt_collision_object) {
return;
+ }
bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, true);
- if (space)
+ if (space) {
space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher());
+ }
}
void CollisionObjectBullet::remove_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) {
exceptions.erase(p_ignoreCollisionObject->get_self());
bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, false);
- if (space)
+ if (space) {
space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher());
+ }
}
bool CollisionObjectBullet::has_collision_exception(const CollisionObjectBullet *p_otherCollisionObject) const {
@@ -195,7 +188,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;
@@ -225,11 +217,6 @@ void CollisionObjectBullet::notify_transform_changed() {
isTransformChanged = true;
}
-RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) :
- CollisionObjectBullet(p_type),
- mainShape(nullptr) {
-}
-
RigidCollisionObjectBullet::~RigidCollisionObjectBullet() {
remove_all_shapes(true, true);
if (mainShape && mainShape->isCompound()) {
@@ -266,8 +253,9 @@ btCollisionShape *RigidCollisionObjectBullet::get_bt_shape(int p_index) const {
int RigidCollisionObjectBullet::find_shape(ShapeBullet *p_shape) const {
const int size = shapes.size();
for (int i = 0; i < size; ++i) {
- if (shapes[i].shape == p_shape)
+ if (shapes[i].shape == p_shape) {
return i;
+ }
}
return -1;
}
@@ -297,8 +285,9 @@ void RigidCollisionObjectBullet::remove_all_shapes(bool p_permanentlyFromThisBod
internal_shape_destroy(i, p_permanentlyFromThisBody);
}
shapes.clear();
- if (!p_force_not_reload)
+ if (!p_force_not_reload) {
reload_shapes();
+ }
}
void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transform &p_transform) {
@@ -319,8 +308,9 @@ Transform RigidCollisionObjectBullet::get_shape_transform(int p_index) const {
}
void RigidCollisionObjectBullet::set_shape_disabled(int p_index, bool p_disabled) {
- if (shapes[p_index].active != p_disabled)
+ if (shapes[p_index].active != p_disabled) {
return;
+ }
shapes.write[p_index].active = !p_disabled;
shape_changed(p_index);
}
@@ -339,7 +329,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/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h
index 25176458a7..f1423a69e4 100644
--- a/modules/bullet/collision_object_bullet.h
+++ b/modules/bullet/collision_object_bullet.h
@@ -69,27 +69,22 @@ public:
};
struct ShapeWrapper {
- ShapeBullet *shape;
- btCollisionShape *bt_shape;
+ ShapeBullet *shape = nullptr;
+ btCollisionShape *bt_shape = nullptr;
btTransform transform;
btVector3 scale;
- bool active;
+ bool active = true;
- ShapeWrapper() :
- shape(nullptr),
- bt_shape(nullptr),
- active(true) {}
+ ShapeWrapper() {}
ShapeWrapper(ShapeBullet *p_shape, const btTransform &p_transform, bool p_active) :
shape(p_shape),
- bt_shape(nullptr),
active(p_active) {
set_transform(p_transform);
}
ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) :
shape(p_shape),
- bt_shape(nullptr),
active(p_active) {
set_transform(p_transform);
}
@@ -117,15 +112,15 @@ public:
protected:
Type type;
ObjectID instance_id;
- uint32_t collisionLayer;
- uint32_t collisionMask;
- bool collisionsEnabled;
- bool m_isStatic;
- bool ray_pickable;
- btCollisionObject *bt_collision_object;
- Vector3 body_scale;
- bool force_shape_reset;
- SpaceBullet *space;
+ uint32_t collisionLayer = 0;
+ uint32_t collisionMask = 0;
+ bool collisionsEnabled = true;
+ bool m_isStatic = false;
+ bool ray_pickable = false;
+ btCollisionObject *bt_collision_object = nullptr;
+ Vector3 body_scale = Vector3(1, 1, 1);
+ bool force_shape_reset = false;
+ SpaceBullet *space = nullptr;
VSet<RID> exceptions;
@@ -133,7 +128,7 @@ protected:
/// New area is added when overlap with new area (AreaBullet::addOverlap), then is removed when it exit (CollisionObjectBullet::onExitArea)
/// This array is used mainly to know which area hold the pointer of this object
Vector<AreaBullet *> areasOverlapped;
- bool isTransformChanged;
+ bool isTransformChanged = false;
public:
CollisionObjectBullet(Type p_type);
@@ -218,11 +213,12 @@ public:
class RigidCollisionObjectBullet : public CollisionObjectBullet, public ShapeOwnerBullet {
protected:
- btCollisionShape *mainShape;
+ btCollisionShape *mainShape = nullptr;
Vector<ShapeWrapper> shapes;
public:
- RigidCollisionObjectBullet(Type p_type);
+ RigidCollisionObjectBullet(Type p_type) :
+ CollisionObjectBullet(p_type) {}
~RigidCollisionObjectBullet();
_FORCE_INLINE_ const Vector<ShapeWrapper> &get_shapes_wrappers() const { return shapes; }
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.cpp b/modules/bullet/constraint_bullet.cpp
index 469b58521e..c47a23e75f 100644
--- a/modules/bullet/constraint_bullet.cpp
+++ b/modules/bullet/constraint_bullet.cpp
@@ -37,10 +37,7 @@
@author AndreaCatania
*/
-ConstraintBullet::ConstraintBullet() :
- space(nullptr),
- constraint(nullptr),
- disabled_collisions_between_bodies(true) {}
+ConstraintBullet::ConstraintBullet() {}
void ConstraintBullet::setup(btTypedConstraint *p_constraint) {
constraint = p_constraint;
diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h
index 1946807bad..538808be51 100644
--- a/modules/bullet/constraint_bullet.h
+++ b/modules/bullet/constraint_bullet.h
@@ -45,11 +45,10 @@ class SpaceBullet;
class btTypedConstraint;
class ConstraintBullet : public RIDBullet {
-
protected:
- SpaceBullet *space;
- btTypedConstraint *constraint;
- bool disabled_collisions_between_bodies;
+ SpaceBullet *space = nullptr;
+ btTypedConstraint *constraint = nullptr;
+ bool disabled_collisions_between_bodies = true;
public:
ConstraintBullet();
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 2ef277cf5b..a84f3511ba 100644
--- a/modules/bullet/godot_ray_world_algorithm.cpp
+++ b/modules/bullet/godot_ray_world_algorithm.cpp
@@ -52,7 +52,6 @@ GodotRayWorldAlgorithm::GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *wo
btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap),
m_world(world),
m_manifoldPtr(mf),
- m_ownManifold(false),
m_isSwapped(isSwapped) {}
GodotRayWorldAlgorithm::~GodotRayWorldAlgorithm() {
@@ -62,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());
@@ -80,13 +78,11 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo
const btCollisionObjectWrapper *other_co_wrapper;
if (m_isSwapped) {
-
ray_shape = static_cast<const btRayShape *>(body1Wrap->getCollisionShape());
ray_transform = body1Wrap->getWorldTransform();
other_co_wrapper = body0Wrap;
} else {
-
ray_shape = static_cast<const btRayShape *>(body0Wrap->getCollisionShape());
ray_transform = body0Wrap->getWorldTransform();
@@ -100,15 +96,15 @@ 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)
+ if (depth > -RAY_PENETRATION_DEPTH_EPSILON) {
depth = 0.0;
+ }
- if (ray_shape->getSlipsOnSlope())
+ if (ray_shape->getSlipsOnSlope()) {
resultOut->addContactPoint(btResult.m_hitNormalWorld, btResult.m_hitPointWorld, depth);
- else {
+ } else {
resultOut->addContactPoint((ray_transform.getOrigin() - to.getOrigin()).normalize(), btResult.m_hitPointWorld, depth);
}
}
diff --git a/modules/bullet/godot_ray_world_algorithm.h b/modules/bullet/godot_ray_world_algorithm.h
index 2cdea6c133..9786732d40 100644
--- a/modules/bullet/godot_ray_world_algorithm.h
+++ b/modules/bullet/godot_ray_world_algorithm.h
@@ -42,10 +42,9 @@
class btDiscreteDynamicsWorld;
class GodotRayWorldAlgorithm : public btActivatingCollisionAlgorithm {
-
const btDiscreteDynamicsWorld *m_world;
btPersistentManifold *m_manifoldPtr;
- bool m_ownManifold;
+ bool m_ownManifold = false;
bool m_isSwapped;
public:
@@ -57,11 +56,11 @@ public:
virtual void getAllContactManifolds(btManifoldArray &manifoldArray) {
///should we use m_ownManifold to avoid adding duplicates?
- if (m_manifoldPtr && m_ownManifold)
+ if (m_manifoldPtr && m_ownManifold) {
manifoldArray.push_back(m_manifoldPtr);
+ }
}
struct CreateFunc : public btCollisionAlgorithmCreateFunc {
-
const btDiscreteDynamicsWorld *m_world;
CreateFunc(const btDiscreteDynamicsWorld *world);
@@ -72,7 +71,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..f82648d6ff 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -62,11 +62,13 @@ bool GodotClosestRayResultCallback::needsCollision(btBroadphaseProxy *proxy0) co
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());
if (CollisionObjectBullet::TYPE_AREA == gObj->getType()) {
- if (!collide_with_areas)
+ if (!collide_with_areas) {
return false;
+ }
} else {
- if (!collide_with_bodies)
+ if (!collide_with_bodies) {
return false;
+ }
}
if (m_pickRay && !gObj->is_ray_pickable()) {
@@ -84,8 +86,9 @@ bool GodotClosestRayResultCallback::needsCollision(btBroadphaseProxy *proxy0) co
}
bool GodotAllConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
- if (count >= m_resultMax)
+ if (count >= m_resultMax) {
return false;
+ }
const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask);
if (needs) {
@@ -102,8 +105,9 @@ bool GodotAllConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) con
}
btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace) {
- if (count >= m_resultMax)
+ if (count >= m_resultMax) {
return 1; // not used by bullet
+ }
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(convexResult.m_hitCollisionObject->getUserPointer());
@@ -126,16 +130,18 @@ 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())
+ if (m_infinite_inertia && !btObj->isStaticOrKinematicObject()) {
return false;
+ }
- if (gObj->getType() == CollisionObjectBullet::TYPE_AREA)
+ if (gObj->getType() == CollisionObjectBullet::TYPE_AREA) {
return false;
+ }
- if (m_self_object->has_collision_exception(gObj) || gObj->has_collision_exception(m_self_object))
+ if (m_self_object->has_collision_exception(gObj) || gObj->has_collision_exception(m_self_object)) {
return false;
+ }
}
return true;
} else {
@@ -150,11 +156,13 @@ bool GodotClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0)
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());
if (CollisionObjectBullet::TYPE_AREA == gObj->getType()) {
- if (!collide_with_areas)
+ if (!collide_with_areas) {
return false;
+ }
} else {
- if (!collide_with_bodies)
+ if (!collide_with_bodies) {
return false;
+ }
}
if (m_exclude->has(gObj->get_self())) {
@@ -167,16 +175,18 @@ bool GodotClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0)
}
btScalar GodotClosestConvexResultCallback::addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace) {
- if (convexResult.m_localShapeInfo)
+ if (convexResult.m_localShapeInfo) {
m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
- else
+ } else {
m_shapeId = 0;
+ }
return btCollisionWorld::ClosestConvexResultCallback::addSingleResult(convexResult, normalInWorldSpace);
}
bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
- if (m_count >= m_resultMax)
+ if (m_count >= m_resultMax) {
return false;
+ }
const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask);
if (needs) {
@@ -184,11 +194,13 @@ bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) co
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());
if (CollisionObjectBullet::TYPE_AREA == gObj->getType()) {
- if (!collide_with_areas)
+ if (!collide_with_areas) {
return false;
+ }
} else {
- if (!collide_with_bodies)
+ if (!collide_with_bodies) {
return false;
+ }
}
if (m_exclude->has(gObj->get_self())) {
@@ -201,12 +213,11 @@ 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)
+ if (m_count >= m_resultMax) {
return cp.getDistance();
+ }
if (cp.getDistance() <= 0) {
-
PhysicsDirectSpaceState3D::ShapeResult &result = m_results[m_count];
// Penetrated
@@ -229,8 +240,9 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
}
bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
- if (m_count >= m_resultMax)
+ if (m_count >= m_resultMax) {
return false;
+ }
const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask);
if (needs) {
@@ -238,11 +250,13 @@ bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *pr
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());
if (CollisionObjectBullet::TYPE_AREA == gObj->getType()) {
- if (!collide_with_areas)
+ if (!collide_with_areas) {
return false;
+ }
} else {
- if (!collide_with_bodies)
+ if (!collide_with_bodies) {
return false;
+ }
}
if (m_exclude->has(gObj->get_self())) {
@@ -255,8 +269,9 @@ bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *pr
}
btScalar GodotContactPairContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) {
- if (m_count >= m_resultMax)
+ if (m_count >= m_resultMax) {
return 1; // not used by bullet
+ }
if (m_self_object == colObj0Wrap->getCollisionObject()) {
B_TO_G(cp.m_localPointA, m_results[m_count * 2 + 0]); // Local contact
@@ -278,11 +293,13 @@ bool GodotRestInfoContactResultCallback::needsCollision(btBroadphaseProxy *proxy
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());
if (CollisionObjectBullet::TYPE_AREA == gObj->getType()) {
- if (!collide_with_areas)
+ if (!collide_with_areas) {
return false;
+ }
} else {
- if (!collide_with_bodies)
+ if (!collide_with_bodies) {
return false;
+ }
}
if (m_exclude->has(gObj->get_self())) {
@@ -295,7 +312,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 +341,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/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 7e74a2b22e..1325542973 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -56,8 +56,8 @@ struct GodotFilterCallback : public btOverlapFilterCallback {
/// It performs an additional check allow exclusions.
struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResultCallback {
const Set<RID> *m_exclude;
- bool m_pickRay;
- int m_shapeId;
+ bool m_pickRay = false;
+ int m_shapeId = 0;
bool collide_with_bodies;
bool collide_with_areas;
@@ -66,18 +66,17 @@ public:
GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld),
m_exclude(p_exclude),
- m_pickRay(false),
- m_shapeId(0),
collide_with_bodies(p_collide_with_bodies),
collide_with_areas(p_collide_with_areas) {}
virtual bool needsCollision(btBroadphaseProxy *proxy0) const;
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace) {
- if (rayResult.m_localShapeInfo)
+ if (rayResult.m_localShapeInfo) {
m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
- else
+ } else {
m_shapeId = 0;
+ }
return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
}
};
@@ -88,13 +87,12 @@ public:
PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
- int count;
+ int count = 0;
GodotAllConvexResultCallback(PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) :
m_results(p_results),
m_resultMax(p_resultMax),
- m_exclude(p_exclude),
- count(0) {}
+ m_exclude(p_exclude) {}
virtual bool needsCollision(btBroadphaseProxy *proxy0) const;
@@ -117,7 +115,7 @@ public:
struct GodotClosestConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback {
public:
const Set<RID> *m_exclude;
- int m_shapeId;
+ int m_shapeId = 0;
bool collide_with_bodies;
bool collide_with_areas;
@@ -125,7 +123,6 @@ public:
GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld),
m_exclude(p_exclude),
- m_shapeId(0),
collide_with_bodies(p_collide_with_bodies),
collide_with_areas(p_collide_with_areas) {}
@@ -140,7 +137,7 @@ public:
PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
- int m_count;
+ int m_count = 0;
bool collide_with_bodies;
bool collide_with_areas;
@@ -150,7 +147,6 @@ public:
m_results(p_results),
m_resultMax(p_resultMax),
m_exclude(p_exclude),
- m_count(0),
collide_with_bodies(p_collide_with_bodies),
collide_with_areas(p_collide_with_areas) {}
@@ -166,7 +162,7 @@ public:
Vector3 *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
- int m_count;
+ int m_count = 0;
bool collide_with_bodies;
bool collide_with_areas;
@@ -176,7 +172,6 @@ public:
m_results(p_results),
m_resultMax(p_resultMax),
m_exclude(p_exclude),
- m_count(0),
collide_with_bodies(p_collide_with_bodies),
collide_with_areas(p_collide_with_areas) {}
@@ -190,8 +185,8 @@ public:
const btCollisionObject *m_self_object;
PhysicsDirectSpaceState3D::ShapeRestInfo *m_result;
const Set<RID> *m_exclude;
- bool m_collided;
- real_t m_min_distance;
+ bool m_collided = false;
+ real_t m_min_distance = 0;
const btCollisionObject *m_rest_info_collision_object;
btVector3 m_rest_info_bt_point;
bool collide_with_bodies;
@@ -201,8 +196,6 @@ public:
m_self_object(p_self_object),
m_result(p_result),
m_exclude(p_exclude),
- m_collided(false),
- m_min_distance(0),
collide_with_bodies(p_collide_with_bodies),
collide_with_areas(p_collide_with_areas) {}
@@ -214,13 +207,11 @@ public:
struct GodotDeepPenetrationContactResultCallback : public btManifoldResult {
btVector3 m_pointNormalWorld;
btVector3 m_pointWorld;
- btScalar m_penetration_distance;
- int m_other_compound_shape_index;
+ btScalar m_penetration_distance = 0;
+ int m_other_compound_shape_index = 0;
GodotDeepPenetrationContactResultCallback(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap) :
- btManifoldResult(body0Wrap, body1Wrap),
- m_penetration_distance(0),
- m_other_compound_shape_index(0) {}
+ btManifoldResult(body0Wrap, body1Wrap) {}
void reset() {
m_penetration_distance = 0;
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 e393396713..9aac7ba9e4 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -256,26 +256,7 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) {
}
RigidBodyBullet::RigidBodyBullet() :
- RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY),
- kinematic_utilities(nullptr),
- locked_axis(0),
- mass(1),
- gravity_scale(1),
- linearDamp(0),
- angularDamp(0),
- can_sleep(true),
- omit_forces_integration(false),
- can_integrate_forces(false),
- maxCollisionsDetection(0),
- collisionsCount(0),
- prev_collision_count(0),
- maxAreasWhereIam(10),
- areaWhereIamCount(0),
- countGravityPointSpaces(0),
- isScratchedSpaceOverrideModificator(false),
- previousActiveState(true),
- force_integration_callback(nullptr) {
-
+ RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY) {
godotMotionState = bulletnew(GodotMotionState(this));
// Initial properties
@@ -302,8 +283,9 @@ RigidBodyBullet::RigidBodyBullet() :
RigidBodyBullet::~RigidBodyBullet() {
bulletdelete(godotMotionState);
- if (force_integration_callback)
+ if (force_integration_callback) {
memdelete(force_integration_callback);
+ }
destroy_kinematic_utilities();
}
@@ -328,8 +310,9 @@ void RigidBodyBullet::main_shape_changed() {
void RigidBodyBullet::reload_body() {
if (space) {
space->remove_rigid_body(this);
- if (get_main_shape())
+ if (get_main_shape()) {
space->add_rigid_body(this);
+ }
}
}
@@ -355,9 +338,9 @@ 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)
+ if (omit_forces_integration) {
btBody->clearForces();
+ }
BulletPhysicsDirectBodyState3D *bodyDirect = BulletPhysicsDirectBodyState3D::get_singleton(this);
@@ -389,7 +372,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;
@@ -416,7 +398,6 @@ void RigidBodyBullet::on_collision_filters_change() {
}
void RigidBodyBullet::on_collision_checker_start() {
-
prev_collision_count = collisionsCount;
collisionsCount = 0;
@@ -432,7 +413,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;
}
@@ -454,8 +434,9 @@ bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const
bool RigidBodyBullet::was_colliding(RigidBodyBullet *p_other_object) {
for (int i = prev_collision_count - 1; 0 <= i; --i) {
- if ((*prev_collision_traces)[i] == p_other_object)
+ if ((*prev_collision_traces)[i] == p_other_object) {
return true;
+ }
}
return false;
}
@@ -464,11 +445,6 @@ void RigidBodyBullet::assert_no_constraints() {
if (btBody->getNumConstraintRefs()) {
WARN_PRINT("A body with a joints is destroyed. Please check the implementation in order to destroy the joint before the body.");
}
- /*for(int i = btBody->getNumConstraintRefs()-1; 0<=i; --i){
- btTypedConstraint* btConst = btBody->getConstraintRef(i);
- JointBullet* joint = static_cast<JointBullet*>( btConst->getUserConstraintPtr() );
- space->removeConstraint(joint);
- }*/
}
void RigidBodyBullet::set_activation_state(bool p_active) {
@@ -578,12 +554,12 @@ void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) {
btBody->setAngularVelocity(btVector3(0, 0, 0));
btBody->setLinearVelocity(btVector3(0, 0, 0));
}
+
PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const {
return mode;
}
void RigidBodyBullet::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
-
switch (p_state) {
case PhysicsServer3D::BODY_STATE_TRANSFORM:
set_transform(p_variant);
@@ -630,8 +606,9 @@ Variant RigidBodyBullet::get_state(PhysicsServer3D::BodyState p_state) const {
void RigidBodyBullet::apply_central_impulse(const Vector3 &p_impulse) {
btVector3 btImpu;
G_TO_B(p_impulse, btImpu);
- if (Vector3() != p_impulse)
+ if (Vector3() != p_impulse) {
btBody->activate();
+ }
btBody->applyCentralImpulse(btImpu);
}
@@ -640,16 +617,18 @@ void RigidBodyBullet::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impul
btVector3 btPos;
G_TO_B(p_impulse, btImpu);
G_TO_B(p_pos, btPos);
- if (Vector3() != p_impulse)
+ if (Vector3() != p_impulse) {
btBody->activate();
+ }
btBody->applyImpulse(btImpu, btPos);
}
void RigidBodyBullet::apply_torque_impulse(const Vector3 &p_impulse) {
btVector3 btImp;
G_TO_B(p_impulse, btImp);
- if (Vector3() != p_impulse)
+ if (Vector3() != p_impulse) {
btBody->activate();
+ }
btBody->applyTorqueImpulse(btImp);
}
@@ -658,32 +637,36 @@ void RigidBodyBullet::apply_force(const Vector3 &p_force, const Vector3 &p_pos)
btVector3 btPos;
G_TO_B(p_force, btForce);
G_TO_B(p_pos, btPos);
- if (Vector3() != p_force)
+ if (Vector3() != p_force) {
btBody->activate();
+ }
btBody->applyForce(btForce, btPos);
}
void RigidBodyBullet::apply_central_force(const Vector3 &p_force) {
btVector3 btForce;
G_TO_B(p_force, btForce);
- if (Vector3() != p_force)
+ if (Vector3() != p_force) {
btBody->activate();
+ }
btBody->applyCentralForce(btForce);
}
void RigidBodyBullet::apply_torque(const Vector3 &p_torque) {
btVector3 btTorq;
G_TO_B(p_torque, btTorq);
- if (Vector3() != p_torque)
+ if (Vector3() != p_torque) {
btBody->activate();
+ }
btBody->applyTorque(btTorq);
}
void RigidBodyBullet::set_applied_force(const Vector3 &p_force) {
btVector3 btVec = btBody->getTotalTorque();
- if (Vector3() != p_force)
+ if (Vector3() != p_force) {
btBody->activate();
+ }
btBody->clearForces();
btBody->applyTorque(btVec);
@@ -701,8 +684,9 @@ Vector3 RigidBodyBullet::get_applied_force() const {
void RigidBodyBullet::set_applied_torque(const Vector3 &p_torque) {
btVector3 btVec = btBody->getTotalForce();
- if (Vector3() != p_torque)
+ if (Vector3() != p_torque) {
btBody->activate();
+ }
btBody->clearForces();
btBody->applyCentralForce(btVec);
@@ -732,7 +716,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
@@ -771,8 +754,9 @@ bool RigidBodyBullet::is_continuous_collision_detection_enabled() const {
void RigidBodyBullet::set_linear_velocity(const Vector3 &p_velocity) {
btVector3 btVec;
G_TO_B(p_velocity, btVec);
- if (Vector3() != p_velocity)
+ if (Vector3() != p_velocity) {
btBody->activate();
+ }
btBody->setLinearVelocity(btVec);
}
@@ -785,8 +769,9 @@ Vector3 RigidBodyBullet::get_linear_velocity() const {
void RigidBodyBullet::set_angular_velocity(const Vector3 &p_velocity) {
btVector3 btVec;
G_TO_B(p_velocity, btVec);
- if (Vector3() != p_velocity)
+ if (Vector3() != p_velocity) {
btBody->activate();
+ }
btBody->setAngularVelocity(btVec);
}
@@ -798,8 +783,9 @@ Vector3 RigidBodyBullet::get_angular_velocity() const {
void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) {
if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
- if (space && space->get_delta_time() != 0)
+ if (space && space->get_delta_time() != 0) {
btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time());
+ }
// The kinematic use MotionState class
godotMotionState->moveBody(p_global_transform);
} else {
@@ -811,10 +797,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();
}
}
@@ -830,8 +814,9 @@ void RigidBodyBullet::reload_shapes() {
// shapes incorrectly do not set the vector in calculateLocalIntertia.
// Arbitrary zero is preferable to undefined behaviour.
btVector3 inertia(0, 0, 0);
- if (EMPTY_SHAPE_PROXYTYPE != mainShape->getShapeType()) // Necessary to avoid assertion of the empty shape
+ if (EMPTY_SHAPE_PROXYTYPE != mainShape->getShapeType()) { // Necessary to avoid assertion of the empty shape
mainShape->calculateLocalInertia(mass, inertia);
+ }
btBody->setMassProps(mass, inertia);
}
btBody->updateInertiaTensor();
@@ -849,7 +834,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;
@@ -906,8 +890,9 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
void RigidBodyBullet::reload_space_override_modificator() {
// Make sure that kinematic bodies have their total gravity calculated
- if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode)
+ if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) {
return;
+ }
Vector3 newGravity(0.0, 0.0, 0.0);
real_t newLinearDamp = MAX(0.0, linearDamp);
@@ -919,7 +904,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()) {
@@ -928,7 +912,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();
@@ -1022,7 +1005,6 @@ void RigidBodyBullet::notify_transform_changed() {
}
void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
-
btVector3 localInertia(0, 0, 0);
int clearedCurrentFlags = btBody->getCollisionFlags();
@@ -1031,19 +1013,18 @@ 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)
+ if (PhysicsServer3D::BODY_MODE_RIGID != mode && PhysicsServer3D::BODY_MODE_CHARACTER != mode) {
return;
+ }
m_isStatic = false;
- if (mainShape)
+ if (mainShape) {
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);
}
@@ -1053,16 +1034,14 @@ 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)
+ 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 420b5cc443..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;
@@ -162,11 +161,10 @@ public:
/// Used to hold shapes
struct KinematicShape {
- class btConvexShape *shape;
+ class btConvexShape *shape = nullptr;
btTransform transform;
- KinematicShape() :
- shape(nullptr) {}
+ KinematicShape() {}
bool is_active() const { return shape; }
};
@@ -190,19 +188,19 @@ private:
friend class BulletPhysicsDirectBodyState3D;
// This is required only for Kinematic movement
- KinematicUtilities *kinematic_utilities;
+ KinematicUtilities *kinematic_utilities = nullptr;
PhysicsServer3D::BodyMode mode;
GodotMotionState *godotMotionState;
btRigidBody *btBody;
- uint16_t locked_axis;
- real_t mass;
- real_t gravity_scale;
- real_t linearDamp;
- real_t angularDamp;
- bool can_sleep;
- bool omit_forces_integration;
- bool can_integrate_forces;
+ uint16_t locked_axis = 0;
+ real_t mass = 1;
+ real_t gravity_scale = 1;
+ real_t linearDamp = 0;
+ real_t angularDamp = 0;
+ bool can_sleep = true;
+ bool omit_forces_integration = false;
+ bool can_integrate_forces = false;
Vector<CollisionData> collisions;
Vector<RigidBodyBullet *> collision_traces_1;
@@ -211,21 +209,21 @@ private:
Vector<RigidBodyBullet *> *curr_collision_traces;
// these parameters are used to avoid vector resize
- int maxCollisionsDetection;
- int collisionsCount;
- int prev_collision_count;
+ int maxCollisionsDetection = 0;
+ int collisionsCount = 0;
+ int prev_collision_count = 0;
Vector<AreaBullet *> areasWhereIam;
// these parameters are used to avoid vector resize
- int maxAreasWhereIam;
- int areaWhereIamCount;
+ int maxAreasWhereIam = 10;
+ int areaWhereIamCount = 0;
// Used to know if the area is used as gravity point
- int countGravityPointSpaces;
- bool isScratchedSpaceOverrideModificator;
+ int countGravityPointSpaces = 0;
+ bool isScratchedSpaceOverrideModificator = false;
- bool previousActiveState; // Last check state
+ bool previousActiveState = true; // Last check state
- ForceIntegrationCallback *force_integration_callback;
+ ForceIntegrationCallback *force_integration_callback = nullptr;
public:
RigidBodyBullet();
@@ -250,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 5bcb4743c9..d53f1e7d17 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -46,8 +46,7 @@
@author AndreaCatania
*/
-ShapeBullet::ShapeBullet() :
- margin(0.04) {}
+ShapeBullet::ShapeBullet() {}
ShapeBullet::~ShapeBullet() {}
@@ -81,8 +80,9 @@ void ShapeBullet::add_owner(ShapeOwnerBullet *p_owner) {
void ShapeBullet::remove_owner(ShapeOwnerBullet *p_owner, bool p_permanentlyFromThisBody) {
Map<ShapeOwnerBullet *, int>::Element *E = owners.find(p_owner);
- if (!E)
+ if (!E) {
return;
+ }
E->get()--;
if (p_permanentlyFromThisBody || 0 >= E->get()) {
owners.erase(E);
@@ -90,7 +90,6 @@ void ShapeBullet::remove_owner(ShapeOwnerBullet *p_owner, bool p_permanentlyFrom
}
bool ShapeBullet::is_owner(ShapeOwnerBullet *p_owner) const {
-
return owners.has(p_owner);
}
@@ -152,8 +151,9 @@ btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(Vector<real_t>
btHeightfieldTerrainShape *heightfield = bulletnew(btHeightfieldTerrainShape(p_width, p_depth, heightsPtr, ignoredHeightScale, p_min_height, p_max_height, YAxis, PHY_FLOAT, flipQuadEdges));
// The shape can be created without params when you do PhysicsServer3D.shape_create(PhysicsServer3D.SHAPE_HEIGHTMAP)
- if (heightsPtr)
+ if (heightsPtr) {
heightfield->buildAccelerator(16);
+ }
return heightfield;
}
@@ -350,9 +350,10 @@ void ConvexPolygonShapeBullet::setup(const Vector<Vector3> &p_vertices) {
}
btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) {
- if (!vertices.size())
+ if (!vertices.size()) {
// This is necessary since 0 vertices
return prepare(ShapeBullet::create_shape_empty());
+ }
btCollisionShape *cs(ShapeBullet::create_shape_convex(vertices));
cs->setLocalScaling(p_implicit_scale);
prepare(cs);
@@ -362,8 +363,7 @@ btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape(const btVector3 &p_i
/* Concave polygon */
ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() :
- ShapeBullet(),
- meshShape(nullptr) {}
+ ShapeBullet() {}
ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() {
if (meshShape) {
@@ -396,7 +396,6 @@ void ConcavePolygonShapeBullet::setup(Vector<Vector3> 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);
@@ -434,9 +433,10 @@ void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
btCollisionShape *ConcavePolygonShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) {
btCollisionShape *cs = ShapeBullet::create_shape_concave(meshShape);
- if (!cs)
+ if (!cs) {
// This is necessary since if 0 faces the creation of concave return null
cs = ShapeBullet::create_shape_empty();
+ }
cs->setLocalScaling(p_implicit_scale);
prepare(cs);
cs->setMargin(0);
@@ -459,10 +459,12 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
real_t l_max_height = 0.0;
// If specified, min and max height will be used as precomputed values
- if (d.has("min_height"))
+ if (d.has("min_height")) {
l_min_height = d["min_height"];
- if (d.has("max_height"))
+ }
+ if (d.has("max_height")) {
l_max_height = d["max_height"];
+ }
ERR_FAIL_COND(l_min_height > l_max_height);
@@ -515,7 +517,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();
@@ -563,18 +564,14 @@ btCollisionShape *HeightMapShapeBullet::create_bt_shape(const btVector3 &p_impli
/* Ray shape */
RayShapeBullet::RayShapeBullet() :
- ShapeBullet(),
- length(1),
- slips_on_slope(false) {}
+ 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 0dbc616fe5..a35a1d8a18 100644
--- a/modules/bullet/shape_bullet.h
+++ b/modules/bullet/shape_bullet.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_BULLET_H
#define SHAPE_BULLET_H
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/variant.h"
#include "rid_bullet.h"
#include "servers/physics_server_3d.h"
@@ -50,9 +50,8 @@ class ShapeOwnerBullet;
class btBvhTriangleMeshShape;
class ShapeBullet : public RIDBullet {
-
Map<ShapeOwnerBullet *, int> owners;
- real_t margin;
+ real_t margin = 0.04;
protected:
/// return self
@@ -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<btVector3> vertices;
@@ -200,7 +193,7 @@ private:
};
class ConcavePolygonShapeBullet : public ShapeBullet {
- class btBvhTriangleMeshShape *meshShape;
+ class btBvhTriangleMeshShape *meshShape = nullptr;
public:
Vector<Vector3> faces;
@@ -218,7 +211,6 @@ private:
};
class HeightMapShapeBullet : public ShapeBullet {
-
public:
Vector<real_t> heights;
int width;
@@ -238,10 +230,9 @@ private:
};
class RayShapeBullet : public ShapeBullet {
-
public:
- real_t length;
- bool slips_on_slope;
+ real_t length = 1;
+ bool slips_on_slope = false;
RayShapeBullet();
diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp
index de47c91e5d..6d5d95d07a 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);
@@ -121,6 +119,7 @@ real_t SliderJointBullet::getLowerLinLimit() const {
void SliderJointBullet::setLowerLinLimit(real_t lowerLimit) {
sliderConstraint->setLowerLinLimit(lowerLimit);
}
+
real_t SliderJointBullet::getUpperLinLimit() const {
return sliderConstraint->getUpperLinLimit();
}
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index 236bdc7c8a..6794d6c313 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -36,18 +36,7 @@
#include "space_bullet.h"
SoftBodyBullet::SoftBodyBullet() :
- CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY),
- bt_soft_body(nullptr),
- isScratched(false),
- simulation_precision(5),
- total_mass(1.),
- linear_stiffness(0.5),
- areaAngular_stiffness(0.5),
- volume_stiffness(0.5),
- pressure_coefficient(0.),
- pose_matching_coefficient(0.),
- damping_coefficient(0.01),
- drag_coefficient(0.) {}
+ CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY) {}
SoftBodyBullet::~SoftBodyBullet() {
}
@@ -77,8 +66,9 @@ void SoftBodyBullet::on_enter_area(AreaBullet *p_area) {}
void SoftBodyBullet::on_exit_area(AreaBullet *p_area) {}
void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_rendering_server_handler) {
- if (!bt_soft_body)
+ if (!bt_soft_body) {
return;
+ }
/// Update visual server vertices
const btSoftBody::tNodeArray &nodes(bt_soft_body->m_nodes);
@@ -116,14 +106,13 @@ void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_r
}
void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
-
- if (p_mesh.is_null())
+ if (p_mesh.is_null()) {
soft_mesh.unref();
- else
+ } else {
soft_mesh = p_mesh;
+ }
if (soft_mesh.is_null()) {
-
destroy_soft_body();
return;
}
@@ -134,9 +123,9 @@ void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
}
void SoftBodyBullet::destroy_soft_body() {
-
- if (!bt_soft_body)
+ if (!bt_soft_body) {
return;
+ }
if (space) {
/// Remove from world before deletion
@@ -153,8 +142,9 @@ void SoftBodyBullet::set_soft_transform(const Transform &p_transform) {
}
void SoftBodyBullet::move_all_nodes(const Transform &p_transform) {
- if (!bt_soft_body)
+ if (!bt_soft_body) {
return;
+ }
btTransform bt_transf;
G_TO_B(p_transform, bt_transf);
bt_soft_body->transform(bt_transf);
@@ -180,8 +170,9 @@ void SoftBodyBullet::get_node_position(int p_node_index, Vector3 &r_position) co
}
void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const {
- if (soft_mesh.is_null())
+ if (soft_mesh.is_null()) {
return;
+ }
Array arrays = soft_mesh->surface_get_arrays(0);
Vector<Vector3> vertices(arrays[RS::ARRAY_VERTEX]);
@@ -226,15 +217,15 @@ void SoftBodyBullet::reset_all_node_mass() {
}
void SoftBodyBullet::reset_all_node_positions() {
- if (soft_mesh.is_null())
+ if (soft_mesh.is_null()) {
return;
+ }
Array arrays = soft_mesh->surface_get_arrays(0);
Vector<Vector3> vs_vertices(arrays[RS::ARRAY_VERTEX]);
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;
@@ -342,7 +333,6 @@ void SoftBodyBullet::set_trimesh_body_shape(Vector<int> p_indices, Vector<Vector
const Vector3 *p_vertices_read = p_vertices.ptr();
for (int vs_vertex_index = 0; vs_vertex_index < vs_vertices_size; ++vs_vertex_index) {
-
Map<Vector3, int>::Element *e = unique_vertices.find(p_vertices_read[vs_vertex_index]);
int vertex_id;
if (e) {
@@ -398,9 +388,9 @@ void SoftBodyBullet::set_trimesh_body_shape(Vector<int> p_indices, Vector<Vector
}
void SoftBodyBullet::setup_soft_body() {
-
- if (!bt_soft_body)
+ if (!bt_soft_body) {
return;
+ }
// Soft body setup
setupBulletCollisionObject(bt_soft_body);
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index 3c6871e0d6..da8a2412ed 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -56,24 +56,23 @@
*/
class SoftBodyBullet : public CollisionObjectBullet {
-
private:
- btSoftBody *bt_soft_body;
+ btSoftBody *bt_soft_body = nullptr;
Vector<Vector<int>> indices_table;
btSoftBody::Material *mat0; // This is just a copy of pointer managed by btSoftBody
- bool isScratched;
+ bool isScratched = false;
Ref<Mesh> soft_mesh;
- int simulation_precision;
- real_t total_mass;
- real_t linear_stiffness; // [0,1]
- real_t areaAngular_stiffness; // [0,1]
- real_t volume_stiffness; // [0,1]
- real_t pressure_coefficient; // [-inf,+inf]
- real_t pose_matching_coefficient; // [0,1]
- real_t damping_coefficient; // [0,1]
- real_t drag_coefficient; // [0,1]
+ int simulation_precision = 5;
+ real_t total_mass = 1.;
+ real_t linear_stiffness = 0.5; // [0,1]
+ real_t areaAngular_stiffness = 0.5; // [0,1]
+ real_t volume_stiffness = 0.5; // [0,1]
+ real_t pressure_coefficient = 0.; // [-inf,+inf]
+ real_t pose_matching_coefficient = 0.; // [0,1]
+ real_t damping_coefficient = 0.01; // [0,1]
+ real_t drag_coefficient = 0.; // [0,1]
Vector<int> pinned_nodes;
// Other property to add
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index d49e635fd5..99f58e7059 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -63,9 +63,9 @@ 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<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
- if (p_result_max <= 0)
+ if (p_result_max <= 0) {
return 0;
+ }
btVector3 bt_point;
G_TO_B(p_point, bt_point);
@@ -86,7 +86,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<RID> &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;
@@ -119,8 +118,9 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
}
int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- if (p_result_max <= 0)
+ if (p_result_max <= 0) {
return 0;
+ }
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
@@ -204,8 +204,9 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
/// Returns the list of contacts pairs in this order: Local contact, other body contact
bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- if (p_result_max <= 0)
- return 0;
+ if (p_result_max <= 0) {
+ return false;
+ }
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
@@ -213,7 +214,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
if (!btShape->isConvex()) {
bulletdelete(btShape);
ERR_PRINT("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
- return 0;
+ return false;
}
btConvexShape *btConvex = static_cast<btConvexShape *>(btShape);
@@ -238,14 +239,13 @@ 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<RID> &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);
if (!btShape->isConvex()) {
bulletdelete(btShape);
ERR_PRINT("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
- return 0;
+ return false;
}
btConvexShape *btConvex = static_cast<btConvexShape *>(btShape);
@@ -276,7 +276,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,33 +319,16 @@ 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();
}
}
-SpaceBullet::SpaceBullet() :
- broadphase(nullptr),
- collisionConfiguration(nullptr),
- dispatcher(nullptr),
- solver(nullptr),
- dynamicsWorld(nullptr),
- soft_body_world_info(nullptr),
- ghostPairCallback(nullptr),
- godotFilterCallback(nullptr),
- gravityDirection(0, -1, 0),
- gravityMagnitude(10),
- linear_damp(0.0),
- angular_damp(0.0),
- contactDebugCount(0),
- delta_time(0.) {
-
+SpaceBullet::SpaceBullet() {
create_empty_world(GLOBAL_DEF("physics/3d/active_soft_world", true));
direct_access = memnew(BulletPhysicsDirectSpaceState(this));
}
@@ -554,7 +536,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
@@ -576,17 +557,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);
@@ -639,7 +617,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);
@@ -663,7 +640,6 @@ void SpaceBullet::destroy_world() {
}
void SpaceBullet::check_ghost_overlaps() {
-
/// Algorithm support variables
btCollisionShape *other_body_shape;
btConvexShape *area_shape;
@@ -677,8 +653,9 @@ void SpaceBullet::check_ghost_overlaps() {
btVector3 area_scale(area->get_bt_body_scale());
- if (!area->is_monitoring())
+ if (!area->is_monitoring()) {
continue;
+ }
/// 1. Reset all states
for (i = area->overlappingObjects.size() - 1; 0 <= i; --i) {
@@ -696,7 +673,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<RigidCollisionObjectBullet *>(overlapped_bt_co->getUserPointer());
@@ -708,15 +684,18 @@ void SpaceBullet::check_ghost_overlaps() {
}
if (overlapped_bt_co->getUserIndex() == CollisionObjectBullet::TYPE_AREA) {
- if (!static_cast<AreaBullet *>(overlapped_bt_co->getUserPointer())->is_monitorable())
+ if (!static_cast<AreaBullet *>(overlapped_bt_co->getUserPointer())->is_monitorable()) {
continue;
- } else if (overlapped_bt_co->getUserIndex() != CollisionObjectBullet::TYPE_RIGID_BODY)
+ }
+ } else if (overlapped_bt_co->getUserIndex() != CollisionObjectBullet::TYPE_RIGID_BODY) {
continue;
+ }
// For each area shape
for (y = area->get_shape_count() - 1; 0 <= y; --y) {
- if (!area->get_bt_shape(y)->isConvex())
+ if (!area->get_bt_shape(y)->isConvex()) {
continue;
+ }
btTransform area_shape_treansform(area->get_bt_shape_transform(y));
area_shape_treansform.getOrigin() *= area_scale;
@@ -729,7 +708,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<btCollisionShape *>(otherObject->get_bt_shape(z));
btTransform other_shape_transform(otherObject->get_bt_shape_transform(z));
@@ -740,7 +718,6 @@ void SpaceBullet::check_ghost_overlaps() {
other_shape_transform;
if (other_body_shape->isConvex()) {
-
btPointCollector result;
btGjkPairDetector gjk_pair_detector(
area_shape,
@@ -755,14 +732,14 @@ 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);
btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS);
- if (!algorithm)
+ if (!algorithm) {
continue;
+ }
GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB);
algorithm->processCollision(&obA, &obB, dynamicsWorld->getDispatchInfo(), &contactPointResult);
@@ -780,8 +757,9 @@ void SpaceBullet::check_ghost_overlaps() {
} // ~For each area shape
collision_found:
- if (!hasOverlap)
+ if (!hasOverlap) {
continue;
+ }
indexOverlap = area->find_overlapping_object(otherObject);
if (-1 == indexOverlap) {
@@ -838,7 +816,6 @@ void SpaceBullet::check_body_collision() {
pt.getDistance() <= 0.0 ||
bodyA->was_colliding(bodyB) ||
bodyB->was_colliding(bodyA)) {
-
Vector3 collisionWorldPosition;
Vector3 collisionLocalPosition;
Vector3 normalOnB;
@@ -898,7 +875,6 @@ static Ref<StandardMaterial3D> 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
@@ -1015,7 +991,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<const btRigidBody *>(r_recover_result.other_collision_object);
CollisionObjectBullet *collisionObject = static_cast<CollisionObjectBullet *>(btRigid->getUserPointer());
@@ -1049,7 +1024,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);
@@ -1114,14 +1088,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<btCollisionObject *>(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)) {
@@ -1165,13 +1137,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;
@@ -1216,7 +1186,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;
@@ -1235,8 +1204,9 @@ bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTran
if (p_infinite_inertia && !otherObject->isStaticOrKinematicObject()) {
otherObject->activate(); // Force activation of hitten rigid, soft body
continue;
- } else if (!p_body->get_bt_collision_object()->checkCollideWith(otherObject) || !otherObject->checkCollideWith(p_body->get_bt_collision_object()))
+ } else if (!p_body->get_bt_collision_object()->checkCollideWith(otherObject) || !otherObject->checkCollideWith(p_body->get_bt_collision_object())) {
continue;
+ }
if (otherObject->getCollisionShape()->isCompound()) {
const btCompoundShape *cs = static_cast<const btCompoundShape *>(otherObject->getCollisionShape());
@@ -1245,23 +1215,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<const btConvexShape *>(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<const btConvexShape *>(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;
}
}
@@ -1272,7 +1238,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;
@@ -1303,7 +1268,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);
@@ -1340,7 +1304,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<const btRigidBody *>(p_other_object);
@@ -1362,13 +1325,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;
@@ -1412,7 +1373,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;
}
@@ -1434,8 +1394,9 @@ int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btT
if (p_infinite_inertia && !otherObject->isStaticOrKinematicObject()) {
otherObject->activate(); // Force activation of hitten rigid, soft body
continue;
- } else if (!p_body->get_bt_collision_object()->checkCollideWith(otherObject) || !otherObject->checkCollideWith(p_body->get_bt_collision_object()))
+ } else if (!p_body->get_bt_collision_object()->checkCollideWith(otherObject) || !otherObject->checkCollideWith(p_body->get_bt_collision_object())) {
continue;
+ }
if (otherObject->getCollisionShape()->isCompound()) {
const btCompoundShape *cs = static_cast<const btCompoundShape *>(otherObject->getCollisionShape());
@@ -1444,14 +1405,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 0173c5a1c7..5ff421ef52 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -87,35 +87,34 @@ public:
};
class SpaceBullet : public RIDBullet {
-
friend class AreaBullet;
friend void onBulletTickCallback(btDynamicsWorld *world, btScalar timeStep);
friend class BulletPhysicsDirectSpaceState;
- btBroadphaseInterface *broadphase;
- btDefaultCollisionConfiguration *collisionConfiguration;
- btCollisionDispatcher *dispatcher;
- btConstraintSolver *solver;
- btDiscreteDynamicsWorld *dynamicsWorld;
- btSoftBodyWorldInfo *soft_body_world_info;
- btGhostPairCallback *ghostPairCallback;
- GodotFilterCallback *godotFilterCallback;
+ btBroadphaseInterface *broadphase = nullptr;
+ btDefaultCollisionConfiguration *collisionConfiguration = nullptr;
+ btCollisionDispatcher *dispatcher = nullptr;
+ btConstraintSolver *solver = nullptr;
+ btDiscreteDynamicsWorld *dynamicsWorld = nullptr;
+ btSoftBodyWorldInfo *soft_body_world_info = nullptr;
+ btGhostPairCallback *ghostPairCallback = nullptr;
+ GodotFilterCallback *godotFilterCallback = nullptr;
btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver;
btVoronoiSimplexSolver *gjk_simplex_solver;
BulletPhysicsDirectSpaceState *direct_access;
- Vector3 gravityDirection;
- real_t gravityMagnitude;
+ Vector3 gravityDirection = Vector3(0, -1, 0);
+ real_t gravityMagnitude = 10;
- real_t linear_damp;
- real_t angular_damp;
+ real_t linear_damp = 0.0;
+ real_t angular_damp = 0.0;
Vector<AreaBullet *> areas;
Vector<Vector3> contactDebug;
- int contactDebugCount;
- real_t delta_time;
+ int contactDebugCount = 0;
+ real_t delta_time = 0.;
public:
SpaceBullet();
@@ -170,8 +169,9 @@ public:
contactDebugCount = 0;
}
_FORCE_INLINE_ void add_debug_contact(const Vector3 &p_contact) {
- if (contactDebugCount < contactDebug.size())
+ if (contactDebugCount < contactDebug.size()) {
contactDebug.write[contactDebugCount++] = p_contact;
+ }
}
_FORCE_INLINE_ Vector<Vector3> get_debug_contacts() { return contactDebug; }
_FORCE_INLINE_ int get_debug_contact_count() { return contactDebugCount; }
@@ -194,22 +194,15 @@ private:
void check_body_collision();
struct RecoverResult {
- bool hasPenetration;
- btVector3 normal;
- btVector3 pointWorld;
- btScalar penetration_distance; // Negative mean penetration
- int other_compound_shape_index;
- const btCollisionObject *other_collision_object;
- int local_shape_most_recovered;
-
- RecoverResult() :
- hasPenetration(false),
- normal(0, 0, 0),
- pointWorld(0, 0, 0),
- penetration_distance(1e20),
- other_compound_shape_index(0),
- other_collision_object(nullptr),
- local_shape_most_recovered(0) {}
+ bool hasPenetration = false;
+ btVector3 normal = btVector3(0, 0, 0);
+ btVector3 pointWorld = btVector3(0, 0, 0);
+ btScalar penetration_distance = 1e20; // Negative mean penetration
+ int other_compound_shape_index = 0;
+ const btCollisionObject *other_collision_object = nullptr;
+ int local_shape_most_recovered = 0;
+
+ RecoverResult() {}
};
bool 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 = nullptr);
diff --git a/modules/camera/camera_win.cpp b/modules/camera/camera_win.cpp
index 875f0b26bc..1646644be3 100644
--- a/modules/camera/camera_win.cpp
+++ b/modules/camera/camera_win.cpp
@@ -53,9 +53,9 @@ public:
void deactivate_feed();
};
-CameraFeedWindows::CameraFeedWindows(){
+CameraFeedWindows::CameraFeedWindows() {
///@TODO implement this, should store information about our available camera
-};
+}
CameraFeedWindows::~CameraFeedWindows() {
// make sure we stop recording if we are!
@@ -75,16 +75,16 @@ bool CameraFeedWindows::activate_feed() {
///@TODO we should probably have a callback method here that is being called by the
// camera API which provides frames and call back into the CameraServer to update our texture
-void CameraFeedWindows::deactivate_feed(){
+void CameraFeedWindows::deactivate_feed() {
///@TODO this should deactivate our camera and stop the process of capturing frames
-};
+}
//////////////////////////////////////////////////////////////////////////
// CameraWindows - Subclass for our camera server on windows
-void CameraWindows::add_active_cameras(){
+void CameraWindows::add_active_cameras() {
///@TODO scan through any active cameras and create CameraFeedWindows objects for them
-};
+}
CameraWindows::CameraWindows() {
// Find cameras active right now
@@ -92,7 +92,3 @@ CameraWindows::CameraWindows() {
// need to add something that will react to devices being connected/removed...
};
-
-CameraWindows::~CameraWindows(){
-
-};
diff --git a/modules/camera/camera_win.h b/modules/camera/camera_win.h
index 39a1b0b86f..bbc8880c12 100644
--- a/modules/camera/camera_win.h
+++ b/modules/camera/camera_win.h
@@ -40,7 +40,7 @@ private:
public:
CameraWindows();
- ~CameraWindows();
+ ~CameraWindows() {}
};
#endif /* CAMERAWIN_H */
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index a6951a9320..ded0b970dc 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -30,22 +30,21 @@
#include "csg.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
#include "core/math/math_funcs.h"
#include "core/sort_array.h"
// 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)
+ if (segment_length < CMP_EPSILON) {
return p_uvs[0];
+ }
float distance = (p_interpolation_point - p_segement_points[0]).length();
float fraction = distance / segment_length;
@@ -54,13 +53,15 @@ 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)
+ 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)
+ }
+ if (p_interpolation_point.distance_squared_to(p_vertices[1]) < CMP_EPSILON2) {
return p_uvs[1];
- if (p_interpolation_point.distance_squared_to(p_vertices[2]) < CMP_EPSILON2)
+ }
+ if (p_interpolation_point.distance_squared_to(p_vertices[2]) < CMP_EPSILON2) {
return p_uvs[2];
+ }
Vector2 edge1 = p_vertices[1] - p_vertices[0];
Vector2 edge2 = p_vertices[2] - p_vertices[0];
@@ -72,8 +73,9 @@ inline static Vector2 interpolate_triangle_uv(const Vector2 p_vertices[3], const
float inter_on_edge1 = interpolation.dot(edge1);
float inter_on_edge2 = interpolation.dot(edge2);
float scale = (edge1_on_edge1 * edge2_on_edge2 - edge1_on_edge2 * edge1_on_edge2);
- if (scale == 0)
+ if (scale == 0) {
return p_uvs[0];
+ }
float v = (edge2_on_edge2 * inter_on_edge1 - edge1_on_edge2 * inter_on_edge2) / scale;
float w = (edge1_on_edge1 * inter_on_edge2 - edge1_on_edge2 * inter_on_edge1) / scale;
@@ -83,25 +85,27 @@ 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);
real_t a = edge1.dot(h);
// Check if ray is parallel to triangle.
- if (Math::is_zero_approx(a))
+ if (Math::is_zero_approx(a)) {
return false;
+ }
real_t f = 1.0 / a;
Vector3 s = p_from - p_vertices[0];
real_t u = f * s.dot(h);
- if (u < 0.0 - p_tolerance || u > 1.0 + p_tolerance)
+ if (u < 0.0 - p_tolerance || u > 1.0 + p_tolerance) {
return false;
+ }
Vector3 q = s.cross(edge1);
real_t v = f * p_dir.dot(q);
- if (v < 0.0 - p_tolerance || u + v > 1.0 + p_tolerance)
+ if (v < 0.0 - p_tolerance || u + v > 1.0 + p_tolerance) {
return false;
+ }
// Ray intersects triangle.
// Calculate distance.
@@ -110,12 +114,12 @@ static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3
if (t >= p_tolerance) {
r_intersection_point = p_from + p_dir * t;
return true;
- } else
+ } else {
return false;
+ }
}
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.
@@ -138,26 +142,28 @@ inline bool is_point_in_triangle(const Vector3 &p_point, const Vector3 p_vertice
lambda[2] = p_vertices[0].cross(p_vertices[1]).dot(p_point) / det;
// Point is in the plane if all lambdas sum to 1.
- if (!Math::is_equal_approx(lambda[0] + lambda[1] + lambda[2], 1))
+ if (!Math::is_equal_approx(lambda[0] + lambda[1] + lambda[2], 1)) {
return false;
+ }
// Point is inside the triangle if all lambdas are positive.
- if (lambda[0] < 0 || lambda[1] < 0 || lambda[2] < 0)
+ if (lambda[0] < 0 || lambda[1] < 0 || lambda[2] < 0) {
return false;
+ }
return true;
}
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);
real_t segment2_length2 = segment2.dot(segment2);
real_t segment_onto_segment = segment2.dot(segment1);
- if (segment1_length2 < p_vertex_snap2 || segment2_length2 < p_vertex_snap2)
+ if (segment1_length2 < p_vertex_snap2 || segment2_length2 < p_vertex_snap2) {
return true;
+ }
real_t max_separation2;
if (segment1_length2 > segment2_length2) {
@@ -172,7 +178,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 +187,6 @@ void CSGBrush::_regen_face_aabbs() {
}
void CSGBrush::build_from_faces(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uvs, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials, const Vector<bool> &p_invert_faces) {
-
faces.clear();
int vc = p_vertices.size();
@@ -204,7 +208,6 @@ void CSGBrush::build_from_faces(const Vector<Vector3> &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];
@@ -216,21 +219,21 @@ void CSGBrush::build_from_faces(const Vector<Vector3> &p_vertices, const Vector<
f.uvs[2] = ruv[i * 3 + 2];
}
- if (sc == vc / 3)
+ if (sc == vc / 3) {
f.smooth = rs[i];
- else
+ } else {
f.smooth = false;
+ }
- if (ic == vc / 3)
+ if (ic == vc / 3) {
f.invert = ri[i];
- else
+ } else {
f.invert = false;
+ }
if (mc == vc / 3) {
-
Ref<Material> mat = rm[i];
if (mat.is_valid()) {
-
const Map<Ref<Material>, int>::Element *E = material_map.find(mat);
if (E) {
@@ -255,7 +258,6 @@ void CSGBrush::build_from_faces(const Vector<Vector3> &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 +273,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 +288,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> material;
if (p_brush_a.faces[i].material != -1) {
material = p_brush_a.materials[p_brush_a.faces[i].material];
@@ -307,7 +307,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> material;
if (p_brush_b.faces[i].material != -1) {
material = p_brush_b.materials[p_brush_b.faces[i].material];
@@ -333,14 +332,13 @@ 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++) {
- if (mesh_merge.faces[i].inside)
+ if (mesh_merge.faces[i].inside) {
continue;
+ }
outside_count++;
}
@@ -349,9 +347,9 @@ 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)
+ if (mesh_merge.faces[i].inside) {
continue;
+ }
for (int j = 0; j < 3; j++) {
r_merged_brush.faces.write[outside_count].vertices[j] = mesh_merge.points[mesh_merge.faces[i].points[j]];
@@ -369,12 +367,12 @@ 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++) {
- if (!mesh_merge.faces[i].inside)
+ if (!mesh_merge.faces[i].inside) {
continue;
+ }
inside_count++;
}
@@ -383,9 +381,9 @@ 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)
+ if (!mesh_merge.faces[i].inside) {
continue;
+ }
for (int j = 0; j < 3; j++) {
r_merged_brush.faces.write[inside_count].vertices[j] = mesh_merge.points[mesh_merge.faces[i].points[j]];
@@ -403,14 +401,15 @@ 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++) {
- if (mesh_merge.faces[i].from_b && !mesh_merge.faces[i].inside)
+ 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)
+ }
+ if (!mesh_merge.faces[i].from_b && mesh_merge.faces[i].inside) {
continue;
+ }
face_count++;
}
@@ -419,11 +418,12 @@ 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)
+ 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)
+ }
+ if (!mesh_merge.faces[i].from_b && mesh_merge.faces[i].inside) {
continue;
+ }
for (int j = 0; j < 3; j++) {
r_merged_brush.faces.write[face_count].vertices[j] = mesh_merge.points[mesh_merge.faces[i].points[j]];
@@ -460,7 +460,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 +484,6 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac
int li = aabb.get_longest_axis_index();
switch (li) {
-
case Vector3::AXIS_X: {
SortArray<FaceBVH *, FaceBVHCmpX> sort_x;
sort_x.nth_element(0, p_size, p_size / 2, &facebvhptrptr[p_from]);
@@ -521,19 +519,19 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac
}
void CSGBrushOperation::MeshMerge::_add_distance(List<real_t> &r_intersectionsA, List<real_t> &r_intersectionsB, bool p_from_B, real_t p_distance) const {
-
List<real_t> &intersections = p_from_B ? r_intersectionsB : r_intersectionsA;
// Check if distance exists.
- for (const List<real_t>::Element *E = intersections.front(); E; E = E->next())
- if (Math::abs(**E - p_distance) < vertex_snap)
+ for (const List<real_t>::Element *E = intersections.front(); E; E = E->next()) {
+ if (Math::abs(**E - p_distance) < vertex_snap) {
return;
+ }
+ }
intersections.push_back(p_distance);
}
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 +561,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 &current_face = faces[current_facebvhptr->face];
Vector3 current_points[3] = {
points[current_face.points[0]],
@@ -592,8 +584,9 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
if ((current_normal - face_normal).length_squared() < CMP_EPSILON2 &&
is_point_in_triangle(face_center, current_points)) {
// Only add an intersection if checking a B face.
- if (face.from_b)
+ if (face.from_b) {
_add_distance(intersectionsA, intersectionsB, current_face.from_b, 0);
+ }
} else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) {
real_t distance = (intersection_point - face_center).length();
_add_distance(intersectionsA, intersectionsB, current_face.from_b, distance);
@@ -610,7 +603,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 +615,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 +622,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,18 +629,19 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de
}
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
continue;
}
}
- if (done)
+ if (done) {
break;
+ }
}
// Inside if face normal intersects other faces an odd number of times.
@@ -658,7 +649,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.
@@ -704,8 +694,9 @@ void CSGBrushOperation::MeshMerge::mark_inside_faces() {
AABB intersection_aabb = aabb_a.intersection(aabb_b);
// Check if shape AABBs intersect.
- if (intersection_aabb.size == Vector3())
+ if (intersection_aabb.size == Vector3()) {
return;
+ }
Vector<FaceBVH *> bvhtrvec;
bvhtrvec.resize(faces.size());
@@ -719,21 +710,20 @@ 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))
+ if (!intersection_aabb.intersects_inclusive(facebvh[i].aabb)) {
continue;
+ }
- if (_bvh_inside(facebvh, max_depth, max_alloc - 1, i))
+ if (_bvh_inside(facebvh, max_depth, max_alloc - 1, i)) {
faces.write[i].inside = true;
+ }
}
}
void CSGBrushOperation::MeshMerge::add_face(const Vector3 p_points[], const Vector2 p_uvs[], bool p_smooth, bool p_invert, const Ref<Material> &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));
@@ -750,8 +740,9 @@ void CSGBrushOperation::MeshMerge::add_face(const Vector3 p_points[], const Vect
}
// Don't add degenerate faces.
- if (indices[0] == indices[2] || indices[0] == indices[1] || indices[1] == indices[2])
+ if (indices[0] == indices[2] || indices[0] == indices[1] || indices[1] == indices[2]) {
return;
+ }
MeshMerge::Face face;
face.from_b = p_from_b;
@@ -781,27 +772,26 @@ 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)
+ if ((p_point - vertices[vertex_idx].point).length_squared() < vertex_snap2) {
return vertex_idx;
+ }
}
return -1;
}
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)
+ if (vertex_id != -1) {
return vertex_id;
+ }
vertices.push_back(p_vertex);
return vertices.size() - 1;
}
void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector<int> &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,20 +804,21 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector<int> &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;
// Sort along the axis with the greatest difference.
int axis = 0;
- if (Math::abs(new_point.x - first_point.x) < Math::abs(new_point.y - first_point.y))
+ if (Math::abs(new_point.x - first_point.x) < Math::abs(new_point.y - first_point.y)) {
axis = 1;
+ }
// Add it to the beginning or the end appropriately.
- if (new_point[axis] < first_point[axis])
+ if (new_point[axis] < first_point[axis]) {
r_vertex_indices.insert(0, p_new_vertex_index);
- else
+ } else {
r_vertex_indices.push_back(p_new_vertex_index);
+ }
return;
}
@@ -839,8 +830,9 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector<int> &r_vert
// Determine axis being sorted against i.e. the axis with the greatest difference.
int axis = 0;
- if (Math::abs(last_point.x - first_point.x) < Math::abs(last_point.y - first_point.y))
+ if (Math::abs(last_point.x - first_point.x) < Math::abs(last_point.y - first_point.y)) {
axis = 1;
+ }
// Insert the point at the appropriate index.
for (int insert_idx = 0; insert_idx < r_vertex_indices.size(); ++insert_idx) {
@@ -857,14 +849,13 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector<int> &r_vert
}
void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_indices) {
-
int segments = p_segment_indices.size() - 1;
- if (segments < 2)
+ 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,15 +884,15 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &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];
// Skip flattened faces.
if (outer_edge_idx[0] == p_segment_indices[closest_idx] ||
- outer_edge_idx[1] == p_segment_indices[closest_idx])
+ outer_edge_idx[1] == p_segment_indices[closest_idx]) {
continue;
+ }
//Don't create degenerate triangles.
Vector2 edge1[2] = {
@@ -929,15 +920,16 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
// Delete the old faces in reverse index order.
merge_faces_idx.sort();
merge_faces_idx.invert();
- for (int i = 0; i < merge_faces_idx.size(); ++i)
+ for (int i = 0; i < merge_faces_idx.size(); ++i) {
faces.remove(merge_faces_idx[i]);
+ }
- if (degenerate_points.size() == 0)
+ if (degenerate_points.size() == 0) {
continue;
+ }
// 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 +943,6 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &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;
@@ -963,20 +954,19 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
break;
}
}
- if (existing)
+ if (existing) {
continue;
+ }
// 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]
};
- Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(point_2D, edge_points);
+ Vector2 closest_point = Geometry2D::get_closest_point_to_segment(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 +1004,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_
}
void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_segment_points[2], Vector<int> &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 +1015,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
@@ -1041,7 +1028,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
// First check if the ends of the segment are on the edge.
bool on_edge = false;
for (int edge_point_idx = 0; edge_point_idx < 2; ++edge_point_idx) {
- intersection_point = Geometry::get_closest_point_to_segment_2d(p_segment_points[edge_point_idx], edge_points);
+ intersection_point = Geometry2D::get_closest_point_to_segment(p_segment_points[edge_point_idx], edge_points);
if ((intersection_point - p_segment_points[edge_point_idx]).length_squared() < vertex_snap2) {
on_edge = true;
break;
@@ -1049,16 +1036,17 @@ 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)) {
-
+ if (on_edge || Geometry2D::segment_intersects_segment(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)
+ (intersection_point - edge_points[1]).length_squared() < vertex_snap2) {
continue;
+ }
// Check if edge exists, by checking if the intersecting segment is parallel to the edge.
- if (are_segements_parallel(p_segment_points, edge_points, vertex_snap2))
+ if (are_segements_parallel(p_segment_points, edge_points, vertex_snap2)) {
continue;
+ }
// Add the intersection point as a new vertex.
Vertex2D new_vertex;
@@ -1086,9 +1074,10 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s
}
// If opposite point is on the segemnt, add its index to segment indices too.
- Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(vertices[opposite_vertex_idx].point, p_segment_points);
- if ((closest_point - vertices[opposite_vertex_idx].point).length_squared() < vertex_snap2)
+ Vector2 closest_point = Geometry2D::get_closest_point_to_segment(vertices[opposite_vertex_idx].point, p_segment_points);
+ if ((closest_point - vertices[opposite_vertex_idx].point).length_squared() < vertex_snap2) {
_add_vertex_idx_sorted(r_segment_indices, opposite_vertex_idx);
+ }
// Create two new faces around the new edge and remove this face.
// The new edge is the last edge.
@@ -1113,11 +1102,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]],
@@ -1137,14 +1124,14 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
// Check if point is existing face vertex.
for (int i = 0; i < 3; ++i) {
- if ((p_point - face_vertices[i].point).length_squared() < vertex_snap2)
+ if ((p_point - face_vertices[i].point).length_squared() < vertex_snap2) {
return face.vertex_idx[i];
+ }
}
// 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]
@@ -1154,7 +1141,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) {
uvs[(face_edge_idx + 1) % 3]
};
- Vector2 closest_point = Geometry::get_closest_point_to_segment_2d(p_point, edge_points);
+ Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, edge_points);
if ((closest_point - p_point).length_squared() < vertex_snap2) {
on_edge = true;
@@ -1205,8 +1192,7 @@ 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)) {
-
+ if (!on_edge && Geometry2D::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 +1202,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 +1228,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 +1236,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,13 +1245,14 @@ 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))
+ if (plane.has_point(next_point_3D)) {
continue; // Next point is in plane, it will be added separately.
- if (plane.is_point_over(point_3D) == plane.is_point_over(next_point_3D))
+ }
+ if (plane.is_point_over(point_3D) == plane.is_point_over(next_point_3D)) {
continue; // Both points on the same side of the plane, ignore.
+ }
// Edge crosses the plane, find and add the intersection point.
Vector3 point_2D;
@@ -1315,7 +1299,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<Material> &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 +1322,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 +1350,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],
@@ -1396,8 +1377,9 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face
p_collection.build2DFacesB[p_face_idx_b] = Build2DFaces();
has_degenerate = true;
}
- if (has_degenerate)
+ if (has_degenerate) {
return;
+ }
// Ensure B has points either side of or in the plane of A.
int in_plane_count = 0, over_count = 0, under_count = 0;
@@ -1405,16 +1387,18 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face
ERR_FAIL_COND_MSG(plane_a.normal == Vector3(), "Couldn't form plane from Brush A face.");
for (int i = 0; i < 3; i++) {
- if (plane_a.has_point(vertices_b[i]))
+ if (plane_a.has_point(vertices_b[i])) {
in_plane_count++;
- else if (plane_a.is_point_over(vertices_b[i]))
+ } else if (plane_a.is_point_over(vertices_b[i])) {
over_count++;
- else
+ } else {
under_count++;
+ }
}
// If all points under or over the plane, there is no intesection.
- if (over_count == 3 || under_count == 3)
+ if (over_count == 3 || under_count == 3) {
return;
+ }
// Ensure A has points either side of or in the plane of B.
in_plane_count = 0;
@@ -1424,32 +1408,32 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face
ERR_FAIL_COND_MSG(plane_b.normal == Vector3(), "Couldn't form plane from Brush B face.");
for (int i = 0; i < 3; i++) {
- if (plane_b.has_point(vertices_a[i]))
+ if (plane_b.has_point(vertices_a[i])) {
in_plane_count++;
- else if (plane_b.is_point_over(vertices_a[i]))
+ } else if (plane_b.is_point_over(vertices_a[i])) {
over_count++;
- else
+ } else {
under_count++;
+ }
}
// If all points under or over the plane, there is no intesection.
- if (over_count == 3 || under_count == 3)
+ if (over_count == 3 || under_count == 3) {
return;
+ }
// 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);
- if (sep_axis == Vector3())
+ if (sep_axis == Vector3()) {
continue; //colineal
+ }
sep_axis.normalize();
real_t min_a = 1e20, max_a = -1e20;
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..cce72770f5 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,37 @@ CSGShape3DGizmoPlugin::CSGShape3DGizmoPlugin() {
}
String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
-
CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
if (Object::cast_to<CSGSphere3D>(cs)) {
-
return "Radius";
}
if (Object::cast_to<CSGBox3D>(cs)) {
-
static const char *hname[3] = { "Width", "Height", "Depth" };
return hname[p_idx];
}
if (Object::cast_to<CSGCylinder3D>(cs)) {
-
return p_idx == 0 ? "Radius" : "Height";
}
if (Object::cast_to<CSGTorus3D>(cs)) {
-
return p_idx == 0 ? "InnerRadius" : "OuterRadius";
}
return "";
}
-Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
+Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
if (Object::cast_to<CSGSphere3D>(cs)) {
-
CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
return s->get_radius();
}
if (Object::cast_to<CSGBox3D>(cs)) {
-
CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
switch (p_idx) {
case 0:
@@ -100,21 +92,19 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int
}
if (Object::cast_to<CSGCylinder3D>(cs)) {
-
CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
return p_idx == 0 ? s->get_radius() : s->get_height();
}
if (Object::cast_to<CSGTorus3D>(cs)) {
-
CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
return p_idx == 0 ? s->get_inner_radius() : s->get_outer_radius();
}
return Variant();
}
-void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
+void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
Transform gt = cs->get_global_transform();
@@ -127,37 +117,37 @@ 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<CSGSphere3D>(cs)) {
-
CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
s->set_radius(d);
}
if (Object::cast_to<CSGBox3D>(cs)) {
-
CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
Vector3 axis;
axis[p_idx] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
switch (p_idx) {
case 0:
@@ -173,51 +163,53 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca
}
if (Object::cast_to<CSGCylinder3D>(cs)) {
-
CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
Vector3 axis;
axis[p_idx == 0 ? 0 : 1] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
- if (p_idx == 0)
+ if (p_idx == 0) {
s->set_radius(d);
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
s->set_height(d * 2.0);
+ }
}
if (Object::cast_to<CSGTorus3D>(cs)) {
-
CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
Vector3 axis;
axis[0] = 1.0;
Vector3 ra, rb;
- Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
+ Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
- if (d < 0.001)
+ if (d < 0.001) {
d = 0.001;
+ }
- if (p_idx == 0)
+ if (p_idx == 0) {
s->set_inner_radius(d);
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
s->set_outer_radius(d);
+ }
}
}
-void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
if (Object::cast_to<CSGSphere3D>(cs)) {
@@ -275,10 +267,11 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx,
if (Object::cast_to<CSGCylinder3D>(cs)) {
CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
if (p_cancel) {
- if (p_idx == 0)
+ if (p_idx == 0) {
s->set_radius(p_restore);
- else
+ } else {
s->set_height(p_restore);
+ }
return;
}
@@ -299,10 +292,11 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx,
if (Object::cast_to<CSGTorus3D>(cs)) {
CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
if (p_cancel) {
- if (p_idx == 0)
+ if (p_idx == 0) {
s->set_inner_radius(p_restore);
- else
+ } else {
s->set_outer_radius(p_restore);
+ }
return;
}
@@ -320,6 +314,7 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx,
ur->commit_action();
}
}
+
bool CSGShape3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<CSGSphere3D>(p_spatial) || Object::cast_to<CSGBox3D>(p_spatial) || Object::cast_to<CSGCylinder3D>(p_spatial) || Object::cast_to<CSGTorus3D>(p_spatial) || Object::cast_to<CSGMesh3D>(p_spatial) || Object::cast_to<CSGPolygon3D>(p_spatial);
}
@@ -337,7 +332,6 @@ bool CSGShape3DGizmoPlugin::is_selectable_when_hidden() const {
}
void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
-
CSGShape3D *cs = Object::cast_to<CSGShape3D>(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..cea006364f 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -29,17 +29,19 @@
/*************************************************************************/
#include "csg_shape.h"
+#include "core/math/geometry_2d.h"
#include "scene/3d/path_3d.h"
void CSGShape3D::set_use_collision(bool p_enable) {
-
- if (use_collision == p_enable)
+ if (use_collision == p_enable) {
return;
+ }
use_collision = p_enable;
- if (!is_inside_tree() || !is_root_shape())
+ if (!is_inside_tree() || !is_root_shape()) {
return;
+ }
if (use_collision) {
root_collision_shape.instance();
@@ -71,12 +73,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,42 +84,38 @@ 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)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
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)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_layer(mask);
}
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,9 +128,9 @@ float CSGShape3D::get_snap() const {
}
void CSGShape3D::_make_dirty() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (dirty) {
return;
@@ -151,7 +147,6 @@ void CSGShape3D::_make_dirty() {
}
CSGBrush *CSGShape3D::_get_brush() {
-
if (dirty) {
if (brush) {
memdelete(brush);
@@ -161,23 +156,24 @@ CSGBrush *CSGShape3D::_get_brush() {
CSGBrush *n = _build_brush();
for (int i = 0; i < get_child_count(); i++) {
-
CSGShape3D *child = Object::cast_to<CSGShape3D>(get_child(i));
- if (!child)
+ if (!child) {
continue;
- if (!child->is_visible_in_tree())
+ }
+ if (!child->is_visible_in_tree()) {
continue;
+ }
CSGBrush *n2 = child->_get_brush();
- if (!n2)
+ if (!n2) {
continue;
+ }
if (!n) {
n = memnew(CSGBrush);
n->copy_from(*n2, child->get_transform());
} else {
-
CSGBrush *nn = memnew(CSGBrush);
CSGBrush *nn2 = memnew(CSGBrush);
nn2->copy_from(*n2, child->get_transform());
@@ -205,10 +201,11 @@ CSGBrush *CSGShape3D::_get_brush() {
AABB aabb;
for (int i = 0; i < n->faces.size(); i++) {
for (int j = 0; j < 3; j++) {
- if (i == 0 && j == 0)
+ if (i == 0 && j == 0) {
aabb.position = n->faces[i].vertices[j];
- else
+ } else {
aabb.expand_to(n->faces[i].vertices[j]);
+ }
}
}
node_aabb = aabb;
@@ -263,7 +260,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,9 +276,9 @@ void CSGShape3D::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const
}
void CSGShape3D::_update_shape() {
-
- if (parent)
+ if (parent) {
return;
+ }
set_base(RID());
root_mesh.unref(); //byebye root mesh
@@ -325,7 +321,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 +343,11 @@ void CSGShape3D::_update_shape() {
// Update collision faces.
if (root_collision_shape.is_valid()) {
-
Vector<Vector3> 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 +365,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 +380,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 +389,6 @@ void CSGShape3D::_update_shape() {
}
if (n->faces[i].invert) {
-
normal = -normal;
}
@@ -443,8 +433,9 @@ void CSGShape3D::_update_shape() {
have_tangents = genTangSpaceDefault(&msc);
}
- if (surfaces[i].last_added == 0)
+ if (surfaces[i].last_added == 0) {
continue;
+ }
// and convert to surface array
Array array;
@@ -464,6 +455,7 @@ void CSGShape3D::_update_shape() {
set_base(root_mesh->get_rid());
}
+
AABB CSGShape3D::get_aabb() const {
return node_aabb;
}
@@ -491,14 +483,11 @@ Vector<Vector3> CSGShape3D::get_brush_faces() {
}
Vector<Face3> CSGShape3D::get_faces(uint32_t p_usage_flags) const {
-
return Vector<Face3>();
}
void CSGShape3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
Node *parentn = get_parent();
if (parentn) {
parent = Object::cast_to<CSGShape3D>(parentn);
@@ -523,23 +512,21 @@ 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)
+ if (parent) {
parent->_make_dirty();
+ }
parent = nullptr;
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
@@ -552,7 +539,6 @@ void CSGShape3D::_notification(int p_what) {
}
void CSGShape3D::set_operation(Operation p_operation) {
-
operation = p_operation;
_make_dirty();
update_gizmo();
@@ -582,7 +568,6 @@ void CSGShape3D::_validate_property(PropertyInfo &property) const {
}
Array CSGShape3D::get_meshes() const {
-
if (root_mesh.is_valid()) {
Array arr;
arr.resize(2);
@@ -593,8 +578,8 @@ Array CSGShape3D::get_meshes() const {
return Array();
}
-void CSGShape3D::_bind_methods() {
+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);
@@ -657,10 +642,10 @@ CSGShape3D::~CSGShape3D() {
brush = nullptr;
}
}
+
//////////////////////////////////
CSGBrush *CSGCombiner3D::_build_brush() {
-
return nullptr; //does not build anything
}
@@ -670,7 +655,6 @@ CSGCombiner3D::CSGCombiner3D() {
/////////////////////
CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials) {
-
CSGBrush *brush = memnew(CSGBrush);
Vector<bool> invert;
@@ -688,7 +672,6 @@ CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector<Vector3> &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);
@@ -696,8 +679,9 @@ void CSGPrimitive3D::_bind_methods() {
}
void CSGPrimitive3D::set_invert_faces(bool p_invert) {
- if (invert_faces == p_invert)
+ if (invert_faces == p_invert) {
return;
+ }
invert_faces = p_invert;
@@ -715,9 +699,9 @@ CSGPrimitive3D::CSGPrimitive3D() {
/////////////////////
CSGBrush *CSGMesh3D::_build_brush() {
-
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
return nullptr;
+ }
Vector<Vector3> vertices;
Vector<bool> smooth;
@@ -726,7 +710,6 @@ CSGBrush *CSGMesh3D::_build_brush() {
Ref<Material> material = get_material();
for (int i = 0; i < mesh->get_surface_count(); i++) {
-
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
}
@@ -739,8 +722,9 @@ CSGBrush *CSGMesh3D::_build_brush() {
}
Vector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
- if (avertices.size() == 0)
+ if (avertices.size() == 0) {
continue;
+ }
const Vector3 *vr = avertices.ptr();
@@ -781,7 +765,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 +808,6 @@ CSGBrush *CSGMesh3D::_build_brush() {
Ref<Material> *mw = materials.ptrw();
for (int j = 0; j < is; j += 3) {
-
Vector3 vertex[3];
Vector3 normal[3];
Vector2 uv[3];
@@ -856,8 +838,9 @@ CSGBrush *CSGMesh3D::_build_brush() {
}
}
- if (vertices.size() == 0)
+ if (vertices.size() == 0) {
return nullptr;
+ }
return _create_brush_from_arrays(vertices, uvs, smooth, materials);
}
@@ -868,19 +851,18 @@ void CSGMesh3D::_mesh_changed() {
}
void CSGMesh3D::set_material(const Ref<Material> &p_material) {
- if (material == p_material)
+ if (material == p_material) {
return;
+ }
material = p_material;
_make_dirty();
}
Ref<Material> 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,9 +874,9 @@ void CSGMesh3D::_bind_methods() {
}
void CSGMesh3D::set_mesh(const Ref<Mesh> &p_mesh) {
-
- if (mesh == p_mesh)
+ if (mesh == p_mesh) {
return;
+ }
if (mesh.is_valid()) {
mesh->disconnect("changed", callable_mp(this, &CSGMesh3D::_mesh_changed));
}
@@ -914,7 +896,6 @@ Ref<Mesh> CSGMesh3D::get_mesh() {
////////////////////////////////
CSGBrush *CSGSphere3D::_build_brush() {
-
// set our bounding box
CSGBrush *brush = memnew(CSGBrush);
@@ -938,7 +919,6 @@ CSGBrush *CSGSphere3D::_build_brush() {
invert.resize(face_count);
{
-
Vector3 *facesw = faces.ptrw();
Vector2 *uvsw = uvs.ptrw();
bool *smoothw = smooth.ptrw();
@@ -959,7 +939,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 +965,6 @@ CSGBrush *CSGSphere3D::_build_brush() {
};
if (i < rings) {
-
//face 1
facesw[face * 3 + 0] = v[0];
facesw[face * 3 + 1] = v[1];
@@ -1096,13 +1074,11 @@ bool CSGSphere3D::get_smooth_faces() const {
}
void CSGSphere3D::set_material(const Ref<Material> &p_material) {
-
material = p_material;
_make_dirty();
}
Ref<Material> CSGSphere3D::get_material() const {
-
return material;
}
@@ -1117,7 +1093,6 @@ CSGSphere3D::CSGSphere3D() {
///////////////
CSGBrush *CSGBox3D::_build_brush() {
-
// set our bounding box
CSGBrush *brush = memnew(CSGBrush);
@@ -1141,7 +1116,6 @@ CSGBrush *CSGBox3D::_build_brush() {
invert.resize(face_count);
{
-
Vector3 *facesw = faces.ptrw();
Vector2 *uvsw = uvs.ptrw();
bool *smoothw = smooth.ptrw();
@@ -1153,25 +1127,22 @@ 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)
+ if (i < 3) {
face_points[j][(i + k) % 3] = v[k];
- else
+ } else {
face_points[3 - j][(i + k) % 3] = -v[k];
+ }
}
}
@@ -1274,14 +1245,12 @@ float CSGBox3D::get_depth() const {
}
void CSGBox3D::set_material(const Ref<Material> &p_material) {
-
material = p_material;
_make_dirty();
update_gizmo();
}
Ref<Material> CSGBox3D::get_material() const {
-
return material;
}
@@ -1295,7 +1264,6 @@ CSGBox3D::CSGBox3D() {
///////////////
CSGBrush *CSGCylinder3D::_build_brush() {
-
// set our bounding box
CSGBrush *brush = memnew(CSGBrush);
@@ -1319,7 +1287,6 @@ CSGBrush *CSGCylinder3D::_build_brush() {
invert.resize(face_count);
{
-
Vector3 *facesw = faces.ptrw();
Vector2 *uvsw = uvs.ptrw();
bool *smoothw = smooth.ptrw();
@@ -1331,9 +1298,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 +1475,11 @@ bool CSGCylinder3D::get_smooth_faces() const {
}
void CSGCylinder3D::set_material(const Ref<Material> &p_material) {
-
material = p_material;
_make_dirty();
}
Ref<Material> CSGCylinder3D::get_material() const {
-
return material;
}
@@ -1532,14 +1495,14 @@ CSGCylinder3D::CSGCylinder3D() {
///////////////
CSGBrush *CSGTorus3D::_build_brush() {
-
// set our bounding box
float min_radius = inner_radius;
float max_radius = outer_radius;
- if (min_radius == max_radius)
+ if (min_radius == max_radius) {
return nullptr; //sorry, can't
+ }
if (min_radius > max_radius) {
SWAP(min_radius, max_radius);
@@ -1568,7 +1531,6 @@ CSGBrush *CSGTorus3D::_build_brush() {
invert.resize(face_count);
{
-
Vector3 *facesw = faces.ptrw();
Vector2 *uvsw = uvs.ptrw();
bool *smoothw = smooth.ptrw();
@@ -1578,9 +1540,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 +1551,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 +1697,11 @@ bool CSGTorus3D::get_smooth_faces() const {
}
void CSGTorus3D::set_material(const Ref<Material> &p_material) {
-
material = p_material;
_make_dirty();
}
Ref<Material> CSGTorus3D::get_material() const {
-
return material;
}
@@ -1760,11 +1717,11 @@ CSGTorus3D::CSGTorus3D() {
///////////////
CSGBrush *CSGPolygon3D::_build_brush() {
-
// set our bounding box
- if (polygon.size() < 3)
+ if (polygon.size() < 3) {
return nullptr;
+ }
Vector<Point2> final_polygon = polygon;
@@ -1772,10 +1729,11 @@ CSGBrush *CSGPolygon3D::_build_brush() {
final_polygon.invert();
}
- Vector<int> triangles = Geometry::triangulate_polygon(final_polygon);
+ Vector<int> triangles = Geometry2D::triangulate_polygon(final_polygon);
- if (triangles.size() < 3)
+ if (triangles.size() < 3) {
return nullptr;
+ }
Path3D *path = nullptr;
Ref<Curve3D> curve;
@@ -1789,28 +1747,35 @@ CSGBrush *CSGPolygon3D::_build_brush() {
final_polygon_min = p;
final_polygon_max = final_polygon_min;
} else {
- if (p.x < final_polygon_min.x)
+ if (p.x < final_polygon_min.x) {
final_polygon_min.x = p.x;
- if (p.y < final_polygon_min.y)
+ }
+ if (p.y < final_polygon_min.y) {
final_polygon_min.y = p.y;
+ }
- if (p.x > final_polygon_max.x)
+ if (p.x > final_polygon_max.x) {
final_polygon_max.x = p.x;
- if (p.y > final_polygon_max.y)
+ }
+ if (p.y > final_polygon_max.y) {
final_polygon_max.y = p.y;
+ }
}
}
Vector2 final_polygon_size = final_polygon_max - final_polygon_min;
if (mode == MODE_PATH) {
- if (!has_node(path_node))
+ if (!has_node(path_node)) {
return nullptr;
+ }
Node *n = get_node(path_node);
- if (!n)
+ if (!n) {
return nullptr;
+ }
path = Object::cast_to<Path3D>(n);
- if (!path)
+ if (!path) {
return nullptr;
+ }
if (path != path_cache) {
if (path_cache) {
@@ -1826,10 +1791,12 @@ CSGBrush *CSGPolygon3D::_build_brush() {
path_cache = nullptr;
}
curve = path->get_curve();
- if (curve.is_null())
+ if (curve.is_null()) {
return nullptr;
- if (curve->get_baked_length() <= 0)
+ }
+ if (curve->get_baked_length() <= 0) {
return nullptr;
+ }
}
CSGBrush *brush = memnew(CSGBrush);
@@ -1871,7 +1838,6 @@ CSGBrush *CSGPolygon3D::_build_brush() {
AABB aabb; //must be computed
{
-
Vector3 *facesw = faces.ptrw();
Vector2 *uvsw = uvs.ptrw();
bool *smoothw = smooth.ptrw();
@@ -1882,10 +1848,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 +1874,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 +1923,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 +1935,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 +1983,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 +2000,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 +2019,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 +2044,6 @@ CSGBrush *CSGPolygon3D::_build_brush() {
}
for (int i = 0; i <= splits; i++) {
-
float ofs = i * path_interval;
if (ofs > bl) {
ofs = bl;
@@ -2127,7 +2083,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 +2132,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 +2149,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 };
@@ -2417,6 +2370,7 @@ void CSGPolygon3D::set_path_interval(float p_interval) {
_make_dirty();
update_gizmo();
}
+
float CSGPolygon3D::get_path_interval() const {
return path_interval;
}
@@ -2461,13 +2415,11 @@ bool CSGPolygon3D::get_smooth_faces() const {
}
void CSGPolygon3D::set_material(const Ref<Material> &p_material) {
-
material = p_material;
_make_dirty();
}
Ref<Material> 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<CSGShape3D>();
diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index 9dbaa88202..2a4f836478 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -137,9 +137,9 @@ 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)
+ if (p_image->get_format() >= Image::FORMAT_BPTC_RGBA) {
return; //do not compress, already compressed
+ }
int w = p_image->get_width();
int h = p_image->get_height();
@@ -154,16 +154,17 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann
cvtt::Options options;
uint32_t flags = cvtt::Flags::Fastest;
- if (p_lossy_quality > 0.85)
+ if (p_lossy_quality > 0.85) {
flags = cvtt::Flags::Ultra;
- else if (p_lossy_quality > 0.75)
+ } else if (p_lossy_quality > 0.75) {
flags = cvtt::Flags::Better;
- else if (p_lossy_quality > 0.55)
+ } else if (p_lossy_quality > 0.55) {
flags = cvtt::Flags::Default;
- else if (p_lossy_quality > 0.35)
+ } else if (p_lossy_quality > 0.35) {
flags = cvtt::Flags::Fast;
- else if (p_lossy_quality > 0.15)
+ } else if (p_lossy_quality > 0.15) {
flags = cvtt::Flags::Faster;
+ }
flags |= cvtt::Flags::BC7_RespectPunchThrough;
@@ -222,7 +223,6 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann
Vector<CVTTCompressionRowTask> 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 +280,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 +317,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<ResourceFormatDDS> 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..2f4f7d7a4c 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -29,14 +29,15 @@
/*************************************************************************/
#include "texture_loader_dds.h"
+
#include "core/os/file_access.h"
#define PF_FOURCC(s) ((uint32_t)(((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0])))
+// Reference: https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dds-header
+
enum {
DDS_MAGIC = 0x20534444,
- DDSD_CAPS = 0x00000001,
- DDSD_PIXELFORMAT = 0x00001000,
DDSD_PITCH = 0x00000008,
DDSD_LINEARSIZE = 0x00080000,
DDSD_MIPMAPCOUNT = 0x00020000,
@@ -47,7 +48,6 @@ enum {
};
enum DDSFormat {
-
DDS_DXT1,
DDS_DXT3,
DDS_DXT5,
@@ -95,18 +95,20 @@ 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)
+ if (r_error) {
*r_error = ERR_CANT_OPEN;
+ }
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (!f)
+ if (!f) {
return RES();
+ }
FileAccessRef fref(f);
- if (r_error)
+ if (r_error) {
*r_error = ERR_FILE_CORRUPT;
+ }
ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open DDS texture file '" + p_path + "'.");
@@ -120,13 +122,15 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
uint32_t mipmaps = f->get_32();
//skip 11
- for (int i = 0; i < 11; i++)
+ for (int i = 0; i < 11; i++) {
f->get_32();
+ }
//validate
- if (magic != DDS_MAGIC || hsize != 124 || !(flags & DDSD_PIXELFORMAT) || !(flags & DDSD_CAPS)) {
-
+ // We don't check DDSD_CAPS or DDSD_PIXELFORMAT, as they're mandatory when writing,
+ // but non-mandatory when reading (as some writers don't set them)...
+ if (magic != DDS_MAGIC || hsize != 124) {
ERR_FAIL_V_MSG(RES(), "Invalid or unsupported DDS texture file '" + p_path + "'.");
}
@@ -157,70 +161,55 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
*/
//must avoid this later
- while (f->get_position() < 128)
+ while (f->get_position() < 128) {
f->get_8();
+ }
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 + "'.");
}
- if (!(flags & DDSD_MIPMAPCOUNT))
+ if (!(flags & DDSD_MIPMAPCOUNT)) {
mipmaps = 1;
+ }
Vector<uint8_t> src_data;
@@ -236,7 +225,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 +237,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,16 +249,15 @@ 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)
+ if (palette[i * 4 + 3] < 255) {
colsize = 4;
+ }
}
int w2 = width;
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,14 +268,14 @@ 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];
wb[dst_ofs + 1] = palette[src_ofs + 1];
wb[dst_ofs + 2] = palette[src_ofs + 0];
- if (colsize == 4)
+ if (colsize == 4) {
wb[dst_ofs + 3] = palette[src_ofs + 3];
+ }
}
} else {
//uncompressed generic...
@@ -297,30 +283,27 @@ 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;
}
- if (dds_format == DDS_BGR565)
+ if (dds_format == DDS_BGR565) {
size = size * 3 / 2;
- else if (dds_format == DDS_BGR5A1)
+ } else if (dds_format == DDS_BGR5A1) {
size = size * 2;
+ }
src_data.resize(size);
uint8_t *wb = src_data.ptrw();
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 +318,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 +334,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 +354,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 +387,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 +397,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;
@@ -444,25 +415,24 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
Ref<ImageTexture> texture = memnew(ImageTexture);
texture->create_from_image(img);
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return texture;
}
void ResourceFormatDDS::get_recognized_extensions(List<String> *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")
+ if (p_path.get_extension().to_lower() == "dds") {
return "ImageTexture";
+ }
return "";
}
diff --git a/modules/denoise/config.py b/modules/denoise/config.py
index 53b8f2f2e3..091d7643c0 100644
--- a/modules/denoise/config.py
+++ b/modules/denoise/config.py
@@ -1,5 +1,11 @@
def can_build(env, platform):
- return env["tools"]
+ # Thirdparty dependency OpenImage Denoise includes oneDNN library
+ # which only supports 64-bit architectures.
+ # It's also only relevant for tools build and desktop platforms,
+ # as doing lightmap generation and denoising on Android or HTML5
+ # would be a bit far-fetched.
+ desktop_platforms = ["linuxbsd", "osx", "windows"]
+ return env["tools"] and platform in desktop_platforms and env["bits"] == "64"
def configure(env):
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 <stdio.h>
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/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<Image> LightmapDenoiserOIDN::denoise_image(const Ref<Image> &p_image) {
-
Ref<Image> 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..4e7698b67c 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -34,21 +34,18 @@
#include "core/os/os.h"
void NetworkedMultiplayerENet::set_transfer_mode(TransferMode p_mode) {
-
transfer_mode = p_mode;
}
-NetworkedMultiplayerPeer::TransferMode NetworkedMultiplayerENet::get_transfer_mode() const {
+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 +53,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 +60,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 +67,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).");
@@ -120,8 +114,8 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int
connection_status = CONNECTION_CONNECTED;
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) {
+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 +207,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,9 +214,9 @@ 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
+ if (!host || !active) { // Might have been disconnected while emitting a notification
return;
+ }
int ret = enet_host_service(host, &event, 0);
@@ -267,14 +260,15 @@ void NetworkedMultiplayerENet::poll() {
if (server) {
// Do not notify other peers when server_relay is disabled.
- if (!server_relay)
+ if (!server_relay) {
break;
+ }
// Someone connected, notify all the peers available
for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) {
-
- if (E->key() == *new_id)
+ if (E->key() == *new_id) {
continue;
+ }
// Send existing peers to new peer
ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE);
encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]);
@@ -287,13 +281,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,18 +299,16 @@ 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<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) {
-
- if (E->key() == *id)
+ if (E->key() == *id) {
continue;
+ }
ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE);
encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]);
@@ -332,7 +322,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 +334,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 +346,6 @@ void NetworkedMultiplayerENet::poll() {
enet_packet_destroy(event.packet);
} else if (event.channelID < channel_count) {
-
Packet packet;
packet.packet = event.packet;
@@ -391,9 +377,9 @@ void NetworkedMultiplayerENet::poll() {
incoming_packets.push_back(packet);
// And make copies for sending
for (Map<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) {
-
- if (uint32_t(E->key()) == source) // Do not resend to self
+ if (uint32_t(E->key()) == source) { // Do not resend to self
continue;
+ }
ENetPacket *packet2 = enet_packet_create(packet.packet->data, packet.packet->dataLength, packet.packet->flags);
@@ -405,9 +391,9 @@ void NetworkedMultiplayerENet::poll() {
// And make copies for sending
for (Map<int, ENetPeer *>::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
+ if (uint32_t(E->key()) == source || E->key() == -target) { // Do not resend to self, also do not send to excluded
continue;
+ }
ENetPacket *packet2 = enet_packet_create(packet.packet->data, packet.packet->dataLength, packet.packet->flags);
@@ -428,7 +414,6 @@ void NetworkedMultiplayerENet::poll() {
enet_peer_send(peer_map[target], event.channelID, packet.packet);
}
} else {
-
incoming_packets.push_back(packet);
}
@@ -452,7 +437,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 +468,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 +480,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<int, ENetPeer *>::Element *E = peer_map.front(); E; E = E->next()) {
-
if (E->key() == p_peer) {
continue;
}
@@ -509,8 +491,9 @@ void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) {
}
}
- if (id)
+ if (id) {
memdelete(id);
+ }
emit_signal("peer_disconnected", p_peer);
peer_map.erase(p_peer);
@@ -520,12 +503,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 +521,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.");
@@ -549,10 +529,11 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
switch (transfer_mode) {
case TRANSFER_MODE_UNRELIABLE: {
- if (always_ordered)
+ if (always_ordered) {
packet_flags = 0;
- else
+ } else {
packet_flags = ENET_PACKET_FLAG_UNSEQUENCED;
+ }
channel = SYSCH_UNRELIABLE;
} break;
case TRANSFER_MODE_UNRELIABLE_ORDERED: {
@@ -565,13 +546,13 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
} break;
}
- if (transfer_channel > SYSCH_CONFIG)
+ if (transfer_channel > SYSCH_CONFIG) {
channel = transfer_channel;
+ }
Map<int, ENetPeer *>::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 +563,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,9 +572,9 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
int exclude = -target_peer;
for (Map<int, ENetPeer *>::Element *F = peer_map.front(); F; F = F->next()) {
-
- if (F->key() == exclude) // Exclude packet
+ if (F->key() == exclude) { // Exclude packet
continue;
+ }
ENetPacket *packet2 = enet_packet_create(packet->data, packet->dataLength, packet_flags);
@@ -606,7 +586,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 +596,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 +609,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 +634,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) {
@@ -727,11 +695,13 @@ size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer *
}
int ret = Compression::compress(enet->dst_compressor_mem.ptrw(), enet->src_compressor_mem.ptr(), ofs, mode);
- if (ret < 0)
+ if (ret < 0) {
return 0;
+ }
- if (ret > int(outLimit))
+ if (ret > int(outLimit)) {
return 0; // Do not bother
+ }
copymem(outData, enet->dst_compressor_mem.ptr(), ret);
@@ -739,20 +709,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 +732,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 +742,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 +767,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 +778,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 +788,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 +816,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 +859,6 @@ void NetworkedMultiplayerENet::_bind_methods() {
}
NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
-
active = false;
server = false;
refuse_connections = false;
@@ -929,7 +884,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 <enet/enet.h>
class NetworkedMultiplayerENet : public NetworkedMultiplayerPeer {
-
GDCLASS(NetworkedMultiplayerENet, NetworkedMultiplayerPeer);
public:
@@ -86,7 +85,6 @@ private:
Map<int, ENetPeer *> 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..18051f756a 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,7 @@ void register_enet_types() {
}
void unregister_enet_types() {
-
- if (enet_ok)
+ if (enet_ok) {
enet_deinitialize();
+ }
}
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index 223830f445..9b6d8a2d35 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -127,8 +127,9 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
Ref<Image> img = p_img->duplicate();
- if (img->get_format() != Image::FORMAT_RGBA8)
+ if (img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
+ }
if (img->has_mipmaps()) {
if (next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh) {
@@ -165,12 +166,13 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
int encoding_time = 0;
float effort = 0.0; //default, reasonable time
- if (p_lossy_quality > 0.75)
+ if (p_lossy_quality > 0.75) {
effort = 0.4;
- else if (p_lossy_quality > 0.85)
+ } else if (p_lossy_quality > 0.85) {
effort = 0.6;
- else if (p_lossy_quality > 0.95)
+ } else if (p_lossy_quality > 0.95) {
effort = 0.8;
+ }
Etc::ErrorMetric error_metric = Etc::ErrorMetric::RGBX; // NOTE: we can experiment with other error metrics
Etc::Image::Format etc2comp_etc_format = _image_format_to_etc2comp_format(etc_format);
@@ -219,7 +221,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<ResourceFormatPKM> 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..c40e9612a8 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -43,18 +43,20 @@ 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)
+ if (r_error) {
*r_error = ERR_CANT_OPEN;
+ }
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (!f)
+ if (!f) {
return RES();
+ }
FileAccessRef fref(f);
- if (r_error)
+ if (r_error) {
*r_error = ERR_FILE_CORRUPT;
+ }
ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open PKM texture file '" + p_path + "'.");
@@ -87,8 +89,9 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
Ref<ImageTexture> texture = memnew(ImageTexture);
texture->create_from_image(img);
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
f->close();
memdelete(f);
@@ -96,18 +99,16 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
}
void ResourceFormatPKM::get_recognized_extensions(List<String> *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")
+ 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..3d747ba41e 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/")) {
@@ -115,8 +114,9 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
// set entries
List<String> entry_key_list;
- if (config_file->has_section("entry"))
+ if (config_file->has_section("entry")) {
config_file->get_section_keys("entry", &entry_key_list);
+ }
for (List<String>::Element *E = entry_key_list.front(); E; E = E->next()) {
String key = E->get();
@@ -132,8 +132,9 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
// set dependencies
List<String> dependency_key_list;
- if (config_file->has_section("dependencies"))
+ if (config_file->has_section("dependencies")) {
config_file->get_section_keys("dependencies", &dependency_key_list);
+ }
for (List<String>::Element *E = dependency_key_list.front(); E; E = E->next()) {
String key = E->get();
@@ -148,7 +149,6 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
}
void GDNativeLibrary::set_config_file(Ref<ConfigFile> 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,11 +156,11 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) {
String entry_lib_path;
{
-
List<String> entry_keys;
- if (p_config_file->has_section("entry"))
+ if (p_config_file->has_section("entry")) {
p_config_file->get_section_keys("entry", &entry_keys);
+ }
for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) {
String key = E->get();
@@ -188,11 +188,11 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) {
Vector<String> dependency_paths;
{
-
List<String> dependency_keys;
- if (p_config_file->has_section("dependencies"))
+ if (p_config_file->has_section("dependencies")) {
p_config_file->get_section_keys("dependencies", &dependency_keys);
+ }
for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) {
String key = E->get();
@@ -383,7 +383,6 @@ bool GDNative::initialize() {
}
bool GDNative::terminate() {
-
if (!initialized) {
ERR_PRINT("No valid library handle, can't terminate GDNative object");
return false;
@@ -452,7 +451,6 @@ Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
}
Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) {
-
Map<StringName, native_call_cb>::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 +476,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;
@@ -520,13 +517,13 @@ bool GDNativeLibraryResourceLoader::handles_type(const String &p_type) const {
String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (el == "gdnlib")
+ if (el == "gdnlib") {
return "GDNativeLibrary";
+ }
return "";
}
Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<GDNativeLibrary> lib = p_resource;
if (lib.is_null()) {
diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp
index 246e5d4e8d..7f22c7dfe3 100644
--- a/modules/gdnative/gdnative/aabb.cpp
+++ b/modules/gdnative/gdnative/aabb.cpp
@@ -37,6 +37,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch");
+
void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) {
const Vector3 *pos = (const Vector3 *)p_pos;
const Vector3 *size = (const Vector3 *)p_size;
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index 0c764ab8fd..59953f5182 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -41,6 +41,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch");
+
void GDAPI godot_array_new(godot_array *r_dest) {
Array *dest = (Array *)r_dest;
memnew_placement(dest, Array);
@@ -100,9 +102,33 @@ void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_
}
}
-void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_packed_real_array *p_pra) {
+void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra) {
+ Array *dest = (Array *)r_dest;
+ Vector<float> *pca = (Vector<float> *)p_pra;
+ memnew_placement(dest, Array);
+ dest->resize(pca->size());
+
+ for (int i = 0; i < dest->size(); i++) {
+ Variant v = pca->operator[](i);
+ dest->operator[](i) = v;
+ }
+}
+
+void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra) {
+ Array *dest = (Array *)r_dest;
+ Vector<double> *pca = (Vector<double> *)p_pra;
+ memnew_placement(dest, Array);
+ dest->resize(pca->size());
+
+ for (int i = 0; i < dest->size(); i++) {
+ Variant v = pca->operator[](i);
+ dest->operator[](i) = v;
+ }
+}
+
+void GDAPI godot_array_new_packed_int32_array(godot_array *r_dest, const godot_packed_int32_array *p_pia) {
Array *dest = (Array *)r_dest;
- Vector<godot_real> *pca = (Vector<godot_real> *)p_pra;
+ Vector<int32_t> *pca = (Vector<int32_t> *)p_pia;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -112,9 +138,9 @@ void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_pa
}
}
-void GDAPI godot_array_new_packed_int_array(godot_array *r_dest, const godot_packed_int_array *p_pia) {
+void GDAPI godot_array_new_packed_int64_array(godot_array *r_dest, const godot_packed_int64_array *p_pia) {
Array *dest = (Array *)r_dest;
- Vector<godot_int> *pca = (Vector<godot_int> *)p_pia;
+ Vector<int64_t> *pca = (Vector<int64_t> *)p_pia;
memnew_placement(dest, Array);
dest->resize(pca->size());
diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp
index 4f489287b9..990fd3795d 100644
--- a/modules/gdnative/gdnative/basis.cpp
+++ b/modules/gdnative/gdnative/basis.cpp
@@ -37,6 +37,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch");
+
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis) {
const Vector3 *x_axis = (const Vector3 *)p_x_axis;
const Vector3 *y_axis = (const Vector3 *)p_y_axis;
diff --git a/modules/gdnative/gdnative/callable.cpp b/modules/gdnative/gdnative/callable.cpp
new file mode 100644
index 0000000000..868b324227
--- /dev/null
+++ b/modules/gdnative/gdnative/callable.cpp
@@ -0,0 +1,252 @@
+/*************************************************************************/
+/* callable.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 "gdnative/callable.h"
+
+#include "core/callable.h"
+#include "core/resource.h"
+#include "core/variant.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static_assert(sizeof(godot_callable) == sizeof(Callable), "Callable size mismatch");
+static_assert(sizeof(godot_signal) == sizeof(Signal), "Signal size mismatch");
+
+// Callable
+
+void GDAPI godot_callable_new_with_object(godot_callable *r_dest, const godot_object *p_object, const godot_string_name *p_method) {
+ Callable *dest = (Callable *)r_dest;
+ const Object *object = (const Object *)p_object;
+ const StringName *method = (const StringName *)p_method;
+ memnew_placement(dest, Callable(object, *method));
+}
+
+void GDAPI godot_callable_new_with_object_id(godot_callable *r_dest, uint64_t p_objectid, const godot_string_name *p_method) {
+ Callable *dest = (Callable *)r_dest;
+ const StringName *method = (const StringName *)p_method;
+ memnew_placement(dest, Callable(ObjectID(p_objectid), *method));
+}
+
+void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src) {
+ Callable *dest = (Callable *)r_dest;
+ const Callable *src = (const Callable *)p_src;
+ memnew_placement(dest, Callable(*src));
+}
+
+void GDAPI godot_callable_destroy(godot_callable *p_self) {
+ Callable *self = (Callable *)p_self;
+ self->~Callable();
+}
+
+godot_int GDAPI godot_callable_call(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount, godot_variant *r_return_value) {
+ const Callable *self = (const Callable *)p_self;
+ const Variant **arguments = (const Variant **)p_arguments;
+ Variant *return_value = (Variant *)r_return_value;
+ Variant ret;
+ Callable::CallError err;
+ self->call(arguments, p_argcount, ret, err);
+ if (return_value)
+ (*return_value) = ret;
+ return (godot_int)err.error;
+}
+
+void GDAPI godot_callable_call_deferred(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount) {
+ const Callable *self = (const Callable *)p_self;
+ const Variant **arguments = (const Variant **)p_arguments;
+ self->call_deferred(arguments, p_argcount);
+}
+
+godot_bool GDAPI godot_callable_is_null(const godot_callable *p_self) {
+ const Callable *self = (const Callable *)p_self;
+ return self->is_null();
+}
+
+godot_bool GDAPI godot_callable_is_custom(const godot_callable *p_self) {
+ const Callable *self = (const Callable *)p_self;
+ return self->is_custom();
+}
+
+godot_bool GDAPI godot_callable_is_standard(const godot_callable *p_self) {
+ const Callable *self = (const Callable *)p_self;
+ return self->is_standard();
+}
+
+godot_object GDAPI *godot_callable_get_object(const godot_callable *p_self) {
+ const Callable *self = (const Callable *)p_self;
+ return (godot_object *)self->get_object();
+}
+
+uint64_t GDAPI godot_callable_get_object_id(const godot_callable *p_self) {
+ const Callable *self = (const Callable *)p_self;
+ return (uint64_t)self->get_object_id();
+}
+
+godot_string_name GDAPI godot_callable_get_method(const godot_callable *p_self) {
+ godot_string_name raw_dest;
+ const Callable *self = (const Callable *)p_self;
+ StringName *dest = (StringName *)&raw_dest;
+ memnew_placement(dest, StringName(self->get_method()));
+ return raw_dest;
+}
+
+uint32_t GDAPI godot_callable_hash(const godot_callable *p_self) {
+ const Callable *self = (const Callable *)p_self;
+ return self->hash();
+}
+
+godot_string GDAPI godot_callable_as_string(const godot_callable *p_self) {
+ godot_string ret;
+ const Callable *self = (const Callable *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_bool GDAPI godot_callable_operator_equal(const godot_callable *p_self, const godot_callable *p_other) {
+ const Callable *self = (const Callable *)p_self;
+ const Callable *other = (const Callable *)p_other;
+ return *self == *other;
+}
+
+godot_bool GDAPI godot_callable_operator_less(const godot_callable *p_self, const godot_callable *p_other) {
+ const Callable *self = (const Callable *)p_self;
+ const Callable *other = (const Callable *)p_other;
+ return *self < *other;
+}
+
+// Signal
+
+void GDAPI godot_signal_new_with_object(godot_signal *r_dest, const godot_object *p_object, const godot_string_name *p_name) {
+ Signal *dest = (Signal *)r_dest;
+ const Object *object = (const Object *)p_object;
+ const StringName *name = (const StringName *)p_name;
+ memnew_placement(dest, Signal(object, *name));
+}
+
+void GDAPI godot_signal_new_with_object_id(godot_signal *r_dest, uint64_t p_objectid, const godot_string_name *p_name) {
+ Signal *dest = (Signal *)r_dest;
+ const StringName *name = (const StringName *)p_name;
+ memnew_placement(dest, Signal(ObjectID(p_objectid), *name));
+}
+
+void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src) {
+ Signal *dest = (Signal *)r_dest;
+ const Signal *src = (const Signal *)p_src;
+ memnew_placement(dest, Signal(*src));
+}
+
+void GDAPI godot_signal_destroy(godot_signal *p_self) {
+ Signal *self = (Signal *)p_self;
+ self->~Signal();
+}
+
+godot_int GDAPI godot_signal_emit(const godot_signal *p_self, const godot_variant **p_arguments, godot_int p_argcount) {
+ const Signal *self = (const Signal *)p_self;
+ const Variant **arguments = (const Variant **)p_arguments;
+ return (godot_int)self->emit(arguments, p_argcount);
+}
+
+godot_int GDAPI godot_signal_connect(godot_signal *p_self, const godot_callable *p_callable, const godot_array *p_binds, uint32_t p_flags) {
+ Signal *self = (Signal *)p_self;
+ const Callable *callable = (const Callable *)p_callable;
+ const Array *binds_ar = (const Array *)p_binds;
+ Vector<Variant> binds;
+ for (int i = 0; i < binds_ar->size(); i++) {
+ binds.push_back(binds_ar->get(i));
+ }
+ return (godot_int)self->connect(*callable, binds, p_flags);
+}
+
+void GDAPI godot_signal_disconnect(godot_signal *p_self, const godot_callable *p_callable) {
+ Signal *self = (Signal *)p_self;
+ const Callable *callable = (const Callable *)p_callable;
+ self->disconnect(*callable);
+}
+
+godot_bool GDAPI godot_signal_is_null(const godot_signal *p_self) {
+ const Signal *self = (const Signal *)p_self;
+ return self->is_null();
+}
+
+godot_bool GDAPI godot_signal_is_connected(const godot_signal *p_self, const godot_callable *p_callable) {
+ const Signal *self = (const Signal *)p_self;
+ const Callable *callable = (const Callable *)p_callable;
+ return self->is_connected(*callable);
+}
+
+godot_array GDAPI godot_signal_get_connections(const godot_signal *p_self) {
+ godot_array raw_dest;
+ const Signal *self = (const Signal *)p_self;
+ Array *dest = (Array *)&raw_dest;
+ memnew_placement(dest, Array(self->get_connections()));
+ return raw_dest;
+}
+
+godot_object GDAPI *godot_signal_get_object(const godot_signal *p_self) {
+ const Signal *self = (const Signal *)p_self;
+ return (godot_object *)self->get_object();
+}
+
+uint64_t GDAPI godot_signal_get_object_id(const godot_signal *p_self) {
+ const Signal *self = (const Signal *)p_self;
+ return (uint64_t)self->get_object_id();
+}
+
+godot_string_name GDAPI godot_signal_get_name(const godot_signal *p_self) {
+ godot_string_name raw_dest;
+ const Signal *self = (const Signal *)p_self;
+ StringName *dest = (StringName *)&raw_dest;
+ memnew_placement(dest, StringName(self->get_name()));
+ return raw_dest;
+}
+
+godot_string GDAPI godot_signal_as_string(const godot_signal *p_self) {
+ godot_string ret;
+ const Signal *self = (const Signal *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_bool GDAPI godot_signal_operator_equal(const godot_signal *p_self, const godot_signal *p_other) {
+ const Signal *self = (const Signal *)p_self;
+ const Signal *other = (const Signal *)p_other;
+ return *self == *other;
+}
+
+godot_bool GDAPI godot_signal_operator_less(const godot_signal *p_self, const godot_signal *p_other) {
+ const Signal *self = (const Signal *)p_self;
+ const Signal *other = (const Signal *)p_other;
+ return *self < *other;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp
index 68c83e05a6..c75e74daba 100644
--- a/modules/gdnative/gdnative/color.cpp
+++ b/modules/gdnative/gdnative/color.cpp
@@ -37,14 +37,14 @@
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) {
+static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch");
+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/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp
index b145b88934..a126974815 100644
--- a/modules/gdnative/gdnative/dictionary.cpp
+++ b/modules/gdnative/gdnative/dictionary.cpp
@@ -39,6 +39,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch");
+
void GDAPI godot_dictionary_new(godot_dictionary *r_dest) {
Dictionary *dest = (Dictionary *)r_dest;
memnew_placement(dest, Dictionary);
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 1216d1d9d3..e94190b07b 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);
@@ -93,8 +91,9 @@ godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, god
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
- if (class_info)
+ if (class_info) {
return (godot_class_constructor)class_info->creation_func;
+ }
return nullptr;
}
@@ -166,7 +165,7 @@ void _gdnative_report_loading_error(const godot_object *p_library, const char *p
_err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
}
-godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) {
+godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id) {
return (godot_object *)ObjectDB::get_instance(ObjectID(p_instance_id));
}
@@ -177,13 +176,19 @@ void *godot_get_class_tag(const godot_string_name *p_class) {
}
godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) {
- if (!p_object)
+ if (!p_object) {
return nullptr;
+ }
Object *o = (Object *)p_object;
return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr;
}
+uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object) {
+ const Object *o = (const Object *)p_object;
+ return (uint64_t)o->get_instance_id();
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp
index 93f43835c8..88ed650ebe 100644
--- a/modules/gdnative/gdnative/node_path.cpp
+++ b/modules/gdnative/gdnative/node_path.cpp
@@ -37,6 +37,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch");
+
void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from) {
NodePath *dest = (NodePath *)r_dest;
const String *from = (const String *)p_from;
diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp
index 589b4d4dfe..fc71d50289 100644
--- a/modules/gdnative/gdnative/pool_arrays.cpp
+++ b/modules/gdnative/gdnative/packed_arrays.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* pool_arrays.cpp */
+/* packed_arrays.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gdnative/pool_arrays.h"
+#include "gdnative/packed_arrays.h"
#include "core/array.h"
@@ -42,6 +42,16 @@
extern "C" {
#endif
+static_assert(sizeof(godot_packed_byte_array) == sizeof(Vector<uint8_t>), "Vector<uint8_t> size mismatch");
+static_assert(sizeof(godot_packed_int32_array) == sizeof(Vector<int32_t>), "Vector<int32_t> size mismatch");
+static_assert(sizeof(godot_packed_int64_array) == sizeof(Vector<int64_t>), "Vector<int64_t> size mismatch");
+static_assert(sizeof(godot_packed_float32_array) == sizeof(Vector<float>), "Vector<float> size mismatch");
+static_assert(sizeof(godot_packed_float64_array) == sizeof(Vector<double>), "Vector<double> size mismatch");
+static_assert(sizeof(godot_packed_string_array) == sizeof(Vector<String>), "Vector<String> size mismatch");
+static_assert(sizeof(godot_packed_vector2_array) == sizeof(Vector<Vector2>), "Vector<Vector2> size mismatch");
+static_assert(sizeof(godot_packed_vector3_array) == sizeof(Vector<Vector3>), "Vector<Vector3> size mismatch");
+static_assert(sizeof(godot_packed_color_array) == sizeof(Vector<Color>), "Vector<Color> size mismatch");
+
#define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr)
// byte
@@ -68,6 +78,16 @@ void GDAPI godot_packed_byte_array_new_with_array(godot_packed_byte_array *r_des
}
}
+const uint8_t GDAPI *godot_packed_byte_array_ptr(const godot_packed_byte_array *p_self) {
+ const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self;
+ return self->ptr();
+}
+
+uint8_t GDAPI *godot_packed_byte_array_ptrw(godot_packed_byte_array *p_self) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
+ return self->ptrw();
+}
+
void GDAPI godot_packed_byte_array_append(godot_packed_byte_array *p_self, const uint8_t p_data) {
Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
self->push_back(p_data);
@@ -128,23 +148,117 @@ void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) {
((Vector<uint8_t> *)p_self)->~Vector();
}
-// int
+// int32
+
+void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *r_dest) {
+ Vector<int32_t> *dest = (Vector<int32_t> *)r_dest;
+ memnew_placement(dest, Vector<int32_t>);
+}
+
+void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src) {
+ Vector<int32_t> *dest = (Vector<int32_t> *)r_dest;
+ const Vector<int32_t> *src = (const Vector<int32_t> *)p_src;
+ memnew_placement(dest, Vector<int32_t>(*src));
+}
+
+void GDAPI godot_packed_int32_array_new_with_array(godot_packed_int32_array *r_dest, const godot_array *p_a) {
+ Vector<int32_t> *dest = (Vector<int32_t> *)r_dest;
+ Array *a = (Array *)p_a;
+ memnew_placement(dest, Vector<int32_t>);
+
+ dest->resize(a->size());
+ for (int i = 0; i < a->size(); i++) {
+ dest->set(i, (*a)[i]);
+ }
+}
+
+const int32_t GDAPI *godot_packed_int32_array_ptr(const godot_packed_int32_array *p_self) {
+ const Vector<int32_t> *self = (const Vector<int32_t> *)p_self;
+ return self->ptr();
+}
+
+int32_t GDAPI *godot_packed_int32_array_ptrw(godot_packed_int32_array *p_self) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ return self->ptrw();
+}
+
+void GDAPI godot_packed_int32_array_append(godot_packed_int32_array *p_self, const int32_t p_data) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ self->push_back(p_data);
+}
+
+void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_self, const godot_packed_int32_array *p_array) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ Vector<int32_t> *array = (Vector<int32_t> *)p_array;
+ self->append_array(*array);
+}
+
+godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ return (godot_error)self->insert(p_idx, p_data);
+}
+
+void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ self->invert();
+}
+
+void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ self->push_back(p_data);
+}
+
+void GDAPI godot_packed_int32_array_remove(godot_packed_int32_array *p_self, const godot_int p_idx) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ self->remove(p_idx);
+}
+
+void GDAPI godot_packed_int32_array_resize(godot_packed_int32_array *p_self, const godot_int p_size) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ self->resize(p_size);
+}
+
+void GDAPI godot_packed_int32_array_set(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data) {
+ Vector<int32_t> *self = (Vector<int32_t> *)p_self;
+ self->set(p_idx, p_data);
+}
+
+int32_t GDAPI godot_packed_int32_array_get(const godot_packed_int32_array *p_self, const godot_int p_idx) {
+ const Vector<int32_t> *self = (const Vector<int32_t> *)p_self;
+ return self->get(p_idx);
+}
+
+godot_int GDAPI godot_packed_int32_array_size(const godot_packed_int32_array *p_self) {
+ const Vector<int32_t> *self = (const Vector<int32_t> *)p_self;
+ return self->size();
+}
+
+godot_bool GDAPI godot_packed_int32_array_empty(const godot_packed_int32_array *p_self) {
+ const Vector<int32_t> *self = (const Vector<int32_t> *)p_self;
+ return self->empty();
+}
+
+void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self) {
+ ((Vector<int32_t> *)p_self)->~Vector();
+}
+
+// int64
-void GDAPI godot_packed_int_array_new(godot_packed_int_array *r_dest) {
- Vector<godot_int> *dest = (Vector<godot_int> *)r_dest;
- memnew_placement(dest, Vector<godot_int>);
+void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *r_dest) {
+ Vector<int64_t> *dest = (Vector<int64_t> *)r_dest;
+ memnew_placement(dest, Vector<int64_t>);
}
-void GDAPI godot_packed_int_array_new_copy(godot_packed_int_array *r_dest, const godot_packed_int_array *p_src) {
- Vector<godot_int> *dest = (Vector<godot_int> *)r_dest;
- const Vector<godot_int> *src = (const Vector<godot_int> *)p_src;
- memnew_placement(dest, Vector<godot_int>(*src));
+void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src) {
+ Vector<int64_t> *dest = (Vector<int64_t> *)r_dest;
+ const Vector<int64_t> *src = (const Vector<int64_t> *)p_src;
+ memnew_placement(dest, Vector<int64_t>(*src));
}
-void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, const godot_array *p_a) {
- Vector<godot_int> *dest = (Vector<godot_int> *)r_dest;
+void GDAPI godot_packed_int64_array_new_with_array(godot_packed_int64_array *r_dest, const godot_array *p_a) {
+ Vector<int64_t> *dest = (Vector<int64_t> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, Vector<godot_int>);
+ memnew_placement(dest, Vector<int64_t>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -152,83 +266,93 @@ void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest,
}
}
-void GDAPI godot_packed_int_array_append(godot_packed_int_array *p_self, const godot_int p_data) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+const int64_t GDAPI *godot_packed_int64_array_ptr(const godot_packed_int64_array *p_self) {
+ const Vector<int64_t> *self = (const Vector<int64_t> *)p_self;
+ return self->ptr();
+}
+
+int64_t GDAPI *godot_packed_int64_array_ptrw(godot_packed_int64_array *p_self) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
+ return self->ptrw();
+}
+
+void GDAPI godot_packed_int64_array_append(godot_packed_int64_array *p_self, const int64_t p_data) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_packed_int_array_append_array(godot_packed_int_array *p_self, const godot_packed_int_array *p_array) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
- Vector<godot_int> *array = (Vector<godot_int> *)p_array;
+void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_self, const godot_packed_int64_array *p_array) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
+ Vector<int64_t> *array = (Vector<int64_t> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_packed_int_array_insert(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
return (godot_error)self->insert(p_idx, p_data);
}
-void GDAPI godot_packed_int_array_invert(godot_packed_int_array *p_self) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
self->invert();
}
-void GDAPI godot_packed_int_array_push_back(godot_packed_int_array *p_self, const godot_int p_data) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_packed_int_array_remove(godot_packed_int_array *p_self, const godot_int p_idx) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+void GDAPI godot_packed_int64_array_remove(godot_packed_int64_array *p_self, const godot_int p_idx) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_packed_int_array_resize(godot_packed_int_array *p_self, const godot_int p_size) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+void GDAPI godot_packed_int64_array_resize(godot_packed_int64_array *p_self, const godot_int p_size) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
self->resize(p_size);
}
-void GDAPI godot_packed_int_array_set(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data) {
- Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+void GDAPI godot_packed_int64_array_set(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data) {
+ Vector<int64_t> *self = (Vector<int64_t> *)p_self;
self->set(p_idx, p_data);
}
-godot_int GDAPI godot_packed_int_array_get(const godot_packed_int_array *p_self, const godot_int p_idx) {
- const Vector<godot_int> *self = (const Vector<godot_int> *)p_self;
+int64_t GDAPI godot_packed_int64_array_get(const godot_packed_int64_array *p_self, const godot_int p_idx) {
+ const Vector<int64_t> *self = (const Vector<int64_t> *)p_self;
return self->get(p_idx);
}
-godot_int GDAPI godot_packed_int_array_size(const godot_packed_int_array *p_self) {
- const Vector<godot_int> *self = (const Vector<godot_int> *)p_self;
+godot_int GDAPI godot_packed_int64_array_size(const godot_packed_int64_array *p_self) {
+ const Vector<int64_t> *self = (const Vector<int64_t> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_packed_int_array_empty(const godot_packed_int_array *p_self) {
- const Vector<godot_int> *self = (const Vector<godot_int> *)p_self;
+godot_bool GDAPI godot_packed_int64_array_empty(const godot_packed_int64_array *p_self) {
+ const Vector<int64_t> *self = (const Vector<int64_t> *)p_self;
return self->empty();
}
-void GDAPI godot_packed_int_array_destroy(godot_packed_int_array *p_self) {
- ((Vector<godot_int> *)p_self)->~Vector();
+void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self) {
+ ((Vector<int64_t> *)p_self)->~Vector();
}
-// real
+// float32
-void GDAPI godot_packed_real_array_new(godot_packed_real_array *r_dest) {
- Vector<godot_real> *dest = (Vector<godot_real> *)r_dest;
- memnew_placement(dest, Vector<godot_real>);
+void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *r_dest) {
+ Vector<float> *dest = (Vector<float> *)r_dest;
+ memnew_placement(dest, Vector<float>);
}
-void GDAPI godot_packed_real_array_new_copy(godot_packed_real_array *r_dest, const godot_packed_real_array *p_src) {
- Vector<godot_real> *dest = (Vector<godot_real> *)r_dest;
- const Vector<godot_real> *src = (const Vector<godot_real> *)p_src;
- memnew_placement(dest, Vector<godot_real>(*src));
+void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src) {
+ Vector<float> *dest = (Vector<float> *)r_dest;
+ const Vector<float> *src = (const Vector<float> *)p_src;
+ memnew_placement(dest, Vector<float>(*src));
}
-void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_dest, const godot_array *p_a) {
- Vector<godot_real> *dest = (Vector<godot_real> *)r_dest;
+void GDAPI godot_packed_float32_array_new_with_array(godot_packed_float32_array *r_dest, const godot_array *p_a) {
+ Vector<float> *dest = (Vector<float> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, Vector<godot_real>);
+ memnew_placement(dest, Vector<float>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -236,64 +360,168 @@ void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_des
}
}
-void GDAPI godot_packed_real_array_append(godot_packed_real_array *p_self, const godot_real p_data) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+const float GDAPI *godot_packed_float32_array_ptr(const godot_packed_float32_array *p_self) {
+ const Vector<float> *self = (const Vector<float> *)p_self;
+ return self->ptr();
+}
+
+float GDAPI *godot_packed_float32_array_ptrw(godot_packed_float32_array *p_self) {
+ Vector<float> *self = (Vector<float> *)p_self;
+ return self->ptrw();
+}
+
+void GDAPI godot_packed_float32_array_append(godot_packed_float32_array *p_self, const float p_data) {
+ Vector<float> *self = (Vector<float> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_packed_real_array_append_array(godot_packed_real_array *p_self, const godot_packed_real_array *p_array) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
- Vector<godot_real> *array = (Vector<godot_real> *)p_array;
+void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p_self, const godot_packed_float32_array *p_array) {
+ Vector<float> *self = (Vector<float> *)p_self;
+ Vector<float> *array = (Vector<float> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_packed_real_array_insert(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data) {
+ Vector<float> *self = (Vector<float> *)p_self;
return (godot_error)self->insert(p_idx, p_data);
}
-void GDAPI godot_packed_real_array_invert(godot_packed_real_array *p_self) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self) {
+ Vector<float> *self = (Vector<float> *)p_self;
self->invert();
}
-void GDAPI godot_packed_real_array_push_back(godot_packed_real_array *p_self, const godot_real p_data) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data) {
+ Vector<float> *self = (Vector<float> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_packed_real_array_remove(godot_packed_real_array *p_self, const godot_int p_idx) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+void GDAPI godot_packed_float32_array_remove(godot_packed_float32_array *p_self, const godot_int p_idx) {
+ Vector<float> *self = (Vector<float> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_packed_real_array_resize(godot_packed_real_array *p_self, const godot_int p_size) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+void GDAPI godot_packed_float32_array_resize(godot_packed_float32_array *p_self, const godot_int p_size) {
+ Vector<float> *self = (Vector<float> *)p_self;
self->resize(p_size);
}
-void GDAPI godot_packed_real_array_set(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data) {
- Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+void GDAPI godot_packed_float32_array_set(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data) {
+ Vector<float> *self = (Vector<float> *)p_self;
self->set(p_idx, p_data);
}
-godot_real GDAPI godot_packed_real_array_get(const godot_packed_real_array *p_self, const godot_int p_idx) {
- const Vector<godot_real> *self = (const Vector<godot_real> *)p_self;
+float GDAPI godot_packed_float32_array_get(const godot_packed_float32_array *p_self, const godot_int p_idx) {
+ const Vector<float> *self = (const Vector<float> *)p_self;
return self->get(p_idx);
}
-godot_int GDAPI godot_packed_real_array_size(const godot_packed_real_array *p_self) {
- const Vector<godot_real> *self = (const Vector<godot_real> *)p_self;
+godot_int GDAPI godot_packed_float32_array_size(const godot_packed_float32_array *p_self) {
+ const Vector<float> *self = (const Vector<float> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_packed_real_array_empty(const godot_packed_real_array *p_self) {
- const Vector<godot_real> *self = (const Vector<godot_real> *)p_self;
+godot_bool GDAPI godot_packed_float32_array_empty(const godot_packed_float32_array *p_self) {
+ const Vector<float> *self = (const Vector<float> *)p_self;
return self->empty();
}
-void GDAPI godot_packed_real_array_destroy(godot_packed_real_array *p_self) {
- ((Vector<godot_real> *)p_self)->~Vector();
+void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self) {
+ ((Vector<float> *)p_self)->~Vector();
+}
+
+// float64
+
+void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *r_dest) {
+ Vector<double> *dest = (Vector<double> *)r_dest;
+ memnew_placement(dest, Vector<double>);
+}
+
+void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src) {
+ Vector<double> *dest = (Vector<double> *)r_dest;
+ const Vector<double> *src = (const Vector<double> *)p_src;
+ memnew_placement(dest, Vector<double>(*src));
+}
+
+void GDAPI godot_packed_float64_array_new_with_array(godot_packed_float64_array *r_dest, const godot_array *p_a) {
+ Vector<double> *dest = (Vector<double> *)r_dest;
+ Array *a = (Array *)p_a;
+ memnew_placement(dest, Vector<double>);
+
+ dest->resize(a->size());
+ for (int i = 0; i < a->size(); i++) {
+ dest->set(i, (*a)[i]);
+ }
+}
+
+const double GDAPI *godot_packed_float64_array_ptr(const godot_packed_float64_array *p_self) {
+ const Vector<double> *self = (const Vector<double> *)p_self;
+ return self->ptr();
+}
+
+double GDAPI *godot_packed_float64_array_ptrw(godot_packed_float64_array *p_self) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ return self->ptrw();
+}
+
+void GDAPI godot_packed_float64_array_append(godot_packed_float64_array *p_self, const double p_data) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ self->push_back(p_data);
+}
+
+void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p_self, const godot_packed_float64_array *p_array) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ Vector<double> *array = (Vector<double> *)p_array;
+ self->append_array(*array);
+}
+
+godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ return (godot_error)self->insert(p_idx, p_data);
+}
+
+void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ self->invert();
+}
+
+void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ self->push_back(p_data);
+}
+
+void GDAPI godot_packed_float64_array_remove(godot_packed_float64_array *p_self, const godot_int p_idx) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ self->remove(p_idx);
+}
+
+void GDAPI godot_packed_float64_array_resize(godot_packed_float64_array *p_self, const godot_int p_size) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ self->resize(p_size);
+}
+
+void GDAPI godot_packed_float64_array_set(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data) {
+ Vector<double> *self = (Vector<double> *)p_self;
+ self->set(p_idx, p_data);
+}
+
+double GDAPI godot_packed_float64_array_get(const godot_packed_float64_array *p_self, const godot_int p_idx) {
+ const Vector<double> *self = (const Vector<double> *)p_self;
+ return self->get(p_idx);
+}
+
+godot_int GDAPI godot_packed_float64_array_size(const godot_packed_float64_array *p_self) {
+ const Vector<double> *self = (const Vector<double> *)p_self;
+ return self->size();
+}
+
+godot_bool GDAPI godot_packed_float64_array_empty(const godot_packed_float64_array *p_self) {
+ const Vector<double> *self = (const Vector<double> *)p_self;
+ return self->empty();
+}
+
+void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self) {
+ ((Vector<double> *)p_self)->~Vector();
}
// string
@@ -320,6 +548,16 @@ void GDAPI godot_packed_string_array_new_with_array(godot_packed_string_array *r
}
}
+const godot_string GDAPI *godot_packed_string_array_ptr(const godot_packed_string_array *p_self) {
+ const Vector<String> *self = (const Vector<String> *)p_self;
+ return (const godot_string *)self->ptr();
+}
+
+godot_string GDAPI *godot_packed_string_array_ptrw(godot_packed_string_array *p_self) {
+ Vector<String> *self = (Vector<String> *)p_self;
+ return (godot_string *)self->ptrw();
+}
+
void GDAPI godot_packed_string_array_append(godot_packed_string_array *p_self, const godot_string *p_data) {
Vector<String> *self = (Vector<String> *)p_self;
String &s = *(String *)p_data;
@@ -412,6 +650,16 @@ void GDAPI godot_packed_vector2_array_new_with_array(godot_packed_vector2_array
}
}
+const godot_vector2 GDAPI *godot_packed_vector2_array_ptr(const godot_packed_vector2_array *p_self) {
+ const Vector<Vector2> *self = (const Vector<Vector2> *)p_self;
+ return (const godot_vector2 *)self->ptr();
+}
+
+godot_vector2 GDAPI *godot_packed_vector2_array_ptrw(godot_packed_vector2_array *p_self) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
+ return (godot_vector2 *)self->ptrw();
+}
+
void GDAPI godot_packed_vector2_array_append(godot_packed_vector2_array *p_self, const godot_vector2 *p_data) {
Vector<Vector2> *self = (Vector<Vector2> *)p_self;
Vector2 &s = *(Vector2 *)p_data;
@@ -503,6 +751,16 @@ void GDAPI godot_packed_vector3_array_new_with_array(godot_packed_vector3_array
}
}
+const godot_vector3 GDAPI *godot_packed_vector3_array_ptr(const godot_packed_vector3_array *p_self) {
+ const Vector<Vector3> *self = (const Vector<Vector3> *)p_self;
+ return (const godot_vector3 *)self->ptr();
+}
+
+godot_vector3 GDAPI *godot_packed_vector3_array_ptrw(godot_packed_vector3_array *p_self) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
+ return (godot_vector3 *)self->ptrw();
+}
+
void GDAPI godot_packed_vector3_array_append(godot_packed_vector3_array *p_self, const godot_vector3 *p_data) {
Vector<Vector3> *self = (Vector<Vector3> *)p_self;
Vector3 &s = *(Vector3 *)p_data;
@@ -594,6 +852,16 @@ void GDAPI godot_packed_color_array_new_with_array(godot_packed_color_array *r_d
}
}
+const godot_color GDAPI *godot_packed_color_array_ptr(const godot_packed_color_array *p_self) {
+ const Vector<Color> *self = (const Vector<Color> *)p_self;
+ return (const godot_color *)self->ptr();
+}
+
+godot_color GDAPI *godot_packed_color_array_ptrw(godot_packed_color_array *p_self) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
+ return (godot_color *)self->ptrw();
+}
+
void GDAPI godot_packed_color_array_append(godot_packed_color_array *p_self, const godot_color *p_data) {
Vector<Color> *self = (Vector<Color> *)p_self;
Color &s = *(Color *)p_data;
diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp
index 17221fe081..663937f906 100644
--- a/modules/gdnative/gdnative/plane.cpp
+++ b/modules/gdnative/gdnative/plane.cpp
@@ -37,8 +37,9 @@
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) {
+static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch");
+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..de6308ad2a 100644
--- a/modules/gdnative/gdnative/quat.cpp
+++ b/modules/gdnative/gdnative/quat.cpp
@@ -37,8 +37,9 @@
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) {
+static_assert(sizeof(godot_quat) == sizeof(Quat), "Quat size mismatch");
+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..516f4d75ce 100644
--- a/modules/gdnative/gdnative/rect2.cpp
+++ b/modules/gdnative/gdnative/rect2.cpp
@@ -37,6 +37,11 @@
extern "C" {
#endif
+static_assert(sizeof(godot_rect2) == sizeof(Rect2), "Rect2 size mismatch");
+static_assert(sizeof(godot_rect2i) == sizeof(Rect2i), "Rect2i size mismatch");
+
+// Rect2
+
void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size) {
const Vector2 *position = (const Vector2 *)p_pos;
const Vector2 *size = (const Vector2 *)p_size;
@@ -45,7 +50,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);
}
@@ -57,6 +61,13 @@ godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self) {
return ret;
}
+godot_rect2i GDAPI godot_rect2_as_rect2i(const godot_rect2 *p_self) {
+ godot_rect2i dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+ *((Rect2i *)&dest) = Rect2i(*self);
+ return dest;
+}
+
godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self) {
const Rect2 *self = (const Rect2 *)p_self;
return self->get_area();
@@ -172,6 +183,149 @@ void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size
self->set_size(*size);
}
+// Rect2i
+
+void GDAPI godot_rect2i_new_with_position_and_size(godot_rect2i *r_dest, const godot_vector2i *p_pos, const godot_vector2i *p_size) {
+ const Vector2i *position = (const Vector2i *)p_pos;
+ const Vector2i *size = (const Vector2i *)p_size;
+ Rect2i *dest = (Rect2i *)r_dest;
+ *dest = Rect2i(*position, *size);
+}
+
+void GDAPI godot_rect2i_new(godot_rect2i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_width, const godot_int p_height) {
+ Rect2i *dest = (Rect2i *)r_dest;
+ *dest = Rect2i(p_x, p_y, p_width, p_height);
+}
+
+godot_string GDAPI godot_rect2i_as_string(const godot_rect2i *p_self) {
+ godot_string ret;
+ const Rect2i *self = (const Rect2i *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_rect2 GDAPI godot_rect2i_as_rect2(const godot_rect2i *p_self) {
+ godot_rect2 dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ *((Rect2 *)&dest) = Rect2(*self);
+ return dest;
+}
+
+godot_int GDAPI godot_rect2i_get_area(const godot_rect2i *p_self) {
+ const Rect2i *self = (const Rect2i *)p_self;
+ return self->get_area();
+}
+
+godot_bool GDAPI godot_rect2i_intersects(const godot_rect2i *p_self, const godot_rect2i *p_b) {
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Rect2i *b = (const Rect2i *)p_b;
+ return self->intersects(*b);
+}
+
+godot_bool GDAPI godot_rect2i_encloses(const godot_rect2i *p_self, const godot_rect2i *p_b) {
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Rect2i *b = (const Rect2i *)p_b;
+ return self->encloses(*b);
+}
+
+godot_bool GDAPI godot_rect2i_has_no_area(const godot_rect2i *p_self) {
+ const Rect2i *self = (const Rect2i *)p_self;
+ return self->has_no_area();
+}
+
+godot_rect2i GDAPI godot_rect2i_clip(const godot_rect2i *p_self, const godot_rect2i *p_b) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Rect2i *b = (const Rect2i *)p_b;
+ *((Rect2i *)&dest) = self->clip(*b);
+ return dest;
+}
+
+godot_rect2i GDAPI godot_rect2i_merge(const godot_rect2i *p_self, const godot_rect2i *p_b) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Rect2i *b = (const Rect2i *)p_b;
+ *((Rect2i *)&dest) = self->merge(*b);
+ return dest;
+}
+
+godot_bool GDAPI godot_rect2i_has_point(const godot_rect2i *p_self, const godot_vector2i *p_point) {
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Vector2i *point = (const Vector2i *)p_point;
+ return self->has_point(*point);
+}
+
+godot_rect2i GDAPI godot_rect2i_grow(const godot_rect2i *p_self, const godot_int p_by) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+
+ *((Rect2i *)&dest) = self->grow(p_by);
+ return dest;
+}
+
+godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, const godot_int p_left, const godot_int p_top, const godot_int p_right, const godot_int p_bottom) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ *((Rect2i *)&dest) = self->grow_individual(p_left, p_top, p_right, p_bottom);
+ return dest;
+}
+
+godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_margin, const godot_int p_by) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ *((Rect2i *)&dest) = self->grow_margin((Margin)p_margin, p_by);
+ return dest;
+}
+
+godot_rect2i GDAPI godot_rect2i_abs(const godot_rect2i *p_self) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ *((Rect2i *)&dest) = self->abs();
+ return dest;
+}
+
+godot_rect2i GDAPI godot_rect2i_expand(const godot_rect2i *p_self, const godot_vector2i *p_to) {
+ godot_rect2i dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Vector2i *to = (const Vector2i *)p_to;
+ *((Rect2i *)&dest) = self->expand(*to);
+ return dest;
+}
+
+godot_bool GDAPI godot_rect2i_operator_equal(const godot_rect2i *p_self, const godot_rect2i *p_b) {
+ const Rect2i *self = (const Rect2i *)p_self;
+ const Rect2i *b = (const Rect2i *)p_b;
+ return *self == *b;
+}
+
+godot_vector2i GDAPI godot_rect2i_get_position(const godot_rect2i *p_self) {
+ godot_vector2i dest;
+ Vector2i *d = (Vector2i *)&dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ *d = self->get_position();
+ return dest;
+}
+
+godot_vector2i GDAPI godot_rect2i_get_size(const godot_rect2i *p_self) {
+ godot_vector2i dest;
+ Vector2i *d = (Vector2i *)&dest;
+ const Rect2i *self = (const Rect2i *)p_self;
+ *d = self->get_size();
+ return dest;
+}
+
+void GDAPI godot_rect2i_set_position(godot_rect2i *p_self, const godot_vector2i *p_pos) {
+ Rect2i *self = (Rect2i *)p_self;
+ const Vector2i *position = (const Vector2i *)p_pos;
+ self->set_position(*position);
+}
+
+void GDAPI godot_rect2i_set_size(godot_rect2i *p_self, const godot_vector2i *p_size) {
+ Rect2i *self = (Rect2i *)p_self;
+ const Vector2i *size = (const Vector2i *)p_size;
+ self->set_size(*size);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp
index 7ea80123a3..d7a63f33a7 100644
--- a/modules/gdnative/gdnative/rid.cpp
+++ b/modules/gdnative/gdnative/rid.cpp
@@ -38,6 +38,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch");
+
void GDAPI godot_rid_new(godot_rid *r_dest) {
RID *dest = (RID *)r_dest;
memnew_placement(dest, RID);
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 4cb55900b0..724a4b56cb 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -40,6 +40,10 @@
extern "C" {
#endif
+static_assert(sizeof(godot_char_string) == sizeof(CharString), "CharString size mismatch");
+static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch");
+static_assert(sizeof(godot_char_type) == sizeof(CharType), "CharType size mismatch");
+
godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) {
const CharString *cs = (const CharString *)p_cs;
@@ -137,6 +141,7 @@ signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const go
return self->nocasecmp_to(*str);
}
+
signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
const String *self = (const String *)p_self;
const String *str = (const String *)p_str;
diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp
index 1abb4486b1..7bbaaeeaa0 100644
--- a/modules/gdnative/gdnative/string_name.cpp
+++ b/modules/gdnative/gdnative/string_name.cpp
@@ -39,6 +39,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch");
+
void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name) {
StringName *dest = (StringName *)r_dest;
const String *name = (const String *)p_name;
diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index c9b3e37fb2..d19de93e9b 100644
--- a/modules/gdnative/gdnative/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -37,6 +37,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_transform) == sizeof(Transform), "Transform size mismatch");
+
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin) {
const Vector3 *x_axis = (const Vector3 *)p_x_axis;
const Vector3 *y_axis = (const Vector3 *)p_y_axis;
diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp
index 26a71333b1..c0f7878eb0 100644
--- a/modules/gdnative/gdnative/transform2d.cpp
+++ b/modules/gdnative/gdnative/transform2d.cpp
@@ -37,6 +37,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch");
+
void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos) {
const Vector2 *pos = (const Vector2 *)p_pos;
Transform2D *dest = (Transform2D *)r_dest;
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index f0fc44ae8a..dac4feb0e5 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -37,6 +37,8 @@
extern "C" {
#endif
+static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch");
+
// Workaround GCC ICE on armv7hl which was affected GCC 6.0 up to 8.0 (GH-16100).
// It was fixed upstream in 8.1, and a fix was backported to 7.4.
// This can be removed once no supported distro ships with versions older than 7.4.
@@ -97,24 +99,48 @@ void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p
memnew_placement_custom(dest, Variant, Variant(*s));
}
+void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s) {
+ Variant *dest = (Variant *)r_dest;
+ StringName *s = (StringName *)p_s;
+ memnew_placement_custom(dest, Variant, Variant(*s));
+}
+
void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2) {
Variant *dest = (Variant *)r_dest;
Vector2 *v2 = (Vector2 *)p_v2;
memnew_placement_custom(dest, Variant, Variant(*v2));
}
+void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2) {
+ Variant *dest = (Variant *)r_dest;
+ Vector2i *v2 = (Vector2i *)p_v2;
+ memnew_placement_custom(dest, Variant, Variant(*v2));
+}
+
void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2) {
Variant *dest = (Variant *)r_dest;
Rect2 *rect2 = (Rect2 *)p_rect2;
memnew_placement_custom(dest, Variant, Variant(*rect2));
}
+void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2) {
+ Variant *dest = (Variant *)r_dest;
+ Rect2i *rect2 = (Rect2i *)p_rect2;
+ memnew_placement_custom(dest, Variant, Variant(*rect2));
+}
+
void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3) {
Variant *dest = (Variant *)r_dest;
Vector3 *v3 = (Vector3 *)p_v3;
memnew_placement_custom(dest, Variant, Variant(*v3));
}
+void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3) {
+ Variant *dest = (Variant *)r_dest;
+ Vector3i *v3 = (Vector3i *)p_v3;
+ memnew_placement_custom(dest, Variant, Variant(*v3));
+}
+
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) {
Variant *dest = (Variant *)r_dest;
Transform2D *t2d = (Transform2D *)p_t2d;
@@ -169,6 +195,18 @@ void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid)
memnew_placement_custom(dest, Variant, Variant(*rid));
}
+void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_cb) {
+ Variant *dest = (Variant *)r_dest;
+ Callable *cb = (Callable *)p_cb;
+ memnew_placement_custom(dest, Variant, Variant(*cb));
+}
+
+void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal) {
+ Variant *dest = (Variant *)r_dest;
+ Signal *signal = (Signal *)p_signal;
+ memnew_placement_custom(dest, Variant, Variant(*signal));
+}
+
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) {
Variant *dest = (Variant *)r_dest;
Object *obj = (Object *)p_obj;
@@ -207,18 +245,30 @@ void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godo
memnew_placement_custom(dest, Variant, Variant(*pba));
}
-void GDAPI godot_variant_new_packed_int_array(godot_variant *r_dest, const godot_packed_int_array *p_pia) {
+void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia) {
Variant *dest = (Variant *)r_dest;
PackedInt32Array *pia = (PackedInt32Array *)p_pia;
memnew_placement_custom(dest, Variant, Variant(*pia));
}
-void GDAPI godot_variant_new_packed_real_array(godot_variant *r_dest, const godot_packed_real_array *p_pra) {
+void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia) {
+ Variant *dest = (Variant *)r_dest;
+ PackedInt64Array *pia = (PackedInt64Array *)p_pia;
+ memnew_placement_custom(dest, Variant, Variant(*pia));
+}
+
+void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra) {
Variant *dest = (Variant *)r_dest;
PackedFloat32Array *pra = (PackedFloat32Array *)p_pra;
memnew_placement_custom(dest, Variant, Variant(*pra));
}
+void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra) {
+ Variant *dest = (Variant *)r_dest;
+ PackedFloat64Array *pra = (PackedFloat64Array *)p_pra;
+ memnew_placement_custom(dest, Variant, Variant(*pra));
+}
+
void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa) {
Variant *dest = (Variant *)r_dest;
PackedStringArray *psa = (PackedStringArray *)p_psa;
@@ -271,6 +321,14 @@ godot_string GDAPI godot_variant_as_string(const godot_variant *p_self) {
return raw_dest;
}
+godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self) {
+ godot_string_name raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ StringName *dest = (StringName *)&raw_dest;
+ memnew_placement(dest, StringName(self->operator StringName())); // operator = is overloaded by StringName
+ return raw_dest;
+}
+
godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self) {
godot_vector2 raw_dest;
const Variant *self = (const Variant *)p_self;
@@ -279,6 +337,14 @@ godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self) {
return raw_dest;
}
+godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self) {
+ godot_vector2i raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ *dest = *self;
+ return raw_dest;
+}
+
godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self) {
godot_rect2 raw_dest;
const Variant *self = (const Variant *)p_self;
@@ -287,6 +353,14 @@ godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self) {
return raw_dest;
}
+godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self) {
+ godot_rect2i raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ Rect2i *dest = (Rect2i *)&raw_dest;
+ *dest = *self;
+ return raw_dest;
+}
+
godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self) {
godot_vector3 raw_dest;
const Variant *self = (const Variant *)p_self;
@@ -295,6 +369,14 @@ godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self) {
return raw_dest;
}
+godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self) {
+ godot_vector3i raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ *dest = *self;
+ return raw_dest;
+}
+
godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self) {
godot_transform2d raw_dest;
const Variant *self = (const Variant *)p_self;
@@ -367,6 +449,22 @@ godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self) {
return raw_dest;
}
+godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self) {
+ godot_callable raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ Callable *dest = (Callable *)&raw_dest;
+ *dest = *self;
+ return raw_dest;
+}
+
+godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self) {
+ godot_signal raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ Signal *dest = (Signal *)&raw_dest;
+ *dest = *self;
+ return raw_dest;
+}
+
godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self) {
const Variant *self = (const Variant *)p_self;
Object *dest;
@@ -399,8 +497,8 @@ godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_var
return raw_dest;
}
-godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_variant *p_self) {
- godot_packed_int_array raw_dest;
+godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self) {
+ godot_packed_int32_array raw_dest;
const Variant *self = (const Variant *)p_self;
PackedInt32Array *dest = (PackedInt32Array *)&raw_dest;
memnew_placement(dest, PackedInt32Array(self->operator PackedInt32Array())); // operator = is overloaded by PackedInt32Array
@@ -408,8 +506,17 @@ godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_varia
return raw_dest;
}
-godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_variant *p_self) {
- godot_packed_real_array raw_dest;
+godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self) {
+ godot_packed_int64_array raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ PackedInt64Array *dest = (PackedInt64Array *)&raw_dest;
+ memnew_placement(dest, PackedInt64Array(self->operator PackedInt64Array())); // operator = is overloaded by PackedInt64Array
+ *dest = *self;
+ return raw_dest;
+}
+
+godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self) {
+ godot_packed_float32_array raw_dest;
const Variant *self = (const Variant *)p_self;
PackedFloat32Array *dest = (PackedFloat32Array *)&raw_dest;
memnew_placement(dest, PackedFloat32Array(self->operator PackedFloat32Array())); // operator = is overloaded by PackedFloat32Array
@@ -417,6 +524,15 @@ godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_var
return raw_dest;
}
+godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self) {
+ godot_packed_float64_array raw_dest;
+ const Variant *self = (const Variant *)p_self;
+ PackedFloat64Array *dest = (PackedFloat64Array *)&raw_dest;
+ memnew_placement(dest, PackedFloat64Array(self->operator PackedFloat64Array())); // operator = is overloaded by PackedFloat64Array
+ *dest = *self;
+ return raw_dest;
+}
+
godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self) {
godot_packed_string_array raw_dest;
const Variant *self = (const Variant *)p_self;
@@ -487,6 +603,11 @@ godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const
return self->operator<(*other);
}
+uint32_t GDAPI godot_variant_hash(const godot_variant *p_self) {
+ const Variant *self = (const Variant *)p_self;
+ return self->hash();
+}
+
godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other) {
const Variant *self = (const Variant *)p_self;
const Variant *other = (const Variant *)p_other;
diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index dc273e7951..1ee716df86 100644
--- a/modules/gdnative/gdnative/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.cpp
@@ -37,8 +37,12 @@
extern "C" {
#endif
-void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) {
+static_assert(sizeof(godot_vector2) == sizeof(Vector2), "Vector2 size mismatch");
+static_assert(sizeof(godot_vector2i) == sizeof(Vector2i), "Vector2i size mismatch");
+
+// Vector2
+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);
}
@@ -50,6 +54,13 @@ godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self) {
return ret;
}
+godot_vector2i GDAPI godot_vector2_as_vector2i(const godot_vector2 *p_self) {
+ godot_vector2i dest;
+ const Vector2 *self = (const Vector2 *)p_self;
+ *((Vector2i *)&dest) = Vector2i(*self);
+ return dest;
+}
+
godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self) {
godot_vector2 dest;
const Vector2 *self = (const Vector2 *)p_self;
@@ -157,6 +168,13 @@ godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self) {
return dest;
}
+godot_vector2 GDAPI godot_vector2_sign(const godot_vector2 *p_self) {
+ godot_vector2 dest;
+ const Vector2 *self = (const Vector2 *)p_self;
+ *((Vector2 *)&dest) = self->sign();
+ return dest;
+}
+
godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by) {
godot_vector2 dest;
const Vector2 *self = (const Vector2 *)p_self;
@@ -307,6 +325,138 @@ godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self) {
return self->y;
}
+// Vector2i
+
+void GDAPI godot_vector2i_new(godot_vector2i *r_dest, const godot_int p_x, const godot_int p_y) {
+ Vector2i *dest = (Vector2i *)r_dest;
+ *dest = Vector2i(p_x, p_y);
+}
+
+godot_string GDAPI godot_vector2i_as_string(const godot_vector2i *p_self) {
+ godot_string ret;
+ const Vector2i *self = (const Vector2i *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_vector2 GDAPI godot_vector2i_as_vector2(const godot_vector2i *p_self) {
+ godot_vector2 dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ *((Vector2 *)&dest) = Vector2(*self);
+ return dest;
+}
+
+godot_real GDAPI godot_vector2i_aspect(const godot_vector2i *p_self) {
+ const Vector2i *self = (const Vector2i *)p_self;
+ return self->aspect();
+}
+
+godot_vector2i GDAPI godot_vector2i_abs(const godot_vector2i *p_self) {
+ godot_vector2i dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ *((Vector2i *)&dest) = self->abs();
+ return dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_sign(const godot_vector2i *p_self) {
+ godot_vector2i dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ *((Vector2i *)&dest) = self->sign();
+ return dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_add(const godot_vector2i *p_self, const godot_vector2i *p_b) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ const Vector2i *b = (const Vector2i *)p_b;
+ *dest = *self + *b;
+ return raw_dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_subtract(const godot_vector2i *p_self, const godot_vector2i *p_b) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ const Vector2i *b = (const Vector2i *)p_b;
+ *dest = *self - *b;
+ return raw_dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_multiply_vector(const godot_vector2i *p_self, const godot_vector2i *p_b) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ const Vector2i *b = (const Vector2i *)p_b;
+ *dest = *self * *b;
+ return raw_dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_multiply_scalar(const godot_vector2i *p_self, const godot_int p_b) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ *dest = *self * p_b;
+ return raw_dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_divide_vector(const godot_vector2i *p_self, const godot_vector2i *p_b) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ const Vector2i *b = (const Vector2i *)p_b;
+ *dest = *self / *b;
+ return raw_dest;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_divide_scalar(const godot_vector2i *p_self, const godot_int p_b) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ *dest = *self / p_b;
+ return raw_dest;
+}
+
+godot_bool GDAPI godot_vector2i_operator_equal(const godot_vector2i *p_self, const godot_vector2i *p_b) {
+ const Vector2i *self = (const Vector2i *)p_self;
+ const Vector2i *b = (const Vector2i *)p_b;
+ return *self == *b;
+}
+
+godot_bool GDAPI godot_vector2i_operator_less(const godot_vector2i *p_self, const godot_vector2i *p_b) {
+ const Vector2i *self = (const Vector2i *)p_self;
+ const Vector2i *b = (const Vector2i *)p_b;
+ return *self < *b;
+}
+
+godot_vector2i GDAPI godot_vector2i_operator_neg(const godot_vector2i *p_self) {
+ godot_vector2i raw_dest;
+ Vector2i *dest = (Vector2i *)&raw_dest;
+ const Vector2i *self = (const Vector2i *)p_self;
+ *dest = -(*self);
+ return raw_dest;
+}
+
+void GDAPI godot_vector2i_set_x(godot_vector2i *p_self, const godot_int p_x) {
+ Vector2i *self = (Vector2i *)p_self;
+ self->x = p_x;
+}
+
+void GDAPI godot_vector2i_set_y(godot_vector2i *p_self, const godot_int p_y) {
+ Vector2i *self = (Vector2i *)p_self;
+ self->y = p_y;
+}
+
+godot_int GDAPI godot_vector2i_get_x(const godot_vector2i *p_self) {
+ const Vector2i *self = (const Vector2i *)p_self;
+ return self->x;
+}
+
+godot_int GDAPI godot_vector2i_get_y(const godot_vector2i *p_self) {
+ const Vector2i *self = (const Vector2i *)p_self;
+ return self->y;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index bb27ad5a00..32cad30c17 100644
--- a/modules/gdnative/gdnative/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.cpp
@@ -37,8 +37,12 @@
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) {
+static_assert(sizeof(godot_vector3) == sizeof(Vector3), "Vector3 size mismatch");
+static_assert(sizeof(godot_vector3i) == sizeof(Vector3i), "Vector3i size mismatch");
+
+// Vector3
+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);
}
@@ -50,6 +54,13 @@ godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self) {
return ret;
}
+godot_vector3i GDAPI godot_vector3_as_vector3i(const godot_vector3 *p_self) {
+ godot_vector3i dest;
+ const Vector3 *self = (const Vector3 *)p_self;
+ *((Vector3i *)&dest) = Vector3i(*self);
+ return dest;
+}
+
godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self) {
const Vector3 *self = (const Vector3 *)p_self;
return self->min_axis();
@@ -168,6 +179,13 @@ godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self) {
return dest;
}
+godot_vector3 GDAPI godot_vector3_sign(const godot_vector3 *p_self) {
+ godot_vector3 dest;
+ const Vector3 *self = (const Vector3 *)p_self;
+ *((Vector3 *)&dest) = self->sign();
+ return dest;
+}
+
godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self) {
godot_vector3 dest;
const Vector3 *self = (const Vector3 *)p_self;
@@ -314,6 +332,133 @@ godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot
return self->get_axis(p_axis);
}
+// Vector3i
+
+void GDAPI godot_vector3i_new(godot_vector3i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_z) {
+ Vector3i *dest = (Vector3i *)r_dest;
+ *dest = Vector3i(p_x, p_y, p_z);
+}
+
+godot_string GDAPI godot_vector3i_as_string(const godot_vector3i *p_self) {
+ godot_string ret;
+ const Vector3i *self = (const Vector3i *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_vector3 GDAPI godot_vector3i_as_vector3(const godot_vector3i *p_self) {
+ godot_vector3 dest;
+ const Vector3i *self = (const Vector3i *)p_self;
+ *((Vector3 *)&dest) = Vector3(*self);
+ return dest;
+}
+
+godot_int GDAPI godot_vector3i_min_axis(const godot_vector3i *p_self) {
+ const Vector3i *self = (const Vector3i *)p_self;
+ return self->min_axis();
+}
+
+godot_int GDAPI godot_vector3i_max_axis(const godot_vector3i *p_self) {
+ const Vector3i *self = (const Vector3i *)p_self;
+ return self->max_axis();
+}
+
+godot_vector3i GDAPI godot_vector3i_abs(const godot_vector3i *p_self) {
+ godot_vector3i dest;
+ const Vector3i *self = (const Vector3i *)p_self;
+ *((Vector3i *)&dest) = self->abs();
+ return dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_sign(const godot_vector3i *p_self) {
+ godot_vector3i dest;
+ const Vector3i *self = (const Vector3i *)p_self;
+ *((Vector3i *)&dest) = self->sign();
+ return dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_add(const godot_vector3i *p_self, const godot_vector3i *p_b) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ Vector3i *self = (Vector3i *)p_self;
+ const Vector3i *b = (const Vector3i *)p_b;
+ *dest = *self + *b;
+ return raw_dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_subtract(const godot_vector3i *p_self, const godot_vector3i *p_b) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ Vector3i *self = (Vector3i *)p_self;
+ const Vector3i *b = (const Vector3i *)p_b;
+ *dest = *self - *b;
+ return raw_dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_multiply_vector(const godot_vector3i *p_self, const godot_vector3i *p_b) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ Vector3i *self = (Vector3i *)p_self;
+ const Vector3i *b = (const Vector3i *)p_b;
+ *dest = *self * *b;
+ return raw_dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_multiply_scalar(const godot_vector3i *p_self, const godot_int p_b) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ Vector3i *self = (Vector3i *)p_self;
+ *dest = *self * p_b;
+ return raw_dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_divide_vector(const godot_vector3i *p_self, const godot_vector3i *p_b) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ Vector3i *self = (Vector3i *)p_self;
+ const Vector3i *b = (const Vector3i *)p_b;
+ *dest = *self / *b;
+ return raw_dest;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_divide_scalar(const godot_vector3i *p_self, const godot_int p_b) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ Vector3i *self = (Vector3i *)p_self;
+ *dest = *self / p_b;
+ return raw_dest;
+}
+
+godot_bool GDAPI godot_vector3i_operator_equal(const godot_vector3i *p_self, const godot_vector3i *p_b) {
+ Vector3i *self = (Vector3i *)p_self;
+ const Vector3i *b = (const Vector3i *)p_b;
+ return *self == *b;
+}
+
+godot_bool GDAPI godot_vector3i_operator_less(const godot_vector3i *p_self, const godot_vector3i *p_b) {
+ Vector3i *self = (Vector3i *)p_self;
+ const Vector3i *b = (const Vector3i *)p_b;
+ return *self < *b;
+}
+
+godot_vector3i GDAPI godot_vector3i_operator_neg(const godot_vector3i *p_self) {
+ godot_vector3i raw_dest;
+ Vector3i *dest = (Vector3i *)&raw_dest;
+ const Vector3i *self = (const Vector3i *)p_self;
+ *dest = -(*self);
+ return raw_dest;
+}
+
+void GDAPI godot_vector3i_set_axis(godot_vector3i *p_self, const godot_vector3_axis p_axis, const godot_int p_val) {
+ Vector3i *self = (Vector3i *)p_self;
+ self->set_axis(p_axis, p_val);
+}
+
+godot_int GDAPI godot_vector3i_get_axis(const godot_vector3i *p_self, const godot_vector3_axis p_axis) {
+ const Vector3i *self = (const Vector3i *)p_self;
+ return self->get_axis(p_axis);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index d5ab62dc61..ccd8d2041c 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -2,1130 +2,580 @@
"core": {
"type": "CORE",
"version": {
- "major": 1,
+ "major": 4,
"minor": 0
},
- "next": {
- "type": "CORE",
- "version": {
- "major": 1,
- "minor": 1
- },
- "next": {
- "type": "CORE",
- "version": {
- "major": 1,
- "minor": 2
- },
- "next": null,
- "api": [
- {
- "name": "godot_dictionary_duplicate",
- "return_type": "godot_dictionary",
- "arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_bool", "p_deep"]
- ]
- },
- {
- "name": "godot_vector3_move_toward",
- "return_type": "godot_vector3",
- "arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_to"],
- ["const godot_real", "p_delta"]
- ]
- },
- {
- "name": "godot_vector2_move_toward",
- "return_type": "godot_vector2",
- "arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_to"],
- ["const godot_real", "p_delta"]
- ]
- },
- {
- "name": "godot_string_count",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"],
- ["godot_int", "p_from"],
- ["godot_int", "p_to"]
- ]
- },
- {
- "name": "godot_string_countn",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"],
- ["godot_int", "p_from"],
- ["godot_int", "p_to"]
- ]
- },
- {
- "name": "godot_vector3_direction_to",
- "return_type": "godot_vector3",
- "arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_to"]
- ]
- },
- {
- "name": "godot_vector2_direction_to",
- "return_type": "godot_vector2",
- "arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_to"]
- ]
- },
- {
- "name": "godot_array_slice",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_int", "p_begin"],
- ["const godot_int", "p_end"],
- ["const godot_int", "p_step"],
- ["const godot_bool", "p_deep"]
- ]
- },
- {
- "name": "godot_packed_byte_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_byte_array *", "p_self"]
- ]
- },
- {
- "name": "godot_packed_int_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_int_array *", "p_self"]
- ]
- },
- {
- "name": "godot_packed_real_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_real_array *", "p_self"]
- ]
- },
- {
- "name": "godot_packed_string_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_string_array *", "p_self"]
- ]
- },
- {
- "name": "godot_packed_vector2_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_vector2_array *", "p_self"]
- ]
- },
- {
- "name": "godot_packed_vector3_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_vector3_array *", "p_self"]
- ]
- },
- {
- "name": "godot_packed_color_array_empty",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_packed_color_array *", "p_self"]
- ]
- },
- {
- "name": "godot_get_class_tag",
- "return_type": "void *",
- "arguments": [
- ["const godot_string_name *", "p_class"]
- ]
- },
- {
- "name": "godot_object_cast_to",
- "return_type": "godot_object *",
- "arguments": [
- ["const godot_object *", "p_object"],
- ["void *", "p_class_tag"]
- ]
- },
- {
- "name": "godot_instance_from_id",
- "return_type": "godot_object *",
- "arguments": [
- ["godot_int", "p_instance_id"]
- ]
- }
- ]
- },
- "api": [
- {
- "name": "godot_color_to_abgr32",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_to_abgr64",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_to_argb64",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_to_rgba64",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_darkened",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_real", "p_amount"]
- ]
- },
- {
- "name": "godot_color_from_hsv",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_real", "p_h"],
- ["const godot_real", "p_s"],
- ["const godot_real", "p_v"],
- ["const godot_real", "p_a"]
- ]
- },
- {
- "name": "godot_color_lightened",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_real", "p_amount"]
- ]
- },
- {
- "name": "godot_array_duplicate",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_bool", "p_deep"]
- ]
- },
- {
- "name": "godot_array_max",
- "return_type": "godot_variant",
- "arguments": [
- ["const godot_array *", "p_self"]
- ]
- },
- {
- "name": "godot_array_min",
- "return_type": "godot_variant",
- "arguments": [
- ["const godot_array *", "p_self"]
- ]
- },
- {
- "name": "godot_array_shuffle",
- "return_type": "void",
- "arguments": [
- ["godot_array *", "p_self"]
- ]
- },
- {
- "name": "godot_basis_slerp",
- "return_type": "godot_basis",
- "arguments": [
- ["const godot_basis *", "p_self"],
- ["const godot_basis *", "p_b"],
- ["const godot_real", "p_t"]
- ]
- },
- {
- "name": "godot_dictionary_get_with_default",
- "return_type": "godot_variant",
- "arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"],
- ["const godot_variant *", "p_default"]
- ]
- },
- {
- "name": "godot_dictionary_erase_with_return",
- "return_type": "bool",
- "arguments": [
- ["godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
- ]
- },
- {
- "name": "godot_node_path_get_as_property_path",
- "return_type": "godot_node_path",
- "arguments": [
- ["const godot_node_path *", "p_self"]
- ]
- },
- {
- "name": "godot_quat_set_axis_angle",
- "return_type": "void",
- "arguments": [
- ["godot_quat *", "p_self"],
- ["const godot_vector3 *", "p_axis"],
- ["const godot_real", "p_angle"]
- ]
- },
- {
- "name": "godot_rect2_grow_individual",
- "return_type": "godot_rect2",
- "arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_real", "p_left"],
- ["const godot_real", "p_top"],
- ["const godot_real", "p_right"],
- ["const godot_real", "p_bottom"]
- ]
- },
- {
- "name": "godot_rect2_grow_margin",
- "return_type": "godot_rect2",
- "arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_int", "p_margin"],
- ["const godot_real", "p_by"]
- ]
- },
- {
- "name": "godot_rect2_abs",
- "return_type": "godot_rect2",
- "arguments": [
- ["const godot_rect2 *", "p_self"]
- ]
- },
- {
- "name": "godot_string_dedent",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"]
- ]
- },
- {
- "name": "godot_string_trim_prefix",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_prefix"]
- ]
- },
- {
- "name": "godot_string_trim_suffix",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_suffix"]
- ]
- },
- {
- "name": "godot_string_rstrip",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_chars"]
- ]
- },
- {
- "name": "godot_string_rsplit",
- "return_type": "godot_packed_string_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_divisor"],
- ["const godot_bool", "p_allow_empty"],
- ["const godot_int", "p_maxsplit"]
- ]
- },
- {
- "name": "godot_basis_get_quat",
- "return_type": "godot_quat",
- "arguments": [
- ["const godot_basis *", "p_self"]
- ]
- },
- {
- "name": "godot_basis_set_quat",
- "return_type": "void",
- "arguments": [
- ["godot_basis *", "p_self"],
- ["const godot_quat *", "p_quat"]
- ]
- },
- {
- "name": "godot_basis_set_axis_angle_scale",
- "return_type": "void",
- "arguments": [
- ["godot_basis *", "p_self"],
- ["const godot_vector3 *", "p_axis"],
- ["godot_real", "p_phi"],
- ["const godot_vector3 *", "p_scale"]
- ]
- },
- {
- "name": "godot_basis_set_euler_scale",
- "return_type": "void",
- "arguments": [
- ["godot_basis *", "p_self"],
- ["const godot_vector3 *", "p_euler"],
- ["const godot_vector3 *", "p_scale"]
- ]
- },
- {
- "name": "godot_basis_set_quat_scale",
- "return_type": "void",
- "arguments": [
- ["godot_basis *", "p_self"],
- ["const godot_quat *", "p_quat"],
- ["const godot_vector3 *", "p_scale"]
- ]
- },
- {
- "name": "godot_quat_new_with_basis",
- "return_type": "void",
- "arguments": [
- ["godot_quat *", "r_dest"],
- ["const godot_basis *", "p_basis"]
- ]
- },
- {
- "name": "godot_quat_new_with_euler",
- "return_type": "void",
- "arguments": [
- ["godot_quat *", "r_dest"],
- ["const godot_vector3 *", "p_euler"]
- ]
- },
- {
- "name": "godot_transform_new_with_quat",
- "return_type": "void",
- "arguments": [
- ["godot_transform *", "r_dest"],
- ["const godot_quat *", "p_quat"]
- ]
- },
- {
- "name": "godot_variant_get_operator_name",
- "return_type": "godot_string",
- "arguments": [
- ["godot_variant_operator", "p_op"]
- ]
- },
- {
- "name": "godot_variant_evaluate",
- "return_type": "void",
- "arguments": [
- ["godot_variant_operator", "p_op"],
- ["const godot_variant *", "p_a"],
- ["const godot_variant *", "p_b"],
- ["godot_variant *", "r_ret"],
- ["godot_bool *", "r_valid"]
- ]
- }
- ]
- },
+ "next": null,
"api": [
{
- "name": "godot_color_new_rgba",
- "return_type": "void",
- "arguments": [
- ["godot_color *", "r_dest"],
- ["const godot_real", "p_r"],
- ["const godot_real", "p_g"],
- ["const godot_real", "p_b"],
- ["const godot_real", "p_a"]
- ]
- },
- {
- "name": "godot_color_new_rgb",
- "return_type": "void",
- "arguments": [
- ["godot_color *", "r_dest"],
- ["const godot_real", "p_r"],
- ["const godot_real", "p_g"],
- ["const godot_real", "p_b"]
- ]
- },
- {
- "name": "godot_color_get_r",
- "return_type": "godot_real",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_set_r",
- "return_type": "void",
- "arguments": [
- ["godot_color *", "p_self"],
- ["const godot_real", "r"]
- ]
- },
- {
- "name": "godot_color_get_g",
- "return_type": "godot_real",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_set_g",
+ "name": "godot_aabb_new",
"return_type": "void",
"arguments": [
- ["godot_color *", "p_self"],
- ["const godot_real", "g"]
+ ["godot_aabb *", "r_dest"],
+ ["const godot_vector3 *", "p_pos"],
+ ["const godot_vector3 *", "p_size"]
]
},
{
- "name": "godot_color_get_b",
- "return_type": "godot_real",
+ "name": "godot_aabb_get_position",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_color *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_color_set_b",
+ "name": "godot_aabb_set_position",
"return_type": "void",
"arguments": [
- ["godot_color *", "p_self"],
- ["const godot_real", "b"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_color_get_a",
- "return_type": "godot_real",
+ "name": "godot_aabb_get_size",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_color *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_color_set_a",
+ "name": "godot_aabb_set_size",
"return_type": "void",
"arguments": [
- ["godot_color *", "p_self"],
- ["const godot_real", "a"]
- ]
- },
- {
- "name": "godot_color_get_h",
- "return_type": "godot_real",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_get_s",
- "return_type": "godot_real",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_get_v",
- "return_type": "godot_real",
- "arguments": [
- ["const godot_color *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_color_as_string",
+ "name": "godot_aabb_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_to_rgba32",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_to_argb32",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_inverted",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_contrasted",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
- "name": "godot_color_lerp",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_color *", "p_b"],
- ["const godot_real", "p_t"]
- ]
- },
- {
- "name": "godot_color_blend",
- "return_type": "godot_color",
- "arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_color *", "p_over"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_color_to_html",
- "return_type": "godot_string",
+ "name": "godot_aabb_get_area",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_bool", "p_with_alpha"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_color_operator_equal",
+ "name": "godot_aabb_has_no_area",
"return_type": "godot_bool",
"arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_color *", "p_b"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_color_operator_less",
+ "name": "godot_aabb_has_no_surface",
"return_type": "godot_bool",
"arguments": [
- ["const godot_color *", "p_self"],
- ["const godot_color *", "p_b"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_new",
- "return_type": "void",
+ "name": "godot_aabb_intersects",
+ "return_type": "godot_bool",
"arguments": [
- ["godot_vector2 *", "r_dest"],
- ["const godot_real", "p_x"],
- ["const godot_real", "p_y"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_vector2_as_string",
- "return_type": "godot_string",
+ "name": "godot_aabb_encloses",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_vector2_normalized",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_merge",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_vector2_length",
- "return_type": "godot_real",
+ "name": "godot_aabb_intersection",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_vector2_angle",
- "return_type": "godot_real",
+ "name": "godot_aabb_intersects_plane",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_plane *", "p_plane"]
]
},
{
- "name": "godot_vector2_length_squared",
- "return_type": "godot_real",
+ "name": "godot_aabb_intersects_segment",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_vector3 *", "p_from"],
+ ["const godot_vector3 *", "p_to"]
]
},
{
- "name": "godot_vector2_is_normalized",
+ "name": "godot_aabb_has_point",
"return_type": "godot_bool",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_vector3 *", "p_point"]
]
},
{
- "name": "godot_vector2_distance_to",
- "return_type": "godot_real",
+ "name": "godot_aabb_get_support",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_to"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_vector3 *", "p_dir"]
]
},
{
- "name": "godot_vector2_distance_squared_to",
- "return_type": "godot_real",
+ "name": "godot_aabb_get_longest_axis",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_to"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_angle_to",
- "return_type": "godot_real",
+ "name": "godot_aabb_get_longest_axis_index",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_to"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_angle_to_point",
+ "name": "godot_aabb_get_longest_axis_size",
"return_type": "godot_real",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_to"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_lerp",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_get_shortest_axis",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"],
- ["const godot_real", "p_t"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_cubic_interpolate",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_get_shortest_axis_index",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"],
- ["const godot_vector2 *", "p_pre_a"],
- ["const godot_vector2 *", "p_post_b"],
- ["const godot_real", "p_t"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_rotated",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_get_shortest_axis_size",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_real", "p_phi"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_vector2_tangent",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_expand",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_vector3 *", "p_to_point"]
]
},
{
- "name": "godot_vector2_floor",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_grow",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_real", "p_by"]
]
},
{
- "name": "godot_vector2_snapped",
- "return_type": "godot_vector2",
+ "name": "godot_aabb_get_endpoint",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_by"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_vector2_aspect",
- "return_type": "godot_real",
+ "name": "godot_aabb_operator_equal",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_b"]
]
},
{
- "name": "godot_vector2_dot",
- "return_type": "godot_real",
+ "name": "godot_array_new",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_with"]
+ ["godot_array *", "r_dest"]
]
},
{
- "name": "godot_vector2_slide",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_copy",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_n"]
+ ["godot_array *", "r_dest"],
+ ["const godot_array *", "p_src"]
]
},
{
- "name": "godot_vector2_bounce",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_color_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_n"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_color_array *", "p_pca"]
]
},
{
- "name": "godot_vector2_reflect",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_vector3_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_n"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_vector3_array *", "p_pv3a"]
]
},
{
- "name": "godot_vector2_abs",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_vector2_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_vector2_array *", "p_pv2a"]
]
},
{
- "name": "godot_vector2_clamped",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_string_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_real", "p_length"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_string_array *", "p_psa"]
]
},
{
- "name": "godot_vector2_operator_add",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_float32_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_float32_array *", "p_pra"]
]
},
{
- "name": "godot_vector2_operator_subtract",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_float64_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_float64_array *", "p_pra"]
]
},
{
- "name": "godot_vector2_operator_multiply_vector",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_int32_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_int32_array *", "p_pia"]
]
},
{
- "name": "godot_vector2_operator_multiply_scalar",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_int64_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_real", "p_b"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_int64_array *", "p_pia"]
]
},
{
- "name": "godot_vector2_operator_divide_vector",
- "return_type": "godot_vector2",
+ "name": "godot_array_new_packed_byte_array",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"]
+ ["godot_array *", "r_dest"],
+ ["const godot_packed_byte_array *", "p_pba"]
]
},
{
- "name": "godot_vector2_operator_divide_scalar",
- "return_type": "godot_vector2",
+ "name": "godot_array_set",
+ "return_type": "void",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_real", "p_b"]
+ ["godot_array *", "p_self"],
+ ["const godot_int", "p_idx"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_vector2_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_array_get",
+ "return_type": "godot_variant",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"]
+ ["const godot_array *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_vector2_operator_less",
- "return_type": "godot_bool",
+ "name": "godot_array_operator_index",
+ "return_type": "godot_variant *",
"arguments": [
- ["const godot_vector2 *", "p_self"],
- ["const godot_vector2 *", "p_b"]
+ ["godot_array *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_vector2_operator_neg",
- "return_type": "godot_vector2",
+ "name": "godot_array_operator_index_const",
+ "return_type": "const godot_variant *",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_array *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_vector2_set_x",
+ "name": "godot_array_append",
"return_type": "void",
"arguments": [
- ["godot_vector2 *", "p_self"],
- ["const godot_real", "p_x"]
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_vector2_set_y",
+ "name": "godot_array_clear",
"return_type": "void",
"arguments": [
- ["godot_vector2 *", "p_self"],
- ["const godot_real", "p_y"]
+ ["godot_array *", "p_self"]
]
},
{
- "name": "godot_vector2_get_x",
- "return_type": "godot_real",
+ "name": "godot_array_count",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_vector2_get_y",
- "return_type": "godot_real",
+ "name": "godot_array_duplicate",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_vector2 *", "p_self"]
+ ["const godot_array *", "p_self"],
+ ["const godot_bool", "p_deep"]
]
},
{
- "name": "godot_quat_new",
- "return_type": "void",
+ "name": "godot_array_empty",
+ "return_type": "godot_bool",
"arguments": [
- ["godot_quat *", "r_dest"],
- ["const godot_real", "p_x"],
- ["const godot_real", "p_y"],
- ["const godot_real", "p_z"],
- ["const godot_real", "p_w"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_new_with_axis_angle",
+ "name": "godot_array_erase",
"return_type": "void",
"arguments": [
- ["godot_quat *", "r_dest"],
- ["const godot_vector3 *", "p_axis"],
- ["const godot_real", "p_angle"]
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_quat_get_x",
- "return_type": "godot_real",
+ "name": "godot_array_front",
+ "return_type": "godot_variant",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_set_x",
- "return_type": "void",
+ "name": "godot_array_back",
+ "return_type": "godot_variant",
"arguments": [
- ["godot_quat *", "p_self"],
- ["const godot_real", "val"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_get_y",
- "return_type": "godot_real",
+ "name": "godot_array_find",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["const godot_array *", "p_self"],
+ ["const godot_variant *", "p_what"],
+ ["const godot_int", "p_from"]
]
},
{
- "name": "godot_quat_set_y",
- "return_type": "void",
+ "name": "godot_array_find_last",
+ "return_type": "godot_int",
"arguments": [
- ["godot_quat *", "p_self"],
- ["const godot_real", "val"]
+ ["const godot_array *", "p_self"],
+ ["const godot_variant *", "p_what"]
]
},
{
- "name": "godot_quat_get_z",
- "return_type": "godot_real",
+ "name": "godot_array_has",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["const godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_quat_set_z",
- "return_type": "void",
+ "name": "godot_array_hash",
+ "return_type": "godot_int",
"arguments": [
- ["godot_quat *", "p_self"],
- ["const godot_real", "val"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_get_w",
- "return_type": "godot_real",
+ "name": "godot_array_insert",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["godot_array *", "p_self"],
+ ["const godot_int", "p_pos"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_quat_set_w",
+ "name": "godot_array_invert",
"return_type": "void",
"arguments": [
- ["godot_quat *", "p_self"],
- ["const godot_real", "val"]
+ ["godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_as_string",
- "return_type": "godot_string",
+ "name": "godot_array_max",
+ "return_type": "godot_variant",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_length",
- "return_type": "godot_real",
+ "name": "godot_array_min",
+ "return_type": "godot_variant",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_length_squared",
- "return_type": "godot_real",
+ "name": "godot_array_pop_back",
+ "return_type": "godot_variant",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_normalized",
- "return_type": "godot_quat",
+ "name": "godot_array_pop_front",
+ "return_type": "godot_variant",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_is_normalized",
- "return_type": "godot_bool",
+ "name": "godot_array_push_back",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_quat_inverse",
- "return_type": "godot_quat",
+ "name": "godot_array_push_front",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"]
]
},
{
- "name": "godot_quat_dot",
- "return_type": "godot_real",
+ "name": "godot_array_remove",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"]
+ ["godot_array *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_quat_xform",
- "return_type": "godot_vector3",
+ "name": "godot_array_resize",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_vector3 *", "p_v"]
+ ["godot_array *", "p_self"],
+ ["const godot_int", "p_size"]
]
},
{
- "name": "godot_quat_slerp",
- "return_type": "godot_quat",
+ "name": "godot_array_rfind",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"],
- ["const godot_real", "p_t"]
+ ["const godot_array *", "p_self"],
+ ["const godot_variant *", "p_what"],
+ ["const godot_int", "p_from"]
]
},
{
- "name": "godot_quat_slerpni",
- "return_type": "godot_quat",
+ "name": "godot_array_size",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"],
- ["const godot_real", "p_t"]
+ ["const godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_cubic_slerp",
- "return_type": "godot_quat",
+ "name": "godot_array_shuffle",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"],
- ["const godot_quat *", "p_pre_a"],
- ["const godot_quat *", "p_post_b"],
- ["const godot_real", "p_t"]
+ ["godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_operator_multiply",
- "return_type": "godot_quat",
+ "name": "godot_array_slice",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_real", "p_b"]
+ ["const godot_array *", "p_self"],
+ ["const godot_int", "p_begin"],
+ ["const godot_int", "p_end"],
+ ["const godot_int", "p_step"],
+ ["const godot_bool", "p_deep"]
]
},
{
- "name": "godot_quat_operator_add",
- "return_type": "godot_quat",
+ "name": "godot_array_sort",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"]
+ ["godot_array *", "p_self"]
]
},
{
- "name": "godot_quat_operator_subtract",
- "return_type": "godot_quat",
+ "name": "godot_array_sort_custom",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"]
+ ["godot_array *", "p_self"],
+ ["godot_object *", "p_obj"],
+ ["const godot_string *", "p_func"]
]
},
{
- "name": "godot_quat_operator_divide",
- "return_type": "godot_quat",
+ "name": "godot_array_bsearch",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_real", "p_b"]
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"],
+ ["const godot_bool", "p_before"]
]
},
{
- "name": "godot_quat_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_array_bsearch_custom",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_quat *", "p_self"],
- ["const godot_quat *", "p_b"]
+ ["godot_array *", "p_self"],
+ ["const godot_variant *", "p_value"],
+ ["godot_object *", "p_obj"],
+ ["const godot_string *", "p_func"],
+ ["const godot_bool", "p_before"]
]
},
{
- "name": "godot_quat_operator_neg",
- "return_type": "godot_quat",
+ "name": "godot_array_destroy",
+ "return_type": "void",
"arguments": [
- ["const godot_quat *", "p_self"]
+ ["godot_array *", "p_self"]
]
},
{
@@ -1366,294 +816,803 @@
]
},
{
- "name": "godot_vector3_new",
+ "name": "godot_basis_slerp",
+ "return_type": "godot_basis",
+ "arguments": [
+ ["const godot_basis *", "p_self"],
+ ["const godot_basis *", "p_b"],
+ ["const godot_real", "p_t"]
+ ]
+ },
+ {
+ "name": "godot_basis_get_quat",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_basis *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_quat",
"return_type": "void",
"arguments": [
- ["godot_vector3 *", "r_dest"],
- ["const godot_real", "p_x"],
- ["const godot_real", "p_y"],
- ["const godot_real", "p_z"]
+ ["godot_basis *", "p_self"],
+ ["const godot_quat *", "p_quat"]
]
},
{
- "name": "godot_vector3_as_string",
+ "name": "godot_basis_set_axis_angle_scale",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_vector3 *", "p_axis"],
+ ["godot_real", "p_phi"],
+ ["const godot_vector3 *", "p_scale"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_euler_scale",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_vector3 *", "p_euler"],
+ ["const godot_vector3 *", "p_scale"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_quat_scale",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_quat *", "p_quat"],
+ ["const godot_vector3 *", "p_scale"]
+ ]
+ },
+ {
+ "name": "godot_callable_new_with_object",
+ "return_type": "void",
+ "arguments": [
+ ["godot_callable *", "r_dest"],
+ ["const godot_object *", "p_object"],
+ ["const godot_string_name *", "p_method"]
+ ]
+ },
+ {
+ "name": "godot_callable_new_with_object_id",
+ "return_type": "void",
+ "arguments": [
+ ["godot_callable *", "r_dest"],
+ ["uint64_t", "p_objectid"],
+ ["const godot_string_name *", "p_method"]
+ ]
+ },
+ {
+ "name": "godot_callable_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_callable *", "r_dest"],
+ ["const godot_callable *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_callable_destroy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_call",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_callable *", "p_self"],
+ ["const godot_variant **", "p_arguments"],
+ ["godot_int", "p_argcount"],
+ ["godot_variant *", "r_return_value"]
+ ]
+ },
+ {
+ "name": "godot_callable_call_deferred",
+ "return_type": "void",
+ "arguments": [
+ ["const godot_callable *", "p_self"],
+ ["const godot_variant **", "p_arguments"],
+ ["godot_int", "p_argcount"]
+ ]
+ },
+ {
+ "name": "godot_callable_is_null",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_is_custom",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_is_standard",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_get_object",
+ "return_type": "godot_object *",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_get_object_id",
+ "return_type": "uint64_t",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_get_method",
+ "return_type": "godot_string_name",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_hash",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const godot_callable *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_callable_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_callable *", "p_self"]
]
},
{
- "name": "godot_vector3_min_axis",
+ "name": "godot_callable_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_callable *", "p_self"],
+ ["const godot_callable *", "p_other"]
+ ]
+ },
+ {
+ "name": "godot_callable_operator_less",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_callable *", "p_self"],
+ ["const godot_callable *", "p_other"]
+ ]
+ },
+ {
+ "name": "godot_signal_new_with_object",
+ "return_type": "void",
+ "arguments": [
+ ["godot_signal *", "r_dest"],
+ ["const godot_object *", "p_object"],
+ ["const godot_string_name *", "p_method"]
+ ]
+ },
+ {
+ "name": "godot_signal_new_with_object_id",
+ "return_type": "void",
+ "arguments": [
+ ["godot_signal *", "r_dest"],
+ ["uint64_t", "p_objectid"],
+ ["const godot_string_name *", "p_method"]
+ ]
+ },
+ {
+ "name": "godot_signal_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_signal *", "r_dest"],
+ ["const godot_signal *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_signal_destroy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_signal *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_signal_emit",
"return_type": "godot_int",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_signal *", "p_self"],
+ ["const godot_variant **", "p_arguments"],
+ ["godot_int", "p_argcount"]
]
},
{
- "name": "godot_vector3_max_axis",
+ "name": "godot_signal_connect",
"return_type": "godot_int",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["godot_signal *", "p_self"],
+ ["const godot_callable *", "p_callable"],
+ ["const godot_array *", "p_binds"],
+ ["uint32_t", "p_flags"]
]
},
{
- "name": "godot_vector3_length",
- "return_type": "godot_real",
+ "name": "godot_signal_disconnect",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["godot_signal *", "p_self"],
+ ["const godot_callable *", "p_callable"]
]
},
{
- "name": "godot_vector3_length_squared",
- "return_type": "godot_real",
+ "name": "godot_signal_is_null",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_signal *", "p_self"]
]
},
{
- "name": "godot_vector3_is_normalized",
+ "name": "godot_signal_is_connected",
"return_type": "godot_bool",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_signal *", "p_self"],
+ ["const godot_callable *", "p_callable"]
]
},
{
- "name": "godot_vector3_normalized",
- "return_type": "godot_vector3",
+ "name": "godot_signal_get_connections",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_signal *", "p_self"]
]
},
{
- "name": "godot_vector3_inverse",
- "return_type": "godot_vector3",
+ "name": "godot_signal_get_object",
+ "return_type": "godot_object *",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_signal *", "p_self"]
]
},
{
- "name": "godot_vector3_snapped",
- "return_type": "godot_vector3",
+ "name": "godot_signal_get_object_id",
+ "return_type": "uint64_t",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_by"]
+ ["const godot_signal *", "p_self"]
]
},
{
- "name": "godot_vector3_rotated",
- "return_type": "godot_vector3",
+ "name": "godot_signal_get_name",
+ "return_type": "godot_string_name",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_axis"],
- ["const godot_real", "p_phi"]
+ ["const godot_signal *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_signal_as_string",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_signal *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_signal_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_signal *", "p_self"],
+ ["const godot_signal *", "p_other"]
+ ]
+ },
+ {
+ "name": "godot_signal_operator_less",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_signal *", "p_self"],
+ ["const godot_signal *", "p_other"]
]
},
{
- "name": "godot_vector3_lerp",
- "return_type": "godot_vector3",
+ "name": "godot_color_new_rgba",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"],
- ["const godot_real", "p_t"]
+ ["godot_color *", "r_dest"],
+ ["const godot_real", "p_r"],
+ ["const godot_real", "p_g"],
+ ["const godot_real", "p_b"],
+ ["const godot_real", "p_a"]
]
},
{
- "name": "godot_vector3_cubic_interpolate",
- "return_type": "godot_vector3",
+ "name": "godot_color_new_rgb",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"],
- ["const godot_vector3 *", "p_pre_a"],
- ["const godot_vector3 *", "p_post_b"],
- ["const godot_real", "p_t"]
+ ["godot_color *", "r_dest"],
+ ["const godot_real", "p_r"],
+ ["const godot_real", "p_g"],
+ ["const godot_real", "p_b"]
]
},
{
- "name": "godot_vector3_dot",
+ "name": "godot_color_get_r",
"return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_cross",
- "return_type": "godot_vector3",
+ "name": "godot_color_set_r",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["godot_color *", "p_self"],
+ ["const godot_real", "r"]
]
},
{
- "name": "godot_vector3_outer",
- "return_type": "godot_basis",
+ "name": "godot_color_get_g",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_to_diagonal_matrix",
- "return_type": "godot_basis",
+ "name": "godot_color_set_g",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["godot_color *", "p_self"],
+ ["const godot_real", "g"]
]
},
{
- "name": "godot_vector3_abs",
- "return_type": "godot_vector3",
+ "name": "godot_color_get_b",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_floor",
- "return_type": "godot_vector3",
+ "name": "godot_color_set_b",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["godot_color *", "p_self"],
+ ["const godot_real", "b"]
]
},
{
- "name": "godot_vector3_ceil",
- "return_type": "godot_vector3",
+ "name": "godot_color_get_a",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_distance_to",
+ "name": "godot_color_set_a",
+ "return_type": "void",
+ "arguments": [
+ ["godot_color *", "p_self"],
+ ["const godot_real", "a"]
+ ]
+ },
+ {
+ "name": "godot_color_get_h",
"return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_distance_squared_to",
+ "name": "godot_color_get_s",
"return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_angle_to",
+ "name": "godot_color_get_v",
"return_type": "godot_real",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_to"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_slide",
- "return_type": "godot_vector3",
+ "name": "godot_color_as_string",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_n"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_bounce",
- "return_type": "godot_vector3",
+ "name": "godot_color_to_rgba32",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_n"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_reflect",
- "return_type": "godot_vector3",
+ "name": "godot_color_to_argb32",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_n"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_operator_add",
- "return_type": "godot_vector3",
+ "name": "godot_color_inverted",
+ "return_type": "godot_color",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_operator_subtract",
- "return_type": "godot_vector3",
+ "name": "godot_color_contrasted",
+ "return_type": "godot_color",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"]
]
},
{
- "name": "godot_vector3_operator_multiply_vector",
- "return_type": "godot_vector3",
+ "name": "godot_color_lerp",
+ "return_type": "godot_color",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"],
+ ["const godot_color *", "p_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_vector3_operator_multiply_scalar",
- "return_type": "godot_vector3",
+ "name": "godot_color_blend",
+ "return_type": "godot_color",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_real", "p_b"]
+ ["const godot_color *", "p_self"],
+ ["const godot_color *", "p_over"]
]
},
{
- "name": "godot_vector3_operator_divide_vector",
- "return_type": "godot_vector3",
+ "name": "godot_color_to_html",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"],
+ ["const godot_bool", "p_with_alpha"]
]
},
{
- "name": "godot_vector3_operator_divide_scalar",
- "return_type": "godot_vector3",
+ "name": "godot_color_operator_equal",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_real", "p_b"]
+ ["const godot_color *", "p_self"],
+ ["const godot_color *", "p_b"]
]
},
{
- "name": "godot_vector3_operator_equal",
+ "name": "godot_color_operator_less",
"return_type": "godot_bool",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_color *", "p_self"],
+ ["const godot_color *", "p_b"]
]
},
{
- "name": "godot_vector3_operator_less",
+ "name": "godot_color_to_abgr32",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_color *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_color_to_abgr64",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_color *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_color_to_argb64",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_color *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_color_to_rgba64",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_color *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_color_darkened",
+ "return_type": "godot_color",
+ "arguments": [
+ ["const godot_color *", "p_self"],
+ ["const godot_real", "p_amount"]
+ ]
+ },
+ {
+ "name": "godot_color_from_hsv",
+ "return_type": "godot_color",
+ "arguments": [
+ ["const godot_color *", "p_self"],
+ ["const godot_real", "p_h"],
+ ["const godot_real", "p_s"],
+ ["const godot_real", "p_v"],
+ ["const godot_real", "p_a"]
+ ]
+ },
+ {
+ "name": "godot_color_lightened",
+ "return_type": "godot_color",
+ "arguments": [
+ ["const godot_color *", "p_self"],
+ ["const godot_real", "p_amount"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_new",
+ "return_type": "void",
+ "arguments": [
+ ["godot_dictionary *", "r_dest"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_dictionary *", "r_dest"],
+ ["const godot_dictionary *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_destroy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_dictionary *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_size",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3 *", "p_b"]
+ ["const godot_dictionary *", "p_self"]
]
},
{
- "name": "godot_vector3_operator_neg",
- "return_type": "godot_vector3",
+ "name": "godot_dictionary_clear",
+ "return_type": "void",
"arguments": [
- ["const godot_vector3 *", "p_self"]
+ ["godot_dictionary *", "p_self"]
]
},
{
- "name": "godot_vector3_set_axis",
+ "name": "godot_dictionary_has",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_has_all",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_array *", "p_keys"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_erase",
"return_type": "void",
"arguments": [
- ["godot_vector3 *", "p_self"],
- ["const godot_vector3_axis", "p_axis"],
- ["const godot_real", "p_val"]
+ ["godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
]
},
{
- "name": "godot_vector3_get_axis",
- "return_type": "godot_real",
+ "name": "godot_dictionary_hash",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_vector3 *", "p_self"],
- ["const godot_vector3_axis", "p_axis"]
+ ["const godot_dictionary *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_keys",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_values",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_get",
+ "return_type": "godot_variant",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_set",
+ "return_type": "void",
+ "arguments": [
+ ["godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"],
+ ["const godot_variant *", "p_value"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_operator_index",
+ "return_type": "godot_variant *",
+ "arguments": [
+ ["godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_operator_index_const",
+ "return_type": "const godot_variant *",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_next",
+ "return_type": "godot_variant *",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_dictionary *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_to_json",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_duplicate",
+ "return_type": "godot_dictionary",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_bool", "p_deep"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_get_with_default",
+ "return_type": "godot_variant",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"],
+ ["const godot_variant *", "p_default"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_erase_with_return",
+ "return_type": "bool",
+ "arguments": [
+ ["godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_node_path_new",
+ "return_type": "void",
+ "arguments": [
+ ["godot_node_path *", "r_dest"],
+ ["const godot_string *", "p_from"]
+ ]
+ },
+ {
+ "name": "godot_node_path_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_node_path *", "r_dest"],
+ ["const godot_node_path *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_node_path_destroy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_as_string",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_is_absolute",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_get_name_count",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_get_name",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_node_path *", "p_self"],
+ ["const godot_int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_node_path_get_subname_count",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_get_subname",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_node_path *", "p_self"],
+ ["const godot_int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_node_path_get_concatenated_subnames",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_is_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_node_path_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_node_path *", "p_self"],
+ ["const godot_node_path *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_node_path_get_as_property_path",
+ "return_type": "godot_node_path",
+ "arguments": [
+ ["const godot_node_path *", "p_self"]
]
},
{
@@ -1680,6 +1639,13 @@
]
},
{
+ "name": "godot_packed_byte_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_byte_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_byte_array_append",
"return_type": "void",
"arguments": [
@@ -1736,6 +1702,20 @@
]
},
{
+ "name": "godot_packed_byte_array_ptr",
+ "return_type": "const uint8_t *",
+ "arguments": [
+ ["const godot_packed_byte_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_byte_array_ptrw",
+ "return_type": "uint8_t *",
+ "arguments": [
+ ["godot_packed_byte_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_byte_array_set",
"return_type": "void",
"arguments": [
@@ -1767,223 +1747,527 @@
]
},
{
- "name": "godot_packed_int_array_new",
+ "name": "godot_packed_int32_array_new",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "r_dest"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "r_dest"],
+ ["const godot_packed_int32_array *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_new_with_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "r_dest"],
+ ["const godot_array *", "p_a"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_int32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_append",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"],
+ ["const int32_t", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_append_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"],
+ ["const godot_packed_int32_array *", "p_array"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_insert",
+ "return_type": "godot_error",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"],
+ ["const godot_int", "p_idx"],
+ ["const int32_t", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_invert",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_push_back",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"],
+ ["const int32_t", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_remove",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "r_dest"]
+ ["godot_packed_int32_array *", "p_self"],
+ ["const godot_int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_resize",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"],
+ ["const godot_int", "p_size"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_ptr",
+ "return_type": "const int32_t *",
+ "arguments": [
+ ["const godot_packed_int32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_ptrw",
+ "return_type": "int32_t *",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_set",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int32_array *", "p_self"],
+ ["const godot_int", "p_idx"],
+ ["const int32_t", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_get",
+ "return_type": "int32_t",
+ "arguments": [
+ ["const godot_packed_int32_array *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_packed_int_array_new_copy",
+ "name": "godot_packed_int32_array_size",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_packed_int32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int32_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "r_dest"],
- ["const godot_packed_int_array *", "p_src"]
+ ["godot_packed_int32_array *", "p_self"]
]
},
{
- "name": "godot_packed_int_array_new_with_array",
+ "name": "godot_packed_int64_array_new",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "r_dest"],
+ ["godot_packed_int64_array *", "r_dest"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int64_array *", "r_dest"],
+ ["const godot_packed_int64_array *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_new_with_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int64_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_packed_int_array_append",
+ "name": "godot_packed_int64_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_int64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_append",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
- ["const godot_int", "p_data"]
+ ["godot_packed_int64_array *", "p_self"],
+ ["const int64_t", "p_data"]
]
},
{
- "name": "godot_packed_int_array_append_array",
+ "name": "godot_packed_int64_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
- ["const godot_packed_int_array *", "p_array"]
+ ["godot_packed_int64_array *", "p_self"],
+ ["const godot_packed_int64_array *", "p_array"]
]
},
{
- "name": "godot_packed_int_array_insert",
+ "name": "godot_packed_int64_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
+ ["godot_packed_int64_array *", "p_self"],
["const godot_int", "p_idx"],
- ["const godot_int", "p_data"]
+ ["const int64_t", "p_data"]
]
},
{
- "name": "godot_packed_int_array_invert",
+ "name": "godot_packed_int64_array_invert",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"]
+ ["godot_packed_int64_array *", "p_self"]
]
},
{
- "name": "godot_packed_int_array_push_back",
+ "name": "godot_packed_int64_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
- ["const godot_int", "p_data"]
+ ["godot_packed_int64_array *", "p_self"],
+ ["const int64_t", "p_data"]
]
},
{
- "name": "godot_packed_int_array_remove",
+ "name": "godot_packed_int64_array_remove",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
+ ["godot_packed_int64_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_packed_int_array_resize",
+ "name": "godot_packed_int64_array_resize",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
+ ["godot_packed_int64_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_packed_int_array_set",
+ "name": "godot_packed_int64_array_ptr",
+ "return_type": "const int64_t *",
+ "arguments": [
+ ["const godot_packed_int64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_ptrw",
+ "return_type": "int64_t *",
+ "arguments": [
+ ["godot_packed_int64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_set",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"],
+ ["godot_packed_int64_array *", "p_self"],
["const godot_int", "p_idx"],
- ["const godot_int", "p_data"]
+ ["const int64_t", "p_data"]
]
},
{
- "name": "godot_packed_int_array_get",
+ "name": "godot_packed_int64_array_get",
+ "return_type": "int64_t",
+ "arguments": [
+ ["const godot_packed_int64_array *", "p_self"],
+ ["const godot_int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_packed_int_array *", "p_self"],
+ ["const godot_packed_int64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_int64_array_destroy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_int64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_new",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "r_dest"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_new_copy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "r_dest"],
+ ["const godot_packed_float32_array *", "p_src"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_new_with_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "r_dest"],
+ ["const godot_array *", "p_a"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_float32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_append",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
+ ["const float", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_append_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
+ ["const godot_packed_float32_array *", "p_array"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_insert",
+ "return_type": "godot_error",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
+ ["const godot_int", "p_idx"],
+ ["const float", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_invert",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_push_back",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
+ ["const float", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_remove",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_packed_int_array_size",
+ "name": "godot_packed_float32_array_resize",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
+ ["const godot_int", "p_size"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_ptr",
+ "return_type": "const float *",
+ "arguments": [
+ ["const godot_packed_float32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_ptrw",
+ "return_type": "float *",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_set",
+ "return_type": "void",
+ "arguments": [
+ ["godot_packed_float32_array *", "p_self"],
+ ["const godot_int", "p_idx"],
+ ["const float", "p_data"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_get",
+ "return_type": "float",
+ "arguments": [
+ ["const godot_packed_float32_array *", "p_self"],
+ ["const godot_int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_packed_float32_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_packed_int_array *", "p_self"]
+ ["const godot_packed_float32_array *", "p_self"]
]
},
{
- "name": "godot_packed_int_array_destroy",
+ "name": "godot_packed_float32_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_packed_int_array *", "p_self"]
+ ["godot_packed_float32_array *", "p_self"]
]
},
{
- "name": "godot_packed_real_array_new",
+ "name": "godot_packed_float64_array_new",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "r_dest"]
+ ["godot_packed_float64_array *", "r_dest"]
]
},
{
- "name": "godot_packed_real_array_new_copy",
+ "name": "godot_packed_float64_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "r_dest"],
- ["const godot_packed_real_array *", "p_src"]
+ ["godot_packed_float64_array *", "r_dest"],
+ ["const godot_packed_float64_array *", "p_src"]
]
},
{
- "name": "godot_packed_real_array_new_with_array",
+ "name": "godot_packed_float64_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "r_dest"],
+ ["godot_packed_float64_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_packed_real_array_append",
+ "name": "godot_packed_float64_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_float64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float64_array_append",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
- ["const godot_real", "p_data"]
+ ["godot_packed_float64_array *", "p_self"],
+ ["const double", "p_data"]
]
},
{
- "name": "godot_packed_real_array_append_array",
+ "name": "godot_packed_float64_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
- ["const godot_packed_real_array *", "p_array"]
+ ["godot_packed_float64_array *", "p_self"],
+ ["const godot_packed_float64_array *", "p_array"]
]
},
{
- "name": "godot_packed_real_array_insert",
+ "name": "godot_packed_float64_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
+ ["godot_packed_float64_array *", "p_self"],
["const godot_int", "p_idx"],
- ["const godot_real", "p_data"]
+ ["const double", "p_data"]
]
},
{
- "name": "godot_packed_real_array_invert",
+ "name": "godot_packed_float64_array_invert",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"]
+ ["godot_packed_float64_array *", "p_self"]
]
},
{
- "name": "godot_packed_real_array_push_back",
+ "name": "godot_packed_float64_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
- ["const godot_real", "p_data"]
+ ["godot_packed_float64_array *", "p_self"],
+ ["const double", "p_data"]
]
},
{
- "name": "godot_packed_real_array_remove",
+ "name": "godot_packed_float64_array_remove",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
+ ["godot_packed_float64_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_packed_real_array_resize",
+ "name": "godot_packed_float64_array_resize",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
+ ["godot_packed_float64_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_packed_real_array_set",
+ "name": "godot_packed_float64_array_ptr",
+ "return_type": "const double *",
+ "arguments": [
+ ["const godot_packed_float64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float64_array_ptrw",
+ "return_type": "double *",
+ "arguments": [
+ ["godot_packed_float64_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_float64_array_set",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"],
+ ["godot_packed_float64_array *", "p_self"],
["const godot_int", "p_idx"],
- ["const godot_real", "p_data"]
+ ["const double", "p_data"]
]
},
{
- "name": "godot_packed_real_array_get",
- "return_type": "godot_real",
+ "name": "godot_packed_float64_array_get",
+ "return_type": "double",
"arguments": [
- ["const godot_packed_real_array *", "p_self"],
+ ["const godot_packed_float64_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_packed_real_array_size",
+ "name": "godot_packed_float64_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_packed_real_array *", "p_self"]
+ ["const godot_packed_float64_array *", "p_self"]
]
},
{
- "name": "godot_packed_real_array_destroy",
+ "name": "godot_packed_float64_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_packed_real_array *", "p_self"]
+ ["godot_packed_float64_array *", "p_self"]
]
},
{
@@ -2010,6 +2294,13 @@
]
},
{
+ "name": "godot_packed_string_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_string_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_string_array_append",
"return_type": "void",
"arguments": [
@@ -2066,6 +2357,20 @@
]
},
{
+ "name": "godot_packed_string_array_ptr",
+ "return_type": "const godot_string *",
+ "arguments": [
+ ["const godot_packed_string_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_string_array_ptrw",
+ "return_type": "godot_string *",
+ "arguments": [
+ ["godot_packed_string_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_string_array_set",
"return_type": "void",
"arguments": [
@@ -2120,6 +2425,13 @@
]
},
{
+ "name": "godot_packed_vector2_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_vector2_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_vector2_array_append",
"return_type": "void",
"arguments": [
@@ -2176,6 +2488,20 @@
]
},
{
+ "name": "godot_packed_vector2_array_ptr",
+ "return_type": "const godot_vector2 *",
+ "arguments": [
+ ["const godot_packed_vector2_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_vector2_array_ptrw",
+ "return_type": "godot_vector2 *",
+ "arguments": [
+ ["godot_packed_vector2_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_vector2_array_set",
"return_type": "void",
"arguments": [
@@ -2230,6 +2556,13 @@
]
},
{
+ "name": "godot_packed_vector3_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_vector3_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_vector3_array_append",
"return_type": "void",
"arguments": [
@@ -2286,6 +2619,20 @@
]
},
{
+ "name": "godot_packed_vector3_array_ptr",
+ "return_type": "const godot_vector3 *",
+ "arguments": [
+ ["const godot_packed_vector3_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_vector3_array_ptrw",
+ "return_type": "godot_vector3 *",
+ "arguments": [
+ ["godot_packed_vector3_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_vector3_array_set",
"return_type": "void",
"arguments": [
@@ -2340,6 +2687,13 @@
]
},
{
+ "name": "godot_packed_color_array_empty",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_packed_color_array *", "p_self"]
+ ]
+ },
+ {
"name": "godot_packed_color_array_append",
"return_type": "void",
"arguments": [
@@ -2394,6 +2748,20 @@
["godot_packed_color_array *", "p_self"],
["const godot_int", "p_size"]
]
+ },
+ {
+ "name": "godot_packed_color_array_ptr",
+ "return_type": "const godot_color *",
+ "arguments": [
+ ["const godot_packed_color_array *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_packed_color_array_ptrw",
+ "return_type": "godot_color *",
+ "arguments": [
+ ["godot_packed_color_array *", "p_self"]
+ ]
},
{
"name": "godot_packed_color_array_set",
@@ -2427,1090 +2795,2064 @@
]
},
{
- "name": "godot_array_new",
+ "name": "godot_plane_new_with_reals",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"]
+ ["godot_plane *", "r_dest"],
+ ["const godot_real", "p_a"],
+ ["const godot_real", "p_b"],
+ ["const godot_real", "p_c"],
+ ["const godot_real", "p_d"]
]
},
{
- "name": "godot_array_new_copy",
+ "name": "godot_plane_new_with_vectors",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_array *", "p_src"]
+ ["godot_plane *", "r_dest"],
+ ["const godot_vector3 *", "p_v1"],
+ ["const godot_vector3 *", "p_v2"],
+ ["const godot_vector3 *", "p_v3"]
]
},
{
- "name": "godot_array_new_packed_color_array",
+ "name": "godot_plane_new_with_normal",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_color_array *", "p_pca"]
+ ["godot_plane *", "r_dest"],
+ ["const godot_vector3 *", "p_normal"],
+ ["const godot_real", "p_d"]
]
},
{
- "name": "godot_array_new_packed_vector3_array",
+ "name": "godot_plane_as_string",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_normalized",
+ "return_type": "godot_plane",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_center",
+ "return_type": "godot_vector3",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_get_any_point",
+ "return_type": "godot_vector3",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_is_point_over",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["const godot_vector3 *", "p_point"]
+ ]
+ },
+ {
+ "name": "godot_plane_distance_to",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["const godot_vector3 *", "p_point"]
+ ]
+ },
+ {
+ "name": "godot_plane_has_point",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["const godot_vector3 *", "p_point"],
+ ["const godot_real", "p_epsilon"]
+ ]
+ },
+ {
+ "name": "godot_plane_project",
+ "return_type": "godot_vector3",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["const godot_vector3 *", "p_point"]
+ ]
+ },
+ {
+ "name": "godot_plane_intersect_3",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["godot_vector3 *", "r_dest"],
+ ["const godot_plane *", "p_b"],
+ ["const godot_plane *", "p_c"]
+ ]
+ },
+ {
+ "name": "godot_plane_intersects_ray",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["godot_vector3 *", "r_dest"],
+ ["const godot_vector3 *", "p_from"],
+ ["const godot_vector3 *", "p_dir"]
+ ]
+ },
+ {
+ "name": "godot_plane_intersects_segment",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["godot_vector3 *", "r_dest"],
+ ["const godot_vector3 *", "p_begin"],
+ ["const godot_vector3 *", "p_end"]
+ ]
+ },
+ {
+ "name": "godot_plane_operator_neg",
+ "return_type": "godot_plane",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_plane *", "p_self"],
+ ["const godot_plane *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_plane_set_normal",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_vector3_array *", "p_pv3a"]
+ ["godot_plane *", "p_self"],
+ ["const godot_vector3 *", "p_normal"]
]
},
{
- "name": "godot_array_new_packed_vector2_array",
+ "name": "godot_plane_get_normal",
+ "return_type": "godot_vector3",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_get_d",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_plane *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_plane_set_d",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_vector2_array *", "p_pv2a"]
+ ["godot_plane *", "p_self"],
+ ["const godot_real", "p_d"]
]
},
{
- "name": "godot_array_new_packed_string_array",
+ "name": "godot_quat_new",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_string_array *", "p_psa"]
+ ["godot_quat *", "r_dest"],
+ ["const godot_real", "p_x"],
+ ["const godot_real", "p_y"],
+ ["const godot_real", "p_z"],
+ ["const godot_real", "p_w"]
]
},
{
- "name": "godot_array_new_packed_real_array",
+ "name": "godot_quat_new_with_axis_angle",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_real_array *", "p_pra"]
+ ["godot_quat *", "r_dest"],
+ ["const godot_vector3 *", "p_axis"],
+ ["const godot_real", "p_angle"]
]
},
{
- "name": "godot_array_new_packed_int_array",
+ "name": "godot_quat_new_with_basis",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_int_array *", "p_pia"]
+ ["godot_quat *", "r_dest"],
+ ["const godot_basis *", "p_basis"]
]
},
{
- "name": "godot_array_new_packed_byte_array",
+ "name": "godot_quat_new_with_euler",
"return_type": "void",
"arguments": [
- ["godot_array *", "r_dest"],
- ["const godot_packed_byte_array *", "p_pba"]
+ ["godot_quat *", "r_dest"],
+ ["const godot_vector3 *", "p_euler"]
]
},
{
- "name": "godot_array_set",
+ "name": "godot_quat_get_x",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_quat *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_quat_set_x",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_int", "p_idx"],
- ["const godot_variant *", "p_value"]
+ ["godot_quat *", "p_self"],
+ ["const godot_real", "val"]
]
},
{
- "name": "godot_array_get",
- "return_type": "godot_variant",
+ "name": "godot_quat_get_y",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_quat *", "p_self"]
]
},
{
- "name": "godot_array_operator_index",
- "return_type": "godot_variant *",
+ "name": "godot_quat_set_y",
+ "return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["godot_quat *", "p_self"],
+ ["const godot_real", "val"]
]
},
{
- "name": "godot_array_operator_index_const",
- "return_type": "const godot_variant *",
+ "name": "godot_quat_get_z",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_quat *", "p_self"]
]
},
{
- "name": "godot_array_append",
+ "name": "godot_quat_set_z",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_variant *", "p_value"]
+ ["godot_quat *", "p_self"],
+ ["const godot_real", "val"]
]
},
{
- "name": "godot_array_clear",
+ "name": "godot_quat_get_w",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_quat *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_quat_set_w",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"]
+ ["godot_quat *", "p_self"],
+ ["const godot_real", "val"]
]
},
{
- "name": "godot_array_count",
- "return_type": "godot_int",
+ "name": "godot_quat_set_axis_angle",
+ "return_type": "void",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_variant *", "p_value"]
+ ["godot_quat *", "p_self"],
+ ["const godot_vector3 *", "p_axis"],
+ ["const godot_real", "p_angle"]
]
},
{
- "name": "godot_array_empty",
+ "name": "godot_quat_as_string",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_quat *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_quat_length",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_quat *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_quat_length_squared",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_quat *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_quat_normalized",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_quat *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_quat_is_normalized",
"return_type": "godot_bool",
"arguments": [
- ["const godot_array *", "p_self"]
+ ["const godot_quat *", "p_self"]
]
},
{
- "name": "godot_array_erase",
- "return_type": "void",
+ "name": "godot_quat_inverse",
+ "return_type": "godot_quat",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_variant *", "p_value"]
+ ["const godot_quat *", "p_self"]
]
},
{
- "name": "godot_array_front",
- "return_type": "godot_variant",
+ "name": "godot_quat_dot",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_array *", "p_self"]
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"]
]
},
{
- "name": "godot_array_back",
- "return_type": "godot_variant",
+ "name": "godot_quat_xform",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_array *", "p_self"]
+ ["const godot_quat *", "p_self"],
+ ["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_array_find",
- "return_type": "godot_int",
+ "name": "godot_quat_slerp",
+ "return_type": "godot_quat",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_variant *", "p_what"],
- ["const godot_int", "p_from"]
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_array_find_last",
- "return_type": "godot_int",
+ "name": "godot_quat_slerpni",
+ "return_type": "godot_quat",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_variant *", "p_what"]
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_array_has",
+ "name": "godot_quat_cubic_slerp",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"],
+ ["const godot_quat *", "p_pre_a"],
+ ["const godot_quat *", "p_post_b"],
+ ["const godot_real", "p_t"]
+ ]
+ },
+ {
+ "name": "godot_quat_operator_multiply",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_quat *", "p_self"],
+ ["const godot_real", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_quat_operator_add",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_quat_operator_subtract",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_quat_operator_divide",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_quat *", "p_self"],
+ ["const godot_real", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_quat_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_variant *", "p_value"]
+ ["const godot_quat *", "p_self"],
+ ["const godot_quat *", "p_b"]
]
},
{
- "name": "godot_array_hash",
- "return_type": "godot_int",
+ "name": "godot_quat_operator_neg",
+ "return_type": "godot_quat",
"arguments": [
- ["const godot_array *", "p_self"]
+ ["const godot_quat *", "p_self"]
]
},
{
- "name": "godot_array_insert",
+ "name": "godot_rect2_new_with_position_and_size",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_int", "p_pos"],
- ["const godot_variant *", "p_value"]
+ ["godot_rect2 *", "r_dest"],
+ ["const godot_vector2 *", "p_pos"],
+ ["const godot_vector2 *", "p_size"]
]
},
{
- "name": "godot_array_invert",
+ "name": "godot_rect2_new",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"]
+ ["godot_rect2 *", "r_dest"],
+ ["const godot_real", "p_x"],
+ ["const godot_real", "p_y"],
+ ["const godot_real", "p_width"],
+ ["const godot_real", "p_height"]
]
},
{
- "name": "godot_array_pop_back",
- "return_type": "godot_variant",
+ "name": "godot_rect2_as_rect2i",
+ "return_type": "godot_rect2i",
"arguments": [
- ["godot_array *", "p_self"]
+ ["const godot_rect2 *", "p_self"]
]
},
{
- "name": "godot_array_pop_front",
- "return_type": "godot_variant",
+ "name": "godot_rect2_as_string",
+ "return_type": "godot_string",
"arguments": [
- ["godot_array *", "p_self"]
+ ["const godot_rect2 *", "p_self"]
]
},
{
- "name": "godot_array_push_back",
+ "name": "godot_rect2_get_area",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2_grow_individual",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_real", "p_left"],
+ ["const godot_real", "p_top"],
+ ["const godot_real", "p_right"],
+ ["const godot_real", "p_bottom"]
+ ]
+ },
+ {
+ "name": "godot_rect2_grow_margin",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_int", "p_margin"],
+ ["const godot_real", "p_by"]
+ ]
+ },
+ {
+ "name": "godot_rect2_abs",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2_intersects",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_rect2 *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2_encloses",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_rect2 *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2_has_no_area",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2_clip",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_rect2 *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2_merge",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_rect2 *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2_has_point",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_vector2 *", "p_point"]
+ ]
+ },
+ {
+ "name": "godot_rect2_grow",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_real", "p_by"]
+ ]
+ },
+ {
+ "name": "godot_rect2_expand",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
+ ]
+ },
+ {
+ "name": "godot_rect2_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"],
+ ["const godot_rect2 *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2_get_position",
+ "return_type": "godot_vector2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2_get_size",
+ "return_type": "godot_vector2",
+ "arguments": [
+ ["const godot_rect2 *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2_set_position",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_variant *", "p_value"]
+ ["godot_rect2 *", "p_self"],
+ ["const godot_vector2 *", "p_pos"]
]
},
{
- "name": "godot_array_push_front",
+ "name": "godot_rect2_set_size",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_variant *", "p_value"]
+ ["godot_rect2 *", "p_self"],
+ ["const godot_vector2 *", "p_size"]
]
},
{
- "name": "godot_array_remove",
+ "name": "godot_rect2i_new_with_position_and_size",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["godot_rect2i *", "r_dest"],
+ ["const godot_vector2i *", "p_pos"],
+ ["const godot_vector2i *", "p_size"]
]
},
{
- "name": "godot_array_resize",
+ "name": "godot_rect2i_new",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_int", "p_size"]
+ ["godot_rect2i *", "r_dest"],
+ ["const godot_int", "p_x"],
+ ["const godot_int", "p_y"],
+ ["const godot_int", "p_width"],
+ ["const godot_int", "p_height"]
]
},
{
- "name": "godot_array_rfind",
- "return_type": "godot_int",
+ "name": "godot_rect2i_as_string",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_array *", "p_self"],
- ["const godot_variant *", "p_what"],
- ["const godot_int", "p_from"]
+ ["const godot_rect2i *", "p_self"]
]
},
{
- "name": "godot_array_size",
+ "name": "godot_rect2i_as_rect2",
+ "return_type": "godot_rect2",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_get_area",
"return_type": "godot_int",
"arguments": [
- ["const godot_array *", "p_self"]
+ ["const godot_rect2i *", "p_self"]
]
},
{
- "name": "godot_array_sort",
+ "name": "godot_rect2i_intersects",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_rect2i *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_encloses",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_rect2i *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_has_no_area",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_clip",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_rect2i *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_merge",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_rect2i *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_has_point",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_vector2i *", "p_point"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_grow",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_int", "p_by"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_grow_individual",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_int", "p_left"],
+ ["const godot_int", "p_top"],
+ ["const godot_int", "p_right"],
+ ["const godot_int", "p_bottom"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_grow_margin",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_int", "p_margin"],
+ ["const godot_int", "p_by"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_abs",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_expand",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_vector2i *", "p_to"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"],
+ ["const godot_rect2i *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_get_position",
+ "return_type": "godot_vector2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_get_size",
+ "return_type": "godot_vector2i",
+ "arguments": [
+ ["const godot_rect2i *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_rect2i_set_position",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"]
+ ["godot_rect2i *", "p_self"],
+ ["const godot_vector2i *", "p_pos"]
]
},
{
- "name": "godot_array_sort_custom",
+ "name": "godot_rect2i_set_size",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"],
- ["godot_object *", "p_obj"],
- ["const godot_string *", "p_func"]
+ ["godot_rect2i *", "p_self"],
+ ["const godot_vector2i *", "p_size"]
]
},
{
- "name": "godot_array_bsearch",
+ "name": "godot_rid_new",
+ "return_type": "void",
+ "arguments": [
+ ["godot_rid *", "r_dest"]
+ ]
+ },
+ {
+ "name": "godot_rid_get_id",
"return_type": "godot_int",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_variant *", "p_value"],
- ["const godot_bool", "p_before"]
+ ["const godot_rid *", "p_self"]
]
},
{
- "name": "godot_array_bsearch_custom",
+ "name": "godot_rid_new_with_resource",
+ "return_type": "void",
+ "arguments": [
+ ["godot_rid *", "r_dest"],
+ ["const godot_object *", "p_from"]
+ ]
+ },
+ {
+ "name": "godot_rid_operator_equal",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rid *", "p_self"],
+ ["const godot_rid *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_rid_operator_less",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_rid *", "p_self"],
+ ["const godot_rid *", "p_b"]
+ ]
+ },
+ {
+ "name": "godot_char_string_length",
"return_type": "godot_int",
"arguments": [
- ["godot_array *", "p_self"],
- ["const godot_variant *", "p_value"],
- ["godot_object *", "p_obj"],
- ["const godot_string *", "p_func"],
- ["const godot_bool", "p_before"]
+ ["const godot_char_string *", "p_cs"]
]
},
{
- "name": "godot_array_destroy",
+ "name": "godot_char_string_get_data",
+ "return_type": "const char *",
+ "arguments": [
+ ["const godot_char_string *", "p_cs"]
+ ]
+ },
+ {
+ "name": "godot_char_string_destroy",
"return_type": "void",
"arguments": [
- ["godot_array *", "p_self"]
+ ["godot_char_string *", "p_cs"]
]
},
{
- "name": "godot_dictionary_new",
+ "name": "godot_string_new",
"return_type": "void",
"arguments": [
- ["godot_dictionary *", "r_dest"]
+ ["godot_string *", "r_dest"]
]
},
{
- "name": "godot_dictionary_new_copy",
+ "name": "godot_string_new_copy",
"return_type": "void",
"arguments": [
- ["godot_dictionary *", "r_dest"],
- ["const godot_dictionary *", "p_src"]
+ ["godot_string *", "r_dest"],
+ ["const godot_string *", "p_src"]
]
},
{
- "name": "godot_dictionary_destroy",
+ "name": "godot_string_new_with_wide_string",
"return_type": "void",
"arguments": [
- ["godot_dictionary *", "p_self"]
+ ["godot_string *", "r_dest"],
+ ["const wchar_t *", "p_contents"],
+ ["const int", "p_size"]
]
},
{
- "name": "godot_dictionary_size",
- "return_type": "godot_int",
+ "name": "godot_string_operator_index",
+ "return_type": "const wchar_t *",
"arguments": [
- ["const godot_dictionary *", "p_self"]
+ ["godot_string *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_dictionary_empty",
- "return_type": "godot_bool",
+ "name": "godot_string_operator_index_const",
+ "return_type": "wchar_t",
"arguments": [
- ["const godot_dictionary *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_int", "p_idx"]
]
},
{
- "name": "godot_dictionary_clear",
- "return_type": "void",
+ "name": "godot_string_wide_str",
+ "return_type": "const wchar_t *",
"arguments": [
- ["godot_dictionary *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_dictionary_has",
+ "name": "godot_string_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_b"]
]
},
{
- "name": "godot_dictionary_has_all",
+ "name": "godot_string_operator_less",
"return_type": "godot_bool",
"arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_array *", "p_keys"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_b"]
]
},
{
- "name": "godot_dictionary_erase",
- "return_type": "void",
+ "name": "godot_string_operator_plus",
+ "return_type": "godot_string",
"arguments": [
- ["godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_b"]
]
},
{
- "name": "godot_dictionary_hash",
+ "name": "godot_string_count",
"return_type": "godot_int",
"arguments": [
- ["const godot_dictionary *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"],
+ ["godot_int", "p_to"]
]
},
{
- "name": "godot_dictionary_keys",
- "return_type": "godot_array",
+ "name": "godot_string_countn",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_dictionary *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"],
+ ["godot_int", "p_to"]
]
},
{
- "name": "godot_dictionary_values",
- "return_type": "godot_array",
+ "name": "godot_string_dedent",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_dictionary *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_dictionary_get",
- "return_type": "godot_variant",
+ "name": "godot_string_length",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_dictionary_set",
- "return_type": "void",
+ "name": "godot_string_casecmp_to",
+ "return_type": "signed char",
"arguments": [
- ["godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"],
- ["const godot_variant *", "p_value"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
]
},
{
- "name": "godot_dictionary_operator_index",
- "return_type": "godot_variant *",
+ "name": "godot_string_nocasecmp_to",
+ "return_type": "signed char",
"arguments": [
- ["godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
]
},
{
- "name": "godot_dictionary_operator_index_const",
- "return_type": "const godot_variant *",
+ "name": "godot_string_naturalnocasecmp_to",
+ "return_type": "signed char",
"arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_str"]
]
},
{
- "name": "godot_dictionary_next",
- "return_type": "godot_variant *",
+ "name": "godot_string_begins_with",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_string"]
]
},
{
- "name": "godot_dictionary_operator_equal",
+ "name": "godot_string_begins_with_char_array",
"return_type": "godot_bool",
"arguments": [
- ["const godot_dictionary *", "p_self"],
- ["const godot_dictionary *", "p_b"]
+ ["const godot_string *", "p_self"],
+ ["const char *", "p_char_array"]
]
},
{
- "name": "godot_dictionary_to_json",
+ "name": "godot_string_bigrams",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_chr",
"return_type": "godot_string",
"arguments": [
- ["const godot_dictionary *", "p_self"]
+ ["wchar_t", "p_character"]
]
},
{
- "name": "godot_node_path_new",
- "return_type": "void",
+ "name": "godot_string_ends_with",
+ "return_type": "godot_bool",
"arguments": [
- ["godot_node_path *", "r_dest"],
- ["const godot_string *", "p_from"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_string"]
]
},
{
- "name": "godot_node_path_new_copy",
- "return_type": "void",
+ "name": "godot_string_find",
+ "return_type": "godot_int",
"arguments": [
- ["godot_node_path *", "r_dest"],
- ["const godot_node_path *", "p_src"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"]
]
},
{
- "name": "godot_node_path_destroy",
- "return_type": "void",
+ "name": "godot_string_find_from",
+ "return_type": "godot_int",
"arguments": [
- ["godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"]
]
},
{
- "name": "godot_node_path_as_string",
- "return_type": "godot_string",
+ "name": "godot_string_findmk",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_keys"]
]
},
{
- "name": "godot_node_path_is_absolute",
- "return_type": "godot_bool",
+ "name": "godot_string_findmk_from",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_keys"],
+ ["godot_int", "p_from"]
]
},
{
- "name": "godot_node_path_get_name_count",
+ "name": "godot_string_findmk_from_in_place",
"return_type": "godot_int",
"arguments": [
- ["const godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_keys"],
+ ["godot_int", "p_from"],
+ ["godot_int *", "r_key"]
]
},
{
- "name": "godot_node_path_get_name",
+ "name": "godot_string_findn",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"]
+ ]
+ },
+ {
+ "name": "godot_string_findn_from",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"]
+ ]
+ },
+ {
+ "name": "godot_string_find_last",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"]
+ ]
+ },
+ {
+ "name": "godot_string_format",
"return_type": "godot_string",
"arguments": [
- ["const godot_node_path *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_string *", "p_self"],
+ ["const godot_variant *", "p_values"]
]
},
{
- "name": "godot_node_path_get_subname_count",
+ "name": "godot_string_format_with_custom_placeholder",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_variant *", "p_values"],
+ ["const char *", "p_placeholder"]
+ ]
+ },
+ {
+ "name": "godot_string_hex_encode_buffer",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const uint8_t *", "p_buffer"],
+ ["godot_int", "p_len"]
+ ]
+ },
+ {
+ "name": "godot_string_hex_to_int",
"return_type": "godot_int",
"arguments": [
- ["const godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_node_path_get_subname",
+ "name": "godot_string_hex_to_int_without_prefix",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_insert",
"return_type": "godot_string",
"arguments": [
- ["const godot_node_path *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_at_pos"],
+ ["godot_string", "p_string"]
]
},
{
- "name": "godot_node_path_get_concatenated_subnames",
+ "name": "godot_string_is_numeric",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_is_subsequence_of",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_string"]
+ ]
+ },
+ {
+ "name": "godot_string_is_subsequence_ofi",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_string"]
+ ]
+ },
+ {
+ "name": "godot_string_lpad",
"return_type": "godot_string",
"arguments": [
- ["const godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_min_length"]
]
},
{
- "name": "godot_node_path_is_empty",
+ "name": "godot_string_lpad_with_custom_character",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_min_length"],
+ ["const godot_string *", "p_character"]
+ ]
+ },
+ {
+ "name": "godot_string_match",
"return_type": "godot_bool",
"arguments": [
- ["const godot_node_path *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_wildcard"]
]
},
{
- "name": "godot_node_path_operator_equal",
+ "name": "godot_string_matchn",
"return_type": "godot_bool",
"arguments": [
- ["const godot_node_path *", "p_self"],
- ["const godot_node_path *", "p_b"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_wildcard"]
]
},
{
- "name": "godot_plane_new_with_reals",
- "return_type": "void",
+ "name": "godot_string_md5",
+ "return_type": "godot_string",
"arguments": [
- ["godot_plane *", "r_dest"],
- ["const godot_real", "p_a"],
- ["const godot_real", "p_b"],
- ["const godot_real", "p_c"],
- ["const godot_real", "p_d"]
+ ["const uint8_t *", "p_md5"]
]
},
{
- "name": "godot_plane_new_with_vectors",
- "return_type": "void",
+ "name": "godot_string_num",
+ "return_type": "godot_string",
"arguments": [
- ["godot_plane *", "r_dest"],
- ["const godot_vector3 *", "p_v1"],
- ["const godot_vector3 *", "p_v2"],
- ["const godot_vector3 *", "p_v3"]
+ ["double", "p_num"]
]
},
{
- "name": "godot_plane_new_with_normal",
- "return_type": "void",
+ "name": "godot_string_num_int64",
+ "return_type": "godot_string",
"arguments": [
- ["godot_plane *", "r_dest"],
- ["const godot_vector3 *", "p_normal"],
- ["const godot_real", "p_d"]
+ ["int64_t", "p_num"],
+ ["godot_int", "p_base"]
]
},
{
- "name": "godot_plane_as_string",
+ "name": "godot_string_num_int64_capitalized",
"return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["int64_t", "p_num"],
+ ["godot_int", "p_base"],
+ ["godot_bool", "p_capitalize_hex"]
]
},
{
- "name": "godot_plane_normalized",
- "return_type": "godot_plane",
+ "name": "godot_string_num_real",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["double", "p_num"]
]
},
{
- "name": "godot_plane_center",
- "return_type": "godot_vector3",
+ "name": "godot_string_num_scientific",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["double", "p_num"]
]
},
{
- "name": "godot_plane_get_any_point",
- "return_type": "godot_vector3",
+ "name": "godot_string_num_with_decimals",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["double", "p_num"],
+ ["godot_int", "p_decimals"]
]
},
{
- "name": "godot_plane_is_point_over",
- "return_type": "godot_bool",
+ "name": "godot_string_pad_decimals",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["const godot_vector3 *", "p_point"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_digits"]
]
},
{
- "name": "godot_plane_distance_to",
- "return_type": "godot_real",
+ "name": "godot_string_pad_zeros",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["const godot_vector3 *", "p_point"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_digits"]
]
},
{
- "name": "godot_plane_has_point",
- "return_type": "godot_bool",
+ "name": "godot_string_replace_first",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["const godot_vector3 *", "p_point"],
- ["const godot_real", "p_epsilon"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_key"],
+ ["godot_string", "p_with"]
]
},
{
- "name": "godot_plane_project",
- "return_type": "godot_vector3",
+ "name": "godot_string_replace",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["const godot_vector3 *", "p_point"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_key"],
+ ["godot_string", "p_with"]
]
},
{
- "name": "godot_plane_intersect_3",
- "return_type": "godot_bool",
+ "name": "godot_string_replacen",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["godot_vector3 *", "r_dest"],
- ["const godot_plane *", "p_b"],
- ["const godot_plane *", "p_c"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_key"],
+ ["godot_string", "p_with"]
]
},
{
- "name": "godot_plane_intersects_ray",
- "return_type": "godot_bool",
+ "name": "godot_string_rfind",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["godot_vector3 *", "r_dest"],
- ["const godot_vector3 *", "p_from"],
- ["const godot_vector3 *", "p_dir"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"]
]
},
{
- "name": "godot_plane_intersects_segment",
- "return_type": "godot_bool",
+ "name": "godot_string_rfindn",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["godot_vector3 *", "r_dest"],
- ["const godot_vector3 *", "p_begin"],
- ["const godot_vector3 *", "p_end"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"]
]
},
{
- "name": "godot_plane_operator_neg",
- "return_type": "godot_plane",
+ "name": "godot_string_rfind_from",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"]
]
},
{
- "name": "godot_plane_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_string_rfindn_from",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_plane *", "p_self"],
- ["const godot_plane *", "p_b"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_what"],
+ ["godot_int", "p_from"]
]
},
{
- "name": "godot_plane_set_normal",
- "return_type": "void",
+ "name": "godot_string_rpad",
+ "return_type": "godot_string",
"arguments": [
- ["godot_plane *", "p_self"],
- ["const godot_vector3 *", "p_normal"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_min_length"]
]
},
{
- "name": "godot_plane_get_normal",
- "return_type": "godot_vector3",
+ "name": "godot_string_rpad_with_custom_character",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_min_length"],
+ ["const godot_string *", "p_character"]
]
},
{
- "name": "godot_plane_get_d",
+ "name": "godot_string_similarity",
"return_type": "godot_real",
"arguments": [
- ["const godot_plane *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_string"]
]
},
{
- "name": "godot_plane_set_d",
- "return_type": "void",
+ "name": "godot_string_sprintf",
+ "return_type": "godot_string",
"arguments": [
- ["godot_plane *", "p_self"],
- ["const godot_real", "p_d"]
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_values"],
+ ["godot_bool *", "p_error"]
]
},
{
- "name": "godot_rect2_new_with_position_and_size",
- "return_type": "void",
+ "name": "godot_string_substr",
+ "return_type": "godot_string",
"arguments": [
- ["godot_rect2 *", "r_dest"],
- ["const godot_vector2 *", "p_pos"],
- ["const godot_vector2 *", "p_size"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_from"],
+ ["godot_int", "p_chars"]
]
},
{
- "name": "godot_rect2_new",
- "return_type": "void",
+ "name": "godot_string_to_double",
+ "return_type": "double",
"arguments": [
- ["godot_rect2 *", "r_dest"],
- ["const godot_real", "p_x"],
- ["const godot_real", "p_y"],
- ["const godot_real", "p_width"],
- ["const godot_real", "p_height"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_as_string",
+ "name": "godot_string_to_float",
+ "return_type": "godot_real",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_to_int",
+ "return_type": "godot_int",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_camelcase_to_underscore",
"return_type": "godot_string",
"arguments": [
- ["const godot_rect2 *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_get_area",
- "return_type": "godot_real",
+ "name": "godot_string_camelcase_to_underscore_lowercased",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_rect2 *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_intersects",
- "return_type": "godot_bool",
+ "name": "godot_string_capitalize",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_rect2 *", "p_b"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_encloses",
- "return_type": "godot_bool",
+ "name": "godot_string_char_to_double",
+ "return_type": "double",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_rect2 *", "p_b"]
+ ["const char *", "p_what"]
]
},
{
- "name": "godot_rect2_has_no_area",
- "return_type": "godot_bool",
+ "name": "godot_string_char_to_int",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_rect2 *", "p_self"]
+ ["const char *", "p_what"]
]
},
{
- "name": "godot_rect2_clip",
- "return_type": "godot_rect2",
+ "name": "godot_string_wchar_to_int",
+ "return_type": "int64_t",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_rect2 *", "p_b"]
+ ["const wchar_t *", "p_str"]
]
},
{
- "name": "godot_rect2_merge",
- "return_type": "godot_rect2",
+ "name": "godot_string_char_to_int_with_len",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_rect2 *", "p_b"]
+ ["const char *", "p_what"],
+ ["godot_int", "p_len"]
]
},
{
- "name": "godot_rect2_has_point",
- "return_type": "godot_bool",
+ "name": "godot_string_char_to_int64_with_len",
+ "return_type": "int64_t",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_vector2 *", "p_point"]
+ ["const wchar_t *", "p_str"],
+ ["int", "p_len"]
]
},
{
- "name": "godot_rect2_grow",
- "return_type": "godot_rect2",
+ "name": "godot_string_hex_to_int64",
+ "return_type": "int64_t",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_real", "p_by"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_expand",
- "return_type": "godot_rect2",
+ "name": "godot_string_hex_to_int64_with_prefix",
+ "return_type": "int64_t",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_vector2 *", "p_to"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_string_to_int64",
+ "return_type": "int64_t",
"arguments": [
- ["const godot_rect2 *", "p_self"],
- ["const godot_rect2 *", "p_b"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rect2_get_position",
- "return_type": "godot_vector2",
+ "name": "godot_string_unicode_char_to_double",
+ "return_type": "double",
"arguments": [
- ["const godot_rect2 *", "p_self"]
+ ["const wchar_t *", "p_str"],
+ ["const wchar_t **", "r_end"]
]
},
{
- "name": "godot_rect2_get_size",
- "return_type": "godot_vector2",
+ "name": "godot_string_get_slice_count",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_rect2 *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_splitter"]
]
},
{
- "name": "godot_rect2_set_position",
- "return_type": "void",
+ "name": "godot_string_get_slice",
+ "return_type": "godot_string",
"arguments": [
- ["godot_rect2 *", "p_self"],
- ["const godot_vector2 *", "p_pos"]
+ ["const godot_string *", "p_self"],
+ ["godot_string", "p_splitter"],
+ ["godot_int", "p_slice"]
]
},
{
- "name": "godot_rect2_set_size",
- "return_type": "void",
+ "name": "godot_string_get_slicec",
+ "return_type": "godot_string",
"arguments": [
- ["godot_rect2 *", "p_self"],
- ["const godot_vector2 *", "p_size"]
+ ["const godot_string *", "p_self"],
+ ["wchar_t", "p_splitter"],
+ ["godot_int", "p_slice"]
]
},
{
- "name": "godot_aabb_new",
- "return_type": "void",
+ "name": "godot_string_split",
+ "return_type": "godot_array",
"arguments": [
- ["godot_aabb *", "r_dest"],
- ["const godot_vector3 *", "p_pos"],
- ["const godot_vector3 *", "p_size"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_splitter"]
]
},
{
- "name": "godot_aabb_get_position",
- "return_type": "godot_vector3",
+ "name": "godot_string_split_allow_empty",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_splitter"]
]
},
{
- "name": "godot_aabb_set_position",
- "return_type": "void",
+ "name": "godot_string_split_floats",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_vector3 *", "p_v"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_splitter"]
]
},
{
- "name": "godot_aabb_get_size",
- "return_type": "godot_vector3",
+ "name": "godot_string_split_floats_allows_empty",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_splitter"]
]
},
{
- "name": "godot_aabb_set_size",
- "return_type": "void",
+ "name": "godot_string_split_floats_mk",
+ "return_type": "godot_array",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_vector3 *", "p_v"]
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_splitters"]
]
},
{
- "name": "godot_aabb_as_string",
+ "name": "godot_string_split_floats_mk_allows_empty",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_splitters"]
+ ]
+ },
+ {
+ "name": "godot_string_split_ints",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_splitter"]
+ ]
+ },
+ {
+ "name": "godot_string_split_ints_allows_empty",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_splitter"]
+ ]
+ },
+ {
+ "name": "godot_string_split_ints_mk",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_splitters"]
+ ]
+ },
+ {
+ "name": "godot_string_split_ints_mk_allows_empty",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_array *", "p_splitters"]
+ ]
+ },
+ {
+ "name": "godot_string_split_spaces",
+ "return_type": "godot_array",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_rstrip",
"return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_chars"]
]
},
{
- "name": "godot_aabb_get_area",
- "return_type": "godot_real",
+ "name": "godot_string_rsplit",
+ "return_type": "godot_packed_string_array",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_divisor"],
+ ["const godot_bool", "p_allow_empty"],
+ ["const godot_int", "p_maxsplit"]
]
},
{
- "name": "godot_aabb_has_no_area",
- "return_type": "godot_bool",
+ "name": "godot_string_trim_prefix",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_prefix"]
]
},
{
- "name": "godot_aabb_has_no_surface",
+ "name": "godot_string_trim_suffix",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_suffix"]
+ ]
+ },
+ {
+ "name": "godot_string_char_lowercase",
+ "return_type": "wchar_t",
+ "arguments": [
+ ["wchar_t", "p_char"]
+ ]
+ },
+ {
+ "name": "godot_string_char_uppercase",
+ "return_type": "wchar_t",
+ "arguments": [
+ ["wchar_t", "p_char"]
+ ]
+ },
+ {
+ "name": "godot_string_to_lower",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_to_upper",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_get_basename",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_get_extension",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_left",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_pos"]
+ ]
+ },
+ {
+ "name": "godot_string_ord_at",
+ "return_type": "wchar_t",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_string_plus_file",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_file"]
+ ]
+ },
+ {
+ "name": "godot_string_right",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_pos"]
+ ]
+ },
+ {
+ "name": "godot_string_strip_edges",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_bool", "p_left"],
+ ["godot_bool", "p_right"]
+ ]
+ },
+ {
+ "name": "godot_string_strip_escapes",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_erase",
+ "return_type": "void",
+ "arguments": [
+ ["godot_string *", "p_self"],
+ ["godot_int", "p_pos"],
+ ["godot_int", "p_chars"]
+ ]
+ },
+ {
+ "name": "godot_string_ascii",
+ "return_type": "godot_char_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_ascii_extended",
+ "return_type": "godot_char_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_utf8",
+ "return_type": "godot_char_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_parse_utf8",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["godot_string *", "p_self"],
+ ["const char *", "p_utf8"]
]
},
{
- "name": "godot_aabb_intersects",
+ "name": "godot_string_parse_utf8_with_len",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_aabb *", "p_with"]
+ ["godot_string *", "p_self"],
+ ["const char *", "p_utf8"],
+ ["godot_int", "p_len"]
]
},
{
- "name": "godot_aabb_encloses",
+ "name": "godot_string_chars_to_utf8",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const char *", "p_utf8"]
+ ]
+ },
+ {
+ "name": "godot_string_chars_to_utf8_with_len",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const char *", "p_utf8"],
+ ["godot_int", "p_len"]
+ ]
+ },
+ {
+ "name": "godot_string_hash",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_hash64",
+ "return_type": "uint64_t",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_hash_chars",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const char *", "p_cstr"]
+ ]
+ },
+ {
+ "name": "godot_string_hash_chars_with_len",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const char *", "p_cstr"],
+ ["godot_int", "p_len"]
+ ]
+ },
+ {
+ "name": "godot_string_hash_utf8_chars",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const wchar_t *", "p_str"]
+ ]
+ },
+ {
+ "name": "godot_string_hash_utf8_chars_with_len",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const wchar_t *", "p_str"],
+ ["godot_int", "p_len"]
+ ]
+ },
+ {
+ "name": "godot_string_md5_buffer",
+ "return_type": "godot_packed_byte_array",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_md5_text",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_sha256_buffer",
+ "return_type": "godot_packed_byte_array",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_sha256_text",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_aabb *", "p_with"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_merge",
- "return_type": "godot_aabb",
+ "name": "godot_string_get_base_dir",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_aabb *", "p_with"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_intersection",
- "return_type": "godot_aabb",
+ "name": "godot_string_get_file",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_aabb *", "p_with"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_intersects_plane",
+ "name": "godot_string_humanize_size",
+ "return_type": "godot_string",
+ "arguments": [
+ ["size_t", "p_size"]
+ ]
+ },
+ {
+ "name": "godot_string_is_abs_path",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_plane *", "p_plane"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_intersects_segment",
+ "name": "godot_string_is_rel_path",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_vector3 *", "p_from"],
- ["const godot_vector3 *", "p_to"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_has_point",
+ "name": "godot_string_is_resource_file",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_vector3 *", "p_point"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_get_support",
- "return_type": "godot_vector3",
+ "name": "godot_string_path_to",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_vector3 *", "p_dir"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_path"]
]
},
{
- "name": "godot_aabb_get_longest_axis",
- "return_type": "godot_vector3",
+ "name": "godot_string_path_to_file",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"],
+ ["const godot_string *", "p_path"]
]
},
{
- "name": "godot_aabb_get_longest_axis_index",
- "return_type": "godot_int",
+ "name": "godot_string_simplify_path",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_get_longest_axis_size",
- "return_type": "godot_real",
+ "name": "godot_string_c_escape",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_get_shortest_axis",
- "return_type": "godot_vector3",
+ "name": "godot_string_c_escape_multiline",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_get_shortest_axis_index",
- "return_type": "godot_int",
+ "name": "godot_string_c_unescape",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_get_shortest_axis_size",
- "return_type": "godot_real",
+ "name": "godot_string_http_escape",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_expand",
- "return_type": "godot_aabb",
+ "name": "godot_string_http_unescape",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_vector3 *", "p_to_point"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_grow",
- "return_type": "godot_aabb",
+ "name": "godot_string_json_escape",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_real", "p_by"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_aabb_get_endpoint",
- "return_type": "godot_vector3",
+ "name": "godot_string_word_wrap",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_string *", "p_self"],
+ ["godot_int", "p_chars_per_line"]
]
},
{
- "name": "godot_aabb_operator_equal",
+ "name": "godot_string_xml_escape",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_xml_escape_with_quotes",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_xml_unescape",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_percent_decode",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_percent_encode",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_is_valid_float",
"return_type": "godot_bool",
"arguments": [
- ["const godot_aabb *", "p_self"],
- ["const godot_aabb *", "p_b"]
+ ["const godot_string *", "p_self"]
]
},
{
- "name": "godot_rid_new",
+ "name": "godot_string_is_valid_hex_number",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"],
+ ["godot_bool", "p_with_prefix"]
+ ]
+ },
+ {
+ "name": "godot_string_is_valid_html_color",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_is_valid_identifier",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_is_valid_integer",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_is_valid_ip_address",
+ "return_type": "godot_bool",
+ "arguments": [
+ ["const godot_string *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_destroy",
"return_type": "void",
"arguments": [
- ["godot_rid *", "r_dest"]
+ ["godot_string *", "p_self"]
]
},
{
- "name": "godot_rid_get_id",
- "return_type": "godot_int",
+ "name": "godot_string_name_new",
+ "return_type": "void",
"arguments": [
- ["const godot_rid *", "p_self"]
+ ["godot_string_name *", "r_dest"],
+ ["const godot_string *", "p_name"]
]
},
{
- "name": "godot_rid_new_with_resource",
+ "name": "godot_string_name_new_data",
"return_type": "void",
"arguments": [
- ["godot_rid *", "r_dest"],
- ["const godot_object *", "p_from"]
+ ["godot_string_name *", "r_dest"],
+ ["const char *", "p_name"]
]
},
{
- "name": "godot_rid_operator_equal",
+ "name": "godot_string_name_get_name",
+ "return_type": "godot_string",
+ "arguments": [
+ ["const godot_string_name *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_name_get_hash",
+ "return_type": "uint32_t",
+ "arguments": [
+ ["const godot_string_name *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_name_get_data_unique_pointer",
+ "return_type": "const void *",
+ "arguments": [
+ ["const godot_string_name *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_string_name_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rid *", "p_self"],
- ["const godot_rid *", "p_b"]
+ ["const godot_string_name *", "p_self"],
+ ["const godot_string_name *", "p_other"]
]
},
{
- "name": "godot_rid_operator_less",
+ "name": "godot_string_name_operator_less",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rid *", "p_self"],
- ["const godot_rid *", "p_b"]
+ ["const godot_string_name *", "p_self"],
+ ["const godot_string_name *", "p_other"]
+ ]
+ },
+ {
+ "name": "godot_string_name_destroy",
+ "return_type": "void",
+ "arguments": [
+ ["godot_string_name *", "p_self"]
]
},
{
@@ -3525,6 +4867,14 @@
]
},
{
+ "name": "godot_transform_new_with_quat",
+ "return_type": "void",
+ "arguments": [
+ ["godot_transform *", "r_dest"],
+ ["const godot_quat *", "p_quat"]
+ ]
+ },
+ {
"name": "godot_transform_new",
"return_type": "void",
"arguments": [
@@ -3931,6 +5281,14 @@
]
},
{
+ "name": "godot_variant_new_string_name",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_string_name *", "p_s"]
+ ]
+ },
+ {
"name": "godot_variant_new_vector2",
"return_type": "void",
"arguments": [
@@ -3939,6 +5297,14 @@
]
},
{
+ "name": "godot_variant_new_vector2i",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_vector2i *", "p_v2"]
+ ]
+ },
+ {
"name": "godot_variant_new_rect2",
"return_type": "void",
"arguments": [
@@ -3947,6 +5313,14 @@
]
},
{
+ "name": "godot_variant_new_rect2i",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_rect2i *", "p_rect2"]
+ ]
+ },
+ {
"name": "godot_variant_new_vector3",
"return_type": "void",
"arguments": [
@@ -3955,6 +5329,14 @@
]
},
{
+ "name": "godot_variant_new_vector3i",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_vector3i *", "p_v3"]
+ ]
+ },
+ {
"name": "godot_variant_new_transform2d",
"return_type": "void",
"arguments": [
@@ -4035,6 +5417,22 @@
]
},
{
+ "name": "godot_variant_new_callable",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_callable *", "p_cb"]
+ ]
+ },
+ {
+ "name": "godot_variant_new_signal",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_signal *", "p_signal"]
+ ]
+ },
+ {
"name": "godot_variant_new_dictionary",
"return_type": "void",
"arguments": [
@@ -4059,19 +5457,35 @@
]
},
{
- "name": "godot_variant_new_packed_int_array",
+ "name": "godot_variant_new_packed_int32_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_packed_int_array *", "p_pia"]
+ ["const godot_packed_int32_array *", "p_pia"]
]
},
{
- "name": "godot_variant_new_packed_real_array",
+ "name": "godot_variant_new_packed_int64_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_packed_real_array *", "p_pra"]
+ ["const godot_packed_int64_array *", "p_pia"]
+ ]
+ },
+ {
+ "name": "godot_variant_new_packed_float32_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_packed_float32_array *", "p_pra"]
+ ]
+ },
+ {
+ "name": "godot_variant_new_packed_float64_array",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant *", "r_dest"],
+ ["const godot_packed_float64_array *", "p_pra"]
]
},
{
@@ -4142,6 +5556,13 @@
]
},
{
+ "name": "godot_variant_as_string_name",
+ "return_type": "godot_string_name",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
"name": "godot_variant_as_vector2",
"return_type": "godot_vector2",
"arguments": [
@@ -4149,6 +5570,13 @@
]
},
{
+ "name": "godot_variant_as_vector2i",
+ "return_type": "godot_vector2i",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
"name": "godot_variant_as_rect2",
"return_type": "godot_rect2",
"arguments": [
@@ -4156,6 +5584,13 @@
]
},
{
+ "name": "godot_variant_as_rect2i",
+ "return_type": "godot_rect2i",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
"name": "godot_variant_as_vector3",
"return_type": "godot_vector3",
"arguments": [
@@ -4163,6 +5598,13 @@
]
},
{
+ "name": "godot_variant_as_vector3i",
+ "return_type": "godot_vector3i",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
"name": "godot_variant_as_transform2d",
"return_type": "godot_transform2d",
"arguments": [
@@ -4233,6 +5675,20 @@
]
},
{
+ "name": "godot_variant_as_callable",
+ "return_type": "godot_callable",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_variant_as_signal",
+ "return_type": "godot_signal",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
"name": "godot_variant_as_dictionary",
"return_type": "godot_dictionary",
"arguments": [
@@ -4254,15 +5710,29 @@
]
},
{
- "name": "godot_variant_as_packed_int_array",
- "return_type": "godot_packed_int_array",
+ "name": "godot_variant_as_packed_int32_array",
+ "return_type": "godot_packed_int32_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_packed_real_array",
- "return_type": "godot_packed_real_array",
+ "name": "godot_variant_as_packed_int64_array",
+ "return_type": "godot_packed_int64_array",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_variant_as_packed_float32_array",
+ "return_type": "godot_packed_float32_array",
+ "arguments": [
+ ["const godot_variant *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_variant_as_packed_float64_array",
+ "return_type": "godot_packed_float64_array",
"arguments": [
["const godot_variant *", "p_self"]
]
@@ -4315,15 +5785,14 @@
]
},
{
- "name": "godot_variant_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_variant_hash",
+ "return_type": "uint32_t",
"arguments": [
- ["const godot_variant *", "p_self"],
- ["const godot_variant *", "p_other"]
+ ["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_operator_less",
+ "name": "godot_variant_operator_equal",
"return_type": "godot_bool",
"arguments": [
["const godot_variant *", "p_self"],
@@ -4331,7 +5800,7 @@
]
},
{
- "name": "godot_variant_hash_compare",
+ "name": "godot_variant_operator_less",
"return_type": "godot_bool",
"arguments": [
["const godot_variant *", "p_self"],
@@ -4339,1236 +5808,1005 @@
]
},
{
- "name": "godot_variant_booleanize",
- "return_type": "godot_bool",
- "arguments": [
- ["const godot_variant *", "p_self"]
- ]
- },
- {
- "name": "godot_variant_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_variant *", "p_self"]
- ]
- },
- {
- "name": "godot_char_string_length",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_char_string *", "p_cs"]
- ]
- },
- {
- "name": "godot_char_string_get_data",
- "return_type": "const char *",
+ "name": "godot_variant_get_operator_name",
+ "return_type": "godot_string",
"arguments": [
- ["const godot_char_string *", "p_cs"]
+ ["godot_variant_operator", "p_op"]
]
},
{
- "name": "godot_char_string_destroy",
+ "name": "godot_variant_evaluate",
"return_type": "void",
"arguments": [
- ["godot_char_string *", "p_cs"]
+ ["godot_variant_operator", "p_op"],
+ ["const godot_variant *", "p_a"],
+ ["const godot_variant *", "p_b"],
+ ["godot_variant *", "r_ret"],
+ ["godot_bool *", "r_valid"]
]
},
{
- "name": "godot_string_new",
- "return_type": "void",
+ "name": "godot_variant_hash_compare",
+ "return_type": "godot_bool",
"arguments": [
- ["godot_string *", "r_dest"]
+ ["const godot_variant *", "p_self"],
+ ["const godot_variant *", "p_other"]
]
},
{
- "name": "godot_string_new_copy",
- "return_type": "void",
+ "name": "godot_variant_booleanize",
+ "return_type": "godot_bool",
"arguments": [
- ["godot_string *", "r_dest"],
- ["const godot_string *", "p_src"]
+ ["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_string_new_with_wide_string",
+ "name": "godot_variant_destroy",
"return_type": "void",
"arguments": [
- ["godot_string *", "r_dest"],
- ["const wchar_t *", "p_contents"],
- ["const int", "p_size"]
+ ["godot_variant *", "p_self"]
]
},
{
- "name": "godot_string_operator_index",
- "return_type": "const wchar_t *",
+ "name": "godot_vector2_as_vector2i",
+ "return_type": "godot_vector2i",
"arguments": [
- ["godot_string *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_operator_index_const",
- "return_type": "wchar_t",
+ "name": "godot_vector2_sign",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_int", "p_idx"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_wide_str",
- "return_type": "const wchar_t *",
+ "name": "godot_vector2_move_toward",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"],
+ ["const godot_real", "p_delta"]
]
},
{
- "name": "godot_string_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_vector2_direction_to",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_b"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
]
},
{
- "name": "godot_string_operator_less",
- "return_type": "godot_bool",
+ "name": "godot_vector2_new",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_b"]
+ ["godot_vector2 *", "r_dest"],
+ ["const godot_real", "p_x"],
+ ["const godot_real", "p_y"]
]
},
{
- "name": "godot_string_operator_plus",
+ "name": "godot_vector2_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_b"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_length",
- "return_type": "godot_int",
+ "name": "godot_vector2_normalized",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_casecmp_to",
- "return_type": "signed char",
+ "name": "godot_vector2_length",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_str"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_nocasecmp_to",
- "return_type": "signed char",
+ "name": "godot_vector2_angle",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_str"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_naturalnocasecmp_to",
- "return_type": "signed char",
+ "name": "godot_vector2_length_squared",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_str"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_begins_with",
+ "name": "godot_vector2_is_normalized",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_string"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_begins_with_char_array",
- "return_type": "godot_bool",
+ "name": "godot_vector2_distance_to",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const char *", "p_char_array"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
]
},
{
- "name": "godot_string_bigrams",
- "return_type": "godot_array",
+ "name": "godot_vector2_distance_squared_to",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
]
},
{
- "name": "godot_string_chr",
- "return_type": "godot_string",
+ "name": "godot_vector2_angle_to",
+ "return_type": "godot_real",
"arguments": [
- ["wchar_t", "p_character"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
]
},
{
- "name": "godot_string_ends_with",
- "return_type": "godot_bool",
+ "name": "godot_vector2_angle_to_point",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_string"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_to"]
]
},
{
- "name": "godot_string_find",
- "return_type": "godot_int",
+ "name": "godot_vector2_lerp",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_string_find_from",
- "return_type": "godot_int",
+ "name": "godot_vector2_cubic_interpolate",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"],
- ["godot_int", "p_from"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"],
+ ["const godot_vector2 *", "p_pre_a"],
+ ["const godot_vector2 *", "p_post_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_string_findmk",
- "return_type": "godot_int",
+ "name": "godot_vector2_rotated",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_keys"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_real", "p_phi"]
]
},
{
- "name": "godot_string_findmk_from",
- "return_type": "godot_int",
+ "name": "godot_vector2_tangent",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_keys"],
- ["godot_int", "p_from"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_findmk_from_in_place",
- "return_type": "godot_int",
+ "name": "godot_vector2_floor",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_keys"],
- ["godot_int", "p_from"],
- ["godot_int *", "r_key"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_findn",
- "return_type": "godot_int",
+ "name": "godot_vector2_snapped",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_by"]
]
},
{
- "name": "godot_string_findn_from",
- "return_type": "godot_int",
+ "name": "godot_vector2_aspect",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"],
- ["godot_int", "p_from"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_find_last",
- "return_type": "godot_int",
+ "name": "godot_vector2_dot",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_with"]
]
},
{
- "name": "godot_string_format",
- "return_type": "godot_string",
+ "name": "godot_vector2_slide",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_variant *", "p_values"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_n"]
]
},
{
- "name": "godot_string_format_with_custom_placeholder",
- "return_type": "godot_string",
+ "name": "godot_vector2_bounce",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_variant *", "p_values"],
- ["const char *", "p_placeholder"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_n"]
]
},
{
- "name": "godot_string_hex_encode_buffer",
- "return_type": "godot_string",
+ "name": "godot_vector2_reflect",
+ "return_type": "godot_vector2",
"arguments": [
- ["const uint8_t *", "p_buffer"],
- ["godot_int", "p_len"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_n"]
]
},
{
- "name": "godot_string_hex_to_int",
- "return_type": "godot_int",
+ "name": "godot_vector2_abs",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_hex_to_int_without_prefix",
- "return_type": "godot_int",
+ "name": "godot_vector2_clamped",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_real", "p_length"]
]
},
{
- "name": "godot_string_insert",
- "return_type": "godot_string",
+ "name": "godot_vector2_operator_add",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_at_pos"],
- ["godot_string", "p_string"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"]
]
},
{
- "name": "godot_string_is_numeric",
- "return_type": "godot_bool",
+ "name": "godot_vector2_operator_subtract",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"]
]
},
{
- "name": "godot_string_is_subsequence_of",
- "return_type": "godot_bool",
+ "name": "godot_vector2_operator_multiply_vector",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_string"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"]
]
},
{
- "name": "godot_string_is_subsequence_ofi",
- "return_type": "godot_bool",
+ "name": "godot_vector2_operator_multiply_scalar",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_string"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_real", "p_b"]
]
},
{
- "name": "godot_string_lpad",
- "return_type": "godot_string",
+ "name": "godot_vector2_operator_divide_vector",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_min_length"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"]
]
},
{
- "name": "godot_string_lpad_with_custom_character",
- "return_type": "godot_string",
+ "name": "godot_vector2_operator_divide_scalar",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_min_length"],
- ["const godot_string *", "p_character"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_real", "p_b"]
]
},
{
- "name": "godot_string_match",
+ "name": "godot_vector2_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_wildcard"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"]
]
},
{
- "name": "godot_string_matchn",
+ "name": "godot_vector2_operator_less",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_wildcard"]
- ]
- },
- {
- "name": "godot_string_md5",
- "return_type": "godot_string",
- "arguments": [
- ["const uint8_t *", "p_md5"]
- ]
- },
- {
- "name": "godot_string_num",
- "return_type": "godot_string",
- "arguments": [
- ["double", "p_num"]
- ]
- },
- {
- "name": "godot_string_num_int64",
- "return_type": "godot_string",
- "arguments": [
- ["int64_t", "p_num"],
- ["godot_int", "p_base"]
- ]
- },
- {
- "name": "godot_string_num_int64_capitalized",
- "return_type": "godot_string",
- "arguments": [
- ["int64_t", "p_num"],
- ["godot_int", "p_base"],
- ["godot_bool", "p_capitalize_hex"]
- ]
- },
- {
- "name": "godot_string_num_real",
- "return_type": "godot_string",
- "arguments": [
- ["double", "p_num"]
- ]
- },
- {
- "name": "godot_string_num_scientific",
- "return_type": "godot_string",
- "arguments": [
- ["double", "p_num"]
- ]
- },
- {
- "name": "godot_string_num_with_decimals",
- "return_type": "godot_string",
- "arguments": [
- ["double", "p_num"],
- ["godot_int", "p_decimals"]
- ]
- },
- {
- "name": "godot_string_pad_decimals",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_digits"]
- ]
- },
- {
- "name": "godot_string_pad_zeros",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_digits"]
- ]
- },
- {
- "name": "godot_string_replace_first",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_key"],
- ["godot_string", "p_with"]
- ]
- },
- {
- "name": "godot_string_replace",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_key"],
- ["godot_string", "p_with"]
- ]
- },
- {
- "name": "godot_string_replacen",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_key"],
- ["godot_string", "p_with"]
- ]
- },
- {
- "name": "godot_string_rfind",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"]
- ]
- },
- {
- "name": "godot_string_rfindn",
- "return_type": "godot_int",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"]
+ ["const godot_vector2 *", "p_self"],
+ ["const godot_vector2 *", "p_b"]
]
},
{
- "name": "godot_string_rfind_from",
- "return_type": "godot_int",
+ "name": "godot_vector2_operator_neg",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"],
- ["godot_int", "p_from"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_rfindn_from",
- "return_type": "godot_int",
+ "name": "godot_vector2_set_x",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_what"],
- ["godot_int", "p_from"]
+ ["godot_vector2 *", "p_self"],
+ ["const godot_real", "p_x"]
]
},
{
- "name": "godot_string_rpad",
- "return_type": "godot_string",
+ "name": "godot_vector2_set_y",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_min_length"]
+ ["godot_vector2 *", "p_self"],
+ ["const godot_real", "p_y"]
]
},
{
- "name": "godot_string_rpad_with_custom_character",
- "return_type": "godot_string",
+ "name": "godot_vector2_get_x",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_min_length"],
- ["const godot_string *", "p_character"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_similarity",
+ "name": "godot_vector2_get_y",
"return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_string"]
+ ["const godot_vector2 *", "p_self"]
]
},
{
- "name": "godot_string_sprintf",
- "return_type": "godot_string",
+ "name": "godot_vector2i_new",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_values"],
- ["godot_bool *", "p_error"]
+ ["godot_vector2i *", "r_dest"],
+ ["const godot_int", "p_x"],
+ ["const godot_int", "p_y"]
]
},
{
- "name": "godot_string_substr",
+ "name": "godot_vector2i_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_from"],
- ["godot_int", "p_chars"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_to_double",
- "return_type": "double",
+ "name": "godot_vector2i_as_vector2",
+ "return_type": "godot_vector2",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_to_float",
+ "name": "godot_vector2i_aspect",
"return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_to_int",
- "return_type": "godot_int",
+ "name": "godot_vector2i_abs",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_camelcase_to_underscore",
- "return_type": "godot_string",
+ "name": "godot_vector2i_sign",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_camelcase_to_underscore_lowercased",
- "return_type": "godot_string",
+ "name": "godot_vector2i_operator_add",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_vector2i *", "p_b"]
]
},
{
- "name": "godot_string_capitalize",
- "return_type": "godot_string",
+ "name": "godot_vector2i_operator_subtract",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_vector2i *", "p_b"]
]
},
{
- "name": "godot_string_char_to_double",
- "return_type": "double",
+ "name": "godot_vector2i_operator_multiply_vector",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const char *", "p_what"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_vector2i *", "p_b"]
]
},
{
- "name": "godot_string_char_to_int",
- "return_type": "godot_int",
+ "name": "godot_vector2i_operator_multiply_scalar",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const char *", "p_what"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_int", "p_b"]
]
},
{
- "name": "godot_string_wchar_to_int",
- "return_type": "int64_t",
+ "name": "godot_vector2i_operator_divide_vector",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const wchar_t *", "p_str"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_vector2i *", "p_b"]
]
},
{
- "name": "godot_string_char_to_int_with_len",
- "return_type": "godot_int",
+ "name": "godot_vector2i_operator_divide_scalar",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const char *", "p_what"],
- ["godot_int", "p_len"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_int", "p_b"]
]
},
{
- "name": "godot_string_char_to_int64_with_len",
- "return_type": "int64_t",
+ "name": "godot_vector2i_operator_equal",
+ "return_type": "godot_bool",
"arguments": [
- ["const wchar_t *", "p_str"],
- ["int", "p_len"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_vector2i *", "p_b"]
]
},
{
- "name": "godot_string_hex_to_int64",
- "return_type": "int64_t",
+ "name": "godot_vector2i_operator_less",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"],
+ ["const godot_vector2i *", "p_b"]
]
},
{
- "name": "godot_string_hex_to_int64_with_prefix",
- "return_type": "int64_t",
+ "name": "godot_vector2i_operator_neg",
+ "return_type": "godot_vector2i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_to_int64",
- "return_type": "int64_t",
+ "name": "godot_vector2i_set_x",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["godot_vector2i *", "p_self"],
+ ["const godot_int", "p_x"]
]
},
{
- "name": "godot_string_unicode_char_to_double",
- "return_type": "double",
+ "name": "godot_vector2i_set_y",
+ "return_type": "void",
"arguments": [
- ["const wchar_t *", "p_str"],
- ["const wchar_t **", "r_end"]
+ ["godot_vector2i *", "p_self"],
+ ["const godot_int", "p_y"]
]
},
{
- "name": "godot_string_get_slice_count",
+ "name": "godot_vector2i_get_x",
"return_type": "godot_int",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_get_slice",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["godot_string", "p_splitter"],
- ["godot_int", "p_slice"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_get_slicec",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["wchar_t", "p_splitter"],
- ["godot_int", "p_slice"]
- ]
- },
- {
- "name": "godot_string_split",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_split_allow_empty",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_split_floats",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_split_floats_allows_empty",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_split_floats_mk",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_splitters"]
- ]
- },
- {
- "name": "godot_string_split_floats_mk_allows_empty",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_splitters"]
- ]
- },
- {
- "name": "godot_string_split_ints",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_split_ints_allows_empty",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_splitter"]
- ]
- },
- {
- "name": "godot_string_split_ints_mk",
- "return_type": "godot_array",
+ "name": "godot_vector2i_get_y",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_splitters"]
+ ["const godot_vector2i *", "p_self"]
]
},
{
- "name": "godot_string_split_ints_mk_allows_empty",
- "return_type": "godot_array",
+ "name": "godot_vector3_as_vector3i",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_array *", "p_splitters"]
- ]
- },
- {
- "name": "godot_string_split_spaces",
- "return_type": "godot_array",
- "arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_char_lowercase",
- "return_type": "wchar_t",
+ "name": "godot_vector3_sign",
+ "return_type": "godot_vector3",
"arguments": [
- ["wchar_t", "p_char"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_char_uppercase",
- "return_type": "wchar_t",
+ "name": "godot_vector3_move_toward",
+ "return_type": "godot_vector3",
"arguments": [
- ["wchar_t", "p_char"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_to"],
+ ["const godot_real", "p_delta"]
]
},
{
- "name": "godot_string_to_lower",
- "return_type": "godot_string",
+ "name": "godot_vector3_direction_to",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_to"]
]
},
{
- "name": "godot_string_to_upper",
- "return_type": "godot_string",
+ "name": "godot_vector3_new",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["godot_vector3 *", "r_dest"],
+ ["const godot_real", "p_x"],
+ ["const godot_real", "p_y"],
+ ["const godot_real", "p_z"]
]
},
{
- "name": "godot_string_get_basename",
+ "name": "godot_vector3_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_get_extension",
- "return_type": "godot_string",
+ "name": "godot_vector3_min_axis",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_left",
- "return_type": "godot_string",
+ "name": "godot_vector3_max_axis",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_pos"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_ord_at",
- "return_type": "wchar_t",
+ "name": "godot_vector3_length",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_idx"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_plus_file",
- "return_type": "godot_string",
+ "name": "godot_vector3_length_squared",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_file"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_right",
- "return_type": "godot_string",
+ "name": "godot_vector3_is_normalized",
+ "return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_pos"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_strip_edges",
- "return_type": "godot_string",
+ "name": "godot_vector3_normalized",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_bool", "p_left"],
- ["godot_bool", "p_right"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_strip_escapes",
- "return_type": "godot_string",
+ "name": "godot_vector3_inverse",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_erase",
- "return_type": "void",
+ "name": "godot_vector3_snapped",
+ "return_type": "godot_vector3",
"arguments": [
- ["godot_string *", "p_self"],
- ["godot_int", "p_pos"],
- ["godot_int", "p_chars"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_by"]
]
},
{
- "name": "godot_string_ascii",
- "return_type": "godot_char_string",
+ "name": "godot_vector3_rotated",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_axis"],
+ ["const godot_real", "p_phi"]
]
},
{
- "name": "godot_string_ascii_extended",
- "return_type": "godot_char_string",
+ "name": "godot_vector3_lerp",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_string_utf8",
- "return_type": "godot_char_string",
+ "name": "godot_vector3_cubic_interpolate",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"],
+ ["const godot_vector3 *", "p_pre_a"],
+ ["const godot_vector3 *", "p_post_b"],
+ ["const godot_real", "p_t"]
]
},
{
- "name": "godot_string_parse_utf8",
- "return_type": "godot_bool",
+ "name": "godot_vector3_dot",
+ "return_type": "godot_real",
"arguments": [
- ["godot_string *", "p_self"],
- ["const char *", "p_utf8"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_parse_utf8_with_len",
- "return_type": "godot_bool",
+ "name": "godot_vector3_cross",
+ "return_type": "godot_vector3",
"arguments": [
- ["godot_string *", "p_self"],
- ["const char *", "p_utf8"],
- ["godot_int", "p_len"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_chars_to_utf8",
- "return_type": "godot_string",
+ "name": "godot_vector3_outer",
+ "return_type": "godot_basis",
"arguments": [
- ["const char *", "p_utf8"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_chars_to_utf8_with_len",
- "return_type": "godot_string",
+ "name": "godot_vector3_to_diagonal_matrix",
+ "return_type": "godot_basis",
"arguments": [
- ["const char *", "p_utf8"],
- ["godot_int", "p_len"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_hash",
- "return_type": "uint32_t",
+ "name": "godot_vector3_abs",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_hash64",
- "return_type": "uint64_t",
+ "name": "godot_vector3_floor",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_hash_chars",
- "return_type": "uint32_t",
+ "name": "godot_vector3_ceil",
+ "return_type": "godot_vector3",
"arguments": [
- ["const char *", "p_cstr"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_hash_chars_with_len",
- "return_type": "uint32_t",
+ "name": "godot_vector3_distance_to",
+ "return_type": "godot_real",
"arguments": [
- ["const char *", "p_cstr"],
- ["godot_int", "p_len"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_hash_utf8_chars",
- "return_type": "uint32_t",
+ "name": "godot_vector3_distance_squared_to",
+ "return_type": "godot_real",
"arguments": [
- ["const wchar_t *", "p_str"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_hash_utf8_chars_with_len",
- "return_type": "uint32_t",
+ "name": "godot_vector3_angle_to",
+ "return_type": "godot_real",
"arguments": [
- ["const wchar_t *", "p_str"],
- ["godot_int", "p_len"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_to"]
]
},
{
- "name": "godot_string_md5_buffer",
- "return_type": "godot_packed_byte_array",
+ "name": "godot_vector3_slide",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_n"]
]
},
{
- "name": "godot_string_md5_text",
- "return_type": "godot_string",
+ "name": "godot_vector3_bounce",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_n"]
]
},
{
- "name": "godot_string_sha256_buffer",
- "return_type": "godot_packed_byte_array",
+ "name": "godot_vector3_reflect",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_n"]
]
},
{
- "name": "godot_string_sha256_text",
- "return_type": "godot_string",
+ "name": "godot_vector3_operator_add",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_empty",
- "return_type": "godot_bool",
+ "name": "godot_vector3_operator_subtract",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_get_base_dir",
- "return_type": "godot_string",
+ "name": "godot_vector3_operator_multiply_vector",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_get_file",
- "return_type": "godot_string",
+ "name": "godot_vector3_operator_multiply_scalar",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_real", "p_b"]
]
},
{
- "name": "godot_string_humanize_size",
- "return_type": "godot_string",
+ "name": "godot_vector3_operator_divide_vector",
+ "return_type": "godot_vector3",
"arguments": [
- ["size_t", "p_size"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_is_abs_path",
- "return_type": "godot_bool",
+ "name": "godot_vector3_operator_divide_scalar",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_real", "p_b"]
]
},
{
- "name": "godot_string_is_rel_path",
+ "name": "godot_vector3_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_is_resource_file",
+ "name": "godot_vector3_operator_less",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"]
- ]
- },
- {
- "name": "godot_string_path_to",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_path"]
- ]
- },
- {
- "name": "godot_string_path_to_file",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"],
- ["const godot_string *", "p_path"]
- ]
- },
- {
- "name": "godot_string_simplify_path",
- "return_type": "godot_string",
- "arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3 *", "p_b"]
]
},
{
- "name": "godot_string_c_escape",
- "return_type": "godot_string",
+ "name": "godot_vector3_operator_neg",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"]
]
},
{
- "name": "godot_string_c_escape_multiline",
- "return_type": "godot_string",
+ "name": "godot_vector3_set_axis",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["godot_vector3 *", "p_self"],
+ ["const godot_vector3_axis", "p_axis"],
+ ["const godot_real", "p_val"]
]
},
{
- "name": "godot_string_c_unescape",
- "return_type": "godot_string",
+ "name": "godot_vector3_get_axis",
+ "return_type": "godot_real",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3 *", "p_self"],
+ ["const godot_vector3_axis", "p_axis"]
]
},
{
- "name": "godot_string_http_escape",
- "return_type": "godot_string",
+ "name": "godot_vector3i_new",
+ "return_type": "void",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["godot_vector3i *", "r_dest"],
+ ["const godot_int", "p_x"],
+ ["const godot_int", "p_y"],
+ ["const godot_int", "p_z"]
]
},
{
- "name": "godot_string_http_unescape",
+ "name": "godot_vector3i_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_json_escape",
- "return_type": "godot_string",
+ "name": "godot_vector3i_as_vector3",
+ "return_type": "godot_vector3",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_word_wrap",
- "return_type": "godot_string",
+ "name": "godot_vector3i_min_axis",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_int", "p_chars_per_line"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_xml_escape",
- "return_type": "godot_string",
+ "name": "godot_vector3i_max_axis",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_xml_escape_with_quotes",
- "return_type": "godot_string",
+ "name": "godot_vector3i_abs",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_xml_unescape",
- "return_type": "godot_string",
+ "name": "godot_vector3i_sign",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_percent_decode",
- "return_type": "godot_string",
+ "name": "godot_vector3i_operator_add",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3i *", "p_b"]
]
},
{
- "name": "godot_string_percent_encode",
- "return_type": "godot_string",
+ "name": "godot_vector3i_operator_subtract",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3i *", "p_b"]
]
},
{
- "name": "godot_string_is_valid_float",
- "return_type": "godot_bool",
+ "name": "godot_vector3i_operator_multiply_vector",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3i *", "p_b"]
]
},
{
- "name": "godot_string_is_valid_hex_number",
- "return_type": "godot_bool",
+ "name": "godot_vector3i_operator_multiply_scalar",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"],
- ["godot_bool", "p_with_prefix"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_int", "p_b"]
]
},
{
- "name": "godot_string_is_valid_html_color",
- "return_type": "godot_bool",
+ "name": "godot_vector3i_operator_divide_vector",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3i *", "p_b"]
]
},
{
- "name": "godot_string_is_valid_identifier",
- "return_type": "godot_bool",
+ "name": "godot_vector3i_operator_divide_scalar",
+ "return_type": "godot_vector3i",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_int", "p_b"]
]
},
{
- "name": "godot_string_is_valid_integer",
+ "name": "godot_vector3i_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3i *", "p_b"]
]
},
{
- "name": "godot_string_is_valid_ip_address",
+ "name": "godot_vector3i_operator_less",
"return_type": "godot_bool",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3i *", "p_b"]
]
},
{
- "name": "godot_string_destroy",
- "return_type": "void",
+ "name": "godot_vector3i_operator_neg",
+ "return_type": "godot_vector3i",
"arguments": [
- ["godot_string *", "p_self"]
+ ["const godot_vector3i *", "p_self"]
]
},
{
- "name": "godot_string_name_new",
+ "name": "godot_vector3i_set_axis",
"return_type": "void",
"arguments": [
- ["godot_string_name *", "r_dest"],
- ["const godot_string *", "p_name"]
- ]
- },
- {
- "name": "godot_string_name_new_data",
- "return_type": "void",
- "arguments": [
- ["godot_string_name *", "r_dest"],
- ["const char *", "p_name"]
+ ["godot_vector3i *", "p_self"],
+ ["const godot_vector3_axis", "p_axis"],
+ ["const godot_int", "p_val"]
]
},
{
- "name": "godot_string_name_get_name",
- "return_type": "godot_string",
+ "name": "godot_vector3i_get_axis",
+ "return_type": "godot_int",
"arguments": [
- ["const godot_string_name *", "p_self"]
+ ["const godot_vector3i *", "p_self"],
+ ["const godot_vector3_axis", "p_axis"]
]
},
{
- "name": "godot_string_name_get_hash",
- "return_type": "uint32_t",
+ "name": "godot_global_get_singleton",
+ "return_type": "godot_object *",
"arguments": [
- ["const godot_string_name *", "p_self"]
+ ["char *", "p_name"]
]
},
{
- "name": "godot_string_name_get_data_unique_pointer",
- "return_type": "const void *",
+ "name": "godot_get_class_tag",
+ "return_type": "void *",
"arguments": [
- ["const godot_string_name *", "p_self"]
+ ["const godot_string_name *", "p_class"]
]
},
{
- "name": "godot_string_name_operator_equal",
- "return_type": "godot_bool",
+ "name": "godot_object_cast_to",
+ "return_type": "godot_object *",
"arguments": [
- ["const godot_string_name *", "p_self"],
- ["const godot_string_name *", "p_other"]
+ ["const godot_object *", "p_object"],
+ ["void *", "p_class_tag"]
]
},
{
- "name": "godot_string_name_operator_less",
- "return_type": "godot_bool",
+ "name": "godot_object_get_instance_id",
+ "return_type": "uint64_t",
"arguments": [
- ["const godot_string_name *", "p_self"],
- ["const godot_string_name *", "p_other"]
+ ["const godot_object *", "p_object"]
]
},
{
- "name": "godot_string_name_destroy",
- "return_type": "void",
+ "name": "godot_instance_from_id",
+ "return_type": "godot_object *",
"arguments": [
- ["godot_string_name *", "p_self"]
+ ["uint64_t", "p_instance_id"]
]
},
{
@@ -5579,13 +6817,6 @@
]
},
{
- "name": "godot_global_get_singleton",
- "return_type": "godot_object *",
- "arguments": [
- ["char *", "p_name"]
- ]
- },
- {
"name": "godot_method_bind_get_method",
"return_type": "godot_method_bind *",
"arguments": [
@@ -5691,132 +6922,10 @@
"name": "nativescript",
"type": "NATIVESCRIPT",
"version": {
- "major": 1,
+ "major": 4,
"minor": 0
},
- "next": {
- "type": "NATIVESCRIPT",
- "version": {
- "major": 1,
- "minor": 1
- },
- "next": null,
- "api": [
- {
- "name": "godot_nativescript_set_method_argument_information",
- "return_type": "void",
- "arguments": [
- ["void *", "p_gdnative_handle"],
- ["const char *", "p_name"],
- ["const char *", "p_function_name"],
- ["int", "p_num_args"],
- ["const godot_method_arg *", "p_args"]
- ]
- },
- {
- "name": "godot_nativescript_set_class_documentation",
- "return_type": "void",
- "arguments": [
- ["void *", "p_gdnative_handle"],
- ["const char *", "p_name"],
- ["godot_string", "p_documentation"]
- ]
- },
- {
- "name": "godot_nativescript_set_method_documentation",
- "return_type": "void",
- "arguments": [
- ["void *", "p_gdnative_handle"],
- ["const char *", "p_name"],
- ["const char *", "p_function_name"],
- ["godot_string", "p_documentation"]
- ]
- },
- {
- "name": "godot_nativescript_set_property_documentation",
- "return_type": "void",
- "arguments": [
- ["void *", "p_gdnative_handle"],
- ["const char *", "p_name"],
- ["const char *", "p_path"],
- ["godot_string", "p_documentation"]
- ]
- },
- {
- "name": "godot_nativescript_set_signal_documentation",
- "return_type": "void",
- "arguments": [
- ["void *", "p_gdnative_handle"],
- ["const char *", "p_name"],
- ["const char *", "p_signal_name"],
- ["godot_string", "p_documentation"]
- ]
- },
- {
- "name": "godot_nativescript_set_global_type_tag",
- "return_type": "void",
- "arguments": [
- ["int", "p_idx"],
- ["const char *", "p_name"],
- ["const void *", "p_type_tag"]
- ]
- },
- {
- "name": "godot_nativescript_get_global_type_tag",
- "return_type": "const void *",
- "arguments": [
- ["int", "p_idx"],
- ["const char *", "p_name"]
- ]
- },
- {
- "name": "godot_nativescript_set_type_tag",
- "return_type": "void",
- "arguments": [
- ["void *", "p_gdnative_handle"],
- ["const char *", "p_name"],
- ["const void *", "p_type_tag"]
- ]
- },
- {
- "name": "godot_nativescript_get_type_tag",
- "return_type": "const void *",
- "arguments": [
- ["const godot_object *", "p_object"]
- ]
- },
- {
- "name": "godot_nativescript_register_instance_binding_data_functions",
- "return_type": "int",
- "arguments": [
- ["godot_instance_binding_functions", "p_binding_functions"]
- ]
- },
- {
- "name": "godot_nativescript_unregister_instance_binding_data_functions",
- "return_type": "void",
- "arguments": [
- ["int", "p_idx"]
- ]
- },
- {
- "name": "godot_nativescript_get_instance_binding_data",
- "return_type": "void *",
- "arguments": [
- ["int", "p_idx"],
- ["godot_object *", "p_object"]
- ]
- },
- {
- "name": "godot_nativescript_profiling_add_data",
- "return_type": "void",
- "arguments": [
- ["const char *", "p_signature"],
- ["uint64_t", "p_line"]
- ]
- }
- ]
- },
+ "next": null,
"api": [
{
"name": "godot_nativescript_register_class",
@@ -5825,8 +6934,8 @@
["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"]
+ ["godot_nativescript_instance_create_func", "p_create_func"],
+ ["godot_nativescript_instance_destroy_func", "p_destroy_func"]
]
},
{
@@ -5836,8 +6945,8 @@
["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"]
+ ["godot_nativescript_instance_create_func", "p_create_func"],
+ ["godot_nativescript_instance_destroy_func", "p_destroy_func"]
]
},
{
@@ -5847,8 +6956,19 @@
["void *", "p_gdnative_handle"],
["const char *", "p_name"],
["const char *", "p_function_name"],
- ["godot_method_attributes", "p_attr"],
- ["godot_instance_method", "p_method"]
+ ["godot_nativescript_method_attributes", "p_attr"],
+ ["godot_nativescript_instance_method", "p_method"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_method_argument_information",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_function_name"],
+ ["int", "p_num_args"],
+ ["const godot_nativescript_method_argument *", "p_args"]
]
},
{
@@ -5858,9 +6978,9 @@
["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"]
+ ["godot_nativescript_property_attributes *", "p_attr"],
+ ["godot_nativescript_property_set_func", "p_set_func"],
+ ["godot_nativescript_property_get_func", "p_get_func"]
]
},
{
@@ -5869,7 +6989,7 @@
"arguments": [
["void *", "p_gdnative_handle"],
["const char *", "p_name"],
- ["const godot_signal *", "p_signal"]
+ ["const godot_nativescript_signal *", "p_signal"]
]
},
{
@@ -5878,6 +6998,108 @@
"arguments": [
["godot_object *", "p_instance"]
]
+ },
+ {
+ "name": "godot_nativescript_set_class_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_method_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_function_name"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_property_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_path"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_signal_documentation",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const char *", "p_signal_name"],
+ ["godot_string", "p_documentation"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_global_type_tag",
+ "return_type": "void",
+ "arguments": [
+ ["int", "p_idx"],
+ ["const char *", "p_name"],
+ ["const void *", "p_type_tag"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_get_global_type_tag",
+ "return_type": "const void *",
+ "arguments": [
+ ["int", "p_idx"],
+ ["const char *", "p_name"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_set_type_tag",
+ "return_type": "void",
+ "arguments": [
+ ["void *", "p_gdnative_handle"],
+ ["const char *", "p_name"],
+ ["const void *", "p_type_tag"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_get_type_tag",
+ "return_type": "const void *",
+ "arguments": [
+ ["const godot_object *", "p_object"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_register_instance_binding_data_functions",
+ "return_type": "int",
+ "arguments": [
+ ["godot_nativescript_instance_binding_functions", "p_binding_functions"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_unregister_instance_binding_data_functions",
+ "return_type": "void",
+ "arguments": [
+ ["int", "p_idx"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_get_instance_binding_data",
+ "return_type": "void *",
+ "arguments": [
+ ["int", "p_idx"],
+ ["godot_object *", "p_object"]
+ ]
+ },
+ {
+ "name": "godot_nativescript_profiling_add_data",
+ "return_type": "void",
+ "arguments": [
+ ["const char *", "p_signature"],
+ ["uint64_t", "p_line"]
+ ]
}
]
},
@@ -6071,42 +7293,10 @@
"name": "net",
"type": "NET",
"version": {
- "major": 3,
- "minor": 1
- },
- "next": {
- "type": "NET",
- "version": {
- "major": 3,
- "minor": 2
- },
- "next": null,
- "api": [
- {
- "name": "godot_net_set_webrtc_library",
- "return_type": "godot_error",
- "arguments": [
- ["const godot_net_webrtc_library *", "p_library"]
- ]
- },
- {
- "name": "godot_net_bind_webrtc_peer_connection",
- "return_type": "void",
- "arguments": [
- ["godot_object *", "p_obj"],
- ["const godot_net_webrtc_peer_connection *", "p_interface"]
- ]
- },
- {
- "name": "godot_net_bind_webrtc_data_channel",
- "return_type": "void",
- "arguments": [
- ["godot_object *", "p_obj"],
- ["const godot_net_webrtc_data_channel *", "p_interface"]
- ]
- }
- ]
+ "major": 4,
+ "minor": 0
},
+ "next": null,
"api": [
{
"name": "godot_net_bind_stream_peer",
@@ -6131,6 +7321,29 @@
["godot_object *", "p_obj"],
["const godot_net_multiplayer_peer *", "p_interface"]
]
+ },
+ {
+ "name": "godot_net_set_webrtc_library",
+ "return_type": "godot_error",
+ "arguments": [
+ ["const godot_net_webrtc_library *", "p_library"]
+ ]
+ },
+ {
+ "name": "godot_net_bind_webrtc_peer_connection",
+ "return_type": "void",
+ "arguments": [
+ ["godot_object *", "p_obj"],
+ ["const godot_net_webrtc_peer_connection *", "p_interface"]
+ ]
+ },
+ {
+ "name": "godot_net_bind_webrtc_data_channel",
+ "return_type": "void",
+ "arguments": [
+ ["godot_object *", "p_obj"],
+ ["const godot_net_webrtc_data_channel *", "p_interface"]
+ ]
}
]
}
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 620935795f..a6f8afb85b 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -228,7 +228,16 @@ def _build_gdnative_api_struct_source(api):
"extern const godot_gdnative_core_api_struct api_struct = {",
"\tGDNATIVE_" + api["core"]["type"] + ",",
"\t{" + str(api["core"]["version"]["major"]) + ", " + str(api["core"]["version"]["minor"]) + "},",
- "\t(const godot_gdnative_api_struct *)&api_1_1,",
+ "\t"
+ + (
+ "nullptr, "
+ if not api["core"]["next"]
+ else (
+ "(const godot_gdnative_api_struct *)& api_{0}_{1},".format(
+ api["core"]["next"]["version"]["major"], api["core"]["next"]["version"]["minor"]
+ )
+ )
+ ),
"\t" + str(len(api["extensions"])) + ",",
"\tgdnative_extensions_pointers,",
]
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index 10ddd79d3a..2a9836329e 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<GDNativeLibrary> p_library) {
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
for (List<String>::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<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
-
String target = E->key() + "." + it->get();
TreeItem *bit = tree->create_item(platform);
@@ -125,17 +121,16 @@ void GDNativeLibraryEditor::_update_tree() {
}
void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
-
String target = Object::cast_to<TreeItem>(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)
+ if (id == BUTTON_SELECT_DEPENDENCES) {
mode = EditorFileDialog::FILE_MODE_OPEN_FILES;
+ }
file_dialog->set_meta("target", target);
file_dialog->set_meta("section", section);
@@ -156,24 +151,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<TreeItem>(p_item);
String name = item->get_text(0);
@@ -185,7 +176,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 +184,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()) {
@@ -204,19 +193,18 @@ void GDNativeLibraryEditor::_on_create_new_entry() {
}
void GDNativeLibraryEditor::_set_target_value(const String &section, const String &target, Variant file) {
- if (section == "entry")
+ if (section == "entry") {
entry_configs[target].library = file;
- else if (section == "dependencies")
+ } else if (section == "dependencies") {
entry_configs[target].dependencies = file;
+ }
_translate_to_config_file();
_update_tree();
}
void GDNativeLibraryEditor::_erase_entry(const String &platform, const String &entry) {
-
if (platforms.has(platform)) {
if (List<String>::Element *E = platforms[platform].entries.find(entry)) {
-
String target = platform + "." + entry;
platforms[platform].entries.erase(E);
@@ -243,19 +231,17 @@ void GDNativeLibraryEditor::_move_entry(const String &platform, const String &en
}
void GDNativeLibraryEditor::_translate_to_config_file() {
-
if (!library.is_null()) {
-
Ref<ConfigFile> config = library->get_config_file();
config->erase_section("entry");
config->erase_section("dependencies");
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
for (List<String>::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())
+ if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) {
continue;
+ }
config->set_value("entry", target, entry_configs[target].library);
config->set_value("dependencies", target, entry_configs[target].dependencies);
@@ -267,7 +253,6 @@ void GDNativeLibraryEditor::_translate_to_config_file() {
}
GDNativeLibraryEditor::GDNativeLibraryEditor() {
-
{ // Define platforms
NativePlatformConfig platform_windows;
platform_windows.name = "Windows";
@@ -388,32 +373,30 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
}
void GDNativeLibraryEditorPlugin::edit(Object *p_node) {
-
Ref<GDNativeLibrary> new_library = Object::cast_to<GDNativeLibrary>(p_node);
- if (new_library.is_valid())
+ 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);
} else {
- if (library_editor->is_visible_in_tree())
+ if (library_editor->is_visible_in_tree()) {
EditorNode::get_singleton()->hide_bottom_panel();
+ }
button->hide();
}
}
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..409b6cbffe 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<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) {
-
Set<String> file_paths;
// check children
@@ -67,7 +66,6 @@ Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil
}
void GDNativeLibrarySingletonEditor::_discover_singletons() {
-
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> 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
@@ -139,19 +135,22 @@ void GDNativeLibrarySingletonEditor::_update_libraries() {
}
// The singletons list changed, we must update the settings
- if (updated_disabled.size() != singletons_disabled.size())
+ if (updated_disabled.size() != singletons_disabled.size()) {
ProjectSettings::get_singleton()->set("gdnative/singletons_disabled", updated_disabled);
+ }
updating = false;
}
void GDNativeLibrarySingletonEditor::_item_edited() {
- if (updating)
+ if (updating) {
return;
+ }
TreeItem *item = libraries->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
bool enabled = item->get_range(1);
String path = item->get_metadata(0);
@@ -169,8 +168,9 @@ void GDNativeLibrarySingletonEditor::_item_edited() {
if (enabled) {
disabled_paths.erase(path);
} else {
- if (disabled_paths.find(path) == -1)
+ if (disabled_paths.find(path) == -1) {
disabled_paths.push_back(path);
+ }
}
undo_redo->create_action(enabled ? TTR("Enabled GDNative Singleton") : TTR("Disabled GDNative Singleton"));
@@ -182,7 +182,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 +190,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/gdnative/array.h b/modules/gdnative/include/gdnative/array.h
index e3114e9348..4db685873f 100644
--- a/modules/gdnative/include/gdnative/array.h
+++ b/modules/gdnative/include/gdnative/array.h
@@ -51,7 +51,7 @@ typedef struct {
}
#endif
-#include <gdnative/pool_arrays.h>
+#include <gdnative/packed_arrays.h>
#include <gdnative/variant.h>
#include <gdnative/gdnative.h>
@@ -66,8 +66,10 @@ void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_p
void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a);
void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a);
void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa);
-void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_packed_real_array *p_pra);
-void GDAPI godot_array_new_packed_int_array(godot_array *r_dest, const godot_packed_int_array *p_pia);
+void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra);
+void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra);
+void GDAPI godot_array_new_packed_int32_array(godot_array *r_dest, const godot_packed_int32_array *p_pia);
+void GDAPI godot_array_new_packed_int64_array(godot_array *r_dest, const godot_packed_int64_array *p_pia);
void GDAPI godot_array_new_packed_byte_array(godot_array *r_dest, const godot_packed_byte_array *p_pba);
void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value);
diff --git a/modules/gdnative/include/gdnative/callable.h b/modules/gdnative/include/gdnative/callable.h
new file mode 100644
index 0000000000..dbb5d02590
--- /dev/null
+++ b/modules/gdnative/include/gdnative/callable.h
@@ -0,0 +1,126 @@
+/*************************************************************************/
+/* callable.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 GODOT_CALLABLE_H
+#define GODOT_CALLABLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define GODOT_CALLABLE_SIZE (16)
+
+#ifndef GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_CALLABLE_SIZE];
+} godot_callable;
+#endif
+
+#define GODOT_SIGNAL_SIZE (16)
+
+#ifndef GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE];
+} godot_signal;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <gdnative/gdnative.h>
+#include <gdnative/string_name.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Callable
+
+void GDAPI godot_callable_new_with_object(godot_callable *r_dest, const godot_object *p_object, const godot_string_name *p_method);
+void GDAPI godot_callable_new_with_object_id(godot_callable *r_dest, uint64_t p_objectid, const godot_string_name *p_method);
+void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src);
+
+void GDAPI godot_callable_destroy(godot_callable *p_self);
+
+godot_int GDAPI godot_callable_call(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount, godot_variant *r_return_value);
+void GDAPI godot_callable_call_deferred(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount);
+
+godot_bool GDAPI godot_callable_is_null(const godot_callable *p_self);
+godot_bool GDAPI godot_callable_is_custom(const godot_callable *p_self);
+godot_bool GDAPI godot_callable_is_standard(const godot_callable *p_self);
+
+godot_object GDAPI *godot_callable_get_object(const godot_callable *p_self);
+uint64_t GDAPI godot_callable_get_object_id(const godot_callable *p_self);
+godot_string_name GDAPI godot_callable_get_method(const godot_callable *p_self);
+
+uint32_t GDAPI godot_callable_hash(const godot_callable *p_self);
+
+godot_string GDAPI godot_callable_as_string(const godot_callable *p_self);
+
+godot_bool GDAPI godot_callable_operator_equal(const godot_callable *p_self, const godot_callable *p_other);
+godot_bool GDAPI godot_callable_operator_less(const godot_callable *p_self, const godot_callable *p_other);
+
+// Signal
+
+void GDAPI godot_signal_new_with_object(godot_signal *r_dest, const godot_object *p_object, const godot_string_name *p_name);
+void GDAPI godot_signal_new_with_object_id(godot_signal *r_dest, uint64_t p_objectid, const godot_string_name *p_name);
+void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src);
+
+void GDAPI godot_signal_destroy(godot_signal *p_self);
+
+godot_int GDAPI godot_signal_emit(const godot_signal *p_self, const godot_variant **p_arguments, godot_int p_argcount);
+
+godot_int GDAPI godot_signal_connect(godot_signal *p_self, const godot_callable *p_callable, const godot_array *p_binds, uint32_t p_flags);
+void GDAPI godot_signal_disconnect(godot_signal *p_self, const godot_callable *p_callable);
+
+godot_bool GDAPI godot_signal_is_null(const godot_signal *p_self);
+godot_bool GDAPI godot_signal_is_connected(const godot_signal *p_self, const godot_callable *p_callable);
+
+godot_array GDAPI godot_signal_get_connections(const godot_signal *p_self);
+
+godot_object GDAPI *godot_signal_get_object(const godot_signal *p_self);
+uint64_t GDAPI godot_signal_get_object_id(const godot_signal *p_self);
+godot_string_name GDAPI godot_signal_get_name(const godot_signal *p_self);
+
+godot_string GDAPI godot_signal_as_string(const godot_signal *p_self);
+
+godot_bool GDAPI godot_signal_operator_equal(const godot_signal *p_self, const godot_signal *p_other);
+godot_bool GDAPI godot_signal_operator_less(const godot_signal *p_self, const godot_signal *p_other);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index 6fdca30122..6a0a375da8 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -144,15 +144,15 @@ typedef void godot_object;
#include <gdnative/string_name.h>
-////// Vector2
+////// Vector2 & Vector2i
#include <gdnative/vector2.h>
-////// Rect2
+////// Rect2 & Rect2i
#include <gdnative/rect2.h>
-////// Vector3
+////// Vector3 & Vector3i
#include <gdnative/vector3.h>
@@ -192,6 +192,10 @@ typedef void godot_object;
#include <gdnative/rid.h>
+/////// Callable & Signal
+
+#include <gdnative/callable.h>
+
/////// Dictionary
#include <gdnative/dictionary.h>
@@ -200,8 +204,8 @@ typedef void godot_object;
#include <gdnative/array.h>
-// single API file for Pool*Array
-#include <gdnative/pool_arrays.h>
+// single API file for Packed*Array
+#include <gdnative/packed_arrays.h>
void GDAPI godot_object_destroy(godot_object *p_o);
@@ -289,7 +293,9 @@ void GDAPI *godot_get_class_tag(const godot_string_name *p_class);
godot_object GDAPI *godot_object_cast_to(const godot_object *p_object, void *p_class_tag);
// equivalent of GDScript's instance_from_id
-godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id);
+godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id);
+
+uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/packed_arrays.h
index c610377f54..8cff6d49a5 100644
--- a/modules/gdnative/include/gdnative/pool_arrays.h
+++ b/modules/gdnative/include/gdnative/packed_arrays.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* pool_arrays.h */
+/* packed_arrays.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_POOL_ARRAYS_H
-#define GODOT_POOL_ARRAYS_H
+#ifndef GODOT_PACKED_ARRAYS_H
+#define GODOT_PACKED_ARRAYS_H
#ifdef __cplusplus
extern "C" {
@@ -39,7 +39,7 @@ extern "C" {
/////// PackedByteArray
-#define GODOT_PACKED_BYTE_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_BYTE_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED
@@ -50,29 +50,51 @@ typedef struct {
/////// PackedInt32Array
-#define GODOT_PACKED_INT_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_INT32_ARRAY_SIZE (2 * sizeof(void *))
-#ifndef GODOT_CORE_API_GODOT_PACKED_INT_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_PACKED_INT_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_PACKED_INT_ARRAY_SIZE];
-} godot_packed_int_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_INT32_ARRAY_SIZE];
+} godot_packed_int32_array;
+#endif
+
+/////// PackedInt64Array
+
+#define GODOT_PACKED_INT64_ARRAY_SIZE (2 * sizeof(void *))
+
+#ifndef GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_PACKED_INT64_ARRAY_SIZE];
+} godot_packed_int64_array;
#endif
/////// PackedFloat32Array
-#define GODOT_PACKED_REAL_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_FLOAT32_ARRAY_SIZE (2 * sizeof(void *))
+
+#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_PACKED_FLOAT32_ARRAY_SIZE];
+} godot_packed_float32_array;
+#endif
+
+/////// PackedFloat64Array
-#ifndef GODOT_CORE_API_GODOT_PACKED_REAL_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_PACKED_REAL_ARRAY_TYPE_DEFINED
+#define GODOT_PACKED_FLOAT64_ARRAY_SIZE (2 * sizeof(void *))
+
+#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_PACKED_REAL_ARRAY_SIZE];
-} godot_packed_real_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_FLOAT64_ARRAY_SIZE];
+} godot_packed_float64_array;
#endif
/////// PackedStringArray
-#define GODOT_PACKED_STRING_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_STRING_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED
@@ -83,7 +105,7 @@ typedef struct {
/////// PackedVector2Array
-#define GODOT_PACKED_VECTOR2_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_VECTOR2_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED
@@ -94,7 +116,7 @@ typedef struct {
/////// PackedVector3Array
-#define GODOT_PACKED_VECTOR3_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_VECTOR3_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED
@@ -105,7 +127,7 @@ typedef struct {
/////// PackedColorArray
-#define GODOT_PACKED_COLOR_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_COLOR_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED
@@ -136,6 +158,9 @@ void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *r_dest);
void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src);
void GDAPI godot_packed_byte_array_new_with_array(godot_packed_byte_array *r_dest, const godot_array *p_a);
+const uint8_t GDAPI *godot_packed_byte_array_ptr(const godot_packed_byte_array *p_self);
+uint8_t GDAPI *godot_packed_byte_array_ptrw(godot_packed_byte_array *p_self);
+
void GDAPI godot_packed_byte_array_append(godot_packed_byte_array *p_self, const uint8_t p_data);
void GDAPI godot_packed_byte_array_append_array(godot_packed_byte_array *p_self, const godot_packed_byte_array *p_array);
@@ -159,63 +184,133 @@ godot_bool GDAPI godot_packed_byte_array_empty(const godot_packed_byte_array *p_
void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self);
-// int
+// int32
+
+void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *r_dest);
+void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src);
+void GDAPI godot_packed_int32_array_new_with_array(godot_packed_int32_array *r_dest, const godot_array *p_a);
+
+const int32_t GDAPI *godot_packed_int32_array_ptr(const godot_packed_int32_array *p_self);
+int32_t GDAPI *godot_packed_int32_array_ptrw(godot_packed_int32_array *p_self);
+
+void GDAPI godot_packed_int32_array_append(godot_packed_int32_array *p_self, const int32_t p_data);
+
+void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_self, const godot_packed_int32_array *p_array);
+
+godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data);
+
+void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self);
+
+void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data);
+
+void GDAPI godot_packed_int32_array_remove(godot_packed_int32_array *p_self, const godot_int p_idx);
+
+void GDAPI godot_packed_int32_array_resize(godot_packed_int32_array *p_self, const godot_int p_size);
+
+void GDAPI godot_packed_int32_array_set(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data);
+int32_t GDAPI godot_packed_int32_array_get(const godot_packed_int32_array *p_self, const godot_int p_idx);
+
+godot_int GDAPI godot_packed_int32_array_size(const godot_packed_int32_array *p_self);
+
+godot_bool GDAPI godot_packed_int32_array_empty(const godot_packed_int32_array *p_self);
-void GDAPI godot_packed_int_array_new(godot_packed_int_array *r_dest);
-void GDAPI godot_packed_int_array_new_copy(godot_packed_int_array *r_dest, const godot_packed_int_array *p_src);
-void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, const godot_array *p_a);
+void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self);
-void GDAPI godot_packed_int_array_append(godot_packed_int_array *p_self, const godot_int p_data);
+// int64
-void GDAPI godot_packed_int_array_append_array(godot_packed_int_array *p_self, const godot_packed_int_array *p_array);
+void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *r_dest);
+void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src);
+void GDAPI godot_packed_int64_array_new_with_array(godot_packed_int64_array *r_dest, const godot_array *p_a);
-godot_error GDAPI godot_packed_int_array_insert(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data);
+const int64_t GDAPI *godot_packed_int64_array_ptr(const godot_packed_int64_array *p_self);
+int64_t GDAPI *godot_packed_int64_array_ptrw(godot_packed_int64_array *p_self);
-void GDAPI godot_packed_int_array_invert(godot_packed_int_array *p_self);
+void GDAPI godot_packed_int64_array_append(godot_packed_int64_array *p_self, const int64_t p_data);
-void GDAPI godot_packed_int_array_push_back(godot_packed_int_array *p_self, const godot_int p_data);
+void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_self, const godot_packed_int64_array *p_array);
-void GDAPI godot_packed_int_array_remove(godot_packed_int_array *p_self, const godot_int p_idx);
+godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data);
-void GDAPI godot_packed_int_array_resize(godot_packed_int_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self);
-void GDAPI godot_packed_int_array_set(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data);
-godot_int GDAPI godot_packed_int_array_get(const godot_packed_int_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data);
-godot_int GDAPI godot_packed_int_array_size(const godot_packed_int_array *p_self);
+void GDAPI godot_packed_int64_array_remove(godot_packed_int64_array *p_self, const godot_int p_idx);
-godot_bool GDAPI godot_packed_int_array_empty(const godot_packed_int_array *p_self);
+void GDAPI godot_packed_int64_array_resize(godot_packed_int64_array *p_self, const godot_int p_size);
-void GDAPI godot_packed_int_array_destroy(godot_packed_int_array *p_self);
+void GDAPI godot_packed_int64_array_set(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data);
+int64_t GDAPI godot_packed_int64_array_get(const godot_packed_int64_array *p_self, const godot_int p_idx);
-// real
+godot_int GDAPI godot_packed_int64_array_size(const godot_packed_int64_array *p_self);
-void GDAPI godot_packed_real_array_new(godot_packed_real_array *r_dest);
-void GDAPI godot_packed_real_array_new_copy(godot_packed_real_array *r_dest, const godot_packed_real_array *p_src);
-void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_dest, const godot_array *p_a);
+godot_bool GDAPI godot_packed_int64_array_empty(const godot_packed_int64_array *p_self);
-void GDAPI godot_packed_real_array_append(godot_packed_real_array *p_self, const godot_real p_data);
+void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self);
-void GDAPI godot_packed_real_array_append_array(godot_packed_real_array *p_self, const godot_packed_real_array *p_array);
+// float32
-godot_error GDAPI godot_packed_real_array_insert(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data);
+void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *r_dest);
+void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src);
+void GDAPI godot_packed_float32_array_new_with_array(godot_packed_float32_array *r_dest, const godot_array *p_a);
-void GDAPI godot_packed_real_array_invert(godot_packed_real_array *p_self);
+const float GDAPI *godot_packed_float32_array_ptr(const godot_packed_float32_array *p_self);
+float GDAPI *godot_packed_float32_array_ptrw(godot_packed_float32_array *p_self);
-void GDAPI godot_packed_real_array_push_back(godot_packed_real_array *p_self, const godot_real p_data);
+void GDAPI godot_packed_float32_array_append(godot_packed_float32_array *p_self, const float p_data);
-void GDAPI godot_packed_real_array_remove(godot_packed_real_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p_self, const godot_packed_float32_array *p_array);
-void GDAPI godot_packed_real_array_resize(godot_packed_real_array *p_self, const godot_int p_size);
+godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data);
-void GDAPI godot_packed_real_array_set(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data);
-godot_real GDAPI godot_packed_real_array_get(const godot_packed_real_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self);
-godot_int GDAPI godot_packed_real_array_size(const godot_packed_real_array *p_self);
+void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data);
-godot_bool GDAPI godot_packed_real_array_empty(const godot_packed_real_array *p_self);
+void GDAPI godot_packed_float32_array_remove(godot_packed_float32_array *p_self, const godot_int p_idx);
-void GDAPI godot_packed_real_array_destroy(godot_packed_real_array *p_self);
+void GDAPI godot_packed_float32_array_resize(godot_packed_float32_array *p_self, const godot_int p_size);
+
+void GDAPI godot_packed_float32_array_set(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data);
+float GDAPI godot_packed_float32_array_get(const godot_packed_float32_array *p_self, const godot_int p_idx);
+
+godot_int GDAPI godot_packed_float32_array_size(const godot_packed_float32_array *p_self);
+
+godot_bool GDAPI godot_packed_float32_array_empty(const godot_packed_float32_array *p_self);
+
+void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self);
+
+// float64
+
+void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *r_dest);
+void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src);
+void GDAPI godot_packed_float64_array_new_with_array(godot_packed_float64_array *r_dest, const godot_array *p_a);
+
+const double GDAPI *godot_packed_float64_array_ptr(const godot_packed_float64_array *p_self);
+double GDAPI *godot_packed_float64_array_ptrw(godot_packed_float64_array *p_self);
+
+void GDAPI godot_packed_float64_array_append(godot_packed_float64_array *p_self, const double p_data);
+
+void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p_self, const godot_packed_float64_array *p_array);
+
+godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data);
+
+void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self);
+
+void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data);
+
+void GDAPI godot_packed_float64_array_remove(godot_packed_float64_array *p_self, const godot_int p_idx);
+
+void GDAPI godot_packed_float64_array_resize(godot_packed_float64_array *p_self, const godot_int p_size);
+
+void GDAPI godot_packed_float64_array_set(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data);
+double GDAPI godot_packed_float64_array_get(const godot_packed_float64_array *p_self, const godot_int p_idx);
+
+godot_int GDAPI godot_packed_float64_array_size(const godot_packed_float64_array *p_self);
+
+godot_bool GDAPI godot_packed_float64_array_empty(const godot_packed_float64_array *p_self);
+
+void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self);
// string
@@ -223,6 +318,9 @@ void GDAPI godot_packed_string_array_new(godot_packed_string_array *r_dest);
void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src);
void GDAPI godot_packed_string_array_new_with_array(godot_packed_string_array *r_dest, const godot_array *p_a);
+const godot_string GDAPI *godot_packed_string_array_ptr(const godot_packed_string_array *p_self);
+godot_string GDAPI *godot_packed_string_array_ptrw(godot_packed_string_array *p_self);
+
void GDAPI godot_packed_string_array_append(godot_packed_string_array *p_self, const godot_string *p_data);
void GDAPI godot_packed_string_array_append_array(godot_packed_string_array *p_self, const godot_packed_string_array *p_array);
@@ -252,6 +350,9 @@ void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *r_dest);
void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src);
void GDAPI godot_packed_vector2_array_new_with_array(godot_packed_vector2_array *r_dest, const godot_array *p_a);
+const godot_vector2 GDAPI *godot_packed_vector2_array_ptr(const godot_packed_vector2_array *p_self);
+godot_vector2 GDAPI *godot_packed_vector2_array_ptrw(godot_packed_vector2_array *p_self);
+
void GDAPI godot_packed_vector2_array_append(godot_packed_vector2_array *p_self, const godot_vector2 *p_data);
void GDAPI godot_packed_vector2_array_append_array(godot_packed_vector2_array *p_self, const godot_packed_vector2_array *p_array);
@@ -281,6 +382,9 @@ void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest);
void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src);
void GDAPI godot_packed_vector3_array_new_with_array(godot_packed_vector3_array *r_dest, const godot_array *p_a);
+const godot_vector3 GDAPI *godot_packed_vector3_array_ptr(const godot_packed_vector3_array *p_self);
+godot_vector3 GDAPI *godot_packed_vector3_array_ptrw(godot_packed_vector3_array *p_self);
+
void GDAPI godot_packed_vector3_array_append(godot_packed_vector3_array *p_self, const godot_vector3 *p_data);
void GDAPI godot_packed_vector3_array_append_array(godot_packed_vector3_array *p_self, const godot_packed_vector3_array *p_array);
@@ -310,6 +414,9 @@ void GDAPI godot_packed_color_array_new(godot_packed_color_array *r_dest);
void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src);
void GDAPI godot_packed_color_array_new_with_array(godot_packed_color_array *r_dest, const godot_array *p_a);
+const godot_color GDAPI *godot_packed_color_array_ptr(const godot_packed_color_array *p_self);
+godot_color GDAPI *godot_packed_color_array_ptrw(godot_packed_color_array *p_self);
+
void GDAPI godot_packed_color_array_append(godot_packed_color_array *p_self, const godot_color *p_data);
void GDAPI godot_packed_color_array_append_array(godot_packed_color_array *p_self, const godot_packed_color_array *p_array);
diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h
index 0ecf072471..f317afc9da 100644
--- a/modules/gdnative/include/gdnative/rect2.h
+++ b/modules/gdnative/include/gdnative/rect2.h
@@ -44,6 +44,13 @@ typedef struct godot_rect2 {
} godot_rect2;
#endif
+#ifndef GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED
+typedef struct godot_rect2i {
+ uint8_t _dont_touch_that[16];
+} godot_rect2i;
+#endif
+
// reduce extern "C" nesting for VS2013
#ifdef __cplusplus
}
@@ -56,11 +63,15 @@ typedef struct godot_rect2 {
extern "C" {
#endif
+// Rect2
+
void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size);
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);
godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self);
+godot_rect2i GDAPI godot_rect2_as_rect2i(const godot_rect2 *p_self);
+
godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self);
godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b);
@@ -95,6 +106,49 @@ void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_
void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size);
+// Rect2I
+
+void GDAPI godot_rect2i_new_with_position_and_size(godot_rect2i *r_dest, const godot_vector2i *p_pos, const godot_vector2i *p_size);
+void GDAPI godot_rect2i_new(godot_rect2i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_width, const godot_int p_height);
+
+godot_string GDAPI godot_rect2i_as_string(const godot_rect2i *p_self);
+
+godot_rect2 GDAPI godot_rect2i_as_rect2(const godot_rect2i *p_self);
+
+godot_int GDAPI godot_rect2i_get_area(const godot_rect2i *p_self);
+
+godot_bool GDAPI godot_rect2i_intersects(const godot_rect2i *p_self, const godot_rect2i *p_b);
+
+godot_bool GDAPI godot_rect2i_encloses(const godot_rect2i *p_self, const godot_rect2i *p_b);
+
+godot_bool GDAPI godot_rect2i_has_no_area(const godot_rect2i *p_self);
+
+godot_rect2i GDAPI godot_rect2i_clip(const godot_rect2i *p_self, const godot_rect2i *p_b);
+
+godot_rect2i GDAPI godot_rect2i_merge(const godot_rect2i *p_self, const godot_rect2i *p_b);
+
+godot_bool GDAPI godot_rect2i_has_point(const godot_rect2i *p_self, const godot_vector2i *p_point);
+
+godot_rect2i GDAPI godot_rect2i_grow(const godot_rect2i *p_self, const godot_int p_by);
+
+godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, const godot_int p_left, const godot_int p_top, const godot_int p_right, const godot_int p_bottom);
+
+godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_margin, const godot_int p_by);
+
+godot_rect2i GDAPI godot_rect2i_abs(const godot_rect2i *p_self);
+
+godot_rect2i GDAPI godot_rect2i_expand(const godot_rect2i *p_self, const godot_vector2i *p_to);
+
+godot_bool GDAPI godot_rect2i_operator_equal(const godot_rect2i *p_self, const godot_rect2i *p_b);
+
+godot_vector2i GDAPI godot_rect2i_get_position(const godot_rect2i *p_self);
+
+godot_vector2i GDAPI godot_rect2i_get_size(const godot_rect2i *p_self);
+
+void GDAPI godot_rect2i_set_position(godot_rect2i *p_self, const godot_vector2i *p_pos);
+
+void GDAPI godot_rect2i_set_size(godot_rect2i *p_self, const godot_vector2i *p_size);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h
index 04661cedc8..73b601dc04 100644
--- a/modules/gdnative/include/gdnative/rid.h
+++ b/modules/gdnative/include/gdnative/rid.h
@@ -37,7 +37,7 @@ extern "C" {
#include <stdint.h>
-#define GODOT_RID_SIZE sizeof(void *)
+#define GODOT_RID_SIZE sizeof(uint64_t)
#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index 934e856fbf..0a611b76e9 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -37,7 +37,7 @@ extern "C" {
#include <stdint.h>
-#define GODOT_VARIANT_SIZE (16 + sizeof(void *))
+#define GODOT_VARIANT_SIZE (16 + sizeof(int64_t))
#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
@@ -71,16 +71,21 @@ typedef enum godot_variant_type {
// misc types
GODOT_VARIANT_TYPE_COLOR,
+ GODOT_VARIANT_TYPE_STRING_NAME,
GODOT_VARIANT_TYPE_NODE_PATH,
GODOT_VARIANT_TYPE_RID,
GODOT_VARIANT_TYPE_OBJECT,
+ GODOT_VARIANT_TYPE_CALLABLE,
+ GODOT_VARIANT_TYPE_SIGNAL,
GODOT_VARIANT_TYPE_DICTIONARY,
GODOT_VARIANT_TYPE_ARRAY,
// arrays
GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY,
- GODOT_VARIANT_TYPE_PACKED_INT_ARRAY,
- GODOT_VARIANT_TYPE_PACKED_REAL_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_INT32_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_INT64_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY,
GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
@@ -149,15 +154,17 @@ typedef enum godot_variant_operator {
#include <gdnative/aabb.h>
#include <gdnative/array.h>
#include <gdnative/basis.h>
+#include <gdnative/callable.h>
#include <gdnative/color.h>
#include <gdnative/dictionary.h>
#include <gdnative/node_path.h>
+#include <gdnative/packed_arrays.h>
#include <gdnative/plane.h>
-#include <gdnative/pool_arrays.h>
#include <gdnative/quat.h>
#include <gdnative/rect2.h>
#include <gdnative/rid.h>
#include <gdnative/string.h>
+#include <gdnative/string_name.h>
#include <gdnative/transform.h>
#include <gdnative/transform2d.h>
#include <gdnative/variant.h>
@@ -181,9 +188,13 @@ void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i);
void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i);
void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r);
void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s);
+void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s);
void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2);
+void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2);
void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2);
+void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2);
void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3);
+void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3);
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d);
void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane);
void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat);
@@ -193,12 +204,16 @@ void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transf
void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color);
void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np);
void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid);
+void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_callable);
+void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal);
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj);
void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict);
void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr);
void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba);
-void GDAPI godot_variant_new_packed_int_array(godot_variant *r_dest, const godot_packed_int_array *p_pia);
-void GDAPI godot_variant_new_packed_real_array(godot_variant *r_dest, const godot_packed_real_array *p_pra);
+void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia);
+void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia);
+void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra);
+void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra);
void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa);
void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a);
void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a);
@@ -209,9 +224,13 @@ uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self);
int64_t GDAPI godot_variant_as_int(const godot_variant *p_self);
double GDAPI godot_variant_as_real(const godot_variant *p_self);
godot_string GDAPI godot_variant_as_string(const godot_variant *p_self);
+godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self);
godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self);
+godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self);
godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self);
+godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self);
godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self);
+godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self);
godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self);
godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self);
godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self);
@@ -221,12 +240,16 @@ godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self);
godot_color GDAPI godot_variant_as_color(const godot_variant *p_self);
godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self);
godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self);
+godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self);
+godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self);
godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self);
godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self);
godot_array GDAPI godot_variant_as_array(const godot_variant *p_self);
godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self);
-godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_variant *p_self);
-godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_variant *p_self);
+godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self);
+godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self);
+godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self);
+godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self);
godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self);
godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self);
godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self);
@@ -239,6 +262,7 @@ godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const god
godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other);
godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other);
+uint32_t GDAPI godot_variant_hash(const godot_variant *p_self);
godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other);
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self);
diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h
index c11e23a586..35b02c5a75 100644
--- a/modules/gdnative/include/gdnative/vector2.h
+++ b/modules/gdnative/include/gdnative/vector2.h
@@ -46,6 +46,15 @@ typedef struct {
} godot_vector2;
#endif
+#define GODOT_VECTOR2I_SIZE 8
+
+#ifndef GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VECTOR2I_SIZE];
+} godot_vector2i;
+#endif
+
// reduce extern "C" nesting for VS2013
#ifdef __cplusplus
}
@@ -57,10 +66,14 @@ typedef struct {
extern "C" {
#endif
+// Vector2
+
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y);
godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self);
+godot_vector2i GDAPI godot_vector2_as_vector2i(const godot_vector2 *p_self);
+
godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self);
godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self);
@@ -93,6 +106,8 @@ godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_self);
godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self);
+godot_vector2 GDAPI godot_vector2_sign(const godot_vector2 *p_self);
+
godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by);
godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self);
@@ -135,6 +150,46 @@ godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self);
godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self);
+// Vector2i
+
+void GDAPI godot_vector2i_new(godot_vector2i *r_dest, const godot_int p_x, const godot_int p_y);
+
+godot_string GDAPI godot_vector2i_as_string(const godot_vector2i *p_self);
+
+godot_vector2 GDAPI godot_vector2i_as_vector2(const godot_vector2i *p_self);
+
+godot_real GDAPI godot_vector2i_aspect(const godot_vector2i *p_self);
+
+godot_vector2i GDAPI godot_vector2i_abs(const godot_vector2i *p_self);
+
+godot_vector2i GDAPI godot_vector2i_sign(const godot_vector2i *p_self);
+
+godot_vector2i GDAPI godot_vector2i_operator_add(const godot_vector2i *p_self, const godot_vector2i *p_b);
+
+godot_vector2i GDAPI godot_vector2i_operator_subtract(const godot_vector2i *p_self, const godot_vector2i *p_b);
+
+godot_vector2i GDAPI godot_vector2i_operator_multiply_vector(const godot_vector2i *p_self, const godot_vector2i *p_b);
+
+godot_vector2i GDAPI godot_vector2i_operator_multiply_scalar(const godot_vector2i *p_self, const godot_int p_b);
+
+godot_vector2i GDAPI godot_vector2i_operator_divide_vector(const godot_vector2i *p_self, const godot_vector2i *p_b);
+
+godot_vector2i GDAPI godot_vector2i_operator_divide_scalar(const godot_vector2i *p_self, const godot_int p_b);
+
+godot_bool GDAPI godot_vector2i_operator_equal(const godot_vector2i *p_self, const godot_vector2i *p_b);
+
+godot_bool GDAPI godot_vector2i_operator_less(const godot_vector2i *p_self, const godot_vector2i *p_b);
+
+godot_vector2i GDAPI godot_vector2i_operator_neg(const godot_vector2i *p_self);
+
+void GDAPI godot_vector2i_set_x(godot_vector2i *p_self, const godot_int p_x);
+
+void GDAPI godot_vector2i_set_y(godot_vector2i *p_self, const godot_int p_y);
+
+godot_int GDAPI godot_vector2i_get_x(const godot_vector2i *p_self);
+
+godot_int GDAPI godot_vector2i_get_y(const godot_vector2i *p_self);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h
index 8ebf15b724..5127b8789b 100644
--- a/modules/gdnative/include/gdnative/vector3.h
+++ b/modules/gdnative/include/gdnative/vector3.h
@@ -46,6 +46,15 @@ typedef struct {
} godot_vector3;
#endif
+#define GODOT_VECTOR3I_SIZE 12
+
+#ifndef GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_VECTOR3I_SIZE];
+} godot_vector3i;
+#endif
+
// reduce extern "C" nesting for VS2013
#ifdef __cplusplus
}
@@ -64,10 +73,14 @@ typedef enum {
GODOT_VECTOR3_AXIS_Z,
} godot_vector3_axis;
+// Vector3
+
void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z);
godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self);
+godot_vector3i GDAPI godot_vector3_as_vector3i(const godot_vector3 *p_self);
+
godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self);
godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self);
@@ -102,6 +115,8 @@ godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_self);
godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self);
+godot_vector3 GDAPI godot_vector3_sign(const godot_vector3 *p_self);
+
godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self);
godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self);
@@ -142,6 +157,44 @@ void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axi
godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis);
+// Vector3i
+
+void GDAPI godot_vector3i_new(godot_vector3i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_z);
+
+godot_string GDAPI godot_vector3i_as_string(const godot_vector3i *p_self);
+
+godot_vector3 GDAPI godot_vector3i_as_vector3(const godot_vector3i *p_self);
+
+godot_int GDAPI godot_vector3i_min_axis(const godot_vector3i *p_self);
+
+godot_int GDAPI godot_vector3i_max_axis(const godot_vector3i *p_self);
+
+godot_vector3i GDAPI godot_vector3i_abs(const godot_vector3i *p_self);
+
+godot_vector3i GDAPI godot_vector3i_sign(const godot_vector3i *p_self);
+
+godot_vector3i GDAPI godot_vector3i_operator_add(const godot_vector3i *p_self, const godot_vector3i *p_b);
+
+godot_vector3i GDAPI godot_vector3i_operator_subtract(const godot_vector3i *p_self, const godot_vector3i *p_b);
+
+godot_vector3i GDAPI godot_vector3i_operator_multiply_vector(const godot_vector3i *p_self, const godot_vector3i *p_b);
+
+godot_vector3i GDAPI godot_vector3i_operator_multiply_scalar(const godot_vector3i *p_self, const godot_int p_b);
+
+godot_vector3i GDAPI godot_vector3i_operator_divide_vector(const godot_vector3i *p_self, const godot_vector3i *p_b);
+
+godot_vector3i GDAPI godot_vector3i_operator_divide_scalar(const godot_vector3i *p_self, const godot_int p_b);
+
+godot_bool GDAPI godot_vector3i_operator_equal(const godot_vector3i *p_self, const godot_vector3i *p_b);
+
+godot_bool GDAPI godot_vector3i_operator_less(const godot_vector3i *p_self, const godot_vector3i *p_b);
+
+godot_vector3i GDAPI godot_vector3i_operator_neg(const godot_vector3i *p_self);
+
+void GDAPI godot_vector3i_set_axis(godot_vector3i *p_self, const godot_vector3_axis p_axis, const godot_int p_val);
+
+godot_int GDAPI godot_vector3i_get_axis(const godot_vector3i *p_self, const godot_vector3_axis p_axis);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index 0fb5180103..825033c99c 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -45,7 +45,7 @@ typedef enum {
GODOT_METHOD_RPC_MODE_REMOTESYNC,
GODOT_METHOD_RPC_MODE_MASTERSYNC,
GODOT_METHOD_RPC_MODE_PUPPETSYNC,
-} godot_method_rpc_mode;
+} godot_nativescript_method_rpc_mode;
typedef enum {
GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
@@ -82,7 +82,7 @@ typedef enum {
GODOT_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
GODOT_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
GODOT_PROPERTY_HINT_MAX,
-} godot_property_hint;
+} godot_nativescript_property_hint;
typedef enum {
@@ -106,106 +106,95 @@ typedef enum {
GODOT_PROPERTY_USAGE_DEFAULT = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK,
GODOT_PROPERTY_USAGE_DEFAULT_INTL = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK | GODOT_PROPERTY_USAGE_INTERNATIONALIZED,
GODOT_PROPERTY_USAGE_NOEDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
-} godot_property_usage_flags;
+} godot_nativescript_property_usage_flags;
typedef struct {
- godot_method_rpc_mode rset_type;
+ godot_nativescript_method_rpc_mode rset_type;
godot_int type;
- godot_property_hint hint;
+ godot_nativescript_property_hint hint;
godot_string hint_string;
- godot_property_usage_flags usage;
+ godot_nativescript_property_usage_flags usage;
godot_variant default_value;
-} godot_property_attributes;
+} godot_nativescript_property_attributes;
typedef struct {
// instance pointer, method_data - return user data
GDCALLINGCONV void *(*create_func)(godot_object *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_create_func;
+} godot_nativescript_instance_create_func;
typedef struct {
// instance pointer, method data, user data
GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_destroy_func;
+} godot_nativescript_instance_destroy_func;
-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);
+void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func);
-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);
+void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func);
typedef struct {
- godot_method_rpc_mode rpc_type;
-} godot_method_attributes;
+ godot_nativescript_method_rpc_mode rpc_type;
+} godot_nativescript_method_attributes;
+
+typedef struct {
+ godot_string name;
+
+ godot_variant_type type;
+ godot_nativescript_property_hint hint;
+ godot_string hint_string;
+} godot_nativescript_method_argument;
typedef struct {
// instance pointer, method data, user data, num args, args - return result as varaint
GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_method;
+} godot_nativescript_instance_method;
-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);
+void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_nativescript_method_attributes p_attr, godot_nativescript_instance_method p_method);
+void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_nativescript_method_argument *p_args);
typedef struct {
// instance pointer, method data, user data, value
GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
-} godot_property_set_func;
+} godot_nativescript_property_set_func;
typedef struct {
// instance pointer, method data, user data, value
GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
-} godot_property_get_func;
+} godot_nativescript_property_get_func;
-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);
+void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_nativescript_property_attributes *p_attr, godot_nativescript_property_set_func p_set_func, godot_nativescript_property_get_func p_get_func);
typedef struct {
godot_string name;
godot_int type;
- godot_property_hint hint;
+ godot_nativescript_property_hint hint;
godot_string hint_string;
- godot_property_usage_flags usage;
+ godot_nativescript_property_usage_flags usage;
godot_variant default_value;
-} godot_signal_argument;
+} godot_nativescript_signal_argument;
typedef struct {
godot_string name;
int num_args;
- godot_signal_argument *args;
+ godot_nativescript_signal_argument *args;
int num_default_args;
godot_variant *default_args;
-} godot_signal;
+} godot_nativescript_signal;
-void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal);
+void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal);
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance);
-/*
- *
- *
- * NativeScript 1.1
- *
- *
- */
-
-// method registering with argument names
-
-typedef struct {
- godot_string name;
-
- godot_variant_type type;
- godot_property_hint hint;
- godot_string hint_string;
-} godot_method_arg;
-
-void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_method_arg *p_args);
-
// documentation
void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation);
@@ -230,9 +219,9 @@ typedef struct {
GDCALLINGCONV bool (*refcount_decremented_instance_binding)(void *, godot_object *);
void *data;
GDCALLINGCONV void (*free_func)(void *);
-} godot_instance_binding_functions;
+} godot_nativescript_instance_binding_functions;
-int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions);
+int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_nativescript_instance_binding_functions p_binding_functions);
void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx);
void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object);
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/include/videodecoder/godot_videodecoder.h b/modules/gdnative/include/videodecoder/godot_videodecoder.h
index 3e91a2e9ac..16c92abd22 100644
--- a/modules/gdnative/include/videodecoder/godot_videodecoder.h
+++ b/modules/gdnative/include/videodecoder/godot_videodecoder.h
@@ -46,7 +46,7 @@ typedef struct
void *next;
void *(*constructor)(godot_object *);
void (*destructor)(void *);
- const char *(*get_plugin_name)(void);
+ const char *(*get_plugin_name)();
const char **(*get_supported_extensions)(int *count);
godot_bool (*open_file)(void *, void *); // data struct, and a FileAccess pointer
godot_real (*get_length)(const void *);
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<String> &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<ClassAPI> generate_c_api_classes() {
-
List<ClassAPI> api;
List<StringName> classes;
@@ -410,7 +405,6 @@ List<ClassAPI> generate_c_api_classes() {
* Generates the JSON source from the API in p_api
*/
static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
-
// I'm sorry for the \t mess
List<String> source;
@@ -520,7 +514,6 @@ static List<String> generate_c_api_json(const List<ClassAPI> &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..e47548f3e9 100644
--- a/modules/gdnative/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -51,8 +51,7 @@ 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) {
-
+void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
@@ -84,8 +83,7 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char
classes->insert(p_name, desc);
}
-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) {
-
+void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
@@ -118,8 +116,7 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const
classes->insert(p_name, desc);
}
-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) {
-
+void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_nativescript_method_attributes p_attr, godot_nativescript_instance_method p_method) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -138,8 +135,7 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha
E->get().methods.insert(p_function_name, method);
}
-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) {
-
+void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_nativescript_property_attributes *p_attr, godot_nativescript_property_set_func p_set_func, godot_nativescript_property_get_func p_get_func) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -163,8 +159,7 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c
E->get().properties.insert(p_path, property);
}
-void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal) {
-
+void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -176,7 +171,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
for (int i = 0; i < p_signal->num_args; i++) {
PropertyInfo info;
- godot_signal_argument arg = p_signal->args[i];
+ godot_nativescript_signal_argument arg = p_signal->args[i];
info.hint = (PropertyHint)arg.hint;
info.hint_string = *(String *)&arg.hint_string;
@@ -189,7 +184,7 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
for (int i = 0; i < p_signal->num_default_args; i++) {
Variant *v;
- godot_signal_argument attrib = p_signal->args[i];
+ godot_nativescript_signal_argument attrib = p_signal->args[i];
v = (Variant *)&attrib.default_value;
@@ -209,8 +204,9 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
Object *instance = (Object *)p_instance;
- if (!instance)
+ if (!instance) {
return nullptr;
+ }
if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) {
return ((NativeScriptInstance *)instance->get_script_instance())->userdata;
}
@@ -225,7 +221,7 @@ void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
*
*/
-void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_method_arg *p_args) {
+void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_nativescript_method_argument *p_args) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -239,7 +235,7 @@ void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_h
List<PropertyInfo> args;
for (int i = 0; i < p_num_args; i++) {
- godot_method_arg arg = p_args[i];
+ godot_nativescript_method_argument arg = p_args[i];
String name = *(String *)&arg.name;
String hint_string = *(String *)&arg.hint_string;
@@ -315,7 +311,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()) {
@@ -326,14 +321,15 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object)
return nullptr;
}
- if (script->get_script_desc())
+ if (script->get_script_desc()) {
return script->get_script_desc()->type_tag;
+ }
}
return nullptr;
}
-int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions) {
+int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_nativescript_instance_binding_functions p_binding_functions) {
return NativeScriptLanguage::get_singleton()->register_binding_functions(p_binding_functions);
}
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index ed3ec44bf7..06b9534fce 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
@@ -185,8 +184,9 @@ bool NativeScript::can_instance() const {
Ref<Script> NativeScript::get_base_script() const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return Ref<Script>();
+ }
NativeScript *script = (NativeScript *)NSL->create_script();
Ref<NativeScript> ns = Ref<NativeScript>(script);
@@ -200,14 +200,14 @@ Ref<Script> NativeScript::get_base_script() const {
StringName NativeScript::get_instance_base_type() const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return "";
+ }
return script_data->base_native_type;
}
ScriptInstance *NativeScript::instance_create(Object *p_this) {
-
NativeScriptDesc *script_data = get_script_desc();
if (!script_data) {
@@ -274,8 +274,9 @@ bool NativeScript::has_method(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
- if (script_data->methods.has(p_method))
+ if (script_data->methods.has(p_method)) {
return true;
+ }
script_data = script_data->base_data;
}
@@ -285,14 +286,16 @@ bool NativeScript::has_method(const StringName &p_method) const {
MethodInfo NativeScript::get_method_info(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return MethodInfo();
+ }
while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method);
- if (M)
+ if (M) {
return M->get().info;
+ }
script_data = script_data->base_data;
}
@@ -306,8 +309,9 @@ bool NativeScript::is_valid() const {
bool NativeScript::is_tool() const {
NativeScriptDesc *script_data = get_script_desc();
- if (script_data)
+ if (script_data) {
return script_data->is_tool;
+ }
return false;
}
@@ -320,8 +324,9 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
- if (script_data->signals_.has(p_signal))
+ if (script_data->signals_.has(p_signal)) {
return true;
+ }
script_data = script_data->base_data;
}
return false;
@@ -330,13 +335,13 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const {
void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return;
+ }
Set<MethodInfo> signals_;
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) {
signals_.insert(S->get().signal);
}
@@ -357,8 +362,9 @@ bool NativeScript::get_property_default_value(const StringName &p_property, Vari
P = script_data->properties.find(p_property);
script_data = script_data->base_data;
}
- if (!P)
+ if (!P) {
return false;
+ }
r_value = P.get().default_value;
return true;
@@ -370,13 +376,13 @@ void NativeScript::update_exports() {
void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return;
+ }
Set<MethodInfo> methods;
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
methods.insert(E->get().info);
}
@@ -408,13 +414,11 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
}
Vector<ScriptNetData> NativeScript::get_rpc_methods() const {
-
Vector<ScriptNetData> v;
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
if (E->get().rpc_mode != GODOT_METHOD_RPC_MODE_DISABLED) {
ScriptNetData nd;
@@ -434,7 +438,6 @@ uint16_t NativeScript::get_rpc_method_id(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) {
return E->get().rpc_method_id;
@@ -452,7 +455,6 @@ StringName NativeScript::get_rpc_method(uint16_t p_id) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
if (E->get().rpc_method_id == p_id) {
return E->key();
@@ -466,13 +468,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<StringName, NativeScriptDesc::Method>::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 +503,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<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) {
switch (E->get().rpc_mode) {
@@ -542,7 +540,6 @@ Vector<ScriptNetData> NativeScript::get_rset_properties() const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
if (E.get().rset_mode != GODOT_METHOD_RPC_MODE_DISABLED) {
ScriptNetData nd;
@@ -561,7 +558,6 @@ uint16_t NativeScript::get_rset_property_id(const StringName &p_variable) const
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
if (E) {
return E.get().rset_property_id;
@@ -579,7 +575,6 @@ StringName NativeScript::get_rset_property(uint16_t p_id) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
if (E.get().rset_property_id == p_id) {
return E.key();
@@ -593,13 +588,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<StringName, NativeScriptDesc::Property>::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 +623,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<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
if (E) {
switch (E.get().rset_mode) {
@@ -677,7 +668,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<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method);
if (method) {
@@ -696,7 +686,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<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name);
if (signal) {
@@ -715,7 +704,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<StringName, NativeScriptDesc::Property>::Element property = script_data->properties.find(p_path);
if (property) {
@@ -729,7 +717,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();
@@ -840,6 +827,7 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value)
}
return false;
}
+
bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
@@ -884,10 +872,8 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
-
Map<StringName, NativeScriptDesc::Method>::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 +922,9 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *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<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name);
if (P) {
*r_is_valid = true;
@@ -961,7 +945,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) {
@@ -1017,17 +1000,20 @@ String NativeScriptInstance::to_string(bool *r_valid) {
Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret.operator String();
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return String();
}
@@ -1127,11 +1113,11 @@ void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method,
}
NativeScriptInstance::~NativeScriptInstance() {
-
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
- if (!script_data)
+ if (!script_data) {
return;
+ }
script_data->destroy_func.destroy_func((godot_object *)owner, script_data->destroy_func.method_data, userdata);
@@ -1145,16 +1131,13 @@ NativeScriptInstance::~NativeScriptInstance() {
NativeScriptLanguage *NativeScriptLanguage::singleton;
void NativeScriptLanguage::_unload_stuff(bool p_reload) {
-
Map<String, Ref<GDNative>> erase_and_unload;
for (Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.front(); L; L = L->next()) {
-
String lib_path = L->key();
Map<StringName, NativeScriptDesc> classes = L->get();
if (p_reload) {
-
Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path);
Ref<GDNative> gdn;
@@ -1184,28 +1167,32 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {
}
for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
-
// free property stuff first
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
- if (P.get().getter.free_func)
+ if (P.get().getter.free_func) {
P.get().getter.free_func(P.get().getter.method_data);
+ }
- if (P.get().setter.free_func)
+ if (P.get().setter.free_func) {
P.get().setter.free_func(P.get().setter.method_data);
+ }
}
// free method stuff
for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
- if (M->get().method.free_func)
+ if (M->get().method.free_func) {
M->get().method.free_func(M->get().method.method_data);
+ }
}
// free constructor/destructor
- if (C->get().create_func.free_func)
+ if (C->get().create_func.free_func) {
C->get().create_func.free_func(C->get().create_func.method_data);
+ }
- if (C->get().destroy_func.free_func)
+ if (C->get().destroy_func.free_func) {
C->get().destroy_func.free_func(C->get().destroy_func.method_data);
+ }
}
erase_and_unload.insert(lib_path, gdn);
@@ -1253,13 +1240,10 @@ NativeScriptLanguage::NativeScriptLanguage() {
}
NativeScriptLanguage::~NativeScriptLanguage() {
-
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
-
Ref<GDNative> 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 +1269,6 @@ void _add_reload_node() {
}
void NativeScriptLanguage::init() {
-
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
List<String> args = OS::get_singleton()->get_cmdline_args();
@@ -1304,22 +1287,29 @@ void NativeScriptLanguage::init() {
EditorNode::add_init_callback(&_add_reload_node);
#endif
}
+
String NativeScriptLanguage::get_type() const {
return "NativeScript";
}
+
String NativeScriptLanguage::get_extension() const {
return "gdns";
}
+
Error NativeScriptLanguage::execute_file(const String &p_path) {
return OK; // Qué?
}
+
void NativeScriptLanguage::finish() {
_unload_stuff();
}
+
void NativeScriptLanguage::get_reserved_words(List<String> *p_words) const {
}
+
void NativeScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
}
+
void NativeScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
}
@@ -1328,6 +1318,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const
s->set_class_name(p_class_name);
return Ref<NativeScript>(s);
}
+
bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
return true;
}
@@ -1336,20 +1327,26 @@ Script *NativeScriptLanguage::create_script() const {
NativeScript *script = memnew(NativeScript);
return script;
}
+
bool NativeScriptLanguage::has_named_classes() const {
return true;
}
+
bool NativeScriptLanguage::supports_builtin_mode() const {
return true;
}
+
int NativeScriptLanguage::find_function(const String &p_function, const String &p_code) const {
return -1;
}
+
String NativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
return "";
}
+
void NativeScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
}
+
void NativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
}
@@ -1357,27 +1354,36 @@ void NativeScriptLanguage::add_global_constant(const StringName &p_variable, con
String NativeScriptLanguage::debug_get_error() const {
return "";
}
+
int NativeScriptLanguage::debug_get_stack_level_count() const {
return -1;
}
+
int NativeScriptLanguage::debug_get_stack_level_line(int p_level) const {
return -1;
}
+
String NativeScriptLanguage::debug_get_stack_level_function(int p_level) const {
return "";
}
+
String NativeScriptLanguage::debug_get_stack_level_source(int p_level) const {
return "";
}
+
void NativeScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
}
+
void NativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
}
+
void NativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
}
+
String NativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
return "";
}
+
// Debugging stuff end.
void NativeScriptLanguage::reload_all_scripts() {
@@ -1385,6 +1391,7 @@ void NativeScriptLanguage::reload_all_scripts() {
void NativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
}
+
void NativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("gdns");
}
@@ -1419,8 +1426,9 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a
int current = 0;
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
- if (current >= p_info_max)
+ if (current >= p_info_max) {
break;
+ }
p_info_arr[current].call_count = d->get().call_count;
p_info_arr[current].self_time = d->get().self_time;
@@ -1442,8 +1450,9 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in
int current = 0;
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
- if (current >= p_info_max)
+ if (current >= p_info_max) {
break;
+ }
if (d->get().last_frame_call_count) {
p_info_arr[current].call_count = d->get().last_frame_call_count;
@@ -1489,8 +1498,7 @@ void NativeScriptLanguage::profiling_add_data(StringName p_signature, uint64_t p
#endif
}
-int NativeScriptLanguage::register_binding_functions(godot_instance_binding_functions p_binding_functions) {
-
+int NativeScriptLanguage::register_binding_functions(godot_nativescript_instance_binding_functions p_binding_functions) {
// find index
int idx = -1;
@@ -1521,14 +1529,16 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) {
Vector<void *> &binding_data = *E->get();
- if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data)
+ if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) {
binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]);
+ }
}
binding_functions.write[p_idx].first = false;
- if (binding_functions[p_idx].second.free_func)
+ if (binding_functions[p_idx].second.free_func) {
binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data);
+ }
}
void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) {
@@ -1538,8 +1548,9 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx);
- if (!binding_data)
+ if (!binding_data) {
return nullptr; // should never happen.
+ }
if (binding_data->size() <= p_idx) {
// okay, add new elements here.
@@ -1553,7 +1564,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 +1574,6 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
}
void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
-
Vector<void *> *binding_data = new Vector<void *>;
binding_data->resize(binding_functions.size());
@@ -1579,15 +1588,16 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
}
void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
-
- if (!p_data)
+ if (!p_data) {
return;
+ }
Vector<void *> &binding_data = *(Vector<void *> *)p_data;
for (int i = 0; i < binding_data.size(); i++) {
- if (!binding_data[i])
+ if (!binding_data[i]) {
continue;
+ }
if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) {
binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]);
@@ -1600,20 +1610,22 @@ 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)
+ if (!data) {
return;
+ }
Vector<void *> &binding_data = *(Vector<void *> *)data;
for (int i = 0; i < binding_data.size(); i++) {
- if (!binding_data[i])
+ if (!binding_data[i]) {
continue;
+ }
- if (!binding_functions[i].first)
+ if (!binding_functions[i].first) {
continue;
+ }
if (binding_functions[i].second.refcount_incremented_instance_binding) {
binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object);
@@ -1622,22 +1634,24 @@ 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)
+ if (!data) {
return true;
+ }
Vector<void *> &binding_data = *(Vector<void *> *)data;
bool can_die = true;
for (int i = 0; i < binding_data.size(); i++) {
- if (!binding_data[i])
+ if (!binding_data[i]) {
continue;
+ }
- if (!binding_functions[i].first)
+ if (!binding_functions[i].first) {
continue;
+ }
if (binding_functions[i].second.refcount_decremented_instance_binding) {
can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object);
@@ -1658,13 +1672,15 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam
}
const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const {
- if (!global_type_tags.has(p_idx))
+ if (!global_type_tags.has(p_idx)) {
return nullptr;
+ }
const HashMap<StringName, const void *> &tags = global_type_tags[p_idx];
- if (!tags.has(p_class_name))
+ if (!tags.has(p_class_name)) {
return nullptr;
+ }
const void *tag = tags.get(p_class_name);
@@ -1700,8 +1716,9 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>());
- if (!library_script_users.has(lib_path))
+ if (!library_script_users.has(lib_path)) {
library_script_users.insert(lib_path, Set<NativeScript *>());
+ }
void *proc_ptr;
@@ -1741,13 +1758,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<String, Ref<GDNative>>::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);
@@ -1812,16 +1827,20 @@ String NativeScriptLanguage::get_global_class_name(const String &p_path, String
if (!p_path.empty()) {
Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript");
if (script.is_valid()) {
- if (r_base_type)
+ if (r_base_type) {
*r_base_type = script->get_instance_base_type();
- if (r_icon_path)
+ }
+ if (r_icon_path) {
*r_icon_path = script->get_script_class_icon_path();
+ }
return script->get_script_class_name();
}
- if (r_base_type)
+ if (r_base_type) {
*r_base_type = String();
- if (r_icon_path)
+ }
+ if (r_icon_path) {
*r_icon_path = String();
+ }
}
return String();
}
@@ -1835,14 +1854,13 @@ void NativeReloadNode::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_WM_FOCUS_OUT: {
-
- if (unloaded)
+ if (unloaded) {
break;
+ }
MutexLock lock(NSL->mutex);
NSL->_unload_stuff(true);
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
-
Ref<GDNative> gdn = L->get();
if (gdn.is_null()) {
@@ -1870,14 +1888,13 @@ void NativeReloadNode::_notification(int p_what) {
} break;
case NOTIFICATION_WM_FOCUS_IN: {
-
- if (!unloaded)
+ if (!unloaded) {
break;
+ }
MutexLock lock(NSL->mutex);
Set<StringName> libs_to_remove;
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
-
Ref<GDNative> gdn = L->get();
if (gdn.is_null()) {
@@ -1915,8 +1932,9 @@ void NativeReloadNode::_notification(int p_what) {
for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) {
NativeScript *script = S->get();
- if (script->placeholders.size() == 0)
+ if (script->placeholders.size() == 0) {
continue;
+ }
for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
script->_update_placeholder(P->get());
@@ -1952,8 +1970,9 @@ bool ResourceFormatLoaderNativeScript::handles_type(const String &p_type) const
String ResourceFormatLoaderNativeScript::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (el == "gdns")
+ if (el == "gdns") {
return "NativeScript";
+ }
return "";
}
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 7e7598e06c..fabf4bb87e 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -43,20 +43,21 @@
#include "scene/main/node.h"
#include "modules/gdnative/gdnative.h"
+
#include <nativescript/godot_nativescript.h>
struct NativeScriptDesc {
-
struct Method {
- godot_instance_method method;
+ godot_nativescript_instance_method method;
MethodInfo info;
int rpc_mode;
uint16_t rpc_method_id;
String documentation;
};
+
struct Property {
- godot_property_set_func setter;
- godot_property_get_func getter;
+ godot_nativescript_property_set_func setter;
+ godot_nativescript_property_get_func getter;
PropertyInfo info;
Variant default_value;
int rset_mode;
@@ -69,35 +70,26 @@ struct NativeScriptDesc {
String documentation;
};
- uint16_t rpc_count;
+ uint16_t rpc_count = 0;
Map<StringName, Method> methods;
- uint16_t rset_count;
+ uint16_t rset_count = 0;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base;
StringName base_native_type;
NativeScriptDesc *base_data;
- godot_instance_create_func create_func;
- godot_instance_destroy_func destroy_func;
+ godot_nativescript_instance_create_func create_func;
+ godot_nativescript_instance_destroy_func destroy_func;
String documentation;
- const void *type_tag;
+ const void *type_tag = nullptr;
bool is_tool;
- inline NativeScriptDesc() :
- rpc_count(0),
- methods(),
- rset_count(0),
- properties(),
- signals_(),
- base(),
- base_native_type(),
- documentation(),
- type_tag(nullptr) {
- zeromem(&create_func, sizeof(godot_instance_create_func));
- zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
+ inline NativeScriptDesc() {
+ zeromem(&create_func, sizeof(godot_nativescript_instance_create_func));
+ zeromem(&destroy_func, sizeof(godot_nativescript_instance_destroy_func));
}
};
@@ -201,7 +193,6 @@ public:
};
class NativeScriptInstance : public ScriptInstance {
-
friend class NativeScript;
Object *owner;
@@ -252,7 +243,6 @@ public:
class NativeReloadNode;
class NativeScriptLanguage : public ScriptLanguage {
-
friend class NativeScript;
friend class NativeScriptInstance;
friend class NativeReloadNode;
@@ -277,7 +267,7 @@ private:
void call_libraries_cb(const StringName &name);
- Vector<Pair<bool, godot_instance_binding_functions>> binding_functions;
+ Vector<Pair<bool, godot_nativescript_instance_binding_functions>> binding_functions;
Set<Vector<void *> *> binding_instances;
Map<int, HashMap<StringName, const void *>> global_type_tags;
@@ -370,7 +360,7 @@ public:
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
- int register_binding_functions(godot_instance_binding_functions p_binding_functions);
+ int register_binding_functions(godot_nativescript_instance_binding_functions p_binding_functions);
void unregister_binding_functions(int p_idx);
void *get_instance_binding_data(int p_idx, Object *p_object);
@@ -396,14 +386,13 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const {
class NativeReloadNode : public Node {
GDCLASS(NativeReloadNode, Node);
- bool unloaded;
+ bool unloaded = false;
public:
static void _bind_methods();
void _notification(int p_what);
- NativeReloadNode() :
- unloaded(false) {}
+ NativeReloadNode() {}
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
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..4feee4f4a5 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp
@@ -40,8 +40,9 @@ ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptL
}
RES ResourceFormatLoaderPluginScript::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)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
PluginScript *script = memnew(PluginScript);
script->init(_language);
@@ -55,8 +56,9 @@ RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p
script->reload();
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return scriptres;
}
@@ -71,8 +73,9 @@ bool ResourceFormatLoaderPluginScript::handles_type(const String &p_type) const
String ResourceFormatLoaderPluginScript::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (el == _language->get_extension())
+ if (el == _language->get_extension()) {
return _language->get_type();
+ }
return "";
}
@@ -101,13 +104,11 @@ Error ResourceFormatSaverPluginScript::save(const String &p_path, const RES &p_r
}
void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (Object::cast_to<PluginScript>(*p_resource)) {
p_extensions->push_back(_language->get_extension());
}
}
bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const {
-
return Object::cast_to<PluginScript>(*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 6b303c8716..87c6288806 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) {
@@ -156,10 +154,12 @@ Ref<Script> PluginScript::get_base_script() const {
}
StringName PluginScript::get_instance_base_type() const {
- if (_native_parent)
+ if (_native_parent) {
return _native_parent;
- if (_ref_base_parent.is_valid())
+ }
+ if (_ref_base_parent.is_valid()) {
return _ref_base_parent->get_instance_base_type();
+ }
return StringName();
}
@@ -167,7 +167,6 @@ void PluginScript::update_exports() {
#ifdef TOOLS_ENABLED
ASSERT_SCRIPT_VALID();
if (placeholders.size()) {
-
//update placeholders if any
Map<StringName, Variant> propdefvalues;
List<PropertyInfo> propinfos;
@@ -229,8 +228,9 @@ String PluginScript::get_source_code() const {
}
void PluginScript::set_source_code(const String &p_code) {
- if (_source == p_code)
+ if (_source == p_code) {
return;
+ }
_source = p_code;
}
@@ -244,11 +244,13 @@ Error PluginScript::reload(bool p_keep_state) {
_valid = false;
String basedir = _path;
- if (basedir == "")
+ if (basedir == "") {
basedir = get_path();
+ }
- if (basedir != "")
+ if (basedir != "") {
basedir = basedir.get_base_dir();
+ }
if (_data) {
_desc->finish(_data);
@@ -281,7 +283,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 +435,6 @@ ScriptLanguage *PluginScript::get_language() const {
}
Error PluginScript::load_source_code(const String &p_path) {
-
Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -476,11 +476,11 @@ void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
int PluginScript::get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
- if (_member_lines.has(p_member))
+ if (_member_lines.has(p_member)) {
return _member_lines[p_member];
- else
+ }
#endif
- return -1;
+ return -1;
}
Vector<ScriptNetData> PluginScript::get_rpc_methods() const {
@@ -499,15 +499,17 @@ uint16_t PluginScript::get_rpc_method_id(const StringName &p_method) const {
StringName PluginScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
ASSERT_SCRIPT_VALID_V(StringName());
- if (p_rpc_method_id >= _rpc_methods.size())
+ if (p_rpc_method_id >= _rpc_methods.size()) {
return StringName();
+ }
return _rpc_methods[p_rpc_method_id].name;
}
MultiplayerAPI::RPCMode PluginScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
- if (p_rpc_method_id >= _rpc_methods.size())
+ if (p_rpc_method_id >= _rpc_methods.size()) {
return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
return _rpc_methods[p_rpc_method_id].mode;
}
@@ -532,15 +534,17 @@ uint16_t PluginScript::get_rset_property_id(const StringName &p_property) const
StringName PluginScript::get_rset_property(const uint16_t p_rset_property_id) const {
ASSERT_SCRIPT_VALID_V(StringName());
- if (p_rset_property_id >= _rpc_variables.size())
+ if (p_rset_property_id >= _rpc_variables.size()) {
return StringName();
+ }
return _rpc_variables[p_rset_property_id].name;
}
MultiplayerAPI::RPCMode PluginScript::get_rset_mode_by_id(const uint16_t p_rset_property_id) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
- if (p_rset_property_id >= _rpc_variables.size())
+ if (p_rset_property_id >= _rpc_variables.size()) {
return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
return _rpc_variables[p_rset_property_id].mode;
}
@@ -550,11 +554,6 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
}
PluginScript::PluginScript() :
- _data(nullptr),
- _desc(nullptr),
- _language(nullptr),
- _tool(false),
- _valid(false),
_script_list(this) {
}
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 70b9ca980b..659289ef9b 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -38,18 +38,17 @@
#include <pluginscript/godot_pluginscript.h>
class PluginScript : public Script {
-
GDCLASS(PluginScript, Script);
friend class PluginScriptInstance;
friend class PluginScriptLanguage;
private:
- godot_pluginscript_script_data *_data;
- const godot_pluginscript_script_desc *_desc;
- PluginScriptLanguage *_language;
- bool _tool;
- bool _valid;
+ godot_pluginscript_script_data *_data = nullptr;
+ const godot_pluginscript_script_desc *_desc = nullptr;
+ PluginScriptLanguage *_language = nullptr;
+ bool _tool = false;
+ bool _valid = false;
Ref<Script> _ref_base_parent;
StringName _native_parent;
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 67a286ee2e..136af5bd1e 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<String> &p_features);
};
@@ -77,7 +76,6 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
Ref<ConfigFile> config = lib->get_config_file();
{
-
List<String> 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<GDNativeLibraryResourceLoader> resource_loader_gdnlib;
Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib;
void register_gdnative_types() {
-
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(editor_init_callback);
@@ -259,8 +254,9 @@ void register_gdnative_types() {
for (int i = 0; i < singletons.size(); i++) {
String path = singletons[i];
- if (excluded.has(path))
+ if (excluded.has(path)) {
continue;
+ }
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
Ref<GDNative> singleton;
@@ -287,9 +283,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<ResourceFormatLoaderVideoStreamGDNative> 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 f7d87595af..9d9c5b6473 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);
}
}
@@ -202,32 +201,19 @@ void VideoStreamPlaybackGDNative::update_texture() {
// ctor and dtor
VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() :
- texture(Ref<ImageTexture>(memnew(ImageTexture))),
- playing(false),
- paused(false),
- mix_udata(nullptr),
- mix_callback(nullptr),
- num_channels(-1),
- time(0),
- seek_backward(false),
- mix_rate(0),
- delay_compensation(0),
- pcm(nullptr),
- pcm_write_idx(0),
- samples_decoded(0),
- file(nullptr),
- interface(nullptr),
- data_struct(nullptr) {}
+ texture(Ref<ImageTexture>(memnew(ImageTexture))) {}
VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() {
cleanup();
}
void VideoStreamPlaybackGDNative::cleanup() {
- if (data_struct)
+ if (data_struct) {
interface->destructor(data_struct);
- if (pcm)
+ }
+ if (pcm) {
memfree(pcm);
+ }
pcm = nullptr;
time = 0;
num_channels = -1;
@@ -255,7 +241,6 @@ bool VideoStreamPlaybackGDNative::is_paused() const {
}
void VideoStreamPlaybackGDNative::play() {
-
stop();
playing = true;
@@ -274,8 +259,9 @@ void VideoStreamPlaybackGDNative::stop() {
void VideoStreamPlaybackGDNative::seek(float p_time) {
ERR_FAIL_COND(interface == nullptr);
interface->seek(data_struct, p_time);
- if (p_time < time)
+ if (p_time < time) {
seek_backward = true;
+ }
time = p_time;
// reset audio buffers
memset(pcm, 0, num_channels * AUX_BUFFER_SIZE * sizeof(float));
@@ -297,7 +283,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);
}
@@ -317,7 +302,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;
}
@@ -339,27 +323,26 @@ int VideoStreamPlaybackGDNative::get_mix_rate() const {
Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() {
Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative);
VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower());
- if (decoder == nullptr)
+ if (decoder == nullptr) {
return nullptr;
+ }
pb->set_interface(decoder->interface);
pb->set_audio_track(audio_track);
- if (pb->open_file(file))
+ if (pb->open_file(file)) {
return pb;
+ }
return nullptr;
}
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);
@@ -367,7 +350,6 @@ void VideoStreamGDNative::_bind_methods() {
}
void VideoStreamGDNative::set_audio_track(int p_track) {
-
audio_track = p_track;
}
@@ -405,7 +387,8 @@ bool ResourceFormatLoaderVideoStreamGDNative::handles_type(const String &p_type)
String ResourceFormatLoaderVideoStreamGDNative::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (VideoDecoderServer::get_instance()->get_extensions().has(el))
+ if (VideoDecoderServer::get_instance()->get_extensions().has(el)) {
return "VideoStreamGDNative";
+ }
return "";
}
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index 092e10a0f5..53017a6a97 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -37,13 +37,11 @@
#include "scene/resources/video_stream.h"
struct VideoDecoderGDNative {
- const godot_videodecoder_interface_gdnative *interface;
- String plugin_name;
+ const godot_videodecoder_interface_gdnative *interface = nullptr;
+ String plugin_name = "none";
Vector<String> supported_extensions;
- VideoDecoderGDNative() :
- interface(nullptr),
- plugin_name("none") {}
+ VideoDecoderGDNative() {}
VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) :
interface(p_interface),
@@ -88,8 +86,9 @@ public:
}
VideoDecoderGDNative *get_decoder(const String &extension) {
- if (extensions.size() == 0 || !extensions.has(extension))
+ if (extensions.size() == 0 || !extensions.has(extension)) {
return nullptr;
+ }
return decoders[extensions[extension]];
}
@@ -107,27 +106,26 @@ public:
};
class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
-
GDCLASS(VideoStreamPlaybackGDNative, VideoStreamPlayback);
Ref<ImageTexture> texture;
- bool playing;
- bool paused;
+ bool playing = false;
+ bool paused = false;
Vector2 texture_size;
- void *mix_udata;
- AudioMixCallback mix_callback;
+ void *mix_udata = nullptr;
+ AudioMixCallback mix_callback = nullptr;
- int num_channels;
- float time;
- bool seek_backward;
- int mix_rate;
- double delay_compensation;
+ int num_channels = -1;
+ float time = 0;
+ bool seek_backward = false;
+ int mix_rate = 0;
+ double delay_compensation = 0;
- float *pcm;
- int pcm_write_idx;
- int samples_decoded;
+ float *pcm = nullptr;
+ int pcm_write_idx = 0;
+ int samples_decoded = 0;
void cleanup();
void update_texture();
@@ -135,10 +133,10 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
protected:
String file_name;
- FileAccess *file;
+ FileAccess *file = nullptr;
- const godot_videodecoder_interface_gdnative *interface;
- void *data_struct;
+ const godot_videodecoder_interface_gdnative *interface = nullptr;
+ void *data_struct = nullptr;
public:
VideoStreamPlaybackGDNative();
@@ -177,11 +175,10 @@ public:
};
class VideoStreamGDNative : public VideoStream {
-
GDCLASS(VideoStreamGDNative, VideoStream);
String file;
- int audio_track;
+ int audio_track = 0;
protected:
static void
@@ -194,7 +191,7 @@ public:
virtual void set_audio_track(int p_track);
virtual Ref<VideoStreamPlayback> instance_playback();
- VideoStreamGDNative() { audio_track = 0; }
+ VideoStreamGDNative() {}
};
class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader {
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 278c27ae22..c80cdcfeab 100644
--- a/modules/gdnavigation/gd_navigation_server.cpp
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -114,8 +114,7 @@
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
GdNavigationServer::GdNavigationServer() :
- NavigationServer3D(),
- active(true) {
+ NavigationServer3D() {
}
GdNavigationServer::~GdNavigationServer() {
@@ -250,9 +249,9 @@ 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)
+ if (region->get_map()->get_self() == p_map) {
return; // Pointless
+ }
region->get_map()->remove_region(region);
region->set_map(nullptr);
@@ -305,8 +304,9 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
ERR_FAIL_COND(agent == nullptr);
if (agent->get_map()) {
- if (agent->get_map()->get_self() == p_map)
+ if (agent->get_map()->get_self() == p_map) {
return; // Pointless
+ }
agent->get_map()->remove_agent(agent);
}
diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h
index 01d1a4fba9..e3e02f3d7c 100644
--- a/modules/gdnavigation/gd_navigation_server.h
+++ b/modules/gdnavigation/gd_navigation_server.h
@@ -78,7 +78,7 @@ class GdNavigationServer : public NavigationServer3D {
mutable RID_PtrOwner<NavRegion> region_owner;
mutable RID_PtrOwner<RvoAgent> agent_owner;
- bool active;
+ bool active = true;
Vector<NavMap *> active_maps;
public:
diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp
index 7e6a3f7a26..7919e6a01f 100644
--- a/modules/gdnavigation/nav_map.cpp
+++ b/modules/gdnavigation/nav_map.cpp
@@ -33,6 +33,7 @@
#include "core/os/threaded_array_processor.h"
#include "nav_region.h"
#include "rvo_agent.h"
+
#include <algorithm>
/**
@@ -41,16 +42,6 @@
#define USE_ENTRY_POINT
-NavMap::NavMap() :
- up(0, 1, 0),
- cell_size(0.3),
- edge_connection_margin(5.0),
- regenerate_polygons(true),
- regenerate_links(true),
- agents_dirty(false),
- deltatime(0.0),
- map_update_id(0) {}
-
void NavMap::set_up(Vector3 p_up) {
up = p_up;
regenerate_polygons = true;
@@ -80,7 +71,6 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const {
}
Vector<Vector3> 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;
@@ -94,7 +84,6 @@ Vector<Vector3> 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);
@@ -120,7 +109,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
if (begin_poly == end_poly) {
-
Vector<Vector3> path;
path.resize(2);
path.write[0] = begin_point;
@@ -151,15 +139,15 @@ Vector<Vector3> 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++) {
gd::NavigationPoly *least_cost_poly = &navigation_polys[least_cost_id];
const gd::Edge &edge = least_cost_poly->poly->edges[i];
- if (!edge.other_polygon)
+ if (!edge.other_polygon) {
continue;
+ }
#ifdef USE_ENTRY_POINT
Vector3 edge_line[2] = {
@@ -167,7 +155,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
least_cost_poly->poly->points[(i + 1) % least_cost_poly->poly->points.size()].pos
};
- const Vector3 new_entry = Geometry::get_closest_point_to_segment(least_cost_poly->entry, edge_line);
+ const Vector3 new_entry = Geometry3D::get_closest_point_to_segment(least_cost_poly->entry, edge_line);
const float new_distance = least_cost_poly->entry.distance_to(new_entry) + least_cost_poly->traveled_distance;
#else
const float new_distance = least_cost_poly->poly->center.distance_to(edge.other_polygon->center) + least_cost_poly->traveled_distance;
@@ -181,7 +169,6 @@ Vector<Vector3> 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;
@@ -283,10 +270,8 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
if (found_route) {
-
Vector<Vector3> path;
if (p_optimize) {
-
// String pulling
gd::NavigationPoly *apex_poly = &navigation_polys[least_cost_id];
@@ -300,7 +285,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
path.push_back(end_point);
while (p) {
-
Vector3 left;
Vector3 right;
@@ -315,7 +299,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
left = p->poly->points[prev].pos;
right = p->poly->points[prev_n].pos;
- //if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5).dot(up) < 0){
if (p->poly->clockwise) {
SWAP(left, right);
}
@@ -329,7 +312,6 @@ Vector<Vector3> 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;
@@ -349,7 +331,6 @@ Vector<Vector3> 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;
@@ -362,15 +343,17 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
}
- if (p->prev_navigation_poly_id != -1)
+ if (p->prev_navigation_poly_id != -1) {
p = &navigation_polys[p->prev_navigation_poly_id];
- else
+ } else {
// The end
p = nullptr;
+ }
}
- if (path[path.size() - 1] != begin_point)
+ if (path[path.size() - 1] != begin_point) {
path.push_back(begin_point);
+ }
path.invert();
@@ -380,7 +363,6 @@ Vector<Vector3> 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
@@ -402,7 +384,6 @@ Vector<Vector3> 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;
@@ -413,7 +394,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)) {
@@ -423,7 +403,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;
}
@@ -431,12 +410,10 @@ 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(
+ Geometry3D::get_closest_points_between_segments(
p_from,
p_to,
p.points[point_id].pos,
@@ -446,7 +423,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;
}
@@ -469,7 +445,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);
@@ -496,7 +471,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);
@@ -524,7 +498,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);
@@ -588,7 +561,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();
@@ -741,8 +713,9 @@ void NavMap::sync() {
if (agents_dirty) {
std::vector<RVO::Agent *> raw_agents;
raw_agents.reserve(agents.size());
- for (size_t i(0); i < agents.size(); i++)
+ for (size_t i(0); i < agents.size(); i++) {
raw_agents.push_back(agents[i]->get_agent());
+ }
rvo.buildAgentTree(raw_agents);
}
@@ -776,17 +749,18 @@ void NavMap::dispatch_callbacks() {
void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const {
Vector3 from = path[path.size() - 1];
- if (from.distance_to(p_to_point) < CMP_EPSILON)
+ if (from.distance_to(p_to_point) < CMP_EPSILON) {
return;
+ }
Plane cut_plane;
cut_plane.normal = (from - p_to_point).cross(up);
- if (cut_plane.normal == Vector3())
+ if (cut_plane.normal == Vector3()) {
return;
+ }
cut_plane.normal.normalize();
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;
@@ -795,7 +769,6 @@ void NavMap::clip_path(const std::vector<gd::NavigationPoly> &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 4543f00926..892755f3f9 100644
--- a/modules/gdnavigation/nav_map.h
+++ b/modules/gdnavigation/nav_map.h
@@ -46,19 +46,18 @@ class RvoAgent;
class NavRegion;
class NavMap : public NavRid {
-
/// Map Up
- Vector3 up;
+ Vector3 up = Vector3(0, 1, 0);
/// To find the polygons edges the vertices are displaced in a grid where
/// each cell has the following cell_size.
- real_t cell_size;
+ real_t cell_size = 0.3;
/// This value is used to detect the near edges to connect.
- real_t edge_connection_margin;
+ real_t edge_connection_margin = 5.0;
- bool regenerate_polygons;
- bool regenerate_links;
+ bool regenerate_polygons = true;
+ bool regenerate_links = true;
std::vector<NavRegion *> regions;
@@ -69,7 +68,7 @@ class NavMap : public NavRid {
RVO::KdTree rvo;
/// Is agent array modified?
- bool agents_dirty;
+ bool agents_dirty = false;
/// All the Agents (even the controlled one)
std::vector<RvoAgent *> agents;
@@ -78,13 +77,13 @@ class NavMap : public NavRid {
std::vector<RvoAgent *> controlled_agents;
/// Physics delta time
- real_t deltatime;
+ real_t deltatime = 0.0;
/// Change the id each time the map is updated.
- uint32_t map_update_id;
+ uint32_t map_update_id = 0;
public:
- NavMap();
+ NavMap() {}
void set_up(Vector3 p_up);
Vector3 get_up() const {
diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp
index b91376f761..51fba67cc3 100644
--- a/modules/gdnavigation/nav_region.cpp
+++ b/modules/gdnavigation/nav_region.cpp
@@ -36,11 +36,6 @@
@author AndreaCatania
*/
-NavRegion::NavRegion() :
- map(nullptr),
- polygons_dirty(true) {
-}
-
void NavRegion::set_map(NavMap *p_map) {
map = p_map;
polygons_dirty = true;
@@ -75,13 +70,15 @@ void NavRegion::update_polygons() {
return;
}
- if (mesh.is_null())
+ if (mesh.is_null()) {
return;
+ }
Vector<Vector3> vertices = mesh->get_vertices();
int len = vertices.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
const Vector3 *vertices_r = vertices.ptr();
@@ -89,7 +86,6 @@ void NavRegion::update_polygons() {
// Build
for (size_t i(0); i < polygons.size(); i++) {
-
gd::Polygon &p = polygons[i];
p.owner = this;
@@ -103,7 +99,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_region.h b/modules/gdnavigation/nav_region.h
index f35ee4bea0..731855bfb5 100644
--- a/modules/gdnavigation/nav_region.h
+++ b/modules/gdnavigation/nav_region.h
@@ -45,17 +45,17 @@ class NavMap;
class NavRegion;
class NavRegion : public NavRid {
- NavMap *map;
+ NavMap *map = nullptr;
Transform transform;
Ref<NavigationMesh> mesh;
- bool polygons_dirty;
+ bool polygons_dirty = true;
/// Cache
std::vector<gd::Polygon> polygons;
public:
- NavRegion();
+ NavRegion() {}
void scratch_polygons() {
polygons_dirty = true;
diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h
index 3401284c31..40e54df553 100644
--- a/modules/gdnavigation/nav_utils.h
+++ b/modules/gdnavigation/nav_utils.h
@@ -32,6 +32,7 @@
#define NAV_UTILS_H
#include "core/math/vector3.h"
+
#include <vector>
/**
@@ -44,7 +45,6 @@ namespace gd {
struct Polygon;
union PointKey {
-
struct {
int64_t x : 21;
int64_t y : 22;
@@ -56,7 +56,6 @@ union PointKey {
};
struct EdgeKey {
-
PointKey a;
PointKey b;
@@ -80,19 +79,15 @@ struct Point {
struct Edge {
/// This edge ID
- int this_edge;
+ int this_edge = -1;
/// Other Polygon
- Polygon *other_polygon;
+ Polygon *other_polygon = nullptr;
/// The other `Polygon` at this edge id has this `Polygon`.
- int other_edge;
+ int other_edge = -1;
- Edge() {
- this_edge = -1;
- other_polygon = nullptr;
- other_edge = -1;
- }
+ Edge() {}
};
struct Polygon {
@@ -112,40 +107,29 @@ struct Polygon {
};
struct Connection {
+ Polygon *A = nullptr;
+ int A_edge = -1;
+ Polygon *B = nullptr;
+ int B_edge = -1;
- Polygon *A;
- int A_edge;
- Polygon *B;
- int B_edge;
-
- Connection() {
- A = nullptr;
- B = nullptr;
- A_edge = -1;
- B_edge = -1;
- }
+ Connection() {}
};
struct NavigationPoly {
- uint32_t self_id;
+ uint32_t self_id = 0;
/// This poly.
const Polygon *poly;
/// The previous navigation poly (id in the `navigation_poly` array).
- int prev_navigation_poly_id;
+ int prev_navigation_poly_id = -1;
/// The edge id in this `Poly` to reach the `prev_navigation_poly_id`.
- uint32_t back_navigation_edge;
+ uint32_t back_navigation_edge = 0;
/// The entry location of this poly.
Vector3 entry;
/// The distance to the destination.
- float traveled_distance;
+ float traveled_distance = 0.0;
NavigationPoly(const Polygon *p_poly) :
- self_id(0),
- poly(p_poly),
- prev_navigation_poly_id(-1),
- back_navigation_edge(0),
- traveled_distance(0.0) {
- }
+ poly(p_poly) {}
bool operator==(const NavigationPoly &other) const {
return this->poly == other.poly;
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
index abaf73ba6a..5fe1060aae 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,9 +69,9 @@ void NavigationMeshEditor::_bake_pressed() {
}
void NavigationMeshEditor::_clear_pressed() {
-
- if (node)
+ if (node) {
NavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
+ }
button_bake->set_pressed(false);
bake_info->set_text("");
@@ -85,7 +82,6 @@ void NavigationMeshEditor::_clear_pressed() {
}
void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) {
-
if (p_nav_region == nullptr || node == p_nav_region) {
return;
}
@@ -97,7 +93,6 @@ void NavigationMeshEditor::_bind_methods() {
}
NavigationMeshEditor::NavigationMeshEditor() {
-
bake_hbox = memnew(HBoxContainer);
button_bake = memnew(ToolButton);
@@ -124,22 +119,18 @@ NavigationMeshEditor::~NavigationMeshEditor() {
}
void NavigationMeshEditorPlugin::edit(Object *p_object) {
-
navigation_mesh_editor->edit(Object::cast_to<NavigationRegion3D>(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 +138,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..5329600e39 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -74,8 +74,9 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
current_vertex_count = p_verticies.size() / 3;
- if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
+ }
int index_count = 0;
if (p_mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
@@ -94,7 +95,6 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
const Vector3 *vr = mesh_vertices.ptr();
if (p_mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
-
Vector<int> mesh_indices = a[Mesh::ARRAY_INDEX];
const int *ir = mesh_indices.ptr();
@@ -139,9 +139,7 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
}
void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
-
if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
-
MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh();
if (mesh.is_valid()) {
@@ -151,7 +149,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
#ifdef MODULE_CSG_ENABLED
if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
-
CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);
Array meshes = csg_shape->get_meshes();
if (!meshes.empty()) {
@@ -167,7 +164,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(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<CollisionShape3D>(child)) {
@@ -222,7 +218,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s);
if (convex_polygon) {
Vector<Vector3> varr = Variant(convex_polygon->get_points());
- Geometry::MeshData md;
+ Geometry3D::MeshData md;
Error err = QuickHull::build(varr, md);
@@ -230,7 +226,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
PackedVector3Array faces;
for (int j = 0; j < md.faces.size(); ++j) {
- Geometry::MeshData::Face face = md.faces[j];
+ Geometry3D::MeshData::Face face = md.faces[j];
for (int k = 2; k < face.indices.size(); ++k) {
faces.push_back(md.vertices[face.indices[0]]);
@@ -278,7 +274,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh) {
-
Vector<Vector3> nav_vertices;
for (int i = 0; i < p_detail_mesh->nverts; i++) {
@@ -320,8 +315,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
rcContext ctx;
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Setting up Configuration..."), 1);
+ }
#endif
const float *verts = vertices.ptr();
@@ -357,14 +353,16 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
cfg.bmax[2] = bmax[2];
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Calculating grid size..."), 2);
+ }
#endif
rcCalcGridSize(cfg.bmin, cfg.bmax, cfg.cs, &cfg.width, &cfg.height);
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Creating heightfield..."), 3);
+ }
#endif
hf = rcAllocHeightfield();
@@ -372,8 +370,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcCreateHeightfield(&ctx, *hf, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch));
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Marking walkable triangles..."), 4);
+ }
#endif
{
Vector<unsigned char> tri_areas;
@@ -387,16 +386,20 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcRasterizeTriangles(&ctx, verts, nverts, tris, tri_areas.ptr(), ntris, *hf, cfg.walkableClimb));
}
- if (p_nav_mesh->get_filter_low_hanging_obstacles())
+ if (p_nav_mesh->get_filter_low_hanging_obstacles()) {
rcFilterLowHangingWalkableObstacles(&ctx, cfg.walkableClimb, *hf);
- if (p_nav_mesh->get_filter_ledge_spans())
+ }
+ if (p_nav_mesh->get_filter_ledge_spans()) {
rcFilterLedgeSpans(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf);
- if (p_nav_mesh->get_filter_walkable_low_height_spans())
+ }
+ if (p_nav_mesh->get_filter_walkable_low_height_spans()) {
rcFilterWalkableLowHeightSpans(&ctx, cfg.walkableHeight, *hf);
+ }
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Constructing compact heightfield..."), 5);
+ }
#endif
chf = rcAllocCompactHeightfield();
@@ -408,15 +411,17 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
hf = nullptr;
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Eroding walkable area..."), 6);
+ }
#endif
ERR_FAIL_COND(!rcErodeWalkableArea(&ctx, cfg.walkableRadius, *chf));
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Partitioning..."), 7);
+ }
#endif
if (p_nav_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_WATERSHED) {
@@ -429,8 +434,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
}
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Creating contours..."), 8);
+ }
#endif
cset = rcAllocContourSet();
@@ -439,8 +445,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcBuildContours(&ctx, *chf, cfg.maxSimplificationError, cfg.maxEdgeLen, *cset));
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Creating polymesh..."), 9);
+ }
#endif
poly_mesh = rcAllocPolyMesh();
@@ -457,8 +464,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
cset = nullptr;
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Converting to native navigation mesh..."), 10);
+ }
#endif
_convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh);
@@ -481,7 +489,6 @@ NavigationMeshGenerator::~NavigationMeshGenerator() {
}
void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) {
-
ERR_FAIL_COND(!p_nav_mesh.is_valid());
#ifdef TOOLS_ENABLED
@@ -490,8 +497,9 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
ep = memnew(EditorProgress("bake", TTR("Navigation Mesh Generator Setup:"), 11));
}
- if (ep)
+ if (ep) {
ep->step(TTR("Parsing Geometry..."), 0);
+ }
#endif
Vector<float> vertices;
@@ -514,7 +522,6 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
}
if (vertices.size() > 0 && indices.size() > 0) {
-
rcHeightfield *hf = nullptr;
rcCompactHeightfield *chf = nullptr;
rcContourSet *cset = nullptr;
@@ -551,11 +558,13 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
}
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Done!"), 11);
+ }
- if (ep)
+ if (ep) {
memdelete(ep);
+ }
#endif
}
diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp
index 3c39f02c26..1e1bdbd07d 100644
--- a/modules/gdnavigation/rvo_agent.cpp
+++ b/modules/gdnavigation/rvo_agent.cpp
@@ -36,8 +36,7 @@
@author AndreaCatania
*/
-RvoAgent::RvoAgent() :
- map(nullptr) {
+RvoAgent::RvoAgent() {
callback.id = ObjectID();
}
diff --git a/modules/gdnavigation/rvo_agent.h b/modules/gdnavigation/rvo_agent.h
index 914cbaa7d9..f5c579ba84 100644
--- a/modules/gdnavigation/rvo_agent.h
+++ b/modules/gdnavigation/rvo_agent.h
@@ -49,7 +49,7 @@ class RvoAgent : public NavRid {
Variant new_velocity;
};
- NavMap *map;
+ NavMap *map = nullptr;
RVO::Agent agent;
AvoidanceComputedCallback callback;
uint32_t map_update_id;
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index 0aca4dbc5e..d0f27b632b 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,10 +177,10 @@ Map<int, TextEdit::HighlighterInfo> 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]))
+ while (to < str.length() && _is_text_char(str[to])) {
to++;
+ }
String word = str.substr(j, to - j);
Color col = Color();
@@ -208,7 +205,6 @@ Map<int, TextEdit::HighlighterInfo> 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 +234,6 @@ Map<int, TextEdit::HighlighterInfo> 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..632407c61f 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<Script> GDScript::get_base_script() const {
-
if (_base) {
return Ref<GDScript>(_base);
} else {
@@ -189,16 +180,16 @@ Ref<Script> GDScript::get_base_script() const {
}
StringName GDScript::get_instance_base_type() const {
-
- if (native.is_valid())
+ if (native.is_valid()) {
return native->get_name();
- if (base.is_valid() && base->is_valid())
+ }
+ if (base.is_valid() && base->is_valid()) {
return base->get_instance_base_type();
+ }
return StringName();
}
struct _GDScriptMemberSort {
-
int index;
StringName name;
_FORCE_INLINE_ bool operator<(const _GDScriptMemberSort &p_member) const { return index < p_member.index; }
@@ -207,13 +198,11 @@ struct _GDScriptMemberSort {
#ifdef TOOLS_ENABLED
void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
-
placeholders.erase(p_placeholder);
}
#endif
void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
-
const GDScript *current = this;
while (current) {
for (const Map<StringName, GDScriptFunction *>::Element *E = current->member_functions.front(); E; E = E->next()) {
@@ -233,15 +222,12 @@ void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
}
void GDScript::get_script_property_list(List<PropertyInfo> *p_list) const {
-
const GDScript *sptr = this;
List<PropertyInfo> props;
while (sptr) {
-
Vector<_GDScriptMemberSort> msort;
for (Map<StringName, PropertyInfo>::Element *E = sptr->member_info.front(); E; E = E->next()) {
-
_GDScriptMemberSort ms;
ERR_CONTINUE(!sptr->member_indices.has(E->key()));
ms.index = sptr->member_indices[E->key()].index;
@@ -252,7 +238,6 @@ void GDScript::get_script_property_list(List<PropertyInfo> *p_list) const {
msort.sort();
msort.invert();
for (int i = 0; i < msort.size(); i++) {
-
props.push_front(sptr->member_info[msort[i].name]);
}
@@ -265,15 +250,14 @@ void GDScript::get_script_property_list(List<PropertyInfo> *p_list) const {
}
bool GDScript::has_method(const StringName &p_method) const {
-
return member_functions.has(p_method);
}
MethodInfo GDScript::get_method_info(const StringName &p_method) const {
-
const Map<StringName, GDScriptFunction *>::Element *E = member_functions.find(p_method);
- if (!E)
+ if (!E) {
return MethodInfo();
+ }
GDScriptFunction *func = E->get();
MethodInfo mi;
@@ -287,7 +271,6 @@ MethodInfo GDScript::get_method_info(const StringName &p_method) const {
}
bool GDScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
-
#ifdef TOOLS_ENABLED
const Map<StringName, Variant>::Element *E = member_default_values_cache.find(p_property);
@@ -304,14 +287,13 @@ bool GDScript::get_property_default_value(const StringName &p_property, Variant
}
ScriptInstance *GDScript::instance_create(Object *p_this) {
-
GDScript *top = this;
- while (top->_base)
+ while (top->_base) {
top = top->_base;
+ }
if (top->native.is_valid()) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) {
-
if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
}
@@ -335,24 +317,23 @@ PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this)
}
bool GDScript::instance_has(const Object *p_this) const {
-
MutexLock lock(GDScriptLanguage::singleton->lock);
return instances.has((Object *)p_this);
}
bool GDScript::has_source_code() const {
-
return source != "";
}
-String GDScript::get_source_code() const {
+String GDScript::get_source_code() const {
return source;
}
-void GDScript::set_source_code(const String &p_code) {
- if (source == p_code)
+void GDScript::set_source_code(const String &p_code) {
+ if (source == p_code) {
return;
+ }
source = p_code;
#ifdef TOOLS_ENABLED
source_changed_cache = true;
@@ -361,7 +342,6 @@ void GDScript::set_source_code(const String &p_code) {
#ifdef TOOLS_ENABLED
void GDScript::_update_exports_values(Map<StringName, Variant> &values, List<PropertyInfo> &propnames) {
-
if (base_cache.is_valid()) {
base_cache->_update_exports_values(values, propnames);
}
@@ -377,12 +357,12 @@ void GDScript::_update_exports_values(Map<StringName, Variant> &values, List<Pro
#endif
bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
-
#ifdef TOOLS_ENABLED
static Vector<GDScript *> base_caches;
- if (!p_recursive_call)
+ if (!p_recursive_call) {
base_caches.clear();
+ }
base_caches.append(this);
bool changed = false;
@@ -393,17 +373,18 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
String basedir = path;
- if (basedir == "")
+ if (basedir == "") {
basedir = get_path();
+ }
- if (basedir != "")
+ if (basedir != "") {
basedir = basedir.get_base_dir();
+ }
GDScriptParser parser;
Error err = parser.parse(source, basedir, true, path);
if (err == OK) {
-
const GDScriptParser::Node *root = parser.get_parse_tree();
ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
@@ -419,10 +400,8 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
if (String(c->extends_file) != "" && String(c->extends_file) != get_path()) {
path = c->extends_file;
if (path.is_rel_path()) {
-
String base = get_path();
if (base == "" || base.is_rel_path()) {
-
ERR_PRINT(("Could not resolve relative path for parent class: " + path).utf8().get_data());
} else {
path = base.get_base_dir().plus_file(path);
@@ -431,17 +410,16 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
} else if (c->extends_class.size() != 0) {
String base = c->extends_class[0];
- if (ScriptServer::is_global_class(base))
+ if (ScriptServer::is_global_class(base)) {
path = ScriptServer::get_global_class_path(base);
+ }
}
if (path != "") {
if (path != get_path()) {
-
Ref<GDScript> bf = ResourceLoader::load(path);
if (bf.is_valid()) {
-
base_cache = bf;
bf->inheriters_cache.insert(get_instance_id());
}
@@ -455,8 +433,9 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
member_default_values_cache.clear();
for (int i = 0; i < c->variables.size(); i++) {
- if (c->variables[i]._export.type == Variant::NIL)
+ if (c->variables[i]._export.type == Variant::NIL) {
continue;
+ }
members_cache.push_back(c->variables[i]._export);
member_default_values_cache[c->variables[i].identifier] = c->variables[i].default_value;
@@ -480,8 +459,9 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
if (base_cache.is_valid() && base_cache->is_valid()) {
for (int i = 0; i < base_caches.size(); i++) {
if (base_caches[i] == base_cache.ptr()) {
- if (r_err)
+ if (r_err) {
*r_err = true;
+ }
valid = false; // to show error in the editor
base_cache->valid = false;
base_cache->inheriters_cache.clear(); // to prevent future stackoverflows
@@ -492,8 +472,9 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
}
}
if (base_cache->_update_exports(r_err, true)) {
- if (r_err && *r_err)
+ if (r_err && *r_err) {
return false;
+ }
changed = true;
}
}
@@ -518,21 +499,22 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
}
void GDScript::update_exports() {
-
#ifdef TOOLS_ENABLED
bool cyclic_error = false;
_update_exports(&cyclic_error);
- if (cyclic_error)
+ if (cyclic_error) {
return;
+ }
Set<ObjectID> copy = inheriters_cache; //might get modified
for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) {
Object *id = ObjectDB::get_instance(E->get());
GDScript *s = Object::cast_to<GDScript>(id);
- if (!s)
+ if (!s) {
continue;
+ }
s->update_exports();
}
@@ -540,16 +522,13 @@ void GDScript::update_exports() {
}
void GDScript::_set_subclass_path(Ref<GDScript> &p_sc, const String &p_path) {
-
p_sc->path = p_path;
for (Map<StringName, Ref<GDScript>>::Element *E = p_sc->subclasses.front(); E; E = E->next()) {
-
_set_subclass_path(E->get(), p_path);
}
}
Error GDScript::reload(bool p_keep_state) {
-
bool has_instances;
{
MutexLock lock(GDScriptLanguage::singleton->lock);
@@ -561,11 +540,13 @@ Error GDScript::reload(bool p_keep_state) {
String basedir = path;
- if (basedir == "")
+ if (basedir == "") {
basedir = get_path();
+ }
- if (basedir != "")
+ if (basedir != "") {
basedir = basedir.get_base_dir();
+ }
if (source.find("%BASE%") != -1) {
//loading a template, don't parse
@@ -589,7 +570,6 @@ Error GDScript::reload(bool p_keep_state) {
err = compiler.compile(&parser, this, p_keep_state);
if (err) {
-
if (can_run) {
if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), compiler.get_error_line(), "Parser Error: " + compiler.get_error());
@@ -613,7 +593,6 @@ Error GDScript::reload(bool p_keep_state) {
valid = true;
for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) {
-
_set_subclass_path(E->get(), path);
}
@@ -623,12 +602,10 @@ Error GDScript::reload(bool p_keep_state) {
}
ScriptLanguage *GDScript::get_language() const {
-
return GDScriptLanguage::get_singleton();
}
void GDScript::get_constants(Map<StringName, Variant> *p_constants) {
-
if (p_constants) {
for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) {
(*p_constants)[E->key()] = E->value();
@@ -658,14 +635,16 @@ uint16_t GDScript::get_rpc_method_id(const StringName &p_method) const {
}
StringName GDScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
- if (p_rpc_method_id >= rpc_functions.size())
+ if (p_rpc_method_id >= rpc_functions.size()) {
return StringName();
+ }
return rpc_functions[p_rpc_method_id].name;
}
MultiplayerAPI::RPCMode GDScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
- if (p_rpc_method_id >= rpc_functions.size())
+ if (p_rpc_method_id >= rpc_functions.size()) {
return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
return rpc_functions[p_rpc_method_id].mode;
}
@@ -687,14 +666,16 @@ uint16_t GDScript::get_rset_property_id(const StringName &p_variable) const {
}
StringName GDScript::get_rset_property(const uint16_t p_rset_member_id) const {
- if (p_rset_member_id >= rpc_variables.size())
+ if (p_rset_member_id >= rpc_variables.size()) {
return StringName();
+ }
return rpc_variables[p_rset_member_id].name;
}
MultiplayerAPI::RPCMode GDScript::get_rset_mode_by_id(const uint16_t p_rset_member_id) const {
- if (p_rset_member_id >= rpc_variables.size())
+ if (p_rset_member_id >= rpc_variables.size()) {
return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
return rpc_variables[p_rset_member_id].mode;
}
@@ -703,13 +684,10 @@ MultiplayerAPI::RPCMode GDScript::get_rset_mode(const StringName &p_variable) co
}
Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
GDScript *top = this;
while (top) {
-
Map<StringName, GDScriptFunction *>::Element *E = top->member_functions.find(p_method);
if (E) {
-
ERR_FAIL_COND_V_MSG(!E->get()->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script.");
return E->get()->call(nullptr, p_args, p_argcount, r_error);
@@ -723,16 +701,12 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p
}
bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
-
{
-
const GDScript *top = this;
while (top) {
-
{
const Map<StringName, Variant>::Element *E = top->constants.find(p_name);
if (E) {
-
r_ret = E->get();
return true;
}
@@ -741,7 +715,6 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
{
const Map<StringName, Ref<GDScript>>::Element *E = subclasses.find(p_name);
if (E) {
-
r_ret = E->get();
return true;
}
@@ -750,7 +723,6 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
}
if (p_name == GDScriptLanguage::get_singleton()->strings._script_source) {
-
r_ret = get_source_code();
return true;
}
@@ -758,42 +730,37 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-bool GDScript::_set(const StringName &p_name, const Variant &p_value) {
+bool GDScript::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == GDScriptLanguage::get_singleton()->strings._script_source) {
-
set_source_code(p_value);
reload();
- } else
+ } else {
return false;
+ }
return true;
}
void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const {
-
p_properties->push_back(PropertyInfo(Variant::STRING, "script/source", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
}
void GDScript::_bind_methods() {
-
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &GDScript::_new, MethodInfo("new"));
ClassDB::bind_method(D_METHOD("get_as_byte_code"), &GDScript::get_as_byte_code);
}
Vector<uint8_t> GDScript::get_as_byte_code() const {
-
GDScriptTokenizerBuffer tokenizer;
return tokenizer.parse_code_string(source);
};
Error GDScript::load_byte_code(const String &p_path) {
-
Vector<uint8_t> bytecode;
if (p_path.ends_with("gde")) {
-
FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V(!fa, ERR_CANT_OPEN);
@@ -822,7 +789,6 @@ Error GDScript::load_byte_code(const String &p_path) {
memdelete(fae);
} else {
-
bytecode = FileAccess::get_file_as_array(p_path);
}
@@ -831,11 +797,13 @@ Error GDScript::load_byte_code(const String &p_path) {
String basedir = path;
- if (basedir == "")
+ if (basedir == "") {
basedir = get_path();
+ }
- if (basedir != "")
+ if (basedir != "") {
basedir = basedir.get_base_dir();
+ }
valid = false;
GDScriptParser parser;
@@ -856,7 +824,6 @@ Error GDScript::load_byte_code(const String &p_path) {
valid = true;
for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) {
-
_set_subclass_path(E->get(), path);
}
@@ -866,12 +833,10 @@ Error GDScript::load_byte_code(const String &p_path) {
}
Error GDScript::load_source_code(const String &p_path) {
-
Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
-
ERR_FAIL_COND_V(err, err);
}
@@ -886,7 +851,6 @@ Error GDScript::load_source_code(const String &p_path) {
String s;
if (s.parse_utf8((const char *)w)) {
-
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
@@ -899,23 +863,20 @@ Error GDScript::load_source_code(const String &p_path) {
}
const Map<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions() const {
-
return member_functions;
}
StringName GDScript::debug_get_member_by_index(int p_idx) const {
-
for (const Map<StringName, MemberInfo>::Element *E = member_indices.front(); E; E = E->next()) {
-
- if (E->get().index == p_idx)
+ if (E->get().index == p_idx) {
return E->key();
+ }
}
return "<error>";
}
Ref<GDScript> GDScript::get_base() const {
-
return base;
}
@@ -938,8 +899,9 @@ bool GDScript::inherits_script(const Ref<Script> &p_script) const {
}
bool GDScript::has_script_signal(const StringName &p_signal) const {
- if (_signals.has(p_signal))
+ if (_signals.has(p_signal)) {
return true;
+ }
if (base.is_valid()) {
return base->has_script_signal(p_signal);
}
@@ -950,10 +912,9 @@ bool GDScript::has_script_signal(const StringName &p_signal) const {
#endif
return false;
}
-void GDScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
+void GDScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
for (const Map<StringName, Vector<StringName>>::Element *E = _signals.front(); E; E = E->next()) {
-
MethodInfo mi;
mi.name = E->key();
for (int i = 0; i < E->get().size(); i++) {
@@ -977,7 +938,6 @@ void GDScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
GDScript::GDScript() :
script_list(this) {
-
valid = false;
subclass_count = 0;
initializer = nullptr;
@@ -1022,8 +982,9 @@ void GDScript::_save_orphaned_subclasses() {
for (int i = 0; i < weak_subclasses.size(); i++) {
ClassRefWithName subclass = weak_subclasses[i];
Object *obj = ObjectDB::get_instance(subclass.id);
- if (!obj)
+ if (!obj) {
continue;
+ }
// subclass is not released
GDScriptLanguage::get_singleton()->add_orphan_subclass(subclass.fully_qualified_name, subclass.id);
}
@@ -1064,13 +1025,15 @@ void GDScript::_init_rpc_methods_properties() {
}
}
- if (cscript != this)
+ if (cscript != this) {
sub_E = sub_E->next();
+ }
- if (sub_E)
+ if (sub_E) {
cscript = sub_E->get().ptr();
- else
+ } else {
cscript = nullptr;
+ }
}
// Sort so we are 100% that they are always the same.
@@ -1079,7 +1042,6 @@ void GDScript::_init_rpc_methods_properties() {
}
GDScript::~GDScript() {
-
{
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
@@ -1109,7 +1071,6 @@ GDScript::~GDScript() {
//////////////////////////////
bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
-
//member
{
const Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name);
@@ -1144,17 +1105,16 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
GDScript *sptr = script.ptr();
while (sptr) {
-
Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set);
if (E) {
-
Variant name = p_name;
const Variant *args[2] = { &name, &p_value };
Callable::CallError err;
Variant ret = E->get()->call(this, (const Variant **)args, 2, err);
- if (err.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::BOOL && ret.operator bool())
+ if (err.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::BOOL && ret.operator bool()) {
return true;
+ }
}
sptr = sptr->_base;
}
@@ -1163,10 +1123,8 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
}
bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
-
const GDScript *sptr = script.ptr();
while (sptr) {
-
{
const Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name);
if (E) {
@@ -1183,7 +1141,6 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
}
{
-
const GDScript *sl = sptr;
while (sl) {
const Map<StringName, Variant>::Element *E = sl->constants.find(p_name);
@@ -1198,7 +1155,6 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
{
const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get);
if (E) {
-
Variant name = p_name;
const Variant *args[1] = { &name };
@@ -1217,20 +1173,20 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
}
Variant::Type GDScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
-
const GDScript *sptr = script.ptr();
while (sptr) {
-
if (sptr->member_info.has(p_name)) {
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = true;
+ }
return sptr->member_info[p_name].type;
}
sptr = sptr->_base;
}
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = false;
+ }
return Variant::NIL;
}
@@ -1241,19 +1197,15 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
List<PropertyInfo> props;
while (sptr) {
-
const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
if (E) {
-
Callable::CallError err;
Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err);
if (err.error == Callable::CallError::CALL_OK) {
-
ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
Array arr = ret;
for (int i = 0; i < arr.size(); i++) {
-
Dictionary d = arr[i];
ERR_CONTINUE(!d.has("name"));
ERR_CONTINUE(!d.has("type"));
@@ -1262,12 +1214,15 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
ERR_CONTINUE(pinfo.type < 0 || pinfo.type >= Variant::VARIANT_MAX);
pinfo.name = d["name"];
ERR_CONTINUE(pinfo.name == "");
- if (d.has("hint"))
+ if (d.has("hint")) {
pinfo.hint = PropertyHint(d["hint"].operator int());
- if (d.has("hint_string"))
+ }
+ if (d.has("hint_string")) {
pinfo.hint_string = d["hint_string"];
- if (d.has("usage"))
+ }
+ if (d.has("usage")) {
pinfo.usage = d["usage"];
+ }
props.push_back(pinfo);
}
@@ -1278,7 +1233,6 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
Vector<_GDScriptMemberSort> msort;
for (Map<StringName, PropertyInfo>::Element *F = sptr->member_info.front(); F; F = F->next()) {
-
_GDScriptMemberSort ms;
ERR_CONTINUE(!sptr->member_indices.has(F->key()));
ms.index = sptr->member_indices[F->key()].index;
@@ -1289,7 +1243,6 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
msort.sort();
msort.invert();
for (int i = 0; i < msort.size(); i++) {
-
props.push_front(sptr->member_info[msort[i].name]);
}
@@ -1297,23 +1250,20 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
}
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
p_properties->push_back(E->get());
}
}
void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
-
const GDScript *sptr = script.ptr();
while (sptr) {
-
for (Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) {
-
MethodInfo mi;
mi.name = E->key();
mi.flags |= METHOD_FLAG_FROM_SCRIPT;
- for (int i = 0; i < E->get()->get_argument_count(); i++)
+ for (int i = 0; i < E->get()->get_argument_count(); i++) {
mi.arguments.push_back(PropertyInfo(Variant::NIL, "arg" + itos(i)));
+ }
p_list->push_back(mi);
}
sptr = sptr->_base;
@@ -1321,19 +1271,19 @@ void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
}
bool GDScriptInstance::has_method(const StringName &p_method) const {
-
const GDScript *sptr = script.ptr();
while (sptr) {
const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
- if (E)
+ if (E) {
return true;
+ }
sptr = sptr->_base;
}
return false;
}
-Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
+Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
GDScript *sptr = script.ptr();
while (sptr) {
Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
@@ -1347,7 +1297,6 @@ Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_arg
}
void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
-
GDScript *sptr = script.ptr();
Callable::CallError ce;
@@ -1361,9 +1310,9 @@ void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant
}
void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
-
- if (sptr->_base)
+ if (sptr->_base) {
_ml_call_reversed(sptr->_base, p_method, p_args, p_argcount);
+ }
Callable::CallError ce;
@@ -1374,14 +1323,12 @@ void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_met
}
void GDScriptInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
-
if (script.ptr()) {
_ml_call_reversed(script.ptr(), p_method, p_args, p_argcount);
}
}
void GDScriptInstance::notification(int p_notification) {
-
//notification is not virtual, it gets called at ALL levels just like in C.
Variant value = p_notification;
const Variant *args[1] = { &value };
@@ -1406,27 +1353,28 @@ String GDScriptInstance::to_string(bool *r_valid) {
Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret.operator String();
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return String();
}
Ref<Script> GDScriptInstance::get_script() const {
-
return script;
}
ScriptLanguage *GDScriptInstance::get_language() {
-
return GDScriptLanguage::get_singleton();
}
@@ -1471,7 +1419,6 @@ MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_vari
}
void GDScriptInstance::reload_members() {
-
#ifdef DEBUG_ENABLED
members.resize(script->member_indices.size()); //resize
@@ -1481,7 +1428,6 @@ void GDScriptInstance::reload_members() {
//pass the values to the new indices
for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) {
-
if (member_indices_cache.has(E->key())) {
Variant value = members[member_indices_cache[E->key()]];
new_members.write[E->get().index] = value;
@@ -1494,7 +1440,6 @@ void GDScriptInstance::reload_members() {
//pass the values to the new indices
member_indices_cache.clear();
for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) {
-
member_indices_cache[E->key()] = E->get().index;
}
@@ -1507,7 +1452,6 @@ GDScriptInstance::GDScriptInstance() {
}
GDScriptInstance::~GDScriptInstance() {
-
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
@@ -1525,14 +1469,12 @@ GDScriptInstance::~GDScriptInstance() {
GDScriptLanguage *GDScriptLanguage::singleton = nullptr;
String GDScriptLanguage::get_name() const {
-
return "GDScript";
}
/* LANGUAGE FUNCTIONS */
void GDScriptLanguage::_add_global(const StringName &p_name, const Variant &p_value) {
-
if (globals.has(p_name)) {
//overwrite existing
global_array.write[globals[p_name]] = p_value;
@@ -1544,7 +1486,6 @@ void GDScriptLanguage::_add_global(const StringName &p_name, const Variant &p_va
}
void GDScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
-
_add_global(p_variable, p_value);
}
@@ -1558,11 +1499,9 @@ void GDScriptLanguage::remove_named_global_constant(const StringName &p_name) {
}
void GDScriptLanguage::init() {
-
//populate global constants
int gcc = GlobalConstants::get_global_constant_count();
for (int i = 0; i < gcc; i++) {
-
_add_global(StaticCString::create(GlobalConstants::get_global_constant_name(i)), GlobalConstants::get_global_constant_value(i));
}
@@ -1576,14 +1515,15 @@ void GDScriptLanguage::init() {
List<StringName> class_list;
ClassDB::get_class_list(&class_list);
for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) {
-
StringName n = E->get();
String s = String(n);
- if (s.begins_with("_"))
+ if (s.begins_with("_")) {
n = s.substr(1, s.length());
+ }
- if (globals.has(n))
+ if (globals.has(n)) {
continue;
+ }
Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get()));
_add_global(n, nc);
}
@@ -1593,29 +1533,27 @@ void GDScriptLanguage::init() {
List<Engine::Singleton> singletons;
Engine::get_singleton()->get_singletons(&singletons);
for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
-
_add_global(E->get().name, E->get().ptr);
}
}
String GDScriptLanguage::get_type() const {
-
return "GDScript";
}
-String GDScriptLanguage::get_extension() const {
+String GDScriptLanguage::get_extension() const {
return "gd";
}
-Error GDScriptLanguage::execute_file(const String &p_path) {
+Error GDScriptLanguage::execute_file(const String &p_path) {
// ??
return OK;
}
+
void GDScriptLanguage::finish() {
}
void GDScriptLanguage::profiling_start() {
-
#ifdef DEBUG_ENABLED
MutexLock lock(this->lock);
@@ -1638,7 +1576,6 @@ void GDScriptLanguage::profiling_start() {
}
void GDScriptLanguage::profiling_stop() {
-
#ifdef DEBUG_ENABLED
MutexLock lock(this->lock);
@@ -1647,7 +1584,6 @@ void GDScriptLanguage::profiling_stop() {
}
int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
-
int current = 0;
#ifdef DEBUG_ENABLED
@@ -1655,8 +1591,9 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
- if (current >= p_info_max)
+ if (current >= p_info_max) {
break;
+ }
p_info_arr[current].call_count = elem->self()->profile.call_count;
p_info_arr[current].self_time = elem->self()->profile.self_time;
p_info_arr[current].total_time = elem->self()->profile.total_time;
@@ -1670,7 +1607,6 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
}
int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
-
int current = 0;
#ifdef DEBUG_ENABLED
@@ -1678,8 +1614,9 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
- if (current >= p_info_max)
+ if (current >= p_info_max) {
break;
+ }
if (elem->self()->profile.last_frame_call_count > 0) {
p_info_arr[current].call_count = elem->self()->profile.last_frame_call_count;
p_info_arr[current].self_time = elem->self()->profile.last_frame_self_time;
@@ -1695,12 +1632,11 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
}
struct GDScriptDepSort {
-
//must support sorting so inheritance works properly (parent must be reloaded first)
bool operator()(const Ref<GDScript> &A, const Ref<GDScript> &B) const {
-
- if (A == B)
+ if (A == B) {
return false; //shouldn't happen but..
+ }
const GDScript *I = B->get_base().ptr();
while (I) {
if (I == A.ptr()) {
@@ -1716,7 +1652,6 @@ struct GDScriptDepSort {
};
void GDScriptLanguage::reload_all_scripts() {
-
#ifdef DEBUG_ENABLED
print_verbose("GDScript: Reloading all scripts");
List<Ref<GDScript>> scripts;
@@ -1738,7 +1673,6 @@ void GDScriptLanguage::reload_all_scripts() {
scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order
for (List<Ref<GDScript>>::Element *E = scripts.front(); E; E = E->next()) {
-
print_verbose("GDScript: Reloading: " + E->get()->get_path());
E->get()->load_source_code(E->get()->get_path());
E->get()->reload(true);
@@ -1747,7 +1681,6 @@ void GDScriptLanguage::reload_all_scripts() {
}
void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
-
#ifdef DEBUG_ENABLED
List<Ref<GDScript>> scripts;
@@ -1757,7 +1690,6 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
SelfList<GDScript> *elem = script_list.first();
while (elem) {
if (elem->self()->get_path().is_resource_file()) {
-
scripts.push_back(Ref<GDScript>(elem->self())); //cast to gdscript to avoid being erased by accident
}
elem = elem->next();
@@ -1773,16 +1705,15 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order
for (List<Ref<GDScript>>::Element *E = scripts.front(); E; E = E->next()) {
-
bool reload = E->get() == p_script || to_reload.has(E->get()->get_base());
- if (!reload)
+ if (!reload) {
continue;
+ }
to_reload.insert(E->get(), Map<ObjectID, List<Pair<StringName, Variant>>>());
if (!p_soft_reload) {
-
//save state and remove script from instances
Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[E->get()];
@@ -1791,7 +1722,6 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
//save instance info
List<Pair<StringName, Variant>> state;
if (obj->get_script_instance()) {
-
obj->get_script_instance()->get_property_state(state);
map[obj->get_instance_id()] = state;
obj->set_script(Variant());
@@ -1806,7 +1736,6 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
//save instance info
if (obj->get_script_instance()) {
-
map.insert(obj->get_instance_id(), List<Pair<StringName, Variant>>());
List<Pair<StringName, Variant>> &state = map[obj->get_instance_id()];
obj->get_script_instance()->get_property_state(state);
@@ -1826,18 +1755,17 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
}
for (Map<Ref<GDScript>, Map<ObjectID, List<Pair<StringName, Variant>>>>::Element *E = to_reload.front(); E; E = E->next()) {
-
Ref<GDScript> scr = E->key();
scr->reload(p_soft_reload);
//restore state if saved
for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = E->get().front(); F; F = F->next()) {
-
List<Pair<StringName, Variant>> &saved_state = F->get();
Object *obj = ObjectDB::get_instance(F->key());
- if (!obj)
+ if (!obj) {
continue;
+ }
if (!p_soft_reload) {
//clear it just in case (may be a pending reload state)
@@ -1876,7 +1804,6 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
}
void GDScriptLanguage::frame() {
-
calls = 0;
#ifdef DEBUG_ENABLED
@@ -1900,7 +1827,6 @@ void GDScriptLanguage::frame() {
/* EDITOR FUNCTIONS */
void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
-
static const char *_reserved_words[] = {
// operators
"and",
@@ -1964,7 +1890,6 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
const char **w = _reserved_words;
while (*w) {
-
p_words->push_back(*w);
w++;
}
@@ -1975,12 +1900,10 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
}
bool GDScriptLanguage::handles_global_class_type(const String &p_type) const {
-
return p_type == "GDScript";
}
String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
-
Vector<uint8_t> sourcef;
Error err;
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -1994,16 +1917,15 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
parser.parse(source, p_path.get_base_dir(), true, p_path, false, nullptr, true);
if (parser.get_parse_tree() && parser.get_parse_tree()->type == GDScriptParser::Node::TYPE_CLASS) {
-
const GDScriptParser::ClassNode *c = static_cast<const GDScriptParser::ClassNode *>(parser.get_parse_tree());
if (r_icon_path) {
- if (c->icon_path.empty() || c->icon_path.is_abs_path())
+ if (c->icon_path.empty() || c->icon_path.is_abs_path()) {
*r_icon_path = c->icon_path;
- else if (c->icon_path.is_rel_path())
+ } else if (c->icon_path.is_rel_path()) {
*r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path();
+ }
}
if (r_base_type) {
-
const GDScriptParser::ClassNode *subclass = c;
String path = p_path;
GDScriptParser subparser;
@@ -2077,7 +1999,6 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
#ifdef DEBUG_ENABLED
String GDScriptWarning::get_message() const {
-
#define CHECK_SYMBOLS(m_amount) ERR_FAIL_COND_V(symbols.size() < m_amount, String());
switch (code) {
@@ -2246,7 +2167,6 @@ GDScriptWarning::Code GDScriptWarning::get_code_from_name(const String &p_name)
#endif // DEBUG_ENABLED
GDScriptLanguage::GDScriptLanguage() {
-
calls = 0;
ERR_FAIL_COND(singleton);
singleton = this;
@@ -2291,7 +2211,6 @@ GDScriptLanguage::GDScriptLanguage() {
}
GDScriptLanguage::~GDScriptLanguage() {
-
if (_call_stack) {
memdelete_arr(_call_stack);
}
@@ -2304,29 +2223,30 @@ void GDScriptLanguage::add_orphan_subclass(const String &p_qualified_name, const
Ref<GDScript> GDScriptLanguage::get_orphan_subclass(const String &p_qualified_name) {
Map<String, ObjectID>::Element *orphan_subclass_element = orphan_subclasses.find(p_qualified_name);
- if (!orphan_subclass_element)
+ if (!orphan_subclass_element) {
return Ref<GDScript>();
+ }
ObjectID orphan_subclass = orphan_subclass_element->get();
Object *obj = ObjectDB::get_instance(orphan_subclass);
orphan_subclasses.erase(orphan_subclass_element);
- if (!obj)
+ if (!obj) {
return Ref<GDScript>();
+ }
return Ref<GDScript>(Object::cast_to<GDScript>(obj));
}
/*************** RESOURCE ***************/
RES ResourceFormatLoaderGDScript::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)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
GDScript *script = memnew(GDScript);
Ref<GDScript> scriptres(script);
if (p_path.ends_with(".gde") || p_path.ends_with(".gdc")) {
-
script->set_script_path(p_original_path); // script needs this.
script->set_path(p_original_path);
Error err = script->load_byte_code(p_path);
@@ -2341,34 +2261,32 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
script->reload();
}
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return scriptres;
}
void ResourceFormatLoaderGDScript::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("gd");
p_extensions->push_back("gdc");
p_extensions->push_back("gde");
}
bool ResourceFormatLoaderGDScript::handles_type(const String &p_type) const {
-
return (p_type == "Script" || p_type == "GDScript");
}
String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "gd" || el == "gdc" || el == "gde")
+ if (el == "gd" || el == "gdc" || el == "gde") {
return "GDScript";
+ }
return "";
}
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
FileAccessRef file = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_MSG(!file, "Cannot open file '" + p_path + "'.");
@@ -2388,7 +2306,6 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S
}
Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<GDScript> sqscr = p_resource;
ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
@@ -2415,12 +2332,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou
}
void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (Object::cast_to<GDScript>(*p_resource)) {
p_extensions->push_back("gd");
}
}
-bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const {
+bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const {
return Object::cast_to<GDScript>(*p_resource) != nullptr;
}
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index b7ac2bd0c5..e770dc3abd 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -39,7 +39,6 @@
#include "gdscript_function.h"
class GDScriptNativeClass : public Reference {
-
GDCLASS(GDScriptNativeClass, Reference);
StringName name;
@@ -56,7 +55,6 @@ public:
};
class GDScript : public Script {
-
GDCLASS(GDScript, Script);
bool tool;
bool valid;
@@ -211,11 +209,11 @@ public:
virtual int get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
- if (member_lines.has(p_member))
+ if (member_lines.has(p_member)) {
return member_lines[p_member];
- else
+ }
#endif
- return -1;
+ return -1;
}
virtual void get_constants(Map<StringName, Variant> *p_constants);
@@ -334,23 +332,22 @@ struct GDScriptWarning {
DEPRECATED_KEYWORD, // The keyword is deprecated and should be replaced
STANDALONE_TERNARY, // Return value of ternary expression is discarded
WARNING_MAX,
- } code;
+ };
+
+ Code code = WARNING_MAX;
Vector<String> symbols;
- int line;
+ int line = -1;
String get_name() const;
String get_message() const;
static String get_name_from_code(Code p_code);
static Code get_code_from_name(const String &p_name);
- GDScriptWarning() :
- code(WARNING_MAX),
- line(-1) {}
+ GDScriptWarning() {}
};
#endif // DEBUG_ENABLED
class GDScriptLanguage : public ScriptLanguage {
-
friend class GDScriptFunctionState;
static GDScriptLanguage *singleton;
@@ -361,7 +358,6 @@ class GDScriptLanguage : public ScriptLanguage {
Map<StringName, Variant> named_globals;
struct CallLevel {
-
Variant *stack;
GDScriptFunction *function;
GDScriptInstance *instance;
@@ -400,12 +396,13 @@ public:
bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
_FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
-
- if (Thread::get_main_id() != Thread::get_caller_id())
+ if (Thread::get_main_id() != Thread::get_caller_id()) {
return; //no support for other threads than main for now
+ }
- if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0)
+ if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() + 1);
+ }
if (_debug_call_stack_pos >= _debug_max_call_stack) {
//stack overflow
@@ -423,15 +420,15 @@ public:
}
_FORCE_INLINE_ void exit_function() {
-
- if (Thread::get_main_id() != Thread::get_caller_id())
+ if (Thread::get_main_id() != Thread::get_caller_id()) {
return; //no support for other threads than main for now
+ }
- if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0)
+ if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() - 1);
+ }
if (_debug_call_stack_pos == 0) {
-
_debug_error = "Stack Underflow (Engine Bug)";
EngineDebugger::get_script_debugger()->debug(this);
return;
@@ -441,8 +438,9 @@ public:
}
virtual Vector<StackInfo> debug_get_current_stack_info() {
- if (Thread::get_main_id() != Thread::get_caller_id())
+ if (Thread::get_main_id() != Thread::get_caller_id()) {
return Vector<StackInfo>();
+ }
Vector<StackInfo> csi;
csi.resize(_debug_call_stack_pos);
@@ -457,7 +455,6 @@ public:
}
struct {
-
StringName _init;
StringName _notification;
StringName _set;
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 473b6fab05..bc095ae1f9 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -33,24 +33,24 @@
#include "gdscript.h"
bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) {
-
- if (codegen.function_node && codegen.function_node->_static)
+ if (codegen.function_node && codegen.function_node->_static) {
return false;
+ }
- if (codegen.stack_identifiers.has(p_name))
+ if (codegen.stack_identifiers.has(p_name)) {
return false; //shadowed
+ }
return _is_class_member_property(codegen.script, p_name);
}
bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
-
GDScript *scr = owner;
GDScriptNativeClass *nc = nullptr;
while (scr) {
-
- if (scr->native.is_valid())
+ if (scr->native.is_valid()) {
nc = scr->native.ptr();
+ }
scr = scr->_base;
}
@@ -60,9 +60,9 @@ bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringNa
}
void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::Node *p_node) {
-
- if (error != "")
+ if (error != "") {
return;
+ }
error = p_error;
if (p_node) {
@@ -75,12 +75,12 @@ void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::N
}
bool GDScriptCompiler::_create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level) {
-
ERR_FAIL_COND_V(on->arguments.size() != 1, false);
int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (src_address_a < 0)
+ if (src_address_a < 0) {
return false;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_OPERATOR); // perform operator
codegen.opcodes.push_back(op); //which operator
@@ -91,18 +91,20 @@ bool GDScriptCompiler::_create_unary_operator(CodeGen &codegen, const GDScriptPa
}
bool GDScriptCompiler::_create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer, int p_index_addr) {
-
ERR_FAIL_COND_V(on->arguments.size() != 2, false);
int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level, false, p_initializer, p_index_addr);
- if (src_address_a < 0)
+ if (src_address_a < 0) {
return false;
- if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
+ }
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
p_stack_level++; //uses stack for return, increase stack
+ }
int src_address_b = _parse_expression(codegen, on->arguments[1], p_stack_level, false, p_initializer);
- if (src_address_b < 0)
+ if (src_address_b < 0) {
return false;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_OPERATOR); // perform operator
codegen.opcodes.push_back(op); //which operator
@@ -172,11 +174,9 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
}
int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level, int p_index_addr) {
-
Variant::Operator var_op = Variant::OP_MAX;
switch (p_expression->op) {
-
case GDScriptParser::OperatorNode::OP_ASSIGN_ADD:
var_op = Variant::OP_ADD;
break;
@@ -209,11 +209,9 @@ int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDS
break;
case GDScriptParser::OperatorNode::OP_INIT_ASSIGN:
case GDScriptParser::OperatorNode::OP_ASSIGN: {
-
//none
} break;
default: {
-
ERR_FAIL_V(-1);
}
}
@@ -221,12 +219,12 @@ int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDS
bool initializer = p_expression->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN;
if (var_op == Variant::OP_MAX) {
-
return _parse_expression(codegen, p_expression->arguments[1], p_stack_level, false, initializer);
}
- if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer, p_index_addr))
+ if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer, p_index_addr)) {
return -1;
+ }
int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
@@ -235,7 +233,6 @@ int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDS
}
int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer, int p_index_addr) {
-
switch (p_expression->type) {
//should parse variable declaration and adjust stack accordingly...
case GDScriptParser::Node::TYPE_IDENTIFIER: {
@@ -251,7 +248,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
// TRY STACK!
if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
-
int pos = codegen.stack_identifiers[identifier];
return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
}
@@ -269,11 +265,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//TRY MEMBERS!
if (!codegen.function_node || !codegen.function_node->_static) {
-
// TRY MEMBER VARIABLES!
//static function
if (codegen.script->member_indices.has(identifier)) {
-
int idx = codegen.script->member_indices[identifier].index;
return idx | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
@@ -283,26 +277,23 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
GDScript *owner = codegen.script;
while (owner) {
-
GDScript *scr = owner;
GDScriptNativeClass *nc = nullptr;
while (scr) {
-
if (scr->constants.has(identifier)) {
-
//int idx=scr->constants[identifier];
int idx = codegen.get_name_map_pos(identifier);
return idx | (GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
- if (scr->native.is_valid())
+ if (scr->native.is_valid()) {
nc = scr->native.ptr();
+ }
scr = scr->_base;
}
// CLASS C++ Integer Constant
if (nc) {
-
bool success = false;
int constant = ClassDB::get_integer_constant(nc->get_name(), identifier, &success);
if (success) {
@@ -310,7 +301,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int idx;
if (!codegen.constant_map.has(key)) {
-
idx = codegen.constant_map.size();
codegen.constant_map[key] = idx;
@@ -326,7 +316,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
}
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
-
int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];
return idx | (GDScriptFunction::ADDR_TYPE_GLOBAL << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
@@ -334,7 +323,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
/* TRY GLOBAL CLASSES */
if (ScriptServer::is_global_class(identifier)) {
-
const GDScriptParser::ClassNode *class_node = codegen.class_node;
while (class_node->owner) {
class_node = class_node->owner;
@@ -355,7 +343,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int idx;
if (!codegen.constant_map.has(key)) {
-
idx = codegen.constant_map.size();
codegen.constant_map[key] = idx;
@@ -368,7 +355,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
#ifdef TOOLS_ENABLED
if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(identifier)) {
-
int idx = codegen.named_globals.find(identifier);
if (idx == -1) {
idx = codegen.named_globals.size();
@@ -392,7 +378,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int idx;
if (!codegen.constant_map.has(cn->value)) {
-
idx = codegen.constant_map.size();
codegen.constant_map[cn->value] = idx;
@@ -412,17 +397,16 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
return (GDScriptFunction::ADDR_TYPE_SELF << GDScriptFunction::ADDR_BITS);
} break;
case GDScriptParser::Node::TYPE_ARRAY: {
-
const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_expression);
Vector<int> values;
int slevel = p_stack_level;
for (int i = 0; i < an->elements.size(); i++) {
-
int ret = _parse_expression(codegen, an->elements[i], slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -433,8 +417,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT_ARRAY);
codegen.opcodes.push_back(values.size());
- for (int i = 0; i < values.size(); i++)
+ for (int i = 0; i < values.size(); i++) {
codegen.opcodes.push_back(values[i]);
+ }
int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
@@ -443,17 +428,16 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
case GDScriptParser::Node::TYPE_DICTIONARY: {
-
const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(p_expression);
Vector<int> values;
int slevel = p_stack_level;
for (int i = 0; i < dn->elements.size(); i++) {
-
int ret = _parse_expression(codegen, dn->elements[i].key, slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -462,8 +446,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
values.push_back(ret);
ret = _parse_expression(codegen, dn->elements[i].value, slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -474,8 +459,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY);
codegen.opcodes.push_back(dn->elements.size());
- for (int i = 0; i < values.size(); i++)
+ for (int i = 0; i < values.size(); i++) {
codegen.opcodes.push_back(values[i]);
+ }
int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
@@ -488,8 +474,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int slevel = p_stack_level;
int src_addr = _parse_expression(codegen, cn->source_node, slevel);
- if (src_addr < 0)
+ if (src_addr < 0) {
return src_addr;
+ }
if (src_addr & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
@@ -505,7 +492,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
case GDScriptDataType::NATIVE: {
int class_idx;
if (GDScriptLanguage::get_singleton()->get_global_map().has(cast_type.native_type)) {
-
class_idx = GDScriptLanguage::get_singleton()->get_global_map()[cast_type.native_type];
class_idx |= (GDScriptFunction::ADDR_TYPE_GLOBAL << GDScriptFunction::ADDR_BITS); //argument (stack root)
} else {
@@ -517,7 +503,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
case GDScriptDataType::SCRIPT:
case GDScriptDataType::GDSCRIPT: {
-
Variant script = cast_type.script_type;
int idx = codegen.get_constant_pos(script);
idx |= GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS; //make it a local constant (faster access)
@@ -543,10 +528,8 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
const GDScriptParser::OperatorNode *on = static_cast<const GDScriptParser::OperatorNode *>(p_expression);
switch (on->op) {
-
//call/constructor operator
case GDScriptParser::OperatorNode::OP_PARENT_CALL: {
-
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
const GDScriptParser::IdentifierNode *in = (const GDScriptParser::IdentifierNode *)on->arguments[0];
@@ -554,10 +537,10 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
Vector<int> arguments;
int slevel = p_stack_level;
for (int i = 1; i < on->arguments.size(); i++) {
-
int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -571,12 +554,12 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(codegen.get_name_map_pos(in->name)); //instance
codegen.opcodes.push_back(arguments.size()); //argument count
codegen.alloc_call(arguments.size());
- for (int i = 0; i < arguments.size(); i++)
+ for (int i = 0; i < arguments.size(); i++) {
codegen.opcodes.push_back(arguments[i]); //arguments
+ }
} break;
case GDScriptParser::OperatorNode::OP_CALL: {
-
if (on->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) {
//construct a basic type
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
@@ -587,10 +570,10 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
Vector<int> arguments;
int slevel = p_stack_level;
for (int i = 1; i < on->arguments.size(); i++) {
-
int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -603,8 +586,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(vtype); //instance
codegen.opcodes.push_back(arguments.size()); //argument count
codegen.alloc_call(arguments.size());
- for (int i = 0; i < arguments.size(); i++)
+ for (int i = 0; i < arguments.size(); i++) {
codegen.opcodes.push_back(arguments[i]); //arguments
+ }
} else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
//built in function
@@ -614,10 +598,10 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
Vector<int> arguments;
int slevel = p_stack_level;
for (int i = 1; i < on->arguments.size(); i++) {
-
int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
@@ -631,8 +615,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(static_cast<const GDScriptParser::BuiltInFunctionNode *>(on->arguments[0])->function);
codegen.opcodes.push_back(on->arguments.size() - 1);
codegen.alloc_call(on->arguments.size() - 1);
- for (int i = 0; i < arguments.size(); i++)
+ for (int i = 0; i < arguments.size(); i++) {
codegen.opcodes.push_back(arguments[i]);
+ }
} else {
//regular function
@@ -648,14 +633,12 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int slevel = p_stack_level;
for (int i = 0; i < on->arguments.size(); i++) {
-
int ret;
if (i == 0 && on->arguments[i]->type == GDScriptParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
//static call to self
ret = (GDScriptFunction::ADDR_TYPE_CLASS << GDScriptFunction::ADDR_BITS);
} else if (i == 1) {
-
if (on->arguments[i]->type != GDScriptParser::Node::TYPE_IDENTIFIER) {
_set_error("Attempt to call a non-identifier.", on);
return -1;
@@ -664,10 +647,10 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
ret = codegen.get_name_map_pos(id->name);
} else {
-
ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -679,21 +662,21 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(p_root ? GDScriptFunction::OPCODE_CALL : GDScriptFunction::OPCODE_CALL_RETURN); // perform operator
codegen.opcodes.push_back(on->arguments.size() - 2);
codegen.alloc_call(on->arguments.size() - 2);
- for (int i = 0; i < arguments.size(); i++)
+ for (int i = 0; i < arguments.size(); i++) {
codegen.opcodes.push_back(arguments[i]);
+ }
}
} break;
case GDScriptParser::OperatorNode::OP_YIELD: {
-
ERR_FAIL_COND_V(on->arguments.size() && on->arguments.size() != 2, -1);
Vector<int> arguments;
int slevel = p_stack_level;
for (int i = 0; i < on->arguments.size(); i++) {
-
int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
+ if (ret < 0) {
return ret;
+ }
if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) {
slevel++;
codegen.alloc_stack(slevel);
@@ -703,8 +686,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//push call bytecode
codegen.opcodes.push_back(arguments.size() == 0 ? GDScriptFunction::OPCODE_YIELD : GDScriptFunction::OPCODE_YIELD_SIGNAL); // basic type constructor
- for (int i = 0; i < arguments.size(); i++)
+ for (int i = 0; i < arguments.size(); i++) {
codegen.opcodes.push_back(arguments[i]); //arguments
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_YIELD_RESUME);
//next will be where to place the result :)
@@ -713,22 +697,21 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//indexing operator
case GDScriptParser::OperatorNode::OP_INDEX:
case GDScriptParser::OperatorNode::OP_INDEX_NAMED: {
-
ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
int slevel = p_stack_level;
bool named = (on->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED);
int from = _parse_expression(codegen, on->arguments[0], slevel);
- if (from < 0)
+ if (from < 0) {
return from;
+ }
int index;
if (p_index_addr != 0) {
index = p_index_addr;
} else if (named) {
if (on->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
-
GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1]);
const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(identifier->name);
@@ -749,7 +732,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
index = codegen.get_name_map_pos(static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name);
} else {
-
if (on->arguments[1]->type == GDScriptParser::Node::TYPE_CONSTANT && static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) {
//also, somehow, named (speed up anyway)
StringName name = static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value;
@@ -764,8 +746,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
}
index = _parse_expression(codegen, on->arguments[1], slevel);
- if (index < 0)
+ if (index < 0) {
return index;
+ }
}
}
@@ -775,20 +758,21 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
case GDScriptParser::OperatorNode::OP_AND: {
-
// AND operator with early out on failure
int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
res = _parse_expression(codegen, on->arguments[1], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
@@ -808,20 +792,21 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
case GDScriptParser::OperatorNode::OP_OR: {
-
// OR operator with early out on success
int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF);
codegen.opcodes.push_back(res);
int jump_success_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
res = _parse_expression(codegen, on->arguments[1], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF);
codegen.opcodes.push_back(res);
@@ -842,20 +827,21 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
// ternary operators
case GDScriptParser::OperatorNode::OP_TERNARY_IF: {
-
// x IF a ELSE y operator with early out on failure
int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
res = _parse_expression(codegen, on->arguments[1], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.alloc_stack(p_stack_level); //it will be used..
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
@@ -867,8 +853,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.write[jump_fail_pos] = codegen.opcodes.size();
res = _parse_expression(codegen, on->arguments[2], p_stack_level);
- if (res < 0)
+ if (res < 0) {
return res;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
@@ -881,92 +868,113 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
//unary operators
case GDScriptParser::OperatorNode::OP_NEG: {
- if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level))
+ if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_POS: {
- if (!_create_unary_operator(codegen, on, Variant::OP_POSITIVE, p_stack_level))
+ if (!_create_unary_operator(codegen, on, Variant::OP_POSITIVE, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_NOT: {
- if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level))
+ if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_BIT_INVERT: {
- if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level))
+ if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level)) {
return -1;
+ }
} break;
//binary operators (in precedence order)
case GDScriptParser::OperatorNode::OP_IN: {
- if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_NOT_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_LESS: {
- if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_LESS_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_GREATER: {
- if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_ADD: {
- if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_SUB: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_MUL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_DIV: {
- if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_MOD: {
- if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level)) {
return -1;
+ }
} break;
//case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break;
//case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break;
case GDScriptParser::OperatorNode::OP_BIT_AND: {
- if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_BIT_OR: {
- if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_BIT_XOR: {
- if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level)) {
return -1;
+ }
} break;
//shift
case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level)) {
return -1;
+ }
} break;
case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level))
+ if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level)) {
return -1;
+ }
} break;
//assignment operators
case GDScriptParser::OperatorNode::OP_ASSIGN_ADD:
@@ -981,18 +989,15 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR:
case GDScriptParser::OperatorNode::OP_INIT_ASSIGN:
case GDScriptParser::OperatorNode::OP_ASSIGN: {
-
ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
if (on->arguments[0]->type == GDScriptParser::Node::TYPE_OPERATOR && (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX || static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED)) {
-
// SET (chained) MODE!
#ifdef DEBUG_ENABLED
if (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
const GDScriptParser::OperatorNode *inon = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]);
if (inon->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
-
const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name);
if (MI && MI->get().setter == codegen.function_node->name) {
String n = static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name;
@@ -1017,13 +1022,10 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//create get/set chain
GDScriptParser::OperatorNode *n = op;
while (true) {
-
chain.push_back(n);
if (n->arguments[0]->type != GDScriptParser::Node::TYPE_OPERATOR) {
-
//check for a built-in property
if (n->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
-
GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(n->arguments[0]);
if (_is_class_member_property(codegen, identifier->name)) {
assign_property = identifier->name;
@@ -1032,8 +1034,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
break;
}
n = static_cast<GDScriptParser::OperatorNode *>(n->arguments[0]);
- if (n->op != GDScriptParser::OperatorNode::OP_INDEX && n->op != GDScriptParser::OperatorNode::OP_INDEX_NAMED)
+ if (n->op != GDScriptParser::OperatorNode::OP_INDEX && n->op != GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
break;
+ }
}
}
@@ -1041,8 +1044,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//get at (potential) root stack pos, so it can be returned
int prev_pos = _parse_expression(codegen, chain.back()->get()->arguments[0], slevel);
- if (prev_pos < 0)
+ if (prev_pos < 0) {
return prev_pos;
+ }
int retval = prev_pos;
if (retval & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
@@ -1053,7 +1057,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
Vector<int> setchain;
if (assign_property != StringName()) {
-
// recover and assign at the end, this allows stuff like
// position.x+=2.0
// in Node2D
@@ -1063,20 +1066,18 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
}
for (List<GDScriptParser::OperatorNode *>::Element *E = chain.back(); E; E = E->prev()) {
-
- if (E == chain.front()) //ignore first
+ if (E == chain.front()) { //ignore first
break;
+ }
bool named = E->get()->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED;
int key_idx;
if (named) {
-
key_idx = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(E->get()->arguments[1])->name);
//printf("named key %x\n",key_idx);
} else {
-
if (prev_pos & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) {
slevel++;
codegen.alloc_stack(slevel);
@@ -1089,8 +1090,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
//stack was raised here if retval was stack but..
}
- if (key_idx < 0) //error
+ if (key_idx < 0) { //error
return key_idx;
+ }
codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::OPCODE_GET);
codegen.opcodes.push_back(prev_pos);
@@ -1117,17 +1119,16 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
bool named = false;
if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
-
set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name);
named = true;
} else {
-
set_index = _parse_expression(codegen, op->arguments[1], slevel + 1);
named = false;
}
- if (set_index < 0) //error
+ if (set_index < 0) { //error
return set_index;
+ }
if (set_index & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
@@ -1135,8 +1136,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
}
int set_value = _parse_assign_right_expression(codegen, on, slevel + 1, named ? 0 : set_index);
- if (set_value < 0) //error
+ if (set_value < 0) { //error
return set_value;
+ }
codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET);
codegen.opcodes.push_back(prev_pos);
@@ -1144,7 +1146,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(set_value);
for (int i = 0; i < setchain.size(); i++) {
-
codegen.opcodes.push_back(setchain[i]);
}
@@ -1156,8 +1157,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int slevel = p_stack_level;
int src_address = _parse_assign_right_expression(codegen, on, slevel);
- if (src_address < 0)
+ if (src_address < 0) {
return -1;
+ }
StringName name = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name;
@@ -1167,14 +1169,14 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
return GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
} else {
-
//REGULAR ASSIGNMENT MODE!!
int slevel = p_stack_level;
int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN);
- if (dst_address_a < 0)
+ if (dst_address_a < 0) {
return -1;
+ }
if (dst_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
@@ -1182,8 +1184,9 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
}
int src_address_b = _parse_assign_right_expression(codegen, on, slevel);
- if (src_address_b < 0)
+ if (src_address_b < 0) {
return -1;
+ }
GDScriptDataType assign_type = _gdtype_from_datatype(on->arguments[0]->get_datatype());
@@ -1199,7 +1202,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
case GDScriptDataType::NATIVE: {
int class_idx;
if (GDScriptLanguage::get_singleton()->get_global_map().has(assign_type.native_type)) {
-
class_idx = GDScriptLanguage::get_singleton()->get_global_map()[assign_type.native_type];
class_idx |= (GDScriptFunction::ADDR_TYPE_GLOBAL << GDScriptFunction::ADDR_BITS); //argument (stack root)
} else {
@@ -1213,7 +1215,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
case GDScriptDataType::SCRIPT:
case GDScriptDataType::GDSCRIPT: {
-
Variant script = assign_type.script_type;
int idx = codegen.get_constant_pos(script);
idx |= GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS; //make it a local constant (faster access)
@@ -1242,21 +1243,23 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
}
} break;
case GDScriptParser::OperatorNode::OP_IS: {
-
ERR_FAIL_COND_V(on->arguments.size() != 2, false);
int slevel = p_stack_level;
int src_address_a = _parse_expression(codegen, on->arguments[0], slevel);
- if (src_address_a < 0)
+ if (src_address_a < 0) {
return -1;
+ }
- if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++; //uses stack for return, increase stack
+ }
int src_address_b = _parse_expression(codegen, on->arguments[1], slevel);
- if (src_address_b < 0)
+ if (src_address_b < 0) {
return -1;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_EXTENDS_TEST); // perform operator
codegen.opcodes.push_back(src_address_a); // argument 1
@@ -1270,11 +1273,13 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int slevel = p_stack_level;
int src_address_a = _parse_expression(codegen, on->arguments[0], slevel);
- if (src_address_a < 0)
+ if (src_address_a < 0) {
return -1;
+ }
- if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++; //uses stack for return, increase stack
+ }
const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(on->arguments[1]);
@@ -1283,7 +1288,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back((int)tn->vtype); // argument 2 (unary only takes one parameter)
} break;
default: {
-
ERR_FAIL_V_MSG(0, "Bug in bytecode compiler, unexpected operator #" + itos(on->op) + " in parse tree while parsing expression."); //unreachable code
} break;
@@ -1296,20 +1300,17 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
} break;
//TYPE_TYPE,
default: {
-
ERR_FAIL_V_MSG(-1, "Bug in bytecode compiler, unexpected node in parse tree while parsing expression."); //unreachable code
} break;
}
}
Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
-
codegen.push_stack_identifiers();
int new_identifiers = 0;
codegen.current_line = p_block->line;
for (int i = 0; i < p_block->statements.size(); i++) {
-
const GDScriptParser::Node *s = p_block->statements[i];
switch (s->type) {
@@ -1327,7 +1328,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
const GDScriptParser::ControlFlowNode *cf = static_cast<const GDScriptParser::ControlFlowNode *>(s);
switch (cf->cf_type) {
-
case GDScriptParser::ControlFlowNode::CF_MATCH: {
GDScriptParser::MatchNode *match = cf->match;
@@ -1401,10 +1401,10 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_IF: {
-
int ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret2 < 0)
+ if (ret2 < 0) {
return ERR_PARSE_ERROR;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(ret2);
@@ -1412,19 +1412,20 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.opcodes.push_back(0); //temporary
Error err = _parse_block(codegen, cf->body, p_stack_level, p_break_addr, p_continue_addr);
- if (err)
+ if (err) {
return err;
+ }
if (cf->body_else) {
-
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
int end_addr = codegen.opcodes.size();
codegen.opcodes.push_back(0);
codegen.opcodes.write[else_addr] = codegen.opcodes.size();
Error err2 = _parse_block(codegen, cf->body_else, p_stack_level, p_break_addr, p_continue_addr);
- if (err2)
+ if (err2) {
return err2;
+ }
codegen.opcodes.write[end_addr] = codegen.opcodes.size();
} else {
@@ -1434,7 +1435,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_FOR: {
-
int slevel = p_stack_level;
int iter_stack_pos = slevel;
int iterator_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
@@ -1446,8 +1446,9 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.add_stack_identifier(static_cast<const GDScriptParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos);
int ret2 = _parse_expression(codegen, cf->arguments[1], slevel, false);
- if (ret2 < 0)
+ if (ret2 < 0) {
return ERR_COMPILATION_FAILED;
+ }
//assign container
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
@@ -1475,8 +1476,9 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
codegen.opcodes.push_back(iterator_pos);
Error err = _parse_block(codegen, cf->body, slevel, break_pos, continue_pos);
- if (err)
+ if (err) {
return err;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(continue_pos);
@@ -1486,7 +1488,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_WHILE: {
-
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
int break_addr = codegen.opcodes.size();
@@ -1495,14 +1496,16 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
int continue_addr = codegen.opcodes.size();
int ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret2 < 0)
+ if (ret2 < 0) {
return ERR_PARSE_ERROR;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(ret2);
codegen.opcodes.push_back(break_addr);
Error err = _parse_block(codegen, cf->body, p_stack_level, break_addr, continue_addr);
- if (err)
+ if (err) {
return err;
+ }
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(continue_addr);
@@ -1510,9 +1513,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_BREAK: {
-
if (p_break_addr < 0) {
-
_set_error("'break'' not within loop", cf);
return ERR_COMPILATION_FAILED;
}
@@ -1521,9 +1522,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
-
if (p_continue_addr < 0) {
-
_set_error("'continue' not within loop", cf);
return ERR_COMPILATION_FAILED;
}
@@ -1533,17 +1532,15 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
} break;
case GDScriptParser::ControlFlowNode::CF_RETURN: {
-
int ret2;
if (cf->arguments.size()) {
-
ret2 = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret2 < 0)
+ if (ret2 < 0) {
return ERR_PARSE_ERROR;
+ }
} else {
-
ret2 = GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
}
@@ -1560,14 +1557,16 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
const GDScriptParser::AssertNode *as = static_cast<const GDScriptParser::AssertNode *>(s);
int ret2 = _parse_expression(codegen, as->condition, p_stack_level, false);
- if (ret2 < 0)
+ if (ret2 < 0) {
return ERR_PARSE_ERROR;
+ }
int message_ret = 0;
if (as->message) {
message_ret = _parse_expression(codegen, as->message, p_stack_level + 1, false);
- if (message_ret < 0)
+ if (message_ret < 0) {
return ERR_PARSE_ERROR;
+ }
}
codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSERT);
@@ -1582,7 +1581,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
#endif
} break;
case GDScriptParser::Node::TYPE_LOCAL_VAR: {
-
const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(s);
// since we are using properties now for most class access, allow shadowing of class members to make user's life easier.
@@ -1600,8 +1598,9 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
default: {
//expression
int ret2 = _parse_expression(codegen, s, p_stack_level, true);
- if (ret2 < 0)
+ if (ret2 < 0) {
return ERR_PARSE_ERROR;
+ }
} break;
}
}
@@ -1610,7 +1609,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
}
Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready) {
-
Vector<int> bytecode;
CodeGen codegen;
@@ -1651,7 +1649,6 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
if (is_initializer || (p_func && String(p_func->name) == "_init")) {
//parse initializer for class members
if (!p_func && p_class->extends_used && p_script->native.is_null()) {
-
//call implicit parent constructor
codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_SELF_BASE);
codegen.opcodes.push_back(codegen.get_name_map_pos("_init"));
@@ -1659,8 +1656,9 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
codegen.opcodes.push_back((GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | 0);
}
Error err = _parse_block(codegen, p_class->initializer, stack_level);
- if (err)
+ if (err) {
return err;
+ }
is_initializer = true;
}
@@ -1668,8 +1666,9 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
//parse initializer for class members
if (p_class->ready->statements.size()) {
Error err = _parse_block(codegen, p_class->ready, stack_level);
- if (err)
+ if (err) {
return err;
+ }
}
}
@@ -1679,13 +1678,10 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
StringName func_name;
if (p_func) {
-
if (p_func->default_values.size()) {
-
codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
defarg_addr.push_back(codegen.opcodes.size());
for (int i = 0; i < p_func->default_values.size(); i++) {
-
_parse_expression(codegen, p_func->default_values[i], stack_level, true);
defarg_addr.push_back(codegen.opcodes.size());
}
@@ -1694,15 +1690,17 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
}
Error err = _parse_block(codegen, p_func->body, stack_level);
- if (err)
+ if (err) {
return err;
+ }
func_name = p_func->name;
} else {
- if (p_for_ready)
+ if (p_for_ready) {
func_name = "_ready";
- else
+ } else {
func_name = "_init";
+ }
}
codegen.opcodes.push_back(GDScriptFunction::OPCODE_END);
@@ -1747,17 +1745,14 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
gdfunc->constants.write[idx] = *K;
}
} else {
-
gdfunc->_constants_ptr = nullptr;
gdfunc->_constant_count = 0;
}
//global names
if (codegen.name_map.size()) {
-
gdfunc->global_names.resize(codegen.name_map.size());
gdfunc->_global_names_ptr = &gdfunc->global_names[0];
for (Map<StringName, int>::Element *E = codegen.name_map.front(); E; E = E->next()) {
-
gdfunc->global_names.write[E->get()] = E->key();
}
gdfunc->_global_names_count = gdfunc->global_names.size();
@@ -1780,19 +1775,16 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
#endif
if (codegen.opcodes.size()) {
-
gdfunc->code = codegen.opcodes;
gdfunc->_code_ptr = &gdfunc->code[0];
gdfunc->_code_size = codegen.opcodes.size();
} else {
-
gdfunc->_code_ptr = nullptr;
gdfunc->_code_size = 0;
}
if (defarg_addr.size()) {
-
gdfunc->default_arguments = defarg_addr;
gdfunc->_default_arg_count = defarg_addr.size() - 1;
gdfunc->_default_arg_ptr = &gdfunc->default_arguments[0];
@@ -1809,8 +1801,9 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
if (EngineDebugger::is_active()) {
String signature;
//path
- if (p_script->get_path() != String())
+ if (p_script->get_path() != String()) {
signature += p_script->get_path();
+ }
//loc
if (p_func) {
signature += "::" + itos(p_func->body->line);
@@ -1850,17 +1843,18 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
gdfunc->_initial_line = 0;
}
- if (codegen.debug_stack)
+ if (codegen.debug_stack) {
gdfunc->stack_debug = codegen.stack_debug;
+ }
- if (is_initializer)
+ if (is_initializer) {
p_script->initializer = gdfunc;
+ }
return OK;
}
Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
-
parsing_classes.insert(p_script);
if (p_class->owner && p_class->owner->owner) {
@@ -1931,7 +1925,6 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
}
for (int i = 0; i < p_class->variables.size(); i++) {
-
StringName name = p_class->variables[i].identifier;
GDScript::MemberInfo minfo;
@@ -1946,7 +1939,6 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
PropertyInfo export_info = p_class->variables[i]._export;
if (export_info.type != Variant::NIL) {
-
if (!minfo.data_type.has_type) {
prop_info.type = export_info.type;
prop_info.class_name = export_info.class_name;
@@ -1973,7 +1965,6 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
}
for (Map<StringName, GDScriptParser::ClassNode::Constant>::Element *E = p_class->constant_expressions.front(); E; E = E->next()) {
-
StringName name = E->key();
ERR_CONTINUE(E->get().expression->type != GDScriptParser::Node::TYPE_CONSTANT);
@@ -1988,13 +1979,11 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
}
for (int i = 0; i < p_class->_signals.size(); i++) {
-
StringName name = p_class->_signals[i].name;
GDScript *c = p_script;
while (c) {
-
if (c->_signals.has(name)) {
_set_error("Signal '" + name + "' redefined (in current or parent class)", p_class);
return ERR_ALREADY_EXISTS;
@@ -2030,8 +2019,9 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
// Subclass might still be parsing, just skip it
if (!parsed_classes.has(subclass_ptr) && !parsing_classes.has(subclass_ptr)) {
Error err = _parse_class_level(subclass_ptr, p_class->subclasses[i], p_keep_state);
- if (err)
+ if (err) {
return err;
+ }
}
#ifdef TOOLS_ENABLED
@@ -2052,37 +2042,41 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
bool has_ready = false;
for (int i = 0; i < p_class->functions.size(); i++) {
-
- if (!has_initializer && p_class->functions[i]->name == "_init")
+ if (!has_initializer && p_class->functions[i]->name == "_init") {
has_initializer = true;
- if (!has_ready && p_class->functions[i]->name == "_ready")
+ }
+ if (!has_ready && p_class->functions[i]->name == "_ready") {
has_ready = true;
+ }
Error err = _parse_function(p_script, p_class, p_class->functions[i]);
- if (err)
+ if (err) {
return err;
+ }
}
//parse static methods
for (int i = 0; i < p_class->static_functions.size(); i++) {
-
Error err = _parse_function(p_script, p_class, p_class->static_functions[i]);
- if (err)
+ if (err) {
return err;
+ }
}
if (!has_initializer) {
//create a constructor
Error err = _parse_function(p_script, p_class, nullptr);
- if (err)
+ if (err) {
return err;
+ }
}
if (!has_ready && p_class->ready->statements.size()) {
//create a constructor
Error err = _parse_function(p_script, p_class, nullptr, true);
- if (err)
+ if (err) {
return err;
+ }
}
#ifdef DEBUG_ENABLED
@@ -2091,7 +2085,6 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
if (p_keep_state) {
for (Set<Object *>::Element *E = p_script->instances.front(); E;) {
-
Set<Object *>::Element *N = E->next();
ScriptInstance *si = E->get()->get_script_instance();
@@ -2126,7 +2119,6 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
}
#endif
} else {
-
GDScriptInstance *gi = static_cast<GDScriptInstance *>(si);
gi->reload_members();
}
@@ -2151,7 +2143,6 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
}
void GDScriptCompiler::_make_scripts(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
-
Map<StringName, Ref<GDScript>> old_subclasses;
if (p_keep_state) {
@@ -2186,7 +2177,6 @@ void GDScriptCompiler::_make_scripts(GDScript *p_script, const GDScriptParser::C
}
Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state) {
-
err_line = -1;
err_column = -1;
error = "";
@@ -2206,27 +2196,28 @@ Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_scri
p_script->_owner = nullptr;
Error err = _parse_class_level(p_script, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state);
- if (err)
+ if (err) {
return err;
+ }
err = _parse_class_blocks(p_script, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state);
- if (err)
+ if (err) {
return err;
+ }
return OK;
}
String GDScriptCompiler::get_error() const {
-
return error;
}
-int GDScriptCompiler::get_error_line() const {
+int GDScriptCompiler::get_error_line() const {
return err_line;
}
-int GDScriptCompiler::get_error_column() const {
+int GDScriptCompiler::get_error_column() const {
return err_column;
}
diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h
index 08e1ec74af..315d4f1842 100644
--- a/modules/gdscript/gdscript_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -36,13 +36,11 @@
#include "gdscript_parser.h"
class GDScriptCompiler {
-
const GDScriptParser *parser;
Set<GDScript *> parsed_classes;
Set<GDScript *> parsing_classes;
GDScript *main_script;
struct CodeGen {
-
GDScript *script;
const GDScriptParser::ClassNode *class_node;
const GDScriptParser::FunctionNode *function_node;
@@ -71,7 +69,6 @@ class GDScriptCompiler {
void push_stack_identifiers() {
stack_id_stack.push_back(stack_identifiers);
if (debug_stack) {
-
block_identifier_stack.push_back(block_identifiers);
block_identifiers.clear();
}
@@ -83,7 +80,6 @@ class GDScriptCompiler {
if (debug_stack) {
for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) {
-
GDScriptFunction::StackDebug sd;
sd.added = false;
sd.identifier = E->key();
@@ -114,8 +110,9 @@ class GDScriptCompiler {
}
int get_constant_pos(const Variant &p_constant) {
- if (constant_map.has(p_constant))
+ if (constant_map.has(p_constant)) {
return constant_map[p_constant];
+ }
int pos = constant_map.size();
constant_map[p_constant] = pos;
return pos;
@@ -123,12 +120,14 @@ class GDScriptCompiler {
Vector<int> opcodes;
void alloc_stack(int p_level) {
- if (p_level >= stack_max)
+ if (p_level >= stack_max) {
stack_max = p_level + 1;
+ }
}
void alloc_call(int p_params) {
- if (p_params >= call_max)
+ if (p_params >= call_max) {
call_max = p_params;
+ }
}
int current_line;
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 8af98c187f..3a5db3687b 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -41,19 +41,16 @@
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
-
p_delimiters->push_back("#");
}
void GDScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
-
p_delimiters->push_back("\" \"");
p_delimiters->push_back("' '");
p_delimiters->push_back("\"\"\" \"\"\"");
}
String GDScriptLanguage::_get_processed_template(const String &p_template, const String &p_base_class_name) const {
-
String processed_template = p_template;
#ifdef TOOLS_ENABLED
@@ -109,18 +106,15 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
}
bool GDScriptLanguage::is_using_templates() {
-
return true;
}
void GDScriptLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {
-
String _template = _get_processed_template(p_script->get_source_code(), p_base_class_name);
p_script->set_source_code(_template);
}
bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
-
GDScriptParser parser;
Error err = parser.parse(p_script, p_path.get_base_dir(), true, p_path, false, r_safe_lines);
@@ -143,35 +137,29 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
r_test_error = parser.get_error();
return false;
} else {
-
const GDScriptParser::Node *root = parser.get_parse_tree();
ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
Map<int, String> funcs;
for (int i = 0; i < cl->functions.size(); i++) {
-
funcs[cl->functions[i]->line] = cl->functions[i]->name;
}
for (int i = 0; i < cl->static_functions.size(); i++) {
-
funcs[cl->static_functions[i]->line] = cl->static_functions[i]->name;
}
for (int i = 0; i < cl->subclasses.size(); i++) {
for (int j = 0; j < cl->subclasses[i]->functions.size(); j++) {
-
funcs[cl->subclasses[i]->functions[j]->line] = String(cl->subclasses[i]->name) + "." + cl->subclasses[i]->functions[j]->name;
}
for (int j = 0; j < cl->subclasses[i]->static_functions.size(); j++) {
-
funcs[cl->subclasses[i]->static_functions[j]->line] = String(cl->subclasses[i]->name) + "." + cl->subclasses[i]->static_functions[j]->name;
}
}
for (Map<int, String>::Element *E = funcs.front(); E; E = E->next()) {
-
r_functions->push_back(E->get() + ":" + itos(E->key()));
}
}
@@ -180,27 +168,22 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
}
bool GDScriptLanguage::has_named_classes() const {
-
return false;
}
bool GDScriptLanguage::supports_builtin_mode() const {
-
return true;
}
int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const {
-
GDScriptTokenizerText tokenizer;
tokenizer.set_code(p_code);
int indent = 0;
while (tokenizer.get_token() != GDScriptTokenizer::TK_EOF && tokenizer.get_token() != GDScriptTokenizer::TK_ERROR) {
-
if (tokenizer.get_token() == GDScriptTokenizer::TK_NEWLINE) {
indent = tokenizer.get_token_line_indent();
}
if (indent == 0 && tokenizer.get_token() == GDScriptTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDScriptTokenizer::TK_IDENTIFIER) {
-
String identifier = tokenizer.get_token_identifier(1);
if (identifier == p_function) {
return tokenizer.get_token_line();
@@ -212,7 +195,6 @@ int GDScriptLanguage::find_function(const String &p_function, const String &p_co
}
Script *GDScriptLanguage::create_script() const {
-
return memnew(GDScript);
}
@@ -222,7 +204,6 @@ bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const
//break because of parse error
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
-
_debug_parse_err_line = p_line;
_debug_parse_err_file = p_file;
_debug_error = p_error;
@@ -234,9 +215,7 @@ bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const
}
bool GDScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) {
-
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
-
_debug_parse_err_line = -1;
_debug_parse_err_file = "";
_debug_error = p_error;
@@ -249,21 +228,21 @@ bool GDScriptLanguage::debug_break(const String &p_error, bool p_allow_continue)
}
String GDScriptLanguage::debug_get_error() const {
-
return _debug_error;
}
int GDScriptLanguage::debug_get_stack_level_count() const {
-
- if (_debug_parse_err_line >= 0)
+ if (_debug_parse_err_line >= 0) {
return 1;
+ }
return _debug_call_stack_pos;
}
-int GDScriptLanguage::debug_get_stack_level_line(int p_level) const {
- if (_debug_parse_err_line >= 0)
+int GDScriptLanguage::debug_get_stack_level_line(int p_level) const {
+ if (_debug_parse_err_line >= 0) {
return _debug_parse_err_line;
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, -1);
@@ -271,28 +250,31 @@ int GDScriptLanguage::debug_get_stack_level_line(int p_level) const {
return *(_call_stack[l].line);
}
-String GDScriptLanguage::debug_get_stack_level_function(int p_level) const {
- if (_debug_parse_err_line >= 0)
+String GDScriptLanguage::debug_get_stack_level_function(int p_level) const {
+ if (_debug_parse_err_line >= 0) {
return "";
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, "");
int l = _debug_call_stack_pos - p_level - 1;
return _call_stack[l].function->get_name();
}
-String GDScriptLanguage::debug_get_stack_level_source(int p_level) const {
- if (_debug_parse_err_line >= 0)
+String GDScriptLanguage::debug_get_stack_level_source(int p_level) const {
+ if (_debug_parse_err_line >= 0) {
return _debug_parse_err_file;
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, "");
int l = _debug_call_stack_pos - p_level - 1;
return _call_stack[l].function->get_source();
}
-void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_debug_parse_err_line >= 0)
+void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+ if (_debug_parse_err_line >= 0) {
return;
+ }
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
@@ -303,23 +285,24 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p
f->debug_get_stack_member_state(*_call_stack[l].line, &locals);
for (List<Pair<StringName, int>>::Element *E = locals.front(); E; E = E->next()) {
-
p_locals->push_back(E->get().first);
p_values->push_back(_call_stack[l].stack[E->get().second]);
}
}
-void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_debug_parse_err_line >= 0)
+void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+ if (_debug_parse_err_line >= 0) {
return;
+ }
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
GDScriptInstance *instance = _call_stack[l].instance;
- if (!instance)
+ if (!instance) {
return;
+ }
Ref<GDScript> script = instance->get_script();
ERR_FAIL_COND(script.is_null());
@@ -327,16 +310,15 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *
const Map<StringName, GDScript::MemberInfo> &mi = script->debug_get_member_indices();
for (const Map<StringName, GDScript::MemberInfo>::Element *E = mi.front(); E; E = E->next()) {
-
p_members->push_back(E->key());
p_values->push_back(instance->debug_get_member_by_index(E->get().index));
}
}
ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
-
- if (_debug_parse_err_line >= 0)
+ if (_debug_parse_err_line >= 0) {
return nullptr;
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, nullptr);
@@ -347,7 +329,6 @@ ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
}
void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
-
const Map<StringName, int> &name_idx = GDScriptLanguage::get_singleton()->get_global_map();
const Variant *globals = GDScriptLanguage::get_singleton()->get_global_array();
@@ -355,9 +336,9 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
get_public_constants(&cinfo);
for (const Map<StringName, int>::Element *E = name_idx.front(); E; E = E->next()) {
-
- if (ClassDB::class_exists(E->key()) || Engine::get_singleton()->has_singleton(E->key()))
+ if (ClassDB::class_exists(E->key()) || Engine::get_singleton()->has_singleton(E->key())) {
continue;
+ }
bool is_script_constant = false;
for (List<Pair<String, Variant>>::Element *CE = cinfo.front(); CE; CE = CE->next()) {
@@ -366,13 +347,15 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
break;
}
}
- if (is_script_constant)
+ if (is_script_constant) {
continue;
+ }
const Variant &var = globals[E->value()];
if (Object *obj = var) {
- if (Object::cast_to<GDScriptNativeClass>(obj))
+ if (Object::cast_to<GDScriptNativeClass>(obj)) {
continue;
+ }
}
bool skip = false;
@@ -382,8 +365,9 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
break;
}
}
- if (skip)
+ if (skip) {
continue;
+ }
p_globals->push_back(E->key());
p_values->push_back(var);
@@ -391,19 +375,15 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
}
String GDScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
-
return "";
}
void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("gd");
}
void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
-
for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
-
p_functions->push_back(GDScriptFunctions::get_info(GDScriptFunctions::Function(i)));
}
@@ -437,7 +417,6 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
}
void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
-
Pair<String, Variant> pi;
pi.first = "PI";
pi.second = Math_PI;
@@ -460,7 +439,6 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_const
}
String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
-
#ifdef TOOLS_ENABLED
bool th = EditorSettings::get_singleton()->get_setting("text_editor/completion/add_type_hints");
#else
@@ -470,8 +448,9 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
String s = "func " + p_name + "(";
if (p_args.size()) {
for (int i = 0; i < p_args.size(); i++) {
- if (i > 0)
+ if (i > 0) {
s += ", ";
+ }
s += p_args[i].get_slice(":", 0);
if (th) {
String type = p_args[i].get_slice(":", 1);
@@ -491,36 +470,27 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
struct GDScriptCompletionContext {
-
- const GDScriptParser::ClassNode *_class;
- const GDScriptParser::FunctionNode *function;
- const GDScriptParser::BlockNode *block;
- Object *base;
+ const GDScriptParser::ClassNode *_class = nullptr;
+ const GDScriptParser::FunctionNode *function = nullptr;
+ const GDScriptParser::BlockNode *block = nullptr;
+ Object *base = nullptr;
String base_path;
- int line;
- uint32_t depth;
-
- GDScriptCompletionContext() :
- _class(nullptr),
- function(nullptr),
- block(nullptr),
- base(nullptr),
- line(0),
- depth(0) {}
+ int line = 0;
+ uint32_t depth = 0;
+
+ GDScriptCompletionContext() {}
};
struct GDScriptCompletionIdentifier {
GDScriptParser::DataType type;
String enumeration;
Variant value;
- const GDScriptParser::Node *assigned_expression;
+ const GDScriptParser::Node *assigned_expression = nullptr;
- GDScriptCompletionIdentifier() :
- assigned_expression(nullptr) {}
+ GDScriptCompletionIdentifier() {}
};
static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) {
-
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
for (int i = 0; i < p_dir->get_file_count(); i++) {
@@ -535,7 +505,6 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
}
static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = true) {
-
if (p_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
String enum_name = p_info.class_name;
if (enum_name.find(".") == -1) {
@@ -835,7 +804,6 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
Object *baseptr = base.value;
if (all_is_const && String(id) == "get_node" && ClassDB::is_parent_class(native_type.native_type, "Node") && args.size()) {
-
String arg1 = args[0];
if (arg1.begins_with("/root/")) {
String which = arg1.get_slice("/", 2);
@@ -849,7 +817,6 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String s = E->get().name;
if (!s.begins_with("autoload/")) {
continue;
@@ -1191,7 +1158,6 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
}
static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type) {
-
// Look in blocks first
const GDScriptParser::BlockNode *blk = p_context.block;
int last_assign_line = -1;
@@ -1753,7 +1719,6 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con
}
static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
-
String arghint = _get_visual_datatype(p_info.return_val, false) + " " + p_info.name + "(";
int def_args = p_info.arguments.size() - p_info.default_arguments.size();
@@ -1798,7 +1763,6 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
}
static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_function, int p_arg_idx) {
-
String arghint = p_function->return_type.to_string() + " " + p_function->name.operator String() + "(";
int def_args = p_function->arguments.size() - p_function->default_values.size();
@@ -1840,7 +1804,6 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
}
static void _find_enumeration_candidates(const String p_enum_hint, Map<String, ScriptCodeCompletionOption> &r_result) {
-
if (p_enum_hint.find(".") == -1) {
// Global constant
StringName current_enum = p_enum_hint;
@@ -2119,7 +2082,11 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
if (!p_only_functions) {
List<PropertyInfo> members;
- tmp.get_property_list(&members);
+ if (p_base.value.get_type() != Variant::NIL) {
+ p_base.value.get_property_list(&members);
+ } else {
+ tmp.get_property_list(&members);
+ }
for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) {
if (String(E->get().name).find("/") == -1) {
@@ -2151,11 +2118,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
}
static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result) {
-
const GDScriptParser::BlockNode *block = p_context.block;
if (p_context.function) {
-
const GDScriptParser::FunctionNode *f = p_context.function;
for (int i = 0; i < f->arguments.size(); i++) {
@@ -2424,7 +2389,6 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
}
static void _find_call_arguments(GDScriptCompletionContext &p_context, const GDScriptParser::Node *p_node, int p_argidx, Map<String, ScriptCodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) {
-
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
if (!p_node || p_node->type != GDScriptParser::Node::TYPE_OPERATOR) {
@@ -2480,7 +2444,6 @@ static void _find_call_arguments(GDScriptCompletionContext &p_context, const GDS
}
return;
} else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_SELF) {
-
if (op->arguments.size() < 2 || op->arguments[1]->type != GDScriptParser::Node::TYPE_IDENTIFIER) {
return;
}
@@ -2554,7 +2517,6 @@ static void _find_call_arguments(GDScriptCompletionContext &p_context, const GDS
}
Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
-
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
GDScriptParser parser;
@@ -2602,7 +2564,6 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
p_owner->get_argument_options("get_node", 0, &opts);
for (List<String>::Element *E = opts.front(); E; E = E->next()) {
-
String opt = E->get().strip_edges();
if (opt.is_quoted()) {
r_forced = true;
@@ -2710,7 +2671,6 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
List<MethodInfo> virtual_methods;
ClassDB::get_virtual_methods(class_name, &virtual_methods);
for (List<MethodInfo>::Element *E = virtual_methods.front(); E; E = E->next()) {
-
MethodInfo &mi = E->get();
String method_hint = mi.name;
if (method_hint.find(":") != -1) {
@@ -3034,19 +2994,16 @@ String GDScriptLanguage::_get_indentation() const {
}
void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
-
String indent = _get_indentation();
Vector<String> lines = p_code.split("\n");
List<int> indent_stack;
for (int i = 0; i < lines.size(); i++) {
-
String l = lines[i];
int tc = 0;
for (int j = 0; j < l.length(); j++) {
if (l[j] == ' ' || l[j] == '\t') {
-
tc++;
} else {
break;
@@ -3054,8 +3011,9 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
}
String st = l.substr(tc, l.length()).strip_edges();
- if (st == "" || st.begins_with("#"))
+ if (st == "" || st.begins_with("#")) {
continue; //ignore!
+ }
int ilevel = 0;
if (indent_stack.size()) {
@@ -3069,12 +3027,12 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
indent_stack.pop_back();
}
- if (indent_stack.size() && indent_stack.back()->get() != tc)
+ if (indent_stack.size() && indent_stack.back()->get() != tc) {
indent_stack.push_back(tc); //this is not right but gets the job done
+ }
}
if (i >= p_from_line) {
-
l = "";
for (int j = 0; j < indent_stack.size(); j++) {
l += indent;
@@ -3090,8 +3048,9 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
p_code = "";
for (int i = 0; i < lines.size(); i++) {
- if (i > 0)
+ if (i > 0) {
p_code += "\n";
+ }
p_code += lines[i];
}
}
@@ -3134,6 +3093,14 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return OK;
}
}
+
+ for (int i = 0; i < base_type.class_type->subclasses.size(); i++) {
+ if (base_type.class_type->subclasses[i]->name == p_symbol) {
+ r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.location = base_type.class_type->subclasses[i]->line;
+ return OK;
+ }
+ }
}
base_type = base_type.class_type->base_type;
}
@@ -3278,7 +3245,6 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
-
//before parsing, try the usual stuff
if (ClassDB::class_exists(p_symbol)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
@@ -3359,7 +3325,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
[[fallthrough]];
}
case GDScriptParser::COMPLETION_IDENTIFIER: {
-
if (!is_function) {
is_function = parser.get_completion_identifier_is_function();
}
@@ -3411,13 +3376,12 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String s = E->get().name;
- if (!s.begins_with("autoload/"))
+ if (!s.begins_with("autoload/")) {
continue;
+ }
String name = s.get_slice("/", 1);
if (name == String(p_symbol)) {
-
String path = ProjectSettings::get_singleton()->get(s);
if (path.begins_with("*")) {
String script = path.substr(1, path.length());
@@ -3429,7 +3393,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
if (FileAccess::exists(script)) {
-
r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
r_result.location = 0;
r_result.script = ResourceLoader::load(script);
@@ -3512,7 +3475,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
case GDScriptParser::COMPLETION_TYPE_HINT: {
-
GDScriptParser::DataType base_type = context._class->base_type;
base_type.has_type = true;
base_type.kind = GDScriptParser::DataType::CLASS;
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index df0fac956c..1aab71d161 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -35,12 +35,10 @@
#include "gdscript_functions.h"
Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const {
-
int address = p_address & ADDR_MASK;
//sequential table (jump table generated by compiler)
switch ((p_address & ADDR_TYPE_MASK) >> ADDR_BITS) {
-
case ADDR_TYPE_SELF: {
#ifdef DEBUG_ENABLED
if (unlikely(!p_instance)) {
@@ -51,7 +49,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
return &self;
} break;
case ADDR_TYPE_CLASS: {
-
return &static_ref;
} break;
case ADDR_TYPE_MEMBER: {
@@ -65,7 +62,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
return &p_instance->members.write[address];
} break;
case ADDR_TYPE_CLASS_CONSTANT: {
-
//todo change to index!
GDScript *s = p_script;
#ifdef DEBUG_ENABLED
@@ -76,7 +72,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
while (s) {
GDScript *o = s;
while (o) {
-
Map<StringName, Variant>::Element *E = o->constants.find(*sn);
if (E) {
return &E->get();
@@ -133,7 +128,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
#ifdef DEBUG_ENABLED
static String _get_var_type(const Variant *p_var) {
-
String basestr;
if (p_var->get_type() == Variant::OBJECT) {
@@ -146,10 +140,11 @@ static String _get_var_type(const Variant *p_var) {
basestr = "previously freed";
}
} else {
- if (bobj->get_script_instance())
+ if (bobj->get_script_instance()) {
basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")";
- else
+ } else {
basestr = bobj->get_class();
+ }
}
} else {
@@ -161,7 +156,6 @@ static String _get_var_type(const Variant *p_var) {
#endif // DEBUG_ENABLED
String GDScriptFunction::_get_call_error(const Callable::CallError &p_err, const String &p_where, const Variant **argptrs) const {
-
String err_text;
if (p_err.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) {
@@ -259,11 +253,9 @@ String GDScriptFunction::_get_call_error(const Callable::CallError &p_err, const
#endif
Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state) {
-
OPCODES_TABLE;
if (!_code_ptr) {
-
return Variant();
}
@@ -300,22 +292,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
self = p_state->self;
} else {
-
if (p_argcount != _argument_count) {
-
if (p_argcount > _argument_count) {
-
r_err.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_err.argument = _argument_count;
return Variant();
} else if (p_argcount < _argument_count - _default_arg_count) {
-
r_err.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_err.argument = _argument_count - _default_arg_count;
return Variant();
} else {
-
defarg = _argument_count - p_argcount;
}
}
@@ -323,11 +310,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
alloca_size = sizeof(Variant *) * _call_size + sizeof(Variant) * _stack_size;
if (alloca_size) {
-
uint8_t *aptr = (uint8_t *)alloca(alloca_size);
if (_stack_size) {
-
stack = (Variant *)aptr;
for (int i = 0; i < p_argcount; i++) {
if (!argument_types[i].has_type) {
@@ -356,10 +341,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
if (_call_size) {
-
call_args = (Variant **)&aptr[sizeof(Variant) * _stack_size];
} else {
-
call_args = nullptr;
}
@@ -370,7 +353,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
if (p_instance) {
if (p_instance->base_ref && static_cast<Reference *>(p_instance->owner)->is_referenced()) {
-
self = REF(static_cast<Reference *>(p_instance->owner));
} else {
self = p_instance->owner;
@@ -381,12 +363,15 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
}
+ static_ref = script;
+
String err_text;
#ifdef DEBUG_ENABLED
- if (EngineDebugger::is_active())
+ if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->enter_function(p_instance, this, stack, &ip, &line);
+ }
#define GD_ERR_BREAK(m_cond) \
{ \
@@ -437,9 +422,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
OPCODE_SWITCH(_code_ptr[ip]) {
-
OPCODE(OPCODE_OPERATOR) {
-
CHECK_SPACE(5);
bool valid;
@@ -459,7 +442,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
#ifdef DEBUG_ENABLED
if (!valid) {
-
if (ret.get_type() == Variant::STRING) {
//return a string when invalid with the error
err_text = ret;
@@ -476,7 +458,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_EXTENDS_TEST) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(a, 1);
@@ -485,7 +466,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (b->get_type() != Variant::OBJECT || b->operator Object *() == nullptr) {
-
err_text = "Right operand of 'is' is not a class.";
OPCODE_BREAK;
}
@@ -493,7 +473,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool extends_ok = false;
if (a->get_type() == Variant::OBJECT && a->operator Object *() != nullptr) {
-
#ifdef DEBUG_ENABLED
bool was_freed;
Object *obj_A = a->get_validated_object_with_check(was_freed);
@@ -522,11 +501,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
//in other situation, this shoul return false.
if (obj_A->get_script_instance() && obj_A->get_script_instance()->get_language() == GDScriptLanguage::get_singleton()) {
-
GDScript *cmp = static_cast<GDScript *>(obj_A->get_script_instance()->get_script().ptr());
//bool found=false;
while (cmp) {
-
if (cmp == scr_B) {
//inherits from script, all ok
extends_ok = true;
@@ -538,12 +515,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
} else {
-
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(obj_B);
#ifdef DEBUG_ENABLED
if (!nc) {
-
err_text = "Right operand of 'is' is not a class (type: '" + obj_B->get_class() + "').";
OPCODE_BREAK;
}
@@ -558,7 +533,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_IS_BUILTIN) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(value, 1);
@@ -573,7 +547,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_SET) {
-
CHECK_SPACE(3);
GET_VARIANT_PTR(dst, 1);
@@ -600,7 +573,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_GET) {
-
CHECK_SPACE(3);
GET_VARIANT_PTR(src, 1);
@@ -633,7 +605,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_SET_NAMED) {
-
CHECK_SPACE(3);
GET_VARIANT_PTR(dst, 1);
@@ -659,7 +630,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_GET_NAMED) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(src, 1);
@@ -694,7 +664,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_SET_MEMBER) {
-
CHECK_SPACE(3);
int indexname = _code_ptr[ip + 1];
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
@@ -719,7 +688,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_GET_MEMBER) {
-
CHECK_SPACE(3);
int indexname = _code_ptr[ip + 1];
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
@@ -740,7 +708,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ASSIGN) {
-
CHECK_SPACE(3);
GET_VARIANT_PTR(dst, 1);
GET_VARIANT_PTR(src, 2);
@@ -752,7 +719,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ASSIGN_TRUE) {
-
CHECK_SPACE(2);
GET_VARIANT_PTR(dst, 1);
@@ -763,7 +729,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ASSIGN_FALSE) {
-
CHECK_SPACE(2);
GET_VARIANT_PTR(dst, 1);
@@ -774,7 +739,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ASSIGN_TYPED_BUILTIN) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3);
@@ -804,7 +768,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ASSIGN_TYPED_NATIVE) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3);
@@ -833,7 +796,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ASSIGN_TYPED_SCRIPT) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3);
@@ -850,7 +812,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
if (src->get_type() != Variant::NIL && src->operator Object *() != nullptr) {
-
ScriptInstance *scr_inst = src->operator Object *()->get_script_instance();
if (!scr_inst) {
err_text = "Trying to assign value of type '" + src->operator Object *()->get_class_name() +
@@ -884,7 +845,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CAST_TO_BUILTIN) {
-
CHECK_SPACE(4);
Variant::Type to_type = (Variant::Type)_code_ptr[ip + 1];
GET_VARIANT_PTR(src, 2);
@@ -907,7 +867,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CAST_TO_NATIVE) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(to_type, 1);
GET_VARIANT_PTR(src, 2);
@@ -935,7 +894,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CAST_TO_SCRIPT) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(to_type, 1);
GET_VARIANT_PTR(src, 2);
@@ -955,11 +913,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool valid = false;
if (src->get_type() != Variant::NIL && src->operator Object *() != nullptr) {
-
ScriptInstance *scr_inst = src->operator Object *()->get_script_instance();
if (scr_inst) {
-
Script *src_type = src->operator Object *()->get_script_instance()->get_script().ptr();
while (src_type) {
@@ -983,7 +939,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CONSTRUCT) {
-
CHECK_SPACE(2);
Variant::Type t = Variant::Type(_code_ptr[ip + 1]);
int argc = _code_ptr[ip + 2];
@@ -1000,7 +955,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (err.error != Callable::CallError::CALL_OK) {
-
err_text = _get_call_error(err, "'" + Variant::get_type_name(t) + "' constructor", (const Variant **)argptrs);
OPCODE_BREAK;
}
@@ -1012,7 +966,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CONSTRUCT_ARRAY) {
-
CHECK_SPACE(1);
int argc = _code_ptr[ip + 1];
Array array; //arrays are always shared
@@ -1033,7 +986,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CONSTRUCT_DICTIONARY) {
-
CHECK_SPACE(1);
int argc = _code_ptr[ip + 1];
Dictionary dict; //arrays are always shared
@@ -1041,7 +993,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
CHECK_SPACE(argc * 2 + 2);
for (int i = 0; i < argc; i++) {
-
GET_VARIANT_PTR(k, 2 + i * 2 + 0);
GET_VARIANT_PTR(v, 2 + i * 2 + 1);
dict[*k] = *v;
@@ -1057,7 +1008,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_CALL_RETURN)
OPCODE(OPCODE_CALL) {
-
CHECK_SPACE(4);
bool call_ret = _code_ptr[ip] == OPCODE_CALL_RETURN;
@@ -1088,11 +1038,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
Callable::CallError err;
if (call_ret) {
-
GET_VARIANT_PTR(ret, argc);
base->call_ptr(*methodname, (const Variant **)argptrs, argc, ret, err);
} else {
-
base->call_ptr(*methodname, (const Variant **)argptrs, argc, nullptr, err);
}
#ifdef DEBUG_ENABLED
@@ -1101,7 +1049,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
if (err.error != Callable::CallError::CALL_OK) {
-
String methodstr = *methodname;
String basestr = _get_var_type(base);
@@ -1113,14 +1060,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
}
} else if (methodstr == "free") {
-
if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
-
if (base->is_ref()) {
err_text = "Attempted to free a reference.";
OPCODE_BREAK;
} else if (base->get_type() == Variant::OBJECT) {
-
err_text = "Attempted to free a locked object (calling or emitting).";
OPCODE_BREAK;
}
@@ -1137,7 +1081,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CALL_BUILT_IN) {
-
CHECK_SPACE(4);
GDScriptFunctions::Function func = GDScriptFunctions::Function(_code_ptr[ip + 1]);
@@ -1161,7 +1104,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (err.error != Callable::CallError::CALL_OK) {
-
String methodstr = GDScriptFunctions::get_func_name(func);
if (dst->get_type() == Variant::STRING) {
//call provided error string
@@ -1177,18 +1119,15 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_CALL_SELF) {
-
OPCODE_BREAK;
}
OPCODE(OPCODE_CALL_SELF_BASE) {
-
CHECK_SPACE(2);
int self_fun = _code_ptr[ip + 1];
#ifdef DEBUG_ENABLED
if (self_fun < 0 || self_fun >= _global_names_count) {
-
err_text = "compiler bug, function name not found";
OPCODE_BREAK;
}
@@ -1214,19 +1153,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
while (gds->base.ptr()) {
gds = gds->base.ptr();
E = gds->member_functions.find(*methodname);
- if (E)
+ if (E) {
break;
+ }
}
Callable::CallError err;
if (E) {
-
*dst = E->get()->call(p_instance, (const Variant **)argptrs, argc, err);
} else if (gds->native.ptr()) {
-
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
-
MethodBind *mb = ClassDB::get_method(gds->native->get_name(), *methodname);
if (!mb) {
err.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -1237,7 +1174,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
err.error = Callable::CallError::CALL_OK;
}
} else {
-
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
err.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
} else {
@@ -1246,7 +1182,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
if (err.error != Callable::CallError::CALL_OK) {
-
String methodstr = *methodname;
err_text = _get_call_error(err, "function '" + methodstr + "'", (const Variant **)argptrs);
@@ -1259,7 +1194,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_YIELD)
OPCODE(OPCODE_YIELD_SIGNAL) {
-
int ipofs = 1;
if (_code_ptr[ip] == OPCODE_YIELD_SIGNAL) {
CHECK_SPACE(4);
@@ -1289,7 +1223,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
gdfs->state.instance = p_instance;
p_instance->pending_func_states.add(&gdfs->instances_list);
} else {
- gdfs->state.instance = NULL;
+ gdfs->state.instance = nullptr;
}
}
#ifdef DEBUG_ENABLED
@@ -1332,7 +1266,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_BREAK;
}
if (signal.length() == 0) {
-
err_text = "Second argument of yield() is an empty string (for signal name).";
OPCODE_BREAK;
}
@@ -1358,7 +1291,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
OPCODE(OPCODE_YIELD_RESUME) {
-
CHECK_SPACE(2);
#ifdef DEBUG_ENABLED
if (!p_state) {
@@ -1373,7 +1305,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_JUMP) {
-
CHECK_SPACE(2);
int to = _code_ptr[ip + 1];
@@ -1383,7 +1314,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_JUMP_IF) {
-
CHECK_SPACE(3);
GET_VARIANT_PTR(test, 1);
@@ -1401,7 +1331,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_JUMP_IF_NOT) {
-
CHECK_SPACE(3);
GET_VARIANT_PTR(test, 1);
@@ -1419,14 +1348,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_JUMP_TO_DEF_ARGUMENT) {
-
CHECK_SPACE(2);
ip = _default_arg_ptr[defarg];
}
DISPATCH_OPCODE;
OPCODE(OPCODE_RETURN) {
-
CHECK_SPACE(2);
GET_VARIANT_PTR(r, 1);
retvalue = *r;
@@ -1437,7 +1364,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
OPCODE(OPCODE_ITERATE_BEGIN) {
-
CHECK_SPACE(8); //space for this a regular iterate
GET_VARIANT_PTR(counter, 1);
@@ -1470,7 +1396,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_ITERATE) {
-
CHECK_SPACE(4);
GET_VARIANT_PTR(counter, 1);
@@ -1507,11 +1432,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
GET_VARIANT_PTR(test, 1);
- GET_VARIANT_PTR(message, 2);
bool result = test->booleanize();
if (!result) {
- const String &message_str = *message;
+ String message_str;
+ if (_code_ptr[ip + 2] != 0) {
+ GET_VARIANT_PTR(message, 2);
+ message_str = *message;
+ }
if (message_str.empty()) {
err_text = "Assertion failed.";
} else {
@@ -1546,15 +1474,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool do_break = false;
if (EngineDebugger::get_script_debugger()->get_lines_left() > 0) {
-
- if (EngineDebugger::get_script_debugger()->get_depth() <= 0)
+ if (EngineDebugger::get_script_debugger()->get_depth() <= 0) {
EngineDebugger::get_script_debugger()->set_lines_left(EngineDebugger::get_script_debugger()->get_lines_left() - 1);
- if (EngineDebugger::get_script_debugger()->get_lines_left() <= 0)
+ }
+ if (EngineDebugger::get_script_debugger()->get_lines_left() <= 0) {
do_break = true;
+ }
}
- if (EngineDebugger::get_script_debugger()->is_breakpoint(line, source))
+ if (EngineDebugger::get_script_debugger()->is_breakpoint(line, source)) {
do_break = true;
+ }
if (do_break) {
GDScriptLanguage::get_singleton()->debug_break("Breakpoint", true);
@@ -1582,20 +1512,24 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODES_END
#ifdef DEBUG_ENABLED
- if (exit_ok)
+ if (exit_ok) {
OPCODE_OUT;
+ }
//error
// function, file, line, error, explanation
String err_file;
- if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->path != "")
+ if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->path != "") {
err_file = p_instance->script->path;
- else if (script)
+ } else if (script) {
err_file = script->path;
- if (err_file == "")
+ }
+ if (err_file == "") {
err_file = "<built-in>";
+ }
String err_func = name;
- if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->name != "")
+ if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->name != "") {
err_func = p_instance->script->name + "." + err_func;
+ }
int err_line = line;
if (err_text == "") {
err_text = "Internal Script Error! - opcode #" + itos(last_opcode) + " (report please).";
@@ -1627,14 +1561,16 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
// When it's the last resume it will postpone the exit from stack,
// so the debugger knows which function triggered the resume of the next function (if any)
if (!p_state || yielded) {
- if (EngineDebugger::is_active())
+ if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->exit_function();
+ }
#endif
if (_stack_size) {
//free stack
- for (int i = 0; i < _stack_size; i++)
+ for (int i = 0; i < _stack_size; i++) {
stack[i].~Variant();
+ }
}
#ifdef DEBUG_ENABLED
@@ -1645,32 +1581,28 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
const int *GDScriptFunction::get_code() const {
-
return _code_ptr;
}
-int GDScriptFunction::get_code_size() const {
+int GDScriptFunction::get_code_size() const {
return _code_size;
}
Variant GDScriptFunction::get_constant(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>");
return constants[p_idx];
}
StringName GDScriptFunction::get_global_name(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, global_names.size(), "<errgname>");
return global_names[p_idx];
}
int GDScriptFunction::get_default_argument_count() const {
-
return _default_arg_count;
}
-int GDScriptFunction::get_default_argument_addr(int p_idx) const {
+int GDScriptFunction::get_default_argument_addr(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1);
return default_arguments[p_idx];
}
@@ -1685,45 +1617,38 @@ GDScriptDataType GDScriptFunction::get_argument_type(int p_idx) const {
}
StringName GDScriptFunction::get_name() const {
-
return name;
}
int GDScriptFunction::get_max_stack_size() const {
-
return _stack_size;
}
struct _GDFKC {
-
int order;
List<int> pos;
};
struct _GDFKCS {
-
int order;
StringName id;
int pos;
bool operator<(const _GDFKCS &p_r) const {
-
return order < p_r.order;
}
};
void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const {
-
int oc = 0;
Map<StringName, _GDFKC> sdmap;
for (const List<StackDebug>::Element *E = stack_debug.front(); E; E = E->next()) {
-
const StackDebug &sd = E->get();
- if (sd.line > p_line)
+ if (sd.line > p_line) {
break;
+ }
if (sd.added) {
-
if (!sdmap.has(sd.identifier)) {
_GDFKC d;
d.order = oc++;
@@ -1734,18 +1659,17 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
sdmap[sd.identifier].pos.push_back(sd.pos);
}
} else {
-
ERR_CONTINUE(!sdmap.has(sd.identifier));
sdmap[sd.identifier].pos.pop_back();
- if (sdmap[sd.identifier].pos.empty())
+ if (sdmap[sd.identifier].pos.empty()) {
sdmap.erase(sd.identifier);
+ }
}
}
List<_GDFKCS> stackpositions;
for (Map<StringName, _GDFKC>::Element *E = sdmap.front(); E; E = E->next()) {
-
_GDFKCS spp;
spp.id = E->key();
spp.order = E->get().order;
@@ -1756,7 +1680,6 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
stackpositions.sort();
for (List<_GDFKCS>::Element *E = stackpositions.front(); E; E = E->next()) {
-
Pair<StringName, int> p;
p.first = E->get().id;
p.second = E->get().pos;
@@ -1766,7 +1689,6 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
GDScriptFunction::GDScriptFunction() :
function_list(this) {
-
_stack_size = 0;
_call_size = 0;
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
@@ -1805,7 +1727,6 @@ GDScriptFunction::~GDScriptFunction() {
/////////////////////
Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
Variant arg;
r_error.error = Callable::CallError::CALL_OK;
@@ -1838,9 +1759,9 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
}
bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
-
- if (function == nullptr)
+ if (function == nullptr) {
return false;
+ }
if (p_extended_check) {
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
@@ -1859,7 +1780,6 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
}
Variant GDScriptFunctionState::resume(const Variant &p_arg) {
-
ERR_FAIL_COND_V(!function, Variant());
{
MutexLock lock(GDScriptLanguage::singleton->lock);
@@ -1903,8 +1823,6 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
state.result = Variant();
if (completed) {
- _clear_stack();
-
if (first_state.is_valid()) {
first_state->emit_signal("completed", ret);
} else {
@@ -1912,8 +1830,9 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
}
#ifdef DEBUG_ENABLED
- if (EngineDebugger::is_active())
+ if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->exit_function();
+ }
#endif
}
@@ -1921,17 +1840,16 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
}
void GDScriptFunctionState::_clear_stack() {
-
if (state.stack_size) {
Variant *stack = (Variant *)state.stack.ptr();
- for (int i = 0; i < state.stack_size; i++)
+ for (int i = 0; i < state.stack_size; i++) {
stack[i].~Variant();
+ }
state.stack_size = 0;
}
}
void GDScriptFunctionState::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false));
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDScriptFunctionState::_signal_callback, MethodInfo("_signal_callback"));
@@ -1942,12 +1860,10 @@ void GDScriptFunctionState::_bind_methods() {
GDScriptFunctionState::GDScriptFunctionState() :
scripts_list(this),
instances_list(this) {
-
function = nullptr;
}
GDScriptFunctionState::~GDScriptFunctionState() {
-
_clear_stack();
{
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 89dbeacf34..583eab744a 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -43,21 +43,25 @@ class GDScriptInstance;
class GDScript;
struct GDScriptDataType {
- bool has_type;
- enum {
+ enum Kind {
UNINITIALIZED,
BUILTIN,
NATIVE,
SCRIPT,
GDSCRIPT,
- } kind;
- Variant::Type builtin_type;
+ };
+
+ Kind kind = UNINITIALIZED;
+
+ bool has_type = false;
+ Variant::Type builtin_type = Variant::NIL;
StringName native_type;
Ref<Script> script_type;
bool is_type(const Variant &p_variant, bool p_allow_implicit_conversion = false) const {
- if (!has_type)
+ if (!has_type) {
return true; // Can't type check
+ }
switch (kind) {
case UNINITIALIZED:
@@ -147,10 +151,7 @@ struct GDScriptDataType {
return info;
}
- GDScriptDataType() :
- has_type(false),
- kind(UNINITIALIZED),
- builtin_type(Variant::NIL) {}
+ GDScriptDataType() {}
};
class GDScriptFunction {
@@ -215,7 +216,6 @@ public:
};
struct StackDebug {
-
int line;
int pos;
bool added;
@@ -293,7 +293,6 @@ private:
public:
struct CallState {
-
GDScript *script;
GDScriptInstance *instance;
#ifdef DEBUG_ENABLED
@@ -351,7 +350,6 @@ public:
};
class GDScriptFunctionState : public Reference {
-
GDCLASS(GDScriptFunctionState, Reference);
friend class GDScriptFunction;
GDScriptFunction *function;
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 85a5d86ca0..d4258c385e 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -41,7 +41,6 @@
#include "gdscript.h"
const char *GDScriptFunctions::get_func_name(Function p_func) {
-
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, "");
static const char *_names[FUNC_MAX] = {
@@ -140,7 +139,6 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
}
void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_OK;
#ifdef DEBUG_ENABLED
@@ -176,7 +174,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
//using a switch, so the compiler generates a jumptable
switch (p_func) {
-
case MATH_SIN: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
@@ -269,15 +266,12 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case MATH_ABS: {
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() == Variant::INT) {
-
int64_t i = *p_args[0];
r_ret = ABS(i);
} else if (p_args[0]->get_type() == Variant::FLOAT) {
-
double r = *p_args[0];
r_ret = Math::abs(r);
} else {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::FLOAT;
@@ -287,15 +281,12 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case MATH_SIGN: {
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() == Variant::INT) {
-
int64_t i = *p_args[0];
r_ret = i < 0 ? -1 : (i > 0 ? +1 : 0);
} else if (p_args[0]->get_type() == Variant::FLOAT) {
-
real_t r = *p_args[0];
r_ret = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
} else {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::FLOAT;
@@ -505,7 +496,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case LOGIC_MAX: {
VALIDATE_ARG_COUNT(2);
if (p_args[0]->get_type() == Variant::INT && p_args[1]->get_type() == Variant::INT) {
-
int64_t a = *p_args[0];
int64_t b = *p_args[1];
r_ret = MAX(a, b);
@@ -523,7 +513,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case LOGIC_MIN: {
VALIDATE_ARG_COUNT(2);
if (p_args[0]->get_type() == Variant::INT && p_args[1]->get_type() == Variant::INT) {
-
int64_t a = *p_args[0];
int64_t b = *p_args[1];
r_ret = MIN(a, b);
@@ -540,7 +529,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case LOGIC_CLAMP: {
VALIDATE_ARG_COUNT(3);
if (p_args[0]->get_type() == Variant::INT && p_args[1]->get_type() == Variant::INT && p_args[2]->get_type() == Variant::INT) {
-
int64_t a = *p_args[0];
int64_t b = *p_args[1];
int64_t c = *p_args[2];
@@ -595,7 +583,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case FUNC_FUNCREF: {
VALIDATE_ARG_COUNT(2);
if (p_args[0]->get_type() != Variant::OBJECT) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -603,7 +590,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
return;
}
if (p_args[1]->get_type() != Variant::STRING && p_args[1]->get_type() != Variant::NODE_PATH) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
@@ -624,7 +610,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_NUM(1);
int type = *p_args[1];
if (type < 0 || type >= Variant::VARIANT_MAX) {
-
r_ret = RTR("Invalid type argument to convert(), use TYPE_* constants.");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -632,18 +617,15 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
return;
} else {
-
r_ret = Variant::construct(Variant::Type(type), p_args, 1, r_error);
}
} break;
case TYPE_OF: {
-
VALIDATE_ARG_COUNT(1);
r_ret = p_args[0]->get_type();
} break;
case TYPE_EXISTS: {
-
VALIDATE_ARG_COUNT(1);
r_ret = ClassDB::class_exists(*p_args[0]);
@@ -655,11 +637,9 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = String(result);
} break;
case TEXT_ORD: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
@@ -670,7 +650,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
String str = p_args[0]->operator String();
if (str.length() != 1) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
@@ -691,23 +670,21 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
}
String str;
for (int i = 0; i < p_arg_count; i++) {
-
String os = p_args[i]->operator String();
- if (i == 0)
+ if (i == 0) {
str = os;
- else
+ } else {
str += os;
+ }
}
r_ret = str;
} break;
case TEXT_PRINT: {
-
String str;
for (int i = 0; i < p_arg_count; i++) {
-
str += p_args[i]->operator String();
}
@@ -716,12 +693,11 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case TEXT_PRINT_TABBED: {
-
String str;
for (int i = 0; i < p_arg_count; i++) {
-
- if (i)
+ if (i) {
str += "\t";
+ }
str += p_args[i]->operator String();
}
@@ -730,12 +706,11 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case TEXT_PRINT_SPACED: {
-
String str;
for (int i = 0; i < p_arg_count; i++) {
-
- if (i)
+ if (i) {
str += " ";
+ }
str += p_args[i]->operator String();
}
@@ -745,10 +720,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case TEXT_PRINTERR: {
-
String str;
for (int i = 0; i < p_arg_count; i++) {
-
str += p_args[i]->operator String();
}
@@ -759,7 +732,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case TEXT_PRINTRAW: {
String str;
for (int i = 0; i < p_arg_count; i++) {
-
str += p_args[i]->operator String();
}
@@ -770,7 +742,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case TEXT_PRINT_DEBUG: {
String str;
for (int i = 0; i < p_arg_count; i++) {
-
str += p_args[i]->operator String();
}
@@ -922,18 +893,14 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case GEN_RANGE: {
-
switch (p_arg_count) {
-
case 0: {
-
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
r_ret = Variant();
} break;
case 1: {
-
VALIDATE_ARG_NUM(0);
int count = *p_args[0];
Array arr;
@@ -955,7 +922,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = arr;
} break;
case 2: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
@@ -973,12 +939,12 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = Variant();
return;
}
- for (int i = from; i < to; i++)
+ for (int i = from; i < to; i++) {
arr[i - from] = i;
+ }
r_ret = arr;
} break;
case 3: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
@@ -987,7 +953,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
int to = *p_args[1];
int incr = *p_args[2];
if (incr == 0) {
-
r_ret = RTR("Step argument is zero!");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return;
@@ -1006,10 +971,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
//calculate how many
int count = 0;
if (incr > 0) {
-
count = ((to - from - 1) / incr) + 1;
} else {
-
count = ((from - to - 1) / -incr) + 1;
}
@@ -1027,7 +990,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
arr[idx++] = i;
}
} else {
-
int idx = 0;
for (int i = from; i > to; i += incr) {
arr[idx++] = i;
@@ -1037,7 +999,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = arr;
} break;
default: {
-
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = 3;
r_ret = Variant();
@@ -1059,7 +1020,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case INST2DICT: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() == Variant::NIL) {
@@ -1069,24 +1029,20 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_error.argument = 0;
r_ret = Variant();
} else {
-
Object *obj = *p_args[0];
if (!obj) {
r_ret = Variant();
} else if (!obj->get_script_instance() || obj->get_script_instance()->get_language() != GDScriptLanguage::get_singleton()) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
r_ret = RTR("Not a script with an instance");
return;
} else {
-
GDScriptInstance *ins = static_cast<GDScriptInstance *>(obj->get_script_instance());
Ref<GDScript> base = ins->get_script();
if (base.is_null()) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
@@ -1098,7 +1054,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Vector<StringName> sname;
while (p->_owner) {
-
sname.push_back(p->name);
p = p->_owner;
}
@@ -1132,11 +1087,9 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case DICT2INST: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::DICTIONARY) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
@@ -1148,7 +1101,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Dictionary d = *p_args[0];
if (!d.has("@path")) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1159,7 +1111,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Ref<Script> scr = ResourceLoader::load(d["@path"]);
if (!scr.is_valid()) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1170,7 +1121,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Ref<GDScript> gdscr = scr;
if (!gdscr.is_valid()) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1185,10 +1135,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
}
for (int i = 0; i < sub.get_name_count(); i++) {
-
gdscr = gdscr->subclasses[sub.get_name(i)];
if (!gdscr.is_valid()) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1215,7 +1163,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case VALIDATE_JSON: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
@@ -1239,7 +1186,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case PARSE_JSON: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
@@ -1267,13 +1213,11 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = JSON::print(*p_args[0]);
} break;
case HASH: {
-
VALIDATE_ARG_COUNT(1);
r_ret = p_args[0]->hash();
} break;
case COLOR8: {
-
if (p_arg_count < 3) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 3;
@@ -1304,7 +1248,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case COLORN: {
-
if (p_arg_count < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
@@ -1339,7 +1282,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
ScriptLanguage *script = GDScriptLanguage::get_singleton();
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
-
print_line("Frame " + itos(i) + " - " + script->debug_get_stack_level_source(i) + ":" + itos(script->debug_get_stack_level_line(i)) + " in function '" + script->debug_get_stack_level_function(i) + "'");
};
} break;
@@ -1350,7 +1292,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
ScriptLanguage *script = GDScriptLanguage::get_singleton();
Array ret;
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
-
Dictionary frame;
frame["source"] = script->debug_get_stack_level_source(i);
frame["function"] = script->debug_get_stack_level_function(i);
@@ -1361,7 +1302,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case INSTANCE_FROM_ID: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::INT && p_args[0]->get_type() != Variant::FLOAT) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -1376,66 +1316,53 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case LEN: {
-
VALIDATE_ARG_COUNT(1);
switch (p_args[0]->get_type()) {
case Variant::STRING: {
-
String d = *p_args[0];
r_ret = d.length();
} break;
case Variant::DICTIONARY: {
-
Dictionary d = *p_args[0];
r_ret = d.size();
} break;
case Variant::ARRAY: {
-
Array d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_BYTE_ARRAY: {
-
Vector<uint8_t> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_INT32_ARRAY: {
-
Vector<int32_t> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_INT64_ARRAY: {
-
Vector<int64_t> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
Vector<float> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_FLOAT64_ARRAY: {
-
Vector<double> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_STRING_ARRAY: {
-
Vector<String> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_VECTOR2_ARRAY: {
-
Vector<Vector2> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_VECTOR3_ARRAY: {
-
Vector<Vector3> d = *p_args[0];
r_ret = d.size();
} break;
case Variant::PACKED_COLOR_ARRAY: {
-
Vector<Color> d = *p_args[0];
r_ret = d.size();
} break;
@@ -1450,7 +1377,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case IS_INSTANCE_VALID: {
-
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::OBJECT) {
r_ret = false;
@@ -1461,19 +1387,16 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case FUNC_MAX: {
-
ERR_FAIL();
} break;
}
}
bool GDScriptFunctions::is_deterministic(Function p_func) {
-
//man i couldn't have chosen a worse function name,
//way too controversial..
switch (p_func) {
-
case MATH_SIN:
case MATH_COS:
case MATH_TAN:
@@ -1537,12 +1460,10 @@ bool GDScriptFunctions::is_deterministic(Function p_func) {
}
MethodInfo GDScriptFunctions::get_info(Function p_func) {
-
#ifdef DEBUG_ENABLED
//using a switch, so the compiler generates a jumptable
switch (p_func) {
-
case MATH_SIN: {
MethodInfo mi("sin", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::FLOAT;
@@ -1817,7 +1738,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case OBJ_WEAKREF: {
-
MethodInfo mi("weakref", PropertyInfo(Variant::OBJECT, "obj"));
mi.return_val.type = Variant::OBJECT;
mi.return_val.class_name = "WeakRef";
@@ -1826,7 +1746,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case FUNC_FUNCREF: {
-
MethodInfo mi("funcref", PropertyInfo(Variant::OBJECT, "instance"), PropertyInfo(Variant::STRING, "funcname"));
mi.return_val.type = Variant::OBJECT;
mi.return_val.class_name = "FuncRef";
@@ -1834,42 +1753,36 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TYPE_CONVERT: {
-
MethodInfo mi("convert", PropertyInfo(Variant::NIL, "what", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::INT, "type"));
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case TYPE_OF: {
-
MethodInfo mi("typeof", PropertyInfo(Variant::NIL, "what", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT));
mi.return_val.type = Variant::INT;
return mi;
} break;
case TYPE_EXISTS: {
-
MethodInfo mi("type_exists", PropertyInfo(Variant::STRING, "type"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case TEXT_CHAR: {
-
MethodInfo mi("char", PropertyInfo(Variant::INT, "code"));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case TEXT_ORD: {
-
MethodInfo mi("ord", PropertyInfo(Variant::STRING, "char"));
mi.return_val.type = Variant::INT;
return mi;
} break;
case TEXT_STR: {
-
MethodInfo mi("str");
mi.return_val.type = Variant::STRING;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1877,7 +1790,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_PRINT: {
-
MethodInfo mi("print");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1885,7 +1797,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_PRINT_TABBED: {
-
MethodInfo mi("printt");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1893,7 +1804,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_PRINT_SPACED: {
-
MethodInfo mi("prints");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1901,7 +1811,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_PRINTERR: {
-
MethodInfo mi("printerr");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1909,7 +1818,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_PRINTRAW: {
-
MethodInfo mi("printraw");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1917,7 +1825,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_PRINT_DEBUG: {
-
MethodInfo mi("print_debug");
mi.return_val.type = Variant::NIL;
mi.flags |= METHOD_FLAG_VARARG;
@@ -1925,41 +1832,35 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case PUSH_ERROR: {
-
MethodInfo mi(Variant::NIL, "push_error", PropertyInfo(Variant::STRING, "message"));
mi.return_val.type = Variant::NIL;
return mi;
} break;
case PUSH_WARNING: {
-
MethodInfo mi(Variant::NIL, "push_warning", PropertyInfo(Variant::STRING, "message"));
mi.return_val.type = Variant::NIL;
return mi;
} break;
case VAR_TO_STR: {
-
MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case STR_TO_VAR: {
-
MethodInfo mi(Variant::NIL, "str2var", PropertyInfo(Variant::STRING, "string"));
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case VAR_TO_BYTES: {
-
MethodInfo mi("var2bytes", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::BOOL, "full_objects"));
mi.default_arguments.push_back(false);
mi.return_val.type = Variant::PACKED_BYTE_ARRAY;
return mi;
} break;
case BYTES_TO_VAR: {
-
MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytes"), PropertyInfo(Variant::BOOL, "allow_objects"));
mi.default_arguments.push_back(false);
mi.return_val.type = Variant::NIL;
@@ -1967,65 +1868,55 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case GEN_RANGE: {
-
MethodInfo mi("range");
mi.return_val.type = Variant::ARRAY;
mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case RESOURCE_LOAD: {
-
MethodInfo mi("load", PropertyInfo(Variant::STRING, "path"));
mi.return_val.type = Variant::OBJECT;
mi.return_val.class_name = "Resource";
return mi;
} break;
case INST2DICT: {
-
MethodInfo mi("inst2dict", PropertyInfo(Variant::OBJECT, "inst"));
mi.return_val.type = Variant::DICTIONARY;
return mi;
} break;
case DICT2INST: {
-
MethodInfo mi("dict2inst", PropertyInfo(Variant::DICTIONARY, "dict"));
mi.return_val.type = Variant::OBJECT;
return mi;
} break;
case VALIDATE_JSON: {
-
MethodInfo mi("validate_json", PropertyInfo(Variant::STRING, "json"));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case PARSE_JSON: {
-
MethodInfo mi(Variant::NIL, "parse_json", PropertyInfo(Variant::STRING, "json"));
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case TO_JSON: {
-
MethodInfo mi("to_json", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case HASH: {
-
MethodInfo mi("hash", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT));
mi.return_val.type = Variant::INT;
return mi;
} break;
case COLOR8: {
-
MethodInfo mi("Color8", PropertyInfo(Variant::INT, "r8"), PropertyInfo(Variant::INT, "g8"), PropertyInfo(Variant::INT, "b8"), PropertyInfo(Variant::INT, "a8"));
mi.default_arguments.push_back(255);
mi.return_val.type = Variant::COLOR;
return mi;
} break;
case COLORN: {
-
MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::FLOAT, "alpha"));
mi.default_arguments.push_back(1.0f);
mi.return_val.type = Variant::COLOR;
@@ -2059,7 +1950,6 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
default: {
-
ERR_FAIL_V(MethodInfo());
} break;
}
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index b900ba903f..ca452bf008 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -42,14 +42,14 @@
template <class T>
T *GDScriptParser::alloc_node() {
-
T *t = memnew(T);
t->next = list;
list = t;
- if (!head)
+ if (!head) {
head = t;
+ }
t->line = tokenizer->get_token_line();
t->column = tokenizer->get_token_column();
@@ -61,7 +61,6 @@ static String _find_function_name(const GDScriptParser::OperatorNode *p_call);
#endif // DEBUG_ENABLED
bool GDScriptParser::_end_statement() {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) {
tokenizer->advance();
return true; //handle next
@@ -83,7 +82,6 @@ void GDScriptParser::_set_end_statement_error(String p_name) {
}
bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
-
if (tokenizer->get_token() != GDScriptTokenizer::TK_COLON) {
// report location at the previous token (on the previous line)
int error_line = tokenizer->get_token_line(-1);
@@ -108,12 +106,10 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
while (true) {
if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
-
return false; //wtf
} else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_EOF) {
return false;
} else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
-
int indent = tokenizer->get_token_line_indent();
int tabs = tokenizer->get_token_line_tab_indent();
IndentLevel current_level = indent_level.back()->get();
@@ -132,7 +128,6 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
return true;
} else if (p_block) {
-
NewLineNode *nl = alloc_node<NewLineNode>();
nl->line = tokenizer->get_token_line();
p_block->statements.push_back(nl);
@@ -143,16 +138,13 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
}
bool GDScriptParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete, bool p_parsing_constant) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
} else {
-
parenthesis++;
int argidx = 0;
while (true) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(argidx);
completion_node = p_parent;
@@ -178,9 +170,7 @@ bool GDScriptParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bo
break;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
-
if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
-
_set_error("Expression expected");
return false;
}
@@ -200,7 +190,6 @@ bool GDScriptParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bo
}
void GDScriptParser::_make_completable_call(int p_arg) {
-
completion_cursor = StringName();
completion_type = COMPLETION_CALL_ARGUMENTS;
completion_class = current_class;
@@ -213,14 +202,12 @@ void GDScriptParser::_make_completable_call(int p_arg) {
}
bool GDScriptParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) {
-
identifier = StringName();
if (tokenizer->is_token_literal()) {
identifier = tokenizer->get_token_literal();
tokenizer->advance();
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
-
completion_cursor = identifier;
completion_type = p_type;
completion_class = current_class;
@@ -246,7 +233,6 @@ bool GDScriptParser::_get_completable_identifier(CompletionType p_type, StringNa
}
GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) {
-
//Vector<Node*> expressions;
//Vector<OperatorNode::Operator> operators;
@@ -257,7 +243,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
int op_line = tokenizer->get_token_line(); // when operators are created at the bottom, the line might have been changed (\n found)
while (true) {
-
/*****************/
/* Parse Operand */
/*****************/
@@ -285,11 +270,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
parenthesis++;
Node *subexpr = _parse_expression(p_parent, p_static, p_allow_assign, p_parsing_constant);
parenthesis--;
- if (!subexpr)
+ if (!subexpr) {
return nullptr;
+ }
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
-
_set_error("Expected ')' in expression");
return nullptr;
}
@@ -306,7 +291,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
int line = tokenizer->get_token_line();
while (!done) {
-
switch (tokenizer->get_token()) {
case GDScriptTokenizer::TK_CURSOR: {
completion_type = COMPLETION_GET_NODE;
@@ -320,7 +304,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
} break;
case GDScriptTokenizer::TK_CONSTANT: {
-
if (!need_identifier) {
done = true;
break;
@@ -337,7 +320,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
} break;
case GDScriptTokenizer::TK_OP_DIV: {
-
if (need_identifier) {
done = true;
break;
@@ -392,7 +374,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
continue; //no point in cursor in the middle of expression
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) {
-
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = tokenizer->get_token_constant();
@@ -400,7 +381,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
expr = constant;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_PI) {
-
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_PI;
@@ -408,7 +388,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
expr = constant;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_TAU) {
-
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_TAU;
@@ -416,7 +395,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
expr = constant;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_INF) {
-
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_INF;
@@ -424,7 +402,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
expr = constant;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_NAN) {
-
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_NAN;
@@ -432,7 +409,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
expr = constant;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_PRELOAD) {
-
//constant defined by tokenizer
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
@@ -489,11 +465,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
return nullptr;
}
- if (!path.is_abs_path() && base_path != "")
+ if (!path.is_abs_path() && base_path != "") {
path = base_path.plus_file(path);
+ }
path = path.replace("///", "//").simplify_path();
if (path == self_path) {
-
_set_error("Can't preload itself (use 'get_script()').");
return nullptr;
}
@@ -502,7 +478,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
dependencies.push_back(path);
if (!dependencies_only) {
if (!validating) {
-
//this can be too slow for just validating code
if (for_completion && ScriptCodeCompletionCache::get_singleton() && FileAccess::exists(path)) {
res = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
@@ -510,7 +485,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
res = ResourceLoader::load(path);
}
} else {
-
if (!FileAccess::exists(path)) {
_set_error("Can't preload resource at path: " + path);
return nullptr;
@@ -543,7 +517,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
expr = constant;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_YIELD) {
-
if (!current_function) {
_set_error("\"yield()\" can only be used inside function blocks.");
return nullptr;
@@ -570,12 +543,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
expr = yield;
tokenizer->advance();
} else {
-
parenthesis++;
Node *object = _parse_and_reduce_expression(p_parent, p_static);
- if (!object)
+ if (!object) {
return nullptr;
+ }
yield->arguments.push_back(object);
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
@@ -586,7 +559,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
-
completion_cursor = StringName();
completion_node = object;
completion_type = COMPLETION_YIELD;
@@ -600,8 +572,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
Node *signal = _parse_and_reduce_expression(p_parent, p_static);
- if (!signal)
+ if (!signal) {
return nullptr;
+ }
yield->arguments.push_back(signal);
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
@@ -617,7 +590,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_SELF) {
-
if (p_static) {
_set_error("\"self\" isn't allowed in a static function or constant expression.");
return nullptr;
@@ -627,28 +599,23 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
expr = self;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
-
Variant::Type bi_type = tokenizer->get_token_type();
tokenizer->advance(2);
StringName identifier;
if (_get_completable_identifier(COMPLETION_BUILT_IN_TYPE_CONSTANT, identifier)) {
-
completion_built_in_constant = bi_type;
}
if (identifier == StringName()) {
-
_set_error("Built-in type constant or static function expected after \".\".");
return nullptr;
}
if (!Variant::has_constant(bi_type, identifier)) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN &&
Variant::is_method_const(bi_type, identifier) &&
Variant::get_method_return_type(bi_type, identifier) == bi_type) {
-
tokenizer->advance();
OperatorNode *construct = alloc_node<OperatorNode>();
@@ -666,8 +633,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
id->name = identifier;
op->arguments.push_back(id);
- if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant))
+ if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant)) {
return nullptr;
+ }
expr = op;
} else {
@@ -688,7 +656,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
}
} else {
-
ConstantNode *cn = alloc_node<ConstantNode>();
cn->value = Variant::get_constant_value(bi_type, identifier);
cn->datatype = _type_from_variant(cn->value);
@@ -733,13 +700,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance(2);
}
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
-
BuiltInFunctionNode *bn = alloc_node<BuiltInFunctionNode>();
bn->function = tokenizer->get_token_built_in_func();
op->arguments.push_back(bn);
tokenizer->advance(2);
} else {
-
SelfNode *self = alloc_node<SelfNode>();
op->arguments.push_back(self);
@@ -765,8 +730,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
}
if (!replaced) {
- if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant))
+ if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant)) {
return nullptr;
+ }
expr = op;
}
} else if (tokenizer->is_token_literal(0, true)) {
@@ -913,7 +879,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ADD || tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB || tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT || tokenizer->get_token() == GDScriptTokenizer::TK_OP_BIT_INVERT) {
-
//single prefix operators like !expr +expr -expr ++expr --expr
alloc_node<OperatorNode>();
Expression e;
@@ -979,9 +944,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
bool expecting_comma = false;
while (true) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
-
_set_error("Unterminated array");
return nullptr;
@@ -989,7 +952,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
break;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
-
tokenizer->advance(); //ignore newline
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
if (!expecting_comma) {
@@ -1006,8 +968,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
return nullptr;
}
Node *n = _parse_expression(arr, p_static, p_allow_assign, p_parsing_constant);
- if (!n)
+ if (!n) {
return nullptr;
+ }
arr->elements.push_back(n);
expecting_comma = true;
}
@@ -1035,14 +998,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
DictExpect expecting = DICT_EXPECT_KEY;
while (true) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
-
_set_error("Unterminated dictionary");
return nullptr;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
-
if (expecting == DICT_EXPECT_COLON) {
_set_error("':' expected");
return nullptr;
@@ -1054,10 +1014,8 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
break;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
-
tokenizer->advance(); //ignore newline
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
-
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
return nullptr;
@@ -1075,7 +1033,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance(); //ignore newline
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
-
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
return nullptr;
@@ -1092,7 +1049,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
expecting = DICT_EXPECT_VALUE;
tokenizer->advance(); //ignore newline
} else {
-
if (expecting == DICT_EXPECT_COMMA) {
_set_error("',' or '}' expected");
return nullptr;
@@ -1103,7 +1059,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
if (expecting == DICT_EXPECT_KEY) {
-
if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//lua style identifier, easier to write
@@ -1116,16 +1071,18 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
} else {
//python/js style more flexible
key = _parse_expression(dict, p_static, p_allow_assign, p_parsing_constant);
- if (!key)
+ if (!key) {
return nullptr;
+ }
expecting = DICT_EXPECT_COLON;
}
}
if (expecting == DICT_EXPECT_VALUE) {
Node *value = _parse_expression(dict, p_static, p_allow_assign, p_parsing_constant);
- if (!value)
+ if (!value) {
return nullptr;
+ }
expecting = DICT_EXPECT_COMMA;
if (key->type == GDScriptParser::Node::TYPE_CONSTANT) {
@@ -1191,7 +1148,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
expr = tn;
tokenizer->advance();
} else {
-
//find list [ or find dictionary {
_set_error("Error parsing expression, misplaced: " + String(tokenizer->get_token_name(tokenizer->get_token())));
return nullptr; //nothing
@@ -1204,11 +1160,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
/******************/
while (true) {
-
//expressions can be indexed any number of times
if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
-
//indexing using "."
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
@@ -1239,8 +1193,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
_make_completable_call(0);
completion_node = op;
}
- if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant))
+ if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant)) {
return nullptr;
+ }
expr = op;
} else {
@@ -1252,7 +1207,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
StringName identifier;
if (_get_completable_identifier(COMPLETION_INDEX, identifier)) {
-
if (identifier == StringName()) {
identifier = "@temp"; //so it parses alright
}
@@ -1292,8 +1246,9 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance(1);
expr = op;
- } else
+ } else {
break;
+ }
}
/*****************/
@@ -1478,16 +1433,13 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
/* Reduce the set set of expressions and place them in an operator tree, respecting precedence */
while (expression.size() > 1) {
-
int next_op = -1;
int min_priority = 0xFFFFF;
bool is_unary = false;
bool is_ternary = false;
for (int i = 0; i < expression.size(); i++) {
-
if (!expression[i].is_op) {
-
continue;
}
@@ -1499,7 +1451,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
bool right_to_left = false;
switch (expression[i].op) {
-
case OperatorNode::OP_IS:
case OperatorNode::OP_IS_BUILTIN:
priority = -1;
@@ -1650,17 +1601,14 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
if (next_op == -1) {
-
_set_error("Yet another parser bug....");
ERR_FAIL_V(nullptr);
}
// OK! create operator..
if (is_unary) {
-
int expr_pos = next_op;
while (expression[expr_pos].is_op) {
-
expr_pos++;
if (expr_pos == expression.size()) {
//can happen..
@@ -1671,7 +1619,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
//consecutively do unary operators
for (int i = expr_pos - 1; i >= next_op; i--) {
-
OperatorNode *op = alloc_node<OperatorNode>();
op->op = expression[i].op;
op->arguments.push_back(expression[i + 1].node);
@@ -1701,7 +1648,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
op->line = op_line; //line might have been changed from a \n
if (expression[next_op - 1].is_op) {
-
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
}
@@ -1737,7 +1683,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
expression.remove(next_op);
expression.remove(next_op);
} else {
-
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
@@ -1748,7 +1693,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
op->line = op_line; //line might have been changed from a \n
if (expression[next_op - 1].is_op) {
-
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
}
@@ -1777,23 +1721,20 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to_const) {
-
switch (p_node->type) {
-
case Node::TYPE_BUILT_IN_FUNCTION: {
//many may probably be optimizable
return p_node;
} break;
case Node::TYPE_ARRAY: {
-
ArrayNode *an = static_cast<ArrayNode *>(p_node);
bool all_constants = true;
for (int i = 0; i < an->elements.size(); i++) {
-
an->elements.write[i] = _reduce_expression(an->elements[i], p_to_const);
- if (an->elements[i]->type != Node::TYPE_CONSTANT)
+ if (an->elements[i]->type != Node::TYPE_CONSTANT) {
all_constants = false;
+ }
}
if (all_constants && p_to_const) {
@@ -1815,18 +1756,18 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
} break;
case Node::TYPE_DICTIONARY: {
-
DictionaryNode *dn = static_cast<DictionaryNode *>(p_node);
bool all_constants = true;
for (int i = 0; i < dn->elements.size(); i++) {
-
dn->elements.write[i].key = _reduce_expression(dn->elements[i].key, p_to_const);
- if (dn->elements[i].key->type != Node::TYPE_CONSTANT)
+ if (dn->elements[i].key->type != Node::TYPE_CONSTANT) {
all_constants = false;
+ }
dn->elements.write[i].value = _reduce_expression(dn->elements[i].value, p_to_const);
- if (dn->elements[i].value->type != Node::TYPE_CONSTANT)
+ if (dn->elements[i].value->type != Node::TYPE_CONSTANT) {
all_constants = false;
+ }
}
if (all_constants && p_to_const) {
@@ -1849,14 +1790,12 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
} break;
case Node::TYPE_OPERATOR: {
-
OperatorNode *op = static_cast<OperatorNode *>(p_node);
bool all_constants = true;
int last_not_constant = -1;
for (int i = 0; i < op->arguments.size(); i++) {
-
op->arguments.write[i] = _reduce_expression(op->arguments[i], p_to_const);
if (op->arguments[i]->type != Node::TYPE_CONSTANT) {
all_constants = false;
@@ -1875,15 +1814,12 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
} else if (op->op == OperatorNode::OP_CALL) {
//can reduce base type constructors
if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDScriptFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) {
-
//native type constructor or intrinsic function
const Variant **vptr = nullptr;
Vector<Variant *> ptrs;
if (op->arguments.size() > 1) {
-
ptrs.resize(op->arguments.size() - 1);
for (int i = 0; i < ptrs.size(); i++) {
-
ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[i + 1]);
ptrs.write[i] = &cn->value;
}
@@ -1904,7 +1840,6 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
}
if (ce.error != Callable::CallError::CALL_OK) {
-
String errwhere;
if (op->arguments[0]->type == Node::TYPE_TYPE) {
TypeNode *tn = static_cast<TypeNode *>(op->arguments[0]);
@@ -1916,18 +1851,14 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
}
switch (ce.error) {
-
case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
-
_set_error("Invalid argument (#" + itos(ce.argument + 1) + ") for " + errwhere + ".");
} break;
case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
-
_set_error("Too many arguments for " + errwhere + ".");
} break;
case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
-
_set_error("Too few arguments for " + errwhere + ".");
} break;
default: {
@@ -1956,7 +1887,6 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
//can reduce indices into constant arrays or dictionaries
if (all_constants) {
-
ConstantNode *ca = static_cast<ConstantNode *>(op->arguments[0]);
ConstantNode *cb = static_cast<ConstantNode *>(op->arguments[1]);
@@ -1978,9 +1908,7 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
return op;
} else if (op->op == OperatorNode::OP_INDEX_NAMED) {
-
if (op->arguments[0]->type == Node::TYPE_CONSTANT && op->arguments[1]->type == Node::TYPE_IDENTIFIER) {
-
ConstantNode *ca = static_cast<ConstantNode *>(op->arguments[0]);
IdentifierNode *ib = static_cast<IdentifierNode *>(op->arguments[1]);
@@ -2003,7 +1931,6 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
//validate assignment (don't assign to constant expression
switch (op->op) {
-
case OperatorNode::OP_ASSIGN:
case OperatorNode::OP_ASSIGN_ADD:
case OperatorNode::OP_ASSIGN_SUB:
@@ -2015,7 +1942,6 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
case OperatorNode::OP_ASSIGN_BIT_AND:
case OperatorNode::OP_ASSIGN_BIT_OR:
case OperatorNode::OP_ASSIGN_BIT_XOR: {
-
if (op->arguments[0]->type == Node::TYPE_CONSTANT) {
_set_error("Can't assign to constant", tokenizer->get_token_line() - 1);
error_line = op->line;
@@ -2041,8 +1967,9 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
}
}
//now se if all are constants
- if (!all_constants)
+ if (!all_constants) {
return op; //nothing to reduce from here on
+ }
#define _REDUCE_UNARY(m_vop) \
bool valid = false; \
Variant res; \
@@ -2072,7 +1999,6 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
return cn;
switch (op->op) {
-
//unary operators
case OperatorNode::OP_NEG: {
_REDUCE_UNARY(Variant::OP_NEGATE);
@@ -2164,23 +2090,24 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
}
GDScriptParser::Node *GDScriptParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) {
-
Node *expr = _parse_expression(p_parent, p_static, p_allow_assign, p_reduce_const);
- if (!expr || error_set)
+ if (!expr || error_set) {
return nullptr;
+ }
expr = _reduce_expression(expr, p_reduce_const);
- if (!expr || error_set)
+ if (!expr || error_set) {
return nullptr;
+ }
return expr;
}
bool GDScriptParser::_reduce_export_var_type(Variant &p_value, int p_line) {
-
if (p_value.get_type() == Variant::ARRAY) {
Array arr = p_value;
for (int i = 0; i < arr.size(); i++) {
- if (!_reduce_export_var_type(arr[i], p_line))
+ if (!_reduce_export_var_type(arr[i], p_line)) {
return false;
+ }
}
return true;
}
@@ -2189,8 +2116,9 @@ bool GDScriptParser::_reduce_export_var_type(Variant &p_value, int p_line) {
Dictionary dict = p_value;
for (int i = 0; i < dict.size(); i++) {
Variant value = dict.get_value_at_index(i);
- if (!_reduce_export_var_type(value, p_line))
+ if (!_reduce_export_var_type(value, p_line)) {
return false;
+ }
}
return true;
}
@@ -2209,7 +2137,6 @@ bool GDScriptParser::_reduce_export_var_type(Variant &p_value, int p_line) {
}
bool GDScriptParser::_recover_from_completion() {
-
if (!completion_found) {
return false; //can't recover if no completion
}
@@ -2227,12 +2154,12 @@ bool GDScriptParser::_recover_from_completion() {
}
GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
-
PatternNode *pattern = alloc_node<PatternNode>();
GDScriptTokenizer::Token token = tokenizer->get_token();
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
if (token == GDScriptTokenizer::TK_EOF) {
return nullptr;
@@ -2244,7 +2171,6 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
tokenizer->advance();
pattern->pt_type = GDScriptParser::PatternNode::PT_ARRAY;
while (true) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
@@ -2316,7 +2242,6 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
tokenizer->advance();
pattern->pt_type = GDScriptParser::PatternNode::PT_DICTIONARY;
while (true) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break;
@@ -2429,13 +2354,14 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
bool catch_all_appeared = false;
while (true) {
-
- while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline()) {
;
+ }
// GDScriptTokenizer::Token token = tokenizer->get_token();
- if (error_set)
+ if (error_set) {
return;
+ }
if (current_level.indent > indent_level.back()->get().indent) {
break; // go back a level
@@ -2507,12 +2433,10 @@ void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBran
}
void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) {
-
const DataType &to_match_type = p_node_to_match->get_datatype();
switch (p_pattern->pt_type) {
case PatternNode::PT_CONSTANT: {
-
DataType pattern_type = _reduce_node_type(p_pattern->constant);
if (error_set) {
return;
@@ -2576,7 +2500,6 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
p_resulting_node = true_value;
} break;
case PatternNode::PT_ARRAY: {
-
bool open_ended = false;
if (p_pattern->array.size() > 0) {
@@ -2673,7 +2596,6 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
} break;
case PatternNode::PT_DICTIONARY: {
-
bool open_ended = false;
if (p_pattern->array.size() > 0) {
@@ -2742,7 +2664,6 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
}
for (Map<ConstantNode *, PatternNode *>::Element *e = p_pattern->dictionary.front(); e; e = e->next()) {
-
Node *condition = nullptr;
// check for has, then for pattern
@@ -2757,7 +2678,6 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
has_call->arguments.push_back(e->key());
if (e->value()) {
-
OperatorNode *indexed_value = alloc_node<OperatorNode>();
indexed_value->op = OperatorNode::OP_INDEX;
indexed_value->arguments.push_back(p_node_to_match);
@@ -2795,7 +2715,6 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
p_resulting_node = true_value;
} break;
default: {
-
} break;
}
}
@@ -2816,7 +2735,6 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
}
for (int i = 0; i < p_match_statement->branches.size(); i++) {
-
PatternBranchNode *branch = p_match_statement->branches[i];
MatchNode::CompiledPatternBranch compiled_branch;
@@ -2899,11 +2817,12 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
}
void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
-
IndentLevel current_level = indent_level.back()->get();
#ifdef DEBUG_ENABLED
+ pending_newline = -1; // reset for the new block
+
NewLineNode *nl = alloc_node<NewLineNode>();
nl->line = tokenizer->get_token_line();
@@ -2926,8 +2845,9 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
is_first_line = false;
GDScriptTokenizer::Token token = tokenizer->get_token();
- if (error_set)
+ if (error_set) {
return;
+ }
if (current_level.indent > indent_level.back()->get().indent) {
p_block->end_line = tokenizer->get_token_line();
@@ -2935,7 +2855,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
if (pending_newline != -1) {
-
NewLineNode *nl2 = alloc_node<NewLineNode>();
nl2->line = pending_newline;
p_block->statements.push_back(nl2);
@@ -2967,7 +2886,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
} break;
case GDScriptTokenizer::TK_NEWLINE: {
-
int line = tokenizer->get_token_line();
if (!_parse_newline()) {
@@ -2986,7 +2904,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
} break;
case GDScriptTokenizer::TK_CF_PASS: {
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF) {
-
_set_error("Expected \";\" or a line break.");
return;
}
@@ -3003,7 +2920,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
tokenizer->advance();
int var_line = tokenizer->get_token_line();
if (!tokenizer->is_token_literal(0, true)) {
-
_set_error("Expected an identifier for the local variable name.");
return;
}
@@ -3048,7 +2964,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
-
tokenizer->advance();
Node *subexpr = _parse_and_reduce_expression(p_block, p_static);
if (!subexpr) {
@@ -3061,7 +2976,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
lv->assignments++;
assigned = subexpr;
} else {
-
assigned = _get_default_value_for_type(lv->datatype, var_line);
}
//must be added later, to avoid self-referencing.
@@ -3088,7 +3002,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
} break;
case GDScriptTokenizer::TK_CF_IF: {
-
tokenizer->advance();
Node *condition = _parse_and_reduce_expression(p_block, p_static);
@@ -3120,17 +3033,18 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
_parse_block(cf_if->body, p_static);
current_block = p_block;
- if (error_set)
+ if (error_set) {
return;
+ }
p_block->statements.push_back(cf_if);
bool all_have_return = cf_if->body->has_return;
bool have_else = false;
while (true) {
-
- while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline()) {
;
+ }
if (indent_level.back()->get().indent < current_level.indent) { //not at current indent level
p_block->end_line = tokenizer->get_token_line();
@@ -3138,9 +3052,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELIF) {
-
if (indent_level.back()->get().indent > current_level.indent) {
-
_set_error("Invalid indentation.");
return;
}
@@ -3180,13 +3092,13 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
current_block = cf_else->body;
_parse_block(cf_else->body, p_static);
current_block = p_block;
- if (error_set)
+ if (error_set) {
return;
+ }
all_have_return = all_have_return && cf_else->body->has_return;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELSE) {
-
if (indent_level.back()->get().indent > current_level.indent) {
_set_error("Invalid indentation.");
return;
@@ -3205,16 +3117,18 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
current_block = cf_if->body_else;
_parse_block(cf_if->body_else, p_static);
current_block = p_block;
- if (error_set)
+ if (error_set) {
return;
+ }
all_have_return = all_have_return && cf_if->body_else->has_return;
have_else = true;
break; //after else, exit
- } else
+ } else {
break;
+ }
}
cf_if->body->has_return = all_have_return;
@@ -3223,7 +3137,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
} break;
case GDScriptTokenizer::TK_CF_WHILE: {
-
tokenizer->advance();
Node *condition2 = _parse_and_reduce_expression(p_block, p_static);
if (!condition2) {
@@ -3240,6 +3153,8 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
cf_while->body = alloc_node<BlockNode>();
cf_while->body->parent_block = p_block;
+ cf_while->body->can_break = true;
+ cf_while->body->can_continue = true;
p_block->sub_blocks.push_back(cf_while->body);
if (!_enter_indent_block(cf_while->body)) {
@@ -3251,22 +3166,36 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
current_block = cf_while->body;
_parse_block(cf_while->body, p_static);
current_block = p_block;
- if (error_set)
+ if (error_set) {
return;
- p_block->has_return = cf_while->body->has_return;
+ }
p_block->statements.push_back(cf_while);
} break;
case GDScriptTokenizer::TK_CF_FOR: {
-
tokenizer->advance();
if (!tokenizer->is_token_literal(0, true)) {
-
_set_error("Identifier expected after \"for\".");
}
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = tokenizer->get_token_identifier();
+#ifdef DEBUG_ENABLED
+ for (int j = 0; j < current_class->variables.size(); j++) {
+ if (current_class->variables[j].identifier == id->name) {
+ _add_warning(GDScriptWarning::SHADOWED_VARIABLE, id->line, id->name, itos(current_class->variables[j].line));
+ }
+ }
+#endif // DEBUG_ENABLED
+
+ BlockNode *check_block = p_block;
+ while (check_block) {
+ if (check_block->variables.has(id->name)) {
+ _set_error("Variable \"" + String(id->name) + "\" already defined in the scope (at line " + itos(check_block->variables[id->name]->line) + ").");
+ return;
+ }
+ check_block = check_block->parent_block;
+ }
tokenizer->advance();
@@ -3288,7 +3217,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
DataType iter_type;
if (container->type == Node::TYPE_OPERATOR) {
-
OperatorNode *op = static_cast<OperatorNode *>(container);
if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDScriptFunctions::GEN_RANGE) {
//iterating a range, so see if range() can be optimized without allocating memory, by replacing it by vectors (which can work as iterable too!)
@@ -3313,9 +3241,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
if (args.size() > 0 && args.size() < 4) {
-
if (constant) {
-
ConstantNode *cn = alloc_node<ConstantNode>();
switch (args.size()) {
case 1:
@@ -3371,6 +3297,8 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
cf_for->body = alloc_node<BlockNode>();
cf_for->body->parent_block = p_block;
+ cf_for->body->can_break = true;
+ cf_for->body->can_continue = true;
p_block->sub_blocks.push_back(cf_for->body);
if (!_enter_indent_block(cf_for->body)) {
@@ -3394,12 +3322,26 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
_parse_block(cf_for->body, p_static);
current_block = p_block;
- if (error_set)
+ if (error_set) {
return;
- p_block->has_return = cf_for->body->has_return;
+ }
p_block->statements.push_back(cf_for);
} break;
case GDScriptTokenizer::TK_CF_CONTINUE: {
+ BlockNode *upper_block = p_block;
+ bool is_continue_valid = false;
+ while (upper_block) {
+ if (upper_block->can_continue) {
+ is_continue_valid = true;
+ break;
+ }
+ upper_block = upper_block->parent_block;
+ }
+
+ if (!is_continue_valid) {
+ _set_error("Unexpected keyword \"continue\" outside a loop.");
+ return;
+ }
_mark_line_as_safe(tokenizer->get_token_line());
tokenizer->advance();
@@ -3412,6 +3354,20 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
case GDScriptTokenizer::TK_CF_BREAK: {
+ BlockNode *upper_block = p_block;
+ bool is_break_valid = false;
+ while (upper_block) {
+ if (upper_block->can_break) {
+ is_break_valid = true;
+ break;
+ }
+ upper_block = upper_block->parent_block;
+ }
+
+ if (!is_break_valid) {
+ _set_error("Unexpected keyword \"break\" outside a loop.");
+ return;
+ }
_mark_line_as_safe(tokenizer->get_token_line());
tokenizer->advance();
@@ -3424,7 +3380,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
case GDScriptTokenizer::TK_CF_RETURN: {
-
tokenizer->advance();
ControlFlowNode *cf_return = alloc_node<ControlFlowNode>();
cf_return->cf_type = ControlFlowNode::CF_RETURN;
@@ -3456,7 +3411,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
} break;
case GDScriptTokenizer::TK_CF_MATCH: {
-
tokenizer->advance();
MatchNode *match_node = alloc_node<MatchNode>();
@@ -3480,13 +3434,15 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
BlockNode *compiled_branches = alloc_node<BlockNode>();
compiled_branches->parent_block = p_block;
compiled_branches->parent_class = p_block->parent_class;
+ compiled_branches->can_continue = true;
p_block->sub_blocks.push_back(compiled_branches);
_parse_pattern_block(compiled_branches, match_node->branches, p_static);
- if (error_set)
+ if (error_set) {
return;
+ }
ControlFlowNode *match_cf_node = alloc_node<ControlFlowNode>();
match_cf_node->cf_type = ControlFlowNode::CF_MATCH;
@@ -3499,7 +3455,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
_end_statement();
} break;
case GDScriptTokenizer::TK_PR_ASSERT: {
-
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
@@ -3543,7 +3498,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
case GDScriptTokenizer::TK_PR_BREAKPOINT: {
-
tokenizer->advance();
BreakpointNode *bn = alloc_node<BreakpointNode>();
p_block->statements.push_back(bn);
@@ -3554,7 +3508,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
default: {
-
Node *expression = _parse_and_reduce_expression(p_block, p_static, false, true);
if (!expression) {
if (_recover_from_completion()) {
@@ -3579,9 +3532,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
bool GDScriptParser::_parse_newline() {
-
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
-
IndentLevel current_level = indent_level.back()->get();
int indent = tokenizer->get_token_line_indent();
int tabs = tokenizer->get_token_line_tab_indent();
@@ -3598,9 +3549,7 @@ bool GDScriptParser::_parse_newline() {
}
if (indent < current_level.indent) {
-
while (indent < current_level.indent) {
-
//exit block
if (indent_level.size() == 1) {
_set_error("Invalid indentation. Bug?");
@@ -3610,7 +3559,6 @@ bool GDScriptParser::_parse_newline() {
indent_level.pop_back();
if (indent_level.back()->get().indent < indent) {
-
_set_error("Unindent does not match any outer indentation level.");
return false;
}
@@ -3633,15 +3581,12 @@ bool GDScriptParser::_parse_newline() {
}
void GDScriptParser::_parse_extends(ClassNode *p_class) {
-
if (p_class->extends_used) {
-
_set_error("\"extends\" can only be present once per script.");
return;
}
if (!p_class->constant_expressions.empty() || !p_class->subclasses.empty() || !p_class->functions.empty() || !p_class->variables.empty()) {
-
_set_error("\"extends\" must be used before anything else.");
return;
}
@@ -3658,10 +3603,8 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) {
// see if inheritance happens from a file
if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) {
-
Variant constant = tokenizer->get_token_constant();
if (constant.get_type() != Variant::STRING) {
-
_set_error("\"extends\" constant must be a string.");
return;
}
@@ -3678,16 +3621,14 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) {
if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD) {
return;
- } else
+ } else {
tokenizer->advance();
+ }
}
while (true) {
-
switch (tokenizer->get_token()) {
-
case GDScriptTokenizer::TK_IDENTIFIER: {
-
StringName identifier = tokenizer->get_token_identifier();
p_class->extends_class.push_back(identifier);
} break;
@@ -3696,7 +3637,6 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) {
break;
default: {
-
_set_error("Invalid \"extends\" syntax, expected string constant (path) and/or identifier (parent class).");
return;
}
@@ -3705,7 +3645,6 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) {
tokenizer->advance(1);
switch (tokenizer->get_token()) {
-
case GDScriptTokenizer::TK_IDENTIFIER:
case GDScriptTokenizer::TK_PERIOD:
continue;
@@ -3717,14 +3656,13 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) {
}
void GDScriptParser::_parse_class(ClassNode *p_class) {
-
IndentLevel current_level = indent_level.back()->get();
while (true) {
-
GDScriptTokenizer::Token token = tokenizer->get_token();
- if (error_set)
+ if (error_set) {
return;
+ }
if (current_level.indent > indent_level.back()->get().indent) {
p_class->end_line = tokenizer->get_token_line();
@@ -3732,7 +3670,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
switch (token) {
-
case GDScriptTokenizer::TK_CURSOR: {
tokenizer->advance();
} break;
@@ -3752,11 +3689,11 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
} break;
case GDScriptTokenizer::TK_PR_EXTENDS: {
-
_mark_line_as_safe(tokenizer->get_token_line());
_parse_extends(p_class);
- if (error_set)
+ if (error_set) {
return;
+ }
if (!_end_statement()) {
_set_end_statement_error("extends");
return;
@@ -3764,7 +3701,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
case GDScriptTokenizer::TK_PR_CLASS_NAME: {
-
_mark_line_as_safe(tokenizer->get_token_line());
if (p_class->owner) {
_set_error("\"class_name\" is only valid for the main class namespace.");
@@ -3775,7 +3711,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) {
-
_set_error("\"class_name\" syntax: \"class_name <UniqueName>\"");
return;
}
@@ -3841,9 +3776,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
case GDScriptTokenizer::TK_PR_TOOL: {
-
if (p_class->tool) {
-
_set_error("The \"tool\" keyword can only be present once per script.");
return;
}
@@ -3858,7 +3791,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
StringName name;
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) {
-
_set_error("\"class\" syntax: \"class <Name>:\" or \"class <Name> extends <BaseClass>:\"");
return;
}
@@ -3907,14 +3839,13 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
p_class->subclasses.push_back(newclass);
if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_EXTENDS) {
-
_parse_extends(newclass);
- if (error_set)
+ if (error_set) {
return;
+ }
}
if (!_enter_indent_block()) {
-
_set_error("Indented block expected.");
return;
}
@@ -3932,7 +3863,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
case GDScriptTokenizer::TK_PR_STATIC: {
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
-
_set_error("Expected \"func\".");
return;
}
@@ -3940,12 +3870,10 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
[[fallthrough]];
}
case GDScriptTokenizer::TK_PR_FUNCTION: {
-
bool _static = false;
pending_newline = -1;
if (tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_STATIC) {
-
_static = true;
}
@@ -3956,7 +3884,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (name == StringName()) {
-
_set_error("Expected an identifier after \"func\" (syntax: \"func <identifier>([arguments]):\").");
return;
}
@@ -3989,7 +3916,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
#endif // DEBUG_ENABLED
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
-
_set_error("Expected \"(\" after the identifier (syntax: \"func <identifier>([arguments]):\" ).");
return;
}
@@ -4009,19 +3935,16 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
//has arguments
bool defaulting = false;
while (true) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
continue;
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_VAR) {
-
tokenizer->advance(); //var before the identifier is allowed
}
if (!tokenizer->is_token_literal(0, true)) {
-
_set_error("Expected an identifier for an argument.");
return;
}
@@ -4053,7 +3976,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
argument_types.push_back(argtype);
if (defaulting && tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) {
-
_set_error("Default parameter expected.");
return;
}
@@ -4064,8 +3986,9 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
defaulting = true;
tokenizer->advance(1);
Node *defval = _parse_and_reduce_expression(p_class, _static);
- if (!defval || error_set)
+ if (!defval || error_set) {
return;
+ }
OperatorNode *on = alloc_node<OperatorNode>();
on->op = OperatorNode::OP_ASSIGN;
@@ -4094,7 +4017,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
continue;
} else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
-
_set_error("Expected \",\" or \")\".");
return;
}
@@ -4122,14 +4044,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
if (name == "_init") {
-
if (_static) {
_set_error("The constructor cannot be static.");
return;
}
if (p_class->extends_used) {
-
OperatorNode *cparent = alloc_node<OperatorNode>();
cparent->op = OperatorNode::OP_PARENT_CALL;
block->statements.push_back(cparent);
@@ -4150,7 +4070,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
//has arguments
parenthesis++;
while (true) {
-
current_function = function;
Node *arg = _parse_and_reduce_expression(p_class, _static);
current_function = nullptr;
@@ -4160,7 +4079,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
continue;
} else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
-
_set_error("Expected \",\" or \")\".");
return;
}
@@ -4173,9 +4091,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
} else {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
-
_set_error("Parent constructor call found for a class without inheritance.");
return;
}
@@ -4184,7 +4100,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
DataType return_type;
if (tokenizer->get_token() == GDScriptTokenizer::TK_FORWARD_ARROW) {
-
if (!_parse_type(return_type, true)) {
_set_error("Expected a return type for the function.");
return;
@@ -4192,17 +4107,17 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (!_enter_indent_block(block)) {
-
_set_error(vformat("Indented block expected after declaration of \"%s\" function.", function->name));
return;
}
function->return_type = return_type;
- if (_static)
+ if (_static) {
p_class->static_functions.push_back(function);
- else
+ } else {
p_class->functions.push_back(function);
+ }
current_function = function;
function->body = block;
@@ -4224,6 +4139,14 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
sig.name = tokenizer->get_token_identifier();
sig.emissions = 0;
sig.line = tokenizer->get_token_line();
+
+ for (int i = 0; i < current_class->_signals.size(); i++) {
+ if (current_class->_signals[i].name == sig.name) {
+ _set_error("The signal \"" + sig.name + "\" already exists in this class (at line: " + itos(current_class->_signals[i].line) + ").");
+ return;
+ }
+ }
+
tokenizer->advance();
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
@@ -4268,11 +4191,9 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
} break;
case GDScriptTokenizer::TK_PR_EXPORT: {
-
tokenizer->advance();
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
-
#define _ADVANCE_AND_CONSUME_NEWLINES \
do { \
tokenizer->advance(); \
@@ -4297,7 +4218,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
-
Variant::Type type = tokenizer->get_token_type();
if (type == Variant::NIL) {
_set_error("Can't export null type.");
@@ -4316,11 +4236,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_ADVANCE_AND_CONSUME_NEWLINES;
switch (type) {
-
case Variant::INT: {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") {
-
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
@@ -4333,7 +4250,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
bool first = true;
while (true) {
-
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in the named bit flags hint.");
@@ -4341,16 +4257,18 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
String c = tokenizer->get_token_constant();
- if (!first)
+ if (!first) {
current_export.hint_string += ",";
- else
+ } else {
first = false;
+ }
current_export.hint_string += c.xml_escape();
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
+ }
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
@@ -4364,7 +4282,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_2D_RENDER") {
-
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected \")\" in the layers 2D render hint.");
@@ -4375,7 +4292,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_2D_PHYSICS") {
-
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected \")\" in the layers 2D physics hint.");
@@ -4386,7 +4302,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_3D_RENDER") {
-
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected \")\" in the layers 3D render hint.");
@@ -4397,7 +4312,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_3D_PHYSICS") {
-
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected \")\" in the layers 3D physics hint.");
@@ -4412,25 +4326,25 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_ENUM;
bool first = true;
while (true) {
-
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
-
current_export = PropertyInfo();
_set_error("Expected a string constant in the enumeration hint.");
return;
}
String c = tokenizer->get_token_constant();
- if (!first)
+ if (!first) {
current_export.hint_string += ",";
- else
+ } else {
first = false;
+ }
current_export.hint_string += c.xml_escape();
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
+ }
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
@@ -4447,7 +4361,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
[[fallthrough]];
}
case Variant::FLOAT: {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
current_export.hint = PROPERTY_HINT_EXP_EASING;
_ADVANCE_AND_CONSUME_NEWLINES;
@@ -4460,19 +4373,19 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
// range
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") {
-
current_export.hint = PROPERTY_HINT_EXP_RANGE;
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
- else if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected \")\" or \",\" in the exponential range hint.");
return;
}
_ADVANCE_AND_CONSUME_NEWLINES;
- } else
+ } else {
current_export.hint = PROPERTY_HINT_RANGE;
+ }
float sign = 1.0;
@@ -4481,7 +4394,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_ADVANCE_AND_CONSUME_NEWLINES;
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
-
current_export = PropertyInfo();
_set_error("Expected a range in the numeric hint.");
return;
@@ -4496,7 +4408,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
-
current_export = PropertyInfo();
_set_error("Expected \",\" or \")\" in the numeric range hint.");
return;
@@ -4511,7 +4422,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
-
current_export = PropertyInfo();
_set_error("Expected a number as upper bound in the numeric range hint.");
return;
@@ -4520,11 +4430,11 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += "," + rtos(sign * double(tokenizer->get_token_constant()));
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
+ }
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
-
current_export = PropertyInfo();
_set_error("Expected \",\" or \")\" in the numeric range hint.");
return;
@@ -4538,7 +4448,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
-
current_export = PropertyInfo();
_set_error("Expected a number as step in the numeric range hint.");
return;
@@ -4549,30 +4458,29 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
case Variant::STRING: {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
//enumeration
current_export.hint = PROPERTY_HINT_ENUM;
bool first = true;
while (true) {
-
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
-
current_export = PropertyInfo();
_set_error("Expected a string constant in the enumeration hint.");
return;
}
String c = tokenizer->get_token_constant();
- if (!first)
+ if (!first) {
current_export.hint_string += ",";
- else
+ } else {
first = false;
+ }
current_export.hint_string += c.xml_escape();
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
+ }
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
@@ -4586,13 +4494,11 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") {
-
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
current_export.hint = PROPERTY_HINT_DIR;
- else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
-
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) {
@@ -4618,16 +4524,13 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") {
-
current_export.hint = PROPERTY_HINT_FILE;
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
-
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") {
-
if (!p_class->tool) {
_set_error("Global filesystem hints may only be used in tool scripts.");
return;
@@ -4635,22 +4538,22 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_GLOBAL_FILE;
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
- else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA)
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
_ADVANCE_AND_CONSUME_NEWLINES;
- else {
+ } else {
_set_error("Expected \")\" or \",\" in the hint.");
return;
}
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
-
- if (current_export.hint == PROPERTY_HINT_GLOBAL_FILE)
+ if (current_export.hint == PROPERTY_HINT_GLOBAL_FILE) {
_set_error("Expected string constant with filter.");
- else
+ } else {
_set_error("Expected \"GLOBAL\" or string constant with filter.");
+ }
return;
}
current_export.hint_string = tokenizer->get_token_constant();
@@ -4665,7 +4568,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") {
-
current_export.hint = PROPERTY_HINT_MULTILINE_TEXT;
_ADVANCE_AND_CONSUME_NEWLINES;
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
@@ -4676,9 +4578,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
} break;
case Variant::COLOR: {
-
if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) {
-
current_export = PropertyInfo();
_set_error("Color type hint expects RGB or RGBA as hints.");
return;
@@ -4698,7 +4598,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
default: {
-
current_export = PropertyInfo();
_set_error("Type \"" + Variant::get_type_name(type) + "\" can't take hints.");
return;
@@ -4707,7 +4606,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
} else {
-
parenthesis++;
Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
@@ -4767,10 +4665,11 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
bool first = true;
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
if (enum_values[E->get()].get_type() == Variant::INT) {
- if (!first)
+ if (!first) {
current_export.hint_string += ",";
- else
+ } else {
first = false;
+ }
current_export.hint_string += E->get().operator String().camelcase_to_underscore(true).capitalize().xml_escape();
if (!is_flags) {
@@ -4787,7 +4686,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
-
current_export = PropertyInfo();
_set_error("Expected \")\" or \",\" after the export hint.");
return;
@@ -4809,7 +4707,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPET && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTESYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTERSYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPETSYNC) {
-
current_export = PropertyInfo();
_set_error("Expected \"var\", \"onready\", \"remote\", \"master\", \"puppet\", \"remotesync\", \"mastersync\", \"puppetsync\".");
return;
@@ -4818,7 +4715,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_ONREADY: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
@@ -4829,7 +4725,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_REMOTE: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
@@ -4849,7 +4744,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_MASTER: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
@@ -4869,7 +4763,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_PUPPET: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
@@ -4889,14 +4782,14 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_REMOTESYNC: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
- if (current_export.type)
+ if (current_export.type) {
_set_error("Expected \"var\".");
- else
+ } else {
_set_error("Expected \"var\" or \"func\".");
+ }
return;
}
@@ -4904,14 +4797,14 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_MASTERSYNC: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
- if (current_export.type)
+ if (current_export.type) {
_set_error("Expected \"var\".");
- else
+ } else {
_set_error("Expected \"var\" or \"func\".");
+ }
return;
}
@@ -4919,14 +4812,14 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
continue;
} break;
case GDScriptTokenizer::TK_PR_PUPPETSYNC: {
-
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
- if (current_export.type)
+ if (current_export.type) {
_set_error("Expected \"var\".");
- else
+ } else {
_set_error("Expected \"var\" or \"func\".");
+ }
return;
}
@@ -4948,7 +4841,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
if (!tokenizer->is_token_literal(0, true)) {
-
_set_error("Expected an identifier for the member variable name.");
return;
}
@@ -5038,7 +4930,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
#endif
if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
-
#ifdef DEBUG_ENABLED
int line = tokenizer->get_token_line();
#endif
@@ -5054,12 +4945,10 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
//discourage common error
if (!onready && subexpr->type == Node::TYPE_OPERATOR) {
-
OperatorNode *op = static_cast<OperatorNode *>(subexpr);
if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_SELF && op->arguments[1]->type == Node::TYPE_IDENTIFIER) {
IdentifierNode *id = static_cast<IdentifierNode *>(op->arguments[1]);
if (id->name == "get_node") {
-
_set_error("Use \"onready var " + String(member.identifier) + " = get_node(...)\" instead.");
return;
}
@@ -5069,22 +4958,20 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
member.expression = subexpr;
if (autoexport && !member.data_type.has_type) {
-
if (subexpr->type != Node::TYPE_CONSTANT) {
-
_set_error("Type-less export needs a constant expression assigned to infer type.");
return;
}
ConstantNode *cn = static_cast<ConstantNode *>(subexpr);
if (cn->value.get_type() == Variant::NIL) {
-
_set_error("Can't accept a null constant expression for inferring export type.");
return;
}
- if (!_reduce_export_var_type(cn->value, member.line))
+ if (!_reduce_export_var_type(cn->value, member.line)) {
return;
+ }
member._export.type = cn->value.get_type();
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
@@ -5101,7 +4988,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
#ifdef TOOLS_ENABLED
if (subexpr->type == Node::TYPE_CONSTANT && (member._export.type != Variant::NIL || member.data_type.has_type)) {
-
ConstantNode *cn = static_cast<ConstantNode *>(subexpr);
if (cn->value.get_type() != Variant::NIL) {
if (member._export.type != Variant::NIL && cn->value.get_type() != member._export.type) {
@@ -5131,20 +5017,21 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
#ifdef DEBUG_ENABLED
NewLineNode *nl2 = alloc_node<NewLineNode>();
nl2->line = line;
- if (onready)
+ if (onready) {
p_class->ready->statements.push_back(nl2);
- else
+ } else {
p_class->initializer->statements.push_back(nl2);
+ }
#endif
- if (onready)
+ if (onready) {
p_class->ready->statements.push_back(op);
- else
+ } else {
p_class->initializer->statements.push_back(op);
+ }
member.initial_assignment = op;
} else {
-
if (autoexport && !member.data_type.has_type) {
_set_error("Type-less export needs a constant expression assigned to infer type.");
return;
@@ -5177,7 +5064,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_SETGET) {
-
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
@@ -5218,7 +5104,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
if (!tokenizer->is_token_literal(0, true)) {
-
_set_error("Expected an identifier for the constant.");
return;
}
@@ -5334,14 +5219,11 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
while (true) {
if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
-
tokenizer->advance(); // Ignore newlines
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
-
tokenizer->advance();
break; // End of enum
} else if (!tokenizer->is_token_literal(0, true)) {
-
if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unexpected end of file.");
} else {
@@ -5462,7 +5344,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
} break;
default: {
-
_set_error(String() + "Unexpected token: " + tokenizer->get_token_name(tokenizer->get_token()) + ":" + tokenizer->get_token_identifier());
return;
@@ -5472,7 +5353,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive) {
-
if (p_class->base_type.has_type) {
// Already determined
} else if (p_class->extends_used) {
@@ -5487,7 +5367,6 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
//path (and optionally subclasses)
if (path.is_rel_path()) {
-
String base = base_path;
if (base == "" || base.is_rel_path()) {
@@ -5502,22 +5381,17 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
return;
}
if (!script->is_valid()) {
-
_set_error("Script isn't fully loaded (cyclic preload?): " + path, p_class->line);
return;
}
if (p_class->extends_class.size()) {
-
for (int i = 0; i < p_class->extends_class.size(); i++) {
-
String sub = p_class->extends_class[i];
if (script->get_subclasses().has(sub)) {
-
Ref<Script> subclass = script->get_subclasses()[sub]; //avoid reference from disappearing
script = subclass;
} else {
-
_set_error("Couldn't find the subclass: " + sub, p_class->line);
return;
}
@@ -5525,7 +5399,6 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
}
} else {
-
if (p_class->extends_class.size() == 0) {
_set_error("Parser bug: undecidable inheritance.", p_class->line);
ERR_FAIL();
@@ -5572,7 +5445,6 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
}
while (p) {
-
bool found = false;
for (int i = 0; i < p->subclasses.size(); i++) {
@@ -5601,10 +5473,12 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
}
}
- if (base_class)
+ if (base_class) {
break;
- if (found)
+ }
+ if (found) {
continue;
+ }
if (p->constant_expressions.has(base)) {
if (p->constant_expressions[base].expression->type != Node::TYPE_CONSTANT) {
@@ -5624,21 +5498,17 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
}
if (base_script.is_valid()) {
-
String ident = base;
Ref<GDScript> find_subclass = base_script;
for (int i = extend_iter; i < p_class->extends_class.size(); i++) {
-
String subclass = p_class->extends_class[i];
ident += ("." + subclass);
if (find_subclass->get_subclasses().has(subclass)) {
-
find_subclass = find_subclass->get_subclasses()[subclass];
} else if (find_subclass->get_constants().has(subclass)) {
-
Ref<GDScript> new_base_class = find_subclass->get_constants()[subclass];
if (new_base_class.is_null()) {
_set_error("Constant isn't a class: " + ident, p_class->line);
@@ -5646,7 +5516,6 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
}
find_subclass = new_base_class;
} else {
-
_set_error("Couldn't find the subclass: " + ident, p_class->line);
return;
}
@@ -5655,15 +5524,12 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
script = find_subclass;
} else if (!base_class) {
-
if (p_class->extends_class.size() > 1) {
-
_set_error("Invalid inheritance (unknown class + subclasses).", p_class->line);
return;
}
//if not found, try engine classes
if (!GDScriptLanguage::get_singleton()->get_global_map().has(base)) {
-
_set_error("Unknown class: \"" + base + "\"", p_class->line);
return;
}
@@ -5706,12 +5572,14 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
}
String GDScriptParser::DataType::to_string() const {
- if (!has_type)
+ if (!has_type) {
return "var";
+ }
switch (kind) {
case BUILTIN: {
- if (builtin_type == Variant::NIL)
+ if (builtin_type == Variant::NIL) {
return "null";
+ }
return Variant::get_type_name(builtin_type);
} break;
case NATIVE: {
@@ -5875,10 +5743,12 @@ bool GDScriptParser::_parse_type(DataType &r_type, bool p_can_be_void) {
}
GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source, int p_line) {
- if (!p_source.has_type)
+ if (!p_source.has_type) {
return p_source;
- if (p_source.kind != DataType::UNRESOLVED)
+ }
+ if (p_source.kind != DataType::UNRESOLVED) {
return p_source;
+ }
Vector<String> full_name = p_source.native_type.operator String().split(".", false);
int name_part = 0;
@@ -5887,7 +5757,6 @@ GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source,
result.has_type = true;
while (name_part < full_name.size()) {
-
bool found = false;
StringName id = full_name[name_part];
DataType base_type = result;
@@ -6549,7 +6418,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
DataType source_type = _reduce_node_type(cn->source_node);
cn->cast_type = _resolve_type(cn->cast_type, cn->line);
if (source_type.has_type) {
-
bool valid = false;
if (check_types) {
if (cn->cast_type.kind == DataType::BUILTIN && source_type.kind == DataType::BUILTIN) {
@@ -6603,7 +6471,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
} break;
case OperatorNode::OP_IS:
case OperatorNode::OP_IS_BUILTIN: {
-
if (op->arguments.size() != 2) {
_set_error("Parser bug: binary operation without 2 arguments.", op->line);
ERR_FAIL_V(DataType());
@@ -6639,7 +6506,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case OperatorNode::OP_POS:
case OperatorNode::OP_NOT:
case OperatorNode::OP_BIT_INVERT: {
-
DataType argument_type = _reduce_node_type(op->arguments[0]);
if (!argument_type.has_type) {
break;
@@ -6677,7 +6543,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case OperatorNode::OP_BIT_AND:
case OperatorNode::OP_BIT_OR:
case OperatorNode::OP_BIT_XOR: {
-
if (op->arguments.size() != 2) {
_set_error("Parser bug: binary operation without 2 arguments.", op->line);
ERR_FAIL_V(DataType());
@@ -6745,7 +6610,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case OperatorNode::OP_ASSIGN_BIT_OR:
case OperatorNode::OP_ASSIGN_BIT_XOR:
case OperatorNode::OP_INIT_ASSIGN: {
-
_set_error("Assignment inside an expression isn't allowed (parser bug?).", op->line);
return DataType();
@@ -6808,7 +6672,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
}
} break;
case OperatorNode::OP_INDEX: {
-
if (op->arguments[1]->type == Node::TYPE_CONSTANT) {
ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[1]);
if (cn->value.get_type() == Variant::STRING) {
@@ -7007,7 +6870,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
}
bool GDScriptParser::_get_function_signature(DataType &p_base_type, const StringName &p_function, DataType &r_return_type, List<DataType> &r_arg_types, int &r_default_arg_count, bool &r_static, bool &r_vararg) const {
-
r_static = false;
r_default_arg_count = 0;
@@ -7118,8 +6980,9 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String
native = "_" + native.operator String();
}
if (!ClassDB::class_exists(native)) {
- if (!check_types)
+ if (!check_types) {
return false;
+ }
ERR_FAIL_V_MSG(false, "Parser bug: Class '" + String(native) + "' not found.");
}
@@ -7210,8 +7073,9 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
par_types.write[i - 1] = _reduce_node_type(p_call->arguments[i]);
}
- if (error_set)
+ if (error_set) {
return DataType();
+ }
// Special case: check copy constructor. Those are defined implicitly in Variant.
if (par_types.size() == 1) {
@@ -7279,8 +7143,9 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
err += "' matches the signature '";
err += Variant::get_type_name(tn->vtype) + "(";
for (int i = 0; i < par_types.size(); i++) {
- if (i > 0)
+ if (i > 0) {
err += ", ";
+ }
err += par_types[i].to_string();
}
err += ")'.";
@@ -7489,8 +7354,8 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
} else if (!_is_type_compatible(arg_types[i - arg_diff], par_type, true)) {
// Supertypes are acceptable for dynamic compliance
if (!_is_type_compatible(par_type, arg_types[i - arg_diff])) {
- _set_error("At \"" + callee_name + "()\" call, argument " + itos(i - arg_diff + 1) + ". Assigned type (" +
- par_type.to_string() + ") doesn't match the function argument's type (" +
+ _set_error("At \"" + callee_name + "()\" call, argument " + itos(i - arg_diff + 1) + ". The passed argument's type (" +
+ par_type.to_string() + ") doesn't match the function's expected argument type (" +
arg_types[i - arg_diff].to_string() + ").",
p_call->line);
return DataType();
@@ -7520,8 +7385,9 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
while (base) {
if (base->constant_expressions.has(p_member)) {
- if (r_is_const)
+ if (r_is_const) {
*r_is_const = true;
+ }
r_member_type = base->constant_expressions[p_member].expression->get_datatype();
return true;
}
@@ -7640,8 +7506,9 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
native = "_" + native.operator String();
}
if (!ClassDB::class_exists(native)) {
- if (!check_types)
+ if (!check_types) {
return false;
+ }
ERR_FAIL_V_MSG(false, "Parser bug: Class \"" + String(native) + "\" not found.");
}
@@ -7729,7 +7596,6 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
}
GDScriptParser::DataType GDScriptParser::_reduce_identifier_type(const DataType *p_base_type, const StringName &p_identifier, int p_line, bool p_is_indexing) {
-
if (p_base_type && !p_base_type->has_type) {
return DataType();
}
@@ -7903,7 +7769,6 @@ GDScriptParser::DataType GDScriptParser::_reduce_identifier_type(const DataType
}
void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
-
// Names of internal object properties that we check to avoid overriding them.
// "__meta__" could also be in here, but since it doesn't really affect object metadata,
// it is okay to override it on script.
@@ -7939,14 +7804,16 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
// Function declarations
for (int i = 0; i < p_class->static_functions.size(); i++) {
_check_function_types(p_class->static_functions[i]);
- if (error_set)
+ if (error_set) {
return;
+ }
}
for (int i = 0; i < p_class->functions.size(); i++) {
_check_function_types(p_class->functions[i]);
- if (error_set)
+ if (error_set) {
return;
+ }
}
// Class variables
@@ -8005,6 +7872,10 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
_set_error("The assigned value doesn't have a set type; the variable type can't be inferred.", v.line);
return;
}
+ if (expr_type.kind == DataType::BUILTIN && expr_type.builtin_type == Variant::NIL) {
+ _set_error("The variable type cannot be inferred because its value is \"null\".", v.line);
+ return;
+ }
v.data_type = expr_type;
v.data_type.is_constant = false;
}
@@ -8022,8 +7893,9 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
}
// Setter and getter
- if (v.setter == StringName() && v.getter == StringName())
+ if (v.setter == StringName() && v.getter == StringName()) {
continue;
+ }
bool found_getter = false;
bool found_setter = false;
@@ -8066,12 +7938,14 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
return;
}
}
- if (found_getter && found_setter)
+ if (found_getter && found_setter) {
break;
+ }
}
- if ((found_getter || v.getter == StringName()) && (found_setter || v.setter == StringName()))
+ if ((found_getter || v.getter == StringName()) && (found_setter || v.setter == StringName())) {
continue;
+ }
// Check for static functions
for (int j = 0; j < p_class->static_functions.size(); j++) {
@@ -8098,18 +7972,59 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
}
}
+ // Signals
+ DataType base = p_class->base_type;
+
+ while (base.kind == DataType::CLASS) {
+ ClassNode *base_class = base.class_type;
+ for (int i = 0; i < p_class->_signals.size(); i++) {
+ for (int j = 0; j < base_class->_signals.size(); j++) {
+ if (p_class->_signals[i].name == base_class->_signals[j].name) {
+ _set_error("The signal \"" + p_class->_signals[i].name + "\" already exists in a parent class.", p_class->_signals[i].line);
+ return;
+ }
+ }
+ }
+ base = base_class->base_type;
+ }
+
+ StringName native;
+ if (base.kind == DataType::GDSCRIPT || base.kind == DataType::SCRIPT) {
+ Ref<Script> scr = base.script_type;
+ if (scr.is_valid() && scr->is_valid()) {
+ native = scr->get_instance_base_type();
+ for (int i = 0; i < p_class->_signals.size(); i++) {
+ if (scr->has_script_signal(p_class->_signals[i].name)) {
+ _set_error("The signal \"" + p_class->_signals[i].name + "\" already exists in a parent class.", p_class->_signals[i].line);
+ return;
+ }
+ }
+ }
+ } else if (base.kind == DataType::NATIVE) {
+ native = base.native_type;
+ }
+
+ if (native != StringName()) {
+ for (int i = 0; i < p_class->_signals.size(); i++) {
+ if (ClassDB::has_signal(native, p_class->_signals[i].name)) {
+ _set_error("The signal \"" + p_class->_signals[i].name + "\" already exists in a parent class.", p_class->_signals[i].line);
+ return;
+ }
+ }
+ }
+
// Inner classes
for (int i = 0; i < p_class->subclasses.size(); i++) {
current_class = p_class->subclasses[i];
_check_class_level_types(current_class);
- if (error_set)
+ if (error_set) {
return;
+ }
current_class = p_class;
}
}
void GDScriptParser::_check_function_types(FunctionNode *p_function) {
-
p_function->return_type = _resolve_type(p_function->return_type, p_function->line);
// Arguments
@@ -8228,21 +8143,9 @@ void GDScriptParser::_check_function_types(FunctionNode *p_function) {
p_function->return_type.has_type = false;
p_function->return_type.may_yield = true;
}
-
-#ifdef DEBUG_ENABLED
- for (Map<StringName, LocalVarNode *>::Element *E = p_function->body->variables.front(); E; E = E->next()) {
- LocalVarNode *lv = E->get();
- for (int i = 0; i < current_class->variables.size(); i++) {
- if (current_class->variables[i].identifier == lv->name) {
- _add_warning(GDScriptWarning::SHADOWED_VARIABLE, lv->line, lv->name, itos(current_class->variables[i].line));
- }
- }
- }
-#endif // DEBUG_ENABLED
}
void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
-
// Function blocks
for (int i = 0; i < p_class->static_functions.size(); i++) {
current_function = p_class->static_functions[i];
@@ -8251,8 +8154,9 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
_check_block_types(current_block);
current_block = nullptr;
current_function = nullptr;
- if (error_set)
+ if (error_set) {
return;
+ }
}
for (int i = 0; i < p_class->functions.size(); i++) {
@@ -8262,8 +8166,9 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
_check_block_types(current_block);
current_block = nullptr;
current_function = nullptr;
- if (error_set)
+ if (error_set) {
return;
+ }
}
#ifdef DEBUG_ENABLED
@@ -8284,8 +8189,9 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
for (int i = 0; i < p_class->subclasses.size(); i++) {
current_class = p_class->subclasses[i];
_check_class_blocks_types(current_class);
- if (error_set)
+ if (error_set) {
return;
+ }
current_class = p_class;
}
}
@@ -8311,7 +8217,6 @@ static String _find_function_name(const GDScriptParser::OperatorNode *p_call) {
#endif // DEBUG_ENABLED
void GDScriptParser::_check_block_types(BlockNode *p_block) {
-
Node *last_var_assign = nullptr;
// Check each statement
@@ -8349,6 +8254,11 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
if (lv->datatype.has_type && assign_type.may_yield && lv->assign->type == Node::TYPE_OPERATOR) {
_add_warning(GDScriptWarning::FUNCTION_MAY_YIELD, lv->line, _find_function_name(static_cast<OperatorNode *>(lv->assign)));
}
+ for (int i = 0; i < current_class->variables.size(); i++) {
+ if (current_class->variables[i].identifier == lv->name) {
+ _add_warning(GDScriptWarning::SHADOWED_VARIABLE, lv->line, lv->name, itos(current_class->variables[i].line));
+ }
+ }
#endif // DEBUG_ENABLED
if (!_is_type_compatible(lv->datatype, assign_type)) {
@@ -8394,6 +8304,10 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
_set_error("The assigned value doesn't have a set type; the variable type can't be inferred.", lv->line);
return;
}
+ if (assign_type.kind == DataType::BUILTIN && assign_type.builtin_type == Variant::NIL) {
+ _set_error("The variable type cannot be inferred because its value is \"null\".", lv->line);
+ return;
+ }
lv->datatype = assign_type;
lv->datatype.is_constant = false;
}
@@ -8548,8 +8462,9 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
_add_warning(GDScriptWarning::RETURN_VALUE_DISCARDED, op->line, func_name);
}
#endif // DEBUG_ENABLED
- if (error_set)
+ if (error_set) {
return;
+ }
} break;
case OperatorNode::OP_YIELD: {
_mark_line_as_safe(op->line);
@@ -8584,8 +8499,9 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
}
}
- if (!function_type.has_type)
+ if (!function_type.has_type) {
break;
+ }
if (function_type.kind == DataType::BUILTIN && function_type.builtin_type == Variant::NIL) {
// Return void, should not have arguments
@@ -8645,8 +8561,9 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
current_block = p_block->sub_blocks[i];
_check_block_types(current_block);
current_block = p_block;
- if (error_set)
+ if (error_set) {
return;
+ }
}
#ifdef DEBUG_ENABLED
@@ -8665,9 +8582,9 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
}
void GDScriptParser::_set_error(const String &p_error, int p_line, int p_column) {
-
- if (error_set)
+ if (error_set) {
return; //allow no further errors
+ }
error = p_error;
error_line = p_line < 0 ? tokenizer->get_token_line() : p_line;
@@ -8729,16 +8646,14 @@ void GDScriptParser::_add_warning(int p_code, int p_line, const Vector<String> &
#endif // DEBUG_ENABLED
String GDScriptParser::get_error() const {
-
return error;
}
int GDScriptParser::get_error_line() const {
-
return error_line;
}
-int GDScriptParser::get_error_column() const {
+int GDScriptParser::get_error_column() const {
return error_column;
}
@@ -8747,7 +8662,6 @@ bool GDScriptParser::has_error() const {
}
Error GDScriptParser::_parse(const String &p_base_path) {
-
base_path = p_base_path;
//assume class
@@ -8789,8 +8703,9 @@ Error GDScriptParser::_parse(const String &p_base_path) {
current_function = nullptr;
current_block = nullptr;
- if (for_completion)
+ if (for_completion) {
check_types = false;
+ }
// Resolve all class-level stuff before getting into function blocks
_check_class_level_types(main_class);
@@ -8846,7 +8761,6 @@ Error GDScriptParser::_parse(const String &p_base_path) {
}
Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) {
-
clear();
self_path = p_self_path;
@@ -8860,7 +8774,6 @@ Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const St
}
Error GDScriptParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion, Set<int> *r_safe_lines, bool p_dependencies_only) {
-
clear();
self_path = p_self_path;
@@ -8881,19 +8794,15 @@ Error GDScriptParser::parse(const String &p_code, const String &p_base_path, boo
}
bool GDScriptParser::is_tool_script() const {
-
return (head && head->type == Node::TYPE_CLASS && static_cast<const ClassNode *>(head)->tool);
}
const GDScriptParser::Node *GDScriptParser::get_parse_tree() const {
-
return head;
}
void GDScriptParser::clear() {
-
while (list) {
-
Node *l = list;
list = list->next;
memdelete(l);
@@ -8935,57 +8844,46 @@ void GDScriptParser::clear() {
}
GDScriptParser::CompletionType GDScriptParser::get_completion_type() {
-
return completion_type;
}
StringName GDScriptParser::get_completion_cursor() {
-
return completion_cursor;
}
int GDScriptParser::get_completion_line() {
-
return completion_line;
}
Variant::Type GDScriptParser::get_completion_built_in_constant() {
-
return completion_built_in_constant;
}
GDScriptParser::Node *GDScriptParser::get_completion_node() {
-
return completion_node;
}
GDScriptParser::BlockNode *GDScriptParser::get_completion_block() {
-
return completion_block;
}
GDScriptParser::ClassNode *GDScriptParser::get_completion_class() {
-
return completion_class;
}
GDScriptParser::FunctionNode *GDScriptParser::get_completion_function() {
-
return completion_function;
}
int GDScriptParser::get_completion_argument_index() {
-
return completion_argument;
}
bool GDScriptParser::get_completion_identifier_is_function() {
-
return completion_ident_is_call;
}
GDScriptParser::GDScriptParser() {
-
head = nullptr;
list = nullptr;
tokenizer = nullptr;
@@ -8994,6 +8892,5 @@ GDScriptParser::GDScriptParser() {
}
GDScriptParser::~GDScriptParser() {
-
clear();
}
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 834bab02a4..7dedb6d6f9 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -45,25 +45,27 @@ public:
struct ClassNode;
struct DataType {
- enum {
+ enum Kind {
BUILTIN,
NATIVE,
SCRIPT,
GDSCRIPT,
CLASS,
UNRESOLVED
- } kind;
+ };
+
+ Kind kind = UNRESOLVED;
- bool has_type;
- bool is_constant;
- bool is_meta_type; // Whether the value can be used as a type
- bool infer_type;
- bool may_yield; // For function calls
+ bool has_type = false;
+ bool is_constant = false;
+ bool is_meta_type = false; // Whether the value can be used as a type
+ bool infer_type = false;
+ bool may_yield = false; // For function calls
- Variant::Type builtin_type;
+ Variant::Type builtin_type = Variant::NIL;
StringName native_type;
Ref<Script> script_type;
- ClassNode *class_type;
+ ClassNode *class_type = nullptr;
String to_string() const;
@@ -94,19 +96,10 @@ public:
return false;
}
- DataType() :
- kind(UNRESOLVED),
- has_type(false),
- is_constant(false),
- is_meta_type(false),
- infer_type(false),
- may_yield(false),
- builtin_type(Variant::NIL),
- class_type(nullptr) {}
+ DataType() {}
};
struct Node {
-
enum Type {
TYPE_CLASS,
TYPE_FUNCTION,
@@ -145,7 +138,6 @@ public:
struct OperatorNode;
struct ClassNode : public Node {
-
bool tool;
StringName name;
bool extends_used;
@@ -206,7 +198,6 @@ public:
};
struct FunctionNode : public Node {
-
bool _static;
MultiplayerAPI::RPCMode rpc_mode;
bool has_yield;
@@ -235,67 +226,65 @@ public:
};
struct BlockNode : public Node {
-
- ClassNode *parent_class;
- BlockNode *parent_block;
+ ClassNode *parent_class = nullptr;
+ BlockNode *parent_block = nullptr;
List<Node *> statements;
Map<StringName, LocalVarNode *> variables;
- bool has_return;
+ bool has_return = false;
+ bool can_break = false;
+ bool can_continue = false;
- Node *if_condition; //tiny hack to improve code completion on if () blocks
+ Node *if_condition = nullptr; //tiny hack to improve code completion on if () blocks
//the following is useful for code completion
List<BlockNode *> sub_blocks;
- int end_line;
+ int end_line = -1;
+
BlockNode() {
- if_condition = nullptr;
type = TYPE_BLOCK;
- end_line = -1;
- parent_block = nullptr;
- parent_class = nullptr;
- has_return = false;
}
};
struct TypeNode : public Node {
-
Variant::Type vtype;
- TypeNode() { type = TYPE_TYPE; }
+
+ TypeNode() {
+ type = TYPE_TYPE;
+ }
};
+
struct BuiltInFunctionNode : public Node {
GDScriptFunctions::Function function;
- BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
+
+ BuiltInFunctionNode() {
+ type = TYPE_BUILT_IN_FUNCTION;
+ }
};
struct IdentifierNode : public Node {
-
StringName name;
- BlockNode *declared_block; // Simplify lookup by checking if it is declared locally
+ BlockNode *declared_block = nullptr; // Simplify lookup by checking if it is declared locally
DataType datatype;
virtual DataType get_datatype() const { return datatype; }
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
+
IdentifierNode() {
type = TYPE_IDENTIFIER;
- declared_block = nullptr;
}
};
struct LocalVarNode : public Node {
-
StringName name;
- Node *assign;
- OperatorNode *assign_op;
- int assignments;
- int usages;
+ Node *assign = nullptr;
+ OperatorNode *assign_op = nullptr;
+ int assignments = 0;
+ int usages = 0;
DataType datatype;
virtual DataType get_datatype() const { return datatype; }
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
+
LocalVarNode() {
type = TYPE_LOCAL_VAR;
- assign = nullptr;
- assign_op = nullptr;
- assignments = 0;
- usages = 0;
}
};
@@ -304,15 +293,18 @@ public:
DataType datatype;
virtual DataType get_datatype() const { return datatype; }
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
- ConstantNode() { type = TYPE_CONSTANT; }
+
+ ConstantNode() {
+ type = TYPE_CONSTANT;
+ }
};
struct ArrayNode : public Node {
-
Vector<Node *> elements;
DataType datatype;
virtual DataType get_datatype() const { return datatype; }
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
+
ArrayNode() {
type = TYPE_ARRAY;
datatype.has_type = true;
@@ -322,9 +314,7 @@ public:
};
struct DictionaryNode : public Node {
-
struct Pair {
-
Node *key;
Node *value;
};
@@ -333,6 +323,7 @@ public:
DataType datatype;
virtual DataType get_datatype() const { return datatype; }
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
+
DictionaryNode() {
type = TYPE_DICTIONARY;
datatype.has_type = true;
@@ -342,7 +333,9 @@ public:
};
struct SelfNode : public Node {
- SelfNode() { type = TYPE_SELF; }
+ SelfNode() {
+ type = TYPE_SELF;
+ }
};
struct OperatorNode : public Node {
@@ -404,11 +397,12 @@ public:
DataType datatype;
virtual DataType get_datatype() const { return datatype; }
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
- OperatorNode() { type = TYPE_OPERATOR; }
+ OperatorNode() {
+ type = TYPE_OPERATOR;
+ }
};
struct PatternNode : public Node {
-
enum PatternType {
PT_CONSTANT,
PT_BIND,
@@ -454,19 +448,17 @@ public:
CF_MATCH
};
- CFType cf_type;
+ CFType cf_type = CF_IF;
Vector<Node *> arguments;
- BlockNode *body;
- BlockNode *body_else;
+ BlockNode *body = nullptr;
+ BlockNode *body_else = nullptr;
MatchNode *match;
ControlFlowNode *_else; //used for if
+
ControlFlowNode() {
type = TYPE_CONTROL_FLOW;
- cf_type = CF_IF;
- body = nullptr;
- body_else = nullptr;
}
};
@@ -476,29 +468,34 @@ public:
DataType return_type;
virtual DataType get_datatype() const { return return_type; }
virtual void set_datatype(const DataType &p_datatype) { return_type = p_datatype; }
- CastNode() { type = TYPE_CAST; }
+
+ CastNode() {
+ type = TYPE_CAST;
+ }
};
struct AssertNode : public Node {
- Node *condition;
- Node *message;
- AssertNode() :
- condition(0),
- message(0) {
+ Node *condition = nullptr;
+ Node *message = nullptr;
+
+ AssertNode() {
type = TYPE_ASSERT;
}
};
struct BreakpointNode : public Node {
- BreakpointNode() { type = TYPE_BREAKPOINT; }
+ BreakpointNode() {
+ type = TYPE_BREAKPOINT;
+ }
};
struct NewLineNode : public Node {
- NewLineNode() { type = TYPE_NEWLINE; }
+ NewLineNode() {
+ type = TYPE_NEWLINE;
+ }
};
struct Expression {
-
bool is_op;
union {
OperatorNode::Operator op;
@@ -553,8 +550,8 @@ private:
int pending_newline;
struct IndentLevel {
- int indent;
- int tabs;
+ int indent = 0;
+ int tabs = 0;
bool is_mixed(IndentLevel other) {
return (
@@ -563,9 +560,7 @@ private:
(indent < other.indent && tabs > other.tabs));
}
- IndentLevel() :
- indent(0),
- tabs(0) {}
+ IndentLevel() {}
IndentLevel(int p_indent, int p_tabs) :
indent(p_indent),
@@ -648,14 +643,16 @@ private:
void _check_block_types(BlockNode *p_block);
_FORCE_INLINE_ void _mark_line_as_safe(int p_line) const {
#ifdef DEBUG_ENABLED
- if (safe_lines)
+ if (safe_lines) {
safe_lines->insert(p_line);
+ }
#endif // DEBUG_ENABLED
}
_FORCE_INLINE_ void _mark_line_as_unsafe(int p_line) const {
#ifdef DEBUG_ENABLED
- if (safe_lines)
+ if (safe_lines) {
safe_lines->erase(p_line);
+ }
#endif // DEBUG_ENABLED
}
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 1c8282e13e..2db42601c6 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -240,7 +240,6 @@ static const _kws _keyword_list[] = {
};
const char *GDScriptTokenizer::get_token_name(Token p_token) {
-
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
return token_names[p_token];
}
@@ -364,27 +363,22 @@ StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
}
static bool _is_text_char(CharType c) {
-
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
static bool _is_number(CharType c) {
-
return (c >= '0' && c <= '9');
}
static bool _is_hex(CharType c) {
-
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
static bool _is_bin(CharType c) {
-
return (c == '0' || c == '1');
}
void GDScriptTokenizerText::_make_token(Token p_type) {
-
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = p_type;
@@ -393,8 +387,8 @@ void GDScriptTokenizerText::_make_token(Token p_type) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
+void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_IDENTIFIER;
@@ -406,7 +400,6 @@ void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
}
void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_func) {
-
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_BUILT_IN_FUNC;
@@ -416,8 +409,8 @@ void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_fu
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
+void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_CONSTANT;
@@ -429,7 +422,6 @@ void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
}
void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) {
-
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_BUILT_IN_TYPE;
@@ -441,7 +433,6 @@ void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) {
}
void GDScriptTokenizerText::_make_error(const String &p_error) {
-
error_flag = true;
last_error = p_error;
@@ -454,7 +445,6 @@ void GDScriptTokenizerText::_make_error(const String &p_error) {
}
void GDScriptTokenizerText::_make_newline(int p_indentation, int p_tabs) {
-
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_NEWLINE;
tk.constant = Vector2(p_indentation, p_tabs);
@@ -464,7 +454,6 @@ void GDScriptTokenizerText::_make_newline(int p_indentation, int p_tabs) {
}
void GDScriptTokenizerText::_advance() {
-
if (error_flag) {
//parser broke
_make_error(last_error);
@@ -482,7 +471,6 @@ void GDScriptTokenizerText::_advance() {
column += m_amount; \
}
while (true) {
-
bool is_string_name = false;
StringMode string_mode = STRING_DOUBLE_QUOTE;
@@ -570,7 +558,6 @@ void GDScriptTokenizerText::_advance() {
return;
}
case '/': {
-
switch (GETCHAR(1)) {
case '=': { // diveq
@@ -587,13 +574,13 @@ void GDScriptTokenizerText::_advance() {
_make_token(TK_OP_EQUAL);
INCPOS(1);
- } else
+ } else {
_make_token(TK_OP_ASSIGN);
+ }
} break;
case '<': {
if (GETCHAR(1) == '=') {
-
_make_token(TK_OP_LESS_EQUAL);
INCPOS(1);
} else if (GETCHAR(1) == '<') {
@@ -604,8 +591,9 @@ void GDScriptTokenizerText::_advance() {
_make_token(TK_OP_SHIFT_LEFT);
}
INCPOS(1);
- } else
+ } else {
_make_token(TK_OP_LESS);
+ }
} break;
case '>': {
@@ -684,7 +672,6 @@ void GDScriptTokenizerText::_advance() {
break;
case '&': {
if (GETCHAR(1) == '&') {
-
_make_token(TK_OP_AND);
INCPOS(1);
} else if (GETCHAR(1) == '=') {
@@ -696,7 +683,6 @@ void GDScriptTokenizerText::_advance() {
} break;
case '|': {
if (GETCHAR(1) == '|') {
-
_make_token(TK_OP_OR);
INCPOS(1);
} else if (GETCHAR(1) == '=') {
@@ -707,7 +693,6 @@ void GDScriptTokenizerText::_advance() {
}
} break;
case '*': {
-
if (GETCHAR(1) == '=') {
_make_token(TK_OP_ASSIGN_MUL);
INCPOS(1);
@@ -716,7 +701,6 @@ void GDScriptTokenizerText::_advance() {
}
} break;
case '+': {
-
if (GETCHAR(1) == '=') {
_make_token(TK_OP_ASSIGN_ADD);
INCPOS(1);
@@ -731,7 +715,6 @@ void GDScriptTokenizerText::_advance() {
} break;
case '-': {
-
if (GETCHAR(1) == '=') {
_make_token(TK_OP_ASSIGN_SUB);
INCPOS(1);
@@ -743,7 +726,6 @@ void GDScriptTokenizerText::_advance() {
}
} break;
case '%': {
-
if (GETCHAR(1) == '=') {
_make_token(TK_OP_ASSIGN_MOD);
INCPOS(1);
@@ -761,9 +743,9 @@ void GDScriptTokenizerText::_advance() {
[[fallthrough]];
case '\'':
case '"': {
-
- if (GETCHAR(0) == '\'')
+ if (GETCHAR(0) == '\'') {
string_mode = STRING_SINGLE_QUOTE;
+ }
int i = 1;
if (string_mode == STRING_DOUBLE_QUOTE && GETCHAR(i) == '"' && GETCHAR(i + 1) == '"') {
@@ -774,7 +756,6 @@ void GDScriptTokenizerText::_advance() {
String str;
while (true) {
if (CharType(GETCHAR(i)) == 0) {
-
_make_error("Unterminated String");
return;
} else if (string_mode == STRING_DOUBLE_QUOTE && CharType(GETCHAR(i)) == '"') {
@@ -802,7 +783,6 @@ void GDScriptTokenizerText::_advance() {
CharType res = 0;
switch (next) {
-
case 'a':
res = '\a';
break;
@@ -869,14 +849,14 @@ void GDScriptTokenizerText::_advance() {
column = 1;
} break;
default: {
-
_make_error("Invalid escape sequence");
return;
} break;
}
- if (next != '\n')
+ if (next != '\n') {
str += res;
+ }
} else {
if (CharType(GETCHAR(i)) == '\n') {
@@ -901,7 +881,6 @@ void GDScriptTokenizerText::_advance() {
_make_token(TK_CURSOR);
} break;
default: {
-
if (_is_number(GETCHAR(0)) || (GETCHAR(0) == '.' && _is_number(GETCHAR(1)))) {
// parse number
bool period_found = false;
@@ -933,7 +912,6 @@ void GDScriptTokenizerText::_advance() {
}
hexa_found = true;
} else if (hexa_found && _is_hex(GETCHAR(i))) {
-
} else if (!hexa_found && GETCHAR(i) == 'b') {
if (bin_found || str.length() != 1 || !((i == 1 && str[0] == '0') || (i == 2 && str[1] == '0' && str[0] == '-'))) {
_make_error("Invalid numeric constant at 'b'");
@@ -950,7 +928,6 @@ void GDScriptTokenizerText::_advance() {
//all ok
} else if (bin_found && _is_bin(GETCHAR(i))) {
-
} else if ((GETCHAR(i) == '-' || GETCHAR(i) == '+') && exponent_found) {
if (sign_found) {
_make_error("Invalid numeric constant at '-'");
@@ -960,8 +937,9 @@ void GDScriptTokenizerText::_advance() {
} else if (GETCHAR(i) == '_') {
i++;
continue; // Included for readability, shouldn't be a part of the string
- } else
+ } else {
break;
+ }
str += CharType(GETCHAR(i));
i++;
@@ -1018,15 +996,12 @@ void GDScriptTokenizerText::_advance() {
} else if (str == "false") {
_make_constant(false);
} else {
-
bool found = false;
{
-
int idx = 0;
while (_type_list[idx].text) {
-
if (str == _type_list[idx].text) {
_make_type(_type_list[idx].type);
found = true;
@@ -1037,13 +1012,10 @@ void GDScriptTokenizerText::_advance() {
}
if (!found) {
-
//built in func?
for (int j = 0; j < GDScriptFunctions::FUNC_MAX; j++) {
-
if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(j))) {
-
_make_built_in_func(GDScriptFunctions::Function(j));
found = true;
break;
@@ -1058,7 +1030,6 @@ void GDScriptTokenizerText::_advance() {
found = false;
while (_keyword_list[idx].text) {
-
if (str == _keyword_list[idx].text) {
_make_token(_keyword_list[idx].token);
found = true;
@@ -1068,8 +1039,9 @@ void GDScriptTokenizerText::_advance() {
}
}
- if (!found)
+ if (!found) {
identifier = true;
+ }
}
if (identifier) {
@@ -1091,7 +1063,6 @@ void GDScriptTokenizerText::_advance() {
}
void GDScriptTokenizerText::set_code(const String &p_code) {
-
code = p_code;
len = p_code.length();
if (len) {
@@ -1108,8 +1079,9 @@ void GDScriptTokenizerText::set_code(const String &p_code) {
ignore_warnings = false;
#endif // DEBUG_ENABLED
last_error = "";
- for (int i = 0; i < MAX_LOOKAHEAD + 1; i++)
+ for (int i = 0; i < MAX_LOOKAHEAD + 1; i++) {
_advance();
+ }
}
GDScriptTokenizerText::Token GDScriptTokenizerText::get_token(int p_offset) const {
@@ -1146,7 +1118,6 @@ const Variant &GDScriptTokenizerText::get_token_constant(int p_offset) const {
}
StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const {
-
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName());
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName());
@@ -1156,7 +1127,6 @@ StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const {
}
GDScriptFunctions::Function GDScriptTokenizerText::get_token_built_in_func(int p_offset) const {
-
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
@@ -1166,7 +1136,6 @@ GDScriptFunctions::Function GDScriptTokenizerText::get_token_built_in_func(int p
}
Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const {
-
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, Variant::NIL);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, Variant::NIL);
@@ -1176,7 +1145,6 @@ Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const {
}
int GDScriptTokenizerText::get_token_line_indent(int p_offset) const {
-
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
@@ -1186,7 +1154,6 @@ int GDScriptTokenizerText::get_token_line_indent(int p_offset) const {
}
int GDScriptTokenizerText::get_token_line_tab_indent(int p_offset) const {
-
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
@@ -1196,7 +1163,6 @@ int GDScriptTokenizerText::get_token_line_tab_indent(int p_offset) const {
}
String GDScriptTokenizerText::get_token_error(int p_offset) const {
-
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, String());
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, String());
@@ -1206,10 +1172,10 @@ String GDScriptTokenizerText::get_token_error(int p_offset) const {
}
void GDScriptTokenizerText::advance(int p_amount) {
-
ERR_FAIL_COND(p_amount <= 0);
- for (int i = 0; i < p_amount; i++)
+ for (int i = 0; i < p_amount; i++) {
_advance();
+ }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1217,7 +1183,6 @@ void GDScriptTokenizerText::advance(int p_amount) {
#define BYTECODE_VERSION 13
Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
-
const uint8_t *buf = p_buffer.ptr();
int total_len = p_buffer.size();
ERR_FAIL_COND_V(p_buffer.size() < 24 || p_buffer[0] != 'G' || p_buffer[1] != 'D' || p_buffer[2] != 'S' || p_buffer[3] != 'C', ERR_INVALID_DATA);
@@ -1235,7 +1200,6 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
identifiers.resize(identifier_count);
for (int i = 0; i < identifier_count; i++) {
-
int len = decode_uint32(b);
ERR_FAIL_COND_V(len > total_len, ERR_INVALID_DATA);
b += 4;
@@ -1255,13 +1219,13 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
constants.resize(constant_count);
for (int i = 0; i < constant_count; i++) {
-
Variant v;
int len;
// An object cannot be constant, never decode objects
Error err = decode_variant(v, b, total_len, &len, false);
- if (err)
+ if (err) {
return err;
+ }
b += len;
total_len -= len;
constants.write[i] = v;
@@ -1270,7 +1234,6 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
ERR_FAIL_COND_V(line_count * 8 > total_len, ERR_INVALID_DATA);
for (int i = 0; i < line_count; i++) {
-
uint32_t token = decode_uint32(b);
b += 4;
uint32_t linecol = decode_uint32(b);
@@ -1283,7 +1246,6 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
tokens.resize(token_count);
for (int i = 0; i < token_count; i++) {
-
ERR_FAIL_COND_V(total_len < 1, ERR_INVALID_DATA);
if ((*b) & TOKEN_BYTE_MASK) { //little endian always
@@ -1304,7 +1266,6 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
}
Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) {
-
Vector<uint8_t> buf;
Map<StringName, int> identifier_map;
@@ -1317,16 +1278,13 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
int line = -1;
while (true) {
-
if (tt.get_token_line() != line) {
-
line = tt.get_token_line();
line_map[line] = token_array.size();
}
uint32_t token = tt.get_token();
switch (tt.get_token()) {
-
case TK_IDENTIFIER: {
StringName id = tt.get_token_identifier();
if (!identifier_map.has(id)) {
@@ -1336,7 +1294,6 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
token |= identifier_map[id] << TOKEN_BITS;
} break;
case TK_CONSTANT: {
-
const Variant &c = tt.get_token_constant();
if (!constant_map.has(c)) {
int idx = constant_map.size();
@@ -1345,20 +1302,16 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
token |= constant_map[c] << TOKEN_BITS;
} break;
case TK_BUILT_IN_TYPE: {
-
token |= tt.get_token_type() << TOKEN_BITS;
} break;
case TK_BUILT_IN_FUNC: {
-
token |= tt.get_token_built_in_func() << TOKEN_BITS;
} break;
case TK_NEWLINE: {
-
token |= tt.get_token_line_indent() << TOKEN_BITS;
} break;
case TK_ERROR: {
-
ERR_FAIL_V(Vector<uint8_t>());
} break;
default: {
@@ -1367,8 +1320,9 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
token_array.push_back(token);
- if (tt.get_token() == TK_EOF)
+ if (tt.get_token() == TK_EOF) {
break;
+ }
tt.advance();
}
@@ -1405,12 +1359,12 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
//save identifiers
for (Map<int, StringName>::Element *E = rev_identifier_map.front(); E; E = E->next()) {
-
CharString cs = String(E->get()).utf8();
int len = cs.length() + 1;
int extra = 4 - (len % 4);
- if (extra == 4)
+ if (extra == 4) {
extra = 0;
+ }
uint8_t ibuf[4];
encode_uint32(len + extra, ibuf);
@@ -1426,7 +1380,6 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
}
for (Map<int, Variant>::Element *E = rev_constant_map.front(); E; E = E->next()) {
-
int len;
// Objects cannot be constant, never encode objects
Error err = encode_variant(E->get(), nullptr, len, false);
@@ -1437,16 +1390,15 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
}
for (Map<int, uint32_t>::Element *E = rev_line_map.front(); E; E = E->next()) {
-
uint8_t ibuf[8];
encode_uint32(E->key(), &ibuf[0]);
encode_uint32(E->get(), &ibuf[4]);
- for (int i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++) {
buf.push_back(ibuf[i]);
+ }
}
for (int i = 0; i < token_array.size(); i++) {
-
uint32_t token = token_array[i];
if (token & ~TOKEN_MASK) {
@@ -1464,17 +1416,16 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
}
GDScriptTokenizerBuffer::Token GDScriptTokenizerBuffer::get_token(int p_offset) const {
-
int offset = token + p_offset;
- if (offset < 0 || offset >= tokens.size())
+ if (offset < 0 || offset >= tokens.size()) {
return TK_EOF;
+ }
return GDScriptTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
}
StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
-
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), StringName());
@@ -1485,14 +1436,12 @@ StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
}
GDScriptFunctions::Function GDScriptTokenizerBuffer::get_token_built_in_func(int p_offset) const {
-
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), GDScriptFunctions::FUNC_MAX);
return GDScriptFunctions::Function(tokens[offset] >> TOKEN_BITS);
}
Variant::Type GDScriptTokenizerBuffer::get_token_type(int p_offset) const {
-
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), Variant::NIL);
@@ -1500,55 +1449,57 @@ Variant::Type GDScriptTokenizerBuffer::get_token_type(int p_offset) const {
}
int GDScriptTokenizerBuffer::get_token_line(int p_offset) const {
-
int offset = token + p_offset;
int pos = lines.find_nearest(offset);
- if (pos < 0)
+ if (pos < 0) {
return -1;
- if (pos >= lines.size())
+ }
+ if (pos >= lines.size()) {
pos = lines.size() - 1;
+ }
uint32_t l = lines.getv(pos);
return l & TOKEN_LINE_MASK;
}
-int GDScriptTokenizerBuffer::get_token_column(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_column(int p_offset) const {
int offset = token + p_offset;
int pos = lines.find_nearest(offset);
- if (pos < 0)
+ if (pos < 0) {
return -1;
- if (pos >= lines.size())
+ }
+ if (pos >= lines.size()) {
pos = lines.size() - 1;
+ }
uint32_t l = lines.getv(pos);
return l >> TOKEN_LINE_BITS;
}
-int GDScriptTokenizerBuffer::get_token_line_indent(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_line_indent(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), 0);
return tokens[offset] >> TOKEN_BITS;
}
-const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const {
+const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), nil);
uint32_t constant = tokens[offset] >> TOKEN_BITS;
ERR_FAIL_UNSIGNED_INDEX_V(constant, (uint32_t)constants.size(), nil);
return constants[constant];
}
-String GDScriptTokenizerBuffer::get_token_error(int p_offset) const {
+String GDScriptTokenizerBuffer::get_token_error(int p_offset) const {
ERR_FAIL_V(String());
}
void GDScriptTokenizerBuffer::advance(int p_amount) {
-
ERR_FAIL_INDEX(p_amount + token, tokens.size());
token += p_amount;
}
-GDScriptTokenizerBuffer::GDScriptTokenizerBuffer() {
+GDScriptTokenizerBuffer::GDScriptTokenizerBuffer() {
token = 0;
}
diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h
index 180ec3c77e..32603c010f 100644
--- a/modules/gdscript/gdscript_tokenizer.h
+++ b/modules/gdscript/gdscript_tokenizer.h
@@ -176,11 +176,10 @@ public:
virtual bool is_ignoring_warnings() const = 0;
#endif // DEBUG_ENABLED
- virtual ~GDScriptTokenizer(){};
+ virtual ~GDScriptTokenizer() {}
};
class GDScriptTokenizerText : public GDScriptTokenizer {
-
enum {
MAX_LOOKAHEAD = 4,
TK_RB_SIZE = MAX_LOOKAHEAD * 2 + 1
@@ -252,7 +251,6 @@ public:
};
class GDScriptTokenizerBuffer : public GDScriptTokenizer {
-
enum {
TOKEN_BYTE_MASK = 0x80,
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp
index a6b749059a..330530be80 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp
+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp
@@ -29,13 +29,13 @@
/*************************************************************************/
#include "gdscript_extend_parser.h"
+
#include "../gdscript.h"
#include "core/io/json.h"
#include "gdscript_language_protocol.h"
#include "gdscript_workspace.h"
void ExtendGDScriptParser::update_diagnostics() {
-
diagnostics.clear();
if (has_error()) {
@@ -80,12 +80,10 @@ void ExtendGDScriptParser::update_diagnostics() {
}
void ExtendGDScriptParser::update_symbols() {
-
members.clear();
const GDScriptParser::Node *head = get_parse_tree();
if (const GDScriptParser::ClassNode *gdclass = dynamic_cast<const GDScriptParser::ClassNode *>(head)) {
-
parse_class_symbol(gdclass, class_symbol);
for (int i = 0; i < class_symbol.children.size(); i++) {
@@ -141,15 +139,15 @@ void ExtendGDScriptParser::update_document_links(const String &p_code) {
}
void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p_class, lsp::DocumentSymbol &r_symbol) {
-
const String uri = get_uri();
r_symbol.uri = uri;
r_symbol.script_path = path;
r_symbol.children.clear();
r_symbol.name = p_class->name;
- if (r_symbol.name.empty())
+ if (r_symbol.name.empty()) {
r_symbol.name = path.get_file();
+ }
r_symbol.kind = lsp::SymbolKind::Class;
r_symbol.deprecated = false;
r_symbol.range.start.line = LINE_NUMBER_TO_INDEX(p_class->line);
@@ -161,7 +159,6 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
r_symbol.documentation = parse_documentation(is_root_class ? 0 : LINE_NUMBER_TO_INDEX(p_class->line), is_root_class);
for (int i = 0; i < p_class->variables.size(); ++i) {
-
const GDScriptParser::ClassNode::Member &m = p_class->variables[i];
lsp::DocumentSymbol symbol;
@@ -289,7 +286,6 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
}
void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionNode *p_func, lsp::DocumentSymbol &r_symbol) {
-
const String uri = get_uri();
r_symbol.name = p_func->name;
@@ -384,9 +380,9 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
int step = p_docs_down ? 1 : -1;
int start_line = p_docs_down ? p_line : p_line - 1;
for (int i = start_line; true; i += step) {
-
- if (i < 0 || i >= lines.size())
+ if (i < 0 || i >= lines.size()) {
break;
+ }
String line_comment = lines[i].strip_edges(true, false);
if (line_comment.begins_with("#")) {
@@ -409,22 +405,20 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
}
String ExtendGDScriptParser::get_text_for_completion(const lsp::Position &p_cursor) const {
-
String longthing;
int len = lines.size();
for (int i = 0; i < len; i++) {
-
if (i == p_cursor.line) {
longthing += lines[i].substr(0, p_cursor.character);
longthing += String::chr(0xFFFF); //not unicode, represents the cursor
longthing += lines[i].substr(p_cursor.character, lines[i].size());
} else {
-
longthing += lines[i];
}
- if (i != len - 1)
+ if (i != len - 1) {
longthing += "\n";
+ }
}
return longthing;
@@ -434,7 +428,6 @@ String ExtendGDScriptParser::get_text_for_lookup_symbol(const lsp::Position &p_c
String longthing;
int len = lines.size();
for (int i = 0; i < len; i++) {
-
if (i == p_cursor.line) {
String line = lines[i];
String first_part = line.substr(0, p_cursor.character);
@@ -458,19 +451,18 @@ String ExtendGDScriptParser::get_text_for_lookup_symbol(const lsp::Position &p_c
}
longthing += last_part;
} else {
-
longthing += lines[i];
}
- if (i != len - 1)
+ if (i != len - 1) {
longthing += "\n";
+ }
}
return longthing;
}
String ExtendGDScriptParser::get_identifier_under_position(const lsp::Position &p_position, Vector2i &p_offset) const {
-
ERR_FAIL_INDEX_V(p_position.line, lines.size(), "");
String line = lines[p_position.line];
ERR_FAIL_INDEX_V(p_position.character, line.size(), "");
@@ -525,7 +517,6 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(i
}
Error ExtendGDScriptParser::get_left_function_call(const lsp::Position &p_position, lsp::Position &r_func_pos, int &r_arg_index) const {
-
ERR_FAIL_INDEX_V(p_position.line, lines.size(), ERR_INVALID_PARAMETER);
int bracket_stack = 0;
@@ -577,7 +568,6 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int
}
const lsp::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String &p_name, const String &p_subclass) const {
-
if (p_subclass.empty()) {
const lsp::DocumentSymbol *const *ptr = members.getptr(p_name);
if (ptr) {
@@ -600,12 +590,9 @@ const List<lsp::DocumentLink> &ExtendGDScriptParser::get_document_links() const
}
const Array &ExtendGDScriptParser::get_member_completions() {
-
if (member_completions.empty()) {
-
const String *name = members.next(nullptr);
while (name) {
-
const lsp::DocumentSymbol *symbol = members.get(*name);
lsp::CompletionItem item = symbol->make_completion_item();
item.data = JOIN_SYMBOLS(path, *name);
@@ -616,7 +603,6 @@ const Array &ExtendGDScriptParser::get_member_completions() {
const String *_class = inner_classes.next(nullptr);
while (_class) {
-
const ClassMembers *inner_class = inner_classes.getptr(*_class);
const String *member_name = inner_class->next(nullptr);
while (member_name) {
@@ -697,7 +683,6 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
Array constants;
for (Map<StringName, GDScriptParser::ClassNode::Constant>::Element *E = p_class->constant_expressions.front(); E; E = E->next()) {
-
const GDScriptParser::ClassNode::Constant &c = E->value();
const GDScriptParser::ConstantNode *node = dynamic_cast<const GDScriptParser::ConstantNode *>(c.expression);
ERR_FAIL_COND_V(!node, class_api);
@@ -766,7 +751,6 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
}
Dictionary ExtendGDScriptParser::generate_api() const {
-
Dictionary api;
const GDScriptParser::Node *head = get_parse_tree();
if (const GDScriptParser::ClassNode *gdclass = dynamic_cast<const GDScriptParser::ClassNode *>(head)) {
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.h b/modules/gdscript/language_server/gdscript_extend_parser.h
index 43dfce994b..0c031d7883 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.h
+++ b/modules/gdscript/language_server/gdscript_extend_parser.h
@@ -50,7 +50,6 @@
typedef HashMap<String, const lsp::DocumentSymbol *> ClassMembers;
class ExtendGDScriptParser : public GDScriptParser {
-
String path;
Vector<String> lines;
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index 69662e96f7..2a67d2ff4f 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "gdscript_language_protocol.h"
+
#include "core/io/json.h"
#include "core/os/copymem.h"
#include "core/project_settings.h"
@@ -47,10 +48,11 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
ERR_FAIL_COND_V_MSG(true, ERR_OUT_OF_MEMORY, "Response header too big");
}
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
- if (err != OK)
+ if (err != OK) {
return FAILED;
- else if (read != 1) // Busy, wait until next poll
+ } else if (read != 1) { // Busy, wait until next poll
return ERR_BUSY;
+ }
char *r = (char *)req_buf;
int l = req_pos;
@@ -75,10 +77,11 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
ERR_FAIL_COND_V_MSG(req_pos >= LSP_MAX_BUFFER_SIZE, ERR_OUT_OF_MEMORY, "Response content too big");
}
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
- if (err != OK)
+ if (err != OK) {
return FAILED;
- else if (read != 1)
+ } else if (read != 1) {
return ERR_BUSY;
+ }
req_pos++;
}
@@ -145,7 +148,6 @@ String GDScriptLanguageProtocol::process_message(const String &p_text) {
}
String GDScriptLanguageProtocol::format_output(const String &p_text) {
-
String header = "Content-Length: ";
CharString charstr = p_text.utf8();
size_t len = charstr.length();
@@ -160,7 +162,7 @@ void GDScriptLanguageProtocol::_bind_methods() {
ClassDB::bind_method(D_METHOD("initialized", "params"), &GDScriptLanguageProtocol::initialized);
ClassDB::bind_method(D_METHOD("on_client_connected"), &GDScriptLanguageProtocol::on_client_connected);
ClassDB::bind_method(D_METHOD("on_client_disconnected"), &GDScriptLanguageProtocol::on_client_disconnected);
- ClassDB::bind_method(D_METHOD("notify_client", "p_method", "p_params"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("notify_client", "method", "params"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("is_smart_resolve_enabled"), &GDScriptLanguageProtocol::is_smart_resolve_enabled);
ClassDB::bind_method(D_METHOD("get_text_document"), &GDScriptLanguageProtocol::get_text_document);
ClassDB::bind_method(D_METHOD("get_workspace"), &GDScriptLanguageProtocol::get_workspace);
@@ -168,7 +170,6 @@ void GDScriptLanguageProtocol::_bind_methods() {
}
Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
-
lsp::InitializeResult ret;
String root_uri = p_params["rootUri"];
@@ -183,13 +184,14 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
if (root_uri.length() && is_same_workspace) {
workspace->root_uri = root_uri;
} else {
-
workspace->root_uri = "file://" + workspace->root;
Dictionary params;
params["path"] = workspace->root;
- Dictionary request = make_notification("gdscrip_client/changeWorkspace", params);
+ Dictionary request = make_notification("gdscript_client/changeWorkspace", params);
+ ERR_FAIL_COND_V_MSG(!clients.has(latest_client_id), ret.to_json(),
+ vformat("GDScriptLanguageProtocol: Can't initialize invalid peer '%d'.", latest_client_id));
Ref<LSPeer> peer = clients.get(latest_client_id);
if (peer != nullptr) {
String msg = JSON::print(request);
@@ -208,12 +210,10 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
}
void GDScriptLanguageProtocol::initialized(const Variant &p_params) {
-
lsp::GodotCapabilities capabilities;
DocData *doc = EditorHelp::get_doc_data();
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
-
lsp::GodotNativeClassInfo gdclass;
gdclass.name = E->get().name;
gdclass.class_doc = &(E->get());
@@ -271,8 +271,11 @@ void GDScriptLanguageProtocol::stop() {
void GDScriptLanguageProtocol::notify_client(const String &p_method, const Variant &p_params, int p_client_id) {
if (p_client_id == -1) {
+ ERR_FAIL_COND_MSG(latest_client_id == -1,
+ "GDScript LSP: Can't notify client as none was connected.");
p_client_id = latest_client_id;
}
+ ERR_FAIL_COND(!clients.has(p_client_id));
Ref<LSPeer> peer = clients.get(p_client_id);
ERR_FAIL_COND(peer == nullptr);
@@ -293,13 +296,10 @@ bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
server.instance();
singleton = this;
- _initialized = false;
workspace.instance();
text_document.instance();
set_scope("textDocument", text_document.ptr());
set_scope("completionItem", text_document.ptr());
set_scope("workspace", workspace.ptr());
workspace->root = ProjectSettings::get_singleton()->get_resource_path();
- latest_client_id = 0;
- next_client_id = 0;
}
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h
index d929fd255d..cf5242e8c5 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.h
+++ b/modules/gdscript/language_server/gdscript_language_protocol.h
@@ -70,8 +70,8 @@ private:
HashMap<int, Ref<LSPeer>> clients;
Ref<TCP_Server> server;
- int latest_client_id;
- int next_client_id;
+ int latest_client_id = 0;
+ int next_client_id = 0;
Ref<GDScriptTextDocument> text_document;
Ref<GDScriptWorkspace> workspace;
@@ -82,7 +82,7 @@ private:
String process_message(const String &p_text);
String format_output(const String &p_text);
- bool _initialized;
+ bool _initialized = false;
protected:
static void _bind_methods();
diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp
index e1d86ecdd4..3387d262f8 100644
--- a/modules/gdscript/language_server/gdscript_language_server.cpp
+++ b/modules/gdscript/language_server/gdscript_language_server.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "gdscript_language_server.h"
+
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "editor/editor_log.h"
@@ -48,7 +49,6 @@ GDScriptLanguageServer::GDScriptLanguageServer() {
}
void GDScriptLanguageServer::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
start();
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index f065b33570..c6fe3169dc 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "gdscript_text_document.h"
+
#include "../gdscript.h"
#include "core/os/os.h"
#include "editor/editor_settings.h"
@@ -85,19 +86,15 @@ void GDScriptTextDocument::notify_client_show_symbol(const lsp::DocumentSymbol *
}
void GDScriptTextDocument::initialize() {
-
if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
-
const HashMap<StringName, ClassMembers> &native_members = GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members;
const StringName *class_ptr = native_members.next(nullptr);
while (class_ptr) {
-
const ClassMembers &members = native_members.get(*class_ptr);
const String *name = members.next(nullptr);
while (name) {
-
const lsp::DocumentSymbol *symbol = members.get(*name);
lsp::CompletionItem item = symbol->make_completion_item();
item.data = JOIN_SYMBOLS(String(*class_ptr), *name);
@@ -112,7 +109,6 @@ void GDScriptTextDocument::initialize() {
}
Variant GDScriptTextDocument::nativeSymbol(const Dictionary &p_params) {
-
Variant ret;
lsp::NativeSymbolInspectParams params;
@@ -142,7 +138,6 @@ Array GDScriptTextDocument::documentSymbol(const Dictionary &p_params) {
}
Array GDScriptTextDocument::completion(const Dictionary &p_params) {
-
Array arr;
lsp::CompletionParams params;
@@ -153,12 +148,10 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
GDScriptLanguageProtocol::get_singleton()->get_workspace()->completion(params, &options);
if (!options.empty()) {
-
int i = 0;
arr.resize(options.size());
for (const List<ScriptCodeCompletionOption>::Element *E = options.front(); E; E = E->next()) {
-
const ScriptCodeCompletionOption &option = E->get();
lsp::CompletionItem item;
item.label = option.display;
@@ -201,11 +194,9 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
i++;
}
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
-
arr = native_member_completions.duplicate();
for (Map<String, ExtendGDScriptParser *>::Element *E = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.front(); E; E = E->next()) {
-
ExtendGDScriptParser *script = E->get();
const Array &items = script->get_member_completions();
@@ -220,7 +211,6 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
}
Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
-
lsp::CompletionItem item;
item.load(p_params);
@@ -230,18 +220,15 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
const lsp::DocumentSymbol *symbol = nullptr;
if (data.get_type() == Variant::DICTIONARY) {
-
params.load(p_params["data"]);
symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(params, item.label, item.kind == lsp::CompletionItemKind::Method || item.kind == lsp::CompletionItemKind::Function);
} else if (data.get_type() == Variant::STRING) {
-
String query = data;
Vector<String> param_symbols = query.split(SYMBOL_SEPERATOR, false);
if (param_symbols.size() >= 2) {
-
String class_ = param_symbols[0];
StringName class_name = class_;
String member_name = param_symbols[param_symbols.size() - 1];
@@ -313,13 +300,11 @@ Array GDScriptTextDocument::colorPresentation(const Dictionary &p_params) {
}
Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
-
lsp::TextDocumentPositionParams params;
params.load(p_params);
const lsp::DocumentSymbol *symbol = GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_symbol(params);
if (symbol) {
-
lsp::Hover hover;
hover.contents = symbol->render();
hover.range.start = params.position;
@@ -327,7 +312,6 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
return hover.to_json();
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
-
Dictionary ret;
Array contents;
List<const lsp::DocumentSymbol *> list;
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index be036b44c4..a203b9bfdb 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "gdscript_workspace.h"
+
#include "../gdscript.h"
#include "../gdscript_parser.h"
#include "core/project_settings.h"
@@ -41,12 +42,12 @@
void GDScriptWorkspace::_bind_methods() {
ClassDB::bind_method(D_METHOD("symbol"), &GDScriptWorkspace::symbol);
- ClassDB::bind_method(D_METHOD("parse_script", "p_path", "p_content"), &GDScriptWorkspace::parse_script);
- ClassDB::bind_method(D_METHOD("parse_local_script", "p_path"), &GDScriptWorkspace::parse_local_script);
- ClassDB::bind_method(D_METHOD("get_file_path", "p_uri"), &GDScriptWorkspace::get_file_path);
- ClassDB::bind_method(D_METHOD("get_file_uri", "p_path"), &GDScriptWorkspace::get_file_uri);
- ClassDB::bind_method(D_METHOD("publish_diagnostics", "p_path"), &GDScriptWorkspace::publish_diagnostics);
- ClassDB::bind_method(D_METHOD("generate_script_api", "p_path"), &GDScriptWorkspace::generate_script_api);
+ ClassDB::bind_method(D_METHOD("parse_script", "path", "content"), &GDScriptWorkspace::parse_script);
+ ClassDB::bind_method(D_METHOD("parse_local_script", "path"), &GDScriptWorkspace::parse_local_script);
+ ClassDB::bind_method(D_METHOD("get_file_path", "uri"), &GDScriptWorkspace::get_file_path);
+ ClassDB::bind_method(D_METHOD("get_file_uri", "path"), &GDScriptWorkspace::get_file_uri);
+ ClassDB::bind_method(D_METHOD("publish_diagnostics", "path"), &GDScriptWorkspace::publish_diagnostics);
+ ClassDB::bind_method(D_METHOD("generate_script_api", "path"), &GDScriptWorkspace::generate_script_api);
}
void GDScriptWorkspace::remove_cache_parser(const String &p_path) {
@@ -71,7 +72,6 @@ void GDScriptWorkspace::remove_cache_parser(const String &p_path) {
}
const lsp::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_class, const String &p_member) const {
-
StringName class_name = p_class;
StringName empty;
@@ -185,12 +185,12 @@ Array GDScriptWorkspace::symbol(const Dictionary &p_params) {
}
Error GDScriptWorkspace::initialize() {
- if (initialized)
+ if (initialized) {
return OK;
+ }
DocData *doc = EditorHelp::get_doc_data();
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
-
const DocData::ClassDoc &class_data = E->value();
lsp::DocumentSymbol class_symbol;
String class_name = E->key();
@@ -315,14 +315,12 @@ Error GDScriptWorkspace::initialize() {
}
Error GDScriptWorkspace::parse_script(const String &p_path, const String &p_content) {
-
ExtendGDScriptParser *parser = memnew(ExtendGDScriptParser);
Error err = parser->parse(p_content, p_path);
Map<String, ExtendGDScriptParser *>::Element *last_parser = parse_results.find(p_path);
Map<String, ExtendGDScriptParser *>::Element *last_script = scripts.find(p_path);
if (err == OK) {
-
remove_cache_parser(p_path);
parse_results[p_path] = parser;
scripts[p_path] = parser;
@@ -378,15 +376,15 @@ void GDScriptWorkspace::publish_diagnostics(const String &p_path) {
}
void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners) {
- if (!efsd)
+ if (!efsd) {
return;
+ }
for (int i = 0; i < efsd->get_subdir_count(); i++) {
_get_owners(efsd->get_subdir(i), p_path, owners);
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
Vector<String> deps = efsd->get_file_deps(i);
bool found = false;
for (int j = 0; j < deps.size(); j++) {
@@ -395,8 +393,9 @@ void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_pa
break;
}
}
- if (!found)
+ if (!found) {
continue;
+ }
owners.push_back(efsd->get_file_path(i));
}
@@ -422,7 +421,6 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
}
void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) {
-
String path = get_file_path(p_params.textDocument.uri);
String call_hint;
bool forced = false;
@@ -438,12 +436,10 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
}
const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_requred) {
-
const lsp::DocumentSymbol *symbol = nullptr;
String path = get_file_path(p_doc_pos.textDocument.uri);
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
-
String symbol_identifier = p_symbol_name;
Vector<String> identifier_parts = symbol_identifier.split("(");
if (identifier_parts.size()) {
@@ -458,19 +454,14 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
}
if (!symbol_identifier.empty()) {
-
if (ScriptServer::is_global_class(symbol_identifier)) {
-
String class_path = ScriptServer::get_global_class_path(symbol_identifier);
symbol = get_script_symbol(class_path);
} else {
-
ScriptLanguage::LookupResult ret;
if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_requred), symbol_identifier, path, nullptr, ret)) {
-
if (ret.type == ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION) {
-
String target_script_path = path;
if (!ret.script.is_null()) {
target_script_path = ret.script->get_path();
@@ -481,7 +472,6 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
}
} else {
-
String member = ret.class_member;
if (member.empty() && symbol_identifier != ret.class_name) {
member = symbol_identifier;
@@ -499,10 +489,8 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
}
void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list) {
-
String path = get_file_path(p_doc_pos.textDocument.uri);
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
-
String symbol_identifier;
Vector2i offset;
symbol_identifier = parser->get_identifier_under_position(p_doc_pos.position, offset);
@@ -526,7 +514,6 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
const HashMap<String, ClassMembers> &inner_classes = script->get_inner_classes();
const String *_class = inner_classes.next(nullptr);
while (_class) {
-
const ClassMembers *inner_class = inner_classes.getptr(*_class);
if (const lsp::DocumentSymbol *const *symbol = inner_class->getptr(symbol_identifier)) {
r_list.push_back(*symbol);
@@ -539,7 +526,6 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
}
const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params) {
-
if (Map<StringName, lsp::DocumentSymbol>::Element *E = native_symbols.find(p_params.native_class)) {
const lsp::DocumentSymbol &symbol = E->get();
if (p_params.symbol_name.empty() || p_params.symbol_name == symbol.name) {
@@ -575,12 +561,10 @@ Dictionary GDScriptWorkspace::generate_script_api(const String &p_path) {
Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::SignatureHelp &r_signature) {
if (const ExtendGDScriptParser *parser = get_parse_result(get_file_path(p_doc_pos.textDocument.uri))) {
-
lsp::TextDocumentPositionParams text_pos;
text_pos.textDocument = p_doc_pos.textDocument;
if (parser->get_left_function_call(p_doc_pos.position, text_pos.position, r_signature.activeParameter) == OK) {
-
List<const lsp::DocumentSymbol *> symbols;
if (const lsp::DocumentSymbol *symbol = resolve_symbol(text_pos)) {
@@ -592,7 +576,6 @@ Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams
for (List<const lsp::DocumentSymbol *>::Element *E = symbols.front(); E; E = E->next()) {
const lsp::DocumentSymbol *symbol = E->get();
if (symbol->kind == lsp::SymbolKind::Method || symbol->kind == lsp::SymbolKind::Function) {
-
lsp::SignatureInformation signature_info;
signature_info.label = symbol->detail;
signature_info.documentation = symbol->render();
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index e469a26df8..cf27a1578c 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -149,7 +149,6 @@ struct Location {
* Represents a link between a source and a target location.
*/
struct LocationLink {
-
/**
* Span of the origin of this link.
*
@@ -220,7 +219,6 @@ struct DocumentLinkParams {
* text document or a web site.
*/
struct DocumentLink {
-
/**
* The range this link applies to.
*/
@@ -282,8 +280,9 @@ struct Command {
Dictionary dict;
dict["title"] = title;
dict["command"] = command;
- if (arguments.size())
+ if (arguments.size()) {
dict["arguments"] = arguments;
+ }
return dict;
}
};
@@ -487,7 +486,7 @@ struct TextDocumentSyncOptions {
* If present save notifications are sent to the server. If omitted the notification should not be
* sent.
*/
- SaveOptions save;
+ bool save = false;
Dictionary to_json() {
Dictionary dict;
@@ -495,7 +494,7 @@ struct TextDocumentSyncOptions {
dict["willSave"] = willSave;
dict["openClose"] = openClose;
dict["change"] = change;
- dict["save"] = save.to_json();
+ dict["save"] = save;
return dict;
}
};
@@ -947,20 +946,24 @@ struct CompletionItem {
dict["preselect"] = preselect;
dict["sortText"] = sortText;
dict["filterText"] = filterText;
- if (commitCharacters.size())
+ if (commitCharacters.size()) {
dict["commitCharacters"] = commitCharacters;
+ }
dict["command"] = command.to_json();
}
return dict;
}
void load(const Dictionary &p_dict) {
- if (p_dict.has("label"))
+ if (p_dict.has("label")) {
label = p_dict["label"];
- if (p_dict.has("kind"))
+ }
+ if (p_dict.has("kind")) {
kind = p_dict["kind"];
- if (p_dict.has("detail"))
+ }
+ if (p_dict.has("detail")) {
detail = p_dict["detail"];
+ }
if (p_dict.has("documentation")) {
Variant doc = p_dict["documentation"];
if (doc.get_type() == Variant::STRING) {
@@ -970,18 +973,24 @@ struct CompletionItem {
documentation.value = v["value"];
}
}
- if (p_dict.has("deprecated"))
+ if (p_dict.has("deprecated")) {
deprecated = p_dict["deprecated"];
- if (p_dict.has("preselect"))
+ }
+ if (p_dict.has("preselect")) {
preselect = p_dict["preselect"];
- if (p_dict.has("sortText"))
+ }
+ if (p_dict.has("sortText")) {
sortText = p_dict["sortText"];
- if (p_dict.has("filterText"))
+ }
+ if (p_dict.has("filterText")) {
filterText = p_dict["filterText"];
- if (p_dict.has("insertText"))
+ }
+ if (p_dict.has("insertText")) {
insertText = p_dict["insertText"];
- if (p_dict.has("data"))
+ }
+ if (p_dict.has("data")) {
data = p_dict["data"];
+ }
}
};
@@ -1107,7 +1116,6 @@ struct DocumentedSymbolInformation : public SymbolInformation {
* e.g. the range of an identifier.
*/
struct DocumentSymbol {
-
/**
* The name of this symbol. Will be displayed in the user interface and therefore must not be
* an empty string or a string only consisting of white spaces.
@@ -1216,7 +1224,6 @@ struct DocumentSymbol {
}
_FORCE_INLINE_ CompletionItem make_completion_item(bool resolved = false) const {
-
lsp::CompletionItem item;
item.label = name;
@@ -1260,7 +1267,6 @@ struct DocumentSymbol {
};
struct NativeSymbolInspectParams {
-
String native_class;
String symbol_name;
@@ -1292,7 +1298,6 @@ static const String Region = "region";
* Represents a folding range.
*/
struct FoldingRange {
-
/**
* The zero-based line number from where the folded range starts.
*/
@@ -1375,7 +1380,6 @@ struct CompletionContext {
};
struct CompletionParams : public TextDocumentPositionParams {
-
/**
* The completion context. This is only available if the client specifies
* to send this using `ClientCapabilities.textDocument.completion.contextSupport === true`
@@ -1416,7 +1420,6 @@ struct Hover {
* have a label and a doc-comment.
*/
struct ParameterInformation {
-
/**
* The label of this parameter information.
*
@@ -1653,7 +1656,7 @@ struct ServerCapabilities {
_FORCE_INLINE_ Dictionary to_json() {
Dictionary dict;
- dict["textDocumentSync"] = (int)textDocumentSync.change;
+ dict["textDocumentSync"] = textDocumentSync.to_json();
dict["completionProvider"] = completionProvider.to_json();
signatureHelpProvider.triggerCharacters.push_back(",");
signatureHelpProvider.triggerCharacters.push_back("(");
@@ -1695,7 +1698,6 @@ struct InitializeResult {
};
struct GodotNativeClassInfo {
-
String name;
const DocData::ClassDoc *class_doc = nullptr;
const ClassDB::ClassInfo *class_info = nullptr;
@@ -1710,7 +1712,6 @@ struct GodotNativeClassInfo {
/** Features not included in the standard lsp specifications */
struct GodotCapabilities {
-
/**
* Native class list
*/
@@ -1729,7 +1730,6 @@ struct GodotCapabilities {
/** Format BBCode documentation from DocData to markdown */
static String marked_documentation(const String &p_bbcode) {
-
String markdown = p_bbcode.strip_edges();
Vector<String> lines = markdown.split("\n");
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 62b9d94d6c..0625123530 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -54,12 +54,10 @@ Ref<ResourceFormatSaverGDScript> resource_saver_gd;
#endif // !GDSCRIPT_NO_LSP
class EditorExportGDScript : public EditorExportPlugin {
-
GDCLASS(EditorExportGDScript, EditorExportPlugin);
public:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
-
int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED;
String script_key;
@@ -70,21 +68,21 @@ public:
script_key = preset->get_script_encryption_key().to_lower();
}
- if (!p_path.ends_with(".gd") || script_mode == EditorExportPreset::MODE_SCRIPT_TEXT)
+ if (!p_path.ends_with(".gd") || script_mode == EditorExportPreset::MODE_SCRIPT_TEXT) {
return;
+ }
Vector<uint8_t> file = FileAccess::get_file_as_array(p_path);
- if (file.empty())
+ if (file.empty()) {
return;
+ }
String txt;
txt.parse_utf8((const char *)file.ptr(), file.size());
file = GDScriptTokenizerBuffer::parse_code_string(txt);
if (!file.empty()) {
-
if (script_mode == EditorExportPreset::MODE_SCRIPT_ENCRYPTED) {
-
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("script.gde");
FileAccess *fa = FileAccess::open(tmp_path, FileAccess::WRITE);
@@ -94,19 +92,21 @@ public:
int v = 0;
if (i * 2 < script_key.length()) {
CharType ct = script_key[i * 2];
- if (ct >= '0' && ct <= '9')
+ if (ct >= '0' && ct <= '9') {
ct = ct - '0';
- else if (ct >= 'a' && ct <= 'f')
+ } else if (ct >= 'a' && ct <= 'f') {
ct = 10 + ct - 'a';
+ }
v |= ct << 4;
}
if (i * 2 + 1 < script_key.length()) {
CharType ct = script_key[i * 2 + 1];
- if (ct >= '0' && ct <= '9')
+ if (ct >= '0' && ct <= '9') {
ct = ct - '0';
- else if (ct >= 'a' && ct <= 'f')
+ } else if (ct >= 'a' && ct <= 'f') {
ct = 10 + ct - 'a';
+ }
v |= ct;
}
key.write[i] = v;
@@ -127,7 +127,6 @@ public:
DirAccess::remove_file_or_error(tmp_path);
} else {
-
add_file(p_path.get_basename() + ".gdc", file, true);
}
}
@@ -135,7 +134,6 @@ public:
};
static void _editor_init() {
-
Ref<EditorExportGDScript> gd_export;
gd_export.instance();
EditorExport::get_singleton()->add_export_plugin(gd_export);
@@ -151,7 +149,6 @@ static void _editor_init() {
#endif // TOOLS_ENABLED
void register_gdscript_types() {
-
ClassDB::register_class<GDScript>();
ClassDB::register_virtual_class<GDScriptFunctionState>();
@@ -171,11 +168,11 @@ void register_gdscript_types() {
}
void unregister_gdscript_types() {
-
ScriptServer::unregister_language(script_language_gd);
- if (script_language_gd)
+ if (script_language_gd) {
memdelete(script_language_gd);
+ }
ResourceLoader::remove_resource_format_loader(resource_loader_gd);
resource_loader_gd.unref();
diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp
index 2540ba476c..dd28c4ad4a 100644
--- a/modules/glslang/register_types.cpp
+++ b/modules/glslang/register_types.cpp
@@ -130,20 +130,19 @@ static const TBuiltInResource default_builtin_resource = {
/*maxTaskWorkGroupSizeZ_NV*/ 0,
/*maxMeshViewCountNV*/ 0,
/*limits*/ {
- /*nonInductiveForLoops*/ 1,
- /*whileLoops*/ 1,
- /*doWhileLoops*/ 1,
- /*generalUniformIndexing*/ 1,
- /*generalAttributeMatrixVectorIndexing*/ 1,
- /*generalVaryingIndexing*/ 1,
- /*generalSamplerIndexing*/ 1,
- /*generalVariableIndexing*/ 1,
- /*generalConstantMatrixVectorIndexing*/ 1,
+ /*nonInductiveForLoops*/ true,
+ /*whileLoops*/ true,
+ /*doWhileLoops*/ true,
+ /*generalUniformIndexing*/ true,
+ /*generalAttributeMatrixVectorIndexing*/ true,
+ /*generalVaryingIndexing*/ true,
+ /*generalSamplerIndexing*/ true,
+ /*generalVariableIndexing*/ true,
+ /*generalConstantMatrixVectorIndexing*/ true,
}
};
static Vector<uint8_t> _compile_shader_glsl(RenderingDevice::ShaderStage p_stage, const String &p_source_code, RenderingDevice::ShaderLanguage p_language, String *r_error) {
-
Vector<uint8_t> ret;
ERR_FAIL_COND_V(p_language == RenderingDevice::SHADER_LANGUAGE_HLSL, ret);
@@ -177,7 +176,6 @@ static Vector<uint8_t> _compile_shader_glsl(RenderingDevice::ShaderStage p_stage
//preprocess
if (!shader.preprocess(&default_builtin_resource, DefaultVersion, ENoProfile, false, false, messages, &pre_processed_code, includer)) {
-
if (r_error) {
(*r_error) = "Failed pre-process:\n";
(*r_error) += shader.getInfoLog();
@@ -240,7 +238,7 @@ void preregister_glslang_types() {
void register_glslang_types() {
}
-void unregister_glslang_types() {
+void unregister_glslang_types() {
glslang::FinalizeProcess();
}
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 0dbefbb39f..2975a97bfe 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -40,22 +40,18 @@
#include "servers/rendering_server.h"
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name == "data") {
-
Dictionary d = p_value;
if (d.has("cells")) {
-
Vector<int> cells = d["cells"];
int amount = cells.size();
const int *r = cells.ptr();
ERR_FAIL_COND_V(amount % 3, false); // not even
cell_map.clear();
for (int i = 0; i < amount / 3; i++) {
-
IndexKey ik;
ik.key = decode_uint64((const uint8_t *)&r[i * 3]);
Cell cell;
@@ -67,7 +63,6 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
_recreate_octant_data();
} else if (name == "baked_meshes") {
-
clear_baked_meshes();
Array meshes = p_value;
@@ -96,11 +91,9 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
}
bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name == "data") {
-
Dictionary d;
Vector<int> cells;
@@ -109,7 +102,6 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
int *w = cells.ptrw();
int i = 0;
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next(), i++) {
-
encode_uint64(E->key().key, (uint8_t *)&w[i * 3]);
encode_uint32(E->get().cell, (uint8_t *)&w[i * 3 + 2]);
}
@@ -119,7 +111,6 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = d;
} else if (name == "baked_meshes") {
-
Array ret;
ret.resize(baked_meshes.size());
for (int i = 0; i < baked_meshes.size(); i++) {
@@ -127,14 +118,14 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
}
r_ret = ret;
- } else
+ } else {
return false;
+ }
return true;
}
void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
-
if (baked_meshes.size()) {
p_list->push_back(PropertyInfo(Variant::ARRAY, "baked_meshes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
}
@@ -143,71 +134,65 @@ void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
}
void GridMap::set_collision_layer(uint32_t p_layer) {
-
collision_layer = p_layer;
_reset_physic_bodies_collision_filters();
}
uint32_t GridMap::get_collision_layer() const {
-
return collision_layer;
}
void GridMap::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
_reset_physic_bodies_collision_filters();
}
uint32_t GridMap::get_collision_mask() const {
-
return collision_mask;
}
void GridMap::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool GridMap::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
void GridMap::set_collision_layer_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_layer();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_layer(mask);
}
bool GridMap::get_collision_layer_bit(int p_bit) const {
-
return get_collision_layer() & (1 << p_bit);
}
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
-
- if (!mesh_library.is_null())
+ if (!mesh_library.is_null()) {
mesh_library->unregister_owner(this);
+ }
mesh_library = p_mesh_library;
- if (!mesh_library.is_null())
+ if (!mesh_library.is_null()) {
mesh_library->register_owner(this);
+ }
_recreate_octant_data();
_change_notify("mesh_library");
}
Ref<MeshLibrary> GridMap::get_mesh_library() const {
-
return mesh_library;
}
@@ -217,24 +202,22 @@ void GridMap::set_cell_size(const Vector3 &p_size) {
_recreate_octant_data();
emit_signal("cell_size_changed", cell_size);
}
-Vector3 GridMap::get_cell_size() const {
+Vector3 GridMap::get_cell_size() const {
return cell_size;
}
void GridMap::set_octant_size(int p_size) {
-
ERR_FAIL_COND(p_size == 0);
octant_size = p_size;
_recreate_octant_data();
}
-int GridMap::get_octant_size() const {
+int GridMap::get_octant_size() const {
return octant_size;
}
void GridMap::set_center_x(bool p_enable) {
-
center_x = p_enable;
_recreate_octant_data();
}
@@ -244,7 +227,6 @@ bool GridMap::get_center_x() const {
}
void GridMap::set_center_y(bool p_enable) {
-
center_y = p_enable;
_recreate_octant_data();
}
@@ -254,7 +236,6 @@ bool GridMap::get_center_y() const {
}
void GridMap::set_center_z(bool p_enable) {
-
center_z = p_enable;
_recreate_octant_data();
}
@@ -264,7 +245,6 @@ bool GridMap::get_center_z() const {
}
void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
-
if (baked_meshes.size() && !recreating_octants) {
//if you set a cell item, baked meshes go good bye
clear_baked_meshes();
@@ -313,7 +293,6 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_collisions_hint()) {
-
g->collision_debug = RenderingServer::get_singleton()->mesh_create();
g->collision_debug_instance = RenderingServer::get_singleton()->instance_create();
RenderingServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
@@ -340,7 +319,6 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
}
int GridMap::get_cell_item(int p_x, int p_y, int p_z) const {
-
ERR_FAIL_INDEX_V(ABS(p_x), 1 << 20, INVALID_CELL_ITEM);
ERR_FAIL_INDEX_V(ABS(p_y), 1 << 20, INVALID_CELL_ITEM);
ERR_FAIL_INDEX_V(ABS(p_z), 1 << 20, INVALID_CELL_ITEM);
@@ -350,13 +328,13 @@ int GridMap::get_cell_item(int p_x, int p_y, int p_z) const {
key.y = p_y;
key.z = p_z;
- if (!cell_map.has(key))
+ if (!cell_map.has(key)) {
return INVALID_CELL_ITEM;
+ }
return cell_map[key].item;
}
int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const {
-
ERR_FAIL_INDEX_V(ABS(p_x), 1 << 20, -1);
ERR_FAIL_INDEX_V(ABS(p_y), 1 << 20, -1);
ERR_FAIL_INDEX_V(ABS(p_z), 1 << 20, -1);
@@ -366,8 +344,9 @@ int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const {
key.y = p_y;
key.z = p_z;
- if (!cell_map.has(key))
+ if (!cell_map.has(key)) {
return -1;
+ }
return cell_map[key].rot;
}
@@ -389,7 +368,6 @@ Vector3 GridMap::map_to_world(int p_x, int p_y, int p_z) const {
}
void GridMap::_octant_transform(const OctantKey &p_key) {
-
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
@@ -406,15 +384,15 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
bool GridMap::_octant_update(const OctantKey &p_key) {
ERR_FAIL_COND_V(!octant_map.has(p_key), false);
Octant &g = *octant_map[p_key];
- if (!g.dirty)
+ if (!g.dirty) {
return false;
+ }
//erase body shapes
PhysicsServer3D::get_singleton()->body_clear_shapes(g.static_body);
//erase body shapes debug
if (g.collision_debug.is_valid()) {
-
RS::get_singleton()->mesh_clear(g.collision_debug);
}
@@ -427,7 +405,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
//erase multimeshes
for (int i = 0; i < g.multimesh_instances.size(); i++) {
-
RS::get_singleton()->free(g.multimesh_instances[i].instance);
RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
@@ -450,12 +427,12 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
Map<int, List<Pair<Transform, IndexKey>>> multimesh_items;
for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) {
-
ERR_CONTINUE(!cell_map.has(E->get()));
const Cell &c = cell_map[E->get()];
- if (!mesh_library.is_valid() || !mesh_library->has_item(c.item))
+ if (!mesh_library.is_valid() || !mesh_library->has_item(c.item)) {
continue;
+ }
Vector3 cellpos = Vector3(E->get().x, E->get().y, E->get().z);
Vector3 ofs = _get_offset();
@@ -482,8 +459,9 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
// add the item's shape at given xform to octant's static_body
for (int i = 0; i < shapes.size(); i++) {
// add the item's shape
- if (!shapes[i].shape.is_valid())
+ if (!shapes[i].shape.is_valid()) {
continue;
+ }
PhysicsServer3D::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
if (g.collision_debug.is_valid()) {
shapes.write[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform);
@@ -509,7 +487,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
//update multimeshes, only if not baked
if (baked_meshes.size() == 0) {
-
for (Map<int, List<Pair<Transform, IndexKey>>>::Element *E = multimesh_items.front(); E; E = E->next()) {
Octant::MultimeshInstance mmi;
@@ -548,7 +525,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
if (col_debug.size()) {
-
Array arr;
arr.resize(RS::ARRAY_MAX);
arr[RS::ARRAY_VERTEX] = col_debug;
@@ -573,7 +549,6 @@ void GridMap::_reset_physic_bodies_collision_filters() {
}
void GridMap::_octant_enter_world(const OctantKey &p_key) {
-
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
@@ -591,7 +566,6 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (navigation && mesh_library.is_valid()) {
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
-
if (cell_map.has(F->key()) && F->get().region.is_valid() == false) {
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item);
if (nm.is_valid()) {
@@ -607,14 +581,12 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
}
void GridMap::_octant_exit_world(const OctantKey &p_key) {
-
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
PhysicsServer3D::get_singleton()->body_set_space(g.static_body, RID());
if (g.collision_debug_instance.is_valid()) {
-
RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
@@ -624,7 +596,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
if (navigation) {
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
-
if (F->get().region.is_valid()) {
NavigationServer3D::get_singleton()->free(F->get().region);
F->get().region = RID();
@@ -634,14 +605,15 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
}
void GridMap::_octant_clean_up(const OctantKey &p_key) {
-
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- if (g.collision_debug.is_valid())
+ if (g.collision_debug.is_valid()) {
RS::get_singleton()->free(g.collision_debug);
- if (g.collision_debug_instance.is_valid())
+ }
+ if (g.collision_debug_instance.is_valid()) {
RS::get_singleton()->free(g.collision_debug_instance);
+ }
PhysicsServer3D::get_singleton()->free(g.static_body);
@@ -654,7 +626,6 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
//erase multimeshes
for (int i = 0; i < g.multimesh_instances.size(); i++) {
-
RS::get_singleton()->free(g.multimesh_instances[i].instance);
RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
@@ -662,11 +633,8 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
}
void GridMap::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_WORLD: {
-
Node3D *c = this;
while (c) {
navigation = Object::cast_to<Navigation3D>(c);
@@ -690,10 +658,10 @@ void GridMap::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
Transform new_xform = get_global_transform();
- if (new_xform == last_transform)
+ if (new_xform == last_transform) {
break;
+ }
//update run
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
_octant_transform(E->key());
@@ -707,7 +675,6 @@ void GridMap::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_WORLD: {
-
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
_octant_exit_world(E->key());
}
@@ -729,8 +696,9 @@ void GridMap::_notification(int p_what) {
}
void GridMap::_update_visibility() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_change_notify("visible");
@@ -744,31 +712,29 @@ void GridMap::_update_visibility() {
}
void GridMap::_queue_octants_dirty() {
-
- if (awaiting_update)
+ if (awaiting_update) {
return;
+ }
MessageQueue::get_singleton()->push_call(this, "_update_octants_callback");
awaiting_update = true;
}
void GridMap::_recreate_octant_data() {
-
recreating_octants = true;
Map<IndexKey, Cell> cell_copy = cell_map;
_clear_internal();
for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) {
-
set_cell_item(E->key().x, E->key().y, E->key().z, E->get().item, E->get().rot);
}
recreating_octants = false;
}
void GridMap::_clear_internal() {
-
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- if (is_inside_world())
+ if (is_inside_world()) {
_octant_exit_world(E->key());
+ }
_octant_clean_up(E->key());
memdelete(E->get());
@@ -779,24 +745,21 @@ void GridMap::_clear_internal() {
}
void GridMap::clear() {
-
_clear_internal();
clear_baked_meshes();
}
void GridMap::resource_changed(const RES &p_res) {
-
_recreate_octant_data();
}
void GridMap::_update_octants_callback() {
-
- if (!awaiting_update)
+ if (!awaiting_update) {
return;
+ }
List<OctantKey> to_delete;
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
-
if (_octant_update(E->key())) {
to_delete.push_back(E->key());
}
@@ -812,7 +775,6 @@ void GridMap::_update_octants_callback() {
}
void GridMap::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &GridMap::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &GridMap::get_collision_layer);
@@ -885,11 +847,12 @@ void GridMap::_bind_methods() {
}
void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::Axis p_axis) {
-
- if (!p_enabled && !clip)
+ if (!p_enabled && !clip) {
return;
- if (clip && p_enabled && clip_floor == p_floor && p_clip_above == clip_above && p_axis == clip_axis)
+ }
+ if (clip && p_enabled && clip_floor == p_floor && p_clip_above == clip_above && p_axis == clip_axis) {
return;
+ }
clip = p_enabled;
clip_floor = p_floor;
@@ -898,7 +861,6 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::
//make it all update
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
-
Octant *g = E->get();
g->dirty = true;
}
@@ -907,18 +869,15 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::
}
void GridMap::set_cell_scale(float p_scale) {
-
cell_scale = p_scale;
_recreate_octant_data();
}
float GridMap::get_cell_scale() const {
-
return cell_scale;
}
Array GridMap::get_used_cells() const {
-
Array a;
a.resize(cell_map.size());
int i = 0;
@@ -931,21 +890,22 @@ Array GridMap::get_used_cells() const {
}
Array GridMap::get_meshes() {
-
- if (mesh_library.is_null())
+ if (mesh_library.is_null()) {
return Array();
+ }
Vector3 ofs = _get_offset();
Array meshes;
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
-
int id = E->get().item;
- if (!mesh_library->has_item(id))
+ if (!mesh_library->has_item(id)) {
continue;
+ }
Ref<Mesh> mesh = mesh_library->get_item_mesh(id);
- if (mesh.is_null())
+ if (mesh.is_null()) {
continue;
+ }
IndexKey ik = E->key();
@@ -973,7 +933,6 @@ Vector3 GridMap::_get_offset() const {
}
void GridMap::clear_baked_meshes() {
-
for (int i = 0; i < baked_meshes.size(); i++) {
RS::get_singleton()->free(baked_meshes[i].instance);
}
@@ -983,24 +942,25 @@ void GridMap::clear_baked_meshes() {
}
void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texel_size) {
-
- if (!mesh_library.is_valid())
+ if (!mesh_library.is_valid()) {
return;
+ }
//generate
Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>> surface_map;
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
-
IndexKey key = E->key();
int item = E->get().item;
- if (!mesh_library->has_item(item))
+ if (!mesh_library->has_item(item)) {
continue;
+ }
Ref<Mesh> mesh = mesh_library->get_item_mesh(item);
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
continue;
+ }
Vector3 cellpos = Vector3(key.x, key.y, key.z);
Vector3 ofs = _get_offset();
@@ -1023,9 +983,9 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
Map<Ref<Material>, Ref<SurfaceTool>> &mat_map = surface_map[ok];
for (int i = 0; i < mesh->get_surface_count(); i++) {
-
- if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
+ }
Ref<Material> surf_mat = mesh->surface_get_material(i);
if (!mat_map.has(surf_mat)) {
@@ -1041,7 +1001,6 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
}
for (Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>>::Element *E = surface_map.front(); E; E = E->next()) {
-
Ref<ArrayMesh> mesh;
mesh.instance();
for (Map<Ref<Material>, Ref<SurfaceTool>>::Element *F = E->get().front(); F; F = F->next()) {
@@ -1068,7 +1027,6 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
}
Array GridMap::get_bake_meshes() {
-
if (!baked_meshes.size()) {
make_baked_meshes(true);
}
@@ -1083,13 +1041,11 @@ Array GridMap::get_bake_meshes() {
}
RID GridMap::get_bake_mesh_instance(int p_idx) {
-
ERR_FAIL_INDEX_V(p_idx, baked_meshes.size(), RID());
return baked_meshes[p_idx].instance;
}
GridMap::GridMap() {
-
collision_layer = 1;
collision_mask = 1;
@@ -1113,9 +1069,9 @@ GridMap::GridMap() {
}
GridMap::~GridMap() {
-
- if (!mesh_library.is_null())
+ if (!mesh_library.is_null()) {
mesh_library->unregister_owner(this);
+ }
clear();
}
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 3f3da09fe9..9eb9aee7d1 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -40,7 +40,6 @@
//should scale better with hardware that supports instancing
class GridMap : public Node3D {
-
GDCLASS(GridMap, Node3D);
enum {
@@ -49,7 +48,6 @@ class GridMap : public Node3D {
};
union IndexKey {
-
struct {
int16_t x;
int16_t y;
@@ -58,7 +56,6 @@ class GridMap : public Node3D {
uint64_t key;
_FORCE_INLINE_ bool operator<(const IndexKey &p_key) const {
-
return key < p_key.key;
}
@@ -69,7 +66,6 @@ class GridMap : public Node3D {
* @brief A Cell is a single cell in the cube map space; it is defined by its coordinates and the populating Item, identified by int id.
*/
union Cell {
-
struct {
unsigned int item : 16;
unsigned int rot : 5;
@@ -89,7 +85,6 @@ class GridMap : public Node3D {
* A GridMap can have multiple Octants.
*/
struct Octant {
-
struct NavMesh {
RID region;
Transform xform;
@@ -118,7 +113,6 @@ class GridMap : public Node3D {
};
union OctantKey {
-
struct {
int16_t x;
int16_t y;
@@ -129,7 +123,6 @@ class GridMap : public Node3D {
uint64_t key;
_FORCE_INLINE_ bool operator<(const OctantKey &p_key) const {
-
return key < p_key.key;
}
@@ -165,7 +158,6 @@ class GridMap : public Node3D {
void _recreate_octant_data();
struct BakeLight {
-
RS::LightType type;
Vector3 pos;
Vector3 dir;
@@ -173,7 +165,6 @@ class GridMap : public Node3D {
};
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {
-
return Vector3(p_key.x, p_key.y, p_key.z) * cell_size * octant_size;
}
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 9abbac6a0b..3b0e78546d 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -35,28 +35,25 @@
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
-#include "core/math/geometry.h"
#include "core/os/keyboard.h"
#include "scene/main/window.h"
void GridMapEditor::_node_removed(Node *p_node) {
-
- if (p_node == node)
+ if (p_node == node) {
node = nullptr;
+ }
}
void GridMapEditor::_configure() {
-
- if (!node)
+ if (!node) {
return;
+ }
update_grid();
}
void GridMapEditor::_menu_option(int p_option) {
-
switch (p_option) {
-
case MENU_OPTION_PREV_LEVEL: {
floor->set_value(floor->get_value() - 1);
} break;
@@ -66,7 +63,6 @@ void GridMapEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_LOCK_VIEW: {
-
int index = options->get_popup()->get_item_index(MENU_OPTION_LOCK_VIEW);
lock_view = !options->get_popup()->is_item_checked(index);
@@ -75,10 +71,8 @@ void GridMapEditor::_menu_option(int p_option) {
case MENU_OPTION_CLIP_DISABLED:
case MENU_OPTION_CLIP_ABOVE:
case MENU_OPTION_CLIP_BELOW: {
-
clip_mode = ClipMode(p_option - MENU_OPTION_CLIP_DISABLED);
for (int i = 0; i < 3; i++) {
-
int index = options->get_popup()->get_item_index(MENU_OPTION_CLIP_DISABLED + i);
options->get_popup()->set_item_checked(index, i == clip_mode);
}
@@ -88,7 +82,6 @@ void GridMapEditor::_menu_option(int p_option) {
case MENU_OPTION_X_AXIS:
case MENU_OPTION_Y_AXIS:
case MENU_OPTION_Z_AXIS: {
-
int new_axis = p_option - MENU_OPTION_X_AXIS;
for (int i = 0; i < 3; i++) {
int idx = options->get_popup()->get_item_index(MENU_OPTION_X_AXIS + i);
@@ -114,10 +107,8 @@ void GridMapEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CURSOR_ROTATE_Y: {
-
Basis r;
if (input_action == INPUT_PASTE) {
-
r.set_orthogonal_index(paste_indicator.orientation);
r.rotate(Vector3(0, 1, 0), -Math_PI / 2.0);
paste_indicator.orientation = r.get_orthogonal_index();
@@ -131,10 +122,8 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_ROTATE_X: {
-
Basis r;
if (input_action == INPUT_PASTE) {
-
r.set_orthogonal_index(paste_indicator.orientation);
r.rotate(Vector3(1, 0, 0), -Math_PI / 2.0);
paste_indicator.orientation = r.get_orthogonal_index();
@@ -148,10 +137,8 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_ROTATE_Z: {
-
Basis r;
if (input_action == INPUT_PASTE) {
-
r.set_orthogonal_index(paste_indicator.orientation);
r.rotate(Vector3(0, 0, 1), -Math_PI / 2.0);
paste_indicator.orientation = r.get_orthogonal_index();
@@ -165,10 +152,8 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_BACK_ROTATE_Y: {
-
Basis r;
if (input_action == INPUT_PASTE) {
-
r.set_orthogonal_index(paste_indicator.orientation);
r.rotate(Vector3(0, 1, 0), Math_PI / 2.0);
paste_indicator.orientation = r.get_orthogonal_index();
@@ -182,10 +167,8 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_BACK_ROTATE_X: {
-
Basis r;
if (input_action == INPUT_PASTE) {
-
r.set_orthogonal_index(paste_indicator.orientation);
r.rotate(Vector3(1, 0, 0), Math_PI / 2.0);
paste_indicator.orientation = r.get_orthogonal_index();
@@ -199,10 +182,8 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_BACK_ROTATE_Z: {
-
Basis r;
if (input_action == INPUT_PASTE) {
-
r.set_orthogonal_index(paste_indicator.orientation);
r.rotate(Vector3(0, 0, 1), Math_PI / 2.0);
paste_indicator.orientation = r.get_orthogonal_index();
@@ -216,9 +197,7 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_CLEAR_ROTATION: {
-
if (input_action == INPUT_PASTE) {
-
paste_indicator.orientation = 0;
_update_paste_indicator();
break;
@@ -235,8 +214,9 @@ void GridMapEditor::_menu_option(int p_option) {
case MENU_OPTION_SELECTION_DUPLICATE:
case MENU_OPTION_SELECTION_CUT: {
- if (!(selection.active && input_action == INPUT_NONE))
+ if (!(selection.active && input_action == INPUT_NONE)) {
break;
+ }
_set_clipboard_data();
@@ -253,15 +233,17 @@ void GridMapEditor::_menu_option(int p_option) {
_update_paste_indicator();
} break;
case MENU_OPTION_SELECTION_CLEAR: {
- if (!selection.active)
+ if (!selection.active) {
break;
+ }
_delete_selection();
} break;
case MENU_OPTION_SELECTION_FILL: {
- if (!selection.active)
+ if (!selection.active) {
return;
+ }
_fill_selection();
@@ -273,7 +255,6 @@ void GridMapEditor::_menu_option(int p_option) {
}
void GridMapEditor::_update_cursor_transform() {
-
cursor_transform = Transform();
cursor_transform.origin = cursor_origin;
cursor_transform.basis.set_orthogonal_index(cursor_rot);
@@ -291,7 +272,6 @@ void GridMapEditor::_update_selection_transform() {
xf_zero.basis.set_zero();
if (!selection.active) {
-
RenderingServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
for (int i = 0; i < 3; i++) {
RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
@@ -309,7 +289,6 @@ void GridMapEditor::_update_selection_transform() {
if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) {
RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
} else {
-
Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1));
scale[edit_axis] = 1.0;
Vector3 pos = selection.begin;
@@ -328,24 +307,26 @@ void GridMapEditor::_update_selection_transform() {
}
void GridMapEditor::_validate_selection() {
-
- if (!selection.active)
+ if (!selection.active) {
return;
+ }
selection.begin = selection.click;
selection.end = selection.current;
- if (selection.begin.x > selection.end.x)
+ if (selection.begin.x > selection.end.x) {
SWAP(selection.begin.x, selection.end.x);
- if (selection.begin.y > selection.end.y)
+ }
+ if (selection.begin.y > selection.end.y) {
SWAP(selection.begin.y, selection.end.y);
- if (selection.begin.z > selection.end.z)
+ }
+ if (selection.begin.z > selection.end.z) {
SWAP(selection.begin.z, selection.end.z);
+ }
_update_selection_transform();
}
void GridMapEditor::_set_selection(bool p_active, const Vector3 &p_begin, const Vector3 &p_end) {
-
selection.active = p_active;
selection.begin = p_begin;
selection.end = p_end;
@@ -363,17 +344,20 @@ void GridMapEditor::_set_selection(bool p_active, const Vector3 &p_begin, const
}
bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, bool p_click) {
-
- if (!spatial_editor)
+ if (!spatial_editor) {
return false;
+ }
- if (selected_palette < 0 && input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE)
+ if (selected_palette < 0 && input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE) {
return false;
+ }
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
- if (mesh_library.is_null())
+ if (mesh_library.is_null()) {
return false;
- if (input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE && !mesh_library->has_item(selected_palette))
+ }
+ if (input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE && !mesh_library->has_item(selected_palette)) {
return false;
+ }
Camera3D *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point);
@@ -388,30 +372,30 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
Vector3 inters;
- if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters))
+ if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters)) {
return false;
+ }
// Make sure the intersection is inside the frustum planes, to avoid
// Painting on invisible regions.
for (int i = 0; i < planes.size(); i++) {
-
Plane fp = local_xform.xform(planes[i]);
- if (fp.is_point_over(inters))
+ if (fp.is_point_over(inters)) {
return false;
+ }
}
int cell[3];
float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z };
for (int i = 0; i < 3; i++) {
-
- if (i == edit_axis)
+ if (i == edit_axis) {
cell[i] = edit_floor[i];
- else {
-
+ } else {
cell[i] = inters[i] / node->get_cell_size()[i];
- if (inters[i] < 0)
+ if (inters[i] < 0) {
cell[i] -= 1; // Compensate negative.
+ }
grid_ofs[i] = cell[i] * cell_size[i];
}
}
@@ -419,7 +403,6 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
RS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
if (cursor_instance.is_valid()) {
-
cursor_origin = (Vector3(cell[0], cell[1], cell[2]) + Vector3(0.5 * node->get_center_x(), 0.5 * node->get_center_y(), 0.5 * node->get_center_z())) * node->get_cell_size();
cursor_visible = true;
@@ -431,21 +414,19 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
}
if (input_action == INPUT_PASTE) {
-
paste_indicator.current = Vector3(cell[0], cell[1], cell[2]);
_update_paste_indicator();
} else if (input_action == INPUT_SELECT) {
-
selection.current = Vector3(cell[0], cell[1], cell[2]);
- if (p_click)
+ if (p_click) {
selection.click = selection.current;
+ }
selection.active = true;
_validate_selection();
return true;
} else if (input_action == INPUT_PICK) {
-
int item = node->get_cell_item(cell[0], cell[1], cell[2]);
if (item >= 0) {
selected_palette = item;
@@ -481,17 +462,14 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
}
void GridMapEditor::_delete_selection() {
-
- if (!selection.active)
+ if (!selection.active) {
return;
+ }
undo_redo->create_action(TTR("GridMap Delete Selection"));
for (int i = selection.begin.x; i <= selection.end.x; i++) {
-
for (int j = selection.begin.y; j <= selection.end.y; j++) {
-
for (int k = selection.begin.z; k <= selection.end.z; k++) {
-
undo_redo->add_do_method(node, "set_cell_item", i, j, k, GridMap::INVALID_CELL_ITEM);
undo_redo->add_undo_method(node, "set_cell_item", i, j, k, node->get_cell_item(i, j, k), node->get_cell_item_orientation(i, j, k));
}
@@ -503,17 +481,14 @@ void GridMapEditor::_delete_selection() {
}
void GridMapEditor::_fill_selection() {
-
- if (!selection.active)
+ if (!selection.active) {
return;
+ }
undo_redo->create_action(TTR("GridMap Fill Selection"));
for (int i = selection.begin.x; i <= selection.end.x; i++) {
-
for (int j = selection.begin.y; j <= selection.end.y; j++) {
-
for (int k = selection.begin.z; k <= selection.end.z; k++) {
-
undo_redo->add_do_method(node, "set_cell_item", i, j, k, selected_palette, cursor_rot);
undo_redo->add_undo_method(node, "set_cell_item", i, j, k, node->get_cell_item(i, j, k), node->get_cell_item_orientation(i, j, k));
}
@@ -525,9 +500,7 @@ void GridMapEditor::_fill_selection() {
}
void GridMapEditor::_clear_clipboard_data() {
-
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
-
RenderingServer::get_singleton()->free(E->get().instance);
}
@@ -535,20 +508,17 @@ void GridMapEditor::_clear_clipboard_data() {
}
void GridMapEditor::_set_clipboard_data() {
-
_clear_clipboard_data();
Ref<MeshLibrary> meshLibrary = node->get_mesh_library();
for (int i = selection.begin.x; i <= selection.end.x; i++) {
-
for (int j = selection.begin.y; j <= selection.end.y; j++) {
-
for (int k = selection.begin.z; k <= selection.end.z; k++) {
-
int itm = node->get_cell_item(i, j, k);
- if (itm == GridMap::INVALID_CELL_ITEM)
+ if (itm == GridMap::INVALID_CELL_ITEM) {
continue;
+ }
Ref<Mesh> mesh = meshLibrary->get_item_mesh(itm);
@@ -565,9 +535,7 @@ void GridMapEditor::_set_clipboard_data() {
}
void GridMapEditor::_update_paste_indicator() {
-
if (input_action != INPUT_PASTE) {
-
Transform xf;
xf.basis.set_zero();
RenderingServer::get_singleton()->instance_set_transform(paste_instance, xf);
@@ -587,7 +555,6 @@ void GridMapEditor::_update_paste_indicator() {
RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf);
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
-
ClipboardItem &item = E->get();
xf = Transform();
@@ -604,7 +571,6 @@ void GridMapEditor::_update_paste_indicator() {
}
void GridMapEditor::_do_paste() {
-
int idx = options->get_popup()->get_item_index(MENU_OPTION_PASTE_SELECTS);
bool reselect = options->get_popup()->is_item_checked(idx);
@@ -615,7 +581,6 @@ void GridMapEditor::_do_paste() {
undo_redo->create_action(TTR("GridMap Paste Selection"));
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
-
ClipboardItem &item = E->get();
Vector3 pos = rot.xform(item.grid_offset) + paste_indicator.begin + ofs;
@@ -629,7 +594,6 @@ void GridMapEditor::_do_paste() {
}
if (reselect) {
-
undo_redo->add_do_method(this, "_set_selection", true, paste_indicator.begin + ofs, paste_indicator.end + ofs);
undo_redo->add_undo_method(this, "_set_selection", selection.active, selection.begin, selection.end);
}
@@ -647,15 +611,16 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
+ if (mb->is_pressed()) {
floor->set_value(floor->get_value() + mb->get_factor());
+ }
return true; // Eaten.
} else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
+ if (mb->is_pressed()) {
floor->set_value(floor->get_value() - mb->get_factor());
+ }
return true;
}
@@ -664,7 +629,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
if ((nav_scheme == Node3DEditorViewport::NAVIGATION_MAYA || nav_scheme == Node3DEditorViewport::NAVIGATION_MODO) && mb->get_alt()) {
input_action = INPUT_NONE;
} else if (mb->get_button_index() == BUTTON_LEFT) {
-
bool can_edit = (node && node->get_mesh_library().is_valid());
if (input_action == INPUT_PASTE) {
_do_paste();
@@ -698,18 +662,14 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else {
-
if ((mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) || (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
-
if (set_items.size()) {
undo_redo->create_action(TTR("GridMap Paint"));
for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
-
const SetItem &si = E->get();
undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
}
for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
-
const SetItem &si = E->get();
undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
}
@@ -722,7 +682,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
}
if (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_SELECT) {
-
undo_redo->create_action("GridMap Selection");
undo_redo->add_do_method(this, "_set_selection", selection.active, selection.begin, selection.end);
undo_redo->add_undo_method(this, "_set_selection", last_selection.active, last_selection.begin, last_selection.end);
@@ -730,7 +689,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
}
if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
-
set_items.clear();
input_action = INPUT_NONE;
return true;
@@ -745,7 +703,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
return do_input_action(p_camera, mm->get_position(), false);
}
@@ -754,7 +711,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
if (k.is_valid()) {
if (k->is_pressed()) {
if (k->get_keycode() == KEY_ESCAPE) {
-
if (input_action == INPUT_PASTE) {
_clear_clipboard_data();
input_action = INPUT_NONE;
@@ -773,7 +729,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
}
if (k->get_shift() && selection.active && input_action != INPUT_PASTE) {
-
if (k->get_keycode() == options->get_popup()->get_item_accelerator(options->get_popup()->get_item_index(MENU_OPTION_PREV_LEVEL))) {
selection.click[edit_axis]--;
_validate_selection();
@@ -790,7 +745,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
-
if (pan_gesture->get_alt() && (pan_gesture->get_command() || pan_gesture->get_shift())) {
const real_t delta = pan_gesture->get_delta().y * 0.5;
accumulated_floor_delta += delta;
@@ -811,7 +765,6 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
}
struct _CGMEItemSort {
-
String name;
int id;
_FORCE_INLINE_ bool operator<(const _CGMEItemSort &r_it) const { return name < r_it.name; }
@@ -840,11 +793,9 @@ void GridMapEditor::_text_changed(const String &p_text) {
}
void GridMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
-
const Ref<InputEventKey> k = p_ie;
if (k.is_valid() && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_PAGEUP || k->get_keycode() == KEY_PAGEDOWN)) {
-
// Forward the key input to the ItemList so it can be scrolled
mesh_library_palette->call("_gui_input", k);
search_box->accept_event();
@@ -852,12 +803,10 @@ void GridMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
}
void GridMapEditor::_mesh_library_palette_input(const Ref<InputEvent> &p_ie) {
-
const Ref<InputEventMouseButton> mb = p_ie;
// Zoom in/out using Ctrl + mouse wheel
if (mb.is_valid() && mb->is_pressed() && mb->get_command()) {
-
if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_UP) {
size_slider->set_value(size_slider->get_value() + 0.2);
}
@@ -911,7 +860,6 @@ void GridMapEditor::update_palette() {
List<_CGMEItemSort> il;
for (int i = 0; i < ids.size(); i++) {
-
_CGMEItemSort is;
is.id = ids[i];
is.name = mesh_library->get_item_name(ids[i]);
@@ -932,8 +880,9 @@ void GridMapEditor::update_palette() {
name = "#" + itos(id);
}
- if (filter != "" && !filter.is_subsequence_ofi(name))
+ if (filter != "" && !filter.is_subsequence_ofi(name)) {
continue;
+ }
mesh_library_palette->add_item("");
if (!preview.is_null()) {
@@ -954,8 +903,9 @@ void GridMapEditor::update_palette() {
}
void GridMapEditor::edit(GridMap *p_gridmap) {
- if (!p_gridmap && node)
+ if (!p_gridmap && node) {
node->disconnect("cell_size_changed", callable_mp(this, &GridMapEditor::_draw_grids));
+ }
node = p_gridmap;
@@ -993,16 +943,15 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
}
void GridMapEditor::_update_clip() {
-
node->set_meta("_editor_clip_", clip_mode);
- if (clip_mode == CLIP_DISABLED)
+ if (clip_mode == CLIP_DISABLED) {
node->set_clip(false);
- else
+ } else {
node->set_clip(true, clip_mode == CLIP_ABOVE, edit_floor[edit_axis], edit_axis);
+ }
}
void GridMapEditor::update_grid() {
-
grid_xform.origin.x -= 1; // Force update in hackish way.
grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
@@ -1031,7 +980,6 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
Vector<Color> grid_colors[3];
for (int i = 0; i < 3; i++) {
-
Vector3 axis;
axis[i] = 1;
Vector3 axis_n1;
@@ -1040,9 +988,7 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
axis_n2[(i + 2) % 3] = cell_size[(i + 2) % 3];
for (int j = -GRID_CURSOR_SIZE; j <= GRID_CURSOR_SIZE; j++) {
-
for (int k = -GRID_CURSOR_SIZE; k <= GRID_CURSOR_SIZE; k++) {
-
Vector3 p = axis_n1 * j + axis_n2 * k;
float trans = Math::pow(MAX(0, 1.0 - (Vector2(j, k).length() / GRID_CURSOR_SIZE)), 2);
@@ -1074,14 +1020,11 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
}
void GridMapEditor::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
get_tree()->connect("node_removed", callable_mp(this, &GridMapEditor::_node_removed));
mesh_library_palette->connect("item_selected", callable_mp(this, &GridMapEditor::_item_selected_cbk));
for (int i = 0; i < 3; i++) {
-
grid[i] = RS::get_singleton()->mesh_create();
grid_instance[i] = RS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world_3d()->get_scenario());
selection_level_instance[i] = RenderingServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world_3d()->get_scenario());
@@ -1099,7 +1042,6 @@ void GridMapEditor::_notification(int p_what) {
_clear_clipboard_data();
for (int i = 0; i < 3; i++) {
-
RS::get_singleton()->free(grid_instance[i]);
RS::get_singleton()->free(grid[i]);
grid_instance[i] = RID();
@@ -1122,17 +1064,16 @@ void GridMapEditor::_notification(int p_what) {
if (xf != grid_xform) {
for (int i = 0; i < 3; i++) {
-
RS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
}
grid_xform = xf;
}
Ref<MeshLibrary> cgmt = node->get_mesh_library();
- if (cgmt.operator->() != last_mesh_library)
+ if (cgmt.operator->() != last_mesh_library) {
update_palette();
+ }
if (lock_view) {
-
EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0));
Plane p;
@@ -1141,8 +1082,9 @@ void GridMapEditor::_notification(int p_what) {
p = node->get_transform().xform(p); // plane to snap
Node3DEditorPlugin *sep = Object::cast_to<Node3DEditorPlugin>(editor->get_editor_plugin_screen());
- if (sep)
+ if (sep) {
sep->snap_cursor_to_plane(p);
+ }
}
} break;
@@ -1158,16 +1100,15 @@ void GridMapEditor::_update_cursor_instance() {
return;
}
- if (cursor_instance.is_valid())
+ if (cursor_instance.is_valid()) {
RenderingServer::get_singleton()->free(cursor_instance);
+ }
cursor_instance = RID();
if (selected_palette >= 0) {
-
if (node && !node->get_mesh_library().is_null()) {
Ref<Mesh> mesh = node->get_mesh_library()->get_item_mesh(selected_palette);
if (!mesh.is_null() && mesh->get_rid().is_valid()) {
-
cursor_instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world_3d()->get_scenario());
RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
}
@@ -1182,9 +1123,9 @@ void GridMapEditor::_item_selected_cbk(int idx) {
}
void GridMapEditor::_floor_changed(float p_value) {
-
- if (updating)
+ if (updating) {
return;
+ }
edit_floor[edit_axis] = p_value;
node->set_meta("_editor_floor_", Vector3(edit_floor[0], edit_floor[1], edit_floor[2]));
@@ -1198,13 +1139,11 @@ void GridMapEditor::_floor_mouse_exited() {
}
void GridMapEditor::_bind_methods() {
-
ClassDB::bind_method("_configure", &GridMapEditor::_configure);
ClassDB::bind_method("_set_selection", &GridMapEditor::_set_selection);
}
GridMapEditor::GridMapEditor(EditorNode *p_editor) {
-
input_action = INPUT_NONE;
editor = p_editor;
undo_redo = p_editor->get_undo_redo();
@@ -1364,22 +1303,20 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
Vector<Vector3> square[3];
for (int i = 0; i < 6; i++) {
-
Vector3 face_points[4];
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)
+ if (i < 3) {
face_points[j][(i + k) % 3] = v[k];
- else
+ } else {
face_points[3 - j][(i + k) % 3] = -v[k];
+ }
}
}
@@ -1393,7 +1330,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
}
for (int i = 0; i < 12; i++) {
-
AABB base(Vector3(0, 0, 0), Vector3(1, 1, 1));
Vector3 a, b;
base.get_edge(i, a, b);
@@ -1404,9 +1340,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
for (int i = 0; i < 3; i++) {
Vector3 points[4];
for (int j = 0; j < 4; j++) {
-
- static const bool orderx[4] = { 0, 1, 1, 0 };
- static const bool ordery[4] = { 0, 0, 1, 1 };
+ static const bool orderx[4] = { false, true, true, false };
+ static const bool ordery[4] = { false, false, true, true };
Vector3 sp;
if (orderx[j]) {
@@ -1420,7 +1355,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
}
for (int j = 0; j < 4; j++) {
-
Vector3 ofs;
ofs[i] += 0.01;
square[i].push_back(points[j] - ofs);
@@ -1487,36 +1421,39 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
}
GridMapEditor::~GridMapEditor() {
-
_clear_clipboard_data();
for (int i = 0; i < 3; i++) {
-
- if (grid[i].is_valid())
+ if (grid[i].is_valid()) {
RenderingServer::get_singleton()->free(grid[i]);
- if (grid_instance[i].is_valid())
+ }
+ if (grid_instance[i].is_valid()) {
RenderingServer::get_singleton()->free(grid_instance[i]);
- if (cursor_instance.is_valid())
+ }
+ if (cursor_instance.is_valid()) {
RenderingServer::get_singleton()->free(cursor_instance);
- if (selection_level_instance[i].is_valid())
+ }
+ if (selection_level_instance[i].is_valid()) {
RenderingServer::get_singleton()->free(selection_level_instance[i]);
- if (selection_level_mesh[i].is_valid())
+ }
+ if (selection_level_mesh[i].is_valid()) {
RenderingServer::get_singleton()->free(selection_level_mesh[i]);
+ }
}
RenderingServer::get_singleton()->free(selection_mesh);
- if (selection_instance.is_valid())
+ if (selection_instance.is_valid()) {
RenderingServer::get_singleton()->free(selection_instance);
+ }
RenderingServer::get_singleton()->free(paste_mesh);
- if (paste_instance.is_valid())
+ if (paste_instance.is_valid()) {
RenderingServer::get_singleton()->free(paste_instance);
+ }
}
void GridMapEditorPlugin::_notification(int p_what) {
-
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
-
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
case 0: { // Left.
Node3DEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0);
@@ -1529,23 +1466,19 @@ void GridMapEditorPlugin::_notification(int p_what) {
}
void GridMapEditorPlugin::edit(Object *p_object) {
-
grid_map_editor->edit(Object::cast_to<GridMap>(p_object));
}
bool GridMapEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("GridMap");
}
void GridMapEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
grid_map_editor->show();
grid_map_editor->spatial_editor_hb->show();
grid_map_editor->set_process(true);
} else {
-
grid_map_editor->spatial_editor_hb->hide();
grid_map_editor->hide();
grid_map_editor->edit(nullptr);
@@ -1554,7 +1487,6 @@ void GridMapEditorPlugin::make_visible(bool p_visible) {
}
GridMapEditorPlugin::GridMapEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
EDITOR_DEF("editors/grid_map/editor_side", 1);
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index fd880e8b7b..19eea18965 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -85,7 +85,6 @@ class GridMapEditor : public VBoxContainer {
Label *spin_box_label;
struct SetItem {
-
Vector3 pos;
int new_value;
int new_orientation;
@@ -133,7 +132,6 @@ class GridMapEditor : public VBoxContainer {
bool updating;
struct Selection {
-
Vector3 click;
Vector3 current;
Vector3 begin;
@@ -143,7 +141,6 @@ class GridMapEditor : public VBoxContainer {
Selection last_selection;
struct PasteIndicator {
-
Vector3 click;
Vector3 current;
Vector3 begin;
@@ -191,7 +188,6 @@ class GridMapEditor : public VBoxContainer {
Node3DEditorPlugin *spatial_editor;
struct AreaDisplay {
-
RID mesh;
RID instance;
};
@@ -251,7 +247,6 @@ public:
};
class GridMapEditorPlugin : public EditorPlugin {
-
GDCLASS(GridMapEditorPlugin, EditorPlugin);
GridMapEditor *grid_map_editor;
diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp
index afd51945ab..906e506b62 100644
--- a/modules/gridmap/register_types.cpp
+++ b/modules/gridmap/register_types.cpp
@@ -36,7 +36,6 @@
#endif
void register_gridmap_types() {
-
#ifndef _3D_DISABLED
ClassDB::register_class<GridMap>();
#ifdef TOOLS_ENABLED
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp
index c03ae4ab1f..333b1cf377 100644
--- a/modules/hdr/image_loader_hdr.cpp
+++ b/modules/hdr/image_loader_hdr.cpp
@@ -34,7 +34,6 @@
#include "core/print_string.h"
Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
String header = f->get_token();
ERR_FAIL_COND_V_MSG(header != "#?RADIANCE" && header != "#?RGBE", ERR_FILE_UNRECOGNIZED, "Unsupported header information in HDR: " + header + ".");
@@ -42,8 +41,9 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
while (true) {
String line = f->get_line();
ERR_FAIL_COND_V(f->eof_reached(), ERR_FILE_UNRECOGNIZED);
- if (line == "") // empty line indicates end of header
+ if (line == "") { // empty line indicates end of header
break;
+ }
if (line.begins_with("FORMAT=")) { // leave option to implement other commands
ERR_FAIL_COND_V_MSG(line != "FORMAT=32-bit_rle_rgbe", ERR_FILE_UNRECOGNIZED, "Only 32-bit_rle_rgbe is supported for HDR files.");
} else if (!line.begins_with("#")) { // not comment
@@ -68,7 +68,6 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
imgdata.resize(height * width * sizeof(uint32_t));
{
-
uint8_t *w = imgdata.ptrw();
uint8_t *ptr = (uint8_t *)w;
@@ -109,12 +108,14 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
// Run
int value = f->get_8();
count -= 128;
- for (int z = 0; z < count; ++z)
+ for (int z = 0; z < count; ++z) {
ptr[(j * width + i++) * 4 + k] = uint8_t(value);
+ }
} else {
// Dump
- for (int z = 0; z < count; ++z)
+ for (int z = 0; z < count; ++z) {
ptr[(j * width + i++) * 4 + k] = f->get_8();
+ }
}
}
}
@@ -123,7 +124,6 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
//convert
for (int i = 0; i < width * height; i++) {
-
float exp = pow(2.0f, ptr[3] - 128.0f);
Color c(
@@ -146,7 +146,6 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
void ImageLoaderHDR::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("hdr");
}
diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h
index a5f1f9c387..ef8e116616 100644
--- a/modules/hdr/image_loader_hdr.h
+++ b/modules/hdr/image_loader_hdr.h
@@ -34,7 +34,6 @@
#include "core/io/image_loader.h"
class ImageLoaderHDR : public ImageFormatLoader {
-
public:
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp
index 5f2d1578c5..e749928f60 100644
--- a/modules/hdr/register_types.cpp
+++ b/modules/hdr/register_types.cpp
@@ -35,12 +35,10 @@
static ImageLoaderHDR *image_loader_hdr = nullptr;
void register_hdr_types() {
-
image_loader_hdr = memnew(ImageLoaderHDR);
ImageLoader::add_image_format_loader(image_loader_hdr);
}
void unregister_hdr_types() {
-
memdelete(image_loader_hdr);
}
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index 9e87d11ac1..9c7ace5cf2 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -37,7 +37,6 @@
#include <string.h>
Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p_buffer_len) {
-
jpgd::jpeg_decoder_mem_stream mem_stream(p_buffer, p_buffer_len);
jpgd::jpeg_decoder decoder(&mem_stream);
@@ -49,11 +48,13 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
const int image_width = decoder.get_width();
const int image_height = decoder.get_height();
const int comps = decoder.get_num_components();
- if (comps != 1 && comps != 3)
+ if (comps != 1 && comps != 3) {
return ERR_FILE_CORRUPT;
+ }
- if (decoder.begin_decoding() != jpgd::JPGD_SUCCESS)
+ if (decoder.begin_decoding() != jpgd::JPGD_SUCCESS) {
return ERR_FILE_CORRUPT;
+ }
const int dst_bpl = image_width * comps;
@@ -91,18 +92,18 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
//all good
Image::Format fmt;
- if (comps == 1)
+ if (comps == 1) {
fmt = Image::FORMAT_L8;
- else
+ } else {
fmt = Image::FORMAT_RGB8;
+ }
- p_image->create(image_width, image_height, 0, fmt, data);
+ p_image->create(image_width, image_height, false, fmt, data);
return OK;
}
Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
@@ -120,13 +121,11 @@ Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("jpg");
p_extensions->push_back("jpeg");
}
static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) {
-
Ref<Image> img;
img.instance();
Error err = jpeg_load_image_from_buffer(img.ptr(), p_png, p_size);
@@ -135,6 +134,5 @@ static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) {
}
ImageLoaderJPG::ImageLoaderJPG() {
-
Image::_jpg_mem_loader_func = _jpegd_mem_loader_func;
}
diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h
index 9ef37ae303..9aebaad9e3 100644
--- a/modules/jpg/image_loader_jpegd.h
+++ b/modules/jpg/image_loader_jpegd.h
@@ -34,7 +34,6 @@
#include "core/io/image_loader.h"
class ImageLoaderJPG : public ImageFormatLoader {
-
public:
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp
index 61375fef10..b31746f769 100644
--- a/modules/jpg/register_types.cpp
+++ b/modules/jpg/register_types.cpp
@@ -35,12 +35,10 @@
static ImageLoaderJPG *image_loader_jpg = nullptr;
void register_jpg_types() {
-
image_loader_jpg = memnew(ImageLoaderJPG);
ImageLoader::add_image_format_loader(image_loader_jpg);
}
void unregister_jpg_types() {
-
memdelete(image_loader_jpg);
}
diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp
index 208ce24f3d..7bb70b098f 100644
--- a/modules/jsonrpc/jsonrpc.cpp
+++ b/modules/jsonrpc/jsonrpc.cpp
@@ -120,7 +120,7 @@ Variant JSONRPC::process_action(const Variant &p_action, bool p_process_arr_elem
}
if (object == nullptr || !object->has_method(method)) {
- ret = make_response_error(JSONRPC::METHOD_NOT_FOUND, "Method not found", id);
+ ret = make_response_error(JSONRPC::METHOD_NOT_FOUND, "Method not found: " + method, id);
} else {
Variant call_ret = object->callv(method, args);
if (id.get_type() != Variant::NIL) {
@@ -147,9 +147,9 @@ Variant JSONRPC::process_action(const Variant &p_action, bool p_process_arr_elem
}
String JSONRPC::process_string(const String &p_input) {
-
- if (p_input.empty())
+ if (p_input.empty()) {
return String();
+ }
Variant ret;
Variant input;
diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp
index 6983c222c0..4de523baa0 100644
--- a/modules/lightmapper_rd/lightmapper_rd.cpp
+++ b/modules/lightmapper_rd/lightmapper_rd.cpp
@@ -1,5 +1,35 @@
+/*************************************************************************/
+/* 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/math/geometry_2d.h"
#include "core/project_settings.h"
#include "lm_blendseams.glsl.gen.h"
#include "lm_compute.glsl.gen.h"
@@ -34,6 +64,7 @@ void LightmapperRD::add_directional_light(bool p_static, const Vector3 &p_direct
l.size = p_angular_distance;
lights.push_back(l);
}
+
void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_size) {
Light l;
l.type = LIGHT_TYPE_OMNI;
@@ -50,8 +81,8 @@ void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, con
l.size = p_size;
lights.push_back(l);
}
-void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, const Vector3 p_direction, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_spot_angle, float p_spot_attenuation, float p_size) {
+void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, const Vector3 p_direction, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_spot_angle, float p_spot_attenuation, float p_size) {
Light l;
l.type = LIGHT_TYPE_SPOT;
l.position[0] = p_position.x;
@@ -83,11 +114,9 @@ void LightmapperRD::add_probe(const Vector3 &p_position) {
}
void LightmapperRD::_plot_triangle_into_triangle_index_list(int p_size, const Vector3i &p_ofs, const AABB &p_bounds, const Vector3 p_points[3], uint32_t p_triangle_index, LocalVector<TriangleSort> &triangles, uint32_t p_grid_size) {
-
int half_size = p_size / 2;
for (int i = 0; i < 8; i++) {
-
AABB aabb = p_bounds;
aabb.size *= 0.5;
Vector3i n = p_ofs;
@@ -108,7 +137,7 @@ void LightmapperRD::_plot_triangle_into_triangle_index_list(int p_size, const Ve
{
Vector3 qsize = aabb.size * 0.5; //quarter size, for fast aabb test
- if (!Geometry::triangle_box_overlap(aabb.position + qsize, qsize, p_points)) {
+ if (!Geometry3D::triangle_box_overlap(aabb.position + qsize, qsize, p_points)) {
//does not fit in child, go on
continue;
}
@@ -127,11 +156,9 @@ void LightmapperRD::_plot_triangle_into_triangle_index_list(int p_size, const Ve
}
Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_size, Vector<Ref<Image>> &albedo_images, Vector<Ref<Image>> &emission_images, AABB &bounds, Size2i &atlas_size, int &atlas_slices, BakeStepFunc p_step_function, void *p_bake_userdata) {
-
Vector<Size2i> sizes;
for (int m_i = 0; m_i < mesh_instances.size(); m_i++) {
-
MeshInstance &mi = mesh_instances.write[m_i];
Size2i s = Size2i(mi.data.albedo_on_uv2->get_width(), mi.data.albedo_on_uv2->get_height());
sizes.push_back(s);
@@ -159,7 +186,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
//determine best texture array atlas size by bruteforce fitting
while (atlas_size.x <= p_max_texture_size && atlas_size.y <= p_max_texture_size) {
-
Vector<Vector2i> source_sizes = sizes;
Vector<int> source_indices;
source_indices.resize(source_sizes.size());
@@ -172,8 +198,7 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
int slices = 0;
while (source_sizes.size() > 0) {
-
- Vector<Vector3i> offsets = Geometry::partial_pack_rects(source_sizes, atlas_size);
+ Vector<Vector3i> offsets = Geometry2D::partial_pack_rects(source_sizes, atlas_size);
Vector<int> new_indices;
Vector<Vector2i> new_sources;
for (int i = 0; i < offsets.size(); i++) {
@@ -236,7 +261,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
//assign uv positions
for (int m_i = 0; m_i < mesh_instances.size(); m_i++) {
-
MeshInstance &mi = mesh_instances.write[m_i];
mi.offset.x = best_atlas_offsets[m_i].x;
mi.offset.y = best_atlas_offsets[m_i].y;
@@ -249,7 +273,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
}
void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i atlas_size, int atlas_slices, AABB &bounds, int grid_size, Vector<Probe> &probe_positions, GenerateProbes p_generate_probes, Vector<int> &slice_triangle_count, Vector<int> &slice_seam_count, RID &vertex_buffer, RID &triangle_buffer, RID &box_buffer, RID &lights_buffer, RID &triangle_cell_indices_buffer, RID &probe_positions_buffer, RID &grid_texture, RID &grid_texture_sdf, RID &seams_buffer, BakeStepFunc p_step_function, void *p_bake_userdata) {
-
HashMap<Vertex, uint32_t, VertexHash> vertex_map;
//fill triangles array and vertex array
@@ -269,7 +292,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
bounds = AABB();
for (int m_i = 0; m_i < mesh_instances.size(); m_i++) {
-
if (p_step_function) {
float p = float(m_i + 1) / mesh_instances.size() * 0.1;
p_step_function(0.3 + p, vformat(TTR("Plotting mesh into acceleration structure %d/%d"), m_i + 1, mesh_instances.size()), p_bake_userdata, false);
@@ -286,7 +308,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
}
for (int i = 0; i < mi.data.points.size(); i += 3) {
-
Vector3 vtxs[3] = { mi.data.points[i + 0], mi.data.points[i + 1], mi.data.points[i + 2] };
Vector2 uvs[3] = { mi.data.uv2[i + 0] * uv_scale + uv_offset, mi.data.uv2[i + 1] * uv_scale + uv_offset, mi.data.uv2[i + 2] * uv_scale + uv_offset };
Vector3 normal[3] = { mi.data.normal[i + 0], mi.data.normal[i + 1], mi.data.normal[i + 2] };
@@ -295,7 +316,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
Triangle t;
t.slice = mi.slice;
for (int k = 0; k < 3; k++) {
-
bounds.expand_to(vtxs[k]);
Vertex v;
@@ -397,7 +417,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
//fill list of triangles in grid
LocalVector<TriangleSort> triangle_sort;
for (uint32_t i = 0; i < triangles.size(); i++) {
-
const Triangle &t = triangles[i];
Vector3 face[3] = {
Vector3(vertex_array[t.indices[0]].position[0], vertex_array[t.indices[0]].position[1], vertex_array[t.indices[0]].position[2]),
@@ -469,9 +488,9 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
}
//generate SDF for raytracing
- Vector<uint32_t> euclidean_pos = Geometry::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), false);
- Vector<uint32_t> euclidean_neg = Geometry::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), true);
- Vector<int8_t> sdf8 = Geometry::generate_sdf8(euclidean_pos, euclidean_neg);
+ Vector<uint32_t> euclidean_pos = Geometry3D::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), false);
+ Vector<uint32_t> euclidean_neg = Geometry3D::generate_edf(solid, Vector3i(grid_size, grid_size, grid_size), true);
+ Vector<int8_t> sdf8 = Geometry3D::generate_sdf8(euclidean_pos, euclidean_neg);
/*****************************/
/*** CREATE GPU STRUCTURES ***/
@@ -541,7 +560,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
}
void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int atlas_slices, int grid_size, AABB bounds, float p_bias, Vector<int> slice_triangle_count, RID position_tex, RID unocclude_tex, RID normal_tex, RID raster_depth_buffer, RID rasterize_shader, RID raster_base_uniform) {
-
Vector<RID> framebuffers;
for (int i = 0; i < atlas_slices; i++) {
@@ -564,7 +582,6 @@ void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int
RID raster_pipeline = rd->render_pipeline_create(rasterize_shader, rd->framebuffer_get_format(framebuffers[0]), RD::INVALID_FORMAT_ID, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(3), 0);
RID raster_pipeline_wire;
{
-
RD::PipelineRasterizationState rw;
rw.wireframe = true;
raster_pipeline_wire = rd->render_pipeline_create(rasterize_shader, rd->framebuffer_get_format(framebuffers[0]), RD::INVALID_FORMAT_ID, RD::RENDER_PRIMITIVE_TRIANGLES, rw, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(3), 0);
@@ -577,7 +594,6 @@ void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int
clear_colors.push_back(Color(0, 0, 0, 0));
for (int i = 0; i < atlas_slices; i++) {
-
RasterPushConstant raster_push_constant;
raster_push_constant.atlas_size[0] = atlas_size.x;
raster_push_constant.atlas_size[1] = atlas_size.y;
@@ -614,7 +630,6 @@ void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int
}
LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_denoiser, int p_bounces, float p_bias, int p_max_texture_size, bool p_bake_sh, GenerateProbes p_generate_probes, const Ref<Image> &p_environment_panorama, const Basis &p_environment_transform, BakeStepFunc p_step_function, void *p_bake_userdata) {
-
if (p_step_function) {
p_step_function(0.0, TTR("Begin Bake"), p_bake_userdata, true);
}
@@ -810,7 +825,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
Vector<RD::Uniform> base_uniforms;
{
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 1;
@@ -945,7 +959,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
compute_shader.instance();
err = compute_shader->parse_versions_from_text(lm_compute_shader_glsl, p_bake_sh ? "\n#define USE_SH_LIGHTMAPS\n" : "");
if (err != OK) {
-
FREE_TEXTURES
FREE_BUFFERS
FREE_RASTER_RESOURCES
@@ -1032,11 +1045,9 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* UNOCCLUDE */
{
-
Vector<RD::Uniform> uniforms;
{
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_IMAGE;
u.binding = 0;
@@ -1074,11 +1085,9 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* PRIMARY (direct) LIGHT PASS */
{
-
Vector<RD::Uniform> uniforms;
{
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_IMAGE;
u.binding = 0;
@@ -1156,11 +1165,9 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
}
if (p_bounces > 0) {
-
Vector<RD::Uniform> uniforms;
{
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_IMAGE;
u.binding = 0;
@@ -1256,7 +1263,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < x_regions; i++) {
for (int j = 0; j < y_regions; j++) {
-
int x = i * max_region_size;
int y = j * max_region_size;
int w = MIN((i + 1) * max_region_size, atlas_size.width) - x;
@@ -1268,7 +1274,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
group_size = Vector3i((w - 1) / 8 + 1, (h - 1) / 8 + 1, 1);
for (int k = 0; k < ray_iterations; k++) {
-
RD::ComputeListID compute_list = rd->compute_list_begin();
rd->compute_list_bind_compute_pipeline(compute_list, compute_shader_secondary_pipeline);
rd->compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0);
@@ -1302,7 +1307,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
RID light_probe_buffer;
if (probe_positions.size()) {
-
light_probe_buffer = rd->storage_buffer_create(sizeof(float) * 4 * 9 * probe_positions.size());
if (p_step_function) {
@@ -1311,9 +1315,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
Vector<RD::Uniform> uniforms;
{
-
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_STORAGE_BUFFER;
u.binding = 0;
@@ -1366,7 +1368,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
int ray_iterations = (push_constant.ray_count - 1) / max_rays + 1;
for (int i = 0; i < ray_iterations; i++) {
-
RD::ComputeListID compute_list = rd->compute_list_begin();
rd->compute_list_bind_compute_pipeline(compute_list, compute_shader_light_probes_pipeline);
rd->compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0);
@@ -1456,13 +1457,11 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* DILATE LIGHTMAP */
{
-
SWAP(light_accum_tex, light_accum_tex2);
Vector<RD::Uniform> uniforms;
{
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_IMAGE;
u.binding = 0;
@@ -1537,7 +1536,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
rd->free(blendseams_triangle_raster_shader);
{
-
//pre copy
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
rd->texture_copy(light_accum_tex, light_accum_tex2, Vector3(), Vector3(), Vector3(atlas_size.width, atlas_size.height, 1), 0, 0, i, i, true);
@@ -1555,7 +1553,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
Vector<RD::Uniform> uniforms;
{
{
-
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 0;
@@ -1585,10 +1582,8 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
Vector<Color> clear_colors;
clear_colors.push_back(Color(0, 0, 0, 1));
for (int i = 0; i < atlas_slices; i++) {
-
int subslices = (p_bake_sh ? 4 : 1);
for (int k = 0; k < subslices; k++) {
-
RasterSeamsPushConstant seams_push_constant;
seams_push_constant.slice = uint32_t(i * subslices + k);
seams_push_constant.debug = debug;
@@ -1638,7 +1633,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
rd->draw_list_bind_render_pipeline(draw_list, blendseams_line_raster_pipeline);
for (int j = 1; j < uv_offset_count; j++) {
-
seams_push_constant.base_index = seam_offset;
seams_push_constant.uv_offset[0] = uv_offsets[j].x / float(atlas_size.width);
seams_push_constant.uv_offset[1] = uv_offsets[j].y / float(atlas_size.height);
@@ -1708,19 +1702,22 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
int LightmapperRD::get_bake_texture_count() const {
return bake_textures.size();
}
+
Ref<Image> LightmapperRD::get_bake_texture(int p_index) const {
ERR_FAIL_INDEX_V(p_index, bake_textures.size(), Ref<Image>());
return bake_textures[p_index];
}
+
int LightmapperRD::get_bake_mesh_count() const {
return mesh_instances.size();
}
+
Variant LightmapperRD::get_bake_mesh_userdata(int p_index) const {
ERR_FAIL_INDEX_V(p_index, mesh_instances.size(), Variant());
return mesh_instances[p_index].data.userdata;
}
-Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const {
+Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const {
ERR_FAIL_COND_V(bake_textures.size() == 0, Rect2());
Rect2 uv_ofs;
Vector2 atlas_size = Vector2(bake_textures[0]->get_width(), bake_textures[0]->get_height());
@@ -1728,6 +1725,7 @@ Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const {
uv_ofs.size = Vector2(mesh_instances[p_index].data.albedo_on_uv2->get_width(), mesh_instances[p_index].data.albedo_on_uv2->get_height()) / atlas_size;
return uv_ofs;
}
+
int LightmapperRD::get_bake_mesh_texture_slice(int p_index) const {
ERR_FAIL_INDEX_V(p_index, mesh_instances.size(), Variant());
return mesh_instances[p_index].slice;
diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h
index cb98efbeaa..6cb3ecbe9e 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
@@ -168,7 +198,6 @@ class LightmapperRD : public Lightmapper {
};
struct RasterSeamsPushConstant {
-
uint32_t base_index;
uint32_t slice;
float uv_offset[2];
diff --git a/modules/lightmapper_rd/lm_blendseams.glsl b/modules/lightmapper_rd/lm_blendseams.glsl
index ef1ece8ea1..e47e5fcc51 100644
--- a/modules/lightmapper_rd/lm_blendseams.glsl
+++ b/modules/lightmapper_rd/lm_blendseams.glsl
@@ -1,10 +1,9 @@
-/* clang-format off */
-[versions]
+#[versions]
-lines = "#define MODE_LINES"
-triangles = "#define MODE_TRIANGLES"
+lines = "#define MODE_LINES";
+triangles = "#define MODE_TRIANGLES";
-[vertex]
+#[vertex]
#version 450
@@ -12,23 +11,20 @@ VERSION_DEFINES
#include "lm_common_inc.glsl"
- /* clang-format on */
-
- layout(push_constant, binding = 0, std430) uniform Params {
- uint base_index;
- uint slice;
- vec2 uv_offset;
- bool debug;
- float blend;
- uint pad[2];
- } params;
+layout(push_constant, binding = 0, std430) uniform Params {
+ uint base_index;
+ uint slice;
+ vec2 uv_offset;
+ bool debug;
+ float blend;
+ uint pad[2];
+}
+params;
layout(location = 0) out vec3 uv_interp;
void main() {
-
#ifdef MODE_TRIANGLES
-
uint triangle_idx = params.base_index + gl_VertexIndex / 3;
uint triangle_subidx = gl_VertexIndex % 3;
@@ -43,7 +39,6 @@ void main() {
uv_interp = vec3(uv, float(params.slice));
gl_Position = vec4((uv + params.uv_offset) * 2.0 - 1.0, 0.0001, 1.0);
-
#endif
#ifdef MODE_LINES
@@ -72,12 +67,10 @@ void main() {
uv_interp = vec3(src_uv, float(params.slice));
gl_Position = vec4(dst_uv * 2.0 - 1.0, 0.0001, 1.0);
- ;
#endif
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
@@ -85,16 +78,15 @@ VERSION_DEFINES
#include "lm_common_inc.glsl"
- /* clang-format on */
-
- layout(push_constant, binding = 0, std430) uniform Params {
- uint base_index;
- uint slice;
- vec2 uv_offset;
- bool debug;
- float blend;
- uint pad[2];
- } params;
+layout(push_constant, binding = 0, std430) uniform Params {
+ uint base_index;
+ uint slice;
+ vec2 uv_offset;
+ bool debug;
+ float blend;
+ uint pad[2];
+}
+params;
layout(location = 0) in vec3 uv_interp;
@@ -103,7 +95,6 @@ layout(location = 0) out vec4 dst_color;
layout(set = 1, binding = 0) uniform texture2DArray src_color_tex;
void main() {
-
if (params.debug) {
#ifdef MODE_TRIANGLES
dst_color = vec4(1, 0, 1, 1);
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl
index a178bd9b2e..56976bd623 100644
--- a/modules/lightmapper_rd/lm_compute.glsl
+++ b/modules/lightmapper_rd/lm_compute.glsl
@@ -1,13 +1,12 @@
-/* clang-format off */
-[versions]
+#[versions]
-primary = "#define MODE_DIRECT_LIGHT"
-secondary = "#define MODE_BOUNCE_LIGHT"
-dilate = "#define MODE_DILATE"
-unocclude = "#define MODE_UNOCCLUDE"
-light_probes = "#define MODE_LIGHT_PROBES"
+primary = "#define MODE_DIRECT_LIGHT";
+secondary = "#define MODE_BOUNCE_LIGHT";
+dilate = "#define MODE_DILATE";
+unocclude = "#define MODE_UNOCCLUDE";
+light_probes = "#define MODE_LIGHT_PROBES";
-[compute]
+#[compute]
#version 450
@@ -29,8 +28,6 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
#include "lm_common_inc.glsl"
-/* clang-format on */
-
#ifdef MODE_LIGHT_PROBES
layout(set = 1, binding = 0, std430) restrict buffer LightProbeData {
@@ -97,7 +94,6 @@ params;
//check it, but also return distance and barycentric coords (for uv lookup)
bool ray_hits_triangle(vec3 from, vec3 dir, float max_dist, vec3 p0, vec3 p1, vec3 p2, out float r_distance, out vec3 r_barycentric) {
-
const vec3 e0 = p1 - p0;
const vec3 e1 = p0 - p2;
vec3 triangleNormal = cross(e1, e0);
@@ -122,7 +118,6 @@ bool trace_ray(vec3 p_from, vec3 p_to
out float r_distance, out vec3 r_normal
#endif
) {
-
/* world coords */
vec3 rel = p_to - p_from;
@@ -146,10 +141,8 @@ bool trace_ray(vec3 p_from, vec3 p_to
uint iters = 0;
while (all(greaterThanEqual(icell, ivec3(0))) && all(lessThan(icell, ivec3(params.grid_size))) && iters < 1000) {
-
uvec2 cell_data = texelFetch(usampler3D(grid, linear_sampler), icell, 0).xy;
if (cell_data.x > 0) { //triangles here
-
bool hit = false;
#if defined(MODE_UNOCCLUDE)
bool hit_backface = false;
@@ -211,7 +204,6 @@ bool trace_ray(vec3 p_from, vec3 p_to
r_triangle = tidx;
r_barycentric = barycentric;
}
-
#endif
}
}
@@ -258,7 +250,6 @@ float quick_hash(vec2 pos) {
}
void main() {
-
#ifdef MODE_LIGHT_PROBES
int probe_index = int(gl_GlobalInvocationID.x);
if (probe_index >= params.atlas_size.x) { //too large, do nothing
@@ -294,7 +285,6 @@ void main() {
#endif
for (uint i = 0; i < params.light_count; i++) {
-
vec3 light_pos;
float attenuation;
if (lights.data[i].type == LIGHT_TYPE_DIRECTIONAL) {
@@ -313,7 +303,6 @@ void main() {
attenuation = pow(max(1.0 - d, 0.0), lights.data[i].attenuation);
if (lights.data[i].type == LIGHT_TYPE_SPOT) {
-
vec3 rel = normalize(position - light_pos);
float angle = acos(dot(rel, lights.data[i].direction));
if (angle > lights.data[i].spot_angle) {
@@ -512,7 +501,6 @@ void main() {
vec3 norm;
if (trace_ray(base_pos, ray_to, d, norm)) {
-
if (d < min_d) {
vertex_pos = base_pos + rays[i] * d + norm * params.bias * 10.0; //this bias needs to be greater than the regular bias, because otherwise later, rays will go the other side when pointing back.
min_d = d;
@@ -561,7 +549,6 @@ void main() {
light = textureLod(sampler2DArray(source_light, linear_sampler), uvw, 0.0).rgb;
light += textureLod(sampler2DArray(source_direct_light, linear_sampler), uvw, 0.0).rgb;
} else {
-
//did not hit a triangle, reach out for the sky
vec3 sky_dir = normalize(mat3(params.env_transform) * ray_dir);
diff --git a/modules/lightmapper_rd/lm_raster.glsl b/modules/lightmapper_rd/lm_raster.glsl
index ae3038aead..6c2904192b 100644
--- a/modules/lightmapper_rd/lm_raster.glsl
+++ b/modules/lightmapper_rd/lm_raster.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
@@ -7,9 +6,7 @@ VERSION_DEFINES
#include "lm_common_inc.glsl"
- /* clang-format on */
-
- layout(location = 0) out vec3 vertex_interp;
+layout(location = 0) out vec3 vertex_interp;
layout(location = 1) out vec3 normal_interp;
layout(location = 2) out vec2 uv_interp;
layout(location = 3) out vec3 barycentric;
@@ -28,10 +25,7 @@ layout(push_constant, binding = 0, std430) uniform Params {
}
params;
-/* clang-format on */
-
void main() {
-
uint triangle_idx = params.base_triangle + gl_VertexIndex / 3;
uint triangle_subidx = gl_VertexIndex % 3;
@@ -56,12 +50,9 @@ void main() {
face_normal = -normalize(cross((vertices.data[vertex_indices.x].position - vertices.data[vertex_indices.y].position), (vertices.data[vertex_indices.x].position - vertices.data[vertex_indices.z].position)));
gl_Position = vec4((uv_interp + params.uv_offset) * 2.0 - 1.0, 0.0001, 1.0);
- ;
}
-/* clang-format off */
-
-[fragment]
+#[fragment]
#version 450
@@ -69,7 +60,6 @@ VERSION_DEFINES
#include "lm_common_inc.glsl"
-
layout(push_constant, binding = 0, std430) uniform Params {
vec2 atlas_size;
vec2 uv_offset;
@@ -79,9 +69,8 @@ layout(push_constant, binding = 0, std430) uniform Params {
float bias;
ivec3 grid_size;
uint pad2;
-} params;
-
-/* clang-format on */
+}
+params;
layout(location = 0) in vec3 vertex_interp;
layout(location = 1) in vec3 normal_interp;
@@ -95,13 +84,11 @@ layout(location = 1) out vec4 normal;
layout(location = 2) out vec4 unocclude;
void main() {
-
vec3 vertex_pos = vertex_interp;
{
// smooth out vertex position by interpolating its projection in the 3 normal planes (normal plane is created by vertex pos and normal)
// because we don't want to interpolate inwards, normals found pointing inwards are pushed out.
-
vec3 pos_a = vertices.data[vertex_indices.x].position;
vec3 pos_b = vertices.data[vertex_indices.y].position;
vec3 pos_c = vertices.data[vertex_indices.z].position;
diff --git a/modules/lightmapper_rd/register_types.cpp b/modules/lightmapper_rd/register_types.cpp
index f3938f3190..0e6d7590cc 100644
--- a/modules/lightmapper_rd/register_types.cpp
+++ b/modules/lightmapper_rd/register_types.cpp
@@ -41,7 +41,6 @@ static Lightmapper *create_lightmapper_rd() {
#endif
void register_lightmapper_rd_types() {
-
GLOBAL_DEF("rendering/gpu_lightmapper/quality/low_quality_ray_count", 16);
GLOBAL_DEF("rendering/gpu_lightmapper/quality/medium_quality_ray_count", 64);
GLOBAL_DEF("rendering/gpu_lightmapper/quality/high_quality_ray_count", 256);
diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp
index a47a4503a5..1f9d8c2aa3 100644
--- a/modules/mbedtls/crypto_mbedtls.cpp
+++ b/modules/mbedtls/crypto_mbedtls.cpp
@@ -155,7 +155,6 @@ Crypto *CryptoMbedTLS::create() {
}
void CryptoMbedTLS::initialize_crypto() {
-
#ifdef DEBUG_ENABLED
mbedtls_debug_set_threshold(1);
#endif
diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h
index db3d00a5e3..48855d082a 100644
--- a/modules/mbedtls/crypto_mbedtls.h
+++ b/modules/mbedtls/crypto_mbedtls.h
@@ -41,7 +41,6 @@
class CryptoMbedTLS;
class SSLContextMbedTLS;
class CryptoKeyMbedTLS : public CryptoKey {
-
private:
mbedtls_pk_context pkey;
int locks;
@@ -70,7 +69,6 @@ public:
};
class X509CertificateMbedTLS : public X509Certificate {
-
private:
mbedtls_x509_crt cert;
int locks;
@@ -100,7 +98,6 @@ public:
};
class CryptoMbedTLS : public Crypto {
-
private:
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp
index f31f067f4e..d9961b026f 100644
--- a/modules/mbedtls/dtls_server_mbedtls.cpp
+++ b/modules/mbedtls/dtls_server_mbedtls.cpp
@@ -54,12 +54,10 @@ Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_
}
DTLSServer *DTLSServerMbedTLS::_create_func() {
-
return memnew(DTLSServerMbedTLS);
}
void DTLSServerMbedTLS::initialize() {
-
_create = _create_func;
available = true;
}
diff --git a/modules/mbedtls/dtls_server_mbedtls.h b/modules/mbedtls/dtls_server_mbedtls.h
index d61ab3179e..d93553bf7f 100644
--- a/modules/mbedtls/dtls_server_mbedtls.h
+++ b/modules/mbedtls/dtls_server_mbedtls.h
@@ -35,7 +35,6 @@
#include "ssl_context_mbedtls.h"
class DTLSServerMbedTLS : public DTLSServer {
-
private:
static DTLSServer *_create_func();
Ref<CryptoKey> _key;
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp
index 37477e1246..8206d739ae 100644
--- a/modules/mbedtls/packet_peer_mbed_dtls.cpp
+++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp
@@ -35,9 +35,9 @@
#include "core/os/file_access.h"
int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
-
- if (buf == nullptr || len <= 0)
+ if (buf == nullptr || len <= 0) {
return 0;
+ }
PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
@@ -53,9 +53,9 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len
}
int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
-
- if (buf == nullptr || len <= 0)
+ if (buf == nullptr || len <= 0) {
return 0;
+ }
PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
@@ -79,7 +79,6 @@ int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
}
void PacketPeerMbedDTLS::_cleanup() {
-
ssl_ctx->clear();
base = Ref<PacketPeer>();
status = STATUS_DISCONNECTED;
@@ -116,7 +115,6 @@ Error PacketPeerMbedDTLS::_do_handshake() {
}
Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs, const String &p_for_hostname, Ref<X509Certificate> p_ca_certs) {
-
ERR_FAIL_COND_V(!p_base.is_valid() || !p_base->is_connected_to_host(), ERR_INVALID_PARAMETER);
base = p_base;
@@ -141,7 +139,6 @@ Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_vali
}
Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain, Ref<CookieContextMbedTLS> p_cookies) {
-
Error err = ssl_ctx->init_server(MBEDTLS_SSL_TRANSPORT_DATAGRAM, MBEDTLS_SSL_VERIFY_NONE, p_key, p_cert, p_cookies);
ERR_FAIL_COND_V(err != OK, err);
@@ -170,11 +167,11 @@ Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey>
}
Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
- if (p_bytes == 0)
+ if (p_bytes == 0) {
return OK;
+ }
int ret = mbedtls_ssl_write(ssl_ctx->get_context(), p_buffer, p_bytes);
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
@@ -189,7 +186,6 @@ Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) {
}
Error PacketPeerMbedDTLS::get_packet(const uint8_t **r_buffer, int &r_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
r_bytes = 0;
@@ -215,7 +211,6 @@ Error PacketPeerMbedDTLS::get_packet(const uint8_t **r_buffer, int &r_bytes) {
}
void PacketPeerMbedDTLS::poll() {
-
if (status == STATUS_HANDSHAKING) {
_do_handshake();
return;
@@ -240,19 +235,16 @@ void PacketPeerMbedDTLS::poll() {
}
int PacketPeerMbedDTLS::get_available_packet_count() const {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, 0);
return mbedtls_ssl_get_bytes_avail(&(ssl_ctx->ssl)) > 0 ? 1 : 0;
}
int PacketPeerMbedDTLS::get_max_packet_size() const {
-
return 488; // 512 (UDP in Godot) - 24 (DTLS header)
}
PacketPeerMbedDTLS::PacketPeerMbedDTLS() {
-
ssl_ctx.instance();
status = STATUS_DISCONNECTED;
}
@@ -262,33 +254,30 @@ PacketPeerMbedDTLS::~PacketPeerMbedDTLS() {
}
void PacketPeerMbedDTLS::disconnect_from_peer() {
-
- if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
+ if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING) {
return;
+ }
if (status == STATUS_CONNECTED) {
int ret = 0;
// Send SSL close notification, blocking, but ignore other errors.
- do
+ do {
ret = mbedtls_ssl_close_notify(ssl_ctx->get_context());
- while (ret == MBEDTLS_ERR_SSL_WANT_WRITE);
+ } while (ret == MBEDTLS_ERR_SSL_WANT_WRITE);
}
_cleanup();
}
PacketPeerMbedDTLS::Status PacketPeerMbedDTLS::get_status() const {
-
return status;
}
PacketPeerDTLS *PacketPeerMbedDTLS::_create_func() {
-
return memnew(PacketPeerMbedDTLS);
}
void PacketPeerMbedDTLS::initialize_dtls() {
-
_create = _create_func;
available = true;
}
diff --git a/modules/mbedtls/register_types.cpp b/modules/mbedtls/register_types.cpp
index d39af7fe87..84a27c29bd 100755..100644
--- a/modules/mbedtls/register_types.cpp
+++ b/modules/mbedtls/register_types.cpp
@@ -36,7 +36,6 @@
#include "stream_peer_mbedtls.h"
void register_mbedtls_types() {
-
CryptoMbedTLS::initialize_crypto();
StreamPeerMbedTLS::initialize_ssl();
PacketPeerMbedDTLS::initialize_dtls();
@@ -44,7 +43,6 @@ void register_mbedtls_types() {
}
void unregister_mbedtls_types() {
-
DTLSServerMbedTLS::finalize();
PacketPeerMbedDTLS::finalize_dtls();
StreamPeerMbedTLS::finalize_ssl();
diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp
index 1ffb9bda05..a2200e0644 100644
--- a/modules/mbedtls/ssl_context_mbedtls.cpp
+++ b/modules/mbedtls/ssl_context_mbedtls.cpp
@@ -33,7 +33,6 @@
static void my_debug(void *ctx, int level,
const char *file, int line,
const char *str) {
-
printf("%s:%04d: %s", file, line, str);
fflush(stdout);
}
@@ -68,8 +67,9 @@ Error CookieContextMbedTLS::setup() {
}
void CookieContextMbedTLS::clear() {
- if (!inited)
+ if (!inited) {
return;
+ }
mbedtls_ctr_drbg_free(&ctr_drbg);
mbedtls_entropy_free(&entropy);
mbedtls_ssl_cookie_free(&cookie_ctx);
@@ -121,10 +121,12 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto
// Locking key and certificate(s)
pkey = p_pkey;
certs = p_cert;
- if (pkey.is_valid())
+ if (pkey.is_valid()) {
pkey->lock();
- if (certs.is_valid())
+ }
+ if (certs.is_valid()) {
certs->lock();
+ }
// Adding key and certificate
int ret = mbedtls_ssl_conf_own_cert(&conf, &(certs->cert), &(pkey->pkey));
@@ -176,19 +178,22 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce
}
void SSLContextMbedTLS::clear() {
- if (!inited)
+ if (!inited) {
return;
+ }
mbedtls_ssl_free(&ssl);
mbedtls_ssl_config_free(&conf);
mbedtls_ctr_drbg_free(&ctr_drbg);
mbedtls_entropy_free(&entropy);
// Unlock and key and certificates
- if (certs.is_valid())
+ if (certs.is_valid()) {
certs->unlock();
+ }
certs = Ref<X509Certificate>();
- if (pkey.is_valid())
+ if (pkey.is_valid()) {
pkey->unlock();
+ }
pkey = Ref<CryptoKeyMbedTLS>();
cookies = Ref<CookieContextMbedTLS>();
inited = false;
diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h
index d3e1f87a8e..baaeb6eb85 100644
--- a/modules/mbedtls/ssl_context_mbedtls.h
+++ b/modules/mbedtls/ssl_context_mbedtls.h
@@ -47,7 +47,6 @@
class SSLContextMbedTLS;
class CookieContextMbedTLS : public Reference {
-
friend class SSLContextMbedTLS;
protected:
@@ -65,7 +64,6 @@ public:
};
class SSLContextMbedTLS : public Reference {
-
protected:
bool inited;
diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp
index af36b29dac..e9a610b7ee 100644
--- a/modules/mbedtls/stream_peer_mbedtls.cpp
+++ b/modules/mbedtls/stream_peer_mbedtls.cpp
@@ -34,9 +34,9 @@
#include "core/os/file_access.h"
int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
-
- if (buf == nullptr || len <= 0)
+ if (buf == nullptr || len <= 0) {
return 0;
+ }
StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
@@ -54,9 +54,9 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len)
}
int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
-
- if (buf == nullptr || len <= 0)
+ if (buf == nullptr || len <= 0) {
return 0;
+ }
StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
@@ -74,7 +74,6 @@ int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
}
void StreamPeerMbedTLS::_cleanup() {
-
ssl_ctx->clear();
base = Ref<StreamPeer>();
status = STATUS_DISCONNECTED;
@@ -104,7 +103,6 @@ Error StreamPeerMbedTLS::_do_handshake() {
}
Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String &p_for_hostname, Ref<X509Certificate> p_ca_certs) {
-
ERR_FAIL_COND_V(p_base.is_null(), ERR_INVALID_PARAMETER);
base = p_base;
@@ -127,7 +125,6 @@ Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida
}
Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain) {
-
ERR_FAIL_COND_V(p_base.is_null(), ERR_INVALID_PARAMETER);
Error err = ssl_ctx->init_server(MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_VERIFY_NONE, p_key, p_cert);
@@ -146,8 +143,8 @@ Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base, Ref<CryptoKey> p_
status = STATUS_CONNECTED;
return OK;
}
-Error StreamPeerMbedTLS::put_data(const uint8_t *p_data, int p_bytes) {
+Error StreamPeerMbedTLS::put_data(const uint8_t *p_data, int p_bytes) {
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
Error err;
@@ -168,13 +165,13 @@ Error StreamPeerMbedTLS::put_data(const uint8_t *p_data, int p_bytes) {
}
Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
r_sent = 0;
- if (p_bytes == 0)
+ if (p_bytes == 0) {
return OK;
+ }
int ret = mbedtls_ssl_write(ssl_ctx->get_context(), p_data, p_bytes);
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
@@ -195,14 +192,12 @@ Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, in
}
Error StreamPeerMbedTLS::get_data(uint8_t *p_buffer, int p_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
Error err;
int got = 0;
while (p_bytes > 0) {
-
err = get_partial_data(p_buffer, p_bytes, got);
if (err != OK) {
@@ -217,7 +212,6 @@ Error StreamPeerMbedTLS::get_data(uint8_t *p_buffer, int p_bytes) {
}
Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
r_received = 0;
@@ -240,7 +234,6 @@ Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r
}
void StreamPeerMbedTLS::poll() {
-
ERR_FAIL_COND(status != STATUS_CONNECTED && status != STATUS_HANDSHAKING);
ERR_FAIL_COND(!base.is_valid());
@@ -274,13 +267,12 @@ void StreamPeerMbedTLS::poll() {
}
int StreamPeerMbedTLS::get_available_bytes() const {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, 0);
return mbedtls_ssl_get_bytes_avail(&(ssl_ctx->ssl));
}
-StreamPeerMbedTLS::StreamPeerMbedTLS() {
+StreamPeerMbedTLS::StreamPeerMbedTLS() {
ssl_ctx.instance();
status = STATUS_DISCONNECTED;
}
@@ -290,9 +282,9 @@ StreamPeerMbedTLS::~StreamPeerMbedTLS() {
}
void StreamPeerMbedTLS::disconnect_from_stream() {
-
- if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
+ if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING) {
return;
+ }
Ref<StreamPeerTCP> tcp = base;
if (tcp.is_valid() && tcp->get_status() == StreamPeerTCP::STATUS_CONNECTED) {
@@ -304,23 +296,19 @@ void StreamPeerMbedTLS::disconnect_from_stream() {
}
StreamPeerMbedTLS::Status StreamPeerMbedTLS::get_status() const {
-
return status;
}
StreamPeerSSL *StreamPeerMbedTLS::_create_func() {
-
return memnew(StreamPeerMbedTLS);
}
void StreamPeerMbedTLS::initialize_ssl() {
-
_create = _create_func;
available = true;
}
void StreamPeerMbedTLS::finalize_ssl() {
-
available = false;
_create = nullptr;
}
diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp
index 6d10de0096..a2fb443ef0 100644
--- a/modules/mobile_vr/mobile_vr_interface.cpp
+++ b/modules/mobile_vr/mobile_vr_interface.cpp
@@ -61,19 +61,25 @@ Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) {
};
// adjust our min and max
- if (mag_raw.x > mag_next_max.x)
+ if (mag_raw.x > mag_next_max.x) {
mag_next_max.x = mag_raw.x;
- if (mag_raw.y > mag_next_max.y)
+ }
+ if (mag_raw.y > mag_next_max.y) {
mag_next_max.y = mag_raw.y;
- if (mag_raw.z > mag_next_max.z)
+ }
+ if (mag_raw.z > mag_next_max.z) {
mag_next_max.z = mag_raw.z;
+ }
- if (mag_raw.x < mag_next_min.x)
+ if (mag_raw.x < mag_next_min.x) {
mag_next_min.x = mag_raw.x;
- if (mag_raw.y < mag_next_min.y)
+ }
+ if (mag_raw.y < mag_next_min.y) {
mag_next_min.y = mag_raw.y;
- if (mag_raw.z < mag_next_min.z)
+ }
+ if (mag_raw.z < mag_next_min.z) {
mag_next_min.z = mag_raw.z;
+ }
// scale our x, y and z
if (!(mag_current_max.x - mag_current_min.x)) {
@@ -442,12 +448,6 @@ void MobileVRInterface::process() {
};
};
-void MobileVRInterface::notification(int p_what){
- _THREAD_SAFE_METHOD_
-
- // nothing to do here, I guess we could pauze our sensors...
-}
-
MobileVRInterface::MobileVRInterface() {
initialized = false;
diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h
index 3a9ed1314a..e986a4a3de 100644
--- a/modules/mobile_vr/mobile_vr_interface.h
+++ b/modules/mobile_vr/mobile_vr_interface.h
@@ -142,7 +142,7 @@ public:
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
virtual void process();
- virtual void notification(int p_what);
+ virtual void notification(int p_what) {}
MobileVRInterface();
~MobileVRInterface();
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index c723b210cb..e8f3174a0a 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -29,7 +29,7 @@ if env_mono["tools"] or env_mono["target"] != "release":
mono_configure.configure(env, env_mono)
-if env_mono["tools"] and env_mono["mono_glue"]:
+if env_mono["tools"] and env_mono["mono_glue"] and env_mono["build_cil"]:
# Build Godot API solution
import build_scripts.api_solution_build as api_solution_build
diff --git a/modules/mono/build_scripts/godot_tools_build.py b/modules/mono/build_scripts/godot_tools_build.py
index 7391e8790d..3bbbf29d3b 100644
--- a/modules/mono/build_scripts/godot_tools_build.py
+++ b/modules/mono/build_scripts/godot_tools_build.py
@@ -15,7 +15,9 @@ def build_godot_tools(source, target, env):
from .solution_builder import build_solution
- build_solution(env, solution_path, build_config)
+ extra_msbuild_args = ["/p:GodotPlatform=" + env["platform"]]
+
+ build_solution(env, solution_path, build_config, extra_msbuild_args)
# No need to copy targets. The GodotTools csproj takes care of copying them.
diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py
index 23f01b3cca..80e3b59325 100644
--- a/modules/mono/build_scripts/mono_configure.py
+++ b/modules/mono/build_scripts/mono_configure.py
@@ -191,17 +191,16 @@ def configure(env, env_mono):
env.Append(LIBS=["psapi"])
env.Append(LIBS=["version"])
else:
- mono_lib_name = find_name_in_dir_files(
- mono_lib_path, mono_lib_names, prefixes=["", "lib"], extensions=lib_suffixes
- )
+ mono_lib_file = find_file_in_dir(mono_lib_path, mono_lib_names, extensions=lib_suffixes)
- if not mono_lib_name:
+ if not mono_lib_file:
raise RuntimeError("Could not find mono library in: " + mono_lib_path)
if env.msvc:
- env.Append(LINKFLAGS=mono_lib_name + ".lib")
+ env.Append(LINKFLAGS=mono_lib_file)
else:
- env.Append(LIBS=[mono_lib_name])
+ mono_lib_file_path = os.path.join(mono_lib_path, mono_lib_file)
+ env.Append(LINKFLAGS=mono_lib_file_path)
mono_bin_path = os.path.join(mono_root, "bin")
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp
index 384685d04b..39e3a95afa 100644
--- a/modules/mono/class_db_api_json.cpp
+++ b/modules/mono/class_db_api_json.cpp
@@ -45,14 +45,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
const StringName *k = nullptr;
while ((k = ClassDB::classes.next(k))) {
-
names.push_back(*k);
}
//must be alphabetically sorted for hash to compute
names.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
ClassDB::ClassInfo *t = ClassDB::classes.getptr(E->get());
ERR_FAIL_COND(!t);
if (t->api != p_api || !t->exposed)
@@ -70,7 +68,6 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
k = nullptr;
while ((k = t->method_map.next(k))) {
-
String name = k->operator String();
ERR_CONTINUE(name.empty());
@@ -135,7 +132,6 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
k = nullptr;
while ((k = t->constant_map.next(k))) {
-
snames.push_back(*k);
}
@@ -163,7 +159,6 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
k = nullptr;
while ((k = t->signal_map.next(k))) {
-
snames.push_back(*k);
}
@@ -199,7 +194,6 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
k = nullptr;
while ((k = t->property_setget.next(k))) {
-
snames.push_back(*k);
}
diff --git a/modules/mono/config.py b/modules/mono/config.py
index d41f3755b5..7980a86cb3 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -30,6 +30,7 @@ def configure(env):
)
envvars.Add(BoolVariable("mono_static", "Statically link mono", default_mono_static))
envvars.Add(BoolVariable("mono_glue", "Build with the mono glue sources", True))
+ envvars.Add(BoolVariable("build_cil", "Build C# solutions", True))
envvars.Add(
BoolVariable(
"copy_mono_root", "Make a copy of the mono installation directory to bundle with the editor", False
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 7d00d2d314..ae25bd3544 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -67,7 +67,6 @@
#ifdef TOOLS_ENABLED
static bool _create_project_solution_if_needed() {
-
String sln_path = GodotSharpDirs::get_project_sln_path();
String csproj_path = GodotSharpDirs::get_project_csproj_path();
@@ -85,28 +84,23 @@ static bool _create_project_solution_if_needed() {
CSharpLanguage *CSharpLanguage::singleton = nullptr;
String CSharpLanguage::get_name() const {
-
return "C#";
}
String CSharpLanguage::get_type() const {
-
return "CSharpScript";
}
String CSharpLanguage::get_extension() const {
-
return "cs";
}
Error CSharpLanguage::execute_file(const String &p_path) {
-
// ??
return OK;
}
void CSharpLanguage::init() {
-
#ifdef DEBUG_METHODS_ENABLED
if (OS::get_singleton()->get_cmdline_args().find("--class-db-json")) {
class_db_api_to_json("user://class_db_api.json", ClassDB::API_CORE);
@@ -140,7 +134,6 @@ void CSharpLanguage::init() {
}
void CSharpLanguage::finish() {
-
if (finalized)
return;
@@ -184,7 +177,6 @@ void CSharpLanguage::finish() {
}
void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
-
static const char *_reserved_words[] = {
// Reserved keywords
"abstract",
@@ -295,7 +287,7 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
"when",
"where",
"yield",
- 0
+ nullptr
};
const char **w = _reserved_words;
@@ -307,13 +299,11 @@ void CSharpLanguage::get_reserved_words(List<String> *p_words) const {
}
void CSharpLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
-
p_delimiters->push_back("//"); // single-line comment
p_delimiters->push_back("/* */"); // delimited comment
}
void CSharpLanguage::get_string_delimiters(List<String> *p_delimiters) const {
-
p_delimiters->push_back("' '"); // character literal
p_delimiters->push_back("\" \""); // regular string literal
// Verbatim string literals (`@" "`) don't render correctly, so don't highlight them.
@@ -321,7 +311,6 @@ void CSharpLanguage::get_string_delimiters(List<String> *p_delimiters) const {
}
static String get_base_class_name(const String &p_base_class_name, const String p_class_name) {
-
String base_class = p_base_class_name;
if (p_class_name == base_class) {
base_class = "Godot." + base_class;
@@ -330,7 +319,6 @@ static String get_base_class_name(const String &p_base_class_name, const String
}
Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
-
String script_template = "using " BINDINGS_NAMESPACE ";\n"
"using System;\n"
"\n"
@@ -366,12 +354,10 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin
}
bool CSharpLanguage::is_using_templates() {
-
return true;
}
void CSharpLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {
-
String src = p_script->get_source_code();
String base_class_name = get_base_class_name(p_base_class_name, p_class_name);
src = src.replace("%BASE%", base_class_name)
@@ -381,7 +367,6 @@ void CSharpLanguage::make_template(const String &p_class_name, const String &p_b
}
String CSharpLanguage::validate_path(const String &p_path) const {
-
String class_name = p_path.get_file().get_basename();
List<String> keywords;
get_reserved_words(&keywords);
@@ -392,23 +377,19 @@ String CSharpLanguage::validate_path(const String &p_path) const {
}
Script *CSharpLanguage::create_script() const {
-
return memnew(CSharpScript);
}
bool CSharpLanguage::has_named_classes() const {
-
return false;
}
bool CSharpLanguage::supports_builtin_mode() const {
-
return false;
}
#ifdef TOOLS_ENABLED
static String variant_type_to_managed_name(const String &p_var_type_name) {
-
if (p_var_type_name.empty())
return "object";
@@ -531,12 +512,10 @@ String CSharpLanguage::_get_indentation() const {
}
String CSharpLanguage::debug_get_error() const {
-
return _debug_error;
}
int CSharpLanguage::debug_get_stack_level_count() const {
-
if (_debug_parse_err_line >= 0)
return 1;
@@ -545,7 +524,6 @@ int CSharpLanguage::debug_get_stack_level_count() const {
}
int CSharpLanguage::debug_get_stack_level_line(int p_level) const {
-
if (_debug_parse_err_line >= 0)
return _debug_parse_err_line;
@@ -554,7 +532,6 @@ int CSharpLanguage::debug_get_stack_level_line(int p_level) const {
}
String CSharpLanguage::debug_get_stack_level_function(int p_level) const {
-
if (_debug_parse_err_line >= 0)
return String();
@@ -563,7 +540,6 @@ String CSharpLanguage::debug_get_stack_level_function(int p_level) const {
}
String CSharpLanguage::debug_get_stack_level_source(int p_level) const {
-
if (_debug_parse_err_line >= 0)
return _debug_parse_err_file;
@@ -572,7 +548,6 @@ String CSharpLanguage::debug_get_stack_level_source(int p_level) const {
}
Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info() {
-
#ifdef DEBUG_ENABLED
// Printing an error here will result in endless recursion, so we must be careful
static thread_local bool _recursion_flag_ = false;
@@ -604,7 +579,6 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info()
#ifdef DEBUG_ENABLED
Vector<ScriptLanguage::StackInfo> CSharpLanguage::stack_trace_get_info(MonoObject *p_stack_trace) {
-
// Printing an error here will result in endless recursion, so we must be careful
static thread_local bool _recursion_flag_ = false;
if (_recursion_flag_)
@@ -678,7 +652,6 @@ void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) {
}
void CSharpLanguage::frame() {
-
if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != nullptr) {
const Ref<MonoGCHandleRef> &task_scheduler_handle = GDMonoCache::cached_data.task_scheduler_handle;
@@ -698,7 +671,6 @@ void CSharpLanguage::frame() {
}
struct CSharpScriptDepSort {
-
// must support sorting so inheritance works properly (parent must be reloaded first)
bool operator()(const Ref<CSharpScript> &A, const Ref<CSharpScript> &B) const {
if (A == B)
@@ -718,7 +690,6 @@ struct CSharpScriptDepSort {
};
void CSharpLanguage::reload_all_scripts() {
-
#ifdef GD_MONO_HOT_RELOAD
if (is_assembly_reloading_needed()) {
GD_MONO_SCOPE_THREAD_ATTACH;
@@ -728,7 +699,6 @@ void CSharpLanguage::reload_all_scripts() {
}
void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
-
(void)p_script; // UNUSED
CRASH_COND(!Engine::get_singleton()->is_editor_hint());
@@ -747,7 +717,6 @@ void CSharpLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft
#ifdef GD_MONO_HOT_RELOAD
bool CSharpLanguage::is_assembly_reloading_needed() {
-
if (!gdmono->is_runtime_initialized())
return false;
@@ -782,7 +751,6 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
}
void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
-
if (!gdmono->is_runtime_initialized())
return;
@@ -1173,7 +1141,6 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
#endif
void CSharpLanguage::_load_scripts_metadata() {
-
scripts_metadata.clear();
String scripts_metadata_filename = "scripts_metadata.";
@@ -1218,24 +1185,20 @@ void CSharpLanguage::_load_scripts_metadata() {
}
void CSharpLanguage::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("cs");
}
#ifdef TOOLS_ENABLED
Error CSharpLanguage::open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) {
-
return (Error)(int)get_godotsharp_editor()->call("OpenInExternalEditor", p_script, p_line, p_col);
}
bool CSharpLanguage::overrides_external_editor() {
-
return get_godotsharp_editor()->call("OverridesExternalEditor");
}
#endif
void CSharpLanguage::thread_enter() {
-
#if 0
if (gdmono->is_runtime_initialized()) {
GDMonoUtils::attach_current_thread();
@@ -1244,7 +1207,6 @@ void CSharpLanguage::thread_enter() {
}
void CSharpLanguage::thread_exit() {
-
#if 0
if (gdmono->is_runtime_initialized()) {
GDMonoUtils::detach_current_thread();
@@ -1253,7 +1215,6 @@ void CSharpLanguage::thread_exit() {
}
bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const String &p_error) {
-
// Not a parser error in our case, but it's still used for other type of errors
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_line = p_line;
@@ -1267,7 +1228,6 @@ bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const S
}
bool CSharpLanguage::debug_break(const String &p_error, bool p_allow_continue) {
-
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_line = -1;
_debug_parse_err_file = "";
@@ -1301,7 +1261,6 @@ void CSharpLanguage::_on_scripts_domain_unloaded() {
#ifdef TOOLS_ENABLED
void CSharpLanguage::_editor_init_callback() {
-
register_editor_internal_calls();
// Initialize GodotSharpEditor
@@ -1328,13 +1287,11 @@ void CSharpLanguage::_editor_init_callback() {
#endif
void CSharpLanguage::set_language_index(int p_idx) {
-
ERR_FAIL_COND(lang_idx != -1);
lang_idx = p_idx;
}
void CSharpLanguage::release_script_gchandle(MonoGCHandleData &p_gchandle) {
-
if (!p_gchandle.is_released()) { // Do not lock unnecessarily
MutexLock lock(get_singleton()->script_gchandle_release_mutex);
p_gchandle.release();
@@ -1342,7 +1299,6 @@ void CSharpLanguage::release_script_gchandle(MonoGCHandleData &p_gchandle) {
}
void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, MonoGCHandleData &p_gchandle) {
-
uint32_t pinned_gchandle = GDMonoUtils::new_strong_gchandle_pinned(p_expected_obj); // We might lock after this, so pin it
if (!p_gchandle.is_released()) { // Do not lock unnecessarily
@@ -1363,19 +1319,16 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, MonoGCH
}
CSharpLanguage::CSharpLanguage() {
-
ERR_FAIL_COND_MSG(singleton, "C# singleton already exist.");
singleton = this;
}
CSharpLanguage::~CSharpLanguage() {
-
finish();
singleton = nullptr;
}
bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_binding, Object *p_object) {
-
#ifdef DEBUG_ENABLED
// I don't trust you
if (p_object->get_script_instance()) {
@@ -1424,7 +1377,6 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
}
void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) {
-
MutexLock lock(language_bind_mutex);
Map<Object *, CSharpScriptBinding>::Element *match = script_bindings.find(p_object);
@@ -1440,12 +1392,10 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) {
}
Map<Object *, CSharpScriptBinding>::Element *CSharpLanguage::insert_script_binding(Object *p_object, const CSharpScriptBinding &p_script_binding) {
-
return script_bindings.insert(p_object, p_script_binding);
}
void CSharpLanguage::free_instance_binding_data(void *p_data) {
-
if (GDMono::get_singleton() == nullptr) {
#ifdef DEBUG_ENABLED
CRASH_COND(!script_bindings.empty());
@@ -1481,7 +1431,6 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) {
}
void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) {
-
Reference *ref_owner = Object::cast_to<Reference>(p_object);
#ifdef DEBUG_ENABLED
@@ -1517,7 +1466,6 @@ void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) {
}
bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) {
-
Reference *ref_owner = Object::cast_to<Reference>(p_object);
#ifdef DEBUG_ENABLED
@@ -1558,7 +1506,6 @@ bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) {
}
CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpScript *p_script, const MonoGCHandleData &p_gchandle) {
-
CSharpInstance *instance = memnew(CSharpInstance(Ref<CSharpScript>(p_script)));
Reference *ref = Object::cast_to<Reference>(p_owner);
@@ -1576,7 +1523,6 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS
}
MonoObject *CSharpInstance::get_mono_object() const {
-
ERR_FAIL_COND_V(gchandle.is_released(), nullptr);
return gchandle.get_target();
}
@@ -1586,7 +1532,6 @@ Object *CSharpInstance::get_owner() {
}
bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) {
-
ERR_FAIL_COND_V(!script.is_valid(), false);
GD_MONO_SCOPE_THREAD_ATTACH;
@@ -1640,7 +1585,6 @@ bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) {
}
bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
-
ERR_FAIL_COND_V(!script.is_valid(), false);
GD_MONO_SCOPE_THREAD_ATTACH;
@@ -1704,7 +1648,6 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
}
void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Variant>> &r_state) {
-
List<PropertyInfo> pinfo;
get_property_list(&pinfo);
@@ -1729,7 +1672,6 @@ void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Va
}
void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, Array>> &r_state) {
-
MonoObject *owner_managed = get_mono_object();
ERR_FAIL_NULL(owner_managed);
@@ -1760,7 +1702,6 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName,
}
void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
-
for (Map<StringName, PropertyInfo>::Element *E = script->member_info.front(); E; E = E->next()) {
p_properties->push_back(E->value());
}
@@ -1797,7 +1738,6 @@ void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const {
}
Variant::Type CSharpInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
-
if (script->member_info.has(p_name)) {
if (r_is_valid)
*r_is_valid = true;
@@ -1811,7 +1751,6 @@ Variant::Type CSharpInstance::get_property_type(const StringName &p_name, bool *
}
bool CSharpInstance::has_method(const StringName &p_method) const {
-
if (!script.is_valid())
return false;
@@ -1831,7 +1770,6 @@ bool CSharpInstance::has_method(const StringName &p_method) const {
}
Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
ERR_FAIL_COND_V(!script.is_valid(), Variant());
GD_MONO_SCOPE_THREAD_ATTACH;
@@ -1869,7 +1807,6 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
}
void CSharpInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
-
GD_MONO_SCOPE_THREAD_ATTACH;
if (script.is_valid()) {
@@ -1882,7 +1819,6 @@ void CSharpInstance::call_multilevel(const StringName &p_method, const Variant *
}
void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringName &p_method, const Variant **p_args, int p_argcount) {
-
GD_MONO_ASSERT_THREAD_ATTACHED;
GDMonoClass *top = script->script_class;
@@ -1900,14 +1836,12 @@ void CSharpInstance::_call_multilevel(MonoObject *p_mono_object, const StringNam
}
void CSharpInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
-
// Sorry, the method is the one that controls the call order
call_multilevel(p_method, p_args, p_argcount);
}
bool CSharpInstance::_reference_owner_unsafe() {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
CRASH_COND(owner == nullptr);
@@ -1929,7 +1863,6 @@ bool CSharpInstance::_reference_owner_unsafe() {
}
bool CSharpInstance::_unreference_owner_unsafe() {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
CRASH_COND(owner == nullptr);
@@ -1991,7 +1924,6 @@ MonoObject *CSharpInstance::_internal_new_managed() {
}
void CSharpInstance::mono_object_disposed(MonoObject *p_obj) {
-
disconnect_event_signals();
#ifdef DEBUG_ENABLED
@@ -2002,7 +1934,6 @@ void CSharpInstance::mono_object_disposed(MonoObject *p_obj) {
}
void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_delete_owner, bool &r_remove_script_instance) {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
CRASH_COND(gchandle.is_released());
@@ -2063,7 +1994,6 @@ void CSharpInstance::disconnect_event_signals() {
}
void CSharpInstance::refcount_incremented() {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
CRASH_COND(owner == nullptr);
@@ -2086,7 +2016,6 @@ void CSharpInstance::refcount_incremented() {
}
bool CSharpInstance::refcount_decremented() {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
CRASH_COND(owner == nullptr);
@@ -2156,7 +2085,6 @@ MultiplayerAPI::RPCMode CSharpInstance::get_rset_mode(const StringName &p_variab
}
void CSharpInstance::notification(int p_notification) {
-
GD_MONO_SCOPE_THREAD_ATTACH;
if (p_notification == Object::NOTIFICATION_PREDELETE) {
@@ -2195,7 +2123,6 @@ void CSharpInstance::notification(int p_notification) {
}
void CSharpInstance::_call_notification(int p_notification) {
-
GD_MONO_ASSERT_THREAD_ATTACHED;
MonoObject *mono_object = get_mono_object();
@@ -2252,12 +2179,10 @@ String CSharpInstance::to_string(bool *r_valid) {
}
Ref<Script> CSharpInstance::get_script() const {
-
return script;
}
ScriptLanguage *CSharpInstance::get_language() {
-
return CSharpLanguage::get_singleton();
}
@@ -2266,7 +2191,6 @@ CSharpInstance::CSharpInstance(const Ref<CSharpScript> &p_script) :
}
CSharpInstance::~CSharpInstance() {
-
GD_MONO_SCOPE_THREAD_ATTACH;
destructing_script_instance = true;
@@ -2348,14 +2272,12 @@ CSharpInstance::~CSharpInstance() {
#ifdef TOOLS_ENABLED
void CSharpScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
-
placeholders.erase(p_placeholder);
}
#endif
#ifdef TOOLS_ENABLED
void CSharpScript::_update_exports_values(Map<StringName, Variant> &values, List<PropertyInfo> &propnames) {
-
if (base_cache.is_valid()) {
base_cache->_update_exports_values(values, propnames);
}
@@ -2370,7 +2292,6 @@ void CSharpScript::_update_exports_values(Map<StringName, Variant> &values, List
}
void CSharpScript::_update_member_info_no_exports() {
-
if (exports_invalidated) {
GD_MONO_ASSERT_THREAD_ATTACHED;
@@ -2419,7 +2340,6 @@ void CSharpScript::_update_member_info_no_exports() {
#endif
bool CSharpScript::_update_exports() {
-
#ifdef TOOLS_ENABLED
bool is_editor = Engine::get_singleton()->is_editor_hint();
if (is_editor)
@@ -2499,15 +2419,22 @@ bool CSharpScript::_update_exports() {
StringName member_name = field->get_name();
member_info[member_name] = prop_info;
+
+ if (exported) {
#ifdef TOOLS_ENABLED
- if (is_editor && exported) {
- exported_members_cache.push_front(prop_info);
+ if (is_editor) {
+ exported_members_cache.push_front(prop_info);
- if (tmp_object) {
- exported_members_defval_cache[member_name] = GDMonoMarshal::mono_object_to_variant(field->get_value(tmp_object));
+ if (tmp_object) {
+ exported_members_defval_cache[member_name] = GDMonoMarshal::mono_object_to_variant(field->get_value(tmp_object));
+ }
}
- }
#endif
+
+#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
+ exported_members_names.insert(member_name);
+#endif
+ }
}
}
@@ -2520,21 +2447,28 @@ bool CSharpScript::_update_exports() {
StringName member_name = property->get_name();
member_info[member_name] = prop_info;
+
+ if (exported) {
#ifdef TOOLS_ENABLED
- if (is_editor && exported) {
- exported_members_cache.push_front(prop_info);
- if (tmp_object) {
- MonoException *exc = nullptr;
- MonoObject *ret = property->get_value(tmp_object, &exc);
- if (exc) {
- exported_members_defval_cache[member_name] = Variant();
- GDMonoUtils::debug_print_unhandled_exception(exc);
- } else {
- exported_members_defval_cache[member_name] = GDMonoMarshal::mono_object_to_variant(ret);
+ if (is_editor) {
+ exported_members_cache.push_front(prop_info);
+ if (tmp_object) {
+ MonoException *exc = nullptr;
+ MonoObject *ret = property->get_value(tmp_object, &exc);
+ if (exc) {
+ exported_members_defval_cache[member_name] = Variant();
+ GDMonoUtils::debug_print_unhandled_exception(exc);
+ } else {
+ exported_members_defval_cache[member_name] = GDMonoMarshal::mono_object_to_variant(ret);
+ }
}
}
- }
#endif
+
+#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
+ exported_members_names.insert(member_name);
+#endif
+ }
}
}
@@ -2592,7 +2526,6 @@ bool CSharpScript::_update_exports() {
}
void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class) {
-
// no need to load the script's signals more than once
if (!signals_invalidated) {
return;
@@ -2699,7 +2632,6 @@ bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoMethod *p_delegate_in
* If there was an error, r_prop_info and r_exported are not assigned any value.
*/
bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect_export, PropertyInfo &r_prop_info, bool &r_exported) {
-
GD_MONO_ASSERT_THREAD_ATTACHED;
// Goddammit, C++. All I wanted was some nested functions.
@@ -2756,7 +2688,9 @@ bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect
return true;
}
+#ifdef TOOLS_ENABLED
MonoObject *attr = p_member->get_attribute(CACHED_CLASS(ExportAttribute));
+#endif
PropertyHint hint = PROPERTY_HINT_NONE;
String hint_string;
@@ -2798,7 +2732,6 @@ bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect
#ifdef TOOLS_ENABLED
int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, ManagedType p_type, Variant::Type p_variant_type, bool p_allow_generics, PropertyHint &r_hint, String &r_hint_string) {
-
if (p_variant_type == Variant::NIL) {
// System.Object (Variant)
return 1;
@@ -2898,7 +2831,6 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage
#endif
void CSharpScript::_clear() {
-
tool = false;
valid = false;
@@ -2908,7 +2840,6 @@ void CSharpScript::_clear() {
}
Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (unlikely(GDMono::get_singleton() == nullptr)) {
// Probably not the best error but eh.
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
@@ -2940,7 +2871,6 @@ Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, i
}
void CSharpScript::_resource_path_changed() {
-
String path = get_path();
if (!path.empty()) {
@@ -2949,9 +2879,7 @@ void CSharpScript::_resource_path_changed() {
}
bool CSharpScript::_get(const StringName &p_name, Variant &r_ret) const {
-
if (p_name == CSharpLanguage::singleton->string_names._script_source) {
-
r_ret = get_source_code();
return true;
}
@@ -2960,9 +2888,7 @@ bool CSharpScript::_get(const StringName &p_name, Variant &r_ret) const {
}
bool CSharpScript::_set(const StringName &p_name, const Variant &p_value) {
-
if (p_name == CSharpLanguage::singleton->string_names._script_source) {
-
set_source_code(p_value);
reload();
return true;
@@ -2972,17 +2898,14 @@ bool CSharpScript::_set(const StringName &p_name, const Variant &p_value) {
}
void CSharpScript::_get_property_list(List<PropertyInfo> *p_properties) const {
-
p_properties->push_back(PropertyInfo(Variant::STRING, CSharpLanguage::singleton->string_names._script_source, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
}
void CSharpScript::_bind_methods() {
-
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &CSharpScript::_new, MethodInfo("new"));
}
Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class, GDMonoClass *p_native) {
-
// This method should not fail, only assertions allowed
CRASH_COND(p_class == nullptr);
@@ -2996,7 +2919,6 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class, GD
}
void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMonoClass *p_class, GDMonoClass *p_native) {
-
// This method should not fail, only assertions allowed
CRASH_COND(p_class == nullptr);
@@ -3060,7 +2982,6 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon
}
bool CSharpScript::can_instance() const {
-
#ifdef TOOLS_ENABLED
bool extra_cond = tool || ScriptServer::is_scripting_enabled();
#else
@@ -3084,7 +3005,6 @@ bool CSharpScript::can_instance() const {
}
StringName CSharpScript::get_instance_base_type() const {
-
if (native)
return native->get_name();
else
@@ -3092,7 +3012,6 @@ StringName CSharpScript::get_instance_base_type() const {
}
CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) {
-
GD_MONO_ASSERT_THREAD_ATTACHED;
/* STEP 1, CREATE */
@@ -3182,7 +3101,6 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
}
Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (!valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
@@ -3218,7 +3136,6 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
}
ScriptInstance *CSharpScript::instance_create(Object *p_this) {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!valid);
#endif
@@ -3243,7 +3160,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
}
PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) {
-
#ifdef TOOLS_ENABLED
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
placeholders.insert(si);
@@ -3255,23 +3171,19 @@ PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_t
}
bool CSharpScript::instance_has(const Object *p_this) const {
-
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
return instances.has((Object *)p_this);
}
bool CSharpScript::has_source_code() const {
-
return !source.empty();
}
String CSharpScript::get_source_code() const {
-
return source;
}
void CSharpScript::set_source_code(const String &p_code) {
-
if (source == p_code)
return;
source = p_code;
@@ -3281,7 +3193,6 @@ void CSharpScript::set_source_code(const String &p_code) {
}
void CSharpScript::get_script_method_list(List<MethodInfo> *p_list) const {
-
if (!script_class)
return;
@@ -3295,7 +3206,6 @@ void CSharpScript::get_script_method_list(List<MethodInfo> *p_list) const {
}
bool CSharpScript::has_method(const StringName &p_method) const {
-
if (!script_class)
return false;
@@ -3305,7 +3215,6 @@ bool CSharpScript::has_method(const StringName &p_method) const {
}
MethodInfo CSharpScript::get_method_info(const StringName &p_method) const {
-
if (!script_class)
return MethodInfo();
@@ -3326,7 +3235,6 @@ MethodInfo CSharpScript::get_method_info(const StringName &p_method) const {
}
Error CSharpScript::reload(bool p_keep_state) {
-
bool has_instances;
{
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
@@ -3348,9 +3256,7 @@ Error CSharpScript::reload(bool p_keep_state) {
ERR_FAIL_NULL_V(namespace_, ERR_BUG);
ERR_FAIL_NULL_V(class_name, ERR_BUG);
GDMonoClass *klass = project_assembly->get_class(namespace_->operator String(), class_name->operator String());
- if (klass) {
- bool obj_type = CACHED_CLASS(GodotObject)->is_assignable_from(klass);
- ERR_FAIL_COND_V(!obj_type, ERR_BUG);
+ if (klass && CACHED_CLASS(GodotObject)->is_assignable_from(klass)) {
script_class = klass;
}
} else {
@@ -3488,12 +3394,10 @@ Error CSharpScript::reload(bool p_keep_state) {
}
ScriptLanguage *CSharpScript::get_language() const {
-
return CSharpLanguage::get_singleton();
}
bool CSharpScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
-
#ifdef TOOLS_ENABLED
const Map<StringName, Variant>::Element *E = exported_members_defval_cache.find(p_property);
@@ -3511,7 +3415,6 @@ bool CSharpScript::get_property_default_value(const StringName &p_property, Vari
}
void CSharpScript::update_exports() {
-
#ifdef TOOLS_ENABLED
_update_exports();
#endif
@@ -3522,7 +3425,6 @@ bool CSharpScript::has_script_signal(const StringName &p_signal) const {
}
void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
-
for (const Map<StringName, Vector<SignalParameter>>::Element *E = _signals.front(); E; E = E->next()) {
MethodInfo mi;
mi.name = E->key();
@@ -3579,26 +3481,22 @@ bool CSharpScript::inherits_script(const Ref<Script> &p_script) const {
}
Ref<Script> CSharpScript::get_base_script() const {
-
// TODO search in metadata file once we have it, not important any way?
return Ref<Script>();
}
void CSharpScript::get_script_property_list(List<PropertyInfo> *p_list) const {
-
for (Map<StringName, PropertyInfo>::Element *E = member_info.front(); E; E = E->next()) {
p_list->push_back(E->value());
}
}
int CSharpScript::get_member_line(const StringName &p_member) const {
-
// TODO omnisharp
return -1;
}
MultiplayerAPI::RPCMode CSharpScript::_member_get_rpc_mode(IMonoClassMember *p_member) const {
-
if (p_member->has_attribute(CACHED_CLASS(RemoteAttribute)))
return MultiplayerAPI::RPC_MODE_REMOTE;
if (p_member->has_attribute(CACHED_CLASS(MasterAttribute)))
@@ -3670,7 +3568,6 @@ MultiplayerAPI::RPCMode CSharpScript::get_rset_mode(const StringName &p_variable
}
Error CSharpScript::load_source_code(const String &p_path) {
-
Error ferr = read_all_file_utf8(p_path, source);
ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
@@ -3687,12 +3584,10 @@ Error CSharpScript::load_source_code(const String &p_path) {
}
StringName CSharpScript::get_script_name() const {
-
return name;
}
CSharpScript::CSharpScript() {
-
_clear();
_resource_path_changed();
@@ -3706,17 +3601,25 @@ CSharpScript::CSharpScript() {
}
CSharpScript::~CSharpScript() {
-
#ifdef DEBUG_ENABLED
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
CSharpLanguage::get_singleton()->script_list.remove(&this->script_list);
#endif
}
+void CSharpScript::get_members(Set<StringName> *p_members) {
+#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
+ if (p_members) {
+ for (Set<StringName>::Element *E = exported_members_names.front(); E; E = E->next()) {
+ p_members->insert(E->get());
+ }
+ }
+#endif
+}
+
/*************** RESOURCE ***************/
RES ResourceFormatLoaderCSharpScript::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_FILE_CANT_OPEN;
@@ -3742,22 +3645,18 @@ RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p
}
void ResourceFormatLoaderCSharpScript::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("cs");
}
bool ResourceFormatLoaderCSharpScript::handles_type(const String &p_type) const {
-
return p_type == "Script" || p_type == CSharpLanguage::get_singleton()->get_type();
}
String ResourceFormatLoaderCSharpScript::get_resource_type(const String &p_path) const {
-
return p_path.get_extension().to_lower() == "cs" ? CSharpLanguage::get_singleton()->get_type() : "";
}
Error ResourceFormatSaverCSharpScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<CSharpScript> sqscr = p_resource;
ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
@@ -3801,19 +3700,16 @@ Error ResourceFormatSaverCSharpScript::save(const String &p_path, const RES &p_r
}
void ResourceFormatSaverCSharpScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (Object::cast_to<CSharpScript>(p_resource.ptr())) {
p_extensions->push_back("cs");
}
}
bool ResourceFormatSaverCSharpScript::recognize(const RES &p_resource) const {
-
return Object::cast_to<CSharpScript>(p_resource.ptr()) != nullptr;
}
CSharpLanguage::StringNameCache::StringNameCache() {
-
_signal_callback = StaticCString::create("_signal_callback");
_set = StaticCString::create("_set");
_get = StaticCString::create("_get");
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index c9ea482c36..0bf08ceafd 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -66,7 +66,6 @@ TScriptInstance *cast_script_instance(ScriptInstance *p_inst) {
#define CAST_CSHARP_INSTANCE(m_inst) (cast_script_instance<CSharpInstance, CSharpLanguage>(m_inst))
class CSharpScript : public Script {
-
GDCLASS(CSharpScript, Script);
public:
@@ -139,6 +138,10 @@ private:
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
#endif
+#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
+ Set<StringName> exported_members_names;
+#endif
+
Map<StringName, PropertyInfo> member_info;
void _clear();
@@ -192,6 +195,8 @@ public:
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
virtual void update_exports();
+ void get_members(Set<StringName> *p_members) override;
+
virtual bool is_tool() const { return tool; }
virtual bool is_valid() const { return valid; }
@@ -231,7 +236,6 @@ public:
};
class CSharpInstance : public ScriptInstance {
-
friend class CSharpScript;
friend class CSharpLanguage;
@@ -326,17 +330,13 @@ public:
};
struct CSharpScriptBinding {
- bool inited;
+ bool inited = false;
StringName type_name;
- GDMonoClass *wrapper_class;
+ GDMonoClass *wrapper_class = nullptr;
MonoGCHandleData gchandle;
- Object *owner;
+ Object *owner = nullptr;
- CSharpScriptBinding() :
- inited(false),
- wrapper_class(nullptr),
- owner(nullptr) {
- }
+ CSharpScriptBinding() {}
};
class ManagedCallableMiddleman : public Object {
@@ -344,7 +344,6 @@ class ManagedCallableMiddleman : public Object {
};
class CSharpLanguage : public ScriptLanguage {
-
friend class CSharpScript;
friend class CSharpInstance;
@@ -371,7 +370,6 @@ class CSharpLanguage : public ScriptLanguage {
ManagedCallableMiddleman *managed_callable_middleman = memnew(ManagedCallableMiddleman);
struct StringNameCache {
-
StringName _signal_callback;
StringName _set;
StringName _get;
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs
index d069651dd3..572c541412 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Client.cs
@@ -19,9 +19,12 @@ namespace GodotTools.IdeMessaging
private readonly string identity;
private string MetaFilePath { get; }
+ private DateTime? metaFileModifiedTime;
private GodotIdeMetadata godotIdeMetadata;
private readonly FileSystemWatcher fsWatcher;
+ public string GodotEditorExecutablePath => godotIdeMetadata.EditorExecutablePath;
+
private readonly IMessageHandler messageHandler;
private Peer peer;
@@ -123,7 +126,7 @@ namespace GodotTools.IdeMessaging
MetaFilePath = Path.Combine(projectMetadataDir, GodotIdeMetadata.DefaultFileName);
// FileSystemWatcher requires an existing directory
- if (!File.Exists(projectMetadataDir))
+ if (!Directory.Exists(projectMetadataDir))
Directory.CreateDirectory(projectMetadataDir);
fsWatcher = new FileSystemWatcher(projectMetadataDir, GodotIdeMetadata.DefaultFileName);
@@ -142,6 +145,13 @@ namespace GodotTools.IdeMessaging
if (!File.Exists(MetaFilePath))
return;
+ var lastWriteTime = File.GetLastWriteTime(MetaFilePath);
+
+ if (lastWriteTime == metaFileModifiedTime)
+ return;
+
+ metaFileModifiedTime = lastWriteTime;
+
var metadata = ReadMetadataFile();
if (metadata != null && metadata != godotIdeMetadata)
@@ -173,6 +183,13 @@ namespace GodotTools.IdeMessaging
if (IsConnected || !File.Exists(MetaFilePath))
return;
+ var lastWriteTime = File.GetLastWriteTime(MetaFilePath);
+
+ if (lastWriteTime == metaFileModifiedTime)
+ return;
+
+ metaFileModifiedTime = lastWriteTime;
+
var metadata = ReadMetadataFile();
if (metadata != null)
@@ -185,7 +202,8 @@ namespace GodotTools.IdeMessaging
private GodotIdeMetadata? ReadMetadataFile()
{
- using (var reader = File.OpenText(MetaFilePath))
+ using (var fileStream = new FileStream(MetaFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+ using (var reader = new StreamReader(fileStream))
{
string portStr = reader.ReadLine();
@@ -272,6 +290,7 @@ namespace GodotTools.IdeMessaging
// ReSharper disable once UnusedMember.Global
public async void Start()
{
+ fsWatcher.Created += OnMetaFileChanged;
fsWatcher.Changed += OnMetaFileChanged;
fsWatcher.Deleted += OnMetaFileDeleted;
fsWatcher.EnableRaisingEvents = true;
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj
index 67815959a6..dad6b9ae7a 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/GodotTools.IdeMessaging.csproj
@@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<PackageId>GodotTools.IdeMessaging</PackageId>
- <Version>1.1.0</Version>
+ <Version>1.1.1</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<Authors>Godot Engine contributors</Authors>
<Company />
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs
index a4e86d6177..10d7e1898e 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Peer.cs
@@ -105,49 +105,45 @@ namespace GodotTools.IdeMessaging
try
{
- try
+ if (msg.Kind == MessageKind.Request)
{
- if (msg.Kind == MessageKind.Request)
- {
- var responseContent = await messageHandler.HandleRequest(this, msg.Id, msg.Content, Logger);
- await WriteMessage(new Message(MessageKind.Response, msg.Id, responseContent));
- }
- else if (msg.Kind == MessageKind.Response)
- {
- ResponseAwaiter responseAwaiter;
+ var responseContent = await messageHandler.HandleRequest(this, msg.Id, msg.Content, Logger);
+ await WriteMessage(new Message(MessageKind.Response, msg.Id, responseContent));
+ }
+ else if (msg.Kind == MessageKind.Response)
+ {
+ ResponseAwaiter responseAwaiter;
- using (await requestsSem.UseAsync())
+ using (await requestsSem.UseAsync())
+ {
+ if (!requestAwaiterQueues.TryGetValue(msg.Id, out var queue) || queue.Count <= 0)
{
- if (!requestAwaiterQueues.TryGetValue(msg.Id, out var queue) || queue.Count <= 0)
- {
- Logger.LogError($"Received unexpected response: {msg.Id}");
- return;
- }
-
- responseAwaiter = queue.Dequeue();
+ Logger.LogError($"Received unexpected response: {msg.Id}");
+ return;
}
- responseAwaiter.SetResult(msg.Content);
- }
- else
- {
- throw new IndexOutOfRangeException($"Invalid message kind {msg.Kind}");
+ responseAwaiter = queue.Dequeue();
}
+
+ responseAwaiter.SetResult(msg.Content);
}
- catch (Exception e)
+ else
{
- Logger.LogError($"Message handler for '{msg}' failed with exception", e);
+ throw new IndexOutOfRangeException($"Invalid message kind {msg.Kind}");
}
}
catch (Exception e)
{
- Logger.LogError($"Exception thrown from message handler. Message: {msg}", e);
+ Logger.LogError($"Message handler for '{msg}' failed with exception", e);
}
}
}
catch (Exception e)
{
- Logger.LogError("Unhandled exception in the peer loop", e);
+ if (!IsDisposed || !(e is SocketException || e.InnerException is SocketException))
+ {
+ Logger.LogError("Unhandled exception in the peer loop", e);
+ }
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Requests/Requests.cs b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Requests/Requests.cs
index 1dd4f852e5..e93db9377b 100644
--- a/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Requests/Requests.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Requests/Requests.cs
@@ -67,6 +67,19 @@ namespace GodotTools.IdeMessaging.Requests
{
}
+ public sealed class StopPlayRequest : Request
+ {
+ public new const string Id = "StopPlay";
+
+ public StopPlayRequest() : base(Id)
+ {
+ }
+ }
+
+ public sealed class StopPlayResponse : Response
+ {
+ }
+
public sealed class DebugPlayRequest : Request
{
public string DebuggerHost { get; set; }
diff --git a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj
new file mode 100644
index 0000000000..5b3ed0b1b7
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/GodotTools.OpenVisualStudio.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <ProjectGuid>{EAFFF236-FA96-4A4D-BD23-0E51EF988277}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net472</TargetFramework>
+ <LangVersion>7.2</LangVersion>
+ </PropertyGroup>
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
+ <PackageReference Include="EnvDTE" Version="8.0.2" />
+ </ItemGroup>
+</Project>
diff --git a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
new file mode 100644
index 0000000000..affb2a47e7
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
@@ -0,0 +1,270 @@
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
+using System.Text.RegularExpressions;
+using EnvDTE;
+
+namespace GodotTools.OpenVisualStudio
+{
+ internal static class Program
+ {
+ [DllImport("ole32.dll")]
+ private static extern int GetRunningObjectTable(int reserved, out IRunningObjectTable pprot);
+
+ [DllImport("ole32.dll")]
+ private static extern void CreateBindCtx(int reserved, out IBindCtx ppbc);
+
+ [DllImport("user32.dll")]
+ private static extern bool SetForegroundWindow(IntPtr hWnd);
+
+ private static void ShowHelp()
+ {
+ Console.WriteLine("Opens the file(s) in a Visual Studio instance that is editing the specified solution.");
+ Console.WriteLine("If an existing instance for the solution is not found, a new one is created.");
+ Console.WriteLine();
+ Console.WriteLine("Usage:");
+ Console.WriteLine(@" GodotTools.OpenVisualStudio.exe solution [file[;line[;col]]...]");
+ Console.WriteLine();
+ Console.WriteLine("Lines and columns begin at one. Zero or lower will result in an error.");
+ Console.WriteLine("If a line is specified but a column is not, the line is selected in the text editor.");
+ }
+
+ // STAThread needed, otherwise CoRegisterMessageFilter may return CO_E_NOT_SUPPORTED.
+ [STAThread]
+ private static int Main(string[] args)
+ {
+ if (args.Length == 0 || args[0] == "--help" || args[0] == "-h")
+ {
+ ShowHelp();
+ return 0;
+ }
+
+ string solutionFile = NormalizePath(args[0]);
+
+ var dte = FindInstanceEditingSolution(solutionFile);
+
+ if (dte == null)
+ {
+ // Open a new instance
+
+ var visualStudioDteType = Type.GetTypeFromProgID("VisualStudio.DTE.16.0", throwOnError: true);
+ dte = (DTE)Activator.CreateInstance(visualStudioDteType);
+
+ dte.UserControl = true;
+
+ try
+ {
+ dte.Solution.Open(solutionFile);
+ }
+ catch (ArgumentException)
+ {
+ Console.Error.WriteLine("Solution.Open: Invalid path or file not found");
+ return 1;
+ }
+
+ dte.MainWindow.Visible = true;
+ }
+
+ MessageFilter.Register();
+
+ try
+ {
+ // Open files
+
+ for (int i = 1; i < args.Length; i++)
+ {
+ // Both the line number and the column begin at one
+
+ string[] fileArgumentParts = args[i].Split(';');
+
+ string filePath = NormalizePath(fileArgumentParts[0]);
+
+ try
+ {
+ dte.ItemOperations.OpenFile(filePath);
+ }
+ catch (ArgumentException)
+ {
+ Console.Error.WriteLine("ItemOperations.OpenFile: Invalid path or file not found");
+ return 1;
+ }
+
+ if (fileArgumentParts.Length > 1)
+ {
+ if (int.TryParse(fileArgumentParts[1], out int line))
+ {
+ var textSelection = (TextSelection)dte.ActiveDocument.Selection;
+
+ if (fileArgumentParts.Length > 2)
+ {
+ if (int.TryParse(fileArgumentParts[2], out int column))
+ {
+ textSelection.MoveToLineAndOffset(line, column);
+ }
+ else
+ {
+ Console.Error.WriteLine("The column part of the argument must be a valid integer");
+ return 1;
+ }
+ }
+ else
+ {
+ textSelection.GotoLine(line, Select: true);
+ }
+ }
+ else
+ {
+ Console.Error.WriteLine("The line part of the argument must be a valid integer");
+ return 1;
+ }
+ }
+ }
+ }
+ finally
+ {
+ var mainWindow = dte.MainWindow;
+ mainWindow.Activate();
+ SetForegroundWindow(new IntPtr(mainWindow.HWnd));
+
+ MessageFilter.Revoke();
+ }
+
+ return 0;
+ }
+
+ private static DTE FindInstanceEditingSolution(string solutionPath)
+ {
+ if (GetRunningObjectTable(0, out IRunningObjectTable pprot) != 0)
+ return null;
+
+ try
+ {
+ pprot.EnumRunning(out IEnumMoniker ppenumMoniker);
+ ppenumMoniker.Reset();
+
+ var moniker = new IMoniker[1];
+
+ while (ppenumMoniker.Next(1, moniker, IntPtr.Zero) == 0)
+ {
+ string ppszDisplayName;
+
+ CreateBindCtx(0, out IBindCtx ppbc);
+
+ try
+ {
+ moniker[0].GetDisplayName(ppbc, null, out ppszDisplayName);
+ }
+ finally
+ {
+ Marshal.ReleaseComObject(ppbc);
+ }
+
+ if (ppszDisplayName == null)
+ continue;
+
+ // The digits after the colon are the process ID
+ if (!Regex.IsMatch(ppszDisplayName, "!VisualStudio.DTE.16.0:[0-9]"))
+ continue;
+
+ if (pprot.GetObject(moniker[0], out object ppunkObject) == 0)
+ {
+ if (ppunkObject is DTE dte && dte.Solution.FullName.Length > 0)
+ {
+ if (NormalizePath(dte.Solution.FullName) == solutionPath)
+ return dte;
+ }
+ }
+ }
+ }
+ finally
+ {
+ Marshal.ReleaseComObject(pprot);
+ }
+
+ return null;
+ }
+
+ static string NormalizePath(string path)
+ {
+ return new Uri(Path.GetFullPath(path)).LocalPath
+ .TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
+ .ToUpperInvariant();
+ }
+
+ #region MessageFilter. See: http: //msdn.microsoft.com/en-us/library/ms228772.aspx
+
+ private class MessageFilter : IOleMessageFilter
+ {
+ // Class containing the IOleMessageFilter
+ // thread error-handling functions
+
+ private static IOleMessageFilter _oldFilter;
+
+ // Start the filter
+ public static void Register()
+ {
+ IOleMessageFilter newFilter = new MessageFilter();
+ int ret = CoRegisterMessageFilter(newFilter, out _oldFilter);
+ if (ret != 0)
+ Console.Error.WriteLine($"CoRegisterMessageFilter failed with error code: {ret}");
+ }
+
+ // Done with the filter, close it
+ public static void Revoke()
+ {
+ int ret = CoRegisterMessageFilter(_oldFilter, out _);
+ if (ret != 0)
+ Console.Error.WriteLine($"CoRegisterMessageFilter failed with error code: {ret}");
+ }
+
+ //
+ // IOleMessageFilter functions
+ // Handle incoming thread requests
+ int IOleMessageFilter.HandleInComingCall(int dwCallType, IntPtr hTaskCaller, int dwTickCount, IntPtr lpInterfaceInfo)
+ {
+ // Return the flag SERVERCALL_ISHANDLED
+ return 0;
+ }
+
+ // Thread call was rejected, so try again.
+ int IOleMessageFilter.RetryRejectedCall(IntPtr hTaskCallee, int dwTickCount, int dwRejectType)
+ {
+ if (dwRejectType == 2)
+ // flag = SERVERCALL_RETRYLATER
+ {
+ // Retry the thread call immediately if return >= 0 & < 100
+ return 99;
+ }
+
+ // Too busy; cancel call
+ return -1;
+ }
+
+ int IOleMessageFilter.MessagePending(IntPtr hTaskCallee, int dwTickCount, int dwPendingType)
+ {
+ // Return the flag PENDINGMSG_WAITDEFPROCESS
+ return 2;
+ }
+
+ // Implement the IOleMessageFilter interface
+ [DllImport("ole32.dll")]
+ private static extern int CoRegisterMessageFilter(IOleMessageFilter newFilter, out IOleMessageFilter oldFilter);
+ }
+
+ [ComImport(), Guid("00000016-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ private interface IOleMessageFilter
+ {
+ [PreserveSig]
+ int HandleInComingCall(int dwCallType, IntPtr hTaskCaller, int dwTickCount, IntPtr lpInterfaceInfo);
+
+ [PreserveSig]
+ int RetryRejectedCall(IntPtr hTaskCallee, int dwTickCount, int dwRejectType);
+
+ [PreserveSig]
+ int MessagePending(IntPtr hTaskCallee, int dwTickCount, int dwPendingType);
+ }
+
+ #endregion
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs
index fb2beb6995..679d5bb444 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs
@@ -12,6 +12,11 @@ namespace GodotTools.ProjectEditor
private const string CoreApiProjectName = "GodotSharp";
private const string EditorApiProjectName = "GodotSharpEditor";
+ public const string CSharpProjectTypeGuid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
+ public const string GodotProjectTypeGuid = "{8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED}";
+
+ public static readonly string GodotDefaultProjectTypeGuids = $"{GodotProjectTypeGuid};{CSharpProjectTypeGuid}";
+
public static string GenGameProject(string dir, string name, IEnumerable<string> compileItems)
{
string path = Path.Combine(dir, name + ".csproj");
@@ -19,6 +24,7 @@ namespace GodotTools.ProjectEditor
ProjectPropertyGroupElement mainGroup;
var root = CreateLibraryProject(name, "Debug", out mainGroup);
+ mainGroup.SetProperty("ProjectTypeGuids", GodotDefaultProjectTypeGuids);
mainGroup.SetProperty("OutputPath", Path.Combine(".mono", "temp", "bin", "$(Configuration)"));
mainGroup.SetProperty("BaseIntermediateOutputPath", Path.Combine(".mono", "temp", "obj"));
mainGroup.SetProperty("IntermediateOutputPath", Path.Combine("$(BaseIntermediateOutputPath)", "$(Configuration)"));
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
index 069a1edaa3..8774b4ee31 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
@@ -165,6 +165,21 @@ namespace GodotTools.ProjectEditor
return result.ToArray();
}
+ public static void EnsureHasProjectTypeGuids(MSBuildProject project)
+ {
+ var root = project.Root;
+
+ bool found = root.PropertyGroups.Any(pg =>
+ string.IsNullOrEmpty(pg.Condition) && pg.Properties.Any(p => p.Name == "ProjectTypeGuids"));
+
+ if (found)
+ return;
+
+ root.AddProperty("ProjectTypeGuids", ProjectGenerator.GodotDefaultProjectTypeGuids);
+
+ project.HasUnsavedChanges = true;
+ }
+
/// Simple function to make sure the Api assembly references are configured correctly
public static void FixApiHintPath(MSBuildProject project)
{
diff --git a/modules/mono/editor/GodotTools/GodotTools.sln b/modules/mono/editor/GodotTools/GodotTools.sln
index f6147eb5bb..ba5379e562 100644
--- a/modules/mono/editor/GodotTools/GodotTools.sln
+++ b/modules/mono/editor/GodotTools/GodotTools.sln
@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotTools.BuildLogger", "G
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotTools.IdeMessaging", "GodotTools.IdeMessaging\GodotTools.IdeMessaging.csproj", "{92600954-25F0-4291-8E11-1FEE9FC4BE20}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodotTools.OpenVisualStudio", "GodotTools.OpenVisualStudio\GodotTools.OpenVisualStudio.csproj", "{EAFFF236-FA96-4A4D-BD23-0E51EF988277}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -37,5 +39,9 @@ Global
{92600954-25F0-4291-8E11-1FEE9FC4BE20}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92600954-25F0-4291-8E11-1FEE9FC4BE20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92600954-25F0-4291-8E11-1FEE9FC4BE20}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EAFFF236-FA96-4A4D-BD23-0E51EF988277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EAFFF236-FA96-4A4D-BD23-0E51EF988277}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EAFFF236-FA96-4A4D-BD23-0E51EF988277}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EAFFF236-FA96-4A4D-BD23-0E51EF988277}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index eb7696685f..403e25781d 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+using System.Linq;
using GodotTools.Ides;
using GodotTools.Ides.Rider;
using GodotTools.Internals;
@@ -238,7 +239,31 @@ namespace GodotTools
// Not an error. Tells the caller to fallback to the global external editor settings or the built-in editor.
return Error.Unavailable;
case ExternalEditorId.VisualStudio:
- throw new NotSupportedException();
+ {
+ string scriptPath = ProjectSettings.GlobalizePath(script.ResourcePath);
+
+ var args = new List<string>
+ {
+ GodotSharpDirs.ProjectSlnPath,
+ line >= 0 ? $"{scriptPath};{line + 1};{col + 1}" : scriptPath
+ };
+
+ string command = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "GodotTools.OpenVisualStudio.exe");
+
+ try
+ {
+ if (Godot.OS.IsStdoutVerbose())
+ Console.WriteLine($"Running: \"{command}\" {string.Join(" ", args.Select(a => $"\"{a}\""))}");
+
+ OS.RunProcess(command, args);
+ }
+ catch (Exception e)
+ {
+ GD.PushError($"Error when trying to run code editor: VisualStudio. Exception message: '{e.Message}'");
+ }
+
+ break;
+ }
case ExternalEditorId.VisualStudioForMac:
goto case ExternalEditorId.MonoDevelop;
case ExternalEditorId.Rider:
@@ -421,7 +446,7 @@ namespace GodotTools
aboutLabel.Text =
"C# support in Godot Engine is in late alpha stage and, while already usable, " +
"it is not meant for use in production.\n\n" +
- "Projects can be exported to Linux, macOS, Windows and Android, but not yet to iOS, HTML5 or UWP. " +
+ "Projects can be exported to Linux, macOS, Windows, Android, iOS and HTML5, but not yet to UWP. " +
"Bugs and usability issues will be addressed gradually over future releases, " +
"potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" +
"If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" +
@@ -458,6 +483,9 @@ namespace GodotTools
// Apply the other fixes only after configurations have been migrated
+ // Make sure the existing project has the ProjectTypeGuids property (for VisualStudio)
+ ProjectUtils.EnsureHasProjectTypeGuids(msbuildProject);
+
// Make sure the existing project has Api assembly references configured correctly
ProjectUtils.FixApiHintPath(msbuildProject);
@@ -501,7 +529,8 @@ namespace GodotTools
if (OS.IsWindows)
{
- settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
+ settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" +
+ $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
$",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
$",JetBrains Rider:{(int)ExternalEditorId.Rider}";
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index ba527ca3b5..3f14629b11 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -33,5 +33,7 @@
<ProjectReference Include="..\GodotTools.IdeMessaging\GodotTools.IdeMessaging.csproj" />
<ProjectReference Include="..\GodotTools.ProjectEditor\GodotTools.ProjectEditor.csproj" />
<ProjectReference Include="..\GodotTools.Core\GodotTools.Core.csproj" />
+ <!-- Include it if this is an SCons build targeting Windows, or if it's not an SCons build but we're on Windows -->
+ <ProjectReference Include="..\GodotTools.OpenVisualStudio\GodotTools.OpenVisualStudio.csproj" Condition=" '$(GodotPlatform)' == 'windows' Or ( '$(GodotPlatform)' == '' And '$(OS)' == 'Windows_NT' ) " />
</ItemGroup>
</Project>
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs
index 32f264d100..98e8d13be0 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs
@@ -307,6 +307,11 @@ namespace GodotTools.Ides
var request = JsonConvert.DeserializeObject<DebugPlayRequest>(content.Body);
return await HandleDebugPlay(request);
},
+ [StopPlayRequest.Id] = async (peer, content) =>
+ {
+ var request = JsonConvert.DeserializeObject<StopPlayRequest>(content.Body);
+ return await HandleStopPlay(request);
+ },
[ReloadScriptsRequest.Id] = async (peer, content) =>
{
_ = JsonConvert.DeserializeObject<ReloadScriptsRequest>(content.Body);
@@ -343,6 +348,12 @@ namespace GodotTools.Ides
return Task.FromResult<Response>(new DebugPlayResponse());
}
+ private static Task<Response> HandleStopPlay(StopPlayRequest request)
+ {
+ DispatchToMainThread(Internal.EditorRunStop);
+ return Task.FromResult<Response>(new StopPlayResponse());
+ }
+
private static Task<Response> HandleReloadScripts()
{
DispatchToMainThread(Internal.ScriptEditorDebugger_ReloadScripts);
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 258b8ed3ed..730ffcb945 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -105,7 +105,6 @@
const char *BindingsGenerator::TypeInterface::DEFAULT_VARARG_C_IN("\t%0 %1_in = %1;\n");
static String fix_doc_description(const String &p_bbcode) {
-
// This seems to be the correct way to do this. It's the same EditorHelp does.
return p_bbcode.dedent()
@@ -115,7 +114,6 @@ static String fix_doc_description(const String &p_bbcode) {
}
static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_upper = false) {
-
String ret;
Vector<String> parts = p_identifier.split("_", true);
@@ -125,8 +123,9 @@ static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_u
if (part.length()) {
part[0] = _find_upper(part[0]);
if (p_input_is_upper) {
- for (int j = 1; j < part.length(); j++)
+ for (int j = 1; j < part.length(); j++) {
part[j] = _find_lower(part[j]);
+ }
}
ret += part;
} else {
@@ -148,7 +147,6 @@ static String snake_to_pascal_case(const String &p_identifier, bool p_input_is_u
}
static String snake_to_camel_case(const String &p_identifier, bool p_input_is_upper = false) {
-
String ret;
Vector<String> parts = p_identifier.split("_", true);
@@ -160,8 +158,9 @@ static String snake_to_camel_case(const String &p_identifier, bool p_input_is_up
part[0] = _find_upper(part[0]);
}
if (p_input_is_upper) {
- for (int j = i != 0 ? 1 : 0; j < part.length(); j++)
+ for (int j = i != 0 ? 1 : 0; j < part.length(); j++) {
part[j] = _find_lower(part[j]);
+ }
}
ret += part;
} else {
@@ -183,11 +182,11 @@ static String snake_to_camel_case(const String &p_identifier, bool p_input_is_up
}
String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterface *p_itype) {
-
// Based on the version in EditorHelp
- if (p_bbcode.empty())
+ if (p_bbcode.empty()) {
return String();
+ }
DocData *doc = EditorHelp::get_doc_data();
@@ -204,8 +203,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
while (pos < bbcode.length()) {
int brk_pos = bbcode.find("[", pos);
- if (brk_pos < 0)
+ if (brk_pos < 0) {
brk_pos = bbcode.length();
+ }
if (brk_pos > pos) {
String text = bbcode.substr(pos, brk_pos - pos);
@@ -214,19 +214,22 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
} else {
Vector<String> lines = text.split("\n");
for (int i = 0; i < lines.size(); i++) {
- if (i != 0)
+ if (i != 0) {
xml_output.append("<para>");
+ }
xml_output.append(lines[i].xml_escape());
- if (i != lines.size() - 1)
+ if (i != lines.size() - 1) {
xml_output.append("</para>\n");
+ }
}
}
}
- if (brk_pos == bbcode.length())
+ if (brk_pos == bbcode.length()) {
break; // nothing else to add
+ }
int brk_end = bbcode.find("]", brk_pos + 1);
@@ -237,13 +240,15 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
} else {
Vector<String> lines = text.split("\n");
for (int i = 0; i < lines.size(); i++) {
- if (i != 0)
+ if (i != 0) {
xml_output.append("<para>");
+ }
xml_output.append(lines[i].xml_escape());
- if (i != lines.size() - 1)
+ if (i != lines.size() - 1) {
xml_output.append("</para>\n");
+ }
}
}
@@ -416,8 +421,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) {
target_ienum = &E->get();
target_iconst = find_constant_by_name(target_name, target_ienum->constants);
- if (target_iconst)
+ if (target_iconst) {
break;
+ }
}
if (target_iconst) {
@@ -454,8 +460,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) {
target_ienum = &E->get();
target_iconst = find_constant_by_name(target_name, target_ienum->constants);
- if (target_iconst)
+ if (target_iconst) {
break;
+ }
}
if (target_iconst) {
@@ -587,8 +594,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
tag_stack.push_front(tag);
} else if (tag == "url") {
int end = bbcode.find("[", brk_end);
- if (end == -1)
+ if (end == -1) {
end = bbcode.length();
+ }
String url = bbcode.substr(brk_end + 1, end - brk_end - 1);
xml_output.append("<a href=\"");
xml_output.append(url);
@@ -607,8 +615,9 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
tag_stack.push_front("url");
} else if (tag == "img") {
int end = bbcode.find("[", brk_end);
- if (end == -1)
+ if (end == -1) {
end = bbcode.length();
+ }
String image = bbcode.substr(brk_end + 1, end - brk_end - 1);
// Not supported. Just append the bbcode.
@@ -638,15 +647,15 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
}
int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) {
-
CRASH_COND(p_ienum.constants.empty());
const ConstantInterface &front_iconstant = p_ienum.constants.front()->get();
Vector<String> front_parts = front_iconstant.name.split("_", /* p_allow_empty: */ true);
int candidate_len = front_parts.size() - 1;
- if (candidate_len == 0)
+ if (candidate_len == 0) {
return 0;
+ }
for (const List<ConstantInterface>::Element *E = p_ienum.constants.front()->next(); E; E = E->next()) {
const ConstantInterface &iconstant = E->get();
@@ -658,21 +667,22 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) {
if (front_parts[i] != parts[i]) {
// HARDCODED: Some Flag enums have the prefix 'FLAG_' for everything except 'FLAGS_DEFAULT' (same for 'METHOD_FLAG_' and'METHOD_FLAGS_DEFAULT').
bool hardcoded_exc = (i == candidate_len - 1 && ((front_parts[i] == "FLAGS" && parts[i] == "FLAG") || (front_parts[i] == "FLAG" && parts[i] == "FLAGS")));
- if (!hardcoded_exc)
+ if (!hardcoded_exc) {
break;
+ }
}
}
candidate_len = i;
- if (candidate_len == 0)
+ if (candidate_len == 0) {
return 0;
+ }
}
return candidate_len;
}
void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumInterface &p_ienum, int p_prefix_length) {
-
if (p_prefix_length > 0) {
for (List<ConstantInterface>::Element *E = p_ienum.constants.front(); E; E = E->next()) {
int curr_prefix_length = p_prefix_length;
@@ -683,22 +693,25 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI
Vector<String> parts = constant_name.split("_", /* p_allow_empty: */ true);
- if (parts.size() <= curr_prefix_length)
+ if (parts.size() <= curr_prefix_length) {
continue;
+ }
if (parts[curr_prefix_length][0] >= '0' && parts[curr_prefix_length][0] <= '9') {
// The name of enum constants may begin with a numeric digit when strip from the enum prefix,
// so we make the prefix for this constant one word shorter in those cases.
for (curr_prefix_length = curr_prefix_length - 1; curr_prefix_length > 0; curr_prefix_length--) {
- if (parts[curr_prefix_length][0] < '0' || parts[curr_prefix_length][0] > '9')
+ if (parts[curr_prefix_length][0] < '0' || parts[curr_prefix_length][0] > '9') {
break;
+ }
}
}
constant_name = "";
for (int i = curr_prefix_length; i < parts.size(); i++) {
- if (i > curr_prefix_length)
+ if (i > curr_prefix_length) {
constant_name += "_";
+ }
constant_name += parts[i];
}
@@ -708,12 +721,12 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI
}
void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
-
for (const List<MethodInterface>::Element *E = p_itype.methods.front(); E; E = E->next()) {
const MethodInterface &imethod = E->get();
- if (imethod.is_virtual)
+ if (imethod.is_virtual) {
continue;
+ }
const TypeInterface *return_type = _get_type_or_placeholder(imethod.return_type);
@@ -762,8 +775,9 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
List<InternalCall>::Element *match = method_icalls.find(im_icall);
if (match) {
- if (p_itype.api_type != ClassDB::API_EDITOR)
+ if (p_itype.api_type != ClassDB::API_EDITOR) {
match->get().editor_only = false;
+ }
method_icalls_map.insert(&E->get(), &match->get());
} else {
List<InternalCall>::Element *added = method_icalls.push_back(im_icall);
@@ -773,7 +787,6 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
}
void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
-
// Constants (in partial GD class)
p_output.append("\n#pragma warning disable CS1591 // Disable warning: "
@@ -809,8 +822,9 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
p_output.append(";");
}
- if (!global_constants.empty())
+ if (!global_constants.empty()) {
p_output.append("\n");
+ }
p_output.append(INDENT1 CLOSE_BLOCK); // end of GD class
@@ -872,8 +886,9 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
p_output.append(INDENT1 CLOSE_BLOCK);
- if (enum_in_static_class)
+ if (enum_in_static_class) {
p_output.append(INDENT1 CLOSE_BLOCK);
+ }
}
p_output.append(CLOSE_BLOCK); // end of namespace
@@ -882,7 +897,6 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
}
Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
-
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -908,8 +922,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
_generate_global_constants(constants_source);
String output_file = path::join(base_gen_dir, BINDINGS_GLOBAL_SCOPE_CLASS "_constants.cs");
Error save_err = _save_file(output_file, constants_source);
- if (save_err != OK)
+ if (save_err != OK) {
return save_err;
+ }
compile_items.push_back(output_file);
}
@@ -917,17 +932,20 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
const TypeInterface &itype = E.get();
- if (itype.api_type == ClassDB::API_EDITOR)
+ if (itype.api_type == ClassDB::API_EDITOR) {
continue;
+ }
String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
Error err = _generate_cs_type(itype, output_file);
- if (err == ERR_SKIP)
+ if (err == ERR_SKIP) {
continue;
+ }
- if (err != OK)
+ if (err != OK) {
return err;
+ }
compile_items.push_back(output_file);
}
@@ -958,10 +976,12 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
cs_icalls_content.append(m_icall.im_sig + ");\n"); \
}
- for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next())
+ for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) {
ADD_INTERNAL_CALL(E->get());
- for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next())
+ }
+ for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) {
ADD_INTERNAL_CALL(E->get());
+ }
#undef ADD_INTERNAL_CALL
@@ -970,8 +990,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS ".cs");
Error err = _save_file(internal_methods_file, cs_icalls_content);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
compile_items.push_back(internal_methods_file);
@@ -990,14 +1011,14 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props");
err = _save_file(includes_props_file, includes_props_content);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
return OK;
}
Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
-
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -1020,17 +1041,20 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
const TypeInterface &itype = E.get();
- if (itype.api_type != ClassDB::API_EDITOR)
+ if (itype.api_type != ClassDB::API_EDITOR) {
continue;
+ }
String output_file = path::join(godot_objects_gen_dir, itype.proxy_name + ".cs");
Error err = _generate_cs_type(itype, output_file);
- if (err == ERR_SKIP)
+ if (err == ERR_SKIP) {
continue;
+ }
- if (err != OK)
+ if (err != OK) {
return err;
+ }
compile_items.push_back(output_file);
}
@@ -1060,10 +1084,12 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
cs_icalls_content.append(m_icall.im_sig + ");\n"); \
}
- for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next())
+ for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) {
ADD_INTERNAL_CALL(E->get());
- for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next())
+ }
+ for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) {
ADD_INTERNAL_CALL(E->get());
+ }
#undef ADD_INTERNAL_CALL
@@ -1072,8 +1098,9 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
String internal_methods_file = path::join(base_gen_dir, BINDINGS_CLASS_NATIVECALLS_EDITOR ".cs");
Error err = _save_file(internal_methods_file, cs_icalls_content);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
compile_items.push_back(internal_methods_file);
@@ -1092,14 +1119,14 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
String includes_props_file = path::join(base_gen_dir, "GeneratedIncludes.props");
err = _save_file(includes_props_file, includes_props_content);
- if (err != OK)
+ if (err != OK) {
return err;
+ }
return OK;
}
Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
-
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
String output_dir = path::abspath(path::realpath(p_output_dir));
@@ -1147,7 +1174,6 @@ Error BindingsGenerator::generate_cs_api(const String &p_output_dir) {
// - Csc warning e.g.:
// ObjectType/LineEdit.cs(140,38): warning CS0108: 'LineEdit.FocusMode' hides inherited member 'Control.FocusMode'. Use the new keyword if hiding was intended.
Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const String &p_output_file) {
-
CRASH_COND(!itype.is_object_type);
bool is_derived_type = itype.base_name != StringName();
@@ -1222,93 +1248,89 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.append(INDENT1 "{");
- if (class_doc) {
-
- // Add constants
+ // Add constants
- for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) {
- const ConstantInterface &iconstant = E->get();
-
- if (iconstant.const_doc && iconstant.const_doc->description.size()) {
- String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype);
- Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
+ for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) {
+ const ConstantInterface &iconstant = E->get();
- if (summary_lines.size()) {
- output.append(MEMBER_BEGIN "/// <summary>\n");
+ if (iconstant.const_doc && iconstant.const_doc->description.size()) {
+ String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype);
+ Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
- for (int i = 0; i < summary_lines.size(); i++) {
- output.append(INDENT2 "/// ");
- output.append(summary_lines[i]);
- output.append("\n");
- }
+ if (summary_lines.size()) {
+ output.append(MEMBER_BEGIN "/// <summary>\n");
- output.append(INDENT2 "/// </summary>");
+ for (int i = 0; i < summary_lines.size(); i++) {
+ output.append(INDENT2 "/// ");
+ output.append(summary_lines[i]);
+ output.append("\n");
}
- }
- output.append(MEMBER_BEGIN "public const int ");
- output.append(iconstant.proxy_name);
- output.append(" = ");
- output.append(itos(iconstant.value));
- output.append(";");
+ output.append(INDENT2 "/// </summary>");
+ }
}
- if (itype.constants.size())
- output.append("\n");
+ output.append(MEMBER_BEGIN "public const int ");
+ output.append(iconstant.proxy_name);
+ output.append(" = ");
+ output.append(itos(iconstant.value));
+ output.append(";");
+ }
- // Add enums
+ if (itype.constants.size()) {
+ output.append("\n");
+ }
- for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) {
- const EnumInterface &ienum = E->get();
+ // Add enums
- ERR_FAIL_COND_V(ienum.constants.empty(), ERR_BUG);
+ for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) {
+ const EnumInterface &ienum = E->get();
- output.append(MEMBER_BEGIN "public enum ");
- output.append(ienum.cname.operator String());
- output.append(MEMBER_BEGIN OPEN_BLOCK);
+ ERR_FAIL_COND_V(ienum.constants.empty(), ERR_BUG);
- for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) {
- const ConstantInterface &iconstant = F->get();
+ output.append(MEMBER_BEGIN "public enum ");
+ output.append(ienum.cname.operator String());
+ output.append(MEMBER_BEGIN OPEN_BLOCK);
- if (iconstant.const_doc && iconstant.const_doc->description.size()) {
- String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype);
- Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
+ for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) {
+ const ConstantInterface &iconstant = F->get();
- if (summary_lines.size()) {
- output.append(INDENT3 "/// <summary>\n");
+ if (iconstant.const_doc && iconstant.const_doc->description.size()) {
+ String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype);
+ Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
- for (int i = 0; i < summary_lines.size(); i++) {
- output.append(INDENT3 "/// ");
- output.append(summary_lines[i]);
- output.append("\n");
- }
+ if (summary_lines.size()) {
+ output.append(INDENT3 "/// <summary>\n");
- output.append(INDENT3 "/// </summary>\n");
+ for (int i = 0; i < summary_lines.size(); i++) {
+ output.append(INDENT3 "/// ");
+ output.append(summary_lines[i]);
+ output.append("\n");
}
- }
- output.append(INDENT3);
- output.append(iconstant.proxy_name);
- output.append(" = ");
- output.append(itos(iconstant.value));
- output.append(F != ienum.constants.back() ? ",\n" : "\n");
+ output.append(INDENT3 "/// </summary>\n");
+ }
}
- output.append(INDENT2 CLOSE_BLOCK);
+ output.append(INDENT3);
+ output.append(iconstant.proxy_name);
+ output.append(" = ");
+ output.append(itos(iconstant.value));
+ output.append(F != ienum.constants.back() ? ",\n" : "\n");
}
- // Add properties
-
- for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) {
- const PropertyInterface &iprop = E->get();
- Error prop_err = _generate_cs_property(itype, iprop, output);
- ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err,
- "Failed to generate property '" + iprop.cname.operator String() +
- "' for class '" + itype.name + "'.");
- }
+ output.append(INDENT2 CLOSE_BLOCK);
}
- // TODO: BINDINGS_NATIVE_NAME_FIELD should be StringName, once we support it in C#
+ // Add properties
+
+ for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) {
+ const PropertyInterface &iprop = E->get();
+ Error prop_err = _generate_cs_property(itype, iprop, output);
+ ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err,
+ "Failed to generate property '" + iprop.cname.operator String() +
+ "' for class '" + itype.name + "'.");
+ }
if (itype.is_singleton) {
// Add the type name and the singleton pointer as static fields
@@ -1381,15 +1403,17 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
if (itype.is_singleton) {
InternalCall singleton_icall = InternalCall(itype.api_type, ICALL_PREFIX + itype.name + SINGLETON_ICALL_SUFFIX, "IntPtr");
- if (!find_icall_by_name(singleton_icall.name, custom_icalls))
+ if (!find_icall_by_name(singleton_icall.name, custom_icalls)) {
custom_icalls.push_back(singleton_icall);
+ }
}
if (is_derived_type && itype.is_instantiable) {
InternalCall ctor_icall = InternalCall(itype.api_type, ctor_method, "IntPtr", itype.proxy_name + " obj");
- if (!find_icall_by_name(ctor_icall.name, custom_icalls))
+ if (!find_icall_by_name(ctor_icall.name, custom_icalls)) {
custom_icalls.push_back(ctor_icall);
+ }
}
output.append(INDENT1 CLOSE_BLOCK /* class */
@@ -1403,7 +1427,6 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
}
Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInterface &p_itype, const PropertyInterface &p_iprop, StringBuilder &p_output) {
-
const MethodInterface *setter = p_itype.find_method_by_name(p_iprop.setter);
// Search it in base types too
@@ -1456,6 +1479,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
const TypeInterface *prop_itype = _get_type_or_null(proptype_name);
ERR_FAIL_NULL_V(prop_itype, ERR_BUG); // Property type not found
+ ERR_FAIL_COND_V_MSG(prop_itype->is_singleton, ERR_BUG,
+ "Property type is a singleton: '" + p_itype.name + "." + String(p_iprop.cname) + "'.");
+
if (p_iprop.prop_doc && p_iprop.prop_doc->description.size()) {
String xml_summary = bbcode_to_xml(fix_doc_description(p_iprop.prop_doc->description), &p_itype);
Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
@@ -1475,8 +1501,9 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.append(MEMBER_BEGIN "public ");
- if (p_itype.is_singleton)
+ if (p_itype.is_singleton) {
p_output.append("static ");
+ }
p_output.append(prop_itype->cs_type);
p_output.append(" ");
@@ -1546,9 +1573,11 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
}
Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterface &p_itype, const BindingsGenerator::MethodInterface &p_imethod, int &p_method_bind_count, StringBuilder &p_output) {
-
const TypeInterface *return_type = _get_type_or_placeholder(p_imethod.return_type);
+ ERR_FAIL_COND_V_MSG(return_type->is_singleton, ERR_BUG,
+ "Method return type is a singleton: '" + p_itype.name + "." + p_imethod.name + "'.");
+
String method_bind_field = "__method_bind_" + itos(p_method_bind_count);
String arguments_sig;
@@ -1564,29 +1593,41 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
const ArgumentInterface &iarg = F->get();
const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
+ ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG,
+ "Argument type is a singleton: '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'.");
+
+ if (iarg.default_argument.size()) {
+ CRASH_COND_MSG(!_arg_default_value_is_assignable_to_type(iarg.def_param_value, *arg_type),
+ "Invalid default value for parameter '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'.");
+ }
+
// Add the current arguments to the signature
// If the argument has a default value which is not a constant, we will make it Nullable
{
- if (F != p_imethod.arguments.front())
+ if (F != p_imethod.arguments.front()) {
arguments_sig += ", ";
+ }
- if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL)
+ if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) {
arguments_sig += "Nullable<";
+ }
arguments_sig += arg_type->cs_type;
- if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL)
+ if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) {
arguments_sig += "> ";
- else
+ } else {
arguments_sig += " ";
+ }
arguments_sig += iarg.name;
if (iarg.default_argument.size()) {
- if (iarg.def_param_mode != ArgumentInterface::CONSTANT)
+ if (iarg.def_param_mode != ArgumentInterface::CONSTANT) {
arguments_sig += " = null";
- else
+ } else {
arguments_sig += " = " + sformat(iarg.default_argument, arg_type->cs_type);
+ }
}
}
@@ -1604,17 +1645,19 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
cs_in_statements += " = ";
cs_in_statements += iarg.name;
- if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL)
+ if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) {
cs_in_statements += ".HasValue ? ";
- else
+ } else {
cs_in_statements += " != null ? ";
+ }
cs_in_statements += iarg.name;
- if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL)
+ if (iarg.def_param_mode == ArgumentInterface::NULLABLE_VAL) {
cs_in_statements += ".Value : ";
- else
+ } else {
cs_in_statements += " : ";
+ }
String def_arg = sformat(iarg.default_argument, arg_type->cs_type);
@@ -1674,8 +1717,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
}
if (p_imethod.is_deprecated) {
- if (p_imethod.deprecation_message.empty())
+ if (p_imethod.deprecation_message.empty()) {
WARN_PRINT("An empty deprecation message is discouraged. Method: '" + p_imethod.proxy_name + "'.");
+ }
p_output.append(MEMBER_BEGIN "[Obsolete(\"");
p_output.append(p_imethod.deprecation_message);
@@ -1735,8 +1779,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
im_call += ".";
im_call += im_icall->name;
- if (p_imethod.arguments.size())
+ if (p_imethod.arguments.size()) {
p_output.append(cs_in_statements);
+ }
if (return_type->cname == name_cache.type_void) {
p_output.append(im_call + "(" + icall_params + ");\n");
@@ -1763,10 +1808,14 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
const ArgumentInterface &iarg = F->get();
const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
+ ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG,
+ "Argument type is a singleton: '" + iarg.name + "' of signal" + p_itype.name + "." + p_isignal.name + "'.");
+
// Add the current arguments to the signature
- if (F != p_isignal.arguments.front())
+ if (F != p_isignal.arguments.front()) {
arguments_sig += ", ";
+ }
arguments_sig += arg_type->cs_type;
arguments_sig += " ";
@@ -1793,8 +1842,9 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
}
if (p_isignal.is_deprecated) {
- if (p_isignal.deprecation_message.empty())
+ if (p_isignal.deprecation_message.empty()) {
WARN_PRINT("An empty deprecation message is discouraged. Signal: '" + p_isignal.proxy_name + "'.");
+ }
p_output.append(MEMBER_BEGIN "[Obsolete(\"");
p_output.append(p_isignal.deprecation_message);
@@ -1825,8 +1875,9 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
// Generate event
p_output.append(MEMBER_BEGIN "[Signal]" MEMBER_BEGIN "public ");
- if (p_itype.is_singleton)
+ if (p_itype.is_singleton) {
p_output.append("static ");
+ }
p_output.append("event ");
p_output.append(delegate_name);
@@ -1834,18 +1885,20 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
p_output.append(p_isignal.proxy_name);
p_output.append("\n" OPEN_BLOCK_L2);
- if (p_itype.is_singleton)
+ if (p_itype.is_singleton) {
p_output.append("add => Singleton.Connect(__signal_name_");
- else
+ } else {
p_output.append("add => Connect(__signal_name_");
+ }
p_output.append(p_isignal.name);
p_output.append(", new Callable(value));\n");
- if (p_itype.is_singleton)
+ if (p_itype.is_singleton) {
p_output.append(INDENT3 "remove => Singleton.Disconnect(__signal_name_");
- else
+ } else {
p_output.append(INDENT3 "remove => Disconnect(__signal_name_");
+ }
p_output.append(p_isignal.name);
p_output.append(", new Callable(value));\n");
@@ -1856,7 +1909,6 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
}
Error BindingsGenerator::generate_glue(const String &p_output_dir) {
-
ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED);
bool dir_exists = DirAccess::exists(p_output_dir);
@@ -1880,7 +1932,6 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
CRASH_COND(itype.cname != name_cache.type_Object);
CRASH_COND(!itype.is_instantiable);
CRASH_COND(itype.api_type != ClassDB::API_CORE);
- CRASH_COND(itype.is_reference);
CRASH_COND(itype.is_singleton);
}
@@ -1901,8 +1952,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
String singleton_icall_name = ICALL_PREFIX + itype.name + SINGLETON_ICALL_SUFFIX;
InternalCall singleton_icall = InternalCall(itype.api_type, singleton_icall_name, "IntPtr");
- if (!find_icall_by_name(singleton_icall.name, custom_icalls))
+ if (!find_icall_by_name(singleton_icall.name, custom_icalls)) {
custom_icalls.push_back(singleton_icall);
+ }
output.append("Object* ");
output.append(singleton_icall_name);
@@ -1914,8 +1966,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
if (is_derived_type && itype.is_instantiable) {
InternalCall ctor_icall = InternalCall(itype.api_type, ctor_method, "IntPtr", itype.proxy_name + " obj");
- if (!find_icall_by_name(ctor_icall.name, custom_icalls))
+ if (!find_icall_by_name(ctor_icall.name, custom_icalls)) {
custom_icalls.push_back(ctor_icall);
+ }
output.append("Object* ");
output.append(ctor_method);
@@ -1961,7 +2014,6 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
bool tools_sequence = false;
for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) {
-
if (tools_sequence) {
if (!E->get().editor_only) {
tools_sequence = false;
@@ -2015,8 +2067,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
output.append("\n#endif // MONO_GLUE_ENABLED\n");
Error save_err = _save_file(path::join(p_output_dir, "mono_glue.gen.cpp"), output);
- if (save_err != OK)
+ if (save_err != OK) {
return save_err;
+ }
OS::get_singleton()->print("Mono glue generated successfully\n");
@@ -2028,7 +2081,6 @@ uint32_t BindingsGenerator::get_version() {
}
Error BindingsGenerator::_save_file(const String &p_path, const StringBuilder &p_content) {
-
FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V_MSG(!file, ERR_FILE_CANT_WRITE, "Cannot open file: '" + p_path + "'.");
@@ -2040,9 +2092,9 @@ Error BindingsGenerator::_save_file(const String &p_path, const StringBuilder &p
}
Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInterface &p_itype, const BindingsGenerator::MethodInterface &p_imethod, StringBuilder &p_output) {
-
- if (p_imethod.is_virtual)
+ if (p_imethod.is_virtual) {
return OK; // Ignore
+ }
bool ret_void = p_imethod.return_type.cname == name_cache.type_void;
@@ -2070,10 +2122,12 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
c_in_statements += sformat(", &%s_in);\n", c_param_name);
}
} else {
- if (i > 0)
+ if (i > 0) {
c_args_var_content += ", ";
- if (arg_type->c_in.size())
+ }
+ if (arg_type->c_in.size()) {
c_in_statements += sformat(arg_type->c_in, arg_type->c_type, c_param_name);
+ }
c_args_var_content += sformat(arg_type->c_arg_in, c_param_name);
}
@@ -2103,8 +2157,9 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
if (!generated_icall_funcs.find(im_icall)) {
generated_icall_funcs.push_back(im_icall);
- if (im_icall->editor_only)
+ if (im_icall->editor_only) {
p_output.append("#ifdef TOOLS_ENABLED\n");
+ }
// Generate icall function
@@ -2222,30 +2277,33 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
p_output.append(CLOSE_BLOCK "\n");
- if (im_icall->editor_only)
+ if (im_icall->editor_only) {
p_output.append("#endif // TOOLS_ENABLED\n");
+ }
}
return OK;
}
const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(const TypeReference &p_typeref) {
-
const Map<StringName, TypeInterface>::Element *builtin_type_match = builtin_types.find(p_typeref.cname);
- if (builtin_type_match)
+ if (builtin_type_match) {
return &builtin_type_match->get();
+ }
const OrderedHashMap<StringName, TypeInterface>::Element obj_type_match = obj_types.find(p_typeref.cname);
- if (obj_type_match)
+ if (obj_type_match) {
return &obj_type_match.get();
+ }
if (p_typeref.is_enum) {
const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(p_typeref.cname);
- if (enum_match)
+ if (enum_match) {
return &enum_match->get();
+ }
// Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead.
const Map<StringName, TypeInterface>::Element *int_match = builtin_types.find(name_cache.type_int);
@@ -2257,18 +2315,19 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(con
}
const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placeholder(const TypeReference &p_typeref) {
-
const TypeInterface *found = _get_type_or_null(p_typeref);
- if (found)
+ if (found) {
return found;
+ }
ERR_PRINT(String() + "Type not found. Creating placeholder: '" + p_typeref.cname.operator String() + "'.");
const Map<StringName, TypeInterface>::Element *match = placeholder_types.find(p_typeref.cname);
- if (match)
+ if (match) {
return &match->get();
+ }
TypeInterface placeholder;
TypeInterface::create_placeholder_type(placeholder, p_typeref.cname);
@@ -2277,7 +2336,6 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placehol
}
StringName BindingsGenerator::_get_int_type_name_from_meta(GodotTypeInfo::Metadata p_meta) {
-
switch (p_meta) {
case GodotTypeInfo::METADATA_INT_IS_INT8:
return "sbyte";
@@ -2310,7 +2368,6 @@ StringName BindingsGenerator::_get_int_type_name_from_meta(GodotTypeInfo::Metada
}
StringName BindingsGenerator::_get_float_type_name_from_meta(GodotTypeInfo::Metadata p_meta) {
-
switch (p_meta) {
case GodotTypeInfo::METADATA_REAL_IS_FLOAT:
return "float";
@@ -2328,8 +2385,85 @@ StringName BindingsGenerator::_get_float_type_name_from_meta(GodotTypeInfo::Meta
}
}
-bool BindingsGenerator::_populate_object_type_interfaces() {
+bool BindingsGenerator::_arg_default_value_is_assignable_to_type(const Variant &p_val, const TypeInterface &p_arg_type) {
+ if (p_arg_type.name == name_cache.type_Variant) {
+ // Variant can take anything
+ return true;
+ }
+ switch (p_val.get_type()) {
+ case Variant::NIL:
+ return p_arg_type.is_object_type ||
+ name_cache.is_nullable_type(p_arg_type.name);
+ case Variant::BOOL:
+ return p_arg_type.name == name_cache.type_bool;
+ case Variant::INT:
+ return p_arg_type.name == name_cache.type_sbyte ||
+ p_arg_type.name == name_cache.type_short ||
+ p_arg_type.name == name_cache.type_int ||
+ p_arg_type.name == name_cache.type_byte ||
+ p_arg_type.name == name_cache.type_ushort ||
+ p_arg_type.name == name_cache.type_uint ||
+ p_arg_type.name == name_cache.type_long ||
+ p_arg_type.name == name_cache.type_ulong ||
+ p_arg_type.name == name_cache.type_float ||
+ p_arg_type.name == name_cache.type_double ||
+ p_arg_type.is_enum;
+ case Variant::FLOAT:
+ return p_arg_type.name == name_cache.type_float ||
+ p_arg_type.name == name_cache.type_double;
+ case Variant::STRING:
+ case Variant::STRING_NAME:
+ return p_arg_type.name == name_cache.type_String ||
+ p_arg_type.name == name_cache.type_StringName ||
+ p_arg_type.name == name_cache.type_NodePath;
+ case Variant::NODE_PATH:
+ return p_arg_type.name == name_cache.type_NodePath;
+ case Variant::TRANSFORM:
+ case Variant::TRANSFORM2D:
+ case Variant::BASIS:
+ case Variant::QUAT:
+ case Variant::PLANE:
+ case Variant::AABB:
+ case Variant::COLOR:
+ case Variant::VECTOR2:
+ case Variant::RECT2:
+ case Variant::VECTOR3:
+ case Variant::_RID:
+ case Variant::ARRAY:
+ case Variant::DICTIONARY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
+ case Variant::CALLABLE:
+ case Variant::SIGNAL:
+ return p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ case Variant::OBJECT:
+ return p_arg_type.is_object_type;
+ case Variant::VECTOR2I:
+ return p_arg_type.name == name_cache.type_Vector2 ||
+ p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ case Variant::RECT2I:
+ return p_arg_type.name == name_cache.type_Rect2 ||
+ p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ case Variant::VECTOR3I:
+ return p_arg_type.name == name_cache.type_Vector3 ||
+ p_arg_type.name == Variant::get_type_name(p_val.get_type());
+ default:
+ CRASH_NOW_MSG("Unexpected Variant type: " + itos(p_val.get_type()));
+ break;
+ }
+
+ return false;
+}
+
+bool BindingsGenerator::_populate_object_type_interfaces() {
obj_types.clear();
List<StringName> class_list;
@@ -2391,8 +2525,9 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
const PropertyInfo &property = E->get();
- if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY)
+ if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) {
continue;
+ }
if (property.name.find("/") >= 0) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
@@ -2404,10 +2539,12 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
iprop.setter = ClassDB::get_property_setter(type_cname, iprop.cname);
iprop.getter = ClassDB::get_property_getter(type_cname, iprop.cname);
- if (iprop.setter != StringName())
+ if (iprop.setter != StringName()) {
accessor_methods[iprop.setter] = iprop.cname;
- if (iprop.getter != StringName())
+ }
+ if (iprop.getter != StringName()) {
accessor_methods[iprop.getter] = iprop.cname;
+ }
bool valid = false;
iprop.index = ClassDB::get_property_index(type_cname, iprop.cname, &valid);
@@ -2451,20 +2588,23 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
int argc = method_info.arguments.size();
- if (method_info.name.empty())
+ if (method_info.name.empty()) {
continue;
+ }
String cname = method_info.name;
- if (blacklisted_methods.find(itype.cname) && blacklisted_methods[itype.cname].find(cname))
+ if (blacklisted_methods.find(itype.cname) && blacklisted_methods[itype.cname].find(cname)) {
continue;
+ }
MethodInterface imethod;
imethod.name = method_info.name;
imethod.cname = cname;
- if (method_info.flags & METHOD_FLAG_VIRTUAL)
+ if (method_info.flags & METHOD_FLAG_VIRTUAL) {
imethod.is_virtual = true;
+ }
PropertyInfo return_info = method_info.return_val;
@@ -2486,9 +2626,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
// We assume the return type is void.
imethod.return_type.cname = name_cache.type_void;
- // Actually, more methods like this may be added in the future,
- // which could actually will return something different.
- // Let's put this to notify us if that ever happens.
+ // Actually, more methods like this may be added in the future, which could return
+ // something different. Let's put this check to notify us if that ever happens.
if (itype.cname != name_cache.type_Object || imethod.name != "free") {
WARN_PRINT("Notification: New unexpected virtual non-overridable method found."
" We only expected Object.free, but found '" +
@@ -2499,13 +2638,12 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
imethod.return_type.is_enum = true;
} else if (return_info.class_name != StringName()) {
imethod.return_type.cname = return_info.class_name;
- if (!imethod.is_virtual && ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference) && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE) {
- /* clang-format off */
- ERR_PRINT("Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'."
- " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'.");
- /* clang-format on */
- ERR_FAIL_V(false);
- }
+
+ bool bad_reference_hint = !imethod.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE &&
+ ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference);
+ ERR_FAIL_COND_V_MSG(bad_reference_hint, false,
+ String() + "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." +
+ " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'.");
} else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
imethod.return_type.cname = return_info.hint_string;
} else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
@@ -2596,6 +2734,10 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
}
}
+ ERR_FAIL_COND_V_MSG(itype.find_property_by_name(imethod.cname), false,
+ "Method name conflicts with property: '" + itype.name + "." + imethod.name + "'.");
+
+ // Classes starting with an underscore are ignored unless they're used as a property setter or getter
if (!imethod.is_virtual && imethod.name[0] == '_') {
for (const List<PropertyInterface>::Element *F = itype.properties.front(); F; F = F->next()) {
const PropertyInterface &iprop = F->get();
@@ -2775,8 +2917,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
}
bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, ArgumentInterface &r_iarg) {
-
- r_iarg.default_argument = p_val;
+ r_iarg.def_param_value = p_val;
+ r_iarg.default_argument = p_val.operator String();
switch (p_val.get_type()) {
case Variant::NIL:
@@ -2809,8 +2951,9 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
}
break;
case Variant::TRANSFORM:
- if (p_val.operator Transform() == Transform())
+ if (p_val.operator Transform() == Transform()) {
r_iarg.default_argument.clear();
+ }
r_iarg.default_argument = "new %s(" + r_iarg.default_argument + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
break;
@@ -2876,14 +3019,14 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
break;
}
- if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type.cname == name_cache.type_Variant && r_iarg.default_argument != "null")
+ if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type.cname == name_cache.type_Variant && r_iarg.default_argument != "null") {
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
+ }
return true;
}
void BindingsGenerator::_populate_builtin_type_interfaces() {
-
builtin_types.clear();
TypeInterface itype;
@@ -3259,7 +3402,6 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
}
void BindingsGenerator::_populate_global_constants() {
-
int global_constants_count = GlobalConstants::get_global_constant_count();
if (global_constants_count > 0) {
@@ -3270,7 +3412,6 @@ void BindingsGenerator::_populate_global_constants() {
const DocData::ClassDoc &global_scope_doc = match->value();
for (int i = 0; i < global_constants_count; i++) {
-
String constant_name = GlobalConstants::get_global_constant_name(i);
const DocData::ConstantDoc *const_doc = nullptr;
@@ -3349,14 +3490,12 @@ void BindingsGenerator::_populate_global_constants() {
}
void BindingsGenerator::_initialize_blacklisted_methods() {
-
blacklisted_methods["Object"].push_back("to_string"); // there is already ToString
blacklisted_methods["Object"].push_back("_to_string"); // override ToString instead
blacklisted_methods["Object"].push_back("_init"); // never called in C# (TODO: implement it)
}
void BindingsGenerator::_log(const char *p_format, ...) {
-
if (log_print_enabled) {
va_list list;
@@ -3367,7 +3506,6 @@ void BindingsGenerator::_log(const char *p_format, ...) {
}
void BindingsGenerator::_initialize() {
-
initialized = false;
EditorHelp::generate_doc();
@@ -3388,14 +3526,14 @@ void BindingsGenerator::_initialize() {
core_custom_icalls.clear();
editor_custom_icalls.clear();
- for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next())
+ for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) {
_generate_method_icalls(E.get());
+ }
initialized = true;
}
void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) {
-
const int NUM_OPTIONS = 2;
String generate_all_glue_option = "--generate-mono-glue";
String generate_cs_glue_option = "--generate-mono-cs-glue";
@@ -3458,21 +3596,25 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
}
if (glue_dir_path.length()) {
- if (bindings_generator.generate_glue(glue_dir_path) != OK)
+ if (bindings_generator.generate_glue(glue_dir_path) != OK) {
ERR_PRINT(generate_all_glue_option + ": Failed to generate the C++ glue.");
+ }
- if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK)
+ if (bindings_generator.generate_cs_api(glue_dir_path.plus_file(API_SOLUTION_NAME)) != OK) {
ERR_PRINT(generate_all_glue_option + ": Failed to generate the C# API.");
+ }
}
if (cs_dir_path.length()) {
- if (bindings_generator.generate_cs_api(cs_dir_path) != OK)
+ if (bindings_generator.generate_cs_api(cs_dir_path) != OK) {
ERR_PRINT(generate_cs_glue_option + ": Failed to generate the C# API.");
+ }
}
if (cpp_dir_path.length()) {
- if (bindings_generator.generate_glue(cpp_dir_path) != OK)
+ if (bindings_generator.generate_glue(cpp_dir_path) != OK) {
ERR_PRINT(generate_cpp_glue_option + ": Failed to generate the C++ glue.");
+ }
}
// Exit once done
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 5672231e9a..90c1c9f3ee 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -41,7 +41,6 @@
#include "core/ustring.h"
class BindingsGenerator {
-
struct ConstantInterface {
String name;
String proxy_name;
@@ -85,16 +84,12 @@ class BindingsGenerator {
struct TypeReference {
StringName cname;
- bool is_enum;
+ bool is_enum = false;
- TypeReference() :
- is_enum(false) {
- }
+ TypeReference() {}
TypeReference(const StringName &p_cname) :
- cname(p_cname),
- is_enum(false) {
- }
+ cname(p_cname) {}
};
struct ArgumentInterface {
@@ -107,7 +102,9 @@ class BindingsGenerator {
TypeReference type;
String name;
- DefaultParamMode def_param_mode;
+
+ Variant def_param_value;
+ DefaultParamMode def_param_mode = CONSTANT;
/**
* Determines the expression for the parameter default value.
@@ -116,9 +113,7 @@ class BindingsGenerator {
*/
String default_argument;
- ArgumentInterface() {
- def_param_mode = CONSTANT;
- }
+ ArgumentInterface() {}
};
struct MethodInterface {
@@ -138,19 +133,19 @@ class BindingsGenerator {
/**
* Determines if the method has a variable number of arguments (VarArg)
*/
- bool is_vararg;
+ bool is_vararg = false;
/**
* Virtual methods ("virtual" as defined by the Godot API) are methods that by default do nothing,
* but can be overridden by the user to add custom functionality.
* e.g.: _ready, _process, etc.
*/
- bool is_virtual;
+ bool is_virtual = false;
/**
* Determines if the call should fallback to Godot's object.Call(string, params) in C#.
*/
- bool requires_object_call;
+ bool requires_object_call = false;
/**
* Determines if the method visibility is 'internal' (visible only to files in the same assembly).
@@ -158,27 +153,20 @@ class BindingsGenerator {
* but are required by properties as getters or setters.
* Methods that are not meant to be exposed are those that begin with underscore and are not virtual.
*/
- bool is_internal;
+ bool is_internal = false;
List<ArgumentInterface> arguments;
- const DocData::MethodDoc *method_doc;
+ const DocData::MethodDoc *method_doc = nullptr;
- bool is_deprecated;
+ bool is_deprecated = false;
String deprecation_message;
void add_argument(const ArgumentInterface &argument) {
arguments.push_back(argument);
}
- MethodInterface() {
- is_vararg = false;
- is_virtual = false;
- requires_object_call = false;
- is_internal = false;
- method_doc = nullptr;
- is_deprecated = false;
- }
+ MethodInterface() {}
};
struct SignalInterface {
@@ -192,19 +180,16 @@ class BindingsGenerator {
List<ArgumentInterface> arguments;
- const DocData::MethodDoc *method_doc;
+ const DocData::MethodDoc *method_doc = nullptr;
- bool is_deprecated;
+ bool is_deprecated = false;
String deprecation_message;
void add_argument(const ArgumentInterface &argument) {
arguments.push_back(argument);
}
- SignalInterface() {
- method_doc = nullptr;
- is_deprecated = false;
- }
+ SignalInterface() {}
};
struct TypeInterface {
@@ -225,26 +210,26 @@ class BindingsGenerator {
*/
String proxy_name;
- ClassDB::APIType api_type;
+ ClassDB::APIType api_type = ClassDB::API_NONE;
- bool is_enum;
- bool is_object_type;
- bool is_singleton;
- bool is_reference;
+ bool is_enum = false;
+ bool is_object_type = false;
+ bool is_singleton = false;
+ bool is_reference = false;
/**
* Used only by Object-derived types.
* Determines if this type is not abstract (incomplete).
* e.g.: CanvasItem cannot be instantiated.
*/
- bool is_instantiable;
+ bool is_instantiable = false;
/**
* Used only by Object-derived types.
* Determines if the C# class owns the native handle and must free it somehow when disposed.
* e.g.: Reference types must notify when the C# instance is disposed, for proper refcounting.
*/
- bool memory_own;
+ bool memory_own = false;
/**
* This must be set to true for any struct bigger than 32-bits. Those cannot be passed/returned by value
@@ -252,7 +237,7 @@ class BindingsGenerator {
* In this case, [c_out] and [cs_out] must have a different format, explained below.
* The Mono IL interpreter icall trampolines don't support passing structs bigger than 32-bits by value (at least not on WASM).
*/
- bool ret_as_byref_arg;
+ bool ret_as_byref_arg = false;
// !! The comments of the following fields make reference to other fields via square brackets, e.g.: [field_name]
// !! When renaming those fields, make sure to rename their references in the comments
@@ -279,7 +264,7 @@ class BindingsGenerator {
* Formatting elements:
* %0 or %s: name of the parameter
*/
- String c_arg_in;
+ String c_arg_in = "%s";
/**
* One or more statements that determine how a variable of this type is returned from a function.
@@ -362,7 +347,7 @@ class BindingsGenerator {
*/
String im_type_out;
- const DocData::ClassDoc *class_doc;
+ const DocData::ClassDoc *class_doc = nullptr;
List<ConstantInterface> constants;
List<EnumInterface> enums;
@@ -372,8 +357,9 @@ class BindingsGenerator {
const MethodInterface *find_method_by_name(const StringName &p_cname) const {
for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) {
- if (E->get().cname == p_cname)
+ if (E->get().cname == p_cname) {
return &E->get();
+ }
}
return nullptr;
@@ -381,8 +367,9 @@ class BindingsGenerator {
const PropertyInterface *find_property_by_name(const StringName &p_cname) const {
for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) {
- if (E->get().cname == p_cname)
+ if (E->get().cname == p_cname) {
return &E->get();
+ }
}
return nullptr;
@@ -390,8 +377,9 @@ class BindingsGenerator {
const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const {
for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) {
- if (E->get().proxy_name == p_proxy_name)
+ if (E->get().proxy_name == p_proxy_name) {
return &E->get();
+ }
}
return nullptr;
@@ -399,8 +387,9 @@ class BindingsGenerator {
const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const {
for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) {
- if (E->get().proxy_name == p_proxy_name)
+ if (E->get().proxy_name == p_proxy_name) {
return &E->get();
+ }
}
return nullptr;
@@ -482,24 +471,7 @@ class BindingsGenerator {
r_enum_itype.class_doc = &EditorHelp::get_doc_data()->class_list[r_enum_itype.proxy_name];
}
- TypeInterface() {
-
- api_type = ClassDB::API_NONE;
-
- is_enum = false;
- is_object_type = false;
- is_singleton = false;
- is_reference = false;
- is_instantiable = false;
-
- memory_own = false;
-
- ret_as_byref_arg = false;
-
- c_arg_in = "%s";
-
- class_doc = nullptr;
- }
+ TypeInterface() {}
};
struct InternalCall {
@@ -532,8 +504,8 @@ class BindingsGenerator {
}
};
- bool log_print_enabled;
- bool initialized;
+ bool log_print_enabled = true;
+ bool initialized = false;
OrderedHashMap<StringName, TypeInterface> obj_types;
@@ -557,58 +529,70 @@ class BindingsGenerator {
void _initialize_blacklisted_methods();
struct NameCache {
- StringName type_void;
- StringName type_Array;
- StringName type_Dictionary;
- StringName type_Variant;
- StringName type_VarArg;
- StringName type_Object;
- StringName type_Reference;
- StringName type_RID;
- StringName type_String;
- StringName type_StringName;
- StringName type_NodePath;
- StringName type_at_GlobalScope;
- StringName enum_Error;
-
- StringName type_sbyte;
- StringName type_short;
- StringName type_int;
- StringName type_long;
- StringName type_byte;
- StringName type_ushort;
- StringName type_uint;
- StringName type_ulong;
- StringName type_float;
- StringName type_double;
-
- NameCache() {
- type_void = StaticCString::create("void");
- type_Array = StaticCString::create("Array");
- type_Dictionary = StaticCString::create("Dictionary");
- type_Variant = StaticCString::create("Variant");
- type_VarArg = StaticCString::create("VarArg");
- type_Object = StaticCString::create("Object");
- type_Reference = StaticCString::create("Reference");
- type_RID = StaticCString::create("RID");
- type_String = StaticCString::create("String");
- type_StringName = StaticCString::create("StringName");
- type_NodePath = StaticCString::create("NodePath");
- type_at_GlobalScope = StaticCString::create("@GlobalScope");
- enum_Error = StaticCString::create("Error");
-
- type_sbyte = StaticCString::create("sbyte");
- type_short = StaticCString::create("short");
- type_int = StaticCString::create("int");
- type_long = StaticCString::create("long");
- type_byte = StaticCString::create("byte");
- type_ushort = StaticCString::create("ushort");
- type_uint = StaticCString::create("uint");
- type_ulong = StaticCString::create("ulong");
- type_float = StaticCString::create("float");
- type_double = StaticCString::create("double");
+ StringName type_void = StaticCString::create("void");
+ StringName type_Variant = StaticCString::create("Variant");
+ StringName type_VarArg = StaticCString::create("VarArg");
+ StringName type_Object = StaticCString::create("Object");
+ StringName type_Reference = StaticCString::create("Reference");
+ StringName type_RID = StaticCString::create("RID");
+ StringName type_String = StaticCString::create("String");
+ StringName type_StringName = StaticCString::create("StringName");
+ StringName type_NodePath = StaticCString::create("NodePath");
+ StringName type_at_GlobalScope = StaticCString::create("@GlobalScope");
+ StringName enum_Error = StaticCString::create("Error");
+
+ StringName type_sbyte = StaticCString::create("sbyte");
+ StringName type_short = StaticCString::create("short");
+ StringName type_int = StaticCString::create("int");
+ StringName type_byte = StaticCString::create("byte");
+ StringName type_ushort = StaticCString::create("ushort");
+ StringName type_uint = StaticCString::create("uint");
+ StringName type_long = StaticCString::create("long");
+ StringName type_ulong = StaticCString::create("ulong");
+
+ StringName type_bool = StaticCString::create("bool");
+ StringName type_float = StaticCString::create("float");
+ StringName type_double = StaticCString::create("double");
+
+ StringName type_Vector2 = StaticCString::create("Vector2");
+ StringName type_Rect2 = StaticCString::create("Rect2");
+ StringName type_Vector3 = StaticCString::create("Vector3");
+
+ // Object not included as it must be checked for all derived classes
+ static constexpr int nullable_types_count = 17;
+ StringName nullable_types[nullable_types_count] = {
+ type_String,
+ type_StringName,
+ type_NodePath,
+
+ StaticCString::create(_STR(Array)),
+ StaticCString::create(_STR(Dictionary)),
+ StaticCString::create(_STR(Callable)),
+ StaticCString::create(_STR(Signal)),
+
+ StaticCString::create(_STR(PackedByteArray)),
+ StaticCString::create(_STR(PackedInt32Array)),
+ StaticCString::create(_STR(PackedInt64rray)),
+ StaticCString::create(_STR(PackedFloat32Array)),
+ StaticCString::create(_STR(PackedFloat64Array)),
+ StaticCString::create(_STR(PackedStringArray)),
+ StaticCString::create(_STR(PackedVector2Array)),
+ StaticCString::create(_STR(PackedVector3Array)),
+ StaticCString::create(_STR(PackedColorArray)),
+ };
+
+ bool is_nullable_type(const StringName &p_type) const {
+ for (int i = 0; i < nullable_types_count; i++) {
+ if (p_type == nullable_types[i]) {
+ return true;
+ }
+ }
+
+ return false;
}
+ NameCache() {}
+
private:
NameCache(const NameCache &);
NameCache &operator=(const NameCache &);
@@ -619,8 +603,9 @@ class BindingsGenerator {
const List<InternalCall>::Element *find_icall_by_name(const String &p_name, const List<InternalCall> &p_list) {
const List<InternalCall>::Element *it = p_list.front();
while (it) {
- if (it->get().name == p_name)
+ if (it->get().name == p_name) {
return it;
+ }
it = it->next();
}
return nullptr;
@@ -628,20 +613,22 @@ class BindingsGenerator {
const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const {
for (const List<ConstantInterface>::Element *E = p_constants.front(); E; E = E->next()) {
- if (E->get().name == p_name)
+ if (E->get().name == p_name) {
return &E->get();
+ }
}
return nullptr;
}
inline String get_unique_sig(const TypeInterface &p_type) {
- if (p_type.is_reference)
+ if (p_type.is_reference) {
return "Ref";
- else if (p_type.is_object_type)
+ } else if (p_type.is_object_type) {
return "Obj";
- else if (p_type.is_enum)
+ } else if (p_type.is_enum) {
return "int";
+ }
return p_type.name;
}
@@ -660,6 +647,7 @@ class BindingsGenerator {
StringName _get_float_type_name_from_meta(GodotTypeInfo::Metadata p_meta);
bool _arg_default_value_from_variant(const Variant &p_val, ArgumentInterface &r_iarg);
+ bool _arg_default_value_is_assignable_to_type(const Variant &p_val, const TypeInterface &p_arg_type);
bool _populate_object_type_interfaces();
void _populate_builtin_type_interfaces();
@@ -697,9 +685,7 @@ public:
static void handle_cmdline_args(const List<String> &p_cmdline_args);
- BindingsGenerator() :
- log_print_enabled(true),
- initialized(false) {
+ BindingsGenerator() {
_initialize();
}
};
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index e5c2d023d3..3a30f3106c 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -45,7 +45,6 @@
namespace CSharpProject {
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) {
-
if (!GLOBAL_DEF("mono/project/auto_update_project", true))
return;
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index c9117f1312..b183787618 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -399,7 +399,6 @@ MonoBoolean godot_icall_Utils_OS_UnixFileHasExecutableAccess(MonoString *p_file_
}
void register_editor_internal_calls() {
-
// GodotSharpDirs
mono_add_internal_call("GodotTools.Internals.GodotSharpDirs::internal_ResDataDir", (void *)godot_icall_GodotSharpDirs_ResDataDir);
mono_add_internal_call("GodotTools.Internals.GodotSharpDirs::internal_ResMetadataDir", (void *)godot_icall_GodotSharpDirs_ResMetadataDir);
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp
index d6a271f1d9..1cdb08d50e 100644
--- a/modules/mono/editor/godotsharp_export.cpp
+++ b/modules/mono/editor/godotsharp_export.cpp
@@ -78,7 +78,7 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String>
if (r_assembly_dependencies.has(ref_name))
continue;
- GDMonoAssembly *ref_assembly = NULL;
+ GDMonoAssembly *ref_assembly = nullptr;
{
MonoAssemblyName *ref_aname = mono_assembly_name_new("A"); // We can't allocate an empty MonoAssemblyName, hence "A"
diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp
index 3ffbf8ba14..7276612230 100644
--- a/modules/mono/editor/script_class_parser.cpp
+++ b/modules/mono/editor/script_class_parser.cpp
@@ -54,13 +54,11 @@ const char *ScriptClassParser::token_names[ScriptClassParser::TK_MAX] = {
};
String ScriptClassParser::get_token_name(ScriptClassParser::Token p_token) {
-
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
return token_names[p_token];
}
ScriptClassParser::Token ScriptClassParser::get_token() {
-
while (true) {
switch (code[idx]) {
case '\n': {
@@ -268,7 +266,6 @@ ScriptClassParser::Token ScriptClassParser::get_token() {
}
Error ScriptClassParser::_skip_generic_type_params() {
-
Token tk;
while (true) {
@@ -337,7 +334,6 @@ Error ScriptClassParser::_skip_generic_type_params() {
}
Error ScriptClassParser::_parse_type_full_name(String &r_full_name) {
-
Token tk = get_token();
if (tk != TK_IDENTIFIER) {
@@ -370,7 +366,6 @@ Error ScriptClassParser::_parse_type_full_name(String &r_full_name) {
}
Error ScriptClassParser::_parse_class_base(Vector<String> &r_base) {
-
String name;
Error err = _parse_type_full_name(name);
@@ -470,7 +465,6 @@ Error ScriptClassParser::_parse_type_constraints() {
}
Error ScriptClassParser::_parse_namespace_name(String &r_name, int &r_curly_stack) {
-
Token tk = get_token();
if (tk == TK_IDENTIFIER) {
@@ -497,7 +491,6 @@ Error ScriptClassParser::_parse_namespace_name(String &r_name, int &r_curly_stac
}
Error ScriptClassParser::parse(const String &p_code) {
-
code = p_code;
idx = 0;
line = 0;
@@ -653,7 +646,6 @@ static String get_preprocessor_directive(const String &p_line, int p_from) {
}
static void run_dummy_preprocessor(String &r_source, const String &p_filepath) {
-
Vector<String> lines = r_source.split("\n", /* p_allow_empty: */ true);
bool *include_lines = memnew_arr(bool, lines.size());
@@ -720,7 +712,6 @@ static void run_dummy_preprocessor(String &r_source, const String &p_filepath) {
}
Error ScriptClassParser::parse_file(const String &p_filepath) {
-
String source;
Error ferr = read_all_file_utf8(p_filepath, source);
diff --git a/modules/mono/editor/script_class_parser.h b/modules/mono/editor/script_class_parser.h
index a76a3a50a9..c194ed1422 100644
--- a/modules/mono/editor/script_class_parser.h
+++ b/modules/mono/editor/script_class_parser.h
@@ -36,7 +36,6 @@
#include "core/vector.h"
class ScriptClassParser {
-
public:
struct NameDecl {
enum Type {
diff --git a/modules/mono/glue/arguments_vector.h b/modules/mono/glue/arguments_vector.h
index aeb466ba72..4ee553fc11 100644
--- a/modules/mono/glue/arguments_vector.h
+++ b/modules/mono/glue/arguments_vector.h
@@ -35,7 +35,6 @@
template <typename T, int POOL_SIZE = 5>
struct ArgumentsVector {
-
private:
T pool[POOL_SIZE];
T *_ptr;
diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp
index 2da39a916a..e43b06d18e 100644
--- a/modules/mono/glue/gd_glue.cpp
+++ b/modules/mono/glue/gd_glue.cpp
@@ -91,7 +91,6 @@ void godot_icall_GD_print(MonoArray *p_what) {
}
void godot_icall_GD_printerr(MonoArray *p_what) {
-
String str;
int length = mono_array_length(p_what);
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index d596163926..692da991c7 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -86,7 +86,6 @@ String _get_mono_user_dir() {
}
class _GodotSharpDirs {
-
public:
String res_data_dir;
String res_metadata_dir;
diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp
index e362d5affb..16a6875406 100644
--- a/modules/mono/mono_gc_handle.cpp
+++ b/modules/mono/mono_gc_handle.cpp
@@ -56,11 +56,9 @@ MonoGCHandleData MonoGCHandleData::new_weak_handle(MonoObject *p_object) {
}
Ref<MonoGCHandleRef> MonoGCHandleRef::create_strong(MonoObject *p_object) {
-
return memnew(MonoGCHandleRef(MonoGCHandleData::new_strong_handle(p_object)));
}
Ref<MonoGCHandleRef> MonoGCHandleRef::create_weak(MonoObject *p_object) {
-
return memnew(MonoGCHandleRef(MonoGCHandleData::new_weak_handle(p_object)));
}
diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h
index fbcb405b0d..13cfad4654 100644
--- a/modules/mono/mono_gc_handle.h
+++ b/modules/mono/mono_gc_handle.h
@@ -47,8 +47,8 @@ enum class GCHandleType : char {
// Manual release of the GC handle must be done when using this struct
struct MonoGCHandleData {
- uint32_t handle;
- gdmono::GCHandleType type;
+ uint32_t handle = 0;
+ gdmono::GCHandleType type = gdmono::GCHandleType::NIL;
_FORCE_INLINE_ bool is_released() const { return !handle; }
_FORCE_INLINE_ bool is_weak() const { return type == gdmono::GCHandleType::WEAK_HANDLE; }
@@ -68,10 +68,7 @@ struct MonoGCHandleData {
MonoGCHandleData(const MonoGCHandleData &) = default;
- MonoGCHandleData() :
- handle(0),
- type(gdmono::GCHandleType::NIL) {
- }
+ MonoGCHandleData() {}
MonoGCHandleData(uint32_t p_handle, gdmono::GCHandleType p_type) :
handle(p_handle),
@@ -84,7 +81,6 @@ struct MonoGCHandleData {
};
class MonoGCHandleRef : public Reference {
-
GDCLASS(MonoGCHandleRef, Reference);
MonoGCHandleData data;
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index fbaa81e83f..39c3bd8934 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -130,7 +130,6 @@ void gd_mono_profiler_init() {
}
void gd_mono_debug_init() {
-
CharString da_args = OS::get_singleton()->get_environment("GODOT_MONO_DEBUGGER_AGENT").utf8();
if (da_args.length()) {
@@ -251,7 +250,6 @@ void GDMono::add_mono_shared_libs_dir_to_path() {
}
void GDMono::determine_mono_dirs(String &r_assembly_rootdir, String &r_config_dir) {
-
String bundled_assembly_rootdir = GodotSharpDirs::get_data_mono_lib_dir();
String bundled_config_dir = GodotSharpDirs::get_data_mono_etc_dir();
@@ -314,7 +312,6 @@ void GDMono::determine_mono_dirs(String &r_assembly_rootdir, String &r_config_di
}
void GDMono::initialize() {
-
ERR_FAIL_NULL(Engine::get_singleton());
print_verbose("Mono: Initializing module...");
@@ -413,7 +410,6 @@ void GDMono::initialize() {
}
void GDMono::initialize_load_assemblies() {
-
#ifndef MONO_GLUE_ENABLED
CRASH_NOW_MSG("Mono: This binary was built with 'mono_glue=no'; cannot load assemblies.");
#endif
@@ -426,6 +422,9 @@ void GDMono::initialize_load_assemblies() {
#if defined(TOOLS_ENABLED)
bool tool_assemblies_loaded = _load_tools_assemblies();
CRASH_COND_MSG(!tool_assemblies_loaded, "Mono: Failed to load '" TOOLS_ASM_NAME "' assemblies.");
+
+ if (Main::is_project_manager())
+ return;
#endif
// Load the project's main assembly. This doesn't necessarily need to succeed.
@@ -471,6 +470,7 @@ uint64_t get_editor_api_hash() {
uint32_t get_bindings_version() {
GD_UNREACHABLE();
}
+
uint32_t get_cs_glue_version() {
GD_UNREACHABLE();
}
@@ -513,12 +513,10 @@ void GDMono::_init_exception_policy() {
}
void GDMono::add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly) {
-
assemblies[p_domain_id][p_assembly->get_name()] = p_assembly;
}
GDMonoAssembly *GDMono::get_loaded_assembly(const String &p_name) {
-
if (p_name == "mscorlib" && corlib_assembly)
return corlib_assembly;
@@ -529,7 +527,6 @@ GDMonoAssembly *GDMono::get_loaded_assembly(const String &p_name) {
}
bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly) {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!r_assembly);
#endif
@@ -543,7 +540,6 @@ bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bo
}
bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly) {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!r_assembly);
#endif
@@ -552,7 +548,6 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo
}
bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly, const Vector<String> &p_search_dirs) {
-
#ifdef DEBUG_ENABLED
CRASH_COND(!r_assembly);
#endif
@@ -572,7 +567,6 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo
}
bool GDMono::load_assembly_from(const String &p_name, const String &p_path, GDMonoAssembly **r_assembly, bool p_refonly) {
-
CRASH_COND(!r_assembly);
print_verbose("Mono: Loading assembly " + p_name + (p_refonly ? " (refonly)" : "") + "...");
@@ -620,7 +614,6 @@ String ApiAssemblyInfo::to_string(ApiAssemblyInfo::Type p_type) {
}
bool GDMono::_load_corlib_assembly() {
-
if (corlib_assembly)
return true;
@@ -634,7 +627,6 @@ bool GDMono::_load_corlib_assembly() {
#ifdef TOOLS_ENABLED
bool GDMono::copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const String &p_config) {
-
String src_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String dst_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config);
@@ -705,7 +697,6 @@ static bool try_get_cached_api_hash_for(const String &p_api_assemblies_dir, bool
}
static void create_cached_api_hash_for(const String &p_api_assemblies_dir) {
-
String core_api_assembly_path = p_api_assemblies_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
String editor_api_assembly_path = p_api_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
String cached_api_hash_path = p_api_assemblies_dir.plus_file("api_hash_cache.cfg");
@@ -748,7 +739,6 @@ bool GDMono::_temp_domain_load_are_assemblies_out_of_sync(const String &p_config
}
String GDMono::update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync, const bool *p_editor_api_out_of_sync) {
-
#define FAIL_REASON(m_out_of_sync, m_prebuilt_exists) \
( \
(m_out_of_sync ? \
@@ -805,7 +795,6 @@ String GDMono::update_api_assemblies_from_prebuilt(const String &p_config, const
#endif
bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, const String &p_config, bool p_refonly) {
-
if (r_loaded_api_assembly.assembly)
return true;
@@ -839,7 +828,6 @@ bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, c
#ifdef TOOLS_ENABLED
bool GDMono::_load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, const String &p_config, bool p_refonly) {
-
if (r_loaded_api_assembly.assembly)
return true;
@@ -916,7 +904,6 @@ bool GDMono::_try_load_api_assemblies_preset() {
}
void GDMono::_load_api_assemblies() {
-
bool api_assemblies_loaded = _try_load_api_assemblies_preset();
#if defined(TOOLS_ENABLED) && !defined(GD_MONO_SINGLE_APPDOMAIN)
@@ -969,7 +956,6 @@ void GDMono::_load_api_assemblies() {
#ifdef TOOLS_ENABLED
bool GDMono::_load_tools_assemblies() {
-
if (tools_assembly && tools_project_editor_assembly)
return true;
@@ -981,7 +967,6 @@ bool GDMono::_load_tools_assemblies() {
#endif
bool GDMono::_load_project_assembly() {
-
if (project_assembly)
return true;
@@ -1001,7 +986,6 @@ bool GDMono::_load_project_assembly() {
}
void GDMono::_install_trace_listener() {
-
#ifdef DEBUG_ENABLED
// Install the trace listener now before the project assembly is loaded
GDMonoClass *debug_utils = get_core_api_assembly()->get_class(BINDINGS_NAMESPACE, "DebuggingUtils");
@@ -1018,7 +1002,6 @@ void GDMono::_install_trace_listener() {
#ifndef GD_MONO_SINGLE_APPDOMAIN
Error GDMono::_load_scripts_domain() {
-
ERR_FAIL_COND_V(scripts_domain != nullptr, ERR_BUG);
print_verbose("Mono: Loading scripts domain...");
@@ -1033,7 +1016,6 @@ Error GDMono::_load_scripts_domain() {
}
Error GDMono::_unload_scripts_domain() {
-
ERR_FAIL_NULL_V(scripts_domain, ERR_BUG);
print_verbose("Mono: Finalizing scripts domain...");
@@ -1086,7 +1068,6 @@ Error GDMono::_unload_scripts_domain() {
#ifdef GD_MONO_HOT_RELOAD
Error GDMono::reload_scripts_domain() {
-
ERR_FAIL_COND_V(!runtime_initialized, ERR_BUG);
if (scripts_domain) {
@@ -1123,7 +1104,6 @@ Error GDMono::reload_scripts_domain() {
#ifndef GD_MONO_SINGLE_APPDOMAIN
Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
-
CRASH_COND(p_domain == nullptr);
CRASH_COND(p_domain == GDMono::get_singleton()->get_scripts_domain()); // Should use _unload_scripts_domain() instead
@@ -1156,7 +1136,6 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
#endif
GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) {
-
MonoImage *image = mono_class_get_image(p_raw_class);
if (image == corlib_assembly->get_image())
@@ -1180,7 +1159,6 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) {
}
GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName &p_name) {
-
GDMonoClass *klass = corlib_assembly->get_class(p_namespace, p_name);
if (klass)
return klass;
@@ -1200,7 +1178,6 @@ GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName &
}
void GDMono::_domain_assemblies_cleanup(uint32_t p_domain_id) {
-
HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[p_domain_id];
const String *k = nullptr;
@@ -1212,7 +1189,6 @@ void GDMono::_domain_assemblies_cleanup(uint32_t p_domain_id) {
}
void GDMono::unhandled_exception_hook(MonoObject *p_exc, void *) {
-
// This method will be called by the runtime when a thrown exception is not handled.
// It won't be called when we manually treat a thrown exception as unhandled.
// We assume the exception was already printed before calling this hook.
@@ -1229,7 +1205,6 @@ void GDMono::unhandled_exception_hook(MonoObject *p_exc, void *) {
}
GDMono::GDMono() {
-
singleton = this;
gdmono_log = memnew(GDMonoLog);
@@ -1256,7 +1231,6 @@ GDMono::GDMono() {
}
GDMono::~GDMono() {
-
if (is_runtime_initialized()) {
#ifndef GD_MONO_SINGLE_APPDOMAIN
if (scripts_domain) {
@@ -1330,51 +1304,42 @@ GDMono::~GDMono() {
_GodotSharp *_GodotSharp::singleton = nullptr;
void _GodotSharp::attach_thread() {
-
GDMonoUtils::attach_current_thread();
}
void _GodotSharp::detach_thread() {
-
GDMonoUtils::detach_current_thread();
}
int32_t _GodotSharp::get_domain_id() {
-
MonoDomain *domain = mono_domain_get();
CRASH_COND(!domain); // User must check if runtime is initialized before calling this method
return mono_domain_get_id(domain);
}
int32_t _GodotSharp::get_scripts_domain_id() {
-
MonoDomain *domain = GDMono::get_singleton()->get_scripts_domain();
CRASH_COND(!domain); // User must check if scripts domain is loaded before calling this method
return mono_domain_get_id(domain);
}
bool _GodotSharp::is_scripts_domain_loaded() {
-
return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != nullptr;
}
bool _GodotSharp::_is_domain_finalizing_for_unload(int32_t p_domain_id) {
-
return is_domain_finalizing_for_unload(p_domain_id);
}
bool _GodotSharp::is_domain_finalizing_for_unload() {
-
return is_domain_finalizing_for_unload(mono_domain_get());
}
bool _GodotSharp::is_domain_finalizing_for_unload(int32_t p_domain_id) {
-
return is_domain_finalizing_for_unload(mono_domain_get_by_id(p_domain_id));
}
bool _GodotSharp::is_domain_finalizing_for_unload(MonoDomain *p_domain) {
-
if (!p_domain)
return true;
if (p_domain == GDMono::get_singleton()->get_scripts_domain() && GDMono::get_singleton()->is_finalizing_scripts_domain())
@@ -1383,12 +1348,10 @@ bool _GodotSharp::is_domain_finalizing_for_unload(MonoDomain *p_domain) {
}
bool _GodotSharp::is_runtime_shutting_down() {
-
return mono_runtime_is_shutting_down();
}
bool _GodotSharp::is_runtime_initialized() {
-
return GDMono::get_singleton()->is_runtime_initialized();
}
@@ -1402,7 +1365,6 @@ void _GodotSharp::_reload_assemblies(bool p_soft_reload) {
}
void _GodotSharp::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("attach_thread"), &_GodotSharp::attach_thread);
ClassDB::bind_method(D_METHOD("detach_thread"), &_GodotSharp::detach_thread);
@@ -1417,11 +1379,9 @@ void _GodotSharp::_bind_methods() {
}
_GodotSharp::_GodotSharp() {
-
singleton = this;
}
_GodotSharp::~_GodotSharp() {
-
singleton = nullptr;
}
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 153ae891f7..833855b371 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -48,9 +48,9 @@ enum Type {
};
struct Version {
- uint64_t godot_api_hash;
- uint32_t bindings_version;
- uint32_t cs_glue_version;
+ uint64_t godot_api_hash = 0;
+ uint32_t bindings_version = 0;
+ uint32_t cs_glue_version = 0;
bool operator==(const Version &p_other) const {
return godot_api_hash == p_other.godot_api_hash &&
@@ -58,11 +58,7 @@ struct Version {
cs_glue_version == p_other.cs_glue_version;
}
- Version() :
- godot_api_hash(0),
- bindings_version(0),
- cs_glue_version(0) {
- }
+ Version() {}
Version(uint64_t p_godot_api_hash,
uint32_t p_bindings_version,
@@ -79,7 +75,6 @@ String to_string(Type p_type);
} // namespace ApiAssemblyInfo
class GDMono {
-
public:
enum UnhandledExceptionPolicy {
POLICY_TERMINATE_APP,
@@ -87,13 +82,10 @@ public:
};
struct LoadedApiAssembly {
- GDMonoAssembly *assembly;
- bool out_of_sync;
+ GDMonoAssembly *assembly = nullptr;
+ bool out_of_sync = false;
- LoadedApiAssembly() :
- assembly(nullptr),
- out_of_sync(false) {
- }
+ LoadedApiAssembly() {}
};
private:
@@ -256,7 +248,6 @@ public:
namespace gdmono {
class ScopeDomain {
-
MonoDomain *prev_domain;
public:
diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp
index da2ed2a7fc..073c9a5214 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.cpp
+++ b/modules/mono/mono_gd/gd_mono_assembly.cpp
@@ -46,7 +46,6 @@
Vector<String> GDMonoAssembly::search_dirs;
void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config, const String &p_custom_bcl_dir) {
-
String framework_dir;
if (!p_custom_bcl_dir.empty()) {
@@ -101,7 +100,6 @@ void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const Strin
// assembly to the list of loaded assemblies so that the 'search' hook can look it up.
void GDMonoAssembly::assembly_load_hook(MonoAssembly *assembly, [[maybe_unused]] void *user_data) {
-
String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly)));
MonoImage *image = mono_assembly_get_image(assembly);
@@ -135,7 +133,6 @@ MonoAssembly *GDMonoAssembly::assembly_refonly_preload_hook(MonoAssemblyName *an
}
MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, [[maybe_unused]] void *user_data, bool refonly) {
-
String name = String::utf8(mono_assembly_name_get_name(aname));
bool has_extension = name.ends_with(".dll") || name.ends_with(".exe");
@@ -147,13 +144,11 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, [[maybe_unus
}
MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, [[maybe_unused]] void *user_data, bool refonly) {
-
String name = String::utf8(mono_assembly_name_get_name(aname));
return _load_assembly_search(name, aname, refonly, search_dirs);
}
MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, MonoAssemblyName *p_aname, bool p_refonly, const Vector<String> &p_search_dirs) {
-
MonoAssembly *res = nullptr;
String path;
@@ -190,7 +185,6 @@ MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, MonoAs
}
String GDMonoAssembly::find_assembly(const String &p_name) {
-
String path;
bool has_extension = p_name.ends_with(".dll") || p_name.ends_with(".exe");
@@ -217,7 +211,6 @@ String GDMonoAssembly::find_assembly(const String &p_name) {
}
void GDMonoAssembly::initialize() {
-
fill_search_dirs(search_dirs);
mono_install_assembly_search_hook(&assembly_search_hook, nullptr);
@@ -228,7 +221,6 @@ void GDMonoAssembly::initialize() {
}
MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, bool p_refonly, MonoAssemblyName *p_aname) {
-
Vector<uint8_t> data = FileAccess::get_file_as_array(p_path);
ERR_FAIL_COND_V_MSG(data.empty(), nullptr, "Could read the assembly in the specified location");
@@ -326,7 +318,6 @@ no_pdb:
}
void GDMonoAssembly::unload() {
-
ERR_FAIL_NULL(image); // Should not be called if already unloaded
for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) {
@@ -345,7 +336,6 @@ String GDMonoAssembly::get_path() const {
}
GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) {
-
ERR_FAIL_NULL_V(image, nullptr);
ClassKey key(p_namespace, p_name);
@@ -369,7 +359,6 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri
}
GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) {
-
ERR_FAIL_NULL_V(image, nullptr);
Map<MonoClass *, GDMonoClass *>::Element *match = cached_raw.find(p_mono_class);
@@ -389,7 +378,6 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) {
}
GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) {
-
GDMonoClass *match = nullptr;
if (gdobject_class_cache_updated) {
@@ -449,7 +437,6 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class)
}
GDMonoAssembly *GDMonoAssembly::load(const String &p_name, MonoAssemblyName *p_aname, bool p_refonly, const Vector<String> &p_search_dirs) {
-
if (GDMono::get_singleton()->get_corlib_assembly() && (p_name == "mscorlib" || p_name == "mscorlib.dll"))
return GDMono::get_singleton()->get_corlib_assembly();
@@ -469,7 +456,6 @@ GDMonoAssembly *GDMonoAssembly::load(const String &p_name, MonoAssemblyName *p_a
}
GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_path, bool p_refonly) {
-
if (p_name == "mscorlib" || p_name == "mscorlib.dll")
return GDMono::get_singleton()->get_corlib_assembly();
@@ -490,18 +476,7 @@ GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_
return loaded_asm;
}
-GDMonoAssembly::GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) :
- name(p_name),
- image(p_image),
- assembly(p_assembly),
-#ifdef GD_MONO_HOT_RELOAD
- modified_time(0),
-#endif
- gdobject_class_cache_updated(false) {
-}
-
GDMonoAssembly::~GDMonoAssembly() {
-
if (image)
unload();
}
diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h
index 7fc1817993..63899dc9be 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.h
+++ b/modules/mono/mono_gd/gd_mono_assembly.h
@@ -40,7 +40,6 @@
#include "gd_mono_utils.h"
class GDMonoAssembly {
-
struct ClassKey {
struct Hasher {
static _FORCE_INLINE_ uint32_t hash(const ClassKey &p_key) {
@@ -73,10 +72,10 @@ class GDMonoAssembly {
MonoAssembly *assembly;
#ifdef GD_MONO_HOT_RELOAD
- uint64_t modified_time;
+ uint64_t modified_time = 0;
#endif
- bool gdobject_class_cache_updated;
+ bool gdobject_class_cache_updated = false;
Map<StringName, GDMonoClass *> gdobject_class_cache;
HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes;
@@ -125,7 +124,11 @@ public:
static GDMonoAssembly *load(const String &p_name, MonoAssemblyName *p_aname, bool p_refonly, const Vector<String> &p_search_dirs);
static GDMonoAssembly *load_from(const String &p_name, const String &p_path, bool p_refonly);
- GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly);
+ GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) :
+ name(p_name),
+ image(p_image),
+ assembly(p_assembly) {
+ }
~GDMonoAssembly();
};
diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp
index 5ddf18d544..c002ad2139 100644
--- a/modules/mono/mono_gd/gd_mono_cache.cpp
+++ b/modules/mono/mono_gd/gd_mono_cache.cpp
@@ -65,7 +65,6 @@ CachedData cached_data;
#define CACHE_METHOD_THUNK_AND_CHECK(m_class, m_method, m_val) CACHE_METHOD_THUNK_AND_CHECK_IMPL(cached_data.methodthunk_##m_class##_##m_method, m_val)
void CachedData::clear_corlib_cache() {
-
corlib_cache_updated = false;
class_MonoObject = nullptr;
@@ -98,7 +97,6 @@ void CachedData::clear_corlib_cache() {
}
void CachedData::clear_godot_api_cache() {
-
godot_api_cache_updated = false;
rawclass_Dictionary = nullptr;
@@ -193,7 +191,6 @@ void CachedData::clear_godot_api_cache() {
#define GODOT_API_NS_CLASS(m_ns, m_class) (GDMono::get_singleton()->get_core_api_assembly()->get_class(m_ns, #m_class))
void update_corlib_cache() {
-
CACHE_CLASS_AND_CHECK(MonoObject, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_object_class()));
CACHE_CLASS_AND_CHECK(bool, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_boolean_class()));
CACHE_CLASS_AND_CHECK(int8_t, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_sbyte_class()));
@@ -228,7 +225,6 @@ void update_corlib_cache() {
}
void update_godot_api_cache() {
-
CACHE_CLASS_AND_CHECK(Vector2, GODOT_API_CLASS(Vector2));
CACHE_CLASS_AND_CHECK(Vector2i, GODOT_API_CLASS(Vector2i));
CACHE_CLASS_AND_CHECK(Rect2, GODOT_API_CLASS(Rect2));
diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h
index 3cf2bd6ce5..a7bbc763a7 100644
--- a/modules/mono/mono_gd/gd_mono_cache.h
+++ b/modules/mono/mono_gd/gd_mono_cache.h
@@ -37,7 +37,6 @@
namespace GDMonoCache {
struct CachedData {
-
// -----------------------------------------------
// corlib classes
diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp
index 9dabb4ec4c..691da55b10 100644
--- a/modules/mono/mono_gd/gd_mono_class.cpp
+++ b/modules/mono/mono_gd/gd_mono_class.cpp
@@ -105,7 +105,6 @@ GDMonoClass *GDMonoClass::get_nesting_class() const {
#ifdef TOOLS_ENABLED
Vector<MonoClassField *> GDMonoClass::get_enum_fields() {
-
bool class_is_enum = mono_class_is_enum(mono_class);
ERR_FAIL_COND_V(!class_is_enum, Vector<MonoClassField *>());
@@ -128,7 +127,6 @@ Vector<MonoClassField *> GDMonoClass::get_enum_fields() {
#endif
bool GDMonoClass::has_attribute(GDMonoClass *p_attr_class) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_NULL_V(p_attr_class, false);
#endif
@@ -143,7 +141,6 @@ bool GDMonoClass::has_attribute(GDMonoClass *p_attr_class) {
}
MonoObject *GDMonoClass::get_attribute(GDMonoClass *p_attr_class) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_NULL_V(p_attr_class, nullptr);
#endif
@@ -158,7 +155,6 @@ MonoObject *GDMonoClass::get_attribute(GDMonoClass *p_attr_class) {
}
void GDMonoClass::fetch_attributes() {
-
ERR_FAIL_COND(attributes != nullptr);
attributes = mono_custom_attrs_from_class(get_mono_ptr());
@@ -166,7 +162,6 @@ void GDMonoClass::fetch_attributes() {
}
void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base) {
-
CRASH_COND(!CACHED_CLASS(GodotObject)->is_assignable_from(this));
if (methods_fetched)
@@ -182,7 +177,6 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
ERR_CONTINUE(!method);
if (method->get_name() != name) {
-
#ifdef DEBUG_ENABLED
String fullname = method->get_ret_type_full_name() + " " + name + "(" + method->get_signature_desc(true) + ")";
WARN_PRINT("Method '" + fullname + "' is hidden by Godot API method. Should be '" +
@@ -196,7 +190,6 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
// This allows us to warn the user here if he is using snake_case by mistake.
if (p_native_base != this) {
-
GDMonoClass *native_top = p_native_base;
while (native_top) {
GDMonoMethod *m = native_top->get_method(name, method->get_parameters_count());
@@ -260,7 +253,6 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
}
GDMonoMethod *GDMonoClass::get_fetched_method_unknown_params(const StringName &p_name) {
-
ERR_FAIL_COND_V(!methods_fetched, nullptr);
const MethodKey *k = nullptr;
@@ -274,23 +266,19 @@ GDMonoMethod *GDMonoClass::get_fetched_method_unknown_params(const StringName &p
}
bool GDMonoClass::has_fetched_method_unknown_params(const StringName &p_name) {
-
return get_fetched_method_unknown_params(p_name) != nullptr;
}
bool GDMonoClass::implements_interface(GDMonoClass *p_interface) {
-
return mono_class_implements_interface(mono_class, p_interface->get_mono_ptr());
}
bool GDMonoClass::has_public_parameterless_ctor() {
-
GDMonoMethod *ctor = get_method(".ctor", 0);
return ctor && ctor->get_visibility() == IMonoClassMember::PUBLIC;
}
GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_count) {
-
MethodKey key = MethodKey(p_name, p_params_count);
GDMonoMethod **match = methods.getptr(key);
@@ -314,7 +302,6 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou
}
GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) {
-
MonoMethodSignature *sig = mono_method_signature(p_raw_method);
int params_count = mono_signature_get_param_count(sig);
@@ -324,14 +311,12 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) {
}
GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName &p_name) {
-
MonoMethodSignature *sig = mono_method_signature(p_raw_method);
int params_count = mono_signature_get_param_count(sig);
return get_method(p_raw_method, p_name, params_count);
}
GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName &p_name, int p_params_count) {
-
ERR_FAIL_NULL_V(p_raw_method, nullptr);
MethodKey key = MethodKey(p_name, p_params_count);
@@ -348,7 +333,6 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName
}
GDMonoMethod *GDMonoClass::get_method_with_desc(const String &p_description, bool p_include_namespace) {
-
MonoMethodDesc *desc = mono_method_desc_new(p_description.utf8().get_data(), p_include_namespace);
MonoMethod *method = mono_method_desc_search_in_class(desc, mono_class);
mono_method_desc_free(desc);
@@ -362,7 +346,6 @@ GDMonoMethod *GDMonoClass::get_method_with_desc(const String &p_description, boo
}
GDMonoField *GDMonoClass::get_field(const StringName &p_name) {
-
Map<StringName, GDMonoField *>::Element *result = fields.find(p_name);
if (result)
@@ -384,7 +367,6 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) {
}
const Vector<GDMonoField *> &GDMonoClass::get_all_fields() {
-
if (fields_fetched)
return fields_list;
@@ -410,7 +392,6 @@ const Vector<GDMonoField *> &GDMonoClass::get_all_fields() {
}
GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) {
-
Map<StringName, GDMonoProperty *>::Element *result = properties.find(p_name);
if (result)
@@ -432,7 +413,6 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) {
}
const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() {
-
if (properties_fetched)
return properties_list;
@@ -485,7 +465,6 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() {
}
const Vector<GDMonoMethod *> &GDMonoClass::get_all_methods() {
-
if (!method_list_fetched) {
void *iter = nullptr;
MonoMethod *raw_method = nullptr;
@@ -500,7 +479,6 @@ const Vector<GDMonoMethod *> &GDMonoClass::get_all_methods() {
}
GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name, MonoClass *p_class, GDMonoAssembly *p_assembly) {
-
namespace_name = p_namespace;
class_name = p_name;
mono_class = p_class;
@@ -517,7 +495,6 @@ GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name
}
GDMonoClass::~GDMonoClass() {
-
if (attributes) {
mono_custom_attrs_free(attributes);
}
diff --git a/modules/mono/mono_gd/gd_mono_field.h b/modules/mono/mono_gd/gd_mono_field.h
index 61f2c8f071..5b40b439f9 100644
--- a/modules/mono/mono_gd/gd_mono_field.h
+++ b/modules/mono/mono_gd/gd_mono_field.h
@@ -36,7 +36,6 @@
#include "i_mono_class_member.h"
class GDMonoField : public IMonoClassMember {
-
GDMonoClass *owner;
MonoClassField *mono_field;
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index 1898785699..27e402d777 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -45,7 +45,6 @@
namespace GDMonoInternals {
void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
-
// This method should not fail
CRASH_COND(!unmanaged);
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index b56350ae1b..04728be725 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -51,7 +51,6 @@ GDMonoLog *GDMonoLog::singleton = nullptr;
#ifdef GD_MONO_LOG_ENABLED
static int get_log_level_id(const char *p_log_level) {
-
const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", nullptr };
int i = 0;
@@ -65,7 +64,6 @@ static int get_log_level_id(const char *p_log_level) {
}
void GDMonoLog::mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *) {
-
FileAccess *f = GDMonoLog::get_singleton()->log_file;
if (GDMonoLog::get_singleton()->log_level_id >= get_log_level_id(log_level)) {
@@ -94,7 +92,6 @@ void GDMonoLog::mono_log_callback(const char *log_domain, const char *log_level,
}
bool GDMonoLog::_try_create_logs_dir(const String &p_logs_dir) {
-
if (!DirAccess::exists(p_logs_dir)) {
DirAccessRef diraccess = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
ERR_FAIL_COND_V(!diraccess, false);
@@ -106,7 +103,6 @@ bool GDMonoLog::_try_create_logs_dir(const String &p_logs_dir) {
}
void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) {
-
static const uint64_t MAX_SECS = 5 * 86400; // 5 days
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -135,7 +131,6 @@ void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) {
}
void GDMonoLog::initialize() {
-
CharString log_level = OS::get_singleton()->get_environment("GODOT_MONO_LOG_LEVEL").utf8();
if (log_level.length() != 0 && get_log_level_id(log_level.get_data()) == -1) {
@@ -183,14 +178,12 @@ void GDMonoLog::initialize() {
}
GDMonoLog::GDMonoLog() {
-
singleton = this;
log_level_id = -1;
}
GDMonoLog::~GDMonoLog() {
-
singleton = nullptr;
if (log_file) {
@@ -207,12 +200,10 @@ void GDMonoLog::initialize() {
}
GDMonoLog::GDMonoLog() {
-
singleton = this;
}
GDMonoLog::~GDMonoLog() {
-
singleton = nullptr;
}
diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h
index 1fc21f7df5..3a52316060 100644
--- a/modules/mono/mono_gd/gd_mono_log.h
+++ b/modules/mono/mono_gd/gd_mono_log.h
@@ -45,7 +45,6 @@
#endif
class GDMonoLog {
-
#ifdef GD_MONO_LOG_ENABLED
int log_level_id;
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 91ee07388b..085062261d 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -787,7 +787,6 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
}
Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type, bool p_fail_with_err = true) {
-
ERR_FAIL_COND_V(!p_type.type_class, Variant());
switch (p_type.type_encoding) {
diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp
index 432aa74a6f..e601bb12ad 100644
--- a/modules/mono/mono_gd/gd_mono_method.cpp
+++ b/modules/mono/mono_gd/gd_mono_method.cpp
@@ -245,7 +245,6 @@ void GDMonoMethod::get_parameter_types(Vector<ManagedType> &types) const {
}
const MethodInfo &GDMonoMethod::get_method_info() {
-
if (!method_info_fetched) {
method_info.name = name;
diff --git a/modules/mono/mono_gd/gd_mono_method.h b/modules/mono/mono_gd/gd_mono_method.h
index 54b2eba3e8..f78f57dca0 100644
--- a/modules/mono/mono_gd/gd_mono_method.h
+++ b/modules/mono/mono_gd/gd_mono_method.h
@@ -36,7 +36,6 @@
#include "i_mono_class_member.h"
class GDMonoMethod : public IMonoClassMember {
-
StringName name;
int params_count;
diff --git a/modules/mono/mono_gd/gd_mono_method_thunk.h b/modules/mono/mono_gd/gd_mono_method_thunk.h
index 0e05e974e9..01f3ae342a 100644
--- a/modules/mono/mono_gd/gd_mono_method_thunk.h
+++ b/modules/mono/mono_gd/gd_mono_method_thunk.h
@@ -47,10 +47,9 @@
template <class... ParamTypes>
struct GDMonoMethodThunk {
-
typedef void(GD_MONO_STDCALL *M)(ParamTypes... p_args, MonoException **);
- M mono_method_thunk;
+ M mono_method_thunk = nullptr;
public:
_FORCE_INLINE_ void invoke(ParamTypes... p_args, MonoException **r_exc) {
@@ -81,9 +80,7 @@ public:
mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr());
}
- GDMonoMethodThunk() :
- mono_method_thunk(nullptr) {
- }
+ GDMonoMethodThunk() {}
explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) {
set_from_method(p_mono_method);
@@ -92,10 +89,9 @@ public:
template <class R, class... ParamTypes>
struct GDMonoMethodThunkR {
-
typedef R(GD_MONO_STDCALL *M)(ParamTypes... p_args, MonoException **);
- M mono_method_thunk;
+ M mono_method_thunk = nullptr;
public:
_FORCE_INLINE_ R invoke(ParamTypes... p_args, MonoException **r_exc) {
@@ -127,9 +123,7 @@ public:
mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr());
}
- GDMonoMethodThunkR() :
- mono_method_thunk(nullptr) {
- }
+ GDMonoMethodThunkR() {}
explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
@@ -247,8 +241,7 @@ struct VariadicInvokeMonoMethodR<1, R, P1> {
template <class... ParamTypes>
struct GDMonoMethodThunk {
-
- GDMonoMethod *mono_method;
+ GDMonoMethod *mono_method = nullptr;
public:
_FORCE_INLINE_ void invoke(ParamTypes... p_args, MonoException **r_exc) {
@@ -277,9 +270,7 @@ public:
mono_method = p_mono_method;
}
- GDMonoMethodThunk() :
- mono_method(nullptr) {
- }
+ GDMonoMethodThunk() {}
explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) {
set_from_method(p_mono_method);
@@ -288,8 +279,7 @@ public:
template <class R, class... ParamTypes>
struct GDMonoMethodThunkR {
-
- GDMonoMethod *mono_method;
+ GDMonoMethod *mono_method = nullptr;
public:
_FORCE_INLINE_ R invoke(ParamTypes... p_args, MonoException **r_exc) {
@@ -318,9 +308,7 @@ public:
mono_method = p_mono_method;
}
- GDMonoMethodThunkR() :
- mono_method(nullptr) {
- }
+ GDMonoMethodThunkR() {}
explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) {
set_from_method(p_mono_method);
diff --git a/modules/mono/mono_gd/gd_mono_property.h b/modules/mono/mono_gd/gd_mono_property.h
index 4653758a86..611ac293e4 100644
--- a/modules/mono/mono_gd/gd_mono_property.h
+++ b/modules/mono/mono_gd/gd_mono_property.h
@@ -36,7 +36,6 @@
#include "i_mono_class_member.h"
class GDMonoProperty : public IMonoClassMember {
-
GDMonoClass *owner;
MonoProperty *mono_property;
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index c0fea6ede9..332744ae6e 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -56,7 +56,6 @@
namespace GDMonoUtils {
MonoObject *unmanaged_get_managed(Object *unmanaged) {
-
if (!unmanaged)
return nullptr;
@@ -664,8 +663,7 @@ GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, Mon
} // namespace Marshal
-ScopeThreadAttach::ScopeThreadAttach() :
- mono_thread(nullptr) {
+ScopeThreadAttach::ScopeThreadAttach() {
if (likely(GDMono::get_singleton()->is_runtime_initialized()) && unlikely(!mono_domain_get())) {
mono_thread = GDMonoUtils::attach_current_thread();
}
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index e3011ade5d..a7ca46f012 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -134,6 +134,7 @@ extern thread_local int current_invoke_count;
_FORCE_INLINE_ int get_runtime_invoke_count() {
return current_invoke_count;
}
+
_FORCE_INLINE_ int &get_runtime_invoke_count_ref() {
return current_invoke_count;
}
@@ -155,7 +156,7 @@ struct ScopeThreadAttach {
~ScopeThreadAttach();
private:
- MonoThread *mono_thread;
+ MonoThread *mono_thread = nullptr;
};
StringName get_native_godot_class_name(GDMonoClass *p_class);
diff --git a/modules/mono/mono_gd/managed_type.h b/modules/mono/mono_gd/managed_type.h
index 84d1837853..491a2f3d20 100644
--- a/modules/mono/mono_gd/managed_type.h
+++ b/modules/mono/mono_gd/managed_type.h
@@ -36,18 +36,15 @@
#include "gd_mono_header.h"
struct ManagedType {
- int type_encoding;
- GDMonoClass *type_class;
+ int type_encoding = 0;
+ GDMonoClass *type_class = nullptr;
static ManagedType from_class(GDMonoClass *p_class);
static ManagedType from_class(MonoClass *p_mono_class);
static ManagedType from_type(MonoType *p_mono_type);
static ManagedType from_reftype(MonoReflectionType *p_mono_reftype);
- ManagedType() :
- type_encoding(0),
- type_class(nullptr) {
- }
+ ManagedType() {}
ManagedType(int p_type_encoding, GDMonoClass *p_type_class) :
type_encoding(p_type_encoding),
diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp
index 8bcdeec9dd..8bcdeec9dd 100755..100644
--- a/modules/mono/mono_gd/support/android_support.cpp
+++ b/modules/mono/mono_gd/support/android_support.cpp
diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm
index e3d1a647fd..e3d1a647fd 100755..100644
--- a/modules/mono/mono_gd/support/ios_support.mm
+++ b/modules/mono/mono_gd/support/ios_support.mm
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index e77a2e98f2..ed0dc5cc28 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -77,7 +77,6 @@ String SignalAwaiterCallable::get_as_text() const {
String class_name = base->get_class();
Ref<Script> script = base->get_script();
if (script.is_valid() && script->get_path().is_resource_file()) {
-
class_name += "(" + script->get_path().get_file() + ")";
}
return class_name + "::SignalAwaiterMiddleman::" + String(signal);
diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp
index 8f0ad8ba5e..e0cf916a01 100644
--- a/modules/mono/utils/mono_reg_utils.cpp
+++ b/modules/mono/utils/mono_reg_utils.cpp
@@ -58,7 +58,6 @@ REGSAM _get_bitness_sam() {
}
LONG _RegOpenKey(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult) {
-
LONG res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ, phkResult);
if (res != ERROR_SUCCESS)
@@ -68,7 +67,6 @@ LONG _RegOpenKey(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult) {
}
LONG _RegKeyQueryString(HKEY hKey, const String &p_value_name, String &r_value) {
-
Vector<WCHAR> buffer;
buffer.resize(512);
DWORD dwBufferSize = buffer.size();
@@ -77,7 +75,6 @@ LONG _RegKeyQueryString(HKEY hKey, const String &p_value_name, String &r_value)
if (res == ERROR_MORE_DATA) {
// dwBufferSize now contains the actual size
- Vector<WCHAR> buffer;
buffer.resize(dwBufferSize);
res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize);
}
@@ -92,7 +89,6 @@ LONG _RegKeyQueryString(HKEY hKey, const String &p_value_name, String &r_value)
}
LONG _find_mono_in_reg(const String &p_subkey, MonoRegInfo &r_info, bool p_old_reg = false) {
-
HKEY hKey;
LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, p_subkey.c_str(), &hKey);
@@ -128,7 +124,6 @@ cleanup:
}
LONG _find_mono_in_reg_old(const String &p_subkey, MonoRegInfo &r_info) {
-
String default_clr;
HKEY hKey;
@@ -150,7 +145,6 @@ cleanup:
}
MonoRegInfo find_mono() {
-
MonoRegInfo info;
if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS)
@@ -163,7 +157,6 @@ MonoRegInfo find_mono() {
}
String find_msbuild_tools_path() {
-
String msbuild_tools_path;
// Try to find 15.0 with vswhere
@@ -232,6 +225,7 @@ cleanup:
return msbuild_tools_path;
}
+
} // namespace MonoRegUtils
#endif // WINDOWS_ENABLED
diff --git a/modules/mono/utils/mono_reg_utils.h b/modules/mono/utils/mono_reg_utils.h
index f844a7233a..4ef876f2b6 100644
--- a/modules/mono/utils/mono_reg_utils.h
+++ b/modules/mono/utils/mono_reg_utils.h
@@ -36,7 +36,6 @@
#include "core/ustring.h"
struct MonoRegInfo {
-
String version;
String install_root_dir;
String assembly_dir;
diff --git a/modules/mono/utils/osx_utils.cpp b/modules/mono/utils/osx_utils.cpp
index 8fadf3c109..8e3e51e688 100644
--- a/modules/mono/utils/osx_utils.cpp
+++ b/modules/mono/utils/osx_utils.cpp
@@ -38,7 +38,6 @@
#include <CoreServices/CoreServices.h>
bool osx_is_app_bundle_installed(const String &p_bundle_id) {
-
CFURLRef app_url = nullptr;
CFStringRef bundle_id = CFStringCreateWithCString(nullptr, p_bundle_id.utf8(), kCFStringEncodingUTF8);
OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, nullptr, nullptr, &app_url);
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index 67b264d803..da1b719d99 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -81,6 +81,7 @@ int sfind(const String &p_text, int p_from) {
return -1;
}
+
} // namespace
String sformat(const String &p_text, const Variant &p1, const Variant &p2, const Variant &p3, const Variant &p4, const Variant &p5) {
@@ -132,7 +133,6 @@ String sformat(const String &p_text, const Variant &p1, const Variant &p2, const
#ifdef TOOLS_ENABLED
bool is_csharp_keyword(const String &p_name) {
-
// Reserved keywords
return p_name == "abstract" || p_name == "as" || p_name == "base" || p_name == "bool" ||
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 16cd04b044..1181e69cd3 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -59,7 +59,6 @@ NoiseTexture::~NoiseTexture() {
}
void NoiseTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_width", "width"), &NoiseTexture::set_width);
ClassDB::bind_method(D_METHOD("set_height", "height"), &NoiseTexture::set_height);
@@ -88,7 +87,6 @@ void NoiseTexture::_bind_methods() {
}
void NoiseTexture::_validate_property(PropertyInfo &property) const {
-
if (property.name == "bump_strength") {
if (!as_normalmap) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
@@ -110,7 +108,6 @@ void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) {
}
void NoiseTexture::_thread_done(const Ref<Image> &p_image) {
-
_set_texture_data(p_image);
Thread::wait_to_finish(noise_thread);
memdelete(noise_thread);
@@ -127,16 +124,15 @@ void NoiseTexture::_thread_function(void *p_ud) {
}
void NoiseTexture::_queue_update() {
-
- if (update_queued)
+ if (update_queued) {
return;
+ }
update_queued = true;
call_deferred("_update_texture");
}
Ref<Image> NoiseTexture::_generate_texture() {
-
// Prevent memdelete due to unref() on other thread.
Ref<OpenSimplexNoise> ref_noise = noise;
@@ -169,7 +165,6 @@ void NoiseTexture::_update_texture() {
use_thread = false;
#endif
if (use_thread) {
-
if (!noise_thread) {
noise_thread = Thread::create(_thread_function, this);
regen_queued = false;
@@ -185,8 +180,9 @@ void NoiseTexture::_update_texture() {
}
void NoiseTexture::set_noise(Ref<OpenSimplexNoise> p_noise) {
- if (p_noise == noise)
+ if (p_noise == noise) {
return;
+ }
if (noise.is_valid()) {
noise->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NoiseTexture::_queue_update));
}
@@ -202,22 +198,25 @@ Ref<OpenSimplexNoise> NoiseTexture::get_noise() {
}
void NoiseTexture::set_width(int p_width) {
- if (p_width == size.x)
+ if (p_width == size.x) {
return;
+ }
size.x = p_width;
_queue_update();
}
void NoiseTexture::set_height(int p_height) {
- if (p_height == size.y)
+ if (p_height == size.y) {
return;
+ }
size.y = p_height;
_queue_update();
}
void NoiseTexture::set_seamless(bool p_seamless) {
- if (p_seamless == seamless)
+ if (p_seamless == seamless) {
return;
+ }
seamless = p_seamless;
_queue_update();
}
@@ -227,8 +226,9 @@ bool NoiseTexture::get_seamless() {
}
void NoiseTexture::set_as_normalmap(bool p_as_normalmap) {
- if (p_as_normalmap == as_normalmap)
+ if (p_as_normalmap == as_normalmap) {
return;
+ }
as_normalmap = p_as_normalmap;
_queue_update();
_change_notify();
@@ -239,26 +239,24 @@ bool NoiseTexture::is_normalmap() {
}
void NoiseTexture::set_bump_strength(float p_bump_strength) {
-
- if (p_bump_strength == bump_strength)
+ if (p_bump_strength == bump_strength) {
return;
+ }
bump_strength = p_bump_strength;
- if (as_normalmap)
+ if (as_normalmap) {
_queue_update();
+ }
}
float NoiseTexture::get_bump_strength() {
-
return bump_strength;
}
int NoiseTexture::get_width() const {
-
return size.x;
}
int NoiseTexture::get_height() const {
-
return size.y;
}
@@ -271,6 +269,5 @@ RID NoiseTexture::get_rid() const {
}
Ref<Image> NoiseTexture::get_data() const {
-
return data;
}
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp
index 205c033614..00b3d47db9 100644
--- a/modules/opensimplex/open_simplex_noise.cpp
+++ b/modules/opensimplex/open_simplex_noise.cpp
@@ -33,7 +33,6 @@
#include "core/core_string_names.h"
OpenSimplexNoise::OpenSimplexNoise() {
-
seed = 0;
persistence = 0.5;
octaves = 3;
@@ -53,9 +52,9 @@ void OpenSimplexNoise::_init_seeds() {
}
void OpenSimplexNoise::set_seed(int p_seed) {
-
- if (seed == p_seed)
+ if (seed == p_seed) {
return;
+ }
seed = p_seed;
@@ -65,13 +64,13 @@ void OpenSimplexNoise::set_seed(int p_seed) {
}
int OpenSimplexNoise::get_seed() {
-
return seed;
}
void OpenSimplexNoise::set_octaves(int p_octaves) {
- if (p_octaves == octaves)
+ if (p_octaves == octaves) {
return;
+ }
ERR_FAIL_COND_MSG(p_octaves > MAX_OCTAVES, vformat("The number of OpenSimplexNoise octaves is limited to %d; ignoring the new value.", MAX_OCTAVES));
@@ -80,28 +79,30 @@ void OpenSimplexNoise::set_octaves(int p_octaves) {
}
void OpenSimplexNoise::set_period(float p_period) {
- if (p_period == period)
+ if (p_period == period) {
return;
+ }
period = p_period;
emit_changed();
}
void OpenSimplexNoise::set_persistence(float p_persistence) {
- if (p_persistence == persistence)
+ if (p_persistence == persistence) {
return;
+ }
persistence = p_persistence;
emit_changed();
}
void OpenSimplexNoise::set_lacunarity(float p_lacunarity) {
- if (p_lacunarity == lacunarity)
+ if (p_lacunarity == lacunarity) {
return;
+ }
lacunarity = p_lacunarity;
emit_changed();
}
Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) {
-
Vector<uint8_t> data;
data.resize(p_width * p_height * 4);
@@ -124,7 +125,6 @@ Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) {
}
Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) {
-
Vector<uint8_t> data;
data.resize(p_size * p_size * 4);
@@ -132,7 +132,6 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) {
for (int i = 0; i < p_size; i++) {
for (int j = 0; j < p_size; j++) {
-
float ii = (float)i / (float)p_size;
float jj = (float)j / (float)p_size;
@@ -161,7 +160,6 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) {
}
void OpenSimplexNoise::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_seed"), &OpenSimplexNoise::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &OpenSimplexNoise::set_seed);
@@ -196,12 +194,10 @@ void OpenSimplexNoise::_bind_methods() {
}
float OpenSimplexNoise::get_noise_1d(float x) {
-
return get_noise_2d(x, 1.0);
}
float OpenSimplexNoise::get_noise_2d(float x, float y) {
-
x /= period;
y /= period;
@@ -222,7 +218,6 @@ float OpenSimplexNoise::get_noise_2d(float x, float y) {
}
float OpenSimplexNoise::get_noise_3d(float x, float y, float z) {
-
x /= period;
y /= period;
z /= period;
@@ -245,7 +240,6 @@ float OpenSimplexNoise::get_noise_3d(float x, float y, float z) {
}
float OpenSimplexNoise::get_noise_4d(float x, float y, float z, float w) {
-
x /= period;
y /= period;
z /= period;
diff --git a/modules/opensimplex/register_types.cpp b/modules/opensimplex/register_types.cpp
index 6fae1fe415..fef90cdce3 100644
--- a/modules/opensimplex/register_types.cpp
+++ b/modules/opensimplex/register_types.cpp
@@ -33,7 +33,6 @@
#include "open_simplex_noise.h"
void register_opensimplex_types() {
-
ClassDB::register_class<OpenSimplexNoise>();
ClassDB::register_class<NoiseTexture>();
}
diff --git a/modules/opus/config.py b/modules/opus/config.py
index d22f9454ed..9ff7b2dece 100644
--- a/modules/opus/config.py
+++ b/modules/opus/config.py
@@ -1,5 +1,5 @@
def can_build(env, platform):
- return True
+ return env.module_check_dependencies("opus", ["ogg"])
def configure(env):
diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp
index 5f900a0256..1eb697bba3 100644
--- a/modules/pvr/register_types.cpp
+++ b/modules/pvr/register_types.cpp
@@ -35,13 +35,11 @@
static Ref<ResourceFormatPVR> resource_loader_pvr;
void register_pvr_types() {
-
resource_loader_pvr.instance();
ResourceLoader::add_resource_format_loader(resource_loader_pvr);
}
void unregister_pvr_types() {
-
ResourceLoader::remove_resource_format_loader(resource_loader_pvr);
resource_loader_pvr.unref();
}
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index d28199420d..36c0913f62 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -52,21 +52,23 @@ enum PVRFLags {
};
RES ResourceFormatPVR::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)
+ if (r_error) {
*r_error = ERR_CANT_OPEN;
+ }
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (!f)
+ if (!f) {
return RES();
+ }
FileAccessRef faref(f);
ERR_FAIL_COND_V(err, RES());
- if (r_error)
+ if (r_error) {
*r_error = ERR_FILE_CORRUPT;
+ }
uint32_t hsize = f->get_32();
@@ -109,7 +111,6 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path,
Image::Format format = Image::FORMAT_MAX;
switch (flags & 0xFF) {
-
case 0x18:
case 0xC:
format = (flags & PVR_HAS_ALPHA) ? Image::FORMAT_PVRTC2A : Image::FORMAT_PVRTC2;
@@ -162,29 +163,29 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path,
Ref<ImageTexture> texture = memnew(ImageTexture);
texture->create_from_image(image);
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return texture;
}
void ResourceFormatPVR::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("pvr");
}
-bool ResourceFormatPVR::handles_type(const String &p_type) const {
+bool ResourceFormatPVR::handles_type(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Texture2D");
}
-String ResourceFormatPVR::get_resource_type(const String &p_path) const {
- if (p_path.get_extension().to_lower() == "pvr")
+String ResourceFormatPVR::get_resource_type(const String &p_path) const {
+ if (p_path.get_extension().to_lower() == "pvr") {
return "Texture2D";
+ }
return "";
}
static void _compress_pvrtc4(Image *p_img) {
-
Ref<Image> img = p_img->duplicate();
bool make_mipmaps = false;
@@ -193,8 +194,9 @@ static void _compress_pvrtc4(Image *p_img) {
img->resize_to_po2(true);
}
img->convert(Image::FORMAT_RGBA8);
- if (!img->has_mipmaps() && make_mipmaps)
+ if (!img->has_mipmaps() && make_mipmaps) {
img->generate_mipmaps();
+ }
bool use_alpha = img->detect_alpha();
@@ -208,7 +210,6 @@ static void _compress_pvrtc4(Image *p_img) {
const uint8_t *r = img->get_data().ptr();
for (int i = 0; i <= new_img->get_mipmap_count(); i++) {
-
int ofs, size, w, h;
img->get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h);
Javelin::RgbaBitmap bm(w, h);
@@ -226,7 +227,6 @@ static void _compress_pvrtc4(Image *p_img) {
}
ResourceFormatPVR::ResourceFormatPVR() {
-
Image::_image_decompress_pvrtc = _pvrtc_decompress;
Image::_image_compress_pvrtc4_func = _compress_pvrtc4;
Image::_image_compress_pvrtc2_func = _compress_pvrtc4;
@@ -259,31 +259,28 @@ struct PVRTCBlock {
};
_FORCE_INLINE_ bool is_po2(uint32_t p_input) {
-
- if (p_input == 0)
- return 0;
+ if (p_input == 0) {
+ return false;
+ }
uint32_t minus1 = p_input - 1;
- return ((p_input | minus1) == (p_input ^ minus1)) ? 1 : 0;
+ return ((p_input | minus1) == (p_input ^ minus1)) ? true : false;
}
static void unpack_5554(const PVRTCBlock *p_block, int p_ab_colors[2][4]) {
-
uint32_t raw_bits[2];
raw_bits[0] = p_block->data[1] & (0xFFFE);
raw_bits[1] = p_block->data[1] >> 16;
for (int i = 0; i < 2; i++) {
-
if (raw_bits[i] & (1 << 15)) {
-
p_ab_colors[i][0] = (raw_bits[i] >> 10) & 0x1F;
p_ab_colors[i][1] = (raw_bits[i] >> 5) & 0x1F;
p_ab_colors[i][2] = raw_bits[i] & 0x1F;
- if (i == 0)
+ if (i == 0) {
p_ab_colors[0][2] |= p_ab_colors[0][2] >> 4;
+ }
p_ab_colors[i][3] = 0xF;
} else {
-
p_ab_colors[i][0] = (raw_bits[i] >> (8 - 1)) & 0x1E;
p_ab_colors[i][1] = (raw_bits[i] >> (4 - 1)) & 0x1E;
@@ -292,10 +289,11 @@ static void unpack_5554(const PVRTCBlock *p_block, int p_ab_colors[2][4]) {
p_ab_colors[i][2] = (raw_bits[i] & 0xF) << 1;
- if (i == 0)
+ if (i == 0) {
p_ab_colors[0][2] |= p_ab_colors[0][2] >> 3;
- else
+ } else {
p_ab_colors[0][2] |= p_ab_colors[0][2] >> 4;
+ }
p_ab_colors[i][3] = (raw_bits[i] >> 11) & 0xE;
}
@@ -303,15 +301,12 @@ static void unpack_5554(const PVRTCBlock *p_block, int p_ab_colors[2][4]) {
}
static void unpack_modulations(const PVRTCBlock *p_block, const int p_2bit, int p_modulation[8][16], int p_modulation_modes[8][16], int p_x, int p_y) {
-
int block_mod_mode = p_block->data[1] & 1;
uint32_t modulation_bits = p_block->data[0];
if (p_2bit && block_mod_mode) {
-
for (int y = 0; y < BLK_Y_SIZE; y++) {
for (int x = 0; x < BLK_X_2BPP; x++) {
-
p_modulation_modes[y + p_y][x + p_x] = block_mod_mode;
if (((x ^ y) & 1) == 0) {
@@ -322,15 +317,15 @@ static void unpack_modulations(const PVRTCBlock *p_block, const int p_2bit, int
}
} else if (p_2bit) {
-
for (int y = 0; y < BLK_Y_SIZE; y++) {
for (int x = 0; x < BLK_X_2BPP; x++) {
p_modulation_modes[y + p_y][x + p_x] = block_mod_mode;
- if (modulation_bits & 1)
+ if (modulation_bits & 1) {
p_modulation[y + p_y][x + p_x] = 0x3;
- else
+ } else {
p_modulation[y + p_y][x + p_x] = 0x0;
+ }
modulation_bits >>= 1;
}
@@ -365,10 +360,11 @@ static void interpolate_colors(const int p_colorp[4], const int p_colorq[4], con
v = (y & 0x3) | ((~y & 0x2) << 1);
- if (p_2bit)
+ if (p_2bit) {
u = (x & 0x7) | ((~x & 0x4) << 1);
- else
+ } else {
u = (x & 0x3) | ((~x & 0x2) << 1);
+ }
v = v - BLK_Y_SIZE / 2;
@@ -424,19 +420,20 @@ static void get_modulation_value(int x, int y, const int p_2bit, const int p_mod
y = (y & 0x3) | ((~y & 0x2) << 1);
- if (p_2bit)
+ if (p_2bit) {
x = (x & 0x7) | ((~x & 0x4) << 1);
- else
+ } else {
x = (x & 0x3) | ((~x & 0x2) << 1);
+ }
*p_dopt = 0;
if (p_modulation_modes[y][x] == 0) {
mod_val = rep_vals0[p_modulation[y][x]];
} else if (p_2bit) {
- if (((x ^ y) & 1) == 0)
+ if (((x ^ y) & 1) == 0) {
mod_val = rep_vals0[p_modulation[y][x]];
- else if (p_modulation_modes[y][x] == 1) {
+ } else if (p_modulation_modes[y][x] == 1) {
mod_val = (rep_vals0[p_modulation[y - 1][x]] +
rep_vals0[p_modulation[y + 1][x]] +
rep_vals0[p_modulation[y][x - 1]] +
@@ -463,7 +460,6 @@ static void get_modulation_value(int x, int y, const int p_2bit, const int p_mod
static int disable_twiddling = 0;
static uint32_t twiddle_uv(uint32_t p_height, uint32_t p_width, uint32_t p_y, uint32_t p_x) {
-
uint32_t twiddled;
uint32_t min_dimension;
@@ -488,8 +484,9 @@ static uint32_t twiddle_uv(uint32_t p_height, uint32_t p_width, uint32_t p_y, ui
max_value = p_y;
}
- if (disable_twiddling)
+ if (disable_twiddling) {
return (p_y * p_width + p_x);
+ }
scr_bit_pos = 1;
dst_bit_pos = 1;
@@ -549,17 +546,17 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
int r_result[4];
- if (p_2bit)
+ if (p_2bit) {
x_block_size = BLK_X_2BPP;
- else
+ } else {
x_block_size = BLK_X_4BPP;
+ }
block_width = MAX(2, p_width / x_block_size);
block_height = MAX(2, p_height / BLK_Y_SIZE);
for (y = 0; y < p_height; y++) {
for (x = 0; x < p_width; x++) {
-
block_x = (x - x_block_size / 2);
blk_y = (y - BLK_Y_SIZE / 2);
@@ -624,8 +621,9 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
r_result[i] >>= 3;
}
- if (DoPT)
+ if (DoPT) {
r_result[3] = 0;
+ }
u_pos = (x + y * p_width) << 2;
p_dst[u_pos + 0] = (uint8_t)r_result[0];
@@ -637,7 +635,6 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
}
static void _pvrtc_decompress(Image *p_img) {
-
ERR_FAIL_COND(p_img->get_format() != Image::FORMAT_PVRTC2 && p_img->get_format() != Image::FORMAT_PVRTC2A && p_img->get_format() != Image::FORMAT_PVRTC4 && p_img->get_format() != Image::FORMAT_PVRTC4A);
bool _2bit = (p_img->get_format() == Image::FORMAT_PVRTC2 || p_img->get_format() == Image::FORMAT_PVRTC2A);
@@ -653,6 +650,7 @@ static void _pvrtc_decompress(Image *p_img) {
bool make_mipmaps = p_img->has_mipmaps();
p_img->create(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata);
- if (make_mipmaps)
+ if (make_mipmaps) {
p_img->generate_mipmaps();
+ }
}
diff --git a/modules/regex/SCsub b/modules/regex/SCsub
index 753650adcb..2afacc1d9c 100644
--- a/modules/regex/SCsub
+++ b/modules/regex/SCsub
@@ -7,7 +7,7 @@ env_regex = env_modules.Clone()
if env["builtin_pcre2"]:
thirdparty_dir = "#thirdparty/pcre2/src/"
- thirdparty_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H"]
+ thirdparty_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H", "SUPPORT_UNICODE"]
if env["builtin_pcre2_with_jit"]:
thirdparty_flags.append("SUPPORT_JIT")
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index 3130c53331..c00fa96b2e 100644
--- a/modules/regex/doc_classes/RegEx.xml
+++ b/modules/regex/doc_classes/RegEx.xml
@@ -32,8 +32,7 @@
[codeblock]
for result in regex.search_all("d01, d03, d0c, x3f and x42"):
print(result.get_string("digit"))
- # Would print 01 03 3f 42
- # Note that d0c would not match
+ # Would print 01 03 0 3f 42
[/codeblock]
[b]Note:[/b] Godot's regex implementation is based on the [url=https://www.pcre.org/]PCRE2[/url] library. You can view the full pattern reference [url=https://www.pcre.org/current/doc/html/pcre2pattern.html]here[/url].
[b]Tip:[/b] You can use [url=https://regexr.com/]Regexr[/url] to test regular expressions online.
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index 151e881b6f..a45de60aef 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -49,7 +49,7 @@
</methods>
<members>
<member name="names" type="Dictionary" setter="" getter="get_names" default="{}">
- A dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
+ A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
</member>
<member name="strings" type="Array" setter="" getter="get_strings" default="[ ]">
An [Array] of the match and its capturing groups.
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 25cc580591..50ca01067b 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -36,48 +36,43 @@ extern "C" {
}
static void *_regex_malloc(PCRE2_SIZE size, void *user) {
-
return memalloc(size);
}
static void _regex_free(void *ptr, void *user) {
-
memfree(ptr);
}
int RegExMatch::_find(const Variant &p_name) const {
-
if (p_name.is_num()) {
-
int i = (int)p_name;
- if (i >= data.size())
+ if (i >= data.size()) {
return -1;
+ }
return i;
} else if (p_name.get_type() == Variant::STRING) {
-
const Map<String, int>::Element *found = names.find((String)p_name);
- if (found)
+ if (found) {
return found->value();
+ }
}
return -1;
}
String RegExMatch::get_subject() const {
-
return subject;
}
int RegExMatch::get_group_count() const {
-
- if (data.size() == 0)
+ if (data.size() == 0) {
return 0;
+ }
return data.size() - 1;
}
Dictionary RegExMatch::get_names() const {
-
Dictionary result;
for (const Map<String, int>::Element *i = names.front(); i != nullptr; i = i->next()) {
@@ -88,13 +83,11 @@ Dictionary RegExMatch::get_names() const {
}
Array RegExMatch::get_strings() const {
-
Array result;
int size = data.size();
for (int i = 0; i < size; i++) {
-
int start = data[i].start;
if (start == -1) {
@@ -111,16 +104,17 @@ Array RegExMatch::get_strings() const {
}
String RegExMatch::get_string(const Variant &p_name) const {
-
int id = _find(p_name);
- if (id < 0)
+ if (id < 0) {
return String();
+ }
int start = data[id].start;
- if (start == -1)
+ if (start == -1) {
return String();
+ }
int length = data[id].end - start;
@@ -128,27 +122,26 @@ String RegExMatch::get_string(const Variant &p_name) const {
}
int RegExMatch::get_start(const Variant &p_name) const {
-
int id = _find(p_name);
- if (id < 0)
+ if (id < 0) {
return -1;
+ }
return data[id].start;
}
int RegExMatch::get_end(const Variant &p_name) const {
-
int id = _find(p_name);
- if (id < 0)
+ if (id < 0) {
return -1;
+ }
return data[id].end;
}
void RegExMatch::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_subject"), &RegExMatch::get_subject);
ClassDB::bind_method(D_METHOD("get_group_count"), &RegExMatch::get_group_count);
ClassDB::bind_method(D_METHOD("get_names"), &RegExMatch::get_names);
@@ -163,28 +156,22 @@ void RegExMatch::_bind_methods() {
}
void RegEx::_pattern_info(uint32_t what, void *where) const {
-
if (sizeof(CharType) == 2) {
-
pcre2_pattern_info_16((pcre2_code_16 *)code, what, where);
} else {
-
pcre2_pattern_info_32((pcre2_code_32 *)code, what, where);
}
}
void RegEx::clear() {
-
if (sizeof(CharType) == 2) {
-
if (code) {
pcre2_code_free_16((pcre2_code_16 *)code);
code = nullptr;
}
} else {
-
if (code) {
pcre2_code_free_32((pcre2_code_32 *)code);
code = nullptr;
@@ -193,7 +180,6 @@ void RegEx::clear() {
}
Error RegEx::compile(const String &p_pattern) {
-
pattern = p_pattern;
clear();
@@ -202,7 +188,6 @@ Error RegEx::compile(const String &p_pattern) {
uint32_t flags = PCRE2_DUPNAMES;
if (sizeof(CharType) == 2) {
-
pcre2_general_context_16 *gctx = (pcre2_general_context_16 *)general_ctx;
pcre2_compile_context_16 *cctx = pcre2_compile_context_create_16(gctx);
PCRE2_SPTR16 p = (PCRE2_SPTR16)pattern.c_str();
@@ -220,7 +205,6 @@ Error RegEx::compile(const String &p_pattern) {
}
} else {
-
pcre2_general_context_32 *gctx = (pcre2_general_context_32 *)general_ctx;
pcre2_compile_context_32 *cctx = pcre2_compile_context_create_32(gctx);
PCRE2_SPTR32 p = (PCRE2_SPTR32)pattern.c_str();
@@ -241,17 +225,16 @@ Error RegEx::compile(const String &p_pattern) {
}
Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) const {
-
ERR_FAIL_COND_V(!is_valid(), nullptr);
Ref<RegExMatch> result = memnew(RegExMatch);
int length = p_subject.length();
- if (p_end >= 0 && p_end < length)
+ if (p_end >= 0 && p_end < length) {
length = p_end;
+ }
if (sizeof(CharType) == 2) {
-
pcre2_code_16 *c = (pcre2_code_16 *)code;
pcre2_general_context_16 *gctx = (pcre2_general_context_16 *)general_ctx;
pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
@@ -272,7 +255,6 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
result->data.resize(size);
for (uint32_t i = 0; i < size; i++) {
-
result->data.write[i].start = ovector[i * 2];
result->data.write[i].end = ovector[i * 2 + 1];
}
@@ -281,7 +263,6 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
pcre2_match_context_free_16(mctx);
} else {
-
pcre2_code_32 *c = (pcre2_code_32 *)code;
pcre2_general_context_32 *gctx = (pcre2_general_context_32 *)general_ctx;
pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
@@ -304,7 +285,6 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
result->data.resize(size);
for (uint32_t i = 0; i < size; i++) {
-
result->data.write[i].start = ovector[i * 2];
result->data.write[i].end = ovector[i * 2 + 1];
}
@@ -324,13 +304,14 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
_pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
for (uint32_t i = 0; i < count; i++) {
-
CharType id = table[i * entry_size];
- if (result->data[id].start == -1)
+ if (result->data[id].start == -1) {
continue;
+ }
String name = &table[i * entry_size + 1];
- if (result->names.has(name))
+ if (result->names.has(name)) {
continue;
+ }
result->names.insert(name, id);
}
@@ -339,13 +320,13 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
}
Array RegEx::search_all(const String &p_subject, int p_offset, int p_end) const {
-
int last_end = -1;
Array result;
Ref<RegExMatch> match = search(p_subject, p_offset, p_end);
while (match.is_valid()) {
- if (last_end == match->get_end(0))
+ if (last_end == match->get_end(0)) {
break;
+ }
result.push_back(match);
last_end = match->get_end(0);
match = search(p_subject, match->get_end(0), p_end);
@@ -354,7 +335,6 @@ Array RegEx::search_all(const String &p_subject, int p_offset, int p_end) const
}
String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_all, int p_offset, int p_end) const {
-
ERR_FAIL_COND_V(!is_valid(), String());
// safety_zone is the number of chars we allocate in addition to the number of chars expected in order to
@@ -368,15 +348,16 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
output.resize(olength + safety_zone);
uint32_t flags = PCRE2_SUBSTITUTE_OVERFLOW_LENGTH;
- if (p_all)
+ if (p_all) {
flags |= PCRE2_SUBSTITUTE_GLOBAL;
+ }
PCRE2_SIZE length = p_subject.length();
- if (p_end >= 0 && (uint32_t)p_end < length)
+ if (p_end >= 0 && (uint32_t)p_end < length) {
length = p_end;
+ }
if (sizeof(CharType) == 2) {
-
pcre2_code_16 *c = (pcre2_code_16 *)code;
pcre2_general_context_16 *gctx = (pcre2_general_context_16 *)general_ctx;
pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
@@ -397,11 +378,11 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_data_free_16(match);
pcre2_match_context_free_16(mctx);
- if (res < 0)
+ if (res < 0) {
return String();
+ }
} else {
-
pcre2_code_32 *c = (pcre2_code_32 *)code;
pcre2_general_context_32 *gctx = (pcre2_general_context_32 *)general_ctx;
pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
@@ -422,25 +403,23 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_data_free_32(match);
pcre2_match_context_free_32(mctx);
- if (res < 0)
+ if (res < 0) {
return String();
+ }
}
return String(output.ptr(), olength);
}
bool RegEx::is_valid() const {
-
return (code != nullptr);
}
String RegEx::get_pattern() const {
-
return pattern;
}
int RegEx::get_group_count() const {
-
ERR_FAIL_COND_V(!is_valid(), 0);
uint32_t count;
@@ -451,7 +430,6 @@ int RegEx::get_group_count() const {
}
Array RegEx::get_names() const {
-
Array result;
ERR_FAIL_COND_V(!is_valid(), result);
@@ -465,7 +443,6 @@ Array RegEx::get_names() const {
_pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
for (uint32_t i = 0; i < count; i++) {
-
String name = &table[i * entry_size + 1];
if (result.find(name) < 0) {
result.append(name);
@@ -476,26 +453,20 @@ Array RegEx::get_names() const {
}
RegEx::RegEx() {
-
if (sizeof(CharType) == 2) {
-
general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, nullptr);
} else {
-
general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr);
}
code = nullptr;
}
RegEx::RegEx(const String &p_pattern) {
-
if (sizeof(CharType) == 2) {
-
general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, nullptr);
} else {
-
general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr);
}
code = nullptr;
@@ -503,23 +474,21 @@ RegEx::RegEx(const String &p_pattern) {
}
RegEx::~RegEx() {
-
if (sizeof(CharType) == 2) {
-
- if (code)
+ if (code) {
pcre2_code_free_16((pcre2_code_16 *)code);
+ }
pcre2_general_context_free_16((pcre2_general_context_16 *)general_ctx);
} else {
-
- if (code)
+ if (code) {
pcre2_code_free_32((pcre2_code_32 *)code);
+ }
pcre2_general_context_free_32((pcre2_general_context_32 *)general_ctx);
}
}
void RegEx::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("clear"), &RegEx::clear);
ClassDB::bind_method(D_METHOD("compile", "pattern"), &RegEx::compile);
ClassDB::bind_method(D_METHOD("search", "subject", "offset", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1));
diff --git a/modules/regex/regex.h b/modules/regex/regex.h
index a342c17c78..52b49c783e 100644
--- a/modules/regex/regex.h
+++ b/modules/regex/regex.h
@@ -39,7 +39,6 @@
#include "core/vector.h"
class RegExMatch : public Reference {
-
GDCLASS(RegExMatch, Reference);
struct Range {
@@ -70,7 +69,6 @@ public:
};
class RegEx : public Reference {
-
GDCLASS(RegEx, Reference);
void *general_ctx;
diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp
index 77b19fa8f0..5d4aeba2d7 100644
--- a/modules/regex/register_types.cpp
+++ b/modules/regex/register_types.cpp
@@ -33,7 +33,6 @@
#include "regex.h"
void register_regex_types() {
-
ClassDB::register_class<RegExMatch>();
ClassDB::register_class<RegEx>();
}
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index bb77f68590..c510779317 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -78,21 +78,21 @@ void image_decompress_squish(Image *p_image) {
}
void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels) {
-
- if (p_image->get_format() >= Image::FORMAT_DXT1)
+ if (p_image->get_format() >= Image::FORMAT_DXT1) {
return; //do not compress, already compressed
+ }
int w = p_image->get_width();
int h = p_image->get_height();
if (p_image->get_format() <= Image::FORMAT_RGBA8) {
-
int squish_comp = squish::kColourRangeFit;
- if (p_lossy_quality > 0.85)
+ if (p_lossy_quality > 0.85) {
squish_comp = squish::kColourIterativeClusterFit;
- else if (p_lossy_quality > 0.75)
+ } else if (p_lossy_quality > 0.75) {
squish_comp = squish::kColourClusterFit;
+ }
Image::Format target_format = Image::FORMAT_RGBA8;
@@ -100,32 +100,26 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedCha
switch (p_channels) {
case Image::USED_CHANNELS_L: {
-
target_format = Image::FORMAT_DXT1;
squish_comp |= squish::kDxt1;
} break;
case Image::USED_CHANNELS_LA: {
-
target_format = Image::FORMAT_DXT5;
squish_comp |= squish::kDxt5;
} break;
case Image::USED_CHANNELS_R: {
-
target_format = Image::FORMAT_RGTC_R;
squish_comp |= squish::kBc4;
} break;
case Image::USED_CHANNELS_RG: {
-
target_format = Image::FORMAT_RGTC_RG;
squish_comp |= squish::kBc5;
} break;
case Image::USED_CHANNELS_RGB: {
-
target_format = Image::FORMAT_DXT1;
squish_comp |= squish::kDxt1;
} break;
case Image::USED_CHANNELS_RGBA: {
-
//TODO, should convert both, then measure which one does a better job
target_format = Image::FORMAT_DXT5;
squish_comp |= squish::kDxt5;
@@ -149,7 +143,6 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedCha
int dst_ofs = 0;
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;
diff --git a/modules/squish/register_types.cpp b/modules/squish/register_types.cpp
index 2a0cf82b56..ad28aff058 100644
--- a/modules/squish/register_types.cpp
+++ b/modules/squish/register_types.cpp
@@ -32,7 +32,6 @@
#include "image_compress_squish.h"
void register_squish_types() {
-
Image::set_compress_bc_func(image_compress_squish);
Image::_image_decompress_bc = image_decompress_squish;
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 9609c234ec..3aceaf11c5 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -33,7 +33,6 @@
#include "core/os/file_access.h"
void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) {
-
ERR_FAIL_COND(!active);
int todo = p_frames;
@@ -76,12 +75,10 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra
}
float AudioStreamPlaybackOGGVorbis::get_stream_sampling_rate() {
-
return vorbis_stream->sample_rate;
}
void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) {
-
active = true;
seek(p_from_pos);
loops = 0;
@@ -89,27 +86,25 @@ void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) {
}
void AudioStreamPlaybackOGGVorbis::stop() {
-
active = false;
}
-bool AudioStreamPlaybackOGGVorbis::is_playing() const {
+bool AudioStreamPlaybackOGGVorbis::is_playing() const {
return active;
}
int AudioStreamPlaybackOGGVorbis::get_loop_count() const {
-
return loops;
}
float AudioStreamPlaybackOGGVorbis::get_playback_position() const {
-
return float(frames_mixed) / vorbis_stream->sample_rate;
}
-void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
- if (!active)
+void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
+ if (!active) {
return;
+ }
if (p_time >= vorbis_stream->get_length()) {
p_time = 0;
@@ -127,7 +122,6 @@ AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
}
Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
-
Ref<AudioStreamPlaybackOGGVorbis> ovs;
ERR_FAIL_COND_V(data == nullptr, ovs);
@@ -142,7 +136,6 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
int error;
ovs->ogg_stream = stb_vorbis_open_memory((const unsigned char *)data, data_len, &error, &ovs->ogg_alloc);
if (!ovs->ogg_stream) {
-
memfree(ovs->ogg_alloc.alloc_buffer);
ovs->ogg_alloc.alloc_buffer = nullptr;
ERR_FAIL_COND_V(!ovs->ogg_stream, Ref<AudioStreamPlaybackOGGVorbis>());
@@ -152,7 +145,6 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
}
String AudioStreamOGGVorbis::get_stream_name() const {
-
return ""; //return stream_name;
}
@@ -165,7 +157,6 @@ void AudioStreamOGGVorbis::clear_data() {
}
void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
-
int src_data_len = p_data.size();
#define MAX_TEST_MEM (1 << 20)
@@ -176,7 +167,6 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
stb_vorbis_alloc ogg_alloc;
while (alloc_try < MAX_TEST_MEM) {
-
alloc_mem.resize(alloc_try);
w = alloc_mem.ptrw();
@@ -189,10 +179,8 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar, src_data_len, &error, &ogg_alloc);
if (!ogg_stream && error == VORBIS_outofmem) {
-
alloc_try *= 2;
} else {
-
ERR_FAIL_COND(alloc_try == MAX_TEST_MEM);
ERR_FAIL_COND(ogg_stream == nullptr);
@@ -220,7 +208,6 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
}
Vector<uint8_t> AudioStreamOGGVorbis::get_data() const {
-
Vector<uint8_t> vdata;
if (data_len && data) {
@@ -239,7 +226,6 @@ void AudioStreamOGGVorbis::set_loop(bool p_enable) {
}
bool AudioStreamOGGVorbis::has_loop() const {
-
return loop;
}
@@ -252,12 +238,10 @@ float AudioStreamOGGVorbis::get_loop_offset() const {
}
float AudioStreamOGGVorbis::get_length() const {
-
return length;
}
void AudioStreamOGGVorbis::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamOGGVorbis::set_data);
ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamOGGVorbis::get_data);
@@ -273,7 +257,6 @@ void AudioStreamOGGVorbis::_bind_methods() {
}
AudioStreamOGGVorbis::AudioStreamOGGVorbis() {
-
data = nullptr;
data_len = 0;
length = 0;
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
index f296e8c19f..3002134651 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -39,7 +39,6 @@
class AudioStreamOGGVorbis;
class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled {
-
GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled);
stb_vorbis *ogg_stream;
@@ -71,7 +70,6 @@ public:
};
class AudioStreamOGGVorbis : public AudioStream {
-
GDCLASS(AudioStreamOGGVorbis, AudioStream);
OBJ_SAVE_TYPE(AudioStream); // Saves derived classes with common type so they can be interchanged.
RES_BASE_EXTENSION("oggstr");
diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp
index ac2612bd6a..6669d30278 100644
--- a/modules/stb_vorbis/register_types.cpp
+++ b/modules/stb_vorbis/register_types.cpp
@@ -38,7 +38,6 @@
#endif
void register_stb_vorbis_types() {
-
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
Ref<ResourceImporterOGGVorbis> ogg_import;
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index 13d96541e3..d68d050d34 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -35,16 +35,14 @@
#include "scene/resources/texture.h"
String ResourceImporterOGGVorbis::get_importer_name() const {
-
return "ogg_vorbis";
}
String ResourceImporterOGGVorbis::get_visible_name() const {
-
return "OGGVorbis";
}
-void ResourceImporterOGGVorbis::get_recognized_extensions(List<String> *p_extensions) const {
+void ResourceImporterOGGVorbis::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("ogg");
}
@@ -53,31 +51,27 @@ String ResourceImporterOGGVorbis::get_save_extension() const {
}
String ResourceImporterOGGVorbis::get_resource_type() const {
-
return "AudioStreamOGGVorbis";
}
bool ResourceImporterOGGVorbis::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
return true;
}
int ResourceImporterOGGVorbis::get_preset_count() const {
return 0;
}
-String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const {
+String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const {
return String();
}
void ResourceImporterOGGVorbis::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "loop_offset"), 0));
}
Error ResourceImporterOGGVorbis::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-
bool loop = p_options["loop"];
float loop_offset = p_options["loop_offset"];
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index 3c2784f8de..8ca4452ac9 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -40,6 +40,7 @@ void SVGRasterizer::rasterize(NSVGimage *p_image, float p_tx, float p_ty, float
SVGRasterizer::SVGRasterizer() {
rasterizer = nsvgCreateRasterizer();
}
+
SVGRasterizer::~SVGRasterizer() {
nsvgDeleteRasterizer(rasterizer);
}
@@ -47,7 +48,6 @@ SVGRasterizer::~SVGRasterizer() {
SVGRasterizer ImageLoaderSVG::rasterizer;
inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, const uint32_t p_new) {
-
if (p_paint->type == NSVG_PAINT_COLOR) {
if (p_paint->color << 8 == p_old << 8) {
p_paint->color = (p_paint->color & 0xFF000000) | (p_new & 0x00FFFFFF);
@@ -64,9 +64,7 @@ inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, co
}
void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image) {
-
for (NSVGshape *shape = p_svg_image->shapes; shape != nullptr; shape = shape->next) {
-
for (int i = 0; i < replace_colors.old_colors.size(); i++) {
change_nsvg_paint_color(&(shape->stroke), replace_colors.old_colors[i], replace_colors.new_colors[i]);
change_nsvg_paint_color(&(shape->fill), replace_colors.old_colors[i], replace_colors.new_colors[i]);
@@ -75,7 +73,6 @@ void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image) {
}
void ImageLoaderSVG::set_convert_colors(Dictionary *p_replace_color) {
-
if (p_replace_color) {
Dictionary replace_color = *p_replace_color;
for (int i = 0; i < replace_color.keys().size(); i++) {
@@ -133,7 +130,6 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const Vector<uint8_t> *p
}
Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, bool convert_colors) {
-
size_t str_len = strlen(p_svg_str);
Vector<uint8_t> src_data;
src_data.resize(str_len + 1);
@@ -144,7 +140,6 @@ Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *p
}
Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
uint32_t size = f->get_len();
Vector<uint8_t> src_image;
src_image.resize(size + 1);
@@ -156,7 +151,6 @@ Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
void ImageLoaderSVG::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("svg");
p_extensions->push_back("svgz");
}
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
index 0fa4a0fdf4..ecaba5052b 100644
--- a/modules/svg/image_loader_svg.h
+++ b/modules/svg/image_loader_svg.h
@@ -43,7 +43,6 @@ struct NSVGrasterizer;
struct NSVGimage;
class SVGRasterizer {
-
NSVGrasterizer *rasterizer;
public:
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
index 37875313aa..9fbefd2cfe 100644
--- a/modules/svg/register_types.cpp
+++ b/modules/svg/register_types.cpp
@@ -35,12 +35,10 @@
static ImageLoaderSVG *image_loader_svg = nullptr;
void register_svg_types() {
-
image_loader_svg = memnew(ImageLoaderSVG);
ImageLoader::add_image_format_loader(image_loader_svg);
}
void unregister_svg_types() {
-
memdelete(image_loader_svg);
}
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index fc9d727bb0..ce889a4928 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -38,8 +38,9 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
Vector<uint8_t> pixels;
error = pixels.resize(p_pixel_size);
- if (error != OK)
+ if (error != OK) {
return error;
+ }
uint8_t *pixels_w = pixels.ptrw();
@@ -77,7 +78,6 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
}
Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome) {
-
#define TGA_PUT_PIXEL(r, g, b, a) \
int image_data_ofs = ((y * width) + x); \
image_data_w[image_data_ofs * 4 + 0] = r; \
@@ -199,13 +199,12 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
}
}
- p_image->create(width, height, 0, Image::FORMAT_RGBA8, image_data);
+ p_image->create(width, height, false, Image::FORMAT_RGBA8, image_data);
return OK;
}
Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
@@ -234,8 +233,9 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
bool has_color_map = (tga_header.image_type == TGA_TYPE_RLE_INDEXED || tga_header.image_type == TGA_TYPE_INDEXED);
bool is_monochrome = (tga_header.image_type == TGA_TYPE_RLE_MONOCHROME || tga_header.image_type == TGA_TYPE_MONOCHROME);
- if (tga_header.image_type == TGA_TYPE_NO_DATA)
+ if (tga_header.image_type == TGA_TYPE_NO_DATA) {
err = FAILED;
+ }
if (has_color_map) {
if (tga_header.color_map_length > 256 || (tga_header.color_map_depth != 24) || tga_header.color_map_type != 1) {
@@ -247,8 +247,9 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
}
- if (tga_header.image_width <= 0 || tga_header.image_height <= 0)
+ if (tga_header.image_width <= 0 || tga_header.image_height <= 0) {
err = FAILED;
+ }
if (!(tga_header.pixel_depth == 8 || tga_header.pixel_depth == 24 || tga_header.pixel_depth == 32)) {
err = FAILED;
@@ -286,7 +287,6 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
const uint8_t *buffer = nullptr;
if (is_encoded) {
-
err = decode_tga_rle(src_image_r, pixel_size, uncompressed_buffer_w, buffer_size);
if (err == OK) {
@@ -308,7 +308,6 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
}
void ImageLoaderTGA::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("tga");
}
diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp
index 0d9268ebbf..320f748083 100644
--- a/modules/tga/register_types.cpp
+++ b/modules/tga/register_types.cpp
@@ -35,12 +35,10 @@
static ImageLoaderTGA *image_loader_tga = nullptr;
void register_tga_types() {
-
image_loader_tga = memnew(ImageLoaderTGA);
ImageLoader::add_image_format_loader(image_loader_tga);
}
void unregister_tga_types() {
-
memdelete(image_loader_tga);
}
diff --git a/modules/theora/config.py b/modules/theora/config.py
index 413acce2df..b063ed51f9 100644
--- a/modules/theora/config.py
+++ b/modules/theora/config.py
@@ -1,5 +1,5 @@
def can_build(env, platform):
- return True
+ return env.module_check_dependencies("theora", ["ogg", "vorbis"])
def configure(env):
diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp
index f58e27c855..0676cab5c5 100644
--- a/modules/theora/register_types.cpp
+++ b/modules/theora/register_types.cpp
@@ -35,7 +35,6 @@
static Ref<ResourceFormatLoaderTheora> resource_loader_theora;
void register_theora_types() {
-
resource_loader_theora.instance();
ResourceLoader::add_resource_format_loader(resource_loader_theora, true);
@@ -43,7 +42,6 @@ void register_theora_types() {
}
void unregister_theora_types() {
-
ResourceLoader::remove_resource_format_loader(resource_loader_theora);
resource_loader_theora.unref();
}
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index f5a7b5fc06..498391e44a 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -36,7 +36,6 @@
#include "thirdparty/misc/yuv2rgb.h"
int VideoStreamPlaybackTheora::buffer_data() {
-
char *buffer = ogg_sync_buffer(&oy, 4096);
#ifdef THEORA_USE_THREAD_STREAMING
@@ -69,18 +68,20 @@ int VideoStreamPlaybackTheora::buffer_data() {
int VideoStreamPlaybackTheora::queue_page(ogg_page *page) {
if (theora_p) {
ogg_stream_pagein(&to, page);
- if (to.e_o_s)
+ if (to.e_o_s) {
theora_eos = true;
+ }
}
if (vorbis_p) {
ogg_stream_pagein(&vo, page);
- if (vo.e_o_s)
+ if (vo.e_o_s) {
vorbis_eos = true;
+ }
}
return 0;
}
-void VideoStreamPlaybackTheora::video_write(void) {
+void VideoStreamPlaybackTheora::video_write() {
th_ycbcr_buffer yuv;
th_decode_ycbcr_out(td, yuv);
@@ -93,15 +94,12 @@ void VideoStreamPlaybackTheora::video_write(void) {
//uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y/2);
if (px_fmt == TH_PF_444) {
-
yuv444_2_rgb8888((uint8_t *)dst, (uint8_t *)yuv[0].data, (uint8_t *)yuv[1].data, (uint8_t *)yuv[2].data, size.x, size.y, yuv[0].stride, yuv[1].stride, size.x << 2);
} else if (px_fmt == TH_PF_422) {
-
yuv422_2_rgb8888((uint8_t *)dst, (uint8_t *)yuv[0].data, (uint8_t *)yuv[1].data, (uint8_t *)yuv[2].data, size.x, size.y, yuv[0].stride, yuv[1].stride, size.x << 2);
} else if (px_fmt == TH_PF_420) {
-
yuv420_2_rgb8888((uint8_t *)dst, (uint8_t *)yuv[0].data, (uint8_t *)yuv[1].data, (uint8_t *)yuv[2].data, size.x, size.y, yuv[0].stride, yuv[1].stride, size.x << 2);
};
@@ -116,9 +114,9 @@ void VideoStreamPlaybackTheora::video_write(void) {
}
void VideoStreamPlaybackTheora::clear() {
-
- if (!file)
+ if (!file) {
return;
+ }
if (vorbis_p) {
ogg_stream_clear(&vo);
@@ -164,7 +162,6 @@ void VideoStreamPlaybackTheora::clear() {
};
void VideoStreamPlaybackTheora::set_file(const String &p_file) {
-
ERR_FAIL_COND(playing);
ogg_packet op;
th_setup_info *ts = nullptr;
@@ -209,8 +206,9 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
while (!stateflag) {
int ret = buffer_data();
- if (ret == 0)
+ if (ret == 0) {
break;
+ }
while (ogg_sync_pageout(&oy, &og) > 0) {
ogg_stream_state test;
@@ -232,7 +230,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
copymem(&to, &test, sizeof(test));
theora_p = 1;
} else if (!vorbis_p && vorbis_synthesis_headerin(&vi, &vc, &op) >= 0) {
-
/* it is vorbis */
if (audio_track_skip) {
vorbis_info_clear(&vi);
@@ -287,8 +284,9 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
return;
}
vorbis_p++;
- if (vorbis_p == 3)
+ if (vorbis_p == 3) {
break;
+ }
}
/* The header pages/packets will arrive before anything else we
@@ -374,14 +372,13 @@ float VideoStreamPlaybackTheora::get_time() const {
};
Ref<Texture2D> VideoStreamPlaybackTheora::get_texture() const {
-
return texture;
}
void VideoStreamPlaybackTheora::update(float p_delta) {
-
- if (!file)
+ if (!file) {
return;
+ }
if (!playing || paused) {
//printf("not playing\n");
@@ -415,13 +412,11 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
/* if there's pending, decoded audio, grab it */
ret = vorbis_synthesis_pcmout(&vd, &pcm);
if (ret > 0) {
-
const int AUXBUF_LEN = 4096;
int to_read = ret;
float aux_buffer[AUXBUF_LEN];
while (to_read) {
-
int m = MIN(AUXBUF_LEN / vi.channels, to_read);
int count = 0;
@@ -449,7 +444,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
audio_frames_wrote += ret - to_read;
} else {
-
/* no pending audio; is there a pending packet to decode? */
if (ogg_stream_packetout(&vo, &op) > 0) {
if (vorbis_synthesis(&vb, &op) == 0) { /* test for success! */
@@ -462,14 +456,14 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
audio_done = videobuf_time < (audio_frames_wrote / float(vi.rate));
- if (buffer_full)
+ if (buffer_full) {
break;
+ }
}
while (theora_p && !frame_done) {
/* theora is one in, one out... */
if (ogg_stream_packetout(&to, &op) > 0) {
-
if (false && pp_inc) {
pp_level += pp_inc;
th_decode_ctl(td, TH_DECCTL_SET_PPLEVEL, &pp_level,
@@ -536,7 +530,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
/* are we at or past time for this video frame? */
if (videobuf_ready && videobuf_time <= get_time()) {
-
//video_write();
//videobuf_ready=0;
} else {
@@ -556,10 +549,9 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
};
void VideoStreamPlaybackTheora::play() {
-
- if (!playing)
+ if (!playing) {
time = 0;
- else {
+ } else {
stop();
}
@@ -569,9 +561,7 @@ void VideoStreamPlaybackTheora::play() {
};
void VideoStreamPlaybackTheora::stop() {
-
if (playing) {
-
clear();
set_file(file_name); //reset
}
@@ -580,86 +570,68 @@ void VideoStreamPlaybackTheora::stop() {
};
bool VideoStreamPlaybackTheora::is_playing() const {
-
return playing;
};
void VideoStreamPlaybackTheora::set_paused(bool p_paused) {
-
paused = p_paused;
};
bool VideoStreamPlaybackTheora::is_paused() const {
-
return paused;
};
-void VideoStreamPlaybackTheora::set_loop(bool p_enable){
-
-};
+void VideoStreamPlaybackTheora::set_loop(bool p_enable) {
+}
bool VideoStreamPlaybackTheora::has_loop() const {
-
return false;
};
float VideoStreamPlaybackTheora::get_length() const {
-
return 0;
};
String VideoStreamPlaybackTheora::get_stream_name() const {
-
return "";
};
int VideoStreamPlaybackTheora::get_loop_count() const {
-
return 0;
};
float VideoStreamPlaybackTheora::get_playback_position() const {
-
return get_time();
};
-void VideoStreamPlaybackTheora::seek(float p_time){
-
- // no
-};
+void VideoStreamPlaybackTheora::seek(float p_time) {
+}
void VideoStreamPlaybackTheora::set_mix_callback(AudioMixCallback p_callback, void *p_userdata) {
-
mix_callback = p_callback;
mix_udata = p_userdata;
}
int VideoStreamPlaybackTheora::get_channels() const {
-
return vi.channels;
}
void VideoStreamPlaybackTheora::set_audio_track(int p_idx) {
-
audio_track = p_idx;
}
int VideoStreamPlaybackTheora::get_mix_rate() const {
-
return vi.rate;
}
#ifdef THEORA_USE_THREAD_STREAMING
void VideoStreamPlaybackTheora::_streaming_thread(void *ud) {
-
VideoStreamPlaybackTheora *vs = (VideoStreamPlaybackTheora *)ud;
while (!vs->thread_exit) {
-
//just fill back the buffer
if (!vs->thread_eof) {
-
int to_read = vs->ring_buffer.space_left();
if (to_read) {
int read = vs->file->get_buffer(vs->read_buffer.ptr(), to_read);
@@ -675,7 +647,6 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) {
#endif
VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
-
file = nullptr;
theora_p = 0;
vorbis_p = 0;
@@ -706,19 +677,18 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
};
VideoStreamPlaybackTheora::~VideoStreamPlaybackTheora() {
-
#ifdef THEORA_USE_THREAD_STREAMING
memdelete(thread_sem);
#endif
clear();
- if (file)
+ if (file) {
memdelete(file);
+ }
};
void VideoStreamTheora::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamTheora::set_file);
ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamTheora::get_file);
@@ -728,7 +698,6 @@ void VideoStreamTheora::_bind_methods() {
////////////
RES ResourceFormatLoaderTheora::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) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
if (r_error) {
@@ -752,19 +721,17 @@ RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_origi
}
void ResourceFormatLoaderTheora::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("ogv");
}
bool ResourceFormatLoaderTheora::handles_type(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "VideoStream");
}
String ResourceFormatLoaderTheora::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "ogv")
+ if (el == "ogv") {
return "VideoStreamTheora";
+ }
return "";
}
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index f98368ed8b..f90c2465b4 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -45,7 +45,6 @@
//#define THEORA_USE_THREAD_STREAMING
class VideoStreamPlaybackTheora : public VideoStreamPlayback {
-
GDCLASS(VideoStreamPlaybackTheora, VideoStreamPlayback);
enum {
@@ -63,7 +62,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
int buffer_data();
int queue_page(ogg_page *page);
- void video_write(void);
+ void video_write();
float get_time() const;
bool theora_eos;
@@ -161,7 +160,6 @@ public:
};
class VideoStreamTheora : public VideoStream {
-
GDCLASS(VideoStreamTheora, VideoStream);
String file;
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 1c0f3cd03e..9e7266b95a 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -36,7 +36,6 @@
#include "thirdparty/tinyexr/tinyexr.h"
Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
@@ -62,7 +61,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
int ret = ParseEXRVersionFromMemory(&exr_version, w, src_image_len);
if (ret != TINYEXR_SUCCESS) {
-
return ERR_FILE_CORRUPT;
}
@@ -141,12 +139,10 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
int output_channels = 0;
if (idxA != -1) {
-
imgdata.resize(exr_image.width * exr_image.height * 8); //RGBA16
format = Image::FORMAT_RGBAH;
output_channels = 4;
} else {
-
imgdata.resize(exr_image.width * exr_image.height * 6); //RGB16
format = Image::FORMAT_RGBH;
output_channels = 3;
@@ -185,7 +181,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
// Assume `out_rgba` have enough memory allocated.
for (int tile_index = 0; tile_index < num_tiles; tile_index++) {
-
const EXRTile &tile = exr_tiles[tile_index];
int tw = tile.width;
@@ -215,11 +210,11 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
uint16_t *row_w = first_row_w + (y * exr_image.width * output_channels);
for (int x = 0; x < tw; x++) {
-
Color color(*r_channel++, *g_channel++, *b_channel++);
- if (p_force_linear)
+ if (p_force_linear) {
color = color.to_linear();
+ }
*row_w++ = Math::make_half_float(color.r);
*row_w++ = Math::make_half_float(color.g);
@@ -242,7 +237,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
}
void ImageLoaderTinyEXR::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("exr");
}
diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h
index af95989254..ff040b0915 100644
--- a/modules/tinyexr/image_loader_tinyexr.h
+++ b/modules/tinyexr/image_loader_tinyexr.h
@@ -34,7 +34,6 @@
#include "core/io/image_loader.h"
class ImageLoaderTinyEXR : public ImageFormatLoader {
-
public:
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp
index bc30f4e4fd..420619bd5f 100644
--- a/modules/tinyexr/image_saver_tinyexr.cpp
+++ b/modules/tinyexr/image_saver_tinyexr.cpp
@@ -140,7 +140,6 @@ static int get_channel_count(Image::Format p_format) {
}
Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) {
-
Image::Format format = p_img->get_format();
if (!is_supported_format(format)) {
@@ -192,7 +191,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
const uint8_t *src_r = src_data.ptr();
for (int channel_index = 0; channel_index < channel_count; ++channel_index) {
-
// De-interleave channels
PackedByteArray &dst = channels[channel_index];
@@ -201,7 +199,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
uint8_t *dst_w = dst.ptrw();
if (src_pixel_type == SRC_FLOAT && target_pixel_type == TINYEXR_PIXELTYPE_FLOAT) {
-
// Note: we don't save mipmaps
CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
@@ -213,7 +210,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
}
} else if (src_pixel_type == SRC_HALF && target_pixel_type == TINYEXR_PIXELTYPE_HALF) {
-
CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
const uint16_t *src_rp = (uint16_t *)src_r;
@@ -224,7 +220,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
}
} else if (src_pixel_type == SRC_BYTE && target_pixel_type == TINYEXR_PIXELTYPE_HALF) {
-
CRASH_COND(src_data.size() < pixel_count * channel_count);
const uint8_t *src_rp = (uint8_t *)src_r;
diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp
index af05a411e1..9d0fb8729e 100644
--- a/modules/tinyexr/register_types.cpp
+++ b/modules/tinyexr/register_types.cpp
@@ -36,7 +36,6 @@
static ImageLoaderTinyEXR *image_loader_tinyexr = nullptr;
void register_tinyexr_types() {
-
image_loader_tinyexr = memnew(ImageLoaderTinyEXR);
ImageLoader::add_image_format_loader(image_loader_tinyexr);
@@ -44,7 +43,6 @@ void register_tinyexr_types() {
}
void unregister_tinyexr_types() {
-
memdelete(image_loader_tinyexr);
Image::save_exr_func = nullptr;
diff --git a/modules/upnp/register_types.cpp b/modules/upnp/register_types.cpp
index 270aa2d7e8..34900206de 100644
--- a/modules/upnp/register_types.cpp
+++ b/modules/upnp/register_types.cpp
@@ -36,7 +36,6 @@
#include "upnp_device.h"
void register_upnp_types() {
-
ClassDB::register_class<UPNP>();
ClassDB::register_class<UPNPDevice>();
}
diff --git a/modules/upnp/upnp.h b/modules/upnp/upnp.h
index 46f44e04e5..1c4b5549f4 100644
--- a/modules/upnp/upnp.h
+++ b/modules/upnp/upnp.h
@@ -38,7 +38,6 @@
#include <miniupnpc/miniupnpc.h>
class UPNP : public Reference {
-
GDCLASS(UPNP, Reference);
private:
diff --git a/modules/upnp/upnp_device.h b/modules/upnp/upnp_device.h
index f25d3427fc..4b519fce32 100644
--- a/modules/upnp/upnp_device.h
+++ b/modules/upnp/upnp_device.h
@@ -34,7 +34,6 @@
#include "core/reference.h"
class UPNPDevice : public Reference {
-
GDCLASS(UPNPDevice, Reference);
public:
diff --git a/modules/vhacd/register_types.cpp b/modules/vhacd/register_types.cpp
index c006a9deec..40c5e47440 100644
--- a/modules/vhacd/register_types.cpp
+++ b/modules/vhacd/register_types.cpp
@@ -33,7 +33,6 @@
#include "thirdparty/vhacd/public/VHACD.h"
static Vector<Vector<Face3>> convex_decompose(const Vector<Face3> &p_faces) {
-
Vector<float> vertices;
vertices.resize(p_faces.size() * 9);
Vector<uint32_t> indices;
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index 5ea84a32c4..8afed1229f 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -47,7 +47,6 @@ static _VisualScriptEditor *vs_editor_singleton = nullptr;
#endif
void register_visual_script_types() {
-
visual_script_language = memnew(VisualScriptLanguage);
//script_language_gd->init();
ScriptServer::register_language(visual_script_language);
@@ -125,7 +124,6 @@ void register_visual_script_types() {
}
void unregister_visual_script_types() {
-
unregister_visual_script_nodes();
ScriptServer::unregister_language(visual_script_language);
@@ -136,6 +134,7 @@ void unregister_visual_script_types() {
memdelete(vs_editor_singleton);
}
#endif
- if (visual_script_language)
+ if (visual_script_language) {
memdelete(visual_script_language);
+ }
}
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index fe1d82f977..f387c0f288 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -44,7 +44,6 @@ void VisualScriptNode::set_breakpoint(bool p_breakpoint) {
}
bool VisualScriptNode::is_breakpoint() const {
-
return breakpoint;
}
@@ -53,7 +52,6 @@ void VisualScriptNode::ports_changed_notify() {
}
void VisualScriptNode::set_default_input_value(int p_port, const Variant &p_value) {
-
ERR_FAIL_INDEX(p_port, default_input_values.size());
default_input_values[p_port] = p_value;
@@ -66,13 +64,11 @@ void VisualScriptNode::set_default_input_value(int p_port, const Variant &p_valu
}
Variant VisualScriptNode::get_default_input_value(int p_port) const {
-
ERR_FAIL_INDEX_V(p_port, default_input_values.size(), Variant());
return default_input_values[p_port];
}
void VisualScriptNode::_set_default_input_values(Array p_values) {
-
default_input_values = p_values;
}
@@ -81,7 +77,6 @@ void VisualScriptNode::validate_input_default_values() {
//actually validate on save
for (int i = 0; i < get_input_value_port_count(); i++) {
-
Variant::Type expected = get_input_value_port_info(i).type;
if (expected == Variant::NIL || expected == default_input_values[i].get_type()) {
@@ -101,7 +96,6 @@ void VisualScriptNode::validate_input_default_values() {
}
Array VisualScriptNode::_get_default_input_values() const {
-
//validate on save, since on load there is little info about this
Array values = default_input_values;
values.resize(get_input_value_port_count());
@@ -114,7 +108,6 @@ String VisualScriptNode::get_text() const {
}
void VisualScriptNode::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_visual_script"), &VisualScriptNode::get_visual_script);
ClassDB::bind_method(D_METHOD("set_default_input_value", "port_idx", "value"), &VisualScriptNode::set_default_input_value);
ClassDB::bind_method(D_METHOD("get_default_input_value", "port_idx"), &VisualScriptNode::get_default_input_value);
@@ -127,7 +120,6 @@ void VisualScriptNode::_bind_methods() {
}
VisualScriptNode::TypeGuess VisualScriptNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
PropertyInfo pinfo = get_output_value_port_info(p_output);
TypeGuess tg;
@@ -141,9 +133,9 @@ VisualScriptNode::TypeGuess VisualScriptNode::guess_output_type(TypeGuess *p_inp
}
Ref<VisualScript> VisualScriptNode::get_visual_script() const {
-
- if (scripts_used.size())
+ if (scripts_used.size()) {
return Ref<VisualScript>(scripts_used.front()->get());
+ }
return Ref<VisualScript>();
}
@@ -157,13 +149,11 @@ VisualScriptNode::VisualScriptNode() {
/////////////////////
VisualScriptNodeInstance::VisualScriptNodeInstance() {
-
sequence_outputs = nullptr;
input_ports = nullptr;
}
VisualScriptNodeInstance::~VisualScriptNodeInstance() {
-
if (sequence_outputs) {
memdelete_arr(sequence_outputs);
}
@@ -178,7 +168,6 @@ VisualScriptNodeInstance::~VisualScriptNodeInstance() {
}
void VisualScript::add_function(const StringName &p_name) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!String(p_name).is_valid_identifier());
ERR_FAIL_COND(functions.has(p_name));
@@ -188,16 +177,14 @@ void VisualScript::add_function(const StringName &p_name) {
}
bool VisualScript::has_function(const StringName &p_name) const {
-
return functions.has(p_name);
}
-void VisualScript::remove_function(const StringName &p_name) {
+void VisualScript::remove_function(const StringName &p_name) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_name));
for (Map<int, Function::NodeData>::Element *E = functions[p_name].nodes.front(); E; E = E->next()) {
-
E->get().node->disconnect("ports_changed", callable_mp(this, &VisualScript::_node_ports_changed));
E->get().node->scripts_used.erase(this);
}
@@ -206,11 +193,11 @@ void VisualScript::remove_function(const StringName &p_name) {
}
void VisualScript::rename_function(const StringName &p_name, const StringName &p_new_name) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_name));
- if (p_new_name == p_name)
+ if (p_new_name == p_name) {
return;
+ }
ERR_FAIL_COND(!String(p_new_name).is_valid_identifier());
@@ -223,19 +210,16 @@ void VisualScript::rename_function(const StringName &p_name, const StringName &p
}
void VisualScript::set_function_scroll(const StringName &p_name, const Vector2 &p_scroll) {
-
ERR_FAIL_COND(!functions.has(p_name));
functions[p_name].scroll = p_scroll;
}
Vector2 VisualScript::get_function_scroll(const StringName &p_name) const {
-
ERR_FAIL_COND_V(!functions.has(p_name), Vector2());
return functions[p_name].scroll;
}
void VisualScript::get_function_list(List<StringName> *r_functions) const {
-
for (const Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
r_functions->push_back(E->key());
}
@@ -244,18 +228,15 @@ void VisualScript::get_function_list(List<StringName> *r_functions) const {
}
int VisualScript::get_function_node_id(const StringName &p_name) const {
-
ERR_FAIL_COND_V(!functions.has(p_name), -1);
return functions[p_name].function_id;
}
void VisualScript::_node_ports_changed(int p_id) {
-
StringName function;
for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
-
if (E->get().nodes.has(p_id)) {
function = E->key();
break;
@@ -276,11 +257,9 @@ void VisualScript::_node_ports_changed(int p_id) {
for (Set<SequenceConnection>::Element *E = func.sequence_connections.front(); E; E = E->next()) {
if (E->get().from_node == p_id && E->get().from_output >= vsn->get_output_sequence_port_count()) {
-
to_remove.push_back(E->get());
}
if (E->get().to_node == p_id && !vsn->has_input_sequence_port()) {
-
to_remove.push_back(E->get());
}
}
@@ -292,7 +271,6 @@ void VisualScript::_node_ports_changed(int p_id) {
}
{
-
List<DataConnection> to_remove;
for (Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) {
@@ -317,12 +295,10 @@ void VisualScript::_node_ports_changed(int p_id) {
}
void VisualScript::add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_func));
for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
-
ERR_FAIL_COND(E->get().nodes.has(p_id)); //id can exist only one in script, even for different functions
}
@@ -348,7 +324,6 @@ void VisualScript::add_node(const StringName &p_func, int p_id, const Ref<Visual
}
void VisualScript::remove_node(const StringName &p_func, int p_id) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_func));
Function &func = functions[p_func];
@@ -370,7 +345,6 @@ void VisualScript::remove_node(const StringName &p_func, int p_id) {
}
{
-
List<DataConnection> to_remove;
for (Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) {
@@ -396,7 +370,6 @@ void VisualScript::remove_node(const StringName &p_func, int p_id) {
}
bool VisualScript::has_node(const StringName &p_func, int p_id) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), false);
const Function &func = functions[p_func];
@@ -404,7 +377,6 @@ bool VisualScript::has_node(const StringName &p_func, int p_id) const {
}
Ref<VisualScriptNode> VisualScript::get_node(const StringName &p_func, int p_id) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), Ref<VisualScriptNode>());
const Function &func = functions[p_func];
@@ -414,7 +386,6 @@ Ref<VisualScriptNode> VisualScript::get_node(const StringName &p_func, int p_id)
}
void VisualScript::set_node_position(const StringName &p_func, int p_id, const Point2 &p_pos) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_func));
Function &func = functions[p_func];
@@ -424,7 +395,6 @@ void VisualScript::set_node_position(const StringName &p_func, int p_id, const P
}
Point2 VisualScript::get_node_position(const StringName &p_func, int p_id) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), Point2());
const Function &func = functions[p_func];
@@ -433,7 +403,6 @@ Point2 VisualScript::get_node_position(const StringName &p_func, int p_id) const
}
void VisualScript::get_node_list(const StringName &p_func, List<int> *r_nodes) const {
-
ERR_FAIL_COND(!functions.has(p_func));
const Function &func = functions[p_func];
@@ -443,7 +412,6 @@ void VisualScript::get_node_list(const StringName &p_func, List<int> *r_nodes) c
}
void VisualScript::sequence_connect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_func));
Function &func = functions[p_func];
@@ -458,7 +426,6 @@ void VisualScript::sequence_connect(const StringName &p_func, int p_from_node, i
}
void VisualScript::sequence_disconnect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) {
-
ERR_FAIL_COND(!functions.has(p_func));
Function &func = functions[p_func];
@@ -472,7 +439,6 @@ void VisualScript::sequence_disconnect(const StringName &p_func, int p_from_node
}
bool VisualScript::has_sequence_connection(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), false);
const Function &func = functions[p_func];
@@ -485,7 +451,6 @@ bool VisualScript::has_sequence_connection(const StringName &p_func, int p_from_
}
void VisualScript::get_sequence_connection_list(const StringName &p_func, List<SequenceConnection> *r_connection) const {
-
ERR_FAIL_COND(!functions.has(p_func));
const Function &func = functions[p_func];
@@ -495,7 +460,6 @@ void VisualScript::get_sequence_connection_list(const StringName &p_func, List<S
}
void VisualScript::data_connect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!functions.has(p_func));
Function &func = functions[p_func];
@@ -512,7 +476,6 @@ void VisualScript::data_connect(const StringName &p_func, int p_from_node, int p
}
void VisualScript::data_disconnect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) {
-
ERR_FAIL_COND(!functions.has(p_func));
Function &func = functions[p_func];
@@ -528,7 +491,6 @@ void VisualScript::data_disconnect(const StringName &p_func, int p_from_node, in
}
bool VisualScript::has_data_connection(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), false);
const Function &func = functions[p_func];
@@ -542,20 +504,19 @@ bool VisualScript::has_data_connection(const StringName &p_func, int p_from_node
}
bool VisualScript::is_input_value_port_connected(const StringName &p_func, int p_node, int p_port) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), false);
const Function &func = functions[p_func];
for (const Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) {
- if (E->get().to_node == p_node && E->get().to_port == p_port)
+ if (E->get().to_node == p_node && E->get().to_port == p_port) {
return true;
+ }
}
return false;
}
bool VisualScript::get_input_value_port_connection_source(const StringName &p_func, int p_node, int p_port, int *r_node, int *r_port) const {
-
ERR_FAIL_COND_V(!functions.has(p_func), false);
const Function &func = functions[p_func];
@@ -571,7 +532,6 @@ bool VisualScript::get_input_value_port_connection_source(const StringName &p_fu
}
void VisualScript::get_data_connection_list(const StringName &p_func, List<DataConnection> *r_connection) const {
-
ERR_FAIL_COND(!functions.has(p_func));
const Function &func = functions[p_func];
@@ -585,7 +545,6 @@ void VisualScript::set_tool_enabled(bool p_enabled) {
}
void VisualScript::add_variable(const StringName &p_name, const Variant &p_default_value, bool p_export) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!String(p_name).is_valid_identifier());
ERR_FAIL_COND(variables.has(p_name));
@@ -605,12 +564,10 @@ void VisualScript::add_variable(const StringName &p_name, const Variant &p_defau
}
bool VisualScript::has_variable(const StringName &p_name) const {
-
return variables.has(p_name);
}
void VisualScript::remove_variable(const StringName &p_name) {
-
ERR_FAIL_COND(!variables.has(p_name));
variables.erase(p_name);
@@ -620,7 +577,6 @@ void VisualScript::remove_variable(const StringName &p_name) {
}
void VisualScript::set_variable_default_value(const StringName &p_name, const Variant &p_value) {
-
ERR_FAIL_COND(!variables.has(p_name));
variables[p_name].default_value = p_value;
@@ -629,13 +585,13 @@ void VisualScript::set_variable_default_value(const StringName &p_name, const Va
_update_placeholders();
#endif
}
-Variant VisualScript::get_variable_default_value(const StringName &p_name) const {
+Variant VisualScript::get_variable_default_value(const StringName &p_name) const {
ERR_FAIL_COND_V(!variables.has(p_name), Variant());
return variables[p_name].default_value;
}
-void VisualScript::set_variable_info(const StringName &p_name, const PropertyInfo &p_info) {
+void VisualScript::set_variable_info(const StringName &p_name, const PropertyInfo &p_info) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!variables.has(p_name));
variables[p_name].info = p_info;
@@ -645,14 +601,13 @@ void VisualScript::set_variable_info(const StringName &p_name, const PropertyInf
_update_placeholders();
#endif
}
-PropertyInfo VisualScript::get_variable_info(const StringName &p_name) const {
+PropertyInfo VisualScript::get_variable_info(const StringName &p_name) const {
ERR_FAIL_COND_V(!variables.has(p_name), PropertyInfo());
return variables[p_name].info;
}
void VisualScript::set_variable_export(const StringName &p_name, bool p_export) {
-
ERR_FAIL_COND(!variables.has(p_name));
variables[p_name]._export = p_export;
@@ -662,30 +617,32 @@ void VisualScript::set_variable_export(const StringName &p_name, bool p_export)
}
bool VisualScript::get_variable_export(const StringName &p_name) const {
-
ERR_FAIL_COND_V(!variables.has(p_name), false);
return variables[p_name]._export;
}
void VisualScript::_set_variable_info(const StringName &p_name, const Dictionary &p_info) {
-
PropertyInfo pinfo;
- if (p_info.has("type"))
+ if (p_info.has("type")) {
pinfo.type = Variant::Type(int(p_info["type"]));
- if (p_info.has("name"))
+ }
+ if (p_info.has("name")) {
pinfo.name = p_info["name"];
- if (p_info.has("hint"))
+ }
+ if (p_info.has("hint")) {
pinfo.hint = PropertyHint(int(p_info["hint"]));
- if (p_info.has("hint_string"))
+ }
+ if (p_info.has("hint_string")) {
pinfo.hint_string = p_info["hint_string"];
- if (p_info.has("usage"))
+ }
+ if (p_info.has("usage")) {
pinfo.usage = p_info["usage"];
+ }
set_variable_info(p_name, pinfo);
}
Dictionary VisualScript::_get_variable_info(const StringName &p_name) const {
-
PropertyInfo pinfo = get_variable_info(p_name);
Dictionary d;
d["type"] = pinfo.type;
@@ -698,7 +655,6 @@ Dictionary VisualScript::_get_variable_info(const StringName &p_name) const {
}
void VisualScript::get_variable_list(List<StringName> *r_variables) const {
-
for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) {
r_variables->push_back(E->key());
}
@@ -707,17 +663,16 @@ void VisualScript::get_variable_list(List<StringName> *r_variables) const {
}
void VisualScript::set_instance_base_type(const StringName &p_type) {
-
ERR_FAIL_COND(instances.size());
base_type = p_type;
}
void VisualScript::rename_variable(const StringName &p_name, const StringName &p_new_name) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!variables.has(p_name));
- if (p_new_name == p_name)
+ if (p_new_name == p_name) {
return;
+ }
ERR_FAIL_COND(!String(p_new_name).is_valid_identifier());
@@ -736,13 +691,15 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p
for (List<int>::Element *E = ids.front(); E; E = E->next()) {
Ref<VisualScriptVariableGet> nodeget = get_node(F->get(), E->get());
if (nodeget.is_valid()) {
- if (nodeget->get_variable() == p_name)
+ if (nodeget->get_variable() == p_name) {
nodeget->set_variable(p_new_name);
+ }
} else {
Ref<VisualScriptVariableSet> nodeset = get_node(F->get(), E->get());
if (nodeset.is_valid()) {
- if (nodeset->get_variable() == p_name)
+ if (nodeset->get_variable() == p_name) {
nodeset->set_variable(p_new_name);
+ }
}
}
}
@@ -750,7 +707,6 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p
}
void VisualScript::add_custom_signal(const StringName &p_name) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!String(p_name).is_valid_identifier());
ERR_FAIL_COND(custom_signals.has(p_name));
@@ -759,48 +715,49 @@ void VisualScript::add_custom_signal(const StringName &p_name) {
}
bool VisualScript::has_custom_signal(const StringName &p_name) const {
-
return custom_signals.has(p_name);
}
-void VisualScript::custom_signal_add_argument(const StringName &p_func, Variant::Type p_type, const String &p_name, int p_index) {
+void VisualScript::custom_signal_add_argument(const StringName &p_func, Variant::Type p_type, const String &p_name, int p_index) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_func));
Argument arg;
arg.type = p_type;
arg.name = p_name;
- if (p_index < 0)
+ if (p_index < 0) {
custom_signals[p_func].push_back(arg);
- else
+ } else {
custom_signals[p_func].insert(0, arg);
+ }
}
-void VisualScript::custom_signal_set_argument_type(const StringName &p_func, int p_argidx, Variant::Type p_type) {
+void VisualScript::custom_signal_set_argument_type(const StringName &p_func, int p_argidx, Variant::Type p_type) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_func));
ERR_FAIL_INDEX(p_argidx, custom_signals[p_func].size());
custom_signals[p_func].write[p_argidx].type = p_type;
}
-Variant::Type VisualScript::custom_signal_get_argument_type(const StringName &p_func, int p_argidx) const {
+Variant::Type VisualScript::custom_signal_get_argument_type(const StringName &p_func, int p_argidx) const {
ERR_FAIL_COND_V(!custom_signals.has(p_func), Variant::NIL);
ERR_FAIL_INDEX_V(p_argidx, custom_signals[p_func].size(), Variant::NIL);
return custom_signals[p_func][p_argidx].type;
}
+
void VisualScript::custom_signal_set_argument_name(const StringName &p_func, int p_argidx, const String &p_name) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_func));
ERR_FAIL_INDEX(p_argidx, custom_signals[p_func].size());
custom_signals[p_func].write[p_argidx].name = p_name;
}
-String VisualScript::custom_signal_get_argument_name(const StringName &p_func, int p_argidx) const {
+String VisualScript::custom_signal_get_argument_name(const StringName &p_func, int p_argidx) const {
ERR_FAIL_COND_V(!custom_signals.has(p_func), String());
ERR_FAIL_INDEX_V(p_argidx, custom_signals[p_func].size(), String());
return custom_signals[p_func][p_argidx].name;
}
-void VisualScript::custom_signal_remove_argument(const StringName &p_func, int p_argidx) {
+void VisualScript::custom_signal_remove_argument(const StringName &p_func, int p_argidx) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_func));
ERR_FAIL_INDEX(p_argidx, custom_signals[p_func].size());
@@ -808,12 +765,11 @@ void VisualScript::custom_signal_remove_argument(const StringName &p_func, int p
}
int VisualScript::custom_signal_get_argument_count(const StringName &p_func) const {
-
ERR_FAIL_COND_V(!custom_signals.has(p_func), 0);
return custom_signals[p_func].size();
}
-void VisualScript::custom_signal_swap_argument(const StringName &p_func, int p_argidx, int p_with_argidx) {
+void VisualScript::custom_signal_swap_argument(const StringName &p_func, int p_argidx, int p_with_argidx) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_func));
ERR_FAIL_INDEX(p_argidx, custom_signals[p_func].size());
@@ -821,19 +777,19 @@ void VisualScript::custom_signal_swap_argument(const StringName &p_func, int p_a
SWAP(custom_signals[p_func].write[p_argidx], custom_signals[p_func].write[p_with_argidx]);
}
-void VisualScript::remove_custom_signal(const StringName &p_name) {
+void VisualScript::remove_custom_signal(const StringName &p_name) {
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_name));
custom_signals.erase(p_name);
}
void VisualScript::rename_custom_signal(const StringName &p_name, const StringName &p_new_name) {
-
ERR_FAIL_COND(instances.size());
ERR_FAIL_COND(!custom_signals.has(p_name));
- if (p_new_name == p_name)
+ if (p_new_name == p_name) {
return;
+ }
ERR_FAIL_COND(!String(p_new_name).is_valid_identifier());
@@ -846,7 +802,6 @@ void VisualScript::rename_custom_signal(const StringName &p_name, const StringNa
}
void VisualScript::get_custom_signal_list(List<StringName> *r_custom_signals) const {
-
for (const Map<StringName, Vector<Argument>>::Element *E = custom_signals.front(); E; E = E->next()) {
r_custom_signals->push_back(E->key());
}
@@ -855,11 +810,11 @@ void VisualScript::get_custom_signal_list(List<StringName> *r_custom_signals) co
}
int VisualScript::get_available_id() const {
-
int max_id = 0;
for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
- if (E->get().nodes.empty())
+ if (E->get().nodes.empty()) {
continue;
+ }
int last_id = E->get().nodes.back()->key();
max_id = MAX(max_id, last_id + 1);
@@ -871,12 +826,10 @@ int VisualScript::get_available_id() const {
/////////////////////////////////
bool VisualScript::can_instance() const {
-
return true; //ScriptServer::is_scripting_enabled();
}
StringName VisualScript::get_instance_base_type() const {
-
return base_type;
}
@@ -886,21 +839,20 @@ Ref<Script> VisualScript::get_base_script() const {
#ifdef TOOLS_ENABLED
void VisualScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
-
placeholders.erase(p_placeholder);
}
void VisualScript::_update_placeholders() {
-
- if (placeholders.size() == 0)
+ if (placeholders.size() == 0) {
return; //no bother if no placeholders
+ }
List<PropertyInfo> pinfo;
Map<StringName, Variant> values;
for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) {
-
- if (!E->get()._export)
+ if (!E->get()._export) {
continue;
+ }
PropertyInfo p = E->get().info;
p.name = String(E->key());
@@ -909,7 +861,6 @@ void VisualScript::_update_placeholders() {
}
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
-
E->get()->update(pinfo, values);
}
}
@@ -917,11 +868,9 @@ void VisualScript::_update_placeholders() {
#endif
ScriptInstance *VisualScript::instance_create(Object *p_this) {
-
#ifdef TOOLS_ENABLED
if (!ScriptServer::is_scripting_enabled() && !is_tool_script) {
-
PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(VisualScriptLanguage::singleton, Ref<Script>((Script *)this), p_this));
placeholders.insert(sins);
@@ -929,9 +878,9 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
Map<StringName, Variant> values;
for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) {
-
- if (!E->get()._export)
+ if (!E->get()._export) {
continue;
+ }
PropertyInfo p = E->get().info;
p.name = String(E->key());
@@ -958,17 +907,14 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
}
bool VisualScript::instance_has(const Object *p_this) const {
-
return instances.has((Object *)p_this);
}
bool VisualScript::has_source_code() const {
-
return false;
}
String VisualScript::get_source_code() const {
-
return String();
}
@@ -976,12 +922,10 @@ void VisualScript::set_source_code(const String &p_code) {
}
Error VisualScript::reload(bool p_keep_state) {
-
return OK;
}
bool VisualScript::is_tool() const {
-
return is_tool_script;
}
@@ -990,19 +934,15 @@ bool VisualScript::is_valid() const {
}
ScriptLanguage *VisualScript::get_language() const {
-
return VisualScriptLanguage::singleton;
}
bool VisualScript::has_script_signal(const StringName &p_signal) const {
-
return custom_signals.has(p_signal);
}
void VisualScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
-
for (const Map<StringName, Vector<Argument>>::Element *E = custom_signals.front(); E; E = E->next()) {
-
MethodInfo mi;
mi.name = E->key();
for (int i = 0; i < E->get().size(); i++) {
@@ -1017,21 +957,19 @@ void VisualScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
}
bool VisualScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
-
- if (!variables.has(p_property))
+ if (!variables.has(p_property)) {
return false;
+ }
r_value = variables[p_property].default_value;
return true;
}
-void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const {
+void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const {
for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
-
MethodInfo mi;
mi.name = E->key();
if (E->get().function_id >= 0) {
-
Ref<VisualScriptFunction> func = E->get().nodes[E->get().function_id].node;
if (func.is_valid()) {
for (int i = 0; i < func->get_argument_count(); i++) {
@@ -1048,22 +986,20 @@ void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const {
}
bool VisualScript::has_method(const StringName &p_method) const {
-
return functions.has(p_method);
}
-MethodInfo VisualScript::get_method_info(const StringName &p_method) const {
+MethodInfo VisualScript::get_method_info(const StringName &p_method) const {
const Map<StringName, Function>::Element *E = functions.find(p_method);
- if (!E)
+ if (!E) {
return MethodInfo();
+ }
MethodInfo mi;
mi.name = E->key();
if (E->get().function_id >= 0) {
-
Ref<VisualScriptFunction> func = E->get().nodes[E->get().function_id].node;
if (func.is_valid()) {
-
for (int i = 0; i < func->get_argument_count(); i++) {
PropertyInfo arg;
arg.name = func->get_argument_name(i);
@@ -1081,7 +1017,6 @@ MethodInfo VisualScript::get_method_info(const StringName &p_method) const {
}
void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const {
-
List<StringName> vars;
get_variable_list(&vars);
@@ -1098,8 +1033,9 @@ int VisualScript::get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
if (has_function(p_member)) {
for (Map<int, Function::NodeData>::Element *E = functions[p_member].nodes.front(); E; E = E->next()) {
- if (Object::cast_to<VisualScriptFunction>(E->get().node.ptr()))
+ if (Object::cast_to<VisualScriptFunction>(E->get().node.ptr())) {
return E->key();
+ }
}
}
#endif
@@ -1108,9 +1044,7 @@ int VisualScript::get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
bool VisualScript::are_subnodes_edited() const {
-
for (const Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
-
for (const Map<int, Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) {
if (F->get().node->is_edited()) {
return true;
@@ -1177,15 +1111,14 @@ MultiplayerAPI::RPCMode VisualScript::get_rset_mode(const StringName &p_variable
}
void VisualScript::_set_data(const Dictionary &p_data) {
-
Dictionary d = p_data;
- if (d.has("base_type"))
+ if (d.has("base_type")) {
base_type = d["base_type"];
+ }
variables.clear();
Array vars = d["variables"];
for (int i = 0; i < vars.size(); i++) {
-
Dictionary v = vars[i];
StringName name = v["name"];
add_variable(name);
@@ -1197,7 +1130,6 @@ void VisualScript::_set_data(const Dictionary &p_data) {
custom_signals.clear();
Array sigs = d["signals"];
for (int i = 0; i < sigs.size(); i++) {
-
Dictionary cs = sigs[i];
add_custom_signal(cs["name"]);
@@ -1214,7 +1146,6 @@ void VisualScript::_set_data(const Dictionary &p_data) {
Vector2 last_size = Vector2(0.0, 0.0);
for (int i = 0; i < funcs.size(); i++) {
-
Dictionary func = funcs[i];
StringName name = func["name"];
@@ -1264,22 +1195,21 @@ void VisualScript::_set_data(const Dictionary &p_data) {
Array sequence_connections = func["sequence_connections"];
for (int j = 0; j < sequence_connections.size(); j += 3) {
-
sequence_connect(name, sequence_connections[j + 0], sequence_connections[j + 1], sequence_connections[j + 2]);
}
Array data_connections = func["data_connections"];
for (int j = 0; j < data_connections.size(); j += 4) {
-
data_connect(name, data_connections[j + 0], data_connections[j + 1], data_connections[j + 2], data_connections[j + 3]);
}
}
- if (d.has("is_tool_script"))
+ if (d.has("is_tool_script")) {
is_tool_script = d["is_tool_script"];
- else
+ } else {
is_tool_script = false;
+ }
// Takes all the rpc methods
rpc_functions.clear();
@@ -1307,12 +1237,10 @@ void VisualScript::_set_data(const Dictionary &p_data) {
}
Dictionary VisualScript::_get_data() const {
-
Dictionary d;
d["base_type"] = base_type;
Array vars;
for (const Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) {
-
Dictionary var = _get_variable_info(E->key());
var["name"] = E->key(); //make sure it's the right one
var["default_value"] = E->get().default_value;
@@ -1323,7 +1251,6 @@ Dictionary VisualScript::_get_data() const {
Array sigs;
for (const Map<StringName, Vector<Argument>>::Element *E = custom_signals.front(); E; E = E->next()) {
-
Dictionary cs;
cs["name"] = E->key();
Array args;
@@ -1341,7 +1268,6 @@ Dictionary VisualScript::_get_data() const {
Array funcs;
for (const Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
-
Dictionary func;
func["name"] = E->key();
func["function_id"] = E->get().function_id;
@@ -1350,7 +1276,6 @@ Dictionary VisualScript::_get_data() const {
Array nodes;
for (const Map<int, Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) {
-
nodes.push_back(F->key());
nodes.push_back(F->get().pos);
nodes.push_back(F->get().node);
@@ -1361,7 +1286,6 @@ Dictionary VisualScript::_get_data() const {
Array sequence_connections;
for (const Set<SequenceConnection>::Element *F = E->get().sequence_connections.front(); F; F = F->next()) {
-
sequence_connections.push_back(F->get().from_node);
sequence_connections.push_back(F->get().from_output);
sequence_connections.push_back(F->get().to_node);
@@ -1372,7 +1296,6 @@ Dictionary VisualScript::_get_data() const {
Array data_connections;
for (const Set<DataConnection>::Element *F = E->get().data_connections.front(); F; F = F->next()) {
-
data_connections.push_back(F->get().from_node);
data_connections.push_back(F->get().from_port);
data_connections.push_back(F->get().to_node);
@@ -1392,7 +1315,6 @@ Dictionary VisualScript::_get_data() const {
}
void VisualScript::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_function", "name"), &VisualScript::add_function);
ClassDB::bind_method(D_METHOD("has_function", "name"), &VisualScript::has_function);
ClassDB::bind_method(D_METHOD("remove_function", "name"), &VisualScript::remove_function);
@@ -1455,7 +1377,6 @@ void VisualScript::_bind_methods() {
}
VisualScript::VisualScript() {
-
base_type = "Object";
is_tool_script = false;
}
@@ -1482,7 +1403,6 @@ Set<int> VisualScript::get_output_sequence_ports_connected(const String &edited_
}
VisualScript::~VisualScript() {
-
while (!functions.empty()) {
remove_function(functions.front()->key());
}
@@ -1491,10 +1411,10 @@ VisualScript::~VisualScript() {
////////////////////////////////////////////
bool VisualScriptInstance::set(const StringName &p_name, const Variant &p_value) {
-
Map<StringName, Variant>::Element *E = variables.find(p_name);
- if (!E)
+ if (!E) {
return false;
+ }
E->get() = p_value;
@@ -1502,45 +1422,45 @@ bool VisualScriptInstance::set(const StringName &p_name, const Variant &p_value)
}
bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
-
const Map<StringName, Variant>::Element *E = variables.find(p_name);
- if (!E)
+ if (!E) {
return false;
+ }
r_ret = E->get();
return true;
}
-void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
+void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
for (const Map<StringName, VisualScript::Variable>::Element *E = script->variables.front(); E; E = E->next()) {
-
- if (!E->get()._export)
+ if (!E->get()._export) {
continue;
+ }
PropertyInfo p = E->get().info;
p.name = String(E->key());
p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
p_properties->push_back(p);
}
}
-Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
+Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
const Map<StringName, VisualScript::Variable>::Element *E = script->variables.find(p_name);
if (!E) {
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = false;
+ }
ERR_FAIL_V(Variant::NIL);
}
- if (r_is_valid)
+ if (r_is_valid) {
*r_is_valid = true;
+ }
return E->get().info.type;
}
void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
-
for (const Map<StringName, VisualScript::Function>::Element *E = script->functions.front(); E; E = E->next()) {
-
if (E->key() == script->get_default_func()) {
continue;
}
@@ -1548,10 +1468,8 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
MethodInfo mi;
mi.name = E->key();
if (E->get().function_id >= 0 && E->get().nodes.has(E->get().function_id)) {
-
Ref<VisualScriptFunction> vsf = E->get().nodes[E->get().function_id].node;
if (vsf.is_valid()) {
-
for (int i = 0; i < vsf->get_argument_count(); i++) {
PropertyInfo arg;
arg.name = vsf->get_argument_name(i);
@@ -1569,10 +1487,11 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
p_list->push_back(mi);
}
}
-bool VisualScriptInstance::has_method(const StringName &p_method) const {
- if (p_method == script->get_default_func())
+bool VisualScriptInstance::has_method(const StringName &p_method) const {
+ if (p_method == script->get_default_func()) {
return false;
+ }
return script->functions.has(p_method);
}
@@ -1581,29 +1500,27 @@ bool VisualScriptInstance::has_method(const StringName &p_method) const {
#define VSDEBUG(m_text)
void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Callable::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node) {
-
ERR_FAIL_COND(node->pass_idx == -1);
- if (pass_stack[node->pass_idx] == p_pass)
+ if (pass_stack[node->pass_idx] == p_pass) {
return;
+ }
pass_stack[node->pass_idx] = p_pass;
if (!node->dependencies.empty()) {
-
int dc = node->dependencies.size();
VisualScriptNodeInstance **deps = node->dependencies.ptrw();
for (int i = 0; i < dc; i++) {
-
_dependency_step(deps[i], p_pass, pass_stack, input_args, output_args, variant_stack, r_error, error_str, r_error_node);
- if (r_error.error != Callable::CallError::CALL_OK)
+ if (r_error.error != Callable::CallError::CALL_OK) {
return;
+ }
}
}
for (int i = 0; i < node->input_port_count; i++) {
-
int index = node->input_ports[i] & VisualScriptNodeInstance::INPUT_MASK;
if (node->input_ports[i] & VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT) {
@@ -1628,7 +1545,6 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int
}
Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Callable::CallError &r_error) {
-
Map<StringName, Function>::Element *F = functions.find(p_method);
ERR_FAIL_COND_V(!F, Variant());
Function *f = &F->get();
@@ -1659,7 +1575,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
#endif
while (true) {
-
p_pass++; //increment pass
current_node_id = node->get_id();
@@ -1678,16 +1593,13 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
input_args[i] = &variant_stack[i];
}
} else {
-
//run dependencies first
if (!node->dependencies.empty()) {
-
int dc = node->dependencies.size();
VisualScriptNodeInstance **deps = node->dependencies.ptrw();
for (int i = 0; i < dc; i++) {
-
_dependency_step(deps[i], p_pass, pass_stack, input_args, output_args, variant_stack, r_error, error_str, &node);
if (r_error.error != Callable::CallError::CALL_OK) {
error = true;
@@ -1698,12 +1610,10 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}
if (!error) {
-
//setup input pointers normally
VSDEBUG("INPUT PORTS: " + itos(node->input_port_count));
for (int i = 0; i < node->input_port_count; i++) {
-
int index = node->input_ports[i] & VisualScriptNodeInstance::INPUT_MASK;
if (node->input_ports[i] & VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT) {
@@ -1719,8 +1629,9 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}
}
- if (error)
+ if (error) {
break;
+ }
//setup output pointers
@@ -1766,7 +1677,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
} else {
Ref<VisualScriptFunctionState> state = *working_mem;
if (!state.is_valid()) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Node yielded, but did not return a function state in the first working memory.");
error = true;
@@ -1805,15 +1715,17 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
bool do_break = false;
if (EngineDebugger::get_script_debugger()->get_lines_left() > 0) {
-
- if (EngineDebugger::get_script_debugger()->get_depth() <= 0)
+ if (EngineDebugger::get_script_debugger()->get_depth() <= 0) {
EngineDebugger::get_script_debugger()->set_lines_left(EngineDebugger::get_script_debugger()->get_lines_left() - 1);
- if (EngineDebugger::get_script_debugger()->get_lines_left() <= 0)
+ }
+ if (EngineDebugger::get_script_debugger()->get_lines_left() <= 0) {
do_break = true;
+ }
}
- if (EngineDebugger::get_script_debugger()->is_breakpoint(current_node_id, source))
+ if (EngineDebugger::get_script_debugger()->is_breakpoint(current_node_id, source)) {
do_break = true;
+ }
if (do_break) {
VisualScriptLanguage::singleton->debug_break("Breakpoint", true);
@@ -1828,7 +1740,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
if (ret & VisualScriptNodeInstance::STEP_EXIT_FUNCTION_BIT) {
if (node->get_working_memory_size() == 0) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Return value must be assigned to first element of node working memory! Fix your node please.");
error = true;
@@ -1861,13 +1772,11 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}
if (flow_stack) {
-
//update flow stack pos (may have changed)
flow_stack[flow_stack_pos] = current_node_id;
//add stack push bit if requested
if (ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) {
-
flow_stack[flow_stack_pos] |= VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT;
sequence_bits[node->sequence_index] = true; //remember sequence bit
VSDEBUG("NEXT SEQ - FLAG BIT");
@@ -1888,7 +1797,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
break; //simply exit without value or error
}
} else if (next) {
-
if (sequence_bits[next->sequence_index]) {
// what happened here is that we are entering a node that is in the middle of doing a sequence (pushed stack) from the front
// because each node has a working memory, we can't really do a sub-sequence
@@ -1898,7 +1806,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
bool found = false;
for (int i = flow_stack_pos; i >= 0; i--) {
-
if ((flow_stack[i] & VisualScriptNodeInstance::FLOW_STACK_MASK) == next->get_id()) {
flow_stack_pos = i; //roll back and remove bit
flow_stack[i] = next->get_id();
@@ -1940,10 +1847,8 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
bool found = false;
for (int i = flow_stack_pos; i >= 0; i--) {
-
VSDEBUG("FS " + itos(i) + " - " + itos(flow_stack[i]));
if (flow_stack[i] & VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT) {
-
node = instances[flow_stack[i] & VisualScriptNodeInstance::FLOW_STACK_MASK];
flow_stack_pos = i;
found = true;
@@ -1959,13 +1864,11 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
VSDEBUG("NO NEXT NODE, GO BACK TO: " + itos(flow_stack_pos));
}
} else {
-
node = next; //stackless mode, simply assign next node
}
}
if (error) {
-
//error
// function, file, line, error, explanation
String err_file = script->get_path();
@@ -1973,7 +1876,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
int err_line = current_node_id; //not a line but it works as one
if (node && (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD || error_str == String())) {
-
if (error_str != String()) {
error_str += " ";
}
@@ -1996,13 +1898,11 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
// debugger break did not happen
if (!VisualScriptLanguage::singleton->debug_break(error_str, false)) {
-
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, error_str.utf8().get_data(), ERR_HANDLER_SCRIPT);
}
//}
} else {
-
//return_value=
}
@@ -2021,7 +1921,6 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}
Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_OK; //ok by default
Map<StringName, Function>::Element *F = functions.find(p_method);
@@ -2109,7 +2008,6 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p
}
void VisualScriptInstance::notification(int p_notification) {
-
//do nothing as this is called using virtual
Variant what = p_notification;
@@ -2124,22 +2022,24 @@ String VisualScriptInstance::to_string(bool *r_valid) {
Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret.operator String();
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return String();
}
Ref<Script> VisualScriptInstance::get_script() const {
-
return script;
}
@@ -2184,7 +2084,6 @@ MultiplayerAPI::RPCMode VisualScriptInstance::get_rset_mode(const StringName &p_
}
void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_owner) {
-
script = p_script;
owner = p_owner;
source = p_script->get_path();
@@ -2195,16 +2094,21 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
if (Object::cast_to<Node>(p_owner)) {
//turn on these if they exist and base is a node
Node *node = Object::cast_to<Node>(p_owner);
- if (p_script->functions.has("_process"))
+ if (p_script->functions.has("_process")) {
node->set_process(true);
- if (p_script->functions.has("_physics_process"))
+ }
+ if (p_script->functions.has("_physics_process")) {
node->set_physics_process(true);
- if (p_script->functions.has("_input"))
+ }
+ if (p_script->functions.has("_input")) {
node->set_process_input(true);
- if (p_script->functions.has("_unhandled_input"))
+ }
+ if (p_script->functions.has("_unhandled_input")) {
node->set_process_unhandled_input(true);
- if (p_script->functions.has("_unhandled_key_input"))
+ }
+ if (p_script->functions.has("_unhandled_key_input")) {
node->set_process_unhandled_key_input(true);
+ }
}
for (const Map<StringName, VisualScript::Variable>::Element *E = script->variables.front(); E; E = E->next()) {
@@ -2212,7 +2116,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
}
for (const Map<StringName, VisualScript::Function>::Element *E = script->functions.front(); E; E = E->next()) {
-
if (E->key() == script->get_default_func()) {
continue;
}
@@ -2251,7 +2154,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
//first create the nodes
for (const Map<int, VisualScript::Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) {
-
Ref<VisualScriptNode> node = F->get().node;
VisualScriptNodeInstance *instance = node->instance(this); //create instance
@@ -2272,7 +2174,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
if (instance->input_port_count) {
instance->input_ports = memnew_arr(int, instance->input_port_count);
for (int i = 0; i < instance->input_port_count; i++) {
-
instance->input_ports[i] = -1; //if not assigned, will become default value
}
}
@@ -2297,10 +2198,11 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
StringName var_name;
- if (Object::cast_to<VisualScriptLocalVar>(*node))
+ if (Object::cast_to<VisualScriptLocalVar>(*node)) {
var_name = String(Object::cast_to<VisualScriptLocalVar>(*node)->get_var_name()).strip_edges();
- else
+ } else {
var_name = String(Object::cast_to<VisualScriptLocalVarSet>(*node)->get_var_name()).strip_edges();
+ }
if (!local_var_indices.has(var_name)) {
local_var_indices[var_name] = function.max_stack;
@@ -2327,7 +2229,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
//second pass, do data connections
for (const Set<VisualScript::DataConnection>::Element *F = E->get().data_connections.front(); F; F = F->next()) {
-
VisualScript::DataConnection dc = F->get();
ERR_CONTINUE(!instances.has(dc.from_node));
VisualScriptNodeInstance *from = instances[dc.from_node];
@@ -2337,7 +2238,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
ERR_CONTINUE(dc.to_port >= to->input_port_count);
if (from->output_ports[dc.from_port] == -1) {
-
int stack_pos = function.max_stack++;
from->output_ports[dc.from_port] = stack_pos;
}
@@ -2357,7 +2257,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
//third pass, do sequence connections
for (const Set<VisualScript::SequenceConnection>::Element *F = E->get().sequence_connections.front(); F; F = F->next()) {
-
VisualScript::SequenceConnection sc = F->get();
ERR_CONTINUE(!instances.has(sc.from_node));
VisualScriptNodeInstance *from = instances[sc.from_node];
@@ -2373,7 +2272,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
// 2) connect unassigned output ports to trash
for (const Map<int, VisualScript::Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) {
-
ERR_CONTINUE(!instances.has(F->key()));
Ref<VisualScriptNode> node = F->get().node;
@@ -2382,7 +2280,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
// connect to default values
for (int i = 0; i < instance->input_port_count; i++) {
if (instance->input_ports[i] == -1) {
-
//unassigned, connect to default val
instance->input_ports[i] = default_values.size() | VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT;
default_values.push_back(node->get_default_input_value(i));
@@ -2402,7 +2299,6 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
}
ScriptLanguage *VisualScriptInstance::get_language() {
-
return VisualScriptLanguage::singleton;
}
@@ -2410,7 +2306,6 @@ VisualScriptInstance::VisualScriptInstance() {
}
VisualScriptInstance::~VisualScriptInstance() {
-
{
MutexLock lock(VisualScriptLanguage::singleton->lock);
@@ -2427,7 +2322,6 @@ VisualScriptInstance::~VisualScriptInstance() {
/////////////////////
Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
ERR_FAIL_COND_V(function == StringName(), Variant());
#ifdef DEBUG_ENABLED
@@ -2448,7 +2342,6 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int
} else if (p_argcount == 1) {
//noooneee, reserved for me, me and only me.
} else {
-
for (int i = 0; i < p_argcount - 1; i++) {
args.push_back(*p_args[i]);
}
@@ -2475,7 +2368,6 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int
}
void VisualScriptFunctionState::connect_to_signal(Object *p_obj, const String &p_signal, Array p_binds) {
-
Vector<Variant> binds;
for (int i = 0; i < p_binds.size(); i++) {
binds.push_back(p_binds[i]);
@@ -2485,12 +2377,10 @@ void VisualScriptFunctionState::connect_to_signal(Object *p_obj, const String &p
}
bool VisualScriptFunctionState::is_valid() const {
-
return function != StringName();
}
Variant VisualScriptFunctionState::resume(Array p_args) {
-
ERR_FAIL_COND_V(function == StringName(), Variant());
#ifdef DEBUG_ENABLED
@@ -2512,7 +2402,6 @@ Variant VisualScriptFunctionState::resume(Array p_args) {
}
void VisualScriptFunctionState::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("connect_to_signal", "obj", "signals", "args"), &VisualScriptFunctionState::connect_to_signal);
ClassDB::bind_method(D_METHOD("resume", "args"), &VisualScriptFunctionState::resume, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("is_valid"), &VisualScriptFunctionState::is_valid);
@@ -2523,7 +2412,6 @@ VisualScriptFunctionState::VisualScriptFunctionState() {
}
VisualScriptFunctionState::~VisualScriptFunctionState() {
-
if (function != StringName()) {
Variant *s = ((Variant *)stack.ptr());
for (int i = 0; i < variant_stack_size; i++) {
@@ -2535,37 +2423,39 @@ VisualScriptFunctionState::~VisualScriptFunctionState() {
///////////////////////////////////////////////
String VisualScriptLanguage::get_name() const {
-
return "VisualScript";
}
/* LANGUAGE FUNCTIONS */
void VisualScriptLanguage::init() {
}
-String VisualScriptLanguage::get_type() const {
+String VisualScriptLanguage::get_type() const {
return "VisualScript";
}
-String VisualScriptLanguage::get_extension() const {
+String VisualScriptLanguage::get_extension() const {
return "vs";
}
-Error VisualScriptLanguage::execute_file(const String &p_path) {
+Error VisualScriptLanguage::execute_file(const String &p_path) {
return OK;
}
+
void VisualScriptLanguage::finish() {
}
/* EDITOR FUNCTIONS */
void VisualScriptLanguage::get_reserved_words(List<String> *p_words) const {
}
+
void VisualScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
}
+
void VisualScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
}
-Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
+Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
Ref<VisualScript> script;
script.instance();
script->set_instance_base_type(p_base_class_name);
@@ -2573,7 +2463,6 @@ Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const
}
bool VisualScriptLanguage::is_using_templates() {
-
return true;
}
@@ -2583,32 +2472,32 @@ void VisualScriptLanguage::make_template(const String &p_class_name, const Strin
}
bool VisualScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
-
return false;
}
-Script *VisualScriptLanguage::create_script() const {
+Script *VisualScriptLanguage::create_script() const {
return memnew(VisualScript);
}
-bool VisualScriptLanguage::has_named_classes() const {
+bool VisualScriptLanguage::has_named_classes() const {
return false;
}
-bool VisualScriptLanguage::supports_builtin_mode() const {
+bool VisualScriptLanguage::supports_builtin_mode() const {
return true;
}
-int VisualScriptLanguage::find_function(const String &p_function, const String &p_code) const {
+int VisualScriptLanguage::find_function(const String &p_function, const String &p_code) const {
return -1;
}
-String VisualScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
+String VisualScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
return String();
}
void VisualScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
}
+
void VisualScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
}
@@ -2618,7 +2507,6 @@ bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, c
//break because of parse error
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
-
_debug_parse_err_node = p_node;
_debug_parse_err_file = p_file;
_debug_error = p_error;
@@ -2630,9 +2518,7 @@ bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, c
}
bool VisualScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) {
-
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
-
_debug_parse_err_node = -1;
_debug_parse_err_file = "";
_debug_error = p_error;
@@ -2644,21 +2530,21 @@ bool VisualScriptLanguage::debug_break(const String &p_error, bool p_allow_conti
}
String VisualScriptLanguage::debug_get_error() const {
-
return _debug_error;
}
int VisualScriptLanguage::debug_get_stack_level_count() const {
-
- if (_debug_parse_err_node >= 0)
+ if (_debug_parse_err_node >= 0) {
return 1;
+ }
return _debug_call_stack_pos;
}
-int VisualScriptLanguage::debug_get_stack_level_line(int p_level) const {
- if (_debug_parse_err_node >= 0)
+int VisualScriptLanguage::debug_get_stack_level_line(int p_level) const {
+ if (_debug_parse_err_node >= 0) {
return _debug_parse_err_node;
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, -1);
@@ -2666,28 +2552,31 @@ int VisualScriptLanguage::debug_get_stack_level_line(int p_level) const {
return *(_call_stack[l].current_id);
}
-String VisualScriptLanguage::debug_get_stack_level_function(int p_level) const {
- if (_debug_parse_err_node >= 0)
+String VisualScriptLanguage::debug_get_stack_level_function(int p_level) const {
+ if (_debug_parse_err_node >= 0) {
return "";
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, "");
int l = _debug_call_stack_pos - p_level - 1;
return *_call_stack[l].function;
}
-String VisualScriptLanguage::debug_get_stack_level_source(int p_level) const {
- if (_debug_parse_err_node >= 0)
+String VisualScriptLanguage::debug_get_stack_level_source(int p_level) const {
+ if (_debug_parse_err_node >= 0) {
return _debug_parse_err_file;
+ }
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, "");
int l = _debug_call_stack_pos - p_level - 1;
return _call_stack[l].instance->get_script_ptr()->get_path();
}
-void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_debug_parse_err_node >= 0)
+void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+ if (_debug_parse_err_node >= 0) {
return;
+ }
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
@@ -2724,7 +2613,6 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String
}
for (int i = 0; i < node->output_port_count; i++) {
-
String name = node->get_base_node()->get_output_value_port_info(i).name;
if (name == String()) {
name = "out_" + itos(i);
@@ -2759,17 +2647,19 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String
}
*/
}
-void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
- if (_debug_parse_err_node >= 0)
+void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
+ if (_debug_parse_err_node >= 0) {
return;
+ }
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
Ref<VisualScript> vs = _call_stack[l].instance->get_script();
- if (vs.is_null())
+ if (vs.is_null()) {
return;
+ }
List<StringName> vars;
vs->get_variable_list(&vars);
@@ -2783,48 +2673,48 @@ void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<Strin
}
void VisualScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
-
//no globals are really reachable in gdscript
}
-String VisualScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
+String VisualScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
return "";
}
void VisualScriptLanguage::reload_all_scripts() {
}
+
void VisualScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
}
+
/* LOADER FUNCTIONS */
void VisualScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("vs");
}
+
void VisualScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
}
+
void VisualScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
}
void VisualScriptLanguage::profiling_start() {
}
+
void VisualScriptLanguage::profiling_stop() {
}
int VisualScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
-
return 0;
}
int VisualScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
-
return 0;
}
VisualScriptLanguage *VisualScriptLanguage::singleton = nullptr;
void VisualScriptLanguage::add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func) {
-
ERR_FAIL_COND(register_funcs.has(p_name));
register_funcs[p_name] = p_func;
}
@@ -2835,21 +2725,18 @@ void VisualScriptLanguage::remove_register_func(const String &p_name) {
}
Ref<VisualScriptNode> VisualScriptLanguage::create_node_from_name(const String &p_name) {
-
ERR_FAIL_COND_V(!register_funcs.has(p_name), Ref<VisualScriptNode>());
return register_funcs[p_name](p_name);
}
void VisualScriptLanguage::get_registered_node_names(List<String> *r_names) {
-
for (Map<String, VisualScriptNodeRegisterFunc>::Element *E = register_funcs.front(); E; E = E->next()) {
r_names->push_back(E->key());
}
}
VisualScriptLanguage::VisualScriptLanguage() {
-
notification = "_notification";
_step = "_step";
_subcall = "_subcall";
@@ -2873,7 +2760,6 @@ VisualScriptLanguage::VisualScriptLanguage() {
}
VisualScriptLanguage::~VisualScriptLanguage() {
-
if (_call_stack) {
memdelete_arr(_call_stack);
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index c154e56703..d54b1faf42 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -89,7 +89,6 @@ public:
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0;
struct TypeGuess {
-
Variant::Type type;
StringName gdclass;
Ref<Script> script;
@@ -166,16 +165,13 @@ public:
};
class VisualScript : public Script {
-
GDCLASS(VisualScript, Script);
RES_BASE_EXTENSION("vs");
public:
struct SequenceConnection {
-
union {
-
struct {
uint64_t from_node : 24;
uint64_t from_output : 16;
@@ -185,15 +181,12 @@ public:
};
bool operator<(const SequenceConnection &p_connection) const {
-
return id < p_connection.id;
}
};
struct DataConnection {
-
union {
-
struct {
uint64_t from_node : 24;
uint64_t from_port : 8;
@@ -204,7 +197,6 @@ public:
};
bool operator<(const DataConnection &p_connection) const {
-
return id < p_connection.id;
}
};
@@ -431,20 +423,20 @@ public:
String to_string(bool *r_valid);
bool set_variable(const StringName &p_variable, const Variant &p_value) {
-
Map<StringName, Variant>::Element *E = variables.find(p_variable);
- if (!E)
+ if (!E) {
return false;
+ }
E->get() = p_value;
return true;
}
bool get_variable(const StringName &p_variable, Variant *r_variable) const {
-
const Map<StringName, Variant>::Element *E = variables.find(p_variable);
- if (!E)
+ if (!E) {
return false;
+ }
*r_variable = E->get();
return true;
@@ -476,7 +468,6 @@ public:
};
class VisualScriptFunctionState : public Reference {
-
GDCLASS(VisualScriptFunctionState, Reference);
friend class VisualScriptInstance;
@@ -507,11 +498,9 @@ public:
typedef Ref<VisualScriptNode> (*VisualScriptNodeRegisterFunc)(const String &p_type);
class VisualScriptLanguage : public ScriptLanguage {
-
Map<String, VisualScriptNodeRegisterFunc> register_funcs;
struct CallLevel {
-
Variant *stack;
Variant **work_mem;
const StringName *function;
@@ -540,12 +529,13 @@ public:
bool debug_break_parse(const String &p_file, int p_node, const String &p_error);
_FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) {
-
- if (Thread::get_main_id() != Thread::get_caller_id())
+ if (Thread::get_main_id() != Thread::get_caller_id()) {
return; //no support for other threads than main for now
+ }
- if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0)
+ if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() + 1);
+ }
if (_debug_call_stack_pos >= _debug_max_call_stack) {
//stack overflow
@@ -563,15 +553,15 @@ public:
}
_FORCE_INLINE_ void exit_function() {
-
- if (Thread::get_main_id() != Thread::get_caller_id())
+ if (Thread::get_main_id() != Thread::get_caller_id()) {
return; //no support for other threads than main for now
+ }
- if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0)
+ if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() - 1);
+ }
if (_debug_call_stack_pos == 0) {
-
_debug_error = "Stack Underflow (Engine Bug)";
EngineDebugger::get_script_debugger()->debug(this);
return;
@@ -645,7 +635,6 @@ public:
//aid for registering
template <class T>
static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
-
Ref<T> node;
node.instance();
return node;
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index bb291b1cb6..a0dcd76d10 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -110,30 +110,26 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
};
VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::find_function(const String &p_string) {
-
for (int i = 0; i < FUNC_MAX; i++) {
- if (p_string == func_name[i])
+ if (p_string == func_name[i]) {
return BuiltinFunc(i);
+ }
}
return FUNC_MAX;
}
String VisualScriptBuiltinFunc::get_func_name(BuiltinFunc p_func) {
-
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, String());
return func_name[p_func];
}
int VisualScriptBuiltinFunc::get_output_sequence_port_count() const {
-
return has_input_sequence_port() ? 1 : 0;
}
bool VisualScriptBuiltinFunc::has_input_sequence_port() const {
-
switch (func) {
-
case MATH_RANDOMIZE:
case TEXT_PRINT:
case TEXT_PRINTERR:
@@ -145,9 +141,7 @@ bool VisualScriptBuiltinFunc::has_input_sequence_port() const {
}
int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
-
switch (p_func) {
-
case MATH_RANDOMIZE:
case MATH_RAND:
case MATH_RANDF:
@@ -228,11 +222,10 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
}
int VisualScriptBuiltinFunc::get_input_value_port_count() const {
-
return get_func_argument_count(func);
}
-int VisualScriptBuiltinFunc::get_output_value_port_count() const {
+int VisualScriptBuiltinFunc::get_output_value_port_count() const {
switch (func) {
case MATH_RANDOMIZE:
case TEXT_PRINT:
@@ -250,14 +243,11 @@ int VisualScriptBuiltinFunc::get_output_value_port_count() const {
}
String VisualScriptBuiltinFunc::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const {
-
switch (func) {
-
case MATH_SIN:
case MATH_COS:
case MATH_TAN:
@@ -280,96 +270,106 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::FLOAT, "s");
} break;
case MATH_ATAN2: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "y");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "x");
+ }
} break;
case MATH_FMOD:
case MATH_FPOSMOD:
case LOGIC_MAX:
case LOGIC_MIN: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "a");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "b");
+ }
} break;
case MATH_POSMOD: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::INT, "a");
- else
+ } else {
return PropertyInfo(Variant::INT, "b");
+ }
} break;
case MATH_POW: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "base");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "exp");
+ }
} break;
case MATH_EASE: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "s");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "curve");
+ }
} break;
case MATH_STEP_DECIMALS: {
return PropertyInfo(Variant::FLOAT, "step");
} break;
case MATH_STEPIFY: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "s");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "steps");
+ }
} break;
case MATH_LERP:
case MATH_LERP_ANGLE:
case MATH_INVERSE_LERP:
case MATH_SMOOTHSTEP: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "from");
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
return PropertyInfo(Variant::FLOAT, "to");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "weight");
+ }
} break;
case MATH_RANGE_LERP: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "value");
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
return PropertyInfo(Variant::FLOAT, "istart");
- else if (p_idx == 2)
+ } else if (p_idx == 2) {
return PropertyInfo(Variant::FLOAT, "istop");
- else if (p_idx == 3)
+ } else if (p_idx == 3) {
return PropertyInfo(Variant::FLOAT, "ostart");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "ostop");
+ }
} break;
case MATH_MOVE_TOWARD: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "from");
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
return PropertyInfo(Variant::FLOAT, "to");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "delta");
+ }
} break;
case MATH_DECTIME: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "value");
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
return PropertyInfo(Variant::FLOAT, "amount");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "step");
+ }
} break;
case MATH_RANDOMIZE:
case MATH_RAND:
case MATH_RANDF: {
-
} break;
case MATH_RANDOM: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "from");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "to");
+ }
} break;
case MATH_SEED:
case MATH_RANDSEED: {
@@ -388,33 +388,37 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::FLOAT, "db");
} break;
case MATH_POLAR2CARTESIAN: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "r");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "th");
+ }
} break;
case MATH_CARTESIAN2POLAR: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "x");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "y");
+ }
} break;
case MATH_WRAP: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::INT, "value");
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
return PropertyInfo(Variant::INT, "min");
- else
+ } else {
return PropertyInfo(Variant::INT, "max");
+ }
} break;
case MATH_WRAPF:
case LOGIC_CLAMP: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::FLOAT, "value");
- else if (p_idx == 1)
+ } else if (p_idx == 1) {
return PropertyInfo(Variant::FLOAT, "min");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "max");
+ }
} break;
case LOGIC_NEAREST_PO2: {
return PropertyInfo(Variant::INT, "value");
@@ -423,16 +427,18 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::OBJECT, "source");
} break;
case FUNC_FUNCREF: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::OBJECT, "instance");
- else
+ } else {
return PropertyInfo(Variant::STRING, "funcname");
+ }
} break;
case TYPE_CONVERT: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::NIL, "what");
- else
+ } else {
return PropertyInfo(Variant::STRING, "type");
+ }
} break;
case TYPE_OF: {
return PropertyInfo(Variant::NIL, "what");
@@ -453,29 +459,30 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::NIL, "value");
} break;
case STR_TO_VAR: {
-
return PropertyInfo(Variant::STRING, "string");
} break;
case VAR_TO_STR:
case VAR_TO_BYTES: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::NIL, "var");
- else
+ } else {
return PropertyInfo(Variant::BOOL, "full_objects");
+ }
} break;
case BYTES_TO_VAR: {
-
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytes");
- else
+ } else {
return PropertyInfo(Variant::BOOL, "allow_objects");
+ }
} break;
case COLORN: {
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::STRING, "name");
- else
+ } else {
return PropertyInfo(Variant::FLOAT, "alpha");
+ }
} break;
case FUNC_MAX: {
}
@@ -485,10 +492,8 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) const {
-
Variant::Type t = Variant::NIL;
switch (func) {
-
case MATH_SIN:
case MATH_COS:
case MATH_TAN:
@@ -545,10 +550,8 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
} break;
case MATH_RANDOMIZE: {
-
} break;
case MATH_RAND: {
-
t = Variant::INT;
} break;
case MATH_RANDF:
@@ -556,14 +559,13 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
t = Variant::FLOAT;
} break;
case MATH_SEED: {
-
} break;
case MATH_RANDSEED: {
-
- if (p_idx == 0)
+ if (p_idx == 0) {
return PropertyInfo(Variant::INT, "rnd");
- else
+ } else {
return PropertyInfo(Variant::INT, "seed");
+ }
} break;
case MATH_DEG2RAD:
case MATH_RAD2DEG:
@@ -582,24 +584,20 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case LOGIC_MAX:
case LOGIC_MIN:
case LOGIC_CLAMP: {
-
} break;
case LOGIC_NEAREST_PO2: {
t = Variant::NIL;
} break;
case OBJ_WEAKREF: {
-
t = Variant::OBJECT;
} break;
case FUNC_FUNCREF: {
-
t = Variant::OBJECT;
} break;
case TYPE_CONVERT: {
-
} break;
case TEXT_ORD:
case TYPE_OF: {
@@ -607,41 +605,37 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
} break;
case TYPE_EXISTS: {
-
t = Variant::BOOL;
} break;
case TEXT_CHAR:
case TEXT_STR: {
-
t = Variant::STRING;
} break;
case TEXT_PRINT: {
-
} break;
case TEXT_PRINTERR: {
-
} break;
case TEXT_PRINTRAW: {
-
} break;
case VAR_TO_STR: {
t = Variant::STRING;
} break;
case STR_TO_VAR: {
-
} break;
case VAR_TO_BYTES: {
- if (p_idx == 0)
+ if (p_idx == 0) {
t = Variant::PACKED_BYTE_ARRAY;
- else
+ } else {
t = Variant::BOOL;
+ }
} break;
case BYTES_TO_VAR: {
- if (p_idx == 1)
+ if (p_idx == 1) {
t = Variant::BOOL;
+ }
} break;
case COLORN: {
t = Variant::COLOR;
@@ -658,15 +652,14 @@ String VisualScriptBuiltinFunc::get_caption() const {
return "BuiltinFunc";
}
+
*/
String VisualScriptBuiltinFunc::get_caption() const {
-
return func_name[func];
}
void VisualScriptBuiltinFunc::set_func(BuiltinFunc p_which) {
-
ERR_FAIL_INDEX(p_which, FUNC_MAX);
func = p_which;
_change_notify();
@@ -686,197 +679,159 @@ VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::get_func() {
}
void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Callable::CallError &r_error, String &r_error_str) {
-
switch (p_func) {
case VisualScriptBuiltinFunc::MATH_SIN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::sin((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_COS: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::cos((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_TAN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::tan((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_SINH: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::sinh((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_COSH: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::cosh((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_TANH: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::tanh((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ASIN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::asin((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ACOS: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::acos((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ATAN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::atan((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ATAN2: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::atan2((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_SQRT: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::sqrt((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_FMOD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::fmod((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_FPOSMOD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::fposmod((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_POSMOD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::posmod((int)*p_inputs[0], (int)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_FLOOR: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::floor((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_CEIL: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::ceil((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ROUND: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::round((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ABS: {
-
if (p_inputs[0]->get_type() == Variant::INT) {
-
int64_t i = *p_inputs[0];
*r_return = ABS(i);
} else if (p_inputs[0]->get_type() == Variant::FLOAT) {
-
real_t r = *p_inputs[0];
*r_return = Math::abs(r);
} else {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::FLOAT;
}
} break;
case VisualScriptBuiltinFunc::MATH_SIGN: {
-
if (p_inputs[0]->get_type() == Variant::INT) {
-
int64_t i = *p_inputs[0];
*r_return = i < 0 ? -1 : (i > 0 ? +1 : 0);
} else if (p_inputs[0]->get_type() == Variant::FLOAT) {
-
real_t r = *p_inputs[0];
*r_return = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
} else {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::FLOAT;
}
} break;
case VisualScriptBuiltinFunc::MATH_POW: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::pow((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_LOG: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::log((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_EXP: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::exp((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ISNAN: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::is_nan((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ISINF: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::is_inf((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_EASE: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::ease((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_STEP_DECIMALS: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::step_decimals((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_STEPIFY: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::stepify((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_LERP: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::lerp((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_LERP_ANGLE: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::lerp_angle((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_INVERSE_LERP: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::inverse_lerp((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_RANGE_LERP: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
@@ -891,14 +846,12 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
*r_return = Math::smoothstep((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_MOVE_TOWARD: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
*r_return = Math::move_toward((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_DECTIME: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
@@ -915,20 +868,17 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
*r_return = Math::randf();
} break;
case VisualScriptBuiltinFunc::MATH_RANDOM: {
-
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
*r_return = Math::random((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_SEED: {
-
VALIDATE_ARG_NUM(0);
uint64_t seed = *p_inputs[0];
Math::seed(seed);
} break;
case VisualScriptBuiltinFunc::MATH_RANDSEED: {
-
VALIDATE_ARG_NUM(0);
uint64_t seed = *p_inputs[0];
int ret = Math::rand_from_seed(&seed);
@@ -939,22 +889,18 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::MATH_DEG2RAD: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::deg2rad((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_RAD2DEG: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::rad2deg((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_LINEAR2DB: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::linear2db((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_DB2LINEAR: {
-
VALIDATE_ARG_NUM(0);
*r_return = Math::db2linear((double)*p_inputs[0]);
} break;
@@ -985,9 +931,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
*r_return = Math::wrapf((double)*p_inputs[0], (double)*p_inputs[1], (double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::LOGIC_MAX: {
-
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT) {
-
int64_t a = *p_inputs[0];
int64_t b = *p_inputs[1];
*r_return = MAX(a, b);
@@ -1003,9 +947,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::LOGIC_MIN: {
-
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT) {
-
int64_t a = *p_inputs[0];
int64_t b = *p_inputs[1];
*r_return = MIN(a, b);
@@ -1020,9 +962,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
}
} break;
case VisualScriptBuiltinFunc::LOGIC_CLAMP: {
-
if (p_inputs[0]->get_type() == Variant::INT && p_inputs[1]->get_type() == Variant::INT && p_inputs[2]->get_type() == Variant::INT) {
-
int64_t a = *p_inputs[0];
int64_t b = *p_inputs[1];
int64_t c = *p_inputs[2];
@@ -1040,15 +980,12 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
}
} break;
case VisualScriptBuiltinFunc::LOGIC_NEAREST_PO2: {
-
VALIDATE_ARG_NUM(0);
int64_t num = *p_inputs[0];
*r_return = next_power_of_2(num);
} break;
case VisualScriptBuiltinFunc::OBJ_WEAKREF: {
-
if (p_inputs[0]->get_type() != Variant::OBJECT) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1057,10 +994,8 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
}
if (p_inputs[0]->is_ref()) {
-
REF r = *p_inputs[0];
if (!r.is_valid()) {
-
return;
}
@@ -1070,7 +1005,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} else {
Object *obj = *p_inputs[0];
if (!obj) {
-
return;
}
Ref<WeakRef> wref = memnew(WeakRef);
@@ -1080,9 +1014,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::FUNC_FUNCREF: {
-
if (p_inputs[0]->get_type() != Variant::OBJECT) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1090,7 +1022,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
return;
}
if (p_inputs[1]->get_type() != Variant::STRING && p_inputs[1]->get_type() != Variant::NODE_PATH) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
@@ -1107,11 +1038,9 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::TYPE_CONVERT: {
-
VALIDATE_ARG_NUM(1);
int type = *p_inputs[1];
if (type < 0 || type >= Variant::VARIANT_MAX) {
-
r_error_str = RTR("Invalid type argument to convert(), use TYPE_* constants.");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -1119,29 +1048,24 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
return;
} else {
-
*r_return = Variant::construct(Variant::Type(type), p_inputs, 1, r_error);
}
} break;
case VisualScriptBuiltinFunc::TYPE_OF: {
-
*r_return = p_inputs[0]->get_type();
} break;
case VisualScriptBuiltinFunc::TYPE_EXISTS: {
-
*r_return = ClassDB::class_exists(*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::TEXT_CHAR: {
-
CharType result[2] = { *p_inputs[0], 0 };
*r_return = String(result);
} break;
case VisualScriptBuiltinFunc::TEXT_ORD: {
-
if (p_inputs[0]->get_type() != Variant::STRING) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -1165,39 +1089,33 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::TEXT_STR: {
-
String str = *p_inputs[0];
*r_return = str;
} break;
case VisualScriptBuiltinFunc::TEXT_PRINT: {
-
String str = *p_inputs[0];
print_line(str);
} break;
case VisualScriptBuiltinFunc::TEXT_PRINTERR: {
-
String str = *p_inputs[0];
print_error(str);
} break;
case VisualScriptBuiltinFunc::TEXT_PRINTRAW: {
-
String str = *p_inputs[0];
OS::get_singleton()->print("%s", str.utf8().get_data());
} break;
case VisualScriptBuiltinFunc::VAR_TO_STR: {
-
String vars;
VariantWriter::write_to_string(*p_inputs[0], vars);
*r_return = vars;
} break;
case VisualScriptBuiltinFunc::STR_TO_VAR: {
-
if (p_inputs[0]->get_type() != Variant::STRING) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -1223,7 +1141,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::VAR_TO_BYTES: {
-
if (p_inputs[1]->get_type() != Variant::BOOL) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
@@ -1250,7 +1167,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
*r_return = barr;
} break;
case VisualScriptBuiltinFunc::BYTES_TO_VAR: {
-
if (p_inputs[0]->get_type() != Variant::PACKED_BYTE_ARRAY) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -1283,7 +1199,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
} break;
case VisualScriptBuiltinFunc::COLORN: {
-
VALIDATE_ARG_NUM(1);
Color color = Color::named(*p_inputs[0]);
@@ -1309,14 +1224,12 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
VisualScriptBuiltinFunc::exec_func(func, p_inputs, p_outputs[0], r_error, r_error_str);
return 0;
}
};
VisualScriptNodeInstance *VisualScriptBuiltinFunc::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceBuiltinFunc *instance = memnew(VisualScriptNodeInstanceBuiltinFunc);
instance->node = this;
instance->instance = p_instance;
@@ -1325,16 +1238,15 @@ VisualScriptNodeInstance *VisualScriptBuiltinFunc::instance(VisualScriptInstance
}
void VisualScriptBuiltinFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_func", "which"), &VisualScriptBuiltinFunc::set_func);
ClassDB::bind_method(D_METHOD("get_func"), &VisualScriptBuiltinFunc::get_func);
String cc;
for (int i = 0; i < FUNC_MAX; i++) {
-
- if (i > 0)
+ if (i > 0) {
cc += ",";
+ }
cc += func_name[i];
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, cc), "set_func", "get_func");
@@ -1411,24 +1323,20 @@ void VisualScriptBuiltinFunc::_bind_methods() {
}
VisualScriptBuiltinFunc::VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func) {
-
this->func = func;
}
VisualScriptBuiltinFunc::VisualScriptBuiltinFunc() {
-
func = MATH_SIN;
}
template <VisualScriptBuiltinFunc::BuiltinFunc func>
static Ref<VisualScriptNode> create_builtin_func_node(const String &p_name) {
-
Ref<VisualScriptBuiltinFunc> node = memnew(VisualScriptBuiltinFunc(func));
return node;
}
void register_visual_script_builtin_func_node() {
-
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sin", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIN>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/cos", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COS>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/tan", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TAN>);
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index d950f858d4..1b186353f1 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -34,7 +34,6 @@
#include "visual_script.h"
class VisualScriptBuiltinFunc : public VisualScriptNode {
-
GDCLASS(VisualScriptBuiltinFunc, VisualScriptNode);
public:
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 3649486724..b7ca3c882b 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -46,7 +46,6 @@
#ifdef TOOLS_ENABLED
class VisualScriptEditorSignalEdit : public Object {
-
GDCLASS(VisualScriptEditorSignalEdit, Object);
StringName sig;
@@ -62,22 +61,21 @@ protected:
}
void _sig_changed() {
-
_change_notify();
emit_signal("changed");
}
bool _set(const StringName &p_name, const Variant &p_value) {
-
- if (sig == StringName())
+ if (sig == StringName()) {
return false;
+ }
if (p_name == "argument_count") {
-
int new_argc = p_value;
int argc = script->custom_signal_get_argument_count(sig);
- if (argc == new_argc)
+ if (argc == new_argc) {
return true;
+ }
undo_redo->create_action(TTR("Change Signal Arguments"));
@@ -87,9 +85,7 @@ protected:
undo_redo->add_undo_method(script.ptr(), "custom_signal_add_argument", sig, script->custom_signal_get_argument_name(sig, i), script->custom_signal_get_argument_type(sig, i), -1);
}
} else if (new_argc > argc) {
-
for (int i = argc; i < new_argc; i++) {
-
undo_redo->add_do_method(script.ptr(), "custom_signal_add_argument", sig, Variant::NIL, "arg" + itos(i + 1), -1);
undo_redo->add_undo_method(script.ptr(), "custom_signal_remove_argument", sig, argc);
}
@@ -107,7 +103,6 @@ protected:
ERR_FAIL_INDEX_V(idx, script->custom_signal_get_argument_count(sig), false);
String what = String(p_name).get_slice("/", 2);
if (what == "type") {
-
int old_type = script->custom_signal_get_argument_type(sig, idx);
int new_type = p_value;
undo_redo->create_action(TTR("Change Argument Type"));
@@ -119,7 +114,6 @@ protected:
}
if (what == "name") {
-
String old_name = script->custom_signal_get_argument_name(sig, idx);
String new_name = p_value;
undo_redo->create_action(TTR("Change Argument name"));
@@ -134,9 +128,9 @@ protected:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
- if (sig == StringName())
+ if (sig == StringName()) {
return false;
+ }
if (p_name == "argument_count") {
r_ret = script->custom_signal_get_argument_count(sig);
@@ -159,9 +153,9 @@ protected:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
- if (sig == StringName())
+ if (sig == StringName()) {
return;
+ }
p_list->push_back(PropertyInfo(Variant::INT, "argument_count", PROPERTY_HINT_RANGE, "0,256"));
String argt = "Variant";
@@ -177,7 +171,6 @@ protected:
public:
void edit(const StringName &p_sig) {
-
sig = p_sig;
_change_notify();
}
@@ -186,7 +179,6 @@ public:
};
class VisualScriptEditorVariableEdit : public Object {
-
GDCLASS(VisualScriptEditorVariableEdit, Object);
StringName var;
@@ -203,20 +195,18 @@ protected:
}
void _var_changed() {
-
_change_notify();
emit_signal("changed");
}
void _var_value_changed() {
-
_change_notify("value"); //so the whole tree is not redrawn, makes editing smoother in general
emit_signal("changed");
}
bool _set(const StringName &p_name, const Variant &p_value) {
-
- if (var == StringName())
+ if (var == StringName()) {
return false;
+ }
if (String(p_name) == "value") {
undo_redo->create_action(TTR("Set Variable Default Value"));
@@ -232,7 +222,6 @@ protected:
Dictionary d = script->call("get_variable_info", var);
if (String(p_name) == "type") {
-
Dictionary dc = d.duplicate();
dc["type"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
@@ -245,7 +234,6 @@ protected:
}
if (String(p_name) == "hint") {
-
Dictionary dc = d.duplicate();
dc["hint"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
@@ -258,7 +246,6 @@ protected:
}
if (String(p_name) == "hint_string") {
-
Dictionary dc = d.duplicate();
dc["hint_string"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
@@ -280,9 +267,9 @@ protected:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
- if (var == StringName())
+ if (var == StringName()) {
return false;
+ }
if (String(p_name) == "value") {
r_ret = script->get_variable_default_value(var);
@@ -312,9 +299,9 @@ protected:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
- if (var == StringName())
+ if (var == StringName()) {
return;
+ }
String argt = "Variant";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
@@ -330,7 +317,6 @@ protected:
public:
void edit(const StringName &p_var) {
-
var = p_var;
_change_notify();
}
@@ -340,7 +326,7 @@ public:
static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
Color color;
- if (dark_theme)
+ if (dark_theme) {
switch (p_type) {
case Variant::NIL:
color = Color(0.41, 0.93, 0.74);
@@ -446,7 +432,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
default:
color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.7, 0.7);
}
- else
+ } else {
switch (p_type) {
case Variant::NIL:
color = Color(0.15, 0.89, 0.63);
@@ -552,12 +538,12 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
default:
color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.3, 0.3);
}
+ }
return color;
}
void VisualScriptEditor::_update_graph_connections() {
-
graph->clear_connections();
List<StringName> funcs;
@@ -569,12 +555,10 @@ void VisualScriptEditor::_update_graph_connections() {
}
for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) {
-
List<VisualScript::SequenceConnection> sequence_conns;
script->get_sequence_connection_list(F->get(), &sequence_conns);
for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
-
graph->connect_node(itos(E->get().from_node), E->get().from_output, itos(E->get().to_node), 0);
}
@@ -582,7 +566,6 @@ void VisualScriptEditor::_update_graph_connections() {
script->get_data_connection_list(F->get(), &data_conns);
for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) {
-
VisualScript::DataConnection dc = E->get();
Ref<VisualScriptNode> from_node = script->get_node(F->get(), E->get().from_node);
@@ -600,9 +583,9 @@ void VisualScriptEditor::_update_graph_connections() {
}
void VisualScriptEditor::_update_graph(int p_only_id) {
-
- if (updating_graph)
+ if (updating_graph) {
return;
+ }
updating_graph = true;
@@ -610,13 +593,12 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (p_only_id >= 0) {
if (graph->has_node(itos(p_only_id))) {
Node *gid = graph->get_node(itos(p_only_id));
- if (gid)
+ if (gid) {
memdelete(gid);
+ }
}
} else {
-
for (int i = 0; i < graph->get_child_count(); i++) {
-
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
@@ -681,9 +663,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
StringName editor_icons = "EditorIcons";
for (List<int>::Element *E = ids.front(); E; E = E->next()) {
-
- if (p_only_id >= 0 && p_only_id != E->get())
+ if (p_only_id >= 0 && p_only_id != E->get()) {
continue;
+ }
Ref<VisualScriptNode> node = script->get_node(F->get(), E->get());
Vector2 pos = script->get_node_position(F->get(), E->get());
@@ -721,8 +703,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E->get()), CONNECT_DEFERRED);
}
if (nd_list->is_output_port_editable()) {
- if (nd_list->is_input_port_editable())
+ if (nd_list->is_input_port_editable()) {
hbnc->add_spacer();
+ }
has_gnode_text = true;
Button *btn = memnew(Button);
btn->set_text(TTR("Add Output Port"));
@@ -758,8 +741,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (node_styles.has(node->get_category())) {
Ref<StyleBoxFlat> sbf = node_styles[node->get_category()];
- if (gnode->is_comment())
+ if (gnode->is_comment()) {
sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode");
+ }
Color c = sbf->get_border_color();
Color ic = c;
@@ -807,12 +791,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
int mixed_seq_ports = 0;
if (!single_seq_output) {
-
if (node->has_mixed_input_and_sequence_ports()) {
mixed_seq_ports = node->get_output_sequence_port_count();
} else {
for (int i = 0; i < node->get_output_sequence_port_count(); i++) {
-
Label *text2 = memnew(Label);
text2->set_text(node->get_output_sequence_port_text(i));
text2->set_align(Label::ALIGN_RIGHT);
@@ -824,7 +806,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
for (int i = 0; i < MAX(node->get_output_value_port_count(), MAX(mixed_seq_ports, node->get_input_value_port_count())); i++) {
-
bool left_ok = false;
Variant::Type left_type = Variant::NIL;
String left_name;
@@ -852,7 +833,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
vbc->add_child(hbc);
vbc->add_child(hbc2);
if (left_ok) {
-
Ref<Texture2D> t;
if (left_type >= 0 && left_type < Variant::VARIANT_MAX) {
t = type_icons[left_type];
@@ -897,7 +877,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
if (left_type != Variant::NIL && !script->is_input_value_port_connected(F->get(), E->get(), i)) {
-
PropertyInfo pi = node->get_input_value_port_info(i);
Button *button = memnew(Button);
Variant value = node->get_default_input_value(i);
@@ -913,7 +892,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
button->connect("draw", callable_mp(this, &VisualScriptEditor::_draw_color_over_button), varray(button, value));
} else if (left_type == Variant::OBJECT && Ref<Resource>(value).is_valid()) {
-
Ref<Resource> res = value;
Array arr;
arr.push_back(button->get_instance_id());
@@ -921,10 +899,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr);
} else if (pi.type == Variant::INT && pi.hint == PROPERTY_HINT_ENUM) {
-
button->set_text(pi.hint_string.get_slice(",", value));
} else {
-
button->set_text(value);
}
button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i));
@@ -940,7 +916,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
hbc2->add_spacer();
if (i < mixed_seq_ports) {
-
Label *text2 = memnew(Label);
text2->set_text(node->get_output_sequence_port_text(i));
text2->set_align(Label::ALIGN_RIGHT);
@@ -948,7 +923,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
if (right_ok) {
-
if (is_vslist) {
Button *rmbtn = memnew(Button);
rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
@@ -1019,12 +993,12 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, bool is_input) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
undo_redo->create_action("Change Port Type");
if (is_input) {
@@ -1038,24 +1012,27 @@ void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, b
}
void VisualScriptEditor::_update_node_size(int p_id) {
-
Node *node = graph->get_node(itos(p_id));
- if (Object::cast_to<Control>(node))
+ if (Object::cast_to<Control>(node)) {
Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); //shrink if text is smaller
+ }
}
+
void VisualScriptEditor::_port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input) {
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
String text;
- if (Object::cast_to<LineEdit>(p_name_box))
+ if (Object::cast_to<LineEdit>(p_name_box)) {
text = Object::cast_to<LineEdit>(p_name_box)->get_text();
- else
+ } else {
return;
+ }
undo_redo->create_action("Change Port Name");
if (is_input) {
@@ -1086,7 +1063,6 @@ void VisualScriptEditor::_update_members() {
List<StringName> func_names;
script->get_function_list(&func_names);
for (List<StringName>::Element *E = func_names.front(); E; E = E->next()) {
-
if (E->get() == default_func) {
continue;
}
@@ -1096,8 +1072,9 @@ void VisualScriptEditor::_update_members() {
ti->set_selectable(0, true);
ti->set_metadata(0, E->get());
ti->add_button(0, Control::get_theme_icon("Edit", "EditorIcons"), 0);
- if (selected == E->get())
+ if (selected == E->get()) {
ti->select(0);
+ }
}
TreeItem *variables = members->create_item(root);
@@ -1154,8 +1131,9 @@ void VisualScriptEditor::_update_members() {
ti->set_selectable(0, true);
ti->set_editable(0, true);
ti->set_metadata(0, E->get());
- if (selected == E->get())
+ if (selected == E->get()) {
ti->select(0);
+ }
}
TreeItem *_signals = members->create_item(root);
@@ -1172,8 +1150,9 @@ void VisualScriptEditor::_update_members() {
ti->set_selectable(0, true);
ti->set_editable(0, true);
ti->set_metadata(0, E->get());
- if (selected == E->get())
+ if (selected == E->get()) {
ti->select(0);
+ }
}
String base_type = script->get_instance_base_type();
@@ -1189,9 +1168,9 @@ void VisualScriptEditor::_update_members() {
}
void VisualScriptEditor::_member_selected() {
-
- if (updating_members)
+ if (updating_members) {
return;
+ }
TreeItem *ti = members->get_selected();
ERR_FAIL_COND(!ti);
@@ -1199,7 +1178,6 @@ void VisualScriptEditor::_member_selected() {
selected = ti->get_metadata(0);
if (ti->get_parent() == members->get_root()->get_children()) {
-
#ifdef OSX_ENABLED
bool held_ctrl = Input::get_singleton()->is_key_pressed(KEY_META);
#else
@@ -1213,9 +1191,9 @@ void VisualScriptEditor::_member_selected() {
}
void VisualScriptEditor::_member_edited() {
-
- if (updating_members)
+ if (updating_members) {
return;
+ }
TreeItem *ti = members->get_edited();
ERR_FAIL_COND(!ti);
@@ -1223,11 +1201,11 @@ void VisualScriptEditor::_member_edited() {
String name = ti->get_metadata(0);
String new_name = ti->get_text(0);
- if (name == new_name)
+ if (name == new_name) {
return;
+ }
if (!new_name.is_valid_identifier()) {
-
EditorNode::get_singleton()->show_warning(TTR("Name is not a valid identifier:") + " " + new_name);
updating_members = true;
ti->set_text(0, name);
@@ -1236,7 +1214,6 @@ void VisualScriptEditor::_member_edited() {
}
if (script->has_function(new_name) || script->has_variable(new_name) || script->has_custom_signal(new_name)) {
-
EditorNode::get_singleton()->show_warning(TTR("Name already in use by another func/var/signal:") + " " + new_name);
updating_members = true;
ti->set_text(0, name);
@@ -1247,7 +1224,6 @@ void VisualScriptEditor::_member_edited() {
TreeItem *root = members->get_root();
if (ti->get_parent() == root->get_children()) {
-
selected = new_name;
int node_id = script->get_function_node_id(name);
@@ -1271,8 +1247,9 @@ void VisualScriptEditor::_member_edited() {
script->get_node_list(E->get(), &lst);
for (List<int>::Element *F = lst.front(); F; F = F->next()) {
Ref<VisualScriptFunctionCall> fncall = script->get_node(E->get(), F->get());
- if (!fncall.is_valid())
+ if (!fncall.is_valid()) {
continue;
+ }
if (fncall->get_function() == name) {
undo_redo->add_do_method(fncall.ptr(), "set_function", new_name);
undo_redo->add_undo_method(fncall.ptr(), "set_function", name);
@@ -1292,7 +1269,6 @@ void VisualScriptEditor::_member_edited() {
}
if (ti->get_parent() == root->get_children()->get_next()) {
-
selected = new_name;
undo_redo->create_action(TTR("Rename Variable"));
undo_redo->add_do_method(script.ptr(), "rename_variable", name, new_name);
@@ -1309,7 +1285,6 @@ void VisualScriptEditor::_member_edited() {
}
if (ti->get_parent() == root->get_children()->get_next()->get_next()) {
-
selected = new_name;
undo_redo->create_action(TTR("Rename Signal"));
undo_redo->add_do_method(script.ptr(), "rename_custom_signal", name, new_name);
@@ -1346,8 +1321,9 @@ void VisualScriptEditor::_create_function() {
for (int i = 0; i < func_input_vbox->get_child_count(); i++) {
OptionButton *opbtn = Object::cast_to<OptionButton>(func_input_vbox->get_child(i)->get_child(3));
LineEdit *lne = Object::cast_to<LineEdit>(func_input_vbox->get_child(i)->get_child(1));
- if (!opbtn || !lne)
+ if (!opbtn || !lne) {
continue;
+ }
Variant::Type arg_type = Variant::Type(opbtn->get_selected());
String arg_name = lne->get_text();
func_node->add_argument(arg_type, arg_name);
@@ -1392,8 +1368,9 @@ void VisualScriptEditor::_add_func_input() {
OptionButton *type_box = memnew(OptionButton);
type_box->set_custom_minimum_size(Size2(120 * EDSCALE, 0));
- for (int i = Variant::NIL; i < Variant::VARIANT_MAX; i++)
+ for (int i = Variant::NIL; i < Variant::VARIANT_MAX; i++) {
type_box->add_item(Variant::get_type_name(Variant::Type(i)));
+ }
type_box->select(1);
hbox->add_child(type_box);
@@ -1425,13 +1402,13 @@ void VisualScriptEditor::_deselect_input_names() {
int cn = func_input_vbox->get_child_count();
for (int i = 0; i < cn; i++) {
LineEdit *lne = Object::cast_to<LineEdit>(func_input_vbox->get_child(i)->get_child(1));
- if (lne)
+ if (lne) {
lne->deselect();
+ }
}
}
void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
TreeItem *root = members->get_root();
@@ -1446,7 +1423,6 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
return;
} else if (p_button == 0) {
-
String name = _validate_name("new_function");
selected = name;
Vector2 ofs = _get_available_pos();
@@ -1514,12 +1490,12 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
}
void VisualScriptEditor::_add_input_port(int p_id) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
updating_graph = true;
@@ -1536,12 +1512,12 @@ void VisualScriptEditor::_add_input_port(int p_id) {
}
void VisualScriptEditor::_add_output_port(int p_id) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
updating_graph = true;
@@ -1558,12 +1534,12 @@ void VisualScriptEditor::_add_output_port(int p_id) {
}
void VisualScriptEditor::_remove_input_port(int p_id, int p_port) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
updating_graph = true;
@@ -1572,14 +1548,16 @@ void VisualScriptEditor::_remove_input_port(int p_id, int p_port) {
int conn_from = -1, conn_port = -1;
script->get_input_value_port_connection_source(func, p_id, p_port, &conn_from, &conn_port);
- if (conn_from != -1)
+ if (conn_from != -1) {
undo_redo->add_do_method(script.ptr(), "data_disconnect", func, conn_from, conn_port, p_id, p_port);
+ }
undo_redo->add_do_method(vsn.ptr(), "remove_input_data_port", p_port);
undo_redo->add_do_method(this, "_update_graph", p_id);
- if (conn_from != -1)
+ if (conn_from != -1) {
undo_redo->add_undo_method(script.ptr(), "data_connect", func, conn_from, conn_port, p_id, p_port);
+ }
undo_redo->add_undo_method(vsn.ptr(), "add_input_data_port", vsn->get_input_value_port_info(p_port).type, vsn->get_input_value_port_info(p_port).name, p_port);
undo_redo->add_undo_method(this, "_update_graph", p_id);
@@ -1590,12 +1568,12 @@ void VisualScriptEditor::_remove_input_port(int p_id, int p_port) {
}
void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
updating_graph = true;
@@ -1608,8 +1586,9 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
for (const List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
if (E->get().from_node == p_id && E->get().from_port == p_port) {
// push into the connections map
- if (!conn_map.has(E->get().to_node))
+ if (!conn_map.has(E->get().to_node)) {
conn_map.set(E->get().to_node, Set<int>());
+ }
conn_map[E->get().to_node].insert(E->get().to_port);
}
}
@@ -1634,12 +1613,12 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
}
void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptExpression> vse = script->get_node(func, p_id);
- if (!vse.is_valid())
+ if (!vse.is_valid()) {
return;
+ }
updating_graph = true;
@@ -1651,15 +1630,17 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id
undo_redo->commit_action();
Node *node = graph->get_node(itos(p_id));
- if (Object::cast_to<Control>(node))
+ if (Object::cast_to<Control>(node)) {
Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); //shrink if text is smaller
+ }
updating_graph = false;
}
Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const {
- if (centered)
+ if (centered) {
ofs = graph->get_scroll_ofs() + graph->get_size() * 0.5;
+ }
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -1685,8 +1666,9 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
}
}
}
- if (exists)
+ if (exists) {
continue;
+ }
break;
}
@@ -1694,12 +1676,10 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
}
String VisualScriptEditor::_validate_name(const String &p_name) const {
-
String valid = p_name;
int counter = 1;
while (true) {
-
bool exists = script->has_function(valid) || script->has_variable(valid) || script->has_custom_signal(valid);
if (exists) {
@@ -1715,7 +1695,6 @@ String VisualScriptEditor::_validate_name(const String &p_name) const {
}
void VisualScriptEditor::_on_nodes_delete() {
-
// delete all the selected nodes
List<int> to_erase;
@@ -1729,13 +1708,13 @@ void VisualScriptEditor::_on_nodes_delete() {
}
}
- if (to_erase.empty())
+ if (to_erase.empty()) {
return;
+ }
undo_redo->create_action(TTR("Remove VisualScript Nodes"));
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
-
int cr_node = F->get();
StringName func = _get_function_of_node(cr_node);
@@ -1747,7 +1726,6 @@ void VisualScriptEditor::_on_nodes_delete() {
script->get_sequence_connection_list(func, &sequence_conns);
for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
-
if (E->get().from_node == cr_node || E->get().to_node == cr_node) {
undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, E->get().from_node, E->get().from_output, E->get().to_node);
}
@@ -1757,7 +1735,6 @@ void VisualScriptEditor::_on_nodes_delete() {
script->get_data_connection_list(func, &data_conns);
for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) {
-
if (E->get().from_node == F->get() || E->get().to_node == F->get()) {
undo_redo->add_undo_method(script.ptr(), "data_connect", func, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
}
@@ -1770,7 +1747,6 @@ void VisualScriptEditor::_on_nodes_delete() {
}
void VisualScriptEditor::_on_nodes_duplicate() {
-
Set<int> to_duplicate;
List<StringName> funcs;
@@ -1785,8 +1761,9 @@ void VisualScriptEditor::_on_nodes_duplicate() {
}
}
- if (to_duplicate.empty())
+ if (to_duplicate.empty()) {
return;
+ }
undo_redo->create_action(TTR("Duplicate VisualScript Nodes"));
int idc = script->get_available_id() + 1;
@@ -1795,7 +1772,6 @@ void VisualScriptEditor::_on_nodes_duplicate() {
HashMap<int, int> remap;
for (Set<int>::Element *F = to_duplicate.front(); F; F = F->next()) {
-
// duplicate from the specific function but place it into the default func as it would lack the connections
StringName func = _get_function_of_node(F->get());
Ref<VisualScriptNode> node = script->get_node(func, F->get());
@@ -1847,10 +1823,11 @@ void VisualScriptEditor::_on_nodes_duplicate() {
}
void VisualScriptEditor::_generic_search(String p_base_type, Vector2 pos, bool node_centered) {
- if (node_centered)
+ if (node_centered) {
port_action_pos = graph->get_size() / 2.0f;
- else
+ } else {
port_action_pos = graph->get_viewport()->get_mouse_position() - graph->get_global_position();
+ }
new_connect_node_select->select_from_visual_script(p_base_type, false, false); // neither connecting nor reset text
@@ -1859,8 +1836,9 @@ void VisualScriptEditor::_generic_search(String p_base_type, Vector2 pos, bool n
pos.x = pos.x > bounds.x ? bounds.x : pos.x;
pos.y = pos.y > bounds.y ? bounds.y : pos.y;
- if (pos != Vector2())
+ if (pos != Vector2()) {
new_connect_node_select->set_position(pos);
+ }
}
void VisualScriptEditor::_input(const Ref<InputEvent> &p_event) {
@@ -1884,7 +1862,6 @@ void VisualScriptEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
}
void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
if (members->has_focus()) {
@@ -1914,21 +1891,19 @@ void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> btn = p_event;
if (btn.is_valid() && btn->is_doubleclick()) {
TreeItem *ti = members->get_selected();
- if (ti && ti->get_parent() == members->get_root()->get_children()) // to check if it's a function
+ if (ti && ti->get_parent() == members->get_root()->get_children()) { // to check if it's a function
_center_on_node(ti->get_metadata(0), script->get_function_node_id(ti->get_metadata(0)));
+ }
}
}
void VisualScriptEditor::_rename_function(const String &name, const String &new_name) {
-
if (!new_name.is_valid_identifier()) {
-
EditorNode::get_singleton()->show_warning(TTR("Name is not a valid identifier:") + " " + new_name);
return;
}
if (script->has_function(new_name) || script->has_variable(new_name) || script->has_custom_signal(new_name)) {
-
EditorNode::get_singleton()->show_warning(TTR("Name already in use by another func/var/signal:") + " " + new_name);
return;
}
@@ -1954,8 +1929,9 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_
script->get_node_list(E->get(), &lst);
for (List<int>::Element *F = lst.front(); F; F = F->next()) {
Ref<VisualScriptFunctionCall> fncall = script->get_node(E->get(), F->get());
- if (!fncall.is_valid())
+ if (!fncall.is_valid()) {
continue;
+ }
if (fncall->get_function() == name) {
undo_redo->add_do_method(fncall.ptr(), "set_function", new_name);
undo_redo->add_undo_method(fncall.ptr(), "set_function", name);
@@ -1973,9 +1949,9 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_
}
void VisualScriptEditor::_fn_name_box_input(const Ref<InputEvent> &p_event) {
-
- if (!function_name_edit->is_visible())
+ if (!function_name_edit->is_visible()) {
return;
+ }
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && key->get_keycode() == KEY_ENTER) {
@@ -1986,31 +1962,28 @@ void VisualScriptEditor::_fn_name_box_input(const Ref<InputEvent> &p_event) {
}
Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
if (p_from == members) {
-
TreeItem *it = members->get_item_at_position(p_point);
- if (!it)
+ if (!it) {
return Variant();
+ }
String type = it->get_metadata(0);
- if (type == String())
+ if (type == String()) {
return Variant();
+ }
Dictionary dd;
TreeItem *root = members->get_root();
if (it->get_parent() == root->get_children()) {
-
dd["type"] = "visual_script_function_drag";
dd["function"] = type;
} else if (it->get_parent() == root->get_children()->get_next()) {
-
dd["type"] = "visual_script_variable_drag";
dd["variable"] = type;
} else if (it->get_parent() == root->get_children()->get_next()->get_next()) {
-
dd["type"] = "visual_script_signal_drag";
dd["signal"] = type;
@@ -2027,9 +2000,7 @@ Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
}
bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
if (p_from == graph) {
-
Dictionary d = p_data;
if (d.has("type") &&
(String(d["type"]) == "visual_script_node_drag" ||
@@ -2040,9 +2011,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
String(d["type"]) == "resource" ||
String(d["type"]) == "files" ||
String(d["type"]) == "nodes")) {
-
if (String(d["type"]) == "obj_property") {
-
#ifdef OSX_ENABLED
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a Getter. Hold Shift to drop a generic signature."), find_keycode_name(KEY_META)));
#else
@@ -2051,7 +2020,6 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
if (String(d["type"]) == "nodes") {
-
#ifdef OSX_ENABLED
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a simple reference to the node."), find_keycode_name(KEY_META)));
#else
@@ -2060,7 +2028,6 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
if (String(d["type"]) == "visual_script_variable_drag") {
-
#ifdef OSX_ENABLED
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a Variable Setter."), find_keycode_name(KEY_META)));
#else
@@ -2076,26 +2043,27 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
- if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
+ if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
return nullptr;
+ }
Ref<Script> scr = p_current_node->get_script();
- if (scr.is_valid() && scr == script)
+ if (scr.is_valid() && scr == script) {
return p_current_node;
+ }
for (int i = 0; i < p_current_node->get_child_count(); i++) {
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
- if (n)
+ if (n) {
return n;
+ }
}
return nullptr;
}
void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
if (p_from != graph) {
return;
}
@@ -2130,7 +2098,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_variable_drag") {
-
#ifdef OSX_ENABLED
bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
#else
@@ -2151,7 +2118,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnodes->set_variable(d["variable"]);
vnode = vnodes;
} else {
-
Ref<VisualScriptVariableGet> vnodeg;
vnodeg.instance();
vnodeg->set_variable(d["variable"]);
@@ -2175,7 +2141,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_function_drag") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2208,7 +2173,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_signal_drag") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2238,7 +2202,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "resource") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2268,7 +2231,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "files") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2286,10 +2248,10 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->create_action(TTR("Add Preload Node"));
for (int i = 0; i < files.size(); i++) {
-
Ref<Resource> res = ResourceLoader::load(files[i]);
- if (!res.is_valid())
+ if (!res.is_valid()) {
continue;
+ }
Ref<VisualScriptPreload> prnode;
prnode.instance();
@@ -2308,7 +2270,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
for (List<int>::Element *E = new_ids.front(); E; E = E->next()) {
-
Node *node = graph->get_node(itos(E->get()));
if (node) {
graph->set_selected(node);
@@ -2318,7 +2279,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "nodes") {
-
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn) {
@@ -2350,7 +2310,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
for (int i = 0; i < nodes.size(); i++) {
-
NodePath np = nodes[i];
Node *node = get_node(np);
if (!node) {
@@ -2388,7 +2347,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "obj_property") {
-
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
@@ -2398,8 +2356,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Object *obj = d["object"];
- if (!obj)
+ if (!obj) {
return;
+ }
Node *node = Object::cast_to<Node>(obj);
Vector2 ofs = graph->get_scroll_ofs() + p_point;
@@ -2417,18 +2376,17 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
#endif
if (!node || Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
-
- if (use_get)
+ if (use_get) {
undo_redo->create_action(TTR("Add Getter Property"));
- else
+ } else {
undo_redo->create_action(TTR("Add Setter Property"));
+ }
int base_id = script->get_available_id();
Ref<VisualScriptNode> vnode;
if (!use_get) {
-
Ref<VisualScriptPropertySet> pset;
pset.instance();
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
@@ -2439,7 +2397,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}*/
vnode = pset;
} else {
-
Ref<VisualScriptPropertyGet> pget;
pget.instance();
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
@@ -2461,18 +2418,17 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->commit_action();
} else {
-
- if (use_get)
+ if (use_get) {
undo_redo->create_action(TTR("Add Getter Property"));
- else
+ } else {
undo_redo->create_action(TTR("Add Setter Property"));
+ }
int base_id = script->get_available_id();
Ref<VisualScriptNode> vnode;
if (!use_get) {
-
Ref<VisualScriptPropertySet> pset;
pset.instance();
if (sn == node) {
@@ -2484,7 +2440,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnode = pset;
} else {
-
Ref<VisualScriptPropertyGet> pget;
pget.instance();
if (sn == node) {
@@ -2510,33 +2465,33 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
void VisualScriptEditor::_selected_method(const String &p_method, const String &p_type, const bool p_connecting) {
-
Ref<VisualScriptFunctionCall> vsfc = script->get_node(default_func, selecting_method_id);
- if (!vsfc.is_valid())
+ if (!vsfc.is_valid()) {
return;
+ }
vsfc->set_function(p_method);
}
void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
-
Button *button = Object::cast_to<Button>(obj);
- if (!button)
+ if (!button) {
return;
+ }
Ref<StyleBox> normal = get_theme_stylebox("normal", "Button");
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
-
Array ud = p_ud;
ERR_FAIL_COND(ud.size() != 2);
ObjectID id = ud[0];
Object *obj = ObjectDB::get_instance(id);
- if (!obj)
+ if (!obj) {
return;
+ }
Button *b = Object::cast_to<Button>(obj);
ERR_FAIL_COND(!b);
@@ -2544,7 +2499,6 @@ void VisualScriptEditor::_button_resource_previewed(const String &p_path, const
if (p_preview.is_null()) {
b->set_text(ud[1]);
} else {
-
b->set_icon(p_preview);
}
}
@@ -2559,7 +2513,6 @@ RES VisualScriptEditor::get_edited_resource() const {
}
void VisualScriptEditor::set_edited_resource(const RES &p_res) {
-
script = p_res;
signal_editor->script = script;
signal_editor->undo_redo = undo_redo;
@@ -2581,7 +2534,6 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) {
}
Vector<String> VisualScriptEditor::get_functions() {
-
return Vector<String>();
}
@@ -2589,7 +2541,6 @@ void VisualScriptEditor::reload_text() {
}
String VisualScriptEditor::get_name() {
-
String name;
if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
@@ -2597,26 +2548,24 @@ String VisualScriptEditor::get_name() {
if (is_unsaved()) {
name += "(*)";
}
- } else if (script->get_name() != "")
+ } else if (script->get_name() != "") {
name = script->get_name();
- else
+ } else {
name = script->get_class() + "(" + itos(script->get_instance_id()) + ")";
+ }
return name;
}
Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
-
return Control::get_theme_icon("VisualScript", "EditorIcons");
}
bool VisualScriptEditor::is_unsaved() {
-
return script->is_edited() || script->are_subnodes_edited();
}
Variant VisualScriptEditor::get_edit_state() {
-
Dictionary d;
d["function"] = default_func;
d["scroll"] = graph->get_scroll_ofs();
@@ -2627,7 +2576,6 @@ Variant VisualScriptEditor::get_edit_state() {
}
void VisualScriptEditor::set_edit_state(const Variant &p_state) {
-
Dictionary d = p_state;
if (d.has("function")) {
selected = default_func;
@@ -2651,15 +2599,15 @@ void VisualScriptEditor::set_edit_state(const Variant &p_state) {
}
void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) {
-
Node *n = graph->get_node(itos(p_id));
GraphNode *gn = Object::cast_to<GraphNode>(n);
// clear selection
for (int i = 0; i < graph->get_child_count(); i++) {
GraphNode *gnd = Object::cast_to<GraphNode>(graph->get_child(i));
- if (gnd)
+ if (gnd) {
gnd->set_selected(false);
+ }
}
if (gn) {
@@ -2672,18 +2620,16 @@ void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) {
}
void VisualScriptEditor::goto_line(int p_line, bool p_with_error) {
-
p_line += 1; //add one because script lines begin from 0.
- if (p_with_error)
+ if (p_with_error) {
error_line = p_line;
+ }
List<StringName> functions;
script->get_function_list(&functions);
for (List<StringName>::Element *E = functions.front(); E; E = E->next()) {
-
if (script->has_node(E->get(), p_line)) {
-
_update_graph();
_update_members();
@@ -2714,7 +2660,6 @@ void VisualScriptEditor::convert_indent_to_tabs() {
}
void VisualScriptEditor::ensure_focus() {
-
graph->grab_focus();
}
@@ -2726,15 +2671,12 @@ void VisualScriptEditor::reload(bool p_soft) {
}
void VisualScriptEditor::get_breakpoints(List<int> *p_breakpoints) {
-
List<StringName> functions;
script->get_function_list(&functions);
for (List<StringName>::Element *E = functions.front(); E; E = E->next()) {
-
List<int> nodes;
script->get_node_list(E->get(), &nodes);
for (List<int>::Element *F = nodes.front(); F; F = F->next()) {
-
Ref<VisualScriptNode> vsn = script->get_node(E->get(), F->get());
if (vsn->is_breakpoint()) {
p_breakpoints->push_back(F->get() - 1); //subtract 1 because breakpoints in text start from zero
@@ -2744,7 +2686,6 @@ void VisualScriptEditor::get_breakpoints(List<int> *p_breakpoints) {
}
void VisualScriptEditor::add_callback(const String &p_function, PackedStringArray p_args) {
-
if (script->has_function(p_function)) {
_update_members();
_update_graph();
@@ -2755,7 +2696,6 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
Ref<VisualScriptFunction> func;
func.instance();
for (int i = 0; i < p_args.size(); i++) {
-
String name = p_args[i];
Variant::Type type = Variant::NIL;
@@ -2763,7 +2703,6 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
String tt = name.get_slice(":", 1);
name = name.get_slice(":", 0);
for (int j = 0; j < Variant::VARIANT_MAX; j++) {
-
String tname = Variant::get_type_name(Variant::Type(j));
if (tname == tt) {
type = Variant::Type(j);
@@ -2790,7 +2729,6 @@ bool VisualScriptEditor::show_members_overview() {
}
void VisualScriptEditor::update_settings() {
-
_update_graph();
}
@@ -2805,12 +2743,10 @@ void VisualScriptEditor::set_tooltip_request_func(String p_method, Object *p_obj
}
Control *VisualScriptEditor::get_edit_menu() {
-
return edit_menu;
}
void VisualScriptEditor::_change_base_type() {
-
select_base_type->popup_create(true, true);
}
@@ -2824,7 +2760,6 @@ void VisualScriptEditor::clear_edit_menu() {
}
void VisualScriptEditor::_change_base_type_callback() {
-
String bt = select_base_type->get_selected_type();
ERR_FAIL_COND(bt == String());
@@ -2837,16 +2772,15 @@ void VisualScriptEditor::_change_base_type_callback() {
}
void VisualScriptEditor::_node_selected(Node *p_node) {
-
Ref<VisualScriptNode> vnode = p_node->get_meta("__vnode");
- if (vnode.is_null())
+ if (vnode.is_null()) {
return;
+ }
EditorNode::get_singleton()->push_item(vnode.ptr()); //edit node in inspector
}
static bool _get_out_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r_real_slot, bool &r_sequence) {
-
if (p_slot < p_node->get_output_sequence_port_count()) {
r_sequence = true;
r_real_slot = p_slot;
@@ -2861,7 +2795,6 @@ static bool _get_out_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &
}
static bool _get_in_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r_real_slot, bool &r_sequence) {
-
if (p_slot == 0 && p_node->has_input_sequence_port()) {
r_sequence = true;
r_real_slot = 0;
@@ -2875,30 +2808,28 @@ static bool _get_in_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r
}
void VisualScriptEditor::_begin_node_move() {
-
undo_redo->create_action(TTR("Move Node(s)"));
}
void VisualScriptEditor::_end_node_move() {
-
undo_redo->commit_action();
}
void VisualScriptEditor::_move_node(const StringName &p_func, int p_id, const Vector2 &p_to) {
-
- if (!script->has_function(p_func))
+ if (!script->has_function(p_func)) {
return;
+ }
Node *node = graph->get_node(itos(p_id));
- if (Object::cast_to<GraphNode>(node))
+ if (Object::cast_to<GraphNode>(node)) {
Object::cast_to<GraphNode>(node)->set_offset(p_to);
+ }
script->set_node_position(p_func, p_id, p_to / EDSCALE);
}
StringName VisualScriptEditor::_get_function_of_node(int p_id) const {
-
List<StringName> funcs;
script->get_function_list(&funcs);
for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) {
@@ -2911,7 +2842,6 @@ StringName VisualScriptEditor::_get_function_of_node(int p_id) const {
}
void VisualScriptEditor::_node_moved(Vector2 p_from, Vector2 p_to, int p_id) {
-
StringName func = _get_function_of_node(p_id);
undo_redo->add_do_method(this, "_move_node", func, p_id, p_to);
@@ -2919,7 +2849,6 @@ void VisualScriptEditor::_node_moved(Vector2 p_from, Vector2 p_to, int p_id) {
}
void VisualScriptEditor::_remove_node(int p_id) {
-
undo_redo->create_action(TTR("Remove VisualScript Node"));
StringName func = _get_function_of_node(p_id);
@@ -2931,7 +2860,6 @@ void VisualScriptEditor::_remove_node(int p_id) {
script->get_sequence_connection_list(func, &sequence_conns);
for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
-
if (E->get().from_node == p_id || E->get().to_node == p_id) {
undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, E->get().from_node, E->get().from_output, E->get().to_node);
}
@@ -2941,7 +2869,6 @@ void VisualScriptEditor::_remove_node(int p_id) {
script->get_data_connection_list(func, &data_conns);
for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) {
-
if (E->get().from_node == p_id || E->get().to_node == p_id) {
undo_redo->add_undo_method(script.ptr(), "data_connect", func, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
}
@@ -2954,7 +2881,6 @@ void VisualScriptEditor::_remove_node(int p_id) {
}
void VisualScriptEditor::_node_ports_changed(const String &p_func, int p_id) {
-
_update_graph(p_id);
}
@@ -2966,15 +2892,15 @@ bool VisualScriptEditor::node_has_sequence_connections(const StringName &p_func,
int from = E->get().from_node;
int to = E->get().to_node;
- if (to == p_id || from == p_id)
+ if (to == p_id || from == p_id) {
return true;
+ }
}
return false;
}
void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot) {
-
StringName from_func = _get_function_of_node(p_from.to_int());
Ref<VisualScriptNode> from_node = script->get_node(from_func, p_from.to_int());
@@ -2983,8 +2909,9 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
bool from_seq;
int from_port;
- if (!_get_out_slot(from_node, p_from_slot, from_port, from_seq))
+ if (!_get_out_slot(from_node, p_from_slot, from_port, from_seq)) {
return; //can't connect this, it's invalid
+ }
StringName to_func = _get_function_of_node(p_to.to_int());
@@ -2994,8 +2921,9 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
bool to_seq;
int to_port;
- if (!_get_in_slot(to_node, p_to_slot, to_port, to_seq))
+ if (!_get_in_slot(to_node, p_to_slot, to_port, to_seq)) {
return; //can't connect this, it's invalid
+ }
ERR_FAIL_COND(from_seq != to_seq);
@@ -3096,19 +3024,21 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
Vector2 constructor_pos;
if ((to_node_pos.x - from_node_pos.x) < 0) {
// to is behind from node
- if (to_node_pos.x > (from_node_pos.x - to_node_size.x - 240))
+ if (to_node_pos.x > (from_node_pos.x - to_node_size.x - 240)) {
new_to_node_pos.x = from_node_pos.x - to_node_size.x - 240; // approx size of constructor node + padding
- else
+ } else {
new_to_node_pos.x = to_node_pos.x;
+ }
new_to_node_pos.y = to_node_pos.y;
constructor_pos.x = from_node_pos.x - 210;
constructor_pos.y = to_node_pos.y;
} else {
// to is ahead of from node
- if (to_node_pos.x < (from_node_size.x + from_node_pos.x + 240))
+ if (to_node_pos.x < (from_node_size.x + from_node_pos.x + 240)) {
new_to_node_pos.x = from_node_size.x + from_node_pos.x + 240; // approx size of constructor node + padding
- else
+ } else {
new_to_node_pos.x = to_node_pos.x;
+ }
new_to_node_pos.y = to_node_pos.y;
constructor_pos.x = from_node_size.x + from_node_pos.x + 10;
constructor_pos.y = to_node_pos.y;
@@ -3172,7 +3102,6 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
}
void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot) {
-
StringName func = _get_function_of_node(p_from.to_int());
ERR_FAIL_COND(func != _get_function_of_node(p_to.to_int()));
@@ -3182,8 +3111,9 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
bool from_seq;
int from_port;
- if (!_get_out_slot(from_node, p_from_slot, from_port, from_seq))
+ if (!_get_out_slot(from_node, p_from_slot, from_port, from_seq)) {
return; //can't connect this, it's invalid
+ }
Ref<VisualScriptNode> to_node = script->get_node(func, p_to.to_int());
ERR_FAIL_COND(!to_node.is_valid());
@@ -3191,8 +3121,9 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
bool to_seq;
int to_port;
- if (!_get_in_slot(to_node, p_to_slot, to_port, to_seq))
+ if (!_get_in_slot(to_node, p_to_slot, to_port, to_seq)) {
return; //can't connect this, it's invalid
+ }
ERR_FAIL_COND(from_seq != to_seq);
@@ -3202,7 +3133,6 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
undo_redo->add_do_method(script.ptr(), "sequence_disconnect", func, p_from.to_int(), from_port, p_to.to_int());
undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, p_from.to_int(), from_port, p_to.to_int());
} else {
-
can_swap = true;
data_disconnect_node = p_to.to_int();
data_disconnect_port = to_port;
@@ -3222,7 +3152,6 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
}
void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from, const StringName &p_func_to, int p_id) {
-
Set<int> nodes_to_move;
HashMap<int, Map<int, int>> seqconns_to_move; // from => List(outp, to)
HashMap<int, Map<int, Pair<int, int>>> dataconns_to_move; // to => List(inp_p => from, outp)
@@ -3239,8 +3168,9 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
int from = E->get().from_node;
int to = E->get().to_node;
int out_p = E->get().from_output;
- if (!seqcons.has(from))
+ if (!seqcons.has(from)) {
seqcons.set(from, Map<int, int>());
+ }
seqcons[from].insert(out_p, to);
sequence_connections.insert(to);
sequence_connections.insert(from);
@@ -3263,12 +3193,14 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
}
continue;
}
- if (!seen.has(conn))
+ if (!seen.has(conn)) {
seen.set(conn, Set<int>());
+ }
seen[conn].insert(E->key());
stack.push_back(conn);
- if (!seqconns_to_move.has(conn))
+ if (!seqconns_to_move.has(conn)) {
seqconns_to_move.set(conn, Map<int, int>());
+ }
seqconns_to_move[conn].insert(E->key(), E->get());
conn = E->get();
nodes_to_move.insert(conn);
@@ -3284,6 +3216,7 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
{
List<VisualScript::DataConnection> data_connections;
script->get_data_connection_list(p_func_from, &data_connections);
+ int func_from_node_id = script->get_function_node_id(p_func_from);
HashMap<int, Map<int, Pair<int, int>>> connections;
@@ -3293,8 +3226,14 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
int out_p = E->get().from_port;
int in_p = E->get().to_port;
- if (!connections.has(to))
+ // skip if the from_node is a function node
+ if (from == func_from_node_id) {
+ continue;
+ }
+
+ if (!connections.has(to)) {
connections.set(to, Map<int, Pair<int, int>>());
+ }
connections[to].insert(in_p, Pair<int, int>(from, out_p));
}
@@ -3331,12 +3270,14 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
}
}
- if (!seen.has(id))
+ if (!seen.has(id)) {
seen.set(id, Set<int>());
+ }
seen[id].insert(E->key());
stack.push_back(id);
- if (!dataconns_to_move.has(id))
+ if (!dataconns_to_move.has(id)) {
dataconns_to_move.set(id, Map<int, Pair<int, int>>());
+ }
dataconns_to_move[id].insert(E->key(), Pair<int, int>(E->get().first, E->get().second));
id = E->get().first;
nodes_to_be_added.insert(id);
@@ -3432,22 +3373,22 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
}
void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos) {
-
Node *node = graph->get_node(p_from);
GraphNode *gn = Object::cast_to<GraphNode>(node);
- if (!gn)
+ if (!gn) {
return;
+ }
StringName func = _get_function_of_node(p_from.to_int());
Ref<VisualScriptNode> vsn = script->get_node(func, p_from.to_int());
- if (!vsn.is_valid())
+ if (!vsn.is_valid()) {
return;
+ }
port_action_pos = p_release_pos;
if (p_from_slot < vsn->get_output_sequence_port_count()) {
-
port_action_node = p_from.to_int();
port_action_output = p_from_slot;
_port_action_menu(CREATE_ACTION, func);
@@ -3459,12 +3400,12 @@ void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_fro
}
VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &visited_nodes) {
-
VisualScriptNode::TypeGuess tg;
tg.type = Variant::NIL;
- if (visited_nodes.has(p_port_action_node))
+ if (visited_nodes.has(p_port_action_node)) {
return tg; //no loop
+ }
visited_nodes.insert(p_port_action_node);
@@ -3473,7 +3414,6 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
Ref<VisualScriptNode> node = script->get_node(func, p_port_action_node);
if (!node.is_valid()) {
-
return tg;
}
@@ -3490,16 +3430,13 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
int from_port;
if (script->get_input_value_port_connection_source(func, p_port_action_node, i, &from_node, &from_port)) {
-
g = _guess_output_type(from_node, from_port, visited_nodes);
} else {
Variant defval = node->get_default_input_value(i);
if (defval.get_type() == Variant::OBJECT) {
-
Object *obj = defval;
if (obj) {
-
g.type = Variant::OBJECT;
g.gdclass = obj->get_class();
g.script = obj->get_script();
@@ -3515,7 +3452,6 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
}
void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) {
-
Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -3526,7 +3462,6 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func)
Set<int> vn;
switch (p_option) {
-
case CREATE_CALL_SET_GET: {
Ref<VisualScriptFunctionCall> n;
n.instance();
@@ -3590,7 +3525,6 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func)
}
void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id) {
-
undo_redo->create_action(TTR("Connect Node Data"));
VisualScriptReturn *vnode_return = Object::cast_to<VisualScriptReturn>(vnode.ptr());
if (vnode_return != nullptr && vnode_old->get_output_value_port_count() > 0) {
@@ -3616,7 +3550,6 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua
}
void VisualScriptEditor::_selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting) {
-
Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -3638,8 +3571,9 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == "visualscript") {
Ref<VisualScriptNode> vnode_new = VisualScriptLanguage::singleton->create_node_from_name(p_text);
Ref<VisualScriptNode> vnode_old;
- if (port_node_exists)
+ if (port_node_exists) {
vnode_old = script->get_node(func, port_action_node);
+ }
int new_id = script->get_available_id();
if (Object::cast_to<VisualScriptOperator>(vnode_new.ptr()) && vnode_old.is_valid()) {
@@ -3678,18 +3612,15 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
Ref<VisualScriptPropertySet> script_prop_set;
if (p_category == String("method")) {
-
Ref<VisualScriptFunctionCall> n;
n.instance();
vnode = n;
} else if (p_category == String("set")) {
-
Ref<VisualScriptPropertySet> n;
n.instance();
vnode = n;
script_prop_set = n;
} else if (p_category == String("get")) {
-
Ref<VisualScriptPropertyGet> n;
n.instance();
n->set_property(p_text);
@@ -3698,33 +3629,27 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("action")) {
if (p_text == "VisualScriptCondition") {
-
Ref<VisualScriptCondition> n;
n.instance();
vnode = n;
}
if (p_text == "VisualScriptSwitch") {
-
Ref<VisualScriptSwitch> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptSequence") {
-
Ref<VisualScriptSequence> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptIterator") {
-
Ref<VisualScriptIterator> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptWhile") {
-
Ref<VisualScriptWhile> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptReturn") {
-
Ref<VisualScriptReturn> n;
n.instance();
vnode = n;
@@ -3739,15 +3664,15 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
undo_redo->add_undo_method(this, "_update_graph", new_id);
undo_redo->commit_action();
- if (script_prop_set.is_valid())
+ if (script_prop_set.is_valid()) {
script_prop_set->set_property(p_text);
+ }
port_action_new_node = new_id;
Ref<VisualScriptNode> vsn = script->get_node(func, port_action_new_node);
if (Object::cast_to<VisualScriptFunctionCall>(vsn.ptr())) {
-
Ref<VisualScriptFunctionCall> vsfc = vsn;
vsfc->set_function(p_text);
@@ -3852,12 +3777,12 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
}
_update_graph(port_action_new_node);
- if (port_node_exists)
+ if (port_node_exists) {
_update_graph_connections();
+ }
}
void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id) {
-
VisualScriptOperator *vnode_operator = Object::cast_to<VisualScriptOperator>(vnode_new.ptr());
if (vnode_operator != nullptr && !vnode_operator->has_input_sequence_port()) {
return;
@@ -3905,7 +3830,6 @@ void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<Visual
}
void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting) {
-
String name = p_text;
if (script->has_function(name)) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Script already has function '%s'"), name));
@@ -3968,10 +3892,10 @@ void VisualScriptEditor::_cancel_connect_node() {
}
int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const Vector2 &p_point, const StringName &p_func) {
-
StringName func = default_func;
- if (p_func != StringName())
+ if (p_func != StringName()) {
func = p_func;
+ }
Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(p_text);
int new_id = script->get_available_id();
@@ -3985,10 +3909,10 @@ int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const V
}
void VisualScriptEditor::_default_value_changed() {
-
Ref<VisualScriptNode> vsn = script->get_node(_get_function_of_node(editing_id), editing_id);
- if (vsn.is_null())
+ if (vsn.is_null()) {
return;
+ }
undo_redo->create_action(TTR("Change Input Value"));
undo_redo->add_do_method(vsn.ptr(), "set_default_input_value", editing_input, default_value_edit->get_variant());
@@ -4000,15 +3924,14 @@ void VisualScriptEditor::_default_value_changed() {
}
void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_input_port) {
-
Ref<VisualScriptNode> vsn = script->get_node(_get_function_of_node(p_id), p_id);
- if (vsn.is_null())
+ if (vsn.is_null()) {
return;
+ }
PropertyInfo pinfo = vsn->get_input_value_port_info(p_input_port);
Variant existing = vsn->get_default_input_value(p_input_port);
if (pinfo.type != Variant::NIL && existing.get_type() != pinfo.type) {
-
Callable::CallError ce;
const Variant *existingp = &existing;
existing = Variant::construct(pinfo.type, &existingp, 1, ce, false);
@@ -4018,7 +3941,6 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
default_value_edit->set_size(Size2(1, 1));
if (pinfo.type == Variant::NODE_PATH) {
-
Node *edited_scene = get_tree()->get_edited_scene_root();
if (edited_scene) { // Fixing an old crash bug ( Visual Script Crashes on editing NodePath with an empty scene open)
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
@@ -4036,10 +3958,11 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
}
if (default_value_edit->edit(nullptr, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) {
- if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT)
+ if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT) {
default_value_edit->popup_centered_ratio();
- else
+ } else {
default_value_edit->popup();
+ }
}
editing_id = p_id;
@@ -4047,19 +3970,16 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
}
void VisualScriptEditor::_show_hint(const String &p_hint) {
-
hint_text->set_text(p_hint);
hint_text->show();
hint_text_timer->start();
}
void VisualScriptEditor::_hide_timer() {
-
hint_text->hide();
}
void VisualScriptEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY: {
variable_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_members));
@@ -4122,9 +4042,9 @@ void VisualScriptEditor::_notification(int p_what) {
}
void VisualScriptEditor::_graph_ofs_changed(const Vector2 &p_ofs) {
-
- if (updating_graph || !script.is_valid())
+ if (updating_graph || !script.is_valid()) {
return;
+ }
updating_graph = true;
@@ -4137,20 +4057,22 @@ void VisualScriptEditor::_graph_ofs_changed(const Vector2 &p_ofs) {
}
void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_node) {
-
- if (updating_graph)
+ if (updating_graph) {
return;
+ }
StringName func = _get_function_of_node(p_node);
Ref<VisualScriptComment> vsc = script->get_node(func, p_node);
- if (vsc.is_null())
+ if (vsc.is_null()) {
return;
+ }
Node *node = graph->get_node(itos(p_node));
GraphNode *gn = Object::cast_to<GraphNode>(node);
- if (!gn)
+ if (!gn) {
return;
+ }
updating_graph = true;
@@ -4168,13 +4090,11 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_
}
void VisualScriptEditor::_menu_option(int p_what) {
-
switch (p_what) {
case EDIT_DELETE_NODES: {
_on_nodes_delete();
} break;
case EDIT_TOGGLE_BREAKPOINT: {
-
List<String> reselect;
for (int i = 0; i < graph->get_child_count(); i++) {
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
@@ -4204,8 +4124,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
} break;
case EDIT_COPY_NODES:
case EDIT_CUT_NODES: {
- if (!script->has_function(default_func))
+ if (!script->has_function(default_func)) {
break;
+ }
clipboard->nodes.clear();
clipboard->data_connections.clear();
@@ -4216,7 +4137,6 @@ void VisualScriptEditor::_menu_option(int p_what) {
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected()) {
-
int id = String(gn->get_name()).to_int();
StringName func = _get_function_of_node(id);
Ref<VisualScriptNode> node = script->get_node(func, id);
@@ -4233,8 +4153,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
}
- if (clipboard->nodes.empty())
+ if (clipboard->nodes.empty()) {
break;
+ }
for (Set<String>::Element *F = funcs.front(); F; F = F->next()) {
List<VisualScript::SequenceConnection> sequence_connections;
@@ -4242,9 +4163,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
script->get_sequence_connection_list(F->get(), &sequence_connections);
for (List<VisualScript::SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) {
-
if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) {
-
clipboard->sequence_connections.insert(E->get());
}
}
@@ -4254,9 +4173,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
script->get_data_connection_list(F->get(), &data_connections);
for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
-
if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) {
-
clipboard->data_connections.insert(E->get());
}
}
@@ -4267,8 +4184,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
} break;
case EDIT_PASTE_NODES: {
- if (!script->has_function(default_func))
+ if (!script->has_function(default_func)) {
break;
+ }
if (clipboard->nodes.empty()) {
EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty!"));
@@ -4298,7 +4216,6 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
for (Map<int, Ref<VisualScriptNode>>::Element *E = clipboard->nodes.front(); E; E = E->next()) {
-
Ref<VisualScriptNode> node = E->get()->duplicate();
int new_id = idc++;
@@ -4317,13 +4234,11 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
for (Set<VisualScript::SequenceConnection>::Element *E = clipboard->sequence_connections.front(); E; E = E->next()) {
-
undo_redo->add_do_method(script.ptr(), "sequence_connect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
}
for (Set<VisualScript::DataConnection>::Element *E = clipboard->data_connections.front(); E; E = E->next()) {
-
undo_redo->add_do_method(script.ptr(), "data_connect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
undo_redo->add_undo_method(script.ptr(), "data_disconnect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
}
@@ -4342,7 +4257,6 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
} break;
case EDIT_CREATE_FUNCTION: {
-
StringName function = "";
Map<int, Ref<VisualScriptNode>> nodes;
Set<int> selections;
@@ -4384,9 +4298,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
Set<int> end_nodes;
if (nodes.size() == 1) {
Ref<VisualScriptNode> nd = script->get_node(function, nodes.front()->key());
- if (nd.is_valid() && nd->has_input_sequence_port())
+ if (nd.is_valid() && nd->has_input_sequence_port()) {
start_node = nodes.front()->key();
- else {
+ } else {
EditorNode::get_singleton()->show_warning(TTR("Select at least one node with sequence port."));
return;
}
@@ -4415,9 +4329,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
}
Ref<VisualScriptNode> nd = script->get_node(function, top_nd);
- if (nd.is_valid() && nd->has_input_sequence_port())
+ if (nd.is_valid() && nd->has_input_sequence_port()) {
start_node = top_nd;
- else {
+ } else {
EditorNode::get_singleton()->show_warning(TTR("Select at least one node with sequence port."));
return;
}
@@ -4614,7 +4528,6 @@ void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::Sequence
}
void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
-
TreeItem *ti = members->get_selected();
ERR_FAIL_COND(!ti);
@@ -4632,7 +4545,6 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
Ref<Texture2D> edit_icon = Control::get_theme_icon("Edit", "EditorIcons");
if (ti->get_parent() == root->get_children()) {
-
member_type = MEMBER_FUNCTION;
member_name = ti->get_text(0);
member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT);
@@ -4643,7 +4555,6 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
}
if (ti->get_parent() == root->get_children()->get_next()) {
-
member_type = MEMBER_VARIABLE;
member_name = ti->get_text(0);
member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT);
@@ -4654,7 +4565,6 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
}
if (ti->get_parent() == root->get_children()->get_next()->get_next()) {
-
member_type = MEMBER_SIGNAL;
member_name = ti->get_text(0);
member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT);
@@ -4666,10 +4576,8 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
}
void VisualScriptEditor::_member_option(int p_option) {
-
switch (member_type) {
case MEMBER_FUNCTION: {
-
if (p_option == MEMBER_REMOVE) {
//delete the function
String name = member_name;
@@ -4712,7 +4620,6 @@ void VisualScriptEditor::_member_option(int p_option) {
}
} break;
case MEMBER_VARIABLE: {
-
String name = member_name;
if (p_option == MEMBER_REMOVE) {
@@ -4760,7 +4667,6 @@ void VisualScriptEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter
}
void VisualScriptEditor::_bind_methods() {
-
ClassDB::bind_method("_move_node", &VisualScriptEditor::_move_node);
ClassDB::bind_method("_update_graph", &VisualScriptEditor::_update_graph, DEFVAL(-1));
@@ -4783,7 +4689,6 @@ void VisualScriptEditor::_bind_methods() {
}
VisualScriptEditor::VisualScriptEditor() {
-
if (!clipboard) {
clipboard = memnew(Clipboard);
}
@@ -5015,14 +4920,12 @@ VisualScriptEditor::VisualScriptEditor() {
}
VisualScriptEditor::~VisualScriptEditor() {
-
undo_redo->clear_history(); // Avoid crashes.
memdelete(signal_editor);
memdelete(variable_editor);
}
static ScriptEditorBase *create_editor(const RES &p_resource) {
-
if (Object::cast_to<VisualScript>(*p_resource)) {
return memnew(VisualScriptEditor);
}
@@ -5033,12 +4936,12 @@ static ScriptEditorBase *create_editor(const RES &p_resource) {
VisualScriptEditor::Clipboard *VisualScriptEditor::clipboard = nullptr;
void VisualScriptEditor::free_clipboard() {
- if (clipboard)
+ if (clipboard) {
memdelete(clipboard);
+ }
}
static void register_editor_callback() {
-
ScriptEditor::register_create_script_editor_function(create_editor);
ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected"), KEY_DELETE);
@@ -5053,13 +4956,11 @@ static void register_editor_callback() {
}
void VisualScriptEditor::register_editor() {
-
// Too early to register stuff here, request a callback.
EditorNode::add_plugin_init_callback(register_editor_callback);
}
Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_name) {
-
Ref<VisualScriptCustomNode> node;
node.instance();
node->set_script(singleton->custom_nodes[p_name]);
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index d9494e4d04..37063b2da1 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -152,7 +152,6 @@ class VisualScriptEditor : public ScriptEditorBase {
String _validate_name(const String &p_name) const;
struct Clipboard {
-
Map<int, Ref<VisualScriptNode>> nodes;
Map<int, Vector2> nodes_positions;
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 616a621845..bd41117497 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -31,7 +31,6 @@
#include "visual_script_expression.h"
bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_value) {
-
if (String(p_name) == "expression") {
expression = p_value;
expression_dirty = true;
@@ -52,7 +51,6 @@ bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_val
}
if (String(p_name) == "input_count") {
-
int from = inputs.size();
inputs.resize(int(p_value));
for (int i = from; i < inputs.size(); i++) {
@@ -70,17 +68,14 @@ bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_val
}
if (String(p_name).begins_with("input_")) {
-
int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int();
ERR_FAIL_INDEX_V(idx, inputs.size(), false);
String what = String(p_name).get_slice("/", 1);
if (what == "type") {
-
inputs.write[idx].type = Variant::Type(int(p_value));
} else if (what == "name") {
-
inputs.write[idx].name = p_value;
} else {
return false;
@@ -95,7 +90,6 @@ bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_val
}
bool VisualScriptExpression::_get(const StringName &p_name, Variant &r_ret) const {
-
if (String(p_name) == "expression") {
r_ret = expression;
return true;
@@ -117,17 +111,14 @@ bool VisualScriptExpression::_get(const StringName &p_name, Variant &r_ret) cons
}
if (String(p_name).begins_with("input_")) {
-
int idx = String(p_name).get_slicec('_', 1).get_slicec('/', 0).to_int();
ERR_FAIL_INDEX_V(idx, inputs.size(), false);
String what = String(p_name).get_slice("/", 1);
if (what == "type") {
-
r_ret = inputs[idx].type;
} else if (what == "name") {
-
r_ret = inputs[idx].name;
} else {
return false;
@@ -138,8 +129,8 @@ bool VisualScriptExpression::_get(const StringName &p_name, Variant &r_ret) cons
return false;
}
-void VisualScriptExpression::_get_property_list(List<PropertyInfo> *p_list) const {
+void VisualScriptExpression::_get_property_list(List<PropertyInfo> *p_list) const {
String argt = "Any";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
argt += "," + Variant::get_type_name(Variant::Type(i));
@@ -151,55 +142,48 @@ void VisualScriptExpression::_get_property_list(List<PropertyInfo> *p_list) cons
p_list->push_back(PropertyInfo(Variant::BOOL, "sequenced"));
for (int i = 0; i < inputs.size(); i++) {
-
p_list->push_back(PropertyInfo(Variant::INT, "input_" + itos(i) + "/type", PROPERTY_HINT_ENUM, argt));
p_list->push_back(PropertyInfo(Variant::STRING, "input_" + itos(i) + "/name"));
}
}
int VisualScriptExpression::get_output_sequence_port_count() const {
-
return sequenced ? 1 : 0;
}
-bool VisualScriptExpression::has_input_sequence_port() const {
+bool VisualScriptExpression::has_input_sequence_port() const {
return sequenced;
}
String VisualScriptExpression::get_output_sequence_port_text(int p_port) const {
-
return String();
}
int VisualScriptExpression::get_input_value_port_count() const {
-
return inputs.size();
}
-int VisualScriptExpression::get_output_value_port_count() const {
+int VisualScriptExpression::get_output_value_port_count() const {
return 1;
}
PropertyInfo VisualScriptExpression::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo(inputs[p_idx].type, inputs[p_idx].name);
}
-PropertyInfo VisualScriptExpression::get_output_value_port_info(int p_idx) const {
+PropertyInfo VisualScriptExpression::get_output_value_port_info(int p_idx) const {
return PropertyInfo(output_type, "result");
}
String VisualScriptExpression::get_caption() const {
-
return "Expression";
}
-String VisualScriptExpression::get_text() const {
+String VisualScriptExpression::get_text() const {
return expression;
}
Error VisualScriptExpression::_get_token(Token &r_token) {
-
while (true) {
#define GET_CHAR() (str_ofs >= expression.length() ? 0 : expression[str_ofs++])
@@ -210,58 +194,47 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
}
switch (cchar) {
-
case 0: {
r_token.type = TK_EOF;
return OK;
} break;
case '{': {
-
r_token.type = TK_CURLY_BRACKET_OPEN;
return OK;
};
case '}': {
-
r_token.type = TK_CURLY_BRACKET_CLOSE;
return OK;
};
case '[': {
-
r_token.type = TK_BRACKET_OPEN;
return OK;
};
case ']': {
-
r_token.type = TK_BRACKET_CLOSE;
return OK;
};
case '(': {
-
r_token.type = TK_PARENTHESIS_OPEN;
return OK;
};
case ')': {
-
r_token.type = TK_PARENTHESIS_CLOSE;
return OK;
};
case ',': {
-
r_token.type = TK_COMMA;
return OK;
};
case ':': {
-
r_token.type = TK_COLON;
return OK;
};
case '.': {
-
r_token.type = TK_PERIOD;
return OK;
};
case '=': {
-
cchar = GET_CHAR();
if (cchar == '=') {
r_token.type = TK_OP_EQUAL;
@@ -273,7 +246,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return OK;
};
case '!': {
-
if (expression[str_ofs] == '=') {
r_token.type = TK_OP_NOT_EQUAL;
str_ofs++;
@@ -283,7 +255,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return OK;
};
case '>': {
-
if (expression[str_ofs] == '=') {
r_token.type = TK_OP_GREATER_EQUAL;
str_ofs++;
@@ -296,7 +267,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return OK;
};
case '<': {
-
if (expression[str_ofs] == '=') {
r_token.type = TK_OP_LESS_EQUAL;
str_ofs++;
@@ -329,7 +299,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return OK;
};
case '&': {
-
if (expression[str_ofs] == '&') {
r_token.type = TK_OP_AND;
str_ofs++;
@@ -339,7 +308,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return OK;
};
case '|': {
-
if (expression[str_ofs] == '|') {
r_token.type = TK_OP_OR;
str_ofs++;
@@ -349,22 +317,18 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return OK;
};
case '^': {
-
r_token.type = TK_OP_BIT_XOR;
return OK;
};
case '~': {
-
r_token.type = TK_OP_BIT_INVERT;
return OK;
};
case '"': {
-
String str;
while (true) {
-
CharType ch = GET_CHAR();
if (ch == 0) {
@@ -385,7 +349,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
CharType res = 0;
switch (next) {
-
case 'b':
res = 8;
break;
@@ -412,7 +375,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
return ERR_PARSE_ERROR;
}
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
-
_set_error("Malformed hex constant in string");
r_token.type = TK_ERROR;
return ERR_PARSE_ERROR;
@@ -454,7 +416,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
default: {
-
if (cchar <= 32) {
break;
}
@@ -476,10 +437,8 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
bool is_float = false;
while (true) {
-
switch (reading) {
case READING_INT: {
-
if (c >= '0' && c <= '9') {
//pass
} else if (c == '.') {
@@ -493,9 +452,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
case READING_DEC: {
-
if (c >= '0' && c <= '9') {
-
} else if (c == 'e') {
reading = READING_EXP;
@@ -505,13 +462,13 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
case READING_EXP: {
-
if (c >= '0' && c <= '9') {
exp_beg = true;
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
- if (c == '-')
+ if (c == '-') {
is_float = true;
+ }
exp_sign = true;
} else {
@@ -520,8 +477,9 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
}
- if (reading == READING_DONE)
+ if (reading == READING_DONE) {
break;
+ }
num += String::chr(c);
c = GET_CHAR();
}
@@ -530,19 +488,18 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
r_token.type = TK_CONSTANT;
- if (is_float)
+ if (is_float) {
r_token.value = num.to_double();
- else
+ } else {
r_token.value = num.to_int();
+ }
return OK;
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
-
String id;
bool first = true;
while ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_' || (!first && cchar >= '0' && cchar <= '9')) {
-
id += String::chr(cchar);
cchar = GET_CHAR();
first = false;
@@ -582,7 +539,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} else if (id == "self") {
r_token.type = TK_SELF;
} else {
-
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (id == Variant::get_type_name(Variant::Type(i))) {
r_token.type = TK_BASIC_TYPE;
@@ -657,7 +613,6 @@ const char *VisualScriptExpression::token_name[TK_MAX] = {
};
VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
-
Vector<Expression> expression;
while (true) {
@@ -666,8 +621,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
Token tk;
_get_token(tk);
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
switch (tk.type) {
case TK_CURLY_BRACKET_OPEN: {
@@ -675,7 +631,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
DictionaryNode *dn = alloc_node<DictionaryNode>();
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_CURLY_BRACKET_CLOSE) {
@@ -684,8 +639,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *expr2 = _parse_expression();
- if (!expr2)
+ if (!expr2) {
return nullptr;
+ }
dn->dict.push_back(expr2);
_get_token(tk);
@@ -695,8 +651,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
}
expr2 = _parse_expression();
- if (!expr2)
+ if (!expr2) {
return nullptr;
+ }
dn->dict.push_back(expr2);
@@ -719,7 +676,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
ArrayNode *an = alloc_node<ArrayNode>();
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_BRACKET_CLOSE) {
@@ -728,8 +684,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *expr2 = _parse_expression();
- if (!expr2)
+ if (!expr2) {
return nullptr;
+ }
an->array.push_back(expr2);
cofs = str_ofs;
@@ -748,8 +705,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
case TK_PARENTHESIS_OPEN: {
//a suexpression
ENode *e = _parse_expression();
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
_get_token(tk);
if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')'");
@@ -760,7 +718,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
} break;
case TK_IDENTIFIER: {
-
String what = tk.value;
int index = -1;
for (int i = 0; i < inputs.size(); i++) {
@@ -780,7 +737,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
}
} break;
case TK_SELF: {
-
SelfNode *self = alloc_node<SelfNode>();
expr = self;
} break;
@@ -803,7 +759,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
constructor->data_type = bt;
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -812,8 +767,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *expr2 = _parse_expression();
- if (!expr2)
+ if (!expr2) {
return nullptr;
+ }
constructor->arguments.push_back(expr2);
@@ -844,7 +800,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
bifunc->func = VisualScriptBuiltinFunc::BuiltinFunc(int(tk.value));
while (true) {
-
int cofs = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -853,8 +808,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
str_ofs = cofs; //revert
//parse an expression
ENode *expr2 = _parse_expression();
- if (!expr2)
+ if (!expr2) {
return nullptr;
+ }
bifunc->arguments.push_back(expr2);
@@ -878,7 +834,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
} break;
case TK_OP_SUB: {
-
Expression e;
e.is_op = true;
e.op = Variant::OP_NEGATE;
@@ -886,7 +841,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
continue;
} break;
case TK_OP_NOT: {
-
Expression e;
e.is_op = true;
e.op = Variant::OP_NOT;
@@ -905,8 +859,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
while (true) {
int cofs2 = str_ofs;
_get_token(tk);
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
bool done = false;
@@ -918,8 +873,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
index->base = expr;
ENode *what = _parse_expression();
- if (!what)
+ if (!what) {
return nullptr;
+ }
index->index = what;
@@ -950,7 +906,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
func_call->base = expr;
while (true) {
-
int cofs3 = str_ofs;
_get_token(tk);
if (tk.type == TK_PARENTHESIS_CLOSE) {
@@ -959,8 +914,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
str_ofs = cofs3; //revert
//parse an expression
ENode *expr2 = _parse_expression();
- if (!expr2)
+ if (!expr2) {
return nullptr;
+ }
func_call->arguments.push_back(expr2);
@@ -993,8 +949,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
} break;
}
- if (done)
+ if (done) {
break;
+ }
}
//push expression
@@ -1009,8 +966,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
int cofs = str_ofs;
_get_token(tk);
- if (error_set)
+ if (error_set) {
return nullptr;
+ }
Variant::Operator op = Variant::OP_MAX;
@@ -1099,15 +1057,12 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
/* Reduce the set set of expressions and place them in an operator tree, respecting precedence */
while (expression.size() > 1) {
-
int next_op = -1;
int min_priority = 0xFFFFF;
bool is_unary = false;
for (int i = 0; i < expression.size(); i++) {
-
if (!expression[i].is_op) {
-
continue;
}
@@ -1116,7 +1071,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
bool unary = false;
switch (expression[i].op) {
-
case Variant::OP_BIT_NEGATE:
priority = 0;
unary = true;
@@ -1212,17 +1166,14 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
}
if (next_op == -1) {
-
_set_error("Yet another parser bug....");
ERR_FAIL_V(nullptr);
}
// OK! create operator..
if (is_unary) {
-
int expr_pos = next_op;
while (expression[expr_pos].is_op) {
-
expr_pos++;
if (expr_pos == expression.size()) {
//can happen..
@@ -1233,7 +1184,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//consecutively do unary operators
for (int i = expr_pos - 1; i >= next_op; i--) {
-
OperatorNode *op = alloc_node<OperatorNode>();
op->op = expression[i].op;
op->nodes[0] = expression[i + 1].node;
@@ -1244,7 +1194,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
}
} else {
-
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
@@ -1254,7 +1203,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
op->op = expression[next_op].op;
if (expression[next_op - 1].is_op) {
-
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
}
@@ -1283,9 +1231,9 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
}
bool VisualScriptExpression::_compile_expression() {
-
- if (!expression_dirty)
+ if (!expression_dirty) {
return error_set;
+ }
if (nodes) {
memdelete(nodes);
@@ -1320,38 +1268,35 @@ public:
//virtual int get_working_memory_size() const { return 0; }
//execute by parsing the tree directly
virtual bool _execute(const Variant **p_inputs, VisualScriptExpression::ENode *p_node, Variant &r_ret, String &r_error_str, Callable::CallError &ce) {
-
switch (p_node->type) {
case VisualScriptExpression::ENode::TYPE_INPUT: {
-
const VisualScriptExpression::InputNode *in = static_cast<const VisualScriptExpression::InputNode *>(p_node);
r_ret = *p_inputs[in->index];
} break;
case VisualScriptExpression::ENode::TYPE_CONSTANT: {
-
const VisualScriptExpression::ConstantNode *c = static_cast<const VisualScriptExpression::ConstantNode *>(p_node);
r_ret = c->value;
} break;
case VisualScriptExpression::ENode::TYPE_SELF: {
-
r_ret = instance->get_owner_ptr();
} break;
case VisualScriptExpression::ENode::TYPE_OPERATOR: {
-
const VisualScriptExpression::OperatorNode *op = static_cast<const VisualScriptExpression::OperatorNode *>(p_node);
Variant a;
bool ret = _execute(p_inputs, op->nodes[0], a, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
Variant b;
if (op->nodes[1]) {
ret = _execute(p_inputs, op->nodes[1], b, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
}
bool valid = true;
@@ -1363,19 +1308,20 @@ public:
} break;
case VisualScriptExpression::ENode::TYPE_INDEX: {
-
const VisualScriptExpression::IndexNode *index = static_cast<const VisualScriptExpression::IndexNode *>(p_node);
Variant base;
bool ret = _execute(p_inputs, index->base, base, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
Variant idx;
ret = _execute(p_inputs, index->index, idx, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
bool valid;
r_ret = base.get(idx, &valid);
@@ -1386,13 +1332,13 @@ public:
} break;
case VisualScriptExpression::ENode::TYPE_NAMED_INDEX: {
-
const VisualScriptExpression::NamedIndexNode *index = static_cast<const VisualScriptExpression::NamedIndexNode *>(p_node);
Variant base;
bool ret = _execute(p_inputs, index->base, base, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
bool valid;
r_ret = base.get_named(index->name, &valid);
@@ -1408,11 +1354,11 @@ public:
Array arr;
arr.resize(array->array.size());
for (int i = 0; i < array->array.size(); i++) {
-
Variant value;
bool ret = _execute(p_inputs, array->array[i], value, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
arr[i] = value;
}
@@ -1424,16 +1370,17 @@ public:
Dictionary d;
for (int i = 0; i < dictionary->dict.size(); i += 2) {
-
Variant key;
bool ret = _execute(p_inputs, dictionary->dict[i + 0], key, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
Variant value;
ret = _execute(p_inputs, dictionary->dict[i + 1], value, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
d[key] = value;
}
@@ -1441,7 +1388,6 @@ public:
r_ret = d;
} break;
case VisualScriptExpression::ENode::TYPE_CONSTRUCTOR: {
-
const VisualScriptExpression::ConstructorNode *constructor = static_cast<const VisualScriptExpression::ConstructorNode *>(p_node);
Vector<Variant> arr;
@@ -1450,11 +1396,11 @@ public:
argp.resize(constructor->arguments.size());
for (int i = 0; i < constructor->arguments.size(); i++) {
-
Variant value;
bool ret = _execute(p_inputs, constructor->arguments[i], value, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
arr.write[i] = value;
argp.write[i] = &arr[i];
}
@@ -1468,7 +1414,6 @@ public:
} break;
case VisualScriptExpression::ENode::TYPE_BUILTIN_FUNC: {
-
const VisualScriptExpression::BuiltinFuncNode *bifunc = static_cast<const VisualScriptExpression::BuiltinFuncNode *>(p_node);
Vector<Variant> arr;
@@ -1477,11 +1422,11 @@ public:
argp.resize(bifunc->arguments.size());
for (int i = 0; i < bifunc->arguments.size(); i++) {
-
Variant value;
bool ret = _execute(p_inputs, bifunc->arguments[i], value, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
arr.write[i] = value;
argp.write[i] = &arr[i];
}
@@ -1495,13 +1440,13 @@ public:
} break;
case VisualScriptExpression::ENode::TYPE_CALL: {
-
const VisualScriptExpression::CallNode *call = static_cast<const VisualScriptExpression::CallNode *>(p_node);
Variant base;
bool ret = _execute(p_inputs, call->base, base, r_error_str, ce);
- if (ret)
+ if (ret) {
return true;
+ }
Vector<Variant> arr;
Vector<const Variant *> argp;
@@ -1509,11 +1454,11 @@ public:
argp.resize(call->arguments.size());
for (int i = 0; i < call->arguments.size(); i++) {
-
Variant value;
bool ret2 = _execute(p_inputs, call->arguments[i], value, r_error_str, ce);
- if (ret2)
+ if (ret2) {
return true;
+ }
arr.write[i] = value;
argp.write[i] = &arr[i];
}
@@ -1531,7 +1476,6 @@ public:
}
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (!expression->root || expression->error_set) {
r_error_str = expression->error_str;
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -1545,7 +1489,6 @@ public:
#ifdef DEBUG_ENABLED
if (!error && expression->output_type != Variant::NIL && !Variant::can_convert_strict(p_outputs[0]->get_type(), expression->output_type)) {
-
r_error_str += "Can't convert expression result from " + Variant::get_type_name(p_outputs[0]->get_type()) + " to " + Variant::get_type_name(expression->output_type) + ".";
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
}
@@ -1556,7 +1499,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptExpression::instance(VisualScriptInstance *p_instance) {
-
_compile_expression();
VisualScriptNodeInstanceExpression *instance = memnew(VisualScriptNodeInstanceExpression);
instance->instance = p_instance;
@@ -1574,13 +1516,11 @@ VisualScriptExpression::VisualScriptExpression() {
}
VisualScriptExpression::~VisualScriptExpression() {
-
if (nodes) {
memdelete(nodes);
}
}
void register_visual_script_expression_node() {
-
VisualScriptLanguage::singleton->add_register_func("operators/expression", create_node_generic<VisualScriptExpression>);
}
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index 61b50ff99d..dee0213d54 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -35,12 +35,10 @@
#include "visual_script_builtin_funcs.h"
class VisualScriptExpression : public VisualScriptNode {
-
GDCLASS(VisualScriptExpression, VisualScriptNode);
friend class VisualScriptNodeInstanceExpression;
struct Input {
-
Variant::Type type;
String name;
@@ -101,14 +99,14 @@ class VisualScriptExpression : public VisualScriptNode {
static const char *token_name[TK_MAX];
struct Token {
-
TokenType type;
Variant value;
};
void _set_error(const String &p_err) {
- if (error_set)
+ if (error_set) {
return;
+ }
error_str = p_err;
error_set = true;
}
@@ -119,7 +117,6 @@ class VisualScriptExpression : public VisualScriptNode {
bool error_set;
struct ENode {
-
enum Type {
TYPE_INPUT,
TYPE_CONSTANT,
@@ -147,7 +144,6 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct Expression {
-
bool is_op;
union {
Variant::Operator op;
@@ -158,7 +154,6 @@ class VisualScriptExpression : public VisualScriptNode {
ENode *_parse_expression();
struct InputNode : public ENode {
-
int index;
InputNode() {
type = TYPE_INPUT;
@@ -166,7 +161,6 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct ConstantNode : public ENode {
-
Variant value;
ConstantNode() {
type = TYPE_CONSTANT;
@@ -174,7 +168,6 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct OperatorNode : public ENode {
-
Variant::Operator op;
ENode *nodes[2];
@@ -185,7 +178,6 @@ class VisualScriptExpression : public VisualScriptNode {
};
struct SelfNode : public ENode {
-
SelfNode() {
type = TYPE_SELF;
}
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 8a644c6860..3ed20fab35 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -39,78 +39,70 @@
//////////////////////////////////////////
int VisualScriptReturn::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptReturn::has_input_sequence_port() const {
-
return true;
}
int VisualScriptReturn::get_input_value_port_count() const {
-
return with_value ? 1 : 0;
}
-int VisualScriptReturn::get_output_value_port_count() const {
+int VisualScriptReturn::get_output_value_port_count() const {
return 0;
}
String VisualScriptReturn::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptReturn::get_input_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = "result";
pinfo.type = type;
return pinfo;
}
+
PropertyInfo VisualScriptReturn::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptReturn::get_caption() const {
-
return "Return";
}
String VisualScriptReturn::get_text() const {
-
return get_name();
}
void VisualScriptReturn::set_return_type(Variant::Type p_type) {
-
- if (type == p_type)
+ if (type == p_type) {
return;
+ }
type = p_type;
ports_changed_notify();
}
Variant::Type VisualScriptReturn::get_return_type() const {
-
return type;
}
void VisualScriptReturn::set_enable_return_value(bool p_enable) {
- if (with_value == p_enable)
+ if (with_value == p_enable) {
return;
+ }
with_value = p_enable;
ports_changed_notify();
}
bool VisualScriptReturn::is_return_value_enabled() const {
-
return with_value;
}
void VisualScriptReturn::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_return_type", "type"), &VisualScriptReturn::set_return_type);
ClassDB::bind_method(D_METHOD("get_return_type"), &VisualScriptReturn::get_return_type);
ClassDB::bind_method(D_METHOD("set_enable_return_value", "enable"), &VisualScriptReturn::set_enable_return_value);
@@ -136,7 +128,6 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (with_value) {
*p_working_mem = *p_inputs[0];
return STEP_EXIT_FUNCTION_BIT;
@@ -148,7 +139,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptReturn::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceReturn *instance = memnew(VisualScriptNodeInstanceReturn);
instance->node = this;
instance->instance = p_instance;
@@ -157,14 +147,12 @@ VisualScriptNodeInstance *VisualScriptReturn::instance(VisualScriptInstance *p_i
}
VisualScriptReturn::VisualScriptReturn() {
-
with_value = false;
type = Variant::NIL;
}
template <bool with_value>
static Ref<VisualScriptNode> create_return_node(const String &p_name) {
-
Ref<VisualScriptReturn> node;
node.instance();
node->set_enable_return_value(with_value);
@@ -176,52 +164,47 @@ static Ref<VisualScriptNode> create_return_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptCondition::get_output_sequence_port_count() const {
-
return 3;
}
bool VisualScriptCondition::has_input_sequence_port() const {
-
return true;
}
int VisualScriptCondition::get_input_value_port_count() const {
-
return 1;
}
-int VisualScriptCondition::get_output_value_port_count() const {
+int VisualScriptCondition::get_output_value_port_count() const {
return 0;
}
String VisualScriptCondition::get_output_sequence_port_text(int p_port) const {
-
- if (p_port == 0)
+ if (p_port == 0) {
return "true";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "false";
- else
+ } else {
return "done";
+ }
}
PropertyInfo VisualScriptCondition::get_input_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = "cond";
pinfo.type = Variant::BOOL;
return pinfo;
}
+
PropertyInfo VisualScriptCondition::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptCondition::get_caption() const {
-
return "Condition";
}
String VisualScriptCondition::get_text() const {
-
return "if (cond) is: ";
}
@@ -238,18 +221,17 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
- if (p_start_mode == START_MODE_CONTINUE_SEQUENCE)
+ if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
return 2;
- else if (p_inputs[0]->operator bool())
+ } else if (p_inputs[0]->operator bool()) {
return 0 | STEP_FLAG_PUSH_STACK_BIT;
- else
+ } else {
return 1 | STEP_FLAG_PUSH_STACK_BIT;
+ }
}
};
VisualScriptNodeInstance *VisualScriptCondition::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceCondition *instance = memnew(VisualScriptNodeInstanceCondition);
instance->node = this;
instance->instance = p_instance;
@@ -264,50 +246,45 @@ VisualScriptCondition::VisualScriptCondition() {
//////////////////////////////////////////
int VisualScriptWhile::get_output_sequence_port_count() const {
-
return 2;
}
bool VisualScriptWhile::has_input_sequence_port() const {
-
return true;
}
int VisualScriptWhile::get_input_value_port_count() const {
-
return 1;
}
-int VisualScriptWhile::get_output_value_port_count() const {
+int VisualScriptWhile::get_output_value_port_count() const {
return 0;
}
String VisualScriptWhile::get_output_sequence_port_text(int p_port) const {
-
- if (p_port == 0)
+ if (p_port == 0) {
return "repeat";
- else
+ } else {
return "exit";
+ }
}
PropertyInfo VisualScriptWhile::get_input_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = "cond";
pinfo.type = Variant::BOOL;
return pinfo;
}
+
PropertyInfo VisualScriptWhile::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptWhile::get_caption() const {
-
return "While";
}
String VisualScriptWhile::get_text() const {
-
return "while (cond): ";
}
@@ -324,23 +301,23 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
bool keep_going = p_inputs[0]->operator bool();
- if (keep_going)
+ if (keep_going) {
return 0 | STEP_FLAG_PUSH_STACK_BIT;
- else
+ } else {
return 1;
+ }
}
};
VisualScriptNodeInstance *VisualScriptWhile::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceWhile *instance = memnew(VisualScriptNodeInstanceWhile);
instance->node = this;
instance->instance = p_instance;
return instance;
}
+
VisualScriptWhile::VisualScriptWhile() {
}
@@ -349,52 +326,48 @@ VisualScriptWhile::VisualScriptWhile() {
//////////////////////////////////////////
int VisualScriptIterator::get_output_sequence_port_count() const {
-
return 2;
}
bool VisualScriptIterator::has_input_sequence_port() const {
-
return true;
}
int VisualScriptIterator::get_input_value_port_count() const {
-
return 1;
}
-int VisualScriptIterator::get_output_value_port_count() const {
+int VisualScriptIterator::get_output_value_port_count() const {
return 1;
}
String VisualScriptIterator::get_output_sequence_port_text(int p_port) const {
-
- if (p_port == 0)
+ if (p_port == 0) {
return "each";
- else
+ } else {
return "exit";
+ }
}
PropertyInfo VisualScriptIterator::get_input_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = "input";
pinfo.type = Variant::NIL;
return pinfo;
}
+
PropertyInfo VisualScriptIterator::get_output_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "elem";
pinfo.type = Variant::NIL;
return pinfo;
}
-String VisualScriptIterator::get_caption() const {
+String VisualScriptIterator::get_caption() const {
return "Iterator";
}
String VisualScriptIterator::get_text() const {
-
return "for (elem) in (input): ";
}
@@ -411,7 +384,6 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
p_working_mem[0] = *p_inputs[0];
bool valid;
@@ -423,8 +395,9 @@ public:
return 0;
}
- if (!can_iter)
+ if (!can_iter) {
return 1; //nothing to iterate
+ }
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
@@ -445,8 +418,9 @@ public:
return 0;
}
- if (!can_iter)
+ if (!can_iter) {
return 1; //nothing to iterate
+ }
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
@@ -462,7 +436,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptIterator::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceIterator *instance = memnew(VisualScriptNodeInstanceIterator);
instance->node = this;
instance->instance = p_instance;
@@ -477,62 +450,56 @@ VisualScriptIterator::VisualScriptIterator() {
//////////////////////////////////////////
int VisualScriptSequence::get_output_sequence_port_count() const {
-
return steps;
}
bool VisualScriptSequence::has_input_sequence_port() const {
-
return true;
}
int VisualScriptSequence::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptSequence::get_output_value_port_count() const {
+int VisualScriptSequence::get_output_value_port_count() const {
return 1;
}
String VisualScriptSequence::get_output_sequence_port_text(int p_port) const {
-
return itos(p_port + 1);
}
PropertyInfo VisualScriptSequence::get_input_value_port_info(int p_idx) const {
return PropertyInfo();
}
+
PropertyInfo VisualScriptSequence::get_output_value_port_info(int p_idx) const {
return PropertyInfo(Variant::INT, "current");
}
-String VisualScriptSequence::get_caption() const {
+String VisualScriptSequence::get_caption() const {
return "Sequence";
}
String VisualScriptSequence::get_text() const {
-
return "in order: ";
}
void VisualScriptSequence::set_steps(int p_steps) {
-
ERR_FAIL_COND(p_steps < 1);
- if (steps == p_steps)
+ if (steps == p_steps) {
return;
+ }
steps = p_steps;
ports_changed_notify();
}
int VisualScriptSequence::get_steps() const {
-
return steps;
}
void VisualScriptSequence::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_steps", "steps"), &VisualScriptSequence::set_steps);
ClassDB::bind_method(D_METHOD("get_steps"), &VisualScriptSequence::get_steps);
@@ -550,9 +517,7 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
-
p_working_mem[0] = 0;
}
@@ -560,9 +525,9 @@ public:
*p_outputs[0] = step;
- if (step + 1 == steps)
+ if (step + 1 == steps) {
return step;
- else {
+ } else {
p_working_mem[0] = step + 1;
return step | STEP_FLAG_PUSH_STACK_BIT;
}
@@ -570,15 +535,14 @@ public:
};
VisualScriptNodeInstance *VisualScriptSequence::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSequence *instance = memnew(VisualScriptNodeInstanceSequence);
instance->node = this;
instance->instance = p_instance;
instance->steps = steps;
return instance;
}
-VisualScriptSequence::VisualScriptSequence() {
+VisualScriptSequence::VisualScriptSequence() {
steps = 1;
}
@@ -587,52 +551,46 @@ VisualScriptSequence::VisualScriptSequence() {
//////////////////////////////////////////
int VisualScriptSwitch::get_output_sequence_port_count() const {
-
return case_values.size() + 1;
}
bool VisualScriptSwitch::has_input_sequence_port() const {
-
return true;
}
int VisualScriptSwitch::get_input_value_port_count() const {
-
return case_values.size() + 1;
}
-int VisualScriptSwitch::get_output_value_port_count() const {
+int VisualScriptSwitch::get_output_value_port_count() const {
return 0;
}
String VisualScriptSwitch::get_output_sequence_port_text(int p_port) const {
-
- if (p_port == case_values.size())
+ if (p_port == case_values.size()) {
return "done";
+ }
return String();
}
PropertyInfo VisualScriptSwitch::get_input_value_port_info(int p_idx) const {
-
if (p_idx < case_values.size()) {
return PropertyInfo(case_values[p_idx].type, " =");
- } else
+ } else {
return PropertyInfo(Variant::NIL, "input");
+ }
}
PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptSwitch::get_caption() const {
-
return "Switch";
}
String VisualScriptSwitch::get_text() const {
-
return "'input' is:";
}
@@ -646,13 +604,11 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
return case_count; //exit
}
for (int i = 0; i < case_count; i++) {
-
if (*p_inputs[i] == *p_inputs[case_count]) {
return i | STEP_FLAG_PUSH_STACK_BIT;
}
@@ -663,7 +619,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSwitch *instance = memnew(VisualScriptNodeInstanceSwitch);
instance->instance = p_instance;
instance->case_count = case_values.size();
@@ -671,7 +626,6 @@ VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_i
}
bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) {
-
if (String(p_name) == "case_count") {
case_values.resize(p_value);
_change_notify();
@@ -680,7 +634,6 @@ bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value)
}
if (String(p_name).begins_with("case/")) {
-
int idx = String(p_name).get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
@@ -695,14 +648,12 @@ bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value)
}
bool VisualScriptSwitch::_get(const StringName &p_name, Variant &r_ret) const {
-
if (String(p_name) == "case_count") {
r_ret = case_values.size();
return true;
}
if (String(p_name).begins_with("case/")) {
-
int idx = String(p_name).get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
@@ -712,8 +663,8 @@ bool VisualScriptSwitch::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void VisualScriptSwitch::_get_property_list(List<PropertyInfo> *p_list) const {
+void VisualScriptSwitch::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "case_count", PROPERTY_HINT_RANGE, "0,128"));
String argt = "Any";
@@ -737,56 +688,49 @@ VisualScriptSwitch::VisualScriptSwitch() {
//////////////////////////////////////////
int VisualScriptTypeCast::get_output_sequence_port_count() const {
-
return 2;
}
bool VisualScriptTypeCast::has_input_sequence_port() const {
-
return true;
}
int VisualScriptTypeCast::get_input_value_port_count() const {
-
return 1;
}
-int VisualScriptTypeCast::get_output_value_port_count() const {
+int VisualScriptTypeCast::get_output_value_port_count() const {
return 1;
}
String VisualScriptTypeCast::get_output_sequence_port_text(int p_port) const {
-
return p_port == 0 ? "yes" : "no";
}
PropertyInfo VisualScriptTypeCast::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::OBJECT, "instance");
}
PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_TYPE_STRING, get_base_type());
}
String VisualScriptTypeCast::get_caption() const {
-
return "Type Cast";
}
String VisualScriptTypeCast::get_text() const {
-
- if (script != String())
+ if (script != String()) {
return "Is " + script.get_file() + "?";
- else
+ } else {
return "Is " + base_type + "?";
+ }
}
void VisualScriptTypeCast::set_base_type(const StringName &p_type) {
-
- if (base_type == p_type)
+ if (base_type == p_type) {
return;
+ }
base_type = p_type;
_change_notify();
@@ -794,26 +738,24 @@ void VisualScriptTypeCast::set_base_type(const StringName &p_type) {
}
StringName VisualScriptTypeCast::get_base_type() const {
-
return base_type;
}
void VisualScriptTypeCast::set_base_script(const String &p_path) {
-
- if (script == p_path)
+ if (script == p_path) {
return;
+ }
script = p_path;
_change_notify();
ports_changed_notify();
}
-String VisualScriptTypeCast::get_base_script() const {
+String VisualScriptTypeCast::get_base_script() const {
return script;
}
VisualScriptTypeCast::TypeGuess VisualScriptTypeCast::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
TypeGuess tg;
tg.type = Variant::OBJECT;
if (script != String()) {
@@ -837,7 +779,6 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
Object *obj = *p_inputs[0];
*p_outputs[0] = Variant();
@@ -849,7 +790,6 @@ public:
}
if (script != String()) {
-
Ref<Script> obj_script = obj->get_script();
if (!obj_script.is_valid()) {
return 1; //well, definitely not the script because object we got has no script.
@@ -867,7 +807,6 @@ public:
}
while (obj_script.is_valid()) {
-
if (cast_script == obj_script) {
*p_outputs[0] = *p_inputs[0]; //copy
return 0; // it is the script, yey
@@ -882,13 +821,13 @@ public:
if (ClassDB::is_parent_class(obj->get_class_name(), base_type)) {
*p_outputs[0] = *p_inputs[0]; //copy
return 0;
- } else
+ } else {
return 1;
+ }
}
};
VisualScriptNodeInstance *VisualScriptTypeCast::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceTypeCast *instance = memnew(VisualScriptNodeInstanceTypeCast);
instance->instance = p_instance;
instance->base_type = base_type;
@@ -897,7 +836,6 @@ VisualScriptNodeInstance *VisualScriptTypeCast::instance(VisualScriptInstance *p
}
void VisualScriptTypeCast::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_base_type", "type"), &VisualScriptTypeCast::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptTypeCast::get_base_type);
@@ -911,8 +849,9 @@ void VisualScriptTypeCast::_bind_methods() {
String script_ext_hint;
for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
- if (script_ext_hint != String())
+ if (script_ext_hint != String()) {
script_ext_hint += ",";
+ }
script_ext_hint += "*." + E->get();
}
@@ -921,12 +860,10 @@ void VisualScriptTypeCast::_bind_methods() {
}
VisualScriptTypeCast::VisualScriptTypeCast() {
-
base_type = "Object";
}
void register_visual_script_flow_control_nodes() {
-
VisualScriptLanguage::singleton->add_register_func("flow_control/return", create_return_node<false>);
VisualScriptLanguage::singleton->add_register_func("flow_control/return_with_value", create_return_node<true>);
VisualScriptLanguage::singleton->add_register_func("flow_control/condition", create_node_generic<VisualScriptCondition>);
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index 8597d051db..45b56b3073 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -34,7 +34,6 @@
#include "visual_script.h"
class VisualScriptReturn : public VisualScriptNode {
-
GDCLASS(VisualScriptReturn, VisualScriptNode);
Variant::Type type;
@@ -71,7 +70,6 @@ public:
};
class VisualScriptCondition : public VisualScriptNode {
-
GDCLASS(VisualScriptCondition, VisualScriptNode);
protected:
@@ -99,7 +97,6 @@ public:
};
class VisualScriptWhile : public VisualScriptNode {
-
GDCLASS(VisualScriptWhile, VisualScriptNode);
protected:
@@ -127,7 +124,6 @@ public:
};
class VisualScriptIterator : public VisualScriptNode {
-
GDCLASS(VisualScriptIterator, VisualScriptNode);
protected:
@@ -155,7 +151,6 @@ public:
};
class VisualScriptSequence : public VisualScriptNode {
-
GDCLASS(VisualScriptSequence, VisualScriptNode);
int steps;
@@ -188,7 +183,6 @@ public:
};
class VisualScriptSwitch : public VisualScriptNode {
-
GDCLASS(VisualScriptSwitch, VisualScriptNode);
struct Case {
@@ -230,7 +224,6 @@ public:
};
class VisualScriptTypeCast : public VisualScriptNode {
-
GDCLASS(VisualScriptTypeCast, VisualScriptNode);
StringName base_type;
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 3b6ae369ae..f13377f3c8 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -42,33 +42,34 @@
//////////////////////////////////////////
int VisualScriptFunctionCall::get_output_sequence_port_count() const {
-
- if ((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function)))
+ if ((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))) {
return 0;
- else
+ } else {
return 1;
+ }
}
bool VisualScriptFunctionCall::has_input_sequence_port() const {
-
return !((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function)));
}
#ifdef TOOLS_ENABLED
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
- if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
+ if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
return nullptr;
+ }
Ref<Script> scr = p_current_node->get_script();
- if (scr.is_valid() && scr == script)
+ if (scr.is_valid() && scr == script) {
return p_current_node;
+ }
for (int i = 0; i < p_current_node->get_child_count(); i++) {
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
- if (n)
+ if (n) {
return n;
+ }
}
return nullptr;
@@ -76,30 +77,34 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
#endif
Node *VisualScriptFunctionCall::_get_base_node() const {
-
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return nullptr;
+ }
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
- if (!scene_tree)
+ if (!scene_tree) {
return nullptr;
+ }
Node *edited_scene = scene_tree->get_edited_scene_root();
- if (!edited_scene)
+ if (!edited_scene) {
return nullptr;
+ }
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
- if (!script_node)
+ if (!script_node) {
return nullptr;
+ }
- if (!script_node->has_node(base_path))
+ if (!script_node->has_node(base_path)) {
return nullptr;
+ }
Node *path_to = script_node->get_node(base_path);
@@ -111,26 +116,24 @@ Node *VisualScriptFunctionCall::_get_base_node() const {
}
StringName VisualScriptFunctionCall::_get_base_type() const {
-
- if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid())
+ if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
return get_visual_script()->get_instance_base_type();
- else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
+ } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
Node *path = _get_base_node();
- if (path)
+ if (path) {
return path->get_class();
+ }
}
return base_type;
}
int VisualScriptFunctionCall::get_input_value_port_count() const {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type, function);
return types.size() + (rpc_call_mode >= RPC_RELIABLE_TO_ID ? 1 : 0) + 1;
} else {
-
MethodBind *mb = ClassDB::get_method(_get_base_type(), function);
if (mb) {
int defaulted_args = mb->get_argument_count() < use_default_args ? mb->get_argument_count() : use_default_args;
@@ -141,10 +144,9 @@ int VisualScriptFunctionCall::get_input_value_port_count() const {
return method_cache.arguments.size() + (call_mode == CALL_MODE_INSTANCE ? 1 : 0) + (rpc_call_mode >= RPC_RELIABLE_TO_ID ? 1 : 0) - defaulted_args;
}
}
-int VisualScriptFunctionCall::get_output_value_port_count() const {
+int VisualScriptFunctionCall::get_output_value_port_count() const {
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
bool returns = false;
Variant::get_method_return_type(basic_type, function, &returns);
return returns ? 1 : 0;
@@ -154,8 +156,9 @@ int VisualScriptFunctionCall::get_output_value_port_count() const {
MethodBind *mb = ClassDB::get_method(_get_base_type(), function);
if (mb) {
ret = mb->has_return() ? 1 : 0;
- } else
+ } else {
ret = 1; //it is assumed that script always returns something
+ }
if (call_mode == CALL_MODE_INSTANCE) {
ret++;
@@ -166,12 +169,10 @@ int VisualScriptFunctionCall::get_output_value_port_count() const {
}
String VisualScriptFunctionCall::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) const {
-
if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) {
if (p_idx == 0) {
PropertyInfo pi;
@@ -184,7 +185,6 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons
}
if (rpc_call_mode >= RPC_RELIABLE_TO_ID) {
-
if (p_idx == 0) {
return PropertyInfo(Variant::INT, "peer_id");
} else {
@@ -195,13 +195,11 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons
#ifdef DEBUG_METHODS_ENABLED
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
Vector<StringName> names = Variant::get_method_argument_names(basic_type, function);
Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type, function);
return PropertyInfo(types[p_idx], names[p_idx]);
} else {
-
MethodBind *mb = ClassDB::get_method(_get_base_type(), function);
if (mb) {
return mb->get_argument_info(p_idx);
@@ -219,14 +217,11 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons
}
PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) const {
-
#ifdef DEBUG_METHODS_ENABLED
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
return PropertyInfo(Variant::get_method_return_type(basic_type, function), "");
} else {
-
if (call_mode == CALL_MODE_INSTANCE) {
if (p_idx == 0) {
return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type());
@@ -260,20 +255,21 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con
}
String VisualScriptFunctionCall::get_caption() const {
- if (call_mode == CALL_MODE_SELF)
+ if (call_mode == CALL_MODE_SELF) {
return " " + String(function) + "()";
- if (call_mode == CALL_MODE_SINGLETON)
+ }
+ if (call_mode == CALL_MODE_SINGLETON) {
return String(singleton) + ":" + String(function) + "()";
- else if (call_mode == CALL_MODE_BASIC_TYPE)
+ } else if (call_mode == CALL_MODE_BASIC_TYPE) {
return Variant::get_type_name(basic_type) + "." + String(function) + "()";
- else if (call_mode == CALL_MODE_NODE_PATH)
+ } else if (call_mode == CALL_MODE_NODE_PATH) {
return " [" + String(base_path.simplified()) + "]." + String(function) + "()";
- else
+ } else {
return " " + base_type + "." + String(function) + "()";
+ }
}
String VisualScriptFunctionCall::get_text() const {
-
if (rpc_call_mode) {
return "RPC";
}
@@ -281,9 +277,9 @@ String VisualScriptFunctionCall::get_text() const {
}
void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
-
- if (basic_type == p_type)
+ if (basic_type == p_type) {
return;
+ }
basic_type = p_type;
_change_notify();
@@ -291,14 +287,13 @@ void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
}
Variant::Type VisualScriptFunctionCall::get_basic_type() const {
-
return basic_type;
}
void VisualScriptFunctionCall::set_base_type(const StringName &p_type) {
-
- if (base_type == p_type)
+ if (base_type == p_type) {
return;
+ }
base_type = p_type;
_change_notify();
@@ -306,14 +301,13 @@ void VisualScriptFunctionCall::set_base_type(const StringName &p_type) {
}
StringName VisualScriptFunctionCall::get_base_type() const {
-
return base_type;
}
void VisualScriptFunctionCall::set_base_script(const String &p_path) {
-
- if (base_script == p_path)
+ if (base_script == p_path) {
return;
+ }
base_script = p_path;
_change_notify();
@@ -321,14 +315,13 @@ void VisualScriptFunctionCall::set_base_script(const String &p_path) {
}
String VisualScriptFunctionCall::get_base_script() const {
-
return base_script;
}
void VisualScriptFunctionCall::set_singleton(const StringName &p_type) {
-
- if (singleton == p_type)
+ if (singleton == p_type) {
return;
+ }
singleton = p_type;
Object *obj = Engine::get_singleton()->get_singleton_object(singleton);
@@ -341,7 +334,6 @@ void VisualScriptFunctionCall::set_singleton(const StringName &p_type) {
}
StringName VisualScriptFunctionCall::get_singleton() const {
-
return singleton;
}
@@ -350,7 +342,6 @@ void VisualScriptFunctionCall::_update_method_cache() {
Ref<Script> script;
if (call_mode == CALL_MODE_NODE_PATH) {
-
Node *node = _get_base_node();
if (node) {
type = node->get_class();
@@ -358,7 +349,6 @@ void VisualScriptFunctionCall::_update_method_cache() {
script = node->get_script();
}
} else if (call_mode == CALL_MODE_SELF) {
-
if (get_visual_script().is_valid()) {
type = get_visual_script()->get_instance_base_type();
base_type = type; //cache, too
@@ -366,7 +356,6 @@ void VisualScriptFunctionCall::_update_method_cache() {
}
} else if (call_mode == CALL_MODE_SINGLETON) {
-
Object *obj = Engine::get_singleton()->get_singleton_object(singleton);
if (obj) {
type = obj->get_class();
@@ -374,17 +363,13 @@ void VisualScriptFunctionCall::_update_method_cache() {
}
} else if (call_mode == CALL_MODE_INSTANCE) {
-
type = base_type;
if (base_script != String()) {
-
if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) {
-
ScriptServer::edit_request_func(base_script); //make sure it's loaded
}
if (ResourceCache::has(base_script)) {
-
script = Ref<Resource>(ResourceCache::get(base_script));
} else {
return;
@@ -421,16 +406,15 @@ void VisualScriptFunctionCall::_update_method_cache() {
}
}
} else if (script.is_valid() && script->has_method(function)) {
-
method_cache = script->get_method_info(function);
use_default_args = method_cache.default_arguments.size();
}
}
void VisualScriptFunctionCall::set_function(const StringName &p_type) {
-
- if (function == p_type)
+ if (function == p_type) {
return;
+ }
function = p_type;
@@ -445,15 +429,15 @@ void VisualScriptFunctionCall::set_function(const StringName &p_type) {
_change_notify();
ports_changed_notify();
}
-StringName VisualScriptFunctionCall::get_function() const {
+StringName VisualScriptFunctionCall::get_function() const {
return function;
}
void VisualScriptFunctionCall::set_base_path(const NodePath &p_type) {
-
- if (base_path == p_type)
+ if (base_path == p_type) {
return;
+ }
base_path = p_type;
_change_notify();
@@ -461,59 +445,54 @@ void VisualScriptFunctionCall::set_base_path(const NodePath &p_type) {
}
NodePath VisualScriptFunctionCall::get_base_path() const {
-
return base_path;
}
void VisualScriptFunctionCall::set_call_mode(CallMode p_mode) {
-
- if (call_mode == p_mode)
+ if (call_mode == p_mode) {
return;
+ }
call_mode = p_mode;
_change_notify();
ports_changed_notify();
}
-VisualScriptFunctionCall::CallMode VisualScriptFunctionCall::get_call_mode() const {
+VisualScriptFunctionCall::CallMode VisualScriptFunctionCall::get_call_mode() const {
return call_mode;
}
void VisualScriptFunctionCall::set_use_default_args(int p_amount) {
-
- if (use_default_args == p_amount)
+ if (use_default_args == p_amount) {
return;
+ }
use_default_args = p_amount;
ports_changed_notify();
}
void VisualScriptFunctionCall::set_rpc_call_mode(VisualScriptFunctionCall::RPCCallMode p_mode) {
-
- if (rpc_call_mode == p_mode)
+ if (rpc_call_mode == p_mode) {
return;
+ }
rpc_call_mode = p_mode;
ports_changed_notify();
_change_notify();
}
VisualScriptFunctionCall::RPCCallMode VisualScriptFunctionCall::get_rpc_call_mode() const {
-
return rpc_call_mode;
}
int VisualScriptFunctionCall::get_use_default_args() const {
-
return use_default_args;
}
void VisualScriptFunctionCall::set_validate(bool p_amount) {
-
validate = p_amount;
}
bool VisualScriptFunctionCall::get_validate() const {
-
return validate;
}
@@ -523,12 +502,10 @@ void VisualScriptFunctionCall::_set_argument_cache(const Dictionary &p_cache) {
}
Dictionary VisualScriptFunctionCall::_get_argument_cache() const {
-
return method_cache;
}
void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const {
-
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
@@ -556,8 +533,9 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
property.hint = PROPERTY_HINT_ENUM;
String sl;
for (List<Engine::Singleton>::Element *E = names.front(); E; E = E->next()) {
- if (sl != String())
+ if (sl != String()) {
sl += ",";
+ }
sl += E->get().name;
}
property.hint_string = sl;
@@ -568,7 +546,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
-
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
@@ -577,9 +554,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
if (property.name == "function") {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
property.hint = PROPERTY_HINT_METHOD_OF_VARIANT_TYPE;
property.hint_string = Variant::get_type_name(basic_type);
@@ -587,13 +562,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT;
property.hint_string = itos(get_visual_script()->get_instance_id());
} else if (call_mode == CALL_MODE_SINGLETON) {
-
Object *obj = Engine::get_singleton()->get_singleton_object(singleton);
if (obj) {
property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE;
property.hint_string = itos(obj->get_instance_id());
} else {
-
property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE;
property.hint_string = base_type; //should be cached
}
@@ -603,15 +576,12 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
if (base_script != String()) {
if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) {
-
ScriptServer::edit_request_func(base_script); //make sure it's loaded
}
if (ResourceCache::has(base_script)) {
-
Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script));
if (script.is_valid()) {
-
property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT;
property.hint_string = itos(script->get_instance_id());
}
@@ -631,18 +601,15 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
if (property.name == "use_default_args") {
-
property.hint = PROPERTY_HINT_RANGE;
int mc = 0;
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
mc = Variant::get_method_default_arguments(basic_type, function).size();
} else {
MethodBind *mb = ClassDB::get_method(_get_base_type(), function);
if (mb) {
-
mc = mb->get_default_argument_count();
}
}
@@ -650,7 +617,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
if (mc == 0) {
property.usage = 0; //do not show
} else {
-
property.hint_string = "0," + itos(mc) + ",1";
}
}
@@ -663,7 +629,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
}
void VisualScriptFunctionCall::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptFunctionCall::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptFunctionCall::get_base_type);
@@ -699,8 +664,9 @@ void VisualScriptFunctionCall::_bind_methods() {
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i > 0)
+ if (i > 0) {
bt += ",";
+ }
bt += Variant::get_type_name(Variant::Type(i));
}
@@ -712,8 +678,9 @@ void VisualScriptFunctionCall::_bind_methods() {
String script_ext_hint;
for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
- if (script_ext_hint != String())
+ if (script_ext_hint != String()) {
script_ext_hint += ",";
+ }
script_ext_hint += "*." + E->get();
}
@@ -761,13 +728,14 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
_FORCE_INLINE_ bool call_rpc(Object *p_base, const Variant **p_args, int p_argcount) {
-
- if (!p_base)
+ if (!p_base) {
return false;
+ }
Node *node = Object::cast_to<Node>(p_base);
- if (!node)
+ if (!node) {
return false;
+ }
int to_id = 0;
bool reliable = true;
@@ -789,11 +757,8 @@ public:
}
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
switch (call_mode) {
-
case VisualScriptFunctionCall::CALL_MODE_SELF: {
-
Object *object = instance->get_owner_ptr();
if (rpc_mode) {
@@ -805,7 +770,6 @@ public:
}
} break;
case VisualScriptFunctionCall::CALL_MODE_NODE_PATH: {
-
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -831,7 +795,6 @@ public:
} break;
case VisualScriptFunctionCall::CALL_MODE_INSTANCE:
case VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE: {
-
Variant v = *p_inputs[0];
if (rpc_mode) {
@@ -863,7 +826,6 @@ public:
} break;
case VisualScriptFunctionCall::CALL_MODE_SINGLETON: {
-
Object *object = Engine::get_singleton()->get_singleton_object(singleton);
if (!object) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -882,7 +844,6 @@ public:
}
if (!validate) {
-
//ignore call errors if validation is disabled
r_error.error = Callable::CallError::CALL_OK;
r_error_str = String();
@@ -893,7 +854,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceFunctionCall *instance = memnew(VisualScriptNodeInstanceFunctionCall);
instance->node = this;
instance->instance = p_instance;
@@ -909,7 +869,6 @@ VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstanc
}
VisualScriptFunctionCall::TypeGuess VisualScriptFunctionCall::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
if (p_output == 0 && call_mode == CALL_MODE_INSTANCE) {
return p_inputs[0];
}
@@ -918,7 +877,6 @@ VisualScriptFunctionCall::TypeGuess VisualScriptFunctionCall::guess_output_type(
}
VisualScriptFunctionCall::VisualScriptFunctionCall() {
-
validate = true;
call_mode = CALL_MODE_SELF;
basic_type = Variant::NIL;
@@ -929,7 +887,6 @@ VisualScriptFunctionCall::VisualScriptFunctionCall() {
template <VisualScriptFunctionCall::CallMode cmode>
static Ref<VisualScriptNode> create_function_call_node(const String &p_name) {
-
Ref<VisualScriptFunctionCall> node;
node.instance();
node->set_call_mode(cmode);
@@ -941,41 +898,43 @@ static Ref<VisualScriptNode> create_function_call_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptPropertySet::get_output_sequence_port_count() const {
-
return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0;
}
bool VisualScriptPropertySet::has_input_sequence_port() const {
-
return call_mode != CALL_MODE_BASIC_TYPE;
}
Node *VisualScriptPropertySet::_get_base_node() const {
-
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return nullptr;
+ }
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
- if (!scene_tree)
+ if (!scene_tree) {
return nullptr;
+ }
Node *edited_scene = scene_tree->get_edited_scene_root();
- if (!edited_scene)
+ if (!edited_scene) {
return nullptr;
+ }
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
- if (!script_node)
+ if (!script_node) {
return nullptr;
+ }
- if (!script_node->has_node(base_path))
+ if (!script_node->has_node(base_path)) {
return nullptr;
+ }
Node *path_to = script_node->get_node(base_path);
@@ -987,38 +946,34 @@ Node *VisualScriptPropertySet::_get_base_node() const {
}
StringName VisualScriptPropertySet::_get_base_type() const {
-
- if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid())
+ if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
return get_visual_script()->get_instance_base_type();
- else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
+ } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
Node *path = _get_base_node();
- if (path)
+ if (path) {
return path->get_class();
+ }
}
return base_type;
}
int VisualScriptPropertySet::get_input_value_port_count() const {
-
int pc = (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 2 : 1;
return pc;
}
-int VisualScriptPropertySet::get_output_value_port_count() const {
+int VisualScriptPropertySet::get_output_value_port_count() const {
return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0;
}
String VisualScriptPropertySet::get_output_sequence_port_text(int p_port) const {
-
return String();
}
void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const {
-
if (index != StringName()) {
-
Variant v;
Callable::CallError ce;
v = Variant::construct(pinfo.type, nullptr, 0, ce);
@@ -1065,7 +1020,6 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptPropertySet::get_caption() const {
-
static const char *opname[ASSIGN_OP_MAX] = {
"Set", "Add", "Subtract", "Multiply", "Divide", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor"
};
@@ -1079,7 +1033,6 @@ String VisualScriptPropertySet::get_caption() const {
}
String VisualScriptPropertySet::get_text() const {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
return String("On ") + Variant::get_type_name(basic_type);
}
@@ -1096,22 +1049,21 @@ String VisualScriptPropertySet::get_text() const {
void VisualScriptPropertySet::_update_base_type() {
//cache it because this information may not be available on load
if (call_mode == CALL_MODE_NODE_PATH) {
-
Node *node = _get_base_node();
if (node) {
base_type = node->get_class();
}
} else if (call_mode == CALL_MODE_SELF) {
-
if (get_visual_script().is_valid()) {
base_type = get_visual_script()->get_instance_base_type();
}
}
}
-void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) {
- if (basic_type == p_type)
+void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) {
+ if (basic_type == p_type) {
return;
+ }
basic_type = p_type;
_change_notify();
@@ -1120,14 +1072,13 @@ void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) {
}
Variant::Type VisualScriptPropertySet::get_basic_type() const {
-
return basic_type;
}
void VisualScriptPropertySet::set_base_type(const StringName &p_type) {
-
- if (base_type == p_type)
+ if (base_type == p_type) {
return;
+ }
base_type = p_type;
_change_notify();
@@ -1135,14 +1086,13 @@ void VisualScriptPropertySet::set_base_type(const StringName &p_type) {
}
StringName VisualScriptPropertySet::get_base_type() const {
-
return base_type;
}
void VisualScriptPropertySet::set_base_script(const String &p_path) {
-
- if (base_script == p_path)
+ if (base_script == p_path) {
return;
+ }
base_script = p_path;
_change_notify();
@@ -1150,20 +1100,19 @@ void VisualScriptPropertySet::set_base_script(const String &p_path) {
}
String VisualScriptPropertySet::get_base_script() const {
-
return base_script;
}
void VisualScriptPropertySet::_update_cache() {
-
- if (!Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop()))
+ if (!Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop())) {
return;
+ }
- if (!Engine::get_singleton()->is_editor_hint()) //only update cache if editor exists, it's pointless otherwise
+ if (!Engine::get_singleton()->is_editor_hint()) { //only update cache if editor exists, it's pointless otherwise
return;
+ }
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
//not super efficient..
Variant v;
@@ -1174,21 +1123,17 @@ void VisualScriptPropertySet::_update_cache() {
v.get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
if (E->get().name == property) {
-
type_cache = E->get();
}
}
} else {
-
StringName type;
Ref<Script> script;
Node *node = nullptr;
if (call_mode == CALL_MODE_NODE_PATH) {
-
node = _get_base_node();
if (node) {
type = node->get_class();
@@ -1196,24 +1141,19 @@ void VisualScriptPropertySet::_update_cache() {
script = node->get_script();
}
} else if (call_mode == CALL_MODE_SELF) {
-
if (get_visual_script().is_valid()) {
type = get_visual_script()->get_instance_base_type();
base_type = type; //cache, too
script = get_visual_script();
}
} else if (call_mode == CALL_MODE_INSTANCE) {
-
type = base_type;
if (base_script != String()) {
-
if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) {
-
ScriptServer::edit_request_func(base_script); //make sure it's loaded
}
if (ResourceCache::has(base_script)) {
-
script = Ref<Resource>(ResourceCache::get(base_script));
} else {
return;
@@ -1224,19 +1164,16 @@ void VisualScriptPropertySet::_update_cache() {
List<PropertyInfo> pinfo;
if (node) {
-
node->get_property_list(&pinfo);
} else {
ClassDB::get_property_list(type, &pinfo);
}
if (script.is_valid()) {
-
script->get_script_property_list(&pinfo);
}
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
if (E->get().name == property) {
type_cache = E->get();
return;
@@ -1246,9 +1183,9 @@ void VisualScriptPropertySet::_update_cache() {
}
void VisualScriptPropertySet::set_property(const StringName &p_type) {
-
- if (property == p_type)
+ if (property == p_type) {
return;
+ }
property = p_type;
index = StringName();
@@ -1256,15 +1193,15 @@ void VisualScriptPropertySet::set_property(const StringName &p_type) {
_change_notify();
ports_changed_notify();
}
-StringName VisualScriptPropertySet::get_property() const {
+StringName VisualScriptPropertySet::get_property() const {
return property;
}
void VisualScriptPropertySet::set_base_path(const NodePath &p_type) {
-
- if (base_path == p_type)
+ if (base_path == p_type) {
return;
+ }
base_path = p_type;
_update_base_type();
@@ -1273,22 +1210,21 @@ void VisualScriptPropertySet::set_base_path(const NodePath &p_type) {
}
NodePath VisualScriptPropertySet::get_base_path() const {
-
return base_path;
}
void VisualScriptPropertySet::set_call_mode(CallMode p_mode) {
-
- if (call_mode == p_mode)
+ if (call_mode == p_mode) {
return;
+ }
call_mode = p_mode;
_update_base_type();
_change_notify();
ports_changed_notify();
}
-VisualScriptPropertySet::CallMode VisualScriptPropertySet::get_call_mode() const {
+VisualScriptPropertySet::CallMode VisualScriptPropertySet::get_call_mode() const {
return call_mode;
}
@@ -1297,14 +1233,13 @@ void VisualScriptPropertySet::_set_type_cache(const Dictionary &p_type) {
}
Dictionary VisualScriptPropertySet::_get_type_cache() const {
-
return type_cache;
}
void VisualScriptPropertySet::set_index(const StringName &p_type) {
-
- if (index == p_type)
+ if (index == p_type) {
return;
+ }
index = p_type;
_update_cache();
_change_notify();
@@ -1312,15 +1247,14 @@ void VisualScriptPropertySet::set_index(const StringName &p_type) {
}
StringName VisualScriptPropertySet::get_index() const {
-
return index;
}
void VisualScriptPropertySet::set_assign_op(AssignOp p_op) {
-
ERR_FAIL_INDEX(p_op, ASSIGN_OP_MAX);
- if (assign_op == p_op)
+ if (assign_op == p_op) {
return;
+ }
assign_op = p_op;
_update_cache();
@@ -1333,7 +1267,6 @@ VisualScriptPropertySet::AssignOp VisualScriptPropertySet::get_assign_op() const
}
void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
-
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
@@ -1356,7 +1289,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
-
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
@@ -1365,9 +1297,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
}
if (property.name == "property") {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
property.hint = PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE;
property.hint_string = Variant::get_type_name(basic_type);
@@ -1380,15 +1310,12 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (base_script != String()) {
if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) {
-
ScriptServer::edit_request_func(base_script); //make sure it's loaded
}
if (ResourceCache::has(base_script)) {
-
Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script));
if (script.is_valid()) {
-
property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT;
property.hint_string = itos(script->get_instance_id());
}
@@ -1408,7 +1335,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
}
if (property.name == "index") {
-
Callable::CallError ce;
Variant v = Variant::construct(type_cache.type, nullptr, 0, ce);
List<PropertyInfo> plist;
@@ -1421,13 +1347,13 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
property.hint = PROPERTY_HINT_ENUM;
property.hint_string = options;
property.type = Variant::STRING;
- if (options == "")
+ if (options == "") {
property.usage = 0; //hide if type has no usable index
+ }
}
}
void VisualScriptPropertySet::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptPropertySet::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptPropertySet::get_base_type);
@@ -1457,8 +1383,9 @@ void VisualScriptPropertySet::_bind_methods() {
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i > 0)
+ if (i > 0) {
bt += ",";
+ }
bt += Variant::get_type_name(Variant::Type(i));
}
@@ -1470,8 +1397,9 @@ void VisualScriptPropertySet::_bind_methods() {
String script_ext_hint;
for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
- if (script_ext_hint != String())
+ if (script_ext_hint != String()) {
script_ext_hint += ",";
+ }
script_ext_hint += "*." + E->get();
}
@@ -1520,11 +1448,9 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
_FORCE_INLINE_ void _process_get(Variant &source, const Variant &p_argument, bool &valid) {
-
if (index != StringName() && assign_op == VisualScriptPropertySet::ASSIGN_OP_NONE) {
source.set_named(index, p_argument, &valid);
} else {
-
Variant value;
if (index != StringName()) {
value = source.get_named(index, &valid);
@@ -1579,11 +1505,8 @@ public:
}
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
switch (call_mode) {
-
case VisualScriptPropertySet::CALL_MODE_SELF: {
-
Object *object = instance->get_owner_ptr();
bool valid;
@@ -1602,7 +1525,6 @@ public:
}
} break;
case VisualScriptPropertySet::CALL_MODE_NODE_PATH: {
-
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -1620,7 +1542,6 @@ public:
bool valid;
if (needs_get) {
-
Variant value = another->get(property, &valid);
_process_get(value, *p_inputs[0], valid);
another->set(property, value, &valid);
@@ -1636,7 +1557,6 @@ public:
} break;
case VisualScriptPropertySet::CALL_MODE_INSTANCE:
case VisualScriptPropertySet::CALL_MODE_BASIC_TYPE: {
-
Variant v = *p_inputs[0];
bool valid;
@@ -1664,7 +1584,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstancePropertySet *instance = memnew(VisualScriptNodeInstancePropertySet);
instance->node = this;
instance->instance = p_instance;
@@ -1678,15 +1597,14 @@ VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance
}
VisualScriptPropertySet::TypeGuess VisualScriptPropertySet::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
if (p_output == 0 && call_mode == CALL_MODE_INSTANCE) {
return p_inputs[0];
}
return VisualScriptNode::guess_output_type(p_inputs, p_output);
}
-VisualScriptPropertySet::VisualScriptPropertySet() {
+VisualScriptPropertySet::VisualScriptPropertySet() {
assign_op = ASSIGN_OP_NONE;
call_mode = CALL_MODE_SELF;
base_type = "Object";
@@ -1695,7 +1613,6 @@ VisualScriptPropertySet::VisualScriptPropertySet() {
template <VisualScriptPropertySet::CallMode cmode>
static Ref<VisualScriptNode> create_property_set_node(const String &p_name) {
-
Ref<VisualScriptPropertySet> node;
node.instance();
node->set_call_mode(cmode);
@@ -1707,55 +1624,57 @@ static Ref<VisualScriptNode> create_property_set_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptPropertyGet::get_output_sequence_port_count() const {
-
return 0; // (call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?0:1;
}
bool VisualScriptPropertyGet::has_input_sequence_port() const {
-
return false; //(call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?false:true;
}
+
void VisualScriptPropertyGet::_update_base_type() {
//cache it because this information may not be available on load
if (call_mode == CALL_MODE_NODE_PATH) {
-
Node *node = _get_base_node();
if (node) {
base_type = node->get_class();
}
} else if (call_mode == CALL_MODE_SELF) {
-
if (get_visual_script().is_valid()) {
base_type = get_visual_script()->get_instance_base_type();
}
}
}
-Node *VisualScriptPropertyGet::_get_base_node() const {
+Node *VisualScriptPropertyGet::_get_base_node() const {
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return nullptr;
+ }
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
- if (!scene_tree)
+ if (!scene_tree) {
return nullptr;
+ }
Node *edited_scene = scene_tree->get_edited_scene_root();
- if (!edited_scene)
+ if (!edited_scene) {
return nullptr;
+ }
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
- if (!script_node)
+ if (!script_node) {
return nullptr;
+ }
- if (!script_node->has_node(base_path))
+ if (!script_node->has_node(base_path)) {
return nullptr;
+ }
Node *path_to = script_node->get_node(base_path);
@@ -1767,34 +1686,31 @@ Node *VisualScriptPropertyGet::_get_base_node() const {
}
StringName VisualScriptPropertyGet::_get_base_type() const {
-
- if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid())
+ if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
return get_visual_script()->get_instance_base_type();
- else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
+ } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
Node *path = _get_base_node();
- if (path)
+ if (path) {
return path->get_class();
+ }
}
return base_type;
}
int VisualScriptPropertyGet::get_input_value_port_count() const {
-
return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0;
}
-int VisualScriptPropertyGet::get_output_value_port_count() const {
+int VisualScriptPropertyGet::get_output_value_port_count() const {
return 1;
}
String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const {
-
if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) {
if (p_idx == 0) {
PropertyInfo pi;
@@ -1819,12 +1735,10 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptPropertyGet::get_caption() const {
-
return String("Get ") + property;
}
String VisualScriptPropertyGet::get_text() const {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
return String("On ") + Variant::get_type_name(basic_type);
}
@@ -1839,9 +1753,9 @@ String VisualScriptPropertyGet::get_text() const {
}
void VisualScriptPropertyGet::set_base_type(const StringName &p_type) {
-
- if (base_type == p_type)
+ if (base_type == p_type) {
return;
+ }
base_type = p_type;
_change_notify();
@@ -1849,14 +1763,13 @@ void VisualScriptPropertyGet::set_base_type(const StringName &p_type) {
}
StringName VisualScriptPropertyGet::get_base_type() const {
-
return base_type;
}
void VisualScriptPropertyGet::set_base_script(const String &p_path) {
-
- if (base_script == p_path)
+ if (base_script == p_path) {
return;
+ }
base_script = p_path;
_change_notify();
@@ -1864,14 +1777,11 @@ void VisualScriptPropertyGet::set_base_script(const String &p_path) {
}
String VisualScriptPropertyGet::get_base_script() const {
-
return base_script;
}
void VisualScriptPropertyGet::_update_cache() {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
//not super efficient..
Variant v;
@@ -1882,22 +1792,18 @@ void VisualScriptPropertyGet::_update_cache() {
v.get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
if (E->get().name == property) {
-
type_cache = E->get().type;
return;
}
}
} else {
-
StringName type;
Ref<Script> script;
Node *node = nullptr;
if (call_mode == CALL_MODE_NODE_PATH) {
-
node = _get_base_node();
if (node) {
type = node->get_class();
@@ -1905,24 +1811,19 @@ void VisualScriptPropertyGet::_update_cache() {
script = node->get_script();
}
} else if (call_mode == CALL_MODE_SELF) {
-
if (get_visual_script().is_valid()) {
type = get_visual_script()->get_instance_base_type();
base_type = type; //cache, too
script = get_visual_script();
}
} else if (call_mode == CALL_MODE_INSTANCE) {
-
type = base_type;
if (base_script != String()) {
-
if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) {
-
ScriptServer::edit_request_func(base_script); //make sure it's loaded
}
if (ResourceCache::has(base_script)) {
-
script = Ref<Resource>(ResourceCache::get(base_script));
} else {
return;
@@ -1942,7 +1843,6 @@ void VisualScriptPropertyGet::_update_cache() {
}
if (node) {
-
Variant prop = node->get(property, &valid);
if (valid) {
type_cache = prop.get_type();
@@ -1951,7 +1851,6 @@ void VisualScriptPropertyGet::_update_cache() {
}
if (script.is_valid()) {
-
type_ret = script->get_static_property_type(property, &valid);
if (valid) {
@@ -1963,9 +1862,9 @@ void VisualScriptPropertyGet::_update_cache() {
}
void VisualScriptPropertyGet::set_property(const StringName &p_type) {
-
- if (property == p_type)
+ if (property == p_type) {
return;
+ }
property = p_type;
@@ -1973,15 +1872,15 @@ void VisualScriptPropertyGet::set_property(const StringName &p_type) {
_change_notify();
ports_changed_notify();
}
-StringName VisualScriptPropertyGet::get_property() const {
+StringName VisualScriptPropertyGet::get_property() const {
return property;
}
void VisualScriptPropertyGet::set_base_path(const NodePath &p_type) {
-
- if (base_path == p_type)
+ if (base_path == p_type) {
return;
+ }
base_path = p_type;
_change_notify();
@@ -1990,29 +1889,28 @@ void VisualScriptPropertyGet::set_base_path(const NodePath &p_type) {
}
NodePath VisualScriptPropertyGet::get_base_path() const {
-
return base_path;
}
void VisualScriptPropertyGet::set_call_mode(CallMode p_mode) {
-
- if (call_mode == p_mode)
+ if (call_mode == p_mode) {
return;
+ }
call_mode = p_mode;
_change_notify();
_update_base_type();
ports_changed_notify();
}
-VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const {
+VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const {
return call_mode;
}
void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) {
-
- if (basic_type == p_type)
+ if (basic_type == p_type) {
return;
+ }
basic_type = p_type;
_change_notify();
@@ -2020,7 +1918,6 @@ void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) {
}
Variant::Type VisualScriptPropertyGet::get_basic_type() const {
-
return basic_type;
}
@@ -2029,14 +1926,13 @@ void VisualScriptPropertyGet::_set_type_cache(Variant::Type p_type) {
}
Variant::Type VisualScriptPropertyGet::_get_type_cache() const {
-
return type_cache;
}
void VisualScriptPropertyGet::set_index(const StringName &p_type) {
-
- if (index == p_type)
+ if (index == p_type) {
return;
+ }
index = p_type;
_update_cache();
_change_notify();
@@ -2044,12 +1940,10 @@ void VisualScriptPropertyGet::set_index(const StringName &p_type) {
}
StringName VisualScriptPropertyGet::get_index() const {
-
return index;
}
void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
-
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
@@ -2072,7 +1966,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
-
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
@@ -2081,9 +1974,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
}
if (property.name == "property") {
-
if (call_mode == CALL_MODE_BASIC_TYPE) {
-
property.hint = PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE;
property.hint_string = Variant::get_type_name(basic_type);
@@ -2096,15 +1987,12 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (base_script != String()) {
if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) {
-
ScriptServer::edit_request_func(base_script); //make sure it's loaded
}
if (ResourceCache::has(base_script)) {
-
Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script));
if (script.is_valid()) {
-
property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT;
property.hint_string = itos(script->get_instance_id());
}
@@ -2123,7 +2011,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
}
if (property.name == "index") {
-
Callable::CallError ce;
Variant v = Variant::construct(type_cache, nullptr, 0, ce);
List<PropertyInfo> plist;
@@ -2136,13 +2023,13 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
property.hint = PROPERTY_HINT_ENUM;
property.hint_string = options;
property.type = Variant::STRING;
- if (options == "")
+ if (options == "") {
property.usage = 0; //hide if type has no usable index
+ }
}
}
void VisualScriptPropertyGet::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptPropertyGet::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptPropertyGet::get_base_type);
@@ -2169,8 +2056,9 @@ void VisualScriptPropertyGet::_bind_methods() {
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i > 0)
+ if (i > 0) {
bt += ",";
+ }
bt += Variant::get_type_name(Variant::Type(i));
}
@@ -2182,8 +2070,9 @@ void VisualScriptPropertyGet::_bind_methods() {
String script_ext_hint;
for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
- if (script_ext_hint != String())
+ if (script_ext_hint != String()) {
script_ext_hint += ",";
+ }
script_ext_hint += "." + E->get();
}
@@ -2212,11 +2101,8 @@ public:
VisualScriptInstance *instance;
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
switch (call_mode) {
-
case VisualScriptPropertyGet::CALL_MODE_SELF: {
-
Object *object = instance->get_owner_ptr();
bool valid;
@@ -2234,7 +2120,6 @@ public:
}
} break;
case VisualScriptPropertyGet::CALL_MODE_NODE_PATH: {
-
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -2265,7 +2150,6 @@ public:
} break;
default: {
-
bool valid;
Variant v = *p_inputs[0];
@@ -2286,7 +2170,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstancePropertyGet *instance = memnew(VisualScriptNodeInstancePropertyGet);
instance->node = this;
instance->instance = p_instance;
@@ -2299,7 +2182,6 @@ VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance
}
VisualScriptPropertyGet::VisualScriptPropertyGet() {
-
call_mode = CALL_MODE_SELF;
base_type = "Object";
basic_type = Variant::NIL;
@@ -2308,7 +2190,6 @@ VisualScriptPropertyGet::VisualScriptPropertyGet() {
template <VisualScriptPropertyGet::CallMode cmode>
static Ref<VisualScriptNode> create_property_get_node(const String &p_name) {
-
Ref<VisualScriptPropertyGet> node;
node.instance();
node->set_call_mode(cmode);
@@ -2320,44 +2201,40 @@ static Ref<VisualScriptNode> create_property_get_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptEmitSignal::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptEmitSignal::has_input_sequence_port() const {
-
return true;
}
int VisualScriptEmitSignal::get_input_value_port_count() const {
-
Ref<VisualScript> vs = get_visual_script();
if (vs.is_valid()) {
-
- if (!vs->has_custom_signal(name))
+ if (!vs->has_custom_signal(name)) {
return 0;
+ }
return vs->custom_signal_get_argument_count(name);
}
return 0;
}
+
int VisualScriptEmitSignal::get_output_value_port_count() const {
return 0;
}
String VisualScriptEmitSignal::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptEmitSignal::get_input_value_port_info(int p_idx) const {
-
Ref<VisualScript> vs = get_visual_script();
if (vs.is_valid()) {
-
- if (!vs->has_custom_signal(name))
+ if (!vs->has_custom_signal(name)) {
return PropertyInfo();
+ }
return PropertyInfo(vs->custom_signal_get_argument_type(name, p_idx), vs->custom_signal_get_argument_name(name, p_idx));
}
@@ -2366,32 +2243,29 @@ PropertyInfo VisualScriptEmitSignal::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptEmitSignal::get_caption() const {
-
return "Emit " + String(name);
}
void VisualScriptEmitSignal::set_signal(const StringName &p_type) {
-
- if (name == p_type)
+ if (name == p_type) {
return;
+ }
name = p_type;
_change_notify();
ports_changed_notify();
}
-StringName VisualScriptEmitSignal::get_signal() const {
+StringName VisualScriptEmitSignal::get_signal() const {
return name;
}
void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
-
if (property.name == "signal") {
property.hint = PROPERTY_HINT_ENUM;
@@ -2399,15 +2273,14 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
Ref<VisualScript> vs = get_visual_script();
if (vs.is_valid()) {
-
vs->get_custom_signal_list(&sigs);
}
String ml;
for (List<StringName>::Element *E = sigs.front(); E; E = E->next()) {
-
- if (ml != String())
+ if (ml != String()) {
ml += ",";
+ }
ml += E->get();
}
@@ -2416,7 +2289,6 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
}
void VisualScriptEmitSignal::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_signal", "name"), &VisualScriptEmitSignal::set_signal);
ClassDB::bind_method(D_METHOD("get_signal"), &VisualScriptEmitSignal::get_signal);
@@ -2435,7 +2307,6 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
Object *obj = instance->get_owner_ptr();
obj->emit_signal(name, p_inputs, argcount);
@@ -2445,7 +2316,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptEmitSignal::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceEmitSignal *instance = memnew(VisualScriptNodeInstanceEmitSignal);
instance->node = this;
instance->instance = p_instance;
@@ -2458,7 +2328,6 @@ VisualScriptEmitSignal::VisualScriptEmitSignal() {
}
static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) {
-
Vector<String> path = p_name.split("/");
ERR_FAIL_COND_V(path.size() < 4, Ref<VisualScriptNode>());
String base_type = path[2];
@@ -2470,7 +2339,6 @@ static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) {
Variant::Type type = Variant::VARIANT_MAX;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
-
if (Variant::get_type_name(Variant::Type(i)) == base_type) {
type = Variant::Type(i);
break;
@@ -2487,7 +2355,6 @@ static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) {
}
void register_visual_script_func_nodes() {
-
VisualScriptLanguage::singleton->add_register_func("functions/call", create_node_generic<VisualScriptFunctionCall>);
VisualScriptLanguage::singleton->add_register_func("functions/set", create_node_generic<VisualScriptPropertySet>);
VisualScriptLanguage::singleton->add_register_func("functions/get", create_node_generic<VisualScriptPropertyGet>);
@@ -2497,7 +2364,6 @@ void register_visual_script_func_nodes() {
VisualScriptLanguage::singleton->add_register_func("functions/emit_signal", create_node_generic<VisualScriptEmitSignal>);
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
-
Variant::Type t = Variant::Type(i);
String type_name = Variant::get_type_name(t);
Callable::CallError ce;
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 2dba0ae3c1..6921f0e820 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -34,7 +34,6 @@
#include "visual_script.h"
class VisualScriptFunctionCall : public VisualScriptNode {
-
GDCLASS(VisualScriptFunctionCall, VisualScriptNode);
public:
@@ -137,7 +136,6 @@ VARIANT_ENUM_CAST(VisualScriptFunctionCall::CallMode);
VARIANT_ENUM_CAST(VisualScriptFunctionCall::RPCCallMode);
class VisualScriptPropertySet : public VisualScriptNode {
-
GDCLASS(VisualScriptPropertySet, VisualScriptNode);
public:
@@ -243,7 +241,6 @@ VARIANT_ENUM_CAST(VisualScriptPropertySet::CallMode);
VARIANT_ENUM_CAST(VisualScriptPropertySet::AssignOp);
class VisualScriptPropertyGet : public VisualScriptNode {
-
GDCLASS(VisualScriptPropertyGet, VisualScriptNode);
public:
@@ -325,7 +322,6 @@ public:
VARIANT_ENUM_CAST(VisualScriptPropertyGet::CallMode);
class VisualScriptEmitSignal : public VisualScriptNode {
-
GDCLASS(VisualScriptEmitSignal, VisualScriptNode);
private:
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 52399d29d0..87aa64211e 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -43,13 +43,12 @@
//////////////////////////////////////////
bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value) {
-
if (p_name == "argument_count") {
-
int new_argc = p_value;
int argc = arguments.size();
- if (argc == new_argc)
+ if (argc == new_argc) {
return true;
+ }
arguments.resize(new_argc);
@@ -66,7 +65,6 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value
ERR_FAIL_INDEX_V(idx, arguments.size(), false);
String what = String(p_name).get_slice("/", 1);
if (what == "type") {
-
Variant::Type new_type = Variant::Type(int(p_value));
arguments.write[idx].type = new_type;
ports_changed_notify();
@@ -75,7 +73,6 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value
}
if (what == "name") {
-
arguments.write[idx].name = p_value;
ports_changed_notify();
return true;
@@ -107,7 +104,6 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value
}
bool VisualScriptFunction::_get(const StringName &p_name, Variant &r_ret) const {
-
if (p_name == "argument_count") {
r_ret = arguments.size();
return true;
@@ -148,8 +144,8 @@ bool VisualScriptFunction::_get(const StringName &p_name, Variant &r_ret) const
return false;
}
-void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const {
+void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "argument_count", PROPERTY_HINT_RANGE, "0,256"));
String argt = "Any";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
@@ -171,35 +167,30 @@ void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const
}
int VisualScriptFunction::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptFunction::has_input_sequence_port() const {
-
return false;
}
int VisualScriptFunction::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptFunction::get_output_value_port_count() const {
+int VisualScriptFunction::get_output_value_port_count() const {
return arguments.size();
}
String VisualScriptFunction::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptFunction::get_input_value_port_info(int p_idx) const {
-
ERR_FAIL_V(PropertyInfo());
}
-PropertyInfo VisualScriptFunction::get_output_value_port_info(int p_idx) const {
+PropertyInfo VisualScriptFunction::get_output_value_port_info(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, arguments.size(), PropertyInfo());
PropertyInfo out;
out.type = arguments[p_idx].type;
@@ -210,55 +201,53 @@ PropertyInfo VisualScriptFunction::get_output_value_port_info(int p_idx) const {
}
String VisualScriptFunction::get_caption() const {
-
return "Function";
}
String VisualScriptFunction::get_text() const {
-
return get_name(); //use name as function name I guess
}
void VisualScriptFunction::add_argument(Variant::Type p_type, const String &p_name, int p_index, const PropertyHint p_hint, const String &p_hint_string) {
-
Argument arg;
arg.name = p_name;
arg.type = p_type;
arg.hint = p_hint;
arg.hint_string = p_hint_string;
- if (p_index >= 0)
+ if (p_index >= 0) {
arguments.insert(p_index, arg);
- else
+ } else {
arguments.push_back(arg);
+ }
ports_changed_notify();
}
-void VisualScriptFunction::set_argument_type(int p_argidx, Variant::Type p_type) {
+void VisualScriptFunction::set_argument_type(int p_argidx, Variant::Type p_type) {
ERR_FAIL_INDEX(p_argidx, arguments.size());
arguments.write[p_argidx].type = p_type;
ports_changed_notify();
}
-Variant::Type VisualScriptFunction::get_argument_type(int p_argidx) const {
+Variant::Type VisualScriptFunction::get_argument_type(int p_argidx) const {
ERR_FAIL_INDEX_V(p_argidx, arguments.size(), Variant::NIL);
return arguments[p_argidx].type;
}
-void VisualScriptFunction::set_argument_name(int p_argidx, const String &p_name) {
+void VisualScriptFunction::set_argument_name(int p_argidx, const String &p_name) {
ERR_FAIL_INDEX(p_argidx, arguments.size());
arguments.write[p_argidx].name = p_name;
ports_changed_notify();
}
-String VisualScriptFunction::get_argument_name(int p_argidx) const {
+String VisualScriptFunction::get_argument_name(int p_argidx) const {
ERR_FAIL_INDEX_V(p_argidx, arguments.size(), String());
return arguments[p_argidx].name;
}
-void VisualScriptFunction::remove_argument(int p_argidx) {
+void VisualScriptFunction::remove_argument(int p_argidx) {
ERR_FAIL_INDEX(p_argidx, arguments.size());
arguments.remove(p_argidx);
@@ -266,7 +255,6 @@ void VisualScriptFunction::remove_argument(int p_argidx) {
}
int VisualScriptFunction::get_argument_count() const {
-
return arguments.size();
}
@@ -286,7 +274,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
int ac = node->get_argument_count();
for (int i = 0; i < ac; i++) {
@@ -310,7 +297,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptFunction::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceFunction *instance = memnew(VisualScriptNodeInstanceFunction);
instance->node = this;
instance->instance = p_instance;
@@ -318,7 +304,6 @@ VisualScriptNodeInstance *VisualScriptFunction::instance(VisualScriptInstance *p
}
VisualScriptFunction::VisualScriptFunction() {
-
stack_size = 256;
stack_less = false;
sequenced = true;
@@ -335,23 +320,19 @@ bool VisualScriptFunction::is_stack_less() const {
}
void VisualScriptFunction::set_sequenced(bool p_enable) {
-
sequenced = p_enable;
}
bool VisualScriptFunction::is_sequenced() const {
-
return sequenced;
}
void VisualScriptFunction::set_stack_size(int p_size) {
-
ERR_FAIL_COND(p_size < 1 || p_size > 100000);
stack_size = p_size;
}
int VisualScriptFunction::get_stack_size() const {
-
return stack_size;
}
@@ -360,10 +341,12 @@ int VisualScriptFunction::get_stack_size() const {
//////////////////////////////////////////
int VisualScriptLists::get_output_sequence_port_count() const {
- if (sequenced)
+ if (sequenced) {
return 1;
+ }
return 0;
}
+
bool VisualScriptLists::has_input_sequence_port() const {
return sequenced;
}
@@ -375,6 +358,7 @@ String VisualScriptLists::get_output_sequence_port_text(int p_port) const {
int VisualScriptLists::get_input_value_port_count() const {
return inputports.size();
}
+
int VisualScriptLists::get_output_value_port_count() const {
return outputports.size();
}
@@ -387,6 +371,7 @@ PropertyInfo VisualScriptLists::get_input_value_port_info(int p_idx) const {
pi.type = inputports[p_idx].type;
return pi;
}
+
PropertyInfo VisualScriptLists::get_output_value_port_info(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, outputports.size(), PropertyInfo());
@@ -399,9 +384,11 @@ PropertyInfo VisualScriptLists::get_output_value_port_info(int p_idx) const {
bool VisualScriptLists::is_input_port_editable() const {
return ((flags & INPUT_EDITABLE) == INPUT_EDITABLE);
}
+
bool VisualScriptLists::is_input_port_name_editable() const {
return ((flags & INPUT_NAME_EDITABLE) == INPUT_NAME_EDITABLE);
}
+
bool VisualScriptLists::is_input_port_type_editable() const {
return ((flags & INPUT_TYPE_EDITABLE) == INPUT_TYPE_EDITABLE);
}
@@ -409,22 +396,23 @@ bool VisualScriptLists::is_input_port_type_editable() const {
bool VisualScriptLists::is_output_port_editable() const {
return ((flags & OUTPUT_EDITABLE) == OUTPUT_EDITABLE);
}
+
bool VisualScriptLists::is_output_port_name_editable() const {
return ((flags & INPUT_NAME_EDITABLE) == INPUT_NAME_EDITABLE);
}
+
bool VisualScriptLists::is_output_port_type_editable() const {
return ((flags & INPUT_TYPE_EDITABLE) == INPUT_TYPE_EDITABLE);
}
// for the inspector
bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
-
if (p_name == "input_count" && is_input_port_editable()) {
-
int new_argc = p_value;
int argc = inputports.size();
- if (argc == new_argc)
+ if (argc == new_argc) {
return true;
+ }
inputports.resize(new_argc);
@@ -441,7 +429,6 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_INDEX_V(idx, inputports.size(), false);
String what = String(p_name).get_slice("/", 1);
if (what == "type") {
-
Variant::Type new_type = Variant::Type(int(p_value));
inputports.write[idx].type = new_type;
ports_changed_notify();
@@ -450,7 +437,6 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
}
if (what == "name") {
-
inputports.write[idx].name = p_value;
ports_changed_notify();
return true;
@@ -458,11 +444,11 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
}
if (p_name == "output_count" && is_output_port_editable()) {
-
int new_argc = p_value;
int argc = outputports.size();
- if (argc == new_argc)
+ if (argc == new_argc) {
return true;
+ }
outputports.resize(new_argc);
@@ -479,7 +465,6 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_INDEX_V(idx, outputports.size(), false);
String what = String(p_name).get_slice("/", 1);
if (what == "type") {
-
Variant::Type new_type = Variant::Type(int(p_value));
outputports.write[idx].type = new_type;
ports_changed_notify();
@@ -488,7 +473,6 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
}
if (what == "name") {
-
outputports.write[idx].name = p_value;
ports_changed_notify();
return true;
@@ -503,8 +487,8 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) {
return false;
}
-bool VisualScriptLists::_get(const StringName &p_name, Variant &r_ret) const {
+bool VisualScriptLists::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "input_count" && is_input_port_editable()) {
r_ret = inputports.size();
return true;
@@ -548,8 +532,8 @@ bool VisualScriptLists::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void VisualScriptLists::_get_property_list(List<PropertyInfo> *p_list) const {
+void VisualScriptLists::_get_property_list(List<PropertyInfo> *p_list) const {
if (is_input_port_editable()) {
p_list->push_back(PropertyInfo(Variant::INT, "input_count", PROPERTY_HINT_RANGE, "0,256"));
String argt = "Any";
@@ -580,25 +564,27 @@ void VisualScriptLists::_get_property_list(List<PropertyInfo> *p_list) const {
// input data port interaction
void VisualScriptLists::add_input_data_port(Variant::Type p_type, const String &p_name, int p_index) {
-
- if (!is_input_port_editable())
+ if (!is_input_port_editable()) {
return;
+ }
Port inp;
inp.name = p_name;
inp.type = p_type;
- if (p_index >= 0)
+ if (p_index >= 0) {
inputports.insert(p_index, inp);
- else
+ } else {
inputports.push_back(inp);
+ }
ports_changed_notify();
_change_notify();
}
-void VisualScriptLists::set_input_data_port_type(int p_idx, Variant::Type p_type) {
- if (!is_input_port_type_editable())
+void VisualScriptLists::set_input_data_port_type(int p_idx, Variant::Type p_type) {
+ if (!is_input_port_type_editable()) {
return;
+ }
ERR_FAIL_INDEX(p_idx, inputports.size());
@@ -606,10 +592,11 @@ void VisualScriptLists::set_input_data_port_type(int p_idx, Variant::Type p_type
ports_changed_notify();
_change_notify();
}
-void VisualScriptLists::set_input_data_port_name(int p_idx, const String &p_name) {
- if (!is_input_port_name_editable())
+void VisualScriptLists::set_input_data_port_name(int p_idx, const String &p_name) {
+ if (!is_input_port_name_editable()) {
return;
+ }
ERR_FAIL_INDEX(p_idx, inputports.size());
@@ -617,10 +604,11 @@ void VisualScriptLists::set_input_data_port_name(int p_idx, const String &p_name
ports_changed_notify();
_change_notify();
}
-void VisualScriptLists::remove_input_data_port(int p_argidx) {
- if (!is_input_port_editable())
+void VisualScriptLists::remove_input_data_port(int p_argidx) {
+ if (!is_input_port_editable()) {
return;
+ }
ERR_FAIL_INDEX(p_argidx, inputports.size());
@@ -632,25 +620,27 @@ void VisualScriptLists::remove_input_data_port(int p_argidx) {
// output data port interaction
void VisualScriptLists::add_output_data_port(Variant::Type p_type, const String &p_name, int p_index) {
-
- if (!is_output_port_editable())
+ if (!is_output_port_editable()) {
return;
+ }
Port out;
out.name = p_name;
out.type = p_type;
- if (p_index >= 0)
+ if (p_index >= 0) {
outputports.insert(p_index, out);
- else
+ } else {
outputports.push_back(out);
+ }
ports_changed_notify();
_change_notify();
}
-void VisualScriptLists::set_output_data_port_type(int p_idx, Variant::Type p_type) {
- if (!is_output_port_type_editable())
+void VisualScriptLists::set_output_data_port_type(int p_idx, Variant::Type p_type) {
+ if (!is_output_port_type_editable()) {
return;
+ }
ERR_FAIL_INDEX(p_idx, outputports.size());
@@ -658,10 +648,11 @@ void VisualScriptLists::set_output_data_port_type(int p_idx, Variant::Type p_typ
ports_changed_notify();
_change_notify();
}
-void VisualScriptLists::set_output_data_port_name(int p_idx, const String &p_name) {
- if (!is_output_port_name_editable())
+void VisualScriptLists::set_output_data_port_name(int p_idx, const String &p_name) {
+ if (!is_output_port_name_editable()) {
return;
+ }
ERR_FAIL_INDEX(p_idx, outputports.size());
@@ -669,10 +660,11 @@ void VisualScriptLists::set_output_data_port_name(int p_idx, const String &p_nam
ports_changed_notify();
_change_notify();
}
-void VisualScriptLists::remove_output_data_port(int p_argidx) {
- if (!is_output_port_editable())
+void VisualScriptLists::remove_output_data_port(int p_argidx) {
+ if (!is_output_port_editable()) {
return;
+ }
ERR_FAIL_INDEX(p_argidx, outputports.size());
@@ -684,11 +676,13 @@ void VisualScriptLists::remove_output_data_port(int p_argidx) {
// sequences
void VisualScriptLists::set_sequenced(bool p_enable) {
- if (sequenced == p_enable)
+ if (sequenced == p_enable) {
return;
+ }
sequenced = p_enable;
ports_changed_notify();
}
+
bool VisualScriptLists::is_sequenced() const {
return sequenced;
}
@@ -716,10 +710,12 @@ void VisualScriptLists::_bind_methods() {
//////////////////////////////////////////
int VisualScriptComposeArray::get_output_sequence_port_count() const {
- if (sequenced)
+ if (sequenced) {
return 1;
+ }
return 0;
}
+
bool VisualScriptComposeArray::has_input_sequence_port() const {
return sequenced;
}
@@ -731,6 +727,7 @@ String VisualScriptComposeArray::get_output_sequence_port_text(int p_port) const
int VisualScriptComposeArray::get_input_value_port_count() const {
return inputports.size();
}
+
int VisualScriptComposeArray::get_output_value_port_count() const {
return 1;
}
@@ -743,6 +740,7 @@ PropertyInfo VisualScriptComposeArray::get_input_value_port_info(int p_idx) cons
pi.type = inputports[p_idx].type;
return pi;
}
+
PropertyInfo VisualScriptComposeArray::get_output_value_port_info(int p_idx) const {
PropertyInfo pi;
pi.name = "out";
@@ -753,6 +751,7 @@ PropertyInfo VisualScriptComposeArray::get_output_value_port_info(int p_idx) con
String VisualScriptComposeArray::get_caption() const {
return "Compose Array";
}
+
String VisualScriptComposeArray::get_text() const {
return "";
}
@@ -763,11 +762,11 @@ public:
virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (input_count > 0) {
Array arr;
- for (int i = 0; i < input_count; i++)
+ for (int i = 0; i < input_count; i++) {
arr.push_back((*p_inputs[i]));
+ }
Variant va = Variant(arr);
*p_outputs[0] = va;
@@ -778,7 +777,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptComposeArray::instance(VisualScriptInstance *p_instance) {
-
VisualScriptComposeArrayNode *instance = memnew(VisualScriptComposeArrayNode);
instance->input_count = inputports.size();
return instance;
@@ -795,31 +793,26 @@ VisualScriptComposeArray::VisualScriptComposeArray() {
//////////////////////////////////////////
int VisualScriptOperator::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptOperator::has_input_sequence_port() const {
-
return false;
}
int VisualScriptOperator::get_input_value_port_count() const {
-
return (op == Variant::OP_BIT_NEGATE || op == Variant::OP_NOT || op == Variant::OP_NEGATE || op == Variant::OP_POSITIVE) ? 1 : 2;
}
-int VisualScriptOperator::get_output_value_port_count() const {
+int VisualScriptOperator::get_output_value_port_count() const {
return 1;
}
String VisualScriptOperator::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptOperator::get_input_value_port_info(int p_idx) const {
-
static const Variant::Type port_types[Variant::OP_MAX][2] = {
{ Variant::NIL, Variant::NIL }, //OP_EQUAL,
{ Variant::NIL, Variant::NIL }, //OP_NOT_EQUAL,
@@ -857,10 +850,12 @@ PropertyInfo VisualScriptOperator::get_input_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = p_idx == 0 ? "A" : "B";
pinfo.type = port_types[op][p_idx];
- if (pinfo.type == Variant::NIL)
+ if (pinfo.type == Variant::NIL) {
pinfo.type = typed;
+ }
return pinfo;
}
+
PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const {
static const Variant::Type port_types[Variant::OP_MAX] = {
//comparison
@@ -898,8 +893,9 @@ PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "";
pinfo.type = port_types[op];
- if (pinfo.type == Variant::NIL)
+ if (pinfo.type == Variant::NIL) {
pinfo.type = typed;
+ }
return pinfo;
}
@@ -937,7 +933,6 @@ static const char *op_names[] = {
};
String VisualScriptOperator::get_caption() const {
-
static const wchar_t *op_names[] = {
//comparison
L"A = B", //OP_EQUAL,
@@ -974,34 +969,31 @@ String VisualScriptOperator::get_caption() const {
}
void VisualScriptOperator::set_operator(Variant::Operator p_op) {
-
- if (op == p_op)
+ if (op == p_op) {
return;
+ }
op = p_op;
ports_changed_notify();
}
Variant::Operator VisualScriptOperator::get_operator() const {
-
return op;
}
void VisualScriptOperator::set_typed(Variant::Type p_op) {
-
- if (typed == p_op)
+ if (typed == p_op) {
return;
+ }
typed = p_op;
ports_changed_notify();
}
Variant::Type VisualScriptOperator::get_typed() const {
-
return typed;
}
void VisualScriptOperator::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualScriptOperator::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualScriptOperator::get_operator);
@@ -1010,8 +1002,9 @@ void VisualScriptOperator::_bind_methods() {
String types;
for (int i = 0; i < Variant::OP_MAX; i++) {
- if (i > 0)
+ if (i > 0) {
types += ",";
+ }
types += op_names[i];
}
@@ -1032,25 +1025,23 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
bool valid;
if (unary) {
-
Variant::evaluate(op, *p_inputs[0], Variant(), *p_outputs[0], valid);
} else {
Variant::evaluate(op, *p_inputs[0], *p_inputs[1], *p_outputs[0], valid);
}
if (!valid) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
if (p_outputs[0]->get_type() == Variant::STRING) {
r_error_str = *p_outputs[0];
} else {
- if (unary)
+ if (unary) {
r_error_str = String(op_names[op]) + RTR(": Invalid argument of type: ") + Variant::get_type_name(p_inputs[0]->get_type());
- else
+ } else {
r_error_str = String(op_names[op]) + RTR(": Invalid arguments: ") + "A: " + Variant::get_type_name(p_inputs[0]->get_type()) + " B: " + Variant::get_type_name(p_inputs[1]->get_type());
+ }
}
}
@@ -1059,7 +1050,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptOperator::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceOperator *instance = memnew(VisualScriptNodeInstanceOperator);
instance->unary = get_input_value_port_count() == 1;
instance->op = op;
@@ -1067,14 +1057,12 @@ VisualScriptNodeInstance *VisualScriptOperator::instance(VisualScriptInstance *p
}
VisualScriptOperator::VisualScriptOperator() {
-
op = Variant::OP_ADD;
typed = Variant::NIL;
}
template <Variant::Operator OP>
static Ref<VisualScriptNode> create_op_node(const String &p_name) {
-
Ref<VisualScriptOperator> node;
node.instance();
node->set_operator(OP);
@@ -1086,31 +1074,26 @@ static Ref<VisualScriptNode> create_op_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptSelect::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptSelect::has_input_sequence_port() const {
-
return false;
}
int VisualScriptSelect::get_input_value_port_count() const {
-
return 3;
}
-int VisualScriptSelect::get_output_value_port_count() const {
+int VisualScriptSelect::get_output_value_port_count() const {
return 1;
}
String VisualScriptSelect::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptSelect::get_input_value_port_info(int p_idx) const {
-
if (p_idx == 0) {
return PropertyInfo(Variant::BOOL, "cond");
} else if (p_idx == 1) {
@@ -1119,37 +1102,33 @@ PropertyInfo VisualScriptSelect::get_input_value_port_info(int p_idx) const {
return PropertyInfo(typed, "b");
}
}
-PropertyInfo VisualScriptSelect::get_output_value_port_info(int p_idx) const {
+PropertyInfo VisualScriptSelect::get_output_value_port_info(int p_idx) const {
return PropertyInfo(typed, "out");
}
String VisualScriptSelect::get_caption() const {
-
return "Select";
}
String VisualScriptSelect::get_text() const {
-
return "a if cond, else b";
}
void VisualScriptSelect::set_typed(Variant::Type p_op) {
-
- if (typed == p_op)
+ if (typed == p_op) {
return;
+ }
typed = p_op;
ports_changed_notify();
}
Variant::Type VisualScriptSelect::get_typed() const {
-
return typed;
}
void VisualScriptSelect::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_typed", "type"), &VisualScriptSelect::set_typed);
ClassDB::bind_method(D_METHOD("get_typed"), &VisualScriptSelect::get_typed);
@@ -1166,25 +1145,23 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
bool cond = *p_inputs[0];
- if (cond)
+ if (cond) {
*p_outputs[0] = *p_inputs[1];
- else
+ } else {
*p_outputs[0] = *p_inputs[2];
+ }
return 0;
}
};
VisualScriptNodeInstance *VisualScriptSelect::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSelect *instance = memnew(VisualScriptNodeInstanceSelect);
return instance;
}
VisualScriptSelect::VisualScriptSelect() {
-
typed = Variant::NIL;
}
@@ -1193,36 +1170,30 @@ VisualScriptSelect::VisualScriptSelect() {
//////////////////////////////////////////
int VisualScriptVariableGet::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptVariableGet::has_input_sequence_port() const {
-
return false;
}
int VisualScriptVariableGet::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptVariableGet::get_output_value_port_count() const {
+int VisualScriptVariableGet::get_output_value_port_count() const {
return 1;
}
String VisualScriptVariableGet::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptVariableGet::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptVariableGet::get_output_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = "value";
if (get_visual_script().is_valid() && get_visual_script()->has_variable(variable)) {
@@ -1235,24 +1206,22 @@ PropertyInfo VisualScriptVariableGet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptVariableGet::get_caption() const {
-
return "Get " + variable;
}
-void VisualScriptVariableGet::set_variable(StringName p_variable) {
- if (variable == p_variable)
+void VisualScriptVariableGet::set_variable(StringName p_variable) {
+ if (variable == p_variable) {
return;
+ }
variable = p_variable;
ports_changed_notify();
}
StringName VisualScriptVariableGet::get_variable() const {
-
return variable;
}
void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const {
-
if (property.name == "var_name" && get_visual_script().is_valid()) {
Ref<VisualScript> vs = get_visual_script();
List<StringName> vars;
@@ -1260,8 +1229,9 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const {
String vhint;
for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
- if (vhint != String())
+ if (vhint != String()) {
vhint += ",";
+ }
vhint += E->get().operator String();
}
@@ -1272,7 +1242,6 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const {
}
void VisualScriptVariableGet::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_variable", "name"), &VisualScriptVariableGet::set_variable);
ClassDB::bind_method(D_METHOD("get_variable"), &VisualScriptVariableGet::get_variable);
@@ -1286,7 +1255,6 @@ public:
StringName variable;
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (!instance->get_variable(variable, p_outputs[0])) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("VariableGet not found in script: ") + "'" + String(variable) + "'";
@@ -1297,13 +1265,13 @@ public:
};
VisualScriptNodeInstance *VisualScriptVariableGet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceVariableGet *instance = memnew(VisualScriptNodeInstanceVariableGet);
instance->node = this;
instance->instance = p_instance;
instance->variable = variable;
return instance;
}
+
VisualScriptVariableGet::VisualScriptVariableGet() {
}
@@ -1312,31 +1280,26 @@ VisualScriptVariableGet::VisualScriptVariableGet() {
//////////////////////////////////////////
int VisualScriptVariableSet::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptVariableSet::has_input_sequence_port() const {
-
return true;
}
int VisualScriptVariableSet::get_input_value_port_count() const {
-
return 1;
}
-int VisualScriptVariableSet::get_output_value_port_count() const {
+int VisualScriptVariableSet::get_output_value_port_count() const {
return 0;
}
String VisualScriptVariableSet::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptVariableSet::get_input_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = "set";
if (get_visual_script().is_valid() && get_visual_script()->has_variable(variable)) {
@@ -1349,30 +1312,26 @@ PropertyInfo VisualScriptVariableSet::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptVariableSet::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptVariableSet::get_caption() const {
-
return "Set " + variable;
}
void VisualScriptVariableSet::set_variable(StringName p_variable) {
-
- if (variable == p_variable)
+ if (variable == p_variable) {
return;
+ }
variable = p_variable;
ports_changed_notify();
}
StringName VisualScriptVariableSet::get_variable() const {
-
return variable;
}
void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const {
-
if (property.name == "var_name" && get_visual_script().is_valid()) {
Ref<VisualScript> vs = get_visual_script();
List<StringName> vars;
@@ -1380,8 +1339,9 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const {
String vhint;
for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
- if (vhint != String())
+ if (vhint != String()) {
vhint += ",";
+ }
vhint += E->get().operator String();
}
@@ -1392,7 +1352,6 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const {
}
void VisualScriptVariableSet::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_variable", "name"), &VisualScriptVariableSet::set_variable);
ClassDB::bind_method(D_METHOD("get_variable"), &VisualScriptVariableSet::get_variable);
@@ -1408,9 +1367,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (!instance->set_variable(variable, *p_inputs[0])) {
-
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("VariableSet not found in script: ") + "'" + String(variable) + "'";
}
@@ -1420,13 +1377,13 @@ public:
};
VisualScriptNodeInstance *VisualScriptVariableSet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceVariableSet *instance = memnew(VisualScriptNodeInstanceVariableSet);
instance->node = this;
instance->instance = p_instance;
instance->variable = variable;
return instance;
}
+
VisualScriptVariableSet::VisualScriptVariableSet() {
}
@@ -1435,36 +1392,30 @@ VisualScriptVariableSet::VisualScriptVariableSet() {
//////////////////////////////////////////
int VisualScriptConstant::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptConstant::has_input_sequence_port() const {
-
return false;
}
int VisualScriptConstant::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptConstant::get_output_value_port_count() const {
+int VisualScriptConstant::get_output_value_port_count() const {
return 1;
}
String VisualScriptConstant::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptConstant::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptConstant::get_output_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.name = String(value);
pinfo.type = type;
@@ -1472,14 +1423,13 @@ PropertyInfo VisualScriptConstant::get_output_value_port_info(int p_idx) const {
}
String VisualScriptConstant::get_caption() const {
-
return "Constant";
}
void VisualScriptConstant::set_constant_type(Variant::Type p_type) {
-
- if (type == p_type)
+ if (type == p_type) {
return;
+ }
type = p_type;
Callable::CallError ce;
@@ -1489,34 +1439,32 @@ void VisualScriptConstant::set_constant_type(Variant::Type p_type) {
}
Variant::Type VisualScriptConstant::get_constant_type() const {
-
return type;
}
void VisualScriptConstant::set_constant_value(Variant p_value) {
-
- if (value == p_value)
+ if (value == p_value) {
return;
+ }
value = p_value;
ports_changed_notify();
}
-Variant VisualScriptConstant::get_constant_value() const {
+Variant VisualScriptConstant::get_constant_value() const {
return value;
}
void VisualScriptConstant::_validate_property(PropertyInfo &property) const {
-
if (property.name == "value") {
property.type = type;
- if (type == Variant::NIL)
+ if (type == Variant::NIL) {
property.usage = 0; //do not save if nil
+ }
}
}
void VisualScriptConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant_type", "type"), &VisualScriptConstant::set_constant_type);
ClassDB::bind_method(D_METHOD("get_constant_type"), &VisualScriptConstant::get_constant_type);
@@ -1538,21 +1486,18 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = constant;
return 0;
}
};
VisualScriptNodeInstance *VisualScriptConstant::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceConstant *instance = memnew(VisualScriptNodeInstanceConstant);
instance->constant = value;
return instance;
}
VisualScriptConstant::VisualScriptConstant() {
-
type = Variant::NIL;
}
@@ -1561,36 +1506,30 @@ VisualScriptConstant::VisualScriptConstant() {
//////////////////////////////////////////
int VisualScriptPreload::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptPreload::has_input_sequence_port() const {
-
return false;
}
int VisualScriptPreload::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptPreload::get_output_value_port_count() const {
+int VisualScriptPreload::get_output_value_port_count() const {
return 1;
}
String VisualScriptPreload::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptPreload::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const {
-
PropertyInfo pinfo;
pinfo.type = Variant::OBJECT;
if (preload.is_valid()) {
@@ -1611,26 +1550,23 @@ PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const {
}
String VisualScriptPreload::get_caption() const {
-
return "Preload";
}
void VisualScriptPreload::set_preload(const Ref<Resource> &p_preload) {
-
- if (preload == p_preload)
+ if (preload == p_preload) {
return;
+ }
preload = p_preload;
ports_changed_notify();
}
Ref<Resource> VisualScriptPreload::get_preload() const {
-
return preload;
}
void VisualScriptPreload::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_preload", "resource"), &VisualScriptPreload::set_preload);
ClassDB::bind_method(D_METHOD("get_preload"), &VisualScriptPreload::get_preload);
@@ -1643,14 +1579,12 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = preload;
return 0;
}
};
VisualScriptNodeInstance *VisualScriptPreload::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstancePreload *instance = memnew(VisualScriptNodeInstancePreload);
instance->preload = preload;
return instance;
@@ -1664,31 +1598,26 @@ VisualScriptPreload::VisualScriptPreload() {
//////////////////////////////////////////
int VisualScriptIndexGet::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptIndexGet::has_input_sequence_port() const {
-
return false;
}
int VisualScriptIndexGet::get_input_value_port_count() const {
-
return 2;
}
-int VisualScriptIndexGet::get_output_value_port_count() const {
+int VisualScriptIndexGet::get_output_value_port_count() const {
return 1;
}
String VisualScriptIndexGet::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptIndexGet::get_input_value_port_info(int p_idx) const {
-
if (p_idx == 0) {
return PropertyInfo(Variant::NIL, "base");
} else {
@@ -1697,12 +1626,10 @@ PropertyInfo VisualScriptIndexGet::get_input_value_port_info(int p_idx) const {
}
PropertyInfo VisualScriptIndexGet::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptIndexGet::get_caption() const {
-
return "Get Index";
}
@@ -1711,7 +1638,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
bool valid;
*p_outputs[0] = p_inputs[0]->get(*p_inputs[1], &valid);
@@ -1724,10 +1650,10 @@ public:
};
VisualScriptNodeInstance *VisualScriptIndexGet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceIndexGet *instance = memnew(VisualScriptNodeInstanceIndexGet);
return instance;
}
+
VisualScriptIndexGet::VisualScriptIndexGet() {
}
@@ -1736,31 +1662,26 @@ VisualScriptIndexGet::VisualScriptIndexGet() {
//////////////////////////////////////////
int VisualScriptIndexSet::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptIndexSet::has_input_sequence_port() const {
-
return true;
}
int VisualScriptIndexSet::get_input_value_port_count() const {
-
return 3;
}
-int VisualScriptIndexSet::get_output_value_port_count() const {
+int VisualScriptIndexSet::get_output_value_port_count() const {
return 0;
}
String VisualScriptIndexSet::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptIndexSet::get_input_value_port_info(int p_idx) const {
-
if (p_idx == 0) {
return PropertyInfo(Variant::NIL, "base");
} else if (p_idx == 1) {
@@ -1772,12 +1693,10 @@ PropertyInfo VisualScriptIndexSet::get_input_value_port_info(int p_idx) const {
}
PropertyInfo VisualScriptIndexSet::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptIndexSet::get_caption() const {
-
return "Set Index";
}
@@ -1786,7 +1705,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
bool valid;
*p_outputs[0] = *p_inputs[0];
p_outputs[0]->set(*p_inputs[1], *p_inputs[2], &valid);
@@ -1800,10 +1718,10 @@ public:
};
VisualScriptNodeInstance *VisualScriptIndexSet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceIndexSet *instance = memnew(VisualScriptNodeInstanceIndexSet);
return instance;
}
+
VisualScriptIndexSet::VisualScriptIndexSet() {
}
@@ -1812,31 +1730,26 @@ VisualScriptIndexSet::VisualScriptIndexSet() {
//////////////////////////////////////////
int VisualScriptGlobalConstant::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptGlobalConstant::has_input_sequence_port() const {
-
return false;
}
int VisualScriptGlobalConstant::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptGlobalConstant::get_output_value_port_count() const {
+int VisualScriptGlobalConstant::get_output_value_port_count() const {
return 1;
}
String VisualScriptGlobalConstant::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptGlobalConstant::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
@@ -1846,12 +1759,10 @@ PropertyInfo VisualScriptGlobalConstant::get_output_value_port_info(int p_idx) c
}
String VisualScriptGlobalConstant::get_caption() const {
-
return "Global Constant";
}
void VisualScriptGlobalConstant::set_global_constant(int p_which) {
-
index = p_which;
_change_notify();
ports_changed_notify();
@@ -1867,37 +1778,33 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = GlobalConstants::get_global_constant_value(index);
return 0;
}
};
VisualScriptNodeInstance *VisualScriptGlobalConstant::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceGlobalConstant *instance = memnew(VisualScriptNodeInstanceGlobalConstant);
instance->index = index;
return instance;
}
void VisualScriptGlobalConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_global_constant", "index"), &VisualScriptGlobalConstant::set_global_constant);
ClassDB::bind_method(D_METHOD("get_global_constant"), &VisualScriptGlobalConstant::get_global_constant);
String cc;
for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
-
- if (i > 0)
+ if (i > 0) {
cc += ",";
+ }
cc += GlobalConstants::get_global_constant_name(i);
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant");
}
VisualScriptGlobalConstant::VisualScriptGlobalConstant() {
-
index = 0;
}
@@ -1906,31 +1813,26 @@ VisualScriptGlobalConstant::VisualScriptGlobalConstant() {
//////////////////////////////////////////
int VisualScriptClassConstant::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptClassConstant::has_input_sequence_port() const {
-
return false;
}
int VisualScriptClassConstant::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptClassConstant::get_output_value_port_count() const {
+int VisualScriptClassConstant::get_output_value_port_count() const {
return 1;
}
String VisualScriptClassConstant::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptClassConstant::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
@@ -1943,12 +1845,10 @@ PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) co
}
String VisualScriptClassConstant::get_caption() const {
-
return "Class Constant";
}
void VisualScriptClassConstant::set_class_constant(const StringName &p_which) {
-
name = p_which;
_change_notify();
ports_changed_notify();
@@ -1959,7 +1859,6 @@ StringName VisualScriptClassConstant::get_class_constant() {
}
void VisualScriptClassConstant::set_base_type(const StringName &p_which) {
-
base_type = p_which;
List<String> constants;
ClassDB::get_integer_constant_list(base_type, &constants, true);
@@ -1992,7 +1891,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (!valid) {
r_error_str = "Invalid constant name, pick a valid class constant.";
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -2004,16 +1902,13 @@ public:
};
VisualScriptNodeInstance *VisualScriptClassConstant::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceClassConstant *instance = memnew(VisualScriptNodeInstanceClassConstant);
instance->value = ClassDB::get_integer_constant(base_type, name, &instance->valid);
return instance;
}
void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const {
-
if (property.name == "constant") {
-
List<String> constants;
ClassDB::get_integer_constant_list(base_type, &constants, true);
@@ -2028,7 +1923,6 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const
}
void VisualScriptClassConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_class_constant", "name"), &VisualScriptClassConstant::set_class_constant);
ClassDB::bind_method(D_METHOD("get_class_constant"), &VisualScriptClassConstant::get_class_constant);
@@ -2040,7 +1934,6 @@ void VisualScriptClassConstant::_bind_methods() {
}
VisualScriptClassConstant::VisualScriptClassConstant() {
-
base_type = "Object";
}
@@ -2049,41 +1942,34 @@ VisualScriptClassConstant::VisualScriptClassConstant() {
//////////////////////////////////////////
int VisualScriptBasicTypeConstant::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptBasicTypeConstant::has_input_sequence_port() const {
-
return false;
}
int VisualScriptBasicTypeConstant::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptBasicTypeConstant::get_output_value_port_count() const {
+int VisualScriptBasicTypeConstant::get_output_value_port_count() const {
return 1;
}
String VisualScriptBasicTypeConstant::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptBasicTypeConstant::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptBasicTypeConstant::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(type, "value");
}
String VisualScriptBasicTypeConstant::get_caption() const {
-
return "Basic Constant";
}
@@ -2096,7 +1982,6 @@ String VisualScriptBasicTypeConstant::get_text() const {
}
void VisualScriptBasicTypeConstant::set_basic_type_constant(const StringName &p_which) {
-
name = p_which;
_change_notify();
ports_changed_notify();
@@ -2107,7 +1992,6 @@ StringName VisualScriptBasicTypeConstant::get_basic_type_constant() const {
}
void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) {
-
type = p_which;
List<StringName> constants;
@@ -2141,7 +2025,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (!valid) {
r_error_str = "Invalid constant name, pick a valid basic type constant.";
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -2153,16 +2036,13 @@ public:
};
VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceBasicTypeConstant *instance = memnew(VisualScriptNodeInstanceBasicTypeConstant);
instance->value = Variant::get_constant_value(type, name, &instance->valid);
return instance;
}
void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) const {
-
if (property.name == "constant") {
-
List<StringName> constants;
Variant::get_constants_for_type(type, &constants);
@@ -2181,7 +2061,6 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c
}
void VisualScriptBasicTypeConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_basic_type", "name"), &VisualScriptBasicTypeConstant::set_basic_type);
ClassDB::bind_method(D_METHOD("get_basic_type"), &VisualScriptBasicTypeConstant::get_basic_type);
@@ -2198,7 +2077,6 @@ void VisualScriptBasicTypeConstant::_bind_methods() {
}
VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() {
-
type = Variant::NIL;
}
@@ -2229,46 +2107,38 @@ double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX] = {
};
int VisualScriptMathConstant::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptMathConstant::has_input_sequence_port() const {
-
return false;
}
int VisualScriptMathConstant::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptMathConstant::get_output_value_port_count() const {
+int VisualScriptMathConstant::get_output_value_port_count() const {
return 1;
}
String VisualScriptMathConstant::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptMathConstant::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptMathConstant::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::FLOAT, const_name[constant]);
}
String VisualScriptMathConstant::get_caption() const {
-
return "Math Constant";
}
void VisualScriptMathConstant::set_math_constant(MathConstant p_which) {
-
constant = p_which;
_change_notify();
ports_changed_notify();
@@ -2284,30 +2154,27 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = value;
return 0;
}
};
VisualScriptNodeInstance *VisualScriptMathConstant::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceMathConstant *instance = memnew(VisualScriptNodeInstanceMathConstant);
instance->value = const_value[constant];
return instance;
}
void VisualScriptMathConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_math_constant", "which"), &VisualScriptMathConstant::set_math_constant);
ClassDB::bind_method(D_METHOD("get_math_constant"), &VisualScriptMathConstant::get_math_constant);
String cc;
for (int i = 0; i < MATH_CONSTANT_MAX; i++) {
-
- if (i > 0)
+ if (i > 0) {
cc += ",";
+ }
cc += const_name[i];
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant");
@@ -2324,7 +2191,6 @@ void VisualScriptMathConstant::_bind_methods() {
}
VisualScriptMathConstant::VisualScriptMathConstant() {
-
constant = MATH_CONSTANT_ONE;
}
@@ -2333,46 +2199,38 @@ VisualScriptMathConstant::VisualScriptMathConstant() {
//////////////////////////////////////////
int VisualScriptEngineSingleton::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptEngineSingleton::has_input_sequence_port() const {
-
return false;
}
int VisualScriptEngineSingleton::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptEngineSingleton::get_output_value_port_count() const {
+int VisualScriptEngineSingleton::get_output_value_port_count() const {
return 1;
}
String VisualScriptEngineSingleton::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptEngineSingleton::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptEngineSingleton::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::OBJECT, singleton);
}
String VisualScriptEngineSingleton::get_caption() const {
-
return "Get Engine Singleton";
}
void VisualScriptEngineSingleton::set_singleton(const String &p_string) {
-
singleton = p_string;
_change_notify();
@@ -2390,21 +2248,18 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = singleton;
return 0;
}
};
VisualScriptNodeInstance *VisualScriptEngineSingleton::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceEngineSingleton *instance = memnew(VisualScriptNodeInstanceEngineSingleton);
instance->singleton = Engine::get_singleton()->get_singleton_object(singleton);
return instance;
}
VisualScriptEngineSingleton::TypeGuess VisualScriptEngineSingleton::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
Object *obj = Engine::get_singleton()->get_singleton_object(singleton);
TypeGuess tg;
tg.type = Variant::OBJECT;
@@ -2417,7 +2272,6 @@ VisualScriptEngineSingleton::TypeGuess VisualScriptEngineSingleton::guess_output
}
void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) const {
-
String cc;
List<Engine::Singleton> singletons;
@@ -2425,11 +2279,13 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con
Engine::get_singleton()->get_singletons(&singletons);
for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
- if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D")
+ if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D") {
continue; //skip these, too simple named
+ }
- if (cc != String())
+ if (cc != String()) {
cc += ",";
+ }
cc += E->get().name;
}
@@ -2438,7 +2294,6 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con
}
void VisualScriptEngineSingleton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_singleton", "name"), &VisualScriptEngineSingleton::set_singleton);
ClassDB::bind_method(D_METHOD("get_singleton"), &VisualScriptEngineSingleton::get_singleton);
@@ -2446,7 +2301,6 @@ void VisualScriptEngineSingleton::_bind_methods() {
}
VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
-
singleton = String();
}
@@ -2455,46 +2309,38 @@ VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
//////////////////////////////////////////
int VisualScriptSceneNode::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptSceneNode::has_input_sequence_port() const {
-
return false;
}
int VisualScriptSceneNode::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptSceneNode::get_output_value_port_count() const {
+int VisualScriptSceneNode::get_output_value_port_count() const {
return 1;
}
String VisualScriptSceneNode::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptSceneNode::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptSceneNode::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::OBJECT, path.simplified());
}
String VisualScriptSceneNode::get_caption() const {
-
return "Get Scene Node";
}
void VisualScriptSceneNode::set_node_path(const NodePath &p_path) {
-
path = p_path;
_change_notify();
ports_changed_notify();
@@ -2513,7 +2359,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -2535,7 +2380,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptSceneNode::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSceneNode *instance = memnew(VisualScriptNodeInstanceSceneNode);
instance->node = this;
instance->instance = p_instance;
@@ -2546,19 +2390,21 @@ VisualScriptNodeInstance *VisualScriptSceneNode::instance(VisualScriptInstance *
#ifdef TOOLS_ENABLED
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
- if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
+ if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
return nullptr;
+ }
Ref<Script> scr = p_current_node->get_script();
- if (scr.is_valid() && scr == script)
+ if (scr.is_valid() && scr == script) {
return p_current_node;
+ }
for (int i = 0; i < p_current_node->get_child_count(); i++) {
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
- if (n)
+ if (n) {
return n;
+ }
}
return nullptr;
@@ -2567,31 +2413,34 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
#endif
VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
tg.gdclass = "Node";
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return tg;
+ }
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
- if (!scene_tree)
+ if (!scene_tree) {
return tg;
+ }
Node *edited_scene = scene_tree->get_edited_scene_root();
- if (!edited_scene)
+ if (!edited_scene) {
return tg;
+ }
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
- if (!script_node)
+ if (!script_node) {
return tg;
+ }
Node *another = script_node->get_node(path);
@@ -2604,29 +2453,31 @@ VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGu
}
void VisualScriptSceneNode::_validate_property(PropertyInfo &property) const {
-
#ifdef TOOLS_ENABLED
if (property.name == "node_path") {
-
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return;
+ }
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *edited_scene = scene_tree->get_edited_scene_root();
- if (!edited_scene)
+ if (!edited_scene) {
return;
+ }
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
- if (!script_node)
+ if (!script_node) {
return;
+ }
property.hint_string = script_node->get_path();
}
@@ -2634,7 +2485,6 @@ void VisualScriptSceneNode::_validate_property(PropertyInfo &property) const {
}
void VisualScriptSceneNode::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_node_path", "path"), &VisualScriptSceneNode::set_node_path);
ClassDB::bind_method(D_METHOD("get_node_path"), &VisualScriptSceneNode::get_node_path);
@@ -2642,7 +2492,6 @@ void VisualScriptSceneNode::_bind_methods() {
}
VisualScriptSceneNode::VisualScriptSceneNode() {
-
path = String(".");
}
@@ -2651,41 +2500,34 @@ VisualScriptSceneNode::VisualScriptSceneNode() {
//////////////////////////////////////////
int VisualScriptSceneTree::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptSceneTree::has_input_sequence_port() const {
-
return false;
}
int VisualScriptSceneTree::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptSceneTree::get_output_value_port_count() const {
+int VisualScriptSceneTree::get_output_value_port_count() const {
return 1;
}
String VisualScriptSceneTree::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptSceneTree::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptSceneTree::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::OBJECT, "Scene Tree", PROPERTY_HINT_TYPE_STRING, "SceneTree");
}
String VisualScriptSceneTree::get_caption() const {
-
return "Get Scene Tree";
}
@@ -2697,7 +2539,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -2719,7 +2560,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptSceneTree::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSceneTree *instance = memnew(VisualScriptNodeInstanceSceneTree);
instance->node = this;
instance->instance = p_instance;
@@ -2727,7 +2567,6 @@ VisualScriptNodeInstance *VisualScriptSceneTree::instance(VisualScriptInstance *
}
VisualScriptSceneTree::TypeGuess VisualScriptSceneTree::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
TypeGuess tg;
tg.type = Variant::OBJECT;
tg.gdclass = "SceneTree";
@@ -2748,46 +2587,38 @@ VisualScriptSceneTree::VisualScriptSceneTree() {
//////////////////////////////////////////
int VisualScriptResourcePath::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptResourcePath::has_input_sequence_port() const {
-
return false;
}
int VisualScriptResourcePath::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptResourcePath::get_output_value_port_count() const {
+int VisualScriptResourcePath::get_output_value_port_count() const {
return 1;
}
String VisualScriptResourcePath::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptResourcePath::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptResourcePath::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(Variant::STRING, path);
}
String VisualScriptResourcePath::get_caption() const {
-
return "Resource Path";
}
void VisualScriptResourcePath::set_resource_path(const String &p_path) {
-
path = p_path;
_change_notify();
ports_changed_notify();
@@ -2804,21 +2635,18 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = path;
return 0;
}
};
VisualScriptNodeInstance *VisualScriptResourcePath::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceResourcePath *instance = memnew(VisualScriptNodeInstanceResourcePath);
instance->path = path;
return instance;
}
void VisualScriptResourcePath::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_resource_path", "path"), &VisualScriptResourcePath::set_resource_path);
ClassDB::bind_method(D_METHOD("get_resource_path"), &VisualScriptResourcePath::get_resource_path);
@@ -2826,7 +2654,6 @@ void VisualScriptResourcePath::_bind_methods() {
}
VisualScriptResourcePath::VisualScriptResourcePath() {
-
path = "";
}
@@ -2835,47 +2662,41 @@ VisualScriptResourcePath::VisualScriptResourcePath() {
//////////////////////////////////////////
int VisualScriptSelf::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptSelf::has_input_sequence_port() const {
-
return false;
}
int VisualScriptSelf::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptSelf::get_output_value_port_count() const {
+int VisualScriptSelf::get_output_value_port_count() const {
return 1;
}
String VisualScriptSelf::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const {
-
String type_name;
- if (get_visual_script().is_valid())
+ if (get_visual_script().is_valid()) {
type_name = get_visual_script()->get_instance_base_type();
- else
+ } else {
type_name = "instance";
+ }
return PropertyInfo(Variant::OBJECT, type_name);
}
String VisualScriptSelf::get_caption() const {
-
return "Get Self";
}
@@ -2886,28 +2707,26 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = instance->get_owner_ptr();
return 0;
}
};
VisualScriptNodeInstance *VisualScriptSelf::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSelf *instance = memnew(VisualScriptNodeInstanceSelf);
instance->instance = p_instance;
return instance;
}
VisualScriptSelf::TypeGuess VisualScriptSelf::guess_output_type(TypeGuess *p_inputs, int p_output) const {
-
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
tg.gdclass = "Object";
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return tg;
+ }
tg.gdclass = script->get_instance_base_type();
tg.script = script;
@@ -2926,7 +2745,6 @@ VisualScriptSelf::VisualScriptSelf() {
//////////////////////////////////////////
int VisualScriptCustomNode::get_output_sequence_port_count() const {
-
if (get_script_instance() && get_script_instance()->has_method("_get_output_sequence_port_count")) {
return get_script_instance()->call("_get_output_sequence_port_count");
}
@@ -2934,7 +2752,6 @@ int VisualScriptCustomNode::get_output_sequence_port_count() const {
}
bool VisualScriptCustomNode::has_input_sequence_port() const {
-
if (get_script_instance() && get_script_instance()->has_method("_has_input_sequence_port")) {
return get_script_instance()->call("_has_input_sequence_port");
}
@@ -2942,14 +2759,13 @@ bool VisualScriptCustomNode::has_input_sequence_port() const {
}
int VisualScriptCustomNode::get_input_value_port_count() const {
-
if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_count")) {
return get_script_instance()->call("_get_input_value_port_count");
}
return 0;
}
-int VisualScriptCustomNode::get_output_value_port_count() const {
+int VisualScriptCustomNode::get_output_value_port_count() const {
if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_count")) {
return get_script_instance()->call("_get_output_value_port_count");
}
@@ -2957,7 +2773,6 @@ int VisualScriptCustomNode::get_output_value_port_count() const {
}
String VisualScriptCustomNode::get_output_sequence_port_text(int p_port) const {
-
if (get_script_instance() && get_script_instance()->has_method("_get_output_sequence_port_text")) {
return get_script_instance()->call("_get_output_sequence_port_text", p_port);
}
@@ -2966,7 +2781,6 @@ String VisualScriptCustomNode::get_output_sequence_port_text(int p_port) const {
}
PropertyInfo VisualScriptCustomNode::get_input_value_port_info(int p_idx) const {
-
PropertyInfo info;
if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_type")) {
info.type = Variant::Type(int(get_script_instance()->call("_get_input_value_port_type", p_idx)));
@@ -2978,7 +2792,6 @@ PropertyInfo VisualScriptCustomNode::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptCustomNode::get_output_value_port_info(int p_idx) const {
-
PropertyInfo info;
if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_type")) {
info.type = Variant::Type(int(get_script_instance()->call("_get_output_value_port_type", p_idx)));
@@ -2990,7 +2803,6 @@ PropertyInfo VisualScriptCustomNode::get_output_value_port_info(int p_idx) const
}
String VisualScriptCustomNode::get_caption() const {
-
if (get_script_instance() && get_script_instance()->has_method("_get_caption")) {
return get_script_instance()->call("_get_caption");
}
@@ -2998,7 +2810,6 @@ String VisualScriptCustomNode::get_caption() const {
}
String VisualScriptCustomNode::get_text() const {
-
if (get_script_instance() && get_script_instance()->has_method("_get_text")) {
return get_script_instance()->call("_get_text");
}
@@ -3006,7 +2817,6 @@ String VisualScriptCustomNode::get_text() const {
}
String VisualScriptCustomNode::get_category() const {
-
if (get_script_instance() && get_script_instance()->has_method("_get_category")) {
return get_script_instance()->call("_get_category");
}
@@ -3023,7 +2833,6 @@ public:
virtual int get_working_memory_size() const { return work_mem_size; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (node->get_script_instance()) {
#ifdef DEBUG_ENABLED
if (!node->get_script_instance()->has_method(VisualScriptLanguage::singleton->_step)) {
@@ -3085,7 +2894,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceCustomNode *instance = memnew(VisualScriptNodeInstanceCustomNode);
instance->instance = p_instance;
instance->node = this;
@@ -3106,7 +2914,6 @@ void VisualScriptCustomNode::_script_changed() {
}
void VisualScriptCustomNode::_bind_methods() {
-
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_sequence_port_count"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_input_sequence_port"));
@@ -3150,42 +2957,35 @@ VisualScriptCustomNode::VisualScriptCustomNode() {
//////////////////////////////////////////
int VisualScriptSubCall::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptSubCall::has_input_sequence_port() const {
-
return true;
}
int VisualScriptSubCall::get_input_value_port_count() const {
-
Ref<Script> script = get_script();
if (script.is_valid() && script->has_method(VisualScriptLanguage::singleton->_subcall)) {
-
MethodInfo mi = script->get_method_info(VisualScriptLanguage::singleton->_subcall);
return mi.arguments.size();
}
return 0;
}
-int VisualScriptSubCall::get_output_value_port_count() const {
+int VisualScriptSubCall::get_output_value_port_count() const {
return 1;
}
String VisualScriptSubCall::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptSubCall::get_input_value_port_info(int p_idx) const {
-
Ref<Script> script = get_script();
if (script.is_valid() && script->has_method(VisualScriptLanguage::singleton->_subcall)) {
-
MethodInfo mi = script->get_method_info(VisualScriptLanguage::singleton->_subcall);
return mi.arguments[p_idx];
}
@@ -3194,7 +2994,6 @@ PropertyInfo VisualScriptSubCall::get_input_value_port_info(int p_idx) const {
}
PropertyInfo VisualScriptSubCall::get_output_value_port_info(int p_idx) const {
-
Ref<Script> script = get_script();
if (script.is_valid() && script->has_method(VisualScriptLanguage::singleton->_subcall)) {
MethodInfo mi = script->get_method_info(VisualScriptLanguage::singleton->_subcall);
@@ -3204,25 +3003,24 @@ PropertyInfo VisualScriptSubCall::get_output_value_port_info(int p_idx) const {
}
String VisualScriptSubCall::get_caption() const {
-
return "SubCall";
}
String VisualScriptSubCall::get_text() const {
-
Ref<Script> script = get_script();
if (script.is_valid()) {
- if (script->get_name() != String())
+ if (script->get_name() != String()) {
return script->get_name();
- if (script->get_path().is_resource_file())
+ }
+ if (script->get_path().is_resource_file()) {
return script->get_path().get_file();
+ }
return script->get_class();
}
return "";
}
String VisualScriptSubCall::get_category() const {
-
return "custom";
}
@@ -3236,7 +3034,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (!valid) {
r_error_str = "Node requires a script with a _subcall(<args>) method to work.";
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -3248,7 +3045,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceSubCall *instance = memnew(VisualScriptNodeInstanceSubCall);
instance->instance = p_instance;
Ref<Script> script = get_script();
@@ -3262,7 +3058,6 @@ VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_
}
void VisualScriptSubCall::_bind_methods() {
-
MethodInfo scmi(Variant::NIL, "_subcall", PropertyInfo(Variant::NIL, "arguments"));
scmi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
BIND_VMETHOD(scmi);
@@ -3276,87 +3071,78 @@ VisualScriptSubCall::VisualScriptSubCall() {
//////////////////////////////////////////
int VisualScriptComment::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptComment::has_input_sequence_port() const {
-
return false;
}
int VisualScriptComment::get_input_value_port_count() const {
return 0;
}
-int VisualScriptComment::get_output_value_port_count() const {
+int VisualScriptComment::get_output_value_port_count() const {
return 0;
}
String VisualScriptComment::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptComment::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptComment::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptComment::get_caption() const {
-
return title;
}
String VisualScriptComment::get_text() const {
-
return description;
}
void VisualScriptComment::set_title(const String &p_title) {
-
- if (title == p_title)
+ if (title == p_title) {
return;
+ }
title = p_title;
ports_changed_notify();
}
String VisualScriptComment::get_title() const {
-
return title;
}
void VisualScriptComment::set_description(const String &p_description) {
-
- if (description == p_description)
+ if (description == p_description) {
return;
+ }
description = p_description;
ports_changed_notify();
}
-String VisualScriptComment::get_description() const {
+String VisualScriptComment::get_description() const {
return description;
}
void VisualScriptComment::set_size(const Size2 &p_size) {
-
- if (size == p_size)
+ if (size == p_size) {
return;
+ }
size = p_size;
ports_changed_notify();
}
-Size2 VisualScriptComment::get_size() const {
+Size2 VisualScriptComment::get_size() const {
return size;
}
String VisualScriptComment::get_category() const {
-
return "data";
}
@@ -3367,20 +3153,17 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
return 0;
}
};
VisualScriptNodeInstance *VisualScriptComment::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceComment *instance = memnew(VisualScriptNodeInstanceComment);
instance->instance = p_instance;
return instance;
}
void VisualScriptComment::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_title", "title"), &VisualScriptComment::set_title);
ClassDB::bind_method(D_METHOD("get_title"), &VisualScriptComment::get_title);
@@ -3396,7 +3179,6 @@ void VisualScriptComment::_bind_methods() {
}
VisualScriptComment::VisualScriptComment() {
-
title = "Comment";
size = Size2(150, 150);
}
@@ -3406,70 +3188,60 @@ VisualScriptComment::VisualScriptComment() {
//////////////////////////////////////////
int VisualScriptConstructor::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptConstructor::has_input_sequence_port() const {
-
return false;
}
int VisualScriptConstructor::get_input_value_port_count() const {
return constructor.arguments.size();
}
-int VisualScriptConstructor::get_output_value_port_count() const {
+int VisualScriptConstructor::get_output_value_port_count() const {
return 1;
}
String VisualScriptConstructor::get_output_sequence_port_text(int p_port) const {
-
return "";
}
PropertyInfo VisualScriptConstructor::get_input_value_port_info(int p_idx) const {
-
return constructor.arguments[p_idx];
}
PropertyInfo VisualScriptConstructor::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(type, "value");
}
String VisualScriptConstructor::get_caption() const {
-
return "Construct " + Variant::get_type_name(type);
}
String VisualScriptConstructor::get_category() const {
-
return "functions";
}
void VisualScriptConstructor::set_constructor_type(Variant::Type p_type) {
-
- if (type == p_type)
+ if (type == p_type) {
return;
+ }
type = p_type;
ports_changed_notify();
}
Variant::Type VisualScriptConstructor::get_constructor_type() const {
-
return type;
}
void VisualScriptConstructor::set_constructor(const Dictionary &p_info) {
-
constructor = MethodInfo::from_dict(p_info);
ports_changed_notify();
}
Dictionary VisualScriptConstructor::get_constructor() const {
-
return constructor;
}
@@ -3482,7 +3254,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
Callable::CallError ce;
*p_outputs[0] = Variant::construct(type, p_inputs, argcount, ce);
if (ce.error != Callable::CallError::CALL_OK) {
@@ -3494,7 +3265,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptConstructor::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceConstructor *instance = memnew(VisualScriptNodeInstanceConstructor);
instance->instance = p_instance;
instance->type = type;
@@ -3503,7 +3273,6 @@ VisualScriptNodeInstance *VisualScriptConstructor::instance(VisualScriptInstance
}
void VisualScriptConstructor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constructor_type", "type"), &VisualScriptConstructor::set_constructor_type);
ClassDB::bind_method(D_METHOD("get_constructor_type"), &VisualScriptConstructor::get_constructor_type);
@@ -3515,14 +3284,12 @@ void VisualScriptConstructor::_bind_methods() {
}
VisualScriptConstructor::VisualScriptConstructor() {
-
type = Variant::NIL;
}
static Map<String, Pair<Variant::Type, MethodInfo>> constructor_map;
static Ref<VisualScriptNode> create_constructor_node(const String &p_name) {
-
ERR_FAIL_COND_V(!constructor_map.has(p_name), Ref<VisualScriptNode>());
Ref<VisualScriptConstructor> vsc;
@@ -3538,69 +3305,60 @@ static Ref<VisualScriptNode> create_constructor_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptLocalVar::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptLocalVar::has_input_sequence_port() const {
-
return false;
}
int VisualScriptLocalVar::get_input_value_port_count() const {
return 0;
}
-int VisualScriptLocalVar::get_output_value_port_count() const {
+int VisualScriptLocalVar::get_output_value_port_count() const {
return 1;
}
String VisualScriptLocalVar::get_output_sequence_port_text(int p_port) const {
-
return "";
}
PropertyInfo VisualScriptLocalVar::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
-PropertyInfo VisualScriptLocalVar::get_output_value_port_info(int p_idx) const {
+PropertyInfo VisualScriptLocalVar::get_output_value_port_info(int p_idx) const {
return PropertyInfo(type, name);
}
String VisualScriptLocalVar::get_caption() const {
-
return "Get Local Var";
}
String VisualScriptLocalVar::get_category() const {
-
return "data";
}
void VisualScriptLocalVar::set_var_name(const StringName &p_name) {
-
- if (name == p_name)
+ if (name == p_name) {
return;
+ }
name = p_name;
ports_changed_notify();
}
StringName VisualScriptLocalVar::get_var_name() const {
-
return name;
}
void VisualScriptLocalVar::set_var_type(Variant::Type p_type) {
-
type = p_type;
ports_changed_notify();
}
Variant::Type VisualScriptLocalVar::get_var_type() const {
-
return type;
}
@@ -3611,14 +3369,12 @@ public:
virtual int get_working_memory_size() const { return 1; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_outputs[0] = *p_working_mem;
return 0;
}
};
VisualScriptNodeInstance *VisualScriptLocalVar::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceLocalVar *instance = memnew(VisualScriptNodeInstanceLocalVar);
instance->instance = p_instance;
instance->name = name;
@@ -3627,7 +3383,6 @@ VisualScriptNodeInstance *VisualScriptLocalVar::instance(VisualScriptInstance *p
}
void VisualScriptLocalVar::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_var_name", "name"), &VisualScriptLocalVar::set_var_name);
ClassDB::bind_method(D_METHOD("get_var_name"), &VisualScriptLocalVar::get_var_name);
@@ -3644,7 +3399,6 @@ void VisualScriptLocalVar::_bind_methods() {
}
VisualScriptLocalVar::VisualScriptLocalVar() {
-
name = "new_local";
type = Variant::NIL;
}
@@ -3654,74 +3408,64 @@ VisualScriptLocalVar::VisualScriptLocalVar() {
//////////////////////////////////////////
int VisualScriptLocalVarSet::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptLocalVarSet::has_input_sequence_port() const {
-
return true;
}
int VisualScriptLocalVarSet::get_input_value_port_count() const {
return 1;
}
-int VisualScriptLocalVarSet::get_output_value_port_count() const {
+int VisualScriptLocalVarSet::get_output_value_port_count() const {
return 1;
}
String VisualScriptLocalVarSet::get_output_sequence_port_text(int p_port) const {
-
return "";
}
PropertyInfo VisualScriptLocalVarSet::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo(type, "set");
}
-PropertyInfo VisualScriptLocalVarSet::get_output_value_port_info(int p_idx) const {
+PropertyInfo VisualScriptLocalVarSet::get_output_value_port_info(int p_idx) const {
return PropertyInfo(type, "get");
}
String VisualScriptLocalVarSet::get_caption() const {
-
return "Set Local Var";
}
String VisualScriptLocalVarSet::get_text() const {
-
return name;
}
String VisualScriptLocalVarSet::get_category() const {
-
return "data";
}
void VisualScriptLocalVarSet::set_var_name(const StringName &p_name) {
-
- if (name == p_name)
+ if (name == p_name) {
return;
+ }
name = p_name;
ports_changed_notify();
}
StringName VisualScriptLocalVarSet::get_var_name() const {
-
return name;
}
void VisualScriptLocalVarSet::set_var_type(Variant::Type p_type) {
-
type = p_type;
ports_changed_notify();
}
Variant::Type VisualScriptLocalVarSet::get_var_type() const {
-
return type;
}
@@ -3732,7 +3476,6 @@ public:
virtual int get_working_memory_size() const { return 1; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
*p_working_mem = *p_inputs[0];
*p_outputs[0] = *p_working_mem;
return 0;
@@ -3740,7 +3483,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptLocalVarSet::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceLocalVarSet *instance = memnew(VisualScriptNodeInstanceLocalVarSet);
instance->instance = p_instance;
instance->name = name;
@@ -3749,7 +3491,6 @@ VisualScriptNodeInstance *VisualScriptLocalVarSet::instance(VisualScriptInstance
}
void VisualScriptLocalVarSet::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_var_name", "name"), &VisualScriptLocalVarSet::set_var_name);
ClassDB::bind_method(D_METHOD("get_var_name"), &VisualScriptLocalVarSet::get_var_name);
@@ -3766,7 +3507,6 @@ void VisualScriptLocalVarSet::_bind_methods() {
}
VisualScriptLocalVarSet::VisualScriptLocalVarSet() {
-
name = "new_local";
type = Variant::NIL;
}
@@ -3776,34 +3516,30 @@ VisualScriptLocalVarSet::VisualScriptLocalVarSet() {
//////////////////////////////////////////
int VisualScriptInputAction::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptInputAction::has_input_sequence_port() const {
-
return false;
}
int VisualScriptInputAction::get_input_value_port_count() const {
return 0;
}
-int VisualScriptInputAction::get_output_value_port_count() const {
+int VisualScriptInputAction::get_output_value_port_count() const {
return 1;
}
String VisualScriptInputAction::get_output_sequence_port_text(int p_port) const {
-
return "";
}
PropertyInfo VisualScriptInputAction::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
-PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) const {
+PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) const {
String mstr;
switch (mode) {
case MODE_PRESSED: {
@@ -3824,39 +3560,36 @@ PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) cons
}
String VisualScriptInputAction::get_caption() const {
-
return "Action " + name;
}
String VisualScriptInputAction::get_category() const {
-
return "data";
}
void VisualScriptInputAction::set_action_name(const StringName &p_name) {
-
- if (name == p_name)
+ if (name == p_name) {
return;
+ }
name = p_name;
ports_changed_notify();
}
StringName VisualScriptInputAction::get_action_name() const {
-
return name;
}
void VisualScriptInputAction::set_action_mode(Mode p_mode) {
-
- if (mode == p_mode)
+ if (mode == p_mode) {
return;
+ }
mode = p_mode;
ports_changed_notify();
}
-VisualScriptInputAction::Mode VisualScriptInputAction::get_action_mode() const {
+VisualScriptInputAction::Mode VisualScriptInputAction::get_action_mode() const {
return mode;
}
@@ -3867,7 +3600,6 @@ public:
VisualScriptInputAction::Mode mode;
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
switch (mode) {
case VisualScriptInputAction::MODE_PRESSED: {
*p_outputs[0] = Input::get_singleton()->is_action_pressed(action);
@@ -3888,7 +3620,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptInputAction::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceInputAction *instance = memnew(VisualScriptNodeInstanceInputAction);
instance->instance = p_instance;
instance->action = name;
@@ -3898,9 +3629,7 @@ VisualScriptNodeInstance *VisualScriptInputAction::instance(VisualScriptInstance
}
void VisualScriptInputAction::_validate_property(PropertyInfo &property) const {
-
if (property.name == "action") {
-
property.hint = PROPERTY_HINT_ENUM;
String actions;
@@ -3911,8 +3640,9 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const {
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
- if (!pi.name.begins_with("input/"))
+ if (!pi.name.begins_with("input/")) {
continue;
+ }
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
@@ -3922,8 +3652,9 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const {
al.sort();
for (int i = 0; i < al.size(); i++) {
- if (actions != String())
+ if (actions != String()) {
actions += ",";
+ }
actions += al[i];
}
@@ -3932,7 +3663,6 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const {
}
void VisualScriptInputAction::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_action_name", "name"), &VisualScriptInputAction::set_action_name);
ClassDB::bind_method(D_METHOD("get_action_name"), &VisualScriptInputAction::get_action_name);
@@ -3949,7 +3679,6 @@ void VisualScriptInputAction::_bind_methods() {
}
VisualScriptInputAction::VisualScriptInputAction() {
-
name = "";
mode = MODE_PRESSED;
}
@@ -3959,50 +3688,42 @@ VisualScriptInputAction::VisualScriptInputAction() {
//////////////////////////////////////////
int VisualScriptDeconstruct::get_output_sequence_port_count() const {
-
return 0;
}
bool VisualScriptDeconstruct::has_input_sequence_port() const {
-
return false;
}
int VisualScriptDeconstruct::get_input_value_port_count() const {
return 1;
}
-int VisualScriptDeconstruct::get_output_value_port_count() const {
+int VisualScriptDeconstruct::get_output_value_port_count() const {
return elements.size();
}
String VisualScriptDeconstruct::get_output_sequence_port_text(int p_port) const {
-
return "";
}
PropertyInfo VisualScriptDeconstruct::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo(type, "value");
}
PropertyInfo VisualScriptDeconstruct::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo(elements[p_idx].type, elements[p_idx].name);
}
String VisualScriptDeconstruct::get_caption() const {
-
return "Deconstruct " + Variant::get_type_name(type);
}
String VisualScriptDeconstruct::get_category() const {
-
return "functions";
}
void VisualScriptDeconstruct::_update_elements() {
-
elements.clear();
Variant v;
Callable::CallError ce;
@@ -4012,7 +3733,6 @@ void VisualScriptDeconstruct::_update_elements() {
v.get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
Element e;
e.name = E->get().name;
e.type = E->get().type;
@@ -4021,9 +3741,9 @@ void VisualScriptDeconstruct::_update_elements() {
}
void VisualScriptDeconstruct::set_deconstruct_type(Variant::Type p_type) {
-
- if (type == p_type)
+ if (type == p_type) {
return;
+ }
type = p_type;
_update_elements();
@@ -4032,12 +3752,10 @@ void VisualScriptDeconstruct::set_deconstruct_type(Variant::Type p_type) {
}
Variant::Type VisualScriptDeconstruct::get_deconstruct_type() const {
-
return type;
}
void VisualScriptDeconstruct::_set_elem_cache(const Array &p_elements) {
-
ERR_FAIL_COND(p_elements.size() % 2 == 1);
elements.resize(p_elements.size() / 2);
for (int i = 0; i < elements.size(); i++) {
@@ -4047,7 +3765,6 @@ void VisualScriptDeconstruct::_set_elem_cache(const Array &p_elements) {
}
Array VisualScriptDeconstruct::_get_elem_cache() const {
-
Array ret;
for (int i = 0; i < elements.size(); i++) {
ret.push_back(elements[i].name);
@@ -4064,7 +3781,6 @@ public:
//virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
Variant in = *p_inputs[0];
for (int i = 0; i < outputs.size(); i++) {
@@ -4082,7 +3798,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptDeconstruct::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceDeconstruct *instance = memnew(VisualScriptNodeInstanceDeconstruct);
instance->instance = p_instance;
instance->outputs.resize(elements.size());
@@ -4097,7 +3812,6 @@ void VisualScriptDeconstruct::_validate_property(PropertyInfo &property) const {
}
void VisualScriptDeconstruct::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_deconstruct_type", "type"), &VisualScriptDeconstruct::set_deconstruct_type);
ClassDB::bind_method(D_METHOD("get_deconstruct_type"), &VisualScriptDeconstruct::get_deconstruct_type);
@@ -4114,7 +3828,6 @@ void VisualScriptDeconstruct::_bind_methods() {
}
VisualScriptDeconstruct::VisualScriptDeconstruct() {
-
type = Variant::NIL;
}
@@ -4127,7 +3840,6 @@ static Ref<VisualScriptNode> create_node_deconst_typed(const String &p_name) {
}
void register_visual_script_nodes() {
-
VisualScriptLanguage::singleton->add_register_func("data/set_variable", create_node_generic<VisualScriptVariableSet>);
VisualScriptLanguage::singleton->add_register_func("data/get_variable", create_node_generic<VisualScriptVariableGet>);
VisualScriptLanguage::singleton->add_register_func("data/engine_singleton", create_node_generic<VisualScriptEngineSingleton>);
@@ -4199,12 +3911,10 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("functions/compose_array", create_node_generic<VisualScriptComposeArray>);
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
-
List<MethodInfo> constructors;
Variant::get_constructor_list(Variant::Type(i), &constructors);
for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) {
-
if (E->get().arguments.size() > 0) {
String name = "functions/constructors/" + Variant::get_type_name(Variant::Type(i)) + "(";
for (int j = 0; j < E->get().arguments.size(); j++) {
@@ -4229,6 +3939,5 @@ void register_visual_script_nodes() {
}
void unregister_visual_script_nodes() {
-
constructor_map.clear();
}
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 0df5071491..fa284b216c 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -34,7 +34,6 @@
#include "visual_script.h"
class VisualScriptFunction : public VisualScriptNode {
-
GDCLASS(VisualScriptFunction, VisualScriptNode);
struct Argument {
@@ -104,7 +103,6 @@ public:
};
class VisualScriptLists : public VisualScriptNode {
-
GDCLASS(VisualScriptLists, VisualScriptNode)
struct Port {
@@ -176,7 +174,6 @@ public:
};
class VisualScriptComposeArray : public VisualScriptLists {
-
GDCLASS(VisualScriptComposeArray, VisualScriptLists)
public:
@@ -201,7 +198,6 @@ public:
};
class VisualScriptOperator : public VisualScriptNode {
-
GDCLASS(VisualScriptOperator, VisualScriptNode);
Variant::Type typed;
@@ -237,7 +233,6 @@ public:
};
class VisualScriptSelect : public VisualScriptNode {
-
GDCLASS(VisualScriptSelect, VisualScriptNode);
Variant::Type typed;
@@ -270,7 +265,6 @@ public:
};
class VisualScriptVariableGet : public VisualScriptNode {
-
GDCLASS(VisualScriptVariableGet, VisualScriptNode);
StringName variable;
@@ -303,7 +297,6 @@ public:
};
class VisualScriptVariableSet : public VisualScriptNode {
-
GDCLASS(VisualScriptVariableSet, VisualScriptNode);
StringName variable;
@@ -336,7 +329,6 @@ public:
};
class VisualScriptConstant : public VisualScriptNode {
-
GDCLASS(VisualScriptConstant, VisualScriptNode);
Variant::Type type;
@@ -373,7 +365,6 @@ public:
};
class VisualScriptPreload : public VisualScriptNode {
-
GDCLASS(VisualScriptPreload, VisualScriptNode);
Ref<Resource> preload;
@@ -405,7 +396,6 @@ public:
};
class VisualScriptIndexGet : public VisualScriptNode {
-
GDCLASS(VisualScriptIndexGet, VisualScriptNode);
public:
@@ -429,7 +419,6 @@ public:
};
class VisualScriptIndexSet : public VisualScriptNode {
-
GDCLASS(VisualScriptIndexSet, VisualScriptNode);
public:
@@ -453,7 +442,6 @@ public:
};
class VisualScriptGlobalConstant : public VisualScriptNode {
-
GDCLASS(VisualScriptGlobalConstant, VisualScriptNode);
int index;
@@ -484,7 +472,6 @@ public:
};
class VisualScriptClassConstant : public VisualScriptNode {
-
GDCLASS(VisualScriptClassConstant, VisualScriptNode);
StringName base_type;
@@ -521,7 +508,6 @@ public:
};
class VisualScriptBasicTypeConstant : public VisualScriptNode {
-
GDCLASS(VisualScriptBasicTypeConstant, VisualScriptNode);
Variant::Type type;
@@ -559,7 +545,6 @@ public:
};
class VisualScriptMathConstant : public VisualScriptNode {
-
GDCLASS(VisualScriptMathConstant, VisualScriptNode);
public:
@@ -609,7 +594,6 @@ public:
VARIANT_ENUM_CAST(VisualScriptMathConstant::MathConstant)
class VisualScriptEngineSingleton : public VisualScriptNode {
-
GDCLASS(VisualScriptEngineSingleton, VisualScriptNode);
String singleton;
@@ -645,7 +629,6 @@ public:
};
class VisualScriptSceneNode : public VisualScriptNode {
-
GDCLASS(VisualScriptSceneNode, VisualScriptNode);
NodePath path;
@@ -680,7 +663,6 @@ public:
};
class VisualScriptSceneTree : public VisualScriptNode {
-
GDCLASS(VisualScriptSceneTree, VisualScriptNode);
protected:
@@ -710,7 +692,6 @@ public:
};
class VisualScriptResourcePath : public VisualScriptNode {
-
GDCLASS(VisualScriptResourcePath, VisualScriptNode);
String path;
@@ -742,7 +723,6 @@ public:
};
class VisualScriptSelf : public VisualScriptNode {
-
GDCLASS(VisualScriptSelf, VisualScriptNode);
protected:
@@ -771,7 +751,6 @@ public:
};
class VisualScriptCustomNode : public VisualScriptNode {
-
GDCLASS(VisualScriptCustomNode, VisualScriptNode);
protected:
@@ -819,7 +798,6 @@ public:
VARIANT_ENUM_CAST(VisualScriptCustomNode::StartMode);
class VisualScriptSubCall : public VisualScriptNode {
-
GDCLASS(VisualScriptSubCall, VisualScriptNode);
protected:
@@ -847,7 +825,6 @@ public:
};
class VisualScriptComment : public VisualScriptNode {
-
GDCLASS(VisualScriptComment, VisualScriptNode);
String title;
@@ -888,7 +865,6 @@ public:
};
class VisualScriptConstructor : public VisualScriptNode {
-
GDCLASS(VisualScriptConstructor, VisualScriptNode);
Variant::Type type;
@@ -924,7 +900,6 @@ public:
};
class VisualScriptLocalVar : public VisualScriptNode {
-
GDCLASS(VisualScriptLocalVar, VisualScriptNode);
StringName name;
@@ -960,7 +935,6 @@ public:
};
class VisualScriptLocalVarSet : public VisualScriptNode {
-
GDCLASS(VisualScriptLocalVarSet, VisualScriptNode);
StringName name;
@@ -997,7 +971,6 @@ public:
};
class VisualScriptInputAction : public VisualScriptNode {
-
GDCLASS(VisualScriptInputAction, VisualScriptNode);
public:
@@ -1045,7 +1018,6 @@ public:
VARIANT_ENUM_CAST(VisualScriptInputAction::Mode)
class VisualScriptDeconstruct : public VisualScriptNode {
-
GDCLASS(VisualScriptDeconstruct, VisualScriptNode);
struct Element {
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index f57853078d..3c44faab90 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -46,23 +46,21 @@ void VisualScriptPropertySelector::_text_changed(const String &p_newtext) {
}
void VisualScriptPropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
-
Ref<InputEventKey> k = p_ie;
if (k.is_valid()) {
-
switch (k->get_keycode()) {
case KEY_UP:
case KEY_DOWN:
case KEY_PAGEUP:
case KEY_PAGEDOWN: {
-
search_options->call("_gui_input", k);
search_box->accept_event();
TreeItem *root = search_options->get_root();
- if (!root->get_children())
+ if (!root->get_children()) {
break;
+ }
TreeItem *current = search_options->get_selected();
@@ -153,11 +151,13 @@ void VisualScriptPropertySelector::_update_search() {
}
}
for (List<PropertyInfo>::Element *F = props.front(); F; F = F->next()) {
- if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE))
+ if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
continue;
+ }
- if (type_filter.size() && type_filter.find(F->get().type) == -1)
+ if (type_filter.size() && type_filter.find(F->get().type) == -1) {
continue;
+ }
// capitalize() also converts underscore to space, we'll match again both possible styles
String get_text_raw = String(vformat(TTR("Get %s"), F->get().name));
@@ -172,7 +172,7 @@ void VisualScriptPropertySelector::_update_search() {
item->set_metadata(0, F->get().name);
item->set_icon(0, type_icons[F->get().type]);
item->set_metadata(1, "get");
- item->set_collapsed(1);
+ item->set_collapsed(true);
item->set_selectable(0, true);
item->set_selectable(1, false);
item->set_selectable(2, false);
@@ -199,7 +199,6 @@ void VisualScriptPropertySelector::_update_search() {
v = Variant::construct(type, nullptr, 0, ce);
v.get_method_list(&methods);
} else {
-
Object *obj = ObjectDB::get_instance(script);
if (Object::cast_to<Script>(obj)) {
Object::cast_to<Script>(obj)->get_script_method_list(&methods);
@@ -209,23 +208,24 @@ void VisualScriptPropertySelector::_update_search() {
}
}
for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
-
String name = M->get().name.get_slice(":", 0);
- if (name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL))
+ if (name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
continue;
+ }
- if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL))
+ if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
continue;
+ }
- if (!virtuals_only && (M->get().flags & METHOD_FLAG_VIRTUAL))
+ if (!virtuals_only && (M->get().flags & METHOD_FLAG_VIRTUAL)) {
continue;
+ }
MethodInfo mi = M->get();
String desc_arguments;
if (mi.arguments.size() > 0) {
desc_arguments = "(";
for (int i = 0; i < mi.arguments.size(); i++) {
-
if (i > 0) {
desc_arguments += ", ";
}
@@ -257,7 +257,7 @@ void VisualScriptPropertySelector::_update_search() {
item->set_selectable(0, true);
item->set_metadata(1, "method");
- item->set_collapsed(1);
+ item->set_collapsed(true);
item->set_selectable(1, false);
item->set_selectable(2, false);
@@ -320,7 +320,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name,
item->set_metadata(0, name);
item->set_metadata(1, "action");
item->set_selectable(0, true);
- item->set_collapsed(1);
+ item->set_collapsed(true);
item->set_selectable(1, false);
item->set_selectable(2, false);
item->set_metadata(2, connecting);
@@ -359,8 +359,9 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
bool in_modifier = p_modifiers.empty();
for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
- if (E->get().findn(F->get()) != -1)
+ if (E->get().findn(F->get()) != -1) {
in_modifier = true;
+ }
}
if (!in_modifier) {
continue;
@@ -411,21 +412,21 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
}
void VisualScriptPropertySelector::_confirmed() {
-
TreeItem *ti = search_options->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
set_visible(false);
}
void VisualScriptPropertySelector::_item_selected() {
-
help_bit->set_text("");
TreeItem *item = search_options->get_selected();
- if (!item)
+ if (!item) {
return;
+ }
String name = item->get_metadata(0);
String class_type;
@@ -442,12 +443,11 @@ void VisualScriptPropertySelector::_item_selected() {
String at_class = class_type;
while (at_class != String()) {
-
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
if (E) {
for (int i = 0; i < E->get().properties.size(); i++) {
if (E->get().properties[i].name == name) {
- text = E->get().properties[i].description;
+ text = DTR(E->get().properties[i].description);
}
}
}
@@ -457,12 +457,11 @@ void VisualScriptPropertySelector::_item_selected() {
at_class = class_type;
while (at_class != String()) {
-
Map<String, DocData::ClassDoc>::Element *C = dd->class_list.find(at_class);
if (C) {
for (int i = 0; i < C->get().methods.size(); i++) {
if (C->get().methods[i].name == name) {
- text = C->get().methods[i].description;
+ text = DTR(C->get().methods[i].description);
}
}
}
@@ -474,7 +473,7 @@ void VisualScriptPropertySelector::_item_selected() {
for (int i = 0; i < T->get().methods.size(); i++) {
Vector<String> functions = name.rsplit("/", false, 1);
if (T->get().methods[i].name == functions[functions.size() - 1]) {
- text = T->get().methods[i].description;
+ text = DTR(T->get().methods[i].description);
}
}
}
@@ -493,7 +492,7 @@ void VisualScriptPropertySelector::_item_selected() {
if (typecast_node.is_valid()) {
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(typecast_node->get_class_name());
if (F) {
- text = F->get().description;
+ text = DTR(F->get().description);
}
}
@@ -503,7 +502,7 @@ void VisualScriptPropertySelector::_item_selected() {
if (F) {
for (int i = 0; i < F->get().constants.size(); i++) {
if (F->get().constants[i].value.to_int() == int(builtin_node->get_func())) {
- text = F->get().constants[i].description;
+ text = DTR(F->get().constants[i].description);
}
}
}
@@ -512,8 +511,9 @@ void VisualScriptPropertySelector::_item_selected() {
memdelete(names);
- if (text == String())
+ if (text == String()) {
return;
+ }
help_bit->set_text(text);
}
@@ -523,15 +523,12 @@ void VisualScriptPropertySelector::_hide_requested() {
}
void VisualScriptPropertySelector::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
connect("confirmed", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
}
}
void VisualScriptPropertySelector::select_method_from_base_type(const String &p_base, const String &p_current, const bool p_virtuals_only, const bool p_connecting, bool clear_text) {
-
base_type = p_base;
selected = p_current;
type = Variant::NIL;
@@ -540,10 +537,11 @@ void VisualScriptPropertySelector::select_method_from_base_type(const String &p_
virtuals_only = p_virtuals_only;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
connecting = p_connecting;
@@ -555,7 +553,6 @@ void VisualScriptPropertySelector::set_type_filter(const Vector<Variant::Type> &
}
void VisualScriptPropertySelector::select_from_base_type(const String &p_base, const String &p_current, bool p_virtuals_only, bool p_seq_connect, const bool p_connecting, bool clear_text) {
-
base_type = p_base;
selected = p_current;
type = Variant::NIL;
@@ -565,10 +562,11 @@ void VisualScriptPropertySelector::select_from_base_type(const String &p_base, c
virtuals_only = p_virtuals_only;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
seq_connect = p_seq_connect;
connecting = p_connecting;
@@ -589,10 +587,11 @@ void VisualScriptPropertySelector::select_from_script(const Ref<Script> &p_scrip
virtuals_only = false;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
seq_connect = false;
connecting = p_connecting;
@@ -611,10 +610,11 @@ void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type,
virtuals_only = false;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
seq_connect = false;
connecting = p_connecting;
@@ -632,10 +632,11 @@ void VisualScriptPropertySelector::select_from_action(const String &p_type, cons
virtuals_only = false;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
seq_connect = true;
connecting = p_connecting;
@@ -653,10 +654,11 @@ void VisualScriptPropertySelector::select_from_instance(Object *p_instance, cons
virtuals_only = false;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
seq_connect = false;
connecting = p_connecting;
@@ -673,10 +675,11 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas
instance = nullptr;
virtuals_only = false;
show_window(.5f);
- if (clear_text)
+ if (clear_text) {
search_box->set_text("");
- else
+ } else {
search_box->select_all();
+ }
search_box->grab_focus();
connecting = p_connecting;
@@ -684,17 +687,14 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas
}
void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
-
popup_centered_ratio(p_screen_ratio);
}
void VisualScriptPropertySelector::_bind_methods() {
-
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::STRING, "category"), PropertyInfo(Variant::BOOL, "connecting")));
}
VisualScriptPropertySelector::VisualScriptPropertySelector() {
-
vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 2296745ad0..dd07cc45a7 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -40,46 +40,38 @@
//////////////////////////////////////////
int VisualScriptYield::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptYield::has_input_sequence_port() const {
-
return true;
}
int VisualScriptYield::get_input_value_port_count() const {
-
return 0;
}
-int VisualScriptYield::get_output_value_port_count() const {
+int VisualScriptYield::get_output_value_port_count() const {
return 0;
}
String VisualScriptYield::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptYield::get_input_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
PropertyInfo VisualScriptYield::get_output_value_port_info(int p_idx) const {
-
return PropertyInfo();
}
String VisualScriptYield::get_caption() const {
-
return yield_mode == YIELD_RETURN ? "Yield" : "Wait";
}
String VisualScriptYield::get_text() const {
-
switch (yield_mode) {
case YIELD_RETURN:
return "";
@@ -108,7 +100,6 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (p_start_mode == START_MODE_RESUME_YIELD) {
return 0; //resuming yield
} else {
@@ -126,7 +117,6 @@ public:
int ret = STEP_YIELD_BIT;
switch (mode) {
-
case VisualScriptYield::YIELD_RETURN:
ret = STEP_EXIT_FUNCTION_BIT;
break; //return the yield
@@ -149,7 +139,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptYield::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceYield *instance = memnew(VisualScriptNodeInstanceYield);
//instance->instance=p_instance;
instance->mode = yield_mode;
@@ -158,34 +147,31 @@ VisualScriptNodeInstance *VisualScriptYield::instance(VisualScriptInstance *p_in
}
void VisualScriptYield::set_yield_mode(YieldMode p_mode) {
-
- if (yield_mode == p_mode)
+ if (yield_mode == p_mode) {
return;
+ }
yield_mode = p_mode;
ports_changed_notify();
_change_notify();
}
VisualScriptYield::YieldMode VisualScriptYield::get_yield_mode() {
-
return yield_mode;
}
void VisualScriptYield::set_wait_time(float p_time) {
-
- if (wait_time == p_time)
+ if (wait_time == p_time) {
return;
+ }
wait_time = p_time;
ports_changed_notify();
}
float VisualScriptYield::get_wait_time() {
-
return wait_time;
}
void VisualScriptYield::_validate_property(PropertyInfo &property) const {
-
if (property.name == "wait_time") {
if (yield_mode != YIELD_WAIT) {
property.usage = 0;
@@ -194,7 +180,6 @@ void VisualScriptYield::_validate_property(PropertyInfo &property) const {
}
void VisualScriptYield::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_yield_mode", "mode"), &VisualScriptYield::set_yield_mode);
ClassDB::bind_method(D_METHOD("get_yield_mode"), &VisualScriptYield::get_yield_mode);
@@ -210,14 +195,12 @@ void VisualScriptYield::_bind_methods() {
}
VisualScriptYield::VisualScriptYield() {
-
yield_mode = YIELD_FRAME;
wait_time = 1;
}
template <VisualScriptYield::YieldMode MODE>
static Ref<VisualScriptNode> create_yield_node(const String &p_name) {
-
Ref<VisualScriptYield> node;
node.instance();
node->set_yield_mode(MODE);
@@ -229,30 +212,30 @@ static Ref<VisualScriptNode> create_yield_node(const String &p_name) {
//////////////////////////////////////////////////
int VisualScriptYieldSignal::get_output_sequence_port_count() const {
-
return 1;
}
bool VisualScriptYieldSignal::has_input_sequence_port() const {
-
return true;
}
#ifdef TOOLS_ENABLED
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
- if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
+ if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
return nullptr;
+ }
Ref<Script> scr = p_current_node->get_script();
- if (scr.is_valid() && scr == script)
+ if (scr.is_valid() && scr == script) {
return p_current_node;
+ }
for (int i = 0; i < p_current_node->get_child_count(); i++) {
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
- if (n)
+ if (n) {
return n;
+ }
}
return nullptr;
@@ -260,30 +243,34 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
#endif
Node *VisualScriptYieldSignal::_get_base_node() const {
-
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
- if (!script.is_valid())
+ if (!script.is_valid()) {
return nullptr;
+ }
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
- if (!scene_tree)
+ if (!scene_tree) {
return nullptr;
+ }
Node *edited_scene = scene_tree->get_edited_scene_root();
- if (!edited_scene)
+ if (!edited_scene) {
return nullptr;
+ }
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
- if (!script_node)
+ if (!script_node) {
return nullptr;
+ }
- if (!script_node->has_node(base_path))
+ if (!script_node->has_node(base_path)) {
return nullptr;
+ }
Node *path_to = script_node->get_node(base_path);
@@ -295,60 +282,59 @@ Node *VisualScriptYieldSignal::_get_base_node() const {
}
StringName VisualScriptYieldSignal::_get_base_type() const {
-
- if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid())
+ if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
return get_visual_script()->get_instance_base_type();
- else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
+ } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
Node *path = _get_base_node();
- if (path)
+ if (path) {
return path->get_class();
+ }
}
return base_type;
}
int VisualScriptYieldSignal::get_input_value_port_count() const {
-
- if (call_mode == CALL_MODE_INSTANCE)
+ if (call_mode == CALL_MODE_INSTANCE) {
return 1;
- else
+ } else {
return 0;
+ }
}
-int VisualScriptYieldSignal::get_output_value_port_count() const {
+int VisualScriptYieldSignal::get_output_value_port_count() const {
MethodInfo sr;
- if (!ClassDB::get_signal(_get_base_type(), signal, &sr))
+ if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) {
return 0;
+ }
return sr.arguments.size();
}
String VisualScriptYieldSignal::get_output_sequence_port_text(int p_port) const {
-
return String();
}
PropertyInfo VisualScriptYieldSignal::get_input_value_port_info(int p_idx) const {
-
- if (call_mode == CALL_MODE_INSTANCE)
+ if (call_mode == CALL_MODE_INSTANCE) {
return PropertyInfo(Variant::OBJECT, "instance");
- else
+ } else {
return PropertyInfo();
+ }
}
PropertyInfo VisualScriptYieldSignal::get_output_value_port_info(int p_idx) const {
-
MethodInfo sr;
- if (!ClassDB::get_signal(_get_base_type(), signal, &sr))
+ if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) {
return PropertyInfo(); //no signal
+ }
ERR_FAIL_INDEX_V(p_idx, sr.arguments.size(), PropertyInfo());
return sr.arguments[p_idx];
}
String VisualScriptYieldSignal::get_caption() const {
-
static const char *cname[3] = {
"WaitSignal",
"WaitNodeSignal",
@@ -359,17 +345,17 @@ String VisualScriptYieldSignal::get_caption() const {
}
String VisualScriptYieldSignal::get_text() const {
-
- if (call_mode == CALL_MODE_SELF)
+ if (call_mode == CALL_MODE_SELF) {
return " " + String(signal) + "()";
- else
+ } else {
return " " + _get_base_type() + "." + String(signal) + "()";
+ }
}
void VisualScriptYieldSignal::set_base_type(const StringName &p_type) {
-
- if (base_type == p_type)
+ if (base_type == p_type) {
return;
+ }
base_type = p_type;
@@ -378,29 +364,28 @@ void VisualScriptYieldSignal::set_base_type(const StringName &p_type) {
}
StringName VisualScriptYieldSignal::get_base_type() const {
-
return base_type;
}
void VisualScriptYieldSignal::set_signal(const StringName &p_type) {
-
- if (signal == p_type)
+ if (signal == p_type) {
return;
+ }
signal = p_type;
_change_notify();
ports_changed_notify();
}
-StringName VisualScriptYieldSignal::get_signal() const {
+StringName VisualScriptYieldSignal::get_signal() const {
return signal;
}
void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) {
-
- if (base_path == p_type)
+ if (base_path == p_type) {
return;
+ }
base_path = p_type;
@@ -409,14 +394,13 @@ void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) {
}
NodePath VisualScriptYieldSignal::get_base_path() const {
-
return base_path;
}
void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) {
-
- if (call_mode == p_mode)
+ if (call_mode == p_mode) {
return;
+ }
call_mode = p_mode;
@@ -425,12 +409,10 @@ void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) {
}
VisualScriptYieldSignal::CallMode VisualScriptYieldSignal::get_call_mode() const {
-
return call_mode;
}
void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
-
if (property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
property.usage = PROPERTY_USAGE_NOEDITOR;
@@ -441,7 +423,6 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0;
} else {
-
Node *bnode = _get_base_node();
if (bnode) {
property.hint_string = bnode->get_path(); //convert to loong string
@@ -458,8 +439,9 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
List<String> mstring;
for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
- if (E->get().name.begins_with("_"))
+ if (E->get().name.begins_with("_")) {
continue;
+ }
mstring.push_back(E->get().name.get_slice(":", 0));
}
@@ -467,9 +449,9 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
String ml;
for (List<String>::Element *E = mstring.front(); E; E = E->next()) {
-
- if (ml != String())
+ if (ml != String()) {
ml += ",";
+ }
ml += E->get();
}
@@ -478,7 +460,6 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
}
void VisualScriptYieldSignal::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptYieldSignal::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptYieldSignal::get_base_type);
@@ -493,8 +474,9 @@ void VisualScriptYieldSignal::_bind_methods() {
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i > 0)
+ if (i > 0) {
bt += ",";
+ }
bt += Variant::get_type_name(Variant::Type(i));
}
@@ -524,7 +506,6 @@ public:
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
-
if (p_start_mode == START_MODE_RESUME_YIELD) {
return 0; //resuming yield
} else {
@@ -533,14 +514,11 @@ public:
Object *object = nullptr;
switch (call_mode) {
-
case VisualScriptYieldSignal::CALL_MODE_SELF: {
-
object = instance->get_owner_ptr();
} break;
case VisualScriptYieldSignal::CALL_MODE_NODE_PATH: {
-
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -559,7 +537,6 @@ public:
} break;
case VisualScriptYieldSignal::CALL_MODE_INSTANCE: {
-
object = *p_inputs[0];
if (!object) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -583,7 +560,6 @@ public:
};
VisualScriptNodeInstance *VisualScriptYieldSignal::instance(VisualScriptInstance *p_instance) {
-
VisualScriptNodeInstanceYieldSignal *instance = memnew(VisualScriptNodeInstanceYieldSignal);
instance->node = this;
instance->instance = p_instance;
@@ -593,15 +569,14 @@ VisualScriptNodeInstance *VisualScriptYieldSignal::instance(VisualScriptInstance
instance->output_args = get_output_value_port_count();
return instance;
}
-VisualScriptYieldSignal::VisualScriptYieldSignal() {
+VisualScriptYieldSignal::VisualScriptYieldSignal() {
call_mode = CALL_MODE_SELF;
base_type = "Object";
}
template <VisualScriptYieldSignal::CallMode cmode>
static Ref<VisualScriptNode> create_yield_signal_node(const String &p_name) {
-
Ref<VisualScriptYieldSignal> node;
node.instance();
node->set_call_mode(cmode);
@@ -609,7 +584,6 @@ static Ref<VisualScriptNode> create_yield_signal_node(const String &p_name) {
}
void register_visual_script_yield_nodes() {
-
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_frame", create_yield_node<VisualScriptYield::YIELD_FRAME>);
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_physics_frame", create_yield_node<VisualScriptYield::YIELD_PHYSICS_FRAME>);
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_time", create_yield_node<VisualScriptYield::YIELD_WAIT>);
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index 4b976bd6c6..4877e8b7e6 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -34,7 +34,6 @@
#include "visual_script.h"
class VisualScriptYield : public VisualScriptNode {
-
GDCLASS(VisualScriptYield, VisualScriptNode);
public:
@@ -84,7 +83,6 @@ public:
VARIANT_ENUM_CAST(VisualScriptYield::YieldMode)
class VisualScriptYieldSignal : public VisualScriptNode {
-
GDCLASS(VisualScriptYieldSignal, VisualScriptNode);
public:
diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py
index d22f9454ed..8a384e3066 100644
--- a/modules/vorbis/config.py
+++ b/modules/vorbis/config.py
@@ -1,5 +1,5 @@
def can_build(env, platform):
- return True
+ return env.module_check_dependencies("vorbis", ["ogg"])
def configure(env):
diff --git a/modules/webm/config.py b/modules/webm/config.py
index 93b49d177a..99f8ace114 100644
--- a/modules/webm/config.py
+++ b/modules/webm/config.py
@@ -1,5 +1,8 @@
def can_build(env, platform):
- return platform not in ["iphone"]
+ if platform in ["iphone"]:
+ return False
+
+ return env.module_check_dependencies("webm", ["ogg", "opus", "vorbis"])
def configure(env):
diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp
index 5449dd458c..6248787879 100644
--- a/modules/webm/register_types.cpp
+++ b/modules/webm/register_types.cpp
@@ -35,7 +35,6 @@
static Ref<ResourceFormatLoaderWebm> resource_loader_webm;
void register_webm_types() {
-
resource_loader_webm.instance();
ResourceLoader::add_resource_format_loader(resource_loader_webm, true);
@@ -43,7 +42,6 @@ void register_webm_types() {
}
void unregister_webm_types() {
-
ResourceLoader::remove_resource_format_loader(resource_loader_webm);
resource_loader_webm.unref();
}
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index a2d0f78f5f..832e14d91a 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -48,41 +48,39 @@
#include <mkvparser/mkvparser.h>
class MkvReader : public mkvparser::IMkvReader {
-
public:
MkvReader(const String &p_file) {
-
file = FileAccess::open(p_file, FileAccess::READ);
ERR_FAIL_COND_MSG(!file, "Failed loading resource: '" + p_file + "'.");
}
~MkvReader() {
-
- if (file)
+ if (file) {
memdelete(file);
+ }
}
virtual int Read(long long pos, long len, unsigned char *buf) {
-
if (file) {
-
- if (file->get_position() != (size_t)pos)
+ if (file->get_position() != (size_t)pos) {
file->seek(pos);
- if (file->get_buffer(buf, len) == len)
+ }
+ if (file->get_buffer(buf, len) == len) {
return 0;
+ }
}
return -1;
}
virtual int Length(long long *total, long long *available) {
-
if (file) {
-
const size_t len = file->get_len();
- if (total)
+ if (total) {
*total = len;
- if (available)
+ }
+ if (available) {
*available = len;
+ }
return 0;
}
return -1;
@@ -95,47 +93,23 @@ private:
/**/
VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() :
- audio_track(0),
- webm(nullptr),
- video(nullptr),
- audio(nullptr),
- video_frames(nullptr),
- audio_frame(nullptr),
- video_frames_pos(0),
- video_frames_capacity(0),
- num_decoded_samples(0),
- samples_offset(-1),
- mix_callback(nullptr),
- mix_udata(nullptr),
- playing(false),
- paused(false),
- delay_compensation(0.0),
- time(0.0),
- video_frame_delay(0.0),
- video_pos(0.0),
- texture(memnew(ImageTexture)),
- pcm(nullptr) {}
-VideoStreamPlaybackWebm::~VideoStreamPlaybackWebm() {
+ texture(memnew(ImageTexture)) {}
+VideoStreamPlaybackWebm::~VideoStreamPlaybackWebm() {
delete_pointers();
}
bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
-
file_name = p_file;
webm = memnew(WebMDemuxer(new MkvReader(file_name), 0, audio_track));
if (webm->isOpen()) {
-
video = memnew(VPXDecoder(*webm, OS::get_singleton()->get_processor_count()));
if (video->isOpen()) {
-
audio = memnew(OpusVorbisDecoder(*webm));
if (audio->isOpen()) {
-
audio_frame = memnew(WebMFrame);
pcm = (float *)memalloc(sizeof(float) * audio->getBufferSamples() * webm->getChannels());
} else {
-
memdelete(audio);
audio = nullptr;
}
@@ -157,9 +131,7 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
}
void VideoStreamPlaybackWebm::stop() {
-
if (playing) {
-
delete_pointers();
pcm = nullptr;
@@ -180,8 +152,8 @@ void VideoStreamPlaybackWebm::stop() {
time = 0.0;
playing = false;
}
-void VideoStreamPlaybackWebm::play() {
+void VideoStreamPlaybackWebm::play() {
stop();
delay_compensation = ProjectSettings::get_singleton()->get("audio/video_delay_compensation_ms");
@@ -191,58 +163,52 @@ void VideoStreamPlaybackWebm::play() {
}
bool VideoStreamPlaybackWebm::is_playing() const {
-
return playing;
}
void VideoStreamPlaybackWebm::set_paused(bool p_paused) {
-
paused = p_paused;
}
-bool VideoStreamPlaybackWebm::is_paused() const {
+bool VideoStreamPlaybackWebm::is_paused() const {
return paused;
}
void VideoStreamPlaybackWebm::set_loop(bool p_enable) {
-
//Empty
}
-bool VideoStreamPlaybackWebm::has_loop() const {
+bool VideoStreamPlaybackWebm::has_loop() const {
return false;
}
float VideoStreamPlaybackWebm::get_length() const {
-
- if (webm)
+ if (webm) {
return webm->getLength();
+ }
return 0.0f;
}
float VideoStreamPlaybackWebm::get_playback_position() const {
-
return video_pos;
}
-void VideoStreamPlaybackWebm::seek(float p_time) {
+void VideoStreamPlaybackWebm::seek(float p_time) {
//Not implemented
}
void VideoStreamPlaybackWebm::set_audio_track(int p_idx) {
-
audio_track = p_idx;
}
Ref<Texture2D> VideoStreamPlaybackWebm::get_texture() const {
-
return texture;
}
void VideoStreamPlaybackWebm::update(float p_delta) {
-
- if ((!playing || paused) || !video)
+ if ((!playing || paused) || !video) {
return;
+ }
time += p_delta;
@@ -253,16 +219,13 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
bool audio_buffer_full = false;
if (samples_offset > -1) {
-
//Mix remaining samples
const int to_read = num_decoded_samples - samples_offset;
const int mixed = mix_callback(mix_udata, pcm + samples_offset * webm->getChannels(), to_read);
if (mixed != to_read) {
-
samples_offset += mixed;
audio_buffer_full = true;
} else {
-
samples_offset = -1;
}
}
@@ -270,10 +233,8 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
const bool hasAudio = (audio && mix_callback);
while ((hasAudio && !audio_buffer_full && !has_enough_video_frames()) ||
(!hasAudio && video_frames_pos == 0)) {
-
if (hasAudio && !audio_buffer_full && audio_frame->isValid() &&
audio->getPCMF(*audio_frame, pcm, num_decoded_samples) && num_decoded_samples > 0) {
-
const int mixed = mix_callback(mix_udata, pcm, num_decoded_samples);
if (mixed != num_decoded_samples) {
@@ -284,42 +245,37 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
WebMFrame *video_frame;
if (video_frames_pos >= video_frames_capacity) {
-
WebMFrame **video_frames_new = (WebMFrame **)memrealloc(video_frames, ++video_frames_capacity * sizeof(void *));
ERR_FAIL_COND(!video_frames_new); //Out of memory
(video_frames = video_frames_new)[video_frames_capacity - 1] = memnew(WebMFrame);
}
video_frame = video_frames[video_frames_pos];
- if (!webm->readFrame(video_frame, audio_frame)) //This will invalidate frames
+ if (!webm->readFrame(video_frame, audio_frame)) { //This will invalidate frames
break; //Can't demux, EOS?
+ }
- if (video_frame->isValid())
+ if (video_frame->isValid()) {
++video_frames_pos;
+ }
};
bool video_frame_done = false;
while (video_frames_pos > 0 && !video_frame_done) {
-
WebMFrame *video_frame = video_frames[0];
// It seems VPXDecoder::decode has to be executed even though we might skip this frame
if (video->decode(*video_frame)) {
-
VPXDecoder::IMAGE_ERROR err;
VPXDecoder::Image image;
if (should_process(*video_frame)) {
-
if ((err = video->getImage(image)) != VPXDecoder::NO_FRAME) {
-
if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) {
-
uint8_t *w = frame_data.ptrw();
bool converted = false;
if (image.chromaShiftW == 0 && image.chromaShiftH == 0 && image.cs == VPX_CS_SRGB) {
-
uint8_t *wp = w;
unsigned char *rRow = image.planes[2];
unsigned char *gRow = image.planes[0];
@@ -337,22 +293,18 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
}
converted = true;
} else if (image.chromaShiftW == 1 && image.chromaShiftH == 1) {
-
yuv420_2_rgb8888(w, image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
//libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 1 && image.chromaShiftH == 0) {
-
yuv422_2_rgb8888(w, image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
//libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 0 && image.chromaShiftH == 0) {
-
yuv444_2_rgb8888(w, image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
//libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 2 && image.chromaShiftH == 0) {
-
//libyuv::I411ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2] image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
//converted = true;
}
@@ -372,25 +324,27 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
video_frames[video_frames_pos] = video_frame;
}
- if (video_frames_pos == 0 && webm->isEOS())
+ if (video_frames_pos == 0 && webm->isEOS()) {
stop();
+ }
}
void VideoStreamPlaybackWebm::set_mix_callback(VideoStreamPlayback::AudioMixCallback p_callback, void *p_userdata) {
-
mix_callback = p_callback;
mix_udata = p_userdata;
}
-int VideoStreamPlaybackWebm::get_channels() const {
- if (audio)
+int VideoStreamPlaybackWebm::get_channels() const {
+ if (audio) {
return webm->getChannels();
+ }
return 0;
}
-int VideoStreamPlaybackWebm::get_mix_rate() const {
- if (audio)
+int VideoStreamPlaybackWebm::get_mix_rate() const {
+ if (audio) {
return webm->getSampleRate();
+ }
return 0;
}
@@ -415,52 +369,54 @@ bool VideoStreamPlaybackWebm::should_process(WebMFrame &video_frame) {
}
void VideoStreamPlaybackWebm::delete_pointers() {
-
- if (pcm)
+ if (pcm) {
memfree(pcm);
+ }
- if (audio_frame)
+ if (audio_frame) {
memdelete(audio_frame);
+ }
if (video_frames) {
- for (int i = 0; i < video_frames_capacity; ++i)
+ for (int i = 0; i < video_frames_capacity; ++i) {
memdelete(video_frames[i]);
+ }
memfree(video_frames);
}
- if (video)
+ if (video) {
memdelete(video);
- if (audio)
+ }
+ if (audio) {
memdelete(audio);
+ }
- if (webm)
+ if (webm) {
memdelete(webm);
+ }
}
/**/
-VideoStreamWebm::VideoStreamWebm() :
- audio_track(0) {}
+VideoStreamWebm::VideoStreamWebm() {}
Ref<VideoStreamPlayback> VideoStreamWebm::instance_playback() {
-
Ref<VideoStreamPlaybackWebm> pb = memnew(VideoStreamPlaybackWebm);
pb->set_audio_track(audio_track);
- if (pb->open_file(file))
+ if (pb->open_file(file)) {
return pb;
+ }
return nullptr;
}
void VideoStreamWebm::set_file(const String &p_file) {
-
file = p_file;
}
-String VideoStreamWebm::get_file() {
+String VideoStreamWebm::get_file() {
return file;
}
void VideoStreamWebm::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamWebm::set_file);
ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamWebm::get_file);
@@ -468,14 +424,12 @@ void VideoStreamWebm::_bind_methods() {
}
void VideoStreamWebm::set_audio_track(int p_track) {
-
audio_track = p_track;
}
////////////
RES ResourceFormatLoaderWebm::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) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
if (r_error) {
@@ -499,19 +453,17 @@ RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_origina
}
void ResourceFormatLoaderWebm::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("webm");
}
bool ResourceFormatLoaderWebm::handles_type(const String &p_type) const {
-
return ClassDB::is_parent_class(p_type, "VideoStream");
}
String ResourceFormatLoaderWebm::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "webm")
+ if (el == "webm") {
return "VideoStreamWebm";
+ }
return "";
}
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index 6677fb85aa..f6c148b29b 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -40,31 +40,30 @@ class VPXDecoder;
class OpusVorbisDecoder;
class VideoStreamPlaybackWebm : public VideoStreamPlayback {
-
GDCLASS(VideoStreamPlaybackWebm, VideoStreamPlayback);
String file_name;
- int audio_track;
+ int audio_track = 0;
- WebMDemuxer *webm;
- VPXDecoder *video;
- OpusVorbisDecoder *audio;
+ WebMDemuxer *webm = nullptr;
+ VPXDecoder *video = nullptr;
+ OpusVorbisDecoder *audio = nullptr;
- WebMFrame **video_frames, *audio_frame;
- int video_frames_pos, video_frames_capacity;
+ WebMFrame **video_frames = nullptr, *audio_frame = nullptr;
+ int video_frames_pos = 0, video_frames_capacity = 0;
- int num_decoded_samples, samples_offset;
- AudioMixCallback mix_callback;
- void *mix_udata;
+ int num_decoded_samples = 0, samples_offset = -1;
+ AudioMixCallback mix_callback = nullptr;
+ void *mix_udata = nullptr;
- bool playing, paused;
- double delay_compensation;
- double time, video_frame_delay, video_pos;
+ bool playing = false, paused = false;
+ double delay_compensation = 0.0;
+ double time = 0.0, video_frame_delay = 0.0, video_pos = 0.0;
Vector<uint8_t> frame_data;
Ref<ImageTexture> texture;
- float *pcm;
+ float *pcm = nullptr;
public:
VideoStreamPlaybackWebm();
@@ -107,11 +106,10 @@ private:
/**/
class VideoStreamWebm : public VideoStream {
-
GDCLASS(VideoStreamWebm, VideoStream);
String file;
- int audio_track;
+ int audio_track = 0;
protected:
static void _bind_methods();
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 0998977bb4..d5c80e7909 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -39,14 +39,14 @@
#include <webp/encode.h>
static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quality) {
-
ERR_FAIL_COND_V(p_image.is_null() || p_image->empty(), Vector<uint8_t>());
Ref<Image> img = p_image->duplicate();
- if (img->detect_alpha())
+ if (img->detect_alpha()) {
img->convert(Image::FORMAT_RGBA8);
- else
+ } else {
img->convert(Image::FORMAT_RGB8);
+ }
Size2 s(img->get_width(), img->get_height());
Vector<uint8_t> data = img->get_data();
@@ -55,7 +55,6 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali
uint8_t *dst_buff = nullptr;
size_t dst_size = 0;
if (img->get_format() == Image::FORMAT_RGB8) {
-
dst_size = WebPEncodeRGB(r, s.width, s.height, 3 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff);
} else {
dst_size = WebPEncodeRGBA(r, s.width, s.height, 4 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff);
@@ -76,7 +75,6 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali
}
static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) {
-
int size = p_buffer.size() - 4;
ERR_FAIL_COND_V(size <= 0, Ref<Image>());
const uint8_t *r = p_buffer.ptr();
@@ -113,7 +111,6 @@ static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) {
}
Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p_buffer_len) {
-
ERR_FAIL_NULL_V(p_image, ERR_INVALID_PARAMETER);
WebPBitstreamFeatures features;
@@ -135,13 +132,12 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
ERR_FAIL_COND_V_MSG(errdec, ERR_FILE_CORRUPT, "Failed decoding WebP image.");
- p_image->create(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image);
+ p_image->create(features.width, features.height, false, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image);
return OK;
}
static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) {
-
Ref<Image> img;
img.instance();
Error err = webp_load_image_from_buffer(img.ptr(), p_png, p_size);
@@ -150,7 +146,6 @@ static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) {
}
Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
-
Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
@@ -168,7 +163,6 @@ Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_forc
}
void ImageLoaderWEBP::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("webp");
}
diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h
index 9206ca2525..49a7407600 100644
--- a/modules/webp/image_loader_webp.h
+++ b/modules/webp/image_loader_webp.h
@@ -34,7 +34,6 @@
#include "core/io/image_loader.h"
class ImageLoaderWEBP : public ImageFormatLoader {
-
public:
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp
index fe945b01d4..0788b06309 100644
--- a/modules/webp/register_types.cpp
+++ b/modules/webp/register_types.cpp
@@ -35,12 +35,10 @@
static ImageLoaderWEBP *image_loader_webp = nullptr;
void register_webp_types() {
-
image_loader_webp = memnew(ImageLoaderWEBP);
ImageLoader::add_image_format_loader(image_loader_webp);
}
void unregister_webp_types() {
-
memdelete(image_loader_webp);
}
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
index 504b4705d8..2054276655 100644
--- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
@@ -120,7 +120,7 @@
</argument>
<description>
Sets the SDP description of the local peer. This should be called in response to [signal session_description_created].
- If [code]type[/code] is [code]answer[/code] the peer will start emitting [signal ice_candidate_created].
+ After calling this function the peer will start emitting [signal ice_candidate_created] (unless an [enum Error] different from [constant OK] is returned).
</description>
</method>
<method name="set_remote_description">
diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp
index 40c3f5801b..2c648ba9f9 100644
--- a/modules/webrtc/webrtc_data_channel_js.cpp
+++ b/modules/webrtc/webrtc_data_channel_js.cpp
@@ -68,7 +68,6 @@ void WebRTCDataChannelJS::_on_error() {
}
void WebRTCDataChannelJS::_on_message(uint8_t *p_data, uint32_t p_size, bool p_is_string) {
-
ERR_FAIL_COND_MSG(in_buffer.space_left() < (int)(p_size + 5), "Buffer full! Dropping data.");
uint8_t is_string = p_is_string ? 1 : 0;
diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp
index f294733961..e0c0cad68c 100644
--- a/modules/webrtc/webrtc_multiplayer.cpp
+++ b/modules/webrtc/webrtc_multiplayer.cpp
@@ -65,8 +65,9 @@ bool WebRTCMultiplayer::is_server() const {
}
void WebRTCMultiplayer::poll() {
- if (peer_map.size() == 0)
+ if (peer_map.size() == 0) {
return;
+ }
List<int> remove;
List<int> add;
@@ -113,15 +114,17 @@ void WebRTCMultiplayer::poll() {
// Remove disconnected peers
for (List<int>::Element *E = remove.front(); E; E = E->next()) {
remove_peer(E->get());
- if (next_packet_peer == E->get())
+ if (next_packet_peer == E->get()) {
next_packet_peer = 0;
+ }
}
// Signal newly connected peers
for (List<int>::Element *E = add.front(); E; E = E->next()) {
// Already connected to server: simply notify new peer.
// NOTE: Mesh is always connected.
- if (connection_status == CONNECTION_CONNECTED)
+ if (connection_status == CONNECTION_CONNECTED) {
emit_signal("peer_connected", E->get());
+ }
// Server emulation mode suppresses peer_conencted until server connects.
if (server_compat && E->get() == TARGET_PEER_SERVER) {
@@ -131,21 +134,24 @@ void WebRTCMultiplayer::poll() {
emit_signal("connection_succeeded");
// Notify of all previously connected peers
for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) {
- if (F->key() != 1 && F->get()->connected)
+ if (F->key() != 1 && F->get()->connected) {
emit_signal("peer_connected", F->key());
+ }
}
break; // Because we already notified of all newly added peers.
}
}
// Fetch next packet
- if (next_packet_peer == 0)
+ if (next_packet_peer == 0) {
_find_next_peer();
+ }
}
void WebRTCMultiplayer::_find_next_peer() {
Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.find(next_packet_peer);
- if (E)
+ if (E) {
E = E->next();
+ }
// After last.
while (E) {
for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) {
@@ -165,8 +171,9 @@ void WebRTCMultiplayer::_find_next_peer() {
return;
}
}
- if (E->key() == (int)next_packet_peer)
+ if (E->key() == (int)next_packet_peer) {
break;
+ }
E = E->next();
}
// No packet found
@@ -191,10 +198,11 @@ Error WebRTCMultiplayer::initialize(int p_self_id, bool p_server_compat) {
server_compat = p_server_compat;
// Mesh and server are always connected
- if (!server_compat || p_self_id == 1)
+ if (!server_compat || p_self_id == 1) {
connection_status = CONNECTION_CONNECTED;
- else
+ } else {
connection_status = CONNECTION_CONNECTING;
+ }
return OK;
}
@@ -320,7 +328,6 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size)
Map<int, Ref<ConnectedPeer>>::Element *E = nullptr;
if (target_peer > 0) {
-
E = peer_map.find(target_peer);
ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer: " + itos(target_peer) + ".");
@@ -332,10 +339,10 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size)
int exclude = -target_peer;
for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) {
-
// Exclude packet. If target_peer == 0 then don't exclude any packets
- if (target_peer != 0 && F->key() == exclude)
+ if (target_peer != 0 && F->key() == exclude) {
continue;
+ }
ERR_CONTINUE(F->value()->channels.size() <= ch || !F->value()->channels[ch].is_valid());
F->value()->channels[ch]->put_packet(p_buffer, p_buffer_size);
@@ -345,8 +352,9 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size)
}
int WebRTCMultiplayer::get_available_packet_count() const {
- if (next_packet_peer == 0)
+ if (next_packet_peer == 0) {
return 0; // To be sure next call to get_packet works if size > 0 .
+ }
int size = 0;
for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) {
for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) {
diff --git a/modules/webrtc/webrtc_multiplayer.h b/modules/webrtc/webrtc_multiplayer.h
index 0e1335b8a8..906b90a1b6 100644
--- a/modules/webrtc/webrtc_multiplayer.h
+++ b/modules/webrtc/webrtc_multiplayer.h
@@ -35,7 +35,6 @@
#include "webrtc_peer_connection.h"
class WebRTCMultiplayer : public NetworkedMultiplayerPeer {
-
GDCLASS(WebRTCMultiplayer, NetworkedMultiplayerPeer);
protected:
@@ -50,7 +49,6 @@ private:
};
class ConnectedPeer : public Reference {
-
public:
Ref<WebRTCPeerConnection> connection;
List<Ref<WebRTCDataChannel>> channels;
@@ -58,8 +56,9 @@ private:
ConnectedPeer() {
connected = false;
- for (int i = 0; i < CH_RESERVED_MAX; i++)
+ for (int i = 0; i < CH_RESERVED_MAX; i++) {
channels.push_front(Ref<WebRTCDataChannel>());
+ }
}
};
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp
index 399e4f09ff..670924bca2 100644
--- a/modules/webrtc/webrtc_peer_connection.cpp
+++ b/modules/webrtc/webrtc_peer_connection.cpp
@@ -33,14 +33,13 @@
WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = nullptr;
Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() {
-
return create();
}
WebRTCPeerConnection *WebRTCPeerConnection::create() {
-
- if (!_create)
+ if (!_create) {
return nullptr;
+ }
return _create();
}
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
index f082646629..aaa45d3a54 100644
--- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp
+++ b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
@@ -49,7 +49,6 @@ Error WebRTCPeerConnectionGDNative::set_default_library(const godot_net_webrtc_l
}
WebRTCPeerConnection *WebRTCPeerConnectionGDNative::_create() {
-
WebRTCPeerConnectionGDNative *obj = memnew(WebRTCPeerConnectionGDNative);
ERR_FAIL_COND_V_MSG(!default_library, obj, "Default GDNative WebRTC implementation not defined.");
diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h
index 6540077e84..cdaf3068e3 100644
--- a/modules/webrtc/webrtc_peer_connection_js.h
+++ b/modules/webrtc/webrtc_peer_connection_js.h
@@ -36,7 +36,6 @@
#include "webrtc_peer_connection.h"
class WebRTCPeerConnectionJS : public WebRTCPeerConnection {
-
private:
int _js_id;
ConnectionState _conn_state;
diff --git a/modules/websocket/editor_debugger_server_websocket.cpp b/modules/websocket/editor_debugger_server_websocket.cpp
index cc8507227e..95ea7ceafa 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 */
@@ -39,8 +39,9 @@ void EditorDebuggerServerWebSocket::_peer_connected(int p_id, String _protocol)
}
void EditorDebuggerServerWebSocket::_peer_disconnected(int p_id, bool p_was_clean) {
- if (pending_peers.find(p_id))
+ if (pending_peers.find(p_id)) {
pending_peers.erase(p_id);
+ }
}
void EditorDebuggerServerWebSocket::poll() {
@@ -87,6 +88,6 @@ EditorDebuggerServerWebSocket::~EditorDebuggerServerWebSocket() {
}
EditorDebuggerServer *EditorDebuggerServerWebSocket::create(const String &p_protocol) {
- ERR_FAIL_COND_V(p_protocol != "ws://", NULL);
+ ERR_FAIL_COND_V(p_protocol != "ws://", nullptr);
return memnew(EditorDebuggerServerWebSocket);
}
diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor_debugger_server_websocket.h
index 81a31d8364..c66db1b72a 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 */
@@ -36,7 +36,6 @@
#include "editor/debugger/editor_debugger_server.h"
class EditorDebuggerServerWebSocket : public EditorDebuggerServer {
-
GDCLASS(EditorDebuggerServerWebSocket, EditorDebuggerServer);
private:
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
index bc9d75d327..7c31449709 100644
--- a/modules/websocket/emws_client.cpp
+++ b/modules/websocket/emws_client.cpp
@@ -65,7 +65,6 @@ EMSCRIPTEN_KEEPALIVE void _esws_on_close(void *obj, int code, char *reason, int
}
Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocols, const Vector<String> p_custom_headers) {
-
String proto_string;
for (int i = 0; i < p_protocols.size(); i++) {
if (i != 0)
@@ -190,12 +189,10 @@ void EMWSClient::poll() {
}
Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const {
-
return _peer;
}
NetworkedMultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const {
-
if (_peer->is_connected_to_host()) {
if (_is_connecting)
return CONNECTION_CONNECTING;
@@ -206,17 +203,14 @@ NetworkedMultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() c
};
void EMWSClient::disconnect_from_host(int p_code, String p_reason) {
-
_peer->close(p_code, p_reason);
};
IP_Address EMWSClient::get_connected_host() const {
-
ERR_FAIL_V_MSG(IP_Address(), "Not supported in HTML5 export.");
};
uint16_t EMWSClient::get_connected_port() const {
-
ERR_FAIL_V_MSG(0, "Not supported in HTML5 export.");
};
@@ -244,7 +238,6 @@ EMWSClient::EMWSClient() {
};
EMWSClient::~EMWSClient() {
-
disconnect_from_host();
_peer = Ref<EMWSPeer>();
/* clang-format off */
diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h
index 9f1c220ed4..ab8a0612bb 100644
--- a/modules/websocket/emws_client.h
+++ b/modules/websocket/emws_client.h
@@ -38,7 +38,6 @@
#include "websocket_client.h"
class EMWSClient : public WebSocketClient {
-
GDCIIMPL(EMWSClient, WebSocketClient);
private:
diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp
index 9472daa620..749f45451a 100644
--- a/modules/websocket/emws_peer.cpp
+++ b/modules/websocket/emws_peer.cpp
@@ -34,7 +34,6 @@
#include "core/io/ip.h"
void EMWSPeer::set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size) {
-
peer_sock = p_sock;
_in_buffer.resize(p_in_pkt_size, p_in_buf_size);
_packet_buffer.resize((1 << p_in_buf_size));
@@ -49,13 +48,11 @@ EMWSPeer::WriteMode EMWSPeer::get_write_mode() const {
}
Error EMWSPeer::read_msg(uint8_t *p_data, uint32_t p_size, bool p_is_string) {
-
uint8_t is_string = p_is_string ? 1 : 0;
return _in_buffer.write_packet(p_data, p_size, &is_string);
}
Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
-
int is_bin = write_mode == WebSocketPeer::WRITE_MODE_BINARY ? 1 : 0;
/* clang-format off */
@@ -86,7 +83,6 @@ Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
};
Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
-
if (_in_buffer.packets_left() == 0)
return ERR_UNAVAILABLE;
@@ -101,22 +97,18 @@ Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
};
int EMWSPeer::get_available_packet_count() const {
-
return _in_buffer.packets_left();
};
bool EMWSPeer::was_string_packet() const {
-
return _is_string;
};
bool EMWSPeer::is_connected_to_host() const {
-
return peer_sock != -1;
};
void EMWSPeer::close(int p_code, String p_reason) {
-
if (peer_sock != -1) {
/* clang-format off */
EM_ASM({
@@ -134,17 +126,14 @@ void EMWSPeer::close(int p_code, String p_reason) {
};
IP_Address EMWSPeer::get_connected_host() const {
-
ERR_FAIL_V_MSG(IP_Address(), "Not supported in HTML5 export.");
};
uint16_t EMWSPeer::get_connected_port() const {
-
ERR_FAIL_V_MSG(0, "Not supported in HTML5 export.");
};
void EMWSPeer::set_no_delay(bool p_enabled) {
-
ERR_FAIL_MSG("'set_no_delay' is not supported in HTML5 export.");
}
@@ -155,7 +144,6 @@ EMWSPeer::EMWSPeer() {
};
EMWSPeer::~EMWSPeer() {
-
close();
};
diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h
index 6308ebe490..9c00f2d58b 100644
--- a/modules/websocket/emws_peer.h
+++ b/modules/websocket/emws_peer.h
@@ -41,7 +41,6 @@
#include "websocket_peer.h"
class EMWSPeer : public WebSocketPeer {
-
GDCIIMPL(EMWSPeer, WebSocketPeer);
private:
diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp
index 95cffb4775..9d43283d3e 100644
--- a/modules/websocket/emws_server.cpp
+++ b/modules/websocket/emws_server.cpp
@@ -34,7 +34,6 @@
#include "core/os/os.h"
Error EMWSServer::listen(int p_port, Vector<String> p_protocols, bool gd_mp_api) {
-
return FAILED;
}
@@ -60,12 +59,10 @@ Vector<String> EMWSServer::get_protocols() const {
}
IP_Address EMWSServer::get_peer_address(int p_peer_id) const {
-
return IP_Address();
}
int EMWSServer::get_peer_port(int p_peer_id) const {
-
return 0;
}
diff --git a/modules/websocket/emws_server.h b/modules/websocket/emws_server.h
index f273fd078f..bb6f35a711 100644
--- a/modules/websocket/emws_server.h
+++ b/modules/websocket/emws_server.h
@@ -38,7 +38,6 @@
#include "websocket_server.h"
class EMWSServer : public WebSocketServer {
-
GDCIIMPL(EMWSServer, WebSocketServer);
public:
diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h
index 5f5f0e20cd..9973efe297 100644
--- a/modules/websocket/packet_buffer.h
+++ b/modules/websocket/packet_buffer.h
@@ -36,7 +36,6 @@
template <class T>
class PacketBuffer {
-
private:
typedef struct {
uint32_t size;
diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp
index 1ad249e1eb..bc50de414e 100644
--- a/modules/websocket/register_types.cpp
+++ b/modules/websocket/register_types.cpp
@@ -42,9 +42,16 @@
#endif
#ifdef TOOLS_ENABLED
#include "editor/debugger/editor_debugger_server.h"
+#include "editor/editor_node.h"
#include "editor_debugger_server_websocket.h"
#endif
+#ifdef TOOLS_ENABLED
+static void _editor_init_callback() {
+ EditorDebuggerServer::register_protocol_handler("ws://", EditorDebuggerServerWebSocket::create);
+}
+#endif
+
void register_websocket_types() {
#ifdef JAVASCRIPT_ENABLED
EMWSPeer::make_default();
@@ -62,7 +69,7 @@ void register_websocket_types() {
ClassDB::register_custom_instance_class<WebSocketPeer>();
#ifdef TOOLS_ENABLED
- EditorDebuggerServer::register_protocol_handler("ws://", EditorDebuggerServerWebSocket::create);
+ EditorNode::add_init_callback(&_editor_init_callback);
#endif
}
diff --git a/modules/websocket/remote_debugger_peer_websocket.cpp b/modules/websocket/remote_debugger_peer_websocket.cpp
index f132b58e05..a67a959e31 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 */
@@ -33,7 +33,6 @@
#include "core/project_settings.h"
Error RemoteDebuggerPeerWebSocket::connect_to_host(const String &p_uri) {
-
Vector<String> protocols;
protocols.push_back("binary"); // Compatibility for emscripten TCP-to-WebSocket.
@@ -41,7 +40,6 @@ Error RemoteDebuggerPeerWebSocket::connect_to_host(const String &p_uri) {
ws_client->poll();
if (ws_client->get_connection_status() == WebSocketClient::CONNECTION_DISCONNECTED) {
-
ERR_PRINT("Remote Debugger: Unable to connect. Status: " + String::num(ws_client->get_connection_status()) + ".");
return FAILED;
}
@@ -90,8 +88,9 @@ Array RemoteDebuggerPeerWebSocket::get_message() {
}
Error RemoteDebuggerPeerWebSocket::put_message(const Array &p_arr) {
- if (out_queue.size() >= max_queued_messages)
+ if (out_queue.size() >= max_queued_messages) {
return ERR_OUT_OF_MEMORY;
+ }
out_queue.push_back(p_arr);
return OK;
}
@@ -123,12 +122,12 @@ RemoteDebuggerPeerWebSocket::RemoteDebuggerPeerWebSocket(Ref<WebSocketPeer> p_pe
}
RemoteDebuggerPeer *RemoteDebuggerPeerWebSocket::create(const String &p_uri) {
- ERR_FAIL_COND_V(!p_uri.begins_with("ws://") && !p_uri.begins_with("wss://"), NULL);
+ ERR_FAIL_COND_V(!p_uri.begins_with("ws://") && !p_uri.begins_with("wss://"), nullptr);
RemoteDebuggerPeerWebSocket *peer = memnew(RemoteDebuggerPeerWebSocket);
Error err = peer->connect_to_host(p_uri);
if (err != OK) {
memdelete(peer);
- return NULL;
+ return nullptr;
}
return peer;
}
diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h
index fe46533bed..bb03e5e892 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 */
@@ -39,7 +39,6 @@
#include "core/debugger/remote_debugger_peer.h"
class RemoteDebuggerPeerWebSocket : public RemoteDebuggerPeer {
-
Ref<WebSocketClient> ws_client;
Ref<WebSocketPeer> ws_peer;
List<Array> in_queue;
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
index 7ee4b990b5..3900180739 100644
--- a/modules/websocket/websocket_client.cpp
+++ b/modules/websocket/websocket_client.cpp
@@ -33,7 +33,6 @@
GDCINULL(WebSocketClient);
WebSocketClient::WebSocketClient() {
-
verify_ssl = true;
}
@@ -54,8 +53,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
port = 443;
} else {
ssl = false;
- if (host.begins_with("ws://"))
+ if (host.begins_with("ws://")) {
host = host.substr(5, host.length() - 5);
+ }
}
// Path
@@ -76,33 +76,27 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
}
void WebSocketClient::set_verify_ssl_enabled(bool p_verify_ssl) {
-
verify_ssl = p_verify_ssl;
}
bool WebSocketClient::is_verify_ssl_enabled() const {
-
return verify_ssl;
}
Ref<X509Certificate> WebSocketClient::get_trusted_ssl_certificate() const {
-
return ssl_cert;
}
void WebSocketClient::set_trusted_ssl_certificate(Ref<X509Certificate> p_cert) {
-
ERR_FAIL_COND(get_connection_status() != CONNECTION_DISCONNECTED);
ssl_cert = p_cert;
}
bool WebSocketClient::is_server() const {
-
return false;
}
void WebSocketClient::_on_peer_packet() {
-
if (_is_multiplayer) {
_process_multiplayer(get_peer(1), 1);
} else {
@@ -111,7 +105,6 @@ void WebSocketClient::_on_peer_packet() {
}
void WebSocketClient::_on_connect(String p_protocol) {
-
if (_is_multiplayer) {
// need to wait for ID confirmation...
} else {
@@ -120,12 +113,10 @@ void WebSocketClient::_on_connect(String p_protocol) {
}
void WebSocketClient::_on_close_request(int p_code, String p_reason) {
-
emit_signal("server_close_request", p_code, p_reason);
}
void WebSocketClient::_on_disconnect(bool p_was_clean) {
-
if (_is_multiplayer) {
emit_signal("connection_failed");
} else {
@@ -134,7 +125,6 @@ void WebSocketClient::_on_disconnect(bool p_was_clean) {
}
void WebSocketClient::_on_error() {
-
if (_is_multiplayer) {
emit_signal("connection_failed");
} else {
diff --git a/modules/websocket/websocket_client.h b/modules/websocket/websocket_client.h
index 4dc1224066..ba8e21aed6 100644
--- a/modules/websocket/websocket_client.h
+++ b/modules/websocket/websocket_client.h
@@ -37,7 +37,6 @@
#include "websocket_peer.h"
class WebSocketClient : public WebSocketMultiplayerPeer {
-
GDCLASS(WebSocketClient, WebSocketMultiplayerPeer);
GDCICLASS(WebSocketClient);
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 9b71b32e33..fa2fe891a5 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -33,7 +33,6 @@
#include "core/os/os.h"
WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() {
-
_is_multiplayer = false;
_peer_id = 0;
_target_peer = 0;
@@ -46,16 +45,13 @@ WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() {
}
WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() {
-
_clear();
}
int WebSocketMultiplayerPeer::_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(
@@ -71,11 +67,12 @@ int WebSocketMultiplayerPeer::_gen_unique_id() const {
return hash;
}
-void WebSocketMultiplayerPeer::_clear() {
+void WebSocketMultiplayerPeer::_clear() {
_peer_map.clear();
- if (_current_packet.data != nullptr)
+ if (_current_packet.data != nullptr) {
memfree(_current_packet.data);
+ }
for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) {
memfree(E->get().data);
@@ -86,7 +83,6 @@ void WebSocketMultiplayerPeer::_clear() {
}
void WebSocketMultiplayerPeer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_buffers", "input_buffer_size_kb", "input_max_packets", "output_buffer_size_kb", "output_max_packets"), &WebSocketMultiplayerPeer::set_buffers);
ClassDB::bind_method(D_METHOD("get_peer", "peer_id"), &WebSocketMultiplayerPeer::get_peer);
@@ -97,14 +93,12 @@ void WebSocketMultiplayerPeer::_bind_methods() {
// PacketPeer
//
int WebSocketMultiplayerPeer::get_available_packet_count() const {
-
ERR_FAIL_COND_V_MSG(!_is_multiplayer, 0, "Please use get_peer(ID).get_available_packet_count to get available packet count from peers when not using the MultiplayerAPI.");
return _incoming_packets.size();
}
Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
-
ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).get_packet/var to communicate with peers when not using the MultiplayerAPI.");
r_buffer_size = 0;
@@ -124,7 +118,6 @@ Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buff
}
Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
-
ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).put_packet/var to communicate with peers when not using the MultiplayerAPI.");
Vector<uint8_t> buffer = _make_pkt(SYS_NONE, get_unique_id(), _target_peer, p_buffer, p_buffer_size);
@@ -140,23 +133,19 @@ Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer
// NetworkedMultiplayerPeer
//
void WebSocketMultiplayerPeer::set_transfer_mode(TransferMode p_mode) {
-
// Websocket uses TCP, reliable
}
NetworkedMultiplayerPeer::TransferMode WebSocketMultiplayerPeer::get_transfer_mode() const {
-
// Websocket uses TCP, reliable
return TRANSFER_MODE_RELIABLE;
}
void WebSocketMultiplayerPeer::set_target_peer(int p_target_peer) {
-
_target_peer = p_target_peer;
}
int WebSocketMultiplayerPeer::get_packet_peer() const {
-
ERR_FAIL_COND_V_MSG(!_is_multiplayer, 1, "This function is not available when not using the MultiplayerAPI.");
ERR_FAIL_COND_V(_incoming_packets.size() == 0, 1);
@@ -164,22 +153,18 @@ int WebSocketMultiplayerPeer::get_packet_peer() const {
}
int WebSocketMultiplayerPeer::get_unique_id() const {
-
return _peer_id;
}
void WebSocketMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
-
_refusing = p_enable;
}
bool WebSocketMultiplayerPeer::is_refusing_new_connections() const {
-
return _refusing;
}
void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_type, int32_t p_peer_id) {
-
ERR_FAIL_COND(!p_peer.is_valid());
ERR_FAIL_COND(!p_peer->is_connected_to_host());
@@ -188,7 +173,6 @@ void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_ty
}
Vector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) {
-
Vector<uint8_t> out;
out.resize(PROTO_SIZE + p_data_size);
@@ -202,7 +186,6 @@ Vector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint8_t p_type, int32_t p_fr
}
void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) {
-
// First of all, confirm the ID!
_send_sys(get_peer(p_peer_id), SYS_ID, p_peer_id);
@@ -211,8 +194,9 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) {
for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) {
int32_t id = E->key();
- if (p_peer_id == id)
+ if (p_peer_id == id) {
continue; // Skip the newwly added peer (already confirmed)
+ }
// Send new peer to others
_send_sys(get_peer(id), SYS_ADD, p_peer_id);
@@ -224,8 +208,9 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) {
void WebSocketMultiplayerPeer::_send_del(int32_t p_peer_id) {
for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) {
int32_t id = E->key();
- if (p_peer_id != id)
+ if (p_peer_id != id) {
_send_sys(get_peer(id), SYS_DEL, p_peer_id);
+ }
}
}
@@ -242,27 +227,25 @@ void WebSocketMultiplayerPeer::_store_pkt(int32_t p_source, int32_t p_dest, cons
Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size) {
if (p_to == 1) {
-
return OK; // Will not send to self
} else if (p_to == 0) {
-
for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) {
- if (E->key() != p_from)
+ if (E->key() != p_from) {
E->get()->put_packet(p_buffer, p_buffer_size);
+ }
}
return OK; // Sent to all but sender
} else if (p_to < 0) {
-
for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) {
- if (E->key() != p_from && E->key() != -p_to)
+ if (E->key() != p_from && E->key() != -p_to) {
E->get()->put_packet(p_buffer, p_buffer_size);
+ }
}
return OK; // Sent to all but sender and excluded
} else {
-
ERR_FAIL_COND_V(p_to == p_from, FAILED);
Ref<WebSocketPeer> peer_to = get_peer(p_to);
@@ -273,7 +256,6 @@ Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, cons
}
void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, uint32_t p_peer_id) {
-
ERR_FAIL_COND(!p_peer.is_valid());
const uint8_t *in_buffer;
@@ -304,21 +286,19 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u
_store_pkt(from, to, in_buffer, data_size);
} else if (to == 0) {
-
// Broadcast, for us too
_store_pkt(from, to, in_buffer, data_size);
} else if (to < 0) {
-
// All but one, for us if not excluded
- if (_peer_id != -(int32_t)p_peer_id)
+ if (_peer_id != -(int32_t)p_peer_id) {
_store_pkt(from, to, in_buffer, data_size);
+ }
}
// Relay if needed (i.e. "to" includes a peer that is not the server)
_server_relay(from, to, in_buffer, size);
} else {
-
if (type == SYS_NONE) { // Payload message
_store_pkt(from, to, in_buffer, data_size);
@@ -331,12 +311,12 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u
copymem(&id, &in_buffer[PROTO_SIZE], 4);
switch (type) {
-
case SYS_ADD: // Add peer
_peer_map[id] = Ref<WebSocketPeer>();
emit_signal("peer_connected", id);
- if (id == 1) // We just connected to the server
+ if (id == 1) { // We just connected to the server
emit_signal("connection_succeeded");
+ }
break;
case SYS_DEL: // Remove peer
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index c6669c730c..3ee26e2c5b 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/modules/websocket/websocket_multiplayer_peer.h
@@ -37,7 +37,6 @@
#include "websocket_peer.h"
class WebSocketMultiplayerPeer : public NetworkedMultiplayerPeer {
-
GDCLASS(WebSocketMultiplayerPeer, NetworkedMultiplayerPeer);
private:
diff --git a/modules/websocket/websocket_peer.h b/modules/websocket/websocket_peer.h
index d4173600ec..5f7d1c768b 100644
--- a/modules/websocket/websocket_peer.h
+++ b/modules/websocket/websocket_peer.h
@@ -36,7 +36,6 @@
#include "websocket_macros.h"
class WebSocketPeer : public PacketPeer {
-
GDCLASS(WebSocketPeer, PacketPeer);
GDCICLASS(WebSocketPeer);
diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp
index a7ced65543..b20b925dec 100644
--- a/modules/websocket/websocket_server.cpp
+++ b/modules/websocket/websocket_server.cpp
@@ -41,7 +41,6 @@ WebSocketServer::~WebSocketServer() {
}
void WebSocketServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("is_listening"), &WebSocketServer::is_listening);
ClassDB::bind_method(D_METHOD("listen", "port", "protocols", "gd_mp_api"), &WebSocketServer::listen, DEFVAL(Vector<String>()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("stop"), &WebSocketServer::stop);
@@ -110,19 +109,18 @@ void WebSocketServer::set_ca_chain(Ref<X509Certificate> p_ca_chain) {
}
NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
- if (is_listening())
+ if (is_listening()) {
return CONNECTION_CONNECTED;
+ }
return CONNECTION_DISCONNECTED;
}
bool WebSocketServer::is_server() const {
-
return true;
}
void WebSocketServer::_on_peer_packet(int32_t p_peer_id) {
-
if (_is_multiplayer) {
_process_multiplayer(get_peer(p_peer_id), p_peer_id);
} else {
@@ -131,7 +129,6 @@ void WebSocketServer::_on_peer_packet(int32_t p_peer_id) {
}
void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol) {
-
if (_is_multiplayer) {
// Send add to clients
_send_add(p_peer_id);
@@ -142,7 +139,6 @@ void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol) {
}
void WebSocketServer::_on_disconnect(int32_t p_peer_id, bool p_was_clean) {
-
if (_is_multiplayer) {
// Send delete to clients
_send_del(p_peer_id);
@@ -153,6 +149,5 @@ void WebSocketServer::_on_disconnect(int32_t p_peer_id, bool p_was_clean) {
}
void WebSocketServer::_on_close_request(int32_t p_peer_id, int p_code, String p_reason) {
-
emit_signal("client_close_request", p_peer_id, p_code, p_reason);
}
diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h
index 3ce4dbe711..5df0a37945 100644
--- a/modules/websocket/websocket_server.h
+++ b/modules/websocket/websocket_server.h
@@ -37,7 +37,6 @@
#include "websocket_peer.h"
class WebSocketServer : public WebSocketMultiplayerPeer {
-
GDCLASS(WebSocketServer, WebSocketMultiplayerPeer);
GDCICLASS(WebSocketServer);
diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp
index 0eaafe2d66..7d16c2e99f 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -117,10 +117,11 @@ bool WSLClient::_verify_headers(String &r_protocol) {
ERR_FAIL_COND_V_MSG(header.size() != 2, false, "Invalid header -> " + psa[i] + ".");
String name = header[0].to_lower();
String value = header[1].strip_edges();
- if (headers.has(name))
+ if (headers.has(name)) {
headers[name] += "," + value;
- else
+ } else {
headers[name] = value;
+ }
}
#define _WSL_CHECK(NAME, VALUE) \
@@ -142,19 +143,20 @@ bool WSLClient::_verify_headers(String &r_protocol) {
r_protocol = headers["sec-websocket-protocol"];
bool valid = false;
for (int i = 0; i < _protocols.size(); i++) {
- if (_protocols[i] != r_protocol)
+ if (_protocols[i] != r_protocol) {
continue;
+ }
valid = true;
break;
}
- if (!valid)
+ if (!valid) {
return false;
+ }
}
return true;
}
Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocols, const Vector<String> p_custom_headers) {
-
ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE);
_peer = Ref<WSLPeer>(memnew(WSLPeer));
@@ -200,8 +202,9 @@ Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
if (p_protocols.size() > 0) {
request += "Sec-WebSocket-Protocol: ";
for (int i = 0; i < p_protocols.size(); i++) {
- if (i != 0)
+ if (i != 0) {
request += ",";
+ }
request += p_protocols[i];
}
request += "\r\n";
@@ -229,8 +232,9 @@ void WSLClient::poll() {
return;
}
- if (_connection.is_null())
+ if (_connection.is_null()) {
return; // Not connected.
+ }
switch (_tcp->get_status()) {
case StreamPeerTCP::STATUS_NONE:
@@ -257,9 +261,9 @@ void WSLClient::poll() {
ERR_FAIL_COND(ssl.is_null()); // Bug?
ssl->poll();
}
- if (ssl->get_status() == StreamPeerSSL::STATUS_HANDSHAKING)
+ if (ssl->get_status() == StreamPeerSSL::STATUS_HANDSHAKING) {
return; // Need more polling.
- else if (ssl->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
+ } else if (ssl->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
disconnect_from_host();
_on_error();
return; // Error.
@@ -278,25 +282,24 @@ void WSLClient::poll() {
}
Ref<WebSocketPeer> WSLClient::get_peer(int p_peer_id) const {
-
ERR_FAIL_COND_V(p_peer_id != 1, nullptr);
return _peer;
}
NetworkedMultiplayerPeer::ConnectionStatus WSLClient::get_connection_status() const {
-
- if (_peer->is_connected_to_host())
+ if (_peer->is_connected_to_host()) {
return CONNECTION_CONNECTED;
+ }
- if (_tcp->is_connected_to_host())
+ if (_tcp->is_connected_to_host()) {
return CONNECTION_CONNECTING;
+ }
return CONNECTION_DISCONNECTED;
}
void WSLClient::disconnect_from_host(int p_code, String p_reason) {
-
_peer->close(p_code, p_reason);
_connection = Ref<StreamPeer>(nullptr);
_tcp = Ref<StreamPeerTCP>(memnew(StreamPeerTCP));
@@ -314,13 +317,11 @@ void WSLClient::disconnect_from_host(int p_code, String p_reason) {
}
IP_Address WSLClient::get_connected_host() const {
-
ERR_FAIL_COND_V(!_peer->is_connected_to_host(), IP_Address());
return _peer->get_connected_host();
}
uint16_t WSLClient::get_connected_port() const {
-
ERR_FAIL_COND_V(!_peer->is_connected_to_host(), 0);
return _peer->get_connected_port();
}
@@ -347,7 +348,6 @@ WSLClient::WSLClient() {
}
WSLClient::~WSLClient() {
-
_peer->close_now();
_peer->invalidate();
disconnect_from_host();
diff --git a/modules/websocket/wsl_client.h b/modules/websocket/wsl_client.h
index 2cecfd97ee..8355a5a737 100644
--- a/modules/websocket/wsl_client.h
+++ b/modules/websocket/wsl_client.h
@@ -41,7 +41,6 @@
#include "wslay/wslay.h"
class WSLClient : public WebSocketClient {
-
GDCIIMPL(WSLClient, WebSocketClient);
private:
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index 44b71f70f4..bf1ba43f8a 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -60,8 +60,9 @@ String WSLPeer::compute_key_response(String p_key) {
}
void WSLPeer::_wsl_destroy(struct PeerData **p_data) {
- if (!p_data || !(*p_data))
+ if (!p_data || !(*p_data)) {
return;
+ }
struct PeerData *data = *p_data;
if (data->polling) {
data->destroy = true;
@@ -147,8 +148,9 @@ void wsl_msg_recv_callback(wslay_event_context_ptr ctx, const struct wslay_event
}
WSLPeer *peer = (WSLPeer *)peer_data->peer;
- if (peer->parse_message(arg) != OK)
+ if (peer->parse_message(arg) != OK) {
return;
+ }
if (peer_data->is_server) {
WSLServer *helper = (WSLServer *)peer_data->obj;
@@ -209,10 +211,11 @@ void WSLPeer::make_context(PeerData *p_data, unsigned int p_in_buf_size, unsigne
_data->peer = this;
_data->valid = true;
- if (_data->is_server)
+ if (_data->is_server) {
wslay_event_context_server_init(&(_data->ctx), &wsl_callbacks, _data);
- else
+ } else {
wslay_event_context_client_init(&(_data->ctx), &wsl_callbacks, _data);
+ }
wslay_event_config_set_max_recv_msg_length(_data->ctx, (1ULL << p_in_buf_size));
}
@@ -225,8 +228,9 @@ WSLPeer::WriteMode WSLPeer::get_write_mode() const {
}
void WSLPeer::poll() {
- if (!_data)
+ if (!_data) {
return;
+ }
if (_wsl_poll(_data)) {
_data = nullptr;
@@ -234,7 +238,6 @@ void WSLPeer::poll() {
}
Error WSLPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
-
ERR_FAIL_COND_V(!is_connected_to_host(), FAILED);
struct wslay_event_msg msg; // Should I use fragmented?
@@ -251,13 +254,13 @@ Error WSLPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
}
Error WSLPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
-
r_buffer_size = 0;
ERR_FAIL_COND_V(!is_connected_to_host(), FAILED);
- if (_in_buffer.packets_left() == 0)
+ if (_in_buffer.packets_left() == 0) {
return ERR_UNAVAILABLE;
+ }
int read = 0;
uint8_t *rw = _packet_buffer.ptrw();
@@ -270,20 +273,18 @@ Error WSLPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
}
int WSLPeer::get_available_packet_count() const {
-
- if (!is_connected_to_host())
+ if (!is_connected_to_host()) {
return 0;
+ }
return _in_buffer.packets_left();
}
bool WSLPeer::was_string_packet() const {
-
return _is_string;
}
bool WSLPeer::is_connected_to_host() const {
-
return _data != nullptr;
}
@@ -305,28 +306,26 @@ void WSLPeer::close(int p_code, String p_reason) {
}
IP_Address WSLPeer::get_connected_host() const {
-
ERR_FAIL_COND_V(!is_connected_to_host() || _data->tcp.is_null(), IP_Address());
return _data->tcp->get_connected_host();
}
uint16_t WSLPeer::get_connected_port() const {
-
ERR_FAIL_COND_V(!is_connected_to_host() || _data->tcp.is_null(), 0);
return _data->tcp->get_connected_port();
}
void WSLPeer::set_no_delay(bool p_enabled) {
-
ERR_FAIL_COND(!is_connected_to_host() || _data->tcp.is_null());
_data->tcp->set_no_delay(p_enabled);
}
void WSLPeer::invalidate() {
- if (_data)
+ if (_data) {
_data->valid = false;
+ }
}
WSLPeer::WSLPeer() {
@@ -337,7 +336,6 @@ WSLPeer::WSLPeer() {
}
WSLPeer::~WSLPeer() {
-
close();
invalidate();
_wsl_destroy(&_data);
diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h
index 3b0639831a..fe4abfb64c 100644
--- a/modules/websocket/wsl_peer.h
+++ b/modules/websocket/wsl_peer.h
@@ -44,7 +44,6 @@
#define WSL_MAX_HEADER_SIZE 4096
class WSLPeer : public WebSocketPeer {
-
GDCIIMPL(WSLPeer, WebSocketPeer);
public:
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index cc4685973e..da7bfc70c0 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -60,10 +60,11 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) {
ERR_FAIL_COND_V_MSG(header.size() != 2, false, "Invalid header -> " + psa[i]);
String name = header[0].to_lower();
String value = header[1].strip_edges();
- if (headers.has(name))
+ if (headers.has(name)) {
headers[name] += "," + value;
- else
+ } else {
headers[name] = value;
+ }
}
#define _WSL_CHECK(NAME, VALUE) \
ERR_FAIL_COND_V_MSG(!headers.has(NAME) || headers[NAME].to_lower() != VALUE, false, \
@@ -83,44 +84,52 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) {
String proto = protos[i].strip_edges();
// Check if we have the given protocol
for (int j = 0; j < p_protocols.size(); j++) {
- if (proto != p_protocols[j])
+ if (proto != p_protocols[j]) {
continue;
+ }
protocol = proto;
break;
}
// Found a protocol
- if (protocol != "")
+ if (protocol != "") {
break;
+ }
}
- if (protocol == "") // Invalid protocol(s) requested
+ if (protocol == "") { // Invalid protocol(s) requested
return false;
- } else if (p_protocols.size() > 0) // No protocol requested, but we need one
+ }
+ } else if (p_protocols.size() > 0) { // No protocol requested, but we need one
return false;
+ }
return true;
}
Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols) {
- if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT)
+ if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT) {
return ERR_TIMEOUT;
+ }
if (use_ssl) {
Ref<StreamPeerSSL> ssl = static_cast<Ref<StreamPeerSSL>>(connection);
- if (ssl.is_null())
+ if (ssl.is_null()) {
return FAILED;
+ }
ssl->poll();
- if (ssl->get_status() == StreamPeerSSL::STATUS_HANDSHAKING)
+ if (ssl->get_status() == StreamPeerSSL::STATUS_HANDSHAKING) {
return ERR_BUSY;
- else if (ssl->get_status() != StreamPeerSSL::STATUS_CONNECTED)
+ } else if (ssl->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
return FAILED;
+ }
}
if (!has_request) {
int read = 0;
while (true) {
ERR_FAIL_COND_V_MSG(req_pos >= WSL_MAX_HEADER_SIZE, ERR_OUT_OF_MEMORY, "Response headers too big.");
Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
- if (err != OK) // Got an error
+ if (err != OK) { // Got an error
return FAILED;
- else if (read != 1) // Busy, wait next poll
+ } else if (read != 1) { // Busy, wait next poll
return ERR_BUSY;
+ }
char *r = (char *)req_buf;
int l = req_pos;
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
@@ -132,8 +141,9 @@ Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols) {
s += "Upgrade: websocket\r\n";
s += "Connection: Upgrade\r\n";
s += "Sec-WebSocket-Accept: " + WSLPeer::compute_key_response(key) + "\r\n";
- if (protocol != "")
+ if (protocol != "") {
s += "Sec-WebSocket-Protocol: " + protocol + "\r\n";
+ }
s += "\r\n";
response = s.utf8();
has_request = true;
@@ -150,8 +160,9 @@ Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols) {
}
response_sent += sent;
}
- if (response_sent < response.size() - 1)
+ if (response_sent < response.size() - 1) {
return ERR_BUSY;
+ }
return OK;
}
@@ -169,7 +180,6 @@ Error WSLServer::listen(int p_port, const Vector<String> p_protocols, bool gd_mp
}
void WSLServer::poll() {
-
List<int> remove_ids;
for (Map<int, Ref<WebSocketPeer>>::Element *E = _peer_map.front(); E; E = E->next()) {
Ref<WSLPeer> peer = (WSLPeer *)E->get().ptr();
@@ -217,13 +227,15 @@ void WSLServer::poll() {
}
remove_peers.clear();
- if (!_server->is_listening())
+ if (!_server->is_listening()) {
return;
+ }
while (_server->is_connection_available()) {
Ref<StreamPeerTCP> conn = _server->take_connection();
- if (is_refusing_new_connections())
+ if (is_refusing_new_connections()) {
continue; // Conn will go out-of-scope and be closed.
+ }
Ref<PendingPeer> peer = memnew(PendingPeer);
if (private_key.is_valid() && ssl_cert.is_valid()) {
diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h
index 2e893d6727..f86de02797 100644
--- a/modules/websocket/wsl_server.h
+++ b/modules/websocket/wsl_server.h
@@ -43,12 +43,10 @@
#define WSL_SERVER_TIMEOUT 1000
class WSLServer : public WebSocketServer {
-
GDCIIMPL(WSLServer, WebSocketServer);
private:
class PendingPeer : public Reference {
-
private:
bool _parse_request(const Vector<String> p_protocols);
diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp
index f77646ce28..6242009f67 100644
--- a/modules/xatlas_unwrap/register_types.cpp
+++ b/modules/xatlas_unwrap/register_types.cpp
@@ -42,7 +42,6 @@
extern bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y, int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache);
bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, float **r_uvs, int **r_vertices, int *r_vertex_count, int **r_indices, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y, int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache) {
-
CryptoCore::MD5Context ctx;
ctx.start();
@@ -146,7 +145,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
ERR_FAIL_COND_V_MSG(err != xatlas::AddMeshError::Enum::Success, false, xatlas::StringForEnum(err));
printf("Generate..\n");
- xatlas::Generate(atlas, chart_options, nullptr, pack_options);
+ xatlas::Generate(atlas, chart_options, xatlas::ParameterizeOptions(), pack_options);
*r_size_hint_x = atlas->width;
*r_size_hint_y = atlas->height;
@@ -230,7 +229,6 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
}
void register_xatlas_unwrap_types() {
-
array_mesh_lightmap_unwrap_callback = xatlas_mesh_lightmap_unwrap_callback;
}
diff --git a/platform/android/android_keys_utils.cpp b/platform/android/android_keys_utils.cpp
index 88874ba2c7..b5b4fb9a4b 100644
--- a/platform/android/android_keys_utils.cpp
+++ b/platform/android/android_keys_utils.cpp
@@ -32,9 +32,7 @@
unsigned int android_get_keysym(unsigned int p_code) {
for (int i = 0; _ak_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
-
if (_ak_to_keycode[i].keycode == p_code) {
-
return _ak_to_keycode[i].keysym;
}
}
diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h
index f076688ac8..fb442f4c54 100644
--- a/platform/android/android_keys_utils.h
+++ b/platform/android/android_keys_utils.h
@@ -154,7 +154,6 @@ enum {
};
struct _WinTranslatePair {
-
unsigned int keysym;
unsigned int keycode;
};
diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp
index 4fe868d4f0..1f140f7119 100644
--- a/platform/android/api/api.cpp
+++ b/platform/android/api/api.cpp
@@ -39,7 +39,6 @@ static JavaClassWrapper *java_class_wrapper = nullptr;
#endif
void register_android_api() {
-
#if !defined(ANDROID_ENABLED)
// On Android platforms, the `java_class_wrapper` instantiation and the
// `JNISingleton` registration occurs in
@@ -54,14 +53,12 @@ void register_android_api() {
}
void unregister_android_api() {
-
#if !defined(ANDROID_ENABLED)
memdelete(java_class_wrapper);
#endif
}
void JavaClassWrapper::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("wrap", "name"), &JavaClassWrapper::wrap);
}
diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h
index 3dfdc75cf4..e34f2a9f69 100644
--- a/platform/android/api/java_class_wrapper.h
+++ b/platform/android/api/java_class_wrapper.h
@@ -43,7 +43,6 @@ class JavaObject;
#endif
class JavaClass : public Reference {
-
GDCLASS(JavaClass, Reference);
#ifdef ANDROID_ENABLED
@@ -68,7 +67,6 @@ class JavaClass : public Reference {
Map<StringName, Variant> constant_map;
struct MethodInfo {
-
bool _static;
Vector<uint32_t> param_types;
Vector<StringName> param_sigs;
@@ -77,12 +75,10 @@ class JavaClass : public Reference {
};
_FORCE_INLINE_ static void _convert_to_variant_type(int p_sig, Variant::Type &r_type, float &likelihood) {
-
likelihood = 1.0;
r_type = Variant::NIL;
switch (p_sig) {
-
case ARG_TYPE_VOID:
r_type = Variant::NIL;
break;
@@ -190,7 +186,6 @@ public:
};
class JavaObject : public Reference {
-
GDCLASS(JavaObject, Reference);
#ifdef ANDROID_ENABLED
@@ -210,7 +205,6 @@ public:
};
class JavaClassWrapper : public Object {
-
GDCLASS(JavaClassWrapper, Object);
#ifdef ANDROID_ENABLED
diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h
index 917c3f5029..ed69f8d6e4 100644
--- a/platform/android/api/jni_singleton.h
+++ b/platform/android/api/jni_singleton.h
@@ -38,12 +38,10 @@
#endif
class JNISingleton : public Object {
-
GDCLASS(JNISingleton, Object);
#ifdef ANDROID_ENABLED
struct MethodData {
-
jmethodID method;
Variant::Type ret_type;
Vector<Variant::Type> argtypes;
@@ -63,7 +61,6 @@ public:
bool call_error = !E || E->get().argtypes.size() != p_argcount;
if (!call_error) {
for (int i = 0; i < p_argcount; i++) {
-
if (!Variant::can_convert(p_args[i]->get_type(), E->get().argtypes[i])) {
call_error = true;
break;
@@ -83,7 +80,6 @@ public:
jvalue *v = nullptr;
if (p_argcount) {
-
v = (jvalue *)alloca(sizeof(jvalue) * p_argcount);
}
@@ -95,7 +91,6 @@ public:
List<jobject> to_erase;
for (int i = 0; i < p_argcount; i++) {
-
jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
v[i] = vr.val;
if (vr.obj)
@@ -105,31 +100,24 @@ public:
Variant ret;
switch (E->get().ret_type) {
-
case Variant::NIL: {
-
env->CallVoidMethodA(instance, E->get().method, v);
} break;
case Variant::BOOL: {
-
ret = env->CallBooleanMethodA(instance, E->get().method, v) == JNI_TRUE;
} break;
case Variant::INT: {
-
ret = env->CallIntMethodA(instance, E->get().method, v);
} break;
case Variant::FLOAT: {
-
ret = env->CallFloatMethodA(instance, E->get().method, v);
} break;
case Variant::STRING: {
-
jobject o = env->CallObjectMethodA(instance, E->get().method, v);
ret = jstring_to_string((jstring)o, env);
env->DeleteLocalRef(o);
} break;
case Variant::PACKED_STRING_ARRAY: {
-
jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance, E->get().method, v);
ret = _jobject_to_variant(env, arr);
@@ -137,7 +125,6 @@ public:
env->DeleteLocalRef(arr);
} break;
case Variant::PACKED_INT32_ARRAY: {
-
jintArray arr = (jintArray)env->CallObjectMethodA(instance, E->get().method, v);
int fCount = env->GetArrayLength(arr);
@@ -150,7 +137,6 @@ public:
env->DeleteLocalRef(arr);
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance, E->get().method, v);
int fCount = env->GetArrayLength(arr);
@@ -167,14 +153,12 @@ public:
#warning This is missing 64 bits arrays, I have no idea how to do it in JNI
#endif
case Variant::DICTIONARY: {
-
jobject obj = env->CallObjectMethodA(instance, E->get().method, v);
ret = _jobject_to_variant(env, obj);
env->DeleteLocalRef(obj);
} break;
default: {
-
env->PopLocalFrame(nullptr);
ERR_FAIL_V(Variant());
} break;
@@ -197,17 +181,14 @@ public:
#ifdef ANDROID_ENABLED
jobject get_instance() const {
-
return instance;
}
void set_instance(jobject p_instance) {
-
instance = p_instance;
}
void add_method(const StringName &p_name, jmethodID p_method, const Vector<Variant::Type> &p_args, Variant::Type p_ret_type) {
-
MethodData md;
md.method = p_method;
md.argtypes = p_args;
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp
index 802d85e7be..09c981b3fa 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -52,12 +52,10 @@ Mutex AudioDriverAndroid::mutex;
int32_t *AudioDriverAndroid::audioBuffer32 = nullptr;
const char *AudioDriverAndroid::get_name() const {
-
return "Android";
}
Error AudioDriverAndroid::init() {
-
/*
// TODO: pass in/return a (Java) device ID, also whether we're opening for input or output
this->spec.samples = Android_JNI_OpenAudioDevice(this->spec.freq, this->spec.format == AUDIO_U8 ? 0 : 1, this->spec.channels, this->spec.samples);
@@ -75,9 +73,9 @@ Error AudioDriverAndroid::init() {
// __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
JNIEnv *env = ThreadAndroid::get_env();
- int mix_rate = GLOBAL_DEF_RST("audio/mix_rate", 44100);
+ int mix_rate = GLOBAL_GET("audio/mix_rate");
- int latency = GLOBAL_DEF_RST("audio/output_latency", 25);
+ int latency = GLOBAL_GET("audio/output_latency");
unsigned int buffer_size = next_power_of_2(latency * mix_rate / 1000);
print_verbose("Audio buffer size: " + itos(buffer_size));
@@ -100,7 +98,6 @@ void AudioDriverAndroid::start() {
}
void AudioDriverAndroid::setup(jobject p_io) {
-
JNIEnv *env = ThreadAndroid::get_env();
io = p_io;
@@ -114,10 +111,8 @@ void AudioDriverAndroid::setup(jobject p_io) {
}
void AudioDriverAndroid::thread_func(JNIEnv *env) {
-
jclass cls = env->FindClass("org/godotengine/godot/Godot");
if (cls) {
-
cls = (jclass)env->NewGlobalRef(cls);
}
jfieldID fid = env->GetStaticFieldID(cls, "io", "Lorg/godotengine/godot/GodotIO;");
@@ -128,24 +123,20 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) {
_write_buffer = env->GetMethodID(lcls, "audioWriteShortBuffer", "([S)V");
while (!quit) {
-
int16_t *ptr = (int16_t *)audioBufferPinned;
int fc = audioBufferFrames;
if (!s_ad->active || mutex.try_lock() != OK) {
-
for (int i = 0; i < fc; i++) {
ptr[i] = 0;
}
} else {
-
s_ad->audio_server_process(fc / 2, audioBuffer32);
mutex.unlock();
for (int i = 0; i < fc; i++) {
-
ptr[i] = audioBuffer32[i] >> 16;
}
}
@@ -155,27 +146,22 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) {
}
int AudioDriverAndroid::get_mix_rate() const {
-
return mix_rate;
}
AudioDriver::SpeakerMode AudioDriverAndroid::get_speaker_mode() const {
-
return SPEAKER_MODE_STEREO;
}
void AudioDriverAndroid::lock() {
-
mutex.lock();
}
void AudioDriverAndroid::unlock() {
-
mutex.unlock();
}
void AudioDriverAndroid::finish() {
-
JNIEnv *env = ThreadAndroid::get_env();
env->CallVoidMethod(io, _quit);
@@ -189,13 +175,11 @@ void AudioDriverAndroid::finish() {
}
void AudioDriverAndroid::set_pause(bool p_pause) {
-
JNIEnv *env = ThreadAndroid::get_env();
env->CallVoidMethod(io, _pause, p_pause);
}
AudioDriverAndroid::AudioDriverAndroid() {
-
s_ad = this;
active = false;
}
diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h
index b1cc3f9aa0..953ade9311 100644
--- a/platform/android/audio_driver_jandroid.h
+++ b/platform/android/audio_driver_jandroid.h
@@ -36,7 +36,6 @@
#include "java_godot_lib_jni.h"
class AudioDriverAndroid : public AudioDriver {
-
static Mutex mutex;
static AudioDriverAndroid *s_ad;
static jobject io;
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index e59850e016..740e9a3132 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -39,7 +39,6 @@
void AudioDriverOpenSL::_buffer_callback(
SLAndroidSimpleBufferQueueItf queueItf) {
-
bool mix = true;
if (pause) {
@@ -51,7 +50,6 @@ void AudioDriverOpenSL::_buffer_callback(
if (mix) {
audio_server_process(buffer_size, mixdown_buffer);
} else {
-
int32_t *src_buff = mixdown_buffer;
for (unsigned int i = 0; i < buffer_size * 2; i++) {
src_buff[i] = 0;
@@ -67,7 +65,6 @@ void AudioDriverOpenSL::_buffer_callback(
last_free = (last_free + 1) % BUFFER_COUNT;
for (unsigned int i = 0; i < buffer_size * 2; i++) {
-
ptr[i] = src_buff[i] >> 16;
}
@@ -77,7 +74,6 @@ void AudioDriverOpenSL::_buffer_callback(
void AudioDriverOpenSL::_buffer_callbacks(
SLAndroidSimpleBufferQueueItf queueItf,
void *pContext) {
-
AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext;
ad->_buffer_callback(queueItf);
@@ -86,12 +82,10 @@ void AudioDriverOpenSL::_buffer_callbacks(
AudioDriverOpenSL *AudioDriverOpenSL::s_ad = nullptr;
const char *AudioDriverOpenSL::get_name() const {
-
return "Android";
}
Error AudioDriverOpenSL::init() {
-
SLresult res;
SLEngineOption EngineOption[] = {
{ (SLuint32)SL_ENGINEOPTION_THREADSAFE, (SLuint32)SL_BOOLEAN_TRUE }
@@ -106,7 +100,6 @@ Error AudioDriverOpenSL::init() {
}
void AudioDriverOpenSL::start() {
-
active = false;
SLresult res;
@@ -114,7 +107,6 @@ void AudioDriverOpenSL::start() {
buffer_size = 1024;
for (int i = 0; i < BUFFER_COUNT; i++) {
-
buffers[i] = memnew_arr(int16_t, buffer_size * 2);
memset(buffers[i], 0, buffer_size * 4);
}
@@ -204,7 +196,6 @@ void AudioDriverOpenSL::start() {
}
void AudioDriverOpenSL::_record_buffer_callback(SLAndroidSimpleBufferQueueItf queueItf) {
-
for (int i = 0; i < rec_buffer.size(); i++) {
int32_t sample = rec_buffer[i] << 16;
input_buffer_write(sample);
@@ -216,14 +207,12 @@ void AudioDriverOpenSL::_record_buffer_callback(SLAndroidSimpleBufferQueueItf qu
}
void AudioDriverOpenSL::_record_buffer_callbacks(SLAndroidSimpleBufferQueueItf queueItf, void *pContext) {
-
AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext;
ad->_record_buffer_callback(queueItf);
}
Error AudioDriverOpenSL::capture_init_device() {
-
SLDataLocator_IODevice loc_dev = {
SL_DATALOCATOR_IODEVICE,
SL_IODEVICE_AUDIOINPUT,
@@ -291,7 +280,6 @@ Error AudioDriverOpenSL::capture_init_device() {
}
Error AudioDriverOpenSL::capture_start() {
-
if (OS::get_singleton()->request_permission("RECORD_AUDIO")) {
return capture_init_device();
}
@@ -300,7 +288,6 @@ Error AudioDriverOpenSL::capture_start() {
}
Error AudioDriverOpenSL::capture_stop() {
-
SLuint32 state;
SLresult res = (*recordItf)->GetRecordState(recordItf, &state);
ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
@@ -317,34 +304,28 @@ Error AudioDriverOpenSL::capture_stop() {
}
int AudioDriverOpenSL::get_mix_rate() const {
-
return 44100; // hardcoded for Android, as selected by SL_SAMPLINGRATE_44_1
}
AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const {
-
return SPEAKER_MODE_STEREO;
}
void AudioDriverOpenSL::lock() {
-
if (active)
mutex.lock();
}
void AudioDriverOpenSL::unlock() {
-
if (active)
mutex.unlock();
}
void AudioDriverOpenSL::finish() {
-
(*sl)->Destroy(sl);
}
void AudioDriverOpenSL::set_pause(bool p_pause) {
-
pause = p_pause;
if (active) {
diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h
index 569e2aa54b..9858a40822 100644
--- a/platform/android/audio_driver_opensl.h
+++ b/platform/android/audio_driver_opensl.h
@@ -38,7 +38,6 @@
#include <SLES/OpenSLES_Android.h>
class AudioDriverOpenSL : public AudioDriver {
-
bool active;
Mutex mutex;
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index f8571e6277..ca312b427f 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -42,12 +42,10 @@ jmethodID DirAccessJAndroid::_dir_close = nullptr;
jmethodID DirAccessJAndroid::_dir_is_dir = nullptr;
DirAccess *DirAccessJAndroid::create_fs() {
-
return memnew(DirAccessJAndroid);
}
Error DirAccessJAndroid::list_dir_begin() {
-
list_dir_end();
JNIEnv *env = ThreadAndroid::get_env();
@@ -62,7 +60,6 @@ Error DirAccessJAndroid::list_dir_begin() {
}
String DirAccessJAndroid::get_next() {
-
ERR_FAIL_COND_V(id == 0, "");
JNIEnv *env = ThreadAndroid::get_env();
@@ -76,19 +73,16 @@ String DirAccessJAndroid::get_next() {
}
bool DirAccessJAndroid::current_is_dir() const {
-
JNIEnv *env = ThreadAndroid::get_env();
return env->CallBooleanMethod(io, _dir_is_dir, id);
}
bool DirAccessJAndroid::current_is_hidden() const {
-
return current != "." && current != ".." && current.begins_with(".");
}
void DirAccessJAndroid::list_dir_end() {
-
if (id == 0)
return;
@@ -98,17 +92,14 @@ void DirAccessJAndroid::list_dir_end() {
}
int DirAccessJAndroid::get_drive_count() {
-
return 0;
}
String DirAccessJAndroid::get_drive(int p_drive) {
-
return "";
}
Error DirAccessJAndroid::change_dir(String p_dir) {
-
JNIEnv *env = ThreadAndroid::get_env();
if (p_dir == "" || p_dir == "." || (p_dir == ".." && current_dir == ""))
@@ -145,12 +136,10 @@ Error DirAccessJAndroid::change_dir(String p_dir) {
}
String DirAccessJAndroid::get_current_dir(bool p_include_drive) {
-
return "res://" + current_dir;
}
bool DirAccessJAndroid::file_exists(String p_file) {
-
String sd;
if (current_dir == "")
sd = p_file;
@@ -165,7 +154,6 @@ bool DirAccessJAndroid::file_exists(String p_file) {
}
bool DirAccessJAndroid::dir_exists(String p_dir) {
-
JNIEnv *env = ThreadAndroid::get_env();
String sd;
@@ -198,33 +186,27 @@ bool DirAccessJAndroid::dir_exists(String p_dir) {
}
Error DirAccessJAndroid::make_dir(String p_dir) {
-
ERR_FAIL_V(ERR_UNAVAILABLE);
}
Error DirAccessJAndroid::rename(String p_from, String p_to) {
-
ERR_FAIL_V(ERR_UNAVAILABLE);
}
Error DirAccessJAndroid::remove(String p_name) {
-
ERR_FAIL_V(ERR_UNAVAILABLE);
}
String DirAccessJAndroid::get_filesystem_type() const {
-
return "APK";
}
//FileType get_file_type() const;
size_t DirAccessJAndroid::get_space_left() {
-
return 0;
}
void DirAccessJAndroid::setup(jobject p_io) {
-
JNIEnv *env = ThreadAndroid::get_env();
io = p_io;
@@ -240,11 +222,9 @@ void DirAccessJAndroid::setup(jobject p_io) {
}
DirAccessJAndroid::DirAccessJAndroid() {
-
id = 0;
}
DirAccessJAndroid::~DirAccessJAndroid() {
-
list_dir_end();
}
diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h
index 8dab3e50ce..7d0def137a 100644
--- a/platform/android/dir_access_jandroid.h
+++ b/platform/android/dir_access_jandroid.h
@@ -36,7 +36,6 @@
#include <stdio.h>
class DirAccessJAndroid : public DirAccess {
-
//AAssetDir* aad;
static jobject io;
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index 60d10b2457..1436d832de 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -155,12 +155,12 @@ bool DisplayServerAndroid::screen_is_touchscreen(int p_screen) const {
return true;
}
-void DisplayServerAndroid::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_length) {
+void DisplayServerAndroid::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_length, int p_cursor_start, int p_cursor_end) {
GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java();
ERR_FAIL_COND(!godot_io_java);
if (godot_io_java->has_vk()) {
- godot_io_java->show_vk(p_existing_text, p_max_length);
+ godot_io_java->show_vk(p_existing_text, p_max_length, p_cursor_start, p_cursor_end);
} else {
ERR_PRINT("Virtual keyboard not available");
}
@@ -367,6 +367,25 @@ void DisplayServerAndroid::register_android_driver() {
register_create_function("android", create_func, get_rendering_drivers_func);
}
+void DisplayServerAndroid::reset_window() {
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ ANativeWindow *native_window = OS_Android::get_singleton()->get_native_window();
+ ERR_FAIL_COND(!native_window);
+
+ ERR_FAIL_COND(!context_vulkan);
+ context_vulkan->window_destroy(MAIN_WINDOW_ID);
+
+ Size2i display_size = OS_Android::get_singleton()->get_display_size();
+ if (context_vulkan->window_create(native_window, display_size.width, display_size.height) == -1) {
+ memdelete(context_vulkan);
+ context_vulkan = nullptr;
+ ERR_FAIL_MSG("Failed to reset Vulkan window.");
+ }
+ }
+#endif
+}
+
DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
rendering_driver = p_rendering_driver;
@@ -493,7 +512,6 @@ void DisplayServerAndroid::process_touch(int p_what, int p_pointer, const Vector
if (touch.size()) {
//end all if exist
for (int i = 0; i < touch.size(); i++) {
-
Ref<InputEventScreenTouch> ev;
ev.instance();
ev->set_index(touch[i].id);
@@ -511,7 +529,6 @@ void DisplayServerAndroid::process_touch(int p_what, int p_pointer, const Vector
//send touch
for (int i = 0; i < touch.size(); i++) {
-
Ref<InputEventScreenTouch> ev;
ev.instance();
ev->set_index(touch[i].id);
@@ -525,10 +542,8 @@ void DisplayServerAndroid::process_touch(int p_what, int p_pointer, const Vector
ERR_FAIL_COND(touch.size() != p_points.size());
for (int i = 0; i < touch.size(); i++) {
-
int idx = -1;
for (int j = 0; j < p_points.size(); j++) {
-
if (touch[i].id == p_points[j].id) {
idx = j;
break;
@@ -554,7 +569,6 @@ void DisplayServerAndroid::process_touch(int p_what, int p_pointer, const Vector
if (touch.size()) {
//end all if exist
for (int i = 0; i < touch.size(); i++) {
-
Ref<InputEventScreenTouch> ev;
ev.instance();
ev->set_index(touch[i].id);
@@ -586,7 +600,6 @@ void DisplayServerAndroid::process_touch(int p_what, int p_pointer, const Vector
case 4: { // remove touch
for (int i = 0; i < touch.size(); i++) {
if (touch[i].id == p_pointer) {
-
Ref<InputEventScreenTouch> ev;
ev.instance();
ev->set_index(touch[i].id);
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index 2096ba68f1..d64542df58 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -52,7 +52,6 @@ public:
};
struct JoypadEvent {
-
int device;
int type;
int index;
@@ -107,7 +106,7 @@ public:
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
- virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_length = -1);
+ virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_length = -1, int p_cursor_start = -1, int p_cursor_end = -1);
virtual void virtual_keyboard_hide();
virtual int virtual_keyboard_get_height() const;
@@ -167,6 +166,8 @@ public:
static Vector<String> get_rendering_drivers_func();
static void register_android_driver();
+ void reset_window();
+
DisplayServerAndroid(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
~DisplayServerAndroid();
};
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index f346ca54d2..a663a847c2 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -44,6 +44,7 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "platform/android/logo.gen.h"
+#include "platform/android/plugin/godot_plugin_config.h"
#include "platform/android/run_icon.gen.h"
#include <string.h>
@@ -235,14 +236,12 @@ static const LauncherIcon launcher_adaptive_icon_backgrounds[icon_densities_coun
};
class EditorExportPlatformAndroid : public EditorExportPlatform {
-
GDCLASS(EditorExportPlatformAndroid, EditorExportPlatform);
Ref<ImageTexture> logo;
Ref<ImageTexture> run_icon;
struct Device {
-
String id;
String name;
String description;
@@ -250,26 +249,53 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
};
struct APKExportData {
-
zipFile apk;
EditorProgress *ep;
};
+ Vector<PluginConfig> plugins;
+ String last_plugin_names;
+ uint64_t last_custom_build_time = 0;
+ volatile bool plugins_changed;
+ Mutex plugins_lock;
Vector<Device> devices;
volatile bool devices_changed;
Mutex device_lock;
- Thread *device_thread;
+ Thread *check_for_changes_thread;
volatile bool quit_request;
- static void _device_poll_thread(void *ud) {
-
+ static void _check_for_changes_poll_thread(void *ud) {
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
while (!ea->quit_request) {
+ // Check for plugins updates
+ {
+ // Nothing to do if we already know the plugins have changed.
+ if (!ea->plugins_changed) {
+ Vector<PluginConfig> loaded_plugins = get_plugins();
+
+ MutexLock lock(ea->plugins_lock);
+
+ if (ea->plugins.size() != loaded_plugins.size()) {
+ ea->plugins_changed = true;
+ } else {
+ for (int i = 0; i < ea->plugins.size(); i++) {
+ if (ea->plugins[i].name != loaded_plugins[i].name) {
+ ea->plugins_changed = true;
+ break;
+ }
+ }
+ }
+
+ if (ea->plugins_changed) {
+ ea->plugins = loaded_plugins;
+ }
+ }
+ }
+ // Check for devices updates
String adb = EditorSettings::get_singleton()->get("export/android/adb");
if (FileAccess::exists(adb)) {
-
String devices;
List<String> args;
args.push_back("devices");
@@ -279,11 +305,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
Vector<String> ds = devices.split("\n");
Vector<String> ldevices;
for (int i = 1; i < ds.size(); i++) {
-
String d = ds[i];
int dpos = d.find("device");
- if (dpos == -1)
+ if (dpos == -1) {
continue;
+ }
d = d.substr(0, dpos).strip_edges();
ldevices.push_back(d);
}
@@ -293,12 +319,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool different = false;
if (ea->devices.size() != ldevices.size()) {
-
different = true;
} else {
-
for (int i = 0; i < ea->devices.size(); i++) {
-
if (ea->devices[i].id != ldevices[i]) {
different = true;
break;
@@ -307,11 +330,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
if (different) {
-
Vector<Device> ndevices;
for (int i = 0; i < ldevices.size(); i++) {
-
Device d;
d.id = ldevices[i];
for (int j = 0; j < ea->devices.size(); j++) {
@@ -340,7 +361,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
d.description = "Device ID: " + d.id + "\n";
d.api_level = 0;
for (int j = 0; j < props.size(); j++) {
-
// got information by `shell cat /system/build.prop` before and its format is "property=value"
// it's now changed to use `shell getporp` because of permission issue with Android 8.0 and above
// its format is "[property]: [value]" so changed it as like build.prop
@@ -372,8 +392,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
d.name = vendor + " " + device;
- if (device == String())
+ if (device == String()) {
continue;
+ }
}
ndevices.push_back(d);
@@ -389,8 +410,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
uint64_t time = OS::get_singleton()->get_ticks_usec();
while (OS::get_singleton()->get_ticks_usec() - time < wait) {
OS::get_singleton()->delay_usec(1000 * sleep);
- if (ea->quit_request)
+ if (ea->quit_request) {
break;
+ }
}
}
@@ -407,7 +429,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
String get_project_name(const String &p_name) const {
-
String aname;
if (p_name != "") {
aname = p_name;
@@ -423,7 +444,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
String get_package_name(const String &p_package) const {
-
String pname = p_package;
String basename = ProjectSettings::get_singleton()->get("application/config/name");
basename = basename.to_lower();
@@ -440,8 +460,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
first = false;
}
}
- if (name == "")
+ if (name == "") {
name = "noname";
+ }
pname = pname.replace("$genname", name);
@@ -449,7 +470,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const {
-
String pname = p_package;
if (pname.length() == 0) {
@@ -513,7 +533,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data) {
-
/*
* By not compressing files with little or not benefit in doing so,
* a performance gain is expected attime. Moreover, if the APK is
@@ -560,7 +579,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
static zip_fileinfo get_zip_fileinfo() {
-
OS::Time time = OS::get_singleton()->get_time();
OS::Date date = OS::get_singleton()->get_date();
@@ -587,6 +605,73 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
return abis;
}
+ /// List the gdap files in the directory specified by the p_path parameter.
+ static Vector<String> list_gdap_files(const String &p_path) {
+ Vector<String> dir_files;
+ DirAccessRef da = DirAccess::open(p_path);
+ if (da) {
+ da->list_dir_begin();
+ while (true) {
+ String file = da->get_next();
+ if (file == "") {
+ break;
+ }
+
+ if (da->current_is_dir() || da->current_is_hidden()) {
+ continue;
+ }
+
+ if (file.ends_with(PLUGIN_CONFIG_EXT)) {
+ dir_files.push_back(file);
+ }
+ }
+ da->list_dir_end();
+ }
+
+ return dir_files;
+ }
+
+ static Vector<PluginConfig> get_plugins() {
+ Vector<PluginConfig> loaded_plugins;
+
+ String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/plugins");
+
+ // Add the prebuilt plugins
+ loaded_plugins.append_array(get_prebuilt_plugins(plugins_dir));
+
+ if (DirAccess::exists(plugins_dir)) {
+ Vector<String> plugins_filenames = list_gdap_files(plugins_dir);
+
+ if (!plugins_filenames.empty()) {
+ Ref<ConfigFile> config_file = memnew(ConfigFile);
+ for (int i = 0; i < plugins_filenames.size(); i++) {
+ PluginConfig config = load_plugin_config(config_file, plugins_dir.plus_file(plugins_filenames[i]));
+ if (config.valid_config) {
+ loaded_plugins.push_back(config);
+ } else {
+ print_error("Invalid plugin config file " + plugins_filenames[i]);
+ }
+ }
+ }
+ }
+
+ return loaded_plugins;
+ }
+
+ static Vector<PluginConfig> get_enabled_plugins(const Ref<EditorExportPreset> &p_presets) {
+ Vector<PluginConfig> enabled_plugins;
+ Vector<PluginConfig> all_plugins = get_plugins();
+ for (int i = 0; i < all_plugins.size(); i++) {
+ PluginConfig plugin = all_plugins[i];
+ bool enabled = p_presets->get("plugins/" + plugin.name);
+ if (enabled) {
+ enabled_plugins.push_back(plugin);
+ }
+ }
+
+ return enabled_plugins;
+ }
+
static Error store_in_apk(APKExportData *ed, const String &p_path, const Vector<uint8_t> &p_data, int compression_method = Z_DEFLATED) {
zip_fileinfo zipfi = get_zip_fileinfo();
zipOpenNewFileInZip(ed->apk,
@@ -649,7 +734,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
void _fix_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest, bool p_give_internet) {
-
// Leaving the unused types commented because looking these constants up
// again later would be annoying
// const int CHUNK_AXML_FILE = 0x00080003;
@@ -688,17 +772,18 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool screen_support_xlarge = p_preset->get("screen/support_xlarge");
int xr_mode_index = p_preset->get("xr_features/xr_mode");
+ bool focus_awareness = p_preset->get("xr_features/focus_awareness");
- String plugins = p_preset->get("custom_template/plugins");
+ String plugins_names = get_plugins_names(get_enabled_plugins(p_preset));
Vector<String> perms;
const char **aperms = android_perms;
while (*aperms) {
-
bool enabled = p_preset->get("permissions/" + String(*aperms).to_lower());
- if (enabled)
+ if (enabled) {
perms.push_back("android.permission." + String(*aperms));
+ }
aperms++;
}
@@ -712,19 +797,17 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
if (p_give_internet) {
- if (perms.find("android.permission.INTERNET") == -1)
+ if (perms.find("android.permission.INTERNET") == -1) {
perms.push_back("android.permission.INTERNET");
+ }
}
while (ofs < (uint32_t)p_manifest.size()) {
-
uint32_t chunk = decode_uint32(&p_manifest[ofs]);
uint32_t size = decode_uint32(&p_manifest[ofs + 4]);
switch (chunk) {
-
case CHUNK_STRINGS: {
-
int iofs = ofs + 8;
string_count = decode_uint32(&p_manifest[iofs]);
@@ -745,14 +828,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
string_table_begins = st_offset;
for (uint32_t i = 0; i < string_count; i++) {
-
uint32_t string_at = decode_uint32(&p_manifest[st_offset + i * 4]);
string_at += st_offset + string_count * 4;
ERR_FAIL_COND_MSG(string_flags & UTF8_FLAG, "Unimplemented, can't read UTF-8 string table.");
if (string_flags & UTF8_FLAG) {
-
} else {
uint32_t len = decode_uint16(&p_manifest[string_at]);
Vector<CharType> ucstring;
@@ -775,7 +856,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
} break;
case CHUNK_XML_START_TAG: {
-
int iofs = ofs + 8;
uint32_t name = decode_uint32(&p_manifest[iofs + 12]);
@@ -805,8 +885,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
if (tname == "manifest" && attrname == "versionName") {
if (attr_value == 0xFFFFFFFF) {
WARN_PRINT("Version name in a resource, should be plain text");
- } else
+ } else {
string_table.write[attr_value] = version_name;
+ }
}
if (tname == "instrumentation" && attrname == "targetPackage") {
@@ -814,26 +895,20 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
if (tname == "activity" && attrname == "screenOrientation") {
-
encode_uint32(orientation == 0 ? 0 : 1, &p_manifest.write[iofs + 16]);
}
if (tname == "supports-screens") {
-
if (attrname == "smallScreens") {
-
encode_uint32(screen_support_small ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]);
} else if (attrname == "normalScreens") {
-
encode_uint32(screen_support_normal ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]);
} else if (attrname == "largeScreens") {
-
encode_uint32(screen_support_large ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]);
} else if (attrname == "xlargeScreens") {
-
encode_uint32(screen_support_xlarge ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]);
}
}
@@ -854,9 +929,14 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}
- if (tname == "meta-data" && attrname == "value" && value == "custom_template_plugins_value") {
+ if (tname == "meta-data" && attrname == "value" && value == "oculus_focus_aware_value") {
+ // Update the focus awareness meta-data value
+ string_table.write[attr_value] = xr_mode_index == /* XRMode.OVR */ 1 && focus_awareness ? "true" : "false";
+ }
+
+ if (tname == "meta-data" && attrname == "value" && value == "plugins_value" && !plugins_names.empty()) {
// Update the meta-data 'android:value' attribute with the list of enabled plugins.
- string_table.write[attr_value] = plugins;
+ string_table.write[attr_value] = plugins_names;
}
iofs += 20;
@@ -890,8 +970,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
feature_required_list.push_back(hand_tracking_index == 2);
feature_versions.push_back(-1); // no version attribute should be added.
- if (perms.find("oculus.permission.handtracking") == -1) {
- perms.push_back("oculus.permission.handtracking");
+ if (perms.find("com.oculus.permission.HAND_TRACKING") == -1) {
+ perms.push_back("com.oculus.permission.HAND_TRACKING");
}
}
}
@@ -1038,7 +1118,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}
if (tname == "manifest") {
-
// save manifest ending so we can restore it
Vector<uint8_t> manifest_end;
uint32_t manifest_cur_size = p_manifest.size();
@@ -1124,13 +1203,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
ret.resize(string_table_begins + string_table.size() * 4);
for (uint32_t i = 0; i < string_table_begins; i++) {
-
ret.write[i] = p_manifest[i];
}
ofs = 0;
for (int i = 0; i < string_table.size(); i++) {
-
encode_uint32(ofs, &ret.write[string_table_begins + i * 4]);
ofs += string_table[i].length() * 2 + 2 + 2;
}
@@ -1139,7 +1216,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
string_data_offset = ret.size() - ofs;
uint8_t *chars = &ret.write[string_data_offset];
for (int i = 0; i < string_table.size(); i++) {
-
String s = string_table[i];
encode_uint16(s.length(), chars);
chars += 2;
@@ -1156,18 +1232,21 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
//pad
- while (ret.size() % 4)
+ while (ret.size() % 4) {
ret.push_back(0);
+ }
uint32_t new_stable_end = ret.size();
uint32_t extra = (p_manifest.size() - string_table_ends);
ret.resize(new_stable_end + extra);
- for (uint32_t i = 0; i < extra; i++)
+ for (uint32_t i = 0; i < extra; i++) {
ret.write[new_stable_end + i] = p_manifest[string_table_ends + i];
+ }
- while (ret.size() % 4)
+ while (ret.size() % 4) {
ret.push_back(0);
+ }
encode_uint32(ret.size(), &ret.write[4]); //update new file size
encode_uint32(new_stable_end - 8, &ret.write[12]); //update new string table size
@@ -1178,16 +1257,16 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
static String _parse_string(const uint8_t *p_bytes, bool p_utf8) {
-
uint32_t offset = 0;
uint32_t len = 0;
if (p_utf8) {
uint8_t byte = p_bytes[offset];
- if (byte & 0x80)
+ if (byte & 0x80) {
offset += 2;
- else
+ } else {
offset += 1;
+ }
byte = p_bytes[offset];
offset++;
if (byte & 0x80) {
@@ -1208,7 +1287,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
if (p_utf8) {
-
Vector<uint8_t> str8;
str8.resize(len + 1);
for (uint32_t i = 0; i < len; i++) {
@@ -1219,19 +1297,18 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
str.parse_utf8((const char *)str8.ptr());
return str;
} else {
-
String str;
for (uint32_t i = 0; i < len; i++) {
CharType c = decode_uint16(&p_bytes[offset + i * 2]);
- if (c == 0)
+ if (c == 0) {
break;
+ }
str += String::chr(c);
}
return str;
}
}
void _fix_resources(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest) {
-
const int UTF8_FLAG = 0x00000100;
uint32_t string_block_len = decode_uint32(&p_manifest[16]);
@@ -1244,20 +1321,17 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String package_name = p_preset->get("package/name");
for (uint32_t i = 0; i < string_count; i++) {
-
uint32_t offset = decode_uint32(&p_manifest[string_table_begins + i * 4]);
offset += string_table_begins + string_count * 4;
String str = _parse_string(&p_manifest[offset], string_flags & UTF8_FLAG);
if (str.begins_with("godot-project-name")) {
-
if (str == "godot-project-name") {
//project name
str = get_project_name(package_name);
} else {
-
String lang = str.substr(str.find_last("-") + 1, str.length()).replace("-", "_");
String prop = "application/config/name_" + lang;
if (ProjectSettings::get_singleton()->has_setting(prop)) {
@@ -1276,13 +1350,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
ret.resize(string_table_begins + string_table.size() * 4);
for (uint32_t i = 0; i < string_table_begins; i++) {
-
ret.write[i] = p_manifest[i];
}
int ofs = 0;
for (int i = 0; i < string_table.size(); i++) {
-
encode_uint32(ofs, &ret.write[string_table_begins + i * 4]);
ofs += string_table[i].length() * 2 + 2 + 2;
}
@@ -1290,7 +1362,6 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
ret.resize(ret.size() + ofs);
uint8_t *chars = &ret.write[ret.size() - ofs];
for (int i = 0; i < string_table.size(); i++) {
-
String s = string_table[i];
encode_uint16(s.length(), chars);
chars += 2;
@@ -1303,8 +1374,9 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
//pad
- while (ret.size() % 4)
+ while (ret.size() % 4) {
ret.push_back(0);
+ }
//change flags to not use utf8
encode_uint32(string_flags & ~0x100, &ret.write[28]);
@@ -1363,7 +1435,6 @@ public:
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
-
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
if (driver == "GLES2") {
r_features->push_back("etc");
@@ -1380,16 +1451,23 @@ public:
}
virtual void get_export_options(List<ExportOption> *r_options) {
-
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/degrees_of_freedom", PROPERTY_HINT_ENUM, "None,3DOF and 6DOF,6DOF"), 0));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/hand_tracking", PROPERTY_HINT_ENUM, "None,Optional,Required"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "xr_features/focus_awareness"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "custom_template/use_custom_build"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/plugins", PROPERTY_HINT_PLACEHOLDER_TEXT, "Plugin1,Plugin2,..."), ""));
+
+ Vector<PluginConfig> plugins_configs = get_plugins();
+ for (int i = 0; i < plugins_configs.size(); i++) {
+ print_verbose("Found Android plugin " + plugins_configs[i].name);
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + plugins_configs[i].name), false));
+ }
+ plugins_changed = false;
+
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0"));
@@ -1427,7 +1505,6 @@ public:
const char **perms = android_perms;
while (*perms) {
-
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "permissions/" + String(*perms).to_lower()), false));
perms++;
}
@@ -1445,8 +1522,16 @@ public:
return logo;
}
- virtual bool poll_export() {
+ virtual bool should_update_export_options() {
+ bool export_options_changed = plugins_changed;
+ if (export_options_changed) {
+ // don't clear unless we're reporting true, to avoid race
+ plugins_changed = false;
+ }
+ return export_options_changed;
+ }
+ virtual bool poll_export() {
bool dc = devices_changed;
if (dc) {
// don't clear unless we're reporting true, to avoid race
@@ -1456,25 +1541,21 @@ public:
}
virtual int get_options_count() const {
-
MutexLock lock(device_lock);
return devices.size();
}
virtual String get_options_tooltip() const {
-
return TTR("Select device from the list");
}
virtual String get_option_label(int p_index) const {
-
ERR_FAIL_INDEX_V(p_index, devices.size(), "");
MutexLock lock(device_lock);
return devices[p_index].name;
}
virtual String get_option_tooltip(int p_index) const {
-
ERR_FAIL_INDEX_V(p_index, devices.size(), "");
MutexLock lock(device_lock);
String s = devices[p_index].description;
@@ -1488,7 +1569,6 @@ public:
}
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
-
ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER);
String can_export_error;
@@ -1512,8 +1592,9 @@ public:
const bool use_remote = (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) || (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT);
const bool use_reverse = devices[p_device].api_level >= 21;
- if (use_reverse)
+ if (use_reverse) {
p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST;
+ }
String tmp_export_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport.apk");
@@ -1572,7 +1653,6 @@ public:
if (use_remote) {
if (use_reverse) {
-
static const char *const msg = "--- Device API >= 21; debugging over USB ---";
EditorNode::get_singleton()->get_log()->add_message(msg, EditorLog::MSG_TYPE_EDITOR);
print_line(String(msg).to_upper());
@@ -1585,7 +1665,6 @@ public:
OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv);
if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) {
-
int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
args.clear();
args.push_back("-s");
@@ -1599,7 +1678,6 @@ public:
}
if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) {
-
int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
args.clear();
@@ -1613,7 +1691,6 @@ public:
print_line("Reverse result2: " + itos(rv));
}
} else {
-
static const char *const msg = "--- Device API < 21; debugging over Wi-Fi ---";
EditorNode::get_singleton()->get_log()->add_message(msg, EditorLog::MSG_TYPE_EDITOR);
print_line(String(msg).to_upper());
@@ -1653,30 +1730,38 @@ public:
}
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
-
String err;
bool valid = false;
// Look for export templates (first official, and if defined custom templates).
if (!bool(p_preset->get("custom_template/use_custom_build"))) {
- bool dvalid = exists_export_template("android_debug.apk", &err);
- bool rvalid = exists_export_template("android_release.apk", &err);
+ String template_err;
+ bool dvalid = false;
+ bool rvalid = false;
if (p_preset->get("custom_template/debug") != "") {
dvalid = FileAccess::exists(p_preset->get("custom_template/debug"));
if (!dvalid) {
- err += TTR("Custom debug template not found.") + "\n";
+ template_err += TTR("Custom debug template not found.") + "\n";
}
+ } else {
+ dvalid = exists_export_template("android_debug.apk", &template_err);
}
+
if (p_preset->get("custom_template/release") != "") {
rvalid = FileAccess::exists(p_preset->get("custom_template/release"));
if (!rvalid) {
- err += TTR("Custom release template not found.") + "\n";
+ template_err += TTR("Custom release template not found.") + "\n";
}
+ } else {
+ rvalid = exists_export_template("android_release.apk", &template_err);
}
valid = dvalid || rvalid;
+ if (!valid) {
+ err += template_err;
+ }
} else {
valid = exists_export_template("android_source.zip", &err);
}
@@ -1687,7 +1772,6 @@ public:
String adb = EditorSettings::get_singleton()->get("export/android/adb");
if (!FileAccess::exists(adb)) {
-
valid = false;
err += TTR("ADB executable not configured in the Editor Settings.") + "\n";
}
@@ -1695,7 +1779,6 @@ public:
String js = EditorSettings::get_singleton()->get("export/android/jarsigner");
if (!FileAccess::exists(js)) {
-
valid = false;
err += TTR("OpenJDK jarsigner not configured in the Editor Settings.") + "\n";
}
@@ -1703,7 +1786,6 @@ public:
String dk = p_preset->get("keystore/debug");
if (!FileAccess::exists(dk)) {
-
dk = EditorSettings::get_singleton()->get("export/android/debug_keystore");
if (!FileAccess::exists(dk)) {
valid = false;
@@ -1711,6 +1793,13 @@ public:
}
}
+ String rk = p_preset->get("keystore/release");
+
+ if (!rk.empty() && !FileAccess::exists(rk)) {
+ valid = false;
+ err += TTR("Release keystore incorrectly configured in the export preset.") + "\n";
+ }
+
if (bool(p_preset->get("custom_template/use_custom_build"))) {
String sdk_path = EditorSettings::get_singleton()->get("export/android/custom_build_sdk_path");
if (sdk_path == "") {
@@ -1726,7 +1815,6 @@ public:
}
if (!FileAccess::exists("res://android/build/build.gradle")) {
-
err += TTR("Android build template not installed in the project. Install it from the Project menu.") + "\n";
valid = false;
}
@@ -1735,7 +1823,6 @@ public:
bool apk_expansion = p_preset->get("apk_expansion/enable");
if (apk_expansion) {
-
String apk_expansion_pkey = p_preset->get("apk_expansion/public_key");
if (apk_expansion_pkey == "") {
@@ -1749,7 +1836,6 @@ public:
String pn_err;
if (!is_package_name_valid(get_package_name(pn), &pn_err)) {
-
valid = false;
err += TTR("Invalid package name:") + " " + pn_err + "\n";
}
@@ -1760,6 +1846,40 @@ public:
err += etc_error;
}
+ // Ensure that `Use Custom Build` is enabled if a plugin is selected.
+ String enabled_plugins_names = get_plugins_names(get_enabled_plugins(p_preset));
+ bool custom_build_enabled = p_preset->get("custom_template/use_custom_build");
+ if (!enabled_plugins_names.empty() && !custom_build_enabled) {
+ valid = false;
+ err += TTR("\"Use Custom Build\" must be enabled to use the plugins.");
+ err += "\n";
+ }
+
+ // Validate the Xr features are properly populated
+ int xr_mode_index = p_preset->get("xr_features/xr_mode");
+ int degrees_of_freedom = p_preset->get("xr_features/degrees_of_freedom");
+ int hand_tracking = p_preset->get("xr_features/hand_tracking");
+ bool focus_awareness = p_preset->get("xr_features/focus_awareness");
+ if (xr_mode_index != /* XRMode.OVR*/ 1) {
+ if (degrees_of_freedom > 0) {
+ valid = false;
+ err += TTR("\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\".");
+ err += "\n";
+ }
+
+ if (hand_tracking > 0) {
+ valid = false;
+ err += TTR("\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\".");
+ err += "\n";
+ }
+
+ if (focus_awareness) {
+ valid = false;
+ err += TTR("\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\".");
+ err += "\n";
+ }
+ }
+
r_error = err;
return valid;
}
@@ -1770,8 +1890,30 @@ public:
return list;
}
- virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) {
+ inline bool is_clean_build_required(Vector<PluginConfig> enabled_plugins) {
+ String plugin_names = get_plugins_names(enabled_plugins);
+ bool first_build = last_custom_build_time == 0;
+ bool have_plugins_changed = false;
+
+ if (!first_build) {
+ have_plugins_changed = plugin_names != last_plugin_names;
+ if (!have_plugins_changed) {
+ for (int i = 0; i < enabled_plugins.size(); i++) {
+ if (enabled_plugins.get(i).last_updated > last_custom_build_time) {
+ have_plugins_changed = true;
+ break;
+ }
+ }
+ }
+ }
+ last_custom_build_time = OS::get_singleton()->get_unix_time();
+ last_plugin_names = plugin_names;
+
+ return have_plugins_changed || first_build;
+ }
+
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) {
ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
String src_apk;
@@ -1808,18 +1950,26 @@ public:
#endif
String build_path = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/build");
- String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/plugins");
build_command = build_path.plus_file(build_command);
String package_name = get_package_name(p_preset->get("package/unique_name"));
- String plugins = p_preset->get("custom_template/plugins");
+
+ Vector<PluginConfig> enabled_plugins = get_enabled_plugins(p_preset);
+ String local_plugins_binaries = get_plugins_binaries(BINARY_TYPE_LOCAL, enabled_plugins);
+ String remote_plugins_binaries = get_plugins_binaries(BINARY_TYPE_REMOTE, enabled_plugins);
+ String custom_maven_repos = get_plugins_custom_maven_repos(enabled_plugins);
+ bool clean_build_required = is_clean_build_required(enabled_plugins);
List<String> cmdline;
+ if (clean_build_required) {
+ cmdline.push_back("clean");
+ }
cmdline.push_back("build");
cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name.
- cmdline.push_back("-Pcustom_template_plugins_dir=" + plugins_dir); // argument to specify the plugins directory.
- cmdline.push_back("-Pcustom_template_plugins=" + plugins); // argument to specify the list of plugins to enable.
+ cmdline.push_back("-Pplugins_local_binaries=" + local_plugins_binaries); // argument to specify the list of plugins local dependencies.
+ cmdline.push_back("-Pplugins_remote_binaries=" + remote_plugins_binaries); // argument to specify the list of plugins remote dependencies.
+ cmdline.push_back("-Pplugins_maven_repos=" + custom_maven_repos); // argument to specify the list of custom maven repos for the plugins dependencies.
cmdline.push_back("-p"); // argument to specify the start directory.
cmdline.push_back(build_path); // start directory.
/*{ used for debug
@@ -1846,11 +1996,11 @@ public:
}
} else {
-
- if (p_debug)
+ if (p_debug) {
src_apk = p_preset->get("custom_template/debug");
- else
+ } else {
src_apk = p_preset->get("custom_template/release");
+ }
src_apk = src_apk.strip_edges();
if (src_apk == "") {
@@ -1879,7 +2029,6 @@ public:
unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io);
if (!pkg) {
-
EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk);
return ERR_FILE_NOT_FOUND;
}
@@ -1953,7 +2102,6 @@ public:
Vector<String> invalid_abis(enabled_abis);
while (ret == UNZ_OK) {
-
//get filename
unz_file_info info;
char fname[16384];
@@ -2059,7 +2207,6 @@ public:
gen_export_flags(cl, p_flags);
if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
-
APKExportData ed;
ed.ep = &ep;
ed.apk = unaligned_apk;
@@ -2068,7 +2215,6 @@ public:
//all files
if (apk_expansion) {
-
String apkfname = "main." + itos(version_code) + "." + get_package_name(package_name) + ".obb";
String fullpath = p_path.get_base_dir().plus_file(apkfname);
err = save_pack(p_preset, fullpath);
@@ -2087,7 +2233,6 @@ public:
cl.push_back(apk_expansion_pkey.strip_edges());
} else {
-
APKExportData ed;
ed.ep = &ep;
ed.apk = unaligned_apk;
@@ -2104,14 +2249,17 @@ public:
cl.push_back("--xr_mode_regular");
}
- if (use_32_fb)
+ if (use_32_fb) {
cl.push_back("--use_depth_32");
+ }
- if (immersive)
+ if (immersive) {
cl.push_back("--use_immersive");
+ }
- if (debug_opengl)
+ if (debug_opengl) {
cl.push_back("--debug_opengl");
+ }
if (cl.size()) {
//add comandline
@@ -2119,13 +2267,13 @@ public:
clf.resize(4);
encode_uint32(cl.size(), &clf.write[0]);
for (int i = 0; i < cl.size(); i++) {
-
print_line(itos(i) + " param: " + cl[i]);
CharString txt = cl[i].utf8();
int base = clf.size();
int length = txt.length();
- if (!length)
+ if (!length) {
continue;
+ }
clf.resize(base + 4 + length);
encode_uint32(length, &clf.write[base]);
copymem(&clf.write[base + 4], txt.ptr(), length);
@@ -2156,7 +2304,6 @@ public:
}
if (_signed) {
-
String jarsigner = EditorSettings::get_singleton()->get("export/android/jarsigner");
if (!FileAccess::exists(jarsigner)) {
EditorNode::add_io_error("'jarsigner' could not be found.\nPlease supply a path in the Editor Settings.\nThe resulting APK is unsigned.");
@@ -2167,13 +2314,11 @@ public:
String password;
String user;
if (p_debug) {
-
keystore = p_preset->get("keystore/debug");
password = p_preset->get("keystore/debug_password");
user = p_preset->get("keystore/debug_user");
if (keystore.empty()) {
-
keystore = EditorSettings::get_singleton()->get("export/android/debug_keystore");
password = EditorSettings::get_singleton()->get("export/android/debug_keystore_pass");
user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user");
@@ -2250,7 +2395,6 @@ public:
unzFile tmp_unaligned = unzOpen2(tmp_unaligned_path.utf8().get_data(), &io);
if (!tmp_unaligned) {
-
EditorNode::add_io_error("Could not unzip temporary unaligned APK.");
CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND);
}
@@ -2267,7 +2411,6 @@ public:
// following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp
int bias = 0;
while (ret == UNZ_OK) {
-
unz_file_info info;
memset(&info, 0, sizeof(info));
@@ -2326,7 +2469,6 @@ public:
}
virtual void get_platform_features(List<String> *r_features) {
-
r_features->push_back("mobile");
r_features->push_back("Android");
}
@@ -2335,7 +2477,6 @@ public:
}
EditorExportPlatformAndroid() {
-
Ref<Image> img = memnew(Image(_android_logo));
logo.instance();
logo->create_from_image(img);
@@ -2345,19 +2486,19 @@ public:
run_icon->create_from_image(img);
devices_changed = true;
+ plugins_changed = true;
quit_request = false;
- device_thread = Thread::create(_device_poll_thread, this);
+ check_for_changes_thread = Thread::create(_check_for_changes_poll_thread, this);
}
~EditorExportPlatformAndroid() {
quit_request = true;
- Thread::wait_to_finish(device_thread);
- memdelete(device_thread);
+ Thread::wait_to_finish(check_for_changes_thread);
+ memdelete(check_for_changes_thread);
}
};
void register_android_exporter() {
-
String exe_ext;
if (OS::get_singleton()->get_name() == "Windows") {
exe_ext = "*.exe";
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index fa805ec4f3..05d5fb576d 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -39,12 +39,10 @@ AAssetManager *FileAccessAndroid::asset_manager = nullptr;
}*/
FileAccess *FileAccessAndroid::create_android() {
-
return memnew(FileAccessAndroid);
}
Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) {
-
String path = fix_path(p_path).simplify_path();
if (path.begins_with("/"))
path = path.substr(1, path.length());
@@ -64,7 +62,6 @@ Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessAndroid::close() {
-
if (!a)
return;
AAsset_close(a);
@@ -72,12 +69,10 @@ void FileAccessAndroid::close() {
}
bool FileAccessAndroid::is_open() const {
-
return a != nullptr;
}
void FileAccessAndroid::seek(size_t p_position) {
-
ERR_FAIL_COND(!a);
AAsset_seek(a, p_position, SEEK_SET);
pos = p_position;
@@ -90,29 +85,24 @@ void FileAccessAndroid::seek(size_t p_position) {
}
void FileAccessAndroid::seek_end(int64_t p_position) {
-
ERR_FAIL_COND(!a);
AAsset_seek(a, p_position, SEEK_END);
pos = len + p_position;
}
size_t FileAccessAndroid::get_position() const {
-
return pos;
}
size_t FileAccessAndroid::get_len() const {
-
return len;
}
bool FileAccessAndroid::eof_reached() const {
-
return eof;
}
uint8_t FileAccessAndroid::get_8() const {
-
if (pos >= len) {
eof = true;
return 0;
@@ -125,7 +115,6 @@ uint8_t FileAccessAndroid::get_8() const {
}
int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
-
off_t r = AAsset_read(a, p_dst, p_length);
if (pos + p_length > len) {
@@ -133,7 +122,6 @@ int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
}
if (r >= 0) {
-
pos += r;
if (pos > len) {
pos = len;
@@ -143,22 +131,18 @@ int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessAndroid::get_error() const {
-
return eof ? ERR_FILE_EOF : OK; //not sure what else it may happen
}
void FileAccessAndroid::flush() {
-
ERR_FAIL();
}
void FileAccessAndroid::store_8(uint8_t p_dest) {
-
ERR_FAIL();
}
bool FileAccessAndroid::file_exists(const String &p_path) {
-
String path = fix_path(p_path).simplify_path();
if (path.begins_with("/"))
path = path.substr(1, path.length());
diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h
index 6b5ec541fd..a347c63ffb 100644
--- a/platform/android/file_access_android.h
+++ b/platform/android/file_access_android.h
@@ -38,7 +38,6 @@
//#include <android_native_app_glue.h>
class FileAccessAndroid : public FileAccess {
-
static FileAccess *create_android();
mutable AAsset *a;
mutable size_t len;
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index e088eca8ef..df8b57fd3a 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -44,12 +44,10 @@ jmethodID FileAccessJAndroid::_file_eof = 0;
jmethodID FileAccessJAndroid::_file_close = 0;
FileAccess *FileAccessJAndroid::create_jandroid() {
-
return memnew(FileAccessJAndroid);
}
Error FileAccessJAndroid::_open(const String &p_path, int p_mode_flags) {
-
if (is_open())
close();
@@ -75,7 +73,6 @@ Error FileAccessJAndroid::_open(const String &p_path, int p_mode_flags) {
}
void FileAccessJAndroid::close() {
-
if (!is_open())
return;
@@ -86,12 +83,10 @@ void FileAccessJAndroid::close() {
}
bool FileAccessJAndroid::is_open() const {
-
return id != 0;
}
void FileAccessJAndroid::seek(size_t p_position) {
-
JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use.");
@@ -99,42 +94,37 @@ void FileAccessJAndroid::seek(size_t p_position) {
}
void FileAccessJAndroid::seek_end(int64_t p_position) {
-
ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use.");
seek(get_len());
}
size_t FileAccessJAndroid::get_position() const {
-
JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
return env->CallIntMethod(io, _file_tell, id);
}
size_t FileAccessJAndroid::get_len() const {
-
JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
return env->CallIntMethod(io, _file_get_size, id);
}
bool FileAccessJAndroid::eof_reached() const {
-
JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
return env->CallIntMethod(io, _file_eof, id);
}
uint8_t FileAccessJAndroid::get_8() const {
-
ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
uint8_t byte;
get_buffer(&byte, 1);
return byte;
}
-int FileAccessJAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
+int FileAccessJAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
if (p_length == 0)
return 0;
@@ -150,7 +140,6 @@ int FileAccessJAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
}
Error FileAccessJAndroid::get_error() const {
-
if (eof_reached())
return ERR_FILE_EOF;
return OK;
@@ -163,7 +152,6 @@ void FileAccessJAndroid::store_8(uint8_t p_dest) {
}
bool FileAccessJAndroid::file_exists(const String &p_path) {
-
JNIEnv *env = ThreadAndroid::get_env();
String path = fix_path(p_path).simplify_path();
@@ -184,7 +172,6 @@ bool FileAccessJAndroid::file_exists(const String &p_path) {
}
void FileAccessJAndroid::setup(jobject p_io) {
-
io = p_io;
JNIEnv *env = ThreadAndroid::get_env();
@@ -201,12 +188,10 @@ void FileAccessJAndroid::setup(jobject p_io) {
}
FileAccessJAndroid::FileAccessJAndroid() {
-
id = 0;
}
FileAccessJAndroid::~FileAccessJAndroid() {
-
if (is_open())
close();
}
diff --git a/platform/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h
index b361c64922..e252a4d3ac 100644
--- a/platform/android/file_access_jandroid.h
+++ b/platform/android/file_access_jandroid.h
@@ -34,7 +34,6 @@
#include "core/os/file_access.h"
#include "java_godot_lib_jni.h"
class FileAccessJAndroid : public FileAccess {
-
static jobject io;
static jclass cls;
diff --git a/platform/android/java/app/AndroidManifest.xml b/platform/android/java/app/AndroidManifest.xml
index cc480d1c84..dbf1dc0f3c 100644
--- a/platform/android/java/app/AndroidManifest.xml
+++ b/platform/android/java/app/AndroidManifest.xml
@@ -32,8 +32,8 @@
<!-- Metadata populated at export time and used by Godot to figure out which plugins must be enabled. -->
<meta-data
- android:name="custom_template_plugins"
- android:value="custom_template_plugins_value"/>
+ android:name="plugins"
+ android:value="plugins_value"/>
<activity
android:name=".GodotApp"
@@ -45,6 +45,9 @@
android:resizeableActivity="false"
tools:ignore="UnusedAttribute" >
+ <!-- Focus awareness metadata populated at export time if the user enables it in the 'Xr Features' section. -->
+ <meta-data android:name="com.oculus.vr.focusaware" android:value="oculus_focus_aware_value" />
+
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/platform/android/java/app/build.gradle b/platform/android/java/app/build.gradle
index 9ae47d6174..19202d2310 100644
--- a/platform/android/java/app/build.gradle
+++ b/platform/android/java/app/build.gradle
@@ -21,6 +21,16 @@ allprojects {
mavenCentral()
google()
jcenter()
+
+ // Godot user plugins custom maven repos
+ String[] mavenRepos = getGodotPluginsMavenRepos()
+ if (mavenRepos != null && mavenRepos.size() > 0) {
+ for (String repoUrl : mavenRepos) {
+ maven {
+ url repoUrl
+ }
+ }
+ }
}
}
@@ -40,15 +50,18 @@ dependencies {
releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar', '*.aar'])
}
- // Godot prebuilt plugins
- implementation fileTree(dir: 'libs/plugins', include: ["GodotPayment*.aar"])
+ // Godot user plugins remote dependencies
+ String[] remoteDeps = getGodotPluginsRemoteBinaries()
+ if (remoteDeps != null && remoteDeps.size() > 0) {
+ for (String dep : remoteDeps) {
+ implementation dep
+ }
+ }
- // Godot user plugins dependencies
- String pluginsDir = getGodotPluginsDirectory()
- String[] pluginsBinaries = getGodotPluginsBinaries()
- if (pluginsDir != null && !pluginsDir.isEmpty() &&
- pluginsBinaries != null && pluginsBinaries.size() > 0) {
- implementation fileTree(dir: pluginsDir, include: pluginsBinaries)
+ // Godot user plugins local dependencies
+ String[] pluginsBinaries = getGodotPluginsLocalBinaries()
+ if (pluginsBinaries != null && pluginsBinaries.size() > 0) {
+ implementation files(pluginsBinaries)
}
}
@@ -62,6 +75,11 @@ android {
}
defaultConfig {
+ // The default ignore pattern for the 'assets' directory includes hidden files and directories which are used by Godot projects.
+ aaptOptions {
+ ignoreAssetsPattern "!.svn:!.git:!.ds_store:!*.scc:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"
+ }
+
// Feel free to modify the application id to your own.
applicationId getExportPackageName()
minSdkVersion versions.minSdk
diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle
index aa98194a10..acfdef531e 100644
--- a/platform/android/java/app/config.gradle
+++ b/platform/android/java/app/config.gradle
@@ -4,18 +4,18 @@ ext.versions = [
minSdk : 18,
targetSdk : 29,
buildTools : '29.0.3',
- supportCoreUtils : '28.0.0',
+ supportCoreUtils : '1.0.0',
kotlinVersion : '1.3.61',
- v4Support : '28.0.0'
+ v4Support : '1.0.0'
]
ext.libraries = [
androidGradlePlugin: "com.android.tools.build:gradle:$versions.androidGradlePlugin",
- supportCoreUtils : "com.android.support:support-core-utils:$versions.supportCoreUtils",
+ supportCoreUtils : "androidx.legacy:legacy-support-core-utils:$versions.supportCoreUtils",
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion",
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlinVersion",
- v4Support : "com.android.support:support-v4:$versions.v4Support"
+ v4Support : "androidx.legacy:legacy-support-v4:$versions.v4Support"
]
ext.getExportPackageName = { ->
@@ -28,39 +28,63 @@ ext.getExportPackageName = { ->
return appId
}
+final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|"
+
/**
- * Parse the project properties for the 'custom_template_plugins' property and return
- * their binaries for inclusion in the build dependencies.
- *
- * The listed plugins must have their binaries in the project plugins directory.
+ * Parse the project properties for the 'plugins_maven_repos' property and return the list
+ * of maven repos.
*/
-ext.getGodotPluginsBinaries = { ->
- String[] binDeps = []
+ext.getGodotPluginsMavenRepos = { ->
+ Set<String> mavenRepos = []
- // Retrieve the list of enabled plugins.
- if (project.hasProperty("custom_template_plugins")) {
- String pluginsList = project.property("custom_template_plugins")
- if (pluginsList != null && !pluginsList.trim().isEmpty()) {
- for (String plugin : pluginsList.split(",")) {
- binDeps += plugin.trim() + "*.aar"
+ // Retrieve the list of maven repos.
+ if (project.hasProperty("plugins_maven_repos")) {
+ String mavenReposProperty = project.property("plugins_maven_repos")
+ if (mavenReposProperty != null && !mavenReposProperty.trim().isEmpty()) {
+ for (String mavenRepoUrl : mavenReposProperty.split(PLUGIN_VALUE_SEPARATOR_REGEX)) {
+ mavenRepos += mavenRepoUrl.trim()
}
}
}
- return binDeps
+ return mavenRepos
}
/**
- * Parse the project properties for the 'custom_template_plugins_dir' property and return
- * its value.
- *
- * The returned value is the directory containing user plugins.
+ * Parse the project properties for the 'plugins_remote_binaries' property and return
+ * it for inclusion in the build dependencies.
*/
-ext.getGodotPluginsDirectory = { ->
- // The plugins directory is provided by the 'custom_template_plugins_dir' property.
- String pluginsDir = project.hasProperty("custom_template_plugins_dir")
- ? project.property("custom_template_plugins_dir")
- : ""
+ext.getGodotPluginsRemoteBinaries = { ->
+ Set<String> remoteDeps = []
+
+ // Retrieve the list of remote plugins binaries.
+ if (project.hasProperty("plugins_remote_binaries")) {
+ String remoteDepsList = project.property("plugins_remote_binaries")
+ if (remoteDepsList != null && !remoteDepsList.trim().isEmpty()) {
+ for (String dep: remoteDepsList.split(PLUGIN_VALUE_SEPARATOR_REGEX)) {
+ remoteDeps += dep.trim()
+ }
+ }
+ }
+ return remoteDeps
+}
- return pluginsDir
+/**
+ * Parse the project properties for the 'plugins_local_binaries' property and return
+ * their binaries for inclusion in the build dependencies.
+ */
+ext.getGodotPluginsLocalBinaries = { ->
+ Set<String> binDeps = []
+
+ // Retrieve the list of local plugins binaries.
+ if (project.hasProperty("plugins_local_binaries")) {
+ String pluginsList = project.property("plugins_local_binaries")
+ if (pluginsList != null && !pluginsList.trim().isEmpty()) {
+ for (String plugin : pluginsList.split(PLUGIN_VALUE_SEPARATOR_REGEX)) {
+ binDeps += plugin.trim()
+ }
+ }
+ }
+
+ return binDeps
}
diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle
index 865b61956c..80c6be0fae 100644
--- a/platform/android/java/build.gradle
+++ b/platform/android/java/build.gradle
@@ -140,7 +140,7 @@ task generateGodotTemplates(type: GradleBuild) {
startParameter.excludedTaskNames += ":lib:" + getSconsTaskName(buildType)
}
- tasks = ["copyGodotPaymentPluginToAppModule"]
+ tasks = []
// Only build the apks and aar files for which we have native shared libraries.
for (String target : supportedTargets) {
@@ -161,6 +161,7 @@ task generateGodotTemplates(type: GradleBuild) {
}
}
+ dependsOn 'copyGodotPaymentPluginToAppModule'
finalizedBy 'zipCustomBuild'
}
@@ -192,4 +193,6 @@ task cleanGodotTemplates(type: Delete) {
delete("$binDir/android_source.zip")
delete("$binDir/godot-lib.debug.aar")
delete("$binDir/godot-lib.release.aar")
+
+ finalizedBy getTasksByName("clean", true)
}
diff --git a/platform/android/java/gradle.properties b/platform/android/java/gradle.properties
index aac7c9b461..e14cd5ba5c 100644
--- a/platform/android/java/gradle.properties
+++ b/platform/android/java/gradle.properties
@@ -7,6 +7,9 @@
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
+android.enableJetifier=true
+android.useAndroidX=true
+
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
diff --git a/platform/android/java/lib/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java b/platform/android/java/lib/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java
index 0abaf2e052..d481c22204 100644
--- a/platform/android/java/lib/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java
+++ b/platform/android/java/lib/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java
@@ -29,9 +29,9 @@ import com.google.android.vending.expansion.downloader.IDownloaderClient;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
-import android.os.Build;
import android.os.Messenger;
-import android.support.v4.app.NotificationCompat;
+
+import androidx.core.app.NotificationCompat;
/**
* This class handles displaying the notification associated with the download
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java b/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java
index 594cae774b..8b7a9c6c74 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java
@@ -34,16 +34,13 @@ import java.util.HashMap;
import java.util.Set;
public class Dictionary extends HashMap<String, Object> {
-
protected String[] keys_cache;
public String[] get_keys() {
-
String[] ret = new String[size()];
int i = 0;
Set<String> keys = keySet();
for (String key : keys) {
-
ret[i] = key;
i++;
};
@@ -52,12 +49,10 @@ public class Dictionary extends HashMap<String, Object> {
};
public Object[] get_values() {
-
Object[] ret = new Object[size()];
int i = 0;
Set<String> keys = keySet();
for (String key : keys) {
-
ret[i] = get(key);
i++;
};
@@ -70,7 +65,6 @@ public class Dictionary extends HashMap<String, Object> {
};
public void set_values(Object[] vals) {
-
int i = 0;
for (String key : keys_cache) {
put(key, vals[i]);
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
index ffe5402a54..fcbbc86100 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
@@ -66,10 +66,6 @@ import android.os.Messenger;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings.Secure;
-import android.support.annotation.CallSuper;
-import android.support.annotation.Keep;
-import android.support.annotation.NonNull;
-import android.support.v4.app.FragmentActivity;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -85,6 +81,11 @@ import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
+import androidx.annotation.CallSuper;
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentActivity;
+
import com.google.android.vending.expansion.downloader.DownloadProgressInfo;
import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
import com.google.android.vending.expansion.downloader.DownloaderServiceMarshaller;
@@ -102,7 +103,6 @@ import java.util.List;
import java.util.Locale;
public abstract class Godot extends FragmentActivity implements SensorEventListener, IDownloaderClient {
-
private IStub mDownloaderClientStub;
private TextView mStatusText;
private TextView mProgressFraction;
@@ -251,7 +251,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
mRenderView.queueOnRenderThread(new Runnable() {
@Override
public void run() {
-
// Must occur after GodotLib.setup has completed.
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onRegisterPluginWithGodotNative();
@@ -263,7 +262,7 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
// Include the returned non-null views in the Godot view hierarchy.
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
- View pluginView = plugin.onMainCreateView(this);
+ View pluginView = plugin.onMainCreate(this);
if (pluginView != null) {
layout.addView(pluginView);
}
@@ -346,7 +345,8 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
return deviceInfo.reqGlEsVersion;
}
- private String[] getCommandLine() {
+ @CallSuper
+ protected String[] getCommandLine() {
InputStream is;
try {
is = getAssets().open("_cl_");
@@ -361,7 +361,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
for (int i = 0; i < argc; i++) {
r = is.read(len);
if (r < 4) {
-
return new String[0];
}
int strlen = ((int)(len[3] & 0xFF) << 24) | ((int)(len[2] & 0xFF) << 16) | ((int)(len[1] & 0xFF) << 8) | ((int)(len[0] & 0xFF));
@@ -409,9 +408,7 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
String expansion_pack_path;
private void initializeGodot() {
-
if (expansion_pack_path != null) {
-
String[] new_cmdline;
int cll = 0;
if (command_line != null) {
@@ -458,7 +455,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
@Override
protected void onCreate(Bundle icicle) {
-
super.onCreate(icicle);
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
@@ -475,7 +471,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
List<String> new_args = new LinkedList<String>();
for (int i = 0; i < command_line.length; i++) {
-
boolean has_extra = i < command_line.length - 1;
if (command_line[i].equals(XRMode.REGULAR.cmdLineArg)) {
xrMode = XRMode.REGULAR;
@@ -519,7 +514,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
if (new_args.isEmpty()) {
command_line = null;
} else {
-
command_line = new_args.toArray(new String[new_args.size()]);
}
if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
@@ -541,7 +535,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
boolean pack_valid = true;
if (!f.exists()) {
-
pack_valid = false;
} else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
@@ -553,7 +546,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
}
if (!pack_valid) {
-
Intent notifierIntent = new Intent(this, this.getClass());
notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -602,7 +594,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
@Override
protected void onDestroy() {
-
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onMainDestroy();
}
@@ -637,7 +628,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
}
public String getClipboard() {
-
String copiedText = "";
if (mClipboard.getPrimaryClip() != null) {
@@ -649,7 +639,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
}
public void setClipboard(String p_text) {
-
ClipData clip = ClipData.newPlainText("myLabel", p_text);
mClipboard.setPrimaryClip(clip);
}
@@ -809,9 +798,7 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
}
private boolean obbIsCorrupted(String f, String main_pack_md5) {
-
try {
-
InputStream fis = new FileInputStream(f);
// Create MD5 Hash
@@ -852,7 +839,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
}
public boolean gotTouchEvent(final MotionEvent event) {
-
final int evcount = event.getPointerCount();
if (evcount == 0)
return true;
@@ -861,7 +847,6 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
final int[] arr = new int[event.getPointerCount() * 3];
for (int i = 0; i < event.getPointerCount(); i++) {
-
arr[i * 3 + 0] = (int)event.getPointerId(i);
arr[i * 3 + 1] = (int)event.getX(i);
arr[i * 3 + 2] = (int)event.getY(i);
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java b/platform/android/java/lib/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
index fa95e82e7a..a3dae15980 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
@@ -46,7 +46,6 @@ import com.google.android.vending.expansion.downloader.DownloaderClientMarshalle
* <receiver android:name=".GodotDownloaderAlarmReceiver"/>
*/
public class GodotDownloaderAlarmReceiver extends BroadcastReceiver {
-
@Override
public void onReceive(Context context, Intent intent) {
Log.d("GODOT", "Alarma recivida");
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
index 5d8ac09643..14dd893faa 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
@@ -68,7 +68,6 @@ import android.view.SurfaceView;
* bit depths). Failure to do so would result in an EGL_BAD_MATCH error.
*/
public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView {
-
private final Godot activity;
private final GodotInputHandler inputHandler;
private final GestureDetector detector;
@@ -140,11 +139,9 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
}
private void init(XRMode xrMode, boolean translucent, int depth, int stencil) {
-
setPreserveEGLContextOnPause(true);
setFocusableInTouchMode(true);
switch (xrMode) {
-
case OVR:
// Replace the default egl config chooser.
setEGLConfigChooser(new OvrConfigChooser());
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
index 2eb6f4e313..93f4786e83 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
@@ -50,7 +50,6 @@ import java.util.Locale;
// Wrapper for native library
public class GodotIO {
-
AssetManager am;
Godot activity;
GodotEditText edit;
@@ -70,7 +69,6 @@ public class GodotIO {
public int last_file_id = 1;
class AssetData {
-
public boolean eof = false;
public String path;
public InputStream is;
@@ -81,7 +79,6 @@ public class GodotIO {
SparseArray<AssetData> streams;
public int file_open(String path, boolean write) {
-
//System.out.printf("file_open: Attempt to Open %s\n",path);
//Log.v("MyApp", "TRYING TO OPEN FILE: " + path);
@@ -94,7 +91,6 @@ public class GodotIO {
ad.is = am.open(path);
} catch (Exception e) {
-
//System.out.printf("Exception on file_open: %s\n",path);
return -1;
}
@@ -102,7 +98,6 @@ public class GodotIO {
try {
ad.len = ad.is.available();
} catch (Exception e) {
-
System.out.printf("Exception availabling on file_open: %s\n", path);
return -1;
}
@@ -115,7 +110,6 @@ public class GodotIO {
return last_file_id;
}
public int file_get_size(int id) {
-
if (streams.get(id) == null) {
System.out.printf("file_get_size: Invalid file id: %d\n", id);
return -1;
@@ -124,7 +118,6 @@ public class GodotIO {
return streams.get(id).len;
}
public void file_seek(int id, int bytes) {
-
if (streams.get(id) == null) {
System.out.printf("file_get_size: Invalid file id: %d\n", id);
return;
@@ -137,7 +130,6 @@ public class GodotIO {
bytes = 0;
try {
-
if (bytes > (int)ad.pos) {
int todo = bytes - (int)ad.pos;
while (todo > 0) {
@@ -145,7 +137,6 @@ public class GodotIO {
}
ad.pos = bytes;
} else if (bytes < (int)ad.pos) {
-
ad.is = am.open(ad.path);
ad.pos = bytes;
@@ -157,14 +148,12 @@ public class GodotIO {
ad.eof = false;
} catch (IOException e) {
-
System.out.printf("Exception on file_seek: %s\n", e);
return;
}
}
public int file_tell(int id) {
-
if (streams.get(id) == null) {
System.out.printf("file_read: Can't tell eof for invalid file id: %d\n", id);
return 0;
@@ -174,7 +163,6 @@ public class GodotIO {
return ad.pos;
}
public boolean file_eof(int id) {
-
if (streams.get(id) == null) {
System.out.printf("file_read: Can't check eof for invalid file id: %d\n", id);
return false;
@@ -185,7 +173,6 @@ public class GodotIO {
}
public byte[] file_read(int id, int bytes) {
-
if (streams.get(id) == null) {
System.out.printf("file_read: Can't read invalid file id: %d\n", id);
return new byte[0];
@@ -194,13 +181,11 @@ public class GodotIO {
AssetData ad = streams.get(id);
if (ad.pos + bytes > ad.len) {
-
bytes = ad.len - ad.pos;
ad.eof = true;
}
if (bytes == 0) {
-
return new byte[0];
}
@@ -209,7 +194,6 @@ public class GodotIO {
try {
r = ad.is.read(buf1);
} catch (IOException e) {
-
System.out.printf("Exception on file_read: %s\n", e);
return new byte[bytes];
}
@@ -221,19 +205,16 @@ public class GodotIO {
ad.pos += r;
if (r < bytes) {
-
byte[] buf2 = new byte[r];
for (int i = 0; i < r; i++)
buf2[i] = buf1[i];
return buf2;
} else {
-
return buf1;
}
}
public void file_close(int id) {
-
if (streams.get(id) == null) {
System.out.printf("file_close: Can't close invalid file id: %d\n", id);
return;
@@ -247,7 +228,6 @@ public class GodotIO {
/////////////////////////
class AssetDir {
-
public String[] files;
public int current;
public String path;
@@ -258,7 +238,6 @@ public class GodotIO {
SparseArray<AssetDir> dirs;
public int dir_open(String path) {
-
AssetDir ad = new AssetDir();
ad.current = 0;
ad.path = path;
@@ -271,7 +250,6 @@ public class GodotIO {
return -1;
}
} catch (IOException e) {
-
System.out.printf("Exception on dir_open: %s\n", e);
return -1;
}
@@ -310,7 +288,6 @@ public class GodotIO {
}
public String dir_next(int id) {
-
if (dirs.get(id) == null) {
System.out.printf("dir_next: invalid dir id: %d\n", id);
return "";
@@ -329,7 +306,6 @@ public class GodotIO {
}
public void dir_close(int id) {
-
if (dirs.get(id) == null) {
System.out.printf("dir_close: invalid dir id: %d\n", id);
return;
@@ -339,7 +315,6 @@ public class GodotIO {
}
GodotIO(Godot p_activity) {
-
am = p_activity.getAssets();
activity = p_activity;
//streams = new HashMap<Integer, AssetData>();
@@ -430,7 +405,6 @@ public class GodotIO {
}
public void audioPause(boolean p_pause) {
-
if (p_pause)
mAudioTrack.pause();
else
@@ -442,7 +416,6 @@ public class GodotIO {
/////////////////////////
public int openURI(String p_uri) {
-
try {
Log.v("MyApp", "TRYING TO OPEN URI: " + p_uri);
String path = p_uri;
@@ -451,7 +424,6 @@ public class GodotIO {
//absolute path to filesystem, prepend file://
path = "file://" + path;
if (p_uri.endsWith(".png") || p_uri.endsWith(".jpg") || p_uri.endsWith(".gif") || p_uri.endsWith(".webp")) {
-
type = "image/*";
}
}
@@ -467,18 +439,15 @@ public class GodotIO {
activity.startActivity(intent);
return 0;
} catch (ActivityNotFoundException e) {
-
return 1;
}
}
public String getDataDir() {
-
return activity.getFilesDir().getAbsolutePath();
}
public String getLocale() {
-
return Locale.getDefault().toString();
}
@@ -491,9 +460,9 @@ public class GodotIO {
return (int)(metrics.density * 160f);
}
- public void showKeyboard(String p_existing_text, int p_max_input_length) {
+ public void showKeyboard(String p_existing_text, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
if (edit != null)
- edit.showKeyboard(p_existing_text, p_max_input_length);
+ edit.showKeyboard(p_existing_text, p_max_input_length, p_cursor_start, p_cursor_end);
//InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
//inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
@@ -505,9 +474,7 @@ public class GodotIO {
};
public void setScreenOrientation(int p_orientation) {
-
switch (p_orientation) {
-
case SCREEN_LANDSCAPE: {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} break;
@@ -550,7 +517,6 @@ public class GodotIO {
public static final int SYSTEM_DIR_RINGTONES = 7;
public String getSystemDir(int idx) {
-
String what = "";
switch (idx) {
case SYSTEM_DIR_DESKTOP: {
@@ -595,7 +561,6 @@ public class GodotIO {
public static String unique_id = "";
public String getUniqueID() {
-
return unique_id;
}
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
index 9383781150..3693f36557 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
@@ -41,7 +41,6 @@ import javax.microedition.khronos.opengles.GL10;
* Wrapper for native library
*/
public class GodotLib {
-
public static GodotIO io;
static {
@@ -67,11 +66,12 @@ public class GodotLib {
/**
* Invoked on the GL thread when the underlying Android surface has changed size.
- * @param width
- * @param height
+ * @param p_surface
+ * @param p_width
+ * @param p_height
* @see android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(GL10, int, int)
*/
- public static native void resize(int width, int height);
+ public static native void resize(Surface p_surface, int p_width, int p_height);
/**
* Invoked on the render thread when the underlying Android surface is created or recreated.
@@ -190,7 +190,7 @@ public class GodotLib {
* @param p_method Name of the method to invoke
* @param p_params Parameters to use for method invocation
*/
- public static native void callobject(int p_id, String p_method, Object[] p_params);
+ public static native void callobject(long p_id, String p_method, Object[] p_params);
/**
* Invoke method |p_method| on the Godot object specified by |p_id| during idle time.
@@ -198,7 +198,7 @@ public class GodotLib {
* @param p_method Name of the method to invoke
* @param p_params Parameters to use for method invocation
*/
- public static native void calldeferred(int p_id, String p_method, Object[] p_params);
+ public static native void calldeferred(long p_id, String p_method, Object[] p_params);
/**
* Forward the results from a permission request.
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java
index 170c433c9c..27e63f3a66 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java
@@ -33,7 +33,6 @@ package org.godotengine.godot;
import android.view.SurfaceView;
public interface GodotRenderView {
-
abstract public SurfaceView getView();
abstract public void initInputDevices();
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java
index 39858e5fee..64395f7d1e 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java
@@ -44,7 +44,6 @@ import javax.microedition.khronos.opengles.GL10;
* Godot's renderer implementation.
*/
class GodotRenderer implements GLSurfaceView.Renderer {
-
private final GodotPluginRegistry pluginRegistry;
private boolean activityJustResumed = false;
@@ -65,7 +64,7 @@ class GodotRenderer implements GLSurfaceView.Renderer {
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
- GodotLib.resize(width, height);
+ GodotLib.resize(null, width, height);
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onGLSurfaceChanged(gl, width, height);
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java
index 3a36c512a2..e9872b58ff 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java
@@ -42,7 +42,6 @@ import android.view.MotionEvent;
import android.view.SurfaceView;
public class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderView {
-
private final Godot mActivity;
private final GodotInputHandler mInputHandler;
private final GestureDetector mGestureDetector;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java
index 547c093419..7f596575a8 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java
@@ -58,6 +58,7 @@ public class GodotEditText extends EditText {
private GodotTextInputWrapper mInputWrapper;
private EditHandler sHandler = new EditHandler(this);
private String mOriginText;
+ private int mMaxInputLength;
private static class EditHandler extends Handler {
private final WeakReference<GodotEditText> mEdit;
@@ -104,11 +105,18 @@ public class GodotEditText extends EditText {
String text = edit.mOriginText;
if (edit.requestFocus()) {
edit.removeTextChangedListener(edit.mInputWrapper);
+ setMaxInputLength(edit);
edit.setText("");
edit.append(text);
+ if (msg.arg2 != -1) {
+ edit.setSelection(msg.arg1, msg.arg2);
+ edit.mInputWrapper.setSelection(true);
+ } else {
+ edit.mInputWrapper.setSelection(false);
+ }
+
edit.mInputWrapper.setOriginText(text);
edit.addTextChangedListener(edit.mInputWrapper);
- setMaxInputLength(edit, msg.arg1);
final InputMethodManager imm = (InputMethodManager)mRenderView.getView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(edit, 0);
}
@@ -125,14 +133,10 @@ public class GodotEditText extends EditText {
}
}
- private void setMaxInputLength(EditText p_edit_text, int p_max_input_length) {
- if (p_max_input_length > 0) {
- InputFilter[] filters = new InputFilter[1];
- filters[0] = new InputFilter.LengthFilter(p_max_input_length);
- p_edit_text.setFilters(filters);
- } else {
- p_edit_text.setFilters(new InputFilter[] {});
- }
+ private void setMaxInputLength(EditText p_edit_text) {
+ InputFilter[] filters = new InputFilter[1];
+ filters[0] = new InputFilter.LengthFilter(this.mMaxInputLength);
+ p_edit_text.setFilters(filters);
}
// ===========================================================
@@ -164,13 +168,24 @@ public class GodotEditText extends EditText {
// ===========================================================
// Methods
// ===========================================================
- public void showKeyboard(String p_existing_text, int p_max_input_length) {
- mOriginText = p_existing_text;
+ public void showKeyboard(String p_existing_text, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
+ int maxInputLength = (p_max_input_length <= 0) ? Integer.MAX_VALUE : p_max_input_length;
+ if (p_cursor_start == -1) { // cursor position not given
+ this.mOriginText = p_existing_text;
+ this.mMaxInputLength = maxInputLength;
+ } else if (p_cursor_end == -1) { // not text selection
+ this.mOriginText = p_existing_text.substring(0, p_cursor_start);
+ this.mMaxInputLength = maxInputLength - (p_existing_text.length() - p_cursor_start);
+ } else {
+ this.mOriginText = p_existing_text.substring(0, p_cursor_end);
+ this.mMaxInputLength = maxInputLength - (p_existing_text.length() - p_cursor_end);
+ }
final Message msg = new Message();
msg.what = HANDLER_OPEN_IME_KEYBOARD;
msg.obj = this;
- msg.arg1 = p_max_input_length;
+ msg.arg1 = p_cursor_start;
+ msg.arg2 = p_cursor_end;
sHandler.sendMessage(msg);
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java
index 0ac82dbfe4..1c9a683bbd 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.java
@@ -42,7 +42,6 @@ import android.view.MotionEvent;
* https://developer.android.com/reference/android/view/GestureDetector.SimpleOnGestureListener
*/
public class GodotGestureHandler extends GestureDetector.SimpleOnGestureListener {
-
private final GodotRenderView mRenderView;
public GodotGestureHandler(GodotRenderView godotView) {
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
index cea58f27e6..9abd65cc67 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
@@ -51,7 +51,6 @@ import java.util.List;
* Handles input related events for the {@link GodotRenderView} view.
*/
public class GodotInputHandler implements InputDeviceListener {
-
private final ArrayList<Joystick> mJoysticksDevices = new ArrayList<Joystick>();
private final GodotRenderView mRenderView;
@@ -86,7 +85,6 @@ public class GodotInputHandler implements InputDeviceListener {
int source = event.getSource();
if (isKeyEvent_GameDevice(source)) {
-
final int button = getGodotButton(keyCode);
final int device_id = findJoystickDevice(event.getDeviceId());
@@ -129,7 +127,6 @@ public class GodotInputHandler implements InputDeviceListener {
//Log.e(TAG, String.format("Key down! source %d, device %d, joystick %d, %d, %d", event.getDeviceId(), source, (source & InputDevice.SOURCE_JOYSTICK), (source & InputDevice.SOURCE_DPAD), (source & InputDevice.SOURCE_GAMEPAD)));
if (isKeyEvent_GameDevice(source)) {
-
if (event.getRepeatCount() > 0) // ignore key echo
return true;
@@ -161,7 +158,6 @@ public class GodotInputHandler implements InputDeviceListener {
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK && event.getAction() == MotionEvent.ACTION_MOVE) {
-
final int device_id = findJoystickDevice(event.getDeviceId());
// Check if the device exists
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java
index 9cd08de529..9c7cf9f341 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -53,6 +53,7 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
private final GodotRenderView mRenderView;
private final GodotEditText mEdit;
private String mOriginText;
+ private boolean mHasSelection;
// ===========================================================
// Constructors
@@ -77,6 +78,10 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
mOriginText = originText;
}
+ public void setSelection(boolean selection) {
+ mHasSelection = selection;
+ }
+
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@@ -95,6 +100,11 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
for (int i = 0; i < count; ++i) {
GodotLib.key(KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_DEL, 0, true);
GodotLib.key(KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_DEL, 0, false);
+
+ if (mHasSelection) {
+ mHasSelection = false;
+ break;
+ }
}
}
});
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java
index 4042c42e9d..62810ad3a4 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java
@@ -120,7 +120,6 @@ public interface InputManagerCompat {
* Use this to construct a compatible InputManager.
*/
public static class Factory {
-
/**
* Constructs and returns a compatible InputManger
*
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java
index 3b88609cc9..61828dccae 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java
@@ -29,7 +29,6 @@ import java.util.Map;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class InputManagerV16 implements InputManagerCompat {
-
private final InputManager mInputManager;
private final Map<InputManagerCompat.InputDeviceListener, V16InputDeviceListener> mListeners;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java
index a42bcb28ce..ce85880fa3 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java
@@ -35,13 +35,14 @@ import org.godotengine.godot.Godot;
import android.app.Activity;
import android.content.Intent;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
+import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@@ -76,7 +77,6 @@ import javax.microedition.khronos.opengles.GL10;
* 'godot/plugin/v1/[PluginName]/'
*/
public abstract class GodotPlugin {
-
private static final String TAG = GodotPlugin.class.getSimpleName();
private final Godot godot;
@@ -94,6 +94,14 @@ public abstract class GodotPlugin {
}
/**
+ * Provides access to the underlying {@link Activity}.
+ */
+ @Nullable
+ protected Activity getActivity() {
+ return godot;
+ }
+
+ /**
* Register the plugin with Godot native code.
*
* This method is invoked on the render thread.
@@ -146,13 +154,14 @@ public abstract class GodotPlugin {
* Invoked once during the Godot Android initialization process after creation of the
* {@link org.godotengine.godot.GodotView} view.
* <p>
- * This method should be overridden by descendants of this class that would like to add
- * their view/layout to the Godot view hierarchy.
+ * The plugin can return a non-null {@link View} layout in order to add it to the Godot view
+ * hierarchy.
*
- * @return the view to be included; null if no views should be included.
+ * @see Activity#onCreate(Bundle)
+ * @return the plugin's view to be included; null if no views should be included.
*/
@Nullable
- public View onMainCreateView(Activity activity) {
+ public View onMainCreate(Activity activity) {
return null;
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
index 7bc8f2c03f..12d2ed09fb 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java
@@ -35,13 +35,13 @@ import org.godotengine.godot.Godot;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
+import androidx.annotation.Nullable;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -51,7 +51,6 @@ import java.util.concurrent.ConcurrentHashMap;
* Registry used to load and access the registered Godot Android plugins.
*/
public final class GodotPluginRegistry {
-
private static final String TAG = GodotPluginRegistry.class.getSimpleName();
private static final String GODOT_PLUGIN_V1_NAME_PREFIX = "org.godotengine.plugin.v1.";
@@ -59,7 +58,9 @@ public final class GodotPluginRegistry {
/**
* Name for the metadata containing the list of Godot plugins to enable.
*/
- private static final String GODOT_ENABLED_PLUGINS_LABEL = "custom_template_plugins";
+ private static final String GODOT_ENABLED_PLUGINS_LABEL = "plugins";
+
+ private static final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|";
private static GodotPluginRegistry instance;
private final ConcurrentHashMap<String, GodotPlugin> registry;
@@ -129,13 +130,13 @@ public final class GodotPluginRegistry {
}
// When using the Godot editor for building and exporting the apk, this is used to check
- // which plugins to enable since the custom build template may contain prebuilt plugins.
+ // which plugins to enable.
// When using a custom process to generate the apk, the metadata is not needed since
// it's assumed that the developer is aware of the dependencies included in the apk.
final Set<String> enabledPluginsSet;
if (metaData.containsKey(GODOT_ENABLED_PLUGINS_LABEL)) {
String enabledPlugins = metaData.getString(GODOT_ENABLED_PLUGINS_LABEL, "");
- String[] enabledPluginsList = enabledPlugins.split(",");
+ String[] enabledPluginsList = enabledPlugins.split(PLUGIN_VALUE_SEPARATOR_REGEX);
if (enabledPluginsList.length == 0) {
// No plugins to enable. Aborting early.
return;
@@ -159,6 +160,8 @@ public final class GodotPluginRegistry {
continue;
}
+ Log.i(TAG, "Initializing Godot plugin " + pluginName);
+
// Retrieve the plugin class full name.
String pluginHandleClassFullName = metaData.getString(metaDataName);
if (!TextUtils.isEmpty(pluginHandleClassFullName)) {
@@ -178,6 +181,7 @@ public final class GodotPluginRegistry {
"Meta-data plugin name does not match the value returned by the plugin handle: " + pluginName + " =/= " + pluginHandle.getPluginName());
}
registry.put(pluginName, pluginHandle);
+ Log.i(TAG, "Completed initialization for Godot plugin " + pluginHandle.getPluginName());
} catch (ClassNotFoundException e) {
Log.w(TAG, "Unable to load Godot plugin " + pluginName, e);
} catch (IllegalAccessException e) {
diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/SignalInfo.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/SignalInfo.java
index 424251169b..f82c4d3fa0 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/plugin/SignalInfo.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/SignalInfo.java
@@ -30,16 +30,16 @@
package org.godotengine.godot.plugin;
-import android.support.annotation.NonNull;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import java.util.Arrays;
/**
* Store information about a {@link GodotPlugin}'s signal.
*/
public final class SignalInfo {
-
private final String name;
private final Class<?>[] paramTypes;
private final String[] paramTypesNames;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java
index bc0e565774..acc9c4981b 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java
@@ -34,7 +34,6 @@ import java.security.MessageDigest;
import java.util.Random;
public class Crypt {
-
public static String md5(String input) {
try {
// Create MD5 Hash
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
index 291847723c..82420eda79 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java
@@ -40,7 +40,6 @@ import javax.microedition.khronos.egl.EGLDisplay;
* Contains GL utilities methods.
*/
public class GLUtils {
-
private static final String TAG = GLUtils.class.getSimpleName();
public static final boolean DEBUG = false;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java
index bb1667afda..0832a9b965 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java
@@ -42,7 +42,6 @@ import android.util.Log;
* to receive broadcast and multicast packets.
*/
public class GodotNetUtils {
-
/* A single, reference counted, multicast lock, or null if permission CHANGE_WIFI_MULTICAST_STATE is missing */
private WifiManager.MulticastLock multicastLock;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
index 4000e63fbe..6837e4f147 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
@@ -37,9 +37,10 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Build;
-import android.support.v4.content.ContextCompat;
import android.util.Log;
+import androidx.core.content.ContextCompat;
+
import java.util.ArrayList;
import java.util.List;
@@ -48,7 +49,6 @@ import java.util.List;
* @author Cagdas Caglak <cagdascaglak@gmail.com>
*/
public final class PermissionsUtil {
-
private static final String TAG = PermissionsUtil.class.getSimpleName();
static final int REQUEST_RECORD_AUDIO_PERMISSION = 1;
diff --git a/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt b/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt
index 608ad48df9..aeb4628d5d 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/vulkan/VkRenderer.kt
@@ -59,9 +59,7 @@ internal class VkRenderer {
* Called when the surface is created and signals the beginning of rendering.
*/
fun onVkSurfaceCreated(surface: Surface) {
- // TODO: properly implement surface re-creation:
- // GodotLib.newcontext should be called here once it's done.
- //GodotLib.newcontext(surface, false)
+ GodotLib.newcontext(surface, false)
for (plugin in pluginRegistry.getAllPlugins()) {
plugin.onVkSurfaceCreated(surface)
@@ -72,12 +70,7 @@ internal class VkRenderer {
* Called after the surface is created and whenever its size changes.
*/
fun onVkSurfaceChanged(surface: Surface, width: Int, height: Int) {
- GodotLib.resize(width, height)
-
- // TODO: properly implement surface re-creation:
- // Update the native renderer instead of restarting the app.
- // GodotLib.newcontext should not be called here once it's done.
- GodotLib.newcontext(surface, false)
+ GodotLib.resize(surface, width, height)
for (plugin in pluginRegistry.getAllPlugins()) {
plugin.onVkSurfaceChanged(surface, width, height)
diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrConfigChooser.java b/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrConfigChooser.java
index c66d75bb2d..819bcccdf1 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrConfigChooser.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrConfigChooser.java
@@ -41,7 +41,6 @@ import javax.microedition.khronos.egl.EGLDisplay;
* EGL config chooser for the Oculus Mobile VR SDK.
*/
public class OvrConfigChooser implements GLSurfaceView.EGLConfigChooser {
-
private static final int[] CONFIG_ATTRIBS = {
EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8,
diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrContextFactory.java b/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrContextFactory.java
index 16d4a998f2..2d9b921466 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrContextFactory.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrContextFactory.java
@@ -42,7 +42,6 @@ import javax.microedition.khronos.egl.EGLDisplay;
* EGL Context factory for the Oculus mobile VR SDK.
*/
public class OvrContextFactory implements GLSurfaceView.EGLContextFactory {
-
private static final int[] CONTEXT_ATTRIBS = {
EGL14.EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE
};
diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrWindowSurfaceFactory.java b/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrWindowSurfaceFactory.java
index 7ca0777f11..43c7f0f966 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrWindowSurfaceFactory.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/xr/ovr/OvrWindowSurfaceFactory.java
@@ -41,7 +41,6 @@ import javax.microedition.khronos.egl.EGLSurface;
* EGL window surface factory for the Oculus mobile VR SDK.
*/
public class OvrWindowSurfaceFactory implements GLSurfaceView.EGLWindowSurfaceFactory {
-
private final static int[] SURFACE_ATTRIBS = {
EGL10.EGL_WIDTH, 16,
EGL10.EGL_HEIGHT, 16,
diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularConfigChooser.java b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularConfigChooser.java
index 924d12f0bc..54672db282 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularConfigChooser.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularConfigChooser.java
@@ -42,7 +42,6 @@ import javax.microedition.khronos.egl.EGLDisplay;
* Used to select the egl config for pancake games.
*/
public class RegularConfigChooser implements GLSurfaceView.EGLConfigChooser {
-
private static final String TAG = RegularConfigChooser.class.getSimpleName();
private int[] mValue = new int[1];
@@ -74,7 +73,6 @@ public class RegularConfigChooser implements GLSurfaceView.EGLConfigChooser {
}
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
-
/* Get the number of minimally matching EGL configurations
*/
int[] num_config = new int[1];
@@ -129,7 +127,6 @@ public class RegularConfigChooser implements GLSurfaceView.EGLConfigChooser {
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
EGLConfig config, int attribute, int defaultValue) {
-
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0];
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java
index 64bc4ac1da..c83c47bed7 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularFallbackConfigChooser.java
@@ -40,7 +40,6 @@ import javax.microedition.khronos.egl.EGLDisplay;
/* Fallback if 32bit View is not supported*/
public class RegularFallbackConfigChooser extends RegularConfigChooser {
-
private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName();
private RegularConfigChooser fallback;
diff --git a/platform/android/java/plugins/godotpayment/build.gradle b/platform/android/java/plugins/godotpayment/build.gradle
index ffab86e26e..fb3aa8bba2 100644
--- a/platform/android/java/plugins/godotpayment/build.gradle
+++ b/platform/android/java/plugins/godotpayment/build.gradle
@@ -3,7 +3,6 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools
- useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion versions.minSdk
@@ -21,6 +20,7 @@ android {
dependencies {
implementation libraries.supportCoreUtils
implementation libraries.v4Support
+ implementation 'com.android.billingclient:billing:2.2.1'
if (rootProject.findProject(":lib")) {
compileOnly project(":lib")
diff --git a/platform/android/java/plugins/godotpayment/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl b/platform/android/java/plugins/godotpayment/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl
deleted file mode 100644
index 0f2bcae338..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.vending.billing;
-
-import android.os.Bundle;
-
-/**
- * InAppBillingService is the service that provides in-app billing version 3 and beyond.
- * This service provides the following features:
- * 1. Provides a new API to get details of in-app items published for the app including
- * price, type, title and description.
- * 2. The purchase flow is synchronous and purchase information is available immediately
- * after it completes.
- * 3. Purchase information of in-app purchases is maintained within the Google Play system
- * till the purchase is consumed.
- * 4. An API to consume a purchase of an inapp item. All purchases of one-time
- * in-app items are consumable and thereafter can be purchased again.
- * 5. An API to get current purchases of the user immediately. This will not contain any
- * consumed purchases.
- *
- * All calls will give a response code with the following possible values
- * RESULT_OK = 0 - success
- * RESULT_USER_CANCELED = 1 - User pressed back or canceled a dialog
- * RESULT_SERVICE_UNAVAILABLE = 2 - The network connection is down
- * RESULT_BILLING_UNAVAILABLE = 3 - This billing API version is not supported for the type requested
- * RESULT_ITEM_UNAVAILABLE = 4 - Requested SKU is not available for purchase
- * RESULT_DEVELOPER_ERROR = 5 - Invalid arguments provided to the API
- * RESULT_ERROR = 6 - Fatal error during the API action
- * RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned
- * RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned
- */
-interface IInAppBillingService {
- /**
- * Checks support for the requested billing API version, package and in-app type.
- * Minimum API version supported by this interface is 3.
- * @param apiVersion billing API version that the app is using
- * @param packageName the package name of the calling app
- * @param type type of the in-app item being purchased ("inapp" for one-time purchases
- * and "subs" for subscriptions)
- * @return RESULT_OK(0) on success and appropriate response code on failures.
- */
- int isBillingSupported(int apiVersion, String packageName, String type);
-
- /**
- * Provides details of a list of SKUs
- * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
- * with a list JSON strings containing the productId, price, title and description.
- * This API can be called with a maximum of 20 SKUs.
- * @param apiVersion billing API version that the app is using
- * @param packageName the package name of the calling app
- * @param type of the in-app items ("inapp" for one-time purchases
- * and "subs" for subscriptions)
- * @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
- * on failures.
- * "DETAILS_LIST" with a StringArrayList containing purchase information
- * in JSON format similar to:
- * '{ "productId" : "exampleSku",
- * "type" : "inapp",
- * "price" : "$5.00",
- * "price_currency": "USD",
- * "price_amount_micros": 5000000,
- * "title : "Example Title",
- * "description" : "This is an example description" }'
- */
- Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
-
- /**
- * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,
- * the type, a unique purchase token and an optional developer payload.
- * @param apiVersion billing API version that the app is using
- * @param packageName package name of the calling app
- * @param sku the SKU of the in-app item as published in the developer console
- * @param type of the in-app item being purchased ("inapp" for one-time purchases
- * and "subs" for subscriptions)
- * @param developerPayload optional argument to be sent back with the purchase information
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
- * on failures.
- * "BUY_INTENT" - PendingIntent to start the purchase flow
- *
- * The Pending intent should be launched with startIntentSenderForResult. When purchase flow
- * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
- * If the purchase is successful, the result data will contain the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response
- * codes on failures.
- * "INAPP_PURCHASE_DATA" - String in JSON format similar to
- * '{"orderId":"12999763169054705758.1371079406387615",
- * "packageName":"com.example.app",
- * "productId":"exampleSku",
- * "purchaseTime":1345678900000,
- * "purchaseToken" : "122333444455555",
- * "developerPayload":"example developer payload" }'
- * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
- * was signed with the private key of the developer
- */
- Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,
- String developerPayload);
-
- /**
- * Returns the current SKUs owned by the user of the type and package name specified along with
- * purchase information and a signature of the data to be validated.
- * This will return all SKUs that have been purchased in V3 and managed items purchased using
- * V1 and V2 that have not been consumed.
- * @param apiVersion billing API version that the app is using
- * @param packageName package name of the calling app
- * @param type of the in-app items being requested ("inapp" for one-time purchases
- * and "subs" for subscriptions)
- * @param continuationToken to be set as null for the first call, if the number of owned
- * skus are too many, a continuationToken is returned in the response bundle.
- * This method can be called again with the continuation token to get the next set of
- * owned skus.
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
- on failures.
- * "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs
- * "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information
- * "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures
- * of the purchase information
- * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
- * next set of in-app purchases. Only set if the
- * user has more owned skus than the current list.
- */
- Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);
-
- /**
- * Consume the last purchase of the given SKU. This will result in this item being removed
- * from all subsequent responses to getPurchases() and allow re-purchase of this item.
- * @param apiVersion billing API version that the app is using
- * @param packageName package name of the calling app
- * @param purchaseToken token in the purchase information JSON that identifies the purchase
- * to be consumed
- * @return RESULT_OK(0) if consumption succeeded, appropriate response codes on failures.
- */
- int consumePurchase(int apiVersion, String packageName, String purchaseToken);
-
- /**
- * This API is currently under development.
- */
- int stub(int apiVersion, String packageName, String type);
-
- /**
- * Returns a pending intent to launch the purchase flow for upgrading or downgrading a
- * subscription. The existing owned SKU(s) should be provided along with the new SKU that
- * the user is upgrading or downgrading to.
- * @param apiVersion billing API version that the app is using, must be 5 or later
- * @param packageName package name of the calling app
- * @param oldSkus the SKU(s) that the user is upgrading or downgrading from,
- * if null or empty this method will behave like {@link #getBuyIntent}
- * @param newSku the SKU that the user is upgrading or downgrading to
- * @param type of the item being purchased, currently must be "subs"
- * @param developerPayload optional argument to be sent back with the purchase information
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
- * on failures.
- * "BUY_INTENT" - PendingIntent to start the purchase flow
- *
- * The Pending intent should be launched with startIntentSenderForResult. When purchase flow
- * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
- * If the purchase is successful, the result data will contain the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response
- * codes on failures.
- * "INAPP_PURCHASE_DATA" - String in JSON format similar to
- * '{"orderId":"12999763169054705758.1371079406387615",
- * "packageName":"com.example.app",
- * "productId":"exampleSku",
- * "purchaseTime":1345678900000,
- * "purchaseToken" : "122333444455555",
- * "developerPayload":"example developer payload" }'
- * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
- * was signed with the private key of the developer
- */
- Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName,
- in List<String> oldSkus, String newSku, String type, String developerPayload);
-
- /**
- * Returns a pending intent to launch the purchase flow for an in-app item. This method is
- * a variant of the {@link #getBuyIntent} method and takes an additional {@code extraParams}
- * parameter. This parameter is a Bundle of optional keys and values that affect the
- * operation of the method.
- * @param apiVersion billing API version that the app is using, must be 6 or later
- * @param packageName package name of the calling app
- * @param sku the SKU of the in-app item as published in the developer console
- * @param type of the in-app item being purchased ("inapp" for one-time purchases
- * and "subs" for subscriptions)
- * @param developerPayload optional argument to be sent back with the purchase information
- * @extraParams a Bundle with the following optional keys:
- * "skusToReplace" - List<String> - an optional list of SKUs that the user is
- * upgrading or downgrading from.
- * Pass this field if the purchase is upgrading or downgrading
- * existing subscriptions.
- * The specified SKUs are replaced with the SKUs that the user is
- * purchasing. Google Play replaces the specified SKUs at the start of
- * the next billing cycle.
- * "replaceSkusProration" - Boolean - whether the user should be credited for any unused
- * subscription time on the SKUs they are upgrading or downgrading.
- * If you set this field to true, Google Play swaps out the old SKUs
- * and credits the user with the unused value of their subscription
- * time on a pro-rated basis.
- * Google Play applies this credit to the new subscription, and does
- * not begin billing the user for the new subscription until after
- * the credit is used up.
- * If you set this field to false, the user does not receive credit for
- * any unused subscription time and the recurrence date does not
- * change.
- * Default value is true. Ignored if you do not pass skusToReplace.
- * "accountId" - String - an optional obfuscated string that is uniquely
- * associated with the user's account in your app.
- * If you pass this value, Google Play can use it to detect irregular
- * activity, such as many devices making purchases on the same
- * account in a short period of time.
- * Do not use the developer ID or the user's Google ID for this field.
- * In addition, this field should not contain the user's ID in
- * cleartext.
- * We recommend that you use a one-way hash to generate a string from
- * the user's ID, and store the hashed string in this field.
- * "vr" - Boolean - an optional flag indicating whether the returned intent
- * should start a VR purchase flow. The apiVersion must also be 7 or
- * later to use this flag.
- */
- Bundle getBuyIntentExtraParams(int apiVersion, String packageName, String sku,
- String type, String developerPayload, in Bundle extraParams);
-
- /**
- * Returns the most recent purchase made by the user for each SKU, even if that purchase is
- * expired, canceled, or consumed.
- * @param apiVersion billing API version that the app is using, must be 6 or later
- * @param packageName package name of the calling app
- * @param type of the in-app items being requested ("inapp" for one-time purchases
- * and "subs" for subscriptions)
- * @param continuationToken to be set as null for the first call, if the number of owned
- * skus is too large, a continuationToken is returned in the response bundle.
- * This method can be called again with the continuation token to get the next set of
- * owned skus.
- * @param extraParams a Bundle with extra params that would be appended into http request
- * query string. Not used at this moment. Reserved for future functionality.
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value: RESULT_OK(0) if success,
- * {@link IabHelper#BILLING_RESPONSE_RESULT_*} response codes on failures.
- *
- * "INAPP_PURCHASE_ITEM_LIST" - ArrayList<String> containing the list of SKUs
- * "INAPP_PURCHASE_DATA_LIST" - ArrayList<String> containing the purchase information
- * "INAPP_DATA_SIGNATURE_LIST"- ArrayList<String> containing the signatures
- * of the purchase information
- * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
- * next set of in-app purchases. Only set if the
- * user has more owned skus than the current list.
- */
- Bundle getPurchaseHistory(int apiVersion, String packageName, String type,
- String continuationToken, in Bundle extraParams);
-
- /**
- * This method is a variant of {@link #isBillingSupported}} that takes an additional
- * {@code extraParams} parameter.
- * @param apiVersion billing API version that the app is using, must be 7 or later
- * @param packageName package name of the calling app
- * @param type of the in-app item being purchased ("inapp" for one-time purchases and "subs"
- * for subscriptions)
- * @param extraParams a Bundle with the following optional keys:
- * "vr" - Boolean - an optional flag to indicate whether {link #getBuyIntentExtraParams}
- * supports returning a VR purchase flow.
- * @return RESULT_OK(0) on success and appropriate response code on failures.
- */
- int isBillingSupportedExtraParams(int apiVersion, String packageName, String type,
- in Bundle extraParams);
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ConsumeTask.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ConsumeTask.java
deleted file mode 100644
index 31c72fe7f8..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ConsumeTask.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************/
-/* ConsumeTask.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import android.content.Context;
-import android.os.AsyncTask;
-import android.os.RemoteException;
-
-import com.android.vending.billing.IInAppBillingService;
-
-import java.lang.ref.WeakReference;
-
-abstract public class ConsumeTask {
-
- private Context context;
- private IInAppBillingService mService;
-
- private String mSku;
- private String mToken;
-
- private static class ConsumeAsyncTask extends AsyncTask<String, String, String> {
-
- private WeakReference<ConsumeTask> mTask;
-
- ConsumeAsyncTask(ConsumeTask consume) {
- mTask = new WeakReference<>(consume);
- }
-
- @Override
- protected String doInBackground(String... strings) {
- ConsumeTask consume = mTask.get();
- if (consume != null) {
- return consume.doInBackground(strings);
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(String param) {
- ConsumeTask consume = mTask.get();
- if (consume != null) {
- consume.onPostExecute(param);
- }
- }
- }
-
- public ConsumeTask(IInAppBillingService mService, Context context) {
- this.context = context;
- this.mService = mService;
- }
-
- public void consume(final String sku) {
- mSku = sku;
- PaymentsCache pc = new PaymentsCache(context);
- Boolean isBlocked = pc.getConsumableFlag("block", sku);
- mToken = pc.getConsumableValue("token", sku);
- if (!isBlocked && mToken == null) {
- // Consuming task is processing
- } else if (!isBlocked) {
- return;
- } else if (mToken == null) {
- this.error("No token for sku:" + sku);
- return;
- }
- new ConsumeAsyncTask(this).execute();
- }
-
- private String doInBackground(String... params) {
- try {
- int response = mService.consumePurchase(3, context.getPackageName(), mToken);
- if (response == 0 || response == 8) {
- return null;
- }
- } catch (RemoteException e) {
- return e.getMessage();
- }
- return "Some error";
- }
-
- private void onPostExecute(String param) {
- if (param == null) {
- success(new PaymentsCache(context).getConsumableValue("ticket", mSku));
- } else {
- error(param);
- }
- }
-
- abstract protected void success(String ticket);
- abstract protected void error(String message);
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java
index 08ade2a18d..bf8e485d96 100644
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java
+++ b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/GodotPayment.java
@@ -32,214 +32,177 @@ package org.godotengine.godot.plugin.payment;
import org.godotengine.godot.Dictionary;
import org.godotengine.godot.Godot;
-import org.godotengine.godot.GodotLib;
import org.godotengine.godot.plugin.GodotPlugin;
+import org.godotengine.godot.plugin.SignalInfo;
+import org.godotengine.godot.plugin.payment.utils.GodotPaymentUtils;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.collection.ArraySet;
+
+import com.android.billingclient.api.AcknowledgePurchaseParams;
+import com.android.billingclient.api.AcknowledgePurchaseResponseListener;
+import com.android.billingclient.api.BillingClient;
+import com.android.billingclient.api.BillingClientStateListener;
+import com.android.billingclient.api.BillingFlowParams;
+import com.android.billingclient.api.BillingResult;
+import com.android.billingclient.api.ConsumeParams;
+import com.android.billingclient.api.ConsumeResponseListener;
+import com.android.billingclient.api.Purchase;
+import com.android.billingclient.api.PurchasesUpdatedListener;
+import com.android.billingclient.api.SkuDetails;
+import com.android.billingclient.api.SkuDetailsParams;
+import com.android.billingclient.api.SkuDetailsResponseListener;
-import android.content.Intent;
-import android.support.annotation.NonNull;
-import android.util.Log;
-
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Set;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class GodotPayment extends GodotPlugin {
-
- private Integer purchaseCallbackId = 0;
- private String accessToken;
- private String purchaseValidationUrlPrefix;
- private String transactionId;
- private final PaymentsManager mPaymentManager;
- private final Dictionary mSkuDetails = new Dictionary();
+public class GodotPayment extends GodotPlugin implements PurchasesUpdatedListener, BillingClientStateListener {
+ private final BillingClient billingClient;
+ private final HashMap<String, SkuDetails> skuDetailsCache = new HashMap<>(); // sku → SkuDetails
public GodotPayment(Godot godot) {
super(godot);
- mPaymentManager = new PaymentsManager(godot, this);
- mPaymentManager.initService();
- }
-
- @Override
- public void onMainActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE) {
- mPaymentManager.processPurchaseResponse(resultCode, data);
- }
- }
-
- @Override
- public void onMainDestroy() {
- super.onMainDestroy();
- if (mPaymentManager != null) {
- mPaymentManager.destroy();
- }
- }
-
- public void purchase(final String sku, final String transactionId) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mPaymentManager.requestPurchase(sku, transactionId);
- }
- });
- }
- public void consumeUnconsumedPurchases() {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mPaymentManager.consumeUnconsumedPurchases();
- }
- });
+ billingClient = BillingClient
+ .newBuilder(getActivity())
+ .enablePendingPurchases()
+ .setListener(this)
+ .build();
}
- private String signature;
-
- public String getSignature() {
- return this.signature;
+ public void startConnection() {
+ billingClient.startConnection(this);
}
- public void callbackSuccess(String ticket, String signature, String sku) {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_success", new Object[] { ticket, signature, sku });
+ public void endConnection() {
+ billingClient.endConnection();
}
- public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku) {
- Log.d(this.getClass().getName(), "callbackSuccessProductMassConsumed > " + ticket + "," + signature + "," + sku);
- GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[] { ticket, signature, sku });
+ public boolean isReady() {
+ return this.billingClient.isReady();
}
- public void callbackSuccessNoUnconsumedPurchases() {
- GodotLib.calldeferred(purchaseCallbackId, "consume_not_required", new Object[] {});
- }
-
- public void callbackFailConsume(String message) {
- GodotLib.calldeferred(purchaseCallbackId, "consume_fail", new Object[] { message });
- }
-
- public void callbackFail(String message) {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[] { message });
- }
+ public Dictionary queryPurchases(String type) {
+ Purchase.PurchasesResult result = billingClient.queryPurchases(type);
- public void callbackCancel() {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_cancel", new Object[] {});
- }
-
- public void callbackAlreadyOwned(String sku) {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[] { sku });
- }
-
- public int getPurchaseCallbackId() {
- return purchaseCallbackId;
- }
-
- public void setPurchaseCallbackId(int purchaseCallbackId) {
- this.purchaseCallbackId = purchaseCallbackId;
- }
+ Dictionary returnValue = new Dictionary();
+ if (result.getBillingResult().getResponseCode() == BillingClient.BillingResponseCode.OK) {
+ returnValue.put("status", 0); // OK = 0
+ returnValue.put("purchases", GodotPaymentUtils.convertPurchaseListToDictionaryObjectArray(result.getPurchasesList()));
+ } else {
+ returnValue.put("status", 1); // FAILED = 1
+ returnValue.put("response_code", result.getBillingResult().getResponseCode());
+ returnValue.put("debug_message", result.getBillingResult().getDebugMessage());
+ }
- public String getPurchaseValidationUrlPrefix() {
- return this.purchaseValidationUrlPrefix;
+ return returnValue;
}
- public void setPurchaseValidationUrlPrefix(String url) {
- this.purchaseValidationUrlPrefix = url;
- }
+ public void querySkuDetails(final String[] list, String type) {
+ List<String> skuList = Arrays.asList(list);
- public String getAccessToken() {
- return accessToken;
- }
+ SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder()
+ .setSkusList(skuList)
+ .setType(type);
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
+ billingClient.querySkuDetailsAsync(params.build(), new SkuDetailsResponseListener() {
+ @Override
+ public void onSkuDetailsResponse(BillingResult billingResult,
+ List<SkuDetails> skuDetailsList) {
+ if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
+ for (SkuDetails skuDetails : skuDetailsList) {
+ skuDetailsCache.put(skuDetails.getSku(), skuDetails);
+ }
+ emitSignal("sku_details_query_completed", (Object)GodotPaymentUtils.convertSkuDetailsListToDictionaryObjectArray(skuDetailsList));
+ } else {
+ emitSignal("sku_details_query_error", billingResult.getResponseCode(), billingResult.getDebugMessage(), list);
+ }
+ }
+ });
}
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
+ public void acknowledgePurchase(final String purchaseToken) {
+ AcknowledgePurchaseParams acknowledgePurchaseParams =
+ AcknowledgePurchaseParams.newBuilder()
+ .setPurchaseToken(purchaseToken)
+ .build();
+ billingClient.acknowledgePurchase(acknowledgePurchaseParams, new AcknowledgePurchaseResponseListener() {
+ @Override
+ public void onAcknowledgePurchaseResponse(BillingResult billingResult) {
+ if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
+ emitSignal("purchase_acknowledged", purchaseToken);
+ } else {
+ emitSignal("purchase_acknowledgement_error", billingResult.getResponseCode(), billingResult.getDebugMessage(), purchaseToken);
+ }
+ }
+ });
}
- public String getTransactionId() {
- return this.transactionId;
- }
+ public void consumePurchase(String purchaseToken) {
+ ConsumeParams consumeParams = ConsumeParams.newBuilder()
+ .setPurchaseToken(purchaseToken)
+ .build();
- // request purchased items are not consumed
- public void requestPurchased() {
- runOnUiThread(new Runnable() {
+ billingClient.consumeAsync(consumeParams, new ConsumeResponseListener() {
@Override
- public void run() {
- mPaymentManager.requestPurchased();
+ public void onConsumeResponse(BillingResult billingResult, String purchaseToken) {
+ if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
+ emitSignal("purchase_consumed", purchaseToken);
+ } else {
+ emitSignal("purchase_consumption_error", billingResult.getResponseCode(), billingResult.getDebugMessage(), purchaseToken);
+ }
}
});
}
- // callback for requestPurchased()
- public void callbackPurchased(String receipt, String signature, String sku) {
- GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[] { receipt, signature, sku });
- }
-
- public void callbackDisconnected() {
- GodotLib.calldeferred(purchaseCallbackId, "iap_disconnected", new Object[] {});
+ @Override
+ public void onBillingSetupFinished(BillingResult billingResult) {
+ if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
+ emitSignal("connected");
+ } else {
+ emitSignal("connect_error", billingResult.getResponseCode(), billingResult.getDebugMessage());
+ }
}
- public void callbackConnected() {
- GodotLib.calldeferred(purchaseCallbackId, "iap_connected", new Object[] {});
+ @Override
+ public void onBillingServiceDisconnected() {
+ emitSignal("disconnected");
}
- // true if connected, false otherwise
- public boolean isConnected() {
- return mPaymentManager.isConnected();
- }
+ public Dictionary purchase(String sku) {
+ if (!skuDetailsCache.containsKey(sku)) {
+ emitSignal("purchase_error", null, "You must query the sku details and wait for the result before purchasing!");
+ }
- // consume item automatically after purchase. default is true.
- public void setAutoConsume(boolean autoConsume) {
- mPaymentManager.setAutoConsume(autoConsume);
- }
+ SkuDetails skuDetails = skuDetailsCache.get(sku);
+ BillingFlowParams purchaseParams = BillingFlowParams.newBuilder()
+ .setSkuDetails(skuDetails)
+ .build();
- // consume a specific item
- public void consume(String sku) {
- mPaymentManager.consume(sku);
- }
+ BillingResult result = billingClient.launchBillingFlow(getActivity(), purchaseParams);
- // query in app item detail info
- public void querySkuDetails(String[] list) {
- List<String> nKeys = Arrays.asList(list);
- List<String> cKeys = Arrays.asList(mSkuDetails.get_keys());
- ArrayList<String> fKeys = new ArrayList<String>();
- for (String key : nKeys) {
- if (!cKeys.contains(key)) {
- fKeys.add(key);
- }
- }
- if (fKeys.size() > 0) {
- mPaymentManager.querySkuDetails(fKeys.toArray(new String[0]));
+ Dictionary returnValue = new Dictionary();
+ if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) {
+ returnValue.put("status", 0); // OK = 0
} else {
- completeSkuDetail();
- }
- }
-
- public void addSkuDetail(String itemJson) {
- JSONObject o = null;
- try {
- o = new JSONObject(itemJson);
- Dictionary item = new Dictionary();
- item.put("type", o.optString("type"));
- item.put("product_id", o.optString("productId"));
- item.put("title", o.optString("title"));
- item.put("description", o.optString("description"));
- item.put("price", o.optString("price"));
- item.put("price_currency_code", o.optString("price_currency_code"));
- item.put("price_amount", 0.000001d * o.optLong("price_amount_micros"));
- mSkuDetails.put(item.get("product_id").toString(), item);
- } catch (JSONException e) {
- e.printStackTrace();
+ returnValue.put("status", 1); // FAILED = 1
+ returnValue.put("response_code", result.getResponseCode());
+ returnValue.put("debug_message", result.getDebugMessage());
}
- }
- public void completeSkuDetail() {
- GodotLib.calldeferred(purchaseCallbackId, "sku_details_complete", new Object[] { mSkuDetails });
+ return returnValue;
}
- public void errorSkuDetail(String errorMessage) {
- GodotLib.calldeferred(purchaseCallbackId, "sku_details_error", new Object[] { errorMessage });
+ @Override
+ public void onPurchasesUpdated(final BillingResult billingResult, @Nullable final List<Purchase> list) {
+ if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null) {
+ emitSignal("purchases_updated", (Object)GodotPaymentUtils.convertPurchaseListToDictionaryObjectArray(list));
+ } else {
+ emitSignal("purchase_error", billingResult.getResponseCode(), billingResult.getDebugMessage());
+ }
}
@NonNull
@@ -251,8 +214,26 @@ public class GodotPayment extends GodotPlugin {
@NonNull
@Override
public List<String> getPluginMethods() {
- return Arrays.asList("purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix",
- "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased",
- "setAutoConsume", "consume", "querySkuDetails", "isConnected");
+ return Arrays.asList("startConnection", "endConnection", "purchase", "querySkuDetails", "isReady", "queryPurchases", "acknowledgePurchase", "consumePurchase");
+ }
+
+ @NonNull
+ @Override
+ public Set<SignalInfo> getPluginSignals() {
+ Set<SignalInfo> signals = new ArraySet<>();
+
+ signals.add(new SignalInfo("connected"));
+ signals.add(new SignalInfo("disconnected"));
+ signals.add(new SignalInfo("connect_error", Integer.class, String.class));
+ signals.add(new SignalInfo("purchases_updated", Object[].class));
+ signals.add(new SignalInfo("purchase_error", Integer.class, String.class));
+ signals.add(new SignalInfo("sku_details_query_completed", Object[].class));
+ signals.add(new SignalInfo("sku_details_query_error", Integer.class, String.class, String[].class));
+ signals.add(new SignalInfo("purchase_acknowledged", String.class));
+ signals.add(new SignalInfo("purchase_acknowledgement_error", Integer.class, String.class, String.class));
+ signals.add(new SignalInfo("purchase_consumed", String.class));
+ signals.add(new SignalInfo("purchase_consumption_error", Integer.class, String.class, String.class));
+
+ return signals;
}
}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/HandlePurchaseTask.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/HandlePurchaseTask.java
deleted file mode 100644
index 70a51fcb97..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/HandlePurchaseTask.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*************************************************************************/
-/* HandlePurchaseTask.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import android.app.Activity;
-import android.content.Intent;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-abstract public class HandlePurchaseTask {
-
- private Activity context;
-
- public HandlePurchaseTask(Activity context) {
- this.context = context;
- }
-
- public void handlePurchaseRequest(int resultCode, Intent data) {
- //Log.d("XXX", "Handling purchase response");
- if (resultCode == Activity.RESULT_OK) {
- try {
- //int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
- PaymentsCache pc = new PaymentsCache(context);
-
- String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
- //Log.d("XXX", "Purchase data:" + purchaseData);
- String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
- //Log.d("XXX", "Purchase signature:" + dataSignature);
- //Log.d("SARLANGA", purchaseData);
-
- JSONObject jo = new JSONObject(purchaseData);
- //String sku = jo.getString("productId");
- //alert("You have bought the " + sku + ". Excellent choice, aventurer!");
- //String orderId = jo.getString("orderId");
- //String packageName = jo.getString("packageName");
- String productId = jo.getString("productId");
- //Long purchaseTime = jo.getLong("purchaseTime");
- //Integer state = jo.getInt("purchaseState");
- String developerPayload = jo.getString("developerPayload");
- String purchaseToken = jo.getString("purchaseToken");
-
- if (!pc.getConsumableValue("validation_hash", productId).equals(developerPayload)) {
- error("Untrusted callback");
- return;
- }
- //Log.d("XXX", "Este es el product ID:" + productId);
- pc.setConsumableValue("ticket_signautre", productId, dataSignature);
- pc.setConsumableValue("ticket", productId, purchaseData);
- pc.setConsumableFlag("block", productId, true);
- pc.setConsumableValue("token", productId, purchaseToken);
-
- success(productId, dataSignature, purchaseData);
- return;
- } catch (JSONException e) {
- error(e.getMessage());
- }
- } else if (resultCode == Activity.RESULT_CANCELED) {
- canceled();
- }
- }
-
- abstract protected void success(String sku, String signature, String ticket);
- abstract protected void error(String message);
- abstract protected void canceled();
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsCache.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsCache.java
deleted file mode 100644
index d5919e3d9d..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsCache.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*************************************************************************/
-/* PaymentsCache.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-public class PaymentsCache {
-
- public Context context;
-
- public PaymentsCache(Context context) {
- this.context = context;
- }
-
- public void setConsumableFlag(String set, String sku, Boolean flag) {
- SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putBoolean(sku, flag);
- editor.apply();
- }
-
- public boolean getConsumableFlag(String set, String sku) {
- SharedPreferences sharedPref = context.getSharedPreferences(
- "consumables_" + set, Context.MODE_PRIVATE);
- return sharedPref.getBoolean(sku, false);
- }
-
- public void setConsumableValue(String set, String sku, String value) {
- SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putString(sku, value);
- //Log.d("XXX", "Setting asset: consumables_" + set + ":" + sku);
- editor.apply();
- }
-
- public String getConsumableValue(String set, String sku) {
- SharedPreferences sharedPref = context.getSharedPreferences(
- "consumables_" + set, Context.MODE_PRIVATE);
- //Log.d("XXX", "Getting asset: consumables_" + set + ":" + sku);
- return sharedPref.getString(sku, null);
- }
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsManager.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsManager.java
deleted file mode 100644
index 0393c0b06e..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PaymentsManager.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*************************************************************************/
-/* PaymentsManager.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.vending.billing.IInAppBillingService;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class PaymentsManager {
-
- public static final int BILLING_RESPONSE_RESULT_OK = 0;
- public static final int REQUEST_CODE_FOR_PURCHASE = 0x1001;
- private static boolean auto_consume = true;
-
- private final Activity activity;
- private final GodotPayment godotPayment;
- IInAppBillingService mService;
-
- PaymentsManager(Activity activity, GodotPayment godotPayment) {
- this.activity = activity;
- this.godotPayment = godotPayment;
- }
-
- public PaymentsManager initService() {
- Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
- intent.setPackage("com.android.vending");
- activity.bindService(
- intent,
- mServiceConn,
- Context.BIND_AUTO_CREATE);
- return this;
- }
-
- public void destroy() {
- if (mService != null) {
- activity.unbindService(mServiceConn);
- }
- }
-
- ServiceConnection mServiceConn = new ServiceConnection() {
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mService = null;
-
- // At this stage, godotPayment might not have been initialized yet.
- if (godotPayment != null) {
- godotPayment.callbackDisconnected();
- }
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mService = IInAppBillingService.Stub.asInterface(service);
-
- // At this stage, godotPayment might not have been initialized yet.
- if (godotPayment != null) {
- godotPayment.callbackConnected();
- }
- }
- };
-
- public void requestPurchase(final String sku, String transactionId) {
- new PurchaseTask(mService, activity) {
- @Override
- protected void error(String message) {
- godotPayment.callbackFail(message);
- }
-
- @Override
- protected void canceled() {
- godotPayment.callbackCancel();
- }
-
- @Override
- protected void alreadyOwned() {
- godotPayment.callbackAlreadyOwned(sku);
- }
- }
- .purchase(sku, transactionId);
- }
-
- public boolean isConnected() {
- return mService != null;
- }
-
- public void consumeUnconsumedPurchases() {
- new ReleaseAllConsumablesTask(mService, activity) {
- @Override
- protected void success(String sku, String receipt, String signature, String token) {
- godotPayment.callbackSuccessProductMassConsumed(receipt, signature, sku);
- }
-
- @Override
- protected void error(String message) {
- Log.d("godot", "consumeUnconsumedPurchases :" + message);
- godotPayment.callbackFailConsume(message);
- }
-
- @Override
- protected void notRequired() {
- Log.d("godot", "callbackSuccessNoUnconsumedPurchases :");
- godotPayment.callbackSuccessNoUnconsumedPurchases();
- }
- }
- .consumeItAll();
- }
-
- public void requestPurchased() {
- try {
- PaymentsCache pc = new PaymentsCache(activity);
-
- String continueToken = null;
-
- do {
- Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp", continueToken);
-
- if (bundle.getInt("RESPONSE_CODE") == 0) {
-
- final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
- final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
-
- if (myPurchases == null || myPurchases.size() == 0) {
- godotPayment.callbackPurchased("", "", "");
- return;
- }
-
- for (int i = 0; i < myPurchases.size(); i++) {
-
- try {
- String receipt = myPurchases.get(i);
- JSONObject inappPurchaseData = new JSONObject(receipt);
- String sku = inappPurchaseData.getString("productId");
- String token = inappPurchaseData.getString("purchaseToken");
- String signature = mySignatures.get(i);
-
- pc.setConsumableValue("ticket_signautre", sku, signature);
- pc.setConsumableValue("ticket", sku, receipt);
- pc.setConsumableFlag("block", sku, true);
- pc.setConsumableValue("token", sku, token);
-
- godotPayment.callbackPurchased(receipt, signature, sku);
- } catch (JSONException e) {
- }
- }
- }
- continueToken = bundle.getString("INAPP_CONTINUATION_TOKEN");
- Log.d("godot", "continue token = " + continueToken);
- } while (!TextUtils.isEmpty(continueToken));
- } catch (Exception e) {
- Log.d("godot", "Error requesting purchased products:" + e.getClass().getName() + ":" + e.getMessage());
- }
- }
-
- public void processPurchaseResponse(int resultCode, Intent data) {
- new HandlePurchaseTask(activity) {
- @Override
- protected void success(final String sku, final String signature, final String ticket) {
- godotPayment.callbackSuccess(ticket, signature, sku);
-
- if (auto_consume) {
- new ConsumeTask(mService, activity) {
- @Override
- protected void success(String ticket) {
- }
-
- @Override
- protected void error(String message) {
- godotPayment.callbackFail(message);
- }
- }
- .consume(sku);
- }
- }
-
- @Override
- protected void error(String message) {
- godotPayment.callbackFail(message);
- }
-
- @Override
- protected void canceled() {
- godotPayment.callbackCancel();
- }
- }
- .handlePurchaseRequest(resultCode, data);
- }
-
- public void validatePurchase(String purchaseToken, final String sku) {
-
- new ValidateTask(activity, godotPayment) {
- @Override
- protected void success() {
-
- new ConsumeTask(mService, activity) {
- @Override
- protected void success(String ticket) {
- godotPayment.callbackSuccess(ticket, null, sku);
- }
-
- @Override
- protected void error(String message) {
- godotPayment.callbackFail(message);
- }
- }
- .consume(sku);
- }
-
- @Override
- protected void error(String message) {
- godotPayment.callbackFail(message);
- }
-
- @Override
- protected void canceled() {
- godotPayment.callbackCancel();
- }
- }
- .validatePurchase(sku);
- }
-
- public void setAutoConsume(boolean autoConsume) {
- auto_consume = autoConsume;
- }
-
- public void consume(final String sku) {
- new ConsumeTask(mService, activity) {
- @Override
- protected void success(String ticket) {
- godotPayment.callbackSuccessProductMassConsumed(ticket, "", sku);
- }
-
- @Override
- protected void error(String message) {
- godotPayment.callbackFailConsume(message);
- }
- }
- .consume(sku);
- }
-
- // Workaround to bug where sometimes response codes come as Long instead of Integer
- int getResponseCodeFromBundle(Bundle b) {
- Object o = b.get("RESPONSE_CODE");
- if (o == null) {
- //logDebug("Bundle with null response code, assuming OK (known issue)");
- return BILLING_RESPONSE_RESULT_OK;
- } else if (o instanceof Integer)
- return ((Integer)o).intValue();
- else if (o instanceof Long)
- return (int)((Long)o).longValue();
- else {
- //logError("Unexpected type for bundle response code.");
- //logError(o.getClass().getName());
- throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
- }
- }
-
- /**
- * Returns a human-readable description for the given response code.
- *
- * @param code The response code
- * @return A human-readable string explaining the result code.
- * It also includes the result code numerically.
- */
- public static String getResponseDesc(int code) {
- String[] iab_msgs = ("0:OK/1:User Canceled/2:Unknown/"
- +
- "3:Billing Unavailable/4:Item unavailable/"
- +
- "5:Developer Error/6:Error/7:Item Already Owned/"
- +
- "8:Item not owned")
- .split("/");
- String[] iabhelper_msgs = ("0:OK/-1001:Remote exception during initialization/"
- +
- "-1002:Bad response received/"
- +
- "-1003:Purchase signature verification failed/"
- +
- "-1004:Send intent failed/"
- +
- "-1005:User cancelled/"
- +
- "-1006:Unknown purchase response/"
- +
- "-1007:Missing token/"
- +
- "-1008:Unknown error/"
- +
- "-1009:Subscriptions not available/"
- +
- "-1010:Invalid consumption attempt")
- .split("/");
-
- if (code <= -1000) {
- int index = -1000 - code;
- if (index >= 0 && index < iabhelper_msgs.length)
- return iabhelper_msgs[index];
- else
- return String.valueOf(code) + ":Unknown IAB Helper Error";
- } else if (code < 0 || code >= iab_msgs.length)
- return String.valueOf(code) + ":Unknown";
- else
- return iab_msgs[code];
- }
-
- public void querySkuDetails(final String[] list) {
- (new Thread(new Runnable() {
- @Override
- public void run() {
- ArrayList<String> skuList = new ArrayList<String>(Arrays.asList(list));
- if (skuList.size() == 0) {
- return;
- }
- // Split the sku list in blocks of no more than 20 elements.
- ArrayList<ArrayList<String>> packs = new ArrayList<ArrayList<String>>();
- ArrayList<String> tempList;
- int n = skuList.size() / 20;
- int mod = skuList.size() % 20;
- for (int i = 0; i < n; i++) {
- tempList = new ArrayList<String>();
- for (String s : skuList.subList(i * 20, i * 20 + 20)) {
- tempList.add(s);
- }
- packs.add(tempList);
- }
- if (mod != 0) {
- tempList = new ArrayList<String>();
- for (String s : skuList.subList(n * 20, n * 20 + mod)) {
- tempList.add(s);
- }
- packs.add(tempList);
- }
- for (ArrayList<String> skuPartList : packs) {
- Bundle querySkus = new Bundle();
- querySkus.putStringArrayList("ITEM_ID_LIST", skuPartList);
- Bundle skuDetails = null;
- try {
- skuDetails = mService.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
- if (!skuDetails.containsKey("DETAILS_LIST")) {
- int response = getResponseCodeFromBundle(skuDetails);
- if (response != BILLING_RESPONSE_RESULT_OK) {
- godotPayment.errorSkuDetail(getResponseDesc(response));
- } else {
- godotPayment.errorSkuDetail("No error but no detail list.");
- }
- return;
- }
-
- ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
-
- for (String thisResponse : responseList) {
- Log.d("godot", "response = " + thisResponse);
- godotPayment.addSkuDetail(thisResponse);
- }
- } catch (RemoteException e) {
- e.printStackTrace();
- godotPayment.errorSkuDetail("RemoteException error!");
- }
- }
- godotPayment.completeSkuDetail();
- }
- }))
- .start();
- }
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PurchaseTask.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PurchaseTask.java
deleted file mode 100644
index 4894e4020f..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/PurchaseTask.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*************************************************************************/
-/* PurchaseTask.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import android.app.Activity;
-import android.app.PendingIntent;
-import android.content.Intent;
-import android.content.IntentSender.SendIntentException;
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.util.Log;
-
-import com.android.vending.billing.IInAppBillingService;
-
-abstract public class PurchaseTask {
-
- private Activity context;
-
- private IInAppBillingService mService;
- public PurchaseTask(IInAppBillingService mService, Activity context) {
- this.context = context;
- this.mService = mService;
- }
-
- private boolean isLooping = false;
-
- public void purchase(final String sku, final String transactionId) {
- Log.d("XXX", "Starting purchase for: " + sku);
- PaymentsCache pc = new PaymentsCache(context);
- Boolean isBlocked = pc.getConsumableFlag("block", sku);
- /*
- if(isBlocked){
- Log.d("XXX", "Is awaiting payment confirmation");
- error("Awaiting payment confirmation");
- return;
- }
- */
- final String hash = transactionId;
-
- Bundle buyIntentBundle;
- try {
- buyIntentBundle = mService.getBuyIntent(3, context.getApplicationContext().getPackageName(), sku, "inapp", hash);
- } catch (RemoteException e) {
- //Log.d("XXX", "Error: " + e.getMessage());
- error(e.getMessage());
- return;
- }
- Object rc = buyIntentBundle.get("RESPONSE_CODE");
- int responseCode = 0;
- if (rc == null) {
- responseCode = PaymentsManager.BILLING_RESPONSE_RESULT_OK;
- } else if (rc instanceof Integer) {
- responseCode = ((Integer)rc).intValue();
- } else if (rc instanceof Long) {
- responseCode = (int)((Long)rc).longValue();
- }
- //Log.d("XXX", "Buy intent response code: " + responseCode);
- if (responseCode == 1 || responseCode == 3 || responseCode == 4) {
- canceled();
- return;
- }
- if (responseCode == 7) {
- alreadyOwned();
- return;
- }
-
- PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
- pc.setConsumableValue("validation_hash", sku, hash);
- try {
- if (context == null) {
- //Log.d("XXX", "No context!");
- }
- if (pendingIntent == null) {
- //Log.d("XXX", "No pending intent");
- }
- //Log.d("XXX", "Starting activity for purchase!");
- context.startIntentSenderForResult(
- pendingIntent.getIntentSender(),
- PaymentsManager.REQUEST_CODE_FOR_PURCHASE,
- new Intent(),
- Integer.valueOf(0), Integer.valueOf(0),
- Integer.valueOf(0));
- } catch (SendIntentException e) {
- error(e.getMessage());
- }
- }
-
- abstract protected void error(String message);
- abstract protected void canceled();
- abstract protected void alreadyOwned();
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ReleaseAllConsumablesTask.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ReleaseAllConsumablesTask.java
deleted file mode 100644
index 006688a450..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ReleaseAllConsumablesTask.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*************************************************************************/
-/* ReleaseAllConsumablesTask.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import android.content.Context;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.android.vending.billing.IInAppBillingService;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-abstract public class ReleaseAllConsumablesTask {
-
- private Context context;
- private IInAppBillingService mService;
-
- private static class ReleaseAllConsumablesAsyncTask extends AsyncTask<String, String, String> {
-
- private WeakReference<ReleaseAllConsumablesTask> mTask;
- private String mSku;
- private String mReceipt;
- private String mSignature;
- private String mToken;
-
- ReleaseAllConsumablesAsyncTask(ReleaseAllConsumablesTask task, String sku, String receipt, String signature, String token) {
- mTask = new WeakReference<ReleaseAllConsumablesTask>(task);
-
- mSku = sku;
- mReceipt = receipt;
- mSignature = signature;
- mToken = token;
- }
-
- @Override
- protected String doInBackground(String... params) {
- ReleaseAllConsumablesTask consume = mTask.get();
- if (consume != null) {
- return consume.doInBackground(mToken);
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(String param) {
- ReleaseAllConsumablesTask consume = mTask.get();
- if (consume != null) {
- consume.success(mSku, mReceipt, mSignature, mToken);
- }
- }
- }
-
- public ReleaseAllConsumablesTask(IInAppBillingService mService, Context context) {
- this.context = context;
- this.mService = mService;
- }
-
- public void consumeItAll() {
- try {
- //Log.d("godot", "consumeItall for " + context.getPackageName());
- Bundle bundle = mService.getPurchases(3, context.getPackageName(), "inapp", null);
-
- if (bundle.getInt("RESPONSE_CODE") == 0) {
-
- final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
- final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
-
- if (myPurchases == null || myPurchases.size() == 0) {
- //Log.d("godot", "No purchases!");
- notRequired();
- return;
- }
-
- //Log.d("godot", "# products to be consumed:" + myPurchases.size());
- for (int i = 0; i < myPurchases.size(); i++) {
-
- try {
- String receipt = myPurchases.get(i);
- JSONObject inappPurchaseData = new JSONObject(receipt);
- String sku = inappPurchaseData.getString("productId");
- String token = inappPurchaseData.getString("purchaseToken");
- String signature = mySignatures.get(i);
- //Log.d("godot", "A punto de consumir un item con token:" + token + "\n" + receipt);
- new ReleaseAllConsumablesAsyncTask(this, sku, receipt, signature, token).execute();
- } catch (JSONException e) {
- }
- }
- }
- } catch (Exception e) {
- Log.d("godot", "Error releasing products:" + e.getClass().getName() + ":" + e.getMessage());
- }
- }
-
- private String doInBackground(String token) {
- try {
- //Log.d("godot", "Requesting to consume an item with token ." + token);
- int response = mService.consumePurchase(3, context.getPackageName(), token);
- //Log.d("godot", "consumePurchase response: " + response);
- if (response == 0 || response == 8) {
- return null;
- }
- } catch (Exception e) {
- Log.d("godot", "Error " + e.getClass().getName() + ":" + e.getMessage());
- }
- return null;
- }
-
- abstract protected void success(String sku, String receipt, String signature, String token);
- abstract protected void error(String message);
- abstract protected void notRequired();
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ValidateTask.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ValidateTask.java
deleted file mode 100644
index 4ee7b5a0f8..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/ValidateTask.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*************************************************************************/
-/* ValidateTask.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment;
-
-import org.godotengine.godot.plugin.payment.utils.HttpRequester;
-import org.godotengine.godot.plugin.payment.utils.RequestParams;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.os.AsyncTask;
-
-import java.lang.ref.WeakReference;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-abstract public class ValidateTask {
-
- private Activity context;
- private GodotPayment godotPayments;
- private ProgressDialog dialog;
- private String mSku;
-
- private static class ValidateAsyncTask extends AsyncTask<String, String, String> {
- private WeakReference<ValidateTask> mTask;
-
- ValidateAsyncTask(ValidateTask task) {
- mTask = new WeakReference<>(task);
- }
-
- @Override
- protected void onPreExecute() {
- ValidateTask task = mTask.get();
- if (task != null) {
- task.onPreExecute();
- }
- }
-
- @Override
- protected String doInBackground(String... params) {
- ValidateTask task = mTask.get();
- if (task != null) {
- return task.doInBackground(params);
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(String response) {
- ValidateTask task = mTask.get();
- if (task != null) {
- task.onPostExecute(response);
- }
- }
- }
-
- public ValidateTask(Activity context, GodotPayment godotPayments) {
- this.context = context;
- this.godotPayments = godotPayments;
- }
-
- public void validatePurchase(final String sku) {
- mSku = sku;
- new ValidateAsyncTask(this).execute();
- }
-
- private void onPreExecute() {
- dialog = ProgressDialog.show(context, null, "Please wait...");
- }
-
- private String doInBackground(String... params) {
- PaymentsCache pc = new PaymentsCache(context);
- String url = godotPayments.getPurchaseValidationUrlPrefix();
- RequestParams param = new RequestParams();
- param.setUrl(url);
- param.put("ticket", pc.getConsumableValue("ticket", mSku));
- param.put("purchaseToken", pc.getConsumableValue("token", mSku));
- param.put("sku", mSku);
- //Log.d("XXX", "Haciendo request a " + url);
- //Log.d("XXX", "ticket: " + pc.getConsumableValue("ticket", sku));
- //Log.d("XXX", "purchaseToken: " + pc.getConsumableValue("token", sku));
- //Log.d("XXX", "sku: " + sku);
- param.put("package", context.getApplicationContext().getPackageName());
- HttpRequester requester = new HttpRequester();
- String jsonResponse = requester.post(param);
- //Log.d("XXX", "Validation response:\n"+jsonResponse);
- return jsonResponse;
- }
-
- private void onPostExecute(String response) {
- if (dialog != null) {
- dialog.dismiss();
- dialog = null;
- }
- JSONObject j;
- try {
- j = new JSONObject(response);
- if (j.getString("status").equals("OK")) {
- success();
- return;
- } else if (j.getString("status") != null) {
- error(j.getString("message"));
- } else {
- error("Connection error");
- }
- } catch (JSONException e) {
- error(e.getMessage());
- } catch (Exception e) {
- error(e.getMessage());
- }
- }
-
- abstract protected void success();
- abstract protected void error(String message);
- abstract protected void canceled();
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/CustomSSLSocketFactory.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/CustomSSLSocketFactory.java
deleted file mode 100644
index 55b87b49e5..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/CustomSSLSocketFactory.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************/
-/* CustomSSLSocketFactory.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment.utils;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-
-import org.apache.http.conn.ssl.SSLSocketFactory;
-
-/**
- *
- * @author Luis Linietsky <luis.linietsky@gmail.com>
- */
-public class CustomSSLSocketFactory extends SSLSocketFactory {
- SSLContext sslContext = SSLContext.getInstance("TLS");
-
- public CustomSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
- super(truststore);
-
- TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
- tmf.init(truststore);
-
- sslContext.init(null, tmf.getTrustManagers(), null);
- }
-
- @Override
- public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
- return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
- }
-
- @Override
- public Socket createSocket() throws IOException {
- return sslContext.getSocketFactory().createSocket();
- }
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java
new file mode 100644
index 0000000000..f569c1b8bf
--- /dev/null
+++ b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/GodotPaymentUtils.java
@@ -0,0 +1,66 @@
+package org.godotengine.godot.plugin.payment.utils;
+
+import org.godotengine.godot.Dictionary;
+
+import com.android.billingclient.api.Purchase;
+import com.android.billingclient.api.SkuDetails;
+
+import java.util.List;
+
+public class GodotPaymentUtils {
+ public static Dictionary convertPurchaseToDictionary(Purchase purchase) {
+ Dictionary dictionary = new Dictionary();
+ dictionary.put("order_id", purchase.getOrderId());
+ dictionary.put("package_name", purchase.getPackageName());
+ dictionary.put("purchase_state", Integer.valueOf(purchase.getPurchaseState()));
+ dictionary.put("purchase_time", Long.valueOf(purchase.getPurchaseTime()));
+ dictionary.put("purchase_token", purchase.getPurchaseToken());
+ dictionary.put("signature", purchase.getSignature());
+ dictionary.put("sku", purchase.getSku());
+ dictionary.put("is_acknowledged", Boolean.valueOf(purchase.isAcknowledged()));
+ dictionary.put("is_auto_renewing", Boolean.valueOf(purchase.isAutoRenewing()));
+ return dictionary;
+ }
+
+ public static Dictionary convertSkuDetailsToDictionary(SkuDetails details) {
+ Dictionary dictionary = new Dictionary();
+ dictionary.put("sku", details.getSku());
+ dictionary.put("title", details.getTitle());
+ dictionary.put("description", details.getDescription());
+ dictionary.put("price", details.getPrice());
+ dictionary.put("price_currency_code", details.getPriceCurrencyCode());
+ dictionary.put("price_amount_micros", Long.valueOf(details.getPriceAmountMicros()));
+ dictionary.put("free_trial_period", details.getFreeTrialPeriod());
+ dictionary.put("icon_url", details.getIconUrl());
+ dictionary.put("introductory_price", details.getIntroductoryPrice());
+ dictionary.put("introductory_price_amount_micros", Long.valueOf(details.getIntroductoryPriceAmountMicros()));
+ dictionary.put("introductory_price_cycles", details.getIntroductoryPriceCycles());
+ dictionary.put("introductory_price_period", details.getIntroductoryPricePeriod());
+ dictionary.put("original_price", details.getOriginalPrice());
+ dictionary.put("original_price_amount_micros", Long.valueOf(details.getOriginalPriceAmountMicros()));
+ dictionary.put("subscription_period", details.getSubscriptionPeriod());
+ dictionary.put("type", details.getType());
+ dictionary.put("is_rewarded", Boolean.valueOf(details.isRewarded()));
+ return dictionary;
+ }
+
+ public static Object[] convertPurchaseListToDictionaryObjectArray(List<Purchase> purchases) {
+ Object[] purchaseDictionaries = new Object[purchases.size()];
+
+ for (int i = 0; i < purchases.size(); i++) {
+ purchaseDictionaries[i] = GodotPaymentUtils.convertPurchaseToDictionary(purchases.get(i));
+ }
+
+ return purchaseDictionaries;
+ }
+
+ public static Object[] convertSkuDetailsListToDictionaryObjectArray(List<SkuDetails> skuDetails) {
+ Object[] skuDetailsDictionaries = new Object[skuDetails.size()];
+
+ for (int i = 0; i < skuDetails.size(); i++) {
+ skuDetailsDictionaries[i] = GodotPaymentUtils.convertSkuDetailsToDictionary(skuDetails.get(i));
+ }
+
+ return skuDetailsDictionaries;
+ }
+}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/HttpRequester.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/HttpRequester.java
deleted file mode 100644
index acd17f10f2..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/HttpRequester.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*************************************************************************/
-/* HttpRequester.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment.utils;
-
-import org.godotengine.godot.utils.Crypt;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.util.Log;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.security.KeyStore;
-import java.util.Date;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-
-/**
- *
- * @author Luis Linietsky <luis.linietsky@gmail.com>
- */
-public class HttpRequester {
-
- private Context context;
- private static final int TTL = 600000; // 10 minutos
- private long cttl = 0;
-
- public HttpRequester() {
- //Log.d("XXX", "Creando http request sin contexto");
- }
-
- public HttpRequester(Context context) {
- this.context = context;
- //Log.d("XXX", "Creando http request con contexto");
- }
-
- public String post(RequestParams params) {
- HttpPost httppost = new HttpPost(params.getUrl());
- try {
- httppost.setEntity(new UrlEncodedFormEntity(params.toPairsList()));
- return request(httppost);
- } catch (UnsupportedEncodingException e) {
- return null;
- }
- }
-
- public String get(RequestParams params) {
- String response = getResponseFromCache(params.getUrl());
- if (response == null) {
- //Log.d("XXX", "Cache miss!");
- HttpGet httpget = new HttpGet(params.getUrl());
- long timeInit = new Date().getTime();
- response = request(httpget);
- long delay = new Date().getTime() - timeInit;
- Log.d("HttpRequest::get(url)", "Url: " + params.getUrl() + " downloaded in " + String.format("%.03f", delay / 1000.0f) + " seconds");
- if (response == null || response.length() == 0) {
- response = "";
- } else {
- saveResponseIntoCache(params.getUrl(), response);
- }
- }
- Log.d("XXX", "Req: " + params.getUrl());
- Log.d("XXX", "Resp: " + response);
- return response;
- }
-
- private String request(HttpUriRequest request) {
- //Log.d("XXX", "Haciendo request a: " + request.getURI() );
- Log.d("PPP", "Haciendo request a: " + request.getURI());
- long init = new Date().getTime();
- HttpClient httpclient = getNewHttpClient();
- HttpParams httpParameters = httpclient.getParams();
- HttpConnectionParams.setConnectionTimeout(httpParameters, 0);
- HttpConnectionParams.setSoTimeout(httpParameters, 0);
- HttpConnectionParams.setTcpNoDelay(httpParameters, true);
- try {
- HttpResponse response = httpclient.execute(request);
- Log.d("PPP", "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI());
- //Log.d("XXX1", "Status:" + response.getStatusLine().toString());
- if (response.getStatusLine().getStatusCode() == 200) {
- String strResponse = EntityUtils.toString(response.getEntity());
- //Log.d("XXX2", strResponse);
- return strResponse;
- } else {
- Log.d("XXX3", "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity()));
- return null;
- }
-
- } catch (ClientProtocolException e) {
- Log.d("XXX3", e.getMessage());
- } catch (IOException e) {
- Log.d("XXX4", e.getMessage());
- }
- return null;
- }
-
- private HttpClient getNewHttpClient() {
- try {
- KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- trustStore.load(null, null);
-
- SSLSocketFactory sf = new CustomSSLSocketFactory(trustStore);
- sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- HttpParams params = new BasicHttpParams();
- HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
- HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
-
- SchemeRegistry registry = new SchemeRegistry();
- registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
- registry.register(new Scheme("https", sf, 443));
-
- ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
-
- return new DefaultHttpClient(ccm, params);
- } catch (Exception e) {
- return new DefaultHttpClient();
- }
- }
-
- private static String convertStreamToString(InputStream is) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- StringBuilder sb = new StringBuilder();
- String line = null;
- try {
- while ((line = reader.readLine()) != null) {
- sb.append((line + "\n"));
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return sb.toString();
- }
-
- public void saveResponseIntoCache(String request, String response) {
- if (context == null) {
- //Log.d("XXX", "No context, cache failed!");
- return;
- }
- SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putString("request_" + Crypt.md5(request), response);
- editor.putLong("request_" + Crypt.md5(request) + "_ttl", new Date().getTime() + getTtl());
- editor.apply();
- }
-
- public String getResponseFromCache(String request) {
- if (context == null) {
- Log.d("XXX", "No context, cache miss");
- return null;
- }
- SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE);
- long ttl = getResponseTtl(request);
- if (ttl == 0l || (new Date().getTime() - ttl) > 0l) {
- Log.d("XXX", "Cache invalid ttl:" + ttl + " vs now:" + new Date().getTime());
- return null;
- }
- return sharedPref.getString("request_" + Crypt.md5(request), null);
- }
-
- public long getResponseTtl(String request) {
- SharedPreferences sharedPref = context.getSharedPreferences(
- "http_get_cache", Context.MODE_PRIVATE);
- return sharedPref.getLong("request_" + Crypt.md5(request) + "_ttl", 0l);
- }
-
- public long getTtl() {
- return cttl > 0 ? cttl : TTL;
- }
-
- public void setTtl(long ttl) {
- this.cttl = (ttl * 1000) + new Date().getTime();
- }
-}
diff --git a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/RequestParams.java b/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/RequestParams.java
deleted file mode 100644
index 023fd87f68..0000000000
--- a/platform/android/java/plugins/godotpayment/src/main/java/org/godotengine/godot/plugin/payment/utils/RequestParams.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*************************************************************************/
-/* RequestParams.java */
-/*************************************************************************/
-/* 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. */
-/*************************************************************************/
-
-package org.godotengine.godot.plugin.payment.utils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.http.NameValuePair;
-import org.apache.http.message.BasicNameValuePair;
-
-/**
- *
- * @author Luis Linietsky <luis.linietsky@gmail.com>
- */
-public class RequestParams {
-
- private HashMap<String, String> params;
- private String url;
-
- public RequestParams() {
- params = new HashMap<String, String>();
- }
-
- public void put(String key, String value) {
- params.put(key, value);
- }
-
- public String get(String key) {
- return params.get(key);
- }
-
- public void remove(Object key) {
- params.remove(key);
- }
-
- public boolean has(String key) {
- return params.containsKey(key);
- }
-
- public List<NameValuePair> toPairsList() {
- List<NameValuePair> fields = new ArrayList<NameValuePair>();
-
- for (String key : params.keySet()) {
- fields.add(new BasicNameValuePair(key, this.get(key)));
- }
- return fields;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-}
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index 6b9105b8e5..39de3cb642 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -33,7 +33,6 @@
#include "thread_jandroid.h"
bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error, Variant &ret) {
-
Map<StringName, List<MethodInfo>>::Element *M = methods.find(p_method);
if (!M)
return false;
@@ -42,7 +41,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
MethodInfo *method = nullptr;
for (List<MethodInfo>::Element *E = M->get().front(); E; E = E->next()) {
-
if (!p_instance && !E->get()._static) {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
continue;
@@ -50,13 +48,11 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
int pc = E->get().param_types.size();
if (pc > p_argcount) {
-
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = pc;
continue;
}
if (pc < p_argcount) {
-
r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = pc;
continue;
@@ -65,10 +61,8 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
bool valid = true;
for (int i = 0; i < pc; i++) {
-
Variant::Type arg_expected = Variant::NIL;
switch (ptypes[i]) {
-
case ARG_TYPE_VOID: {
//bug?
} break;
@@ -86,7 +80,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
case ARG_TYPE_SHORT:
case ARG_TYPE_INT:
case ARG_TYPE_LONG: {
-
if (!p_args[i]->is_num())
arg_expected = Variant::INT;
@@ -95,32 +88,26 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
case ARG_NUMBER_CLASS_BIT | ARG_TYPE_DOUBLE:
case ARG_TYPE_FLOAT:
case ARG_TYPE_DOUBLE: {
-
if (!p_args[i]->is_num())
arg_expected = Variant::FLOAT;
} break;
case ARG_TYPE_STRING: {
-
if (p_args[i]->get_type() != Variant::STRING)
arg_expected = Variant::STRING;
} break;
case ARG_TYPE_CLASS: {
-
if (p_args[i]->get_type() != Variant::OBJECT)
arg_expected = Variant::OBJECT;
else {
-
Ref<Reference> ref = *p_args[i];
if (!ref.is_null()) {
if (Object::cast_to<JavaObject>(ref.ptr())) {
-
Ref<JavaObject> jo = ref;
//could be faster
jclass c = env->FindClass(E->get().param_sigs[i].operator String().utf8().get_data());
if (!c || !env->IsInstanceOf(jo->instance, c)) {
-
arg_expected = Variant::OBJECT;
} else {
//ok
@@ -133,7 +120,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
default: {
-
if (p_args[i]->get_type() != Variant::ARRAY)
arg_expected = Variant::ARRAY;
@@ -163,13 +149,11 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
jvalue *argv = nullptr;
if (method->param_types.size()) {
-
argv = (jvalue *)alloca(sizeof(jvalue) * method->param_types.size());
}
List<jobject> to_free;
for (int i = 0; i < method->param_types.size(); i++) {
-
switch (method->param_types[i]) {
case ARG_TYPE_VOID: {
//can't happen
@@ -279,10 +263,8 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
to_free.push_back(jStr);
} break;
case ARG_TYPE_CLASS: {
-
Ref<JavaObject> jo = *p_args[i];
if (jo.is_valid()) {
-
argv[i].l = jo->instance;
} else {
argv[i].l = nullptr; //I hope this works
@@ -290,7 +272,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_BOOLEAN: {
-
Array arr = *p_args[i];
jbooleanArray a = env->NewBooleanArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -302,7 +283,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_BYTE: {
-
Array arr = *p_args[i];
jbyteArray a = env->NewByteArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -314,7 +294,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_CHAR: {
-
Array arr = *p_args[i];
jcharArray a = env->NewCharArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -326,7 +305,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_SHORT: {
-
Array arr = *p_args[i];
jshortArray a = env->NewShortArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -338,7 +316,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_INT: {
-
Array arr = *p_args[i];
jintArray a = env->NewIntArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -360,7 +337,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_FLOAT: {
-
Array arr = *p_args[i];
jfloatArray a = env->NewFloatArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -372,7 +348,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_DOUBLE: {
-
Array arr = *p_args[i];
jdoubleArray a = env->NewDoubleArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
@@ -384,11 +359,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_ARRAY_BIT | ARG_TYPE_STRING: {
-
Array arr = *p_args[i];
jobjectArray a = env->NewObjectArray(arr.size(), env->FindClass("java/lang/String"), nullptr);
for (int j = 0; j < arr.size(); j++) {
-
String s = arr[j];
jstring jStr = env->NewStringUTF(s.utf8().get_data());
env->SetObjectArrayElement(a, j, jStr);
@@ -399,7 +372,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
to_free.push_back(a);
} break;
case ARG_ARRAY_BIT | ARG_TYPE_CLASS: {
-
argv[i].l = nullptr;
} break;
}
@@ -409,7 +381,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
bool success = true;
switch (method->return_type) {
-
case ARG_TYPE_VOID: {
if (method->_static) {
env->CallStaticVoidMethodA(_class, method->method, argv);
@@ -434,7 +405,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
}
} break;
case ARG_TYPE_CHAR: {
-
if (method->_static) {
ret = env->CallStaticCharMethodA(_class, method->method, argv);
} else {
@@ -442,7 +412,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
}
} break;
case ARG_TYPE_SHORT: {
-
if (method->_static) {
ret = env->CallStaticShortMethodA(_class, method->method, argv);
} else {
@@ -451,7 +420,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_TYPE_INT: {
-
if (method->_static) {
ret = env->CallStaticIntMethodA(_class, method->method, argv);
} else {
@@ -460,7 +428,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_TYPE_LONG: {
-
if (method->_static) {
ret = (int64_t)env->CallStaticLongMethodA(_class, method->method, argv);
} else {
@@ -469,7 +436,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_TYPE_FLOAT: {
-
if (method->_static) {
ret = env->CallStaticFloatMethodA(_class, method->method, argv);
} else {
@@ -478,7 +444,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
case ARG_TYPE_DOUBLE: {
-
if (method->_static) {
ret = env->CallStaticDoubleMethodA(_class, method->method, argv);
} else {
@@ -487,7 +452,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
} break;
default: {
-
jobject obj;
if (method->_static) {
obj = env->CallStaticObjectMethodA(_class, method->method, argv);
@@ -498,7 +462,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
if (!obj) {
ret = Variant();
} else {
-
if (!_convert_object_to_variant(env, obj, ret, method->return_type)) {
ret = Variant();
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
@@ -518,7 +481,6 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
}
Variant JavaClass::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
Variant ret;
bool found = _call_method(nullptr, p_method, p_args, p_argcount, r_error, ret);
if (found) {
@@ -534,7 +496,6 @@ JavaClass::JavaClass() {
/////////////////////
Variant JavaObject::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
return Variant();
}
@@ -547,14 +508,12 @@ JavaObject::~JavaObject() {
////////////////////
bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, String &strsig) {
-
jstring name2 = (jstring)env->CallObjectMethod(obj, Class_getName);
String str_type = jstring_to_string(name2, env);
env->DeleteLocalRef(name2);
uint32_t t = 0;
if (str_type.begins_with("[")) {
-
t = JavaClass::ARG_ARRAY_BIT;
strsig = "[";
str_type = str_type.substr(1, str_type.length() - 1);
@@ -633,87 +592,71 @@ bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, St
}
bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &var, uint32_t p_sig) {
-
if (!obj) {
var = Variant(); //seems null is just null...
return true;
}
switch (p_sig) {
-
case ARG_TYPE_VOID: {
-
return Variant();
} break;
case ARG_TYPE_BOOLEAN | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallBooleanMethod(obj, JavaClassWrapper::singleton->Boolean_booleanValue);
return true;
} break;
case ARG_TYPE_BYTE | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallByteMethod(obj, JavaClassWrapper::singleton->Byte_byteValue);
return true;
} break;
case ARG_TYPE_CHAR | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallCharMethod(obj, JavaClassWrapper::singleton->Character_characterValue);
return true;
} break;
case ARG_TYPE_SHORT | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallShortMethod(obj, JavaClassWrapper::singleton->Short_shortValue);
return true;
} break;
case ARG_TYPE_INT | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallIntMethod(obj, JavaClassWrapper::singleton->Integer_integerValue);
return true;
} break;
case ARG_TYPE_LONG | ARG_NUMBER_CLASS_BIT: {
-
var = (int64_t)env->CallLongMethod(obj, JavaClassWrapper::singleton->Long_longValue);
return true;
} break;
case ARG_TYPE_FLOAT | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallFloatMethod(obj, JavaClassWrapper::singleton->Float_floatValue);
return true;
} break;
case ARG_TYPE_DOUBLE | ARG_NUMBER_CLASS_BIT: {
-
var = env->CallDoubleMethod(obj, JavaClassWrapper::singleton->Double_doubleValue);
return true;
} break;
case ARG_TYPE_STRING: {
-
var = jstring_to_string((jstring)obj, env);
return true;
} break;
case ARG_TYPE_CLASS: {
-
return false;
} break;
case ARG_ARRAY_BIT | ARG_TYPE_VOID: {
-
var = Array(); // ?
return true;
} break;
case ARG_ARRAY_BIT | ARG_TYPE_BOOLEAN: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jboolean val;
env->GetBooleanArrayRegion((jbooleanArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -724,14 +667,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
} break;
case ARG_ARRAY_BIT | ARG_TYPE_BYTE: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jbyte val;
env->GetByteArrayRegion((jbyteArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -747,7 +688,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jchar val;
env->GetCharArrayRegion((jcharArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -763,7 +703,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jshort val;
env->GetShortArrayRegion((jshortArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -779,7 +718,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jint val;
env->GetIntArrayRegion((jintArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -795,7 +733,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jlong val;
env->GetLongArrayRegion((jlongArray)arr, 0, 1, &val);
ret.push_back((int64_t)val);
@@ -811,7 +748,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jfloat val;
env->GetFloatArrayRegion((jfloatArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -827,7 +763,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jdouble val;
env->GetDoubleArrayRegion((jdoubleArray)arr, 0, 1, &val);
ret.push_back(val);
@@ -837,14 +772,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_BOOLEAN: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -860,14 +793,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_BYTE: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -882,14 +813,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_CHAR: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -904,14 +833,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_SHORT: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -926,14 +853,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_INT: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -948,14 +873,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_LONG: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -970,14 +893,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_NUMBER_CLASS_BIT | ARG_ARRAY_BIT | ARG_TYPE_FLOAT: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -998,7 +919,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -1014,14 +934,12 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
} break;
case ARG_ARRAY_BIT | ARG_TYPE_STRING: {
-
Array ret;
jobjectArray arr = (jobjectArray)obj;
int count = env->GetArrayLength(arr);
for (int i = 0; i < count; i++) {
-
jobject o = env->GetObjectArrayElement(arr, i);
if (!o)
ret.push_back(Variant());
@@ -1036,7 +954,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
return true;
} break;
case ARG_ARRAY_BIT | ARG_TYPE_CLASS: {
-
} break;
}
@@ -1044,7 +961,6 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
}
Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
-
if (class_cache.has(p_class))
return class_cache[p_class];
@@ -1066,7 +982,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
int count = env->GetArrayLength(methods);
for (int i = 0; i < count; i++) {
-
jobject obj = env->GetObjectArrayElement(methods, i);
ERR_CONTINUE(!obj);
@@ -1096,7 +1011,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
String signature = "(";
for (int j = 0; j < count2; j++) {
-
jobject obj2 = env->GetObjectArrayElement(param_types, j);
String strsig;
uint32_t sig = 0;
@@ -1138,7 +1052,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
bool discard = false;
for (List<JavaClass::MethodInfo>::Element *E = java_class->methods[str_method].front(); E; E = E->next()) {
-
float new_likeliness = 0;
float existing_likeliness = 0;
@@ -1146,7 +1059,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
continue;
bool valid = true;
for (int j = 0; j < E->get().param_types.size(); j++) {
-
Variant::Type _new;
float new_l;
Variant::Type existing;
@@ -1195,7 +1107,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
count = env->GetArrayLength(fields);
for (int i = 0; i < count; i++) {
-
jobject obj = env->GetObjectArrayElement(fields, i);
ERR_CONTINUE(!obj);
@@ -1207,17 +1118,13 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
jobject objc = env->CallObjectMethod(obj, Field_get, nullptr);
if (objc) {
-
uint32_t sig;
String strsig;
jclass cl = env->GetObjectClass(objc);
if (JavaClassWrapper::_get_type_sig(env, cl, sig, strsig)) {
-
if ((sig & JavaClass::ARG_TYPE_MASK) <= JavaClass::ARG_TYPE_STRING) {
-
Variant value;
if (JavaClass::_convert_object_to_variant(env, objc, value, sig)) {
-
java_class->constant_map[str_field] = value;
}
}
@@ -1239,7 +1146,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
JavaClassWrapper *JavaClassWrapper::singleton = nullptr;
JavaClassWrapper::JavaClassWrapper(jobject p_activity) {
-
singleton = this;
JNIEnv *env = ThreadAndroid::get_env();
diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp
index 0da0bd6387..0a42adeaf2 100644
--- a/platform/android/java_godot_io_wrapper.cpp
+++ b/platform/android/java_godot_io_wrapper.cpp
@@ -53,7 +53,7 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc
_get_model = p_env->GetMethodID(cls, "getModel", "()Ljava/lang/String;");
_get_screen_DPI = p_env->GetMethodID(cls, "getScreenDPI", "()I");
_get_unique_id = p_env->GetMethodID(cls, "getUniqueID", "()Ljava/lang/String;");
- _show_keyboard = p_env->GetMethodID(cls, "showKeyboard", "(Ljava/lang/String;I)V");
+ _show_keyboard = p_env->GetMethodID(cls, "showKeyboard", "(Ljava/lang/String;III)V");
_hide_keyboard = p_env->GetMethodID(cls, "hideKeyboard", "()V");
_set_screen_orientation = p_env->GetMethodID(cls, "setScreenOrientation", "(I)V");
_get_screen_orientation = p_env->GetMethodID(cls, "getScreenOrientation", "()I");
@@ -132,11 +132,11 @@ bool GodotIOJavaWrapper::has_vk() {
return (_show_keyboard != 0) && (_hide_keyboard != 0);
}
-void GodotIOJavaWrapper::show_vk(const String &p_existing, int p_max_input_length) {
+void GodotIOJavaWrapper::show_vk(const String &p_existing, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
if (_show_keyboard) {
JNIEnv *env = ThreadAndroid::get_env();
jstring jStr = env->NewStringUTF(p_existing.utf8().get_data());
- env->CallVoidMethod(godot_io_instance, _show_keyboard, jStr, p_max_input_length);
+ env->CallVoidMethod(godot_io_instance, _show_keyboard, jStr, p_max_input_length, p_cursor_start, p_cursor_end);
}
}
diff --git a/platform/android/java_godot_io_wrapper.h b/platform/android/java_godot_io_wrapper.h
index dbb3b564f6..1742021379 100644
--- a/platform/android/java_godot_io_wrapper.h
+++ b/platform/android/java_godot_io_wrapper.h
@@ -70,7 +70,7 @@ public:
int get_screen_dpi();
String get_unique_id();
bool has_vk();
- void show_vk(const String &p_existing, int p_max_input_length);
+ void show_vk(const String &p_existing, int p_max_input_length, int p_cursor_start, int p_cursor_end);
void hide_vk();
int get_vk_height();
void set_vk_height(int p_height);
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index a6730903cc..1f61c4a805 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -78,7 +78,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHei
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jclass clazz, jobject activity, jobject p_asset_manager, jboolean p_use_apk_expansion) {
-
initialized = true;
JavaVM *jvm;
@@ -137,7 +136,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jc
j_cmdline = (jstring *)malloc(cmdlen * sizeof(jstring));
for (int i = 0; i < cmdlen; i++) {
-
jstring string = (jstring)env->GetObjectArrayElement(p_cmdline, i);
const char *rawString = env->GetStringUTFChars(string, 0);
@@ -166,10 +164,20 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jc
ClassDB::register_class<JNISingleton>();
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jint width, jint height) {
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height) {
+ if (os_android) {
+ os_android->set_display_size(Size2i(p_width, p_height));
- if (os_android)
- os_android->set_display_size(Size2i(width, height));
+ // No need to reset the surface during startup
+ if (step > 0) {
+ if (p_surface) {
+ ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
+ os_android->set_native_window(native_window);
+
+ DisplayServerAndroid::get_singleton()->reset_window();
+ }
+ }
+ }
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits) {
@@ -225,19 +233,16 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
DisplayServerAndroid::get_singleton()->process_gyroscope(gyroscope);
if (os_android->main_loop_iterate()) {
-
godot_java->force_quit(env);
}
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint count, jintArray positions) {
-
if (step == 0)
return;
Vector<DisplayServerAndroid::TouchPos> points;
for (int i = 0; i < count; i++) {
-
jint p[3];
env->GetIntArrayRegion(positions, i * 3, 3, p);
DisplayServerAndroid::TouchPos tp;
@@ -357,7 +362,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) {
-
if (step == 0)
return;
@@ -365,7 +369,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env,
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) {
-
if (step == 0)
return;
@@ -373,21 +376,18 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env,
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv *env, jclass clazz) {
-
ThreadAndroid::setup_thread();
AudioDriverAndroid::thread_func(env);
}
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path) {
-
String js = jstring_to_string(path, env);
return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jint ID, jstring method, jobjectArray params) {
-
- Object *obj = ObjectDB::get_instance(ObjectID((uint64_t)ID));
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
+ Object *obj = ObjectDB::get_instance(ObjectID(ID));
ERR_FAIL_COND(!obj);
int res = env->PushLocalFrame(16);
@@ -399,7 +399,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en
Variant *vlist = (Variant *)alloca(sizeof(Variant) * count);
Variant **vptr = (Variant **)alloca(sizeof(Variant *) * count);
for (int i = 0; i < count; i++) {
-
jobject obj = env->GetObjectArrayElement(params, i);
Variant v;
if (obj)
@@ -417,9 +416,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en
env->PopLocalFrame(nullptr);
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jint ID, jstring method, jobjectArray params) {
-
- Object *obj = ObjectDB::get_instance(ObjectID((uint64_t)ID));
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
+ Object *obj = ObjectDB::get_instance(ObjectID(ID));
ERR_FAIL_COND(!obj);
int res = env->PushLocalFrame(16);
@@ -431,7 +429,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
Variant args[VARIANT_ARG_MAX];
for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) {
-
jobject obj = env->GetObjectArrayElement(params, i);
if (obj)
args[i] = _jobject_to_variant(env, obj);
diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h
index 221d701e2b..e8be7be0d0 100644
--- a/platform/android/java_godot_lib_jni.h
+++ b/platform/android/java_godot_lib_jni.h
@@ -40,7 +40,7 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jclass clazz, jobject activity, jobject p_asset_manager, jboolean p_use_apk_expansion);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz, jobject activity);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jint width, jint height);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz);
@@ -61,8 +61,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz);
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jint ID, jstring method, jobjectArray params);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jint ID, jstring method, jobjectArray params);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz);
diff --git a/platform/android/jni_utils.cpp b/platform/android/jni_utils.cpp
index ded79a668f..8e1ae53b78 100644
--- a/platform/android/jni_utils.cpp
+++ b/platform/android/jni_utils.cpp
@@ -31,13 +31,10 @@
#include "jni_utils.h"
jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_arg, bool force_jobject) {
-
jvalret v;
switch (p_type) {
-
case Variant::BOOL: {
-
if (force_jobject) {
jclass bclass = env->FindClass("java/lang/Boolean");
jmethodID ctor = env->GetMethodID(bclass, "<init>", "(Z)V");
@@ -52,9 +49,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
};
} break;
case Variant::INT: {
-
if (force_jobject) {
-
jclass bclass = env->FindClass("java/lang/Integer");
jmethodID ctor = env->GetMethodID(bclass, "<init>", "(I)V");
jvalue val;
@@ -69,9 +64,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
};
} break;
case Variant::FLOAT: {
-
if (force_jobject) {
-
jclass bclass = env->FindClass("java/lang/Double");
jmethodID ctor = env->GetMethodID(bclass, "<init>", "(D)V");
jvalue val;
@@ -86,19 +79,16 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
};
} break;
case Variant::STRING: {
-
String s = *p_arg;
jstring jStr = env->NewStringUTF(s.utf8().get_data());
v.val.l = jStr;
v.obj = jStr;
} break;
case Variant::PACKED_STRING_ARRAY: {
-
Vector<String> sarray = *p_arg;
jobjectArray arr = env->NewObjectArray(sarray.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
for (int j = 0; j < sarray.size(); j++) {
-
jstring str = env->NewStringUTF(sarray[j].utf8().get_data());
env->SetObjectArrayElement(arr, j, str);
env->DeleteLocalRef(str);
@@ -109,7 +99,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} break;
case Variant::DICTIONARY: {
-
Dictionary dict = *p_arg;
jclass dclass = env->FindClass("org/godotengine/godot/Dictionary");
jmethodID ctor = env->GetMethodID(dclass, "<init>", "()V");
@@ -152,7 +141,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} break;
case Variant::PACKED_INT32_ARRAY: {
-
Vector<int> array = *p_arg;
jintArray arr = env->NewIntArray(array.size());
const int *r = array.ptr();
@@ -171,7 +159,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
} break;
case Variant::PACKED_FLOAT32_ARRAY: {
-
Vector<float> array = *p_arg;
jfloatArray arr = env->NewFloatArray(array.size());
const float *r = array.ptr();
@@ -185,7 +172,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
#endif
default: {
-
v.val.i = 0;
} break;
}
@@ -193,7 +179,6 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
}
String _get_class_name(JNIEnv *env, jclass cls, bool *array) {
-
jclass cclass = env->FindClass("java/lang/Class");
jmethodID getName = env->GetMethodID(cclass, "getName", "()Ljava/lang/String;");
jstring clsName = (jstring)env->CallObjectMethod(cls, getName);
@@ -210,7 +195,6 @@ String _get_class_name(JNIEnv *env, jclass cls, bool *array) {
}
Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
-
if (obj == nullptr) {
return Variant();
}
@@ -220,12 +204,10 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
String name = _get_class_name(env, c, &array);
if (name == "java.lang.String") {
-
return jstring_to_string((jstring)obj, env);
};
if (name == "[Ljava.lang.String;") {
-
jobjectArray arr = (jobjectArray)obj;
int stringCount = env->GetArrayLength(arr);
Vector<String> sarr;
@@ -240,14 +222,12 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "java.lang.Boolean") {
-
jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
bool ret = env->CallBooleanMethod(obj, boolValue);
return ret;
};
if (name == "java.lang.Integer" || name == "java.lang.Long") {
-
jclass nclass = env->FindClass("java/lang/Number");
jmethodID longValue = env->GetMethodID(nclass, "longValue", "()J");
jlong ret = env->CallLongMethod(obj, longValue);
@@ -255,7 +235,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[I") {
-
jintArray arr = (jintArray)obj;
int fCount = env->GetArrayLength(arr);
Vector<int> sarr;
@@ -267,7 +246,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[B") {
-
jbyteArray arr = (jbyteArray)obj;
int fCount = env->GetArrayLength(arr);
Vector<uint8_t> sarr;
@@ -279,7 +257,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "java.lang.Float" || name == "java.lang.Double") {
-
jclass nclass = env->FindClass("java/lang/Number");
jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
double ret = env->CallDoubleMethod(obj, doubleValue);
@@ -287,7 +264,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[D") {
-
jdoubleArray arr = (jdoubleArray)obj;
int fCount = env->GetArrayLength(arr);
PackedFloat32Array sarr;
@@ -296,7 +272,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
real_t *w = sarr.ptrw();
for (int i = 0; i < fCount; i++) {
-
double n;
env->GetDoubleArrayRegion(arr, i, 1, &n);
w[i] = n;
@@ -305,7 +280,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[F") {
-
jfloatArray arr = (jfloatArray)obj;
int fCount = env->GetArrayLength(arr);
PackedFloat32Array sarr;
@@ -314,7 +288,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
real_t *w = sarr.ptrw();
for (int i = 0; i < fCount; i++) {
-
float n;
env->GetFloatArrayRegion(arr, i, 1, &n);
w[i] = n;
@@ -323,7 +296,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "[Ljava.lang.Object;") {
-
jobjectArray arr = (jobjectArray)obj;
int objCount = env->GetArrayLength(arr);
Array varr;
@@ -339,7 +311,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
};
if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") {
-
Dictionary ret;
jclass oclass = c;
jmethodID get_keys = env->GetMethodID(oclass, "get_keys", "()[Ljava/lang/String;");
@@ -355,7 +326,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
env->DeleteLocalRef(arr);
for (int i = 0; i < keys.size(); i++) {
-
ret[keys[i]] = vals[i];
};
@@ -368,7 +338,6 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
}
Variant::Type get_jni_type(const String &p_type) {
-
static struct {
const char *name;
Variant::Type type;
@@ -390,7 +359,6 @@ Variant::Type get_jni_type(const String &p_type) {
int idx = 0;
while (_type_to_vtype[idx].name) {
-
if (p_type == _type_to_vtype[idx].name)
return _type_to_vtype[idx].type;
@@ -401,7 +369,6 @@ Variant::Type get_jni_type(const String &p_type) {
}
const char *get_jni_sig(const String &p_type) {
-
static struct {
const char *name;
const char *sig;
@@ -423,7 +390,6 @@ const char *get_jni_sig(const String &p_type) {
int idx = 0;
while (_type_to_vtype[idx].name) {
-
if (p_type == _type_to_vtype[idx].name)
return _type_to_vtype[idx].sig;
diff --git a/platform/android/jni_utils.h b/platform/android/jni_utils.h
index c2baa51b4a..5320715853 100644
--- a/platform/android/jni_utils.h
+++ b/platform/android/jni_utils.h
@@ -37,7 +37,6 @@
#include <jni.h>
struct jvalret {
-
jobject obj;
jvalue val;
jvalret() { obj = nullptr; }
diff --git a/platform/android/net_socket_android.cpp b/platform/android/net_socket_android.cpp
index 320bdd3817..0341ef3ec6 100644
--- a/platform/android/net_socket_android.cpp
+++ b/platform/android/net_socket_android.cpp
@@ -38,7 +38,6 @@ jmethodID NetSocketAndroid::_multicast_lock_acquire = 0;
jmethodID NetSocketAndroid::_multicast_lock_release = 0;
void NetSocketAndroid::setup(jobject p_net_utils) {
-
JNIEnv *env = ThreadAndroid::get_env();
net_utils = env->NewGlobalRef(p_net_utils);
@@ -72,11 +71,6 @@ void NetSocketAndroid::make_default() {
_create = _create_func;
}
-NetSocketAndroid::NetSocketAndroid() :
- wants_broadcast(false),
- multicast_groups(0) {
-}
-
NetSocketAndroid::~NetSocketAndroid() {
close();
}
diff --git a/platform/android/net_socket_android.h b/platform/android/net_socket_android.h
index 4fc80d2de1..955d906535 100644
--- a/platform/android/net_socket_android.h
+++ b/platform/android/net_socket_android.h
@@ -45,15 +45,14 @@
* joins/leaves a multicast group.
*/
class NetSocketAndroid : public NetSocketPosix {
-
private:
static jobject net_utils;
static jclass cls;
static jmethodID _multicast_lock_acquire;
static jmethodID _multicast_lock_release;
- bool wants_broadcast;
- int multicast_groups;
+ bool wants_broadcast = false;
+ int multicast_groups = 0;
static void multicast_lock_acquire();
static void multicast_lock_release();
@@ -71,7 +70,7 @@ public:
virtual Error join_multicast_group(const IP_Address &p_multi_address, String p_if_name);
virtual Error leave_multicast_group(const IP_Address &p_multi_address, String p_if_name);
- NetSocketAndroid();
+ NetSocketAndroid() {}
~NetSocketAndroid();
};
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 9ae18415ba..baf6ee952a 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -57,7 +57,6 @@ public:
};
void OS_Android::initialize_core() {
-
OS_Unix::initialize_core();
if (use_apk_expansion)
@@ -121,17 +120,14 @@ GodotIOJavaWrapper *OS_Android::get_godot_io_java() {
}
bool OS_Android::request_permission(const String &p_name) {
-
return godot_java->request_permission(p_name);
}
bool OS_Android::request_permissions() {
-
return godot_java->request_permissions();
}
Vector<String> OS_Android::get_granted_permissions() const {
-
return godot_java->get_granted_permissions();
}
@@ -142,30 +138,25 @@ Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_han
}
String OS_Android::get_name() const {
-
return "Android";
}
MainLoop *OS_Android::get_main_loop() const {
-
return main_loop;
}
void OS_Android::main_loop_begin() {
-
if (main_loop)
main_loop->init();
}
bool OS_Android::main_loop_iterate() {
-
if (!main_loop)
return false;
return Main::iteration();
}
void OS_Android::main_loop_end() {
-
if (main_loop)
main_loop->finish();
}
@@ -185,17 +176,14 @@ void OS_Android::main_loop_request_go_back() {
}
Error OS_Android::shell_open(String p_uri) {
-
return godot_io_java->open_uri(p_uri);
}
String OS_Android::get_resource_dir() const {
-
return "/"; //android has its own filesystem for resources inside the APK
}
String OS_Android::get_locale() const {
-
String locale = godot_io_java->get_locale();
if (locale != "") {
return locale;
@@ -205,7 +193,6 @@ String OS_Android::get_locale() const {
}
String OS_Android::get_model_name() const {
-
String model = godot_io_java->get_model();
if (model != "")
return model;
@@ -214,13 +201,11 @@ String OS_Android::get_model_name() const {
}
String OS_Android::get_user_data_dir() const {
-
if (data_dir_cache != String())
return data_dir_cache;
String data_dir = godot_io_java->get_user_data_dir();
if (data_dir != "") {
-
//store current dir
char real_current_dir_name[2048];
getcwd(real_current_dir_name, 2048);
@@ -245,7 +230,6 @@ String OS_Android::get_user_data_dir() const {
}
String OS_Android::get_unique_id() const {
-
String unique_id = godot_io_java->get_unique_id();
if (unique_id != "")
return unique_id;
@@ -254,7 +238,6 @@ String OS_Android::get_unique_id() const {
}
String OS_Android::get_system_dir(SystemDir p_dir) const {
-
return godot_io_java->get_system_dir(p_dir);
}
diff --git a/platform/android/plugin/godot_plugin_config.h b/platform/android/plugin/godot_plugin_config.h
new file mode 100644
index 0000000000..5bc0fc3a58
--- /dev/null
+++ b/platform/android/plugin/godot_plugin_config.h
@@ -0,0 +1,267 @@
+/*************************************************************************/
+/* godot_plugin_config.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 GODOT_PLUGIN_CONFIG_H
+#define GODOT_PLUGIN_CONFIG_H
+
+#include "core/error_list.h"
+#include "core/io/config_file.h"
+#include "core/ustring.h"
+
+static const char *PLUGIN_CONFIG_EXT = ".gdap";
+
+static const char *CONFIG_SECTION = "config";
+static const char *CONFIG_NAME_KEY = "name";
+static const char *CONFIG_BINARY_TYPE_KEY = "binary_type";
+static const char *CONFIG_BINARY_KEY = "binary";
+
+static const char *DEPENDENCIES_SECTION = "dependencies";
+static const char *DEPENDENCIES_LOCAL_KEY = "local";
+static const char *DEPENDENCIES_REMOTE_KEY = "remote";
+static const char *DEPENDENCIES_CUSTOM_MAVEN_REPOS_KEY = "custom_maven_repos";
+
+static const char *BINARY_TYPE_LOCAL = "local";
+static const char *BINARY_TYPE_REMOTE = "remote";
+
+static const char *PLUGIN_VALUE_SEPARATOR = "|";
+
+/*
+ The `config` section and fields are required and defined as follow:
+- **name**: name of the plugin
+- **binary_type**: can be either `local` or `remote`. The type affects the **binary** field
+- **binary**:
+ - if **binary_type** is `local`, then this should be the filename of the plugin `aar` file in the `res://android/plugins` directory (e.g: `MyPlugin.aar`).
+ - if **binary_type** is `remote`, then this should be a declaration for a remote gradle binary (e.g: "org.godot.example:my-plugin:0.0.0").
+
+The `dependencies` section and fields are optional and defined as follow:
+- **local**: contains a list of local `.aar` binary files the plugin depends on. The local binary dependencies must also be located in the `res://android/plugins` directory.
+- **remote**: contains a list of remote binary gradle dependencies for the plugin.
+- **custom_maven_repos**: contains a list of urls specifying custom maven repos required for the plugin's dependencies.
+
+ See https://github.com/godotengine/godot/issues/38157#issuecomment-618773871
+ */
+struct PluginConfig {
+ // Set to true when the config file is properly loaded.
+ bool valid_config = false;
+ // Unix timestamp of last change to this plugin.
+ uint64_t last_updated = 0;
+
+ // Required config section
+ String name;
+ String binary_type;
+ String binary;
+
+ // Optional dependencies section
+ Vector<String> local_dependencies;
+ Vector<String> remote_dependencies;
+ Vector<String> custom_maven_repos;
+};
+
+/*
+ * Set of prebuilt plugins.
+ */
+static const PluginConfig GODOT_PAYMENT = {
+ /*.valid_config =*/true,
+ /*.last_updated =*/0,
+ /*.name =*/"GodotPayment",
+ /*.binary_type =*/"local",
+ /*.binary =*/"res://android/build/libs/plugins/GodotPayment.release.aar",
+ /*.local_dependencies =*/{},
+ /*.remote_dependencies =*/String("com.android.billingclient:billing:2.2.1").split("|"),
+ /*.custom_maven_repos =*/{}
+};
+
+static inline String resolve_local_dependency_path(String plugin_config_dir, String dependency_path) {
+ String absolute_path;
+ if (!dependency_path.empty()) {
+ if (dependency_path.is_abs_path()) {
+ absolute_path = ProjectSettings::get_singleton()->globalize_path(dependency_path);
+ } else {
+ absolute_path = plugin_config_dir.plus_file(dependency_path);
+ }
+ }
+
+ return absolute_path;
+}
+
+static inline PluginConfig resolve_prebuilt_plugin(PluginConfig prebuilt_plugin, String plugin_config_dir) {
+ PluginConfig resolved = prebuilt_plugin;
+ resolved.binary = resolved.binary_type == BINARY_TYPE_LOCAL ? resolve_local_dependency_path(plugin_config_dir, prebuilt_plugin.binary) : prebuilt_plugin.binary;
+ if (!prebuilt_plugin.local_dependencies.empty()) {
+ resolved.local_dependencies.clear();
+ for (int i = 0; i < prebuilt_plugin.local_dependencies.size(); i++) {
+ resolved.local_dependencies.push_back(resolve_local_dependency_path(plugin_config_dir, prebuilt_plugin.local_dependencies[i]));
+ }
+ }
+ return resolved;
+}
+
+static inline Vector<PluginConfig> get_prebuilt_plugins(String plugins_base_dir) {
+ Vector<PluginConfig> prebuilt_plugins;
+ prebuilt_plugins.push_back(resolve_prebuilt_plugin(GODOT_PAYMENT, plugins_base_dir));
+ return prebuilt_plugins;
+}
+
+static inline bool is_plugin_config_valid(PluginConfig plugin_config) {
+ bool valid_name = !plugin_config.name.empty();
+ bool valid_binary_type = plugin_config.binary_type == BINARY_TYPE_LOCAL ||
+ plugin_config.binary_type == BINARY_TYPE_REMOTE;
+
+ bool valid_binary = false;
+ if (valid_binary_type) {
+ valid_binary = !plugin_config.binary.empty() &&
+ (plugin_config.binary_type == BINARY_TYPE_REMOTE ||
+ FileAccess::exists(plugin_config.binary));
+ }
+
+ bool valid_local_dependencies = true;
+ if (!plugin_config.local_dependencies.empty()) {
+ for (int i = 0; i < plugin_config.local_dependencies.size(); i++) {
+ if (!FileAccess::exists(plugin_config.local_dependencies[i])) {
+ valid_local_dependencies = false;
+ break;
+ }
+ }
+ }
+ return valid_name && valid_binary && valid_binary_type && valid_local_dependencies;
+}
+
+static inline uint64_t get_plugin_modification_time(const PluginConfig &plugin_config, const String &config_path) {
+ uint64_t last_updated = FileAccess::get_modified_time(config_path);
+ last_updated = MAX(last_updated, FileAccess::get_modified_time(plugin_config.binary));
+
+ for (int i = 0; i < plugin_config.local_dependencies.size(); i++) {
+ String binary = plugin_config.local_dependencies.get(i);
+ last_updated = MAX(last_updated, FileAccess::get_modified_time(binary));
+ }
+
+ return last_updated;
+}
+
+static inline PluginConfig load_plugin_config(Ref<ConfigFile> config_file, const String &path) {
+ PluginConfig plugin_config = {};
+
+ if (config_file.is_valid()) {
+ Error err = config_file->load(path);
+ if (err == OK) {
+ String config_base_dir = path.get_base_dir();
+
+ plugin_config.name = config_file->get_value(CONFIG_SECTION, CONFIG_NAME_KEY, String());
+ plugin_config.binary_type = config_file->get_value(CONFIG_SECTION, CONFIG_BINARY_TYPE_KEY, String());
+
+ String binary_path = config_file->get_value(CONFIG_SECTION, CONFIG_BINARY_KEY, String());
+ plugin_config.binary = plugin_config.binary_type == BINARY_TYPE_LOCAL ? resolve_local_dependency_path(config_base_dir, binary_path) : binary_path;
+
+ if (config_file->has_section(DEPENDENCIES_SECTION)) {
+ Vector<String> local_dependencies_paths = config_file->get_value(DEPENDENCIES_SECTION, DEPENDENCIES_LOCAL_KEY, Vector<String>());
+ if (!local_dependencies_paths.empty()) {
+ for (int i = 0; i < local_dependencies_paths.size(); i++) {
+ plugin_config.local_dependencies.push_back(resolve_local_dependency_path(config_base_dir, local_dependencies_paths[i]));
+ }
+ }
+
+ plugin_config.remote_dependencies = config_file->get_value(DEPENDENCIES_SECTION, DEPENDENCIES_REMOTE_KEY, Vector<String>());
+ plugin_config.custom_maven_repos = config_file->get_value(DEPENDENCIES_SECTION, DEPENDENCIES_CUSTOM_MAVEN_REPOS_KEY, Vector<String>());
+ }
+
+ plugin_config.valid_config = is_plugin_config_valid(plugin_config);
+ plugin_config.last_updated = get_plugin_modification_time(plugin_config, path);
+ }
+ }
+
+ return plugin_config;
+}
+
+static inline String get_plugins_binaries(String binary_type, Vector<PluginConfig> plugins_configs) {
+ String plugins_binaries;
+ if (!plugins_configs.empty()) {
+ Vector<String> binaries;
+ for (int i = 0; i < plugins_configs.size(); i++) {
+ PluginConfig config = plugins_configs[i];
+ if (!config.valid_config) {
+ continue;
+ }
+
+ if (config.binary_type == binary_type) {
+ binaries.push_back(config.binary);
+ }
+
+ if (binary_type == BINARY_TYPE_LOCAL) {
+ binaries.append_array(config.local_dependencies);
+ }
+
+ if (binary_type == BINARY_TYPE_REMOTE) {
+ binaries.append_array(config.remote_dependencies);
+ }
+ }
+
+ plugins_binaries = String(PLUGIN_VALUE_SEPARATOR).join(binaries);
+ }
+
+ return plugins_binaries;
+}
+
+static inline String get_plugins_custom_maven_repos(Vector<PluginConfig> plugins_configs) {
+ String custom_maven_repos;
+ if (!plugins_configs.empty()) {
+ Vector<String> repos_urls;
+ for (int i = 0; i < plugins_configs.size(); i++) {
+ PluginConfig config = plugins_configs[i];
+ if (!config.valid_config) {
+ continue;
+ }
+
+ repos_urls.append_array(config.custom_maven_repos);
+ }
+
+ custom_maven_repos = String(PLUGIN_VALUE_SEPARATOR).join(repos_urls);
+ }
+ return custom_maven_repos;
+}
+
+static inline String get_plugins_names(Vector<PluginConfig> plugins_configs) {
+ String plugins_names;
+ if (!plugins_configs.empty()) {
+ Vector<String> names;
+ for (int i = 0; i < plugins_configs.size(); i++) {
+ PluginConfig config = plugins_configs[i];
+ if (!config.valid_config) {
+ continue;
+ }
+
+ names.push_back(config.name);
+ }
+ plugins_names = String(PLUGIN_VALUE_SEPARATOR).join(names);
+ }
+
+ return plugins_names;
+}
+
+#endif // GODOT_PLUGIN_CONFIG_H
diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp
index c3bfb2f2ed..d2528bebeb 100644
--- a/platform/android/plugin/godot_plugin_jni.cpp
+++ b/platform/android/plugin/godot_plugin_jni.cpp
@@ -42,7 +42,6 @@ static HashMap<String, JNISingleton *> jni_singletons;
extern "C" {
JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterSingleton(JNIEnv *env, jobject obj, jstring name) {
-
String singname = jstring_to_string(name, env);
JNISingleton *s = (JNISingleton *)ClassDB::instance("JNISingleton");
s->set_instance(env->NewGlobalRef(obj));
@@ -53,7 +52,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegisterMethod(JNIEnv *env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args) {
-
String singname = jstring_to_string(sname, env);
ERR_FAIL_COND(!jni_singletons.has(singname));
@@ -68,7 +66,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis
int stringCount = env->GetArrayLength(args);
for (int i = 0; i < stringCount; i++) {
-
jstring string = (jstring)env->GetObjectArrayElement(args, i);
const String rawString = jstring_to_string(string, env);
types.push_back(get_jni_type(rawString));
@@ -80,7 +77,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis
jclass cls = env->GetObjectClass(s->get_instance());
jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data());
if (!mid) {
-
print_line("Failed getting method ID " + mname);
}
@@ -100,7 +96,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeRegis
int stringCount = env->GetArrayLength(j_signal_param_types);
for (int i = 0; i < stringCount; i++) {
-
jstring j_signal_param_type = (jstring)env->GetObjectArrayElement(j_signal_param_types, i);
const String signal_param_type = jstring_to_string(j_signal_param_type, env);
types.push_back(get_jni_type(signal_param_type));
@@ -119,13 +114,15 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS
String signal_name = jstring_to_string(j_signal_name, env);
int count = env->GetArrayLength(j_signal_params);
- const Variant *args[count];
+ ERR_FAIL_COND_MSG(count > VARIANT_ARG_MAX, "Maximum argument count exceeded!");
- for (int i = 0; i < count; i++) {
+ Variant variant_params[VARIANT_ARG_MAX];
+ const Variant *args[VARIANT_ARG_MAX];
+ for (int i = 0; i < count; i++) {
jobject j_param = env->GetObjectArrayElement(j_signal_params, i);
- Variant variant = _jobject_to_variant(env, j_param);
- args[i] = &variant;
+ variant_params[i] = _jobject_to_variant(env, j_param);
+ args[i] = &variant_params[i];
env->DeleteLocalRef(j_param);
};
diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp
index 729327f6f0..13aa313ebf 100644
--- a/platform/android/thread_jandroid.cpp
+++ b/platform/android/thread_jandroid.cpp
@@ -48,17 +48,14 @@ pthread_key_t ThreadAndroid::thread_id_key = _create_thread_id_key();
Thread::ID ThreadAndroid::next_thread_id = 0;
Thread::ID ThreadAndroid::get_id() const {
-
return id;
}
Thread *ThreadAndroid::create_thread_jandroid() {
-
return memnew(ThreadAndroid);
}
void *ThreadAndroid::thread_callback(void *userdata) {
-
ThreadAndroid *t = reinterpret_cast<ThreadAndroid *>(userdata);
setup_thread();
ScriptServer::thread_enter(); //scripts may need to attach a stack
@@ -70,7 +67,6 @@ void *ThreadAndroid::thread_callback(void *userdata) {
}
Thread *ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
-
ThreadAndroid *tr = memnew(ThreadAndroid);
tr->callback = p_callback;
tr->user = p_user;
@@ -83,7 +79,6 @@ Thread *ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback, voi
}
Thread::ID ThreadAndroid::get_thread_id_func_jandroid() {
-
void *value = pthread_getspecific(thread_id_key);
if (value)
@@ -95,7 +90,6 @@ Thread::ID ThreadAndroid::get_thread_id_func_jandroid() {
}
void ThreadAndroid::wait_to_finish_func_jandroid(Thread *p_thread) {
-
ThreadAndroid *tp = static_cast<ThreadAndroid *>(p_thread);
ERR_FAIL_COND(!tp);
ERR_FAIL_COND(tp->pthread == 0);
@@ -105,7 +99,6 @@ void ThreadAndroid::wait_to_finish_func_jandroid(Thread *p_thread) {
}
void ThreadAndroid::_thread_destroyed(void *value) {
-
/* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
JNIEnv *env = (JNIEnv *)value;
if (env != nullptr) {
@@ -118,7 +111,6 @@ pthread_key_t ThreadAndroid::jvm_key;
JavaVM *ThreadAndroid::java_vm = nullptr;
void ThreadAndroid::setup_thread() {
-
if (pthread_getspecific(jvm_key))
return; //already setup
JNIEnv *env;
@@ -127,7 +119,6 @@ void ThreadAndroid::setup_thread() {
}
void ThreadAndroid::make_default(JavaVM *p_java_vm) {
-
java_vm = p_java_vm;
create_func = create_func_jandroid;
get_thread_id_func = get_thread_id_func_jandroid;
@@ -137,7 +128,6 @@ void ThreadAndroid::make_default(JavaVM *p_java_vm) {
}
JNIEnv *ThreadAndroid::get_env() {
-
if (!pthread_getspecific(jvm_key)) {
setup_thread();
}
@@ -148,7 +138,6 @@ JNIEnv *ThreadAndroid::get_env() {
}
ThreadAndroid::ThreadAndroid() {
-
pthread = 0;
}
diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h
index eb4725ae68..9cfcc64813 100644
--- a/platform/android/thread_jandroid.h
+++ b/platform/android/thread_jandroid.h
@@ -37,7 +37,6 @@
#include <sys/types.h>
class ThreadAndroid : public Thread {
-
static pthread_key_t thread_id_key;
static ID next_thread_id;
diff --git a/platform/android/vulkan/vulkan_context_android.h b/platform/android/vulkan/vulkan_context_android.h
index 7e698ada4f..6bd3cbee36 100644
--- a/platform/android/vulkan/vulkan_context_android.h
+++ b/platform/android/vulkan/vulkan_context_android.h
@@ -36,7 +36,6 @@
struct ANativeWindow;
class VulkanContextAndroid : public VulkanContext {
-
virtual const char *_get_platform_surface_extension() const;
public:
diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp
index 94c9e83368..2fbbeeb176 100644
--- a/platform/haiku/audio_driver_media_kit.cpp
+++ b/platform/haiku/audio_driver_media_kit.cpp
@@ -39,11 +39,11 @@ int32_t *AudioDriverMediaKit::samples_in = nullptr;
Error AudioDriverMediaKit::init() {
active = false;
- mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ mix_rate = GLOBAL_GET("audio/mix_rate");
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
- int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+ int latency = GLOBAL_GET("audio/output_latency");
buffer_size = next_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
diff --git a/platform/haiku/key_mapping_haiku.h b/platform/haiku/key_mapping_haiku.h
index a0e85e3390..e735108e44 100644
--- a/platform/haiku/key_mapping_haiku.h
+++ b/platform/haiku/key_mapping_haiku.h
@@ -32,7 +32,7 @@
#define KEY_MAPPING_HAIKU_H
class KeyMappingHaiku {
- KeyMappingHaiku(){};
+ KeyMappingHaiku() {}
public:
static unsigned int get_keysym(int32 raw_char, int32 key);
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index 07cb18d7cd..7a2591784f 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -324,12 +324,10 @@ String OS_Haiku::get_executable_path() const {
}
bool OS_Haiku::_check_internal_feature_support(const String &p_feature) {
-
return p_feature == "pc";
}
String OS_Haiku::get_config_path() const {
-
if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
@@ -340,7 +338,6 @@ String OS_Haiku::get_config_path() const {
}
String OS_Haiku::get_data_path() const {
-
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else if (has_environment("HOME")) {
@@ -351,7 +348,6 @@ String OS_Haiku::get_data_path() const {
}
String OS_Haiku::get_cache_path() const {
-
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index fb30441bd3..c4ef185bf1 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -426,7 +426,6 @@ OS::VideoMode _get_video_mode() {
static int frame_count = 0;
- (void)drawView:(UIView *)view;
{
-
switch (frame_count) {
case 0: {
OS::get_singleton()->set_video_mode(_get_video_mode());
@@ -463,7 +462,6 @@ static int frame_count = 0;
}; break;
case 1: {
-
Main::setup2();
++frame_count;
@@ -490,7 +488,6 @@ static int frame_count = 0;
ProjectSettings::get_singleton()->set("Info.plist/" + ukey, uval);
} else if ([value isKindOfClass:[NSNumber class]]) {
-
NSNumber *n = (NSNumber *)value;
double dval = [n doubleValue];
@@ -502,7 +499,6 @@ static int frame_count = 0;
}; break;
case 2: {
-
Main::start();
++frame_count;
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index 2222a7f552..63c3cb8c23 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "export.h"
+
#include "core/io/image_loader.h"
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
@@ -47,7 +48,6 @@
#include <sys/stat.h>
class EditorExportPlatformIOS : public EditorExportPlatform {
-
GDCLASS(EditorExportPlatformIOS, EditorExportPlatform);
int version_code;
@@ -72,14 +72,10 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
String modules_buildgrp;
};
struct ExportArchitecture {
-
String name;
- bool is_default;
+ bool is_default = false;
- ExportArchitecture() :
- name(""),
- is_default(false) {
- }
+ ExportArchitecture() {}
ExportArchitecture(String p_name, bool p_is_default) {
name = p_name;
@@ -107,7 +103,6 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
Error _export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets);
bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const {
-
String pname = p_package;
if (pname.length() == 0) {
@@ -150,7 +145,6 @@ public:
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual void get_platform_features(List<String> *r_features) {
-
r_features->push_back("mobile");
r_features->push_back("iOS");
}
@@ -163,7 +157,6 @@ public:
};
void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
-
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
if (driver == "GLES2") {
r_features->push_back("etc");
@@ -209,7 +202,6 @@ static const LoadingScreenInfo loading_screen_infos[] = {
};
void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) {
-
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
@@ -423,8 +415,9 @@ String EditorExportPlatformIOS::_get_linker_flags() {
String result;
for (int i = 0; i < export_plugins.size(); ++i) {
String flags = export_plugins[i]->get_ios_linker_flags();
- if (flags.length() == 0)
+ if (flags.length() == 0) {
continue;
+ }
if (result.length() > 0) {
result += ' ';
}
@@ -444,7 +437,6 @@ String EditorExportPlatformIOS::_get_cpp_code() {
}
void EditorExportPlatformIOS::_blend_and_rotate(Ref<Image> &p_dst, Ref<Image> &p_src, bool p_rot) {
-
ERR_FAIL_COND(p_dst.is_null());
ERR_FAIL_COND(p_src.is_null());
@@ -457,10 +449,12 @@ void EditorExportPlatformIOS::_blend_and_rotate(Ref<Image> &p_dst, Ref<Image> &p
int xs = (x_pos >= 0) ? 0 : -x_pos;
int ys = (y_pos >= 0) ? 0 : -y_pos;
- if (sw + x_pos > p_dst->get_width())
+ if (sw + x_pos > p_dst->get_width()) {
sw = p_dst->get_width() - x_pos;
- if (sh + y_pos > p_dst->get_height())
+ }
+ if (sh + y_pos > p_dst->get_height()) {
sh = p_dst->get_height() - y_pos;
+ }
for (int y = ys; y < sh; y++) {
for (int x = xs; x < sw; x++) {
@@ -930,8 +924,9 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir
ERR_FAIL_COND_V(err, err);
Vector<String> project_static_libs = export_plugins[i]->get_ios_project_static_libs();
- for (int j = 0; j < project_static_libs.size(); j++)
+ for (int j = 0; j < project_static_libs.size(); j++) {
project_static_libs.write[j] = project_static_libs[j].get_file(); // Only the file name as it's copied to the project
+ }
err = _export_additional_assets(p_out_dir, project_static_libs, true, r_exported_assets);
ERR_FAIL_COND_V(err, err);
@@ -990,10 +985,11 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
String team_id = p_preset->get("application/app_store_team_id");
ERR_FAIL_COND_V_MSG(team_id.length() == 0, ERR_CANT_OPEN, "App Store Team ID not specified - cannot configure the project.");
- if (p_debug)
+ if (p_debug) {
src_pkg_name = p_preset->get("custom_template/debug");
- else
+ } else {
src_pkg_name = p_preset->get("custom_template/release");
+ }
if (src_pkg_name == "") {
String err;
@@ -1039,8 +1035,9 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
String pack_path = dest_dir + binary_name + ".pck";
Vector<SharedObject> libraries;
Error err = save_pack(p_preset, pack_path, &libraries);
- if (err)
+ if (err) {
return err;
+ }
if (ep.step("Extracting and configuring Xcode project", 1)) {
return ERR_SKIP;
@@ -1050,12 +1047,13 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
print_line("Static library: " + library_to_use);
String pkg_name;
- if (p_preset->get("application/name") != "")
+ if (p_preset->get("application/name") != "") {
pkg_name = p_preset->get("application/name"); // app_name
- else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "")
+ } else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
- else
+ } else {
pkg_name = "Unnamed";
+ }
bool found_library = false;
int total_size = 0;
@@ -1234,16 +1232,19 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
err = tmp_app_path->make_dir_recursive(iconset_dir);
}
memdelete(tmp_app_path);
- if (err)
+ if (err) {
return err;
+ }
err = _export_icons(p_preset, iconset_dir);
- if (err)
+ if (err) {
return err;
+ }
err = _export_loading_screens(p_preset, dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/");
- if (err)
+ if (err) {
return err;
+ }
print_line("Exporting additional assets");
Vector<IOSExportAsset> assets;
@@ -1313,7 +1314,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
}
bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
-
String err;
bool valid = false;
@@ -1371,14 +1371,14 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset
err += etc_error;
}
- if (!err.empty())
+ if (!err.empty()) {
r_error = err;
+ }
return valid;
}
EditorExportPlatformIOS::EditorExportPlatformIOS() {
-
Ref<Image> img = memnew(Image(_iphone_logo));
logo.instance();
logo->create_from_image(img);
@@ -1388,7 +1388,6 @@ EditorExportPlatformIOS::~EditorExportPlatformIOS() {
}
void register_iphone_exporter() {
-
Ref<EditorExportPlatformIOS> platform;
platform.instance();
diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h
index d35cc4b87c..0d3ef5b696 100644
--- a/platform/iphone/game_center.h
+++ b/platform/iphone/game_center.h
@@ -36,7 +36,6 @@
#include "core/object.h"
class GameCenter : public Object {
-
GDCLASS(GameCenter, Object);
static GameCenter *instance;
diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm
index 99d539d4ff..8d470da1a8 100644
--- a/platform/iphone/game_center.mm
+++ b/platform/iphone/game_center.mm
@@ -75,7 +75,6 @@ void GameCenter::return_connect_error(const char *p_error_description) {
}
void GameCenter::connect() {
-
//if this class isn't available, game center isn't implemented
if ((NSClassFromString(@"GKLocalPlayer")) == nil) {
return_connect_error("GameCenter not available");
@@ -125,7 +124,6 @@ bool GameCenter::is_authenticated() {
};
Error GameCenter::post_score(Variant p_score) {
-
Dictionary params = p_score;
ERR_FAIL_COND_V(!params.has("score") || !params.has("category"), ERR_INVALID_PARAMETER);
float score = params["score"];
@@ -156,7 +154,6 @@ Error GameCenter::post_score(Variant p_score) {
};
Error GameCenter::award_achievement(Variant p_params) {
-
Dictionary params = p_params;
ERR_FAIL_COND_V(!params.has("name") || !params.has("progress"), ERR_INVALID_PARAMETER);
String name = params["name"];
@@ -192,7 +189,6 @@ Error GameCenter::award_achievement(Variant p_params) {
};
void GameCenter::request_achievement_descriptions() {
-
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) {
Dictionary ret;
ret["type"] = "achievement_descriptions";
@@ -207,7 +203,6 @@ void GameCenter::request_achievement_descriptions() {
Array replayable;
for (int i = 0; i < [descriptions count]; i++) {
-
GKAchievementDescription *description = [descriptions objectAtIndex:i];
const char *str = [description.identifier UTF8String];
@@ -247,7 +242,6 @@ void GameCenter::request_achievement_descriptions() {
};
void GameCenter::request_achievements() {
-
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
Dictionary ret;
ret["type"] = "achievements";
@@ -257,7 +251,6 @@ void GameCenter::request_achievements() {
PackedFloat32Array percentages;
for (int i = 0; i < [achievements count]; i++) {
-
GKAchievement *achievement = [achievements objectAtIndex:i];
const char *str = [achievement.identifier UTF8String];
names.push_back(String::utf8(str != NULL ? str : ""));
@@ -278,7 +271,6 @@ void GameCenter::request_achievements() {
};
void GameCenter::reset_achievements() {
-
[GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "reset_achievements";
@@ -294,7 +286,6 @@ void GameCenter::reset_achievements() {
};
Error GameCenter::show_game_center(Variant p_params) {
-
ERR_FAIL_COND_V(!NSProtocolFromString(@"GKGameCenterControllerDelegate"), FAILED);
Dictionary params = p_params;
@@ -338,7 +329,6 @@ Error GameCenter::show_game_center(Variant p_params) {
};
Error GameCenter::request_identity_verification_signature() {
-
ERR_FAIL_COND_V(!is_authenticated(), ERR_UNAUTHORIZED);
GKLocalPlayer *player = [GKLocalPlayer localPlayer];
@@ -365,7 +355,6 @@ Error GameCenter::request_identity_verification_signature() {
};
void GameCenter::game_center_closed() {
-
Dictionary ret;
ret["type"] = "show_game_center";
ret["result"] = "ok";
@@ -373,12 +362,10 @@ void GameCenter::game_center_closed() {
}
int GameCenter::get_pending_event_count() {
-
return pending_events.size();
};
Variant GameCenter::pop_pending_event() {
-
Variant front = pending_events.front()->get();
pending_events.pop_front();
@@ -395,6 +382,6 @@ GameCenter::GameCenter() {
authenticated = false;
};
-GameCenter::~GameCenter(){};
+GameCenter::~GameCenter() {}
#endif
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index ede60a502d..1169ebc6b4 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -174,7 +174,6 @@ void _focus_out_video() {
};
void _unpause_video() {
-
[_instance.avPlayer play];
video_playing = true;
};
@@ -207,14 +206,12 @@ static const int max_touches = 8;
static UITouch *touches[max_touches];
static void init_touches() {
-
for (int i = 0; i < max_touches; i++) {
touches[i] = NULL;
};
};
static int get_touch_id(UITouch *p_touch) {
-
int first = -1;
for (int i = 0; i < max_touches; i++) {
if (first == -1 && touches[i] == NULL) {
@@ -234,10 +231,8 @@ static int get_touch_id(UITouch *p_touch) {
};
static int remove_touch(UITouch *p_touch) {
-
int remaining = 0;
for (int i = 0; i < max_touches; i++) {
-
if (touches[i] == NULL)
continue;
if (touches[i] == p_touch)
@@ -249,9 +244,7 @@ static int remove_touch(UITouch *p_touch) {
};
static void clear_touches() {
-
for (int i = 0; i < max_touches; i++) {
-
touches[i] = NULL;
};
};
@@ -396,7 +389,6 @@ static void clear_touches() {
active = TRUE;
printf("start animation!\n");
if (useCADisplayLink) {
-
// Approximate frame rate
// assumes device refreshes at 60 fps
int frameInterval = (int)floor(animationInterval * 60.0f);
@@ -446,7 +438,6 @@ static void clear_touches() {
// Updates the OpenGL view when the timer fires
- (void)drawView {
-
if (!active) {
printf("draw view not active!\n");
return;
@@ -489,9 +480,7 @@ static void clear_touches() {
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *tlist = [[event allTouches] allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
-
if ([touches containsObject:[tlist objectAtIndex:i]]) {
-
UITouch *touch = [tlist objectAtIndex:i];
if (touch.phase != UITouchPhaseBegan)
continue;
@@ -504,12 +493,9 @@ static void clear_touches() {
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
-
NSArray *tlist = [[event allTouches] allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
-
if ([touches containsObject:[tlist objectAtIndex:i]]) {
-
UITouch *touch = [tlist objectAtIndex:i];
if (touch.phase != UITouchPhaseMoved)
continue;
@@ -525,9 +511,7 @@ static void clear_touches() {
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *tlist = [[event allTouches] allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
-
if ([touches containsObject:[tlist objectAtIndex:i]]) {
-
UITouch *touch = [tlist objectAtIndex:i];
if (touch.phase != UITouchPhaseEnded)
continue;
@@ -541,7 +525,6 @@ static void clear_touches() {
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
-
OSIPhone::get_singleton()->touches_cancelled();
clear_touches();
};
@@ -599,7 +582,6 @@ static void clear_touches() {
NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
switch (routeChangeReason) {
-
case AVAudioSessionRouteChangeReasonNewDeviceAvailable: {
NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable");
NSLog(@"Headphone/Line plugged in");
@@ -609,7 +591,6 @@ static void clear_touches() {
NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable");
NSLog(@"Headphone/Line was pulled. Resuming video play....");
if (_is_video_playing()) {
-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[_instance.avPlayer play]; // NOTE: change this line according your current player implementation
NSLog(@"resumed play");
@@ -685,7 +666,6 @@ static void clear_touches() {
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
-
if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
_stop_video();
@@ -695,7 +675,6 @@ static void clear_touches() {
if (_instance.avPlayer.status == AVPlayerStatusReadyToPlay &&
_instance.avPlayerItem.status == AVPlayerItemStatusReadyToPlay &&
CMTIME_COMPARE_INLINE(video_current_time, ==, kCMTimeZero)) {
-
//NSLog(@"time: %@", video_current_time);
[_instance.avPlayer seekToTime:video_current_time];
diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp
index cea0e5c7f0..b9d217c9d2 100644
--- a/platform/iphone/godot_iphone.cpp
+++ b/platform/iphone/godot_iphone.cpp
@@ -46,7 +46,6 @@ int add_cmdline(int p_argc, char **p_args);
int iphone_main(int, int, int, char **, String);
int iphone_main(int width, int height, int argc, char **argv, String data_dir) {
-
size_t len = strlen(argv[0]);
while (len--) {
@@ -86,7 +85,6 @@ int iphone_main(int width, int height, int argc, char **argv, String data_dir) {
};
void iphone_finish() {
-
printf("iphone_finish\n");
Main::cleanup();
delete os;
diff --git a/platform/iphone/icloud.h b/platform/iphone/icloud.h
index 401a6cbeb8..b11e22fec6 100644
--- a/platform/iphone/icloud.h
+++ b/platform/iphone/icloud.h
@@ -36,7 +36,6 @@
#include "core/object.h"
class ICloud : public Object {
-
GDCLASS(ICloud, Object);
static ICloud *instance;
diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm
index 251f78f2da..c768274b1f 100644
--- a/platform/iphone/icloud.mm
+++ b/platform/iphone/icloud.mm
@@ -58,12 +58,10 @@ void ICloud::_bind_methods() {
};
int ICloud::get_pending_event_count() {
-
return pending_events.size();
};
Variant ICloud::pop_pending_event() {
-
Variant front = pending_events.front()->get();
pending_events.pop_front();
@@ -284,6 +282,7 @@ Error ICloud::synchronize_key_values() {
return FAILED;
}
}
+
/*
Error ICloud::initial_sync() {
//you sometimes have to write something to the store to get it to download new data. go apple!
@@ -298,6 +297,7 @@ Error ICloud::initial_sync() {
}
return synchronize();
}
+
*/
ICloud::ICloud() {
ERR_FAIL_COND(instance != NULL);
@@ -354,6 +354,6 @@ ICloud::ICloud() {
}];
}
-ICloud::~ICloud(){};
+ICloud::~ICloud() {}
#endif
diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h
index 493877a5a7..44e65e77ed 100644
--- a/platform/iphone/in_app_store.h
+++ b/platform/iphone/in_app_store.h
@@ -36,7 +36,6 @@
#include "core/object.h"
class InAppStore : public Object {
-
GDCLASS(InAppStore, Object);
static InAppStore *instance;
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index a8a887824f..a2efd6691b 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -57,6 +57,7 @@ NSMutableDictionary *pending_transactions = [NSMutableDictionary dictionary];
[numberFormatter release];
return formattedString;
}
+
@end
InAppStore *InAppStore::instance = NULL;
@@ -80,7 +81,6 @@ void InAppStore::_bind_methods() {
@implementation ProductsDelegate
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
-
NSArray *products = response.products;
Dictionary ret;
ret["type"] = "product_info";
@@ -93,7 +93,6 @@ void InAppStore::_bind_methods() {
PackedStringArray currency_codes;
for (NSUInteger i = 0; i < [products count]; i++) {
-
SKProduct *product = [products objectAtIndex:i];
const char *str = [product.localizedTitle UTF8String];
@@ -116,7 +115,6 @@ void InAppStore::_bind_methods() {
PackedStringArray invalid_ids;
for (NSString *ipid in response.invalidProductIdentifiers) {
-
invalid_ids.push_back(String::utf8([ipid UTF8String]));
};
ret["invalid_ids"] = invalid_ids;
@@ -129,7 +127,6 @@ void InAppStore::_bind_methods() {
@end
Error InAppStore::request_product_info(Variant p_params) {
-
Dictionary params = p_params;
ERR_FAIL_COND_V(!params.has("product_ids"), ERR_INVALID_PARAMETER);
@@ -155,7 +152,6 @@ Error InAppStore::request_product_info(Variant p_params) {
};
Error InAppStore::restore_purchases() {
-
printf("restoring purchases!\n");
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
@@ -169,10 +165,8 @@ Error InAppStore::restore_purchases() {
@implementation TransObserver
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
-
printf("transactions updated!\n");
for (SKPaymentTransaction *transaction in transactions) {
-
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased: {
printf("status purchased!\n");
@@ -189,11 +183,9 @@ Error InAppStore::restore_purchases() {
int sdk_version = 6;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
-
NSURL *receiptFileURL = nil;
NSBundle *bundle = [NSBundle mainBundle];
if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) {
-
// Get the transaction receipt file path location in the app bundle.
receiptFileURL = [bundle appStoreReceiptURL];
@@ -263,7 +255,6 @@ Error InAppStore::restore_purchases() {
@end
Error InAppStore::purchase(Variant p_params) {
-
ERR_FAIL_COND_V(![SKPaymentQueue canMakePayments], ERR_UNAVAILABLE);
if (![SKPaymentQueue canMakePayments])
return ERR_UNAVAILABLE;
@@ -286,7 +277,6 @@ int InAppStore::get_pending_event_count() {
};
Variant InAppStore::pop_pending_event() {
-
Variant front = pending_events.front()->get();
pending_events.pop_front();
@@ -294,12 +284,10 @@ Variant InAppStore::pop_pending_event() {
};
void InAppStore::_post_event(Variant p_event) {
-
pending_events.push_back(p_event);
};
void InAppStore::_record_purchase(String product_id) {
-
String skey = "purchased/" + product_id;
NSString *key = [[[NSString alloc] initWithUTF8String:skey.utf8().get_data()] autorelease];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:key];
@@ -307,7 +295,6 @@ void InAppStore::_record_purchase(String product_id) {
};
InAppStore *InAppStore::get_singleton() {
-
return instance;
};
@@ -334,6 +321,6 @@ void InAppStore::set_auto_finish_transaction(bool b) {
auto_finish_transactions = b;
}
-InAppStore::~InAppStore(){};
+InAppStore::~InAppStore() {}
#endif
diff --git a/platform/iphone/ios.h b/platform/iphone/ios.h
index 1378fdbbc5..2b29e6f268 100644
--- a/platform/iphone/ios.h
+++ b/platform/iphone/ios.h
@@ -34,7 +34,6 @@
#include "core/object.h"
class iOS : public Object {
-
GDCLASS(iOS, Object);
static void _bind_methods();
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index 2656f125b9..5923f558a5 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -34,7 +34,6 @@
#import <UIKit/UIKit.h>
void iOS::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url);
};
@@ -81,4 +80,4 @@ String iOS::get_rate_url(int p_app_id) const {
return ret;
};
-iOS::iOS(){};
+iOS::iOS() {}
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 3ef521a61a..41dd623e69 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -58,12 +58,10 @@
#include <dlfcn.h>
int OSIPhone::get_video_driver_count() const {
-
return 2;
};
const char *OSIPhone::get_video_driver_name(int p_driver) const {
-
switch (p_driver) {
case VIDEO_DRIVER_GLES2:
return "GLES2";
@@ -72,14 +70,12 @@ const char *OSIPhone::get_video_driver_name(int p_driver) const {
};
OSIPhone *OSIPhone::get_singleton() {
-
return (OSIPhone *)OS::get_singleton();
};
extern int gl_view_base_fb; // from gl_view.mm
void OSIPhone::set_data_dir(String p_dir) {
-
DirAccess *da = DirAccess::open(p_dir);
data_dir = da->get_current_dir();
@@ -88,17 +84,14 @@ void OSIPhone::set_data_dir(String p_dir) {
};
void OSIPhone::set_unique_id(String p_id) {
-
unique_id = p_id;
};
String OSIPhone::get_unique_id() const {
-
return unique_id;
};
void OSIPhone::initialize_core() {
-
OS_Unix::initialize_core();
set_data_dir(data_dir);
@@ -174,12 +167,10 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p
};
MainLoop *OSIPhone::get_main_loop() const {
-
return main_loop;
};
void OSIPhone::set_main_loop(MainLoop *p_main_loop) {
-
main_loop = p_main_loop;
if (main_loop) {
@@ -189,13 +180,11 @@ void OSIPhone::set_main_loop(MainLoop *p_main_loop) {
};
bool OSIPhone::iterate() {
-
if (!main_loop)
return true;
if (main_loop) {
for (int i = 0; i < event_count; i++) {
-
input->parse_input_event(event_queue[i]);
};
};
@@ -205,7 +194,6 @@ bool OSIPhone::iterate() {
};
void OSIPhone::key(uint32_t p_key, bool p_pressed) {
-
Ref<InputEventKey> ev;
ev.instance();
ev->set_echo(false);
@@ -217,7 +205,6 @@ void OSIPhone::key(uint32_t p_key, bool p_pressed) {
};
void OSIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick) {
-
if (!GLOBAL_DEF("debug/disable_touch", false)) {
Ref<InputEventScreenTouch> ev;
ev.instance();
@@ -232,9 +219,7 @@ void OSIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_d
};
void OSIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) {
-
if (!GLOBAL_DEF("debug/disable_touch", false)) {
-
Ref<InputEventScreenDrag> ev;
ev.instance();
ev->set_index(p_idx);
@@ -245,18 +230,14 @@ void OSIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
};
void OSIPhone::queue_event(const Ref<InputEvent> &p_event) {
-
ERR_FAIL_INDEX(event_count, MAX_EVENTS);
event_queue[event_count++] = p_event;
};
void OSIPhone::touches_cancelled() {
-
for (int i = 0; i < MAX_MOUSE_COUNT; i++) {
-
if (touch_list.pressed[i]) {
-
// send a mouse_up outside the screen
touch_press(i, -1, -1, false, false);
};
@@ -270,7 +251,6 @@ void OSIPhone::update_gravity(float p_x, float p_y, float p_z) {
};
void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
-
// Found out the Z should not be negated! Pass as is!
input->set_accelerometer(Vector3(p_x / (float)ACCEL_RANGE, p_y / (float)ACCEL_RANGE, p_z / (float)ACCEL_RANGE));
@@ -333,7 +313,6 @@ void OSIPhone::joy_axis(int p_device, int p_axis, const InputDefault::JoyAxis &p
};
void OSIPhone::delete_main_loop() {
-
if (main_loop) {
main_loop->finish();
memdelete(main_loop);
@@ -343,7 +322,6 @@ void OSIPhone::delete_main_loop() {
};
void OSIPhone::finalize() {
-
delete_main_loop();
memdelete(input);
@@ -372,28 +350,24 @@ void OSIPhone::finalize() {
event_count = 0;
};
-void OSIPhone::set_mouse_show(bool p_show){};
-void OSIPhone::set_mouse_grab(bool p_grab){};
+void OSIPhone::set_mouse_show(bool p_show) {}
+void OSIPhone::set_mouse_grab(bool p_grab) {}
bool OSIPhone::is_mouse_grab_enabled() const {
-
return true;
};
Point2 OSIPhone::get_mouse_position() const {
-
return Point2();
};
int OSIPhone::get_mouse_button_state() const {
-
return 0;
};
-void OSIPhone::set_window_title(const String &p_title){};
+void OSIPhone::set_window_title(const String &p_title) {}
void OSIPhone::alert(const String &p_alert, const String &p_title) {
-
const CharString utf8_alert = p_alert.utf8();
const CharString utf8_title = p_title.utf8();
iOS::alert(utf8_alert.get_data(), utf8_title.get_data());
@@ -431,22 +405,18 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const
}
void OSIPhone::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
-
video_mode = p_video_mode;
};
OS::VideoMode OSIPhone::get_video_mode(int p_screen) const {
-
return video_mode;
};
void OSIPhone::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
-
p_list->push_back(video_mode);
};
bool OSIPhone::can_draw() const {
-
if (native_video_is_playing())
return false;
return true;
@@ -471,7 +441,7 @@ extern Error _shell_open(String p_uri);
extern void _set_keep_screen_on(bool p_enabled);
extern void _vibrate();
-void OSIPhone::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length) {
+void OSIPhone::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
_show_keyboard(p_existing_text);
};
@@ -497,17 +467,14 @@ void OSIPhone::set_keep_screen_on(bool p_enabled) {
};
String OSIPhone::get_user_data_dir() const {
-
return data_dir;
};
String OSIPhone::get_name() const {
-
return "iOS";
};
String OSIPhone::get_model_name() const {
-
String model = ios->get_model();
if (model != "")
return model;
@@ -516,7 +483,6 @@ String OSIPhone::get_model_name() const {
}
Size2 OSIPhone::get_window_size() const {
-
return Vector2(video_mode.width, video_mode.height);
}
@@ -527,7 +493,6 @@ Rect2 OSIPhone::get_window_safe_area() const {
}
bool OSIPhone::has_touchscreen_ui_hint() const {
-
return true;
}
@@ -600,7 +565,6 @@ void OSIPhone::vibrate_handheld(int p_duration_ms) {
}
bool OSIPhone::_check_internal_feature_support(const String &p_feature) {
-
return p_feature == "mobile";
}
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index eb94e1d69b..955eb15d57 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -50,7 +50,6 @@
#endif
class OSIPhone : public OS_Unix {
-
private:
enum {
MAX_MOUSE_COUNT = 8,
@@ -99,7 +98,6 @@ private:
virtual void finalize();
struct MouseList {
-
bool pressed[MAX_MOUSE_COUNT];
MouseList() {
for (int i = 0; i < MAX_MOUSE_COUNT; i++)
@@ -172,7 +170,7 @@ public:
virtual bool can_draw() const;
virtual bool has_virtual_keyboard() const;
- virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1);
+ virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1);
virtual void hide_virtual_keyboard();
virtual int get_virtual_keyboard_height() const;
diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm
index 465e38e45e..279bcc1226 100644
--- a/platform/iphone/view_controller.mm
+++ b/platform/iphone/view_controller.mm
@@ -40,7 +40,6 @@ int add_path(int, char **);
int add_cmdline(int, char **);
int add_path(int p_argc, char **p_args) {
-
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
if (!str)
return p_argc;
@@ -54,13 +53,11 @@ int add_path(int p_argc, char **p_args) {
};
int add_cmdline(int p_argc, char **p_args) {
-
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
if (!arr)
return p_argc;
for (int i = 0; i < [arr count]; i++) {
-
NSString *str = [arr objectAtIndex:i];
if (!str)
continue;
@@ -81,7 +78,6 @@ int add_cmdline(int p_argc, char **p_args) {
@implementation ViewController
- (void)didReceiveMemoryWarning {
-
printf("*********** did receive memory warning!\n");
};
diff --git a/platform/iphone/vulkan_context_iphone.h b/platform/iphone/vulkan_context_iphone.h
index 625e41f4b9..cadd701636 100644
--- a/platform/iphone/vulkan_context_iphone.h
+++ b/platform/iphone/vulkan_context_iphone.h
@@ -35,7 +35,6 @@
// #import <UIKit/UIKit.h>
class VulkanContextIPhone : public VulkanContext {
-
virtual const char *_get_platform_surface_extension() const;
public:
diff --git a/platform/iphone/vulkan_context_iphone.mm b/platform/iphone/vulkan_context_iphone.mm
index 701ac0d9bb..44c940dc3a 100644
--- a/platform/iphone/vulkan_context_iphone.mm
+++ b/platform/iphone/vulkan_context_iphone.mm
@@ -36,7 +36,6 @@ const char *VulkanContextIPhone::_get_platform_surface_extension() const {
}
int VulkanContextIPhone::window_create(void *p_window, int p_width, int p_height) {
-
VkIOSSurfaceCreateInfoMVK createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
createInfo.pNext = NULL;
diff --git a/platform/javascript/api/api.cpp b/platform/javascript/api/api.cpp
index 45cb82b351..9c73e5c4c4 100644
--- a/platform/javascript/api/api.cpp
+++ b/platform/javascript/api/api.cpp
@@ -35,26 +35,22 @@
static JavaScript *javascript_eval;
void register_javascript_api() {
-
ClassDB::register_virtual_class<JavaScript>();
javascript_eval = memnew(JavaScript);
Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval));
}
void unregister_javascript_api() {
-
memdelete(javascript_eval);
}
JavaScript *JavaScript::singleton = nullptr;
JavaScript *JavaScript::get_singleton() {
-
return singleton;
}
JavaScript::JavaScript() {
-
ERR_FAIL_COND_MSG(singleton != nullptr, "JavaScript singleton already exist.");
singleton = this;
}
@@ -62,13 +58,11 @@ JavaScript::JavaScript() {
JavaScript::~JavaScript() {}
void JavaScript::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, DEFVAL(false));
}
#if !defined(JAVASCRIPT_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED)
Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
-
return Variant();
}
#endif
diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp
index 690ce5ba47..b8914414e6 100644
--- a/platform/javascript/audio_driver_javascript.cpp
+++ b/platform/javascript/audio_driver_javascript.cpp
@@ -30,27 +30,25 @@
#include "audio_driver_javascript.h"
+#include "core/project_settings.h"
+
#include <emscripten.h>
AudioDriverJavaScript *AudioDriverJavaScript::singleton = nullptr;
const char *AudioDriverJavaScript::get_name() const {
-
return "JavaScript";
}
extern "C" EMSCRIPTEN_KEEPALIVE void audio_driver_js_mix() {
-
AudioDriverJavaScript::singleton->mix_to_js();
}
extern "C" EMSCRIPTEN_KEEPALIVE void audio_driver_process_capture(float sample) {
-
AudioDriverJavaScript::singleton->process_capture(sample);
}
void AudioDriverJavaScript::mix_to_js() {
-
int channel_count = get_total_channels_by_speaker_mode(get_speaker_mode());
int sample_count = memarr_len(internal_buffer) / channel_count;
int32_t *stream_buffer = reinterpret_cast<int32_t *>(internal_buffer);
@@ -61,45 +59,41 @@ void AudioDriverJavaScript::mix_to_js() {
}
void AudioDriverJavaScript::process_capture(float sample) {
-
int32_t sample32 = int32_t(sample * 32768.f) * (1U << 16);
input_buffer_write(sample32);
}
Error AudioDriverJavaScript::init() {
+ int mix_rate = GLOBAL_GET("audio/mix_rate");
+ int latency = GLOBAL_GET("audio/output_latency");
/* clang-format off */
_driver_id = EM_ASM_INT({
+ const MIX_RATE = $0;
+ const LATENCY = $1 / 1000;
return Module.IDHandler.add({
- 'context': new (window.AudioContext || window.webkitAudioContext),
+ 'context': new (window.AudioContext || window.webkitAudioContext)({ sampleRate: MIX_RATE, latencyHint: LATENCY}),
'input': null,
'stream': null,
'script': null
});
- });
+ }, mix_rate, latency);
/* clang-format on */
int channel_count = get_total_channels_by_speaker_mode(get_speaker_mode());
+ buffer_length = closest_power_of_2((latency * mix_rate / 1000) * channel_count);
/* clang-format off */
buffer_length = EM_ASM_INT({
var ref = Module.IDHandler.get($0);
- var ctx = ref['context'];
- var CHANNEL_COUNT = $1;
-
- var channelCount = ctx.destination.channelCount;
- var script = null;
- try {
- // Try letting the browser recommend a buffer length.
- script = ctx.createScriptProcessor(0, 2, channelCount);
- } catch (e) {
- // ...otherwise, default to 4096.
- script = ctx.createScriptProcessor(4096, 2, channelCount);
- }
+ const ctx = ref['context'];
+ const BUFFER_LENGTH = $1;
+ const CHANNEL_COUNT = $2;
+
+ var script = ctx.createScriptProcessor(BUFFER_LENGTH, 2, CHANNEL_COUNT);
script.connect(ctx.destination);
ref['script'] = script;
-
return script.bufferSize;
- }, _driver_id, channel_count);
+ }, _driver_id, buffer_length, channel_count);
/* clang-format on */
if (!buffer_length) {
return FAILED;
@@ -115,7 +109,6 @@ Error AudioDriverJavaScript::init() {
}
void AudioDriverJavaScript::start() {
-
/* clang-format off */
EM_ASM({
const ref = Module.IDHandler.get($0);
@@ -163,8 +156,26 @@ void AudioDriverJavaScript::resume() {
/* clang-format on */
}
-int AudioDriverJavaScript::get_mix_rate() const {
+float AudioDriverJavaScript::get_latency() {
+ /* clang-format off */
+ return EM_ASM_DOUBLE({
+ const ref = Module.IDHandler.get($0);
+ var latency = 0;
+ if (ref && ref['context']) {
+ const ctx = ref['context'];
+ if (ctx.baseLatency) {
+ latency += ctx.baseLatency;
+ }
+ if (ctx.outputLatency) {
+ latency += ctx.outputLatency;
+ }
+ }
+ return latency;
+ }, _driver_id);
+ /* clang-format on */
+}
+int AudioDriverJavaScript::get_mix_rate() const {
/* clang-format off */
return EM_ASM_INT({
const ref = Module.IDHandler.get($0);
@@ -174,7 +185,6 @@ int AudioDriverJavaScript::get_mix_rate() const {
}
AudioDriver::SpeakerMode AudioDriverJavaScript::get_speaker_mode() const {
-
/* clang-format off */
return get_speaker_mode_by_total_channels(EM_ASM_INT({
const ref = Module.IDHandler.get($0);
@@ -191,7 +201,6 @@ void AudioDriverJavaScript::unlock() {
}
void AudioDriverJavaScript::finish_async() {
-
// Close the context, add the operation to the async_finish list in module.
int id = _driver_id;
_driver_id = 0;
@@ -230,7 +239,6 @@ void AudioDriverJavaScript::finish() {
}
Error AudioDriverJavaScript::capture_start() {
-
input_buffer_init(buffer_length);
/* clang-format off */
@@ -260,7 +268,6 @@ Error AudioDriverJavaScript::capture_start() {
}
Error AudioDriverJavaScript::capture_stop() {
-
/* clang-format off */
EM_ASM({
var ref = Module.IDHandler.get($0);
@@ -286,7 +293,6 @@ Error AudioDriverJavaScript::capture_stop() {
}
AudioDriverJavaScript::AudioDriverJavaScript() {
-
_driver_id = 0;
internal_buffer = nullptr;
buffer_length = 0;
diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h
index 4a44f4683f..9b26be001e 100644
--- a/platform/javascript/audio_driver_javascript.h
+++ b/platform/javascript/audio_driver_javascript.h
@@ -34,7 +34,6 @@
#include "servers/audio_server.h"
class AudioDriverJavaScript : public AudioDriver {
-
float *internal_buffer;
int _driver_id;
@@ -51,6 +50,7 @@ public:
virtual Error init();
virtual void start();
void resume();
+ virtual float get_latency();
virtual int get_mix_rate() const;
virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index c302614eca..0312efb377 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* display_server_javascript.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 "platform/javascript/display_server_javascript.h"
#include "drivers/dummy/rasterizer_dummy.h"
@@ -26,7 +56,6 @@ extern "C" EMSCRIPTEN_KEEPALIVE void _set_canvas_id(uint8_t *p_data, int p_data_
}
static void focus_canvas() {
-
/* clang-format off */
EM_ASM(
Module['canvas'].focus();
@@ -35,7 +64,6 @@ static void focus_canvas() {
}
static bool is_canvas_focused() {
-
/* clang-format off */
return EM_ASM_INT_V(
return document.activeElement == Module['canvas'];
@@ -66,7 +94,6 @@ static Point2 compute_position_in_canvas(int x, int y) {
static bool cursor_inside_canvas = true;
EM_BOOL DisplayServerJavaScript::fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data) {
-
DisplayServerJavaScript *display = get_singleton();
// Empty ID is canvas.
String target_id = String::utf8(p_event->id);
@@ -105,7 +132,6 @@ extern "C" EMSCRIPTEN_KEEPALIVE void _drop_files_callback(char *p_filev[], int p
template <typename T>
static void dom2godot_mod(T *emscripten_event_ptr, Ref<InputEventWithModifiers> godot_event) {
-
godot_event->set_shift(emscripten_event_ptr->shiftKey);
godot_event->set_alt(emscripten_event_ptr->altKey);
godot_event->set_control(emscripten_event_ptr->ctrlKey);
@@ -113,13 +139,12 @@ static void dom2godot_mod(T *emscripten_event_ptr, Ref<InputEventWithModifiers>
}
static Ref<InputEventKey> setup_key_event(const EmscriptenKeyboardEvent *emscripten_event) {
-
Ref<InputEventKey> ev;
ev.instance();
ev->set_echo(emscripten_event->repeat);
dom2godot_mod(emscripten_event, ev);
- ev->set_keycode(dom2godot_keycode(emscripten_event->keyCode));
- ev->set_physical_keycode(dom2godot_keycode(emscripten_event->keyCode));
+ ev->set_keycode(dom_code2godot_scancode(emscripten_event->code, emscripten_event->key, false));
+ ev->set_physical_keycode(dom_code2godot_scancode(emscripten_event->code, emscripten_event->key, true));
String unicode = String::utf8(emscripten_event->key);
// Check if empty or multi-character (e.g. `CapsLock`).
@@ -135,7 +160,6 @@ static Ref<InputEventKey> setup_key_event(const EmscriptenKeyboardEvent *emscrip
}
EM_BOOL DisplayServerJavaScript::keydown_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data) {
-
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(true);
@@ -150,7 +174,6 @@ EM_BOOL DisplayServerJavaScript::keydown_callback(int p_event_type, const Emscri
}
EM_BOOL DisplayServerJavaScript::keypress_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data) {
-
DisplayServerJavaScript *display = get_singleton();
display->deferred_key_event->set_unicode(p_event->charCode);
Input::get_singleton()->parse_input_event(display->deferred_key_event);
@@ -158,7 +181,6 @@ EM_BOOL DisplayServerJavaScript::keypress_callback(int p_event_type, const Emscr
}
EM_BOOL DisplayServerJavaScript::keyup_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data) {
-
Ref<InputEventKey> ev = setup_key_event(p_event);
ev->set_pressed(false);
Input::get_singleton()->parse_input_event(ev);
@@ -168,7 +190,6 @@ EM_BOOL DisplayServerJavaScript::keyup_callback(int p_event_type, const Emscript
// Mouse
EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const EmscriptenMouseEvent *p_event, void *p_user_data) {
-
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventMouseButton> ev;
@@ -199,13 +220,10 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
}
if (ev->is_pressed()) {
-
double diff = emscripten_get_now() - display->last_click_ms;
if (ev->get_button_index() == display->last_click_button_index) {
-
if (diff < 400 && Point2(display->last_click_pos).distance_to(ev->get_position()) < 5) {
-
display->last_click_ms = 0;
display->last_click_pos = Point2(-100, -100);
display->last_click_button_index = -1;
@@ -245,7 +263,6 @@ EM_BOOL DisplayServerJavaScript::mouse_button_callback(int p_event_type, const E
}
EM_BOOL DisplayServerJavaScript::mousemove_callback(int p_event_type, const EmscriptenMouseEvent *p_event, void *p_user_data) {
-
Input *input = Input::get_singleton();
int input_mask = input->get_mouse_button_mask();
Point2 pos = compute_position_in_canvas(p_event->clientX, p_event->clientY);
@@ -273,7 +290,6 @@ EM_BOOL DisplayServerJavaScript::mousemove_callback(int p_event_type, const Emsc
// Cursor
static const char *godot2dom_cursor(DisplayServer::CursorShape p_shape) {
-
switch (p_shape) {
case DisplayServer::CURSOR_ARROW:
return "auto";
@@ -315,7 +331,6 @@ static const char *godot2dom_cursor(DisplayServer::CursorShape p_shape) {
}
static void set_css_cursor(const char *p_cursor) {
-
/* clang-format off */
EM_ASM_({
Module['canvas'].style.cursor = UTF8ToString($0);
@@ -324,7 +339,6 @@ static void set_css_cursor(const char *p_cursor) {
}
static bool is_css_cursor_hidden() {
-
/* clang-format off */
return EM_ASM_INT({
return Module['canvas'].style.cursor === 'none';
@@ -333,7 +347,6 @@ static bool is_css_cursor_hidden() {
}
void DisplayServerJavaScript::cursor_set_shape(CursorShape p_shape) {
-
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
if (mouse_get_mode() == MOUSE_MODE_VISIBLE) {
@@ -353,9 +366,7 @@ DisplayServer::CursorShape DisplayServerJavaScript::cursor_get_shape() const {
}
void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
-
if (p_cursor.is_valid()) {
-
Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
if (cursor_c) {
@@ -483,25 +494,21 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso
// Mouse mode
void DisplayServerJavaScript::mouse_set_mode(MouseMode p_mode) {
-
ERR_FAIL_COND_MSG(p_mode == MOUSE_MODE_CONFINED, "MOUSE_MODE_CONFINED is not supported for the HTML5 platform.");
if (p_mode == mouse_get_mode())
return;
if (p_mode == MOUSE_MODE_VISIBLE) {
-
// set_css_cursor must be called before set_cursor_shape to make the cursor visible
set_css_cursor(godot2dom_cursor(cursor_shape));
cursor_set_shape(cursor_shape);
emscripten_exit_pointerlock();
} else if (p_mode == MOUSE_MODE_HIDDEN) {
-
set_css_cursor("none");
emscripten_exit_pointerlock();
} else if (p_mode == MOUSE_MODE_CAPTURED) {
-
EMSCRIPTEN_RESULT result = emscripten_request_pointerlock("canvas", false);
ERR_FAIL_COND_MSG(result == EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED, "MOUSE_MODE_CAPTURED can only be entered from within an appropriate input callback.");
ERR_FAIL_COND_MSG(result != EMSCRIPTEN_RESULT_SUCCESS, "MOUSE_MODE_CAPTURED can only be entered from within an appropriate input callback.");
@@ -512,7 +519,6 @@ void DisplayServerJavaScript::mouse_set_mode(MouseMode p_mode) {
}
DisplayServer::MouseMode DisplayServerJavaScript::mouse_get_mode() const {
-
if (is_css_cursor_hidden())
return MOUSE_MODE_HIDDEN;
@@ -524,7 +530,6 @@ DisplayServer::MouseMode DisplayServerJavaScript::mouse_get_mode() const {
// Wheel
EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const EmscriptenWheelEvent *p_event, void *p_user_data) {
-
ERR_FAIL_COND_V(p_event_type != EMSCRIPTEN_EVENT_WHEEL, false);
if (!is_canvas_focused()) {
if (cursor_inside_canvas) {
@@ -574,13 +579,11 @@ EM_BOOL DisplayServerJavaScript::wheel_callback(int p_event_type, const Emscript
// Touch
EM_BOOL DisplayServerJavaScript::touch_press_callback(int p_event_type, const EmscriptenTouchEvent *p_event, void *p_user_data) {
-
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventScreenTouch> ev;
ev.instance();
int lowest_id_index = -1;
for (int i = 0; i < p_event->numTouches; ++i) {
-
const EmscriptenTouchPoint &touch = p_event->touches[i];
if (lowest_id_index == -1 || touch.identifier < p_event->touches[lowest_id_index].identifier)
lowest_id_index = i;
@@ -598,13 +601,11 @@ EM_BOOL DisplayServerJavaScript::touch_press_callback(int p_event_type, const Em
}
EM_BOOL DisplayServerJavaScript::touchmove_callback(int p_event_type, const EmscriptenTouchEvent *p_event, void *p_user_data) {
-
DisplayServerJavaScript *display = get_singleton();
Ref<InputEventScreenDrag> ev;
ev.instance();
int lowest_id_index = -1;
for (int i = 0; i < p_event->numTouches; ++i) {
-
const EmscriptenTouchPoint &touch = p_event->touches[i];
if (lowest_id_index == -1 || touch.identifier < p_event->touches[lowest_id_index].identifier)
lowest_id_index = i;
@@ -628,10 +629,8 @@ bool DisplayServerJavaScript::screen_is_touchscreen(int p_screen) const {
// Gamepad
EM_BOOL DisplayServerJavaScript::gamepad_change_callback(int p_event_type, const EmscriptenGamepadEvent *p_event, void *p_user_data) {
-
Input *input = Input::get_singleton();
if (p_event_type == EMSCRIPTEN_EVENT_GAMEPADCONNECTED) {
-
String guid = "";
if (String::utf8(p_event->mapping) == "standard")
guid = "Default HTML5 Gamepad";
@@ -643,7 +642,6 @@ EM_BOOL DisplayServerJavaScript::gamepad_change_callback(int p_event_type, const
}
void DisplayServerJavaScript::process_joypads() {
-
int joypad_count = emscripten_get_num_gamepads();
Input *input = Input::get_singleton();
for (int joypad = 0; joypad < joypad_count; joypad++) {
@@ -653,16 +651,13 @@ void DisplayServerJavaScript::process_joypads() {
ERR_CONTINUE(query_result != EMSCRIPTEN_RESULT_SUCCESS &&
query_result != EMSCRIPTEN_RESULT_NO_DATA);
if (query_result == EMSCRIPTEN_RESULT_SUCCESS && state.connected) {
-
int button_count = MIN(state.numButtons, 18);
int axis_count = MIN(state.numAxes, 8);
for (int button = 0; button < button_count; button++) {
-
float value = state.analogButton[button];
input->joy_button(joypad, button, value);
}
for (int axis = 0; axis < axis_count; axis++) {
-
Input::JoyAxis joy_axis;
joy_axis.min = -1;
joy_axis.value = state.axis[axis];
@@ -678,6 +673,7 @@ bool DisplayServerJavaScript::is_joy_known(int p_device) {
return Input::get_singleton()->is_joy_mapped(p_device);
}
+
String DisplayServerJavaScript::get_joy_guid(int p_device) const {
return Input::get_singleton()->get_joy_guid_remapped(p_device);
@@ -730,7 +726,6 @@ String DisplayServerJavaScript::clipboard_get() const {
}
extern "C" EMSCRIPTEN_KEEPALIVE void send_window_event(int p_notification) {
-
if (p_notification == DisplayServer::WINDOW_EVENT_MOUSE_ENTER || p_notification == DisplayServer::WINDOW_EVENT_MOUSE_EXIT) {
cursor_inside_canvas = p_notification == DisplayServer::WINDOW_EVENT_MOUSE_ENTER;
}
@@ -748,7 +743,6 @@ extern "C" EMSCRIPTEN_KEEPALIVE void send_window_event(int p_notification) {
}
void DisplayServerJavaScript::alert(const String &p_alert, const String &p_title) {
-
/* clang-format off */
EM_ASM_({
window.alert(UTF8ToString($0));
@@ -757,7 +751,6 @@ void DisplayServerJavaScript::alert(const String &p_alert, const String &p_title
}
void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) {
-
ERR_FAIL_COND(p_icon.is_null());
Ref<Image> icon = p_icon;
if (icon->is_compressed()) {
@@ -827,7 +820,6 @@ DisplayServer *DisplayServerJavaScript::create_func(const String &p_rendering_dr
}
DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
-
/* clang-format off */
EM_ASM({
const canvas = Module['canvas'];
@@ -1012,7 +1004,6 @@ Point2i DisplayServerJavaScript::screen_get_position(int p_screen) const {
}
Size2i DisplayServerJavaScript::screen_get_size(int p_screen) const {
-
EmscriptenFullscreenChangeEvent ev;
EMSCRIPTEN_RESULT result = emscripten_get_fullscreen_status(&ev);
ERR_FAIL_COND_V(result != EMSCRIPTEN_RESULT_SUCCESS, Size2i());
@@ -1086,6 +1077,7 @@ void DisplayServerJavaScript::window_set_current_screen(int p_screen, WindowID p
Point2i DisplayServerJavaScript::window_get_position(WindowID p_window) const {
return Point2i(); // TODO Does this need implementation?
}
+
void DisplayServerJavaScript::window_set_position(const Point2i &p_position, WindowID p_window) {
// Not supported.
}
diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h
index 73a7b017e6..9860ecdf98 100644
--- a/platform/javascript/display_server_javascript.h
+++ b/platform/javascript/display_server_javascript.h
@@ -37,7 +37,6 @@
#include <emscripten/html5.h>
class DisplayServerJavaScript : public DisplayServer {
-
//int video_driver_index;
Vector2 windowed_size;
diff --git a/platform/javascript/dom_keys.inc b/platform/javascript/dom_keys.inc
index 42d394fd4f..e3f2ce42b4 100644
--- a/platform/javascript/dom_keys.inc
+++ b/platform/javascript/dom_keys.inc
@@ -30,401 +30,203 @@
#include "core/os/keyboard.h"
-// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#Constants_for_keyCode_value
-#define DOM_VK_CANCEL 0x03
-#define DOM_VK_HELP 0x06
-#define DOM_VK_BACK_SPACE 0x08
-#define DOM_VK_TAB 0x09
-#define DOM_VK_CLEAR 0x0C
-#define DOM_VK_RETURN 0x0D
-#define DOM_VK_ENTER 0x0E // "Reserved, but not used."
-#define DOM_VK_SHIFT 0x10
-#define DOM_VK_CONTROL 0x11
-#define DOM_VK_ALT 0x12
-#define DOM_VK_PAUSE 0x13
-#define DOM_VK_CAPS_LOCK 0x14
-#define DOM_VK_KANA 0x15
-#define DOM_VK_HANGUL 0x15
-#define DOM_VK_EISU 0x16
-#define DOM_VK_JUNJA 0x17
-#define DOM_VK_FINAL 0x18
-#define DOM_VK_HANJA 0x19
-#define DOM_VK_KANJI 0x19
-#define DOM_VK_ESCAPE 0x1B
-#define DOM_VK_CONVERT 0x1C
-#define DOM_VK_NONCONVERT 0x1D
-#define DOM_VK_ACCEPT 0x1E
-#define DOM_VK_MODECHANGE 0x1F
-#define DOM_VK_SPACE 0x20
-#define DOM_VK_PAGE_UP 0x21
-#define DOM_VK_PAGE_DOWN 0x22
-#define DOM_VK_END 0x23
-#define DOM_VK_HOME 0x24
-#define DOM_VK_LEFT 0x25
-#define DOM_VK_UP 0x26
-#define DOM_VK_RIGHT 0x27
-#define DOM_VK_DOWN 0x28
-#define DOM_VK_SELECT 0x29
-#define DOM_VK_PRINT 0x2A
-#define DOM_VK_EXECUTE 0x2B
-#define DOM_VK_PRINTSCREEN 0x2C
-#define DOM_VK_INSERT 0x2D
-#define DOM_VK_DELETE 0x2E
-#define DOM_VK_0 0x30
-#define DOM_VK_1 0x31
-#define DOM_VK_2 0x32
-#define DOM_VK_3 0x33
-#define DOM_VK_4 0x34
-#define DOM_VK_5 0x35
-#define DOM_VK_6 0x36
-#define DOM_VK_7 0x37
-#define DOM_VK_8 0x38
-#define DOM_VK_9 0x39
-#define DOM_VK_COLON 0x3A
-#define DOM_VK_SEMICOLON 0x3B
-#define DOM_VK_LESS_THAN 0x3C
-#define DOM_VK_EQUALS 0x3D
-#define DOM_VK_GREATER_THAN 0x3E
-#define DOM_VK_QUESTION_MARK 0x3F
-#define DOM_VK_AT 0x40
-#define DOM_VK_A 0x41
-#define DOM_VK_B 0x42
-#define DOM_VK_C 0x43
-#define DOM_VK_D 0x44
-#define DOM_VK_E 0x45
-#define DOM_VK_F 0x46
-#define DOM_VK_G 0x47
-#define DOM_VK_H 0x48
-#define DOM_VK_I 0x49
-#define DOM_VK_J 0x4A
-#define DOM_VK_K 0x4B
-#define DOM_VK_L 0x4C
-#define DOM_VK_M 0x4D
-#define DOM_VK_N 0x4E
-#define DOM_VK_O 0x4F
-#define DOM_VK_P 0x50
-#define DOM_VK_Q 0x51
-#define DOM_VK_R 0x52
-#define DOM_VK_S 0x53
-#define DOM_VK_T 0x54
-#define DOM_VK_U 0x55
-#define DOM_VK_V 0x56
-#define DOM_VK_W 0x57
-#define DOM_VK_X 0x58
-#define DOM_VK_Y 0x59
-#define DOM_VK_Z 0x5A
-#define DOM_VK_WIN 0x5B
-#define DOM_VK_CONTEXT_MENU 0x5D
-#define DOM_VK_SLEEP 0x5F
-#define DOM_VK_NUMPAD0 0x60
-#define DOM_VK_NUMPAD1 0x61
-#define DOM_VK_NUMPAD2 0x62
-#define DOM_VK_NUMPAD3 0x63
-#define DOM_VK_NUMPAD4 0x64
-#define DOM_VK_NUMPAD5 0x65
-#define DOM_VK_NUMPAD6 0x66
-#define DOM_VK_NUMPAD7 0x67
-#define DOM_VK_NUMPAD8 0x68
-#define DOM_VK_NUMPAD9 0x69
-#define DOM_VK_MULTIPLY 0x6A
-#define DOM_VK_ADD 0x6B
-#define DOM_VK_SEPARATOR 0x6C
-#define DOM_VK_SUBTRACT 0x6D
-#define DOM_VK_DECIMAL 0x6E
-#define DOM_VK_DIVIDE 0x6F
-#define DOM_VK_F1 0x70
-#define DOM_VK_F2 0x71
-#define DOM_VK_F3 0x72
-#define DOM_VK_F4 0x73
-#define DOM_VK_F5 0x74
-#define DOM_VK_F6 0x75
-#define DOM_VK_F7 0x76
-#define DOM_VK_F8 0x77
-#define DOM_VK_F9 0x78
-#define DOM_VK_F10 0x79
-#define DOM_VK_F11 0x7A
-#define DOM_VK_F12 0x7B
-#define DOM_VK_F13 0x7C
-#define DOM_VK_F14 0x7D
-#define DOM_VK_F15 0x7E
-#define DOM_VK_F16 0x7F
-#define DOM_VK_F17 0x80
-#define DOM_VK_F18 0x81
-#define DOM_VK_F19 0x82
-#define DOM_VK_F20 0x83
-#define DOM_VK_F21 0x84
-#define DOM_VK_F22 0x85
-#define DOM_VK_F23 0x86
-#define DOM_VK_F24 0x87
-#define DOM_VK_NUM_LOCK 0x90
-#define DOM_VK_SCROLL_LOCK 0x91
-#define DOM_VK_WIN_OEM_FJ_JISHO 0x92
-#define DOM_VK_WIN_OEM_FJ_MASSHOU 0x93
-#define DOM_VK_WIN_OEM_FJ_TOUROKU 0x94
-#define DOM_VK_WIN_OEM_FJ_LOYA 0x95
-#define DOM_VK_WIN_OEM_FJ_ROYA 0x96
-#define DOM_VK_CIRCUMFLEX 0xA0
-#define DOM_VK_EXCLAMATION 0xA1
-#define DOM_VK_DOUBLE_QUOTE 0xA2
-#define DOM_VK_HASH 0xA3
-#define DOM_VK_DOLLAR 0xA4
-#define DOM_VK_PERCENT 0xA5
-#define DOM_VK_AMPERSAND 0xA6
-#define DOM_VK_UNDERSCORE 0xA7
-#define DOM_VK_OPEN_PAREN 0xA8
-#define DOM_VK_CLOSE_PAREN 0xA9
-#define DOM_VK_ASTERISK 0xAA
-#define DOM_VK_PLUS 0xAB
-#define DOM_VK_PIPE 0xAC
-#define DOM_VK_HYPHEN_MINUS 0xAD
-#define DOM_VK_OPEN_CURLY_BRACKET 0xAE
-#define DOM_VK_CLOSE_CURLY_BRACKET 0xAF
-#define DOM_VK_TILDE 0xB0
-#define DOM_VK_VOLUME_MUTE 0xB5
-#define DOM_VK_VOLUME_DOWN 0xB6
-#define DOM_VK_VOLUME_UP 0xB7
-#define DOM_VK_COMMA 0xBC
-#define DOM_VK_PERIOD 0xBE
-#define DOM_VK_SLASH 0xBF
-#define DOM_VK_BACK_QUOTE 0xC0
-#define DOM_VK_OPEN_BRACKET 0xDB
-#define DOM_VK_BACK_SLASH 0xDC
-#define DOM_VK_CLOSE_BRACKET 0xDD
-#define DOM_VK_QUOTE 0xDE
-#define DOM_VK_META 0xE0
-#define DOM_VK_ALTGR 0xE1
-#define DOM_VK_WIN_ICO_HELP 0xE3
-#define DOM_VK_WIN_ICO_00 0xE4
-#define DOM_VK_WIN_ICO_CLEAR 0xE6
-#define DOM_VK_WIN_OEM_RESET 0xE9
-#define DOM_VK_WIN_OEM_JUMP 0xEA
-#define DOM_VK_WIN_OEM_PA1 0xEB
-#define DOM_VK_WIN_OEM_PA2 0xEC
-#define DOM_VK_WIN_OEM_PA3 0xED
-#define DOM_VK_WIN_OEM_WSCTRL 0xEE
-#define DOM_VK_WIN_OEM_CUSEL 0xEF
-#define DOM_VK_WIN_OEM_ATTN 0xF0
-#define DOM_VK_WIN_OEM_FINISH 0xF1
-#define DOM_VK_WIN_OEM_COPY 0xF2
-#define DOM_VK_WIN_OEM_AUTO 0xF3
-#define DOM_VK_WIN_OEM_ENLW 0xF4
-#define DOM_VK_WIN_OEM_BACKTAB 0xF5
-#define DOM_VK_ATTN 0xF6
-#define DOM_VK_CRSEL 0xF7
-#define DOM_VK_EXSEL 0xF8
-#define DOM_VK_EREOF 0xF9
-#define DOM_VK_PLAY 0xFA
-#define DOM_VK_ZOOM 0xFB
-#define DOM_VK_PA1 0xFD
-#define DOM_VK_WIN_OEM_CLEAR 0xFE
-
-int dom2godot_keycode(int dom_keycode) {
-
- if (DOM_VK_0 <= dom_keycode && dom_keycode <= DOM_VK_Z) {
- // ASCII intersection
- return dom_keycode;
- }
-
- if (DOM_VK_NUMPAD0 <= dom_keycode && dom_keycode <= DOM_VK_NUMPAD9) {
- // Numpad numbers
- return KEY_KP_0 + (dom_keycode - DOM_VK_NUMPAD0);
+// See https://w3c.github.io/uievents-code/#code-value-tables
+int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) {
+#define DOM2GODOT(p_str, p_godot_code) \
+ if (memcmp((const void *)p_str, (void *)p_code, strlen(p_str) + 1) == 0) { \
+ return KEY_##p_godot_code; \
}
- if (DOM_VK_F1 <= dom_keycode && dom_keycode <= DOM_VK_F16) {
- // F1-F16
- return KEY_F1 + (dom_keycode - DOM_VK_F1);
+ // Numpad section.
+ DOM2GODOT("NumLock", NUMLOCK);
+ DOM2GODOT("Numpad0", KP_0);
+ DOM2GODOT("Numpad1", KP_1);
+ DOM2GODOT("Numpad2", KP_2);
+ DOM2GODOT("Numpad3", KP_3);
+ DOM2GODOT("Numpad4", KP_4);
+ DOM2GODOT("Numpad5", KP_5);
+ DOM2GODOT("Numpad6", KP_6);
+ DOM2GODOT("Numpad7", KP_7);
+ DOM2GODOT("Numpad8", KP_8);
+ DOM2GODOT("Numpad9", KP_9);
+ DOM2GODOT("NumpadAdd", KP_ADD);
+ DOM2GODOT("NumpadBackspace", BACKSPACE);
+ DOM2GODOT("NumpadClear", CLEAR);
+ DOM2GODOT("NumpadClearEntry", CLEAR);
+ //DOM2GODOT("NumpadComma", UNKNOWN);
+ DOM2GODOT("NumpadDecimal", KP_PERIOD);
+ DOM2GODOT("NumpadDivide", KP_DIVIDE);
+ DOM2GODOT("NumpadEnter", KP_ENTER);
+ DOM2GODOT("NumpadEqual", EQUAL);
+ //DOM2GODOT("NumpadHash", UNKNOWN);
+ //DOM2GODOT("NumpadMemoryAdd", UNKNOWN);
+ //DOM2GODOT("NumpadMemoryClear", UNKNOWN);
+ //DOM2GODOT("NumpadMemoryRecall", UNKNOWN);
+ //DOM2GODOT("NumpadMemoryStore", UNKNOWN);
+ //DOM2GODOT("NumpadMemorySubtract", UNKNOWN);
+ DOM2GODOT("NumpadMultiply", KP_MULTIPLY);
+ DOM2GODOT("NumpadParenLeft", PARENLEFT);
+ DOM2GODOT("NumpadParenRight", PARENRIGHT);
+ DOM2GODOT("NumpadStar", KP_MULTIPLY); // or ASTERISK ?
+ DOM2GODOT("NumpadSubtract", KP_SUBTRACT);
+
+ // Printable ASCII.
+ if (!p_physical) {
+ uint8_t b0 = (uint8_t)p_key[0];
+ uint8_t b1 = (uint8_t)p_key[1];
+ uint8_t b2 = (uint8_t)p_key[2];
+ if (b1 == 0 && b0 > 0x1F && b0 < 0x7F) { // ASCII.
+ if (b0 > 0x60 && b0 < 0x7B) { // Lowercase ASCII.
+ b0 -= 32;
+ }
+ return b0;
+ }
+
+#define _U_2BYTES_MASK 0xE0
+#define _U_2BYTES 0xC0
+ // Latin-1 codes.
+ if (b2 == 0 && (b0 & _U_2BYTES_MASK) == _U_2BYTES) { // 2-bytes utf8, only known latin.
+ uint32_t key = ((b0 & ~_U_2BYTES_MASK) << 6) | (b1 & 0x3F);
+ if (key >= 0xA0 && key <= 0xDF) {
+ return key;
+ }
+ if (key >= 0xE0 && key <= 0xFF) { // Lowercase known latin.
+ key -= 0x20;
+ return key;
+ }
+ }
+#undef _U_2BYTES_MASK
+#undef _U_2BYTES
}
- switch (dom_keycode) {
- //case DOM_VK_CANCEL: return KEY_UNKNOWN;
- case DOM_VK_HELP:
- return KEY_HELP;
- case DOM_VK_BACK_SPACE:
- return KEY_BACKSPACE;
- case DOM_VK_TAB:
- return KEY_TAB;
-
- case DOM_VK_CLEAR:
- case DOM_VK_WIN_OEM_CLEAR: // OEM duplicate
- return KEY_CLEAR;
-
- case DOM_VK_RETURN:
- case DOM_VK_ENTER: // unused according to MDN
- return KEY_ENTER;
-
- case DOM_VK_SHIFT:
- return KEY_SHIFT;
- case DOM_VK_CONTROL:
- return KEY_CONTROL;
-
- case DOM_VK_ALT:
- case DOM_VK_ALTGR:
- return KEY_ALT;
-
- case DOM_VK_PAUSE:
- return KEY_PAUSE;
- case DOM_VK_CAPS_LOCK:
- return KEY_CAPSLOCK;
-
- /*
- case DOM_VK_KANA: return KEY_UNKNOWN;
- case DOM_VK_HANGUL: return KEY_UNKNOWN;
- case DOM_VK_EISU: return KEY_UNKNOWN;
- case DOM_VK_JUNJA: return KEY_UNKNOWN;
- case DOM_VK_FINAL: return KEY_UNKNOWN;
- case DOM_VK_HANJA: return KEY_UNKNOWN;
- case DOM_VK_KANJI: return KEY_UNKNOWN;
- */
-
- case DOM_VK_ESCAPE:
- return KEY_ESCAPE;
- /*
- case DOM_VK_CONVERT: return KEY_UNKNOWN;
- case DOM_VK_NONCONVERT: return KEY_UNKNOWN;
- case DOM_VK_ACCEPT: return KEY_UNKNOWN;
- case DOM_VK_MODECHANGE: return KEY_UNKNOWN;
- */
-
- case DOM_VK_SPACE:
- return KEY_SPACE;
- case DOM_VK_PAGE_UP:
- return KEY_PAGEUP;
- case DOM_VK_PAGE_DOWN:
- return KEY_PAGEDOWN;
- case DOM_VK_END:
- return KEY_END;
- case DOM_VK_HOME:
- return KEY_HOME;
- case DOM_VK_LEFT:
- return KEY_LEFT;
- case DOM_VK_UP:
- return KEY_UP;
- case DOM_VK_RIGHT:
- return KEY_RIGHT;
- case DOM_VK_DOWN:
- return KEY_DOWN;
-
- //case DOM_VK_SELECT: return KEY_UNKNOWN;
-
- case DOM_VK_PRINTSCREEN:
- case DOM_VK_PRINT:
- return KEY_PRINT;
-
- //case DOM_VK_EXECUTE: return KEY_UNKNOWN;
- case DOM_VK_INSERT:
- return KEY_INSERT;
- case DOM_VK_DELETE:
- return KEY_DELETE;
-
- case DOM_VK_META:
- case DOM_VK_WIN:
- return KEY_META;
-
- case DOM_VK_CONTEXT_MENU:
- return KEY_MENU;
- case DOM_VK_SLEEP:
- return KEY_STANDBY;
-
- // Numpad keys
- case DOM_VK_MULTIPLY:
- return KEY_KP_MULTIPLY;
- case DOM_VK_ADD:
- return KEY_KP_ADD;
- case DOM_VK_SEPARATOR:
- return KEY_KP_PERIOD; // Good enough?
- case DOM_VK_SUBTRACT:
- return KEY_KP_SUBTRACT;
- case DOM_VK_DECIMAL:
- return KEY_KP_PERIOD;
- case DOM_VK_DIVIDE:
- return KEY_KP_DIVIDE;
-
- /*
- case DOM_VK_F17: return KEY_UNKNOWN;
- case DOM_VK_F18: return KEY_UNKNOWN;
- case DOM_VK_F19: return KEY_UNKNOWN;
- case DOM_VK_F20: return KEY_UNKNOWN;
- case DOM_VK_F21: return KEY_UNKNOWN;
- case DOM_VK_F22: return KEY_UNKNOWN;
- case DOM_VK_F23: return KEY_UNKNOWN;
- case DOM_VK_F24: return KEY_UNKNOWN;
- */
-
- case DOM_VK_NUM_LOCK:
- return KEY_NUMLOCK;
- case DOM_VK_SCROLL_LOCK:
- return KEY_SCROLLLOCK;
-
- /*
- case DOM_VK_WIN_OEM_FJ_JISHO: return KEY_UNKNOWN;
- case DOM_VK_WIN_OEM_FJ_MASSHOU: return KEY_UNKNOWN;
- case DOM_VK_WIN_OEM_FJ_TOUROKU: return KEY_UNKNOWN;
- case DOM_VK_WIN_OEM_FJ_LOYA: return KEY_UNKNOWN;
- case DOM_VK_WIN_OEM_FJ_ROYA: return KEY_UNKNOWN;
- */
-
- case DOM_VK_CIRCUMFLEX:
- return KEY_ASCIICIRCUM;
- case DOM_VK_EXCLAMATION:
- return KEY_EXCLAM;
- case DOM_VK_DOUBLE_QUOTE:
- return KEY_QUOTEDBL;
- case DOM_VK_HASH:
- return KEY_NUMBERSIGN;
- case DOM_VK_DOLLAR:
- return KEY_DOLLAR;
- case DOM_VK_PERCENT:
- return KEY_PERCENT;
- case DOM_VK_AMPERSAND:
- return KEY_AMPERSAND;
- case DOM_VK_UNDERSCORE:
- return KEY_UNDERSCORE;
- case DOM_VK_OPEN_PAREN:
- return KEY_PARENLEFT;
- case DOM_VK_CLOSE_PAREN:
- return KEY_PARENRIGHT;
- case DOM_VK_ASTERISK:
- return KEY_ASTERISK;
- case DOM_VK_PLUS:
- return KEY_PLUS;
- case DOM_VK_PIPE:
- return KEY_BAR;
- case DOM_VK_HYPHEN_MINUS:
- return KEY_MINUS;
- case DOM_VK_OPEN_CURLY_BRACKET:
- return KEY_BRACELEFT;
- case DOM_VK_CLOSE_CURLY_BRACKET:
- return KEY_BRACERIGHT;
- case DOM_VK_TILDE:
- return KEY_ASCIITILDE;
-
- case DOM_VK_VOLUME_MUTE:
- return KEY_VOLUMEMUTE;
- case DOM_VK_VOLUME_DOWN:
- return KEY_VOLUMEDOWN;
- case DOM_VK_VOLUME_UP:
- return KEY_VOLUMEUP;
-
- case DOM_VK_COMMA:
- return KEY_COMMA;
- case DOM_VK_PERIOD:
- return KEY_PERIOD;
- case DOM_VK_SLASH:
- return KEY_SLASH;
- case DOM_VK_BACK_QUOTE:
- return KEY_QUOTELEFT;
- case DOM_VK_OPEN_BRACKET:
- return KEY_BRACKETLEFT;
- case DOM_VK_BACK_SLASH:
- return KEY_BACKSLASH;
- case DOM_VK_CLOSE_BRACKET:
- return KEY_BRACKETRIGHT;
- case DOM_VK_QUOTE:
- return KEY_APOSTROPHE;
-
- // The rest is OEM/unusual.
-
- default:
- return KEY_UNKNOWN;
- };
+ // Alphanumeric section.
+ DOM2GODOT("Backquote", QUOTELEFT);
+ DOM2GODOT("Backslash", BACKSLASH);
+ DOM2GODOT("BracketLeft", BRACKETLEFT);
+ DOM2GODOT("BracketRight", BRACKETRIGHT);
+ DOM2GODOT("Comma", COMMA);
+ DOM2GODOT("Digit0", 0);
+ DOM2GODOT("Digit1", 1);
+ DOM2GODOT("Digit2", 2);
+ DOM2GODOT("Digit3", 3);
+ DOM2GODOT("Digit4", 4);
+ DOM2GODOT("Digit5", 5);
+ DOM2GODOT("Digit6", 6);
+ DOM2GODOT("Digit7", 7);
+ DOM2GODOT("Digit8", 8);
+ DOM2GODOT("Digit9", 9);
+ DOM2GODOT("Equal", EQUAL);
+ DOM2GODOT("IntlBackslash", BACKSLASH);
+ //DOM2GODOT("IntlRo", UNKNOWN);
+ DOM2GODOT("IntlYen", YEN);
+
+ DOM2GODOT("KeyA", A);
+ DOM2GODOT("KeyB", B);
+ DOM2GODOT("KeyC", C);
+ DOM2GODOT("KeyD", D);
+ DOM2GODOT("KeyE", E);
+ DOM2GODOT("KeyF", F);
+ DOM2GODOT("KeyG", G);
+ DOM2GODOT("KeyH", H);
+ DOM2GODOT("KeyI", I);
+ DOM2GODOT("KeyJ", J);
+ DOM2GODOT("KeyK", K);
+ DOM2GODOT("KeyL", L);
+ DOM2GODOT("KeyM", M);
+ DOM2GODOT("KeyN", N);
+ DOM2GODOT("KeyO", O);
+ DOM2GODOT("KeyP", P);
+ DOM2GODOT("KeyQ", Q);
+ DOM2GODOT("KeyR", R);
+ DOM2GODOT("KeyS", S);
+ DOM2GODOT("KeyT", T);
+ DOM2GODOT("KeyU", U);
+ DOM2GODOT("KeyV", V);
+ DOM2GODOT("KeyW", W);
+ DOM2GODOT("KeyX", X);
+ DOM2GODOT("KeyY", Y);
+ DOM2GODOT("KeyZ", Z);
+
+ DOM2GODOT("Minus", MINUS);
+ DOM2GODOT("Period", PERIOD);
+ DOM2GODOT("Quote", APOSTROPHE);
+ DOM2GODOT("Semicolon", SEMICOLON);
+ DOM2GODOT("Slash", SLASH);
+
+ // Functional keys in the Alphanumeric section.
+ DOM2GODOT("AltLeft", ALT);
+ DOM2GODOT("AltRight", ALT);
+ DOM2GODOT("Backspace", BACKSPACE);
+ DOM2GODOT("CapsLock", CAPSLOCK);
+ DOM2GODOT("ContextMenu", MENU);
+ DOM2GODOT("ControlLeft", CONTROL);
+ DOM2GODOT("ControlRight", CONTROL);
+ DOM2GODOT("Enter", ENTER);
+ DOM2GODOT("MetaLeft", SUPER_L);
+ DOM2GODOT("MetaRight", SUPER_R);
+ DOM2GODOT("ShiftLeft", SHIFT);
+ DOM2GODOT("ShiftRight", SHIFT);
+ DOM2GODOT("Space", SPACE);
+ DOM2GODOT("Tab", TAB);
+
+ // ControlPad section.
+ DOM2GODOT("Delete", DELETE);
+ DOM2GODOT("End", END);
+ DOM2GODOT("Help", HELP);
+ DOM2GODOT("Home", HOME);
+ DOM2GODOT("Insert", INSERT);
+ DOM2GODOT("PageDown", PAGEDOWN);
+ DOM2GODOT("PageUp", PAGEUP);
+
+ // ArrowPad section.
+ DOM2GODOT("ArrowDown", DOWN);
+ DOM2GODOT("ArrowLeft", LEFT);
+ DOM2GODOT("ArrowRight", RIGHT);
+ DOM2GODOT("ArrowUp", UP);
+
+ // Function section.
+ DOM2GODOT("Escape", ESCAPE);
+ DOM2GODOT("F1", F1);
+ DOM2GODOT("F2", F2);
+ DOM2GODOT("F3", F3);
+ DOM2GODOT("F4", F4);
+ DOM2GODOT("F5", F5);
+ DOM2GODOT("F6", F6);
+ DOM2GODOT("F7", F7);
+ DOM2GODOT("F8", F8);
+ DOM2GODOT("F9", F9);
+ DOM2GODOT("F10", F10);
+ DOM2GODOT("F11", F11);
+ DOM2GODOT("F12", F12);
+ //DOM2GODOT("Fn", UNKNOWN); // never actually fired, but included in the standard draft.
+ //DOM2GODOT("FnLock", UNKNOWN);
+ DOM2GODOT("PrintScreen", PRINT);
+ DOM2GODOT("ScrollLock", SCROLLLOCK);
+ DOM2GODOT("Pause", PAUSE);
+
+ // Media keys section.
+ DOM2GODOT("BrowserBack", BACK);
+ DOM2GODOT("BrowserFavorites", FAVORITES);
+ DOM2GODOT("BrowserForward", FORWARD);
+ DOM2GODOT("BrowserHome", OPENURL);
+ DOM2GODOT("BrowserRefresh", REFRESH);
+ DOM2GODOT("BrowserSearch", SEARCH);
+ DOM2GODOT("BrowserStop", STOP);
+ //DOM2GODOT("Eject", UNKNOWN);
+ DOM2GODOT("LaunchApp1", LAUNCH0);
+ DOM2GODOT("LaunchApp2", LAUNCH1);
+ DOM2GODOT("LaunchMail", LAUNCHMAIL);
+ DOM2GODOT("MediaPlayPause", MEDIAPLAY);
+ DOM2GODOT("MediaSelect", LAUNCHMEDIA);
+ DOM2GODOT("MediaStop", MEDIASTOP);
+ DOM2GODOT("MediaTrackNext", MEDIANEXT);
+ DOM2GODOT("MediaTrackPrevious", MEDIAPREVIOUS);
+ //DOM2GODOT("Power", UNKNOWN);
+ //DOM2GODOT("Sleep", UNKNOWN);
+ DOM2GODOT("AudioVolumeDown", VOLUMEDOWN);
+ DOM2GODOT("AudioVolumeMute", VOLUMEMUTE);
+ DOM2GODOT("AudioVolumeUp", VOLUMEUP);
+ //DOM2GODOT("WakeUp", UNKNOWN);
+ return KEY_UNKNOWN;
+#undef DOM2GODOT
}
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index fbc298a399..3573ddac95 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -41,7 +41,6 @@
#define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip"
class EditorHTTPServer : public Reference {
-
private:
Ref<TCP_Server> server;
Ref<StreamPeerTCP> connection;
@@ -149,11 +148,13 @@ public:
}
void poll() {
- if (!server->is_listening())
+ if (!server->is_listening()) {
return;
+ }
if (connection.is_null()) {
- if (!server->is_connection_available())
+ if (!server->is_connection_available()) {
return;
+ }
connection = server->take_connection();
time = OS::get_singleton()->get_ticks_usec();
}
@@ -161,11 +162,11 @@ public:
_clear_client();
return;
}
- if (connection->get_status() != StreamPeerTCP::STATUS_CONNECTED)
+ if (connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
return;
+ }
while (true) {
-
char *r = (char *)req_buf;
int l = req_pos - 1;
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
@@ -191,7 +192,6 @@ public:
};
class EditorExportPlatformJavaScript : public EditorExportPlatform {
-
GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform);
Ref<ImageTexture> logo;
@@ -231,7 +231,6 @@ public:
virtual Ref<Texture2D> get_run_icon() const;
virtual void get_platform_features(List<String> *r_features) {
-
r_features->push_back("web");
r_features->push_back(get_os_name());
}
@@ -246,7 +245,6 @@ public:
};
void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags) {
-
String str_template = String::utf8(reinterpret_cast<const char *>(p_html.ptr()), p_html.size());
String str_export;
Vector<String> lines = str_template.split("\n");
@@ -256,7 +254,6 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
flags_json = JSON::print(flags);
for (int i = 0; i < lines.size(); i++) {
-
String current_line = lines[i];
current_line = current_line.replace("$GODOT_BASENAME", p_name);
current_line = current_line.replace("$GODOT_PROJECT_NAME", ProjectSettings::get_singleton()->get_setting("application/config/name"));
@@ -274,7 +271,6 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
}
void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
-
if (p_preset->get("vram_texture_compression/for_desktop")) {
r_features->push_back("s3tc");
}
@@ -291,7 +287,6 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
}
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
-
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), ""));
@@ -301,22 +296,18 @@ void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_op
}
String EditorExportPlatformJavaScript::get_name() const {
-
return "HTML5";
}
String EditorExportPlatformJavaScript::get_os_name() const {
-
return "HTML5";
}
Ref<Texture2D> EditorExportPlatformJavaScript::get_logo() const {
-
return logo;
}
bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
-
String err;
bool valid = false;
@@ -351,14 +342,14 @@ bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p
}
}
- if (!err.empty())
+ if (!err.empty()) {
r_error = err;
+ }
return valid;
}
List<String> EditorExportPlatformJavaScript::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
-
List<String> list;
list.push_back("html");
return list;
@@ -376,11 +367,11 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
template_path = template_path.strip_edges();
if (template_path == String()) {
-
- if (p_debug)
+ if (p_debug) {
template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG);
- else
+ } else {
template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE);
+ }
}
if (!DirAccess::exists(p_path.get_base_dir())) {
@@ -404,7 +395,6 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
unzFile pkg = unzOpen2(template_path.utf8().get_data(), &io);
if (!pkg) {
-
EditorNode::get_singleton()->show_warning(TTR("Could not open template for export:") + "\n" + template_path);
return ERR_FILE_NOT_FOUND;
}
@@ -434,7 +424,6 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
//write
if (file == "godot.html") {
-
if (!custom_html.empty()) {
continue;
}
@@ -442,14 +431,11 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
file = p_path.get_file();
} else if (file == "godot.js") {
-
file = p_path.get_file().get_basename() + ".js";
} else if (file == "godot.worker.js") {
-
file = p_path.get_file().get_basename() + ".worker.js";
} else if (file == "godot.wasm") {
-
file = p_path.get_file().get_basename() + ".wasm";
}
@@ -467,7 +453,6 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
unzClose(pkg);
if (!custom_html.empty()) {
-
FileAccess *f = FileAccess::open(custom_html, FileAccess::READ);
if (!f) {
EditorNode::get_singleton()->show_warning(TTR("Could not read custom HTML shell:") + "\n" + custom_html);
@@ -531,11 +516,9 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
}
bool EditorExportPlatformJavaScript::poll_export() {
-
Ref<EditorExportPreset> preset;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
-
Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
if (ep->is_runnable() && ep->get_platform() == this) {
preset = ep;
@@ -561,12 +544,10 @@ Ref<ImageTexture> EditorExportPlatformJavaScript::get_option_icon(int p_index) c
}
int EditorExportPlatformJavaScript::get_options_count() const {
-
return menu_options;
}
Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags) {
-
if (p_option == 1) {
MutexLock lock(server_lock);
server->stop();
@@ -614,7 +595,6 @@ Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_prese
}
Ref<Texture2D> EditorExportPlatformJavaScript::get_run_icon() const {
-
return run_icon;
}
@@ -630,7 +610,6 @@ void EditorExportPlatformJavaScript::_server_thread_poll(void *data) {
}
EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
-
server.instance();
server_quit = false;
server_thread = Thread::create(_server_thread_poll, this);
@@ -644,10 +623,11 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
run_icon->create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
- if (theme.is_valid())
+ if (theme.is_valid()) {
stop_icon = theme->get_icon("Stop", "EditorIcons");
- else
+ } else {
stop_icon.instance();
+ }
menu_options = 0;
}
@@ -660,7 +640,6 @@ EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() {
}
void register_javascript_exporter() {
-
EDITOR_DEF("export/web/http_host", "localhost");
EDITOR_DEF("export/web/http_port", 8060);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "export/web/http_port", PROPERTY_HINT_RANGE, "1,65535,1"));
diff --git a/platform/javascript/http_client.h.inc b/platform/javascript/http_client.h.inc
index ac275aadbc..4d5ff88bdd 100644
--- a/platform/javascript/http_client.h.inc
+++ b/platform/javascript/http_client.h.inc
@@ -33,21 +33,21 @@
Error prepare_request(Method p_method, const String &p_url, const Vector<String> &p_headers);
int xhr_id;
-int read_limit;
-int response_read_offset;
-Status status;
+int read_limit = 4096;
+int response_read_offset = 0;
+Status status = STATUS_DISCONNECTED;
String host;
-int port;
-bool use_tls;
+int port = -1;
+bool use_tls = false;
String username;
String password;
-int polled_response_code;
+int polled_response_code = 0;
String polled_response_header;
PackedByteArray polled_response;
#ifdef DEBUG_ENABLED
-bool has_polled;
-uint64_t last_polling_frame;
+bool has_polled = false;
+uint64_t last_polling_frame = 0;
#endif
diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp
index 863c207896..cb0e48b8a9 100644
--- a/platform/javascript/http_client_javascript.cpp
+++ b/platform/javascript/http_client_javascript.cpp
@@ -29,10 +29,10 @@
/*************************************************************************/
#include "core/io/http_client.h"
+
#include "http_request.h"
Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
-
close();
if (p_ssl && !p_verify_host) {
WARN_PRINT("Disabling HTTPClient's host verification is not supported for the HTML5 platform, host will be verified");
@@ -67,17 +67,14 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
}
void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
-
ERR_FAIL_MSG("Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform.");
}
Ref<StreamPeer> HTTPClient::get_connection() const {
-
ERR_FAIL_V_MSG(REF(), "Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform.");
}
Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Vector<String> &p_headers) {
-
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_method == METHOD_TRACE || p_method == METHOD_CONNECT, ERR_UNAVAILABLE, "HTTP methods TRACE and CONNECT are not supported for the HTML5 platform.");
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
@@ -104,7 +101,6 @@ Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Ve
}
Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const Vector<uint8_t> &p_body) {
-
Error err = prepare_request(p_method, p_url, p_headers);
if (err != OK)
return err;
@@ -113,7 +109,6 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector
}
Error HTTPClient::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) {
-
Error err = prepare_request(p_method, p_url, p_headers);
if (err != OK)
return err;
@@ -122,7 +117,6 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str
}
void HTTPClient::close() {
-
host = "";
port = -1;
use_tls = false;
@@ -134,28 +128,23 @@ void HTTPClient::close() {
}
HTTPClient::Status HTTPClient::get_status() const {
-
return status;
}
bool HTTPClient::has_response() const {
-
return !polled_response_header.empty();
}
bool HTTPClient::is_response_chunked() const {
-
// TODO evaluate using moz-chunked-arraybuffer, fetch & ReadableStream
return false;
}
int HTTPClient::get_response_code() const {
-
return polled_response_code;
}
Error HTTPClient::get_response_headers(List<String> *r_response) {
-
if (polled_response_header.empty())
return ERR_INVALID_PARAMETER;
@@ -168,12 +157,10 @@ Error HTTPClient::get_response_headers(List<String> *r_response) {
}
int HTTPClient::get_response_body_length() const {
-
return polled_response.size();
}
PackedByteArray HTTPClient::read_response_body_chunk() {
-
ERR_FAIL_COND_V(status != STATUS_BODY, PackedByteArray());
int to_read = MIN(read_limit, polled_response.size() - response_read_offset);
@@ -192,17 +179,14 @@ PackedByteArray HTTPClient::read_response_body_chunk() {
}
void HTTPClient::set_blocking_mode(bool p_enable) {
-
ERR_FAIL_COND_MSG(p_enable, "HTTPClient blocking mode is not supported for the HTML5 platform.");
}
bool HTTPClient::is_blocking_mode_enabled() const {
-
return false;
}
void HTTPClient::set_read_chunk_size(int p_size) {
-
read_limit = p_size;
}
@@ -211,9 +195,7 @@ int HTTPClient::get_read_chunk_size() const {
}
Error HTTPClient::poll() {
-
switch (status) {
-
case STATUS_DISCONNECTED:
return ERR_UNCONFIGURED;
@@ -233,7 +215,6 @@ Error HTTPClient::poll() {
return ERR_CONNECTION_ERROR;
case STATUS_REQUESTING: {
-
#ifdef DEBUG_ENABLED
if (!has_polled) {
has_polled = true;
@@ -279,20 +260,9 @@ Error HTTPClient::poll() {
}
HTTPClient::HTTPClient() {
-
xhr_id = godot_xhr_new();
- read_limit = 4096;
- status = STATUS_DISCONNECTED;
- port = -1;
- use_tls = false;
- polled_response_code = 0;
-#ifdef DEBUG_ENABLED
- has_polled = false;
- last_polling_frame = 0;
-#endif
}
HTTPClient::~HTTPClient() {
-
godot_xhr_free(xhr_id);
}
diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp
index db8050b90e..3a72b10dd4 100644
--- a/platform/javascript/javascript_eval.cpp
+++ b/platform/javascript/javascript_eval.cpp
@@ -34,14 +34,12 @@
#include "emscripten.h"
extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *resize_PackedByteArray_and_open_write(PackedByteArray *p_arr, VectorWriteProxy<uint8_t> *r_write, int p_len) {
-
p_arr->resize(p_len);
*r_write = p_arr->write;
return p_arr->ptrw();
}
Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
-
union {
bool b;
double d;
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index 854383aeee..fd61c46e63 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -46,7 +46,6 @@ void exit_callback() {
}
void main_loop_callback() {
-
if (os->main_loop_iterate()) {
emscripten_cancel_main_loop(); // Cancel current loop and wait for finalize_async.
EM_ASM({
@@ -69,7 +68,6 @@ extern "C" EMSCRIPTEN_KEEPALIVE void cleanup_after_sync() {
}
extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) {
-
String idbfs_err = String::utf8(p_idbfs_err);
if (!idbfs_err.empty()) {
print_line("IndexedDB not available: " + idbfs_err);
@@ -82,10 +80,12 @@ extern "C" EMSCRIPTEN_KEEPALIVE void main_after_fs_sync(char *p_idbfs_err) {
Main::start();
os->get_main_loop()->init();
emscripten_resume_main_loop();
+ // Immediately run the first iteration.
+ // We are inside an animation frame, we want to immediately draw on the newly setup canvas.
+ main_loop_callback();
}
int main(int argc, char *argv[]) {
-
os = new OS_JavaScript();
Main::setup(argv[0], argc - 1, &argv[1], false);
emscripten_set_main_loop(main_loop_callback, -1, false);
@@ -94,14 +94,15 @@ int main(int argc, char *argv[]) {
// Sync from persistent state into memory and then
// run the 'main_after_fs_sync' function.
/* clang-format off */
- EM_ASM(
+ EM_ASM({
FS.mkdir('/userfs');
FS.mount(IDBFS, {}, '/userfs');
FS.syncfs(true, function(err) {
- ccall('main_after_fs_sync', null, ['string'], [err ? err.message : ""])
+ requestAnimationFrame(function() {
+ ccall('main_after_fs_sync', null, ['string'], [err ? err.message : ""]);
+ });
});
-
- );
+ });
/* clang-format on */
return 0;
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 1ec23973d6..ad4b5a5afa 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -47,7 +47,6 @@
#include <stdlib.h>
bool OS_JavaScript::has_touchscreen_ui_hint() const {
-
/* clang-format off */
return EM_ASM_INT_V(
return 'ontouchstart' in window;
@@ -58,18 +57,15 @@ bool OS_JavaScript::has_touchscreen_ui_hint() const {
// Audio
int OS_JavaScript::get_audio_driver_count() const {
-
return 1;
}
const char *OS_JavaScript::get_audio_driver_name(int p_driver) const {
-
return "JavaScript";
}
// Lifecycle
void OS_JavaScript::initialize() {
-
OS_Unix::initialize_core();
FileAccess::make_default<FileAccessBufferedFA<FileAccessUnix>>(FileAccess::ACCESS_RESOURCES);
DisplayServerJavaScript::register_javascript_driver();
@@ -93,22 +89,18 @@ void OS_JavaScript::resume_audio() {
}
void OS_JavaScript::set_main_loop(MainLoop *p_main_loop) {
-
main_loop = p_main_loop;
}
MainLoop *OS_JavaScript::get_main_loop() const {
-
return main_loop;
}
void OS_JavaScript::main_loop_callback() {
-
get_singleton()->main_loop_iterate();
}
bool OS_JavaScript::main_loop_iterate() {
-
if (is_userfs_persistent() && sync_wait_time >= 0) {
int64_t current_time = get_ticks_msec();
int64_t elapsed_time = current_time - last_sync_check_time;
@@ -133,7 +125,6 @@ bool OS_JavaScript::main_loop_iterate() {
}
void OS_JavaScript::delete_main_loop() {
-
if (main_loop) {
memdelete(main_loop);
}
@@ -146,14 +137,12 @@ void OS_JavaScript::finalize_async() {
}
void OS_JavaScript::finalize() {
-
delete_main_loop();
}
// Miscellaneous
Error OS_JavaScript::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
-
Array args;
for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) {
args.push_back(E->get());
@@ -175,17 +164,14 @@ Error OS_JavaScript::execute(const String &p_path, const List<String> &p_argumen
}
Error OS_JavaScript::kill(const ProcessID &p_pid) {
-
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "OS::kill() is not available on the HTML5 platform.");
}
int OS_JavaScript::get_process_id() const {
-
ERR_FAIL_V_MSG(0, "OS::get_process_id() is not available on the HTML5 platform.");
}
bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
-
if (p_feature == "HTML5" || p_feature == "web")
return true;
@@ -198,12 +184,10 @@ bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
}
String OS_JavaScript::get_executable_path() const {
-
return OS::get_executable_path();
}
Error OS_JavaScript::shell_open(String p_uri) {
-
// Open URI in a new tab, browser will deal with it by protocol.
/* clang-format off */
EM_ASM_({
@@ -214,37 +198,30 @@ Error OS_JavaScript::shell_open(String p_uri) {
}
String OS_JavaScript::get_name() const {
-
return "HTML5";
}
bool OS_JavaScript::can_draw() const {
-
return true; // Always?
}
String OS_JavaScript::get_user_data_dir() const {
-
return "/userfs";
};
String OS_JavaScript::get_cache_path() const {
-
return "/home/web_user/.cache";
}
String OS_JavaScript::get_config_path() const {
-
return "/home/web_user/.config";
}
String OS_JavaScript::get_data_path() const {
-
return "/home/web_user/.local/share";
}
void OS_JavaScript::file_access_close_callback(const String &p_file, int p_flags) {
-
OS_JavaScript *os = get_singleton();
if (os->is_userfs_persistent() && p_file.begins_with("/userfs") && p_flags & FileAccess::WRITE) {
os->last_sync_check_time = OS::get_singleton()->get_ticks_msec();
@@ -254,17 +231,14 @@ void OS_JavaScript::file_access_close_callback(const String &p_file, int p_flags
}
void OS_JavaScript::set_idb_available(bool p_idb_available) {
-
idb_available = p_idb_available;
}
bool OS_JavaScript::is_userfs_persistent() const {
-
return idb_available;
}
OS_JavaScript *OS_JavaScript::get_singleton() {
-
return static_cast<OS_JavaScript *>(OS::get_singleton());
}
@@ -272,7 +246,6 @@ void OS_JavaScript::initialize_joypads() {
}
OS_JavaScript::OS_JavaScript() {
-
AudioDriverManager::add_driver(&audio_driver_javascript);
Vector<Logger *> loggers;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 0a81a4a5b3..f0f18b44f8 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -39,7 +39,6 @@
#include <emscripten/html5.h>
class OS_JavaScript : public OS_Unix {
-
MainLoop *main_loop = nullptr;
AudioDriverJavaScript audio_driver_javascript;
diff --git a/platform/linuxbsd/context_gl_x11.cpp b/platform/linuxbsd/context_gl_x11.cpp
index 308d68521a..71dc9602b3 100644
--- a/platform/linuxbsd/context_gl_x11.cpp
+++ b/platform/linuxbsd/context_gl_x11.cpp
@@ -46,22 +46,18 @@
typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *);
struct ContextGL_X11_Private {
-
::GLXContext glx_context;
};
void ContextGL_X11::release_current() {
-
glXMakeCurrent(x11_display, None, nullptr);
}
void ContextGL_X11::make_current() {
-
glXMakeCurrent(x11_display, x11_window, p->glx_context);
}
void ContextGL_X11::swap_buffers() {
-
glXSwapBuffers(x11_display, x11_window);
}
@@ -85,7 +81,6 @@ static void set_class_hint(Display *p_display, Window p_window) {
}
Error ContextGL_X11::initialize() {
-
//const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte *)"glXCreateContextAttribsARB");
@@ -167,7 +162,6 @@ Error ContextGL_X11::initialize() {
switch (context_type) {
case GLES_2_0_COMPATIBLE: {
-
p->glx_context = glXCreateNewContext(x11_display, fbconfig, GLX_RGBA_TYPE, 0, true);
ERR_FAIL_COND_V(!p->glx_context, ERR_UNCONFIGURED);
} break;
@@ -192,7 +186,6 @@ Error ContextGL_X11::initialize() {
}
int ContextGL_X11::get_window_width() {
-
XWindowAttributes xwa;
XGetWindowAttributes(x11_display, x11_window, &xwa);
@@ -234,14 +227,13 @@ void ContextGL_X11::set_use_vsync(bool p_use) {
return;
use_vsync = p_use;
}
-bool ContextGL_X11::is_using_vsync() const {
+bool ContextGL_X11::is_using_vsync() const {
return use_vsync;
}
ContextGL_X11::ContextGL_X11(::Display *p_x11_display, ::Window &p_x11_window, const OS::VideoMode &p_default_video_mode, ContextType p_context_type) :
x11_window(p_x11_window) {
-
default_video_mode = p_default_video_mode;
x11_display = p_x11_display;
diff --git a/platform/linuxbsd/context_gl_x11.h b/platform/linuxbsd/context_gl_x11.h
index 2c0643c95a..7aed280c98 100644
--- a/platform/linuxbsd/context_gl_x11.h
+++ b/platform/linuxbsd/context_gl_x11.h
@@ -42,7 +42,6 @@
struct ContextGL_X11_Private;
class ContextGL_X11 {
-
public:
enum ContextType {
GLES_2_0_COMPATIBLE,
diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp
index dbdb15918e..b3553e961a 100644
--- a/platform/linuxbsd/crash_handler_linuxbsd.cpp
+++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp
@@ -63,8 +63,9 @@ static void handle_crash(int sig) {
// Dump the backtrace to stderr with a message to the user
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
- if (OS::get_singleton()->get_main_loop())
+ if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH);
+ }
fprintf(stderr, "Dumping the backtrace. %ls\n", msg.c_str());
char **strings = backtrace_symbols(bt_buffer, size);
@@ -85,8 +86,9 @@ static void handle_crash(int sig) {
snprintf(fname, 1024, "%s", demangled);
}
- if (demangled)
+ if (demangled) {
free(demangled);
+ }
}
}
@@ -128,8 +130,9 @@ CrashHandler::~CrashHandler() {
}
void CrashHandler::disable() {
- if (disabled)
+ if (disabled) {
return;
+ }
#ifdef CRASH_HANDLER_ENABLED
signal(SIGSEGV, nullptr);
diff --git a/platform/linuxbsd/crash_handler_linuxbsd.h b/platform/linuxbsd/crash_handler_linuxbsd.h
index 94b4649690..9bb03579bc 100644
--- a/platform/linuxbsd/crash_handler_linuxbsd.h
+++ b/platform/linuxbsd/crash_handler_linuxbsd.h
@@ -32,7 +32,6 @@
#define CRASH_HANDLER_X11_H
class CrashHandler {
-
bool disabled;
public:
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index f016892453..a0954600a2 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -127,6 +127,7 @@ bool DisplayServerX11::has_feature(Feature p_feature) const {
return false;
}
+
String DisplayServerX11::get_name() const {
return "X11";
}
@@ -148,8 +149,9 @@ void DisplayServerX11::alert(const String &p_alert, const String &p_title) {
}
}
- if (program.length())
+ if (program.length()) {
break;
+ }
}
List<String> args;
@@ -204,7 +206,6 @@ void DisplayServerX11::_update_real_mouse_position(const WindowData &wd) {
if (xquerypointer_result) {
if (win_x > 0 && win_y > 0 && win_x <= wd.size.width && win_y <= wd.size.height) {
-
last_mouse_pos.x = win_x;
last_mouse_pos.y = win_y;
last_mouse_pos_valid = true;
@@ -245,10 +246,12 @@ bool DisplayServerX11::_refresh_device_info() {
for (int i = 0; i < dev_count; i++) {
XIDeviceInfo *dev = &info[i];
- if (!dev->enabled)
+ if (!dev->enabled) {
continue;
- if (!(dev->use == XIMasterPointer || dev->use == XIFloatingSlave))
+ }
+ if (!(dev->use == XIMasterPointer || dev->use == XIFloatingSlave)) {
continue;
+ }
bool direct_touch = false;
bool absolute_mode = false;
@@ -354,20 +357,20 @@ void DisplayServerX11::_flush_mouse_motion() {
}
void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
-
_THREAD_SAFE_METHOD_
- if (p_mode == mouse_mode)
+ if (p_mode == mouse_mode) {
return;
+ }
- if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED)
+ if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) {
XUngrabPointer(x11_display, CurrentTime);
+ }
// The only modes that show a cursor are VISIBLE and CONFINED
bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
-
if (showCursor) {
XDefineCursor(x11_display, E->get().x11_window, cursors[current_cursor]); // show cursor
} else {
@@ -377,7 +380,6 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
mouse_mode = p_mode;
if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) {
-
//flush pending motion events
_flush_mouse_motion();
WindowData &main_window = windows[MAIN_WINDOW_ID];
@@ -404,19 +406,17 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
XFlush(x11_display);
}
+
DisplayServerX11::MouseMode DisplayServerX11::mouse_get_mode() const {
return mouse_mode;
}
void DisplayServerX11::mouse_warp_to_position(const Point2i &p_to) {
-
_THREAD_SAFE_METHOD_
if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
last_mouse_pos = p_to;
} else {
-
/*XWindowAttributes xwa;
XGetWindowAttributes(x11_display, x11_window, &xwa);
printf("%d %d\n", xwa.x, xwa.y); needed? */
@@ -451,7 +451,6 @@ int DisplayServerX11::mouse_get_button_state() const {
}
void DisplayServerX11::clipboard_set(const String &p_text) {
-
_THREAD_SAFE_METHOD_
internal_clipboard = p_text;
@@ -460,7 +459,6 @@ void DisplayServerX11::clipboard_set(const String &p_text) {
}
static String _clipboard_get_impl(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard, Atom target) {
-
String ret;
Atom type;
@@ -471,7 +469,6 @@ static String _clipboard_get_impl(Atom p_source, Window x11_window, ::Display *x
Window Sown = XGetSelectionOwner(x11_display, p_source);
if (Sown == x11_window) {
-
return p_internal_clipboard;
};
@@ -507,8 +504,9 @@ static String _clipboard_get_impl(Atom p_source, Window x11_window, ::Display *x
&len, &dummy, &data);
if (result == Success) {
ret.parse_utf8((const char *)data);
- } else
+ } else {
printf("FAIL\n");
+ }
if (data) {
XFree(data);
}
@@ -531,7 +529,6 @@ static String _clipboard_get(Atom p_source, Window x11_window, ::Display *x11_di
}
String DisplayServerX11::clipboard_get() const {
-
_THREAD_SAFE_METHOD_
String ret;
@@ -545,22 +542,22 @@ String DisplayServerX11::clipboard_get() const {
}
int DisplayServerX11::get_screen_count() const {
-
_THREAD_SAFE_METHOD_
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
- if (!ext_okay)
+ if (!ext_okay) {
return 0;
+ }
int count;
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
XFree(xsi);
return count;
}
-Point2i DisplayServerX11::screen_get_position(int p_screen) const {
+Point2i DisplayServerX11::screen_get_position(int p_screen) const {
_THREAD_SAFE_METHOD_
if (p_screen == SCREEN_OF_MAIN_WINDOW) {
@@ -601,13 +598,15 @@ Rect2i DisplayServerX11::screen_get_usable_rect(int p_screen) const {
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
- if (!ext_okay)
+ if (!ext_okay) {
return Rect2i(0, 0, 0, 0);
+ }
int count;
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
- if (p_screen >= count)
+ if (p_screen >= count) {
return Rect2i(0, 0, 0, 0);
+ }
Rect2i rect = Rect2i(xsi[p_screen].x_org, xsi[p_screen].y_org, xsi[p_screen].width, xsi[p_screen].height);
XFree(xsi);
@@ -615,7 +614,6 @@ Rect2i DisplayServerX11::screen_get_usable_rect(int p_screen) const {
}
int DisplayServerX11::screen_get_dpi(int p_screen) const {
-
_THREAD_SAFE_METHOD_
if (p_screen == SCREEN_OF_MAIN_WINDOW) {
@@ -652,14 +650,15 @@ int DisplayServerX11::screen_get_dpi(int p_screen) const {
int height_mm = DisplayHeightMM(x11_display, p_screen);
double xdpi = (width_mm ? sc.width / (double)width_mm * 25.4 : 0);
double ydpi = (height_mm ? sc.height / (double)height_mm * 25.4 : 0);
- if (xdpi || ydpi)
+ if (xdpi || ydpi) {
return (xdpi + ydpi) / (xdpi && ydpi ? 2 : 1);
+ }
//could not get dpi
return 96;
}
-bool DisplayServerX11::screen_is_touchscreen(int p_screen) const {
+bool DisplayServerX11::screen_is_touchscreen(int p_screen) const {
_THREAD_SAFE_METHOD_
#ifndef _MSC_VER
@@ -680,7 +679,6 @@ Vector<DisplayServer::WindowID> DisplayServerX11::get_window_list() const {
}
DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
-
_THREAD_SAFE_METHOD_
WindowID id = _create_window(p_mode, p_flags, p_rect);
@@ -694,7 +692,6 @@ DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, u
}
void DisplayServerX11::delete_sub_window(WindowID p_id) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_id));
@@ -725,7 +722,6 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
}
void DisplayServerX11::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
-
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
@@ -733,19 +729,16 @@ void DisplayServerX11::window_attach_instance_id(ObjectID p_instance, WindowID p
}
ObjectID DisplayServerX11::window_get_attached_instance_id(WindowID p_window) const {
-
ERR_FAIL_COND_V(!windows.has(p_window), ObjectID());
const WindowData &wd = windows[p_window];
return wd.instance_id;
}
DisplayServerX11::WindowID DisplayServerX11::get_window_at_screen_position(const Point2i &p_position) const {
-
return INVALID_WINDOW_ID;
}
void DisplayServerX11::window_set_title(const String &p_title, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -759,7 +752,6 @@ void DisplayServerX11::window_set_title(const String &p_title, WindowID p_window
}
void DisplayServerX11::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -768,7 +760,6 @@ void DisplayServerX11::window_set_rect_changed_callback(const Callable &p_callab
}
void DisplayServerX11::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -777,15 +768,14 @@ void DisplayServerX11::window_set_window_event_callback(const Callable &p_callab
}
void DisplayServerX11::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
wd.input_event_callback = p_callable;
}
-void DisplayServerX11::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
+void DisplayServerX11::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -794,7 +784,6 @@ void DisplayServerX11::window_set_input_text_callback(const Callable &p_callable
}
void DisplayServerX11::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -803,7 +792,6 @@ void DisplayServerX11::window_set_drop_files_callback(const Callable &p_callable
}
int DisplayServerX11::window_get_current_screen(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), -1);
@@ -817,21 +805,23 @@ int DisplayServerX11::window_get_current_screen(WindowID p_window) const {
for (int i = 0; i < count; i++) {
Point2i pos = screen_get_position(i);
Size2i size = screen_get_size(i);
- if ((x >= pos.x && x < pos.x + size.width) && (y >= pos.y && y < pos.y + size.height))
+ if ((x >= pos.x && x < pos.x + size.width) && (y >= pos.y && y < pos.y + size.height)) {
return i;
+ }
}
return 0;
}
-void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window) {
+void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
int count = get_screen_count();
- if (p_screen >= count)
+ if (p_screen >= count) {
return;
+ }
if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN) {
Point2i position = screen_get_position(p_screen);
@@ -847,7 +837,6 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window
}
void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(p_window == p_parent);
@@ -883,7 +872,6 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent
}
Point2i DisplayServerX11::window_get_position(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
@@ -893,7 +881,6 @@ Point2i DisplayServerX11::window_get_position(WindowID p_window) const {
}
void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -926,7 +913,6 @@ void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p
}
void DisplayServerX11::window_set_max_size(const Size2i p_size, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -958,8 +944,8 @@ void DisplayServerX11::window_set_max_size(const Size2i p_size, WindowID p_windo
XFlush(x11_display);
}
}
-Size2i DisplayServerX11::window_get_max_size(WindowID p_window) const {
+Size2i DisplayServerX11::window_get_max_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -969,7 +955,6 @@ Size2i DisplayServerX11::window_get_max_size(WindowID p_window) const {
}
void DisplayServerX11::window_set_min_size(const Size2i p_size, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1001,8 +986,8 @@ void DisplayServerX11::window_set_min_size(const Size2i p_size, WindowID p_windo
XFlush(x11_display);
}
}
-Size2i DisplayServerX11::window_get_min_size(WindowID p_window) const {
+Size2i DisplayServerX11::window_get_min_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -1012,7 +997,6 @@ Size2i DisplayServerX11::window_get_min_size(WindowID p_window) const {
}
void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1023,8 +1007,9 @@ void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
WindowData &wd = windows[p_window];
- if (wd.size.width == size.width && wd.size.height == size.height)
+ if (wd.size.width == size.width && wd.size.height == size.height) {
return;
+ }
XWindowAttributes xwa;
XSync(x11_display, False);
@@ -1067,22 +1052,23 @@ void DisplayServerX11::window_set_size(const Size2i p_size, WindowID p_window) {
XSync(x11_display, False);
XGetWindowAttributes(x11_display, wd.x11_window, &xwa);
- if (old_w != xwa.width || old_h != xwa.height)
+ if (old_w != xwa.width || old_h != xwa.height) {
break;
+ }
usleep(10000);
}
}
-Size2i DisplayServerX11::window_get_size(WindowID p_window) const {
+Size2i DisplayServerX11::window_get_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
const WindowData &wd = windows[p_window];
return wd.size;
}
-Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -1113,7 +1099,6 @@ Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
}
bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), false);
@@ -1148,13 +1133,16 @@ bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const {
bool found_wm_act_max_vert = false;
for (uint64_t i = 0; i < len; i++) {
- if (atoms[i] == wm_act_max_horz)
+ if (atoms[i] == wm_act_max_horz) {
found_wm_act_max_horz = true;
- if (atoms[i] == wm_act_max_vert)
+ }
+ if (atoms[i] == wm_act_max_vert) {
found_wm_act_max_vert = true;
+ }
- if (found_wm_act_max_horz || found_wm_act_max_vert)
+ if (found_wm_act_max_horz || found_wm_act_max_vert) {
return true;
+ }
}
XFree(atoms);
}
@@ -1163,7 +1151,6 @@ bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const {
}
void DisplayServerX11::_set_wm_maximized(WindowID p_window, bool p_enabled) {
-
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
@@ -1195,7 +1182,6 @@ void DisplayServerX11::_set_wm_maximized(WindowID p_window, bool p_enabled) {
}
void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
-
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
@@ -1280,7 +1266,6 @@ void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
}
void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1341,7 +1326,6 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
} break;
case WINDOW_MODE_MAXIMIZED: {
-
_set_wm_maximized(p_window, false);
} break;
}
@@ -1386,7 +1370,6 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
wd.fullscreen = true;
} break;
case WINDOW_MODE_MAXIMIZED: {
-
_set_wm_maximized(p_window, true);
} break;
@@ -1394,7 +1377,6 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
}
DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED);
@@ -1435,10 +1417,12 @@ DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) c
bool found_wm_max_vert = false;
for (uint64_t i = 0; i < len; i++) {
- if (atoms[i] == wm_max_horz)
+ if (atoms[i] == wm_max_horz) {
found_wm_max_horz = true;
- if (atoms[i] == wm_max_vert)
+ }
+ if (atoms[i] == wm_max_vert) {
found_wm_max_vert = true;
+ }
if (found_wm_max_horz && found_wm_max_vert) {
retval = true;
@@ -1493,7 +1477,6 @@ DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) c
}
void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1534,7 +1517,6 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
} break;
case WINDOW_FLAG_BORDERLESS: {
-
Hints hints;
Atom property;
hints.flags = 2;
@@ -1548,7 +1530,6 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
wd.borderless = p_enabled;
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
-
ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID, "Can't make a window transient if the 'on top' flag is active.");
if (p_enabled && wd.fullscreen) {
_set_wm_maximized(p_window, true);
@@ -1581,8 +1562,8 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
}
}
}
-bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
+bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), false);
@@ -1590,15 +1571,12 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co
switch (p_flag) {
case WINDOW_FLAG_RESIZE_DISABLED: {
-
return wd.resize_disabled;
} break;
case WINDOW_FLAG_BORDERLESS: {
-
bool borderless = wd.borderless;
Atom prop = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
if (prop != None) {
-
Atom type;
int format;
unsigned long len;
@@ -1616,7 +1594,6 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co
return borderless;
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
-
return wd.on_top;
} break;
case WINDOW_FLAG_TRANSPARENT: {
@@ -1630,7 +1607,6 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co
}
void DisplayServerX11::window_request_attention(WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1657,7 +1633,6 @@ void DisplayServerX11::window_request_attention(WindowID p_window) {
}
void DisplayServerX11::window_move_to_foreground(WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1679,12 +1654,11 @@ void DisplayServerX11::window_move_to_foreground(WindowID p_window) {
}
bool DisplayServerX11::window_can_draw(WindowID p_window) const {
-
//this seems to be all that is provided by X11
return window_get_mode(p_window) != WINDOW_MODE_MINIMIZED;
}
-bool DisplayServerX11::can_any_window_draw() const {
+bool DisplayServerX11::can_any_window_draw() const {
_THREAD_SAFE_METHOD_
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
@@ -1697,7 +1671,6 @@ bool DisplayServerX11::can_any_window_draw() const {
}
void DisplayServerX11::window_set_ime_active(const bool p_active, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1705,8 +1678,9 @@ void DisplayServerX11::window_set_ime_active(const bool p_active, WindowID p_win
wd.im_active = p_active;
- if (!wd.xic)
+ if (!wd.xic) {
return;
+ }
if (p_active) {
XSetICFocus(wd.xic);
@@ -1715,8 +1689,8 @@ void DisplayServerX11::window_set_ime_active(const bool p_active, WindowID p_win
XUnsetICFocus(wd.xic);
}
}
-void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
+void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1724,8 +1698,9 @@ void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_
wd.im_position = p_pos;
- if (!wd.xic)
+ if (!wd.xic) {
return;
+ }
::XPoint spot;
spot.x = short(p_pos.x);
@@ -1736,7 +1711,6 @@ void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_
}
void DisplayServerX11::cursor_set_shape(CursorShape p_shape) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
@@ -1759,15 +1733,15 @@ void DisplayServerX11::cursor_set_shape(CursorShape p_shape) {
current_cursor = p_shape;
}
+
DisplayServerX11::CursorShape DisplayServerX11::cursor_get_shape() const {
return current_cursor;
}
-void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
_THREAD_SAFE_METHOD_
if (p_cursor.is_valid()) {
-
Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
if (cursor_c) {
@@ -1872,41 +1846,109 @@ void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape
}
}
-DisplayServerX11::LatinKeyboardVariant DisplayServerX11::get_latin_keyboard_variant() const {
- _THREAD_SAFE_METHOD_
+int DisplayServerX11::keyboard_get_layout_count() const {
+ int _group_count = 0;
+ XkbDescRec *kbd = XkbAllocKeyboard();
+ if (kbd) {
+ kbd->dpy = x11_display;
+ XkbGetControls(x11_display, XkbAllControlsMask, kbd);
+ XkbGetNames(x11_display, XkbSymbolsNameMask, kbd);
- XkbDescRec *xkbdesc = XkbAllocKeyboard();
- ERR_FAIL_COND_V(!xkbdesc, LATIN_KEYBOARD_QWERTY);
+ const Atom *groups = kbd->names->groups;
+ if (kbd->ctrls != NULL) {
+ _group_count = kbd->ctrls->num_groups;
+ } else {
+ while (_group_count < XkbNumKbdGroups && groups[_group_count] != None) {
+ _group_count++;
+ }
+ }
+ XkbFreeKeyboard(kbd, 0, true);
+ }
+ return _group_count;
+}
- XkbGetNames(x11_display, XkbSymbolsNameMask, xkbdesc);
- ERR_FAIL_COND_V(!xkbdesc->names, LATIN_KEYBOARD_QWERTY);
- ERR_FAIL_COND_V(!xkbdesc->names->symbols, LATIN_KEYBOARD_QWERTY);
+int DisplayServerX11::keyboard_get_current_layout() const {
+ XkbStateRec state;
+ XkbGetState(x11_display, XkbUseCoreKbd, &state);
+ return state.group;
+}
- char *layout = XGetAtomName(x11_display, xkbdesc->names->symbols);
- ERR_FAIL_COND_V(!layout, LATIN_KEYBOARD_QWERTY);
+void DisplayServerX11::keyboard_set_current_layout(int p_index) {
+ ERR_FAIL_INDEX(p_index, keyboard_get_layout_count());
+ XkbLockGroup(x11_display, XkbUseCoreKbd, p_index);
+}
- Vector<String> info = String(layout).split("+");
- ERR_FAIL_INDEX_V(1, info.size(), LATIN_KEYBOARD_QWERTY);
+String DisplayServerX11::keyboard_get_layout_language(int p_index) const {
+ String ret;
+ XkbDescRec *kbd = XkbAllocKeyboard();
+ if (kbd) {
+ kbd->dpy = x11_display;
+ XkbGetControls(x11_display, XkbAllControlsMask, kbd);
+ XkbGetNames(x11_display, XkbSymbolsNameMask, kbd);
+ XkbGetNames(x11_display, XkbGroupNamesMask, kbd);
+
+ int _group_count = 0;
+ const Atom *groups = kbd->names->groups;
+ if (kbd->ctrls != NULL) {
+ _group_count = kbd->ctrls->num_groups;
+ } else {
+ while (_group_count < XkbNumKbdGroups && groups[_group_count] != None) {
+ _group_count++;
+ }
+ }
- if (info[1].find("colemak") != -1) {
- return LATIN_KEYBOARD_COLEMAK;
- } else if (info[1].find("qwertz") != -1) {
- return LATIN_KEYBOARD_QWERTZ;
- } else if (info[1].find("azerty") != -1) {
- return LATIN_KEYBOARD_AZERTY;
- } else if (info[1].find("qzerty") != -1) {
- return LATIN_KEYBOARD_QZERTY;
- } else if (info[1].find("dvorak") != -1) {
- return LATIN_KEYBOARD_DVORAK;
- } else if (info[1].find("neo") != -1) {
- return LATIN_KEYBOARD_NEO;
+ Atom names = kbd->names->symbols;
+ if (names != None) {
+ char *name = XGetAtomName(x11_display, names);
+ Vector<String> info = String(name).split("+");
+ if (p_index >= 0 && p_index < _group_count) {
+ if (p_index + 1 < info.size()) {
+ ret = info[p_index + 1]; // Skip "pc" at the start and "inet"/"group" at the end of symbols.
+ } else {
+ ret = "en"; // No symbol for layout fallback to "en".
+ }
+ } else {
+ ERR_PRINT("Index " + itos(p_index) + "is out of bounds (" + itos(_group_count) + ").");
+ }
+ XFree(name);
+ }
+ XkbFreeKeyboard(kbd, 0, true);
}
+ return ret.substr(0, 2);
+}
+
+String DisplayServerX11::keyboard_get_layout_name(int p_index) const {
+ String ret;
+ XkbDescRec *kbd = XkbAllocKeyboard();
+ if (kbd) {
+ kbd->dpy = x11_display;
+ XkbGetControls(x11_display, XkbAllControlsMask, kbd);
+ XkbGetNames(x11_display, XkbSymbolsNameMask, kbd);
+ XkbGetNames(x11_display, XkbGroupNamesMask, kbd);
+
+ int _group_count = 0;
+ const Atom *groups = kbd->names->groups;
+ if (kbd->ctrls != NULL) {
+ _group_count = kbd->ctrls->num_groups;
+ } else {
+ while (_group_count < XkbNumKbdGroups && groups[_group_count] != None) {
+ _group_count++;
+ }
+ }
- return LATIN_KEYBOARD_QWERTY;
+ if (p_index >= 0 && p_index < _group_count) {
+ char *full_name = XGetAtomName(x11_display, groups[p_index]);
+ ret.parse_utf8(full_name);
+ XFree(full_name);
+ } else {
+ ERR_PRINT("Index " + itos(p_index) + "is out of bounds (" + itos(_group_count) + ").");
+ }
+ XkbFreeKeyboard(kbd, 0, true);
+ }
+ return ret;
}
DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display, Window p_window, Atom p_property) {
-
Atom actual_type;
int actual_format;
unsigned long nitems;
@@ -1918,8 +1960,9 @@ DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display,
//Keep trying to read the property until there are no
//bytes unread.
do {
- if (ret != nullptr)
+ if (ret != nullptr) {
XFree(ret);
+ }
XGetWindowProperty(p_display, p_window, p_property, 0, read_bytes, False, AnyPropertyType,
&actual_type, &actual_format, &nitems, &bytes_after,
@@ -1935,36 +1978,36 @@ DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display,
}
static Atom pick_target_from_list(Display *p_display, Atom *p_list, int p_count) {
-
static const char *target_type = "text/uri-list";
for (int i = 0; i < p_count; i++) {
-
Atom atom = p_list[i];
- if (atom != None && String(XGetAtomName(p_display, atom)) == target_type)
+ if (atom != None && String(XGetAtomName(p_display, atom)) == target_type) {
return atom;
+ }
}
return None;
}
static Atom pick_target_from_atoms(Display *p_disp, Atom p_t1, Atom p_t2, Atom p_t3) {
-
static const char *target_type = "text/uri-list";
- if (p_t1 != None && String(XGetAtomName(p_disp, p_t1)) == target_type)
+ if (p_t1 != None && String(XGetAtomName(p_disp, p_t1)) == target_type) {
return p_t1;
+ }
- if (p_t2 != None && String(XGetAtomName(p_disp, p_t2)) == target_type)
+ if (p_t2 != None && String(XGetAtomName(p_disp, p_t2)) == target_type) {
return p_t2;
+ }
- if (p_t3 != None && String(XGetAtomName(p_disp, p_t3)) == target_type)
+ if (p_t3 != None && String(XGetAtomName(p_disp, p_t3)) == target_type) {
return p_t3;
+ }
return None;
}
void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state) {
-
state->set_shift((p_x11_state & ShiftMask));
state->set_control((p_x11_state & ControlMask));
state->set_alt((p_x11_state & Mod1Mask /*|| p_x11_state&Mod5Mask*/)); //altgr should not count as alt
@@ -1972,7 +2015,6 @@ void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<Inp
}
unsigned int DisplayServerX11::_get_mouse_button_state(unsigned int p_x11_button, int p_x11_type) {
-
unsigned int mask = 1 << (p_x11_button - 1);
if (p_x11_type == ButtonPress) {
@@ -1985,7 +2027,6 @@ unsigned int DisplayServerX11::_get_mouse_button_state(unsigned int p_x11_button
}
void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, bool p_echo) {
-
WindowData wd = windows[p_window];
// X11 functions don't know what const is
XKeyEvent *xkeyevent = p_event;
@@ -2029,7 +2070,6 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
}
if (xkeyevent->type == KeyPress && wd.xic) {
-
Status status;
#ifdef X_HAVE_UTF8_STRING
int utf8len = 8;
@@ -2049,8 +2089,9 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode);
unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode);
- if (keycode >= 'a' && keycode <= 'z')
+ if (keycode >= 'a' && keycode <= 'z') {
keycode -= 'a' - 'A';
+ }
String tmp;
tmp.parse_utf8(utf8string, utf8bytes);
@@ -2093,7 +2134,6 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
memfree(utf8string);
#else
do {
-
int mnbytes = XmbLookupString(xic, xkeyevent, xmbstring, xmblen - 1, &keysym_unicode, &status);
xmbstring[mnbytes] = '\0';
@@ -2161,7 +2201,6 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
// difference in time is below a threshold.
if (xkeyevent->type != KeyPress) {
-
p_echo = false;
// make sure there are events pending,
@@ -2200,8 +2239,9 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
k->set_pressed(keypress);
- if (keycode >= 'a' && keycode <= 'z')
+ if (keycode >= 'a' && keycode <= 'z') {
keycode -= 'a' - 'A';
+ }
k->set_keycode(keycode);
k->set_physical_keycode(physical_keycode);
@@ -2218,14 +2258,15 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
//don't set mod state if modifier keys are released by themselves
//else event.is_action() will not work correctly here
if (!k->is_pressed()) {
- if (k->get_keycode() == KEY_SHIFT)
+ if (k->get_keycode() == KEY_SHIFT) {
k->set_shift(false);
- else if (k->get_keycode() == KEY_CONTROL)
+ } else if (k->get_keycode() == KEY_CONTROL) {
k->set_control(false);
- else if (k->get_keycode() == KEY_ALT)
+ } else if (k->get_keycode() == KEY_ALT) {
k->set_alt(false);
- else if (k->get_keycode() == KEY_META)
+ } else if (k->get_keycode() == KEY_META) {
k->set_metakey(false);
+ }
}
bool last_is_pressed = Input::get_singleton()->is_key_pressed(k->get_keycode());
@@ -2240,7 +2281,6 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
void DisplayServerX11::_xim_destroy_callback(::XIM im, ::XPointer client_data,
::XPointer call_data) {
-
WARN_PRINT("Input method stopped");
DisplayServerX11 *ds = reinterpret_cast<DisplayServerX11 *>(client_data);
ds->xim = nullptr;
@@ -2251,7 +2291,6 @@ void DisplayServerX11::_xim_destroy_callback(::XIM im, ::XPointer client_data,
}
void DisplayServerX11::_window_changed(XEvent *event) {
-
WindowID window_id = MAIN_WINDOW_ID;
// Assign the event to the relevant window
@@ -2316,7 +2355,6 @@ void DisplayServerX11::_dispatch_input_events(const Ref<InputEvent> &p_event) {
}
void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
-
Variant ev = p_event;
Variant *evp = &ev;
Variant ret;
@@ -2352,8 +2390,8 @@ void DisplayServerX11::_send_window_event(const WindowData &wd, WindowEvent p_ev
wd.event_callback.call((const Variant **)&eventp, 1, ret, ce);
}
}
-void DisplayServerX11::process_events() {
+void DisplayServerX11::process_events() {
_THREAD_SAFE_METHOD_
do_mouse_warp = false;
@@ -2384,9 +2422,7 @@ void DisplayServerX11::process_events() {
}
if (XGetEventData(x11_display, &event.xcookie)) {
-
if (event.xcookie.type == GenericEvent && event.xcookie.extension == xi.opcode) {
-
XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data;
int index = event_data->detail;
Vector2 pos = Vector2(event_data->event_x, event_data->event_y);
@@ -2493,7 +2529,6 @@ void DisplayServerX11::process_events() {
//XIAllowTouchEvents(x11_display, event_data->deviceid, event_data->detail, x11_window, XIAcceptTouch);
case XI_TouchEnd: {
-
bool is_begin = event_data->evtype == XI_TouchBegin;
Ref<InputEventScreenTouch> st;
@@ -2504,8 +2539,9 @@ void DisplayServerX11::process_events() {
st->set_pressed(is_begin);
if (is_begin) {
- if (xi.state.has(index)) // Defensive
+ if (xi.state.has(index)) { // Defensive
break;
+ }
xi.state[index] = pos;
if (xi.state.size() == 1) {
// X11 may send a motion event when a touch gesture begins, that would result
@@ -2514,22 +2550,21 @@ void DisplayServerX11::process_events() {
}
Input::get_singleton()->accumulate_input_event(st);
} else {
- if (!xi.state.has(index)) // Defensive
+ if (!xi.state.has(index)) { // Defensive
break;
+ }
xi.state.erase(index);
Input::get_singleton()->accumulate_input_event(st);
}
} break;
case XI_TouchUpdate: {
-
Map<int, Vector2>::Element *curr_pos_elem = xi.state.find(index);
if (!curr_pos_elem) { // Defensive
break;
}
if (curr_pos_elem->value() != pos) {
-
Ref<InputEventScreenDrag> sd;
sd.instance();
sd->set_window_id(window_id);
@@ -2581,11 +2616,11 @@ void DisplayServerX11::process_events() {
// Show and update the cursor if confined and the window regained focus.
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
-
- if (mouse_mode == MOUSE_MODE_CONFINED)
+ if (mouse_mode == MOUSE_MODE_CONFINED) {
XUndefineCursor(x11_display, E->get().x11_window);
- else if (mouse_mode == MOUSE_MODE_CAPTURED) // or re-hide it in captured mode
+ } else if (mouse_mode == MOUSE_MODE_CAPTURED) { // or re-hide it in captured mode
XDefineCursor(x11_display, E->get().x11_window, null_cursor);
+ }
XGrabPointer(
x11_display, E->get().x11_window, True,
@@ -2612,7 +2647,6 @@ void DisplayServerX11::process_events() {
if (mouse_mode_grab) {
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
-
//dear X11, I try, I really try, but you never work, you do whathever you want.
if (mouse_mode == MOUSE_MODE_CAPTURED) {
// Show the cursor if we're in captured mode so it doesn't look weird.
@@ -2629,7 +2663,6 @@ void DisplayServerX11::process_events() {
// Release every pointer to avoid sticky points
for (Map<int, Vector2>::Element *E = xi.state.front(); E; E = E->next()) {
-
Ref<InputEventScreenTouch> st;
st.instance();
st->set_index(E->key());
@@ -2649,7 +2682,6 @@ void DisplayServerX11::process_events() {
break;
case ButtonPress:
case ButtonRelease: {
-
/* exit in case of a mouse button press */
last_timestamp = event.xbutton.time;
if (mouse_mode == MOUSE_MODE_CAPTURED) {
@@ -2663,10 +2695,11 @@ void DisplayServerX11::process_events() {
mb->set_window_id(window_id);
_get_key_modifier_state(event.xbutton.state, mb);
mb->set_button_index(event.xbutton.button);
- if (mb->get_button_index() == 2)
+ if (mb->get_button_index() == 2) {
mb->set_button_index(3);
- else if (mb->get_button_index() == 3)
+ } else if (mb->get_button_index() == 3) {
mb->set_button_index(2);
+ }
mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type));
mb->set_position(Vector2(event.xbutton.x, event.xbutton.y));
mb->set_global_position(mb->get_position());
@@ -2674,13 +2707,10 @@ void DisplayServerX11::process_events() {
mb->set_pressed((event.type == ButtonPress));
if (event.type == ButtonPress) {
-
uint64_t diff = OS::get_singleton()->get_ticks_usec() / 1000 - last_click_ms;
if (mb->get_button_index() == last_click_button_index) {
-
if (diff < 400 && Vector2(last_click_pos).distance_to(Vector2(event.xbutton.x, event.xbutton.y)) < 5) {
-
last_click_ms = 0;
last_click_pos = Point2i(-100, -100);
last_click_button_index = -1;
@@ -2701,7 +2731,6 @@ void DisplayServerX11::process_events() {
} break;
case MotionNotify: {
-
// The X11 API requires filtering one-by-one through the motion
// notify events, in order to figure out which event is the one
// generated by warping the mouse pointer.
@@ -2757,7 +2786,6 @@ void DisplayServerX11::process_events() {
}
if (!last_mouse_pos_valid) {
-
last_mouse_pos = pos;
last_mouse_pos_valid = true;
}
@@ -2814,13 +2842,13 @@ void DisplayServerX11::process_events() {
// Don't propagate the motion event unless we have focus
// this is so that the relative motion doesn't get messed up
// after we regain focus.
- if (window_has_focus || !mouse_mode_grab)
+ if (window_has_focus || !mouse_mode_grab) {
Input::get_singleton()->accumulate_input_event(mm);
+ }
} break;
case KeyPress:
case KeyRelease: {
-
last_timestamp = event.xkey.time;
// key event is a little complex, so
@@ -2828,7 +2856,6 @@ void DisplayServerX11::process_events() {
_handle_key_event(window_id, (XKeyEvent *)&event);
} break;
case SelectionRequest: {
-
XSelectionRequestEvent *req;
XEvent e, respond;
e = event;
@@ -2851,7 +2878,6 @@ void DisplayServerX11::process_events() {
clip.length());
respond.xselection.property = req->property;
} else if (req->target == XInternAtom(x11_display, "TARGETS", 0)) {
-
Atom data[7];
data[0] = XInternAtom(x11_display, "TARGETS", 0);
data[1] = XInternAtom(x11_display, "UTF8_STRING", 0);
@@ -2874,8 +2900,9 @@ void DisplayServerX11::process_events() {
} else {
char *targetname = XGetAtomName(x11_display, req->target);
printf("No Target '%s'\n", targetname);
- if (targetname)
+ if (targetname) {
XFree(targetname);
+ }
respond.xselection.property = None;
}
@@ -2892,7 +2919,6 @@ void DisplayServerX11::process_events() {
case SelectionNotify:
if (event.xselection.target == requested) {
-
Property p = _read_property(x11_display, windows[window_id].x11_window, XInternAtom(x11_display, "PRIMARY", 0));
Vector<String> files = String((char *)p.data).split("\n", false);
@@ -2931,7 +2957,6 @@ void DisplayServerX11::process_events() {
}
else if ((unsigned int)event.xclient.message_type == (unsigned int)xdnd_enter) {
-
//File(s) have been dragged over the window, check for supported target (text/uri-list)
xdnd_version = (event.xclient.data.l[1] >> 24);
Window source = event.xclient.data.l[0];
@@ -2939,10 +2964,10 @@ void DisplayServerX11::process_events() {
if (more_than_3) {
Property p = _read_property(x11_display, source, XInternAtom(x11_display, "XdndTypeList", False));
requested = pick_target_from_list(x11_display, (Atom *)p.data, p.nitems);
- } else
+ } else {
requested = pick_target_from_atoms(x11_display, event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
+ }
} else if ((unsigned int)event.xclient.message_type == (unsigned int)xdnd_position) {
-
//xdnd position event, reply with an XDND status message
//just depending on type of data for now
XClientMessageEvent m;
@@ -2961,13 +2986,13 @@ void DisplayServerX11::process_events() {
XSendEvent(x11_display, event.xclient.data.l[0], False, NoEventMask, (XEvent *)&m);
XFlush(x11_display);
} else if ((unsigned int)event.xclient.message_type == (unsigned int)xdnd_drop) {
-
if (requested != None) {
xdnd_source_window = event.xclient.data.l[0];
- if (xdnd_version >= 1)
+ if (xdnd_version >= 1) {
XConvertSelection(x11_display, xdnd_selection, requested, XInternAtom(x11_display, "PRIMARY", 0), windows[window_id].x11_window, event.xclient.data.l[2]);
- else
+ } else {
XConvertSelection(x11_display, xdnd_selection, requested, XInternAtom(x11_display, "PRIMARY", 0), windows[window_id].x11_window, CurrentTime);
+ }
} else {
//Reply that we're not interested.
XClientMessageEvent m;
@@ -2992,7 +3017,6 @@ void DisplayServerX11::process_events() {
XFlush(x11_display);
if (do_mouse_warp) {
-
XWarpPointer(x11_display, None, windows[MAIN_WINDOW_ID].x11_window,
0, 0, 0, 0, (int)windows[MAIN_WINDOW_ID].size.width / 2, (int)windows[MAIN_WINDOW_ID].size.height / 2);
@@ -3024,7 +3048,6 @@ void DisplayServerX11::_update_context(WindowData &wd) {
XClassHint *classHint = XAllocClassHint();
if (classHint) {
-
CharString name_str;
switch (context) {
case CONTEXT_EDITOR:
@@ -3057,8 +3080,8 @@ void DisplayServerX11::_update_context(WindowData &wd) {
XFree(classHint);
}
}
-void DisplayServerX11::set_context(Context p_context) {
+void DisplayServerX11::set_context(Context p_context) {
_THREAD_SAFE_METHOD_
context = p_context;
@@ -3067,6 +3090,7 @@ void DisplayServerX11::set_context(Context p_context) {
_update_context(E->get());
}
}
+
void DisplayServerX11::set_native_icon(const String &p_filename) {
WARN_PRINT("Native icon not supported by this display server.");
}
@@ -3142,8 +3166,9 @@ void DisplayServerX11::set_icon(const Ref<Image> &p_icon) {
XChangeProperty(x11_display, wd.x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pd.ptr(), pd.size());
- if (!g_set_icon_error)
+ if (!g_set_icon_error) {
break;
+ }
}
} else {
XDeleteProperty(x11_display, wd.x11_window, net_wm_icon);
@@ -3167,12 +3192,10 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() {
}
DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
-
return memnew(DisplayServerX11(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
}
DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
-
//Create window
long visualMask = VisualScreenMask;
@@ -3254,7 +3277,6 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
XChangeProperty(x11_display, wd.x11_window, xdnd_aware, XA_ATOM, 32, PropModeReplace, (unsigned char *)&xdnd_version, 1);
if (xim && xim_style) {
-
wd.xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, wd.x11_window, XNFocusWindow, wd.x11_window, (char *)nullptr);
if (XGetICValues(wd.xic, XNFilterEvents, &im_event_mask, nullptr) != nullptr) {
WARN_PRINT("XGetICValues couldn't obtain XNFilterEvents value");
@@ -3267,7 +3289,6 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
WARN_PRINT("XCreateIC couldn't create wd.xic");
}
} else {
-
wd.xic = nullptr;
WARN_PRINT("XCreateIC couldn't create wd.xic");
}
@@ -3279,9 +3300,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
windows[id] = wd;
{
-
if (p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT) {
-
XSizeHints *xsh;
xsh = XAllocSizeHints();
@@ -3345,7 +3364,6 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
}
if (id != MAIN_WINDOW_ID) {
-
XSizeHints my_hints = XSizeHints();
my_hints.flags = PPosition | PSize; /* I want to specify position and size */
@@ -3395,14 +3413,12 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
//set cursor
if (cursors[current_cursor] != None) {
-
XDefineCursor(x11_display, wd.x11_window, cursors[current_cursor]);
}
return id;
}
DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
-
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
r_error = OK;
@@ -3411,7 +3427,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
mouse_mode = MOUSE_MODE_VISIBLE;
for (int i = 0; i < CURSOR_MAX; i++) {
-
cursors[i] = None;
img[i] = nullptr;
}
@@ -3446,7 +3461,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
// Try to support IME if detectable auto-repeat is supported
if (xkb_dar == True) {
-
#ifdef X_HAVE_UTF8_STRING
// Xutf8LookupString will be used later instead of XmbLookupString before
// the multibyte sequences can be converted to unicode string.
@@ -3523,10 +3537,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
if (xim_styles) {
xim_style = 0L;
for (int i = 0; i < xim_styles->count_styles; i++) {
-
if (xim_styles->supported_styles[i] ==
(XIMPreeditNothing | XIMStatusNothing)) {
-
xim_style = xim_styles->supported_styles[i];
break;
}
@@ -3561,7 +3573,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
context_vulkan = memnew(VulkanContextX11);
if (context_vulkan->initialize() != OK) {
memdelete(context_vulkan);
@@ -3583,7 +3594,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
getenv("PRIMUS_libGL") ||
getenv("PRIMUS_LOAD_GLOBAL") ||
getenv("BUMBLEBEE_SOCKET")) {
-
print_verbose("Optirun/primusrun detected. Skipping GPU detection");
use_prime = 0;
}
@@ -3595,7 +3605,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
for (int i = 0; i < libraries.size(); ++i) {
if (FileAccess::exists(libraries[i] + "/libGL.so.1") ||
FileAccess::exists(libraries[i] + "/libGL.so")) {
-
print_verbose("Custom libGL override detected. Skipping GPU detection");
use_prime = 0;
}
@@ -3649,7 +3658,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
//create RenderingDevice if used
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
//temporary
rendering_device_vulkan = memnew(RenderingDeviceVulkan);
rendering_device_vulkan->initialize(context_vulkan);
@@ -3695,7 +3703,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
}
for (int i = 0; i < CURSOR_MAX; i++) {
-
static const char *cursor_file[] = {
"left_ptr",
"xterm",
@@ -3830,8 +3837,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
r_error = OK;
}
-DisplayServerX11::~DisplayServerX11() {
+DisplayServerX11::~DisplayServerX11() {
//destroy all windows
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
#ifdef VULKAN_ENABLED
@@ -3850,25 +3857,28 @@ DisplayServerX11::~DisplayServerX11() {
//destroy drivers
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
if (rendering_device_vulkan) {
rendering_device_vulkan->finalize();
memdelete(rendering_device_vulkan);
}
- if (context_vulkan)
+ if (context_vulkan) {
memdelete(context_vulkan);
+ }
}
#endif
- if (xrandr_handle)
+ if (xrandr_handle) {
dlclose(xrandr_handle);
+ }
for (int i = 0; i < CURSOR_MAX; i++) {
- if (cursors[i] != None)
+ if (cursors[i] != None) {
XFreeCursor(x11_display, cursors[i]);
- if (img[i] != nullptr)
+ }
+ if (img[i] != nullptr) {
XcursorImageDestroy(img[i]);
+ }
};
if (xim) {
@@ -3876,12 +3886,12 @@ DisplayServerX11::~DisplayServerX11() {
}
XCloseDisplay(x11_display);
- if (xmbstring)
+ if (xmbstring) {
memfree(xmbstring);
+ }
}
void DisplayServerX11::register_x11_driver() {
-
register_create_function("x11", create_func, get_rendering_drivers_func);
}
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index b5ea71f72a..f01b9a2323 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -327,7 +327,11 @@ public:
virtual CursorShape cursor_get_shape() const;
virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+ virtual int keyboard_get_layout_count() const;
+ virtual int keyboard_get_current_layout() const;
+ virtual void keyboard_set_current_layout(int p_index);
+ virtual String keyboard_get_layout_language(int p_index) const;
+ virtual String keyboard_get_layout_name(int p_index) const;
virtual void process_events();
diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp
index 53e3ce8f85..86ea95c563 100644
--- a/platform/linuxbsd/export/export.cpp
+++ b/platform/linuxbsd/export/export.cpp
@@ -38,7 +38,6 @@
static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size);
void register_linuxbsd_exporter() {
-
Ref<EditorExportPlatformPC> platform;
platform.instance();
@@ -62,7 +61,6 @@ void register_linuxbsd_exporter() {
}
static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
-
// Patch the header of the "pck" section in the ELF file so that it corresponds to the embedded data
FileAccess *f = FileAccess::open(p_path, FileAccess::READ_WRITE);
@@ -139,7 +137,6 @@ static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start,
bool found = false;
for (int i = 0; i < num_sections; ++i) {
-
int64_t section_header_pos = section_table_pos + i * section_header_size;
f->seek(section_header_pos);
diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp
index 710ba3ca40..3ed64e9d46 100644
--- a/platform/linuxbsd/godot_linuxbsd.cpp
+++ b/platform/linuxbsd/godot_linuxbsd.cpp
@@ -37,7 +37,6 @@
#include "os_linuxbsd.h"
int main(int argc, char *argv[]) {
-
OS_LinuxBSD os;
setlocale(LC_CTYPE, "");
@@ -52,8 +51,9 @@ int main(int argc, char *argv[]) {
return 255;
}
- if (Main::start())
+ if (Main::start()) {
os.run(); // it is actually the OS that decides how to run
+ }
Main::cleanup();
if (ret) { // Previous getcwd was successful
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index f57f74907f..5edaf35c50 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -59,7 +59,6 @@ JoypadLinux::Joypad::Joypad() {
}
JoypadLinux::Joypad::~Joypad() {
-
for (int i = 0; i < MAX_ABS; i++) {
if (abs_info[i]) {
memdelete(abs_info[i]);
@@ -94,7 +93,6 @@ JoypadLinux::~JoypadLinux() {
}
void JoypadLinux::joy_thread_func(void *p_user) {
-
if (p_user) {
JoypadLinux *joy = (JoypadLinux *)p_user;
joy->run_joypad_thread();
@@ -115,7 +113,6 @@ void JoypadLinux::run_joypad_thread() {
#ifdef UDEV_ENABLED
void JoypadLinux::enumerate_joypads(udev *p_udev) {
-
udev_enumerate *enumerate;
udev_list_entry *devices, *dev_list_entry;
udev_device *dev;
@@ -126,13 +123,11 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
udev_list_entry_foreach(dev_list_entry, devices) {
-
const char *path = udev_list_entry_get_name(dev_list_entry);
dev = udev_device_new_from_syspath(p_udev, path);
const char *devnode = udev_device_get_devnode(dev);
if (devnode) {
-
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
MutexLock lock(joy_mutex);
@@ -145,7 +140,6 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
}
void JoypadLinux::monitor_joypads(udev *p_udev) {
-
udev_device *dev = nullptr;
udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev");
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", nullptr);
@@ -153,7 +147,6 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
int fd = udev_monitor_get_fd(mon);
while (!exit_udev) {
-
fd_set fds;
struct timeval tv;
int ret;
@@ -172,15 +165,12 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
dev = udev_monitor_receive_device(mon);
if (dev && udev_device_get_devnode(dev) != 0) {
-
MutexLock lock(joy_mutex);
String action = udev_device_get_action(dev);
const char *devnode = udev_device_get_devnode(dev);
if (devnode) {
-
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
-
if (action == "add")
open_joypad(devnode);
else if (String(action) == "remove")
@@ -198,7 +188,6 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
#endif
void JoypadLinux::monitor_joypads() {
-
while (!exit_udev) {
{
MutexLock lock(joy_mutex);
@@ -216,9 +205,7 @@ void JoypadLinux::monitor_joypads() {
}
int JoypadLinux::get_joy_from_path(String p_path) const {
-
for (int i = 0; i < JOYPADS_MAX; i++) {
-
if (joypads[i].devpath == p_path) {
return i;
}
@@ -229,17 +216,16 @@ int JoypadLinux::get_joy_from_path(String p_path) const {
void JoypadLinux::close_joypad(int p_id) {
if (p_id == -1) {
for (int i = 0; i < JOYPADS_MAX; i++) {
-
close_joypad(i);
};
return;
- } else if (p_id < 0)
+ } else if (p_id < 0) {
return;
+ }
Joypad &joy = joypads[p_id];
if (joy.fd != -1) {
-
close(joy.fd);
joy.fd = -1;
attached_devices.remove(attached_devices.find(joy.devpath));
@@ -248,7 +234,6 @@ void JoypadLinux::close_joypad(int p_id) {
}
static String _hex_str(uint8_t p_byte) {
-
static const char *dict = "0123456789abcdef";
char ret[3];
ret[2] = 0;
@@ -260,7 +245,6 @@ static String _hex_str(uint8_t p_byte) {
}
void JoypadLinux::setup_joypad_properties(int p_id) {
-
Joypad *joy = &joypads[p_id];
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
@@ -274,16 +258,12 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
return;
}
for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
-
if (test_bit(i, keybit)) {
-
joy->key_map[i] = num_buttons++;
}
}
for (int i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
-
if (test_bit(i, keybit)) {
-
joy->key_map[i] = num_buttons++;
}
}
@@ -294,7 +274,6 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
continue;
}
if (test_bit(i, absbit)) {
-
joy->abs_map[i] = num_axes++;
joy->abs_info[i] = memnew(input_absinfo);
if (ioctl(joy->fd, EVIOCGABS(i), joy->abs_info[i]) < 0) {
@@ -315,11 +294,9 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
}
void JoypadLinux::open_joypad(const char *p_path) {
-
int joy_num = input->get_unused_joy_id();
int fd = open(p_path, O_RDWR | O_NONBLOCK);
if (fd != -1 && joy_num != -1) {
-
unsigned long evbit[NBITS(EV_MAX)] = { 0 };
unsigned long keybit[NBITS(KEY_MAX)] = { 0 };
unsigned long absbit[NBITS(ABS_MAX)] = { 0 };
@@ -369,7 +346,6 @@ void JoypadLinux::open_joypad(const char *p_path) {
setup_joypad_properties(joy_num);
sprintf(uid, "%04x%04x", BSWAP16(inpid.bustype), 0);
if (inpid.vendor && inpid.product && inpid.version) {
-
uint16_t vendor = BSWAP16(inpid.vendor);
uint16_t product = BSWAP16(inpid.product);
uint16_t version = BSWAP16(inpid.version);
@@ -380,7 +356,6 @@ void JoypadLinux::open_joypad(const char *p_path) {
String uidname = uid;
int uidlen = MIN(name.length(), 11);
for (int i = 0; i < uidlen; i++) {
-
uidname = uidname + _hex_str(name[i]);
}
uidname += "00";
@@ -437,7 +412,6 @@ void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
}
Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
-
int min = p_abs->minimum;
int max = p_abs->maximum;
Input::JoyAxis jx;
@@ -457,14 +431,13 @@ Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value
}
void JoypadLinux::process_joypads() {
-
if (joy_mutex.try_lock() != OK) {
return;
}
for (int i = 0; i < JOYPADS_MAX; i++) {
-
- if (joypads[i].fd == -1)
+ if (joypads[i].fd == -1) {
continue;
+ }
input_event events[32];
Joypad *joy = &joypads[i];
@@ -474,13 +447,13 @@ void JoypadLinux::process_joypads() {
while ((len = read(joy->fd, events, (sizeof events))) > 0) {
len /= sizeof(events[0]);
for (int j = 0; j < len; j++) {
-
input_event &ev = events[j];
// ev may be tainted and out of MAX_KEY range, which will cause
// joy->key_map[ev.code] to crash
- if (ev.code >= MAX_KEY)
+ if (ev.code >= MAX_KEY) {
return;
+ }
switch (ev.type) {
case EV_KEY:
@@ -492,31 +465,36 @@ void JoypadLinux::process_joypads() {
switch (ev.code) {
case ABS_HAT0X:
if (ev.value != 0) {
- if (ev.value < 0)
+ if (ev.value < 0) {
joy->dpad |= Input::HAT_MASK_LEFT;
- else
+ } else {
joy->dpad |= Input::HAT_MASK_RIGHT;
- } else
+ }
+ } else {
joy->dpad &= ~(Input::HAT_MASK_LEFT | Input::HAT_MASK_RIGHT);
+ }
input->joy_hat(i, joy->dpad);
break;
case ABS_HAT0Y:
if (ev.value != 0) {
- if (ev.value < 0)
+ if (ev.value < 0) {
joy->dpad |= Input::HAT_MASK_UP;
- else
+ } else {
joy->dpad |= Input::HAT_MASK_DOWN;
- } else
+ }
+ } else {
joy->dpad &= ~(Input::HAT_MASK_UP | Input::HAT_MASK_DOWN);
+ }
input->joy_hat(i, joy->dpad);
break;
default:
- if (ev.code >= MAX_ABS)
+ if (ev.code >= MAX_ABS) {
return;
+ }
if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) {
Input::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value);
joy->curr_axis[joy->abs_map[ev.code]] = value;
diff --git a/platform/linuxbsd/key_mapping_x11.cpp b/platform/linuxbsd/key_mapping_x11.cpp
index 78bd2b71a0..77512b1a9e 100644
--- a/platform/linuxbsd/key_mapping_x11.cpp
+++ b/platform/linuxbsd/key_mapping_x11.cpp
@@ -33,7 +33,6 @@
/***** SCAN CODE CONVERSION ******/
struct _XTranslatePair {
-
KeySym keysym;
unsigned int keycode;
};
@@ -181,7 +180,6 @@ static _XTranslatePair _xkeysym_to_keycode[] = {
};
struct _TranslatePair {
-
unsigned int keysym;
unsigned int keycode;
};
@@ -301,10 +299,8 @@ static _TranslatePair _scancode_to_keycode[] = {
};
unsigned int KeyMappingX11::get_scancode(unsigned int p_code) {
-
unsigned int keycode = KEY_UNKNOWN;
for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
-
if (_scancode_to_keycode[i].keycode == p_code) {
keycode = _scancode_to_keycode[i].keysym;
break;
@@ -315,34 +311,34 @@ unsigned int KeyMappingX11::get_scancode(unsigned int p_code) {
}
unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) {
-
// kinda bruteforce.. could optimize.
- if (p_keysym < 0x100) // Latin 1, maps 1-1
+ if (p_keysym < 0x100) { // Latin 1, maps 1-1
return p_keysym;
+ }
// look for special key
for (int idx = 0; _xkeysym_to_keycode[idx].keysym != 0; idx++) {
-
- if (_xkeysym_to_keycode[idx].keysym == p_keysym)
+ if (_xkeysym_to_keycode[idx].keysym == p_keysym) {
return _xkeysym_to_keycode[idx].keycode;
+ }
}
return 0;
}
KeySym KeyMappingX11::get_keysym(unsigned int p_code) {
-
// kinda bruteforce.. could optimize.
- if (p_code < 0x100) // Latin 1, maps 1-1
+ if (p_code < 0x100) { // Latin 1, maps 1-1
return p_code;
+ }
// look for special key
for (int idx = 0; _xkeysym_to_keycode[idx].keysym != 0; idx++) {
-
- if (_xkeysym_to_keycode[idx].keycode == p_code)
+ if (_xkeysym_to_keycode[idx].keycode == p_code) {
return _xkeysym_to_keycode[idx].keysym;
+ }
}
return 0;
@@ -353,7 +349,6 @@ KeySym KeyMappingX11::get_keysym(unsigned int p_code) {
// Tables taken from FOX toolkit
struct _XTranslateUnicodePair {
-
KeySym keysym;
unsigned int unicode;
};
@@ -1125,37 +1120,41 @@ static _XTranslateUnicodePair _xkeysym_to_unicode[_KEYSYM_MAX] = {
};
unsigned int KeyMappingX11::get_unicode_from_keysym(KeySym p_keysym) {
-
/* Latin-1 */
- if (p_keysym >= 0x20 && p_keysym <= 0x7e)
+ if (p_keysym >= 0x20 && p_keysym <= 0x7e) {
return p_keysym;
- if (p_keysym >= 0xa0 && p_keysym <= 0xff)
+ }
+ if (p_keysym >= 0xa0 && p_keysym <= 0xff) {
return p_keysym;
+ }
// keypad to latin1 is easy
- if (p_keysym >= 0xffaa && p_keysym <= 0xffb9)
+ if (p_keysym >= 0xffaa && p_keysym <= 0xffb9) {
return p_keysym - 0xff80;
+ }
/* Unicode (may be present)*/
- if ((p_keysym & 0xff000000) == 0x01000000)
+ if ((p_keysym & 0xff000000) == 0x01000000) {
return p_keysym & 0x00ffffff;
+ }
int middle, low = 0, high = _KEYSYM_MAX - 1;
do {
middle = (high + low) / 2;
- if (_xkeysym_to_unicode[middle].keysym == p_keysym)
+ if (_xkeysym_to_unicode[middle].keysym == p_keysym) {
return _xkeysym_to_unicode[middle].unicode;
- if (_xkeysym_to_unicode[middle].keysym <= p_keysym)
+ }
+ if (_xkeysym_to_unicode[middle].keysym <= p_keysym) {
low = middle + 1;
- else
+ } else {
high = middle - 1;
+ }
} while (high >= low);
return 0;
}
struct _XTranslateUnicodePairReverse {
-
unsigned int unicode;
KeySym keysym;
};
@@ -1919,24 +1918,27 @@ static _XTranslateUnicodePairReverse _unicode_to_xkeysym[_UNICODE_MAX] = {
};
KeySym KeyMappingX11::get_keysym_from_unicode(unsigned int p_unicode) {
-
/* Latin 1 */
- if (p_unicode >= 0x20 && p_unicode <= 0x7e)
+ if (p_unicode >= 0x20 && p_unicode <= 0x7e) {
return p_unicode;
+ }
- if (p_unicode >= 0xa0 && p_unicode <= 0xff)
+ if (p_unicode >= 0xa0 && p_unicode <= 0xff) {
return p_unicode;
+ }
int middle, low = 0, high = _UNICODE_MAX - 1;
do {
middle = (high + low) / 2;
- if (_unicode_to_xkeysym[middle].keysym == p_unicode)
+ if (_unicode_to_xkeysym[middle].keysym == p_unicode) {
return _unicode_to_xkeysym[middle].keysym;
- if (_unicode_to_xkeysym[middle].keysym <= p_unicode)
+ }
+ if (_unicode_to_xkeysym[middle].keysym <= p_unicode) {
low = middle + 1;
- else
+ } else {
high = middle - 1;
+ }
} while (high >= low);
// if not found, let's hope X understands it as unicode
diff --git a/platform/linuxbsd/key_mapping_x11.h b/platform/linuxbsd/key_mapping_x11.h
index 10db43bcc4..8f5e01a3c2 100644
--- a/platform/linuxbsd/key_mapping_x11.h
+++ b/platform/linuxbsd/key_mapping_x11.h
@@ -41,7 +41,7 @@
#include "core/os/keyboard.h"
class KeyMappingX11 {
- KeyMappingX11(){};
+ KeyMappingX11() {}
public:
static unsigned int get_keycode(KeySym p_keysym);
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 7b76f7394b..09a5eca914 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -55,21 +55,18 @@
#endif
void OS_LinuxBSD::initialize() {
-
crash_handler.initialize();
OS_Unix::initialize_core();
}
void OS_LinuxBSD::initialize_joypads() {
-
#ifdef JOYDEV_ENABLED
joypad = memnew(JoypadLinux(Input::get_singleton()));
#endif
}
String OS_LinuxBSD::get_unique_id() const {
-
static String machine_id;
if (machine_id.empty()) {
if (FileAccess *f = FileAccess::open("/etc/machine-id", FileAccess::READ)) {
@@ -84,9 +81,9 @@ String OS_LinuxBSD::get_unique_id() const {
}
void OS_LinuxBSD::finalize() {
-
- if (main_loop)
+ if (main_loop) {
memdelete(main_loop);
+ }
main_loop = nullptr;
#ifdef ALSAMIDI_ENABLED
@@ -99,24 +96,21 @@ void OS_LinuxBSD::finalize() {
}
MainLoop *OS_LinuxBSD::get_main_loop() const {
-
return main_loop;
}
void OS_LinuxBSD::delete_main_loop() {
-
- if (main_loop)
+ if (main_loop) {
memdelete(main_loop);
+ }
main_loop = nullptr;
}
void OS_LinuxBSD::set_main_loop(MainLoop *p_main_loop) {
-
main_loop = p_main_loop;
}
String OS_LinuxBSD::get_name() const {
-
#ifdef __linux__
return "Linux";
#elif defined(__FreeBSD__)
@@ -129,27 +123,26 @@ String OS_LinuxBSD::get_name() const {
}
Error OS_LinuxBSD::shell_open(String p_uri) {
-
Error ok;
List<String> args;
args.push_back(p_uri);
ok = execute("xdg-open", args, false);
- if (ok == OK)
+ if (ok == OK) {
return OK;
+ }
ok = execute("gnome-open", args, false);
- if (ok == OK)
+ if (ok == OK) {
return OK;
+ }
ok = execute("kde-open", args, false);
return ok;
}
bool OS_LinuxBSD::_check_internal_feature_support(const String &p_feature) {
-
return p_feature == "pc";
}
String OS_LinuxBSD::get_config_path() const {
-
if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
@@ -160,7 +153,6 @@ String OS_LinuxBSD::get_config_path() const {
}
String OS_LinuxBSD::get_data_path() const {
-
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else if (has_environment("HOME")) {
@@ -171,7 +163,6 @@ String OS_LinuxBSD::get_data_path() const {
}
String OS_LinuxBSD::get_cache_path() const {
-
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
@@ -182,46 +173,37 @@ String OS_LinuxBSD::get_cache_path() const {
}
String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const {
-
String xdgparam;
switch (p_dir) {
case SYSTEM_DIR_DESKTOP: {
-
xdgparam = "DESKTOP";
} break;
case SYSTEM_DIR_DCIM: {
-
xdgparam = "PICTURES";
} break;
case SYSTEM_DIR_DOCUMENTS: {
-
xdgparam = "DOCUMENTS";
} break;
case SYSTEM_DIR_DOWNLOADS: {
-
xdgparam = "DOWNLOAD";
} break;
case SYSTEM_DIR_MOVIES: {
-
xdgparam = "VIDEOS";
} break;
case SYSTEM_DIR_MUSIC: {
-
xdgparam = "MUSIC";
} break;
case SYSTEM_DIR_PICTURES: {
-
xdgparam = "PICTURES";
} break;
case SYSTEM_DIR_RINGTONES: {
-
xdgparam = "MUSIC";
} break;
@@ -231,17 +213,18 @@ String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const {
List<String> arg;
arg.push_back(xdgparam);
Error err = const_cast<OS_LinuxBSD *>(this)->execute("xdg-user-dir", arg, true, nullptr, &pipe);
- if (err != OK)
+ if (err != OK) {
return ".";
+ }
return pipe.strip_edges();
}
void OS_LinuxBSD::run() {
-
force_quit = false;
- if (!main_loop)
+ if (!main_loop) {
return;
+ }
main_loop->init();
@@ -251,13 +234,13 @@ void OS_LinuxBSD::run() {
//uint64_t frame=0;
while (!force_quit) {
-
DisplayServer::get_singleton()->process_events(); // get rid of pending events
#ifdef JOYDEV_ENABLED
joypad->process_joypads();
#endif
- if (Main::iteration())
+ if (Main::iteration()) {
break;
+ }
};
main_loop->finish();
@@ -363,7 +346,6 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
}
OS_LinuxBSD::OS_LinuxBSD() {
-
main_loop = nullptr;
force_quit = false;
diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h
index 391f29e8a3..4295721c68 100644
--- a/platform/linuxbsd/os_linuxbsd.h
+++ b/platform/linuxbsd/os_linuxbsd.h
@@ -43,7 +43,6 @@
#include "servers/rendering_server.h"
class OS_LinuxBSD : public OS_Unix {
-
virtual void delete_main_loop();
bool force_quit;
diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp
index 1798a7026e..2eaa9f9446 100644
--- a/platform/linuxbsd/vulkan_context_x11.cpp
+++ b/platform/linuxbsd/vulkan_context_x11.cpp
@@ -36,7 +36,6 @@ const char *VulkanContextX11::_get_platform_surface_extension() const {
}
Error VulkanContextX11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) {
-
VkXlibSurfaceCreateInfoKHR createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
createInfo.pNext = nullptr;
diff --git a/platform/linuxbsd/vulkan_context_x11.h b/platform/linuxbsd/vulkan_context_x11.h
index 6e144ab2d9..af3d923cfe 100644
--- a/platform/linuxbsd/vulkan_context_x11.h
+++ b/platform/linuxbsd/vulkan_context_x11.h
@@ -35,7 +35,6 @@
#include <X11/Xlib.h>
class VulkanContextX11 : public VulkanContext {
-
virtual const char *_get_platform_surface_extension() const;
public:
diff --git a/platform/osx/context_gl_osx.h b/platform/osx/context_gl_osx.h
index 7e436c5e36..cce00fb35f 100644
--- a/platform/osx/context_gl_osx.h
+++ b/platform/osx/context_gl_osx.h
@@ -41,7 +41,6 @@
#include <CoreVideo/CoreVideo.h>
class ContextGL_OSX {
-
bool opengl_3_context;
bool use_vsync;
diff --git a/platform/osx/context_gl_osx.mm b/platform/osx/context_gl_osx.mm
index 91d1332d24..2319e9eb1f 100644
--- a/platform/osx/context_gl_osx.mm
+++ b/platform/osx/context_gl_osx.mm
@@ -33,42 +33,34 @@
#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
void ContextGL_OSX::release_current() {
-
[NSOpenGLContext clearCurrentContext];
}
void ContextGL_OSX::make_current() {
-
[context makeCurrentContext];
}
void ContextGL_OSX::update() {
-
[context update];
}
void ContextGL_OSX::set_opacity(GLint p_opacity) {
-
[context setValues:&p_opacity forParameter:NSOpenGLCPSurfaceOpacity];
}
int ContextGL_OSX::get_window_width() {
-
return OS::get_singleton()->get_video_mode().width;
}
int ContextGL_OSX::get_window_height() {
-
return OS::get_singleton()->get_video_mode().height;
}
void ContextGL_OSX::swap_buffers() {
-
[context flushBuffer];
}
void ContextGL_OSX::set_use_vsync(bool p_use) {
-
CGLContextObj ctx = CGLGetCurrentContext();
if (ctx) {
GLint swapInterval = p_use ? 1 : 0;
@@ -78,12 +70,10 @@ void ContextGL_OSX::set_use_vsync(bool p_use) {
}
bool ContextGL_OSX::is_using_vsync() const {
-
return use_vsync;
}
Error ContextGL_OSX::initialize() {
-
framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
ERR_FAIL_COND_V(!framework, ERR_CANT_CREATE);
@@ -161,7 +151,6 @@ Error ContextGL_OSX::initialize() {
}
ContextGL_OSX::ContextGL_OSX(id p_view, bool p_opengl_3_context) {
-
opengl_3_context = p_opengl_3_context;
window_view = p_view;
use_vsync = false;
diff --git a/platform/osx/crash_handler_osx.h b/platform/osx/crash_handler_osx.h
index abd9812596..9970f6045a 100644
--- a/platform/osx/crash_handler_osx.h
+++ b/platform/osx/crash_handler_osx.h
@@ -32,7 +32,6 @@
#define CRASH_HANDLER_OSX_H
class CrashHandler {
-
bool disabled;
public:
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm
index 66ea380903..7791ba5407 100644
--- a/platform/osx/dir_access_osx.mm
+++ b/platform/osx/dir_access_osx.mm
@@ -38,7 +38,6 @@
#include <Foundation/Foundation.h>
String DirAccessOSX::fix_unicode_name(const char *p_name) const {
-
String fname;
NSString *nsstr = [[NSString stringWithUTF8String:p_name] precomposedStringWithCanonicalMapping];
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index 8133dfe2c4..fddb1d0ca6 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -281,7 +281,11 @@ public:
virtual bool get_swap_ok_cancel();
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+ virtual int keyboard_get_layout_count() const;
+ virtual int keyboard_get_current_layout() const;
+ virtual void keyboard_set_current_layout(int p_index);
+ virtual String keyboard_get_layout_language(int p_index) const;
+ virtual String keyboard_get_layout_name(int p_index) const;
virtual void process_events();
virtual void force_process_and_drop_events();
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index 71e4584dac..4a94e09c1c 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -149,6 +149,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
Variant meta;
bool checkable;
}
+
@end
@implementation GlobalMenuItem
@@ -277,13 +278,17 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (BOOL)windowShouldClose:(id)sender {
- ERR_FAIL_COND_V(!DS_OSX->windows.has(window_id), YES);
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return YES;
+ }
DS_OSX->_send_window_event(DS_OSX->windows[window_id], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST);
return NO;
}
- (void)windowWillClose:(NSNotification *)notification {
- ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
while (wd.transient_children.size()) {
@@ -309,7 +314,9 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidEnterFullScreen:(NSNotification *)notification {
- ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
wd.fullscreen = true;
@@ -319,8 +326,9 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidExitFullScreen:(NSNotification *)notification {
- if (!DS_OSX || !DS_OSX->windows.has(window_id))
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
wd.fullscreen = false;
@@ -382,8 +390,9 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidResize:(NSNotification *)notification {
- if (!DS_OSX || !DS_OSX->windows.has(window_id))
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
#if defined(OPENGL_ENABLED)
@@ -424,11 +433,26 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidMove:(NSNotification *)notification {
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
+ DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
+
DS_OSX->_release_pressed_events();
+
+ if (!wd.rect_changed_callback.is_null()) {
+ Variant size = Rect2i(DS_OSX->window_get_position(window_id), DS_OSX->window_get_size(window_id));
+ Variant *sizep = &size;
+ Variant ret;
+ Callable::CallError ce;
+ wd.rect_changed_callback.call((const Variant **)&sizep, 1, ret, ce);
+ }
}
- (void)windowDidBecomeKey:(NSNotification *)notification {
- ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
const CGFloat backingScaleFactor = (OS::get_singleton()->is_hidpi_allowed()) ? [wd.window_view backingScaleFactor] : 1.0;
@@ -440,7 +464,9 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidResignKey:(NSNotification *)notification {
- ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
DS_OSX->window_focused = false;
@@ -450,7 +476,9 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidMiniaturize:(NSNotification *)notification {
- ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
DS_OSX->window_focused = false;
@@ -460,7 +488,9 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
- (void)windowDidDeminiaturize:(NSNotification *)notification {
- ERR_FAIL_COND(!DS_OSX->windows.has(window_id));
+ if (!DS_OSX || !DS_OSX->windows.has(window_id)) {
+ return;
+ }
DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id];
DS_OSX->window_focused = true;
@@ -921,7 +951,6 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, i
}
static bool isNumpadKey(unsigned int key) {
-
static const unsigned int table[] = {
0x41, /* kVK_ANSI_KeypadDecimal */
0x43, /* kVK_ANSI_KeypadMultiply */
@@ -954,7 +983,6 @@ static bool isNumpadKey(unsigned int key) {
// Translates a OS X keycode to a Godot keycode
//
static int translateKey(unsigned int key) {
-
// Keyboard symbol translation table
static const unsigned int table[128] = {
/* 00 */ KEY_A,
@@ -1424,6 +1452,7 @@ inline void sendPanEvent(DisplayServer::WindowID window_id, double dx, double dy
@interface GodotWindow : NSWindow {
}
+
@end
@implementation GodotWindow
@@ -2148,7 +2177,7 @@ Rect2i DisplayServerOSX::screen_get_usable_rect(int p_screen) const {
Point2i position = Point2i(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * displayScale - _get_screens_origin();
position.y *= -1;
- Size2i size = Size2i(nsrect.size.width, nsrect.size.height) / displayScale;
+ Size2i size = Size2i(nsrect.size.width, nsrect.size.height) * displayScale;
return Rect2i(position, size);
}
@@ -2958,86 +2987,129 @@ void DisplayServerOSX::cursor_set_custom_image(const RES &p_cursor, CursorShape
}
}
+struct LayoutInfo {
+ String name;
+ String code;
+};
+
+static Vector<LayoutInfo> kbd_layouts;
+static int current_layout = 0;
static bool keyboard_layout_dirty = true;
static void keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) {
+ kbd_layouts.clear();
+ current_layout = 0;
keyboard_layout_dirty = true;
}
-// Returns string representation of keys, if they are printable.
-static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
- TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
- if (!currentKeyboard)
- return nil;
+void _update_keyboard_layouts() {
+ @autoreleasepool {
+ TISInputSourceRef cur_source = TISCopyCurrentKeyboardInputSource();
+ NSString *cur_name = (NSString *)TISGetInputSourceProperty(cur_source, kTISPropertyLocalizedName);
+ CFRelease(cur_source);
- CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
- if (!layoutData)
- return nil;
+ // Enum IME layouts
+ NSDictionary *filter_ime = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode };
+ NSArray *list_ime = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_ime, false);
+ for (NSUInteger i = 0; i < [list_ime count]; i++) {
+ LayoutInfo ly;
+ NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyLocalizedName);
+ ly.name.parse_utf8([name UTF8String]);
- const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
+ NSArray *langs = (NSArray *)TISGetInputSourceProperty((TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyInputSourceLanguages);
+ ly.code.parse_utf8([(NSString *)[langs objectAtIndex:0] UTF8String]);
+ kbd_layouts.push_back(ly);
- OSStatus err;
- CFMutableStringRef output = CFStringCreateMutable(NULL, 0);
+ if ([name isEqualToString:cur_name]) {
+ current_layout = kbd_layouts.size() - 1;
+ }
+ }
+ [list_ime release];
- for (int i = 0; i < length; ++i) {
- UInt32 keysDown = 0;
- UniChar chars[4];
- UniCharCount realLength;
+ // Enum plain keyboard layouts
+ NSDictionary *filter_kbd = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout };
+ NSArray *list_kbd = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_kbd, false);
+ for (NSUInteger i = 0; i < [list_kbd count]; i++) {
+ LayoutInfo ly;
+ NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyLocalizedName);
+ ly.name.parse_utf8([name UTF8String]);
- err = UCKeyTranslate(keyboardLayout,
- keyCode[i],
- kUCKeyActionDisplay,
- 0,
- LMGetKbdType(),
- kUCKeyTranslateNoDeadKeysBit,
- &keysDown,
- sizeof(chars) / sizeof(chars[0]),
- &realLength,
- chars);
+ NSArray *langs = (NSArray *)TISGetInputSourceProperty((TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyInputSourceLanguages);
+ ly.code.parse_utf8([(NSString *)[langs objectAtIndex:0] UTF8String]);
+ kbd_layouts.push_back(ly);
- if (err != noErr) {
- CFRelease(output);
- return nil;
+ if ([name isEqualToString:cur_name]) {
+ current_layout = kbd_layouts.size() - 1;
+ }
}
-
- CFStringAppendCharacters(output, chars, 1);
+ [list_kbd release];
}
- return (NSString *)output;
+ keyboard_layout_dirty = false;
}
-DisplayServerOSX::LatinKeyboardVariant DisplayServerOSX::get_latin_keyboard_variant() const {
- _THREAD_SAFE_METHOD_
-
- static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
+int DisplayServerOSX::keyboard_get_layout_count() const {
+ if (keyboard_layout_dirty) {
+ _update_keyboard_layouts();
+ }
+ return kbd_layouts.size();
+}
+void DisplayServerOSX::keyboard_set_current_layout(int p_index) {
if (keyboard_layout_dirty) {
+ _update_keyboard_layouts();
+ }
+
+ ERR_FAIL_INDEX(p_index, kbd_layouts.size());
- layout = LATIN_KEYBOARD_QWERTY;
+ NSString *cur_name = [NSString stringWithUTF8String:kbd_layouts[p_index].name.utf8().get_data()];
- CGKeyCode keys[] = { kVK_ANSI_Q, kVK_ANSI_W, kVK_ANSI_E, kVK_ANSI_R, kVK_ANSI_T, kVK_ANSI_Y };
- NSString *test = createStringForKeys(keys, 6);
+ NSDictionary *filter_kbd = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout };
+ NSArray *list_kbd = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_kbd, false);
+ for (NSUInteger i = 0; i < [list_kbd count]; i++) {
+ NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyLocalizedName);
+ if ([name isEqualToString:cur_name]) {
+ TISSelectInputSource((TISInputSourceRef)[list_kbd objectAtIndex:i]);
+ break;
+ }
+ }
+ [list_kbd release];
- if ([test isEqualToString:@"qwertz"]) {
- layout = LATIN_KEYBOARD_QWERTZ;
- } else if ([test isEqualToString:@"azerty"]) {
- layout = LATIN_KEYBOARD_AZERTY;
- } else if ([test isEqualToString:@"qzerty"]) {
- layout = LATIN_KEYBOARD_QZERTY;
- } else if ([test isEqualToString:@"',.pyf"]) {
- layout = LATIN_KEYBOARD_DVORAK;
- } else if ([test isEqualToString:@"xvlcwk"]) {
- layout = LATIN_KEYBOARD_NEO;
- } else if ([test isEqualToString:@"qwfpgj"]) {
- layout = LATIN_KEYBOARD_COLEMAK;
+ NSDictionary *filter_ime = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode };
+ NSArray *list_ime = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_ime, false);
+ for (NSUInteger i = 0; i < [list_ime count]; i++) {
+ NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyLocalizedName);
+ if ([name isEqualToString:cur_name]) {
+ TISSelectInputSource((TISInputSourceRef)[list_ime objectAtIndex:i]);
+ break;
}
+ }
+ [list_ime release];
+}
+
+int DisplayServerOSX::keyboard_get_current_layout() const {
+ if (keyboard_layout_dirty) {
+ _update_keyboard_layouts();
+ }
- [test release];
+ return current_layout;
+}
- keyboard_layout_dirty = false;
- return layout;
+String DisplayServerOSX::keyboard_get_layout_language(int p_index) const {
+ if (keyboard_layout_dirty) {
+ _update_keyboard_layouts();
}
- return layout;
+ ERR_FAIL_INDEX_V(p_index, kbd_layouts.size(), "");
+ return kbd_layouts[p_index].code;
+}
+
+String DisplayServerOSX::keyboard_get_layout_name(int p_index) const {
+ if (keyboard_layout_dirty) {
+ _update_keyboard_layouts();
+ }
+
+ ERR_FAIL_INDEX_V(p_index, kbd_layouts.size(), "");
+ return kbd_layouts[p_index].name;
}
void DisplayServerOSX::_push_input(const Ref<InputEvent> &p_event) {
@@ -3553,7 +3625,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
#endif
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
context_vulkan = memnew(VulkanContextOSX);
if (context_vulkan->initialize() != OK) {
memdelete(context_vulkan);
@@ -3613,7 +3684,6 @@ DisplayServerOSX::~DisplayServerOSX() {
//destroy drivers
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
if (rendering_device_vulkan) {
rendering_device_vulkan->finalize();
memdelete(rendering_device_vulkan);
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index c2df9c7082..c9b01ebbb4 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -46,7 +46,6 @@
#include <sys/stat.h>
class EditorExportPlatformOSX : public EditorExportPlatform {
-
GDCLASS(EditorExportPlatformOSX, EditorExportPlatform);
int version_code;
@@ -56,8 +55,10 @@ class EditorExportPlatformOSX : public EditorExportPlatform {
void _fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary);
void _make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data);
+ Error _notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path);
Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path);
Error _create_dmg(const String &p_dmg_path, const String &p_pkg_name, const String &p_app_path_name);
+ void _zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name);
#ifdef OSX_ENABLED
bool use_codesign() const { return true; }
@@ -66,6 +67,28 @@ class EditorExportPlatformOSX : public EditorExportPlatform {
bool use_codesign() const { return false; }
bool use_dmg() const { return false; }
#endif
+ bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const {
+ String pname = p_package;
+
+ if (pname.length() == 0) {
+ if (r_error) {
+ *r_error = TTR("Identifier is missing.");
+ }
+ return false;
+ }
+
+ for (int i = 0; i < pname.length(); i++) {
+ CharType c = pname[i];
+ if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '.')) {
+ if (r_error) {
+ *r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c));
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
protected:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
@@ -89,7 +112,6 @@ public:
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual void get_platform_features(List<String> *r_features) {
-
r_features->push_back("pc");
r_features->push_back("s3tc");
r_features->push_back("OSX");
@@ -117,7 +139,6 @@ void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset>
}
void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) {
-
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
@@ -140,6 +161,11 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/hardened_runtime"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements", PROPERTY_HINT_GLOBAL_FILE, "*.plist"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "notarization/enable"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Apple ID email"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_id_password", PROPERTY_HINT_PLACEHOLDER_TEXT, "Enable two-factor authentication and provide app-specific password"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "notarization/apple_team_id", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide team ID if your Apple ID belongs to multiple teams"), ""));
#endif
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
@@ -148,7 +174,6 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options)
}
void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector<uint8_t> &p_source, Vector<uint8_t> &p_dest) {
-
int src_len = p_size * p_size;
Vector<uint8_t> result;
@@ -163,7 +188,6 @@ void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector<uint8_t> &p_source,
uint8_t cur = p_source.ptr()[i * 4 + p_ch];
if (i < src_len - 2) {
-
if ((p_source.ptr()[(i + 1) * 4 + p_ch] == cur) && (p_source.ptr()[(i + 2) * 4 + p_ch] == cur)) {
if (buf_size > 0) {
result.write[res_size++] = (uint8_t)(buf_size - 1);
@@ -215,7 +239,6 @@ void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector<uint8_t> &p_source,
}
void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_t> &p_data) {
-
Ref<ImageTexture> it = memnew(ImageTexture);
Vector<uint8_t> data;
@@ -320,7 +343,6 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_
}
void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
-
String str;
String strnew;
str.parse_utf8((const char *)plist.ptr(), plist.size());
@@ -369,7 +391,54 @@ void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset
- and then wrap it up in a DMG
**/
+Error EditorExportPlatformOSX::_notarize(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
+#ifdef OSX_ENABLED
+ List<String> args;
+
+ args.push_back("altool");
+ args.push_back("--notarize-app");
+
+ args.push_back("--primary-bundle-id");
+ args.push_back(p_preset->get("application/identifier"));
+
+ args.push_back("--username");
+ args.push_back(p_preset->get("notarization/apple_id_name"));
+
+ args.push_back("--password");
+ args.push_back(p_preset->get("notarization/apple_id_password"));
+
+ args.push_back("--type");
+ args.push_back("osx");
+
+ if (p_preset->get("notarization/apple_team_id")) {
+ args.push_back("--asc-provider");
+ args.push_back(p_preset->get("notarization/apple_team_id"));
+ }
+
+ args.push_back("--file");
+ args.push_back(p_path);
+
+ String str;
+ Error err = OS::get_singleton()->execute("xcrun", args, true, nullptr, &str, nullptr, true);
+ ERR_FAIL_COND_V(err != OK, err);
+
+ print_line("altool (" + p_path + "):\n" + str);
+ if (str.find("RequestUUID") == -1) {
+ EditorNode::add_io_error("altool: " + str);
+ return FAILED;
+ } else {
+ print_line("Note: The notarization process generally takes less than an hour. When the process is completed, you'll receive an email.");
+ print_line(" You can check progress manually by opening a Terminal and running the following command:");
+ print_line(" \"xcrun altool --notarization-history 0 -u <your email> -p <app-specific pwd>\"");
+ }
+
+#endif
+
+ return OK;
+}
+
Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
+#ifdef OSX_ENABLED
List<String> args;
if (p_preset->get("codesign/timestamp")) {
@@ -380,8 +449,7 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese
args.push_back("runtime");
}
- if (p_preset->get("codesign/entitlements") != "") {
- /* this should point to our entitlements.plist file that sandboxes our application, I don't know if this should also be placed in our app bundle */
+ if ((p_preset->get("codesign/entitlements") != "") && (p_path.get_extension() != "dmg")) {
args.push_back("--entitlements");
args.push_back(p_preset->get("codesign/entitlements"));
}
@@ -405,7 +473,7 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese
Error err = OS::get_singleton()->execute("codesign", args, true, nullptr, &str, nullptr, true);
ERR_FAIL_COND_V(err != OK, err);
- print_line("codesign (" + p_path + "): " + str);
+ print_line("codesign (" + p_path + "):\n" + str);
if (str.find("no identity found") != -1) {
EditorNode::add_io_error("codesign: no identity found");
return FAILED;
@@ -414,6 +482,7 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese
EditorNode::add_io_error("codesign: invalid entitlements file");
return FAILED;
}
+#endif
return OK;
}
@@ -458,10 +527,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
EditorProgress ep("export", "Exporting for OSX", 3, true);
- if (p_debug)
+ if (p_debug) {
src_pkg_name = p_preset->get("custom_template/debug");
- else
+ } else {
src_pkg_name = p_preset->get("custom_template/release");
+ }
if (src_pkg_name == "") {
String err;
@@ -485,7 +555,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io);
if (!src_pkg_zip) {
-
EditorNode::add_io_error("Could not find template app to export:\n" + src_pkg_name);
return ERR_FILE_NOT_FOUND;
}
@@ -495,64 +564,54 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".64";
String pkg_name;
- if (p_preset->get("application/name") != "")
+ if (p_preset->get("application/name") != "") {
pkg_name = p_preset->get("application/name"); // app_name
- else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "")
+ } else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
- else
+ } else {
pkg_name = "Unnamed";
+ }
String pkg_name_safe = OS::get_singleton()->get_safe_dir_name(pkg_name);
Error err = OK;
String tmp_app_path_name = "";
- zlib_filefunc_def io2 = io;
- FileAccess *dst_f = nullptr;
- io2.opaque = &dst_f;
- zipFile dst_pkg_zip = nullptr;
DirAccess *tmp_app_path = nullptr;
String export_format = use_dmg() && p_path.ends_with("dmg") ? "dmg" : "zip";
- if (export_format == "dmg") {
- // We're on OSX so we can export to DMG, but first we create our application bundle
- tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app");
- print_line("Exporting to " + tmp_app_path_name);
- tmp_app_path = DirAccess::create_for_path(tmp_app_path_name);
- if (!tmp_app_path) {
- err = ERR_CANT_CREATE;
- }
- // Create our folder structure or rely on unzip?
- if (err == OK) {
- print_line("Creating " + tmp_app_path_name + "/Contents/MacOS");
- err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/MacOS");
- }
+ // Create our application bundle.
+ tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app");
+ print_line("Exporting to " + tmp_app_path_name);
+ tmp_app_path = DirAccess::create_for_path(tmp_app_path_name);
+ if (!tmp_app_path) {
+ err = ERR_CANT_CREATE;
+ }
- if (err == OK) {
- print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks");
- err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
- }
+ // Create our folder structure.
+ if (err == OK) {
+ print_line("Creating " + tmp_app_path_name + "/Contents/MacOS");
+ err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/MacOS");
+ }
- if (err == OK) {
- print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
- err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
- }
- } else {
- // Open our destination zip file
- dst_pkg_zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2);
- if (!dst_pkg_zip) {
- err = ERR_CANT_CREATE;
- }
+ if (err == OK) {
+ print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks");
+ err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
}
- // Now process our template
+ if (err == OK) {
+ print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
+ err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
+ }
+
+ // Now process our template.
bool found_binary = false;
int total_size = 0;
while (ret == UNZ_OK && err == OK) {
bool is_execute = false;
- //get filename
+ // Get filename.
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0);
@@ -562,13 +621,12 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
- //read
+ // Read.
unzOpenCurrentFile(src_pkg_zip);
unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size());
unzCloseCurrentFile(src_pkg_zip);
- //write
-
+ // Write.
file = file.replace_first("osx_template.app/", "");
if (file == "Contents/Info.plist") {
@@ -578,7 +636,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (file.begins_with("Contents/MacOS/godot_")) {
if (file != "Contents/MacOS/" + binary_to_use) {
ret = unzGoToNextFile(src_pkg_zip);
- continue; //ignore!
+ continue; // skip
}
found_binary = true;
is_execute = true;
@@ -586,12 +644,13 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
if (file == "Contents/Resources/icon.icns") {
- //see if there is an icon
+ // See if there is an icon.
String iconpath;
- if (p_preset->get("application/icon") != "")
+ if (p_preset->get("application/icon") != "") {
iconpath = p_preset->get("application/icon");
- else
+ } else {
iconpath = ProjectSettings::get_singleton()->get("application/config/icon");
+ }
if (iconpath != "") {
if (iconpath.get_extension() == "icns") {
@@ -614,18 +673,17 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
if (data.size() > 0) {
-
if (file.find("/data.mono.osx.64.release_debug/") != -1) {
if (!p_debug) {
ret = unzGoToNextFile(src_pkg_zip);
- continue; //skip
+ continue; // skip
}
file = file.replace("/data.mono.osx.64.release_debug/", "/data_" + pkg_name_safe + "/");
}
if (file.find("/data.mono.osx.64.release/") != -1) {
if (p_debug) {
ret = unzGoToNextFile(src_pkg_zip);
- continue; //skip
+ continue; // skip
}
file = file.replace("/data.mono.osx.64.release/", "/data_" + pkg_name_safe + "/");
}
@@ -633,62 +691,31 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
print_line("ADDING: " + file + " size: " + itos(data.size()));
total_size += data.size();
- if (export_format == "dmg") {
- // write it into our application bundle
- file = tmp_app_path_name.plus_file(file);
- if (err == OK) {
- err = tmp_app_path->make_dir_recursive(file.get_base_dir());
- }
- if (err == OK) {
- // write the file, need to add chmod
- FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
- if (f) {
- f->store_buffer(data.ptr(), data.size());
- f->close();
- if (is_execute) {
- // Chmod with 0755 if the file is executable
- FileAccess::set_unix_permissions(file, 0755);
- }
- memdelete(f);
- } else {
- err = ERR_CANT_CREATE;
+ // Write it into our application bundle.
+ file = tmp_app_path_name.plus_file(file);
+ if (err == OK) {
+ err = tmp_app_path->make_dir_recursive(file.get_base_dir());
+ }
+ if (err == OK) {
+ FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
+ if (f) {
+ f->store_buffer(data.ptr(), data.size());
+ f->close();
+ if (is_execute) {
+ // chmod with 0755 if the file is executable.
+ FileAccess::set_unix_permissions(file, 0755);
}
+ memdelete(f);
+ } else {
+ err = ERR_CANT_CREATE;
}
- } else {
- // add it to our zip file
- file = pkg_name + ".app/" + file;
-
- zip_fileinfo fi;
- fi.tmz_date.tm_hour = info.tmu_date.tm_hour;
- fi.tmz_date.tm_min = info.tmu_date.tm_min;
- fi.tmz_date.tm_sec = info.tmu_date.tm_sec;
- fi.tmz_date.tm_mon = info.tmu_date.tm_mon;
- fi.tmz_date.tm_mday = info.tmu_date.tm_mday;
- fi.tmz_date.tm_year = info.tmu_date.tm_year;
- fi.dosDate = info.dosDate;
- fi.internal_fa = info.internal_fa;
- fi.external_fa = info.external_fa;
-
- zipOpenNewFileInZip(dst_pkg_zip,
- file.utf8().get_data(),
- &fi,
- nullptr,
- 0,
- nullptr,
- 0,
- nullptr,
- Z_DEFLATED,
- Z_DEFAULT_COMPRESSION);
-
- zipWriteInFileInZip(dst_pkg_zip, data.ptr(), data.size());
- zipCloseFileInZip(dst_pkg_zip);
}
}
ret = unzGoToNextFile(src_pkg_zip);
}
- // we're done with our source zip
+ // We're done with our source zip.
unzClose(src_pkg_zip);
if (!found_binary) {
@@ -701,124 +728,139 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
return ERR_SKIP;
}
- if (export_format == "dmg") {
- String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
- Vector<SharedObject> shared_objects;
- err = save_pack(p_preset, pack_path, &shared_objects);
+ String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
+ Vector<SharedObject> shared_objects;
+ err = save_pack(p_preset, pack_path, &shared_objects);
- // see if we can code sign our new package
- bool sign_enabled = p_preset->get("codesign/enable");
+ // See if we can code sign our new package.
+ bool sign_enabled = p_preset->get("codesign/enable");
- if (err == OK) {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- for (int i = 0; i < shared_objects.size(); i++) {
- err = da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
- if (err == OK && sign_enabled) {
- err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
- }
+ if (err == OK) {
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ for (int i = 0; i < shared_objects.size(); i++) {
+ err = da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
+ if (err == OK && sign_enabled) {
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
}
- memdelete(da);
}
+ memdelete(da);
+ }
- if (err == OK && sign_enabled) {
- if (ep.step("Code signing bundle", 2)) {
- return ERR_SKIP;
- }
-
- // the order in which we code sign is important, this is a bit of a shame or we could do this in our loop that extracts the files from our ZIP
-
- // start with our application
- err = _code_sign(p_preset, tmp_app_path_name + "/Contents/MacOS/" + pkg_name);
-
- ///@TODO we should check the contents of /Contents/Frameworks for frameworks to sign
+ if (err == OK && sign_enabled) {
+ if (ep.step("Code signing bundle", 2)) {
+ return ERR_SKIP;
}
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/MacOS/" + pkg_name);
+ }
- // and finally create a DMG
+ if (export_format == "dmg") {
+ // Create a DMG.
if (err == OK) {
if (ep.step("Making DMG", 3)) {
return ERR_SKIP;
}
err = _create_dmg(p_path, pkg_name, tmp_app_path_name);
}
-
- // Clean up temporary .app dir
- OS::get_singleton()->move_to_trash(tmp_app_path_name);
-
- } else { // pck
-
- String pack_path = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".pck");
-
- Vector<SharedObject> shared_objects;
- err = save_pack(p_preset, pack_path, &shared_objects);
-
- if (err == OK) {
- zipOpenNewFileInZip(dst_pkg_zip,
- (pkg_name + ".app/Contents/Resources/" + pkg_name + ".pck").utf8().get_data(),
- nullptr,
- nullptr,
- 0,
- nullptr,
- 0,
- nullptr,
- Z_DEFLATED,
- Z_DEFAULT_COMPRESSION);
-
- FileAccess *pf = FileAccess::open(pack_path, FileAccess::READ);
- if (pf) {
- const int BSIZE = 16384;
- uint8_t buf[BSIZE];
-
- while (true) {
-
- int r = pf->get_buffer(buf, BSIZE);
- if (r <= 0)
- break;
- zipWriteInFileInZip(dst_pkg_zip, buf, r);
- }
-
- zipCloseFileInZip(dst_pkg_zip);
- memdelete(pf);
- } else {
- err = ERR_CANT_OPEN;
+ // Sign DMG.
+ if (err == OK && sign_enabled) {
+ if (ep.step("Code signing DMG", 3)) {
+ return ERR_SKIP;
}
+ err = _code_sign(p_preset, p_path);
}
-
+ } else {
+ // Create ZIP.
if (err == OK) {
- //add shared objects
- for (int i = 0; i < shared_objects.size(); i++) {
- Vector<uint8_t> file = FileAccess::get_file_as_array(shared_objects[i].path);
- ERR_CONTINUE(file.empty());
-
- zipOpenNewFileInZip(dst_pkg_zip,
- (pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(),
- nullptr,
- nullptr,
- 0,
- nullptr,
- 0,
- nullptr,
- Z_DEFLATED,
- Z_DEFAULT_COMPRESSION);
-
- zipWriteInFileInZip(dst_pkg_zip, file.ptr(), file.size());
- zipCloseFileInZip(dst_pkg_zip);
+ if (ep.step("Making ZIP", 3)) {
+ return ERR_SKIP;
+ }
+ if (FileAccess::exists(p_path)) {
+ OS::get_singleton()->move_to_trash(p_path);
}
+
+ FileAccess *dst_f = nullptr;
+ zlib_filefunc_def io_dst = zipio_create_io_from_file(&dst_f);
+ zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
+
+ _zip_folder_recursive(zip, EditorSettings::get_singleton()->get_cache_dir(), pkg_name + ".app", pkg_name);
+
+ zipClose(zip, nullptr);
}
+ }
- // Clean up generated file.
- DirAccess::remove_file_or_error(pack_path);
+ bool noto_enabled = p_preset->get("notarization/enable");
+ if (err == OK && noto_enabled) {
+ if (ep.step("Sending archive for notarization", 4)) {
+ return ERR_SKIP;
+ }
+ err = _notarize(p_preset, p_path);
}
- }
- if (dst_pkg_zip) {
- zipClose(dst_pkg_zip, nullptr);
+ // Clean up temporary .app dir.
+ OS::get_singleton()->move_to_trash(tmp_app_path_name);
}
return err;
}
-bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String &p_root_path, const String &p_folder, const String &p_pkg_name) {
+ String dir = p_root_path.plus_file(p_folder);
+
+ DirAccess *da = DirAccess::open(dir);
+ da->list_dir_begin();
+ String f;
+ while ((f = da->get_next()) != "") {
+ if (f == "." || f == "..") {
+ continue;
+ }
+ if (da->current_is_dir()) {
+ _zip_folder_recursive(p_zip, p_root_path, p_folder.plus_file(f), p_pkg_name);
+ } else {
+ bool is_executable = (p_folder.ends_with("MacOS") && (f == p_pkg_name));
+
+ OS::Time time = OS::get_singleton()->get_time();
+ OS::Date date = OS::get_singleton()->get_date();
+
+ zip_fileinfo zipfi;
+ zipfi.tmz_date.tm_hour = time.hour;
+ zipfi.tmz_date.tm_mday = date.day;
+ zipfi.tmz_date.tm_min = time.min;
+ zipfi.tmz_date.tm_mon = date.month;
+ zipfi.tmz_date.tm_sec = time.sec;
+ zipfi.tmz_date.tm_year = date.year;
+ zipfi.dosDate = 0;
+ zipfi.external_fa = (is_executable ? 0755 : 0644) << 16L;
+ zipfi.internal_fa = 0;
+
+ zipOpenNewFileInZip4(p_zip,
+ p_folder.plus_file(f).utf8().get_data(),
+ &zipfi,
+ nullptr,
+ 0,
+ nullptr,
+ 0,
+ nullptr,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION,
+ 0,
+ -MAX_WBITS,
+ DEF_MEM_LEVEL,
+ Z_DEFAULT_STRATEGY,
+ nullptr,
+ 0,
+ 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
+ 0);
+
+ Vector<uint8_t> array = FileAccess::get_file_as_array(dir.plus_file(f));
+ zipWriteInFileInZip(p_zip, array.ptr(), array.size());
+ zipCloseFileInZip(p_zip);
+ }
+ }
+ da->list_dir_end();
+ memdelete(da);
+}
+bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
String err;
bool valid = false;
@@ -843,13 +885,48 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset
valid = dvalid || rvalid;
r_missing_templates = !valid;
- if (!err.empty())
+ String identifier = p_preset->get("application/identifier");
+ String pn_err;
+ if (!is_package_name_valid(identifier, &pn_err)) {
+ err += TTR("Invalid bundle identifier:") + " " + pn_err + "\n";
+ valid = false;
+ }
+
+ bool sign_enabled = p_preset->get("codesign/enable");
+ if (sign_enabled) {
+ if (p_preset->get("codesign/identity") == "") {
+ err += TTR("Codesign: identity not specified.") + "\n";
+ valid = false;
+ }
+ }
+ bool noto_enabled = p_preset->get("notarization/enable");
+ if (noto_enabled) {
+ if (!sign_enabled) {
+ err += TTR("Notarization: code signing required.") + "\n";
+ valid = false;
+ }
+ bool hr_enabled = p_preset->get("codesign/hardened_runtime");
+ if (!hr_enabled) {
+ err += TTR("Notarization: hardened runtime required.") + "\n";
+ valid = false;
+ }
+ if (p_preset->get("notarization/apple_id_name") == "") {
+ err += TTR("Notarization: Apple ID name not specified.") + "\n";
+ valid = false;
+ }
+ if (p_preset->get("notarization/apple_id_password") == "") {
+ err += TTR("Notarization: Apple ID password not specified.") + "\n";
+ valid = false;
+ }
+ }
+
+ if (!err.empty()) {
r_error = err;
+ }
return valid;
}
EditorExportPlatformOSX::EditorExportPlatformOSX() {
-
Ref<Image> img = memnew(Image(_osx_logo));
logo.instance();
logo->create_from_image(img);
@@ -859,7 +936,6 @@ EditorExportPlatformOSX::~EditorExportPlatformOSX() {
}
void register_osx_exporter() {
-
Ref<EditorExportPlatformOSX> platform;
platform.instance();
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index eacd2b5cc6..93d0d6168c 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -36,7 +36,6 @@
#include <unistd.h>
int main(int argc, char **argv) {
-
#if defined(VULKAN_ENABLED)
//MoltenVK - enable full component swizzling support
setenv("MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE", "1", 1);
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index 0f50ba63c6..cfc371710b 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -98,6 +98,7 @@ int joypad::get_hid_element_state(rec_element *p_element) const {
}
return value;
}
+
void joypad::add_hid_element(IOHIDElementRef p_element) {
const CFTypeID elementTypeID = p_element ? CFGetTypeID(p_element) : 0;
@@ -240,7 +241,6 @@ static bool is_joypad(IOHIDDeviceRef p_device_ref) {
}
void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) {
-
if (p_res != kIOReturnSuccess || have_device(p_device)) {
return;
}
@@ -264,7 +264,6 @@ void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) {
}
void JoypadOSX::_device_removed(IOReturn p_res, IOHIDDeviceRef p_device) {
-
int device = get_joy_ref(p_device);
ERR_FAIL_COND(device == -1);
@@ -274,7 +273,6 @@ void JoypadOSX::_device_removed(IOReturn p_res, IOHIDDeviceRef p_device) {
}
static String _hex_str(uint8_t p_byte) {
-
static const char *dict = "0123456789abcdef";
char ret[3];
ret[2] = 0;
@@ -286,7 +284,6 @@ static String _hex_str(uint8_t p_byte) {
}
bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) {
-
p_joy->device_ref = p_device_ref;
/* get device name */
String name;
@@ -314,9 +311,16 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) {
if (refCF) {
CFNumberGetValue((CFNumberRef)refCF, kCFNumberSInt32Type, &product_id);
}
+
+ int version = 0;
+ refCF = IOHIDDeviceGetProperty(p_device_ref, CFSTR(kIOHIDVersionNumberKey));
+ if (refCF) {
+ CFNumberGetValue((CFNumberRef)refCF, kCFNumberSInt32Type, &version);
+ }
+
if (vendor && product_id) {
char uid[128];
- sprintf(uid, "%04x%08x%04x%08x", OSSwapHostToBigInt32(vendor), 0, OSSwapHostToBigInt32(product_id), 0);
+ sprintf(uid, "%08x%08x%08x%08x", OSSwapHostToBigInt32(3), OSSwapHostToBigInt32(vendor), OSSwapHostToBigInt32(product_id), OSSwapHostToBigInt32(version));
input->joy_connection_changed(id, true, name, uid);
} else {
//bluetooth device
@@ -346,7 +350,6 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) {
} \
}
bool joypad::config_force_feedback(io_service_t p_service) {
-
HRESULT ret = FFCreateDevice(p_service, &ff_device);
ERR_FAIL_COND_V(ret != FF_OK, false);
@@ -368,7 +371,6 @@ bool joypad::config_force_feedback(io_service_t p_service) {
#define TEST_FF(ff) (features.supportedEffects & (ff))
bool joypad::check_ff_features() {
-
FFCAPABILITIES features;
HRESULT ret = FFDeviceGetForceFeedbackCapabilities(ff_device, &features);
if (ret == FF_OK && (features.supportedEffects & FFCAP_ET_CONSTANTFORCE)) {
@@ -559,7 +561,6 @@ static CFDictionaryRef create_match_dictionary(const UInt32 page, const UInt32 u
}
void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const {
-
CFRunLoopRef runloop = CFRunLoopGetCurrent();
IOReturn ret = IOHIDManagerOpen(hid_manager, kIOHIDOptionsTypeNone);
ERR_FAIL_COND(ret != kIOReturnSuccess);
@@ -603,7 +604,6 @@ JoypadOSX::JoypadOSX(Input *in) {
}
JoypadOSX::~JoypadOSX() {
-
for (int i = 0; i < device_list.size(); i++) {
device_list.write[i].free();
}
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h
index fc176b0990..dc238e68e4 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -88,7 +88,6 @@ struct joypad {
};
class JoypadOSX {
-
enum {
JOYPADS_MAX = 16,
};
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index f132ed9514..dba96ccfcd 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -139,7 +139,6 @@ void OS_OSX::initialize() {
}
void OS_OSX::finalize() {
-
#ifdef COREMIDI_ENABLED
midi_driver.close();
#endif
@@ -261,10 +260,8 @@ String OS_OSX::get_system_dir(SystemDir p_dir) const {
String ret;
if (found) {
-
NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES);
if (paths && [paths count] >= 1) {
-
char *utfs = strdup([[paths firstObject] UTF8String]);
ret.parse_utf8(utfs);
free(utfs);
diff --git a/platform/osx/vulkan_context_osx.h b/platform/osx/vulkan_context_osx.h
index 09a5494ae8..e996f176a9 100644
--- a/platform/osx/vulkan_context_osx.h
+++ b/platform/osx/vulkan_context_osx.h
@@ -35,7 +35,6 @@
#include <AppKit/AppKit.h>
class VulkanContextOSX : public VulkanContext {
-
virtual const char *_get_platform_surface_extension() const;
public:
diff --git a/platform/osx/vulkan_context_osx.mm b/platform/osx/vulkan_context_osx.mm
index 320401cdcb..ec8745ff01 100644
--- a/platform/osx/vulkan_context_osx.mm
+++ b/platform/osx/vulkan_context_osx.mm
@@ -36,7 +36,6 @@ const char *VulkanContextOSX::_get_platform_surface_extension() const {
}
Error VulkanContextOSX::window_create(DisplayServer::WindowID p_window_id, id p_window, int p_width, int p_height) {
-
VkMacOSSurfaceCreateInfoMVK createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
createInfo.pNext = NULL;
diff --git a/platform/server/godot_server.cpp b/platform/server/godot_server.cpp
index df49bfaebf..32bd943ac3 100644
--- a/platform/server/godot_server.cpp
+++ b/platform/server/godot_server.cpp
@@ -32,7 +32,6 @@
#include "os_server.h"
int main(int argc, char *argv[]) {
-
OS_Server os;
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index 0fda0663a2..fbe526ef6d 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -42,11 +42,10 @@
#include <unistd.h>
int OS_Server::get_video_driver_count() const {
-
return 1;
}
-const char *OS_Server::get_video_driver_name(int p_driver) const {
+const char *OS_Server::get_video_driver_name(int p_driver) const {
return "Dummy";
}
@@ -55,7 +54,6 @@ int OS_Server::get_audio_driver_count() const {
}
const char *OS_Server::get_audio_driver_name(int p_driver) const {
-
return "Dummy";
}
@@ -64,14 +62,12 @@ int OS_Server::get_current_video_driver() const {
}
void OS_Server::initialize_core() {
-
crash_handler.initialize();
OS_Unix::initialize_core();
}
Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
-
args = OS::get_singleton()->get_cmdline_args();
current_videomode = p_desired;
main_loop = nullptr;
@@ -96,7 +92,6 @@ Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int
}
void OS_Server::finalize() {
-
if (main_loop)
memdelete(main_loop);
main_loop = nullptr;
@@ -116,22 +111,18 @@ void OS_Server::set_mouse_show(bool p_show) {
}
void OS_Server::set_mouse_grab(bool p_grab) {
-
grab = p_grab;
}
bool OS_Server::is_mouse_grab_enabled() const {
-
return grab;
}
int OS_Server::get_mouse_button_state() const {
-
return 0;
}
Point2 OS_Server::get_mouse_position() const {
-
return Point2();
}
@@ -142,12 +133,10 @@ void OS_Server::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
}
OS::VideoMode OS_Server::get_video_mode(int p_screen) const {
-
return current_videomode;
}
Size2 OS_Server::get_window_size() const {
-
return Vector2(current_videomode.width, current_videomode.height);
}
@@ -155,30 +144,25 @@ void OS_Server::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen)
}
MainLoop *OS_Server::get_main_loop() const {
-
return main_loop;
}
void OS_Server::delete_main_loop() {
-
if (main_loop)
memdelete(main_loop);
main_loop = nullptr;
}
void OS_Server::set_main_loop(MainLoop *p_main_loop) {
-
main_loop = p_main_loop;
input->set_main_loop(p_main_loop);
}
bool OS_Server::can_draw() const {
-
return false; //can never draw
};
String OS_Server::get_name() const {
-
return "Server";
}
@@ -190,7 +174,6 @@ bool OS_Server::_check_internal_feature_support(const String &p_feature) {
}
void OS_Server::run() {
-
force_quit = false;
if (!main_loop)
@@ -199,7 +182,6 @@ void OS_Server::run() {
main_loop->init();
while (!force_quit) {
-
if (Main::iteration())
break;
};
@@ -208,7 +190,6 @@ void OS_Server::run() {
}
String OS_Server::get_config_path() const {
-
if (has_environment("XDG_CONFIG_HOME")) {
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("HOME")) {
@@ -219,7 +200,6 @@ String OS_Server::get_config_path() const {
}
String OS_Server::get_data_path() const {
-
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else if (has_environment("HOME")) {
@@ -230,7 +210,6 @@ String OS_Server::get_data_path() const {
}
String OS_Server::get_cache_path() const {
-
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("HOME")) {
@@ -241,46 +220,37 @@ String OS_Server::get_cache_path() const {
}
String OS_Server::get_system_dir(SystemDir p_dir) const {
-
String xdgparam;
switch (p_dir) {
case SYSTEM_DIR_DESKTOP: {
-
xdgparam = "DESKTOP";
} break;
case SYSTEM_DIR_DCIM: {
-
xdgparam = "PICTURES";
} break;
case SYSTEM_DIR_DOCUMENTS: {
-
xdgparam = "DOCUMENTS";
} break;
case SYSTEM_DIR_DOWNLOADS: {
-
xdgparam = "DOWNLOAD";
} break;
case SYSTEM_DIR_MOVIES: {
-
xdgparam = "VIDEOS";
} break;
case SYSTEM_DIR_MUSIC: {
-
xdgparam = "MUSIC";
} break;
case SYSTEM_DIR_PICTURES: {
-
xdgparam = "PICTURES";
} break;
case SYSTEM_DIR_RINGTONES: {
-
xdgparam = "MUSIC";
} break;
@@ -304,7 +274,6 @@ bool OS_Server::is_disable_crash_handler() const {
}
OS_Server::OS_Server() {
-
//adriver here
grab = false;
};
diff --git a/platform/server/os_server.h b/platform/server/os_server.h
index b273e8d4e4..06ea483fd4 100644
--- a/platform/server/os_server.h
+++ b/platform/server/os_server.h
@@ -47,7 +47,6 @@
#undef CursorShape
class OS_Server : public OS_Unix {
-
RenderingServer *rendering_server;
VideoMode current_videomode;
List<String> args;
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index d3870b0b6c..6090d13854 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -78,16 +78,6 @@ public:
return 0;
}
-App::App() :
- mWindowClosed(false),
- mWindowVisible(true),
- mWindowWidth(0),
- mWindowHeight(0),
- mEglDisplay(EGL_NO_DISPLAY),
- mEglContext(EGL_NO_CONTEXT),
- mEglSurface(EGL_NO_SURFACE) {
-}
-
// The first method called when the IFrameworkView is being created.
void App::Initialize(CoreApplicationView ^ applicationView) {
// Register event handlers for app lifecycle. This example includes Activated, so that we
@@ -156,7 +146,6 @@ void App::SetWindow(CoreWindow ^ p_window) {
}
static int _get_button(Windows::UI::Input::PointerPoint ^ pt) {
-
using namespace Windows::UI::Input;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
@@ -207,7 +196,6 @@ static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) {
}
static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windows::Foundation::Point rawPosition, OS *os) {
-
Windows::Foundation::Point outputPosition;
// Compute coordinates normalized from 0..1.
@@ -247,17 +235,14 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windo
};
static int _get_finger(uint32_t p_touch_id) {
-
return p_touch_id % 31; // for now
};
void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) {
-
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
int but = _get_button(point);
if (_is_touch(point)) {
-
Ref<InputEventScreenTouch> screen_touch;
screen_touch.instance();
screen_touch->set_device(0);
@@ -270,7 +255,6 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
os->input_event(screen_touch);
} else {
-
Ref<InputEventMouseButton> mouse_button;
mouse_button.instance();
mouse_button->set_device(0);
@@ -301,22 +285,18 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor
};
void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
-
pointer_event(sender, args, true);
};
void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
-
pointer_event(sender, args, false);
};
void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
-
pointer_event(sender, args, true, true);
}
void App::OnMouseModeChanged(Windows::System::Threading::Core::SignalNotifier ^ signalNotifier, bool timedOut) {
-
OS::MouseMode mode = os->get_mouse_mode();
SignalNotifier ^ notifier = mouseChangedNotifier;
@@ -325,12 +305,10 @@ void App::OnMouseModeChanged(Windows::System::Threading::Core::SignalNotifier ^
ref new DispatchedHandler(
[mode, notifier, this]() {
if (mode == OS::MOUSE_MODE_CAPTURED) {
-
this->MouseMovedToken = MouseDevice::GetForCurrentView()->MouseMoved +=
ref new TypedEventHandler<MouseDevice ^, MouseEventArgs ^>(this, &App::OnMouseMoved);
} else {
-
MouseDevice::GetForCurrentView()->MouseMoved -= MouseMovedToken;
}
@@ -341,12 +319,10 @@ void App::OnMouseModeChanged(Windows::System::Threading::Core::SignalNotifier ^
}
void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) {
-
Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint;
Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os);
if (_is_touch(point)) {
-
Ref<InputEventScreenDrag> screen_drag;
screen_drag.instance();
screen_drag->set_device(0);
@@ -356,7 +332,6 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
os->input_event(screen_drag);
} else {
-
// In case the mouse grabbed, MouseMoved will handle this
if (os->get_mouse_mode() == OS::MouseMode::MOUSE_MODE_CAPTURED)
return;
@@ -375,7 +350,6 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Co
}
void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
-
// In case the mouse isn't grabbed, PointerMoved will handle this
if (os->get_mouse_mode() != OS::MouseMode::MOUSE_MODE_CAPTURED)
return;
@@ -397,7 +371,6 @@ void App::OnMouseMoved(MouseDevice ^ mouse_device, MouseEventArgs ^ args) {
}
void App::key_event(Windows::UI::Core::CoreWindow ^ sender, bool p_pressed, Windows::UI::Core::KeyEventArgs ^ key_args, Windows::UI::Core::CharacterReceivedEventArgs ^ char_args) {
-
OS_UWP::KeyEvent ke;
ke.control = sender->GetAsyncKeyState(VirtualKey::Control) == CoreVirtualKeyStates::Down;
@@ -407,7 +380,6 @@ void App::key_event(Windows::UI::Core::CoreWindow ^ sender, bool p_pressed, Wind
ke.pressed = p_pressed;
if (key_args != nullptr) {
-
ke.type = OS_UWP::KeyEvent::MessageType::KEY_EVENT_MESSAGE;
ke.unicode = 0;
ke.keycode = KeyMappingWindows::get_keysym((unsigned int)key_args->VirtualKey);
@@ -415,7 +387,6 @@ void App::key_event(Windows::UI::Core::CoreWindow ^ sender, bool p_pressed, Wind
ke.echo = (!p_pressed && !key_args->KeyStatus.IsKeyReleased) || (p_pressed && key_args->KeyStatus.WasKeyDown);
} else {
-
ke.type = OS_UWP::KeyEvent::MessageType::CHAR_EVENT_MESSAGE;
ke.unicode = char_args->KeyCode;
ke.keycode = 0;
@@ -425,6 +396,7 @@ void App::key_event(Windows::UI::Core::CoreWindow ^ sender, bool p_pressed, Wind
os->queue_key_event(ke);
}
+
void App::OnKeyDown(CoreWindow ^ sender, KeyEventArgs ^ args) {
key_event(sender, true, args);
}
@@ -506,14 +478,12 @@ void App::UpdateWindowSize(Size size) {
}
char **App::get_command_line(unsigned int *out_argc) {
-
static char *fail_cl[] = { "--path", "game", nullptr };
*out_argc = 2;
FILE *f = _wfopen(L"__cl__.cl", L"rb");
if (f == nullptr) {
-
wprintf(L"Couldn't open command line file.\n");
return fail_cl;
}
@@ -535,7 +505,6 @@ char **App::get_command_line(unsigned int *out_argc) {
int argc = READ_LE_4(len);
for (int i = 0; i < argc; i++) {
-
r = fread(len, sizeof(uint8_t), 4, f);
if (r < 4) {
@@ -557,7 +526,6 @@ char **App::get_command_line(unsigned int *out_argc) {
arg[strlen] = '\0';
if (r == strlen) {
-
int warg_size = MultiByteToWideChar(CP_UTF8, 0, arg, -1, nullptr, 0);
wchar_t *warg = new wchar_t[warg_size];
@@ -566,7 +534,6 @@ char **App::get_command_line(unsigned int *out_argc) {
cl.Append(ref new Platform::String(warg, warg_size));
} else {
-
delete[] arg;
fclose(f);
wprintf(L"Error reading command.\n");
@@ -582,7 +549,6 @@ char **App::get_command_line(unsigned int *out_argc) {
char **ret = new char *[cl.Size + 1];
for (int i = 0; i < cl.Size; i++) {
-
int arg_size = WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, nullptr, 0, nullptr, nullptr);
char *arg = new char[arg_size];
diff --git a/platform/uwp/app.h b/platform/uwp/app.h
index b7265ad086..5cffe378b1 100644
--- a/platform/uwp/app.h
+++ b/platform/uwp/app.h
@@ -45,7 +45,7 @@ namespace GodotUWP
ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView
{
public:
- App();
+ App() {}
// IFrameworkView Methods.
virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
@@ -92,14 +92,14 @@ namespace GodotUWP
char** get_command_line(unsigned int* out_argc);
- bool mWindowClosed;
- bool mWindowVisible;
- GLsizei mWindowWidth;
- GLsizei mWindowHeight;
+ bool mWindowClosed = false;
+ bool mWindowVisible = true;
+ GLsizei mWindowWidth = 0;
+ GLsizei mWindowHeight = 0;
- EGLDisplay mEglDisplay;
- EGLContext mEglContext;
- EGLSurface mEglSurface;
+ EGLDisplay mEglDisplay = EGL_NO_DISPLAY;
+ EGLContext mEglContext = EGL_NO_CONTEXT;
+ EGLSurface mEglSurface = EGL_NO_SURFACE;
CoreWindow^ window;
OS_UWP* os;
diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp
index bc8ca2e36c..2da6c5897a 100644
--- a/platform/uwp/context_egl_uwp.cpp
+++ b/platform/uwp/context_egl_uwp.cpp
@@ -35,27 +35,22 @@
using Platform::Exception;
void ContextEGL_UWP::release_current() {
-
eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext);
};
void ContextEGL_UWP::make_current() {
-
eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext);
};
int ContextEGL_UWP::get_window_width() {
-
return width;
};
int ContextEGL_UWP::get_window_height() {
-
return height;
};
void ContextEGL_UWP::reset() {
-
cleanup();
window = CoreWindow::GetForCurrentThread();
@@ -63,7 +58,6 @@ void ContextEGL_UWP::reset() {
};
void ContextEGL_UWP::swap_buffers() {
-
if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) {
cleanup();
@@ -75,7 +69,6 @@ void ContextEGL_UWP::swap_buffers() {
};
Error ContextEGL_UWP::initialize() {
-
EGLint configAttribList[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
@@ -115,7 +108,6 @@ Error ContextEGL_UWP::initialize() {
}
try {
-
const EGLint displayAttributes[] = {
/*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
@@ -191,7 +183,6 @@ Error ContextEGL_UWP::initialize() {
};
void ContextEGL_UWP::cleanup() {
-
if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) {
eglDestroySurface(mEglDisplay, mEglSurface);
mEglSurface = EGL_NO_SURFACE;
@@ -216,6 +207,5 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) :
window(p_window) {}
ContextEGL_UWP::~ContextEGL_UWP() {
-
cleanup();
};
diff --git a/platform/uwp/context_egl_uwp.h b/platform/uwp/context_egl_uwp.h
index fa61cf50c6..6f333b8e6a 100644
--- a/platform/uwp/context_egl_uwp.h
+++ b/platform/uwp/context_egl_uwp.h
@@ -41,7 +41,6 @@
using namespace Windows::UI::Core;
class ContextEGL_UWP {
-
public:
enum Driver {
GLES_2_0,
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index bee1ddfc99..cb4716bd65 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -83,7 +83,6 @@ static const char *uwp_device_capabilities[] = {
};
class AppxPackager {
-
enum {
FILE_HEADER_MAGIC = 0x04034b50,
DATA_DESCRIPTOR_MAGIC = 0x08074b50,
@@ -107,29 +106,21 @@ class AppxPackager {
};
struct BlockHash {
-
String base64_hash;
size_t compressed_size;
};
struct FileMeta {
-
String name;
- int lfh_size;
- bool compressed;
- size_t compressed_size;
- size_t uncompressed_size;
+ int lfh_size = 0;
+ bool compressed = false;
+ size_t compressed_size = 0;
+ size_t uncompressed_size = 0;
Vector<BlockHash> hashes;
- uLong file_crc32;
- ZPOS64_T zip_offset;
-
- FileMeta() :
- lfh_size(0),
- compressed(false),
- compressed_size(0),
- uncompressed_size(0),
- file_crc32(0),
- zip_offset(0) {}
+ uLong file_crc32 = 0;
+ ZPOS64_T zip_offset = 0;
+
+ FileMeta() {}
};
String progress_task;
@@ -195,7 +186,6 @@ public:
///////////////////////////////////////////////////////////////////////////
String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len) {
-
unsigned char hash[32];
char base64[45];
@@ -208,24 +198,22 @@ String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len)
}
void AppxPackager::make_block_map(const String &p_path) {
-
FileAccess *tmp_file = FileAccess::open(p_path, FileAccess::WRITE);
tmp_file->store_string("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
tmp_file->store_string("<BlockMap xmlns=\"http://schemas.microsoft.com/appx/2010/blockmap\" HashMethod=\"http://www.w3.org/2001/04/xmlenc#sha256\">");
for (int i = 0; i < file_metadata.size(); i++) {
-
FileMeta file = file_metadata[i];
tmp_file->store_string(
"<File Name=\"" + file.name.replace("/", "\\") + "\" Size=\"" + itos(file.uncompressed_size) + "\" LfhSize=\"" + itos(file.lfh_size) + "\">");
for (int j = 0; j < file.hashes.size(); j++) {
-
tmp_file->store_string("<Block Hash=\"" + file.hashes[j].base64_hash + "\" ");
- if (file.compressed)
+ if (file.compressed) {
tmp_file->store_string("Size=\"" + itos(file.hashes[j].compressed_size) + "\" ");
+ }
tmp_file->store_string("/>");
}
@@ -239,21 +227,20 @@ void AppxPackager::make_block_map(const String &p_path) {
}
String AppxPackager::content_type(String p_extension) {
-
- if (p_extension == "png")
+ if (p_extension == "png") {
return "image/png";
- else if (p_extension == "jpg")
+ } else if (p_extension == "jpg") {
return "image/jpg";
- else if (p_extension == "xml")
+ } else if (p_extension == "xml") {
return "application/xml";
- else if (p_extension == "exe" || p_extension == "dll")
+ } else if (p_extension == "exe" || p_extension == "dll") {
return "application/x-msdownload";
- else
+ } else {
return "application/octet-stream";
+ }
}
void AppxPackager::make_content_types(const String &p_path) {
-
FileAccess *tmp_file = FileAccess::open(p_path, FileAccess::WRITE);
tmp_file->store_string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
@@ -262,11 +249,11 @@ void AppxPackager::make_content_types(const String &p_path) {
Map<String, String> types;
for (int i = 0; i < file_metadata.size(); i++) {
-
String ext = file_metadata[i].name.get_extension();
- if (types.has(ext))
+ if (types.has(ext)) {
continue;
+ }
types[ext] = content_type(ext);
@@ -289,7 +276,6 @@ void AppxPackager::make_content_types(const String &p_path) {
}
Vector<uint8_t> AppxPackager::make_file_header(FileMeta p_file_meta) {
-
Vector<uint8_t> buf;
buf.resize(BASE_FILE_HEADER_SIZE + p_file_meta.name.length());
@@ -332,7 +318,6 @@ Vector<uint8_t> AppxPackager::make_file_header(FileMeta p_file_meta) {
}
void AppxPackager::store_central_dir_header(const FileMeta &p_file, bool p_do_hash) {
-
Vector<uint8_t> &buf = central_dir_data;
int offs = buf.size();
buf.resize(buf.size() + BASE_CENTRAL_DIR_SIZE + p_file.name.length());
@@ -384,7 +369,6 @@ void AppxPackager::store_central_dir_header(const FileMeta &p_file, bool p_do_ha
}
Vector<uint8_t> AppxPackager::make_end_of_central_record() {
-
Vector<uint8_t> buf;
buf.resize(ZIP64_END_OF_CENTRAL_DIR_SIZE + 12 + END_OF_CENTRAL_DIR_SIZE); // Size plus magic
@@ -454,14 +438,12 @@ Vector<uint8_t> AppxPackager::make_end_of_central_record() {
}
void AppxPackager::init(FileAccess *p_fa) {
-
package = p_fa;
central_dir_offset = 0;
end_of_central_dir_offset = 0;
}
Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress) {
-
if (p_file_no >= 1 && p_total_files >= 1) {
if (EditorNode::progress_task_step(progress_task, "File: " + p_file_name, (p_file_no * 100) / p_total_files)) {
return ERR_SKIP;
@@ -485,7 +467,6 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
Vector<uint8_t> strm_out;
if (p_compress) {
-
strm.zalloc = zipio_alloc;
strm.zfree = zipio_free;
strm.opaque = &strm_f;
@@ -498,7 +479,6 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
int step = 0;
while (p_len - step > 0) {
-
size_t block_size = (p_len - step) > BLOCK_SIZE ? (size_t)BLOCK_SIZE : (p_len - step);
for (uint64_t i = 0; i < block_size; i++) {
@@ -509,7 +489,6 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
bh.base64_hash = hash_block(strm_in.ptr(), block_size);
if (p_compress) {
-
strm.avail_in = block_size;
strm.avail_out = strm_out.size();
strm.next_in = (uint8_t *)strm_in.ptr();
@@ -525,15 +504,17 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + bh.compressed_size);
- for (uint64_t i = 0; i < bh.compressed_size; i++)
+ for (uint64_t i = 0; i < bh.compressed_size; i++) {
file_buffer.write[start + i] = strm_out[i];
+ }
} else {
bh.compressed_size = block_size;
//package->store_buffer(strm_in.ptr(), block_size);
int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + block_size);
- for (uint64_t i = 0; i < bh.compressed_size; i++)
+ for (uint64_t i = 0; i < bh.compressed_size; i++) {
file_buffer.write[start + i] = strm_in[i];
+ }
}
meta.hashes.push_back(bh);
@@ -542,7 +523,6 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
}
if (p_compress) {
-
strm.avail_in = 0;
strm.avail_out = strm_out.size();
strm.next_in = (uint8_t *)strm_in.ptr();
@@ -555,14 +535,14 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before));
- for (uint64_t i = 0; i < (strm.total_out - total_out_before); i++)
+ for (uint64_t i = 0; i < (strm.total_out - total_out_before); i++) {
file_buffer.write[start + i] = strm_out[i];
+ }
deflateEnd(&strm);
meta.compressed_size = strm.total_out;
} else {
-
meta.compressed_size = p_len;
}
@@ -585,7 +565,6 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
}
void AppxPackager::finish() {
-
// Create and add block map file
EditorNode::progress_task_step("export", "Creating block map...", 4);
@@ -652,7 +631,6 @@ AppxPackager::~AppxPackager() {}
////////////////////////////////////////////////////////////////////
class EditorExportPlatformUWP : public EditorExportPlatform {
-
GDCLASS(EditorExportPlatformUWP, EditorExportPlatform);
Ref<ImageTexture> logo;
@@ -664,11 +642,12 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
};
bool _valid_resource_name(const String &p_name) const {
-
- if (p_name.empty())
+ if (p_name.empty()) {
return false;
- if (p_name.ends_with("."))
+ }
+ if (p_name.ends_with(".")) {
return false;
+ }
static const char *invalid_names[] = {
"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7",
@@ -678,8 +657,9 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
const char **t = invalid_names;
while (*t) {
- if (p_name == *t)
+ if (p_name == *t) {
return false;
+ }
t++;
}
@@ -687,28 +667,33 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
}
bool _valid_guid(const String &p_guid) const {
-
Vector<String> parts = p_guid.split("-");
- if (parts.size() != 5)
+ if (parts.size() != 5) {
return false;
- if (parts[0].length() != 8)
+ }
+ if (parts[0].length() != 8) {
return false;
- for (int i = 1; i < 4; i++)
- if (parts[i].length() != 4)
+ }
+ for (int i = 1; i < 4; i++) {
+ if (parts[i].length() != 4) {
return false;
- if (parts[4].length() != 12)
+ }
+ }
+ if (parts[4].length() != 12) {
return false;
+ }
return true;
}
bool _valid_bgcolor(const String &p_color) const {
-
- if (p_color.empty())
+ if (p_color.empty()) {
return true;
- if (p_color.begins_with("#") && p_color.is_valid_html_color())
+ }
+ if (p_color.begins_with("#") && p_color.is_valid_html_color()) {
return true;
+ }
// Colors from https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
static const char *valid_colors[] = {
@@ -742,8 +727,9 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
const char **color = valid_colors;
while (*color) {
- if (p_color == *color)
+ if (p_color == *color) {
return true;
+ }
color++;
}
@@ -751,33 +737,16 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
}
bool _valid_image(const StreamTexture2D *p_image, int p_width, int p_height) const {
-
if (!p_image) {
return false;
}
// TODO: Add resource creation or image rescaling to enable other scales:
// 1.25, 1.5, 2.0
- real_t scales[] = { 1.0 };
- bool valid_w = false;
- bool valid_h = false;
-
- for (int i = 0; i < 1; i++) {
-
- int w = ceil(p_width * scales[i]);
- int h = ceil(p_height * scales[i]);
-
- if (w == p_image->get_width())
- valid_w = true;
- if (h == p_image->get_height())
- valid_h = true;
- }
-
- return valid_w && valid_h;
+ return p_width == p_image->get_width() && p_height == p_image->get_height();
}
Vector<uint8_t> _fix_manifest(const Ref<EditorExportPreset> &p_preset, const Vector<uint8_t> &p_template, bool p_give_internet) const {
-
String result = String::utf8((const char *)p_template.ptr(), p_template.size());
result = result.replace("$godot_version$", VERSION_FULL_NAME);
@@ -878,14 +847,14 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
Vector<uint8_t> r_ret;
r_ret.resize(result.length());
- for (int i = 0; i < result.length(); i++)
+ for (int i = 0; i < result.length(); i++) {
r_ret.write[i] = result.utf8().get(i);
+ }
return r_ret;
}
Vector<uint8_t> _get_image_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
-
Vector<uint8_t> data;
StreamTexture2D *image = nullptr;
@@ -907,15 +876,15 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
ERR_PRINT("Unable to load logo");
}
- if (!image)
+ if (!image) {
return data;
+ }
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("uwp_tmp_logo.png");
Error err = image->get_data()->save_png(tmp_path);
if (err != OK) {
-
String err_string = "Couldn't save temp logo file.";
EditorNode::add_io_error(err_string);
@@ -925,7 +894,6 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
FileAccess *f = FileAccess::open(tmp_path, FileAccess::READ, &err);
if (err != OK) {
-
String err_string = "Couldn't open temp logo file.";
// Cleanup generated file.
DirAccess::remove_file_or_error(tmp_path);
@@ -944,17 +912,16 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
}
static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data) {
-
/* TODO: This was copied verbatim from Android export. It should be
- * refactored to the parent class and also be used for .zip export.
- */
+ * refactored to the parent class and also be used for .zip export.
+ */
/*
- * By not compressing files with little or not benefit in doing so,
- * a performance gain is expected at runtime. Moreover, if the APK is
- * zip-aligned, assets stored as they are can be efficiently read by
- * Android by memory-mapping them.
- */
+ * By not compressing files with little or not benefit in doing so,
+ * a performance gain is expected at runtime. Moreover, if the APK is
+ * zip-aligned, assets stored as they are can be efficiently read by
+ * Android by memory-mapping them.
+ */
// -- Unconditional uncompress to mimic AAPT plus some other
@@ -995,7 +962,6 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
}
static Error save_appx_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
-
AppxPackager *packager = (AppxPackager *)p_userdata;
String dst_path = p_path.replace_first("res://", "game/");
@@ -1102,7 +1068,6 @@ public:
}
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
-
String err;
bool valid = false;
@@ -1213,15 +1178,15 @@ public:
}
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) {
-
String src_appx;
EditorProgress ep("export", "Exporting for Windows Universal", 7, true);
- if (p_debug)
+ if (p_debug) {
src_appx = p_preset->get("custom_template/debug");
- else
+ } else {
src_appx = p_preset->get("custom_template/release");
+ }
src_appx = src_appx.strip_edges();
@@ -1273,7 +1238,6 @@ public:
unzFile pkg = unzOpen2(src_appx.utf8().get_data(), &io);
if (!pkg) {
-
EditorNode::add_io_error("Could not find template appx to export:\n" + src_appx);
return ERR_FILE_NOT_FOUND;
}
@@ -1291,7 +1255,6 @@ public:
int template_file_no = 1;
while (ret == UNZ_OK) {
-
// get file name
unz_file_info info;
char fname[16834];
@@ -1309,12 +1272,12 @@ public:
bool do_read = true;
if (path.begins_with("Assets/")) {
-
path = path.replace(".scale-100", "");
data = _get_image_data(p_preset, path);
- if (data.size() > 0)
+ if (data.size() > 0) {
do_read = false;
+ }
}
//read
@@ -1326,7 +1289,6 @@ public:
}
if (path == "AppxManifest.xml") {
-
data = _fix_manifest(p_preset, data, p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG));
}
@@ -1369,7 +1331,6 @@ public:
encode_uint32(cl.size(), clf.ptrw());
for (int i = 0; i < cl.size(); i++) {
-
CharString txt = cl[i].utf8();
int base = clf.size();
clf.resize(base + 4 + txt.length());
@@ -1458,7 +1419,6 @@ public:
}
virtual void get_platform_features(List<String> *r_features) {
-
r_features->push_back("pc");
r_features->push_back("UWP");
}
@@ -1474,7 +1434,6 @@ public:
};
void register_uwp_exporter() {
-
#ifdef WINDOWS_ENABLED
EDITOR_DEF("export/uwp/signtool", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/uwp/signtool", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index 066787e9d6..4fdfde9673 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -35,7 +35,6 @@ using namespace Windows::Gaming::Input;
using namespace Windows::Foundation;
void JoypadUWP::register_events() {
-
Gamepad::GamepadAdded +=
ref new EventHandler<Gamepad ^>(this, &JoypadUWP::OnGamepadAdded);
Gamepad::GamepadRemoved +=
@@ -43,23 +42,18 @@ void JoypadUWP::register_events() {
}
void JoypadUWP::process_controllers() {
-
for (int i = 0; i < MAX_CONTROLLERS; i++) {
-
ControllerDevice &joy = controllers[i];
if (!joy.connected)
break;
switch (joy.type) {
-
case ControllerType::GAMEPAD_CONTROLLER: {
-
GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading();
int button_mask = (int)GamepadButtons::Menu;
for (int j = 0; j < 14; j++) {
-
input->joy_button(joy.id, j, (int)reading.Buttons & button_mask);
button_mask *= 2;
}
@@ -93,24 +87,20 @@ void JoypadUWP::process_controllers() {
}
JoypadUWP::JoypadUWP() {
-
for (int i = 0; i < MAX_CONTROLLERS; i++)
controllers[i].id = i;
}
JoypadUWP::JoypadUWP(InputDefault *p_input) {
-
input = p_input;
JoypadUWP();
}
void JoypadUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) {
-
short idx = -1;
for (int i = 0; i < MAX_CONTROLLERS; i++) {
-
if (!controllers[i].connected) {
idx = i;
break;
@@ -128,11 +118,9 @@ void JoypadUWP::OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input
}
void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value) {
-
short idx = -1;
for (int i = 0; i < MAX_CONTROLLERS; i++) {
-
if (controllers[i].controller_reference == value) {
idx = i;
break;
@@ -147,7 +135,6 @@ void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Inp
}
InputDefault::JoyAxis JoypadUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const {
-
InputDefault::JoyAxis jx;
jx.min = p_trigger ? 0 : -1;
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index 69431052e5..13f246a438 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -34,7 +34,6 @@
#include "core/input/input.h"
ref class JoypadUWP sealed {
-
/** clang-format breaks this, it does not understand this token. */
/* clang-format off */
internal:
@@ -57,7 +56,6 @@ private:
};
struct ControllerDevice {
-
Windows::Gaming::Input::IGameController ^ controller_reference;
int id;
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 1c83ebfdf7..ee25754704 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -82,7 +82,6 @@ int OS_UWP::get_current_video_driver() const {
}
void OS_UWP::set_window_size(const Size2 p_size) {
-
Windows::Foundation::Size new_size;
new_size.Width = p_size.width;
new_size.Height = p_size.height;
@@ -90,14 +89,12 @@ void OS_UWP::set_window_size(const Size2 p_size) {
ApplicationView ^ view = ApplicationView::GetForCurrentView();
if (view->TryResizeView(new_size)) {
-
video_mode.width = p_size.width;
video_mode.height = p_size.height;
}
}
void OS_UWP::set_window_fullscreen(bool p_enabled) {
-
ApplicationView ^ view = ApplicationView::GetForCurrentView();
video_mode.fullscreen = view->IsFullScreenMode;
@@ -106,23 +103,19 @@ void OS_UWP::set_window_fullscreen(bool p_enabled) {
return;
if (p_enabled) {
-
video_mode.fullscreen = view->TryEnterFullScreenMode();
} else {
-
view->ExitFullScreenMode();
video_mode.fullscreen = false;
}
}
bool OS_UWP::is_window_fullscreen() const {
-
return ApplicationView::GetForCurrentView()->IsFullScreenMode;
}
void OS_UWP::set_keep_screen_on(bool p_enabled) {
-
if (is_keep_screen_on() == p_enabled)
return;
@@ -135,7 +128,6 @@ void OS_UWP::set_keep_screen_on(bool p_enabled) {
}
void OS_UWP::initialize_core() {
-
last_button_state = 0;
//RedirectIOToConsole();
@@ -166,7 +158,6 @@ void OS_UWP::initialize_core() {
}
bool OS_UWP::can_draw() const {
-
return !minimized;
};
@@ -175,12 +166,10 @@ void OS_UWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) {
}
void OS_UWP::screen_size_changed() {
-
gl_context->reset();
};
Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
-
main_loop = nullptr;
outside = true;
@@ -231,11 +220,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
if (p_desired.fullscreen != view->IsFullScreenMode) {
if (p_desired.fullscreen) {
-
vm.fullscreen = view->TryEnterFullScreenMode();
} else {
-
view->ExitFullScreenMode();
vm.fullscreen = false;
}
@@ -248,7 +235,6 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
view->PreferredLaunchViewSize = desired;
if (view->TryResizeView(desired)) {
-
vm.width = view->VisibleBounds.Width;
vm.height = view->VisibleBounds.Height;
}
@@ -309,7 +295,6 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
}
void OS_UWP::set_clipboard(const String &p_text) {
-
DataPackage ^ clip = ref new DataPackage();
clip->RequestedOperation = DataPackageOperation::Copy;
clip->SetText(ref new Platform::String((const wchar_t *)p_text.c_str()));
@@ -318,7 +303,6 @@ void OS_UWP::set_clipboard(const String &p_text) {
};
String OS_UWP::get_clipboard() const {
-
if (managed_object->clipboard != nullptr)
return managed_object->clipboard->Data();
else
@@ -326,25 +310,21 @@ String OS_UWP::get_clipboard() const {
};
void OS_UWP::input_event(const Ref<InputEvent> &p_event) {
-
input->parse_input_event(p_event);
};
void OS_UWP::delete_main_loop() {
-
if (main_loop)
memdelete(main_loop);
main_loop = nullptr;
}
void OS_UWP::set_main_loop(MainLoop *p_main_loop) {
-
input->set_main_loop(p_main_loop);
main_loop = p_main_loop;
}
void OS_UWP::finalize() {
-
if (main_loop)
memdelete(main_loop);
@@ -363,12 +343,10 @@ void OS_UWP::finalize() {
}
void OS_UWP::finalize_core() {
-
NetSocketPosix::cleanup();
}
void OS_UWP::alert(const String &p_alert, const String &p_title) {
-
Platform::String ^ alert = ref new Platform::String(p_alert.c_str());
Platform::String ^ title = ref new Platform::String(p_title.c_str());
@@ -384,21 +362,17 @@ void OS_UWP::alert(const String &p_alert, const String &p_title) {
}
void OS_UWP::ManagedType::alert_close(IUICommand ^ command) {
-
alert_close_handle = false;
}
void OS_UWP::ManagedType::on_clipboard_changed(Platform::Object ^ sender, Platform::Object ^ ev) {
-
update_clipboard();
}
void OS_UWP::ManagedType::update_clipboard() {
-
DataPackageView ^ data = Clipboard::GetContent();
if (data->Contains(StandardDataFormats::Text)) {
-
create_task(data->GetTextAsync()).then([this](Platform::String ^ clipboard_content) {
this->clipboard = clipboard_content;
});
@@ -406,7 +380,6 @@ void OS_UWP::ManagedType::update_clipboard() {
}
void OS_UWP::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sender, AccelerometerReadingChangedEventArgs ^ args) {
-
AccelerometerReading ^ reading = args->Reading;
os->input->set_accelerometer(Vector3(
@@ -416,7 +389,6 @@ void OS_UWP::ManagedType::on_accelerometer_reading_changed(Accelerometer ^ sende
}
void OS_UWP::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender, MagnetometerReadingChangedEventArgs ^ args) {
-
MagnetometerReading ^ reading = args->Reading;
os->input->set_magnetometer(Vector3(
@@ -426,7 +398,6 @@ void OS_UWP::ManagedType::on_magnetometer_reading_changed(Magnetometer ^ sender,
}
void OS_UWP::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, GyrometerReadingChangedEventArgs ^ args) {
-
GyrometerReading ^ reading = args->Reading;
os->input->set_magnetometer(Vector3(
@@ -436,22 +407,17 @@ void OS_UWP::ManagedType::on_gyroscope_reading_changed(Gyrometer ^ sender, Gyrom
}
void OS_UWP::set_mouse_mode(MouseMode p_mode) {
-
if (p_mode == MouseMode::MOUSE_MODE_CAPTURED) {
-
CoreWindow::GetForCurrentThread()->SetPointerCapture();
} else {
-
CoreWindow::GetForCurrentThread()->ReleasePointerCapture();
}
if (p_mode == MouseMode::MOUSE_MODE_CAPTURED || p_mode == MouseMode::MOUSE_MODE_HIDDEN) {
-
CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
} else {
-
CoreWindow::GetForCurrentThread()->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
}
@@ -461,17 +427,14 @@ void OS_UWP::set_mouse_mode(MouseMode p_mode) {
}
OS_UWP::MouseMode OS_UWP::get_mouse_mode() const {
-
return mouse_mode;
}
Point2 OS_UWP::get_mouse_position() const {
-
return Point2(old_x, old_y);
}
int OS_UWP::get_mouse_button_state() const {
-
return last_button_state;
}
@@ -479,23 +442,21 @@ void OS_UWP::set_window_title(const String &p_title) {
}
void OS_UWP::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
-
video_mode = p_video_mode;
}
-OS::VideoMode OS_UWP::get_video_mode(int p_screen) const {
+OS::VideoMode OS_UWP::get_video_mode(int p_screen) const {
return video_mode;
}
+
void OS_UWP::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
}
String OS_UWP::get_name() const {
-
return "UWP";
}
OS::Date OS_UWP::get_date(bool utc) const {
-
SYSTEMTIME systemtime;
if (utc)
GetSystemTime(&systemtime);
@@ -510,8 +471,8 @@ OS::Date OS_UWP::get_date(bool utc) const {
date.dst = false;
return date;
}
-OS::Time OS_UWP::get_time(bool utc) const {
+OS::Time OS_UWP::get_time(bool utc) const {
SYSTEMTIME systemtime;
if (utc)
GetSystemTime(&systemtime);
@@ -545,7 +506,6 @@ OS::TimeZoneInfo OS_UWP::get_time_zone_info() const {
}
uint64_t OS_UWP::get_unix_time() const {
-
FILETIME ft;
SYSTEMTIME st;
GetSystemTime(&st);
@@ -567,20 +527,36 @@ uint64_t OS_UWP::get_unix_time() const {
};
void OS_UWP::delay_usec(uint32_t p_usec) const {
-
int msec = p_usec < 1000 ? 1 : p_usec / 1000;
// no Sleep()
WaitForSingleObjectEx(GetCurrentThread(), msec, false);
}
-uint64_t OS_UWP::get_ticks_usec() const {
+uint64_t OS_UWP::get_ticks_usec() const {
uint64_t ticks;
- uint64_t time;
+
// This is the number of clock ticks since start
QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
+
// Divide by frequency to get the time in seconds
- time = ticks * 1000000L / ticks_per_second;
+ // original calculation shown below is subject to overflow
+ // with high ticks_per_second and a number of days since the last reboot.
+ // time = ticks * 1000000L / ticks_per_second;
+
+ // we can prevent this by either using 128 bit math
+ // or separating into a calculation for seconds, and the fraction
+ uint64_t seconds = ticks / ticks_per_second;
+
+ // compiler will optimize these two into one divide
+ uint64_t leftover = ticks % ticks_per_second;
+
+ // remainder
+ uint64_t time = (leftover * 1000000L) / ticks_per_second;
+
+ // seconds
+ time += seconds * 1000000L;
+
// Subtract the time at game start to get
// the time since the game started
time -= ticks_start;
@@ -588,15 +564,12 @@ uint64_t OS_UWP::get_ticks_usec() const {
}
void OS_UWP::process_events() {
-
joypad->process_controllers();
process_key_events();
}
void OS_UWP::process_key_events() {
-
for (int i = 0; i < key_event_pos; i++) {
-
KeyEvent &kev = key_event_buffer[i];
Ref<InputEventKey> key_event;
@@ -619,7 +592,6 @@ void OS_UWP::queue_key_event(KeyEvent &p_event) {
// This merges Char events with the previous Key event, so
// the unicode can be retrieved without sending duplicate events.
if (p_event.type == KeyEvent::MessageType::CHAR_EVENT_MESSAGE && key_event_pos > 0) {
-
KeyEvent &old = key_event_buffer[key_event_pos - 1];
ERR_FAIL_COND(old.type != KeyEvent::MessageType::KEY_EVENT_MESSAGE);
@@ -633,7 +605,6 @@ void OS_UWP::queue_key_event(KeyEvent &p_event) {
}
void OS_UWP::set_cursor_shape(CursorShape p_shape) {
-
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
if (cursor_shape == p_shape)
@@ -665,7 +636,6 @@ void OS_UWP::set_cursor_shape(CursorShape p_shape) {
}
OS::CursorShape OS_UWP::get_cursor_shape() const {
-
return cursor_shape;
}
@@ -674,22 +644,18 @@ void OS_UWP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
}
Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
-
return FAILED;
};
Error OS_UWP::kill(const ProcessID &p_pid) {
-
return FAILED;
};
Error OS_UWP::set_cwd(const String &p_cwd) {
-
return FAILED;
}
String OS_UWP::get_executable_path() const {
-
return "";
}
@@ -697,22 +663,18 @@ void OS_UWP::set_icon(const Ref<Image> &p_icon) {
}
bool OS_UWP::has_environment(const String &p_var) const {
-
return false;
};
String OS_UWP::get_environment(const String &p_var) const {
-
return "";
};
bool OS_UWP::set_environment(const String &p_var, const String &p_value) const {
-
return false;
}
String OS_UWP::get_stdin_string(bool p_block) {
-
return String();
}
@@ -720,12 +682,10 @@ void OS_UWP::move_window_to_foreground() {
}
Error OS_UWP::shell_open(String p_uri) {
-
return FAILED;
}
String OS_UWP::get_locale() const {
-
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // this should work on phone 8.1, but it doesn't
return "en";
#else
@@ -735,45 +695,37 @@ String OS_UWP::get_locale() const {
}
void OS_UWP::release_rendering_thread() {
-
gl_context->release_current();
}
void OS_UWP::make_rendering_thread() {
-
gl_context->make_current();
}
void OS_UWP::swap_buffers() {
-
gl_context->swap_buffers();
}
bool OS_UWP::has_touchscreen_ui_hint() const {
-
TouchCapabilities ^ tc = ref new TouchCapabilities();
return tc->TouchPresent != 0 || UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch;
}
bool OS_UWP::has_virtual_keyboard() const {
-
return UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch;
}
-void OS_UWP::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length) {
-
+void OS_UWP::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
InputPane ^ pane = InputPane::GetForCurrentView();
pane->TryShow();
}
void OS_UWP::hide_virtual_keyboard() {
-
InputPane ^ pane = InputPane::GetForCurrentView();
pane->TryHide();
}
static String format_error_message(DWORD id) {
-
LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr);
@@ -786,7 +738,6 @@ static String format_error_message(DWORD id) {
}
Error OS_UWP::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
-
String full_path = "game/" + p_path;
p_library_handle = (void *)LoadPackagedLibrary(full_path.c_str(), 0);
ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + full_path + ", error: " + format_error_message(GetLastError()) + ".");
@@ -813,7 +764,6 @@ Error OS_UWP::get_dynamic_library_symbol_handle(void *p_library_handle, const St
}
void OS_UWP::run() {
-
if (!main_loop)
return;
@@ -825,7 +775,6 @@ void OS_UWP::run() {
uint64_t frame = 0;
while (!force_quit) {
-
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
if (managed_object->alert_close_handle)
continue;
@@ -838,12 +787,10 @@ void OS_UWP::run() {
}
MainLoop *OS_UWP::get_main_loop() const {
-
return main_loop;
}
String OS_UWP::get_user_data_dir() const {
-
Windows::Storage::StorageFolder ^ data_folder = Windows::Storage::ApplicationData::Current->LocalFolder;
return String(data_folder->Path->Data()).replace("\\", "/");
@@ -854,7 +801,6 @@ bool OS_UWP::_check_internal_feature_support(const String &p_feature) {
}
OS_UWP::OS_UWP() {
-
key_event_pos = 0;
force_quit = false;
alt_mem = false;
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 2233f6a413..95359c68b0 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -48,10 +48,8 @@
#include <windows.h>
class OS_UWP : public OS {
-
public:
struct KeyEvent {
-
enum MessageType {
KEY_EVENT_MESSAGE,
CHAR_EVENT_MESSAGE
@@ -236,7 +234,7 @@ public:
virtual bool has_touchscreen_ui_hint() const;
virtual bool has_virtual_keyboard() const;
- virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1);
+ virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1);
virtual void hide_virtual_keyboard();
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
diff --git a/platform/uwp/thread_uwp.cpp b/platform/uwp/thread_uwp.cpp
index 9dc20a74e8..8e7bb144be 100644
--- a/platform/uwp/thread_uwp.cpp
+++ b/platform/uwp/thread_uwp.cpp
@@ -33,7 +33,6 @@
#include "core/os/memory.h"
Thread *ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
-
ThreadUWP *thread = memnew(ThreadUWP);
std::thread new_thread(p_callback, p_user);
@@ -43,18 +42,15 @@ Thread *ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback, void *p_user
};
Thread::ID ThreadUWP::get_thread_id_func_uwp() {
-
return std::hash<std::thread::id>()(std::this_thread::get_id());
};
void ThreadUWP::wait_to_finish_func_uwp(Thread *p_thread) {
-
ThreadUWP *tp = static_cast<ThreadUWP *>(p_thread);
tp->thread.join();
};
Thread::ID ThreadUWP::get_id() const {
-
return std::hash<std::thread::id>()(thread.get_id());
};
@@ -63,11 +59,3 @@ void ThreadUWP::make_default() {
get_thread_id_func = get_thread_id_func_uwp;
wait_to_finish_func = wait_to_finish_func_uwp;
};
-
-ThreadUWP::ThreadUWP(){
-
-};
-
-ThreadUWP::~ThreadUWP(){
-
-};
diff --git a/platform/uwp/thread_uwp.h b/platform/uwp/thread_uwp.h
index a2d367ae2f..9b2a2590a8 100644
--- a/platform/uwp/thread_uwp.h
+++ b/platform/uwp/thread_uwp.h
@@ -38,23 +38,22 @@
#include <thread>
class ThreadUWP : public Thread {
-
std::thread thread;
static Thread *create_func_uwp(ThreadCreateCallback p_callback, void *, const Settings &);
static ID get_thread_id_func_uwp();
static void wait_to_finish_func_uwp(Thread *p_thread);
- ThreadUWP();
+ ThreadUWP() {}
public:
virtual ID get_id() const;
static void make_default();
- ~ThreadUWP();
+ ~ThreadUWP() {}
};
-#endif
+#endif // UWP_ENABLED
-#endif
+#endif // THREAD_UWP_H
diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp
index 5a36b5546d..1c32639a38 100644
--- a/platform/windows/context_gl_windows.cpp
+++ b/platform/windows/context_gl_windows.cpp
@@ -51,27 +51,22 @@
typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *);
void ContextGL_Windows::release_current() {
-
wglMakeCurrent(hDC, nullptr);
}
void ContextGL_Windows::make_current() {
-
wglMakeCurrent(hDC, hRC);
}
int ContextGL_Windows::get_window_width() {
-
return OS::get_singleton()->get_video_mode().width;
}
int ContextGL_Windows::get_window_height() {
-
return OS::get_singleton()->get_video_mode().height;
}
bool ContextGL_Windows::should_vsync_via_compositor() {
-
if (OS::get_singleton()->is_window_fullscreen() || !OS::get_singleton()->is_vsync_via_compositor_enabled()) {
return false;
}
@@ -88,7 +83,6 @@ bool ContextGL_Windows::should_vsync_via_compositor() {
}
void ContextGL_Windows::swap_buffers() {
-
SwapBuffers(hDC);
if (use_vsync) {
@@ -108,7 +102,6 @@ void ContextGL_Windows::swap_buffers() {
}
void ContextGL_Windows::set_use_vsync(bool p_use) {
-
vsync_via_compositor = p_use && should_vsync_via_compositor();
if (wglSwapIntervalEXT) {
@@ -120,14 +113,12 @@ void ContextGL_Windows::set_use_vsync(bool p_use) {
}
bool ContextGL_Windows::is_using_vsync() const {
-
return use_vsync;
}
#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
Error ContextGL_Windows::initialize() {
-
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1,
@@ -175,7 +166,6 @@ Error ContextGL_Windows::initialize() {
wglMakeCurrent(hDC, hRC);
if (opengl_3_context) {
-
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
@@ -217,7 +207,6 @@ Error ContextGL_Windows::initialize() {
}
ContextGL_Windows::ContextGL_Windows(HWND hwnd, bool p_opengl_3_context) {
-
opengl_3_context = p_opengl_3_context;
hWnd = hwnd;
use_vsync = false;
diff --git a/platform/windows/context_gl_windows.h b/platform/windows/context_gl_windows.h
index 280c5a1e3c..046e3437ea 100644
--- a/platform/windows/context_gl_windows.h
+++ b/platform/windows/context_gl_windows.h
@@ -44,7 +44,6 @@ typedef bool(APIENTRY *PFNWGLSWAPINTERVALEXTPROC)(int interval);
typedef int(APIENTRY *PFNWGLGETSWAPINTERVALEXTPROC)(void);
class ContextGL_Windows {
-
HDC hDC;
HGLRC hRC;
unsigned int pixel_format;
diff --git a/platform/windows/crash_handler_windows.h b/platform/windows/crash_handler_windows.h
index adc548073c..66a4cac296 100644
--- a/platform/windows/crash_handler_windows.h
+++ b/platform/windows/crash_handler_windows.h
@@ -41,7 +41,6 @@ extern DWORD CrashHandlerException(EXCEPTION_POINTERS *ep);
#endif
class CrashHandler {
-
bool disabled;
public:
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index e794efb4fb..0b7130db74 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -38,7 +38,6 @@
#ifdef DEBUG_ENABLED
static String format_error_message(DWORD id) {
-
LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr);
@@ -83,7 +82,6 @@ void DisplayServerWindows::alert(const String &p_alert, const String &p_title) {
}
void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) {
-
if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED) {
WindowData &wd = windows[MAIN_WINDOW_ID];
@@ -93,7 +91,6 @@ void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) {
ClientToScreen(wd.hWnd, (POINT *)&clipRect.right);
ClipCursor(&clipRect);
if (p_mode == MOUSE_MODE_CAPTURED) {
-
center = window_get_size() / 2;
POINT pos = { (int)center.x, (int)center.y };
ClientToScreen(wd.hWnd, &pos);
@@ -113,8 +110,8 @@ void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) {
cursor_set_shape(c);
}
}
-void DisplayServerWindows::mouse_set_mode(MouseMode p_mode) {
+void DisplayServerWindows::mouse_set_mode(MouseMode p_mode) {
_THREAD_SAFE_METHOD_
if (mouse_mode == p_mode)
@@ -124,12 +121,12 @@ void DisplayServerWindows::mouse_set_mode(MouseMode p_mode) {
mouse_mode = p_mode;
}
+
DisplayServer::MouseMode DisplayServerWindows::mouse_get_mode() const {
return mouse_mode;
}
void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
-
_THREAD_SAFE_METHOD_
if (!windows.has(last_focused_window)) {
@@ -137,11 +134,9 @@ void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
}
if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
old_x = p_to.x;
old_y = p_to.y;
} else {
-
POINT p;
p.x = p_to.x;
p.y = p_to.y;
@@ -150,18 +145,19 @@ void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
SetCursorPos(p.x, p.y);
}
}
+
Point2i DisplayServerWindows::mouse_get_position() const {
POINT p;
GetCursorPos(&p);
return Point2i(p.x, p.y);
//return Point2(old_x, old_y);
}
+
int DisplayServerWindows::mouse_get_button_state() const {
return last_button_state;
}
void DisplayServerWindows::clipboard_set(const String &p_text) {
-
_THREAD_SAFE_METHOD_
if (!windows.has(last_focused_window)) {
@@ -200,8 +196,8 @@ void DisplayServerWindows::clipboard_set(const String &p_text) {
CloseClipboard();
}
-String DisplayServerWindows::clipboard_get() const {
+String DisplayServerWindows::clipboard_get() const {
_THREAD_SAFE_METHOD_
if (!windows.has(last_focused_window)) {
@@ -214,26 +210,20 @@ String DisplayServerWindows::clipboard_get() const {
};
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
-
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
if (mem != nullptr) {
-
LPWSTR ptr = (LPWSTR)GlobalLock(mem);
if (ptr != nullptr) {
-
ret = String((CharType *)ptr);
GlobalUnlock(mem);
};
};
} else if (IsClipboardFormatAvailable(CF_TEXT)) {
-
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
if (mem != nullptr) {
-
LPTSTR ptr = (LPTSTR)GlobalLock(mem);
if (ptr != nullptr) {
-
ret.parse_utf8((const char *)ptr);
GlobalUnlock(mem);
};
@@ -252,7 +242,6 @@ typedef struct {
} EnumScreenData;
static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
EnumScreenData *data = (EnumScreenData *)dwData;
if (data->monitor == hMonitor) {
data->screen = data->count;
@@ -263,7 +252,6 @@ static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, L
}
static BOOL CALLBACK _MonitorEnumProcCount(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
int *data = (int *)dwData;
(*data)++;
return TRUE;
@@ -284,7 +272,6 @@ typedef struct {
} EnumPosData;
static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
EnumPosData *data = (EnumPosData *)dwData;
if (data->count == data->screen) {
data->pos.x = lprcMonitor->left;
@@ -294,8 +281,8 @@ static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRE
data->count++;
return TRUE;
}
-Point2i DisplayServerWindows::screen_get_position(int p_screen) const {
+Point2i DisplayServerWindows::screen_get_position(int p_screen) const {
_THREAD_SAFE_METHOD_
EnumPosData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Point2() };
@@ -316,7 +303,6 @@ typedef struct {
} EnumRectData;
static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
EnumSizeData *data = (EnumSizeData *)dwData;
if (data->count == data->screen) {
data->size.x = lprcMonitor->right - lprcMonitor->left;
@@ -328,7 +314,6 @@ static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPR
}
Size2i DisplayServerWindows::screen_get_size(int p_screen) const {
-
_THREAD_SAFE_METHOD_
EnumSizeData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Size2() };
@@ -337,7 +322,6 @@ Size2i DisplayServerWindows::screen_get_size(int p_screen) const {
}
static BOOL CALLBACK _MonitorEnumProcUsableSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
EnumRectData *data = (EnumRectData *)dwData;
if (data->count == data->screen) {
MONITORINFO minfo;
@@ -356,7 +340,6 @@ static BOOL CALLBACK _MonitorEnumProcUsableSize(HMONITOR hMonitor, HDC hdcMonito
}
Rect2i DisplayServerWindows::screen_get_usable_rect(int p_screen) const {
-
_THREAD_SAFE_METHOD_
EnumRectData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Rect2i() };
@@ -378,7 +361,6 @@ enum _MonitorDpiType {
};
static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Default) {
-
int dpiX = 96, dpiY = 96;
static HMODULE Shcore = nullptr;
@@ -401,7 +383,6 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau
if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE)) {
hr = getDPIForMonitor(hmon, dpiType /*MDT_Effective_DPI*/, &x, &y);
if (SUCCEEDED(hr) && (x > 0) && (y > 0)) {
-
dpiX = (int)x;
dpiY = (int)y;
}
@@ -425,7 +406,6 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau
}
static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
-
EnumDpiData *data = (EnumDpiData *)dwData;
if (data->count == data->screen) {
data->dpi = QueryDpiForMonitor(hMonitor);
@@ -442,6 +422,7 @@ int DisplayServerWindows::screen_get_dpi(int p_screen) const {
EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcDpi, (LPARAM)&data);
return data.dpi;
}
+
bool DisplayServerWindows::screen_is_touchscreen(int p_screen) const {
#ifndef _MSC_VER
#warning touchscreen not working
@@ -451,18 +432,19 @@ bool DisplayServerWindows::screen_is_touchscreen(int p_screen) const {
void DisplayServerWindows::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
}
+
DisplayServer::ScreenOrientation DisplayServerWindows::screen_get_orientation(int p_screen) const {
return SCREEN_LANDSCAPE;
}
void DisplayServerWindows::screen_set_keep_on(bool p_enable) {
}
+
bool DisplayServerWindows::screen_is_kept_on() const {
return false;
}
Vector<DisplayServer::WindowID> DisplayServerWindows::get_window_list() const {
-
_THREAD_SAFE_METHOD_
Vector<DisplayServer::WindowID> ret;
@@ -473,7 +455,6 @@ Vector<DisplayServer::WindowID> DisplayServerWindows::get_window_list() const {
}
DisplayServer::WindowID DisplayServerWindows::get_window_at_screen_position(const Point2i &p_position) const {
-
POINT p;
p.x = p_position.x;
p.y = p_position.y;
@@ -488,7 +469,6 @@ DisplayServer::WindowID DisplayServerWindows::get_window_at_screen_position(cons
}
DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
-
_THREAD_SAFE_METHOD_
WindowID window_id = _create_window(p_mode, p_flags, p_rect);
@@ -518,8 +498,8 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod
return window_id;
}
-void DisplayServerWindows::delete_sub_window(WindowID p_window) {
+void DisplayServerWindows::delete_sub_window(WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -541,7 +521,7 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
#endif
- if (!OS::get_singleton()->is_wintab_disabled() && wintab_available && windows[p_window].wtctx) {
+ if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[p_window].wtctx) {
wintab_WTClose(windows[p_window].wtctx);
windows[p_window].wtctx = 0;
}
@@ -550,7 +530,6 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
void DisplayServerWindows::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -558,7 +537,6 @@ void DisplayServerWindows::window_attach_instance_id(ObjectID p_instance, Window
}
ObjectID DisplayServerWindows::window_get_attached_instance_id(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), ObjectID());
@@ -566,7 +544,6 @@ ObjectID DisplayServerWindows::window_get_attached_instance_id(WindowID p_window
}
void DisplayServerWindows::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -574,21 +551,20 @@ void DisplayServerWindows::window_set_rect_changed_callback(const Callable &p_ca
}
void DisplayServerWindows::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
windows[p_window].event_callback = p_callable;
}
-void DisplayServerWindows::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
+void DisplayServerWindows::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
windows[p_window].input_event_callback = p_callable;
}
-void DisplayServerWindows::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
+void DisplayServerWindows::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -596,7 +572,6 @@ void DisplayServerWindows::window_set_input_text_callback(const Callable &p_call
}
void DisplayServerWindows::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -604,7 +579,6 @@ void DisplayServerWindows::window_set_drop_files_callback(const Callable &p_call
}
void DisplayServerWindows::window_set_title(const String &p_title, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -612,7 +586,6 @@ void DisplayServerWindows::window_set_title(const String &p_title, WindowID p_wi
}
int DisplayServerWindows::window_get_current_screen(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), -1);
@@ -621,8 +594,8 @@ int DisplayServerWindows::window_get_current_screen(WindowID p_window) const {
EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcScreen, (LPARAM)&data);
return data.screen;
}
-void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_window) {
+void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -633,7 +606,6 @@ void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_wi
}
Point2i DisplayServerWindows::window_get_position(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
@@ -658,8 +630,8 @@ Point2i DisplayServerWindows::window_get_position(WindowID p_window) const {
return Point2(r.left, r.top);
#endif
}
-void DisplayServerWindows::_update_real_mouse_position(WindowID p_window) {
+void DisplayServerWindows::_update_real_mouse_position(WindowID p_window) {
POINT mouse_pos;
if (GetCursorPos(&mouse_pos) && ScreenToClient(windows[p_window].hWnd, &mouse_pos)) {
if (mouse_pos.x > 0 && mouse_pos.y > 0 && mouse_pos.x <= windows[p_window].width && mouse_pos.y <= windows[p_window].height) {
@@ -670,8 +642,8 @@ void DisplayServerWindows::_update_real_mouse_position(WindowID p_window) {
}
}
}
-void DisplayServerWindows::window_set_position(const Point2i &p_position, WindowID p_window) {
+void DisplayServerWindows::window_set_position(const Point2i &p_position, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -712,7 +684,6 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window
}
void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_parent) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(p_window == p_parent);
@@ -749,7 +720,6 @@ void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_pa
}
void DisplayServerWindows::window_set_max_size(const Size2i p_size, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -761,8 +731,8 @@ void DisplayServerWindows::window_set_max_size(const Size2i p_size, WindowID p_w
}
wd.max_size = p_size;
}
-Size2i DisplayServerWindows::window_get_max_size(WindowID p_window) const {
+Size2i DisplayServerWindows::window_get_max_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -771,7 +741,6 @@ Size2i DisplayServerWindows::window_get_max_size(WindowID p_window) const {
}
void DisplayServerWindows::window_set_min_size(const Size2i p_size, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -783,8 +752,8 @@ void DisplayServerWindows::window_set_min_size(const Size2i p_size, WindowID p_w
}
wd.min_size = p_size;
}
-Size2i DisplayServerWindows::window_get_min_size(WindowID p_window) const {
+Size2i DisplayServerWindows::window_get_min_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -793,7 +762,6 @@ Size2i DisplayServerWindows::window_get_min_size(WindowID p_window) const {
}
void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -837,8 +805,8 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
ClipCursor(&crect);
}
}
-Size2i DisplayServerWindows::window_get_size(WindowID p_window) const {
+Size2i DisplayServerWindows::window_get_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -854,8 +822,8 @@ Size2i DisplayServerWindows::window_get_size(WindowID p_window) const {
}
return Size2();
}
-Size2i DisplayServerWindows::window_get_real_size(WindowID p_window) const {
+Size2i DisplayServerWindows::window_get_real_size(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
@@ -869,7 +837,6 @@ Size2i DisplayServerWindows::window_get_real_size(WindowID p_window) const {
}
void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscreen, bool p_borderless, bool p_resizable, bool p_maximized, bool p_no_activate_focus, DWORD &r_style, DWORD &r_style_ex) {
-
r_style = 0;
r_style_ex = WS_EX_WINDOWEDGE;
if (p_main_window) {
@@ -882,7 +849,6 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre
// r_style_ex |= WS_EX_TOOLWINDOW;
//}
} else {
-
if (p_resizable) {
if (p_maximized) {
r_style = WS_OVERLAPPEDWINDOW | WS_MAXIMIZE;
@@ -901,7 +867,6 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre
}
void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint, bool p_maximized) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -925,14 +890,12 @@ void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repain
}
void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
if (wd.fullscreen && p_mode != WINDOW_MODE_FULLSCREEN) {
-
RECT rect;
wd.fullscreen = false;
@@ -954,21 +917,18 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
}
if (p_mode == WINDOW_MODE_MAXIMIZED) {
-
ShowWindow(wd.hWnd, SW_MAXIMIZE);
wd.maximized = true;
wd.minimized = false;
}
if (p_mode == WINDOW_MODE_WINDOWED) {
-
ShowWindow(wd.hWnd, SW_RESTORE);
wd.maximized = false;
wd.minimized = false;
}
if (p_mode == WINDOW_MODE_MINIMIZED) {
-
ShowWindow(wd.hWnd, SW_MINIMIZE);
wd.maximized = false;
wd.minimized = true;
@@ -997,8 +957,8 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
MoveWindow(wd.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
}
}
-DisplayServer::WindowMode DisplayServerWindows::window_get_mode(WindowID p_window) const {
+DisplayServer::WindowMode DisplayServerWindows::window_get_mode(WindowID p_window) const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED);
@@ -1016,7 +976,6 @@ DisplayServer::WindowMode DisplayServerWindows::window_get_mode(WindowID p_windo
}
bool DisplayServerWindows::window_is_maximize_allowed(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), false);
@@ -1027,34 +986,28 @@ bool DisplayServerWindows::window_is_maximize_allowed(WindowID p_window) const {
}
void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
switch (p_flag) {
case WINDOW_FLAG_RESIZE_DISABLED: {
-
wd.resizable = !p_enabled;
_update_window_style(p_window);
} break;
case WINDOW_FLAG_BORDERLESS: {
-
wd.borderless = p_enabled;
_update_window_style(p_window);
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
-
ERR_FAIL_COND_MSG(wd.transient_parent != INVALID_WINDOW_ID && p_enabled, "Transient windows can't become on top");
wd.always_on_top = p_enabled;
_update_window_style(p_window);
} break;
case WINDOW_FLAG_TRANSPARENT: {
-
// FIXME: Implement.
} break;
case WINDOW_FLAG_NO_FOCUS: {
-
wd.no_focus = p_enabled;
_update_window_style(p_window);
} break;
@@ -1064,30 +1017,24 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
}
bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), false);
const WindowData &wd = windows[p_window];
switch (p_flag) {
case WINDOW_FLAG_RESIZE_DISABLED: {
-
return !wd.resizable;
} break;
case WINDOW_FLAG_BORDERLESS: {
-
return wd.borderless;
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
-
return wd.always_on_top;
} break;
case WINDOW_FLAG_TRANSPARENT: {
-
// FIXME: Implement.
} break;
case WINDOW_FLAG_NO_FOCUS: {
-
return wd.no_focus;
} break;
case WINDOW_FLAG_MAX:
@@ -1098,7 +1045,6 @@ bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window
}
void DisplayServerWindows::window_request_attention(WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1112,8 +1058,8 @@ void DisplayServerWindows::window_request_attention(WindowID p_window) {
info.uCount = 2;
FlashWindowEx(&info);
}
-void DisplayServerWindows::window_move_to_foreground(WindowID p_window) {
+void DisplayServerWindows::window_move_to_foreground(WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1123,7 +1069,6 @@ void DisplayServerWindows::window_move_to_foreground(WindowID p_window) {
}
bool DisplayServerWindows::window_can_draw(WindowID p_window) const {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!windows.has(p_window), false);
@@ -1132,7 +1077,6 @@ bool DisplayServerWindows::window_can_draw(WindowID p_window) const {
}
bool DisplayServerWindows::can_any_window_draw() const {
-
_THREAD_SAFE_METHOD_
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
@@ -1145,7 +1089,6 @@ bool DisplayServerWindows::can_any_window_draw() const {
}
void DisplayServerWindows::window_set_ime_active(const bool p_active, WindowID p_window) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1159,8 +1102,8 @@ void DisplayServerWindows::window_set_ime_active(const bool p_active, WindowID p
ImmAssociateContext(wd.hWnd, (HIMC)0);
}
}
-void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
+void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window));
@@ -1181,7 +1124,6 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI
}
void DisplayServerWindows::console_set_visible(bool p_enabled) {
-
_THREAD_SAFE_METHOD_
if (console_visible == p_enabled)
@@ -1189,12 +1131,12 @@ void DisplayServerWindows::console_set_visible(bool p_enabled) {
ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE);
console_visible = p_enabled;
}
+
bool DisplayServerWindows::is_console_visible() const {
return console_visible;
}
void DisplayServerWindows::cursor_set_shape(CursorShape p_shape) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
@@ -1235,12 +1177,12 @@ void DisplayServerWindows::cursor_set_shape(CursorShape p_shape) {
cursor_shape = p_shape;
}
+
DisplayServer::CursorShape DisplayServerWindows::cursor_get_shape() const {
return cursor_shape;
}
void DisplayServerWindows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap) {
-
// Get the system display DC
HDC hDC = GetDC(nullptr);
@@ -1290,11 +1232,9 @@ void DisplayServerWindows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTra
}
void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
-
_THREAD_SAFE_METHOD_
if (p_cursor.is_valid()) {
-
Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
if (cursor_c) {
@@ -1432,75 +1372,102 @@ void DisplayServerWindows::enable_for_stealing_focus(OS::ProcessID pid) {
AllowSetForegroundWindow(pid);
}
-DisplayServer::LatinKeyboardVariant DisplayServerWindows::get_latin_keyboard_variant() const {
+int DisplayServerWindows::keyboard_get_layout_count() const {
+ return GetKeyboardLayoutList(0, NULL);
+}
- _THREAD_SAFE_METHOD_
+int DisplayServerWindows::keyboard_get_current_layout() const {
+ HKL cur_layout = GetKeyboardLayout(0);
- unsigned long azerty[] = {
- 0x00020401, // Arabic (102) AZERTY
- 0x0001080c, // Belgian (Comma)
- 0x0000080c, // Belgian French
- 0x0000040c, // French
- 0 // <--- STOP MARK
- };
- unsigned long qwertz[] = {
- 0x0000041a, // Croation
- 0x00000405, // Czech
- 0x00000407, // German
- 0x00010407, // German (IBM)
- 0x0000040e, // Hungarian
- 0x0000046e, // Luxembourgish
- 0x00010415, // Polish (214)
- 0x00000418, // Romanian (Legacy)
- 0x0000081a, // Serbian (Latin)
- 0x0000041b, // Slovak
- 0x00000424, // Slovenian
- 0x0001042e, // Sorbian Extended
- 0x0002042e, // Sorbian Standard
- 0x0000042e, // Sorbian Standard (Legacy)
- 0x0000100c, // Swiss French
- 0x00000807, // Swiss German
- 0 // <--- STOP MARK
- };
- unsigned long dvorak[] = {
- 0x00010409, // US-Dvorak
- 0x00030409, // US-Dvorak for left hand
- 0x00040409, // US-Dvorak for right hand
- 0 // <--- STOP MARK
- };
+ int layout_count = GetKeyboardLayoutList(0, NULL);
+ HKL *layouts = (HKL *)memalloc(layout_count * sizeof(HKL));
+ GetKeyboardLayoutList(layout_count, layouts);
+
+ for (int i = 0; i < layout_count; i++) {
+ if (cur_layout == layouts[i]) {
+ memfree(layouts);
+ return i;
+ }
+ }
+ memfree(layouts);
+ return -1;
+}
+
+void DisplayServerWindows::keyboard_set_current_layout(int p_index) {
+ int layout_count = GetKeyboardLayoutList(0, NULL);
+
+ ERR_FAIL_INDEX(p_index, layout_count);
+
+ HKL *layouts = (HKL *)memalloc(layout_count * sizeof(HKL));
+ GetKeyboardLayoutList(layout_count, layouts);
+ ActivateKeyboardLayout(layouts[p_index], KLF_SETFORPROCESS);
+ memfree(layouts);
+}
+
+String DisplayServerWindows::keyboard_get_layout_language(int p_index) const {
+ int layout_count = GetKeyboardLayoutList(0, NULL);
+
+ ERR_FAIL_INDEX_V(p_index, layout_count, "");
+
+ HKL *layouts = (HKL *)memalloc(layout_count * sizeof(HKL));
+ GetKeyboardLayoutList(layout_count, layouts);
+
+ wchar_t buf[LOCALE_NAME_MAX_LENGTH];
+ memset(buf, 0, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t));
+ LCIDToLocaleName(MAKELCID(LOWORD(layouts[p_index]), SORT_DEFAULT), buf, LOCALE_NAME_MAX_LENGTH, 0);
+
+ memfree(layouts);
- char name[KL_NAMELENGTH + 1];
- name[0] = 0;
- GetKeyboardLayoutNameA(name);
+ return String(buf).substr(0, 2);
+}
+
+String _get_full_layout_name_from_registry(HKL p_layout) {
+ String id = "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\" + String::num_int64((int64_t)p_layout, 16, false).lpad(8, "0");
+ String ret;
- unsigned long hex = strtoul(name, nullptr, 16);
+ HKEY hkey;
+ wchar_t layout_text[1024];
+ memset(layout_text, 0, 1024 * sizeof(wchar_t));
- int i = 0;
- while (azerty[i] != 0) {
- if (azerty[i] == hex)
- return LATIN_KEYBOARD_AZERTY;
- i++;
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCWSTR)id.c_str(), 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) {
+ return ret;
}
- i = 0;
- while (qwertz[i] != 0) {
- if (qwertz[i] == hex)
- return LATIN_KEYBOARD_QWERTZ;
- i++;
+ DWORD buffer = 1024;
+ DWORD vtype = REG_SZ;
+ if (RegQueryValueExW(hkey, L"Layout Text", NULL, &vtype, (LPBYTE)layout_text, &buffer) == ERROR_SUCCESS) {
+ ret = String(layout_text);
}
+ RegCloseKey(hkey);
+ return ret;
+}
+
+String DisplayServerWindows::keyboard_get_layout_name(int p_index) const {
+ int layout_count = GetKeyboardLayoutList(0, NULL);
+
+ ERR_FAIL_INDEX_V(p_index, layout_count, "");
+
+ HKL *layouts = (HKL *)memalloc(layout_count * sizeof(HKL));
+ GetKeyboardLayoutList(layout_count, layouts);
+
+ String ret = _get_full_layout_name_from_registry(layouts[p_index]); // Try reading full name from Windows registry, fallback to locale name if failed (e.g. on Wine).
+ if (ret == String()) {
+ wchar_t buf[LOCALE_NAME_MAX_LENGTH];
+ memset(buf, 0, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t));
+ LCIDToLocaleName(MAKELCID(LOWORD(layouts[p_index]), SORT_DEFAULT), buf, LOCALE_NAME_MAX_LENGTH, 0);
- i = 0;
- while (dvorak[i] != 0) {
- if (dvorak[i] == hex)
- return LATIN_KEYBOARD_DVORAK;
- i++;
+ wchar_t name[1024];
+ memset(name, 0, 1024 * sizeof(wchar_t));
+ GetLocaleInfoEx(buf, LOCALE_SLOCALIZEDDISPLAYNAME, (LPWSTR)&name, 1024);
+
+ ret = String(name);
}
+ memfree(layouts);
- return LATIN_KEYBOARD_QWERTY;
+ return ret;
}
void DisplayServerWindows::process_events() {
-
_THREAD_SAFE_METHOD_
MSG msg;
@@ -1510,7 +1477,6 @@ void DisplayServerWindows::process_events() {
}
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
-
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
@@ -1522,7 +1488,6 @@ void DisplayServerWindows::process_events() {
}
void DisplayServerWindows::force_process_and_drop_events() {
-
_THREAD_SAFE_METHOD_
drop_events = true;
@@ -1532,13 +1497,14 @@ void DisplayServerWindows::force_process_and_drop_events() {
void DisplayServerWindows::release_rendering_thread() {
}
+
void DisplayServerWindows::make_rendering_thread() {
}
+
void DisplayServerWindows::swap_buffers() {
}
void DisplayServerWindows::set_native_icon(const String &p_filename) {
-
_THREAD_SAFE_METHOD_
FileAccess *f = FileAccess::open(p_filename, FileAccess::READ);
@@ -1631,8 +1597,8 @@ void DisplayServerWindows::set_native_icon(const String &p_filename) {
memdelete(f);
memdelete(icon_dir);
}
-void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
+void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!p_icon.is_valid());
@@ -1664,9 +1630,7 @@ void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
const uint8_t *r = icon->get_data().ptr();
for (int i = 0; i < h; i++) {
-
for (int j = 0; j < w; j++) {
-
const uint8_t *rpx = &r[((h - i - 1) * w + j) * 4];
uint8_t *wpx = &wr[(i * w + j) * 4];
wpx[0] = rpx[2];
@@ -1687,6 +1651,7 @@ void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
void DisplayServerWindows::vsync_set_use_via_compositor(bool p_enable) {
}
+
bool DisplayServerWindows::vsync_is_using_via_compositor() const {
return false;
}
@@ -1703,7 +1668,6 @@ void DisplayServerWindows::set_context(Context p_context) {
#define IsTouchEvent(dw) (IsPenEvent(dw) && ((dw)&0x80))
void DisplayServerWindows::_touch_event(WindowID p_window, bool p_pressed, float p_x, float p_y, int idx) {
-
// Defensive
if (touch_state.has(idx) == p_pressed)
return;
@@ -1725,7 +1689,6 @@ void DisplayServerWindows::_touch_event(WindowID p_window, bool p_pressed, float
}
void DisplayServerWindows::_drag_event(WindowID p_window, float p_x, float p_y, int idx) {
-
Map<int, Vector2>::Element *curr = touch_state.find(idx);
// Defensive
if (!curr)
@@ -1747,7 +1710,6 @@ void DisplayServerWindows::_drag_event(WindowID p_window, float p_x, float p_y,
}
void DisplayServerWindows::_send_window_event(const WindowData &wd, WindowEvent p_event) {
-
if (!wd.event_callback.is_null()) {
Variant event = int(p_event);
Variant *eventp = &event;
@@ -1762,7 +1724,12 @@ void DisplayServerWindows::_dispatch_input_events(const Ref<InputEvent> &p_event
}
void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event) {
+ _THREAD_SAFE_METHOD_
+ if (in_dispatch_input_event) {
+ return;
+ }
+ in_dispatch_input_event = true;
Variant ev = p_event;
Variant *evp = &ev;
Variant ret;
@@ -1774,6 +1741,7 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event)
ERR_FAIL_COND(!windows.has(event_from_window->get_window_id()));
Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
if (callable.is_null()) {
+ in_dispatch_input_event = false;
return;
}
callable.call((const Variant **)&evp, 1, ret, ce);
@@ -1787,14 +1755,13 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event)
callable.call((const Variant **)&evp, 1, ret, ce);
}
}
+
+ in_dispatch_input_event = false;
}
LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
-
if (drop_events) {
-
if (user_proc) {
-
return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
} else {
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
@@ -1813,7 +1780,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
switch (uMsg) // Check For Windows Messages
{
case WM_SETFOCUS: {
-
windows[window_id].window_has_focus = true;
last_focused_window = window_id;
@@ -1842,7 +1808,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
windows[window_id].minimized = HIWORD(wParam) != 0;
if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) {
-
_send_window_event(windows[window_id], WINDOW_EVENT_FOCUS_IN);
windows[window_id].window_focused = true;
alt_mem = false;
@@ -1855,7 +1820,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
alt_mem = false;
};
- if (!OS::get_singleton()->is_wintab_disabled() && wintab_available && windows[window_id].wtctx) {
+ if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
wintab_WTEnable(windows[window_id].wtctx, GET_WM_ACTIVATE_STATE(wParam, lParam));
}
@@ -1899,13 +1864,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_CLOSE: // Did We Receive A Close Message?
{
-
_send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST);
return 0; // Jump Back
}
case WM_MOUSELEAVE: {
-
old_invalid = true;
outside = true;
@@ -1959,7 +1922,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY));
} else if (raw->data.mouse.usFlags == MOUSE_MOVE_ABSOLUTE) {
-
int nScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
int nScreenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
@@ -1991,7 +1953,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
case WT_CSRCHANGE:
case WT_PROXIMITY: {
- if (!OS::get_singleton()->is_wintab_disabled() && wintab_available && windows[window_id].wtctx) {
+ if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
AXIS pressure;
if (wintab_WTInfo(WTI_DEVICES + windows[window_id].wtlc.lcDevice, DVC_NPRESSURE, &pressure)) {
windows[window_id].min_pressure = int(pressure.axMin);
@@ -2005,10 +1967,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
} break;
case WT_PACKET: {
- if (!OS::get_singleton()->is_wintab_disabled() && wintab_available && windows[window_id].wtctx) {
+ if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
PACKET packet;
if (wintab_WTPacket(windows[window_id].wtctx, wParam, &packet)) {
-
float pressure = float(packet.pkNormalPressure - windows[window_id].min_pressure) / float(windows[window_id].max_pressure - windows[window_id].min_pressure);
windows[window_id].last_pressure = pressure;
windows[window_id].last_pressure_update = 0;
@@ -2075,17 +2036,43 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
old_x = mm->get_position().x;
old_y = mm->get_position().y;
if (windows[window_id].window_has_focus)
- Input::get_singleton()->parse_input_event(mm);
+ Input::get_singleton()->accumulate_input_event(mm);
}
return 0;
}
} break;
+ case WM_POINTERENTER: {
+ if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
+ break;
+ }
+
+ if ((OS::get_singleton()->get_current_tablet_driver() != "winink") || !winink_available) {
+ break;
+ }
+
+ uint32_t pointer_id = LOWORD(wParam);
+ POINTER_INPUT_TYPE pointer_type = PT_POINTER;
+ if (!win8p_GetPointerType(pointer_id, &pointer_type)) {
+ break;
+ }
+
+ if (pointer_type != PT_PEN) {
+ break;
+ }
+
+ windows[window_id].block_mm = true;
+ return 0;
+ } break;
+ case WM_POINTERLEAVE: {
+ windows[window_id].block_mm = false;
+ return 0;
+ } break;
case WM_POINTERUPDATE: {
if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
break;
}
- if (!win8p_GetPointerType || !win8p_GetPointerPenInfo) {
+ if ((OS::get_singleton()->get_current_tablet_driver() != "winink") || !winink_available) {
break;
}
@@ -2166,7 +2153,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_global_position(Vector2(coords.x, coords.y));
if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
Point2i c(windows[window_id].width / 2, windows[window_id].height / 2);
old_x = c.x;
old_y = c.y;
@@ -2187,7 +2173,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_speed(Input::get_singleton()->get_last_mouse_speed());
if (old_invalid) {
-
old_x = mm->get_position().x;
old_y = mm->get_position().y;
old_invalid = false;
@@ -2197,12 +2182,16 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
old_x = mm->get_position().x;
old_y = mm->get_position().y;
if (windows[window_id].window_has_focus) {
- Input::get_singleton()->parse_input_event(mm);
+ Input::get_singleton()->accumulate_input_event(mm);
}
return 0; //Pointer event handled return 0 to avoid duplicate WM_MOUSEMOVE event
} break;
case WM_MOUSEMOVE: {
+ if (windows[window_id].block_mm) {
+ break;
+ }
+
if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
break;
}
@@ -2247,7 +2236,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_shift((wParam & MK_SHIFT) != 0);
mm->set_alt(alt_mem);
- if (!OS::get_singleton()->is_wintab_disabled() && wintab_available && windows[window_id].wtctx) {
+ if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
// Note: WinTab sends both WT_PACKET and WM_xBUTTONDOWN/UP/MOUSEMOVE events, use mouse 1/0 pressure only when last_pressure was not update recently.
if (windows[window_id].last_pressure_update < 10) {
windows[window_id].last_pressure_update++;
@@ -2269,7 +2258,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_global_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
if (mouse_mode == MOUSE_MODE_CAPTURED) {
-
Point2i c(windows[window_id].width / 2, windows[window_id].height / 2);
old_x = c.x;
old_y = c.y;
@@ -2290,7 +2278,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mm->set_speed(Input::get_singleton()->get_last_mouse_speed());
if (old_invalid) {
-
old_x = mm->get_position().x;
old_y = mm->get_position().y;
old_invalid = false;
@@ -2325,7 +2312,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_XBUTTONDBLCLK:
case WM_XBUTTONDOWN:
case WM_XBUTTONUP: {
-
Ref<InputEventMouseButton> mb;
mb.instance();
mb->set_window_id(window_id);
@@ -2371,7 +2357,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_doubleclick(true);
} break;
case WM_MOUSEWHEEL: {
-
mb->set_pressed(true);
int motion = (short)HIWORD(wParam);
if (!motion)
@@ -2384,7 +2369,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
case WM_MOUSEHWHEEL: {
-
mb->set_pressed(true);
int motion = (short)HIWORD(wParam);
if (!motion)
@@ -2399,7 +2383,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
} break;
case WM_XBUTTONDOWN: {
-
mb->set_pressed(true);
if (HIWORD(wParam) == XBUTTON1)
mb->set_button_index(BUTTON_XBUTTON1);
@@ -2407,7 +2390,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_button_index(BUTTON_XBUTTON2);
} break;
case WM_XBUTTONUP: {
-
mb->set_pressed(false);
if (HIWORD(wParam) == XBUTTON1)
mb->set_button_index(BUTTON_XBUTTON1);
@@ -2415,7 +2397,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_button_index(BUTTON_XBUTTON2);
} break;
case WM_XBUTTONDBLCLK: {
-
mb->set_pressed(true);
if (HIWORD(wParam) == XBUTTON1)
mb->set_button_index(BUTTON_XBUTTON1);
@@ -2441,17 +2422,14 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
mb->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
if (mouse_mode == MOUSE_MODE_CAPTURED && !use_raw_input) {
-
mb->set_position(Vector2(old_x, old_y));
}
if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) {
if (mb->is_pressed()) {
-
if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED)
SetCapture(hWnd);
} else {
-
if (--pressrc <= 0) {
if (mouse_mode != MOUSE_MODE_CAPTURED) {
ReleaseCapture();
@@ -2492,7 +2470,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
windows[window_id].last_pos = Point2(x, y);
if (!windows[window_id].rect_changed_callback.is_null()) {
-
Variant size = Rect2i(windows[window_id].last_pos.x, windows[window_id].last_pos.y, windows[window_id].width, windows[window_id].height);
Variant *sizep = &size;
Variant ret;
@@ -2524,7 +2501,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
if (!windows[window_id].rect_changed_callback.is_null()) {
-
Variant size = Rect2i(windows[window_id].last_pos.x, windows[window_id].last_pos.y, windows[window_id].width, windows[window_id].height);
Variant *sizep = &size;
Variant ret;
@@ -2588,7 +2564,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_SYSKEYUP:
case WM_KEYUP:
case WM_KEYDOWN: {
-
if (wParam == VK_SHIFT)
shift_mem = uMsg == WM_KEYDOWN;
if (wParam == VK_CONTROL)
@@ -2612,7 +2587,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
[[fallthrough]];
}
case WM_CHAR: {
-
ERR_BREAK(key_event_pos >= KEY_EVENT_BUFFER_SIZE);
// Make sure we don't include modifiers for the modifier key itself.
@@ -2635,12 +2609,10 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
case WM_INPUTLANGCHANGEREQUEST: {
-
// FIXME: Do something?
} break;
case WM_TOUCH: {
-
BOOL bHandled = FALSE;
UINT cInputs = LOWORD(wParam);
PTOUCHINPUT pInputs = memnew_arr(TOUCHINPUT, cInputs);
@@ -2655,10 +2627,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
ScreenToClient(hWnd, &touch_pos);
//do something with each touch input entry
if (ti.dwFlags & TOUCHEVENTF_MOVE) {
-
_drag_event(window_id, touch_pos.x, touch_pos.y, ti.dwID);
} else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) {
-
_touch_event(window_id, ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID);
};
}
@@ -2678,7 +2648,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
case WM_DEVICECHANGE: {
-
joypad->probe_joypads();
} break;
case WM_SETCURSOR: {
@@ -2701,7 +2670,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
case WM_DROPFILES: {
-
HDROP hDropInfo = (HDROP)wParam;
const int buffsize = 4096;
wchar_t buf[buffsize];
@@ -2711,7 +2679,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
Vector<String> files;
for (int i = 0; i < fcount; i++) {
-
DragQueryFileW(hDropInfo, i, buf, buffsize);
String file = buf;
files.push_back(file);
@@ -2728,9 +2695,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
default: {
-
if (user_proc) {
-
return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
};
};
@@ -2740,7 +2705,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
-
DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton());
if (ds_win)
return ds_win->WndProc(hWnd, uMsg, wParam, lParam);
@@ -2749,14 +2713,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
void DisplayServerWindows::_process_key_events() {
-
for (int i = 0; i < key_event_pos; i++) {
-
KeyEvent &ke = key_event_buffer[i];
switch (ke.uMsg) {
-
case WM_CHAR: {
- if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) {
+ // extended keys should only be processed as WM_KEYDOWN message.
+ if (!KeyMappingWindows::is_extended_key(ke.wParam) && ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR))) {
Ref<InputEventKey> k;
k.instance();
@@ -2784,7 +2746,6 @@ void DisplayServerWindows::_process_key_events() {
} break;
case WM_KEYUP:
case WM_KEYDOWN: {
-
Ref<InputEventKey> k;
k.instance();
@@ -2827,8 +2788,46 @@ void DisplayServerWindows::_process_key_events() {
key_event_pos = 0;
}
-DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
+void DisplayServerWindows::_update_tablet_ctx(const String &p_old_driver, const String &p_new_driver) {
+ for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
+ WindowData &wd = E->get();
+ wd.block_mm = false;
+ if ((p_old_driver == "wintab") && wintab_available && wd.wtctx) {
+ wintab_WTEnable(wd.wtctx, false);
+ wintab_WTClose(wd.wtctx);
+ wd.wtctx = 0;
+ }
+ if ((p_new_driver == "wintab") && wintab_available) {
+ wintab_WTInfo(WTI_DEFSYSCTX, 0, &wd.wtlc);
+ wd.wtlc.lcOptions |= CXO_MESSAGES;
+ wd.wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
+ wd.wtlc.lcMoveMask = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE;
+ wd.wtlc.lcPktMode = 0;
+ wd.wtlc.lcOutOrgX = 0;
+ wd.wtlc.lcOutExtX = wd.wtlc.lcInExtX;
+ wd.wtlc.lcOutOrgY = 0;
+ wd.wtlc.lcOutExtY = -wd.wtlc.lcInExtY;
+ wd.wtctx = wintab_WTOpen(wd.hWnd, &wd.wtlc, false);
+ if (wd.wtctx) {
+ wintab_WTEnable(wd.wtctx, true);
+ AXIS pressure;
+ if (wintab_WTInfo(WTI_DEVICES + wd.wtlc.lcDevice, DVC_NPRESSURE, &pressure)) {
+ wd.min_pressure = int(pressure.axMin);
+ wd.max_pressure = int(pressure.axMax);
+ }
+ AXIS orientation[3];
+ if (wintab_WTInfo(WTI_DEVICES + wd.wtlc.lcDevice, DVC_ORIENTATION, &orientation)) {
+ wd.tilt_supported = orientation[0].axResolution && orientation[1].axResolution;
+ }
+ wintab_WTEnable(wd.wtctx, true);
+ } else {
+ print_verbose("WinTab context creation failed.");
+ }
+ }
+ }
+}
+DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) {
DWORD dwExStyle;
DWORD dwStyle;
@@ -2884,7 +2883,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
DragAcceptFiles(wd.hWnd, true);
- if (!OS::get_singleton()->is_wintab_disabled() && wintab_available) {
+ if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available) {
wintab_WTInfo(WTI_DEFSYSCTX, 0, &wd.wtlc);
wd.wtlc.lcOptions |= CXO_MESSAGES;
wd.wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
@@ -2943,6 +2942,7 @@ WTPacketPtr DisplayServerWindows::wintab_WTPacket = nullptr;
WTEnablePtr DisplayServerWindows::wintab_WTEnable = nullptr;
// Windows Ink API
+bool DisplayServerWindows::winink_available = false;
GetPointerTypePtr DisplayServerWindows::win8p_GetPointerType = nullptr;
GetPointerPenInfoPtr DisplayServerWindows::win8p_GetPointerPenInfo = nullptr;
@@ -2953,26 +2953,6 @@ typedef enum _SHC_PROCESS_DPI_AWARENESS {
} SHC_PROCESS_DPI_AWARENESS;
DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
-
- //Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
- HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
- if (wintab_lib) {
- wintab_WTOpen = (WTOpenPtr)GetProcAddress(wintab_lib, "WTOpenW");
- wintab_WTClose = (WTClosePtr)GetProcAddress(wintab_lib, "WTClose");
- wintab_WTInfo = (WTInfoPtr)GetProcAddress(wintab_lib, "WTInfoW");
- wintab_WTPacket = (WTPacketPtr)GetProcAddress(wintab_lib, "WTPacket");
- wintab_WTEnable = (WTEnablePtr)GetProcAddress(wintab_lib, "WTEnable");
-
- wintab_available = wintab_WTOpen && wintab_WTClose && wintab_WTInfo && wintab_WTPacket && wintab_WTEnable;
- }
-
- //Note: Windows Ink API for pen input, available on Windows 8+ only.
- HMODULE user32_lib = LoadLibraryW(L"user32.dll");
- if (user32_lib) {
- win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
- win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
- }
-
drop_events = false;
key_event_pos = 0;
@@ -3042,7 +3022,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
context_vulkan = memnew(VulkanContextWindows);
if (context_vulkan->initialize() != OK) {
memdelete(context_vulkan);
@@ -3054,7 +3033,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
#endif
#if defined(OPENGL_ENABLED)
if (rendering_driver_index == VIDEO_DRIVER_GLES2) {
-
context_gles2 = memnew(ContextGL_Windows(hWnd, false));
if (context_gles2->initialize() != OK) {
@@ -3093,7 +3071,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
-
rendering_device_vulkan = memnew(RenderingDeviceVulkan);
rendering_device_vulkan->initialize(context_vulkan);
@@ -3144,35 +3121,19 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() {
}
DisplayServer *DisplayServerWindows::create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
-
return memnew(DisplayServerWindows(p_rendering_driver, p_mode, p_flags, p_resolution, r_error));
}
void DisplayServerWindows::register_windows_driver() {
-
register_create_function("windows", create_func, get_rendering_drivers_func);
}
DisplayServerWindows::~DisplayServerWindows() {
-
delete joypad;
touch_state.clear();
cursors_cache.clear();
-#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
-
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
- }
-
- if (context_vulkan)
- memdelete(context_vulkan);
- }
-#endif
-
if (user_proc) {
SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
};
@@ -3189,4 +3150,16 @@ DisplayServerWindows::~DisplayServerWindows() {
}
DestroyWindow(windows[MAIN_WINDOW_ID].hWnd);
}
+
+#if defined(VULKAN_ENABLED)
+ if (rendering_driver == "vulkan") {
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ }
+
+ if (context_vulkan)
+ memdelete(context_vulkan);
+ }
+#endif
}
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 4f5bdbac5b..995ced0809 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -229,6 +229,14 @@ typedef struct tagPOINTER_PEN_INFO {
#define WM_POINTERUPDATE 0x0245
#endif
+#ifndef WM_POINTERENTER
+#define WM_POINTERENTER 0x0249
+#endif
+
+#ifndef WM_POINTERLEAVE
+#define WM_POINTERLEAVE 0x024A
+#endif
+
typedef BOOL(WINAPI *GetPointerTypePtr)(uint32_t p_id, POINTER_INPUT_TYPE *p_type);
typedef BOOL(WINAPI *GetPointerPenInfoPtr)(uint32_t p_id, POINTER_PEN_INFO *p_pen_info);
@@ -256,6 +264,7 @@ class DisplayServerWindows : public DisplayServer {
_THREAD_SAFE_CLASS_
+public:
// WinTab API
static bool wintab_available;
static WTOpenPtr wintab_WTOpen;
@@ -265,9 +274,13 @@ class DisplayServerWindows : public DisplayServer {
static WTEnablePtr wintab_WTEnable;
// Windows Ink API
+ static bool winink_available;
static GetPointerTypePtr win8p_GetPointerType;
static GetPointerPenInfoPtr win8p_GetPointerPenInfo;
+ void _update_tablet_ctx(const String &p_old_driver, const String &p_new_driver);
+
+private:
void GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap);
enum {
@@ -275,7 +288,6 @@ class DisplayServerWindows : public DisplayServer {
};
struct KeyEvent {
-
WindowID window_id;
bool alt, shift, control, meta;
UINT uMsg;
@@ -329,6 +341,7 @@ class DisplayServerWindows : public DisplayServer {
int min_pressure;
int max_pressure;
bool tilt_supported;
+ bool block_mm = false;
int last_pressure_update;
float last_pressure;
@@ -389,6 +402,7 @@ class DisplayServerWindows : public DisplayServer {
uint32_t last_button_state = 0;
bool use_raw_input = false;
bool drop_events = false;
+ bool in_dispatch_input_event = false;
bool console_visible = false;
WNDCLASSEXW wc;
@@ -509,7 +523,11 @@ public:
virtual void enable_for_stealing_focus(OS::ProcessID pid);
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+ virtual int keyboard_get_layout_count() const;
+ virtual int keyboard_get_current_layout() const;
+ virtual void keyboard_set_current_layout(int p_index);
+ virtual String keyboard_get_layout_language(int p_index) const;
+ virtual String keyboard_get_layout_name(int p_index) const;
virtual void process_events();
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index d63067587c..c2436e8b64 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -38,7 +38,6 @@
static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size);
class EditorExportPlatformWindows : public EditorExportPlatformPC {
-
void _rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path);
Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path);
@@ -331,7 +330,6 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
}
void register_windows_exporter() {
-
EDITOR_DEF("export/windows/rcedit", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/rcedit", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
#ifdef WINDOWS_ENABLED
@@ -366,7 +364,6 @@ void register_windows_exporter() {
}
static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
-
// Patch the header of the "pck" section in the PE file so that it corresponds to the embedded data
FileAccess *f = FileAccess::open(p_path, FileAccess::READ_WRITE);
@@ -408,7 +405,6 @@ static Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start,
bool found = false;
for (int i = 0; i < num_sections; ++i) {
-
int64_t section_header_pos = section_table_pos + i * 40;
f->seek(section_header_pos);
diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index 2aa928c2a7..910059a9fc 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -136,7 +136,6 @@ char *wc_to_utf8(const wchar_t *wc) {
}
int widechar_main(int argc, wchar_t **argv) {
-
OS_Windows os(nullptr);
setlocale(LC_CTYPE, "");
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp
index 821d4eb685..271a4e41bc 100644
--- a/platform/windows/joypad_windows.cpp
+++ b/platform/windows/joypad_windows.cpp
@@ -33,10 +33,6 @@
#include <oleauto.h>
#include <wbemidl.h>
-#ifndef __GNUC__
-#define __builtin_bswap32 _byteswap_ulong
-#endif
-
#if defined(__GNUC__)
// Workaround GCC warning from -Wcast-function-type.
#define GetProcAddress (void *)GetProcAddress
@@ -45,6 +41,7 @@
DWORD WINAPI _xinput_get_state(DWORD dwUserIndex, XINPUT_STATE *pState) {
return ERROR_DEVICE_NOT_CONNECTED;
}
+
DWORD WINAPI _xinput_set_state(DWORD dwUserIndex, XINPUT_VIBRATION *pVibration) {
return ERROR_DEVICE_NOT_CONNECTED;
}
@@ -53,7 +50,6 @@ JoypadWindows::JoypadWindows() {
}
JoypadWindows::JoypadWindows(HWND *hwnd) {
-
input = Input::get_singleton();
hWnd = hwnd;
joypad_count = 0;
@@ -67,27 +63,31 @@ JoypadWindows::JoypadWindows(HWND *hwnd) {
for (int i = 0; i < JOYPADS_MAX; i++)
attached_joypads[i] = false;
- HRESULT result;
- result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr);
- if (FAILED(result)) {
- printf("failed init DINPUT: %ld\n", result);
+ HRESULT result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr);
+ if (result == DI_OK) {
+ probe_joypads();
+ } else {
+ ERR_PRINT("Couldn't initialize DirectInput. Error: " + itos(result));
+ if (result == DIERR_OUTOFMEMORY) {
+ ERR_PRINT("The Windows DirectInput subsystem could not allocate sufficient memory.");
+ ERR_PRINT("Rebooting your PC may solve this issue.");
+ }
+ // Ensure dinput is still a nullptr.
+ dinput = nullptr;
}
- probe_joypads();
}
JoypadWindows::~JoypadWindows() {
-
close_joypad();
- dinput->Release();
+ if (dinput) {
+ dinput->Release();
+ }
unload_xinput();
}
bool JoypadWindows::have_device(const GUID &p_guid) {
-
for (int i = 0; i < JOYPADS_MAX; i++) {
-
if (d_joypads[i].guid == p_guid) {
-
d_joypads[i].confirmed = true;
return true;
}
@@ -97,7 +97,6 @@ bool JoypadWindows::have_device(const GUID &p_guid) {
// adapted from SDL2, works a lot better than the MSDN version
bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
-
static GUID IID_ValveStreamingGamepad = { MAKELONG(0x28DE, 0x11FF), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
static GUID IID_X360WiredGamepad = { MAKELONG(0x045E, 0x02A1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
static GUID IID_X360WirelessGamepad = { MAKELONG(0x045E, 0x028E), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } };
@@ -120,7 +119,6 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
return false;
}
for (unsigned int i = 0; i < dev_list_count; i++) {
-
RID_DEVICE_INFO rdi;
char dev_name[128];
UINT rdiSize = sizeof(rdi);
@@ -132,7 +130,6 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == (LONG)p_guid->Data1) &&
(GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICENAME, &dev_name, &nameSize) != (UINT)-1) &&
(strstr(dev_name, "IG_") != nullptr)) {
-
free(dev_list);
return true;
}
@@ -142,7 +139,7 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
}
bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) {
-
+ ERR_FAIL_NULL_V_MSG(dinput, false, "DirectInput not initialized. Rebooting your PC may solve this issue.");
HRESULT hr;
int num = input->get_unused_joy_id();
@@ -166,10 +163,13 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) {
const GUID &guid = instance->guidProduct;
char uid[128];
- sprintf_s(uid, "%08lx%04hx%04hx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
- __builtin_bswap32(guid.Data1), guid.Data2, guid.Data3,
- guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
- guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
+
+ ERR_FAIL_COND_V_MSG(memcmp(&guid.Data4[2], "PIDVID", 6), false, "DirectInput device not recognised.");
+ WORD type = BSWAP16(0x03);
+ WORD vendor = BSWAP16(LOWORD(guid.Data1));
+ WORD product = BSWAP16(HIWORD(guid.Data1));
+ WORD version = 0;
+ sprintf_s(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", type, 0, vendor, 0, product, 0, version, 0);
id_to_change = joypad_count;
@@ -189,9 +189,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) {
}
void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_joy_id) {
-
if (ob->dwType & DIDFT_AXIS) {
-
HRESULT res;
DIPROPRANGE prop_range;
DIPROPDWORD dilong;
@@ -240,7 +238,6 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_
}
BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE *p_instance, void *p_context) {
-
JoypadWindows *self = (JoypadWindows *)p_context;
if (self->is_xinput_device(&p_instance->guidProduct)) {
return DIENUM_CONTINUE;
@@ -250,7 +247,6 @@ BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE *p_instance, vo
}
BOOL CALLBACK JoypadWindows::objectsCallback(const DIDEVICEOBJECTINSTANCE *instance, void *context) {
-
JoypadWindows *self = (JoypadWindows *)context;
self->setup_joypad_object(instance, self->id_to_change);
@@ -258,11 +254,8 @@ BOOL CALLBACK JoypadWindows::objectsCallback(const DIDEVICEOBJECTINSTANCE *insta
}
void JoypadWindows::close_joypad(int id) {
-
if (id == -1) {
-
for (int i = 0; i < JOYPADS_MAX; i++) {
-
close_joypad(i);
}
return;
@@ -281,18 +274,15 @@ void JoypadWindows::close_joypad(int id) {
}
void JoypadWindows::probe_joypads() {
-
+ ERR_FAIL_NULL_MSG(dinput, "DirectInput not initialized. Rebooting your PC may solve this issue.");
DWORD dwResult;
for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) {
-
ZeroMemory(&x_joypads[i].state, sizeof(XINPUT_STATE));
dwResult = xinput_get_state(i, &x_joypads[i].state);
if (dwResult == ERROR_SUCCESS) {
-
int id = input->get_unused_joy_id();
if (id != -1 && !x_joypads[i].attached) {
-
x_joypads[i].attached = true;
x_joypads[i].id = id;
x_joypads[i].ff_timestamp = 0;
@@ -302,7 +292,6 @@ void JoypadWindows::probe_joypads() {
input->joy_connection_changed(id, true, "XInput Gamepad", "__XINPUT_DEVICE__");
}
} else if (x_joypads[i].attached) {
-
x_joypads[i].attached = false;
attached_joypads[x_joypads[i].id] = false;
input->joy_connection_changed(x_joypads[i].id, false, "");
@@ -310,27 +299,22 @@ void JoypadWindows::probe_joypads() {
}
for (int i = 0; i < joypad_count; i++) {
-
d_joypads[i].confirmed = false;
}
dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback, this, DIEDFL_ATTACHEDONLY);
for (int i = 0; i < joypad_count; i++) {
-
if (!d_joypads[i].confirmed) {
-
close_joypad(i);
}
}
}
void JoypadWindows::process_joypads() {
-
HRESULT hr;
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
-
xinput_gamepad &joy = x_joypads[i];
if (!joy.attached) {
continue;
@@ -339,10 +323,8 @@ void JoypadWindows::process_joypads() {
xinput_get_state(i, &joy.state);
if (joy.state.dwPacketNumber != joy.last_packet) {
-
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
for (int j = 0; j <= 16; j++) {
-
input->joy_button(joy.id, j, joy.state.Gamepad.wButtons & button_mask);
button_mask = button_mask * 2;
}
@@ -372,7 +354,6 @@ void JoypadWindows::process_joypads() {
}
for (int i = 0; i < JOYPADS_MAX; i++) {
-
dinput_gamepad *joy = &d_joypads[i];
if (!joy->attached)
@@ -393,18 +374,13 @@ void JoypadWindows::process_joypads() {
post_hat(joy->id, js.rgdwPOV[0]);
for (int j = 0; j < 128; j++) {
-
if (js.rgbButtons[j] & 0x80) {
-
if (!joy->last_buttons[j]) {
-
input->joy_button(joy->id, j, true);
joy->last_buttons[j] = true;
}
} else {
-
if (joy->last_buttons[j]) {
-
input->joy_button(joy->id, j, false);
joy->last_buttons[j] = false;
}
@@ -417,7 +393,6 @@ void JoypadWindows::process_joypads() {
int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz };
for (int j = 0; j < joy->joy_axis.size(); j++) {
-
for (int k = 0; k < count; k++) {
if (joy->joy_axis[j] == axes[k]) {
input->joy_axis(joy->id, j, axis_correct(values[k]));
@@ -430,7 +405,6 @@ void JoypadWindows::process_joypads() {
}
void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
-
int dpad_val = 0;
// Should be -1 when centered, but according to docs:
@@ -441,42 +415,33 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
dpad_val = Input::HAT_MASK_CENTER;
}
if (p_dpad == 0) {
-
dpad_val = Input::HAT_MASK_UP;
} else if (p_dpad == 4500) {
-
dpad_val = (Input::HAT_MASK_UP | Input::HAT_MASK_RIGHT);
} else if (p_dpad == 9000) {
-
dpad_val = Input::HAT_MASK_RIGHT;
} else if (p_dpad == 13500) {
-
dpad_val = (Input::HAT_MASK_RIGHT | Input::HAT_MASK_DOWN);
} else if (p_dpad == 18000) {
-
dpad_val = Input::HAT_MASK_DOWN;
} else if (p_dpad == 22500) {
-
dpad_val = (Input::HAT_MASK_DOWN | Input::HAT_MASK_LEFT);
} else if (p_dpad == 27000) {
-
dpad_val = Input::HAT_MASK_LEFT;
} else if (p_dpad == 31500) {
-
dpad_val = (Input::HAT_MASK_LEFT | Input::HAT_MASK_UP);
}
input->joy_hat(p_device, dpad_val);
};
Input::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
-
Input::JoyAxis jx;
if (Math::abs(p_val) < MIN_JOY_AXIS) {
jx.min = p_trigger ? 0 : -1;
@@ -484,7 +449,6 @@ Input::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trig
return jx;
}
if (p_xinput) {
-
if (p_trigger) {
jx.min = 0;
jx.value = (float)p_val / MAX_TRIGGER;
@@ -534,7 +498,6 @@ void JoypadWindows::joypad_vibration_stop_xinput(int p_device, uint64_t p_timest
}
void JoypadWindows::load_xinput() {
-
xinput_get_state = &_xinput_get_state;
xinput_set_state = &_xinput_set_state;
xinput_dll = LoadLibrary("XInput1_4.dll");
@@ -561,9 +524,7 @@ void JoypadWindows::load_xinput() {
}
void JoypadWindows::unload_xinput() {
-
if (xinput_dll) {
-
FreeLibrary((HMODULE)xinput_dll);
}
}
diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h
index fefdcf1673..6c06b3f6f0 100644
--- a/platform/windows/joypad_windows.h
+++ b/platform/windows/joypad_windows.h
@@ -70,7 +70,6 @@ private:
};
struct dinput_gamepad {
-
int id;
bool attached;
bool confirmed;
@@ -93,7 +92,6 @@ private:
};
struct xinput_gamepad {
-
int id;
bool attached;
bool vibrating;
diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp
index 92a2585745..d8d0b13068 100644
--- a/platform/windows/key_mapping_windows.cpp
+++ b/platform/windows/key_mapping_windows.cpp
@@ -33,7 +33,6 @@
#include <stdio.h>
struct _WinTranslatePair {
-
unsigned int keysym;
unsigned int keycode;
};
@@ -337,9 +336,7 @@ static _WinTranslatePair _scancode_to_keycode[] = {
};
unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) {
-
for (int i = 0; _vk_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
-
if (_vk_to_keycode[i].keycode == p_code) {
//printf("outcode: %x\n",_vk_to_keycode[i].keysym);
@@ -353,7 +350,6 @@ unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) {
unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended) {
unsigned int keycode = KEY_UNKNOWN;
for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) {
-
if (_scancode_to_keycode[i].keycode == p_code) {
keycode = _scancode_to_keycode[i].keysym;
break;
@@ -415,3 +411,16 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended
return keycode;
}
+
+bool KeyMappingWindows::is_extended_key(unsigned int p_code) {
+ return p_code == VK_INSERT ||
+ p_code == VK_DELETE ||
+ p_code == VK_HOME ||
+ p_code == VK_END ||
+ p_code == VK_PRIOR ||
+ p_code == VK_NEXT ||
+ p_code == VK_LEFT ||
+ p_code == VK_UP ||
+ p_code == VK_RIGHT ||
+ p_code == VK_DOWN;
+}
diff --git a/platform/windows/key_mapping_windows.h b/platform/windows/key_mapping_windows.h
index 3361ad397f..f64f1feb9f 100644
--- a/platform/windows/key_mapping_windows.h
+++ b/platform/windows/key_mapping_windows.h
@@ -38,12 +38,12 @@
#include <winuser.h>
class KeyMappingWindows {
-
- KeyMappingWindows(){};
+ KeyMappingWindows() {}
public:
static unsigned int get_keysym(unsigned int p_code);
static unsigned int get_scansym(unsigned int p_code, bool p_extended);
+ static bool is_extended_key(unsigned int p_code);
};
#endif // KEY_MAPPING_WINDOWS_H
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 39c86cd961..5b15896b0c 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -80,7 +80,6 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#ifdef DEBUG_ENABLED
static String format_error_message(DWORD id) {
-
LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr);
@@ -94,7 +93,6 @@ static String format_error_message(DWORD id) {
#endif // DEBUG_ENABLED
void RedirectIOToConsole() {
-
int hConHandle;
intptr_t lStdHandle;
@@ -175,12 +173,10 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) {
}
void OS_Windows::initialize_debugging() {
-
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
}
void OS_Windows::initialize() {
-
crash_handler.initialize();
//RedirectIOToConsole();
@@ -224,19 +220,16 @@ void OS_Windows::initialize() {
}
void OS_Windows::delete_main_loop() {
-
if (main_loop)
memdelete(main_loop);
main_loop = nullptr;
}
void OS_Windows::set_main_loop(MainLoop *p_main_loop) {
-
main_loop = p_main_loop;
}
void OS_Windows::finalize() {
-
#ifdef WINMIDI_ENABLED
driver_midi.close();
#endif
@@ -248,7 +241,6 @@ void OS_Windows::finalize() {
}
void OS_Windows::finalize_core() {
-
timeEndPeriod(1);
memdelete(process_map);
@@ -256,7 +248,6 @@ void OS_Windows::finalize_core() {
}
Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
-
String path = p_path;
if (!FileAccess::exists(path)) {
@@ -307,12 +298,10 @@ Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, cons
}
String OS_Windows::get_name() const {
-
return "Windows";
}
OS::Date OS_Windows::get_date(bool utc) const {
-
SYSTEMTIME systemtime;
if (utc)
GetSystemTime(&systemtime);
@@ -327,8 +316,8 @@ OS::Date OS_Windows::get_date(bool utc) const {
date.dst = false;
return date;
}
-OS::Time OS_Windows::get_time(bool utc) const {
+OS::Time OS_Windows::get_time(bool utc) const {
SYSTEMTIME systemtime;
if (utc)
GetSystemTime(&systemtime);
@@ -361,107 +350,89 @@ OS::TimeZoneInfo OS_Windows::get_time_zone_info() const {
return ret;
}
-uint64_t OS_Windows::get_unix_time() const {
-
- FILETIME ft;
- SYSTEMTIME st;
- GetSystemTime(&st);
- SystemTimeToFileTime(&st, &ft);
-
- SYSTEMTIME ep;
- ep.wYear = 1970;
- ep.wMonth = 1;
- ep.wDayOfWeek = 4;
- ep.wDay = 1;
- ep.wHour = 0;
- ep.wMinute = 0;
- ep.wSecond = 0;
- ep.wMilliseconds = 0;
- FILETIME fep;
- SystemTimeToFileTime(&ep, &fep);
-
- // Type punning through unions (rather than pointer cast) as per:
- // https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime#remarks
- ULARGE_INTEGER ft_punning;
- ft_punning.LowPart = ft.dwLowDateTime;
- ft_punning.HighPart = ft.dwHighDateTime;
-
- ULARGE_INTEGER fep_punning;
- fep_punning.LowPart = fep.dwLowDateTime;
- fep_punning.HighPart = fep.dwHighDateTime;
-
- return (ft_punning.QuadPart - fep_punning.QuadPart) / 10000000;
-};
-
-uint64_t OS_Windows::get_system_time_secs() const {
-
- return get_system_time_msecs() / 1000;
-}
-
-uint64_t OS_Windows::get_system_time_msecs() const {
-
- const uint64_t WINDOWS_TICK = 10000;
- const uint64_t MSEC_TO_UNIX_EPOCH = 11644473600000LL;
+double OS_Windows::get_unix_time() const {
+ // 1 Windows tick is 100ns
+ const uint64_t WINDOWS_TICKS_PER_SECOND = 10000000;
+ const uint64_t TICKS_TO_UNIX_EPOCH = 116444736000000000LL;
SYSTEMTIME st;
GetSystemTime(&st);
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
- uint64_t ret;
- ret = ft.dwHighDateTime;
- ret <<= 32;
- ret |= ft.dwLowDateTime;
+ uint64_t ticks_time;
+ ticks_time = ft.dwHighDateTime;
+ ticks_time <<= 32;
+ ticks_time |= ft.dwLowDateTime;
- return (uint64_t)(ret / WINDOWS_TICK - MSEC_TO_UNIX_EPOCH);
+ return (double)(ticks_time - TICKS_TO_UNIX_EPOCH) / WINDOWS_TICKS_PER_SECOND;
}
void OS_Windows::delay_usec(uint32_t p_usec) const {
-
if (p_usec < 1000)
Sleep(1);
else
Sleep(p_usec / 1000);
}
-uint64_t OS_Windows::get_ticks_usec() const {
+uint64_t OS_Windows::get_ticks_usec() const {
uint64_t ticks;
- uint64_t time;
+
// This is the number of clock ticks since start
if (!QueryPerformanceCounter((LARGE_INTEGER *)&ticks))
ticks = (UINT64)timeGetTime();
+
// Divide by frequency to get the time in seconds
- time = ticks * 1000000L / ticks_per_second;
+ // original calculation shown below is subject to overflow
+ // with high ticks_per_second and a number of days since the last reboot.
+ // time = ticks * 1000000L / ticks_per_second;
+
+ // we can prevent this by either using 128 bit math
+ // or separating into a calculation for seconds, and the fraction
+ uint64_t seconds = ticks / ticks_per_second;
+
+ // compiler will optimize these two into one divide
+ uint64_t leftover = ticks % ticks_per_second;
+
+ // remainder
+ uint64_t time = (leftover * 1000000L) / ticks_per_second;
+
+ // seconds
+ time += seconds * 1000000L;
+
// Subtract the time at game start to get
// the time since the game started
time -= ticks_start;
return time;
}
-Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
+String OS_Windows::_quote_command_line_argument(const String &p_text) const {
+ for (int i = 0; i < p_text.size(); i++) {
+ CharType c = p_text[i];
+ if (c == ' ' || c == '&' || c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}' || c == '^' || c == '=' || c == ';' || c == '!' || c == '\'' || c == '+' || c == ',' || c == '`' || c == '~') {
+ return "\"" + p_text + "\"";
+ }
+ }
+ return p_text;
+}
+Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) {
if (p_blocking && r_pipe) {
-
- String argss;
- argss = "\"\"" + p_path + "\"";
-
+ String argss = _quote_command_line_argument(p_path);
for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) {
-
- argss += " \"" + E->get() + "\"";
+ argss += " " + _quote_command_line_argument(E->get());
}
- argss += "\"";
-
if (read_stderr) {
argss += " 2>&1"; // Read stderr too
}
+ // Note: _wpopen is calling command as "cmd.exe /c argss", instead of executing it directly, add extra quotes around full command, to prevent it from stripping quotes in the command.
+ argss = _quote_command_line_argument(argss);
FILE *f = _wpopen(argss.c_str(), L"r");
-
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
char buf[65535];
while (fgets(buf, 65535, f)) {
-
if (p_pipe_mutex) {
p_pipe_mutex->lock();
}
@@ -472,20 +443,19 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
}
int rv = _pclose(f);
- if (r_exitcode)
+ if (r_exitcode) {
*r_exitcode = rv;
+ }
return OK;
}
- String cmdline = "\"" + p_path + "\"";
+ String cmdline = _quote_command_line_argument(p_path);
const List<String>::Element *I = p_arguments.front();
while (I) {
-
- cmdline += " \"" + I->get() + "\"";
-
+ cmdline += " " + _quote_command_line_argument(I->get());
I = I->next();
- };
+ }
ProcessInfo pi;
ZeroMemory(&pi.si, sizeof(pi.si));
@@ -493,34 +463,34 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
ZeroMemory(&pi.pi, sizeof(pi.pi));
LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si;
- Vector<CharType> modstr; //windows wants to change this no idea why
+ Vector<CharType> modstr; // Windows wants to change this no idea why.
modstr.resize(cmdline.size());
- for (int i = 0; i < cmdline.size(); i++)
+ for (int i = 0; i < cmdline.size(); i++) {
modstr.write[i] = cmdline[i];
+ }
+
int ret = CreateProcessW(nullptr, modstr.ptrw(), nullptr, nullptr, 0, NORMAL_PRIORITY_CLASS & CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi);
ERR_FAIL_COND_V(ret == 0, ERR_CANT_FORK);
if (p_blocking) {
-
DWORD ret2 = WaitForSingleObject(pi.pi.hProcess, INFINITE);
- if (r_exitcode)
+ if (r_exitcode) {
*r_exitcode = ret2;
+ }
CloseHandle(pi.pi.hProcess);
CloseHandle(pi.pi.hThread);
} else {
-
ProcessID pid = pi.pi.dwProcessId;
if (r_child_id) {
*r_child_id = pid;
- };
+ }
process_map->insert(pid, pi);
- };
+ }
return OK;
};
Error OS_Windows::kill(const ProcessID &p_pid) {
-
ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED);
const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi;
@@ -539,7 +509,6 @@ int OS_Windows::get_process_id() const {
}
Error OS_Windows::set_cwd(const String &p_cwd) {
-
if (_wchdir(p_cwd.c_str()) != 0)
return ERR_CANT_OPEN;
@@ -547,7 +516,6 @@ Error OS_Windows::set_cwd(const String &p_cwd) {
}
String OS_Windows::get_executable_path() const {
-
wchar_t bufname[4096];
GetModuleFileNameW(nullptr, bufname, 4096);
String s = bufname;
@@ -555,7 +523,6 @@ String OS_Windows::get_executable_path() const {
}
bool OS_Windows::has_environment(const String &p_var) const {
-
#ifdef MINGW_ENABLED
return _wgetenv(p_var.c_str()) != nullptr;
#else
@@ -569,7 +536,6 @@ bool OS_Windows::has_environment(const String &p_var) const {
};
String OS_Windows::get_environment(const String &p_var) const {
-
wchar_t wval[0x7Fff]; // MSDN says 32767 char is the maximum
int wlen = GetEnvironmentVariableW(p_var.c_str(), wval, 0x7Fff);
if (wlen > 0) {
@@ -579,12 +545,10 @@ String OS_Windows::get_environment(const String &p_var) const {
}
bool OS_Windows::set_environment(const String &p_var, const String &p_value) const {
-
return (bool)SetEnvironmentVariableW(p_var.c_str(), p_value.c_str());
}
String OS_Windows::get_stdin_string(bool p_block) {
-
if (p_block) {
char buff[1024];
return fgets(buff, 1024, stdin);
@@ -594,13 +558,11 @@ String OS_Windows::get_stdin_string(bool p_block) {
}
Error OS_Windows::shell_open(String p_uri) {
-
ShellExecuteW(nullptr, nullptr, p_uri.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
return OK;
}
String OS_Windows::get_locale() const {
-
const _WinLocale *wl = &_win_locales[0];
LANGID langid = GetUserDefaultUILanguage();
@@ -609,7 +571,6 @@ String OS_Windows::get_locale() const {
int sublang = langid & ~((1 << 9) - 1);
while (wl->locale) {
-
if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL)
neutral = wl->locale;
@@ -656,14 +617,12 @@ int OS_Windows::get_processor_count() const {
}
void OS_Windows::run() {
-
if (!main_loop)
return;
main_loop->init();
while (!force_quit) {
-
DisplayServer::get_singleton()->process_events(); // get rid of pending events
if (Main::iteration())
break;
@@ -673,12 +632,10 @@ void OS_Windows::run() {
}
MainLoop *OS_Windows::get_main_loop() const {
-
return main_loop;
}
String OS_Windows::get_config_path() const {
-
if (has_environment("XDG_CONFIG_HOME")) { // unlikely, but after all why not?
return get_environment("XDG_CONFIG_HOME");
} else if (has_environment("APPDATA")) {
@@ -689,7 +646,6 @@ String OS_Windows::get_config_path() const {
}
String OS_Windows::get_data_path() const {
-
if (has_environment("XDG_DATA_HOME")) {
return get_environment("XDG_DATA_HOME");
} else {
@@ -698,7 +654,6 @@ String OS_Windows::get_data_path() const {
}
String OS_Windows::get_cache_path() const {
-
if (has_environment("XDG_CACHE_HOME")) {
return get_environment("XDG_CACHE_HOME");
} else if (has_environment("TEMP")) {
@@ -710,12 +665,10 @@ String OS_Windows::get_cache_path() const {
// Get properly capitalized engine name for system paths
String OS_Windows::get_godot_dir_name() const {
-
return String(VERSION_SHORT_NAME).capitalize();
}
String OS_Windows::get_system_dir(SystemDir p_dir) const {
-
KNOWNFOLDERID id;
switch (p_dir) {
@@ -754,7 +707,6 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const {
}
String OS_Windows::get_user_data_dir() const {
-
String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
if (appname != "") {
bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir");
@@ -773,14 +725,12 @@ String OS_Windows::get_user_data_dir() const {
}
String OS_Windows::get_unique_id() const {
-
HW_PROFILE_INFO HwProfInfo;
ERR_FAIL_COND_V(!GetCurrentHwProfile(&HwProfInfo), "");
return String(HwProfInfo.szHwProfileGuid);
}
bool OS_Windows::_check_internal_feature_support(const String &p_feature) {
-
return p_feature == "pc";
}
@@ -818,7 +768,71 @@ Error OS_Windows::move_to_trash(const String &p_path) {
return OK;
}
+int OS_Windows::get_tablet_driver_count() const {
+ return tablet_drivers.size();
+}
+
+String OS_Windows::get_tablet_driver_name(int p_driver) const {
+ if (p_driver < 0 || p_driver >= tablet_drivers.size()) {
+ return "";
+ } else {
+ return tablet_drivers[p_driver];
+ }
+}
+
+String OS_Windows::get_current_tablet_driver() const {
+ return tablet_driver;
+}
+
+void OS_Windows::set_current_tablet_driver(const String &p_driver) {
+ if (get_tablet_driver_count() == 0) {
+ return;
+ }
+ bool found = false;
+ for (int i = 0; i < get_tablet_driver_count(); i++) {
+ if (p_driver == get_tablet_driver_name(i)) {
+ found = true;
+ }
+ }
+ if (found) {
+ if (DisplayServerWindows::get_singleton()) {
+ ((DisplayServerWindows *)DisplayServerWindows::get_singleton())->_update_tablet_ctx(tablet_driver, p_driver);
+ }
+ tablet_driver = p_driver;
+ } else {
+ ERR_PRINT("Unknown tablet driver " + p_driver + ".");
+ }
+}
+
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
+ //Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
+ HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
+ if (wintab_lib) {
+ DisplayServerWindows::wintab_WTOpen = (WTOpenPtr)GetProcAddress(wintab_lib, "WTOpenW");
+ DisplayServerWindows::wintab_WTClose = (WTClosePtr)GetProcAddress(wintab_lib, "WTClose");
+ DisplayServerWindows::wintab_WTInfo = (WTInfoPtr)GetProcAddress(wintab_lib, "WTInfoW");
+ DisplayServerWindows::wintab_WTPacket = (WTPacketPtr)GetProcAddress(wintab_lib, "WTPacket");
+ DisplayServerWindows::wintab_WTEnable = (WTEnablePtr)GetProcAddress(wintab_lib, "WTEnable");
+
+ DisplayServerWindows::wintab_available = DisplayServerWindows::wintab_WTOpen && DisplayServerWindows::wintab_WTClose && DisplayServerWindows::wintab_WTInfo && DisplayServerWindows::wintab_WTPacket && DisplayServerWindows::wintab_WTEnable;
+ }
+
+ if (DisplayServerWindows::wintab_available) {
+ tablet_drivers.push_back("wintab");
+ }
+
+ //Note: Windows Ink API for pen input, available on Windows 8+ only.
+ HMODULE user32_lib = LoadLibraryW(L"user32.dll");
+ if (user32_lib) {
+ DisplayServerWindows::win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
+ DisplayServerWindows::win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
+
+ DisplayServerWindows::winink_available = DisplayServerWindows::win8p_GetPointerType && DisplayServerWindows::win8p_GetPointerPenInfo;
+ }
+
+ if (DisplayServerWindows::winink_available) {
+ tablet_drivers.push_back("winink");
+ }
force_quit = false;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 7226109e57..910a83539a 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -63,7 +63,6 @@
class JoypadWindows;
class OS_Windows : public OS {
-
#ifdef STDOUT_FILE
FILE *stdo;
#endif
@@ -74,6 +73,9 @@ class OS_Windows : public OS {
HINSTANCE hInstance;
MainLoop *main_loop;
+ String tablet_driver;
+ Vector<String> tablet_drivers;
+
#ifdef WASAPI_ENABLED
AudioDriverWASAPI driver_wasapi;
#endif
@@ -100,8 +102,9 @@ protected:
virtual void finalize_core();
virtual String get_stdin_string(bool p_block);
- struct ProcessInfo {
+ String _quote_command_line_argument(const String &p_text) const;
+ struct ProcessInfo {
STARTUPINFO si;
PROCESS_INFORMATION pi;
};
@@ -116,14 +119,17 @@ public:
virtual String get_name() const;
+ virtual int get_tablet_driver_count() const;
+ virtual String get_tablet_driver_name(int p_driver) const;
+ virtual String get_current_tablet_driver() const;
+ virtual void set_current_tablet_driver(const String &p_driver);
+
virtual void initialize_joypads() {}
virtual Date get_date(bool utc) const;
virtual Time get_time(bool utc) const;
virtual TimeZoneInfo get_time_zone_info() const;
- virtual uint64_t get_unix_time() const;
- virtual uint64_t get_system_time_secs() const;
- virtual uint64_t get_system_time_msecs() const;
+ virtual double get_unix_time() const;
virtual Error set_cwd(const String &p_cwd);
diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp
index 98aa21411f..2c63281c49 100644
--- a/platform/windows/vulkan_context_win.cpp
+++ b/platform/windows/vulkan_context_win.cpp
@@ -36,7 +36,6 @@ const char *VulkanContextWindows::_get_platform_surface_extension() const {
}
int VulkanContextWindows::window_create(DisplayServer::WindowID p_window_id, HWND p_window, HINSTANCE p_instance, int p_width, int p_height) {
-
VkWin32SurfaceCreateInfoKHR createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
createInfo.pNext = nullptr;
diff --git a/platform/windows/vulkan_context_win.h b/platform/windows/vulkan_context_win.h
index c9fea9369b..6e80db0286 100644
--- a/platform/windows/vulkan_context_win.h
+++ b/platform/windows/vulkan_context_win.h
@@ -35,7 +35,6 @@
#include <windows.h>
class VulkanContextWindows : public VulkanContext {
-
virtual const char *_get_platform_surface_extension() const;
public:
diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp
index 3fb2adfd2c..0938b65b04 100644
--- a/platform/windows/windows_terminal_logger.cpp
+++ b/platform/windows/windows_terminal_logger.cpp
@@ -81,7 +81,6 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
StdLogger::log_error(p_function, p_file, p_line, p_code, p_rationale, p_type);
#ifndef UWP_ENABLED
} else {
-
CONSOLE_SCREEN_BUFFER_INFO sbi; //original
GetConsoleScreenBufferInfo(hCon, &sbi);
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp
index fc34f967ce..3268544519 100644
--- a/scene/2d/animated_sprite_2d.cpp
+++ b/scene/2d/animated_sprite_2d.cpp
@@ -70,8 +70,9 @@ bool AnimatedSprite2D::_edit_use_rect() const {
return false;
}
Ref<Texture2D> t;
- if (animation)
+ if (animation) {
t = frames->get_frame(animation, frame);
+ }
return t.is_valid();
}
#endif
@@ -86,31 +87,35 @@ Rect2 AnimatedSprite2D::_get_rect() const {
}
Ref<Texture2D> t;
- if (animation)
+ if (animation) {
t = frames->get_frame(animation, frame);
- if (t.is_null())
+ }
+ if (t.is_null()) {
return Rect2();
+ }
Size2 s = t->get_size();
Point2 ofs = offset;
- if (centered)
+ if (centered) {
ofs -= Size2(s) / 2;
+ }
- if (s == Size2(0, 0))
+ if (s == Size2(0, 0)) {
s = Size2(1, 1);
+ }
return Rect2(ofs, s);
}
void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture2D> &p_frame, int p_at_pos) {
-
Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
- if (p_at_pos >= 0 && p_at_pos < E->get().frames.size())
+ if (p_at_pos >= 0 && p_at_pos < E->get().frames.size()) {
E->get().frames.insert(p_at_pos, p_frame);
- else
+ } else {
E->get().frames.push_back(p_frame);
+ }
emit_changed();
}
@@ -123,15 +128,14 @@ int SpriteFrames::get_frame_count(const StringName &p_anim) const {
}
void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) {
-
Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().frames.remove(p_idx);
emit_changed();
}
-void SpriteFrames::clear(const StringName &p_anim) {
+void SpriteFrames::clear(const StringName &p_anim) {
Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
@@ -140,13 +144,11 @@ void SpriteFrames::clear(const StringName &p_anim) {
}
void SpriteFrames::clear_all() {
-
animations.clear();
add_animation("default");
}
void SpriteFrames::add_animation(const StringName &p_anim) {
-
ERR_FAIL_COND_MSG(animations.has(p_anim), "SpriteFrames already has animation '" + p_anim + "'.");
animations[p_anim] = Anim();
@@ -155,16 +157,14 @@ void SpriteFrames::add_animation(const StringName &p_anim) {
}
bool SpriteFrames::has_animation(const StringName &p_anim) const {
-
return animations.has(p_anim);
}
-void SpriteFrames::remove_animation(const StringName &p_anim) {
+void SpriteFrames::remove_animation(const StringName &p_anim) {
animations.erase(p_anim);
}
void SpriteFrames::rename_animation(const StringName &p_prev, const StringName &p_next) {
-
ERR_FAIL_COND_MSG(!animations.has(p_prev), "SpriteFrames doesn't have animation '" + String(p_prev) + "'.");
ERR_FAIL_COND_MSG(animations.has(p_next), "Animation '" + String(p_next) + "' already exists.");
@@ -176,12 +176,10 @@ void SpriteFrames::rename_animation(const StringName &p_prev, const StringName &
}
Vector<String> SpriteFrames::_get_animation_list() const {
-
Vector<String> ret;
List<StringName> al;
get_animation_list(&al);
for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
@@ -189,14 +187,12 @@ Vector<String> SpriteFrames::_get_animation_list() const {
}
void SpriteFrames::get_animation_list(List<StringName> *r_animations) const {
-
for (const Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) {
r_animations->push_back(E->key());
}
}
Vector<String> SpriteFrames::get_animation_names() const {
-
Vector<String> names;
for (const Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) {
names.push_back(E->key());
@@ -206,14 +202,13 @@ Vector<String> SpriteFrames::get_animation_names() const {
}
void SpriteFrames::set_animation_speed(const StringName &p_anim, float p_fps) {
-
ERR_FAIL_COND_MSG(p_fps < 0, "Animation speed cannot be negative (" + itos(p_fps) + ").");
Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().speed = p_fps;
}
-float SpriteFrames::get_animation_speed(const StringName &p_anim) const {
+float SpriteFrames::get_animation_speed(const StringName &p_anim) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V_MSG(!E, 0, "Animation '" + String(p_anim) + "' doesn't exist.");
return E->get().speed;
@@ -224,6 +219,7 @@ void SpriteFrames::set_animation_loop(const StringName &p_anim, bool p_loop) {
ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
E->get().loop = p_loop;
}
+
bool SpriteFrames::get_animation_loop(const StringName &p_anim) const {
const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V_MSG(!E, false, "Animation '" + String(p_anim) + "' doesn't exist.");
@@ -231,22 +227,21 @@ bool SpriteFrames::get_animation_loop(const StringName &p_anim) const {
}
void SpriteFrames::_set_frames(const Array &p_frames) {
-
clear_all();
Map<StringName, Anim>::Element *E = animations.find(SceneStringNames::get_singleton()->_default);
ERR_FAIL_COND(!E);
E->get().frames.resize(p_frames.size());
- for (int i = 0; i < E->get().frames.size(); i++)
+ for (int i = 0; i < E->get().frames.size(); i++) {
E->get().frames.write[i] = p_frames[i];
+ }
}
-Array SpriteFrames::_get_frames() const {
+Array SpriteFrames::_get_frames() const {
return Array();
}
Array SpriteFrames::_get_animations() const {
-
Array anims;
for (Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) {
Dictionary d;
@@ -263,11 +258,10 @@ Array SpriteFrames::_get_animations() const {
return anims;
}
-void SpriteFrames::_set_animations(const Array &p_animations) {
+void SpriteFrames::_set_animations(const Array &p_animations) {
animations.clear();
for (int i = 0; i < p_animations.size(); i++) {
-
Dictionary d = p_animations[i];
ERR_CONTINUE(!d.has("name"));
@@ -280,7 +274,6 @@ void SpriteFrames::_set_animations(const Array &p_animations) {
anim.loop = d["loop"];
Array frames = d["frames"];
for (int j = 0; j < frames.size(); j++) {
-
RES res = frames[j];
anim.frames.push_back(res);
}
@@ -290,7 +283,6 @@ void SpriteFrames::_set_animations(const Array &p_animations) {
}
void SpriteFrames::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_animation", "anim"), &SpriteFrames::add_animation);
ClassDB::bind_method(D_METHOD("has_animation", "anim"), &SpriteFrames::has_animation);
ClassDB::bind_method(D_METHOD("remove_animation", "anim"), &SpriteFrames::remove_animation);
@@ -324,16 +316,14 @@ void SpriteFrames::_bind_methods() {
}
SpriteFrames::SpriteFrames() {
-
add_animation(SceneStringNames::get_singleton()->_default);
}
void AnimatedSprite2D::_validate_property(PropertyInfo &property) const {
-
- if (!frames.is_valid())
+ if (!frames.is_valid()) {
return;
+ }
if (property.name == "animation") {
-
property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
frames->get_animation_list(&names);
@@ -371,43 +361,45 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &property) const {
}
void AnimatedSprite2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_INTERNAL_PROCESS: {
-
- if (frames.is_null())
+ if (frames.is_null()) {
return;
- if (!frames->has_animation(animation))
+ }
+ if (!frames->has_animation(animation)) {
return;
- if (frame < 0)
+ }
+ if (frame < 0) {
return;
+ }
float speed = frames->get_animation_speed(animation) * speed_scale;
- if (speed == 0)
+ if (speed == 0) {
return; //do nothing
+ }
float remaining = get_process_delta_time();
while (remaining) {
-
if (timeout <= 0) {
-
timeout = _get_frame_duration();
int fc = frames->get_frame_count(animation);
if ((!backwards && frame >= fc - 1) || (backwards && frame <= 0)) {
if (frames->get_animation_loop(animation)) {
- if (backwards)
+ if (backwards) {
frame = fc - 1;
- else
+ } else {
frame = 0;
+ }
emit_signal(SceneStringNames::get_singleton()->animation_finished);
} else {
- if (backwards)
+ if (backwards) {
frame = 0;
- else
+ } else {
frame = fc - 1;
+ }
if (!is_over) {
is_over = true;
@@ -415,10 +407,11 @@ void AnimatedSprite2D::_notification(int p_what) {
}
}
} else {
- if (backwards)
+ if (backwards) {
frame--;
- else
+ } else {
frame++;
+ }
}
update();
@@ -433,17 +426,20 @@ void AnimatedSprite2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
-
- if (frames.is_null())
+ if (frames.is_null()) {
return;
- if (frame < 0)
+ }
+ if (frame < 0) {
return;
- if (!frames->has_animation(animation))
+ }
+ if (!frames->has_animation(animation)) {
return;
+ }
Ref<Texture2D> texture = frames->get_frame(animation, frame);
- if (texture.is_null())
+ if (texture.is_null()) {
return;
+ }
Ref<Texture2D> normal = frames->get_normal_frame(animation, frame);
Ref<Texture2D> specular = frames->get_specular_frame(animation, frame);
@@ -453,18 +449,21 @@ void AnimatedSprite2D::_notification(int p_what) {
Size2i s;
s = texture->get_size();
Point2 ofs = offset;
- if (centered)
+ if (centered) {
ofs -= s / 2;
+ }
if (Engine::get_singleton()->get_use_pixel_snap()) {
ofs = ofs.floor();
}
Rect2 dst_rect(ofs, s);
- if (hflip)
+ if (hflip) {
dst_rect.size.x = -dst_rect.size.x;
- if (vflip)
+ }
+ if (vflip) {
dst_rect.size.y = -dst_rect.size.y;
+ }
texture->draw_rect_region(ci, dst_rect, Rect2(Vector2(), texture->get_size()), Color(1, 1, 1), false, normal, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess));
@@ -473,12 +472,13 @@ void AnimatedSprite2D::_notification(int p_what) {
}
void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
-
- if (frames.is_valid())
+ if (frames.is_valid()) {
frames->disconnect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed));
+ }
frames = p_frames;
- if (frames.is_valid())
+ if (frames.is_valid()) {
frames->connect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed));
+ }
if (!frames.is_valid()) {
frame = 0;
@@ -493,27 +493,28 @@ void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
}
Ref<SpriteFrames> AnimatedSprite2D::get_sprite_frames() const {
-
return frames;
}
void AnimatedSprite2D::set_frame(int p_frame) {
-
if (!frames.is_valid()) {
return;
}
if (frames->has_animation(animation)) {
int limit = frames->get_frame_count(animation);
- if (p_frame >= limit)
+ if (p_frame >= limit) {
p_frame = limit - 1;
+ }
}
- if (p_frame < 0)
+ if (p_frame < 0) {
p_frame = 0;
+ }
- if (frame == p_frame)
+ if (frame == p_frame) {
return;
+ }
frame = p_frame;
_reset_timeout();
@@ -521,13 +522,12 @@ void AnimatedSprite2D::set_frame(int p_frame) {
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
-int AnimatedSprite2D::get_frame() const {
+int AnimatedSprite2D::get_frame() const {
return frame;
}
void AnimatedSprite2D::set_speed_scale(float p_speed_scale) {
-
float elapsed = _get_frame_duration() - timeout;
speed_scale = MAX(p_speed_scale, 0.0f);
@@ -538,56 +538,49 @@ void AnimatedSprite2D::set_speed_scale(float p_speed_scale) {
}
float AnimatedSprite2D::get_speed_scale() const {
-
return speed_scale;
}
void AnimatedSprite2D::set_centered(bool p_center) {
-
centered = p_center;
update();
item_rect_changed();
}
bool AnimatedSprite2D::is_centered() const {
-
return centered;
}
void AnimatedSprite2D::set_offset(const Point2 &p_offset) {
-
offset = p_offset;
update();
item_rect_changed();
_change_notify("offset");
}
-Point2 AnimatedSprite2D::get_offset() const {
+Point2 AnimatedSprite2D::get_offset() const {
return offset;
}
void AnimatedSprite2D::set_flip_h(bool p_flip) {
-
hflip = p_flip;
update();
}
-bool AnimatedSprite2D::is_flipped_h() const {
+bool AnimatedSprite2D::is_flipped_h() const {
return hflip;
}
void AnimatedSprite2D::set_flip_v(bool p_flip) {
-
vflip = p_flip;
update();
}
-bool AnimatedSprite2D::is_flipped_v() const {
+bool AnimatedSprite2D::is_flipped_v() const {
return vflip;
}
void AnimatedSprite2D::_res_changed() {
-
set_frame(frame);
_change_notify("frame");
_change_notify("animation");
@@ -595,39 +588,36 @@ void AnimatedSprite2D::_res_changed() {
}
void AnimatedSprite2D::_set_playing(bool p_playing) {
-
- if (playing == p_playing)
+ if (playing == p_playing) {
return;
+ }
playing = p_playing;
_reset_timeout();
set_process_internal(playing);
}
bool AnimatedSprite2D::_is_playing() const {
-
return playing;
}
void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backwards) {
-
backwards = p_backwards;
if (p_animation) {
set_animation(p_animation);
- if (backwards && get_frame() == 0)
+ if (backwards && get_frame() == 0) {
set_frame(frames->get_frame_count(p_animation) - 1);
+ }
}
_set_playing(true);
}
void AnimatedSprite2D::stop() {
-
_set_playing(false);
}
bool AnimatedSprite2D::is_playing() const {
-
return playing;
}
@@ -642,21 +632,21 @@ float AnimatedSprite2D::_get_frame_duration() {
}
void AnimatedSprite2D::_reset_timeout() {
-
- if (!playing)
+ if (!playing) {
return;
+ }
timeout = _get_frame_duration();
is_over = false;
}
void AnimatedSprite2D::set_animation(const StringName &p_animation) {
-
ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", p_animation));
ERR_FAIL_COND_MSG(frames->get_animation_names().find(p_animation) == -1, vformat("There is no animation with name '%s'.", p_animation));
- if (animation == p_animation)
+ if (animation == p_animation) {
return;
+ }
animation = p_animation;
_reset_timeout();
@@ -664,13 +654,12 @@ void AnimatedSprite2D::set_animation(const StringName &p_animation) {
_change_notify();
update();
}
-StringName AnimatedSprite2D::get_animation() const {
+StringName AnimatedSprite2D::get_animation() const {
return animation;
}
String AnimatedSprite2D::get_configuration_warning() const {
-
if (frames.is_null()) {
return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite to display frames.");
}
@@ -697,7 +686,6 @@ float AnimatedSprite2D::get_shininess() const {
}
void AnimatedSprite2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite2D::set_sprite_frames);
ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite2D::get_sprite_frames);
@@ -755,7 +743,6 @@ void AnimatedSprite2D::_bind_methods() {
}
AnimatedSprite2D::AnimatedSprite2D() {
-
centered = true;
hflip = false;
vflip = false;
diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h
index 726ecefd32..5e8344ec4c 100644
--- a/scene/2d/animated_sprite_2d.h
+++ b/scene/2d/animated_sprite_2d.h
@@ -35,11 +35,9 @@
#include "scene/resources/texture.h"
class SpriteFrames : public Resource {
-
GDCLASS(SpriteFrames, Resource);
struct Anim {
-
float speed;
bool loop;
Vector<Ref<Texture2D>> frames;
@@ -87,40 +85,40 @@ public:
void add_frame(const StringName &p_anim, const Ref<Texture2D> &p_frame, int p_at_pos = -1);
int get_frame_count(const StringName &p_anim) const;
_FORCE_INLINE_ Ref<Texture2D> get_frame(const StringName &p_anim, int p_idx) const {
-
const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>());
- if (p_idx >= E->get().frames.size())
+ if (p_idx >= E->get().frames.size()) {
return Ref<Texture2D>();
+ }
return E->get().frames[p_idx];
}
_FORCE_INLINE_ Ref<Texture2D> get_normal_frame(const StringName &p_anim, int p_idx) const {
-
const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>());
const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name);
- if (!EN || p_idx >= EN->get().frames.size())
+ if (!EN || p_idx >= EN->get().frames.size()) {
return Ref<Texture2D>();
+ }
return EN->get().frames[p_idx];
}
_FORCE_INLINE_ Ref<Texture2D> get_specular_frame(const StringName &p_anim, int p_idx) const {
-
const Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_V(!E, Ref<Texture2D>());
ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>());
const Map<StringName, Anim>::Element *EN = animations.find(E->get().specular_name);
- if (!EN || p_idx >= EN->get().frames.size())
+ if (!EN || p_idx >= EN->get().frames.size()) {
return Ref<Texture2D>();
+ }
return EN->get().frames[p_idx];
}
@@ -129,8 +127,9 @@ public:
Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND(p_idx < 0);
- if (p_idx >= E->get().frames.size())
+ if (p_idx >= E->get().frames.size()) {
return;
+ }
E->get().frames.write[p_idx] = p_frame;
}
void remove_frame(const StringName &p_anim, int p_idx);
@@ -141,7 +140,6 @@ public:
};
class AnimatedSprite2D : public Node2D {
-
GDCLASS(AnimatedSprite2D, Node2D);
Ref<SpriteFrames> frames;
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 8ba334bc67..ebfcb9cad6 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -35,27 +35,24 @@
#include "servers/physics_server_2d.h"
void Area2D::set_space_override_mode(SpaceOverride p_mode) {
-
space_override = p_mode;
PhysicsServer2D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer2D::AreaSpaceOverrideMode(p_mode));
}
-Area2D::SpaceOverride Area2D::get_space_override_mode() const {
+Area2D::SpaceOverride Area2D::get_space_override_mode() const {
return space_override;
}
void Area2D::set_gravity_is_point(bool p_enabled) {
-
gravity_is_point = p_enabled;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
-bool Area2D::is_gravity_a_point() const {
+bool Area2D::is_gravity_a_point() const {
return gravity_is_point;
}
void Area2D::set_gravity_distance_scale(real_t p_scale) {
-
gravity_distance_scale = p_scale;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
}
@@ -65,58 +62,51 @@ real_t Area2D::get_gravity_distance_scale() const {
}
void Area2D::set_gravity_vector(const Vector2 &p_vec) {
-
gravity_vec = p_vec;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_vec);
}
-Vector2 Area2D::get_gravity_vector() const {
+Vector2 Area2D::get_gravity_vector() const {
return gravity_vec;
}
void Area2D::set_gravity(real_t p_gravity) {
-
gravity = p_gravity;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY, p_gravity);
}
-real_t Area2D::get_gravity() const {
+real_t Area2D::get_gravity() const {
return gravity;
}
void Area2D::set_linear_damp(real_t p_linear_damp) {
-
linear_damp = p_linear_damp;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
-real_t Area2D::get_linear_damp() const {
+real_t Area2D::get_linear_damp() const {
return linear_damp;
}
void Area2D::set_angular_damp(real_t p_angular_damp) {
-
angular_damp = p_angular_damp;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
real_t Area2D::get_angular_damp() const {
-
return angular_damp;
}
void Area2D::set_priority(real_t p_priority) {
-
priority = p_priority;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_PRIORITY, p_priority);
}
-real_t Area2D::get_priority() const {
+real_t Area2D::get_priority() const {
return priority;
}
void Area2D::_body_enter_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -128,13 +118,11 @@ void Area2D::_body_enter_tree(ObjectID p_id) {
E->get().in_tree = true;
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
}
void Area2D::_body_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -144,13 +132,11 @@ void Area2D::_body_exit_tree(ObjectID p_id) {
E->get().in_tree = false;
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
}
void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
-
bool body_in = p_status == PhysicsServer2D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
@@ -167,7 +153,6 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
if (body_in) {
if (!E) {
-
E = body_map.insert(objid, BodyState());
E->get().rc = 0;
E->get().in_tree = node && node->is_inside_tree();
@@ -180,29 +165,30 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
}
}
E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape));
+ }
if (!node || E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape);
}
} else {
-
E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape));
+ }
bool eraseit = false;
if (E->get().rc == 0) {
-
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_body_exit_tree));
- if (E->get().in_tree)
+ if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
+ }
}
eraseit = true;
@@ -211,15 +197,15 @@ void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape);
}
- if (eraseit)
+ if (eraseit) {
body_map.erase(E);
+ }
}
locked = false;
}
void Area2D::_area_enter_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -231,13 +217,11 @@ void Area2D::_area_enter_tree(ObjectID p_id) {
E->get().in_tree = true;
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
}
void Area2D::_area_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -247,13 +231,11 @@ void Area2D::_area_exit_tree(ObjectID p_id) {
E->get().in_tree = false;
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
}
void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
-
bool area_in = p_status == PhysicsServer2D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
@@ -269,7 +251,6 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
if (area_in) {
if (!E) {
-
E = area_map.insert(objid, AreaState());
E->get().rc = 0;
E->get().in_tree = node && node->is_inside_tree();
@@ -282,29 +263,30 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
}
}
E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape));
+ }
if (!node || E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape);
}
} else {
-
E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape));
+ }
bool eraseit = false;
if (E->get().rc == 0) {
-
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_area_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_area_exit_tree));
- if (E->get().in_tree)
+ if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
+ }
}
eraseit = true;
@@ -313,15 +295,15 @@ void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape);
}
- if (eraseit)
+ if (eraseit) {
area_map.erase(E);
+ }
}
locked = false;
}
void Area2D::_clear_monitoring() {
-
ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal.");
{
@@ -330,21 +312,21 @@ void Area2D::_clear_monitoring() {
//disconnect all monitored stuff
for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
- if (!node) //node may have been deleted in previous frame or at other legitimate point
+ if (!node) { //node may have been deleted in previous frame or at other legitimate point
continue;
+ }
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_body_exit_tree));
- if (!E->get().in_tree)
+ if (!E->get().in_tree) {
continue;
+ }
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
@@ -353,27 +335,26 @@ void Area2D::_clear_monitoring() {
}
{
-
Map<ObjectID, AreaState> bmcopy = area_map;
area_map.clear();
//disconnect all monitored stuff
for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
- if (!node) //node may have been deleted in previous frame or at other legitimate point
+ if (!node) { //node may have been deleted in previous frame or at other legitimate point
continue;
+ }
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area2D::_area_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area2D::_area_exit_tree));
- if (!E->get().in_tree)
+ if (!E->get().in_tree) {
continue;
+ }
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
@@ -383,26 +364,22 @@ void Area2D::_clear_monitoring() {
}
void Area2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_EXIT_TREE: {
-
_clear_monitoring();
} break;
}
}
void Area2D::set_monitoring(bool p_enable) {
-
- if (p_enable == monitoring)
+ if (p_enable == monitoring) {
return;
+ }
ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false).");
monitoring = p_enable;
if (monitoring) {
-
PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
@@ -414,16 +391,15 @@ void Area2D::set_monitoring(bool p_enable) {
}
bool Area2D::is_monitoring() const {
-
return monitoring;
}
void Area2D::set_monitorable(bool p_enable) {
-
ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer2D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
- if (p_enable == monitorable)
+ if (p_enable == monitorable) {
return;
+ }
monitorable = p_enable;
@@ -431,12 +407,10 @@ void Area2D::set_monitorable(bool p_enable) {
}
bool Area2D::is_monitorable() const {
-
return monitorable;
}
TypedArray<Node2D> Area2D::get_overlapping_bodies() const {
-
ERR_FAIL_COND_V_MSG(!monitoring, Array(), "Can't find overlapping bodies when monitoring is off.");
TypedArray<Node2D> ret;
ret.resize(body_map.size());
@@ -454,7 +428,6 @@ TypedArray<Node2D> Area2D::get_overlapping_bodies() const {
}
TypedArray<Area2D> Area2D::get_overlapping_areas() const {
-
ERR_FAIL_COND_V_MSG(!monitoring, Array(), "Can't find overlapping bodies when monitoring is off.");
TypedArray<Area2D> ret;
ret.resize(area_map.size());
@@ -472,92 +445,82 @@ TypedArray<Area2D> Area2D::get_overlapping_areas() const {
}
bool Area2D::overlaps_area(Node *p_area) const {
-
ERR_FAIL_NULL_V(p_area, false);
const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().in_tree;
}
bool Area2D::overlaps_body(Node *p_body) const {
-
ERR_FAIL_NULL_V(p_body, false);
const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().in_tree;
}
void Area2D::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
PhysicsServer2D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
}
uint32_t Area2D::get_collision_mask() const {
-
return collision_mask;
}
void Area2D::set_collision_layer(uint32_t p_layer) {
-
collision_layer = p_layer;
PhysicsServer2D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
}
uint32_t Area2D::get_collision_layer() const {
-
return collision_layer;
}
void Area2D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool Area2D::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
void Area2D::set_collision_layer_bit(int p_bit, bool p_value) {
-
uint32_t layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
layer |= 1 << p_bit;
- else
+ } else {
layer &= ~(1 << p_bit);
+ }
set_collision_layer(layer);
}
bool Area2D::get_collision_layer_bit(int p_bit) const {
-
return get_collision_layer() & (1 << p_bit);
}
void Area2D::set_audio_bus_override(bool p_override) {
-
audio_bus_override = p_override;
}
bool Area2D::is_overriding_audio_bus() const {
-
return audio_bus_override;
}
void Area2D::set_audio_bus_name(const StringName &p_audio_bus) {
-
audio_bus = p_audio_bus;
}
StringName Area2D::get_audio_bus_name() const {
-
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) {
return audio_bus;
@@ -567,13 +530,12 @@ StringName Area2D::get_audio_bus_name() const {
}
void Area2D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "audio_bus_name") {
-
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -677,7 +639,6 @@ void Area2D::_bind_methods() {
Area2D::Area2D() :
CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) {
-
space_override = SPACE_OVERRIDE_DISABLED;
set_gravity(98);
set_gravity_vector(Vector2(0, 1));
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index 0e2c0ac672..0d0293dd12 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -35,7 +35,6 @@
#include "scene/2d/collision_object_2d.h"
class Area2D : public CollisionObject2D {
-
GDCLASS(Area2D, CollisionObject2D);
public:
@@ -68,14 +67,14 @@ private:
void _body_exit_tree(ObjectID p_id);
struct ShapePair {
-
int body_shape;
int area_shape;
bool operator<(const ShapePair &p_sp) const {
- if (body_shape == p_sp.body_shape)
+ if (body_shape == p_sp.body_shape) {
return area_shape < p_sp.area_shape;
- else
+ } else {
return body_shape < p_sp.body_shape;
+ }
}
ShapePair() {}
@@ -86,7 +85,6 @@ private:
};
struct BodyState {
-
int rc;
bool in_tree;
VSet<ShapePair> shapes;
@@ -100,14 +98,14 @@ private:
void _area_exit_tree(ObjectID p_id);
struct AreaShapePair {
-
int area_shape;
int self_shape;
bool operator<(const AreaShapePair &p_sp) const {
- if (area_shape == p_sp.area_shape)
+ if (area_shape == p_sp.area_shape) {
return self_shape < p_sp.self_shape;
- else
+ } else {
return area_shape < p_sp.area_shape;
+ }
}
AreaShapePair() {}
@@ -118,7 +116,6 @@ private:
};
struct AreaState {
-
int rc;
bool in_tree;
VSet<AreaShapePair> shapes;
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 55d111439a..5b89ac15b1 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -35,7 +35,6 @@
#include "scene/main/window.h"
void AudioStreamPlayer2D::_mix_audio() {
-
if (!stream_playback.is_valid() || !active ||
(stream_paused && !stream_paused_fade_out)) {
return;
@@ -59,7 +58,6 @@ void AudioStreamPlayer2D::_mix_audio() {
//write all outputs
for (int i = 0; i < output_count; i++) {
-
Output current = outputs[i];
//see if current output exists, to keep volume ramp
@@ -92,13 +90,13 @@ void AudioStreamPlayer2D::_mix_audio() {
int cc = AudioServer::get_singleton()->get_channel_count();
if (cc == 1) {
- if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, 0))
+ if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, 0)) {
continue; //may have been removed
+ }
AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 0);
for (int j = 0; j < buffer_size; j++) {
-
target[j] += buffer[j] * vol;
vol += vol_inc;
}
@@ -116,11 +114,11 @@ void AudioStreamPlayer2D::_mix_audio() {
targets[k] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, k);
}
- if (!valid)
+ if (!valid) {
continue;
+ }
for (int j = 0; j < buffer_size; j++) {
-
AudioFrame frame = buffer[j] * vol;
for (int k = 0; k < cc; k++) {
targets[k][j] += frame;
@@ -145,9 +143,7 @@ void AudioStreamPlayer2D::_mix_audio() {
}
void AudioStreamPlayer2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
AudioServer::get_singleton()->add_callback(_mix_audios, this);
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
@@ -155,7 +151,6 @@ void AudioStreamPlayer2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
AudioServer::get_singleton()->remove_callback(_mix_audios, this);
}
@@ -171,7 +166,6 @@ void AudioStreamPlayer2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
-
//update anything related to position first, if possible of course
if (!output_ready) {
@@ -194,13 +188,14 @@ void AudioStreamPlayer2D::_notification(int p_what) {
int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true);
for (int i = 0; i < areas; i++) {
-
Area2D *area2d = Object::cast_to<Area2D>(sr[i].collider);
- if (!area2d)
+ if (!area2d) {
continue;
+ }
- if (!area2d->is_overriding_audio_bus())
+ if (!area2d->is_overriding_audio_bus()) {
continue;
+ }
StringName bus_name = area2d->get_audio_bus_name();
bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name);
@@ -209,10 +204,8 @@ void AudioStreamPlayer2D::_notification(int p_what) {
world_2d->get_viewport_list(&viewports);
for (List<Viewport *>::Element *E = viewports.front(); E; E = E->next()) {
-
Viewport *vp = E->get();
if (vp->is_audio_listener_2d()) {
-
//compute matrix to convert to screen
Transform2D to_screen = vp->get_global_canvas_transform() * vp->get_canvas_transform();
Vector2 screen_size = vp->get_visible_rect().size;
@@ -222,8 +215,9 @@ void AudioStreamPlayer2D::_notification(int p_what) {
float dist = global_pos.distance_to(screen_in_global); //distance to screen center
- if (dist > max_distance)
+ if (dist > max_distance) {
continue; //can't hear this sound in this viewport
+ }
float multiplier = Math::pow(1.0f - dist / max_distance, attenuation);
multiplier *= Math::db2linear(volume_db); //also apply player volume!
@@ -240,8 +234,9 @@ void AudioStreamPlayer2D::_notification(int p_what) {
outputs[new_output_count].bus_index = bus_index;
outputs[new_output_count].viewport = vp; //keep pointer only for reference
new_output_count++;
- if (new_output_count == MAX_OUTPUTS)
+ if (new_output_count == MAX_OUTPUTS) {
break;
+ }
}
}
@@ -269,7 +264,6 @@ void AudioStreamPlayer2D::_notification(int p_what) {
}
void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
-
AudioServer::get_singleton()->lock();
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
@@ -294,16 +288,14 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
}
Ref<AudioStream> AudioStreamPlayer2D::get_stream() const {
-
return stream;
}
void AudioStreamPlayer2D::set_volume_db(float p_volume) {
-
volume_db = p_volume;
}
-float AudioStreamPlayer2D::get_volume_db() const {
+float AudioStreamPlayer2D::get_volume_db() const {
return volume_db;
}
@@ -311,12 +303,12 @@ void AudioStreamPlayer2D::set_pitch_scale(float p_pitch_scale) {
ERR_FAIL_COND(p_pitch_scale <= 0.0);
pitch_scale = p_pitch_scale;
}
+
float AudioStreamPlayer2D::get_pitch_scale() const {
return pitch_scale;
}
void AudioStreamPlayer2D::play(float p_from_pos) {
-
if (!is_playing()) {
// Reset the prev_output_count if the stream is stopped
prev_output_count = 0;
@@ -331,14 +323,12 @@ void AudioStreamPlayer2D::play(float p_from_pos) {
}
void AudioStreamPlayer2D::seek(float p_seconds) {
-
if (stream_playback.is_valid()) {
setseek = p_seconds;
}
}
void AudioStreamPlayer2D::stop() {
-
if (stream_playback.is_valid()) {
active = false;
set_physics_process_internal(false);
@@ -347,7 +337,6 @@ void AudioStreamPlayer2D::stop() {
}
bool AudioStreamPlayer2D::is_playing() const {
-
if (stream_playback.is_valid()) {
return active; // && stream_playback->is_playing();
}
@@ -356,7 +345,6 @@ bool AudioStreamPlayer2D::is_playing() const {
}
float AudioStreamPlayer2D::get_playback_position() {
-
if (stream_playback.is_valid()) {
return stream_playback->get_playback_position();
}
@@ -365,14 +353,13 @@ float AudioStreamPlayer2D::get_playback_position() {
}
void AudioStreamPlayer2D::set_bus(const StringName &p_bus) {
-
//if audio is active, must lock this
AudioServer::get_singleton()->lock();
bus = p_bus;
AudioServer::get_singleton()->unlock();
}
-StringName AudioStreamPlayer2D::get_bus() const {
+StringName AudioStreamPlayer2D::get_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == bus) {
return bus;
@@ -382,34 +369,32 @@ StringName AudioStreamPlayer2D::get_bus() const {
}
void AudioStreamPlayer2D::set_autoplay(bool p_enable) {
-
autoplay = p_enable;
}
-bool AudioStreamPlayer2D::is_autoplay_enabled() {
+bool AudioStreamPlayer2D::is_autoplay_enabled() {
return autoplay;
}
void AudioStreamPlayer2D::_set_playing(bool p_enable) {
-
- if (p_enable)
+ if (p_enable) {
play();
- else
+ } else {
stop();
+ }
}
-bool AudioStreamPlayer2D::_is_active() const {
+bool AudioStreamPlayer2D::_is_active() const {
return active;
}
void AudioStreamPlayer2D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "bus") {
-
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -419,42 +404,35 @@ void AudioStreamPlayer2D::_validate_property(PropertyInfo &property) const {
}
void AudioStreamPlayer2D::_bus_layout_changed() {
-
_change_notify();
}
void AudioStreamPlayer2D::set_max_distance(float p_pixels) {
-
ERR_FAIL_COND(p_pixels <= 0.0);
max_distance = p_pixels;
}
float AudioStreamPlayer2D::get_max_distance() const {
-
return max_distance;
}
void AudioStreamPlayer2D::set_attenuation(float p_curve) {
-
attenuation = p_curve;
}
-float AudioStreamPlayer2D::get_attenuation() const {
+float AudioStreamPlayer2D::get_attenuation() const {
return attenuation;
}
void AudioStreamPlayer2D::set_area_mask(uint32_t p_mask) {
-
area_mask = p_mask;
}
uint32_t AudioStreamPlayer2D::get_area_mask() const {
-
return area_mask;
}
void AudioStreamPlayer2D::set_stream_paused(bool p_pause) {
-
if (p_pause != stream_paused) {
stream_paused = p_pause;
stream_paused_fade_in = !p_pause;
@@ -463,7 +441,6 @@ void AudioStreamPlayer2D::set_stream_paused(bool p_pause) {
}
bool AudioStreamPlayer2D::get_stream_paused() const {
-
return stream_paused;
}
@@ -472,7 +449,6 @@ Ref<AudioStreamPlayback> AudioStreamPlayer2D::get_stream_playback() {
}
void AudioStreamPlayer2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_stream", "stream"), &AudioStreamPlayer2D::set_stream);
ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer2D::get_stream);
@@ -527,7 +503,6 @@ void AudioStreamPlayer2D::_bind_methods() {
}
AudioStreamPlayer2D::AudioStreamPlayer2D() {
-
volume_db = 0;
pitch_scale = 1.0;
autoplay = false;
diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h
index 86e931b3c6..7f0b6f5897 100644
--- a/scene/2d/audio_stream_player_2d.h
+++ b/scene/2d/audio_stream_player_2d.h
@@ -36,7 +36,6 @@
#include "servers/audio_server.h"
class AudioStreamPlayer2D : public Node2D {
-
GDCLASS(AudioStreamPlayer2D, Node2D);
private:
@@ -47,7 +46,6 @@ private:
};
struct Output {
-
AudioFrame vol;
int bus_index;
Viewport *viewport; //pointer only used for reference to previous mix
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index 4c952b7ca6..a36e0a86e1 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -31,19 +31,14 @@
#include "back_buffer_copy.h"
void BackBufferCopy::_update_copy_mode() {
-
switch (copy_mode) {
-
case COPY_MODE_DISABLED: {
-
RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2());
} break;
case COPY_MODE_RECT: {
-
RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect);
} break;
case COPY_MODE_VIEWPORT: {
-
RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2());
} break;
@@ -52,7 +47,6 @@ void BackBufferCopy::_update_copy_mode() {
#ifdef TOOLS_ENABLED
Rect2 BackBufferCopy::_edit_get_rect() const {
-
return rect;
}
@@ -62,12 +56,10 @@ bool BackBufferCopy::_edit_use_rect() const {
#endif
Rect2 BackBufferCopy::get_anchorable_rect() const {
-
return rect;
}
void BackBufferCopy::set_rect(const Rect2 &p_rect) {
-
rect = p_rect;
_update_copy_mode();
}
@@ -77,17 +69,15 @@ Rect2 BackBufferCopy::get_rect() const {
}
void BackBufferCopy::set_copy_mode(CopyMode p_mode) {
-
copy_mode = p_mode;
_update_copy_mode();
}
-BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const {
+BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const {
return copy_mode;
}
void BackBufferCopy::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_rect", "rect"), &BackBufferCopy::set_rect);
ClassDB::bind_method(D_METHOD("get_rect"), &BackBufferCopy::get_rect);
@@ -103,10 +93,10 @@ void BackBufferCopy::_bind_methods() {
}
BackBufferCopy::BackBufferCopy() {
-
rect = Rect2(-100, -100, 200, 200);
copy_mode = COPY_MODE_RECT;
_update_copy_mode();
}
+
BackBufferCopy::~BackBufferCopy() {
}
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index d8af14a3fb..68e99445d8 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -36,20 +36,20 @@
#include "servers/rendering_server.h"
void Camera2D::_update_scroll() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (Engine::get_singleton()->is_editor_hint()) {
update(); //will just be drawn
return;
}
- if (!viewport)
+ if (!viewport) {
return;
+ }
if (current) {
-
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Transform2D xform = get_camera_transform();
@@ -64,7 +64,6 @@ void Camera2D::_update_scroll() {
}
void Camera2D::_update_process_mode() {
-
if (Engine::get_singleton()->is_editor_hint()) {
set_process_internal(false);
set_physics_process_internal(false);
@@ -78,7 +77,6 @@ void Camera2D::_update_process_mode() {
}
void Camera2D::set_zoom(const Vector2 &p_zoom) {
-
zoom = p_zoom;
Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
@@ -86,14 +84,13 @@ void Camera2D::set_zoom(const Vector2 &p_zoom) {
};
Vector2 Camera2D::get_zoom() const {
-
return zoom;
};
Transform2D Camera2D::get_camera_transform() {
-
- if (!get_tree())
+ if (!get_tree()) {
return Transform2D();
+ }
ERR_FAIL_COND_V(custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D());
@@ -103,14 +100,11 @@ Transform2D Camera2D::get_camera_transform() {
Point2 ret_camera_pos;
if (!first) {
-
if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
-
if (h_drag_enabled && !Engine::get_singleton()->is_editor_hint() && !h_offset_changed) {
camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * zoom.x * drag_margin[MARGIN_LEFT]));
camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * zoom.x * drag_margin[MARGIN_RIGHT]));
} else {
-
if (h_ofs < 0) {
camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs;
} else {
@@ -121,12 +115,10 @@ Transform2D Camera2D::get_camera_transform() {
}
if (v_drag_enabled && !Engine::get_singleton()->is_editor_hint() && !v_offset_changed) {
-
camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * zoom.y * drag_margin[MARGIN_TOP]));
camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * zoom.y * drag_margin[MARGIN_BOTTOM]));
} else {
-
if (v_ofs < 0) {
camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs;
} else {
@@ -137,7 +129,6 @@ Transform2D Camera2D::get_camera_transform() {
}
} else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) {
-
camera_pos = new_camera_pos;
}
@@ -145,27 +136,29 @@ Transform2D Camera2D::get_camera_transform() {
Rect2 screen_rect(-screen_offset + camera_pos, screen_size * zoom);
if (limit_smoothing_enabled) {
- if (screen_rect.position.x < limit[MARGIN_LEFT])
+ if (screen_rect.position.x < limit[MARGIN_LEFT]) {
camera_pos.x -= screen_rect.position.x - limit[MARGIN_LEFT];
+ }
- if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT])
+ if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT]) {
camera_pos.x -= screen_rect.position.x + screen_rect.size.x - limit[MARGIN_RIGHT];
+ }
- if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM])
+ if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM]) {
camera_pos.y -= screen_rect.position.y + screen_rect.size.y - limit[MARGIN_BOTTOM];
+ }
- if (screen_rect.position.y < limit[MARGIN_TOP])
+ if (screen_rect.position.y < limit[MARGIN_TOP]) {
camera_pos.y -= screen_rect.position.y - limit[MARGIN_TOP];
+ }
}
if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) {
-
float c = smoothing * (process_mode == CAMERA2D_PROCESS_PHYSICS ? get_physics_process_delta_time() : get_process_delta_time());
smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos;
ret_camera_pos = smoothed_camera_pos;
//camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
} else {
-
ret_camera_pos = smoothed_camera_pos = camera_pos;
}
@@ -182,20 +175,25 @@ Transform2D Camera2D::get_camera_transform() {
}
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
- if (screen_rect.position.x < limit[MARGIN_LEFT])
+ if (screen_rect.position.x < limit[MARGIN_LEFT]) {
screen_rect.position.x = limit[MARGIN_LEFT];
+ }
- if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT])
+ if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT]) {
screen_rect.position.x = limit[MARGIN_RIGHT] - screen_rect.size.x;
+ }
- if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM])
+ if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM]) {
screen_rect.position.y = limit[MARGIN_BOTTOM] - screen_rect.size.y;
+ }
- if (screen_rect.position.y < limit[MARGIN_TOP])
+ if (screen_rect.position.y < limit[MARGIN_TOP]) {
screen_rect.position.y = limit[MARGIN_TOP];
+ }
- if (offset != Vector2())
+ if (offset != Vector2()) {
screen_rect.position += offset;
+ }
camera_screen_center = screen_rect.position + screen_rect.size * 0.5;
@@ -218,23 +216,19 @@ Transform2D Camera2D::get_camera_transform() {
}
void Camera2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_INTERNAL_PROCESS:
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
-
_update_scroll();
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
- if (!is_processing_internal() && !is_physics_processing_internal())
+ if (!is_processing_internal() && !is_physics_processing_internal()) {
_update_scroll();
+ }
} break;
case NOTIFICATION_ENTER_TREE: {
-
if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) {
viewport = custom_viewport;
} else {
@@ -256,7 +250,6 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
if (is_current()) {
if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
viewport->set_canvas_transform(Transform2D());
@@ -268,9 +261,9 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
-
- if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint())
+ if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint()) {
break;
+ }
if (screen_drawing_enabled) {
Color area_axis_color(0.5, 0.42, 0.87, 0.63);
@@ -349,56 +342,51 @@ void Camera2D::_notification(int p_what) {
}
void Camera2D::set_offset(const Vector2 &p_offset) {
-
offset = p_offset;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
Vector2 Camera2D::get_offset() const {
-
return offset;
}
void Camera2D::set_anchor_mode(AnchorMode p_anchor_mode) {
-
anchor_mode = p_anchor_mode;
_update_scroll();
}
Camera2D::AnchorMode Camera2D::get_anchor_mode() const {
-
return anchor_mode;
}
void Camera2D::set_rotating(bool p_rotating) {
-
rotating = p_rotating;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
bool Camera2D::is_rotating() const {
-
return rotating;
}
void Camera2D::set_process_mode(Camera2DProcessMode p_mode) {
-
- if (process_mode == p_mode)
+ if (process_mode == p_mode) {
return;
+ }
process_mode = p_mode;
_update_process_mode();
}
Camera2D::Camera2DProcessMode Camera2D::get_process_mode() const {
-
return process_mode;
}
void Camera2D::_make_current(Object *p_which) {
-
if (p_which == this) {
-
current = true;
} else {
current = false;
@@ -406,21 +394,19 @@ void Camera2D::_make_current(Object *p_which) {
}
void Camera2D::_set_current(bool p_current) {
-
- if (p_current)
+ if (p_current) {
make_current();
+ }
current = p_current;
update();
}
bool Camera2D::is_current() const {
-
return current;
}
void Camera2D::make_current() {
-
if (!is_inside_tree()) {
current = true;
} else {
@@ -430,7 +416,6 @@ void Camera2D::make_current() {
}
void Camera2D::clear_current() {
-
current = false;
if (is_inside_tree()) {
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)nullptr);
@@ -438,60 +423,50 @@ void Camera2D::clear_current() {
}
void Camera2D::set_limit(Margin p_margin, int p_limit) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
limit[p_margin] = p_limit;
update();
}
int Camera2D::get_limit(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return limit[p_margin];
}
void Camera2D::set_limit_smoothing_enabled(bool enable) {
-
limit_smoothing_enabled = enable;
_update_scroll();
}
bool Camera2D::is_limit_smoothing_enabled() const {
-
return limit_smoothing_enabled;
}
void Camera2D::set_drag_margin(Margin p_margin, float p_drag_margin) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
drag_margin[p_margin] = p_drag_margin;
update();
}
float Camera2D::get_drag_margin(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return drag_margin[p_margin];
}
Vector2 Camera2D::get_camera_position() const {
-
return camera_pos;
}
void Camera2D::force_update_scroll() {
-
_update_scroll();
}
void Camera2D::reset_smoothing() {
-
smoothed_camera_pos = camera_pos;
_update_scroll();
}
void Camera2D::align() {
-
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Size2 screen_size = viewport->get_visible_rect().size;
@@ -509,7 +484,6 @@ void Camera2D::align() {
camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs;
}
} else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) {
-
camera_pos = current_camera_pos;
}
@@ -517,64 +491,59 @@ void Camera2D::align() {
}
void Camera2D::set_follow_smoothing(float p_speed) {
-
smoothing = p_speed;
- if (smoothing > 0 && !(is_inside_tree() && Engine::get_singleton()->is_editor_hint()))
+ if (smoothing > 0 && !(is_inside_tree() && Engine::get_singleton()->is_editor_hint())) {
set_process_internal(true);
- else
+ } else {
set_process_internal(false);
+ }
}
float Camera2D::get_follow_smoothing() const {
-
return smoothing;
}
Point2 Camera2D::get_camera_screen_center() const {
-
return camera_screen_center;
}
void Camera2D::set_h_drag_enabled(bool p_enabled) {
-
h_drag_enabled = p_enabled;
}
bool Camera2D::is_h_drag_enabled() const {
-
return h_drag_enabled;
}
void Camera2D::set_v_drag_enabled(bool p_enabled) {
-
v_drag_enabled = p_enabled;
}
bool Camera2D::is_v_drag_enabled() const {
-
return v_drag_enabled;
}
void Camera2D::set_v_offset(float p_offset) {
-
v_ofs = p_offset;
v_offset_changed = true;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
float Camera2D::get_v_offset() const {
-
return v_ofs;
}
void Camera2D::set_h_offset(float p_offset) {
-
h_ofs = p_offset;
h_offset_changed = true;
+ Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
+ smoothed_camera_pos = old_smoothed_camera_pos;
}
-float Camera2D::get_h_offset() const {
+float Camera2D::get_h_offset() const {
return h_ofs;
}
@@ -587,12 +556,10 @@ void Camera2D::_set_old_smoothing(float p_enable) {
}
void Camera2D::set_enable_follow_smoothing(bool p_enabled) {
-
smoothing_enabled = p_enabled;
}
bool Camera2D::is_follow_smoothing_enabled() const {
-
return smoothing_enabled;
}
@@ -612,11 +579,11 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
}
if (is_inside_tree()) {
-
- if (custom_viewport)
+ if (custom_viewport) {
viewport = custom_viewport;
- else
+ } else {
viewport = get_viewport();
+ }
RID vp = viewport->get_viewport_rid();
group_name = "__cameras_" + itos(vp.get_id());
@@ -627,7 +594,6 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
}
Node *Camera2D::get_custom_viewport() const {
-
return custom_viewport;
}
@@ -659,7 +625,6 @@ bool Camera2D::is_margin_drawing_enabled() const {
}
void Camera2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &Camera2D::set_offset);
ClassDB::bind_method(D_METHOD("get_offset"), &Camera2D::get_offset);
@@ -777,7 +742,6 @@ void Camera2D::_bind_methods() {
}
Camera2D::Camera2D() {
-
anchor_mode = ANCHOR_MODE_DRAG_CENTER;
rotating = false;
current = false;
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 7a106ef79a..0a4e269c40 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -35,7 +35,6 @@
#include "scene/main/window.h"
class Camera2D : public Node2D {
-
GDCLASS(Camera2D, Node2D);
public:
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 05f8804e2a..56643542a8 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -31,22 +31,18 @@
#include "canvas_modulate.h"
void CanvasModulate::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_CANVAS) {
-
if (is_visible_in_tree()) {
RS::get_singleton()->canvas_set_modulate(get_canvas(), color);
add_to_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
} else if (p_what == NOTIFICATION_EXIT_CANVAS) {
-
if (is_visible_in_tree()) {
RS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1));
remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
if (is_visible_in_tree()) {
RS::get_singleton()->canvas_set_modulate(get_canvas(), color);
add_to_group("_canvas_modulate_" + itos(get_canvas().get_id()));
@@ -60,7 +56,6 @@ void CanvasModulate::_notification(int p_what) {
}
void CanvasModulate::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_color", "color"), &CanvasModulate::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &CanvasModulate::get_color);
@@ -68,21 +63,20 @@ void CanvasModulate::_bind_methods() {
}
void CanvasModulate::set_color(const Color &p_color) {
-
color = p_color;
if (is_visible_in_tree()) {
RS::get_singleton()->canvas_set_modulate(get_canvas(), color);
}
}
-Color CanvasModulate::get_color() const {
+Color CanvasModulate::get_color() const {
return color;
}
String CanvasModulate::get_configuration_warning() const {
-
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
List<Node *> nodes;
get_tree()->get_nodes_in_group("_canvas_modulate_" + itos(get_canvas().get_id()), &nodes);
diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h
index ada6e27760..a0b61f43ba 100644
--- a/scene/2d/canvas_modulate.h
+++ b/scene/2d/canvas_modulate.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class CanvasModulate : public Node2D {
-
GDCLASS(CanvasModulate, Node2D);
Color color;
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index d82f4a2f2b..fe16d4089a 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -34,23 +34,22 @@
#include "servers/physics_server_2d.h"
void CollisionObject2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
Transform2D global_transform = get_global_transform();
- if (area)
+ if (area) {
PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform);
- else
+ } else {
PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform);
+ }
RID space = get_world_2d()->get_space();
if (area) {
PhysicsServer2D::get_singleton()->area_set_space(rid, space);
- } else
+ } else {
PhysicsServer2D::get_singleton()->body_set_space(rid, space);
+ }
_update_pickable();
@@ -58,52 +57,50 @@ void CollisionObject2D::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_CANVAS: {
-
- if (area)
+ if (area) {
PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
- else
+ } else {
PhysicsServer2D::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id());
+ }
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
_update_pickable();
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
if (only_update_transform_changes) {
return;
}
Transform2D global_transform = get_global_transform();
- if (area)
+ if (area) {
PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform);
- else
+ } else {
PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform);
+ }
} break;
case NOTIFICATION_EXIT_TREE: {
-
if (area) {
PhysicsServer2D::get_singleton()->area_set_space(rid, RID());
- } else
+ } else {
PhysicsServer2D::get_singleton()->body_set_space(rid, RID());
+ }
} break;
case NOTIFICATION_EXIT_CANVAS: {
-
- if (area)
+ if (area) {
PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, ObjectID());
- else
+ } else {
PhysicsServer2D::get_singleton()->body_attach_canvas_instance_id(rid, ObjectID());
+ }
} break;
}
}
uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) {
-
ShapeData sd;
uint32_t id;
@@ -121,7 +118,6 @@ uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) {
}
void CollisionObject2D::remove_shape_owner(uint32_t owner) {
-
ERR_FAIL_COND(!shapes.has(owner));
shape_owner_clear_shapes(owner);
@@ -144,16 +140,15 @@ void CollisionObject2D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl
}
bool CollisionObject2D::is_shape_owner_disabled(uint32_t p_owner) const {
-
ERR_FAIL_COND_V(!shapes.has(p_owner), false);
return shapes[p_owner].disabled;
}
void CollisionObject2D::shape_owner_set_one_way_collision(uint32_t p_owner, bool p_enable) {
-
- if (area)
+ if (area) {
return; //not for areas
+ }
ERR_FAIL_COND(!shapes.has(p_owner));
@@ -165,16 +160,15 @@ void CollisionObject2D::shape_owner_set_one_way_collision(uint32_t p_owner, bool
}
bool CollisionObject2D::is_shape_owner_one_way_collision_enabled(uint32_t p_owner) const {
-
ERR_FAIL_COND_V(!shapes.has(p_owner), false);
return shapes[p_owner].one_way_collision;
}
void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owner, float p_margin) {
-
- if (area)
+ if (area) {
return; //not for areas
+ }
ERR_FAIL_COND(!shapes.has(p_owner));
@@ -186,21 +180,18 @@ void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owne
}
float CollisionObject2D::get_shape_owner_one_way_collision_margin(uint32_t p_owner) const {
-
ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
return shapes[p_owner].one_way_collision_margin;
}
void CollisionObject2D::get_shape_owners(List<uint32_t> *r_owners) {
-
for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
r_owners->push_back(E->key());
}
}
Array CollisionObject2D::_get_shape_owners() {
-
Array ret;
for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
ret.push_back(E->key());
@@ -210,7 +201,6 @@ Array CollisionObject2D::_get_shape_owners() {
}
void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
ShapeData &sd = shapes[p_owner];
@@ -224,22 +214,20 @@ void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transf
}
}
}
-Transform2D CollisionObject2D::shape_owner_get_transform(uint32_t p_owner) const {
+Transform2D CollisionObject2D::shape_owner_get_transform(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), Transform2D());
return shapes[p_owner].xform;
}
Object *CollisionObject2D::shape_owner_get_owner(uint32_t p_owner) const {
-
ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr);
return shapes[p_owner].owner;
}
void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
ERR_FAIL_COND(p_shape.is_null());
@@ -256,21 +244,21 @@ void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2
total_subshapes++;
}
-int CollisionObject2D::shape_owner_get_shape_count(uint32_t p_owner) const {
+int CollisionObject2D::shape_owner_get_shape_count(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
return shapes[p_owner].shapes.size();
}
-Ref<Shape2D> CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
+Ref<Shape2D> CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape2D>());
ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape2D>());
return shapes[p_owner].shapes[p_shape].shape;
}
-int CollisionObject2D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
+int CollisionObject2D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), -1);
ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), -1);
@@ -278,7 +266,6 @@ int CollisionObject2D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape
}
void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size());
@@ -303,7 +290,6 @@ void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape)
}
void CollisionObject2D::shape_owner_clear_shapes(uint32_t p_owner) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
while (shape_owner_get_shape_count(p_owner) > 0) {
@@ -312,7 +298,6 @@ void CollisionObject2D::shape_owner_clear_shapes(uint32_t p_owner) {
}
uint32_t CollisionObject2D::shape_find_owner(int p_shape_index) const {
-
ERR_FAIL_INDEX_V(p_shape_index, total_subshapes, 0);
for (const Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
@@ -328,21 +313,19 @@ uint32_t CollisionObject2D::shape_find_owner(int p_shape_index) const {
}
void CollisionObject2D::set_pickable(bool p_enabled) {
-
- if (pickable == p_enabled)
+ if (pickable == p_enabled) {
return;
+ }
pickable = p_enabled;
_update_pickable();
}
bool CollisionObject2D::is_pickable() const {
-
return pickable;
}
void CollisionObject2D::_input_event(Node *p_viewport, const Ref<InputEvent> &p_input_event, int p_shape) {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_viewport, p_input_event, p_shape);
}
@@ -350,7 +333,6 @@ void CollisionObject2D::_input_event(Node *p_viewport, const Ref<InputEvent> &p_
}
void CollisionObject2D::_mouse_enter() {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
}
@@ -358,7 +340,6 @@ void CollisionObject2D::_mouse_enter() {
}
void CollisionObject2D::_mouse_exit() {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
}
@@ -370,18 +351,19 @@ void CollisionObject2D::set_only_update_transform_changes(bool p_enable) {
}
void CollisionObject2D::_update_pickable() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool is_pickable = pickable && is_visible_in_tree();
- if (area)
+ if (area) {
PhysicsServer2D::get_singleton()->area_set_pickable(rid, is_pickable);
- else
+ } else {
PhysicsServer2D::get_singleton()->body_set_pickable(rid, is_pickable);
+ }
}
String CollisionObject2D::get_configuration_warning() const {
-
String warning = Node2D::get_configuration_warning();
if (shapes.empty()) {
@@ -395,7 +377,6 @@ String CollisionObject2D::get_configuration_warning() const {
}
void CollisionObject2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject2D::get_rid);
ClassDB::bind_method(D_METHOD("set_pickable", "enabled"), &CollisionObject2D::set_pickable);
@@ -432,7 +413,6 @@ void CollisionObject2D::_bind_methods() {
}
CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
-
rid = p_rid;
area = p_area;
pickable = true;
@@ -441,7 +421,6 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
only_update_transform_changes = false;
if (p_area) {
-
PhysicsServer2D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
} else {
PhysicsServer2D::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
@@ -449,13 +428,11 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
}
CollisionObject2D::CollisionObject2D() {
-
//owner=
set_notify_transform(true);
}
CollisionObject2D::~CollisionObject2D() {
-
PhysicsServer2D::get_singleton()->free(rid);
}
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index e931f20f40..d7af2f3a2a 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -35,7 +35,6 @@
#include "scene/resources/shape_2d.h"
class CollisionObject2D : public Node2D {
-
GDCLASS(CollisionObject2D, Node2D);
bool area;
@@ -43,7 +42,6 @@ class CollisionObject2D : public Node2D {
bool pickable;
struct ShapeData {
-
Object *owner;
Transform2D xform;
struct Shape {
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 1e48b2d67f..d23398713a 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -32,22 +32,22 @@
#include "collision_object_2d.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
#include "thirdparty/misc/triangulator.h"
void CollisionPolygon2D::_build_polygon() {
-
parent->shape_owner_clear_shapes(owner_id);
- if (polygon.size() == 0)
+ if (polygon.size() == 0) {
return;
+ }
bool solids = build_mode == BUILD_SOLIDS;
if (solids) {
-
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
Vector<Vector<Vector2>> decomp = _decompose_in_convex();
@@ -58,7 +58,6 @@ void CollisionPolygon2D::_build_polygon() {
}
} else {
-
Ref<ConcavePolygonShape2D> concave = memnew(ConcavePolygonShape2D);
Vector<Vector2> segments;
@@ -77,25 +76,23 @@ void CollisionPolygon2D::_build_polygon() {
}
Vector<Vector<Vector2>> CollisionPolygon2D::_decompose_in_convex() {
- Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon);
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(polygon);
return decomp;
}
void CollisionPolygon2D::_update_in_shape_owner(bool p_xform_only) {
-
parent->shape_owner_set_transform(owner_id, get_transform());
- if (p_xform_only)
+ if (p_xform_only) {
return;
+ }
parent->shape_owner_set_disabled(owner_id, disabled);
parent->shape_owner_set_one_way_collision(owner_id, one_way_collision);
parent->shape_owner_set_one_way_collision_margin(owner_id, one_way_collision_margin);
}
void CollisionPolygon2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_PARENTED: {
-
parent = Object::cast_to<CollisionObject2D>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
@@ -111,14 +108,12 @@ void CollisionPolygon2D::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
-
if (parent) {
_update_in_shape_owner();
}
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
-
if (parent) {
_update_in_shape_owner(true);
}
@@ -133,13 +128,11 @@ void CollisionPolygon2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
-
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
for (int i = 0; i < polygon.size(); i++) {
-
Vector2 p = polygon[i];
Vector2 n = polygon[(i + 1) % polygon.size()];
// draw line with width <= 1, so it does not scale with zoom and break pixel exact editing
@@ -152,7 +145,6 @@ void CollisionPolygon2D::_notification(int p_what) {
Color c(0.4, 0.9, 0.1);
for (int i = 0; i < decomp.size(); i++) {
-
c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5);
draw_colored_polygon(decomp[i], c);
}
@@ -171,8 +163,9 @@ void CollisionPolygon2D::_notification(int p_what) {
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
Vector<Color> cols;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
cols.push_back(dcol);
+ }
draw_primitive(pts, cols, Vector<Vector2>()); //small arrow
}
@@ -181,18 +174,17 @@ void CollisionPolygon2D::_notification(int p_what) {
}
void CollisionPolygon2D::set_polygon(const Vector<Point2> &p_polygon) {
-
polygon = p_polygon;
{
for (int i = 0; i < polygon.size(); i++) {
- if (i == 0)
+ if (i == 0) {
aabb = Rect2(polygon[i], Size2());
- else
+ } else {
aabb.expand_to(polygon[i]);
+ }
}
if (aabb == Rect2()) {
-
aabb = Rect2(-10, -10, 20, 20);
} else {
aabb.position -= aabb.size * 0.3;
@@ -208,12 +200,10 @@ void CollisionPolygon2D::set_polygon(const Vector<Point2> &p_polygon) {
}
Vector<Point2> CollisionPolygon2D::get_polygon() const {
-
return polygon;
}
void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
-
ERR_FAIL_INDEX((int)p_mode, 2);
build_mode = p_mode;
if (parent) {
@@ -222,13 +212,11 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
}
CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const {
-
return build_mode;
}
#ifdef TOOLS_ENABLED
Rect2 CollisionPolygon2D::_edit_get_rect() const {
-
return aabb;
}
@@ -237,13 +225,11 @@ bool CollisionPolygon2D::_edit_use_rect() const {
}
bool CollisionPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
- return Geometry::is_point_in_polygon(p_point, Variant(polygon));
+ return Geometry2D::is_point_in_polygon(p_point, Variant(polygon));
}
#endif
String CollisionPolygon2D::get_configuration_warning() const {
-
if (!Object::cast_to<CollisionObject2D>(get_parent())) {
return TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
}
@@ -276,7 +262,6 @@ void CollisionPolygon2D::set_one_way_collision(bool p_enable) {
}
bool CollisionPolygon2D::is_one_way_collision_enabled() const {
-
return one_way_collision;
}
@@ -290,8 +275,8 @@ void CollisionPolygon2D::set_one_way_collision_margin(float p_margin) {
float CollisionPolygon2D::get_one_way_collision_margin() const {
return one_way_collision_margin;
}
-void CollisionPolygon2D::_bind_methods() {
+void CollisionPolygon2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CollisionPolygon2D::set_polygon);
ClassDB::bind_method(D_METHOD("get_polygon"), &CollisionPolygon2D::get_polygon);
@@ -315,7 +300,6 @@ void CollisionPolygon2D::_bind_methods() {
}
CollisionPolygon2D::CollisionPolygon2D() {
-
aabb = Rect2(-10, -10, 20, 20);
build_mode = BUILD_SOLIDS;
set_notify_local_transform(true);
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index 92a2758813..bf3e560a93 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -37,7 +37,6 @@
class CollisionObject2D;
class CollisionPolygon2D : public Node2D {
-
GDCLASS(CollisionPolygon2D, Node2D);
public:
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index b1dbc57c94..88d124536c 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -41,26 +41,22 @@
#include "scene/resources/segment_shape_2d.h"
void CollisionShape2D::_shape_changed() {
-
update();
}
void CollisionShape2D::_update_in_shape_owner(bool p_xform_only) {
-
parent->shape_owner_set_transform(owner_id, get_transform());
- if (p_xform_only)
+ if (p_xform_only) {
return;
+ }
parent->shape_owner_set_disabled(owner_id, disabled);
parent->shape_owner_set_one_way_collision(owner_id, one_way_collision);
parent->shape_owner_set_one_way_collision_margin(owner_id, one_way_collision_margin);
}
void CollisionShape2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_PARENTED: {
-
parent = Object::cast_to<CollisionObject2D>(get_parent());
if (parent) {
owner_id = parent->create_shape_owner(this);
@@ -78,14 +74,12 @@ void CollisionShape2D::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
-
if (parent) {
_update_in_shape_owner();
}
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
-
if (parent) {
_update_in_shape_owner(true);
}
@@ -100,7 +94,6 @@ void CollisionShape2D::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW: {
-
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
}
@@ -137,8 +130,9 @@ void CollisionShape2D::_notification(int p_what) {
pts.push_back(line_to + (Vector2(Math_SQRT12 * tsize, 0)));
pts.push_back(line_to + (Vector2(-Math_SQRT12 * tsize, 0)));
Vector<Color> cols;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
cols.push_back(draw_col);
+ }
draw_primitive(pts, cols, Vector<Vector2>());
}
@@ -147,9 +141,9 @@ void CollisionShape2D::_notification(int p_what) {
}
void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
-
- if (shape.is_valid())
+ if (shape.is_valid()) {
shape->disconnect("changed", callable_mp(this, &CollisionShape2D::_shape_changed));
+ }
shape = p_shape;
update();
if (parent) {
@@ -159,27 +153,26 @@ void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
}
}
- if (shape.is_valid())
+ if (shape.is_valid()) {
shape->connect("changed", callable_mp(this, &CollisionShape2D::_shape_changed));
+ }
update_configuration_warning();
}
Ref<Shape2D> CollisionShape2D::get_shape() const {
-
return shape;
}
bool CollisionShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
- if (!shape.is_valid())
+ if (!shape.is_valid()) {
return false;
+ }
return shape->_edit_is_selected_on_click(p_point, p_tolerance);
}
String CollisionShape2D::get_configuration_warning() const {
-
if (!Object::cast_to<CollisionObject2D>(get_parent())) {
return TTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
}
@@ -212,7 +205,6 @@ void CollisionShape2D::set_one_way_collision(bool p_enable) {
}
bool CollisionShape2D::is_one_way_collision_enabled() const {
-
return one_way_collision;
}
@@ -228,7 +220,6 @@ float CollisionShape2D::get_one_way_collision_margin() const {
}
void CollisionShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape2D::set_shape);
ClassDB::bind_method(D_METHOD("get_shape"), &CollisionShape2D::get_shape);
ClassDB::bind_method(D_METHOD("set_disabled", "disabled"), &CollisionShape2D::set_disabled);
@@ -245,7 +236,6 @@ void CollisionShape2D::_bind_methods() {
}
CollisionShape2D::CollisionShape2D() {
-
rect = Rect2(-Point2(10, 10), Point2(20, 20));
set_notify_local_transform(true);
owner_id = 0;
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 80bea0a979..ec7808ee7c 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -37,7 +37,6 @@
class CollisionObject2D;
class CollisionShape2D : public Node2D {
-
GDCLASS(CollisionShape2D, Node2D);
Ref<Shape2D> shape;
Rect2 rect;
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index c37cd398c4..526951976e 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -37,17 +37,17 @@
#include "servers/rendering_server.h"
void CPUParticles2D::set_emitting(bool p_emitting) {
-
- if (emitting == p_emitting)
+ if (emitting == p_emitting) {
return;
+ }
emitting = p_emitting;
- if (emitting)
+ if (emitting) {
set_process_internal(true);
+ }
}
void CPUParticles2D::set_amount(int p_amount) {
-
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0.");
particles.resize(p_amount);
@@ -64,100 +64,90 @@ void CPUParticles2D::set_amount(int p_amount) {
particle_order.resize(p_amount);
}
-void CPUParticles2D::set_lifetime(float p_lifetime) {
+void CPUParticles2D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
}
void CPUParticles2D::set_one_shot(bool p_one_shot) {
-
one_shot = p_one_shot;
}
void CPUParticles2D::set_pre_process_time(float p_time) {
-
pre_process_time = p_time;
}
-void CPUParticles2D::set_explosiveness_ratio(float p_ratio) {
+void CPUParticles2D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
}
-void CPUParticles2D::set_randomness_ratio(float p_ratio) {
+void CPUParticles2D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
}
-void CPUParticles2D::set_lifetime_randomness(float p_random) {
+void CPUParticles2D::set_lifetime_randomness(float p_random) {
lifetime_randomness = p_random;
}
-void CPUParticles2D::set_use_local_coordinates(bool p_enable) {
+void CPUParticles2D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
set_notify_transform(!p_enable);
}
void CPUParticles2D::set_speed_scale(float p_scale) {
-
speed_scale = p_scale;
}
bool CPUParticles2D::is_emitting() const {
-
return emitting;
}
-int CPUParticles2D::get_amount() const {
+int CPUParticles2D::get_amount() const {
return particles.size();
}
-float CPUParticles2D::get_lifetime() const {
+float CPUParticles2D::get_lifetime() const {
return lifetime;
}
-bool CPUParticles2D::get_one_shot() const {
+bool CPUParticles2D::get_one_shot() const {
return one_shot;
}
float CPUParticles2D::get_pre_process_time() const {
-
return pre_process_time;
}
-float CPUParticles2D::get_explosiveness_ratio() const {
+float CPUParticles2D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float CPUParticles2D::get_randomness_ratio() const {
+float CPUParticles2D::get_randomness_ratio() const {
return randomness_ratio;
}
-float CPUParticles2D::get_lifetime_randomness() const {
+float CPUParticles2D::get_lifetime_randomness() const {
return lifetime_randomness;
}
bool CPUParticles2D::get_use_local_coordinates() const {
-
return local_coords;
}
float CPUParticles2D::get_speed_scale() const {
-
return speed_scale;
}
void CPUParticles2D::set_draw_order(DrawOrder p_order) {
-
draw_order = p_order;
}
CPUParticles2D::DrawOrder CPUParticles2D::get_draw_order() const {
-
return draw_order;
}
void CPUParticles2D::_update_mesh_texture() {
-
Size2 tex_size;
if (texture.is_valid()) {
tex_size = texture->get_size();
@@ -209,23 +199,25 @@ void CPUParticles2D::_update_mesh_texture() {
}
void CPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) {
- if (p_texture == texture)
+ if (p_texture == texture) {
return;
+ }
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CPUParticles2D::_texture_changed));
+ }
texture = p_texture;
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CPUParticles2D::_texture_changed));
+ }
update();
_update_mesh_texture();
}
void CPUParticles2D::_texture_changed() {
-
if (texture.is_valid()) {
update();
_update_mesh_texture();
@@ -233,18 +225,15 @@ void CPUParticles2D::_texture_changed() {
}
Ref<Texture2D> CPUParticles2D::get_texture() const {
-
return texture;
}
void CPUParticles2D::set_normalmap(const Ref<Texture2D> &p_normalmap) {
-
normalmap = p_normalmap;
update();
}
Ref<Texture2D> CPUParticles2D::get_normalmap() const {
-
return normalmap;
}
@@ -265,7 +254,6 @@ bool CPUParticles2D::get_fractional_delta() const {
}
String CPUParticles2D::get_configuration_warning() const {
-
String warnings;
CanvasItemMaterial *mat = Object::cast_to<CanvasItemMaterial>(get_material().ptr());
@@ -273,8 +261,9 @@ String CPUParticles2D::get_configuration_warning() const {
if (get_material().is_null() || (mat && !mat->get_particles_animation())) {
if (get_param(PARAM_ANIM_SPEED) != 0.0 || get_param(PARAM_ANIM_OFFSET) != 0.0 ||
get_param_curve(PARAM_ANIM_SPEED).is_valid() || get_param_curve(PARAM_ANIM_OFFSET).is_valid()) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("CPUParticles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled.");
}
}
@@ -283,7 +272,6 @@ String CPUParticles2D::get_configuration_warning() const {
}
void CPUParticles2D::restart() {
-
time = 0;
inactive_time = 0;
frame_remainder = 0;
@@ -303,62 +291,55 @@ void CPUParticles2D::restart() {
}
void CPUParticles2D::set_direction(Vector2 p_direction) {
-
direction = p_direction;
}
Vector2 CPUParticles2D::get_direction() const {
-
return direction;
}
void CPUParticles2D::set_spread(float p_spread) {
-
spread = p_spread;
}
float CPUParticles2D::get_spread() const {
-
return spread;
}
void CPUParticles2D::set_param(Parameter p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
parameters[p_param] = p_value;
}
-float CPUParticles2D::get_param(Parameter p_param) const {
+float CPUParticles2D::get_param(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return parameters[p_param];
}
void CPUParticles2D::set_param_randomness(Parameter p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
randomness[p_param] = p_value;
}
-float CPUParticles2D::get_param_randomness(Parameter p_param) const {
+float CPUParticles2D::get_param_randomness(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return randomness[p_param];
}
static void _adjust_curve_range(const Ref<Curve> &p_curve, float p_min, float p_max) {
-
Ref<Curve> curve = p_curve;
- if (!curve.is_valid())
+ if (!curve.is_valid()) {
return;
+ }
curve->ensure_default_setup(p_min, p_max);
}
void CPUParticles2D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
curve_parameters[p_param] = p_curve;
@@ -389,7 +370,6 @@ void CPUParticles2D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv
_adjust_curve_range(p_curve, -360, 360);
} break;
case PARAM_SCALE: {
-
} break;
case PARAM_HUE_VARIATION: {
_adjust_curve_range(p_curve, -1, 1);
@@ -403,30 +383,26 @@ void CPUParticles2D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv
}
}
}
-Ref<Curve> CPUParticles2D::get_param_curve(Parameter p_param) const {
+Ref<Curve> CPUParticles2D::get_param_curve(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Curve>());
return curve_parameters[p_param];
}
void CPUParticles2D::set_color(const Color &p_color) {
-
color = p_color;
}
Color CPUParticles2D::get_color() const {
-
return color;
}
void CPUParticles2D::set_color_ramp(const Ref<Gradient> &p_ramp) {
-
color_ramp = p_ramp;
}
Ref<Gradient> CPUParticles2D::get_color_ramp() const {
-
return color_ramp;
}
@@ -447,67 +423,58 @@ void CPUParticles2D::set_emission_shape(EmissionShape p_shape) {
}
void CPUParticles2D::set_emission_sphere_radius(float p_radius) {
-
emission_sphere_radius = p_radius;
}
void CPUParticles2D::set_emission_rect_extents(Vector2 p_extents) {
-
emission_rect_extents = p_extents;
}
void CPUParticles2D::set_emission_points(const Vector<Vector2> &p_points) {
-
emission_points = p_points;
}
void CPUParticles2D::set_emission_normals(const Vector<Vector2> &p_normals) {
-
emission_normals = p_normals;
}
void CPUParticles2D::set_emission_colors(const Vector<Color> &p_colors) {
-
emission_colors = p_colors;
}
float CPUParticles2D::get_emission_sphere_radius() const {
-
return emission_sphere_radius;
}
-Vector2 CPUParticles2D::get_emission_rect_extents() const {
+Vector2 CPUParticles2D::get_emission_rect_extents() const {
return emission_rect_extents;
}
-Vector<Vector2> CPUParticles2D::get_emission_points() const {
+Vector<Vector2> CPUParticles2D::get_emission_points() const {
return emission_points;
}
-Vector<Vector2> CPUParticles2D::get_emission_normals() const {
+Vector<Vector2> CPUParticles2D::get_emission_normals() const {
return emission_normals;
}
Vector<Color> CPUParticles2D::get_emission_colors() const {
-
return emission_colors;
}
CPUParticles2D::EmissionShape CPUParticles2D::get_emission_shape() const {
return emission_shape;
}
-void CPUParticles2D::set_gravity(const Vector2 &p_gravity) {
+void CPUParticles2D::set_gravity(const Vector2 &p_gravity) {
gravity = p_gravity;
}
Vector2 CPUParticles2D::get_gravity() const {
-
return gravity;
}
void CPUParticles2D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "color" && color_ramp.is_valid()) {
property.usage = 0;
}
@@ -538,7 +505,6 @@ void CPUParticles2D::_validate_property(PropertyInfo &property) const {
}
static uint32_t idhash(uint32_t x) {
-
x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b);
x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b);
x = (x >> uint32_t(16)) ^ x;
@@ -548,18 +514,19 @@ static uint32_t idhash(uint32_t x) {
static float rand_from_seed(uint32_t &seed) {
int k;
int s = int(seed);
- if (s == 0)
+ if (s == 0) {
s = 305420679;
+ }
k = s / 127773;
s = 16807 * (s - k * 127773) - 2836 * k;
- if (s < 0)
+ if (s < 0) {
s += 2147483647;
+ }
seed = uint32_t(s);
return float(seed % uint32_t(65536)) / 65535.0;
}
void CPUParticles2D::_update_internal() {
-
if (particles.size() == 0 || !is_visible_in_tree()) {
_set_redraw(false);
return;
@@ -585,12 +552,12 @@ void CPUParticles2D::_update_internal() {
_set_redraw(true);
if (time == 0 && pre_process_time > 0.0) {
-
float frame_time;
- if (fixed_fps > 0)
+ if (fixed_fps > 0) {
frame_time = 1.0 / fixed_fps;
- else
+ } else {
frame_time = 1.0 / 30.0;
+ }
float todo = pre_process_time;
@@ -627,7 +594,6 @@ void CPUParticles2D::_update_internal() {
}
void CPUParticles2D::_particles_process(float p_delta) {
-
p_delta *= speed_scale;
int pcount = particles.size();
@@ -657,11 +623,11 @@ void CPUParticles2D::_particles_process(float p_delta) {
float system_phase = time / lifetime;
for (int i = 0; i < pcount; i++) {
-
Particle &p = parray[i];
- if (!emitting && !p.active)
+ if (!emitting && !p.active) {
continue;
+ }
float local_delta = p_delta;
@@ -715,7 +681,6 @@ void CPUParticles2D::_particles_process(float p_delta) {
}
if (restart) {
-
if (!emitting) {
p.active = false;
continue;
@@ -774,10 +739,10 @@ void CPUParticles2D::_particles_process(float p_delta) {
} break;
case EMISSION_SHAPE_POINTS:
case EMISSION_SHAPE_DIRECTED_POINTS: {
-
int pc = emission_points.size();
- if (pc == 0)
+ if (pc == 0) {
break;
+ }
int random_idx = Math::rand() % pc;
@@ -806,7 +771,6 @@ void CPUParticles2D::_particles_process(float p_delta) {
} else if (p.time > p.lifetime) {
p.active = false;
} else {
-
uint32_t alt_seed = p.seed;
p.time += local_delta;
@@ -890,7 +854,6 @@ void CPUParticles2D::_particles_process(float p_delta) {
}
if (parameters[PARAM_DAMPING] + tex_damping > 0.0) {
-
float v = p.velocity.length();
float damp = (parameters[PARAM_DAMPING] + tex_damping) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_DAMPING]);
v -= damp * local_delta;
@@ -949,7 +912,6 @@ void CPUParticles2D::_particles_process(float p_delta) {
if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
if (p.velocity.length() > 0.0) {
-
p.transform.elements[1] = p.velocity.normalized();
p.transform.elements[0] = p.transform.elements[1].tangent();
}
@@ -961,8 +923,9 @@ void CPUParticles2D::_particles_process(float p_delta) {
//scale by scale
float base_scale = tex_scale * Math::lerp(parameters[PARAM_SCALE], 1.0f, p.scale_rand * randomness[PARAM_SCALE]);
- if (base_scale < 0.000001)
+ if (base_scale < 0.000001) {
base_scale = 0.000001;
+ }
p.transform.elements[0] *= base_scale;
p.transform.elements[1] *= base_scale;
@@ -998,7 +961,6 @@ void CPUParticles2D::_update_particle_data_buffer() {
}
for (int i = 0; i < pc; i++) {
-
int idx = order ? order[i] : i;
Transform2D t = r[idx].transform;
@@ -1008,7 +970,6 @@ void CPUParticles2D::_update_particle_data_buffer() {
}
if (r[idx].active) {
-
ptr[0] = t.elements[0][0];
ptr[1] = t.elements[1][0];
ptr[2] = 0;
@@ -1039,8 +1000,9 @@ void CPUParticles2D::_update_particle_data_buffer() {
}
void CPUParticles2D::_set_redraw(bool p_redraw) {
- if (redraw == p_redraw)
+ if (redraw == p_redraw) {
return;
+ }
redraw = p_redraw;
{
@@ -1065,14 +1027,12 @@ void CPUParticles2D::_set_redraw(bool p_redraw) {
}
void CPUParticles2D::_update_render_thread() {
-
MutexLock lock(update_mutex);
RS::get_singleton()->multimesh_set_buffer(multimesh, particle_data);
}
void CPUParticles2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
set_process_internal(emitting);
}
@@ -1083,11 +1043,13 @@ void CPUParticles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
// first update before rendering to avoid one frame delay after emitting starts
- if (emitting && (time == 0))
+ if (emitting && (time == 0)) {
_update_internal();
+ }
- if (!redraw)
+ if (!redraw) {
return; // don't add to render list
+ }
RID texrid;
if (texture.is_valid()) {
@@ -1107,11 +1069,9 @@ void CPUParticles2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
-
inv_emission_transform = get_global_transform().affine_inverse();
if (!local_coords) {
-
int pc = particles.size();
float *w = particle_data.ptrw();
@@ -1119,11 +1079,9 @@ void CPUParticles2D::_notification(int p_what) {
float *ptr = w;
for (int i = 0; i < pc; i++) {
-
Transform2D t = inv_emission_transform * r[i].transform;
if (r[i].active) {
-
ptr[0] = t.elements[0][0];
ptr[1] = t.elements[1][0];
ptr[2] = 0;
@@ -1144,7 +1102,6 @@ void CPUParticles2D::_notification(int p_what) {
}
void CPUParticles2D::convert_from_particles(Node *p_particles) {
-
GPUParticles2D *particles = Object::cast_to<GPUParticles2D>(p_particles);
ERR_FAIL_COND_MSG(!particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D.");
@@ -1168,8 +1125,9 @@ void CPUParticles2D::convert_from_particles(Node *p_particles) {
}
Ref<ParticlesMaterial> material = particles->get_process_material();
- if (material.is_null())
+ if (material.is_null()) {
return;
+ }
Vector3 dir = material->get_direction();
set_direction(Vector2(dir.x, dir.y));
@@ -1219,7 +1177,6 @@ void CPUParticles2D::convert_from_particles(Node *p_particles) {
}
void CPUParticles2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles2D::set_emitting);
ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles2D::set_amount);
ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles2D::set_lifetime);
@@ -1422,7 +1379,6 @@ void CPUParticles2D::_bind_methods() {
}
CPUParticles2D::CPUParticles2D() {
-
time = 0;
inactive_time = 0;
frame_remainder = 0;
diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h
index 18d0caceed..747f06b90d 100644
--- a/scene/2d/cpu_particles_2d.h
+++ b/scene/2d/cpu_particles_2d.h
@@ -124,7 +124,6 @@ private:
const Particle *particles;
Vector2 axis;
bool operator()(int p_a, int p_b) const {
-
return axis.dot(particles[p_a].transform[2]) < axis.dot(particles[p_b].transform[2]);
}
};
diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp
index de3f8fa09e..0814fbb549 100644
--- a/scene/2d/gpu_particles_2d.cpp
+++ b/scene/2d/gpu_particles_2d.cpp
@@ -39,7 +39,6 @@
#endif
void GPUParticles2D::set_emitting(bool p_emitting) {
-
RS::get_singleton()->particles_set_emitting(particles, p_emitting);
if (p_emitting && one_shot) {
@@ -50,50 +49,49 @@ void GPUParticles2D::set_emitting(bool p_emitting) {
}
void GPUParticles2D::set_amount(int p_amount) {
-
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1.");
amount = p_amount;
RS::get_singleton()->particles_set_amount(particles, amount);
}
-void GPUParticles2D::set_lifetime(float p_lifetime) {
+void GPUParticles2D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
RS::get_singleton()->particles_set_lifetime(particles, lifetime);
}
void GPUParticles2D::set_one_shot(bool p_enable) {
-
one_shot = p_enable;
RS::get_singleton()->particles_set_one_shot(particles, one_shot);
if (is_emitting()) {
-
set_process_internal(true);
- if (!one_shot)
+ if (!one_shot) {
RenderingServer::get_singleton()->particles_restart(particles);
+ }
}
- if (!one_shot)
+ if (!one_shot) {
set_process_internal(false);
+ }
}
-void GPUParticles2D::set_pre_process_time(float p_time) {
+void GPUParticles2D::set_pre_process_time(float p_time) {
pre_process_time = p_time;
RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
}
-void GPUParticles2D::set_explosiveness_ratio(float p_ratio) {
+void GPUParticles2D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
}
-void GPUParticles2D::set_randomness_ratio(float p_ratio) {
+void GPUParticles2D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
-void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
+void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
visibility_rect = p_visibility_rect;
AABB aabb;
aabb.position.x = p_visibility_rect.position.x;
@@ -106,8 +104,8 @@ void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) {
_change_notify("visibility_rect");
update();
}
-void GPUParticles2D::set_use_local_coordinates(bool p_enable) {
+void GPUParticles2D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
set_notify_transform(!p_enable);
@@ -117,7 +115,6 @@ void GPUParticles2D::set_use_local_coordinates(bool p_enable) {
}
void GPUParticles2D::_update_particle_emission_transform() {
-
Transform2D xf2d = get_global_transform();
Transform xf;
xf.basis.set_axis(0, Vector3(xf2d.get_axis(0).x, xf2d.get_axis(0).y, 0));
@@ -128,7 +125,6 @@ void GPUParticles2D::_update_particle_emission_transform() {
}
void GPUParticles2D::set_process_material(const Ref<Material> &p_material) {
-
process_material = p_material;
Ref<ParticlesMaterial> pm = p_material;
if (pm.is_valid() && !pm->get_flag(ParticlesMaterial::FLAG_DISABLE_Z) && pm->get_gravity() == Vector3(0, -9.8, 0)) {
@@ -137,74 +133,69 @@ void GPUParticles2D::set_process_material(const Ref<Material> &p_material) {
pm->set_gravity(Vector3(0, 98, 0));
}
RID material_rid;
- if (process_material.is_valid())
+ if (process_material.is_valid()) {
material_rid = process_material->get_rid();
+ }
RS::get_singleton()->particles_set_process_material(particles, material_rid);
update_configuration_warning();
}
void GPUParticles2D::set_speed_scale(float p_scale) {
-
speed_scale = p_scale;
RS::get_singleton()->particles_set_speed_scale(particles, p_scale);
}
bool GPUParticles2D::is_emitting() const {
-
return RS::get_singleton()->particles_get_emitting(particles);
}
-int GPUParticles2D::get_amount() const {
+int GPUParticles2D::get_amount() const {
return amount;
}
-float GPUParticles2D::get_lifetime() const {
+float GPUParticles2D::get_lifetime() const {
return lifetime;
}
bool GPUParticles2D::get_one_shot() const {
-
return one_shot;
}
-float GPUParticles2D::get_pre_process_time() const {
+float GPUParticles2D::get_pre_process_time() const {
return pre_process_time;
}
-float GPUParticles2D::get_explosiveness_ratio() const {
+float GPUParticles2D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float GPUParticles2D::get_randomness_ratio() const {
+float GPUParticles2D::get_randomness_ratio() const {
return randomness_ratio;
}
-Rect2 GPUParticles2D::get_visibility_rect() const {
+Rect2 GPUParticles2D::get_visibility_rect() const {
return visibility_rect;
}
-bool GPUParticles2D::get_use_local_coordinates() const {
+bool GPUParticles2D::get_use_local_coordinates() const {
return local_coords;
}
-Ref<Material> GPUParticles2D::get_process_material() const {
+Ref<Material> GPUParticles2D::get_process_material() const {
return process_material;
}
float GPUParticles2D::get_speed_scale() const {
-
return speed_scale;
}
void GPUParticles2D::set_draw_order(DrawOrder p_order) {
-
draw_order = p_order;
RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order));
}
GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const {
-
return draw_order;
}
@@ -227,7 +218,6 @@ bool GPUParticles2D::get_fractional_delta() const {
}
String GPUParticles2D::get_configuration_warning() const {
-
if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles2D\" option for this purpose.");
}
@@ -235,11 +225,11 @@ String GPUParticles2D::get_configuration_warning() const {
String warnings;
if (process_material.is_null()) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("A material to process the particles is not assigned, so no behavior is imprinted.");
} else {
-
CanvasItemMaterial *mat = Object::cast_to<CanvasItemMaterial>(get_material().ptr());
if (get_material().is_null() || (mat && !mat->get_particles_animation())) {
@@ -247,8 +237,9 @@ String GPUParticles2D::get_configuration_warning() const {
if (process &&
(process->get_param(ParticlesMaterial::PARAM_ANIM_SPEED) != 0.0 || process->get_param(ParticlesMaterial::PARAM_ANIM_OFFSET) != 0.0 ||
process->get_param_texture(ParticlesMaterial::PARAM_ANIM_SPEED).is_valid() || process->get_param_texture(ParticlesMaterial::PARAM_ANIM_OFFSET).is_valid())) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Particles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled.");
}
}
@@ -258,7 +249,6 @@ String GPUParticles2D::get_configuration_warning() const {
}
Rect2 GPUParticles2D::capture_rect() const {
-
AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles);
Rect2 r;
r.position.x = aabb.position.x;
@@ -278,7 +268,6 @@ Ref<Texture2D> GPUParticles2D::get_texture() const {
}
void GPUParticles2D::set_normal_map(const Ref<Texture2D> &p_normal_map) {
-
normal_map = p_normal_map;
update();
}
@@ -296,21 +285,20 @@ void GPUParticles2D::restart() {
}
void GPUParticles2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
RID texture_rid;
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture_rid = texture->get_rid();
+ }
RID normal_rid;
- if (normal_map.is_valid())
+ if (normal_map.is_valid()) {
normal_rid = normal_map->get_rid();
+ }
RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid);
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
-
draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
}
#endif
@@ -320,7 +308,6 @@ void GPUParticles2D::_notification(int p_what) {
if (can_process()) {
RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
} else {
-
RS::get_singleton()->particles_set_speed_scale(particles, 0);
}
}
@@ -330,7 +317,6 @@ void GPUParticles2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
-
if (one_shot && !is_emitting()) {
_change_notify();
set_process_internal(false);
@@ -339,7 +325,6 @@ void GPUParticles2D::_notification(int p_what) {
}
void GPUParticles2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles2D::set_emitting);
ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles2D::set_amount);
ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles2D::set_lifetime);
@@ -407,7 +392,6 @@ void GPUParticles2D::_bind_methods() {
}
GPUParticles2D::GPUParticles2D() {
-
particles = RS::get_singleton()->particles_create();
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
@@ -427,6 +411,5 @@ GPUParticles2D::GPUParticles2D() {
}
GPUParticles2D::~GPUParticles2D() {
-
RS::get_singleton()->free(particles);
}
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 4d49f4762f..8df72d7aac 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -35,10 +35,10 @@
#include "servers/physics_server_2d.h"
void Joint2D::_update_joint(bool p_only_free) {
-
if (joint.is_valid()) {
- if (ba.is_valid() && bb.is_valid() && exclude_from_collision)
+ if (ba.is_valid() && bb.is_valid() && exclude_from_collision) {
PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, false);
+ }
PhysicsServer2D::get_singleton()->free(joint);
joint = RID();
@@ -46,25 +46,29 @@ void Joint2D::_update_joint(bool p_only_free) {
bb = RID();
}
- if (p_only_free || !is_inside_tree())
+ if (p_only_free || !is_inside_tree()) {
return;
+ }
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr;
- if (!node_a || !node_b)
+ if (!node_a || !node_b) {
return;
+ }
PhysicsBody2D *body_a = Object::cast_to<PhysicsBody2D>(node_a);
PhysicsBody2D *body_b = Object::cast_to<PhysicsBody2D>(node_b);
- if (!body_a || !body_b)
+ if (!body_a || !body_b) {
return;
+ }
joint = _configure_joint(body_a, body_b);
- if (!joint.is_valid())
+ if (!joint.is_valid()) {
return;
+ }
PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias);
@@ -75,35 +79,32 @@ void Joint2D::_update_joint(bool p_only_free) {
}
void Joint2D::set_node_a(const NodePath &p_node_a) {
-
- if (a == p_node_a)
+ if (a == p_node_a) {
return;
+ }
a = p_node_a;
_update_joint();
}
NodePath Joint2D::get_node_a() const {
-
return a;
}
void Joint2D::set_node_b(const NodePath &p_node_b) {
-
- if (b == p_node_b)
+ if (b == p_node_b) {
return;
+ }
b = p_node_b;
_update_joint();
}
-NodePath Joint2D::get_node_b() const {
+NodePath Joint2D::get_node_b() const {
return b;
}
void Joint2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
_update_joint();
} break;
@@ -116,21 +117,20 @@ void Joint2D::_notification(int p_what) {
}
void Joint2D::set_bias(real_t p_bias) {
-
bias = p_bias;
- if (joint.is_valid())
+ if (joint.is_valid()) {
PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias);
+ }
}
real_t Joint2D::get_bias() const {
-
return bias;
}
void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
-
- if (exclude_from_collision == p_enable)
+ if (exclude_from_collision == p_enable) {
return;
+ }
_update_joint(true);
exclude_from_collision = p_enable;
@@ -138,12 +138,10 @@ void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
}
bool Joint2D::get_exclude_nodes_from_collision() const {
-
return exclude_from_collision;
}
void Joint2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint2D::set_node_a);
ClassDB::bind_method(D_METHOD("get_node_a"), &Joint2D::get_node_a);
@@ -163,7 +161,6 @@ void Joint2D::_bind_methods() {
}
Joint2D::Joint2D() {
-
bias = 0;
exclude_from_collision = true;
}
@@ -173,12 +170,11 @@ Joint2D::Joint2D() {
///////////////////////////////////////////////////////////////////////////////
void PinJoint2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
@@ -191,27 +187,24 @@ void PinJoint2D::_notification(int p_what) {
}
RID PinJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
-
RID pj = PhysicsServer2D::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
PhysicsServer2D::get_singleton()->pin_joint_set_param(pj, PhysicsServer2D::PIN_JOINT_SOFTNESS, softness);
return pj;
}
void PinJoint2D::set_softness(real_t p_softness) {
-
softness = p_softness;
update();
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer2D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness);
+ }
}
real_t PinJoint2D::get_softness() const {
-
return softness;
}
void PinJoint2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_softness", "softness"), &PinJoint2D::set_softness);
ClassDB::bind_method(D_METHOD("get_softness"), &PinJoint2D::get_softness);
@@ -219,7 +212,6 @@ void PinJoint2D::_bind_methods() {
}
PinJoint2D::PinJoint2D() {
-
softness = 0;
}
@@ -228,11 +220,11 @@ PinJoint2D::PinJoint2D() {
///////////////////////////////////////////////////////////////////////////////
void GrooveJoint2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
@@ -247,7 +239,6 @@ void GrooveJoint2D::_notification(int p_what) {
}
RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
-
Transform2D gt = get_global_transform();
Vector2 groove_A1 = gt.get_origin();
Vector2 groove_A2 = gt.xform(Vector2(0, length));
@@ -257,29 +248,24 @@ RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b
}
void GrooveJoint2D::set_length(real_t p_length) {
-
length = p_length;
update();
}
real_t GrooveJoint2D::get_length() const {
-
return length;
}
void GrooveJoint2D::set_initial_offset(real_t p_initial_offset) {
-
initial_offset = p_initial_offset;
update();
}
real_t GrooveJoint2D::get_initial_offset() const {
-
return initial_offset;
}
void GrooveJoint2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_length", "length"), &GrooveJoint2D::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &GrooveJoint2D::get_length);
ClassDB::bind_method(D_METHOD("set_initial_offset", "offset"), &GrooveJoint2D::set_initial_offset);
@@ -290,7 +276,6 @@ void GrooveJoint2D::_bind_methods() {
}
GrooveJoint2D::GrooveJoint2D() {
-
length = 50;
initial_offset = 25;
}
@@ -300,12 +285,11 @@ GrooveJoint2D::GrooveJoint2D() {
///////////////////////////////////////////////////////////////////////////////
void DampedSpringJoint2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
@@ -319,72 +303,66 @@ void DampedSpringJoint2D::_notification(int p_what) {
}
RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) {
-
Transform2D gt = get_global_transform();
Vector2 anchor_A = gt.get_origin();
Vector2 anchor_B = gt.xform(Vector2(0, length));
RID dsj = PhysicsServer2D::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
- if (rest_length)
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_REST_LENGTH, rest_length);
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_STIFFNESS, stiffness);
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_DAMPING, damping);
+ if (rest_length) {
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(dsj, PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, rest_length);
+ }
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(dsj, PhysicsServer2D::DAMPED_SPRING_STIFFNESS, stiffness);
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(dsj, PhysicsServer2D::DAMPED_SPRING_DAMPING, damping);
return dsj;
}
void DampedSpringJoint2D::set_length(real_t p_length) {
-
length = p_length;
update();
}
real_t DampedSpringJoint2D::get_length() const {
-
return length;
}
void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
-
rest_length = p_rest_length;
update();
- if (get_joint().is_valid())
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
+ if (get_joint().is_valid()) {
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
+ }
}
real_t DampedSpringJoint2D::get_rest_length() const {
-
return rest_length;
}
void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
-
stiffness = p_stiffness;
update();
- if (get_joint().is_valid())
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_STIFFNESS, p_stiffness);
+ if (get_joint().is_valid()) {
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_STIFFNESS, p_stiffness);
+ }
}
real_t DampedSpringJoint2D::get_stiffness() const {
-
return stiffness;
}
void DampedSpringJoint2D::set_damping(real_t p_damping) {
-
damping = p_damping;
update();
- if (get_joint().is_valid())
- PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_DAMPING, p_damping);
+ if (get_joint().is_valid()) {
+ PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_DAMPING, p_damping);
+ }
}
real_t DampedSpringJoint2D::get_damping() const {
-
return damping;
}
void DampedSpringJoint2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_length", "length"), &DampedSpringJoint2D::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &DampedSpringJoint2D::get_length);
ClassDB::bind_method(D_METHOD("set_rest_length", "rest_length"), &DampedSpringJoint2D::set_rest_length);
@@ -401,7 +379,6 @@ void DampedSpringJoint2D::_bind_methods() {
}
DampedSpringJoint2D::DampedSpringJoint2D() {
-
length = 50;
rest_length = 0;
stiffness = 20;
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index f1750e56b6..9a3bea4407 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -36,7 +36,6 @@
class PhysicsBody2D;
class Joint2D : public Node2D {
-
GDCLASS(Joint2D, Node2D);
RID joint;
@@ -74,7 +73,6 @@ public:
};
class PinJoint2D : public Joint2D {
-
GDCLASS(PinJoint2D, Joint2D);
real_t softness;
@@ -92,7 +90,6 @@ public:
};
class GrooveJoint2D : public Joint2D {
-
GDCLASS(GrooveJoint2D, Joint2D);
real_t length;
@@ -114,7 +111,6 @@ public:
};
class DampedSpringJoint2D : public Joint2D {
-
GDCLASS(DampedSpringJoint2D, Joint2D);
real_t stiffness;
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index b3d54b81f8..1e7e9f6b6a 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -59,8 +59,9 @@ bool Light2D::_edit_use_pivot() const {
}
Rect2 Light2D::_edit_get_rect() const {
- if (texture.is_null())
+ if (texture.is_null()) {
return Rect2();
+ }
Size2 s = texture->get_size() * _scale;
return Rect2(texture_offset - s / 2.0, s);
@@ -72,17 +73,18 @@ bool Light2D::_edit_use_rect() const {
#endif
Rect2 Light2D::get_anchorable_rect() const {
- if (texture.is_null())
+ if (texture.is_null()) {
return Rect2();
+ }
Size2 s = texture->get_size() * _scale;
return Rect2(texture_offset - s / 2.0, s);
}
void Light2D::_update_light_visibility() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool editor_ok = true;
@@ -104,45 +106,39 @@ void Light2D::_update_light_visibility() {
}
void Light2D::set_enabled(bool p_enabled) {
-
enabled = p_enabled;
_update_light_visibility();
}
bool Light2D::is_enabled() const {
-
return enabled;
}
void Light2D::set_editor_only(bool p_editor_only) {
-
editor_only = p_editor_only;
_update_light_visibility();
}
bool Light2D::is_editor_only() const {
-
return editor_only;
}
void Light2D::set_texture(const Ref<Texture2D> &p_texture) {
-
texture = p_texture;
- if (texture.is_valid())
+ if (texture.is_valid()) {
RS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid());
- else
+ } else {
RS::get_singleton()->canvas_light_set_texture(canvas_light, RID());
+ }
update_configuration_warning();
}
Ref<Texture2D> Light2D::get_texture() const {
-
return texture;
}
void Light2D::set_texture_offset(const Vector2 &p_offset) {
-
texture_offset = p_offset;
RS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset);
item_rect_changed();
@@ -150,44 +146,37 @@ void Light2D::set_texture_offset(const Vector2 &p_offset) {
}
Vector2 Light2D::get_texture_offset() const {
-
return texture_offset;
}
void Light2D::set_color(const Color &p_color) {
-
color = p_color;
RS::get_singleton()->canvas_light_set_color(canvas_light, color);
}
-Color Light2D::get_color() const {
+Color Light2D::get_color() const {
return color;
}
void Light2D::set_height(float p_height) {
-
height = p_height;
RS::get_singleton()->canvas_light_set_height(canvas_light, height);
}
float Light2D::get_height() const {
-
return height;
}
void Light2D::set_energy(float p_energy) {
-
energy = p_energy;
RS::get_singleton()->canvas_light_set_energy(canvas_light, energy);
}
float Light2D::get_energy() const {
-
return energy;
}
void Light2D::set_texture_scale(float p_scale) {
-
_scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
if (_scale == 0) {
@@ -198,101 +187,87 @@ void Light2D::set_texture_scale(float p_scale) {
}
float Light2D::get_texture_scale() const {
-
return _scale;
}
void Light2D::set_z_range_min(int p_min_z) {
-
z_min = p_min_z;
RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
}
-int Light2D::get_z_range_min() const {
+int Light2D::get_z_range_min() const {
return z_min;
}
void Light2D::set_z_range_max(int p_max_z) {
-
z_max = p_max_z;
RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
}
-int Light2D::get_z_range_max() const {
+int Light2D::get_z_range_max() const {
return z_max;
}
void Light2D::set_layer_range_min(int p_min_layer) {
-
layer_min = p_min_layer;
RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
}
-int Light2D::get_layer_range_min() const {
+int Light2D::get_layer_range_min() const {
return layer_min;
}
void Light2D::set_layer_range_max(int p_max_layer) {
-
layer_max = p_max_layer;
RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
}
-int Light2D::get_layer_range_max() const {
+int Light2D::get_layer_range_max() const {
return layer_max;
}
void Light2D::set_item_cull_mask(int p_mask) {
-
item_mask = p_mask;
RS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light, item_mask);
}
int Light2D::get_item_cull_mask() const {
-
return item_mask;
}
void Light2D::set_item_shadow_cull_mask(int p_mask) {
-
item_shadow_mask = p_mask;
RS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light, item_shadow_mask);
}
int Light2D::get_item_shadow_cull_mask() const {
-
return item_shadow_mask;
}
void Light2D::set_mode(Mode p_mode) {
-
mode = p_mode;
RS::get_singleton()->canvas_light_set_mode(canvas_light, RS::CanvasLightMode(p_mode));
}
Light2D::Mode Light2D::get_mode() const {
-
return mode;
}
void Light2D::set_shadow_enabled(bool p_enabled) {
-
shadow = p_enabled;
RS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow);
}
-bool Light2D::is_shadow_enabled() const {
+bool Light2D::is_shadow_enabled() const {
return shadow;
}
void Light2D::set_shadow_buffer_size(int p_size) {
-
shadow_buffer_size = p_size;
RS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size);
}
int Light2D::get_shadow_buffer_size() const {
-
return shadow_buffer_size;
}
@@ -303,7 +278,6 @@ void Light2D::set_shadow_filter(ShadowFilter p_filter) {
}
Light2D::ShadowFilter Light2D::get_shadow_filter() const {
-
return shadow_filter;
}
@@ -317,31 +291,25 @@ Color Light2D::get_shadow_color() const {
}
void Light2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas());
_update_light_visibility();
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
-
RS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform());
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
_update_light_visibility();
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID());
_update_light_visibility();
}
}
String Light2D::get_configuration_warning() const {
-
if (!texture.is_valid()) {
return TTR("A texture with the shape of the light must be supplied to the \"Texture\" property.");
}
@@ -350,18 +318,15 @@ String Light2D::get_configuration_warning() const {
}
void Light2D::set_shadow_smooth(float p_amount) {
-
shadow_smooth = p_amount;
RS::get_singleton()->canvas_light_set_shadow_smooth(canvas_light, shadow_smooth);
}
float Light2D::get_shadow_smooth() const {
-
return shadow_smooth;
}
void Light2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &Light2D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &Light2D::is_enabled);
@@ -457,7 +422,6 @@ void Light2D::_bind_methods() {
}
Light2D::Light2D() {
-
canvas_light = RenderingServer::get_singleton()->canvas_light_create();
enabled = true;
editor_only = false;
@@ -482,6 +446,5 @@ Light2D::Light2D() {
}
Light2D::~Light2D() {
-
RenderingServer::get_singleton()->free(canvas_light);
}
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index 7134029441..0d5e8d674a 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class Light2D : public Node2D {
-
GDCLASS(Light2D, Node2D);
public:
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index bd1a820aec..023cfa6d03 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "light_occluder_2d.h"
+#include "core/math/geometry_2d.h"
#include "core/engine.h"
@@ -36,17 +37,17 @@
#ifdef TOOLS_ENABLED
Rect2 OccluderPolygon2D::_edit_get_rect() const {
-
if (rect_cache_dirty) {
if (closed) {
const Vector2 *r = polygon.ptr();
item_rect = Rect2();
for (int i = 0; i < polygon.size(); i++) {
Vector2 pos = r[i];
- if (i == 0)
+ if (i == 0) {
item_rect.position = pos;
- else
+ } else {
item_rect.expand_to(pos);
+ }
}
rect_cache_dirty = false;
} else {
@@ -67,16 +68,16 @@ Rect2 OccluderPolygon2D::_edit_get_rect() const {
}
bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
if (closed) {
- return Geometry::is_point_in_polygon(p_point, Variant(polygon));
+ return Geometry2D::is_point_in_polygon(p_point, Variant(polygon));
} else {
const real_t d = LINE_GRAB_WIDTH / 2 + p_tolerance;
const Vector2 *points = polygon.ptr();
for (int i = 0; i < polygon.size() - 1; i++) {
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, &points[i]);
- if (p.distance_to(p_point) <= d)
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
+ if (p.distance_to(p_point) <= d) {
return true;
+ }
}
return false;
@@ -85,7 +86,6 @@ bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double
#endif
void OccluderPolygon2D::set_polygon(const Vector<Vector2> &p_polygon) {
-
polygon = p_polygon;
rect_cache_dirty = true;
RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed);
@@ -93,43 +93,38 @@ void OccluderPolygon2D::set_polygon(const Vector<Vector2> &p_polygon) {
}
Vector<Vector2> OccluderPolygon2D::get_polygon() const {
-
return polygon;
}
void OccluderPolygon2D::set_closed(bool p_closed) {
-
- if (closed == p_closed)
+ if (closed == p_closed) {
return;
+ }
closed = p_closed;
- if (polygon.size())
+ if (polygon.size()) {
RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, polygon, closed);
+ }
emit_changed();
}
bool OccluderPolygon2D::is_closed() const {
-
return closed;
}
void OccluderPolygon2D::set_cull_mode(CullMode p_mode) {
-
cull = p_mode;
RS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, RS::CanvasOccluderPolygonCullMode(p_mode));
}
OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const {
-
return cull;
}
RID OccluderPolygon2D::get_rid() const {
-
return occ_polygon;
}
void OccluderPolygon2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_closed", "closed"), &OccluderPolygon2D::set_closed);
ClassDB::bind_method(D_METHOD("is_closed"), &OccluderPolygon2D::is_closed);
@@ -149,7 +144,6 @@ void OccluderPolygon2D::_bind_methods() {
}
OccluderPolygon2D::OccluderPolygon2D() {
-
occ_polygon = RS::get_singleton()->canvas_occluder_polygon_create();
closed = true;
cull = CULL_DISABLED;
@@ -157,40 +151,31 @@ OccluderPolygon2D::OccluderPolygon2D() {
}
OccluderPolygon2D::~OccluderPolygon2D() {
-
RS::get_singleton()->free(occ_polygon);
}
void LightOccluder2D::_poly_changed() {
-
#ifdef DEBUG_ENABLED
update();
#endif
}
void LightOccluder2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_CANVAS) {
-
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas());
RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
-
RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
}
if (p_what == NOTIFICATION_DRAW) {
-
if (Engine::get_singleton()->is_editor_hint()) {
-
if (occluder_polygon.is_valid()) {
-
Vector<Vector2> poly = occluder_polygon->get_polygon();
if (poly.size()) {
@@ -199,11 +184,9 @@ void LightOccluder2D::_notification(int p_what) {
color.push_back(Color(0, 0, 0, 0.6));
draw_polygon(Variant(poly), color);
} else {
-
int ps = poly.size();
const Vector2 *r = poly.ptr();
for (int i = 0; i < ps - 1; i++) {
-
draw_line(r[i], r[i + 1], Color(0, 0, 0, 0.6), 3);
}
}
@@ -213,61 +196,56 @@ void LightOccluder2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_CANVAS) {
-
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID());
}
}
#ifdef TOOLS_ENABLED
Rect2 LightOccluder2D::_edit_get_rect() const {
-
return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2();
}
bool LightOccluder2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) {
-
#ifdef DEBUG_ENABLED
- if (occluder_polygon.is_valid())
+ if (occluder_polygon.is_valid()) {
occluder_polygon->disconnect("changed", callable_mp(this, &LightOccluder2D::_poly_changed));
+ }
#endif
occluder_polygon = p_polygon;
- if (occluder_polygon.is_valid())
+ if (occluder_polygon.is_valid()) {
RS::get_singleton()->canvas_light_occluder_set_polygon(occluder, occluder_polygon->get_rid());
- else
+ } else {
RS::get_singleton()->canvas_light_occluder_set_polygon(occluder, RID());
+ }
#ifdef DEBUG_ENABLED
- if (occluder_polygon.is_valid())
+ if (occluder_polygon.is_valid()) {
occluder_polygon->connect("changed", callable_mp(this, &LightOccluder2D::_poly_changed));
+ }
update();
#endif
}
Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {
-
return occluder_polygon;
}
void LightOccluder2D::set_occluder_light_mask(int p_mask) {
-
mask = p_mask;
RS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask);
}
int LightOccluder2D::get_occluder_light_mask() const {
-
return mask;
}
String LightOccluder2D::get_configuration_warning() const {
-
if (!occluder_polygon.is_valid()) {
return TTR("An occluder polygon must be set (or drawn) for this occluder to take effect.");
}
@@ -280,7 +258,6 @@ String LightOccluder2D::get_configuration_warning() const {
}
void LightOccluder2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_occluder_polygon", "polygon"), &LightOccluder2D::set_occluder_polygon);
ClassDB::bind_method(D_METHOD("get_occluder_polygon"), &LightOccluder2D::get_occluder_polygon);
@@ -292,13 +269,11 @@ void LightOccluder2D::_bind_methods() {
}
LightOccluder2D::LightOccluder2D() {
-
occluder = RS::get_singleton()->canvas_light_occluder_create();
mask = 1;
set_notify_transform(true);
}
LightOccluder2D::~LightOccluder2D() {
-
RS::get_singleton()->free(occluder);
}
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
index 83702f2875..eba67edfe4 100644
--- a/scene/2d/light_occluder_2d.h
+++ b/scene/2d/light_occluder_2d.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class OccluderPolygon2D : public Resource {
-
GDCLASS(OccluderPolygon2D, Resource);
public:
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 43c54ffd17..b120b115b0 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -31,6 +31,7 @@
#include "line_2d.h"
#include "core/core_string_names.h"
+#include "core/math/geometry_2d.h"
#include "line_builder.h"
// Needed so we can bind functions
@@ -52,9 +53,9 @@ Line2D::Line2D() {
#ifdef TOOLS_ENABLED
Rect2 Line2D::_edit_get_rect() const {
-
- if (_points.size() == 0)
+ if (_points.size() == 0) {
return Rect2(0, 0, 0, 0);
+ }
Vector2 d = Vector2(_width, _width);
Rect2 aabb = Rect2(_points[0] - d, 2 * d);
for (int i = 1; i < _points.size(); i++) {
@@ -69,13 +70,13 @@ bool Line2D::_edit_use_rect() const {
}
bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
const real_t d = _width / 2 + p_tolerance;
const Vector2 *points = _points.ptr();
for (int i = 0; i < _points.size() - 1; i++) {
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, &points[i]);
- if (p.distance_to(p_point) <= d)
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, &points[i]);
+ if (p.distance_to(p_point) <= d) {
return true;
+ }
}
return false;
@@ -88,8 +89,9 @@ void Line2D::set_points(const Vector<Vector2> &p_points) {
}
void Line2D::set_width(float p_width) {
- if (p_width < 0.0)
+ if (p_width < 0.0) {
p_width = 0.0;
+ }
_width = p_width;
update();
}
@@ -168,7 +170,6 @@ Color Line2D::get_default_color() const {
}
void Line2D::set_gradient(const Ref<Gradient> &p_gradient) {
-
// Cleanup previous connection if any
if (_gradient.is_valid()) {
_gradient->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Line2D::_gradient_changed));
@@ -242,8 +243,9 @@ void Line2D::_notification(int p_what) {
}
void Line2D::set_sharp_limit(float p_limit) {
- if (p_limit < 0.f)
+ if (p_limit < 0.f) {
p_limit = 0.f;
+ }
_sharp_limit = p_limit;
update();
}
@@ -253,8 +255,9 @@ float Line2D::get_sharp_limit() const {
}
void Line2D::set_round_precision(int p_precision) {
- if (p_precision < 1)
+ if (p_precision < 1) {
p_precision = 1;
+ }
_round_precision = p_precision;
update();
}
@@ -273,8 +276,9 @@ bool Line2D::get_antialiased() const {
}
void Line2D::_draw() {
- if (_points.size() <= 1 || _width == 0.f)
+ if (_points.size() <= 1 || _width == 0.f) {
return;
+ }
// TODO Is this really needed?
// Copy points for faster access
@@ -350,7 +354,6 @@ void Line2D::_curve_changed() {
// static
void Line2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_points", "points"), &Line2D::set_points);
ClassDB::bind_method(D_METHOD("get_points"), &Line2D::get_points);
diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h
index 51706befdb..bccbcbdcb9 100644
--- a/scene/2d/line_2d.h
+++ b/scene/2d/line_2d.h
@@ -34,7 +34,6 @@
#include "node_2d.h"
class Line2D : public Node2D {
-
GDCLASS(Line2D, Node2D);
public:
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp
index 6b06f2227a..f1522dbaeb 100644
--- a/scene/2d/line_builder.cpp
+++ b/scene/2d/line_builder.cpp
@@ -53,8 +53,9 @@ static SegmentIntersectionResult segment_intersection(
float ub = (ab.x * (a.y - c.y) - ab.y * (a.x - c.x)) / div;
*out_intersection = a + ua * ab;
if (ua >= 0.f && ua <= 1.f &&
- ub >= 0.f && ub <= 1.f)
+ ub >= 0.f && ub <= 1.f) {
return SEGMENT_INTERSECT;
+ }
return SEGMENT_NO_INTERSECT;
}
@@ -117,7 +118,6 @@ void LineBuilder::clear_output() {
}
void LineBuilder::build() {
-
// Need at least 2 points to draw a line
if (points.size() < 2) {
clear_output();
@@ -158,28 +158,32 @@ void LineBuilder::build() {
//Adjust totalDistance.
// The line's outer length will be a little higher due to begin and end caps
if (begin_cap_mode == Line2D::LINE_CAP_BOX || begin_cap_mode == Line2D::LINE_CAP_ROUND) {
- if (retrieve_curve)
+ if (retrieve_curve) {
total_distance += width * curve->interpolate_baked(0.f) * 0.5f;
- else
+ } else {
total_distance += width * 0.5f;
+ }
}
if (end_cap_mode == Line2D::LINE_CAP_BOX || end_cap_mode == Line2D::LINE_CAP_ROUND) {
- if (retrieve_curve)
+ if (retrieve_curve) {
total_distance += width * curve->interpolate_baked(1.f) * 0.5f;
- else
+ } else {
total_distance += width * 0.5f;
+ }
}
}
- if (_interpolate_color)
+ if (_interpolate_color) {
color0 = gradient->get_color(0);
- else
+ } else {
colors.push_back(default_color);
+ }
float uvx0 = 0.f;
float uvx1 = 0.f;
- if (retrieve_curve)
+ if (retrieve_curve) {
width_factor = curve->interpolate_baked(0.f);
+ }
pos_up0 += u0 * hw * width_factor;
pos_down0 -= u0 * hw * width_factor;
@@ -220,7 +224,6 @@ void LineBuilder::build() {
// For each additional segment
for (int i = 1; i < len - 1; ++i) {
-
pos1 = points[i];
Vector2 pos2 = points[i + 1];
@@ -271,10 +274,10 @@ void LineBuilder::build() {
pos1 + inner_normal1, pos2 + inner_normal1,
&corner_pos_in);
- if (intersection_result == SEGMENT_INTERSECT)
+ if (intersection_result == SEGMENT_INTERSECT) {
// Inner parts of the segments intersect
corner_pos_out = 2.f * pos1 - corner_pos_in;
- else {
+ } else {
// No intersection, segments are either parallel or too sharp
corner_pos_in = pos1 + inner_normal0;
corner_pos_out = pos1 - inner_normal0;
@@ -359,7 +362,6 @@ void LineBuilder::build() {
// Add joint geometry
if (current_joint_mode != Line2D::LINE_JOINT_SHARP) {
-
/* ________________ cbegin
* / \
* / \
@@ -386,10 +388,11 @@ void LineBuilder::build() {
strip_add_arc(pos1, vbegin.angle_to(vend), orientation);
}
- if (intersection_result != SEGMENT_INTERSECT)
+ if (intersection_result != SEGMENT_INTERSECT) {
// In this case the joint is too corrputed to be re-used,
// start again the strip with fallback points
strip_begin(pos_up0, pos_down0, color1, uvx1);
+ }
}
}
// Last (or only) segment
@@ -541,7 +544,6 @@ void LineBuilder::strip_add_tri(Vector2 up, Orientation orientation) {
}
void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation orientation) {
-
// Take the two last vertices and extrude an arc made of triangles
// that all share one of the initial vertices
@@ -551,8 +553,9 @@ void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation o
float angle_step = Math_PI / static_cast<float>(round_precision);
float steps = Math::abs(angle_delta) / angle_step;
- if (angle_delta < 0.f)
+ if (angle_delta < 0.f) {
angle_step = -angle_step;
+ }
float t = Vector2(1, 0).angle_to(vbegin);
float end_angle = t + angle_delta;
@@ -570,7 +573,6 @@ void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation o
}
void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Color color, Rect2 uv_rect) {
-
// Make a standalone arc that doesn't use existing vertices,
// with undistorted UVs from within a square section
@@ -578,8 +580,9 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
float angle_step = Math_PI / static_cast<float>(round_precision);
float steps = Math::abs(angle_delta) / angle_step;
- if (angle_delta < 0.f)
+ if (angle_delta < 0.f) {
angle_step = -angle_step;
+ }
float t = Vector2(1, 0).angle_to(vbegin);
float end_angle = t + angle_delta;
@@ -590,10 +593,12 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
// Center vertice
int vi = vertices.size();
vertices.push_back(center);
- if (_interpolate_color)
+ if (_interpolate_color) {
colors.push_back(color);
- if (texture_mode != Line2D::LINE_TEXTURE_NONE)
+ }
+ if (texture_mode != Line2D::LINE_TEXTURE_NONE) {
uvs.push_back(interpolate(uv_rect, Vector2(0.5f, 0.5f)));
+ }
// Arc vertices
for (int ti = 0; ti < steps; ++ti, t += angle_step) {
@@ -601,8 +606,9 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
rpos = center + sc * radius;
vertices.push_back(rpos);
- if (_interpolate_color)
+ if (_interpolate_color) {
colors.push_back(color);
+ }
if (texture_mode != Line2D::LINE_TEXTURE_NONE) {
Vector2 tsc = Vector2(Math::cos(tt), Math::sin(tt));
uvs.push_back(interpolate(uv_rect, 0.5f * (tsc + Vector2(1.f, 1.f))));
@@ -614,8 +620,9 @@ void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Col
Vector2 sc = Vector2(Math::cos(end_angle), Math::sin(end_angle));
rpos = center + sc * radius;
vertices.push_back(rpos);
- if (_interpolate_color)
+ if (_interpolate_color) {
colors.push_back(color);
+ }
if (texture_mode != Line2D::LINE_TEXTURE_NONE) {
tt = tt_begin + angle_delta;
Vector2 tsc = Vector2(Math::cos(tt), Math::sin(tt));
diff --git a/scene/2d/mesh_instance_2d.cpp b/scene/2d/mesh_instance_2d.cpp
index 5e258be700..897595ad1f 100644
--- a/scene/2d/mesh_instance_2d.cpp
+++ b/scene/2d/mesh_instance_2d.cpp
@@ -31,7 +31,6 @@
#include "mesh_instance_2d.h"
void MeshInstance2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
if (mesh.is_valid()) {
draw_mesh(mesh, texture, normal_map);
@@ -40,7 +39,6 @@ void MeshInstance2D::_notification(int p_what) {
}
void MeshInstance2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance2D::set_mesh);
ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance2D::get_mesh);
@@ -58,20 +56,18 @@ void MeshInstance2D::_bind_methods() {
}
void MeshInstance2D::set_mesh(const Ref<Mesh> &p_mesh) {
-
mesh = p_mesh;
update();
}
Ref<Mesh> MeshInstance2D::get_mesh() const {
-
return mesh;
}
void MeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) {
-
- if (p_texture == texture)
+ if (p_texture == texture) {
return;
+ }
texture = p_texture;
update();
emit_signal("texture_changed");
@@ -79,24 +75,20 @@ void MeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) {
}
void MeshInstance2D::set_normal_map(const Ref<Texture2D> &p_texture) {
-
normal_map = p_texture;
update();
}
Ref<Texture2D> MeshInstance2D::get_normal_map() const {
-
return normal_map;
}
Ref<Texture2D> MeshInstance2D::get_texture() const {
-
return texture;
}
#ifdef TOOLS_ENABLED
Rect2 MeshInstance2D::_edit_get_rect() const {
-
if (mesh.is_valid()) {
AABB aabb = mesh->get_aabb();
return Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp
index 6620027020..b99c0a3fa9 100644
--- a/scene/2d/multimesh_instance_2d.cpp
+++ b/scene/2d/multimesh_instance_2d.cpp
@@ -31,7 +31,6 @@
#include "multimesh_instance_2d.h"
void MultiMeshInstance2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
if (multimesh.is_valid()) {
draw_multimesh(multimesh, texture, normal_map);
@@ -40,7 +39,6 @@ void MultiMeshInstance2D::_notification(int p_what) {
}
void MultiMeshInstance2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance2D::set_multimesh);
ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance2D::get_multimesh);
@@ -58,20 +56,18 @@ void MultiMeshInstance2D::_bind_methods() {
}
void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
-
multimesh = p_multimesh;
update();
}
Ref<MultiMesh> MultiMeshInstance2D::get_multimesh() const {
-
return multimesh;
}
void MultiMeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) {
-
- if (p_texture == texture)
+ if (p_texture == texture) {
return;
+ }
texture = p_texture;
update();
emit_signal("texture_changed");
@@ -79,24 +75,20 @@ void MultiMeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) {
}
Ref<Texture2D> MultiMeshInstance2D::get_texture() const {
-
return texture;
}
void MultiMeshInstance2D::set_normal_map(const Ref<Texture2D> &p_texture) {
-
normal_map = p_texture;
update();
}
Ref<Texture2D> MultiMeshInstance2D::get_normal_map() const {
-
return normal_map;
}
#ifdef TOOLS_ENABLED
Rect2 MultiMeshInstance2D::_edit_get_rect() const {
-
if (multimesh.is_valid()) {
AABB aabb = multimesh->get_aabb();
return Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp
index ae9fc0f32c..039c6f2e53 100644
--- a/scene/2d/navigation_2d.cpp
+++ b/scene/2d/navigation_2d.cpp
@@ -54,7 +54,6 @@ void Navigation2D::_notification(int p_what) {
NavigationServer2D::get_singleton()->map_set_active(map, true);
} break;
case NOTIFICATION_EXIT_TREE: {
-
NavigationServer2D::get_singleton()->map_set_active(map, false);
} break;
}
@@ -83,7 +82,6 @@ RID Navigation2D::get_closest_point_owner(const Vector2 &p_point) const {
}
Navigation2D::Navigation2D() {
-
map = NavigationServer2D::get_singleton()->map_create();
set_cell_size(10); // Ten pixels
set_edge_connection_margin(100);
diff --git a/scene/2d/navigation_2d.h b/scene/2d/navigation_2d.h
index 1da13fc78a..6046bddb32 100644
--- a/scene/2d/navigation_2d.h
+++ b/scene/2d/navigation_2d.h
@@ -35,7 +35,6 @@
#include "scene/2d/node_2d.h"
class Navigation2D : public Node2D {
-
GDCLASS(Navigation2D, Node2D);
RID map;
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index df23a40721..e5cdade4a4 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -31,11 +31,11 @@
#include "navigation_agent_2d.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "scene/2d/navigation_2d.h"
#include "servers/navigation_server_2d.h"
void NavigationAgent2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent2D::set_target_desired_distance);
ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent2D::get_target_desired_distance);
@@ -91,7 +91,6 @@ void NavigationAgent2D::_bind_methods() {
void NavigationAgent2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
-
agent_parent = Object::cast_to<Node2D>(get_parent());
NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
@@ -102,10 +101,11 @@ void NavigationAgent2D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation2D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -120,7 +120,6 @@ void NavigationAgent2D::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent) {
-
NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin());
if (!target_reached) {
if (distance_to_target() < target_desired_distance) {
@@ -133,15 +132,7 @@ void NavigationAgent2D::_notification(int p_what) {
}
}
-NavigationAgent2D::NavigationAgent2D() :
- agent_parent(nullptr),
- navigation(nullptr),
- agent(RID()),
- target_desired_distance(1.0),
- path_max_distance(3.0),
- velocity_submitted(false),
- target_reached(false),
- navigation_finished(true) {
+NavigationAgent2D::NavigationAgent2D() {
agent = NavigationServer2D::get_singleton()->agent_create();
set_neighbor_dist(500.0);
set_max_neighbors(10);
@@ -156,8 +147,9 @@ NavigationAgent2D::~NavigationAgent2D() {
}
void NavigationAgent2D::set_navigation(Navigation2D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -287,13 +279,15 @@ String NavigationAgent2D::get_configuration_warning() const {
}
void NavigationAgent2D::update_navigation() {
-
- if (agent_parent == nullptr)
+ if (agent_parent == nullptr) {
return;
- if (navigation == nullptr)
+ }
+ if (navigation == nullptr) {
return;
- if (update_frame_id == Engine::get_singleton()->get_physics_frames())
+ }
+ if (update_frame_id == Engine::get_singleton()->get_physics_frames()) {
return;
+ }
update_frame_id = Engine::get_singleton()->get_physics_frames();
@@ -311,7 +305,7 @@ void NavigationAgent2D::update_navigation() {
Vector2 segment[2];
segment[0] = navigation_path[nav_path_index - 1];
segment[1] = navigation_path[nav_path_index];
- Vector2 p = Geometry::get_closest_point_to_segment_2d(o, segment);
+ Vector2 p = Geometry2D::get_closest_point_to_segment(o, segment);
if (o.distance_to(p) >= path_max_distance) {
// To faraway, reload path
reload_path = true;
@@ -326,8 +320,9 @@ void NavigationAgent2D::update_navigation() {
emit_signal("path_changed");
}
- if (navigation_path.size() == 0)
+ if (navigation_path.size() == 0) {
return;
+ }
// Check if we can advance the navigation path
if (navigation_finished == false) {
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 26eccfc949..796a85f3f2 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -40,29 +40,29 @@ class Navigation2D;
class NavigationAgent2D : public Node {
GDCLASS(NavigationAgent2D, Node);
- Node2D *agent_parent;
- Navigation2D *navigation;
+ Node2D *agent_parent = nullptr;
+ Navigation2D *navigation = nullptr;
RID agent;
- real_t target_desired_distance;
+ real_t target_desired_distance = 1.0;
real_t radius;
real_t neighbor_dist;
int max_neighbors;
real_t time_horizon;
real_t max_speed;
- real_t path_max_distance;
+ real_t path_max_distance = 3.0;
Vector2 target_location;
Vector<Vector2> navigation_path;
int nav_path_index;
- bool velocity_submitted;
+ bool velocity_submitted = false;
Vector2 prev_safe_velocity;
/// The submitted target velocity
Vector2 target_velocity;
- bool target_reached;
- bool navigation_finished;
+ bool target_reached = false;
+ bool navigation_finished = true;
// No initialized on purpose
uint32_t update_frame_id;
diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp
index 50d02ca507..568023bbe2 100644
--- a/scene/2d/navigation_obstacle_2d.cpp
+++ b/scene/2d/navigation_obstacle_2d.cpp
@@ -36,7 +36,6 @@
#include "servers/navigation_server_2d.h"
void NavigationObstacle2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle2D::set_navigation_node);
ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle2D::get_navigation_node);
}
@@ -44,7 +43,6 @@ void NavigationObstacle2D::_bind_methods() {
void NavigationObstacle2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
-
update_agent_shape();
// Search the navigation node and set it
@@ -53,10 +51,11 @@ void NavigationObstacle2D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation2D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -78,9 +77,7 @@ void NavigationObstacle2D::_notification(int p_what) {
}
}
-NavigationObstacle2D::NavigationObstacle2D() :
- navigation(nullptr),
- agent(RID()) {
+NavigationObstacle2D::NavigationObstacle2D() {
agent = NavigationServer2D::get_singleton()->agent_create();
}
@@ -90,8 +87,9 @@ NavigationObstacle2D::~NavigationObstacle2D() {
}
void NavigationObstacle2D::set_navigation(Navigation2D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -142,8 +140,9 @@ void NavigationObstacle2D::update_agent_shape() {
radius *= MAX(s.x, s.y);
}
- if (radius == 0.0)
+ if (radius == 0.0) {
radius = 1.0; // Never a 0 radius
+ }
// Initialize the Agent as an object
NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
diff --git a/scene/2d/navigation_obstacle_2d.h b/scene/2d/navigation_obstacle_2d.h
index 3935fe1bc5..bdef6f2843 100644
--- a/scene/2d/navigation_obstacle_2d.h
+++ b/scene/2d/navigation_obstacle_2d.h
@@ -38,7 +38,7 @@ class Navigation2D;
class NavigationObstacle2D : public Node {
GDCLASS(NavigationObstacle2D, Node);
- Navigation2D *navigation;
+ Navigation2D *navigation = nullptr;
RID agent;
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index abbfbf83b7..671bda558d 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -32,6 +32,7 @@
#include "core/core_string_names.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "core/os/mutex.h"
#include "navigation_2d.h"
#include "servers/navigation_server_2d.h"
@@ -40,7 +41,6 @@
#ifdef TOOLS_ENABLED
Rect2 NavigationPolygon::_edit_get_rect() const {
-
if (rect_cache_dirty) {
item_rect = Rect2();
bool first = true;
@@ -48,8 +48,9 @@ Rect2 NavigationPolygon::_edit_get_rect() const {
for (int i = 0; i < outlines.size(); i++) {
const Vector<Vector2> &outline = outlines[i];
const int outline_size = outline.size();
- if (outline_size < 3)
+ if (outline_size < 3) {
continue;
+ }
const Vector2 *p = outline.ptr();
for (int j = 0; j < outline_size; j++) {
if (first) {
@@ -67,21 +68,21 @@ Rect2 NavigationPolygon::_edit_get_rect() const {
}
bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
for (int i = 0; i < outlines.size(); i++) {
const Vector<Vector2> &outline = outlines[i];
const int outline_size = outline.size();
- if (outline_size < 3)
+ if (outline_size < 3) {
continue;
- if (Geometry::is_point_in_polygon(p_point, Variant(outline)))
+ }
+ if (Geometry2D::is_point_in_polygon(p_point, Variant(outline))) {
return true;
+ }
}
return false;
}
#endif
void NavigationPolygon::set_vertices(const Vector<Vector2> &p_vertices) {
-
{
MutexLock lock(navmesh_generation);
navmesh.unref();
@@ -91,12 +92,10 @@ void NavigationPolygon::set_vertices(const Vector<Vector2> &p_vertices) {
}
Vector<Vector2> NavigationPolygon::get_vertices() const {
-
return vertices;
}
void NavigationPolygon::_set_polygons(const TypedArray<Vector<int32_t>> &p_array) {
-
{
MutexLock lock(navmesh_generation);
navmesh.unref();
@@ -108,7 +107,6 @@ void NavigationPolygon::_set_polygons(const TypedArray<Vector<int32_t>> &p_array
}
Array NavigationPolygon::_get_polygons() const {
-
Array ret;
ret.resize(polygons.size());
for (int i = 0; i < ret.size(); i++) {
@@ -119,7 +117,6 @@ Array NavigationPolygon::_get_polygons() const {
}
void NavigationPolygon::_set_outlines(const TypedArray<Vector<Vector2>> &p_array) {
-
outlines.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
outlines.write[i] = p_array[i];
@@ -128,7 +125,6 @@ void NavigationPolygon::_set_outlines(const TypedArray<Vector<Vector2>> &p_array
}
Array NavigationPolygon::_get_outlines() const {
-
Array ret;
ret.resize(outlines.size());
for (int i = 0; i < ret.size(); i++) {
@@ -139,7 +135,6 @@ Array NavigationPolygon::_get_outlines() const {
}
void NavigationPolygon::add_polygon(const Vector<int> &p_polygon) {
-
Polygon polygon;
polygon.indices = p_polygon;
polygons.push_back(polygon);
@@ -150,22 +145,20 @@ void NavigationPolygon::add_polygon(const Vector<int> &p_polygon) {
}
void NavigationPolygon::add_outline_at_index(const Vector<Vector2> &p_outline, int p_index) {
-
outlines.insert(p_index, p_outline);
rect_cache_dirty = true;
}
int NavigationPolygon::get_polygon_count() const {
-
return polygons.size();
}
-Vector<int> NavigationPolygon::get_polygon(int p_idx) {
+Vector<int> NavigationPolygon::get_polygon(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>());
return polygons[p_idx].indices;
}
-void NavigationPolygon::clear_polygons() {
+void NavigationPolygon::clear_polygons() {
polygons.clear();
{
MutexLock lock(navmesh_generation);
@@ -200,13 +193,11 @@ Ref<NavigationMesh> NavigationPolygon::get_mesh() {
}
void NavigationPolygon::add_outline(const Vector<Vector2> &p_outline) {
-
outlines.push_back(p_outline);
rect_cache_dirty = true;
}
int NavigationPolygon::get_outline_count() const {
-
return outlines.size();
}
@@ -217,7 +208,6 @@ void NavigationPolygon::set_outline(int p_idx, const Vector<Vector2> &p_outline)
}
void NavigationPolygon::remove_outline(int p_idx) {
-
ERR_FAIL_INDEX(p_idx, outlines.size());
outlines.remove(p_idx);
rect_cache_dirty = true;
@@ -229,12 +219,11 @@ Vector<Vector2> NavigationPolygon::get_outline(int p_idx) const {
}
void NavigationPolygon::clear_outlines() {
-
outlines.clear();
rect_cache_dirty = true;
}
-void NavigationPolygon::make_polygons_from_outlines() {
+void NavigationPolygon::make_polygons_from_outlines() {
{
MutexLock lock(navmesh_generation);
navmesh.unref();
@@ -244,11 +233,11 @@ void NavigationPolygon::make_polygons_from_outlines() {
Vector2 outside_point(-1e10, -1e10);
for (int i = 0; i < outlines.size(); i++) {
-
Vector<Vector2> ol = outlines[i];
int olsize = ol.size();
- if (olsize < 3)
+ if (olsize < 3) {
continue;
+ }
const Vector2 *r = ol.ptr();
for (int j = 0; j < olsize; j++) {
outside_point.x = MAX(r[j].x, outside_point.x);
@@ -259,29 +248,29 @@ void NavigationPolygon::make_polygons_from_outlines() {
outside_point += Vector2(0.7239784, 0.819238); //avoid precision issues
for (int i = 0; i < outlines.size(); i++) {
-
Vector<Vector2> ol = outlines[i];
int olsize = ol.size();
- if (olsize < 3)
+ if (olsize < 3) {
continue;
+ }
const Vector2 *r = ol.ptr();
int interscount = 0;
//test if this is an outer outline
for (int k = 0; k < outlines.size(); k++) {
-
- if (i == k)
+ if (i == k) {
continue; //no self intersect
+ }
Vector<Vector2> ol2 = outlines[k];
int olsize2 = ol2.size();
- if (olsize2 < 3)
+ if (olsize2 < 3) {
continue;
+ }
const Vector2 *r2 = ol2.ptr();
for (int l = 0; l < olsize2; l++) {
-
- if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) {
+ if (Geometry2D::segment_intersects_segment(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) {
interscount++;
}
}
@@ -295,9 +284,9 @@ void NavigationPolygon::make_polygons_from_outlines() {
tp[j] = r[j];
}
- if (outer)
+ if (outer) {
tp.SetOrientation(TRIANGULATOR_CCW);
- else {
+ } else {
tp.SetOrientation(TRIANGULATOR_CW);
tp.SetHole(true);
}
@@ -316,13 +305,11 @@ void NavigationPolygon::make_polygons_from_outlines() {
Map<Vector2, int> points;
for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
-
TriangulatorPoly &tp = I->get();
struct Polygon p;
for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
-
Map<Vector2, int>::Element *E = points.find(tp[i]);
if (!E) {
E = points.insert(tp[i], vertices.size());
@@ -338,7 +325,6 @@ void NavigationPolygon::make_polygons_from_outlines() {
}
void NavigationPolygon::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_vertices", "vertices"), &NavigationPolygon::set_vertices);
ClassDB::bind_method(D_METHOD("get_vertices"), &NavigationPolygon::get_vertices);
@@ -367,68 +353,52 @@ void NavigationPolygon::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "outlines", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_outlines", "_get_outlines");
}
-NavigationPolygon::NavigationPolygon() :
- rect_cache_dirty(true) {
-}
-
-NavigationPolygon::~NavigationPolygon() {
-}
-
void NavigationRegion2D::set_enabled(bool p_enabled) {
-
- if (enabled == p_enabled)
+ if (enabled == p_enabled) {
return;
+ }
enabled = p_enabled;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (!enabled) {
-
NavigationServer2D::get_singleton()->region_set_map(region, RID());
} else {
-
if (navigation) {
-
NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid());
}
}
- if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
+ if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) {
update();
+ }
}
bool NavigationRegion2D::is_enabled() const {
-
return enabled;
}
/////////////////////////////
#ifdef TOOLS_ENABLED
Rect2 NavigationRegion2D::_edit_get_rect() const {
-
return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2();
}
bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
void NavigationRegion2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
Node2D *c = this;
while (c) {
-
navigation = Object::cast_to<Navigation2D>(c);
if (navigation) {
-
if (enabled) {
-
NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid());
}
break;
@@ -439,26 +409,22 @@ void NavigationRegion2D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
NavigationServer2D::get_singleton()->region_set_transform(region, get_global_transform());
} break;
case NOTIFICATION_EXIT_TREE: {
-
if (navigation) {
-
NavigationServer2D::get_singleton()->region_set_map(region, RID());
}
navigation = nullptr;
} break;
case NOTIFICATION_DRAW: {
-
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
-
Vector<Vector2> verts = navpoly->get_vertices();
int vsize = verts.size();
- if (vsize < 3)
+ if (vsize < 3) {
return;
+ }
Color color;
if (enabled) {
@@ -484,10 +450,8 @@ void NavigationRegion2D::_notification(int p_what) {
Vector<int> polygon = navpoly->get_polygon(i);
for (int j = 2; j < polygon.size(); j++) {
-
int kofs[3] = { 0, j - 1, j };
for (int k = 0; k < 3; k++) {
-
int idx = polygon[kofs[k]];
ERR_FAIL_INDEX(idx, vsize);
indices.push_back(idx);
@@ -501,7 +465,6 @@ void NavigationRegion2D::_notification(int p_what) {
}
void NavigationRegion2D::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
-
if (p_navpoly == navpoly) {
return;
}
@@ -523,27 +486,25 @@ void NavigationRegion2D::set_navigation_polygon(const Ref<NavigationPolygon> &p_
}
Ref<NavigationPolygon> NavigationRegion2D::get_navigation_polygon() const {
-
return navpoly;
}
void NavigationRegion2D::_navpoly_changed() {
-
- if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) {
update();
+ }
}
String NavigationRegion2D::get_configuration_warning() const {
-
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
if (!navpoly.is_valid()) {
return TTR("A NavigationPolygon resource must be set or created for this node to work. Please set a property or draw a polygon.");
}
const Node2D *c = this;
while (c) {
-
if (Object::cast_to<Navigation2D>(c)) {
return String();
}
@@ -555,7 +516,6 @@ String NavigationRegion2D::get_configuration_warning() const {
}
void NavigationRegion2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navpoly"), &NavigationRegion2D::set_navigation_polygon);
ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationRegion2D::get_navigation_polygon);
@@ -569,12 +529,8 @@ void NavigationRegion2D::_bind_methods() {
}
NavigationRegion2D::NavigationRegion2D() {
-
- enabled = true;
set_notify_transform(true);
region = NavigationServer2D::get_singleton()->region_create();
-
- navigation = nullptr;
}
NavigationRegion2D::~NavigationRegion2D() {
diff --git a/scene/2d/navigation_region_2d.h b/scene/2d/navigation_region_2d.h
index e730df6373..07cf4d6668 100644
--- a/scene/2d/navigation_region_2d.h
+++ b/scene/2d/navigation_region_2d.h
@@ -35,7 +35,6 @@
#include "scene/resources/navigation_mesh.h"
class NavigationPolygon : public Resource {
-
GDCLASS(NavigationPolygon, Resource);
Vector<Vector2> vertices;
@@ -46,7 +45,7 @@ class NavigationPolygon : public Resource {
Vector<Vector<Vector2>> outlines;
mutable Rect2 item_rect;
- mutable bool rect_cache_dirty;
+ mutable bool rect_cache_dirty = true;
Mutex navmesh_generation;
// Navigation mesh
@@ -88,19 +87,18 @@ public:
Ref<NavigationMesh> get_mesh();
- NavigationPolygon();
- ~NavigationPolygon();
+ NavigationPolygon() {}
+ ~NavigationPolygon() {}
};
class Navigation2D;
class NavigationRegion2D : public Node2D {
-
GDCLASS(NavigationRegion2D, Node2D);
- bool enabled;
+ bool enabled = true;
RID region;
- Navigation2D *navigation;
+ Navigation2D *navigation = nullptr;
Ref<NavigationPolygon> navpoly;
void _navpoly_changed();
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 1ea51be148..72250e96b3 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -37,7 +37,6 @@
#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
-
Dictionary state;
state["position"] = get_position();
state["rotation"] = get_rotation();
@@ -48,7 +47,6 @@ Dictionary Node2D::_edit_get_state() const {
}
void Node2D::_edit_set_state(const Dictionary &p_state) {
-
pos = p_state["position"];
angle = p_state["rotation"];
_scale = p_state["scale"];
@@ -100,17 +98,21 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
Rect2 r = _edit_get_rect();
Vector2 zero_offset;
- if (r.size.x != 0)
+ if (r.size.x != 0) {
zero_offset.x = -r.position.x / r.size.x;
- if (r.size.y != 0)
+ }
+ if (r.size.y != 0) {
zero_offset.y = -r.position.y / r.size.y;
+ }
Size2 new_scale(1, 1);
- if (r.size.x != 0)
+ if (r.size.x != 0) {
new_scale.x = p_edit_rect.size.x / r.size.x;
- if (r.size.y != 0)
+ }
+ if (r.size.y != 0) {
new_scale.y = p_edit_rect.size.y / r.size.y;
+ }
Point2 new_pos = p_edit_rect.position + p_edit_rect.size * zero_offset;
@@ -128,7 +130,6 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
#endif
void Node2D::_update_xform_values() {
-
pos = _mat.elements[2];
angle = _mat.get_rotation();
_scale = _mat.get_scale();
@@ -137,31 +138,31 @@ void Node2D::_update_xform_values() {
}
void Node2D::_update_transform() {
-
_mat.set_rotation_scale_and_skew(angle, _scale, skew);
_mat.elements[2] = pos;
RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_notify_transform();
}
void Node2D::set_position(const Point2 &p_pos) {
-
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
pos = p_pos;
_update_transform();
_change_notify("position");
}
void Node2D::set_rotation(float p_radians) {
-
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
angle = p_radians;
_update_transform();
_change_notify("rotation");
@@ -169,9 +170,9 @@ void Node2D::set_rotation(float p_radians) {
}
void Node2D::set_skew(float p_radians) {
-
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
skew = p_radians;
_update_transform();
_change_notify("skew");
@@ -179,116 +180,111 @@ void Node2D::set_skew(float p_radians) {
}
void Node2D::set_rotation_degrees(float p_degrees) {
-
set_rotation(Math::deg2rad(p_degrees));
}
void Node2D::set_skew_degrees(float p_degrees) {
-
set_skew(Math::deg2rad(p_degrees));
}
void Node2D::set_scale(const Size2 &p_scale) {
-
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
_scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
- if (_scale.x == 0)
+ if (_scale.x == 0) {
_scale.x = CMP_EPSILON;
- if (_scale.y == 0)
+ }
+ if (_scale.y == 0) {
_scale.y = CMP_EPSILON;
+ }
_update_transform();
_change_notify("scale");
}
Point2 Node2D::get_position() const {
-
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
return pos;
}
float Node2D::get_rotation() const {
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
return angle;
}
float Node2D::get_skew() const {
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
return skew;
}
float Node2D::get_rotation_degrees() const {
-
return Math::rad2deg(get_rotation());
}
float Node2D::get_skew_degrees() const {
-
return Math::rad2deg(get_skew());
}
+
Size2 Node2D::get_scale() const {
- if (_xform_dirty)
+ if (_xform_dirty) {
((Node2D *)this)->_update_xform_values();
+ }
return _scale;
}
Transform2D Node2D::get_transform() const {
-
return _mat;
}
void Node2D::rotate(float p_radians) {
-
set_rotation(get_rotation() + p_radians);
}
void Node2D::translate(const Vector2 &p_amount) {
-
set_position(get_position() + p_amount);
}
void Node2D::global_translate(const Vector2 &p_amount) {
-
set_global_position(get_global_position() + p_amount);
}
void Node2D::apply_scale(const Size2 &p_amount) {
-
set_scale(get_scale() * p_amount);
}
void Node2D::move_x(float p_delta, bool p_scaled) {
-
Transform2D t = get_transform();
Vector2 m = t[0];
- if (!p_scaled)
+ if (!p_scaled) {
m.normalize();
+ }
set_position(t[2] + m * p_delta);
}
void Node2D::move_y(float p_delta, bool p_scaled) {
-
Transform2D t = get_transform();
Vector2 m = t[1];
- if (!p_scaled)
+ if (!p_scaled) {
m.normalize();
+ }
set_position(t[2] + m * p_delta);
}
Point2 Node2D::get_global_position() const {
-
return get_global_transform().get_origin();
}
void Node2D::set_global_position(const Point2 &p_pos) {
-
Transform2D inv;
CanvasItem *pi = get_parent_item();
if (pi) {
@@ -300,12 +296,10 @@ void Node2D::set_global_position(const Point2 &p_pos) {
}
float Node2D::get_global_rotation() const {
-
return get_global_transform().get_rotation();
}
void Node2D::set_global_rotation(float p_radians) {
-
CanvasItem *pi = get_parent_item();
if (pi) {
const float parent_global_rot = pi->get_global_transform().get_rotation();
@@ -316,22 +310,18 @@ void Node2D::set_global_rotation(float p_radians) {
}
float Node2D::get_global_rotation_degrees() const {
-
return Math::rad2deg(get_global_rotation());
}
void Node2D::set_global_rotation_degrees(float p_degrees) {
-
set_global_rotation(Math::deg2rad(p_degrees));
}
Size2 Node2D::get_global_scale() const {
-
return get_global_transform().get_scale();
}
void Node2D::set_global_scale(const Size2 &p_scale) {
-
CanvasItem *pi = get_parent_item();
if (pi) {
const Size2 parent_global_scale = pi->get_global_transform().get_scale();
@@ -342,29 +332,28 @@ void Node2D::set_global_scale(const Size2 &p_scale) {
}
void Node2D::set_transform(const Transform2D &p_transform) {
-
_mat = p_transform;
_xform_dirty = true;
RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_notify_transform();
}
void Node2D::set_global_transform(const Transform2D &p_transform) {
-
CanvasItem *pi = get_parent_item();
- if (pi)
+ if (pi) {
set_transform(pi->get_global_transform().affine_inverse() * p_transform);
- else
+ } else {
set_transform(p_transform);
+ }
}
void Node2D::set_z_index(int p_z) {
-
ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN);
ERR_FAIL_COND(p_z > RS::CANVAS_ITEM_Z_MAX);
z_index = p_z;
@@ -373,59 +362,53 @@ void Node2D::set_z_index(int p_z) {
}
void Node2D::set_z_as_relative(bool p_enabled) {
-
- if (z_relative == p_enabled)
+ if (z_relative == p_enabled) {
return;
+ }
z_relative = p_enabled;
RS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(), p_enabled);
}
bool Node2D::is_z_relative() const {
-
return z_relative;
}
int Node2D::get_z_index() const {
-
return z_index;
}
Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const {
-
- if (p_parent == this)
+ if (p_parent == this) {
return Transform2D();
+ }
Node2D *parent_2d = Object::cast_to<Node2D>(get_parent());
ERR_FAIL_COND_V(!parent_2d, Transform2D());
- if (p_parent == parent_2d)
+ if (p_parent == parent_2d) {
return get_transform();
- else
+ } else {
return parent_2d->get_relative_transform_to_parent(p_parent) * get_transform();
+ }
}
void Node2D::look_at(const Vector2 &p_pos) {
-
rotate(get_angle_to(p_pos));
}
float Node2D::get_angle_to(const Vector2 &p_pos) const {
-
return (to_local(p_pos) * get_scale()).angle();
}
Point2 Node2D::to_local(Point2 p_global) const {
-
return get_global_transform().affine_inverse().xform(p_global);
}
Point2 Node2D::to_global(Point2 p_local) const {
-
return get_global_transform().xform(p_local);
}
void Node2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position);
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation);
ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees);
@@ -494,7 +477,6 @@ void Node2D::_bind_methods() {
}
Node2D::Node2D() {
-
angle = 0;
_scale = Vector2(1, 1);
skew = 0;
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 0afec36254..827c192585 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -34,7 +34,6 @@
#include "scene/main/canvas_item.h"
class Node2D : public CanvasItem {
-
GDCLASS(Node2D, CanvasItem);
Point2 pos;
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 0d5f74a265..416622e6d5 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -32,24 +32,19 @@
#include "parallax_layer.h"
void ParallaxBackground::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
group_name = "__cameras_" + itos(get_viewport().get_id());
add_to_group(group_name);
} break;
case NOTIFICATION_EXIT_TREE: {
-
remove_from_group(group_name);
} break;
}
}
void ParallaxBackground::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset) {
-
screen_offset = p_screen_offset;
set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5)));
@@ -57,26 +52,23 @@ void ParallaxBackground::_camera_moved(const Transform2D &p_transform, const Poi
}
void ParallaxBackground::set_scroll_scale(float p_scale) {
-
scale = p_scale;
}
float ParallaxBackground::get_scroll_scale() const {
-
return scale;
}
void ParallaxBackground::set_scroll_offset(const Point2 &p_ofs) {
-
offset = p_ofs;
_update_scroll();
}
void ParallaxBackground::_update_scroll() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
Vector2 ofs = base_offset + offset * base_scale;
@@ -84,103 +76,91 @@ void ParallaxBackground::_update_scroll() {
ofs = -ofs;
if (limit_begin.x < limit_end.x) {
-
- if (ofs.x < limit_begin.x)
+ if (ofs.x < limit_begin.x) {
ofs.x = limit_begin.x;
- else if (ofs.x + vps.x > limit_end.x)
+ } else if (ofs.x + vps.x > limit_end.x) {
ofs.x = limit_end.x - vps.x;
+ }
}
if (limit_begin.y < limit_end.y) {
-
- if (ofs.y < limit_begin.y)
+ if (ofs.y < limit_begin.y) {
ofs.y = limit_begin.y;
- else if (ofs.y + vps.y > limit_end.y)
+ } else if (ofs.y + vps.y > limit_end.y) {
ofs.y = limit_end.y - vps.y;
+ }
}
ofs = -ofs;
final_offset = ofs;
for (int i = 0; i < get_child_count(); i++) {
-
ParallaxLayer *l = Object::cast_to<ParallaxLayer>(get_child(i));
- if (!l)
+ if (!l) {
continue;
+ }
- if (ignore_camera_zoom)
+ if (ignore_camera_zoom) {
l->set_base_offset_and_scale(ofs, 1.0, screen_offset);
- else
+ } else {
l->set_base_offset_and_scale(ofs, scale, screen_offset);
+ }
}
}
Point2 ParallaxBackground::get_scroll_offset() const {
-
return offset;
}
void ParallaxBackground::set_scroll_base_offset(const Point2 &p_ofs) {
-
base_offset = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_scroll_base_offset() const {
-
return base_offset;
}
void ParallaxBackground::set_scroll_base_scale(const Point2 &p_ofs) {
-
base_scale = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_scroll_base_scale() const {
-
return base_scale;
}
void ParallaxBackground::set_limit_begin(const Point2 &p_ofs) {
-
limit_begin = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_limit_begin() const {
-
return limit_begin;
}
void ParallaxBackground::set_limit_end(const Point2 &p_ofs) {
-
limit_end = p_ofs;
_update_scroll();
}
Point2 ParallaxBackground::get_limit_end() const {
-
return limit_end;
}
void ParallaxBackground::set_ignore_camera_zoom(bool ignore) {
-
ignore_camera_zoom = ignore;
}
bool ParallaxBackground::is_ignore_camera_zoom() {
-
return ignore_camera_zoom;
}
Vector2 ParallaxBackground::get_final_offset() const {
-
return final_offset;
}
void ParallaxBackground::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_camera_moved"), &ParallaxBackground::_camera_moved);
ClassDB::bind_method(D_METHOD("set_scroll_offset", "ofs"), &ParallaxBackground::set_scroll_offset);
ClassDB::bind_method(D_METHOD("get_scroll_offset"), &ParallaxBackground::get_scroll_offset);
@@ -205,7 +185,6 @@ void ParallaxBackground::_bind_methods() {
}
ParallaxBackground::ParallaxBackground() {
-
scale = 1.0;
set_layer(-100); //behind all by default
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 25ccd910d1..1667880ddb 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -36,7 +36,6 @@
#include "scene/main/canvas_layer.h"
class ParallaxBackground : public CanvasLayer {
-
GDCLASS(ParallaxBackground, CanvasLayer);
Point2 offset;
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 181f0f158c..4ed335dec8 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -34,7 +34,6 @@
#include "parallax_background.h"
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
-
motion_scale = p_scale;
ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent());
@@ -46,12 +45,10 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
}
Size2 ParallaxLayer::get_motion_scale() const {
-
return motion_scale;
}
void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
-
motion_offset = p_offset;
ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent());
@@ -63,18 +60,16 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
}
Size2 ParallaxLayer::get_motion_offset() const {
-
return motion_offset;
}
void ParallaxLayer::_update_mirroring() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent());
if (pb) {
-
RID c = pb->get_canvas();
RID ci = get_canvas_item();
Point2 mirrorScale = mirroring * get_scale();
@@ -83,33 +78,29 @@ void ParallaxLayer::_update_mirroring() {
}
void ParallaxLayer::set_mirroring(const Size2 &p_mirroring) {
-
mirroring = p_mirroring;
- if (mirroring.x < 0)
+ if (mirroring.x < 0) {
mirroring.x = 0;
- if (mirroring.y < 0)
+ }
+ if (mirroring.y < 0) {
mirroring.y = 0;
+ }
_update_mirroring();
}
Size2 ParallaxLayer::get_mirroring() const {
-
return mirroring;
}
void ParallaxLayer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
orig_offset = get_position();
orig_scale = get_scale();
_update_mirroring();
} break;
case NOTIFICATION_EXIT_TREE: {
-
set_position(orig_offset);
set_scale(orig_scale);
} break;
@@ -119,10 +110,12 @@ void ParallaxLayer::_notification(int p_what) {
void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_scale, const Point2 &p_screen_offset) {
screen_offset = p_screen_offset;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
- if (Engine::get_singleton()->is_editor_hint())
+ }
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Point2 new_ofs = (screen_offset + (p_offset - screen_offset) * motion_scale) + motion_offset * p_scale + orig_offset * p_scale;
@@ -143,7 +136,6 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc
}
String ParallaxLayer::get_configuration_warning() const {
-
if (!Object::cast_to<ParallaxBackground>(get_parent())) {
return TTR("ParallaxLayer node only works when set as child of a ParallaxBackground node.");
}
@@ -152,7 +144,6 @@ String ParallaxLayer::get_configuration_warning() const {
}
void ParallaxLayer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_motion_scale", "scale"), &ParallaxLayer::set_motion_scale);
ClassDB::bind_method(D_METHOD("get_motion_scale"), &ParallaxLayer::get_motion_scale);
ClassDB::bind_method(D_METHOD("set_motion_offset", "offset"), &ParallaxLayer::set_motion_offset);
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index ba59184649..1f001943b5 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class ParallaxLayer : public Node2D {
-
GDCLASS(ParallaxLayer, Node2D);
Point2 orig_offset;
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 149d5c6b0d..f2f549e851 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -31,6 +31,7 @@
#include "path_2d.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -39,16 +40,14 @@
#ifdef TOOLS_ENABLED
Rect2 Path2D::_edit_get_rect() const {
-
- if (!curve.is_valid() || curve->get_point_count() == 0)
+ if (!curve.is_valid() || curve->get_point_count() == 0) {
return Rect2(0, 0, 0, 0);
+ }
Rect2 aabb = Rect2(curve->get_point_position(0), Vector2(0, 0));
for (int i = 0; i < curve->get_point_count(); i++) {
-
for (int j = 0; j <= 8; j++) {
-
real_t frac = j / 8.0;
Vector2 p = curve->interpolate(i, frac);
aabb.expand_to(p);
@@ -63,7 +62,6 @@ bool Path2D::_edit_use_rect() const {
}
bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
if (curve.is_null()) {
return false;
}
@@ -76,9 +74,10 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
real_t frac = j / 8.0;
s[1] = curve->interpolate(i, frac);
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, s);
- if (p.distance_to(p_point) <= p_tolerance)
+ Vector2 p = Geometry2D::get_closest_point_to_segment(p_point, s);
+ if (p.distance_to(p_point) <= p_tolerance) {
return true;
+ }
s[0] = s[1];
}
@@ -89,7 +88,6 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
#endif
void Path2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW && curve.is_valid()) {
//draw the curve!!
@@ -105,11 +103,9 @@ void Path2D::_notification(int p_what) {
const Color color = Color(0.5, 0.6, 1.0, 0.7);
for (int i = 0; i < curve->get_point_count(); i++) {
-
Vector2 prev_p = curve->get_point_position(i);
for (int j = 1; j <= 8; j++) {
-
real_t frac = j / 8.0;
Vector2 p = curve->interpolate(i, frac);
draw_line(prev_p, p, color, line_width);
@@ -132,7 +128,6 @@ void Path2D::_curve_changed() {
}
void Path2D::set_curve(const Ref<Curve2D> &p_curve) {
-
if (curve.is_valid()) {
curve->disconnect("changed", callable_mp(this, &Path2D::_curve_changed));
}
@@ -147,33 +142,27 @@ void Path2D::set_curve(const Ref<Curve2D> &p_curve) {
}
Ref<Curve2D> Path2D::get_curve() const {
-
return curve;
}
void Path2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path2D::set_curve);
ClassDB::bind_method(D_METHOD("get_curve"), &Path2D::get_curve);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), "set_curve", "get_curve");
-}
-
-Path2D::Path2D() {
-
- set_curve(Ref<Curve2D>(memnew(Curve2D))); //create one by default
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve");
}
/////////////////////////////////////////////////////////////////////////////////
void PathFollow2D::_update_transform() {
-
- if (!path)
+ if (!path) {
return;
+ }
Ref<Curve2D> c = path->get_curve();
- if (!c.is_valid())
+ if (!c.is_valid()) {
return;
+ }
float path_length = c->get_baked_length();
if (path_length == 0) {
@@ -219,7 +208,6 @@ void PathFollow2D::_update_transform() {
set_rotation(tangent_to_curve.angle());
} else {
-
pos.x += h_offset;
pos.y += v_offset;
}
@@ -228,11 +216,8 @@ void PathFollow2D::_update_transform() {
}
void PathFollow2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
path = Object::cast_to<Path2D>(get_parent());
if (path) {
_update_transform();
@@ -240,38 +225,34 @@ void PathFollow2D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
path = nullptr;
} break;
}
}
void PathFollow2D::set_cubic_interpolation(bool p_enable) {
-
cubic = p_enable;
}
bool PathFollow2D::get_cubic_interpolation() const {
-
return cubic;
}
void PathFollow2D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "offset") {
-
float max = 10000;
- if (path && path->get_curve().is_valid())
+ if (path && path->get_curve().is_valid()) {
max = path->get_curve()->get_baked_length();
+ }
property.hint_string = "0," + rtos(max) + ",0.01,or_lesser,or_greater";
}
}
String PathFollow2D::get_configuration_warning() const {
-
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
if (!Object::cast_to<Path2D>(get_parent())) {
return TTR("PathFollow2D only works when set as a child of a Path2D node.");
@@ -281,7 +262,6 @@ String PathFollow2D::get_configuration_warning() const {
}
void PathFollow2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow2D::set_offset);
ClassDB::bind_method(D_METHOD("get_offset"), &PathFollow2D::get_offset);
@@ -317,7 +297,6 @@ void PathFollow2D::_bind_methods() {
}
void PathFollow2D::set_offset(float p_offset) {
-
offset = p_offset;
if (path) {
if (path->get_curve().is_valid()) {
@@ -340,81 +319,71 @@ void PathFollow2D::set_offset(float p_offset) {
}
void PathFollow2D::set_h_offset(float p_h_offset) {
-
h_offset = p_h_offset;
- if (path)
+ if (path) {
_update_transform();
+ }
}
float PathFollow2D::get_h_offset() const {
-
return h_offset;
}
void PathFollow2D::set_v_offset(float p_v_offset) {
-
v_offset = p_v_offset;
- if (path)
+ if (path) {
_update_transform();
+ }
}
float PathFollow2D::get_v_offset() const {
-
return v_offset;
}
float PathFollow2D::get_offset() const {
-
return offset;
}
void PathFollow2D::set_unit_offset(float p_unit_offset) {
-
- if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
+ if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
set_offset(p_unit_offset * path->get_curve()->get_baked_length());
+ }
}
float PathFollow2D::get_unit_offset() const {
-
- if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
+ if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
return get_offset() / path->get_curve()->get_baked_length();
- else
+ } else {
return 0;
+ }
}
void PathFollow2D::set_lookahead(float p_lookahead) {
-
lookahead = p_lookahead;
}
float PathFollow2D::get_lookahead() const {
-
return lookahead;
}
void PathFollow2D::set_rotate(bool p_rotate) {
-
rotate = p_rotate;
_update_transform();
}
bool PathFollow2D::is_rotating() const {
-
return rotate;
}
void PathFollow2D::set_loop(bool p_loop) {
-
loop = p_loop;
}
bool PathFollow2D::has_loop() const {
-
return loop;
}
PathFollow2D::PathFollow2D() {
-
offset = 0;
h_offset = 0;
v_offset = 0;
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index 35cf8211f4..38fcca0323 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -35,7 +35,6 @@
#include "scene/resources/curve.h"
class Path2D : public Node2D {
-
GDCLASS(Path2D, Node2D);
Ref<Curve2D> curve;
@@ -56,11 +55,10 @@ public:
void set_curve(const Ref<Curve2D> &p_curve);
Ref<Curve2D> get_curve() const;
- Path2D();
+ Path2D() {}
};
class PathFollow2D : public Node2D {
-
GDCLASS(PathFollow2D, Node2D);
public:
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 4198eb6c06..84560b843b 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -43,18 +43,15 @@ void PhysicsBody2D::_notification(int p_what) {
}
void PhysicsBody2D::_set_layers(uint32_t p_mask) {
-
set_collision_layer(p_mask);
set_collision_mask(p_mask);
}
uint32_t PhysicsBody2D::_get_layers() const {
-
return get_collision_layer();
}
void PhysicsBody2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PhysicsBody2D::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsBody2D::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &PhysicsBody2D::set_collision_mask);
@@ -80,59 +77,53 @@ void PhysicsBody2D::_bind_methods() {
}
void PhysicsBody2D::set_collision_layer(uint32_t p_layer) {
-
collision_layer = p_layer;
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
}
uint32_t PhysicsBody2D::get_collision_layer() const {
-
return collision_layer;
}
void PhysicsBody2D::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody2D::get_collision_mask() const {
-
return collision_mask;
}
void PhysicsBody2D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
-bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const {
+bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) {
-
uint32_t collision_layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
collision_layer |= 1 << p_bit;
- else
+ } else {
collision_layer &= ~(1 << p_bit);
+ }
set_collision_layer(collision_layer);
}
bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const {
-
return get_collision_layer() & (1 << p_bit);
}
PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) :
CollisionObject2D(PhysicsServer2D::get_singleton()->body_create(), false) {
-
PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), p_mode);
collision_layer = 1;
collision_mask = 1;
@@ -154,7 +145,6 @@ TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() {
}
void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
-
ERR_FAIL_NULL(p_node);
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody2D type.");
@@ -162,7 +152,6 @@ void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
}
void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
-
ERR_FAIL_NULL(p_node);
PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node);
ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody2D type.");
@@ -170,23 +159,20 @@ void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
}
void StaticBody2D::set_constant_linear_velocity(const Vector2 &p_vel) {
-
constant_linear_velocity = p_vel;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
void StaticBody2D::set_constant_angular_velocity(real_t p_vel) {
-
constant_angular_velocity = p_vel;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector2 StaticBody2D::get_constant_linear_velocity() const {
-
return constant_linear_velocity;
}
-real_t StaticBody2D::get_constant_angular_velocity() const {
+real_t StaticBody2D::get_constant_angular_velocity() const {
return constant_angular_velocity;
}
@@ -210,7 +196,6 @@ Ref<PhysicsMaterial> StaticBody2D::get_physics_material_override() const {
}
void StaticBody2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody2D::set_constant_linear_velocity);
ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "vel"), &StaticBody2D::set_constant_angular_velocity);
ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody2D::get_constant_linear_velocity);
@@ -226,7 +211,6 @@ void StaticBody2D::_bind_methods() {
StaticBody2D::StaticBody2D() :
PhysicsBody2D(PhysicsServer2D::BODY_MODE_STATIC) {
-
constant_angular_velocity = 0;
}
@@ -244,7 +228,6 @@ void StaticBody2D::_reload_physics_characteristics() {
}
void RigidBody2D::_body_enter_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -260,7 +243,6 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
@@ -268,7 +250,6 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
}
void RigidBody2D::_body_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -283,7 +264,6 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
@@ -291,7 +271,6 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
}
void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
-
bool body_in = p_status == 1;
ObjectID objid = p_instance;
@@ -305,7 +284,6 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (body_in) {
if (!E) {
-
E = contact_monitor->body_map.insert(objid, BodyState());
//E->get().rc=0;
E->get().in_scene = node && node->is_inside_tree();
@@ -320,29 +298,30 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
//E->get().rc++;
}
- if (node)
+ if (node) {
E->get().shapes.insert(ShapePair(p_body_shape, p_local_shape));
+ }
if (E->get().in_scene) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_local_shape);
}
} else {
-
//E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(ShapePair(p_body_shape, p_local_shape));
+ }
bool in_scene = E->get().in_scene;
if (E->get().shapes.empty()) {
-
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody2D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody2D::_body_exit_tree));
- if (in_scene)
+ if (in_scene) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
+ }
}
contact_monitor->body_map.erase(E);
@@ -354,22 +333,20 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
}
struct _RigidBody2DInOut {
-
ObjectID id;
int shape;
int local_shape;
};
bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
-
PhysicsServer2D::MotionResult *r = nullptr;
- if (p_result.is_valid())
+ if (p_result.is_valid()) {
r = p_result->get_result_ptr();
+ }
return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r);
}
void RigidBody2D::_direct_state_changed(Object *p_state) {
-
#ifdef DEBUG_ENABLED
state = Object::cast_to<PhysicsDirectBodyState2D>(p_state);
#else
@@ -377,28 +354,27 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
#endif
set_block_transform_notify(true); // don't want notify (would feedback loop)
- if (mode != MODE_KINEMATIC)
+ if (mode != MODE_KINEMATIC) {
set_global_transform(state->get_transform());
+ }
linear_velocity = state->get_linear_velocity();
angular_velocity = state->get_angular_velocity();
if (sleeping != state->is_sleeping()) {
sleeping = state->is_sleeping();
emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed);
}
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("_integrate_forces", state);
+ }
set_block_transform_notify(false); // want it back
if (contact_monitor) {
-
contact_monitor->locked = true;
//untag all
int rc = 0;
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
-
for (int i = 0; i < E->get().shapes.size(); i++) {
-
E->get().shapes[i].tagged = false;
rc++;
}
@@ -412,7 +388,6 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
//put the ones to add
for (int i = 0; i < state->get_contact_count(); i++) {
-
ObjectID obj = state->get_contact_collider_id(i);
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
@@ -431,7 +406,6 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
ShapePair sp(shape, local_shape);
int idx = E->get().shapes.find(sp);
if (idx == -1) {
-
toadd[toadd_count].local_shape = local_shape;
toadd[toadd_count].id = obj;
toadd[toadd_count].shape = shape;
@@ -445,11 +419,8 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
//put the ones to remove
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
-
for (int i = 0; i < E->get().shapes.size(); i++) {
-
if (!E->get().shapes[i].tagged) {
-
toremove[toremove_count].body_id = E->key();
toremove[toremove_count].pair = E->get().shapes[i];
toremove_count++;
@@ -460,14 +431,12 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
//process remotions
for (int i = 0; i < toremove_count; i++) {
-
_body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
}
//process aditions
for (int i = 0; i < toadd_count; i++) {
-
_body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
}
@@ -478,21 +447,16 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
}
void RigidBody2D::set_mode(Mode p_mode) {
-
mode = p_mode;
switch (p_mode) {
-
case MODE_RIGID: {
-
PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_RIGID);
} break;
case MODE_STATIC: {
-
PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_STATIC);
} break;
case MODE_KINEMATIC: {
-
PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_KINEMATIC);
} break;
@@ -504,41 +468,35 @@ void RigidBody2D::set_mode(Mode p_mode) {
}
RigidBody2D::Mode RigidBody2D::get_mode() const {
-
return mode;
}
void RigidBody2D::set_mass(real_t p_mass) {
-
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
_change_notify("mass");
_change_notify("weight");
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass);
}
-real_t RigidBody2D::get_mass() const {
+real_t RigidBody2D::get_mass() const {
return mass;
}
void RigidBody2D::set_inertia(real_t p_inertia) {
-
ERR_FAIL_COND(p_inertia < 0);
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, p_inertia);
}
real_t RigidBody2D::get_inertia() const {
-
return PhysicsServer2D::get_singleton()->body_get_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA);
}
void RigidBody2D::set_weight(real_t p_weight) {
-
set_mass(p_weight / (real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10));
}
real_t RigidBody2D::get_weight() const {
-
return mass * (real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10);
}
@@ -562,39 +520,35 @@ Ref<PhysicsMaterial> RigidBody2D::get_physics_material_override() const {
}
void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) {
-
gravity_scale = p_gravity_scale;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
-real_t RigidBody2D::get_gravity_scale() const {
+real_t RigidBody2D::get_gravity_scale() const {
return gravity_scale;
}
void RigidBody2D::set_linear_damp(real_t p_linear_damp) {
-
ERR_FAIL_COND(p_linear_damp < -1);
linear_damp = p_linear_damp;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
-real_t RigidBody2D::get_linear_damp() const {
+real_t RigidBody2D::get_linear_damp() const {
return linear_damp;
}
void RigidBody2D::set_angular_damp(real_t p_angular_damp) {
-
ERR_FAIL_COND(p_angular_damp < -1);
angular_damp = p_angular_damp;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
-real_t RigidBody2D::get_angular_damp() const {
+real_t RigidBody2D::get_angular_damp() const {
return angular_damp;
}
void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) {
-
Vector2 v = state ? state->get_linear_velocity() : linear_velocity;
Vector2 axis = p_axis.normalized();
v -= axis * axis.dot(v);
@@ -608,77 +562,68 @@ void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) {
}
void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) {
-
linear_velocity = p_velocity;
- if (state)
+ if (state) {
state->set_linear_velocity(linear_velocity);
- else {
-
+ } else {
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
}
Vector2 RigidBody2D::get_linear_velocity() const {
-
return linear_velocity;
}
void RigidBody2D::set_angular_velocity(real_t p_velocity) {
-
angular_velocity = p_velocity;
- if (state)
+ if (state) {
state->set_angular_velocity(angular_velocity);
- else
+ } else {
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ }
}
-real_t RigidBody2D::get_angular_velocity() const {
+real_t RigidBody2D::get_angular_velocity() const {
return angular_velocity;
}
void RigidBody2D::set_use_custom_integrator(bool p_enable) {
-
- if (custom_integrator == p_enable)
+ if (custom_integrator == p_enable) {
return;
+ }
custom_integrator = p_enable;
PhysicsServer2D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
}
-bool RigidBody2D::is_using_custom_integrator() {
+bool RigidBody2D::is_using_custom_integrator() {
return custom_integrator;
}
void RigidBody2D::set_sleeping(bool p_sleeping) {
-
sleeping = p_sleeping;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody2D::set_can_sleep(bool p_active) {
-
can_sleep = p_active;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody2D::is_able_to_sleep() const {
-
return can_sleep;
}
bool RigidBody2D::is_sleeping() const {
-
return sleeping;
}
void RigidBody2D::set_max_contacts_reported(int p_amount) {
-
max_contacts_reported = p_amount;
PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
int RigidBody2D::get_max_contacts_reported() const {
-
return max_contacts_reported;
}
@@ -687,7 +632,6 @@ void RigidBody2D::apply_central_impulse(const Vector2 &p_impulse) {
}
void RigidBody2D::apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) {
-
PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse);
}
@@ -696,22 +640,18 @@ void RigidBody2D::apply_torque_impulse(float p_torque) {
}
void RigidBody2D::set_applied_force(const Vector2 &p_force) {
-
PhysicsServer2D::get_singleton()->body_set_applied_force(get_rid(), p_force);
};
Vector2 RigidBody2D::get_applied_force() const {
-
return PhysicsServer2D::get_singleton()->body_get_applied_force(get_rid());
};
void RigidBody2D::set_applied_torque(const float p_torque) {
-
PhysicsServer2D::get_singleton()->body_set_applied_torque(get_rid(), p_torque);
};
float RigidBody2D::get_applied_torque() const {
-
return PhysicsServer2D::get_singleton()->body_get_applied_torque(get_rid());
};
@@ -720,7 +660,6 @@ void RigidBody2D::add_central_force(const Vector2 &p_force) {
}
void RigidBody2D::add_force(const Vector2 &p_offset, const Vector2 &p_force) {
-
PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_offset, p_force);
}
@@ -729,18 +668,15 @@ void RigidBody2D::add_torque(const float p_torque) {
}
void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) {
-
ccd_mode = p_mode;
PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode));
}
RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const {
-
return ccd_mode;
}
TypedArray<Node2D> RigidBody2D::get_colliding_bodies() const {
-
ERR_FAIL_COND_V(!contact_monitor, Array());
TypedArray<Node2D> ret;
@@ -759,16 +695,14 @@ TypedArray<Node2D> RigidBody2D::get_colliding_bodies() const {
}
void RigidBody2D::set_contact_monitor(bool p_enabled) {
-
- if (p_enabled == is_contact_monitor_enabled())
+ if (p_enabled == is_contact_monitor_enabled()) {
return;
+ }
if (!p_enabled) {
-
ERR_FAIL_COND_MSG(contact_monitor->locked, "Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\", false) instead.");
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
-
//clean up mess
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
@@ -782,19 +716,16 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) {
memdelete(contact_monitor);
contact_monitor = nullptr;
} else {
-
contact_monitor = memnew(ContactMonitor);
contact_monitor->locked = false;
}
}
bool RigidBody2D::is_contact_monitor_enabled() const {
-
return contact_monitor != nullptr;
}
void RigidBody2D::_notification(int p_what) {
-
#ifdef TOOLS_ENABLED
if (p_what == NOTIFICATION_ENTER_TREE) {
if (Engine::get_singleton()->is_editor_hint()) {
@@ -812,7 +743,6 @@ void RigidBody2D::_notification(int p_what) {
}
String RigidBody2D::get_configuration_warning() const {
-
Transform2D t = get_transform();
String warning = CollisionObject2D::get_configuration_warning();
@@ -828,7 +758,6 @@ String RigidBody2D::get_configuration_warning() const {
}
void RigidBody2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody2D::set_mode);
ClassDB::bind_method(D_METHOD("get_mode"), &RigidBody2D::get_mode);
@@ -940,7 +869,6 @@ void RigidBody2D::_bind_methods() {
RigidBody2D::RigidBody2D() :
PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) {
-
mode = MODE_RIGID;
mass = 1;
@@ -964,9 +892,9 @@ RigidBody2D::RigidBody2D() :
}
RigidBody2D::~RigidBody2D() {
-
- if (contact_monitor)
+ if (contact_monitor) {
memdelete(contact_monitor);
+ }
}
void RigidBody2D::_reload_physics_characteristics() {
@@ -982,7 +910,6 @@ void RigidBody2D::_reload_physics_characteristics() {
//////////////////////////
Ref<KinematicCollision2D> KinematicBody2D::_move(const Vector2 &p_motion, bool p_infinite_inertia, bool p_exclude_raycast_shapes, bool p_test_only) {
-
Collision col;
if (move_and_collide(p_motion, p_infinite_inertia, col, p_exclude_raycast_shapes, p_test_only)) {
@@ -1000,7 +927,6 @@ Ref<KinematicCollision2D> KinematicBody2D::_move(const Vector2 &p_motion, bool p
}
bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) {
-
PhysicsServer2D::SeparationResult sep_res[8]; //max 8 rays
Transform2D gt = get_global_transform();
@@ -1037,7 +963,6 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision
}
bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) {
-
if (sync_to_physics) {
ERR_PRINT("Functions move_and_slide and move_and_collide do not work together with 'sync to physics' option. Please read the documentation.");
}
@@ -1070,9 +995,9 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_
#define FLOOR_ANGLE_THRESHOLD 0.01
Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
-
Vector2 body_velocity = p_linear_velocity;
Vector2 body_velocity_normal = body_velocity.normalized();
+ Vector2 up_direction = p_up_direction.normalized();
Vector2 current_floor_velocity = floor_velocity;
if (on_floor && on_floor_body.is_valid()) {
@@ -1095,7 +1020,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
floor_velocity = Vector2();
while (p_max_slides) {
-
Collision collision;
bool found_collision = false;
@@ -1120,11 +1044,11 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
colliders.push_back(collision);
motion = collision.remainder;
- if (p_up_direction == Vector2()) {
+ if (up_direction == Vector2()) {
//all is a wall
on_wall = true;
} else {
- if (Math::acos(collision.normal.dot(p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
+ if (Math::acos(collision.normal.dot(up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
on_floor = true;
floor_normal = collision.normal;
@@ -1132,14 +1056,14 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
floor_velocity = collision.collider_vel;
if (p_stop_on_slope) {
- if ((body_velocity_normal + p_up_direction).length() < 0.01 && collision.travel.length() < 1) {
+ if ((body_velocity_normal + up_direction).length() < 0.01 && collision.travel.length() < 1) {
Transform2D gt = get_global_transform();
- gt.elements[2] -= collision.travel.slide(p_up_direction);
+ gt.elements[2] -= collision.travel.slide(up_direction);
set_global_transform(gt);
return Vector2();
}
}
- } else if (Math::acos(collision.normal.dot(-p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
+ } else if (Math::acos(collision.normal.dot(-up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
on_ceiling = true;
} else {
on_wall = true;
@@ -1151,8 +1075,9 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
}
}
- if (!found_collision || motion == Vector2())
+ if (!found_collision || motion == Vector2()) {
break;
+ }
--p_max_slides;
}
@@ -1161,10 +1086,10 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
}
Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_velocity, const Vector2 &p_snap, const Vector2 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
-
+ Vector2 up_direction = p_up_direction.normalized();
bool was_on_floor = on_floor;
- Vector2 ret = move_and_slide(p_linear_velocity, p_up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
+ Vector2 ret = move_and_slide(p_linear_velocity, up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
if (!was_on_floor || p_snap == Vector2()) {
return ret;
}
@@ -1174,8 +1099,8 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) {
bool apply = true;
- if (p_up_direction != Vector2()) {
- if (Math::acos(p_up_direction.normalized().dot(col.normal)) < p_floor_max_angle) {
+ if (up_direction != Vector2()) {
+ if (Math::acos(col.normal.dot(up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) {
on_floor = true;
floor_normal = col.normal;
on_floor_body = col.collider_rid;
@@ -1183,7 +1108,7 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
if (p_stop_on_slope) {
// move and collide may stray the object a bit because of pre un-stucking,
// so only ensure that motion happens on floor direction in this case.
- col.travel = p_up_direction * p_up_direction.dot(col.travel);
+ col.travel = up_direction * up_direction.dot(col.travel);
}
} else {
@@ -1201,47 +1126,40 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
}
bool KinematicBody2D::is_on_floor() const {
-
return on_floor;
}
-bool KinematicBody2D::is_on_wall() const {
+bool KinematicBody2D::is_on_wall() const {
return on_wall;
}
-bool KinematicBody2D::is_on_ceiling() const {
+bool KinematicBody2D::is_on_ceiling() const {
return on_ceiling;
}
Vector2 KinematicBody2D::get_floor_normal() const {
-
return floor_normal;
}
Vector2 KinematicBody2D::get_floor_velocity() const {
-
return floor_velocity;
}
bool KinematicBody2D::test_move(const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia) {
-
ERR_FAIL_COND_V(!is_inside_tree(), false);
return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin);
}
void KinematicBody2D::set_safe_margin(float p_margin) {
-
margin = p_margin;
}
float KinematicBody2D::get_safe_margin() const {
-
return margin;
}
int KinematicBody2D::get_slide_count() const {
-
return colliders.size();
}
@@ -1251,7 +1169,6 @@ KinematicBody2D::Collision KinematicBody2D::get_slide_collision(int p_bounce) co
}
Ref<KinematicCollision2D> KinematicBody2D::_get_slide_collision(int p_bounce) {
-
ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision2D>());
if (p_bounce >= slide_colliders.size()) {
slide_colliders.resize(p_bounce + 1);
@@ -1267,14 +1184,14 @@ Ref<KinematicCollision2D> KinematicBody2D::_get_slide_collision(int p_bounce) {
}
void KinematicBody2D::set_sync_to_physics(bool p_enable) {
-
if (sync_to_physics == p_enable) {
return;
}
sync_to_physics = p_enable;
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
if (p_enable) {
PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
@@ -1292,9 +1209,9 @@ bool KinematicBody2D::is_sync_to_physics_enabled() const {
}
void KinematicBody2D::_direct_state_changed(Object *p_state) {
-
- if (!sync_to_physics)
+ if (!sync_to_physics) {
return;
+ }
PhysicsDirectBodyState2D *state = Object::cast_to<PhysicsDirectBodyState2D>(p_state);
@@ -1327,8 +1244,8 @@ void KinematicBody2D::_notification(int p_what) {
set_notify_local_transform(true);
}
}
-void KinematicBody2D::_bind_methods() {
+void KinematicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
@@ -1358,7 +1275,6 @@ void KinematicBody2D::_bind_methods() {
KinematicBody2D::KinematicBody2D() :
PhysicsBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
-
margin = 0.08;
on_floor = false;
@@ -1366,6 +1282,7 @@ KinematicBody2D::KinematicBody2D() :
on_wall = false;
sync_to_physics = false;
}
+
KinematicBody2D::~KinematicBody2D() {
if (motion_cache.is_valid()) {
motion_cache->owner = nullptr;
@@ -1381,39 +1298,42 @@ KinematicBody2D::~KinematicBody2D() {
////////////////////////
Vector2 KinematicCollision2D::get_position() const {
-
return collision.collision;
}
+
Vector2 KinematicCollision2D::get_normal() const {
return collision.normal;
}
+
Vector2 KinematicCollision2D::get_travel() const {
return collision.travel;
}
+
Vector2 KinematicCollision2D::get_remainder() const {
return collision.remainder;
}
+
Object *KinematicCollision2D::get_local_shape() const {
- if (!owner)
+ if (!owner) {
return nullptr;
+ }
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
Object *KinematicCollision2D::get_collider() const {
-
if (collision.collider.is_valid()) {
return ObjectDB::get_instance(collision.collider);
}
return nullptr;
}
-ObjectID KinematicCollision2D::get_collider_id() const {
+ObjectID KinematicCollision2D::get_collider_id() const {
return collision.collider;
}
-Object *KinematicCollision2D::get_collider_shape() const {
+Object *KinematicCollision2D::get_collider_shape() const {
Object *collider = get_collider();
if (collider) {
CollisionObject2D *obj2d = Object::cast_to<CollisionObject2D>(collider);
@@ -1425,21 +1345,20 @@ Object *KinematicCollision2D::get_collider_shape() const {
return nullptr;
}
-int KinematicCollision2D::get_collider_shape_index() const {
+int KinematicCollision2D::get_collider_shape_index() const {
return collision.collider_shape;
}
-Vector2 KinematicCollision2D::get_collider_velocity() const {
+Vector2 KinematicCollision2D::get_collider_velocity() const {
return collision.collider_vel;
}
-Variant KinematicCollision2D::get_collider_metadata() const {
+Variant KinematicCollision2D::get_collider_metadata() const {
return Variant();
}
void KinematicCollision2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision2D::get_position);
ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision2D::get_normal);
ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision2D::get_travel);
@@ -1466,7 +1385,6 @@ void KinematicCollision2D::_bind_methods() {
}
KinematicCollision2D::KinematicCollision2D() {
-
collision.collider_shape = 0;
collision.local_shape = 0;
owner = nullptr;
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 75f4f778bf..cde4398ad3 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -39,7 +39,6 @@
class KinematicCollision2D;
class PhysicsBody2D : public CollisionObject2D {
-
GDCLASS(PhysicsBody2D, CollisionObject2D);
uint32_t collision_layer;
@@ -75,7 +74,6 @@ public:
};
class StaticBody2D : public PhysicsBody2D {
-
GDCLASS(StaticBody2D, PhysicsBody2D);
Vector2 constant_linear_velocity;
@@ -104,7 +102,6 @@ private:
};
class RigidBody2D : public PhysicsBody2D {
-
GDCLASS(RigidBody2D, PhysicsBody2D);
public:
@@ -143,13 +140,13 @@ private:
CCDMode ccd_mode;
struct ShapePair {
-
int body_shape;
int local_shape;
bool tagged;
bool operator<(const ShapePair &p_sp) const {
- if (body_shape == p_sp.body_shape)
+ if (body_shape == p_sp.body_shape) {
return local_shape < p_sp.local_shape;
+ }
return body_shape < p_sp.body_shape;
}
@@ -161,19 +158,16 @@ private:
}
};
struct RigidBody2D_RemoveAction {
-
ObjectID body_id;
ShapePair pair;
};
struct BodyState {
-
//int rc;
bool in_scene;
VSet<ShapePair> shapes;
};
struct ContactMonitor {
-
bool locked;
Map<ObjectID, BodyState> body_map;
};
@@ -271,7 +265,6 @@ VARIANT_ENUM_CAST(RigidBody2D::Mode);
VARIANT_ENUM_CAST(RigidBody2D::CCDMode);
class KinematicBody2D : public PhysicsBody2D {
-
GDCLASS(KinematicBody2D, PhysicsBody2D);
public:
@@ -344,7 +337,6 @@ public:
};
class KinematicCollision2D : public Reference {
-
GDCLASS(KinematicCollision2D, Reference);
KinematicBody2D *owner;
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 84c1828b47..13b62816a4 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -30,7 +30,7 @@
#include "polygon_2d.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
#include "skeleton_2d.h"
#ifdef TOOLS_ENABLED
@@ -65,10 +65,11 @@ Rect2 Polygon2D::_edit_get_rect() const {
item_rect = Rect2();
for (int i = 0; i < l; i++) {
Vector2 pos = r[i] + offset;
- if (i == 0)
+ if (i == 0) {
item_rect.position = pos;
- else
+ } else {
item_rect.expand_to(pos);
+ }
}
rect_cache_dirty = false;
}
@@ -81,12 +82,11 @@ bool Polygon2D::_edit_use_rect() const {
}
bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
Vector<Vector2> polygon2d = Variant(polygon);
if (internal_vertices > 0) {
polygon2d.resize(polygon2d.size() - internal_vertices);
}
- return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d);
+ return Geometry2D::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
#endif
@@ -95,13 +95,11 @@ void Polygon2D::_skeleton_bone_setup_changed() {
}
void Polygon2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
- if (polygon.size() < 3)
+ if (polygon.size() < 3) {
return;
+ }
Skeleton2D *skeleton_node = nullptr;
if (has_node(skeleton)) {
@@ -147,7 +145,6 @@ void Polygon2D::_notification(int p_what) {
points.resize(len);
{
-
const Vector2 *polyr = polygon.ptr();
for (int i = 0; i < len; i++) {
points.write[i] = polyr[i] + offset;
@@ -155,17 +152,17 @@ void Polygon2D::_notification(int p_what) {
}
if (invert) {
-
Rect2 bounds;
int highest_idx = -1;
float highest_y = -1e20;
float sum = 0;
for (int i = 0; i < len; i++) {
- if (i == 0)
+ if (i == 0) {
bounds.position = points[i];
- else
+ } else {
bounds.expand_to(points[i]);
+ }
if (points[i].y > highest_y) {
highest_idx = i;
highest_y = points[i].y;
@@ -195,12 +192,10 @@ void Polygon2D::_notification(int p_what) {
points.resize(points.size() + 7);
for (int i = points.size() - 1; i >= highest_idx + 7; i--) {
-
points.write[i] = points[i - 7];
}
for (int i = 0; i < 7; i++) {
-
points.write[highest_idx + i + 1] = ep[i];
}
@@ -208,7 +203,6 @@ void Polygon2D::_notification(int p_what) {
}
if (texture.is_valid()) {
-
Transform2D texmat(tex_rot, tex_ofs);
texmat.scale(tex_scale);
Size2 tex_size = texture->get_size();
@@ -216,7 +210,6 @@ void Polygon2D::_notification(int p_what) {
uvs.resize(len);
if (points.size() == uv.size()) {
-
const Vector2 *uvr = uv.ptr();
for (int i = 0; i < len; i++) {
@@ -259,8 +252,9 @@ void Polygon2D::_notification(int p_what) {
int bone_index = bone->get_index_in_skeleton();
const float *r = bone_weights[i].weights.ptr();
for (int j = 0; j < vc; j++) {
- if (r[j] == 0.0)
+ if (r[j] == 0.0) {
continue; //weight is unpainted, skip
+ }
//find an index with a weight
for (int k = 0; k < 4; k++) {
if (weightsw[j * 4 + k] < r[j]) {
@@ -283,8 +277,9 @@ void Polygon2D::_notification(int p_what) {
for (int j = 0; j < 4; j++) {
tw += weightsw[i * 4 + j];
}
- if (tw == 0)
+ if (tw == 0) {
continue; //unpainted, do nothing
+ }
//normalize
for (int j = 0; j < 4; j++) {
@@ -305,7 +300,7 @@ void Polygon2D::_notification(int p_what) {
}
if (invert || polygons.size() == 0) {
- Vector<int> indices = Geometry::triangulate_polygon(points);
+ Vector<int> indices = Geometry2D::triangulate_polygon(points);
if (indices.size()) {
RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess));
}
@@ -315,8 +310,9 @@ void Polygon2D::_notification(int p_what) {
for (int i = 0; i < polygons.size(); i++) {
Vector<int> src_indices = polygons[i];
int ic = src_indices.size();
- if (ic < 3)
+ if (ic < 3) {
continue;
+ }
const int *r = src_indices.ptr();
Vector<Vector2> tmp_points;
@@ -327,7 +323,7 @@ void Polygon2D::_notification(int p_what) {
ERR_CONTINUE(idx < 0 || idx >= points.size());
tmp_points.write[j] = points[r[j]];
}
- Vector<int> indices = Geometry::triangulate_polygon(tmp_points);
+ Vector<int> indices = Geometry2D::triangulate_polygon(tmp_points);
int ic2 = indices.size();
const int *r2 = indices.ptr();
@@ -356,12 +352,10 @@ void Polygon2D::set_polygon(const Vector<Vector2> &p_polygon) {
}
Vector<Vector2> Polygon2D::get_polygon() const {
-
return polygon;
}
void Polygon2D::set_internal_vertex_count(int p_count) {
-
internal_vertices = p_count;
}
@@ -370,49 +364,42 @@ int Polygon2D::get_internal_vertex_count() const {
}
void Polygon2D::set_uv(const Vector<Vector2> &p_uv) {
-
uv = p_uv;
update();
}
Vector<Vector2> Polygon2D::get_uv() const {
-
return uv;
}
void Polygon2D::set_polygons(const Array &p_polygons) {
-
polygons = p_polygons;
update();
}
Array Polygon2D::get_polygons() const {
-
return polygons;
}
void Polygon2D::set_color(const Color &p_color) {
-
color = p_color;
update();
}
-Color Polygon2D::get_color() const {
+Color Polygon2D::get_color() const {
return color;
}
void Polygon2D::set_vertex_colors(const Vector<Color> &p_colors) {
-
vertex_colors = p_colors;
update();
}
-Vector<Color> Polygon2D::get_vertex_colors() const {
+Vector<Color> Polygon2D::get_vertex_colors() const {
return vertex_colors;
}
void Polygon2D::set_texture(const Ref<Texture2D> &p_texture) {
-
texture = p_texture;
/*if (texture.is_valid()) {
@@ -425,8 +412,8 @@ void Polygon2D::set_texture(const Ref<Texture2D> &p_texture) {
}*/
update();
}
-Ref<Texture2D> Polygon2D::get_texture() const {
+Ref<Texture2D> Polygon2D::get_texture() const {
return texture;
}
@@ -467,76 +454,68 @@ float Polygon2D::get_shininess() const {
}
void Polygon2D::set_texture_offset(const Vector2 &p_offset) {
-
tex_ofs = p_offset;
update();
}
-Vector2 Polygon2D::get_texture_offset() const {
+Vector2 Polygon2D::get_texture_offset() const {
return tex_ofs;
}
void Polygon2D::set_texture_rotation(float p_rot) {
-
tex_rot = p_rot;
update();
}
-float Polygon2D::get_texture_rotation() const {
+float Polygon2D::get_texture_rotation() const {
return tex_rot;
}
void Polygon2D::set_texture_rotation_degrees(float p_rot) {
-
set_texture_rotation(Math::deg2rad(p_rot));
}
-float Polygon2D::get_texture_rotation_degrees() const {
+float Polygon2D::get_texture_rotation_degrees() const {
return Math::rad2deg(get_texture_rotation());
}
void Polygon2D::set_texture_scale(const Size2 &p_scale) {
-
tex_scale = p_scale;
update();
}
-Size2 Polygon2D::get_texture_scale() const {
+Size2 Polygon2D::get_texture_scale() const {
return tex_scale;
}
void Polygon2D::set_invert(bool p_invert) {
-
invert = p_invert;
update();
}
-bool Polygon2D::get_invert() const {
+bool Polygon2D::get_invert() const {
return invert;
}
void Polygon2D::set_antialiased(bool p_antialiased) {
-
antialiased = p_antialiased;
update();
}
-bool Polygon2D::get_antialiased() const {
+bool Polygon2D::get_antialiased() const {
return antialiased;
}
void Polygon2D::set_invert_border(float p_invert_border) {
-
invert_border = p_invert_border;
update();
}
-float Polygon2D::get_invert_border() const {
+float Polygon2D::get_invert_border() const {
return invert_border;
}
void Polygon2D::set_offset(const Vector2 &p_offset) {
-
offset = p_offset;
rect_cache_dirty = true;
update();
@@ -544,31 +523,31 @@ void Polygon2D::set_offset(const Vector2 &p_offset) {
}
Vector2 Polygon2D::get_offset() const {
-
return offset;
}
void Polygon2D::add_bone(const NodePath &p_path, const Vector<float> &p_weights) {
-
Bone bone;
bone.path = p_path;
bone.weights = p_weights;
bone_weights.push_back(bone);
}
+
int Polygon2D::get_bone_count() const {
return bone_weights.size();
}
+
NodePath Polygon2D::get_bone_path(int p_index) const {
ERR_FAIL_INDEX_V(p_index, bone_weights.size(), NodePath());
return bone_weights[p_index].path;
}
-Vector<float> Polygon2D::get_bone_weights(int p_index) const {
+Vector<float> Polygon2D::get_bone_weights(int p_index) const {
ERR_FAIL_INDEX_V(p_index, bone_weights.size(), Vector<float>());
return bone_weights[p_index].weights;
}
-void Polygon2D::erase_bone(int p_idx) {
+void Polygon2D::erase_bone(int p_idx) {
ERR_FAIL_INDEX(p_idx, bone_weights.size());
bone_weights.remove(p_idx);
}
@@ -582,6 +561,7 @@ void Polygon2D::set_bone_weights(int p_index, const Vector<float> &p_weights) {
bone_weights.write[p_index].weights = p_weights;
update();
}
+
void Polygon2D::set_bone_path(int p_index, const NodePath &p_path) {
ERR_FAIL_INDEX(p_index, bone_weights.size());
bone_weights.write[p_index].path = p_path;
@@ -596,8 +576,8 @@ Array Polygon2D::_get_bones() const {
}
return bones;
}
-void Polygon2D::_set_bones(const Array &p_bones) {
+void Polygon2D::_set_bones(const Array &p_bones) {
ERR_FAIL_COND(p_bones.size() & 1);
clear_bones();
for (int i = 0; i < p_bones.size(); i += 2) {
@@ -606,8 +586,9 @@ void Polygon2D::_set_bones(const Array &p_bones) {
}
void Polygon2D::set_skeleton(const NodePath &p_skeleton) {
- if (skeleton == p_skeleton)
+ if (skeleton == p_skeleton) {
return;
+ }
skeleton = p_skeleton;
update();
}
@@ -617,7 +598,6 @@ NodePath Polygon2D::get_skeleton() const {
}
void Polygon2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &Polygon2D::set_polygon);
ClassDB::bind_method(D_METHOD("get_polygon"), &Polygon2D::get_polygon);
@@ -722,8 +702,7 @@ void Polygon2D::_bind_methods() {
}
Polygon2D::Polygon2D() {
-
- invert = 0;
+ invert = false;
invert_border = 100;
antialiased = false;
tex_rot = 0;
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index 777c1f82f3..dafec1c343 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class Polygon2D : public Node2D {
-
GDCLASS(Polygon2D, Node2D);
Vector<Vector2> polygon;
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index 9e95a55d9f..a94a9f7085 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -36,7 +36,6 @@
const float DEFAULT_GIZMO_EXTENTS = 10.0;
void Position2D::_draw_cross() {
-
float extents = get_gizmo_extents();
// Colors taken from `axis_x_color` and `axis_y_color` (defined in `editor/editor_themes.cpp`)
draw_line(Point2(-extents, 0), Point2(+extents, 0), Color(0.96, 0.20, 0.32));
@@ -45,7 +44,6 @@ void Position2D::_draw_cross() {
#ifdef TOOLS_ENABLED
Rect2 Position2D::_edit_get_rect() const {
-
float extents = get_gizmo_extents();
return Rect2(Point2(-extents, -extents), Size2(extents * 2, extents * 2));
}
@@ -56,18 +54,17 @@ bool Position2D::_edit_use_rect() const {
#endif
void Position2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
update();
} break;
case NOTIFICATION_DRAW: {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
- if (Engine::get_singleton()->is_editor_hint())
+ }
+ if (Engine::get_singleton()->is_editor_hint()) {
_draw_cross();
+ }
} break;
}
@@ -92,7 +89,6 @@ float Position2D::get_gizmo_extents() const {
}
void Position2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_gizmo_extents", "extents"), &Position2D::set_gizmo_extents);
ClassDB::bind_method(D_METHOD("_get_gizmo_extents"), &Position2D::get_gizmo_extents);
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index 3ea636171d..b53fa4c0e2 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class Position2D : public Node2D {
-
GDCLASS(Position2D, Node2D);
void _draw_cross();
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 9d6c7304ce..5020940c5c 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -36,134 +36,129 @@
#include "servers/physics_server_2d.h"
void RayCast2D::set_cast_to(const Vector2 &p_point) {
-
cast_to = p_point;
- if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) {
update();
+ }
}
Vector2 RayCast2D::get_cast_to() const {
-
return cast_to;
}
void RayCast2D::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
}
uint32_t RayCast2D::get_collision_mask() const {
-
return collision_mask;
}
void RayCast2D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool RayCast2D::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
bool RayCast2D::is_colliding() const {
-
return collided;
}
-Object *RayCast2D::get_collider() const {
- if (against.is_null())
+Object *RayCast2D::get_collider() const {
+ if (against.is_null()) {
return nullptr;
+ }
return ObjectDB::get_instance(against);
}
int RayCast2D::get_collider_shape() const {
-
return against_shape;
}
-Vector2 RayCast2D::get_collision_point() const {
+Vector2 RayCast2D::get_collision_point() const {
return collision_point;
}
-Vector2 RayCast2D::get_collision_normal() const {
+Vector2 RayCast2D::get_collision_normal() const {
return collision_normal;
}
void RayCast2D::set_enabled(bool p_enabled) {
-
enabled = p_enabled;
update();
- if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process_internal(p_enabled);
- if (!p_enabled)
+ }
+ if (!p_enabled) {
collided = false;
+ }
}
bool RayCast2D::is_enabled() const {
-
return enabled;
}
void RayCast2D::set_exclude_parent_body(bool p_exclude_parent_body) {
-
- if (exclude_parent_body == p_exclude_parent_body)
+ if (exclude_parent_body == p_exclude_parent_body) {
return;
+ }
exclude_parent_body = p_exclude_parent_body;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (Object::cast_to<CollisionObject2D>(get_parent())) {
- if (exclude_parent_body)
+ if (exclude_parent_body) {
exclude.insert(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
- else
+ } else {
exclude.erase(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
+ }
}
}
bool RayCast2D::get_exclude_parent_body() const {
-
return exclude_parent_body;
}
void RayCast2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
- if (enabled && !Engine::get_singleton()->is_editor_hint())
+ if (enabled && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process_internal(true);
- else
+ } else {
set_physics_process_internal(false);
+ }
if (Object::cast_to<CollisionObject2D>(get_parent())) {
- if (exclude_parent_body)
+ if (exclude_parent_body) {
exclude.insert(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
- else
+ } else {
exclude.erase(Object::cast_to<CollisionObject2D>(get_parent())->get_rid());
+ }
}
} break;
case NOTIFICATION_EXIT_TREE: {
-
- if (enabled)
+ if (enabled) {
set_physics_process_internal(false);
+ }
} break;
case NOTIFICATION_DRAW: {
-
- if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
break;
+ }
Transform2D xf;
xf.rotate(cast_to.angle());
xf.translate(Vector2(cast_to.length(), 0));
@@ -183,17 +178,18 @@ void RayCast2D::_notification(int p_what) {
pts.push_back(xf.xform(Vector2(0, Math_SQRT12 * tsize)));
pts.push_back(xf.xform(Vector2(0, -Math_SQRT12 * tsize)));
Vector<Color> cols;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
cols.push_back(draw_col);
+ }
draw_primitive(pts, cols, Vector<Vector2>());
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
-
- if (!enabled)
+ if (!enabled) {
break;
+ }
_update_raycast_state();
@@ -211,13 +207,13 @@ void RayCast2D::_update_raycast_state() {
Transform2D gt = get_global_transform();
Vector2 to = cast_to;
- if (to == Vector2())
+ if (to == Vector2()) {
to = Vector2(0, 0.01);
+ }
PhysicsDirectSpaceState2D::RayResult rr;
if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) {
-
collided = true;
against = rr.collider_id;
collision_point = rr.position;
@@ -235,60 +231,52 @@ void RayCast2D::force_raycast_update() {
}
void RayCast2D::add_exception_rid(const RID &p_rid) {
-
exclude.insert(p_rid);
}
void RayCast2D::add_exception(const Object *p_object) {
-
ERR_FAIL_NULL(p_object);
const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
add_exception_rid(co->get_rid());
}
void RayCast2D::remove_exception_rid(const RID &p_rid) {
-
exclude.erase(p_rid);
}
void RayCast2D::remove_exception(const Object *p_object) {
-
ERR_FAIL_NULL(p_object);
const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
remove_exception_rid(co->get_rid());
}
void RayCast2D::clear_exceptions() {
-
exclude.clear();
}
void RayCast2D::set_collide_with_areas(bool p_clip) {
-
collide_with_areas = p_clip;
}
bool RayCast2D::is_collide_with_areas_enabled() const {
-
return collide_with_areas;
}
void RayCast2D::set_collide_with_bodies(bool p_clip) {
-
collide_with_bodies = p_clip;
}
bool RayCast2D::is_collide_with_bodies_enabled() const {
-
return collide_with_bodies;
}
void RayCast2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &RayCast2D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &RayCast2D::is_enabled);
@@ -337,7 +325,6 @@ void RayCast2D::_bind_methods() {
}
RayCast2D::RayCast2D() {
-
enabled = false;
collided = false;
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index 20f05e7525..6accc264a0 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class RayCast2D : public Node2D {
-
GDCLASS(RayCast2D, Node2D);
bool enabled;
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index ec50f5f922..3104436dbe 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -32,7 +32,6 @@
#include "scene/scene_string_names.h"
void RemoteTransform2D::_update_cache() {
-
cache = ObjectID();
if (has_node(remote_node)) {
Node *node = get_node(remote_node);
@@ -45,23 +44,25 @@ void RemoteTransform2D::_update_cache() {
}
void RemoteTransform2D::_update_remote() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (cache.is_null())
+ if (cache.is_null()) {
return;
+ }
Node2D *n = Object::cast_to<Node2D>(ObjectDB::get_instance(cache));
- if (!n)
+ if (!n) {
return;
+ }
- if (!n->is_inside_tree())
+ if (!n->is_inside_tree()) {
return;
+ }
//todo make faster
if (use_global_coordinates) {
-
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_global_transform(get_global_transform());
} else {
@@ -69,21 +70,23 @@ void RemoteTransform2D::_update_remote() {
Transform2D our_trans = get_global_transform();
Vector2 n_scale = n->get_scale();
- if (!update_remote_position)
+ if (!update_remote_position) {
our_trans.set_origin(n_trans.get_origin());
- if (!update_remote_rotation)
+ }
+ if (!update_remote_rotation) {
our_trans.set_rotation(n_trans.get_rotation());
+ }
n->set_global_transform(our_trans);
- if (update_remote_scale)
+ if (update_remote_scale) {
n->set_scale(get_global_scale());
- else
+ } else {
n->set_scale(n_scale);
+ }
}
} else {
-
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_transform(get_transform());
} else {
@@ -91,36 +94,36 @@ void RemoteTransform2D::_update_remote() {
Transform2D our_trans = get_transform();
Vector2 n_scale = n->get_scale();
- if (!update_remote_position)
+ if (!update_remote_position) {
our_trans.set_origin(n_trans.get_origin());
- if (!update_remote_rotation)
+ }
+ if (!update_remote_rotation) {
our_trans.set_rotation(n_trans.get_rotation());
+ }
n->set_transform(our_trans);
- if (update_remote_scale)
+ if (update_remote_scale) {
n->set_scale(get_scale());
- else
+ } else {
n->set_scale(n_scale);
+ }
}
}
}
void RemoteTransform2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
_update_cache();
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (cache.is_valid()) {
-
_update_remote();
}
@@ -129,7 +132,6 @@ void RemoteTransform2D::_notification(int p_what) {
}
void RemoteTransform2D::set_remote_node(const NodePath &p_remote_node) {
-
remote_node = p_remote_node;
if (is_inside_tree()) {
_update_cache();
@@ -140,7 +142,6 @@ void RemoteTransform2D::set_remote_node(const NodePath &p_remote_node) {
}
NodePath RemoteTransform2D::get_remote_node() const {
-
return remote_node;
}
@@ -185,7 +186,6 @@ void RemoteTransform2D::force_update_cache() {
}
String RemoteTransform2D::get_configuration_warning() const {
-
if (!has_node(remote_node) || !Object::cast_to<Node2D>(get_node(remote_node))) {
return TTR("Path property must point to a valid Node2D node to work.");
}
@@ -194,7 +194,6 @@ String RemoteTransform2D::get_configuration_warning() const {
}
void RemoteTransform2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform2D::set_remote_node);
ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform2D::get_remote_node);
ClassDB::bind_method(D_METHOD("force_update_cache"), &RemoteTransform2D::force_update_cache);
@@ -219,7 +218,6 @@ void RemoteTransform2D::_bind_methods() {
}
RemoteTransform2D::RemoteTransform2D() {
-
use_global_coordinates = true;
update_remote_position = true;
update_remote_rotation = true;
diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h
index f5b949d10b..caaa0394f2 100644
--- a/scene/2d/remote_transform_2d.h
+++ b/scene/2d/remote_transform_2d.h
@@ -34,7 +34,6 @@
#include "scene/2d/node_2d.h"
class RemoteTransform2D : public Node2D {
-
GDCLASS(RemoteTransform2D, Node2D);
NodePath remote_node;
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp
index 86c9ff6076..ea37c8dfe7 100644
--- a/scene/2d/skeleton_2d.cpp
+++ b/scene/2d/skeleton_2d.cpp
@@ -31,17 +31,18 @@
#include "skeleton_2d.h"
void Bone2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
Node *parent = get_parent();
parent_bone = Object::cast_to<Bone2D>(parent);
skeleton = nullptr;
while (parent) {
skeleton = Object::cast_to<Skeleton2D>(parent);
- if (skeleton)
+ if (skeleton) {
break;
- if (!Object::cast_to<Bone2D>(parent))
+ }
+ if (!Object::cast_to<Bone2D>(parent)) {
break; //skeletons must be chained to Bone2Ds.
+ }
parent = parent->get_parent();
}
@@ -78,8 +79,8 @@ void Bone2D::_notification(int p_what) {
parent_bone = nullptr;
}
}
-void Bone2D::_bind_methods() {
+void Bone2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rest", "rest"), &Bone2D::set_rest);
ClassDB::bind_method(D_METHOD("get_rest"), &Bone2D::get_rest);
ClassDB::bind_method(D_METHOD("apply_rest"), &Bone2D::apply_rest);
@@ -95,8 +96,9 @@ void Bone2D::_bind_methods() {
void Bone2D::set_rest(const Transform2D &p_rest) {
rest = p_rest;
- if (skeleton)
+ if (skeleton) {
skeleton->_make_bone_setup_dirty();
+ }
update_configuration_warning();
}
@@ -106,7 +108,6 @@ Transform2D Bone2D::get_rest() const {
}
Transform2D Bone2D::get_skeleton_rest() const {
-
if (parent_bone) {
return parent_bone->get_skeleton_rest() * rest;
} else {
@@ -119,7 +120,6 @@ void Bone2D::apply_rest() {
}
void Bone2D::set_default_length(float p_length) {
-
default_length = p_length;
}
@@ -132,8 +132,8 @@ int Bone2D::get_index_in_skeleton() const {
skeleton->_update_bone_setup();
return skeleton_index;
}
-String Bone2D::get_configuration_warning() const {
+String Bone2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!skeleton) {
if (warning != String()) {
@@ -171,9 +171,9 @@ Bone2D::Bone2D() {
//////////////////////////////////////
void Skeleton2D::_make_bone_setup_dirty() {
-
- if (bone_setup_dirty)
+ if (bone_setup_dirty) {
return;
+ }
bone_setup_dirty = true;
if (is_inside_tree()) {
call_deferred("_update_bone_setup");
@@ -181,9 +181,9 @@ void Skeleton2D::_make_bone_setup_dirty() {
}
void Skeleton2D::_update_bone_setup() {
-
- if (!bone_setup_dirty)
+ if (!bone_setup_dirty) {
return;
+ }
bone_setup_dirty = false;
RS::get_singleton()->skeleton_allocate(skeleton, bones.size(), true);
@@ -207,9 +207,9 @@ void Skeleton2D::_update_bone_setup() {
}
void Skeleton2D::_make_transform_dirty() {
-
- if (transform_dirty)
+ if (transform_dirty) {
return;
+ }
transform_dirty = true;
if (is_inside_tree()) {
call_deferred("_update_transform");
@@ -217,18 +217,17 @@ void Skeleton2D::_make_transform_dirty() {
}
void Skeleton2D::_update_transform() {
-
if (bone_setup_dirty) {
_update_bone_setup();
return; //above will update transform anyway
}
- if (!transform_dirty)
+ if (!transform_dirty) {
return;
+ }
transform_dirty = false;
for (int i = 0; i < bones.size(); i++) {
-
ERR_CONTINUE(bones[i].parent_index >= i);
if (bones[i].parent_index >= 0) {
bones.write[i].accum_transform = bones[bones[i].parent_index].accum_transform * bones[i].bone->get_transform();
@@ -238,14 +237,12 @@ void Skeleton2D::_update_transform() {
}
for (int i = 0; i < bones.size(); i++) {
-
Transform2D final_xform = bones[i].accum_transform * bones[i].rest_inverse;
RS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform);
}
}
int Skeleton2D::get_bone_count() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), 0);
if (bone_setup_dirty) {
@@ -256,7 +253,6 @@ int Skeleton2D::get_bone_count() const {
}
Bone2D *Skeleton2D::get_bone(int p_idx) {
-
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
ERR_FAIL_INDEX_V(p_idx, bones.size(), nullptr);
@@ -264,13 +260,13 @@ Bone2D *Skeleton2D::get_bone(int p_idx) {
}
void Skeleton2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_READY) {
-
- if (bone_setup_dirty)
+ if (bone_setup_dirty) {
_update_bone_setup();
- if (transform_dirty)
+ }
+ if (transform_dirty) {
_update_transform();
+ }
request_ready();
}
@@ -283,8 +279,8 @@ void Skeleton2D::_notification(int p_what) {
RID Skeleton2D::get_skeleton() const {
return skeleton;
}
-void Skeleton2D::_bind_methods() {
+void Skeleton2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_bone_setup"), &Skeleton2D::_update_bone_setup);
ClassDB::bind_method(D_METHOD("_update_transform"), &Skeleton2D::_update_transform);
@@ -305,6 +301,5 @@ Skeleton2D::Skeleton2D() {
}
Skeleton2D::~Skeleton2D() {
-
RS::get_singleton()->free(skeleton);
}
diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp
index df8859bd9a..7e07019578 100644
--- a/scene/2d/sprite_2d.cpp
+++ b/scene/2d/sprite_2d.cpp
@@ -61,7 +61,6 @@ bool Sprite2D::_edit_use_pivot() const {
}
bool Sprite2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
return is_pixel_opaque(p_point);
}
@@ -79,7 +78,6 @@ Rect2 Sprite2D::get_anchorable_rect() const {
}
void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const {
-
Rect2 base_rect;
if (region) {
@@ -98,28 +96,29 @@ void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_c
r_src_rect.position = base_rect.position + frame_offset;
Point2 dest_offset = offset;
- if (centered)
+ if (centered) {
dest_offset -= frame_size / 2;
+ }
if (Engine::get_singleton()->get_use_pixel_snap()) {
dest_offset = dest_offset.floor();
}
r_dst_rect = Rect2(dest_offset, frame_size);
- if (hflip)
+ if (hflip) {
r_dst_rect.size.x = -r_dst_rect.size.x;
- if (vflip)
+ }
+ if (vflip) {
r_dst_rect.size.y = -r_dst_rect.size.y;
+ }
}
void Sprite2D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return;
+ }
RID ci = get_canvas_item();
@@ -138,17 +137,19 @@ void Sprite2D::_notification(int p_what) {
}
void Sprite2D::set_texture(const Ref<Texture2D> &p_texture) {
-
- if (p_texture == texture)
+ if (p_texture == texture) {
return;
+ }
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed));
+ }
texture = p_texture;
- if (texture.is_valid())
+ if (texture.is_valid()) {
texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite2D::_texture_changed));
+ }
update();
emit_signal("texture_changed");
@@ -157,24 +158,20 @@ void Sprite2D::set_texture(const Ref<Texture2D> &p_texture) {
}
void Sprite2D::set_normal_map(const Ref<Texture2D> &p_texture) {
-
normal_map = p_texture;
update();
}
Ref<Texture2D> Sprite2D::get_normal_map() const {
-
return normal_map;
}
void Sprite2D::set_specular_map(const Ref<Texture2D> &p_texture) {
-
specular = p_texture;
update();
}
Ref<Texture2D> Sprite2D::get_specular_map() const {
-
return specular;
}
@@ -197,83 +194,76 @@ float Sprite2D::get_shininess() const {
}
Ref<Texture2D> Sprite2D::get_texture() const {
-
return texture;
}
void Sprite2D::set_centered(bool p_center) {
-
centered = p_center;
update();
item_rect_changed();
}
bool Sprite2D::is_centered() const {
-
return centered;
}
void Sprite2D::set_offset(const Point2 &p_offset) {
-
offset = p_offset;
update();
item_rect_changed();
_change_notify("offset");
}
-Point2 Sprite2D::get_offset() const {
+Point2 Sprite2D::get_offset() const {
return offset;
}
void Sprite2D::set_flip_h(bool p_flip) {
-
hflip = p_flip;
update();
}
-bool Sprite2D::is_flipped_h() const {
+bool Sprite2D::is_flipped_h() const {
return hflip;
}
void Sprite2D::set_flip_v(bool p_flip) {
-
vflip = p_flip;
update();
}
-bool Sprite2D::is_flipped_v() const {
+bool Sprite2D::is_flipped_v() const {
return vflip;
}
void Sprite2D::set_region(bool p_region) {
-
- if (p_region == region)
+ if (p_region == region) {
return;
+ }
region = p_region;
update();
}
bool Sprite2D::is_region() const {
-
return region;
}
void Sprite2D::set_region_rect(const Rect2 &p_region_rect) {
-
- if (region_rect == p_region_rect)
+ if (region_rect == p_region_rect) {
return;
+ }
region_rect = p_region_rect;
- if (region)
+ if (region) {
item_rect_changed();
+ }
_change_notify("region_rect");
}
Rect2 Sprite2D::get_region_rect() const {
-
return region_rect;
}
@@ -287,11 +277,11 @@ bool Sprite2D::is_region_filter_clip_enabled() const {
}
void Sprite2D::set_frame(int p_frame) {
-
ERR_FAIL_INDEX(p_frame, vframes * hframes);
- if (frame != p_frame)
+ if (frame != p_frame) {
item_rect_changed();
+ }
frame = p_frame;
@@ -301,7 +291,6 @@ void Sprite2D::set_frame(int p_frame) {
}
int Sprite2D::get_frame() const {
-
return frame;
}
@@ -317,52 +306,54 @@ Vector2 Sprite2D::get_frame_coords() const {
}
void Sprite2D::set_vframes(int p_amount) {
-
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of vframes cannot be smaller than 1.");
vframes = p_amount;
update();
item_rect_changed();
_change_notify();
}
-int Sprite2D::get_vframes() const {
+int Sprite2D::get_vframes() const {
return vframes;
}
void Sprite2D::set_hframes(int p_amount) {
-
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of hframes cannot be smaller than 1.");
hframes = p_amount;
update();
item_rect_changed();
_change_notify();
}
-int Sprite2D::get_hframes() const {
+int Sprite2D::get_hframes() const {
return hframes;
}
bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return false;
+ }
- if (texture->get_size().width == 0 || texture->get_size().height == 0)
+ if (texture->get_size().width == 0 || texture->get_size().height == 0) {
return false;
+ }
Rect2 src_rect, dst_rect;
bool filter_clip;
_get_rects(src_rect, dst_rect, filter_clip);
dst_rect.size = dst_rect.size.abs();
- if (!dst_rect.has_point(p_point))
+ if (!dst_rect.has_point(p_point)) {
return false;
+ }
Vector2 q = (p_point - dst_rect.position) / dst_rect.size;
- if (hflip)
+ if (hflip) {
q.x = 1.0f - q.x;
- if (vflip)
+ }
+ if (vflip) {
q.y = 1.0f - q.y;
+ }
q = q * src_rect.size + src_rect.position;
#ifndef _MSC_VER
#warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
@@ -393,9 +384,9 @@ bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const {
}
Rect2 Sprite2D::get_rect() const {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return Rect2(0, 0, 1, 1);
+ }
Size2i s;
@@ -408,17 +399,18 @@ Rect2 Sprite2D::get_rect() const {
s = s / Point2(hframes, vframes);
Point2 ofs = offset;
- if (centered)
+ if (centered) {
ofs -= Size2(s) / 2;
+ }
- if (s == Size2(0, 0))
+ if (s == Size2(0, 0)) {
s = Size2(1, 1);
+ }
return Rect2(ofs, s);
}
void Sprite2D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "frame") {
property.hint = PROPERTY_HINT_RANGE;
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
@@ -431,7 +423,6 @@ void Sprite2D::_validate_property(PropertyInfo &property) const {
}
void Sprite2D::_texture_changed() {
-
// Changes to the texture need to trigger an update to make
// the editor redraw the sprite with the updated texture.
if (texture.is_valid()) {
@@ -440,7 +431,6 @@ void Sprite2D::_texture_changed() {
}
void Sprite2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite2D::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &Sprite2D::get_texture);
@@ -520,7 +510,6 @@ void Sprite2D::_bind_methods() {
}
Sprite2D::Sprite2D() {
-
centered = true;
hflip = false;
vflip = false;
diff --git a/scene/2d/sprite_2d.h b/scene/2d/sprite_2d.h
index 599a9e937e..c72e956307 100644
--- a/scene/2d/sprite_2d.h
+++ b/scene/2d/sprite_2d.h
@@ -35,7 +35,6 @@
#include "scene/resources/texture.h"
class Sprite2D : public Node2D {
-
GDCLASS(Sprite2D, Node2D);
Ref<Texture2D> texture;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 869f290f97..c7a809f6d8 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -39,22 +39,18 @@
#include "servers/physics_server_2d.h"
int TileMap::_get_quadrant_size() const {
-
- if (use_y_sort)
+ if (use_y_sort) {
return 1;
- else
+ } else {
return quadrant_size;
+ }
}
void TileMap::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
Node2D *c = this;
while (c) {
-
navigation = Object::cast_to<Navigation2D>(c);
if (navigation) {
break;
@@ -79,14 +75,11 @@ void TileMap::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
_update_quadrant_space(RID());
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
-
NavigationServer2D::get_singleton()->region_set_map(F->get().region, RID());
}
q.navpoly_ids.clear();
@@ -109,13 +102,11 @@ void TileMap::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
//move stuff
_update_quadrant_transform();
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
-
if (use_parent) {
_recreate_quadrants();
}
@@ -125,10 +116,8 @@ void TileMap::_notification(int p_what) {
}
void TileMap::_update_quadrant_space(const RID &p_space) {
-
if (!use_parent) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
PhysicsServer2D::get_singleton()->body_set_space(q.body, p_space);
}
@@ -136,22 +125,23 @@ void TileMap::_update_quadrant_space(const RID &p_space) {
}
void TileMap::_update_quadrant_transform() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
Transform2D global_transform = get_global_transform();
Transform2D local_transform;
- if (collision_parent)
+ if (collision_parent) {
local_transform = get_transform();
+ }
Transform2D nav_rel;
- if (navigation)
+ if (navigation) {
nav_rel = get_relative_transform_to_parent(navigation);
+ }
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
Transform2D xform;
xform.set_origin(q.pos);
@@ -163,7 +153,6 @@ void TileMap::_update_quadrant_transform() {
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
-
NavigationServer2D::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform);
}
}
@@ -175,7 +164,6 @@ void TileMap::_update_quadrant_transform() {
}
void TileMap::set_tileset(const Ref<TileSet> &p_tileset) {
-
if (tile_set.is_valid()) {
tile_set->disconnect("changed", callable_mp(this, &TileMap::_recreate_quadrants));
tile_set->remove_change_receptor(this);
@@ -196,12 +184,10 @@ void TileMap::set_tileset(const Ref<TileSet> &p_tileset) {
}
Ref<TileSet> TileMap::get_tileset() const {
-
return tile_set;
}
void TileMap::set_cell_size(Size2 p_size) {
-
ERR_FAIL_COND(p_size.x < 1 || p_size.y < 1);
_clear_quadrants();
@@ -211,12 +197,10 @@ void TileMap::set_cell_size(Size2 p_size) {
}
Size2 TileMap::get_cell_size() const {
-
return cell_size;
}
void TileMap::set_quadrant_size(int p_size) {
-
ERR_FAIL_COND_MSG(p_size < 1, "Quadrant size cannot be smaller than 1.");
_clear_quadrants();
@@ -226,17 +210,14 @@ void TileMap::set_quadrant_size(int p_size) {
}
int TileMap::get_quadrant_size() const {
-
return quadrant_size;
}
void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc) {
-
Size2 s = p_sc;
Vector2 offset = p_offset;
if (compatibility_mode && !centered_textures) {
-
if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
offset.y += cell_size.y;
} else if (tile_origin == TILE_ORIGIN_CENTER) {
@@ -326,9 +307,9 @@ void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D>
}
void TileMap::update_dirty_quadrants() {
-
- if (!pending_update)
+ if (!pending_update) {
return;
+ }
if (!is_inside_tree() || !tile_set.is_valid()) {
pending_update = false;
return;
@@ -338,8 +319,9 @@ void TileMap::update_dirty_quadrants() {
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
Vector2 tofs = get_cell_draw_offset();
Transform2D nav_rel;
- if (navigation)
+ if (navigation) {
nav_rel = get_relative_transform_to_parent(navigation);
+ }
Vector2 qofs;
@@ -358,11 +340,9 @@ void TileMap::update_dirty_quadrants() {
}
while (dirty_quadrant_list.first()) {
-
Quadrant &q = *dirty_quadrant_list.first()->self();
for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
-
vs->free(E->get());
}
@@ -377,7 +357,6 @@ void TileMap::update_dirty_quadrants() {
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
-
NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID());
}
q.navpoly_ids.clear();
@@ -393,20 +372,21 @@ void TileMap::update_dirty_quadrants() {
RID prev_debug_canvas_item;
for (int i = 0; i < q.cells.size(); i++) {
-
Map<PosKey, Cell>::Element *E = tile_map.find(q.cells[i]);
Cell &c = E->get();
//moment of truth
- if (!tile_set->has_tile(c.id))
+ if (!tile_set->has_tile(c.id)) {
continue;
+ }
Ref<Texture2D> tex = tile_set->tile_get_texture(c.id);
Vector2 tile_ofs = tile_set->tile_get_texture_offset(c.id);
Vector2 wofs = _map_to_world(E->key().x, E->key().y);
Vector2 offset = wofs - q.pos + tofs;
- if (!tex.is_valid())
+ if (!tex.is_valid()) {
continue;
+ }
Ref<ShaderMaterial> mat = tile_set->tile_get_material(c.id);
int z_index = tile_set->tile_get_z_index(c.id);
@@ -420,10 +400,10 @@ void TileMap::update_dirty_quadrants() {
RID debug_canvas_item;
if (prev_canvas_item == RID() || prev_material != mat || prev_z_index != z_index) {
-
canvas_item = vs->canvas_item_create();
- if (mat.is_valid())
+ if (mat.is_valid()) {
vs->canvas_item_set_material(canvas_item, mat->get_rid());
+ }
vs->canvas_item_set_parent(canvas_item, get_canvas_item());
_update_item_material_state(canvas_item);
Transform2D xform;
@@ -435,7 +415,6 @@ void TileMap::update_dirty_quadrants() {
q.canvas_items.push_back(canvas_item);
if (debug_shapes) {
-
debug_canvas_item = vs->canvas_item_create();
vs->canvas_item_set_parent(debug_canvas_item, canvas_item);
vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item, false);
@@ -463,10 +442,11 @@ void TileMap::update_dirty_quadrants() {
}
Size2 s;
- if (r == Rect2())
+ if (r == Rect2()) {
s = tex->get_size();
- else
+ } else {
s = r.size;
+ }
Rect2 rect;
rect.position = offset.floor();
@@ -476,11 +456,13 @@ void TileMap::update_dirty_quadrants() {
if (compatibility_mode && !centered_textures) {
if (rect.size.y > rect.size.x) {
- if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose))
+ if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose)) {
tile_ofs.y += rect.size.y - rect.size.x;
+ }
} else if (rect.size.y < rect.size.x) {
- if ((c.flip_v && (c.flip_h || c.transpose)) || (c.flip_h && !c.transpose))
+ if ((c.flip_v && (c.flip_h || c.transpose)) || (c.flip_h && !c.transpose)) {
tile_ofs.x += rect.size.x - rect.size.y;
+ }
}
}
@@ -509,34 +491,36 @@ void TileMap::update_dirty_quadrants() {
rect.position += tile_ofs;
} else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
-
rect.position += tile_ofs;
if (c.transpose) {
- if (c.flip_h)
+ if (c.flip_h) {
rect.position.x -= cell_size.x;
- else
+ } else {
rect.position.x += cell_size.x;
+ }
} else {
- if (c.flip_v)
+ if (c.flip_v) {
rect.position.y -= cell_size.y;
- else
+ } else {
rect.position.y += cell_size.y;
+ }
}
} else if (tile_origin == TILE_ORIGIN_CENTER) {
-
rect.position += tile_ofs;
- if (c.flip_h)
+ if (c.flip_h) {
rect.position.x -= cell_size.x / 2;
- else
+ } else {
rect.position.x += cell_size.x / 2;
+ }
- if (c.flip_v)
+ if (c.flip_v) {
rect.position.y -= cell_size.y / 2;
- else
+ } else {
rect.position.y += cell_size.y / 2;
+ }
}
} else {
rect.position += tile_ofs;
@@ -651,10 +635,8 @@ void TileMap::update_dirty_quadrants() {
Vector<int> polygon = navpoly->get_polygon(j);
for (int k = 2; k < polygon.size(); k++) {
-
int kofs[3] = { 0, k - 1, k };
for (int l = 0; l < 3; l++) {
-
int idx = polygon[kofs[l]];
ERR_FAIL_INDEX(idx, vsize);
indices.push_back(idx);
@@ -704,13 +686,10 @@ void TileMap::update_dirty_quadrants() {
pending_update = false;
if (quadrant_order_dirty) {
-
int index = -(int64_t)0x80000000; //always must be drawn below children
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) {
-
RS::get_singleton()->canvas_item_set_draw_index(F->get(), index++);
}
}
@@ -722,24 +701,24 @@ void TileMap::update_dirty_quadrants() {
}
void TileMap::_recompute_rect_cache() {
-
#ifdef DEBUG_ENABLED
- if (!rect_cache_dirty)
+ if (!rect_cache_dirty) {
return;
+ }
Rect2 r_total;
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Rect2 r;
r.position = _map_to_world(E->key().x * _get_quadrant_size(), E->key().y * _get_quadrant_size());
r.expand_to(_map_to_world(E->key().x * _get_quadrant_size() + _get_quadrant_size(), E->key().y * _get_quadrant_size()));
r.expand_to(_map_to_world(E->key().x * _get_quadrant_size() + _get_quadrant_size(), E->key().y * _get_quadrant_size() + _get_quadrant_size()));
r.expand_to(_map_to_world(E->key().x * _get_quadrant_size(), E->key().y * _get_quadrant_size() + _get_quadrant_size()));
- if (E == quadrant_map.front())
+ if (E == quadrant_map.front()) {
r_total = r;
- else
+ } else {
r_total = r_total.merge(r);
+ }
}
rect_cache = r_total;
@@ -751,16 +730,16 @@ void TileMap::_recompute_rect_cache() {
}
Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(const PosKey &p_qk) {
-
Transform2D xform;
//xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size);
Quadrant q;
q.pos = _map_to_world(p_qk.x * _get_quadrant_size(), p_qk.y * _get_quadrant_size());
q.pos += get_cell_draw_offset();
- if (tile_origin == TILE_ORIGIN_CENTER)
+ if (tile_origin == TILE_ORIGIN_CENTER) {
q.pos += cell_size / 2;
- else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT)
+ } else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
q.pos.y += cell_size.y;
+ }
xform.set_origin(q.pos);
//q.canvas_item = RenderingServer::get_singleton()->canvas_item_create();
@@ -794,7 +773,6 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
}
void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
-
Quadrant &q = Q->get();
if (!use_parent) {
PhysicsServer2D::get_singleton()->free(q.body);
@@ -803,16 +781,15 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
}
for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
-
RenderingServer::get_singleton()->free(E->get());
}
q.canvas_items.clear();
- if (q.dirty_list.in_list())
+ if (q.dirty_list.in_list()) {
dirty_quadrant_list.remove(&q.dirty_list);
+ }
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
-
NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID());
}
q.navpoly_ids.clear();
@@ -828,16 +805,18 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
}
void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool update) {
-
Quadrant &q = Q->get();
- if (!q.dirty_list.in_list())
+ if (!q.dirty_list.in_list()) {
dirty_quadrant_list.add(&q.dirty_list);
+ }
- if (pending_update)
+ if (pending_update) {
return;
+ }
pending_update = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (update) {
call_deferred("update_dirty_quadrants");
@@ -845,12 +824,10 @@ void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool updat
}
void TileMap::set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose) {
-
set_cell(p_pos.x, p_pos.y, p_tile, p_flip_x, p_flip_y, p_transpose);
}
void TileMap::_set_celld(const Vector2 &p_pos, const Dictionary &p_data) {
-
Variant v_pos_x = p_pos.x, v_pos_y = p_pos.y, v_tile = p_data["id"], v_flip_h = p_data["flip_h"], v_flip_v = p_data["flip_y"], v_transpose = p_data["transpose"], v_autotile_coord = p_data["auto_coord"];
const Variant *args[7] = { &v_pos_x, &v_pos_y, &v_tile, &v_flip_h, &v_flip_v, &v_transpose, &v_autotile_coord };
Callable::CallError ce;
@@ -858,12 +835,12 @@ void TileMap::_set_celld(const Vector2 &p_pos, const Dictionary &p_data) {
}
void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose, Vector2 p_autotile_coord) {
-
PosKey pk(p_x, p_y);
Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E && p_tile == INVALID_CELL)
+ if (!E && p_tile == INVALID_CELL) {
return; //nothing to do
+ }
PosKey qk = pk.to_quadrant(_get_quadrant_size());
if (p_tile == INVALID_CELL) {
@@ -873,10 +850,11 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_
ERR_FAIL_COND(!Q);
Quadrant &q = Q->get();
q.cells.erase(pk);
- if (q.cells.size() == 0)
+ if (q.cells.size() == 0) {
_erase_quadrant(Q);
- else
+ } else {
_make_quadrant_dirty(Q);
+ }
used_size_cache_dirty = true;
return;
@@ -894,8 +872,9 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_
} else {
ERR_FAIL_COND(!Q); // quadrant should exist...
- if (E->get().id == p_tile && E->get().flip_h == p_flip_x && E->get().flip_v == p_flip_y && E->get().transpose == p_transpose && E->get().autotile_coord_x == (uint16_t)p_autotile_coord.x && E->get().autotile_coord_y == (uint16_t)p_autotile_coord.y)
+ if (E->get().id == p_tile && E->get().flip_h == p_flip_x && E->get().flip_v == p_flip_y && E->get().transpose == p_transpose && E->get().autotile_coord_x == (uint16_t)p_autotile_coord.x && E->get().autotile_coord_y == (uint16_t)p_autotile_coord.y) {
return; //nothing changed
+ }
}
Cell &c = E->get();
@@ -912,12 +891,10 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_
}
int TileMap::get_cellv(const Vector2 &p_pos) const {
-
return get_cell(p_pos.x, p_pos.y);
}
void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) {
-
for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) {
for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) {
PosKey p(x, y);
@@ -929,7 +906,6 @@ void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) {
}
void TileMap::update_bitmask_area(const Vector2 &p_pos) {
-
for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) {
for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) {
update_cell_bitmask(x, y);
@@ -938,7 +914,6 @@ void TileMap::update_bitmask_area(const Vector2 &p_pos) {
}
void TileMap::update_bitmask_region(const Vector2 &p_start, const Vector2 &p_end) {
-
if ((p_end.x < p_start.x || p_end.y < p_start.y) || (p_end.x == p_start.x && p_end.y == p_start.y)) {
Array a = get_used_cells();
for (int i = 0; i < a.size(); i++) {
@@ -955,7 +930,6 @@ void TileMap::update_bitmask_region(const Vector2 &p_start, const Vector2 &p_end
}
void TileMap::update_cell_bitmask(int p_x, int p_y) {
-
ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot update cell bitmask if Tileset is not open.");
PosKey p(p_x, p_y);
Map<PosKey, Cell>::Element *E = tile_map.find(p);
@@ -1027,11 +1001,9 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
_make_quadrant_dirty(Q);
} else if (tile_set->tile_get_tile_mode(id) == TileSet::SINGLE_TILE) {
-
E->get().autotile_coord_x = 0;
E->get().autotile_coord_y = 0;
} else if (tile_set->tile_get_tile_mode(id) == TileSet::ATLAS_TILE) {
-
if (tile_set->autotile_get_bitmask(id, Vector2(p_x, p_y)) == TileSet::BIND_CENTER) {
Vector2 coord = tile_set->atlastile_get_subtile_by_priority(id, this, Vector2(p_x, p_y));
@@ -1043,7 +1015,6 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
}
void TileMap::update_dirty_bitmask() {
-
while (dirty_bitmask.size() > 0) {
update_cell_bitmask(dirty_bitmask[0].x, dirty_bitmask[0].y);
dirty_bitmask.pop_front();
@@ -1051,10 +1022,8 @@ void TileMap::update_dirty_bitmask() {
}
void TileMap::fix_invalid_tiles() {
-
ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot fix invalid tiles if Tileset is not open.");
for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
-
if (!tile_set->has_tile(get_cell(E->key().x, E->key().y))) {
set_cell(E->key().x, E->key().y, INVALID_CELL);
}
@@ -1062,58 +1031,61 @@ void TileMap::fix_invalid_tiles() {
}
int TileMap::get_cell(int p_x, int p_y) const {
-
PosKey pk(p_x, p_y);
const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E)
+ if (!E) {
return INVALID_CELL;
+ }
return E->get().id;
}
-bool TileMap::is_cell_x_flipped(int p_x, int p_y) const {
+bool TileMap::is_cell_x_flipped(int p_x, int p_y) const {
PosKey pk(p_x, p_y);
const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().flip_h;
}
-bool TileMap::is_cell_y_flipped(int p_x, int p_y) const {
+bool TileMap::is_cell_y_flipped(int p_x, int p_y) const {
PosKey pk(p_x, p_y);
const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().flip_v;
}
-bool TileMap::is_cell_transposed(int p_x, int p_y) const {
+bool TileMap::is_cell_transposed(int p_x, int p_y) const {
PosKey pk(p_x, p_y);
const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().transpose;
}
void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord) {
-
PosKey pk(p_x, p_y);
const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E)
+ if (!E) {
return;
+ }
Cell c = E->get();
c.autotile_coord_x = p_coord.x;
@@ -1123,30 +1095,29 @@ void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord)
PosKey qk = pk.to_quadrant(_get_quadrant_size());
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
- if (!Q)
+ if (!Q) {
return;
+ }
_make_quadrant_dirty(Q);
}
Vector2 TileMap::get_cell_autotile_coord(int p_x, int p_y) const {
-
PosKey pk(p_x, p_y);
const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
- if (!E)
+ if (!E) {
return Vector2();
+ }
return Vector2(E->get().autotile_coord_x, E->get().autotile_coord_y);
}
void TileMap::_recreate_quadrants() {
-
_clear_quadrants();
for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
-
PosKey qk = PosKey(E->key().x, E->key().y).to_quadrant(_get_quadrant_size());
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
@@ -1162,50 +1133,41 @@ void TileMap::_recreate_quadrants() {
}
void TileMap::_clear_quadrants() {
-
while (quadrant_map.size()) {
_erase_quadrant(quadrant_map.front());
}
}
void TileMap::set_material(const Ref<Material> &p_material) {
-
CanvasItem::set_material(p_material);
_update_all_items_material_state();
}
void TileMap::set_use_parent_material(bool p_use_parent_material) {
-
CanvasItem::set_use_parent_material(p_use_parent_material);
_update_all_items_material_state();
}
void TileMap::_update_all_items_material_state() {
-
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) {
-
_update_item_material_state(F->get());
}
}
}
void TileMap::_update_item_material_state(const RID &p_canvas_item) {
-
RS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid());
}
void TileMap::clear() {
-
_clear_quadrants();
tile_map.clear();
used_size_cache_dirty = true;
}
void TileMap::_set_tile_data(const Vector<int> &p_data) {
-
ERR_FAIL_COND(format > FORMAT_2);
int c = p_data.size();
@@ -1215,11 +1177,11 @@ void TileMap::_set_tile_data(const Vector<int> &p_data) {
clear();
for (int i = 0; i < c; i += offset) {
-
const uint8_t *ptr = (const uint8_t *)&r[i];
uint8_t local[12];
- for (int j = 0; j < ((format == FORMAT_2) ? 12 : 8); j++)
+ for (int j = 0; j < ((format == FORMAT_2) ? 12 : 8); j++) {
local[j] = ptr[j];
+ }
#ifdef BIG_ENDIAN_ENABLED
@@ -1253,7 +1215,6 @@ void TileMap::_set_tile_data(const Vector<int> &p_data) {
}
Vector<int> TileMap::_get_tile_data() const {
-
Vector<int> data;
data.resize(tile_map.size() * 3);
int *w = data.ptrw();
@@ -1266,12 +1227,15 @@ Vector<int> TileMap::_get_tile_data() const {
encode_uint16(E->key().x, &ptr[0]);
encode_uint16(E->key().y, &ptr[2]);
uint32_t val = E->get().id;
- if (E->get().flip_h)
+ if (E->get().flip_h) {
val |= (1 << 29);
- if (E->get().flip_v)
+ }
+ if (E->get().flip_v) {
val |= (1 << 30);
- if (E->get().transpose)
+ }
+ if (E->get().transpose) {
val |= (1 << 31);
+ }
encode_uint32(val, &ptr[4]);
encode_uint16(E->get().autotile_coord_x, &ptr[8]);
encode_uint16(E->get().autotile_coord_y, &ptr[10]);
@@ -1293,11 +1257,9 @@ Rect2 TileMap::_edit_get_rect() const {
#endif
void TileMap::set_collision_layer(uint32_t p_layer) {
-
collision_layer = p_layer;
if (!use_parent) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
PhysicsServer2D::get_singleton()->body_set_collision_layer(q.body, collision_layer);
}
@@ -1305,11 +1267,9 @@ void TileMap::set_collision_layer(uint32_t p_layer) {
}
void TileMap::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
if (!use_parent) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
PhysicsServer2D::get_singleton()->body_set_collision_mask(q.body, collision_mask);
}
@@ -1317,46 +1277,43 @@ void TileMap::set_collision_mask(uint32_t p_mask) {
}
void TileMap::set_collision_layer_bit(int p_bit, bool p_value) {
-
uint32_t layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
layer |= 1 << p_bit;
- else
+ } else {
layer &= ~(1 << p_bit);
+ }
set_collision_layer(layer);
}
void TileMap::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool TileMap::get_collision_use_kinematic() const {
-
return use_kinematic;
}
void TileMap::set_collision_use_kinematic(bool p_use_kinematic) {
-
_clear_quadrants();
use_kinematic = p_use_kinematic;
_recreate_quadrants();
}
bool TileMap::get_collision_use_parent() const {
-
return use_parent;
}
void TileMap::set_collision_use_parent(bool p_use_parent) {
-
- if (use_parent == p_use_parent)
+ if (use_parent == p_use_parent) {
return;
+ }
_clear_quadrants();
@@ -1375,11 +1332,9 @@ void TileMap::set_collision_use_parent(bool p_use_parent) {
}
void TileMap::set_collision_friction(float p_friction) {
-
friction = p_friction;
if (!use_parent) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_FRICTION, p_friction);
}
@@ -1387,48 +1342,40 @@ void TileMap::set_collision_friction(float p_friction) {
}
float TileMap::get_collision_friction() const {
-
return friction;
}
void TileMap::set_collision_bounce(float p_bounce) {
-
bounce = p_bounce;
if (!use_parent) {
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
Quadrant &q = E->get();
PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_BOUNCE, p_bounce);
}
}
}
-float TileMap::get_collision_bounce() const {
+float TileMap::get_collision_bounce() const {
return bounce;
}
uint32_t TileMap::get_collision_layer() const {
-
return collision_layer;
}
uint32_t TileMap::get_collision_mask() const {
-
return collision_mask;
}
bool TileMap::get_collision_layer_bit(int p_bit) const {
-
return get_collision_layer() & (1 << p_bit);
}
bool TileMap::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
void TileMap::set_mode(Mode p_mode) {
-
_clear_quadrants();
mode = p_mode;
_recreate_quadrants();
@@ -1440,7 +1387,6 @@ TileMap::Mode TileMap::get_mode() const {
}
void TileMap::set_half_offset(HalfOffset p_half_offset) {
-
_clear_quadrants();
half_offset = p_half_offset;
_recreate_quadrants();
@@ -1448,7 +1394,6 @@ void TileMap::set_half_offset(HalfOffset p_half_offset) {
}
void TileMap::set_tile_origin(TileOrigin p_tile_origin) {
-
_clear_quadrants();
tile_origin = p_tile_origin;
_recreate_quadrants();
@@ -1456,25 +1401,19 @@ void TileMap::set_tile_origin(TileOrigin p_tile_origin) {
}
TileMap::TileOrigin TileMap::get_tile_origin() const {
-
return tile_origin;
}
Vector2 TileMap::get_cell_draw_offset() const {
-
switch (mode) {
-
case MODE_SQUARE: {
-
return Vector2();
} break;
case MODE_ISOMETRIC: {
-
return Vector2(-cell_size.x * 0.5, 0);
} break;
case MODE_CUSTOM: {
-
Vector2 min;
min.x = MIN(custom_transform[0].x, min.x);
min.y = MIN(custom_transform[0].y, min.y);
@@ -1492,18 +1431,14 @@ TileMap::HalfOffset TileMap::get_half_offset() const {
}
Transform2D TileMap::get_cell_transform() const {
-
switch (mode) {
-
case MODE_SQUARE: {
-
Transform2D m;
m[0] *= cell_size.x;
m[1] *= cell_size.y;
return m;
} break;
case MODE_ISOMETRIC: {
-
//isometric only makes sense when y is positive in both x and y vectors, otherwise
//the drawing of tiles will overlap
Transform2D m;
@@ -1513,7 +1448,6 @@ Transform2D TileMap::get_cell_transform() const {
} break;
case MODE_CUSTOM: {
-
return custom_transform;
} break;
}
@@ -1522,7 +1456,6 @@ Transform2D TileMap::get_cell_transform() const {
}
void TileMap::set_custom_transform(const Transform2D &p_xform) {
-
_clear_quadrants();
custom_transform = p_xform;
_recreate_quadrants();
@@ -1530,20 +1463,16 @@ void TileMap::set_custom_transform(const Transform2D &p_xform) {
}
Transform2D TileMap::get_custom_transform() const {
-
return custom_transform;
}
Vector2 TileMap::_map_to_world(int p_x, int p_y, bool p_ignore_ofs) const {
-
Vector2 ret = get_cell_transform().xform(Vector2(p_x, p_y));
if (!p_ignore_ofs) {
switch (half_offset) {
-
case HALF_OFFSET_X:
case HALF_OFFSET_NEGATIVE_X: {
if (ABS(p_y) & 1) {
-
ret += get_cell_transform()[0] * (half_offset == HALF_OFFSET_X ? 0.5 : -0.5);
}
} break;
@@ -1562,7 +1491,6 @@ Vector2 TileMap::_map_to_world(int p_x, int p_y, bool p_ignore_ofs) const {
}
bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
-
if (p_name == "format") {
if (p_value.get_type() == Variant::INT) {
format = (DataFormat)(p_value.operator int64_t()); // Set format used for loading
@@ -1579,7 +1507,6 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
}
bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {
-
if (p_name == "format") {
r_ret = FORMAT_2; // When saving, always save highest format
return true;
@@ -1591,7 +1518,6 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {
}
void TileMap::_get_property_list(List<PropertyInfo> *p_list) const {
-
PropertyInfo p(Variant::INT, "format", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL);
p_list->push_back(p);
@@ -1606,16 +1532,13 @@ void TileMap::_validate_property(PropertyInfo &property) const {
}
Vector2 TileMap::map_to_world(const Vector2 &p_pos, bool p_ignore_ofs) const {
-
return _map_to_world(p_pos.x, p_pos.y, p_ignore_ofs);
}
Vector2 TileMap::world_to_map(const Vector2 &p_pos) const {
-
Vector2 ret = get_cell_transform().affine_inverse().xform(p_pos);
switch (half_offset) {
-
case HALF_OFFSET_X: {
if (int(floor(ret.y)) & 1) {
ret.x -= 0.5;
@@ -1650,7 +1573,6 @@ Vector2 TileMap::world_to_map(const Vector2 &p_pos) const {
}
void TileMap::set_y_sort_enabled(bool p_enable) {
-
_clear_quadrants();
use_y_sort = p_enable;
RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), use_y_sort);
@@ -1659,12 +1581,10 @@ void TileMap::set_y_sort_enabled(bool p_enable) {
}
bool TileMap::is_y_sort_enabled() const {
-
return use_y_sort;
}
void TileMap::set_compatibility_mode(bool p_enable) {
-
_clear_quadrants();
compatibility_mode = p_enable;
_recreate_quadrants();
@@ -1672,12 +1592,10 @@ void TileMap::set_compatibility_mode(bool p_enable) {
}
bool TileMap::is_compatibility_mode_enabled() const {
-
return compatibility_mode;
}
void TileMap::set_centered_textures(bool p_enable) {
-
_clear_quadrants();
centered_textures = p_enable;
_recreate_quadrants();
@@ -1685,17 +1603,14 @@ void TileMap::set_centered_textures(bool p_enable) {
}
bool TileMap::is_centered_textures_enabled() const {
-
return centered_textures;
}
TypedArray<Vector2i> TileMap::get_used_cells() const {
-
TypedArray<Vector2i> a;
a.resize(tile_map.size());
int i = 0;
for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
-
Vector2i p(E->key().x, E->key().y);
a[i++] = p;
}
@@ -1704,10 +1619,8 @@ TypedArray<Vector2i> TileMap::get_used_cells() const {
}
TypedArray<Vector2i> TileMap::get_used_cells_by_index(int p_id) const {
-
TypedArray<Vector2i> a;
for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
-
if (E->value().id == p_id) {
Vector2i p(E->key().x, E->key().y);
a.push_back(p);
@@ -1739,10 +1652,8 @@ Rect2 TileMap::get_used_rect() { // Not const because of cache
}
void TileMap::set_occluder_light_mask(int p_mask) {
-
occluder_light_mask = p_mask;
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
for (Map<PosKey, Quadrant::Occluder>::Element *F = E->get().occluder_instances.front(); F; F = F->next()) {
RenderingServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask);
}
@@ -1750,15 +1661,12 @@ void TileMap::set_occluder_light_mask(int p_mask) {
}
int TileMap::get_occluder_light_mask() const {
-
return occluder_light_mask;
}
void TileMap::set_light_mask(int p_light_mask) {
-
CanvasItem::set_light_mask(p_light_mask);
for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
-
for (List<RID>::Element *F = E->get().canvas_items.front(); F; F = F->next()) {
RenderingServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask());
}
@@ -1766,9 +1674,9 @@ void TileMap::set_light_mask(int p_light_mask) {
}
void TileMap::set_clip_uv(bool p_enable) {
-
- if (clip_uv == p_enable)
+ if (clip_uv == p_enable) {
return;
+ }
_clear_quadrants();
clip_uv = p_enable;
@@ -1776,12 +1684,10 @@ void TileMap::set_clip_uv(bool p_enable) {
}
bool TileMap::get_clip_uv() const {
-
return clip_uv;
}
String TileMap::get_configuration_warning() const {
-
String warning = Node2D::get_configuration_warning();
if (use_parent && !collision_parent) {
@@ -1795,7 +1701,6 @@ String TileMap::get_configuration_warning() const {
}
void TileMap::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMap::set_tileset);
ClassDB::bind_method(D_METHOD("get_tileset"), &TileMap::get_tileset);
@@ -1942,7 +1847,6 @@ void TileMap::_changed_callback(Object *p_changed, const char *p_prop) {
}
TileMap::TileMap() {
-
rect_cache_dirty = true;
used_size_cache_dirty = true;
pending_update = false;
@@ -1974,9 +1878,9 @@ TileMap::TileMap() {
}
TileMap::~TileMap() {
-
- if (tile_set.is_valid())
+ if (tile_set.is_valid()) {
tile_set->remove_change_receptor(this);
+ }
clear();
}
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 16784571bf..24d4dc09db 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -40,7 +40,6 @@
class CollisionObject2D;
class TileMap : public Node2D {
-
GDCLASS(TileMap, Node2D);
public:
@@ -82,7 +81,6 @@ private:
Navigation2D *navigation;
union PosKey {
-
struct {
int16_t x;
int16_t y;
@@ -112,7 +110,6 @@ private:
};
union Cell {
-
struct {
int32_t id : 24;
bool flip_h : 1;
@@ -130,7 +127,6 @@ private:
List<PosKey> dirty_bitmask;
struct Quadrant {
-
Vector2 pos;
List<RID> canvas_items;
RID body;
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp
index 590cc1e6c4..4597300db8 100644
--- a/scene/2d/touch_screen_button.cpp
+++ b/scene/2d/touch_screen_button.cpp
@@ -36,104 +36,96 @@
#include "scene/main/window.h"
#
void TouchScreenButton::set_texture(const Ref<Texture2D> &p_texture) {
-
texture = p_texture;
update();
}
Ref<Texture2D> TouchScreenButton::get_texture() const {
-
return texture;
}
void TouchScreenButton::set_texture_pressed(const Ref<Texture2D> &p_texture_pressed) {
-
texture_pressed = p_texture_pressed;
update();
}
Ref<Texture2D> TouchScreenButton::get_texture_pressed() const {
-
return texture_pressed;
}
void TouchScreenButton::set_bitmask(const Ref<BitMap> &p_bitmask) {
-
bitmask = p_bitmask;
}
Ref<BitMap> TouchScreenButton::get_bitmask() const {
-
return bitmask;
}
void TouchScreenButton::set_shape(const Ref<Shape2D> &p_shape) {
-
- if (shape.is_valid())
+ if (shape.is_valid()) {
shape->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update));
+ }
shape = p_shape;
- if (shape.is_valid())
+ if (shape.is_valid()) {
shape->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update));
+ }
update();
}
Ref<Shape2D> TouchScreenButton::get_shape() const {
-
return shape;
}
void TouchScreenButton::set_shape_centered(bool p_shape_centered) {
-
shape_centered = p_shape_centered;
update();
}
bool TouchScreenButton::is_shape_visible() const {
-
return shape_visible;
}
void TouchScreenButton::set_shape_visible(bool p_shape_visible) {
-
shape_visible = p_shape_visible;
update();
}
bool TouchScreenButton::is_shape_centered() const {
-
return shape_centered;
}
void TouchScreenButton::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
- if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ }
+ if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY) {
return;
+ }
if (finger_pressed != -1) {
-
- if (texture_pressed.is_valid())
+ if (texture_pressed.is_valid()) {
draw_texture(texture_pressed, Point2());
- else if (texture.is_valid())
+ } else if (texture.is_valid()) {
draw_texture(texture, Point2());
+ }
} else {
- if (texture.is_valid())
+ if (texture.is_valid()) {
draw_texture(texture, Point2());
+ }
}
- if (!shape_visible)
+ if (!shape_visible) {
return;
- if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ }
+ if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
return;
+ }
if (shape.is_valid()) {
Color draw_col = get_tree()->get_debug_collisions_color();
@@ -145,80 +137,79 @@ void TouchScreenButton::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
-
- if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!Engine::get_singleton()->is_editor_hint() && !!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())) && visibility == VISIBILITY_TOUCHSCREEN_ONLY) {
return;
+ }
update();
- if (!Engine::get_singleton()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint()) {
set_process_input(is_visible_in_tree());
+ }
} break;
case NOTIFICATION_EXIT_TREE: {
- if (is_pressed())
+ if (is_pressed()) {
_release(true);
+ }
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
break;
+ }
if (is_visible_in_tree()) {
set_process_input(true);
} else {
set_process_input(false);
- if (is_pressed())
+ if (is_pressed()) {
_release();
+ }
}
} break;
case NOTIFICATION_PAUSED: {
- if (is_pressed())
+ if (is_pressed()) {
_release();
+ }
} break;
}
}
bool TouchScreenButton::is_pressed() const {
-
return finger_pressed != -1;
}
void TouchScreenButton::set_action(const String &p_action) {
-
action = p_action;
}
String TouchScreenButton::get_action() const {
-
return action;
}
void TouchScreenButton::_input(const Ref<InputEvent> &p_event) {
-
- if (!get_tree())
+ if (!get_tree()) {
return;
+ }
- if (p_event->get_device() != 0)
+ if (p_event->get_device() != 0) {
return;
+ }
ERR_FAIL_COND(!is_visible_in_tree());
const InputEventScreenTouch *st = Object::cast_to<InputEventScreenTouch>(*p_event);
if (passby_press) {
-
const InputEventScreenDrag *sd = Object::cast_to<InputEventScreenDrag>(*p_event);
if (st && !st->is_pressed() && finger_pressed == st->get_index()) {
-
_release();
}
if ((st && st->is_pressed()) || sd) {
-
int index = st ? st->get_index() : sd->get_index();
Point2 coord = st ? st->get_position() : sd->get_position();
if (finger_pressed == -1 || index == finger_pressed) {
-
if (_is_point_inside(coord)) {
if (finger_pressed == -1) {
_press(index);
@@ -232,14 +223,12 @@ void TouchScreenButton::_input(const Ref<InputEvent> &p_event) {
}
} else {
-
if (st) {
-
if (st->is_pressed()) {
-
const bool can_press = finger_pressed == -1;
- if (!can_press)
+ if (!can_press) {
return; //already fingering
+ }
if (_is_point_inside(st->get_position())) {
_press(st->get_index());
@@ -268,29 +257,27 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
}
if (bitmask.is_valid()) {
-
check_rect = false;
if (!touched && Rect2(Point2(), bitmask->get_size()).has_point(coord)) {
-
- if (bitmask->get_bit(coord))
+ if (bitmask->get_bit(coord)) {
touched = true;
+ }
}
}
if (!touched && check_rect) {
- if (texture.is_valid())
+ if (texture.is_valid()) {
touched = Rect2(Size2(), texture->get_size()).has_point(coord);
+ }
}
return touched;
}
void TouchScreenButton::_press(int p_finger_pressed) {
-
finger_pressed = p_finger_pressed;
if (action != StringName()) {
-
Input::get_singleton()->action_press(action);
Ref<InputEventAction> iea;
iea.instance();
@@ -304,14 +291,11 @@ void TouchScreenButton::_press(int p_finger_pressed) {
}
void TouchScreenButton::_release(bool p_exiting_tree) {
-
finger_pressed = -1;
if (action != StringName()) {
-
Input::get_singleton()->action_release(action);
if (!p_exiting_tree) {
-
Ref<InputEventAction> iea;
iea.instance();
iea->set_action(action);
@@ -328,8 +312,9 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
#ifdef TOOLS_ENABLED
Rect2 TouchScreenButton::_edit_get_rect() const {
- if (texture.is_null())
+ if (texture.is_null()) {
return CanvasItem::_edit_get_rect();
+ }
return Rect2(Size2(), texture->get_size());
}
@@ -340,8 +325,9 @@ bool TouchScreenButton::_edit_use_rect() const {
#endif
Rect2 TouchScreenButton::get_anchorable_rect() const {
- if (texture.is_null())
+ if (texture.is_null()) {
return CanvasItem::get_anchorable_rect();
+ }
return Rect2(Size2(), texture->get_size());
}
@@ -352,22 +338,18 @@ void TouchScreenButton::set_visibility_mode(VisibilityMode p_mode) {
}
TouchScreenButton::VisibilityMode TouchScreenButton::get_visibility_mode() const {
-
return visibility;
}
void TouchScreenButton::set_passby_press(bool p_enable) {
-
passby_press = p_enable;
}
bool TouchScreenButton::is_passby_press_enabled() const {
-
return passby_press;
}
void TouchScreenButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TouchScreenButton::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &TouchScreenButton::get_texture);
@@ -417,7 +399,6 @@ void TouchScreenButton::_bind_methods() {
}
TouchScreenButton::TouchScreenButton() {
-
finger_pressed = -1;
passby_press = false;
visibility = VISIBILITY_ALWAYS;
diff --git a/scene/2d/touch_screen_button.h b/scene/2d/touch_screen_button.h
index 42e93f7048..d9c7ef7034 100644
--- a/scene/2d/touch_screen_button.h
+++ b/scene/2d/touch_screen_button.h
@@ -37,7 +37,6 @@
#include "scene/resources/texture.h"
class TouchScreenButton : public Node2D {
-
GDCLASS(TouchScreenButton, Node2D);
public:
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 780d08693d..75154c7acb 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -49,12 +49,12 @@ bool VisibilityNotifier2D::_edit_use_rect() const {
#endif
void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
-
ERR_FAIL_COND(viewports.has(p_viewport));
viewports.insert(p_viewport);
- if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
return;
+ }
if (viewports.size() == 1) {
emit_signal(SceneStringNames::get_singleton()->screen_entered);
@@ -65,12 +65,12 @@ void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
}
void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) {
-
ERR_FAIL_COND(!viewports.has(p_viewport));
viewports.erase(p_viewport);
- if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
return;
+ }
emit_signal(SceneStringNames::get_singleton()->viewport_exited, p_viewport);
if (viewports.size() == 0) {
@@ -81,7 +81,6 @@ void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) {
}
void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
-
rect = p_rect;
if (is_inside_tree()) {
get_world_2d()->_update_notifier(this, get_global_transform().xform(rect));
@@ -95,44 +94,35 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
}
Rect2 VisibilityNotifier2D::get_rect() const {
-
return rect;
}
void VisibilityNotifier2D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
//get_world_2d()->
get_world_2d()->_register_notifier(this, get_global_transform().xform(rect));
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
//get_world_2d()->
get_world_2d()->_update_notifier(this, get_global_transform().xform(rect));
} break;
case NOTIFICATION_DRAW: {
-
if (Engine::get_singleton()->is_editor_hint()) {
-
draw_rect(rect, Color(1, 0.5, 1, 0.2));
}
} break;
case NOTIFICATION_EXIT_TREE: {
-
get_world_2d()->_remove_notifier(this);
} break;
}
}
bool VisibilityNotifier2D::is_on_screen() const {
-
return viewports.size() > 0;
}
void VisibilityNotifier2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_rect", "rect"), &VisibilityNotifier2D::set_rect);
ClassDB::bind_method(D_METHOD("get_rect"), &VisibilityNotifier2D::get_rect);
ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier2D::is_on_screen);
@@ -146,7 +136,6 @@ void VisibilityNotifier2D::_bind_methods() {
}
VisibilityNotifier2D::VisibilityNotifier2D() {
-
rect = Rect2(-10, -10, 20, 20);
set_notify_transform(true);
}
@@ -154,44 +143,42 @@ VisibilityNotifier2D::VisibilityNotifier2D() {
//////////////////////////////////////
void VisibilityEnabler2D::_screen_enter() {
-
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
-
_change_node_state(E->key(), true);
}
- if (enabler[ENABLER_PARENT_PHYSICS_PROCESS] && get_parent())
+ if (enabler[ENABLER_PARENT_PHYSICS_PROCESS] && get_parent()) {
get_parent()->set_physics_process(true);
- if (enabler[ENABLER_PARENT_PROCESS] && get_parent())
+ }
+ if (enabler[ENABLER_PARENT_PROCESS] && get_parent()) {
get_parent()->set_process(true);
+ }
visible = true;
}
void VisibilityEnabler2D::_screen_exit() {
-
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
-
_change_node_state(E->key(), false);
}
- if (enabler[ENABLER_PARENT_PHYSICS_PROCESS] && get_parent())
+ if (enabler[ENABLER_PARENT_PHYSICS_PROCESS] && get_parent()) {
get_parent()->set_physics_process(false);
- if (enabler[ENABLER_PARENT_PROCESS] && get_parent())
+ }
+ if (enabler[ENABLER_PARENT_PROCESS] && get_parent()) {
get_parent()->set_process(false);
+ }
visible = false;
}
void VisibilityEnabler2D::_find_nodes(Node *p_node) {
-
bool add = false;
Variant meta;
{
RigidBody2D *rb2d = Object::cast_to<RigidBody2D>(p_node);
if (rb2d && ((rb2d->get_mode() == RigidBody2D::MODE_CHARACTER || rb2d->get_mode() == RigidBody2D::MODE_RIGID))) {
-
add = true;
meta = rb2d->get_mode();
}
@@ -219,7 +206,6 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
}
if (add) {
-
p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler2D::_node_removed), varray(p_node), CONNECT_ONESHOT);
nodes[p_node] = meta;
_change_node_state(p_node, false);
@@ -227,24 +213,25 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (c->get_filename() != String())
+ if (c->get_filename() != String()) {
continue; //skip, instance
+ }
_find_nodes(c);
}
}
void VisibilityEnabler2D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Node *from = this;
//find where current scene starts
- while (from->get_parent() && from->get_filename() == String())
+ while (from->get_parent() && from->get_filename() == String()) {
from = from->get_parent();
+ }
_find_nodes(from);
@@ -264,14 +251,14 @@ void VisibilityEnabler2D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
-
- if (!visible)
+ if (!visible) {
_change_node_state(E->key(), true);
+ }
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler2D::_node_removed));
}
@@ -280,13 +267,11 @@ void VisibilityEnabler2D::_notification(int p_what) {
}
void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
-
ERR_FAIL_COND(!nodes.has(p_node));
if (enabler[ENABLER_FREEZE_BODIES]) {
RigidBody2D *rb = Object::cast_to<RigidBody2D>(p_node);
if (rb) {
-
rb->set_sleeping(!p_enabled);
}
}
@@ -295,7 +280,6 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
-
ap->set_active(p_enabled);
}
}
@@ -304,11 +288,11 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node);
if (as) {
-
- if (p_enabled)
+ if (p_enabled) {
as->play();
- else
+ } else {
as->stop();
+ }
}
}
@@ -316,16 +300,15 @@ void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
GPUParticles2D *ps = Object::cast_to<GPUParticles2D>(p_node);
if (ps) {
-
ps->set_emitting(p_enabled);
}
}
}
void VisibilityEnabler2D::_node_removed(Node *p_node) {
-
- if (!visible)
+ if (!visible) {
_change_node_state(p_node, true);
+ }
nodes.erase(p_node);
}
@@ -339,7 +322,6 @@ String VisibilityEnabler2D::get_configuration_warning() const {
}
void VisibilityEnabler2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler2D::set_enabler);
ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler2D::is_enabler_enabled);
ClassDB::bind_method(D_METHOD("_node_removed"), &VisibilityEnabler2D::_node_removed);
@@ -361,20 +343,19 @@ void VisibilityEnabler2D::_bind_methods() {
}
void VisibilityEnabler2D::set_enabler(Enabler p_enabler, bool p_enable) {
-
ERR_FAIL_INDEX(p_enabler, ENABLER_MAX);
enabler[p_enabler] = p_enable;
}
-bool VisibilityEnabler2D::is_enabler_enabled(Enabler p_enabler) const {
+bool VisibilityEnabler2D::is_enabler_enabled(Enabler p_enabler) const {
ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false);
return enabler[p_enabler];
}
VisibilityEnabler2D::VisibilityEnabler2D() {
-
- for (int i = 0; i < ENABLER_MAX; i++)
+ for (int i = 0; i < ENABLER_MAX; i++) {
enabler[i] = true;
+ }
enabler[ENABLER_PARENT_PROCESS] = false;
enabler[ENABLER_PARENT_PHYSICS_PROCESS] = false;
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index a3b79d29e9..fb6e48f5e8 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -35,7 +35,6 @@
class Viewport;
class VisibilityNotifier2D : public Node2D {
-
GDCLASS(VisibilityNotifier2D, Node2D);
Set<Viewport *> viewports;
@@ -69,7 +68,6 @@ public:
};
class VisibilityEnabler2D : public VisibilityNotifier2D {
-
GDCLASS(VisibilityEnabler2D, VisibilityNotifier2D);
public:
diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp
index 15d97eeaa0..7c2b41db70 100644
--- a/scene/2d/y_sort.cpp
+++ b/scene/2d/y_sort.cpp
@@ -31,18 +31,15 @@
#include "y_sort.h"
void YSort::set_sort_enabled(bool p_enabled) {
-
sort_enabled = p_enabled;
RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled);
}
bool YSort::is_sort_enabled() const {
-
return sort_enabled;
}
void YSort::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_sort_enabled", "enabled"), &YSort::set_sort_enabled);
ClassDB::bind_method(D_METHOD("is_sort_enabled"), &YSort::is_sort_enabled);
@@ -51,7 +48,6 @@ void YSort::_bind_methods() {
}
YSort::YSort() {
-
sort_enabled = true;
RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true);
}
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp
index b72483d71b..a024757927 100644
--- a/scene/3d/area_3d.cpp
+++ b/scene/3d/area_3d.cpp
@@ -35,27 +35,24 @@
#include "servers/physics_server_3d.h"
void Area3D::set_space_override_mode(SpaceOverride p_mode) {
-
space_override = p_mode;
PhysicsServer3D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer3D::AreaSpaceOverrideMode(p_mode));
}
-Area3D::SpaceOverride Area3D::get_space_override_mode() const {
+Area3D::SpaceOverride Area3D::get_space_override_mode() const {
return space_override;
}
void Area3D::set_gravity_is_point(bool p_enabled) {
-
gravity_is_point = p_enabled;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
-bool Area3D::is_gravity_a_point() const {
+bool Area3D::is_gravity_a_point() const {
return gravity_is_point;
}
void Area3D::set_gravity_distance_scale(real_t p_scale) {
-
gravity_distance_scale = p_scale;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
}
@@ -65,57 +62,51 @@ real_t Area3D::get_gravity_distance_scale() const {
}
void Area3D::set_gravity_vector(const Vector3 &p_vec) {
-
gravity_vec = p_vec;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_vec);
}
-Vector3 Area3D::get_gravity_vector() const {
+Vector3 Area3D::get_gravity_vector() const {
return gravity_vec;
}
void Area3D::set_gravity(real_t p_gravity) {
-
gravity = p_gravity;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY, p_gravity);
}
-real_t Area3D::get_gravity() const {
+real_t Area3D::get_gravity() const {
return gravity;
}
-void Area3D::set_linear_damp(real_t p_linear_damp) {
+void Area3D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
-real_t Area3D::get_linear_damp() const {
+real_t Area3D::get_linear_damp() const {
return linear_damp;
}
void Area3D::set_angular_damp(real_t p_angular_damp) {
-
angular_damp = p_angular_damp;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
real_t Area3D::get_angular_damp() const {
-
return angular_damp;
}
void Area3D::set_priority(real_t p_priority) {
-
priority = p_priority;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_PRIORITY, p_priority);
}
-real_t Area3D::get_priority() const {
+real_t Area3D::get_priority() const {
return priority;
}
void Area3D::_body_enter_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -127,13 +118,11 @@ void Area3D::_body_enter_tree(ObjectID p_id) {
E->get().in_tree = true;
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
}
void Area3D::_body_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -143,13 +132,11 @@ void Area3D::_body_exit_tree(ObjectID p_id) {
E->get().in_tree = false;
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
}
void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) {
-
bool body_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
@@ -166,7 +153,6 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
if (body_in) {
if (!E) {
-
E = body_map.insert(objid, BodyState());
E->get().rc = 0;
E->get().in_tree = node && node->is_inside_tree();
@@ -179,29 +165,30 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
}
}
E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape));
+ }
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape);
}
} else {
-
E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape));
+ }
bool eraseit = false;
if (E->get().rc == 0) {
-
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree));
- if (E->get().in_tree)
+ if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
+ }
}
eraseit = true;
@@ -210,15 +197,15 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape);
}
- if (eraseit)
+ if (eraseit) {
body_map.erase(E);
+ }
}
locked = false;
}
void Area3D::_clear_monitoring() {
-
ERR_FAIL_COND_MSG(locked, "This function can't be used during the in/out signal.");
{
@@ -227,19 +214,19 @@ void Area3D::_clear_monitoring() {
//disconnect all monitored stuff
for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
- if (!node) //node may have been deleted in previous frame or at other legiminate point
+ if (!node) { //node may have been deleted in previous frame or at other legiminate point
continue;
+ }
//ERR_CONTINUE(!node);
- if (!E->get().in_tree)
+ if (!E->get().in_tree) {
continue;
+ }
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
@@ -251,25 +238,24 @@ void Area3D::_clear_monitoring() {
}
{
-
Map<ObjectID, AreaState> bmcopy = area_map;
area_map.clear();
//disconnect all monitored stuff
for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
- if (!node) //node may have been deleted in previous frame or at other legiminate point
+ if (!node) { //node may have been deleted in previous frame or at other legiminate point
continue;
+ }
//ERR_CONTINUE(!node);
- if (!E->get().in_tree)
+ if (!E->get().in_tree) {
continue;
+ }
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
@@ -280,24 +266,23 @@ void Area3D::_clear_monitoring() {
}
}
}
-void Area3D::_notification(int p_what) {
+void Area3D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
_clear_monitoring();
}
}
void Area3D::set_monitoring(bool p_enable) {
-
ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false).");
- if (p_enable == monitoring)
+ if (p_enable == monitoring) {
return;
+ }
monitoring = p_enable;
if (monitoring) {
-
PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
} else {
@@ -308,7 +293,6 @@ void Area3D::set_monitoring(bool p_enable) {
}
void Area3D::_area_enter_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -320,13 +304,11 @@ void Area3D::_area_enter_tree(ObjectID p_id) {
E->get().in_tree = true;
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
}
void Area3D::_area_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -336,13 +318,11 @@ void Area3D::_area_exit_tree(ObjectID p_id) {
E->get().in_tree = false;
emit_signal(SceneStringNames::get_singleton()->area_exited, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
}
void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) {
-
bool area_in = p_status == PhysicsServer3D::AREA_BODY_ADDED;
ObjectID objid = p_instance;
@@ -359,7 +339,6 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
if (area_in) {
if (!E) {
-
E = area_map.insert(objid, AreaState());
E->get().rc = 0;
E->get().in_tree = node && node->is_inside_tree();
@@ -372,24 +351,24 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
}
}
E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape));
+ }
if (!node || E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape);
}
} else {
-
E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape));
+ }
bool eraseit = false;
if (E->get().rc == 0) {
-
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_area_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_area_exit_tree));
@@ -404,20 +383,19 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape);
}
- if (eraseit)
+ if (eraseit) {
area_map.erase(E);
+ }
}
locked = false;
}
bool Area3D::is_monitoring() const {
-
return monitoring;
}
TypedArray<Node3D> Area3D::get_overlapping_bodies() const {
-
ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
ret.resize(body_map.size());
@@ -435,11 +413,11 @@ TypedArray<Node3D> Area3D::get_overlapping_bodies() const {
}
void Area3D::set_monitorable(bool p_enable) {
-
ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
- if (p_enable == monitorable)
+ if (p_enable == monitorable) {
return;
+ }
monitorable = p_enable;
@@ -447,12 +425,10 @@ void Area3D::set_monitorable(bool p_enable) {
}
bool Area3D::is_monitorable() const {
-
return monitorable;
}
TypedArray<Area3D> Area3D::get_overlapping_areas() const {
-
ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
ret.resize(area_map.size());
@@ -470,89 +446,82 @@ TypedArray<Area3D> Area3D::get_overlapping_areas() const {
}
bool Area3D::overlaps_area(Node *p_area) const {
-
ERR_FAIL_NULL_V(p_area, false);
const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().in_tree;
}
bool Area3D::overlaps_body(Node *p_body) const {
-
ERR_FAIL_NULL_V(p_body, false);
const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().in_tree;
}
-void Area3D::set_collision_mask(uint32_t p_mask) {
+void Area3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
PhysicsServer3D::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
}
uint32_t Area3D::get_collision_mask() const {
-
return collision_mask;
}
-void Area3D::set_collision_layer(uint32_t p_layer) {
+void Area3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
PhysicsServer3D::get_singleton()->area_set_collision_layer(get_rid(), p_layer);
}
uint32_t Area3D::get_collision_layer() const {
-
return collision_layer;
}
void Area3D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool Area3D::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
void Area3D::set_collision_layer_bit(int p_bit, bool p_value) {
-
uint32_t layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
layer |= 1 << p_bit;
- else
+ } else {
layer &= ~(1 << p_bit);
+ }
set_collision_layer(layer);
}
bool Area3D::get_collision_layer_bit(int p_bit) const {
-
return get_collision_layer() & (1 << p_bit);
}
void Area3D::set_audio_bus_override(bool p_override) {
-
audio_bus_override = p_override;
}
bool Area3D::is_overriding_audio_bus() const {
-
return audio_bus_override;
}
void Area3D::set_audio_bus(const StringName &p_audio_bus) {
-
audio_bus = p_audio_bus;
}
-StringName Area3D::get_audio_bus() const {
+StringName Area3D::get_audio_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == audio_bus) {
return audio_bus;
@@ -562,20 +531,18 @@ StringName Area3D::get_audio_bus() const {
}
void Area3D::set_use_reverb_bus(bool p_enable) {
-
use_reverb_bus = p_enable;
}
-bool Area3D::is_using_reverb_bus() const {
+bool Area3D::is_using_reverb_bus() const {
return use_reverb_bus;
}
void Area3D::set_reverb_bus(const StringName &p_audio_bus) {
-
reverb_bus = p_audio_bus;
}
-StringName Area3D::get_reverb_bus() const {
+StringName Area3D::get_reverb_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == reverb_bus) {
return reverb_bus;
@@ -585,31 +552,28 @@ StringName Area3D::get_reverb_bus() const {
}
void Area3D::set_reverb_amount(float p_amount) {
-
reverb_amount = p_amount;
}
-float Area3D::get_reverb_amount() const {
+float Area3D::get_reverb_amount() const {
return reverb_amount;
}
void Area3D::set_reverb_uniformity(float p_uniformity) {
-
reverb_uniformity = p_uniformity;
}
-float Area3D::get_reverb_uniformity() const {
+float Area3D::get_reverb_uniformity() const {
return reverb_uniformity;
}
void Area3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") {
-
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -729,7 +693,6 @@ void Area3D::_bind_methods() {
Area3D::Area3D() :
CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) {
-
space_override = SPACE_OVERRIDE_DISABLED;
set_gravity(9.8);
locked = false;
diff --git a/scene/3d/area_3d.h b/scene/3d/area_3d.h
index f6503c6d2d..98f337d3e4 100644
--- a/scene/3d/area_3d.h
+++ b/scene/3d/area_3d.h
@@ -35,7 +35,6 @@
#include "scene/3d/collision_object_3d.h"
class Area3D : public CollisionObject3D {
-
GDCLASS(Area3D, CollisionObject3D);
public:
@@ -68,14 +67,14 @@ private:
void _body_exit_tree(ObjectID p_id);
struct ShapePair {
-
int body_shape;
int area_shape;
bool operator<(const ShapePair &p_sp) const {
- if (body_shape == p_sp.body_shape)
+ if (body_shape == p_sp.body_shape) {
return area_shape < p_sp.area_shape;
- else
+ } else {
return body_shape < p_sp.body_shape;
+ }
}
ShapePair() {}
@@ -86,7 +85,6 @@ private:
};
struct BodyState {
-
int rc;
bool in_tree;
VSet<ShapePair> shapes;
@@ -100,14 +98,14 @@ private:
void _area_exit_tree(ObjectID p_id);
struct AreaShapePair {
-
int area_shape;
int self_shape;
bool operator<(const AreaShapePair &p_sp) const {
- if (area_shape == p_sp.area_shape)
+ if (area_shape == p_sp.area_shape) {
return self_shape < p_sp.self_shape;
- else
+ } else {
return area_shape < p_sp.area_shape;
+ }
}
AreaShapePair() {}
@@ -118,7 +116,6 @@ private:
};
struct AreaState {
-
int rc;
bool in_tree;
VSet<AreaShapePair> shapes;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 8a00d67e12..6e4db8f382 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -138,7 +138,6 @@ void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tig
}
void AudioStreamPlayer3D::_mix_audio() {
-
if (!stream_playback.is_valid() || !active ||
(stream_paused && !stream_paused_fade_out)) {
return;
@@ -162,7 +161,6 @@ void AudioStreamPlayer3D::_mix_audio() {
// Mix if we're not paused or we're fading out
if ((output_count > 0 || out_of_range_mode == OUT_OF_RANGE_MIX)) {
-
float output_pitch_scale = 0.0;
if (output_count) {
//used for doppler, not realistic but good enough
@@ -179,7 +177,6 @@ void AudioStreamPlayer3D::_mix_audio() {
//write all outputs
for (int i = 0; i < output_count; i++) {
-
Output current = outputs[i];
//see if current output exists, to keep volume ramp
@@ -216,8 +213,9 @@ void AudioStreamPlayer3D::_mix_audio() {
AudioFrame vol_inc = (target_volume - vol_prev) / float(buffer_size);
AudioFrame vol = vol_prev;
- if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, k))
+ if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, k)) {
continue; //may have been deleted, will be updated on process
+ }
AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, k);
current.filter.set_mode(AudioFilterSW::HIGHSHELF);
@@ -228,7 +226,6 @@ void AudioStreamPlayer3D::_mix_audio() {
current.filter.set_gain(current.filter_gain);
if (interpolate_filter) {
-
current.filter_process[k * 2 + 0] = prev_outputs[i].filter_process[k * 2 + 0];
current.filter_process[k * 2 + 1] = prev_outputs[i].filter_process[k * 2 + 1];
@@ -238,7 +235,6 @@ void AudioStreamPlayer3D::_mix_audio() {
current.filter_process[k * 2 + 0].update_coeffs(buffer_size);
current.filter_process[k * 2 + 1].update_coeffs(buffer_size);
for (int j = 0; j < buffer_size; j++) {
-
AudioFrame f = buffer[j] * vol;
current.filter_process[k * 2 + 0].process_one_interp(f.l);
current.filter_process[k * 2 + 1].process_one_interp(f.r);
@@ -253,7 +249,6 @@ void AudioStreamPlayer3D::_mix_audio() {
current.filter_process[k * 2 + 0].update_coeffs();
current.filter_process[k * 2 + 1].update_coeffs();
for (int j = 0; j < buffer_size; j++) {
-
AudioFrame f = buffer[j] * vol;
current.filter_process[k * 2 + 0].process_one(f.l);
current.filter_process[k * 2 + 1].process_one(f.r);
@@ -264,9 +259,9 @@ void AudioStreamPlayer3D::_mix_audio() {
}
if (current.reverb_bus_index >= 0) {
-
- if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.reverb_bus_index, k))
+ if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.reverb_bus_index, k)) {
continue; //may have been deleted, will be updated on process
+ }
AudioFrame *rtarget = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.reverb_bus_index, k);
@@ -275,15 +270,12 @@ void AudioStreamPlayer3D::_mix_audio() {
AudioFrame rvol = prev_outputs[i].reverb_vol[k];
for (int j = 0; j < buffer_size; j++) {
-
rtarget[j] += buffer[j] * rvol;
rvol += rvol_inc;
}
} else {
-
AudioFrame rvol = current.reverb_vol[k];
for (int j = 0; j < buffer_size; j++) {
-
rtarget[j] += buffer[j] * rvol;
}
}
@@ -306,7 +298,6 @@ void AudioStreamPlayer3D::_mix_audio() {
}
float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
-
float att = 0;
switch (attenuation_model) {
case ATTENUATION_INVERSE_DISTANCE: {
@@ -340,9 +331,7 @@ void _update_sound() {
}
void AudioStreamPlayer3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
velocity_tracker->reset(get_global_transform().origin);
AudioServer::get_singleton()->add_callback(_mix_audios, this);
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
@@ -351,7 +340,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
AudioServer::get_singleton()->remove_callback(_mix_audios, this);
}
@@ -367,18 +355,15 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
-
if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
velocity_tracker->update_position(get_global_transform().origin);
}
}
if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
-
//update anything related to position first, if possible of course
if (!output_ready) {
-
Vector3 linear_velocity;
//compute linear velocity for doppler
@@ -405,15 +390,18 @@ void AudioStreamPlayer3D::_notification(int p_what) {
Area3D *area = nullptr;
for (int i = 0; i < areas; i++) {
- if (!sr[i].collider)
+ if (!sr[i].collider) {
continue;
+ }
Area3D *tarea = Object::cast_to<Area3D>(sr[i].collider);
- if (!tarea)
+ if (!tarea) {
continue;
+ }
- if (!tarea->is_overriding_audio_bus() && !tarea->is_using_reverb_bus())
+ if (!tarea->is_overriding_audio_bus() && !tarea->is_using_reverb_bus()) {
continue;
+ }
area = tarea;
break;
@@ -423,11 +411,11 @@ void AudioStreamPlayer3D::_notification(int p_what) {
world_3d->get_camera_list(&cameras);
for (List<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
-
Camera3D *camera = E->get();
Viewport *vp = camera->get_viewport();
- if (!vp->is_audio_listener())
+ if (!vp->is_audio_listener()) {
continue;
+ }
bool listener_is_camera = true;
Node3D *listener_node = camera;
@@ -451,7 +439,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
if (max_distance > 0) {
-
float total_max = max_distance;
if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
@@ -478,8 +465,9 @@ void AudioStreamPlayer3D::_notification(int p_what) {
Vector3 listenertopos = global_pos - listener_node->get_global_transform().origin;
float c = listenertopos.normalized().dot(get_global_transform().basis.get_axis(2).normalized()); //it's z negative
float angle = Math::rad2deg(Math::acos(c));
- if (angle > emission_angle)
+ if (angle > emission_angle) {
db_att -= -emission_angle_filter_attenuation_db;
+ }
}
output.filter_gain = Math::db2linear(db_att);
@@ -497,7 +485,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
int vol_index_max = AudioServer::get_singleton()->get_speaker_mode() + 1;
if (area) {
-
if (area->is_overriding_audio_bus()) {
//override audio bus
StringName bus_name = area->get_audio_bus();
@@ -505,7 +492,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
if (area->is_using_reverb_bus()) {
-
filled_reverb = true;
StringName bus_name = area->get_reverb_bus();
output.reverb_bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus_name);
@@ -514,7 +500,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
float area_send = area->get_reverb_amount();
if (uniformity > 0.0) {
-
float distance = listener_area_pos.length();
float attenuation = Math::db2linear(_get_attenuation_db(distance));
@@ -556,26 +541,21 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
for (int i = 0; i < vol_index_max; i++) {
-
output.reverb_vol[i] = output.reverb_vol[i].lerp(center_frame, attenuation);
}
} else {
for (int i = 0; i < vol_index_max; i++) {
-
output.reverb_vol[i] = center_frame;
}
}
for (int i = 0; i < vol_index_max; i++) {
-
output.reverb_vol[i] = output.vol[i].lerp(output.reverb_vol[i] * attenuation, uniformity);
output.reverb_vol[i] *= area_send;
}
} else {
-
for (int i = 0; i < vol_index_max; i++) {
-
output.reverb_vol[i] = output.vol[i] * area_send;
}
}
@@ -583,7 +563,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
-
Vector3 listener_velocity;
if (listener_is_camera) {
@@ -608,17 +587,16 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
if (!filled_reverb) {
-
for (int i = 0; i < vol_index_max; i++) {
-
output.reverb_vol[i] = AudioFrame(0, 0);
}
}
outputs[new_output_count] = output;
new_output_count++;
- if (new_output_count == MAX_OUTPUTS)
+ if (new_output_count == MAX_OUTPUTS) {
break;
+ }
}
output_count = new_output_count;
@@ -645,7 +623,6 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
-
AudioServer::get_singleton()->lock();
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
@@ -670,34 +647,30 @@ void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) {
}
Ref<AudioStream> AudioStreamPlayer3D::get_stream() const {
-
return stream;
}
void AudioStreamPlayer3D::set_unit_db(float p_volume) {
-
unit_db = p_volume;
}
-float AudioStreamPlayer3D::get_unit_db() const {
+float AudioStreamPlayer3D::get_unit_db() const {
return unit_db;
}
void AudioStreamPlayer3D::set_unit_size(float p_volume) {
-
unit_size = p_volume;
}
-float AudioStreamPlayer3D::get_unit_size() const {
+float AudioStreamPlayer3D::get_unit_size() const {
return unit_size;
}
void AudioStreamPlayer3D::set_max_db(float p_boost) {
-
max_db = p_boost;
}
-float AudioStreamPlayer3D::get_max_db() const {
+float AudioStreamPlayer3D::get_max_db() const {
return max_db;
}
@@ -705,12 +678,12 @@ void AudioStreamPlayer3D::set_pitch_scale(float p_pitch_scale) {
ERR_FAIL_COND(p_pitch_scale <= 0.0);
pitch_scale = p_pitch_scale;
}
+
float AudioStreamPlayer3D::get_pitch_scale() const {
return pitch_scale;
}
void AudioStreamPlayer3D::play(float p_from_pos) {
-
if (!is_playing()) {
// Reset the prev_output_count if the stream is stopped
prev_output_count = 0;
@@ -725,14 +698,12 @@ void AudioStreamPlayer3D::play(float p_from_pos) {
}
void AudioStreamPlayer3D::seek(float p_seconds) {
-
if (stream_playback.is_valid()) {
setseek = p_seconds;
}
}
void AudioStreamPlayer3D::stop() {
-
if (stream_playback.is_valid()) {
active = false;
set_physics_process_internal(false);
@@ -741,7 +712,6 @@ void AudioStreamPlayer3D::stop() {
}
bool AudioStreamPlayer3D::is_playing() const {
-
if (stream_playback.is_valid()) {
return active; // && stream_playback->is_playing();
}
@@ -750,7 +720,6 @@ bool AudioStreamPlayer3D::is_playing() const {
}
float AudioStreamPlayer3D::get_playback_position() {
-
if (stream_playback.is_valid()) {
return stream_playback->get_playback_position();
}
@@ -759,14 +728,13 @@ float AudioStreamPlayer3D::get_playback_position() {
}
void AudioStreamPlayer3D::set_bus(const StringName &p_bus) {
-
//if audio is active, must lock this
AudioServer::get_singleton()->lock();
bus = p_bus;
AudioServer::get_singleton()->unlock();
}
-StringName AudioStreamPlayer3D::get_bus() const {
+StringName AudioStreamPlayer3D::get_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == bus) {
return bus;
@@ -776,34 +744,32 @@ StringName AudioStreamPlayer3D::get_bus() const {
}
void AudioStreamPlayer3D::set_autoplay(bool p_enable) {
-
autoplay = p_enable;
}
-bool AudioStreamPlayer3D::is_autoplay_enabled() {
+bool AudioStreamPlayer3D::is_autoplay_enabled() {
return autoplay;
}
void AudioStreamPlayer3D::_set_playing(bool p_enable) {
-
- if (p_enable)
+ if (p_enable) {
play();
- else
+ } else {
stop();
+ }
}
-bool AudioStreamPlayer3D::_is_active() const {
+bool AudioStreamPlayer3D::_is_active() const {
return active;
}
void AudioStreamPlayer3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "bus") {
-
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -813,28 +779,23 @@ void AudioStreamPlayer3D::_validate_property(PropertyInfo &property) const {
}
void AudioStreamPlayer3D::_bus_layout_changed() {
-
_change_notify();
}
void AudioStreamPlayer3D::set_max_distance(float p_metres) {
-
ERR_FAIL_COND(p_metres < 0.0);
max_distance = p_metres;
}
float AudioStreamPlayer3D::get_max_distance() const {
-
return max_distance;
}
void AudioStreamPlayer3D::set_area_mask(uint32_t p_mask) {
-
area_mask = p_mask;
}
uint32_t AudioStreamPlayer3D::get_area_mask() const {
-
return area_mask;
}
@@ -859,30 +820,26 @@ float AudioStreamPlayer3D::get_emission_angle() const {
}
void AudioStreamPlayer3D::set_emission_angle_filter_attenuation_db(float p_angle_attenuation_db) {
-
emission_angle_filter_attenuation_db = p_angle_attenuation_db;
}
float AudioStreamPlayer3D::get_emission_angle_filter_attenuation_db() const {
-
return emission_angle_filter_attenuation_db;
}
void AudioStreamPlayer3D::set_attenuation_filter_cutoff_hz(float p_hz) {
-
attenuation_filter_cutoff_hz = p_hz;
}
-float AudioStreamPlayer3D::get_attenuation_filter_cutoff_hz() const {
+float AudioStreamPlayer3D::get_attenuation_filter_cutoff_hz() const {
return attenuation_filter_cutoff_hz;
}
void AudioStreamPlayer3D::set_attenuation_filter_db(float p_db) {
-
attenuation_filter_db = p_db;
}
-float AudioStreamPlayer3D::get_attenuation_filter_db() const {
+float AudioStreamPlayer3D::get_attenuation_filter_db() const {
return attenuation_filter_db;
}
@@ -896,20 +853,18 @@ AudioStreamPlayer3D::AttenuationModel AudioStreamPlayer3D::get_attenuation_model
}
void AudioStreamPlayer3D::set_out_of_range_mode(OutOfRangeMode p_mode) {
-
ERR_FAIL_INDEX((int)p_mode, 2);
out_of_range_mode = p_mode;
}
AudioStreamPlayer3D::OutOfRangeMode AudioStreamPlayer3D::get_out_of_range_mode() const {
-
return out_of_range_mode;
}
void AudioStreamPlayer3D::set_doppler_tracking(DopplerTracking p_tracking) {
-
- if (doppler_tracking == p_tracking)
+ if (doppler_tracking == p_tracking) {
return;
+ }
doppler_tracking = p_tracking;
@@ -925,12 +880,10 @@ void AudioStreamPlayer3D::set_doppler_tracking(DopplerTracking p_tracking) {
}
AudioStreamPlayer3D::DopplerTracking AudioStreamPlayer3D::get_doppler_tracking() const {
-
return doppler_tracking;
}
void AudioStreamPlayer3D::set_stream_paused(bool p_pause) {
-
if (p_pause != stream_paused) {
stream_paused = p_pause;
stream_paused_fade_in = !stream_paused;
@@ -939,7 +892,6 @@ void AudioStreamPlayer3D::set_stream_paused(bool p_pause) {
}
bool AudioStreamPlayer3D::get_stream_paused() const {
-
return stream_paused;
}
@@ -948,7 +900,6 @@ Ref<AudioStreamPlayback> AudioStreamPlayer3D::get_stream_playback() {
}
void AudioStreamPlayer3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_stream", "stream"), &AudioStreamPlayer3D::set_stream);
ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer3D::get_stream);
@@ -1054,7 +1005,6 @@ void AudioStreamPlayer3D::_bind_methods() {
}
AudioStreamPlayer3D::AudioStreamPlayer3D() {
-
unit_db = 0;
unit_size = 1;
attenuation_model = ATTENUATION_INVERSE_DISTANCE;
@@ -1084,5 +1034,6 @@ AudioStreamPlayer3D::AudioStreamPlayer3D() {
AudioServer::get_singleton()->connect("bus_layout_changed", callable_mp(this, &AudioStreamPlayer3D::_bus_layout_changed));
set_disable_scale(true);
}
+
AudioStreamPlayer3D::~AudioStreamPlayer3D() {
}
diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h
index 13e08339e2..9f261c54b4 100644
--- a/scene/3d/audio_stream_player_3d.h
+++ b/scene/3d/audio_stream_player_3d.h
@@ -39,7 +39,6 @@
class Camera3D;
class AudioStreamPlayer3D : public Node3D {
-
GDCLASS(AudioStreamPlayer3D, Node3D);
public:
@@ -69,7 +68,6 @@ private:
};
struct Output {
-
AudioFilterSW filter;
AudioFilterSW::Processor filter_process[8];
AudioFrame vol[4];
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 82a9a1e589..a41eaf9da0 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -41,7 +41,6 @@
#include "lightmap_probe.h"
void BakedLightmapData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale, int p_slice_index, int32_t p_sub_instance) {
-
User user;
user.path = p_path;
user.uv_scale = p_uv_scale;
@@ -51,29 +50,25 @@ void BakedLightmapData::add_user(const NodePath &p_path, const Rect2 &p_uv_scale
}
int BakedLightmapData::get_user_count() const {
-
return users.size();
}
-NodePath BakedLightmapData::get_user_path(int p_user) const {
+NodePath BakedLightmapData::get_user_path(int p_user) const {
ERR_FAIL_INDEX_V(p_user, users.size(), NodePath());
return users[p_user].path;
}
int32_t BakedLightmapData::get_user_sub_instance(int p_user) const {
-
ERR_FAIL_INDEX_V(p_user, users.size(), -1);
return users[p_user].sub_instance;
}
Rect2 BakedLightmapData::get_user_lightmap_uv_scale(int p_user) const {
-
ERR_FAIL_INDEX_V(p_user, users.size(), Rect2());
return users[p_user].uv_scale;
}
int BakedLightmapData::get_user_lightmap_slice_index(int p_user) const {
-
ERR_FAIL_INDEX_V(p_user, users.size(), -1);
return users[p_user].slice_index;
}
@@ -83,7 +78,6 @@ void BakedLightmapData::clear_users() {
}
void BakedLightmapData::_set_user_data(const Array &p_data) {
-
ERR_FAIL_COND((p_data.size() % 4) != 0);
for (int i = 0; i < p_data.size(); i += 4) {
@@ -92,7 +86,6 @@ void BakedLightmapData::_set_user_data(const Array &p_data) {
}
Array BakedLightmapData::_get_user_data() const {
-
Array ret;
for (int i = 0; i < users.size(); i++) {
ret.push_back(users[i].path);
@@ -150,9 +143,11 @@ void BakedLightmapData::set_capture_data(const AABB &p_bounds, bool p_interior,
PackedVector3Array BakedLightmapData::get_capture_points() const {
return RS::get_singleton()->lightmap_get_probe_capture_points(lightmap);
}
+
PackedColorArray BakedLightmapData::get_capture_sh() const {
return RS::get_singleton()->lightmap_get_probe_capture_sh(lightmap);
}
+
PackedInt32Array BakedLightmapData::get_capture_tetrahedra() const {
return RS::get_singleton()->lightmap_get_probe_capture_tetrahedra(lightmap);
}
@@ -189,8 +184,8 @@ Dictionary BakedLightmapData::_get_probe_data() const {
d["interior"] = is_interior();
return d;
}
-void BakedLightmapData::_bind_methods() {
+void BakedLightmapData::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_user_data", "data"), &BakedLightmapData::_set_user_data);
ClassDB::bind_method(D_METHOD("_get_user_data"), &BakedLightmapData::_get_user_data);
@@ -215,28 +210,23 @@ void BakedLightmapData::_bind_methods() {
}
BakedLightmapData::BakedLightmapData() {
-
lightmap = RS::get_singleton()->lightmap_create();
}
BakedLightmapData::~BakedLightmapData() {
-
RS::get_singleton()->free(lightmap);
}
///////////////////////////
void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound> &meshes, Vector<LightsFound> &lights, Vector<Vector3> &probes) {
-
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node);
if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
-
bool all_have_uv2_and_normal = true;
bool surfaces_found = false;
for (int i = 0; i < mesh->get_surface_count(); i++) {
-
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
}
@@ -284,10 +274,10 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
if (bmeshes.size() && (bmeshes.size() & 1) == 0) {
Transform xf = get_global_transform().affine_inverse() * s->get_global_transform();
for (int i = 0; i < bmeshes.size(); i += 2) {
-
Ref<Mesh> mesh = bmeshes[i];
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
continue;
+ }
MeshesFound mf;
@@ -306,7 +296,6 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
Light3D *light = Object::cast_to<Light3D>(p_at_node);
if (light && light->get_bake_mode() != Light3D::BAKE_DISABLED) {
-
LightsFound lf;
lf.xform = get_global_transform().affine_inverse() * light->get_global_transform();
lf.light = light;
@@ -321,17 +310,16 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
}
for (int i = 0; i < p_at_node->get_child_count(); i++) {
-
Node *child = p_at_node->get_child(i);
- if (!child->get_owner())
+ if (!child->get_owner()) {
continue; //maybe a helper
+ }
_find_meshes_and_lights(child, meshes, lights, probes);
}
}
int BakedLightmap::_bsp_get_simplex_side(const Vector<Vector3> &p_points, const LocalVector<BSPSimplex> &p_simplices, const Plane &p_plane, uint32_t p_simplex) const {
-
int over = 0;
int under = 0;
int coplanar = 0;
@@ -360,7 +348,6 @@ int BakedLightmap::_bsp_get_simplex_side(const Vector<Vector3> &p_points, const
//#define DEBUG_BSP
int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const LocalVector<Plane> &p_planes, LocalVector<int32_t> &planes_tested, const LocalVector<BSPSimplex> &p_simplices, const LocalVector<int32_t> &p_simplex_indices, LocalVector<BSPNode> &bsp_nodes) {
-
//if we reach here, it means there is more than one simplex
int32_t node_index = (int32_t)bsp_nodes.size();
bsp_nodes.push_back(BSPNode());
@@ -427,7 +414,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const
//score *= Math::sqrt(float(over_count + under_count) / p_simplex_indices.size()); //also multiply score
if (score > best_plane_score) {
-
best_plane = plane;
best_plane_score = score;
}
@@ -439,7 +425,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const
//split again, but add to list
for (uint32_t i = 0; i < p_simplex_indices.size(); i++) {
-
uint32_t index = p_simplex_indices[i];
int side = _bsp_get_simplex_side(p_points, p_simplices, best_plane, index);
@@ -478,7 +463,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const
for (uint32_t i = 0; i < p_simplex_indices.size(); i++) {
AABB bounds;
for (uint32_t j = 0; j < 4; j++) {
-
Vector3 p = p_points[p_simplices[p_simplex_indices[i]].vertices[j]];
if (j == 0) {
bounds.position = p;
@@ -549,7 +533,6 @@ int32_t BakedLightmap::_compute_bsp_tree(const Vector<Vector3> &p_points, const
}
bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const String &p_text, void *ud, bool p_refresh) {
-
BakeStepUD *bsud = (BakeStepUD *)ud;
bool ret = false;
if (bsud->func) {
@@ -559,7 +542,6 @@ bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const Strin
}
void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_cell_size, const Vector3 *p_triangle) {
-
for (int i = 0; i < 8; i++) {
Vector3i pos = p_cell->offset;
uint32_t half_size = p_cell->size / 2;
@@ -577,8 +559,9 @@ void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_
subcell.position = Vector3(pos) * p_cell_size;
subcell.size = Vector3(half_size, half_size, half_size) * p_cell_size;
- if (!Geometry::triangle_box_overlap(subcell.position + subcell.size * 0.5, subcell.size * 0.5, p_triangle))
+ if (!Geometry3D::triangle_box_overlap(subcell.position + subcell.size * 0.5, subcell.size * 0.5, p_triangle)) {
continue;
+ }
if (p_cell->children[i] == nullptr) {
GenProbesOctree *child = memnew(GenProbesOctree);
@@ -593,10 +576,9 @@ void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_
}
}
}
-void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell, float p_cell_size, const Vector<Vector3> &probe_positions, LocalVector<Vector3> &new_probe_positions, HashMap<Vector3i, bool, Vector3iHash> &positions_used, const AABB &p_bounds) {
+void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell, float p_cell_size, const Vector<Vector3> &probe_positions, LocalVector<Vector3> &new_probe_positions, HashMap<Vector3i, bool, Vector3iHash> &positions_used, const AABB &p_bounds) {
for (int i = 0; i < 8; i++) {
-
Vector3i pos = p_cell->offset;
if (i & 1) {
pos.x += p_cell->size;
@@ -616,7 +598,6 @@ void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell
const Vector3 *pp = probe_positions.ptr();
bool exists = false;
for (int j = 0; j < ppcount; j++) {
-
if (pp[j].distance_to(real_pos) < CMP_EPSILON) {
exists = true;
break;
@@ -635,14 +616,13 @@ void BakedLightmap::_gen_new_positions_from_octree(const GenProbesOctree *p_cell
}
}
}
-BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_data_path, Lightmapper::BakeStepFunc p_bake_step, void *p_bake_userdata) {
+BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_data_path, Lightmapper::BakeStepFunc p_bake_step, void *p_bake_userdata) {
if (p_image_data_path == "" && (get_light_data().is_null() || !get_light_data()->get_path().is_resource_file())) {
return BAKE_ERROR_NO_SAVE_PATH;
}
if (p_image_data_path == "") {
-
if (get_light_data().is_null()) {
return BAKE_ERROR_NO_SAVE_PATH;
}
@@ -681,7 +661,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
//get the base material textures, help compute altlas size and bounds
for (int m_i = 0; m_i < meshes_found.size(); m_i++) {
-
if (p_bake_step) {
float p = (float)(m_i) / meshes_found.size();
p_bake_step(p * 0.1, vformat(TTR("Preparing geometry %d/%d"), m_i, meshes_found.size()), p_bake_userdata, false);
@@ -718,7 +697,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
}
{
-
if (albedo->get_format() != Image::FORMAT_RGBA8) {
albedo->convert(Image::FORMAT_RGBA8);
}
@@ -779,7 +757,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
const int *ir = nullptr;
if (index.size()) {
-
facecount = index.size() / 3;
ir = index.ptr();
} else {
@@ -787,7 +764,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
}
for (int j = 0; j < facecount; j++) {
-
uint32_t vidx[3];
if (ir) {
@@ -893,7 +869,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
}
//skip first level, since probes are always added at bounds endpoints anyway (code above this)
for (int i = 0; i < 8; i++) {
-
if (octree.children[i]) {
_gen_new_positions_from_octree(octree.children[i], subdiv_cell_size, probes_found, new_probe_positions, positions_used, bounds);
}
@@ -910,7 +885,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
}
{
-
for (int i = 0; i < mesh_data.size(); i++) {
lightmapper->add_mesh(mesh_data[i]);
}
@@ -995,7 +969,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
Ref<TextureLayered> texture;
{
-
Vector<Ref<Image>> images;
for (int i = 0; i < lightmapper->get_bake_texture_count(); i++) {
images.push_back(lightmapper->get_bake_texture(i));
@@ -1016,7 +989,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
config.instance();
if (FileAccess::exists(base_path + ".import")) {
-
config->load(base_path + ".import");
}
@@ -1095,7 +1067,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
PackedInt32Array tetrahedrons;
for (int i = 0; i < solved_simplices.size(); i++) {
-
//Prepare a special representation of the simplex, which uses a BSP Tree
BSPSimplex bsp_simplex;
for (int j = 0; j < 4; j++) {
@@ -1117,7 +1088,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
Plane p(a, b, c);
int plane_index = -1;
for (uint32_t k = 0; k < bsp_planes.size(); k++) {
-
if (bsp_planes[k].is_equal_approx_any_side(p)) {
plane_index = k;
break;
@@ -1218,14 +1188,12 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
void BakedLightmap::_notification(int p_what) {
if (p_what == NOTIFICATION_POST_ENTER_TREE) {
-
if (light_data.is_valid()) {
_assign_lightmaps();
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
if (light_data.is_valid()) {
_clear_lightmaps();
}
@@ -1233,11 +1201,9 @@ void BakedLightmap::_notification(int p_what) {
}
void BakedLightmap::_assign_lightmaps() {
-
ERR_FAIL_COND(!light_data.is_valid());
for (int i = 0; i < light_data->get_user_count(); i++) {
-
Node *node = get_node(light_data->get_user_path(i));
int instance_idx = light_data->get_user_sub_instance(i);
if (instance_idx >= 0) {
@@ -1272,7 +1238,6 @@ void BakedLightmap::_clear_lightmaps() {
}
void BakedLightmap::set_light_data(const Ref<BakedLightmapData> &p_data) {
-
if (light_data.is_valid()) {
if (is_inside_tree()) {
_clear_lightmaps();
@@ -1292,7 +1257,6 @@ void BakedLightmap::set_light_data(const Ref<BakedLightmapData> &p_data) {
}
Ref<BakedLightmapData> BakedLightmap::get_light_data() const {
-
return light_data;
}
@@ -1307,17 +1271,16 @@ BakedLightmap::BakeQuality BakedLightmap::get_bake_quality() const {
AABB BakedLightmap::get_aabb() const {
return AABB();
}
+
Vector<Face3> BakedLightmap::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void BakedLightmap::set_use_denoiser(bool p_enable) {
-
use_denoiser = p_enable;
}
bool BakedLightmap::is_using_denoiser() const {
-
return use_denoiser;
}
@@ -1332,6 +1295,7 @@ bool BakedLightmap::is_directional() const {
void BakedLightmap::set_interior(bool p_enable) {
interior = p_enable;
}
+
bool BakedLightmap::is_interior() const {
return interior;
}
@@ -1356,6 +1320,7 @@ Ref<Sky> BakedLightmap::get_environment_custom_sky() const {
void BakedLightmap::set_environment_custom_color(const Color &p_color) {
environment_custom_color = p_color;
}
+
Color BakedLightmap::get_environment_custom_color() const {
return environment_custom_color;
}
@@ -1363,6 +1328,7 @@ Color BakedLightmap::get_environment_custom_color() const {
void BakedLightmap::set_environment_custom_energy(float p_energy) {
environment_custom_energy = p_energy;
}
+
float BakedLightmap::get_environment_custom_energy() const {
return environment_custom_energy;
}
@@ -1415,7 +1381,6 @@ void BakedLightmap::_validate_property(PropertyInfo &property) const {
}
void BakedLightmap::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_light_data", "data"), &BakedLightmap::set_light_data);
ClassDB::bind_method(D_METHOD("get_light_data"), &BakedLightmap::get_light_data);
@@ -1501,7 +1466,6 @@ void BakedLightmap::_bind_methods() {
}
BakedLightmap::BakedLightmap() {
-
environment_mode = ENVIRONMENT_MODE_DISABLED;
environment_custom_color = Color(0.2, 0.7, 1.0);
environment_custom_energy = 1.0;
diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h
index 748fdf913f..08098c3d5d 100644
--- a/scene/3d/baked_lightmap.h
+++ b/scene/3d/baked_lightmap.h
@@ -52,7 +52,6 @@ class BakedLightmapData : public Resource {
AABB bounds;
struct User {
-
NodePath path;
int32_t sub_instance;
Rect2 uv_scale;
diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp
index 825cb39e2d..68303bbfe5 100644
--- a/scene/3d/bone_attachment_3d.cpp
+++ b/scene/3d/bone_attachment_3d.cpp
@@ -31,23 +31,21 @@
#include "bone_attachment_3d.h"
void BoneAttachment3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "bone_name") {
Skeleton3D *parent = Object::cast_to<Skeleton3D>(get_parent());
if (parent) {
-
String names;
for (int i = 0; i < parent->get_bone_count(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += parent->get_bone_name(i);
}
property.hint = PROPERTY_HINT_ENUM;
property.hint_string = names;
} else {
-
property.hint = PROPERTY_HINT_NONE;
property.hint_string = "";
}
@@ -55,10 +53,8 @@ void BoneAttachment3D::_validate_property(PropertyInfo &property) const {
}
void BoneAttachment3D::_check_bind() {
-
Skeleton3D *sk = Object::cast_to<Skeleton3D>(get_parent());
if (sk) {
-
int idx = sk->find_bone(bone_name);
if (idx != -1) {
sk->bind_child_node_to_bone(idx, this);
@@ -69,12 +65,9 @@ void BoneAttachment3D::_check_bind() {
}
void BoneAttachment3D::_check_unbind() {
-
if (bound) {
-
Skeleton3D *sk = Object::cast_to<Skeleton3D>(get_parent());
if (sk) {
-
int idx = sk->find_bone(bone_name);
if (idx != -1) {
sk->unbind_child_node_from_bone(idx, this);
@@ -85,31 +78,27 @@ void BoneAttachment3D::_check_unbind() {
}
void BoneAttachment3D::set_bone_name(const String &p_name) {
-
- if (is_inside_tree())
+ if (is_inside_tree()) {
_check_unbind();
+ }
bone_name = p_name;
- if (is_inside_tree())
+ if (is_inside_tree()) {
_check_bind();
+ }
}
String BoneAttachment3D::get_bone_name() const {
-
return bone_name;
}
void BoneAttachment3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
_check_bind();
} break;
case NOTIFICATION_EXIT_TREE: {
-
_check_unbind();
} break;
}
diff --git a/scene/3d/bone_attachment_3d.h b/scene/3d/bone_attachment_3d.h
index d2a3ffec90..fec59217d2 100644
--- a/scene/3d/bone_attachment_3d.h
+++ b/scene/3d/bone_attachment_3d.h
@@ -34,7 +34,6 @@
#include "scene/3d/skeleton_3d.h"
class BoneAttachment3D : public Node3D {
-
GDCLASS(BoneAttachment3D, Node3D);
bool bound;
diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp
index 871f3119bc..8dc5cd4aba 100644
--- a/scene/3d/camera_3d.cpp
+++ b/scene/3d/camera_3d.cpp
@@ -39,16 +39,13 @@ void Camera3D::_update_audio_listener_state() {
}
void Camera3D::_request_camera_update() {
-
_update_camera();
}
void Camera3D::_update_camera_mode() {
-
force_change = true;
switch (mode) {
case PROJECTION_PERSPECTIVE: {
-
set_perspective(fov, near, far);
} break;
@@ -78,9 +75,9 @@ void Camera3D::_validate_property(PropertyInfo &p_property) const {
}
void Camera3D::_update_camera() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
RenderingServer::get_singleton()->camera_set_transform(camera, get_camera_transform());
@@ -90,8 +87,9 @@ void Camera3D::_update_camera() {
get_viewport()->_camera_transform_changed_notify();
*/
- if (get_tree()->is_node_being_edited(this) || !is_current())
+ if (get_tree()->is_node_being_edited(this) || !is_current()) {
return;
+ }
get_viewport()->_camera_transform_changed_notify();
@@ -101,11 +99,8 @@ void Camera3D::_update_camera() {
}
void Camera3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_WORLD: {
-
// Needs to track the Viewport because it's needed on NOTIFICATION_EXIT_WORLD
// and Spatial will handle it first, including clearing its reference to the Viewport,
// therefore making it impossible to subclasses to access it
@@ -113,19 +108,18 @@ void Camera3D::_notification(int p_what) {
ERR_FAIL_COND(!viewport);
bool first_camera = viewport->_camera_add(this);
- if (current || first_camera)
+ if (current || first_camera) {
viewport->_camera_set(this);
+ }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
_request_camera_update();
if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
velocity_tracker->update_position(get_global_transform().origin);
}
} break;
case NOTIFICATION_EXIT_WORLD: {
-
if (!get_tree()->is_node_being_edited(this)) {
if (is_current()) {
clear_current();
@@ -156,7 +150,6 @@ void Camera3D::_notification(int p_what) {
}
Transform Camera3D::get_camera_transform() const {
-
Transform tr = get_global_transform().orthonormalized();
tr.origin += tr.basis.get_axis(1) * v_offset;
tr.origin += tr.basis.get_axis(0) * h_offset;
@@ -164,9 +157,9 @@ Transform Camera3D::get_camera_transform() const {
}
void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) {
-
- if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE)
+ if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE) {
return;
+ }
fov = p_fovy_degrees;
near = p_z_near;
@@ -177,10 +170,11 @@ void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_f
update_gizmo();
force_change = false;
}
-void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
- if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL)
+void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
+ if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL) {
return;
+ }
size = p_size;
@@ -194,8 +188,9 @@ void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
}
void Camera3D::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
- if (!force_change && size == p_size && frustum_offset == p_offset && p_z_near == near && p_z_far == far && mode == PROJECTION_FRUSTUM)
+ if (!force_change && size == p_size && frustum_offset == p_offset && p_z_near == near && p_z_far == far && mode == PROJECTION_FRUSTUM) {
return;
+ }
size = p_size;
frustum_offset = p_offset;
@@ -218,16 +213,15 @@ void Camera3D::set_projection(Camera3D::Projection p_mode) {
}
RID Camera3D::get_camera() const {
-
return camera;
};
void Camera3D::make_current() {
-
current = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
get_viewport()->_camera_set(this);
@@ -235,10 +229,10 @@ void Camera3D::make_current() {
}
void Camera3D::clear_current(bool p_enable_next) {
-
current = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (get_viewport()->get_camera() == this) {
get_viewport()->_camera_set(nullptr);
@@ -258,27 +252,23 @@ void Camera3D::set_current(bool p_current) {
}
bool Camera3D::is_current() const {
-
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
-
return get_viewport()->get_camera() == this;
- } else
+ } else {
return current;
+ }
}
bool Camera3D::_can_gizmo_scale() const {
-
return false;
}
Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const {
-
Vector3 ray = project_local_ray_normal(p_pos);
return get_camera_transform().basis.xform(ray).normalized();
};
Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const {
-
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
Size2 viewport_size = get_viewport()->get_camera_rect_size();
@@ -286,7 +276,6 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const {
Vector3 ray;
if (mode == PROJECTION_ORTHOGONAL) {
-
ray = Vector3(0, 0, -1);
} else {
CameraMatrix cm;
@@ -299,7 +288,6 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const {
};
Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const {
-
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
Size2 viewport_size = get_viewport()->get_camera_rect_size();
@@ -307,10 +295,8 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const {
ERR_FAIL_COND_V(viewport_size.y == 0, Vector3());
if (mode == PROJECTION_PERSPECTIVE) {
-
return get_camera_transform().origin;
} else {
-
Vector2 pos = cpos / viewport_size;
float vsize, hsize;
if (keep_aspect == KEEP_WIDTH) {
@@ -331,7 +317,6 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const {
};
bool Camera3D::is_position_behind(const Vector3 &p_pos) const {
-
Transform t = get_global_transform();
Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized();
return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near);
@@ -344,10 +329,11 @@ Vector<Vector3> Camera3D::get_near_plane_points() const {
CameraMatrix cm;
- if (mode == PROJECTION_ORTHOGONAL)
+ if (mode == PROJECTION_ORTHOGONAL) {
cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ }
Vector3 endpoints[8];
cm.get_endpoints(Transform(), endpoints);
@@ -361,17 +347,17 @@ Vector<Vector3> Camera3D::get_near_plane_points() const {
}
Point2 Camera3D::unproject_position(const Vector3 &p_pos) const {
-
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector2(), "Camera is not inside scene.");
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
- if (mode == PROJECTION_ORTHOGONAL)
+ if (mode == PROJECTION_ORTHOGONAL) {
cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ }
Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
@@ -386,7 +372,6 @@ Point2 Camera3D::unproject_position(const Vector3 &p_pos) const {
}
Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const {
-
ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene.");
if (p_z_depth == 0 && mode != PROJECTION_ORTHOGONAL) {
@@ -396,10 +381,11 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const
CameraMatrix cm;
- if (mode == PROJECTION_ORTHOGONAL)
+ if (mode == PROJECTION_ORTHOGONAL) {
cm.set_orthogonal(size, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_perspective(fov, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
+ }
Vector2 vp_he = cm.get_viewport_half_extents();
@@ -414,32 +400,30 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const
}
void Camera3D::set_environment(const Ref<Environment> &p_environment) {
-
environment = p_environment;
- if (environment.is_valid())
+ if (environment.is_valid()) {
RS::get_singleton()->camera_set_environment(camera, environment->get_rid());
- else
+ } else {
RS::get_singleton()->camera_set_environment(camera, RID());
+ }
_update_camera_mode();
}
Ref<Environment> Camera3D::get_environment() const {
-
return environment;
}
void Camera3D::set_effects(const Ref<CameraEffects> &p_effects) {
-
effects = p_effects;
- if (effects.is_valid())
+ if (effects.is_valid()) {
RS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid());
- else
+ } else {
RS::get_singleton()->camera_set_camera_effects(camera, RID());
+ }
_update_camera_mode();
}
Ref<CameraEffects> Camera3D::get_effects() const {
-
return effects;
}
@@ -451,14 +435,13 @@ void Camera3D::set_keep_aspect_mode(KeepAspect p_aspect) {
}
Camera3D::KeepAspect Camera3D::get_keep_aspect_mode() const {
-
return keep_aspect;
}
void Camera3D::set_doppler_tracking(DopplerTracking p_tracking) {
-
- if (doppler_tracking == p_tracking)
+ if (doppler_tracking == p_tracking) {
return;
+ }
doppler_tracking = p_tracking;
if (p_tracking != DOPPLER_TRACKING_DISABLED) {
@@ -475,7 +458,6 @@ Camera3D::DopplerTracking Camera3D::get_doppler_tracking() const {
}
void Camera3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("project_ray_normal", "screen_point"), &Camera3D::project_ray_normal);
ClassDB::bind_method(D_METHOD("project_local_ray_normal", "screen_point"), &Camera3D::project_local_ray_normal);
ClassDB::bind_method(D_METHOD("project_ray_origin", "screen_point"), &Camera3D::project_ray_origin);
@@ -552,17 +534,14 @@ void Camera3D::_bind_methods() {
}
float Camera3D::get_fov() const {
-
return fov;
}
float Camera3D::get_size() const {
-
return size;
}
float Camera3D::get_znear() const {
-
return near;
}
@@ -571,12 +550,10 @@ Vector2 Camera3D::get_frustum_offset() const {
}
float Camera3D::get_zfar() const {
-
return far;
}
Camera3D::Projection Camera3D::get_projection() const {
-
return mode;
}
@@ -616,7 +593,6 @@ void Camera3D::set_cull_mask(uint32_t p_layers) {
}
uint32_t Camera3D::get_cull_mask() const {
-
return layers;
}
@@ -635,27 +611,25 @@ bool Camera3D::get_cull_mask_bit(int p_layer) const {
}
Vector<Plane> Camera3D::get_frustum() const {
-
ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
- if (mode == PROJECTION_PERSPECTIVE)
+ if (mode == PROJECTION_PERSPECTIVE) {
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ }
return cm.get_projection_planes(get_camera_transform());
}
void Camera3D::set_v_offset(float p_offset) {
-
v_offset = p_offset;
_update_camera();
}
float Camera3D::get_v_offset() const {
-
return v_offset;
}
@@ -665,20 +639,18 @@ void Camera3D::set_h_offset(float p_offset) {
}
float Camera3D::get_h_offset() const {
-
return h_offset;
}
Vector3 Camera3D::get_doppler_tracked_velocity() const {
-
if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
return velocity_tracker->get_tracked_linear_velocity();
} else {
return Vector3();
}
}
-Camera3D::Camera3D() {
+Camera3D::Camera3D() {
camera = RenderingServer::get_singleton()->camera_create();
size = 1;
fov = 0;
@@ -703,7 +675,6 @@ Camera3D::Camera3D() {
}
Camera3D::~Camera3D() {
-
RenderingServer::get_singleton()->free(camera);
}
@@ -712,11 +683,12 @@ Camera3D::~Camera3D() {
void ClippedCamera3D::set_margin(float p_margin) {
margin = p_margin;
}
+
float ClippedCamera3D::get_margin() const {
return margin;
}
-void ClippedCamera3D::set_process_mode(ProcessMode p_mode) {
+void ClippedCamera3D::set_process_mode(ProcessMode p_mode) {
if (process_mode == p_mode) {
return;
}
@@ -724,12 +696,12 @@ void ClippedCamera3D::set_process_mode(ProcessMode p_mode) {
set_process_internal(process_mode == CLIP_PROCESS_IDLE);
set_physics_process_internal(process_mode == CLIP_PROCESS_PHYSICS);
}
+
ClippedCamera3D::ProcessMode ClippedCamera3D::get_process_mode() const {
return process_mode;
}
Transform ClippedCamera3D::get_camera_transform() const {
-
Transform t = Camera3D::get_camera_transform();
t.origin += -t.basis.get_axis(Vector3::AXIS_Z).normalized() * clip_offset;
return t;
@@ -737,7 +709,6 @@ Transform ClippedCamera3D::get_camera_transform() const {
void ClippedCamera3D::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS || p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
-
Node3D *parent = Object::cast_to<Node3D>(get_parent());
if (!parent) {
return;
@@ -797,90 +768,78 @@ void ClippedCamera3D::_notification(int p_what) {
}
void ClippedCamera3D::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
}
uint32_t ClippedCamera3D::get_collision_mask() const {
-
return collision_mask;
}
void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool ClippedCamera3D::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
void ClippedCamera3D::add_exception_rid(const RID &p_rid) {
-
exclude.insert(p_rid);
}
void ClippedCamera3D::add_exception(const Object *p_object) {
-
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
add_exception_rid(co->get_rid());
}
void ClippedCamera3D::remove_exception_rid(const RID &p_rid) {
-
exclude.erase(p_rid);
}
void ClippedCamera3D::remove_exception(const Object *p_object) {
-
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
remove_exception_rid(co->get_rid());
}
void ClippedCamera3D::clear_exceptions() {
-
exclude.clear();
}
float ClippedCamera3D::get_clip_offset() const {
-
return clip_offset;
}
void ClippedCamera3D::set_clip_to_areas(bool p_clip) {
-
clip_to_areas = p_clip;
}
bool ClippedCamera3D::is_clip_to_areas_enabled() const {
-
return clip_to_areas;
}
void ClippedCamera3D::set_clip_to_bodies(bool p_clip) {
-
clip_to_bodies = p_clip;
}
bool ClippedCamera3D::is_clip_to_bodies_enabled() const {
-
return clip_to_bodies;
}
void ClippedCamera3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_margin", "margin"), &ClippedCamera3D::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &ClippedCamera3D::get_margin);
@@ -920,6 +879,7 @@ void ClippedCamera3D::_bind_methods() {
BIND_ENUM_CONSTANT(CLIP_PROCESS_PHYSICS);
BIND_ENUM_CONSTANT(CLIP_PROCESS_IDLE);
}
+
ClippedCamera3D::ClippedCamera3D() {
margin = 0;
clip_offset = 0;
@@ -932,6 +892,7 @@ ClippedCamera3D::ClippedCamera3D() {
clip_to_areas = false;
clip_to_bodies = true;
}
+
ClippedCamera3D::~ClippedCamera3D() {
PhysicsServer3D::get_singleton()->free(pyramid_shape);
}
diff --git a/scene/3d/camera_3d.h b/scene/3d/camera_3d.h
index 9a005226cb..138b1b8a7a 100644
--- a/scene/3d/camera_3d.h
+++ b/scene/3d/camera_3d.h
@@ -37,7 +37,6 @@
#include "scene/resources/environment.h"
class Camera3D : public Node3D {
-
GDCLASS(Camera3D, Node3D);
public:
@@ -184,7 +183,6 @@ VARIANT_ENUM_CAST(Camera3D::KeepAspect);
VARIANT_ENUM_CAST(Camera3D::DopplerTracking);
class ClippedCamera3D : public Camera3D {
-
GDCLASS(ClippedCamera3D, Camera3D);
public:
diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp
index 5d050e32b0..356992e922 100644
--- a/scene/3d/collision_object_3d.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -34,52 +34,49 @@
#include "servers/physics_server_3d.h"
void CollisionObject3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_WORLD: {
-
- if (area)
+ if (area) {
PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ }
RID space = get_world_3d()->get_space();
if (area) {
PhysicsServer3D::get_singleton()->area_set_space(rid, space);
- } else
+ } else {
PhysicsServer3D::get_singleton()->body_set_space(rid, space);
+ }
_update_pickable();
//get space
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
- if (area)
+ if (area) {
PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ }
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
_update_pickable();
} break;
case NOTIFICATION_EXIT_WORLD: {
-
if (area) {
PhysicsServer3D::get_singleton()->area_set_space(rid, RID());
- } else
+ } else {
PhysicsServer3D::get_singleton()->body_set_space(rid, RID());
+ }
} break;
}
}
void CollisionObject3D::_input_event(Node *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_camera, p_input_event, p_pos, p_normal, p_shape);
}
@@ -87,7 +84,6 @@ void CollisionObject3D::_input_event(Node *p_camera, const Ref<InputEvent> &p_in
}
void CollisionObject3D::_mouse_enter() {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
}
@@ -95,7 +91,6 @@ void CollisionObject3D::_mouse_enter() {
}
void CollisionObject3D::_mouse_exit() {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
}
@@ -103,29 +98,28 @@ void CollisionObject3D::_mouse_exit() {
}
void CollisionObject3D::_update_pickable() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool pickable = ray_pickable && is_visible_in_tree();
- if (area)
+ if (area) {
PhysicsServer3D::get_singleton()->area_set_ray_pickable(rid, pickable);
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_ray_pickable(rid, pickable);
+ }
}
void CollisionObject3D::set_ray_pickable(bool p_ray_pickable) {
-
ray_pickable = p_ray_pickable;
_update_pickable();
}
bool CollisionObject3D::is_ray_pickable() const {
-
return ray_pickable;
}
void CollisionObject3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &CollisionObject3D::set_ray_pickable);
ClassDB::bind_method(D_METHOD("is_ray_pickable"), &CollisionObject3D::is_ray_pickable);
ClassDB::bind_method(D_METHOD("set_capture_input_on_drag", "enable"), &CollisionObject3D::set_capture_input_on_drag);
@@ -158,7 +152,6 @@ void CollisionObject3D::_bind_methods() {
}
uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) {
-
ShapeData sd;
uint32_t id;
@@ -176,7 +169,6 @@ uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) {
}
void CollisionObject3D::remove_shape_owner(uint32_t owner) {
-
ERR_FAIL_COND(!shapes.has(owner));
shape_owner_clear_shapes(owner);
@@ -199,21 +191,18 @@ void CollisionObject3D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl
}
bool CollisionObject3D::is_shape_owner_disabled(uint32_t p_owner) const {
-
ERR_FAIL_COND_V(!shapes.has(p_owner), false);
return shapes[p_owner].disabled;
}
void CollisionObject3D::get_shape_owners(List<uint32_t> *r_owners) {
-
for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
r_owners->push_back(E->key());
}
}
Array CollisionObject3D::_get_shape_owners() {
-
Array ret;
for (Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
ret.push_back(E->key());
@@ -223,7 +212,6 @@ Array CollisionObject3D::_get_shape_owners() {
}
void CollisionObject3D::shape_owner_set_transform(uint32_t p_owner, const Transform &p_transform) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
ShapeData &sd = shapes[p_owner];
@@ -236,22 +224,20 @@ void CollisionObject3D::shape_owner_set_transform(uint32_t p_owner, const Transf
}
}
}
-Transform CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const {
+Transform CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), Transform());
return shapes[p_owner].xform;
}
Object *CollisionObject3D::shape_owner_get_owner(uint32_t p_owner) const {
-
ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr);
return shapes[p_owner].owner;
}
void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3D> &p_shape) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
ERR_FAIL_COND(p_shape.is_null());
@@ -268,21 +254,21 @@ void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3
total_subshapes++;
}
-int CollisionObject3D::shape_owner_get_shape_count(uint32_t p_owner) const {
+int CollisionObject3D::shape_owner_get_shape_count(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), 0);
return shapes[p_owner].shapes.size();
}
-Ref<Shape3D> CollisionObject3D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
+Ref<Shape3D> CollisionObject3D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape3D>());
ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape3D>());
return shapes[p_owner].shapes[p_shape].shape;
}
-int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
+int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), -1);
ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), -1);
@@ -290,7 +276,6 @@ int CollisionObject3D::shape_owner_get_shape_index(uint32_t p_owner, int p_shape
}
void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
ERR_FAIL_INDEX(p_shape, shapes[p_owner].shapes.size());
@@ -315,7 +300,6 @@ void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape)
}
void CollisionObject3D::shape_owner_clear_shapes(uint32_t p_owner) {
-
ERR_FAIL_COND(!shapes.has(p_owner));
while (shape_owner_get_shape_count(p_owner) > 0) {
@@ -324,7 +308,6 @@ void CollisionObject3D::shape_owner_clear_shapes(uint32_t p_owner) {
}
uint32_t CollisionObject3D::shape_find_owner(int p_shape_index) const {
-
ERR_FAIL_INDEX_V(p_shape_index, total_subshapes, 0);
for (const Map<uint32_t, ShapeData>::Element *E = shapes.front(); E; E = E->next()) {
@@ -340,7 +323,6 @@ uint32_t CollisionObject3D::shape_find_owner(int p_shape_index) const {
}
CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) {
-
rid = p_rid;
area = p_area;
capture_input_on_drag = false;
@@ -357,17 +339,14 @@ CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) {
}
void CollisionObject3D::set_capture_input_on_drag(bool p_capture) {
-
capture_input_on_drag = p_capture;
}
bool CollisionObject3D::get_capture_input_on_drag() const {
-
return capture_input_on_drag;
}
String CollisionObject3D::get_configuration_warning() const {
-
String warning = Node3D::get_configuration_warning();
if (shapes.empty()) {
@@ -381,7 +360,6 @@ String CollisionObject3D::get_configuration_warning() const {
}
CollisionObject3D::CollisionObject3D() {
-
capture_input_on_drag = false;
ray_pickable = true;
set_notify_transform(true);
@@ -391,6 +369,5 @@ CollisionObject3D::CollisionObject3D() {
}
CollisionObject3D::~CollisionObject3D() {
-
PhysicsServer3D::get_singleton()->free(rid);
}
diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h
index 67d3aed3c8..8bcbef0e98 100644
--- a/scene/3d/collision_object_3d.h
+++ b/scene/3d/collision_object_3d.h
@@ -35,7 +35,6 @@
#include "scene/resources/shape_3d.h"
class CollisionObject3D : public Node3D {
-
GDCLASS(CollisionObject3D, Node3D);
bool area;
@@ -43,7 +42,6 @@ class CollisionObject3D : public Node3D {
RID rid;
struct ShapeData {
-
Object *owner;
Transform xform;
struct ShapeBase {
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index 66bd903eeb..e2d11c740a 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -31,22 +31,25 @@
#include "collision_polygon_3d.h"
#include "collision_object_3d.h"
+#include "core/math/geometry_2d.h"
#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_3d.h"
void CollisionPolygon3D::_build_polygon() {
-
- if (!parent)
+ if (!parent) {
return;
+ }
parent->shape_owner_clear_shapes(owner_id);
- if (polygon.size() == 0)
+ if (polygon.size() == 0) {
return;
+ }
- Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon);
- if (decomp.size() == 0)
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(polygon);
+ if (decomp.size() == 0) {
return;
+ }
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
@@ -60,7 +63,6 @@ void CollisionPolygon3D::_build_polygon() {
Vector3 *w = cp.ptrw();
int idx = 0;
for (int j = 0; j < cs; j++) {
-
Vector2 d = decomp[i][j];
w[idx++] = Vector3(d.x, d.y, depth * 0.5);
w[idx++] = Vector3(d.x, d.y, -depth * 0.5);
@@ -74,17 +76,15 @@ void CollisionPolygon3D::_build_polygon() {
}
void CollisionPolygon3D::_update_in_shape_owner(bool p_xform_only) {
-
parent->shape_owner_set_transform(owner_id, get_transform());
- if (p_xform_only)
+ if (p_xform_only) {
return;
+ }
parent->shape_owner_set_disabled(owner_id, disabled);
}
void CollisionPolygon3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_PARENTED: {
parent = Object::cast_to<CollisionObject3D>(get_parent());
if (parent) {
@@ -94,14 +94,12 @@ void CollisionPolygon3D::_notification(int p_what) {
}
} break;
case NOTIFICATION_ENTER_TREE: {
-
if (parent) {
_update_in_shape_owner();
}
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
-
if (parent) {
_update_in_shape_owner(true);
}
@@ -118,7 +116,6 @@ void CollisionPolygon3D::_notification(int p_what) {
}
void CollisionPolygon3D::set_polygon(const Vector<Point2> &p_polygon) {
-
polygon = p_polygon;
if (parent) {
_build_polygon();
@@ -128,24 +125,20 @@ void CollisionPolygon3D::set_polygon(const Vector<Point2> &p_polygon) {
}
Vector<Point2> CollisionPolygon3D::get_polygon() const {
-
return polygon;
}
AABB CollisionPolygon3D::get_item_rect() const {
-
return aabb;
}
void CollisionPolygon3D::set_depth(float p_depth) {
-
depth = p_depth;
_build_polygon();
update_gizmo();
}
float CollisionPolygon3D::get_depth() const {
-
return depth;
}
@@ -163,7 +156,6 @@ bool CollisionPolygon3D::is_disabled() const {
}
String CollisionPolygon3D::get_configuration_warning() const {
-
if (!Object::cast_to<CollisionObject3D>(get_parent())) {
return TTR("CollisionPolygon3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape.");
}
@@ -178,8 +170,8 @@ String CollisionPolygon3D::get_configuration_warning() const {
bool CollisionPolygon3D::_is_editable_3d_polygon() const {
return true;
}
-void CollisionPolygon3D::_bind_methods() {
+void CollisionPolygon3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CollisionPolygon3D::set_depth);
ClassDB::bind_method(D_METHOD("get_depth"), &CollisionPolygon3D::get_depth);
@@ -197,7 +189,6 @@ void CollisionPolygon3D::_bind_methods() {
}
CollisionPolygon3D::CollisionPolygon3D() {
-
aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
depth = 1.0;
set_notify_local_transform(true);
diff --git a/scene/3d/collision_polygon_3d.h b/scene/3d/collision_polygon_3d.h
index 256aee3d7e..0cd9aee111 100644
--- a/scene/3d/collision_polygon_3d.h
+++ b/scene/3d/collision_polygon_3d.h
@@ -36,7 +36,6 @@
class CollisionObject3D;
class CollisionPolygon3D : public Node3D {
-
GDCLASS(CollisionPolygon3D, Node3D);
protected:
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index a66e84ac3c..56367e9bdd 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -45,20 +45,17 @@
//TODO: Implement CylinderShape and HeightMapShape?
void CollisionShape3D::make_convex_from_brothers() {
-
Node *p = get_parent();
- if (!p)
+ if (!p) {
return;
+ }
for (int i = 0; i < p->get_child_count(); i++) {
-
Node *n = p->get_child(i);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(n);
if (mi) {
-
Ref<Mesh> m = mi->get_mesh();
if (m.is_valid()) {
-
Ref<Shape3D> s = m->create_convex_shape();
set_shape(s);
}
@@ -68,15 +65,14 @@ void CollisionShape3D::make_convex_from_brothers() {
void CollisionShape3D::_update_in_shape_owner(bool p_xform_only) {
parent->shape_owner_set_transform(owner_id, get_transform());
- if (p_xform_only)
+ if (p_xform_only) {
return;
+ }
parent->shape_owner_set_disabled(owner_id, disabled);
}
void CollisionShape3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_PARENTED: {
parent = Object::cast_to<CollisionObject3D>(get_parent());
if (parent) {
@@ -111,12 +107,10 @@ void CollisionShape3D::_notification(int p_what) {
}
void CollisionShape3D::resource_changed(RES res) {
-
update_gizmo();
}
String CollisionShape3D::get_configuration_warning() const {
-
if (!Object::cast_to<CollisionObject3D>(get_parent())) {
return TTR("CollisionShape3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape.");
}
@@ -137,7 +131,6 @@ String CollisionShape3D::get_configuration_warning() const {
}
void CollisionShape3D::_bind_methods() {
-
//not sure if this should do anything
ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &CollisionShape3D::resource_changed);
ClassDB::bind_method(D_METHOD("set_shape", "shape"), &CollisionShape3D::set_shape);
@@ -154,7 +147,6 @@ void CollisionShape3D::_bind_methods() {
}
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
-
if (!shape.is_null()) {
shape->unregister_owner(this);
shape->disconnect("changed", callable_mp(this, &CollisionShape3D::_shape_changed));
@@ -172,18 +164,17 @@ void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
}
}
- if (is_inside_tree())
+ if (is_inside_tree()) {
_shape_changed();
+ }
update_configuration_warning();
}
Ref<Shape3D> CollisionShape3D::get_shape() const {
-
return shape;
}
void CollisionShape3D::set_disabled(bool p_disabled) {
-
disabled = p_disabled;
update_gizmo();
if (parent) {
@@ -192,12 +183,10 @@ void CollisionShape3D::set_disabled(bool p_disabled) {
}
bool CollisionShape3D::is_disabled() const {
-
return disabled;
}
CollisionShape3D::CollisionShape3D() {
-
//indicator = RenderingServer::get_singleton()->mesh_create();
disabled = false;
debug_shape = nullptr;
@@ -207,8 +196,9 @@ CollisionShape3D::CollisionShape3D() {
}
CollisionShape3D::~CollisionShape3D() {
- if (!shape.is_null())
+ if (!shape.is_null()) {
shape->unregister_owner(this);
+ }
//RenderingServer::get_singleton()->free(indicator);
}
@@ -221,8 +211,9 @@ void CollisionShape3D::_update_debug_shape() {
}
Ref<Shape3D> s = get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return;
+ }
Ref<Mesh> mesh = s->get_debug_mesh();
MeshInstance3D *mi = memnew(MeshInstance3D);
diff --git a/scene/3d/collision_shape_3d.h b/scene/3d/collision_shape_3d.h
index 8515d292af..4ed2f4007b 100644
--- a/scene/3d/collision_shape_3d.h
+++ b/scene/3d/collision_shape_3d.h
@@ -35,7 +35,6 @@
#include "scene/resources/shape_3d.h"
class CollisionObject3D;
class CollisionShape3D : public Node3D {
-
GDCLASS(CollisionShape3D, Node3D);
OBJ_CATEGORY("3D Physics Nodes");
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp
index 414dc6f97b..4244a11592 100644
--- a/scene/3d/cpu_particles_3d.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -36,31 +36,30 @@
#include "servers/rendering_server.h"
AABB CPUParticles3D::get_aabb() const {
-
return AABB();
}
-Vector<Face3> CPUParticles3D::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> CPUParticles3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void CPUParticles3D::set_emitting(bool p_emitting) {
-
- if (emitting == p_emitting)
+ if (emitting == p_emitting) {
return;
+ }
emitting = p_emitting;
if (emitting) {
set_process_internal(true);
// first update before rendering to avoid one frame delay after emitting starts
- if (time == 0)
+ if (time == 0) {
_update_internal();
+ }
}
}
void CPUParticles3D::set_amount(int p_amount) {
-
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0.");
particles.resize(p_amount);
@@ -78,98 +77,89 @@ void CPUParticles3D::set_amount(int p_amount) {
particle_order.resize(p_amount);
}
-void CPUParticles3D::set_lifetime(float p_lifetime) {
+void CPUParticles3D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
}
void CPUParticles3D::set_one_shot(bool p_one_shot) {
-
one_shot = p_one_shot;
}
void CPUParticles3D::set_pre_process_time(float p_time) {
-
pre_process_time = p_time;
}
-void CPUParticles3D::set_explosiveness_ratio(float p_ratio) {
+void CPUParticles3D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
}
-void CPUParticles3D::set_randomness_ratio(float p_ratio) {
+void CPUParticles3D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
}
-void CPUParticles3D::set_lifetime_randomness(float p_random) {
+void CPUParticles3D::set_lifetime_randomness(float p_random) {
lifetime_randomness = p_random;
}
-void CPUParticles3D::set_use_local_coordinates(bool p_enable) {
+void CPUParticles3D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
}
-void CPUParticles3D::set_speed_scale(float p_scale) {
+void CPUParticles3D::set_speed_scale(float p_scale) {
speed_scale = p_scale;
}
bool CPUParticles3D::is_emitting() const {
-
return emitting;
}
-int CPUParticles3D::get_amount() const {
+int CPUParticles3D::get_amount() const {
return particles.size();
}
-float CPUParticles3D::get_lifetime() const {
+float CPUParticles3D::get_lifetime() const {
return lifetime;
}
-bool CPUParticles3D::get_one_shot() const {
+bool CPUParticles3D::get_one_shot() const {
return one_shot;
}
float CPUParticles3D::get_pre_process_time() const {
-
return pre_process_time;
}
-float CPUParticles3D::get_explosiveness_ratio() const {
+float CPUParticles3D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float CPUParticles3D::get_randomness_ratio() const {
+float CPUParticles3D::get_randomness_ratio() const {
return randomness_ratio;
}
-float CPUParticles3D::get_lifetime_randomness() const {
+float CPUParticles3D::get_lifetime_randomness() const {
return lifetime_randomness;
}
bool CPUParticles3D::get_use_local_coordinates() const {
-
return local_coords;
}
float CPUParticles3D::get_speed_scale() const {
-
return speed_scale;
}
void CPUParticles3D::set_draw_order(DrawOrder p_order) {
-
draw_order = p_order;
}
CPUParticles3D::DrawOrder CPUParticles3D::get_draw_order() const {
-
return draw_order;
}
void CPUParticles3D::set_mesh(const Ref<Mesh> &p_mesh) {
-
mesh = p_mesh;
if (mesh.is_valid()) {
RS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
@@ -179,7 +169,6 @@ void CPUParticles3D::set_mesh(const Ref<Mesh> &p_mesh) {
}
Ref<Mesh> CPUParticles3D::get_mesh() const {
-
return mesh;
}
@@ -200,7 +189,6 @@ bool CPUParticles3D::get_fractional_delta() const {
}
String CPUParticles3D::get_configuration_warning() const {
-
String warnings;
bool mesh_found = false;
@@ -220,15 +208,17 @@ String CPUParticles3D::get_configuration_warning() const {
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES);
if (!mesh_found) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Nothing is visible because no mesh has been assigned.");
}
if (!anim_material_found && (get_param(PARAM_ANIM_SPEED) != 0.0 || get_param(PARAM_ANIM_OFFSET) != 0.0 ||
get_param_curve(PARAM_ANIM_SPEED).is_valid() || get_param_curve(PARAM_ANIM_OFFSET).is_valid())) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("CPUParticles3D animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\".");
}
@@ -236,7 +226,6 @@ String CPUParticles3D::get_configuration_warning() const {
}
void CPUParticles3D::restart() {
-
time = 0;
inactive_time = 0;
frame_remainder = 0;
@@ -256,71 +245,63 @@ void CPUParticles3D::restart() {
}
void CPUParticles3D::set_direction(Vector3 p_direction) {
-
direction = p_direction;
}
Vector3 CPUParticles3D::get_direction() const {
-
return direction;
}
void CPUParticles3D::set_spread(float p_spread) {
-
spread = p_spread;
}
float CPUParticles3D::get_spread() const {
-
return spread;
}
void CPUParticles3D::set_flatness(float p_flatness) {
-
flatness = p_flatness;
}
-float CPUParticles3D::get_flatness() const {
+float CPUParticles3D::get_flatness() const {
return flatness;
}
void CPUParticles3D::set_param(Parameter p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
parameters[p_param] = p_value;
}
-float CPUParticles3D::get_param(Parameter p_param) const {
+float CPUParticles3D::get_param(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return parameters[p_param];
}
void CPUParticles3D::set_param_randomness(Parameter p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
randomness[p_param] = p_value;
}
-float CPUParticles3D::get_param_randomness(Parameter p_param) const {
+float CPUParticles3D::get_param_randomness(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return randomness[p_param];
}
static void _adjust_curve_range(const Ref<Curve> &p_curve, float p_min, float p_max) {
-
Ref<Curve> curve = p_curve;
- if (!curve.is_valid())
+ if (!curve.is_valid()) {
return;
+ }
curve->ensure_default_setup(p_min, p_max);
}
void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
curve_parameters[p_param] = p_curve;
@@ -351,7 +332,6 @@ void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv
_adjust_curve_range(p_curve, -360, 360);
} break;
case PARAM_SCALE: {
-
} break;
case PARAM_HUE_VARIATION: {
_adjust_curve_range(p_curve, -1, 1);
@@ -365,30 +345,26 @@ void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv
}
}
}
-Ref<Curve> CPUParticles3D::get_param_curve(Parameter p_param) const {
+Ref<Curve> CPUParticles3D::get_param_curve(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Curve>());
return curve_parameters[p_param];
}
void CPUParticles3D::set_color(const Color &p_color) {
-
color = p_color;
}
Color CPUParticles3D::get_color() const {
-
return color;
}
void CPUParticles3D::set_color_ramp(const Ref<Gradient> &p_ramp) {
-
color_ramp = p_ramp;
}
Ref<Gradient> CPUParticles3D::get_color_ramp() const {
-
return color_ramp;
}
@@ -411,67 +387,58 @@ void CPUParticles3D::set_emission_shape(EmissionShape p_shape) {
}
void CPUParticles3D::set_emission_sphere_radius(float p_radius) {
-
emission_sphere_radius = p_radius;
}
void CPUParticles3D::set_emission_box_extents(Vector3 p_extents) {
-
emission_box_extents = p_extents;
}
void CPUParticles3D::set_emission_points(const Vector<Vector3> &p_points) {
-
emission_points = p_points;
}
void CPUParticles3D::set_emission_normals(const Vector<Vector3> &p_normals) {
-
emission_normals = p_normals;
}
void CPUParticles3D::set_emission_colors(const Vector<Color> &p_colors) {
-
emission_colors = p_colors;
}
float CPUParticles3D::get_emission_sphere_radius() const {
-
return emission_sphere_radius;
}
-Vector3 CPUParticles3D::get_emission_box_extents() const {
+Vector3 CPUParticles3D::get_emission_box_extents() const {
return emission_box_extents;
}
-Vector<Vector3> CPUParticles3D::get_emission_points() const {
+Vector<Vector3> CPUParticles3D::get_emission_points() const {
return emission_points;
}
-Vector<Vector3> CPUParticles3D::get_emission_normals() const {
+Vector<Vector3> CPUParticles3D::get_emission_normals() const {
return emission_normals;
}
Vector<Color> CPUParticles3D::get_emission_colors() const {
-
return emission_colors;
}
CPUParticles3D::EmissionShape CPUParticles3D::get_emission_shape() const {
return emission_shape;
}
-void CPUParticles3D::set_gravity(const Vector3 &p_gravity) {
+void CPUParticles3D::set_gravity(const Vector3 &p_gravity) {
gravity = p_gravity;
}
Vector3 CPUParticles3D::get_gravity() const {
-
return gravity;
}
void CPUParticles3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "color" && color_ramp.is_valid()) {
property.usage = 0;
}
@@ -498,7 +465,6 @@ void CPUParticles3D::_validate_property(PropertyInfo &property) const {
}
static uint32_t idhash(uint32_t x) {
-
x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b);
x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b);
x = (x >> uint32_t(16)) ^ x;
@@ -508,18 +474,19 @@ static uint32_t idhash(uint32_t x) {
static float rand_from_seed(uint32_t &seed) {
int k;
int s = int(seed);
- if (s == 0)
+ if (s == 0) {
s = 305420679;
+ }
k = s / 127773;
s = 16807 * (s - k * 127773) - 2836 * k;
- if (s < 0)
+ if (s < 0) {
s += 2147483647;
+ }
seed = uint32_t(s);
return float(seed % uint32_t(65536)) / 65535.0;
}
void CPUParticles3D::_update_internal() {
-
if (particles.size() == 0 || !is_visible_in_tree()) {
_set_redraw(false);
return;
@@ -547,12 +514,12 @@ void CPUParticles3D::_update_internal() {
bool processed = false;
if (time == 0 && pre_process_time > 0.0) {
-
float frame_time;
- if (fixed_fps > 0)
+ if (fixed_fps > 0) {
frame_time = 1.0 / fixed_fps;
- else
+ } else {
frame_time = 1.0 / 30.0;
+ }
float todo = pre_process_time;
@@ -594,7 +561,6 @@ void CPUParticles3D::_update_internal() {
}
void CPUParticles3D::_particles_process(float p_delta) {
-
p_delta *= speed_scale;
int pcount = particles.size();
@@ -623,11 +589,11 @@ void CPUParticles3D::_particles_process(float p_delta) {
float system_phase = time / lifetime;
for (int i = 0; i < pcount; i++) {
-
Particle &p = parray[i];
- if (!emitting && !p.active)
+ if (!emitting && !p.active) {
continue;
+ }
float local_delta = p_delta;
@@ -681,7 +647,6 @@ void CPUParticles3D::_particles_process(float p_delta) {
}
if (restart) {
-
if (!emitting) {
p.active = false;
continue;
@@ -750,10 +715,10 @@ void CPUParticles3D::_particles_process(float p_delta) {
} break;
case EMISSION_SHAPE_POINTS:
case EMISSION_SHAPE_DIRECTED_POINTS: {
-
int pc = emission_points.size();
- if (pc == 0)
+ if (pc == 0) {
break;
+ }
int random_idx = Math::rand() % pc;
@@ -805,7 +770,6 @@ void CPUParticles3D::_particles_process(float p_delta) {
} else if (p.time > p.lifetime) {
p.active = false;
} else {
-
uint32_t alt_seed = p.seed;
p.time += local_delta;
@@ -875,7 +839,6 @@ void CPUParticles3D::_particles_process(float p_delta) {
force += diff.length() > 0.0 ? diff.normalized() * (parameters[PARAM_RADIAL_ACCEL] + tex_radial_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_RADIAL_ACCEL]) : Vector3();
//apply tangential acceleration;
if (flags[FLAG_DISABLE_Z]) {
-
Vector2 yx = Vector2(diff.y, diff.x);
Vector2 yx2 = (yx * Vector2(-1.0, 1.0)).normalized();
force += yx.length() > 0.0 ? Vector3(yx2.x, yx2.y, 0.0) * ((parameters[PARAM_TANGENTIAL_ACCEL] + tex_tangential_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_TANGENTIAL_ACCEL])) : Vector3();
@@ -903,7 +866,6 @@ void CPUParticles3D::_particles_process(float p_delta) {
p.velocity = p.velocity.normalized() * tex_linear_velocity;
}
if (parameters[PARAM_DAMPING] + tex_damping > 0.0) {
-
float v = p.velocity.length();
float damp = (parameters[PARAM_DAMPING] + tex_damping) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_DAMPING]);
v -= damp * local_delta;
@@ -960,7 +922,6 @@ void CPUParticles3D::_particles_process(float p_delta) {
p.color *= p.base_color;
if (flags[FLAG_DISABLE_Z]) {
-
if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
if (p.velocity.length() > 0.0) {
p.transform.basis.set_axis(1, p.velocity.normalized());
@@ -1004,8 +965,9 @@ void CPUParticles3D::_particles_process(float p_delta) {
//scale by scale
float base_scale = tex_scale * Math::lerp(parameters[PARAM_SCALE], 1.0f, p.scale_rand * randomness[PARAM_SCALE]);
- if (base_scale < 0.000001)
+ if (base_scale < 0.000001) {
base_scale = 0.000001;
+ }
p.transform.basis.scale(Vector3(1, 1, 1) * base_scale);
@@ -1047,7 +1009,6 @@ void CPUParticles3D::_update_particle_data_buffer() {
Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close
if (local_coords) {
-
// will look different from Particles in editor as this is based on the camera in the scenetree
// and not the editor camera
dir = inv_emission_transform.xform(dir).normalized();
@@ -1064,7 +1025,6 @@ void CPUParticles3D::_update_particle_data_buffer() {
}
for (int i = 0; i < pc; i++) {
-
int idx = order ? order[i] : i;
Transform t = r[idx].transform;
@@ -1109,8 +1069,9 @@ void CPUParticles3D::_update_particle_data_buffer() {
}
void CPUParticles3D::_set_redraw(bool p_redraw) {
- if (redraw == p_redraw)
+ if (redraw == p_redraw) {
return;
+ }
redraw = p_redraw;
{
@@ -1131,7 +1092,6 @@ void CPUParticles3D::_set_redraw(bool p_redraw) {
}
void CPUParticles3D::_update_render_thread() {
-
MutexLock lock(update_mutex);
if (can_update) {
@@ -1141,13 +1101,13 @@ void CPUParticles3D::_update_render_thread() {
}
void CPUParticles3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
set_process_internal(emitting);
// first update before rendering to avoid one frame delay after emitting starts
- if (emitting && (time == 0))
+ if (emitting && (time == 0)) {
_update_internal();
+ }
}
if (p_what == NOTIFICATION_EXIT_TREE) {
@@ -1156,8 +1116,9 @@ void CPUParticles3D::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
// first update before rendering to avoid one frame delay after emitting starts
- if (emitting && (time == 0))
+ if (emitting && (time == 0)) {
_update_internal();
+ }
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
@@ -1165,11 +1126,9 @@ void CPUParticles3D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
-
inv_emission_transform = get_global_transform().affine_inverse();
if (!local_coords) {
-
int pc = particles.size();
float *w = particle_data.ptrw();
@@ -1177,7 +1136,6 @@ void CPUParticles3D::_notification(int p_what) {
float *ptr = w;
for (int i = 0; i < pc; i++) {
-
Transform t = inv_emission_transform * r[i].transform;
if (r[i].active) {
@@ -1206,7 +1164,6 @@ void CPUParticles3D::_notification(int p_what) {
}
void CPUParticles3D::convert_from_particles(Node *p_particles) {
-
GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_particles);
ERR_FAIL_COND_MSG(!particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D.");
@@ -1225,8 +1182,9 @@ void CPUParticles3D::convert_from_particles(Node *p_particles) {
set_mesh(particles->get_draw_pass_mesh(0));
Ref<ParticlesMaterial> material = particles->get_process_material();
- if (material.is_null())
+ if (material.is_null()) {
return;
+ }
set_direction(material->get_direction());
set_spread(material->get_spread());
@@ -1276,7 +1234,6 @@ void CPUParticles3D::convert_from_particles(Node *p_particles) {
}
void CPUParticles3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles3D::set_emitting);
ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles3D::set_amount);
ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles3D::set_lifetime);
@@ -1481,7 +1438,6 @@ void CPUParticles3D::_bind_methods() {
}
CPUParticles3D::CPUParticles3D() {
-
time = 0;
inactive_time = 0;
frame_remainder = 0;
diff --git a/scene/3d/cpu_particles_3d.h b/scene/3d/cpu_particles_3d.h
index ffe0ecc9a9..2afb6846c0 100644
--- a/scene/3d/cpu_particles_3d.h
+++ b/scene/3d/cpu_particles_3d.h
@@ -122,7 +122,6 @@ private:
const Particle *particles;
Vector3 axis;
bool operator()(int p_a, int p_b) const {
-
return axis.dot(particles[p_a].transform.origin) < axis.dot(particles[p_b].transform.origin);
}
};
diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp
index 4c824aedc4..fb72e10171 100644
--- a/scene/3d/decal.cpp
+++ b/scene/3d/decal.cpp
@@ -47,6 +47,7 @@ void Decal::set_texture(DecalTexture p_type, const Ref<Texture2D> &p_texture) {
RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RS::get_singleton()->decal_set_texture(decal, RS::DecalTexture(p_type), texture_rid);
}
+
Ref<Texture2D> Decal::get_texture(DecalTexture p_type) const {
ERR_FAIL_INDEX_V(p_type, TEXTURE_MAX, Ref<Texture2D>());
return textures[p_type];
@@ -56,6 +57,7 @@ void Decal::set_emission_energy(float p_energy) {
emission_energy = p_energy;
RS::get_singleton()->decal_set_emission_energy(decal, emission_energy);
}
+
float Decal::get_emission_energy() const {
return emission_energy;
}
@@ -64,6 +66,7 @@ void Decal::set_albedo_mix(float p_mix) {
albedo_mix = p_mix;
RS::get_singleton()->decal_set_albedo_mix(decal, albedo_mix);
}
+
float Decal::get_albedo_mix() const {
return albedo_mix;
}
@@ -72,6 +75,7 @@ void Decal::set_upper_fade(float p_fade) {
upper_fade = p_fade;
RS::get_singleton()->decal_set_fade(decal, upper_fade, lower_fade);
}
+
float Decal::get_upper_fade() const {
return upper_fade;
}
@@ -80,6 +84,7 @@ void Decal::set_lower_fade(float p_fade) {
lower_fade = p_fade;
RS::get_singleton()->decal_set_fade(decal, upper_fade, lower_fade);
}
+
float Decal::get_lower_fade() const {
return lower_fade;
}
@@ -88,6 +93,7 @@ void Decal::set_normal_fade(float p_fade) {
normal_fade = p_fade;
RS::get_singleton()->decal_set_normal_fade(decal, normal_fade);
}
+
float Decal::get_normal_fade() const {
return normal_fade;
}
@@ -105,6 +111,7 @@ void Decal::set_enable_distance_fade(bool p_enable) {
distance_fade_enabled = p_enable;
RS::get_singleton()->decal_set_distance_fade(decal, distance_fade_enabled, distance_fade_begin, distance_fade_length);
}
+
bool Decal::is_distance_fade_enabled() const {
return distance_fade_enabled;
}
@@ -113,6 +120,7 @@ void Decal::set_distance_fade_begin(float p_distance) {
distance_fade_begin = p_distance;
RS::get_singleton()->decal_set_distance_fade(decal, distance_fade_enabled, distance_fade_begin, distance_fade_length);
}
+
float Decal::get_distance_fade_begin() const {
return distance_fade_begin;
}
@@ -121,6 +129,7 @@ void Decal::set_distance_fade_length(float p_length) {
distance_fade_length = p_length;
RS::get_singleton()->decal_set_distance_fade(decal, distance_fade_enabled, distance_fade_begin, distance_fade_length);
}
+
float Decal::get_distance_fade_length() const {
return distance_fade_length;
}
@@ -129,24 +138,23 @@ void Decal::set_cull_mask(uint32_t p_layers) {
cull_mask = p_layers;
RS::get_singleton()->decal_set_cull_mask(decal, cull_mask);
}
+
uint32_t Decal::get_cull_mask() const {
return cull_mask;
}
AABB Decal::get_aabb() const {
-
AABB aabb;
aabb.position = -extents;
aabb.size = extents * 2.0;
return aabb;
}
-Vector<Face3> Decal::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> Decal::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void Decal::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &Decal::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &Decal::get_extents);
@@ -212,7 +220,6 @@ void Decal::_bind_methods() {
}
Decal::Decal() {
-
extents = Vector3(1, 1, 1);
emission_energy = 1.0;
modulate = Color(1, 1, 1, 1);
@@ -230,6 +237,5 @@ Decal::Decal() {
}
Decal::~Decal() {
-
RS::get_singleton()->free(decal);
}
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 65a330ddc0..1b6f9b45b9 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -101,15 +101,19 @@ void GIProbeData::allocate(const Transform &p_to_cell_xform, const AABB &p_aabb,
AABB GIProbeData::get_bounds() const {
return bounds;
}
+
Vector3 GIProbeData::get_octree_size() const {
return octree_size;
}
+
Vector<uint8_t> GIProbeData::get_octree_cells() const {
return RS::get_singleton()->gi_probe_get_octree_cells(probe);
}
+
Vector<uint8_t> GIProbeData::get_data_cells() const {
return RS::get_singleton()->gi_probe_get_data_cells(probe);
}
+
Vector<uint8_t> GIProbeData::get_distance_field() const {
return RS::get_singleton()->gi_probe_get_distance_field(probe);
}
@@ -117,6 +121,7 @@ Vector<uint8_t> GIProbeData::get_distance_field() const {
Vector<int> GIProbeData::get_level_counts() const {
return RS::get_singleton()->gi_probe_get_level_counts(probe);
}
+
Transform GIProbeData::get_to_cell_xform() const {
return to_cell_xform;
}
@@ -212,7 +217,6 @@ bool GIProbeData::is_using_two_bounces() const {
}
RID GIProbeData::get_rid() const {
-
return probe;
}
@@ -283,7 +287,6 @@ void GIProbeData::_bind_methods() {
}
GIProbeData::GIProbeData() {
-
ao = 0.0;
ao_size = 0.5;
dynamic_range = 4;
@@ -299,7 +302,6 @@ GIProbeData::GIProbeData() {
}
GIProbeData::~GIProbeData() {
-
RS::get_singleton()->free(probe);
}
@@ -307,7 +309,6 @@ GIProbeData::~GIProbeData() {
//////////////////////
void GIProbe::set_probe_data(const Ref<GIProbeData> &p_data) {
-
if (p_data.is_valid()) {
RS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid());
} else {
@@ -318,41 +319,34 @@ void GIProbe::set_probe_data(const Ref<GIProbeData> &p_data) {
}
Ref<GIProbeData> GIProbe::get_probe_data() const {
-
return probe_data;
}
void GIProbe::set_subdiv(Subdiv p_subdiv) {
-
ERR_FAIL_INDEX(p_subdiv, SUBDIV_MAX);
subdiv = p_subdiv;
update_gizmo();
}
GIProbe::Subdiv GIProbe::get_subdiv() const {
-
return subdiv;
}
void GIProbe::set_extents(const Vector3 &p_extents) {
-
extents = p_extents;
update_gizmo();
_change_notify("extents");
}
Vector3 GIProbe::get_extents() const {
-
return extents;
}
void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
-
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_at_node);
if (mi && mi->get_gi_mode() == GeometryInstance3D::GI_MODE_BAKED && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
-
AABB aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform();
@@ -372,16 +366,14 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
Node3D *s = Object::cast_to<Node3D>(p_at_node);
if (s) {
-
if (s->is_visible_in_tree()) {
-
Array meshes = p_at_node->call("get_meshes");
for (int i = 0; i < meshes.size(); i += 2) {
-
Transform mxf = meshes[i];
Ref<Mesh> mesh = meshes[i + 1];
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
continue;
+ }
AABB aabb = mesh->get_aabb();
@@ -416,9 +408,9 @@ Vector3i GIProbe::get_estimated_cell_size() const {
axis_cell_size[longest_axis] = 1 << cell_subdiv;
for (int i = 0; i < 3; i++) {
-
- if (i == longest_axis)
+ if (i == longest_axis) {
continue;
+ }
axis_cell_size[i] = axis_cell_size[longest_axis];
float axis_size = bounds.size[longest_axis];
@@ -432,8 +424,8 @@ Vector3i GIProbe::get_estimated_cell_size() const {
return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]);
}
-void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
+void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 };
Voxelizer baker;
@@ -451,7 +443,6 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
int pmc = 0;
for (List<PlotMesh>::Element *E = mesh_list.front(); E; E = E->next()) {
-
if (bake_step_function) {
bake_step_function(pmc, RTR("Plotting Meshes") + " " + itos(pmc) + "/" + itos(mesh_list.size()));
}
@@ -483,11 +474,11 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
#endif
} else {
-
Ref<GIProbeData> probe_data = get_probe_data();
- if (probe_data.is_null())
+ if (probe_data.is_null()) {
probe_data.instance();
+ }
if (bake_step_function) {
bake_step_function(pmc++, RTR("Generating Distance Field"));
@@ -511,22 +502,18 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
}
void GIProbe::_debug_bake() {
-
bake(nullptr, true);
}
AABB GIProbe::get_aabb() const {
-
return AABB(-extents, extents * 2);
}
Vector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
-
return Vector<Face3>();
}
String GIProbe::get_configuration_warning() const {
-
if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GIProbes are not supported by the GLES2 video driver.\nUse a BakedLightmap instead.");
}
@@ -534,7 +521,6 @@ String GIProbe::get_configuration_warning() const {
}
void GIProbe::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_probe_data", "data"), &GIProbe::set_probe_data);
ClassDB::bind_method(D_METHOD("get_probe_data"), &GIProbe::get_probe_data);
@@ -560,7 +546,6 @@ void GIProbe::_bind_methods() {
}
GIProbe::GIProbe() {
-
subdiv = SUBDIV_128;
extents = Vector3(10, 10, 10);
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index 28b533e82d..b7abfbd01b 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -35,7 +35,6 @@
#include "scene/3d/visual_instance_3d.h"
class GIProbeData : public Resource {
-
GDCLASS(GIProbeData, Resource);
RID probe;
diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp
index 01886a730f..c4480e3ed2 100644
--- a/scene/3d/gpu_particles_3d.cpp
+++ b/scene/3d/gpu_particles_3d.cpp
@@ -36,16 +36,14 @@
#include "servers/rendering_server.h"
AABB GPUParticles3D::get_aabb() const {
-
return AABB();
}
-Vector<Face3> GPUParticles3D::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> GPUParticles3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void GPUParticles3D::set_emitting(bool p_emitting) {
-
RS::get_singleton()->particles_set_emitting(particles, p_emitting);
if (p_emitting && one_shot) {
@@ -56,157 +54,149 @@ void GPUParticles3D::set_emitting(bool p_emitting) {
}
void GPUParticles3D::set_amount(int p_amount) {
-
ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1.");
amount = p_amount;
RS::get_singleton()->particles_set_amount(particles, amount);
}
-void GPUParticles3D::set_lifetime(float p_lifetime) {
+void GPUParticles3D::set_lifetime(float p_lifetime) {
ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0.");
lifetime = p_lifetime;
RS::get_singleton()->particles_set_lifetime(particles, lifetime);
}
void GPUParticles3D::set_one_shot(bool p_one_shot) {
-
one_shot = p_one_shot;
RS::get_singleton()->particles_set_one_shot(particles, one_shot);
if (is_emitting()) {
-
set_process_internal(true);
- if (!one_shot)
+ if (!one_shot) {
RenderingServer::get_singleton()->particles_restart(particles);
+ }
}
- if (!one_shot)
+ if (!one_shot) {
set_process_internal(false);
+ }
}
void GPUParticles3D::set_pre_process_time(float p_time) {
-
pre_process_time = p_time;
RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time);
}
-void GPUParticles3D::set_explosiveness_ratio(float p_ratio) {
+void GPUParticles3D::set_explosiveness_ratio(float p_ratio) {
explosiveness_ratio = p_ratio;
RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio);
}
-void GPUParticles3D::set_randomness_ratio(float p_ratio) {
+void GPUParticles3D::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
-void GPUParticles3D::set_visibility_aabb(const AABB &p_aabb) {
+void GPUParticles3D::set_visibility_aabb(const AABB &p_aabb) {
visibility_aabb = p_aabb;
RS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb);
update_gizmo();
_change_notify("visibility_aabb");
}
-void GPUParticles3D::set_use_local_coordinates(bool p_enable) {
+void GPUParticles3D::set_use_local_coordinates(bool p_enable) {
local_coords = p_enable;
RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords);
}
-void GPUParticles3D::set_process_material(const Ref<Material> &p_material) {
+void GPUParticles3D::set_process_material(const Ref<Material> &p_material) {
process_material = p_material;
RID material_rid;
- if (process_material.is_valid())
+ if (process_material.is_valid()) {
material_rid = process_material->get_rid();
+ }
RS::get_singleton()->particles_set_process_material(particles, material_rid);
update_configuration_warning();
}
void GPUParticles3D::set_speed_scale(float p_scale) {
-
speed_scale = p_scale;
RS::get_singleton()->particles_set_speed_scale(particles, p_scale);
}
bool GPUParticles3D::is_emitting() const {
-
return RS::get_singleton()->particles_get_emitting(particles);
}
-int GPUParticles3D::get_amount() const {
+int GPUParticles3D::get_amount() const {
return amount;
}
-float GPUParticles3D::get_lifetime() const {
+float GPUParticles3D::get_lifetime() const {
return lifetime;
}
-bool GPUParticles3D::get_one_shot() const {
+bool GPUParticles3D::get_one_shot() const {
return one_shot;
}
float GPUParticles3D::get_pre_process_time() const {
-
return pre_process_time;
}
-float GPUParticles3D::get_explosiveness_ratio() const {
+float GPUParticles3D::get_explosiveness_ratio() const {
return explosiveness_ratio;
}
-float GPUParticles3D::get_randomness_ratio() const {
+float GPUParticles3D::get_randomness_ratio() const {
return randomness_ratio;
}
-AABB GPUParticles3D::get_visibility_aabb() const {
+AABB GPUParticles3D::get_visibility_aabb() const {
return visibility_aabb;
}
-bool GPUParticles3D::get_use_local_coordinates() const {
+bool GPUParticles3D::get_use_local_coordinates() const {
return local_coords;
}
-Ref<Material> GPUParticles3D::get_process_material() const {
+Ref<Material> GPUParticles3D::get_process_material() const {
return process_material;
}
float GPUParticles3D::get_speed_scale() const {
-
return speed_scale;
}
void GPUParticles3D::set_draw_order(DrawOrder p_order) {
-
draw_order = p_order;
RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order));
}
GPUParticles3D::DrawOrder GPUParticles3D::get_draw_order() const {
-
return draw_order;
}
void GPUParticles3D::set_draw_passes(int p_count) {
-
ERR_FAIL_COND(p_count < 1);
draw_passes.resize(p_count);
RS::get_singleton()->particles_set_draw_passes(particles, p_count);
_change_notify();
}
-int GPUParticles3D::get_draw_passes() const {
+int GPUParticles3D::get_draw_passes() const {
return draw_passes.size();
}
void GPUParticles3D::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) {
-
ERR_FAIL_INDEX(p_pass, draw_passes.size());
draw_passes.write[p_pass] = p_mesh;
RID mesh_rid;
- if (p_mesh.is_valid())
+ if (p_mesh.is_valid()) {
mesh_rid = p_mesh->get_rid();
+ }
RS::get_singleton()->particles_set_draw_pass_mesh(particles, p_pass, mesh_rid);
@@ -214,7 +204,6 @@ void GPUParticles3D::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) {
}
Ref<Mesh> GPUParticles3D::get_draw_pass_mesh(int p_pass) const {
-
ERR_FAIL_INDEX_V(p_pass, draw_passes.size(), Ref<Mesh>());
return draw_passes[p_pass];
@@ -239,7 +228,6 @@ bool GPUParticles3D::get_fractional_delta() const {
}
String GPUParticles3D::get_configuration_warning() const {
-
if (RenderingServer::get_singleton()->is_low_end()) {
return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles3D node instead. You can use the \"Convert to CPUParticles3D\" option for this purpose.");
}
@@ -257,8 +245,9 @@ String GPUParticles3D::get_configuration_warning() const {
StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(draw_passes[i]->surface_get_material(j).ptr());
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES);
}
- if (anim_material_found)
+ if (anim_material_found) {
break;
+ }
}
}
@@ -267,22 +256,25 @@ String GPUParticles3D::get_configuration_warning() const {
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES);
if (!meshes_found) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Nothing is visible because meshes have not been assigned to draw passes.");
}
if (process_material.is_null()) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("A material to process the particles is not assigned, so no behavior is imprinted.");
} else {
const ParticlesMaterial *process = Object::cast_to<ParticlesMaterial>(process_material.ptr());
if (!anim_material_found && process &&
(process->get_param(ParticlesMaterial::PARAM_ANIM_SPEED) != 0.0 || process->get_param(ParticlesMaterial::PARAM_ANIM_OFFSET) != 0.0 ||
process->get_param_texture(ParticlesMaterial::PARAM_ANIM_SPEED).is_valid() || process->get_param_texture(ParticlesMaterial::PARAM_ANIM_OFFSET).is_valid())) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Particles animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\".");
}
}
@@ -291,18 +283,15 @@ String GPUParticles3D::get_configuration_warning() const {
}
void GPUParticles3D::restart() {
-
RenderingServer::get_singleton()->particles_restart(particles);
RenderingServer::get_singleton()->particles_set_emitting(particles, true);
}
AABB GPUParticles3D::capture_aabb() const {
-
return RS::get_singleton()->particles_get_current_aabb(particles);
}
void GPUParticles3D::_validate_property(PropertyInfo &property) const {
-
if (property.name.begins_with("draw_pass_")) {
int index = property.name.get_slicec('_', 2).to_int() - 1;
if (index >= draw_passes.size()) {
@@ -313,12 +302,10 @@ void GPUParticles3D::_validate_property(PropertyInfo &property) const {
}
void GPUParticles3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
if (can_process()) {
RS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
} else {
-
RS::get_singleton()->particles_set_speed_scale(particles, 0);
}
}
@@ -326,7 +313,6 @@ void GPUParticles3D::_notification(int p_what) {
// Use internal process when emitting and one_shot are on so that when
// the shot ends the editor can properly update
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
-
if (one_shot && !is_emitting()) {
_change_notify();
set_process_internal(false);
@@ -342,7 +328,6 @@ void GPUParticles3D::_notification(int p_what) {
}
void GPUParticles3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &GPUParticles3D::set_emitting);
ClassDB::bind_method(D_METHOD("set_amount", "amount"), &GPUParticles3D::set_amount);
ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &GPUParticles3D::set_lifetime);
@@ -404,7 +389,6 @@ void GPUParticles3D::_bind_methods() {
ADD_GROUP("Draw Passes", "draw_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_passes", PROPERTY_HINT_RANGE, "0," + itos(MAX_DRAW_PASSES) + ",1"), "set_draw_passes", "get_draw_passes");
for (int i = 0; i < MAX_DRAW_PASSES; i++) {
-
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "draw_pass_" + itos(i + 1), PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_draw_pass_mesh", "get_draw_pass_mesh", i);
}
@@ -416,7 +400,6 @@ void GPUParticles3D::_bind_methods() {
}
GPUParticles3D::GPUParticles3D() {
-
particles = RS::get_singleton()->particles_create();
set_base(particles);
one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
@@ -437,6 +420,5 @@ GPUParticles3D::GPUParticles3D() {
}
GPUParticles3D::~GPUParticles3D() {
-
RS::get_singleton()->free(particles);
}
diff --git a/scene/3d/immediate_geometry_3d.cpp b/scene/3d/immediate_geometry_3d.cpp
index 63d4b1ac84..7ccfd527a1 100644
--- a/scene/3d/immediate_geometry_3d.cpp
+++ b/scene/3d/immediate_geometry_3d.cpp
@@ -31,39 +31,33 @@
#include "immediate_geometry_3d.h"
void ImmediateGeometry3D::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) {
-
RS::get_singleton()->immediate_begin(im, (RS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID());
- if (p_texture.is_valid())
+ if (p_texture.is_valid()) {
cached_textures.push_back(p_texture);
+ }
}
void ImmediateGeometry3D::set_normal(const Vector3 &p_normal) {
-
RS::get_singleton()->immediate_normal(im, p_normal);
}
void ImmediateGeometry3D::set_tangent(const Plane &p_tangent) {
-
RS::get_singleton()->immediate_tangent(im, p_tangent);
}
void ImmediateGeometry3D::set_color(const Color &p_color) {
-
RS::get_singleton()->immediate_color(im, p_color);
}
void ImmediateGeometry3D::set_uv(const Vector2 &p_uv) {
-
RS::get_singleton()->immediate_uv(im, p_uv);
}
void ImmediateGeometry3D::set_uv2(const Vector2 &p_uv2) {
-
RS::get_singleton()->immediate_uv2(im, p_uv2);
}
void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) {
-
RS::get_singleton()->immediate_vertex(im, p_vertex);
if (empty) {
aabb.position = p_vertex;
@@ -75,28 +69,24 @@ void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) {
}
void ImmediateGeometry3D::end() {
-
RS::get_singleton()->immediate_end(im);
}
void ImmediateGeometry3D::clear() {
-
RS::get_singleton()->immediate_clear(im);
empty = true;
cached_textures.clear();
}
AABB ImmediateGeometry3D::get_aabb() const {
-
return aabb;
}
-Vector<Face3> ImmediateGeometry3D::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> ImmediateGeometry3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
-
for (int i = 1; i <= p_lats; i++) {
double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
double z0 = Math::sin(lat0);
@@ -107,7 +97,6 @@ void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, boo
double zr1 = Math::cos(lat1);
for (int j = p_lons; j >= 1; j--) {
-
double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
@@ -143,7 +132,6 @@ void ImmediateGeometry3D::add_sphere(int p_lats, int p_lons, float p_radius, boo
}
void ImmediateGeometry3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry3D::begin, DEFVAL(Ref<Texture2D>()));
ClassDB::bind_method(D_METHOD("set_normal", "normal"), &ImmediateGeometry3D::set_normal);
ClassDB::bind_method(D_METHOD("set_tangent", "tangent"), &ImmediateGeometry3D::set_tangent);
@@ -157,13 +145,11 @@ void ImmediateGeometry3D::_bind_methods() {
}
ImmediateGeometry3D::ImmediateGeometry3D() {
-
im = RenderingServer::get_singleton()->immediate_create();
set_base(im);
empty = true;
}
ImmediateGeometry3D::~ImmediateGeometry3D() {
-
RenderingServer::get_singleton()->free(im);
}
diff --git a/scene/3d/immediate_geometry_3d.h b/scene/3d/immediate_geometry_3d.h
index 6e15450a5b..7c9e8851a2 100644
--- a/scene/3d/immediate_geometry_3d.h
+++ b/scene/3d/immediate_geometry_3d.h
@@ -35,7 +35,6 @@
#include "scene/resources/mesh.h"
class ImmediateGeometry3D : public GeometryInstance3D {
-
GDCLASS(ImmediateGeometry3D, GeometryInstance3D);
RID im;
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index 0aa0f7e5ac..ef24676d69 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -35,12 +35,10 @@
#include "scene/resources/surface_tool.h"
bool Light3D::_can_gizmo_scale() const {
-
return false;
}
void Light3D::set_param(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
param[p_param] = p_value;
@@ -60,13 +58,11 @@ void Light3D::set_param(Param p_param, float p_value) {
}
float Light3D::get_param(Param p_param) const {
-
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return param[p_param];
}
void Light3D::set_shadow(bool p_enable) {
-
shadow = p_enable;
RS::get_singleton()->light_set_shadow(light, p_enable);
@@ -74,51 +70,46 @@ void Light3D::set_shadow(bool p_enable) {
update_configuration_warning();
}
}
-bool Light3D::has_shadow() const {
+bool Light3D::has_shadow() const {
return shadow;
}
void Light3D::set_negative(bool p_enable) {
-
negative = p_enable;
RS::get_singleton()->light_set_negative(light, p_enable);
}
-bool Light3D::is_negative() const {
+bool Light3D::is_negative() const {
return negative;
}
void Light3D::set_cull_mask(uint32_t p_cull_mask) {
-
cull_mask = p_cull_mask;
RS::get_singleton()->light_set_cull_mask(light, p_cull_mask);
}
-uint32_t Light3D::get_cull_mask() const {
+uint32_t Light3D::get_cull_mask() const {
return cull_mask;
}
void Light3D::set_color(const Color &p_color) {
-
color = p_color;
RS::get_singleton()->light_set_color(light, p_color);
// The gizmo color depends on the light color, so update it.
update_gizmo();
}
-Color Light3D::get_color() const {
+Color Light3D::get_color() const {
return color;
}
void Light3D::set_shadow_color(const Color &p_shadow_color) {
-
shadow_color = p_shadow_color;
RS::get_singleton()->light_set_shadow_color(light, p_shadow_color);
}
Color Light3D::get_shadow_color() const {
-
return shadow_color;
}
@@ -128,22 +119,17 @@ void Light3D::set_shadow_reverse_cull_face(bool p_enable) {
}
bool Light3D::get_shadow_reverse_cull_face() const {
-
return reverse_cull;
}
AABB Light3D::get_aabb() const {
-
if (type == RenderingServer::LIGHT_DIRECTIONAL) {
-
return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
} else if (type == RenderingServer::LIGHT_OMNI) {
-
return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
} else if (type == RenderingServer::LIGHT_SPOT) {
-
float len = param[PARAM_RANGE];
float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len;
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
@@ -153,7 +139,6 @@ AABB Light3D::get_aabb() const {
}
Vector<Face3> Light3D::get_faces(uint32_t p_usage_flags) const {
-
return Vector<Face3>();
}
@@ -167,7 +152,6 @@ Light3D::BakeMode Light3D::get_bake_mode() const {
}
void Light3D::set_projector(const Ref<Texture2D> &p_texture) {
-
projector = p_texture;
RID tex_id = projector.is_valid() ? projector->get_rid() : RID();
RS::get_singleton()->light_set_projector(light, tex_id);
@@ -179,9 +163,9 @@ Ref<Texture2D> Light3D::get_projector() const {
}
void Light3D::_update_visibility() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool editor_ok = true;
@@ -205,9 +189,7 @@ void Light3D::_update_visibility() {
}
void Light3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
_update_visibility();
}
@@ -217,18 +199,15 @@ void Light3D::_notification(int p_what) {
}
void Light3D::set_editor_only(bool p_editor_only) {
-
editor_only = p_editor_only;
_update_visibility();
}
bool Light3D::is_editor_only() const {
-
return editor_only;
}
void Light3D::_validate_property(PropertyInfo &property) const {
-
if (get_light_type() == RS::LIGHT_DIRECTIONAL && property.name == "light_size") {
property.usage = 0;
}
@@ -243,7 +222,6 @@ void Light3D::_validate_property(PropertyInfo &property) const {
}
void Light3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_editor_only", "editor_only"), &Light3D::set_editor_only);
ClassDB::bind_method(D_METHOD("is_editor_only"), &Light3D::is_editor_only);
@@ -323,7 +301,6 @@ void Light3D::_bind_methods() {
}
Light3D::Light3D(RenderingServer::LightType p_type) {
-
type = p_type;
switch (p_type) {
case RS::LIGHT_DIRECTIONAL:
@@ -373,28 +350,26 @@ Light3D::Light3D(RenderingServer::LightType p_type) {
}
Light3D::Light3D() {
-
type = RenderingServer::LIGHT_DIRECTIONAL;
ERR_PRINT("Light3D should not be instanced directly; use the DirectionalLight3D, OmniLight3D or SpotLight3D subtypes instead.");
}
Light3D::~Light3D() {
-
RS::get_singleton()->instance_set_base(get_instance(), RID());
- if (light.is_valid())
+ if (light.is_valid()) {
RenderingServer::get_singleton()->free(light);
+ }
}
+
/////////////////////////////////////////
void DirectionalLight3D::set_shadow_mode(ShadowMode p_mode) {
-
shadow_mode = p_mode;
RS::get_singleton()->light_directional_set_shadow_mode(light, RS::LightDirectionalShadowMode(p_mode));
}
DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const {
-
return shadow_mode;
}
@@ -404,23 +379,19 @@ void DirectionalLight3D::set_shadow_depth_range(ShadowDepthRange p_range) {
}
DirectionalLight3D::ShadowDepthRange DirectionalLight3D::get_shadow_depth_range() const {
-
return shadow_depth_range;
}
void DirectionalLight3D::set_blend_splits(bool p_enable) {
-
blend_splits = p_enable;
RS::get_singleton()->light_directional_set_blend_splits(light, p_enable);
}
bool DirectionalLight3D::is_blend_splits_enabled() const {
-
return blend_splits;
}
void DirectionalLight3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight3D::set_shadow_mode);
ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight3D::get_shadow_mode);
@@ -431,7 +402,7 @@ void DirectionalLight3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight3D::is_blend_splits_enabled);
ADD_GROUP("Directional Shadow", "directional_shadow_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_mode", PROPERTY_HINT_ENUM, "Orthogonal,PSSM 2 Splits,PSSM 4 Splits"), "set_shadow_mode", "get_shadow_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_mode", PROPERTY_HINT_ENUM, "Orthogonal (Fast),PSSM 2 Splits (Average),PSSM 4 Splits (Slow)"), "set_shadow_mode", "get_shadow_mode");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_1", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_1_OFFSET);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_2", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_2_OFFSET);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET);
@@ -451,7 +422,6 @@ void DirectionalLight3D::_bind_methods() {
DirectionalLight3D::DirectionalLight3D() :
Light3D(RenderingServer::LIGHT_DIRECTIONAL) {
-
set_param(PARAM_SHADOW_MAX_DISTANCE, 100);
set_param(PARAM_SHADOW_FADE_START, 0.8);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
@@ -461,13 +431,11 @@ DirectionalLight3D::DirectionalLight3D() :
}
void OmniLight3D::set_shadow_mode(ShadowMode p_mode) {
-
shadow_mode = p_mode;
RS::get_singleton()->light_omni_set_shadow_mode(light, RS::LightOmniShadowMode(p_mode));
}
OmniLight3D::ShadowMode OmniLight3D::get_shadow_mode() const {
-
return shadow_mode;
}
@@ -485,7 +453,6 @@ String OmniLight3D::get_configuration_warning() const {
}
void OmniLight3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &OmniLight3D::set_shadow_mode);
ClassDB::bind_method(D_METHOD("get_shadow_mode"), &OmniLight3D::get_shadow_mode);
@@ -500,7 +467,6 @@ void OmniLight3D::_bind_methods() {
OmniLight3D::OmniLight3D() :
Light3D(RenderingServer::LIGHT_OMNI) {
-
set_shadow_mode(SHADOW_CUBE);
}
@@ -526,7 +492,6 @@ String SpotLight3D::get_configuration_warning() const {
}
void SpotLight3D::_bind_methods() {
-
ADD_GROUP("Spot", "spot_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "spot_range", PROPERTY_HINT_EXP_RANGE, "0,4096,0.1,or_greater"), "set_param", "get_param", PARAM_RANGE);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "spot_attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), "set_param", "get_param", PARAM_ATTENUATION);
diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h
index 6e78217342..f16773f6ae 100644
--- a/scene/3d/light_3d.h
+++ b/scene/3d/light_3d.h
@@ -36,7 +36,6 @@
#include "servers/rendering_server.h"
class Light3D : public VisualInstance3D {
-
GDCLASS(Light3D, VisualInstance3D);
OBJ_CATEGORY("3D Light Nodes");
@@ -140,7 +139,6 @@ VARIANT_ENUM_CAST(Light3D::Param);
VARIANT_ENUM_CAST(Light3D::BakeMode);
class DirectionalLight3D : public Light3D {
-
GDCLASS(DirectionalLight3D, Light3D);
public:
@@ -180,7 +178,6 @@ VARIANT_ENUM_CAST(DirectionalLight3D::ShadowMode)
VARIANT_ENUM_CAST(DirectionalLight3D::ShadowDepthRange)
class OmniLight3D : public Light3D {
-
GDCLASS(OmniLight3D, Light3D);
public:
@@ -208,7 +205,6 @@ public:
VARIANT_ENUM_CAST(OmniLight3D::ShadowMode)
class SpotLight3D : public Light3D {
-
GDCLASS(SpotLight3D, Light3D);
protected:
diff --git a/scene/3d/lightmap_probe.cpp b/scene/3d/lightmap_probe.cpp
index 2da81337f0..ee21934b80 100644
--- a/scene/3d/lightmap_probe.cpp
+++ b/scene/3d/lightmap_probe.cpp
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* lightmap_probe.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 "lightmap_probe.h"
LightmapProbe::LightmapProbe() {
diff --git a/scene/3d/lightmap_probe.h b/scene/3d/lightmap_probe.h
index 65bc6914f4..c4bd33556f 100644
--- a/scene/3d/lightmap_probe.h
+++ b/scene/3d/lightmap_probe.h
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* lightmap_probe.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 LIGHTMAP_PROBE_H
#define LIGHTMAP_PROBE_H
diff --git a/scene/3d/lightmapper.cpp b/scene/3d/lightmapper.cpp
index 53ebd5ee2e..26faf5154c 100644
--- a/scene/3d/lightmapper.cpp
+++ b/scene/3d/lightmapper.cpp
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* lightmapper.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.h"
LightmapDenoiser *(*LightmapDenoiser::create_function)() = nullptr;
diff --git a/scene/3d/lightmapper.h b/scene/3d/lightmapper.h
index 7c052a30a0..ccf9bde279 100644
--- a/scene/3d/lightmapper.h
+++ b/scene/3d/lightmapper.h
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* lightmapper.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_H
#define LIGHTMAPPER_H
diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp
index 426e34ea80..0a5b9ad09f 100644
--- a/scene/3d/listener_3d.cpp
+++ b/scene/3d/listener_3d.cpp
@@ -36,63 +36,59 @@ void Listener3D::_update_audio_listener_state() {
}
void Listener3D::_request_listener_update() {
-
_update_listener();
}
bool Listener3D::_set(const StringName &p_name, const Variant &p_value) {
-
if (p_name == "current") {
if (p_value.operator bool()) {
make_current();
} else {
clear_current();
}
- } else
+ } else {
return false;
+ }
return true;
}
-bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const {
+bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "current") {
if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
r_ret = current;
} else {
r_ret = is_current();
}
- } else
+ } else {
return false;
+ }
return true;
}
void Listener3D::_get_property_list(List<PropertyInfo> *p_list) const {
-
p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
}
void Listener3D::_update_listener() {
-
if (is_inside_tree() && is_current()) {
get_viewport()->_listener_transform_changed_notify();
}
}
void Listener3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_WORLD: {
bool first_listener = get_viewport()->_listener_add(this);
- if (!get_tree()->is_node_being_edited(this) && (current || first_listener))
+ if (!get_tree()->is_node_being_edited(this) && (current || first_listener)) {
make_current();
+ }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
_request_listener_update();
} break;
case NOTIFICATION_EXIT_WORLD: {
-
if (!get_tree()->is_node_being_edited(this)) {
if (is_current()) {
clear_current();
@@ -110,25 +106,24 @@ void Listener3D::_notification(int p_what) {
}
Transform Listener3D::get_listener_transform() const {
-
return get_global_transform().orthonormalized();
}
void Listener3D::make_current() {
-
current = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
get_viewport()->_listener_set(this);
}
void Listener3D::clear_current() {
-
current = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (get_viewport()->get_listener() == this) {
get_viewport()->_listener_set(nullptr);
@@ -137,18 +132,16 @@ void Listener3D::clear_current() {
}
bool Listener3D::is_current() const {
-
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
-
return get_viewport()->get_listener() == this;
- } else
+ } else {
return current;
+ }
return false;
}
bool Listener3D::_can_gizmo_scale() const {
-
return false;
}
@@ -159,7 +152,6 @@ RES Listener3D::_get_gizmo_geometry() const {
}
void Listener3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("make_current"), &Listener3D::make_current);
ClassDB::bind_method(D_METHOD("clear_current"), &Listener3D::clear_current);
ClassDB::bind_method(D_METHOD("is_current"), &Listener3D::is_current);
@@ -167,7 +159,6 @@ void Listener3D::_bind_methods() {
}
Listener3D::Listener3D() {
-
current = false;
force_change = false;
set_notify_transform(true);
diff --git a/scene/3d/listener_3d.h b/scene/3d/listener_3d.h
index 3383d6725e..4b6923d6e8 100644
--- a/scene/3d/listener_3d.h
+++ b/scene/3d/listener_3d.h
@@ -35,7 +35,6 @@
#include "scene/main/window.h"
class Listener3D : public Node3D {
-
GDCLASS(Listener3D, Node3D);
private:
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp
index cdc8db8aea..13f40aed4f 100644
--- a/scene/3d/mesh_instance_3d.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -37,12 +37,12 @@
#include "skeleton_3d.h"
bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
-
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
//add to it that it's probably found on first call to _set anyway.
- if (!get_instance().is_valid())
+ if (!get_instance().is_valid()) {
return false;
+ }
Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
@@ -53,8 +53,9 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
if (p_name.operator String().begins_with("material/")) {
int idx = p_name.operator String().get_slicec('/', 1).to_int();
- if (idx >= materials.size() || idx < 0)
+ if (idx >= materials.size() || idx < 0) {
return false;
+ }
set_surface_material(idx, p_value);
return true;
@@ -64,9 +65,9 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
}
bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (!get_instance().is_valid())
+ if (!get_instance().is_valid()) {
return false;
+ }
const Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
@@ -76,8 +77,9 @@ bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name.operator String().begins_with("material/")) {
int idx = p_name.operator String().get_slicec('/', 1).to_int();
- if (idx >= materials.size() || idx < 0)
+ if (idx >= materials.size() || idx < 0) {
return false;
+ }
r_ret = materials[idx];
return true;
}
@@ -85,10 +87,8 @@ bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
}
void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
-
List<String> ls;
for (const Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.front(); E; E = E->next()) {
-
ls.push_back(E->key());
}
@@ -106,9 +106,9 @@ void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
}
void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
-
- if (mesh == p_mesh)
+ if (mesh == p_mesh) {
return;
+ }
if (mesh.is_valid()) {
mesh->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed));
@@ -119,9 +119,7 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
blend_shape_tracks.clear();
if (mesh.is_valid()) {
-
for (int i = 0; i < mesh->get_blend_shape_count(); i++) {
-
BlendShapeTrack mt;
mt.idx = i;
mt.value = 0;
@@ -133,7 +131,6 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
set_base(mesh->get_rid());
} else {
-
set_base(RID());
}
@@ -141,13 +138,12 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
_change_notify();
}
-Ref<Mesh> MeshInstance3D::get_mesh() const {
+Ref<Mesh> MeshInstance3D::get_mesh() const {
return mesh;
}
void MeshInstance3D::_resolve_skeleton_path() {
-
Ref<SkinReference> new_skin_reference;
if (!skeleton_path.is_empty()) {
@@ -174,8 +170,9 @@ void MeshInstance3D::_resolve_skeleton_path() {
void MeshInstance3D::set_skin(const Ref<Skin> &p_skin) {
skin_internal = p_skin;
skin = p_skin;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_resolve_skeleton_path();
}
@@ -184,10 +181,10 @@ Ref<Skin> MeshInstance3D::get_skin() const {
}
void MeshInstance3D::set_skeleton_path(const NodePath &p_skeleton) {
-
skeleton_path = p_skeleton;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_resolve_skeleton_path();
}
@@ -196,32 +193,34 @@ NodePath MeshInstance3D::get_skeleton_path() {
}
AABB MeshInstance3D::get_aabb() const {
-
- if (!mesh.is_null())
+ if (!mesh.is_null()) {
return mesh->get_aabb();
+ }
return AABB();
}
Vector<Face3> MeshInstance3D::get_faces(uint32_t p_usage_flags) const {
-
- if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING)))
+ if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING))) {
return Vector<Face3>();
+ }
- if (mesh.is_null())
+ if (mesh.is_null()) {
return Vector<Face3>();
+ }
return mesh->get_faces();
}
Node *MeshInstance3D::create_trimesh_collision_node() {
-
- if (mesh.is_null())
+ if (mesh.is_null()) {
return nullptr;
+ }
Ref<Shape3D> shape = mesh->create_trimesh_shape();
- if (shape.is_null())
+ if (shape.is_null()) {
return nullptr;
+ }
StaticBody3D *static_body = memnew(StaticBody3D);
CollisionShape3D *cshape = memnew(CollisionShape3D);
@@ -231,7 +230,6 @@ Node *MeshInstance3D::create_trimesh_collision_node() {
}
void MeshInstance3D::create_trimesh_collision() {
-
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_trimesh_collision_node());
ERR_FAIL_COND(!static_body);
static_body->set_name(String(get_name()) + "_col");
@@ -245,13 +243,14 @@ void MeshInstance3D::create_trimesh_collision() {
}
Node *MeshInstance3D::create_convex_collision_node() {
-
- if (mesh.is_null())
+ if (mesh.is_null()) {
return nullptr;
+ }
Ref<Shape3D> shape = mesh->create_convex_shape();
- if (shape.is_null())
+ if (shape.is_null()) {
return nullptr;
+ }
StaticBody3D *static_body = memnew(StaticBody3D);
CollisionShape3D *cshape = memnew(CollisionShape3D);
@@ -261,7 +260,6 @@ Node *MeshInstance3D::create_convex_collision_node() {
}
void MeshInstance3D::create_convex_collision() {
-
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(create_convex_collision_node());
ERR_FAIL_COND(!static_body);
static_body->set_name(String(get_name()) + "_col");
@@ -275,38 +273,34 @@ void MeshInstance3D::create_convex_collision() {
}
void MeshInstance3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
_resolve_skeleton_path();
}
}
int MeshInstance3D::get_surface_material_count() const {
-
return materials.size();
}
void MeshInstance3D::set_surface_material(int p_surface, const Ref<Material> &p_material) {
-
ERR_FAIL_INDEX(p_surface, materials.size());
materials.write[p_surface] = p_material;
- if (materials[p_surface].is_valid())
+ if (materials[p_surface].is_valid()) {
RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid());
- else
+ } else {
RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID());
+ }
}
Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const {
-
ERR_FAIL_INDEX_V(p_surface, materials.size(), Ref<Material>());
return materials[p_surface];
}
Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
-
Ref<Material> material_override = get_material_override();
if (material_override.is_valid()) {
return material_override;
@@ -326,28 +320,29 @@ Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
}
void MeshInstance3D::_mesh_changed() {
-
materials.resize(mesh->get_surface_count());
}
void MeshInstance3D::create_debug_tangents() {
-
Vector<Vector3> lines;
Vector<Color> colors;
Ref<Mesh> mesh = get_mesh();
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
return;
+ }
for (int i = 0; i < mesh->get_surface_count(); i++) {
Array arrays = mesh->surface_get_arrays(i);
Vector<Vector3> verts = arrays[Mesh::ARRAY_VERTEX];
Vector<Vector3> norms = arrays[Mesh::ARRAY_NORMAL];
- if (norms.size() == 0)
+ if (norms.size() == 0) {
continue;
+ }
Vector<float> tangents = arrays[Mesh::ARRAY_TANGENT];
- if (tangents.size() == 0)
+ if (tangents.size() == 0) {
continue;
+ }
for (int j = 0; j < verts.size(); j++) {
Vector3 v = verts[j];
@@ -373,7 +368,6 @@ void MeshInstance3D::create_debug_tangents() {
}
if (lines.size()) {
-
Ref<StandardMaterial3D> sm;
sm.instance();
@@ -397,16 +391,16 @@ void MeshInstance3D::create_debug_tangents() {
add_child(mi);
#ifdef TOOLS_ENABLED
- if (this == get_tree()->get_edited_scene_root())
+ if (this == get_tree()->get_edited_scene_root()) {
mi->set_owner(this);
- else
+ } else {
mi->set_owner(get_owner());
+ }
#endif
}
}
void MeshInstance3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance3D::set_mesh);
ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance3D::get_mesh);
ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance3D::set_skeleton_path);
diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h
index 914148f427..e29204f702 100644
--- a/scene/3d/mesh_instance_3d.h
+++ b/scene/3d/mesh_instance_3d.h
@@ -37,7 +37,6 @@
#include "scene/resources/skin.h"
class MeshInstance3D : public GeometryInstance3D {
-
GDCLASS(MeshInstance3D, GeometryInstance3D);
protected:
@@ -48,7 +47,6 @@ protected:
NodePath skeleton_path;
struct BlendShapeTrack {
-
int idx;
float value;
BlendShapeTrack() {
diff --git a/scene/3d/multimesh_instance_3d.cpp b/scene/3d/multimesh_instance_3d.cpp
index a625a34283..88dff111f7 100644
--- a/scene/3d/multimesh_instance_3d.cpp
+++ b/scene/3d/multimesh_instance_3d.cpp
@@ -31,37 +31,34 @@
#include "multimesh_instance_3d.h"
void MultiMeshInstance3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_multimesh", "multimesh"), &MultiMeshInstance3D::set_multimesh);
ClassDB::bind_method(D_METHOD("get_multimesh"), &MultiMeshInstance3D::get_multimesh);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), "set_multimesh", "get_multimesh");
}
void MultiMeshInstance3D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
-
multimesh = p_multimesh;
- if (multimesh.is_valid())
+ if (multimesh.is_valid()) {
set_base(multimesh->get_rid());
- else
+ } else {
set_base(RID());
+ }
}
Ref<MultiMesh> MultiMeshInstance3D::get_multimesh() const {
-
return multimesh;
}
Vector<Face3> MultiMeshInstance3D::get_faces(uint32_t p_usage_flags) const {
-
return Vector<Face3>();
}
AABB MultiMeshInstance3D::get_aabb() const {
-
- if (multimesh.is_null())
+ if (multimesh.is_null()) {
return AABB();
- else
+ } else {
return multimesh->get_aabb();
+ }
}
MultiMeshInstance3D::MultiMeshInstance3D() {
diff --git a/scene/3d/navigation_3d.cpp b/scene/3d/navigation_3d.cpp
index f880f65d37..07a4824c28 100644
--- a/scene/3d/navigation_3d.cpp
+++ b/scene/3d/navigation_3d.cpp
@@ -33,7 +33,6 @@
#include "servers/navigation_server_3d.h"
Vector<Vector3> Navigation3D::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const {
-
return NavigationServer3D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
}
@@ -54,13 +53,11 @@ RID Navigation3D::get_closest_point_owner(const Vector3 &p_point) const {
}
void Navigation3D::set_up_vector(const Vector3 &p_up) {
-
up = p_up;
NavigationServer3D::get_singleton()->map_set_up(map, up);
}
Vector3 Navigation3D::get_up_vector() const {
-
return up;
}
@@ -75,7 +72,6 @@ void Navigation3D::set_edge_connection_margin(float p_edge_connection_margin) {
}
void Navigation3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_rid"), &Navigation3D::get_rid);
ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation3D::get_simple_path, DEFVAL(true));
@@ -104,14 +100,12 @@ void Navigation3D::_notification(int p_what) {
NavigationServer3D::get_singleton()->map_set_active(map, true);
} break;
case NOTIFICATION_EXIT_TREE: {
-
NavigationServer3D::get_singleton()->map_set_active(map, false);
} break;
}
}
Navigation3D::Navigation3D() {
-
map = NavigationServer3D::get_singleton()->map_create();
set_cell_size(0.3);
diff --git a/scene/3d/navigation_3d.h b/scene/3d/navigation_3d.h
index daa9558125..890caed171 100644
--- a/scene/3d/navigation_3d.h
+++ b/scene/3d/navigation_3d.h
@@ -35,7 +35,6 @@
#include "scene/3d/node_3d.h"
class Navigation3D : public Node3D {
-
GDCLASS(Navigation3D, Node3D);
RID map;
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index e672ed9a54..e179261002 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -35,7 +35,6 @@
#include "servers/navigation_server_3d.h"
void NavigationAgent3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent3D::set_target_desired_distance);
ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent3D::get_target_desired_distance);
@@ -99,7 +98,6 @@ void NavigationAgent3D::_bind_methods() {
void NavigationAgent3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
-
agent_parent = Object::cast_to<Node3D>(get_parent());
NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
@@ -110,10 +108,11 @@ void NavigationAgent3D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation3D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -128,7 +127,6 @@ void NavigationAgent3D::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (agent_parent) {
-
NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin);
if (!target_reached) {
if (distance_to_target() < target_desired_distance) {
@@ -141,16 +139,7 @@ void NavigationAgent3D::_notification(int p_what) {
}
}
-NavigationAgent3D::NavigationAgent3D() :
- agent_parent(nullptr),
- navigation(nullptr),
- agent(RID()),
- target_desired_distance(1.0),
- navigation_height_offset(0.0),
- path_max_distance(3.0),
- velocity_submitted(false),
- target_reached(false),
- navigation_finished(true) {
+NavigationAgent3D::NavigationAgent3D() {
agent = NavigationServer3D::get_singleton()->agent_create();
set_neighbor_dist(50.0);
set_max_neighbors(10);
@@ -166,8 +155,9 @@ NavigationAgent3D::~NavigationAgent3D() {
}
void NavigationAgent3D::set_navigation(Navigation3D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -305,13 +295,15 @@ String NavigationAgent3D::get_configuration_warning() const {
}
void NavigationAgent3D::update_navigation() {
-
- if (agent_parent == nullptr)
+ if (agent_parent == nullptr) {
return;
- if (navigation == nullptr)
+ }
+ if (navigation == nullptr) {
return;
- if (update_frame_id == Engine::get_singleton()->get_physics_frames())
+ }
+ if (update_frame_id == Engine::get_singleton()->get_physics_frames()) {
return;
+ }
update_frame_id = Engine::get_singleton()->get_physics_frames();
@@ -331,7 +323,7 @@ void NavigationAgent3D::update_navigation() {
segment[1] = navigation_path[nav_path_index];
segment[0].y -= navigation_height_offset;
segment[1].y -= navigation_height_offset;
- Vector3 p = Geometry::get_closest_point_to_segment(o, segment);
+ Vector3 p = Geometry3D::get_closest_point_to_segment(o, segment);
if (o.distance_to(p) >= path_max_distance) {
// To faraway, reload path
reload_path = true;
@@ -346,8 +338,9 @@ void NavigationAgent3D::update_navigation() {
emit_signal("path_changed");
}
- if (navigation_path.size() == 0)
+ if (navigation_path.size() == 0) {
return;
+ }
// Check if we can advance the navigation path
if (navigation_finished == false) {
diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h
index 3558b4e51b..6dc375ef24 100644
--- a/scene/3d/navigation_agent_3d.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -40,31 +40,31 @@ class Navigation3D;
class NavigationAgent3D : public Node {
GDCLASS(NavigationAgent3D, Node);
- Node3D *agent_parent;
- Navigation3D *navigation;
+ Node3D *agent_parent = nullptr;
+ Navigation3D *navigation = nullptr;
RID agent;
- real_t target_desired_distance;
+ real_t target_desired_distance = 1.0;
real_t radius;
- real_t navigation_height_offset;
+ real_t navigation_height_offset = 0.0;
bool ignore_y;
real_t neighbor_dist;
int max_neighbors;
real_t time_horizon;
real_t max_speed;
- real_t path_max_distance;
+ real_t path_max_distance = 3.0;
Vector3 target_location;
Vector<Vector3> navigation_path;
int nav_path_index;
- bool velocity_submitted;
+ bool velocity_submitted = false;
Vector3 prev_safe_velocity;
/// The submitted target velocity
Vector3 target_velocity;
- bool target_reached;
- bool navigation_finished;
+ bool target_reached = false;
+ bool navigation_finished = true;
// No initialized on purpose
uint32_t update_frame_id;
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index 2ee2008799..69fd5b02fc 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -36,7 +36,6 @@
#include "servers/navigation_server_3d.h"
void NavigationObstacle3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_navigation", "navigation"), &NavigationObstacle3D::set_navigation_node);
ClassDB::bind_method(D_METHOD("get_navigation"), &NavigationObstacle3D::get_navigation_node);
}
@@ -44,7 +43,6 @@ void NavigationObstacle3D::_bind_methods() {
void NavigationObstacle3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
-
update_agent_shape();
// Search the navigation node and set it
@@ -53,10 +51,11 @@ void NavigationObstacle3D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation3D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -76,7 +75,6 @@ void NavigationObstacle3D::_notification(int p_what) {
PhysicsBody3D *rigid = Object::cast_to<PhysicsBody3D>(get_parent());
if (rigid) {
-
Vector3 v = rigid->get_linear_velocity();
NavigationServer3D::get_singleton()->agent_set_velocity(agent, v);
NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, v);
@@ -86,9 +84,7 @@ void NavigationObstacle3D::_notification(int p_what) {
}
}
-NavigationObstacle3D::NavigationObstacle3D() :
- navigation(nullptr),
- agent(RID()) {
+NavigationObstacle3D::NavigationObstacle3D() {
agent = NavigationServer3D::get_singleton()->agent_create();
}
@@ -98,8 +94,9 @@ NavigationObstacle3D::~NavigationObstacle3D() {
}
void NavigationObstacle3D::set_navigation(Navigation3D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -117,7 +114,6 @@ Node *NavigationObstacle3D::get_navigation_node() const {
String NavigationObstacle3D::get_configuration_warning() const {
if (!Object::cast_to<Node3D>(get_parent())) {
-
return TTR("The NavigationObstacle3D only serves to provide collision avoidance to a spatial object.");
}
@@ -151,8 +147,9 @@ void NavigationObstacle3D::update_agent_shape() {
radius *= MAX(s.x, MAX(s.y, s.z));
}
- if (radius == 0.0)
+ if (radius == 0.0) {
radius = 1.0; // Never a 0 radius
+ }
// Initialize the Agent as an object
NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
diff --git a/scene/3d/navigation_obstacle_3d.h b/scene/3d/navigation_obstacle_3d.h
index b58d7c4991..c7d2b556af 100644
--- a/scene/3d/navigation_obstacle_3d.h
+++ b/scene/3d/navigation_obstacle_3d.h
@@ -38,7 +38,7 @@ class Navigation3D;
class NavigationObstacle3D : public Node {
GDCLASS(NavigationObstacle3D, Node);
- Navigation3D *navigation;
+ Navigation3D *navigation = nullptr;
RID agent;
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index 043b816033..15ed448a65 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -36,21 +36,19 @@
#include "servers/navigation_server_3d.h"
void NavigationRegion3D::set_enabled(bool p_enabled) {
-
- if (enabled == p_enabled)
+ if (enabled == p_enabled) {
return;
+ }
enabled = p_enabled;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (!enabled) {
-
NavigationServer3D::get_singleton()->region_set_map(region, RID());
} else {
-
if (navigation) {
-
NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
}
}
@@ -68,25 +66,19 @@ void NavigationRegion3D::set_enabled(bool p_enabled) {
}
bool NavigationRegion3D::is_enabled() const {
-
return enabled;
}
/////////////////////////////
void NavigationRegion3D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
Node3D *c = this;
while (c) {
-
navigation = Object::cast_to<Navigation3D>(c);
if (navigation) {
-
if (enabled) {
-
NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
}
break;
@@ -96,7 +88,6 @@ void NavigationRegion3D::_notification(int p_what) {
}
if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) {
-
MeshInstance3D *dm = memnew(MeshInstance3D);
dm->set_mesh(navmesh->get_debug_mesh());
if (is_enabled()) {
@@ -110,14 +101,11 @@ void NavigationRegion3D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform());
} break;
case NOTIFICATION_EXIT_TREE: {
-
if (navigation) {
-
NavigationServer3D::get_singleton()->region_set_map(region, RID());
}
@@ -131,9 +119,9 @@ void NavigationRegion3D::_notification(int p_what) {
}
void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
-
- if (p_navmesh == navmesh)
+ if (p_navmesh == navmesh) {
return;
+ }
if (navmesh.is_valid()) {
navmesh->remove_change_receptor(this);
@@ -158,7 +146,6 @@ void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_navmes
}
Ref<NavigationMesh> NavigationRegion3D::get_navigation_mesh() const {
-
return navmesh;
}
@@ -176,7 +163,6 @@ void _bake_navigation_mesh(void *p_user_data) {
args->nav_region->call_deferred("_bake_finished", nav_mesh);
memdelete(args);
} else {
-
ERR_PRINT("Can't bake the navigation mesh if the `NavigationMesh` resource doesn't exist");
args->nav_region->call_deferred("_bake_finished", Ref<NavigationMesh>());
memdelete(args);
@@ -199,18 +185,18 @@ void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
}
String NavigationRegion3D::get_configuration_warning() const {
-
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
if (!navmesh.is_valid()) {
return TTR("A NavigationMesh resource must be set or created for this node to work.");
}
const Node3D *c = this;
while (c) {
-
- if (Object::cast_to<Navigation3D>(c))
+ if (Object::cast_to<Navigation3D>(c)) {
return String();
+ }
c = Object::cast_to<Node3D>(c->get_parent());
}
@@ -219,7 +205,6 @@ String NavigationRegion3D::get_configuration_warning() const {
}
void NavigationRegion3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navmesh"), &NavigationRegion3D::set_navigation_mesh);
ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationRegion3D::get_navigation_mesh);
@@ -242,18 +227,13 @@ void NavigationRegion3D::_changed_callback(Object *p_changed, const char *p_prop
}
NavigationRegion3D::NavigationRegion3D() {
-
- enabled = true;
set_notify_transform(true);
region = NavigationServer3D::get_singleton()->region_create();
-
- navigation = nullptr;
- debug_view = nullptr;
- bake_thread = nullptr;
}
NavigationRegion3D::~NavigationRegion3D() {
- if (navmesh.is_valid())
+ if (navmesh.is_valid()) {
navmesh->remove_change_receptor(this);
+ }
NavigationServer3D::get_singleton()->free(region);
}
diff --git a/scene/3d/navigation_region_3d.h b/scene/3d/navigation_region_3d.h
index ae071e6b7a..fcd2efd4ef 100644
--- a/scene/3d/navigation_region_3d.h
+++ b/scene/3d/navigation_region_3d.h
@@ -38,16 +38,15 @@
class Navigation3D;
class NavigationRegion3D : public Node3D {
-
GDCLASS(NavigationRegion3D, Node3D);
- bool enabled;
+ bool enabled = true;
RID region;
Ref<NavigationMesh> navmesh;
- Navigation3D *navigation;
- Node *debug_view;
- Thread *bake_thread;
+ Navigation3D *navigation = nullptr;
+ Node *debug_view = nullptr;
+ Thread *bake_thread = nullptr;
protected:
void _notification(int p_what);
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index 913a3ea49f..73f17060df 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -74,7 +74,6 @@ Node3DGizmo::Node3DGizmo() {
}
void Node3D::_notify_dirty() {
-
#ifdef TOOLS_ENABLED
if ((data.gizmo.is_valid() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) {
#else
@@ -90,8 +89,8 @@ void Node3D::_update_local_transform() const {
data.dirty &= ~DIRTY_LOCAL;
}
-void Node3D::_propagate_transform_changed(Node3D *p_origin) {
+void Node3D::_propagate_transform_changed(Node3D *p_origin) {
if (!is_inside_tree()) {
return;
}
@@ -104,9 +103,9 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) {
data.children_lock++;
for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) {
-
- if (E->get()->data.toplevel_active)
+ if (E->get()->data.toplevel_active) {
continue; //don't propagate to a toplevel
+ }
E->get()->_propagate_transform_changed(p_origin);
}
#ifdef TOOLS_ENABLED
@@ -122,22 +121,22 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) {
}
void Node3D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
ERR_FAIL_COND(!get_tree());
Node *p = get_parent();
- if (p)
+ if (p) {
data.parent = Object::cast_to<Node3D>(p);
+ }
- if (data.parent)
+ if (data.parent) {
data.C = data.parent->data.children.push_back(this);
- else
+ } else {
data.C = nullptr;
+ }
if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) {
-
if (data.parent) {
data.local_transform = data.parent->get_global_transform() * get_transform();
data.dirty = DIRTY_VECTORS; //global is always dirty upon entering a scene
@@ -152,18 +151,18 @@ void Node3D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
notification(NOTIFICATION_EXIT_WORLD, true);
- if (xform_change.in_list())
+ if (xform_change.in_list()) {
get_tree()->xform_change_list.remove(&xform_change);
- if (data.C)
+ }
+ if (data.C) {
data.parent->data.children.erase(data.C);
+ }
data.parent = nullptr;
data.C = nullptr;
data.toplevel_active = false;
} break;
case NOTIFICATION_ENTER_WORLD: {
-
data.inside_world = true;
data.viewport = nullptr;
Node *parent = get_parent();
@@ -175,16 +174,13 @@ void Node3D::_notification(int p_what) {
ERR_FAIL_COND(!data.viewport);
if (get_script_instance()) {
-
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, nullptr, 0);
}
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) {
-
//get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
if (!data.gizmo_disabled) {
-
if (data.gizmo.is_valid()) {
data.gizmo->create();
if (is_visible_in_tree()) {
@@ -198,7 +194,6 @@ void Node3D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_WORLD: {
-
#ifdef TOOLS_ENABLED
if (data.gizmo.is_valid()) {
data.gizmo->free();
@@ -207,7 +202,6 @@ void Node3D::_notification(int p_what) {
#endif
if (get_script_instance()) {
-
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, nullptr, 0);
}
@@ -217,7 +211,6 @@ void Node3D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
#ifdef TOOLS_ENABLED
if (data.gizmo.is_valid()) {
data.gizmo->transform();
@@ -231,7 +224,6 @@ void Node3D::_notification(int p_what) {
}
void Node3D::set_transform(const Transform &p_transform) {
-
data.local_transform = p_transform;
data.dirty |= DIRTY_VECTORS;
_change_notify("translation");
@@ -245,7 +237,6 @@ void Node3D::set_transform(const Transform &p_transform) {
}
void Node3D::set_global_transform(const Transform &p_transform) {
-
Transform xform =
(data.parent && !data.toplevel_active) ?
data.parent->get_global_transform().affine_inverse() * p_transform :
@@ -255,30 +246,24 @@ void Node3D::set_global_transform(const Transform &p_transform) {
}
Transform Node3D::get_transform() const {
-
if (data.dirty & DIRTY_LOCAL) {
-
_update_local_transform();
}
return data.local_transform;
}
-Transform Node3D::get_global_transform() const {
+Transform Node3D::get_global_transform() const {
ERR_FAIL_COND_V(!is_inside_tree(), Transform());
if (data.dirty & DIRTY_GLOBAL) {
-
if (data.dirty & DIRTY_LOCAL) {
-
_update_local_transform();
}
if (data.parent && !data.toplevel_active) {
-
data.global_transform = data.parent->get_global_transform() * data.local_transform;
} else {
-
data.global_transform = data.local_transform;
}
@@ -303,25 +288,24 @@ Transform Node3D::get_local_gizmo_transform() const {
#endif
Node3D *Node3D::get_parent_spatial() const {
-
return data.parent;
}
Transform Node3D::get_relative_transform(const Node *p_parent) const {
-
- if (p_parent == this)
+ if (p_parent == this) {
return Transform();
+ }
ERR_FAIL_COND_V(!data.parent, Transform());
- if (p_parent == data.parent)
+ if (p_parent == data.parent) {
return get_transform();
- else
+ } else {
return data.parent->get_relative_transform(p_parent) * get_transform();
+ }
}
void Node3D::set_translation(const Vector3 &p_translation) {
-
data.local_transform.origin = p_translation;
_change_notify("transform");
_propagate_transform_changed(this);
@@ -331,7 +315,6 @@ void Node3D::set_translation(const Vector3 &p_translation) {
}
void Node3D::set_rotation(const Vector3 &p_euler_rad) {
-
if (data.dirty & DIRTY_VECTORS) {
data.scale = data.local_transform.basis.get_scale();
data.dirty &= ~DIRTY_VECTORS;
@@ -347,12 +330,10 @@ void Node3D::set_rotation(const Vector3 &p_euler_rad) {
}
void Node3D::set_rotation_degrees(const Vector3 &p_euler_deg) {
-
set_rotation(p_euler_deg * Math_PI / 180.0);
}
void Node3D::set_scale(const Vector3 &p_scale) {
-
if (data.dirty & DIRTY_VECTORS) {
data.rotation = data.local_transform.basis.get_rotation();
data.dirty &= ~DIRTY_VECTORS;
@@ -368,12 +349,10 @@ void Node3D::set_scale(const Vector3 &p_scale) {
}
Vector3 Node3D::get_translation() const {
-
return data.local_transform.origin;
}
Vector3 Node3D::get_rotation() const {
-
if (data.dirty & DIRTY_VECTORS) {
data.scale = data.local_transform.basis.get_scale();
data.rotation = data.local_transform.basis.get_rotation();
@@ -385,12 +364,10 @@ Vector3 Node3D::get_rotation() const {
}
Vector3 Node3D::get_rotation_degrees() const {
-
return get_rotation() * 180.0 / Math_PI;
}
Vector3 Node3D::get_scale() const {
-
if (data.dirty & DIRTY_VECTORS) {
data.scale = data.local_transform.basis.get_scale();
data.rotation = data.local_transform.basis.get_rotation();
@@ -402,32 +379,35 @@ Vector3 Node3D::get_scale() const {
}
void Node3D::update_gizmo() {
-
#ifdef TOOLS_ENABLED
- if (!is_inside_world())
+ if (!is_inside_world()) {
return;
- if (!data.gizmo.is_valid())
+ }
+ if (!data.gizmo.is_valid()) {
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
- if (!data.gizmo.is_valid())
+ }
+ if (!data.gizmo.is_valid()) {
return;
- if (data.gizmo_dirty)
+ }
+ if (data.gizmo_dirty) {
return;
+ }
data.gizmo_dirty = true;
MessageQueue::get_singleton()->push_call(this, "_update_gizmo");
#endif
}
void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) {
-
#ifdef TOOLS_ENABLED
- if (data.gizmo_disabled)
+ if (data.gizmo_disabled) {
return;
- if (data.gizmo.is_valid() && is_inside_world())
+ }
+ if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->free();
+ }
data.gizmo = p_gizmo;
if (data.gizmo.is_valid() && is_inside_world()) {
-
data.gizmo->create();
if (is_visible_in_tree()) {
data.gizmo->redraw();
@@ -439,7 +419,6 @@ void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) {
}
Ref<Node3DGizmo> Node3D::get_gizmo() const {
-
#ifdef TOOLS_ENABLED
return data.gizmo;
@@ -450,32 +429,32 @@ Ref<Node3DGizmo> Node3D::get_gizmo() const {
}
void Node3D::_update_gizmo() {
-
#ifdef TOOLS_ENABLED
- if (!is_inside_world())
+ if (!is_inside_world()) {
return;
+ }
data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
data.gizmo->redraw();
- else
+ } else {
data.gizmo->clear();
+ }
}
#endif
}
#ifdef TOOLS_ENABLED
void Node3D::set_disable_gizmo(bool p_enabled) {
-
data.gizmo_disabled = p_enabled;
- if (!p_enabled && data.gizmo.is_valid())
+ if (!p_enabled && data.gizmo.is_valid()) {
data.gizmo = Ref<Node3DGizmo>();
+ }
}
#endif
void Node3D::set_disable_scale(bool p_enabled) {
-
data.disable_scale = p_enabled;
}
@@ -484,15 +463,15 @@ bool Node3D::is_scale_disabled() const {
}
void Node3D::set_as_toplevel(bool p_enabled) {
-
- if (data.toplevel == p_enabled)
+ if (data.toplevel == p_enabled) {
return;
+ }
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
-
- if (p_enabled)
+ if (p_enabled) {
set_transform(get_global_transform());
- else if (data.parent)
+ } else if (data.parent) {
set_transform(data.parent->get_global_transform().affine_inverse() * get_global_transform());
+ }
data.toplevel = p_enabled;
data.toplevel_active = p_enabled;
@@ -503,12 +482,10 @@ void Node3D::set_as_toplevel(bool p_enabled) {
}
bool Node3D::is_set_as_toplevel() const {
-
return data.toplevel;
}
Ref<World3D> Node3D::get_world_3d() const {
-
ERR_FAIL_COND_V(!is_inside_world(), Ref<World3D>());
ERR_FAIL_COND_V(!data.viewport, Ref<World3D>());
@@ -516,52 +493,53 @@ Ref<World3D> Node3D::get_world_3d() const {
}
void Node3D::_propagate_visibility_changed() {
-
notification(NOTIFICATION_VISIBILITY_CHANGED);
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
_change_notify("visible");
#ifdef TOOLS_ENABLED
- if (data.gizmo.is_valid())
+ if (data.gizmo.is_valid()) {
_update_gizmo();
+ }
#endif
for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) {
-
Node3D *c = E->get();
- if (!c || !c->data.visible)
+ if (!c || !c->data.visible) {
continue;
+ }
c->_propagate_visibility_changed();
}
}
void Node3D::show() {
-
- if (data.visible)
+ if (data.visible) {
return;
+ }
data.visible = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_propagate_visibility_changed();
}
void Node3D::hide() {
-
- if (!data.visible)
+ if (!data.visible) {
return;
+ }
data.visible = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_propagate_visibility_changed();
}
bool Node3D::is_visible_in_tree() const {
-
const Node3D *s = this;
while (s) {
@@ -575,15 +553,14 @@ bool Node3D::is_visible_in_tree() const {
}
void Node3D::set_visible(bool p_visible) {
-
- if (p_visible)
+ if (p_visible) {
show();
- else
+ } else {
hide();
+ }
}
bool Node3D::is_visible() const {
-
return data.visible;
}
@@ -594,34 +571,30 @@ void Node3D::rotate_object_local(const Vector3 &p_axis, float p_angle) {
}
void Node3D::rotate(const Vector3 &p_axis, float p_angle) {
-
Transform t = get_transform();
t.basis.rotate(p_axis, p_angle);
set_transform(t);
}
void Node3D::rotate_x(float p_angle) {
-
Transform t = get_transform();
t.basis.rotate(Vector3(1, 0, 0), p_angle);
set_transform(t);
}
void Node3D::rotate_y(float p_angle) {
-
Transform t = get_transform();
t.basis.rotate(Vector3(0, 1, 0), p_angle);
set_transform(t);
}
-void Node3D::rotate_z(float p_angle) {
+void Node3D::rotate_z(float p_angle) {
Transform t = get_transform();
t.basis.rotate(Vector3(0, 0, 1), p_angle);
set_transform(t);
}
void Node3D::translate(const Vector3 &p_offset) {
-
Transform t = get_transform();
t.translate(p_offset);
set_transform(t);
@@ -636,7 +609,6 @@ void Node3D::translate_object_local(const Vector3 &p_offset) {
}
void Node3D::scale(const Vector3 &p_ratio) {
-
Transform t = get_transform();
t.basis.scale(p_ratio);
set_transform(t);
@@ -649,14 +621,12 @@ void Node3D::scale_object_local(const Vector3 &p_scale) {
}
void Node3D::global_rotate(const Vector3 &p_axis, float p_angle) {
-
Transform t = get_global_transform();
t.basis.rotate(p_axis, p_angle);
set_global_transform(t);
}
void Node3D::global_scale(const Vector3 &p_scale) {
-
Transform t = get_global_transform();
t.basis.scale(p_scale);
set_global_transform(t);
@@ -669,25 +639,21 @@ void Node3D::global_translate(const Vector3 &p_offset) {
}
void Node3D::orthonormalize() {
-
Transform t = get_transform();
t.orthonormalize();
set_transform(t);
}
void Node3D::set_identity() {
-
set_transform(Transform());
}
void Node3D::look_at(const Vector3 &p_target, const Vector3 &p_up) {
-
Vector3 origin(get_global_transform().origin);
look_at_from_position(origin, p_target, p_up);
}
void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up) {
-
ERR_FAIL_COND_MSG(p_pos == p_target, "Node origin and target are in the same position, look_at() failed.");
ERR_FAIL_COND_MSG(p_up.cross(p_target - p_pos) == Vector3(), "Up vector and direction between node origin and target are aligned, look_at() failed.");
@@ -701,12 +667,10 @@ void Node3D::look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target
}
Vector3 Node3D::to_local(Vector3 p_global) const {
-
return get_global_transform().affine_inverse().xform(p_global);
}
Vector3 Node3D::to_global(Vector3 p_local) const {
-
return get_global_transform().xform(p_local);
}
@@ -737,7 +701,6 @@ void Node3D::force_update_transform() {
}
void Node3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_transform", "local"), &Node3D::set_transform);
ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform);
ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Node3D::set_translation);
@@ -821,7 +784,6 @@ void Node3D::_bind_methods() {
Node3D::Node3D() :
xform_change(this) {
-
data.dirty = DIRTY_NONE;
data.children_lock = 0;
diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h
index a4191eb2b3..327d4671e9 100644
--- a/scene/3d/node_3d.h
+++ b/scene/3d/node_3d.h
@@ -35,7 +35,6 @@
#include "scene/main/scene_tree.h"
class Node3DGizmo : public Reference {
-
GDCLASS(Node3DGizmo, Reference);
public:
@@ -50,7 +49,6 @@ public:
};
class Node3D : public Node {
-
GDCLASS(Node3D, Node);
OBJ_CATEGORY("3D");
@@ -64,7 +62,6 @@ class Node3D : public Node {
mutable SelfList<Node> xform_change;
struct Data {
-
mutable Transform global_transform;
mutable Transform local_transform;
mutable Vector3 rotation;
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index 4a425d1e0e..40d988ff9f 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -37,9 +37,9 @@ void Path3D::_notification(int p_what) {
}
void Path3D::_curve_changed() {
-
- if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
update_gizmo();
+ }
if (is_inside_tree()) {
emit_signal("curve_changed");
}
@@ -57,7 +57,6 @@ void Path3D::_curve_changed() {
}
void Path3D::set_curve(const Ref<Curve3D> &p_curve) {
-
if (curve.is_valid()) {
curve->disconnect("changed", callable_mp(this, &Path3D::_curve_changed));
}
@@ -71,35 +70,29 @@ void Path3D::set_curve(const Ref<Curve3D> &p_curve) {
}
Ref<Curve3D> Path3D::get_curve() const {
-
return curve;
}
void Path3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve);
ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), "set_curve", "get_curve");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve");
ADD_SIGNAL(MethodInfo("curve_changed"));
}
-Path3D::Path3D() {
-
- set_curve(Ref<Curve3D>(memnew(Curve3D))); //create one by default
-}
-
//////////////
void PathFollow3D::_update_transform() {
-
- if (!path)
+ if (!path) {
return;
+ }
Ref<Curve3D> c = path->get_curve();
- if (!c.is_valid())
+ if (!c.is_valid()) {
return;
+ }
if (delta_offset == 0) {
return;
@@ -124,13 +117,13 @@ void PathFollow3D::_update_transform() {
// will be replaced by "Vector3(h_offset, v_offset, 0)" where it was formerly used
if (rotation_mode == ROTATION_ORIENTED) {
-
Vector3 forward = c->interpolate_baked(o_next, cubic) - pos;
- if (forward.length_squared() < CMP_EPSILON2)
+ if (forward.length_squared() < CMP_EPSILON2) {
forward = Vector3(0, 0, 1);
- else
+ } else {
forward.normalize();
+ }
Vector3 up = c->interpolate_baked_up_vector(offset, true);
@@ -138,10 +131,11 @@ void PathFollow3D::_update_transform() {
Vector3 up1 = c->interpolate_baked_up_vector(o_next, true);
Vector3 axis = up.cross(up1);
- if (axis.length_squared() < CMP_EPSILON2)
+ if (axis.length_squared() < CMP_EPSILON2) {
axis = forward;
- else
+ } else {
axis.normalize();
+ }
up.rotate(axis, up.angle_to(up1) * 0.5f);
}
@@ -213,11 +207,8 @@ void PathFollow3D::_update_transform() {
}
void PathFollow3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
Node *parent = get_parent();
if (parent) {
path = Object::cast_to<Path3D>(parent);
@@ -228,38 +219,34 @@ void PathFollow3D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
path = nullptr;
} break;
}
}
void PathFollow3D::set_cubic_interpolation(bool p_enable) {
-
cubic = p_enable;
}
bool PathFollow3D::get_cubic_interpolation() const {
-
return cubic;
}
void PathFollow3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "offset") {
-
float max = 10000;
- if (path && path->get_curve().is_valid())
+ if (path && path->get_curve().is_valid()) {
max = path->get_curve()->get_baked_length();
+ }
property.hint_string = "0," + rtos(max) + ",0.01,or_lesser,or_greater";
}
}
String PathFollow3D::get_configuration_warning() const {
-
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
if (!Object::cast_to<Path3D>(get_parent())) {
return TTR("PathFollow3D only works when set as a child of a Path3D node.");
@@ -274,7 +261,6 @@ String PathFollow3D::get_configuration_warning() const {
}
void PathFollow3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_offset", "offset"), &PathFollow3D::set_offset);
ClassDB::bind_method(D_METHOD("get_offset"), &PathFollow3D::get_offset);
@@ -336,50 +322,46 @@ void PathFollow3D::set_offset(float p_offset) {
}
void PathFollow3D::set_h_offset(float p_h_offset) {
-
h_offset = p_h_offset;
- if (path)
+ if (path) {
_update_transform();
+ }
}
float PathFollow3D::get_h_offset() const {
-
return h_offset;
}
void PathFollow3D::set_v_offset(float p_v_offset) {
-
v_offset = p_v_offset;
- if (path)
+ if (path) {
_update_transform();
+ }
}
float PathFollow3D::get_v_offset() const {
-
return v_offset;
}
float PathFollow3D::get_offset() const {
-
return offset;
}
void PathFollow3D::set_unit_offset(float p_unit_offset) {
-
- if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
+ if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
set_offset(p_unit_offset * path->get_curve()->get_baked_length());
+ }
}
float PathFollow3D::get_unit_offset() const {
-
- if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
+ if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
return get_offset() / path->get_curve()->get_baked_length();
- else
+ } else {
return 0;
+ }
}
void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) {
-
rotation_mode = p_rotation_mode;
update_configuration_warning();
@@ -387,22 +369,18 @@ void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) {
}
PathFollow3D::RotationMode PathFollow3D::get_rotation_mode() const {
-
return rotation_mode;
}
void PathFollow3D::set_loop(bool p_loop) {
-
loop = p_loop;
}
bool PathFollow3D::has_loop() const {
-
return loop;
}
PathFollow3D::PathFollow3D() {
-
offset = 0;
delta_offset = 0;
h_offset = 0;
diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h
index 6f0db8c5c2..7f227a8a6f 100644
--- a/scene/3d/path_3d.h
+++ b/scene/3d/path_3d.h
@@ -35,7 +35,6 @@
#include "scene/resources/curve.h"
class Path3D : public Node3D {
-
GDCLASS(Path3D, Node3D);
Ref<Curve3D> curve;
@@ -50,11 +49,10 @@ public:
void set_curve(const Ref<Curve3D> &p_curve);
Ref<Curve3D> get_curve() const;
- Path3D();
+ Path3D() {}
};
class PathFollow3D : public Node3D {
-
GDCLASS(PathFollow3D, Node3D);
public:
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 280bab5d45..6320af21eb 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -45,68 +45,60 @@
#endif
Vector3 PhysicsBody3D::get_linear_velocity() const {
-
return Vector3();
}
-Vector3 PhysicsBody3D::get_angular_velocity() const {
+Vector3 PhysicsBody3D::get_angular_velocity() const {
return Vector3();
}
float PhysicsBody3D::get_inverse_mass() const {
-
return 0;
}
void PhysicsBody3D::set_collision_layer(uint32_t p_layer) {
-
collision_layer = p_layer;
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), p_layer);
}
uint32_t PhysicsBody3D::get_collision_layer() const {
-
return collision_layer;
}
void PhysicsBody3D::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody3D::get_collision_mask() const {
-
return collision_mask;
}
void PhysicsBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool PhysicsBody3D::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
void PhysicsBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_layer();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_layer(mask);
}
bool PhysicsBody3D::get_collision_layer_bit(int p_bit) const {
-
return get_collision_layer() & (1 << p_bit);
}
@@ -125,7 +117,6 @@ TypedArray<PhysicsBody3D> PhysicsBody3D::get_collision_exceptions() {
}
void PhysicsBody3D::add_collision_exception_with(Node *p_node) {
-
ERR_FAIL_NULL(p_node);
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds.");
@@ -133,7 +124,6 @@ void PhysicsBody3D::add_collision_exception_with(Node *p_node) {
}
void PhysicsBody3D::remove_collision_exception_with(Node *p_node) {
-
ERR_FAIL_NULL(p_node);
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds.");
@@ -146,7 +136,6 @@ void PhysicsBody3D::_set_layers(uint32_t p_mask) {
}
uint32_t PhysicsBody3D::_get_layers() const {
-
return get_collision_layer();
}
@@ -173,7 +162,6 @@ void PhysicsBody3D::_bind_methods() {
PhysicsBody3D::PhysicsBody3D(PhysicsServer3D::BodyMode p_mode) :
CollisionObject3D(PhysicsServer3D::get_singleton()->body_create(p_mode), false) {
-
collision_layer = 1;
collision_mask = 1;
}
@@ -198,28 +186,24 @@ Ref<PhysicsMaterial> StaticBody3D::get_physics_material_override() const {
}
void StaticBody3D::set_constant_linear_velocity(const Vector3 &p_vel) {
-
constant_linear_velocity = p_vel;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
void StaticBody3D::set_constant_angular_velocity(const Vector3 &p_vel) {
-
constant_angular_velocity = p_vel;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector3 StaticBody3D::get_constant_linear_velocity() const {
-
return constant_linear_velocity;
}
-Vector3 StaticBody3D::get_constant_angular_velocity() const {
+Vector3 StaticBody3D::get_constant_angular_velocity() const {
return constant_angular_velocity;
}
void StaticBody3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody3D::set_constant_linear_velocity);
ClassDB::bind_method(D_METHOD("set_constant_angular_velocity", "vel"), &StaticBody3D::set_constant_angular_velocity);
ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"), &StaticBody3D::get_constant_linear_velocity);
@@ -254,7 +238,6 @@ void StaticBody3D::_reload_physics_characteristics() {
}
void RigidBody3D::_body_enter_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -271,7 +254,6 @@ void RigidBody3D::_body_enter_tree(ObjectID p_id) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
@@ -279,7 +261,6 @@ void RigidBody3D::_body_enter_tree(ObjectID p_id) {
}
void RigidBody3D::_body_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
@@ -294,7 +275,6 @@ void RigidBody3D::_body_exit_tree(ObjectID p_id) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
for (int i = 0; i < E->get().shapes.size(); i++) {
-
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
@@ -302,7 +282,6 @@ void RigidBody3D::_body_exit_tree(ObjectID p_id) {
}
void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
-
bool body_in = p_status == 1;
ObjectID objid = p_instance;
@@ -316,7 +295,6 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (body_in) {
if (!E) {
-
E = contact_monitor->body_map.insert(objid, BodyState());
//E->get().rc=0;
E->get().in_tree = node && node->is_inside_tree();
@@ -329,29 +307,30 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
}
}
//E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(ShapePair(p_body_shape, p_local_shape));
+ }
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_local_shape);
}
} else {
-
//E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(ShapePair(p_body_shape, p_local_shape));
+ }
bool in_tree = E->get().in_tree;
if (E->get().shapes.empty()) {
-
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
- if (in_tree)
+ if (in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
+ }
}
contact_monitor->body_map.erase(E);
@@ -363,14 +342,12 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
}
struct _RigidBodyInOut {
-
ObjectID id;
int shape;
int local_shape;
};
void RigidBody3D::_direct_state_changed(Object *p_state) {
-
#ifdef DEBUG_ENABLED
state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
#else
@@ -385,20 +362,18 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
sleeping = state->is_sleeping();
emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed);
}
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("_integrate_forces", state);
+ }
set_ignore_transform_notification(false);
if (contact_monitor) {
-
contact_monitor->locked = true;
//untag all
int rc = 0;
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
-
for (int i = 0; i < E->get().shapes.size(); i++) {
-
E->get().shapes[i].tagged = false;
rc++;
}
@@ -412,7 +387,6 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
//put the ones to add
for (int i = 0; i < state->get_contact_count(); i++) {
-
ObjectID obj = state->get_contact_collider_id(i);
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
@@ -431,7 +405,6 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
ShapePair sp(shape, local_shape);
int idx = E->get().shapes.find(sp);
if (idx == -1) {
-
toadd[toadd_count].local_shape = local_shape;
toadd[toadd_count].id = obj;
toadd[toadd_count].shape = shape;
@@ -445,11 +418,8 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
//put the ones to remove
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
-
for (int i = 0; i < E->get().shapes.size(); i++) {
-
if (!E->get().shapes[i].tagged) {
-
toremove[toremove_count].body_id = E->key();
toremove[toremove_count].pair = E->get().shapes[i];
toremove_count++;
@@ -460,14 +430,12 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
//process remotions
for (int i = 0; i < toremove_count; i++) {
-
_body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
}
//process aditions
for (int i = 0; i < toadd_count; i++) {
-
_body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
}
@@ -478,7 +446,6 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
}
void RigidBody3D::_notification(int p_what) {
-
#ifdef TOOLS_ENABLED
if (p_what == NOTIFICATION_ENTER_TREE) {
if (Engine::get_singleton()->is_editor_hint()) {
@@ -496,16 +463,12 @@ void RigidBody3D::_notification(int p_what) {
}
void RigidBody3D::set_mode(Mode p_mode) {
-
mode = p_mode;
switch (p_mode) {
-
case MODE_RIGID: {
-
PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_RIGID);
} break;
case MODE_STATIC: {
-
PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_STATIC);
} break;
@@ -514,7 +477,6 @@ void RigidBody3D::set_mode(Mode p_mode) {
} break;
case MODE_KINEMATIC: {
-
PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_KINEMATIC);
} break;
}
@@ -522,29 +484,26 @@ void RigidBody3D::set_mode(Mode p_mode) {
}
RigidBody3D::Mode RigidBody3D::get_mode() const {
-
return mode;
}
void RigidBody3D::set_mass(real_t p_mass) {
-
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
_change_notify("mass");
_change_notify("weight");
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
}
-real_t RigidBody3D::get_mass() const {
+real_t RigidBody3D::get_mass() const {
return mass;
}
void RigidBody3D::set_weight(real_t p_weight) {
-
set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)));
}
-real_t RigidBody3D::get_weight() const {
+real_t RigidBody3D::get_weight() const {
return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
}
@@ -568,39 +527,35 @@ Ref<PhysicsMaterial> RigidBody3D::get_physics_material_override() const {
}
void RigidBody3D::set_gravity_scale(real_t p_gravity_scale) {
-
gravity_scale = p_gravity_scale;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
-real_t RigidBody3D::get_gravity_scale() const {
+real_t RigidBody3D::get_gravity_scale() const {
return gravity_scale;
}
void RigidBody3D::set_linear_damp(real_t p_linear_damp) {
-
ERR_FAIL_COND(p_linear_damp < -1);
linear_damp = p_linear_damp;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
-real_t RigidBody3D::get_linear_damp() const {
+real_t RigidBody3D::get_linear_damp() const {
return linear_damp;
}
void RigidBody3D::set_angular_damp(real_t p_angular_damp) {
-
ERR_FAIL_COND(p_angular_damp < -1);
angular_damp = p_angular_damp;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
-real_t RigidBody3D::get_angular_damp() const {
+real_t RigidBody3D::get_angular_damp() const {
return angular_damp;
}
void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) {
-
Vector3 v = state ? state->get_linear_velocity() : linear_velocity;
Vector3 axis = p_axis.normalized();
v -= axis * axis.dot(v);
@@ -614,75 +569,68 @@ void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) {
}
void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) {
-
linear_velocity = p_velocity;
- if (state)
+ if (state) {
state->set_linear_velocity(linear_velocity);
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ }
}
Vector3 RigidBody3D::get_linear_velocity() const {
-
return linear_velocity;
}
void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) {
-
angular_velocity = p_velocity;
- if (state)
+ if (state) {
state->set_angular_velocity(angular_velocity);
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ }
}
-Vector3 RigidBody3D::get_angular_velocity() const {
+Vector3 RigidBody3D::get_angular_velocity() const {
return angular_velocity;
}
void RigidBody3D::set_use_custom_integrator(bool p_enable) {
-
- if (custom_integrator == p_enable)
+ if (custom_integrator == p_enable) {
return;
+ }
custom_integrator = p_enable;
PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
}
-bool RigidBody3D::is_using_custom_integrator() {
+bool RigidBody3D::is_using_custom_integrator() {
return custom_integrator;
}
void RigidBody3D::set_sleeping(bool p_sleeping) {
-
sleeping = p_sleeping;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody3D::set_can_sleep(bool p_active) {
-
can_sleep = p_active;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody3D::is_able_to_sleep() const {
-
return can_sleep;
}
bool RigidBody3D::is_sleeping() const {
-
return sleeping;
}
void RigidBody3D::set_max_contacts_reported(int p_amount) {
-
max_contacts_reported = p_amount;
PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
int RigidBody3D::get_max_contacts_reported() const {
-
return max_contacts_reported;
}
@@ -703,7 +651,6 @@ void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) {
}
void RigidBody3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
-
PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
}
@@ -712,27 +659,23 @@ void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) {
}
void RigidBody3D::set_use_continuous_collision_detection(bool p_enable) {
-
ccd = p_enable;
PhysicsServer3D::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable);
}
bool RigidBody3D::is_using_continuous_collision_detection() const {
-
return ccd;
}
void RigidBody3D::set_contact_monitor(bool p_enabled) {
-
- if (p_enabled == is_contact_monitor_enabled())
+ if (p_enabled == is_contact_monitor_enabled()) {
return;
+ }
if (!p_enabled) {
-
ERR_FAIL_COND_MSG(contact_monitor->locked, "Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\", false) instead.");
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
-
//clean up mess
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
@@ -746,14 +689,12 @@ void RigidBody3D::set_contact_monitor(bool p_enabled) {
memdelete(contact_monitor);
contact_monitor = nullptr;
} else {
-
contact_monitor = memnew(ContactMonitor);
contact_monitor->locked = false;
}
}
bool RigidBody3D::is_contact_monitor_enabled() const {
-
return contact_monitor != nullptr;
}
@@ -766,7 +707,6 @@ bool RigidBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
}
Array RigidBody3D::get_colliding_bodies() const {
-
ERR_FAIL_COND_V(!contact_monitor, Array());
Array ret;
@@ -785,7 +725,6 @@ Array RigidBody3D::get_colliding_bodies() const {
}
String RigidBody3D::get_configuration_warning() const {
-
Transform t = get_transform();
String warning = CollisionObject3D::get_configuration_warning();
@@ -801,7 +740,6 @@ String RigidBody3D::get_configuration_warning() const {
}
void RigidBody3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody3D::set_mode);
ClassDB::bind_method(D_METHOD("get_mode"), &RigidBody3D::get_mode);
@@ -905,7 +843,6 @@ void RigidBody3D::_bind_methods() {
RigidBody3D::RigidBody3D() :
PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) {
-
mode = MODE_RIGID;
mass = 1;
@@ -928,9 +865,9 @@ RigidBody3D::RigidBody3D() :
}
RigidBody3D::~RigidBody3D() {
-
- if (contact_monitor)
+ if (contact_monitor) {
memdelete(contact_monitor);
+ }
}
void RigidBody3D::_reload_physics_characteristics() {
@@ -947,7 +884,6 @@ void RigidBody3D::_reload_physics_characteristics() {
//////////////////////////
Ref<KinematicCollision3D> KinematicBody3D::_move(const Vector3 &p_motion, bool p_infinite_inertia, bool p_exclude_raycast_shapes, bool p_test_only) {
-
Collision col;
if (move_and_collide(p_motion, p_infinite_inertia, col, p_exclude_raycast_shapes, p_test_only)) {
if (motion_cache.is_null()) {
@@ -972,7 +908,6 @@ Vector3 KinematicBody3D::get_angular_velocity() const {
}
bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) {
-
Transform gt = get_global_transform();
PhysicsServer3D::MotionResult result;
bool colliding = PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, &result, p_exclude_raycast_shapes);
@@ -1008,9 +943,9 @@ bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_
#define FLOOR_ANGLE_THRESHOLD 0.01
Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
-
Vector3 body_velocity = p_linear_velocity;
Vector3 body_velocity_normal = body_velocity.normalized();
+ Vector3 up_direction = p_up_direction.normalized();
for (int i = 0; i < 3; i++) {
if (locked_axis & (1 << i)) {
@@ -1030,7 +965,6 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
floor_velocity = Vector3();
while (p_max_slides) {
-
Collision collision;
bool found_collision = false;
@@ -1055,11 +989,11 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
colliders.push_back(collision);
motion = collision.remainder;
- if (p_up_direction == Vector3()) {
+ if (up_direction == Vector3()) {
//all is a wall
on_wall = true;
} else {
- if (Math::acos(collision.normal.dot(p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
+ if (Math::acos(collision.normal.dot(up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //floor
on_floor = true;
floor_normal = collision.normal;
@@ -1067,14 +1001,14 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
floor_velocity = collision.collider_vel;
if (p_stop_on_slope) {
- if ((body_velocity_normal + p_up_direction).length() < 0.01 && collision.travel.length() < 1) {
+ if ((body_velocity_normal + up_direction).length() < 0.01 && collision.travel.length() < 1) {
Transform gt = get_global_transform();
- gt.origin -= collision.travel.slide(p_up_direction);
+ gt.origin -= collision.travel.slide(up_direction);
set_global_transform(gt);
return Vector3();
}
}
- } else if (Math::acos(collision.normal.dot(-p_up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
+ } else if (Math::acos(collision.normal.dot(-up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) { //ceiling
on_ceiling = true;
} else {
on_wall = true;
@@ -1092,8 +1026,9 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
}
}
- if (!found_collision || motion == Vector3())
+ if (!found_collision || motion == Vector3()) {
break;
+ }
--p_max_slides;
}
@@ -1102,10 +1037,10 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
}
Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_velocity, const Vector3 &p_snap, const Vector3 &p_up_direction, bool p_stop_on_slope, int p_max_slides, float p_floor_max_angle, bool p_infinite_inertia) {
-
+ Vector3 up_direction = p_up_direction.normalized();
bool was_on_floor = on_floor;
- Vector3 ret = move_and_slide(p_linear_velocity, p_up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
+ Vector3 ret = move_and_slide(p_linear_velocity, up_direction, p_stop_on_slope, p_max_slides, p_floor_max_angle, p_infinite_inertia);
if (!was_on_floor || p_snap == Vector3()) {
return ret;
}
@@ -1114,10 +1049,9 @@ Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_veloci
Transform gt = get_global_transform();
if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) {
-
bool apply = true;
- if (p_up_direction != Vector3()) {
- if (Math::acos(p_up_direction.normalized().dot(col.normal)) < p_floor_max_angle) {
+ if (up_direction != Vector3()) {
+ if (Math::acos(col.normal.dot(up_direction)) <= p_floor_max_angle + FLOOR_ANGLE_THRESHOLD) {
on_floor = true;
floor_normal = col.normal;
on_floor_body = col.collider_rid;
@@ -1125,7 +1059,7 @@ Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_veloci
if (p_stop_on_slope) {
// move and collide may stray the object a bit because of pre un-stucking,
// so only ensure that motion happens on floor direction in this case.
- col.travel = col.travel.project(p_up_direction);
+ col.travel = col.travel.project(up_direction);
}
} else {
apply = false; //snapped with floor direction, but did not snap to a floor, do not snap.
@@ -1141,38 +1075,32 @@ Vector3 KinematicBody3D::move_and_slide_with_snap(const Vector3 &p_linear_veloci
}
bool KinematicBody3D::is_on_floor() const {
-
return on_floor;
}
bool KinematicBody3D::is_on_wall() const {
-
return on_wall;
}
-bool KinematicBody3D::is_on_ceiling() const {
+bool KinematicBody3D::is_on_ceiling() const {
return on_ceiling;
}
Vector3 KinematicBody3D::get_floor_normal() const {
-
return floor_normal;
}
Vector3 KinematicBody3D::get_floor_velocity() const {
-
return floor_velocity;
}
bool KinematicBody3D::test_move(const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia) {
-
ERR_FAIL_COND_V(!is_inside_tree(), false);
return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia);
}
bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) {
-
PhysicsServer3D::SeparationResult sep_res[8]; //max 8 rays
Transform gt = get_global_transform();
@@ -1209,6 +1137,11 @@ bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision
}
void KinematicBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) {
+ if (p_lock) {
+ locked_axis |= p_axis;
+ } else {
+ locked_axis &= (~p_axis);
+ }
PhysicsServer3D::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
}
@@ -1217,17 +1150,15 @@ bool KinematicBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
}
void KinematicBody3D::set_safe_margin(float p_margin) {
-
margin = p_margin;
PhysicsServer3D::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin);
}
float KinematicBody3D::get_safe_margin() const {
-
return margin;
}
-int KinematicBody3D::get_slide_count() const {
+int KinematicBody3D::get_slide_count() const {
return colliders.size();
}
@@ -1237,7 +1168,6 @@ KinematicBody3D::Collision KinematicBody3D::get_slide_collision(int p_bounce) co
}
Ref<KinematicCollision3D> KinematicBody3D::_get_slide_collision(int p_bounce) {
-
ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision3D>());
if (p_bounce >= slide_colliders.size()) {
slide_colliders.resize(p_bounce + 1);
@@ -1265,7 +1195,6 @@ void KinematicBody3D::_notification(int p_what) {
}
void KinematicBody3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_direct_state_changed"), &KinematicBody3D::_direct_state_changed);
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody3D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
@@ -1289,9 +1218,10 @@ void KinematicBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody3D::get_slide_count);
ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody3D::_get_slide_collision);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_x", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_y", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_z", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z);
+ ADD_GROUP("Axis Lock", "axis_lock_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_motion_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_motion_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_motion_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
}
@@ -1309,7 +1239,6 @@ void KinematicBody3D::_direct_state_changed(Object *p_state) {
KinematicBody3D::KinematicBody3D() :
PhysicsBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) {
-
margin = 0.001;
locked_axis = 0;
on_floor = false;
@@ -1318,8 +1247,8 @@ KinematicBody3D::KinematicBody3D() :
PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
}
-KinematicBody3D::~KinematicBody3D() {
+KinematicBody3D::~KinematicBody3D() {
if (motion_cache.is_valid()) {
motion_cache->owner = nullptr;
}
@@ -1330,42 +1259,46 @@ KinematicBody3D::~KinematicBody3D() {
}
}
}
+
///////////////////////////////////////
Vector3 KinematicCollision3D::get_position() const {
-
return collision.collision;
}
+
Vector3 KinematicCollision3D::get_normal() const {
return collision.normal;
}
+
Vector3 KinematicCollision3D::get_travel() const {
return collision.travel;
}
+
Vector3 KinematicCollision3D::get_remainder() const {
return collision.remainder;
}
+
Object *KinematicCollision3D::get_local_shape() const {
- if (!owner)
+ if (!owner) {
return nullptr;
+ }
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
Object *KinematicCollision3D::get_collider() const {
-
if (collision.collider.is_valid()) {
return ObjectDB::get_instance(collision.collider);
}
return nullptr;
}
-ObjectID KinematicCollision3D::get_collider_id() const {
+ObjectID KinematicCollision3D::get_collider_id() const {
return collision.collider;
}
-Object *KinematicCollision3D::get_collider_shape() const {
+Object *KinematicCollision3D::get_collider_shape() const {
Object *collider = get_collider();
if (collider) {
CollisionObject3D *obj2d = Object::cast_to<CollisionObject3D>(collider);
@@ -1377,21 +1310,20 @@ Object *KinematicCollision3D::get_collider_shape() const {
return nullptr;
}
-int KinematicCollision3D::get_collider_shape_index() const {
+int KinematicCollision3D::get_collider_shape_index() const {
return collision.collider_shape;
}
-Vector3 KinematicCollision3D::get_collider_velocity() const {
+Vector3 KinematicCollision3D::get_collider_velocity() const {
return collision.collider_vel;
}
-Variant KinematicCollision3D::get_collider_metadata() const {
+Variant KinematicCollision3D::get_collider_metadata() const {
return Variant();
}
void KinematicCollision3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision3D::get_position);
ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision3D::get_normal);
ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision3D::get_travel);
@@ -1418,7 +1350,6 @@ void KinematicCollision3D::_bind_methods() {
}
KinematicCollision3D::KinematicCollision3D() {
-
collision.collider_shape = 0;
collision.local_shape = 0;
owner = nullptr;
@@ -1470,18 +1401,21 @@ bool PhysicalBone3D::PinJointData::_set(const StringName &p_name, const Variant
if ("joint_constraints/bias" == p_name) {
bias = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_BIAS, bias);
+ }
} else if ("joint_constraints/damping" == p_name) {
damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_DAMPING, damping);
+ }
} else if ("joint_constraints/impulse_clamp" == p_name) {
impulse_clamp = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
+ }
} else {
return false;
@@ -1523,28 +1457,33 @@ bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant
if ("joint_constraints/swing_span" == p_name) {
swing_span = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
+ }
} else if ("joint_constraints/twist_span" == p_name) {
twist_span = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
+ }
} else if ("joint_constraints/bias" == p_name) {
bias = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, bias);
+ }
} else if ("joint_constraints/softness" == p_name) {
softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, softness);
+ }
} else if ("joint_constraints/relaxation" == p_name) {
relaxation = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, relaxation);
+ }
} else {
return false;
@@ -1592,33 +1531,39 @@ bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Varian
if ("joint_constraints/angular_limit_enabled" == p_name) {
angular_limit_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
+ }
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
+ }
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
+ }
} else if ("joint_constraints/angular_limit_bias" == p_name) {
angular_limit_bias = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
+ }
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
+ }
} else if ("joint_constraints/angular_limit_relaxation" == p_name) {
angular_limit_relaxation = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
+ }
} else {
return false;
@@ -1669,53 +1614,63 @@ bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Varia
if ("joint_constraints/linear_limit_upper" == p_name) {
linear_limit_upper = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
+ }
} else if ("joint_constraints/linear_limit_lower" == p_name) {
linear_limit_lower = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
+ }
} else if ("joint_constraints/linear_limit_softness" == p_name) {
linear_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
+ }
} else if ("joint_constraints/linear_limit_restitution" == p_name) {
linear_limit_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
+ }
} else if ("joint_constraints/linear_limit_damping" == p_name) {
linear_limit_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
+ }
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
+ }
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
+ }
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ }
} else if ("joint_constraints/angular_limit_restitution" == p_name) {
angular_limit_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ }
} else if ("joint_constraints/angular_limit_damping" == p_name) {
angular_limit_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
+ }
} else {
return false;
@@ -1797,108 +1752,129 @@ bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Varia
if ("linear_limit_enabled" == var_name) {
axis_data[axis].linear_limit_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled);
+ }
} else if ("linear_limit_upper" == var_name) {
axis_data[axis].linear_limit_upper = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper);
+ }
} else if ("linear_limit_lower" == var_name) {
axis_data[axis].linear_limit_lower = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower);
+ }
} else if ("linear_limit_softness" == var_name) {
axis_data[axis].linear_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness);
+ }
} else if ("linear_spring_enabled" == var_name) {
axis_data[axis].linear_spring_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled);
+ }
} else if ("linear_spring_stiffness" == var_name) {
axis_data[axis].linear_spring_stiffness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness);
+ }
} else if ("linear_spring_damping" == var_name) {
axis_data[axis].linear_spring_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping);
+ }
} else if ("linear_equilibrium_point" == var_name) {
axis_data[axis].linear_equilibrium_point = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point);
+ }
} else if ("linear_restitution" == var_name) {
axis_data[axis].linear_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution);
+ }
} else if ("linear_damping" == var_name) {
axis_data[axis].linear_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping);
+ }
} else if ("angular_limit_enabled" == var_name) {
axis_data[axis].angular_limit_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled);
+ }
} else if ("angular_limit_upper" == var_name) {
axis_data[axis].angular_limit_upper = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper);
+ }
} else if ("angular_limit_lower" == var_name) {
axis_data[axis].angular_limit_lower = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower);
+ }
} else if ("angular_limit_softness" == var_name) {
axis_data[axis].angular_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness);
+ }
} else if ("angular_restitution" == var_name) {
axis_data[axis].angular_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution);
+ }
} else if ("angular_damping" == var_name) {
axis_data[axis].angular_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping);
+ }
} else if ("erp" == var_name) {
axis_data[axis].erp = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp);
+ }
} else if ("angular_spring_enabled" == var_name) {
axis_data[axis].angular_spring_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled);
+ }
} else if ("angular_spring_stiffness" == var_name) {
axis_data[axis].angular_spring_stiffness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness);
+ }
} else if ("angular_spring_damping" == var_name) {
axis_data[axis].angular_spring_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping);
+ }
} else if ("angular_equilibrium_point" == var_name) {
axis_data[axis].angular_equilibrium_point = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point);
+ }
} else {
return false;
@@ -2015,8 +1991,9 @@ bool PhysicalBone3D::_set(const StringName &p_name, const Variant &p_value) {
if (joint_data) {
if (joint_data->_set(p_name, p_value)) {
#ifdef TOOLS_ENABLED
- if (get_gizmo().is_valid())
+ if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
+ }
#endif
return true;
}
@@ -2039,21 +2016,19 @@ bool PhysicalBone3D::_get(const StringName &p_name, Variant &r_ret) const {
}
void PhysicalBone3D::_get_property_list(List<PropertyInfo> *p_list) const {
-
Skeleton3D *parent = find_skeleton_parent(get_parent());
if (parent) {
-
String names;
for (int i = 0; i < parent->get_bone_count(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += parent->get_bone_name(i);
}
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name", PROPERTY_HINT_ENUM, names));
} else {
-
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "bone_name"));
}
@@ -2087,7 +2062,6 @@ void PhysicalBone3D::_notification(int p_what) {
break;
case NOTIFICATION_TRANSFORM_CHANGED:
if (Engine::get_singleton()->is_editor_hint()) {
-
update_offset();
}
break;
@@ -2095,7 +2069,6 @@ void PhysicalBone3D::_notification(int p_what) {
}
void PhysicalBone3D::_direct_state_changed(Object *p_state) {
-
if (!simulate_physics || !_internal_simulate_physics) {
return;
}
@@ -2225,8 +2198,9 @@ void PhysicalBone3D::_update_joint_offset() {
set_ignore_transform_notification(false);
#ifdef TOOLS_ENABLED
- if (get_gizmo().is_valid())
+ if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
+ }
#endif
}
@@ -2238,7 +2212,6 @@ void PhysicalBone3D::_fix_joint_offset() {
}
void PhysicalBone3D::_reload_joint() {
-
if (joint.is_valid()) {
PhysicsServer3D::get_singleton()->free(joint);
joint = RID();
@@ -2259,7 +2232,6 @@ void PhysicalBone3D::_reload_joint() {
switch (get_joint_type()) {
case JOINT_TYPE_PIN: {
-
joint = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin);
const PinJointData *pjd(static_cast<const PinJointData *>(joint_data));
PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_BIAS, pjd->bias);
@@ -2268,7 +2240,6 @@ void PhysicalBone3D::_reload_joint() {
} break;
case JOINT_TYPE_CONE: {
-
joint = PhysicsServer3D::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, get_rid(), joint_offset);
const ConeJointData *cjd(static_cast<const ConeJointData *>(joint_data));
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span);
@@ -2279,7 +2250,6 @@ void PhysicalBone3D::_reload_joint() {
} break;
case JOINT_TYPE_HINGE: {
-
joint = PhysicsServer3D::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, get_rid(), joint_offset);
const HingeJointData *hjd(static_cast<const HingeJointData *>(joint_data));
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled);
@@ -2291,7 +2261,6 @@ void PhysicalBone3D::_reload_joint() {
} break;
case JOINT_TYPE_SLIDER: {
-
joint = PhysicsServer3D::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, get_rid(), joint_offset);
const SliderJointData *sjd(static_cast<const SliderJointData *>(joint_data));
PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper);
@@ -2307,7 +2276,6 @@ void PhysicalBone3D::_reload_joint() {
} break;
case JOINT_TYPE_6DOF: {
-
joint = PhysicsServer3D::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, get_rid(), joint_offset);
const SixDOFJointData *g6dofjd(static_cast<const SixDOFJointData *>(joint_data));
for (int axis = 0; axis < 3; ++axis) {
@@ -2370,12 +2338,13 @@ Skeleton3D *PhysicalBone3D::find_skeleton_parent() {
}
void PhysicalBone3D::set_joint_type(JointType p_joint_type) {
-
- if (p_joint_type == get_joint_type())
+ if (p_joint_type == get_joint_type()) {
return;
+ }
- if (joint_data)
+ if (joint_data) {
memdelete(joint_data);
+ }
joint_data = nullptr;
switch (p_joint_type) {
case JOINT_TYPE_PIN:
@@ -2401,8 +2370,9 @@ void PhysicalBone3D::set_joint_type(JointType p_joint_type) {
#ifdef TOOLS_ENABLED
_change_notify();
- if (get_gizmo().is_valid())
+ if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
+ }
#endif
}
@@ -2469,7 +2439,6 @@ bool PhysicalBone3D::is_simulating_physics() {
}
void PhysicalBone3D::set_bone_name(const String &p_name) {
-
bone_name = p_name;
bone_id = -1;
@@ -2478,34 +2447,28 @@ void PhysicalBone3D::set_bone_name(const String &p_name) {
}
const String &PhysicalBone3D::get_bone_name() const {
-
return bone_name;
}
void PhysicalBone3D::set_mass(real_t p_mass) {
-
ERR_FAIL_COND(p_mass <= 0);
mass = p_mass;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
}
real_t PhysicalBone3D::get_mass() const {
-
return mass;
}
void PhysicalBone3D::set_weight(real_t p_weight) {
-
set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)));
}
real_t PhysicalBone3D::get_weight() const {
-
return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
}
void PhysicalBone3D::set_friction(real_t p_friction) {
-
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
friction = p_friction;
@@ -2513,12 +2476,10 @@ void PhysicalBone3D::set_friction(real_t p_friction) {
}
real_t PhysicalBone3D::get_friction() const {
-
return friction;
}
void PhysicalBone3D::set_bounce(real_t p_bounce) {
-
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
bounce = p_bounce;
@@ -2526,18 +2487,15 @@ void PhysicalBone3D::set_bounce(real_t p_bounce) {
}
real_t PhysicalBone3D::get_bounce() const {
-
return bounce;
}
void PhysicalBone3D::set_gravity_scale(real_t p_gravity_scale) {
-
gravity_scale = p_gravity_scale;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
real_t PhysicalBone3D::get_gravity_scale() const {
-
return gravity_scale;
}
@@ -2579,30 +2537,14 @@ bool PhysicalBone3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const {
}
PhysicalBone3D::PhysicalBone3D() :
- PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC),
-#ifdef TOOLS_ENABLED
- gizmo_move_joint(false),
-#endif
- joint_data(nullptr),
- parent_skeleton(nullptr),
- simulate_physics(false),
- _internal_simulate_physics(false),
- bone_id(-1),
- bone_name(""),
- bounce(0),
- mass(1),
- friction(1),
- gravity_scale(1),
- linear_damp(-1),
- angular_damp(-1),
- can_sleep(true) {
-
+ PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC) {
reset_physics_simulation_state();
}
PhysicalBone3D::~PhysicalBone3D() {
- if (joint_data)
+ if (joint_data) {
memdelete(joint_data);
+ }
}
void PhysicalBone3D::update_bone_id() {
@@ -2631,10 +2573,10 @@ void PhysicalBone3D::update_bone_id() {
void PhysicalBone3D::update_offset() {
#ifdef TOOLS_ENABLED
if (parent_skeleton) {
-
Transform bone_transform(parent_skeleton->get_global_transform());
- if (-1 != bone_id)
+ if (-1 != bone_id) {
bone_transform *= parent_skeleton->get_bone_global_pose(bone_id);
+ }
if (gizmo_move_joint) {
bone_transform *= body_offset;
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index 0e719f5108..4c58c73942 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -38,7 +38,6 @@
#include "skeleton_3d.h"
class PhysicsBody3D : public CollisionObject3D {
-
GDCLASS(PhysicsBody3D, CollisionObject3D);
uint32_t collision_layer;
@@ -76,7 +75,6 @@ public:
};
class StaticBody3D : public PhysicsBody3D {
-
GDCLASS(StaticBody3D, PhysicsBody3D);
Vector3 constant_linear_velocity;
@@ -105,7 +103,6 @@ private:
};
class RigidBody3D : public PhysicsBody3D {
-
GDCLASS(RigidBody3D, PhysicsBody3D);
public:
@@ -138,15 +135,15 @@ protected:
bool custom_integrator;
struct ShapePair {
-
int body_shape;
int local_shape;
bool tagged;
bool operator<(const ShapePair &p_sp) const {
- if (body_shape == p_sp.body_shape)
+ if (body_shape == p_sp.body_shape) {
return local_shape < p_sp.local_shape;
- else
+ } else {
return body_shape < p_sp.body_shape;
+ }
}
ShapePair() {}
@@ -157,19 +154,16 @@ protected:
}
};
struct RigidBody3D_RemoveAction {
-
ObjectID body_id;
ShapePair pair;
};
struct BodyState {
-
//int rc;
bool in_tree;
VSet<ShapePair> shapes;
};
struct ContactMonitor {
-
bool locked;
Map<ObjectID, BodyState> body_map;
};
@@ -261,7 +255,6 @@ VARIANT_ENUM_CAST(RigidBody3D::Mode);
class KinematicCollision3D;
class KinematicBody3D : public PhysicsBody3D {
-
GDCLASS(KinematicBody3D, PhysicsBody3D);
public:
@@ -338,7 +331,6 @@ public:
};
class KinematicCollision3D : public Reference {
-
GDCLASS(KinematicCollision3D, Reference);
KinematicBody3D *owner;
@@ -365,7 +357,6 @@ public:
};
class PhysicalBone3D : public PhysicsBody3D {
-
GDCLASS(PhysicalBone3D, PhysicsBody3D);
public:
@@ -396,14 +387,11 @@ public:
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
- real_t bias;
- real_t damping;
- real_t impulse_clamp;
+ real_t bias = 0.3;
+ real_t damping = 1.;
+ real_t impulse_clamp = 0;
- PinJointData() :
- bias(0.3),
- damping(1.),
- impulse_clamp(0) {}
+ PinJointData() {}
};
struct ConeJointData : public JointData {
@@ -414,17 +402,13 @@ public:
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
real_t swing_span;
- real_t twist_span;
- real_t bias;
- real_t softness;
- real_t relaxation;
+ real_t twist_span = Math_PI;
+ real_t bias = 0.3;
+ real_t softness = 0.8;
+ real_t relaxation = 1.;
ConeJointData() :
- swing_span(Math_PI * 0.25),
- twist_span(Math_PI),
- bias(0.3),
- softness(0.8),
- relaxation(1.) {}
+ swing_span(Math_PI * 0.25) {}
};
struct HingeJointData : public JointData {
@@ -434,20 +418,17 @@ public:
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
- bool angular_limit_enabled;
+ bool angular_limit_enabled = false;
real_t angular_limit_upper;
real_t angular_limit_lower;
- real_t angular_limit_bias;
- real_t angular_limit_softness;
- real_t angular_limit_relaxation;
+ real_t angular_limit_bias = 0.3;
+ real_t angular_limit_softness = 0.9;
+ real_t angular_limit_relaxation = 1.;
HingeJointData() :
- angular_limit_enabled(false),
+
angular_limit_upper(Math_PI * 0.5),
- angular_limit_lower(-Math_PI * 0.5),
- angular_limit_bias(0.3),
- angular_limit_softness(0.9),
- angular_limit_relaxation(1.) {}
+ angular_limit_lower(-Math_PI * 0.5) {}
};
struct SliderJointData : public JointData {
@@ -457,76 +438,45 @@ public:
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
- real_t linear_limit_upper;
- real_t linear_limit_lower;
- real_t linear_limit_softness;
- real_t linear_limit_restitution;
- real_t linear_limit_damping;
- real_t angular_limit_upper;
- real_t angular_limit_lower;
- real_t angular_limit_softness;
- real_t angular_limit_restitution;
- real_t angular_limit_damping;
-
- SliderJointData() :
- linear_limit_upper(1.),
- linear_limit_lower(-1.),
- linear_limit_softness(1.),
- linear_limit_restitution(0.7),
- linear_limit_damping(1.),
- angular_limit_upper(0),
- angular_limit_lower(0),
- angular_limit_softness(1.),
- angular_limit_restitution(0.7),
- angular_limit_damping(1.) {}
+ real_t linear_limit_upper = 1.;
+ real_t linear_limit_lower = -1.;
+ real_t linear_limit_softness = 1.;
+ real_t linear_limit_restitution = 0.7;
+ real_t linear_limit_damping = 1.;
+ real_t angular_limit_upper = 0;
+ real_t angular_limit_lower = 0;
+ real_t angular_limit_softness = 1.;
+ real_t angular_limit_restitution = 0.7;
+ real_t angular_limit_damping = 1.;
+
+ SliderJointData() {}
};
struct SixDOFJointData : public JointData {
struct SixDOFAxisData {
- bool linear_limit_enabled;
- real_t linear_limit_upper;
- real_t linear_limit_lower;
- real_t linear_limit_softness;
- real_t linear_restitution;
- real_t linear_damping;
- bool linear_spring_enabled;
- real_t linear_spring_stiffness;
- real_t linear_spring_damping;
- real_t linear_equilibrium_point;
- bool angular_limit_enabled;
- real_t angular_limit_upper;
- real_t angular_limit_lower;
- real_t angular_limit_softness;
- real_t angular_restitution;
- real_t angular_damping;
- real_t erp;
- bool angular_spring_enabled;
- real_t angular_spring_stiffness;
- real_t angular_spring_damping;
- real_t angular_equilibrium_point;
-
- SixDOFAxisData() :
- linear_limit_enabled(true),
- linear_limit_upper(0),
- linear_limit_lower(0),
- linear_limit_softness(0.7),
- linear_restitution(0.5),
- linear_damping(1.),
- linear_spring_enabled(false),
- linear_spring_stiffness(0),
- linear_spring_damping(0),
- linear_equilibrium_point(0),
- angular_limit_enabled(true),
- angular_limit_upper(0),
- angular_limit_lower(0),
- angular_limit_softness(0.5),
- angular_restitution(0),
- angular_damping(1.),
- erp(0.5),
- angular_spring_enabled(false),
- angular_spring_stiffness(0),
- angular_spring_damping(0.),
- angular_equilibrium_point(0) {}
+ bool linear_limit_enabled = true;
+ real_t linear_limit_upper = 0;
+ real_t linear_limit_lower = 0;
+ real_t linear_limit_softness = 0.7;
+ real_t linear_restitution = 0.5;
+ real_t linear_damping = 1.;
+ bool linear_spring_enabled = false;
+ real_t linear_spring_stiffness = 0;
+ real_t linear_spring_damping = 0;
+ real_t linear_equilibrium_point = 0;
+ bool angular_limit_enabled = true;
+ real_t angular_limit_upper = 0;
+ real_t angular_limit_lower = 0;
+ real_t angular_limit_softness = 0.5;
+ real_t angular_restitution = 0;
+ real_t angular_damping = 1.;
+ real_t erp = 0.5;
+ bool angular_spring_enabled = false;
+ real_t angular_spring_stiffness = 0;
+ real_t angular_spring_damping = 0.;
+ real_t angular_equilibrium_point = 0;
+
+ SixDOFAxisData() {}
};
virtual JointType get_joint_type() { return JOINT_TYPE_6DOF; }
@@ -543,28 +493,28 @@ public:
private:
#ifdef TOOLS_ENABLED
// if false gizmo move body
- bool gizmo_move_joint;
+ bool gizmo_move_joint = false;
#endif
- JointData *joint_data;
+ JointData *joint_data = nullptr;
Transform joint_offset;
RID joint;
- Skeleton3D *parent_skeleton;
+ Skeleton3D *parent_skeleton = nullptr;
Transform body_offset;
Transform body_offset_inverse;
- bool simulate_physics;
- bool _internal_simulate_physics;
- int bone_id;
+ bool simulate_physics = false;
+ bool _internal_simulate_physics = false;
+ int bone_id = -1;
String bone_name;
- real_t bounce;
- real_t mass;
- real_t friction;
- real_t gravity_scale;
- real_t linear_damp;
- real_t angular_damp;
- bool can_sleep;
+ real_t bounce = 0;
+ real_t mass = 1;
+ real_t friction = 1;
+ real_t gravity_scale = 1;
+ real_t linear_damp = -1;
+ real_t angular_damp = -1;
+ bool can_sleep = true;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp
index 140d887d9a..af4d6ae152 100644
--- a/scene/3d/physics_joint_3d.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -31,10 +31,10 @@
#include "physics_joint_3d.h"
void Joint3D::_update_joint(bool p_only_free) {
-
if (joint.is_valid()) {
- if (ba.is_valid() && bb.is_valid())
+ if (ba.is_valid() && bb.is_valid()) {
PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb);
+ }
PhysicsServer3D::get_singleton()->free(joint);
joint = RID();
@@ -42,8 +42,9 @@ void Joint3D::_update_joint(bool p_only_free) {
bb = RID();
}
- if (p_only_free || !is_inside_tree())
+ if (p_only_free || !is_inside_tree()) {
return;
+ }
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr;
@@ -51,68 +52,68 @@ void Joint3D::_update_joint(bool p_only_free) {
PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a);
PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b);
- if (!body_a && body_b)
+ if (!body_a && body_b) {
SWAP(body_a, body_b);
+ }
- if (!body_a)
+ if (!body_a) {
return;
+ }
joint = _configure_joint(body_a, body_b);
- if (!joint.is_valid())
+ if (!joint.is_valid()) {
return;
+ }
PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
ba = body_a->get_rid();
- if (body_b)
+ if (body_b) {
bb = body_b->get_rid();
+ }
PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
}
void Joint3D::set_node_a(const NodePath &p_node_a) {
-
- if (a == p_node_a)
+ if (a == p_node_a) {
return;
+ }
a = p_node_a;
_update_joint();
}
NodePath Joint3D::get_node_a() const {
-
return a;
}
void Joint3D::set_node_b(const NodePath &p_node_b) {
-
- if (b == p_node_b)
+ if (b == p_node_b) {
return;
+ }
b = p_node_b;
_update_joint();
}
-NodePath Joint3D::get_node_b() const {
+NodePath Joint3D::get_node_b() const {
return b;
}
void Joint3D::set_solver_priority(int p_priority) {
-
solver_priority = p_priority;
- if (joint.is_valid())
+ if (joint.is_valid()) {
PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
+ }
}
int Joint3D::get_solver_priority() const {
-
return solver_priority;
}
void Joint3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
_update_joint();
} break;
@@ -125,20 +126,18 @@ void Joint3D::_notification(int p_what) {
}
void Joint3D::set_exclude_nodes_from_collision(bool p_enable) {
-
- if (exclude_from_collision == p_enable)
+ if (exclude_from_collision == p_enable) {
return;
+ }
exclude_from_collision = p_enable;
_update_joint();
}
bool Joint3D::get_exclude_nodes_from_collision() const {
-
return exclude_from_collision;
}
void Joint3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint3D::set_node_a);
ClassDB::bind_method(D_METHOD("get_node_a"), &Joint3D::get_node_a);
@@ -159,7 +158,6 @@ void Joint3D::_bind_methods() {
}
Joint3D::Joint3D() {
-
exclude_from_collision = true;
solver_priority = 1;
set_notify_transform(true);
@@ -168,7 +166,6 @@ Joint3D::Joint3D() {
///////////////////////////////////
void PinJoint3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &PinJoint3D::set_param);
ClassDB::bind_method(D_METHOD("get_param", "param"), &PinJoint3D::get_param);
@@ -182,28 +179,28 @@ void PinJoint3D::_bind_methods() {
}
void PinJoint3D::set_param(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, 3);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value);
+ }
}
-float PinJoint3D::get_param(Param p_param) const {
+float PinJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, 3, 0);
return params[p_param];
}
RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
-
Vector3 pinpos = get_global_transform().origin;
Vector3 local_a = body_a->get_global_transform().affine_inverse().xform(pinpos);
Vector3 local_b;
- if (body_b)
+ if (body_b) {
local_b = body_b->get_global_transform().affine_inverse().xform(pinpos);
- else
+ } else {
local_b = pinpos;
+ }
RID j = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < 3; i++) {
@@ -213,7 +210,6 @@ RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
}
PinJoint3D::PinJoint3D() {
-
params[PARAM_BIAS] = 0.3;
params[PARAM_DAMPING] = 1;
params[PARAM_IMPULSE_CLAMP] = 0;
@@ -224,27 +220,22 @@ PinJoint3D::PinJoint3D() {
///////////////////////////////////
void HingeJoint3D::_set_upper_limit(float p_limit) {
-
set_param(PARAM_LIMIT_UPPER, Math::deg2rad(p_limit));
}
float HingeJoint3D::_get_upper_limit() const {
-
return Math::rad2deg(get_param(PARAM_LIMIT_UPPER));
}
void HingeJoint3D::_set_lower_limit(float p_limit) {
-
set_param(PARAM_LIMIT_LOWER, Math::deg2rad(p_limit));
}
float HingeJoint3D::_get_lower_limit() const {
-
return Math::rad2deg(get_param(PARAM_LIMIT_LOWER));
}
void HingeJoint3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &HingeJoint3D::set_param);
ClassDB::bind_method(D_METHOD("get_param", "param"), &HingeJoint3D::get_param);
@@ -286,37 +277,36 @@ void HingeJoint3D::_bind_methods() {
}
void HingeJoint3D::set_param(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value);
+ }
update_gizmo();
}
-float HingeJoint3D::get_param(Param p_param) const {
+float HingeJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
void HingeJoint3D::set_flag(Flag p_flag, bool p_value) {
-
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
+ }
update_gizmo();
}
-bool HingeJoint3D::get_flag(Flag p_flag) const {
+bool HingeJoint3D::get_flag(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
RID HingeJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
-
Transform gt = get_global_transform();
Transform ainv = body_a->get_global_transform().affine_inverse();
@@ -343,7 +333,6 @@ RID HingeJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b)
}
HingeJoint3D::HingeJoint3D() {
-
params[PARAM_BIAS] = 0.3;
params[PARAM_LIMIT_UPPER] = Math_PI * 0.5;
params[PARAM_LIMIT_LOWER] = -Math_PI * 0.5;
@@ -362,27 +351,22 @@ HingeJoint3D::HingeJoint3D() {
//////////////////////////////////
void SliderJoint3D::_set_upper_limit_angular(float p_limit_angular) {
-
set_param(PARAM_ANGULAR_LIMIT_UPPER, Math::deg2rad(p_limit_angular));
}
float SliderJoint3D::_get_upper_limit_angular() const {
-
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_UPPER));
}
void SliderJoint3D::_set_lower_limit_angular(float p_limit_angular) {
-
set_param(PARAM_ANGULAR_LIMIT_LOWER, Math::deg2rad(p_limit_angular));
}
float SliderJoint3D::_get_lower_limit_angular() const {
-
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_LOWER));
}
void SliderJoint3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &SliderJoint3D::set_param);
ClassDB::bind_method(D_METHOD("get_param", "param"), &SliderJoint3D::get_param);
@@ -444,21 +428,20 @@ void SliderJoint3D::_bind_methods() {
}
void SliderJoint3D::set_param(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value);
+ }
update_gizmo();
}
-float SliderJoint3D::get_param(Param p_param) const {
+float SliderJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
RID SliderJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
-
Transform gt = get_global_transform();
Transform ainv = body_a->get_global_transform().affine_inverse();
@@ -482,7 +465,6 @@ RID SliderJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b
}
SliderJoint3D::SliderJoint3D() {
-
params[PARAM_LINEAR_LIMIT_UPPER] = 1.0;
params[PARAM_LINEAR_LIMIT_LOWER] = -1.0;
params[PARAM_LINEAR_LIMIT_SOFTNESS] = 1.0;
@@ -511,27 +493,22 @@ SliderJoint3D::SliderJoint3D() {
//////////////////////////////////
void ConeTwistJoint3D::_set_swing_span(float p_limit_angular) {
-
set_param(PARAM_SWING_SPAN, Math::deg2rad(p_limit_angular));
}
float ConeTwistJoint3D::_get_swing_span() const {
-
return Math::rad2deg(get_param(PARAM_SWING_SPAN));
}
void ConeTwistJoint3D::_set_twist_span(float p_limit_angular) {
-
set_param(PARAM_TWIST_SPAN, Math::deg2rad(p_limit_angular));
}
float ConeTwistJoint3D::_get_twist_span() const {
-
return Math::rad2deg(get_param(PARAM_TWIST_SPAN));
}
void ConeTwistJoint3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ConeTwistJoint3D::set_param);
ClassDB::bind_method(D_METHOD("get_param", "param"), &ConeTwistJoint3D::get_param);
@@ -557,22 +534,21 @@ void ConeTwistJoint3D::_bind_methods() {
}
void ConeTwistJoint3D::set_param(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
+ }
update_gizmo();
}
-float ConeTwistJoint3D::get_param(Param p_param) const {
+float ConeTwistJoint3D::get_param(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
RID ConeTwistJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
-
Transform gt = get_global_transform();
//Vector3 cone_twistpos = gt.origin;
//Vector3 cone_twistdir = gt.basis.get_axis(2);
@@ -599,7 +575,6 @@ RID ConeTwistJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *bod
}
ConeTwistJoint3D::ConeTwistJoint3D() {
-
params[PARAM_SWING_SPAN] = Math_PI * 0.25;
params[PARAM_TWIST_SPAN] = Math_PI;
params[PARAM_BIAS] = 0.3;
@@ -610,67 +585,54 @@ ConeTwistJoint3D::ConeTwistJoint3D() {
/////////////////////////////////////////////////////////////////////
void Generic6DOFJoint3D::_set_angular_hi_limit_x(float p_limit_angular) {
-
set_param_x(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
float Generic6DOFJoint3D::_get_angular_hi_limit_x() const {
-
return Math::rad2deg(get_param_x(PARAM_ANGULAR_UPPER_LIMIT));
}
void Generic6DOFJoint3D::_set_angular_lo_limit_x(float p_limit_angular) {
-
set_param_x(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
float Generic6DOFJoint3D::_get_angular_lo_limit_x() const {
-
return Math::rad2deg(get_param_x(PARAM_ANGULAR_LOWER_LIMIT));
}
void Generic6DOFJoint3D::_set_angular_hi_limit_y(float p_limit_angular) {
-
set_param_y(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
float Generic6DOFJoint3D::_get_angular_hi_limit_y() const {
-
return Math::rad2deg(get_param_y(PARAM_ANGULAR_UPPER_LIMIT));
}
void Generic6DOFJoint3D::_set_angular_lo_limit_y(float p_limit_angular) {
-
set_param_y(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
float Generic6DOFJoint3D::_get_angular_lo_limit_y() const {
-
return Math::rad2deg(get_param_y(PARAM_ANGULAR_LOWER_LIMIT));
}
void Generic6DOFJoint3D::_set_angular_hi_limit_z(float p_limit_angular) {
-
set_param_z(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
float Generic6DOFJoint3D::_get_angular_hi_limit_z() const {
-
return Math::rad2deg(get_param_z(PARAM_ANGULAR_UPPER_LIMIT));
}
void Generic6DOFJoint3D::_set_angular_lo_limit_z(float p_limit_angular) {
-
set_param_z(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
float Generic6DOFJoint3D::_get_angular_lo_limit_z() const {
-
return Math::rad2deg(get_param_z(PARAM_ANGULAR_LOWER_LIMIT));
}
void Generic6DOFJoint3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_x", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_x);
ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_x"), &Generic6DOFJoint3D::_get_angular_hi_limit_x);
@@ -834,86 +796,86 @@ void Generic6DOFJoint3D::_bind_methods() {
}
void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_x[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ }
update_gizmo();
}
-float Generic6DOFJoint3D::get_param_x(Param p_param) const {
+float Generic6DOFJoint3D::get_param_x(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_x[p_param];
}
void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_y[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ }
update_gizmo();
}
-float Generic6DOFJoint3D::get_param_y(Param p_param) const {
+float Generic6DOFJoint3D::get_param_y(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_y[p_param];
}
void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_z[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ }
update_gizmo();
}
-float Generic6DOFJoint3D::get_param_z(Param p_param) const {
+float Generic6DOFJoint3D::get_param_z(Param p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_z[p_param];
}
void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) {
-
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_x[p_flag] = p_enabled;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ }
update_gizmo();
}
-bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const {
+bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_x[p_flag];
}
void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) {
-
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_y[p_flag] = p_enabled;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ }
update_gizmo();
}
-bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const {
+bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_y[p_flag];
}
void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) {
-
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_z[p_flag] = p_enabled;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ }
update_gizmo();
}
-bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const {
+bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_z[p_flag];
}
@@ -927,7 +889,6 @@ void Generic6DOFJoint3D::set_precision(int p_precision) {
}
RID Generic6DOFJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
-
Transform gt = get_global_transform();
//Vector3 cone_twistpos = gt.origin;
//Vector3 cone_twistdir = gt.basis.get_axis(2);
@@ -960,9 +921,7 @@ RID Generic6DOFJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *b
return j;
}
-Generic6DOFJoint3D::Generic6DOFJoint3D() :
- precision(1) {
-
+Generic6DOFJoint3D::Generic6DOFJoint3D() {
set_param_x(PARAM_LINEAR_LOWER_LIMIT, 0);
set_param_x(PARAM_LINEAR_UPPER_LIMIT, 0);
set_param_x(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h
index ce0c7af5d1..a3225ab01c 100644
--- a/scene/3d/physics_joint_3d.h
+++ b/scene/3d/physics_joint_3d.h
@@ -35,7 +35,6 @@
#include "scene/3d/physics_body_3d.h"
class Joint3D : public Node3D {
-
GDCLASS(Joint3D, Node3D);
RID ba, bb;
@@ -77,7 +76,6 @@ public:
///////////////////////////////////////////
class PinJoint3D : public Joint3D {
-
GDCLASS(PinJoint3D, Joint3D);
public:
@@ -102,7 +100,6 @@ public:
VARIANT_ENUM_CAST(PinJoint3D::Param);
class HingeJoint3D : public Joint3D {
-
GDCLASS(HingeJoint3D, Joint3D);
public:
@@ -150,7 +147,6 @@ VARIANT_ENUM_CAST(HingeJoint3D::Param);
VARIANT_ENUM_CAST(HingeJoint3D::Flag);
class SliderJoint3D : public Joint3D {
-
GDCLASS(SliderJoint3D, Joint3D);
public:
@@ -203,7 +199,6 @@ public:
VARIANT_ENUM_CAST(SliderJoint3D::Param);
class ConeTwistJoint3D : public Joint3D {
-
GDCLASS(ConeTwistJoint3D, Joint3D);
public:
@@ -238,7 +233,6 @@ public:
VARIANT_ENUM_CAST(ConeTwistJoint3D::Param);
class Generic6DOFJoint3D : public Joint3D {
-
GDCLASS(Generic6DOFJoint3D, Joint3D);
public:
@@ -305,7 +299,7 @@ protected:
float params_z[PARAM_MAX];
bool flags_z[FLAG_MAX];
- int precision;
+ int precision = 1;
virtual RID _configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b);
static void _bind_methods();
diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h
index 9c806723fb..1c5f05ef95 100644
--- a/scene/3d/position_3d.h
+++ b/scene/3d/position_3d.h
@@ -34,7 +34,6 @@
#include "scene/3d/node_3d.h"
class Position3D : public Node3D {
-
GDCLASS(Position3D, Node3D);
public:
diff --git a/scene/3d/proximity_group_3d.cpp b/scene/3d/proximity_group_3d.cpp
index 44ffabb655..1a0677c603 100644
--- a/scene/3d/proximity_group_3d.cpp
+++ b/scene/3d/proximity_group_3d.cpp
@@ -33,7 +33,6 @@
#include "core/math/math_funcs.h"
void ProximityGroup3D::clear_groups() {
-
Map<StringName, uint32_t>::Element *E;
{
@@ -42,7 +41,6 @@ void ProximityGroup3D::clear_groups() {
E = groups.front();
int num = 0;
while (E && num < size) {
-
if (E->get() != group_version) {
remove_list[num++] = E->key();
};
@@ -50,7 +48,6 @@ void ProximityGroup3D::clear_groups() {
E = E->next();
};
for (int i = 0; i < num; i++) {
-
groups.erase(remove_list[i]);
};
};
@@ -61,9 +58,9 @@ void ProximityGroup3D::clear_groups() {
};
void ProximityGroup3D::update_groups() {
-
- if (grid_radius == Vector3(0, 0, 0))
+ if (grid_radius == Vector3(0, 0, 0)) {
return;
+ }
++group_version;
@@ -77,10 +74,8 @@ void ProximityGroup3D::update_groups() {
};
void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) {
-
p_base = p_base + "|";
if (grid_radius[p_depth] == 0) {
-
if (p_depth == 2) {
_new_group(p_base);
} else {
@@ -92,7 +87,6 @@ void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) {
int end = p_cell[p_depth] + grid_radius[p_depth];
for (int i = start; i <= end; i++) {
-
String gname = p_base + itos(i);
if (p_depth == 2) {
_new_group(gname);
@@ -103,7 +97,6 @@ void ProximityGroup3D::add_groups(int *p_cell, String p_base, int p_depth) {
};
void ProximityGroup3D::_new_group(StringName p_name) {
-
const Map<StringName, uint32_t>::Element *E = groups.find(p_name);
if (!E) {
add_to_group(p_name);
@@ -113,9 +106,7 @@ void ProximityGroup3D::_new_group(StringName p_name) {
};
void ProximityGroup3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_EXIT_TREE:
++group_version;
clear_groups();
@@ -127,59 +118,47 @@ void ProximityGroup3D::_notification(int p_what) {
};
void ProximityGroup3D::broadcast(String p_name, Variant p_params) {
-
Map<StringName, uint32_t>::Element *E;
E = groups.front();
while (E) {
-
get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params);
E = E->next();
};
};
void ProximityGroup3D::_proximity_group_broadcast(String p_name, Variant p_params) {
-
if (dispatch_mode == MODE_PROXY) {
-
get_parent()->call(p_name, p_params);
} else {
-
emit_signal("broadcast", p_name, p_params);
};
};
void ProximityGroup3D::set_group_name(const String &p_group_name) {
-
group_name = p_group_name;
};
String ProximityGroup3D::get_group_name() const {
-
return group_name;
};
void ProximityGroup3D::set_dispatch_mode(DispatchMode p_mode) {
-
dispatch_mode = p_mode;
};
ProximityGroup3D::DispatchMode ProximityGroup3D::get_dispatch_mode() const {
-
return dispatch_mode;
};
void ProximityGroup3D::set_grid_radius(const Vector3 &p_radius) {
-
grid_radius = p_radius;
};
Vector3 ProximityGroup3D::get_grid_radius() const {
-
return grid_radius;
};
void ProximityGroup3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_group_name", "name"), &ProximityGroup3D::set_group_name);
ClassDB::bind_method(D_METHOD("get_group_name"), &ProximityGroup3D::get_group_name);
ClassDB::bind_method(D_METHOD("set_dispatch_mode", "mode"), &ProximityGroup3D::set_dispatch_mode);
@@ -200,15 +179,5 @@ void ProximityGroup3D::_bind_methods() {
};
ProximityGroup3D::ProximityGroup3D() {
-
- group_version = 0;
- dispatch_mode = MODE_PROXY;
-
- cell_size = 1.0;
- grid_radius = Vector3(1, 1, 1);
set_notify_transform(true);
};
-
-ProximityGroup3D::~ProximityGroup3D(){
-
-};
diff --git a/scene/3d/proximity_group_3d.h b/scene/3d/proximity_group_3d.h
index 751bfbdb52..dd3a2f0a87 100644
--- a/scene/3d/proximity_group_3d.h
+++ b/scene/3d/proximity_group_3d.h
@@ -34,7 +34,6 @@
#include "node_3d.h"
class ProximityGroup3D : public Node3D {
-
GDCLASS(ProximityGroup3D, Node3D);
OBJ_CATEGORY("3D");
@@ -50,14 +49,14 @@ public:
void _notification(int p_what);
- DispatchMode dispatch_mode;
+ DispatchMode dispatch_mode = MODE_PROXY;
Map<StringName, uint32_t> groups;
String group_name;
- float cell_size;
- Vector3 grid_radius;
- uint32_t group_version;
+ float cell_size = 1.0;
+ Vector3 grid_radius = Vector3(1, 1, 1);
+ uint32_t group_version = 0;
void add_groups(int *p_cell, String p_base, int p_depth);
void _new_group(StringName p_name);
@@ -79,7 +78,7 @@ public:
void broadcast(String p_name, Variant p_params);
ProximityGroup3D();
- ~ProximityGroup3D();
+ ~ProximityGroup3D() {}
};
VARIANT_ENUM_CAST(ProximityGroup3D::DispatchMode);
diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp
index 304a5e1254..68f4b3132c 100644
--- a/scene/3d/ray_cast_3d.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -36,151 +36,149 @@
#include "servers/physics_server_3d.h"
void RayCast3D::set_cast_to(const Vector3 &p_point) {
-
cast_to = p_point;
- if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) {
update_gizmo();
- if (is_inside_tree() && get_tree()->is_debugging_collisions_hint())
+ }
+ if (is_inside_tree() && get_tree()->is_debugging_collisions_hint()) {
_update_debug_shape();
+ }
}
Vector3 RayCast3D::get_cast_to() const {
-
return cast_to;
}
void RayCast3D::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
}
uint32_t RayCast3D::get_collision_mask() const {
-
return collision_mask;
}
void RayCast3D::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool RayCast3D::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
bool RayCast3D::is_colliding() const {
-
return collided;
}
-Object *RayCast3D::get_collider() const {
- if (against.is_null())
+Object *RayCast3D::get_collider() const {
+ if (against.is_null()) {
return nullptr;
+ }
return ObjectDB::get_instance(against);
}
int RayCast3D::get_collider_shape() const {
-
return against_shape;
}
-Vector3 RayCast3D::get_collision_point() const {
+Vector3 RayCast3D::get_collision_point() const {
return collision_point;
}
-Vector3 RayCast3D::get_collision_normal() const {
+Vector3 RayCast3D::get_collision_normal() const {
return collision_normal;
}
void RayCast3D::set_enabled(bool p_enabled) {
-
enabled = p_enabled;
update_gizmo();
- if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process_internal(p_enabled);
- if (!p_enabled)
+ }
+ if (!p_enabled) {
collided = false;
+ }
if (is_inside_tree() && get_tree()->is_debugging_collisions_hint()) {
- if (p_enabled)
+ if (p_enabled) {
_update_debug_shape();
- else
+ } else {
_clear_debug_shape();
+ }
}
}
bool RayCast3D::is_enabled() const {
-
return enabled;
}
void RayCast3D::set_exclude_parent_body(bool p_exclude_parent_body) {
-
- if (exclude_parent_body == p_exclude_parent_body)
+ if (exclude_parent_body == p_exclude_parent_body) {
return;
+ }
exclude_parent_body = p_exclude_parent_body;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (Object::cast_to<CollisionObject3D>(get_parent())) {
- if (exclude_parent_body)
+ if (exclude_parent_body) {
exclude.insert(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
- else
+ } else {
exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
+ }
}
}
bool RayCast3D::get_exclude_parent_body() const {
-
return exclude_parent_body;
}
void RayCast3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
if (enabled && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process_internal(true);
- if (get_tree()->is_debugging_collisions_hint())
+ if (get_tree()->is_debugging_collisions_hint()) {
_update_debug_shape();
- } else
+ }
+ } else {
set_physics_process_internal(false);
+ }
if (Object::cast_to<CollisionObject3D>(get_parent())) {
- if (exclude_parent_body)
+ if (exclude_parent_body) {
exclude.insert(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
- else
+ } else {
exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
+ }
}
} break;
case NOTIFICATION_EXIT_TREE: {
-
if (enabled) {
set_physics_process_internal(false);
}
- if (debug_shape)
+ if (debug_shape) {
_clear_debug_shape();
+ }
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
-
- if (!enabled)
+ if (!enabled) {
break;
+ }
bool prev_collision_state = collided;
_update_raycast_state();
@@ -205,13 +203,13 @@ void RayCast3D::_update_raycast_state() {
Transform gt = get_global_transform();
Vector3 to = cast_to;
- if (to == Vector3())
+ if (to == Vector3()) {
to = Vector3(0, 0.01, 0);
+ }
PhysicsDirectSpaceState3D::RayResult rr;
if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) {
-
collided = true;
against = rr.collider_id;
collision_point = rr.position;
@@ -229,60 +227,52 @@ void RayCast3D::force_raycast_update() {
}
void RayCast3D::add_exception_rid(const RID &p_rid) {
-
exclude.insert(p_rid);
}
void RayCast3D::add_exception(const Object *p_object) {
-
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
add_exception_rid(co->get_rid());
}
void RayCast3D::remove_exception_rid(const RID &p_rid) {
-
exclude.erase(p_rid);
}
void RayCast3D::remove_exception(const Object *p_object) {
-
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
remove_exception_rid(co->get_rid());
}
void RayCast3D::clear_exceptions() {
-
exclude.clear();
}
void RayCast3D::set_collide_with_areas(bool p_clip) {
-
collide_with_areas = p_clip;
}
bool RayCast3D::is_collide_with_areas_enabled() const {
-
return collide_with_areas;
}
void RayCast3D::set_collide_with_bodies(bool p_clip) {
-
collide_with_bodies = p_clip;
}
bool RayCast3D::is_collide_with_bodies_enabled() const {
-
return collide_with_bodies;
}
void RayCast3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &RayCast3D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &RayCast3D::is_enabled);
@@ -331,7 +321,6 @@ void RayCast3D::_bind_methods() {
}
void RayCast3D::_create_debug_shape() {
-
if (!debug_material.is_valid()) {
debug_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
@@ -350,16 +339,18 @@ void RayCast3D::_create_debug_shape() {
}
void RayCast3D::_update_debug_shape() {
-
- if (!enabled)
+ if (!enabled) {
return;
+ }
- if (!debug_shape)
+ if (!debug_shape) {
_create_debug_shape();
+ }
MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape);
- if (!mi->get_mesh().is_valid())
+ if (!mi->get_mesh().is_valid()) {
return;
+ }
Ref<ArrayMesh> mesh = mi->get_mesh();
mesh->clear_surfaces();
@@ -377,21 +368,21 @@ void RayCast3D::_update_debug_shape() {
}
void RayCast3D::_clear_debug_shape() {
-
- if (!debug_shape)
+ if (!debug_shape) {
return;
+ }
MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape);
- if (mi->is_inside_tree())
+ if (mi->is_inside_tree()) {
mi->queue_delete();
- else
+ } else {
memdelete(mi);
+ }
debug_shape = nullptr;
}
RayCast3D::RayCast3D() {
-
enabled = false;
collided = false;
diff --git a/scene/3d/ray_cast_3d.h b/scene/3d/ray_cast_3d.h
index f8bfb7846a..8f617e5491 100644
--- a/scene/3d/ray_cast_3d.h
+++ b/scene/3d/ray_cast_3d.h
@@ -34,7 +34,6 @@
#include "scene/3d/node_3d.h"
class RayCast3D : public Node3D {
-
GDCLASS(RayCast3D, Node3D);
bool enabled;
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 24bf8b43d1..b1f19053d9 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -31,18 +31,15 @@
#include "reflection_probe.h"
void ReflectionProbe::set_intensity(float p_intensity) {
-
intensity = p_intensity;
RS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity);
}
float ReflectionProbe::get_intensity() const {
-
return intensity;
}
void ReflectionProbe::set_interior_ambient(Color p_ambient) {
-
interior_ambient = p_ambient;
RS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient);
}
@@ -57,33 +54,28 @@ float ReflectionProbe::get_interior_ambient_energy() const {
}
Color ReflectionProbe::get_interior_ambient() const {
-
return interior_ambient;
}
void ReflectionProbe::set_interior_ambient_probe_contribution(float p_contribution) {
-
interior_ambient_probe_contribution = p_contribution;
RS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution);
}
float ReflectionProbe::get_interior_ambient_probe_contribution() const {
-
return interior_ambient_probe_contribution;
}
void ReflectionProbe::set_max_distance(float p_distance) {
-
max_distance = p_distance;
RS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance);
}
-float ReflectionProbe::get_max_distance() const {
+float ReflectionProbe::get_max_distance() const {
return max_distance;
}
void ReflectionProbe::set_extents(const Vector3 &p_extents) {
-
extents = p_extents;
for (int i = 0; i < 3; i++) {
@@ -102,17 +94,15 @@ void ReflectionProbe::set_extents(const Vector3 &p_extents) {
_change_notify("extents");
update_gizmo();
}
-Vector3 ReflectionProbe::get_extents() const {
+Vector3 ReflectionProbe::get_extents() const {
return extents;
}
void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) {
-
origin_offset = p_extents;
for (int i = 0; i < 3; i++) {
-
if (extents[i] - 0.01 < ABS(origin_offset[i])) {
origin_offset[i] = SGN(origin_offset[i]) * (extents[i] - 0.01);
}
@@ -123,50 +113,45 @@ void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) {
_change_notify("origin_offset");
update_gizmo();
}
-Vector3 ReflectionProbe::get_origin_offset() const {
+Vector3 ReflectionProbe::get_origin_offset() const {
return origin_offset;
}
void ReflectionProbe::set_enable_box_projection(bool p_enable) {
-
box_projection = p_enable;
RS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable);
}
-bool ReflectionProbe::is_box_projection_enabled() const {
+bool ReflectionProbe::is_box_projection_enabled() const {
return box_projection;
}
void ReflectionProbe::set_as_interior(bool p_enable) {
-
interior = p_enable;
RS::get_singleton()->reflection_probe_set_as_interior(probe, interior);
_change_notify();
}
bool ReflectionProbe::is_set_as_interior() const {
-
return interior;
}
void ReflectionProbe::set_enable_shadows(bool p_enable) {
-
enable_shadows = p_enable;
RS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable);
}
-bool ReflectionProbe::are_shadows_enabled() const {
+bool ReflectionProbe::are_shadows_enabled() const {
return enable_shadows;
}
void ReflectionProbe::set_cull_mask(uint32_t p_layers) {
-
cull_mask = p_layers;
RS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers);
}
-uint32_t ReflectionProbe::get_cull_mask() const {
+uint32_t ReflectionProbe::get_cull_mask() const {
return cull_mask;
}
@@ -180,19 +165,17 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
}
AABB ReflectionProbe::get_aabb() const {
-
AABB aabb;
aabb.position = -origin_offset;
aabb.size = origin_offset + extents;
return aabb;
}
-Vector<Face3> ReflectionProbe::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> ReflectionProbe::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void ReflectionProbe::_validate_property(PropertyInfo &property) const {
-
if (property.name == "interior/ambient_color" || property.name == "interior/ambient_energy" || property.name == "interior/ambient_contrib") {
if (!interior) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
@@ -201,7 +184,6 @@ void ReflectionProbe::_validate_property(PropertyInfo &property) const {
}
void ReflectionProbe::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &ReflectionProbe::set_intensity);
ClassDB::bind_method(D_METHOD("get_intensity"), &ReflectionProbe::get_intensity);
@@ -258,7 +240,6 @@ void ReflectionProbe::_bind_methods() {
}
ReflectionProbe::ReflectionProbe() {
-
intensity = 1.0;
interior_ambient = Color(0, 0, 0);
interior_ambient_probe_contribution = 0;
@@ -278,6 +259,5 @@ ReflectionProbe::ReflectionProbe() {
}
ReflectionProbe::~ReflectionProbe() {
-
RS::get_singleton()->free(probe);
}
diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp
index 38792bbb58..95fce6b802 100644
--- a/scene/3d/remote_transform_3d.cpp
+++ b/scene/3d/remote_transform_3d.cpp
@@ -43,33 +43,37 @@ void RemoteTransform3D::_update_cache() {
}
void RemoteTransform3D::_update_remote() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (cache.is_null())
+ if (cache.is_null()) {
return;
+ }
Node3D *n = Object::cast_to<Node3D>(ObjectDB::get_instance(cache));
- if (!n)
+ if (!n) {
return;
+ }
- if (!n->is_inside_tree())
+ if (!n->is_inside_tree()) {
return;
+ }
//todo make faster
if (use_global_coordinates) {
-
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_global_transform(get_global_transform());
} else {
Transform our_trans = get_global_transform();
- if (update_remote_rotation)
+ if (update_remote_rotation) {
n->set_rotation(our_trans.basis.get_rotation());
+ }
- if (update_remote_scale)
+ if (update_remote_scale) {
n->set_scale(our_trans.basis.get_scale());
+ }
if (update_remote_position) {
Transform n_trans = n->get_global_transform();
@@ -85,11 +89,13 @@ void RemoteTransform3D::_update_remote() {
} else {
Transform our_trans = get_transform();
- if (update_remote_rotation)
+ if (update_remote_rotation) {
n->set_rotation(our_trans.basis.get_rotation());
+ }
- if (update_remote_scale)
+ if (update_remote_scale) {
n->set_scale(our_trans.basis.get_scale());
+ }
if (update_remote_position) {
Transform n_trans = n->get_transform();
@@ -102,20 +108,17 @@ void RemoteTransform3D::_update_remote() {
}
void RemoteTransform3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
_update_cache();
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (cache.is_valid()) {
-
_update_remote();
}
@@ -124,7 +127,6 @@ void RemoteTransform3D::_notification(int p_what) {
}
void RemoteTransform3D::set_remote_node(const NodePath &p_remote_node) {
-
remote_node = p_remote_node;
if (is_inside_tree()) {
_update_cache();
@@ -135,7 +137,6 @@ void RemoteTransform3D::set_remote_node(const NodePath &p_remote_node) {
}
NodePath RemoteTransform3D::get_remote_node() const {
-
return remote_node;
}
@@ -179,7 +180,6 @@ void RemoteTransform3D::force_update_cache() {
}
String RemoteTransform3D::get_configuration_warning() const {
-
if (!has_node(remote_node) || !Object::cast_to<Node3D>(get_node(remote_node))) {
return TTR("The \"Remote Path\" property must point to a valid Node3D or Node3D-derived node to work.");
}
@@ -188,7 +188,6 @@ String RemoteTransform3D::get_configuration_warning() const {
}
void RemoteTransform3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_remote_node", "path"), &RemoteTransform3D::set_remote_node);
ClassDB::bind_method(D_METHOD("get_remote_node"), &RemoteTransform3D::get_remote_node);
ClassDB::bind_method(D_METHOD("force_update_cache"), &RemoteTransform3D::force_update_cache);
@@ -213,7 +212,6 @@ void RemoteTransform3D::_bind_methods() {
}
RemoteTransform3D::RemoteTransform3D() {
-
use_global_coordinates = true;
update_remote_position = true;
update_remote_rotation = true;
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index 973822653a..6723ca04b9 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -36,6 +36,7 @@
#include "core/type_info.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/resources/surface_tool.h"
+#include "scene/scene_string_names.h"
void SkinReference::_skin_changed() {
if (skeleton_node) {
@@ -66,40 +67,40 @@ SkinReference::~SkinReference() {
RS::get_singleton()->free(skeleton);
}
-bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
+///////////////////////////////////////
+bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
- if (!path.begins_with("bones/"))
+ if (!path.begins_with("bones/")) {
return false;
+ }
int which = path.get_slicec('/', 1).to_int();
String what = path.get_slicec('/', 2);
if (which == bones.size() && what == "name") {
-
add_bone(p_value);
return true;
}
ERR_FAIL_INDEX_V(which, bones.size(), false);
- if (what == "parent")
+ if (what == "parent") {
set_bone_parent(which, p_value);
- else if (what == "rest")
+ } else if (what == "rest") {
set_bone_rest(which, p_value);
- else if (what == "enabled")
+ } else if (what == "enabled") {
set_bone_enabled(which, p_value);
- else if (what == "pose")
+ } else if (what == "pose") {
set_bone_pose(which, p_value);
- else if (what == "bound_children") {
+ } else if (what == "bound_children") {
Array children = p_value;
if (is_inside_tree()) {
bones.write[which].nodes_bound.clear();
for (int i = 0; i < children.size(); i++) {
-
NodePath npath = children[i];
ERR_CONTINUE(npath.operator String() == "");
Node *node = get_node(npath);
@@ -115,32 +116,31 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
}
bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
-
String path = p_path;
- if (!path.begins_with("bones/"))
+ if (!path.begins_with("bones/")) {
return false;
+ }
int which = path.get_slicec('/', 1).to_int();
String what = path.get_slicec('/', 2);
ERR_FAIL_INDEX_V(which, bones.size(), false);
- if (what == "name")
+ if (what == "name") {
r_ret = get_bone_name(which);
- else if (what == "parent")
+ } else if (what == "parent") {
r_ret = get_bone_parent(which);
- else if (what == "rest")
+ } else if (what == "rest") {
r_ret = get_bone_rest(which);
- else if (what == "enabled")
+ } else if (what == "enabled") {
r_ret = is_bone_enabled(which);
- else if (what == "pose")
+ } else if (what == "pose") {
r_ret = get_bone_pose(which);
- else if (what == "bound_children") {
+ } else if (what == "bound_children") {
Array children;
for (const List<ObjectID>::Element *E = bones[which].nodes_bound.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
Node *node = Object::cast_to<Node>(obj);
@@ -150,29 +150,29 @@ bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
}
r_ret = children;
- } else
+ } else {
return false;
+ }
return true;
}
-void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const {
+void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < bones.size(); i++) {
-
String prep = "bones/" + itos(i) + "/";
- p_list->push_back(PropertyInfo(Variant::STRING, prep + "name"));
- p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1"));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest"));
- p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled"));
- p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_children"));
+ p_list->push_back(PropertyInfo(Variant::STRING, prep + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_children", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
}
}
void Skeleton3D::_update_process_order() {
-
- if (!process_order_dirty)
+ if (!process_order_dirty) {
return;
+ }
Bone *bonesptr = bones.ptrw();
int len = bones.size();
@@ -180,7 +180,6 @@ void Skeleton3D::_update_process_order() {
process_order.resize(len);
int *order = process_order.ptrw();
for (int i = 0; i < len; i++) {
-
if (bonesptr[i].parent >= len) {
//validate this just in case
ERR_PRINT("Bone " + itos(i) + " has invalid parent: " + itos(bonesptr[i].parent));
@@ -197,8 +196,9 @@ void Skeleton3D::_update_process_order() {
bool swapped = false;
for (int i = 0; i < len; i++) {
int parent_idx = bonesptr[order[i]].parent;
- if (parent_idx < 0)
+ if (parent_idx < 0) {
continue; //do nothing because it has no parent
+ }
//swap indices
int parent_order = bonesptr[parent_idx].sort_index;
if (parent_order > i) {
@@ -210,25 +210,23 @@ void Skeleton3D::_update_process_order() {
}
}
- if (!swapped)
+ if (!swapped) {
break;
+ }
pass_count++;
}
if (pass_count == len * len) {
- ERR_PRINT("Skeleton parenthood graph is cyclic");
+ ERR_PRINT("Skeleton3D parenthood graph is cyclic");
}
process_order_dirty = false;
}
void Skeleton3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_UPDATE_SKELETON: {
-
- RenderingServer *vs = RenderingServer::get_singleton();
+ RenderingServer *rs = RenderingServer::get_singleton();
Bone *bonesptr = bones.ptrw();
int len = bones.size();
@@ -237,7 +235,6 @@ void Skeleton3D::_notification(int p_what) {
const int *order = process_order.ptr();
for (int i = 0; i < len; i++) {
-
Bone &b = bonesptr[order[i]];
if (b.global_pose_override_amount >= 0.999) {
@@ -245,50 +242,38 @@ void Skeleton3D::_notification(int p_what) {
} else {
if (b.disable_rest) {
if (b.enabled) {
-
Transform pose = b.pose;
if (b.custom_pose_enable) {
pose = b.custom_pose * pose;
}
if (b.parent >= 0) {
-
b.pose_global = bonesptr[b.parent].pose_global * pose;
} else {
-
b.pose_global = pose;
}
} else {
-
if (b.parent >= 0) {
-
b.pose_global = bonesptr[b.parent].pose_global;
} else {
-
b.pose_global = Transform();
}
}
} else {
if (b.enabled) {
-
Transform pose = b.pose;
if (b.custom_pose_enable) {
pose = b.custom_pose * pose;
}
if (b.parent >= 0) {
-
b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose);
} else {
-
b.pose_global = b.rest * pose;
}
} else {
-
if (b.parent >= 0) {
-
b.pose_global = bonesptr[b.parent].pose_global * b.rest;
} else {
-
b.pose_global = b.rest;
}
}
@@ -304,18 +289,16 @@ void Skeleton3D::_notification(int p_what) {
}
for (List<ObjectID>::Element *E = b.nodes_bound.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- Node3D *sp = Object::cast_to<Node3D>(obj);
- ERR_CONTINUE(!sp);
- sp->set_transform(b.pose_global);
+ Node3D *node_3d = Object::cast_to<Node3D>(obj);
+ ERR_CONTINUE(!node_3d);
+ node_3d->set_transform(b.pose_global);
}
}
//update skins
for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
-
const Skin *skin = E->get()->skin.operator->();
RID skeleton = E->get()->skeleton;
uint32_t bind_count = skin->get_bind_count();
@@ -328,7 +311,6 @@ void Skeleton3D::_notification(int p_what) {
}
if (E->get()->skeleton_version != version) {
-
for (uint32_t i = 0; i < bind_count; i++) {
StringName bind_name = skin->get_bind_name(i);
@@ -344,7 +326,7 @@ void Skeleton3D::_notification(int p_what) {
}
if (!found) {
- ERR_PRINT("Skin bind #" + itos(i) + " contains named bind '" + String(bind_name) + "' but Skeleton has no bone by that name.");
+ ERR_PRINT("Skin bind #" + itos(i) + " contains named bind '" + String(bind_name) + "' but Skeleton3D has no bone by that name.");
E->get()->skin_bone_indices_ptrs[i] = 0;
}
} else if (skin->get_bind_bone(i) >= 0) {
@@ -367,11 +349,16 @@ void Skeleton3D::_notification(int p_what) {
for (uint32_t i = 0; i < bind_count; i++) {
uint32_t bone_index = E->get()->skin_bone_indices_ptrs[i];
ERR_CONTINUE(bone_index >= (uint32_t)len);
- vs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i));
+ rs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i));
}
}
dirty = false;
+
+#ifdef TOOLS_ENABLED
+ emit_signal(SceneStringNames::get_singleton()->pose_updated);
+#endif // TOOLS_ENABLED
+
} break;
#ifndef _3D_DISABLED
@@ -405,7 +392,6 @@ void Skeleton3D::clear_bones_global_pose_override() {
}
void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].global_pose_override_amount = p_amount;
bones.write[p_bone].global_pose_override = p_pose;
@@ -414,20 +400,18 @@ void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_po
}
Transform Skeleton3D::get_bone_global_pose(int p_bone) const {
-
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
- if (dirty)
+ if (dirty) {
const_cast<Skeleton3D *>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
+ }
return bones[p_bone].pose_global;
}
// skeleton creation api
void Skeleton3D::add_bone(const String &p_name) {
-
ERR_FAIL_COND(p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1);
for (int i = 0; i < bones.size(); i++) {
-
ERR_FAIL_COND(bones[i].name == p_name);
}
@@ -439,43 +423,42 @@ void Skeleton3D::add_bone(const String &p_name) {
_make_dirty();
update_gizmo();
}
-int Skeleton3D::find_bone(const String &p_name) const {
+int Skeleton3D::find_bone(const String &p_name) const {
for (int i = 0; i < bones.size(); i++) {
-
- if (bones[i].name == p_name)
+ if (bones[i].name == p_name) {
return i;
+ }
}
return -1;
}
-String Skeleton3D::get_bone_name(int p_bone) const {
+String Skeleton3D::get_bone_name(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), "");
return bones[p_bone].name;
}
bool Skeleton3D::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {
-
int parent_of_bone = get_bone_parent(p_bone);
- if (-1 == parent_of_bone)
+ if (-1 == parent_of_bone) {
return false;
+ }
- if (parent_of_bone == p_parent_bone_id)
+ if (parent_of_bone == p_parent_bone_id) {
return true;
+ }
return is_bone_parent_of(parent_of_bone, p_parent_bone_id);
}
int Skeleton3D::get_bone_count() const {
-
return bones.size();
}
void Skeleton3D::set_bone_parent(int p_bone, int p_parent) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
ERR_FAIL_COND(p_parent != -1 && (p_parent < 0));
@@ -485,7 +468,6 @@ void Skeleton3D::set_bone_parent(int p_bone, int p_parent) {
}
void Skeleton3D::unparent_bone_and_rest(int p_bone) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
_update_process_order();
@@ -503,80 +485,73 @@ void Skeleton3D::unparent_bone_and_rest(int p_bone) {
}
void Skeleton3D::set_bone_disable_rest(int p_bone, bool p_disable) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].disable_rest = p_disable;
}
bool Skeleton3D::is_bone_rest_disabled(int p_bone) const {
-
ERR_FAIL_INDEX_V(p_bone, bones.size(), false);
return bones[p_bone].disable_rest;
}
int Skeleton3D::get_bone_parent(int p_bone) const {
-
ERR_FAIL_INDEX_V(p_bone, bones.size(), -1);
return bones[p_bone].parent;
}
void Skeleton3D::set_bone_rest(int p_bone, const Transform &p_rest) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].rest = p_rest;
_make_dirty();
}
-Transform Skeleton3D::get_bone_rest(int p_bone) const {
+Transform Skeleton3D::get_bone_rest(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].rest;
}
void Skeleton3D::set_bone_enabled(int p_bone, bool p_enabled) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].enabled = p_enabled;
_make_dirty();
}
-bool Skeleton3D::is_bone_enabled(int p_bone) const {
+bool Skeleton3D::is_bone_enabled(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), false);
return bones[p_bone].enabled;
}
void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) {
-
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX(p_bone, bones.size());
ObjectID id = p_node->get_instance_id();
for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) {
-
- if (E->get() == id)
+ if (E->get() == id) {
return; // already here
+ }
}
bones.write[p_bone].nodes_bound.push_back(id);
}
-void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) {
+void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX(p_bone, bones.size());
ObjectID id = p_node->get_instance_id();
bones.write[p_bone].nodes_bound.erase(id);
}
-void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const {
+void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const {
ERR_FAIL_INDEX(p_bone, bones.size());
for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) {
-
Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
p_bound->push_back(Object::cast_to<Node>(obj));
@@ -584,7 +559,6 @@ void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound
}
void Skeleton3D::clear_bones() {
-
bones.clear();
process_order_dirty = true;
version++;
@@ -594,7 +568,6 @@ void Skeleton3D::clear_bones() {
// posing api
void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
bones.write[p_bone].pose = p_pose;
@@ -602,14 +575,13 @@ void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) {
_make_dirty();
}
}
-Transform Skeleton3D::get_bone_pose(int p_bone) const {
+Transform Skeleton3D::get_bone_pose(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].pose;
}
void Skeleton3D::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose) {
-
ERR_FAIL_INDEX(p_bone, bones.size());
//ERR_FAIL_COND( !is_inside_scene() );
@@ -620,15 +592,14 @@ void Skeleton3D::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose
}
Transform Skeleton3D::get_bone_custom_pose(int p_bone) const {
-
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].custom_pose;
}
void Skeleton3D::_make_dirty() {
-
- if (dirty)
+ if (dirty) {
return;
+ }
MessageQueue::get_singleton()->push_notification(this, NOTIFICATION_UPDATE_SKELETON);
dirty = true;
@@ -640,8 +611,12 @@ int Skeleton3D::get_process_order(int p_idx) {
return process_order[p_idx];
}
-void Skeleton3D::localize_rests() {
+Vector<int> Skeleton3D::get_bone_process_orders() {
+ _update_process_order();
+ return process_order;
+}
+void Skeleton3D::localize_rests() {
_update_process_order();
for (int i = bones.size() - 1; i >= 0; i--) {
@@ -729,14 +704,14 @@ void Skeleton3D::_rebuild_physical_bones_cache() {
PhysicalBone3D *parent_pb = _get_physical_bone_parent(i);
if (parent_pb != bones[i].physical_bone) {
bones.write[i].cache_parent_physical_bone = parent_pb;
- if (bones[i].physical_bone)
+ if (bones[i].physical_bone) {
bones[i].physical_bone->_on_bone_parent_changed();
+ }
}
}
}
void _pb_stop_simulation(Node *p_node) {
-
for (int i = p_node->get_child_count() - 1; 0 <= i; --i) {
_pb_stop_simulation(p_node->get_child(i));
}
@@ -755,7 +730,6 @@ void Skeleton3D::physical_bones_stop_simulation() {
}
void _pb_start_simulation(const Skeleton3D *p_skeleton, Node *p_node, const Vector<int> &p_sim_bones) {
-
for (int i = p_node->get_child_count() - 1; 0 <= i; --i) {
_pb_start_simulation(p_skeleton, p_node->get_child(i), p_sim_bones);
}
@@ -782,8 +756,9 @@ void Skeleton3D::physical_bones_start_simulation_on(const TypedArray<StringName>
int c = 0;
for (int i = sim_bones.size() - 1; 0 <= i; --i) {
int bone_id = find_bone(p_bones[i]);
- if (bone_id != -1)
+ if (bone_id != -1) {
sim_bones.write[c++] = bone_id;
+ }
}
sim_bones.resize(c);
}
@@ -792,7 +767,6 @@ void Skeleton3D::physical_bones_start_simulation_on(const TypedArray<StringName>
}
void _physical_bones_add_remove_collision_exception(bool p_add, Node *p_node, RID p_exception) {
-
for (int i = p_node->get_child_count() - 1; 0 <= i; --i) {
_physical_bones_add_remove_collision_exception(p_add, p_node->get_child(i), p_exception);
}
@@ -822,7 +796,6 @@ void Skeleton3D::_skin_changed() {
}
Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
-
for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
if (E->get()->skin == p_skin) {
return Ref<SkinReference>(E->get());
@@ -882,8 +855,17 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) {
return skin_ref;
}
-void Skeleton3D::_bind_methods() {
+// helper functions
+Transform Skeleton3D::bone_transform_to_world_transform(Transform p_bone_transform) {
+ return get_global_transform() * p_bone_transform;
+}
+
+Transform Skeleton3D::world_transform_to_bone_transform(Transform p_world_transform) {
+ return get_global_transform().affine_inverse() * p_world_transform;
+}
+void Skeleton3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_bone_process_orders"), &Skeleton3D::get_bone_process_orders);
ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton3D::add_bone);
ClassDB::bind_method(D_METHOD("find_bone", "name"), &Skeleton3D::find_bone);
ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &Skeleton3D::get_bone_name);
@@ -921,6 +903,9 @@ void Skeleton3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_bone_custom_pose", "bone_idx"), &Skeleton3D::get_bone_custom_pose);
ClassDB::bind_method(D_METHOD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton3D::set_bone_custom_pose);
+ ClassDB::bind_method(D_METHOD("bone_transform_to_world_transform", "bone_transform"), &Skeleton3D::bone_transform_to_world_transform);
+ ClassDB::bind_method(D_METHOD("world_transform_to_bone_transform", "world_transform"), &Skeleton3D::world_transform_to_bone_transform);
+
#ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("set_animate_physical_bones"), &Skeleton3D::set_animate_physical_bones);
@@ -934,11 +919,14 @@ void Skeleton3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones");
#endif // _3D_DISABLED
+#ifdef TOOLS_ENABLED
+ ADD_SIGNAL(MethodInfo("pose_updated"));
+#endif // TOOLS_ENABLED
+
BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON);
}
Skeleton3D::Skeleton3D() {
-
animate_physical_bones = true;
dirty = false;
version = 1;
@@ -946,7 +934,6 @@ Skeleton3D::Skeleton3D() {
}
Skeleton3D::~Skeleton3D() {
-
//some skins may remain bound
for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) {
E->get()->skeleton_node = nullptr;
diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h
index 0bccd3f8fc..a21891a32e 100644
--- a/scene/3d/skeleton_3d.h
+++ b/scene/3d/skeleton_3d.h
@@ -66,18 +66,12 @@ public:
};
class Skeleton3D : public Node3D {
-
GDCLASS(Skeleton3D, Node3D);
private:
friend class SkinReference;
- Set<SkinReference *> skin_bindings;
-
- void _skin_changed();
-
struct Bone {
-
String name;
bool enabled;
@@ -118,6 +112,10 @@ private:
}
};
+ Set<SkinReference *> skin_bindings;
+
+ void _skin_changed();
+
bool animate_physical_bones;
Vector<Bone> bones;
Vector<int> process_order;
@@ -130,13 +128,11 @@ private:
// bind helpers
Array _get_bound_child_nodes_to_bone(int p_bone) const {
-
Array bound;
List<Node *> children;
get_bound_child_nodes_to_bone(p_bone, &children);
for (int i = 0; i < children.size(); i++) {
-
bound.push_back(children[i]);
}
return bound;
@@ -200,9 +196,14 @@ public:
void localize_rests(); // used for loaders and tools
int get_process_order(int p_idx);
+ Vector<int> get_bone_process_orders();
Ref<SkinReference> register_skin(const Ref<Skin> &p_skin);
+ // Helper functions
+ Transform bone_transform_to_world_transform(Transform p_transform);
+ Transform world_transform_to_bone_transform(Transform p_transform);
+
#ifndef _3D_DISABLED
// Physical bone API
@@ -216,7 +217,7 @@ public:
PhysicalBone3D *get_physical_bone_parent(int p_bone);
private:
- /// This is a slow API os it's cached
+ /// This is a slow API, so it's cached
PhysicalBone3D *_get_physical_bone_parent(int p_bone);
void _rebuild_physical_bones_cache();
diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp
index 10bdd71d73..9023f3c68a 100644
--- a/scene/3d/skeleton_ik_3d.cpp
+++ b/scene/3d/skeleton_ik_3d.cpp
@@ -55,7 +55,6 @@ FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::add_child(
/// Build a chain that starts from the root to tip
bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain) {
-
ERR_FAIL_COND_V(-1 == p_task->root_bone, false);
Chain &chain(p_task->chain);
@@ -75,7 +74,6 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
chain_ids.resize(p_task->skeleton->get_bone_count());
for (int x = p_task->end_effectors.size() - 1; 0 <= x; --x) {
-
const EndEffector *ee(&p_task->end_effectors[x]);
ERR_FAIL_COND_V(p_task->root_bone >= ee->tip_bone, false);
ERR_FAIL_INDEX_V(ee->tip_bone, p_task->skeleton->get_bone_count(), false);
@@ -84,7 +82,6 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
// Picks all IDs that composing a single chain in reverse order (except the root)
BoneId chain_sub_tip(ee->tip_bone);
while (chain_sub_tip > p_task->root_bone) {
-
chain_ids.write[sub_chain_size++] = chain_sub_tip;
chain_sub_tip = p_task->skeleton->get_bone_parent(chain_sub_tip);
}
@@ -95,10 +92,8 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
// For each chain item id will be created a ChainItem if doesn't exists
ChainItem *sub_chain(&chain.chain_root);
for (int i = sub_chain_size - 1; 0 <= i; --i) {
-
ChainItem *child_ci(sub_chain->find_child(chain_ids[i]));
if (!child_ci) {
-
child_ci = sub_chain->add_child(chain_ids[i]);
child_ci->pb = p_task->skeleton->get_physical_bone(child_ci->bone);
@@ -118,8 +113,9 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
}
}
- if (!middle_chain_item_id)
+ if (!middle_chain_item_id) {
chain.middle_chain_item = nullptr;
+ }
// Initialize current tip
chain.tips.write[x].chain_item = sub_chain;
@@ -137,9 +133,9 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
}
void FabrikInverseKinematic::update_chain(const Skeleton3D *p_sk, ChainItem *p_chain_item) {
-
- if (!p_chain_item)
+ if (!p_chain_item) {
return;
+ }
p_chain_item->initial_transform = p_sk->get_bone_global_pose(p_chain_item->bone);
p_chain_item->current_pos = p_chain_item->initial_transform.origin;
@@ -151,7 +147,6 @@ void FabrikInverseKinematic::update_chain(const Skeleton3D *p_sk, ChainItem *p_c
}
void FabrikInverseKinematic::solve_simple(Task *p_task, bool p_solve_magnet) {
-
real_t distance_to_goal(1e4);
real_t previous_distance_to_goal(0);
int can_solve(p_task->max_iterations);
@@ -167,7 +162,6 @@ void FabrikInverseKinematic::solve_simple(Task *p_task, bool p_solve_magnet) {
}
void FabrikInverseKinematic::solve_simple_backwards(Chain &r_chain, bool p_solve_magnet) {
-
if (p_solve_magnet && !r_chain.middle_chain_item) {
return;
}
@@ -200,7 +194,6 @@ void FabrikInverseKinematic::solve_simple_backwards(Chain &r_chain, bool p_solve
}
void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_magnet) {
-
if (p_solve_magnet && !r_chain.middle_chain_item) {
return;
}
@@ -212,7 +205,6 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_
sub_chain_root->current_pos = origin;
if (!sub_chain_root->children.empty()) {
-
ChainItem &child(sub_chain_root->children.write[0]);
// Is not tip
@@ -231,7 +223,6 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_
sub_chain_root = &child;
}
} else {
-
// Is tip
sub_chain_root = nullptr;
}
@@ -239,7 +230,6 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_
}
FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleton3D *p_sk, BoneId root_bone, BoneId tip_bone, const Transform &goal_transform) {
-
FabrikInverseKinematic::EndEffector ee;
ee.tip_bone = tip_bone;
@@ -258,8 +248,9 @@ FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleto
}
void FabrikInverseKinematic::free_task(Task *p_task) {
- if (p_task)
+ if (p_task) {
memdelete(p_task);
+ }
}
void FabrikInverseKinematic::set_goal(Task *p_task, const Transform &p_goal) {
@@ -267,12 +258,10 @@ void FabrikInverseKinematic::set_goal(Task *p_task, const Transform &p_goal) {
}
void FabrikInverseKinematic::make_goal(Task *p_task, const Transform &p_inverse_transf, real_t blending_delta) {
-
if (blending_delta >= 0.99f) {
// Update the end_effector (local transform) without blending
p_task->end_effectors.write[0].goal_transform = p_inverse_transf * p_task->goal_global_transform;
} else {
-
// End effector in local transform
const Transform end_effector_pose(p_task->skeleton->get_bone_global_pose(p_task->end_effectors.write[0].tip_bone));
@@ -282,7 +271,6 @@ void FabrikInverseKinematic::make_goal(Task *p_task, const Transform &p_inverse_
}
void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool override_tip_basis, bool p_use_magnet, const Vector3 &p_magnet_position) {
-
if (blending_delta <= 0.01f) {
return; // Skip solving
}
@@ -314,7 +302,6 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
new_bone_pose.origin = ci->current_pos;
if (!ci->children.empty()) {
-
/// Rotate basis
const Vector3 initial_ori((ci->children[0].initial_transform.origin - ci->initial_transform.origin).normalized());
const Vector3 rot_axis(initial_ori.cross(ci->current_ori).normalized());
@@ -325,38 +312,37 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
}
} else {
// Set target orientation to tip
- if (override_tip_basis)
+ if (override_tip_basis) {
new_bone_pose.basis = p_task->chain.tips[0].end_effector->goal_transform.basis;
- else
+ } else {
new_bone_pose.basis = new_bone_pose.basis * p_task->chain.tips[0].end_effector->goal_transform.basis;
+ }
}
p_task->skeleton->set_bone_global_pose_override(ci->bone, new_bone_pose, 1.0, true);
- if (!ci->children.empty())
+ if (!ci->children.empty()) {
ci = &ci->children.write[0];
- else
+ } else {
ci = nullptr;
+ }
}
}
void SkeletonIK3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "root_bone" || property.name == "tip_bone") {
-
if (skeleton) {
-
String names("--,");
for (int i = 0; i < skeleton->get_bone_count(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += skeleton->get_bone_name(i);
}
property.hint = PROPERTY_HINT_ENUM;
property.hint_string = names;
} else {
-
property.hint = PROPERTY_HINT_NONE;
property.hint_string = "";
}
@@ -364,7 +350,6 @@ void SkeletonIK3D::_validate_property(PropertyInfo &property) const {
}
void SkeletonIK3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_root_bone", "root_bone"), &SkeletonIK3D::set_root_bone);
ClassDB::bind_method(D_METHOD("get_root_bone"), &SkeletonIK3D::get_root_bone);
@@ -421,9 +406,9 @@ void SkeletonIK3D::_notification(int p_what) {
reload_chain();
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
-
- if (target_node_override)
+ if (target_node_override) {
reload_goal();
+ }
_solve_chain();
@@ -434,15 +419,7 @@ void SkeletonIK3D::_notification(int p_what) {
}
}
-SkeletonIK3D::SkeletonIK3D() :
- interpolation(1),
- override_tip_basis(true),
- use_magnet(false),
- min_distance(0.01),
- max_iterations(10),
- skeleton(nullptr),
- target_node_override(nullptr),
- task(nullptr) {
+SkeletonIK3D::SkeletonIK3D() {
}
SkeletonIK3D::~SkeletonIK3D() {
@@ -545,23 +522,24 @@ void SkeletonIK3D::stop() {
}
Transform SkeletonIK3D::_get_target_transform() {
-
- if (!target_node_override && !target_node_path_override.is_empty())
+ if (!target_node_override && !target_node_path_override.is_empty()) {
target_node_override = Object::cast_to<Node3D>(get_node(target_node_path_override));
+ }
- if (target_node_override)
+ if (target_node_override) {
return target_node_override->get_global_transform();
- else
+ } else {
return target;
+ }
}
void SkeletonIK3D::reload_chain() {
-
FabrikInverseKinematic::free_task(task);
task = nullptr;
- if (!skeleton)
+ if (!skeleton) {
return;
+ }
task = FabrikInverseKinematic::create_simple_task(skeleton, skeleton->find_bone(root_bone), skeleton->find_bone(tip_bone), _get_target_transform());
if (task) {
@@ -571,15 +549,17 @@ void SkeletonIK3D::reload_chain() {
}
void SkeletonIK3D::reload_goal() {
- if (!task)
+ if (!task) {
return;
+ }
FabrikInverseKinematic::set_goal(task, _get_target_transform());
}
void SkeletonIK3D::_solve_chain() {
- if (!task)
+ if (!task) {
return;
+ }
FabrikInverseKinematic::solve(task, interpolation, override_tip_basis, use_magnet, magnet_position);
}
diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h
index 5fbbe6e9e7..0d948f13a9 100644
--- a/scene/3d/skeleton_ik_3d.h
+++ b/scene/3d/skeleton_ik_3d.h
@@ -41,45 +41,37 @@
#include "scene/3d/skeleton_3d.h"
class FabrikInverseKinematic {
-
struct EndEffector {
BoneId tip_bone;
Transform goal_transform;
};
struct ChainItem {
-
Vector<ChainItem> children;
- ChainItem *parent_item;
+ ChainItem *parent_item = nullptr;
// Bone info
- BoneId bone;
- PhysicalBone3D *pb;
+ BoneId bone = -1;
+ PhysicalBone3D *pb = nullptr;
- real_t length;
+ real_t length = 0;
/// Positions relative to root bone
Transform initial_transform;
Vector3 current_pos;
// Direction from this bone to child
Vector3 current_ori;
- ChainItem() :
- parent_item(nullptr),
- bone(-1),
- pb(nullptr),
- length(0) {}
+ ChainItem() {}
ChainItem *find_child(const BoneId p_bone_id);
ChainItem *add_child(const BoneId p_bone_id);
};
struct ChainTip {
- ChainItem *chain_item;
- const EndEffector *end_effector;
+ ChainItem *chain_item = nullptr;
+ const EndEffector *end_effector = nullptr;
- ChainTip() :
- chain_item(nullptr),
- end_effector(nullptr) {}
+ ChainTip() {}
ChainTip(ChainItem *p_chain_item, const EndEffector *p_end_effector) :
chain_item(p_chain_item),
@@ -100,25 +92,21 @@ class FabrikInverseKinematic {
public:
struct Task {
RID self;
- Skeleton3D *skeleton;
+ Skeleton3D *skeleton = nullptr;
Chain chain;
// Settings
- real_t min_distance;
- int max_iterations;
+ real_t min_distance = 0.01;
+ int max_iterations = 10;
// Bone data
- BoneId root_bone;
+ BoneId root_bone = -1;
Vector<EndEffector> end_effectors;
Transform goal_global_transform;
- Task() :
- skeleton(nullptr),
- min_distance(0.01),
- max_iterations(10),
- root_bone(-1) {}
+ Task() {}
};
private:
@@ -146,19 +134,19 @@ class SkeletonIK3D : public Node {
StringName root_bone;
StringName tip_bone;
- real_t interpolation;
+ real_t interpolation = 1;
Transform target;
NodePath target_node_path_override;
- bool override_tip_basis;
- bool use_magnet;
+ bool override_tip_basis = true;
+ bool use_magnet = false;
Vector3 magnet_position;
- real_t min_distance;
- int max_iterations;
+ real_t min_distance = 0.01;
+ int max_iterations = 10;
- Skeleton3D *skeleton;
- Node3D *target_node_override;
- FabrikInverseKinematic::Task *task;
+ Skeleton3D *skeleton = nullptr;
+ Node3D *target_node_override = nullptr;
+ FabrikInverseKinematic::Task *task = nullptr;
protected:
virtual void
diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp
index 850ffab292..a267c57f5e 100644
--- a/scene/3d/soft_body_3d.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -65,7 +65,6 @@ void SoftBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) {
}
void SoftBodyRenderingServerHandler::clear() {
-
if (mesh.is_valid()) {
buffer.resize(0);
}
@@ -97,9 +96,7 @@ void SoftBodyRenderingServerHandler::set_aabb(const AABB &p_aabb) {
RS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb);
}
-SoftBody3D::PinnedPoint::PinnedPoint() :
- point_index(-1),
- spatial_attachment(nullptr) {
+SoftBody3D::PinnedPoint::PinnedPoint() {
}
SoftBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) {
@@ -118,8 +115,9 @@ SoftBody3D::PinnedPoint SoftBody3D::PinnedPoint::operator=(const PinnedPoint &ob
}
void SoftBody3D::_update_pickable() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool pickable = ray_pickable && is_visible_in_tree();
PhysicsServer3D::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
}
@@ -129,11 +127,9 @@ bool SoftBody3D::_set(const StringName &p_name, const Variant &p_value) {
String which = name.get_slicec('/', 0);
if ("pinned_points" == which) {
-
return _set_property_pinned_points_indices(p_value);
} else if ("attachments" == which) {
-
int idx = name.get_slicec('/', 1).to_int();
String what = name.get_slicec('/', 2);
@@ -161,7 +157,6 @@ bool SoftBody3D::_get(const StringName &p_name, Variant &r_ret) const {
return true;
} else if ("attachments" == which) {
-
int idx = name.get_slicec('/', 1).to_int();
String what = name.get_slicec('/', 2);
@@ -172,7 +167,6 @@ bool SoftBody3D::_get(const StringName &p_name, Variant &r_ret) const {
}
void SoftBody3D::_get_property_list(List<PropertyInfo> *p_list) const {
-
const int pinned_points_indices_size = pinned_points.size();
p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "pinned_points"));
@@ -185,7 +179,6 @@ void SoftBody3D::_get_property_list(List<PropertyInfo> *p_list) const {
}
bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) {
-
const int p_indices_size = p_indices.size();
{ // Remove the pined points on physics server that will be removed by resize
@@ -204,8 +197,9 @@ bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) {
for (int i = 0; i < p_indices_size; ++i) {
point_index = p_indices.get(i);
if (w[i].point_index != point_index) {
- if (-1 != w[i].point_index)
+ if (-1 != w[i].point_index) {
pin_point(w[i].point_index, false);
+ }
w[i].point_index = point_index;
pin_point(w[i].point_index, true);
}
@@ -264,9 +258,7 @@ void SoftBody3D::_changed_callback(Object *p_changed, const char *p_prop) {
void SoftBody3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
-
if (Engine::get_singleton()->is_editor_hint()) {
-
add_change_receptor(this);
}
@@ -275,12 +267,12 @@ void SoftBody3D::_notification(int p_what) {
prepare_physics_server();
} break;
case NOTIFICATION_READY: {
- if (!parent_collision_ignore.is_empty())
+ if (!parent_collision_ignore.is_empty()) {
add_collision_exception_with(get_node(parent_collision_ignore));
+ }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
if (Engine::get_singleton()->is_editor_hint()) {
_reset_points_offsets();
return;
@@ -296,12 +288,10 @@ void SoftBody3D::_notification(int p_what) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
_update_pickable();
} break;
case NOTIFICATION_EXIT_WORLD: {
-
PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, RID());
} break;
@@ -319,7 +309,6 @@ void SoftBody3D::_notification(int p_what) {
}
void SoftBody3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &SoftBody3D::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &SoftBody3D::get_collision_mask);
@@ -388,20 +377,21 @@ void SoftBody3D::_bind_methods() {
}
String SoftBody3D::get_configuration_warning() const {
-
String warning = MeshInstance3D::get_configuration_warning();
if (get_mesh().is_null()) {
- if (!warning.empty())
+ if (!warning.empty()) {
warning += "\n\n";
+ }
warning += TTR("This body will be ignored until you set a mesh.");
}
Transform t = get_transform();
if ((ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) {
- if (!warning.empty())
+ if (!warning.empty()) {
warning += "\n\n";
+ }
warning += TTR("Size changes to SoftBody3D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.");
}
@@ -410,8 +400,9 @@ String SoftBody3D::get_configuration_warning() const {
}
void SoftBody3D::_update_physics_server() {
- if (!simulation_started)
+ if (!simulation_started) {
return;
+ }
_update_cache_pin_points_datas();
// Submit bone attachment
@@ -425,11 +416,11 @@ void SoftBody3D::_update_physics_server() {
}
void SoftBody3D::_draw_soft_mesh() {
- if (get_mesh().is_null())
+ if (get_mesh().is_null()) {
return;
+ }
if (!rendering_server_handler.is_ready()) {
-
rendering_server_handler.prepare(get_mesh()->get_rid(), 0);
/// Necessary in order to render the mesh correctly (Soft body nodes are in global space)
@@ -448,24 +439,21 @@ void SoftBody3D::_draw_soft_mesh() {
}
void SoftBody3D::prepare_physics_server() {
-
if (Engine::get_singleton()->is_editor_hint()) {
-
- if (get_mesh().is_valid())
+ if (get_mesh().is_valid()) {
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
- else
+ } else {
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr);
+ }
return;
}
if (get_mesh().is_valid()) {
-
become_mesh_owner();
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh));
} else {
-
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr);
if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) {
RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh));
@@ -474,8 +462,9 @@ void SoftBody3D::prepare_physics_server() {
}
void SoftBody3D::become_mesh_owner() {
- if (mesh.is_null())
+ if (mesh.is_null()) {
return;
+ }
if (!mesh_owner) {
mesh_owner = true;
@@ -515,6 +504,7 @@ void SoftBody3D::set_collision_mask(uint32_t p_mask) {
uint32_t SoftBody3D::get_collision_mask() const {
return collision_mask;
}
+
void SoftBody3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
PhysicsServer3D::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer);
@@ -526,10 +516,11 @@ uint32_t SoftBody3D::get_collision_layer() const {
void SoftBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
@@ -539,10 +530,11 @@ bool SoftBody3D::get_collision_mask_bit(int p_bit) const {
void SoftBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
layer |= 1 << p_bit;
- else
+ } else {
layer &= ~(1 << p_bit);
+ }
set_collision_layer(layer);
}
@@ -691,25 +683,16 @@ bool SoftBody3D::is_point_pinned(int p_point_index) const {
}
void SoftBody3D::set_ray_pickable(bool p_ray_pickable) {
-
ray_pickable = p_ray_pickable;
_update_pickable();
}
bool SoftBody3D::is_ray_pickable() const {
-
return ray_pickable;
}
SoftBody3D::SoftBody3D() :
- physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()),
- mesh_owner(false),
- collision_mask(1),
- collision_layer(1),
- simulation_started(false),
- pinned_points_cache_dirty(true),
- ray_pickable(true) {
-
+ physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()) {
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
}
@@ -730,14 +713,14 @@ void SoftBody3D::_make_cache_dirty() {
}
void SoftBody3D::_update_cache_pin_points_datas() {
- if (!pinned_points_cache_dirty)
+ if (!pinned_points_cache_dirty) {
return;
+ }
pinned_points_cache_dirty = false;
PinnedPoint *w = pinned_points.ptrw();
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
-
if (!w[i].spatial_attachment_path.is_empty()) {
w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(w[i].spatial_attachment_path));
}
@@ -754,7 +737,6 @@ void SoftBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) {
void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) {
SoftBody3D::PinnedPoint *pinned_point;
if (-1 == _get_pinned_point(p_point_index, pinned_point)) {
-
// Create new
PinnedPoint pp;
pp.point_index = p_point_index;
@@ -768,7 +750,6 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_
pinned_points.push_back(pp);
} else {
-
pinned_point->point_index = p_point_index;
pinned_point->spatial_attachment_path = p_spatial_attachment_path;
@@ -780,19 +761,20 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_
}
void SoftBody3D::_reset_points_offsets() {
-
- if (!Engine::get_singleton()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint()) {
return;
+ }
const PinnedPoint *r = pinned_points.ptr();
PinnedPoint *w = pinned_points.ptrw();
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
-
- if (!r[i].spatial_attachment)
+ if (!r[i].spatial_attachment) {
w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(r[i].spatial_attachment_path));
+ }
- if (!r[i].spatial_attachment)
+ if (!r[i].spatial_attachment) {
continue;
+ }
w[i].offset = (r[i].spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, r[i].point_index));
}
diff --git a/scene/3d/soft_body_3d.h b/scene/3d/soft_body_3d.h
index 7dd5880985..0063e342f2 100644
--- a/scene/3d/soft_body_3d.h
+++ b/scene/3d/soft_body_3d.h
@@ -36,7 +36,6 @@
class SoftBody3D;
class SoftBodyRenderingServerHandler {
-
friend class SoftBody3D;
RID mesh;
@@ -68,9 +67,9 @@ class SoftBody3D : public MeshInstance3D {
public:
struct PinnedPoint {
- int point_index;
+ int point_index = -1;
NodePath spatial_attachment_path;
- Node3D *spatial_attachment; // Cache
+ Node3D *spatial_attachment = nullptr; // Cache
Vector3 offset;
PinnedPoint();
@@ -83,19 +82,19 @@ private:
RID physics_rid;
- bool mesh_owner;
- uint32_t collision_mask;
- uint32_t collision_layer;
+ bool mesh_owner = false;
+ uint32_t collision_mask = 1;
+ uint32_t collision_layer = 1;
NodePath parent_collision_ignore;
Vector<PinnedPoint> pinned_points;
- bool simulation_started;
- bool pinned_points_cache_dirty;
+ bool simulation_started = false;
+ bool pinned_points_cache_dirty = true;
Ref<ArrayMesh> debug_mesh_cache;
class MeshInstance3D *debug_mesh;
bool capture_input_on_drag;
- bool ray_pickable;
+ bool ray_pickable = true;
void _update_pickable();
diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp
index 1410b730fd..9775ecc6c6 100644
--- a/scene/3d/spring_arm_3d.cpp
+++ b/scene/3d/spring_arm_3d.cpp
@@ -29,18 +29,12 @@
/*************************************************************************/
#include "spring_arm_3d.h"
+
#include "core/engine.h"
#include "scene/3d/collision_object_3d.h"
#include "scene/resources/sphere_shape_3d.h"
#include "servers/physics_server_3d.h"
-SpringArm3D::SpringArm3D() :
- spring_length(1),
- current_spring_length(0),
- keep_child_basis(false),
- mask(1),
- margin(0.01) {}
-
void SpringArm3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
@@ -60,7 +54,6 @@ void SpringArm3D::_notification(int p_what) {
}
void SpringArm3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_hit_length"), &SpringArm3D::get_hit_length);
ClassDB::bind_method(D_METHOD("set_length", "length"), &SpringArm3D::set_length);
@@ -90,8 +83,9 @@ float SpringArm3D::get_length() const {
}
void SpringArm3D::set_length(float p_length) {
- if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) {
update_gizmo();
+ }
spring_length = p_length;
}
@@ -163,7 +157,6 @@ void SpringArm3D::process_spring() {
childs_transform.origin = get_global_transform().origin + cast_direction * (spring_length * motion_delta);
for (int i = get_child_count() - 1; 0 <= i; --i) {
-
Node3D *child = Object::cast_to<Node3D>(get_child(i));
if (child) {
childs_transform.basis = child->get_global_transform().basis;
diff --git a/scene/3d/spring_arm_3d.h b/scene/3d/spring_arm_3d.h
index cb8a00ecf9..7f6fe2f1a2 100644
--- a/scene/3d/spring_arm_3d.h
+++ b/scene/3d/spring_arm_3d.h
@@ -38,11 +38,11 @@ class SpringArm3D : public Node3D {
Ref<Shape3D> shape;
Set<RID> excluded_objects;
- float spring_length;
- float current_spring_length;
- bool keep_child_basis;
- uint32_t mask;
- float margin;
+ float spring_length = 1;
+ float current_spring_length = 0;
+ bool keep_child_basis = false;
+ uint32_t mask = 1;
+ float margin = 0.01;
protected:
void _notification(int p_what);
@@ -62,7 +62,7 @@ public:
void set_margin(float p_margin);
float get_margin();
- SpringArm3D();
+ SpringArm3D() {}
private:
void process_spring();
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 85e5ebc475..3b76cb6499 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -34,14 +34,15 @@
#include "scene/scene_string_names.h"
Color SpriteBase3D::_get_color_accum() {
-
- if (!color_dirty)
+ if (!color_dirty) {
return color_accum;
+ }
- if (parent_sprite)
+ if (parent_sprite) {
color_accum = parent_sprite->_get_color_accum();
- else
+ } else {
color_accum = Color(1, 1, 1, 1);
+ }
color_accum.r *= modulate.r;
color_accum.g *= modulate.g;
@@ -52,25 +53,23 @@ Color SpriteBase3D::_get_color_accum() {
}
void SpriteBase3D::_propagate_color_changed() {
-
- if (color_dirty)
+ if (color_dirty) {
return;
+ }
color_dirty = true;
_queue_update();
for (List<SpriteBase3D *>::Element *E = children.front(); E; E = E->next()) {
-
E->get()->_propagate_color_changed();
}
}
void SpriteBase3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
- if (!pending_update)
+ if (!pending_update) {
_im_update();
+ }
parent_sprite = Object::cast_to<SpriteBase3D>(get_parent());
if (parent_sprite) {
@@ -79,9 +78,7 @@ void SpriteBase3D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
if (parent_sprite) {
-
parent_sprite->children.erase(pI);
pI = nullptr;
parent_sprite = nullptr;
@@ -90,100 +87,89 @@ void SpriteBase3D::_notification(int p_what) {
}
void SpriteBase3D::set_centered(bool p_center) {
-
centered = p_center;
_queue_update();
}
bool SpriteBase3D::is_centered() const {
-
return centered;
}
void SpriteBase3D::set_offset(const Point2 &p_offset) {
-
offset = p_offset;
_queue_update();
}
-Point2 SpriteBase3D::get_offset() const {
+Point2 SpriteBase3D::get_offset() const {
return offset;
}
void SpriteBase3D::set_flip_h(bool p_flip) {
-
hflip = p_flip;
_queue_update();
}
-bool SpriteBase3D::is_flipped_h() const {
+bool SpriteBase3D::is_flipped_h() const {
return hflip;
}
void SpriteBase3D::set_flip_v(bool p_flip) {
-
vflip = p_flip;
_queue_update();
}
-bool SpriteBase3D::is_flipped_v() const {
+bool SpriteBase3D::is_flipped_v() const {
return vflip;
}
void SpriteBase3D::set_modulate(const Color &p_color) {
-
modulate = p_color;
_propagate_color_changed();
_queue_update();
}
Color SpriteBase3D::get_modulate() const {
-
return modulate;
}
void SpriteBase3D::set_pixel_size(float p_amount) {
-
pixel_size = p_amount;
_queue_update();
}
-float SpriteBase3D::get_pixel_size() const {
+float SpriteBase3D::get_pixel_size() const {
return pixel_size;
}
void SpriteBase3D::set_opacity(float p_amount) {
-
opacity = p_amount;
_queue_update();
}
-float SpriteBase3D::get_opacity() const {
+float SpriteBase3D::get_opacity() const {
return opacity;
}
void SpriteBase3D::set_axis(Vector3::Axis p_axis) {
-
ERR_FAIL_INDEX(p_axis, 3);
axis = p_axis;
_queue_update();
}
-Vector3::Axis SpriteBase3D::get_axis() const {
+Vector3::Axis SpriteBase3D::get_axis() const {
return axis;
}
void SpriteBase3D::_im_update() {
-
_draw();
pending_update = false;
}
void SpriteBase3D::_queue_update() {
-
- if (pending_update)
+ if (pending_update) {
return;
+ }
triangle_mesh.unref();
update_gizmo();
@@ -193,17 +179,17 @@ void SpriteBase3D::_queue_update() {
}
AABB SpriteBase3D::get_aabb() const {
-
return aabb;
}
-Vector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
- if (triangle_mesh.is_valid())
+ if (triangle_mesh.is_valid()) {
return triangle_mesh;
+ }
Vector<Vector3> faces;
faces.resize(6);
@@ -211,8 +197,9 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
Rect2 final_rect = get_item_rect();
- if (final_rect.size.x == 0 || final_rect.size.y == 0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0) {
return Ref<TriangleMesh>();
+ }
float pixel_size = get_pixel_size();
@@ -260,7 +247,6 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
}
void SpriteBase3D::set_draw_flag(DrawFlags p_flag, bool p_enable) {
-
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_enable;
_queue_update();
@@ -272,31 +258,26 @@ bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const {
}
void SpriteBase3D::set_alpha_cut_mode(AlphaCutMode p_mode) {
-
ERR_FAIL_INDEX(p_mode, 3);
alpha_cut = p_mode;
_queue_update();
}
SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const {
-
return alpha_cut;
}
void SpriteBase3D::set_billboard_mode(StandardMaterial3D::BillboardMode p_mode) {
-
ERR_FAIL_INDEX(p_mode, 3);
billboard_mode = p_mode;
_queue_update();
}
StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const {
-
return billboard_mode;
}
void SpriteBase3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_centered", "centered"), &SpriteBase3D::set_centered);
ClassDB::bind_method(D_METHOD("is_centered"), &SpriteBase3D::is_centered);
@@ -359,7 +340,6 @@ void SpriteBase3D::_bind_methods() {
}
SpriteBase3D::SpriteBase3D() {
-
color_dirty = true;
centered = true;
hflip = false;
@@ -367,8 +347,9 @@ SpriteBase3D::SpriteBase3D() {
parent_sprite = nullptr;
pI = nullptr;
- for (int i = 0; i < FLAG_MAX; i++)
+ for (int i = 0; i < FLAG_MAX; i++) {
flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED;
+ }
alpha_cut = ALPHA_CUT_DISABLED;
billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED;
@@ -382,46 +363,50 @@ SpriteBase3D::SpriteBase3D() {
}
SpriteBase3D::~SpriteBase3D() {
-
RenderingServer::get_singleton()->free(immediate);
}
///////////////////////////////////////////
void Sprite3D::_draw() {
-
RID immediate = get_immediate();
RS::get_singleton()->immediate_clear(immediate);
- if (!texture.is_valid())
+ if (!texture.is_valid()) {
return;
+ }
Vector2 tsize = texture->get_size();
- if (tsize.x == 0 || tsize.y == 0)
+ if (tsize.x == 0 || tsize.y == 0) {
return;
+ }
Rect2 base_rect;
- if (region)
+ if (region) {
base_rect = region_rect;
- else
+ } else {
base_rect = Rect2(0, 0, texture->get_width(), texture->get_height());
+ }
Size2 frame_size = base_rect.size / Size2(hframes, vframes);
Point2 frame_offset = Point2(frame % hframes, frame / hframes);
frame_offset *= frame_size;
Point2 dest_offset = get_offset();
- if (is_centered())
+ if (is_centered()) {
dest_offset -= frame_size / 2;
+ }
Rect2 src_rect(base_rect.position + frame_offset, frame_size);
Rect2 final_dst_rect(dest_offset, frame_size);
Rect2 final_rect;
Rect2 final_src_rect;
- if (!texture->get_rect_region(final_dst_rect, src_rect, final_rect, final_src_rect))
+ if (!texture->get_rect_region(final_dst_rect, src_rect, final_rect, final_src_rect)) {
return;
+ }
- if (final_rect.size.x == 0 || final_rect.size.y == 0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0) {
return;
+ }
Color color = _get_color_accum();
color.a *= get_opacity();
@@ -458,7 +443,6 @@ void Sprite3D::_draw() {
SWAP(uvs[2], uvs[3]);
}
if (is_flipped_v()) {
-
SWAP(uvs[0], uvs[3]);
SWAP(uvs[1], uvs[2]);
}
@@ -499,7 +483,6 @@ void Sprite3D::_draw() {
AABB aabb;
for (int i = 0; i < 6; i++) {
-
static const int index[6] = { 0, 1, 2, 0, 2, 3 };
RS::get_singleton()->immediate_normal(immediate, normal);
@@ -527,9 +510,9 @@ void Sprite3D::_texture_changed() {
}
void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) {
-
- if (p_texture == texture)
+ if (p_texture == texture) {
return;
+ }
if (texture.is_valid()) {
texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite3D::_texture_changed));
}
@@ -541,26 +524,23 @@ void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) {
}
Ref<Texture2D> Sprite3D::get_texture() const {
-
return texture;
}
void Sprite3D::set_region(bool p_region) {
-
- if (p_region == region)
+ if (p_region == region) {
return;
+ }
region = p_region;
_queue_update();
}
bool Sprite3D::is_region() const {
-
return region;
}
void Sprite3D::set_region_rect(const Rect2 &p_region_rect) {
-
bool changed = region_rect != p_region_rect;
region_rect = p_region_rect;
if (region && changed) {
@@ -569,12 +549,10 @@ void Sprite3D::set_region_rect(const Rect2 &p_region_rect) {
}
Rect2 Sprite3D::get_region_rect() const {
-
return region_rect;
}
void Sprite3D::set_frame(int p_frame) {
-
ERR_FAIL_INDEX(p_frame, int64_t(vframes) * hframes);
frame = p_frame;
@@ -587,7 +565,6 @@ void Sprite3D::set_frame(int p_frame) {
}
int Sprite3D::get_frame() const {
-
return frame;
}
@@ -603,33 +580,31 @@ Vector2 Sprite3D::get_frame_coords() const {
}
void Sprite3D::set_vframes(int p_amount) {
-
ERR_FAIL_COND(p_amount < 1);
vframes = p_amount;
_queue_update();
_change_notify();
}
-int Sprite3D::get_vframes() const {
+int Sprite3D::get_vframes() const {
return vframes;
}
void Sprite3D::set_hframes(int p_amount) {
-
ERR_FAIL_COND(p_amount < 1);
hframes = p_amount;
_queue_update();
_change_notify();
}
-int Sprite3D::get_hframes() const {
+int Sprite3D::get_hframes() const {
return hframes;
}
Rect2 Sprite3D::get_item_rect() const {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return Rect2(0, 0, 1, 1);
+ }
/*
if (texture.is_null())
return CanvasItem::get_item_rect();
@@ -638,7 +613,6 @@ Rect2 Sprite3D::get_item_rect() const {
Size2i s;
if (region) {
-
s = region_rect.size;
} else {
s = texture->get_size();
@@ -646,17 +620,18 @@ Rect2 Sprite3D::get_item_rect() const {
}
Point2 ofs = get_offset();
- if (is_centered())
+ if (is_centered()) {
ofs -= s / 2;
+ }
- if (s == Size2(0, 0))
+ if (s == Size2(0, 0)) {
s = Size2(1, 1);
+ }
return Rect2(ofs, s);
}
void Sprite3D::_validate_property(PropertyInfo &property) const {
-
if (property.name == "frame") {
property.hint = PROPERTY_HINT_RANGE;
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
@@ -669,7 +644,6 @@ void Sprite3D::_validate_property(PropertyInfo &property) const {
}
void Sprite3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite3D::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &Sprite3D::get_texture);
@@ -705,7 +679,6 @@ void Sprite3D::_bind_methods() {
}
Sprite3D::Sprite3D() {
-
region = false;
frame = 0;
vframes = 1;
@@ -715,7 +688,6 @@ Sprite3D::Sprite3D() {
////////////////////////////////////////
void AnimatedSprite3D::_draw() {
-
RID immediate = get_immediate();
RS::get_singleton()->immediate_clear(immediate);
@@ -732,11 +704,13 @@ void AnimatedSprite3D::_draw() {
}
Ref<Texture2D> texture = frames->get_frame(animation, frame);
- if (!texture.is_valid())
+ if (!texture.is_valid()) {
return; //no texuture no life
+ }
Vector2 tsize = texture->get_size();
- if (tsize.x == 0 || tsize.y == 0)
+ if (tsize.x == 0 || tsize.y == 0) {
return;
+ }
Size2i s = tsize;
Rect2 src_rect;
@@ -744,18 +718,21 @@ void AnimatedSprite3D::_draw() {
src_rect.size = s;
Point2 ofs = get_offset();
- if (is_centered())
+ if (is_centered()) {
ofs -= s / 2;
+ }
Rect2 dst_rect(ofs, s);
Rect2 final_rect;
Rect2 final_src_rect;
- if (!texture->get_rect_region(dst_rect, src_rect, final_rect, final_src_rect))
+ if (!texture->get_rect_region(dst_rect, src_rect, final_rect, final_src_rect)) {
return;
+ }
- if (final_rect.size.x == 0 || final_rect.size.y == 0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0) {
return;
+ }
Color color = _get_color_accum();
color.a *= get_opacity();
@@ -792,7 +769,6 @@ void AnimatedSprite3D::_draw() {
SWAP(uvs[2], uvs[3]);
}
if (is_flipped_v()) {
-
SWAP(uvs[0], uvs[3]);
SWAP(uvs[1], uvs[2]);
}
@@ -834,7 +810,6 @@ void AnimatedSprite3D::_draw() {
AABB aabb;
for (int i = 0; i < 6; i++) {
-
static const int indices[6] = {
0, 1, 2,
0, 2, 3
@@ -861,11 +836,10 @@ void AnimatedSprite3D::_draw() {
}
void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
-
- if (!frames.is_valid())
+ if (!frames.is_valid()) {
return;
+ }
if (property.name == "animation") {
-
property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
frames->get_animation_list(&names);
@@ -903,27 +877,27 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
}
void AnimatedSprite3D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_INTERNAL_PROCESS: {
-
- if (frames.is_null())
+ if (frames.is_null()) {
return;
- if (!frames->has_animation(animation))
+ }
+ if (!frames->has_animation(animation)) {
return;
- if (frame < 0)
+ }
+ if (frame < 0) {
return;
+ }
float speed = frames->get_animation_speed(animation);
- if (speed == 0)
+ if (speed == 0) {
return; //do nothing
+ }
float remaining = get_process_delta_time();
while (remaining) {
-
if (timeout <= 0) {
-
timeout = 1.0 / speed;
int fc = frames->get_frame_count(animation);
@@ -950,12 +924,13 @@ void AnimatedSprite3D::_notification(int p_what) {
}
void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
-
- if (frames.is_valid())
+ if (frames.is_valid()) {
frames->disconnect("changed", callable_mp(this, &AnimatedSprite3D::_res_changed));
+ }
frames = p_frames;
- if (frames.is_valid())
+ if (frames.is_valid()) {
frames->connect("changed", callable_mp(this, &AnimatedSprite3D::_res_changed));
+ }
if (!frames.is_valid()) {
frame = 0;
@@ -970,27 +945,28 @@ void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
}
Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const {
-
return frames;
}
void AnimatedSprite3D::set_frame(int p_frame) {
-
if (!frames.is_valid()) {
return;
}
if (frames->has_animation(animation)) {
int limit = frames->get_frame_count(animation);
- if (p_frame >= limit)
+ if (p_frame >= limit) {
p_frame = limit - 1;
+ }
}
- if (p_frame < 0)
+ if (p_frame < 0) {
p_frame = 0;
+ }
- if (frame == p_frame)
+ if (frame == p_frame) {
return;
+ }
frame = p_frame;
_reset_timeout();
@@ -998,36 +974,38 @@ void AnimatedSprite3D::set_frame(int p_frame) {
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
-int AnimatedSprite3D::get_frame() const {
+int AnimatedSprite3D::get_frame() const {
return frame;
}
Rect2 AnimatedSprite3D::get_item_rect() const {
-
if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
return Rect2(0, 0, 1, 1);
}
Ref<Texture2D> t;
- if (animation)
+ if (animation) {
t = frames->get_frame(animation, frame);
- if (t.is_null())
+ }
+ if (t.is_null()) {
return Rect2(0, 0, 1, 1);
+ }
Size2i s = t->get_size();
Point2 ofs = get_offset();
- if (centered)
+ if (centered) {
ofs -= s / 2;
+ }
- if (s == Size2(0, 0))
+ if (s == Size2(0, 0)) {
s = Size2(1, 1);
+ }
return Rect2(ofs, s);
}
void AnimatedSprite3D::_res_changed() {
-
set_frame(frame);
_change_notify("frame");
_change_notify("animation");
@@ -1035,40 +1013,37 @@ void AnimatedSprite3D::_res_changed() {
}
void AnimatedSprite3D::_set_playing(bool p_playing) {
-
- if (playing == p_playing)
+ if (playing == p_playing) {
return;
+ }
playing = p_playing;
_reset_timeout();
set_process_internal(playing);
}
bool AnimatedSprite3D::_is_playing() const {
-
return playing;
}
void AnimatedSprite3D::play(const StringName &p_animation) {
-
- if (p_animation)
+ if (p_animation) {
set_animation(p_animation);
+ }
_set_playing(true);
}
void AnimatedSprite3D::stop() {
-
_set_playing(false);
}
bool AnimatedSprite3D::is_playing() const {
-
return is_processing();
}
void AnimatedSprite3D::_reset_timeout() {
-
- if (!playing)
+ if (!playing) {
return;
+ }
if (frames.is_valid() && frames->has_animation(animation)) {
float speed = frames->get_animation_speed(animation);
@@ -1083,9 +1058,9 @@ void AnimatedSprite3D::_reset_timeout() {
}
void AnimatedSprite3D::set_animation(const StringName &p_animation) {
-
- if (animation == p_animation)
+ if (animation == p_animation) {
return;
+ }
animation = p_animation;
_reset_timeout();
@@ -1093,13 +1068,12 @@ void AnimatedSprite3D::set_animation(const StringName &p_animation) {
_change_notify();
_queue_update();
}
-StringName AnimatedSprite3D::get_animation() const {
+StringName AnimatedSprite3D::get_animation() const {
return animation;
}
String AnimatedSprite3D::get_configuration_warning() const {
-
if (frames.is_null()) {
return TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite3D to display frames.");
}
@@ -1108,7 +1082,6 @@ String AnimatedSprite3D::get_configuration_warning() const {
}
void AnimatedSprite3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite3D::set_sprite_frames);
ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite3D::get_sprite_frames);
@@ -1134,7 +1107,6 @@ void AnimatedSprite3D::_bind_methods() {
}
AnimatedSprite3D::AnimatedSprite3D() {
-
frame = 0;
playing = false;
animation = "default";
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 64bef41fd8..721bed56f1 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -35,7 +35,6 @@
#include "scene/3d/visual_instance_3d.h"
class SpriteBase3D : public GeometryInstance3D {
-
GDCLASS(SpriteBase3D, GeometryInstance3D);
mutable Ref<TriangleMesh> triangle_mesh; //cached
@@ -145,7 +144,6 @@ public:
};
class Sprite3D : public SpriteBase3D {
-
GDCLASS(Sprite3D, SpriteBase3D);
Ref<Texture2D> texture;
@@ -194,7 +192,6 @@ public:
};
class AnimatedSprite3D : public SpriteBase3D {
-
GDCLASS(AnimatedSprite3D, SpriteBase3D);
Ref<SpriteFrames> frames;
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp
index 5c2fa59a21..9c6b940b00 100644
--- a/scene/3d/vehicle_body_3d.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -44,7 +44,7 @@ public:
real_t getDiagonal() const { return m_Adiag; }
- btVehicleJacobianEntry(){};
+ btVehicleJacobianEntry() {}
//constraint between two different rigidbodies
btVehicleJacobianEntry(
const Basis &world2A,
@@ -79,12 +79,11 @@ public:
};
void VehicleWheel3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
- if (!cb)
+ if (!cb) {
return;
+ }
body = cb;
local_xform = get_transform();
cb->wheels.push_back(this);
@@ -94,10 +93,10 @@ void VehicleWheel3D::_notification(int p_what) {
m_wheelAxleCS = get_transform().basis.get_axis(Vector3::AXIS_X).normalized();
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
- if (!cb)
+ if (!cb) {
return;
+ }
cb->wheels.erase(this);
body = nullptr;
}
@@ -112,7 +111,6 @@ String VehicleWheel3D::get_configuration_warning() const {
}
void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) {
-
if (m_raycastInfo.m_isInContact)
{
@@ -145,77 +143,68 @@ void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) {
}
void VehicleWheel3D::set_radius(float p_radius) {
-
m_wheelRadius = p_radius;
update_gizmo();
}
float VehicleWheel3D::get_radius() const {
-
return m_wheelRadius;
}
void VehicleWheel3D::set_suspension_rest_length(float p_length) {
-
m_suspensionRestLength = p_length;
update_gizmo();
}
-float VehicleWheel3D::get_suspension_rest_length() const {
+float VehicleWheel3D::get_suspension_rest_length() const {
return m_suspensionRestLength;
}
void VehicleWheel3D::set_suspension_travel(float p_length) {
-
m_maxSuspensionTravelCm = p_length / 0.01;
}
-float VehicleWheel3D::get_suspension_travel() const {
+float VehicleWheel3D::get_suspension_travel() const {
return m_maxSuspensionTravelCm * 0.01;
}
void VehicleWheel3D::set_suspension_stiffness(float p_value) {
-
m_suspensionStiffness = p_value;
}
-float VehicleWheel3D::get_suspension_stiffness() const {
+float VehicleWheel3D::get_suspension_stiffness() const {
return m_suspensionStiffness;
}
void VehicleWheel3D::set_suspension_max_force(float p_value) {
-
m_maxSuspensionForce = p_value;
}
-float VehicleWheel3D::get_suspension_max_force() const {
+float VehicleWheel3D::get_suspension_max_force() const {
return m_maxSuspensionForce;
}
void VehicleWheel3D::set_damping_compression(float p_value) {
-
m_wheelsDampingCompression = p_value;
}
-float VehicleWheel3D::get_damping_compression() const {
+float VehicleWheel3D::get_damping_compression() const {
return m_wheelsDampingCompression;
}
void VehicleWheel3D::set_damping_relaxation(float p_value) {
-
m_wheelsDampingRelaxation = p_value;
}
-float VehicleWheel3D::get_damping_relaxation() const {
+float VehicleWheel3D::get_damping_relaxation() const {
return m_wheelsDampingRelaxation;
}
void VehicleWheel3D::set_friction_slip(float p_value) {
-
m_frictionSlip = p_value;
}
-float VehicleWheel3D::get_friction_slip() const {
+float VehicleWheel3D::get_friction_slip() const {
return m_frictionSlip;
}
@@ -232,7 +221,6 @@ bool VehicleWheel3D::is_in_contact() const {
}
void VehicleWheel3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel3D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel3D::get_radius);
@@ -303,65 +291,54 @@ void VehicleWheel3D::_bind_methods() {
}
void VehicleWheel3D::set_engine_force(float p_engine_force) {
-
m_engineForce = p_engine_force;
}
float VehicleWheel3D::get_engine_force() const {
-
return m_engineForce;
}
void VehicleWheel3D::set_brake(float p_brake) {
-
m_brake = p_brake;
}
-float VehicleWheel3D::get_brake() const {
+float VehicleWheel3D::get_brake() const {
return m_brake;
}
void VehicleWheel3D::set_steering(float p_steering) {
-
m_steering = p_steering;
}
-float VehicleWheel3D::get_steering() const {
+float VehicleWheel3D::get_steering() const {
return m_steering;
}
void VehicleWheel3D::set_use_as_traction(bool p_enable) {
-
engine_traction = p_enable;
}
bool VehicleWheel3D::is_used_as_traction() const {
-
return engine_traction;
}
void VehicleWheel3D::set_use_as_steering(bool p_enabled) {
-
steers = p_enabled;
}
bool VehicleWheel3D::is_used_as_steering() const {
-
return steers;
}
float VehicleWheel3D::get_skidinfo() const {
-
return m_skidInfo;
}
float VehicleWheel3D::get_rpm() const {
-
return m_rpm;
}
VehicleWheel3D::VehicleWheel3D() {
-
steers = false;
engine_traction = false;
m_steering = real_t(0.);
@@ -389,7 +366,6 @@ VehicleWheel3D::VehicleWheel3D() {
}
void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s) {
-
wheel.m_raycastInfo.m_isInContact = false;
Transform chassisTrans = s->get_transform();
@@ -406,7 +382,6 @@ void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirect
}
void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState3D *s) {
-
VehicleWheel3D &wheel = *wheels[p_idx];
_update_wheel_transform(wheel, s);
@@ -431,7 +406,6 @@ void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState3D *s) {
}
real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
-
VehicleWheel3D &wheel = *wheels[p_idx];
_update_wheel_transform(wheel, s);
@@ -462,8 +436,9 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
wheel.m_raycastInfo.m_contactNormalWS = rr.normal;
wheel.m_raycastInfo.m_isInContact = true;
- if (rr.collider)
+ if (rr.collider) {
wheel.m_raycastInfo.m_groundObject = Object::cast_to<PhysicsBody3D>(rr.collider);
+ }
real_t hitDistance = param * raylen;
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
@@ -514,7 +489,6 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
}
void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) {
-
real_t chassisMass = mass;
for (int w_it = 0; w_it < wheels.size(); w_it++) {
@@ -560,7 +534,6 @@ void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) {
//bilateral constraint between two dynamic objects
void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const Vector3 &pos1,
PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence) {
-
real_t normalLenSqr = normal.length_squared();
//ERR_FAIL_COND( normalLenSqr < real_t(1.1));
@@ -571,15 +544,17 @@ void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const
Vector3 rel_pos1 = pos1 - s->get_transform().origin;
Vector3 rel_pos2;
- if (body2)
+ if (body2) {
rel_pos2 = pos2 - body2->get_global_transform().origin;
+ }
//this jacobian entry could be re-used for all iterations
Vector3 vel1 = s->get_linear_velocity() + (s->get_angular_velocity()).cross(rel_pos1); // * mPos);
Vector3 vel2;
- if (body2)
+ if (body2) {
vel2 = body2->get_linear_velocity() + body2->get_angular_velocity().cross(rel_pos2);
+ }
Vector3 vel = vel1 - vel2;
@@ -668,15 +643,15 @@ VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDir
}
real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) {
-
real_t j1 = 0.f;
const Vector3 &contactPosWorld = contactPoint.m_frictionPositionWorld;
Vector3 rel_pos1 = contactPosWorld - contactPoint.m_s->get_transform().origin;
Vector3 rel_pos2;
- if (contactPoint.m_body1)
+ if (contactPoint.m_body1) {
rel_pos2 = contactPosWorld - contactPoint.m_body1->get_global_transform().origin;
+ }
real_t maxImpulse = contactPoint.m_maxImpulse;
@@ -699,11 +674,11 @@ real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contact
static const real_t sideFrictionStiffness2 = real_t(1.0);
void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
-
//calculate the impulse, so that the wheels don't move sidewards
int numWheel = wheels.size();
- if (!numWheel)
+ if (!numWheel) {
return;
+ }
m_forwardWS.resize(numWheel);
m_axle.resize(numWheel);
@@ -717,13 +692,10 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
}
{
-
for (int i = 0; i < wheels.size(); i++) {
-
VehicleWheel3D &wheelInfo = *wheels[i];
if (wheelInfo.m_raycastInfo.m_isInContact) {
-
//const btTransform& wheelTrans = getWheelTransformWS( i );
Basis wheelBasis0 = wheelInfo.m_worldTransform.basis; //get_global_transform().basis;
@@ -851,7 +823,6 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
}
void VehicleBody3D::_direct_state_changed(Object *p_state) {
-
RigidBody3D::_direct_state_changed(p_state);
state = Object::cast_to<PhysicsDirectBodyState3D>(p_state);
@@ -859,12 +830,10 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) {
float step = state->get_step();
for (int i = 0; i < wheels.size(); i++) {
-
_update_wheel(i, state);
}
for (int i = 0; i < wheels.size(); i++) {
-
_ray_cast(i, state);
wheels[i]->set_transform(state->get_transform().inverse() * wheels[i]->m_worldTransform);
}
@@ -872,7 +841,6 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) {
_update_suspension(state);
for (int i = 0; i < wheels.size(); i++) {
-
//apply suspension force
VehicleWheel3D &wheel = *wheels[i];
@@ -921,49 +889,46 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) {
}
void VehicleBody3D::set_engine_force(float p_engine_force) {
-
engine_force = p_engine_force;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
- if (wheelInfo.engine_traction)
+ if (wheelInfo.engine_traction) {
wheelInfo.m_engineForce = p_engine_force;
+ }
}
}
float VehicleBody3D::get_engine_force() const {
-
return engine_force;
}
void VehicleBody3D::set_brake(float p_brake) {
-
brake = p_brake;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
wheelInfo.m_brake = p_brake;
}
}
-float VehicleBody3D::get_brake() const {
+float VehicleBody3D::get_brake() const {
return brake;
}
void VehicleBody3D::set_steering(float p_steering) {
-
m_steeringValue = p_steering;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
- if (wheelInfo.steers)
+ if (wheelInfo.steers) {
wheelInfo.m_steering = p_steering;
+ }
}
}
-float VehicleBody3D::get_steering() const {
+float VehicleBody3D::get_steering() const {
return m_steeringValue;
}
void VehicleBody3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody3D::set_engine_force);
ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody3D::get_engine_force);
@@ -980,7 +945,6 @@ void VehicleBody3D::_bind_methods() {
}
VehicleBody3D::VehicleBody3D() {
-
m_pitchControl = 0;
m_currentVehicleSpeedKmHour = real_t(0.);
m_steeringValue = real_t(0.);
diff --git a/scene/3d/vehicle_body_3d.h b/scene/3d/vehicle_body_3d.h
index d5e896263d..e76f44acfd 100644
--- a/scene/3d/vehicle_body_3d.h
+++ b/scene/3d/vehicle_body_3d.h
@@ -36,7 +36,6 @@
class VehicleBody3D;
class VehicleWheel3D : public Node3D {
-
GDCLASS(VehicleWheel3D, Node3D);
friend class VehicleBody3D;
@@ -152,7 +151,6 @@ public:
};
class VehicleBody3D : public RigidBody3D {
-
GDCLASS(VehicleBody3D, RigidBody3D);
float engine_force;
diff --git a/scene/3d/velocity_tracker_3d.cpp b/scene/3d/velocity_tracker_3d.cpp
index c9b95e6397..db10f3273b 100644
--- a/scene/3d/velocity_tracker_3d.cpp
+++ b/scene/3d/velocity_tracker_3d.cpp
@@ -32,16 +32,14 @@
#include "core/engine.h"
void VelocityTracker3D::set_track_physics_step(bool p_track_physics_step) {
-
physics_step = p_track_physics_step;
}
bool VelocityTracker3D::is_tracking_physics_step() const {
-
return physics_step;
}
-void VelocityTracker3D::update_position(const Vector3 &p_position) {
+void VelocityTracker3D::update_position(const Vector3 &p_position) {
PositionHistory ph;
ph.position = p_position;
if (physics_step) {
@@ -59,8 +57,8 @@ void VelocityTracker3D::update_position(const Vector3 &p_position) {
position_history.write[0] = ph;
}
-Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
+Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
Vector3 linear_velocity;
float max_time = 1 / 5.0; //maximum time to interpolate a velocity
@@ -90,8 +88,9 @@ Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
delta = double(diff) / 1000000.0;
}
- if (base_time + time_accum + delta > max_time)
+ if (base_time + time_accum + delta > max_time) {
break;
+ }
distance_accum += distance;
time_accum += delta;
@@ -105,7 +104,6 @@ Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
}
void VelocityTracker3D::reset(const Vector3 &p_new_pos) {
-
PositionHistory ph;
ph.position = p_new_pos;
if (physics_step) {
@@ -119,7 +117,6 @@ void VelocityTracker3D::reset(const Vector3 &p_new_pos) {
}
void VelocityTracker3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_track_physics_step", "enable"), &VelocityTracker3D::set_track_physics_step);
ClassDB::bind_method(D_METHOD("is_tracking_physics_step"), &VelocityTracker3D::is_tracking_physics_step);
ClassDB::bind_method(D_METHOD("update_position", "position"), &VelocityTracker3D::update_position);
diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp
index 2707a0a514..a64b0df1cc 100644
--- a/scene/3d/visibility_notifier_3d.cpp
+++ b/scene/3d/visibility_notifier_3d.cpp
@@ -37,7 +37,6 @@
#include "scene/scene_string_names.h"
void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) {
-
ERR_FAIL_COND(cameras.has(p_camera));
cameras.insert(p_camera);
if (cameras.size() == 1) {
@@ -49,7 +48,6 @@ void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) {
}
void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) {
-
ERR_FAIL_COND(!cameras.has(p_camera));
cameras.erase(p_camera);
@@ -62,9 +60,9 @@ void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) {
}
void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) {
-
- if (aabb == p_aabb)
+ if (aabb == p_aabb) {
return;
+ }
aabb = p_aabb;
if (is_inside_world()) {
@@ -76,35 +74,28 @@ void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) {
}
AABB VisibilityNotifier3D::get_aabb() const {
-
return aabb;
}
void VisibilityNotifier3D::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
-
get_world_3d()->_register_notifier(this, get_global_transform().xform(aabb));
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
get_world_3d()->_update_notifier(this, get_global_transform().xform(aabb));
} break;
case NOTIFICATION_EXIT_WORLD: {
-
get_world_3d()->_remove_notifier(this);
} break;
}
}
bool VisibilityNotifier3D::is_on_screen() const {
-
return cameras.size() != 0;
}
void VisibilityNotifier3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibilityNotifier3D::set_aabb);
ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier3D::get_aabb);
ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier3D::is_on_screen);
@@ -118,7 +109,6 @@ void VisibilityNotifier3D::_bind_methods() {
}
VisibilityNotifier3D::VisibilityNotifier3D() {
-
aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
set_notify_transform(true);
}
@@ -126,9 +116,7 @@ VisibilityNotifier3D::VisibilityNotifier3D() {
//////////////////////////////////////
void VisibilityEnabler3D::_screen_enter() {
-
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
-
_change_node_state(E->key(), true);
}
@@ -136,9 +124,7 @@ void VisibilityEnabler3D::_screen_enter() {
}
void VisibilityEnabler3D::_screen_exit() {
-
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
-
_change_node_state(E->key(), false);
}
@@ -146,14 +132,12 @@ void VisibilityEnabler3D::_screen_exit() {
}
void VisibilityEnabler3D::_find_nodes(Node *p_node) {
-
bool add = false;
Variant meta;
{
RigidBody3D *rb = Object::cast_to<RigidBody3D>(p_node);
if (rb && ((rb->get_mode() == RigidBody3D::MODE_CHARACTER || rb->get_mode() == RigidBody3D::MODE_RIGID))) {
-
add = true;
meta = rb->get_mode();
}
@@ -167,7 +151,6 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) {
}
if (add) {
-
p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed), varray(p_node), CONNECT_ONESHOT);
nodes[p_node] = meta;
_change_node_state(p_node, false);
@@ -175,37 +158,38 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) {
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (c->get_filename() != String())
+ if (c->get_filename() != String()) {
continue; //skip, instance
+ }
_find_nodes(c);
}
}
void VisibilityEnabler3D::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Node *from = this;
//find where current scene starts
- while (from->get_parent() && from->get_filename() == String())
+ while (from->get_parent() && from->get_filename() == String()) {
from = from->get_parent();
+ }
_find_nodes(from);
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
-
- if (!visible)
+ if (!visible) {
_change_node_state(E->key(), true);
+ }
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed));
}
@@ -214,35 +198,32 @@ void VisibilityEnabler3D::_notification(int p_what) {
}
void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) {
-
ERR_FAIL_COND(!nodes.has(p_node));
if (enabler[ENABLER_FREEZE_BODIES]) {
RigidBody3D *rb = Object::cast_to<RigidBody3D>(p_node);
- if (rb)
-
+ if (rb) {
rb->set_sleeping(!p_enabled);
+ }
}
if (enabler[ENABLER_PAUSE_ANIMATIONS]) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
if (ap) {
-
ap->set_active(p_enabled);
}
}
}
void VisibilityEnabler3D::_node_removed(Node *p_node) {
-
- if (!visible)
+ if (!visible) {
_change_node_state(p_node, true);
+ }
nodes.erase(p_node);
}
void VisibilityEnabler3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler3D::set_enabler);
ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler3D::is_enabler_enabled);
@@ -255,20 +236,19 @@ void VisibilityEnabler3D::_bind_methods() {
}
void VisibilityEnabler3D::set_enabler(Enabler p_enabler, bool p_enable) {
-
ERR_FAIL_INDEX(p_enabler, ENABLER_MAX);
enabler[p_enabler] = p_enable;
}
-bool VisibilityEnabler3D::is_enabler_enabled(Enabler p_enabler) const {
+bool VisibilityEnabler3D::is_enabler_enabled(Enabler p_enabler) const {
ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false);
return enabler[p_enabler];
}
VisibilityEnabler3D::VisibilityEnabler3D() {
-
- for (int i = 0; i < ENABLER_MAX; i++)
+ for (int i = 0; i < ENABLER_MAX; i++) {
enabler[i] = true;
+ }
visible = false;
}
diff --git a/scene/3d/visibility_notifier_3d.h b/scene/3d/visibility_notifier_3d.h
index 19204a6a4e..3864b398f4 100644
--- a/scene/3d/visibility_notifier_3d.h
+++ b/scene/3d/visibility_notifier_3d.h
@@ -35,7 +35,6 @@
class Camera3D;
class VisibilityNotifier3D : public Node3D {
-
GDCLASS(VisibilityNotifier3D, Node3D);
Set<Camera3D *> cameras;
@@ -62,7 +61,6 @@ public:
};
class VisibilityEnabler3D : public VisibilityNotifier3D {
-
GDCLASS(VisibilityEnabler3D, VisibilityNotifier3D);
public:
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp
index 4724c88a30..a1c498e8ab 100644
--- a/scene/3d/visual_instance_3d.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -35,25 +35,21 @@
#include "skeleton_3d.h"
AABB VisualInstance3D::get_transformed_aabb() const {
-
return get_global_transform().xform(get_aabb());
}
void VisualInstance3D::_update_visibility() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_change_notify("visible");
RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree());
}
void VisualInstance3D::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_WORLD: {
-
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
/*
Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent());
@@ -66,42 +62,35 @@ void VisualInstance3D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
Transform gt = get_global_transform();
RenderingServer::get_singleton()->instance_set_transform(instance, gt);
} break;
case NOTIFICATION_EXIT_WORLD: {
-
RenderingServer::get_singleton()->instance_set_scenario(instance, RID());
RenderingServer::get_singleton()->instance_attach_skeleton(instance, RID());
//RS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
_update_visibility();
} break;
}
}
RID VisualInstance3D::get_instance() const {
-
return instance;
}
RID VisualInstance3D::_get_visual_instance_rid() const {
-
return instance;
}
void VisualInstance3D::set_layer_mask(uint32_t p_mask) {
-
layers = p_mask;
RenderingServer::get_singleton()->instance_set_layer_mask(instance, p_mask);
}
uint32_t VisualInstance3D::get_layer_mask() const {
-
return layers;
}
@@ -120,7 +109,6 @@ bool VisualInstance3D::get_layer_mask_bit(int p_layer) const {
}
void VisualInstance3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance3D::_get_visual_instance_rid);
ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance3D::set_base);
ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance3D::get_base);
@@ -136,18 +124,15 @@ void VisualInstance3D::_bind_methods() {
}
void VisualInstance3D::set_base(const RID &p_base) {
-
RenderingServer::get_singleton()->instance_set_base(instance, p_base);
base = p_base;
}
RID VisualInstance3D::get_base() const {
-
return base;
}
VisualInstance3D::VisualInstance3D() {
-
instance = RenderingServer::get_singleton()->instance_create();
RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id());
layers = 1;
@@ -155,62 +140,51 @@ VisualInstance3D::VisualInstance3D() {
}
VisualInstance3D::~VisualInstance3D() {
-
RenderingServer::get_singleton()->free(instance);
}
void GeometryInstance3D::set_material_override(const Ref<Material> &p_material) {
-
material_override = p_material;
RS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID());
}
Ref<Material> GeometryInstance3D::get_material_override() const {
-
return material_override;
}
void GeometryInstance3D::set_lod_min_distance(float p_dist) {
-
lod_min_distance = p_dist;
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
float GeometryInstance3D::get_lod_min_distance() const {
-
return lod_min_distance;
}
void GeometryInstance3D::set_lod_max_distance(float p_dist) {
-
lod_max_distance = p_dist;
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
float GeometryInstance3D::get_lod_max_distance() const {
-
return lod_max_distance;
}
void GeometryInstance3D::set_lod_min_hysteresis(float p_dist) {
-
lod_min_hysteresis = p_dist;
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
float GeometryInstance3D::get_lod_min_hysteresis() const {
-
return lod_min_hysteresis;
}
void GeometryInstance3D::set_lod_max_hysteresis(float p_dist) {
-
lod_max_hysteresis = p_dist;
RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis);
}
float GeometryInstance3D::get_lod_max_hysteresis() const {
-
return lod_max_hysteresis;
}
@@ -262,6 +236,7 @@ bool GeometryInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
+
void GeometryInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
List<PropertyInfo> pinfo;
RS::get_singleton()->instance_geometry_get_shader_parameter_list(get_instance(), &pinfo);
@@ -284,31 +259,26 @@ void GeometryInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
}
void GeometryInstance3D::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
-
shadow_casting_setting = p_shadow_casting_setting;
RS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (RS::ShadowCastingSetting)p_shadow_casting_setting);
}
GeometryInstance3D::ShadowCastingSetting GeometryInstance3D::get_cast_shadows_setting() const {
-
return shadow_casting_setting;
}
void GeometryInstance3D::set_extra_cull_margin(float p_margin) {
-
ERR_FAIL_COND(p_margin < 0);
extra_cull_margin = p_margin;
RS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin);
}
float GeometryInstance3D::get_extra_cull_margin() const {
-
return extra_cull_margin;
}
void GeometryInstance3D::set_shader_instance_uniform(const StringName &p_uniform, const Variant &p_value) {
-
if (p_value.get_type() == Variant::NIL) {
Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), p_uniform);
RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_uniform, def_value);
@@ -320,11 +290,10 @@ void GeometryInstance3D::set_shader_instance_uniform(const StringName &p_uniform
}
Variant GeometryInstance3D::get_shader_instance_uniform(const StringName &p_uniform) const {
-
return RS::get_singleton()->instance_geometry_get_shader_parameter(get_instance(), p_uniform);
}
-void GeometryInstance3D::set_custom_aabb(AABB aabb) {
+void GeometryInstance3D::set_custom_aabb(AABB aabb) {
RS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb);
}
@@ -338,7 +307,6 @@ GeometryInstance3D::LightmapScale GeometryInstance3D::get_lightmap_scale() const
}
void GeometryInstance3D::set_gi_mode(GIMode p_mode) {
-
switch (p_mode) {
case GI_MODE_DISABLED: {
RS::get_singleton()->instance_geometry_set_flag(get_instance(), RS::INSTANCE_FLAG_USE_BAKED_LIGHT, false);
@@ -363,7 +331,6 @@ GeometryInstance3D::GIMode GeometryInstance3D::get_gi_mode() const {
}
void GeometryInstance3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_material_override", "material"), &GeometryInstance3D::set_material_override);
ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance3D::get_material_override);
diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h
index a871c65b6a..195674f62d 100644
--- a/scene/3d/visual_instance_3d.h
+++ b/scene/3d/visual_instance_3d.h
@@ -37,7 +37,6 @@
#include "scene/resources/material.h"
class VisualInstance3D : public Node3D {
-
GDCLASS(VisualInstance3D, Node3D);
OBJ_CATEGORY("3D Visual Nodes");
@@ -81,7 +80,6 @@ public:
};
class GeometryInstance3D : public VisualInstance3D {
-
GDCLASS(GeometryInstance3D, VisualInstance3D);
public:
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index f9c3810843..de5496ee35 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -29,14 +29,13 @@
/*************************************************************************/
#include "voxelizer.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/os/os.h"
#include "core/os/threaded_array_processor.h"
#include <stdlib.h>
static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3 *p_vtx, const Vector2 *p_uv, const Vector3 *p_normal, Vector2 &r_uv, Vector3 &r_normal) {
-
if (p_pos.distance_squared_to(p_vtx[0]) < CMP_EPSILON2) {
r_uv = p_uv[0];
r_normal = p_normal[0];
@@ -77,7 +76,6 @@ static _FORCE_INLINE_ void get_uv_and_normal(const Vector3 &p_pos, const Vector3
}
void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector3 *p_normal, const Vector2 *p_uv, const MaterialCache &p_material, const AABB &p_aabb) {
-
if (p_level == cell_subdiv) {
//plot the face by guessing its albedo and emission value
@@ -89,7 +87,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector3 normal = plane.normal;
for (int i = 0; i < 3; i++) {
-
Vector3 axis;
axis[i] = 1.0;
float dot = ABS(normal.dot(axis));
@@ -117,11 +114,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
//map to a grid average in the best axis for this face
for (int i = 0; i < color_scan_cell_width; i++) {
-
Vector3 ofs_i = float(i) * t1;
for (int j = 0; j < color_scan_cell_width; j++) {
-
Vector3 ofs_j = float(j) * t2;
Vector3 from = p_aabb.position + ofs_i + ofs_j;
@@ -129,7 +124,7 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector3 half = (to - from) * 0.5;
//is in this cell?
- if (!Geometry::triangle_box_overlap(from + half, half, p_vtx)) {
+ if (!Geometry3D::triangle_box_overlap(from + half, half, p_vtx)) {
continue; //face does not span this cell
}
@@ -147,7 +142,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
if (ABS(plane.distance_to(ray_from)) < ABS(plane.distance_to(ray_to))) {
intersection = plane.project(ray_from);
} else {
-
intersection = plane.project(ray_to);
}
}
@@ -157,8 +151,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector2 uv;
Vector3 lnormal;
get_uv_and_normal(intersection, p_vtx, p_uv, p_normal, uv, lnormal);
- if (lnormal == Vector3()) //just in case normal as nor provided
+ if (lnormal == Vector3()) { //just in case normal as nor provided
lnormal = normal;
+ }
int uv_x = CLAMP(int(Math::fposmod(uv.x, 1.0f) * bake_texture_size), 0, bake_texture_size - 1);
int uv_y = CLAMP(int(Math::fposmod(uv.y, 1.0f) * bake_texture_size), 0, bake_texture_size - 1);
@@ -188,8 +183,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector3 lnormal;
Vector2 uv;
get_uv_and_normal(inters, p_vtx, p_uv, p_normal, uv, normal);
- if (lnormal == Vector3()) //just in case normal as nor provided
+ if (lnormal == Vector3()) { //just in case normal as nor provided
lnormal = normal;
+ }
int uv_x = CLAMP(Math::fposmod(uv.x, 1.0f) * bake_texture_size, 0, bake_texture_size - 1);
int uv_y = CLAMP(Math::fposmod(uv.y, 1.0f) * bake_texture_size, 0, bake_texture_size - 1);
@@ -210,7 +206,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
normal_accum = lnormal * alpha;
} else {
-
float accdiv = 1.0 / (color_scan_cell_width * color_scan_cell_width);
alpha *= accdiv;
@@ -243,7 +238,6 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
int half = (1 << cell_subdiv) >> (p_level + 1);
for (int i = 0; i < 8; i++) {
-
AABB aabb = p_aabb;
aabb.size *= 0.5;
@@ -264,15 +258,16 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
nz += half;
}
//make sure to not plot beyond limits
- if (nx < 0 || nx >= axis_cell_size[0] || ny < 0 || ny >= axis_cell_size[1] || nz < 0 || nz >= axis_cell_size[2])
+ if (nx < 0 || nx >= axis_cell_size[0] || ny < 0 || ny >= axis_cell_size[1] || nz < 0 || nz >= axis_cell_size[2]) {
continue;
+ }
{
AABB test_aabb = aabb;
//test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time
Vector3 qsize = test_aabb.size * 0.5; //quarter size, for fast aabb test
- if (!Geometry::triangle_box_overlap(test_aabb.position + qsize, qsize, p_vtx)) {
+ if (!Geometry3D::triangle_box_overlap(test_aabb.position + qsize, qsize, p_vtx)) {
//if (!Face3(p_vtx[0],p_vtx[1],p_vtx[2]).intersects_aabb2(aabb)) {
//does not fit in child, go on
continue;
@@ -297,11 +292,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
}
Vector<Color> Voxelizer::_get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add) {
-
Vector<Color> ret;
if (p_image.is_null() || p_image->empty()) {
-
ret.resize(bake_texture_size * bake_texture_size);
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
ret.write[i] = p_color_add;
@@ -335,7 +328,6 @@ Vector<Color> Voxelizer::_get_bake_texture(Ref<Image> p_image, const Color &p_co
}
Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material) {
-
//this way of obtaining materials is inaccurate and also does not support some compressed formats very well
Ref<StandardMaterial3D> mat = p_material;
@@ -348,12 +340,10 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
MaterialCache mc;
if (mat.is_valid()) {
-
Ref<Texture2D> albedo_tex = mat->get_texture(StandardMaterial3D::TEXTURE_ALBEDO);
Ref<Image> img_albedo;
if (albedo_tex.is_valid()) {
-
img_albedo = albedo_tex->get_data();
mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), Color(0, 0, 0)); // albedo texture, color is multiplicative
} else {
@@ -368,7 +358,6 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
Ref<Image> img_emission;
if (emission_tex.is_valid()) {
-
img_emission = emission_tex->get_data();
}
@@ -390,11 +379,10 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
}
void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material) {
-
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
-
- if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue; //only triangles
+ }
Ref<Material> src_material;
@@ -426,12 +414,10 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
if (index.size()) {
-
int facecount = index.size() / 3;
const int *ir = index.ptr();
for (int j = 0; j < facecount; j++) {
-
Vector3 vtxs[3];
Vector2 uvs[3];
Vector3 normal[3];
@@ -453,18 +439,17 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
//test against original bounds
- if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs))
+ if (!Geometry3D::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
continue;
+ }
//plot
_plot_face(0, 0, 0, 0, 0, vtxs, normal, uvs, material, po2_bounds);
}
} else {
-
int facecount = vertices.size() / 3;
for (int j = 0; j < facecount; j++) {
-
Vector3 vtxs[3];
Vector2 uvs[3];
Vector3 normal[3];
@@ -486,8 +471,9 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
//test against original bounds
- if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs))
+ if (!Geometry3D::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
continue;
+ }
//plot face
_plot_face(0, 0, 0, 0, 0, vtxs, normal, uvs, material, po2_bounds);
}
@@ -498,7 +484,6 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
void Voxelizer::_sort() {
-
// cells need to be sorted by level and coordinates
// it is important that level has more priority (for compute), and that Z has the least,
// given it may aid older implementations plot using GPU
@@ -507,7 +492,6 @@ void Voxelizer::_sort() {
uint32_t cell_count = bake_cells.size();
sorted_cells.resize(cell_count);
{
-
CellSort *sort_cellsp = sorted_cells.ptrw();
const Cell *bake_cellsp = bake_cells.ptr();
@@ -540,7 +524,6 @@ void Voxelizer::_sort() {
}
{
-
const CellSort *sort_cellsp = sorted_cells.ptr();
const Cell *bake_cellsp = bake_cells.ptr();
const uint32_t *reverse_mapp = reverse_map.ptr();
@@ -563,9 +546,7 @@ void Voxelizer::_sort() {
}
void Voxelizer::_fixup_plot(int p_idx, int p_level) {
-
if (p_level == cell_subdiv) {
-
leaf_voxel_count++;
float alpha = bake_cells[p_idx].alpha;
@@ -604,7 +585,6 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) {
}*/
} else {
-
//go down
bake_cells.write[p_idx].emission[0] = 0;
@@ -621,11 +601,11 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) {
int children_found = 0;
for (int i = 0; i < 8; i++) {
-
uint32_t child = bake_cells[p_idx].children[i];
- if (child == CHILD_EMPTY)
+ if (child == CHILD_EMPTY) {
continue;
+ }
_fixup_plot(child, p_level + 1);
alpha_average += bake_cells[child].alpha;
@@ -638,7 +618,6 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) {
}
void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds) {
-
sorted = false;
original_bounds = p_bounds;
cell_subdiv = p_subdiv;
@@ -653,9 +632,9 @@ void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds) {
leaf_voxel_count = 0;
for (int i = 0; i < 3; i++) {
-
- if (i == longest_axis)
+ if (i == longest_axis) {
continue;
+ }
axis_cell_size[i] = axis_cell_size[longest_axis];
float axis_size = po2_bounds.size[longest_axis];
@@ -693,9 +672,11 @@ void Voxelizer::end_bake() {
int Voxelizer::get_gi_probe_octree_depth() const {
return cell_subdiv;
}
+
Vector3i Voxelizer::get_giprobe_octree_size() const {
return Vector3i(axis_cell_size[0], axis_cell_size[1], axis_cell_size[2]);
}
+
int Voxelizer::get_giprobe_cell_count() const {
return bake_cells.size();
}
@@ -711,7 +692,6 @@ Vector<uint8_t> Voxelizer::get_giprobe_octree_cells() const {
uint32_t cell_count = bake_cells.size();
for (uint32_t i = 0; i < cell_count; i++) {
-
for (uint32_t j = 0; j < 8; j++) {
children_cells[i * 8 + j] = cells[i].children[j];
}
@@ -720,6 +700,7 @@ Vector<uint8_t> Voxelizer::get_giprobe_octree_cells() const {
return data;
}
+
Vector<uint8_t> Voxelizer::get_giprobe_data_cells() const {
Vector<uint8_t> data;
data.resize((4 * 4) * bake_cells.size()); //8 uint32t values
@@ -731,7 +712,6 @@ Vector<uint8_t> Voxelizer::get_giprobe_data_cells() const {
uint32_t cell_count = bake_cells.size();
for (uint32_t i = 0; i < cell_count; i++) {
-
{ //position
uint32_t x = cells[i].x;
@@ -803,7 +783,6 @@ Vector<int> Voxelizer::get_giprobe_level_cell_count() const {
/* dt of 1d function using squared distance */
static void edt(float *f, int stride, int n) {
-
float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1));
int *v = (int *)&(d[n]);
float *z = (float *)&v[n];
@@ -827,8 +806,9 @@ static void edt(float *f, int stride, int n) {
k = 0;
for (int q = 0; q <= n - 1; q++) {
- while (z[k + 1] < q)
+ while (z[k + 1] < q) {
k++;
+ }
d[q] = square(q - v[k]) + f[v[k] * stride];
}
@@ -840,7 +820,6 @@ static void edt(float *f, int stride, int n) {
#undef square
Vector<uint8_t> Voxelizer::get_sdf_3d_image() const {
-
Vector3i octree_size = get_giprobe_octree_size();
uint32_t float_count = octree_size.x * octree_size.y * octree_size.z;
@@ -858,7 +837,6 @@ Vector<uint8_t> Voxelizer::get_sdf_3d_image() const {
uint32_t cell_count = bake_cells.size();
for (uint32_t i = 0; i < cell_count; i++) {
-
if (cells[i].level < (cell_subdiv - 1)) {
continue; //do not care about this level
}
@@ -912,9 +890,7 @@ Vector<uint8_t> Voxelizer::get_sdf_3d_image() const {
#undef INF
void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx) {
-
if (p_level == cell_subdiv - 1) {
-
Vector3 center = p_aabb.position + p_aabb.size * 0.5;
Transform xform;
xform.origin = center;
@@ -928,23 +904,25 @@ void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<Mult
idx++;
} else {
-
for (int i = 0; i < 8; i++) {
-
uint32_t child = bake_cells[p_idx].children[i];
- if (child == CHILD_EMPTY || child >= (uint32_t)max_original_cells)
+ if (child == CHILD_EMPTY || child >= (uint32_t)max_original_cells) {
continue;
+ }
AABB aabb = p_aabb;
aabb.size *= 0.5;
- if (i & 1)
+ if (i & 1) {
aabb.position.x += aabb.size.x;
- if (i & 2)
+ }
+ if (i & 2) {
aabb.position.y += aabb.size.y;
- if (i & 4)
+ }
+ if (i & 4) {
aabb.position.z += aabb.size.z;
+ }
_debug_mesh(bake_cells[p_idx].children[i], p_level + 1, aabb, p_multimesh, idx);
}
@@ -952,7 +930,6 @@ void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<Mult
}
Ref<MultiMesh> Voxelizer::create_debug_multimesh() {
-
Ref<MultiMesh> mm;
mm.instance();
@@ -975,22 +952,20 @@ Ref<MultiMesh> Voxelizer::create_debug_multimesh() {
colors.push_back(Color(1, 1, 1, 1));
for (int i = 0; i < 6; i++) {
-
Vector3 face_points[4];
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)
+ if (i < 3) {
face_points[j][(i + k) % 3] = v[k];
- else
+ } else {
face_points[3 - j][(i + k) % 3] = -v[k];
+ }
}
}
@@ -1031,6 +1006,7 @@ Ref<MultiMesh> Voxelizer::create_debug_multimesh() {
Transform Voxelizer::get_to_cell_space_xform() const {
return to_cell_space;
}
+
Voxelizer::Voxelizer() {
sorted = false;
color_scan_cell_width = 4;
diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h
index 1fde6237a2..3546fd7729 100644
--- a/scene/3d/voxelizer.h
+++ b/scene/3d/voxelizer.h
@@ -43,7 +43,6 @@ private:
};
struct Cell {
-
uint32_t children[8];
float albedo[3]; //albedo in RGB24
float emission[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast)
diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp
index 8dbb709ae4..24071f31f3 100644
--- a/scene/3d/world_environment.cpp
+++ b/scene/3d/world_environment.cpp
@@ -32,9 +32,7 @@
#include "scene/main/window.h"
void WorldEnvironment::_notification(int p_what) {
-
if (p_what == Node3D::NOTIFICATION_ENTER_WORLD || p_what == Node3D::NOTIFICATION_ENTER_TREE) {
-
if (environment.is_valid()) {
if (get_viewport()->find_world_3d()->get_environment().is_valid()) {
WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
@@ -52,7 +50,6 @@ void WorldEnvironment::_notification(int p_what) {
}
} else if (p_what == Node3D::NOTIFICATION_EXIT_WORLD || p_what == Node3D::NOTIFICATION_EXIT_TREE) {
-
if (environment.is_valid() && get_viewport()->find_world_3d()->get_environment() == environment) {
get_viewport()->find_world_3d()->set_environment(Ref<Environment>());
remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()));
@@ -66,7 +63,6 @@ void WorldEnvironment::_notification(int p_what) {
}
void WorldEnvironment::set_environment(const Ref<Environment> &p_environment) {
-
if (is_inside_tree() && environment.is_valid() && get_viewport()->find_world_3d()->get_environment() == environment) {
get_viewport()->find_world_3d()->set_environment(Ref<Environment>());
remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()));
@@ -86,12 +82,10 @@ void WorldEnvironment::set_environment(const Ref<Environment> &p_environment) {
}
Ref<Environment> WorldEnvironment::get_environment() const {
-
return environment;
}
void WorldEnvironment::set_camera_effects(const Ref<CameraEffects> &p_camera_effects) {
-
if (is_inside_tree() && camera_effects.is_valid() && get_viewport()->find_world_3d()->get_camera_effects() == camera_effects) {
get_viewport()->find_world_3d()->set_camera_effects(Ref<CameraEffects>());
remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()));
@@ -111,18 +105,17 @@ void WorldEnvironment::set_camera_effects(const Ref<CameraEffects> &p_camera_eff
}
Ref<CameraEffects> WorldEnvironment::get_camera_effects() const {
-
return camera_effects;
}
String WorldEnvironment::get_configuration_warning() const {
-
if (!environment.is_valid()) {
return TTR("WorldEnvironment requires its \"Environment\" property to contain an Environment to have a visible effect.");
}
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return String();
+ }
List<Node *> nodes;
get_tree()->get_nodes_in_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()), &nodes);
@@ -135,7 +128,6 @@ String WorldEnvironment::get_configuration_warning() const {
}
void WorldEnvironment::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_environment", "env"), &WorldEnvironment::set_environment);
ClassDB::bind_method(D_METHOD("get_environment"), &WorldEnvironment::get_environment);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment");
diff --git a/scene/3d/world_environment.h b/scene/3d/world_environment.h
index e4c9fc071d..ddb2af7bd3 100644
--- a/scene/3d/world_environment.h
+++ b/scene/3d/world_environment.h
@@ -34,7 +34,6 @@
#include "scene/3d/node_3d.h"
class WorldEnvironment : public Node {
-
GDCLASS(WorldEnvironment, Node);
Ref<Environment> environment;
diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp
index 6f41629bac..f4a514cdd6 100644
--- a/scene/3d/xr_nodes.cpp
+++ b/scene/3d/xr_nodes.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "xr_nodes.h"
+
#include "core/input/input.h"
#include "servers/xr/xr_interface.h"
#include "servers/xr_server.h"
@@ -55,8 +56,9 @@ void XRCamera3D::_notification(int p_what) {
};
String XRCamera3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
// must be child node of XROrigin3D!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
@@ -167,14 +169,6 @@ Vector<Plane> XRCamera3D::get_frustum() const {
return cm.get_projection_planes(get_camera_transform());
};
-XRCamera3D::XRCamera3D(){
- // nothing to do here yet for now..
-};
-
-XRCamera3D::~XRCamera3D(){
- // nothing to do here yet for now..
-};
-
////////////////////////////////////////////////////////////////////////////////////////////////////
void XRController3D::_notification(int p_what) {
@@ -269,11 +263,11 @@ void XRController3D::set_controller_id(int p_controller_id) {
update_configuration_warning();
};
-int XRController3D::get_controller_id(void) const {
+int XRController3D::get_controller_id() const {
return controller_id;
};
-String XRController3D::get_controller_name(void) const {
+String XRController3D::get_controller_name() const {
// get our XRServer
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL_V(xr_server, String());
@@ -364,8 +358,9 @@ XRPositionalTracker::TrackerHand XRController3D::get_hand() const {
};
String XRController3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
// must be child node of XROrigin!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
@@ -380,16 +375,6 @@ String XRController3D::get_configuration_warning() const {
return String();
};
-XRController3D::XRController3D() {
- controller_id = 1;
- is_active = true;
- button_states = 0;
-};
-
-XRController3D::~XRController3D(){
- // nothing to do here yet for now..
-};
-
////////////////////////////////////////////////////////////////////////////////////////////////////
void XRAnchor3D::_notification(int p_what) {
@@ -443,7 +428,6 @@ void XRAnchor3D::_notification(int p_what) {
};
void XRAnchor3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &XRAnchor3D::set_anchor_id);
ClassDB::bind_method(D_METHOD("get_anchor_id"), &XRAnchor3D::get_anchor_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id");
@@ -465,7 +449,7 @@ void XRAnchor3D::set_anchor_id(int p_anchor_id) {
update_configuration_warning();
};
-int XRAnchor3D::get_anchor_id(void) const {
+int XRAnchor3D::get_anchor_id() const {
return anchor_id;
};
@@ -473,7 +457,7 @@ Vector3 XRAnchor3D::get_size() const {
return size;
};
-String XRAnchor3D::get_anchor_name(void) const {
+String XRAnchor3D::get_anchor_name() const {
// get our XRServer
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL_V(xr_server, String());
@@ -491,8 +475,9 @@ bool XRAnchor3D::get_is_active() const {
};
String XRAnchor3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
// must be child node of XROrigin3D!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
@@ -520,23 +505,16 @@ Ref<Mesh> XRAnchor3D::get_mesh() const {
return mesh;
}
-XRAnchor3D::XRAnchor3D() {
- anchor_id = 1;
- is_active = true;
-};
-
-XRAnchor3D::~XRAnchor3D(){
- // nothing to do here yet for now..
-};
-
////////////////////////////////////////////////////////////////////////////////////////////////////
String XROrigin3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
- if (tracked_camera == nullptr)
+ if (tracked_camera == nullptr) {
return TTR("XROrigin3D requires an XRCamera3D child node.");
+ }
return String();
};
@@ -611,11 +589,3 @@ void XROrigin3D::_notification(int p_what) {
}
}
};
-
-XROrigin3D::XROrigin3D() {
- tracked_camera = nullptr;
-};
-
-XROrigin3D::~XROrigin3D(){
- // nothing to do here yet for now..
-};
diff --git a/scene/3d/xr_nodes.h b/scene/3d/xr_nodes.h
index a2f16545d1..4d4f82aa38 100644
--- a/scene/3d/xr_nodes.h
+++ b/scene/3d/xr_nodes.h
@@ -44,7 +44,6 @@
XRCamera is a subclass of camera which will register itself with its parent XROrigin and as a result is automatically positioned
*/
class XRCamera3D : public Camera3D {
-
GDCLASS(XRCamera3D, Camera3D);
protected:
@@ -58,8 +57,8 @@ public:
virtual Vector3 project_position(const Point2 &p_point, float p_z_depth) const;
virtual Vector<Plane> get_frustum() const;
- XRCamera3D();
- ~XRCamera3D();
+ XRCamera3D() {}
+ ~XRCamera3D() {}
};
/*
@@ -69,13 +68,12 @@ public:
*/
class XRController3D : public Node3D {
-
GDCLASS(XRController3D, Node3D);
private:
- int controller_id;
- bool is_active;
- int button_states;
+ int controller_id = 1;
+ bool is_active = true;
+ int button_states = 0;
Ref<Mesh> mesh;
protected:
@@ -84,8 +82,8 @@ protected:
public:
void set_controller_id(int p_controller_id);
- int get_controller_id(void) const;
- String get_controller_name(void) const;
+ int get_controller_id() const;
+ String get_controller_name() const;
int get_joystick_id() const;
bool is_button_pressed(int p_button) const;
@@ -97,12 +95,12 @@ public:
bool get_is_active() const;
XRPositionalTracker::TrackerHand get_hand() const;
- Ref<Mesh> get_mesh(void) const;
+ Ref<Mesh> get_mesh() const;
String get_configuration_warning() const;
- XRController3D();
- ~XRController3D();
+ XRController3D() {}
+ ~XRController3D() {}
};
/*
@@ -114,8 +112,8 @@ class XRAnchor3D : public Node3D {
GDCLASS(XRAnchor3D, Node3D);
private:
- int anchor_id;
- bool is_active;
+ int anchor_id = 1;
+ bool is_active = true;
Vector3 size;
Ref<Mesh> mesh;
@@ -125,20 +123,20 @@ protected:
public:
void set_anchor_id(int p_anchor_id);
- int get_anchor_id(void) const;
- String get_anchor_name(void) const;
+ int get_anchor_id() const;
+ String get_anchor_name() const;
bool get_is_active() const;
Vector3 get_size() const;
Plane get_plane() const;
- Ref<Mesh> get_mesh(void) const;
+ Ref<Mesh> get_mesh() const;
String get_configuration_warning() const;
- XRAnchor3D();
- ~XRAnchor3D();
+ XRAnchor3D() {}
+ ~XRAnchor3D() {}
};
/*
@@ -150,11 +148,10 @@ public:
This node will automatically locate any camera child nodes and update its position while our XRController3D node will handle tracked controllers.
*/
class XROrigin3D : public Node3D {
-
GDCLASS(XROrigin3D, Node3D);
private:
- XRCamera3D *tracked_camera;
+ XRCamera3D *tracked_camera = nullptr;
protected:
void _notification(int p_what);
@@ -169,8 +166,8 @@ public:
float get_world_scale() const;
void set_world_scale(float p_world_scale);
- XROrigin3D();
- ~XROrigin3D();
+ XROrigin3D() {}
+ ~XROrigin3D() {}
};
#endif /* XR_NODES_H */
diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp
index 3502f5e961..e426e98def 100644
--- a/scene/animation/animation_blend_space_1d.cpp
+++ b/scene/animation/animation_blend_space_1d.cpp
@@ -33,6 +33,7 @@
void AnimationNodeBlendSpace1D::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, blend_position));
}
+
Variant AnimationNodeBlendSpace1D::get_parameter_default_value(const StringName &p_parameter) const {
return 0;
}
@@ -167,7 +168,6 @@ void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) {
}
int AnimationNodeBlendSpace1D::get_blend_point_count() const {
-
return blend_points_used;
}
@@ -220,7 +220,6 @@ void AnimationNodeBlendSpace1D::_add_blend_point(int p_index, const Ref<Animatio
}
float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) {
-
if (blend_points_used == 0) {
return 0.0;
}
@@ -241,7 +240,6 @@ float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) {
// find the closest two points to blend between
for (int i = 0; i < blend_points_used; i++) {
-
float pos = blend_points[i].position;
if (pos <= blend_pos) {
@@ -276,7 +274,6 @@ float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) {
weights[point_lower] = 1.0;
} else {
-
// we are between two points.
// figure out weights, then blend the animations
@@ -311,7 +308,6 @@ String AnimationNodeBlendSpace1D::get_caption() const {
}
AnimationNodeBlendSpace1D::AnimationNodeBlendSpace1D() {
-
for (int i = 0; i < MAX_BLEND_POINTS; i++) {
blend_points[i].name = itos(i);
}
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index ad60249f9a..5a42e2af7a 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -30,13 +30,14 @@
#include "animation_blend_space_2d.h"
-#include "core/math/delaunay_2d.h"
+#include "core/math/geometry_2d.h"
void AnimationNodeBlendSpace2D::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::VECTOR2, blend_position));
r_list->push_back(PropertyInfo(Variant::INT, closest, PROPERTY_HINT_NONE, "", 0));
r_list->push_back(PropertyInfo(Variant::FLOAT, length_internal, PROPERTY_HINT_NONE, "", 0));
}
+
Variant AnimationNodeBlendSpace2D::get_parameter_default_value(const StringName &p_parameter) const {
if (p_parameter == closest) {
return -1;
@@ -91,6 +92,7 @@ void AnimationNodeBlendSpace2D::set_blend_point_position(int p_point, const Vect
blend_points[p_point].position = p_position;
_queue_auto_triangles();
}
+
void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node) {
ERR_FAIL_INDEX(p_point, blend_points_used);
ERR_FAIL_COND(p_node.is_null());
@@ -103,14 +105,17 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim
emit_signal("tree_changed");
}
+
Vector2 AnimationNodeBlendSpace2D::get_blend_point_position(int p_point) const {
ERR_FAIL_INDEX_V(p_point, blend_points_used, Vector2());
return blend_points[p_point].position;
}
+
Ref<AnimationRootNode> AnimationNodeBlendSpace2D::get_blend_point_node(int p_point) const {
ERR_FAIL_INDEX_V(p_point, blend_points_used, Ref<AnimationRootNode>());
return blend_points[p_point].node;
}
+
void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) {
ERR_FAIL_INDEX(p_point, blend_points_used);
@@ -142,12 +147,10 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) {
}
int AnimationNodeBlendSpace2D::get_blend_point_count() const {
-
return blend_points_used;
}
bool AnimationNodeBlendSpace2D::has_triangle(int p_x, int p_y, int p_z) const {
-
ERR_FAIL_INDEX_V(p_x, blend_points_used, false);
ERR_FAIL_INDEX_V(p_y, blend_points_used, false);
ERR_FAIL_INDEX_V(p_z, blend_points_used, false);
@@ -168,15 +171,15 @@ bool AnimationNodeBlendSpace2D::has_triangle(int p_x, int p_y, int p_z) const {
break;
}
}
- if (all_equal)
+ if (all_equal) {
return true;
+ }
}
return false;
}
void AnimationNodeBlendSpace2D::add_triangle(int p_x, int p_y, int p_z, int p_at_index) {
-
ERR_FAIL_INDEX(p_x, blend_points_used);
ERR_FAIL_INDEX(p_y, blend_points_used);
ERR_FAIL_INDEX(p_z, blend_points_used);
@@ -208,14 +211,15 @@ void AnimationNodeBlendSpace2D::add_triangle(int p_x, int p_y, int p_z, int p_at
triangles.insert(p_at_index, t);
}
}
-int AnimationNodeBlendSpace2D::get_triangle_point(int p_triangle, int p_point) {
+int AnimationNodeBlendSpace2D::get_triangle_point(int p_triangle, int p_point) {
_update_triangles();
ERR_FAIL_INDEX_V(p_point, 3, -1);
ERR_FAIL_INDEX_V(p_triangle, triangles.size(), -1);
return triangles[p_triangle].points[p_point];
}
+
void AnimationNodeBlendSpace2D::remove_triangle(int p_triangle) {
ERR_FAIL_INDEX(p_triangle, triangles.size());
@@ -227,7 +231,6 @@ int AnimationNodeBlendSpace2D::get_triangle_count() const {
}
void AnimationNodeBlendSpace2D::set_min_space(const Vector2 &p_min) {
-
min_space = p_min;
if (min_space.x >= max_space.x) {
min_space.x = max_space.x - 1;
@@ -236,12 +239,12 @@ void AnimationNodeBlendSpace2D::set_min_space(const Vector2 &p_min) {
min_space.y = max_space.y - 1;
}
}
+
Vector2 AnimationNodeBlendSpace2D::get_min_space() const {
return min_space;
}
void AnimationNodeBlendSpace2D::set_max_space(const Vector2 &p_max) {
-
max_space = p_max;
if (max_space.x <= min_space.x) {
max_space.x = min_space.x + 1;
@@ -250,6 +253,7 @@ void AnimationNodeBlendSpace2D::set_max_space(const Vector2 &p_max) {
max_space.y = min_space.y + 1;
}
}
+
Vector2 AnimationNodeBlendSpace2D::get_max_space() const {
return max_space;
}
@@ -257,6 +261,7 @@ Vector2 AnimationNodeBlendSpace2D::get_max_space() const {
void AnimationNodeBlendSpace2D::set_snap(const Vector2 &p_snap) {
snap = p_snap;
}
+
Vector2 AnimationNodeBlendSpace2D::get_snap() const {
return snap;
}
@@ -264,6 +269,7 @@ Vector2 AnimationNodeBlendSpace2D::get_snap() const {
void AnimationNodeBlendSpace2D::set_x_label(const String &p_label) {
x_label = p_label;
}
+
String AnimationNodeBlendSpace2D::get_x_label() const {
return x_label;
}
@@ -271,6 +277,7 @@ String AnimationNodeBlendSpace2D::get_x_label() const {
void AnimationNodeBlendSpace2D::set_y_label(const String &p_label) {
y_label = p_label;
}
+
String AnimationNodeBlendSpace2D::get_y_label() const {
return y_label;
}
@@ -284,9 +291,9 @@ void AnimationNodeBlendSpace2D::_add_blend_point(int p_index, const Ref<Animatio
}
void AnimationNodeBlendSpace2D::_set_triangles(const Vector<int> &p_triangles) {
-
- if (auto_triangles)
+ if (auto_triangles) {
return;
+ }
ERR_FAIL_COND(p_triangles.size() % 3 != 0);
for (int i = 0; i < p_triangles.size(); i += 3) {
add_triangle(p_triangles[i + 0], p_triangles[i + 1], p_triangles[i + 2]);
@@ -294,10 +301,10 @@ void AnimationNodeBlendSpace2D::_set_triangles(const Vector<int> &p_triangles) {
}
Vector<int> AnimationNodeBlendSpace2D::_get_triangles() const {
-
Vector<int> t;
- if (auto_triangles && trianges_dirty)
+ if (auto_triangles && trianges_dirty) {
return t;
+ }
t.resize(triangles.size() * 3);
for (int i = 0; i < triangles.size(); i++) {
@@ -318,9 +325,9 @@ void AnimationNodeBlendSpace2D::_queue_auto_triangles() {
}
void AnimationNodeBlendSpace2D::_update_triangles() {
-
- if (!auto_triangles || !trianges_dirty)
+ if (!auto_triangles || !trianges_dirty) {
return;
+ }
trianges_dirty = false;
triangles.clear();
@@ -344,11 +351,11 @@ void AnimationNodeBlendSpace2D::_update_triangles() {
}
Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
-
_update_triangles();
- if (triangles.size() == 0)
+ if (triangles.size() == 0) {
return Vector2();
+ }
Vector2 best_point;
bool first = true;
@@ -359,8 +366,7 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
points[j] = get_blend_point_position(get_triangle_point(i, j));
}
- if (Geometry::is_point_in_triangle(p_point, points[0], points[1], points[2])) {
-
+ if (Geometry2D::is_point_in_triangle(p_point, points[0], points[1], points[2])) {
return p_point;
}
@@ -369,7 +375,7 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
points[j],
points[(j + 1) % 3]
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, s);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, s);
if (first || closest.distance_to(p_point) < best_point.distance_to(p_point)) {
best_point = closest;
first = false;
@@ -381,7 +387,6 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
}
void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vector2 *p_points, float *r_weights) {
-
if (p_pos.distance_squared_to(p_points[0]) < CMP_EPSILON2) {
r_weights[0] = 1;
r_weights[1] = 0;
@@ -427,7 +432,6 @@ void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vect
}
float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
-
_update_triangles();
Vector2 blend_pos = get_parameter(blend_position);
@@ -436,9 +440,9 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
float mind = 0; //time of min distance point
if (blend_mode == BLEND_MODE_INTERPOLATED) {
-
- if (triangles.size() == 0)
+ if (triangles.size() == 0) {
return 0;
+ }
Vector2 best_point;
bool first = true;
@@ -451,8 +455,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
points[j] = get_blend_point_position(get_triangle_point(i, j));
}
- if (Geometry::is_point_in_triangle(blend_pos, points[0], points[1], points[2])) {
-
+ if (Geometry2D::is_point_in_triangle(blend_pos, points[0], points[1], points[2])) {
blend_triangle = i;
_blend_triangle(blend_pos, points, blend_weights);
break;
@@ -463,7 +466,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
points[j],
points[(j + 1) % 3]
};
- Vector2 closest2 = Geometry::get_closest_point_to_segment_2d(blend_pos, s);
+ Vector2 closest2 = Geometry2D::get_closest_point_to_segment(blend_pos, s);
if (first || closest2.distance_to(blend_pos) < best_point.distance_to(blend_pos)) {
best_point = closest2;
blend_triangle = i;
@@ -494,7 +497,6 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
first = true;
for (int i = 0; i < blend_points_used; i++) {
-
bool found = false;
for (int j = 0; j < 3; j++) {
if (i == triangle_points[j]) {
@@ -515,22 +517,18 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
}
}
} else {
-
int new_closest = -1;
float new_closest_dist = 1e20;
for (int i = 0; i < blend_points_used; i++) {
-
float d = blend_points[i].position.distance_squared_to(blend_pos);
if (d < new_closest_dist) {
-
new_closest = i;
new_closest_dist = d;
}
}
if (new_closest != closest && new_closest != -1) {
-
float from = 0;
if (blend_mode == BLEND_MODE_DISCRETE_CARRY && closest != -1) {
//see how much animation remains
@@ -557,7 +555,6 @@ String AnimationNodeBlendSpace2D::get_caption() const {
}
void AnimationNodeBlendSpace2D::_validate_property(PropertyInfo &property) const {
-
if (auto_triangles && property.name == "triangles") {
property.usage = 0;
}
@@ -601,7 +598,6 @@ AnimationNodeBlendSpace2D::BlendMode AnimationNodeBlendSpace2D::get_blend_mode()
}
void AnimationNodeBlendSpace2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_blend_point", "node", "pos", "at_index"), &AnimationNodeBlendSpace2D::add_blend_point, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_blend_point_position", "point", "pos"), &AnimationNodeBlendSpace2D::set_blend_point_position);
ClassDB::bind_method(D_METHOD("get_blend_point_position", "point"), &AnimationNodeBlendSpace2D::get_blend_point_position);
@@ -666,7 +662,6 @@ void AnimationNodeBlendSpace2D::_bind_methods() {
}
AnimationNodeBlendSpace2D::AnimationNodeBlendSpace2D() {
-
for (int i = 0; i < MAX_BLEND_POINTS; i++) {
blend_points[i].name = itos(i);
}
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 570735ad87..56995c0c13 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -46,13 +46,12 @@ Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = nullpt
void AnimationNodeAnimation::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0));
}
-void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
+void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
if (property.name == "animation" && get_editable_animation_list) {
Vector<String> names = get_editable_animation_list();
String anims;
for (int i = 0; i < names.size(); i++) {
-
if (i > 0) {
anims += ",";
}
@@ -66,14 +65,12 @@ void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
}
float AnimationNodeAnimation::process(float p_time, bool p_seek) {
-
AnimationPlayer *ap = state->player;
ERR_FAIL_COND_V(!ap, 0);
float time = get_parameter(this->time);
if (!ap->has_animation(animation)) {
-
AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent);
if (tree) {
String name = tree->get_node_name(Ref<AnimationNodeAnimation>(this));
@@ -101,13 +98,11 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) {
float anim_size = anim->get_length();
if (anim->has_loop()) {
-
if (anim_size) {
time = Math::fposmod(time, anim_size);
}
} else if (time > anim_size) {
-
time = anim_size;
}
@@ -156,56 +151,50 @@ Variant AnimationNodeOneShot::get_parameter_default_value(const StringName &p_pa
}
void AnimationNodeOneShot::set_fadein_time(float p_time) {
-
fade_in = p_time;
}
void AnimationNodeOneShot::set_fadeout_time(float p_time) {
-
fade_out = p_time;
}
float AnimationNodeOneShot::get_fadein_time() const {
-
return fade_in;
}
-float AnimationNodeOneShot::get_fadeout_time() const {
+float AnimationNodeOneShot::get_fadeout_time() const {
return fade_out;
}
void AnimationNodeOneShot::set_autorestart(bool p_active) {
-
autorestart = p_active;
}
-void AnimationNodeOneShot::set_autorestart_delay(float p_time) {
+void AnimationNodeOneShot::set_autorestart_delay(float p_time) {
autorestart_delay = p_time;
}
-void AnimationNodeOneShot::set_autorestart_random_delay(float p_time) {
+void AnimationNodeOneShot::set_autorestart_random_delay(float p_time) {
autorestart_random_delay = p_time;
}
bool AnimationNodeOneShot::has_autorestart() const {
-
return autorestart;
}
-float AnimationNodeOneShot::get_autorestart_delay() const {
+float AnimationNodeOneShot::get_autorestart_delay() const {
return autorestart_delay;
}
-float AnimationNodeOneShot::get_autorestart_random_delay() const {
+float AnimationNodeOneShot::get_autorestart_random_delay() const {
return autorestart_random_delay;
}
void AnimationNodeOneShot::set_mix_mode(MixMode p_mix) {
-
mix = p_mix;
}
-AnimationNodeOneShot::MixMode AnimationNodeOneShot::get_mix_mode() const {
+AnimationNodeOneShot::MixMode AnimationNodeOneShot::get_mix_mode() const {
return mix;
}
@@ -218,7 +207,6 @@ bool AnimationNodeOneShot::has_filter() const {
}
float AnimationNodeOneShot::process(float p_time, bool p_seek) {
-
bool active = get_parameter(this->active);
bool prev_active = get_parameter(this->prev_active);
float time = get_parameter(this->time);
@@ -247,8 +235,9 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) {
bool os_seek = p_seek;
- if (p_seek)
+ if (p_seek) {
time = p_time;
+ }
bool do_start = !prev_active;
if (do_start) {
@@ -260,20 +249,21 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) {
float blend;
if (time < fade_in) {
-
- if (fade_in > 0)
+ if (fade_in > 0) {
blend = time / fade_in;
- else
+ } else {
blend = 0; //wtf
+ }
} else if (!do_start && remaining < fade_out) {
-
- if (fade_out)
+ if (fade_out) {
blend = (remaining / fade_out);
- else
+ } else {
blend = 1.0;
- } else
+ }
+ } else {
blend = 1.0;
+ }
float main_rem;
if (mix == MIX_MODE_ADD) {
@@ -306,18 +296,16 @@ float AnimationNodeOneShot::process(float p_time, bool p_seek) {
return MAX(main_rem, remaining);
}
-void AnimationNodeOneShot::set_use_sync(bool p_sync) {
+void AnimationNodeOneShot::set_use_sync(bool p_sync) {
sync = p_sync;
}
bool AnimationNodeOneShot::is_using_sync() const {
-
return sync;
}
void AnimationNodeOneShot::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_fadein_time", "time"), &AnimationNodeOneShot::set_fadein_time);
ClassDB::bind_method(D_METHOD("get_fadein_time"), &AnimationNodeOneShot::get_fadein_time);
@@ -356,7 +344,6 @@ void AnimationNodeOneShot::_bind_methods() {
}
AnimationNodeOneShot::AnimationNodeOneShot() {
-
add_input("in");
add_input("shot");
@@ -381,6 +368,7 @@ AnimationNodeOneShot::AnimationNodeOneShot() {
void AnimationNodeAdd2::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "0,1,0.01"));
}
+
Variant AnimationNodeAdd2::get_parameter_default_value(const StringName &p_parameter) const {
return 0;
}
@@ -388,23 +376,20 @@ Variant AnimationNodeAdd2::get_parameter_default_value(const StringName &p_param
String AnimationNodeAdd2::get_caption() const {
return "Add2";
}
-void AnimationNodeAdd2::set_use_sync(bool p_sync) {
+void AnimationNodeAdd2::set_use_sync(bool p_sync) {
sync = p_sync;
}
bool AnimationNodeAdd2::is_using_sync() const {
-
return sync;
}
bool AnimationNodeAdd2::has_filter() const {
-
return true;
}
float AnimationNodeAdd2::process(float p_time, bool p_seek) {
-
float amount = get_parameter(add_amount);
float rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);
@@ -413,7 +398,6 @@ float AnimationNodeAdd2::process(float p_time, bool p_seek) {
}
void AnimationNodeAdd2::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeAdd2::set_use_sync);
ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeAdd2::is_using_sync);
@@ -421,7 +405,6 @@ void AnimationNodeAdd2::_bind_methods() {
}
AnimationNodeAdd2::AnimationNodeAdd2() {
-
add_amount = "add_amount";
add_input("in");
add_input("add");
@@ -433,6 +416,7 @@ AnimationNodeAdd2::AnimationNodeAdd2() {
void AnimationNodeAdd3::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "-1,1,0.01"));
}
+
Variant AnimationNodeAdd3::get_parameter_default_value(const StringName &p_parameter) const {
return 0;
}
@@ -440,23 +424,20 @@ Variant AnimationNodeAdd3::get_parameter_default_value(const StringName &p_param
String AnimationNodeAdd3::get_caption() const {
return "Add3";
}
-void AnimationNodeAdd3::set_use_sync(bool p_sync) {
+void AnimationNodeAdd3::set_use_sync(bool p_sync) {
sync = p_sync;
}
bool AnimationNodeAdd3::is_using_sync() const {
-
return sync;
}
bool AnimationNodeAdd3::has_filter() const {
-
return true;
}
float AnimationNodeAdd3::process(float p_time, bool p_seek) {
-
float amount = get_parameter(add_amount);
blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_PASS, !sync);
float rem0 = blend_input(1, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
@@ -466,7 +447,6 @@ float AnimationNodeAdd3::process(float p_time, bool p_seek) {
}
void AnimationNodeAdd3::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeAdd3::set_use_sync);
ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeAdd3::is_using_sync);
@@ -474,18 +454,19 @@ void AnimationNodeAdd3::_bind_methods() {
}
AnimationNodeAdd3::AnimationNodeAdd3() {
-
add_amount = "add_amount";
add_input("-add");
add_input("in");
add_input("+add");
sync = false;
}
+
/////////////////////////////////////////////
void AnimationNodeBlend2::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "0,1,0.01"));
}
+
Variant AnimationNodeBlend2::get_parameter_default_value(const StringName &p_parameter) const {
return 0; //for blend amount
}
@@ -495,7 +476,6 @@ String AnimationNodeBlend2::get_caption() const {
}
float AnimationNodeBlend2::process(float p_time, bool p_seek) {
-
float amount = get_parameter(blend_amount);
float rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync);
@@ -505,26 +485,24 @@ float AnimationNodeBlend2::process(float p_time, bool p_seek) {
}
void AnimationNodeBlend2::set_use_sync(bool p_sync) {
-
sync = p_sync;
}
bool AnimationNodeBlend2::is_using_sync() const {
-
return sync;
}
bool AnimationNodeBlend2::has_filter() const {
-
return true;
}
-void AnimationNodeBlend2::_bind_methods() {
+void AnimationNodeBlend2::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeBlend2::set_use_sync);
ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeBlend2::is_using_sync);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");
}
+
AnimationNodeBlend2::AnimationNodeBlend2() {
blend_amount = "blend_amount";
add_input("in");
@@ -537,6 +515,7 @@ AnimationNodeBlend2::AnimationNodeBlend2() {
void AnimationNodeBlend3::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "-1,1,0.01"));
}
+
Variant AnimationNodeBlend3::get_parameter_default_value(const StringName &p_parameter) const {
return 0; //for blend amount
}
@@ -546,17 +525,14 @@ String AnimationNodeBlend3::get_caption() const {
}
void AnimationNodeBlend3::set_use_sync(bool p_sync) {
-
sync = p_sync;
}
bool AnimationNodeBlend3::is_using_sync() const {
-
return sync;
}
float AnimationNodeBlend3::process(float p_time, bool p_seek) {
-
float amount = get_parameter(blend_amount);
float rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync);
float rem1 = blend_input(1, p_time, p_seek, 1.0 - ABS(amount), FILTER_IGNORE, !sync);
@@ -566,12 +542,12 @@ float AnimationNodeBlend3::process(float p_time, bool p_seek) {
}
void AnimationNodeBlend3::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeBlend3::set_use_sync);
ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeBlend3::is_using_sync);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");
}
+
AnimationNodeBlend3::AnimationNodeBlend3() {
blend_amount = "blend_amount";
add_input("-blend");
@@ -585,6 +561,7 @@ AnimationNodeBlend3::AnimationNodeBlend3() {
void AnimationNodeTimeScale::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, scale, PROPERTY_HINT_RANGE, "0,32,0.01,or_greater"));
}
+
Variant AnimationNodeTimeScale::get_parameter_default_value(const StringName &p_parameter) const {
return 1.0; //initial timescale
}
@@ -594,7 +571,6 @@ String AnimationNodeTimeScale::get_caption() const {
}
float AnimationNodeTimeScale::process(float p_time, bool p_seek) {
-
float scale = get_parameter(this->scale);
if (p_seek) {
return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
@@ -605,6 +581,7 @@ float AnimationNodeTimeScale::process(float p_time, bool p_seek) {
void AnimationNodeTimeScale::_bind_methods() {
}
+
AnimationNodeTimeScale::AnimationNodeTimeScale() {
scale = "scale";
add_input("in");
@@ -615,6 +592,7 @@ AnimationNodeTimeScale::AnimationNodeTimeScale() {
void AnimationNodeTimeSeek::get_parameter_list(List<PropertyInfo> *r_list) const {
r_list->push_back(PropertyInfo(Variant::FLOAT, seek_pos, PROPERTY_HINT_RANGE, "-1,3600,0.01,or_greater"));
}
+
Variant AnimationNodeTimeSeek::get_parameter_default_value(const StringName &p_parameter) const {
return 1.0; //initial timescale
}
@@ -624,7 +602,6 @@ String AnimationNodeTimeSeek::get_caption() const {
}
float AnimationNodeTimeSeek::process(float p_time, bool p_seek) {
-
float seek_pos = get_parameter(this->seek_pos);
if (p_seek) {
return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
@@ -649,7 +626,6 @@ AnimationNodeTimeSeek::AnimationNodeTimeSeek() {
/////////////////////////////////////////////////
void AnimationNodeTransition::get_parameter_list(List<PropertyInfo> *r_list) const {
-
String anims;
for (int i = 0; i < enabled_inputs; i++) {
if (i > 0) {
@@ -664,6 +640,7 @@ void AnimationNodeTransition::get_parameter_list(List<PropertyInfo> *r_list) con
r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0));
r_list->push_back(PropertyInfo(Variant::FLOAT, prev_xfading, PROPERTY_HINT_NONE, "", 0));
}
+
Variant AnimationNodeTransition::get_parameter_default_value(const StringName &p_parameter) const {
if (p_parameter == time || p_parameter == prev_xfading) {
return 0.0;
@@ -728,7 +705,6 @@ float AnimationNodeTransition::get_cross_fade_time() const {
}
float AnimationNodeTransition::process(float p_time, bool p_seek) {
-
int current = get_parameter(this->current);
int prev = get_parameter(this->prev);
int prev_current = get_parameter(this->prev_current);
@@ -758,13 +734,13 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) {
rem = blend_input(current, p_time, p_seek, 1.0, FILTER_IGNORE, false);
- if (p_seek)
+ if (p_seek) {
time = p_time;
- else
+ } else {
time += p_time;
+ }
if (inputs[current].auto_advance && rem <= xfade) {
-
set_parameter(this->current, (current + 1) % enabled_inputs);
}
@@ -776,7 +752,6 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) {
rem = blend_input(current, 0, true, 1.0 - blend, FILTER_IGNORE, false);
} else {
-
rem = blend_input(current, p_time, p_seek, 1.0 - blend, FILTER_IGNORE, false);
}
@@ -800,7 +775,6 @@ float AnimationNodeTransition::process(float p_time, bool p_seek) {
}
void AnimationNodeTransition::_validate_property(PropertyInfo &property) const {
-
if (property.name.begins_with("input_")) {
String n = property.name.get_slicec('/', 0).get_slicec('_', 1);
if (n != "count") {
@@ -815,7 +789,6 @@ void AnimationNodeTransition::_validate_property(PropertyInfo &property) const {
}
void AnimationNodeTransition::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_enabled_inputs", "amount"), &AnimationNodeTransition::set_enabled_inputs);
ClassDB::bind_method(D_METHOD("get_enabled_inputs"), &AnimationNodeTransition::get_enabled_inputs);
@@ -838,7 +811,6 @@ void AnimationNodeTransition::_bind_methods() {
}
AnimationNodeTransition::AnimationNodeTransition() {
-
prev_xfading = "prev_xfading";
prev = "prev";
time = "time";
@@ -869,7 +841,6 @@ AnimationNodeOutput::AnimationNodeOutput() {
///////////////////////////////////////////////////////
void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position) {
-
ERR_FAIL_COND(nodes.has(p_name));
ERR_FAIL_COND(p_node.is_null());
ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output);
@@ -889,7 +860,6 @@ void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNod
}
Ref<AnimationNode> AnimationNodeBlendTree::get_node(const StringName &p_name) const {
-
ERR_FAIL_COND_V(!nodes.has(p_name), Ref<AnimationNode>());
return nodes[p_name].node;
@@ -935,13 +905,13 @@ void AnimationNodeBlendTree::get_child_nodes(List<ChildNode> *r_child_nodes) {
bool AnimationNodeBlendTree::has_node(const StringName &p_name) const {
return nodes.has(p_name);
}
-Vector<StringName> AnimationNodeBlendTree::get_node_connection_array(const StringName &p_name) const {
+Vector<StringName> AnimationNodeBlendTree::get_node_connection_array(const StringName &p_name) const {
ERR_FAIL_COND_V(!nodes.has(p_name), Vector<StringName>());
return nodes[p_name].connections;
}
-void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
+void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
ERR_FAIL_COND(!nodes.has(p_name));
ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output); //can't delete output
@@ -967,7 +937,6 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
}
void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringName &p_new_name) {
-
ERR_FAIL_COND(!nodes.has(p_name));
ERR_FAIL_COND(nodes.has(p_new_name));
ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output);
@@ -980,7 +949,6 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN
//rename connections
for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
-
for (int i = 0; i < E->get().connections.size(); i++) {
if (E->get().connections[i] == p_name) {
E->get().connections.write[i] = p_new_name;
@@ -994,7 +962,6 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN
}
void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) {
-
ERR_FAIL_COND(!nodes.has(p_output_node));
ERR_FAIL_COND(!nodes.has(p_input_node));
ERR_FAIL_COND(p_output_node == SceneStringNames::get_singleton()->output);
@@ -1016,7 +983,6 @@ void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_
}
void AnimationNodeBlendTree::disconnect_node(const StringName &p_node, int p_input_index) {
-
ERR_FAIL_COND(!nodes.has(p_node));
Ref<AnimationNode> input = nodes[p_node].node;
@@ -1026,7 +992,6 @@ void AnimationNodeBlendTree::disconnect_node(const StringName &p_node, int p_inp
}
AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) const {
-
if (!nodes.has(p_output_node) || p_output_node == SceneStringNames::get_singleton()->output) {
return CONNECTION_ERROR_NO_OUTPUT;
}
@@ -1061,7 +1026,6 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node
}
void AnimationNodeBlendTree::get_node_connections(List<NodeConnection> *r_connections) const {
-
for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
for (int i = 0; i < E->get().connections.size(); i++) {
StringName output = E->get().connections[i];
@@ -1081,25 +1045,21 @@ String AnimationNodeBlendTree::get_caption() const {
}
float AnimationNodeBlendTree::process(float p_time, bool p_seek) {
-
Ref<AnimationNodeOutput> output = nodes[SceneStringNames::get_singleton()->output].node;
return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, 1.0);
}
void AnimationNodeBlendTree::get_node_list(List<StringName> *r_list) {
-
for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
r_list->push_back(E->key());
}
}
void AnimationNodeBlendTree::set_graph_offset(const Vector2 &p_graph_offset) {
-
graph_offset = p_graph_offset;
}
Vector2 AnimationNodeBlendTree::get_graph_offset() const {
-
return graph_offset;
}
@@ -1108,10 +1068,8 @@ Ref<AnimationNode> AnimationNodeBlendTree::get_child_by_name(const StringName &p
}
bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name.begins_with("nodes/")) {
-
String node_name = name.get_slicec('/', 1);
String what = name.get_slicec('/', 2);
@@ -1124,14 +1082,12 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val
}
if (what == "position") {
-
if (nodes.has(node_name)) {
nodes[node_name].position = p_value;
}
return true;
}
} else if (name == "node_connections") {
-
Array conns = p_value;
ERR_FAIL_COND_V(conns.size() % 3 != 0, false);
@@ -1145,7 +1101,6 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val
}
bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name.begins_with("nodes/")) {
String node_name = name.get_slicec('/', 1);
@@ -1159,7 +1114,6 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons
}
if (what == "position") {
-
if (nodes.has(node_name)) {
r_ret = nodes[node_name].position;
return true;
@@ -1185,8 +1139,8 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons
return false;
}
-void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) const {
+void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
names.push_back(E->key());
@@ -1209,13 +1163,11 @@ void AnimationNodeBlendTree::_tree_changed() {
}
void AnimationNodeBlendTree::_node_changed(const StringName &p_node) {
-
ERR_FAIL_COND(!nodes.has(p_node));
nodes[p_node].connections.resize(nodes[p_node].node->get_input_count());
}
void AnimationNodeBlendTree::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeBlendTree::add_node, DEFVAL(Vector2()));
ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeBlendTree::get_node);
ClassDB::bind_method(D_METHOD("remove_node", "name"), &AnimationNodeBlendTree::remove_node);
@@ -1241,7 +1193,6 @@ void AnimationNodeBlendTree::_bind_methods() {
}
AnimationNodeBlendTree::AnimationNodeBlendTree() {
-
Ref<AnimationNodeOutput> output;
output.instance();
Node n;
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 7ebe3f5444..5c722d00f9 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -34,7 +34,6 @@
#include "scene/animation/animation_tree.h"
class AnimationNodeAnimation : public AnimationRootNode {
-
GDCLASS(AnimationNodeAnimation, AnimationRootNode);
StringName animation;
@@ -268,7 +267,6 @@ class AnimationNodeTransition : public AnimationNode {
MAX_INPUTS = 32
};
struct InputData {
-
String name;
bool auto_advance;
InputData() { auto_advance = false; }
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index ab8be47b4d..abb2cf1b65 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -31,7 +31,6 @@
#include "animation_cache.h"
void AnimationCache::_node_exit_tree(Node *p_node) {
-
//it is one shot, so it disconnects upon arrival
ERR_FAIL_COND(!connected_nodes.has(p_node));
@@ -39,23 +38,20 @@ void AnimationCache::_node_exit_tree(Node *p_node) {
connected_nodes.erase(p_node);
for (int i = 0; i < path_cache.size(); i++) {
-
- if (path_cache[i].node != p_node)
+ if (path_cache[i].node != p_node) {
continue;
+ }
path_cache.write[i].valid = false; //invalidate path cache
}
}
void AnimationCache::_animation_changed() {
-
_clear_cache();
}
void AnimationCache::_clear_cache() {
-
while (connected_nodes.size()) {
-
connected_nodes.front()->get()->disconnect("tree_exiting", callable_mp(this, &AnimationCache::_node_exit_tree));
connected_nodes.erase(connected_nodes.front());
}
@@ -65,7 +61,6 @@ void AnimationCache::_clear_cache() {
}
void AnimationCache::_update_cache() {
-
cache_valid = false;
ERR_FAIL_COND(!root);
@@ -73,12 +68,10 @@ void AnimationCache::_update_cache() {
ERR_FAIL_COND(animation.is_null());
for (int i = 0; i < animation->get_track_count(); i++) {
-
NodePath np = animation->track_get_path(i);
Node *node = root->get_node(np);
if (!node) {
-
path_cache.push_back(Path());
ERR_CONTINUE_MSG(!node, "Invalid track path in animation '" + np + "'.");
}
@@ -88,7 +81,6 @@ void AnimationCache::_update_cache() {
Ref<Resource> res;
if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) {
-
if (np.get_subname_count() > 1) {
path_cache.push_back(Path());
ERR_CONTINUE_MSG(animation->track_get_type(i) == Animation::TYPE_TRANSFORM, "Transform tracks can't have a subpath '" + np + "'.");
@@ -97,7 +89,6 @@ void AnimationCache::_update_cache() {
Node3D *sp = Object::cast_to<Node3D>(node);
if (!sp) {
-
path_cache.push_back(Path());
ERR_CONTINUE_MSG(!sp, "Transform track not of type Node3D '" + np + "'.");
}
@@ -108,7 +99,6 @@ void AnimationCache::_update_cache() {
Skeleton3D *sk = Object::cast_to<Skeleton3D>(node);
if (!sk) {
-
path_cache.push_back(Path());
ERR_CONTINUE_MSG(!sk, "Property defined in Transform track, but not a Skeleton! '" + np + "'.");
}
@@ -127,7 +117,6 @@ void AnimationCache::_update_cache() {
} else {
if (np.get_subname_count() > 0) {
-
RES res2;
Vector<StringName> leftover_subpath;
@@ -144,7 +133,6 @@ void AnimationCache::_update_cache() {
path.subpath = leftover_subpath;
} else {
-
path.node = node;
path.object = node;
path.subpath = np.get_subnames();
@@ -152,15 +140,12 @@ void AnimationCache::_update_cache() {
}
if (animation->track_get_type(i) == Animation::TYPE_VALUE) {
-
if (np.get_subname_count() == 0) {
-
path_cache.push_back(Path());
ERR_CONTINUE_MSG(np.get_subname_count() == 0, "Value Track lacks property: " + np + ".");
}
} else if (animation->track_get_type(i) == Animation::TYPE_METHOD) {
-
if (path.subpath.size() != 0) { // Trying to call a method of a non-resource
path_cache.push_back(Path());
@@ -183,15 +168,16 @@ void AnimationCache::_update_cache() {
}
void AnimationCache::set_track_transform(int p_idx, const Transform &p_transform) {
-
- if (cache_dirty)
+ if (cache_dirty) {
_update_cache();
+ }
ERR_FAIL_COND(!cache_valid);
ERR_FAIL_INDEX(p_idx, path_cache.size());
Path &p = path_cache.write[p_idx];
- if (!p.valid)
+ if (!p.valid) {
return;
+ }
ERR_FAIL_COND(!p.node);
ERR_FAIL_COND(!p.spatial);
@@ -204,49 +190,48 @@ void AnimationCache::set_track_transform(int p_idx, const Transform &p_transform
}
void AnimationCache::set_track_value(int p_idx, const Variant &p_value) {
-
- if (cache_dirty)
+ if (cache_dirty) {
_update_cache();
+ }
ERR_FAIL_COND(!cache_valid);
ERR_FAIL_INDEX(p_idx, path_cache.size());
Path &p = path_cache.write[p_idx];
- if (!p.valid)
+ if (!p.valid) {
return;
+ }
ERR_FAIL_COND(!p.object);
p.object->set_indexed(p.subpath, p_value);
}
void AnimationCache::call_track(int p_idx, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
- if (cache_dirty)
+ if (cache_dirty) {
_update_cache();
+ }
ERR_FAIL_COND(!cache_valid);
ERR_FAIL_INDEX(p_idx, path_cache.size());
Path &p = path_cache.write[p_idx];
- if (!p.valid)
+ if (!p.valid) {
return;
+ }
ERR_FAIL_COND(!p.object);
p.object->call(p_method, p_args, p_argcount, r_error);
}
void AnimationCache::set_all(float p_time, float p_delta) {
-
- if (cache_dirty)
+ if (cache_dirty) {
_update_cache();
+ }
ERR_FAIL_COND(!cache_valid);
int tc = animation->get_track_count();
for (int i = 0; i < tc; i++) {
-
switch (animation->track_get_type(i)) {
-
case Animation::TYPE_TRANSFORM: {
-
Vector3 loc, scale;
Quat rot;
animation->transform_track_interpolate(i, p_time, &loc, &rot, &scale);
@@ -257,17 +242,14 @@ void AnimationCache::set_all(float p_time, float p_delta) {
} break;
case Animation::TYPE_VALUE: {
-
if (animation->value_track_get_update_mode(i) == Animation::UPDATE_CONTINUOUS || (animation->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE && p_delta == 0)) {
Variant v = animation->value_track_interpolate(i, p_time);
set_track_value(i, v);
} else {
-
List<int> indices;
animation->value_track_get_key_indices(i, p_time, p_delta, &indices);
for (List<int>::Element *E = indices.front(); E; E = E->next()) {
-
Variant v = animation->track_get_key_value(i, E->get());
set_track_value(i, v);
}
@@ -275,25 +257,20 @@ void AnimationCache::set_all(float p_time, float p_delta) {
} break;
case Animation::TYPE_METHOD: {
-
List<int> indices;
animation->method_track_get_key_indices(i, p_time, p_delta, &indices);
for (List<int>::Element *E = indices.front(); E; E = E->next()) {
-
Vector<Variant> args = animation->method_track_get_params(i, E->get());
StringName name = animation->method_track_get_name(i, E->get());
Callable::CallError err;
if (!args.size()) {
-
call_track(i, name, nullptr, 0, err);
} else {
-
Vector<const Variant *> argptrs;
argptrs.resize(args.size());
for (int j = 0; j < args.size(); j++) {
-
argptrs.write[j] = &args.write[j];
}
@@ -309,29 +286,28 @@ void AnimationCache::set_all(float p_time, float p_delta) {
}
void AnimationCache::set_animation(const Ref<Animation> &p_animation) {
-
_clear_cache();
- if (animation.is_valid())
+ if (animation.is_valid()) {
animation->disconnect("changed", callable_mp(this, &AnimationCache::_animation_changed));
+ }
animation = p_animation;
- if (animation.is_valid())
+ if (animation.is_valid()) {
animation->connect("changed", callable_mp(this, &AnimationCache::_animation_changed));
+ }
}
void AnimationCache::_bind_methods() {
}
void AnimationCache::set_root(Node *p_root) {
-
_clear_cache();
root = p_root;
}
AnimationCache::AnimationCache() {
-
root = nullptr;
cache_dirty = true;
cache_valid = false;
diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h
index 23312ca7ec..feff1d364a 100644
--- a/scene/animation/animation_cache.h
+++ b/scene/animation/animation_cache.h
@@ -35,11 +35,9 @@
#include "scene/resources/animation.h"
class AnimationCache : public Object {
-
GDCLASS(AnimationCache, Object);
struct Path {
-
RES resource;
Object *object;
Skeleton3D *skeleton; // haxor
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index 9f5e06c43d..17ce05f130 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -33,12 +33,10 @@
/////////////////////////////////////////////////
void AnimationNodeStateMachineTransition::set_switch_mode(SwitchMode p_mode) {
-
switch_mode = p_mode;
}
AnimationNodeStateMachineTransition::SwitchMode AnimationNodeStateMachineTransition::get_switch_mode() const {
-
return switch_mode;
}
@@ -71,7 +69,6 @@ StringName AnimationNodeStateMachineTransition::get_advance_condition_name() con
}
void AnimationNodeStateMachineTransition::set_xfade_time(float p_xfade) {
-
ERR_FAIL_COND(p_xfade < 0);
xfade = p_xfade;
emit_changed();
@@ -133,7 +130,6 @@ void AnimationNodeStateMachineTransition::_bind_methods() {
}
AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() {
-
switch_mode = SWITCH_MODE_IMMEDIATE;
auto_advance = false;
xfade = 0;
@@ -144,7 +140,6 @@ AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() {
////////////////////////////////////////////////////////
void AnimationNodeStateMachinePlayback::travel(const StringName &p_state) {
-
start_request_travel = true;
start_request = p_state;
stop_request = false;
@@ -155,39 +150,45 @@ void AnimationNodeStateMachinePlayback::start(const StringName &p_state) {
start_request = p_state;
stop_request = false;
}
-void AnimationNodeStateMachinePlayback::stop() {
+void AnimationNodeStateMachinePlayback::stop() {
stop_request = true;
}
+
bool AnimationNodeStateMachinePlayback::is_playing() const {
return playing;
}
+
StringName AnimationNodeStateMachinePlayback::get_current_node() const {
return current;
}
+
StringName AnimationNodeStateMachinePlayback::get_blend_from_node() const {
return fading_from;
}
+
Vector<StringName> AnimationNodeStateMachinePlayback::get_travel_path() const {
return path;
}
+
float AnimationNodeStateMachinePlayback::get_current_play_pos() const {
return pos_current;
}
+
float AnimationNodeStateMachinePlayback::get_current_length() const {
return len_current;
}
bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel) {
-
ERR_FAIL_COND_V(!playing, false);
ERR_FAIL_COND_V(!p_state_machine->states.has(p_travel), false);
ERR_FAIL_COND_V(!p_state_machine->states.has(current), false);
path.clear(); //a new one will be needed
- if (current == p_travel)
+ if (current == p_travel) {
return true; //nothing to do
+ }
loops_current = 0; // reset loops, so fade does not happen immediately
@@ -219,7 +220,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
//begin astar
bool found_route = false;
while (!found_route) {
-
if (open_list.size() == 0) {
return false; //no path found
}
@@ -229,7 +229,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
float least_cost = 1e20;
for (List<int>::Element *E = open_list.front(); E; E = E->next()) {
-
float cost = cost_map[p_state_machine->transitions[E->get()].to].distance;
cost += p_state_machine->states[p_state_machine->transitions[E->get()].to].position.distance_to(target_pos);
@@ -293,7 +292,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
}
float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek) {
-
//if not playing and it can restart, then restart
if (!playing && start_request == StringName()) {
if (!stop_request && p_state_machine->start_node) {
@@ -347,7 +345,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
bool do_start = (p_seek && p_time == 0) || play_start || current == StringName();
if (do_start) {
-
if (p_state_machine->start_node != StringName() && p_seek && p_time == 0) {
current = p_state_machine->start_node;
}
@@ -365,7 +362,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
float fade_blend = 1.0;
if (fading_from != StringName()) {
-
if (!p_state_machine->states.has(fading_from)) {
fading_from = StringName();
} else {
@@ -382,7 +378,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false);
if (fading_from != StringName()) {
-
p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false);
}
@@ -407,7 +402,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
AnimationNodeStateMachineTransition::SwitchMode switch_mode = AnimationNodeStateMachineTransition::SWITCH_MODE_IMMEDIATE;
if (path.size()) {
-
for (int i = 0; i < p_state_machine->transitions.size(); i++) {
if (p_state_machine->transitions[i].from == current && p_state_machine->transitions[i].to == path[0]) {
next_xfade = p_state_machine->transitions[i].transition->get_xfade_time();
@@ -419,7 +413,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
float priority_best = 1e20;
int auto_advance_to = -1;
for (int i = 0; i < p_state_machine->transitions.size(); i++) {
-
bool auto_advance = false;
if (p_state_machine->transitions[i].transition->has_auto_advance()) {
auto_advance = true;
@@ -430,7 +423,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
}
if (p_state_machine->transitions[i].from == current && auto_advance) {
-
if (p_state_machine->transitions[i].transition->get_priority() <= priority_best) {
priority_best = p_state_machine->transitions[i].transition->get_priority();
auto_advance_to = i;
@@ -447,7 +439,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
//if next, see when to transition
if (next != StringName()) {
-
bool goto_next = false;
if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_AT_END) {
@@ -492,7 +483,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
//compute time left for transitions by using the end node
if (p_state_machine->end_node != StringName() && p_state_machine->end_node != current) {
-
rem = p_state_machine->blend_node(p_state_machine->end_node, p_state_machine->states[p_state_machine->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false);
}
@@ -500,7 +490,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
}
void AnimationNodeStateMachinePlayback::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("travel", "to_node"), &AnimationNodeStateMachinePlayback::travel);
ClassDB::bind_method(D_METHOD("start", "node"), &AnimationNodeStateMachinePlayback::start);
ClassDB::bind_method(D_METHOD("stop"), &AnimationNodeStateMachinePlayback::stop);
@@ -542,7 +531,6 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c
}
Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName &p_parameter) const {
-
if (p_parameter == playback) {
Ref<AnimationNodeStateMachinePlayback> p;
p.instance();
@@ -553,7 +541,6 @@ Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName
}
void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position) {
-
ERR_FAIL_COND(states.has(p_name));
ERR_FAIL_COND(p_node.is_null());
ERR_FAIL_COND(String(p_name).find("/") != -1);
@@ -571,7 +558,6 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation
}
void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<AnimationNode> p_node) {
-
ERR_FAIL_COND(states.has(p_name) == false);
ERR_FAIL_COND(p_node.is_null());
ERR_FAIL_COND(String(p_name).find("/") != -1);
@@ -592,7 +578,6 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima
}
Ref<AnimationNode> AnimationNodeStateMachine::get_node(const StringName &p_name) const {
-
ERR_FAIL_COND_V(!states.has(p_name), Ref<AnimationNode>());
return states[p_name].node;
@@ -628,8 +613,8 @@ void AnimationNodeStateMachine::get_child_nodes(List<ChildNode> *r_child_nodes)
bool AnimationNodeStateMachine::has_node(const StringName &p_name) const {
return states.has(p_name);
}
-void AnimationNodeStateMachine::remove_node(const StringName &p_name) {
+void AnimationNodeStateMachine::remove_node(const StringName &p_name) {
ERR_FAIL_COND(!states.has(p_name));
{
@@ -668,7 +653,6 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) {
}
void AnimationNodeStateMachine::rename_node(const StringName &p_name, const StringName &p_new_name) {
-
ERR_FAIL_COND(!states.has(p_name));
ERR_FAIL_COND(states.has(p_new_name));
@@ -702,7 +686,6 @@ void AnimationNodeStateMachine::rename_node(const StringName &p_name, const Stri
}
void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const {
-
List<StringName> nodes;
for (Map<StringName, State>::Element *E = states.front(); E; E = E->next()) {
nodes.push_back(E->key());
@@ -715,25 +698,24 @@ void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const {
}
bool AnimationNodeStateMachine::has_transition(const StringName &p_from, const StringName &p_to) const {
-
for (int i = 0; i < transitions.size(); i++) {
- if (transitions[i].from == p_from && transitions[i].to == p_to)
+ if (transitions[i].from == p_from && transitions[i].to == p_to) {
return true;
+ }
}
return false;
}
int AnimationNodeStateMachine::find_transition(const StringName &p_from, const StringName &p_to) const {
-
for (int i = 0; i < transitions.size(); i++) {
- if (transitions[i].from == p_from && transitions[i].to == p_to)
+ if (transitions[i].from == p_from && transitions[i].to == p_to) {
return i;
+ }
}
return -1;
}
void AnimationNodeStateMachine::add_transition(const StringName &p_from, const StringName &p_to, const Ref<AnimationNodeStateMachineTransition> &p_transition) {
-
ERR_FAIL_COND(p_from == p_to);
ERR_FAIL_COND(!states.has(p_from));
ERR_FAIL_COND(!states.has(p_to));
@@ -757,23 +739,22 @@ Ref<AnimationNodeStateMachineTransition> AnimationNodeStateMachine::get_transiti
ERR_FAIL_INDEX_V(p_transition, transitions.size(), Ref<AnimationNodeStateMachineTransition>());
return transitions[p_transition].transition;
}
-StringName AnimationNodeStateMachine::get_transition_from(int p_transition) const {
+StringName AnimationNodeStateMachine::get_transition_from(int p_transition) const {
ERR_FAIL_INDEX_V(p_transition, transitions.size(), StringName());
return transitions[p_transition].from;
}
-StringName AnimationNodeStateMachine::get_transition_to(int p_transition) const {
+StringName AnimationNodeStateMachine::get_transition_to(int p_transition) const {
ERR_FAIL_INDEX_V(p_transition, transitions.size(), StringName());
return transitions[p_transition].to;
}
int AnimationNodeStateMachine::get_transition_count() const {
-
return transitions.size();
}
-void AnimationNodeStateMachine::remove_transition(const StringName &p_from, const StringName &p_to) {
+void AnimationNodeStateMachine::remove_transition(const StringName &p_from, const StringName &p_to) {
for (int i = 0; i < transitions.size(); i++) {
if (transitions[i].from == p_from && transitions[i].to == p_to) {
transitions.write[i].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed));
@@ -788,7 +769,6 @@ void AnimationNodeStateMachine::remove_transition(const StringName &p_from, cons
}
void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) {
-
ERR_FAIL_INDEX(p_transition, transitions.size());
transitions.write[p_transition].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed));
transitions.remove(p_transition);
@@ -798,24 +778,20 @@ void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) {
}
void AnimationNodeStateMachine::set_start_node(const StringName &p_node) {
-
ERR_FAIL_COND(p_node != StringName() && !states.has(p_node));
start_node = p_node;
}
String AnimationNodeStateMachine::get_start_node() const {
-
return start_node;
}
void AnimationNodeStateMachine::set_end_node(const StringName &p_node) {
-
ERR_FAIL_COND(p_node != StringName() && !states.has(p_node));
end_node = p_node;
}
String AnimationNodeStateMachine::get_end_node() const {
-
return end_node;
}
@@ -828,7 +804,6 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const {
}
float AnimationNodeStateMachine::process(float p_time, bool p_seek) {
-
Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback);
ERR_FAIL_COND_V(playback.is_null(), 0.0);
@@ -847,7 +822,6 @@ Ref<AnimationNode> AnimationNodeStateMachine::get_child_by_name(const StringName
}
bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name.begins_with("states/")) {
String node_name = name.get_slicec('/', 1);
@@ -862,14 +836,12 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_
}
if (what == "position") {
-
if (states.has(node_name)) {
states[node_name].position = p_value;
}
return true;
}
} else if (name == "transitions") {
-
Array trans = p_value;
ERR_FAIL_COND_V(trans.size() % 3 != 0, false);
@@ -892,7 +864,6 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_
}
bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name.begins_with("states/")) {
String node_name = name.get_slicec('/', 1);
@@ -906,7 +877,6 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c
}
if (what == "position") {
-
if (states.has(node_name)) {
r_ret = states[node_name].position;
return true;
@@ -937,8 +907,8 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c
return false;
}
-void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) const {
+void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
for (Map<StringName, State>::Element *E = states.front(); E; E = E->next()) {
names.push_back(E->key());
@@ -963,7 +933,6 @@ void AnimationNodeStateMachine::set_node_position(const StringName &p_name, cons
}
Vector2 AnimationNodeStateMachine::get_node_position(const StringName &p_name) const {
-
ERR_FAIL_COND_V(!states.has(p_name), Vector2());
return states[p_name].position;
}
@@ -973,7 +942,6 @@ void AnimationNodeStateMachine::_tree_changed() {
}
void AnimationNodeStateMachine::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeStateMachine::add_node, DEFVAL(Vector2()));
ClassDB::bind_method(D_METHOD("replace_node", "name", "node"), &AnimationNodeStateMachine::replace_node);
ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeStateMachine::get_node);
@@ -1005,6 +973,5 @@ void AnimationNodeStateMachine::_bind_methods() {
}
AnimationNodeStateMachine::AnimationNodeStateMachine() {
-
playback = "playback";
}
diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h
index 27a4451f08..72fa6f77d0 100644
--- a/scene/animation/animation_node_state_machine.h
+++ b/scene/animation/animation_node_state_machine.h
@@ -134,7 +134,6 @@ public:
};
class AnimationNodeStateMachine : public AnimationRootNode {
-
GDCLASS(AnimationNodeStateMachine, AnimationRootNode);
private:
@@ -148,7 +147,6 @@ private:
Map<StringName, State> states;
struct Transition {
-
StringName from;
StringName to;
Ref<AnimationNodeStateMachineTransition> transition;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 7bac09f839..319d0171b3 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -40,7 +40,6 @@
#include "scene/2d/skeleton_2d.h"
void AnimatedValuesBackup::update_skeletons() {
-
for (int i = 0; i < entries.size(); i++) {
if (entries[i].bone_idx != -1) {
// 3D bone
@@ -57,7 +56,6 @@ void AnimatedValuesBackup::update_skeletons() {
#endif
bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name.begins_with("playback/play")) { // bw compatibility
@@ -65,23 +63,19 @@ bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) {
set_current_animation(p_value);
} else if (name.begins_with("anims/")) {
-
String which = name.get_slicec('/', 1);
add_animation(which, p_value);
} else if (name.begins_with("next/")) {
-
String which = name.get_slicec('/', 1);
animation_set_next(which, p_value);
} else if (p_name == SceneStringNames::get_singleton()->blend_times) {
-
Array array = p_value;
int len = array.size();
ERR_FAIL_COND_V(len % 3, false);
for (int i = 0; i < len / 3; i++) {
-
StringName from = array[i * 3 + 0];
StringName to = array[i * 3 + 1];
float time = array[i * 3 + 2];
@@ -89,14 +83,14 @@ bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) {
set_blend_time(from, to, time);
}
- } else
+ } else {
return false;
+ }
return true;
}
bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name == "playback/play") { // bw compatibility
@@ -104,41 +98,36 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_current_animation();
} else if (name.begins_with("anims/")) {
-
String which = name.get_slicec('/', 1);
r_ret = get_animation(which);
} else if (name.begins_with("next/")) {
-
String which = name.get_slicec('/', 1);
r_ret = animation_get_next(which);
} else if (name == "blend_times") {
-
Vector<BlendKey> keys;
for (Map<BlendKey, float>::Element *E = blend_times.front(); E; E = E->next()) {
-
keys.ordered_insert(E->key());
}
Array array;
for (int i = 0; i < keys.size(); i++) {
-
array.push_back(keys[i].from);
array.push_back(keys[i].to);
array.push_back(blend_times[keys[i]]);
}
r_ret = array;
- } else
+ } else {
return false;
+ }
return true;
}
void AnimationPlayer::_validate_property(PropertyInfo &property) const {
-
if (property.name == "current_animation") {
List<String> names;
@@ -149,9 +138,9 @@ void AnimationPlayer::_validate_property(PropertyInfo &property) const {
names.push_front("[stop]");
String hint;
for (List<String>::Element *E = names.front(); E; E = E->next()) {
-
- if (E != names.front())
+ if (E != names.front()) {
hint += ",";
+ }
hint += E->get();
}
@@ -160,14 +149,13 @@ void AnimationPlayer::_validate_property(PropertyInfo &property) const {
}
void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const {
-
List<PropertyInfo> anim_names;
for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
-
anim_names.push_back(PropertyInfo(Variant::OBJECT, "anims/" + String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE));
- if (E->get().next != StringName())
+ if (E->get().next != StringName()) {
anim_names.push_back(PropertyInfo(Variant::STRING, "next/" + String(E->key()), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
+ }
}
anim_names.sort();
@@ -180,16 +168,12 @@ void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const {
}
void AnimationPlayer::advance(float p_time) {
-
_animation_process(p_time);
}
void AnimationPlayer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
if (!processing) {
//make sure that a previous process state was not saved
//only process if "processing" is set
@@ -200,39 +184,40 @@ void AnimationPlayer::_notification(int p_what) {
clear_caches();
} break;
case NOTIFICATION_READY: {
-
if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
play(autoplay);
_animation_process(0);
}
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
- if (animation_process_mode == ANIMATION_PROCESS_PHYSICS)
+ if (animation_process_mode == ANIMATION_PROCESS_PHYSICS) {
break;
+ }
- if (processing)
+ if (processing) {
_animation_process(get_process_delta_time());
+ }
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
-
- if (animation_process_mode == ANIMATION_PROCESS_IDLE)
+ if (animation_process_mode == ANIMATION_PROCESS_IDLE) {
break;
+ }
- if (processing)
+ if (processing) {
_animation_process(get_physics_process_delta_time());
+ }
} break;
case NOTIFICATION_EXIT_TREE: {
-
clear_caches();
} break;
}
}
void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
-
// Already cached?
- if (p_anim->node_cache.size() == p_anim->animation->get_track_count())
+ if (p_anim->node_cache.size() == p_anim->animation->get_track_count()) {
return;
+ }
Node *parent = get_node(root);
@@ -243,7 +228,6 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
p_anim->node_cache.resize(a->get_track_count());
for (int i = 0; i < a->get_track_count(); i++) {
-
p_anim->node_cache.write[i] = nullptr;
RES resource;
Vector<StringName> leftover_path;
@@ -253,26 +237,26 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
int bone_idx = -1;
if (a->track_get_path(i).get_subname_count() == 1 && Object::cast_to<Skeleton3D>(child)) {
-
Skeleton3D *sk = Object::cast_to<Skeleton3D>(child);
bone_idx = sk->find_bone(a->track_get_path(i).get_subname(0));
if (bone_idx == -1) {
-
continue;
}
}
{
- if (!child->is_connected("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed)))
+ if (!child->is_connected("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed))) {
child->connect("tree_exiting", callable_mp(this, &AnimationPlayer::_node_removed), make_binds(child), CONNECT_ONESHOT);
+ }
}
TrackNodeCacheKey key;
key.id = id;
key.bone_idx = bone_idx;
- if (!node_cache_map.has(key))
+ if (!node_cache_map.has(key)) {
node_cache_map[key] = TrackNodeCache();
+ }
p_anim->node_cache.write[i] = &node_cache_map[key];
p_anim->node_cache[i]->path = a->track_get_path(i);
@@ -305,31 +289,27 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
}
if (a->track_get_type(i) == Animation::TYPE_VALUE) {
-
if (!p_anim->node_cache[i]->property_anim.has(a->track_get_path(i).get_concatenated_subnames())) {
-
TrackNodeCache::PropertyAnim pa;
pa.subpath = leftover_path;
pa.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child;
pa.special = SP_NONE;
pa.owner = p_anim->node_cache[i];
if (false && p_anim->node_cache[i]->node_2d) {
-
- if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_pos)
+ if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_pos) {
pa.special = SP_NODE2D_POS;
- else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_rot)
+ } else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_rot) {
pa.special = SP_NODE2D_ROT;
- else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_scale)
+ } else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_scale) {
pa.special = SP_NODE2D_SCALE;
+ }
}
p_anim->node_cache[i]->property_anim[a->track_get_path(i).get_concatenated_subnames()] = pa;
}
}
if (a->track_get_type(i) == Animation::TYPE_BEZIER && leftover_path.size()) {
-
if (!p_anim->node_cache[i]->bezier_anim.has(a->track_get_path(i).get_concatenated_subnames())) {
-
TrackNodeCache::BezierAnim ba;
ba.bezier_property = leftover_path;
ba.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child;
@@ -342,7 +322,6 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
}
void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float p_time, float p_delta, float p_interp, bool p_is_current, bool p_seeked, bool p_started) {
-
_ensure_node_caches(p_anim);
ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count());
@@ -350,7 +329,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
for (int i = 0; i < a->get_track_count(); i++) {
-
// If an animation changes this animation (or it animates itself)
// we need to recreate our animation cache
if (p_anim->node_cache.size() != a->get_track_count()) {
@@ -359,21 +337,23 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
TrackNodeCache *nc = p_anim->node_cache[i];
- if (!nc)
+ if (!nc) {
continue; // no node cache for this track, skip it
+ }
- if (!a->track_is_enabled(i))
+ if (!a->track_is_enabled(i)) {
continue; // do nothing if the track is disabled
+ }
- if (a->track_get_key_count(i) == 0)
+ if (a->track_get_key_count(i) == 0) {
continue; // do nothing if track is empty
+ }
switch (a->track_get_type(i)) {
-
case Animation::TYPE_TRANSFORM: {
-
- if (!nc->spatial)
+ if (!nc->spatial) {
continue;
+ }
Vector3 loc;
Quat rot;
@@ -382,8 +362,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
Error err = a->transform_track_interpolate(i, p_time, &loc, &rot, &scale);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
- if (err != OK)
+ if (err != OK) {
continue;
+ }
if (nc->accum_pass != accum_pass) {
ERR_CONTINUE(cache_update_size >= NODE_CACHE_UPDATE_MAX);
@@ -394,7 +375,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
nc->scale_accum = scale;
} else {
-
nc->loc_accum = nc->loc_accum.lerp(loc, p_interp);
nc->rot_accum = nc->rot_accum.slerp(rot, p_interp);
nc->scale_accum = nc->scale_accum.lerp(scale, p_interp);
@@ -402,9 +382,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
} break;
case Animation::TYPE_VALUE: {
-
- if (!nc->node)
+ if (!nc->node) {
continue;
+ }
//StringName property=a->track_get_path(i).get_property();
@@ -416,14 +396,14 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
Animation::UpdateMode update_mode = a->value_track_get_update_mode(i);
if (update_mode == Animation::UPDATE_CAPTURE) {
-
- if (p_started) {
+ if (p_started || pa->capture == Variant()) {
pa->capture = pa->object->get_indexed(pa->subpath);
}
int key_count = a->track_get_key_count(i);
- if (key_count == 0)
+ if (key_count == 0) {
continue; //eeh not worth it
+ }
float first_key_time = a->track_get_key_time(i, 0);
float transition = 1.0;
@@ -431,8 +411,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
if (first_key_time == 0.0) {
//ignore, use for transition
- if (key_count == 1)
+ if (key_count == 1) {
continue; //with one key we can't do anything
+ }
transition = a->track_get_key_transition(i, 0);
first_key_time = a->track_get_key_time(i, 1);
first_key = 1;
@@ -461,8 +442,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
Variant value = a->value_track_interpolate(i, p_time);
- if (value == Variant())
+ if (value == Variant()) {
continue;
+ }
//thanks to trigger mode, this should be solved now..
/*
@@ -479,15 +461,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
}
} else if (p_is_current && p_delta != 0) {
-
List<int> indices;
a->value_track_get_key_indices(i, p_time, p_delta, &indices);
for (List<int>::Element *F = indices.front(); F; F = F->next()) {
-
Variant value = a->track_get_key_value(i, F->get());
switch (pa->special) {
-
case SP_NONE: {
bool valid;
pa->object->set_indexed(pa->subpath, value, &valid); //you are not speshul
@@ -530,21 +509,21 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
} break;
case Animation::TYPE_METHOD: {
-
- if (!nc->node)
+ if (!nc->node) {
continue;
+ }
if (p_delta == 0) {
continue;
}
- if (!p_is_current)
+ if (!p_is_current) {
break;
+ }
List<int> indices;
a->method_track_get_key_indices(i, p_time, p_delta, &indices);
for (List<int>::Element *E = indices.front(); E; E = E->next()) {
-
StringName method = a->method_track_get_name(i, E->get());
Vector<Variant> params = a->method_track_get_params(i, E->get());
@@ -581,9 +560,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
} break;
case Animation::TYPE_BEZIER: {
-
- if (!nc->node)
+ if (!nc->node) {
continue;
+ }
Map<StringName, TrackNodeCache::BezierAnim>::Element *E = nc->bezier_anim.find(a->track_get_path(i).get_concatenated_subnames());
ERR_CONTINUE(!E); //should it continue, or create a new one?
@@ -602,9 +581,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
} break;
case Animation::TYPE_AUDIO: {
-
- if (!nc->node)
+ if (!nc->node) {
continue;
+ }
if (p_delta == 0) {
continue;
}
@@ -612,8 +591,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
if (p_seeked) {
//find whathever should be playing
int idx = a->track_find_key(i, p_time);
- if (idx < 0)
+ if (idx < 0) {
continue;
+ }
Ref<AudioStream> stream = a->audio_track_get_key_stream(i, idx);
if (!stream.is_valid()) {
@@ -678,7 +658,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
nc->audio_start = p_time;
}
} else if (nc->audio_playing) {
-
bool loop = a->has_loop();
bool stop = false;
@@ -704,22 +683,24 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
} break;
case Animation::TYPE_ANIMATION: {
-
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(nc->node);
- if (!player)
+ if (!player) {
continue;
+ }
if (p_delta == 0 || p_seeked) {
//seek
int idx = a->track_find_key(i, p_time);
- if (idx < 0)
+ if (idx < 0) {
continue;
+ }
float pos = a->track_get_key_time(i, idx);
StringName anim_name = a->animation_track_get_key_animation(i, idx);
- if (String(anim_name) == "[stop]" || !player->has_animation(anim_name))
+ if (String(anim_name) == "[stop]" || !player->has_animation(anim_name)) {
continue;
+ }
Ref<Animation> anim = player->get_animation(anim_name);
@@ -749,7 +730,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
StringName anim_name = a->animation_track_get_key_animation(i, idx);
if (String(anim_name) == "[stop]" || !player->has_animation(anim_name)) {
-
if (playing_caches.has(nc)) {
playing_caches.erase(nc);
player->stop();
@@ -769,7 +749,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
}
void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, float p_blend, bool p_seeked, bool p_started) {
-
float delta = p_delta * speed_scale * cd.speed_scale;
float next_pos = cd.pos + delta;
@@ -777,17 +756,16 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
bool loop = cd.from->animation->has_loop();
if (!loop) {
-
- if (next_pos < 0)
+ if (next_pos < 0) {
next_pos = 0;
- else if (next_pos > len)
+ } else if (next_pos > len) {
next_pos = len;
+ }
// fix delta
delta = next_pos - cd.pos;
if (&cd == &playback.current) {
-
bool backwards = delta < 0;
if (!backwards && cd.pos <= len && next_pos == len /*&& playback.blend.empty()*/) {
@@ -804,7 +782,6 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
}
} else {
-
float looped_next_pos = Math::fposmod(next_pos, len);
if (looped_next_pos == 0 && next_pos != 0) {
// Loop multiples of the length to it, rather than 0
@@ -819,8 +796,8 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
_animation_process_animation(cd.from, cd.pos, delta, p_blend, &cd == &playback.current, p_seeked, p_started);
}
-void AnimationPlayer::_animation_process2(float p_delta, bool p_started) {
+void AnimationPlayer::_animation_process2(float p_delta, bool p_started) {
Playback &c = playback;
accum_pass++;
@@ -832,7 +809,6 @@ void AnimationPlayer::_animation_process2(float p_delta, bool p_started) {
List<Blend>::Element *prev = nullptr;
for (List<Blend>::Element *E = c.blend.back(); E; E = prev) {
-
Blend &b = E->get();
float blend = b.blend_left / b.blend_time;
_animation_process_data(b.data, p_delta, blend, false, false);
@@ -841,7 +817,6 @@ void AnimationPlayer::_animation_process2(float p_delta, bool p_started) {
prev = E->prev();
if (b.blend_left < 0) {
-
c.blend.erase(E);
}
}
@@ -851,7 +826,6 @@ void AnimationPlayer::_animation_update_transforms() {
{
Transform t;
for (int i = 0; i < cache_update_size; i++) {
-
TrackNodeCache *nc = cache_update[i];
ERR_CONTINUE(nc->accum_pass != accum_pass);
@@ -859,11 +833,9 @@ void AnimationPlayer::_animation_update_transforms() {
t.origin = nc->loc_accum;
t.basis.set_quat_scale(nc->rot_accum, nc->scale_accum);
if (nc->skeleton && nc->bone_idx >= 0) {
-
nc->skeleton->set_bone_pose(nc->bone_idx, t);
} else if (nc->spatial) {
-
nc->spatial->set_transform(t);
}
}
@@ -872,13 +844,11 @@ void AnimationPlayer::_animation_update_transforms() {
cache_update_size = 0;
for (int i = 0; i < cache_update_prop_size; i++) {
-
TrackNodeCache::PropertyAnim *pa = cache_update_prop[i];
ERR_CONTINUE(pa->accum_pass != accum_pass);
switch (pa->special) {
-
case SP_NONE: {
bool valid;
pa->object->set_indexed(pa->subpath, pa->value_accum, &valid); //you are not speshul
@@ -921,7 +891,6 @@ void AnimationPlayer::_animation_update_transforms() {
cache_update_prop_size = 0;
for (int i = 0; i < cache_update_bezier_size; i++) {
-
TrackNodeCache::BezierAnim *ba = cache_update_bezier[i];
ERR_CONTINUE(ba->accum_pass != accum_pass);
@@ -932,9 +901,7 @@ void AnimationPlayer::_animation_update_transforms() {
}
void AnimationPlayer::_animation_process(float p_delta) {
-
if (playback.current.from) {
-
end_reached = false;
end_notify = false;
_animation_process2(p_delta, playback.started);
@@ -950,14 +917,16 @@ void AnimationPlayer::_animation_process(float p_delta) {
play(queued.front()->get());
String new_name = playback.assigned;
queued.pop_front();
- if (end_notify)
+ if (end_notify) {
emit_signal(SceneStringNames::get_singleton()->animation_changed, old, new_name);
+ }
} else {
//stop();
playing = false;
_set_process(false);
- if (end_notify)
+ if (end_notify) {
emit_signal(SceneStringNames::get_singleton()->animation_finished, playback.assigned);
+ }
}
end_reached = false;
}
@@ -968,7 +937,6 @@ void AnimationPlayer::_animation_process(float p_delta) {
}
Error AnimationPlayer::add_animation(const StringName &p_name, const Ref<Animation> &p_animation) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V_MSG(String(p_name).find("/") != -1 || String(p_name).find(":") != -1 || String(p_name).find(",") != -1 || String(p_name).find("[") != -1, ERR_INVALID_PARAMETER, "Invalid animation name: " + String(p_name) + ".");
#endif
@@ -976,12 +944,10 @@ Error AnimationPlayer::add_animation(const StringName &p_name, const Ref<Animati
ERR_FAIL_COND_V(p_animation.is_null(), ERR_INVALID_PARAMETER);
if (animation_set.has(p_name)) {
-
_unref_anim(animation_set[p_name].animation);
animation_set[p_name].animation = p_animation;
clear_caches();
} else {
-
AnimationData ad;
ad.animation = p_animation;
ad.name = p_name;
@@ -994,7 +960,6 @@ Error AnimationPlayer::add_animation(const StringName &p_name, const Ref<Animati
}
void AnimationPlayer::remove_animation(const StringName &p_name) {
-
ERR_FAIL_COND(!animation_set.has(p_name));
stop();
@@ -1006,17 +971,14 @@ void AnimationPlayer::remove_animation(const StringName &p_name) {
}
void AnimationPlayer::_ref_anim(const Ref<Animation> &p_anim) {
-
Ref<Animation>(p_anim)->connect(SceneStringNames::get_singleton()->tracks_changed, callable_mp(this, &AnimationPlayer::_animation_changed), varray(), CONNECT_REFERENCE_COUNTED);
}
void AnimationPlayer::_unref_anim(const Ref<Animation> &p_anim) {
-
Ref<Animation>(p_anim)->disconnect(SceneStringNames::get_singleton()->tracks_changed, callable_mp(this, &AnimationPlayer::_animation_changed));
}
void AnimationPlayer::rename_animation(const StringName &p_name, const StringName &p_new_name) {
-
ERR_FAIL_COND(!animation_set.has(p_name));
ERR_FAIL_COND(String(p_new_name).find("/") != -1 || String(p_new_name).find(":") != -1);
ERR_FAIL_COND(animation_set.has(p_new_name));
@@ -1030,7 +992,6 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam
List<BlendKey> to_erase;
Map<BlendKey, float> to_insert;
for (Map<BlendKey, float>::Element *E = blend_times.front(); E; E = E->next()) {
-
BlendKey bk = E->key();
BlendKey new_bk = bk;
bool erase = false;
@@ -1050,7 +1011,6 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam
}
while (to_erase.size()) {
-
blend_times.erase(to_erase.front()->get());
to_erase.pop_front();
}
@@ -1060,73 +1020,71 @@ void AnimationPlayer::rename_animation(const StringName &p_name, const StringNam
to_insert.erase(to_insert.front());
}
- if (autoplay == p_name)
+ if (autoplay == p_name) {
autoplay = p_new_name;
+ }
clear_caches();
_change_notify();
}
bool AnimationPlayer::has_animation(const StringName &p_name) const {
-
return animation_set.has(p_name);
}
-Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const {
+Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const {
ERR_FAIL_COND_V(!animation_set.has(p_name), Ref<Animation>());
const AnimationData &data = animation_set[p_name];
return data.animation;
}
-void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
+void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
List<String> anims;
for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
-
anims.push_back(E->key());
}
anims.sort();
for (List<String>::Element *E = anims.front(); E; E = E->next()) {
-
p_animations->push_back(E->get());
}
}
void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time) {
-
ERR_FAIL_COND_MSG(p_time < 0, "Blend time cannot be smaller than 0.");
BlendKey bk;
bk.from = p_animation1;
bk.to = p_animation2;
- if (p_time == 0)
+ if (p_time == 0) {
blend_times.erase(bk);
- else
+ } else {
blend_times[bk] = p_time;
+ }
}
float AnimationPlayer::get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const {
-
BlendKey bk;
bk.from = p_animation1;
bk.to = p_animation2;
- if (blend_times.has(bk))
+ if (blend_times.has(bk)) {
return blend_times[bk];
- else
+ } else {
return 0;
+ }
}
void AnimationPlayer::queue(const StringName &p_name) {
-
- if (!is_playing())
+ if (!is_playing()) {
play(p_name);
- else
+ } else {
queued.push_back(p_name);
+ }
}
Vector<String> AnimationPlayer::get_queue() {
@@ -1143,23 +1101,21 @@ void AnimationPlayer::clear_queue() {
}
void AnimationPlayer::play_backwards(const StringName &p_name, float p_custom_blend) {
-
play(p_name, p_custom_blend, -1, true);
}
void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float p_custom_scale, bool p_from_end) {
-
StringName name = p_name;
- if (String(name) == "")
+ if (String(name) == "") {
name = playback.assigned;
+ }
ERR_FAIL_COND_MSG(!animation_set.has(name), "Animation not found: " + name + ".");
Playback &c = playback;
if (c.current.from) {
-
float blend_time = 0;
// find if it can blend
BlendKey bk;
@@ -1169,30 +1125,25 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
if (p_custom_blend >= 0) {
blend_time = p_custom_blend;
} else if (blend_times.has(bk)) {
-
blend_time = blend_times[bk];
} else {
-
bk.from = "*";
if (blend_times.has(bk)) {
-
blend_time = blend_times[bk];
} else {
-
bk.from = c.current.from->name;
bk.to = "*";
if (blend_times.has(bk)) {
-
blend_time = blend_times[bk];
}
}
}
- if (p_custom_blend < 0 && blend_time == 0 && default_blend_time)
+ if (p_custom_blend < 0 && blend_time == 0 && default_blend_time) {
blend_time = default_blend_time;
+ }
if (blend_time > 0) {
-
Blend b;
b.data = c.current;
b.blend_time = b.blend_left = blend_time;
@@ -1223,15 +1174,17 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
c.seeked = false;
c.started = true;
- if (!end_reached)
+ if (!end_reached) {
queued.clear();
+ }
_set_process(true); // always process when starting an animation
playing = true;
emit_signal(SceneStringNames::get_singleton()->animation_started, c.assigned);
- if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
return; // no next in this case
+ }
StringName next = animation_get_next(p_name);
if (next != StringName() && animation_set.has(next)) {
@@ -1240,12 +1193,10 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
}
bool AnimationPlayer::is_playing() const {
-
return playing;
}
void AnimationPlayer::set_current_animation(const String &p_anim) {
-
if (p_anim == "[stop]" || p_anim == "") {
stop();
} else if (!is_playing() || playback.assigned != p_anim) {
@@ -1256,12 +1207,10 @@ void AnimationPlayer::set_current_animation(const String &p_anim) {
}
String AnimationPlayer::get_current_animation() const {
-
return (is_playing() ? playback.assigned : "");
}
void AnimationPlayer::set_assigned_animation(const String &p_anim) {
-
if (is_playing()) {
play(p_anim);
} else {
@@ -1273,12 +1222,10 @@ void AnimationPlayer::set_assigned_animation(const String &p_anim) {
}
String AnimationPlayer::get_assigned_animation() const {
-
return playback.assigned;
}
void AnimationPlayer::stop(bool p_reset) {
-
_stop_playing_caches();
Playback &c = playback;
c.blend.clear();
@@ -1293,15 +1240,14 @@ void AnimationPlayer::stop(bool p_reset) {
}
void AnimationPlayer::set_speed_scale(float p_speed) {
-
speed_scale = p_speed;
}
-float AnimationPlayer::get_speed_scale() const {
+float AnimationPlayer::get_speed_scale() const {
return speed_scale;
}
-float AnimationPlayer::get_playing_speed() const {
+float AnimationPlayer::get_playing_speed() const {
if (!playing) {
return 0;
}
@@ -1309,7 +1255,6 @@ float AnimationPlayer::get_playing_speed() const {
}
void AnimationPlayer::seek(float p_time, bool p_update) {
-
if (!playback.current.from) {
if (playback.assigned) {
ERR_FAIL_COND(!animation_set.has(playback.assigned));
@@ -1326,7 +1271,6 @@ void AnimationPlayer::seek(float p_time, bool p_update) {
}
void AnimationPlayer::seek_delta(float p_time, float p_delta) {
-
if (!playback.current.from) {
if (playback.assigned) {
ERR_FAIL_COND(!animation_set.has(playback.assigned));
@@ -1336,31 +1280,28 @@ void AnimationPlayer::seek_delta(float p_time, float p_delta) {
}
playback.current.pos = p_time - p_delta;
- if (speed_scale != 0.0)
+ if (speed_scale != 0.0) {
p_delta /= speed_scale;
+ }
_animation_process(p_delta);
//playback.current.pos=p_time;
}
bool AnimationPlayer::is_valid() const {
-
return (playback.current.from);
}
float AnimationPlayer::get_current_animation_position() const {
-
ERR_FAIL_COND_V(!playback.current.from, 0);
return playback.current.pos;
}
float AnimationPlayer::get_current_animation_length() const {
-
ERR_FAIL_COND_V(!playback.current.from, 0);
return playback.current.from->animation->get_length();
}
void AnimationPlayer::_animation_changed() {
-
clear_caches();
emit_signal("caches_cleared");
if (is_playing()) {
@@ -1369,16 +1310,15 @@ void AnimationPlayer::_animation_changed() {
}
void AnimationPlayer::_stop_playing_caches() {
-
for (Set<TrackNodeCache *>::Element *E = playing_caches.front(); E; E = E->next()) {
-
if (E->get()->node && E->get()->audio_playing) {
E->get()->node->call("stop");
}
if (E->get()->node && E->get()->animation_playing) {
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(E->get()->node);
- if (!player)
+ if (!player) {
continue;
+ }
player->stop();
}
}
@@ -1387,18 +1327,15 @@ void AnimationPlayer::_stop_playing_caches() {
}
void AnimationPlayer::_node_removed(Node *p_node) {
-
clear_caches(); // nodes contained here ar being removed, clear the caches
}
void AnimationPlayer::clear_caches() {
-
_stop_playing_caches();
node_cache_map.clear();
for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
-
E->get().node_cache.clear();
}
@@ -1408,77 +1345,73 @@ void AnimationPlayer::clear_caches() {
}
void AnimationPlayer::set_active(bool p_active) {
-
- if (active == p_active)
+ if (active == p_active) {
return;
+ }
active = p_active;
_set_process(processing, true);
}
bool AnimationPlayer::is_active() const {
-
return active;
}
StringName AnimationPlayer::find_animation(const Ref<Animation> &p_animation) const {
-
for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
-
- if (E->get().animation == p_animation)
+ if (E->get().animation == p_animation) {
return E->key();
+ }
}
return "";
}
void AnimationPlayer::set_autoplay(const String &p_name) {
- if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
WARN_PRINT("Setting autoplay after the node has been added to the scene has no effect.");
+ }
autoplay = p_name;
}
String AnimationPlayer::get_autoplay() const {
-
return autoplay;
}
void AnimationPlayer::set_animation_process_mode(AnimationProcessMode p_mode) {
-
- if (animation_process_mode == p_mode)
+ if (animation_process_mode == p_mode) {
return;
+ }
bool pr = processing;
- if (pr)
+ if (pr) {
_set_process(false);
+ }
animation_process_mode = p_mode;
- if (pr)
+ if (pr) {
_set_process(true);
+ }
}
AnimationPlayer::AnimationProcessMode AnimationPlayer::get_animation_process_mode() const {
-
return animation_process_mode;
}
void AnimationPlayer::set_method_call_mode(AnimationMethodCallMode p_mode) {
-
method_call_mode = p_mode;
}
AnimationPlayer::AnimationMethodCallMode AnimationPlayer::get_method_call_mode() const {
-
return method_call_mode;
}
void AnimationPlayer::_set_process(bool p_process, bool p_force) {
-
- if (processing == p_process && !p_force)
+ if (processing == p_process && !p_force) {
return;
+ }
switch (animation_process_mode) {
-
case ANIMATION_PROCESS_PHYSICS:
set_physics_process_internal(p_process && active);
break;
@@ -1493,41 +1426,35 @@ void AnimationPlayer::_set_process(bool p_process, bool p_force) {
}
void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) {
-
ERR_FAIL_COND(!animation_set.has(p_animation));
animation_set[p_animation].next = p_next;
}
StringName AnimationPlayer::animation_get_next(const StringName &p_animation) const {
-
- if (!animation_set.has(p_animation))
+ if (!animation_set.has(p_animation)) {
return StringName();
+ }
return animation_set[p_animation].next;
}
void AnimationPlayer::set_default_blend_time(float p_default) {
-
default_blend_time = p_default;
}
float AnimationPlayer::get_default_blend_time() const {
-
return default_blend_time;
}
void AnimationPlayer::set_root(const NodePath &p_root) {
-
root = p_root;
clear_caches();
}
NodePath AnimationPlayer::get_root() const {
-
return root;
}
void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
@@ -1539,7 +1466,6 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i
List<StringName> al;
get_animation_list(&al);
for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
-
r_options->push_back(quote_style + String(E->get()) + quote_style);
}
}
@@ -1548,9 +1474,9 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i
#ifdef TOOLS_ENABLED
AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
-
- if (!playback.current.from)
+ if (!playback.current.from) {
return AnimatedValuesBackup();
+ }
_ensure_node_caches(playback.current.from);
@@ -1558,12 +1484,14 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
for (int i = 0; i < playback.current.from->node_cache.size(); i++) {
TrackNodeCache *nc = playback.current.from->node_cache[i];
- if (!nc)
+ if (!nc) {
continue;
+ }
if (nc->skeleton) {
- if (nc->bone_idx == -1)
+ if (nc->bone_idx == -1) {
continue;
+ }
AnimatedValuesBackup::Entry entry;
entry.object = nc->skeleton;
@@ -1586,8 +1514,9 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
bool valid;
entry.value = E->value().object->get_indexed(E->value().subpath, &valid);
entry.bone_idx = -1;
- if (valid)
+ if (valid) {
backup.entries.push_back(entry);
+ }
}
}
}
@@ -1597,9 +1526,7 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
}
void AnimationPlayer::restore_animated_values(const AnimatedValuesBackup &p_backup) {
-
for (int i = 0; i < p_backup.entries.size(); i++) {
-
const AnimatedValuesBackup::Entry *entry = &p_backup.entries[i];
if (entry->bone_idx == -1) {
entry->object->set_indexed(entry->subpath, entry->value);
@@ -1697,7 +1624,6 @@ void AnimationPlayer::_bind_methods() {
}
AnimationPlayer::AnimationPlayer() {
-
accum_pass = 1;
cache_update_size = 0;
cache_update_prop_size = 0;
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index c134aff707..1a66665803 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -85,89 +85,66 @@ private:
};
struct TrackNodeCache {
-
NodePath path;
- uint32_t id;
+ uint32_t id = 0;
RES resource;
- Node *node;
- Node3D *spatial;
- Node2D *node_2d;
- Skeleton3D *skeleton;
- int bone_idx;
+ Node *node = nullptr;
+ Node3D *spatial = nullptr;
+ Node2D *node_2d = nullptr;
+ Skeleton3D *skeleton = nullptr;
+ int bone_idx = -1;
// accumulated transforms
Vector3 loc_accum;
Quat rot_accum;
Vector3 scale_accum;
- uint64_t accum_pass;
+ uint64_t accum_pass = 0;
- bool audio_playing;
- float audio_start;
- float audio_len;
+ bool audio_playing = false;
+ float audio_start = 0.0;
+ float audio_len = 0.0;
- bool animation_playing;
+ bool animation_playing = false;
struct PropertyAnim {
-
- TrackNodeCache *owner;
- SpecialProperty special; //small optimization
+ TrackNodeCache *owner = nullptr;
+ SpecialProperty special = SP_NONE; //small optimization
Vector<StringName> subpath;
- Object *object;
+ Object *object = nullptr;
Variant value_accum;
- uint64_t accum_pass;
+ uint64_t accum_pass = 0;
Variant capture;
- PropertyAnim() :
- owner(nullptr),
- special(SP_NONE),
- object(nullptr),
- accum_pass(0) {}
+ PropertyAnim() {}
};
Map<StringName, PropertyAnim> property_anim;
struct BezierAnim {
-
Vector<StringName> bezier_property;
- TrackNodeCache *owner;
- float bezier_accum;
- Object *object;
- uint64_t accum_pass;
-
- BezierAnim() :
- owner(nullptr),
- bezier_accum(0.0),
- object(nullptr),
- accum_pass(0) {}
+ TrackNodeCache *owner = nullptr;
+ float bezier_accum = 0.0;
+ Object *object = nullptr;
+ uint64_t accum_pass = 0;
+
+ BezierAnim() {}
};
Map<StringName, BezierAnim> bezier_anim;
- TrackNodeCache() :
- id(0),
- node(nullptr),
- spatial(nullptr),
- node_2d(nullptr),
- skeleton(nullptr),
- bone_idx(-1),
- accum_pass(0),
- audio_playing(false),
- audio_start(0.0),
- audio_len(0.0),
- animation_playing(false) {}
+ TrackNodeCache() {}
};
struct TrackNodeCacheKey {
-
ObjectID id;
int bone_idx;
inline bool operator<(const TrackNodeCacheKey &p_right) const {
-
- if (id == p_right.id)
+ if (id == p_right.id) {
return bone_idx < p_right.bone_idx;
- else
+ } else {
return id < p_right.id;
+ }
}
};
@@ -194,7 +171,6 @@ private:
Map<StringName, AnimationData> animation_set;
struct BlendKey {
-
StringName from;
StringName to;
bool operator<(const BlendKey &bk) const { return from == bk.from ? String(to) < String(bk.to) : String(from) < String(bk.from); }
@@ -203,13 +179,11 @@ private:
Map<BlendKey, float> blend_times;
struct PlaybackData {
-
AnimationData *from;
float pos;
float speed_scale;
PlaybackData() {
-
pos = 0;
speed_scale = 1.0;
from = nullptr;
@@ -217,21 +191,18 @@ private:
};
struct Blend {
-
PlaybackData data;
float blend_time;
float blend_left;
Blend() {
-
blend_left = 0;
blend_time = 0;
}
};
struct Playback {
-
List<Blend> blend;
PlaybackData current;
StringName assigned;
@@ -265,12 +236,10 @@ private:
// bind helpers
Vector<String> _get_animation_list() const {
-
List<StringName> animations;
get_animation_list(&animations);
Vector<String> ret;
while (animations.size()) {
-
ret.push_back(animations.front()->get());
animations.pop_front();
}
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 56e224819f..466536db10 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -73,7 +73,6 @@ Variant AnimationNode::get_parameter(const StringName &p_name) const {
}
void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
-
if (get_script_instance()) {
Dictionary cn = get_script_instance()->call("get_child_nodes");
List<Variant> keys;
@@ -88,14 +87,12 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
}
void AnimationNode::blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend) {
-
ERR_FAIL_COND(!state);
ERR_FAIL_COND(!state->player->has_animation(p_animation));
Ref<Animation> animation = state->player->get_animation(p_animation);
if (animation.is_null()) {
-
AnimationNodeBlendTree *btree = Object::cast_to<AnimationNodeBlendTree>(parent);
if (btree) {
String name = btree->get_node_name(Ref<AnimationNodeAnimation>(this));
@@ -120,7 +117,6 @@ void AnimationNode::blend_animation(const StringName &p_animation, float p_time,
}
float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections) {
-
base_path = p_base_path;
parent = p_parent;
connections = p_connections;
@@ -176,12 +172,10 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p
}
float AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) {
-
return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize);
}
float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize, float *r_max) {
-
ERR_FAIL_COND_V(!p_node.is_valid(), 0);
ERR_FAIL_COND_V(!state, 0);
@@ -197,7 +191,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
bool any_valid = false;
if (has_filter() && is_filter_enabled() && p_filter != FILTER_IGNORE) {
-
for (int i = 0; i < blend_count; i++) {
blendw[i] = 0.0; //all to zero by default
}
@@ -217,8 +210,9 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
case FILTER_PASS: {
//values filtered pass, the rest don't
for (int i = 0; i < blend_count; i++) {
- if (blendw[i] == 0) //not filtered, does not pass
+ if (blendw[i] == 0) { //not filtered, does not pass
continue;
+ }
blendw[i] = blendr[i] * p_blend;
if (blendw[i] > CMP_EPSILON) {
@@ -228,12 +222,12 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
} break;
case FILTER_STOP: {
-
//values filtered don't pass, the rest are blended
for (int i = 0; i < blend_count; i++) {
- if (blendw[i] > 0) //filtered, does not pass
+ if (blendw[i] > 0) { //filtered, does not pass
continue;
+ }
blendw[i] = blendr[i] * p_blend;
if (blendw[i] > CMP_EPSILON) {
@@ -243,7 +237,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
} break;
case FILTER_BLEND: {
-
//filtered values are blended, the rest are passed without blending
for (int i = 0; i < blend_count; i++) {
@@ -262,7 +255,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
}
} else {
for (int i = 0; i < blend_count; i++) {
-
//regular blend
blendw[i] = blendr[i] * p_blend;
if (blendw[i] > CMP_EPSILON) {
@@ -278,8 +270,9 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
}
}
- if (!p_seek && p_optimize && !any_valid) //pointless to go on, all are zero
+ if (!p_seek && p_optimize && !any_valid) { //pointless to go on, all are zero
return 0;
+ }
String new_path;
AnimationNode *new_parent;
@@ -297,16 +290,15 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
}
int AnimationNode::get_input_count() const {
-
return inputs.size();
}
+
String AnimationNode::get_input_name(int p_input) {
ERR_FAIL_INDEX_V(p_input, inputs.size(), String());
return inputs[p_input].name;
}
String AnimationNode::get_caption() const {
-
if (get_script_instance()) {
return get_script_instance()->call("get_caption");
}
@@ -338,7 +330,6 @@ void AnimationNode::remove_input(int p_index) {
}
float AnimationNode::process(float p_time, bool p_seek) {
-
if (get_script_instance()) {
return get_script_instance()->call("process", p_time, p_seek);
}
@@ -371,7 +362,6 @@ bool AnimationNode::has_filter() const {
}
Array AnimationNode::_get_filters() const {
-
Array paths;
const NodePath *K = nullptr;
@@ -382,6 +372,7 @@ Array AnimationNode::_get_filters() const {
return paths;
}
+
void AnimationNode::_set_filters(const Array &p_filters) {
filter.clear();
for (int i = 0; i < p_filters.size(); i++) {
@@ -403,7 +394,6 @@ Ref<AnimationNode> AnimationNode::get_child_by_name(const StringName &p_name) {
}
void AnimationNode::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_input_count"), &AnimationNode::get_input_count);
ClassDB::bind_method(D_METHOD("get_input_name", "input"), &AnimationNode::get_input_name);
@@ -452,7 +442,6 @@ void AnimationNode::_bind_methods() {
}
AnimationNode::AnimationNode() {
-
state = nullptr;
parent = nullptr;
filter_enabled = false;
@@ -461,7 +450,6 @@ AnimationNode::AnimationNode() {
////////////////////
void AnimationTree::set_tree_root(const Ref<AnimationNode> &p_root) {
-
if (root.is_valid()) {
root->disconnect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed));
}
@@ -482,9 +470,9 @@ Ref<AnimationNode> AnimationTree::get_tree_root() const {
}
void AnimationTree::set_active(bool p_active) {
-
- if (active == p_active)
+ if (active == p_active) {
return;
+ }
active = p_active;
started = active;
@@ -492,13 +480,11 @@ void AnimationTree::set_active(bool p_active) {
if (process_mode == ANIMATION_PROCESS_IDLE) {
set_process_internal(active);
} else {
-
set_physics_process_internal(active);
}
if (!active && is_inside_tree()) {
for (Set<TrackCache *>::Element *E = playing_caches.front(); E; E = E->next()) {
-
if (ObjectDB::get_instance(E->get()->object_id)) {
E->get()->object->call("stop");
}
@@ -509,14 +495,13 @@ void AnimationTree::set_active(bool p_active) {
}
bool AnimationTree::is_active() const {
-
return active;
}
void AnimationTree::set_process_mode(AnimationProcessMode p_mode) {
-
- if (process_mode == p_mode)
+ if (process_mode == p_mode) {
return;
+ }
bool was_active = is_active();
if (was_active) {
@@ -539,7 +524,6 @@ void AnimationTree::_node_removed(Node *p_node) {
}
bool AnimationTree::_update_caches(AnimationPlayer *player) {
-
setup_pass++;
if (!player->has_node(player->get_root())) {
@@ -572,7 +556,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
}
if (!track) {
-
RES resource;
Vector<StringName> leftover_path;
Node *child = parent->get_node_and_resource(path, resource, leftover_path);
@@ -588,7 +571,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
switch (track_type) {
case Animation::TYPE_VALUE: {
-
TrackCacheValue *track_value = memnew(TrackCacheValue);
if (resource.is_valid()) {
@@ -604,7 +586,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_TRANSFORM: {
-
Node3D *spatial = Object::cast_to<Node3D>(child);
if (!spatial) {
@@ -619,11 +600,9 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_xform->bone_idx = -1;
if (path.get_subname_count() == 1 && Object::cast_to<Skeleton3D>(spatial)) {
-
Skeleton3D *sk = Object::cast_to<Skeleton3D>(spatial);
int bone_idx = sk->find_bone(path.get_subname(0));
if (bone_idx != -1) {
-
track_xform->skeleton = sk;
track_xform->bone_idx = bone_idx;
}
@@ -636,7 +615,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_METHOD: {
-
TrackCacheMethod *track_method = memnew(TrackCacheMethod);
if (resource.is_valid()) {
@@ -651,7 +629,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_BEZIER: {
-
TrackCacheBezier *track_bezier = memnew(TrackCacheBezier);
if (resource.is_valid()) {
@@ -666,7 +643,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track = track_bezier;
} break;
case Animation::TYPE_AUDIO: {
-
TrackCacheAudio *track_audio = memnew(TrackCacheAudio);
track_audio->object = child;
@@ -676,7 +652,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_ANIMATION: {
-
TrackCacheAnimation *track_animation = memnew(TrackCacheAnimation);
track_animation->object = child;
@@ -732,7 +707,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
}
void AnimationTree::_clear_caches() {
-
const NodePath *K = nullptr;
while ((K = track_cache.next(K))) {
memdelete(track_cache[*K]);
@@ -744,7 +718,6 @@ void AnimationTree::_clear_caches() {
}
void AnimationTree::_process_graph(float p_delta) {
-
_update_properties(); //if properties need updating, update them
//check all tracks, see if they need modification
@@ -774,7 +747,6 @@ void AnimationTree::_process_graph(float p_delta) {
}
if (last_animation_player != current_animation_player) {
-
if (last_animation_player.is_valid()) {
Object *old_player = ObjectDB::get_instance(last_animation_player);
if (old_player) {
@@ -826,7 +798,6 @@ void AnimationTree::_process_graph(float p_delta) {
//process
{
-
if (started) {
//if started, seek
root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, Vector<StringName>());
@@ -842,11 +813,9 @@ void AnimationTree::_process_graph(float p_delta) {
//apply value/transform/bezier blends to track caches and execute method/audio/animation tracks
{
-
bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
for (List<AnimationNode::AnimationState>::Element *E = state.animation_states.front(); E; E = E->next()) {
-
const AnimationNode::AnimationState &as = E->get();
Ref<Animation> a = as.animation;
@@ -855,7 +824,6 @@ void AnimationTree::_process_graph(float p_delta) {
bool seeked = as.seeked;
for (int i = 0; i < a->get_track_count(); i++) {
-
NodePath path = a->track_get_path(i);
ERR_CONTINUE(!track_cache.has(path));
@@ -874,19 +842,16 @@ void AnimationTree::_process_graph(float p_delta) {
float blend = (*as.track_blends)[blend_idx];
- if (blend < CMP_EPSILON)
+ if (blend < CMP_EPSILON) {
continue; //nothing to blend
+ }
switch (track->type) {
-
case Animation::TYPE_TRANSFORM: {
-
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
if (track->root_motion) {
-
if (t->process_pass != process_pass) {
-
t->process_pass = process_pass;
t->loc = Vector3();
t->rot = Quat();
@@ -908,7 +873,6 @@ void AnimationTree::_process_graph(float p_delta) {
Vector3 scale[2];
if (prev_time > time) {
-
Error err = a->transform_track_interpolate(i, prev_time, &loc[0], &rot[0], &scale[0]);
if (err != OK) {
continue;
@@ -947,7 +911,6 @@ void AnimationTree::_process_graph(float p_delta) {
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (t->process_pass != process_pass) {
-
t->process_pass = process_pass;
t->loc = loc;
t->rot = rot;
@@ -955,8 +918,9 @@ void AnimationTree::_process_graph(float p_delta) {
t->scale = scale;
}
- if (err != OK)
+ if (err != OK) {
continue;
+ }
t->loc = t->loc.lerp(loc, blend);
if (t->rot_blend_accum == 0) {
@@ -972,7 +936,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_VALUE: {
-
TrackCacheValue *t = static_cast<TrackCacheValue *>(track);
Animation::UpdateMode update_mode = a->value_track_get_update_mode(i);
@@ -981,8 +944,9 @@ void AnimationTree::_process_graph(float p_delta) {
Variant value = a->value_track_interpolate(i, time);
- if (value == Variant())
+ if (value == Variant()) {
continue;
+ }
if (t->process_pass != process_pass) {
t->value = value;
@@ -992,12 +956,10 @@ void AnimationTree::_process_graph(float p_delta) {
Variant::interpolate(t->value, value, blend, t->value);
} else if (delta != 0) {
-
List<int> indices;
a->value_track_get_key_indices(i, time, delta, &indices);
for (List<int>::Element *F = indices.front(); F; F = F->next()) {
-
Variant value = a->track_get_key_value(i, F->get());
t->object->set_indexed(t->subpath, value);
}
@@ -1005,7 +967,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_METHOD: {
-
if (delta == 0) {
continue;
}
@@ -1016,7 +977,6 @@ void AnimationTree::_process_graph(float p_delta) {
a->method_track_get_key_indices(i, time, delta, &indices);
for (List<int>::Element *F = indices.front(); F; F = F->next()) {
-
StringName method = a->method_track_get_name(i, F->get());
Vector<Variant> params = a->method_track_get_params(i, F->get());
@@ -1036,7 +996,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_BEZIER: {
-
TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track);
float bezier = a->bezier_track_interpolate(i, time);
@@ -1050,14 +1009,14 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_AUDIO: {
-
TrackCacheAudio *t = static_cast<TrackCacheAudio *>(track);
if (seeked) {
//find whathever should be playing
int idx = a->track_find_key(i, time);
- if (idx < 0)
+ if (idx < 0) {
continue;
+ }
Ref<AudioStream> stream = a->audio_track_get_key_stream(i, idx);
if (!stream.is_valid()) {
@@ -1122,7 +1081,6 @@ void AnimationTree::_process_graph(float p_delta) {
t->start = time;
}
} else if (t->playing) {
-
bool loop = a->has_loop();
bool stop = false;
@@ -1154,25 +1112,27 @@ void AnimationTree::_process_graph(float p_delta) {
}
} break;
case Animation::TYPE_ANIMATION: {
-
TrackCacheAnimation *t = static_cast<TrackCacheAnimation *>(track);
AnimationPlayer *player2 = Object::cast_to<AnimationPlayer>(t->object);
- if (!player2)
+ if (!player2) {
continue;
+ }
if (delta == 0 || seeked) {
//seek
int idx = a->track_find_key(i, time);
- if (idx < 0)
+ if (idx < 0) {
continue;
+ }
float pos = a->track_get_key_time(i, idx);
StringName anim_name = a->animation_track_get_key_animation(i, idx);
- if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name))
+ if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) {
continue;
+ }
Ref<Animation> anim = player2->get_animation(anim_name);
@@ -1202,7 +1162,6 @@ void AnimationTree::_process_graph(float p_delta) {
StringName anim_name = a->animation_track_get_key_animation(i, idx);
if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) {
-
if (playing_caches.has(t)) {
playing_caches.erase(t);
player2->stop();
@@ -1227,13 +1186,12 @@ void AnimationTree::_process_graph(float p_delta) {
const NodePath *K = nullptr;
while ((K = track_cache.next(K))) {
TrackCache *track = track_cache[*K];
- if (track->process_pass != process_pass)
+ if (track->process_pass != process_pass) {
continue; //not processed, ignore
+ }
switch (track->type) {
-
case Animation::TYPE_TRANSFORM: {
-
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
Transform xform;
@@ -1242,31 +1200,26 @@ void AnimationTree::_process_graph(float p_delta) {
xform.basis.set_quat_scale(t->rot, t->scale);
if (t->root_motion) {
-
root_motion_transform = xform;
if (t->skeleton && t->bone_idx >= 0) {
root_motion_transform = (t->skeleton->get_bone_rest(t->bone_idx) * root_motion_transform) * t->skeleton->get_bone_rest(t->bone_idx).affine_inverse();
}
} else if (t->skeleton && t->bone_idx >= 0) {
-
t->skeleton->set_bone_pose(t->bone_idx, xform);
} else {
-
t->spatial->set_transform(xform);
}
} break;
case Animation::TYPE_VALUE: {
-
TrackCacheValue *t = static_cast<TrackCacheValue *>(track);
t->object->set_indexed(t->subpath, t->value);
} break;
case Animation::TYPE_BEZIER: {
-
TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track);
t->object->set_indexed(t->subpath, t->value);
@@ -1280,12 +1233,10 @@ void AnimationTree::_process_graph(float p_delta) {
}
void AnimationTree::advance(float p_time) {
-
_process_graph(p_time);
}
void AnimationTree::_notification(int p_what) {
-
if (active && p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS && process_mode == ANIMATION_PROCESS_PHYSICS) {
_process_graph(get_physics_process_delta_time());
}
@@ -1297,7 +1248,6 @@ void AnimationTree::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
_clear_caches();
if (last_animation_player.is_valid()) {
-
Object *player = ObjectDB::get_instance(last_animation_player);
if (player) {
player->disconnect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
@@ -1305,7 +1255,6 @@ void AnimationTree::_notification(int p_what) {
}
} else if (p_what == NOTIFICATION_ENTER_TREE) {
if (last_animation_player.is_valid()) {
-
Object *player = ObjectDB::get_instance(last_animation_player);
if (player) {
player->connect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
@@ -1324,11 +1273,10 @@ NodePath AnimationTree::get_animation_player() const {
}
bool AnimationTree::is_state_invalid() const {
-
return !state.valid;
}
-String AnimationTree::get_invalid_state_reason() const {
+String AnimationTree::get_invalid_state_reason() const {
return state.invalid_reasons;
}
@@ -1337,7 +1285,6 @@ uint64_t AnimationTree::get_last_process_pass() const {
}
String AnimationTree::get_configuration_warning() const {
-
String warning = Node::get_configuration_warning();
if (!root.is_valid()) {
@@ -1348,7 +1295,6 @@ String AnimationTree::get_configuration_warning() const {
}
if (!has_node(animation_player)) {
-
if (warning != String()) {
warning += "\n\n";
}
@@ -1402,13 +1348,11 @@ void AnimationTree::_tree_changed() {
}
void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node) {
-
if (!property_parent_map.has(p_base_path)) {
property_parent_map[p_base_path] = HashMap<StringName, StringName>();
}
if (node->get_input_count() && !input_activity_map.has(p_base_path)) {
-
Vector<Activity> activity;
for (int i = 0; i < node->get_input_count(); i++) {
Activity a;
@@ -1492,6 +1436,7 @@ bool AnimationTree::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
+
void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const {
if (properties_dirty) {
const_cast<AnimationTree *>(this)->_update_properties();
@@ -1503,7 +1448,6 @@ void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const {
}
void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) {
-
//rename values first
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
if (E->get().name.begins_with(p_base)) {
@@ -1518,7 +1462,6 @@ void AnimationTree::rename_parameter(const String &p_base, const String &p_new_b
}
float AnimationTree::get_connection_activity(const StringName &p_path, int p_connection) const {
-
if (!input_activity_map_get.has(p_path)) {
return 0;
}
@@ -1572,7 +1515,6 @@ void AnimationTree::_bind_methods() {
}
AnimationTree::AnimationTree() {
-
process_mode = ANIMATION_PROCESS_IDLE;
active = false;
cache_valid = false;
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index d558170f23..8fe01fac8f 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -52,7 +52,6 @@ public:
};
struct Input {
-
String name;
};
@@ -63,7 +62,6 @@ public:
friend class AnimationTree;
struct AnimationState {
-
Ref<Animation> animation;
float time;
float delta;
@@ -73,7 +71,6 @@ public:
};
struct State {
-
int track_count;
HashMap<NodePath, int> track_map;
List<AnimationState> animation_states;
@@ -174,7 +171,6 @@ public:
private:
struct TrackCache {
-
bool root_motion;
uint64_t setup_pass;
uint64_t process_pass;
@@ -209,19 +205,16 @@ private:
};
struct TrackCacheValue : public TrackCache {
-
Variant value;
Vector<StringName> subpath;
TrackCacheValue() { type = Animation::TYPE_VALUE; }
};
struct TrackCacheMethod : public TrackCache {
-
TrackCacheMethod() { type = Animation::TYPE_METHOD; }
};
struct TrackCacheBezier : public TrackCache {
-
float value;
Vector<StringName> subpath;
TrackCacheBezier() {
@@ -231,7 +224,6 @@ private:
};
struct TrackCacheAudio : public TrackCache {
-
bool playing;
float start;
float len;
@@ -245,7 +237,6 @@ private:
};
struct TrackCacheAnimation : public TrackCache {
-
bool playing;
TrackCacheAnimation() {
diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp
index f993127b07..cbf2e4a6ff 100644
--- a/scene/animation/root_motion_view.cpp
+++ b/scene/animation/root_motion_view.cpp
@@ -76,9 +76,7 @@ bool RootMotionView::get_zero_y() const {
}
void RootMotionView::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
RS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false));
first = true;
}
@@ -87,7 +85,6 @@ void RootMotionView::_notification(int p_what) {
Transform transform;
if (has_node(path)) {
-
Node *node = get_node(path);
AnimationTree *tree = Object::cast_to<AnimationTree>(node);
@@ -129,7 +126,6 @@ void RootMotionView::_notification(int p_what) {
RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_LINES);
for (int i = -cells_in_radius; i < cells_in_radius; i++) {
for (int j = -cells_in_radius; j < cells_in_radius; j++) {
-
Vector3 from(i * cell_size, 0, j * cell_size);
Vector3 from_i((i + 1) * cell_size, 0, j * cell_size);
Vector3 from_j(i * cell_size, 0, (j + 1) * cell_size);
@@ -161,15 +157,14 @@ void RootMotionView::_notification(int p_what) {
}
AABB RootMotionView::get_aabb() const {
-
return AABB(Vector3(-radius, 0, -radius), Vector3(radius * 2, 0.001, radius * 2));
}
+
Vector<Face3> RootMotionView::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
void RootMotionView::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_animation_path", "path"), &RootMotionView::set_animation_path);
ClassDB::bind_method(D_METHOD("get_animation_path"), &RootMotionView::get_animation_path);
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index b826907a3a..854db5fee2 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -33,7 +33,6 @@
#include "core/method_bind_ext.gen.inc"
void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8, const Variant &p_arg9, const Variant &p_arg10) {
-
// Add a new pending command and reference it
pending_commands.push_back(PendingCommand());
PendingCommand &cmd = pending_commands.back()->get();
@@ -43,57 +42,66 @@ void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const
// Determine command argument count
int &count = cmd.args;
- if (p_arg10.get_type() != Variant::NIL)
+ if (p_arg10.get_type() != Variant::NIL) {
count = 10;
- else if (p_arg9.get_type() != Variant::NIL)
+ } else if (p_arg9.get_type() != Variant::NIL) {
count = 9;
- else if (p_arg8.get_type() != Variant::NIL)
+ } else if (p_arg8.get_type() != Variant::NIL) {
count = 8;
- else if (p_arg7.get_type() != Variant::NIL)
+ } else if (p_arg7.get_type() != Variant::NIL) {
count = 7;
- else if (p_arg6.get_type() != Variant::NIL)
+ } else if (p_arg6.get_type() != Variant::NIL) {
count = 6;
- else if (p_arg5.get_type() != Variant::NIL)
+ } else if (p_arg5.get_type() != Variant::NIL) {
count = 5;
- else if (p_arg4.get_type() != Variant::NIL)
+ } else if (p_arg4.get_type() != Variant::NIL) {
count = 4;
- else if (p_arg3.get_type() != Variant::NIL)
+ } else if (p_arg3.get_type() != Variant::NIL) {
count = 3;
- else if (p_arg2.get_type() != Variant::NIL)
+ } else if (p_arg2.get_type() != Variant::NIL) {
count = 2;
- else if (p_arg1.get_type() != Variant::NIL)
+ } else if (p_arg1.get_type() != Variant::NIL) {
count = 1;
- else
+ } else {
count = 0;
+ }
// Add the specified arguments to the command
- if (count > 0)
+ if (count > 0) {
cmd.arg[0] = p_arg1;
- if (count > 1)
+ }
+ if (count > 1) {
cmd.arg[1] = p_arg2;
- if (count > 2)
+ }
+ if (count > 2) {
cmd.arg[2] = p_arg3;
- if (count > 3)
+ }
+ if (count > 3) {
cmd.arg[3] = p_arg4;
- if (count > 4)
+ }
+ if (count > 4) {
cmd.arg[4] = p_arg5;
- if (count > 5)
+ }
+ if (count > 5) {
cmd.arg[5] = p_arg6;
- if (count > 6)
+ }
+ if (count > 6) {
cmd.arg[6] = p_arg7;
- if (count > 7)
+ }
+ if (count > 7) {
cmd.arg[7] = p_arg8;
- if (count > 8)
+ }
+ if (count > 8) {
cmd.arg[8] = p_arg9;
- if (count > 9)
+ }
+ if (count > 9) {
cmd.arg[9] = p_arg10;
+ }
}
void Tween::_process_pending_commands() {
-
// For each pending command...
for (List<PendingCommand>::Element *E = pending_commands.front(); E; E = E->next()) {
-
// Get the command
PendingCommand &cmd = E->get();
Callable::CallError err;
@@ -121,7 +129,6 @@ void Tween::_process_pending_commands() {
}
bool Tween::_set(const StringName &p_name, const Variant &p_value) {
-
// Set the correct attribute based on the given name
String name = p_name;
if (name == "playback/speed" || name == "speed") { // Backwards compatibility
@@ -140,7 +147,6 @@ bool Tween::_set(const StringName &p_name, const Variant &p_value) {
}
bool Tween::_get(const StringName &p_name, Variant &r_ret) const {
-
// Get the correct attribute based on the given name
String name = p_name;
if (name == "playback/speed") { // Backwards compatibility
@@ -168,7 +174,6 @@ void Tween::_get_property_list(List<PropertyInfo> *p_list) const {
void Tween::_notification(int p_what) {
// What notification did we receive?
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
// Are we not already active?
if (!is_active()) {
@@ -185,26 +190,30 @@ void Tween::_notification(int p_what) {
case NOTIFICATION_INTERNAL_PROCESS: {
// Are we processing during physics time?
- if (tween_process_mode == TWEEN_PROCESS_PHYSICS)
+ if (tween_process_mode == TWEEN_PROCESS_PHYSICS) {
// Do nothing since we aren't aligned with physics when we should be
break;
+ }
// Should we update?
- if (is_active())
+ if (is_active()) {
// Update the tweens
_tween_process(get_process_delta_time());
+ }
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
// Are we processing during 'regular' time?
- if (tween_process_mode == TWEEN_PROCESS_IDLE)
+ if (tween_process_mode == TWEEN_PROCESS_IDLE) {
// Do nothing since we would only process during idle time
break;
+ }
// Should we update?
- if (is_active())
+ if (is_active()) {
// Update the tweens
_tween_process(get_physics_process_delta_time());
+ }
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -289,7 +298,6 @@ void Tween::_bind_methods() {
}
Variant Tween::_get_initial_val(const InterpolateData &p_data) const {
-
// What type of data are we interpolating?
switch (p_data.type) {
case INTER_PROPERTY:
@@ -353,8 +361,9 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const {
// If we're looking at an INT value, instead convert it to a FLOAT
// This is better for interpolation
- if (final_val.get_type() == Variant::INT)
+ if (final_val.get_type() == Variant::INT) {
final_val = final_val.operator real_t();
+ }
return final_val;
}
@@ -366,7 +375,6 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const {
}
Variant &Tween::_get_delta_val(InterpolateData &p_data) {
-
// What kind of data are we interpolating?
switch (p_data.type) {
case INTER_PROPERTY:
@@ -396,8 +404,9 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) {
// If we're looking at an INT value, instead convert it to a FLOAT
// This is better for interpolation
- if (final_val.get_type() == Variant::INT)
+ if (final_val.get_type() == Variant::INT) {
final_val = final_val.operator real_t();
+ }
// Calculate the delta based on the initial value and the final value
_calc_delta_val(p_data.initial_val, final_val, p_data.delta_val);
@@ -411,8 +420,9 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) {
// If we're looking at an INT value, instead convert it to a FLOAT
// This is better for interpolation
- if (initial_val.get_type() == Variant::INT)
+ if (initial_val.get_type() == Variant::INT) {
initial_val = initial_val.operator real_t();
+ }
// Calculate the delta based on the initial value and the final value
_calc_delta_val(initial_val, p_data.final_val, p_data.delta_val);
@@ -438,7 +448,6 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
// What type of data are we interpolating?
switch (initial_val.get_type()) {
-
case Variant::BOOL:
// Run the boolean specific equation (checking if it is at least 0.5)
result = (_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5;
@@ -613,14 +622,12 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
}
bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) {
-
// Get the object we want to apply the new value to
Object *object = ObjectDB::get_instance(p_data.id);
ERR_FAIL_COND_V(object == nullptr, false);
// What kind of data are we mutating?
switch (p_data.type) {
-
case INTER_PROPERTY:
case FOLLOW_PROPERTY:
case TARGETING_PROPERTY: {
@@ -663,8 +670,9 @@ void Tween::_tween_process(float p_delta) {
_process_pending_commands();
// If the scale is 0, make no progress on the tweens
- if (speed_scale == 0)
+ if (speed_scale == 0) {
return;
+ }
// Update the delta and whether we are pending an update
p_delta *= speed_scale;
@@ -687,8 +695,9 @@ void Tween::_tween_process(float p_delta) {
}
// If we are all finished, we can reset all of the tweens
- if (repeats_finished)
+ if (repeats_finished) {
reset_all();
+ }
}
// Are all of the tweens complete?
@@ -696,7 +705,6 @@ void Tween::_tween_process(float p_delta) {
// For each tween we wish to interpolate...
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
-
// Get the data from it
InterpolateData &data = E->get();
@@ -704,20 +712,22 @@ void Tween::_tween_process(float p_delta) {
all_finished = all_finished && data.finish;
// Is the data not active or already finished? No need to go any further
- if (!data.active || data.finish)
+ if (!data.active || data.finish) {
continue;
+ }
// Get the target object for this interpolation
Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr)
+ if (object == nullptr) {
continue;
+ }
// Are we still delaying this tween?
bool prev_delaying = data.elapsed <= data.delay;
data.elapsed += p_delta;
- if (data.elapsed < data.delay)
+ if (data.elapsed < data.delay) {
continue;
- else if (prev_delaying) {
+ } else if (prev_delaying) {
// We can apply the tween's value to the data and emit that the tween has started
_apply_tween_value(data, data.initial_val);
emit_signal("tween_started", object, NodePath(Vector<StringName>(), data.key, false));
@@ -790,8 +800,9 @@ void Tween::_tween_process(float p_delta) {
emit_signal("tween_completed", object, NodePath(Vector<StringName>(), data.key, false));
// If we are not repeating the tween, remove it
- if (!repeat)
+ if (!repeat) {
call_deferred("_remove_by_uid", data.uid);
+ }
} else if (!repeat) {
// Check whether all tweens are finished
all_finished = all_finished && data.finish;
@@ -821,8 +832,9 @@ bool Tween::is_active() const {
void Tween::set_active(bool p_active) {
// Do nothing if it's the same active mode that we currently are
- if (is_active() == p_active)
+ if (is_active() == p_active) {
return;
+ }
// Depending on physics or idle, set processing
switch (tween_process_mode) {
@@ -852,7 +864,6 @@ float Tween::get_speed_scale() const {
}
void Tween::start() {
-
ERR_FAIL_COND_MSG(!is_inside_tree(), "Tween was not added to the SceneTree!");
// Are there any pending updates?
@@ -873,8 +884,9 @@ void Tween::reset(Object *p_object, StringName p_key) {
// Get the target object
InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr)
+ if (object == nullptr) {
continue;
+ }
// Do we have the correct object and key?
if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
@@ -883,8 +895,9 @@ void Tween::reset(Object *p_object, StringName p_key) {
data.finish = false;
// Also apply the initial state if there isn't a delay
- if (data.delay == 0)
+ if (data.delay == 0) {
_apply_tween_value(data, data.initial_val);
+ }
}
}
pending_update--;
@@ -900,8 +913,9 @@ void Tween::reset_all() {
data.finish = false;
// If there isn't a delay, apply the value to the object
- if (data.delay == 0)
+ if (data.delay == 0) {
_apply_tween_value(data, data.initial_val);
+ }
}
pending_update--;
}
@@ -910,17 +924,18 @@ void Tween::stop(Object *p_object, StringName p_key) {
// Find the tween that has the given target object and string key
pending_update++;
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
-
// Get the object the tween is targeting
InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr)
+ if (object == nullptr) {
continue;
+ }
// Is this the correct object and does it have the given key?
- if (object == p_object && (data.concatenated_key == p_key || p_key == ""))
+ if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
// Disable the tween
data.active = false;
+ }
}
pending_update--;
}
@@ -950,12 +965,14 @@ void Tween::resume(Object *p_object, StringName p_key) {
// Grab the object
InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr)
+ if (object == nullptr) {
continue;
+ }
// If the object and string key match, activate it
- if (object == p_object && (data.concatenated_key == p_key || p_key == ""))
+ if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
data.active = true;
+ }
}
pending_update--;
}
@@ -988,8 +1005,9 @@ void Tween::remove(Object *p_object, StringName p_key) {
// Get the target object
InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if (object == nullptr)
+ if (object == nullptr) {
continue;
+ }
// If the target object and string key match, queue it for removal
if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
@@ -1090,9 +1108,10 @@ real_t Tween::tell() const {
for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
// Get the data and figure out if it's position is further along than the previous ones
const InterpolateData &data = E->get();
- if (data.elapsed > pos)
+ if (data.elapsed > pos) {
// Save it if so
pos = data.elapsed;
+ }
}
pending_update--;
return pos;
@@ -1112,9 +1131,10 @@ real_t Tween::get_runtime() const {
// Get the tween data and see if it's runtime is greater than the previous tweens
const InterpolateData &data = E->get();
real_t t = data.delay + data.duration;
- if (t > runtime)
+ if (t > runtime) {
// This is the longest running tween
runtime = t;
+ }
}
pending_update--;
@@ -1123,7 +1143,6 @@ real_t Tween::get_runtime() const {
}
bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val) {
-
// Get the initial, final, and delta values
const Variant &initial_val = p_initial_val;
const Variant &final_val = p_final_val;
@@ -1131,7 +1150,6 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
// What kind of data are we interpolating?
switch (initial_val.get_type()) {
-
case Variant::BOOL:
// We'll treat booleans just like integers
case Variant::INT:
@@ -1263,7 +1281,6 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
}
void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p_object, NodePath *p_property, StringName *p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
-
// TODO: Add initialization+implementation for remaining interpolation types
// TODO: Fix this method's organization to take advantage of the type
@@ -1322,8 +1339,9 @@ void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p
}
// Is there not a valid delta?
- if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
+ if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) {
return;
+ }
// Add this interpolation to the total
_push_interpolate_data(data);
@@ -1341,14 +1359,17 @@ void Tween::interpolate_property(Object *p_object, NodePath p_property, Variant
// If no initial value given, grab the initial value from the object
// TODO: Is this documented? This is very useful and removes a lot of clutter from tweens!
- if (p_initial_val.get_type() == Variant::NIL)
+ if (p_initial_val.get_type() == Variant::NIL) {
p_initial_val = p_object->get_indexed(p_property.get_subnames());
+ }
// Convert any integers into REALs as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT)
+ if (p_initial_val.get_type() == Variant::INT) {
p_initial_val = p_initial_val.operator real_t();
- if (p_final_val.get_type() == Variant::INT)
+ }
+ if (p_final_val.get_type() == Variant::INT) {
p_final_val = p_final_val.operator real_t();
+ }
// Build the interpolation data
_build_interpolation(INTER_PROPERTY, p_object, &p_property, nullptr, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
@@ -1362,10 +1383,12 @@ void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_
}
// Convert any integers into REALs as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT)
+ if (p_initial_val.get_type() == Variant::INT) {
p_initial_val = p_initial_val.operator real_t();
- if (p_final_val.get_type() == Variant::INT)
+ }
+ if (p_final_val.get_type() == Variant::INT) {
p_final_val = p_final_val.operator real_t();
+ }
// Build the interpolation data
_build_interpolation(INTER_METHOD, p_object, nullptr, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
@@ -1404,18 +1427,19 @@ void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_c
// Add arguments to the interpolation
int args = 0;
- if (p_arg5.get_type() != Variant::NIL)
+ if (p_arg5.get_type() != Variant::NIL) {
args = 5;
- else if (p_arg4.get_type() != Variant::NIL)
+ } else if (p_arg4.get_type() != Variant::NIL) {
args = 4;
- else if (p_arg3.get_type() != Variant::NIL)
+ } else if (p_arg3.get_type() != Variant::NIL) {
args = 3;
- else if (p_arg2.get_type() != Variant::NIL)
+ } else if (p_arg2.get_type() != Variant::NIL) {
args = 2;
- else if (p_arg1.get_type() != Variant::NIL)
+ } else if (p_arg1.get_type() != Variant::NIL) {
args = 1;
- else
+ } else {
args = 0;
+ }
data.args = args;
data.arg[0] = p_arg1;
@@ -1461,18 +1485,19 @@ void Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S
// Collect arguments for the callback
int args = 0;
- if (p_arg5.get_type() != Variant::NIL)
+ if (p_arg5.get_type() != Variant::NIL) {
args = 5;
- else if (p_arg4.get_type() != Variant::NIL)
+ } else if (p_arg4.get_type() != Variant::NIL) {
args = 4;
- else if (p_arg3.get_type() != Variant::NIL)
+ } else if (p_arg3.get_type() != Variant::NIL) {
args = 3;
- else if (p_arg2.get_type() != Variant::NIL)
+ } else if (p_arg2.get_type() != Variant::NIL) {
args = 2;
- else if (p_arg1.get_type() != Variant::NIL)
+ } else if (p_arg1.get_type() != Variant::NIL) {
args = 1;
- else
+ } else {
args = 0;
+ }
data.args = args;
data.arg[0] = p_arg1;
@@ -1498,12 +1523,14 @@ void Tween::follow_property(Object *p_object, NodePath p_property, Variant p_ini
// If no initial value is given, grab it from the source object
// TODO: Is this documented? It's really helpful for decluttering tweens
- if (p_initial_val.get_type() == Variant::NIL)
+ if (p_initial_val.get_type() == Variant::NIL) {
p_initial_val = p_object->get_indexed(p_property.get_subnames());
+ }
// Convert initial INT values to FLOAT as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT)
+ if (p_initial_val.get_type() == Variant::INT) {
p_initial_val = p_initial_val.operator real_t();
+ }
// Confirm the source and target objects are valid
ERR_FAIL_COND(p_object == nullptr);
@@ -1529,8 +1556,9 @@ void Tween::follow_property(Object *p_object, NodePath p_property, Variant p_ini
ERR_FAIL_COND(!target_prop_valid);
// Convert target INT to FLOAT since it is better for interpolation
- if (target_val.get_type() == Variant::INT)
+ if (target_val.get_type() == Variant::INT) {
target_val = target_val.operator real_t();
+ }
// Verify that the target value and initial value are the same type
ERR_FAIL_COND(target_val.get_type() != p_initial_val.get_type());
@@ -1565,8 +1593,9 @@ void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi
return;
}
// Convert initial INT values to FLOAT as they are better for interpolation
- if (p_initial_val.get_type() == Variant::INT)
+ if (p_initial_val.get_type() == Variant::INT) {
p_initial_val = p_initial_val.operator real_t();
+ }
// Verify the source and target objects are valid
ERR_FAIL_COND(p_object == nullptr);
@@ -1592,8 +1621,9 @@ void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi
ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK);
// Convert target INT values to FLOAT as they are better for interpolation
- if (target_val.get_type() == Variant::INT)
+ if (target_val.get_type() == Variant::INT) {
target_val = target_val.operator real_t();
+ }
ERR_FAIL_COND(target_val.get_type() != p_initial_val.get_type());
// Make the new InterpolateData for the method follow
@@ -1630,8 +1660,9 @@ void Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_
p_initial_property = p_initial_property.get_as_property_path();
// Convert the initial INT values to FLOAT as they are better for Interpolation
- if (p_final_val.get_type() == Variant::INT)
+ if (p_final_val.get_type() == Variant::INT) {
p_final_val = p_final_val.operator real_t();
+ }
// Verify both objects are valid
ERR_FAIL_COND(p_object == nullptr);
@@ -1657,8 +1688,9 @@ void Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_
ERR_FAIL_COND(!initial_prop_valid);
// Convert the initial INT value to FLOAT as it is better for interpolation
- if (initial_val.get_type() == Variant::INT)
+ if (initial_val.get_type() == Variant::INT) {
initial_val = initial_val.operator real_t();
+ }
ERR_FAIL_COND(initial_val.get_type() != p_final_val.get_type());
// Build the InterpolateData object
@@ -1698,8 +1730,9 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in
}
// Convert final INT values to FLOAT as they are better for interpolation
- if (p_final_val.get_type() == Variant::INT)
+ if (p_final_val.get_type() == Variant::INT) {
p_final_val = p_final_val.operator real_t();
+ }
// Make sure the given objects are valid
ERR_FAIL_COND(p_object == nullptr);
@@ -1725,8 +1758,9 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in
ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK);
// Convert initial INT values to FLOAT as they aer better for interpolation
- if (initial_val.get_type() == Variant::INT)
+ if (initial_val.get_type() == Variant::INT) {
initial_val = initial_val.operator real_t();
+ }
ERR_FAIL_COND(initial_val.get_type() != p_final_val.get_type());
// Build the new InterpolateData object
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index f74df50f68..668870c526 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -34,7 +34,6 @@
#include "scene/main/node.h"
class Tween : public Node {
-
GDCLASS(Tween, Node);
public:
diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp
index f612944a62..48f70e88cb 100644
--- a/scene/audio/audio_stream_player.cpp
+++ b/scene/audio/audio_stream_player.cpp
@@ -33,7 +33,6 @@
#include "core/engine.h"
void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) {
-
int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);
AudioFrame *targets[4] = { nullptr, nullptr, nullptr, nullptr };
@@ -57,8 +56,9 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) {
}
for (int c = 0; c < 4; c++) {
- if (!targets[c])
+ if (!targets[c]) {
break;
+ }
for (int i = 0; i < p_amount; i++) {
targets[c][i] += p_frames[i];
}
@@ -66,7 +66,6 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) {
}
void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
-
//get data
AudioFrame *buffer = mix_buffer.ptrw();
int buffer_size = mix_buffer.size();
@@ -95,7 +94,6 @@ void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
}
void AudioStreamPlayer::_mix_audio() {
-
if (use_fadeout) {
_mix_to_bus(fadeout_buffer.ptr(), fadeout_buffer.size());
use_fadeout = false;
@@ -122,7 +120,6 @@ void AudioStreamPlayer::_mix_audio() {
if (setseek >= 0.0 && !stop_has_priority) {
if (stream_playback->is_playing()) {
-
//fade out to avoid pops
_mix_internal(true);
}
@@ -138,9 +135,7 @@ void AudioStreamPlayer::_mix_audio() {
}
void AudioStreamPlayer::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
-
AudioServer::get_singleton()->add_callback(_mix_audios, this);
if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
play();
@@ -148,7 +143,6 @@ void AudioStreamPlayer::_notification(int p_what) {
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
-
if (!active || (setseek < 0 && !stream_playback->is_playing())) {
active = false;
set_process_internal(false);
@@ -157,7 +151,6 @@ void AudioStreamPlayer::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
AudioServer::get_singleton()->remove_callback(_mix_audios, this);
}
@@ -174,7 +167,6 @@ void AudioStreamPlayer::_notification(int p_what) {
}
void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
-
AudioServer::get_singleton()->lock();
if (active && stream_playback.is_valid() && !stream_paused) {
@@ -222,16 +214,14 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
}
Ref<AudioStream> AudioStreamPlayer::get_stream() const {
-
return stream;
}
void AudioStreamPlayer::set_volume_db(float p_volume) {
-
volume_db = p_volume;
}
-float AudioStreamPlayer::get_volume_db() const {
+float AudioStreamPlayer::get_volume_db() const {
return volume_db;
}
@@ -239,12 +229,12 @@ void AudioStreamPlayer::set_pitch_scale(float p_pitch_scale) {
ERR_FAIL_COND(p_pitch_scale <= 0.0);
pitch_scale = p_pitch_scale;
}
+
float AudioStreamPlayer::get_pitch_scale() const {
return pitch_scale;
}
void AudioStreamPlayer::play(float p_from_pos) {
-
if (stream_playback.is_valid()) {
//mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks
setseek = p_from_pos;
@@ -255,14 +245,12 @@ void AudioStreamPlayer::play(float p_from_pos) {
}
void AudioStreamPlayer::seek(float p_seconds) {
-
if (stream_playback.is_valid()) {
setseek = p_seconds;
}
}
void AudioStreamPlayer::stop() {
-
if (stream_playback.is_valid() && active) {
setstop = true;
stop_has_priority = true;
@@ -270,7 +258,6 @@ void AudioStreamPlayer::stop() {
}
bool AudioStreamPlayer::is_playing() const {
-
if (stream_playback.is_valid()) {
return active && !setstop; //&& stream_playback->is_playing();
}
@@ -279,7 +266,6 @@ bool AudioStreamPlayer::is_playing() const {
}
float AudioStreamPlayer::get_playback_position() {
-
if (stream_playback.is_valid()) {
return stream_playback->get_playback_position();
}
@@ -288,14 +274,13 @@ float AudioStreamPlayer::get_playback_position() {
}
void AudioStreamPlayer::set_bus(const StringName &p_bus) {
-
//if audio is active, must lock this
AudioServer::get_singleton()->lock();
bus = p_bus;
AudioServer::get_singleton()->unlock();
}
-StringName AudioStreamPlayer::get_bus() const {
+StringName AudioStreamPlayer::get_bus() const {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == bus) {
return bus;
@@ -305,38 +290,34 @@ StringName AudioStreamPlayer::get_bus() const {
}
void AudioStreamPlayer::set_autoplay(bool p_enable) {
-
autoplay = p_enable;
}
-bool AudioStreamPlayer::is_autoplay_enabled() {
+bool AudioStreamPlayer::is_autoplay_enabled() {
return autoplay;
}
void AudioStreamPlayer::set_mix_target(MixTarget p_target) {
-
mix_target = p_target;
}
AudioStreamPlayer::MixTarget AudioStreamPlayer::get_mix_target() const {
-
return mix_target;
}
void AudioStreamPlayer::_set_playing(bool p_enable) {
-
- if (p_enable)
+ if (p_enable) {
play();
- else
+ } else {
stop();
+ }
}
-bool AudioStreamPlayer::_is_active() const {
+bool AudioStreamPlayer::_is_active() const {
return active;
}
void AudioStreamPlayer::set_stream_paused(bool p_pause) {
-
if (p_pause != stream_paused) {
stream_paused = p_pause;
stream_paused_fade = p_pause;
@@ -344,18 +325,16 @@ void AudioStreamPlayer::set_stream_paused(bool p_pause) {
}
bool AudioStreamPlayer::get_stream_paused() const {
-
return stream_paused;
}
void AudioStreamPlayer::_validate_property(PropertyInfo &property) const {
-
if (property.name == "bus") {
-
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -365,7 +344,6 @@ void AudioStreamPlayer::_validate_property(PropertyInfo &property) const {
}
void AudioStreamPlayer::_bus_layout_changed() {
-
_change_notify();
}
@@ -374,7 +352,6 @@ Ref<AudioStreamPlayback> AudioStreamPlayer::get_stream_playback() {
}
void AudioStreamPlayer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_stream", "stream"), &AudioStreamPlayer::set_stream);
ClassDB::bind_method(D_METHOD("get_stream"), &AudioStreamPlayer::get_stream);
@@ -425,7 +402,6 @@ void AudioStreamPlayer::_bind_methods() {
}
AudioStreamPlayer::AudioStreamPlayer() {
-
mix_volume_db = 0;
pitch_scale = 1.0;
volume_db = 0;
diff --git a/scene/audio/audio_stream_player.h b/scene/audio/audio_stream_player.h
index 0f6d855d0e..6769f1bb48 100644
--- a/scene/audio/audio_stream_player.h
+++ b/scene/audio/audio_stream_player.h
@@ -35,7 +35,6 @@
#include "servers/audio/audio_stream.h"
class AudioStreamPlayer : public Node {
-
GDCLASS(AudioStreamPlayer, Node);
public:
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 8cb63c4ab5..f57c8e58db 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -48,8 +48,9 @@ void SceneDebugger::deinitialize() {
#ifdef DEBUG_ENABLED
if (LiveEditor::singleton) {
// Should be removed automatically when deiniting debugger, but just in case
- if (EngineDebugger::has_capture("scene"))
+ if (EngineDebugger::has_capture("scene")) {
EngineDebugger::unregister_message_capture("scene");
+ }
memdelete(LiveEditor::singleton);
LiveEditor::singleton = nullptr;
}
@@ -59,11 +60,13 @@ void SceneDebugger::deinitialize() {
#ifdef DEBUG_ENABLED
Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return ERR_UNCONFIGURED;
+ }
LiveEditor *live_editor = LiveEditor::get_singleton();
- if (!live_editor)
+ if (!live_editor) {
return ERR_UNCONFIGURED;
+ }
r_captured = true;
if (p_msg == "request_scene_tree") { // Scene tree
@@ -193,8 +196,9 @@ void SceneDebugger::_save_node(ObjectID id, const String &p_path) {
void SceneDebugger::_send_object_id(ObjectID p_id, int p_max_size) {
SceneDebuggerObject obj(p_id);
- if (obj.id.is_null())
+ if (obj.id.is_null()) {
return;
+ }
Array arr;
obj.serialize(arr);
@@ -202,10 +206,10 @@ void SceneDebugger::_send_object_id(ObjectID p_id, int p_max_size) {
}
void SceneDebugger::_set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value) {
-
Object *obj = ObjectDB::get_instance(p_id);
- if (!obj)
+ if (!obj) {
return;
+ }
String prop_name = p_property;
if (p_property.begins_with("Members/")) {
@@ -218,17 +222,20 @@ void SceneDebugger::_set_object_property(ObjectID p_id, const String &p_property
void SceneDebugger::add_to_cache(const String &p_filename, Node *p_node) {
LiveEditor *debugger = LiveEditor::get_singleton();
- if (!debugger)
+ if (!debugger) {
return;
+ }
if (EngineDebugger::get_script_debugger() && p_filename != String()) {
debugger->live_scene_edit_cache[p_filename].insert(p_node);
}
}
+
void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
LiveEditor *debugger = LiveEditor::get_singleton();
- if (!debugger)
+ if (!debugger) {
return;
+ }
Map<String, Set<Node *>> &edit_cache = debugger->live_scene_edit_cache;
Map<String, Set<Node *>>::Element *E = edit_cache.find(p_filename);
@@ -243,7 +250,6 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
Map<Node *, Map<ObjectID, Node *>>::Element *F = remove_list.find(p_node);
if (F) {
for (Map<ObjectID, Node *>::Element *G = F->get().front(); G; G = G->next()) {
-
memdelete(G->get());
}
remove_list.erase(F);
@@ -254,8 +260,9 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) {
id = ObjectID();
Object *obj = ObjectDB::get_instance(p_id);
- if (!obj)
+ if (!obj) {
return;
+ }
id = p_id;
class_name = obj->get_class();
@@ -354,15 +361,6 @@ void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) {
RES res = var;
- if (var.get_type() == Variant::OBJECT && var.is_ref()) {
- REF r = var;
- if (r.is_valid()) {
- res = *r;
- } else {
- res = RES();
- }
- }
-
Array prop;
prop.push_back(pi.name);
prop.push_back(pi.type);
@@ -403,7 +401,6 @@ void SceneDebuggerObject::deserialize(const Array &p_arr) {
Array props = p_arr[2];
for (int i = 0; i < props.size(); i++) {
-
CHECK_TYPE(props[i], ARRAY);
Array prop = props[i];
@@ -485,8 +482,9 @@ LiveEditor *LiveEditor::get_singleton() {
void LiveEditor::_send_tree() {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Array arr;
// Encoded as a flat list depth fist.
@@ -496,42 +494,44 @@ void LiveEditor::_send_tree() {
}
void LiveEditor::_node_path_func(const NodePath &p_path, int p_id) {
-
live_edit_node_path_cache[p_id] = p_path;
}
void LiveEditor::_res_path_func(const String &p_path, int p_id) {
-
live_edit_resource_cache[p_id] = p_path;
}
void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
-
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
- if (!live_edit_node_path_cache.has(p_id))
+ if (!live_edit_node_path_cache.has(p_id)) {
return;
+ }
NodePath np = live_edit_node_path_cache[p_id];
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(np))
+ if (!n->has_node(np)) {
continue;
+ }
Node *n2 = n->get_node(np);
n2->set(p_prop, p_value);
@@ -539,110 +539,126 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian
}
void LiveEditor::_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
-
RES r = ResourceLoader::load(p_value);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
_node_set_func(p_id, p_prop, r);
}
+
void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
- if (!live_edit_node_path_cache.has(p_id))
+ }
+ if (!live_edit_node_path_cache.has(p_id)) {
return;
+ }
NodePath np = live_edit_node_path_cache[p_id];
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(np))
+ if (!n->has_node(np)) {
continue;
+ }
Node *n2 = n->get_node(np);
n2->call(p_method, VARIANT_ARG_PASS);
}
}
-void LiveEditor::_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
- if (!live_edit_resource_cache.has(p_id))
+void LiveEditor::_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
+ if (!live_edit_resource_cache.has(p_id)) {
return;
+ }
String resp = live_edit_resource_cache[p_id];
- if (!ResourceCache::has(resp))
+ if (!ResourceCache::has(resp)) {
return;
+ }
RES r = ResourceCache::get(resp);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
r->set(p_prop, p_value);
}
-void LiveEditor::_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
+void LiveEditor::_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
RES r = ResourceLoader::load(p_value);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
_res_set_func(p_id, p_prop, r);
}
-void LiveEditor::_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
- if (!live_edit_resource_cache.has(p_id))
+void LiveEditor::_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
+ if (!live_edit_resource_cache.has(p_id)) {
return;
+ }
String resp = live_edit_resource_cache[p_id];
- if (!ResourceCache::has(resp))
+ if (!ResourceCache::has(resp)) {
return;
+ }
RES r = ResourceCache::get(resp);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
r->call(p_method, VARIANT_ARG_PASS);
}
void LiveEditor::_root_func(const NodePath &p_scene_path, const String &p_scene_from) {
-
live_edit_root = p_scene_path;
live_edit_scene = p_scene_from;
}
void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_parent))
+ if (!n->has_node(p_parent)) {
continue;
+ }
Node *n2 = n->get_node(p_parent);
Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
@@ -654,33 +670,39 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ
n2->add_child(no);
}
}
+
void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Ref<PackedScene> ps = ResourceLoader::load(p_path);
- if (!ps.is_valid())
+ if (!ps.is_valid()) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_parent))
+ if (!n->has_node(p_parent)) {
continue;
+ }
Node *n2 = n->get_node(p_parent);
Node *no = ps->instance();
@@ -692,30 +714,35 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p
n2->add_child(no);
}
}
+
void LiveEditor::_remove_node_func(const NodePath &p_at) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F;) {
-
Set<Node *>::Element *N = F->next();
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
memdelete(n2);
@@ -723,30 +750,35 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) {
F = N;
}
}
+
void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_keep_id) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F;) {
-
Set<Node *>::Element *N = F->next();
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
@@ -757,41 +789,48 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee
F = N;
}
}
+
void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F;) {
-
Set<Node *>::Element *N = F->next();
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
Map<Node *, Map<ObjectID, Node *>>::Element *EN = live_edit_remove_list.find(n);
- if (!EN)
+ if (!EN) {
continue;
+ }
Map<ObjectID, Node *>::Element *FN = EN->get().find(p_id);
- if (!FN)
+ if (!FN) {
continue;
+ }
n2->add_child(FN->get());
EN->get().erase(FN);
@@ -803,73 +842,86 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a
F = N;
}
}
+
void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_name) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
Node *dup = n2->duplicate(Node::DUPLICATE_SIGNALS | Node::DUPLICATE_GROUPS | Node::DUPLICATE_SCRIPTS);
- if (!dup)
+ if (!dup) {
continue;
+ }
dup->set_name(p_new_name);
n2->get_parent()->add_child(dup);
}
}
+
void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *nfrom = n->get_node(p_at);
- if (!n->has_node(p_new_place))
+ if (!n->has_node(p_new_place)) {
continue;
+ }
Node *nto = n->get_node(p_new_place);
nfrom->get_parent()->remove_child(nfrom);
nfrom->set_name(p_new_name);
nto->add_child(nfrom);
- if (p_at_pos >= 0)
+ if (p_at_pos >= 0) {
nto->move_child(nfrom, p_at_pos);
+ }
}
}
diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h
index e295510960..a2bafde039 100644
--- a/scene/debugger/scene_debugger.h
+++ b/scene/debugger/scene_debugger.h
@@ -39,7 +39,6 @@
class Script;
class SceneDebugger {
-
public:
static void initialize();
static void deinitialize();
@@ -59,7 +58,6 @@ public:
#ifdef DEBUG_ENABLED
class SceneDebuggerObject {
-
private:
void _parse_script_properties(Script *p_script, ScriptInstance *p_instance);
@@ -77,7 +75,6 @@ public:
};
class SceneDebuggerTree {
-
public:
struct RemoteNode {
int child_count;
@@ -100,11 +97,10 @@ public:
void serialize(Array &r_arr);
void deserialize(const Array &p_arr);
SceneDebuggerTree(Node *p_root);
- SceneDebuggerTree(){};
+ SceneDebuggerTree() {}
};
class LiveEditor {
-
private:
friend class SceneDebugger;
Map<int, NodePath> live_edit_node_path_cache;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 1cdc6f8057..d8229b5f43 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -35,26 +35,27 @@
#include "scene/scene_string_names.h"
void BaseButton::_unpress_group() {
-
- if (!button_group.is_valid())
+ if (!button_group.is_valid()) {
return;
+ }
if (toggle_mode) {
status.pressed = true;
}
for (Set<BaseButton *>::Element *E = button_group->buttons.front(); E; E = E->next()) {
- if (E->get() == this)
+ if (E->get() == this) {
continue;
+ }
E->get()->set_pressed(false);
}
}
void BaseButton::_gui_input(Ref<InputEvent> p_event) {
-
- if (status.disabled) // no interaction with disabled button
+ if (status.disabled) { // no interaction with disabled button
return;
+ }
Ref<InputEventMouseButton> mouse_button = p_event;
bool ui_accept = p_event->is_action("ui_accept") && !p_event->is_echo();
@@ -78,9 +79,7 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
}
void BaseButton::_notification(int p_what) {
-
if (p_what == NOTIFICATION_MOUSE_ENTER) {
-
status.hovering = true;
update();
}
@@ -90,7 +89,6 @@ void BaseButton::_notification(int p_what) {
update();
}
if (p_what == NOTIFICATION_DRAG_BEGIN || p_what == NOTIFICATION_SCROLL_BEGIN) {
-
if (status.press_attempt) {
status.press_attempt = false;
update();
@@ -98,13 +96,11 @@ void BaseButton::_notification(int p_what) {
}
if (p_what == NOTIFICATION_FOCUS_ENTER) {
-
status.hovering = true;
update();
}
if (p_what == NOTIFICATION_FOCUS_EXIT) {
-
if (status.press_attempt) {
status.press_attempt = false;
status.hovering = false;
@@ -116,7 +112,6 @@ void BaseButton::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE || (p_what == NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree())) {
-
if (!toggle_mode) {
status.pressed = false;
}
@@ -127,7 +122,6 @@ void BaseButton::_notification(int p_what) {
}
void BaseButton::_pressed() {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed);
}
@@ -136,7 +130,6 @@ void BaseButton::_pressed() {
}
void BaseButton::_toggled(bool p_pressed) {
-
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, p_pressed);
}
@@ -145,7 +138,6 @@ void BaseButton::_toggled(bool p_pressed) {
}
void BaseButton::on_action_event(Ref<InputEvent> p_event) {
-
if (p_event->is_pressed()) {
status.press_attempt = true;
status.pressing_inside = true;
@@ -194,8 +186,9 @@ void BaseButton::toggled(bool p_pressed) {
}
void BaseButton::set_disabled(bool p_disabled) {
- if (status.disabled == p_disabled)
+ if (status.disabled == p_disabled) {
return;
+ }
status.disabled = p_disabled;
if (p_disabled) {
@@ -210,16 +203,16 @@ void BaseButton::set_disabled(bool p_disabled) {
}
bool BaseButton::is_disabled() const {
-
return status.disabled;
}
void BaseButton::set_pressed(bool p_pressed) {
-
- if (!toggle_mode)
+ if (!toggle_mode) {
return;
- if (status.pressed == p_pressed)
+ }
+ if (status.pressed == p_pressed) {
return;
+ }
_change_notify("pressed");
status.pressed = p_pressed;
@@ -232,29 +225,26 @@ void BaseButton::set_pressed(bool p_pressed) {
}
bool BaseButton::is_pressing() const {
-
return status.press_attempt;
}
bool BaseButton::is_pressed() const {
-
return toggle_mode ? status.pressed : status.press_attempt;
}
bool BaseButton::is_hovered() const {
-
return status.hovering;
}
BaseButton::DrawMode BaseButton::get_draw_mode() const {
-
if (status.disabled) {
return DRAW_DISABLED;
};
if (!status.press_attempt && status.hovering) {
- if (status.pressed)
+ if (status.pressed) {
return DRAW_HOVER_PRESSED;
+ }
return DRAW_HOVER;
} else {
@@ -262,66 +252,57 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
bool pressing;
if (status.press_attempt) {
-
pressing = (status.pressing_inside || keep_pressed_outside);
- if (status.pressed)
+ if (status.pressed) {
pressing = !pressing;
+ }
} else {
-
pressing = status.pressed;
}
- if (pressing)
+ if (pressing) {
return DRAW_PRESSED;
- else
+ } else {
return DRAW_NORMAL;
+ }
}
return DRAW_NORMAL;
}
void BaseButton::set_toggle_mode(bool p_on) {
-
toggle_mode = p_on;
}
bool BaseButton::is_toggle_mode() const {
-
return toggle_mode;
}
void BaseButton::set_shortcut_in_tooltip(bool p_on) {
-
shortcut_in_tooltip = p_on;
}
bool BaseButton::is_shortcut_in_tooltip_enabled() const {
-
return shortcut_in_tooltip;
}
void BaseButton::set_action_mode(ActionMode p_mode) {
-
action_mode = p_mode;
}
BaseButton::ActionMode BaseButton::get_action_mode() const {
-
return action_mode;
}
void BaseButton::set_button_mask(int p_mask) {
-
button_mask = p_mask;
}
int BaseButton::get_button_mask() const {
-
return button_mask;
}
void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
-
enabled_focus_mode = p_mode;
if (!status.disabled) {
set_focus_mode(p_mode);
@@ -329,22 +310,18 @@ void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
}
Control::FocusMode BaseButton::get_enabled_focus_mode() const {
-
return enabled_focus_mode;
}
void BaseButton::set_keep_pressed_outside(bool p_on) {
-
keep_pressed_outside = p_on;
}
bool BaseButton::is_keep_pressed_outside() const {
-
return keep_pressed_outside;
}
void BaseButton::set_shortcut(const Ref<ShortCut> &p_shortcut) {
-
shortcut = p_shortcut;
set_process_unhandled_input(shortcut.is_valid());
}
@@ -354,15 +331,12 @@ Ref<ShortCut> BaseButton::get_shortcut() const {
}
void BaseButton::_unhandled_input(Ref<InputEvent> p_event) {
-
if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
-
on_action_event(p_event);
}
}
String BaseButton::get_tooltip(const Point2 &p_pos) const {
-
String tooltip = Control::get_tooltip(p_pos);
if (shortcut_in_tooltip && shortcut.is_valid() && shortcut->is_valid()) {
String text = shortcut->get_name() + " (" + shortcut->get_as_text() + ")";
@@ -375,7 +349,6 @@ String BaseButton::get_tooltip(const Point2 &p_pos) const {
}
void BaseButton::set_button_group(const Ref<ButtonGroup> &p_group) {
-
if (button_group.is_valid()) {
button_group->buttons.erase(this);
}
@@ -390,12 +363,10 @@ void BaseButton::set_button_group(const Ref<ButtonGroup> &p_group) {
}
Ref<ButtonGroup> BaseButton::get_button_group() const {
-
return button_group;
}
void BaseButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &BaseButton::_gui_input);
ClassDB::bind_method(D_METHOD("_unhandled_input"), &BaseButton::_unhandled_input);
ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &BaseButton::set_pressed);
@@ -452,7 +423,6 @@ void BaseButton::_bind_methods() {
}
BaseButton::BaseButton() {
-
toggle_mode = false;
shortcut_in_tooltip = true;
keep_pressed_outside = false;
@@ -468,21 +438,18 @@ BaseButton::BaseButton() {
}
BaseButton::~BaseButton() {
-
if (button_group.is_valid()) {
button_group->buttons.erase(this);
}
}
void ButtonGroup::get_buttons(List<BaseButton *> *r_buttons) {
-
for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
r_buttons->push_back(E->get());
}
}
Array ButtonGroup::_get_buttons() {
-
Array btns;
for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
btns.push_back(E->get());
@@ -492,22 +459,20 @@ Array ButtonGroup::_get_buttons() {
}
BaseButton *ButtonGroup::get_pressed_button() {
-
for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
- if (E->get()->is_pressed())
+ if (E->get()->is_pressed()) {
return E->get();
+ }
}
return nullptr;
}
void ButtonGroup::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button);
ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons);
}
ButtonGroup::ButtonGroup() {
-
set_local_to_scene(true);
}
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 21757488a6..05a975e266 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -36,7 +36,6 @@
class ButtonGroup;
class BaseButton : public Control {
-
GDCLASS(BaseButton, Control);
public:
@@ -55,7 +54,6 @@ private:
ActionMode action_mode;
struct Status {
-
bool pressed;
bool hovering;
bool press_attempt;
@@ -136,7 +134,6 @@ VARIANT_ENUM_CAST(BaseButton::DrawMode)
VARIANT_ENUM_CAST(BaseButton::ActionMode)
class ButtonGroup : public Resource {
-
GDCLASS(ButtonGroup, Resource);
friend class BaseButton;
Set<BaseButton *> buttons;
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index 0da6e0fdfa..75d04dba61 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -33,14 +33,12 @@
#include "margin_container.h"
struct _MinSizeCache {
-
int min_size;
bool will_stretch;
int final_size;
};
void BoxContainer::_resort() {
-
/** First pass, determine minimum size AND amount of stretchable elements */
Size2i new_size = get_size();
@@ -56,10 +54,12 @@ void BoxContainer::_resort() {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2i size = c->get_combined_minimum_size();
_MinSizeCache msc;
@@ -84,8 +84,9 @@ void BoxContainer::_resort() {
children_count++;
}
- if (children_count == 0)
+ if (children_count == 0) {
return;
+ }
int stretch_max = (vertical ? new_size.height : new_size.width) - (children_count - 1) * sep;
int stretch_diff = stretch_max - stretch_min;
@@ -105,12 +106,13 @@ void BoxContainer::_resort() {
bool refit_successful = true; //assume refit-test will go well
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
ERR_FAIL_COND(!min_size_cache.has(c));
_MinSizeCache &msc = min_size_cache[c];
@@ -134,8 +136,9 @@ void BoxContainer::_resort() {
}
}
- if (refit_successful) //uf refit went well, break
+ if (refit_successful) { //uf refit went well, break
break;
+ }
}
/** Final pass, draw and stretch elements **/
@@ -158,19 +161,21 @@ void BoxContainer::_resort() {
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
_MinSizeCache &msc = min_size_cache[c];
- if (first)
+ if (first) {
first = false;
- else
+ } else {
ofs += sep;
+ }
int from = ofs;
int to = ofs + msc.final_size;
@@ -187,10 +192,8 @@ void BoxContainer::_resort() {
Rect2 rect;
if (vertical) {
-
rect = Rect2(0, from, new_size.width, size);
} else {
-
rect = Rect2(from, 0, size, new_size.height);
}
@@ -202,7 +205,6 @@ void BoxContainer::_resort() {
}
Size2 BoxContainer::get_minimum_size() const {
-
/* Calculate MINIMUM SIZE */
Size2i minimum;
@@ -212,10 +214,12 @@ Size2 BoxContainer::get_minimum_size() const {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
if (!c->is_visible()) {
continue;
@@ -247,15 +251,11 @@ Size2 BoxContainer::get_minimum_size() const {
}
void BoxContainer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_SORT_CHILDREN: {
-
_resort();
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
} break;
}
@@ -271,28 +271,27 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const {
}
void BoxContainer::add_spacer(bool p_begin) {
-
Control *c = memnew(Control);
c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events
- if (vertical)
+ if (vertical) {
c->set_v_size_flags(SIZE_EXPAND_FILL);
- else
+ } else {
c->set_h_size_flags(SIZE_EXPAND_FILL);
+ }
add_child(c);
- if (p_begin)
+ if (p_begin) {
move_child(c, 0);
+ }
}
BoxContainer::BoxContainer(bool p_vertical) {
-
vertical = p_vertical;
align = ALIGN_BEGIN;
}
void BoxContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_spacer", "begin"), &BoxContainer::add_spacer);
ClassDB::bind_method(D_METHOD("get_alignment"), &BoxContainer::get_alignment);
ClassDB::bind_method(D_METHOD("set_alignment", "alignment"), &BoxContainer::set_alignment);
@@ -305,7 +304,6 @@ void BoxContainer::_bind_methods() {
}
MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) {
-
Label *l = memnew(Label);
l->set_text(p_label);
add_child(l);
@@ -313,8 +311,9 @@ MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control
mc->add_theme_constant_override("margin_left", 0);
mc->add_child(p_control);
add_child(mc);
- if (p_expand)
+ if (p_expand) {
mc->set_v_size_flags(SIZE_EXPAND_FILL);
+ }
return mc;
}
diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h
index 0d7deda364..cc6f6349df 100644
--- a/scene/gui/box_container.h
+++ b/scene/gui/box_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class BoxContainer : public Container {
-
GDCLASS(BoxContainer, Container);
public:
@@ -67,7 +66,6 @@ public:
};
class HBoxContainer : public BoxContainer {
-
GDCLASS(HBoxContainer, BoxContainer);
public:
@@ -77,7 +75,6 @@ public:
class MarginContainer;
class VBoxContainer : public BoxContainer {
-
GDCLASS(VBoxContainer, BoxContainer);
public:
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 1f8487c173..e400801b66 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -34,24 +34,25 @@
#include "servers/rendering_server.h"
Size2 Button::get_minimum_size() const {
-
Size2 minsize = get_theme_font("font")->get_string_size(xl_text);
- if (clip_text)
+ if (clip_text) {
minsize.width = 0;
+ }
if (!expand_icon) {
Ref<Texture2D> _icon;
- if (icon.is_null() && has_theme_icon("icon"))
+ if (icon.is_null() && has_theme_icon("icon")) {
_icon = Control::get_theme_icon("icon");
- else
+ } else {
_icon = icon;
+ }
if (!_icon.is_null()) {
-
minsize.height = MAX(minsize.height, _icon->get_height());
minsize.width += _icon->get_width();
- if (xl_text != "")
+ if (xl_text != "") {
minsize.width += get_theme_constant("hseparation");
+ }
}
}
@@ -59,21 +60,17 @@ Size2 Button::get_minimum_size() const {
}
void Button::_set_internal_margin(Margin p_margin, float p_value) {
-
_internal_margin[p_margin] = p_value;
}
void Button::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
-
xl_text = tr(text);
minimum_size_changed();
update();
} break;
case NOTIFICATION_DRAW: {
-
RID ci = get_canvas_item();
Size2 size = get_size();
Color color;
@@ -83,82 +80,88 @@ void Button::_notification(int p_what) {
switch (get_draw_mode()) {
case DRAW_NORMAL: {
-
style = get_theme_stylebox("normal");
- if (!flat)
+ if (!flat) {
style->draw(ci, Rect2(Point2(0, 0), size));
+ }
color = get_theme_color("font_color");
- if (has_theme_color("icon_color_normal"))
+ if (has_theme_color("icon_color_normal")) {
color_icon = get_theme_color("icon_color_normal");
+ }
} break;
case DRAW_HOVER_PRESSED: {
-
if (has_theme_stylebox("hover_pressed") && has_theme_stylebox_override("hover_pressed")) {
style = get_theme_stylebox("hover_pressed");
- if (!flat)
+ if (!flat) {
style->draw(ci, Rect2(Point2(0, 0), size));
- if (has_theme_color("font_color_hover_pressed"))
+ }
+ if (has_theme_color("font_color_hover_pressed")) {
color = get_theme_color("font_color_hover_pressed");
- else
+ } else {
color = get_theme_color("font_color");
- if (has_theme_color("icon_color_hover_pressed"))
+ }
+ if (has_theme_color("icon_color_hover_pressed")) {
color_icon = get_theme_color("icon_color_hover_pressed");
+ }
break;
}
[[fallthrough]];
}
case DRAW_PRESSED: {
-
style = get_theme_stylebox("pressed");
- if (!flat)
+ if (!flat) {
style->draw(ci, Rect2(Point2(0, 0), size));
- if (has_theme_color("font_color_pressed"))
+ }
+ if (has_theme_color("font_color_pressed")) {
color = get_theme_color("font_color_pressed");
- else
+ } else {
color = get_theme_color("font_color");
- if (has_theme_color("icon_color_pressed"))
+ }
+ if (has_theme_color("icon_color_pressed")) {
color_icon = get_theme_color("icon_color_pressed");
+ }
} break;
case DRAW_HOVER: {
-
style = get_theme_stylebox("hover");
- if (!flat)
+ if (!flat) {
style->draw(ci, Rect2(Point2(0, 0), size));
+ }
color = get_theme_color("font_color_hover");
- if (has_theme_color("icon_color_hover"))
+ if (has_theme_color("icon_color_hover")) {
color_icon = get_theme_color("icon_color_hover");
+ }
} break;
case DRAW_DISABLED: {
-
style = get_theme_stylebox("disabled");
- if (!flat)
+ if (!flat) {
style->draw(ci, Rect2(Point2(0, 0), size));
+ }
color = get_theme_color("font_color_disabled");
- if (has_theme_color("icon_color_disabled"))
+ if (has_theme_color("icon_color_disabled")) {
color_icon = get_theme_color("icon_color_disabled");
+ }
} break;
}
if (has_focus()) {
-
Ref<StyleBox> style2 = get_theme_stylebox("focus");
style2->draw(ci, Rect2(Point2(), size));
}
Ref<Font> font = get_theme_font("font");
Ref<Texture2D> _icon;
- if (icon.is_null() && has_theme_icon("icon"))
+ if (icon.is_null() && has_theme_icon("icon")) {
_icon = Control::get_theme_icon("icon");
- else
+ } else {
_icon = icon;
+ }
Rect2 icon_region = Rect2();
if (!_icon.is_null()) {
-
int valign = size.height - style->get_minimum_size().y;
if (is_disabled()) {
color_icon.a = 0.4;
@@ -172,8 +175,9 @@ void Button::_notification(int p_what) {
if (expand_icon) {
Size2 _size = get_size() - style->get_offset() * 2;
_size.width -= get_theme_constant("hseparation") + icon_ofs_region;
- if (!clip_text)
+ if (!clip_text) {
_size.width -= get_theme_font("font")->get_string_size(xl_text).width;
+ }
float icon_width = _icon->get_width() * _size.height / _icon->get_height();
float icon_height = _size.height;
@@ -209,8 +213,9 @@ void Button::_notification(int p_what) {
text_ofs.y += style->get_offset().y;
} break;
case ALIGN_CENTER: {
- if (text_ofs.x < 0)
+ if (text_ofs.x < 0) {
text_ofs.x = 0;
+ }
text_ofs += icon_ofs;
text_ofs += style->get_offset();
} break;
@@ -235,24 +240,24 @@ void Button::_notification(int p_what) {
}
void Button::set_text(const String &p_text) {
-
- if (text == p_text)
+ if (text == p_text) {
return;
+ }
text = p_text;
xl_text = tr(p_text);
update();
_change_notify("text");
minimum_size_changed();
}
-String Button::get_text() const {
+String Button::get_text() const {
return text;
}
void Button::set_icon(const Ref<Texture2D> &p_icon) {
-
- if (icon == p_icon)
+ if (icon == p_icon) {
return;
+ }
icon = p_icon;
update();
_change_notify("icon");
@@ -260,59 +265,49 @@ void Button::set_icon(const Ref<Texture2D> &p_icon) {
}
Ref<Texture2D> Button::get_icon() const {
-
return icon;
}
void Button::set_expand_icon(bool p_expand_icon) {
-
expand_icon = p_expand_icon;
update();
minimum_size_changed();
}
bool Button::is_expand_icon() const {
-
return expand_icon;
}
void Button::set_flat(bool p_flat) {
-
flat = p_flat;
update();
_change_notify("flat");
}
bool Button::is_flat() const {
-
return flat;
}
void Button::set_clip_text(bool p_clip_text) {
-
clip_text = p_clip_text;
update();
minimum_size_changed();
}
bool Button::get_clip_text() const {
-
return clip_text;
}
void Button::set_text_align(TextAlign p_align) {
-
align = p_align;
update();
}
Button::TextAlign Button::get_text_align() const {
-
return align;
}
void Button::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_text", "text"), &Button::set_text);
ClassDB::bind_method(D_METHOD("get_text"), &Button::get_text);
ClassDB::bind_method(D_METHOD("set_button_icon", "texture"), &Button::set_icon);
@@ -339,7 +334,6 @@ void Button::_bind_methods() {
}
Button::Button(const String &p_text) {
-
flat = false;
clip_text = false;
expand_icon = false;
diff --git a/scene/gui/button.h b/scene/gui/button.h
index 3135b98578..e757badd3e 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -34,7 +34,6 @@
#include "scene/gui/base_button.h"
class Button : public BaseButton {
-
GDCLASS(Button, BaseButton);
public:
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index 64d6885bc8..f8f9bec3d7 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -31,19 +31,21 @@
#include "center_container.h"
Size2 CenterContainer::get_minimum_size() const {
-
- if (use_top_left)
+ if (use_top_left) {
return Size2();
+ }
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (!c->is_visible())
+ }
+ if (!c->is_visible()) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width, minsize.width);
ms.height = MAX(ms.height, minsize.height);
@@ -53,7 +55,6 @@ Size2 CenterContainer::get_minimum_size() const {
}
void CenterContainer::set_use_top_left(bool p_enable) {
-
if (use_top_left == p_enable) {
return;
}
@@ -65,22 +66,20 @@ void CenterContainer::set_use_top_left(bool p_enable) {
}
bool CenterContainer::is_using_top_left() const {
-
return use_top_left;
}
void CenterContainer::_notification(int p_what) {
-
if (p_what == NOTIFICATION_SORT_CHILDREN) {
-
Size2 size = get_size();
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
Point2 ofs = use_top_left ? (-minsize * 0.5).floor() : ((size - minsize) / 2.0).floor();
@@ -90,7 +89,6 @@ void CenterContainer::_notification(int p_what) {
}
void CenterContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_use_top_left", "enable"), &CenterContainer::set_use_top_left);
ClassDB::bind_method(D_METHOD("is_using_top_left"), &CenterContainer::is_using_top_left);
@@ -98,6 +96,5 @@ void CenterContainer::_bind_methods() {
}
CenterContainer::CenterContainer() {
-
use_top_left = false;
}
diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h
index 98733f384d..ae9f87db16 100644
--- a/scene/gui/center_container.h
+++ b/scene/gui/center_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class CenterContainer : public Container {
-
GDCLASS(CenterContainer, Container);
bool use_top_left;
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 470450e3ed..df6f38f65d 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -39,19 +39,22 @@ Size2 CheckBox::get_icon_size() const {
Ref<Texture2D> radio_unchecked = Control::get_theme_icon("radio_unchecked");
Size2 tex_size = Size2(0, 0);
- if (!checked.is_null())
+ if (!checked.is_null()) {
tex_size = Size2(checked->get_width(), checked->get_height());
- if (!unchecked.is_null())
+ }
+ if (!unchecked.is_null()) {
tex_size = Size2(MAX(tex_size.width, unchecked->get_width()), MAX(tex_size.height, unchecked->get_height()));
- if (!radio_checked.is_null())
+ }
+ if (!radio_checked.is_null()) {
tex_size = Size2(MAX(tex_size.width, radio_checked->get_width()), MAX(tex_size.height, radio_checked->get_height()));
- if (!radio_unchecked.is_null())
+ }
+ if (!radio_unchecked.is_null()) {
tex_size = Size2(MAX(tex_size.width, radio_unchecked->get_width()), MAX(tex_size.height, radio_unchecked->get_height()));
+ }
return tex_size;
}
Size2 CheckBox::get_minimum_size() const {
-
Size2 minsize = Button::get_minimum_size();
Size2 tex_size = get_icon_size();
minsize.width += tex_size.width;
@@ -65,12 +68,9 @@ Size2 CheckBox::get_minimum_size() const {
}
void CheckBox::_notification(int p_what) {
-
if (p_what == NOTIFICATION_THEME_CHANGED) {
-
_set_internal_margin(MARGIN_LEFT, get_icon_size().width);
} else if (p_what == NOTIFICATION_DRAW) {
-
RID ci = get_canvas_item();
Ref<Texture2D> on = Control::get_theme_icon(is_radio() ? "radio_checked" : "checked");
@@ -81,15 +81,15 @@ void CheckBox::_notification(int p_what) {
ofs.x = sb->get_margin(MARGIN_LEFT);
ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_theme_constant("check_vadjust");
- if (is_pressed())
+ if (is_pressed()) {
on->draw(ci, ofs);
- else
+ } else {
off->draw(ci, ofs);
+ }
}
}
bool CheckBox::is_radio() {
-
return get_button_group().is_valid();
}
diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h
index 7c8f8c11d6..58f7cce55e 100644
--- a/scene/gui/check_box.h
+++ b/scene/gui/check_box.h
@@ -36,7 +36,6 @@
@author Mariano Suligoy <marianognu.esyrpg@gmail.com>
*/
class CheckBox : public Button {
-
GDCLASS(CheckBox, Button);
protected:
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index 96484424f8..1ddc730dd1 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -34,25 +34,26 @@
#include "servers/rendering_server.h"
Size2 CheckButton::get_icon_size() const {
-
Ref<Texture2D> on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on");
Ref<Texture2D> off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off");
Size2 tex_size = Size2(0, 0);
- if (!on.is_null())
+ if (!on.is_null()) {
tex_size = Size2(on->get_width(), on->get_height());
- if (!off.is_null())
+ }
+ if (!off.is_null()) {
tex_size = Size2(MAX(tex_size.width, off->get_width()), MAX(tex_size.height, off->get_height()));
+ }
return tex_size;
}
Size2 CheckButton::get_minimum_size() const {
-
Size2 minsize = Button::get_minimum_size();
Size2 tex_size = get_icon_size();
minsize.width += tex_size.width;
- if (get_text().length() > 0)
+ if (get_text().length() > 0) {
minsize.width += get_theme_constant("hseparation");
+ }
Ref<StyleBox> sb = get_theme_stylebox("normal");
minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM));
@@ -60,12 +61,9 @@ Size2 CheckButton::get_minimum_size() const {
}
void CheckButton::_notification(int p_what) {
-
if (p_what == NOTIFICATION_THEME_CHANGED) {
-
_set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
} else if (p_what == NOTIFICATION_DRAW) {
-
RID ci = get_canvas_item();
Ref<Texture2D> on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on");
@@ -78,15 +76,15 @@ void CheckButton::_notification(int p_what) {
ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT));
ofs.y = (get_size().height - tex_size.height) / 2 + get_theme_constant("check_vadjust");
- if (is_pressed())
+ if (is_pressed()) {
on->draw(ci, ofs);
- else
+ } else {
off->draw(ci, ofs);
+ }
}
}
CheckButton::CheckButton() {
-
set_toggle_mode(true);
set_text_align(ALIGN_LEFT);
diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h
index 3599c26a4c..8bbad0b4b3 100644
--- a/scene/gui/check_button.h
+++ b/scene/gui/check_button.h
@@ -36,7 +36,6 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
class CheckButton : public Button {
-
GDCLASS(CheckButton, Button);
protected:
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 63878a0b26..84170a65d1 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -41,17 +41,14 @@
#include "scene/main/window.h"
void ColorPicker::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
-
btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_theme_icon("add_preset"));
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
-
btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_theme_icon("add_preset"));
@@ -68,40 +65,40 @@ void ColorPicker::_notification(int p_what) {
#endif
} break;
case NOTIFICATION_PARENTED: {
-
- for (int i = 0; i < 4; i++)
- set_margin((Margin)i, get_theme_constant("margin"));
+ for (int i = 0; i < 4; i++) {
+ set_margin((Margin)i, get_margin((Margin)i) + get_theme_constant("margin"));
+ }
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
Popup *p = Object::cast_to<Popup>(get_parent());
- if (p)
+ if (p) {
p->set_size(Size2(get_combined_minimum_size().width + get_theme_constant("margin") * 2, get_combined_minimum_size().height + get_theme_constant("margin") * 2));
+ }
} break;
case NOTIFICATION_WM_CLOSE_REQUEST: {
-
- if (screen != nullptr && screen->is_visible())
+ if (screen != nullptr && screen->is_visible()) {
screen->hide();
+ }
} break;
}
}
void ColorPicker::set_focus_on_line_edit() {
-
c_text->call_deferred("grab_focus");
}
void ColorPicker::_update_controls() {
-
const char *rgb[3] = { "R", "G", "B" };
const char *hsv[3] = { "H", "S", "V" };
if (hsv_mode_enabled) {
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
labels[i]->set_text(hsv[i]);
+ }
} else {
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
labels[i]->set_text(rgb[i]);
+ }
}
if (hsv_mode_enabled) {
@@ -127,7 +124,6 @@ void ColorPicker::_update_controls() {
}
void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) {
-
color = p_color;
if (color != last_hsv) {
h = color.get_h();
@@ -136,38 +132,37 @@ void ColorPicker::_set_pick_color(const Color &p_color, bool p_update_sliders) {
last_hsv = color;
}
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_update_color(p_update_sliders);
}
void ColorPicker::set_pick_color(const Color &p_color) {
-
_set_pick_color(p_color, true); //because setters can't have more arguments
}
void ColorPicker::set_edit_alpha(bool p_show) {
-
edit_alpha = p_show;
_update_controls();
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_update_color();
sample->update();
}
bool ColorPicker::is_editing_alpha() const {
-
return edit_alpha;
}
void ColorPicker::_value_changed(double) {
-
- if (updating)
+ if (updating) {
return;
+ }
if (hsv_mode_enabled) {
color.set_hsv(scroll[0]->get_value() / 360.0,
@@ -185,28 +180,28 @@ void ColorPicker::_value_changed(double) {
}
void ColorPicker::_html_entered(const String &p_html) {
-
- if (updating || text_is_constructor || !c_text->is_visible())
+ if (updating || text_is_constructor || !c_text->is_visible()) {
return;
+ }
float last_alpha = color.a;
color = Color::html(p_html);
- if (!is_editing_alpha())
+ if (!is_editing_alpha()) {
color.a = last_alpha;
+ }
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
set_pick_color(color);
emit_signal("color_changed", color);
}
void ColorPicker::_update_color(bool p_update_sliders) {
-
updating = true;
if (p_update_sliders) {
-
if (hsv_mode_enabled) {
for (int i = 0; i < 4; i++) {
scroll[i]->set_step(1.0);
@@ -225,8 +220,9 @@ void ColorPicker::_update_color(bool p_update_sliders) {
if (raw_mode_enabled) {
scroll[i]->set_step(0.01);
scroll[i]->set_max(100);
- if (i == 3)
+ if (i == 3) {
scroll[i]->set_max(1);
+ }
scroll[i]->set_value(color.components[i]);
} else {
scroll[i]->set_step(1);
@@ -266,7 +262,6 @@ void ColorPicker::_update_presets() {
}
void ColorPicker::_text_type_toggled() {
-
text_is_constructor = !text_is_constructor;
if (text_is_constructor) {
text_type->set_text("");
@@ -283,12 +278,10 @@ void ColorPicker::_text_type_toggled() {
}
Color ColorPicker::get_pick_color() const {
-
return color;
}
void ColorPicker::add_preset(const Color &p_color) {
-
if (presets.find(p_color)) {
presets.move_to_back(presets.find(p_color));
} else {
@@ -305,7 +298,6 @@ void ColorPicker::add_preset(const Color &p_color) {
}
void ColorPicker::erase_preset(const Color &p_color) {
-
if (presets.find(p_color)) {
presets.erase(presets.find(p_color));
preset->update();
@@ -320,7 +312,6 @@ void ColorPicker::erase_preset(const Color &p_color) {
}
PackedColorArray ColorPicker::get_presets() const {
-
PackedColorArray arr;
arr.resize(presets.size());
for (int i = 0; i < presets.size(); i++) {
@@ -330,42 +321,44 @@ PackedColorArray ColorPicker::get_presets() const {
}
void ColorPicker::set_hsv_mode(bool p_enabled) {
-
- if (hsv_mode_enabled == p_enabled || raw_mode_enabled)
+ if (hsv_mode_enabled == p_enabled || raw_mode_enabled) {
return;
+ }
hsv_mode_enabled = p_enabled;
- if (btn_hsv->is_pressed() != p_enabled)
+ if (btn_hsv->is_pressed() != p_enabled) {
btn_hsv->set_pressed(p_enabled);
+ }
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_update_controls();
_update_color();
}
bool ColorPicker::is_hsv_mode() const {
-
return hsv_mode_enabled;
}
void ColorPicker::set_raw_mode(bool p_enabled) {
-
- if (raw_mode_enabled == p_enabled || hsv_mode_enabled)
+ if (raw_mode_enabled == p_enabled || hsv_mode_enabled) {
return;
+ }
raw_mode_enabled = p_enabled;
- if (btn_raw->is_pressed() != p_enabled)
+ if (btn_raw->is_pressed() != p_enabled) {
btn_raw->set_pressed(p_enabled);
+ }
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_update_controls();
_update_color();
}
bool ColorPicker::is_raw_mode() const {
-
return raw_mode_enabled;
}
@@ -381,10 +374,11 @@ void ColorPicker::_update_text_value() {
bool visible = true;
if (text_is_constructor) {
String t = "Color(" + String::num(color.r) + ", " + String::num(color.g) + ", " + String::num(color.b);
- if (edit_alpha && color.a < 1)
+ if (edit_alpha && color.a < 1) {
t += ", " + String::num(color.a) + ")";
- else
+ } else {
t += ")";
+ }
c_text->set_text(t);
}
@@ -414,8 +408,9 @@ void ColorPicker::_sample_draw() {
}
void ColorPicker::_hsv_draw(int p_which, Control *c) {
- if (!c)
+ if (!c) {
return;
+ }
if (p_which == 0) {
Vector<Point2> points;
points.push_back(Vector2());
@@ -458,7 +453,6 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) {
}
void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
@@ -472,8 +466,9 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) {
last_hsv = color;
set_pick_color(color);
_update_color();
- if (!deferred_mode_enabled)
+ if (!deferred_mode_enabled) {
emit_signal("color_changed", color);
+ }
} else if (deferred_mode_enabled && !bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
emit_signal("color_changed", color);
changing_color = false;
@@ -485,8 +480,9 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
- if (!changing_color)
+ if (!changing_color) {
return;
+ }
float x = CLAMP((float)mev->get_position().x, 0, uv_edit->get_size().width);
float y = CLAMP((float)mev->get_position().y, 0, uv_edit->get_size().height);
s = x / uv_edit->get_size().width;
@@ -495,17 +491,16 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event) {
last_hsv = color;
set_pick_color(color);
_update_color();
- if (!deferred_mode_enabled)
+ if (!deferred_mode_enabled) {
emit_signal("color_changed", color);
+ }
}
}
void ColorPicker::_w_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
-
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
changing_color = true;
float y = CLAMP((float)bev->get_position().y, 0, w_edit->get_size().height);
@@ -517,31 +512,32 @@ void ColorPicker::_w_input(const Ref<InputEvent> &p_event) {
last_hsv = color;
set_pick_color(color);
_update_color();
- if (!deferred_mode_enabled)
+ if (!deferred_mode_enabled) {
emit_signal("color_changed", color);
- else if (!bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT)
+ } else if (!bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
emit_signal("color_changed", color);
+ }
}
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
-
- if (!changing_color)
+ if (!changing_color) {
return;
+ }
float y = CLAMP((float)mev->get_position().y, 0, w_edit->get_size().height);
h = y / w_edit->get_size().height;
color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_pick_color(color);
_update_color();
- if (!deferred_mode_enabled)
+ if (!deferred_mode_enabled) {
emit_signal("color_changed", color);
+ }
}
}
void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid()) {
@@ -569,19 +565,18 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
-
int index = mev->get_position().x * presets.size();
if (preset->get_size().x != 0) {
index /= preset->get_size().x;
}
- if (index < 0 || index >= presets.size())
+ if (index < 0 || index >= presets.size()) {
return;
+ }
preset->set_tooltip(vformat(RTR("Color: #%s\nLMB: Set color\nRMB: Remove preset"), presets[index].to_html(presets[index].a < 1)));
}
}
void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> bev = p_event;
if (bev.is_valid() && bev->get_button_index() == BUTTON_LEFT && !bev->is_pressed()) {
emit_signal("color_changed", color);
@@ -591,12 +586,12 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mev = p_event;
if (mev.is_valid()) {
Viewport *r = get_tree()->get_root();
- if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y)))
+ if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y))) {
return;
+ }
Ref<Image> img = r->get_texture()->get_data();
if (img.is_valid() && !img->empty()) {
-
Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position();
Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y);
@@ -648,15 +643,17 @@ void ColorPicker::_focus_enter() {
void ColorPicker::_focus_exit() {
for (int i = 0; i < 4; i++) {
- if (!values[i]->get_line_edit()->get_menu()->is_visible())
+ if (!values[i]->get_line_edit()->get_menu()->is_visible()) {
values[i]->get_line_edit()->select(0, 0);
+ }
}
c_text->select(0, 0);
}
void ColorPicker::_html_focus_exit() {
- if (c_text->get_menu()->is_visible())
+ if (c_text->get_menu()->is_visible()) {
return;
+ }
_html_entered(c_text->get_text());
_focus_exit();
}
@@ -688,7 +685,6 @@ bool ColorPicker::are_presets_visible() const {
}
void ColorPicker::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPicker::set_pick_color);
ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPicker::get_pick_color);
ClassDB::bind_method(D_METHOD("set_hsv_mode"), &ColorPicker::set_hsv_mode);
@@ -722,7 +718,6 @@ void ColorPicker::_bind_methods() {
ColorPicker::ColorPicker() :
BoxContainer(true) {
-
updating = true;
edit_alpha = true;
text_is_constructor = false;
@@ -779,7 +774,6 @@ ColorPicker::ColorPicker() :
vbr->set_h_size_flags(SIZE_EXPAND_FILL);
for (int i = 0; i < 4; i++) {
-
HBoxContainer *hbc = memnew(HBoxContainer);
labels[i] = memnew(Label());
@@ -826,13 +820,11 @@ ColorPicker::ColorPicker() :
text_type->set_text("#");
text_type->set_tooltip(TTR("Switch between hexadecimal and code values."));
if (Engine::get_singleton()->is_editor_hint()) {
-
#ifdef TOOLS_ENABLED
text_type->set_custom_minimum_size(Size2(28 * EDSCALE, 0)); // Adjust for the width of the "Script" icon.
#endif
text_type->connect("pressed", callable_mp(this, &ColorPicker::_text_type_toggled));
} else {
-
text_type->set_flat(true);
text_type->set_mouse_filter(MOUSE_FILTER_IGNORE);
}
@@ -873,19 +865,16 @@ ColorPicker::ColorPicker() :
/////////////////
void ColorPickerButton::_color_changed(const Color &p_color) {
-
color = p_color;
update();
emit_signal("color_changed", color);
}
void ColorPickerButton::_modal_closed() {
-
emit_signal("popup_closed");
}
void ColorPickerButton::pressed() {
-
_update_picker();
popup->set_as_minsize();
@@ -904,7 +893,6 @@ void ColorPickerButton::pressed() {
if (i & 1) {
cp_rect.position.x = get_screen_position().x;
} else {
-
cp_rect.position.x = get_screen_position().x - MAX(0, (cp_rect.size.x - get_size().x));
}
@@ -918,10 +906,8 @@ void ColorPickerButton::pressed() {
}
void ColorPickerButton::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
-
const Ref<StyleBox> normal = get_theme_stylebox("normal");
const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
draw_texture_rect(Control::get_theme_icon("bg", "ColorPickerButton"), r, true);
@@ -933,9 +919,9 @@ void ColorPickerButton::_notification(int p_what) {
}
} break;
case NOTIFICATION_WM_CLOSE_REQUEST: {
-
- if (popup)
+ if (popup) {
popup->hide();
+ }
} break;
}
@@ -947,7 +933,6 @@ void ColorPickerButton::_notification(int p_what) {
}
void ColorPickerButton::set_pick_color(const Color &p_color) {
-
color = p_color;
if (picker) {
picker->set_pick_color(p_color);
@@ -955,13 +940,12 @@ void ColorPickerButton::set_pick_color(const Color &p_color) {
update();
}
-Color ColorPickerButton::get_pick_color() const {
+Color ColorPickerButton::get_pick_color() const {
return color;
}
void ColorPickerButton::set_edit_alpha(bool p_show) {
-
edit_alpha = p_show;
if (picker) {
picker->set_edit_alpha(p_show);
@@ -969,18 +953,15 @@ void ColorPickerButton::set_edit_alpha(bool p_show) {
}
bool ColorPickerButton::is_editing_alpha() const {
-
return edit_alpha;
}
ColorPicker *ColorPickerButton::get_picker() {
-
_update_picker();
return picker;
}
PopupPanel *ColorPickerButton::get_popup() {
-
_update_picker();
return popup;
}
@@ -1004,7 +985,6 @@ void ColorPickerButton::_update_picker() {
}
void ColorPickerButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPickerButton::set_pick_color);
ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPickerButton::get_pick_color);
ClassDB::bind_method(D_METHOD("get_picker"), &ColorPickerButton::get_picker);
@@ -1020,7 +1000,6 @@ void ColorPickerButton::_bind_methods() {
}
ColorPickerButton::ColorPickerButton() {
-
// Initialization is now done deferred,
// this improves performance in the inspector as the color picker
// can be expensive to initialize.
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index dde2f37135..31ae92f4e4 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -44,7 +44,6 @@
#include "scene/gui/tool_button.h"
class ColorPicker : public BoxContainer {
-
GDCLASS(ColorPicker, BoxContainer);
private:
@@ -139,7 +138,6 @@ public:
};
class ColorPickerButton : public Button {
-
GDCLASS(ColorPickerButton, Button);
PopupPanel *popup;
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
index 61260e153c..627e589c02 100644
--- a/scene/gui/color_rect.cpp
+++ b/scene/gui/color_rect.cpp
@@ -31,25 +31,21 @@
#include "color_rect.h"
void ColorRect::set_frame_color(const Color &p_color) {
-
color = p_color;
update();
}
Color ColorRect::get_frame_color() const {
-
return color;
}
void ColorRect::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
draw_rect(Rect2(Point2(), get_size()), color);
}
}
void ColorRect::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_frame_color", "color"), &ColorRect::set_frame_color);
ClassDB::bind_method(D_METHOD("get_frame_color"), &ColorRect::get_frame_color);
@@ -57,6 +53,5 @@ void ColorRect::_bind_methods() {
}
ColorRect::ColorRect() {
-
color = Color(1, 1, 1);
}
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 41f33bb719..a89eef6209 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -33,7 +33,6 @@
#include "scene/scene_string_names.h"
void Container::_child_minsize_changed() {
-
//Size2 ms = get_combined_minimum_size();
//if (ms.width > get_size().width || ms.height > get_size().height) {
minimum_size_changed();
@@ -41,12 +40,12 @@ void Container::_child_minsize_changed() {
}
void Container::add_child_notify(Node *p_child) {
-
Control::add_child_notify(p_child);
Control *control = Object::cast_to<Control>(p_child);
- if (!control)
+ if (!control) {
return;
+ }
control->connect("size_flags_changed", callable_mp(this, &Container::queue_sort));
control->connect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed));
@@ -57,23 +56,23 @@ void Container::add_child_notify(Node *p_child) {
}
void Container::move_child_notify(Node *p_child) {
-
Control::move_child_notify(p_child);
- if (!Object::cast_to<Control>(p_child))
+ if (!Object::cast_to<Control>(p_child)) {
return;
+ }
minimum_size_changed();
queue_sort();
}
void Container::remove_child_notify(Node *p_child) {
-
Control::remove_child_notify(p_child);
Control *control = Object::cast_to<Control>(p_child);
- if (!control)
+ if (!control) {
return;
+ }
control->disconnect("size_flags_changed", callable_mp(this, &Container::queue_sort));
control->disconnect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed));
@@ -84,9 +83,9 @@ void Container::remove_child_notify(Node *p_child) {
}
void Container::_sort_children() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
notification(NOTIFICATION_SORT_CHILDREN);
emit_signal(SceneStringNames::get_singleton()->sort_children);
@@ -94,7 +93,6 @@ void Container::_sort_children() {
}
void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
-
ERR_FAIL_COND(!p_child);
ERR_FAIL_COND(p_child->get_parent() != this);
@@ -123,8 +121,9 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
}
}
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++) {
p_child->set_anchor(Margin(i), ANCHOR_BEGIN);
+ }
p_child->set_position(r.position);
p_child->set_size(r.size);
@@ -133,35 +132,31 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
}
void Container::queue_sort() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (pending_sort)
+ if (pending_sort) {
return;
+ }
- MessageQueue::get_singleton()->push_call(this, "_sort_children");
+ MessageQueue::get_singleton()->push_callable(callable_mp(this, &Container::_sort_children));
pending_sort = true;
}
void Container::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
pending_sort = false;
queue_sort();
} break;
case NOTIFICATION_RESIZED: {
-
queue_sort();
} break;
case NOTIFICATION_THEME_CHANGED: {
-
queue_sort();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
if (is_visible_in_tree()) {
queue_sort();
}
@@ -170,7 +165,6 @@ void Container::_notification(int p_what) {
}
String Container::get_configuration_warning() const {
-
String warning = Control::get_configuration_warning();
if (get_class() == "Container" && get_script().is_null()) {
@@ -183,9 +177,6 @@ String Container::get_configuration_warning() const {
}
void Container::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children);
-
ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort);
ClassDB::bind_method(D_METHOD("fit_child_in_rect", "child", "rect"), &Container::fit_child_in_rect);
@@ -194,7 +185,6 @@ void Container::_bind_methods() {
}
Container::Container() {
-
pending_sort = false;
// All containers should let mouse events pass by default.
set_mouse_filter(MOUSE_FILTER_PASS);
diff --git a/scene/gui/container.h b/scene/gui/container.h
index 0b736d9790..c8db5ee28f 100644
--- a/scene/gui/container.h
+++ b/scene/gui/container.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class Container : public Control {
-
GDCLASS(Container, Control);
bool pending_sort;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index b710ba4803..97daeceda9 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -30,6 +30,7 @@
#include "control.h"
+#include "core/math/geometry_2d.h"
#include "core/message_queue.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
@@ -49,7 +50,6 @@
#ifdef TOOLS_ENABLED
Dictionary Control::_edit_get_state() const {
-
Dictionary s;
s["rotation"] = get_rotation();
s["scale"] = get_scale();
@@ -70,7 +70,6 @@ Dictionary Control::_edit_get_state() const {
}
void Control::_edit_set_state(const Dictionary &p_state) {
-
Dictionary state = p_state;
set_rotation(state["rotation"]);
@@ -162,37 +161,36 @@ Size2 Control::_edit_get_minimum_size() const {
#endif
void Control::set_custom_minimum_size(const Size2 &p_custom) {
-
- if (p_custom == data.custom_minimum_size)
+ if (p_custom == data.custom_minimum_size) {
return;
+ }
data.custom_minimum_size = p_custom;
minimum_size_changed();
}
Size2 Control::get_custom_minimum_size() const {
-
return data.custom_minimum_size;
}
void Control::_update_minimum_size_cache() {
-
Size2 minsize = get_minimum_size();
minsize.x = MAX(minsize.x, data.custom_minimum_size.x);
minsize.y = MAX(minsize.y, data.custom_minimum_size.y);
bool size_changed = false;
- if (data.minimum_size_cache != minsize)
+ if (data.minimum_size_cache != minsize) {
size_changed = true;
+ }
data.minimum_size_cache = minsize;
data.minimum_size_valid = true;
- if (size_changed)
+ if (size_changed) {
minimum_size_changed();
+ }
}
Size2 Control::get_combined_minimum_size() const {
-
if (!data.minimum_size_valid) {
const_cast<Control *>(this)->_update_minimum_size_cache();
}
@@ -200,7 +198,6 @@ Size2 Control::get_combined_minimum_size() const {
}
Transform2D Control::_get_internal_transform() const {
-
Transform2D rot_scale;
rot_scale.set_rotation_and_scale(data.rotation, data.scale);
Transform2D offset;
@@ -210,14 +207,12 @@ Transform2D Control::_get_internal_transform() const {
}
bool Control::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (!name.begins_with("custom")) {
return false;
}
if (p_value.get_type() == Variant::NIL) {
-
if (name.begins_with("custom_icons/")) {
String dname = name.get_slicec('/', 1);
if (data.icon_override.has(dname)) {
@@ -254,8 +249,9 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) {
String dname = name.get_slicec('/', 1);
data.constant_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
- } else
+ } else {
return false;
+ }
} else {
if (name.begins_with("custom_icons/")) {
@@ -276,16 +272,17 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) {
} else if (name.begins_with("custom_constants/")) {
String dname = name.get_slicec('/', 1);
add_theme_constant_override(dname, p_value);
- } else
+ } else {
return false;
+ }
}
return true;
}
void Control::_update_minimum_size() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
Size2 minsize = get_combined_minimum_size();
if (minsize.x > data.size_cache.x ||
@@ -302,7 +299,6 @@ void Control::_update_minimum_size() {
}
bool Control::_get(const StringName &p_name, Variant &r_ret) const {
-
String sname = p_name;
if (!sname.begins_with("custom")) {
@@ -332,13 +328,14 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const {
String name = sname.get_slicec('/', 1);
r_ret = data.constant_override.has(name) ? Variant(data.constant_override[name]) : Variant();
- } else
+ } else {
return false;
+ }
return true;
}
-void Control::_get_property_list(List<PropertyInfo> *p_list) const {
+void Control::_get_property_list(List<PropertyInfo> *p_list) const {
Ref<Theme> theme = Theme::get_default();
/* Using the default theme since the properties below are meant for editor only
if (data.theme.is_valid()) {
@@ -353,10 +350,10 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
theme->get_icon_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.icon_override.has(E->get()))
+ if (data.icon_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", hint));
}
@@ -365,10 +362,10 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
theme->get_shader_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.shader_override.has(E->get()))
+ if (data.shader_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Shader,VisualShader", hint));
}
@@ -377,10 +374,10 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
theme->get_stylebox_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.style_override.has(E->get()))
+ if (data.style_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_styles/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", hint));
}
@@ -389,10 +386,10 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
theme->get_font_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.font_override.has(E->get()))
+ if (data.font_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_fonts/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Font", hint));
}
@@ -401,10 +398,10 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
theme->get_color_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.color_override.has(E->get()))
+ if (data.color_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::COLOR, "custom_colors/" + E->get(), PROPERTY_HINT_NONE, "", hint));
}
@@ -413,10 +410,10 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
List<StringName> names;
theme->get_constant_list(get_class_name(), &names);
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
- if (data.constant_override.has(E->get()))
+ if (data.constant_override.has(E->get())) {
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
+ }
p_list->push_back(PropertyInfo(Variant::INT, "custom_constants/" + E->get(), PROPERTY_HINT_RANGE, "-16384,16384", hint));
}
@@ -424,19 +421,16 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
}
Control *Control::get_parent_control() const {
-
return data.parent;
}
void Control::_resize(const Size2 &p_size) {
-
_size_changed();
}
//moved theme configuration here, so controls can set up even if still not inside active scene
void Control::add_child_notify(Node *p_child) {
-
Control *child_c = Object::cast_to<Control>(p_child);
if (child_c && child_c->data.theme.is_null() && (data.theme_owner || data.theme_owner_window)) {
@@ -451,7 +445,6 @@ void Control::add_child_notify(Node *p_child) {
}
void Control::remove_child_notify(Node *p_child) {
-
Control *child_c = Object::cast_to<Control>(p_child);
if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) {
@@ -466,7 +459,6 @@ void Control::remove_child_notify(Node *p_child) {
}
void Control::_update_canvas_item_transform() {
-
Transform2D xform = _get_internal_transform();
xform[2] += get_position();
@@ -474,24 +466,19 @@ void Control::_update_canvas_item_transform() {
}
void Control::_notification(int p_notification) {
-
switch (p_notification) {
-
case NOTIFICATION_ENTER_TREE: {
-
} break;
case NOTIFICATION_POST_ENTER_TREE: {
data.minimum_size_valid = false;
_size_changed();
} break;
case NOTIFICATION_EXIT_TREE: {
-
get_viewport()->_gui_remove_control(this);
} break;
case NOTIFICATION_ENTER_CANVAS: {
-
data.parent = Object::cast_to<Control>(get_parent());
Node *parent = this; //meh
@@ -499,11 +486,11 @@ void Control::_notification(int p_notification) {
bool subwindow = false;
while (parent) {
-
parent = parent->get_parent();
- if (!parent)
+ if (!parent) {
break;
+ }
CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
if (ci && ci->is_set_as_toplevel()) {
@@ -516,7 +503,6 @@ void Control::_notification(int p_notification) {
if (parent_control) {
break;
} else if (ci) {
-
} else {
break;
}
@@ -536,7 +522,6 @@ void Control::_notification(int p_notification) {
data.parent_canvas_item = get_parent_item();
if (data.parent_canvas_item) {
-
data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed));
} else {
//connect viewport
@@ -544,9 +529,7 @@ void Control::_notification(int p_notification) {
}
} break;
case NOTIFICATION_EXIT_CANVAS: {
-
if (data.parent_canvas_item) {
-
data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed));
data.parent_canvas_item = nullptr;
} else if (!is_set_as_toplevel()) {
@@ -566,8 +549,9 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_MOVED_IN_PARENT: {
// some parents need to know the order of the childrens to draw (like TabContainer)
// update if necessary
- if (data.parent)
+ if (data.parent) {
data.parent->update();
+ }
update();
if (data.RI) {
@@ -576,11 +560,9 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_RESIZED: {
-
emit_signal(SceneStringNames::get_singleton()->resized);
} break;
case NOTIFICATION_DRAW: {
-
_update_canvas_item_transform();
RenderingServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), !data.disable_visibility_clip, Rect2(Point2(), get_size()));
RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), data.clip_contents);
@@ -588,35 +570,29 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_MOUSE_ENTER: {
-
emit_signal(SceneStringNames::get_singleton()->mouse_entered);
} break;
case NOTIFICATION_MOUSE_EXIT: {
-
emit_signal(SceneStringNames::get_singleton()->mouse_exited);
} break;
case NOTIFICATION_FOCUS_ENTER: {
-
emit_signal(SceneStringNames::get_singleton()->focus_entered);
update();
} break;
case NOTIFICATION_FOCUS_EXIT: {
-
emit_signal(SceneStringNames::get_singleton()->focus_exited);
update();
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
update();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
if (!is_visible_in_tree()) {
-
- if (get_viewport() != nullptr)
+ if (get_viewport() != nullptr) {
get_viewport()->_gui_hid_control(this);
+ }
//remove key focus
@@ -630,14 +606,13 @@ void Control::_notification(int p_notification) {
}
bool Control::clips_input() const {
-
if (get_script_instance()) {
return get_script_instance()->call(SceneStringNames::get_singleton()->_clips_input);
}
return false;
}
-bool Control::has_point(const Point2 &p_point) const {
+bool Control::has_point(const Point2 &p_point) const {
if (get_script_instance()) {
Variant v = p_point;
const Variant *p = &v;
@@ -655,15 +630,14 @@ bool Control::has_point(const Point2 &p_point) const {
}
void Control::set_drag_forwarding(Control *p_target) {
-
- if (p_target)
+ if (p_target) {
data.drag_owner = p_target->get_instance_id();
- else
+ } else {
data.drag_owner = ObjectID();
+ }
}
Variant Control::get_drag_data(const Point2 &p_point) {
-
if (data.drag_owner.is_valid()) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
@@ -677,15 +651,15 @@ Variant Control::get_drag_data(const Point2 &p_point) {
const Variant *p = &v;
Callable::CallError ce;
Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->get_drag_data, &p, 1, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return ret;
+ }
}
return Variant();
}
bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
if (data.drag_owner.is_valid()) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
@@ -699,14 +673,15 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const
const Variant *p[2] = { &v, &p_data };
Callable::CallError ce;
Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->can_drop_data, p, 2, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return ret;
+ }
}
return Variant();
}
-void Control::drop_data(const Point2 &p_point, const Variant &p_data) {
+void Control::drop_data(const Point2 &p_point, const Variant &p_data) {
if (data.drag_owner.is_valid()) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
@@ -721,13 +696,13 @@ void Control::drop_data(const Point2 &p_point, const Variant &p_data) {
const Variant *p[2] = { &v, &p_data };
Callable::CallError ce;
Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->drop_data, p, 2, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return;
+ }
}
}
void Control::force_drag(const Variant &p_data, Control *p_control) {
-
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND(p_data.get_type() == Variant::NIL);
@@ -735,34 +710,30 @@ void Control::force_drag(const Variant &p_data, Control *p_control) {
}
void Control::set_drag_preview(Control *p_control) {
-
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND(!get_viewport()->gui_is_dragging());
get_viewport()->_gui_set_drag_preview(this, p_control);
}
Size2 Control::get_minimum_size() const {
-
ScriptInstance *si = const_cast<Control *>(this)->get_script_instance();
if (si) {
-
Callable::CallError ce;
Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce);
- if (ce.error == Callable::CallError::CALL_OK)
+ if (ce.error == Callable::CallError::CALL_OK) {
return s;
+ }
}
return Size2();
}
template <class T>
bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, T &r_ret, T (Theme::*get_func)(const StringName &, const StringName &) const, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) {
-
// try with custom themes
Control *theme_owner = p_theme_owner;
Window *theme_owner_window = p_theme_owner_window;
while (theme_owner || theme_owner_window) {
-
StringName class_name = p_type;
while (class_name != StringName()) {
@@ -792,7 +763,6 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win
theme_owner = parent_w->theme_owner;
theme_owner_window = parent_w->theme_owner_window;
} else {
-
theme_owner = nullptr;
theme_owner_window = nullptr;
}
@@ -802,13 +772,11 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win
}
bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_window, bool (Theme::*has_func)(const StringName &, const StringName &) const, const StringName &p_name, const StringName &p_type) {
-
// try with custom themes
Control *theme_owner = p_theme_owner;
Window *theme_owner_window = p_theme_owner_window;
while (theme_owner || theme_owner_window) {
-
StringName class_name = p_type;
while (class_name != StringName()) {
@@ -836,7 +804,6 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind
theme_owner = parent_w->theme_owner;
theme_owner_window = parent_w->theme_owner_window;
} else {
-
theme_owner = nullptr;
theme_owner_window = nullptr;
}
@@ -846,12 +813,11 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind
}
Ref<Texture2D> Control::get_theme_icon(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
-
const Ref<Texture2D> *tex = data.icon_override.getptr(p_name);
- if (tex)
+ if (tex) {
return *tex;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -860,7 +826,6 @@ Ref<Texture2D> Control::get_theme_icon(const StringName &p_name, const StringNam
}
Ref<Texture2D> Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
Ref<Texture2D> icon;
if (_find_theme_item(p_theme_owner, p_theme_owner_window, icon, &Theme::get_icon, &Theme::has_icon, p_name, p_type)) {
@@ -877,12 +842,11 @@ Ref<Texture2D> Control::get_icons(Control *p_theme_owner, Window *p_theme_owner_
}
Ref<Shader> Control::get_theme_shader(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
-
const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
- if (sdr)
+ if (sdr) {
return *sdr;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -891,7 +855,6 @@ Ref<Shader> Control::get_theme_shader(const StringName &p_name, const StringName
}
Ref<Shader> Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
Ref<Shader> shader;
if (_find_theme_item(p_theme_owner, p_theme_owner_window, shader, &Theme::get_shader, &Theme::has_shader, p_name, p_type)) {
@@ -908,11 +871,11 @@ Ref<Shader> Control::get_shaders(Control *p_theme_owner, Window *p_theme_owner_w
}
Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<StyleBox> *style = data.style_override.getptr(p_name);
- if (style)
+ if (style) {
return *style;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -921,7 +884,6 @@ Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const String
}
Ref<StyleBox> Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
Ref<StyleBox> stylebox;
if (_find_theme_item(p_theme_owner, p_theme_owner_window, stylebox, &Theme::get_stylebox, &Theme::has_stylebox, p_name, p_type)) {
@@ -938,11 +900,11 @@ Ref<StyleBox> Control::get_styleboxs(Control *p_theme_owner, Window *p_theme_own
}
Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
const Ref<Font> *font = data.font_override.getptr(p_name);
- if (font)
+ if (font) {
return *font;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -951,7 +913,6 @@ Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_
}
Ref<Font> Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
Ref<Font> font;
if (_find_theme_item(p_theme_owner, p_theme_owner_window, font, &Theme::get_font, &Theme::has_font, p_name, p_type)) {
@@ -968,11 +929,11 @@ Ref<Font> Control::get_fonts(Control *p_theme_owner, Window *p_theme_owner_windo
}
Color Control::get_theme_color(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
const Color *color = data.color_override.getptr(p_name);
- if (color)
+ if (color) {
return *color;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -981,7 +942,6 @@ Color Control::get_theme_color(const StringName &p_name, const StringName &p_typ
}
Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
Color color;
if (_find_theme_item(p_theme_owner, p_theme_owner_window, color, &Theme::get_color, &Theme::has_color, p_name, p_type)) {
@@ -997,11 +957,11 @@ Color Control::get_colors(Control *p_theme_owner, Window *p_theme_owner_window,
}
int Control::get_theme_constant(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
const int *constant = data.constant_override.getptr(p_name);
- if (constant)
+ if (constant) {
return *constant;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1010,7 +970,6 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_ty
}
int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
int constant;
if (_find_theme_item(p_theme_owner, p_theme_owner_window, constant, &Theme::get_constant, &Theme::has_constant, p_name, p_type)) {
@@ -1026,46 +985,40 @@ int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window,
}
bool Control::has_theme_icon_override(const StringName &p_name) const {
-
const Ref<Texture2D> *tex = data.icon_override.getptr(p_name);
return tex != nullptr;
}
bool Control::has_theme_shader_override(const StringName &p_name) const {
-
const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
return sdr != nullptr;
}
bool Control::has_theme_stylebox_override(const StringName &p_name) const {
-
const Ref<StyleBox> *style = data.style_override.getptr(p_name);
return style != nullptr;
}
bool Control::has_theme_font_override(const StringName &p_name) const {
-
const Ref<Font> *font = data.font_override.getptr(p_name);
return font != nullptr;
}
bool Control::has_theme_color_override(const StringName &p_name) const {
-
const Color *color = data.color_override.getptr(p_name);
return color != nullptr;
}
bool Control::has_theme_constant_override(const StringName &p_name) const {
-
const int *constant = data.constant_override.getptr(p_name);
return constant != nullptr;
}
bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_icon_override(p_name))
+ if (has_theme_icon_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1074,7 +1027,6 @@ bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type)
}
bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_icon, p_name, p_type)) {
return true;
}
@@ -1088,18 +1040,18 @@ bool Control::has_icons(Control *p_theme_owner, Window *p_theme_owner_window, co
}
bool Control::has_theme_shader(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_shader_override(p_name))
+ if (has_theme_shader_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
return has_shaders(data.theme_owner, data.theme_owner_window, p_name, type);
}
-bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
+bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_shader, p_name, p_type)) {
return true;
}
@@ -1113,10 +1065,10 @@ bool Control::has_shaders(Control *p_theme_owner, Window *p_theme_owner_window,
}
bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_stylebox_override(p_name))
+ if (has_theme_stylebox_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1125,7 +1077,6 @@ bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_t
}
bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_stylebox, p_name, p_type)) {
return true;
}
@@ -1139,18 +1090,18 @@ bool Control::has_styleboxs(Control *p_theme_owner, Window *p_theme_owner_window
}
bool Control::has_theme_font(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_font_override(p_name))
+ if (has_theme_font_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
return has_fonts(data.theme_owner, data.theme_owner_window, p_name, type);
}
-bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
+bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_font, p_name, p_type)) {
return true;
}
@@ -1164,18 +1115,18 @@ bool Control::has_fonts(Control *p_theme_owner, Window *p_theme_owner_window, co
}
bool Control::has_theme_color(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_color_override(p_name))
+ if (has_theme_color_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
return has_colors(data.theme_owner, data.theme_owner_window, p_name, type);
}
-bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
+bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_color, p_name, p_type)) {
return true;
}
@@ -1189,10 +1140,10 @@ bool Control::has_colors(Control *p_theme_owner, Window *p_theme_owner_window, c
}
bool Control::has_theme_constant(const StringName &p_name, const StringName &p_type) const {
-
if (p_type == StringName() || p_type == get_class_name()) {
- if (has_theme_constant_override(p_name))
+ if (has_theme_constant_override(p_name)) {
return true;
+ }
}
StringName type = p_type ? p_type : get_class_name();
@@ -1201,7 +1152,6 @@ bool Control::has_theme_constant(const StringName &p_name, const StringName &p_t
}
bool Control::has_constants(Control *p_theme_owner, Window *p_theme_owner_window, const StringName &p_name, const StringName &p_type) {
-
if (_has_theme_item(p_theme_owner, p_theme_owner_window, &Theme::has_constant, p_name, p_type)) {
return true;
}
@@ -1215,8 +1165,9 @@ bool Control::has_constants(Control *p_theme_owner, Window *p_theme_owner_window
}
Rect2 Control::get_parent_anchorable_rect() const {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return Rect2();
+ }
Rect2 parent_rect;
if (data.parent_canvas_item) {
@@ -1229,18 +1180,15 @@ Rect2 Control::get_parent_anchorable_rect() const {
}
Size2 Control::get_parent_area_size() const {
-
return get_parent_anchorable_rect().size;
}
void Control::_size_changed() {
-
Rect2 parent_rect = get_parent_anchorable_rect();
float margin_pos[4];
for (int i = 0; i < 4; i++) {
-
float area = parent_rect.size[i & 1];
margin_pos[i] = data.margin[i] + (data.anchor[i] * area);
}
@@ -1293,7 +1241,6 @@ void Control::_size_changed() {
}
void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bool p_push_opposite_anchor) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
Rect2 parent_rect = get_parent_anchorable_rect();
@@ -1334,13 +1281,11 @@ void Control::_set_anchor(Margin p_margin, float p_anchor) {
}
void Control::set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor) {
-
set_anchor(p_margin, p_anchor, false, p_push_opposite_anchor);
set_margin(p_margin, p_pos);
}
void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) {
-
ERR_FAIL_INDEX((int)p_preset, 16);
//Left
@@ -1457,7 +1402,6 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) {
}
void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) {
-
ERR_FAIL_INDEX((int)p_preset, 16);
ERR_FAIL_INDEX((int)p_resize_mode, 4);
@@ -1594,14 +1538,12 @@ void Control::set_anchors_and_margins_preset(LayoutPreset p_preset, LayoutPreset
}
float Control::get_anchor(Margin p_margin) const {
-
ERR_FAIL_INDEX_V(int(p_margin), 4, 0.0);
return data.anchor[p_margin];
}
void Control::_change_notify_margins() {
-
// this avoids sending the whole object data again on a change
_change_notify("margin_left");
_change_notify("margin_top");
@@ -1612,7 +1554,6 @@ void Control::_change_notify_margins() {
}
void Control::set_margin(Margin p_margin, float p_value) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
data.margin[p_margin] = p_value;
@@ -1620,37 +1561,32 @@ void Control::set_margin(Margin p_margin, float p_value) {
}
void Control::set_begin(const Size2 &p_point) {
-
data.margin[0] = p_point.x;
data.margin[1] = p_point.y;
_size_changed();
}
void Control::set_end(const Size2 &p_point) {
-
data.margin[2] = p_point.x;
data.margin[3] = p_point.y;
_size_changed();
}
float Control::get_margin(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return data.margin[p_margin];
}
Size2 Control::get_begin() const {
-
return Size2(data.margin[0], data.margin[1]);
}
-Size2 Control::get_end() const {
+Size2 Control::get_end() const {
return Size2(data.margin[2], data.margin[3]);
}
Point2 Control::get_global_position() const {
-
return get_global_transform().get_origin();
}
@@ -1670,11 +1606,9 @@ void Control::_set_global_position(const Point2 &p_point) {
}
void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) {
-
Transform2D inv;
if (data.parent_canvas_item) {
-
inv = data.parent_canvas_item->get_global_transform().affine_inverse();
}
@@ -1682,7 +1616,6 @@ void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) {
}
void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r_anchors)[4]) {
-
Size2 parent_rect_size = get_parent_anchorable_rect().size;
ERR_FAIL_COND(parent_rect_size.x == 0.0);
ERR_FAIL_COND(parent_rect_size.y == 0.0);
@@ -1694,7 +1627,6 @@ void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r
}
void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) {
-
Size2 parent_rect_size = get_parent_anchorable_rect().size;
r_margins[0] = p_rect.position.x - (p_anchors[0] * parent_rect_size.x);
r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y);
@@ -1724,13 +1656,14 @@ void Control::_set_size(const Size2 &p_size) {
}
void Control::set_size(const Size2 &p_size, bool p_keep_margins) {
-
Size2 new_size = p_size;
Size2 min = get_combined_minimum_size();
- if (new_size.x < min.x)
+ if (new_size.x < min.x) {
new_size.x = min.x;
- if (new_size.y < min.y)
+ }
+ if (new_size.y < min.y) {
new_size.y = min.y;
+ }
if (p_keep_margins) {
_compute_anchors(Rect2(data.pos_cache, new_size), data.margin, data.anchor);
@@ -1745,22 +1678,18 @@ void Control::set_size(const Size2 &p_size, bool p_keep_margins) {
}
Size2 Control::get_position() const {
-
return data.pos_cache;
}
Size2 Control::get_size() const {
-
return data.size_cache;
}
Rect2 Control::get_global_rect() const {
-
return Rect2(get_global_position(), get_size());
}
Rect2 Control::get_screen_rect() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
Rect2 r(get_global_position(), get_size());
@@ -1781,17 +1710,14 @@ Rect2 Control::get_window_rect() const {
}
Rect2 Control::get_rect() const {
-
return Rect2(get_position(), get_size());
}
Rect2 Control::get_anchorable_rect() const {
-
return Rect2(Point2(), get_size());
}
void Control::add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) {
-
if (data.icon_override.has(p_name)) {
data.icon_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
}
@@ -1809,7 +1735,6 @@ void Control::add_theme_icon_override(const StringName &p_name, const Ref<Textur
}
void Control::add_theme_shader_override(const StringName &p_name, const Ref<Shader> &p_shader) {
-
if (data.shader_override.has(p_name)) {
data.shader_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
}
@@ -1825,8 +1750,8 @@ void Control::add_theme_shader_override(const StringName &p_name, const Ref<Shad
}
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {
+void Control::add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {
if (data.style_override.has(p_name)) {
data.style_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
}
@@ -1844,7 +1769,6 @@ void Control::add_theme_style_override(const StringName &p_name, const Ref<Style
}
void Control::add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font) {
-
if (data.font_override.has(p_name)) {
data.font_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed));
}
@@ -1860,46 +1784,45 @@ void Control::add_theme_font_override(const StringName &p_name, const Ref<Font>
}
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_theme_color_override(const StringName &p_name, const Color &p_color) {
+void Control::add_theme_color_override(const StringName &p_name, const Color &p_color) {
data.color_override[p_name] = p_color;
notification(NOTIFICATION_THEME_CHANGED);
}
-void Control::add_theme_constant_override(const StringName &p_name, int p_constant) {
+void Control::add_theme_constant_override(const StringName &p_name, int p_constant) {
data.constant_override[p_name] = p_constant;
notification(NOTIFICATION_THEME_CHANGED);
}
void Control::set_focus_mode(FocusMode p_focus_mode) {
-
ERR_FAIL_INDEX((int)p_focus_mode, 3);
- if (is_inside_tree() && p_focus_mode == FOCUS_NONE && data.focus_mode != FOCUS_NONE && has_focus())
+ if (is_inside_tree() && p_focus_mode == FOCUS_NONE && data.focus_mode != FOCUS_NONE && has_focus()) {
release_focus();
+ }
data.focus_mode = p_focus_mode;
}
static Control *_next_control(Control *p_from) {
-
- if (p_from->is_set_as_toplevel())
+ if (p_from->is_set_as_toplevel()) {
return nullptr; // can't go above
+ }
Control *parent = Object::cast_to<Control>(p_from->get_parent());
if (!parent) {
-
return nullptr;
}
int next = p_from->get_index();
ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr);
for (int i = (next + 1); i < parent->get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(parent->get_child(i));
- if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
+ }
return c;
}
@@ -1909,11 +1832,9 @@ static Control *_next_control(Control *p_from) {
}
Control *Control::find_next_valid_focus() const {
-
Control *from = const_cast<Control *>(this);
while (true) {
-
// If the focus property is manually overwritten, attempt to use it.
if (!data.focus_next.is_empty()) {
@@ -1925,8 +1846,9 @@ Control *Control::find_next_valid_focus() const {
} else {
return nullptr;
}
- if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE)
+ if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) {
return c;
+ }
}
// find next child
@@ -1934,7 +1856,6 @@ Control *Control::find_next_valid_focus() const {
Control *next_child = nullptr;
for (int i = 0; i < from->get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(from->get_child(i));
if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
@@ -1945,56 +1866,56 @@ Control *Control::find_next_valid_focus() const {
}
if (!next_child) {
-
next_child = _next_control(from);
if (!next_child) { //nothing else.. go up and find either window or subwindow
next_child = const_cast<Control *>(this);
while (next_child && !next_child->is_set_as_toplevel()) {
-
next_child = cast_to<Control>(next_child->get_parent());
}
if (!next_child) {
-
next_child = const_cast<Control *>(this);
while (next_child) {
-
- if (next_child->data.RI)
+ if (next_child->data.RI) {
break;
+ }
next_child = next_child->get_parent_control();
}
}
}
}
- if (next_child == this) // no next control->
+ if (next_child == this) { // no next control->
return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr;
+ }
if (next_child) {
- if (next_child->get_focus_mode() == FOCUS_ALL)
+ if (next_child->get_focus_mode() == FOCUS_ALL) {
return next_child;
+ }
from = next_child;
- } else
+ } else {
break;
+ }
}
return nullptr;
}
static Control *_prev_control(Control *p_from) {
-
Control *child = nullptr;
for (int i = p_from->get_child_count() - 1; i >= 0; i--) {
-
Control *c = Object::cast_to<Control>(p_from->get_child(i));
- if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
+ }
child = c;
break;
}
- if (!child)
+ if (!child) {
return p_from;
+ }
//no prev in parent, try the same in parent
return _prev_control(child);
@@ -2004,7 +1925,6 @@ Control *Control::find_prev_valid_focus() const {
Control *from = const_cast<Control *>(this);
while (true) {
-
// If the focus property is manually overwritten, attempt to use it.
if (!data.focus_prev.is_empty()) {
@@ -2016,8 +1936,9 @@ Control *Control::find_prev_valid_focus() const {
} else {
return nullptr;
}
- if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE)
+ if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) {
return c;
+ }
}
// find prev child
@@ -2025,15 +1946,12 @@ Control *Control::find_prev_valid_focus() const {
Control *prev_child = nullptr;
if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) {
-
//find last of the children
prev_child = _prev_control(from);
} else {
-
for (int i = (from->get_index() - 1); i >= 0; i--) {
-
Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i));
if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
@@ -2045,19 +1963,19 @@ Control *Control::find_prev_valid_focus() const {
}
if (!prev_child) {
-
prev_child = Object::cast_to<Control>(from->get_parent());
} else {
-
prev_child = _prev_control(prev_child);
}
}
- if (prev_child == this) // no prev control->
+ if (prev_child == this) { // no prev control->
return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr;
+ }
- if (prev_child->get_focus_mode() == FOCUS_ALL)
+ if (prev_child->get_focus_mode() == FOCUS_ALL) {
return prev_child;
+ }
from = prev_child;
}
@@ -2066,16 +1984,14 @@ Control *Control::find_prev_valid_focus() const {
}
Control::FocusMode Control::get_focus_mode() const {
-
return data.focus_mode;
}
-bool Control::has_focus() const {
+bool Control::has_focus() const {
return is_inside_tree() && get_viewport()->_gui_control_has_focus(this);
}
void Control::grab_focus() {
-
ERR_FAIL_COND(!is_inside_tree());
if (data.focus_mode == FOCUS_NONE) {
@@ -2087,40 +2003,38 @@ void Control::grab_focus() {
}
void Control::release_focus() {
-
ERR_FAIL_COND(!is_inside_tree());
- if (!has_focus())
+ if (!has_focus()) {
return;
+ }
get_viewport()->_gui_remove_focus();
update();
}
bool Control::is_toplevel_control() const {
-
return is_inside_tree() && (!data.parent_canvas_item && !data.RI && is_set_as_toplevel());
}
void Control::_propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_owner_window, bool p_assign) {
-
Control *c = Object::cast_to<Control>(p_at);
- if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
+ if (c && c != p_owner && c->data.theme.is_valid()) { // has a theme, this can't be propagated
return;
+ }
Window *w = c == nullptr ? Object::cast_to<Window>(p_at) : nullptr;
- if (w && w != p_owner_window && w->theme.is_valid()) // has a theme, this can't be propagated
+ if (w && w != p_owner_window && w->theme.is_valid()) { // has a theme, this can't be propagated
return;
+ }
for (int i = 0; i < p_at->get_child_count(); i++) {
-
CanvasItem *child = Object::cast_to<CanvasItem>(p_at->get_child(i));
if (child) {
_propagate_theme_changed(child, p_owner, p_owner_window, p_assign);
} else {
-
Window *window = Object::cast_to<Window>(p_at->get_child(i));
if (window) {
_propagate_theme_changed(window, p_owner, p_owner_window, p_assign);
@@ -2129,7 +2043,6 @@ void Control::_propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_o
}
if (c) {
-
if (p_assign) {
c->data.theme_owner = p_owner;
c->data.theme_owner_window = p_owner_window;
@@ -2139,7 +2052,6 @@ void Control::_propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_o
}
if (w) {
-
if (p_assign) {
w->theme_owner = p_owner;
w->theme_owner_window = p_owner_window;
@@ -2150,14 +2062,13 @@ void Control::_propagate_theme_changed(Node *p_at, Control *p_owner, Window *p_o
}
void Control::_theme_changed() {
-
_propagate_theme_changed(this, this, nullptr, false);
}
void Control::set_theme(const Ref<Theme> &p_theme) {
-
- if (data.theme == p_theme)
+ if (data.theme == p_theme) {
return;
+ }
if (data.theme.is_valid()) {
data.theme->disconnect("changed", callable_mp(this, &Control::_theme_changed));
@@ -2165,12 +2076,10 @@ void Control::set_theme(const Ref<Theme> &p_theme) {
data.theme = p_theme;
if (!p_theme.is_null()) {
-
data.theme_owner = this;
data.theme_owner_window = nullptr;
_propagate_theme_changed(this, this, nullptr);
} else {
-
Control *parent_c = Object::cast_to<Control>(get_parent());
if (parent_c && (parent_c->data.theme_owner || parent_c->data.theme_owner_window)) {
@@ -2191,26 +2100,24 @@ void Control::set_theme(const Ref<Theme> &p_theme) {
}
void Control::accept_event() {
-
- if (is_inside_tree())
+ if (is_inside_tree()) {
get_viewport()->_gui_accept_event();
+ }
}
Ref<Theme> Control::get_theme() const {
-
return data.theme;
}
void Control::set_tooltip(const String &p_tooltip) {
-
data.tooltip = p_tooltip;
update_configuration_warning();
}
String Control::get_tooltip(const Point2 &p_pos) const {
-
return data.tooltip;
}
+
Control *Control::make_custom_tooltip(const String &p_text) const {
if (get_script_instance()) {
return const_cast<Control *>(this)->call("_make_custom_tooltip", p_text);
@@ -2219,75 +2126,64 @@ Control *Control::make_custom_tooltip(const String &p_text) const {
}
void Control::set_default_cursor_shape(CursorShape p_shape) {
-
ERR_FAIL_INDEX(int(p_shape), CURSOR_MAX);
data.default_cursor = p_shape;
}
Control::CursorShape Control::get_default_cursor_shape() const {
-
return data.default_cursor;
}
-Control::CursorShape Control::get_cursor_shape(const Point2 &p_pos) const {
+Control::CursorShape Control::get_cursor_shape(const Point2 &p_pos) const {
return data.default_cursor;
}
Transform2D Control::get_transform() const {
-
Transform2D xform = _get_internal_transform();
xform[2] += get_position();
return xform;
}
String Control::_get_tooltip() const {
-
return data.tooltip;
}
void Control::set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
data.focus_neighbour[p_margin] = p_neighbour;
}
NodePath Control::get_focus_neighbour(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, NodePath());
return data.focus_neighbour[p_margin];
}
void Control::set_focus_next(const NodePath &p_next) {
-
data.focus_next = p_next;
}
NodePath Control::get_focus_next() const {
-
return data.focus_next;
}
void Control::set_focus_previous(const NodePath &p_prev) {
-
data.focus_prev = p_prev;
}
NodePath Control::get_focus_previous() const {
-
return data.focus_prev;
}
#define MAX_NEIGHBOUR_SEARCH_COUNT 512
Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, nullptr);
- if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT)
+ if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT) {
return nullptr;
+ }
if (!data.focus_neighbour[p_margin].is_empty()) {
-
Control *c = nullptr;
Node *n = get_node(data.focus_neighbour[p_margin]);
if (n) {
@@ -2297,12 +2193,15 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
return nullptr;
}
bool valid = true;
- if (!c->is_visible())
+ if (!c->is_visible()) {
valid = false;
- if (c->get_focus_mode() == FOCUS_NONE)
+ }
+ if (c->get_focus_mode() == FOCUS_NONE) {
valid = false;
- if (valid)
+ }
+ if (valid) {
return c;
+ }
c = c->_get_focus_neighbour(p_margin, p_count + 1);
return c;
@@ -2332,26 +2231,27 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
float maxd = -1e7;
for (int i = 0; i < 4; i++) {
-
float d = vdir.dot(points[i]);
- if (d > maxd)
+ if (d > maxd) {
maxd = d;
+ }
}
Node *base = this;
while (base) {
-
Control *c = Object::cast_to<Control>(base);
if (c) {
- if (c->data.RI)
+ if (c->data.RI) {
break;
+ }
}
base = base->get_parent();
}
- if (!base)
+ if (!base) {
return nullptr;
+ }
_window_find_focus_neighbour(vdir, base, points, maxd, dist, &result);
@@ -2359,14 +2259,13 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
}
void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest) {
-
- if (Object::cast_to<Viewport>(p_at))
+ if (Object::cast_to<Viewport>(p_at)) {
return; //bye
+ }
Control *c = Object::cast_to<Control>(p_at);
if (c && c != this && c->get_focus_mode() == FOCUS_ALL && c->is_visible_in_tree()) {
-
Point2 points[4];
Transform2D xform = c->get_global_transform();
@@ -2379,27 +2278,24 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
float min = 1e7;
for (int i = 0; i < 4; i++) {
-
float d = p_dir.dot(points[i]);
- if (d < min)
+ if (d < min) {
min = d;
+ }
}
if (min > (p_min - CMP_EPSILON)) {
-
for (int i = 0; i < 4; i++) {
-
Vector2 la = p_points[i];
Vector2 lb = p_points[(i + 1) % 4];
for (int j = 0; j < 4; j++) {
-
Vector2 fa = points[j];
Vector2 fb = points[(j + 1) % 4];
Vector2 pa, pb;
- float d = Geometry::get_closest_points_between_segments(la, lb, fa, fb, pa, pb);
- //float d = Geometry::get_closest_distance_between_segments(Vector3(la.x,la.y,0),Vector3(lb.x,lb.y,0),Vector3(fa.x,fa.y,0),Vector3(fb.x,fb.y,0));
+ float d = Geometry2D::get_closest_points_between_segments(la, lb, fa, fb, pa, pb);
+ //float d = Geometry2D::get_closest_distance_between_segments(Vector3(la.x,la.y,0),Vector3(lb.x,lb.y,0),Vector3(fa.x,fa.y,0),Vector3(fb.x,fb.y,0));
if (d < r_closest_dist) {
r_closest_dist = d;
*r_closest = c;
@@ -2410,19 +2306,19 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con
}
for (int i = 0; i < p_at->get_child_count(); i++) {
-
Node *child = p_at->get_child(i);
Control *childc = Object::cast_to<Control>(child);
- if (childc && childc->data.RI)
+ if (childc && childc->data.RI) {
continue; //subwindow, ignore
+ }
_window_find_focus_neighbour(p_dir, p_at->get_child(i), p_points, p_min, r_closest_dist, r_closest);
}
}
void Control::set_h_size_flags(int p_flags) {
-
- if (data.h_size_flags == p_flags)
+ if (data.h_size_flags == p_flags) {
return;
+ }
data.h_size_flags = p_flags;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
@@ -2430,47 +2326,47 @@ void Control::set_h_size_flags(int p_flags) {
int Control::get_h_size_flags() const {
return data.h_size_flags;
}
-void Control::set_v_size_flags(int p_flags) {
- if (data.v_size_flags == p_flags)
+void Control::set_v_size_flags(int p_flags) {
+ if (data.v_size_flags == p_flags) {
return;
+ }
data.v_size_flags = p_flags;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
void Control::set_stretch_ratio(float p_ratio) {
-
- if (data.expand == p_ratio)
+ if (data.expand == p_ratio) {
return;
+ }
data.expand = p_ratio;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
float Control::get_stretch_ratio() const {
-
return data.expand;
}
void Control::grab_click_focus() {
-
ERR_FAIL_COND(!is_inside_tree());
get_viewport()->_gui_grab_click_focus(this);
}
void Control::minimum_size_changed() {
-
- if (!is_inside_tree() || data.block_minimum_size_adjust)
+ if (!is_inside_tree() || data.block_minimum_size_adjust) {
return;
+ }
Control *invalidate = this;
//invalidate cache upwards
while (invalidate && invalidate->data.minimum_size_valid) {
invalidate->data.minimum_size_valid = false;
- if (invalidate->is_set_as_toplevel())
+ if (invalidate->is_set_as_toplevel()) {
break; // do not go further up
+ }
if (!invalidate->data.parent && get_parent()) {
Window *parent_window = Object::cast_to<Window>(get_parent());
if (parent_window && parent_window->is_wrapping_controls()) {
@@ -2480,11 +2376,13 @@ void Control::minimum_size_changed() {
invalidate = invalidate->data.parent;
}
- if (!is_visible_in_tree())
+ if (!is_visible_in_tree()) {
return;
+ }
- if (data.updating_last_minimum_size)
+ if (data.updating_last_minimum_size) {
return;
+ }
data.updating_last_minimum_size = true;
@@ -2496,19 +2394,16 @@ int Control::get_v_size_flags() const {
}
void Control::set_mouse_filter(MouseFilter p_filter) {
-
ERR_FAIL_INDEX(p_filter, 3);
data.mouse_filter = p_filter;
update_configuration_warning();
}
Control::MouseFilter Control::get_mouse_filter() const {
-
return data.mouse_filter;
}
Control *Control::get_focus_owner() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
return get_viewport()->_gui_get_focus_owner();
}
@@ -2533,7 +2428,6 @@ bool Control::is_text_field() const {
}
void Control::set_rotation(float p_radians) {
-
data.rotation = p_radians;
update();
_notify_transform();
@@ -2541,7 +2435,6 @@ void Control::set_rotation(float p_radians) {
}
float Control::get_rotation() const {
-
return data.rotation;
}
@@ -2554,14 +2447,12 @@ float Control::get_rotation_degrees() const {
}
void Control::_override_changed() {
-
notification(NOTIFICATION_THEME_CHANGED);
emit_signal(SceneStringNames::get_singleton()->theme_changed);
minimum_size_changed(); // overrides are likely to affect minimum size
}
void Control::set_pivot_offset(const Vector2 &p_pivot) {
-
data.pivot_offset = p_pivot;
update();
_notify_transform();
@@ -2569,39 +2460,38 @@ void Control::set_pivot_offset(const Vector2 &p_pivot) {
}
Vector2 Control::get_pivot_offset() const {
-
return data.pivot_offset;
}
void Control::set_scale(const Vector2 &p_scale) {
-
data.scale = p_scale;
// Avoid having 0 scale values, can lead to errors in physics and rendering.
- if (data.scale.x == 0)
+ if (data.scale.x == 0) {
data.scale.x = CMP_EPSILON;
- if (data.scale.y == 0)
+ }
+ if (data.scale.y == 0) {
data.scale.y = CMP_EPSILON;
+ }
update();
_notify_transform();
}
-Vector2 Control::get_scale() const {
+Vector2 Control::get_scale() const {
return data.scale;
}
Control *Control::get_root_parent_control() const {
-
const CanvasItem *ci = this;
const Control *root = this;
while (ci) {
-
const Control *c = Object::cast_to<Control>(ci);
if (c) {
root = c;
- if (c->data.RI || c->is_toplevel_control())
+ if (c->data.RI || c->is_toplevel_control()) {
break;
+ }
}
ci = ci->get_parent_item();
@@ -2615,23 +2505,19 @@ void Control::set_block_minimum_size_adjust(bool p_block) {
}
bool Control::is_minimum_size_adjust_blocked() const {
-
return data.block_minimum_size_adjust;
}
void Control::set_disable_visibility_clip(bool p_ignore) {
-
data.disable_visibility_clip = p_ignore;
update();
}
bool Control::is_visibility_clip_disabled() const {
-
return data.disable_visibility_clip;
}
void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
@@ -2674,18 +2560,15 @@ String Control::get_configuration_warning() const {
}
void Control::set_clip_contents(bool p_clip) {
-
data.clip_contents = p_clip;
update();
}
bool Control::is_clipping_contents() {
-
return data.clip_contents;
}
void Control::set_h_grow_direction(GrowDirection p_direction) {
-
ERR_FAIL_INDEX((int)p_direction, 3);
data.h_grow = p_direction;
@@ -2693,24 +2576,21 @@ void Control::set_h_grow_direction(GrowDirection p_direction) {
}
Control::GrowDirection Control::get_h_grow_direction() const {
-
return data.h_grow;
}
void Control::set_v_grow_direction(GrowDirection p_direction) {
-
ERR_FAIL_INDEX((int)p_direction, 3);
data.v_grow = p_direction;
_size_changed();
}
-Control::GrowDirection Control::get_v_grow_direction() const {
+Control::GrowDirection Control::get_v_grow_direction() const {
return data.v_grow;
}
void Control::_bind_methods() {
-
//ClassDB::bind_method(D_METHOD("_window_resize_event"),&Control::_window_resize_event);
ClassDB::bind_method(D_METHOD("_update_minimum_size"), &Control::_update_minimum_size);
@@ -2983,8 +2863,8 @@ void Control::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_point", PropertyInfo(Variant::VECTOR2, "point")));
}
-Control::Control() {
+Control::Control() {
data.parent = nullptr;
data.mouse_filter = MOUSE_FILTER_STOP;
diff --git a/scene/gui/control.h b/scene/gui/control.h
index d02fea20a6..10d6ad168f 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -44,7 +44,6 @@ class Label;
class Panel;
class Control : public CanvasItem {
-
GDCLASS(Control, CanvasItem);
OBJ_CATEGORY("GUI Nodes");
@@ -132,17 +131,16 @@ public:
private:
struct CComparator {
-
bool operator()(const Control *p_a, const Control *p_b) const {
- if (p_a->get_canvas_layer() == p_b->get_canvas_layer())
+ if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) {
return p_b->is_greater_than(p_a);
+ }
return p_a->get_canvas_layer() < p_b->get_canvas_layer();
}
};
struct Data {
-
Point2 pos_cache;
Size2 size_cache;
Size2 minimum_size_cache;
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 5654219a3e..c6897fc684 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -55,11 +55,9 @@ void AcceptDialog::_parent_focused() {
}
void AcceptDialog::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
-
get_ok()->grab_focus();
_update_child_rects();
parent_visible = get_parent_visible_window();
@@ -98,20 +96,18 @@ void AcceptDialog::_notification(int p_what) {
}
void AcceptDialog::_text_entered(const String &p_text) {
-
_ok_pressed();
}
void AcceptDialog::_ok_pressed() {
-
- if (hide_on_ok)
+ if (hide_on_ok) {
set_visible(false);
+ }
ok_pressed();
emit_signal("confirmed");
}
void AcceptDialog::_cancel_pressed() {
-
Window *parent_window = parent_visible;
if (parent_visible) {
parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
@@ -130,11 +126,10 @@ void AcceptDialog::_cancel_pressed() {
}
String AcceptDialog::get_text() const {
-
return label->get_text();
}
-void AcceptDialog::set_text(String p_text) {
+void AcceptDialog::set_text(String p_text) {
label->set_text(p_text);
child_controls_changed();
if (is_visible()) {
@@ -143,33 +138,30 @@ void AcceptDialog::set_text(String p_text) {
}
void AcceptDialog::set_hide_on_ok(bool p_hide) {
-
hide_on_ok = p_hide;
}
-bool AcceptDialog::get_hide_on_ok() const {
+bool AcceptDialog::get_hide_on_ok() const {
return hide_on_ok;
}
void AcceptDialog::set_autowrap(bool p_autowrap) {
-
label->set_autowrap(p_autowrap);
}
-bool AcceptDialog::has_autowrap() {
+bool AcceptDialog::has_autowrap() {
return label->has_autowrap();
}
void AcceptDialog::register_text_enter(Node *p_line_edit) {
-
ERR_FAIL_NULL(p_line_edit);
LineEdit *line_edit = Object::cast_to<LineEdit>(p_line_edit);
- if (line_edit)
+ if (line_edit) {
line_edit->connect("text_entered", callable_mp(this, &AcceptDialog::_text_entered));
+ }
}
void AcceptDialog::_update_child_rects() {
-
Size2 label_size = label->get_minimum_size();
if (label->get_text().empty()) {
label_size.height = 0;
@@ -183,11 +175,13 @@ void AcceptDialog::_update_child_rects() {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
- if (c == hbc || c == label || c == bg || c->is_set_as_toplevel())
+ if (c == hbc || c == label || c == bg || c->is_set_as_toplevel()) {
continue;
+ }
c->set_position(cpos);
c->set_size(csize);
@@ -204,17 +198,18 @@ void AcceptDialog::_update_child_rects() {
}
Size2 AcceptDialog::_get_contents_minimum_size() const {
-
int margin = hbc->get_theme_constant("margin", "Dialogs");
Size2 minsize = label->get_combined_minimum_size();
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
- if (c == hbc || c == label || c->is_set_as_toplevel())
+ if (c == hbc || c == label || c->is_set_as_toplevel()) {
continue;
+ }
Size2 cminsize = c->get_combined_minimum_size();
minsize.x = MAX(cminsize.x, minsize.x);
@@ -233,20 +228,17 @@ Size2 AcceptDialog::_get_contents_minimum_size() const {
}
void AcceptDialog::_custom_action(const String &p_action) {
-
emit_signal("custom_action", p_action);
custom_action(p_action);
}
Button *AcceptDialog::add_button(const String &p_text, bool p_right, const String &p_action) {
-
Button *button = memnew(Button);
button->set_text(p_text);
if (p_right) {
hbc->add_child(button);
hbc->add_spacer();
} else {
-
hbc->add_child(button);
hbc->move_child(button, 0);
hbc->add_spacer(true);
@@ -260,17 +252,16 @@ Button *AcceptDialog::add_button(const String &p_text, bool p_right, const Strin
}
Button *AcceptDialog::add_cancel(const String &p_cancel) {
-
String c = p_cancel;
- if (p_cancel == "")
+ if (p_cancel == "") {
c = RTR("Cancel");
+ }
Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c);
b->connect("pressed", callable_mp(this, &AcceptDialog::_cancel_pressed));
return b;
}
void AcceptDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_ok"), &AcceptDialog::get_ok);
ClassDB::bind_method(D_METHOD("get_label"), &AcceptDialog::get_label);
ClassDB::bind_method(D_METHOD("set_hide_on_ok", "enabled"), &AcceptDialog::set_hide_on_ok);
@@ -295,12 +286,10 @@ void AcceptDialog::_bind_methods() {
bool AcceptDialog::swap_ok_cancel = false;
void AcceptDialog::set_swap_ok_cancel(bool p_swap) {
-
swap_ok_cancel = p_swap;
}
AcceptDialog::AcceptDialog() {
-
parent_visible = nullptr;
set_wrap_controls(true);
@@ -344,17 +333,14 @@ AcceptDialog::~AcceptDialog() {
// ConfirmationDialog
void ConfirmationDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_cancel"), &ConfirmationDialog::get_cancel);
}
Button *ConfirmationDialog::get_cancel() {
-
return cancel;
}
ConfirmationDialog::ConfirmationDialog() {
-
set_title(RTR("Please Confirm..."));
#ifdef TOOLS_ENABLED
set_min_size(Size2(200, 70) * EDSCALE);
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index b68b4297d7..5d7b6272bf 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -42,7 +42,6 @@
class LineEdit;
class AcceptDialog : public Window {
-
GDCLASS(AcceptDialog, Window);
Window *parent_visible;
@@ -98,7 +97,6 @@ public:
};
class ConfirmationDialog : public AcceptDialog {
-
GDCLASS(ConfirmationDialog, AcceptDialog);
Button *cancel;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index a449d680a8..630f3c8ff6 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -45,7 +45,6 @@ VBoxContainer *FileDialog::get_vbox() {
}
void FileDialog::_theme_changed() {
-
Color font_color = vbox->get_theme_color("font_color", "ToolButton");
Color font_color_hover = vbox->get_theme_color("font_color_hover", "ToolButton");
Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "ToolButton");
@@ -64,15 +63,12 @@ void FileDialog::_theme_changed() {
}
void FileDialog::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (!is_visible()) {
-
set_process_unhandled_input(false);
}
}
if (p_what == NOTIFICATION_ENTER_TREE) {
-
dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog"));
refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog"));
show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog"));
@@ -81,18 +77,13 @@ void FileDialog::_notification(int p_what) {
}
void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && has_focus()) {
-
if (k->is_pressed()) {
-
bool handled = true;
switch (k->get_keycode()) {
-
case KEY_H: {
-
if (k->get_command()) {
set_show_hidden_files(!show_hidden_files);
} else {
@@ -101,11 +92,9 @@ void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
} break;
case KEY_F5: {
-
invalidate();
} break;
case KEY_BACKSPACE: {
-
_dir_entered("..");
} break;
default: {
@@ -113,24 +102,22 @@ void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
}
}
- if (handled)
+ if (handled) {
set_input_as_handled();
+ }
}
}
}
void FileDialog::set_enable_multiple_selection(bool p_enable) {
-
tree->set_select_mode(p_enable ? Tree::SELECT_MULTI : Tree::SELECT_SINGLE);
};
Vector<String> FileDialog::get_selected_files() const {
-
Vector<String> list;
TreeItem *item = tree->get_root();
while ((item = tree->get_next_selected(item))) {
-
list.push_back(dir_access->get_current_dir().plus_file(item->get_text(0)));
};
@@ -138,7 +125,6 @@ Vector<String> FileDialog::get_selected_files() const {
};
void FileDialog::update_dir() {
-
dir->set_text(dir_access->get_current_dir(false));
if (drives->is_visible()) {
@@ -150,7 +136,6 @@ void FileDialog::update_dir() {
}
void FileDialog::_dir_entered(String p_dir) {
-
dir_access->change_dir(p_dir);
file->set_text("");
invalidate();
@@ -158,7 +143,6 @@ void FileDialog::_dir_entered(String p_dir) {
}
void FileDialog::_file_entered(const String &p_file) {
-
_action_pressed();
}
@@ -169,16 +153,16 @@ void FileDialog::_save_confirm_pressed() {
}
void FileDialog::_post_popup() {
-
ConfirmationDialog::_post_popup();
if (invalidated) {
update_file_list();
invalidated = false;
}
- if (mode == FILE_MODE_SAVE_FILE)
+ if (mode == FILE_MODE_SAVE_FILE) {
file->grab_focus();
- else
+ } else {
tree->grab_focus();
+ }
set_process_unhandled_input(true);
@@ -192,15 +176,12 @@ void FileDialog::_post_popup() {
}
void FileDialog::_action_pressed() {
-
if (mode == FILE_MODE_OPEN_FILES) {
-
TreeItem *ti = tree->get_next_selected(nullptr);
String fbase = dir_access->get_current_dir();
Vector<String> files;
while (ti) {
-
files.push_back(fbase.plus_file(ti->get_text(0)));
ti = tree->get_next_selected(ti);
}
@@ -219,7 +200,6 @@ void FileDialog::_action_pressed() {
emit_signal("file_selected", f);
hide();
} else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) {
-
String path = dir_access->get_current_dir();
path = path.replace("\\", "/");
@@ -236,7 +216,6 @@ void FileDialog::_action_pressed() {
}
if (mode == FILE_MODE_SAVE_FILE) {
-
bool valid = false;
if (filter->get_selected() == filter->get_item_count() - 1) {
@@ -244,29 +223,27 @@ void FileDialog::_action_pressed() {
} else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
for (int i = 0; i < filters.size(); i++) {
-
String flt = filters[i].get_slice(";", 0);
for (int j = 0; j < flt.get_slice_count(","); j++) {
-
String str = flt.get_slice(",", j).strip_edges();
if (f.match(str)) {
valid = true;
break;
}
}
- if (valid)
+ if (valid) {
break;
+ }
}
} else {
int idx = filter->get_selected();
- if (filters.size() > 1)
+ if (filters.size() > 1) {
idx--;
+ }
if (idx >= 0 && idx < filters.size()) {
-
String flt = filters[idx].get_slice(";", 0);
int filterSliceCount = flt.get_slice_count(",");
for (int j = 0; j < filterSliceCount; j++) {
-
String str = (flt.get_slice(",", j).strip_edges());
if (f.match(str)) {
valid = true;
@@ -286,7 +263,6 @@ void FileDialog::_action_pressed() {
}
if (!valid) {
-
exterr->popup_centered(Size2(250, 80));
return;
}
@@ -295,7 +271,6 @@ void FileDialog::_action_pressed() {
confirm_save->set_text(RTR("File Exists, Overwrite?"));
confirm_save->popup_centered(Size2(200, 80));
} else {
-
emit_signal("file_selected", f);
hide();
}
@@ -303,27 +278,28 @@ void FileDialog::_action_pressed() {
}
void FileDialog::_cancel_pressed() {
-
file->set_text("");
invalidate();
hide();
}
bool FileDialog::_is_open_should_be_disabled() {
-
- if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE)
+ if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE) {
return false;
+ }
TreeItem *ti = tree->get_next_selected(tree->get_root());
while (ti) {
TreeItem *prev_ti = ti;
ti = tree->get_next_selected(tree->get_root());
- if (ti == prev_ti)
+ if (ti == prev_ti) {
break;
+ }
}
// We have something that we can't select?
- if (!ti)
+ if (!ti) {
return mode != FILE_MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder.
+ }
Dictionary d = ti->get_metadata(0);
@@ -333,14 +309,12 @@ bool FileDialog::_is_open_should_be_disabled() {
}
void FileDialog::_go_up() {
-
dir_access->change_dir("..");
update_file_list();
update_dir();
}
void FileDialog::deselect_items() {
-
// Clear currently selected items in file manager.
tree->deselect_all();
@@ -349,7 +323,6 @@ void FileDialog::deselect_items() {
get_ok()->set_disabled(_is_open_should_be_disabled());
switch (mode) {
-
case FILE_MODE_OPEN_FILE:
case FILE_MODE_OPEN_FILES:
get_ok()->set_text(RTR("Open"));
@@ -370,14 +343,13 @@ void FileDialog::_tree_multi_selected(Object *p_object, int p_cell, bool p_selec
}
void FileDialog::_tree_selected() {
-
TreeItem *ti = tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
Dictionary d = ti->get_metadata(0);
if (!d["dir"]) {
-
file->set_text(d["name"]);
} else if (mode == FILE_MODE_OPEN_DIR) {
get_ok()->set_text(RTR("Select This Folder"));
@@ -387,22 +359,21 @@ void FileDialog::_tree_selected() {
}
void FileDialog::_tree_item_activated() {
-
TreeItem *ti = tree->get_selected();
- if (!ti)
+ if (!ti) {
return;
+ }
Dictionary d = ti->get_metadata(0);
if (d["dir"]) {
-
dir_access->change_dir(d["name"]);
- if (mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES || mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY)
+ if (mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES || mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) {
file->set_text("");
+ }
call_deferred("_update_file_list");
call_deferred("_update_dir");
} else {
-
_action_pressed();
}
}
@@ -410,8 +381,9 @@ void FileDialog::_tree_item_activated() {
void FileDialog::update_file_name() {
int idx = filter->get_selected() - 1;
if ((idx == -1 && filter->get_item_count() == 2) || (filter->get_item_count() > 2 && idx >= 0 && idx < filter->get_item_count() - 2)) {
- if (idx == -1)
+ if (idx == -1) {
idx += 1;
+ }
String filter_str = filters[idx];
String file_str = file->get_text();
String base_name = file_str.get_basename();
@@ -421,7 +393,6 @@ void FileDialog::update_file_name() {
}
void FileDialog::update_file_list() {
-
tree->clear();
// Scroll back to the top after opening a directory
@@ -431,7 +402,9 @@ void FileDialog::update_file_list() {
TreeItem *root = tree->create_item();
Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog");
+ Ref<Texture2D> file_icon = vbox->get_theme_icon("file", "FileDialog");
const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog");
+ const Color file_color = vbox->get_theme_color("file_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@@ -439,17 +412,18 @@ void FileDialog::update_file_list() {
String item;
while ((item = dir_access->get_next()) != "") {
-
- if (item == "." || item == "..")
+ if (item == "." || item == "..") {
continue;
+ }
is_hidden = dir_access->current_is_hidden();
if (show_hidden_files || !is_hidden) {
- if (!dir_access->current_is_dir())
+ if (!dir_access->current_is_dir()) {
files.push_back(item);
- else
+ } else {
dirs.push_back(item);
+ }
}
}
@@ -475,28 +449,24 @@ void FileDialog::update_file_list() {
List<String> patterns;
// build filter
if (filter->get_selected() == filter->get_item_count() - 1) {
-
// match all
} else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
for (int i = 0; i < filters.size(); i++) {
-
String f = filters[i].get_slice(";", 0);
for (int j = 0; j < f.get_slice_count(","); j++) {
-
patterns.push_back(f.get_slice(",", j).strip_edges());
}
}
} else {
int idx = filter->get_selected();
- if (filters.size() > 1)
+ if (filters.size() > 1) {
idx--;
+ }
if (idx >= 0 && idx < filters.size()) {
-
String f = filters[idx].get_slice(";", 0);
for (int j = 0; j < f.get_slice_count(","); j++) {
-
patterns.push_back(f.get_slice(",", j).strip_edges());
}
}
@@ -505,12 +475,10 @@ void FileDialog::update_file_list() {
String base_dir = dir_access->get_current_dir();
while (!files.empty()) {
-
bool match = patterns.empty();
String match_str;
for (List<String>::Element *E = patterns.front(); E; E = E->next()) {
-
if (files.front()->get().matchn(E->get())) {
match_str = E->get();
match = true;
@@ -523,10 +491,12 @@ void FileDialog::update_file_list() {
ti->set_text(0, files.front()->get());
if (get_icon_func) {
-
Ref<Texture2D> icon = get_icon_func(base_dir.plus_file(files.front()->get()));
ti->set_icon(0, icon);
+ } else {
+ ti->set_icon(0, file_icon);
}
+ ti->set_icon_modulate(0, file_color);
if (mode == FILE_MODE_OPEN_DIR) {
ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog"));
@@ -537,25 +507,25 @@ void FileDialog::update_file_list() {
d["dir"] = false;
ti->set_metadata(0, d);
- if (file->get_text() == files.front()->get() || match_str == files.front()->get())
+ if (file->get_text() == files.front()->get() || match_str == files.front()->get()) {
ti->select(0);
+ }
}
files.pop_front();
}
- if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == nullptr)
+ if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == nullptr) {
tree->get_root()->get_children()->select(0);
+ }
}
void FileDialog::_filter_selected(int) {
-
update_file_name();
update_file_list();
}
void FileDialog::update_filters() {
-
filter->clear();
if (filters.size() > 1) {
@@ -565,37 +535,38 @@ void FileDialog::update_filters() {
for (int i = 0; i < MIN(max_filters, filters.size()); i++) {
String flt = filters[i].get_slice(";", 0).strip_edges();
- if (i > 0)
+ if (i > 0) {
all_filters += ", ";
+ }
all_filters += flt;
}
- if (max_filters < filters.size())
+ if (max_filters < filters.size()) {
all_filters += ", ...";
+ }
filter->add_item(RTR("All Recognized") + " (" + all_filters + ")");
}
for (int i = 0; i < filters.size(); i++) {
-
String flt = filters[i].get_slice(";", 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
- if (desc.length())
+ if (desc.length()) {
filter->add_item(String(tr(desc)) + " (" + flt + ")");
- else
+ } else {
filter->add_item("(" + flt + ")");
+ }
}
filter->add_item(RTR("All Files (*)"));
}
void FileDialog::clear_filters() {
-
filters.clear();
update_filters();
invalidate();
}
-void FileDialog::add_filter(const String &p_filter) {
+void FileDialog::add_filter(const String &p_filter) {
filters.push_back(p_filter);
update_filters();
invalidate();
@@ -612,45 +583,44 @@ Vector<String> FileDialog::get_filters() const {
}
String FileDialog::get_current_dir() const {
-
return dir->get_text();
}
-String FileDialog::get_current_file() const {
+String FileDialog::get_current_file() const {
return file->get_text();
}
-String FileDialog::get_current_path() const {
+String FileDialog::get_current_path() const {
return dir->get_text().plus_file(file->get_text());
}
-void FileDialog::set_current_dir(const String &p_dir) {
+void FileDialog::set_current_dir(const String &p_dir) {
dir_access->change_dir(p_dir);
update_dir();
invalidate();
}
-void FileDialog::set_current_file(const String &p_file) {
+void FileDialog::set_current_file(const String &p_file) {
file->set_text(p_file);
update_dir();
invalidate();
int lp = p_file.find_last(".");
if (lp != -1) {
file->select(0, lp);
- if (file->is_inside_tree() && !get_tree()->is_node_being_edited(file))
+ if (file->is_inside_tree() && !get_tree()->is_node_being_edited(file)) {
file->grab_focus();
+ }
}
}
-void FileDialog::set_current_path(const String &p_path) {
- if (!p_path.size())
+void FileDialog::set_current_path(const String &p_path) {
+ if (!p_path.size()) {
return;
+ }
int pos = MAX(p_path.find_last("/"), p_path.find_last("\\"));
if (pos == -1) {
-
set_current_file(p_path);
} else {
-
String dir = p_path.substr(0, pos);
String file = p_path.substr(pos + 1, p_path.length());
set_current_dir(dir);
@@ -667,40 +637,43 @@ bool FileDialog::is_mode_overriding_title() const {
}
void FileDialog::set_file_mode(FileMode p_mode) {
-
ERR_FAIL_INDEX((int)p_mode, 5);
mode = p_mode;
switch (mode) {
-
case FILE_MODE_OPEN_FILE:
get_ok()->set_text(RTR("Open"));
- if (mode_overrides_title)
+ if (mode_overrides_title) {
set_title(RTR("Open a File"));
+ }
makedir->hide();
break;
case FILE_MODE_OPEN_FILES:
get_ok()->set_text(RTR("Open"));
- if (mode_overrides_title)
+ if (mode_overrides_title) {
set_title(RTR("Open File(s)"));
+ }
makedir->hide();
break;
case FILE_MODE_OPEN_DIR:
get_ok()->set_text(RTR("Select Current Folder"));
- if (mode_overrides_title)
+ if (mode_overrides_title) {
set_title(RTR("Open a Directory"));
+ }
makedir->show();
break;
case FILE_MODE_OPEN_ANY:
get_ok()->set_text(RTR("Open"));
- if (mode_overrides_title)
+ if (mode_overrides_title) {
set_title(RTR("Open a File or Directory"));
+ }
makedir->show();
break;
case FILE_MODE_SAVE_FILE:
get_ok()->set_text(RTR("Save"));
- if (mode_overrides_title)
+ if (mode_overrides_title) {
set_title(RTR("Save a File"));
+ }
makedir->show();
break;
}
@@ -713,27 +686,23 @@ void FileDialog::set_file_mode(FileMode p_mode) {
}
FileDialog::FileMode FileDialog::get_file_mode() const {
-
return mode;
}
void FileDialog::set_access(Access p_access) {
-
ERR_FAIL_INDEX(p_access, 3);
- if (access == p_access)
+ if (access == p_access) {
return;
+ }
memdelete(dir_access);
switch (p_access) {
case ACCESS_FILESYSTEM: {
-
dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
} break;
case ACCESS_RESOURCES: {
-
dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
} break;
case ACCESS_USERDATA: {
-
dir_access = DirAccess::create(DirAccess::ACCESS_USERDATA);
} break;
}
@@ -745,7 +714,6 @@ void FileDialog::set_access(Access p_access) {
}
void FileDialog::invalidate() {
-
if (is_visible()) {
update_file_list();
invalidated = false;
@@ -755,12 +723,10 @@ void FileDialog::invalidate() {
}
FileDialog::Access FileDialog::get_access() const {
-
return access;
}
void FileDialog::_make_dir_confirm() {
-
Error err = dir_access->make_dir(makedirname->get_text());
if (err == OK) {
dir_access->change_dir(makedirname->get_text());
@@ -774,13 +740,11 @@ void FileDialog::_make_dir_confirm() {
}
void FileDialog::_make_dir() {
-
makedialog->popup_centered(Size2(250, 80));
makedirname->grab_focus();
}
void FileDialog::_select_drive(int p_idx) {
-
String d = drives->get_item_text(p_idx);
dir_access->change_dir(d);
file->set_text("");
@@ -789,7 +753,6 @@ void FileDialog::_select_drive(int p_idx) {
}
void FileDialog::_update_drives() {
-
int dc = dir_access->get_drive_count();
if (dc == 0 || access != ACCESS_FILESYSTEM) {
drives->hide();
@@ -814,7 +777,6 @@ void FileDialog::_update_drives() {
bool FileDialog::default_show_hidden_files = false;
void FileDialog::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_unhandled_input"), &FileDialog::_unhandled_input);
ClassDB::bind_method(D_METHOD("_cancel_pressed"), &FileDialog::_cancel_pressed);
@@ -884,7 +846,6 @@ void FileDialog::set_default_show_hidden_files(bool p_show) {
}
FileDialog::FileDialog() {
-
show_hidden_files = default_show_hidden_files;
mode_overrides_title = true;
@@ -997,13 +958,14 @@ FileDialog::FileDialog() {
set_hide_on_ok(false);
invalidated = true;
- if (register_func)
+ if (register_func) {
register_func(this);
+ }
}
FileDialog::~FileDialog() {
-
- if (unregister_func)
+ if (unregister_func) {
unregister_func(this);
+ }
memdelete(dir_access);
}
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index ac0e733abc..8bc536d576 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -40,7 +40,6 @@
#include "scene/gui/tree.h"
class FileDialog : public ConfirmationDialog {
-
GDCLASS(FileDialog, ConfirmationDialog);
public:
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index a6ed3d8de9..ecd4ad17ea 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -73,8 +73,9 @@ int GradientEdit::_get_point_from_pos(int x) {
}
void GradientEdit::_show_color_picker() {
- if (grabbed == -1)
+ if (grabbed == -1) {
return;
+ }
picker->set_pick_color(points[grabbed].color);
Size2 minsize = popup->get_contents_minimum_size();
bool show_above = false;
@@ -93,11 +94,9 @@ GradientEdit::~GradientEdit() {
}
void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && grabbed != -1) {
-
points.remove(grabbed);
grabbed = -1;
grabbing = false;
@@ -129,7 +128,6 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
//Hold alt key to duplicate selected color
if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed() && mb->get_alt()) {
-
int x = mb->get_position().x;
grabbed = _get_point_from_pos(x);
@@ -154,7 +152,6 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
//select
if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
-
update();
int x = mb->get_position().x;
int total_w = get_size().width - get_size().height - SPACING;
@@ -182,12 +179,12 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
int pos = -1;
for (int i = 0; i < points.size(); i++) {
- if (points[i].offset < newPoint.offset)
+ if (points[i].offset < newPoint.offset) {
pos = i;
+ }
}
if (pos == -1) {
-
prev.color = Color(0, 0, 0);
prev.offset = 0;
if (points.size()) {
@@ -197,7 +194,6 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
next.offset = 1.0;
}
} else {
-
if (pos == points.size() - 1) {
next.color = Color(1, 1, 1);
next.offset = 1.0;
@@ -222,7 +218,6 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) {
-
if (grabbing) {
grabbing = false;
emit_signal("ramp_changed");
@@ -233,7 +228,6 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && grabbing) {
-
int total_w = get_size().width - get_size().height - SPACING;
int x = mm->get_position().x;
@@ -256,24 +250,25 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
if (temp_ofs < smallest_ofs) {
smallest_ofs = temp_ofs;
nearest_point = i;
- if (found)
+ if (found) {
break;
+ }
found = true;
}
}
}
if (found) {
- if (points[nearest_point].offset < newofs)
+ if (points[nearest_point].offset < newofs) {
newofs = points[nearest_point].offset + 0.00001;
- else
+ } else {
newofs = points[nearest_point].offset - 0.00001;
+ }
newofs = CLAMP(newofs, 0, 1);
}
}
bool valid = true;
for (int i = 0; i < points.size(); i++) {
-
if (points[i].offset == newofs && i != grabbed) {
valid = false;
break;
@@ -300,19 +295,18 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
}
void GradientEdit::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
if (!picker->is_connected("color_changed", callable_mp(this, &GradientEdit::_color_changed))) {
picker->connect("color_changed", callable_mp(this, &GradientEdit::_color_changed));
}
}
if (p_what == NOTIFICATION_DRAW) {
-
int w = get_size().x;
int h = get_size().y;
- if (w == 0 || h == 0)
+ if (w == 0 || h == 0) {
return; //Safety check. We have division by 'h'. And in any case there is nothing to draw with such size
+ }
int total_w = get_size().width - get_size().height - SPACING;
@@ -322,20 +316,21 @@ void GradientEdit::_notification(int p_what) {
//Draw color ramp
Gradient::Point prev;
prev.offset = 0;
- if (points.size() == 0)
+ if (points.size() == 0) {
prev.color = Color(0, 0, 0); //Draw black rectangle if we have no points
- else
+ } else {
prev.color = points[0].color; //Extend color of first point to the beginning.
+ }
for (int i = -1; i < points.size(); i++) {
-
Gradient::Point next;
//If there is no next point
if (i + 1 == points.size()) {
- if (points.size() == 0)
+ if (points.size() == 0) {
next.color = Color(0, 0, 0); //Draw black rectangle if we have no points
- else
+ } else {
next.color = points[i].color; //Extend color of last point to the end.
+ }
next.offset = 1;
} else {
next = points[i + 1];
@@ -362,7 +357,6 @@ void GradientEdit::_notification(int p_what) {
//Draw point markers
for (int i = 0; i < points.size(); i++) {
-
Color col = points[i].color.contrasted();
col.a = 0.9;
@@ -397,7 +391,6 @@ void GradientEdit::_notification(int p_what) {
//Draw borders around color ramp if in focus
if (has_focus()) {
-
draw_line(Vector2(-1, -1), Vector2(total_w + 1, -1), Color(1, 1, 1, 0.6));
draw_line(Vector2(total_w + 1, -1), Vector2(total_w + 1, h + 1), Color(1, 1, 1, 0.6));
draw_line(Vector2(total_w + 1, h + 1), Vector2(-1, h + 1), Color(1, 1, 1, 0.6));
@@ -406,7 +399,6 @@ void GradientEdit::_notification(int p_what) {
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
if (!is_visible()) {
grabbing = false;
}
@@ -435,21 +427,19 @@ void GradientEdit::_draw_checker(int x, int y, int w, int h) {
}
Size2 GradientEdit::get_minimum_size() const {
-
return Vector2(0, 16);
}
void GradientEdit::_color_changed(const Color &p_color) {
-
- if (grabbed == -1)
+ if (grabbed == -1) {
return;
+ }
points.write[grabbed].color = p_color;
update();
emit_signal("ramp_changed");
}
void GradientEdit::set_ramp(const Vector<float> &p_offsets, const Vector<Color> &p_colors) {
-
ERR_FAIL_COND(p_offsets.size() != p_colors.size());
points.clear();
for (int i = 0; i < p_offsets.size(); i++) {
@@ -465,21 +455,24 @@ void GradientEdit::set_ramp(const Vector<float> &p_offsets, const Vector<Color>
Vector<float> GradientEdit::get_offsets() const {
Vector<float> ret;
- for (int i = 0; i < points.size(); i++)
+ for (int i = 0; i < points.size(); i++) {
ret.push_back(points[i].offset);
+ }
return ret;
}
Vector<Color> GradientEdit::get_colors() const {
Vector<Color> ret;
- for (int i = 0; i < points.size(); i++)
+ for (int i = 0; i < points.size(); i++) {
ret.push_back(points[i].color);
+ }
return ret;
}
void GradientEdit::set_points(Vector<Gradient::Point> &p_points) {
- if (points.size() != p_points.size())
+ if (points.size() != p_points.size()) {
grabbed = -1;
+ }
points.clear();
points = p_points;
}
diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h
index a38a3dde47..376837b66c 100644
--- a/scene/gui/gradient_edit.h
+++ b/scene/gui/gradient_edit.h
@@ -37,7 +37,6 @@
#include "scene/resources/gradient.h"
class GradientEdit : public Control {
-
GDCLASS(GradientEdit, Control);
PopupPanel *popup;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0bf67df9b4..5080ba74e2 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -44,19 +44,17 @@
#define MAX_ZOOM (1 * ZOOM_SCALE * ZOOM_SCALE * ZOOM_SCALE)
bool GraphEditFilter::has_point(const Point2 &p_point) const {
-
return ge->_filter_input(p_point);
}
GraphEditFilter::GraphEditFilter(GraphEdit *p_edit) {
-
ge = p_edit;
}
Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
-
- if (is_node_connected(p_from, p_from_port, p_to, p_to_port))
+ if (is_node_connected(p_from, p_from_port, p_to, p_to_port)) {
return OK;
+ }
Connection c;
c.from = p_from;
c.from_port = p_from_port;
@@ -72,22 +70,18 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S
}
bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
-
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port)
+ if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) {
return true;
+ }
}
return false;
}
void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
-
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) {
-
connections.erase(E);
top_layer->update();
update();
@@ -98,17 +92,14 @@ void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const
}
bool GraphEdit::clips_input() const {
-
return true;
}
void GraphEdit::get_connection_list(List<Connection> *r_connections) const {
-
*r_connections = connections;
}
void GraphEdit::set_scroll_ofs(const Vector2 &p_ofs) {
-
setting_scroll_ofs = true;
h_scroll->set_value(p_ofs.x);
v_scroll->set_value(p_ofs.y);
@@ -117,12 +108,10 @@ void GraphEdit::set_scroll_ofs(const Vector2 &p_ofs) {
}
Vector2 GraphEdit::get_scroll_ofs() const {
-
return Vector2(h_scroll->get_value(), v_scroll->get_value());
}
void GraphEdit::_scroll_moved(double) {
-
if (!awaiting_scroll_offset_update) {
call_deferred("_update_scroll_offset");
awaiting_scroll_offset_update = true;
@@ -136,14 +125,13 @@ void GraphEdit::_scroll_moved(double) {
}
void GraphEdit::_update_scroll_offset() {
-
set_block_minimum_size_adjust(true);
for (int i = 0; i < get_child_count(); i++) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
Point2 pos = gn->get_offset() * zoom;
pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
@@ -159,9 +147,9 @@ void GraphEdit::_update_scroll_offset() {
}
void GraphEdit::_update_scroll() {
-
- if (updating)
+ if (updating) {
return;
+ }
updating = true;
@@ -169,10 +157,10 @@ void GraphEdit::_update_scroll() {
Rect2 screen;
for (int i = 0; i < get_child_count(); i++) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
Rect2 r;
r.position = gn->get_offset() * zoom;
@@ -186,19 +174,21 @@ void GraphEdit::_update_scroll() {
h_scroll->set_min(screen.position.x);
h_scroll->set_max(screen.position.x + screen.size.x);
h_scroll->set_page(get_size().x);
- if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page())
+ if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page()) {
h_scroll->hide();
- else
+ } else {
h_scroll->show();
+ }
v_scroll->set_min(screen.position.y);
v_scroll->set_max(screen.position.y + screen.size.y);
v_scroll->set_page(get_size().y);
- if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page())
+ if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page()) {
v_scroll->hide();
- else
+ } else {
v_scroll->show();
+ }
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
@@ -218,7 +208,6 @@ void GraphEdit::_update_scroll() {
}
void GraphEdit::_graph_node_raised(Node *p_gn) {
-
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
ERR_FAIL_COND(!gn);
if (gn->is_comment()) {
@@ -241,7 +230,6 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
}
void GraphEdit::_graph_node_moved(Node *p_gn) {
-
GraphNode *gn = Object::cast_to<GraphNode>(p_gn);
ERR_FAIL_COND(!gn);
top_layer->update();
@@ -250,7 +238,6 @@ void GraphEdit::_graph_node_moved(Node *p_gn) {
}
void GraphEdit::add_child_notify(Node *p_child) {
-
Control::add_child_notify(p_child);
top_layer->call_deferred("raise"); //top layer always on top!
@@ -266,7 +253,6 @@ void GraphEdit::add_child_notify(Node *p_child) {
}
void GraphEdit::remove_child_notify(Node *p_child) {
-
Control::remove_child_notify(p_child);
if (is_inside_tree()) {
top_layer->call_deferred("raise"); //top layer always on top!
@@ -279,7 +265,6 @@ void GraphEdit::remove_child_notify(Node *p_child) {
}
void GraphEdit::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
port_grab_distance_horizontal = get_theme_constant("port_grab_distance_horizontal");
port_grab_distance_vertical = get_theme_constant("port_grab_distance_vertical");
@@ -304,7 +289,6 @@ void GraphEdit::_notification(int p_what) {
v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
}
if (p_what == NOTIFICATION_DRAW) {
-
draw_style_box(get_theme_stylebox("bg"), Rect2(Point2(), get_size()));
if (is_using_snap()) {
@@ -322,26 +306,26 @@ void GraphEdit::_notification(int p_what) {
Color grid_major = get_theme_color("grid_major");
for (int i = from.x; i < from.x + len.x; i++) {
-
Color color;
- if (ABS(i) % 10 == 0)
+ if (ABS(i) % 10 == 0) {
color = grid_major;
- else
+ } else {
color = grid_minor;
+ }
float base_ofs = i * snap * zoom - offset.x * zoom;
draw_line(Vector2(base_ofs, 0), Vector2(base_ofs, get_size().height), color);
}
for (int i = from.y; i < from.y + len.y; i++) {
-
Color color;
- if (ABS(i) % 10 == 0)
+ if (ABS(i) % 10 == 0) {
color = grid_major;
- else
+ } else {
color = grid_minor;
+ }
float base_ofs = i * snap * zoom - offset.y * zoom;
draw_line(Vector2(0, base_ofs), Vector2(get_size().width, base_ofs), color);
@@ -356,24 +340,22 @@ void GraphEdit::_notification(int p_what) {
}
bool GraphEdit::_filter_input(const Point2 &p_point) {
-
Ref<Texture2D> port = get_theme_icon("port", "GraphNode");
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
for (int j = 0; j < gn->get_connection_output_count(); j++) {
-
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
- if (is_in_hot_zone(pos, p_point))
+ if (is_in_hot_zone(pos, p_point)) {
return true;
+ }
}
for (int j = 0; j < gn->get_connection_input_count(); j++) {
-
Vector2 pos = gn->get_connection_input_position(j) + gn->get_position();
if (is_in_hot_zone(pos, p_point)) {
return true;
@@ -385,32 +367,25 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
}
void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventMouseButton> mb = p_ev;
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
-
Ref<Texture2D> port = get_theme_icon("port", "GraphNode");
Vector2 mpos(mb->get_position().x, mb->get_position().y);
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
for (int j = 0; j < gn->get_connection_output_count(); j++) {
-
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
if (is_in_hot_zone(pos, mpos)) {
-
if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) {
//check disconnect
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
if (E->get().from == gn->get_name() && E->get().from_port == j) {
-
Node *to = get_node(String(E->get().to));
if (Object::cast_to<GraphNode>(to)) {
-
connecting_from = E->get().to;
connecting_index = E->get().to_port;
connecting_out = false;
@@ -445,19 +420,14 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
}
for (int j = 0; j < gn->get_connection_input_count(); j++) {
-
Vector2 pos = gn->get_connection_input_position(j) + gn->get_position();
if (is_in_hot_zone(pos, mpos)) {
-
if (right_disconnects || valid_right_disconnect_types.has(gn->get_connection_input_type(j))) {
//check disconnect
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
if (E->get().to == gn->get_name() && E->get().to_port == j) {
-
Node *fr = get_node(String(E->get().from));
if (Object::cast_to<GraphNode>(fr)) {
-
connecting_from = E->get().from;
connecting_index = E->get().from_port;
connecting_out = true;
@@ -496,7 +466,6 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseMotion> mm = p_ev;
if (mm.is_valid() && connecting) {
-
connecting_to = mm->get_position();
connecting_target = false;
top_layer->update();
@@ -504,18 +473,16 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
Ref<Texture2D> port = get_theme_icon("port", "GraphNode");
Vector2 mpos = mm->get_position();
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
if (!connecting_out) {
for (int j = 0; j < gn->get_connection_output_count(); j++) {
-
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
int type = gn->get_connection_output_type(j);
if ((type == connecting_type || valid_connection_types.has(ConnType(type, connecting_type))) && is_in_hot_zone(pos, mpos)) {
-
connecting_target = true;
connecting_to = pos;
connecting_target_to = gn->get_name();
@@ -524,9 +491,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
}
}
} else {
-
for (int j = 0; j < gn->get_connection_input_count(); j++) {
-
Vector2 pos = gn->get_connection_input_position(j) + gn->get_position();
int type = gn->get_connection_input_type(j);
if ((type == connecting_type || valid_connection_types.has(ConnType(type, connecting_type))) && is_in_hot_zone(pos, mpos)) {
@@ -542,9 +507,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
-
if (connecting && connecting_target) {
-
String from = connecting_from;
int from_slot = connecting_index;
String to = connecting_target_to;
@@ -557,7 +520,6 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
emit_signal("connection_request", from, from_slot, to, to_slot);
} else if (!just_disconnected) {
-
String from = connecting_from;
int from_slot = connecting_index;
Vector2 ofs = Vector2(mb->get_position().x, mb->get_position().y);
@@ -577,16 +539,17 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
}
bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &pos) {
-
- if (p_control->is_set_as_toplevel() || !p_control->is_visible())
+ if (p_control->is_set_as_toplevel() || !p_control->is_visible()) {
return false;
+ }
if (!p_control->has_point(pos) || p_control->get_mouse_filter() == MOUSE_FILTER_IGNORE) {
//test children
for (int i = 0; i < p_control->get_child_count(); i++) {
Control *subchild = Object::cast_to<Control>(p_control->get_child(i));
- if (!subchild)
+ if (!subchild) {
continue;
+ }
if (_check_clickable_control(subchild, pos - subchild->get_position())) {
return true;
}
@@ -599,23 +562,25 @@ bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &pos)
}
bool GraphEdit::is_in_hot_zone(const Vector2 &pos, const Vector2 &p_mouse_pos) {
- if (!Rect2(pos.x - port_grab_distance_horizontal, pos.y - port_grab_distance_vertical, port_grab_distance_horizontal * 2, port_grab_distance_vertical * 2).has_point(p_mouse_pos))
+ if (!Rect2(pos.x - port_grab_distance_horizontal, pos.y - port_grab_distance_vertical, port_grab_distance_horizontal * 2, port_grab_distance_vertical * 2).has_point(p_mouse_pos)) {
return false;
+ }
for (int i = 0; i < get_child_count(); i++) {
Control *child = Object::cast_to<Control>(get_child(i));
- if (!child)
+ if (!child) {
continue;
+ }
Rect2 rect = child->get_rect();
if (rect.has_point(p_mouse_pos)) {
-
//check sub-controls
Vector2 subpos = p_mouse_pos - rect.position;
for (int j = 0; j < child->get_child_count(); j++) {
Control *subchild = Object::cast_to<Control>(child->get_child(j));
- if (!subchild)
+ if (!subchild) {
continue;
+ }
if (_check_clickable_control(subchild, subpos - subchild->get_position())) {
return false;
@@ -640,7 +605,6 @@ static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, Vector2 start, Vector2 co
}
void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const {
-
float mp = p_begin + (p_end - p_begin) * 0.5;
Vector2 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
Vector2 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b);
@@ -651,7 +615,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors,
float dp = Math::rad2deg(Math::acos(na.dot(nb)));
if (p_depth >= p_min_depth && (dp < p_tol || p_depth >= p_max_depth)) {
-
points.push_back((beg + end) * 0.5);
colors.push_back(p_color.lerp(p_to_color, mp));
lines++;
@@ -662,7 +625,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors,
}
void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color) {
-
//cubic bezier code
float diff = p_to.x - p_from.x;
float cp_offset;
@@ -696,12 +658,10 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
}
void GraphEdit::_connections_layer_draw() {
-
Color activity_color = get_theme_color("activity");
//draw connections
List<List<Connection>::Element *> to_erase;
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
NodePath fromnp(E->get().from);
Node *from = get_node(fromnp);
@@ -750,20 +710,19 @@ void GraphEdit::_connections_layer_draw() {
}
void GraphEdit::_top_layer_draw() {
-
_update_scroll();
if (connecting) {
-
Node *fromn = get_node(connecting_from);
ERR_FAIL_COND(!fromn);
GraphNode *from = Object::cast_to<GraphNode>(fromn);
ERR_FAIL_COND(!from);
Vector2 pos;
- if (connecting_out)
+ if (connecting_out) {
pos = from->get_connection_output_position(connecting_index);
- else
+ } else {
pos = from->get_connection_input_position(connecting_index);
+ }
pos += from->get_position();
Vector2 topos;
@@ -790,19 +749,17 @@ void GraphEdit::_top_layer_draw() {
}
void GraphEdit::set_selected(Node *p_child) {
-
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
gn->set_selected(gn == p_child);
}
}
void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventMouseMotion> mm = p_ev;
if (mm.is_valid() && (mm->get_button_mask() & BUTTON_MASK_MIDDLE || (mm->get_button_mask() & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
@@ -810,15 +767,11 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (mm.is_valid() && dragging) {
-
just_selected = true;
- // TODO: Remove local mouse pos hack if/when InputEventMouseMotion is fixed to support floats
- //drag_accum+=Vector2(mm->get_relative().x,mm->get_relative().y);
- drag_accum = get_local_mouse_position() - drag_origin;
+ drag_accum += mm->get_relative();
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (gn && gn->is_selected()) {
-
Vector2 pos = (gn->get_drag_from() * zoom + drag_accum) / zoom;
// Snapping can be toggled temporarily by holding down Ctrl.
@@ -834,7 +787,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (mm.is_valid() && box_selecting) {
- box_selecting_to = get_local_mouse_position();
+ box_selecting_to = mm->get_position();
box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
MIN(box_selecting_from.y, box_selecting_to.y),
@@ -842,19 +795,20 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
ABS(box_selecting_from.y - box_selecting_to.y));
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
Rect2 r = gn->get_rect();
r.size *= zoom;
bool in_box = r.intersects(box_selecting_rect);
- if (in_box)
+ if (in_box) {
gn->set_selected(box_selection_mode_additive);
- else
+ } else {
gn->set_selected(previus_selected.find(gn) != nullptr);
+ }
}
top_layer->update();
@@ -862,15 +816,14 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseButton> b = p_ev;
if (b.is_valid()) {
-
if (b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) {
if (box_selecting) {
box_selecting = false;
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (!gn)
+ if (!gn) {
continue;
+ }
gn->set_selected(previus_selected.find(gn) != nullptr);
}
@@ -894,20 +847,21 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (gn) {
Rect2 r = gn->get_rect();
r.size *= zoom;
- if (r.has_point(get_local_mouse_position()))
+ if (r.has_point(b->get_position())) {
gn->set_selected(false);
+ }
}
}
}
if (drag_accum != Vector2()) {
-
emit_signal("_begin_node_move");
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
- if (gn && gn->is_selected())
+ if (gn && gn->is_selected()) {
gn->set_drag(false);
+ }
}
emit_signal("_end_node_move");
@@ -921,18 +875,17 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
-
GraphNode *gn = nullptr;
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn_selected = Object::cast_to<GraphNode>(get_child(i));
if (gn_selected) {
- if (gn_selected->is_resizing())
+ if (gn_selected->is_resizing()) {
continue;
+ }
- if (gn_selected->has_point(gn_selected->get_local_mouse_position())) {
+ if (gn_selected->has_point(b->get_position() - gn_selected->get_position())) {
gn = gn_selected;
break;
}
@@ -940,13 +893,12 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
if (gn) {
-
- if (_filter_input(b->get_position()))
+ if (_filter_input(b->get_position())) {
return;
+ }
dragging = true;
drag_accum = Vector2();
- drag_origin = get_local_mouse_position();
just_selected = !gn->is_selected();
if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
@@ -967,28 +919,32 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
gn->set_selected(true);
for (int i = 0; i < get_child_count(); i++) {
GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i));
- if (!o_gn)
+ if (!o_gn) {
continue;
- if (o_gn->is_selected())
+ }
+ if (o_gn->is_selected()) {
o_gn->set_drag(true);
+ }
}
} else {
- if (_filter_input(b->get_position()))
+ if (_filter_input(b->get_position())) {
return;
- if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ }
+ if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
return;
+ }
box_selecting = true;
- box_selecting_from = get_local_mouse_position();
+ box_selecting_from = b->get_position();
if (b->get_control()) {
box_selection_mode_additive = true;
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
- if (!gn2 || !gn2->is_selected())
+ if (!gn2 || !gn2->is_selected()) {
continue;
+ }
previus_selected.push_back(gn2);
}
@@ -996,10 +952,10 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
box_selection_mode_additive = false;
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
- if (!gn2 || !gn2->is_selected())
+ if (!gn2 || !gn2->is_selected()) {
continue;
+ }
previus_selected.push_back(gn2);
}
@@ -1007,10 +963,10 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
box_selection_mode_additive = true;
previus_selected.clear();
for (int i = get_child_count() - 1; i >= 0; i--) {
-
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
- if (!gn2)
+ if (!gn2) {
continue;
+ }
if (gn2->is_selected()) {
emit_signal("node_unselected", gn2);
}
@@ -1052,7 +1008,6 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventKey> k = p_ev;
if (k.is_valid()) {
-
if (k->get_keycode() == KEY_D && k->is_pressed() && k->get_command()) {
emit_signal("duplicate_nodes_request");
accept_event();
@@ -1076,24 +1031,19 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_ev;
if (magnify_gesture.is_valid()) {
-
set_zoom_custom(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
}
Ref<InputEventPanGesture> pan_gesture = p_ev;
if (pan_gesture.is_valid()) {
-
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
}
}
void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port, float p_activity) {
-
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) {
-
if (Math::is_equal_approx(E->get().activity, p_activity)) {
//update only if changed
top_layer->update();
@@ -1106,22 +1056,20 @@ void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_por
}
void GraphEdit::clear_connections() {
-
connections.clear();
update();
connections_layer->update();
}
void GraphEdit::set_zoom(float p_zoom) {
-
set_zoom_custom(p_zoom, get_size() / 2);
}
void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) {
-
p_zoom = CLAMP(p_zoom, MIN_ZOOM, MAX_ZOOM);
- if (zoom == p_zoom)
+ if (zoom == p_zoom) {
return;
+ }
zoom_minus->set_disabled(zoom == MIN_ZOOM);
zoom_plus->set_disabled(zoom == MAX_ZOOM);
@@ -1135,7 +1083,6 @@ void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) {
connections_layer->update();
if (is_visible_in_tree()) {
-
Vector2 ofs = sbofs * zoom - p_center;
h_scroll->set_value(ofs.x);
v_scroll->set_value(ofs.y);
@@ -1149,37 +1096,30 @@ float GraphEdit::get_zoom() const {
}
void GraphEdit::set_right_disconnects(bool p_enable) {
-
right_disconnects = p_enable;
}
bool GraphEdit::is_right_disconnects_enabled() const {
-
return right_disconnects;
}
void GraphEdit::add_valid_right_disconnect_type(int p_type) {
-
valid_right_disconnect_types.insert(p_type);
}
void GraphEdit::remove_valid_right_disconnect_type(int p_type) {
-
valid_right_disconnect_types.erase(p_type);
}
void GraphEdit::add_valid_left_disconnect_type(int p_type) {
-
valid_left_disconnect_types.insert(p_type);
}
void GraphEdit::remove_valid_left_disconnect_type(int p_type) {
-
valid_left_disconnect_types.erase(p_type);
}
Array GraphEdit::_get_connection_list() const {
-
List<Connection> conns;
get_connection_list(&conns);
Array arr;
@@ -1195,21 +1135,18 @@ Array GraphEdit::_get_connection_list() const {
}
void GraphEdit::_zoom_minus() {
-
set_zoom(zoom / ZOOM_SCALE);
}
-void GraphEdit::_zoom_reset() {
+void GraphEdit::_zoom_reset() {
set_zoom(1);
}
void GraphEdit::_zoom_plus() {
-
set_zoom(zoom * ZOOM_SCALE);
}
void GraphEdit::add_valid_connection_type(int p_type, int p_with_type) {
-
ConnType ct;
ct.type_a = p_type;
ct.type_b = p_with_type;
@@ -1218,7 +1155,6 @@ void GraphEdit::add_valid_connection_type(int p_type, int p_with_type) {
}
void GraphEdit::remove_valid_connection_type(int p_type, int p_with_type) {
-
ConnType ct;
ct.type_a = p_type;
ct.type_b = p_with_type;
@@ -1227,7 +1163,6 @@ void GraphEdit::remove_valid_connection_type(int p_type, int p_with_type) {
}
bool GraphEdit::is_valid_connection_type(int p_type, int p_with_type) const {
-
ConnType ct;
ct.type_a = p_type;
ct.type_b = p_with_type;
@@ -1236,33 +1171,29 @@ bool GraphEdit::is_valid_connection_type(int p_type, int p_with_type) const {
}
void GraphEdit::set_use_snap(bool p_enable) {
-
snap_button->set_pressed(p_enable);
update();
}
bool GraphEdit::is_using_snap() const {
-
return snap_button->is_pressed();
}
int GraphEdit::get_snap() const {
-
return snap_amount->get_value();
}
void GraphEdit::set_snap(int p_snap) {
-
ERR_FAIL_COND(p_snap < 5);
snap_amount->set_value(p_snap);
update();
}
+
void GraphEdit::_snap_toggled() {
update();
}
void GraphEdit::_snap_value_changed(double) {
-
update();
}
@@ -1271,7 +1202,6 @@ HBoxContainer *GraphEdit::get_zoom_hbox() {
}
void GraphEdit::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("connect_node", "from", "from_port", "to", "to_port"), &GraphEdit::connect_node);
ClassDB::bind_method(D_METHOD("is_node_connected", "from", "from_port", "to", "to_port"), &GraphEdit::is_node_connected);
ClassDB::bind_method(D_METHOD("disconnect_node", "from", "from_port", "to", "to_port"), &GraphEdit::disconnect_node);
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index f675f8c7f3..c632490855 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -42,7 +42,6 @@
class GraphEdit;
class GraphEditFilter : public Control {
-
GDCLASS(GraphEditFilter, Control);
friend class GraphEdit;
@@ -54,7 +53,6 @@ public:
};
class GraphEdit : public Control {
-
GDCLASS(GraphEdit, Control);
public:
@@ -99,7 +97,6 @@ private:
bool dragging;
bool just_selected;
Vector2 drag_accum;
- Point2 drag_origin; // Workaround for GH-5907
float zoom;
@@ -142,7 +139,6 @@ private:
bool lines_on_bg;
struct ConnType {
-
union {
struct {
uint32_t type_a;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 5dbc5bc50d..b6a96238dc 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -33,31 +33,33 @@
#include "core/method_bind_ext.gen.inc"
bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
-
- if (!p_name.operator String().begins_with("slot/"))
+ if (!p_name.operator String().begins_with("slot/")) {
return false;
+ }
int idx = p_name.operator String().get_slice("/", 1).to_int();
String what = p_name.operator String().get_slice("/", 2);
Slot si;
- if (slot_info.has(idx))
+ if (slot_info.has(idx)) {
si = slot_info[idx];
+ }
- if (what == "left_enabled")
+ if (what == "left_enabled") {
si.enable_left = p_value;
- else if (what == "left_type")
+ } else if (what == "left_type") {
si.type_left = p_value;
- else if (what == "left_color")
+ } else if (what == "left_color") {
si.color_left = p_value;
- else if (what == "right_enabled")
+ } else if (what == "right_enabled") {
si.enable_right = p_value;
- else if (what == "right_type")
+ } else if (what == "right_type") {
si.type_right = p_value;
- else if (what == "right_color")
+ } else if (what == "right_color") {
si.color_right = p_value;
- else
+ } else {
return false;
+ }
set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right);
update();
@@ -65,7 +67,6 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
}
bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const {
-
if (!p_name.operator String().begins_with("slot/")) {
return false;
}
@@ -74,33 +75,36 @@ bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const {
String what = p_name.operator String().get_slice("/", 2);
Slot si;
- if (slot_info.has(idx))
+ if (slot_info.has(idx)) {
si = slot_info[idx];
+ }
- if (what == "left_enabled")
+ if (what == "left_enabled") {
r_ret = si.enable_left;
- else if (what == "left_type")
+ } else if (what == "left_type") {
r_ret = si.type_left;
- else if (what == "left_color")
+ } else if (what == "left_color") {
r_ret = si.color_left;
- else if (what == "right_enabled")
+ } else if (what == "right_enabled") {
r_ret = si.enable_right;
- else if (what == "right_type")
+ } else if (what == "right_type") {
r_ret = si.type_right;
- else if (what == "right_color")
+ } else if (what == "right_color") {
r_ret = si.color_right;
- else
+ } else {
return false;
+ }
return true;
}
-void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
+void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || c->is_set_as_toplevel())
+ if (!c || c->is_set_as_toplevel()) {
continue;
+ }
String base = "slot/" + itos(idx) + "/";
@@ -116,7 +120,6 @@ void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
}
void GraphNode::_resort() {
-
int sep = get_theme_constant("separation");
Ref<StyleBox> sb = get_theme_stylebox("frame");
bool first = true;
@@ -125,20 +128,23 @@ void GraphNode::_resort() {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2i size = c->get_combined_minimum_size();
minsize.y += size.y;
minsize.x = MAX(minsize.x, size.x);
- if (first)
+ if (first) {
first = false;
- else
+ } else {
minsize.y += sep;
+ }
}
int vofs = 0;
@@ -147,10 +153,12 @@ void GraphNode::_resort() {
cache_y.clear();
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2i size = c->get_combined_minimum_size();
@@ -167,7 +175,6 @@ void GraphNode::_resort() {
}
bool GraphNode::has_point(const Point2 &p_point) const {
-
if (comment) {
Ref<StyleBox> comment = get_theme_stylebox("comment");
Ref<Texture2D> resizer = get_theme_icon("resizer");
@@ -188,17 +195,14 @@ bool GraphNode::has_point(const Point2 &p_point) const {
}
void GraphNode::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
-
Ref<StyleBox> sb;
if (comment) {
sb = get_theme_stylebox(selected ? "commentfocus" : "comment");
} else {
-
sb = get_theme_stylebox(selected ? "selectedframe" : "frame");
}
@@ -223,10 +227,8 @@ void GraphNode::_notification(int p_what) {
switch (overlay) {
case OVERLAY_DISABLED: {
-
} break;
case OVERLAY_BREAKPOINT: {
-
draw_style_box(get_theme_stylebox("breakpoint"), Rect2(Point2(), get_size()));
} break;
case OVERLAY_POSITION: {
@@ -237,8 +239,9 @@ void GraphNode::_notification(int p_what) {
int w = get_size().width - sb->get_minimum_size().x;
- if (show_close)
+ if (show_close) {
w -= close->get_width();
+ }
draw_string(title_font, Point2(sb->get_margin(MARGIN_LEFT) + title_h_offset, -title_font->get_height() + title_font->get_ascent() + title_offset), title, title_color, w);
if (show_close) {
@@ -251,11 +254,12 @@ void GraphNode::_notification(int p_what) {
}
for (Map<int, Slot>::Element *E = slot_info.front(); E; E = E->next()) {
-
- if (E->key() < 0 || E->key() >= cache_y.size())
+ if (E->key() < 0 || E->key() >= cache_y.size()) {
continue;
- if (!slot_info.has(E->key()))
+ }
+ if (!slot_info.has(E->key())) {
continue;
+ }
const Slot &s = slot_info[E->key()];
//left
if (s.enable_left) {
@@ -280,19 +284,16 @@ void GraphNode::_notification(int p_what) {
} break;
case NOTIFICATION_SORT_CHILDREN: {
-
_resort();
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
} break;
}
}
void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) {
-
ERR_FAIL_COND(p_idx < 0);
if (!p_enable_left && p_type_left == 0 && p_color_left == Color(1, 1, 1, 1) && !p_enable_right && p_type_right == 0 && p_color_right == Color(1, 1, 1, 1)) {
@@ -315,61 +316,60 @@ void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const C
}
void GraphNode::clear_slot(int p_idx) {
-
slot_info.erase(p_idx);
update();
connpos_dirty = true;
}
-void GraphNode::clear_all_slots() {
+void GraphNode::clear_all_slots() {
slot_info.clear();
update();
connpos_dirty = true;
}
-bool GraphNode::is_slot_enabled_left(int p_idx) const {
- if (!slot_info.has(p_idx))
+bool GraphNode::is_slot_enabled_left(int p_idx) const {
+ if (!slot_info.has(p_idx)) {
return false;
+ }
return slot_info[p_idx].enable_left;
}
int GraphNode::get_slot_type_left(int p_idx) const {
-
- if (!slot_info.has(p_idx))
+ if (!slot_info.has(p_idx)) {
return 0;
+ }
return slot_info[p_idx].type_left;
}
Color GraphNode::get_slot_color_left(int p_idx) const {
-
- if (!slot_info.has(p_idx))
+ if (!slot_info.has(p_idx)) {
return Color(1, 1, 1, 1);
+ }
return slot_info[p_idx].color_left;
}
bool GraphNode::is_slot_enabled_right(int p_idx) const {
-
- if (!slot_info.has(p_idx))
+ if (!slot_info.has(p_idx)) {
return false;
+ }
return slot_info[p_idx].enable_right;
}
int GraphNode::get_slot_type_right(int p_idx) const {
-
- if (!slot_info.has(p_idx))
+ if (!slot_info.has(p_idx)) {
return 0;
+ }
return slot_info[p_idx].type_right;
}
Color GraphNode::get_slot_color_right(int p_idx) const {
-
- if (!slot_info.has(p_idx))
+ if (!slot_info.has(p_idx)) {
return Color(1, 1, 1, 1);
+ }
return slot_info[p_idx].color_right;
}
Size2 GraphNode::get_minimum_size() const {
-
Ref<Font> title_font = get_theme_font("title_font");
int sep = get_theme_constant("separation");
@@ -384,31 +384,33 @@ Size2 GraphNode::get_minimum_size() const {
}
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2i size = c->get_combined_minimum_size();
minsize.y += size.y;
minsize.x = MAX(minsize.x, size.x);
- if (first)
+ if (first) {
first = false;
- else
+ } else {
minsize.y += sep;
+ }
}
return minsize + sb->get_minimum_size();
}
void GraphNode::set_title(const String &p_title) {
-
- if (title == p_title)
+ if (title == p_title) {
return;
+ }
title = p_title;
update();
_change_notify("title");
@@ -416,19 +418,16 @@ void GraphNode::set_title(const String &p_title) {
}
String GraphNode::get_title() const {
-
return title;
}
void GraphNode::set_offset(const Vector2 &p_offset) {
-
offset = p_offset;
emit_signal("offset_changed");
update();
}
Vector2 GraphNode::get_offset() const {
-
return offset;
}
@@ -442,10 +441,11 @@ bool GraphNode::is_selected() {
}
void GraphNode::set_drag(bool p_drag) {
- if (p_drag)
+ if (p_drag) {
drag_from = get_offset();
- else
+ } else {
emit_signal("dragged", drag_from, get_offset()); //useful for undo/redo
+ }
}
Vector2 GraphNode::get_drag_from() {
@@ -453,17 +453,15 @@ Vector2 GraphNode::get_drag_from() {
}
void GraphNode::set_show_close_button(bool p_enable) {
-
show_close = p_enable;
update();
}
-bool GraphNode::is_close_button_visible() const {
+bool GraphNode::is_close_button_visible() const {
return show_close;
}
void GraphNode::_connpos_update() {
-
int edgeofs = get_theme_constant("port_offset");
int sep = get_theme_constant("separation");
@@ -476,10 +474,12 @@ void GraphNode::_connpos_update() {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2i size = c->get_combined_minimum_size();
@@ -487,7 +487,6 @@ void GraphNode::_connpos_update() {
int h = size.y;
if (slot_info.has(idx)) {
-
if (slot_info[idx].enable_left) {
ConnCache cc;
cc.pos = Point2i(edgeofs, y + h / 2);
@@ -504,8 +503,9 @@ void GraphNode::_connpos_update() {
}
}
- if (vofs > 0)
+ if (vofs > 0) {
vofs += sep;
+ }
vofs += size.y;
idx++;
}
@@ -514,24 +514,25 @@ void GraphNode::_connpos_update() {
}
int GraphNode::get_connection_input_count() {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
return conn_input_cache.size();
}
-int GraphNode::get_connection_output_count() {
- if (connpos_dirty)
+int GraphNode::get_connection_output_count() {
+ if (connpos_dirty) {
_connpos_update();
+ }
return conn_output_cache.size();
}
Vector2 GraphNode::get_connection_input_position(int p_idx) {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), Vector2());
Vector2 pos = conn_input_cache[p_idx].pos;
@@ -541,27 +542,27 @@ Vector2 GraphNode::get_connection_input_position(int p_idx) {
}
int GraphNode::get_connection_input_type(int p_idx) {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), 0);
return conn_input_cache[p_idx].type;
}
Color GraphNode::get_connection_input_color(int p_idx) {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), Color());
return conn_input_cache[p_idx].color;
}
Vector2 GraphNode::get_connection_output_position(int p_idx) {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), Vector2());
Vector2 pos = conn_output_cache[p_idx].pos;
@@ -571,32 +572,29 @@ Vector2 GraphNode::get_connection_output_position(int p_idx) {
}
int GraphNode::get_connection_output_type(int p_idx) {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), 0);
return conn_output_cache[p_idx].type;
}
Color GraphNode::get_connection_output_color(int p_idx) {
-
- if (connpos_dirty)
+ if (connpos_dirty) {
_connpos_update();
+ }
ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), Color());
return conn_output_cache[p_idx].color;
}
void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
-
Ref<InputEventMouseButton> mb = p_ev;
if (mb.is_valid()) {
-
ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphNode must be the child of a GraphEdit node.");
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
Vector2 mpos = Vector2(mb->get_position().x, mb->get_position().y);
if (close_rect.size != Size2() && close_rect.has_point(mpos)) {
//send focus to parent
@@ -609,7 +607,6 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<Texture2D> resizer = get_theme_icon("resizer");
if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
-
resizing = true;
resizing_from = mpos;
resizing_from_size = get_size();
@@ -636,40 +633,33 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
}
void GraphNode::set_overlay(Overlay p_overlay) {
-
overlay = p_overlay;
update();
}
GraphNode::Overlay GraphNode::get_overlay() const {
-
return overlay;
}
void GraphNode::set_comment(bool p_enable) {
-
comment = p_enable;
update();
}
bool GraphNode::is_comment() const {
-
return comment;
}
void GraphNode::set_resizable(bool p_enable) {
-
resizable = p_enable;
update();
}
bool GraphNode::is_resizable() const {
-
return resizable;
}
void GraphNode::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_title", "title"), &GraphNode::set_title);
ClassDB::bind_method(D_METHOD("get_title"), &GraphNode::get_title);
ClassDB::bind_method(D_METHOD("_gui_input"), &GraphNode::_gui_input);
@@ -732,7 +722,6 @@ void GraphNode::_bind_methods() {
}
GraphNode::GraphNode() {
-
overlay = OVERLAY_DISABLED;
show_close = false;
connpos_dirty = true;
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index a3eb8ed152..6372833e6f 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class GraphNode : public Container {
-
GDCLASS(GraphNode, Container);
public:
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 16f6fd0111..2f37461c4d 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -31,11 +31,8 @@
#include "grid_container.h"
void GridContainer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_SORT_CHILDREN: {
-
Map<int, int> col_minw; // Max of min_width of all controls in each col (indexed by col).
Map<int, int> row_minh; // Max of min_height of all controls in each row (indexed by row).
Set<int> col_expanded; // Columns which have the SIZE_EXPAND flag set.
@@ -50,22 +47,25 @@ void GridContainer::_notification(int p_what) {
int valid_controls_index = 0;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
+ }
int row = valid_controls_index / columns;
int col = valid_controls_index % columns;
valid_controls_index++;
Size2i ms = c->get_combined_minimum_size();
- if (col_minw.has(col))
+ if (col_minw.has(col)) {
col_minw[col] = MAX(col_minw[col], ms.width);
- else
+ } else {
col_minw[col] = ms.width;
- if (row_minh.has(row))
+ }
+ if (row_minh.has(row)) {
row_minh[row] = MAX(row_minh[row], ms.height);
- else
+ } else {
row_minh[row] = ms.height;
+ }
if (c->get_h_size_flags() & SIZE_EXPAND) {
col_expanded.insert(col);
@@ -83,13 +83,15 @@ void GridContainer::_notification(int p_what) {
// Evaluate the remaining space for expanded columns/rows.
Size2 remaining_space = get_size();
for (Map<int, int>::Element *E = col_minw.front(); E; E = E->next()) {
- if (!col_expanded.has(E->key()))
+ if (!col_expanded.has(E->key())) {
remaining_space.width -= E->get();
+ }
}
for (Map<int, int>::Element *E = row_minh.front(); E; E = E->next()) {
- if (!row_expanded.has(E->key()))
+ if (!row_expanded.has(E->key())) {
remaining_space.height -= E->get();
+ }
}
remaining_space.height -= vsep * MAX(max_row - 1, 0);
remaining_space.width -= hsep * MAX(max_col - 1, 0);
@@ -146,16 +148,18 @@ void GridContainer::_notification(int p_what) {
valid_controls_index = 0;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
+ }
int row = valid_controls_index / columns;
int col = valid_controls_index % columns;
valid_controls_index++;
if (col == 0) {
col_ofs = 0;
- if (row > 0)
+ if (row > 0) {
row_ofs += (row_expanded.has(row - 1) ? row_expand : row_minh[row - 1]) + vsep;
+ }
}
Point2 p(col_ofs, row_ofs);
@@ -168,14 +172,12 @@ void GridContainer::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
} break;
}
}
void GridContainer::set_columns(int p_columns) {
-
ERR_FAIL_COND(p_columns < 1);
columns = p_columns;
queue_sort();
@@ -183,12 +185,10 @@ void GridContainer::set_columns(int p_columns) {
}
int GridContainer::get_columns() const {
-
return columns;
}
void GridContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_columns", "columns"), &GridContainer::set_columns);
ClassDB::bind_method(D_METHOD("get_columns"), &GridContainer::get_columns);
@@ -196,7 +196,6 @@ void GridContainer::_bind_methods() {
}
Size2 GridContainer::get_minimum_size() const {
-
Map<int, int> col_minw;
Map<int, int> row_minh;
@@ -208,24 +207,26 @@ Size2 GridContainer::get_minimum_size() const {
int valid_controls_index = 0;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible()) {
continue;
+ }
int row = valid_controls_index / columns;
int col = valid_controls_index % columns;
valid_controls_index++;
Size2i ms = c->get_combined_minimum_size();
- if (col_minw.has(col))
+ if (col_minw.has(col)) {
col_minw[col] = MAX(col_minw[col], ms.width);
- else
+ } else {
col_minw[col] = ms.width;
+ }
- if (row_minh.has(row))
+ if (row_minh.has(row)) {
row_minh[row] = MAX(row_minh[row], ms.height);
- else
+ } else {
row_minh[row] = ms.height;
+ }
max_col = MAX(col, max_col);
max_row = MAX(row, max_row);
}
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index 0ed8863196..0a1bd6751a 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class GridContainer : public Container {
-
GDCLASS(GridContainer, Container);
int columns;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 47a5ac68d2..54150d130d 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -33,7 +33,6 @@
#include "core/project_settings.h"
void ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bool p_selectable) {
-
Item item;
item.icon = p_texture;
item.icon_transposed = false;
@@ -52,7 +51,6 @@ void ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, b
}
void ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) {
-
Item item;
item.icon = p_item;
item.icon_transposed = false;
@@ -71,7 +69,6 @@ void ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) {
}
void ItemList::set_item_text(int p_idx, const String &p_text) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].text = p_text;
@@ -80,7 +77,6 @@ void ItemList::set_item_text(int p_idx, const String &p_text) {
}
String ItemList::get_item_text(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), String());
return items[p_idx].text;
}
@@ -96,7 +92,6 @@ bool ItemList::is_item_tooltip_enabled(int p_idx) const {
}
void ItemList::set_item_tooltip(int p_idx, const String &p_tooltip) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].tooltip = p_tooltip;
@@ -105,13 +100,11 @@ void ItemList::set_item_tooltip(int p_idx, const String &p_tooltip) {
}
String ItemList::get_item_tooltip(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), String());
return items[p_idx].tooltip;
}
void ItemList::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].icon = p_icon;
@@ -120,14 +113,12 @@ void ItemList::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
}
Ref<Texture2D> ItemList::get_item_icon(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>());
return items[p_idx].icon;
}
void ItemList::set_item_icon_transposed(int p_idx, const bool p_transposed) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].icon_transposed = p_transposed;
@@ -136,14 +127,12 @@ void ItemList::set_item_icon_transposed(int p_idx, const bool p_transposed) {
}
bool ItemList::is_item_icon_transposed(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].icon_transposed;
}
void ItemList::set_item_icon_region(int p_idx, const Rect2 &p_region) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].icon_region = p_region;
@@ -152,14 +141,12 @@ void ItemList::set_item_icon_region(int p_idx, const Rect2 &p_region) {
}
Rect2 ItemList::get_item_icon_region(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Rect2());
return items[p_idx].icon_region;
}
void ItemList::set_item_icon_modulate(int p_idx, const Color &p_modulate) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].icon_modulate = p_modulate;
@@ -167,70 +154,61 @@ void ItemList::set_item_icon_modulate(int p_idx, const Color &p_modulate) {
}
Color ItemList::get_item_icon_modulate(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
return items[p_idx].icon_modulate;
}
void ItemList::set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].custom_bg = p_custom_bg_color;
}
Color ItemList::get_item_custom_bg_color(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
return items[p_idx].custom_bg;
}
void ItemList::set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].custom_fg = p_custom_fg_color;
}
Color ItemList::get_item_custom_fg_color(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
return items[p_idx].custom_fg;
}
void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].tag_icon = p_tag_icon;
update();
shape_changed = true;
}
-Ref<Texture2D> ItemList::get_item_tag_icon(int p_idx) const {
+Ref<Texture2D> ItemList::get_item_tag_icon(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>());
return items[p_idx].tag_icon;
}
void ItemList::set_item_selectable(int p_idx, bool p_selectable) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].selectable = p_selectable;
}
bool ItemList::is_item_selectable(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].selectable;
}
void ItemList::set_item_disabled(int p_idx, bool p_disabled) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].disabled = p_disabled;
@@ -238,13 +216,11 @@ void ItemList::set_item_disabled(int p_idx, bool p_disabled) {
}
bool ItemList::is_item_disabled(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].disabled;
}
void ItemList::set_item_metadata(int p_idx, const Variant &p_metadata) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].metadata = p_metadata;
@@ -253,16 +229,14 @@ void ItemList::set_item_metadata(int p_idx, const Variant &p_metadata) {
}
Variant ItemList::get_item_metadata(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Variant());
return items[p_idx].metadata;
}
-void ItemList::select(int p_idx, bool p_single) {
+void ItemList::select(int p_idx, bool p_single) {
ERR_FAIL_INDEX(p_idx, items.size());
if (p_single || select_mode == SELECT_SINGLE) {
-
if (!items[p_idx].selectable || items[p_idx].disabled) {
return;
}
@@ -274,15 +248,14 @@ void ItemList::select(int p_idx, bool p_single) {
current = p_idx;
ensure_selected_visible = false;
} else {
-
if (items[p_idx].selectable && !items[p_idx].disabled) {
items.write[p_idx].selected = true;
}
}
update();
}
-void ItemList::unselect(int p_idx) {
+void ItemList::unselect(int p_idx) {
ERR_FAIL_INDEX(p_idx, items.size());
if (select_mode != SELECT_MULTI) {
@@ -295,12 +268,11 @@ void ItemList::unselect(int p_idx) {
}
void ItemList::unselect_all() {
-
- if (items.size() < 1)
+ if (items.size() < 1) {
return;
+ }
for (int i = 0; i < items.size(); i++) {
-
items.write[i].selected = false;
}
current = -1;
@@ -308,7 +280,6 @@ void ItemList::unselect_all() {
}
bool ItemList::is_selected(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].selected;
@@ -317,21 +288,19 @@ bool ItemList::is_selected(int p_idx) const {
void ItemList::set_current(int p_current) {
ERR_FAIL_INDEX(p_current, items.size());
- if (select_mode == SELECT_SINGLE)
+ if (select_mode == SELECT_SINGLE) {
select(p_current, true);
- else {
+ } else {
current = p_current;
update();
}
}
int ItemList::get_current() const {
-
return current;
}
void ItemList::move_item(int p_from_idx, int p_to_idx) {
-
ERR_FAIL_INDEX(p_from_idx, items.size());
ERR_FAIL_INDEX(p_to_idx, items.size());
@@ -348,11 +317,10 @@ void ItemList::move_item(int p_from_idx, int p_to_idx) {
}
int ItemList::get_item_count() const {
-
return items.size();
}
-void ItemList::remove_item(int p_idx) {
+void ItemList::remove_item(int p_idx) {
ERR_FAIL_INDEX(p_idx, items.size());
items.remove(p_idx);
@@ -362,7 +330,6 @@ void ItemList::remove_item(int p_idx) {
}
void ItemList::clear() {
-
items.clear();
current = -1;
ensure_selected_visible = false;
@@ -372,65 +339,58 @@ void ItemList::clear() {
}
void ItemList::set_fixed_column_width(int p_size) {
-
ERR_FAIL_COND(p_size < 0);
fixed_column_width = p_size;
update();
shape_changed = true;
}
-int ItemList::get_fixed_column_width() const {
+int ItemList::get_fixed_column_width() const {
return fixed_column_width;
}
void ItemList::set_same_column_width(bool p_enable) {
-
same_column_width = p_enable;
update();
shape_changed = true;
}
-bool ItemList::is_same_column_width() const {
+bool ItemList::is_same_column_width() const {
return same_column_width;
}
void ItemList::set_max_text_lines(int p_lines) {
-
ERR_FAIL_COND(p_lines < 1);
max_text_lines = p_lines;
update();
shape_changed = true;
}
-int ItemList::get_max_text_lines() const {
+int ItemList::get_max_text_lines() const {
return max_text_lines;
}
void ItemList::set_max_columns(int p_amount) {
-
ERR_FAIL_COND(p_amount < 0);
max_columns = p_amount;
update();
shape_changed = true;
}
-int ItemList::get_max_columns() const {
+int ItemList::get_max_columns() const {
return max_columns;
}
void ItemList::set_select_mode(SelectMode p_mode) {
-
select_mode = p_mode;
update();
}
ItemList::SelectMode ItemList::get_select_mode() const {
-
return select_mode;
}
void ItemList::set_icon_mode(IconMode p_mode) {
-
ERR_FAIL_INDEX((int)p_mode, 2);
icon_mode = p_mode;
update();
@@ -438,28 +398,27 @@ void ItemList::set_icon_mode(IconMode p_mode) {
}
ItemList::IconMode ItemList::get_icon_mode() const {
-
return icon_mode;
}
void ItemList::set_fixed_icon_size(const Size2 &p_size) {
-
fixed_icon_size = p_size;
update();
}
Size2 ItemList::get_fixed_icon_size() const {
-
return fixed_icon_size;
}
-Size2 ItemList::Item::get_icon_size() const {
- if (icon.is_null())
+Size2 ItemList::Item::get_icon_size() const {
+ if (icon.is_null()) {
return Size2();
+ }
Size2 size_result = Size2(icon_region.size).abs();
- if (icon_region.size.x == 0 || icon_region.size.y == 0)
+ if (icon_region.size.x == 0 || icon_region.size.y == 0) {
size_result = icon->get_size();
+ }
if (icon_transposed) {
Size2 size_tmp = size_result;
@@ -471,7 +430,6 @@ Size2 ItemList::Item::get_icon_size() const {
}
void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
-
double prev_scroll = scroll_bar->get_value();
Ref<InputEventMouseMotion> mm = p_event;
@@ -483,7 +441,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (defer_select_single >= 0 && mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
-
select(defer_select_single, true);
emit_signal("multi_selected", defer_select_single, true);
@@ -492,7 +449,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && (mb->get_button_index() == BUTTON_LEFT || (allow_rmb_select && mb->get_button_index() == BUTTON_RIGHT)) && mb->is_pressed()) {
-
search_string = ""; //any mousepress cancels
Vector2 pos = mb->get_position();
Ref<StyleBox> bg = get_theme_stylebox("bg");
@@ -502,7 +458,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
int closest = -1;
for (int i = 0; i < items.size(); i++) {
-
Rect2 rc = items[i].rect_cache;
if (i % current_columns == current_columns - 1) {
rc.size.width = get_size().width; //not right but works
@@ -515,7 +470,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
}
if (closest != -1) {
-
int i = closest;
if (select_mode == SELECT_MULTI && items[i].selected && mb->get_command()) {
@@ -523,7 +477,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("multi_selected", i, false);
} else if (select_mode == SELECT_MULTI && mb->get_shift() && current >= 0 && current < items.size() && current != i) {
-
int from = current;
int to = i;
if (i < current) {
@@ -532,23 +485,21 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
for (int j = from; j <= to; j++) {
bool selected = !items[j].selected;
select(j, false);
- if (selected)
+ if (selected) {
emit_signal("multi_selected", j, true);
+ }
}
if (mb->get_button_index() == BUTTON_RIGHT) {
-
emit_signal("item_rmb_selected", i, get_local_mouse_position());
}
} else {
-
if (!mb->is_doubleclick() && !mb->get_command() && select_mode == SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && mb->get_button_index() == BUTTON_LEFT) {
defer_select_single = i;
return;
}
if (items[i].selected && mb->get_button_index() == BUTTON_RIGHT) {
-
emit_signal("item_rmb_selected", i, get_local_mouse_position());
} else {
bool selected = items[i].selected;
@@ -558,15 +509,14 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
if (!selected || allow_reselect) {
if (select_mode == SELECT_SINGLE) {
emit_signal("item_selected", i);
- } else
+ } else {
emit_signal("multi_selected", i, true);
+ }
}
if (mb->get_button_index() == BUTTON_RIGHT) {
-
emit_signal("item_rmb_selected", i, get_local_mouse_position());
} else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_doubleclick()) {
-
emit_signal("item_activated", i);
}
}
@@ -584,28 +534,21 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("nothing_selected");
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
-
scroll_bar->set_value(scroll_bar->get_value() - scroll_bar->get_page() * mb->get_factor() / 8);
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed()) {
-
scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() * mb->get_factor() / 8);
}
if (p_event->is_pressed() && items.size() > 0) {
if (p_event->is_action("ui_up")) {
-
if (search_string != "") {
-
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
-
for (int i = current - 1; i >= 0; i--) {
-
if (items[i].text.begins_with(search_string)) {
-
set_current(i);
ensure_current_is_visible();
if (select_mode == SELECT_SINGLE) {
@@ -629,18 +572,13 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
accept_event();
}
} else if (p_event->is_action("ui_down")) {
-
if (search_string != "") {
-
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
-
for (int i = current + 1; i < items.size(); i++) {
-
if (items[i].text.begins_with(search_string)) {
-
set_current(i);
ensure_current_is_visible();
if (select_mode == SELECT_SINGLE) {
@@ -663,7 +601,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
accept_event();
}
} else if (p_event->is_action("ui_page_up")) {
-
search_string = ""; //any mousepress cancels
for (int i = 4; i > 0; i--) {
@@ -678,7 +615,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
}
}
} else if (p_event->is_action("ui_page_down")) {
-
search_string = ""; //any mousepress cancels
for (int i = 4; i > 0; i--) {
@@ -694,7 +630,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
}
}
} else if (p_event->is_action("ui_left")) {
-
search_string = ""; //any mousepress cancels
if (current % current_columns != 0) {
@@ -706,7 +641,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
accept_event();
}
} else if (p_event->is_action("ui_right")) {
-
search_string = ""; //any mousepress cancels
if (current % current_columns != (current_columns - 1) && current + 1 < items.size()) {
@@ -720,7 +654,6 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
} else if (p_event->is_action("ui_cancel")) {
search_string = "";
} else if (p_event->is_action("ui_select") && select_mode == SELECT_MULTI) {
-
if (current >= 0 && current < items.size()) {
if (items[current].selectable && !items[current].disabled && !items[current].selected) {
select(current, false);
@@ -737,11 +670,9 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("item_activated", current);
}
} else {
-
Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->get_unicode()) {
-
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000));
@@ -751,19 +682,22 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
search_string = "";
}
- if (String::chr(k->get_unicode()) != search_string)
+ if (String::chr(k->get_unicode()) != search_string) {
search_string += String::chr(k->get_unicode());
+ }
for (int i = current + 1; i <= items.size(); i++) {
if (i == items.size()) {
- if (current == 0 || current == -1)
+ if (current == 0 || current == -1) {
break;
- else
+ } else {
i = 0;
+ }
}
- if (i == current)
+ if (i == current) {
break;
+ }
if (items[i].text.findn(search_string) == 0) {
set_current(i);
@@ -780,22 +714,20 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
-
scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() * pan_gesture->get_delta().y / 8);
}
- if (scroll_bar->get_value() != prev_scroll)
+ if (scroll_bar->get_value() != prev_scroll) {
accept_event(); //accept event if scroll changed
+ }
}
void ItemList::ensure_current_is_visible() {
-
ensure_selected_visible = true;
update();
}
static Rect2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) {
-
Size2 size = p_max_size;
int tex_width = p_size.width * size.height / p_size.height;
int tex_height = size.height;
@@ -812,14 +744,12 @@ static Rect2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) {
}
void ItemList::_notification(int p_what) {
-
if (p_what == NOTIFICATION_RESIZED) {
shape_changed = true;
update();
}
if (p_what == NOTIFICATION_DRAW) {
-
Ref<StyleBox> bg = get_theme_stylebox("bg");
int mw = scroll_bar->get_minimum_size().x;
@@ -865,15 +795,12 @@ void ItemList::_notification(int p_what) {
}
if (shape_changed) {
-
float max_column_width = 0;
//1- compute item minimum sizes
for (int i = 0; i < items.size(); i++) {
-
Size2 minsize;
if (items[i].icon.is_valid()) {
-
if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
minsize = fixed_icon_size * icon_scale;
} else {
@@ -890,7 +817,6 @@ void ItemList::_notification(int p_what) {
}
if (items[i].text != "") {
-
Size2 s = font->get_string_size(items[i].text);
//s.width=MIN(s.width,fixed_column_width);
@@ -908,8 +834,9 @@ void ItemList::_notification(int p_what) {
}
}
- if (fixed_column_width > 0)
+ if (fixed_column_width > 0) {
minsize.x = fixed_column_width;
+ }
max_column_width = MAX(max_column_width, minsize.x);
// elements need to adapt to the selected size
@@ -923,8 +850,9 @@ void ItemList::_notification(int p_what) {
//2-attempt best fit
current_columns = 0x7FFFFFFF;
- if (max_columns > 0)
+ if (max_columns > 0) {
current_columns = max_columns;
+ }
while (true) {
//repeat until all fits
@@ -934,7 +862,6 @@ void ItemList::_notification(int p_what) {
int max_h = 0;
separators.clear();
for (int i = 0; i < items.size(); i++) {
-
if (current_columns > 1 && items[i].rect_cache.size.width + ofs.x > fit_size) {
//went past
current_columns = MAX(col, 1);
@@ -942,16 +869,17 @@ void ItemList::_notification(int p_what) {
break;
}
- if (same_column_width)
+ if (same_column_width) {
items.write[i].rect_cache.size.x = max_column_width;
+ }
items.write[i].rect_cache.position = ofs;
max_h = MAX(max_h, items[i].rect_cache.size.y);
ofs.x += items[i].rect_cache.size.x + hseparation;
col++;
if (col == current_columns) {
-
- if (i < items.size() - 1)
+ if (i < items.size() - 1) {
separators.push_back(ofs.y + max_h + vseparation / 2);
+ }
for (int j = i; j >= 0 && col > 0; j--, col--) {
items.write[j].rect_cache.size.y = max_h;
@@ -971,8 +899,9 @@ void ItemList::_notification(int p_what) {
if (all_fit) {
float page = MAX(0, size.height - bg->get_minimum_size().height);
float max = MAX(page, ofs.y + max_h);
- if (auto_height)
+ if (auto_height) {
auto_height_value = ofs.y + max_h + bg->get_minimum_size().height;
+ }
scroll_bar->set_max(max);
scroll_bar->set_page(page);
if (max <= page) {
@@ -981,8 +910,9 @@ void ItemList::_notification(int p_what) {
} else {
scroll_bar->show();
- if (do_autoscroll_to_bottom)
+ if (do_autoscroll_to_bottom) {
scroll_bar->set_value(max);
+ }
}
break;
}
@@ -994,7 +924,6 @@ void ItemList::_notification(int p_what) {
//ensure_selected_visible needs to be checked before we draw the list.
if (ensure_selected_visible && current >= 0 && current < items.size()) {
-
Rect2 r = items[current].rect_cache;
int from = scroll_bar->get_value();
int to = from + scroll_bar->get_page();
@@ -1035,14 +964,15 @@ void ItemList::_notification(int p_what) {
}
for (int i = first_item_visible; i < items.size(); i++) {
-
Rect2 rcache = items[i].rect_cache;
- if (rcache.position.y > clip.position.y + clip.size.y)
+ if (rcache.position.y > clip.position.y + clip.size.y) {
break; // done
+ }
- if (!clip.intersects(rcache))
+ if (!clip.intersects(rcache)) {
continue;
+ }
if (current_columns == 1) {
rcache.size.width = width - rcache.position.x;
@@ -1073,7 +1003,6 @@ void ItemList::_notification(int p_what) {
Vector2 text_ofs;
if (items[i].icon.is_valid()) {
-
Size2 icon_size;
//= _adjust_to_max_size(items[i].get_icon_size(),fixed_icon_size) * icon_scale;
@@ -1088,7 +1017,6 @@ void ItemList::_notification(int p_what) {
Point2 pos = items[i].rect_cache.position + icon_ofs + base_ofs;
if (icon_mode == ICON_MODE_TOP) {
-
pos.x += Math::floor((items[i].rect_cache.size.width - icon_size.width) / 2);
pos.y += MIN(
Math::floor((items[i].rect_cache.size.height - icon_size.height) / 2),
@@ -1096,7 +1024,6 @@ void ItemList::_notification(int p_what) {
text_ofs.y = icon_size.height + icon_margin;
text_ofs.y += items[i].rect_cache.size.height - items[i].min_rect_cache.size.height;
} else {
-
pos.y += Math::floor((items[i].rect_cache.size.height - icon_size.height) / 2);
text_ofs.x = icon_size.width + icon_margin;
}
@@ -1110,8 +1037,9 @@ void ItemList::_notification(int p_what) {
}
Color modulate = items[i].icon_modulate;
- if (items[i].disabled)
+ if (items[i].disabled) {
modulate.a *= 0.5;
+ }
// If the icon is transposed, we have to switch the size so that it is drawn correctly
if (items[i].icon_transposed) {
@@ -1125,41 +1053,40 @@ void ItemList::_notification(int p_what) {
}
if (items[i].tag_icon.is_valid()) {
-
draw_texture(items[i].tag_icon, items[i].rect_cache.position + base_ofs);
}
if (items[i].text != "") {
-
int max_len = -1;
Vector2 size2 = font->get_string_size(items[i].text);
- if (fixed_column_width)
+ if (fixed_column_width) {
max_len = fixed_column_width;
- else if (same_column_width)
+ } else if (same_column_width) {
max_len = items[i].rect_cache.size.x;
- else
+ } else {
max_len = size2.x;
+ }
Color modulate = items[i].selected ? font_color_selected : (items[i].custom_fg != Color() ? items[i].custom_fg : font_color);
- if (items[i].disabled)
+ if (items[i].disabled) {
modulate.a *= 0.5;
+ }
if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
-
int ss = items[i].text.length();
float ofs = 0;
int line = 0;
for (int j = 0; j <= ss; j++) {
-
int cs = j < ss ? font->get_char_size(items[i].text[j], items[i].text[j + 1]).x : 0;
if (ofs + cs > max_len || j == ss) {
line_limit_cache.write[line] = j;
line_size_cache.write[line] = ofs;
line++;
ofs = 0;
- if (line >= max_text_lines)
+ if (line >= max_text_lines) {
break;
+ }
} else {
ofs += cs;
}
@@ -1175,21 +1102,21 @@ void ItemList::_notification(int p_what) {
FontDrawer drawer(font, Color(1, 1, 1));
for (int j = 0; j < ss; j++) {
-
if (j == line_limit_cache[line]) {
line++;
ofs = 0;
- if (line >= max_text_lines)
+ if (line >= max_text_lines) {
break;
+ }
}
ofs += drawer.draw_char(get_canvas_item(), text_ofs + Vector2(ofs + (max_len - line_size_cache[line]) / 2, line * (font_height + line_separation)).floor(), items[i].text[j], items[i].text[j + 1], modulate);
}
//special multiline mode
} else {
-
- if (fixed_column_width > 0)
+ if (fixed_column_width > 0) {
size2.x = MIN(size2.x, fixed_column_width);
+ }
if (icon_mode == ICON_MODE_TOP) {
text_ofs.x += (items[i].rect_cache.size.width - size2.x) / 2;
@@ -1207,7 +1134,6 @@ void ItemList::_notification(int p_what) {
}
if (select_mode == SELECT_MULTI && i == current) {
-
Rect2 r = rcache;
r.position += base_ofs;
r.position.y -= vseparation / 2;
@@ -1235,8 +1161,9 @@ void ItemList::_notification(int p_what) {
}
for (int i = first_visible_separator; i < separators.size(); i++) {
- if (separators[i] > clip.position.y + clip.size.y)
+ if (separators[i] > clip.position.y + clip.size.y) {
break; // done
+ }
const int y = base_ofs.y + separators[i];
draw_line(Vector2(bg->get_margin(MARGIN_LEFT), y), Vector2(width, y), guide_color);
@@ -1249,7 +1176,6 @@ void ItemList::_scroll_changed(double) {
}
int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const {
-
Vector2 pos = p_pos;
Ref<StyleBox> bg = get_theme_stylebox("bg");
pos -= bg->get_offset();
@@ -1259,7 +1185,6 @@ int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const {
int closest_dist = 0x7FFFFFFF;
for (int i = 0; i < items.size(); i++) {
-
Rect2 rc = items[i].rect_cache;
if (i % current_columns == current_columns - 1) {
rc.size.width = get_size().width - rc.position.x; //make sure you can still select the last item when clicking past the column
@@ -1281,9 +1206,9 @@ int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const {
}
bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const {
-
- if (items.empty())
+ if (items.empty()) {
return true;
+ }
Vector2 pos = p_pos;
Ref<StyleBox> bg = get_theme_stylebox("bg");
@@ -1295,7 +1220,6 @@ bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const {
}
String ItemList::get_tooltip(const Point2 &p_pos) const {
-
int closest = get_item_at_position(p_pos, true);
if (closest != -1) {
@@ -1314,7 +1238,6 @@ String ItemList::get_tooltip(const Point2 &p_pos) const {
}
void ItemList::sort_items_by_text() {
-
items.sort();
update();
shape_changed = true;
@@ -1330,7 +1253,6 @@ void ItemList::sort_items_by_text() {
}
int ItemList::find_metadata(const Variant &p_metadata) const {
-
for (int i = 0; i < items.size(); i++) {
if (items[i].metadata == p_metadata) {
return i;
@@ -1341,22 +1263,18 @@ int ItemList::find_metadata(const Variant &p_metadata) const {
}
void ItemList::set_allow_rmb_select(bool p_allow) {
-
allow_rmb_select = p_allow;
}
bool ItemList::get_allow_rmb_select() const {
-
return allow_rmb_select;
}
void ItemList::set_allow_reselect(bool p_allow) {
-
allow_reselect = p_allow;
}
bool ItemList::get_allow_reselect() const {
-
return allow_reselect;
}
@@ -1383,20 +1301,19 @@ Vector<int> ItemList::get_selected_items() {
bool ItemList::is_anything_selected() {
for (int i = 0; i < items.size(); i++) {
- if (items[i].selected)
+ if (items[i].selected) {
return true;
+ }
}
return false;
}
void ItemList::_set_items(const Array &p_items) {
-
ERR_FAIL_COND(p_items.size() % 3);
clear();
for (int i = 0; i < p_items.size(); i += 3) {
-
String text = p_items[i + 0];
Ref<Texture2D> icon = p_items[i + 1];
bool disabled = p_items[i + 2];
@@ -1408,10 +1325,8 @@ void ItemList::_set_items(const Array &p_items) {
}
Array ItemList::_get_items() const {
-
Array items;
for (int i = 0; i < get_item_count(); i++) {
-
items.push_back(get_item_text(i));
items.push_back(get_item_icon(i));
items.push_back(is_item_disabled(i));
@@ -1421,7 +1336,6 @@ Array ItemList::_get_items() const {
}
Size2 ItemList::get_minimum_size() const {
-
if (auto_height) {
return Size2(0, auto_height_value);
}
@@ -1429,24 +1343,20 @@ Size2 ItemList::get_minimum_size() const {
}
void ItemList::set_autoscroll_to_bottom(const bool p_enable) {
-
do_autoscroll_to_bottom = p_enable;
}
void ItemList::set_auto_height(bool p_enable) {
-
auto_height = p_enable;
shape_changed = true;
update();
}
bool ItemList::has_auto_height() const {
-
return auto_height;
}
void ItemList::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_item", "text", "icon", "selectable"), &ItemList::add_item, DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("add_icon_item", "icon", "selectable"), &ItemList::add_icon_item, DEFVAL(true));
@@ -1581,7 +1491,6 @@ void ItemList::_bind_methods() {
}
ItemList::ItemList() {
-
current = -1;
select_mode = SELECT_SINGLE;
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index da9851dd7d..4cdef40184 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -35,7 +35,6 @@
#include "scene/gui/scroll_bar.h"
class ItemList : public Control {
-
GDCLASS(ItemList, Control);
public:
@@ -51,7 +50,6 @@ public:
private:
struct Item {
-
Ref<Texture2D> icon;
bool icon_transposed;
Rect2i icon_region;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index bedcef2df2..f49acc1b96 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -29,12 +29,12 @@
/*************************************************************************/
#include "label.h"
+
#include "core/print_string.h"
#include "core/project_settings.h"
#include "core/translation.h"
void Label::set_autowrap(bool p_autowrap) {
-
if (autowrap == p_autowrap) {
return;
}
@@ -47,34 +47,31 @@ void Label::set_autowrap(bool p_autowrap) {
minimum_size_changed();
}
}
-bool Label::has_autowrap() const {
+bool Label::has_autowrap() const {
return autowrap;
}
void Label::set_uppercase(bool p_uppercase) {
-
uppercase = p_uppercase;
word_cache_dirty = true;
update();
}
-bool Label::is_uppercase() const {
+bool Label::is_uppercase() const {
return uppercase;
}
int Label::get_line_height() const {
-
return get_theme_font("font")->get_height();
}
void Label::_notification(int p_what) {
-
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
-
String new_text = tr(text);
- if (new_text == xl_text)
+ if (new_text == xl_text) {
return; //nothing new
+ }
xl_text = new_text;
regenerate_word_cache();
@@ -82,13 +79,13 @@ void Label::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
if (clip) {
RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
}
- if (word_cache_dirty)
+ if (word_cache_dirty) {
regenerate_word_cache();
+ }
RID ci = get_canvas_item();
@@ -125,9 +122,7 @@ void Label::_notification(int p_what) {
}
if (lines_visible > 0) {
-
switch (valign) {
-
case VALIGN_TOP: {
//nothing
} break;
@@ -154,22 +149,25 @@ void Label::_notification(int p_what) {
}
WordCache *wc = word_cache;
- if (!wc)
+ if (!wc) {
return;
+ }
int line = 0;
int line_to = lines_skipped + (lines_visible > 0 ? lines_visible : 1);
FontDrawer drawer(font, font_outline_modulate);
while (wc) {
/* handle lines not meant to be drawn quickly */
- if (line >= line_to)
+ if (line >= line_to) {
break;
+ }
if (line < lines_skipped) {
-
- while (wc && wc->char_pos >= 0)
+ while (wc && wc->char_pos >= 0) {
wc = wc->next;
- if (wc)
+ }
+ if (wc) {
wc = wc->next;
+ }
line++;
continue;
}
@@ -189,7 +187,6 @@ void Label::_notification(int p_what) {
int taken = 0;
int spaces = 0;
while (to && to->char_pos >= 0) {
-
taken += to->pixel_width;
if (to != from && to->space_count) {
spaces += to->space_count;
@@ -202,18 +199,14 @@ void Label::_notification(int p_what) {
float x_ofs = 0;
switch (align) {
-
case ALIGN_FILL:
case ALIGN_LEFT: {
-
x_ofs = style->get_offset().x;
} break;
case ALIGN_CENTER: {
-
x_ofs = int(size.width - (taken + spaces * space_w)) / 2;
} break;
case ALIGN_RIGHT: {
-
x_ofs = int(size.width - style->get_margin(MARGIN_RIGHT) - (taken + spaces * space_w));
} break;
}
@@ -223,11 +216,9 @@ void Label::_notification(int p_what) {
y_ofs += vbegin + line * vsep;
while (from != to) {
-
// draw a word
int pos = from->char_pos;
if (from->char_pos < 0) {
-
ERR_PRINT("BUG");
return;
}
@@ -235,17 +226,14 @@ void Label::_notification(int p_what) {
/* spacing */
x_ofs += space_w * from->space_count;
if (can_fill && align == ALIGN_FILL && spaces) {
-
x_ofs += int((size.width - (taken + space_w * spaces)) / spaces);
}
}
if (font_color_shadow.a > 0) {
-
int chars_total_shadow = chars_total; //save chars drawn
float x_ofs_shadow = x_ofs;
for (int i = 0; i < from->word_len; i++) {
-
if (visible_chars < 0 || chars_total_shadow < visible_chars) {
CharType c = xl_text[i + pos];
CharType n = xl_text[i + pos + 1];
@@ -266,7 +254,6 @@ void Label::_notification(int p_what) {
}
}
for (int i = 0; i < from->word_len; i++) {
-
if (visible_chars < 0 || chars_total < visible_chars) {
CharType c = xl_text[i + pos];
CharType n = xl_text[i + pos + 1];
@@ -288,18 +275,15 @@ void Label::_notification(int p_what) {
}
if (p_what == NOTIFICATION_THEME_CHANGED) {
-
word_cache_dirty = true;
update();
}
if (p_what == NOTIFICATION_RESIZED) {
-
word_cache_dirty = true;
}
}
Size2 Label::get_minimum_size() const {
-
Size2 min_style = get_theme_stylebox("normal")->get_minimum_size();
// don't want to mutable everything
@@ -307,79 +291,78 @@ Size2 Label::get_minimum_size() const {
const_cast<Label *>(this)->regenerate_word_cache();
}
- if (autowrap)
+ if (autowrap) {
return Size2(1, clip ? 1 : minsize.height) + min_style;
- else {
+ } else {
Size2 ms = minsize;
- if (clip)
+ if (clip) {
ms.width = 1;
+ }
return ms + min_style;
}
}
int Label::get_longest_line_width() const {
-
Ref<Font> font = get_theme_font("font");
real_t max_line_width = 0;
real_t line_width = 0;
for (int i = 0; i < xl_text.size(); i++) {
-
CharType current = xl_text[i];
- if (uppercase)
+ if (uppercase) {
current = String::char_uppercase(current);
+ }
if (current < 32) {
-
if (current == '\n') {
-
- if (line_width > max_line_width)
+ if (line_width > max_line_width) {
max_line_width = line_width;
+ }
line_width = 0;
}
} else {
-
real_t char_width = font->get_char_size(current, xl_text[i + 1]).width;
line_width += char_width;
}
}
- if (line_width > max_line_width)
+ if (line_width > max_line_width) {
max_line_width = line_width;
+ }
// ceiling to ensure autowrapping does not cut text
return Math::ceil(max_line_width);
}
int Label::get_line_count() const {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return 1;
- if (word_cache_dirty)
+ }
+ if (word_cache_dirty) {
const_cast<Label *>(this)->regenerate_word_cache();
+ }
return line_count;
}
int Label::get_visible_line_count() const {
-
int line_spacing = get_theme_constant("line_spacing");
int font_h = get_theme_font("font")->get_height() + line_spacing;
int lines_visible = (get_size().height - get_theme_stylebox("normal")->get_minimum_size().height + line_spacing) / font_h;
- if (lines_visible > line_count)
+ if (lines_visible > line_count) {
lines_visible = line_count;
+ }
- if (max_lines_visible >= 0 && lines_visible > max_lines_visible)
+ if (max_lines_visible >= 0 && lines_visible > max_lines_visible) {
lines_visible = max_lines_visible;
+ }
return lines_visible;
}
void Label::regenerate_word_cache() {
-
while (word_cache) {
-
WordCache *current = word_cache;
word_cache = current->next;
memdelete(current);
@@ -407,11 +390,11 @@ void Label::regenerate_word_cache() {
WordCache *last = nullptr;
for (int i = 0; i <= xl_text.length(); i++) {
-
CharType current = i < xl_text.length() ? xl_text[i] : L' '; //always a space at the end, so the algo works
- if (uppercase)
+ if (uppercase) {
current = String::char_uppercase(current);
+ }
// ranges taken from http://www.unicodemap.org/
// if your language is not well supported, consider helping improve
@@ -422,7 +405,6 @@ void Label::regenerate_word_cache() {
real_t char_width = 0;
if (current < 33) {
-
if (current_word_size > 0) {
WordCache *wc = memnew(WordCache);
if (word_cache) {
@@ -508,8 +490,9 @@ void Label::regenerate_word_cache() {
}
}
- if (!autowrap)
+ if (!autowrap) {
minsize.width = width;
+ }
if (max_lines_visible > 0 && line_count > max_lines_visible) {
minsize.height = (font->get_height() * max_lines_visible) + (line_spacing * (max_lines_visible - 1));
@@ -525,60 +508,53 @@ void Label::regenerate_word_cache() {
}
void Label::set_align(Align p_align) {
-
ERR_FAIL_INDEX((int)p_align, 4);
align = p_align;
update();
}
Label::Align Label::get_align() const {
-
return align;
}
void Label::set_valign(VAlign p_align) {
-
ERR_FAIL_INDEX((int)p_align, 4);
valign = p_align;
update();
}
Label::VAlign Label::get_valign() const {
-
return valign;
}
void Label::set_text(const String &p_string) {
-
- if (text == p_string)
+ if (text == p_string) {
return;
+ }
text = p_string;
xl_text = tr(p_string);
word_cache_dirty = true;
- if (percent_visible < 1)
+ if (percent_visible < 1) {
visible_chars = get_total_character_count() * percent_visible;
+ }
update();
}
void Label::set_clip_text(bool p_clip) {
-
clip = p_clip;
update();
minimum_size_changed();
}
bool Label::is_clipping_text() const {
-
return clip;
}
String Label::get_text() const {
-
return text;
}
void Label::set_visible_characters(int p_amount) {
-
visible_chars = p_amount;
if (get_total_character_count() > 0) {
percent_visible = (float)p_amount / (float)total_char_cache;
@@ -588,19 +564,15 @@ void Label::set_visible_characters(int p_amount) {
}
int Label::get_visible_characters() const {
-
return visible_chars;
}
void Label::set_percent_visible(float p_percent) {
-
if (p_percent < 0 || p_percent >= 1) {
-
visible_chars = -1;
percent_visible = 1;
} else {
-
visible_chars = get_total_character_count() * p_percent;
percent_visible = p_percent;
}
@@ -609,42 +581,36 @@ void Label::set_percent_visible(float p_percent) {
}
float Label::get_percent_visible() const {
-
return percent_visible;
}
void Label::set_lines_skipped(int p_lines) {
-
lines_skipped = p_lines;
update();
}
int Label::get_lines_skipped() const {
-
return lines_skipped;
}
void Label::set_max_lines_visible(int p_lines) {
-
max_lines_visible = p_lines;
update();
}
int Label::get_max_lines_visible() const {
-
return max_lines_visible;
}
int Label::get_total_character_count() const {
-
- if (word_cache_dirty)
+ if (word_cache_dirty) {
const_cast<Label *>(this)->regenerate_word_cache();
+ }
return total_char_cache;
}
void Label::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_align", "align"), &Label::set_align);
ClassDB::bind_method(D_METHOD("get_align"), &Label::get_align);
ClassDB::bind_method(D_METHOD("set_valign", "valign"), &Label::set_valign);
@@ -693,31 +659,13 @@ void Label::_bind_methods() {
}
Label::Label(const String &p_text) {
-
- align = ALIGN_LEFT;
- valign = VALIGN_TOP;
- xl_text = "";
- word_cache = nullptr;
- word_cache_dirty = true;
- autowrap = false;
- line_count = 0;
- set_v_size_flags(0);
- clip = false;
set_mouse_filter(MOUSE_FILTER_IGNORE);
- total_char_cache = 0;
- visible_chars = -1;
- percent_visible = 1;
- lines_skipped = 0;
- max_lines_visible = -1;
set_text(p_text);
- uppercase = false;
set_v_size_flags(SIZE_SHRINK_CENTER);
}
Label::~Label() {
-
while (word_cache) {
-
WordCache *current = word_cache;
word_cache = current->next;
memdelete(current);
diff --git a/scene/gui/label.h b/scene/gui/label.h
index ba6e627c58..670db69dce 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class Label : public Control {
-
GDCLASS(Label, Control);
public:
@@ -55,48 +54,40 @@ public:
};
private:
- Align align;
- VAlign valign;
+ Align align = ALIGN_LEFT;
+ VAlign valign = VALIGN_TOP;
String text;
String xl_text;
- bool autowrap;
- bool clip;
+ bool autowrap = false;
+ bool clip = false;
Size2 minsize;
- int line_count;
- bool uppercase;
+ int line_count = 0;
+ bool uppercase = false;
int get_longest_line_width() const;
struct WordCache {
-
enum {
CHAR_NEWLINE = -1,
CHAR_WRAPLINE = -2
};
- int char_pos; // if -1, then newline
- int word_len;
- int pixel_width;
- int space_count;
- WordCache *next;
- WordCache() {
- char_pos = 0;
- word_len = 0;
- pixel_width = 0;
- next = 0;
- space_count = 0;
- }
+ int char_pos = 0; // if -1, then newline
+ int word_len = 0;
+ int pixel_width = 0;
+ int space_count = 0;
+ WordCache *next = nullptr;
};
- bool word_cache_dirty;
+ bool word_cache_dirty = true;
void regenerate_word_cache();
- float percent_visible;
+ float percent_visible = 1;
- WordCache *word_cache;
- int total_char_cache;
- int visible_chars;
- int lines_skipped;
- int max_lines_visible;
+ WordCache *word_cache = nullptr;
+ int total_char_cache = 0;
+ int visible_chars = -1;
+ int lines_skipped = 0;
+ int max_lines_visible = -1;
protected:
void _notification(int p_what);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index bb177ae0e7..ee6783167a 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -43,16 +43,13 @@
#endif
#include "scene/main/window.h"
static bool _is_text_char(CharType c) {
-
return !is_symbol(c);
}
void LineEdit::_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
-
if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
menu->set_position(get_global_transform().xform(get_local_mouse_position()));
menu->set_size(Vector2(1, 1));
@@ -63,12 +60,12 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
return;
}
- if (b->get_button_index() != BUTTON_LEFT)
+ if (b->get_button_index() != BUTTON_LEFT) {
return;
+ }
_reset_caret_blink_timer();
if (b->is_pressed()) {
-
accept_event(); //don't pass event further when clicked on text field
if (!text.empty() && is_editable() && _is_over_clear_button(b->get_position())) {
clear_button_status.press_attempt = true;
@@ -81,14 +78,11 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
set_cursor_at_pixel_pos(b->get_position().x);
if (b->get_shift()) {
-
selection_fill_at_cursor();
selection.creating = true;
} else {
-
if (b->is_doubleclick() && selecting_enabled) {
-
selection.enabled = true;
selection.begin = 0;
selection.end = text.length();
@@ -98,12 +92,10 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
selection.drag_attempt = false;
if ((cursor_pos < selection.begin) || (cursor_pos > selection.end) || !selection.enabled) {
-
deselect();
selection.cursor_start = cursor_pos;
selection.creating = true;
} else if (selection.enabled) {
-
selection.drag_attempt = true;
}
}
@@ -111,7 +103,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
update();
} else {
-
if (!text.empty() && is_editable() && clear_button_enabled) {
bool press_attempt = clear_button_status.press_attempt;
clear_button_status.press_attempt = false;
@@ -127,8 +118,13 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
selection.creating = false;
selection.doubleclick = false;
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
- DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
+ if (selection.enabled) {
+ DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, selection.begin, selection.end);
+ } else {
+ DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, cursor_pos);
+ }
+ }
}
update();
@@ -137,7 +133,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
-
if (!text.empty() && is_editable() && clear_button_enabled) {
bool last_press_inside = clear_button_status.pressing_inside;
clear_button_status.pressing_inside = clear_button_status.press_attempt && _is_over_clear_button(m->get_position());
@@ -147,7 +142,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
}
if (m->get_button_mask() & BUTTON_LEFT) {
-
if (selection.creating) {
set_cursor_at_pixel_pos(m->get_position().x);
selection_fill_at_cursor();
@@ -158,9 +152,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
-
- if (!k->is_pressed())
+ if (!k->is_pressed()) {
return;
+ }
#ifdef APPLE_STYLE_KEYS
if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) {
@@ -202,11 +196,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
unsigned int code = k->get_keycode();
if (k->get_command() && is_shortcut_keys_enabled()) {
-
bool handled = true;
switch (code) {
-
case (KEY_X): { // CUT.
if (editable) {
@@ -224,7 +216,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
case (KEY_V): { // PASTE.
if (editable) {
-
paste_text();
}
@@ -243,7 +234,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
case (KEY_U): { // Delete from start to cursor.
if (editable) {
-
deselect();
text = text.substr(cursor_pos, text.length() - cursor_pos);
update_cached_width();
@@ -256,7 +246,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
case (KEY_Y): { // PASTE (Yank for unix users).
if (editable) {
-
paste_text();
}
@@ -264,7 +253,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
case (KEY_K): { // Delete from cursor_pos to end.
if (editable) {
-
deselect();
text = text.substr(0, cursor_pos);
_text_changed();
@@ -300,23 +288,21 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
_reset_caret_blink_timer();
if (!k->get_metakey()) {
-
bool handled = true;
switch (code) {
-
case KEY_KP_ENTER:
case KEY_ENTER: {
-
emit_signal("text_entered", text);
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
DisplayServer::get_singleton()->virtual_keyboard_hide();
+ }
} break;
case KEY_BACKSPACE: {
-
- if (!editable)
+ if (!editable) {
break;
+ }
if (selection.enabled) {
selection_delete();
@@ -337,8 +323,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
while (cc > 0) {
bool ischar = _is_text_char(text[cc - 1]);
- if (prev_char && !ischar)
+ if (prev_char && !ischar) {
break;
+ }
prev_char = ischar;
cc--;
@@ -380,7 +367,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (k->get_command()) {
set_cursor_position(0);
} else if (k->get_alt()) {
-
#else
if (k->get_alt()) {
handled = false;
@@ -393,8 +379,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
while (cc > 0) {
bool ischar = _is_text_char(text[cc - 1]);
- if (prev_char && !ischar)
+ if (prev_char && !ischar) {
break;
+ }
prev_char = ischar;
cc--;
@@ -448,8 +435,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
while (cc < text.length()) {
bool ischar = _is_text_char(text[cc]);
- if (prev_char && !ischar)
+ if (prev_char && !ischar) {
break;
+ }
prev_char = ischar;
cc++;
@@ -465,25 +453,25 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
} break;
case KEY_UP: {
-
shift_selection_check_pre(k->get_shift());
- if (get_cursor_position() == 0)
+ if (get_cursor_position() == 0) {
handled = false;
+ }
set_cursor_position(0);
shift_selection_check_post(k->get_shift());
} break;
case KEY_DOWN: {
-
shift_selection_check_pre(k->get_shift());
- if (get_cursor_position() == text.length())
+ if (get_cursor_position() == text.length()) {
handled = false;
+ }
set_cursor_position(text.length());
shift_selection_check_post(k->get_shift());
} break;
case KEY_DELETE: {
-
- if (!editable)
+ if (!editable) {
break;
+ }
if (k->get_shift() && !k->get_command() && !k->get_alt()) {
cut_text();
@@ -497,8 +485,9 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
int text_len = text.length();
- if (cursor_pos == text_len)
+ if (cursor_pos == text_len) {
break; // Nothing to do.
+ }
#ifdef APPLE_STYLE_KEYS
if (k->get_alt()) {
@@ -513,11 +502,11 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
bool prev_char = false;
while (cc < text.length()) {
-
bool ischar = _is_text_char(text[cc]);
- if (prev_char && !ischar)
+ if (prev_char && !ischar) {
break;
+ }
prev_char = ischar;
cc++;
}
@@ -538,7 +527,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
[[fallthrough]];
}
case KEY_HOME: {
-
shift_selection_check_pre(k->get_shift());
set_cursor_position(0);
shift_selection_check_post(k->get_shift());
@@ -551,7 +539,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
[[fallthrough]];
}
case KEY_END: {
-
shift_selection_check_pre(k->get_shift());
set_cursor_position(text.length());
shift_selection_check_post(k->get_shift());
@@ -568,7 +555,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
} break;
default: {
-
handled = false;
} break;
}
@@ -577,7 +563,6 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
accept_event();
} else if (!k->get_command()) {
if (k->get_unicode() >= 32 && k->get_keycode() != KEY_DELETE) {
-
if (editable) {
selection_delete();
CharType ucodestr[2] = { (CharType)k->get_unicode(), 0 };
@@ -602,19 +587,16 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
}
void LineEdit::set_align(Align p_align) {
-
ERR_FAIL_INDEX((int)p_align, 4);
align = p_align;
update();
}
LineEdit::Align LineEdit::get_align() const {
-
return align;
}
Variant LineEdit::get_drag_data(const Point2 &p_point) {
-
if (selection.drag_attempt && selection.enabled) {
String t = text.substr(selection.begin, selection.end - selection.begin);
Label *l = memnew(Label);
@@ -625,20 +607,21 @@ Variant LineEdit::get_drag_data(const Point2 &p_point) {
return Variant();
}
-bool LineEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
+bool LineEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
return p_data.get_type() == Variant::STRING;
}
-void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
+void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
if (p_data.get_type() == Variant::STRING) {
set_cursor_at_pixel_pos(p_point.x);
int selected = selection.end - selection.begin;
Ref<Font> font = get_theme_font("font");
if (font != nullptr) {
- for (int i = selection.begin; i < selection.end; i++)
+ for (int i = selection.begin; i < selection.end; i++) {
cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width;
+ }
}
text.erase(selection.begin, selected);
@@ -666,7 +649,6 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const {
}
void LineEdit::_notification(int p_what) {
-
switch (p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
@@ -681,7 +663,6 @@ void LineEdit::_notification(int p_what) {
} break;
#endif
case NOTIFICATION_RESIZED: {
-
window_pos = 0;
set_cursor_position(get_cursor_position());
@@ -702,7 +683,6 @@ void LineEdit::_notification(int p_what) {
update();
} break;
case NOTIFICATION_DRAW: {
-
if ((!has_focus() && !menu->has_focus()) || !window_has_focus) {
draw_caret = false;
}
@@ -726,7 +706,6 @@ void LineEdit::_notification(int p_what) {
style->draw(ci, Rect2(Point2(), size));
if (has_focus()) {
-
get_theme_stylebox("focus")->draw(ci, Rect2(Point2(), size));
}
@@ -735,21 +714,18 @@ void LineEdit::_notification(int p_what) {
int cached_text_width = using_placeholder ? cached_placeholder_width : cached_width;
switch (align) {
-
case ALIGN_FILL:
case ALIGN_LEFT: {
-
x_ofs = style->get_offset().x;
} break;
case ALIGN_CENTER: {
-
- if (window_pos != 0)
+ if (window_pos != 0) {
x_ofs = style->get_offset().x;
- else
+ } else {
x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - (cached_text_width)) / 2);
+ }
} break;
case ALIGN_RIGHT: {
-
x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - style->get_margin(MARGIN_RIGHT) - (cached_text_width)));
} break;
}
@@ -769,8 +745,9 @@ void LineEdit::_notification(int p_what) {
const String &t = using_placeholder ? placeholder_translated : text;
// Draw placeholder color.
- if (using_placeholder)
+ if (using_placeholder) {
font_color.a *= placeholder_alpha;
+ }
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
@@ -800,24 +777,26 @@ void LineEdit::_notification(int p_what) {
int caret_height = font->get_height() > y_area ? y_area : font->get_height();
FontDrawer drawer(font, Color(1, 1, 1));
while (true) {
-
// End of string, break.
- if (char_ofs >= t.length())
+ if (char_ofs >= t.length()) {
break;
+ }
if (char_ofs == cursor_pos) {
if (ime_text.length() > 0) {
int ofs = 0;
while (true) {
- if (ofs >= ime_text.length())
+ if (ofs >= ime_text.length()) {
break;
+ }
CharType cchar = (pass && !text.empty()) ? secret_character[0] : ime_text[ofs];
CharType next = (pass && !text.empty()) ? secret_character[0] : ime_text[ofs + 1];
int im_char_width = font->get_char_size(cchar, next).width;
- if ((x_ofs + im_char_width) > ofs_max)
+ if ((x_ofs + im_char_width) > ofs_max) {
break;
+ }
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
@@ -839,13 +818,15 @@ void LineEdit::_notification(int p_what) {
int char_width = font->get_char_size(cchar, next).width;
// End of widget, break.
- if ((x_ofs + char_width) > ofs_max)
+ if ((x_ofs + char_width) > ofs_max) {
break;
+ }
bool selected = selection.enabled && char_ofs >= selection.begin && char_ofs < selection.end;
- if (selected)
+ if (selected) {
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color);
+ }
int yofs = y_ofs + (caret_height - font->get_height()) / 2;
drawer.draw_char(ci, Point2(x_ofs, yofs + font_ascent), cchar, next, selected ? font_color_selected : font_color);
@@ -868,15 +849,17 @@ void LineEdit::_notification(int p_what) {
if (ime_text.length() > 0) {
int ofs = 0;
while (true) {
- if (ofs >= ime_text.length())
+ if (ofs >= ime_text.length()) {
break;
+ }
CharType cchar = (pass && !text.empty()) ? secret_character[0] : ime_text[ofs];
CharType next = (pass && !text.empty()) ? secret_character[0] : ime_text[ofs + 1];
int im_char_width = font->get_char_size(cchar, next).width;
- if ((x_ofs + im_char_width) > ofs_max)
+ if ((x_ofs + im_char_width) > ofs_max) {
break;
+ }
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
@@ -926,7 +909,6 @@ void LineEdit::_notification(int p_what) {
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
-
if (caret_blink_enabled) {
caret_blink_timer->start();
} else {
@@ -939,12 +921,16 @@ void LineEdit::_notification(int p_what) {
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
}
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
- DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length);
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
+ if (selection.enabled) {
+ DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, selection.begin, selection.end);
+ } else {
+ DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, cursor_pos);
+ }
+ }
} break;
case NOTIFICATION_FOCUS_EXIT: {
-
if (caret_blink_enabled) {
caret_blink_timer->stop();
}
@@ -956,12 +942,12 @@ void LineEdit::_notification(int p_what) {
ime_text = "";
ime_selection = Point2();
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
DisplayServer::get_singleton()->virtual_keyboard_hide();
+ }
} break;
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
-
if (has_focus()) {
ime_text = DisplayServer::get_singleton()->ime_get_text();
ime_selection = DisplayServer::get_singleton()->ime_get_selection();
@@ -972,14 +958,12 @@ void LineEdit::_notification(int p_what) {
}
void LineEdit::copy_text() {
-
if (selection.enabled && !pass) {
DisplayServer::get_singleton()->clipboard_set(text.substr(selection.begin, selection.end - selection.begin));
}
}
void LineEdit::cut_text() {
-
if (selection.enabled && !pass) {
DisplayServer::get_singleton()->clipboard_set(text.substr(selection.begin, selection.end - selection.begin));
selection_delete();
@@ -987,15 +971,14 @@ void LineEdit::cut_text() {
}
void LineEdit::paste_text() {
-
// Strip escape characters like \n and \t as they can't be displayed on LineEdit.
String paste_buffer = DisplayServer::get_singleton()->clipboard_get().strip_escapes();
if (paste_buffer != "") {
-
int prev_len = text.length();
- if (selection.enabled)
+ if (selection.enabled) {
selection_delete();
+ }
append_at_cursor(paste_buffer);
if (!text_changed_dirty) {
@@ -1023,8 +1006,9 @@ void LineEdit::undo() {
window_pos = op.window_pos;
set_cursor_position(op.cursor_pos);
- if (expand_to_text_length)
+ if (expand_to_text_length) {
minimum_size_changed();
+ }
_emit_text_change();
}
@@ -1043,29 +1027,29 @@ void LineEdit::redo() {
window_pos = op.window_pos;
set_cursor_position(op.cursor_pos);
- if (expand_to_text_length)
+ if (expand_to_text_length) {
minimum_size_changed();
+ }
_emit_text_change();
}
void LineEdit::shift_selection_check_pre(bool p_shift) {
-
if (!selection.enabled && p_shift) {
selection.cursor_start = cursor_pos;
}
- if (!p_shift)
+ if (!p_shift) {
deselect();
+ }
}
void LineEdit::shift_selection_check_post(bool p_shift) {
-
- if (p_shift)
+ if (p_shift) {
selection_fill_at_cursor();
+ }
}
void LineEdit::set_cursor_at_pixel_pos(int p_x) {
-
Ref<Font> font = get_theme_font("font");
int ofs = window_pos;
Ref<StyleBox> style = get_theme_stylebox("normal");
@@ -1075,33 +1059,31 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) {
int r_icon_width = Control::get_theme_icon("clear")->get_width();
switch (align) {
-
case ALIGN_FILL:
case ALIGN_LEFT: {
-
pixel_ofs = int(style->get_offset().x);
} break;
case ALIGN_CENTER: {
-
- if (window_pos != 0)
+ if (window_pos != 0) {
pixel_ofs = int(style->get_offset().x);
- else
+ } else {
pixel_ofs = int(size.width - (cached_width)) / 2;
+ }
- if (display_clear_icon)
+ if (display_clear_icon) {
pixel_ofs -= int(r_icon_width / 2 + style->get_margin(MARGIN_RIGHT));
+ }
} break;
case ALIGN_RIGHT: {
-
pixel_ofs = int(size.width - style->get_margin(MARGIN_RIGHT) - (cached_width));
- if (display_clear_icon)
+ if (display_clear_icon) {
pixel_ofs -= int(r_icon_width + style->get_margin(MARGIN_RIGHT));
+ }
} break;
}
while (ofs < text.length()) {
-
int char_w = 0;
if (font != nullptr) {
char_w = font->get_char_size(pass ? secret_character[0] : text[ofs]).width;
@@ -1119,7 +1101,6 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) {
}
int LineEdit::get_cursor_pixel_pos() {
-
Ref<Font> font = get_theme_font("font");
int ofs = window_pos;
Ref<StyleBox> style = get_theme_stylebox("normal");
@@ -1129,28 +1110,27 @@ int LineEdit::get_cursor_pixel_pos() {
int r_icon_width = Control::get_theme_icon("clear")->get_width();
switch (align) {
-
case ALIGN_FILL:
case ALIGN_LEFT: {
-
pixel_ofs = int(style->get_offset().x);
} break;
case ALIGN_CENTER: {
-
- if (window_pos != 0)
+ if (window_pos != 0) {
pixel_ofs = int(style->get_offset().x);
- else
+ } else {
pixel_ofs = int(size.width - (cached_width)) / 2;
+ }
- if (display_clear_icon)
+ if (display_clear_icon) {
pixel_ofs -= int(r_icon_width / 2 + style->get_margin(MARGIN_RIGHT));
+ }
} break;
case ALIGN_RIGHT: {
-
pixel_ofs = int(size.width - style->get_margin(MARGIN_RIGHT) - (cached_width));
- if (display_clear_icon)
+ if (display_clear_icon) {
pixel_ofs -= int(r_icon_width + style->get_margin(MARGIN_RIGHT));
+ }
} break;
}
@@ -1210,9 +1190,9 @@ void LineEdit::_toggle_draw_caret() {
}
void LineEdit::delete_char() {
-
- if ((text.length() <= 0) || (cursor_pos == 0))
+ if ((text.length() <= 0) || (cursor_pos == 0)) {
return;
+ }
Ref<Font> font = get_theme_font("font");
if (font != nullptr) {
@@ -1231,12 +1211,14 @@ void LineEdit::delete_char() {
}
void LineEdit::delete_text(int p_from_column, int p_to_column) {
-
+ ERR_FAIL_COND_MSG(p_from_column < 0 || p_from_column > p_to_column || p_to_column > text.length(),
+ vformat("Positional parameters (from: %d, to: %d) are inverted or outside the text length (%d).", p_from_column, p_to_column, text.length()));
if (text.size() > 0) {
Ref<Font> font = get_theme_font("font");
if (font != nullptr) {
- for (int i = p_from_column; i < p_to_column; i++)
+ for (int i = p_from_column; i < p_to_column; i++) {
cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width;
+ }
}
} else {
cached_width = 0;
@@ -1246,11 +1228,9 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) {
cursor_pos -= CLAMP(cursor_pos - p_from_column, 0, p_to_column - p_from_column);
if (cursor_pos >= text.length()) {
-
cursor_pos = text.length();
}
if (window_pos > cursor_pos) {
-
window_pos = cursor_pos;
}
@@ -1267,7 +1247,6 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) {
}
void LineEdit::set_text(String p_text) {
-
clear_internal();
append_at_cursor(p_text);
@@ -1281,18 +1260,15 @@ void LineEdit::set_text(String p_text) {
}
void LineEdit::clear() {
-
clear_internal();
_text_changed();
}
String LineEdit::get_text() const {
-
return text;
}
void LineEdit::set_placeholder(String p_text) {
-
placeholder = p_text;
placeholder_translated = tr(placeholder);
update_placeholder_width();
@@ -1300,33 +1276,30 @@ void LineEdit::set_placeholder(String p_text) {
}
String LineEdit::get_placeholder() const {
-
return placeholder;
}
void LineEdit::set_placeholder_alpha(float p_alpha) {
-
placeholder_alpha = p_alpha;
update();
}
float LineEdit::get_placeholder_alpha() const {
-
return placeholder_alpha;
}
void LineEdit::set_cursor_position(int p_pos) {
-
- if (p_pos > (int)text.length())
+ if (p_pos > (int)text.length()) {
p_pos = text.length();
+ }
- if (p_pos < 0)
+ if (p_pos < 0) {
p_pos = 0;
+ }
cursor_pos = p_pos;
if (!is_inside_tree()) {
-
window_pos = cursor_pos;
return;
}
@@ -1346,16 +1319,15 @@ void LineEdit::set_cursor_position(int p_pos) {
window_width -= r_icon->get_width();
}
- if (window_width < 0)
+ if (window_width < 0) {
return;
+ }
int wp = window_pos;
if (font.is_valid()) {
-
int accum_width = 0;
for (int i = cursor_pos; i >= window_pos; i--) {
-
if (i >= text.length()) {
// Do not do this, because if the cursor is at the end, its just fine that it takes no space.
// accum_width = font->get_char_size(' ').width;
@@ -1366,33 +1338,33 @@ void LineEdit::set_cursor_position(int p_pos) {
accum_width += font->get_char_size(text[i], i + 1 < text.length() ? text[i + 1] : 0).width; // Anything should do.
}
}
- if (accum_width > window_width)
+ if (accum_width > window_width) {
break;
+ }
wp = i;
}
}
- if (wp != window_pos)
+ if (wp != window_pos) {
set_window_pos(wp);
+ }
}
update();
}
int LineEdit::get_cursor_position() const {
-
return cursor_pos;
}
void LineEdit::set_window_pos(int p_pos) {
-
window_pos = p_pos;
- if (window_pos < 0)
+ if (window_pos < 0) {
window_pos = 0;
+ }
}
void LineEdit::append_at_cursor(String p_text) {
-
if ((max_length <= 0) || (text.length() + p_text.length() <= max_length)) {
String pre = text.substr(0, cursor_pos);
String post = text.substr(cursor_pos, text.length() - cursor_pos);
@@ -1405,7 +1377,6 @@ void LineEdit::append_at_cursor(String p_text) {
}
void LineEdit::clear_internal() {
-
deselect();
_clear_undo_stack();
cached_width = 0;
@@ -1417,7 +1388,6 @@ void LineEdit::clear_internal() {
}
Size2 LineEdit::get_minimum_size() const {
-
Ref<StyleBox> style = get_theme_stylebox("normal");
Ref<Font> font = get_theme_font("font");
@@ -1448,7 +1418,6 @@ Size2 LineEdit::get_minimum_size() const {
}
void LineEdit::deselect() {
-
selection.begin = 0;
selection.end = 0;
selection.cursor_start = 0;
@@ -1459,28 +1428,27 @@ void LineEdit::deselect() {
}
void LineEdit::selection_delete() {
-
- if (selection.enabled)
+ if (selection.enabled) {
delete_text(selection.begin, selection.end);
+ }
deselect();
}
void LineEdit::set_max_length(int p_max_length) {
-
ERR_FAIL_COND(p_max_length < 0);
max_length = p_max_length;
set_text(text);
}
int LineEdit::get_max_length() const {
-
return max_length;
}
void LineEdit::selection_fill_at_cursor() {
- if (!selecting_enabled)
+ if (!selecting_enabled) {
return;
+ }
selection.begin = cursor_pos;
selection.end = selection.cursor_start;
@@ -1495,11 +1463,13 @@ void LineEdit::selection_fill_at_cursor() {
}
void LineEdit::select_all() {
- if (!selecting_enabled)
+ if (!selecting_enabled) {
return;
+ }
- if (!text.length())
+ if (!text.length()) {
return;
+ }
selection.begin = 0;
selection.end = text.length();
@@ -1508,9 +1478,9 @@ void LineEdit::select_all() {
}
void LineEdit::set_editable(bool p_editable) {
-
- if (editable == p_editable)
+ if (editable == p_editable) {
return;
+ }
editable = p_editable;
_generate_context_menu();
@@ -1520,24 +1490,20 @@ void LineEdit::set_editable(bool p_editable) {
}
bool LineEdit::is_editable() const {
-
return editable;
}
void LineEdit::set_secret(bool p_secret) {
-
pass = p_secret;
update_cached_width();
update();
}
bool LineEdit::is_secret() const {
-
return pass;
}
void LineEdit::set_secret_character(const String &p_string) {
-
// An empty string as the secret character would crash the engine.
// It also wouldn't make sense to use multiple characters as the secret character.
ERR_FAIL_COND_MSG(p_string.length() != 1, "Secret character must be exactly one character long (" + itos(p_string.length()) + " characters given).");
@@ -1552,8 +1518,9 @@ String LineEdit::get_secret_character() const {
}
void LineEdit::select(int p_from, int p_to) {
- if (!selecting_enabled)
+ if (!selecting_enabled) {
return;
+ }
if (p_from == 0 && p_to == 0) {
deselect();
@@ -1561,15 +1528,19 @@ void LineEdit::select(int p_from, int p_to) {
}
int len = text.length();
- if (p_from < 0)
+ if (p_from < 0) {
p_from = 0;
- if (p_from > len)
+ }
+ if (p_from > len) {
p_from = len;
- if (p_to < 0 || p_to > len)
+ }
+ if (p_to < 0 || p_to > len) {
p_to = len;
+ }
- if (p_from >= p_to)
+ if (p_from >= p_to) {
return;
+ }
selection.enabled = true;
selection.begin = p_from;
@@ -1580,12 +1551,10 @@ void LineEdit::select(int p_from, int p_to) {
}
bool LineEdit::is_text_field() const {
-
return true;
}
void LineEdit::menu_option(int p_option) {
-
switch (p_option) {
case MENU_CUT: {
if (editable) {
@@ -1593,7 +1562,6 @@ void LineEdit::menu_option(int p_option) {
}
} break;
case MENU_COPY: {
-
copy_text();
} break;
case MENU_PASTE: {
@@ -1642,7 +1610,6 @@ void LineEdit::_editor_settings_changed() {
}
void LineEdit::set_expand_to_text_length(bool p_enabled) {
-
expand_to_text_length = p_enabled;
minimum_size_changed();
set_window_pos(0);
@@ -1678,8 +1645,9 @@ bool LineEdit::is_shortcut_keys_enabled() const {
void LineEdit::set_selecting_enabled(bool p_enabled) {
selecting_enabled = p_enabled;
- if (!selecting_enabled)
+ if (!selecting_enabled) {
deselect();
+ }
_generate_context_menu();
}
@@ -1702,8 +1670,9 @@ Ref<Texture2D> LineEdit::get_right_icon() {
}
void LineEdit::_text_changed() {
- if (expand_to_text_length)
+ if (expand_to_text_length) {
minimum_size_changed();
+ }
_emit_text_change();
_clear_redo();
@@ -1769,14 +1738,17 @@ void LineEdit::_create_undo_state() {
void LineEdit::_generate_context_menu() {
// Reorganize context menu.
menu->clear();
- if (editable)
+ if (editable) {
menu->add_item(RTR("Cut"), MENU_CUT, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_X : 0);
+ }
menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_C : 0);
- if (editable)
+ if (editable) {
menu->add_item(RTR("Paste"), MENU_PASTE, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_V : 0);
+ }
menu->add_separator();
- if (is_selecting_enabled())
+ if (is_selecting_enabled()) {
menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_A : 0);
+ }
if (editable) {
menu->add_item(RTR("Clear"), MENU_CLEAR);
menu->add_separator();
@@ -1786,7 +1758,6 @@ void LineEdit::_generate_context_menu() {
}
void LineEdit::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed);
ClassDB::bind_method(D_METHOD("set_align", "align"), &LineEdit::set_align);
@@ -1814,6 +1785,8 @@ void LineEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_max_length", "chars"), &LineEdit::set_max_length);
ClassDB::bind_method(D_METHOD("get_max_length"), &LineEdit::get_max_length);
ClassDB::bind_method(D_METHOD("append_at_cursor", "text"), &LineEdit::append_at_cursor);
+ ClassDB::bind_method(D_METHOD("delete_char_at_cursor"), &LineEdit::delete_char);
+ ClassDB::bind_method(D_METHOD("delete_text", "from_column", "to_column"), &LineEdit::delete_text);
ClassDB::bind_method(D_METHOD("set_editable", "enabled"), &LineEdit::set_editable);
ClassDB::bind_method(D_METHOD("is_editable"), &LineEdit::is_editable);
ClassDB::bind_method(D_METHOD("set_secret", "enabled"), &LineEdit::set_secret);
@@ -1873,7 +1846,6 @@ void LineEdit::_bind_methods() {
}
LineEdit::LineEdit() {
-
undo_stack_pos = nullptr;
_create_undo_state();
align = ALIGN_LEFT;
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index 938974453a..d31a5cb8d8 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -35,7 +35,6 @@
#include "scene/gui/popup_menu.h"
class LineEdit : public Control {
-
GDCLASS(LineEdit, Control);
public:
@@ -94,7 +93,6 @@ private:
Ref<Texture2D> right_icon;
struct Selection {
-
int begin;
int end;
int cursor_start;
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 098e8297ad..f8c8bd4caf 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -31,7 +31,6 @@
#include "link_button.h"
void LinkButton::set_text(const String &p_text) {
-
text = p_text;
update();
minimum_size_changed();
@@ -42,58 +41,48 @@ String LinkButton::get_text() const {
}
void LinkButton::set_underline_mode(UnderlineMode p_underline_mode) {
-
underline_mode = p_underline_mode;
update();
}
LinkButton::UnderlineMode LinkButton::get_underline_mode() const {
-
return underline_mode;
}
Size2 LinkButton::get_minimum_size() const {
-
return get_theme_font("font")->get_string_size(text);
}
void LinkButton::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
RID ci = get_canvas_item();
Size2 size = get_size();
Color color;
bool do_underline = false;
switch (get_draw_mode()) {
-
case DRAW_NORMAL: {
-
color = get_theme_color("font_color");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
case DRAW_HOVER_PRESSED:
case DRAW_PRESSED: {
-
- if (has_theme_color("font_color_pressed"))
+ if (has_theme_color("font_color_pressed")) {
color = get_theme_color("font_color_pressed");
- else
+ } else {
color = get_theme_color("font_color");
+ }
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
-
color = get_theme_color("font_color_hover");
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
-
color = get_theme_color("font_color_disabled");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
@@ -101,7 +90,6 @@ void LinkButton::_notification(int p_what) {
}
if (has_focus()) {
-
Ref<StyleBox> style = get_theme_stylebox("focus");
style->draw(ci, Rect2(Point2(), size));
}
@@ -123,7 +111,6 @@ void LinkButton::_notification(int p_what) {
}
void LinkButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_text", "text"), &LinkButton::set_text);
ClassDB::bind_method(D_METHOD("get_text"), &LinkButton::get_text);
diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h
index 3bef25e249..ee37a29f9d 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -35,7 +35,6 @@
#include "scene/resources/bit_map.h"
class LinkButton : public BaseButton {
-
GDCLASS(LinkButton, BaseButton);
public:
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 1cd4ff4ff8..0299065f77 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -31,7 +31,6 @@
#include "margin_container.h"
Size2 MarginContainer::get_minimum_size() const {
-
int margin_left = get_theme_constant("margin_left");
int margin_top = get_theme_constant("margin_top");
int margin_right = get_theme_constant("margin_right");
@@ -40,20 +39,24 @@ Size2 MarginContainer::get_minimum_size() const {
Size2 max;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (!c->is_visible())
+ }
+ if (!c->is_visible()) {
continue;
+ }
Size2 s = c->get_combined_minimum_size();
- if (s.width > max.width)
+ if (s.width > max.width) {
max.width = s.width;
- if (s.height > max.height)
+ }
+ if (s.height > max.height) {
max.height = s.height;
+ }
}
max.width += (margin_left + margin_right);
@@ -63,10 +66,8 @@ Size2 MarginContainer::get_minimum_size() const {
}
void MarginContainer::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
-
int margin_left = get_theme_constant("margin_left");
int margin_top = get_theme_constant("margin_top");
int margin_right = get_theme_constant("margin_right");
@@ -75,12 +76,13 @@ void MarginContainer::_notification(int p_what) {
Size2 s = get_size();
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
int w = s.width - margin_left - margin_right;
int h = s.height - margin_top - margin_bottom;
@@ -88,7 +90,6 @@ void MarginContainer::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
} break;
}
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index a7d1f64e93..aa69fb39e7 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -34,25 +34,25 @@
#include "scene/main/window.h"
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
-
- if (disable_shortcuts)
+ if (disable_shortcuts) {
return;
+ }
if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
-
- if (!get_parent() || !is_visible_in_tree() || is_disabled())
+ if (!get_parent() || !is_visible_in_tree() || is_disabled()) {
return;
+ }
//bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));
//if (popup->activate_item_by_event(p_event, global_only))
// accept_event();
- if (popup->activate_item_by_event(p_event, false))
+ if (popup->activate_item_by_event(p_event, false)) {
accept_event();
+ }
}
}
void MenuButton::pressed() {
-
{
Window *w = Object::cast_to<Window>(get_viewport());
if (w && !w->is_embedding_subwindows()) {
@@ -75,39 +75,31 @@ void MenuButton::pressed() {
}
void MenuButton::_gui_input(Ref<InputEvent> p_event) {
-
BaseButton::_gui_input(p_event);
}
PopupMenu *MenuButton::get_popup() const {
-
return popup;
}
void MenuButton::_set_items(const Array &p_items) {
-
popup->set("items", p_items);
}
Array MenuButton::_get_items() const {
-
return popup->get("items");
}
void MenuButton::set_switch_on_hover(bool p_enabled) {
-
switch_on_hover = p_enabled;
}
bool MenuButton::is_switch_on_hover() {
-
return switch_on_hover;
}
void MenuButton::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
if (!is_visible_in_tree()) {
popup->hide();
}
@@ -115,7 +107,6 @@ void MenuButton::_notification(int p_what) {
}
void MenuButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_popup"), &MenuButton::get_popup);
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &MenuButton::_unhandled_key_input);
ClassDB::bind_method(D_METHOD("_set_items"), &MenuButton::_set_items);
@@ -131,12 +122,10 @@ void MenuButton::_bind_methods() {
}
void MenuButton::set_disable_shortcuts(bool p_disabled) {
-
disable_shortcuts = p_disabled;
}
MenuButton::MenuButton() {
-
switch_on_hover = false;
set_flat(true);
set_toggle_mode(true);
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 9abd11632f..0cd161c1f0 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -35,7 +35,6 @@
#include "scene/gui/popup_menu.h"
class MenuButton : public Button {
-
GDCLASS(MenuButton, Button);
bool clicked;
diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp
index cf10c4cfbd..bc71ae94f5 100644
--- a/scene/gui/nine_patch_rect.cpp
+++ b/scene/gui/nine_patch_rect.cpp
@@ -33,11 +33,10 @@
#include "servers/rendering_server.h"
void NinePatchRect::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return;
+ }
Rect2 rect = Rect2(Point2(), get_size());
Rect2 src_rect = region_rect;
@@ -50,11 +49,10 @@ void NinePatchRect::_notification(int p_what) {
}
Size2 NinePatchRect::get_minimum_size() const {
-
return Size2(margin[MARGIN_LEFT] + margin[MARGIN_RIGHT], margin[MARGIN_TOP] + margin[MARGIN_BOTTOM]);
}
-void NinePatchRect::_bind_methods() {
+void NinePatchRect::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &NinePatchRect::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &NinePatchRect::get_texture);
ClassDB::bind_method(D_METHOD("set_patch_margin", "margin", "value"), &NinePatchRect::set_patch_margin);
@@ -89,9 +87,9 @@ void NinePatchRect::_bind_methods() {
}
void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) {
-
- if (texture == p_tex)
+ if (texture == p_tex) {
return;
+ }
texture = p_tex;
update();
/*
@@ -104,12 +102,10 @@ void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) {
}
Ref<Texture2D> NinePatchRect::get_texture() const {
-
return texture;
}
void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
margin[p_margin] = p_size;
update();
@@ -131,15 +127,14 @@ void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) {
}
int NinePatchRect::get_patch_margin(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return margin[p_margin];
}
void NinePatchRect::set_region_rect(const Rect2 &p_region_rect) {
-
- if (region_rect == p_region_rect)
+ if (region_rect == p_region_rect) {
return;
+ }
region_rect = p_region_rect;
@@ -148,18 +143,15 @@ void NinePatchRect::set_region_rect(const Rect2 &p_region_rect) {
}
Rect2 NinePatchRect::get_region_rect() const {
-
return region_rect;
}
void NinePatchRect::set_draw_center(bool p_enabled) {
-
draw_center = p_enabled;
update();
}
bool NinePatchRect::is_draw_center_enabled() const {
-
return draw_center;
}
@@ -173,18 +165,15 @@ NinePatchRect::AxisStretchMode NinePatchRect::get_h_axis_stretch_mode() const {
}
void NinePatchRect::set_v_axis_stretch_mode(AxisStretchMode p_mode) {
-
axis_v = p_mode;
update();
}
NinePatchRect::AxisStretchMode NinePatchRect::get_v_axis_stretch_mode() const {
-
return axis_v;
}
NinePatchRect::NinePatchRect() {
-
margin[MARGIN_LEFT] = 0;
margin[MARGIN_RIGHT] = 0;
margin[MARGIN_BOTTOM] = 0;
diff --git a/scene/gui/nine_patch_rect.h b/scene/gui/nine_patch_rect.h
index 0ef7f6b299..23a40fb64b 100644
--- a/scene/gui/nine_patch_rect.h
+++ b/scene/gui/nine_patch_rect.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class NinePatchRect : public Control {
-
GDCLASS(NinePatchRect, Control);
public:
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index a03d6d0cdc..5780cc5e71 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -33,7 +33,6 @@
#include "core/print_string.h"
Size2 OptionButton::get_minimum_size() const {
-
Size2 minsize = Button::get_minimum_size();
if (has_theme_icon("arrow")) {
@@ -51,12 +50,11 @@ Size2 OptionButton::get_minimum_size() const {
}
void OptionButton::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_DRAW: {
-
- if (!has_theme_icon("arrow"))
+ if (!has_theme_icon("arrow")) {
return;
+ }
RID ci = get_canvas_item();
Ref<Texture2D> arrow = Control::get_theme_icon("arrow");
@@ -83,13 +81,11 @@ void OptionButton::_notification(int p_what) {
arrow->draw(ci, ofs, clr);
} break;
case NOTIFICATION_THEME_CHANGED: {
-
if (has_theme_icon("arrow")) {
_set_internal_margin(MARGIN_RIGHT, Control::get_theme_icon("arrow")->get_width());
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
if (!is_visible_in_tree()) {
popup->hide();
}
@@ -102,12 +98,10 @@ void OptionButton::_focused(int p_which) {
}
void OptionButton::_selected(int p_which) {
-
_select(p_which, true);
}
void OptionButton::pressed() {
-
Size2 size = get_size();
popup->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
popup->set_size(Size2(size.width, 0));
@@ -115,105 +109,96 @@ void OptionButton::pressed() {
}
void OptionButton::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id) {
-
popup->add_icon_radio_check_item(p_icon, p_label, p_id);
- if (popup->get_item_count() == 1)
+ if (popup->get_item_count() == 1) {
select(0);
+ }
}
-void OptionButton::add_item(const String &p_label, int p_id) {
+void OptionButton::add_item(const String &p_label, int p_id) {
popup->add_radio_check_item(p_label, p_id);
- if (popup->get_item_count() == 1)
+ if (popup->get_item_count() == 1) {
select(0);
+ }
}
void OptionButton::set_item_text(int p_idx, const String &p_text) {
-
popup->set_item_text(p_idx, p_text);
- if (current == p_idx)
+ if (current == p_idx) {
set_text(p_text);
+ }
}
-void OptionButton::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
+void OptionButton::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
popup->set_item_icon(p_idx, p_icon);
- if (current == p_idx)
+ if (current == p_idx) {
set_icon(p_icon);
+ }
}
-void OptionButton::set_item_id(int p_idx, int p_id) {
+void OptionButton::set_item_id(int p_idx, int p_id) {
popup->set_item_id(p_idx, p_id);
}
void OptionButton::set_item_metadata(int p_idx, const Variant &p_metadata) {
-
popup->set_item_metadata(p_idx, p_metadata);
}
void OptionButton::set_item_disabled(int p_idx, bool p_disabled) {
-
popup->set_item_disabled(p_idx, p_disabled);
}
String OptionButton::get_item_text(int p_idx) const {
-
return popup->get_item_text(p_idx);
}
Ref<Texture2D> OptionButton::get_item_icon(int p_idx) const {
-
return popup->get_item_icon(p_idx);
}
int OptionButton::get_item_id(int p_idx) const {
-
return popup->get_item_id(p_idx);
}
int OptionButton::get_item_index(int p_id) const {
-
return popup->get_item_index(p_id);
}
Variant OptionButton::get_item_metadata(int p_idx) const {
-
return popup->get_item_metadata(p_idx);
}
bool OptionButton::is_item_disabled(int p_idx) const {
-
return popup->is_item_disabled(p_idx);
}
int OptionButton::get_item_count() const {
-
return popup->get_item_count();
}
void OptionButton::add_separator() {
-
popup->add_separator();
}
void OptionButton::clear() {
-
popup->clear();
set_text("");
current = -1;
}
void OptionButton::_select(int p_which, bool p_emit) {
-
- if (p_which < 0)
+ if (p_which < 0) {
return;
- if (p_which == current)
+ }
+ if (p_which == current) {
return;
+ }
ERR_FAIL_INDEX(p_which, popup->get_item_count());
for (int i = 0; i < popup->get_item_count(); i++) {
-
popup->set_item_checked(i, i == p_which);
}
@@ -221,57 +206,53 @@ void OptionButton::_select(int p_which, bool p_emit) {
set_text(popup->get_item_text(current));
set_icon(popup->get_item_icon(current));
- if (is_inside_tree() && p_emit)
+ if (is_inside_tree() && p_emit) {
emit_signal("item_selected", current);
+ }
}
void OptionButton::_select_int(int p_which) {
-
- if (p_which < 0 || p_which >= popup->get_item_count())
+ if (p_which < 0 || p_which >= popup->get_item_count()) {
return;
+ }
_select(p_which, false);
}
void OptionButton::select(int p_idx) {
-
_select(p_idx, false);
}
int OptionButton::get_selected() const {
-
return current;
}
int OptionButton::get_selected_id() const {
-
int idx = get_selected();
- if (idx < 0)
+ if (idx < 0) {
return 0;
+ }
return get_item_id(current);
}
-Variant OptionButton::get_selected_metadata() const {
+Variant OptionButton::get_selected_metadata() const {
int idx = get_selected();
- if (idx < 0)
+ if (idx < 0) {
return Variant();
+ }
return get_item_metadata(current);
}
void OptionButton::remove_item(int p_idx) {
-
popup->remove_item(p_idx);
}
PopupMenu *OptionButton::get_popup() const {
-
return popup;
}
Array OptionButton::_get_items() const {
-
Array items;
for (int i = 0; i < get_item_count(); i++) {
-
items.push_back(get_item_text(i));
items.push_back(get_item_icon(i));
items.push_back(is_item_disabled(i));
@@ -281,13 +262,12 @@ Array OptionButton::_get_items() const {
return items;
}
-void OptionButton::_set_items(const Array &p_items) {
+void OptionButton::_set_items(const Array &p_items) {
ERR_FAIL_COND(p_items.size() % 5);
clear();
for (int i = 0; i < p_items.size(); i += 5) {
-
String text = p_items[i + 0];
Ref<Texture2D> icon = p_items[i + 1];
bool disabled = p_items[i + 2];
@@ -303,12 +283,10 @@ void OptionButton::_set_items(const Array &p_items) {
}
void OptionButton::get_translatable_strings(List<String> *p_strings) const {
-
popup->get_translatable_strings(p_strings);
}
void OptionButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_item", "label", "id"), &OptionButton::add_item, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("add_icon_item", "texture", "label", "id"), &OptionButton::add_icon_item, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_item_text", "idx", "text"), &OptionButton::set_item_text);
@@ -345,7 +323,6 @@ void OptionButton::_bind_methods() {
}
OptionButton::OptionButton() {
-
current = -1;
set_toggle_mode(true);
set_text_align(ALIGN_LEFT);
@@ -357,9 +334,6 @@ OptionButton::OptionButton() {
popup = memnew(PopupMenu);
popup->hide();
add_child(popup);
- // popup->set_pass_on_modal_close_click(false);
- // popup->set_notify_transform(true);
- popup->set_allow_search(true);
popup->connect("index_pressed", callable_mp(this, &OptionButton::_selected));
popup->connect("id_focused", callable_mp(this, &OptionButton::_focused));
popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false));
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index 9658e1fea8..69a94a34f3 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -35,7 +35,6 @@
#include "scene/gui/popup_menu.h"
class OptionButton : public Button {
-
GDCLASS(OptionButton, Button);
PopupMenu *popup;
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index a17d0eb9c6..d8d9beca2b 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -33,9 +33,7 @@
#include "core/print_string.h"
void Panel::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
RID ci = get_canvas_item();
Ref<StyleBox> style = mode == MODE_BACKGROUND ? get_theme_stylebox("panel") : get_theme_stylebox("panel_fg");
style->draw(ci, Rect2(Point2(), get_size()));
@@ -46,6 +44,7 @@ void Panel::set_mode(Mode p_mode) {
mode = p_mode;
update();
}
+
Panel::Mode Panel::get_mode() const {
return mode;
}
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index 75e266b6a6..a68c3d3f0c 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class Panel : public Control {
-
GDCLASS(Panel, Control);
public:
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index 62b9296409..9abdfac009 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -31,56 +31,57 @@
#include "panel_container.h"
Size2 PanelContainer::get_minimum_size() const {
-
Ref<StyleBox> style;
- if (has_theme_stylebox("panel"))
+ if (has_theme_stylebox("panel")) {
style = get_theme_stylebox("panel");
- else
+ } else {
style = get_theme_stylebox("panel", "PanelContainer");
+ }
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible()) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width, minsize.width);
ms.height = MAX(ms.height, minsize.height);
}
- if (style.is_valid())
+ if (style.is_valid()) {
ms += style->get_minimum_size();
+ }
return ms;
}
void PanelContainer::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
RID ci = get_canvas_item();
Ref<StyleBox> style;
- if (has_theme_stylebox("panel"))
+ if (has_theme_stylebox("panel")) {
style = get_theme_stylebox("panel");
- else
+ } else {
style = get_theme_stylebox("panel", "PanelContainer");
+ }
style->draw(ci, Rect2(Point2(), get_size()));
}
if (p_what == NOTIFICATION_SORT_CHILDREN) {
-
Ref<StyleBox> style;
- if (has_theme_stylebox("panel"))
+ if (has_theme_stylebox("panel")) {
style = get_theme_stylebox("panel");
- else
+ } else {
style = get_theme_stylebox("panel", "PanelContainer");
+ }
Size2 size = get_size();
Point2 ofs;
@@ -90,12 +91,13 @@ void PanelContainer::_notification(int p_what) {
}
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
fit_child_in_rect(c, Rect2(ofs, size));
}
diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h
index 5623c3484b..b68bc223dc 100644
--- a/scene/gui/panel_container.h
+++ b/scene/gui/panel_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class PanelContainer : public Container {
-
GDCLASS(PanelContainer, Container);
protected:
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 6edafc65a0..5fc5f9b669 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -42,15 +42,13 @@ void Popup::_input_from_window(const Ref<InputEvent> &p_event) {
}
void Popup::_parent_focused() {
-
_close_pressed();
}
-void Popup::_notification(int p_what) {
+void Popup::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) {
-
parent_visible = get_parent_visible_window();
if (parent_visible) {
parent_visible->connect("focus_entered", callable_mp(this, &Popup::_parent_focused));
@@ -79,7 +77,6 @@ void Popup::_notification(int p_what) {
}
void Popup::_close_pressed() {
-
Window *parent_window = parent_visible;
if (parent_visible) {
parent_visible->disconnect("focus_entered", callable_mp(this, &Popup::_parent_focused));
@@ -98,8 +95,8 @@ void Popup::_close_pressed() {
void Popup::set_as_minsize() {
set_size(get_contents_minimum_size());
}
-void Popup::_bind_methods() {
+void Popup::_bind_methods() {
ADD_SIGNAL(MethodInfo("popup_hide"));
}
@@ -133,7 +130,6 @@ Rect2i Popup::_popup_adjust_rect() const {
}
Popup::Popup() {
-
parent_visible = nullptr;
set_wrap_controls(true);
@@ -149,18 +145,19 @@ Popup::~Popup() {
}
Size2 PopupPanel::_get_contents_minimum_size() const {
-
Ref<StyleBox> p = get_theme_stylebox("panel", get_class_name());
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || c == panel)
+ if (!c || c == panel) {
continue;
+ }
- if (c->is_set_as_toplevel())
+ if (c->is_set_as_toplevel()) {
continue;
+ }
Size2 cms = c->get_combined_minimum_size();
ms.x = MAX(cms.x, ms.x);
@@ -171,7 +168,6 @@ Size2 PopupPanel::_get_contents_minimum_size() const {
}
void PopupPanel::_update_child_rects() {
-
Ref<StyleBox> p = get_theme_stylebox("panel", get_class_name());
Vector2 cpos(p->get_offset());
@@ -179,11 +175,13 @@ void PopupPanel::_update_child_rects() {
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
- if (c->is_set_as_toplevel())
+ if (c->is_set_as_toplevel()) {
continue;
+ }
if (c == panel) {
c->set_position(Vector2());
@@ -196,21 +194,17 @@ void PopupPanel::_update_child_rects() {
}
void PopupPanel::_notification(int p_what) {
-
if (p_what == NOTIFICATION_THEME_CHANGED) {
panel->add_theme_style_override("panel", get_theme_stylebox("panel", get_class_name()));
} else if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_ENTER_TREE) {
-
panel->add_theme_style_override("panel", get_theme_stylebox("panel", get_class_name()));
_update_child_rects();
} else if (p_what == NOTIFICATION_WM_SIZE_CHANGED) {
-
_update_child_rects();
}
}
PopupPanel::PopupPanel() {
-
panel = memnew(Panel);
add_child(panel);
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 6cd2b4028f..0e32d55cb6 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -34,7 +34,6 @@
#include "scene/main/window.h"
class Popup : public Window {
-
GDCLASS(Popup, Window);
Window *parent_visible;
@@ -56,7 +55,6 @@ public:
};
class PopupPanel : public Popup {
-
GDCLASS(PopupPanel, Popup);
Panel *panel;
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 9c48801ec1..6e19b820e0 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -38,18 +38,17 @@
#include "scene/gui/control.h"
String PopupMenu::_get_accel_text(int p_item) const {
-
ERR_FAIL_INDEX_V(p_item, items.size(), String());
- if (items[p_item].shortcut.is_valid())
+ if (items[p_item].shortcut.is_valid()) {
return items[p_item].shortcut->get_as_text();
- else if (items[p_item].accel)
+ } else if (items[p_item].accel) {
return keycode_get_string(items[p_item].accel);
+ }
return String();
}
Size2 PopupMenu::_get_contents_minimum_size() const {
-
int vseparation = get_theme_constant("vseparation");
int hseparation = get_theme_constant("hseparation");
@@ -64,37 +63,36 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
bool has_check = false;
for (int i = 0; i < items.size(); i++) {
-
Size2 size;
if (!items[i].icon.is_null()) {
-
Size2 icon_size = items[i].icon->get_size();
size.height = MAX(icon_size.height, font_h);
icon_w = MAX(icon_size.width + hseparation, icon_w);
} else {
-
size.height = font_h;
}
size.width += items[i].h_ofs;
- if (items[i].checkable_type)
+ if (items[i].checkable_type) {
has_check = true;
+ }
String text = items[i].xl_text;
size.width += font->get_string_size(text).width;
- if (i > 0)
+ if (i > 0) {
size.height += vseparation;
+ }
if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
-
int accel_w = hseparation * 2;
accel_w += font->get_string_size(_get_accel_text(i)).width;
accel_max_w = MAX(accel_w, accel_max_w);
}
- if (items[i].submenu != "")
+ if (items[i].submenu != "") {
size.width += get_theme_icon("submenu")->get_width();
+ }
max_w = MAX(max_w, size.width);
@@ -102,39 +100,38 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
}
minsize.width += max_w + icon_w + accel_max_w;
- if (has_check)
+ if (has_check) {
minsize.width += check_w;
+ }
return minsize;
}
int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
-
- if (p_over.x < 0 || p_over.x >= get_size().width)
+ if (p_over.x < 0 || p_over.x >= get_size().width) {
return -1;
+ }
Ref<StyleBox> style = get_theme_stylebox("panel");
Point2 ofs = style->get_offset();
- if (ofs.y > p_over.y)
+ if (ofs.y > p_over.y) {
return -1;
+ }
Ref<Font> font = get_theme_font("font");
int vseparation = get_theme_constant("vseparation");
float font_h = font->get_height();
for (int i = 0; i < items.size(); i++) {
-
ofs.y += vseparation;
float h;
if (!items[i].icon.is_null()) {
-
Size2 icon_size = items[i].icon->get_size();
h = MAX(icon_size.height, font_h);
} else {
-
h = font_h;
}
@@ -148,13 +145,13 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
}
void PopupMenu::_activate_submenu(int over) {
-
Node *n = get_node(items[over].submenu);
ERR_FAIL_COND_MSG(!n, "Item subnode does not exist: " + items[over].submenu + ".");
Popup *pm = Object::cast_to<Popup>(n);
ERR_FAIL_COND_MSG(!pm, "Item subnode is not a Popup: " + items[over].submenu + ".");
- if (pm->is_visible())
+ if (pm->is_visible()) {
return; //already visible!
+ }
Point2 p = get_position();
Rect2 pr(p, get_size());
@@ -163,8 +160,9 @@ void PopupMenu::_activate_submenu(int over) {
Point2 pos = p + Point2(get_size().width, items[over]._ofs_cache - style->get_offset().y);
Size2 size = pm->get_size();
// fix pos
- if (pos.x + size.width > get_parent_rect().size.width)
+ if (pos.x + size.width > get_parent_rect().size.width) {
pos.x = p.x - size.width;
+ }
pm->set_position(pos);
// pm->set_scale(get_global_transform().get_scale());
@@ -172,7 +170,6 @@ void PopupMenu::_activate_submenu(int over) {
PopupMenu *pum = Object::cast_to<PopupMenu>(pm);
if (pum) {
-
pr.position -= pum->get_position();
pum->clear_autohide_areas();
pum->add_autohide_area(Rect2(pr.position.x, pr.position.y, pr.size.x, items[over]._ofs_cache));
@@ -184,18 +181,17 @@ void PopupMenu::_activate_submenu(int over) {
}
void PopupMenu::_submenu_timeout() {
-
//if (!has_focus()) {
// return; //do not activate if not has focus
//}
- if (mouse_over == submenu_over)
+ if (mouse_over == submenu_over) {
_activate_submenu(mouse_over);
+ }
submenu_over = -1;
}
void PopupMenu::_scroll(float p_factor, const Point2 &p_over) {
-
int vseparation = get_theme_constant("vseparation");
Ref<Font> font = get_theme_font("font");
@@ -226,20 +222,18 @@ void PopupMenu::_scroll(float p_factor, const Point2 &p_over) {
}
void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
-
if (p_event->is_action("ui_down") && p_event->is_pressed()) {
-
int search_from = mouse_over + 1;
- if (search_from >= items.size())
+ if (search_from >= items.size()) {
search_from = 0;
+ }
for (int i = search_from; i < items.size(); i++) {
-
- if (i < 0 || i >= items.size())
+ if (i < 0 || i >= items.size()) {
continue;
+ }
if (!items[i].separator && !items[i].disabled) {
-
mouse_over = i;
emit_signal("id_focused", i);
control->update();
@@ -248,18 +242,17 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
}
}
} else if (p_event->is_action("ui_up") && p_event->is_pressed()) {
-
int search_from = mouse_over - 1;
- if (search_from < 0)
+ if (search_from < 0) {
search_from = items.size() - 1;
+ }
for (int i = search_from; i >= 0; i--) {
-
- if (i >= items.size())
+ if (i >= items.size()) {
continue;
+ }
if (!items[i].separator && !items[i].disabled) {
-
mouse_over = i;
emit_signal("id_focused", i);
control->update();
@@ -268,22 +261,18 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
}
}
} else if (p_event->is_action("ui_left") && p_event->is_pressed()) {
-
Node *n = get_parent();
if (n && Object::cast_to<PopupMenu>(n)) {
hide();
set_input_as_handled();
}
} else if (p_event->is_action("ui_right") && p_event->is_pressed()) {
-
if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator && items[mouse_over].submenu != "" && submenu_over != mouse_over) {
_activate_submenu(mouse_over);
set_input_as_handled();
}
} else if (p_event->is_action("ui_accept") && p_event->is_pressed()) {
-
if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator) {
-
if (items[mouse_over].submenu != "" && submenu_over != mouse_over) {
_activate_submenu(mouse_over);
} else {
@@ -296,25 +285,21 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
-
- if (b->is_pressed())
+ if (b->is_pressed()) {
return;
+ }
int button_idx = b->get_button_index();
switch (button_idx) {
-
case BUTTON_WHEEL_DOWN: {
-
_scroll(-b->get_factor(), b->get_position());
} break;
case BUTTON_WHEEL_UP: {
-
_scroll(b->get_factor(), b->get_position());
} break;
default: {
// Allow activating item by releasing the LMB or any that was down when the popup appeared
if (button_idx == BUTTON_LEFT || (initial_button_mask & (1 << (button_idx - 1)))) {
-
bool was_during_grabbed_click = during_grabbed_click;
during_grabbed_click = false;
initial_button_mask = 0;
@@ -332,11 +317,11 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
break; //non-activable
}
- if (items[over].separator || items[over].disabled)
+ if (items[over].separator || items[over].disabled) {
break;
+ }
if (items[over].submenu != "") {
-
_activate_submenu(over);
return;
}
@@ -351,17 +336,15 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
-
if (invalidated_click) {
moved += m->get_relative();
- if (moved.length() > 4)
+ if (moved.length() > 4) {
invalidated_click = false;
+ }
}
for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
-
if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) {
-
_close_pressed();
return;
}
@@ -395,7 +378,6 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (allow_search && k.is_valid() && k->get_unicode() && k->is_pressed()) {
-
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now - search_time_msec;
uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000));
@@ -405,19 +387,22 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
search_string = "";
}
- if (String::chr(k->get_unicode()) != search_string)
+ if (String::chr(k->get_unicode()) != search_string) {
search_string += String::chr(k->get_unicode());
+ }
for (int i = mouse_over + 1; i <= items.size(); i++) {
if (i == items.size()) {
- if (mouse_over <= 0)
+ if (mouse_over <= 0) {
break;
- else
+ } else {
i = 0;
+ }
}
- if (i == mouse_over)
+ if (i == mouse_over) {
break;
+ }
if (items[i].text.findn(search_string) == 0) {
mouse_over = i;
@@ -431,7 +416,6 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
}
void PopupMenu::_draw() {
-
RID ci = control->get_canvas_item();
Size2 size = get_size();
@@ -460,39 +444,39 @@ void PopupMenu::_draw() {
float icon_ofs = 0.0;
bool has_check = false;
for (int i = 0; i < items.size(); i++) {
-
- if (!items[i].icon.is_null())
+ if (!items[i].icon.is_null()) {
icon_ofs = MAX(items[i].icon->get_size().width, icon_ofs);
+ }
- if (items[i].checkable_type)
+ if (items[i].checkable_type) {
has_check = true;
+ }
}
- if (icon_ofs > 0.0)
+ if (icon_ofs > 0.0) {
icon_ofs += hseparation;
+ }
float check_ofs = 0.0;
- if (has_check)
+ if (has_check) {
check_ofs = MAX(get_theme_icon("checked")->get_width(), get_theme_icon("radio_checked")->get_width()) + hseparation;
+ }
for (int i = 0; i < items.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
ofs.y += vseparation;
+ }
Point2 item_ofs = ofs;
Size2 icon_size;
float h;
if (!items[i].icon.is_null()) {
-
icon_size = items[i].icon->get_size();
h = MAX(icon_size.height, font_h);
} else {
-
h = font_h;
}
if (i == mouse_over) {
-
hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation / 2), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation)));
}
@@ -500,7 +484,6 @@ void PopupMenu::_draw() {
item_ofs.x += items[i].h_ofs;
if (items[i].separator) {
-
int sep_h = separator->get_center_size().height + separator->get_minimum_size().height;
if (text != String()) {
int ss = font->get_string_size(text).width;
@@ -535,13 +518,11 @@ void PopupMenu::_draw() {
item_ofs.y += font->get_ascent();
if (items[i].separator) {
-
if (text != String()) {
int center = (get_size().width - font->get_string_size(text).width) / 2;
font->draw(ci, Point2(center, item_ofs.y + Math::floor((h - font_h) / 2.0)), text, font_color_disabled);
}
} else {
-
item_ofs.x += icon_ofs + check_ofs;
font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text, items[i].disabled ? font_color_disabled : (i == mouse_over ? font_color_hover : font_color));
}
@@ -560,11 +541,8 @@ void PopupMenu::_draw() {
}
void PopupMenu::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
PopupMenu *pm = Object::cast_to<PopupMenu>(get_parent());
if (pm) {
// Inherit submenu's popup delay time from parent menu
@@ -573,7 +551,6 @@ void PopupMenu::_notification(int p_what) {
}
} break;
case NOTIFICATION_TRANSLATION_CHANGED: {
-
for (int i = 0; i < items.size(); i++) {
items.write[i].xl_text = tr(items[i].text);
}
@@ -582,23 +559,19 @@ void PopupMenu::_notification(int p_what) {
control->update();
} break;
case NOTIFICATION_WM_MOUSE_ENTER: {
-
//grab_focus();
} break;
case NOTIFICATION_WM_MOUSE_EXIT: {
-
if (mouse_over >= 0 && (items[mouse_over].submenu == "" || submenu_over != -1)) {
mouse_over = -1;
control->update();
}
} break;
case NOTIFICATION_POST_POPUP: {
-
initial_button_mask = Input::get_singleton()->get_mouse_button_mask();
during_grabbed_click = (bool)initial_button_mask;
} break;
case NOTIFICATION_WM_SIZE_CHANGED: {
-
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
//only used when using operating system windows
@@ -607,7 +580,6 @@ void PopupMenu::_notification(int p_what) {
mouse_pos -= get_position();
for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
-
if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E->get().has_point(mouse_pos)) {
_close_pressed();
return;
@@ -616,7 +588,6 @@ void PopupMenu::_notification(int p_what) {
}
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
if (!is_visible()) {
if (mouse_over >= 0) {
mouse_over = -1;
@@ -624,16 +595,19 @@ void PopupMenu::_notification(int p_what) {
}
for (int i = 0; i < items.size(); i++) {
- if (items[i].submenu == "")
+ if (items[i].submenu == "") {
continue;
+ }
Node *n = get_node(items[i].submenu);
- if (!n)
+ if (!n) {
continue;
+ }
PopupMenu *pm = Object::cast_to<PopupMenu>(n);
- if (!pm || !pm->is_visible())
+ if (!pm || !pm->is_visible()) {
continue;
+ }
pm->hide();
}
@@ -659,7 +633,6 @@ void PopupMenu::_notification(int p_what) {
item.accel = p_accel;
void PopupMenu::add_item(const String &p_label, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
items.push_back(item);
@@ -668,7 +641,6 @@ void PopupMenu::add_item(const String &p_label, int p_id, uint32_t p_accel) {
}
void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.icon = p_icon;
@@ -678,7 +650,6 @@ void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_labe
}
void PopupMenu::add_check_item(const String &p_label, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
@@ -688,7 +659,6 @@ void PopupMenu::add_check_item(const String &p_label, int p_id, uint32_t p_accel
}
void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.icon = p_icon;
@@ -699,7 +669,6 @@ void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String &
}
void PopupMenu::add_radio_check_item(const String &p_label, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
@@ -709,7 +678,6 @@ void PopupMenu::add_radio_check_item(const String &p_label, int p_id, uint32_t p
}
void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.icon = p_icon;
@@ -720,7 +688,6 @@ void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const St
}
void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int p_default_state, int p_id, uint32_t p_accel) {
-
Item item;
ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel);
item.max_states = p_max_states;
@@ -740,7 +707,6 @@ void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int
item.shortcut_is_global = p_global;
void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
-
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
items.push_back(item);
@@ -749,7 +715,6 @@ void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_g
}
void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
-
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
@@ -759,7 +724,6 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortC
}
void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
-
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
@@ -769,7 +733,6 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bo
}
void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
-
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
@@ -780,7 +743,6 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<
}
void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
-
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.checkable_type = Item::CHECKABLE_TYPE_RADIO_BUTTON;
@@ -790,7 +752,6 @@ void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_
}
void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) {
-
Item item;
ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global);
item.icon = p_icon;
@@ -801,7 +762,6 @@ void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, cons
}
void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, int p_id) {
-
Item item;
item.text = p_label;
item.xl_text = tr(p_label);
@@ -818,7 +778,6 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
/* Methods to modify existing items. */
void PopupMenu::set_item_text(int p_idx, const String &p_text) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].text = p_text;
items.write[p_idx].xl_text = tr(p_text);
@@ -826,16 +785,16 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) {
control->update();
child_controls_changed();
}
-void PopupMenu::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
+void PopupMenu::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].icon = p_icon;
control->update();
child_controls_changed();
}
-void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
+void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checked = p_checked;
@@ -843,8 +802,8 @@ void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
control->update();
child_controls_changed();
}
-void PopupMenu::set_item_id(int p_idx, int p_id) {
+void PopupMenu::set_item_id(int p_idx, int p_id) {
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].id = p_id;
@@ -853,7 +812,6 @@ void PopupMenu::set_item_id(int p_idx, int p_id) {
}
void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].accel = p_accel;
@@ -862,7 +820,6 @@ void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
}
void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].metadata = p_meta;
control->update();
@@ -870,7 +827,6 @@ void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
}
void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].disabled = p_disabled;
control->update();
@@ -878,7 +834,6 @@ void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
}
void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].submenu = p_submenu;
control->update();
@@ -886,7 +841,6 @@ void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
}
void PopupMenu::toggle_item_checked(int p_idx) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checked = !items[p_idx].checked;
control->update();
@@ -894,82 +848,71 @@ void PopupMenu::toggle_item_checked(int p_idx) {
}
String PopupMenu::get_item_text(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].text;
}
int PopupMenu::get_item_idx_from_text(const String &text) const {
-
for (int idx = 0; idx < items.size(); idx++) {
- if (items[idx].text == text)
+ if (items[idx].text == text) {
return idx;
+ }
}
return -1;
}
Ref<Texture2D> PopupMenu::get_item_icon(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>());
return items[p_idx].icon;
}
uint32_t PopupMenu::get_item_accelerator(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), 0);
return items[p_idx].accel;
}
Variant PopupMenu::get_item_metadata(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Variant());
return items[p_idx].metadata;
}
bool PopupMenu::is_item_disabled(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].disabled;
}
bool PopupMenu::is_item_checked(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].checked;
}
int PopupMenu::get_item_id(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), 0);
return items[p_idx].id;
}
int PopupMenu::get_item_index(int p_id) const {
-
for (int i = 0; i < items.size(); i++) {
-
- if (items[i].id == p_id)
+ if (items[i].id == p_id) {
return i;
+ }
}
return -1;
}
String PopupMenu::get_item_submenu(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].submenu;
}
String PopupMenu::get_item_tooltip(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].tooltip;
}
Ref<ShortCut> PopupMenu::get_item_shortcut(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<ShortCut>());
return items[p_idx].shortcut;
}
@@ -980,7 +923,6 @@ int PopupMenu::get_item_state(int p_idx) const {
}
void PopupMenu::set_item_as_separator(int p_idx, bool p_separator) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].separator = p_separator;
control->update();
@@ -992,21 +934,18 @@ bool PopupMenu::is_item_separator(int p_idx) const {
}
void PopupMenu::set_item_as_checkable(int p_idx, bool p_checkable) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checkable_type = p_checkable ? Item::CHECKABLE_TYPE_CHECK_BOX : Item::CHECKABLE_TYPE_NONE;
control->update();
}
void PopupMenu::set_item_as_radio_checkable(int p_idx, bool p_radio_checkable) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].checkable_type = p_radio_checkable ? Item::CHECKABLE_TYPE_RADIO_BUTTON : Item::CHECKABLE_TYPE_NONE;
control->update();
}
void PopupMenu::set_item_tooltip(int p_idx, const String &p_tooltip) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].tooltip = p_tooltip;
control->update();
@@ -1028,7 +967,6 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bo
}
void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].h_ofs = p_offset;
control->update();
@@ -1036,29 +974,27 @@ void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
}
void PopupMenu::set_item_multistate(int p_idx, int p_state) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].state = p_state;
control->update();
}
void PopupMenu::set_item_shortcut_disabled(int p_idx, bool p_disabled) {
-
ERR_FAIL_INDEX(p_idx, items.size());
items.write[p_idx].shortcut_is_disabled = p_disabled;
control->update();
}
void PopupMenu::toggle_item_multistate(int p_idx) {
-
ERR_FAIL_INDEX(p_idx, items.size());
if (0 >= items[p_idx].max_states) {
return;
}
++items.write[p_idx].state;
- if (items.write[p_idx].max_states <= items[p_idx].state)
+ if (items.write[p_idx].max_states <= items[p_idx].state) {
items.write[p_idx].state = 0;
+ }
control->update();
}
@@ -1074,43 +1010,45 @@ bool PopupMenu::is_item_radio_checkable(int p_idx) const {
}
bool PopupMenu::is_item_shortcut_disabled(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].shortcut_is_disabled;
}
int PopupMenu::get_current_index() const {
-
return mouse_over;
}
int PopupMenu::get_item_count() const {
-
return items.size();
}
bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_for_global_only) {
-
uint32_t code = 0;
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
code = k->get_keycode();
- if (code == 0)
+ if (code == 0) {
code = k->get_unicode();
- if (k->get_control())
+ }
+ if (k->get_control()) {
code |= KEY_MASK_CTRL;
- if (k->get_alt())
+ }
+ if (k->get_alt()) {
code |= KEY_MASK_ALT;
- if (k->get_metakey())
+ }
+ if (k->get_metakey()) {
code |= KEY_MASK_META;
- if (k->get_shift())
+ }
+ if (k->get_shift()) {
code |= KEY_MASK_SHIFT;
+ }
}
for (int i = 0; i < items.size(); i++) {
- if (is_item_disabled(i) || items[i].shortcut_is_disabled)
+ if (is_item_disabled(i) || items[i].shortcut_is_disabled) {
continue;
+ }
if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event) && (items[i].shortcut_is_global || !p_for_global_only)) {
activate_item(i);
@@ -1124,12 +1062,14 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo
if (items[i].submenu != "") {
Node *n = get_node(items[i].submenu);
- if (!n)
+ if (!n) {
continue;
+ }
PopupMenu *pm = Object::cast_to<PopupMenu>(n);
- if (!pm)
+ if (!pm) {
continue;
+ }
if (pm->activate_item_by_event(p_event, p_for_global_only)) {
return true;
@@ -1140,7 +1080,6 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo
}
void PopupMenu::activate_item(int p_item) {
-
ERR_FAIL_INDEX(p_item, items.size());
ERR_FAIL_COND(items[p_item].separator);
int id = items[p_item].id >= 0 ? items[p_item].id : p_item;
@@ -1153,13 +1092,16 @@ void PopupMenu::activate_item(int p_item) {
// with hide_on_item_selection enabled
if (items[p_item].checkable_type) {
- if (!hide_on_checkable_item_selection || !pop->is_hide_on_checkable_item_selection())
+ if (!hide_on_checkable_item_selection || !pop->is_hide_on_checkable_item_selection()) {
break;
+ }
} else if (0 < items[p_item].max_states) {
- if (!hide_on_multistate_item_selection || !pop->is_hide_on_multistate_item_selection())
+ if (!hide_on_multistate_item_selection || !pop->is_hide_on_multistate_item_selection()) {
break;
- } else if (!hide_on_item_selection || !pop->is_hide_on_item_selection())
+ }
+ } else if (!hide_on_item_selection || !pop->is_hide_on_item_selection()) {
break;
+ }
pop->hide();
next = next->get_parent();
@@ -1172,13 +1114,16 @@ void PopupMenu::activate_item(int p_item) {
bool need_hide = true;
if (items[p_item].checkable_type) {
- if (!hide_on_checkable_item_selection)
+ if (!hide_on_checkable_item_selection) {
need_hide = false;
+ }
} else if (0 < items[p_item].max_states) {
- if (!hide_on_multistate_item_selection)
+ if (!hide_on_multistate_item_selection) {
need_hide = false;
- } else if (!hide_on_item_selection)
+ }
+ } else if (!hide_on_item_selection) {
need_hide = false;
+ }
emit_signal("id_pressed", id);
emit_signal("index_pressed", p_item);
@@ -1189,7 +1134,6 @@ void PopupMenu::activate_item(int p_item) {
}
void PopupMenu::remove_item(int p_idx) {
-
ERR_FAIL_INDEX(p_idx, items.size());
if (items[p_idx].shortcut.is_valid()) {
@@ -1202,7 +1146,6 @@ void PopupMenu::remove_item(int p_idx) {
}
void PopupMenu::add_separator(const String &p_text) {
-
Item sep;
sep.separator = true;
sep.id = -1;
@@ -1215,7 +1158,6 @@ void PopupMenu::add_separator(const String &p_text) {
}
void PopupMenu::clear() {
-
for (int i = 0; i < items.size(); i++) {
if (items[i].shortcut.is_valid()) {
_unref_shortcut(items[i].shortcut);
@@ -1228,10 +1170,8 @@ void PopupMenu::clear() {
}
Array PopupMenu::_get_items() const {
-
Array items;
for (int i = 0; i < get_item_count(); i++) {
-
items.push_back(get_item_text(i));
items.push_back(get_item_icon(i));
// For compatibility, use false/true for no/checkbox and integers for other values
@@ -1251,7 +1191,6 @@ Array PopupMenu::_get_items() const {
}
void PopupMenu::_ref_shortcut(Ref<ShortCut> p_sc) {
-
if (!shortcut_refcount.has(p_sc)) {
shortcut_refcount[p_sc] = 1;
p_sc->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update));
@@ -1261,7 +1200,6 @@ void PopupMenu::_ref_shortcut(Ref<ShortCut> p_sc) {
}
void PopupMenu::_unref_shortcut(Ref<ShortCut> p_sc) {
-
ERR_FAIL_COND(!shortcut_refcount.has(p_sc));
shortcut_refcount[p_sc]--;
if (shortcut_refcount[p_sc] == 0) {
@@ -1271,12 +1209,10 @@ void PopupMenu::_unref_shortcut(Ref<ShortCut> p_sc) {
}
void PopupMenu::_set_items(const Array &p_items) {
-
ERR_FAIL_COND(p_items.size() % 10);
clear();
for (int i = 0; i < p_items.size(); i += 10) {
-
String text = p_items[i + 0];
Ref<Texture2D> icon = p_items[i + 1];
// For compatibility, use false/true for no/checkbox and integers for other values
@@ -1313,87 +1249,74 @@ void PopupMenu::_set_items(const Array &p_items) {
// Hide on item selection determines whether or not the popup will close after item selection
void PopupMenu::set_hide_on_item_selection(bool p_enabled) {
-
hide_on_item_selection = p_enabled;
}
bool PopupMenu::is_hide_on_item_selection() const {
-
return hide_on_item_selection;
}
void PopupMenu::set_hide_on_checkable_item_selection(bool p_enabled) {
-
hide_on_checkable_item_selection = p_enabled;
}
bool PopupMenu::is_hide_on_checkable_item_selection() const {
-
return hide_on_checkable_item_selection;
}
void PopupMenu::set_hide_on_multistate_item_selection(bool p_enabled) {
-
hide_on_multistate_item_selection = p_enabled;
}
bool PopupMenu::is_hide_on_multistate_item_selection() const {
-
return hide_on_multistate_item_selection;
}
void PopupMenu::set_submenu_popup_delay(float p_time) {
-
- if (p_time <= 0)
+ if (p_time <= 0) {
p_time = 0.01;
+ }
submenu_timer->set_wait_time(p_time);
}
float PopupMenu::get_submenu_popup_delay() const {
-
return submenu_timer->get_wait_time();
}
void PopupMenu::set_allow_search(bool p_allow) {
-
allow_search = p_allow;
}
bool PopupMenu::get_allow_search() const {
-
return allow_search;
}
String PopupMenu::get_tooltip(const Point2 &p_pos) const {
-
int over = _get_mouse_over(p_pos);
- if (over < 0 || over >= items.size())
+ if (over < 0 || over >= items.size()) {
return "";
+ }
return items[over].tooltip;
}
void PopupMenu::set_parent_rect(const Rect2 &p_rect) {
-
parent_rect = p_rect;
}
void PopupMenu::get_translatable_strings(List<String> *p_strings) const {
-
for (int i = 0; i < items.size(); i++) {
-
- if (items[i].xl_text != "")
+ if (items[i].xl_text != "") {
p_strings->push_back(items[i].xl_text);
+ }
}
}
void PopupMenu::add_autohide_area(const Rect2 &p_area) {
-
autohide_areas.push_back(p_area);
}
void PopupMenu::clear_autohide_areas() {
-
autohide_areas.clear();
}
@@ -1406,7 +1329,6 @@ void PopupMenu::take_mouse_focus() {
}
void PopupMenu::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &PopupMenu::_gui_input);
ClassDB::bind_method(D_METHOD("add_item", "label", "id", "accel"), &PopupMenu::add_item, DEFVAL(-1), DEFVAL(0));
@@ -1501,14 +1423,12 @@ void PopupMenu::_bind_methods() {
}
void PopupMenu::popup(const Rect2 &p_bounds) {
-
moved = Vector2();
invalidated_click = true;
Popup::popup(p_bounds);
}
PopupMenu::PopupMenu() {
-
control = memnew(Control);
add_child(control);
@@ -1522,7 +1442,7 @@ PopupMenu::PopupMenu() {
during_grabbed_click = false;
invalidated_click = false;
- allow_search = false;
+ allow_search = true;
search_time_msec = 0;
search_string = "";
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index d5c1015863..d03a14d6e4 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -35,7 +35,6 @@
#include "scene/gui/shortcut.h"
class PopupMenu : public Popup {
-
GDCLASS(PopupMenu, Popup);
struct Item {
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 362c45453d..9246f1723d 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -31,7 +31,6 @@
#include "progress_bar.h"
Size2 ProgressBar::get_minimum_size() const {
-
Ref<StyleBox> bg = get_theme_stylebox("bg");
Ref<StyleBox> fg = get_theme_stylebox("fg");
Ref<Font> font = get_theme_font("font");
@@ -49,9 +48,7 @@ Size2 ProgressBar::get_minimum_size() const {
}
void ProgressBar::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
Ref<StyleBox> bg = get_theme_stylebox("bg");
Ref<StyleBox> fg = get_theme_stylebox("fg");
Ref<Font> font = get_theme_font("font");
@@ -62,7 +59,6 @@ void ProgressBar::_notification(int p_what) {
int mp = fg->get_minimum_size().width;
int p = r * (get_size().width - mp);
if (p > 0) {
-
draw_style_box(fg, Rect2(Point2(), Size2(p + fg->get_minimum_size().width, get_size().height)));
}
@@ -74,18 +70,15 @@ void ProgressBar::_notification(int p_what) {
}
void ProgressBar::set_percent_visible(bool p_visible) {
-
percent_visible = p_visible;
update();
}
bool ProgressBar::is_percent_visible() const {
-
return percent_visible;
}
void ProgressBar::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_percent_visible", "visible"), &ProgressBar::set_percent_visible);
ClassDB::bind_method(D_METHOD("is_percent_visible"), &ProgressBar::is_percent_visible);
ADD_GROUP("Percent", "percent_");
@@ -93,7 +86,6 @@ void ProgressBar::_bind_methods() {
}
ProgressBar::ProgressBar() {
-
set_v_size_flags(0);
set_step(0.01);
percent_visible = true;
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index 371d0370f6..d8eba921a3 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -34,7 +34,6 @@
#include "scene/gui/range.h"
class ProgressBar : public Range {
-
GDCLASS(ProgressBar, Range);
bool percent_visible;
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index ab2f64e1b4..59e26d9e38 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -44,7 +44,6 @@ String Range::get_configuration_warning() const {
}
void Range::_value_changed_notify() {
-
_value_changed(shared->val);
emit_signal("value_changed", shared->val);
update();
@@ -52,53 +51,57 @@ void Range::_value_changed_notify() {
}
void Range::Shared::emit_value_changed() {
-
for (Set<Range *>::Element *E = owners.front(); E; E = E->next()) {
Range *r = E->get();
- if (!r->is_inside_tree())
+ if (!r->is_inside_tree()) {
continue;
+ }
r->_value_changed_notify();
}
}
void Range::_changed_notify(const char *p_what) {
-
emit_signal("changed");
update();
_change_notify(p_what);
}
void Range::Shared::emit_changed(const char *p_what) {
-
for (Set<Range *>::Element *E = owners.front(); E; E = E->next()) {
Range *r = E->get();
- if (!r->is_inside_tree())
+ if (!r->is_inside_tree()) {
continue;
+ }
r->_changed_notify(p_what);
}
}
void Range::set_value(double p_val) {
-
- if (shared->step > 0)
+ if (shared->step > 0) {
p_val = Math::round(p_val / shared->step) * shared->step;
+ }
- if (_rounded_values)
+ if (_rounded_values) {
p_val = Math::round(p_val);
+ }
- if (!shared->allow_greater && p_val > shared->max - shared->page)
+ if (!shared->allow_greater && p_val > shared->max - shared->page) {
p_val = shared->max - shared->page;
+ }
- if (!shared->allow_lesser && p_val < shared->min)
+ if (!shared->allow_lesser && p_val < shared->min) {
p_val = shared->min;
+ }
- if (shared->val == p_val)
+ if (shared->val == p_val) {
return;
+ }
shared->val = p_val;
shared->emit_value_changed();
}
+
void Range::set_min(double p_min) {
shared->min = p_min;
set_value(shared->val);
@@ -107,19 +110,20 @@ void Range::set_min(double p_min) {
update_configuration_warning();
}
+
void Range::set_max(double p_max) {
shared->max = p_max;
set_value(shared->val);
shared->emit_changed("max");
}
-void Range::set_step(double p_step) {
+void Range::set_step(double p_step) {
shared->step = p_step;
shared->emit_changed("step");
}
-void Range::set_page(double p_page) {
+void Range::set_page(double p_page) {
shared->page = p_page;
set_value(shared->val);
@@ -127,37 +131,33 @@ void Range::set_page(double p_page) {
}
double Range::get_value() const {
-
return shared->val;
}
-double Range::get_min() const {
+double Range::get_min() const {
return shared->min;
}
-double Range::get_max() const {
+double Range::get_max() const {
return shared->max;
}
-double Range::get_step() const {
+double Range::get_step() const {
return shared->step;
}
-double Range::get_page() const {
+double Range::get_page() const {
return shared->page;
}
void Range::set_as_ratio(double p_value) {
-
double v;
if (shared->exp_ratio && get_min() >= 0) {
-
double exp_min = get_min() == 0 ? 0.0 : Math::log(get_min()) / Math::log((double)2);
double exp_max = Math::log(get_max()) / Math::log((double)2);
v = Math::pow(2, exp_min + (exp_max - exp_min) * p_value);
} else {
-
double percent = (get_max() - get_min()) * p_value;
if (get_step() > 0) {
double steps = round(percent / get_step());
@@ -169,12 +169,11 @@ void Range::set_as_ratio(double p_value) {
v = CLAMP(v, get_min(), get_max());
set_value(v);
}
-double Range::get_as_ratio() const {
+double Range::get_as_ratio() const {
ERR_FAIL_COND_V_MSG(Math::is_equal_approx(get_max(), get_min()), 0.0, "Cannot get ratio when minimum and maximum value are equal.");
if (shared->exp_ratio && get_min() >= 0) {
-
double exp_min = get_min() == 0 ? 0.0 : Math::log(get_min()) / Math::log((double)2);
double exp_max = Math::log(get_max()) / Math::log((double)2);
float value = CLAMP(get_value(), shared->min, shared->max);
@@ -183,21 +182,18 @@ double Range::get_as_ratio() const {
return CLAMP((v - exp_min) / (exp_max - exp_min), 0, 1);
} else {
-
float value = CLAMP(get_value(), shared->min, shared->max);
return CLAMP((value - get_min()) / (get_max() - get_min()), 0, 1);
}
}
void Range::_share(Node *p_range) {
-
Range *r = Object::cast_to<Range>(p_range);
ERR_FAIL_COND(!r);
share(r);
}
void Range::share(Range *p_range) {
-
ERR_FAIL_NULL(p_range);
p_range->_ref_shared(shared);
@@ -206,7 +202,6 @@ void Range::share(Range *p_range) {
}
void Range::unshare() {
-
Shared *nshared = memnew(Shared);
nshared->min = shared->min;
nshared->max = shared->max;
@@ -221,9 +216,9 @@ void Range::unshare() {
}
void Range::_ref_shared(Shared *p_shared) {
-
- if (shared && p_shared == shared)
+ if (shared && p_shared == shared) {
return;
+ }
_unref_shared();
shared = p_shared;
@@ -231,7 +226,6 @@ void Range::_ref_shared(Shared *p_shared) {
}
void Range::_unref_shared() {
-
if (shared) {
shared->owners.erase(this);
if (shared->owners.size() == 0) {
@@ -242,7 +236,6 @@ void Range::_unref_shared() {
}
void Range::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_value"), &Range::get_value);
ClassDB::bind_method(D_METHOD("get_min"), &Range::get_min);
ClassDB::bind_method(D_METHOD("get_max"), &Range::get_max);
@@ -283,49 +276,40 @@ void Range::_bind_methods() {
}
void Range::set_use_rounded_values(bool p_enable) {
-
_rounded_values = p_enable;
}
bool Range::is_using_rounded_values() const {
-
return _rounded_values;
}
void Range::set_exp_ratio(bool p_enable) {
-
shared->exp_ratio = p_enable;
update_configuration_warning();
}
bool Range::is_ratio_exp() const {
-
return shared->exp_ratio;
}
void Range::set_allow_greater(bool p_allow) {
-
shared->allow_greater = p_allow;
}
bool Range::is_greater_allowed() const {
-
return shared->allow_greater;
}
void Range::set_allow_lesser(bool p_allow) {
-
shared->allow_lesser = p_allow;
}
bool Range::is_lesser_allowed() const {
-
return shared->allow_lesser;
}
Range::Range() {
-
shared = memnew(Shared);
shared->min = 0;
shared->max = 100;
@@ -341,6 +325,5 @@ Range::Range() {
}
Range::~Range() {
-
_unref_shared();
}
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 819d76941b..fe43985d0d 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class Range : public Control {
-
GDCLASS(Range, Control);
struct Shared {
diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp
index 0765e5d882..27c57c684a 100644
--- a/scene/gui/reference_rect.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -33,13 +33,13 @@
#include "core/engine.h"
void ReferenceRect::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
- if (Engine::get_singleton()->is_editor_hint() || !editor_only)
+ }
+ if (Engine::get_singleton()->is_editor_hint() || !editor_only) {
draw_rect(Rect2(Point2(), get_size()), border_color, false);
+ }
}
}
diff --git a/scene/gui/reference_rect.h b/scene/gui/reference_rect.h
index c25c54f271..db2f4269f3 100644
--- a/scene/gui/reference_rect.h
+++ b/scene/gui/reference_rect.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class ReferenceRect : public Control {
-
GDCLASS(ReferenceRect, Control);
Color border_color;
bool editor_only;
diff --git a/scene/gui/rich_text_effect.cpp b/scene/gui/rich_text_effect.cpp
index 0f5926ea1c..2628e5ab0f 100644
--- a/scene/gui/rich_text_effect.cpp
+++ b/scene/gui/rich_text_effect.cpp
@@ -64,7 +64,6 @@ RichTextEffect::RichTextEffect() {
}
void CharFXTransform::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_relative_index"), &CharFXTransform::get_relative_index);
ClassDB::bind_method(D_METHOD("set_relative_index", "index"), &CharFXTransform::set_relative_index);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index a6c0c99bdb..92508f7fd2 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -46,16 +46,12 @@
#endif
RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
-
if (p_free) {
-
if (p_item->subitems.size()) {
-
return p_item->subitems.front()->get();
} else if (!p_item->parent) {
return nullptr;
} else if (p_item->E->next()) {
-
return p_item->E->next()->get();
} else {
//go up until something with a next is found
@@ -63,20 +59,19 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
p_item = p_item->parent;
}
- if (p_item->parent)
+ if (p_item->parent) {
return p_item->E->next()->get();
- else
+ } else {
return nullptr;
+ }
}
} else {
if (p_item->subitems.size() && p_item->type != ITEM_TABLE) {
-
return p_item->subitems.front()->get();
} else if (p_item->type == ITEM_FRAME) {
return nullptr;
} else if (p_item->E->next()) {
-
return p_item->E->next()->get();
} else {
//go up until something with a next is found
@@ -84,10 +79,11 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
p_item = p_item->parent;
}
- if (p_item->type != ITEM_FRAME)
+ if (p_item->type != ITEM_FRAME) {
return p_item->E->next()->get();
- else
+ } else {
return nullptr;
+ }
}
}
@@ -96,14 +92,11 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) {
if (p_free) {
-
if (p_item->subitems.size()) {
-
return p_item->subitems.back()->get();
} else if (!p_item->parent) {
return nullptr;
} else if (p_item->E->prev()) {
-
return p_item->E->prev()->get();
} else {
//go back until something with a prev is found
@@ -111,20 +104,19 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) {
p_item = p_item->parent;
}
- if (p_item->parent)
+ if (p_item->parent) {
return p_item->E->prev()->get();
- else
+ } else {
return nullptr;
+ }
}
} else {
if (p_item->subitems.size() && p_item->type != ITEM_TABLE) {
-
return p_item->subitems.back()->get();
} else if (p_item->type == ITEM_FRAME) {
return nullptr;
} else if (p_item->E->prev()) {
-
return p_item->E->prev()->get();
} else {
//go back until something with a prev is found
@@ -132,10 +124,11 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) {
p_item = p_item->parent;
}
- if (p_item->type != ITEM_FRAME)
+ if (p_item->type != ITEM_FRAME) {
return p_item->E->prev()->get();
- else
+ } else {
return nullptr;
+ }
}
}
@@ -148,17 +141,18 @@ Rect2 RichTextLabel::_get_text_rect() {
}
int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) {
-
ERR_FAIL_INDEX_V((int)p_mode, 3, 0);
RID ci;
- if (r_outside)
+ if (r_outside) {
*r_outside = false;
+ }
if (p_mode == PROCESS_DRAW) {
ci = get_canvas_item();
- if (r_click_item)
+ if (r_click_item) {
*r_click_item = nullptr;
+ }
}
Line &l = p_frame->lines.write[p_line];
Item *it = l.from;
@@ -172,7 +166,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int height = get_size().y;
if (p_mode != PROCESS_CACHE) {
-
ERR_FAIL_INDEX_V(line, l.offset_caches.size(), 0);
line_ofs = l.offset_caches[line];
}
@@ -191,14 +184,16 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int spaces_size = 0;
int align_ofs = 0;
- if (p_mode != PROCESS_CACHE && align != ALIGN_FILL)
+ if (p_mode != PROCESS_CACHE && align != ALIGN_FILL) {
wofs += line_ofs;
+ }
int begin = wofs;
Ref<Font> cfont = _find_font(it);
- if (cfont.is_null())
+ if (cfont.is_null()) {
cfont = p_base_font;
+ }
//line height should be the font height for the first time, this ensures that an empty line will never have zero height and successive newlines are displayed
int line_height = cfont->get_height();
@@ -261,6 +256,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
lh = line < l.height_caches.size() ? l.height_caches[line] : 1; \
line_ascent = line < l.ascent_caches.size() ? l.ascent_caches[line] : 1; \
line_descent = line < l.descent_caches.size() ? l.descent_caches[line] : 1; \
+ if (p_mode == PROCESS_DRAW) { \
+ if (line < l.offset_caches.size()) { \
+ wofs = l.offset_caches[line]; \
+ } \
+ } \
} \
if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x < p_ofs.x + wofs) { \
if (r_outside) \
@@ -328,18 +328,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int fh = 0;
while (it) {
-
switch (it->type) {
-
case ITEM_ALIGN: {
-
ItemAlign *align_it = static_cast<ItemAlign *>(it);
align = align_it->align;
} break;
case ITEM_INDENT: {
-
if (it != l.from) {
ItemIndent *indent_it = static_cast<ItemIndent *>(it);
@@ -351,12 +347,12 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} break;
case ITEM_TEXT: {
-
ItemText *text = static_cast<ItemText *>(it);
Ref<Font> font = _find_font(it);
- if (font.is_null())
+ if (font.is_null()) {
font = p_base_font;
+ }
const CharType *c = text->text.c_str();
const CharType *cf = c;
@@ -399,7 +395,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
rchar = 0;
FontDrawer drawer(font, Color(1, 1, 1));
while (*c) {
-
int end = 0;
int w = 0;
int fw = 0;
@@ -412,7 +407,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
line_descent = line < l.descent_caches.size() ? l.descent_caches[line] : 1;
}
while (c[end] != 0 && !(end && c[end - 1] == ' ' && c[end] != ' ')) {
-
int cw = font->get_char_size(c[end], c[end + 1]).width;
if (c[end] == '\t') {
cw = tab_size * font->get_char_size(' ').width;
@@ -446,14 +440,12 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
{
-
int ofs = 0 - backtrack;
for (int i = 0; i < end; i++) {
int pofs = wofs + ofs;
if (p_mode == PROCESS_POINTER && r_click_char && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh) {
-
int cw = font->get_char_size(c[i], c[i + 1]).x;
if (c[i] == '\t') {
@@ -461,7 +453,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
if (p_click_pos.x - cw / 2 > p_ofs.x + align_ofs + pofs) {
-
rchar = int((&c[i]) - cf);
}
@@ -473,7 +464,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
CharType fx_char = c[i];
if (selection.active) {
-
int cofs = (&c[i]) - cf;
if ((text->index > selection.from->index || (text->index == selection.from->index && cofs >= selection.from_char)) && (text->index < selection.to->index || (text->index == selection.to->index && cofs <= selection.to_char))) {
selected = true;
@@ -498,7 +488,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
const bool previously_visible = visible;
for (int j = 0; j < fx_stack.size(); j++) {
-
ItemFX *item_fx = fx_stack[j];
if (item_fx->type == ITEM_CUSTOMFX && custom_fx_ok) {
@@ -567,11 +556,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
w += font->get_char_size(c[i], c[i + 1]).x;
}
- if (c[i] == '\t')
+ if (c[i] == '\t') {
visible = false;
+ }
if (visible) {
-
if (selected) {
cw = font->get_char_size(fx_char, c[i + 1]).x;
draw_rect(Rect2(p_ofs.x + pofs, p_ofs.y + y, cw, lh), selection_bg);
@@ -636,30 +625,33 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} break;
case ITEM_IMAGE: {
-
lh = 0;
- if (p_mode != PROCESS_CACHE)
+ if (p_mode != PROCESS_CACHE) {
lh = line < l.height_caches.size() ? l.height_caches[line] : 1;
- else
+ } else {
l.char_count += 1; //images count as chars too
+ }
ItemImage *img = static_cast<ItemImage *>(it);
Ref<Font> font = _find_font(it);
- if (font.is_null())
+ if (font.is_null()) {
font = p_base_font;
+ }
- if (p_mode == PROCESS_POINTER && r_click_char)
+ if (p_mode == PROCESS_POINTER && r_click_char) {
*r_click_char = 0;
+ }
ENSURE_WIDTH(img->size.width);
bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->size.height, img->size.height));
- if (visible)
+ if (visible) {
line_is_blank = false;
+ }
if (p_mode == PROCESS_DRAW && visible) {
- img->image->draw_rect(ci, Rect2(p_ofs + Point2(align_ofs + wofs, y + lh - font->get_descent() - img->size.height), img->size));
+ img->image->draw_rect(ci, Rect2(p_ofs + Point2(align_ofs + wofs, y + lh - font->get_descent() - img->size.height), img->size), false, img->color);
}
p_char_count++;
@@ -668,7 +660,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} break;
case ITEM_NEWLINE: {
-
lh = 0;
if (p_mode != PROCESS_CACHE) {
@@ -678,7 +669,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} break;
case ITEM_TABLE: {
-
lh = 0;
ItemTable *table = static_cast<ItemTable *>(it);
int hseparation = get_theme_constant("table_hseparation");
@@ -690,7 +680,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
Point2 shadow_ofs2(get_theme_constant("shadow_offset_x"), get_theme_constant("shadow_offset_y"));
if (p_mode == PROCESS_CACHE) {
-
int idx = 0;
//set minimums to zero
for (int i = 0; i < table->columns.size(); i++) {
@@ -710,7 +699,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int ly = 0;
for (int i = 0; i < frame->lines.size(); i++) {
-
_process_line(frame, Point2(), ly, available_width, i, PROCESS_CACHE, cfont, Color(), font_color_shadow, use_outline, shadow_ofs2);
table->columns.write[column].min_width = MAX(table->columns[column].min_width, frame->lines[i].minimum_width);
table->columns.write[column].max_width = MAX(table->columns[column].max_width, frame->lines[i].maximum_width);
@@ -726,17 +714,20 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
for (int i = 0; i < table->columns.size(); i++) {
remaining_width -= table->columns[i].min_width;
- if (table->columns[i].max_width > table->columns[i].min_width)
+ if (table->columns[i].max_width > table->columns[i].min_width) {
table->columns.write[i].expand = true;
- if (table->columns[i].expand)
+ }
+ if (table->columns[i].expand) {
total_ratio += table->columns[i].expand_ratio;
+ }
}
//assign actual widths
for (int i = 0; i < table->columns.size(); i++) {
table->columns.write[i].width = table->columns[i].min_width;
- if (table->columns[i].expand && total_ratio > 0)
+ if (table->columns[i].expand && total_ratio > 0) {
table->columns.write[i].width += table->columns[i].expand_ratio * remaining_width / total_ratio;
+ }
table->total_width += table->columns[i].width + hseparation;
}
@@ -746,8 +737,9 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
table_need_fit = false;
//fit slim
for (int i = 0; i < table->columns.size(); i++) {
- if (!table->columns[i].expand)
+ if (!table->columns[i].expand) {
continue;
+ }
int dif = table->columns[i].width - table->columns[i].max_width;
if (dif > 0) {
table_need_fit = true;
@@ -782,7 +774,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int column = idx % table->columns.size();
for (int i = 0; i < frame->lines.size(); i++) {
-
int ly = 0;
_process_line(frame, Point2(), ly, table->columns[column].width, i, PROCESS_CACHE, cfont, Color(), font_color_shadow, use_outline, shadow_ofs2);
frame->lines.write[i].height_cache = ly; //actual height
@@ -810,11 +801,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int lines_ofs = p_ofs.y + offset.y + draw_ofs.y;
bool visible = lines_ofs < get_size().height && lines_ofs + lines_h >= 0;
- if (visible)
+ if (visible) {
line_is_blank = false;
+ }
for (int i = 0; i < frame->lines.size(); i++) {
-
if (visible) {
if (p_mode == PROCESS_DRAW) {
nonblank_line_count += _process_line(frame, p_ofs + offset + draw_ofs + Vector2(0, yofs), ly, table->columns[column].width, i, PROCESS_DRAW, cfont, ccolor, font_color_shadow, use_outline, shadow_ofs2);
@@ -836,7 +827,6 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
offset.x += table->columns[column].width + hseparation;
if (column == table->columns.size() - 1) {
-
offset.y += row_height + vseparation;
offset.x = hseparation;
row_height = 0;
@@ -863,11 +853,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
it = _get_next_item(it);
if (it && (p_line + 1 < p_frame->lines.size()) && p_frame->lines[p_line + 1].from == it) {
-
if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh) {
//went to next line, but pointer was on the previous one
- if (r_outside)
+ if (r_outside) {
*r_outside = true;
+ }
*r_click_item = itp;
*r_click_char = rchar;
RETURN;
@@ -888,14 +878,15 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
}
void RichTextLabel::_scroll_changed(double) {
-
- if (updating_scroll || !scroll_active)
+ if (updating_scroll) {
return;
+ }
- if (scroll_follow && vscroll->get_value() >= (vscroll->get_max() - vscroll->get_page()))
+ if (scroll_follow && vscroll->get_value() >= (vscroll->get_max() - vscroll->get_page())) {
scroll_following = true;
- else
+ } else {
scroll_following = false;
+ }
scroll_updated = true;
@@ -903,13 +894,11 @@ void RichTextLabel::_scroll_changed(double) {
}
void RichTextLabel::_update_scroll() {
-
int total_height = get_content_height();
bool exceeds = total_height > get_size().height && scroll_active;
if (exceeds != scroll_visible) {
-
if (exceeds) {
scroll_visible = true;
scroll_w = vscroll->get_combined_minimum_size().width;
@@ -961,9 +950,7 @@ void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_
}
void RichTextLabel::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_MOUSE_EXIT: {
if (meta_hovering) {
meta_hovering = nullptr;
@@ -973,27 +960,24 @@ void RichTextLabel::_notification(int p_what) {
}
} break;
case NOTIFICATION_RESIZED: {
-
main->first_invalid_line = 0; //invalidate ALL
update();
} break;
case NOTIFICATION_ENTER_TREE: {
-
- if (bbcode != "")
+ if (bbcode != "") {
set_bbcode(bbcode);
+ }
main->first_invalid_line = 0; //invalidate ALL
update();
} break;
case NOTIFICATION_THEME_CHANGED: {
-
update();
} break;
case NOTIFICATION_DRAW: {
-
_validate_line_caches(main);
_update_scroll();
@@ -1017,15 +1001,16 @@ void RichTextLabel::_notification(int p_what) {
int from_line = 0;
int total_chars = 0;
while (from_line < main->lines.size()) {
-
- if (main->lines[from_line].height_accum_cache + _get_text_rect().get_position().y >= ofs)
+ if (main->lines[from_line].height_accum_cache + _get_text_rect().get_position().y >= ofs) {
break;
+ }
total_chars += main->lines[from_line].char_count;
from_line++;
}
- if (from_line >= main->lines.size())
+ if (from_line >= main->lines.size()) {
break; //nothing to draw
+ }
int y = (main->lines[from_line].height_accum_cache - main->lines[from_line].height_cache) - ofs;
Ref<Font> base_font = get_theme_font("normal_font");
Color base_color = get_theme_color("default_color");
@@ -1035,7 +1020,6 @@ void RichTextLabel::_notification(int p_what) {
visible_line_count = 0;
while (y < size.height && from_line < main->lines.size()) {
-
visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), nullptr, nullptr, nullptr, total_chars);
total_chars += main->lines[from_line].char_count;
@@ -1052,9 +1036,9 @@ void RichTextLabel::_notification(int p_what) {
}
void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item, int *r_click_char, bool *r_outside) {
-
- if (r_click_item)
+ if (r_click_item) {
*r_click_item = nullptr;
+ }
Rect2 text_rect = _get_text_rect();
int ofs = vscroll->get_value();
@@ -1066,57 +1050,61 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
int from_line = 0;
while (from_line < p_frame->lines.size()) {
-
- if (p_frame->lines[from_line].height_accum_cache >= ofs)
+ if (p_frame->lines[from_line].height_accum_cache >= ofs) {
break;
+ }
from_line++;
}
- if (from_line >= p_frame->lines.size())
+ if (from_line >= p_frame->lines.size()) {
return;
+ }
int y = (p_frame->lines[from_line].height_accum_cache - p_frame->lines[from_line].height_cache) - ofs;
Ref<Font> base_font = get_theme_font("normal_font");
Color base_color = get_theme_color("default_color");
while (y < text_rect.get_size().height && from_line < p_frame->lines.size()) {
-
_process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, p_click, r_click_item, r_click_char, r_outside);
- if (r_click_item && *r_click_item)
+ if (r_click_item && *r_click_item) {
return;
+ }
from_line++;
}
}
Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const {
-
- if (!underline_meta)
+ if (!underline_meta) {
return CURSOR_ARROW;
+ }
- if (selection.click)
+ if (selection.click) {
return CURSOR_IBEAM;
+ }
- if (main->first_invalid_line < main->lines.size())
+ if (main->first_invalid_line < main->lines.size()) {
return CURSOR_ARROW; //invalid
+ }
int line = 0;
Item *item = nullptr;
bool outside;
((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line, &outside);
- if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, nullptr))
+ if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, nullptr)) {
return CURSOR_POINTING_HAND;
+ }
return CURSOR_ARROW;
}
void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
- if (main->first_invalid_line < main->lines.size())
+ if (main->first_invalid_line < main->lines.size()) {
return;
+ }
if (b->get_button_index() == BUTTON_LEFT) {
if (b->is_pressed() && !b->is_doubleclick()) {
@@ -1128,9 +1116,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
_find_click(main, b->get_position(), &item, &line, &outside);
if (item) {
-
if (selection.enabled) {
-
selection.click = item;
selection.click_char = line;
@@ -1147,7 +1133,6 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
}
} else if (b->is_pressed() && b->is_doubleclick() && selection.enabled) {
-
//doubleclick: select word
int line = 0;
Item *item = nullptr;
@@ -1156,17 +1141,14 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
_find_click(main, b->get_position(), &item, &line, &outside);
while (item && item->type != ITEM_TEXT) {
-
item = _get_next_item(item, true);
}
if (item && item->type == ITEM_TEXT) {
-
String itext = static_cast<ItemText *>(item)->text;
int beg, end;
if (select_word(itext, line, beg, end)) {
-
selection.from = item;
selection.to = item;
selection.from_char = beg;
@@ -1176,7 +1158,6 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
}
} else if (!b->is_pressed()) {
-
selection.click = nullptr;
if (!b->is_doubleclick() && !scroll_updated) {
@@ -1187,7 +1168,6 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
_find_click(main, b->get_position(), &item, &line, &outside);
if (item) {
-
Variant meta;
if (!outside && _find_meta(item, &meta)) {
//meta clicked
@@ -1200,21 +1180,22 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
if (b->get_button_index() == BUTTON_WHEEL_UP) {
- if (scroll_active)
+ if (scroll_active) {
vscroll->set_value(vscroll->get_value() - vscroll->get_page() * b->get_factor() * 0.5 / 8);
+ }
}
if (b->get_button_index() == BUTTON_WHEEL_DOWN) {
- if (scroll_active)
+ if (scroll_active) {
vscroll->set_value(vscroll->get_value() + vscroll->get_page() * b->get_factor() * 0.5 / 8);
+ }
}
}
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
-
- if (scroll_active)
-
+ if (scroll_active) {
vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y * 0.5 / 8);
+ }
return;
}
@@ -1226,42 +1207,36 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
bool handled = false;
switch (k->get_keycode()) {
case KEY_PAGEUP: {
-
if (vscroll->is_visible_in_tree()) {
vscroll->set_value(vscroll->get_value() - vscroll->get_page());
handled = true;
}
} break;
case KEY_PAGEDOWN: {
-
if (vscroll->is_visible_in_tree()) {
vscroll->set_value(vscroll->get_value() + vscroll->get_page());
handled = true;
}
} break;
case KEY_UP: {
-
if (vscroll->is_visible_in_tree()) {
vscroll->set_value(vscroll->get_value() - get_theme_font("normal_font")->get_height());
handled = true;
}
} break;
case KEY_DOWN: {
-
if (vscroll->is_visible_in_tree()) {
vscroll->set_value(vscroll->get_value() + get_theme_font("normal_font")->get_height());
handled = true;
}
} break;
case KEY_HOME: {
-
if (vscroll->is_visible_in_tree()) {
vscroll->set_value(0);
handled = true;
}
} break;
case KEY_END: {
-
if (vscroll->is_visible_in_tree()) {
vscroll->set_value(vscroll->get_max());
handled = true;
@@ -1269,7 +1244,6 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
} break;
case KEY_INSERT:
case KEY_C: {
-
if (k->get_command()) {
selection_copy();
handled = true;
@@ -1278,16 +1252,18 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
} break;
}
- if (handled)
+ if (handled) {
accept_event();
+ }
}
}
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
- if (main->first_invalid_line < main->lines.size())
+ if (main->first_invalid_line < main->lines.size()) {
return;
+ }
int line = 0;
Item *item = nullptr;
@@ -1295,9 +1271,9 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
_find_click(main, m->get_position(), &item, &line, &outside);
if (selection.click) {
-
- if (!item)
+ if (!item) {
return; // do not update
+ }
selection.from = selection.click;
selection.from_char = selection.click_char;
@@ -1306,13 +1282,12 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
selection.to_char = line;
bool swap = false;
- if (selection.from->index > selection.to->index)
+ if (selection.from->index > selection.to->index) {
swap = true;
- else if (selection.from->index == selection.to->index) {
- if (selection.from_char > selection.to_char)
+ } else if (selection.from->index == selection.to->index) {
+ if (selection.from_char > selection.to_char) {
swap = true;
- else if (selection.from_char == selection.to_char) {
-
+ } else if (selection.from_char == selection.to_char) {
selection.active = false;
return;
}
@@ -1347,13 +1322,10 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
Ref<Font> RichTextLabel::_find_font(Item *p_item) {
-
Item *fontitem = p_item;
while (fontitem) {
-
if (fontitem->type == ITEM_FONT) {
-
ItemFont *fi = static_cast<ItemFont *>(fontitem);
return fi->font;
}
@@ -1365,28 +1337,26 @@ Ref<Font> RichTextLabel::_find_font(Item *p_item) {
}
int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font) {
-
Item *item = p_item;
int margin = 0;
while (item) {
-
if (item->type == ITEM_INDENT) {
-
Ref<Font> font = _find_font(item);
- if (font.is_null())
+ if (font.is_null()) {
font = p_base_font;
+ }
ItemIndent *indent = static_cast<ItemIndent *>(item);
margin += indent->level * tab_size * font->get_char_size(' ').width;
} else if (item->type == ITEM_LIST) {
-
Ref<Font> font = _find_font(item);
- if (font.is_null())
+ if (font.is_null()) {
font = p_base_font;
+ }
}
item = item->parent;
@@ -1396,13 +1366,10 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font) {
}
RichTextLabel::Align RichTextLabel::_find_align(Item *p_item) {
-
Item *item = p_item;
while (item) {
-
if (item->type == ITEM_ALIGN) {
-
ItemAlign *align = static_cast<ItemAlign *>(item);
return align->align;
}
@@ -1414,13 +1381,10 @@ RichTextLabel::Align RichTextLabel::_find_align(Item *p_item) {
}
Color RichTextLabel::_find_color(Item *p_item, const Color &p_default_color) {
-
Item *item = p_item;
while (item) {
-
if (item->type == ITEM_COLOR) {
-
ItemColor *color = static_cast<ItemColor *>(item);
return color->color;
}
@@ -1432,13 +1396,10 @@ Color RichTextLabel::_find_color(Item *p_item, const Color &p_default_color) {
}
bool RichTextLabel::_find_underline(Item *p_item) {
-
Item *item = p_item;
while (item) {
-
if (item->type == ITEM_UNDERLINE) {
-
return true;
}
@@ -1449,13 +1410,10 @@ bool RichTextLabel::_find_underline(Item *p_item) {
}
bool RichTextLabel::_find_strikethrough(Item *p_item) {
-
Item *item = p_item;
while (item) {
-
if (item->type == ITEM_STRIKETHROUGH) {
-
return true;
}
@@ -1466,7 +1424,6 @@ bool RichTextLabel::_find_strikethrough(Item *p_item) {
}
bool RichTextLabel::_find_by_type(Item *p_item, ItemType p_type) {
-
ERR_FAIL_INDEX_V((int)p_type, 19, false);
Item *item = p_item;
@@ -1491,18 +1448,58 @@ void RichTextLabel::_fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack
}
}
+Color RichTextLabel::_get_color_from_string(const String &p_color_str, const Color &p_default_color) {
+ if (p_color_str.begins_with("#")) {
+ return Color::html(p_color_str);
+ } else if (p_color_str == "aqua") {
+ return Color(0, 1, 1);
+ } else if (p_color_str == "black") {
+ return Color(0, 0, 0);
+ } else if (p_color_str == "blue") {
+ return Color(0, 0, 1);
+ } else if (p_color_str == "fuchsia") {
+ return Color(1, 0, 1);
+ } else if (p_color_str == "gray" || p_color_str == "grey") {
+ return Color(0.5, 0.5, 0.5);
+ } else if (p_color_str == "green") {
+ return Color(0, 0.5, 0);
+ } else if (p_color_str == "lime") {
+ return Color(0, 1, 0);
+ } else if (p_color_str == "maroon") {
+ return Color(0.5, 0, 0);
+ } else if (p_color_str == "navy") {
+ return Color(0, 0, 0.5);
+ } else if (p_color_str == "olive") {
+ return Color(0.5, 0.5, 0);
+ } else if (p_color_str == "purple") {
+ return Color(0.5, 0, 0.5);
+ } else if (p_color_str == "red") {
+ return Color(1, 0, 0);
+ } else if (p_color_str == "silver") {
+ return Color(0.75, 0.75, 0.75);
+ } else if (p_color_str == "teal") {
+ return Color(0, 0.5, 0.5);
+ } else if (p_color_str == "white") {
+ return Color(1, 1, 1);
+ } else if (p_color_str == "yellow") {
+ return Color(1, 1, 0);
+ } else {
+ return p_default_color;
+ }
+}
+
bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item) {
Item *item = p_item;
while (item) {
-
if (item->type == ITEM_META) {
-
ItemMeta *meta = static_cast<ItemMeta *>(item);
- if (r_meta)
+ if (r_meta) {
*r_meta = meta->meta;
- if (r_item)
+ }
+ if (r_item) {
*r_item = meta;
+ }
return true;
}
@@ -1513,16 +1510,17 @@ bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item)
}
bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) {
-
if (from && from != to) {
- if (from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH)
+ if (from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) {
return true;
+ }
for (List<Item *>::Element *E = from->subitems.front(); E; E = E->next()) {
bool layout = _find_layout_subitem(E->get(), to);
- if (layout)
+ if (layout) {
return true;
+ }
}
}
@@ -1530,9 +1528,9 @@ bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) {
}
void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
-
- if (p_frame->first_invalid_line == p_frame->lines.size())
+ if (p_frame->first_invalid_line == p_frame->lines.size()) {
return;
+ }
//validate invalid lines
Size2 size = get_size();
@@ -1547,67 +1545,64 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
Ref<Font> base_font = get_theme_font("normal_font");
for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) {
-
int y = 0;
_process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, i, PROCESS_CACHE, base_font, Color(), font_color_shadow, use_outline, shadow_ofs);
p_frame->lines.write[i].height_cache = y;
p_frame->lines.write[i].height_accum_cache = y;
- if (i > 0)
+ if (i > 0) {
p_frame->lines.write[i].height_accum_cache += p_frame->lines[i - 1].height_accum_cache;
+ }
}
int total_height = 0;
- if (p_frame->lines.size())
+ if (p_frame->lines.size()) {
total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache + get_theme_stylebox("normal")->get_minimum_size().height;
+ }
main->first_invalid_line = p_frame->lines.size();
updating_scroll = true;
vscroll->set_max(total_height);
vscroll->set_page(size.height);
- if (scroll_follow && scroll_following)
+ if (scroll_follow && scroll_following) {
vscroll->set_value(total_height - size.height);
+ }
updating_scroll = false;
}
void RichTextLabel::_invalidate_current_line(ItemFrame *p_frame) {
-
if (p_frame->lines.size() - 1 <= p_frame->first_invalid_line) {
-
p_frame->first_invalid_line = p_frame->lines.size() - 1;
update();
}
}
void RichTextLabel::add_text(const String &p_text) {
-
- if (current->type == ITEM_TABLE)
+ if (current->type == ITEM_TABLE) {
return; //can't add anything here
+ }
int pos = 0;
while (pos < p_text.length()) {
-
int end = p_text.find("\n", pos);
String line;
bool eol = false;
if (end == -1) {
-
end = p_text.length();
} else {
-
eol = true;
}
- if (pos == 0 && end == p_text.length())
+ if (pos == 0 && end == p_text.length()) {
line = p_text;
- else
+ } else {
line = p_text.substr(pos, end - pos);
+ }
if (line.length() > 0) {
-
if (current->subitems.size() && current->subitems.back()->get()->type == ITEM_TEXT) {
//append text condition!
ItemText *ti = static_cast<ItemText *>(current->subitems.back()->get());
@@ -1623,13 +1618,13 @@ void RichTextLabel::add_text(const String &p_text) {
}
if (eol) {
-
ItemNewline *item = memnew(ItemNewline);
item->line = current_frame->lines.size();
_add_item(item, false);
current_frame->lines.resize(current_frame->lines.size() + 1);
- if (item->type != ITEM_NEWLINE)
+ if (item->type != ITEM_NEWLINE) {
current_frame->lines.write[current_frame->lines.size() - 1].from = item;
+ }
_invalidate_current_line(current_frame);
}
@@ -1638,13 +1633,13 @@ void RichTextLabel::add_text(const String &p_text) {
}
void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) {
-
p_item->parent = current;
p_item->E = current->subitems.push_back(p_item);
p_item->index = current_idx++;
- if (p_enter)
+ if (p_enter) {
current = p_item;
+ }
if (p_ensure_newline) {
Item *from = current_frame->lines[current_frame->lines.size() - 1].from;
@@ -1668,15 +1663,15 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline)
}
void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_subitem_line) {
-
int size = p_item->subitems.size();
if (size == 0) {
p_item->parent->subitems.erase(p_item);
if (p_item->type == ITEM_NEWLINE) {
current_frame->lines.remove(p_line);
for (int i = p_subitem_line; i < current->subitems.size(); i++) {
- if (current->subitems[i]->line > 0)
+ if (current->subitems[i]->line > 0) {
current->subitems[i]->line--;
+ }
}
}
} else {
@@ -1686,15 +1681,16 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub
}
}
-void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height) {
-
- if (current->type == ITEM_TABLE)
+void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color) {
+ if (current->type == ITEM_TABLE) {
return;
+ }
ERR_FAIL_COND(p_image.is_null());
ItemImage *item = memnew(ItemImage);
item->image = p_image;
+ item->color = p_color;
if (p_width > 0) {
// custom width
@@ -1723,9 +1719,9 @@ void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width,
}
void RichTextLabel::add_newline() {
-
- if (current->type == ITEM_TABLE)
+ if (current->type == ITEM_TABLE) {
return;
+ }
ItemNewline *item = memnew(ItemNewline);
item->line = current_frame->lines.size();
_add_item(item, false);
@@ -1734,9 +1730,9 @@ void RichTextLabel::add_newline() {
}
bool RichTextLabel::remove_line(const int p_line) {
-
- if (p_line >= current_frame->lines.size() || p_line < 0)
+ if (p_line >= current_frame->lines.size() || p_line < 0) {
return false;
+ }
int i = 0;
while (i < current->subitems.size() && current->subitems[i]->line < p_line) {
@@ -1747,8 +1743,9 @@ bool RichTextLabel::remove_line(const int p_line) {
while (i < current->subitems.size()) {
was_newline = current->subitems[i]->type == ITEM_NEWLINE;
_remove_item(current->subitems[i], current->subitems[i]->line, p_line);
- if (was_newline)
+ if (was_newline) {
break;
+ }
}
if (!was_newline) {
@@ -1758,8 +1755,9 @@ bool RichTextLabel::remove_line(const int p_line) {
}
}
- if (p_line == 0 && current->subitems.size() > 0)
+ if (p_line == 0 && current->subitems.size() > 0) {
main->lines.write[0].from = main;
+ }
main->first_invalid_line = 0;
@@ -1767,7 +1765,6 @@ bool RichTextLabel::remove_line(const int p_line) {
}
void RichTextLabel::push_font(const Ref<Font> &p_font) {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ERR_FAIL_COND(p_font.is_null());
ItemFont *item = memnew(ItemFont);
@@ -1812,7 +1809,6 @@ void RichTextLabel::push_mono() {
}
void RichTextLabel::push_color(const Color &p_color) {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ItemColor *item = memnew(ItemColor);
@@ -1821,7 +1817,6 @@ void RichTextLabel::push_color(const Color &p_color) {
}
void RichTextLabel::push_underline() {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ItemUnderline *item = memnew(ItemUnderline);
@@ -1829,7 +1824,6 @@ void RichTextLabel::push_underline() {
}
void RichTextLabel::push_strikethrough() {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ItemStrikethrough *item = memnew(ItemStrikethrough);
@@ -1837,7 +1831,6 @@ void RichTextLabel::push_strikethrough() {
}
void RichTextLabel::push_align(Align p_align) {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ItemAlign *item = memnew(ItemAlign);
@@ -1846,7 +1839,6 @@ void RichTextLabel::push_align(Align p_align) {
}
void RichTextLabel::push_indent(int p_level) {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ERR_FAIL_COND(p_level < 0);
@@ -1856,7 +1848,6 @@ void RichTextLabel::push_indent(int p_level) {
}
void RichTextLabel::push_list(ListType p_list) {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ERR_FAIL_INDEX(p_list, 3);
@@ -1867,7 +1858,6 @@ void RichTextLabel::push_list(ListType p_list) {
}
void RichTextLabel::push_meta(const Variant &p_meta) {
-
ERR_FAIL_COND(current->type == ITEM_TABLE);
ItemMeta *item = memnew(ItemMeta);
@@ -1876,7 +1866,6 @@ void RichTextLabel::push_meta(const Variant &p_meta) {
}
void RichTextLabel::push_table(int p_columns) {
-
ERR_FAIL_COND(p_columns < 1);
ItemTable *item = memnew(ItemTable);
@@ -1933,7 +1922,6 @@ void RichTextLabel::push_customfx(Ref<RichTextEffect> p_custom_effect, Dictionar
}
void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_ratio) {
-
ERR_FAIL_COND(current->type != ITEM_TABLE);
ItemTable *table = static_cast<ItemTable *>(current);
ERR_FAIL_INDEX(p_column, table->columns.size());
@@ -1942,7 +1930,6 @@ void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_r
}
void RichTextLabel::push_cell() {
-
ERR_FAIL_COND(current->type != ITEM_TABLE);
ItemFrame *item = memnew(ItemFrame);
@@ -1957,7 +1944,6 @@ void RichTextLabel::push_cell() {
}
int RichTextLabel::get_current_table_column() const {
-
ERR_FAIL_COND_V(current->type != ITEM_TABLE, -1);
ItemTable *table = static_cast<ItemTable *>(current);
@@ -1966,7 +1952,6 @@ int RichTextLabel::get_current_table_column() const {
}
void RichTextLabel::pop() {
-
ERR_FAIL_COND(!current->parent);
if (current->type == ITEM_FRAME) {
current_frame = static_cast<ItemFrame *>(current)->parent_frame;
@@ -1975,7 +1960,6 @@ void RichTextLabel::pop() {
}
void RichTextLabel::clear() {
-
main->_clear_children();
current = main;
current_frame = main;
@@ -1986,6 +1970,9 @@ void RichTextLabel::clear() {
selection.click = nullptr;
selection.active = false;
current_idx = 1;
+ if (scroll_follow) {
+ scroll_following = true;
+ }
if (fixed_width != -1) {
minimum_size_changed();
@@ -1993,77 +1980,67 @@ void RichTextLabel::clear() {
}
void RichTextLabel::set_tab_size(int p_spaces) {
-
tab_size = p_spaces;
main->first_invalid_line = 0;
update();
}
int RichTextLabel::get_tab_size() const {
-
return tab_size;
}
void RichTextLabel::set_meta_underline(bool p_underline) {
-
underline_meta = p_underline;
update();
}
bool RichTextLabel::is_meta_underlined() const {
-
return underline_meta;
}
void RichTextLabel::set_override_selected_font_color(bool p_override_selected_font_color) {
-
override_selected_font_color = p_override_selected_font_color;
}
bool RichTextLabel::is_overriding_selected_font_color() const {
-
return override_selected_font_color;
}
void RichTextLabel::set_offset(int p_pixel) {
-
vscroll->set_value(p_pixel);
}
void RichTextLabel::set_scroll_active(bool p_active) {
-
- if (scroll_active == p_active)
+ if (scroll_active == p_active) {
return;
+ }
scroll_active = p_active;
+ vscroll->set_drag_node_enabled(p_active);
update();
}
bool RichTextLabel::is_scroll_active() const {
-
return scroll_active;
}
void RichTextLabel::set_scroll_follow(bool p_follow) {
-
scroll_follow = p_follow;
- if (!vscroll->is_visible_in_tree() || vscroll->get_value() >= (vscroll->get_max() - vscroll->get_page()))
+ if (!vscroll->is_visible_in_tree() || vscroll->get_value() >= (vscroll->get_max() - vscroll->get_page())) {
scroll_following = true;
+ }
}
bool RichTextLabel::is_scroll_following() const {
-
return scroll_follow;
}
Error RichTextLabel::parse_bbcode(const String &p_bbcode) {
-
clear();
return append_bbcode(p_bbcode);
}
Error RichTextLabel::append_bbcode(const String &p_bbcode) {
-
int pos = 0;
List<String> tag_stack;
@@ -2083,18 +2060,19 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
set_process_internal(false);
while (pos < p_bbcode.length()) {
-
int brk_pos = p_bbcode.find("[", pos);
- if (brk_pos < 0)
+ if (brk_pos < 0) {
brk_pos = p_bbcode.length();
+ }
if (brk_pos > pos) {
add_text(p_bbcode.substr(pos, brk_pos - pos));
}
- if (brk_pos == p_bbcode.length())
+ if (brk_pos == p_bbcode.length()) {
break; //nothing else to add
+ }
int brk_end = p_bbcode.find("]", brk_pos + 1);
@@ -2106,17 +2084,44 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
String tag = p_bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
Vector<String> split_tag_block = tag.split(" ", false);
- String bbcode = !split_tag_block.empty() ? split_tag_block[0] : "";
- if (tag.begins_with("/") && tag_stack.size()) {
+ // Find optional parameters.
+ String bbcode_name;
+ typedef Map<String, String> OptionMap;
+ OptionMap bbcode_options;
+ if (!split_tag_block.empty()) {
+ bbcode_name = split_tag_block[0];
+ for (int i = 1; i < split_tag_block.size(); i++) {
+ const String &expr = split_tag_block[i];
+ int value_pos = expr.find("=");
+ if (value_pos > -1) {
+ bbcode_options[expr.substr(0, value_pos)] = expr.substr(value_pos + 1);
+ }
+ }
+ } else {
+ bbcode_name = tag;
+ }
+
+ // Find main parameter.
+ String bbcode_value;
+ int main_value_pos = bbcode_name.find("=");
+ if (main_value_pos > -1) {
+ bbcode_value = bbcode_name.substr(main_value_pos + 1);
+ bbcode_name = bbcode_name.substr(0, main_value_pos);
+ }
+
+ if (tag.begins_with("/") && tag_stack.size()) {
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
- if (tag_stack.front()->get() == "b")
+ if (tag_stack.front()->get() == "b") {
in_bold = false;
- if (tag_stack.front()->get() == "i")
+ }
+ if (tag_stack.front()->get() == "i") {
in_italics = false;
- if (tag_stack.front()->get() == "indent")
+ }
+ if (tag_stack.front()->get() == "indent") {
indent_level--;
+ }
if (!tag_ok) {
add_text("[" + tag);
@@ -2126,108 +2131,99 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.pop_front();
pos = brk_end + 1;
- if (tag != "/img")
+ if (tag != "/img") {
pop();
+ }
} else if (tag == "b") {
-
//use bold font
in_bold = true;
- if (in_italics)
+ if (in_italics) {
push_font(bold_italics_font);
- else
+ } else {
push_font(bold_font);
+ }
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "i") {
-
//use italics font
in_italics = true;
- if (in_bold)
+ if (in_bold) {
push_font(bold_italics_font);
- else
+ } else {
push_font(italics_font);
+ }
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "code") {
-
//use monospace font
push_font(mono_font);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag.begins_with("table=")) {
-
int columns = tag.substr(6, tag.length()).to_int();
- if (columns < 1)
+ if (columns < 1) {
columns = 1;
+ }
push_table(columns);
pos = brk_end + 1;
tag_stack.push_front("table");
} else if (tag == "cell") {
-
push_cell();
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag.begins_with("cell=")) {
-
int ratio = tag.substr(5, tag.length()).to_int();
- if (ratio < 1)
+ if (ratio < 1) {
ratio = 1;
+ }
set_table_column_expand(get_current_table_column(), true, ratio);
push_cell();
pos = brk_end + 1;
tag_stack.push_front("cell");
} else if (tag == "u") {
-
//use underline
push_underline();
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "s") {
-
//use strikethrough
push_strikethrough();
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "center") {
-
push_align(ALIGN_CENTER);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "fill") {
-
push_align(ALIGN_FILL);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "right") {
-
push_align(ALIGN_RIGHT);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "ul") {
-
push_list(LIST_DOTS);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "ol") {
-
push_list(LIST_NUMBERS);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "indent") {
-
indent_level++;
push_indent(indent_level);
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "url") {
-
int end = p_bbcode.find("[", brk_end);
- if (end == -1)
+ if (end == -1) {
end = p_bbcode.length();
+ }
String url = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
push_meta(url);
@@ -2235,217 +2231,157 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.push_front(tag);
} else if (tag.begins_with("url=")) {
-
String url = tag.substr(4, tag.length());
push_meta(url);
pos = brk_end + 1;
tag_stack.push_front("url");
- } else if (tag == "img") {
-
+ } else if (bbcode_name == "img") {
int end = p_bbcode.find("[", brk_end);
- if (end == -1)
+ if (end == -1) {
end = p_bbcode.length();
+ }
String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
Ref<Texture2D> texture = ResourceLoader::load(image, "Texture2D");
- if (texture.is_valid())
- add_image(texture);
+ if (texture.is_valid()) {
+ Color color = Color(1.0, 1.0, 1.0);
+ OptionMap::Element *color_option = bbcode_options.find("color");
+ if (color_option) {
+ color = _get_color_from_string(color_option->value(), color);
+ }
- pos = end;
- tag_stack.push_front(tag);
- } else if (tag.begins_with("img=")) {
+ int width = 0;
+ int height = 0;
+ if (!bbcode_value.empty()) {
+ int sep = bbcode_value.find("x");
+ if (sep == -1) {
+ width = bbcode_value.to_int();
+ } else {
+ width = bbcode_value.substr(0, sep).to_int();
+ height = bbcode_value.substr(sep + 1).to_int();
+ }
+ } else {
+ OptionMap::Element *width_option = bbcode_options.find("width");
+ if (width_option) {
+ width = width_option->value().to_int();
+ }
- int width = 0;
- int height = 0;
+ OptionMap::Element *height_option = bbcode_options.find("height");
+ if (height_option) {
+ height = height_option->value().to_int();
+ }
+ }
- String params = tag.substr(4, tag.length());
- int sep = params.find("x");
- if (sep == -1) {
- width = params.to_int();
- } else {
- width = params.substr(0, sep).to_int();
- height = params.substr(sep + 1, params.length()).to_int();
+ add_image(texture, width, height, color);
}
- int end = p_bbcode.find("[", brk_end);
- if (end == -1)
- end = p_bbcode.length();
-
- String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
-
- Ref<Texture2D> texture = ResourceLoader::load(image, "Texture");
- if (texture.is_valid())
- add_image(texture, width, height);
-
pos = end;
- tag_stack.push_front("img");
+ tag_stack.push_front(bbcode_name);
} else if (tag.begins_with("color=")) {
-
- String col = tag.substr(6, tag.length());
- Color color;
-
- if (col.begins_with("#"))
- color = Color::html(col);
- else if (col == "aqua")
- color = Color(0, 1, 1);
- else if (col == "black")
- color = Color(0, 0, 0);
- else if (col == "blue")
- color = Color(0, 0, 1);
- else if (col == "fuchsia")
- color = Color(1, 0, 1);
- else if (col == "gray" || col == "grey")
- color = Color(0.5, 0.5, 0.5);
- else if (col == "green")
- color = Color(0, 0.5, 0);
- else if (col == "lime")
- color = Color(0, 1, 0);
- else if (col == "maroon")
- color = Color(0.5, 0, 0);
- else if (col == "navy")
- color = Color(0, 0, 0.5);
- else if (col == "olive")
- color = Color(0.5, 0.5, 0);
- else if (col == "purple")
- color = Color(0.5, 0, 0.5);
- else if (col == "red")
- color = Color(1, 0, 0);
- else if (col == "silver")
- color = Color(0.75, 0.75, 0.75);
- else if (col == "teal")
- color = Color(0, 0.5, 0.5);
- else if (col == "white")
- color = Color(1, 1, 1);
- else if (col == "yellow")
- color = Color(1, 1, 0);
- else
- color = base_color;
-
+ String color_str = tag.substr(6, tag.length());
+ Color color = _get_color_from_string(color_str, base_color);
push_color(color);
pos = brk_end + 1;
tag_stack.push_front("color");
} else if (tag.begins_with("font=")) {
-
String fnt = tag.substr(5, tag.length());
Ref<Font> font = ResourceLoader::load(fnt, "Font");
- if (font.is_valid())
+ if (font.is_valid()) {
push_font(font);
- else
+ } else {
push_font(normal_font);
+ }
pos = brk_end + 1;
tag_stack.push_front("font");
- } else if (bbcode == "fade") {
- int startIndex = 0;
- int length = 10;
+ } else if (bbcode_name == "fade") {
+ int start_index = 0;
+ OptionMap::Element *start_option = bbcode_options.find("start");
+ if (start_option) {
+ start_index = start_option->value().to_int();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("start=")) {
- String start_str = expr.substr(6, expr.length());
- startIndex = start_str.to_int();
- } else if (expr.begins_with("length=")) {
- String end_str = expr.substr(7, expr.length());
- length = end_str.to_int();
- }
- }
+ int length = 10;
+ OptionMap::Element *length_option = bbcode_options.find("length");
+ if (length_option) {
+ length = length_option->value().to_int();
}
- push_fade(startIndex, length);
+ push_fade(start_index, length);
pos = brk_end + 1;
tag_stack.push_front("fade");
- } else if (bbcode == "shake") {
+ } else if (bbcode_name == "shake") {
int strength = 5;
- float rate = 20.0f;
+ OptionMap::Element *strength_option = bbcode_options.find("level");
+ if (strength_option) {
+ strength = strength_option->value().to_int();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("level=")) {
- String str_str = expr.substr(6, expr.length());
- strength = str_str.to_int();
- } else if (expr.begins_with("rate=")) {
- String rate_str = expr.substr(5, expr.length());
- rate = rate_str.to_float();
- }
- }
+ float rate = 20.0f;
+ OptionMap::Element *rate_option = bbcode_options.find("rate");
+ if (rate_option) {
+ rate = rate_option->value().to_float();
}
push_shake(strength, rate);
pos = brk_end + 1;
tag_stack.push_front("shake");
set_process_internal(true);
- } else if (bbcode == "wave") {
+ } else if (bbcode_name == "wave") {
float amplitude = 20.0f;
- float period = 5.0f;
+ OptionMap::Element *amplitude_option = bbcode_options.find("amp");
+ if (amplitude_option) {
+ amplitude = amplitude_option->value().to_float();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("amp=")) {
- String amp_str = expr.substr(4, expr.length());
- amplitude = amp_str.to_float();
- } else if (expr.begins_with("freq=")) {
- String period_str = expr.substr(5, expr.length());
- period = period_str.to_float();
- }
- }
+ float period = 5.0f;
+ OptionMap::Element *period_option = bbcode_options.find("freq");
+ if (period_option) {
+ period = period_option->value().to_float();
}
push_wave(period, amplitude);
pos = brk_end + 1;
tag_stack.push_front("wave");
set_process_internal(true);
- } else if (bbcode == "tornado") {
+ } else if (bbcode_name == "tornado") {
float radius = 10.0f;
- float frequency = 1.0f;
+ OptionMap::Element *radius_option = bbcode_options.find("radius");
+ if (radius_option) {
+ radius = radius_option->value().to_float();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("radius=")) {
- String amp_str = expr.substr(7, expr.length());
- radius = amp_str.to_float();
- } else if (expr.begins_with("freq=")) {
- String period_str = expr.substr(5, expr.length());
- frequency = period_str.to_float();
- }
- }
+ float frequency = 1.0f;
+ OptionMap::Element *frequency_option = bbcode_options.find("freq");
+ if (frequency_option) {
+ frequency = frequency_option->value().to_float();
}
push_tornado(frequency, radius);
pos = brk_end + 1;
tag_stack.push_front("tornado");
set_process_internal(true);
- } else if (bbcode == "rainbow") {
+ } else if (bbcode_name == "rainbow") {
float saturation = 0.8f;
+ OptionMap::Element *saturation_option = bbcode_options.find("sat");
+ if (saturation_option) {
+ saturation = saturation_option->value().to_float();
+ }
+
float value = 0.8f;
- float frequency = 1.0f;
+ OptionMap::Element *value_option = bbcode_options.find("val");
+ if (value_option) {
+ value = value_option->value().to_float();
+ }
- if (split_tag_block.size() > 1) {
- split_tag_block.remove(0);
- for (int i = 0; i < split_tag_block.size(); i++) {
- String expr = split_tag_block[i];
- if (expr.begins_with("sat=")) {
- String sat_str = expr.substr(4, expr.length());
- saturation = sat_str.to_float();
- } else if (expr.begins_with("val=")) {
- String val_str = expr.substr(4, expr.length());
- value = val_str.to_float();
- } else if (expr.begins_with("freq=")) {
- String freq_str = expr.substr(5, expr.length());
- frequency = freq_str.to_float();
- }
- }
+ float frequency = 1.0f;
+ OptionMap::Element *frequency_option = bbcode_options.find("freq");
+ if (frequency_option) {
+ frequency = frequency_option->value().to_float();
}
push_rainbow(saturation, value, frequency);
@@ -2476,29 +2412,38 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
}
}
+ Vector<ItemFX *> fx_items;
+ for (List<Item *>::Element *E = main->subitems.front(); E; E = E->next()) {
+ Item *subitem = static_cast<Item *>(E->get());
+ _fetch_item_fx_stack(subitem, fx_items);
+
+ if (fx_items.size()) {
+ set_process_internal(true);
+ break;
+ }
+ }
+
return OK;
}
void RichTextLabel::scroll_to_line(int p_line) {
-
ERR_FAIL_INDEX(p_line, main->lines.size());
_validate_line_caches(main);
vscroll->set_value(main->lines[p_line].height_accum_cache - main->lines[p_line].height_cache);
}
int RichTextLabel::get_line_count() const {
-
return current_frame->lines.size();
}
int RichTextLabel::get_visible_line_count() const {
- if (!is_visible())
+ if (!is_visible()) {
return 0;
+ }
return visible_line_count;
}
void RichTextLabel::set_selection_enabled(bool p_enabled) {
-
selection.enabled = p_enabled;
if (!p_enabled) {
if (selection.active) {
@@ -2512,7 +2457,6 @@ void RichTextLabel::set_selection_enabled(bool p_enabled) {
}
bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p_search_previous) {
-
ERR_FAIL_COND_V(!selection.enabled, false);
Item *it = main;
int charidx = 0;
@@ -2523,9 +2467,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
}
while (it) {
-
if (it->type == ITEM_TEXT) {
-
ItemText *t = static_cast<ItemText *>(it);
int sp = t->text.findn(p_string, charidx);
if (sp != -1) {
@@ -2560,10 +2502,11 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
}
}
- if (p_search_previous)
+ if (p_search_previous) {
it = _get_prev_item(it, true);
- else
+ } else {
it = _get_next_item(it, true);
+ }
charidx = 0;
}
@@ -2571,18 +2514,16 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
}
void RichTextLabel::selection_copy() {
-
- if (!selection.active || !selection.enabled)
+ if (!selection.active || !selection.enabled) {
return;
+ }
String text;
RichTextLabel::Item *item = selection.from;
while (item) {
-
if (item->type == ITEM_TEXT) {
-
String itext = static_cast<ItemText *>(item)->text;
if (item == selection.from && item == selection.to) {
text += itext.substr(selection.from_char, selection.to_char - selection.from_char + 1);
@@ -2597,8 +2538,9 @@ void RichTextLabel::selection_copy() {
} else if (item->type == ITEM_NEWLINE) {
text += "\n";
}
- if (item == selection.to)
+ if (item == selection.to) {
break;
+ }
item = _get_next_item(item, true);
}
@@ -2609,34 +2551,32 @@ void RichTextLabel::selection_copy() {
}
bool RichTextLabel::is_selection_enabled() const {
-
return selection.enabled;
}
void RichTextLabel::set_bbcode(const String &p_bbcode) {
bbcode = p_bbcode;
- if (is_inside_tree() && use_bbcode)
+ if (is_inside_tree() && use_bbcode) {
parse_bbcode(p_bbcode);
- else { // raw text
+ } else { // raw text
clear();
add_text(p_bbcode);
}
}
String RichTextLabel::get_bbcode() const {
-
return bbcode;
}
void RichTextLabel::set_use_bbcode(bool p_enable) {
- if (use_bbcode == p_enable)
+ if (use_bbcode == p_enable) {
return;
+ }
use_bbcode = p_enable;
set_bbcode(bbcode);
}
bool RichTextLabel::is_using_bbcode() const {
-
return use_bbcode;
}
@@ -2663,14 +2603,11 @@ void RichTextLabel::set_text(const String &p_string) {
}
void RichTextLabel::set_percent_visible(float p_percent) {
-
if (p_percent < 0 || p_percent >= 1) {
-
visible_characters = -1;
percent_visible = 1;
} else {
-
visible_characters = get_total_character_count() * p_percent;
percent_visible = p_percent;
}
@@ -2711,18 +2648,18 @@ void RichTextLabel::install_effect(const Variant effect) {
int RichTextLabel::get_content_height() {
int total_height = 0;
- if (main->lines.size())
+ if (main->lines.size()) {
total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_theme_stylebox("normal")->get_minimum_size().height;
+ }
return total_height;
}
void RichTextLabel::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input);
ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text);
ClassDB::bind_method(D_METHOD("add_text", "text"), &RichTextLabel::add_text);
ClassDB::bind_method(D_METHOD("set_text", "text"), &RichTextLabel::set_text);
- ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height", "color"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)));
ClassDB::bind_method(D_METHOD("newline"), &RichTextLabel::add_newline);
ClassDB::bind_method(D_METHOD("remove_line", "line"), &RichTextLabel::remove_line);
ClassDB::bind_method(D_METHOD("push_font", "font"), &RichTextLabel::push_font);
@@ -2856,11 +2793,12 @@ void RichTextLabel::set_visible_characters(int p_visible) {
int RichTextLabel::get_visible_characters() const {
return visible_characters;
}
-int RichTextLabel::get_total_character_count() const {
+int RichTextLabel::get_total_character_count() const {
int tc = 0;
- for (int i = 0; i < current_frame->lines.size(); i++)
+ for (int i = 0; i < current_frame->lines.size(); i++) {
tc += current_frame->lines[i].char_count;
+ }
return tc;
}
@@ -2871,7 +2809,6 @@ void RichTextLabel::set_fixed_size_to_width(int p_width) {
}
Size2 RichTextLabel::get_minimum_size() const {
-
if (fixed_width != -1) {
const_cast<RichTextLabel *>(this)->_validate_line_caches(main);
return Size2(fixed_width, const_cast<RichTextLabel *>(this)->get_content_height());
@@ -2882,8 +2819,9 @@ Size2 RichTextLabel::get_minimum_size() const {
Ref<RichTextEffect> RichTextLabel::_get_custom_effect_by_code(String p_bbcode_identifier) {
for (int i = 0; i < custom_effects.size(); i++) {
- if (!custom_effects[i].is_valid())
+ if (!custom_effects[i].is_valid()) {
continue;
+ }
if (custom_effects[i]->get_bbcode() == p_bbcode_identifier) {
return custom_effects[i];
@@ -2953,7 +2891,6 @@ Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressi
}
RichTextLabel::RichTextLabel() {
-
main = memnew(ItemFrame);
main->index = 0;
current = main;
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 7f2b5facb9..4cec435568 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -35,7 +35,6 @@
#include "scene/gui/scroll_bar.h"
class RichTextLabel : public Control {
-
GDCLASS(RichTextLabel, Control);
public:
@@ -84,7 +83,6 @@ private:
struct Item;
struct Line {
-
Item *from;
Vector<int> offset_caches;
Vector<int> height_caches;
@@ -151,6 +149,7 @@ private:
struct ItemImage : public Item {
Ref<Texture2D> image;
Size2 size;
+ Color color;
ItemImage() { type = ITEM_IMAGE; }
};
@@ -352,7 +351,6 @@ private:
};
struct Selection {
-
Item *click;
int click_char;
@@ -384,6 +382,8 @@ private:
bool _find_by_type(Item *p_item, ItemType p_type);
void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack);
+ static Color _get_color_from_string(const String &p_color_str, const Color &p_default_color);
+
void _update_scroll();
void _update_fx(ItemFrame *p_frame, float p_delta_time);
void _scroll_changed(double);
@@ -409,7 +409,7 @@ protected:
public:
String get_text();
void add_text(const String &p_text);
- void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0);
+ void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0));
void add_newline();
bool remove_line(const int p_line);
void push_font(const Ref<Font> &p_font);
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 1c63c25e28..4db6ca2949 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -38,12 +38,10 @@
bool ScrollBar::focus_by_default = false;
void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
-
focus_by_default = p_can_focus;
}
void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventMouseMotion> m = p_event;
if (!m.is_valid() || drag.active) {
emit_signal("scrolling");
@@ -55,22 +53,20 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
accept_event();
if (b->get_button_index() == BUTTON_WHEEL_DOWN && b->is_pressed()) {
-
set_value(get_value() + get_page() / 4.0);
accept_event();
}
if (b->get_button_index() == BUTTON_WHEEL_UP && b->is_pressed()) {
-
set_value(get_value() - get_page() / 4.0);
accept_event();
}
- if (b->get_button_index() != BUTTON_LEFT)
+ if (b->get_button_index() != BUTTON_LEFT) {
return;
+ }
if (b->is_pressed()) {
-
double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x;
Ref<Texture2D> decr = get_theme_icon("decrement");
Ref<Texture2D> incr = get_theme_icon("increment");
@@ -82,13 +78,11 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
double total = orientation == VERTICAL ? get_size().height : get_size().width;
if (ofs < decr_size) {
-
set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
return;
}
if (ofs > total - incr_size) {
-
set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
return;
}
@@ -96,7 +90,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
ofs -= decr_size;
if (ofs < grabber_ofs) {
-
if (scrolling) {
target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page());
} else {
@@ -115,7 +108,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
ofs -= grabber_ofs;
if (ofs < grabber_size) {
-
drag.active = true;
drag.pos_at_click = grabber_ofs + ofs;
drag.value_at_click = get_as_ratio();
@@ -136,18 +128,15 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
}
} else {
-
drag.active = false;
update();
}
}
if (m.is_valid()) {
-
accept_event();
if (drag.active) {
-
double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x;
Ref<Texture2D> decr = get_theme_icon("decrement");
@@ -158,7 +147,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
set_as_ratio(drag.value_at_click + diff);
} else {
-
double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x;
Ref<Texture2D> decr = get_theme_icon("decrement");
Ref<Texture2D> incr = get_theme_icon("increment");
@@ -170,20 +158,16 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
HighlightStatus new_hilite;
if (ofs < decr_size) {
-
new_hilite = HIGHLIGHT_DECR;
} else if (ofs > total - incr_size) {
-
new_hilite = HIGHLIGHT_INCR;
} else {
-
new_hilite = HIGHLIGHT_RANGE;
}
if (new_hilite != highlight) {
-
highlight = new_hilite;
update();
}
@@ -191,47 +175,42 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
}
if (p_event->is_pressed()) {
-
if (p_event->is_action("ui_left")) {
-
- if (orientation != HORIZONTAL)
+ if (orientation != HORIZONTAL) {
return;
+ }
set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
} else if (p_event->is_action("ui_right")) {
-
- if (orientation != HORIZONTAL)
+ if (orientation != HORIZONTAL) {
return;
+ }
set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
} else if (p_event->is_action("ui_up")) {
-
- if (orientation != VERTICAL)
+ if (orientation != VERTICAL) {
return;
+ }
set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
} else if (p_event->is_action("ui_down")) {
-
- if (orientation != VERTICAL)
+ if (orientation != VERTICAL) {
return;
+ }
set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
} else if (p_event->is_action("ui_home")) {
-
set_value(get_min());
} else if (p_event->is_action("ui_end")) {
-
set_value(get_max());
}
}
}
void ScrollBar::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
RID ci = get_canvas_item();
Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_theme_icon("decrement_highlight") : get_theme_icon("decrement");
@@ -239,47 +218,49 @@ void ScrollBar::_notification(int p_what) {
Ref<StyleBox> bg = has_focus() ? get_theme_stylebox("scroll_focus") : get_theme_stylebox("scroll");
Ref<StyleBox> grabber;
- if (drag.active)
+ if (drag.active) {
grabber = get_theme_stylebox("grabber_pressed");
- else if (highlight == HIGHLIGHT_RANGE)
+ } else if (highlight == HIGHLIGHT_RANGE) {
grabber = get_theme_stylebox("grabber_highlight");
- else
+ } else {
grabber = get_theme_stylebox("grabber");
+ }
Point2 ofs;
decr->draw(ci, Point2());
- if (orientation == HORIZONTAL)
+ if (orientation == HORIZONTAL) {
ofs.x += decr->get_width();
- else
+ } else {
ofs.y += decr->get_height();
+ }
Size2 area = get_size();
- if (orientation == HORIZONTAL)
+ if (orientation == HORIZONTAL) {
area.width -= incr->get_width() + decr->get_width();
- else
+ } else {
area.height -= incr->get_height() + decr->get_height();
+ }
bg->draw(ci, Rect2(ofs, area));
- if (orientation == HORIZONTAL)
+ if (orientation == HORIZONTAL) {
ofs.width += area.width;
- else
+ } else {
ofs.height += area.height;
+ }
incr->draw(ci, ofs);
Rect2 grabber_rect;
if (orientation == HORIZONTAL) {
-
grabber_rect.size.width = get_grabber_size();
grabber_rect.size.height = get_size().height;
grabber_rect.position.y = 0;
grabber_rect.position.x = get_grabber_offset() + decr->get_width() + bg->get_margin(MARGIN_LEFT);
} else {
-
grabber_rect.size.width = get_size().width;
grabber_rect.size.height = get_grabber_size();
grabber_rect.position.y = get_grabber_offset() + decr->get_height() + bg->get_margin(MARGIN_TOP);
@@ -290,7 +271,6 @@ void ScrollBar::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
-
if (has_node(drag_node_path)) {
Node *n = get_node(drag_node_path);
drag_node = Object::cast_to<Control>(n);
@@ -302,7 +282,6 @@ void ScrollBar::_notification(int p_what) {
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
if (drag_node) {
drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit));
@@ -312,7 +291,6 @@ void ScrollBar::_notification(int p_what) {
}
if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
-
if (scrolling) {
if (get_value() != target_scroll) {
double target = target_scroll - get_value();
@@ -332,16 +310,13 @@ void ScrollBar::_notification(int p_what) {
}
} else if (drag_node_touching) {
-
if (drag_node_touching_deaccel) {
-
Vector2 pos = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
pos += drag_node_speed * get_physics_process_delta_time();
bool turnoff = false;
if (orientation == HORIZONTAL) {
-
if (pos.x < 0) {
pos.x = 0;
turnoff = true;
@@ -365,7 +340,6 @@ void ScrollBar::_notification(int p_what) {
drag_node_speed.x = sgn_x * val_x;
} else {
-
if (pos.y < 0) {
pos.y = 0;
turnoff = true;
@@ -395,9 +369,7 @@ void ScrollBar::_notification(int p_what) {
}
} else {
-
if (time_since_motion == 0 || time_since_motion > 0.1) {
-
Vector2 diff = drag_node_accum - last_drag_node_accum;
last_drag_node_accum = drag_node_accum;
drag_node_speed = diff / get_physics_process_delta_time();
@@ -409,24 +381,22 @@ void ScrollBar::_notification(int p_what) {
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {
-
highlight = HIGHLIGHT_NONE;
update();
}
}
double ScrollBar::get_grabber_min_size() const {
-
Ref<StyleBox> grabber = get_theme_stylebox("grabber");
Size2 gminsize = grabber->get_minimum_size() + grabber->get_center_size();
return (orientation == VERTICAL) ? gminsize.height : gminsize.width;
}
double ScrollBar::get_grabber_size() const {
-
float range = get_max() - get_min();
- if (range <= 0)
+ if (range <= 0) {
return 0;
+ }
float page = (get_page() > 0) ? get_page() : 0;
/*
@@ -464,17 +434,14 @@ double ScrollBar::get_area_size() const {
}
double ScrollBar::get_area_offset() const {
-
double ofs = 0;
if (orientation == VERTICAL) {
-
ofs += get_theme_stylebox("hscroll")->get_margin(MARGIN_TOP);
ofs += get_theme_icon("decrement")->get_height();
}
if (orientation == HORIZONTAL) {
-
ofs += get_theme_stylebox("hscroll")->get_margin(MARGIN_LEFT);
ofs += get_theme_icon("decrement")->get_width();
}
@@ -483,31 +450,28 @@ double ScrollBar::get_area_offset() const {
}
double ScrollBar::get_click_pos(const Point2 &p_pos) const {
-
float pos = (orientation == VERTICAL) ? p_pos.y : p_pos.x;
pos -= get_area_offset();
float area = get_area_size();
- if (area == 0)
+ if (area == 0) {
return 0;
- else
+ } else {
return pos / area;
+ }
}
double ScrollBar::get_grabber_offset() const {
-
return (get_area_size()) * get_as_ratio();
}
Size2 ScrollBar::get_minimum_size() const {
-
Ref<Texture2D> incr = get_theme_icon("increment");
Ref<Texture2D> decr = get_theme_icon("decrement");
Ref<StyleBox> bg = get_theme_stylebox("scroll");
Size2 minsize;
if (orientation == VERTICAL) {
-
minsize.width = MAX(incr->get_size().width, (bg->get_minimum_size() + bg->get_center_size()).width);
minsize.height += incr->get_size().height;
minsize.height += decr->get_size().height;
@@ -516,7 +480,6 @@ Size2 ScrollBar::get_minimum_size() const {
}
if (orientation == HORIZONTAL) {
-
minsize.height = MAX(incr->get_size().height, (bg->get_center_size() + bg->get_minimum_size()).height);
minsize.width += incr->get_size().width;
minsize.width += decr->get_size().width;
@@ -528,17 +491,14 @@ Size2 ScrollBar::get_minimum_size() const {
}
void ScrollBar::set_custom_step(float p_custom_step) {
-
custom_step = p_custom_step;
}
float ScrollBar::get_custom_step() const {
-
return custom_step;
}
void ScrollBar::_drag_node_exit() {
-
if (drag_node) {
drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
}
@@ -546,16 +506,18 @@ void ScrollBar::_drag_node_exit() {
}
void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
+ if (!drag_node_enabled) {
+ return;
+ }
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
-
- if (mb->get_button_index() != 1)
+ if (mb->get_button_index() != 1) {
return;
+ }
if (mb->is_pressed()) {
-
drag_node_speed = Vector2();
drag_node_accum = Vector2();
last_drag_node_accum = Vector2();
@@ -570,9 +532,7 @@ void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
}
} else {
-
if (drag_node_touching) {
-
if (drag_node_speed == Vector2()) {
drag_node_touching_deaccel = false;
drag_node_touching = false;
@@ -587,19 +547,19 @@ void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid()) {
-
if (drag_node_touching && !drag_node_touching_deaccel) {
-
Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y);
drag_node_accum -= motion;
Vector2 diff = drag_node_from + drag_node_accum;
- if (orientation == HORIZONTAL)
+ if (orientation == HORIZONTAL) {
set_value(diff.x);
+ }
- if (orientation == VERTICAL)
+ if (orientation == VERTICAL) {
set_value(diff.y);
+ }
time_since_motion = 0;
}
@@ -607,9 +567,7 @@ void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
}
void ScrollBar::set_drag_node(const NodePath &p_path) {
-
if (is_inside_tree()) {
-
if (drag_node) {
drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit));
@@ -620,7 +578,6 @@ void ScrollBar::set_drag_node(const NodePath &p_path) {
drag_node_path = p_path;
if (is_inside_tree()) {
-
if (has_node(p_path)) {
Node *n = get_node(p_path);
drag_node = Object::cast_to<Control>(n);
@@ -634,10 +591,13 @@ void ScrollBar::set_drag_node(const NodePath &p_path) {
}
NodePath ScrollBar::get_drag_node() const {
-
return drag_node_path;
}
+void ScrollBar::set_drag_node_enabled(bool p_enable) {
+ drag_node_enabled = p_enable;
+}
+
void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
smooth_scroll_enabled = p_enable;
}
@@ -647,7 +607,6 @@ bool ScrollBar::is_smooth_scroll_enabled() const {
}
void ScrollBar::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input);
ClassDB::bind_method(D_METHOD("set_custom_step", "step"), &ScrollBar::set_custom_step);
ClassDB::bind_method(D_METHOD("get_custom_step"), &ScrollBar::get_custom_step);
@@ -658,24 +617,11 @@ void ScrollBar::_bind_methods() {
}
ScrollBar::ScrollBar(Orientation p_orientation) {
-
orientation = p_orientation;
- highlight = HIGHLIGHT_NONE;
- custom_step = -1;
- drag_node = nullptr;
-
- drag.active = false;
-
- drag_node_speed = Vector2();
- drag_node_touching = false;
- drag_node_touching_deaccel = false;
- scrolling = false;
- target_scroll = 0;
- smooth_scroll_enabled = false;
-
- if (focus_by_default)
+ if (focus_by_default) {
set_focus_mode(FOCUS_ALL);
+ }
set_step(0);
}
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index ee5e7140cf..23ee61d9e1 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -34,7 +34,6 @@
#include "scene/gui/range.h"
class ScrollBar : public Range {
-
GDCLASS(ScrollBar, Range);
enum HighlightStatus {
@@ -48,13 +47,12 @@ class ScrollBar : public Range {
Orientation orientation;
Size2 size;
- float custom_step;
+ float custom_step = -1;
- HighlightStatus highlight;
+ HighlightStatus highlight = HIGHLIGHT_NONE;
struct Drag {
-
- bool active;
+ bool active = false;
float pos_at_click;
float value_at_click;
} drag;
@@ -68,22 +66,23 @@ class ScrollBar : public Range {
static void set_can_focus_by_default(bool p_can_focus);
- Node *drag_node;
+ Node *drag_node = nullptr;
NodePath drag_node_path;
+ bool drag_node_enabled = true;
- Vector2 drag_node_speed;
+ Vector2 drag_node_speed = Vector2();
Vector2 drag_node_accum;
Vector2 drag_node_from;
Vector2 last_drag_node_accum;
float last_drag_node_time;
float time_since_motion;
- bool drag_node_touching;
- bool drag_node_touching_deaccel;
+ bool drag_node_touching = false;
+ bool drag_node_touching_deaccel = false;
bool click_handled;
- bool scrolling;
- double target_scroll;
- bool smooth_scroll_enabled;
+ bool scrolling = false;
+ double target_scroll = 0;
+ bool smooth_scroll_enabled = false;
void _drag_node_exit();
void _drag_node_input(const Ref<InputEvent> &p_input);
@@ -101,6 +100,7 @@ public:
void set_drag_node(const NodePath &p_path);
NodePath get_drag_node() const;
+ void set_drag_node_enabled(bool p_enable);
void set_smooth_scroll_enabled(bool p_enable);
bool is_smooth_scroll_enabled() const;
@@ -111,7 +111,6 @@ public:
};
class HScrollBar : public ScrollBar {
-
GDCLASS(HScrollBar, ScrollBar);
public:
@@ -120,7 +119,6 @@ public:
};
class VScrollBar : public ScrollBar {
-
GDCLASS(VScrollBar, ScrollBar);
public:
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index fb17adf96e..b72b913af0 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -33,24 +33,24 @@
#include "scene/main/window.h"
bool ScrollContainer::clips_input() const {
-
return true;
}
Size2 ScrollContainer::get_minimum_size() const {
-
Ref<StyleBox> sb = get_theme_stylebox("bg");
Size2 min_size;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (c == h_scroll || c == v_scroll)
+ }
+ if (c == h_scroll || c == v_scroll) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
if (!scroll_h) {
@@ -88,14 +88,12 @@ void ScrollContainer::_cancel_drag() {
}
void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
-
double prev_v_scroll = v_scroll->get_value();
double prev_h_scroll = h_scroll->get_value();
Ref<InputEventMouseButton> mb = p_gui_input;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
// only horizontal is enabled, scroll horizontally
if (h_scroll->is_visible() && (!v_scroll->is_visible() || mb->get_shift())) {
@@ -126,17 +124,19 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll)
+ if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) {
accept_event(); //accept event if scroll changed
+ }
- if (!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())))
+ if (!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id()))) {
return;
+ }
- if (mb->get_button_index() != BUTTON_LEFT)
+ if (mb->get_button_index() != BUTTON_LEFT) {
return;
+ }
if (mb->is_pressed()) {
-
if (drag_touching) {
_cancel_drag();
}
@@ -156,11 +156,9 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
} else {
if (drag_touching) {
-
if (drag_speed == Vector2()) {
_cancel_drag();
} else {
-
drag_touching_deaccel = true;
}
}
@@ -170,9 +168,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
Ref<InputEventMouseMotion> mm = p_gui_input;
if (mm.is_valid()) {
-
if (drag_touching && !drag_touching_deaccel) {
-
Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y);
drag_accum -= motion;
@@ -186,14 +182,16 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
drag_accum = -motion;
}
Vector2 diff = drag_from + drag_accum;
- if (scroll_h)
+ if (scroll_h) {
h_scroll->set_value(diff.x);
- else
+ } else {
drag_accum.x = 0;
- if (scroll_v)
+ }
+ if (scroll_v) {
v_scroll->set_value(diff.y);
- else
+ } else {
drag_accum.y = 0;
+ }
time_since_motion = 0;
}
}
@@ -201,7 +199,6 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
Ref<InputEventPanGesture> pan_gesture = p_gui_input;
if (pan_gesture.is_valid()) {
-
if (h_scroll->is_visible_in_tree()) {
h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
}
@@ -210,12 +207,12 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll)
+ if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) {
accept_event(); //accept event if scroll changed
+ }
}
void ScrollContainer::_update_scrollbar_position() {
-
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
@@ -234,7 +231,6 @@ void ScrollContainer::_update_scrollbar_position() {
}
void ScrollContainer::_ensure_focused_visible(Control *p_control) {
-
if (!follow_focus) {
return;
}
@@ -259,19 +255,15 @@ void ScrollContainer::_ensure_focused_visible(Control *p_control) {
}
void ScrollContainer::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
-
call_deferred("_update_scrollbar_position");
};
if (p_what == NOTIFICATION_READY) {
-
get_viewport()->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_ensure_focused_visible));
}
if (p_what == NOTIFICATION_SORT_CHILDREN) {
-
child_max_size = Size2(0, 0);
Size2 size = get_size();
Point2 ofs;
@@ -280,21 +272,25 @@ void ScrollContainer::_notification(int p_what) {
size -= sb->get_minimum_size();
ofs += sb->get_offset();
- if (h_scroll->is_visible_in_tree() && h_scroll->get_parent() == this) //scrolls may have been moved out for reasons
+ if (h_scroll->is_visible_in_tree() && h_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
size.y -= h_scroll->get_minimum_size().y;
+ }
- if (v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) //scrolls may have been moved out for reasons
+ if (v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
size.x -= v_scroll->get_minimum_size().x;
+ }
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (c == h_scroll || c == v_scroll)
+ }
+ if (c == h_scroll || c == v_scroll) {
continue;
+ }
Size2 minsize = c->get_combined_minimum_size();
child_max_size.x = MAX(child_max_size.x, minsize.x);
child_max_size.y = MAX(child_max_size.y, minsize.y);
@@ -302,17 +298,19 @@ void ScrollContainer::_notification(int p_what) {
Rect2 r = Rect2(-scroll, minsize);
if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) {
r.position.x = 0;
- if (c->get_h_size_flags() & SIZE_EXPAND)
+ if (c->get_h_size_flags() & SIZE_EXPAND) {
r.size.width = MAX(size.width, minsize.width);
- else
+ } else {
r.size.width = minsize.width;
+ }
}
if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) {
r.position.y = 0;
- if (c->get_v_size_flags() & SIZE_EXPAND)
+ if (c->get_v_size_flags() & SIZE_EXPAND) {
r.size.height = MAX(size.height, minsize.height);
- else
+ } else {
r.size.height = minsize.height;
+ }
}
r.position += ofs;
fit_child_in_rect(c, r);
@@ -322,7 +320,6 @@ void ScrollContainer::_notification(int p_what) {
};
if (p_what == NOTIFICATION_DRAW) {
-
Ref<StyleBox> sb = get_theme_stylebox("bg");
draw_style_box(sb, Rect2(Vector2(), get_size()));
@@ -330,11 +327,8 @@ void ScrollContainer::_notification(int p_what) {
}
if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
-
if (drag_touching) {
-
if (drag_touching_deaccel) {
-
Vector2 pos = Vector2(h_scroll->get_value(), v_scroll->get_value());
pos += drag_speed * get_physics_process_delta_time();
@@ -359,10 +353,12 @@ void ScrollContainer::_notification(int p_what) {
turnoff_v = true;
}
- if (scroll_h)
+ if (scroll_h) {
h_scroll->set_value(pos.x);
- if (scroll_v)
+ }
+ if (scroll_v) {
v_scroll->set_value(pos.y);
+ }
float sgn_x = drag_speed.x < 0 ? -1 : 1;
float val_x = Math::abs(drag_speed.x);
@@ -387,9 +383,7 @@ void ScrollContainer::_notification(int p_what) {
}
} else {
-
if (time_since_motion == 0 || time_since_motion > 0.1) {
-
Vector2 diff = drag_accum - last_drag_accum;
last_drag_accum = drag_accum;
drag_speed = diff / get_physics_process_delta_time();
@@ -402,7 +396,6 @@ void ScrollContainer::_notification(int p_what) {
};
void ScrollContainer::update_scrollbars() {
-
Size2 size = get_size();
Ref<StyleBox> sb = get_theme_stylebox("bg");
size -= sb->get_minimum_size();
@@ -422,11 +415,9 @@ void ScrollContainer::update_scrollbars() {
bool hide_scroll_h = !scroll_h || min.width <= size.width;
if (hide_scroll_v) {
-
v_scroll->hide();
scroll.y = 0;
} else {
-
v_scroll->show();
v_scroll->set_max(min.height);
if (hide_scroll_h) {
@@ -439,11 +430,9 @@ void ScrollContainer::update_scrollbars() {
}
if (hide_scroll_h) {
-
h_scroll->hide();
scroll.x = 0;
} else {
-
h_scroll->show();
h_scroll->set_max(min.width);
if (hide_scroll_v) {
@@ -461,7 +450,6 @@ void ScrollContainer::update_scrollbars() {
}
void ScrollContainer::_scroll_moved(float) {
-
scroll.x = h_scroll->get_value();
scroll.y = v_scroll->get_value();
queue_sort();
@@ -480,7 +468,6 @@ void ScrollContainer::set_enable_h_scroll(bool p_enable) {
}
bool ScrollContainer::is_h_scroll_enabled() const {
-
return scroll_h;
}
@@ -495,26 +482,23 @@ void ScrollContainer::set_enable_v_scroll(bool p_enable) {
}
bool ScrollContainer::is_v_scroll_enabled() const {
-
return scroll_v;
}
int ScrollContainer::get_v_scroll() const {
-
return v_scroll->get_value();
}
-void ScrollContainer::set_v_scroll(int p_pos) {
+void ScrollContainer::set_v_scroll(int p_pos) {
v_scroll->set_value(p_pos);
_cancel_drag();
}
int ScrollContainer::get_h_scroll() const {
-
return h_scroll->get_value();
}
-void ScrollContainer::set_h_scroll(int p_pos) {
+void ScrollContainer::set_h_scroll(int p_pos) {
h_scroll->set_value(p_pos);
_cancel_drag();
}
@@ -536,40 +520,39 @@ void ScrollContainer::set_follow_focus(bool p_follow) {
}
String ScrollContainer::get_configuration_warning() const {
-
int found = 0;
for (int i = 0; i < get_child_count(); i++) {
-
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c)
+ if (!c) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
- if (c == h_scroll || c == v_scroll)
+ }
+ if (c == h_scroll || c == v_scroll) {
continue;
+ }
found++;
}
- if (found != 1)
+ if (found != 1) {
return TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox, HBox, etc.), or a Control and set the custom minimum size manually.");
- else
+ } else {
return "";
+ }
}
HScrollBar *ScrollContainer::get_h_scrollbar() {
-
return h_scroll;
}
VScrollBar *ScrollContainer::get_v_scrollbar() {
-
return v_scroll;
}
void ScrollContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollContainer::_gui_input);
ClassDB::bind_method(D_METHOD("set_enable_h_scroll", "enable"), &ScrollContainer::set_enable_h_scroll);
ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled);
@@ -604,7 +587,6 @@ void ScrollContainer::_bind_methods() {
};
ScrollContainer::ScrollContainer() {
-
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
add_child(h_scroll);
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 6423b36fcc..321e0e2c5a 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -36,7 +36,6 @@
#include "scroll_bar.h"
class ScrollContainer : public Container {
-
GDCLASS(ScrollContainer, Container);
HScrollBar *h_scroll;
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 75c4b7cce9..4f7e5720b8 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -31,7 +31,6 @@
#include "separator.h"
Size2 Separator::get_minimum_size() const {
-
Size2 ms(3, 3);
if (orientation == VERTICAL) {
ms.x = get_theme_constant("separation");
@@ -42,20 +41,15 @@ Size2 Separator::get_minimum_size() const {
}
void Separator::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
Size2i size = get_size();
Ref<StyleBox> style = get_theme_stylebox("separator");
Size2i ssize = style->get_minimum_size() + style->get_center_size();
if (orientation == VERTICAL) {
-
style->draw(get_canvas_item(), Rect2((size.x - ssize.x) / 2, 0, ssize.x, size.y));
} else {
-
style->draw(get_canvas_item(), Rect2(0, (size.y - ssize.y) / 2, size.x, ssize.y));
}
@@ -70,11 +64,9 @@ Separator::~Separator() {
}
HSeparator::HSeparator() {
-
orientation = HORIZONTAL;
}
VSeparator::VSeparator() {
-
orientation = VERTICAL;
}
diff --git a/scene/gui/separator.h b/scene/gui/separator.h
index 9a64d6ba99..f7e5ef2c6b 100644
--- a/scene/gui/separator.h
+++ b/scene/gui/separator.h
@@ -33,7 +33,6 @@
#include "scene/gui/control.h"
class Separator : public Control {
-
GDCLASS(Separator, Control);
protected:
@@ -48,7 +47,6 @@ public:
};
class VSeparator : public Separator {
-
GDCLASS(VSeparator, Separator);
public:
@@ -56,7 +54,6 @@ public:
};
class HSeparator : public Separator {
-
GDCLASS(HSeparator, Separator);
public:
diff --git a/scene/gui/shortcut.cpp b/scene/gui/shortcut.cpp
index 262d8076f3..9f5b9c40c2 100644
--- a/scene/gui/shortcut.cpp
+++ b/scene/gui/shortcut.cpp
@@ -33,36 +33,31 @@
#include "core/os/keyboard.h"
void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
-
shortcut = p_shortcut;
emit_changed();
}
Ref<InputEvent> ShortCut::get_shortcut() const {
-
return shortcut;
}
bool ShortCut::is_shortcut(const Ref<InputEvent> &p_event) const {
-
return shortcut.is_valid() && shortcut->shortcut_match(p_event);
}
String ShortCut::get_as_text() const {
-
- if (shortcut.is_valid())
+ if (shortcut.is_valid()) {
return shortcut->as_text();
- else
+ } else {
return "None";
+ }
}
bool ShortCut::is_valid() const {
-
return shortcut.is_valid();
}
void ShortCut::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shortcut", "event"), &ShortCut::set_shortcut);
ClassDB::bind_method(D_METHOD("get_shortcut"), &ShortCut::get_shortcut);
diff --git a/scene/gui/shortcut.h b/scene/gui/shortcut.h
index b22c3441c5..063d4e43dc 100644
--- a/scene/gui/shortcut.h
+++ b/scene/gui/shortcut.h
@@ -35,7 +35,6 @@
#include "core/resource.h"
class ShortCut : public Resource {
-
GDCLASS(ShortCut, Resource);
Ref<InputEvent> shortcut;
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 910d5f8230..3dd5e022f0 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -32,21 +32,20 @@
#include "core/os/keyboard.h"
Size2 Slider::get_minimum_size() const {
-
Ref<StyleBox> style = get_theme_stylebox("slider");
Size2i ss = style->get_minimum_size() + style->get_center_size();
Ref<Texture2D> grabber = get_theme_icon("grabber");
Size2i rs = grabber->get_size();
- if (orientation == HORIZONTAL)
+ if (orientation == HORIZONTAL) {
return Size2i(ss.width, MAX(ss.height, rs.height));
- else
+ } else {
return Size2i(MAX(ss.width, rs.width), ss.height);
+ }
}
void Slider::_gui_input(Ref<InputEvent> p_event) {
-
if (!editable) {
return;
}
@@ -55,7 +54,6 @@ void Slider::_gui_input(Ref<InputEvent> p_event) {
if (mb.is_valid()) {
if (mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
Ref<Texture2D> grabber = get_theme_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber");
grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x;
@@ -63,10 +61,11 @@ void Slider::_gui_input(Ref<InputEvent> p_event) {
double grab_width = (double)grabber->get_size().width;
double grab_height = (double)grabber->get_size().height;
double max = orientation == VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
- if (orientation == VERTICAL)
+ if (orientation == VERTICAL) {
set_as_ratio(1 - (((double)grab.pos - (grab_height / 2.0)) / max));
- else
+ } else {
set_as_ratio(((double)grab.pos - (grab_width / 2.0)) / max);
+ }
grab.active = true;
grab.uvalue = get_as_ratio();
} else {
@@ -85,53 +84,51 @@ void Slider::_gui_input(Ref<InputEvent> p_event) {
if (mm.is_valid()) {
if (grab.active) {
-
Size2i size = get_size();
Ref<Texture2D> grabber = get_theme_icon("grabber");
float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos;
- if (orientation == VERTICAL)
+ if (orientation == VERTICAL) {
motion = -motion;
+ }
float areasize = orientation == VERTICAL ? size.height - grabber->get_size().height : size.width - grabber->get_size().width;
- if (areasize <= 0)
+ if (areasize <= 0) {
return;
+ }
float umotion = motion / float(areasize);
set_as_ratio(grab.uvalue + umotion);
}
}
if (!mm.is_valid() && !mb.is_valid()) {
-
if (p_event->is_action_pressed("ui_left", true)) {
-
- if (orientation != HORIZONTAL)
+ if (orientation != HORIZONTAL) {
return;
+ }
set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event->is_action_pressed("ui_right", true)) {
-
- if (orientation != HORIZONTAL)
+ if (orientation != HORIZONTAL) {
return;
+ }
set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event->is_action_pressed("ui_up", true)) {
-
- if (orientation != VERTICAL)
+ if (orientation != VERTICAL) {
return;
+ }
set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event->is_action_pressed("ui_down", true)) {
-
- if (orientation != VERTICAL)
+ if (orientation != VERTICAL) {
return;
+ }
set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event->is_action("ui_home") && p_event->is_pressed()) {
-
set_value(get_min());
accept_event();
} else if (p_event->is_action("ui_end") && p_event->is_pressed()) {
-
set_value(get_max());
accept_event();
}
@@ -139,26 +136,21 @@ void Slider::_gui_input(Ref<InputEvent> p_event) {
}
void Slider::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
update();
} break;
case NOTIFICATION_MOUSE_ENTER: {
-
mouse_inside = true;
update();
} break;
case NOTIFICATION_MOUSE_EXIT: {
-
mouse_inside = false;
update();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: // fallthrough
case NOTIFICATION_EXIT_TREE: {
-
mouse_inside = false;
grab.active = false;
} break;
@@ -173,7 +165,6 @@ void Slider::_notification(int p_what) {
double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio();
if (orientation == VERTICAL) {
-
int widget_width = style->get_minimum_size().width + style->get_center_size().width;
float areasize = size.height - grabber->get_size().height;
style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
@@ -182,15 +173,15 @@ void Slider::_notification(int p_what) {
if (ticks > 1) {
int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2);
for (int i = 0; i < ticks; i++) {
- if (!ticks_on_borders && (i == 0 || i + 1 == ticks))
+ if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) {
continue;
+ }
int ofs = (i * areasize / (ticks - 1)) + grabber_offset;
tick->draw(ci, Point2i((size.width - widget_width) / 2, ofs));
}
}
grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - ratio * areasize - grabber->get_size().height));
} else {
-
int widget_height = style->get_minimum_size().height + style->get_center_size().height;
float areasize = size.width - grabber->get_size().width;
@@ -200,8 +191,9 @@ void Slider::_notification(int p_what) {
if (ticks > 1) {
int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2);
for (int i = 0; i < ticks; i++) {
- if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks)))
+ if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) {
continue;
+ }
int ofs = (i * areasize / (ticks - 1)) + grabber_offset;
tick->draw(ci, Point2i(ofs, (size.height - widget_height) / 2));
}
@@ -214,23 +206,19 @@ void Slider::_notification(int p_what) {
}
void Slider::set_custom_step(float p_custom_step) {
-
custom_step = p_custom_step;
}
float Slider::get_custom_step() const {
-
return custom_step;
}
void Slider::set_ticks(int p_count) {
-
ticks = p_count;
update();
}
int Slider::get_ticks() const {
-
return ticks;
}
@@ -244,28 +232,23 @@ void Slider::set_ticks_on_borders(bool _tob) {
}
void Slider::set_editable(bool p_editable) {
-
editable = p_editable;
update();
}
bool Slider::is_editable() const {
-
return editable;
}
void Slider::set_scrollable(bool p_scrollable) {
-
scrollable = p_scrollable;
}
bool Slider::is_scrollable() const {
-
return scrollable;
}
void Slider::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &Slider::_gui_input);
ClassDB::bind_method(D_METHOD("set_ticks", "count"), &Slider::set_ticks);
ClassDB::bind_method(D_METHOD("get_ticks"), &Slider::get_ticks);
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index 1248044ec4..6f8f7cc7d8 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -34,7 +34,6 @@
#include "scene/gui/range.h"
class Slider : public Range {
-
GDCLASS(Slider, Range);
struct Grab {
@@ -78,7 +77,6 @@ public:
};
class HSlider : public Slider {
-
GDCLASS(HSlider, Slider);
public:
@@ -87,7 +85,6 @@ public:
};
class VSlider : public Slider {
-
GDCLASS(VSlider, Slider);
public:
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 94628f7cea..3670f13705 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -34,24 +34,23 @@
#include "core/math/expression.h"
Size2 SpinBox::get_minimum_size() const {
-
Size2 ms = line_edit->get_combined_minimum_size();
ms.width += last_w;
return ms;
}
void SpinBox::_value_changed(double) {
-
String value = String::num(get_value(), Math::range_step_decimals(get_step()));
- if (prefix != "")
+ if (prefix != "") {
value = prefix + " " + value;
- if (suffix != "")
+ }
+ if (suffix != "") {
value += " " + suffix;
+ }
line_edit->set_text(value);
}
void SpinBox::_text_entered(const String &p_string) {
-
Ref<Expression> expr;
expr.instance();
// Ignore the prefix and suffix in the expression
@@ -68,7 +67,6 @@ void SpinBox::_text_entered(const String &p_string) {
}
LineEdit *SpinBox::get_line_edit() {
-
return line_edit;
}
@@ -76,9 +74,7 @@ void SpinBox::_line_edit_input(const Ref<InputEvent> &p_event) {
}
void SpinBox::_range_click_timeout() {
-
if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
-
bool up = get_local_mouse_position().y < (get_size().height / 2);
set_value(get_value() + (up ? get_step() : -get_step()));
@@ -94,7 +90,6 @@ void SpinBox::_range_click_timeout() {
}
void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
-
if (!is_editable()) {
return;
}
@@ -102,13 +97,10 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed()) {
-
bool up = mb->get_position().y < (get_size().height / 2);
switch (mb->get_button_index()) {
-
case BUTTON_LEFT: {
-
line_edit->grab_focus();
set_value(get_value() + (up ? get_step() : -get_step()));
@@ -121,20 +113,17 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
drag.capture_pos = mb->get_position();
} break;
case BUTTON_RIGHT: {
-
line_edit->grab_focus();
set_value((up ? get_max() : get_min()));
} break;
case BUTTON_WHEEL_UP: {
if (line_edit->has_focus()) {
-
set_value(get_value() + get_step() * mb->get_factor());
accept_event();
}
} break;
case BUTTON_WHEEL_DOWN: {
if (line_edit->has_focus()) {
-
set_value(get_value() - get_step() * mb->get_factor());
accept_event();
}
@@ -143,7 +132,6 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
//set_default_cursor_shape(CURSOR_ARROW);
range_click_timer->stop();
@@ -158,14 +146,11 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
if (drag.enabled) {
-
drag.diff_y += mm->get_relative().y;
float diff_y = -0.01 * Math::pow(ABS(drag.diff_y), 1.8f) * SGN(drag.diff_y);
set_value(CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max()));
} else if (drag.allowed && drag.capture_pos.distance_to(mm->get_position()) > 2) {
-
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
drag.enabled = true;
drag.base_val = get_value();
@@ -175,16 +160,15 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
}
void SpinBox::_line_edit_focus_exit() {
-
// discontinue because the focus_exit was caused by right-click context menu
- if (line_edit->get_menu()->is_visible())
+ if (line_edit->get_menu()->is_visible()) {
return;
+ }
_text_entered(line_edit->get_text());
}
inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) {
-
int w = icon->get_width();
if (w != last_w) {
line_edit->set_margin(MARGIN_RIGHT, -w);
@@ -193,9 +177,7 @@ inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) {
}
void SpinBox::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
Ref<Texture2D> updown = get_theme_icon("updown");
_adjust_width_for_icon(updown);
@@ -206,48 +188,39 @@ void SpinBox::_notification(int p_what) {
updown->draw(ci, Point2i(size.width - updown->get_width(), (size.height - updown->get_height()) / 2));
} else if (p_what == NOTIFICATION_FOCUS_EXIT) {
-
//_value_changed(0);
} else if (p_what == NOTIFICATION_ENTER_TREE) {
-
_adjust_width_for_icon(get_theme_icon("updown"));
_value_changed(0);
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
-
call_deferred("minimum_size_changed");
get_line_edit()->call_deferred("minimum_size_changed");
}
}
void SpinBox::set_align(LineEdit::Align p_align) {
-
line_edit->set_align(p_align);
}
LineEdit::Align SpinBox::get_align() const {
-
return line_edit->get_align();
}
void SpinBox::set_suffix(const String &p_suffix) {
-
suffix = p_suffix;
_value_changed(0);
}
String SpinBox::get_suffix() const {
-
return suffix;
}
void SpinBox::set_prefix(const String &p_prefix) {
-
prefix = p_prefix;
_value_changed(0);
}
String SpinBox::get_prefix() const {
-
return prefix;
}
@@ -256,7 +229,6 @@ void SpinBox::set_editable(bool p_editable) {
}
bool SpinBox::is_editable() const {
-
return line_edit->is_editable();
}
@@ -265,7 +237,6 @@ void SpinBox::apply() {
}
void SpinBox::_bind_methods() {
-
//ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed);
ClassDB::bind_method(D_METHOD("_gui_input"), &SpinBox::_gui_input);
ClassDB::bind_method(D_METHOD("set_align", "align"), &SpinBox::set_align);
@@ -286,7 +257,6 @@ void SpinBox::_bind_methods() {
}
SpinBox::SpinBox() {
-
last_w = 0;
line_edit = memnew(LineEdit);
add_child(line_edit);
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index d3a3d8fe3d..3200480cf5 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -36,7 +36,6 @@
#include "scene/main/timer.h"
class SpinBox : public Range {
-
GDCLASS(SpinBox, Range);
LineEdit *line_edit;
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index de892a4fb9..5c60153d91 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -34,18 +34,20 @@
#include "margin_container.h"
Control *SplitContainer::_getch(int p_idx) const {
-
int idx = 0;
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
+ if (!c || !c->is_visible_in_tree()) {
continue;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
continue;
+ }
- if (idx == p_idx)
+ if (idx == p_idx) {
return c;
+ }
idx++;
}
@@ -119,7 +121,6 @@ void SplitContainer::_resort() {
}
Size2 SplitContainer::get_minimum_size() const {
-
/* Calculate MINIMUM SIZE */
Size2i minimum;
@@ -128,26 +129,24 @@ Size2 SplitContainer::get_minimum_size() const {
sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0;
for (int i = 0; i < 2; i++) {
-
- if (!_getch(i))
+ if (!_getch(i)) {
break;
+ }
if (i == 1) {
-
- if (vertical)
+ if (vertical) {
minimum.height += sep;
- else
+ } else {
minimum.width += sep;
+ }
}
Size2 ms = _getch(i)->get_combined_minimum_size();
if (vertical) {
-
minimum.height += ms.height;
minimum.width = MAX(minimum.width, ms.width);
} else {
-
minimum.width += ms.width;
minimum.height = MAX(minimum.height, ms.height);
}
@@ -157,80 +156,71 @@ Size2 SplitContainer::get_minimum_size() const {
}
void SplitContainer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_SORT_CHILDREN: {
-
_resort();
} break;
case NOTIFICATION_MOUSE_EXIT: {
-
mouse_inside = false;
- if (get_theme_constant("autohide"))
+ if (get_theme_constant("autohide")) {
update();
+ }
} break;
case NOTIFICATION_DRAW: {
-
- if (!_getch(0) || !_getch(1))
+ if (!_getch(0) || !_getch(1)) {
return;
+ }
- if (collapsed || (!dragging && !mouse_inside && get_theme_constant("autohide")))
+ if (collapsed || (!dragging && !mouse_inside && get_theme_constant("autohide"))) {
return;
+ }
- if (dragger_visibility != DRAGGER_VISIBLE)
+ if (dragger_visibility != DRAGGER_VISIBLE) {
return;
+ }
int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_theme_constant("separation") : 0;
Ref<Texture2D> tex = get_theme_icon("grabber");
Size2 size = get_size();
- if (vertical)
+ if (vertical) {
draw_texture(tex, Point2i((size.x - tex->get_width()) / 2, middle_sep + (sep - tex->get_height()) / 2));
- else
+ } else {
draw_texture(tex, Point2i(middle_sep + (sep - tex->get_width()) / 2, (size.y - tex->get_height()) / 2));
+ }
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
} break;
}
}
void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
-
- if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility != DRAGGER_VISIBLE)
+ if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility != DRAGGER_VISIBLE) {
return;
+ }
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->get_button_index() == BUTTON_LEFT) {
-
if (mb->is_pressed()) {
-
int sep = get_theme_constant("separation");
if (vertical) {
-
if (mb->get_position().y > middle_sep && mb->get_position().y < middle_sep + sep) {
-
dragging = true;
drag_from = mb->get_position().y;
drag_ofs = split_offset;
}
} else {
-
if (mb->get_position().x > middle_sep && mb->get_position().x < middle_sep + sep) {
-
dragging = true;
drag_from = mb->get_position().x;
drag_ofs = split_offset;
}
}
} else {
-
dragging = false;
}
}
@@ -239,22 +229,23 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
bool mouse_inside_state = false;
- if (vertical)
+ if (vertical) {
mouse_inside_state = mm->get_position().y > middle_sep && mm->get_position().y < middle_sep + get_theme_constant("separation");
- else
+ } else {
mouse_inside_state = mm->get_position().x > middle_sep && mm->get_position().x < middle_sep + get_theme_constant("separation");
+ }
if (mouse_inside != mouse_inside_state) {
-
mouse_inside = mouse_inside_state;
- if (get_theme_constant("autohide"))
+ if (get_theme_constant("autohide")) {
update();
+ }
}
- if (!dragging)
+ if (!dragging) {
return;
+ }
split_offset = drag_ofs + ((vertical ? mm->get_position().y : mm->get_position().x) - drag_from);
should_clamp_split_offset = true;
@@ -264,22 +255,21 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
}
Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const {
-
- if (dragging)
+ if (dragging) {
return (vertical ? CURSOR_VSPLIT : CURSOR_HSPLIT);
+ }
if (!collapsed && _getch(0) && _getch(1) && dragger_visibility == DRAGGER_VISIBLE) {
-
int sep = get_theme_constant("separation");
if (vertical) {
-
- if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep)
+ if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep) {
return CURSOR_VSPLIT;
+ }
} else {
-
- if (p_pos.x > middle_sep && p_pos.x < middle_sep + sep)
+ if (p_pos.x > middle_sep && p_pos.x < middle_sep + sep) {
return CURSOR_HSPLIT;
+ }
}
}
@@ -287,9 +277,9 @@ Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const
}
void SplitContainer::set_split_offset(int p_offset) {
-
- if (split_offset == p_offset)
+ if (split_offset == p_offset) {
return;
+ }
split_offset = p_offset;
@@ -297,7 +287,6 @@ void SplitContainer::set_split_offset(int p_offset) {
}
int SplitContainer::get_split_offset() const {
-
return split_offset;
}
@@ -308,33 +297,29 @@ void SplitContainer::clamp_split_offset() {
}
void SplitContainer::set_collapsed(bool p_collapsed) {
-
- if (collapsed == p_collapsed)
+ if (collapsed == p_collapsed) {
return;
+ }
collapsed = p_collapsed;
queue_sort();
}
void SplitContainer::set_dragger_visibility(DraggerVisibility p_visibility) {
-
dragger_visibility = p_visibility;
queue_sort();
update();
}
SplitContainer::DraggerVisibility SplitContainer::get_dragger_visibility() const {
-
return dragger_visibility;
}
bool SplitContainer::is_collapsed() const {
-
return collapsed;
}
void SplitContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &SplitContainer::_gui_input);
ClassDB::bind_method(D_METHOD("set_split_offset", "offset"), &SplitContainer::set_split_offset);
@@ -359,7 +344,6 @@ void SplitContainer::_bind_methods() {
}
SplitContainer::SplitContainer(bool p_vertical) {
-
mouse_inside = false;
split_offset = 0;
should_clamp_split_offset = false;
diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h
index d759c6ad35..6dbd316a46 100644
--- a/scene/gui/split_container.h
+++ b/scene/gui/split_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class SplitContainer : public Container {
-
GDCLASS(SplitContainer, Container);
public:
@@ -86,7 +85,6 @@ public:
VARIANT_ENUM_CAST(SplitContainer::DraggerVisibility);
class HSplitContainer : public SplitContainer {
-
GDCLASS(HSplitContainer, SplitContainer);
public:
@@ -95,7 +93,6 @@ public:
};
class VSplitContainer : public SplitContainer {
-
GDCLASS(VSplitContainer, SplitContainer);
public:
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp
index 7252a43651..4e1ad2ae05 100644
--- a/scene/gui/subviewport_container.cpp
+++ b/scene/gui/subviewport_container.cpp
@@ -34,15 +34,15 @@
#include "scene/main/viewport.h"
Size2 SubViewportContainer::get_minimum_size() const {
-
- if (stretch)
+ if (stretch) {
return Size2();
+ }
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
Size2 minsize = c->get_size();
ms.width = MAX(ms.width, minsize.width);
@@ -53,33 +53,32 @@ Size2 SubViewportContainer::get_minimum_size() const {
}
void SubViewportContainer::set_stretch(bool p_enable) {
-
stretch = p_enable;
queue_sort();
update();
}
bool SubViewportContainer::is_stretch_enabled() const {
-
return stretch;
}
void SubViewportContainer::set_stretch_shrink(int p_shrink) {
-
ERR_FAIL_COND(p_shrink < 1);
- if (shrink == p_shrink)
+ if (shrink == p_shrink) {
return;
+ }
shrink = p_shrink;
- if (!stretch)
+ if (!stretch) {
return;
+ }
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
c->set_size(get_size() / shrink);
}
@@ -88,64 +87,62 @@ void SubViewportContainer::set_stretch_shrink(int p_shrink) {
}
int SubViewportContainer::get_stretch_shrink() const {
-
return shrink;
}
void SubViewportContainer::_notification(int p_what) {
-
if (p_what == NOTIFICATION_RESIZED) {
-
- if (!stretch)
+ if (!stretch) {
return;
+ }
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
c->set_size(get_size() / shrink);
}
}
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
c->set_update_mode(SubViewport::UPDATE_ALWAYS);
- else
+ } else {
c->set_update_mode(SubViewport::UPDATE_DISABLED);
+ }
c->set_handle_input_locally(false); //do not handle input locally here
}
}
if (p_what == NOTIFICATION_DRAW) {
-
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c)
+ if (!c) {
continue;
+ }
- if (stretch)
+ if (stretch) {
draw_texture_rect(c->get_texture(), Rect2(Vector2(), get_size()));
- else
+ } else {
draw_texture_rect(c->get_texture(), Rect2(Vector2(), c->get_size()));
+ }
}
}
}
void SubViewportContainer::_input(const Ref<InputEvent> &p_event) {
-
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Transform2D xform = get_global_transform();
@@ -158,19 +155,19 @@ void SubViewportContainer::_input(const Ref<InputEvent> &p_event) {
Ref<InputEvent> ev = p_event->xformed_by(xform.affine_inverse());
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c || c->is_input_disabled())
+ if (!c || c->is_input_disabled()) {
continue;
+ }
c->input(ev);
}
}
void SubViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
-
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Transform2D xform = get_global_transform();
@@ -183,17 +180,16 @@ void SubViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEvent> ev = p_event->xformed_by(xform.affine_inverse());
for (int i = 0; i < get_child_count(); i++) {
-
SubViewport *c = Object::cast_to<SubViewport>(get_child(i));
- if (!c || c->is_input_disabled())
+ if (!c || c->is_input_disabled()) {
continue;
+ }
c->unhandled_input(ev);
}
}
void SubViewportContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &SubViewportContainer::_unhandled_input);
ClassDB::bind_method(D_METHOD("_input", "event"), &SubViewportContainer::_input);
ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch);
@@ -207,7 +203,6 @@ void SubViewportContainer::_bind_methods() {
}
SubViewportContainer::SubViewportContainer() {
-
stretch = false;
shrink = 1;
set_process_input(true);
diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h
index 13b711f838..fc4c9f925a 100644
--- a/scene/gui/subviewport_container.h
+++ b/scene/gui/subviewport_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
class SubViewportContainer : public Container {
-
GDCLASS(SubViewportContainer, Container);
bool stretch;
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 3a128cf8e6..0d48fde642 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -36,9 +36,9 @@
#include "scene/gui/texture_rect.h"
int TabContainer::_get_top_margin() const {
-
- if (!tabs_visible)
+ if (!tabs_visible) {
return 0;
+ }
// Respect the minimum tab height.
Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
@@ -53,14 +53,15 @@ int TabContainer::_get_top_margin() const {
Vector<Control *> tabs = _get_tabs();
for (int i = 0; i < tabs.size(); i++) {
-
Control *c = tabs[i];
- if (!c->has_meta("_tab_icon"))
+ if (!c->has_meta("_tab_icon")) {
continue;
+ }
Ref<Texture2D> tex = c->get_meta("_tab_icon");
- if (!tex.is_valid())
+ if (!tex.is_valid()) {
continue;
+ }
content_height = MAX(content_height, tex->get_size().height);
}
@@ -68,17 +69,16 @@ int TabContainer::_get_top_margin() const {
}
void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
Point2 pos(mb->get_position().x, mb->get_position().y);
Size2 size = get_size();
// Click must be on tabs in the tab header area.
- if (pos.x < tabs_ofs_cache || pos.y > _get_top_margin())
+ if (pos.x < tabs_ofs_cache || pos.y > _get_top_margin()) {
return;
+ }
// Handle menu button.
Ref<Texture2D> menu = get_theme_icon("menu");
@@ -95,8 +95,9 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
}
// Do not activate tabs when tabs is empty.
- if (get_tab_count() == 0)
+ if (get_tab_count() == 0) {
return;
+ }
Vector<Control *> tabs = _get_tabs();
@@ -144,13 +145,11 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
Point2 pos(mm->get_position().x, mm->get_position().y);
Size2 size = get_size();
// Mouse must be on tabs in the tab header area.
if (pos.x < tabs_ofs_cache || pos.y > _get_top_margin()) {
-
if (menu_hovered || highlight_arrow > -1) {
menu_hovered = false;
highlight_arrow = -1;
@@ -161,7 +160,6 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<Texture2D> menu = get_theme_icon("menu");
if (popup) {
-
if (pos.x >= size.width - menu->get_width()) {
if (!menu_hovered) {
menu_hovered = true;
@@ -194,13 +192,11 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<Texture2D> increment = get_theme_icon("increment");
Ref<Texture2D> decrement = get_theme_icon("decrement");
if (pos.x >= size.width - increment->get_width() - popup_ofs) {
-
if (highlight_arrow != 1) {
highlight_arrow = 1;
update();
}
} else if (pos.x >= size.width - increment->get_width() - decrement->get_width() - popup_ofs) {
-
if (highlight_arrow != 0) {
highlight_arrow = 0;
update();
@@ -213,16 +209,12 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
}
void TabContainer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_TRANSLATION_CHANGED: {
-
minimum_size_changed();
update();
} break;
case NOTIFICATION_RESIZED: {
-
Vector<Control *> tabs = _get_tabs();
int side_margin = get_theme_constant("side_margin");
Ref<Texture2D> menu = get_theme_icon("menu");
@@ -231,12 +223,15 @@ void TabContainer::_notification(int p_what) {
int header_width = get_size().width - side_margin * 2;
// Find the width of the header area.
- if (popup)
+ if (popup) {
header_width -= menu->get_width();
- if (buttons_visible_cache)
+ }
+ if (buttons_visible_cache) {
header_width -= increment->get_width() + decrement->get_width();
- if (popup || buttons_visible_cache)
+ }
+ if (popup || buttons_visible_cache) {
header_width += side_margin;
+ }
// Find the width of all tabs after first_tab_cache.
int all_tabs_width = 0;
@@ -249,15 +244,15 @@ void TabContainer::_notification(int p_what) {
for (int i = first_tab_cache - 1; i >= 0; i--) {
int tab_width = _get_tab_width(i);
- if (all_tabs_width + tab_width > header_width)
+ if (all_tabs_width + tab_width > header_width) {
break;
+ }
all_tabs_width += tab_width;
first_tab_cache--;
}
} break;
case NOTIFICATION_DRAW: {
-
RID canvas = get_canvas_item();
Size2 size = get_size();
@@ -283,14 +278,15 @@ void TabContainer::_notification(int p_what) {
Color font_color_bg = get_theme_color("font_color_bg");
Color font_color_disabled = get_theme_color("font_color_disabled");
int side_margin = get_theme_constant("side_margin");
- int icon_text_distance = get_theme_constant("hseparation");
+ int icon_text_distance = get_theme_constant("icon_separation");
// Find out start and width of the header area.
int header_x = side_margin;
int header_width = size.width - side_margin * 2;
int header_height = _get_top_margin();
- if (popup)
+ if (popup) {
header_width -= menu->get_width();
+ }
// Check if all tabs would fit into the header area.
int all_tabs_width = 0;
@@ -327,8 +323,9 @@ void TabContainer::_notification(int p_what) {
continue;
}
int tab_width = _get_tab_width(i);
- if (all_tabs_width + tab_width > header_width && tab_widths.size() > 0)
+ if (all_tabs_width + tab_width > header_width && tab_widths.size() > 0) {
break;
+ }
all_tabs_width += tab_width;
tab_widths.push_back(tab_width);
}
@@ -387,8 +384,9 @@ void TabContainer::_notification(int p_what) {
if (icon.is_valid()) {
int y = y_center - (icon->get_height() / 2);
icon->draw(canvas, Point2i(x_content, y));
- if (text != "")
+ if (text != "") {
x_content += icon->get_width() + icon_text_distance;
+ }
}
}
@@ -404,15 +402,15 @@ void TabContainer::_notification(int p_what) {
x = get_size().width;
if (popup) {
x -= menu->get_width();
- if (menu_hovered)
+ if (menu_hovered) {
menu_hl->draw(get_canvas_item(), Size2(x, (header_height - menu_hl->get_height()) / 2));
- else
+ } else {
menu->draw(get_canvas_item(), Size2(x, (header_height - menu->get_height()) / 2));
+ }
}
// Draw the navigation buttons.
if (buttons_visible_cache) {
-
x -= increment->get_width();
if (last_tab_cache < tabs.size() - 1) {
draw_texture(highlight_arrow == 1 ? increment_hl : increment, Point2(x, (header_height - increment->get_height()) / 2));
@@ -429,7 +427,6 @@ void TabContainer::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED: {
-
minimum_size_changed();
call_deferred("_on_theme_changed"); // Wait until all changed theme.
} break;
@@ -438,7 +435,30 @@ void TabContainer::_notification(int p_what) {
void TabContainer::_on_theme_changed() {
if (get_tab_count() > 0) {
- set_current_tab(get_current_tab());
+ _repaint();
+ update();
+ }
+}
+
+void TabContainer::_repaint() {
+ Ref<StyleBox> sb = get_theme_stylebox("panel");
+ Vector<Control *> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
+ Control *c = tabs[i];
+ if (i == current) {
+ c->show();
+ c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ if (tabs_visible) {
+ c->set_margin(MARGIN_TOP, _get_top_margin());
+ }
+ c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
+ c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
+ c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
+ c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM)));
+
+ } else {
+ c->hide();
+ }
}
}
@@ -451,11 +471,11 @@ void TabContainer::_on_mouse_exited() {
}
int TabContainer::_get_tab_width(int p_index) const {
-
ERR_FAIL_INDEX_V(p_index, get_tab_count(), 0);
Control *control = Object::cast_to<Control>(_get_tabs()[p_index]);
- if (!control || control->is_set_as_toplevel() || get_tab_hidden(p_index))
+ if (!control || control->is_set_as_toplevel() || get_tab_hidden(p_index)) {
return 0;
+ }
// Get the width of the text displayed on the tab.
Ref<Font> font = get_theme_font("font");
@@ -467,8 +487,9 @@ int TabContainer::_get_tab_width(int p_index) const {
Ref<Texture2D> icon = control->get_meta("_tab_icon");
if (icon.is_valid()) {
width += icon->get_width();
- if (text != "")
- width += get_theme_constant("hseparation");
+ if (text != "") {
+ width += get_theme_constant("icon_separation");
+ }
}
}
@@ -488,13 +509,12 @@ int TabContainer::_get_tab_width(int p_index) const {
}
Vector<Control *> TabContainer::_get_tabs() const {
-
Vector<Control *> controls;
for (int i = 0; i < get_child_count(); i++) {
-
Control *control = Object::cast_to<Control>(get_child(i));
- if (!control || control->is_toplevel_control())
+ if (!control || control->is_toplevel_control()) {
continue;
+ }
controls.push_back(control);
}
@@ -502,25 +522,25 @@ Vector<Control *> TabContainer::_get_tabs() const {
}
void TabContainer::_child_renamed_callback() {
-
update();
}
void TabContainer::add_child_notify(Node *p_child) {
-
Container::add_child_notify(p_child);
Control *c = Object::cast_to<Control>(p_child);
- if (!c)
+ if (!c) {
return;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
return;
+ }
bool first = false;
- if (get_tab_count() != 1)
+ if (get_tab_count() != 1) {
c->hide();
- else {
+ } else {
c->show();
//call_deferred("set_current_tab",0);
first = true;
@@ -528,8 +548,9 @@ void TabContainer::add_child_notify(Node *p_child) {
previous = 0;
}
c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- if (tabs_visible)
+ if (tabs_visible) {
c->set_margin(MARGIN_TOP, _get_top_margin());
+ }
Ref<StyleBox> sb = get_theme_stylebox("panel");
c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
@@ -538,46 +559,28 @@ void TabContainer::add_child_notify(Node *p_child) {
update();
p_child->connect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback));
- if (first && is_inside_tree())
+ if (first && is_inside_tree()) {
emit_signal("tab_changed", current);
+ }
}
int TabContainer::get_tab_count() const {
-
return _get_tabs().size();
}
void TabContainer::set_current_tab(int p_current) {
-
ERR_FAIL_INDEX(p_current, get_tab_count());
int pending_previous = current;
current = p_current;
- Ref<StyleBox> sb = get_theme_stylebox("panel");
- Vector<Control *> tabs = _get_tabs();
- for (int i = 0; i < tabs.size(); i++) {
-
- Control *c = tabs[i];
- if (i == current) {
- c->show();
- c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- if (tabs_visible)
- c->set_margin(MARGIN_TOP, _get_top_margin());
- c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP)));
- c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT)));
- c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT)));
- c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM)));
-
- } else
- c->hide();
- }
+ _repaint();
_change_notify("current_tab");
- if (pending_previous == current)
+ if (pending_previous == current) {
emit_signal("tab_selected", current);
- else {
+ } else {
previous = pending_previous;
emit_signal("tab_selected", current);
emit_signal("tab_changed", current);
@@ -587,35 +590,32 @@ void TabContainer::set_current_tab(int p_current) {
}
int TabContainer::get_current_tab() const {
-
return current;
}
int TabContainer::get_previous_tab() const {
-
return previous;
}
Control *TabContainer::get_tab_control(int p_idx) const {
-
Vector<Control *> tabs = _get_tabs();
- if (p_idx >= 0 && p_idx < tabs.size())
+ if (p_idx >= 0 && p_idx < tabs.size()) {
return tabs[p_idx];
- else
+ } else {
return nullptr;
+ }
}
Control *TabContainer::get_current_tab_control() const {
-
Vector<Control *> tabs = _get_tabs();
- if (current >= 0 && current < tabs.size())
+ if (current >= 0 && current < tabs.size()) {
return tabs[current];
- else
+ } else {
return nullptr;
+ }
}
void TabContainer::remove_child_notify(Node *p_child) {
-
Container::remove_child_notify(p_child);
call_deferred("_update_current_tab");
@@ -626,25 +626,27 @@ void TabContainer::remove_child_notify(Node *p_child) {
}
void TabContainer::_update_current_tab() {
-
int tc = get_tab_count();
- if (current >= tc)
+ if (current >= tc) {
current = tc - 1;
- if (current < 0)
+ }
+ if (current < 0) {
current = 0;
- else
+ } else {
set_current_tab(current);
+ }
}
Variant TabContainer::get_drag_data(const Point2 &p_point) {
-
- if (!drag_to_rearrange_enabled)
+ if (!drag_to_rearrange_enabled) {
return Variant();
+ }
int tab_over = get_tab_idx_at_point(p_point);
- if (tab_over < 0)
+ if (tab_over < 0) {
return Variant();
+ }
HBoxContainer *drag_preview = memnew(HBoxContainer);
@@ -666,16 +668,16 @@ Variant TabContainer::get_drag_data(const Point2 &p_point) {
}
bool TabContainer::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
- if (!drag_to_rearrange_enabled)
+ if (!drag_to_rearrange_enabled) {
return false;
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
if (String(d["type"]) == "tabc_element") {
-
NodePath from_path = d["from_path"];
NodePath to_path = get_path();
if (from_path == to_path) {
@@ -693,24 +695,25 @@ bool TabContainer::can_drop_data(const Point2 &p_point, const Variant &p_data) c
}
void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) {
-
- if (!drag_to_rearrange_enabled)
+ if (!drag_to_rearrange_enabled) {
return;
+ }
int hover_now = get_tab_idx_at_point(p_point);
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return;
+ }
if (String(d["type"]) == "tabc_element") {
-
int tab_from_id = d["tabc_element"];
NodePath from_path = d["from_path"];
NodePath to_path = get_path();
if (from_path == to_path) {
- if (hover_now < 0)
+ if (hover_now < 0) {
hover_now = get_tab_count() - 1;
+ }
move_child(get_tab_control(tab_from_id), hover_now);
set_current_tab(hover_now);
} else if (get_tabs_rearrange_group() != -1) {
@@ -721,8 +724,9 @@ void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) {
Control *moving_tabc = from_tabc->get_tab_control(tab_from_id);
from_tabc->remove_child(moving_tabc);
add_child(moving_tabc);
- if (hover_now < 0)
+ if (hover_now < 0) {
hover_now = get_tab_count() - 1;
+ }
move_child(moving_tabc, hover_now);
set_current_tab(hover_now);
emit_signal("tab_changed", hover_now);
@@ -733,13 +737,14 @@ void TabContainer::drop_data(const Point2 &p_point, const Variant &p_data) {
}
int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const {
-
- if (get_tab_count() == 0)
+ if (get_tab_count() == 0) {
return -1;
+ }
// must be on tabs in the tab header area.
- if (p_point.x < tabs_ofs_cache || p_point.y > _get_top_margin())
+ if (p_point.x < tabs_ofs_cache || p_point.y > _get_top_margin()) {
return -1;
+ }
Size2 size = get_size();
int right_ofs = 0;
@@ -772,7 +777,6 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const {
}
void TabContainer::set_tab_align(TabAlign p_align) {
-
ERR_FAIL_INDEX(p_align, 3);
align = p_align;
update();
@@ -781,25 +785,24 @@ void TabContainer::set_tab_align(TabAlign p_align) {
}
TabContainer::TabAlign TabContainer::get_tab_align() const {
-
return align;
}
void TabContainer::set_tabs_visible(bool p_visible) {
-
- if (p_visible == tabs_visible)
+ if (p_visible == tabs_visible) {
return;
+ }
tabs_visible = p_visible;
Vector<Control *> tabs = _get_tabs();
for (int i = 0; i < tabs.size(); i++) {
-
Control *c = tabs[i];
- if (p_visible)
+ if (p_visible) {
c->set_margin(MARGIN_TOP, _get_top_margin());
- else
+ } else {
c->set_margin(MARGIN_TOP, 0);
+ }
}
update();
@@ -807,17 +810,14 @@ void TabContainer::set_tabs_visible(bool p_visible) {
}
bool TabContainer::are_tabs_visible() const {
-
return tabs_visible;
}
Control *TabContainer::_get_tab(int p_idx) const {
-
return get_tab_control(p_idx);
}
void TabContainer::set_tab_title(int p_tab, const String &p_title) {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
child->set_meta("_tab_name", p_title);
@@ -825,34 +825,33 @@ void TabContainer::set_tab_title(int p_tab, const String &p_title) {
}
String TabContainer::get_tab_title(int p_tab) const {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND_V(!child, "");
- if (child->has_meta("_tab_name"))
+ if (child->has_meta("_tab_name")) {
return child->get_meta("_tab_name");
- else
+ } else {
return child->get_name();
+ }
}
void TabContainer::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
child->set_meta("_tab_icon", p_icon);
update();
}
-Ref<Texture2D> TabContainer::get_tab_icon(int p_tab) const {
+Ref<Texture2D> TabContainer::get_tab_icon(int p_tab) const {
Control *child = _get_tab(p_tab);
ERR_FAIL_COND_V(!child, Ref<Texture2D>());
- if (child->has_meta("_tab_icon"))
+ if (child->has_meta("_tab_icon")) {
return child->get_meta("_tab_icon");
- else
+ } else {
return Ref<Texture2D>();
+ }
}
void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
child->set_meta("_tab_disabled", p_disabled);
@@ -860,17 +859,16 @@ void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) {
}
bool TabContainer::get_tab_disabled(int p_tab) const {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND_V(!child, false);
- if (child->has_meta("_tab_disabled"))
+ if (child->has_meta("_tab_disabled")) {
return child->get_meta("_tab_disabled");
- else
+ } else {
return false;
+ }
}
void TabContainer::set_tab_hidden(int p_tab, bool p_hidden) {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
child->set_meta("_tab_hidden", p_hidden);
@@ -890,43 +888,42 @@ void TabContainer::set_tab_hidden(int p_tab, bool p_hidden) {
}
bool TabContainer::get_tab_hidden(int p_tab) const {
-
Control *child = _get_tab(p_tab);
ERR_FAIL_COND_V(!child, false);
- if (child->has_meta("_tab_hidden"))
+ if (child->has_meta("_tab_hidden")) {
return child->get_meta("_tab_hidden");
- else
+ } else {
return false;
+ }
}
void TabContainer::get_translatable_strings(List<String> *p_strings) const {
-
Vector<Control *> tabs = _get_tabs();
for (int i = 0; i < tabs.size(); i++) {
-
Control *c = tabs[i];
- if (!c->has_meta("_tab_name"))
+ if (!c->has_meta("_tab_name")) {
continue;
+ }
String name = c->get_meta("_tab_name");
- if (name != "")
+ if (name != "") {
p_strings->push_back(name);
+ }
}
}
Size2 TabContainer::get_minimum_size() const {
-
Size2 ms;
Vector<Control *> tabs = _get_tabs();
for (int i = 0; i < tabs.size(); i++) {
-
Control *c = tabs[i];
- if (!c->is_visible_in_tree() && !use_hidden_tabs_for_min_size)
+ if (!c->is_visible_in_tree() && !use_hidden_tabs_for_min_size) {
continue;
+ }
Size2 cms = c->get_combined_minimum_size();
ms.x = MAX(ms.x, cms.x);
@@ -966,6 +963,7 @@ void TabContainer::set_drag_to_rearrange_enabled(bool p_enabled) {
bool TabContainer::get_drag_to_rearrange_enabled() const {
return drag_to_rearrange_enabled;
}
+
void TabContainer::set_tabs_rearrange_group(int p_group_id) {
tabs_rearrange_group = p_group_id;
}
@@ -983,7 +981,6 @@ bool TabContainer::get_use_hidden_tabs_for_min_size() const {
}
void TabContainer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &TabContainer::_gui_input);
ClassDB::bind_method(D_METHOD("get_tab_count"), &TabContainer::get_tab_count);
ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabContainer::set_current_tab);
@@ -1030,7 +1027,6 @@ void TabContainer::_bind_methods() {
}
TabContainer::TabContainer() {
-
first_tab_cache = 0;
last_tab_cache = 0;
buttons_visible_cache = false;
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 38c029475c..55a5d35b30 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -34,7 +34,6 @@
#include "scene/gui/container.h"
#include "scene/gui/popup.h"
class TabContainer : public Container {
-
GDCLASS(TabContainer, Container);
public:
@@ -66,6 +65,7 @@ private:
Vector<Control *> _get_tabs() const;
int _get_tab_width(int p_index) const;
void _on_theme_changed();
+ void _repaint();
void _on_mouse_exited();
void _update_current_tab();
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index b856d3ab3a..8f71aa7cab 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -36,7 +36,6 @@
#include "scene/gui/texture_rect.h"
Size2 Tabs::get_minimum_size() const {
-
Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_theme_stylebox("tab_fg");
Ref<StyleBox> tab_disabled = get_theme_stylebox("tab_disabled");
@@ -45,22 +44,23 @@ Size2 Tabs::get_minimum_size() const {
Size2 ms(0, MAX(MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height), tab_disabled->get_minimum_size().height) + font->get_height());
for (int i = 0; i < tabs.size(); i++) {
-
Ref<Texture2D> tex = tabs[i].icon;
if (tex.is_valid()) {
ms.height = MAX(ms.height, tex->get_size().height);
- if (tabs[i].text != "")
+ if (tabs[i].text != "") {
ms.width += get_theme_constant("hseparation");
+ }
}
ms.width += Math::ceil(font->get_string_size(tabs[i].xl_text).width);
- if (tabs[i].disabled)
+ if (tabs[i].disabled) {
ms.width += tab_disabled->get_minimum_size().width;
- else if (current == i)
+ } else if (current == i) {
ms.width += tab_fg->get_minimum_size().width;
- else
+ } else {
ms.width += tab_bg->get_minimum_size().width;
+ }
if (tabs[i].right_button.is_valid()) {
Ref<Texture2D> rb = tabs[i].right_button;
@@ -84,16 +84,13 @@ Size2 Tabs::get_minimum_size() const {
}
void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
Point2 pos = mm->get_position();
highlight_arrow = -1;
if (buttons_visible) {
-
Ref<Texture2D> incr = get_theme_icon("increment");
Ref<Texture2D> decr = get_theme_icon("decrement");
@@ -114,9 +111,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
-
if (scrolling_enabled && buttons_visible) {
if (offset > 0) {
offset--;
@@ -135,7 +130,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
if (rb_pressing && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (rb_hover != -1) {
//pressed
emit_signal("right_button_pressed", rb_hover);
@@ -146,7 +140,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (cb_hover != -1) {
//pressed
emit_signal("tab_close", cb_hover);
@@ -157,12 +150,10 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
if (mb->is_pressed() && (mb->get_button_index() == BUTTON_LEFT || (select_with_rmb && mb->get_button_index() == BUTTON_RIGHT))) {
-
// clicks
Point2 pos(mb->get_position().x, mb->get_position().y);
if (buttons_visible) {
-
Ref<Texture2D> incr = get_theme_icon("increment");
Ref<Texture2D> decr = get_theme_icon("decrement");
@@ -185,7 +176,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
int found = -1;
for (int i = offset; i < tabs.size(); i++) {
-
if (tabs[i].rb_rect.has_point(pos)) {
rb_pressing = true;
update();
@@ -207,7 +197,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
if (found != -1) {
-
set_current_tab(found);
emit_signal("tab_clicked", found);
}
@@ -216,9 +205,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
void Tabs::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_TRANSLATION_CHANGED: {
for (int i = 0; i < tabs.size(); ++i) {
tabs.write[i].xl_text = tr(tabs[i].text);
@@ -249,7 +236,6 @@ void Tabs::_notification(int p_what) {
int mw = 0;
for (int i = 0; i < tabs.size(); i++) {
-
tabs.write[i].ofs_cache = mw;
mw += get_tab_width(i);
}
@@ -274,7 +260,6 @@ void Tabs::_notification(int p_what) {
missing_right = false;
for (int i = offset; i < tabs.size(); i++) {
-
tabs.write[i].ofs_cache = w;
int lsize = tabs[i].size_cache;
@@ -309,10 +294,10 @@ void Tabs::_notification(int p_what) {
Size2i sb_ms = sb->get_minimum_size();
Ref<Texture2D> icon = tabs[i].icon;
if (icon.is_valid()) {
-
icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2));
- if (tabs[i].text != "")
+ if (tabs[i].text != "") {
w += icon->get_width() + get_theme_constant("hseparation");
+ }
}
font->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), tabs[i].xl_text, col, tabs[i].size_text);
@@ -320,7 +305,6 @@ void Tabs::_notification(int p_what) {
w += tabs[i].size_text;
if (tabs[i].right_button.is_valid()) {
-
Ref<StyleBox> style = get_theme_stylebox("button");
Ref<Texture2D> rb = tabs[i].right_button;
@@ -332,10 +316,11 @@ void Tabs::_notification(int p_what) {
rb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2;
if (rb_hover == i) {
- if (rb_pressing)
+ if (rb_pressing) {
get_theme_stylebox("button_pressed")->draw(ci, rb_rect);
- else
+ } else {
style->draw(ci, rb_rect);
+ }
}
rb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), rb_rect.position.y + style->get_margin(MARGIN_TOP)));
@@ -344,7 +329,6 @@ void Tabs::_notification(int p_what) {
}
if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
-
Ref<StyleBox> style = get_theme_stylebox("button");
Ref<Texture2D> cb = close;
@@ -356,10 +340,11 @@ void Tabs::_notification(int p_what) {
cb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2;
if (!tabs[i].disabled && cb_hover == i) {
- if (cb_pressing)
+ if (cb_pressing) {
get_theme_stylebox("button_pressed")->draw(ci, cb_rect);
- else
+ } else {
style->draw(ci, cb_rect);
+ }
}
cb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), cb_rect.position.y + style->get_margin(MARGIN_TOP)));
@@ -371,18 +356,19 @@ void Tabs::_notification(int p_what) {
}
if (offset > 0 || missing_right) {
-
int vofs = (get_size().height - incr->get_size().height) / 2;
- if (offset > 0)
+ if (offset > 0) {
draw_texture(highlight_arrow == 0 ? decr_hl : decr, Point2(limit, vofs));
- else
+ } else {
draw_texture(decr, Point2(limit, vofs), Color(1, 1, 1, 0.5));
+ }
- if (missing_right)
+ if (missing_right) {
draw_texture(highlight_arrow == 1 ? incr_hl : incr, Point2(limit + decr->get_size().width, vofs));
- else
+ } else {
draw_texture(incr, Point2(limit + decr->get_size().width, vofs), Color(1, 1, 1, 0.5));
+ }
buttons_visible = true;
} else {
@@ -393,14 +379,13 @@ void Tabs::_notification(int p_what) {
}
int Tabs::get_tab_count() const {
-
return tabs.size();
}
void Tabs::set_current_tab(int p_current) {
-
- if (current == p_current)
+ if (current == p_current) {
return;
+ }
ERR_FAIL_INDEX(p_current, get_tab_count());
current = p_current;
@@ -413,7 +398,6 @@ void Tabs::set_current_tab(int p_current) {
}
int Tabs::get_current_tab() const {
-
return current;
}
@@ -430,7 +414,6 @@ bool Tabs::get_offset_buttons_visible() const {
}
void Tabs::set_tab_title(int p_tab, const String &p_title) {
-
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].text = p_title;
tabs.write[p_tab].xl_text = tr(p_title);
@@ -439,13 +422,11 @@ void Tabs::set_tab_title(int p_tab, const String &p_title) {
}
String Tabs::get_tab_title(int p_tab) const {
-
ERR_FAIL_INDEX_V(p_tab, tabs.size(), "");
return tabs[p_tab].text;
}
void Tabs::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) {
-
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].icon = p_icon;
update();
@@ -453,39 +434,35 @@ void Tabs::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) {
}
Ref<Texture2D> Tabs::get_tab_icon(int p_tab) const {
-
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>());
return tabs[p_tab].icon;
}
void Tabs::set_tab_disabled(int p_tab, bool p_disabled) {
-
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].disabled = p_disabled;
update();
}
-bool Tabs::get_tab_disabled(int p_tab) const {
+bool Tabs::get_tab_disabled(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), false);
return tabs[p_tab].disabled;
}
void Tabs::set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button) {
-
ERR_FAIL_INDEX(p_tab, tabs.size());
tabs.write[p_tab].right_button = p_right_button;
_update_cache();
update();
minimum_size_changed();
}
-Ref<Texture2D> Tabs::get_tab_right_button(int p_tab) const {
+Ref<Texture2D> Tabs::get_tab_right_button(int p_tab) const {
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>());
return tabs[p_tab].right_button;
}
void Tabs::_update_hover() {
-
if (!is_inside_tree()) {
return;
}
@@ -495,7 +472,6 @@ void Tabs::_update_hover() {
int hover_now = -1;
int hover_buttons = -1;
for (int i = offset; i < tabs.size(); i++) {
-
Rect2 rect = get_tab_rect(i);
if (rect.has_point(pos)) {
hover_now = i;
@@ -552,7 +528,6 @@ void Tabs::_update_cache() {
m_width = MAX((limit - size_fixed) / count_resize, min_width);
}
for (int i = offset; i < tabs.size(); i++) {
-
Ref<StyleBox> sb;
if (tabs[i].disabled) {
sb = tab_disabled;
@@ -587,7 +562,6 @@ void Tabs::_update_cache() {
}
void Tabs::_on_mouse_exited() {
-
rb_hover = -1;
cb_hover = -1;
hover = -1;
@@ -596,7 +570,6 @@ void Tabs::_on_mouse_exited() {
}
void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) {
-
Tab t;
t.text = p_str;
t.xl_text = tr(p_str);
@@ -620,33 +593,36 @@ void Tabs::clear_tabs() {
}
void Tabs::remove_tab(int p_idx) {
-
ERR_FAIL_INDEX(p_idx, tabs.size());
tabs.remove(p_idx);
- if (current >= p_idx)
+ if (current >= p_idx) {
current--;
+ }
_update_cache();
call_deferred("_update_hover");
update();
minimum_size_changed();
- if (current < 0)
+ if (current < 0) {
current = 0;
- if (current >= tabs.size())
+ }
+ if (current >= tabs.size()) {
current = tabs.size() - 1;
+ }
_ensure_no_over_offset();
}
Variant Tabs::get_drag_data(const Point2 &p_point) {
-
- if (!drag_to_rearrange_enabled)
+ if (!drag_to_rearrange_enabled) {
return Variant();
+ }
int tab_over = get_tab_idx_at_point(p_point);
- if (tab_over < 0)
+ if (tab_over < 0) {
return Variant();
+ }
HBoxContainer *drag_preview = memnew(HBoxContainer);
@@ -672,16 +648,16 @@ Variant Tabs::get_drag_data(const Point2 &p_point) {
}
bool Tabs::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
- if (!drag_to_rearrange_enabled)
+ if (!drag_to_rearrange_enabled) {
return false;
+ }
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return false;
+ }
if (String(d["type"]) == "tab_element") {
-
NodePath from_path = d["from_path"];
NodePath to_path = get_path();
if (from_path == to_path) {
@@ -699,24 +675,25 @@ bool Tabs::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
}
void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
-
- if (!drag_to_rearrange_enabled)
+ if (!drag_to_rearrange_enabled) {
return;
+ }
int hover_now = get_tab_idx_at_point(p_point);
Dictionary d = p_data;
- if (!d.has("type"))
+ if (!d.has("type")) {
return;
+ }
if (String(d["type"]) == "tab_element") {
-
int tab_from_id = d["tab_element"];
NodePath from_path = d["from_path"];
NodePath to_path = get_path();
if (from_path == to_path) {
- if (hover_now < 0)
+ if (hover_now < 0) {
hover_now = get_tab_count() - 1;
+ }
move_tab(tab_from_id, hover_now);
emit_signal("reposition_active_tab_request", hover_now);
set_current_tab(hover_now);
@@ -725,11 +702,13 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
Node *from_node = get_node(from_path);
Tabs *from_tabs = Object::cast_to<Tabs>(from_node);
if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) {
- if (tab_from_id >= from_tabs->get_tab_count())
+ if (tab_from_id >= from_tabs->get_tab_count()) {
return;
+ }
Tab moving_tab = from_tabs->tabs[tab_from_id];
- if (hover_now < 0)
+ if (hover_now < 0) {
hover_now = get_tab_count();
+ }
tabs.insert(hover_now, moving_tab);
from_tabs->remove_tab(tab_from_id);
set_current_tab(hover_now);
@@ -742,10 +721,8 @@ void Tabs::drop_data(const Point2 &p_point, const Variant &p_data) {
}
int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
-
int hover_now = -1;
for (int i = offset; i < tabs.size(); i++) {
-
Rect2 rect = get_tab_rect(i);
if (rect.has_point(p_point)) {
hover_now = i;
@@ -756,21 +733,19 @@ int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
}
void Tabs::set_tab_align(TabAlign p_align) {
-
ERR_FAIL_INDEX(p_align, ALIGN_MAX);
tab_align = p_align;
update();
}
Tabs::TabAlign Tabs::get_tab_align() const {
-
return tab_align;
}
void Tabs::move_tab(int from, int to) {
-
- if (from == to)
+ if (from == to) {
return;
+ }
ERR_FAIL_INDEX(from, tabs.size());
ERR_FAIL_INDEX(to, tabs.size());
@@ -784,7 +759,6 @@ void Tabs::move_tab(int from, int to) {
}
int Tabs::get_tab_width(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0);
Ref<StyleBox> tab_bg = get_theme_stylebox("tab_bg");
@@ -797,18 +771,20 @@ int Tabs::get_tab_width(int p_idx) const {
Ref<Texture2D> tex = tabs[p_idx].icon;
if (tex.is_valid()) {
x += tex->get_width();
- if (tabs[p_idx].text != "")
+ if (tabs[p_idx].text != "") {
x += get_theme_constant("hseparation");
+ }
}
x += Math::ceil(font->get_string_size(tabs[p_idx].xl_text).width);
- if (tabs[p_idx].disabled)
+ if (tabs[p_idx].disabled) {
x += tab_disabled->get_minimum_size().width;
- else if (current == p_idx)
+ } else if (current == p_idx) {
x += tab_fg->get_minimum_size().width;
- else
+ } else {
x += tab_bg->get_minimum_size().width;
+ }
if (tabs[p_idx].right_button.is_valid()) {
Ref<Texture2D> rb = tabs[p_idx].right_button;
@@ -826,9 +802,9 @@ int Tabs::get_tab_width(int p_idx) const {
}
void Tabs::_ensure_no_over_offset() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
Ref<Texture2D> incr = get_theme_icon("increment");
Ref<Texture2D> decr = get_theme_icon("decrement");
@@ -836,10 +812,8 @@ void Tabs::_ensure_no_over_offset() {
int limit = get_size().width - incr->get_width() - decr->get_width();
while (offset > 0) {
-
int total_w = 0;
for (int i = offset - 1; i < tabs.size(); i++) {
-
total_w += tabs[i].size_cache;
}
@@ -853,12 +827,13 @@ void Tabs::_ensure_no_over_offset() {
}
void Tabs::ensure_tab_visible(int p_idx) {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (tabs.size() == 0)
+ if (tabs.size() == 0) {
return;
+ }
ERR_FAIL_INDEX(p_idx, tabs.size());
if (p_idx == offset) {
@@ -886,20 +861,17 @@ void Tabs::ensure_tab_visible(int p_idx) {
}
Rect2 Tabs::get_tab_rect(int p_tab) const {
-
ERR_FAIL_INDEX_V(p_tab, tabs.size(), Rect2());
return Rect2(tabs[p_tab].ofs_cache, 0, tabs[p_tab].size_cache, get_size().height);
}
void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
-
ERR_FAIL_INDEX(p_policy, CLOSE_BUTTON_MAX);
cb_displaypolicy = p_policy;
update();
}
Tabs::CloseButtonDisplayPolicy Tabs::get_tab_close_display_policy() const {
-
return cb_displaypolicy;
}
@@ -922,6 +894,7 @@ void Tabs::set_drag_to_rearrange_enabled(bool p_enabled) {
bool Tabs::get_drag_to_rearrange_enabled() const {
return drag_to_rearrange_enabled;
}
+
void Tabs::set_tabs_rearrange_group(int p_group_id) {
tabs_rearrange_group = p_group_id;
}
@@ -939,7 +912,6 @@ bool Tabs::get_select_with_rmb() const {
}
void Tabs::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &Tabs::_gui_input);
ClassDB::bind_method(D_METHOD("_update_hover"), &Tabs::_update_hover);
ClassDB::bind_method(D_METHOD("get_tab_count"), &Tabs::get_tab_count);
@@ -997,7 +969,6 @@ void Tabs::_bind_methods() {
}
Tabs::Tabs() {
-
current = 0;
tab_align = ALIGN_CENTER;
rb_hover = -1;
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 3170acb46f..8757f70ebe 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class Tabs : public Control {
-
GDCLASS(Tabs, Control);
public:
@@ -56,7 +55,6 @@ public:
private:
struct Tab {
-
String text;
String xl_text;
Ref<Texture2D> icon;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index e986e350f3..e050b3f174 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -45,12 +45,10 @@
#define TAB_PIXELS
inline bool _is_symbol(CharType c) {
-
return is_symbol(c);
}
static bool _is_text_char(CharType c) {
-
return !is_symbol(c);
}
@@ -59,7 +57,6 @@ static bool _is_whitespace(CharType c) {
}
static bool _is_char(CharType c) {
-
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
}
@@ -92,38 +89,41 @@ static bool _is_pair_symbol(CharType c) {
}
static CharType _get_right_pair_symbol(CharType c) {
- if (c == '"')
+ if (c == '"') {
return '"';
- if (c == '\'')
+ }
+ if (c == '\'') {
return '\'';
- if (c == '(')
+ }
+ if (c == '(') {
return ')';
- if (c == '[')
+ }
+ if (c == '[') {
return ']';
- if (c == '{')
+ }
+ if (c == '{') {
return '}';
+ }
return 0;
}
static int _find_first_non_whitespace_column_of_line(const String &line) {
int left = 0;
- while (left < line.length() && _is_whitespace(line[left]))
+ while (left < line.length() && _is_whitespace(line[left])) {
left++;
+ }
return left;
}
void TextEdit::Text::set_font(const Ref<Font> &p_font) {
-
font = p_font;
}
void TextEdit::Text::set_indent_size(int p_indent_size) {
-
indent_size = p_indent_size;
}
void TextEdit::Text::_update_line_cache(int p_line) const {
-
int w = 0;
int len = text[p_line].data.length();
@@ -144,9 +144,9 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
text.write[p_line].region_info.clear();
for (int i = 0; i < len; i++) {
-
- if (!_is_symbol(str[i]))
+ if (!_is_symbol(str[i])) {
continue;
+ }
if (str[i] == '\\') {
i++; // Skip quoted anything.
continue;
@@ -155,7 +155,6 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
int left = len - i;
for (int j = 0; j < color_regions->size(); j++) {
-
const ColorRegion &cr = color_regions->operator[](j);
/* BEGIN */
@@ -177,7 +176,6 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
}
if (match) {
-
ColorRegionInfo cri;
cri.end = false;
cri.region = j;
@@ -204,7 +202,6 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
}
if (match) {
-
ColorRegionInfo cri;
cri.end = true;
cri.region = j;
@@ -219,7 +216,6 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
}
const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) const {
-
static Map<int, ColorRegionInfo> cri;
ERR_FAIL_INDEX_V(p_line, text.size(), cri);
@@ -231,7 +227,6 @@ const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_regio
}
int TextEdit::Text::get_line_width(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), -1);
if (text[p_line].width_cache == -1) {
@@ -242,28 +237,24 @@ int TextEdit::Text::get_line_width(int p_line) const {
}
void TextEdit::Text::set_line_wrap_amount(int p_line, int p_wrap_amount) const {
-
ERR_FAIL_INDEX(p_line, text.size());
text.write[p_line].wrap_amount_cache = p_wrap_amount;
}
int TextEdit::Text::get_line_wrap_amount(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), -1);
return text[p_line].wrap_amount_cache;
}
void TextEdit::Text::clear_width_cache() {
-
for (int i = 0; i < text.size(); i++) {
text.write[i].width_cache = -1;
}
}
void TextEdit::Text::clear_wrap_cache() {
-
for (int i = 0; i < text.size(); i++) {
text.write[i].wrap_amount_cache = -1;
}
@@ -276,7 +267,6 @@ void TextEdit::Text::clear_info_icons() {
}
void TextEdit::Text::clear() {
-
text.clear();
insert(0, "");
}
@@ -286,14 +276,14 @@ int TextEdit::Text::get_max_width(bool p_exclude_hidden) const {
int max = 0;
for (int i = 0; i < text.size(); i++) {
- if (!p_exclude_hidden || !is_hidden(i))
+ if (!p_exclude_hidden || !is_hidden(i)) {
max = MAX(max, get_line_width(i));
+ }
}
return max;
}
void TextEdit::Text::set(int p_line, const String &p_text) {
-
ERR_FAIL_INDEX(p_line, text.size());
text.write[p_line].width_cache = -1;
@@ -302,7 +292,6 @@ void TextEdit::Text::set(int p_line, const String &p_text) {
}
void TextEdit::Text::insert(int p_at, const String &p_text) {
-
Line line;
line.marked = false;
line.safe = false;
@@ -315,32 +304,29 @@ void TextEdit::Text::insert(int p_at, const String &p_text) {
line.data = p_text;
text.insert(p_at, line);
}
-void TextEdit::Text::remove(int p_at) {
+void TextEdit::Text::remove(int p_at) {
text.remove(p_at);
}
int TextEdit::Text::get_char_width(CharType c, CharType next_c, int px) const {
-
int tab_w = font->get_char_size(' ').width * indent_size;
int w = 0;
if (c == '\t') {
-
int left = px % tab_w;
- if (left == 0)
+ if (left == 0) {
w = tab_w;
- else
+ } else {
w = tab_w - px % tab_w; // Is right.
+ }
} else {
-
w = font->get_char_size(c, next_c).width;
}
return w;
}
void TextEdit::_update_scrollbars() {
-
Size2 size = get_size();
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
@@ -360,8 +346,9 @@ void TextEdit::_update_scrollbars() {
int visible_width = size.width - cache.style_normal->get_minimum_size().width;
int total_width = text.get_max_width(true) + vmin.x;
- if (line_numbers)
+ if (line_numbers) {
total_width += cache.line_number_w;
+ }
if (draw_breakpoint_gutter || draw_bookmark_gutter) {
total_width += cache.breakpoint_gutter_width;
@@ -384,11 +371,9 @@ void TextEdit::_update_scrollbars() {
// Thanks yessopie for this clever bit of logic.
if (total_rows <= visible_rows && total_width <= visible_width) {
-
use_hscroll = false;
use_vscroll = false;
} else {
-
if (total_rows > visible_rows && total_width <= visible_width) {
use_hscroll = false;
}
@@ -401,7 +386,6 @@ void TextEdit::_update_scrollbars() {
updating_scrolls = true;
if (use_vscroll) {
-
v_scroll->show();
v_scroll->set_max(total_rows + get_visible_rows_offset());
v_scroll->set_page(visible_rows + get_visible_rows_offset());
@@ -413,7 +397,6 @@ void TextEdit::_update_scrollbars() {
set_v_scroll(get_v_scroll());
} else {
-
cursor.line_ofs = 0;
cursor.wrap_ofs = 0;
v_scroll->set_value(0);
@@ -421,18 +404,17 @@ void TextEdit::_update_scrollbars() {
}
if (use_hscroll && !is_wrap_enabled()) {
-
h_scroll->show();
h_scroll->set_max(total_width);
h_scroll->set_page(visible_width);
- if (cursor.x_ofs > (total_width - visible_width))
+ if (cursor.x_ofs > (total_width - visible_width)) {
cursor.x_ofs = (total_width - visible_width);
+ }
if (fabs(h_scroll->get_value() - (double)cursor.x_ofs) >= 1) {
h_scroll->set_value(cursor.x_ofs);
}
} else {
-
cursor.x_ofs = 0;
h_scroll->set_value(0);
h_scroll->hide();
@@ -442,7 +424,6 @@ void TextEdit::_update_scrollbars() {
}
void TextEdit::_click_selection_held() {
-
// Warning: is_mouse_button_pressed(BUTTON_LEFT) returns false for double+ clicks, so this doesn't work for MODE_WORD
// and MODE_LINE. However, moving the mouse triggers _gui_input, which calls these functions too, so that's not a huge problem.
// I'm unsure if there's an actual fix that doesn't have a ton of side effects.
@@ -597,7 +578,6 @@ void TextEdit::_update_minimap_click() {
}
void TextEdit::_update_minimap_drag() {
-
if (!can_drag_minimap) {
return;
}
@@ -614,14 +594,15 @@ void TextEdit::_update_minimap_drag() {
}
void TextEdit::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
_update_caches();
- if (cursor_changed_dirty)
+ if (cursor_changed_dirty) {
MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
- if (text_changed_dirty)
+ }
+ if (text_changed_dirty) {
MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
+ }
_update_wrap_at();
} break;
case NOTIFICATION_RESIZED: {
@@ -718,7 +699,6 @@ void TextEdit::_notification(int p_what) {
};
if (line_numbers) {
-
line_number_char_count = cache.line_number_w;
cache.line_number_w = (cache.line_number_w + 1) * cache.font->get_char_size('0').width;
} else {
@@ -738,8 +718,9 @@ void TextEdit::_notification(int p_what) {
cache.style_readonly->draw(ci, Rect2(Point2(), size));
draw_caret = false;
}
- if (has_focus())
+ if (has_focus()) {
cache.style_focus->draw(ci, Rect2(Point2(), size));
+ }
int ascent = cache.font->get_ascent();
@@ -778,7 +759,6 @@ void TextEdit::_notification(int p_what) {
bool brace_close_mismatch = false;
if (brace_matching_enabled && cursor.line >= 0 && cursor.line < text.size() && cursor.column >= 0) {
-
if (cursor.column < text[cursor.line].length()) {
// Check for open.
CharType c = text[cursor.line][cursor.column];
@@ -793,14 +773,11 @@ void TextEdit::_notification(int p_what) {
}
if (closec != 0) {
-
int stack = 1;
for (int i = cursor.line; i < text.size(); i++) {
-
int from = i == cursor.line ? cursor.column + 1 : 0;
for (int j = from; j < text[i].length(); j++) {
-
CharType cc = text[i][j];
// Ignore any brackets inside a string.
if (cc == '"' || cc == '\'') {
@@ -824,10 +801,11 @@ void TextEdit::_notification(int p_what) {
}
}
} while (cc != quotation);
- } else if (cc == c)
+ } else if (cc == c) {
stack++;
- else if (cc == closec)
+ } else if (cc == closec) {
stack--;
+ }
if (stack == 0) {
brace_open_match_line = i;
@@ -837,12 +815,14 @@ void TextEdit::_notification(int p_what) {
break;
}
}
- if (brace_open_match_line != -1)
+ if (brace_open_match_line != -1) {
break;
+ }
}
- if (!brace_open_matching)
+ if (!brace_open_matching) {
brace_open_mismatch = true;
+ }
}
}
@@ -859,14 +839,11 @@ void TextEdit::_notification(int p_what) {
}
if (closec != 0) {
-
int stack = 1;
for (int i = cursor.line; i >= 0; i--) {
-
int from = i == cursor.line ? cursor.column - 2 : text[i].length() - 1;
for (int j = from; j >= 0; j--) {
-
CharType cc = text[i][j];
// Ignore any brackets inside a string.
if (cc == '"' || cc == '\'') {
@@ -890,10 +867,11 @@ void TextEdit::_notification(int p_what) {
}
}
} while (cc != quotation);
- } else if (cc == c)
+ } else if (cc == c) {
stack++;
- else if (cc == closec)
+ } else if (cc == closec) {
stack--;
+ }
if (stack == 0) {
brace_close_match_line = i;
@@ -903,12 +881,14 @@ void TextEdit::_notification(int p_what) {
break;
}
}
- if (brace_close_match_line != -1)
+ if (brace_close_match_line != -1) {
break;
+ }
}
- if (!brace_close_matching)
+ if (!brace_close_matching) {
brace_close_mismatch = true;
+ }
}
}
}
@@ -957,7 +937,6 @@ void TextEdit::_notification(int p_what) {
Color viewport_color = (cache.background_color.get_v() < 0.5) ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1);
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), viewport_offset_y, cache.minimap_width, viewport_height), viewport_color);
for (int i = 0; i < minimap_draw_amount; i++) {
-
minimap_line++;
if (minimap_line < 0 || minimap_line >= (int)text.size()) {
@@ -992,8 +971,9 @@ void TextEdit::_notification(int p_what) {
for (int line_wrap_index = 0; line_wrap_index < line_wrap_amount + 1; line_wrap_index++) {
if (line_wrap_index != 0) {
i++;
- if (i >= minimap_draw_amount)
+ if (i >= minimap_draw_amount) {
break;
+ }
}
const String &str = wrap_rows[line_wrap_index];
@@ -1078,11 +1058,11 @@ void TextEdit::_notification(int p_what) {
// draw main text
int line = first_visible_line;
for (int i = 0; i < draw_amount; i++) {
-
line++;
- if (line < 0 || line >= (int)text.size())
+ if (line < 0 || line >= (int)text.size()) {
continue;
+ }
while (is_line_hidden(line)) {
line++;
@@ -1091,8 +1071,9 @@ void TextEdit::_notification(int p_what) {
}
}
- if (line < 0 || line >= (int)text.size())
+ if (line < 0 || line >= (int)text.size()) {
continue;
+ }
const String &fullstr = text[line];
@@ -1112,8 +1093,9 @@ void TextEdit::_notification(int p_what) {
for (int line_wrap_index = 0; line_wrap_index < line_wrap_amount + 1; line_wrap_index++) {
if (line_wrap_index != 0) {
i++;
- if (i >= draw_amount)
+ if (i >= draw_amount) {
break;
+ }
}
const String &str = wrap_rows[line_wrap_index];
@@ -1122,8 +1104,9 @@ void TextEdit::_notification(int p_what) {
indent_px = 0;
}
- if (line_wrap_index > 0)
+ if (line_wrap_index > 0) {
last_wrap_column += wrap_rows[line_wrap_index - 1].length();
+ }
int char_margin = xmargin_beg - cursor.x_ofs;
char_margin += indent_px;
@@ -1138,19 +1121,20 @@ void TextEdit::_notification(int p_what) {
int ofs_y = (i * get_row_height() + cache.line_spacing / 2) + ofs_readonly;
ofs_y -= cursor.wrap_ofs * get_row_height();
- if (smooth_scroll_enabled)
- ofs_y += (-get_v_scroll_offset()) * get_row_height();
+ ofs_y -= get_v_scroll_offset() * get_row_height();
// Check if line contains highlighted word.
int highlighted_text_col = -1;
int search_text_col = -1;
int highlighted_word_col = -1;
- if (!search_text.empty())
+ if (!search_text.empty()) {
search_text_col = _get_column_pos_of_word(search_text, str, search_flags, 0);
+ }
- if (highlighted_text.length() != 0 && highlighted_text != search_text)
+ if (highlighted_text.length() != 0 && highlighted_text != search_text) {
highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, 0);
+ }
if (select_identifiers_enabled && highlighted_word.length() != 0) {
if (_is_char(highlighted_word[0]) || highlighted_word[0] == '.') {
@@ -1286,7 +1270,6 @@ void TextEdit::_notification(int p_what) {
// Loop through characters in one line.
int j = 0;
for (; j < str.length(); j++) {
-
if (syntax_coloring) {
if (color_map.has(last_wrap_column + j)) {
current_color = color_map[last_wrap_column + j].color;
@@ -1307,7 +1290,6 @@ void TextEdit::_notification(int p_what) {
// Line highlighting handle horizontal clipping.
if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) {
-
if (j == str.length() - 1) {
// End of line when last char is skipped.
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color);
@@ -1327,8 +1309,9 @@ void TextEdit::_notification(int p_what) {
if (search_text_col != -1) {
// If we are at the end check for new search result on same line.
- if (j >= search_text_col + search_text.length())
+ if (j >= search_text_col + search_text.length()) {
search_text_col = _get_column_pos_of_word(search_text, str, search_flags, j);
+ }
in_search_result = j >= search_text_col && j < search_text_col + search_text.length();
@@ -1365,15 +1348,16 @@ void TextEdit::_notification(int p_what) {
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, 1)), border_color);
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color);
- if (j == search_text_col)
+ if (j == search_text_col) {
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(1, get_row_height())), border_color);
- if (j == search_text_col + search_text.length() - 1)
+ }
+ if (j == search_text_col + search_text.length() - 1) {
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w + ofs_x - 1, ofs_y), Size2i(1, get_row_height())), border_color);
+ }
}
if (highlight_all_occurrences && !only_whitespaces_highlighted) {
if (highlighted_text_col != -1) {
-
// If we are at the end check for new word on same line.
if (j > highlighted_text_col + highlighted_text.length()) {
highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, j);
@@ -1403,23 +1387,22 @@ void TextEdit::_notification(int p_what) {
int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2;
if ((brace_open_match_line == line && brace_open_match_column == last_wrap_column + j) ||
(cursor.column == last_wrap_column + j && cursor.line == line && cursor_wrap_index == line_wrap_index && (brace_open_matching || brace_open_mismatch))) {
-
- if (brace_open_mismatch)
+ if (brace_open_mismatch) {
color = cache.brace_mismatch_color;
+ }
drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color);
}
if ((brace_close_match_line == line && brace_close_match_column == last_wrap_column + j) ||
(cursor.column == last_wrap_column + j + 1 && cursor.line == line && cursor_wrap_index == line_wrap_index && (brace_close_matching || brace_close_mismatch))) {
-
- if (brace_close_mismatch)
+ if (brace_close_mismatch) {
color = cache.brace_mismatch_color;
+ }
drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color);
}
}
if (cursor.column == last_wrap_column + j && cursor.line == line && cursor_wrap_index == line_wrap_index) {
-
cursor_pos = Point2i(char_ofs + char_margin + ofs_x, ofs_y);
cursor_pos.y += (get_row_height() - cache.font->get_height()) / 2;
@@ -1432,15 +1415,17 @@ void TextEdit::_notification(int p_what) {
if (ime_text.length() > 0) {
int ofs = 0;
while (true) {
- if (ofs >= ime_text.length())
+ if (ofs >= ime_text.length()) {
break;
+ }
CharType cchar = ime_text[ofs];
CharType next = ime_text[ofs + 1];
int im_char_width = cache.font->get_char_size(cchar, next).width;
- if ((char_ofs + char_margin + im_char_width) >= xmargin_end)
+ if ((char_ofs + char_margin + im_char_width) >= xmargin_end) {
break;
+ }
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
@@ -1516,7 +1501,6 @@ void TextEdit::_notification(int p_what) {
}
if (cursor.column == (last_wrap_column + j) && cursor.line == line && cursor_wrap_index == line_wrap_index && (char_ofs + char_margin) >= xmargin_beg) {
-
cursor_pos = Point2i(char_ofs + char_margin + ofs_x, ofs_y);
cursor_pos.y += (get_row_height() - cache.font->get_height()) / 2;
@@ -1527,15 +1511,17 @@ void TextEdit::_notification(int p_what) {
if (ime_text.length() > 0) {
int ofs = 0;
while (true) {
- if (ofs >= ime_text.length())
+ if (ofs >= ime_text.length()) {
break;
+ }
CharType cchar = ime_text[ofs];
CharType next = ime_text[ofs + 1];
int im_char_width = cache.font->get_char_size(cchar, next).width;
- if ((char_ofs + char_margin + im_char_width) >= xmargin_end)
+ if ((char_ofs + char_margin + im_char_width) >= xmargin_end) {
break;
+ }
bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y;
if (selected) {
@@ -1594,8 +1580,9 @@ void TextEdit::_notification(int p_what) {
if (completion_options_size < 50) {
for (int i = 0; i < completion_options_size; i++) {
int w2 = MIN(cache.font->get_string_size(completion_options[i].display).x, cmax_width);
- if (w2 > w)
+ if (w2 > w) {
w = w2;
+ }
}
} else {
w = cmax_width;
@@ -1623,8 +1610,9 @@ void TextEdit::_notification(int p_what) {
completion_rect.size.width = w + 2;
completion_rect.size.height = h;
- if (completion_options_size <= maxlines)
+ if (completion_options_size <= maxlines) {
scrollw = 0;
+ }
draw_style_box(csb, Rect2(completion_rect.position - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0)));
@@ -1636,7 +1624,6 @@ void TextEdit::_notification(int p_what) {
draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(MIN(nofs, completion_rect.size.width - (icon_area_size.x + icon_hsep)), completion_rect.size.height)), cache.completion_existing_color);
for (int i = 0; i < lines; i++) {
-
int l = line_from + i;
ERR_CONTINUE(l < 0 || l >= completion_options_size);
Color text_color = cache.completion_font_color;
@@ -1688,7 +1675,6 @@ void TextEdit::_notification(int p_what) {
}
if (show_hint) {
-
Ref<StyleBox> sb = get_theme_stylebox("panel", "TooltipPanel");
Ref<Font> font = cache.font;
Color font_color = get_theme_color("font_color", "TooltipLabel");
@@ -1698,7 +1684,6 @@ void TextEdit::_notification(int p_what) {
int offset = 0;
int spacing = 0;
for (int i = 0; i < sc; i++) {
-
String l = completion_hint.get_slice("\n", i);
int len = font->get_string_size(l).x;
max_w = MAX(len, max_w);
@@ -1756,7 +1741,6 @@ void TextEdit::_notification(int p_what) {
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
-
if (caret_blink_enabled) {
caret_blink_timer->start();
} else {
@@ -1769,11 +1753,11 @@ void TextEdit::_notification(int p_what) {
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
}
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
DisplayServer::get_singleton()->virtual_keyboard_show(get_text(), get_global_rect());
+ }
} break;
case NOTIFICATION_FOCUS_EXIT: {
-
if (caret_blink_enabled) {
caret_blink_timer->stop();
}
@@ -1785,11 +1769,11 @@ void TextEdit::_notification(int p_what) {
ime_text = "";
ime_selection = Point2();
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD))
+ if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
DisplayServer::get_singleton()->virtual_keyboard_hide();
+ }
} break;
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
-
if (has_focus()) {
ime_text = DisplayServer::get_singleton()->ime_get_text();
ime_selection = DisplayServer::get_singleton()->ime_get_selection();
@@ -1800,7 +1784,6 @@ void TextEdit::_notification(int p_what) {
}
void TextEdit::_consume_pair_symbol(CharType ch) {
-
int cursor_position_to_move = cursor_get_column() + 1;
CharType ch_single[2] = { ch, 0 };
@@ -1808,7 +1791,6 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
CharType ch_pair[3] = { ch, _get_right_pair_symbol(ch), 0 };
if (is_selection_active()) {
-
int new_column, new_line;
begin_complex_operation();
@@ -1817,8 +1799,9 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
&new_line, &new_column);
int to_col_offset = 0;
- if (get_selection_from_line() == get_selection_to_line())
+ if (get_selection_from_line() == get_selection_to_line()) {
to_col_offset = 1;
+ }
_insert_text(get_selection_to_line(),
get_selection_to_column() + to_col_offset,
@@ -1907,11 +1890,9 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
}
void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column) {
-
bool remove_right_symbol = false;
if (cursor.column < text[cursor.line].length() && cursor.column > 0) {
-
CharType left_char = text[cursor.line][cursor.column - 1];
CharType right_char = text[cursor.line][cursor.column];
@@ -1927,20 +1908,24 @@ void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column
}
void TextEdit::backspace_at_cursor() {
- if (readonly)
+ if (readonly) {
return;
+ }
- if (cursor.column == 0 && cursor.line == 0)
+ if (cursor.column == 0 && cursor.line == 0) {
return;
+ }
int prev_line = cursor.column ? cursor.line : cursor.line - 1;
int prev_column = cursor.column ? (cursor.column - 1) : (text[cursor.line - 1].length());
- if (is_line_hidden(cursor.line))
+ if (is_line_hidden(cursor.line)) {
set_line_as_hidden(prev_line, true);
+ }
if (is_line_set_as_breakpoint(cursor.line)) {
- if (!text.is_breakpoint(prev_line))
+ if (!text.is_breakpoint(prev_line)) {
emit_signal("breakpoint_toggled", prev_line);
+ }
set_line_as_breakpoint(prev_line, true);
}
@@ -1985,7 +1970,6 @@ void TextEdit::backspace_at_cursor() {
}
void TextEdit::indent_right() {
-
int start_line;
int end_line;
@@ -2016,8 +2000,9 @@ void TextEdit::indent_right() {
int spaces_to_add = _calculate_spaces_till_next_right_indent(left);
// Since we will add this much spaces we want move whole selection and cursor by this much.
selection_offset = spaces_to_add;
- for (int j = 0; j < spaces_to_add; j++)
+ for (int j = 0; j < spaces_to_add; j++) {
line_text = ' ' + line_text;
+ }
} else {
line_text = '\t' + line_text;
}
@@ -2034,7 +2019,6 @@ void TextEdit::indent_right() {
}
void TextEdit::indent_left() {
-
int start_line;
int end_line;
@@ -2095,8 +2079,9 @@ void TextEdit::indent_left() {
int TextEdit::_calculate_spaces_till_next_left_indent(int column) {
int spaces_till_indent = column % indent_size;
- if (spaces_till_indent == 0)
+ if (spaces_till_indent == 0) {
spaces_till_indent = indent_size;
+ }
return spaces_till_indent;
}
@@ -2105,7 +2090,6 @@ int TextEdit::_calculate_spaces_till_next_right_indent(int column) {
}
void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const {
-
float rows = p_mouse.y;
rows -= cache.style_normal->get_margin(MARGIN_TOP);
rows /= get_row_height();
@@ -2115,25 +2099,24 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co
int wrap_index = 0;
if (is_wrap_enabled() || is_hiding_enabled()) {
-
int f_ofs = num_lines_from_rows(first_vis_line, cursor.wrap_ofs, rows + (1 * SGN(rows)), wrap_index) - 1;
- if (rows < 0)
+ if (rows < 0) {
row = first_vis_line - f_ofs;
- else
+ } else {
row = first_vis_line + f_ofs;
+ }
}
- if (row < 0)
+ if (row < 0) {
row = 0; // TODO.
+ }
int col = 0;
if (row >= text.size()) {
-
row = text.size() - 1;
col = text[row].size();
} else {
-
int colx = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width);
colx += cursor.x_ofs;
col = get_char_pos_for_line(colx, row, wrap_index);
@@ -2144,8 +2127,9 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co
for (int i = 0; i < wrap_index + 1; i++) {
row_end_col += rows2[i].length();
}
- if (col >= row_end_col)
+ if (col >= row_end_col) {
col -= 1;
+ }
}
}
@@ -2192,7 +2176,6 @@ Vector2i TextEdit::_get_cursor_pixel_pos() {
}
void TextEdit::_get_minimap_mouse_row(const Point2i &p_mouse, int &r_row) const {
-
float rows = p_mouse.y;
rows -= cache.style_normal->get_margin(MARGIN_TOP);
rows /= (minimap_char_size.y + minimap_line_spacing);
@@ -2226,7 +2209,6 @@ void TextEdit::_get_minimap_mouse_row(const Point2i &p_mouse, int &r_row) const
int wrap_index = 0;
if (is_wrap_enabled() || is_hiding_enabled()) {
-
int f_ofs = num_lines_from_rows(minimap_line, cursor.wrap_ofs, rows + (1 * SGN(rows)), wrap_index) - 1;
if (rows < 0) {
row = minimap_line - f_ofs;
@@ -2247,7 +2229,6 @@ void TextEdit::_get_minimap_mouse_row(const Point2i &p_mouse, int &r_row) const
}
void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
-
double prev_v_scroll = v_scroll->get_value();
double prev_h_scroll = h_scroll->get_value();
@@ -2255,9 +2236,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb.is_valid()) {
if (completion_active && completion_rect.has_point(mb->get_position())) {
-
- if (!mb->is_pressed())
+ if (!mb->is_pressed()) {
return;
+ }
if (mb->get_button_index() == BUTTON_WHEEL_UP) {
if (completion_index > 0) {
@@ -2267,7 +2248,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN) {
-
if (completion_index < completion_options.size() - 1) {
completion_index++;
completion_current = completion_options[completion_index];
@@ -2276,13 +2256,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (mb->get_button_index() == BUTTON_LEFT) {
-
completion_index = CLAMP(completion_line_ofs + (mb->get_position().y - completion_rect.position.y) / get_row_height(), 0, completion_options.size() - 1);
completion_current = completion_options[completion_index];
update();
- if (mb->is_doubleclick())
+ if (mb->is_doubleclick()) {
_confirm_completion();
+ }
}
return;
} else {
@@ -2291,7 +2271,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (mb->is_pressed()) {
-
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
if (mb->get_shift()) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
@@ -2313,7 +2292,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
h_scroll->set_value(h_scroll->get_value() + (100 * mb->get_factor()));
}
if (mb->get_button_index() == BUTTON_LEFT) {
-
_reset_caret_blink_timer();
int row, col;
@@ -2341,7 +2319,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// Toggle fold on gutter click if can.
if (draw_fold_gutter) {
-
int left_margin = cache.style_normal->get_margin(MARGIN_LEFT);
int gutter_left = left_margin + cache.breakpoint_gutter_width + cache.line_number_w + cache.info_gutter_width;
if (mb->get_position().x > gutter_left - 6 && mb->get_position().x <= gutter_left + cache.fold_gutter_width - 3) {
@@ -2379,7 +2356,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
cursor_set_column(col);
if (mb->get_shift() && (cursor.column != prev_col || cursor.line != prev_line)) {
-
if (!selection.active) {
selection.active = true;
selection.selecting_mode = Selection::MODE_POINTER;
@@ -2399,9 +2375,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
selection.selecting_column = prev_col;
update();
} else {
-
if (cursor.line < selection.selecting_line || (cursor.line == selection.selecting_line && cursor.column < selection.selecting_column)) {
-
if (selection.shiftclick_left) {
SWAP(selection.from_column, selection.to_column);
SWAP(selection.from_line, selection.to_line);
@@ -2411,7 +2385,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
selection.from_line = cursor.line;
} else if (cursor.line > selection.selecting_line || (cursor.line == selection.selecting_line && cursor.column > selection.selecting_column)) {
-
if (!selection.shiftclick_left) {
SWAP(selection.from_column, selection.to_column);
SWAP(selection.from_line, selection.to_line);
@@ -2428,7 +2401,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
} else {
-
selection.active = false;
selection.selecting_mode = Selection::MODE_POINTER;
selection.selecting_line = row;
@@ -2436,13 +2408,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (!mb->is_doubleclick() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < 600 && cursor.line == prev_line) {
-
// Triple-click select line.
selection.selecting_mode = Selection::MODE_LINE;
_update_selection_mode_line();
last_dblclk = 0;
} else if (mb->is_doubleclick() && text[cursor.line].length()) {
-
// Double-click select word.
selection.selecting_mode = Selection::MODE_WORD;
_update_selection_mode_word();
@@ -2453,7 +2423,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (mb->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
-
_reset_caret_blink_timer();
int row, col;
@@ -2461,7 +2430,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (is_right_click_moving_caret()) {
if (is_selection_active()) {
-
int from_line = get_selection_from_line();
int to_line = get_selection_to_line();
int from_column = get_selection_from_column();
@@ -2485,7 +2453,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
grab_focus();
}
} else {
-
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->get_command() && highlighted_word != String()) {
int row, col;
@@ -2508,7 +2475,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
const Ref<InputEventPanGesture> pan_gesture = p_gui_input;
if (pan_gesture.is_valid()) {
-
const real_t delta = pan_gesture->get_delta().y;
if (delta < 0) {
_scroll_up(-delta);
@@ -2516,8 +2482,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
_scroll_down(delta);
}
h_scroll->set_value(h_scroll->get_value() + pan_gesture->get_delta().x * 100);
- if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll)
+ if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) {
accept_event(); // Accept event if scroll changed.
+ }
return;
}
@@ -2525,10 +2492,8 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
Ref<InputEventMouseMotion> mm = p_gui_input;
if (mm.is_valid()) {
-
if (select_identifiers_enabled) {
if (!dragging_minimap && !dragging_selection && mm->get_command() && mm->get_button_mask() == 0) {
-
String new_word = get_word_at_pos(mm->get_position());
if (new_word != highlighted_word) {
emit_signal("symbol_validate", new_word);
@@ -2566,13 +2531,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll)
+ if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) {
accept_event(); // Accept event if scroll changed.
+ }
Ref<InputEventKey> k = p_gui_input;
if (k.is_valid()) {
-
k = k->duplicate(); // It will be modified later on.
#ifdef OSX_ENABLED
@@ -2582,7 +2547,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#endif
if (select_identifiers_enabled) {
-
if (k->is_pressed() && !dragging_minimap && !dragging_selection) {
emit_signal("symbol_validate", get_word_at_pos(get_local_mouse_position()));
} else {
@@ -2591,22 +2555,23 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (!k->is_pressed())
+ if (!k->is_pressed()) {
return;
+ }
if (completion_active) {
- if (readonly)
+ if (readonly) {
return;
+ }
bool valid = true;
- if (k->get_command() || k->get_metakey())
+ if (k->get_command() || k->get_metakey()) {
valid = false;
+ }
if (valid) {
-
if (!k->get_alt()) {
if (k->get_keycode() == KEY_UP) {
-
if (completion_index > 0) {
completion_index--;
} else {
@@ -2620,7 +2585,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_keycode() == KEY_DOWN) {
-
if (completion_index < completion_options.size() - 1) {
completion_index++;
} else {
@@ -2634,10 +2598,10 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_keycode() == KEY_PAGEUP) {
-
completion_index -= get_theme_constant("completion_lines");
- if (completion_index < 0)
+ if (completion_index < 0) {
completion_index = 0;
+ }
completion_current = completion_options[completion_index];
update();
accept_event();
@@ -2645,10 +2609,10 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_keycode() == KEY_PAGEDOWN) {
-
completion_index += get_theme_constant("completion_lines");
- if (completion_index >= completion_options.size())
+ if (completion_index >= completion_options.size()) {
completion_index = completion_options.size() - 1;
+ }
completion_current = completion_options[completion_index];
update();
accept_event();
@@ -2656,7 +2620,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_keycode() == KEY_HOME && completion_index > 0) {
-
completion_index = 0;
completion_current = completion_options[completion_index];
update();
@@ -2665,7 +2628,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_keycode() == KEY_END && completion_index < completion_options.size() - 1) {
-
completion_index = completion_options.size() - 1;
completion_current = completion_options[completion_index];
update();
@@ -2674,14 +2636,12 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_keycode() == KEY_KP_ENTER || k->get_keycode() == KEY_ENTER || k->get_keycode() == KEY_TAB) {
-
_confirm_completion();
accept_event();
return;
}
if (k->get_keycode() == KEY_BACKSPACE) {
-
_reset_caret_blink_timer();
backspace_at_cursor();
@@ -2697,14 +2657,12 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (k->get_unicode() > 32) {
-
_reset_caret_blink_timer();
const CharType chr[2] = { (CharType)k->get_unicode(), 0 };
if (auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
_consume_pair_symbol(chr[0]);
} else {
-
// Remove the old character if in insert mode.
if (insert_mode) {
begin_complex_operation();
@@ -2735,11 +2693,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// Some remaps for duplicate functions.
if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) {
-
k->set_keycode(KEY_C);
}
if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) {
-
k->set_keycode(KEY_V);
k->set_command(true);
k->set_shift(false);
@@ -2782,13 +2738,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// Stuff to do when selection is active.
if (!readonly && selection.active) {
-
bool clear = false;
bool unselect = false;
bool dobreak = false;
switch (k->get_keycode()) {
-
case KEY_TAB: {
if (k->get_shift()) {
indent_left();
@@ -2826,16 +2780,19 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
case KEY_HOME:
case KEY_END:
// Ignore arrows if any modifiers are held (shift = selecting, others may be used for editor hotkeys).
- if (k->get_command() || k->get_shift() || k->get_alt())
+ if (k->get_command() || k->get_shift() || k->get_alt()) {
break;
+ }
unselect = true;
break;
default:
- if (k->get_unicode() >= 32 && !k->get_command() && !k->get_alt() && !k->get_metakey())
+ if (k->get_unicode() >= 32 && !k->get_command() && !k->get_alt() && !k->get_metakey()) {
clear = true;
- if (auto_brace_completion_enabled && _is_pair_left_symbol(k->get_unicode()))
+ }
+ if (auto_brace_completion_enabled && _is_pair_left_symbol(k->get_unicode())) {
clear = false;
+ }
}
if (unselect) {
@@ -2844,7 +2801,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
update();
}
if (clear) {
-
if (!dobreak) {
begin_complex_operation();
}
@@ -2855,8 +2811,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
cursor_set_column(selection.from_column);
update();
}
- if (dobreak)
+ if (dobreak) {
return;
+ }
}
selection.selecting_text = false;
@@ -2866,12 +2823,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// Special keycode test.
switch (k->get_keycode()) {
-
case KEY_KP_ENTER:
case KEY_ENTER: {
-
- if (readonly)
+ if (readonly) {
break;
+ }
String ins = "\n";
@@ -2901,8 +2857,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (is_folded(cursor.line))
+ if (is_folded(cursor.line)) {
unfold_line(cursor.line);
+ }
bool brace_indent = false;
@@ -2931,7 +2888,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (indent_char_found && cri_map.has(i) && (color_regions[cri_map[i].region].begin_key == "#" || color_regions[cri_map[i].region].begin_key == "//")) {
-
should_indent = true;
break;
} else if (indent_char_found && !_is_whitespace(c)) {
@@ -2991,11 +2947,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
} break;
case KEY_TAB: {
- if (k->get_command())
+ if (k->get_command()) {
break; // Avoid tab when command.
+ }
- if (readonly)
+ if (readonly) {
break;
+ }
if (is_selection_active()) {
if (k->get_shift()) {
@@ -3005,7 +2963,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
} else {
if (k->get_shift()) {
-
// Simple unindent.
int cc = cursor.column;
const String &line = text[cursor.line];
@@ -3013,23 +2970,26 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int left = _find_first_non_whitespace_column_of_line(line);
cc = MIN(cc, left);
- while (cc < indent_size && cc < left && line[cc] == ' ')
+ while (cc < indent_size && cc < left && line[cc] == ' ') {
cc++;
+ }
if (cc > 0 && cc <= text[cursor.line].length()) {
if (text[cursor.line][cc - 1] == '\t') {
// Tabs unindentation.
_remove_text(cursor.line, cc - 1, cursor.line, cc);
- if (cursor.column >= left)
+ if (cursor.column >= left) {
cursor_set_column(MAX(0, cursor.column - 1));
+ }
update();
} else {
// Spaces unindentation.
int spaces_to_remove = _calculate_spaces_till_next_left_indent(cc);
if (spaces_to_remove > 0) {
_remove_text(cursor.line, cc - spaces_to_remove, cursor.line, cc);
- if (cursor.column > left - spaces_to_remove) // Inside text?
+ if (cursor.column > left - spaces_to_remove) { // Inside text?
cursor_set_column(MAX(0, cursor.column - spaces_to_remove));
+ }
update();
}
}
@@ -3043,8 +3003,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// Insert only as much spaces as needed till next indentation level.
int spaces_to_add = _calculate_spaces_till_next_right_indent(cursor.column);
String indent_to_insert = String();
- for (int i = 0; i < spaces_to_add; i++)
+ for (int i = 0; i < spaces_to_add; i++) {
indent_to_insert = ' ' + indent_to_insert;
+ }
_insert_text_at_cursor(indent_to_insert);
} else {
_insert_text_at_cursor("\t");
@@ -3054,8 +3015,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_BACKSPACE: {
- if (readonly)
+ if (readonly) {
break;
+ }
#ifdef APPLE_STYLE_KEYS
if (k->get_alt() && cursor.column > 1) {
@@ -3110,8 +3072,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
_remove_text(cursor.line, 0, cursor.line, cursor_current_column);
#endif
} else {
- if (cursor.line > 0 && is_line_hidden(cursor.line - 1))
+ if (cursor.line > 0 && is_line_hidden(cursor.line - 1)) {
unfold_line(cursor.line - 1);
+ }
backspace_at_cursor();
}
@@ -3124,15 +3087,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
[[fallthrough]];
}
case KEY_LEFT: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
_pre_shift_selection();
#ifdef APPLE_STYLE_KEYS
- else
+ } else {
#else
- else if (!k->get_alt())
+ } else if (!k->get_alt()) {
#endif
deselect();
+ }
#ifdef APPLE_STYLE_KEYS
if (k->get_command()) {
@@ -3169,8 +3132,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
while (cc > 0) {
bool ischar = _is_text_char(text[cursor.line][cc - 1]);
- if (prev_char && !ischar)
+ if (prev_char && !ischar) {
break;
+ }
prev_char = ischar;
cc--;
@@ -3179,7 +3143,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
} else if (cursor.column == 0) {
-
if (cursor.line > 0) {
cursor_set_line(cursor.line - num_lines_from(CLAMP(cursor.line - 1, 0, text.size() - 1), -1));
cursor_set_column(text[cursor.line].length());
@@ -3188,8 +3151,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
cursor_set_column(cursor_get_column() - 1);
}
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
+ }
} break;
case KEY_KP_6: {
@@ -3200,15 +3164,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
[[fallthrough]];
}
case KEY_RIGHT: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
_pre_shift_selection();
#ifdef APPLE_STYLE_KEYS
- else
+ } else {
#else
- else if (!k->get_alt())
+ } else if (!k->get_alt()) {
#endif
deselect();
+ }
#ifdef APPLE_STYLE_KEYS
if (k->get_command()) {
@@ -3231,8 +3195,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
while (cc < text[cursor.line].length()) {
bool ischar = _is_text_char(text[cursor.line][cc]);
- if (prev_char && !ischar)
+ if (prev_char && !ischar) {
break;
+ }
prev_char = ischar;
cc++;
}
@@ -3240,7 +3205,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
} else if (cursor.column == text[cursor.line].length()) {
-
if (cursor.line < text.size() - 1) {
cursor_set_line(cursor_get_line() + num_lines_from(CLAMP(cursor.line + 1, 0, text.size() - 1), 1), true, false);
cursor_set_column(0);
@@ -3249,8 +3213,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
cursor_set_column(cursor_get_column() + 1);
}
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
+ }
} break;
case KEY_KP_8: {
@@ -3261,7 +3226,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
[[fallthrough]];
}
case KEY_UP: {
-
if (k->get_alt()) {
keycode_handled = false;
break;
@@ -3281,7 +3245,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#ifdef APPLE_STYLE_KEYS
if (k->get_command()) {
-
cursor_set_line(0);
} else
#endif
@@ -3301,8 +3264,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
+ }
_cancel_code_hint();
} break;
@@ -3314,7 +3278,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
[[fallthrough]];
}
case KEY_DOWN: {
-
if (k->get_alt()) {
keycode_handled = false;
break;
@@ -3349,15 +3312,16 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
+ }
_cancel_code_hint();
} break;
case KEY_DELETE: {
-
- if (readonly)
+ if (readonly) {
break;
+ }
if (k->get_shift() && !k->get_command() && !k->get_alt() && is_shortcut_keys_enabled()) {
cut();
@@ -3366,8 +3330,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int curline_len = text[cursor.line].length();
- if (cursor.line == text.size() - 1 && cursor.column == curline_len)
+ if (cursor.line == text.size() - 1 && cursor.column == curline_len) {
break; // Nothing to do.
+ }
int next_line = cursor.column < curline_len ? cursor.line : cursor.line + 1;
int next_column;
@@ -3448,14 +3413,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
else if (k->get_command() || k->get_control())
deselect();
#else
- if (k->get_shift())
+ if (k->get_shift()) {
_pre_shift_selection();
+ }
if (k->get_command()) {
cursor_set_line(0);
cursor_set_column(0);
} else {
-
// Move cursor column to start of wrapped row and then to start of text.
Vector<String> rows = get_wrap_rows_text(cursor.line);
int wi = get_cursor_wrap_index();
@@ -3468,24 +3433,27 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int current_line_whitespace_len = 0;
while (current_line_whitespace_len < text[cursor.line].length()) {
CharType c = text[cursor.line][current_line_whitespace_len];
- if (c != '\t' && c != ' ')
+ if (c != '\t' && c != ' ') {
break;
+ }
current_line_whitespace_len++;
}
- if (cursor_get_column() == current_line_whitespace_len)
+ if (cursor_get_column() == current_line_whitespace_len) {
cursor_set_column(0);
- else
+ } else {
cursor_set_column(current_line_whitespace_len);
+ }
} else {
cursor_set_column(row_start_col);
}
}
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
- else if (k->get_command() || k->get_control())
+ } else if (k->get_command() || k->get_control()) {
deselect();
+ }
_cancel_completion();
completion_hint = "";
#endif
@@ -3509,11 +3477,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
else if (k->get_command() || k->get_control())
deselect();
#else
- if (k->get_shift())
+ if (k->get_shift()) {
_pre_shift_selection();
+ }
- if (k->get_command())
+ if (k->get_command()) {
cursor_set_line(get_last_unhidden_line(), true, false, 9999);
+ }
// Move cursor column to end of wrapped row and then to end of text.
Vector<String> rows = get_wrap_rows_text(cursor.line);
@@ -3528,10 +3498,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
cursor_set_column(row_end_col);
}
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
- else if (k->get_command() || k->get_control())
+ } else if (k->get_command() || k->get_control()) {
deselect();
+ }
_cancel_completion();
completion_hint = "";
@@ -3545,16 +3516,17 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
[[fallthrough]];
}
case KEY_PAGEUP: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
_pre_shift_selection();
+ }
int wi;
int n_line = cursor.line - num_lines_from_rows(cursor.line, get_cursor_wrap_index(), -get_visible_rows(), wi) + 1;
cursor_set_line(n_line, true, false, wi);
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
+ }
_cancel_completion();
completion_hint = "";
@@ -3568,23 +3540,23 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
[[fallthrough]];
}
case KEY_PAGEDOWN: {
-
- if (k->get_shift())
+ if (k->get_shift()) {
_pre_shift_selection();
+ }
int wi;
int n_line = cursor.line + num_lines_from_rows(cursor.line, get_cursor_wrap_index(), get_visible_rows(), wi) - 1;
cursor_set_line(n_line, true, false, wi);
- if (k->get_shift())
+ if (k->get_shift()) {
_post_shift_selection();
+ }
_cancel_completion();
completion_hint = "";
} break;
case KEY_A: {
-
#ifndef APPLE_STYLE_KEYS
if (!k->get_control() || k->get_shift() || k->get_alt()) {
keycode_handled = false;
@@ -3624,7 +3596,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
} break;
case KEY_E: {
-
if (!k->get_control() || k->get_command() || k->get_alt()) {
keycode_handled = false;
break;
@@ -3660,7 +3631,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_C: {
-
if (!k->get_command() || k->get_shift() || k->get_alt()) {
keycode_handled = false;
break;
@@ -3672,7 +3642,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
case KEY_Z: {
-
if (readonly) {
break;
}
@@ -3683,14 +3652,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
if (is_shortcut_keys_enabled()) {
- if (k->get_shift())
+ if (k->get_shift()) {
redo();
- else
+ } else {
undo();
+ }
}
} break;
case KEY_Y: {
-
if (readonly) {
break;
}
@@ -3744,13 +3713,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} break;
default: {
-
keycode_handled = false;
} break;
}
- if (keycode_handled)
+ if (keycode_handled) {
accept_event();
+ }
if (k->get_keycode() == KEY_INSERT) {
set_insert_mode(!insert_mode);
@@ -3761,9 +3730,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (!keycode_handled && !k->get_command()) { // For German keyboards.
if (k->get_unicode() >= 32) {
-
- if (readonly)
+ if (readonly) {
return;
+ }
// Remove the old character if in insert mode and no selection.
if (insert_mode && !had_selection) {
@@ -3802,7 +3771,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
void TextEdit::_scroll_up(real_t p_delta) {
-
if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(-p_delta)) {
scrolling = false;
minimap_clicked = false;
@@ -3830,7 +3798,6 @@ void TextEdit::_scroll_up(real_t p_delta) {
}
void TextEdit::_scroll_down(real_t p_delta) {
-
if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(p_delta)) {
scrolling = false;
minimap_clicked = false;
@@ -3859,9 +3826,7 @@ void TextEdit::_scroll_down(real_t p_delta) {
}
void TextEdit::_pre_shift_selection() {
-
if (!selection.active || selection.selecting_mode == Selection::MODE_NONE) {
-
selection.selecting_line = cursor.line;
selection.selecting_column = cursor.column;
selection.active = true;
@@ -3871,9 +3836,7 @@ void TextEdit::_pre_shift_selection() {
}
void TextEdit::_post_shift_selection() {
-
if (selection.active && selection.selecting_mode == Selection::MODE_SHIFT) {
-
select(selection.selecting_line, selection.selecting_column, cursor.line, cursor.column);
update();
}
@@ -3924,7 +3887,6 @@ void TextEdit::_scroll_lines_down() {
/**** TEXT EDIT CORE API ****/
void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, int &r_end_line, int &r_end_column) {
-
// Save for undo.
ERR_FAIL_INDEX(p_line, text.size());
ERR_FAIL_COND(p_char < 0);
@@ -3942,16 +3904,17 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i
int lines = substrings.size() - 1;
for (; i < text.size(); i++) {
if (text.is_breakpoint(i)) {
- if ((i - lines < p_line || !text.is_breakpoint(i - lines)) || (i - lines == p_line && !shift_first_line))
+ if ((i - lines < p_line || !text.is_breakpoint(i - lines)) || (i - lines == p_line && !shift_first_line)) {
emit_signal("breakpoint_toggled", i);
- if (i + lines >= text.size() || !text.is_breakpoint(i + lines))
+ }
+ if (i + lines >= text.size() || !text.is_breakpoint(i + lines)) {
emit_signal("breakpoint_toggled", i + lines);
+ }
}
}
/* STEP 3: Add spaces if the char is greater than the end of the line. */
while (p_char > text[p_line].length()) {
-
text.set(p_line, text[p_line] + String::chr(' '));
}
@@ -3964,15 +3927,12 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i
// Insert the substrings.
if (j == 0) {
-
text.set(p_line, preinsert_text + substrings[j]);
} else {
-
text.insert(p_line + j, substrings[j]);
}
if (j == substrings.size() - 1) {
-
text.set(p_line + j, text[p_line + j] + postinsert_text);
}
}
@@ -3995,15 +3955,15 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i
r_end_column = text[r_end_line].length() - postinsert_text.length();
if (!text_changed_dirty && !setting_text) {
- if (is_inside_tree())
+ if (is_inside_tree()) {
MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
+ }
text_changed_dirty = true;
}
_line_edited_from(p_line);
}
String TextEdit::_base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const {
-
ERR_FAIL_INDEX_V(p_from_line, text.size(), String());
ERR_FAIL_INDEX_V(p_from_column, text[p_from_line].length() + 1, String());
ERR_FAIL_INDEX_V(p_to_line, text.size(), String());
@@ -4014,12 +3974,12 @@ String TextEdit::_base_get_text(int p_from_line, int p_from_column, int p_to_lin
String ret;
for (int i = p_from_line; i <= p_to_line; i++) {
-
int begin = (i == p_from_line) ? p_from_column : 0;
int end = (i == p_to_line) ? p_to_column : text[i].length();
- if (i > p_from_line)
+ if (i > p_from_line) {
ret += "\n";
+ }
ret += text[i].substr(begin, end - begin);
}
@@ -4027,7 +3987,6 @@ String TextEdit::_base_get_text(int p_from_line, int p_from_column, int p_to_lin
}
void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
-
ERR_FAIL_INDEX(p_from_line, text.size());
ERR_FAIL_INDEX(p_from_column, text[p_from_line].length() + 1);
ERR_FAIL_INDEX(p_to_line, text.size());
@@ -4042,10 +4001,12 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li
for (int i = p_from_line + 1; i < text.size(); i++) {
if (text.is_breakpoint(i)) {
- if (i + lines >= text.size() || !text.is_breakpoint(i + lines))
+ if (i + lines >= text.size() || !text.is_breakpoint(i + lines)) {
emit_signal("breakpoint_toggled", i);
- if (i > p_to_line && (i - lines < 0 || !text.is_breakpoint(i - lines)))
+ }
+ if (i > p_to_line && (i - lines < 0 || !text.is_breakpoint(i - lines))) {
emit_signal("breakpoint_toggled", i - lines);
+ }
}
}
@@ -4057,17 +4018,18 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li
text.set_line_wrap_amount(p_from_line, -1);
if (!text_changed_dirty && !setting_text) {
- if (is_inside_tree())
+ if (is_inside_tree()) {
MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
+ }
text_changed_dirty = true;
}
_line_edited_from(p_from_line);
}
void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r_end_line, int *r_end_char) {
-
- if (!setting_text && idle_detect->is_inside_tree())
+ if (!setting_text && idle_detect->is_inside_tree()) {
idle_detect->start();
+ }
if (undo_enabled) {
_clear_redo();
@@ -4075,13 +4037,16 @@ void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r
int retline, retchar;
_base_insert_text(p_line, p_char, p_text, retline, retchar);
- if (r_end_line)
+ if (r_end_line) {
*r_end_line = retline;
- if (r_end_char)
+ }
+ if (r_end_char) {
*r_end_char = retchar;
+ }
- if (!undo_enabled)
+ if (!undo_enabled) {
return;
+ }
/* UNDO!! */
TextOperation op;
@@ -4119,9 +4084,9 @@ void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r
}
void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
-
- if (!setting_text && idle_detect->is_inside_tree())
+ if (!setting_text && idle_detect->is_inside_tree()) {
idle_detect->start();
+ }
String text;
if (undo_enabled) {
@@ -4131,8 +4096,9 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i
_base_remove_text(p_from_line, p_from_column, p_to_line, p_to_column);
- if (!undo_enabled)
+ if (!undo_enabled) {
return;
+ }
/* UNDO! */
TextOperation op;
@@ -4168,7 +4134,6 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, i
}
void TextEdit::_insert_text_at_cursor(const String &p_text) {
-
int new_column, new_line;
_insert_text(cursor.line, cursor.column, p_text, &new_line, &new_column);
_update_scrollbars();
@@ -4195,13 +4160,12 @@ void TextEdit::_line_edited_from(int p_line) {
}
int TextEdit::get_char_count() {
-
int totalsize = 0;
for (int i = 0; i < text.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
totalsize++; // Include \n.
+ }
totalsize += text[i].length();
}
@@ -4209,7 +4173,6 @@ int TextEdit::get_char_count() {
}
Size2 TextEdit::get_minimum_size() const {
-
return cache.style_normal->get_minimum_size();
}
@@ -4225,14 +4188,17 @@ int TextEdit::_get_control_height() const {
void TextEdit::_generate_context_menu() {
// Reorganize context menu.
menu->clear();
- if (!readonly)
+ if (!readonly) {
menu->add_item(RTR("Cut"), MENU_CUT, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_X : 0);
+ }
menu->add_item(RTR("Copy"), MENU_COPY, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_C : 0);
- if (!readonly)
+ if (!readonly) {
menu->add_item(RTR("Paste"), MENU_PASTE, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_V : 0);
+ }
menu->add_separator();
- if (is_selecting_enabled())
+ if (is_selecting_enabled()) {
menu->add_item(RTR("Select All"), MENU_SELECT_ALL, is_shortcut_keys_enabled() ? KEY_MASK_CMD | KEY_A : 0);
+ }
if (!readonly) {
menu->add_item(RTR("Clear"), MENU_CLEAR);
menu->add_separator();
@@ -4250,11 +4216,11 @@ int TextEdit::_get_minimap_visible_rows() const {
}
int TextEdit::get_total_visible_rows() const {
-
// Returns the total amount of rows we need in the editor.
// This skips hidden lines and counts each wrapping of a line.
- if (!is_hiding_enabled() && !is_wrap_enabled())
+ if (!is_hiding_enabled() && !is_wrap_enabled()) {
return text.size();
+ }
int total_rows = 0;
for (int i = 0; i < text.size(); i++) {
@@ -4267,22 +4233,21 @@ int TextEdit::get_total_visible_rows() const {
}
void TextEdit::_update_wrap_at() {
-
wrap_at = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width - wrap_right_offset;
update_cursor_wrap_offset();
text.clear_wrap_cache();
for (int i = 0; i < text.size(); i++) {
// Update all values that wrap.
- if (!line_wraps(i))
+ if (!line_wraps(i)) {
continue;
+ }
Vector<String> rows = get_wrap_rows_text(i);
text.set_line_wrap_amount(i, rows.size() - 1);
}
}
void TextEdit::adjust_viewport_to_cursor() {
-
// Make sure cursor is visible on the screen.
scrolling = false;
minimap_clicked = false;
@@ -4304,19 +4269,22 @@ void TextEdit::adjust_viewport_to_cursor() {
}
int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width;
- if (v_scroll->is_visible_in_tree())
+ if (v_scroll->is_visible_in_tree()) {
visible_width -= v_scroll->get_combined_minimum_size().width;
+ }
visible_width -= 20; // Give it a little more space.
if (!is_wrap_enabled()) {
// Adjust x offset.
int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]);
- if (cursor_x > (cursor.x_ofs + visible_width))
+ if (cursor_x > (cursor.x_ofs + visible_width)) {
cursor.x_ofs = cursor_x - visible_width + 1;
+ }
- if (cursor_x < cursor.x_ofs)
+ if (cursor_x < cursor.x_ofs) {
cursor.x_ofs = cursor_x;
+ }
} else {
cursor.x_ofs = 0;
}
@@ -4326,29 +4294,32 @@ void TextEdit::adjust_viewport_to_cursor() {
}
void TextEdit::center_viewport_to_cursor() {
-
// Move viewport so the cursor is in the center of the screen.
scrolling = false;
minimap_clicked = false;
- if (is_line_hidden(cursor.line))
+ if (is_line_hidden(cursor.line)) {
unfold_line(cursor.line);
+ }
set_line_as_center_visible(cursor.line, get_cursor_wrap_index());
int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width;
- if (v_scroll->is_visible_in_tree())
+ if (v_scroll->is_visible_in_tree()) {
visible_width -= v_scroll->get_combined_minimum_size().width;
+ }
visible_width -= 20; // Give it a little more space.
if (is_wrap_enabled()) {
// Center x offset.
int cursor_x = get_column_x_offset_for_line(cursor.column, cursor.line);
- if (cursor_x > (cursor.x_ofs + visible_width))
+ if (cursor_x > (cursor.x_ofs + visible_width)) {
cursor.x_ofs = cursor_x - visible_width + 1;
+ }
- if (cursor_x < cursor.x_ofs)
+ if (cursor_x < cursor.x_ofs) {
cursor.x_ofs = cursor_x;
+ }
} else {
cursor.x_ofs = 0;
}
@@ -4368,18 +4339,18 @@ void TextEdit::update_cursor_wrap_offset() {
}
bool TextEdit::line_wraps(int line) const {
-
ERR_FAIL_INDEX_V(line, text.size(), 0);
- if (!is_wrap_enabled())
+ if (!is_wrap_enabled()) {
return false;
+ }
return text.get_line_width(line) > wrap_at;
}
int TextEdit::times_line_wraps(int line) const {
-
ERR_FAIL_INDEX_V(line, text.size(), 0);
- if (!line_wraps(line))
+ if (!line_wraps(line)) {
return 0;
+ }
int wrap_amount = text.get_line_wrap_amount(line);
if (wrap_amount == -1) {
@@ -4393,7 +4364,6 @@ int TextEdit::times_line_wraps(int line) const {
}
Vector<String> TextEdit::get_wrap_rows_text(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), Vector<String>());
Vector<String> lines;
@@ -4466,16 +4436,15 @@ Vector<String> TextEdit::get_wrap_rows_text(int p_line) const {
}
int TextEdit::get_cursor_wrap_index() const {
-
return get_line_wrap_index_at_col(cursor.line, cursor.column);
}
int TextEdit::get_line_wrap_index_at_col(int p_line, int p_column) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
- if (!line_wraps(p_line))
+ if (!line_wraps(p_line)) {
return 0;
+ }
// Loop through wraps in the line text until we get to the column.
int wrap_index = 0;
@@ -4485,43 +4454,50 @@ int TextEdit::get_line_wrap_index_at_col(int p_line, int p_column) const {
wrap_index = i;
String s = rows[wrap_index];
col += s.length();
- if (col > p_column)
+ if (col > p_column) {
break;
+ }
}
return wrap_index;
}
void TextEdit::cursor_set_column(int p_col, bool p_adjust_viewport) {
- if (p_col < 0)
+ if (p_col < 0) {
p_col = 0;
+ }
cursor.column = p_col;
- if (cursor.column > get_line(cursor.line).length())
+ if (cursor.column > get_line(cursor.line).length()) {
cursor.column = get_line(cursor.line).length();
+ }
cursor.last_fit_x = get_column_x_offset_for_line(cursor.column, cursor.line);
- if (p_adjust_viewport)
+ if (p_adjust_viewport) {
adjust_viewport_to_cursor();
+ }
if (!cursor_changed_dirty) {
- if (is_inside_tree())
+ if (is_inside_tree()) {
MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
+ }
cursor_changed_dirty = true;
}
}
void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport, bool p_can_be_hidden, int p_wrap_index) {
-
- if (setting_row)
+ if (setting_row) {
return;
+ }
setting_row = true;
- if (p_row < 0)
+ if (p_row < 0) {
p_row = 0;
+ }
- if (p_row >= text.size())
+ if (p_row >= text.size()) {
p_row = text.size() - 1;
+ }
if (!p_can_be_hidden) {
if (is_line_hidden(CLAMP(p_row, 0, text.size() - 1))) {
@@ -4547,30 +4523,31 @@ void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport, bool p_can_be_
for (int i = 0; i < p_wrap_index + 1; i++) {
row_end_col += rows[i].length();
}
- if (n_col >= row_end_col)
+ if (n_col >= row_end_col) {
n_col -= 1;
+ }
}
cursor.column = n_col;
- if (p_adjust_viewport)
+ if (p_adjust_viewport) {
adjust_viewport_to_cursor();
+ }
setting_row = false;
if (!cursor_changed_dirty) {
- if (is_inside_tree())
+ if (is_inside_tree()) {
MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
+ }
cursor_changed_dirty = true;
}
}
int TextEdit::cursor_get_column() const {
-
return cursor.column;
}
int TextEdit::cursor_get_line() const {
-
return cursor.line;
}
@@ -4624,14 +4601,14 @@ void TextEdit::_v_scroll_input() {
}
void TextEdit::_scroll_moved(double p_to_val) {
-
- if (updating_scrolls)
+ if (updating_scrolls) {
return;
+ }
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
cursor.x_ofs = h_scroll->get_value();
+ }
if (v_scroll->is_visible_in_tree()) {
-
// Set line ofs and wrap ofs.
int v_scroll_i = floor(get_v_scroll());
int sc = 0;
@@ -4640,8 +4617,9 @@ void TextEdit::_scroll_moved(double p_to_val) {
if (!is_line_hidden(n_line)) {
sc++;
sc += times_line_wraps(n_line);
- if (sc > v_scroll_i)
+ if (sc > v_scroll_i) {
break;
+ }
}
}
n_line = MIN(n_line, text.size() - 1);
@@ -4656,27 +4634,26 @@ void TextEdit::_scroll_moved(double p_to_val) {
}
int TextEdit::get_row_height() const {
-
return cache.font->get_height() + cache.line_spacing;
}
int TextEdit::get_char_pos_for_line(int p_px, int p_line, int p_wrap_index) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
if (line_wraps(p_line)) {
-
int line_wrap_amount = times_line_wraps(p_line);
int wrap_offset_px = get_indent_level(p_line) * cache.font->get_char_size(' ').width;
if (wrap_offset_px >= wrap_at) {
wrap_offset_px = 0;
}
- if (p_wrap_index > line_wrap_amount)
+ if (p_wrap_index > line_wrap_amount) {
p_wrap_index = line_wrap_amount;
- if (p_wrap_index > 0)
+ }
+ if (p_wrap_index > 0) {
p_px -= wrap_offset_px;
- else
+ } else {
p_wrap_index = 0;
+ }
Vector<String> rows = get_wrap_rows_text(p_line);
int c_pos = get_char_pos_for(p_px, rows[p_wrap_index]);
for (int i = 0; i < p_wrap_index; i++) {
@@ -4686,17 +4663,14 @@ int TextEdit::get_char_pos_for_line(int p_px, int p_line, int p_wrap_index) cons
return c_pos;
} else {
-
return get_char_pos_for(p_px, text[p_line]);
}
}
int TextEdit::get_column_x_offset_for_line(int p_char, int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
if (line_wraps(p_line)) {
-
int n_char = p_char;
int col = 0;
Vector<String> rows = get_wrap_rows_text(p_line);
@@ -4705,8 +4679,9 @@ int TextEdit::get_column_x_offset_for_line(int p_char, int p_line) const {
wrap_index = i;
String s = rows[wrap_index];
col += s.length();
- if (col > p_char)
+ if (col > p_char) {
break;
+ }
n_char -= s.length();
}
int px = get_column_x_offset(n_char, rows[wrap_index]);
@@ -4715,27 +4690,26 @@ int TextEdit::get_column_x_offset_for_line(int p_char, int p_line) const {
if (wrap_offset_px >= wrap_at) {
wrap_offset_px = 0;
}
- if (wrap_index != 0)
+ if (wrap_index != 0) {
px += wrap_offset_px;
+ }
return px;
} else {
-
return get_column_x_offset(p_char, text[p_line]);
}
}
int TextEdit::get_char_pos_for(int p_px, String p_str) const {
-
int px = 0;
int c = 0;
while (c < p_str.length()) {
-
int w = text.get_char_width(p_str[c], p_str[c + 1], px);
- if (p_px < (px + w / 2))
+ if (p_px < (px + w / 2)) {
break;
+ }
px += w;
c++;
}
@@ -4744,13 +4718,12 @@ int TextEdit::get_char_pos_for(int p_px, String p_str) const {
}
int TextEdit::get_column_x_offset(int p_char, String p_str) const {
-
int px = 0;
for (int i = 0; i < p_char; i++) {
-
- if (i >= p_str.length())
+ if (i >= p_str.length()) {
break;
+ }
px += text.get_char_width(p_str[i], p_str[i + 1], px);
}
@@ -4759,9 +4732,7 @@ int TextEdit::get_column_x_offset(int p_char, String p_str) const {
}
void TextEdit::insert_text_at_cursor(const String &p_text) {
-
if (selection.active) {
-
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
@@ -4775,15 +4746,15 @@ void TextEdit::insert_text_at_cursor(const String &p_text) {
}
Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
- if (highlighted_word != String())
+ if (highlighted_word != String()) {
return CURSOR_POINTING_HAND;
+ }
int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
if ((completion_active && completion_rect.has_point(p_pos))) {
return CURSOR_ARROW;
}
if (p_pos.x < gutter) {
-
int row, col;
_get_mouse_pos(p_pos, row, col);
int left_margin = cache.style_normal->get_margin(MARGIN_LEFT);
@@ -4804,10 +4775,11 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
// Fold icon.
if (draw_fold_gutter && p_pos.x > gutter_left + cache.line_number_w - 6 && p_pos.x <= gutter_left + cache.line_number_w + cache.fold_gutter_width - 3) {
- if (is_folded(row) || can_fold(row))
+ if (is_folded(row) || can_fold(row)) {
return CURSOR_POINTING_HAND;
- else
+ } else {
return CURSOR_ARROW;
+ }
}
return CURSOR_ARROW;
@@ -4833,7 +4805,6 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
}
void TextEdit::set_text(String p_text) {
-
setting_text = true;
if (!undo_enabled) {
_clear();
@@ -4862,72 +4833,67 @@ String TextEdit::get_text() {
String longthing;
int len = text.size();
for (int i = 0; i < len; i++) {
-
longthing += text[i];
- if (i != len - 1)
+ if (i != len - 1) {
longthing += "\n";
+ }
}
return longthing;
};
String TextEdit::get_text_for_lookup_completion() {
-
int row, col;
_get_mouse_pos(get_local_mouse_position(), row, col);
String longthing;
int len = text.size();
for (int i = 0; i < len; i++) {
-
if (i == row) {
longthing += text[i].substr(0, col);
longthing += String::chr(0xFFFF); // Not unicode, represents the cursor.
longthing += text[i].substr(col, text[i].size());
} else {
-
longthing += text[i];
}
- if (i != len - 1)
+ if (i != len - 1) {
longthing += "\n";
+ }
}
return longthing;
}
String TextEdit::get_text_for_completion() {
-
String longthing;
int len = text.size();
for (int i = 0; i < len; i++) {
-
if (i == cursor.line) {
longthing += text[i].substr(0, cursor.column);
longthing += String::chr(0xFFFF); // Not unicode, represents the cursor.
longthing += text[i].substr(cursor.column, text[i].size());
} else {
-
longthing += text[i];
}
- if (i != len - 1)
+ if (i != len - 1) {
longthing += "\n";
+ }
}
return longthing;
};
String TextEdit::get_line(int line) const {
-
- if (line < 0 || line >= text.size())
+ if (line < 0 || line >= text.size()) {
return "";
+ }
return text[line];
};
void TextEdit::_clear() {
-
clear_undo_history();
text.clear();
cursor.column = 0;
@@ -4940,16 +4906,15 @@ void TextEdit::_clear() {
}
void TextEdit::clear() {
-
setting_text = true;
_clear();
setting_text = false;
};
void TextEdit::set_readonly(bool p_readonly) {
-
- if (readonly == p_readonly)
+ if (readonly == p_readonly) {
return;
+ }
readonly = p_readonly;
_generate_context_menu();
@@ -4984,27 +4949,22 @@ void TextEdit::set_readonly(bool p_readonly) {
}
bool TextEdit::is_readonly() const {
-
return readonly;
}
void TextEdit::set_wrap_enabled(bool p_wrap_enabled) {
-
wrap_enabled = p_wrap_enabled;
}
bool TextEdit::is_wrap_enabled() const {
-
return wrap_enabled;
}
void TextEdit::set_max_chars(int p_max_chars) {
-
max_chars = p_max_chars;
}
int TextEdit::get_max_chars() const {
-
return max_chars;
}
@@ -5027,7 +4987,6 @@ void TextEdit::_toggle_draw_caret() {
}
void TextEdit::_update_caches() {
-
cache.style_normal = get_theme_stylebox("normal");
cache.style_focus = get_theme_stylebox("focus");
cache.style_readonly = get_theme_stylebox("read_only");
@@ -5095,7 +5054,6 @@ void TextEdit::_set_syntax_highlighting(SyntaxHighlighter *p_syntax_highlighter)
}
int TextEdit::_is_line_in_region(int p_line) {
-
// Do we have in cache?
if (color_region_cache.has(p_line)) {
return color_region_cache[p_line];
@@ -5153,7 +5111,6 @@ Map<int, TextEdit::Text::ColorRegionInfo> TextEdit::_get_line_color_region_info(
}
void TextEdit::clear_colors() {
-
keywords.clear();
member_keywords.clear();
color_regions.clear();
@@ -5164,7 +5121,6 @@ void TextEdit::clear_colors() {
}
void TextEdit::add_keyword_color(const String &p_keyword, const Color &p_color) {
-
keywords[p_keyword] = p_color;
syntax_highlighting_cache.clear();
update();
@@ -5175,13 +5131,11 @@ bool TextEdit::has_keyword_color(String p_keyword) const {
}
Color TextEdit::get_keyword_color(String p_keyword) const {
-
ERR_FAIL_COND_V(!keywords.has(p_keyword), Color());
return keywords[p_keyword];
}
void TextEdit::add_color_region(const String &p_begin_key, const String &p_end_key, const Color &p_color, bool p_line_only) {
-
color_regions.push_back(ColorRegion(p_begin_key, p_end_key, p_color, p_line_only));
syntax_highlighting_cache.clear();
text.clear_width_cache();
@@ -5209,13 +5163,11 @@ void TextEdit::clear_member_keywords() {
}
void TextEdit::set_syntax_coloring(bool p_enabled) {
-
syntax_coloring = p_enabled;
update();
}
bool TextEdit::is_syntax_coloring_enabled() const {
-
return syntax_coloring;
}
@@ -5224,9 +5176,7 @@ void TextEdit::set_auto_indent(bool p_auto_indent) {
}
void TextEdit::cut() {
-
if (!selection.active) {
-
String clipboard = text[cursor.line];
DisplayServer::get_singleton()->clipboard_set(clipboard);
cursor_set_line(cursor.line);
@@ -5244,7 +5194,6 @@ void TextEdit::cut() {
cut_copy_line = clipboard;
} else {
-
String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
DisplayServer::get_singleton()->clipboard_set(clipboard);
@@ -5260,11 +5209,8 @@ void TextEdit::cut() {
}
void TextEdit::copy() {
-
if (!selection.active) {
-
if (text[cursor.line].length() != 0) {
-
String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
DisplayServer::get_singleton()->clipboard_set(clipboard);
cut_copy_line = clipboard;
@@ -5277,12 +5223,10 @@ void TextEdit::copy() {
}
void TextEdit::paste() {
-
String clipboard = DisplayServer::get_singleton()->clipboard_get();
begin_complex_operation();
if (selection.active) {
-
selection.active = false;
selection.selecting_mode = Selection::MODE_NONE;
_remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
@@ -5290,7 +5234,6 @@ void TextEdit::paste() {
cursor_set_column(selection.from_column);
} else if (!cut_copy_line.empty() && cut_copy_line == clipboard) {
-
cursor_set_column(0);
String ins = "\n";
clipboard += ins;
@@ -5303,11 +5246,13 @@ void TextEdit::paste() {
}
void TextEdit::select_all() {
- if (!selecting_enabled)
+ if (!selecting_enabled) {
return;
+ }
- if (text.size() == 1 && text[0].length() == 0)
+ if (text.size() == 1 && text[0].length() == 0) {
return;
+ }
selection.active = true;
selection.from_line = 0;
selection.from_column = 0;
@@ -5323,32 +5268,38 @@ void TextEdit::select_all() {
}
void TextEdit::deselect() {
-
selection.active = false;
update();
}
void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
- if (!selecting_enabled)
+ if (!selecting_enabled) {
return;
+ }
- if (p_from_line < 0)
+ if (p_from_line < 0) {
p_from_line = 0;
- else if (p_from_line >= text.size())
+ } else if (p_from_line >= text.size()) {
p_from_line = text.size() - 1;
- if (p_from_column >= text[p_from_line].length())
+ }
+ if (p_from_column >= text[p_from_line].length()) {
p_from_column = text[p_from_line].length();
- if (p_from_column < 0)
+ }
+ if (p_from_column < 0) {
p_from_column = 0;
+ }
- if (p_to_line < 0)
+ if (p_to_line < 0) {
p_to_line = 0;
- else if (p_to_line >= text.size())
+ } else if (p_to_line >= text.size()) {
p_to_line = text.size() - 1;
- if (p_to_column >= text[p_to_line].length())
+ }
+ if (p_to_column >= text[p_to_line].length()) {
p_to_column = text[p_to_line].length();
- if (p_to_column < 0)
+ }
+ if (p_to_column < 0) {
p_to_column = 0;
+ }
selection.from_line = p_from_line;
selection.from_column = p_from_column;
@@ -5358,89 +5309,86 @@ void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_t
selection.active = true;
if (selection.from_line == selection.to_line) {
-
if (selection.from_column == selection.to_column) {
-
selection.active = false;
} else if (selection.from_column > selection.to_column) {
-
selection.shiftclick_left = false;
SWAP(selection.from_column, selection.to_column);
} else {
-
selection.shiftclick_left = true;
}
} else if (selection.from_line > selection.to_line) {
-
selection.shiftclick_left = false;
SWAP(selection.from_line, selection.to_line);
SWAP(selection.from_column, selection.to_column);
} else {
-
selection.shiftclick_left = true;
}
update();
}
+
void TextEdit::swap_lines(int line1, int line2) {
String tmp = get_line(line1);
String tmp2 = get_line(line2);
set_line(line2, tmp);
set_line(line1, tmp2);
}
-bool TextEdit::is_selection_active() const {
+bool TextEdit::is_selection_active() const {
return selection.active;
}
-int TextEdit::get_selection_from_line() const {
+int TextEdit::get_selection_from_line() const {
ERR_FAIL_COND_V(!selection.active, -1);
return selection.from_line;
}
-int TextEdit::get_selection_from_column() const {
+int TextEdit::get_selection_from_column() const {
ERR_FAIL_COND_V(!selection.active, -1);
return selection.from_column;
}
-int TextEdit::get_selection_to_line() const {
+int TextEdit::get_selection_to_line() const {
ERR_FAIL_COND_V(!selection.active, -1);
return selection.to_line;
}
-int TextEdit::get_selection_to_column() const {
+int TextEdit::get_selection_to_column() const {
ERR_FAIL_COND_V(!selection.active, -1);
return selection.to_column;
}
String TextEdit::get_selection_text() const {
-
- if (!selection.active)
+ if (!selection.active) {
return "";
+ }
return _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
}
String TextEdit::get_word_under_cursor() const {
-
int prev_cc = cursor.column;
while (prev_cc > 0) {
bool is_char = _is_text_char(text[cursor.line][prev_cc - 1]);
- if (!is_char)
+ if (!is_char) {
break;
+ }
--prev_cc;
}
int next_cc = cursor.column;
while (next_cc < text[cursor.line].length()) {
bool is_char = _is_text_char(text[cursor.line][next_cc]);
- if (!is_char)
+ if (!is_char) {
break;
+ }
++next_cc;
}
- if (prev_cc == cursor.column || next_cc == cursor.column)
+ if (prev_cc == cursor.column || next_cc == cursor.column) {
return "";
+ }
return text[cursor.line].substr(prev_cc, next_cc - prev_cc);
}
@@ -5499,26 +5447,23 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
return col;
}
-Vector<int> TextEdit::_search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const {
-
+Dictionary TextEdit::_search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const {
int col, line;
if (search(p_key, p_search_flags, p_from_line, p_from_column, line, col)) {
- Vector<int> result;
- result.resize(2);
- result.set(SEARCH_RESULT_COLUMN, col);
- result.set(SEARCH_RESULT_LINE, line);
+ Dictionary result;
+ result["line"] = line;
+ result["column"] = col;
return result;
} else {
-
- return Vector<int>();
+ return Dictionary();
}
}
bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column, int &r_line, int &r_column) const {
-
- if (p_key.length() == 0)
+ if (p_key.length() == 0) {
return false;
+ }
ERR_FAIL_INDEX_V(p_from_line, text.size(), false);
ERR_FAIL_INDEX_V(p_from_column, text[p_from_line].length() + 1, false);
@@ -5528,7 +5473,6 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
int pos = -1;
for (int i = 0; i < text.size() + 1; i++) {
-
if (line < 0) {
line = text.size() - 1;
}
@@ -5539,7 +5483,6 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
String text_line = text[line];
int from_column = 0;
if (line == p_from_line) {
-
if (i == text.size()) {
// Wrapped.
@@ -5550,15 +5493,15 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
}
} else {
-
from_column = p_from_column;
}
} else {
- if (p_search_flags & SEARCH_BACKWARDS)
+ if (p_search_flags & SEARCH_BACKWARDS) {
from_column = text_line.length() - 1;
- else
+ } else {
from_column = 0;
+ }
}
pos = -1;
@@ -5567,7 +5510,6 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
int last_pos = -1;
while (true) {
-
if (p_search_flags & SEARCH_BACKWARDS) {
while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.rfind(p_key, pos_from) : text_line.rfindn(p_key, pos_from)) != -1) {
if (last_pos <= from_column) {
@@ -5593,10 +5535,11 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
if (pos != -1 && (p_search_flags & SEARCH_WHOLE_WORDS)) {
// Validate for whole words.
- if (pos > 0 && _is_text_char(text_line[pos - 1]))
+ if (pos > 0 && _is_text_char(text_line[pos - 1])) {
is_match = false;
- else if (pos + p_key.length() < text_line.length() && _is_text_char(text_line[pos + p_key.length()]))
+ } else if (pos + p_key.length() < text_line.length() && _is_text_char(text_line[pos + p_key.length()])) {
is_match = false;
+ }
}
if (pos_from == -1) {
@@ -5611,13 +5554,15 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
pos = -1;
}
- if (pos != -1)
+ if (pos != -1) {
break;
+ }
- if (p_search_flags & SEARCH_BACKWARDS)
+ if (p_search_flags & SEARCH_BACKWARDS) {
line--;
- else
+ } else {
line++;
+ }
}
if (pos == -1) {
@@ -5633,19 +5578,16 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
}
void TextEdit::_cursor_changed_emit() {
-
emit_signal("cursor_changed");
cursor_changed_dirty = false;
}
void TextEdit::_text_changed_emit() {
-
emit_signal("text_changed");
text_changed_dirty = false;
}
void TextEdit::set_line_as_marked(int p_line, bool p_marked) {
-
ERR_FAIL_INDEX(p_line, text.size());
text.set_marked(p_line, p_marked);
update();
@@ -5674,72 +5616,69 @@ void TextEdit::clear_executing_line() {
}
bool TextEdit::is_line_set_as_bookmark(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), false);
return text.is_bookmark(p_line);
}
void TextEdit::set_line_as_bookmark(int p_line, bool p_bookmark) {
-
ERR_FAIL_INDEX(p_line, text.size());
text.set_bookmark(p_line, p_bookmark);
update();
}
void TextEdit::get_bookmarks(List<int> *p_bookmarks) const {
-
for (int i = 0; i < text.size(); i++) {
- if (text.is_bookmark(i))
+ if (text.is_bookmark(i)) {
p_bookmarks->push_back(i);
+ }
}
}
Array TextEdit::get_bookmarks_array() const {
-
Array arr;
for (int i = 0; i < text.size(); i++) {
- if (text.is_bookmark(i))
+ if (text.is_bookmark(i)) {
arr.append(i);
+ }
}
return arr;
}
bool TextEdit::is_line_set_as_breakpoint(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), false);
return text.is_breakpoint(p_line);
}
void TextEdit::set_line_as_breakpoint(int p_line, bool p_breakpoint) {
-
ERR_FAIL_INDEX(p_line, text.size());
text.set_breakpoint(p_line, p_breakpoint);
update();
}
void TextEdit::get_breakpoints(List<int> *p_breakpoints) const {
-
for (int i = 0; i < text.size(); i++) {
- if (text.is_breakpoint(i))
+ if (text.is_breakpoint(i)) {
p_breakpoints->push_back(i);
+ }
}
}
Array TextEdit::get_breakpoints_array() const {
-
Array arr;
for (int i = 0; i < text.size(); i++) {
- if (text.is_breakpoint(i))
+ if (text.is_breakpoint(i)) {
arr.append(i);
+ }
}
return arr;
}
void TextEdit::remove_breakpoints() {
for (int i = 0; i < text.size(); i++) {
- if (text.is_breakpoint(i))
+ if (text.is_breakpoint(i)) {
/* Should "breakpoint_toggled" be fired when breakpoints are removed this way? */
text.set_breakpoint(i, false);
+ }
}
}
@@ -5755,21 +5694,19 @@ void TextEdit::clear_info_icons() {
}
void TextEdit::set_line_as_hidden(int p_line, bool p_hidden) {
-
ERR_FAIL_INDEX(p_line, text.size());
- if (is_hiding_enabled() || !p_hidden)
+ if (is_hiding_enabled() || !p_hidden) {
text.set_hidden(p_line, p_hidden);
+ }
update();
}
bool TextEdit::is_line_hidden(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), false);
return text.is_hidden(p_line);
}
void TextEdit::fold_all_lines() {
-
for (int i = 0; i < text.size(); i++) {
fold_line(i);
}
@@ -5778,7 +5715,6 @@ void TextEdit::fold_all_lines() {
}
void TextEdit::unhide_all_lines() {
-
for (int i = 0; i < text.size(); i++) {
text.set_hidden(i, false);
}
@@ -5787,12 +5723,12 @@ void TextEdit::unhide_all_lines() {
}
int TextEdit::num_lines_from(int p_line_from, int visible_amount) const {
-
// Returns the number of lines (hidden and unhidden) from p_line_from to (p_line_from + visible_amount of unhidden lines).
ERR_FAIL_INDEX_V(p_line_from, text.size(), ABS(visible_amount));
- if (!is_hiding_enabled())
+ if (!is_hiding_enabled()) {
return ABS(visible_amount);
+ }
int num_visible = 0;
int num_total = 0;
@@ -5802,8 +5738,9 @@ int TextEdit::num_lines_from(int p_line_from, int visible_amount) const {
if (!is_line_hidden(i)) {
num_visible++;
}
- if (num_visible >= visible_amount)
+ if (num_visible >= visible_amount) {
break;
+ }
}
} else {
visible_amount = ABS(visible_amount);
@@ -5812,22 +5749,23 @@ int TextEdit::num_lines_from(int p_line_from, int visible_amount) const {
if (!is_line_hidden(i)) {
num_visible++;
}
- if (num_visible >= visible_amount)
+ if (num_visible >= visible_amount) {
break;
+ }
}
}
return num_total;
}
int TextEdit::num_lines_from_rows(int p_line_from, int p_wrap_index_from, int visible_amount, int &wrap_index) const {
-
// Returns the number of lines (hidden and unhidden) from (p_line_from + p_wrap_index_from) row to (p_line_from + visible_amount of unhidden and wrapped rows).
// Wrap index is set to the wrap index of the last line.
wrap_index = 0;
ERR_FAIL_INDEX_V(p_line_from, text.size(), ABS(visible_amount));
- if (!is_hiding_enabled() && !is_wrap_enabled())
+ if (!is_hiding_enabled() && !is_wrap_enabled()) {
return ABS(visible_amount);
+ }
int num_visible = 0;
int num_total = 0;
@@ -5843,8 +5781,9 @@ int TextEdit::num_lines_from_rows(int p_line_from, int p_wrap_index_from, int vi
num_visible++;
num_visible += times_line_wraps(i);
}
- if (num_visible >= visible_amount)
+ if (num_visible >= visible_amount) {
break;
+ }
}
wrap_index = times_line_wraps(MIN(i, text.size() - 1)) - (num_visible - visible_amount);
} else {
@@ -5857,8 +5796,9 @@ int TextEdit::num_lines_from_rows(int p_line_from, int p_wrap_index_from, int vi
num_visible++;
num_visible += times_line_wraps(i);
}
- if (num_visible >= visible_amount)
+ if (num_visible >= visible_amount) {
break;
+ }
}
wrap_index = (num_visible - visible_amount);
}
@@ -5867,10 +5807,10 @@ int TextEdit::num_lines_from_rows(int p_line_from, int p_wrap_index_from, int vi
}
int TextEdit::get_last_unhidden_line() const {
-
// Returns the last line in the text that is not hidden.
- if (!is_hiding_enabled())
+ if (!is_hiding_enabled()) {
return text.size() - 1;
+ }
int last_line;
for (last_line = text.size() - 1; last_line > 0; last_line--) {
@@ -5882,7 +5822,6 @@ int TextEdit::get_last_unhidden_line() const {
}
int TextEdit::get_indent_level(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
// Counts number of tabs and spaces before line starts.
@@ -5902,7 +5841,6 @@ int TextEdit::get_indent_level(int p_line) const {
}
bool TextEdit::is_line_comment(int p_line) const {
-
// Checks to see if this line is the start of a comment.
ERR_FAIL_INDEX_V(p_line, text.size(), false);
@@ -5923,26 +5861,32 @@ bool TextEdit::is_line_comment(int p_line) const {
}
bool TextEdit::can_fold(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), false);
- if (!is_hiding_enabled())
+ if (!is_hiding_enabled()) {
return false;
- if (p_line + 1 >= text.size())
+ }
+ if (p_line + 1 >= text.size()) {
return false;
- if (text[p_line].strip_edges().size() == 0)
+ }
+ if (text[p_line].strip_edges().size() == 0) {
return false;
- if (is_folded(p_line))
+ }
+ if (is_folded(p_line)) {
return false;
- if (is_line_hidden(p_line))
+ }
+ if (is_line_hidden(p_line)) {
return false;
- if (is_line_comment(p_line))
+ }
+ if (is_line_comment(p_line)) {
return false;
+ }
int start_indent = get_indent_level(p_line);
for (int i = p_line + 1; i < text.size(); i++) {
- if (text[i].strip_edges().size() == 0)
+ if (text[i].strip_edges().size() == 0) {
continue;
+ }
int next_indent = get_indent_level(i);
if (is_line_comment(i)) {
continue;
@@ -5957,10 +5901,10 @@ bool TextEdit::can_fold(int p_line) const {
}
bool TextEdit::is_folded(int p_line) const {
-
ERR_FAIL_INDEX_V(p_line, text.size(), false);
- if (p_line + 1 >= text.size())
+ if (p_line + 1 >= text.size()) {
return false;
+ }
return !is_line_hidden(p_line) && is_line_hidden(p_line + 1);
}
@@ -5976,12 +5920,13 @@ Vector<int> TextEdit::get_folded_lines() const {
}
void TextEdit::fold_line(int p_line) {
-
ERR_FAIL_INDEX(p_line, text.size());
- if (!is_hiding_enabled())
+ if (!is_hiding_enabled()) {
return;
- if (!can_fold(p_line))
+ }
+ if (!can_fold(p_line)) {
return;
+ }
// Hide lines below this one.
int start_indent = get_indent_level(p_line);
@@ -6022,15 +5967,16 @@ void TextEdit::fold_line(int p_line) {
}
void TextEdit::unfold_line(int p_line) {
-
ERR_FAIL_INDEX(p_line, text.size());
- if (!is_folded(p_line) && !is_line_hidden(p_line))
+ if (!is_folded(p_line) && !is_line_hidden(p_line)) {
return;
+ }
int fold_start;
for (fold_start = p_line; fold_start > 0; fold_start--) {
- if (is_folded(fold_start))
+ if (is_folded(fold_start)) {
break;
+ }
}
fold_start = is_folded(fold_start) ? fold_start : p_line;
@@ -6046,45 +5992,42 @@ void TextEdit::unfold_line(int p_line) {
}
void TextEdit::toggle_fold_line(int p_line) {
-
ERR_FAIL_INDEX(p_line, text.size());
- if (!is_folded(p_line))
+ if (!is_folded(p_line)) {
fold_line(p_line);
- else
+ } else {
unfold_line(p_line);
+ }
}
int TextEdit::get_line_count() const {
-
return text.size();
}
void TextEdit::_do_text_op(const TextOperation &p_op, bool p_reverse) {
-
ERR_FAIL_COND(p_op.type == TextOperation::TYPE_NONE);
bool insert = p_op.type == TextOperation::TYPE_INSERT;
- if (p_reverse)
+ if (p_reverse) {
insert = !insert;
+ }
if (insert) {
-
int check_line;
int check_column;
_base_insert_text(p_op.from_line, p_op.from_column, p_op.text, check_line, check_column);
ERR_FAIL_COND(check_line != p_op.to_line); // BUG.
ERR_FAIL_COND(check_column != p_op.to_column); // BUG.
} else {
-
_base_remove_text(p_op.from_line, p_op.from_column, p_op.to_line, p_op.to_column);
}
}
void TextEdit::_clear_redo() {
-
- if (undo_stack_pos == nullptr)
+ if (undo_stack_pos == nullptr) {
return; // Nothing to clear.
+ }
_push_current_op();
@@ -6096,27 +6039,28 @@ void TextEdit::_clear_redo() {
}
void TextEdit::undo() {
-
_push_current_op();
if (undo_stack_pos == nullptr) {
-
- if (!undo_stack.size())
+ if (!undo_stack.size()) {
return; // Nothing to undo.
+ }
undo_stack_pos = undo_stack.back();
- } else if (undo_stack_pos == undo_stack.front())
+ } else if (undo_stack_pos == undo_stack.front()) {
return; // At the bottom of the undo stack.
- else
+ } else {
undo_stack_pos = undo_stack_pos->prev();
+ }
deselect();
TextOperation op = undo_stack_pos->get();
_do_text_op(op, true);
- if (op.type != TextOperation::TYPE_INSERT && (op.from_line != op.to_line || op.to_column != op.from_column + 1))
+ if (op.type != TextOperation::TYPE_INSERT && (op.from_line != op.to_line || op.to_column != op.from_column + 1)) {
select(op.from_line, op.from_column, op.to_line, op.to_column);
+ }
current_op.version = op.prev_version;
if (undo_stack_pos->get().chain_backward) {
@@ -6145,11 +6089,11 @@ void TextEdit::undo() {
}
void TextEdit::redo() {
-
_push_current_op();
- if (undo_stack_pos == nullptr)
+ if (undo_stack_pos == nullptr) {
return; // Nothing to do.
+ }
deselect();
@@ -6157,15 +6101,15 @@ void TextEdit::redo() {
_do_text_op(op, false);
current_op.version = op.version;
if (undo_stack_pos->get().chain_forward) {
-
while (true) {
ERR_BREAK(!undo_stack_pos->next());
undo_stack_pos = undo_stack_pos->next();
op = undo_stack_pos->get();
_do_text_op(op, false);
current_op.version = op.version;
- if (undo_stack_pos->get().chain_backward)
+ if (undo_stack_pos->get().chain_backward) {
break;
+ }
}
}
@@ -6177,7 +6121,6 @@ void TextEdit::redo() {
}
void TextEdit::clear_undo_history() {
-
saved_version = 0;
current_op.type = TextOperation::TYPE_NONE;
undo_stack_pos = nullptr;
@@ -6190,7 +6133,6 @@ void TextEdit::begin_complex_operation() {
}
void TextEdit::end_complex_operation() {
-
_push_current_op();
ERR_FAIL_COND(undo_stack.size() == 0);
@@ -6203,9 +6145,9 @@ void TextEdit::end_complex_operation() {
}
void TextEdit::_push_current_op() {
-
- if (current_op.type == TextOperation::TYPE_NONE)
+ if (current_op.type == TextOperation::TYPE_NONE) {
return; // Nothing to do.
+ }
if (next_operation_is_complex) {
current_op.chain_forward = true;
@@ -6244,28 +6186,23 @@ void TextEdit::set_indent_size(const int p_size) {
}
int TextEdit::get_indent_size() {
-
return indent_size;
}
void TextEdit::set_draw_tabs(bool p_draw) {
-
draw_tabs = p_draw;
update();
}
bool TextEdit::is_drawing_tabs() const {
-
return draw_tabs;
}
void TextEdit::set_draw_spaces(bool p_draw) {
-
draw_spaces = p_draw;
}
bool TextEdit::is_drawing_spaces() const {
-
return draw_spaces;
}
@@ -6295,19 +6232,17 @@ uint32_t TextEdit::get_version() const {
}
uint32_t TextEdit::get_saved_version() const {
-
return saved_version;
}
void TextEdit::tag_saved_version() {
-
saved_version = get_version();
}
double TextEdit::get_scroll_pos_for_line(int p_line, int p_wrap_index) const {
-
- if (!is_wrap_enabled() && !is_hiding_enabled())
+ if (!is_wrap_enabled() && !is_hiding_enabled()) {
return p_line;
+ }
// Count the number of visible lines up to this line.
double new_line_scroll_pos = 0;
@@ -6323,12 +6258,10 @@ double TextEdit::get_scroll_pos_for_line(int p_line, int p_wrap_index) const {
}
void TextEdit::set_line_as_first_visible(int p_line, int p_wrap_index) {
-
set_v_scroll(get_scroll_pos_for_line(p_line, p_wrap_index));
}
void TextEdit::set_line_as_center_visible(int p_line, int p_wrap_index) {
-
int visible_rows = get_visible_rows();
int wi;
int first_line = p_line - num_lines_from_rows(p_line, p_wrap_index, -visible_rows / 2, wi) + 1;
@@ -6337,7 +6270,6 @@ void TextEdit::set_line_as_center_visible(int p_line, int p_wrap_index) {
}
void TextEdit::set_line_as_last_visible(int p_line, int p_wrap_index) {
-
int wi;
int first_line = p_line - num_lines_from_rows(p_line, p_wrap_index, -get_visible_rows() - 1, wi) + 1;
@@ -6345,12 +6277,10 @@ void TextEdit::set_line_as_last_visible(int p_line, int p_wrap_index) {
}
int TextEdit::get_first_visible_line() const {
-
return CLAMP(cursor.line_ofs, 0, text.size() - 1);
}
int TextEdit::get_last_visible_line() const {
-
int first_vis_line = get_first_visible_line();
int last_vis_line = 0;
int wi;
@@ -6360,7 +6290,6 @@ int TextEdit::get_last_visible_line() const {
}
int TextEdit::get_last_visible_line_wrap_index() const {
-
int first_vis_line = get_first_visible_line();
int wi;
num_lines_from_rows(first_vis_line, cursor.wrap_ofs, get_visible_rows() + 1, wi);
@@ -6368,7 +6297,6 @@ int TextEdit::get_last_visible_line_wrap_index() const {
}
double TextEdit::get_visible_rows_offset() const {
-
double total = _get_control_height();
total /= (double)get_row_height();
total = total - floor(total);
@@ -6377,31 +6305,27 @@ double TextEdit::get_visible_rows_offset() const {
}
double TextEdit::get_v_scroll_offset() const {
-
double val = get_v_scroll() - floor(get_v_scroll());
return CLAMP(val, 0, 1);
}
double TextEdit::get_v_scroll() const {
-
return v_scroll->get_value();
}
void TextEdit::set_v_scroll(double p_scroll) {
-
v_scroll->set_value(p_scroll);
int max_v_scroll = v_scroll->get_max() - v_scroll->get_page();
- if (p_scroll >= max_v_scroll - 1.0)
+ if (p_scroll >= max_v_scroll - 1.0) {
_scroll_moved(v_scroll->get_value());
+ }
}
int TextEdit::get_h_scroll() const {
-
return h_scroll->get_value();
}
void TextEdit::set_h_scroll(int p_scroll) {
-
if (p_scroll < 0) {
p_scroll = 0;
}
@@ -6409,36 +6333,31 @@ void TextEdit::set_h_scroll(int p_scroll) {
}
void TextEdit::set_smooth_scroll_enabled(bool p_enable) {
-
v_scroll->set_smooth_scroll_enabled(p_enable);
smooth_scroll_enabled = p_enable;
}
bool TextEdit::is_smooth_scroll_enabled() const {
-
return smooth_scroll_enabled;
}
void TextEdit::set_v_scroll_speed(float p_speed) {
-
v_scroll_speed = p_speed;
}
float TextEdit::get_v_scroll_speed() const {
-
return v_scroll_speed;
}
void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) {
-
completion_prefixes.clear();
completion_enabled = p_enabled;
- for (int i = 0; i < p_prefixes.size(); i++)
+ for (int i = 0; i < p_prefixes.size(); i++) {
completion_prefixes.insert(p_prefixes[i]);
+ }
}
void TextEdit::_confirm_completion() {
-
begin_complex_operation();
_remove_text(cursor.line, cursor.column - completion_base.length(), cursor.line, cursor.column);
@@ -6456,7 +6375,6 @@ void TextEdit::_confirm_completion() {
}
if (last_completion_char == '(') {
-
if (next_char == last_completion_char) {
_base_remove_text(cursor.line, cursor.column - 1, cursor.line, cursor.column);
} else if (auto_brace_completion_enabled) {
@@ -6464,7 +6382,6 @@ void TextEdit::_confirm_completion() {
cursor.column--;
}
} else if (last_completion_char == ')' && next_char == '(') {
-
_base_remove_text(cursor.line, cursor.column - 2, cursor.line, cursor.column);
if (line[cursor.column + 1] != ')') {
cursor.column--;
@@ -6481,15 +6398,14 @@ void TextEdit::_confirm_completion() {
}
void TextEdit::_cancel_code_hint() {
-
completion_hint = "";
update();
}
void TextEdit::_cancel_completion() {
-
- if (!completion_active)
+ if (!completion_active) {
return;
+ }
completion_active = false;
completion_forced = false;
@@ -6497,12 +6413,10 @@ void TextEdit::_cancel_completion() {
}
static bool _is_completable(CharType c) {
-
return !_is_symbol(c) || c == '"' || c == '\'';
}
void TextEdit::_update_completion_candidates() {
-
String l = text[cursor.line];
int cofs = CLAMP(cursor.column, 0, l.length());
@@ -6518,8 +6432,9 @@ void TextEdit::_update_completion_candidates() {
while (c >= 0) {
if (l[c] == '"' || l[c] == '\'') {
inquote = !inquote;
- if (first_quote == -1)
+ if (first_quote == -1) {
first_quote = c;
+ }
restore_quotes = 0;
} else if (restore_quotes == 0 && l[c] == '$') {
restore_quotes = 1;
@@ -6536,13 +6451,13 @@ void TextEdit::_update_completion_candidates() {
// No completion here.
cancel = true;
} else if (inquote && first_quote != -1) {
-
s = l.substr(first_quote, cofs - first_quote);
} else if (cofs > 0 && l[cofs - 1] == ' ') {
int kofs = cofs - 1;
String kw;
- while (kofs >= 0 && l[kofs] == ' ')
+ while (kofs >= 0 && l[kofs] == ' ') {
kofs--;
+ }
while (kofs >= 0 && l[kofs] > 32 && _is_completable(l[kofs])) {
kw = String::chr(l[kofs]) + kw;
@@ -6552,11 +6467,11 @@ void TextEdit::_update_completion_candidates() {
pre_keyword = keywords.has(kw);
} else {
-
while (cofs > 0 && l[cofs - 1] > 32 && (l[cofs - 1] == '/' || _is_completable(l[cofs - 1]))) {
s = String::chr(l[cofs - 1]) + s;
- if (l[cofs - 1] == '\'' || l[cofs - 1] == '"' || l[cofs - 1] == '$')
+ if (l[cofs - 1] == '\'' || l[cofs - 1] == '"' || l[cofs - 1] == '$') {
break;
+ }
cofs--;
}
@@ -6569,11 +6484,13 @@ void TextEdit::_update_completion_candidates() {
update();
bool prev_is_prefix = false;
- if (cofs > 0 && completion_prefixes.has(String::chr(l[cofs - 1])))
+ if (cofs > 0 && completion_prefixes.has(String::chr(l[cofs - 1]))) {
prev_is_prefix = true;
+ }
// Check with one space before prefix, to allow indent.
- if (cofs > 1 && l[cofs - 1] == ' ' && completion_prefixes.has(String::chr(l[cofs - 2])))
+ if (cofs > 1 && l[cofs - 1] == ' ' && completion_prefixes.has(String::chr(l[cofs - 2]))) {
prev_is_prefix = true;
+ }
if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !prev_is_prefix))) {
// None to complete, cancel.
@@ -6610,7 +6527,6 @@ void TextEdit::_update_completion_candidates() {
} else if (s.length() == 0) {
completion_options.push_back(option);
} else {
-
// This code works the same as:
/*
if (option.display.begins_with(s)) {
@@ -6685,7 +6601,6 @@ void TextEdit::_update_completion_candidates() {
}
void TextEdit::query_code_comple() {
-
String l = text[cursor.line];
int ofs = CLAMP(cursor.column, 0, l.length());
@@ -6693,8 +6608,9 @@ void TextEdit::query_code_comple() {
int c = ofs - 1;
while (c >= 0) {
- if (l[c] == '"' || l[c] == '\'')
+ if (l[c] == '"' || l[c] == '\'') {
inquote = !inquote;
+ }
c--;
}
@@ -6717,22 +6633,21 @@ void TextEdit::query_code_comple() {
}
if (!ignored) {
- if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1]))))
+ if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1])))) {
emit_signal("request_completion");
- else if (ofs > 1 && l[ofs - 1] == ' ' && completion_prefixes.has(String::chr(l[ofs - 2]))) // Make it work with a space too, it's good enough.
+ } else if (ofs > 1 && l[ofs - 1] == ' ' && completion_prefixes.has(String::chr(l[ofs - 2]))) { // Make it work with a space too, it's good enough.
emit_signal("request_completion");
+ }
}
}
void TextEdit::set_code_hint(const String &p_hint) {
-
completion_hint = p_hint;
completion_hint_offset = -0xFFFF;
update();
}
void TextEdit::code_complete(const List<ScriptCodeCompletionOption> &p_strings, bool p_forced) {
-
completion_sources = p_strings;
completion_active = true;
completion_forced = p_forced;
@@ -6742,16 +6657,15 @@ void TextEdit::code_complete(const List<ScriptCodeCompletionOption> &p_strings,
}
String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
-
int row, col;
_get_mouse_pos(p_pos, row, col);
String s = text[row];
- if (s.length() == 0)
+ if (s.length() == 0) {
return "";
+ }
int beg, end;
if (select_word(s, col, beg, end)) {
-
bool inside_quotes = false;
CharType selected_quote = '\0';
int qbegin = 0, qend = 0;
@@ -6781,18 +6695,18 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
}
String TextEdit::get_tooltip(const Point2 &p_pos) const {
-
- if (!tooltip_obj)
+ if (!tooltip_obj) {
return Control::get_tooltip(p_pos);
+ }
int row, col;
_get_mouse_pos(p_pos, row, col);
String s = text[row];
- if (s.length() == 0)
+ if (s.length() == 0) {
return Control::get_tooltip(p_pos);
+ }
int beg, end;
if (select_word(s, col, beg, end)) {
-
String tt = tooltip_obj->call(tooltip_func, s.substr(beg, end - beg), tooltip_ud);
return tt;
@@ -6802,15 +6716,15 @@ String TextEdit::get_tooltip(const Point2 &p_pos) const {
}
void TextEdit::set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata) {
-
tooltip_obj = p_obj;
tooltip_func = p_function;
tooltip_ud = p_udata;
}
void TextEdit::set_line(int line, String new_text) {
- if (line < 0 || line > text.size())
+ if (line < 0 || line > text.size()) {
return;
+ }
_remove_text(line, 0, line, text[line].length());
_insert_text(line, 0, new_text);
if (cursor.line == line) {
@@ -6840,13 +6754,11 @@ void TextEdit::insert_at(const String &p_text, int at) {
}
void TextEdit::set_show_line_numbers(bool p_show) {
-
line_numbers = p_show;
update();
}
void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
-
line_numbers_zero_padded = p_zero_padded;
update();
}
@@ -6952,8 +6864,9 @@ int TextEdit::get_minimap_width() const {
}
void TextEdit::set_hiding_enabled(bool p_enabled) {
- if (!p_enabled)
+ if (!p_enabled) {
unhide_all_lines();
+ }
hiding_enabled = p_enabled;
update();
}
@@ -6972,12 +6885,10 @@ bool TextEdit::is_highlight_current_line_enabled() const {
}
bool TextEdit::is_text_field() const {
-
return true;
}
void TextEdit::menu_option(int p_option) {
-
switch (p_option) {
case MENU_CUT: {
if (!readonly) {
@@ -7015,12 +6926,10 @@ void TextEdit::set_highlighted_word(const String &new_word) {
}
void TextEdit::set_select_identifiers_on_hover(bool p_enable) {
-
select_identifiers_enabled = p_enable;
}
bool TextEdit::is_selecting_identifiers_on_hover_enabled() const {
-
return select_identifiers_enabled;
}
@@ -7041,8 +6950,9 @@ void TextEdit::set_shortcut_keys_enabled(bool p_enabled) {
void TextEdit::set_selecting_enabled(bool p_enabled) {
selecting_enabled = p_enabled;
- if (!selecting_enabled)
+ if (!selecting_enabled) {
deselect();
+ }
_generate_context_menu();
}
@@ -7060,7 +6970,6 @@ PopupMenu *TextEdit::get_menu() const {
}
void TextEdit::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &TextEdit::_gui_input);
ClassDB::bind_method(D_METHOD("_cursor_changed_emit"), &TextEdit::_cursor_changed_emit);
ClassDB::bind_method(D_METHOD("_text_changed_emit"), &TextEdit::_text_changed_emit);
@@ -7070,9 +6979,6 @@ void TextEdit::_bind_methods() {
BIND_ENUM_CONSTANT(SEARCH_WHOLE_WORDS);
BIND_ENUM_CONSTANT(SEARCH_BACKWARDS);
- BIND_ENUM_CONSTANT(SEARCH_RESULT_COLUMN);
- BIND_ENUM_CONSTANT(SEARCH_RESULT_LINE);
-
/*
ClassDB::bind_method(D_METHOD("delete_char"),&TextEdit::delete_char);
ClassDB::bind_method(D_METHOD("delete_line"),&TextEdit::delete_line);
@@ -7250,7 +7156,6 @@ void TextEdit::_bind_methods() {
}
TextEdit::TextEdit() {
-
setting_row = false;
draw_tabs = false;
draw_spaces = false;
@@ -7496,10 +7401,10 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
}
if (in_region == -1 && !in_keyword && is_char && !prev_is_char) {
-
int to = j;
- while (to < str.length() && _is_text_char(str[to]))
+ while (to < str.length() && _is_text_char(str[to])) {
to++;
+ }
uint32_t hash = String::hash(&str[j], to - j);
StrRange range(&str[j], to - j);
@@ -7528,7 +7433,6 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
}
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++;
@@ -7560,18 +7464,19 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int
in_member_variable = false;
}
- if (in_region >= 0)
+ if (in_region >= 0) {
color = color_regions[in_region].color;
- else if (in_keyword)
+ } else if (in_keyword) {
color = keyword_color;
- else if (in_member_variable)
+ } else if (in_member_variable) {
color = cache.member_variable_color;
- else if (in_function_name)
+ } else if (in_function_name) {
color = cache.function_color;
- else if (is_symbol)
+ } else if (is_symbol) {
color = cache.symbol_color;
- else if (is_number)
+ } else if (is_number) {
color = cache.number_color;
+ }
prev_is_char = is_char;
prev_is_number = is_number;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index ac8eb5da1d..ab78f77d94 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -39,7 +39,6 @@
class SyntaxHighlighter;
class TextEdit : public Control {
-
GDCLASS(TextEdit, Control);
public:
@@ -48,7 +47,6 @@ public:
};
struct ColorRegion {
-
Color color;
String begin_key;
String end_key;
@@ -66,7 +64,6 @@ public:
class Text {
public:
struct ColorRegionInfo {
-
int region;
bool end;
ColorRegionInfo() {
@@ -168,7 +165,6 @@ private:
} cursor;
struct Selection {
-
enum Mode {
MODE_NONE,
@@ -207,7 +203,6 @@ private:
} selection;
struct Cache {
-
Ref<Texture2D> tab_icon;
Ref<Texture2D> space_icon;
Ref<Texture2D> can_fold_icon;
@@ -256,7 +251,6 @@ private:
int info_gutter_width;
int minimap_width;
Cache() {
-
row_height = 0;
line_spacing = 0;
line_number_w = 0;
@@ -271,7 +265,6 @@ private:
Map<int, Map<int, HighlighterInfo>> syntax_highlighting_cache;
struct TextOperation {
-
enum Type {
TYPE_NONE,
TYPE_INSERT,
@@ -515,7 +508,7 @@ private:
int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column);
- Vector<int> _search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const;
+ Dictionary _search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const;
PopupMenu *menu;
@@ -568,11 +561,6 @@ public:
SEARCH_BACKWARDS = 4
};
- enum SearchResult {
- SEARCH_RESULT_COLUMN,
- SEARCH_RESULT_LINE,
- };
-
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
void _get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const;
@@ -833,7 +821,6 @@ public:
VARIANT_ENUM_CAST(TextEdit::MenuItems);
VARIANT_ENUM_CAST(TextEdit::SearchFlags);
-VARIANT_ENUM_CAST(TextEdit::SearchResult);
class SyntaxHighlighter {
protected:
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 5f2e4cf58e..6e86f0f299 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -33,33 +33,34 @@
#include <stdlib.h>
Size2 TextureButton::get_minimum_size() const {
-
Size2 rscale = Control::get_minimum_size();
if (!expand) {
if (normal.is_null()) {
if (pressed.is_null()) {
- if (hover.is_null())
- if (click_mask.is_null())
+ if (hover.is_null()) {
+ if (click_mask.is_null()) {
rscale = Size2();
- else
+ } else {
rscale = click_mask->get_size();
- else
+ }
+ } else {
rscale = hover->get_size();
- } else
+ }
+ } else {
rscale = pressed->get_size();
+ }
- } else
+ } else {
rscale = normal->get_size();
+ }
}
return rscale.abs();
}
bool TextureButton::has_point(const Point2 &p_point) const {
-
if (click_mask.is_valid()) {
-
Point2 point = p_point;
Rect2 rect = Rect2();
Size2 mask_size = click_mask->get_size();
@@ -116,9 +117,7 @@ bool TextureButton::has_point(const Point2 &p_point) const {
}
void TextureButton::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
DrawMode draw_mode = get_draw_mode();
@@ -126,40 +125,44 @@ void TextureButton::_notification(int p_what) {
switch (draw_mode) {
case DRAW_NORMAL: {
-
- if (normal.is_valid())
+ if (normal.is_valid()) {
texdraw = normal;
+ }
} break;
case DRAW_HOVER_PRESSED:
case DRAW_PRESSED: {
-
if (pressed.is_null()) {
if (hover.is_null()) {
- if (normal.is_valid())
+ if (normal.is_valid()) {
texdraw = normal;
- } else
+ }
+ } else {
texdraw = hover;
+ }
- } else
+ } else {
texdraw = pressed;
+ }
} break;
case DRAW_HOVER: {
-
if (hover.is_null()) {
- if (pressed.is_valid() && is_pressed())
+ if (pressed.is_valid() && is_pressed()) {
texdraw = pressed;
- else if (normal.is_valid())
+ } else if (normal.is_valid()) {
texdraw = normal;
- } else
+ }
+ } else {
texdraw = hover;
+ }
} break;
case DRAW_DISABLED: {
-
if (disabled.is_null()) {
- if (normal.is_valid())
+ if (normal.is_valid()) {
texdraw = normal;
- } else
+ }
+ } else {
texdraw = disabled;
+ }
} break;
}
@@ -232,7 +235,6 @@ void TextureButton::_notification(int p_what) {
}
void TextureButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_normal_texture", "texture"), &TextureButton::set_normal_texture);
ClassDB::bind_method(D_METHOD("set_pressed_texture", "texture"), &TextureButton::set_pressed_texture);
ClassDB::bind_method(D_METHOD("set_hover_texture", "texture"), &TextureButton::set_hover_texture);
@@ -271,61 +273,56 @@ void TextureButton::_bind_methods() {
}
void TextureButton::set_normal_texture(const Ref<Texture2D> &p_normal) {
-
normal = p_normal;
update();
minimum_size_changed();
}
void TextureButton::set_pressed_texture(const Ref<Texture2D> &p_pressed) {
-
pressed = p_pressed;
update();
}
-void TextureButton::set_hover_texture(const Ref<Texture2D> &p_hover) {
+void TextureButton::set_hover_texture(const Ref<Texture2D> &p_hover) {
hover = p_hover;
update();
}
-void TextureButton::set_disabled_texture(const Ref<Texture2D> &p_disabled) {
+void TextureButton::set_disabled_texture(const Ref<Texture2D> &p_disabled) {
disabled = p_disabled;
update();
}
-void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) {
+void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) {
click_mask = p_click_mask;
update();
}
Ref<Texture2D> TextureButton::get_normal_texture() const {
-
return normal;
}
-Ref<Texture2D> TextureButton::get_pressed_texture() const {
+Ref<Texture2D> TextureButton::get_pressed_texture() const {
return pressed;
}
-Ref<Texture2D> TextureButton::get_hover_texture() const {
+Ref<Texture2D> TextureButton::get_hover_texture() const {
return hover;
}
-Ref<Texture2D> TextureButton::get_disabled_texture() const {
+Ref<Texture2D> TextureButton::get_disabled_texture() const {
return disabled;
}
-Ref<BitMap> TextureButton::get_click_mask() const {
+Ref<BitMap> TextureButton::get_click_mask() const {
return click_mask;
}
Ref<Texture2D> TextureButton::get_focused_texture() const {
-
return focused;
};
void TextureButton::set_focused_texture(const Ref<Texture2D> &p_focused) {
-
focused = p_focused;
};
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 43b10a8e8b..a1e66203d3 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -34,7 +34,6 @@
#include "scene/gui/base_button.h"
#include "scene/resources/bit_map.h"
class TextureButton : public BaseButton {
-
GDCLASS(TextureButton, BaseButton);
public:
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 0dd43e4a35..484b14d11c 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -33,19 +33,16 @@
#include "core/engine.h"
void TextureProgress::set_under_texture(const Ref<Texture2D> &p_texture) {
-
under = p_texture;
update();
minimum_size_changed();
}
Ref<Texture2D> TextureProgress::get_under_texture() const {
-
return under;
}
void TextureProgress::set_over_texture(const Ref<Texture2D> &p_texture) {
-
over = p_texture;
update();
if (under.is_null()) {
@@ -54,7 +51,6 @@ void TextureProgress::set_over_texture(const Ref<Texture2D> &p_texture) {
}
Ref<Texture2D> TextureProgress::get_over_texture() const {
-
return over;
}
@@ -81,28 +77,26 @@ bool TextureProgress::get_nine_patch_stretch() const {
}
Size2 TextureProgress::get_minimum_size() const {
-
- if (nine_patch_stretch)
+ if (nine_patch_stretch) {
return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]);
- else if (under.is_valid())
+ } else if (under.is_valid()) {
return under->get_size();
- else if (over.is_valid())
+ } else if (over.is_valid()) {
return over->get_size();
- else if (progress.is_valid())
+ } else if (progress.is_valid()) {
return progress->get_size();
+ }
return Size2(1, 1);
}
void TextureProgress::set_progress_texture(const Ref<Texture2D> &p_texture) {
-
progress = p_texture;
update();
minimum_size_changed();
}
Ref<Texture2D> TextureProgress::get_progress_texture() const {
-
return progress;
}
@@ -134,13 +128,16 @@ Color TextureProgress::get_tint_over() const {
}
Point2 TextureProgress::unit_val_to_uv(float val) {
- if (progress.is_null())
+ if (progress.is_null()) {
return Point2();
+ }
- if (val < 0)
+ if (val < 0) {
val += 1;
- if (val > 1)
+ }
+ if (val > 1) {
val -= 1;
+ }
Point2 p = get_relative_center();
@@ -158,40 +155,46 @@ Point2 TextureProgress::unit_val_to_uv(float val) {
for (int edge = 0; edge < 4; edge++) {
if (edge == 0) {
- if (dir.x > 0)
+ if (dir.x > 0) {
continue;
+ }
cq = -(edgeLeft - p.x);
dir.x *= 2.0 * cq;
cp = -dir.x;
} else if (edge == 1) {
- if (dir.x < 0)
+ if (dir.x < 0) {
continue;
+ }
cq = (edgeRight - p.x);
dir.x *= 2.0 * cq;
cp = dir.x;
} else if (edge == 2) {
- if (dir.y > 0)
+ if (dir.y > 0) {
continue;
+ }
cq = -(edgeBottom - p.y);
dir.y *= 2.0 * cq;
cp = -dir.y;
} else if (edge == 3) {
- if (dir.y < 0)
+ if (dir.y < 0) {
continue;
+ }
cq = (edgeTop - p.y);
dir.y *= 2.0 * cq;
cp = dir.y;
}
cr = cq / cp;
- if (cr >= 0 && cr < t1)
+ if (cr >= 0 && cr < t1) {
t1 = cr;
+ }
}
return (p + t1 * dir);
}
Point2 TextureProgress::get_relative_center() {
- if (progress.is_null())
+ if (progress.is_null()) {
return Point2();
+ }
Point2 p = progress->get_size() / 2;
p += rad_center_off;
p.x /= progress->get_width();
@@ -306,9 +309,7 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture,
void TextureProgress::_notification(int p_what) {
const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP)) {
if (under.is_valid()) {
draw_nine_patch_stretched(under, FILL_LEFT_TO_RIGHT, 1.0, tint_under);
@@ -320,8 +321,9 @@ void TextureProgress::_notification(int p_what) {
draw_nine_patch_stretched(over, FILL_LEFT_TO_RIGHT, 1.0, tint_over);
}
} else {
- if (under.is_valid())
+ if (under.is_valid()) {
draw_texture(under, Point2(), tint_under);
+ }
if (progress.is_valid()) {
Size2 s = progress->get_size();
switch (mode) {
@@ -344,8 +346,9 @@ void TextureProgress::_notification(int p_what) {
case FILL_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE:
case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
- if (nine_patch_stretch)
+ if (nine_patch_stretch) {
s = get_size();
+ }
float val = get_as_ratio() * rad_max_degrees / 360;
if (val == 1) {
@@ -367,9 +370,11 @@ void TextureProgress::_notification(int p_what) {
pts.append(end);
float from = MIN(start, end);
float to = MAX(start, end);
- for (int i = 0; i < 12; i++)
- if (corners[i] > from && corners[i] < to)
+ for (int i = 0; i < 12; i++) {
+ if (corners[i] > from && corners[i] < to) {
pts.append(corners[i]);
+ }
+ }
pts.sort();
Vector<Point2> uvs;
Vector<Point2> points;
@@ -377,8 +382,9 @@ void TextureProgress::_notification(int p_what) {
points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
for (int i = 0; i < pts.size(); i++) {
Point2 uv = unit_val_to_uv(pts[i]);
- if (uvs.find(uv) >= 0)
+ if (uvs.find(uv) >= 0) {
continue;
+ }
uvs.push_back(uv);
points.push_back(Point2(uv.x * s.x, uv.y * s.y));
}
@@ -389,10 +395,11 @@ void TextureProgress::_notification(int p_what) {
if (Engine::get_singleton()->is_editor_hint()) {
Point2 p;
- if (nine_patch_stretch)
+ if (nine_patch_stretch) {
p = get_size();
- else
+ } else {
p = progress->get_size();
+ }
p.x *= get_relative_center().x;
p.y *= get_relative_center().y;
@@ -413,10 +420,10 @@ void TextureProgress::_notification(int p_what) {
draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), tint_progress);
}
}
- if (over.is_valid())
+ if (over.is_valid()) {
draw_texture(over, Point2(), tint_over);
+ }
}
-
} break;
}
}
@@ -432,10 +439,12 @@ int TextureProgress::get_fill_mode() {
}
void TextureProgress::set_radial_initial_angle(float p_angle) {
- while (p_angle > 360)
+ while (p_angle > 360) {
p_angle -= 360;
- while (p_angle < 0)
+ }
+ while (p_angle < 0) {
p_angle += 360;
+ }
rad_init_angle = p_angle;
update();
}
@@ -463,7 +472,6 @@ Point2 TextureProgress::get_radial_center_offset() {
}
void TextureProgress::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_under_texture", "tex"), &TextureProgress::set_under_texture);
ClassDB::bind_method(D_METHOD("get_under_texture"), &TextureProgress::get_under_texture);
diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h
index e05f89aa3e..e56454f866 100644
--- a/scene/gui/texture_progress.h
+++ b/scene/gui/texture_progress.h
@@ -34,7 +34,6 @@
#include "scene/gui/range.h"
class TextureProgress : public Range {
-
GDCLASS(TextureProgress, Range);
Ref<Texture2D> under;
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index 92f3c5b5d9..58e7249284 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -33,9 +33,7 @@
#include "servers/rendering_server.h"
void TextureRect::_notification(int p_what) {
-
if (p_what == NOTIFICATION_DRAW) {
-
if (texture.is_null()) {
return;
}
@@ -116,7 +114,6 @@ void TextureRect::_notification(int p_what) {
}
Size2 TextureRect::get_minimum_size() const {
-
if (!expand && !texture.is_null()) {
return texture->get_size();
} else {
@@ -125,7 +122,6 @@ Size2 TextureRect::get_minimum_size() const {
}
void TextureRect::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &TextureRect::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &TextureRect::get_texture);
ClassDB::bind_method(D_METHOD("set_expand", "enable"), &TextureRect::set_expand);
@@ -154,7 +150,6 @@ void TextureRect::_bind_methods() {
}
void TextureRect::_texture_changed() {
-
if (texture.is_valid()) {
update();
minimum_size_changed();
@@ -162,7 +157,6 @@ void TextureRect::_texture_changed() {
}
void TextureRect::set_texture(const Ref<Texture2D> &p_tex) {
-
if (p_tex == texture) {
return;
}
@@ -182,57 +176,47 @@ void TextureRect::set_texture(const Ref<Texture2D> &p_tex) {
}
Ref<Texture2D> TextureRect::get_texture() const {
-
return texture;
}
void TextureRect::set_expand(bool p_expand) {
-
expand = p_expand;
update();
minimum_size_changed();
}
bool TextureRect::has_expand() const {
-
return expand;
}
void TextureRect::set_stretch_mode(StretchMode p_mode) {
-
stretch_mode = p_mode;
update();
}
TextureRect::StretchMode TextureRect::get_stretch_mode() const {
-
return stretch_mode;
}
void TextureRect::set_flip_h(bool p_flip) {
-
hflip = p_flip;
update();
}
bool TextureRect::is_flipped_h() const {
-
return hflip;
}
void TextureRect::set_flip_v(bool p_flip) {
-
vflip = p_flip;
update();
}
bool TextureRect::is_flipped_v() const {
-
return vflip;
}
TextureRect::TextureRect() {
-
expand = false;
hflip = false;
vflip = false;
diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h
index 77a2828fd4..727ab95776 100644
--- a/scene/gui/texture_rect.h
+++ b/scene/gui/texture_rect.h
@@ -34,7 +34,6 @@
#include "scene/gui/control.h"
class TextureRect : public Control {
-
GDCLASS(TextureRect, Control);
public:
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 4a550727fc..7b9db7c081 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -47,9 +47,9 @@
#include <limits.h>
void TreeItem::move_to_top() {
-
- if (!parent || parent->children == this)
+ if (!parent || parent->children == this) {
return; //already on top
+ }
TreeItem *prev = get_prev();
prev->next = next;
next = parent->children;
@@ -57,13 +57,15 @@ void TreeItem::move_to_top() {
}
void TreeItem::move_to_bottom() {
- if (!parent || !next)
+ if (!parent || !next) {
return;
+ }
TreeItem *prev = get_prev();
TreeItem *last = next;
- while (last->next)
+ while (last->next) {
last = last->next;
+ }
if (prev) {
prev->next = next;
@@ -75,54 +77,48 @@ void TreeItem::move_to_bottom() {
}
Size2 TreeItem::Cell::get_icon_size() const {
-
- if (icon.is_null())
+ if (icon.is_null()) {
return Size2();
- if (icon_region == Rect2i())
+ }
+ if (icon_region == Rect2i()) {
return icon->get_size();
- else
+ } else {
return icon_region.size;
+ }
}
void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size, const Color &p_color) const {
-
- if (icon.is_null())
+ if (icon.is_null()) {
return;
+ }
Size2i dsize = (p_size == Size2()) ? icon->get_size() : p_size;
if (icon_region == Rect2i()) {
-
icon->draw_rect_region(p_where, Rect2(p_pos, dsize), Rect2(Point2(), icon->get_size()), p_color);
} else {
-
icon->draw_rect_region(p_where, Rect2(p_pos, dsize), icon_region, p_color);
}
}
void TreeItem::_changed_notify(int p_cell) {
-
tree->item_changed(p_cell, this);
}
void TreeItem::_changed_notify() {
-
tree->item_changed(-1, this);
}
void TreeItem::_cell_selected(int p_cell) {
-
tree->item_selected(p_cell, this);
}
void TreeItem::_cell_deselected(int p_cell) {
-
tree->item_deselected(p_cell, this);
}
/* cell mode */
void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) {
-
ERR_FAIL_INDEX(p_column, cells.size());
Cell &c = cells.write[p_column];
c.mode = p_mode;
@@ -138,32 +134,27 @@ void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) {
}
TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), TreeItem::CELL_MODE_STRING);
return cells[p_column].mode;
}
/* check mode */
void TreeItem::set_checked(int p_column, bool p_checked) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].checked = p_checked;
_changed_notify(p_column);
}
bool TreeItem::is_checked(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].checked;
}
void TreeItem::set_text(int p_column, String p_text) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].text = p_text;
if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE) {
-
Vector<String> strings = p_text.split(",");
cells.write[p_column].min = INT_MAX;
cells.write[p_column].max = INT_MIN;
@@ -181,13 +172,11 @@ void TreeItem::set_text(int p_column, String p_text) {
}
String TreeItem::get_text(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), "");
return cells[p_column].text;
}
void TreeItem::set_suffix(int p_column, String p_suffix) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].suffix = p_suffix;
@@ -195,91 +184,82 @@ void TreeItem::set_suffix(int p_column, String p_suffix) {
}
String TreeItem::get_suffix(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), "");
return cells[p_column].suffix;
}
void TreeItem::set_icon(int p_column, const Ref<Texture2D> &p_icon) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].icon = p_icon;
_changed_notify(p_column);
}
Ref<Texture2D> TreeItem::get_icon(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>());
return cells[p_column].icon;
}
void TreeItem::set_icon_region(int p_column, const Rect2 &p_icon_region) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].icon_region = p_icon_region;
_changed_notify(p_column);
}
Rect2 TreeItem::get_icon_region(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), Rect2());
return cells[p_column].icon_region;
}
void TreeItem::set_icon_modulate(int p_column, const Color &p_modulate) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].icon_color = p_modulate;
_changed_notify(p_column);
}
Color TreeItem::get_icon_modulate(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
return cells[p_column].icon_color;
}
void TreeItem::set_icon_max_width(int p_column, int p_max) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].icon_max_w = p_max;
_changed_notify(p_column);
}
int TreeItem::get_icon_max_width(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), 0);
return cells[p_column].icon_max_w;
}
/* range works for mode number or mode combo */
void TreeItem::set_range(int p_column, double p_value) {
-
ERR_FAIL_INDEX(p_column, cells.size());
- if (cells[p_column].step > 0)
+ if (cells[p_column].step > 0) {
p_value = Math::stepify(p_value, cells[p_column].step);
- if (p_value < cells[p_column].min)
+ }
+ if (p_value < cells[p_column].min) {
p_value = cells[p_column].min;
- if (p_value > cells[p_column].max)
+ }
+ if (p_value > cells[p_column].max) {
p_value = cells[p_column].max;
+ }
cells.write[p_column].val = p_value;
_changed_notify(p_column);
}
double TreeItem::get_range(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), 0);
return cells[p_column].val;
}
bool TreeItem::is_range_exponential(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].expr;
}
-void TreeItem::set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp) {
+void TreeItem::set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp) {
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].min = p_min;
cells.write[p_column].max = p_max;
@@ -289,7 +269,6 @@ void TreeItem::set_range_config(int p_column, double p_min, double p_max, double
}
void TreeItem::get_range_config(int p_column, double &r_min, double &r_max, double &r_step) const {
-
ERR_FAIL_INDEX(p_column, cells.size());
r_min = cells[p_column].min;
r_max = cells[p_column].max;
@@ -297,20 +276,17 @@ void TreeItem::get_range_config(int p_column, double &r_min, double &r_max, doub
}
void TreeItem::set_metadata(int p_column, const Variant &p_meta) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].meta = p_meta;
}
Variant TreeItem::get_metadata(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), Variant());
return cells[p_column].meta;
}
void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName &p_callback) {
-
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_NULL(p_object);
@@ -319,25 +295,21 @@ void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName
}
void TreeItem::set_collapsed(bool p_collapsed) {
-
- if (collapsed == p_collapsed || !tree)
+ if (collapsed == p_collapsed || !tree) {
return;
+ }
collapsed = p_collapsed;
TreeItem *ci = tree->selected_item;
if (ci) {
-
while (ci && ci != this) {
-
ci = ci->parent;
}
if (ci) { // collapsing cursor/selected, move it!
if (tree->select_mode == Tree::SELECT_MULTI) {
-
tree->selected_item = this;
emit_signal("cell_selected");
} else {
-
select(tree->selected_col);
}
@@ -350,7 +322,6 @@ void TreeItem::set_collapsed(bool p_collapsed) {
}
bool TreeItem::is_collapsed() {
-
return collapsed;
}
@@ -364,40 +335,36 @@ int TreeItem::get_custom_minimum_height() const {
}
TreeItem *TreeItem::get_next() {
-
return next;
}
TreeItem *TreeItem::get_prev() {
-
- if (!parent || parent->children == this)
+ if (!parent || parent->children == this) {
return nullptr;
+ }
TreeItem *prev = parent->children;
- while (prev && prev->next != this)
+ while (prev && prev->next != this) {
prev = prev->next;
+ }
return prev;
}
TreeItem *TreeItem::get_parent() {
-
return parent;
}
TreeItem *TreeItem::get_children() {
-
return children;
}
TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
-
TreeItem *current = this;
TreeItem *prev = current->get_prev();
if (!prev) {
-
current = current->parent;
if (current == tree->root && tree->hide_root) {
return nullptr;
@@ -414,14 +381,14 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
}
}
} else {
-
current = prev;
while (!current->collapsed && current->children) {
//go to the very end
current = current->children;
- while (current->next)
+ while (current->next) {
current = current->next;
+ }
}
}
@@ -429,28 +396,24 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
}
TreeItem *TreeItem::get_next_visible(bool p_wrap) {
-
TreeItem *current = this;
if (!current->collapsed && current->children) {
-
current = current->children;
} else if (current->next) {
-
current = current->next;
} else {
-
while (current && !current->next) {
-
current = current->parent;
}
if (!current) {
- if (p_wrap)
+ if (p_wrap) {
return tree->root;
- else
+ } else {
return nullptr;
+ }
} else {
current = current->next;
}
@@ -460,14 +423,11 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) {
}
void TreeItem::remove_child(TreeItem *p_item) {
-
ERR_FAIL_NULL(p_item);
TreeItem **c = &children;
while (*c) {
-
if ((*c) == p_item) {
-
TreeItem *aux = *c;
*c = (*c)->next;
@@ -483,55 +443,51 @@ void TreeItem::remove_child(TreeItem *p_item) {
}
void TreeItem::set_selectable(int p_column, bool p_selectable) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].selectable = p_selectable;
}
bool TreeItem::is_selectable(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].selectable;
}
bool TreeItem::is_selected(int p_column) {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].selectable && cells[p_column].selected;
}
void TreeItem::set_as_cursor(int p_column) {
-
ERR_FAIL_INDEX(p_column, cells.size());
- if (!tree)
+ if (!tree) {
return;
- if (tree->select_mode != Tree::SELECT_MULTI)
+ }
+ if (tree->select_mode != Tree::SELECT_MULTI) {
return;
+ }
tree->selected_item = this;
tree->selected_col = p_column;
tree->update();
}
void TreeItem::select(int p_column) {
-
ERR_FAIL_INDEX(p_column, cells.size());
_cell_selected(p_column);
}
void TreeItem::deselect(int p_column) {
-
ERR_FAIL_INDEX(p_column, cells.size());
_cell_deselected(p_column);
}
void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id, bool p_disabled, const String &p_tooltip) {
-
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_COND(!p_button.is_valid());
TreeItem::Cell::Button button;
button.texture = p_button;
- if (p_id < 0)
+ if (p_id < 0) {
p_id = cells[p_column].buttons.size();
+ }
button.id = p_id;
button.disabled = p_disabled;
button.tooltip = p_tooltip;
@@ -540,27 +496,29 @@ void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id
}
int TreeItem::get_button_count(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
return cells[p_column].buttons.size();
}
+
Ref<Texture2D> TreeItem::get_button(int p_column, int p_idx) const {
ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>());
ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture2D>());
return cells[p_column].buttons[p_idx].texture;
}
+
String TreeItem::get_button_tooltip(int p_column, int p_idx) const {
ERR_FAIL_INDEX_V(p_column, cells.size(), String());
ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), String());
return cells[p_column].buttons[p_idx].tooltip;
}
+
int TreeItem::get_button_id(int p_column, int p_idx) const {
ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), -1);
return cells[p_column].buttons[p_idx].id;
}
-void TreeItem::erase_button(int p_column, int p_idx) {
+void TreeItem::erase_button(int p_column, int p_idx) {
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
cells.write[p_column].buttons.remove(p_idx);
@@ -568,19 +526,17 @@ void TreeItem::erase_button(int p_column, int p_idx) {
}
int TreeItem::get_button_by_id(int p_column, int p_id) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
for (int i = 0; i < cells[p_column].buttons.size(); i++) {
-
- if (cells[p_column].buttons[i].id == p_id)
+ if (cells[p_column].buttons[i].id == p_id) {
return i;
+ }
}
return -1;
}
void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button) {
-
ERR_FAIL_COND(p_button.is_null());
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
@@ -589,7 +545,6 @@ void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture2D> &p_butto
}
void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) {
-
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
cells.write[p_column].buttons.write[p_idx].color = p_color;
@@ -597,7 +552,6 @@ void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) {
}
void TreeItem::set_button_disabled(int p_column, int p_idx, bool p_disabled) {
-
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
@@ -606,7 +560,6 @@ void TreeItem::set_button_disabled(int p_column, int p_idx, bool p_disabled) {
}
bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), false);
@@ -614,34 +567,32 @@ bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
}
void TreeItem::set_editable(int p_column, bool p_editable) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].editable = p_editable;
_changed_notify(p_column);
}
bool TreeItem::is_editable(int p_column) {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].editable;
}
void TreeItem::set_custom_color(int p_column, const Color &p_color) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].custom_color = true;
cells.write[p_column].color = p_color;
_changed_notify(p_column);
}
-Color TreeItem::get_custom_color(int p_column) const {
+Color TreeItem::get_custom_color(int p_column) const {
ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
- if (!cells[p_column].custom_color)
+ if (!cells[p_column].custom_color) {
return Color();
+ }
return cells[p_column].color;
}
-void TreeItem::clear_custom_color(int p_column) {
+void TreeItem::clear_custom_color(int p_column) {
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].custom_color = false;
cells.write[p_column].color = Color();
@@ -649,19 +600,16 @@ void TreeItem::clear_custom_color(int p_column) {
}
void TreeItem::set_tooltip(int p_column, const String &p_tooltip) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].tooltip = p_tooltip;
}
String TreeItem::get_tooltip(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), "");
return cells[p_column].tooltip;
}
void TreeItem::set_custom_bg_color(int p_column, const Color &p_color, bool p_bg_outline) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].custom_bg_color = true;
cells.write[p_column].custom_bg_outline = p_bg_outline;
@@ -670,7 +618,6 @@ void TreeItem::set_custom_bg_color(int p_column, const Color &p_color, bool p_bg
}
void TreeItem::clear_custom_bg_color(int p_column) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].custom_bg_color = false;
cells.write[p_column].bg_color = Color();
@@ -678,21 +625,19 @@ void TreeItem::clear_custom_bg_color(int p_column) {
}
Color TreeItem::get_custom_bg_color(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
- if (!cells[p_column].custom_bg_color)
+ if (!cells[p_column].custom_bg_color) {
return Color();
+ }
return cells[p_column].bg_color;
}
void TreeItem::set_custom_as_button(int p_column, bool p_button) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].custom_button = p_button;
}
bool TreeItem::is_custom_set_as_button(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].custom_button;
}
@@ -709,20 +654,17 @@ TreeItem::TextAlign TreeItem::get_text_align(int p_column) const {
}
void TreeItem::set_expand_right(int p_column, bool p_enable) {
-
ERR_FAIL_INDEX(p_column, cells.size());
cells.write[p_column].expand_right = p_enable;
_changed_notify(p_column);
}
bool TreeItem::get_expand_right(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].expand_right;
}
void TreeItem::set_disable_folding(bool p_disable) {
-
disable_folding = p_disable;
_changed_notify(0);
}
@@ -732,7 +674,6 @@ bool TreeItem::is_folding_disabled() const {
}
Variant TreeItem::_call_recursive_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 0;
@@ -769,7 +710,6 @@ void TreeItem::call_recursive(const StringName &p_method, const Variant **p_args
}
void TreeItem::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_cell_mode", "column", "mode"), &TreeItem::set_cell_mode);
ClassDB::bind_method(D_METHOD("get_cell_mode", "column"), &TreeItem::get_cell_mode);
@@ -887,10 +827,8 @@ void TreeItem::_bind_methods() {
}
void TreeItem::clear_children() {
-
TreeItem *c = children;
while (c) {
-
TreeItem *aux = c;
c = c->get_next();
aux->parent = nullptr; // so it won't try to recursively autoremove from me in here
@@ -901,7 +839,6 @@ void TreeItem::clear_children() {
};
TreeItem::TreeItem(Tree *p_tree) {
-
tree = p_tree;
collapsed = false;
disable_folding = false;
@@ -913,14 +850,13 @@ TreeItem::TreeItem(Tree *p_tree) {
}
TreeItem::~TreeItem() {
-
clear_children();
- if (parent)
+ if (parent) {
parent->remove_child(this);
+ }
if (tree && tree->root == this) {
-
tree->root = nullptr;
}
@@ -933,14 +869,17 @@ TreeItem::~TreeItem() {
tree->cache.hover_item = nullptr;
}
- if (tree && tree->selected_item == this)
+ if (tree && tree->selected_item == this) {
tree->selected_item = nullptr;
+ }
- if (tree && tree->drop_mode_over == this)
+ if (tree && tree->drop_mode_over == this) {
tree->drop_mode_over = nullptr;
+ }
- if (tree && tree->single_select_defer == this)
+ if (tree && tree->single_select_defer == this) {
tree->single_select_defer = nullptr;
+ }
if (tree && tree->edited_item == this) {
tree->edited_item = nullptr;
@@ -956,7 +895,6 @@ TreeItem::~TreeItem() {
/**********************************************/
void Tree::update_cache() {
-
cache.font = get_theme_font("font");
cache.tb_font = get_theme_font("title_button_font");
cache.bg = get_theme_stylebox("bg");
@@ -1001,45 +939,42 @@ void Tree::update_cache() {
}
int Tree::compute_item_height(TreeItem *p_item) const {
-
- if (p_item == root && hide_root)
+ if (p_item == root && hide_root) {
return 0;
+ }
ERR_FAIL_COND_V(cache.font.is_null(), 0);
int height = cache.font->get_height();
for (int i = 0; i < columns.size(); i++) {
-
for (int j = 0; j < p_item->cells[i].buttons.size(); j++) {
-
Size2i s; // = cache.button_pressed->get_minimum_size();
s += p_item->cells[i].buttons[j].texture->get_size();
- if (s.height > height)
+ if (s.height > height) {
height = s.height;
+ }
}
switch (p_item->cells[i].mode) {
-
case TreeItem::CELL_MODE_CHECK: {
-
int check_icon_h = cache.checked->get_height();
- if (height < check_icon_h)
+ if (height < check_icon_h) {
height = check_icon_h;
+ }
[[fallthrough]];
}
case TreeItem::CELL_MODE_STRING:
case TreeItem::CELL_MODE_CUSTOM:
case TreeItem::CELL_MODE_ICON: {
-
Ref<Texture2D> icon = p_item->cells[i].icon;
if (!icon.is_null()) {
-
Size2i s = p_item->cells[i].get_icon_size();
if (p_item->cells[i].icon_max_w > 0 && s.width > p_item->cells[i].icon_max_w) {
s.height = s.height * p_item->cells[i].icon_max_w / s.width;
}
- if (s.height > height)
+ if (s.height > height) {
height = s.height;
+ }
}
if (p_item->cells[i].mode == TreeItem::CELL_MODE_CUSTOM && p_item->cells[i].custom_button) {
height += cache.custom_button->get_minimum_size().height;
@@ -1051,8 +986,9 @@ int Tree::compute_item_height(TreeItem *p_item) const {
}
}
int item_min_height = p_item->get_custom_minimum_height();
- if (height < item_min_height)
+ if (height < item_min_height) {
height = item_min_height;
+ }
height += cache.vseparation;
@@ -1060,7 +996,6 @@ int Tree::compute_item_height(TreeItem *p_item) const {
}
int Tree::get_item_height(TreeItem *p_item) const {
-
int height = compute_item_height(p_item);
height += cache.vseparation;
@@ -1069,7 +1004,6 @@ int Tree::get_item_height(TreeItem *p_item) const {
TreeItem *c = p_item->children;
while (c) {
-
height += get_item_height(c);
c = c->next;
@@ -1080,14 +1014,14 @@ int Tree::get_item_height(TreeItem *p_item) const {
}
void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color) {
-
ERR_FAIL_COND(cache.font.is_null());
Rect2i rect = p_rect;
Ref<Font> font = cache.font;
String text = p_cell.text;
- if (p_cell.suffix != String())
+ if (p_cell.suffix != String()) {
text += " " + p_cell.suffix;
+ }
int w = 0;
if (!p_cell.icon.is_null()) {
@@ -1130,9 +1064,9 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co
}
int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) {
-
- if (p_pos.y - cache.offset.y > (p_draw_size.height))
+ if (p_pos.y - cache.offset.y > (p_draw_size.height)) {
return -1; //draw no more!
+ }
RID ci = get_canvas_item();
@@ -1148,7 +1082,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
bool skip = (p_item == root && hide_root);
if (!skip && (p_pos.y + label_h - cache.offset.y) > 0) {
-
//draw separation.
//if (p_item->get_parent()!=root || !hide_root)
@@ -1160,7 +1093,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
int ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
int skip2 = 0;
for (int i = 0; i < columns.size(); i++) {
-
if (skip2) {
skip2--;
continue;
@@ -1169,22 +1101,18 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
int w = get_column_width(i);
if (i == 0) {
-
w -= ofs;
if (w <= 0) {
-
ofs = get_column_width(0);
continue;
}
} else {
-
ofs += cache.hseparation;
w -= cache.hseparation;
}
if (p_item->cells[i].expand_right) {
-
int plus = 1;
while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text == "" && p_item->cells[i + plus].icon.is_null()) {
w += get_column_width(i + plus);
@@ -1197,8 +1125,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
for (int j = p_item->cells[i].buttons.size() - 1; j >= 0; j--) {
Ref<Texture2D> b = p_item->cells[i].buttons[j].texture;
Size2 s = b->get_size() + cache.button_pressed->get_minimum_size();
- if (s.height < label_h)
+ if (s.height < label_h) {
s.height = label_h;
+ }
Point2i o = Point2i(ofs + w - s.width, p_pos.y) - cache.offset + p_draw_ofs;
@@ -1227,15 +1156,15 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (i == 0) {
-
if (p_item->cells[0].selected && select_mode == SELECT_ROW) {
Rect2i row_rect = Rect2i(Point2i(cache.bg->get_margin(MARGIN_LEFT), item_rect.position.y), Size2i(get_size().width - cache.bg->get_minimum_size().width, item_rect.size.y));
//Rect2 r = Rect2i(row_rect.pos,row_rect.size);
//r.grow(cache.selected->get_margin(MARGIN_LEFT));
- if (has_focus())
+ if (has_focus()) {
cache.selected_focus->draw(ci, row_rect);
- else
+ } else {
cache.selected->draw(ci, row_rect);
+ }
}
}
@@ -1259,7 +1188,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (p_item->cells[i].custom_bg_color) {
-
Rect2 r = cell_rect;
if (i == 0) {
r.position.x = p_draw_ofs.x;
@@ -1279,7 +1207,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (drop_mode_flags && drop_mode_over == p_item) {
-
Rect2 r = cell_rect;
if (drop_mode_section == -1 || drop_mode_section == 0) {
@@ -1303,13 +1230,10 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
text_pos.y += Math::floor((item_rect.size.y - font->get_height()) / 2) + font_ascent;
switch (p_item->cells[i].mode) {
-
case TreeItem::CELL_MODE_STRING: {
-
draw_item_rect(p_item->cells[i], item_rect, col, icon_col);
} break;
case TreeItem::CELL_MODE_CHECK: {
-
Ref<Texture2D> checked = cache.checked;
Ref<Texture2D> unchecked = cache.unchecked;
Point2i check_ofs = item_rect.position;
@@ -1333,9 +1257,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
} break;
case TreeItem::CELL_MODE_RANGE: {
if (p_item->cells[i].text != "") {
-
- if (!p_item->cells[i].editable)
+ if (!p_item->cells[i].editable) {
break;
+ }
int option = (int)p_item->cells[i].val;
@@ -1352,8 +1276,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
}
- if (p_item->cells[i].suffix != String())
+ if (p_item->cells[i].suffix != String()) {
s += " " + p_item->cells[i].suffix;
+ }
Ref<Texture2D> downarrow = cache.select_arrow;
@@ -1365,18 +1290,19 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
downarrow->draw(ci, arrow_pos);
} else {
-
Ref<Texture2D> updown = cache.updown;
String valtext = String::num(p_item->cells[i].val, Math::range_step_decimals(p_item->cells[i].step));
- if (p_item->cells[i].suffix != String())
+ if (p_item->cells[i].suffix != String()) {
valtext += " " + p_item->cells[i].suffix;
+ }
font->draw(ci, text_pos, valtext, col, item_rect.size.x - updown->get_width());
- if (!p_item->cells[i].editable)
+ if (!p_item->cells[i].editable) {
break;
+ }
Point2i updown_pos = item_rect.position;
updown_pos.x += item_rect.size.x - updown->get_width();
@@ -1387,9 +1313,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
} break;
case TreeItem::CELL_MODE_ICON: {
-
- if (p_item->cells[i].icon.is_null())
+ if (p_item->cells[i].icon.is_null()) {
break;
+ }
Size2i icon_size = p_item->cells[i].get_icon_size();
if (p_item->cells[i].icon_max_w > 0 && icon_size.width > p_item->cells[i].icon_max_w) {
icon_size.height = icon_size.height * p_item->cells[i].icon_max_w / icon_size.width;
@@ -1403,16 +1329,14 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
} break;
case TreeItem::CELL_MODE_CUSTOM: {
-
if (p_item->cells[i].custom_draw_obj.is_valid()) {
-
Object *cdo = ObjectDB::get_instance(p_item->cells[i].custom_draw_obj);
- if (cdo)
+ if (cdo) {
cdo->call(p_item->cells[i].custom_draw_callback, p_item, Rect2(item_rect));
+ }
}
if (!p_item->cells[i].editable) {
-
draw_item_rect(p_item->cells[i], item_rect, col, icon_col);
break;
}
@@ -1449,19 +1373,17 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
if (i == 0) {
-
ofs = get_column_width(0);
} else {
-
ofs += w + bw;
}
if (select_mode == SELECT_MULTI && selected_item == p_item && selected_col == i) {
-
- if (has_focus())
+ if (has_focus()) {
cache.cursor->draw(ci, cell_rect);
- else
+ } else {
cache.cursor_unfocus->draw(ci, cell_rect);
+ }
}
}
@@ -1470,7 +1392,6 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
Ref<Texture2D> arrow;
if (p_item->collapsed) {
-
arrow = cache.arrow_collapsed;
} else {
arrow = cache.arrow;
@@ -1495,14 +1416,14 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
int prev_ofs = children_pos.y - cache.offset.y + p_draw_ofs.y;
while (c) {
-
if (cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root)) {
int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
- if (c->get_children() != nullptr)
+ if (c->get_children() != nullptr) {
root_pos -= Point2i(cache.arrow->get_width(), 0);
+ }
float line_width = 1.0;
#ifdef TOOLS_ENABLED
@@ -1546,11 +1467,11 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
int Tree::_count_selected_items(TreeItem *p_from) const {
-
int count = 0;
for (int i = 0; i < columns.size(); i++) {
- if (p_from->is_selected(i))
+ if (p_from->is_selected(i)) {
count++;
+ }
}
if (p_from->get_children()) {
@@ -1563,8 +1484,8 @@ int Tree::_count_selected_items(TreeItem *p_from) const {
return count;
}
-void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev, bool *r_in_range, bool p_force_deselect) {
+void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev, bool *r_in_range, bool p_force_deselect) {
TreeItem::Cell &selected_cell = p_selected->cells.write[p_col];
bool switched = false;
@@ -1576,14 +1497,13 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
bool emitted_row = false;
for (int i = 0; i < columns.size(); i++) {
-
TreeItem::Cell &c = p_current->cells.write[i];
- if (!c.selectable)
+ if (!c.selectable) {
continue;
+ }
if (select_mode == SELECT_ROW) {
-
if (p_selected == p_current && (!c.selected || allow_reselect)) {
c.selected = true;
selected_item = p_selected;
@@ -1598,45 +1518,40 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
*/
} else if (c.selected) {
-
c.selected = false;
//p_current->deselected_signal.call(p_col);
}
} else if (select_mode == SELECT_SINGLE || select_mode == SELECT_MULTI) {
-
if (!r_in_range && &selected_cell == &c) {
-
if (!selected_cell.selected || allow_reselect) {
-
selected_cell.selected = true;
selected_item = p_selected;
selected_col = i;
emit_signal("cell_selected");
- if (select_mode == SELECT_MULTI)
+ if (select_mode == SELECT_MULTI) {
emit_signal("multi_selected", p_current, i, true);
- else if (select_mode == SELECT_SINGLE)
+ } else if (select_mode == SELECT_SINGLE) {
emit_signal("item_selected");
+ }
} else if (select_mode == SELECT_MULTI && (selected_item != p_selected || selected_col != i)) {
-
selected_item = p_selected;
selected_col = i;
emit_signal("cell_selected");
}
} else {
-
if (r_in_range && *r_in_range && !p_force_deselect) {
-
if (!c.selected && c.selectable) {
c.selected = true;
emit_signal("multi_selected", p_current, i, true);
}
} else if (!r_in_range || p_force_deselect) {
- if (select_mode == SELECT_MULTI && c.selected)
+ if (select_mode == SELECT_MULTI && c.selected) {
emit_signal("multi_selected", p_current, i, false);
+ }
c.selected = false;
}
//p_current->deselected_signal.call(p_col);
@@ -1651,21 +1566,17 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
TreeItem *c = p_current->children;
while (c) {
-
select_single_item(p_selected, c, p_col, p_prev, r_in_range, p_current->is_collapsed() || p_force_deselect);
c = c->next;
}
}
Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) {
-
return Rect2();
}
void Tree::_range_click_timeout() {
-
if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
-
Point2 pos = get_local_mouse_position() - cache.bg->get_offset();
if (show_column_titles) {
pos.y -= _get_title_button_height();
@@ -1692,8 +1603,9 @@ void Tree::_range_click_timeout() {
range_click_timer->start();
}
- if (!click_handled)
+ if (!click_handled) {
range_click_timer->stop();
+ }
if (propagate_mouse_activated) {
emit_signal("item_activated");
@@ -1706,7 +1618,6 @@ void Tree::_range_click_timeout() {
}
int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod) {
-
int item_h = compute_item_height(p_item) + cache.vseparation;
bool skip = (p_item == root && hide_root);
@@ -1719,9 +1630,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
}
if (!p_item->disable_folding && !hide_folding && (p_pos.x >= x_ofs && p_pos.x < (x_ofs + cache.item_margin))) {
-
- if (p_item->children)
+ if (p_item->children) {
p_item->set_collapsed(!p_item->is_collapsed());
+ }
return -1; //handled!
}
@@ -1732,11 +1643,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
int col_ofs = 0;
int col_width = 0;
for (int i = 0; i < columns.size(); i++) {
-
col_width = get_column_width(i);
if (p_item->cells[i].expand_right) {
-
int plus = 1;
while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text == "" && p_item->cells[i + plus].icon.is_null()) {
col_width += cache.hseparation;
@@ -1755,16 +1664,15 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
break;
}
- if (col == -1)
+ if (col == -1) {
return -1;
- else if (col == 0) {
+ } else if (col == 0) {
int margin = x_ofs + cache.item_margin; //-cache.hseparation;
//int lm = cache.bg->get_margin(MARGIN_LEFT);
col_width -= margin;
col_ofs += margin;
x -= margin;
} else {
-
col_width -= cache.hseparation;
x -= cache.hseparation;
}
@@ -1815,9 +1723,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
}
if (select_mode == SELECT_MULTI && p_mod->get_command() && c.selectable) {
-
if (!c.selected || p_button == BUTTON_RIGHT) {
-
p_item->select(col);
emit_signal("multi_selected", p_item, col, true);
if (p_button == BUTTON_RIGHT) {
@@ -1826,18 +1732,14 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
//p_item->selected_signal.call(col);
} else {
-
p_item->deselect(col);
emit_signal("multi_selected", p_item, col, false);
//p_item->deselected_signal.call(col);
}
} else {
-
if (c.selectable) {
-
if (select_mode == SELECT_MULTI && p_mod->get_shift() && selected_item && selected_item != p_item) {
-
bool inrange = false;
select_single_item(p_item, root, col, selected_item, &inrange);
@@ -1845,14 +1747,12 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
emit_signal("item_rmb_selected", get_local_mouse_position());
}
} else {
-
int icount = _count_selected_items(root);
if (select_mode == SELECT_MULTI && icount > 1 && p_button != BUTTON_RIGHT) {
single_select_defer = p_item;
single_select_defer_column = col;
} else {
-
if (p_button != BUTTON_RIGHT || !c.selected) {
select_single_item(p_item, root, col);
}
@@ -1873,8 +1773,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
}
}
- if (!c.editable)
+ if (!c.editable) {
return -1; // if cell is not editable, don't bother
+ }
/* editing */
@@ -1882,7 +1783,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
String editor_text = c.text;
switch (c.mode) {
-
case TreeItem::CELL_MODE_STRING: {
//nothing in particular
@@ -1892,7 +1792,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} break;
case TreeItem::CELL_MODE_CHECK: {
-
bring_up_editor = false; //checkboxes are not edited with editor
if (force_edit_checkbox_only_on_checkbox) {
if (x < cache.checked->get_width()) {
@@ -1913,7 +1812,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
popup_menu->clear();
for (int i = 0; i < c.text.get_slice_count(","); i++) {
-
String s = c.text.get_slicec(',', i);
popup_menu->add_item(s.get_slicec(':', 0), s.get_slicec(':', 1).empty() ? i : s.get_slicec(':', 1).to_int());
}
@@ -1926,16 +1824,12 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
//}
bring_up_editor = false;
} else {
-
if (x >= (col_width - item_h / 2)) {
-
/* touching the combo */
bool up = p_pos.y < (item_h / 2);
if (p_button == BUTTON_LEFT) {
-
if (range_click_timer->get_time_left() == 0) {
-
range_item_last = p_item;
range_up_last = up;
@@ -1944,7 +1838,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
range_click_timer->start();
} else if (up != range_up_last) {
-
return -1; // break. avoid changing direction on mouse held
}
@@ -1953,15 +1846,12 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
item_edited(col, p_item);
} else if (p_button == BUTTON_RIGHT) {
-
p_item->set_range(col, (up ? c.max : c.min));
item_edited(col, p_item);
} else if (p_button == BUTTON_WHEEL_UP) {
-
p_item->set_range(col, c.val + c.step);
item_edited(col, p_item);
} else if (p_button == BUTTON_WHEEL_DOWN) {
-
p_item->set_range(col, c.val - c.step);
item_edited(col, p_item);
}
@@ -1970,10 +1860,10 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
bring_up_editor = false;
} else {
-
editor_text = String::num(p_item->cells[col].val, Math::range_step_decimals(p_item->cells[col].step));
- if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id)
+ if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id) {
bring_up_editor = false;
+ }
}
}
click_handled = true;
@@ -2001,8 +1891,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} break;
};
- if (!bring_up_editor || p_button != BUTTON_LEFT)
+ if (!bring_up_editor || p_button != BUTTON_LEFT) {
return -1;
+ }
click_handled = true;
popup_edited_item = p_item;
@@ -2014,7 +1905,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
return -1; //select
} else {
-
Point2i new_pos = p_pos;
if (!skip) {
@@ -2029,11 +1919,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
TreeItem *c = p_item->children;
while (c) {
-
int child_h = propagate_mouse_event(new_pos, x_ofs, y_ofs, p_doubleclick, c, p_button, p_mod);
- if (child_h < 0)
+ if (child_h < 0) {
return -1; // break, stop propagating, no need to anymore
+ }
new_pos.y -= child_h;
y_ofs += child_h;
@@ -2050,47 +1940,46 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
}
void Tree::_text_editor_modal_close() {
-
if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
Input::get_singleton()->is_key_pressed(KEY_KP_ENTER) ||
Input::get_singleton()->is_key_pressed(KEY_ENTER)) {
-
return;
}
- if (value_editor->has_point(value_editor->get_local_mouse_position()))
+ if (value_editor->has_point(value_editor->get_local_mouse_position())) {
return;
+ }
_text_editor_enter(text_editor->get_text());
}
void Tree::_text_editor_enter(String p_text) {
-
popup_editor->hide();
- if (!popup_edited_item)
+ if (!popup_edited_item) {
return;
+ }
- if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size())
+ if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size()) {
return;
+ }
TreeItem::Cell &c = popup_edited_item->cells.write[popup_edited_item_col];
switch (c.mode) {
-
case TreeItem::CELL_MODE_STRING: {
-
c.text = p_text;
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
case TreeItem::CELL_MODE_RANGE: {
-
c.val = p_text.to_double();
- if (c.step > 0)
+ if (c.step > 0) {
c.val = Math::stepify(c.val, c.step);
- if (c.val < c.min)
+ }
+ if (c.val < c.min) {
c.val = c.min;
- else if (c.val > c.max)
+ } else if (c.val > c.max) {
c.val = c.max;
+ }
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
@@ -2104,7 +1993,6 @@ void Tree::_text_editor_enter(String p_text) {
}
void Tree::value_editor_changed(double p_value) {
-
if (updating_value_editor) {
return;
}
@@ -2119,12 +2007,13 @@ void Tree::value_editor_changed(double p_value) {
}
void Tree::popup_select(int p_option) {
-
- if (!popup_edited_item)
+ if (!popup_edited_item) {
return;
+ }
- if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size())
+ if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size()) {
return;
+ }
popup_edited_item->cells.write[popup_edited_item_col].val = p_option;
//popup_edited_item->edited_signal.call( popup_edited_item_col );
@@ -2152,7 +2041,6 @@ void Tree::_go_left() {
selected_col--;
emit_signal("cell_selected");
} else {
-
selected_item->select(selected_col - 1);
}
}
@@ -2174,7 +2062,6 @@ void Tree::_go_right() {
selected_col++;
emit_signal("cell_selected");
} else {
-
selected_item->select(selected_col + 1);
}
}
@@ -2189,7 +2076,6 @@ void Tree::_go_up() {
prev = get_last_item();
selected_col = 0;
} else {
-
prev = selected_item->get_prev_visible();
if (last_keypress != 0) {
//incr search next
@@ -2203,19 +2089,20 @@ void Tree::_go_up() {
}
if (select_mode == SELECT_MULTI) {
-
- if (!prev)
+ if (!prev) {
return;
+ }
selected_item = prev;
emit_signal("cell_selected");
update();
} else {
-
int col = selected_col < 0 ? 0 : selected_col;
- while (prev && !prev->cells[col].selectable)
+ while (prev && !prev->cells[col].selectable) {
prev = prev->get_prev_visible();
- if (!prev)
+ }
+ if (!prev) {
return; // do nothing..
+ }
prev->select(col);
}
@@ -2226,12 +2113,10 @@ void Tree::_go_up() {
void Tree::_go_down() {
TreeItem *next = nullptr;
if (!selected_item) {
-
if (root) {
next = hide_root ? root->get_next_visible() : root;
}
} else {
-
next = selected_item->get_next_visible();
if (last_keypress != 0) {
@@ -2246,7 +2131,6 @@ void Tree::_go_down() {
}
if (select_mode == SELECT_MULTI) {
-
if (!next) {
return;
}
@@ -2255,11 +2139,11 @@ void Tree::_go_down() {
emit_signal("cell_selected");
update();
} else {
-
int col = selected_col < 0 ? 0 : selected_col;
- while (next && !next->cells[col].selectable)
+ while (next && !next->cells[col].selectable) {
next = next->get_next_visible();
+ }
if (!next) {
return; // do nothing..
}
@@ -2271,14 +2155,13 @@ void Tree::_go_down() {
}
void Tree::_gui_input(Ref<InputEvent> p_event) {
-
Ref<InputEventKey> k = p_event;
bool is_command = k.is_valid() && k->get_command();
if (p_event->is_action("ui_right") && p_event->is_pressed()) {
-
- if (!cursor_can_exit_tree)
+ if (!cursor_can_exit_tree) {
accept_event();
+ }
if (!selected_item || select_mode == SELECT_ROW || selected_col > (columns.size() - 1)) {
return;
@@ -2294,9 +2177,9 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
_go_right();
}
} else if (p_event->is_action("ui_left") && p_event->is_pressed()) {
-
- if (!cursor_can_exit_tree)
+ if (!cursor_can_exit_tree) {
accept_event();
+ }
if (!selected_item || select_mode == SELECT_ROW || selected_col < 0) {
return;
@@ -2314,51 +2197,50 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
} else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) {
-
- if (!cursor_can_exit_tree)
+ if (!cursor_can_exit_tree) {
accept_event();
+ }
_go_up();
} else if (p_event->is_action("ui_down") && p_event->is_pressed() && !is_command) {
-
- if (!cursor_can_exit_tree)
+ if (!cursor_can_exit_tree) {
accept_event();
+ }
_go_down();
} else if (p_event->is_action("ui_page_down") && p_event->is_pressed()) {
-
- if (!cursor_can_exit_tree)
+ if (!cursor_can_exit_tree) {
accept_event();
+ }
TreeItem *next = nullptr;
- if (!selected_item)
+ if (!selected_item) {
return;
+ }
next = selected_item;
for (int i = 0; i < 10; i++) {
-
TreeItem *_n = next->get_next_visible();
if (_n) {
next = _n;
} else {
-
break;
}
}
- if (next == selected_item)
+ if (next == selected_item) {
return;
+ }
if (select_mode == SELECT_MULTI) {
-
selected_item = next;
emit_signal("cell_selected");
update();
} else {
-
- while (next && !next->cells[selected_col].selectable)
+ while (next && !next->cells[selected_col].selectable) {
next = next->get_next_visible();
+ }
if (!next) {
return; // do nothing..
}
@@ -2367,37 +2249,36 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
ensure_cursor_is_visible();
} else if (p_event->is_action("ui_page_up") && p_event->is_pressed()) {
-
- if (!cursor_can_exit_tree)
+ if (!cursor_can_exit_tree) {
accept_event();
+ }
TreeItem *prev = nullptr;
- if (!selected_item)
+ if (!selected_item) {
return;
+ }
prev = selected_item;
for (int i = 0; i < 10; i++) {
-
TreeItem *_n = prev->get_prev_visible();
if (_n) {
prev = _n;
} else {
-
break;
}
}
- if (prev == selected_item)
+ if (prev == selected_item) {
return;
+ }
if (select_mode == SELECT_MULTI) {
-
selected_item = prev;
emit_signal("cell_selected");
update();
} else {
-
- while (prev && !prev->cells[selected_col].selectable)
+ while (prev && !prev->cells[selected_col].selectable) {
prev = prev->get_prev_visible();
+ }
if (!prev) {
return; // do nothing..
}
@@ -2405,7 +2286,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
ensure_cursor_is_visible();
} else if (p_event->is_action("ui_accept") && p_event->is_pressed()) {
-
if (selected_item) {
//bring up editor if possible
if (!edit_selected()) {
@@ -2415,10 +2295,10 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
accept_event();
} else if (p_event->is_action("ui_select") && p_event->is_pressed()) {
-
if (select_mode == SELECT_MULTI) {
- if (!selected_item)
+ if (!selected_item) {
return;
+ }
if (selected_item->is_selected(selected_col)) {
selected_item->deselect(selected_col);
emit_signal("multi_selected", selected_item, selected_col, false);
@@ -2432,34 +2312,38 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
if (k.is_valid()) { // Incremental search
- if (!k->is_pressed())
+ if (!k->is_pressed()) {
return;
- if (k->get_command() || (k->get_shift() && k->get_unicode() == 0) || k->get_metakey())
+ }
+ if (k->get_command() || (k->get_shift() && k->get_unicode() == 0) || k->get_metakey()) {
return;
- if (!root)
+ }
+ if (!root) {
return;
+ }
- if (hide_root && !root->get_next_visible())
+ if (hide_root && !root->get_next_visible()) {
return;
+ }
if (k->get_unicode() > 0) {
-
_do_incr_search(String::chr(k->get_unicode()));
accept_event();
return;
} else {
- if (k->get_keycode() != KEY_SHIFT)
+ if (k->get_keycode() != KEY_SHIFT) {
last_keypress = 0;
+ }
}
}
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
- if (cache.font.is_null()) // avoid a strange case that may corrupt stuff
+ if (cache.font.is_null()) { // avoid a strange case that may corrupt stuff
update_cache();
+ }
Ref<StyleBox> bg = cache.bg;
@@ -2476,13 +2360,10 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
pos.x += cache.offset.x;
int len = 0;
for (int i = 0; i < columns.size(); i++) {
-
len += get_column_width(i);
if (pos.x < len) {
-
cache.hover_type = Cache::CLICK_TITLE;
cache.hover_index = i;
- update();
break;
}
}
@@ -2490,16 +2371,19 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
if (root) {
-
Point2 mpos = mm->get_position();
mpos -= cache.bg->get_offset();
mpos.y -= _get_title_button_height();
if (mpos.y >= 0) {
-
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
mpos.x += h_scroll->get_value();
- if (v_scroll->is_visible_in_tree())
+ }
+ if (v_scroll->is_visible_in_tree()) {
mpos.y += v_scroll->get_value();
+ }
+
+ TreeItem *old_it = cache.hover_item;
+ int old_col = cache.hover_cell;
int col, h, section;
TreeItem *it = _find_item_at_pos(root, mpos, col, h, section);
@@ -2515,18 +2399,21 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
}
- if (it != cache.hover_item) {
- cache.hover_item = it;
- update();
- }
+ cache.hover_item = it;
+ cache.hover_cell = col;
- if (it && col != cache.hover_cell) {
- cache.hover_cell = col;
- update();
+ if (it != old_it || col != old_col) {
+ // Only need to update if mouse enters/exits a button
+ bool was_over_button = old_it && old_it->cells[old_col].custom_button;
+ bool is_over_button = it && it->cells[col].custom_button;
+ if (was_over_button || is_over_button) {
+ update();
+ }
}
}
}
+ // Update if mouse enters/exits columns
if (cache.hover_type != old_hover || cache.hover_index != old_index) {
update();
}
@@ -2535,7 +2422,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
//range drag
if (!range_drag_enabled) {
-
Vector2 cpos = mm->get_position();
if (cpos.distance_to(pressing_pos) > 2) {
range_drag_enabled = true;
@@ -2544,7 +2430,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
}
} else {
-
const TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col];
float diff_y = -mm->get_relative().y;
diff_y = Math::pow(ABS(diff_y), 1.8f) * SGN(diff_y);
@@ -2556,7 +2441,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
if (drag_touching && !drag_touching_deaccel) {
-
drag_accum -= mm->get_relative().y;
v_scroll->set_value(drag_from + drag_accum);
drag_speed = -mm->get_speed().y;
@@ -2566,13 +2450,12 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
- if (cache.font.is_null()) // avoid a strange case that may corrupt stuff
+ if (cache.font.is_null()) { // avoid a strange case that may corrupt stuff
update_cache();
+ }
if (!b->is_pressed()) {
-
if (b->get_button_index() == BUTTON_LEFT) {
-
Point2 pos = b->get_position() - cache.bg->get_offset();
if (show_column_titles) {
pos.y -= _get_title_button_height();
@@ -2581,7 +2464,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
pos.x += cache.offset.x;
int len = 0;
for (int i = 0; i < columns.size(); i++) {
-
len += get_column_width(i);
if (pos.x < len) {
emit_signal("column_title_pressed", i);
@@ -2599,9 +2481,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
range_click_timer->stop();
if (pressing_for_editor) {
-
if (range_drag_enabled) {
-
range_drag_enabled = false;
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
@@ -2630,13 +2510,11 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
cache.click_column = 0;
if (drag_touching) {
-
if (drag_speed == 0) {
drag_touching_deaccel = false;
drag_touching = false;
set_physics_process_internal(false);
} else {
-
drag_touching_deaccel = true;
}
}
@@ -2645,8 +2523,9 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
return;
}
- if (range_drag_enabled)
+ if (range_drag_enabled) {
return;
+ }
switch (b->get_button_index()) {
case BUTTON_RIGHT:
@@ -2663,10 +2542,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
pos.x += cache.offset.x;
int len = 0;
for (int i = 0; i < columns.size(); i++) {
-
len += get_column_width(i);
if (pos.x < len) {
-
cache.click_type = Cache::CLICK_TITLE;
cache.click_index = i;
//cache.click_id=;
@@ -2697,8 +2574,9 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
pressing_pos = b->get_position();
}
- if (b->get_button_index() == BUTTON_RIGHT)
+ if (b->get_button_index() == BUTTON_RIGHT) {
break;
+ }
if (drag_touching) {
set_physics_process_internal(false);
@@ -2720,8 +2598,9 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
if (b->get_button_index() == BUTTON_LEFT) {
- if (get_item_at_position(b->get_position()) == nullptr && !b->get_shift() && !b->get_control() && !b->get_command())
+ if (get_item_at_position(b->get_position()) == nullptr && !b->get_shift() && !b->get_control() && !b->get_command()) {
emit_signal("nothing_selected");
+ }
}
}
@@ -2732,7 +2611,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
} break;
case BUTTON_WHEEL_UP: {
-
double prev_value = v_scroll->get_value();
v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8);
if (v_scroll->get_value() != prev_value) {
@@ -2741,7 +2619,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
} break;
case BUTTON_WHEEL_DOWN: {
-
double prev_value = v_scroll->get_value();
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b->get_factor() / 8);
if (v_scroll->get_value() != prev_value) {
@@ -2754,7 +2631,6 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventPanGesture> pan_gesture = p_event;
if (pan_gesture.is_valid()) {
-
double prev_v = v_scroll->get_value();
v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
@@ -2768,15 +2644,15 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
bool Tree::edit_selected() {
-
TreeItem *s = get_selected();
ERR_FAIL_COND_V_MSG(!s, false, "No item selected.");
ensure_cursor_is_visible();
int col = get_selected_column();
ERR_FAIL_INDEX_V_MSG(col, columns.size(), false, "No item column selected.");
- if (!s->cells[col].editable)
+ if (!s->cells[col].editable) {
return false;
+ }
Rect2 rect = s->get_meta("__focus_rect");
popup_edited_item = s;
@@ -2785,12 +2661,10 @@ bool Tree::edit_selected() {
const TreeItem::Cell &c = s->cells[col];
if (c.mode == TreeItem::CELL_MODE_CHECK) {
-
s->set_checked(col, !c.checked);
item_edited(col, s);
return true;
} else if (c.mode == TreeItem::CELL_MODE_CUSTOM) {
-
edited_item = s;
edited_col = col;
custom_popup_rect = Rect2i(get_global_position() + rect.position, rect.size);
@@ -2799,10 +2673,8 @@ bool Tree::edit_selected() {
return true;
} else if (c.mode == TreeItem::CELL_MODE_RANGE && c.text != "") {
-
popup_menu->clear();
for (int i = 0; i < c.text.get_slice_count(","); i++) {
-
String s2 = c.text.get_slicec(',', i);
popup_menu->add_item(s2.get_slicec(':', 0), s2.get_slicec(':', 1).empty() ? i : s2.get_slicec(':', 1).to_int());
}
@@ -2815,7 +2687,6 @@ bool Tree::edit_selected() {
return true;
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE) {
-
Rect2 popup_rect;
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
@@ -2829,7 +2700,6 @@ bool Tree::edit_selected() {
text_editor->select_all();
if (c.mode == TreeItem::CELL_MODE_RANGE) {
-
popup_rect.size.y += value_editor->get_minimum_size().height;
value_editor->show();
@@ -2858,12 +2728,11 @@ bool Tree::edit_selected() {
}
Size2 Tree::get_internal_min_size() const {
-
Size2i size = cache.bg->get_offset();
- if (root)
+ if (root) {
size.height += get_item_height(root);
+ }
for (int i = 0; i < columns.size(); i++) {
-
size.width += columns[i].min_width;
}
@@ -2871,13 +2740,11 @@ Size2 Tree::get_internal_min_size() const {
}
void Tree::update_scrollbars() {
-
Size2 size = get_size();
int tbh;
if (show_column_titles) {
tbh = _get_title_button_height();
} else {
-
tbh = 0;
}
@@ -2893,11 +2760,9 @@ void Tree::update_scrollbars() {
Size2 min = get_internal_min_size();
if (min.height < size.height - hmin.height) {
-
v_scroll->hide();
cache.offset.y = 0;
} else {
-
v_scroll->show();
v_scroll->set_max(min.height);
v_scroll->set_page(size.height - hmin.height - tbh);
@@ -2905,11 +2770,9 @@ void Tree::update_scrollbars() {
}
if (min.width < size.width - vmin.width) {
-
h_scroll->hide();
cache.offset.x = 0;
} else {
-
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
@@ -2918,19 +2781,15 @@ void Tree::update_scrollbars() {
}
int Tree::_get_title_button_height() const {
-
ERR_FAIL_COND_V(cache.font.is_null() || cache.title_button.is_null(), 0);
return show_column_titles ? cache.font->get_height() + cache.title_button->get_minimum_size().height : 0;
}
void Tree::_notification(int p_what) {
-
if (p_what == NOTIFICATION_FOCUS_ENTER) {
-
focus_in_id = get_tree()->get_event_count();
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {
-
if (cache.hover_type != Cache::CLICK_NONE) {
cache.hover_type = Cache::CLICK_NONE;
update();
@@ -2938,23 +2797,19 @@ void Tree::_notification(int p_what) {
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
-
drag_touching = false;
}
if (p_what == NOTIFICATION_ENTER_TREE) {
-
update_cache();
}
if (p_what == NOTIFICATION_DRAG_END) {
-
drop_mode_flags = 0;
scrolling = false;
set_physics_process_internal(false);
update();
}
if (p_what == NOTIFICATION_DRAG_BEGIN) {
-
single_select_defer = nullptr;
if (cache.scroll_speed > 0) {
scrolling = true;
@@ -2962,11 +2817,8 @@ void Tree::_notification(int p_what) {
}
}
if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
-
if (drag_touching) {
-
if (drag_touching_deaccel) {
-
float pos = v_scroll->get_value();
pos += drag_speed * get_physics_process_delta_time();
@@ -3025,7 +2877,6 @@ void Tree::_notification(int p_what) {
}
if (p_what == NOTIFICATION_DRAW) {
-
update_cache();
update_scrollbars();
RID ci = get_canvas_item();
@@ -3050,16 +2901,13 @@ void Tree::_notification(int p_what) {
draw_size.y -= tbh;
if (root) {
-
draw_item(Point2(), draw_ofs, draw_size, root);
}
if (show_column_titles) {
-
//title buttons
int ofs2 = cache.bg->get_margin(MARGIN_LEFT);
for (int i = 0; i < columns.size(); i++) {
-
Ref<StyleBox> sb = (cache.click_type == Cache::CLICK_TITLE && cache.click_index == i) ? cache.title_button_pressed : ((cache.hover_type == Cache::CLICK_TITLE && cache.hover_index == i) ? cache.title_button_hover : cache.title_button);
Ref<Font> f = cache.tb_font;
Rect2 tbrect = Rect2(ofs2 - cache.offset.x, bg->get_margin(MARGIN_TOP), get_column_width(i), tbh);
@@ -3077,7 +2925,6 @@ void Tree::_notification(int p_what) {
}
if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) {
-
if (popup_edited_item != nullptr) {
Rect2 rect = popup_edited_item->get_meta("__focus_rect");
Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
@@ -3093,18 +2940,15 @@ void Tree::_notification(int p_what) {
}
Size2 Tree::get_minimum_size() const {
-
return Size2(1, 1);
}
TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) {
-
ERR_FAIL_COND_V(blocked > 0, nullptr);
TreeItem *ti = nullptr;
if (p_parent) {
-
// Append or insert a new item to the given parent.
ti = memnew(TreeItem(this));
ERR_FAIL_COND_V(!ti, nullptr);
@@ -3123,14 +2967,14 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) {
c = c->next;
}
- if (prev)
+ if (prev) {
prev->next = ti;
- else
+ } else {
p_parent->children = ti;
+ }
ti->parent = p_parent;
} else {
-
if (!root) {
// No root exists, make the given item the new root.
ti = memnew(TreeItem(this));
@@ -3148,61 +2992,56 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) {
}
TreeItem *Tree::get_root() {
-
return root;
}
-TreeItem *Tree::get_last_item() {
+TreeItem *Tree::get_last_item() {
TreeItem *last = root;
while (last) {
-
- if (last->next)
+ if (last->next) {
last = last->next;
- else if (last->children)
+ } else if (last->children) {
last = last->children;
- else
+ } else {
break;
+ }
}
return last;
}
void Tree::item_edited(int p_column, TreeItem *p_item, bool p_lmb) {
-
edited_item = p_item;
edited_col = p_column;
- if (p_lmb)
+ if (p_lmb) {
emit_signal("item_edited");
- else
+ } else {
emit_signal("item_rmb_edited");
+ }
}
void Tree::item_changed(int p_column, TreeItem *p_item) {
-
update();
}
void Tree::item_selected(int p_column, TreeItem *p_item) {
-
if (select_mode == SELECT_MULTI) {
-
- if (!p_item->cells[p_column].selectable)
+ if (!p_item->cells[p_column].selectable) {
return;
+ }
p_item->cells.write[p_column].selected = true;
//emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select
selected_col = p_column;
} else {
-
select_single_item(p_item, root, p_column);
}
update();
}
void Tree::item_deselected(int p_column, TreeItem *p_item) {
-
if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) {
p_item->cells.write[p_column].selected = false;
}
@@ -3210,17 +3049,14 @@ void Tree::item_deselected(int p_column, TreeItem *p_item) {
}
void Tree::set_select_mode(SelectMode p_mode) {
-
select_mode = p_mode;
}
Tree::SelectMode Tree::get_select_mode() const {
-
return select_mode;
}
void Tree::deselect_all() {
-
TreeItem *item = get_next_selected(get_root());
while (item) {
item->deselect(selected_col);
@@ -3236,12 +3072,10 @@ void Tree::deselect_all() {
}
bool Tree::is_anything_selected() {
-
return (selected_item != nullptr);
}
void Tree::clear() {
-
ERR_FAIL_COND(blocked > 0);
if (pressing_for_editor) {
@@ -3266,27 +3100,25 @@ void Tree::clear() {
};
void Tree::set_hide_root(bool p_enabled) {
-
hide_root = p_enabled;
update();
}
bool Tree::is_root_hidden() const {
-
return hide_root;
}
void Tree::set_column_min_width(int p_column, int p_min_width) {
-
ERR_FAIL_INDEX(p_column, columns.size());
- if (p_min_width < 1)
+ if (p_min_width < 1) {
return;
+ }
columns.write[p_column].min_width = p_min_width;
update();
}
-void Tree::set_column_expand(int p_column, bool p_expand) {
+void Tree::set_column_expand(int p_column, bool p_expand) {
ERR_FAIL_INDEX(p_column, columns.size());
columns.write[p_column].expand = p_expand;
@@ -3294,87 +3126,80 @@ void Tree::set_column_expand(int p_column, bool p_expand) {
}
TreeItem *Tree::get_selected() const {
-
return selected_item;
}
int Tree::get_selected_column() const {
-
return selected_col;
}
TreeItem *Tree::get_edited() const {
-
return edited_item;
}
int Tree::get_edited_column() const {
-
return edited_col;
}
TreeItem *Tree::get_next_selected(TreeItem *p_item) {
-
/*
if (!p_item)
return nullptr;
*/
- if (!root)
+ if (!root) {
return nullptr;
+ }
while (true) {
-
if (!p_item) {
p_item = root;
} else {
-
if (p_item->children) {
-
p_item = p_item->children;
} else if (p_item->next) {
-
p_item = p_item->next;
} else {
-
while (!p_item->next) {
-
p_item = p_item->parent;
- if (p_item == nullptr)
+ if (p_item == nullptr) {
return nullptr;
+ }
}
p_item = p_item->next;
}
}
- for (int i = 0; i < columns.size(); i++)
- if (p_item->cells[i].selected)
+ for (int i = 0; i < columns.size(); i++) {
+ if (p_item->cells[i].selected) {
return p_item;
+ }
+ }
}
return nullptr;
}
int Tree::get_column_width(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, columns.size(), -1);
- if (!columns[p_column].expand)
+ if (!columns[p_column].expand) {
return columns[p_column].min_width;
+ }
Ref<StyleBox> bg = cache.bg;
int expand_area = get_size().width - (bg->get_margin(MARGIN_LEFT) + bg->get_margin(MARGIN_RIGHT));
- if (v_scroll->is_visible_in_tree())
+ if (v_scroll->is_visible_in_tree()) {
expand_area -= v_scroll->get_combined_minimum_size().width;
+ }
int expanding_columns = 0;
int expanding_total = 0;
for (int i = 0; i < columns.size(); i++) {
-
if (!columns[i].expand) {
expand_area -= columns[i].min_width;
} else {
@@ -3383,8 +3208,9 @@ int Tree::get_column_width(int p_column) const {
}
}
- if (expand_area < expanding_total)
+ if (expand_area < expanding_total) {
return columns[p_column].min_width;
+ }
ERR_FAIL_COND_V(expanding_columns == 0, -1); // shouldn't happen
@@ -3392,56 +3218,52 @@ int Tree::get_column_width(int p_column) const {
}
void Tree::propagate_set_columns(TreeItem *p_item) {
-
p_item->cells.resize(columns.size());
TreeItem *c = p_item->get_children();
while (c) {
-
propagate_set_columns(c);
c = c->get_next();
}
}
void Tree::set_columns(int p_columns) {
-
ERR_FAIL_COND(p_columns < 1);
ERR_FAIL_COND(blocked > 0);
columns.resize(p_columns);
- if (root)
+ if (root) {
propagate_set_columns(root);
- if (selected_col >= p_columns)
+ }
+ if (selected_col >= p_columns) {
selected_col = p_columns - 1;
+ }
update();
}
int Tree::get_columns() const {
-
return columns.size();
}
void Tree::_scroll_moved(float) {
-
update();
}
Rect2 Tree::get_custom_popup_rect() const {
-
return custom_popup_rect;
}
int Tree::get_item_offset(TreeItem *p_item) const {
-
TreeItem *it = root;
int ofs = _get_title_button_height();
- if (!it)
+ if (!it) {
return 0;
+ }
while (true) {
-
- if (it == p_item)
+ if (it == p_item) {
return ofs;
+ }
ofs += compute_item_height(it);
if (it != root || !hide_root) {
@@ -3449,19 +3271,16 @@ int Tree::get_item_offset(TreeItem *p_item) const {
}
if (it->children && !it->collapsed) {
-
it = it->children;
} else if (it->next) {
-
it = it->next;
} else {
-
while (!it->next) {
-
it = it->parent;
- if (it == nullptr)
+ if (it == nullptr) {
return 0;
+ }
}
it = it->next;
@@ -3518,12 +3337,10 @@ void Tree::ensure_cursor_is_visible() {
}
int Tree::get_pressed_button() const {
-
return pressed_button;
}
Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column) const {
-
ERR_FAIL_NULL_V(p_item, Rect2());
ERR_FAIL_COND_V(p_item->tree != this, Rect2());
if (p_column != -1) {
@@ -3540,7 +3357,6 @@ Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column) const {
r.position.x = 0;
r.size.x = get_size().width;
} else {
-
int accum = 0;
for (int i = 0; i < p_column; i++) {
accum += get_column_width(i);
@@ -3553,43 +3369,38 @@ Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column) const {
}
void Tree::set_column_titles_visible(bool p_show) {
-
show_column_titles = p_show;
update();
}
bool Tree::are_column_titles_visible() const {
-
return show_column_titles;
}
void Tree::set_column_title(int p_column, const String &p_title) {
-
ERR_FAIL_INDEX(p_column, columns.size());
columns.write[p_column].title = p_title;
update();
}
String Tree::get_column_title(int p_column) const {
-
ERR_FAIL_INDEX_V(p_column, columns.size(), "");
return columns[p_column].title;
}
Point2 Tree::get_scroll() const {
-
Point2 ofs;
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
ofs.x = h_scroll->get_value();
- if (v_scroll->is_visible_in_tree())
+ }
+ if (v_scroll->is_visible_in_tree()) {
ofs.y = v_scroll->get_value();
+ }
return ofs;
}
void Tree::scroll_to_item(TreeItem *p_item) {
-
if (!is_visible_in_tree()) {
-
// hack to work around crash in get_item_rect() if Tree is not in tree.
return;
}
@@ -3607,38 +3418,40 @@ void Tree::scroll_to_item(TreeItem *p_item) {
}
TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) {
-
TreeItem *from = p_at;
while (p_at) {
-
for (int i = 0; i < columns.size(); i++) {
if (p_at->get_text(i).findn(p_find) == 0 && (!p_selectable || p_at->is_selectable(i))) {
- if (r_col)
+ if (r_col) {
*r_col = i;
+ }
return p_at;
}
}
- if (p_backwards)
+ if (p_backwards) {
p_at = p_at->get_prev_visible(true);
- else
+ } else {
p_at = p_at->get_next_visible(true);
+ }
- if ((p_at) == from)
+ if ((p_at) == from) {
break;
+ }
}
return nullptr;
}
TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_selectable) {
-
TreeItem *from = get_selected();
- if (!from)
+ if (!from) {
from = root;
- if (!from)
+ }
+ if (!from) {
return nullptr;
+ }
return _search_item_text(from->get_next_visible(true), p_find, r_col, p_selectable);
}
@@ -3655,33 +3468,31 @@ TreeItem *Tree::get_item_with_text(const String &p_find) const {
}
void Tree::_do_incr_search(const String &p_add) {
-
uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec
uint64_t diff = time - last_keypress;
- if (diff > uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000)))
+ if (diff > uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000))) {
incr_search = p_add;
- else if (incr_search != p_add)
+ } else if (incr_search != p_add) {
incr_search += p_add;
+ }
last_keypress = time;
int col;
TreeItem *item = search_item_text(incr_search, &col, true);
- if (!item)
+ if (!item) {
return;
+ }
item->select(col);
ensure_cursor_is_visible();
}
TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int &section) const {
-
Point2 pos = p_pos;
if (root != p_item || !hide_root) {
-
h = compute_item_height(p_item) + cache.vseparation;
if (pos.y < h) {
-
if (drop_mode_flags == DROP_MODE_ON_ITEM) {
section = 0;
} else if (drop_mode_flags == DROP_MODE_INBETWEEN) {
@@ -3695,7 +3506,6 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
}
for (int i = 0; i < columns.size(); i++) {
-
int w = get_column_width(i);
if (pos.x < w) {
r_column = i;
@@ -3707,26 +3517,25 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
return nullptr;
} else {
-
pos.y -= h;
}
} else {
-
h = 0;
}
- if (p_item->is_collapsed())
+ if (p_item->is_collapsed()) {
return nullptr; // do not try children, it's collapsed
+ }
TreeItem *n = p_item->get_children();
while (n) {
-
int ch;
TreeItem *r = _find_item_at_pos(n, pos, r_column, ch, section);
pos.y -= ch;
h += ch;
- if (r)
+ if (r) {
return r;
+ }
n = n->get_next();
}
@@ -3734,19 +3543,20 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
}
int Tree::get_column_at_position(const Point2 &p_pos) const {
-
if (root) {
-
Point2 pos = p_pos;
pos -= cache.bg->get_offset();
pos.y -= _get_title_button_height();
- if (pos.y < 0)
+ if (pos.y < 0) {
return -1;
+ }
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
pos.x += h_scroll->get_value();
- if (v_scroll->is_visible_in_tree())
+ }
+ if (v_scroll->is_visible_in_tree()) {
pos.y += v_scroll->get_value();
+ }
int col, h, section;
TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
@@ -3760,19 +3570,20 @@ int Tree::get_column_at_position(const Point2 &p_pos) const {
}
int Tree::get_drop_section_at_position(const Point2 &p_pos) const {
-
if (root) {
-
Point2 pos = p_pos;
pos -= cache.bg->get_offset();
pos.y -= _get_title_button_height();
- if (pos.y < 0)
+ if (pos.y < 0) {
return -100;
+ }
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
pos.x += h_scroll->get_value();
- if (v_scroll->is_visible_in_tree())
+ }
+ if (v_scroll->is_visible_in_tree()) {
pos.y += v_scroll->get_value();
+ }
int col, h, section;
TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
@@ -3784,26 +3595,27 @@ int Tree::get_drop_section_at_position(const Point2 &p_pos) const {
return -100;
}
-TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
+TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
if (root) {
-
Point2 pos = p_pos;
pos -= cache.bg->get_offset();
pos.y -= _get_title_button_height();
- if (pos.y < 0)
+ if (pos.y < 0) {
return nullptr;
+ }
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
pos.x += h_scroll->get_value();
- if (v_scroll->is_visible_in_tree())
+ }
+ if (v_scroll->is_visible_in_tree()) {
pos.y += v_scroll->get_value();
+ }
int col, h, section;
TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
if (it) {
-
return it;
}
}
@@ -3812,30 +3624,31 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
}
String Tree::get_tooltip(const Point2 &p_pos) const {
-
if (root) {
-
Point2 pos = p_pos;
pos -= cache.bg->get_offset();
pos.y -= _get_title_button_height();
- if (pos.y < 0)
+ if (pos.y < 0) {
return Control::get_tooltip(p_pos);
+ }
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree()) {
pos.x += h_scroll->get_value();
- if (v_scroll->is_visible_in_tree())
+ }
+ if (v_scroll->is_visible_in_tree()) {
pos.y += v_scroll->get_value();
+ }
int col, h, section;
TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
if (it) {
-
const TreeItem::Cell &c = it->cells[col];
int col_width = get_column_width(col);
- for (int i = 0; i < col; i++)
+ for (int i = 0; i < col; i++) {
pos.x -= get_column_width(i);
+ }
for (int j = c.buttons.size() - 1; j >= 0; j--) {
Ref<Texture2D> b = c.buttons[j].texture;
@@ -3849,10 +3662,11 @@ String Tree::get_tooltip(const Point2 &p_pos) const {
col_width -= size.width;
}
String ret;
- if (it->get_tooltip(col) == "")
+ if (it->get_tooltip(col) == "") {
ret = it->get_text(col);
- else
+ } else {
ret = it->get_tooltip(col);
+ }
return ret;
}
}
@@ -3861,12 +3675,10 @@ String Tree::get_tooltip(const Point2 &p_pos) const {
}
void Tree::set_cursor_can_exit_tree(bool p_enable) {
-
cursor_can_exit_tree = p_enable;
}
bool Tree::can_cursor_exit_tree() const {
-
return cursor_can_exit_tree;
}
@@ -3876,13 +3688,13 @@ void Tree::set_hide_folding(bool p_hide) {
}
bool Tree::is_folding_hidden() const {
-
return hide_folding;
}
void Tree::set_drop_mode_flags(int p_flags) {
- if (drop_mode_flags == p_flags)
+ if (drop_mode_flags == p_flags) {
return;
+ }
drop_mode_flags = p_flags;
if (drop_mode_flags == 0) {
drop_mode_over = nullptr;
@@ -3892,27 +3704,22 @@ void Tree::set_drop_mode_flags(int p_flags) {
}
int Tree::get_drop_mode_flags() const {
-
return drop_mode_flags;
}
void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {
-
force_edit_checkbox_only_on_checkbox = p_enable;
}
bool Tree::get_edit_checkbox_cell_only_when_checkbox_is_pressed() const {
-
return force_edit_checkbox_only_on_checkbox;
}
void Tree::set_allow_rmb_select(bool p_allow) {
-
allow_rmb_select = p_allow;
}
bool Tree::get_allow_rmb_select() const {
-
return allow_rmb_select;
}
@@ -3921,12 +3728,10 @@ void Tree::set_allow_reselect(bool p_allow) {
}
bool Tree::get_allow_reselect() const {
-
return allow_reselect;
}
void Tree::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_gui_input"), &Tree::_gui_input);
ClassDB::bind_method(D_METHOD("clear"), &Tree::clear);
@@ -4014,7 +3819,6 @@ void Tree::_bind_methods() {
}
Tree::Tree() {
-
selected_col = 0;
columns.resize(1);
selected_item = nullptr;
@@ -4118,7 +3922,6 @@ Tree::Tree() {
}
Tree::~Tree() {
-
if (root) {
memdelete(root);
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 87c2588a12..46842e78a0 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -40,7 +40,6 @@
class Tree;
class TreeItem : public Object {
-
GDCLASS(TreeItem, Object);
public:
@@ -63,7 +62,6 @@ private:
friend class Tree;
struct Cell {
-
TreeCellMode mode;
Ref<Texture2D> icon;
@@ -111,7 +109,6 @@ private:
Vector<Button> buttons;
Cell() {
-
custom_draw_obj = ObjectID();
custom_button = false;
mode = TreeItem::CELL_MODE_STRING;
@@ -293,7 +290,6 @@ VARIANT_ENUM_CAST(TreeItem::TextAlign);
class VBoxContainer;
class Tree : public Control {
-
GDCLASS(Tree, Control);
public:
@@ -350,7 +346,6 @@ private:
int drop_mode_flags;
struct ColumnInfo {
-
int min_width;
bool expand;
String title;
@@ -404,7 +399,6 @@ private:
void propagate_set_columns(TreeItem *p_item);
struct Cache {
-
Ref<Font> font;
Ref<Font> tb_font;
Ref<StyleBox> bg;
@@ -544,7 +538,7 @@ public:
void clear();
- TreeItem *create_item(TreeItem *p_parent = 0, int p_idx = -1);
+ TreeItem *create_item(TreeItem *p_parent = nullptr, int p_idx = -1);
TreeItem *get_root();
TreeItem *get_last_item();
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index ac1e4a5629..881df06d8f 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -35,7 +35,6 @@
#include "servers/audio_server.h"
int VideoPlayer::sp_get_channel_count() const {
-
if (playback.is_null()) {
return 0;
}
@@ -44,7 +43,6 @@ int VideoPlayer::sp_get_channel_count() const {
}
bool VideoPlayer::mix(AudioFrame *p_buffer, int p_frames) {
-
// Check the amount resampler can really handle.
// If it cannot, wait "wait_resampler_phase_limit" times.
// This mechanism contributes to smoother pause/unpause operation.
@@ -59,7 +57,6 @@ bool VideoPlayer::mix(AudioFrame *p_buffer, int p_frames) {
// Called from main thread (eg VideoStreamPlaybackWebm::update)
int VideoPlayer::_audio_mix_callback(void *p_udata, const float *p_data, int p_frames) {
-
ERR_FAIL_NULL_V(p_udata, 0);
ERR_FAIL_NULL_V(p_data, 0);
@@ -79,14 +76,12 @@ int VideoPlayer::_audio_mix_callback(void *p_udata, const float *p_data, int p_f
}
void VideoPlayer::_mix_audios(void *p_self) {
-
ERR_FAIL_NULL(p_self);
reinterpret_cast<VideoPlayer *>(p_self)->_mix_audio();
}
// Called from audio thread
void VideoPlayer::_mix_audio() {
-
if (!stream.is_valid()) {
return;
}
@@ -98,8 +93,9 @@ void VideoPlayer::_mix_audio() {
int buffer_size = mix_buffer.size();
// Resample
- if (!mix(buffer, buffer_size))
+ if (!mix(buffer, buffer_size)) {
return;
+ }
AudioFrame vol = AudioFrame(volume, volume);
@@ -110,7 +106,6 @@ void VideoPlayer::_mix_audio() {
ERR_FAIL_COND(!target);
for (int j = 0; j < buffer_size; j++) {
-
target[j] += buffer[j] * vol;
}
@@ -123,7 +118,6 @@ void VideoPlayer::_mix_audio() {
}
for (int j = 0; j < buffer_size; j++) {
-
AudioFrame frame = buffer[j] * vol;
for (int k = 0; k < cc; k++) {
targets[k][j] += frame;
@@ -133,11 +127,8 @@ void VideoPlayer::_mix_audio() {
}
void VideoPlayer::_notification(int p_notification) {
-
switch (p_notification) {
-
case NOTIFICATION_ENTER_TREE: {
-
AudioServer::get_singleton()->add_callback(_mix_audios, this);
if (stream.is_valid() && autoplay && !Engine::get_singleton()->is_editor_hint()) {
@@ -147,25 +138,25 @@ void VideoPlayer::_notification(int p_notification) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
AudioServer::get_singleton()->remove_callback(_mix_audios, this);
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
-
bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);
- if (stream.is_null() || paused || playback.is_null() || !playback->is_playing())
+ if (stream.is_null() || paused || playback.is_null() || !playback->is_playing()) {
return;
+ }
double audio_time = USEC_TO_SEC(OS::get_singleton()->get_ticks_usec());
double delta = last_audio_time == 0 ? 0 : audio_time - last_audio_time;
last_audio_time = audio_time;
- if (delta == 0)
+ if (delta == 0) {
return;
+ }
playback->update(delta); // playback->is_playing() returns false in the last video frame
@@ -176,11 +167,12 @@ void VideoPlayer::_notification(int p_notification) {
} break;
case NOTIFICATION_DRAW: {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return;
- if (texture->get_width() == 0)
+ }
+ if (texture->get_width() == 0) {
return;
+ }
Size2 s = expand ? get_size() : texture->get_size();
draw_texture_rect(texture, Rect2(Point2(), s), false);
@@ -190,27 +182,24 @@ void VideoPlayer::_notification(int p_notification) {
};
Size2 VideoPlayer::get_minimum_size() const {
-
- if (!expand && !texture.is_null())
+ if (!expand && !texture.is_null()) {
return texture->get_size();
- else
+ } else {
return Size2();
+ }
}
void VideoPlayer::set_expand(bool p_expand) {
-
expand = p_expand;
update();
minimum_size_changed();
}
bool VideoPlayer::has_expand() const {
-
return expand;
}
void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
-
stop();
AudioServer::get_singleton()->lock();
mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
@@ -232,14 +221,16 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
const int channels = playback->get_channels();
AudioServer::get_singleton()->lock();
- if (channels > 0)
+ if (channels > 0) {
resampler.setup(channels, playback->get_mix_rate(), AudioServer::get_singleton()->get_mix_rate(), buffering_ms, 0);
- else
+ } else {
resampler.clear();
+ }
AudioServer::get_singleton()->unlock();
- if (channels > 0)
+ if (channels > 0) {
playback->set_mix_callback(_audio_mix_callback, this);
+ }
} else {
texture.unref();
@@ -256,15 +247,14 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
};
Ref<VideoStream> VideoPlayer::get_stream() const {
-
return stream;
};
void VideoPlayer::play() {
-
ERR_FAIL_COND(!is_inside_tree());
- if (playback.is_null())
+ if (playback.is_null()) {
return;
+ }
playback->stop();
playback->play();
set_process_internal(true);
@@ -274,11 +264,12 @@ void VideoPlayer::play() {
};
void VideoPlayer::stop() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
- if (playback.is_null())
+ }
+ if (playback.is_null()) {
return;
+ }
playback->stop();
// AudioServer::get_singleton()->stream_set_active(stream_rid,false);
@@ -288,15 +279,14 @@ void VideoPlayer::stop() {
};
bool VideoPlayer::is_playing() const {
-
- if (playback.is_null())
+ if (playback.is_null()) {
return false;
+ }
return playback->is_playing();
};
void VideoPlayer::set_paused(bool p_paused) {
-
paused = p_paused;
if (playback.is_valid()) {
playback->set_paused(p_paused);
@@ -306,17 +296,14 @@ void VideoPlayer::set_paused(bool p_paused) {
};
bool VideoPlayer::is_paused() const {
-
return paused;
}
void VideoPlayer::set_buffering_msec(int p_msec) {
-
buffering_ms = p_msec;
}
int VideoPlayer::get_buffering_msec() const {
-
return buffering_ms;
}
@@ -325,76 +312,70 @@ void VideoPlayer::set_audio_track(int p_track) {
}
int VideoPlayer::get_audio_track() const {
-
return audio_track;
}
void VideoPlayer::set_volume(float p_vol) {
-
volume = p_vol;
};
float VideoPlayer::get_volume() const {
-
return volume;
};
void VideoPlayer::set_volume_db(float p_db) {
-
- if (p_db < -79)
+ if (p_db < -79) {
set_volume(0);
- else
+ } else {
set_volume(Math::db2linear(p_db));
+ }
};
float VideoPlayer::get_volume_db() const {
-
- if (volume == 0)
+ if (volume == 0) {
return -80;
- else
+ } else {
return Math::linear2db(volume);
+ }
};
String VideoPlayer::get_stream_name() const {
-
- if (stream.is_null())
+ if (stream.is_null()) {
return "<No Stream>";
+ }
return stream->get_name();
};
float VideoPlayer::get_stream_position() const {
-
- if (playback.is_null())
+ if (playback.is_null()) {
return 0;
+ }
return playback->get_playback_position();
};
void VideoPlayer::set_stream_position(float p_position) {
-
- if (playback.is_valid())
+ if (playback.is_valid()) {
playback->seek(p_position);
+ }
}
Ref<Texture2D> VideoPlayer::get_video_texture() const {
-
- if (playback.is_valid())
+ if (playback.is_valid()) {
return playback->get_texture();
+ }
return Ref<Texture2D>();
}
void VideoPlayer::set_autoplay(bool p_enable) {
-
autoplay = p_enable;
};
bool VideoPlayer::has_autoplay() const {
-
return autoplay;
};
void VideoPlayer::set_bus(const StringName &p_bus) {
-
//if audio is active, must lock this
AudioServer::get_singleton()->lock();
bus = p_bus;
@@ -402,7 +383,6 @@ void VideoPlayer::set_bus(const StringName &p_bus) {
}
StringName VideoPlayer::get_bus() const {
-
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (AudioServer::get_singleton()->get_bus_name(i) == bus) {
return bus;
@@ -412,13 +392,12 @@ StringName VideoPlayer::get_bus() const {
}
void VideoPlayer::_validate_property(PropertyInfo &p_property) const {
-
if (p_property.name == "bus") {
-
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -428,7 +407,6 @@ void VideoPlayer::_validate_property(PropertyInfo &p_property) const {
}
void VideoPlayer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_stream", "stream"), &VideoPlayer::set_stream);
ClassDB::bind_method(D_METHOD("get_stream"), &VideoPlayer::get_stream);
@@ -485,7 +463,6 @@ void VideoPlayer::_bind_methods() {
}
VideoPlayer::VideoPlayer() {
-
volume = 1;
loops = false;
paused = false;
@@ -506,7 +483,6 @@ VideoPlayer::VideoPlayer() {
};
VideoPlayer::~VideoPlayer() {
-
// if (stream_rid.is_valid())
// AudioServer::get_singleton()->free(stream_rid);
resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 78e7fa05f8..551c079b3c 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -37,11 +37,9 @@
#include "servers/audio_server.h"
class VideoPlayer : public Control {
-
GDCLASS(VideoPlayer, Control);
struct Output {
-
AudioFrame vol;
int bus_index;
Viewport *viewport; //pointer only used for reference to previous mix
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index e91826d44b..721f573f39 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -48,7 +48,6 @@ Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemM
CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = nullptr;
void CanvasItemMaterial::init_shaders() {
-
dirty_materials = memnew(SelfList<CanvasItemMaterial>::List);
shader_names = memnew(ShaderNames);
@@ -59,19 +58,18 @@ void CanvasItemMaterial::init_shaders() {
}
void CanvasItemMaterial::finish_shaders() {
-
memdelete(dirty_materials);
memdelete(shader_names);
dirty_materials = nullptr;
}
void CanvasItemMaterial::_update_shader() {
-
dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
- if (mk.key == current_key.key)
+ if (mk.key == current_key.key) {
return; //no update required in the end
+ }
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -85,7 +83,6 @@ void CanvasItemMaterial::_update_shader() {
current_key = mk;
if (shader_map.has(mk)) {
-
RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
shader_map[mk].users++;
return;
@@ -129,7 +126,6 @@ void CanvasItemMaterial::_update_shader() {
code += ";\n";
if (particles_animation) {
-
code += "uniform int particles_anim_h_frames;\n";
code += "uniform int particles_anim_v_frames;\n";
code += "uniform bool particles_anim_loop;\n";
@@ -165,17 +161,14 @@ void CanvasItemMaterial::_update_shader() {
}
void CanvasItemMaterial::flush_changes() {
-
MutexLock lock(material_mutex);
while (dirty_materials->first()) {
-
dirty_materials->first()->self()->_update_shader();
}
}
void CanvasItemMaterial::_queue_shader_change() {
-
MutexLock lock(material_mutex);
if (!element.in_list()) {
@@ -184,13 +177,12 @@ void CanvasItemMaterial::_queue_shader_change() {
}
bool CanvasItemMaterial::_is_shader_dirty() const {
-
MutexLock lock(material_mutex);
return element.in_list();
}
-void CanvasItemMaterial::set_blend_mode(BlendMode p_blend_mode) {
+void CanvasItemMaterial::set_blend_mode(BlendMode p_blend_mode) {
blend_mode = p_blend_mode;
_queue_shader_change();
}
@@ -200,13 +192,11 @@ CanvasItemMaterial::BlendMode CanvasItemMaterial::get_blend_mode() const {
}
void CanvasItemMaterial::set_light_mode(LightMode p_light_mode) {
-
light_mode = p_light_mode;
_queue_shader_change();
}
CanvasItemMaterial::LightMode CanvasItemMaterial::get_light_mode() const {
-
return light_mode;
}
@@ -221,34 +211,29 @@ bool CanvasItemMaterial::get_particles_animation() const {
}
void CanvasItemMaterial::set_particles_anim_h_frames(int p_frames) {
-
particles_anim_h_frames = p_frames;
RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
}
int CanvasItemMaterial::get_particles_anim_h_frames() const {
-
return particles_anim_h_frames;
}
-void CanvasItemMaterial::set_particles_anim_v_frames(int p_frames) {
+void CanvasItemMaterial::set_particles_anim_v_frames(int p_frames) {
particles_anim_v_frames = p_frames;
RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
}
int CanvasItemMaterial::get_particles_anim_v_frames() const {
-
return particles_anim_v_frames;
}
void CanvasItemMaterial::set_particles_anim_loop(bool p_loop) {
-
particles_anim_loop = p_loop;
RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
}
bool CanvasItemMaterial::get_particles_anim_loop() const {
-
return particles_anim_loop;
}
@@ -259,18 +244,15 @@ void CanvasItemMaterial::_validate_property(PropertyInfo &property) const {
}
RID CanvasItemMaterial::get_shader_rid() const {
-
ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
return shader_map[current_key].shader;
}
Shader::Mode CanvasItemMaterial::get_shader_mode() const {
-
return Shader::MODE_CANVAS_ITEM;
}
void CanvasItemMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &CanvasItemMaterial::set_blend_mode);
ClassDB::bind_method(D_METHOD("get_blend_mode"), &CanvasItemMaterial::get_blend_mode);
@@ -310,7 +292,6 @@ void CanvasItemMaterial::_bind_methods() {
CanvasItemMaterial::CanvasItemMaterial() :
element(this) {
-
blend_mode = BLEND_MODE_MIX;
light_mode = LIGHT_MODE_NORMAL;
particles_animation = false;
@@ -325,7 +306,6 @@ CanvasItemMaterial::CanvasItemMaterial() :
}
CanvasItemMaterial::~CanvasItemMaterial() {
-
MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
@@ -356,15 +336,16 @@ Transform2D CanvasItem::_edit_get_transform() const {
#endif
bool CanvasItem::is_visible_in_tree() const {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return false;
+ }
const CanvasItem *p = this;
while (p) {
- if (!p->visible)
+ if (!p->visible) {
return false;
+ }
if (p->window && !p->window->is_visible()) {
return false;
}
@@ -375,54 +356,56 @@ bool CanvasItem::is_visible_in_tree() const {
}
void CanvasItem::_propagate_visibility_changed(bool p_visible) {
-
if (p_visible && first_draw) { //avoid propagating it twice
first_draw = false;
}
notification(NOTIFICATION_VISIBILITY_CHANGED);
- if (p_visible)
+ if (p_visible) {
update(); //todo optimize
- else
+ } else {
emit_signal(SceneStringNames::get_singleton()->hide);
+ }
_block();
for (int i = 0; i < get_child_count(); i++) {
-
CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i));
- if (c && c->visible) //should the toplevels stop propagation? i think so but..
+ if (c && c->visible) { //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
+ }
}
_unblock();
}
void CanvasItem::show() {
-
- if (visible)
+ if (visible) {
return;
+ }
visible = true;
RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, true);
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_propagate_visibility_changed(true);
_change_notify("visible");
}
void CanvasItem::hide() {
-
- if (!visible)
+ if (!visible) {
return;
+ }
visible = false;
RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, false);
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_propagate_visibility_changed(false);
_change_notify("visible");
@@ -434,7 +417,6 @@ CanvasItem *CanvasItem::get_current_item_drawn() {
}
void CanvasItem::_update_callback() {
-
if (!is_inside_tree()) {
pending_update = false;
return;
@@ -462,13 +444,13 @@ void CanvasItem::_update_callback() {
}
Transform2D CanvasItem::get_global_transform_with_canvas() const {
-
- if (canvas_layer)
+ if (canvas_layer) {
return canvas_layer->get_transform() * get_global_transform();
- else if (is_inside_tree())
+ } else if (is_inside_tree()) {
return get_viewport()->get_canvas_transform() * get_global_transform();
- else
+ } else {
return get_global_transform();
+ }
}
Transform2D CanvasItem::get_screen_transform() const {
@@ -491,12 +473,12 @@ Transform2D CanvasItem::get_global_transform() const {
ERR_FAIL_COND_V(!is_inside_tree(), get_transform());
#endif
if (global_invalid) {
-
const CanvasItem *pi = get_parent_item();
- if (pi)
+ if (pi) {
global_transform = pi->get_global_transform() * get_transform();
- else
+ } else {
global_transform = get_transform();
+ }
global_invalid = false;
}
@@ -505,26 +487,24 @@ Transform2D CanvasItem::get_global_transform() const {
}
void CanvasItem::_toplevel_raise_self() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (canvas_layer)
+ if (canvas_layer) {
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, canvas_layer->get_sort_index());
- else
+ } else {
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_viewport()->gui_get_canvas_sort_index());
+ }
}
void CanvasItem::_enter_canvas() {
-
if ((!Object::cast_to<CanvasItem>(get_parent())) || toplevel) {
-
Node *n = this;
canvas_layer = nullptr;
while (n) {
-
canvas_layer = Object::cast_to<CanvasLayer>(n);
if (canvas_layer) {
break;
@@ -536,25 +516,26 @@ void CanvasItem::_enter_canvas() {
}
RID canvas;
- if (canvas_layer)
+ if (canvas_layer) {
canvas = canvas_layer->get_canvas();
- else
+ } else {
canvas = get_viewport()->find_world_2d()->get_canvas();
+ }
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
group = "root_canvas" + itos(canvas.get_id());
add_to_group(group);
- if (canvas_layer)
+ if (canvas_layer) {
canvas_layer->reset_sort_index();
- else
+ } else {
get_viewport()->gui_reset_canvas_sort_index();
+ }
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, group, "_toplevel_raise_self");
} else {
-
CanvasItem *parent = get_parent_item();
canvas_layer = parent->canvas_layer;
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item());
@@ -568,7 +549,6 @@ void CanvasItem::_enter_canvas() {
}
void CanvasItem::_exit_canvas() {
-
notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID());
canvas_layer = nullptr;
@@ -576,10 +556,8 @@ void CanvasItem::_exit_canvas() {
}
void CanvasItem::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
_update_texture_filter_changed(false);
_update_texture_repeat_changed(false);
@@ -587,8 +565,9 @@ void CanvasItem::_notification(int p_what) {
Node *parent = get_parent();
if (parent) {
CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
- if (ci)
+ if (ci) {
C = ci->children_items.push_back(this);
+ }
if (!ci) {
//look for a window
Viewport *viewport = nullptr;
@@ -615,9 +594,9 @@ void CanvasItem::_notification(int p_what) {
}
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (group != "") {
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, group, "_toplevel_raise_self");
@@ -629,8 +608,9 @@ void CanvasItem::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
- if (xform_change.in_list())
+ if (xform_change.in_list()) {
get_tree()->xform_change_list.remove(&xform_change);
+ }
_exit_canvas();
if (C) {
Object::cast_to<CanvasItem>(get_parent())->children_items.erase(C);
@@ -643,41 +623,38 @@ void CanvasItem::_notification(int p_what) {
} break;
case NOTIFICATION_DRAW:
case NOTIFICATION_TRANSFORM_CHANGED: {
-
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
-
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
} break;
}
}
void CanvasItem::set_visible(bool p_visible) {
-
- if (p_visible)
+ if (p_visible) {
show();
- else
+ } else {
hide();
+ }
}
void CanvasItem::_window_visibility_changed() {
-
if (visible) {
_propagate_visibility_changed(window->is_visible());
}
}
bool CanvasItem::is_visible() const {
-
return visible;
}
void CanvasItem::update() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
- if (pending_update)
+ }
+ if (pending_update) {
return;
+ }
pending_update = true;
@@ -685,22 +662,22 @@ void CanvasItem::update() {
}
void CanvasItem::set_modulate(const Color &p_modulate) {
-
- if (modulate == p_modulate)
+ if (modulate == p_modulate) {
return;
+ }
modulate = p_modulate;
RenderingServer::get_singleton()->canvas_item_set_modulate(canvas_item, modulate);
}
-Color CanvasItem::get_modulate() const {
+Color CanvasItem::get_modulate() const {
return modulate;
}
void CanvasItem::set_as_toplevel(bool p_toplevel) {
-
- if (toplevel == p_toplevel)
+ if (toplevel == p_toplevel) {
return;
+ }
if (!is_inside_tree()) {
toplevel = p_toplevel;
@@ -713,61 +690,57 @@ void CanvasItem::set_as_toplevel(bool p_toplevel) {
}
bool CanvasItem::is_set_as_toplevel() const {
-
return toplevel;
}
CanvasItem *CanvasItem::get_parent_item() const {
-
- if (toplevel)
+ if (toplevel) {
return nullptr;
+ }
return Object::cast_to<CanvasItem>(get_parent());
}
void CanvasItem::set_self_modulate(const Color &p_self_modulate) {
-
- if (self_modulate == p_self_modulate)
+ if (self_modulate == p_self_modulate) {
return;
+ }
self_modulate = p_self_modulate;
RenderingServer::get_singleton()->canvas_item_set_self_modulate(canvas_item, self_modulate);
}
-Color CanvasItem::get_self_modulate() const {
+Color CanvasItem::get_self_modulate() const {
return self_modulate;
}
void CanvasItem::set_light_mask(int p_light_mask) {
-
- if (light_mask == p_light_mask)
+ if (light_mask == p_light_mask) {
return;
+ }
light_mask = p_light_mask;
RS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask);
}
int CanvasItem::get_light_mask() const {
-
return light_mask;
}
void CanvasItem::item_rect_changed(bool p_size_changed) {
-
- if (p_size_changed)
+ if (p_size_changed) {
update();
+ }
emit_signal(SceneStringNames::get_singleton()->item_rect_changed);
}
void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RenderingServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width);
}
void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
Vector<Color> colors;
@@ -776,14 +749,12 @@ void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_co
}
void CanvasItem::draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RenderingServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width);
}
void CanvasItem::draw_arc(const Vector2 &p_center, float p_radius, float p_start_angle, float p_end_angle, int p_point_count, const Color &p_color, float p_width) {
-
Vector<Point2> points;
points.resize(p_point_count);
const float delta_angle = p_end_angle - p_start_angle;
@@ -796,7 +767,6 @@ void CanvasItem::draw_arc(const Vector2 &p_center, float p_radius, float p_start
}
void CanvasItem::draw_multiline(const Vector<Point2> &p_points, const Color &p_color, float p_width) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
Vector<Color> colors;
@@ -805,14 +775,12 @@ void CanvasItem::draw_multiline(const Vector<Point2> &p_points, const Color &p_c
}
void CanvasItem::draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RenderingServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, p_colors, p_width);
}
void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled, float p_width) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
if (p_filled) {
@@ -859,14 +827,12 @@ void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_fil
}
void CanvasItem::draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RenderingServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color);
}
void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND(p_texture.is_null());
@@ -875,14 +841,13 @@ void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_p
}
void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND(p_texture.is_null());
p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
-void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
+void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND(p_texture.is_null());
p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat), p_clip_uv);
@@ -895,8 +860,8 @@ void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p
p_style_box->draw(canvas_item, p_rect);
}
-void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, float p_width, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
+void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, float p_width, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
@@ -905,8 +870,8 @@ void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Col
RenderingServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
-void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) {
+void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) {
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
Transform2D xform(p_rot, p_offset);
@@ -915,14 +880,12 @@ void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const S
}
void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RenderingServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
@@ -933,7 +896,6 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color
}
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
Vector<Color> colors;
@@ -946,7 +908,6 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
}
void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, const Transform2D &p_transform, const Color &p_modulate, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
-
ERR_FAIL_COND(p_mesh.is_null());
RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
@@ -954,8 +915,8 @@ void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_text
RenderingServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat));
}
-void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
+void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) {
ERR_FAIL_COND(p_multimesh.is_null());
RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
@@ -965,7 +926,6 @@ void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Tex
}
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
-
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND(p_font.is_null());
@@ -973,7 +933,6 @@ void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const
}
float CanvasItem::draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next, const Color &p_modulate) {
-
ERR_FAIL_COND_V_MSG(!drawing, 0, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_COND_V(p_char.length() != 1, 0);
@@ -986,7 +945,6 @@ float CanvasItem::draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const
}
void CanvasItem::_notify_transform(CanvasItem *p_node) {
-
/* This check exists to avoid re-propagating the transform
* notification down the tree on dirty nodes. It provides
* optimization by avoiding redundancy (nodes are dirty, will get the
@@ -1001,38 +959,37 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) {
if (p_node->notify_transform && !p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) {
- if (p_node->is_inside_tree())
+ if (p_node->is_inside_tree()) {
get_tree()->xform_change_list.add(&p_node->xform_change);
+ }
}
}
for (List<CanvasItem *>::Element *E = p_node->children_items.front(); E; E = E->next()) {
-
CanvasItem *ci = E->get();
- if (ci->toplevel)
+ if (ci->toplevel) {
continue;
+ }
_notify_transform(ci);
}
}
Rect2 CanvasItem::get_viewport_rect() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
return get_viewport()->get_visible_rect();
}
RID CanvasItem::get_canvas() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), RID());
- if (canvas_layer)
+ if (canvas_layer) {
return canvas_layer->get_canvas();
- else
+ } else {
return get_viewport()->find_world_2d()->get_canvas();
+ }
}
ObjectID CanvasItem::get_canvas_layer_instance_id() const {
-
if (canvas_layer) {
return canvas_layer->get_instance_id();
} else {
@@ -1041,7 +998,6 @@ ObjectID CanvasItem::get_canvas_layer_instance_id() const {
}
CanvasItem *CanvasItem::get_toplevel() const {
-
CanvasItem *ci = const_cast<CanvasItem *>(this);
while (!ci->toplevel && Object::cast_to<CanvasItem>(ci->get_parent())) {
ci = Object::cast_to<CanvasItem>(ci->get_parent());
@@ -1051,7 +1007,6 @@ CanvasItem *CanvasItem::get_toplevel() const {
}
Ref<World2D> CanvasItem::get_world_2d() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), Ref<World2D>());
CanvasItem *tl = get_toplevel();
@@ -1064,7 +1019,6 @@ Ref<World2D> CanvasItem::get_world_2d() const {
}
RID CanvasItem::get_viewport_rid() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), RID());
return get_viewport()->get_viewport_rid();
}
@@ -1074,51 +1028,45 @@ void CanvasItem::set_block_transform_notify(bool p_enable) {
}
bool CanvasItem::is_block_transform_notify_enabled() const {
-
return block_transform_notify;
}
void CanvasItem::set_draw_behind_parent(bool p_enable) {
-
- if (behind == p_enable)
+ if (behind == p_enable) {
return;
+ }
behind = p_enable;
RenderingServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item, behind);
}
bool CanvasItem::is_draw_behind_parent_enabled() const {
-
return behind;
}
void CanvasItem::set_material(const Ref<Material> &p_material) {
-
material = p_material;
RID rid;
- if (material.is_valid())
+ if (material.is_valid()) {
rid = material->get_rid();
+ }
RS::get_singleton()->canvas_item_set_material(canvas_item, rid);
_change_notify(); //properties for material exposed
}
void CanvasItem::set_use_parent_material(bool p_use_parent_material) {
-
use_parent_material = p_use_parent_material;
RS::get_singleton()->canvas_item_set_use_parent_material(canvas_item, p_use_parent_material);
}
bool CanvasItem::get_use_parent_material() const {
-
return use_parent_material;
}
Ref<Material> CanvasItem::get_material() const {
-
return material;
}
Vector2 CanvasItem::make_canvas_position_local(const Vector2 &screen_point) const {
-
ERR_FAIL_COND_V(!is_inside_tree(), screen_point);
Transform2D local_matrix = (get_canvas_transform() * get_global_transform()).affine_inverse();
@@ -1127,7 +1075,6 @@ Vector2 CanvasItem::make_canvas_position_local(const Vector2 &screen_point) cons
}
Ref<InputEvent> CanvasItem::make_input_local(const Ref<InputEvent> &p_event) const {
-
ERR_FAIL_COND_V(p_event.is_null(), p_event);
ERR_FAIL_COND_V(!is_inside_tree(), p_event);
@@ -1135,13 +1082,11 @@ Ref<InputEvent> CanvasItem::make_input_local(const Ref<InputEvent> &p_event) con
}
Vector2 CanvasItem::get_global_mouse_position() const {
-
ERR_FAIL_COND_V(!get_viewport(), Vector2());
return get_canvas_transform().affine_inverse().xform(get_viewport()->get_mouse_position());
}
Vector2 CanvasItem::get_local_mouse_position() const {
-
ERR_FAIL_COND_V(!get_viewport(), Vector2());
return get_global_transform().affine_inverse().xform(get_global_mouse_position());
@@ -1159,7 +1104,6 @@ void CanvasItem::force_update_transform() {
}
void CanvasItem::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self);
ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback);
@@ -1278,8 +1222,8 @@ void CanvasItem::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_light_mask", "get_light_mask");
ADD_GROUP("Texture", "texture_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "ParentNode,Nearest,Linear,MipmapNearest,MipmapLinear,MipmapNearestAniso,MipmapLinearAniso"), "set_texture_filter", "get_texture_filter");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_repeat", PROPERTY_HINT_ENUM, "ParentNode,Disabled,Enabled,Mirror"), "set_texture_repeat", "get_texture_repeat");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "Inherit,Nearest,Linear,MipmapNearest,MipmapLinear,MipmapNearestAniso,MipmapLinearAniso"), "set_texture_filter", "get_texture_filter");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_repeat", PROPERTY_HINT_ENUM, "Inherit,Disabled,Enabled,Mirror"), "set_texture_repeat", "get_texture_repeat");
ADD_GROUP("Material", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial"), "set_material", "get_material");
@@ -1316,23 +1260,21 @@ void CanvasItem::_bind_methods() {
}
Transform2D CanvasItem::get_canvas_transform() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), Transform2D());
- if (canvas_layer)
+ if (canvas_layer) {
return canvas_layer->get_transform();
- else if (Object::cast_to<CanvasItem>(get_parent()))
+ } else if (Object::cast_to<CanvasItem>(get_parent())) {
return Object::cast_to<CanvasItem>(get_parent())->get_canvas_transform();
- else
+ } else {
return get_viewport()->get_canvas_transform();
+ }
}
Transform2D CanvasItem::get_viewport_transform() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), Transform2D());
if (canvas_layer) {
-
if (get_viewport()) {
return get_viewport()->get_final_transform() * canvas_layer->get_transform();
} else {
@@ -1353,8 +1295,9 @@ bool CanvasItem::is_local_transform_notification_enabled() const {
}
void CanvasItem::set_notify_transform(bool p_enable) {
- if (notify_transform == p_enable)
+ if (notify_transform == p_enable) {
return;
+ }
notify_transform = p_enable;
@@ -1369,15 +1312,14 @@ bool CanvasItem::is_transform_notification_enabled() const {
}
int CanvasItem::get_canvas_layer() const {
-
- if (canvas_layer)
+ if (canvas_layer) {
return canvas_layer->get_layer();
- else
+ } else {
return 0;
+ }
}
void CanvasItem::_update_texture_filter_changed(bool p_propagate) {
-
if (!is_inside_tree()) {
return;
}
@@ -1434,7 +1376,6 @@ CanvasItem::TextureFilter CanvasItem::get_texture_filter() const {
}
void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
-
if (!is_inside_tree()) {
return;
}
@@ -1488,7 +1429,6 @@ CanvasItem::TextureRepeat CanvasItem::get_texture_repeat() const {
CanvasItem::CanvasItem() :
xform_change(this) {
-
window = nullptr;
canvas_item = RenderingServer::get_singleton()->canvas_item_create();
visible = true;
@@ -1515,6 +1455,5 @@ CanvasItem::CanvasItem() :
}
CanvasItem::~CanvasItem() {
-
RenderingServer::get_singleton()->free(canvas_item);
}
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index 5f1798cc2a..31edd424a1 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -45,7 +45,6 @@ class Font;
class StyleBox;
class CanvasItemMaterial : public Material {
-
GDCLASS(CanvasItemMaterial, Material);
public:
@@ -66,7 +65,6 @@ public:
private:
union MaterialKey {
-
struct {
uint32_t blend_mode : 4;
uint32_t light_mode : 4;
@@ -99,7 +97,6 @@ private:
MaterialKey current_key;
_FORCE_INLINE_ MaterialKey _compute_key() const {
-
MaterialKey mk;
mk.key = 0;
mk.blend_mode = blend_mode;
@@ -162,7 +159,6 @@ VARIANT_ENUM_CAST(CanvasItemMaterial::BlendMode)
VARIANT_ENUM_CAST(CanvasItemMaterial::LightMode)
class CanvasItem : public Node {
-
GDCLASS(CanvasItem, Node);
public:
@@ -247,11 +243,13 @@ private:
protected:
_FORCE_INLINE_ void _notify_transform() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_notify_transform(this);
- if (!block_transform_notify && notify_local_transform)
+ if (!block_transform_notify && notify_local_transform) {
notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
+ }
}
void item_rect_changed(bool p_size_changed = true);
@@ -277,7 +275,7 @@ public:
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
// Save and restore a CanvasItem state
- virtual void _edit_set_state(const Dictionary &p_state){};
+ virtual void _edit_set_state(const Dictionary &p_state) {}
virtual Dictionary _edit_get_state() const { return Dictionary(); };
// Used to move the node
@@ -290,18 +288,18 @@ public:
// Used to rotate the node
virtual bool _edit_use_rotation() const { return false; };
- virtual void _edit_set_rotation(float p_rotation){};
+ virtual void _edit_set_rotation(float p_rotation) {}
virtual float _edit_get_rotation() const { return 0.0; };
// Used to resize/move the node
virtual bool _edit_use_rect() const { return false; }; // MAYBE REPLACE BY A _edit_get_editmode()
- virtual void _edit_set_rect(const Rect2 &p_rect){};
+ virtual void _edit_set_rect(const Rect2 &p_rect) {}
virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); };
virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); }; // LOOKS WEIRD
// Used to set a pivot
virtual bool _edit_use_pivot() const { return false; };
- virtual void _edit_set_pivot(const Point2 &p_pivot){};
+ virtual void _edit_set_pivot(const Point2 &p_pivot) {}
virtual Point2 _edit_get_pivot() const { return Point2(); };
virtual Transform2D _edit_get_transform() const;
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index c1caa943e3..46cfb968f8 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -32,40 +32,37 @@
#include "viewport.h"
void CanvasLayer::set_layer(int p_xform) {
-
layer = p_xform;
- if (viewport.is_valid())
+ if (viewport.is_valid()) {
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
+ }
}
int CanvasLayer::get_layer() const {
-
return layer;
}
void CanvasLayer::set_transform(const Transform2D &p_xform) {
-
transform = p_xform;
locrotscale_dirty = true;
- if (viewport.is_valid())
+ if (viewport.is_valid()) {
RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
+ }
}
Transform2D CanvasLayer::get_transform() const {
-
return transform;
}
void CanvasLayer::_update_xform() {
-
transform.set_rotation_and_scale(rot, scale);
transform.set_origin(ofs);
- if (viewport.is_valid())
+ if (viewport.is_valid()) {
RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
+ }
}
void CanvasLayer::_update_locrotscale() {
-
ofs = transform.elements[2];
rot = transform.get_rotation();
scale = transform.get_scale();
@@ -73,74 +70,68 @@ void CanvasLayer::_update_locrotscale() {
}
void CanvasLayer::set_offset(const Vector2 &p_offset) {
-
- if (locrotscale_dirty)
+ if (locrotscale_dirty) {
_update_locrotscale();
+ }
ofs = p_offset;
_update_xform();
}
Vector2 CanvasLayer::get_offset() const {
-
- if (locrotscale_dirty)
+ if (locrotscale_dirty) {
const_cast<CanvasLayer *>(this)->_update_locrotscale();
+ }
return ofs;
}
void CanvasLayer::set_rotation(real_t p_radians) {
-
- if (locrotscale_dirty)
+ if (locrotscale_dirty) {
_update_locrotscale();
+ }
rot = p_radians;
_update_xform();
}
real_t CanvasLayer::get_rotation() const {
-
- if (locrotscale_dirty)
+ if (locrotscale_dirty) {
const_cast<CanvasLayer *>(this)->_update_locrotscale();
+ }
return rot;
}
void CanvasLayer::set_rotation_degrees(real_t p_degrees) {
-
set_rotation(Math::deg2rad(p_degrees));
}
real_t CanvasLayer::get_rotation_degrees() const {
-
return Math::rad2deg(get_rotation());
}
void CanvasLayer::set_scale(const Vector2 &p_scale) {
-
- if (locrotscale_dirty)
+ if (locrotscale_dirty) {
_update_locrotscale();
+ }
scale = p_scale;
_update_xform();
}
Vector2 CanvasLayer::get_scale() const {
-
- if (locrotscale_dirty)
+ if (locrotscale_dirty) {
const_cast<CanvasLayer *>(this)->_update_locrotscale();
+ }
return scale;
}
void CanvasLayer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) {
-
vp = custom_viewport;
} else {
vp = Node::get_viewport();
@@ -157,7 +148,6 @@ void CanvasLayer::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
vp->_canvas_layer_remove(this);
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
viewport = RID();
@@ -165,25 +155,24 @@ void CanvasLayer::_notification(int p_what) {
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
-
- if (is_inside_tree())
+ if (is_inside_tree()) {
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
+ }
} break;
}
}
Size2 CanvasLayer::get_viewport_size() const {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return Size2(1, 1);
+ }
Rect2 r = vp->get_visible_rect();
return r.size;
}
RID CanvasLayer::get_viewport() const {
-
return viewport;
}
@@ -204,11 +193,11 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
}
if (is_inside_tree()) {
-
- if (custom_viewport)
+ if (custom_viewport) {
vp = custom_viewport;
- else
+ } else {
vp = Node::get_viewport();
+ }
vp->_canvas_layer_add(this);
viewport = vp->get_viewport_rid();
@@ -220,7 +209,6 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
}
Node *CanvasLayer::get_custom_viewport() const {
-
return custom_viewport;
}
@@ -229,12 +217,10 @@ void CanvasLayer::reset_sort_index() {
}
int CanvasLayer::get_sort_index() {
-
return sort_index++;
}
RID CanvasLayer::get_canvas() const {
-
return canvas;
}
@@ -261,7 +247,6 @@ float CanvasLayer::get_follow_viewport_scale() const {
}
void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
-
if (!is_inside_tree()) {
return;
}
@@ -273,7 +258,6 @@ void CanvasLayer::_update_follow_viewport(bool p_force_exit) {
}
void CanvasLayer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_layer", "layer"), &CanvasLayer::set_layer);
ClassDB::bind_method(D_METHOD("get_layer"), &CanvasLayer::get_layer);
@@ -319,7 +303,6 @@ void CanvasLayer::_bind_methods() {
}
CanvasLayer::CanvasLayer() {
-
vp = nullptr;
scale = Vector2(1, 1);
rot = 0;
@@ -334,6 +317,5 @@ CanvasLayer::CanvasLayer() {
}
CanvasLayer::~CanvasLayer() {
-
RS::get_singleton()->free(canvas);
}
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index 91ddbca3b9..0c68b1ab69 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -36,7 +36,6 @@
class Viewport;
class CanvasLayer : public Node {
-
GDCLASS(CanvasLayer, Node);
bool locrotscale_dirty;
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index dc0da015ac..82ee4dde50 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -34,12 +34,10 @@ void HTTPRequest::_redirect_request(const String &p_new_url) {
}
Error HTTPRequest::_request() {
-
return client->connect_to_host(url, port, use_ssl, validate_ssl);
}
Error HTTPRequest::_parse_url(const String &p_url) {
-
url = p_url;
use_ssl = false;
@@ -85,7 +83,6 @@ Error HTTPRequest::_parse_url(const String &p_url) {
}
Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_headers, bool p_ssl_validate_domain, HTTPClient::Method p_method, const String &p_request_data) {
-
ERR_FAIL_COND_V(!is_inside_tree(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V_MSG(requesting, ERR_BUSY, "HTTPRequest is processing a request. Wait for completion or cancel it before attempting a new one.");
@@ -97,8 +94,9 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
method = p_method;
Error err = _parse_url(p_url);
- if (err)
+ if (err) {
return err;
+ }
validate_ssl = p_ssl_validate_domain;
@@ -109,7 +107,6 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
requesting = true;
if (use_threads) {
-
thread_done = false;
thread_request_quit = false;
client->set_blocking_mode(true);
@@ -129,7 +126,6 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
}
void HTTPRequest::_thread_func(void *p_userdata) {
-
HTTPRequest *hr = (HTTPRequest *)p_userdata;
Error err = hr->_request();
@@ -138,10 +134,10 @@ void HTTPRequest::_thread_func(void *p_userdata) {
hr->call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
} else {
while (!hr->thread_request_quit) {
-
bool exit = hr->_update_connection();
- if (exit)
+ if (exit) {
break;
+ }
OS::get_singleton()->delay_usec(1);
}
}
@@ -150,11 +146,11 @@ void HTTPRequest::_thread_func(void *p_userdata) {
}
void HTTPRequest::cancel_request() {
-
timer->stop();
- if (!requesting)
+ if (!requesting) {
return;
+ }
if (!use_threads) {
set_process_internal(false);
@@ -178,7 +174,6 @@ void HTTPRequest::cancel_request() {
}
bool HTTPRequest::_handle_response(bool *ret_value) {
-
if (!client->has_response()) {
call_deferred("_request_done", RESULT_NO_RESPONSE, 0, PackedStringArray(), PackedByteArray());
*ret_value = true;
@@ -199,7 +194,6 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
// Handle redirect
if (max_redirects >= 0 && redirections >= max_redirects) {
-
call_deferred("_request_done", RESULT_REDIRECT_LIMIT_REACHED, response_code, response_headers, PackedByteArray());
*ret_value = true;
return true;
@@ -243,7 +237,6 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
}
bool HTTPRequest::_update_connection() {
-
switch (client->get_status()) {
case HTTPClient::STATUS_DISCONNECTED: {
call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
@@ -265,23 +258,20 @@ bool HTTPRequest::_update_connection() {
return false;
} break; // Connecting to IP
case HTTPClient::STATUS_CANT_CONNECT: {
-
call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
return true;
} break;
case HTTPClient::STATUS_CONNECTED: {
-
if (request_sent) {
-
if (!got_response) {
-
// No body
bool ret_value;
- if (_handle_response(&ret_value))
+ if (_handle_response(&ret_value)) {
return ret_value;
+ }
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray());
return true;
@@ -315,16 +305,14 @@ bool HTTPRequest::_update_connection() {
} break; // Request in progress
case HTTPClient::STATUS_BODY: {
-
if (!got_response) {
-
bool ret_value;
- if (_handle_response(&ret_value))
+ if (_handle_response(&ret_value)) {
return ret_value;
+ }
if (!client->is_response_chunked() && client->get_response_body_length() == 0) {
-
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray());
return true;
}
@@ -341,7 +329,6 @@ bool HTTPRequest::_update_connection() {
if (download_to_file != String()) {
file = FileAccess::open(download_to_file, FileAccess::WRITE);
if (!file) {
-
call_deferred("_request_done", RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PackedByteArray());
return true;
}
@@ -370,7 +357,6 @@ bool HTTPRequest::_update_connection() {
}
if (body_len >= 0) {
-
if (downloaded == body_len) {
call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
return true;
@@ -397,20 +383,17 @@ bool HTTPRequest::_update_connection() {
}
void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
-
cancel_request();
emit_signal("request_completed", p_status, p_code, headers, p_data);
}
void HTTPRequest::_notification(int p_what) {
-
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
-
- if (use_threads)
+ if (use_threads) {
return;
+ }
bool done = _update_connection();
if (done) {
-
set_process_internal(false);
// cancel_request(); called from _request done now
}
@@ -424,42 +407,35 @@ void HTTPRequest::_notification(int p_what) {
}
void HTTPRequest::set_use_threads(bool p_use) {
-
ERR_FAIL_COND(get_http_client_status() != HTTPClient::STATUS_DISCONNECTED);
use_threads = p_use;
}
bool HTTPRequest::is_using_threads() const {
-
return use_threads;
}
void HTTPRequest::set_body_size_limit(int p_bytes) {
-
ERR_FAIL_COND(get_http_client_status() != HTTPClient::STATUS_DISCONNECTED);
body_size_limit = p_bytes;
}
int HTTPRequest::get_body_size_limit() const {
-
return body_size_limit;
}
void HTTPRequest::set_download_file(const String &p_file) {
-
ERR_FAIL_COND(get_http_client_status() != HTTPClient::STATUS_DISCONNECTED);
download_to_file = p_file;
}
String HTTPRequest::get_download_file() const {
-
return download_to_file;
}
void HTTPRequest::set_download_chunk_size(int p_chunk_size) {
-
ERR_FAIL_COND(get_http_client_status() != HTTPClient::STATUS_DISCONNECTED);
client->set_read_chunk_size(p_chunk_size);
@@ -474,42 +450,36 @@ HTTPClient::Status HTTPRequest::get_http_client_status() const {
}
void HTTPRequest::set_max_redirects(int p_max) {
-
max_redirects = p_max;
}
int HTTPRequest::get_max_redirects() const {
-
return max_redirects;
}
int HTTPRequest::get_downloaded_bytes() const {
-
return downloaded;
}
+
int HTTPRequest::get_body_size() const {
return body_len;
}
void HTTPRequest::set_timeout(int p_timeout) {
-
ERR_FAIL_COND(p_timeout < 0);
timeout = p_timeout;
}
int HTTPRequest::get_timeout() {
-
return timeout;
}
void HTTPRequest::_timeout() {
-
cancel_request();
call_deferred("_request_done", RESULT_TIMEOUT, 0, PackedStringArray(), PackedByteArray());
}
void HTTPRequest::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("request", "url", "custom_headers", "ssl_validate_domain", "method", "request_data"), &HTTPRequest::request, DEFVAL(PackedStringArray()), DEFVAL(true), DEFVAL(HTTPClient::METHOD_GET), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("cancel_request"), &HTTPRequest::cancel_request);
@@ -565,7 +535,6 @@ void HTTPRequest::_bind_methods() {
}
HTTPRequest::HTTPRequest() {
-
thread = nullptr;
port = 80;
@@ -593,6 +562,7 @@ HTTPRequest::HTTPRequest() {
}
HTTPRequest::~HTTPRequest() {
- if (file)
+ if (file) {
memdelete(file);
+ }
}
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index a3d95cd652..1409965d45 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -38,7 +38,6 @@
#include "scene/main/timer.h"
class HTTPRequest : public Node {
-
GDCLASS(HTTPRequest, Node);
public:
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 062b221c84..ca8d5a2ca0 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -34,7 +34,6 @@
#include "scene/resources/packed_scene.h"
bool InstancePlaceholder::_set(const StringName &p_name, const Variant &p_value) {
-
PropSet ps;
ps.name = p_name;
ps.value = p_value;
@@ -43,7 +42,6 @@ bool InstancePlaceholder::_set(const StringName &p_name, const Variant &p_value)
}
bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const {
-
for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
if (E->get().name == p_name) {
r_ret = E->get().value;
@@ -54,7 +52,6 @@ bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const {
}
void InstancePlaceholder::_get_property_list(List<PropertyInfo> *p_list) const {
-
for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
PropertyInfo pi;
pi.name = E->get().name;
@@ -66,34 +63,35 @@ void InstancePlaceholder::_get_property_list(List<PropertyInfo> *p_list) const {
}
void InstancePlaceholder::set_instance_path(const String &p_name) {
-
path = p_name;
}
String InstancePlaceholder::get_instance_path() const {
-
return path;
}
Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene> &p_custom_scene) {
-
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
Node *base = get_parent();
- if (!base)
+ if (!base) {
return nullptr;
+ }
Ref<PackedScene> ps;
- if (p_custom_scene.is_valid())
+ if (p_custom_scene.is_valid()) {
ps = p_custom_scene;
- else
+ } else {
ps = ResourceLoader::load(path, "PackedScene");
+ }
- if (!ps.is_valid())
+ if (!ps.is_valid()) {
return nullptr;
+ }
Node *scene = ps->instance();
- if (!scene)
+ if (!scene) {
return nullptr;
+ }
scene->set_name(get_name());
int pos = get_index();
@@ -113,24 +111,24 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene
}
Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
-
Dictionary ret;
PackedStringArray order;
for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
ret[E->get().name] = E->get().value;
- if (p_with_order)
+ if (p_with_order) {
order.push_back(E->get().name);
+ }
};
- if (p_with_order)
+ if (p_with_order) {
ret[".order"] = order;
+ }
return ret;
};
void InstancePlaceholder::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_stored_values", "with_order"), &InstancePlaceholder::get_stored_values, DEFVAL(false));
ClassDB::bind_method(D_METHOD("create_instance", "replace", "custom_scene"), &InstancePlaceholder::create_instance, DEFVAL(false), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("get_instance_path"), &InstancePlaceholder::get_instance_path);
diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h
index 9f7b84716d..ec1f8a9b09 100644
--- a/scene/main/instance_placeholder.h
+++ b/scene/main/instance_placeholder.h
@@ -36,7 +36,6 @@
class PackedScene;
class InstancePlaceholder : public Node {
-
GDCLASS(InstancePlaceholder, Node);
String path;
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 3d56b51e26..1bf828a03b 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -51,22 +51,16 @@ VARIANT_ENUM_CAST(Node::PauseMode);
int Node::orphan_node_count = 0;
void Node::_notification(int p_notification) {
-
switch (p_notification) {
-
case NOTIFICATION_PROCESS: {
-
if (get_script_instance()) {
-
Variant time = get_process_delta_time();
const Variant *ptr[1] = { &time };
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_process, ptr, 1);
}
} break;
case NOTIFICATION_PHYSICS_PROCESS: {
-
if (get_script_instance()) {
-
Variant time = get_physics_process_delta_time();
const Variant *ptr[1] = { &time };
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_physics_process, ptr, 1);
@@ -78,21 +72,24 @@ void Node::_notification(int p_notification) {
ERR_FAIL_COND(!get_tree());
if (data.pause_mode == PAUSE_MODE_INHERIT) {
-
- if (data.parent)
+ if (data.parent) {
data.pause_owner = data.parent->data.pause_owner;
- else
+ } else {
data.pause_owner = nullptr;
+ }
} else {
data.pause_owner = this;
}
- if (data.input)
+ if (data.input) {
add_to_group("_vp_input" + itos(get_viewport()->get_instance_id()));
- if (data.unhandled_input)
+ }
+ if (data.unhandled_input) {
add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
- if (data.unhandled_key_input)
+ }
+ if (data.unhandled_key_input) {
add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
+ }
get_tree()->node_count++;
orphan_node_count--;
@@ -105,12 +102,15 @@ void Node::_notification(int p_notification) {
get_tree()->node_count--;
orphan_node_count++;
- if (data.input)
+ if (data.input) {
remove_from_group("_vp_input" + itos(get_viewport()->get_instance_id()));
- if (data.unhandled_input)
+ }
+ if (data.unhandled_input) {
remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
- if (data.unhandled_key_input)
+ }
+ if (data.unhandled_key_input) {
remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
+ }
data.pause_owner = nullptr;
if (data.path_cache) {
@@ -119,16 +119,13 @@ void Node::_notification(int p_notification) {
}
} break;
case NOTIFICATION_PATH_CHANGED: {
-
if (data.path_cache) {
memdelete(data.path_cache);
data.path_cache = nullptr;
}
} break;
case NOTIFICATION_READY: {
-
if (get_script_instance()) {
-
if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_input)) {
set_process_input(true);
}
@@ -157,22 +154,18 @@ void Node::_notification(int p_notification) {
data.in_constructor = false;
} break;
case NOTIFICATION_PREDELETE: {
-
set_owner(nullptr);
while (data.owned.size()) {
-
data.owned.front()->get()->set_owner(nullptr);
}
if (data.parent) {
-
data.parent->remove_child(this);
}
// kill children as cleanly as possible
while (data.children.size()) {
-
Node *child = data.children[data.children.size() - 1]; //begin from the end because its faster and more consistent with creation
remove_child(child);
memdelete(child);
@@ -183,11 +176,9 @@ void Node::_notification(int p_notification) {
}
void Node::_propagate_ready() {
-
data.ready_notified = true;
data.blocked++;
for (int i = 0; i < data.children.size(); i++) {
-
data.children[i]->_propagate_ready();
}
data.blocked--;
@@ -208,13 +199,13 @@ void Node::_propagate_enter_tree() {
data.tree = data.parent->data.tree;
data.depth = data.parent->data.depth + 1;
} else {
-
data.depth = 1;
}
data.viewport = Object::cast_to<Viewport>(this);
- if (!data.viewport && data.parent)
+ if (!data.viewport && data.parent) {
data.viewport = data.parent->data.viewport;
+ }
data.inside_tree = true;
@@ -225,7 +216,6 @@ void Node::_propagate_enter_tree() {
notification(NOTIFICATION_ENTER_TREE);
if (get_script_instance()) {
-
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, nullptr, 0);
}
@@ -237,9 +227,9 @@ void Node::_propagate_enter_tree() {
//block while adding children
for (int i = 0; i < data.children.size(); i++) {
-
- if (!data.children[i]->is_inside_tree()) // could have been added in enter_tree
+ if (!data.children[i]->is_inside_tree()) { // could have been added in enter_tree
data.children[i]->_propagate_enter_tree();
+ }
}
data.blocked--;
@@ -251,7 +241,6 @@ void Node::_propagate_enter_tree() {
}
void Node::_propagate_after_exit_tree() {
-
data.blocked++;
for (int i = 0; i < data.children.size(); i++) {
data.children[i]->_propagate_after_exit_tree();
@@ -261,7 +250,6 @@ void Node::_propagate_after_exit_tree() {
}
void Node::_propagate_exit_tree() {
-
//block while removing children
#ifdef DEBUG_ENABLED
@@ -270,21 +258,20 @@ void Node::_propagate_exit_tree() {
data.blocked++;
for (int i = data.children.size() - 1; i >= 0; i--) {
-
data.children[i]->_propagate_exit_tree();
}
data.blocked--;
if (get_script_instance()) {
-
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, nullptr, 0);
}
emit_signal(SceneStringNames::get_singleton()->tree_exiting);
notification(NOTIFICATION_EXIT_TREE, true);
- if (data.tree)
+ if (data.tree) {
data.tree->node_removed(this);
+ }
// exit groups
@@ -295,8 +282,9 @@ void Node::_propagate_exit_tree() {
data.viewport = nullptr;
- if (data.tree)
+ if (data.tree) {
data.tree->tree_changed();
+ }
data.inside_tree = false;
data.ready_notified = false;
@@ -305,7 +293,6 @@ void Node::_propagate_exit_tree() {
}
void Node::move_child(Node *p_child, int p_pos) {
-
ERR_FAIL_NULL(p_child);
ERR_FAIL_INDEX_MSG(p_pos, data.children.size() + 1, "Invalid new child position: " + itos(p_pos) + ".");
ERR_FAIL_COND_MSG(p_child->data.parent != this, "Child is not a child of this node.");
@@ -313,11 +300,13 @@ void Node::move_child(Node *p_child, int p_pos) {
// Specifying one place beyond the end
// means the same as moving to the last position
- if (p_pos == data.children.size())
+ if (p_pos == data.children.size()) {
p_pos--;
+ }
- if (p_child->data.pos == p_pos)
+ if (p_child->data.pos == p_pos) {
return; //do nothing
+ }
int motion_from = MIN(p_pos, p_child->data.pos);
int motion_to = MAX(p_pos, p_child->data.pos);
@@ -332,7 +321,6 @@ void Node::move_child(Node *p_child, int p_pos) {
data.blocked++;
//new pos first
for (int i = motion_from; i <= motion_to; i++) {
-
data.children[i]->data.pos = i;
}
// notification second
@@ -341,94 +329,94 @@ void Node::move_child(Node *p_child, int p_pos) {
data.children[i]->notification(NOTIFICATION_MOVED_IN_PARENT);
}
for (const Map<StringName, GroupData>::Element *E = p_child->data.grouped.front(); E; E = E->next()) {
- if (E->get().group)
+ if (E->get().group) {
E->get().group->changed = true;
+ }
}
data.blocked--;
}
void Node::raise() {
-
- if (!data.parent)
+ if (!data.parent) {
return;
+ }
data.parent->move_child(this, data.parent->data.children.size() - 1);
}
void Node::add_child_notify(Node *p_child) {
-
// to be used when not wanted
}
void Node::remove_child_notify(Node *p_child) {
-
// to be used when not wanted
}
void Node::move_child_notify(Node *p_child) {
-
// to be used when not wanted
}
void Node::set_physics_process(bool p_process) {
-
- if (data.physics_process == p_process)
+ if (data.physics_process == p_process) {
return;
+ }
data.physics_process = p_process;
- if (data.physics_process)
+ if (data.physics_process) {
add_to_group("physics_process", false);
- else
+ } else {
remove_from_group("physics_process");
+ }
_change_notify("physics_process");
}
bool Node::is_physics_processing() const {
-
return data.physics_process;
}
void Node::set_physics_process_internal(bool p_process_internal) {
-
- if (data.physics_process_internal == p_process_internal)
+ if (data.physics_process_internal == p_process_internal) {
return;
+ }
data.physics_process_internal = p_process_internal;
- if (data.physics_process_internal)
+ if (data.physics_process_internal) {
add_to_group("physics_process_internal", false);
- else
+ } else {
remove_from_group("physics_process_internal");
+ }
_change_notify("physics_process_internal");
}
bool Node::is_physics_processing_internal() const {
-
return data.physics_process_internal;
}
void Node::set_pause_mode(PauseMode p_mode) {
-
- if (data.pause_mode == p_mode)
+ if (data.pause_mode == p_mode) {
return;
+ }
bool prev_inherits = data.pause_mode == PAUSE_MODE_INHERIT;
data.pause_mode = p_mode;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return; //pointless
- if ((data.pause_mode == PAUSE_MODE_INHERIT) == prev_inherits)
+ }
+ if ((data.pause_mode == PAUSE_MODE_INHERIT) == prev_inherits) {
return; ///nothing changed
+ }
Node *owner = nullptr;
if (data.pause_mode == PAUSE_MODE_INHERIT) {
-
- if (data.parent)
+ if (data.parent) {
owner = data.parent->data.pause_owner;
+ }
} else {
owner = this;
}
@@ -437,40 +425,34 @@ void Node::set_pause_mode(PauseMode p_mode) {
}
Node::PauseMode Node::get_pause_mode() const {
-
return data.pause_mode;
}
void Node::_propagate_pause_owner(Node *p_owner) {
-
- if (this != p_owner && data.pause_mode != PAUSE_MODE_INHERIT)
+ if (this != p_owner && data.pause_mode != PAUSE_MODE_INHERIT) {
return;
+ }
data.pause_owner = p_owner;
for (int i = 0; i < data.children.size(); i++) {
-
data.children[i]->_propagate_pause_owner(p_owner);
}
}
void Node::set_network_master(int p_peer_id, bool p_recursive) {
-
data.network_master = p_peer_id;
if (p_recursive) {
for (int i = 0; i < data.children.size(); i++) {
-
data.children[i]->set_network_master(p_peer_id, true);
}
}
}
int Node::get_network_master() const {
-
return data.network_master;
}
bool Node::is_network_master() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), false);
return get_multiplayer()->get_network_unique_id() == data.network_master;
@@ -479,7 +461,6 @@ bool Node::is_network_master() const {
/***** RPC CONFIG ********/
uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_mode) {
-
uint16_t mid = get_node_rpc_method_id(p_method);
if (mid == UINT16_MAX) {
// It's new
@@ -496,7 +477,6 @@ uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_
}
uint16_t Node::rset_config(const StringName &p_property, MultiplayerAPI::RPCMode p_mode) {
-
uint16_t pid = get_node_rset_property_id(p_property);
if (pid == UINT16_MAX) {
// It's new
@@ -515,13 +495,13 @@ uint16_t Node::rset_config(const StringName &p_property, MultiplayerAPI::RPCMode
/***** RPC FUNCTIONS ********/
void Node::rpc(const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -529,13 +509,13 @@ void Node::rpc(const StringName &p_method, VARIANT_ARG_DECLARE) {
}
void Node::rpc_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -543,13 +523,13 @@ void Node::rpc_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_DECLARE
}
void Node::rpc_unreliable(const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -557,13 +537,13 @@ void Node::rpc_unreliable(const StringName &p_method, VARIANT_ARG_DECLARE) {
}
void Node::rpc_unreliable_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
argc++;
}
@@ -571,7 +551,6 @@ void Node::rpc_unreliable_id(int p_peer_id, const StringName &p_method, VARIANT_
}
Variant Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
@@ -594,7 +573,6 @@ Variant Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallEr
}
Variant Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 2) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 2;
@@ -625,7 +603,6 @@ Variant Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Callable::Cal
}
Variant Node::_rpc_unreliable_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 1) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
@@ -648,7 +625,6 @@ Variant Node::_rpc_unreliable_bind(const Variant **p_args, int p_argcount, Calla
}
Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (p_argcount < 2) {
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 2;
@@ -690,31 +666,29 @@ void Node::rsetp(int p_peer_id, bool p_unreliable, const StringName &p_property,
/******** RSET *********/
void Node::rset(const StringName &p_property, const Variant &p_value) {
-
rsetp(0, false, p_property, p_value);
}
void Node::rset_id(int p_peer_id, const StringName &p_property, const Variant &p_value) {
-
rsetp(p_peer_id, false, p_property, p_value);
}
void Node::rset_unreliable(const StringName &p_property, const Variant &p_value) {
-
rsetp(0, true, p_property, p_value);
}
void Node::rset_unreliable_id(int p_peer_id, const StringName &p_property, const Variant &p_value) {
-
rsetp(p_peer_id, true, p_property, p_value);
}
//////////// end of rpc
Ref<MultiplayerAPI> Node::get_multiplayer() const {
- if (multiplayer.is_valid())
+ if (multiplayer.is_valid()) {
return multiplayer;
- if (!is_inside_tree())
+ }
+ if (!is_inside_tree()) {
return Ref<MultiplayerAPI>();
+ }
return get_tree()->get_multiplayer();
}
@@ -723,7 +697,6 @@ Ref<MultiplayerAPI> Node::get_custom_multiplayer() const {
}
void Node::set_custom_multiplayer(Ref<MultiplayerAPI> p_multiplayer) {
-
multiplayer = p_multiplayer;
}
@@ -742,8 +715,9 @@ StringName Node::get_node_rpc_method(const uint16_t p_rpc_method_id) const {
// Make sure this is a node generated ID.
if (((1 << 15) & p_rpc_method_id) > 0) {
int mid = (~(1 << 15)) & p_rpc_method_id;
- if (mid < data.rpc_methods.size())
+ if (mid < data.rpc_methods.size()) {
return data.rpc_methods[mid].name;
+ }
}
return StringName();
}
@@ -752,8 +726,9 @@ MultiplayerAPI::RPCMode Node::get_node_rpc_mode_by_id(const uint16_t p_rpc_metho
// Make sure this is a node generated ID.
if (((1 << 15) & p_rpc_method_id) > 0) {
int mid = (~(1 << 15)) & p_rpc_method_id;
- if (mid < data.rpc_methods.size())
+ if (mid < data.rpc_methods.size()) {
return data.rpc_methods[mid].mode;
+ }
}
return MultiplayerAPI::RPC_MODE_DISABLED;
}
@@ -777,8 +752,9 @@ StringName Node::get_node_rset_property(const uint16_t p_rset_property_id) const
// Make sure this is a node generated ID.
if (((1 << 15) & p_rset_property_id) > 0) {
int mid = (~(1 << 15)) & p_rset_property_id;
- if (mid < data.rpc_properties.size())
+ if (mid < data.rpc_properties.size()) {
return data.rpc_properties[mid].name;
+ }
}
return StringName();
}
@@ -786,8 +762,9 @@ StringName Node::get_node_rset_property(const uint16_t p_rset_property_id) const
MultiplayerAPI::RPCMode Node::get_node_rset_mode_by_id(const uint16_t p_rset_property_id) const {
if (((1 << 15) & p_rset_property_id) > 0) {
int mid = (~(1 << 15)) & p_rset_property_id;
- if (mid < data.rpc_properties.size())
+ if (mid < data.rpc_properties.size()) {
return data.rpc_properties[mid].mode;
+ }
}
return MultiplayerAPI::RPC_MODE_DISABLED;
}
@@ -833,25 +810,27 @@ bool Node::can_process_notification(int p_what) const {
}
bool Node::can_process() const {
-
ERR_FAIL_COND_V(!is_inside_tree(), false);
if (get_tree()->is_paused()) {
-
- if (data.pause_mode == PAUSE_MODE_STOP)
+ if (data.pause_mode == PAUSE_MODE_STOP) {
return false;
- if (data.pause_mode == PAUSE_MODE_PROCESS)
+ }
+ if (data.pause_mode == PAUSE_MODE_PROCESS) {
return true;
+ }
if (data.pause_mode == PAUSE_MODE_INHERIT) {
-
- if (!data.pause_owner)
+ if (!data.pause_owner) {
return false; //clearly no pause owner by default
+ }
- if (data.pause_owner->data.pause_mode == PAUSE_MODE_PROCESS)
+ if (data.pause_owner->data.pause_mode == PAUSE_MODE_PROCESS) {
return true;
+ }
- if (data.pause_owner->data.pause_mode == PAUSE_MODE_STOP)
+ if (data.pause_owner->data.pause_mode == PAUSE_MODE_STOP) {
return false;
+ }
}
}
@@ -859,58 +838,58 @@ bool Node::can_process() const {
}
float Node::get_physics_process_delta_time() const {
-
- if (data.tree)
+ if (data.tree) {
return data.tree->get_physics_process_time();
- else
+ } else {
return 0;
+ }
}
float Node::get_process_delta_time() const {
-
- if (data.tree)
+ if (data.tree) {
return data.tree->get_idle_process_time();
- else
+ } else {
return 0;
+ }
}
void Node::set_process(bool p_idle_process) {
-
- if (data.idle_process == p_idle_process)
+ if (data.idle_process == p_idle_process) {
return;
+ }
data.idle_process = p_idle_process;
- if (data.idle_process)
+ if (data.idle_process) {
add_to_group("idle_process", false);
- else
+ } else {
remove_from_group("idle_process");
+ }
_change_notify("idle_process");
}
bool Node::is_processing() const {
-
return data.idle_process;
}
void Node::set_process_internal(bool p_idle_process_internal) {
-
- if (data.idle_process_internal == p_idle_process_internal)
+ if (data.idle_process_internal == p_idle_process_internal) {
return;
+ }
data.idle_process_internal = p_idle_process_internal;
- if (data.idle_process_internal)
+ if (data.idle_process_internal) {
add_to_group("idle_process_internal", false);
- else
+ } else {
remove_from_group("idle_process_internal");
+ }
_change_notify("idle_process_internal");
}
bool Node::is_processing_internal() const {
-
return data.idle_process_internal;
}
@@ -940,23 +919,24 @@ void Node::set_process_priority(int p_priority) {
}
int Node::get_process_priority() const {
-
return data.process_priority;
}
void Node::set_process_input(bool p_enable) {
-
- if (p_enable == data.input)
+ if (p_enable == data.input) {
return;
+ }
data.input = p_enable;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (p_enable)
+ if (p_enable) {
add_to_group("_vp_input" + itos(get_viewport()->get_instance_id()));
- else
+ } else {
remove_from_group("_vp_input" + itos(get_viewport()->get_instance_id()));
+ }
}
bool Node::is_processing_input() const {
@@ -964,17 +944,19 @@ bool Node::is_processing_input() const {
}
void Node::set_process_unhandled_input(bool p_enable) {
-
- if (p_enable == data.unhandled_input)
+ if (p_enable == data.unhandled_input) {
return;
+ }
data.unhandled_input = p_enable;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (p_enable)
+ if (p_enable) {
add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
- else
+ } else {
remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
+ }
}
bool Node::is_processing_unhandled_input() const {
@@ -982,17 +964,19 @@ bool Node::is_processing_unhandled_input() const {
}
void Node::set_process_unhandled_key_input(bool p_enable) {
-
- if (p_enable == data.unhandled_key_input)
+ if (p_enable == data.unhandled_key_input) {
return;
+ }
data.unhandled_key_input = p_enable;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (p_enable)
+ if (p_enable) {
add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
- else
+ } else {
remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
+ }
}
bool Node::is_processing_unhandled_key_input() const {
@@ -1000,12 +984,10 @@ bool Node::is_processing_unhandled_key_input() const {
}
StringName Node::get_name() const {
-
return data.name;
}
void Node::_set_name_nocheck(const StringName &p_name) {
-
data.name = p_name;
}
@@ -1023,7 +1005,6 @@ bool Node::_validate_node_name(String &p_name) {
}
void Node::set_name(const String &p_name) {
-
String name = p_name;
_validate_node_name(name);
@@ -1031,14 +1012,12 @@ void Node::set_name(const String &p_name) {
data.name = name;
if (data.parent) {
-
data.parent->_validate_child_name(this);
}
propagate_notification(NOTIFICATION_PATH_CHANGED);
if (is_inside_tree()) {
-
emit_signal("renamed");
get_tree()->node_renamed(this);
get_tree()->tree_changed();
@@ -1053,13 +1032,11 @@ void Node::init_node_hrcr() {
}
void Node::set_human_readable_collision_renaming(bool p_enabled) {
-
node_hrcr = p_enabled;
}
#ifdef TOOLS_ENABLED
String Node::validate_child_name(Node *p_child) {
-
StringName name = p_child->data.name;
_generate_serial_child_name(p_child, name);
return name;
@@ -1067,11 +1044,9 @@ String Node::validate_child_name(Node *p_child) {
#endif
void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
-
/* Make sure the name is unique */
if (node_hrcr || p_force_human_readable) {
-
//this approach to autoset node names is human readable but very slow
//it's turned on while running in the editor
@@ -1080,7 +1055,6 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
p_child->data.name = name;
} else {
-
//this approach to autoset node names is fast but not as readable
//it's the default and reserves the '@' character for unique names.
@@ -1095,8 +1069,9 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
int cc = data.children.size();
for (int i = 0; i < cc; i++) {
- if (children[i] == p_child)
+ if (children[i] == p_child) {
continue;
+ }
if (children[i]->data.name == p_child->data.name) {
unique = false;
break;
@@ -1105,7 +1080,6 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
}
if (!unique) {
-
ERR_FAIL_COND(!node_hrcr_count.ref());
String name = "@" + String(p_child->get_name()) + "@" + itos(node_hrcr_count.get());
p_child->data.name = name;
@@ -1115,7 +1089,6 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
// Return s + 1 as if it were an integer
String increase_numeric_string(const String &s) {
-
String res = s;
bool carry = res.length() > 0;
@@ -1140,7 +1113,6 @@ String increase_numeric_string(const String &s) {
}
void Node::_generate_serial_child_name(const Node *p_child, StringName &name) const {
-
if (name == StringName()) {
//no name and a new nade is needed, create one.
@@ -1165,7 +1137,6 @@ void Node::_generate_serial_child_name(const Node *p_child, StringName &name) co
const Node *const *children_ptr = data.children.ptr();
{
-
bool exists = false;
for (int i = 0; i < cc; i++) {
@@ -1252,7 +1223,6 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
}
void Node::add_child(Node *p_child, bool p_legible_unique_name) {
-
ERR_FAIL_NULL(p_child);
ERR_FAIL_COND_MSG(p_child == this, "Can't add child '" + p_child->get_name() + "' to itself."); // adding to itself!
ERR_FAIL_COND_MSG(p_child->data.parent, "Can't add child '" + p_child->get_name() + "' to '" + get_name() + "', already has a parent '" + p_child->data.parent->get_name() + "'."); //Fail if node has a parent
@@ -1264,31 +1234,22 @@ void Node::add_child(Node *p_child, bool p_legible_unique_name) {
_add_child_nocheck(p_child, p_child->data.name);
}
-void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_unique_name) {
-
- ERR_FAIL_NULL(p_node);
- ERR_FAIL_NULL(p_child);
-
- add_child(p_child, p_legible_unique_name);
+void Node::add_sibling(Node *p_sibling, bool p_legible_unique_name) {
+ ERR_FAIL_NULL(p_sibling);
+ ERR_FAIL_COND_MSG(p_sibling == this, "Can't add sibling '" + p_sibling->get_name() + "' to itself."); // adding to itself!
+ ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, add_sibling() failed. Consider using call_deferred(\"add_sibling\", sibling) instead.");
- if (is_a_parent_of(p_node)) {
- move_child(p_child, p_node->get_index() + 1);
- } else {
- WARN_PRINT("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent.");
- }
+ get_parent()->add_child(p_sibling, p_legible_unique_name);
+ get_parent()->move_child(p_sibling, this->get_index() + 1);
}
void Node::_propagate_validate_owner() {
-
if (data.owner) {
-
bool found = false;
Node *parent = data.parent;
while (parent) {
-
if (parent == data.owner) {
-
found = true;
break;
}
@@ -1297,20 +1258,17 @@ void Node::_propagate_validate_owner() {
}
if (!found) {
-
data.owner->data.owned.erase(data.OW);
data.owner = nullptr;
}
}
for (int i = 0; i < data.children.size(); i++) {
-
data.children[i]->_propagate_validate_owner();
}
}
void Node::remove_child(Node *p_child) {
-
ERR_FAIL_NULL(p_child);
ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, remove_node() failed. Consider using call_deferred(\"remove_child\", child) instead.");
@@ -1326,9 +1284,7 @@ void Node::remove_child(Node *p_child) {
if (idx == -1) { //maybe removed while unparenting or something and index was not updated, so just in case the above fails, try this.
for (int i = 0; i < child_count; i++) {
-
if (children[i] == p_child) {
-
idx = i;
break;
}
@@ -1353,7 +1309,6 @@ void Node::remove_child(Node *p_child) {
children = data.children.ptrw();
for (int i = idx; i < child_count; i++) {
-
children[i]->data.pos = i;
children[i]->notification(NOTIFICATION_MOVED_IN_PARENT);
}
@@ -1370,31 +1325,29 @@ void Node::remove_child(Node *p_child) {
}
int Node::get_child_count() const {
-
return data.children.size();
}
-Node *Node::get_child(int p_index) const {
+Node *Node::get_child(int p_index) const {
ERR_FAIL_INDEX_V(p_index, data.children.size(), nullptr);
return data.children[p_index];
}
Node *Node::_get_child_by_name(const StringName &p_name) const {
-
int cc = data.children.size();
Node *const *cd = data.children.ptr();
for (int i = 0; i < cc; i++) {
- if (cd[i]->data.name == p_name)
+ if (cd[i]->data.name == p_name) {
return cd[i];
+ }
}
return nullptr;
}
Node *Node::get_node_or_null(const NodePath &p_path) const {
-
if (p_path.is_empty()) {
return nullptr;
}
@@ -1407,14 +1360,13 @@ Node *Node::get_node_or_null(const NodePath &p_path) const {
if (!p_path.is_absolute()) {
current = const_cast<Node *>(this); //start from this
} else {
-
root = const_cast<Node *>(this);
- while (root->data.parent)
+ while (root->data.parent) {
root = root->data.parent; //start from root
+ }
}
for (int i = 0; i < p_path.get_name_count(); i++) {
-
StringName name = p_path.get_name(i);
Node *next = nullptr;
@@ -1424,25 +1376,23 @@ Node *Node::get_node_or_null(const NodePath &p_path) const {
} else if (name == SceneStringNames::get_singleton()->doubledot) { // ..
- if (current == nullptr || !current->data.parent)
+ if (current == nullptr || !current->data.parent) {
return nullptr;
+ }
next = current->data.parent;
} else if (current == nullptr) {
-
- if (name == root->get_name())
+ if (name == root->get_name()) {
next = root;
+ }
} else {
-
next = nullptr;
for (int j = 0; j < current->data.children.size(); j++) {
-
Node *child = current->data.children[j];
if (child->data.name == name) {
-
next = child;
break;
}
@@ -1458,49 +1408,48 @@ Node *Node::get_node_or_null(const NodePath &p_path) const {
}
Node *Node::get_node(const NodePath &p_path) const {
-
Node *node = get_node_or_null(p_path);
ERR_FAIL_COND_V_MSG(!node, nullptr, "Node not found: " + p_path + ".");
return node;
}
bool Node::has_node(const NodePath &p_path) const {
-
return get_node_or_null(p_path) != nullptr;
}
Node *Node::find_node(const String &p_mask, bool p_recursive, bool p_owned) const {
-
Node *const *cptr = data.children.ptr();
int ccount = data.children.size();
for (int i = 0; i < ccount; i++) {
- if (p_owned && !cptr[i]->data.owner)
+ if (p_owned && !cptr[i]->data.owner) {
continue;
- if (cptr[i]->data.name.operator String().match(p_mask))
+ }
+ if (cptr[i]->data.name.operator String().match(p_mask)) {
return cptr[i];
+ }
- if (!p_recursive)
+ if (!p_recursive) {
continue;
+ }
Node *ret = cptr[i]->find_node(p_mask, true, p_owned);
- if (ret)
+ if (ret) {
return ret;
+ }
}
return nullptr;
}
Node *Node::get_parent() const {
-
return data.parent;
}
Node *Node::find_parent(const String &p_mask) const {
-
Node *p = data.parent;
while (p) {
-
- if (p->data.name.operator String().match(p_mask))
+ if (p->data.name.operator String().match(p_mask)) {
return p;
+ }
p = p->data.parent;
}
@@ -1508,13 +1457,12 @@ Node *Node::find_parent(const String &p_mask) const {
}
bool Node::is_a_parent_of(const Node *p_node) const {
-
ERR_FAIL_NULL_V(p_node, false);
Node *p = p_node->data.parent;
while (p) {
-
- if (p == this)
+ if (p == this) {
return true;
+ }
p = p->data.parent;
}
@@ -1522,7 +1470,6 @@ bool Node::is_a_parent_of(const Node *p_node) const {
}
bool Node::is_greater_than(const Node *p_node) const {
-
ERR_FAIL_NULL_V(p_node, false);
ERR_FAIL_COND_V(!data.inside_tree, false);
ERR_FAIL_COND_V(!p_node->data.inside_tree, false);
@@ -1565,7 +1512,6 @@ bool Node::is_greater_than(const Node *p_node) const {
bool res;
while (true) {
-
// using -2 since out-of-tree or nonroot nodes have -1
int this_idx = (idx >= data.depth) ? -2 : this_stack[idx];
int that_idx = (idx >= p_node->data.depth) ? -2 : that_stack[idx];
@@ -1587,18 +1533,19 @@ bool Node::is_greater_than(const Node *p_node) const {
}
void Node::get_owned_by(Node *p_by, List<Node *> *p_owned) {
-
- if (data.owner == p_by)
+ if (data.owner == p_by) {
p_owned->push_back(this);
+ }
- for (int i = 0; i < get_child_count(); i++)
+ for (int i = 0; i < get_child_count(); i++) {
get_child(i)->get_owned_by(p_by, p_owned);
+ }
}
void Node::_set_owner_nocheck(Node *p_owner) {
-
- if (data.owner == p_owner)
+ if (data.owner == p_owner) {
return;
+ }
ERR_FAIL_COND(data.owner);
data.owner = p_owner;
@@ -1607,9 +1554,7 @@ void Node::_set_owner_nocheck(Node *p_owner) {
}
void Node::set_owner(Node *p_owner) {
-
if (data.owner) {
-
data.owner->data.owned.erase(data.OW);
data.OW = nullptr;
data.owner = nullptr;
@@ -1617,14 +1562,14 @@ void Node::set_owner(Node *p_owner) {
ERR_FAIL_COND(p_owner == this);
- if (!p_owner)
+ if (!p_owner) {
return;
+ }
Node *check = this->get_parent();
bool owner_valid = false;
while (check) {
-
if (check == p_owner) {
owner_valid = true;
break;
@@ -1637,22 +1582,21 @@ void Node::set_owner(Node *p_owner) {
_set_owner_nocheck(p_owner);
}
-Node *Node::get_owner() const {
+Node *Node::get_owner() const {
return data.owner;
}
Node *Node::find_common_parent_with(const Node *p_node) const {
-
- if (this == p_node)
+ if (this == p_node) {
return const_cast<Node *>(p_node);
+ }
Set<const Node *> visited;
const Node *n = this;
while (n) {
-
visited.insert(n);
n = n->data.parent;
}
@@ -1660,31 +1604,31 @@ Node *Node::find_common_parent_with(const Node *p_node) const {
const Node *common_parent = p_node;
while (common_parent) {
-
- if (visited.has(common_parent))
+ if (visited.has(common_parent)) {
break;
+ }
common_parent = common_parent->data.parent;
}
- if (!common_parent)
+ if (!common_parent) {
return nullptr;
+ }
return const_cast<Node *>(common_parent);
}
NodePath Node::get_path_to(const Node *p_node) const {
-
ERR_FAIL_NULL_V(p_node, NodePath());
- if (this == p_node)
+ if (this == p_node) {
return NodePath(".");
+ }
Set<const Node *> visited;
const Node *n = this;
while (n) {
-
visited.insert(n);
n = n->data.parent;
}
@@ -1692,9 +1636,9 @@ NodePath Node::get_path_to(const Node *p_node) const {
const Node *common_parent = p_node;
while (common_parent) {
-
- if (visited.has(common_parent))
+ if (visited.has(common_parent)) {
break;
+ }
common_parent = common_parent->data.parent;
}
@@ -1707,7 +1651,6 @@ NodePath Node::get_path_to(const Node *p_node) const {
n = p_node;
while (n != common_parent) {
-
path.push_back(n->get_name());
n = n->data.parent;
}
@@ -1716,7 +1659,6 @@ NodePath Node::get_path_to(const Node *p_node) const {
StringName up = String("..");
while (n != common_parent) {
-
path.push_back(up);
n = n->data.parent;
}
@@ -1727,11 +1669,11 @@ NodePath Node::get_path_to(const Node *p_node) const {
}
NodePath Node::get_path() const {
-
ERR_FAIL_COND_V_MSG(!is_inside_tree(), NodePath(), "Cannot get path of node as it is not in a scene tree.");
- if (data.path_cache)
+ if (data.path_cache) {
return *data.path_cache;
+ }
const Node *n = this;
@@ -1750,16 +1692,15 @@ NodePath Node::get_path() const {
}
bool Node::is_in_group(const StringName &p_identifier) const {
-
return data.grouped.has(p_identifier);
}
void Node::add_to_group(const StringName &p_identifier, bool p_persistent) {
-
ERR_FAIL_COND(!p_identifier.operator String().length());
- if (data.grouped.has(p_identifier))
+ if (data.grouped.has(p_identifier)) {
return;
+ }
GroupData gd;
@@ -1775,21 +1716,20 @@ void Node::add_to_group(const StringName &p_identifier, bool p_persistent) {
}
void Node::remove_from_group(const StringName &p_identifier) {
-
ERR_FAIL_COND(!data.grouped.has(p_identifier));
Map<StringName, GroupData>::Element *E = data.grouped.find(p_identifier);
ERR_FAIL_COND(!E);
- if (data.tree)
+ if (data.tree) {
data.tree->remove_from_group(E->key(), this);
+ }
data.grouped.erase(E);
}
Array Node::_get_groups() const {
-
Array groups;
List<GroupInfo> gi;
get_groups(&gi);
@@ -1801,7 +1741,6 @@ Array Node::_get_groups() const {
}
void Node::get_groups(List<GroupInfo> *p_groups) const {
-
for (const Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
GroupInfo gi;
gi.name = E->key();
@@ -1811,7 +1750,6 @@ void Node::get_groups(List<GroupInfo> *p_groups) const {
}
int Node::get_persistent_group_count() const {
-
int count = 0;
for (const Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
@@ -1822,8 +1760,8 @@ int Node::get_persistent_group_count() const {
return count;
}
-void Node::_print_tree_pretty(const String &prefix, const bool last) {
+void Node::_print_tree_pretty(const String &prefix, const bool last) {
String new_prefix = last ? String::utf8(" â”–â•´") : String::utf8(" â” â•´");
print_line(prefix + new_prefix + String(get_name()));
for (int i = 0; i < data.children.size(); i++) {
@@ -1837,21 +1775,19 @@ void Node::print_tree_pretty() {
}
void Node::print_tree() {
-
_print_tree(this);
}
void Node::_print_tree(const Node *p_node) {
print_line(String(p_node->get_path_to(this)));
- for (int i = 0; i < data.children.size(); i++)
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->_print_tree(p_node);
+ }
}
void Node::_propagate_reverse_notification(int p_notification) {
-
data.blocked++;
for (int i = data.children.size() - 1; i >= 0; i--) {
-
data.children[i]->_propagate_reverse_notification(p_notification);
}
@@ -1860,71 +1796,70 @@ void Node::_propagate_reverse_notification(int p_notification) {
}
void Node::_propagate_deferred_notification(int p_notification, bool p_reverse) {
-
ERR_FAIL_COND(!is_inside_tree());
data.blocked++;
- if (!p_reverse)
+ if (!p_reverse) {
MessageQueue::get_singleton()->push_notification(this, p_notification);
+ }
for (int i = 0; i < data.children.size(); i++) {
-
data.children[i]->_propagate_deferred_notification(p_notification, p_reverse);
}
- if (p_reverse)
+ if (p_reverse) {
MessageQueue::get_singleton()->push_notification(this, p_notification);
+ }
data.blocked--;
}
void Node::propagate_notification(int p_notification) {
-
data.blocked++;
notification(p_notification);
for (int i = 0; i < data.children.size(); i++) {
-
data.children[i]->propagate_notification(p_notification);
}
data.blocked--;
}
void Node::propagate_call(const StringName &p_method, const Array &p_args, const bool p_parent_first) {
-
data.blocked++;
- if (p_parent_first && has_method(p_method))
+ if (p_parent_first && has_method(p_method)) {
callv(p_method, p_args);
+ }
for (int i = 0; i < data.children.size(); i++) {
data.children[i]->propagate_call(p_method, p_args, p_parent_first);
}
- if (!p_parent_first && has_method(p_method))
+ if (!p_parent_first && has_method(p_method)) {
callv(p_method, p_args);
+ }
data.blocked--;
}
void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
- if (get_owner() == p_owner)
+ if (get_owner() == p_owner) {
set_owner(p_by_owner);
+ }
data.blocked++;
- for (int i = 0; i < data.children.size(); i++)
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->_propagate_replace_owner(p_owner, p_by_owner);
+ }
data.blocked--;
}
int Node::get_index() const {
-
return data.pos;
}
void Node::remove_and_skip() {
-
ERR_FAIL_COND(!data.parent);
Node *new_owner = get_owner();
@@ -1932,12 +1867,12 @@ void Node::remove_and_skip() {
List<Node *> children;
while (true) {
-
bool clear = true;
for (int i = 0; i < data.children.size(); i++) {
Node *c_node = data.children[i];
- if (!c_node->get_owner())
+ if (!c_node->get_owner()) {
continue;
+ }
remove_child(c_node);
c_node->_propagate_replace_owner(this, nullptr);
@@ -1946,12 +1881,12 @@ void Node::remove_and_skip() {
break;
}
- if (clear)
+ if (clear) {
break;
+ }
}
while (!children.empty()) {
-
Node *c_node = children.front()->get();
data.parent->add_child(c_node);
c_node->_propagate_replace_owner(nullptr, new_owner);
@@ -1962,20 +1897,18 @@ void Node::remove_and_skip() {
}
void Node::set_filename(const String &p_filename) {
-
data.filename = p_filename;
}
-String Node::get_filename() const {
+String Node::get_filename() const {
return data.filename;
}
void Node::set_editor_description(const String &p_editor_description) {
-
set_meta("_editor_description_", p_editor_description);
}
-String Node::get_editor_description() const {
+String Node::get_editor_description() const {
if (has_meta("_editor_description_")) {
return get_meta("_editor_description_");
} else {
@@ -1984,7 +1917,6 @@ String Node::get_editor_description() const {
}
void Node::set_editable_instance(Node *p_node, bool p_editable) {
-
ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(!is_a_parent_of(p_node));
NodePath p = get_path_to(p_node);
@@ -1999,75 +1931,65 @@ void Node::set_editable_instance(Node *p_node, bool p_editable) {
}
bool Node::is_editable_instance(const Node *p_node) const {
-
- if (!p_node)
+ if (!p_node) {
return false; //easier, null is never editable :)
+ }
ERR_FAIL_COND_V(!is_a_parent_of(p_node), false);
NodePath p = get_path_to(p_node);
return data.editable_instances.has(p);
}
void Node::set_editable_instances(const HashMap<NodePath, int> &p_editable_instances) {
-
data.editable_instances = p_editable_instances;
}
HashMap<NodePath, int> Node::get_editable_instances() const {
-
return data.editable_instances;
}
void Node::set_scene_instance_state(const Ref<SceneState> &p_state) {
-
data.instance_state = p_state;
}
Ref<SceneState> Node::get_scene_instance_state() const {
-
return data.instance_state;
}
void Node::set_scene_inherited_state(const Ref<SceneState> &p_state) {
-
data.inherited_state = p_state;
}
Ref<SceneState> Node::get_scene_inherited_state() const {
-
return data.inherited_state;
}
void Node::set_scene_instance_load_placeholder(bool p_enable) {
-
data.use_placeholder = p_enable;
}
bool Node::get_scene_instance_load_placeholder() const {
-
return data.use_placeholder;
}
Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const {
-
Node *node = nullptr;
bool instanced = false;
if (Object::cast_to<InstancePlaceholder>(this)) {
-
const InstancePlaceholder *ip = Object::cast_to<const InstancePlaceholder>(this);
InstancePlaceholder *nip = memnew(InstancePlaceholder);
nip->set_instance_path(ip->get_instance_path());
node = nip;
} else if ((p_flags & DUPLICATE_USE_INSTANCING) && get_filename() != String()) {
-
Ref<PackedScene> res = ResourceLoader::load(get_filename());
ERR_FAIL_COND_V(res.is_null(), nullptr);
PackedScene::GenEditState ges = PackedScene::GEN_EDIT_STATE_DISABLED;
#ifdef TOOLS_ENABLED
- if (p_flags & DUPLICATE_FROM_EDITOR)
+ if (p_flags & DUPLICATE_FROM_EDITOR) {
ges = PackedScene::GEN_EDIT_STATE_INSTANCE;
+ }
#endif
node = res->instance(ges);
ERR_FAIL_COND_V(!node, nullptr);
@@ -2075,12 +1997,12 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
instanced = true;
} else {
-
Object *obj = ClassDB::instance(get_class());
ERR_FAIL_COND_V(!obj, nullptr);
node = Object::cast_to<Node>(obj);
- if (!node)
+ if (!node) {
memdelete(obj);
+ }
ERR_FAIL_COND_V(!node, nullptr);
}
@@ -2100,13 +2022,13 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) {
-
Node *descendant = N->get()->get_child(i);
// Skip nodes not really belonging to the instanced hierarchy; they'll be processed normally later
// but remember non-instanced nodes that are hidden below instanced ones
if (descendant->data.owner != this) {
- if (descendant->get_parent() && descendant->get_parent() != this && descendant->get_parent()->data.owner == this && descendant->data.owner != descendant->get_parent())
+ if (descendant->get_parent() && descendant->get_parent() != this && descendant->get_parent()->data.owner == this && descendant->data.owner != descendant->get_parent()) {
hidden_roots.push_back(descendant);
+ }
continue;
}
@@ -2116,7 +2038,6 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
}
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
-
Node *current_node = node->get_node(get_path_to(N->get()));
ERR_CONTINUE(!current_node);
@@ -2132,24 +2053,23 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
N->get()->get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
String name = E->get().name;
- if (name == script_property_name)
+ if (name == script_property_name) {
continue;
+ }
Variant value = N->get()->get(name).duplicate(true);
if (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE) {
-
Resource *res = Object::cast_to<Resource>(value);
if (res) { // Duplicate only if it's a resource
current_node->set(name, res->duplicate());
}
} else {
-
current_node->set(name, value);
}
}
@@ -2160,18 +2080,19 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
}
#ifdef TOOLS_ENABLED
- if ((p_flags & DUPLICATE_FROM_EDITOR) && r_duplimap)
+ if ((p_flags & DUPLICATE_FROM_EDITOR) && r_duplimap) {
r_duplimap->insert(this, node);
+ }
#endif
if (p_flags & DUPLICATE_GROUPS) {
List<GroupInfo> gi;
get_groups(&gi);
for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) {
-
#ifdef TOOLS_ENABLED
- if ((p_flags & DUPLICATE_FROM_EDITOR) && !E->get().persistent)
+ if ((p_flags & DUPLICATE_FROM_EDITOR) && !E->get().persistent) {
continue;
+ }
#endif
node->add_to_group(E->get().name, E->get().persistent);
@@ -2179,15 +2100,15 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
}
for (int i = 0; i < get_child_count(); i++) {
-
- if (get_child(i)->data.parent_owned)
+ if (get_child(i)->data.parent_owned) {
continue;
- if (instanced && get_child(i)->data.owner == this)
+ }
+ if (instanced && get_child(i)->data.owner == this) {
continue; //part of instance
+ }
Node *dup = get_child(i)->_duplicate(p_flags, r_duplimap);
if (!dup) {
-
memdelete(node);
return nullptr;
}
@@ -2199,17 +2120,14 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
}
for (List<const Node *>::Element *E = hidden_roots.front(); E; E = E->next()) {
-
Node *parent = node->get_node(get_path_to(E->get()->data.parent));
if (!parent) {
-
memdelete(node);
return nullptr;
}
Node *dup = E->get()->_duplicate(p_flags, r_duplimap);
if (!dup) {
-
memdelete(node);
return nullptr;
}
@@ -2218,7 +2136,6 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
int pos = E->get()->get_index();
if (pos < parent->get_child_count() - 1) {
-
parent->move_child(dup, pos);
}
}
@@ -2227,7 +2144,6 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
}
Node *Node::duplicate(int p_flags) const {
-
Node *dupe = _duplicate(p_flags);
if (dupe && (p_flags & DUPLICATE_SIGNALS)) {
@@ -2239,7 +2155,6 @@ Node *Node::duplicate(int p_flags) const {
#ifdef TOOLS_ENABLED
Node *Node::duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const {
-
Node *dupe = _duplicate(DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS | DUPLICATE_USE_INSTANCING | DUPLICATE_FROM_EDITOR, &r_duplimap);
// Duplication of signals must happen after all the node descendants have been copied,
@@ -2252,20 +2167,18 @@ Node *Node::duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const {
#endif
void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const {
-
- if (get_owner() != get_parent()->get_owner())
+ if (get_owner() != get_parent()->get_owner()) {
return;
+ }
Node *node = nullptr;
if (get_filename() != "") {
-
Ref<PackedScene> res = ResourceLoader::load(get_filename());
ERR_FAIL_COND_MSG(res.is_null(), "Cannot load scene: " + get_filename());
node = res->instance();
ERR_FAIL_COND(!node);
} else {
-
Object *obj = ClassDB::instance(get_class());
ERR_FAIL_COND_MSG(!obj, "Node: Could not duplicate: " + String(get_class()) + ".");
node = Object::cast_to<Node>(obj);
@@ -2280,9 +2193,9 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
String name = E->get().name;
Variant value = get(name).duplicate(true);
@@ -2293,16 +2206,18 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
List<GroupInfo> groups;
get_groups(&groups);
- for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
node->add_to_group(E->get().name, E->get().persistent);
+ }
node->set_name(get_name());
p_new_parent->add_child(node);
Node *owner = get_owner();
- if (p_reown_map.has(owner))
+ if (p_reown_map.has(owner)) {
owner = p_reown_map[owner];
+ }
if (owner) {
NodePath p = get_path_to(owner);
@@ -2315,7 +2230,6 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
}
for (int i = 0; i < get_child_count(); i++) {
-
get_child(i)->_duplicate_and_reown(node, p_reown_map);
}
}
@@ -2324,51 +2238,57 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
// because re-targeting of connections from some descendant to another is not possible
// if the emitter node comes later in tree order than the receiver
void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
-
- if (this != p_original && (get_owner() != p_original && get_owner() != p_original->get_owner()))
+ if ((this != p_original) && !(p_original->is_a_parent_of(this))) {
return;
+ }
- List<Connection> conns;
- get_all_signal_connections(&conns);
+ List<const Node *> process_list;
+ process_list.push_back(this);
+ while (!process_list.empty()) {
+ const Node *n = process_list.front()->get();
+ process_list.pop_front();
- for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
+ List<Connection> conns;
+ n->get_all_signal_connections(&conns);
- if (E->get().flags & CONNECT_PERSIST) {
- //user connected
- NodePath p = p_original->get_path_to(this);
- Node *copy = p_copy->get_node(p);
+ for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().flags & CONNECT_PERSIST) {
+ //user connected
+ NodePath p = p_original->get_path_to(n);
+ Node *copy = p_copy->get_node(p);
- Node *target = Object::cast_to<Node>(E->get().callable.get_object());
- if (!target) {
- continue;
- }
- NodePath ptarget = p_original->get_path_to(target);
+ Node *target = Object::cast_to<Node>(E->get().callable.get_object());
+ if (!target) {
+ continue;
+ }
+ NodePath ptarget = p_original->get_path_to(target);
- Node *copytarget = target;
+ Node *copytarget = target;
- // Attempt to find a path to the duplicate target, if it seems it's not part
- // of the duplicated and not yet parented hierarchy then at least try to connect
- // to the same target as the original
+ // Attempt to find a path to the duplicate target, if it seems it's not part
+ // of the duplicated and not yet parented hierarchy then at least try to connect
+ // to the same target as the original
- if (p_copy->has_node(ptarget))
- copytarget = p_copy->get_node(ptarget);
+ if (p_copy->has_node(ptarget)) {
+ copytarget = p_copy->get_node(ptarget);
+ }
- if (copy && copytarget) {
- const Callable copy_callable = Callable(copytarget, E->get().callable.get_method());
- if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) {
- copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags);
+ if (copy && copytarget) {
+ const Callable copy_callable = Callable(copytarget, E->get().callable.get_method());
+ if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) {
+ copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags);
+ }
}
}
}
- }
- for (int i = 0; i < get_child_count(); i++) {
- get_child(i)->_duplicate_signals(p_original, p_copy);
+ for (int i = 0; i < n->get_child_count(); i++) {
+ process_list.push_back(n->get_child(i));
+ }
}
}
Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
-
ERR_FAIL_COND_V(get_filename() != "", nullptr);
Object *obj = ClassDB::instance(get_class());
@@ -2386,9 +2306,9 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
String name = E->get().name;
node->set(name, get(name));
}
@@ -2396,11 +2316,11 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
List<GroupInfo> groups;
get_groups(&groups);
- for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
node->add_to_group(E->get().name, E->get().persistent);
+ }
for (int i = 0; i < get_child_count(); i++) {
-
get_child(i)->_duplicate_and_reown(node, p_reown_map);
}
@@ -2412,24 +2332,21 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
}
static void find_owned_by(Node *p_by, Node *p_node, List<Node *> *p_owned) {
-
- if (p_node->get_owner() == p_by)
+ if (p_node->get_owner() == p_by) {
p_owned->push_back(p_node);
+ }
for (int i = 0; i < p_node->get_child_count(); i++) {
-
find_owned_by(p_by, p_node->get_child(i), p_owned);
}
}
struct _NodeReplaceByPair {
-
String name;
Variant value;
};
void Node::replace_by(Node *p_node, bool p_keep_data) {
-
ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(p_node->data.parent);
@@ -2440,15 +2357,14 @@ void Node::replace_by(Node *p_node, bool p_keep_data) {
List<_NodeReplaceByPair> replace_data;
if (p_keep_data) {
-
List<PropertyInfo> plist;
get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
_NodeReplaceByPair rd;
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
rd.name = E->get().name;
rd.value = get(rd.name);
}
@@ -2456,29 +2372,29 @@ void Node::replace_by(Node *p_node, bool p_keep_data) {
List<GroupInfo> groups;
get_groups(&groups);
- for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
p_node->add_to_group(E->get().name, E->get().persistent);
+ }
}
_replace_connections_target(p_node);
if (data.owner) {
- for (int i = 0; i < get_child_count(); i++)
+ for (int i = 0; i < get_child_count(); i++) {
find_owned_by(data.owner, get_child(i), &owned_by_owner);
+ }
}
Node *parent = data.parent;
int pos_in_parent = data.pos;
if (data.parent) {
-
parent->remove_child(this);
parent->add_child(p_node);
parent->move_child(p_node, pos_in_parent);
}
while (get_child_count()) {
-
Node *child = get_child(0);
remove_child(child);
if (!child->is_owned_by_parent()) {
@@ -2488,27 +2404,26 @@ void Node::replace_by(Node *p_node, bool p_keep_data) {
}
p_node->set_owner(owner);
- for (int i = 0; i < owned.size(); i++)
+ for (int i = 0; i < owned.size(); i++) {
owned[i]->set_owner(p_node);
+ }
- for (int i = 0; i < owned_by_owner.size(); i++)
+ for (int i = 0; i < owned_by_owner.size(); i++) {
owned_by_owner[i]->set_owner(owner);
+ }
p_node->set_filename(get_filename());
for (List<_NodeReplaceByPair>::Element *E = replace_data.front(); E; E = E->next()) {
-
p_node->set(E->get().name, E->get().value);
}
}
void Node::_replace_connections_target(Node *p_new_target) {
-
List<Connection> cl;
get_signals_connected_to_this(&cl);
for (List<Connection>::Element *E = cl.front(); E; E = E->next()) {
-
Connection &c = E->get();
if (c.flags & CONNECT_PERSIST) {
@@ -2521,41 +2436,45 @@ void Node::_replace_connections_target(Node *p_new_target) {
}
Vector<Variant> Node::make_binds(VARIANT_ARG_DECLARE) {
-
Vector<Variant> ret;
- if (p_arg1.get_type() == Variant::NIL)
+ if (p_arg1.get_type() == Variant::NIL) {
return ret;
- else
+ } else {
ret.push_back(p_arg1);
+ }
- if (p_arg2.get_type() == Variant::NIL)
+ if (p_arg2.get_type() == Variant::NIL) {
return ret;
- else
+ } else {
ret.push_back(p_arg2);
+ }
- if (p_arg3.get_type() == Variant::NIL)
+ if (p_arg3.get_type() == Variant::NIL) {
return ret;
- else
+ } else {
ret.push_back(p_arg3);
+ }
- if (p_arg4.get_type() == Variant::NIL)
+ if (p_arg4.get_type() == Variant::NIL) {
return ret;
- else
+ } else {
ret.push_back(p_arg4);
+ }
- if (p_arg5.get_type() == Variant::NIL)
+ if (p_arg5.get_type() == Variant::NIL) {
return ret;
- else
+ } else {
ret.push_back(p_arg5);
+ }
return ret;
}
bool Node::has_node_and_resource(const NodePath &p_path) const {
-
- if (!has_node(p_path))
+ if (!has_node(p_path)) {
return false;
+ }
RES res;
Vector<StringName> leftover_path;
Node *node = get_node_and_resource(p_path, res, leftover_path, false);
@@ -2564,21 +2483,22 @@ bool Node::has_node_and_resource(const NodePath &p_path) const {
}
Array Node::_get_node_and_resource(const NodePath &p_path) {
-
RES res;
Vector<StringName> leftover_path;
Node *node = get_node_and_resource(p_path, res, leftover_path, false);
Array result;
- if (node)
+ if (node) {
result.push_back(node);
- else
+ } else {
result.push_back(Variant());
+ }
- if (res.is_valid())
+ if (res.is_valid()) {
result.push_back(res);
- else
+ } else {
result.push_back(Variant());
+ }
result.push_back(NodePath(Vector<StringName>(), leftover_path, false));
@@ -2586,15 +2506,14 @@ Array Node::_get_node_and_resource(const NodePath &p_path) {
}
Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property) const {
-
Node *node = get_node(p_path);
r_res = RES();
r_leftover_subpath = Vector<StringName>();
- if (!node)
+ if (!node) {
return nullptr;
+ }
if (p_path.get_subname_count()) {
-
int j = 0;
// If not p_last_is_property, we shouldn't consider the last one as part of the resource
for (; j < p_path.get_subname_count() - (int)p_last_is_property; j++) {
@@ -2622,7 +2541,6 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str
}
void Node::_set_tree(SceneTree *p_tree) {
-
SceneTree *tree_changed_a = nullptr;
SceneTree *tree_changed_b = nullptr;
@@ -2637,7 +2555,6 @@ void Node::_set_tree(SceneTree *p_tree) {
data.tree = p_tree;
if (data.tree) {
-
_propagate_enter_tree();
if (!data.parent || data.parent->data.ready_notified) { // No parent (root) or parent ready
_propagate_ready(); //reverse_notification(NOTIFICATION_READY);
@@ -2646,21 +2563,24 @@ void Node::_set_tree(SceneTree *p_tree) {
tree_changed_b = data.tree;
}
- if (tree_changed_a)
+ if (tree_changed_a) {
tree_changed_a->tree_changed();
- if (tree_changed_b)
+ }
+ if (tree_changed_b) {
tree_changed_b->tree_changed();
+ }
}
#ifdef DEBUG_ENABLED
static void _Node_debug_sn(Object *p_obj) {
-
Node *n = Object::cast_to<Node>(p_obj);
- if (!n)
+ if (!n) {
return;
+ }
- if (n->is_inside_tree())
+ if (n->is_inside_tree()) {
return;
+ }
Node *p = n;
while (p->get_parent()) {
@@ -2668,28 +2588,26 @@ static void _Node_debug_sn(Object *p_obj) {
}
String path;
- if (p == n)
+ if (p == n) {
path = n->get_name();
- else
+ } else {
path = String(p->get_name()) + "/" + p->get_path_to(n);
+ }
print_line(itos(p_obj->get_instance_id()) + " - Stray Node: " + path + " (Type: " + n->get_class() + ")");
}
#endif // DEBUG_ENABLED
void Node::_print_stray_nodes() {
-
print_stray_nodes();
}
void Node::print_stray_nodes() {
-
#ifdef DEBUG_ENABLED
ObjectDB::debug_objects(_Node_debug_sn);
#endif
}
void Node::queue_delete() {
-
if (is_inside_tree()) {
get_tree()->queue_delete(this);
} else {
@@ -2698,25 +2616,23 @@ void Node::queue_delete() {
}
TypedArray<Node> Node::_get_children() const {
-
TypedArray<Node> arr;
int cc = get_child_count();
arr.resize(cc);
- for (int i = 0; i < cc; i++)
+ for (int i = 0; i < cc; i++) {
arr[i] = get_child(i);
+ }
return arr;
}
void Node::set_import_path(const NodePath &p_import_path) {
-
#ifdef TOOLS_ENABLED
data.import_path = p_import_path;
#endif
}
NodePath Node::get_import_path() const {
-
#ifdef TOOLS_ENABLED
return data.import_path;
#else
@@ -2725,15 +2641,15 @@ NodePath Node::get_import_path() const {
}
static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<String> *r_options) {
-
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
const String quote_style = "\"";
#endif
- if (p_node != p_base && !p_node->get_owner())
+ if (p_node != p_base && !p_node->get_owner()) {
return;
+ }
String n = p_base->get_path_to(p_node);
r_options->push_back(quote_style + n + quote_style);
for (int i = 0; i < p_node->get_child_count(); i++) {
@@ -2742,17 +2658,14 @@ static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<S
}
void Node::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-
String pf = p_function;
if ((pf == "has_node" || pf == "get_node") && p_idx == 0) {
-
_add_nodes_to_options(this, this, r_options);
}
Object::get_argument_options(p_function, p_idx, r_options);
}
void Node::clear_internal_tree_resource_paths() {
-
clear_internal_resource_paths();
for (int i = 0; i < data.children.size(); i++) {
data.children[i]->clear_internal_tree_resource_paths();
@@ -2760,7 +2673,6 @@ void Node::clear_internal_tree_resource_paths() {
}
String Node::get_configuration_warning() const {
-
if (get_script_instance() && get_script_instance()->get_script().is_valid() &&
get_script_instance()->get_script()->is_tool() && get_script_instance()->has_method("_get_configuration_warning")) {
return get_script_instance()->call("_get_configuration_warning");
@@ -2769,10 +2681,10 @@ String Node::get_configuration_warning() const {
}
void Node::update_configuration_warning() {
-
#ifdef TOOLS_ENABLED
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed, this);
}
@@ -2788,7 +2700,6 @@ void Node::set_display_folded(bool p_folded) {
}
bool Node::is_displayed_folded() const {
-
return data.display_folded;
}
@@ -2797,13 +2708,12 @@ void Node::request_ready() {
}
void Node::_bind_methods() {
-
GLOBAL_DEF("node/name_num_separator", 0);
ProjectSettings::get_singleton()->set_custom_property_info("node/name_num_separator", PropertyInfo(Variant::INT, "node/name_num_separator", PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
GLOBAL_DEF("node/name_casing", NAME_CASING_PASCAL_CASE);
ProjectSettings::get_singleton()->set_custom_property_info("node/name_casing", PropertyInfo(Variant::INT, "node/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"));
- ClassDB::bind_method(D_METHOD("add_child_below_node", "preceding_node", "node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_sibling", "sibling", "legible_unique_name"), &Node::add_sibling, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_name", "name"), &Node::set_name);
ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name);
@@ -3011,7 +2921,6 @@ String Node::_get_name_num_separator() {
}
Node::Node() {
-
data.pos = -1;
data.depth = -1;
data.blocked = 0;
@@ -3045,7 +2954,6 @@ Node::Node() {
}
Node::~Node() {
-
data.grouped.clear();
data.owned.clear();
data.children.clear();
diff --git a/scene/main/node.h b/scene/main/node.h
index 1c1b7bbd7a..7595aabd9a 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -43,7 +43,6 @@
class Viewport;
class SceneState;
class Node : public Object {
-
GDCLASS(Node, Object);
OBJ_CATEGORY("Nodes");
@@ -67,12 +66,10 @@ public:
};
struct Comparator {
-
bool operator()(const Node *p_a, const Node *p_b) const { return p_b->is_greater_than(p_a); }
};
struct ComparatorWithPriority {
-
bool operator()(const Node *p_a, const Node *p_b) const { return p_b->data.process_priority == p_a->data.process_priority ? p_b->is_greater_than(p_a) : p_b->data.process_priority > p_a->data.process_priority; }
};
@@ -80,7 +77,6 @@ public:
private:
struct GroupData {
-
bool persistent;
SceneTree::Group *group;
GroupData() { persistent = false; }
@@ -92,7 +88,6 @@ private:
};
struct Data {
-
String filename;
Ref<SceneState> instance_state;
Ref<SceneState> inherited_state;
@@ -271,7 +266,7 @@ public:
void set_name(const String &p_name);
void add_child(Node *p_child, bool p_legible_unique_name = false);
- void add_child_below_node(Node *p_node, Node *p_child, bool p_legible_unique_name = false);
+ void add_sibling(Node *p_sibling, bool p_legible_unique_name = false);
void remove_child(Node *p_child);
int get_child_count() const;
@@ -305,7 +300,6 @@ public:
bool is_in_group(const StringName &p_identifier) const;
struct GroupInfo {
-
StringName name;
bool persistent;
};
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index 43a61834eb..c1d4435687 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -31,7 +31,6 @@
#include "resource_preloader.h"
void ResourcePreloader::_set_resources(const Array &p_data) {
-
resources.clear();
ERR_FAIL_COND(p_data.size() != 2);
@@ -41,7 +40,6 @@ void ResourcePreloader::_set_resources(const Array &p_data) {
ERR_FAIL_COND(names.size() != resdata.size());
for (int i = 0; i < resdata.size(); i++) {
-
String name = names[i];
RES resource = resdata[i];
ERR_CONTINUE(!resource.is_valid());
@@ -52,7 +50,6 @@ void ResourcePreloader::_set_resources(const Array &p_data) {
}
Array ResourcePreloader::_get_resources() const {
-
Vector<String> names;
Array arr;
arr.resize(resources.size());
@@ -66,7 +63,6 @@ Array ResourcePreloader::_get_resources() const {
int i = 0;
for (Set<String>::Element *E = sorted_names.front(); E; E = E->next()) {
-
names.set(i, E->get());
arr[i] = resources[E->get()];
i++;
@@ -79,15 +75,12 @@ Array ResourcePreloader::_get_resources() const {
}
void ResourcePreloader::add_resource(const StringName &p_name, const RES &p_resource) {
-
ERR_FAIL_COND(p_resource.is_null());
if (resources.has(p_name)) {
-
StringName new_name;
int idx = 2;
while (true) {
-
new_name = p_name.operator String() + " " + itos(idx);
if (resources.has(new_name)) {
idx++;
@@ -99,18 +92,16 @@ void ResourcePreloader::add_resource(const StringName &p_name, const RES &p_reso
add_resource(new_name, p_resource);
} else {
-
resources[p_name] = p_resource;
}
}
void ResourcePreloader::remove_resource(const StringName &p_name) {
-
ERR_FAIL_COND(!resources.has(p_name));
resources.erase(p_name);
}
-void ResourcePreloader::rename_resource(const StringName &p_from_name, const StringName &p_to_name) {
+void ResourcePreloader::rename_resource(const StringName &p_from_name, const StringName &p_to_name) {
ERR_FAIL_COND(!resources.has(p_from_name));
RES res = resources[p_from_name];
@@ -120,17 +111,15 @@ void ResourcePreloader::rename_resource(const StringName &p_from_name, const Str
}
bool ResourcePreloader::has_resource(const StringName &p_name) const {
-
return resources.has(p_name);
}
-RES ResourcePreloader::get_resource(const StringName &p_name) const {
+RES ResourcePreloader::get_resource(const StringName &p_name) const {
ERR_FAIL_COND_V(!resources.has(p_name), RES());
return resources[p_name];
}
Vector<String> ResourcePreloader::_get_resource_list() const {
-
Vector<String> res;
res.resize(resources.size());
int i = 0;
@@ -142,15 +131,12 @@ Vector<String> ResourcePreloader::_get_resource_list() const {
}
void ResourcePreloader::get_resource_list(List<StringName> *p_list) {
-
for (Map<StringName, RES>::Element *E = resources.front(); E; E = E->next()) {
-
p_list->push_back(E->key());
}
}
void ResourcePreloader::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_set_resources"), &ResourcePreloader::_set_resources);
ClassDB::bind_method(D_METHOD("_get_resources"), &ResourcePreloader::_get_resources);
diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h
index 9ad219dd92..580dc35a57 100644
--- a/scene/main/resource_preloader.h
+++ b/scene/main/resource_preloader.h
@@ -34,7 +34,6 @@
#include "scene/main/node.h"
class ResourcePreloader : public Node {
-
GDCLASS(ResourcePreloader, Node);
Map<StringName, RES> resources;
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 94be22ccd2..a0e10f30c0 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -56,7 +56,6 @@
#include <stdio.h>
void SceneTreeTimer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_time_left", "time"), &SceneTreeTimer::set_time_left);
ClassDB::bind_method(D_METHOD("get_time_left"), &SceneTreeTimer::get_time_left);
@@ -74,7 +73,6 @@ float SceneTreeTimer::get_time_left() const {
}
void SceneTreeTimer::set_pause_mode_process(bool p_pause_mode_process) {
-
process_pause = p_pause_mode_process;
}
@@ -83,7 +81,6 @@ bool SceneTreeTimer::is_pause_mode_process() {
}
void SceneTreeTimer::release_connections() {
-
List<Connection> connections;
get_all_signal_connections(&connections);
@@ -99,33 +96,29 @@ SceneTreeTimer::SceneTreeTimer() {
}
void SceneTree::tree_changed() {
-
tree_version++;
emit_signal(tree_changed_name);
}
void SceneTree::node_added(Node *p_node) {
-
emit_signal(node_added_name, p_node);
}
void SceneTree::node_removed(Node *p_node) {
-
if (current_scene == p_node) {
current_scene = nullptr;
}
emit_signal(node_removed_name, p_node);
- if (call_lock > 0)
+ if (call_lock > 0) {
call_skip.insert(p_node);
+ }
}
void SceneTree::node_renamed(Node *p_node) {
-
emit_signal(node_renamed_name, p_node);
}
SceneTree::Group *SceneTree::add_to_group(const StringName &p_group, Node *p_node) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E) {
E = group_map.insert(p_group, Group());
@@ -139,26 +132,25 @@ SceneTree::Group *SceneTree::add_to_group(const StringName &p_group, Node *p_nod
}
void SceneTree::remove_from_group(const StringName &p_group, Node *p_node) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
ERR_FAIL_COND(!E);
E->get().nodes.erase(p_node);
- if (E->get().nodes.empty())
+ if (E->get().nodes.empty()) {
group_map.erase(E);
+ }
}
void SceneTree::make_group_changed(const StringName &p_group) {
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (E)
+ if (E) {
E->get().changed = true;
+ }
}
void SceneTree::flush_transform_notifications() {
-
SelfList<Node> *n = xform_change_list.first();
while (n) {
-
Node *node = n->self();
SelfList<Node> *nx = n->next();
xform_change_list.remove(n);
@@ -168,16 +160,15 @@ void SceneTree::flush_transform_notifications() {
}
void SceneTree::_flush_ugc() {
-
ugc_locked = true;
while (unique_group_calls.size()) {
-
Map<UGCall, Vector<Variant>>::Element *E = unique_group_calls.front();
Variant v[VARIANT_ARG_MAX];
- for (int i = 0; i < E->get().size(); i++)
+ for (int i = 0; i < E->get().size(); i++) {
v[i] = E->get()[i];
+ }
call_group_flags(GROUP_CALL_REALTIME, E->key().group, E->key().call, v[0], v[1], v[2], v[3], v[4]);
@@ -188,11 +179,12 @@ void SceneTree::_flush_ugc() {
}
void SceneTree::_update_group_order(Group &g, bool p_use_priority) {
-
- if (!g.changed)
+ if (!g.changed) {
return;
- if (g.nodes.empty())
+ }
+ if (g.nodes.empty()) {
return;
+ }
Node **nodes = g.nodes.ptrw();
int node_count = g.nodes.size();
@@ -208,31 +200,33 @@ void SceneTree::_update_group_order(Group &g, bool p_use_priority) {
}
void SceneTree::call_group_flags(uint32_t p_call_flags, const StringName &p_group, const StringName &p_function, VARIANT_ARG_DECLARE) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return;
+ }
Group &g = E->get();
- if (g.nodes.empty())
+ if (g.nodes.empty()) {
return;
+ }
if (p_call_flags & GROUP_CALL_UNIQUE && !(p_call_flags & GROUP_CALL_REALTIME)) {
-
ERR_FAIL_COND(ugc_locked);
UGCall ug;
ug.call = p_function;
ug.group = p_group;
- if (unique_group_calls.has(ug))
+ if (unique_group_calls.has(ug)) {
return;
+ }
VARIANT_ARGPTRS;
Vector<Variant> args;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
- if (argptr[i]->get_type() == Variant::NIL)
+ if (argptr[i]->get_type() == Variant::NIL) {
break;
+ }
args.push_back(*argptr[i]);
}
@@ -249,51 +243,55 @@ void SceneTree::call_group_flags(uint32_t p_call_flags, const StringName &p_grou
call_lock++;
if (p_call_flags & GROUP_CALL_REVERSE) {
-
for (int i = node_count - 1; i >= 0; i--) {
-
- if (call_lock && call_skip.has(nodes[i]))
+ if (call_lock && call_skip.has(nodes[i])) {
continue;
+ }
if (p_call_flags & GROUP_CALL_REALTIME) {
- if (p_call_flags & GROUP_CALL_MULTILEVEL)
+ if (p_call_flags & GROUP_CALL_MULTILEVEL) {
nodes[i]->call_multilevel(p_function, VARIANT_ARG_PASS);
- else
+ } else {
nodes[i]->call(p_function, VARIANT_ARG_PASS);
- } else
+ }
+ } else {
MessageQueue::get_singleton()->push_call(nodes[i], p_function, VARIANT_ARG_PASS);
+ }
}
} else {
-
for (int i = 0; i < node_count; i++) {
-
- if (call_lock && call_skip.has(nodes[i]))
+ if (call_lock && call_skip.has(nodes[i])) {
continue;
+ }
if (p_call_flags & GROUP_CALL_REALTIME) {
- if (p_call_flags & GROUP_CALL_MULTILEVEL)
+ if (p_call_flags & GROUP_CALL_MULTILEVEL) {
nodes[i]->call_multilevel(p_function, VARIANT_ARG_PASS);
- else
+ } else {
nodes[i]->call(p_function, VARIANT_ARG_PASS);
- } else
+ }
+ } else {
MessageQueue::get_singleton()->push_call(nodes[i], p_function, VARIANT_ARG_PASS);
+ }
}
}
call_lock--;
- if (call_lock == 0)
+ if (call_lock == 0) {
call_skip.clear();
+ }
}
void SceneTree::notify_group_flags(uint32_t p_call_flags, const StringName &p_group, int p_notification) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return;
+ }
Group &g = E->get();
- if (g.nodes.empty())
+ if (g.nodes.empty()) {
return;
+ }
_update_group_order(g);
@@ -304,45 +302,47 @@ void SceneTree::notify_group_flags(uint32_t p_call_flags, const StringName &p_gr
call_lock++;
if (p_call_flags & GROUP_CALL_REVERSE) {
-
for (int i = node_count - 1; i >= 0; i--) {
-
- if (call_lock && call_skip.has(nodes[i]))
+ if (call_lock && call_skip.has(nodes[i])) {
continue;
+ }
- if (p_call_flags & GROUP_CALL_REALTIME)
+ if (p_call_flags & GROUP_CALL_REALTIME) {
nodes[i]->notification(p_notification);
- else
+ } else {
MessageQueue::get_singleton()->push_notification(nodes[i], p_notification);
+ }
}
} else {
-
for (int i = 0; i < node_count; i++) {
-
- if (call_lock && call_skip.has(nodes[i]))
+ if (call_lock && call_skip.has(nodes[i])) {
continue;
+ }
- if (p_call_flags & GROUP_CALL_REALTIME)
+ if (p_call_flags & GROUP_CALL_REALTIME) {
nodes[i]->notification(p_notification);
- else
+ } else {
MessageQueue::get_singleton()->push_notification(nodes[i], p_notification);
+ }
}
}
call_lock--;
- if (call_lock == 0)
+ if (call_lock == 0) {
call_skip.clear();
+ }
}
void SceneTree::set_group_flags(uint32_t p_call_flags, const StringName &p_group, const String &p_name, const Variant &p_value) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return;
+ }
Group &g = E->get();
- if (g.nodes.empty())
+ if (g.nodes.empty()) {
return;
+ }
_update_group_order(g);
@@ -353,35 +353,36 @@ void SceneTree::set_group_flags(uint32_t p_call_flags, const StringName &p_group
call_lock++;
if (p_call_flags & GROUP_CALL_REVERSE) {
-
for (int i = node_count - 1; i >= 0; i--) {
-
- if (call_lock && call_skip.has(nodes[i]))
+ if (call_lock && call_skip.has(nodes[i])) {
continue;
+ }
- if (p_call_flags & GROUP_CALL_REALTIME)
+ if (p_call_flags & GROUP_CALL_REALTIME) {
nodes[i]->set(p_name, p_value);
- else
+ } else {
MessageQueue::get_singleton()->push_set(nodes[i], p_name, p_value);
+ }
}
} else {
-
for (int i = 0; i < node_count; i++) {
-
- if (call_lock && call_skip.has(nodes[i]))
+ if (call_lock && call_skip.has(nodes[i])) {
continue;
+ }
- if (p_call_flags & GROUP_CALL_REALTIME)
+ if (p_call_flags & GROUP_CALL_REALTIME) {
nodes[i]->set(p_name, p_value);
- else
+ } else {
MessageQueue::get_singleton()->push_set(nodes[i], p_name, p_value);
+ }
}
}
call_lock--;
- if (call_lock == 0)
+ if (call_lock == 0) {
call_skip.clear();
+ }
}
void SceneTree::call_group(const StringName &p_group, const StringName &p_function, VARIANT_ARG_DECLARE) {
@@ -389,12 +390,10 @@ void SceneTree::call_group(const StringName &p_group, const StringName &p_functi
}
void SceneTree::notify_group(const StringName &p_group, int p_notification) {
-
notify_group_flags(0, p_group, p_notification);
}
void SceneTree::set_group(const StringName &p_group, const String &p_name, const Variant &p_value) {
-
set_group_flags(0, p_group, p_name, p_value);
}
@@ -405,7 +404,6 @@ void SceneTree::init() {
}
bool SceneTree::iteration(float p_time) {
-
root_lock++;
current_frame++;
@@ -432,7 +430,6 @@ bool SceneTree::iteration(float p_time) {
}
bool SceneTree::idle(float p_time) {
-
//print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
//print_line("node count: "+itos(get_node_count()));
//print_line("TEXTURE RAM: "+itos(RS::get_singleton()->get_render_info(RS::INFO_TEXTURE_MEM_USED)));
@@ -470,7 +467,6 @@ bool SceneTree::idle(float p_time) {
List<Ref<SceneTreeTimer>>::Element *L = timers.back(); //last element
for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E;) {
-
List<Ref<SceneTreeTimer>>::Element *N = E->next();
if (pause && !E->get()->is_pause_mode_process()) {
if (E == L) {
@@ -509,7 +505,6 @@ bool SceneTree::idle(float p_time) {
cpath = fallback->get_path();
}
if (cpath != env_path) {
-
if (env_path != String()) {
fallback = ResourceLoader::load(env_path);
if (fallback.is_null()) {
@@ -529,7 +524,6 @@ bool SceneTree::idle(float p_time) {
}
void SceneTree::finish() {
-
_flush_delete_queue();
_flush_ugc();
@@ -553,7 +547,6 @@ void SceneTree::finish() {
}
void SceneTree::quit(int p_exit_code) {
-
if (p_exit_code >= 0) {
// Override the exit code if a positive argument is given (the default is `-1`).
// This is a shorthand for calling `set_exit_code()` on the OS singleton then quitting.
@@ -564,11 +557,11 @@ void SceneTree::quit(int p_exit_code) {
}
void SceneTree::_main_window_close() {
-
if (accept_quit) {
_quit = true;
}
}
+
void SceneTree::_main_window_go_back() {
if (quit_on_go_back) {
_quit = true;
@@ -583,9 +576,7 @@ void SceneTree::_main_window_focus_in() {
}
void SceneTree::_notification(int p_notification) {
-
switch (p_notification) {
-
case NOTIFICATION_TRANSLATION_CHANGED: {
if (!Engine::get_singleton()->is_editor_hint()) {
get_root()->propagate_notification(p_notification);
@@ -597,7 +588,6 @@ void SceneTree::_notification(int p_notification) {
case NOTIFICATION_CRASH:
case NOTIFICATION_APP_RESUMED:
case NOTIFICATION_APP_PAUSED: {
-
get_root()->propagate_notification(p_notification);
} break;
@@ -607,89 +597,74 @@ void SceneTree::_notification(int p_notification) {
};
void SceneTree::set_auto_accept_quit(bool p_enable) {
-
accept_quit = p_enable;
}
void SceneTree::set_quit_on_go_back(bool p_enable) {
-
quit_on_go_back = p_enable;
}
#ifdef TOOLS_ENABLED
bool SceneTree::is_node_being_edited(const Node *p_node) const {
-
return Engine::get_singleton()->is_editor_hint() && edited_scene_root && (edited_scene_root->is_a_parent_of(p_node) || edited_scene_root == p_node);
}
#endif
#ifdef DEBUG_ENABLED
void SceneTree::set_debug_collisions_hint(bool p_enabled) {
-
debug_collisions_hint = p_enabled;
}
bool SceneTree::is_debugging_collisions_hint() const {
-
return debug_collisions_hint;
}
void SceneTree::set_debug_navigation_hint(bool p_enabled) {
-
debug_navigation_hint = p_enabled;
}
bool SceneTree::is_debugging_navigation_hint() const {
-
return debug_navigation_hint;
}
#endif
void SceneTree::set_debug_collisions_color(const Color &p_color) {
-
debug_collisions_color = p_color;
}
Color SceneTree::get_debug_collisions_color() const {
-
return debug_collisions_color;
}
void SceneTree::set_debug_collision_contact_color(const Color &p_color) {
-
debug_collision_contact_color = p_color;
}
Color SceneTree::get_debug_collision_contact_color() const {
-
return debug_collision_contact_color;
}
void SceneTree::set_debug_navigation_color(const Color &p_color) {
-
debug_navigation_color = p_color;
}
Color SceneTree::get_debug_navigation_color() const {
-
return debug_navigation_color;
}
void SceneTree::set_debug_navigation_disabled_color(const Color &p_color) {
-
debug_navigation_disabled_color = p_color;
}
Color SceneTree::get_debug_navigation_disabled_color() const {
-
return debug_navigation_disabled_color;
}
Ref<Material> SceneTree::get_debug_navigation_material() {
-
- if (navigation_material.is_valid())
+ if (navigation_material.is_valid()) {
return navigation_material;
+ }
Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -704,9 +679,9 @@ Ref<Material> SceneTree::get_debug_navigation_material() {
}
Ref<Material> SceneTree::get_debug_navigation_disabled_material() {
-
- if (navigation_disabled_material.is_valid())
+ if (navigation_disabled_material.is_valid()) {
return navigation_disabled_material;
+ }
Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -719,10 +694,11 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material() {
return navigation_disabled_material;
}
-Ref<Material> SceneTree::get_debug_collision_material() {
- if (collision_material.is_valid())
+Ref<Material> SceneTree::get_debug_collision_material() {
+ if (collision_material.is_valid()) {
return collision_material;
+ }
Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -737,9 +713,9 @@ Ref<Material> SceneTree::get_debug_collision_material() {
}
Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
-
- if (debug_contact_mesh.is_valid())
+ if (debug_contact_mesh.is_valid()) {
return debug_contact_mesh;
+ }
debug_contact_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
@@ -773,12 +749,14 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
/* clang-format on */
Vector<int> indices;
- for (int i = 0; i < 8 * 3; i++)
+ for (int i = 0; i < 8 * 3; i++) {
indices.push_back(diamond_faces[i]);
+ }
Vector<Vector3> vertices;
- for (int i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++) {
vertices.push_back(diamond[i] * 0.1);
+ }
Array arr;
arr.resize(Mesh::ARRAY_MAX);
@@ -792,30 +770,31 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
}
void SceneTree::set_pause(bool p_enabled) {
-
- if (p_enabled == pause)
+ if (p_enabled == pause) {
return;
+ }
pause = p_enabled;
NavigationServer3D::get_singleton()->set_active(!p_enabled);
PhysicsServer3D::get_singleton()->set_active(!p_enabled);
PhysicsServer2D::get_singleton()->set_active(!p_enabled);
- if (get_root())
+ if (get_root()) {
get_root()->propagate_notification(p_enabled ? Node::NOTIFICATION_PAUSED : Node::NOTIFICATION_UNPAUSED);
+ }
}
bool SceneTree::is_paused() const {
-
return pause;
}
void SceneTree::_notify_group_pause(const StringName &p_group, int p_notification) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return;
+ }
Group &g = E->get();
- if (g.nodes.empty())
+ if (g.nodes.empty()) {
return;
+ }
_update_group_order(g, p_notification == Node::NOTIFICATION_PROCESS || p_notification == Node::NOTIFICATION_INTERNAL_PROCESS || p_notification == Node::NOTIFICATION_PHYSICS_PROCESS || p_notification == Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
@@ -829,23 +808,26 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio
call_lock++;
for (int i = 0; i < node_count; i++) {
-
Node *n = nodes[i];
- if (call_lock && call_skip.has(n))
+ if (call_lock && call_skip.has(n)) {
continue;
+ }
- if (!n->can_process())
+ if (!n->can_process()) {
continue;
- if (!n->can_process_notification(p_notification))
+ }
+ if (!n->can_process_notification(p_notification)) {
continue;
+ }
n->notification(p_notification);
//ERR_FAIL_COND(node_count != g.nodes.size());
}
call_lock--;
- if (call_lock == 0)
+ if (call_lock == 0) {
call_skip.clear();
+ }
}
/*
@@ -857,16 +839,18 @@ void SceneMainLoop::_update_listener_2d() {
}
}
+
*/
void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input, Viewport *p_viewport) {
-
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return;
+ }
Group &g = E->get();
- if (g.nodes.empty())
+ if (g.nodes.empty()) {
return;
+ }
_update_group_order(g);
@@ -883,27 +867,30 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
call_lock++;
for (int i = node_count - 1; i >= 0; i--) {
-
- if (p_viewport->is_input_handled())
+ if (p_viewport->is_input_handled()) {
break;
+ }
Node *n = nodes[i];
- if (call_lock && call_skip.has(n))
+ if (call_lock && call_skip.has(n)) {
continue;
+ }
- if (!n->can_process())
+ if (!n->can_process()) {
continue;
+ }
n->call_multilevel(p_method, (const Variant **)v, 1);
//ERR_FAIL_COND(node_count != g.nodes.size());
}
call_lock--;
- if (call_lock == 0)
+ if (call_lock == 0) {
call_skip.clear();
+ }
}
-Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
+Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
ERR_FAIL_COND_V(p_argcount < 3, Variant());
@@ -917,7 +904,6 @@ Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Cal
Variant v[VARIANT_ARG_MAX];
for (int i = 0; i < MIN(p_argcount - 3, 5); i++) {
-
v[i] = *p_args[i + 3];
}
@@ -926,7 +912,6 @@ Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Cal
}
Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_OK;
ERR_FAIL_COND_V(p_argcount < 2, Variant());
@@ -938,7 +923,6 @@ Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Callable:
Variant v[VARIANT_ARG_MAX];
for (int i = 0; i < MIN(p_argcount - 2, 5); i++) {
-
v[i] = *p_args[i + 2];
}
@@ -947,31 +931,30 @@ Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Callable:
}
int64_t SceneTree::get_frame() const {
-
return current_frame;
}
-int64_t SceneTree::get_event_count() const {
+int64_t SceneTree::get_event_count() const {
return current_event;
}
Array SceneTree::_get_nodes_in_group(const StringName &p_group) {
-
Array ret;
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return ret;
+ }
_update_group_order(E->get()); //update order just in case
int nc = E->get().nodes.size();
- if (nc == 0)
+ if (nc == 0) {
return ret;
+ }
ret.resize(nc);
Node **ptr = E->get().nodes.ptrw();
for (int i = 0; i < nc; i++) {
-
ret[i] = ptr[i];
}
@@ -979,32 +962,30 @@ Array SceneTree::_get_nodes_in_group(const StringName &p_group) {
}
bool SceneTree::has_group(const StringName &p_identifier) const {
-
return group_map.has(p_identifier);
}
-void SceneTree::get_nodes_in_group(const StringName &p_group, List<Node *> *p_list) {
+void SceneTree::get_nodes_in_group(const StringName &p_group, List<Node *> *p_list) {
Map<StringName, Group>::Element *E = group_map.find(p_group);
- if (!E)
+ if (!E) {
return;
+ }
_update_group_order(E->get()); //update order just in case
int nc = E->get().nodes.size();
- if (nc == 0)
+ if (nc == 0) {
return;
+ }
Node **ptr = E->get().nodes.ptrw();
for (int i = 0; i < nc; i++) {
-
p_list->push_back(ptr[i]);
}
}
void SceneTree::_flush_delete_queue() {
-
_THREAD_SAFE_METHOD_
while (delete_queue.size()) {
-
Object *obj = ObjectDB::get_instance(delete_queue.front()->get());
if (obj) {
memdelete(obj);
@@ -1014,7 +995,6 @@ void SceneTree::_flush_delete_queue() {
}
void SceneTree::queue_delete(Object *p_object) {
-
_THREAD_SAFE_METHOD_
ERR_FAIL_NULL(p_object);
p_object->_is_queued_for_deletion = true;
@@ -1022,7 +1002,6 @@ void SceneTree::queue_delete(Object *p_object) {
}
int SceneTree::get_node_count() const {
-
return node_count;
}
@@ -1033,7 +1012,6 @@ void SceneTree::set_edited_scene_root(Node *p_node) {
}
Node *SceneTree::get_edited_scene_root() const {
-
#ifdef TOOLS_ENABLED
return edited_scene_root;
#else
@@ -1042,18 +1020,15 @@ Node *SceneTree::get_edited_scene_root() const {
}
void SceneTree::set_current_scene(Node *p_scene) {
-
ERR_FAIL_COND(p_scene && p_scene->get_parent() != root);
current_scene = p_scene;
}
Node *SceneTree::get_current_scene() const {
-
return current_scene;
}
void SceneTree::_change_scene(Node *p_to) {
-
if (current_scene) {
memdelete(current_scene);
current_scene = nullptr;
@@ -1075,8 +1050,9 @@ void SceneTree::_change_scene(Node *p_to) {
Error SceneTree::change_scene(const String &p_path) {
Ref<PackedScene> new_scene = ResourceLoader::load(p_path);
- if (new_scene.is_null())
+ if (new_scene.is_null()) {
return ERR_CANT_OPEN;
+ }
return change_scene_to(new_scene);
}
@@ -1099,13 +1075,11 @@ Error SceneTree::reload_current_scene() {
}
void SceneTree::add_current_scene(Node *p_current) {
-
current_scene = p_current;
root->add_child(p_current);
}
Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) {
-
Ref<SceneTreeTimer> stt;
stt.instance();
stt->set_pause_mode_process(p_process_pause);
@@ -1115,27 +1089,22 @@ Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pa
}
void SceneTree::_network_peer_connected(int p_id) {
-
emit_signal("network_peer_connected", p_id);
}
void SceneTree::_network_peer_disconnected(int p_id) {
-
emit_signal("network_peer_disconnected", p_id);
}
void SceneTree::_connected_to_server() {
-
emit_signal("connected_to_server");
}
void SceneTree::_connection_failed() {
-
emit_signal("connection_failed");
}
void SceneTree::_server_disconnected() {
-
emit_signal("server_disconnected");
}
@@ -1173,17 +1142,14 @@ void SceneTree::set_multiplayer(Ref<MultiplayerAPI> p_multiplayer) {
}
void SceneTree::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_network_peer) {
-
multiplayer->set_network_peer(p_network_peer);
}
Ref<NetworkedMultiplayerPeer> SceneTree::get_network_peer() const {
-
return multiplayer->get_network_peer();
}
bool SceneTree::is_network_server() const {
-
return multiplayer->is_network_server();
}
@@ -1192,12 +1158,10 @@ bool SceneTree::has_network_peer() const {
}
int SceneTree::get_network_unique_id() const {
-
return multiplayer->get_network_unique_id();
}
Vector<int> SceneTree::get_network_connected_peers() const {
-
return multiplayer->get_network_connected_peers();
}
@@ -1214,7 +1178,6 @@ bool SceneTree::is_refusing_new_network_connections() const {
}
void SceneTree::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_root"), &SceneTree::get_root);
ClassDB::bind_method(D_METHOD("has_group", "name"), &SceneTree::has_group);
@@ -1327,7 +1290,6 @@ SceneTree::IdleCallback SceneTree::idle_callbacks[SceneTree::MAX_IDLE_CALLBACKS]
int SceneTree::idle_callback_count = 0;
void SceneTree::_call_idle_callbacks() {
-
for (int i = 0; i < idle_callback_count; i++) {
idle_callbacks[i]();
}
@@ -1339,7 +1301,6 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) {
}
void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-
if (p_function == "change_scene") {
DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
List<String> directories;
@@ -1371,9 +1332,9 @@ void SceneTree::get_argument_options(const StringName &p_function, int p_idx, Li
}
SceneTree::SceneTree() {
-
- if (singleton == nullptr)
+ if (singleton == nullptr) {
singleton = this;
+ }
_quit = false;
accept_quit = true;
quit_on_go_back = true;
@@ -1410,8 +1371,9 @@ SceneTree::SceneTree() {
root = memnew(Window);
root->set_name("root");
- if (!root->get_world_3d().is_valid())
+ if (!root->get_world_3d().is_valid()) {
root->set_world_3d(Ref<World3D>(memnew(World3D)));
+ }
// Initialize network state
multiplayer_poll = true;
@@ -1436,8 +1398,9 @@ SceneTree::SceneTree() {
ResourceLoader::get_recognized_extensions_for_type("Environment", &exts);
String ext_hint;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
- if (ext_hint != String())
+ if (ext_hint != String()) {
ext_hint += ",";
+ }
ext_hint += "*." + E->get();
}
//get path
@@ -1479,6 +1442,7 @@ SceneTree::~SceneTree() {
memdelete(root);
}
- if (singleton == this)
+ if (singleton == this) {
singleton = nullptr;
+ }
}
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 319b5a7e74..57b6b4dcfa 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -70,7 +70,6 @@ public:
};
class SceneTree : public MainLoop {
-
_THREAD_SAFE_CLASS_
GDCLASS(SceneTree, MainLoop);
@@ -80,7 +79,6 @@ public:
private:
struct Group {
-
Vector<Node *> nodes;
//uint64_t last_tree_version;
bool changed;
@@ -119,7 +117,6 @@ private:
Node *edited_scene_root;
#endif
struct UGCall {
-
StringName group;
StringName call;
diff --git a/scene/main/shader_globals_override.cpp b/scene/main/shader_globals_override.cpp
index 823892a86a..726dcb58de 100644
--- a/scene/main/shader_globals_override.cpp
+++ b/scene/main/shader_globals_override.cpp
@@ -35,7 +35,6 @@
#include "scene/scene_string_names.h"
StringName *ShaderGlobalsOverride::_remap(const StringName &p_name) const {
-
StringName *r = param_remaps.getptr(p_name);
if (!r) {
//not cached, do caching
@@ -49,8 +48,8 @@ StringName *ShaderGlobalsOverride::_remap(const StringName &p_name) const {
return r;
}
-bool ShaderGlobalsOverride::_set(const StringName &p_name, const Variant &p_value) {
+bool ShaderGlobalsOverride::_set(const StringName &p_name, const Variant &p_value) {
StringName *r = _remap(p_name);
if (r) {
@@ -75,7 +74,6 @@ bool ShaderGlobalsOverride::_set(const StringName &p_name, const Variant &p_valu
}
bool ShaderGlobalsOverride::_get(const StringName &p_name, Variant &r_ret) const {
-
StringName *r = _remap(p_name);
if (r) {
@@ -90,7 +88,6 @@ bool ShaderGlobalsOverride::_get(const StringName &p_name, Variant &r_ret) const
}
void ShaderGlobalsOverride::_get_property_list(List<PropertyInfo> *p_list) const {
-
Vector<StringName> variables;
variables = RS::get_singleton()->global_variable_get_list();
for (int i = 0; i < variables.size(); i++) {
@@ -198,7 +195,6 @@ void ShaderGlobalsOverride::_get_property_list(List<PropertyInfo> *p_list) const
pinfo.hint_string = "Cubemap";
} break;
default: {
-
} break;
}
@@ -206,7 +202,7 @@ void ShaderGlobalsOverride::_get_property_list(List<PropertyInfo> *p_list) const
Override o;
o.in_use = false;
Callable::CallError ce;
- o.override = Variant::construct(pinfo.type, NULL, 0, ce);
+ o.override = Variant::construct(pinfo.type, nullptr, 0, ce);
overrides[variables[i]] = o;
}
@@ -221,7 +217,6 @@ void ShaderGlobalsOverride::_get_property_list(List<PropertyInfo> *p_list) const
}
void ShaderGlobalsOverride::_activate() {
-
List<Node *> nodes;
get_tree()->get_nodes_in_group(SceneStringNames::get_singleton()->shader_overrides_group_active, &nodes);
if (nodes.size() == 0) {
@@ -242,14 +237,11 @@ void ShaderGlobalsOverride::_activate() {
}
void ShaderGlobalsOverride::_notification(int p_what) {
-
if (p_what == Node3D::NOTIFICATION_ENTER_TREE) {
-
add_to_group(SceneStringNames::get_singleton()->shader_overrides_group);
_activate();
} else if (p_what == Node3D::NOTIFICATION_EXIT_TREE) {
-
if (active) {
//remove overrides
const StringName *K = nullptr;
@@ -269,7 +261,6 @@ void ShaderGlobalsOverride::_notification(int p_what) {
}
String ShaderGlobalsOverride::get_configuration_warning() const {
-
if (!active) {
return TTR("ShaderGlobalsOverride is not active because another node of the same type is in the scene.");
}
@@ -278,7 +269,6 @@ String ShaderGlobalsOverride::get_configuration_warning() const {
}
void ShaderGlobalsOverride::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_activate"), &ShaderGlobalsOverride::_activate);
}
diff --git a/scene/main/shader_globals_override.h b/scene/main/shader_globals_override.h
index d470e6a7dc..51420e00cf 100644
--- a/scene/main/shader_globals_override.h
+++ b/scene/main/shader_globals_override.h
@@ -34,7 +34,6 @@
#include "scene/3d/node_3d.h"
class ShaderGlobalsOverride : public Node {
-
GDCLASS(ShaderGlobalsOverride, Node);
struct Override {
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 7cab4028b8..fb55892b54 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -33,45 +33,47 @@
#include "core/engine.h"
void Timer::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_READY: {
-
if (autostart) {
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
+ if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
break;
+ }
#endif
start();
autostart = false;
}
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
- if (timer_process_mode == TIMER_PROCESS_PHYSICS || !is_processing_internal())
+ if (timer_process_mode == TIMER_PROCESS_PHYSICS || !is_processing_internal()) {
return;
+ }
time_left -= get_process_delta_time();
if (time_left < 0) {
- if (!one_shot)
+ if (!one_shot) {
time_left += wait_time;
- else
+ } else {
stop();
+ }
emit_signal("timeout");
}
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
- if (timer_process_mode == TIMER_PROCESS_IDLE || !is_physics_processing_internal())
+ if (timer_process_mode == TIMER_PROCESS_IDLE || !is_physics_processing_internal()) {
return;
+ }
time_left -= get_physics_process_delta_time();
if (time_left < 0) {
- if (!one_shot)
+ if (!one_shot) {
time_left += wait_time;
- else
+ } else {
stop();
+ }
emit_signal("timeout");
}
@@ -83,31 +85,28 @@ void Timer::set_wait_time(float p_time) {
ERR_FAIL_COND_MSG(p_time <= 0, "Time should be greater than zero.");
wait_time = p_time;
}
-float Timer::get_wait_time() const {
+float Timer::get_wait_time() const {
return wait_time;
}
void Timer::set_one_shot(bool p_one_shot) {
-
one_shot = p_one_shot;
}
-bool Timer::is_one_shot() const {
+bool Timer::is_one_shot() const {
return one_shot;
}
void Timer::set_autostart(bool p_start) {
-
autostart = p_start;
}
-bool Timer::has_autostart() const {
+bool Timer::has_autostart() const {
return autostart;
}
void Timer::start(float p_time) {
-
ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree. Either add it or set autostart to true.");
if (p_time > 0) {
@@ -124,8 +123,9 @@ void Timer::stop() {
}
void Timer::set_paused(bool p_paused) {
- if (paused == p_paused)
+ if (paused == p_paused) {
return;
+ }
paused = p_paused;
_set_process(processing);
@@ -140,14 +140,13 @@ bool Timer::is_stopped() const {
}
float Timer::get_time_left() const {
-
return time_left > 0 ? time_left : 0;
}
void Timer::set_timer_process_mode(TimerProcessMode p_mode) {
-
- if (timer_process_mode == p_mode)
+ if (timer_process_mode == p_mode) {
return;
+ }
switch (timer_process_mode) {
case TIMER_PROCESS_PHYSICS:
@@ -167,7 +166,6 @@ void Timer::set_timer_process_mode(TimerProcessMode p_mode) {
}
Timer::TimerProcessMode Timer::get_timer_process_mode() const {
-
return timer_process_mode;
}
@@ -184,7 +182,6 @@ void Timer::_set_process(bool p_process, bool p_force) {
}
void Timer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_wait_time", "time_sec"), &Timer::set_wait_time);
ClassDB::bind_method(D_METHOD("get_wait_time"), &Timer::get_wait_time);
diff --git a/scene/main/timer.h b/scene/main/timer.h
index 044566738e..61abf04f59 100644
--- a/scene/main/timer.h
+++ b/scene/main/timer.h
@@ -34,7 +34,6 @@
#include "scene/main/node.h"
class Timer : public Node {
-
GDCLASS(Timer, Node);
float wait_time;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index e9827d521b..8544d67ecc 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -56,7 +56,6 @@
#include "servers/physics_server_2d.h"
void ViewportTexture::setup_local_to_scene() {
-
if (vp) {
vp->viewport_textures.erase(this);
}
@@ -87,9 +86,9 @@ void ViewportTexture::setup_local_to_scene() {
}
void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
-
- if (path == p_path)
+ if (path == p_path) {
return;
+ }
path = p_path;
@@ -99,27 +98,25 @@ void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
}
NodePath ViewportTexture::get_viewport_path_in_scene() const {
-
return path;
}
int ViewportTexture::get_width() const {
-
ERR_FAIL_COND_V_MSG(!vp, 0, "Viewport Texture must be set to use it.");
return vp->size.width;
}
-int ViewportTexture::get_height() const {
+int ViewportTexture::get_height() const {
ERR_FAIL_COND_V_MSG(!vp, 0, "Viewport Texture must be set to use it.");
return vp->size.height;
}
-Size2 ViewportTexture::get_size() const {
+Size2 ViewportTexture::get_size() const {
ERR_FAIL_COND_V_MSG(!vp, Size2(), "Viewport Texture must be set to use it.");
return vp->size;
}
-RID ViewportTexture::get_rid() const {
+RID ViewportTexture::get_rid() const {
//ERR_FAIL_COND_V_MSG(!vp, RID(), "Viewport Texture must be set to use it.");
if (proxy.is_null()) {
proxy_ph = RS::get_singleton()->texture_2d_placeholder_create();
@@ -129,17 +126,15 @@ RID ViewportTexture::get_rid() const {
}
bool ViewportTexture::has_alpha() const {
-
return false;
}
-Ref<Image> ViewportTexture::get_data() const {
+Ref<Image> ViewportTexture::get_data() const {
ERR_FAIL_COND_V_MSG(!vp, Ref<Image>(), "Viewport Texture must be set to use it.");
return RS::get_singleton()->texture_2d_get(vp->texture_rid);
}
void ViewportTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_viewport_path_in_scene", "path"), &ViewportTexture::set_viewport_path_in_scene);
ClassDB::bind_method(D_METHOD("get_viewport_path_in_scene"), &ViewportTexture::get_viewport_path_in_scene);
@@ -147,13 +142,11 @@ void ViewportTexture::_bind_methods() {
}
ViewportTexture::ViewportTexture() {
-
vp = nullptr;
set_local_to_scene(true);
}
ViewportTexture::~ViewportTexture() {
-
if (vp) {
vp->viewport_textures.erase(this);
}
@@ -169,23 +162,20 @@ ViewportTexture::~ViewportTexture() {
/////////////////////////////////////
class TooltipPanel : public PopupPanel {
-
GDCLASS(TooltipPanel, PopupPanel);
public:
- TooltipPanel(){};
+ TooltipPanel() {}
};
class TooltipLabel : public Label {
-
GDCLASS(TooltipLabel, Label);
public:
- TooltipLabel(){};
+ TooltipLabel() {}
};
Viewport::GUI::GUI() {
-
embed_subwindows_hint = false;
embedding_subwindows = false;
@@ -206,9 +196,9 @@ Viewport::GUI::GUI() {
/////////////////////////////////////
void Viewport::update_worlds() {
-
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
Rect2 abstracted_rect = Rect2(Vector2(), get_visible_rect().size);
Rect2 xformed_rect = (global_canvas_transform * canvas_transform).affine_inverse().xform(abstracted_rect);
@@ -219,7 +209,6 @@ void Viewport::update_worlds() {
}
void Viewport::_collision_object_input_event(CollisionObject3D *p_object, Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
-
Transform object_transform = p_object->get_global_transform();
Transform camera_transform = p_camera->get_global_transform();
ObjectID id = p_object->get_instance_id();
@@ -238,14 +227,12 @@ void Viewport::_collision_object_input_event(CollisionObject3D *p_object, Camera
}
void Viewport::_sub_window_update_order() {
-
for (int i = 0; i < gui.sub_windows.size(); i++) {
RS::get_singleton()->canvas_item_set_draw_index(gui.sub_windows[i].canvas_item, i);
}
}
void Viewport::_sub_window_register(Window *p_window) {
-
ERR_FAIL_COND(!is_inside_tree());
for (int i = 0; i < gui.sub_windows.size(); i++) {
ERR_FAIL_COND(gui.sub_windows[i].window == p_window);
@@ -268,7 +255,6 @@ void Viewport::_sub_window_register(Window *p_window) {
}
void Viewport::_sub_window_update(Window *p_window) {
-
int index = -1;
for (int i = 0; i < gui.sub_windows.size(); i++) {
if (gui.sub_windows[i].window == p_window) {
@@ -313,7 +299,6 @@ void Viewport::_sub_window_update(Window *p_window) {
}
void Viewport::_sub_window_grab_focus(Window *p_window) {
-
if (p_window == nullptr) {
//release current focus
if (gui.subwindow_focused) {
@@ -385,7 +370,6 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
}
void Viewport::_sub_window_remove(Window *p_window) {
-
for (int i = 0; i < gui.sub_windows.size(); i++) {
if (gui.sub_windows[i].window == p_window) {
RS::get_singleton()->free(gui.sub_windows[i].canvas_item);
@@ -407,7 +391,6 @@ void Viewport::_sub_window_remove(Window *p_window) {
gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_OUT);
if (parent_visible && parent_visible != this) {
-
gui.subwindow_focused = parent_visible;
gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_IN);
} else {
@@ -444,11 +427,8 @@ void Viewport::_own_world_3d_changed() {
}
void Viewport::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_ENTER_TREE: {
-
gui.embedding_subwindows = gui.embed_subwindows_hint;
if (get_parent()) {
@@ -491,28 +471,28 @@ void Viewport::_notification(int p_what) {
if (listeners.size() && !listener) {
Listener3D *first = nullptr;
for (Set<Listener3D *>::Element *E = listeners.front(); E; E = E->next()) {
-
if (first == nullptr || first->is_greater_than(E->get())) {
first = E->get();
}
}
- if (first)
+ if (first) {
first->make_current();
+ }
}
if (cameras.size() && !camera) {
//there are cameras but no current camera, pick first in tree and make it current
Camera3D *first = nullptr;
for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
-
if (first == nullptr || first->is_greater_than(E->get())) {
first = E->get();
}
}
- if (first)
+ if (first) {
first->make_current();
+ }
}
#endif
@@ -522,10 +502,10 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
_gui_cancel_tooltip();
- if (world_2d.is_valid())
+ if (world_2d.is_valid()) {
world_2d->_remove_viewport(this);
+ }
RenderingServer::get_singleton()->viewport_set_scenario(viewport, RID());
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
@@ -548,7 +528,6 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
-
if (gui.tooltip_timer >= 0) {
gui.tooltip_timer -= get_process_delta_time();
if (gui.tooltip_timer < 0) {
@@ -558,9 +537,7 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
-
if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) {
-
RenderingServer::get_singleton()->canvas_item_clear(contact_2d_debug);
RenderingServer::get_singleton()->canvas_item_set_draw_index(contact_2d_debug, 0xFFFFF); //very high index
@@ -569,13 +546,11 @@ void Viewport::_notification(int p_what) {
Color ccol = get_tree()->get_debug_collision_contact_color();
for (int i = 0; i < point_count; i++) {
-
RenderingServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol);
}
}
if (get_tree()->is_debugging_collisions_hint() && contact_3d_debug_multimesh.is_valid()) {
-
Vector<Vector3> points = PhysicsServer3D::get_singleton()->space_get_contacts(find_world_3d()->get_space());
int point_count = PhysicsServer3D::get_singleton()->space_get_contact_count(find_world_3d()->get_space());
@@ -583,7 +558,6 @@ void Viewport::_notification(int p_what) {
}
if (physics_object_picking && (to_screen_rect == Rect2i() || Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED)) {
-
#ifndef _3D_DISABLED
Vector2 last_pos(1e20, 1e20);
CollisionObject3D *last_object = nullptr;
@@ -621,7 +595,6 @@ void Viewport::_notification(int p_what) {
}
while (physics_picking_events.size()) {
-
Ref<InputEvent> ev = physics_picking_events.front()->get();
physics_picking_events.pop_front();
@@ -631,7 +604,6 @@ void Viewport::_notification(int p_what) {
Ref<InputEventMouseMotion> mm = ev;
if (mm.is_valid()) {
-
pos = mm->get_position();
is_mouse = true;
@@ -647,7 +619,6 @@ void Viewport::_notification(int p_what) {
Ref<InputEventMouseButton> mb = ev;
if (mb.is_valid()) {
-
pos = mb->get_position();
is_mouse = true;
@@ -715,7 +686,6 @@ void Viewport::_notification(int p_what) {
int rc = ss2d->intersect_point_on_canvas(point, canvas_layer_id, res, 64, Set<RID>(), 0xFFFFFFFF, true, true, true);
for (int i = 0; i < rc; i++) {
-
if (res[i].collider_id.is_valid() && res[i].collider) {
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(res[i].collider);
if (co) {
@@ -750,7 +720,6 @@ void Viewport::_notification(int p_what) {
if (E->get() != frame) {
Object *o = ObjectDB::get_instance(E->key());
if (o) {
-
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o);
if (co) {
co->_mouse_exit();
@@ -771,7 +740,6 @@ void Viewport::_notification(int p_what) {
bool captured = false;
if (physics_object_capture.is_valid()) {
-
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_capture));
if (co && camera) {
_collision_object_input_event(co, camera, ev, Vector3(), Vector3(), 0);
@@ -788,7 +756,6 @@ void Viewport::_notification(int p_what) {
if (captured) {
//none
} else if (pos == last_pos) {
-
if (last_id.is_valid()) {
if (ObjectDB::get_instance(last_id) && last_object) {
//good, exists
@@ -799,22 +766,17 @@ void Viewport::_notification(int p_what) {
}
}
} else {
-
if (camera) {
-
Vector3 from = camera->project_ray_origin(pos);
Vector3 dir = camera->project_ray_normal(pos);
PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space());
if (space) {
-
bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true);
ObjectID new_collider;
if (col) {
-
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(result.collider);
if (co) {
-
_collision_object_input_event(co, camera, ev, result.position, result.normal, result.shape);
last_object = co;
last_id = result.collider_id;
@@ -826,9 +788,7 @@ void Viewport::_notification(int p_what) {
}
if (is_mouse && new_collider != physics_object_over) {
-
if (physics_object_over.is_valid()) {
-
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over));
if (co) {
co->_mouse_exit();
@@ -836,7 +796,6 @@ void Viewport::_notification(int p_what) {
}
if (new_collider.is_valid()) {
-
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(new_collider));
if (co) {
co->_mouse_enter();
@@ -857,7 +816,6 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_WM_MOUSE_EXIT:
case NOTIFICATION_WM_FOCUS_OUT: {
-
_drop_physics_mouseover();
if (gui.mouse_focus && !gui.forced_mouse_focus) {
@@ -868,21 +826,21 @@ void Viewport::_notification(int p_what) {
}
RID Viewport::get_viewport_rid() const {
-
return viewport;
}
void Viewport::update_canvas_items() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_update_canvas_items(this);
}
void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated) {
-
- if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_2d_override == size_2d_override && to_screen_rect != p_to_screen_rect)
+ if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_2d_override == size_2d_override && to_screen_rect != p_to_screen_rect) {
return;
+ }
size = p_size;
size_allocated = p_allocated;
@@ -905,15 +863,16 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override,
Size2i Viewport::_get_size() const {
return size;
}
+
Size2i Viewport::_get_size_2d_override() const {
return size_2d_override;
}
+
bool Viewport::_is_size_allocated() const {
return size_allocated;
}
Rect2 Viewport::get_visible_rect() const {
-
Rect2 r;
if (size == Size2()) {
@@ -933,7 +892,6 @@ void Viewport::_update_listener() {
}
void Viewport::_update_listener_2d() {
-
/*
if (is_inside_tree() && audio_listener && (!get_parent() || (Object::cast_to<Control>(get_parent()) && Object::cast_to<Control>(get_parent())->is_visible_in_tree())))
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, find_world_2d()->get_sound_space());
@@ -943,23 +901,22 @@ void Viewport::_update_listener_2d() {
}
void Viewport::set_as_audio_listener(bool p_enable) {
-
- if (p_enable == audio_listener)
+ if (p_enable == audio_listener) {
return;
+ }
audio_listener = p_enable;
_update_listener();
}
bool Viewport::is_audio_listener() const {
-
return audio_listener;
}
void Viewport::set_as_audio_listener_2d(bool p_enable) {
-
- if (p_enable == audio_listener_2d)
+ if (p_enable == audio_listener_2d) {
return;
+ }
audio_listener_2d = p_enable;
@@ -967,7 +924,6 @@ void Viewport::set_as_audio_listener_2d(bool p_enable) {
}
bool Viewport::is_audio_listener_2d() const {
-
return audio_listener_2d;
}
@@ -1004,7 +960,6 @@ Transform2D Viewport::get_canvas_transform_override() const {
}
void Viewport::set_canvas_transform(const Transform2D &p_transform) {
-
canvas_transform = p_transform;
if (!override_canvas_transform) {
@@ -1013,26 +968,22 @@ void Viewport::set_canvas_transform(const Transform2D &p_transform) {
}
Transform2D Viewport::get_canvas_transform() const {
-
return canvas_transform;
}
void Viewport::_update_global_transform() {
-
Transform2D sxform = stretch_transform * global_canvas_transform;
RenderingServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform);
}
void Viewport::set_global_canvas_transform(const Transform2D &p_transform) {
-
global_canvas_transform = p_transform;
_update_global_transform();
}
Transform2D Viewport::get_global_canvas_transform() const {
-
return global_canvas_transform;
}
@@ -1040,11 +991,11 @@ void Viewport::_listener_transform_changed_notify() {
}
void Viewport::_listener_set(Listener3D *p_listener) {
-
#ifndef _3D_DISABLED
- if (listener == p_listener)
+ if (listener == p_listener) {
return;
+ }
listener = p_listener;
@@ -1054,13 +1005,11 @@ void Viewport::_listener_set(Listener3D *p_listener) {
}
bool Viewport::_listener_add(Listener3D *p_listener) {
-
listeners.insert(p_listener);
return listeners.size() == 1;
}
void Viewport::_listener_remove(Listener3D *p_listener) {
-
listeners.erase(p_listener);
if (listener == p_listener) {
listener = nullptr;
@@ -1069,16 +1018,17 @@ void Viewport::_listener_remove(Listener3D *p_listener) {
#ifndef _3D_DISABLED
void Viewport::_listener_make_next_current(Listener3D *p_exclude) {
-
if (listeners.size() > 0) {
for (Set<Listener3D *>::Element *E = listeners.front(); E; E = E->next()) {
-
- if (p_exclude == E->get())
+ if (p_exclude == E->get()) {
continue;
- if (!E->get()->is_inside_tree())
+ }
+ if (!E->get()->is_inside_tree()) {
continue;
- if (listener != nullptr)
+ }
+ if (listener != nullptr) {
return;
+ }
E->get()->make_current();
}
@@ -1093,17 +1043,16 @@ void Viewport::_listener_make_next_current(Listener3D *p_exclude) {
#endif
void Viewport::_camera_transform_changed_notify() {
-
#ifndef _3D_DISABLED
#endif
}
void Viewport::_camera_set(Camera3D *p_camera) {
-
#ifndef _3D_DISABLED
- if (camera == p_camera)
+ if (camera == p_camera) {
return;
+ }
if (camera) {
camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT);
@@ -1112,10 +1061,11 @@ void Viewport::_camera_set(Camera3D *p_camera) {
camera = p_camera;
if (!camera_override) {
- if (camera)
+ if (camera) {
RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera());
- else
+ } else {
RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID());
+ }
}
if (camera) {
@@ -1128,13 +1078,11 @@ void Viewport::_camera_set(Camera3D *p_camera) {
}
bool Viewport::_camera_add(Camera3D *p_camera) {
-
cameras.insert(p_camera);
return cameras.size() == 1;
}
void Viewport::_camera_remove(Camera3D *p_camera) {
-
cameras.erase(p_camera);
if (camera == p_camera) {
camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT);
@@ -1144,15 +1092,16 @@ void Viewport::_camera_remove(Camera3D *p_camera) {
#ifndef _3D_DISABLED
void Viewport::_camera_make_next_current(Camera3D *p_exclude) {
-
for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
-
- if (p_exclude == E->get())
+ if (p_exclude == E->get()) {
continue;
- if (!E->get()->is_inside_tree())
+ }
+ if (!E->get()->is_inside_tree()) {
continue;
- if (camera != nullptr)
+ }
+ if (camera != nullptr) {
return;
+ }
E->get()->make_current();
}
@@ -1160,29 +1109,26 @@ void Viewport::_camera_make_next_current(Camera3D *p_exclude) {
#endif
void Viewport::_canvas_layer_add(CanvasLayer *p_canvas_layer) {
-
canvas_layers.insert(p_canvas_layer);
}
void Viewport::_canvas_layer_remove(CanvasLayer *p_canvas_layer) {
-
canvas_layers.erase(p_canvas_layer);
}
void Viewport::set_transparent_background(bool p_enable) {
-
transparent_bg = p_enable;
RS::get_singleton()->viewport_set_transparent_background(viewport, p_enable);
}
bool Viewport::has_transparent_background() const {
-
return transparent_bg;
}
void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
- if (world_2d == p_world_2d)
+ if (world_2d == p_world_2d) {
return;
+ }
if (parent && parent->find_world_2d() == p_world_2d) {
WARN_PRINT("Unable to use parent world_3d as world_2d");
@@ -1194,9 +1140,9 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
}
- if (p_world_2d.is_valid())
+ if (p_world_2d.is_valid()) {
world_2d = p_world_2d;
- else {
+ } else {
WARN_PRINT("Invalid world_3d");
world_2d = Ref<World2D>(memnew(World2D));
}
@@ -1211,21 +1157,20 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
}
Ref<World2D> Viewport::find_world_2d() const {
-
- if (world_2d.is_valid())
+ if (world_2d.is_valid()) {
return world_2d;
- else if (parent)
+ } else if (parent) {
return parent->find_world_2d();
- else
+ } else {
return Ref<World2D>();
+ }
}
void Viewport::_propagate_enter_world(Node *p_node) {
-
if (p_node != this) {
-
- if (!p_node->is_inside_tree()) //may not have entered scene yet
+ if (!p_node->is_inside_tree()) { //may not have entered scene yet
return;
+ }
#ifndef _3D_DISABLED
if (Object::cast_to<Node3D>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
@@ -1234,9 +1179,9 @@ void Viewport::_propagate_enter_world(Node *p_node) {
#endif
Viewport *v = Object::cast_to<Viewport>(p_node);
if (v) {
-
- if (v->world_3d.is_valid() || v->own_world_3d.is_valid())
+ if (v->world_3d.is_valid() || v->own_world_3d.is_valid()) {
return;
+ }
}
#ifndef _3D_DISABLED
}
@@ -1244,28 +1189,26 @@ void Viewport::_propagate_enter_world(Node *p_node) {
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
_propagate_enter_world(p_node->get_child(i));
}
}
void Viewport::_propagate_viewport_notification(Node *p_node, int p_what) {
-
p_node->notification(p_what);
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (Object::cast_to<Viewport>(c))
+ if (Object::cast_to<Viewport>(c)) {
continue;
+ }
_propagate_viewport_notification(c, p_what);
}
}
void Viewport::_propagate_exit_world(Node *p_node) {
-
if (p_node != this) {
-
- if (!p_node->is_inside_tree()) //may have exited scene already
+ if (!p_node->is_inside_tree()) { //may have exited scene already
return;
+ }
#ifndef _3D_DISABLED
if (Object::cast_to<Node3D>(p_node) || Object::cast_to<WorldEnvironment>(p_node)) {
@@ -1274,9 +1217,9 @@ void Viewport::_propagate_exit_world(Node *p_node) {
#endif
Viewport *v = Object::cast_to<Viewport>(p_node);
if (v) {
-
- if (v->world_3d.is_valid() || v->own_world_3d.is_valid())
+ if (v->world_3d.is_valid() || v->own_world_3d.is_valid()) {
return;
+ }
}
#ifndef _3D_DISABLED
}
@@ -1284,18 +1227,18 @@ void Viewport::_propagate_exit_world(Node *p_node) {
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
_propagate_exit_world(p_node->get_child(i));
}
}
void Viewport::set_world_3d(const Ref<World3D> &p_world_3d) {
-
- if (world_3d == p_world_3d)
+ if (world_3d == p_world_3d) {
return;
+ }
- if (is_inside_tree())
+ if (is_inside_tree()) {
_propagate_exit_world(this);
+ }
if (own_world_3d.is_valid() && world_3d.is_valid()) {
world_3d->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed));
@@ -1312,8 +1255,9 @@ void Viewport::set_world_3d(const Ref<World3D> &p_world_3d) {
}
}
- if (is_inside_tree())
+ if (is_inside_tree()) {
_propagate_enter_world(this);
+ }
if (is_inside_tree()) {
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
@@ -1323,29 +1267,26 @@ void Viewport::set_world_3d(const Ref<World3D> &p_world_3d) {
}
Ref<World3D> Viewport::get_world_3d() const {
-
return world_3d;
}
Ref<World2D> Viewport::get_world_2d() const {
-
return world_2d;
}
Ref<World3D> Viewport::find_world_3d() const {
-
- if (own_world_3d.is_valid())
+ if (own_world_3d.is_valid()) {
return own_world_3d;
- else if (world_3d.is_valid())
+ } else if (world_3d.is_valid()) {
return world_3d;
- else if (parent)
+ } else if (parent) {
return parent->find_world_3d();
- else
+ } else {
return Ref<World3D>();
+ }
}
Listener3D *Viewport::get_listener() const {
-
return listener;
}
@@ -1354,7 +1295,6 @@ Camera3D *Viewport::get_camera() const {
}
void Viewport::enable_camera_override(bool p_enable) {
-
#ifndef _3D_DISABLED
if (p_enable == camera_override) {
return;
@@ -1399,8 +1339,9 @@ Transform Viewport::get_camera_override_transform() const {
void Viewport::set_camera_override_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) {
if (camera_override) {
if (camera_override.fov == p_fovy_degrees && camera_override.z_near == p_z_near &&
- camera_override.z_far == p_z_far && camera_override.projection == CameraOverrideData::PROJECTION_PERSPECTIVE)
+ camera_override.z_far == p_z_far && camera_override.projection == CameraOverrideData::PROJECTION_PERSPECTIVE) {
return;
+ }
camera_override.fov = p_fovy_degrees;
camera_override.z_near = p_z_near;
@@ -1414,8 +1355,9 @@ void Viewport::set_camera_override_perspective(float p_fovy_degrees, float p_z_n
void Viewport::set_camera_override_orthogonal(float p_size, float p_z_near, float p_z_far) {
if (camera_override) {
if (camera_override.size == p_size && camera_override.z_near == p_z_near &&
- camera_override.z_far == p_z_far && camera_override.projection == CameraOverrideData::PROJECTION_ORTHOGONAL)
+ camera_override.z_far == p_z_far && camera_override.projection == CameraOverrideData::PROJECTION_ORTHOGONAL) {
return;
+ }
camera_override.size = p_size;
camera_override.z_near = p_z_near;
@@ -1427,16 +1369,15 @@ void Viewport::set_camera_override_orthogonal(float p_size, float p_z_near, floa
}
Transform2D Viewport::get_final_transform() const {
-
return stretch_transform * global_canvas_transform;
}
void Viewport::_update_canvas_items(Node *p_node) {
if (p_node != this) {
-
Viewport *vp = Object::cast_to<Viewport>(p_node);
- if (vp)
+ if (vp) {
return;
+ }
CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
if (ci) {
@@ -1452,49 +1393,45 @@ void Viewport::_update_canvas_items(Node *p_node) {
}
Ref<ViewportTexture> Viewport::get_texture() const {
-
return default_texture;
}
void Viewport::set_shadow_atlas_size(int p_size) {
-
- if (shadow_atlas_size == p_size)
+ if (shadow_atlas_size == p_size) {
return;
+ }
shadow_atlas_size = p_size;
RS::get_singleton()->viewport_set_shadow_atlas_size(viewport, p_size);
}
int Viewport::get_shadow_atlas_size() const {
-
return shadow_atlas_size;
}
void Viewport::set_shadow_atlas_quadrant_subdiv(int p_quadrant, ShadowAtlasQuadrantSubdiv p_subdiv) {
-
ERR_FAIL_INDEX(p_quadrant, 4);
ERR_FAIL_INDEX(p_subdiv, SHADOW_ATLAS_QUADRANT_SUBDIV_MAX);
- if (shadow_atlas_quadrant_subdiv[p_quadrant] == p_subdiv)
+ if (shadow_atlas_quadrant_subdiv[p_quadrant] == p_subdiv) {
return;
+ }
shadow_atlas_quadrant_subdiv[p_quadrant] = p_subdiv;
static const int subdiv[SHADOW_ATLAS_QUADRANT_SUBDIV_MAX] = { 0, 1, 4, 16, 64, 256, 1024 };
RS::get_singleton()->viewport_set_shadow_atlas_quadrant_subdivision(viewport, p_quadrant, subdiv[p_subdiv]);
}
-Viewport::ShadowAtlasQuadrantSubdiv Viewport::get_shadow_atlas_quadrant_subdiv(int p_quadrant) const {
+Viewport::ShadowAtlasQuadrantSubdiv Viewport::get_shadow_atlas_quadrant_subdiv(int p_quadrant) const {
ERR_FAIL_INDEX_V(p_quadrant, 4, SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED);
return shadow_atlas_quadrant_subdiv[p_quadrant];
}
Transform2D Viewport::_get_input_pre_xform() const {
-
Transform2D pre_xf;
if (to_screen_rect.size.x != 0 && to_screen_rect.size.y != 0) {
-
pre_xf.elements[2] = -to_screen_rect.position;
pre_xf.scale(size / to_screen_rect.size);
}
@@ -1503,27 +1440,24 @@ Transform2D Viewport::_get_input_pre_xform() const {
}
Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
-
Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
return ev->xformed_by(ai);
}
Vector2 Viewport::get_mouse_position() const {
-
return gui.last_mouse_pos;
}
void Viewport::warp_mouse(const Vector2 &p_pos) {
-
Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos);
Input::get_singleton()->warp_mouse_position(gpos);
}
void Viewport::_gui_sort_roots() {
-
- if (!gui.roots_order_dirty)
+ if (!gui.roots_order_dirty) {
return;
+ }
gui.roots.sort_custom<Control::CComparator>();
@@ -1531,7 +1465,6 @@ void Viewport::_gui_sort_roots() {
}
void Viewport::_gui_cancel_tooltip() {
-
gui.tooltip = nullptr;
gui.tooltip_timer = -1;
if (gui.tooltip_popup) {
@@ -1542,26 +1475,27 @@ void Viewport::_gui_cancel_tooltip() {
}
String Viewport::_gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_which) {
-
Vector2 pos = p_pos;
String tooltip;
while (p_control) {
-
tooltip = p_control->get_tooltip(pos);
if (r_which) {
*r_which = p_control;
}
- if (tooltip != String())
+ if (tooltip != String()) {
break;
+ }
pos = p_control->get_transform().xform(pos);
- if (p_control->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ if (p_control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
break;
- if (p_control->is_set_as_toplevel())
+ }
+ if (p_control->is_set_as_toplevel()) {
break;
+ }
p_control = p_control->get_parent_control();
}
@@ -1570,7 +1504,6 @@ String Viewport::_gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Cont
}
void Viewport::_gui_show_tooltip() {
-
if (!gui.tooltip) {
return;
}
@@ -1578,8 +1511,9 @@ void Viewport::_gui_show_tooltip() {
Control *which = nullptr;
String tooltip = _gui_get_tooltip(gui.tooltip, gui.tooltip->get_global_transform().xform_inv(gui.tooltip_pos), &which);
tooltip = tooltip.strip_edges();
- if (tooltip.length() == 0)
+ if (tooltip.length() == 0) {
return; // bye
+ }
if (gui.tooltip_popup) {
memdelete(gui.tooltip_popup);
@@ -1621,15 +1555,17 @@ void Viewport::_gui_show_tooltip() {
Rect2i vr = gui.tooltip_popup->get_parent_visible_window()->get_usable_parent_rect();
- if (r.size.x + r.position.x > vr.size.x + vr.position.x)
+ if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
r.position.x = vr.position.x + vr.size.x - r.size.x;
- else if (r.position.x < vr.position.x)
+ } else if (r.position.x < vr.position.x) {
r.position.x = vr.position.x;
+ }
- if (r.size.y + r.position.y > vr.size.y + vr.position.y)
+ if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
r.position.y = vr.position.y + vr.size.y - r.size.y;
- else if (r.position.y < vr.position.y)
+ } else if (r.position.y < vr.position.y) {
r.position.y = vr.position.y;
+ }
gui.tooltip_popup->set_position(r.position);
gui.tooltip_popup->set_size(r.size);
@@ -1639,7 +1575,6 @@ void Viewport::_gui_show_tooltip() {
}
void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_input) {
-
//_block();
Ref<InputEvent> ev = p_input;
@@ -1659,32 +1594,36 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
CanvasItem *ci = p_control;
while (ci) {
-
Control *control = Object::cast_to<Control>(ci);
if (control) {
-
if (control->data.mouse_filter != Control::MOUSE_FILTER_IGNORE) {
control->emit_signal(SceneStringNames::get_singleton()->gui_input, ev); //signal should be first, so it's possible to override an event (and then accept it)
}
- if (gui.key_event_accepted)
+ if (gui.key_event_accepted) {
break;
- if (!control->is_inside_tree())
+ }
+ if (!control->is_inside_tree()) {
break;
+ }
if (control->data.mouse_filter != Control::MOUSE_FILTER_IGNORE) {
control->call_multilevel(SceneStringNames::get_singleton()->_gui_input, ev);
}
- if (!control->is_inside_tree() || control->is_set_as_toplevel())
+ if (!control->is_inside_tree() || control->is_set_as_toplevel()) {
break;
- if (gui.key_event_accepted)
+ }
+ if (gui.key_event_accepted) {
break;
- if (!cant_stop_me_now && control->data.mouse_filter == Control::MOUSE_FILTER_STOP && ismouse)
+ }
+ if (!cant_stop_me_now && control->data.mouse_filter == Control::MOUSE_FILTER_STOP && ismouse) {
break;
+ }
}
- if (ci->is_set_as_toplevel())
+ if (ci->is_set_as_toplevel()) {
break;
+ }
ev = ev->xformed_by(ci->get_transform()); //transform event upwards
ci = ci->get_parent_item();
@@ -1694,64 +1633,67 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
}
void Viewport::_gui_call_notification(Control *p_control, int p_what) {
-
CanvasItem *ci = p_control;
while (ci) {
-
Control *control = Object::cast_to<Control>(ci);
if (control) {
-
if (control->data.mouse_filter != Control::MOUSE_FILTER_IGNORE) {
control->notification(p_what);
}
- if (!control->is_inside_tree())
+ if (!control->is_inside_tree()) {
break;
+ }
- if (!control->is_inside_tree() || control->is_set_as_toplevel())
+ if (!control->is_inside_tree() || control->is_set_as_toplevel()) {
break;
- if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ }
+ if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
break;
+ }
}
- if (ci->is_set_as_toplevel())
+ if (ci->is_set_as_toplevel()) {
break;
+ }
ci = ci->get_parent_item();
}
//_unblock();
}
-Control *Viewport::_gui_find_control(const Point2 &p_global) {
+Control *Viewport::_gui_find_control(const Point2 &p_global) {
//aca va subwindows
_gui_sort_roots();
for (List<Control *>::Element *E = gui.roots.back(); E; E = E->prev()) {
-
Control *sw = E->get();
- if (!sw->is_visible_in_tree())
+ if (!sw->is_visible_in_tree()) {
continue;
+ }
Transform2D xform;
CanvasItem *pci = sw->get_parent_item();
- if (pci)
+ if (pci) {
xform = pci->get_global_transform_with_canvas();
- else
+ } else {
xform = sw->get_canvas_transform();
+ }
Control *ret = _gui_find_control_at_pos(sw, p_global, xform, gui.focus_inv_xform);
- if (ret)
+ if (ret) {
return ret;
+ }
}
return nullptr;
}
Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform) {
-
- if (Object::cast_to<Viewport>(p_node))
+ if (Object::cast_to<Viewport>(p_node)) {
return nullptr;
+ }
if (!p_node->is_visible()) {
//return _find_next_visible_control_at_pos(p_node,p_global,r_inv_xform);
@@ -1760,27 +1702,29 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
Transform2D matrix = p_xform * p_node->get_transform();
// matrix.basis_determinant() == 0.0f implies that node does not exist on scene
- if (matrix.basis_determinant() == 0.0f)
+ if (matrix.basis_determinant() == 0.0f) {
return nullptr;
+ }
Control *c = Object::cast_to<Control>(p_node);
if (!c || !c->clips_input() || c->has_point(matrix.affine_inverse().xform(p_global))) {
-
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
-
CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i));
- if (!ci || ci->is_set_as_toplevel())
+ if (!ci || ci->is_set_as_toplevel()) {
continue;
+ }
Control *ret = _gui_find_control_at_pos(ci, p_global, matrix, r_inv_xform);
- if (ret)
+ if (ret) {
return ret;
+ }
}
}
- if (!c)
+ if (!c) {
return nullptr;
+ }
matrix.affine_invert();
@@ -1788,19 +1732,17 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
if (c->data.mouse_filter != Control::MOUSE_FILTER_IGNORE && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c != gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) {
r_inv_xform = matrix;
return c;
- } else
+ } else {
return nullptr;
+ }
}
bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check) {
-
{ //attempt grab, try parent controls too
CanvasItem *ci = p_at_control;
while (ci) {
-
Control *control = Object::cast_to<Control>(ci);
if (control) {
-
if (control->can_drop_data(p_at_pos, gui.drag_data)) {
if (!p_just_check) {
control->drop_data(p_at_pos, gui.drag_data);
@@ -1809,14 +1751,16 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
return true;
}
- if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
break;
+ }
}
p_at_pos = ci->get_transform().xform(p_at_pos);
- if (ci->is_set_as_toplevel())
+ if (ci->is_set_as_toplevel()) {
break;
+ }
ci = ci->get_parent_item();
}
@@ -1826,7 +1770,6 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
}
void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
-
ERR_FAIL_COND(p_event.is_null());
//?
@@ -1839,19 +1782,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
-
gui.key_event_accepted = false;
Point2 mpos = mb->get_position();
if (mb->is_pressed()) {
-
Size2 pos = mpos;
if (gui.mouse_focus_mask) {
-
//do not steal mouse focus and stuff while a focus mask exists
gui.mouse_focus_mask |= 1 << (mb->get_button_index() - 1); //add the button to the mask
} else {
-
bool is_handled = false;
if (is_handled) {
@@ -1892,7 +1831,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
#ifdef DEBUG_ENABLED
if (EngineDebugger::get_singleton() && gui.mouse_focus) {
-
Array arr;
arr.push_back(gui.mouse_focus->get_path());
arr.push_back(gui.mouse_focus->get_class());
@@ -1903,7 +1841,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (mb->get_button_index() == BUTTON_LEFT) { //assign focus
CanvasItem *ci = gui.mouse_focus;
while (ci) {
-
Control *control = Object::cast_to<Control>(ci);
if (control) {
if (control->get_focus_mode() != Control::FOCUS_NONE) {
@@ -1913,12 +1850,14 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
break;
}
- if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
break;
+ }
}
- if (ci->is_set_as_toplevel())
+ if (ci->is_set_as_toplevel()) {
break;
+ }
ci = ci->get_parent_item();
}
@@ -1931,7 +1870,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
set_input_as_handled();
if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == BUTTON_LEFT) {
-
//alternate drop use (when using force_drag(), as proposed by #5342
if (gui.mouse_focus) {
_gui_drop(gui.mouse_focus, pos, false);
@@ -1952,9 +1890,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
//gui.tooltip_popup->hide();
} else {
-
if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == BUTTON_LEFT) {
-
if (gui.drag_mouse_over) {
_gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, false);
}
@@ -2009,7 +1945,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
gui.key_event_accepted = false;
Point2 mpos = mm->get_position();
@@ -2019,22 +1954,17 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
// D&D
if (!gui.drag_attempted && gui.mouse_focus && mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
gui.drag_accum += mm->get_relative();
float len = gui.drag_accum.length();
if (len > 10) {
-
{ //attempt grab, try parent controls too
CanvasItem *ci = gui.mouse_focus;
while (ci) {
-
Control *control = Object::cast_to<Control>(ci);
if (control) {
-
gui.dragging = true;
gui.drag_data = control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos) - gui.drag_accum);
if (gui.drag_data.get_type() != Variant::NIL) {
-
gui.mouse_focus = nullptr;
gui.forced_mouse_focus = false;
gui.mouse_focus_mask = 0;
@@ -2048,12 +1978,14 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.dragging = false;
}
- if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
break;
+ }
}
- if (ci->is_set_as_toplevel())
+ if (ci->is_set_as_toplevel()) {
break;
+ }
ci = ci->get_parent_item();
}
@@ -2061,7 +1993,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_attempted = true;
if (gui.drag_data.get_type() != Variant::NIL) {
-
_propagate_viewport_notification(this, NOTIFICATION_DRAG_BEGIN);
}
}
@@ -2072,12 +2003,10 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
//recompute focus_inv_xform again here
} else {
-
over = _gui_find_control(mpos);
}
if (over != gui.mouse_over) {
-
if (gui.mouse_over) {
_gui_call_notification(gui.mouse_over, Control::NOTIFICATION_MOUSE_EXIT);
}
@@ -2094,7 +2023,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)Input::get_singleton()->get_default_cursor_shape();
if (over) {
-
Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
Size2 pos = localizer.xform(mpos);
Vector2 speed = localizer.basis_xform(mm->get_speed());
@@ -2117,14 +2045,13 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (can_tooltip && gui.tooltip) {
String tooltip = _gui_get_tooltip(over, gui.tooltip->get_global_transform().xform_inv(mpos));
- if (tooltip.length() == 0)
+ if (tooltip.length() == 0) {
_gui_cancel_tooltip();
- else if (gui.tooltip_label) {
+ } else if (gui.tooltip_label) {
if (tooltip == gui.tooltip_label->get_text()) {
is_tooltip_shown = true;
}
} else {
-
Variant t = gui.tooltip_popup->call("get_tooltip_text");
if (t.get_type() == Variant::STRING) {
@@ -2135,12 +2062,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
is_tooltip_shown = true; //well, nothing to compare against, likely using custom control, so if it changes there is nothing we can do
}
}
- } else
+ } else {
_gui_cancel_tooltip();
+ }
}
if (can_tooltip && !is_tooltip_shown) {
-
gui.tooltip = over;
gui.tooltip_pos = over->get_screen_transform().xform(pos); //(parent_xform * get_transform()).affine_inverse().xform(pos);
gui.tooltip_timer = gui.tooltip_delay;
@@ -2158,12 +2085,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
while (c) {
cursor_shape = c->get_cursor_shape(cpos);
cpos = c->get_transform().xform(cpos);
- if (cursor_shape != Control::CURSOR_ARROW)
+ if (cursor_shape != Control::CURSOR_ARROW) {
break;
- if (c->data.mouse_filter == Control::MOUSE_FILTER_STOP)
+ }
+ if (c->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
break;
- if (c->is_set_as_toplevel())
+ }
+ if (c->is_set_as_toplevel()) {
break;
+ }
c = c->get_parent_control();
}
}
@@ -2263,7 +2193,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_mouse_over_pos = localizer.xform(viewport_pos);
if (mm->get_button_mask() & BUTTON_MASK_LEFT) {
-
bool can_drop = _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, true);
if (!can_drop) {
@@ -2284,15 +2213,11 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Ref<InputEventScreenTouch> touch_event = p_event;
if (touch_event.is_valid()) {
-
Size2 pos = touch_event->get_position();
if (touch_event->is_pressed()) {
-
Control *over = _gui_find_control(pos);
if (over) {
-
if (over->can_process()) {
-
touch_event = touch_event->xformed_by(Transform2D()); //make a copy
if (over == gui.mouse_focus) {
pos = gui.focus_inv_xform.xform(pos);
@@ -2306,9 +2231,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
return;
}
} else if (touch_event->get_index() == 0 && gui.last_mouse_focus) {
-
if (gui.last_mouse_focus->can_process()) {
-
touch_event = touch_event->xformed_by(Transform2D()); //make a copy
touch_event->set_position(gui.focus_inv_xform.xform(pos));
@@ -2321,7 +2244,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Ref<InputEventGesture> gesture_event = p_event;
if (gesture_event.is_valid()) {
-
gui.key_event_accepted = false;
_gui_cancel_tooltip();
@@ -2330,9 +2252,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Control *over = _gui_find_control(pos);
if (over) {
-
if (over->can_process()) {
-
gesture_event = gesture_event->xformed_by(Transform2D()); //make a copy
if (over == gui.mouse_focus) {
pos = gui.focus_inv_xform.xform(pos);
@@ -2349,15 +2269,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Ref<InputEventScreenDrag> drag_event = p_event;
if (drag_event.is_valid()) {
-
Control *over = gui.mouse_focus;
if (!over) {
over = _gui_find_control(drag_event->get_position());
}
if (over) {
-
if (over->can_process()) {
-
Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
Size2 pos = localizer.xform(drag_event->get_position());
Vector2 speed = localizer.basis_xform(drag_event->get_speed());
@@ -2378,22 +2295,20 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
if (mm.is_null() && mb.is_null() && p_event->is_action_type()) {
-
if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
gui.key_focus->release_focus();
}
if (gui.key_focus) {
-
gui.key_event_accepted = false;
if (gui.key_focus->can_process()) {
gui.key_focus->call_multilevel(SceneStringNames::get_singleton()->_gui_input, p_event);
- if (gui.key_focus) //maybe lost it
+ if (gui.key_focus) { //maybe lost it
gui.key_focus->emit_signal(SceneStringNames::get_singleton()->gui_input, p_event);
+ }
}
if (gui.key_event_accepted) {
-
set_input_as_handled();
return;
}
@@ -2414,32 +2329,26 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
Input *input = Input::get_singleton();
if (p_event->is_action_pressed("ui_focus_next") && input->is_action_just_pressed("ui_focus_next")) {
-
next = from->find_next_valid_focus();
}
if (p_event->is_action_pressed("ui_focus_prev") && input->is_action_just_pressed("ui_focus_prev")) {
-
next = from->find_prev_valid_focus();
}
if (!mods && p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) {
-
next = from->_get_focus_neighbour(MARGIN_TOP);
}
if (!mods && p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) {
-
next = from->_get_focus_neighbour(MARGIN_LEFT);
}
if (!mods && p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) {
-
next = from->_get_focus_neighbour(MARGIN_RIGHT);
}
if (!mods && p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) {
-
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
}
@@ -2452,7 +2361,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) {
-
gui.roots_order_dirty = true;
return gui.roots.push_back(p_control);
}
@@ -2462,7 +2370,6 @@ void Viewport::_gui_set_root_order_dirty() {
}
void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control) {
-
ERR_FAIL_COND_MSG(p_data.get_type() == Variant::NIL, "Drag data must be a value.");
gui.dragging = true;
@@ -2475,7 +2382,6 @@ void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control *
}
void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
-
ERR_FAIL_NULL(p_control);
ERR_FAIL_COND(!Object::cast_to<Control>((Object *)p_control));
ERR_FAIL_COND(p_control->is_inside_tree());
@@ -2493,35 +2399,35 @@ void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
}
void Viewport::_gui_remove_root_control(List<Control *>::Element *RI) {
-
gui.roots.erase(RI);
}
void Viewport::_gui_unfocus_control(Control *p_control) {
-
if (gui.key_focus == p_control) {
gui.key_focus->release_focus();
}
}
void Viewport::_gui_hid_control(Control *p_control) {
-
if (gui.mouse_focus == p_control) {
_drop_mouse_focus();
}
- if (gui.key_focus == p_control)
+ if (gui.key_focus == p_control) {
_gui_remove_focus();
- if (gui.mouse_over == p_control)
+ }
+ if (gui.mouse_over == p_control) {
gui.mouse_over = nullptr;
- if (gui.drag_mouse_over == p_control)
+ }
+ if (gui.drag_mouse_over == p_control) {
gui.drag_mouse_over = nullptr;
- if (gui.tooltip == p_control)
+ }
+ if (gui.tooltip == p_control) {
_gui_cancel_tooltip();
+ }
}
void Viewport::_gui_remove_control(Control *p_control) {
-
if (gui.mouse_focus == p_control) {
gui.mouse_focus = nullptr;
gui.forced_mouse_focus = false;
@@ -2530,18 +2436,21 @@ void Viewport::_gui_remove_control(Control *p_control) {
if (gui.last_mouse_focus == p_control) {
gui.last_mouse_focus = nullptr;
}
- if (gui.key_focus == p_control)
+ if (gui.key_focus == p_control) {
gui.key_focus = nullptr;
- if (gui.mouse_over == p_control)
+ }
+ if (gui.mouse_over == p_control) {
gui.mouse_over = nullptr;
- if (gui.drag_mouse_over == p_control)
+ }
+ if (gui.drag_mouse_over == p_control) {
gui.drag_mouse_over = nullptr;
- if (gui.tooltip == p_control)
+ }
+ if (gui.tooltip == p_control) {
gui.tooltip = nullptr;
+ }
}
void Viewport::_gui_remove_focus() {
-
if (gui.key_focus) {
Node *f = gui.key_focus;
gui.key_focus = nullptr;
@@ -2550,15 +2459,14 @@ void Viewport::_gui_remove_focus() {
}
bool Viewport::_gui_control_has_focus(const Control *p_control) {
-
return gui.key_focus == p_control;
}
void Viewport::_gui_control_grab_focus(Control *p_control) {
-
//no need for change
- if (gui.key_focus && gui.key_focus == p_control)
+ if (gui.key_focus && gui.key_focus == p_control) {
return;
+ }
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus");
gui.key_focus = p_control;
emit_signal("gui_focus_changed", p_control);
@@ -2567,14 +2475,13 @@ void Viewport::_gui_control_grab_focus(Control *p_control) {
}
void Viewport::_gui_accept_event() {
-
gui.key_event_accepted = true;
- if (is_inside_tree())
+ if (is_inside_tree()) {
set_input_as_handled();
+ }
}
void Viewport::_drop_mouse_focus() {
-
Control *c = gui.mouse_focus;
int mask = gui.mouse_focus_mask;
gui.mouse_focus = nullptr;
@@ -2582,7 +2489,6 @@ void Viewport::_drop_mouse_focus() {
gui.mouse_focus_mask = 0;
for (int i = 0; i < 3; i++) {
-
if (mask & (1 << i)) {
Ref<InputEventMouseButton> mb;
mb.instance();
@@ -2596,7 +2502,6 @@ void Viewport::_drop_mouse_focus() {
}
void Viewport::_drop_physics_mouseover() {
-
physics_has_last_mousepos = false;
while (physics_2d_mouseover.size()) {
@@ -2622,18 +2527,15 @@ void Viewport::_drop_physics_mouseover() {
}
Control *Viewport::_gui_get_focus_owner() {
-
return gui.key_focus;
}
void Viewport::_gui_grab_click_focus(Control *p_control) {
-
gui.mouse_click_grabber = p_control;
call_deferred("_post_gui_grab_click_focus");
}
void Viewport::_post_gui_grab_click_focus() {
-
Control *focus_grabber = gui.mouse_click_grabber;
if (!focus_grabber) {
// Redundant grab requests were made
@@ -2642,17 +2544,15 @@ void Viewport::_post_gui_grab_click_focus() {
gui.mouse_click_grabber = nullptr;
if (gui.mouse_focus) {
-
- if (gui.mouse_focus == focus_grabber)
+ if (gui.mouse_focus == focus_grabber) {
return;
+ }
int mask = gui.mouse_focus_mask;
Point2 click = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
for (int i = 0; i < 3; i++) {
-
if (mask & (1 << i)) {
-
Ref<InputEventMouseButton> mb;
mb.instance();
@@ -2670,9 +2570,7 @@ void Viewport::_post_gui_grab_click_focus() {
click = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
for (int i = 0; i < 3; i++) {
-
if (mask & (1 << i)) {
-
Ref<InputEventMouseButton> mb;
mb.instance();
@@ -2690,7 +2588,6 @@ void Viewport::_post_gui_grab_click_focus() {
///////////////////////////////
void Viewport::input_text(const String &p_text) {
-
if (gui.subwindow_focused) {
gui.subwindow_focused->input_text(p_text);
return;
@@ -2700,8 +2597,8 @@ void Viewport::input_text(const String &p_text) {
gui.key_focus->call("set_text", p_text);
}
}
-Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point) {
+Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point) {
if (p_subwindow->get_flag(Window::FLAG_BORDERLESS)) {
return SUB_WINDOW_RESIZE_DISABLED;
}
@@ -2764,15 +2661,13 @@ Viewport::SubWindowResize Viewport::_sub_window_get_resize_margin(Window *p_subw
return SUB_WINDOW_RESIZE_DISABLED;
}
-bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
+bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
if (gui.subwindow_drag != SUB_WINDOW_DRAG_DISABLED) {
-
ERR_FAIL_COND_V(gui.subwindow_focused == nullptr, false);
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
if (gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE) {
if (gui.subwindow_drag_close_rect.has_point(mb->get_position())) {
//close window
@@ -2787,7 +2682,6 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
if (gui.subwindow_drag == SUB_WINDOW_DRAG_MOVE) {
Vector2 diff = mm->get_position() - gui.subwindow_drag_from;
Rect2i new_rect(gui.subwindow_drag_pos + diff, gui.subwindow_focused->get_size());
@@ -2813,7 +2707,6 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
switch (gui.subwindow_resize_mode) {
case SUB_WINDOW_RESIZE_TOP_LEFT: {
-
diff.x = MIN(diff.x, limit.x);
diff.y = MIN(diff.y, limit.y);
r.position += diff;
@@ -2879,7 +2772,6 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
//if the event is a mouse button, we need to check whether another window was clicked
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
-
bool click_on_window = false;
for (int i = gui.sub_windows.size() - 1; i >= 0; i--) {
SubWindow &sw = gui.sub_windows.write[i];
@@ -2896,7 +2788,6 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
title_bar.size.y = title_height;
if (title_bar.has_point(mb->get_position())) {
-
click_on_window = true;
int close_h_ofs = sw.window->get_theme_constant("close_h_ofs");
@@ -2913,12 +2804,10 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
}
if (close_rect.has_point(mb->get_position())) {
-
gui.subwindow_drag = SUB_WINDOW_DRAG_CLOSE;
gui.subwindow_drag_close_inside = true; //starts inside
gui.subwindow_drag_close_rect = close_rect;
} else {
-
gui.subwindow_drag = SUB_WINDOW_DRAG_MOVE;
}
@@ -2958,13 +2847,10 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
}
if (gui.subwindow_focused) {
-
Ref<InputEventMouseMotion> mm = p_event;
if (mm.is_valid()) {
-
SubWindowResize resize = _sub_window_get_resize_margin(gui.subwindow_focused, mm->get_position());
if (resize != SUB_WINDOW_RESIZE_DISABLED) {
-
DisplayServer::CursorShape shapes[SUB_WINDOW_RESIZE_MAX] = {
DisplayServer::CURSOR_ARROW,
DisplayServer::CURSOR_FDIAGSIZE,
@@ -3003,11 +2889,11 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
}
void Viewport::input(const Ref<InputEvent> &p_event, bool p_local_coords) {
-
ERR_FAIL_COND(!is_inside_tree());
- if (disable_input)
+ if (disable_input) {
return;
+ }
if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
@@ -3038,11 +2924,11 @@ void Viewport::input(const Ref<InputEvent> &p_event, bool p_local_coords) {
}
void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
-
ERR_FAIL_COND(!is_inside_tree());
- if (disable_input)
+ if (disable_input) {
return;
+ }
if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
@@ -3063,7 +2949,6 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coor
}
if (physics_object_picking && !is_input_handled()) {
-
if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED &&
(Object::cast_to<InputEventMouseButton>(*ev) ||
Object::cast_to<InputEventMouseMotion>(*ev) ||
@@ -3078,12 +2963,13 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coor
}
void Viewport::set_use_own_world_3d(bool p_world_3d) {
-
- if (p_world_3d == own_world_3d.is_valid())
+ if (p_world_3d == own_world_3d.is_valid()) {
return;
+ }
- if (is_inside_tree())
+ if (is_inside_tree()) {
_propagate_exit_world(this);
+ }
if (!p_world_3d) {
own_world_3d = Ref<World3D>();
@@ -3099,8 +2985,9 @@ void Viewport::set_use_own_world_3d(bool p_world_3d) {
}
}
- if (is_inside_tree())
+ if (is_inside_tree()) {
_propagate_enter_world(this);
+ }
if (is_inside_tree()) {
RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world_3d()->get_scenario());
@@ -3110,12 +2997,10 @@ void Viewport::set_use_own_world_3d(bool p_world_3d) {
}
bool Viewport::is_using_own_world_3d() const {
-
return own_world_3d.is_valid();
}
void Viewport::set_physics_object_picking(bool p_enable) {
-
physics_object_picking = p_enable;
if (!physics_object_picking) {
physics_picking_events.clear();
@@ -3123,18 +3008,15 @@ void Viewport::set_physics_object_picking(bool p_enable) {
}
bool Viewport::get_physics_object_picking() {
-
return physics_object_picking;
}
Vector2 Viewport::get_camera_coords(const Vector2 &p_viewport_coords) const {
-
Transform2D xf = get_final_transform();
return xf.xform(p_viewport_coords);
}
Vector2 Viewport::get_camera_rect_size() const {
-
return size;
}
@@ -3143,7 +3025,6 @@ void Viewport::set_disable_input(bool p_disable) {
}
bool Viewport::is_input_disabled() const {
-
return disable_input;
}
@@ -3166,61 +3047,55 @@ String Viewport::get_configuration_warning() const {
void Viewport::gui_reset_canvas_sort_index() {
gui.canvas_sort_index = 0;
}
-int Viewport::gui_get_canvas_sort_index() {
+int Viewport::gui_get_canvas_sort_index() {
return gui.canvas_sort_index++;
}
void Viewport::set_msaa(MSAA p_msaa) {
-
ERR_FAIL_INDEX(p_msaa, MSAA_MAX);
- if (msaa == p_msaa)
+ if (msaa == p_msaa) {
return;
+ }
msaa = p_msaa;
RS::get_singleton()->viewport_set_msaa(viewport, RS::ViewportMSAA(p_msaa));
}
Viewport::MSAA Viewport::get_msaa() const {
-
return msaa;
}
void Viewport::set_screen_space_aa(ScreenSpaceAA p_screen_space_aa) {
-
ERR_FAIL_INDEX(p_screen_space_aa, SCREEN_SPACE_AA_MAX);
- if (screen_space_aa == p_screen_space_aa)
+ if (screen_space_aa == p_screen_space_aa) {
return;
+ }
screen_space_aa = p_screen_space_aa;
RS::get_singleton()->viewport_set_screen_space_aa(viewport, RS::ViewportScreenSpaceAA(p_screen_space_aa));
}
Viewport::ScreenSpaceAA Viewport::get_screen_space_aa() const {
-
return screen_space_aa;
}
-void Viewport::set_debug_draw(DebugDraw p_debug_draw) {
+void Viewport::set_debug_draw(DebugDraw p_debug_draw) {
debug_draw = p_debug_draw;
RS::get_singleton()->viewport_set_debug_draw(viewport, RS::ViewportDebugDraw(p_debug_draw));
}
Viewport::DebugDraw Viewport::get_debug_draw() const {
-
return debug_draw;
}
int Viewport::get_render_info(RenderInfo p_info) {
-
return RS::get_singleton()->viewport_get_render_info(viewport, RS::ViewportRenderInfo(p_info));
}
void Viewport::set_snap_controls_to_pixels(bool p_enable) {
-
snap_controls_to_pixels = p_enable;
}
bool Viewport::is_snap_controls_to_pixels_enabled() const {
-
return snap_controls_to_pixels;
}
@@ -3296,6 +3171,7 @@ void Viewport::set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRe
default_canvas_item_texture_repeat = p_repeat;
_propagate_update_default_repeat(this);
}
+
Viewport::DefaultCanvasItemTextureRepeat Viewport::get_default_canvas_item_texture_repeat() const {
return default_canvas_item_texture_repeat;
}
@@ -3338,9 +3214,11 @@ Viewport *Viewport::get_parent_viewport() const {
void Viewport::set_embed_subwindows_hint(bool p_embed) {
gui.embed_subwindows_hint = p_embed;
}
+
bool Viewport::get_embed_subwindows_hint() const {
return gui.embed_subwindows_hint;
}
+
bool Viewport::is_embedding_subwindows() const {
return gui.embed_subwindows_hint;
}
@@ -3362,7 +3240,6 @@ void Viewport::pass_mouse_focus_to(Viewport *p_viewport, Control *p_control) {
}
void Viewport::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_world_2d", "world_2d"), &Viewport::set_world_2d);
ClassDB::bind_method(D_METHOD("get_world_2d"), &Viewport::get_world_2d);
ClassDB::bind_method(D_METHOD("find_world_2d"), &Viewport::find_world_2d);
@@ -3544,7 +3421,6 @@ void Viewport::_bind_methods() {
}
Viewport::Viewport() {
-
world_2d = Ref<World2D>(memnew(World2D));
viewport = RenderingServer::get_singleton()->viewport_create();
@@ -3629,7 +3505,6 @@ Viewport::Viewport() {
}
Viewport::~Viewport() {
-
//erase itself from viewport textures
for (Set<ViewportTexture *>::Element *E = viewport_textures.front(); E; E = E->next()) {
E->get()->vp = nullptr;
@@ -3652,21 +3527,20 @@ bool SubViewport::is_using_xr() {
void SubViewport::set_size(const Size2i &p_size) {
_set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
}
+
Size2i SubViewport::get_size() const {
return _get_size();
}
void SubViewport::set_size_2d_override(const Size2i &p_size) {
-
_set_size(_get_size(), p_size, Rect2i(), _stretch_transform(), true);
}
-Size2i SubViewport::get_size_2d_override() const {
+Size2i SubViewport::get_size_2d_override() const {
return _get_size_2d_override();
}
void SubViewport::set_size_2d_override_stretch(bool p_enable) {
-
if (p_enable == size_2d_override_stretch) {
return;
}
@@ -3674,28 +3548,26 @@ void SubViewport::set_size_2d_override_stretch(bool p_enable) {
size_2d_override_stretch = p_enable;
_set_size(_get_size(), _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
}
-bool SubViewport::is_size_2d_override_stretch_enabled() const {
+bool SubViewport::is_size_2d_override_stretch_enabled() const {
return size_2d_override_stretch;
}
void SubViewport::set_update_mode(UpdateMode p_mode) {
-
update_mode = p_mode;
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::ViewportUpdateMode(p_mode));
}
-SubViewport::UpdateMode SubViewport::get_update_mode() const {
+SubViewport::UpdateMode SubViewport::get_update_mode() const {
return update_mode;
}
void SubViewport::set_clear_mode(ClearMode p_mode) {
-
clear_mode = p_mode;
RS::get_singleton()->viewport_set_clear_mode(get_viewport_rid(), RS::ViewportClearMode(p_mode));
}
-SubViewport::ClearMode SubViewport::get_clear_mode() const {
+SubViewport::ClearMode SubViewport::get_clear_mode() const {
return clear_mode;
}
@@ -3704,7 +3576,6 @@ DisplayServer::WindowID SubViewport::get_window_id() const {
}
Transform2D SubViewport::_stretch_transform() {
-
Transform2D transform = Transform2D();
Size2i view_size_2d_override = _get_size_2d_override();
if (size_2d_override_stretch && view_size_2d_override.width > 0 && view_size_2d_override.height > 0) {
@@ -3716,7 +3587,6 @@ Transform2D SubViewport::_stretch_transform() {
}
void SubViewport::_notification(int p_what) {
-
if (p_what == NOTIFICATION_ENTER_TREE) {
RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 7da57347fd..4536b558f9 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -51,7 +51,6 @@ class Viewport;
class CollisionObject3D;
class ViewportTexture : public Texture2D {
-
GDCLASS(ViewportTexture, Texture2D);
NodePath path;
@@ -85,7 +84,6 @@ public:
};
class Viewport : public Node {
-
GDCLASS(Viewport, Node);
public:
@@ -236,7 +234,6 @@ private:
bool physics_has_last_mousepos;
Vector2 physics_last_mousepos;
struct {
-
bool alt;
bool control;
bool shift;
@@ -579,7 +576,6 @@ public:
};
class SubViewport : public Viewport {
-
GDCLASS(SubViewport, Viewport);
public:
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 19954299de..a9be8a1eff 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -43,20 +43,22 @@ void Window::set_title(const String &p_title) {
embedder->_sub_window_update(this);
} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
-
DisplayServer::get_singleton()->window_set_title(p_title, window_id);
}
}
+
String Window::get_title() const {
return title;
}
void Window::set_current_screen(int p_screen) {
current_screen = p_screen;
- if (window_id == DisplayServer::INVALID_WINDOW_ID)
+ if (window_id == DisplayServer::INVALID_WINDOW_ID) {
return;
+ }
DisplayServer::get_singleton()->window_set_current_screen(p_screen, window_id);
}
+
int Window::get_current_screen() const {
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
current_screen = DisplayServer::get_singleton()->window_get_current_screen(window_id);
@@ -65,17 +67,16 @@ int Window::get_current_screen() const {
}
void Window::set_position(const Point2i &p_position) {
-
position = p_position;
if (embedder) {
embedder->_sub_window_update(this);
} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
-
DisplayServer::get_singleton()->window_set_position(p_position, window_id);
}
}
+
Point2i Window::get_position() const {
return position;
}
@@ -84,13 +85,12 @@ void Window::set_size(const Size2i &p_size) {
size = p_size;
_update_window_size();
}
-Size2i Window::get_size() const {
+Size2i Window::get_size() const {
return size;
}
Size2i Window::get_real_size() const {
-
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
return DisplayServer::get_singleton()->window_get_real_size(window_id);
}
@@ -128,20 +128,17 @@ Size2i Window::get_min_size() const {
}
void Window::set_mode(Mode p_mode) {
-
mode = p_mode;
if (embedder) {
embedder->_sub_window_update(this);
} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
-
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WindowMode(p_mode), window_id);
}
}
Window::Mode Window::get_mode() const {
-
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
mode = (Mode)DisplayServer::get_singleton()->window_get_mode(window_id);
}
@@ -156,7 +153,6 @@ void Window::set_flag(Flags p_flag, bool p_enabled) {
embedder->_sub_window_update(this);
} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
-
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WindowFlags(p_flag), p_enabled, window_id);
}
}
@@ -181,8 +177,8 @@ void Window::request_attention() {
DisplayServer::get_singleton()->window_request_attention(window_id);
}
}
-void Window::move_to_foreground() {
+void Window::move_to_foreground() {
if (embedder) {
embedder->_sub_window_grab_focus(this);
@@ -207,6 +203,7 @@ void Window::set_ime_active(bool p_active) {
DisplayServer::get_singleton()->window_set_ime_active(p_active, window_id);
}
}
+
void Window::set_ime_position(const Point2i &p_pos) {
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
DisplayServer::get_singleton()->window_set_ime_position(p_pos, window_id);
@@ -251,8 +248,8 @@ void Window::_make_window() {
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
}
-void Window::_update_from_window() {
+void Window::_update_from_window() {
ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID);
mode = (Mode)DisplayServer::get_singleton()->window_get_mode(window_id);
for (int i = 0; i < FLAG_MAX; i++) {
@@ -283,7 +280,6 @@ void Window::_clear_window() {
}
void Window::_rect_changed_callback(const Rect2i &p_callback) {
-
//we must always accept this as the truth
if (size == p_callback.size && position == p_callback.position) {
return;
@@ -309,7 +305,6 @@ void Window::_propagate_window_notification(Node *p_node, int p_notification) {
}
void Window::_event_callback(DisplayServer::WindowEvent p_event) {
-
switch (p_event) {
case DisplayServer::WINDOW_EVENT_MOUSE_ENTER: {
_propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER);
@@ -351,12 +346,12 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) {
void Window::show() {
set_visible(true);
}
+
void Window::hide() {
set_visible(false);
}
void Window::set_visible(bool p_visible) {
-
if (visible == p_visible) {
return;
}
@@ -473,12 +468,12 @@ void Window::set_transient(bool p_transient) {
_clear_transient();
}
}
+
bool Window::is_transient() const {
return transient;
}
void Window::set_exclusive(bool p_exclusive) {
-
if (exclusive == p_exclusive) {
return;
}
@@ -506,7 +501,6 @@ bool Window::is_visible() const {
}
void Window::_update_window_size() {
-
Size2i size_limit;
if (wrap_controls) {
size_limit = get_contents_minimum_size();
@@ -535,6 +529,7 @@ void Window::_update_window_size() {
//update the viewport
_update_viewport_size();
}
+
void Window::_update_viewport_size() {
//update the viewport part
@@ -545,12 +540,10 @@ void Window::_update_viewport_size() {
float font_oversampling = 1.0;
if (content_scale_mode == CONTENT_SCALE_MODE_DISABLED || content_scale_size.x == 0 || content_scale_size.y == 0) {
-
stretch_transform = Transform2D();
final_size = size;
} else {
-
//actual screen video mode
Size2 video_mode = size;
Size2 desired_res = content_scale_size;
@@ -569,7 +562,6 @@ void Window::_update_viewport_size() {
// screen ratio is smaller vertically
if (content_scale_aspect == CONTENT_SCALE_ASPECT_KEEP_HEIGHT || content_scale_aspect == CONTENT_SCALE_ASPECT_EXPAND) {
-
//will stretch horizontally
viewport_size.x = desired_res.y * video_mode_aspect;
viewport_size.y = desired_res.y;
@@ -584,7 +576,6 @@ void Window::_update_viewport_size() {
} else {
//screen ratio is smaller horizontally
if (content_scale_aspect == CONTENT_SCALE_ASPECT_KEEP_WIDTH || content_scale_aspect == CONTENT_SCALE_ASPECT_EXPAND) {
-
//will stretch horizontally
viewport_size.x = desired_res.x;
viewport_size.y = desired_res.x / video_mode_aspect;
@@ -622,14 +613,12 @@ void Window::_update_viewport_size() {
//_update_font_oversampling(1.0);
} break;
case CONTENT_SCALE_MODE_OBJECTS: {
-
final_size = screen_size;
final_size_override = viewport_size;
attach_to_screen_rect = Rect2(margin, screen_size);
font_oversampling = screen_size.x / viewport_size.x;
} break;
case CONTENT_SCALE_MODE_PIXELS: {
-
final_size = viewport_size;
attach_to_screen_rect = Rect2(margin, screen_size);
@@ -652,12 +641,10 @@ void Window::_update_viewport_size() {
}
if (window_id == DisplayServer::MAIN_WINDOW_ID) {
-
if (!use_font_oversampling) {
font_oversampling = 1.0;
}
if (DynamicFontAtSize::font_oversampling != font_oversampling) {
-
DynamicFontAtSize::font_oversampling = font_oversampling;
DynamicFont::update_oversampling();
}
@@ -679,11 +666,9 @@ void Window::_update_window_callbacks() {
}
Viewport *Window::_get_embedder() const {
-
Viewport *vp = get_parent_viewport();
while (vp) {
-
if (vp->is_embedding_subwindows()) {
return vp;
}
@@ -699,10 +684,8 @@ Viewport *Window::_get_embedder() const {
void Window::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
-
bool embedded = false;
{
-
embedder = _get_embedder();
if (embedder) {
@@ -757,29 +740,24 @@ void Window::_notification(int p_what) {
}
if (p_what == NOTIFICATION_READY) {
-
if (wrap_controls) {
_update_child_controls();
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
-
if (transient) {
_clear_transient();
}
if (!is_embedded() && window_id != DisplayServer::INVALID_WINDOW_ID) {
-
if (window_id == DisplayServer::MAIN_WINDOW_ID) {
-
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
_update_window_callbacks();
} else {
_clear_window();
}
} else {
-
if (embedder) {
embedder->_sub_window_remove(this);
embedder = nullptr;
@@ -807,6 +785,7 @@ void Window::set_content_scale_mode(ContentScaleMode p_mode) {
content_scale_mode = p_mode;
_update_viewport_size();
}
+
Window::ContentScaleMode Window::get_content_scale_mode() const {
return content_scale_mode;
}
@@ -815,6 +794,7 @@ void Window::set_content_scale_aspect(ContentScaleAspect p_aspect) {
content_scale_aspect = p_aspect;
_update_viewport_size();
}
+
Window::ContentScaleAspect Window::get_content_scale_aspect() const {
return content_scale_aspect;
}
@@ -826,6 +806,7 @@ void Window::set_use_font_oversampling(bool p_oversampling) {
use_font_oversampling = p_oversampling;
_update_viewport_size();
}
+
bool Window::is_using_font_oversampling() const {
return use_font_oversampling;
}
@@ -861,8 +842,8 @@ Size2 Window::_get_contents_minimum_size() const {
return max;
}
-void Window::_update_child_controls() {
+void Window::_update_child_controls() {
if (!updating_child_controls) {
return;
}
@@ -871,8 +852,8 @@ void Window::_update_child_controls() {
updating_child_controls = false;
}
-void Window::child_controls_changed() {
+void Window::child_controls_changed() {
if (!is_inside_tree() || !visible || updating_child_controls) {
return;
}
@@ -882,8 +863,9 @@ void Window::child_controls_changed() {
}
void Window::_window_input(const Ref<InputEvent> &p_ev) {
- if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_ev.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_ev)))
+ if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_ev.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_ev))) {
return; //avoid joy input on editor
+ }
if (EngineDebugger::is_active()) {
//quit from game window using F8
@@ -905,15 +887,16 @@ void Window::_window_input(const Ref<InputEvent> &p_ev) {
unhandled_input(p_ev);
}
}
+
void Window::_window_input_text(const String &p_text) {
input_text(p_text);
}
+
void Window::_window_drop_files(const Vector<String> &p_files) {
emit_signal("files_dropped", p_files, current_screen);
}
Viewport *Window::get_parent_viewport() const {
-
if (get_parent()) {
return get_parent()->get_viewport();
} else {
@@ -922,7 +905,6 @@ Viewport *Window::get_parent_viewport() const {
}
Window *Window::get_parent_visible_window() const {
-
Viewport *vp = get_parent_viewport();
Window *window = nullptr;
while (vp) {
@@ -940,7 +922,6 @@ Window *Window::get_parent_visible_window() const {
}
void Window::popup_on_parent(const Rect2i &p_parent_rect) {
-
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
@@ -958,7 +939,6 @@ void Window::popup_on_parent(const Rect2i &p_parent_rect) {
}
void Window::popup_centered_clamped(const Size2i &p_size, float p_fallback_ratio) {
-
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
@@ -1009,11 +989,10 @@ void Window::popup_centered(const Size2i &p_minsize) {
}
void Window::popup_centered_ratio(float p_ratio) {
-
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND_MSG(window_id == DisplayServer::MAIN_WINDOW_ID, "Can't popup the main window.");
- Rect2i parent_rect;
+ Rect2 parent_rect;
if (is_embedded()) {
parent_rect = get_parent_viewport()->get_visible_rect();
@@ -1032,7 +1011,6 @@ void Window::popup_centered_ratio(float p_ratio) {
}
void Window::popup(const Rect2i &p_screen_rect) {
-
emit_signal("about_to_popup");
if (p_screen_rect != Rect2i()) {
@@ -1046,6 +1024,15 @@ void Window::popup(const Rect2i &p_screen_rect) {
set_size(adjust.size);
}
+ int scr = DisplayServer::get_singleton()->get_screen_count();
+ for (int i = 0; i < scr; i++) {
+ Rect2i r = DisplayServer::get_singleton()->screen_get_usable_rect(i);
+ if (r.has_point(position)) {
+ current_screen = i;
+ break;
+ }
+ }
+
set_transient(true);
set_visible(true);
_post_popup();
@@ -1074,7 +1061,6 @@ Rect2i Window::get_usable_parent_rect() const {
if (is_embedded()) {
parent = _get_embedder()->get_visible_rect();
} else {
-
const Window *w = is_visible() ? this : get_parent_visible_window();
//find a parent that can contain us
ERR_FAIL_COND_V(!w, Rect2());
@@ -1085,7 +1071,6 @@ Rect2i Window::get_usable_parent_rect() const {
}
void Window::add_child_notify(Node *p_child) {
-
Control *child_c = Object::cast_to<Control>(p_child);
if (child_c && child_c->data.theme.is_null() && (theme_owner || theme_owner_window)) {
@@ -1104,7 +1089,6 @@ void Window::add_child_notify(Node *p_child) {
}
void Window::remove_child_notify(Node *p_child) {
-
Control *child_c = Object::cast_to<Control>(p_child);
if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) {
@@ -1123,19 +1107,17 @@ void Window::remove_child_notify(Node *p_child) {
}
void Window::set_theme(const Ref<Theme> &p_theme) {
-
- if (theme == p_theme)
+ if (theme == p_theme) {
return;
+ }
theme = p_theme;
if (!p_theme.is_null()) {
-
theme_owner = nullptr;
theme_owner_window = this;
Control::_propagate_theme_changed(this, nullptr, this);
} else {
-
Control *parent_c = cast_to<Control>(get_parent());
if (parent_c && (parent_c->data.theme_owner || parent_c->data.theme_owner_window)) {
Control::_propagate_theme_changed(this, parent_c->data.theme_owner, parent_c->data.theme_owner_window);
@@ -1149,6 +1131,7 @@ void Window::set_theme(const Ref<Theme> &p_theme) {
}
}
}
+
Ref<Theme> Window::get_theme() const {
return theme;
}
@@ -1157,22 +1140,27 @@ Ref<Texture2D> Window::get_theme_icon(const StringName &p_name, const StringName
StringName type = p_type ? p_type : get_class_name();
return Control::get_icons(theme_owner, theme_owner_window, p_name, type);
}
+
Ref<Shader> Window::get_theme_shader(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::get_shaders(theme_owner, theme_owner_window, p_name, type);
}
+
Ref<StyleBox> Window::get_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::get_styleboxs(theme_owner, theme_owner_window, p_name, type);
}
+
Ref<Font> Window::get_theme_font(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::get_fonts(theme_owner, theme_owner_window, p_name, type);
}
+
Color Window::get_theme_color(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::get_colors(theme_owner, theme_owner_window, p_name, type);
}
+
int Window::get_theme_constant(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::get_constants(theme_owner, theme_owner_window, p_name, type);
@@ -1182,22 +1170,27 @@ bool Window::has_theme_icon(const StringName &p_name, const StringName &p_type)
StringName type = p_type ? p_type : get_class_name();
return Control::has_icons(theme_owner, theme_owner_window, p_name, type);
}
+
bool Window::has_theme_shader(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::has_shaders(theme_owner, theme_owner_window, p_name, type);
}
+
bool Window::has_theme_stylebox(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::has_styleboxs(theme_owner, theme_owner_window, p_name, type);
}
+
bool Window::has_theme_font(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::has_fonts(theme_owner, theme_owner_window, p_name, type);
}
+
bool Window::has_theme_color(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::has_colors(theme_owner, theme_owner_window, p_name, type);
}
+
bool Window::has_theme_constant(const StringName &p_name, const StringName &p_type) const {
StringName type = p_type ? p_type : get_class_name();
return Control::has_constants(theme_owner, theme_owner_window, p_name, type);
@@ -1240,7 +1233,6 @@ Rect2i Window::get_parent_rect() const {
}
void Window::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_title", "title"), &Window::set_title);
ClassDB::bind_method(D_METHOD("get_title"), &Window::get_title);
@@ -1402,5 +1394,6 @@ Window::Window() {
content_scale_aspect = CONTENT_SCALE_ASPECT_IGNORE;
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
}
+
Window::~Window() {
}
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 684df728b8..2d0e2daf41 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -154,6 +154,7 @@
#include "scene/resources/physics_material.h"
#include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h"
+#include "scene/resources/ray_shape_2d.h"
#include "scene/resources/ray_shape_3d.h"
#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/resource_format_text.h"
@@ -235,7 +236,6 @@ static Ref<ResourceFormatSaverShader> resource_saver_shader;
static Ref<ResourceFormatLoaderShader> resource_loader_shader;
void register_scene_types() {
-
SceneStringNames::create();
OS::get_singleton()->yield(); //may take time to init
@@ -436,6 +436,7 @@ void register_scene_types() {
ClassDB::register_class<BakedLightmap>();
ClassDB::register_class<BakedLightmapData>();
ClassDB::register_class<LightmapProbe>();
+ ClassDB::register_virtual_class<Lightmapper>();
ClassDB::register_class<GPUParticles3D>();
ClassDB::register_class<CPUParticles3D>();
ClassDB::register_class<Position3D>();
@@ -688,6 +689,7 @@ void register_scene_types() {
ClassDB::register_class<AnimatedTexture>();
ClassDB::register_class<CameraTexture>();
ClassDB::register_virtual_class<TextureLayered>();
+ ClassDB::register_virtual_class<ImageTextureLayered>();
ClassDB::register_class<Cubemap>();
ClassDB::register_class<CubemapArray>();
ClassDB::register_class<Texture2DArray>();
@@ -920,7 +922,6 @@ void register_scene_types() {
}
void unregister_scene_types() {
-
SceneDebugger::deinitialize();
clear_default_theme();
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index c5806ee7b3..014b773298 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -31,43 +31,33 @@
#include "animation.h"
#include "scene/scene_string_names.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#define ANIM_MIN_LENGTH 0.001
bool Animation::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name.begins_with("tracks/")) {
-
int track = name.get_slicec('/', 1).to_int();
String what = name.get_slicec('/', 2);
if (tracks.size() == track && what == "type") {
-
String type = p_value;
if (type == "transform") {
-
add_track(TYPE_TRANSFORM);
} else if (type == "value") {
-
add_track(TYPE_VALUE);
} else if (type == "method") {
-
add_track(TYPE_METHOD);
} else if (type == "bezier") {
-
add_track(TYPE_BEZIER);
} else if (type == "audio") {
-
add_track(TYPE_AUDIO);
} else if (type == "animation") {
-
add_track(TYPE_ANIMATION);
} else {
-
return false;
}
@@ -76,20 +66,18 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_INDEX_V(track, tracks.size(), false);
- if (what == "path")
+ if (what == "path") {
track_set_path(track, p_value);
- else if (what == "interp")
+ } else if (what == "interp") {
track_set_interpolation_type(track, InterpolationType(p_value.operator int()));
- else if (what == "loop_wrap")
+ } else if (what == "loop_wrap") {
track_set_interpolation_loop_wrap(track, p_value);
- else if (what == "imported")
+ } else if (what == "imported") {
track_set_imported(track, p_value);
- else if (what == "enabled")
+ } else if (what == "enabled") {
track_set_enabled(track, p_value);
- else if (what == "keys" || what == "key_values") {
-
+ } else if (what == "keys" || what == "key_values") {
if (track_get_type(track) == TYPE_TRANSFORM) {
-
TransformTrack *tt = static_cast<TransformTrack *>(tracks[track]);
Vector<float> values = p_value;
int vcount = values.size();
@@ -100,7 +88,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
tt->transforms.resize(vcount / 12);
for (int i = 0; i < (vcount / 12); i++) {
-
TKey<TransformKey> &tk = tt->transforms.write[i];
const float *ofs = &r[i * 12];
tk.time = ofs[0];
@@ -121,7 +108,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
}
} else if (track_get_type(track) == TYPE_VALUE) {
-
ValueTrack *vt = static_cast<ValueTrack *>(tracks[track]);
Dictionary d = p_value;
ERR_FAIL_COND_V(!d.has("times"), false);
@@ -133,10 +119,11 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
if (d.has("update")) {
int um = d["update"];
- if (um < 0)
+ if (um < 0) {
um = 0;
- else if (um > 3)
+ } else if (um > 3) {
um = 3;
+ }
vt->update_mode = UpdateMode(um);
}
@@ -146,7 +133,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(times.size() != values.size(), false);
if (times.size()) {
-
int valcount = times.size();
const float *rt = times.ptr();
@@ -154,20 +140,17 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
vt->values.resize(valcount);
for (int i = 0; i < valcount; i++) {
-
vt->values.write[i].time = rt[i];
vt->values.write[i].value = values[i];
}
if (d.has("transitions")) {
-
Vector<float> transitions = d["transitions"];
ERR_FAIL_COND_V(transitions.size() != valcount, false);
const float *rtr = transitions.ptr();
for (int i = 0; i < valcount; i++) {
-
vt->values.write[i].transition = rtr[i];
}
}
@@ -176,9 +159,9 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
return true;
} else if (track_get_type(track) == TYPE_METHOD) {
-
- while (track_get_key_count(track))
+ while (track_get_key_count(track)) {
track_remove_key(track, 0); //well shouldn't be set anyway
+ }
Dictionary d = p_value;
ERR_FAIL_COND_V(!d.has("times"), false);
@@ -190,31 +173,26 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(times.size() != values.size(), false);
if (times.size()) {
-
int valcount = times.size();
const float *rt = times.ptr();
for (int i = 0; i < valcount; i++) {
-
track_insert_key(track, rt[i], values[i]);
}
if (d.has("transitions")) {
-
Vector<float> transitions = d["transitions"];
ERR_FAIL_COND_V(transitions.size() != valcount, false);
const float *rtr = transitions.ptr();
for (int i = 0; i < valcount; i++) {
-
track_set_key_transition(track, i, rtr[i]);
}
}
}
} else if (track_get_type(track) == TYPE_BEZIER) {
-
BezierTrack *bt = static_cast<BezierTrack *>(tracks[track]);
Dictionary d = p_value;
ERR_FAIL_COND_V(!d.has("times"), false);
@@ -226,7 +204,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(times.size() * 5 != values.size(), false);
if (times.size()) {
-
int valcount = times.size();
const float *rt = times.ptr();
@@ -235,7 +212,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
bt->values.resize(valcount);
for (int i = 0; i < valcount; i++) {
-
bt->values.write[i].time = rt[i];
bt->values.write[i].transition = 0; //unused in bezier
bt->values.write[i].value.value = rv[i * 5 + 0];
@@ -248,7 +224,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
return true;
} else if (track_get_type(track) == TYPE_AUDIO) {
-
AudioTrack *ad = static_cast<AudioTrack *>(tracks[track]);
Dictionary d = p_value;
ERR_FAIL_COND_V(!d.has("times"), false);
@@ -260,7 +235,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(clips.size() != times.size(), false);
if (times.size()) {
-
int valcount = times.size();
const float *rt = times.ptr();
@@ -268,14 +242,16 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ad->values.clear();
for (int i = 0; i < valcount; i++) {
-
Dictionary d2 = clips[i];
- if (!d2.has("start_offset"))
+ if (!d2.has("start_offset")) {
continue;
- if (!d2.has("end_offset"))
+ }
+ if (!d2.has("end_offset")) {
continue;
- if (!d2.has("stream"))
+ }
+ if (!d2.has("stream")) {
continue;
+ }
TKey<AudioKey> ak;
ak.time = rt[i];
@@ -289,7 +265,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
return true;
} else if (track_get_type(track) == TYPE_ANIMATION) {
-
AnimationTrack *an = static_cast<AnimationTrack *>(tracks[track]);
Dictionary d = p_value;
ERR_FAIL_COND_V(!d.has("times"), false);
@@ -301,7 +276,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
ERR_FAIL_COND_V(clips.size() != times.size(), false);
if (times.size()) {
-
int valcount = times.size();
const float *rt = times.ptr();
@@ -310,7 +284,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
an->values.resize(valcount);
for (int i = 0; i < valcount; i++) {
-
TKey<StringName> ak;
ak.time = rt[i];
ak.value = rc[i];
@@ -322,33 +295,31 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) {
} else {
return false;
}
- } else
+ } else {
return false;
- } else
+ }
+ } else {
return false;
+ }
return true;
}
bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
- if (name == "length")
+ if (name == "length") {
r_ret = length;
- else if (name == "loop")
+ } else if (name == "loop") {
r_ret = loop;
- else if (name == "step")
+ } else if (name == "step") {
r_ret = step;
- else if (name.begins_with("tracks/")) {
-
+ } else if (name.begins_with("tracks/")) {
int track = name.get_slicec('/', 1).to_int();
String what = name.get_slicec('/', 2);
ERR_FAIL_INDEX_V(track, tracks.size(), false);
if (what == "type") {
-
switch (track_get_type(track)) {
-
case TYPE_TRANSFORM:
r_ret = "transform";
break;
@@ -371,20 +342,18 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
- } else if (what == "path")
+ } else if (what == "path") {
r_ret = track_get_path(track);
- else if (what == "interp")
+ } else if (what == "interp") {
r_ret = track_get_interpolation_type(track);
- else if (what == "loop_wrap")
+ } else if (what == "loop_wrap") {
r_ret = track_get_interpolation_loop_wrap(track);
- else if (what == "imported")
+ } else if (what == "imported") {
r_ret = track_is_imported(track);
- else if (what == "enabled")
+ } else if (what == "enabled") {
r_ret = track_is_enabled(track);
- else if (what == "keys") {
-
+ } else if (what == "keys") {
if (track_get_type(track) == TYPE_TRANSFORM) {
-
Vector<float> keys;
int kk = track_get_key_count(track);
keys.resize(kk * 12);
@@ -393,7 +362,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
int idx = 0;
for (int i = 0; i < track_get_key_count(track); i++) {
-
Vector3 loc;
Quat rot;
Vector3 scale;
@@ -419,7 +387,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
} else if (track_get_type(track) == TYPE_VALUE) {
-
const ValueTrack *vt = static_cast<const ValueTrack *>(tracks[track]);
Dictionary d;
@@ -442,7 +409,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
const TKey<Variant> *vls = vt->values.ptr();
for (int i = 0; i < kk; i++) {
-
wti[idx] = vls[i].time;
wtr[idx] = vls[i].transition;
key_values[idx] = vls[i].value;
@@ -461,7 +427,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
} else if (track_get_type(track) == TYPE_METHOD) {
-
Dictionary d;
Vector<float> key_times;
@@ -479,7 +444,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
int idx = 0;
for (int i = 0; i < track_get_key_count(track); i++) {
-
wti[idx] = track_get_key_time(track, i);
wtr[idx] = track_get_key_transition(track, i);
key_values[idx] = track_get_key_value(track, i);
@@ -497,7 +461,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
} else if (track_get_type(track) == TYPE_BEZIER) {
-
const BezierTrack *bt = static_cast<const BezierTrack *>(tracks[track]);
Dictionary d;
@@ -518,7 +481,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
const TKey<BezierKey> *vls = bt->values.ptr();
for (int i = 0; i < kk; i++) {
-
wti[idx] = vls[i].time;
wpo[idx * 5 + 0] = vls[i].value.value;
wpo[idx * 5 + 1] = vls[i].value.in_handle.x;
@@ -535,7 +497,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
} else if (track_get_type(track) == TYPE_AUDIO) {
-
const AudioTrack *ad = static_cast<const AudioTrack *>(tracks[track]);
Dictionary d;
@@ -554,7 +515,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
const TKey<AudioKey> *vls = ad->values.ptr();
for (int i = 0; i < kk; i++) {
-
wti[idx] = vls[i].time;
Dictionary clip;
clip["start_offset"] = vls[i].value.start_offset;
@@ -571,7 +531,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
} else if (track_get_type(track) == TYPE_ANIMATION) {
-
const AnimationTrack *an = static_cast<const AnimationTrack *>(tracks[track]);
Dictionary d;
@@ -590,7 +549,6 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
const TKey<StringName> *vls = an->values.ptr();
for (int i = 0; i < kk; i++) {
-
wti[i] = vls[i].time;
wcl[i] = vls[i].value;
}
@@ -602,17 +560,18 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
- } else
+ } else {
return false;
- } else
+ }
+ } else {
return false;
+ }
return true;
}
void Animation::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < tracks.size(); i++) {
-
p_list->push_back(PropertyInfo(Variant::STRING, "tracks/" + itos(i) + "/type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::NODE_PATH, "tracks/" + itos(i) + "/path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::INT, "tracks/" + itos(i) + "/interp", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
@@ -624,44 +583,36 @@ void Animation::_get_property_list(List<PropertyInfo> *p_list) const {
}
int Animation::add_track(TrackType p_type, int p_at_pos) {
-
- if (p_at_pos < 0 || p_at_pos >= tracks.size())
+ if (p_at_pos < 0 || p_at_pos >= tracks.size()) {
p_at_pos = tracks.size();
+ }
switch (p_type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = memnew(TransformTrack);
tracks.insert(p_at_pos, tt);
} break;
case TYPE_VALUE: {
-
tracks.insert(p_at_pos, memnew(ValueTrack));
} break;
case TYPE_METHOD: {
-
tracks.insert(p_at_pos, memnew(MethodTrack));
} break;
case TYPE_BEZIER: {
-
tracks.insert(p_at_pos, memnew(BezierTrack));
} break;
case TYPE_AUDIO: {
-
tracks.insert(p_at_pos, memnew(AudioTrack));
} break;
case TYPE_ANIMATION: {
-
tracks.insert(p_at_pos, memnew(AnimationTrack));
} break;
default: {
-
ERR_PRINT("Unknown track type");
}
}
@@ -671,44 +622,36 @@ int Animation::add_track(TrackType p_type, int p_at_pos) {
}
void Animation::remove_track(int p_track) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
_clear(tt->transforms);
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
_clear(vt->values);
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
_clear(mt->methods);
} break;
case TYPE_BEZIER: {
-
BezierTrack *bz = static_cast<BezierTrack *>(t);
_clear(bz->values);
} break;
case TYPE_AUDIO: {
-
AudioTrack *ad = static_cast<AudioTrack *>(t);
_clear(ad->values);
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *an = static_cast<AnimationTrack *>(t);
_clear(an->values);
@@ -722,18 +665,15 @@ void Animation::remove_track(int p_track) {
}
int Animation::get_track_count() const {
-
return tracks.size();
}
Animation::TrackType Animation::track_get_type(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), TYPE_TRANSFORM);
return tracks[p_track]->type;
}
void Animation::track_set_path(int p_track, const NodePath &p_path) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
tracks[p_track]->path = p_path;
emit_changed();
@@ -741,23 +681,20 @@ void Animation::track_set_path(int p_track, const NodePath &p_path) {
}
NodePath Animation::track_get_path(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), NodePath());
return tracks[p_track]->path;
}
int Animation::find_track(const NodePath &p_path) const {
-
for (int i = 0; i < tracks.size(); i++) {
-
- if (tracks[i]->path == p_path)
+ if (tracks[i]->path == p_path) {
return i;
+ }
};
return -1;
};
void Animation::track_set_interpolation_type(int p_track, InterpolationType p_interp) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
ERR_FAIL_INDEX(p_interp, 3);
tracks[p_track]->interpolation = p_interp;
@@ -765,7 +702,6 @@ void Animation::track_set_interpolation_type(int p_track, InterpolationType p_in
}
Animation::InterpolationType Animation::track_get_interpolation_type(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), INTERPOLATION_NEAREST);
return tracks[p_track]->interpolation;
}
@@ -777,7 +713,6 @@ void Animation::track_set_interpolation_loop_wrap(int p_track, bool p_enable) {
}
bool Animation::track_get_interpolation_loop_wrap(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), INTERPOLATION_NEAREST);
return tracks[p_track]->loop_wrap;
}
@@ -808,23 +743,20 @@ int Animation::_insert_pos(float p_time, T& p_keys) {
}
}
+
*/
template <class T, class V>
int Animation::_insert(float p_time, T &p_keys, const V &p_value) {
-
int idx = p_keys.size();
while (true) {
-
// Condition for replacement.
if (idx > 0 && Math::is_equal_approx(p_keys[idx - 1].time, p_time)) {
-
p_keys.write[idx - 1] = p_value;
return idx - 1;
// Condition for insert.
} else if (idx == 0 || p_keys[idx - 1].time < p_time) {
-
p_keys.insert(idx, p_value);
return idx;
}
@@ -837,12 +769,10 @@ int Animation::_insert(float p_time, T &p_keys, const V &p_value) {
template <class T>
void Animation::_clear(T &p_keys) {
-
p_keys.clear();
}
Error Animation::transform_track_get_key(int p_track, int p_key, Vector3 *r_loc, Quat *r_rot, Vector3 *r_scale) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track];
@@ -850,18 +780,20 @@ Error Animation::transform_track_get_key(int p_track, int p_key, Vector3 *r_loc,
ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM, ERR_INVALID_PARAMETER);
ERR_FAIL_INDEX_V(p_key, tt->transforms.size(), ERR_INVALID_PARAMETER);
- if (r_loc)
+ if (r_loc) {
*r_loc = tt->transforms[p_key].value.loc;
- if (r_rot)
+ }
+ if (r_rot) {
*r_rot = tt->transforms[p_key].value.rot;
- if (r_scale)
+ }
+ if (r_scale) {
*r_scale = tt->transforms[p_key].value.scale;
+ }
return OK;
}
int Animation::transform_track_insert_key(int p_track, float p_time, const Vector3 &p_loc, const Quat &p_rot, const Vector3 &p_scale) {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM, -1);
@@ -880,55 +812,47 @@ int Animation::transform_track_insert_key(int p_track, float p_time, const Vecto
}
void Animation::track_remove_key_at_position(int p_track, float p_pos) {
-
int idx = track_find_key(p_track, p_pos, true);
ERR_FAIL_COND(idx < 0);
track_remove_key(p_track, idx);
}
void Animation::track_remove_key(int p_track, int p_idx) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
switch (t->type) {
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX(p_idx, tt->transforms.size());
tt->transforms.remove(p_idx);
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX(p_idx, vt->values.size());
vt->values.remove(p_idx);
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX(p_idx, mt->methods.size());
mt->methods.remove(p_idx);
} break;
case TYPE_BEZIER: {
-
BezierTrack *bz = static_cast<BezierTrack *>(t);
ERR_FAIL_INDEX(p_idx, bz->values.size());
bz->values.remove(p_idx);
} break;
case TYPE_AUDIO: {
-
AudioTrack *ad = static_cast<AudioTrack *>(t);
ERR_FAIL_INDEX(p_idx, ad->values.size());
ad->values.remove(p_idx);
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *an = static_cast<AnimationTrack *>(t);
ERR_FAIL_INDEX(p_idx, an->values.size());
an->values.remove(p_idx);
@@ -940,74 +864,79 @@ void Animation::track_remove_key(int p_track, int p_idx) {
}
int Animation::track_find_key(int p_track, float p_time, bool p_exact) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
switch (t->type) {
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
int k = _find(tt->transforms, p_time);
- if (k < 0 || k >= tt->transforms.size())
+ if (k < 0 || k >= tt->transforms.size()) {
return -1;
- if (tt->transforms[k].time != p_time && p_exact)
+ }
+ if (tt->transforms[k].time != p_time && p_exact) {
return -1;
+ }
return k;
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
int k = _find(vt->values, p_time);
- if (k < 0 || k >= vt->values.size())
+ if (k < 0 || k >= vt->values.size()) {
return -1;
- if (vt->values[k].time != p_time && p_exact)
+ }
+ if (vt->values[k].time != p_time && p_exact) {
return -1;
+ }
return k;
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
int k = _find(mt->methods, p_time);
- if (k < 0 || k >= mt->methods.size())
+ if (k < 0 || k >= mt->methods.size()) {
return -1;
- if (mt->methods[k].time != p_time && p_exact)
+ }
+ if (mt->methods[k].time != p_time && p_exact) {
return -1;
+ }
return k;
} break;
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
int k = _find(bt->values, p_time);
- if (k < 0 || k >= bt->values.size())
+ if (k < 0 || k >= bt->values.size()) {
return -1;
- if (bt->values[k].time != p_time && p_exact)
+ }
+ if (bt->values[k].time != p_time && p_exact) {
return -1;
+ }
return k;
} break;
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
int k = _find(at->values, p_time);
- if (k < 0 || k >= at->values.size())
+ if (k < 0 || k >= at->values.size()) {
return -1;
- if (at->values[k].time != p_time && p_exact)
+ }
+ if (at->values[k].time != p_time && p_exact) {
return -1;
+ }
return k;
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
int k = _find(at->values, p_time);
- if (k < 0 || k >= at->values.size())
+ if (k < 0 || k >= at->values.size()) {
return -1;
- if (at->values[k].time != p_time && p_exact)
+ }
+ if (at->values[k].time != p_time && p_exact) {
return -1;
+ }
return k;
} break;
@@ -1017,33 +946,32 @@ int Animation::track_find_key(int p_track, float p_time, bool p_exact) const {
}
void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key, float p_transition) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
Dictionary d = p_key;
Vector3 loc;
- if (d.has("location"))
+ if (d.has("location")) {
loc = d["location"];
+ }
Quat rot;
- if (d.has("rotation"))
+ if (d.has("rotation")) {
rot = d["rotation"];
+ }
Vector3 scale;
- if (d.has("scale"))
+ if (d.has("scale")) {
scale = d["scale"];
+ }
int idx = transform_track_insert_key(p_track, p_time, loc, rot, scale);
track_set_key_transition(p_track, idx, p_transition);
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
TKey<Variant> k;
@@ -1054,7 +982,6 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_COND(p_key.get_type() != Variant::DICTIONARY);
@@ -1074,7 +1001,6 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key
} break;
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
Array arr = p_key;
@@ -1091,7 +1017,6 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key
} break;
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
Dictionary k = p_key;
@@ -1108,7 +1033,6 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
TKey<StringName> ak;
@@ -1124,40 +1048,32 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key
}
int Animation::track_get_key_count(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
return tt->transforms.size();
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
return vt->values.size();
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
return mt->methods.size();
} break;
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
return bt->values.size();
} break;
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
return at->values.size();
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
return at->values.size();
} break;
@@ -1167,14 +1083,11 @@ int Animation::track_get_key_count(int p_track) const {
}
Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), Variant());
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), Variant());
@@ -1186,14 +1099,12 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
return d;
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, vt->values.size(), Variant());
return vt->values[p_key_idx].value;
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, mt->methods.size(), Variant());
Dictionary d;
@@ -1203,7 +1114,6 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
} break;
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, bt->values.size(), Variant());
@@ -1218,7 +1128,6 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
} break;
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, at->values.size(), Variant());
@@ -1230,7 +1139,6 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, at->values.size(), Variant());
@@ -1243,48 +1151,40 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
}
float Animation::track_get_key_time(int p_track, int p_key_idx) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), -1);
return tt->transforms[p_key_idx].time;
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, vt->values.size(), -1);
return vt->values[p_key_idx].time;
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, mt->methods.size(), -1);
return mt->methods[p_key_idx].time;
} break;
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, bt->values.size(), -1);
return bt->values[p_key_idx].time;
} break;
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, at->values.size(), -1);
return at->values[p_key_idx].time;
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, at->values.size(), -1);
return at->values[p_key_idx].time;
@@ -1296,14 +1196,11 @@ float Animation::track_get_key_time(int p_track, int p_key_idx) const {
}
void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, tt->transforms.size());
TKey<TransformKey> key = tt->transforms[p_key_idx];
@@ -1313,7 +1210,6 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
return;
}
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, vt->values.size());
TKey<Variant> key = vt->values[p_key_idx];
@@ -1323,7 +1219,6 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
return;
}
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, mt->methods.size());
MethodKey key = mt->methods[p_key_idx];
@@ -1333,7 +1228,6 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
return;
}
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, bt->values.size());
TKey<BezierKey> key = bt->values[p_key_idx];
@@ -1343,7 +1237,6 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
return;
}
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, at->values.size());
TKey<AudioKey> key = at->values[p_key_idx];
@@ -1353,7 +1246,6 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
return;
}
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, at->values.size());
TKey<StringName> key = at->values[p_key_idx];
@@ -1368,42 +1260,34 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) {
}
float Animation::track_get_key_transition(int p_track, int p_key_idx) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), -1);
return tt->transforms[p_key_idx].transition;
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, vt->values.size(), -1);
return vt->values[p_key_idx].transition;
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX_V(p_key_idx, mt->methods.size(), -1);
return mt->methods[p_key_idx].transition;
} break;
case TYPE_BEZIER: {
-
return 1; //bezier does not really use transitions
} break;
case TYPE_AUDIO: {
-
return 1; //audio does not really use transitions
} break;
case TYPE_ANIMATION: {
-
return 1; //animation does not really use transitions
} break;
}
@@ -1412,29 +1296,28 @@ float Animation::track_get_key_transition(int p_track, int p_key_idx) const {
}
void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p_value) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, tt->transforms.size());
Dictionary d = p_value;
- if (d.has("location"))
+ if (d.has("location")) {
tt->transforms.write[p_key_idx].value.loc = d["location"];
- if (d.has("rotation"))
+ }
+ if (d.has("rotation")) {
tt->transforms.write[p_key_idx].value.rot = d["rotation"];
- if (d.has("scale"))
+ }
+ if (d.has("scale")) {
tt->transforms.write[p_key_idx].value.scale = d["scale"];
+ }
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, vt->values.size());
@@ -1442,20 +1325,20 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, mt->methods.size());
Dictionary d = p_value;
- if (d.has("method"))
+ if (d.has("method")) {
mt->methods.write[p_key_idx].method = d["method"];
- if (d.has("args"))
+ }
+ if (d.has("args")) {
mt->methods.write[p_key_idx].params = d["args"];
+ }
} break;
case TYPE_BEZIER: {
-
BezierTrack *bt = static_cast<BezierTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, bt->values.size());
@@ -1470,7 +1353,6 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p
} break;
case TYPE_AUDIO: {
-
AudioTrack *at = static_cast<AudioTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, at->values.size());
@@ -1485,7 +1367,6 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p
} break;
case TYPE_ANIMATION: {
-
AnimationTrack *at = static_cast<AnimationTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, at->values.size());
@@ -1498,27 +1379,22 @@ void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p
}
void Animation::track_set_key_transition(int p_track, int p_key_idx, float p_transition) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
TransformTrack *tt = static_cast<TransformTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, tt->transforms.size());
tt->transforms.write[p_key_idx].transition = p_transition;
} break;
case TYPE_VALUE: {
-
ValueTrack *vt = static_cast<ValueTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, vt->values.size());
vt->values.write[p_key_idx].transition = p_transition;
} break;
case TYPE_METHOD: {
-
MethodTrack *mt = static_cast<MethodTrack *>(t);
ERR_FAIL_INDEX(p_key_idx, mt->methods.size());
mt->methods.write[p_key_idx].transition = p_transition;
@@ -1536,42 +1412,43 @@ void Animation::track_set_key_transition(int p_track, int p_key_idx, float p_tra
template <class K>
int Animation::_find(const Vector<K> &p_keys, float p_time) const {
-
int len = p_keys.size();
- if (len == 0)
+ if (len == 0) {
return -2;
+ }
int low = 0;
int high = len - 1;
int middle = 0;
#ifdef DEBUG_ENABLED
- if (low > high)
+ if (low > high) {
ERR_PRINT("low > high, this may be a bug");
+ }
#endif
const K *keys = &p_keys[0];
while (low <= high) {
-
middle = (low + high) / 2;
if (Math::is_equal_approx(p_time, keys[middle].time)) { //match
return middle;
- } else if (p_time < keys[middle].time)
+ } else if (p_time < keys[middle].time) {
high = middle - 1; //search low end of array
- else
+ } else {
low = middle + 1; //search high end of array
+ }
}
- if (keys[middle].time > p_time)
+ if (keys[middle].time > p_time) {
middle--;
+ }
return middle;
}
Animation::TransformKey Animation::_interpolate(const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, float p_c) const {
-
TransformKey ret;
ret.loc = _interpolate(p_a.loc, p_b.loc, p_c);
ret.rot = _interpolate(p_a.rot, p_b.rot, p_c);
@@ -1581,27 +1458,24 @@ Animation::TransformKey Animation::_interpolate(const Animation::TransformKey &p
}
Vector3 Animation::_interpolate(const Vector3 &p_a, const Vector3 &p_b, float p_c) const {
-
return p_a.lerp(p_b, p_c);
}
-Quat Animation::_interpolate(const Quat &p_a, const Quat &p_b, float p_c) const {
+Quat Animation::_interpolate(const Quat &p_a, const Quat &p_b, float p_c) const {
return p_a.slerp(p_b, p_c);
}
-Variant Animation::_interpolate(const Variant &p_a, const Variant &p_b, float p_c) const {
+Variant Animation::_interpolate(const Variant &p_a, const Variant &p_b, float p_c) const {
Variant dst;
Variant::interpolate(p_a, p_b, p_c, dst);
return dst;
}
float Animation::_interpolate(const float &p_a, const float &p_b, float p_c) const {
-
return p_a * (1.0 - p_c) + p_b * p_c;
}
Animation::TransformKey Animation::_cubic_interpolate(const Animation::TransformKey &p_pre_a, const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, const Animation::TransformKey &p_post_b, float p_c) const {
-
Animation::TransformKey tk;
tk.loc = p_a.loc.cubic_interpolate(p_b.loc, p_pre_a.loc, p_post_b.loc, p_c);
@@ -1610,16 +1484,16 @@ Animation::TransformKey Animation::_cubic_interpolate(const Animation::Transform
return tk;
}
-Vector3 Animation::_cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a, const Vector3 &p_b, const Vector3 &p_post_b, float p_c) const {
+Vector3 Animation::_cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a, const Vector3 &p_b, const Vector3 &p_post_b, float p_c) const {
return p_a.cubic_interpolate(p_b, p_pre_a, p_post_b, p_c);
}
-Quat Animation::_cubic_interpolate(const Quat &p_pre_a, const Quat &p_a, const Quat &p_b, const Quat &p_post_b, float p_c) const {
+Quat Animation::_cubic_interpolate(const Quat &p_pre_a, const Quat &p_a, const Quat &p_b, const Quat &p_post_b, float p_c) const {
return p_a.cubic_slerp(p_b, p_pre_a, p_post_b, p_c);
}
-Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, float p_c) const {
+Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, float p_c) const {
Variant::Type type_a = p_a.get_type();
Variant::Type type_b = p_b.get_type();
Variant::Type type_pa = p_pre_a.get_type();
@@ -1650,14 +1524,11 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
} else if ((vformat & (vformat - 1))) {
-
return p_a; //can't interpolate, mix of types
}
switch (type_a) {
-
case Variant::VECTOR2: {
-
Vector2 a = p_a;
Vector2 b = p_b;
Vector2 pa = p_pre_a;
@@ -1666,7 +1537,6 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
return a.cubic_interpolate(b, pa, pb, p_c);
}
case Variant::RECT2: {
-
Rect2 a = p_a;
Rect2 b = p_b;
Rect2 pa = p_pre_a;
@@ -1677,7 +1547,6 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c));
}
case Variant::VECTOR3: {
-
Vector3 a = p_a;
Vector3 b = p_b;
Vector3 pa = p_pre_a;
@@ -1686,7 +1555,6 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
return a.cubic_interpolate(b, pa, pb, p_c);
}
case Variant::QUAT: {
-
Quat a = p_a;
Quat b = p_b;
Quat pa = p_pre_a;
@@ -1695,7 +1563,6 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
return a.cubic_slerp(b, pa, pb, p_c);
}
case Variant::AABB: {
-
AABB a = p_a;
AABB b = p_b;
AABB pa = p_pre_a;
@@ -1706,31 +1573,31 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c));
}
default: {
-
return _interpolate(p_a, p_b, p_c);
}
}
}
-float Animation::_cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const {
+float Animation::_cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const {
return _interpolate(p_a, p_b, p_c);
}
template <class T>
T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const {
-
int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end)
if (len <= 0) {
// (-1 or -2 returned originally) (plus one above)
// meaning no keys, or only key time is larger than length
- if (p_ok)
+ if (p_ok) {
*p_ok = false;
+ }
return T();
} else if (len == 1) { // one key found (0+1), return it
- if (p_ok)
+ if (p_ok) {
*p_ok = true;
+ }
return p_keys[0].value;
}
@@ -1746,28 +1613,27 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, Interpola
if (loop && p_loop_wrap) {
// loop
if (idx >= 0) {
-
if ((idx + 1) < len) {
-
next = idx + 1;
float delta = p_keys[next].time - p_keys[idx].time;
float from = p_time - p_keys[idx].time;
- if (Math::is_zero_approx(delta))
+ if (Math::is_zero_approx(delta)) {
c = 0;
- else
+ } else {
c = from / delta;
+ }
} else {
-
next = 0;
float delta = (length - p_keys[idx].time) + p_keys[next].time;
float from = p_time - p_keys[idx].time;
- if (Math::is_zero_approx(delta))
+ if (Math::is_zero_approx(delta)) {
c = 0;
- else
+ } else {
c = from / delta;
+ }
}
} else {
@@ -1775,51 +1641,53 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, Interpola
idx = len - 1;
next = 0;
float endtime = (length - p_keys[idx].time);
- if (endtime < 0) // may be keys past the end
+ if (endtime < 0) { // may be keys past the end
endtime = 0;
+ }
float delta = endtime + p_keys[next].time;
float from = endtime + p_time;
- if (Math::is_zero_approx(delta))
+ if (Math::is_zero_approx(delta)) {
c = 0;
- else
+ } else {
c = from / delta;
+ }
}
} else { // no loop
if (idx >= 0) {
-
if ((idx + 1) < len) {
-
next = idx + 1;
float delta = p_keys[next].time - p_keys[idx].time;
float from = p_time - p_keys[idx].time;
- if (Math::is_zero_approx(delta))
+ if (Math::is_zero_approx(delta)) {
c = 0;
- else
+ } else {
c = from / delta;
+ }
} else {
-
next = idx;
}
} else {
-
// only allow extending first key to anim start if looping
- if (loop)
+ if (loop) {
idx = next = 0;
- else
+ } else {
result = false;
+ }
}
}
- if (p_ok)
+ if (p_ok) {
*p_ok = result;
- if (!result)
+ }
+ if (!result) {
return T();
+ }
float tr = p_keys[idx].transition;
@@ -1829,27 +1697,25 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, Interpola
}
if (tr != 1.0) {
-
c = Math::ease(c, tr);
}
switch (p_interp) {
-
case INTERPOLATION_NEAREST: {
-
return p_keys[idx].value;
} break;
case INTERPOLATION_LINEAR: {
-
return _interpolate(p_keys[idx].value, p_keys[next].value, c);
} break;
case INTERPOLATION_CUBIC: {
int pre = idx - 1;
- if (pre < 0)
+ if (pre < 0) {
pre = 0;
+ }
int post = next + 1;
- if (post >= len)
+ if (post >= len) {
post = next;
+ }
return _cubic_interpolate(p_keys[pre].value, p_keys[idx].value, p_keys[next].value, p_keys[post].value, c);
@@ -1862,7 +1728,6 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, Interpola
}
Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3 *r_loc, Quat *r_rot, Vector3 *r_scale) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM, ERR_INVALID_PARAMETER);
@@ -1873,23 +1738,26 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3
TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok);
- if (!ok)
+ if (!ok) {
return ERR_UNAVAILABLE;
+ }
- if (r_loc)
+ if (r_loc) {
*r_loc = tk.loc;
+ }
- if (r_rot)
+ if (r_rot) {
*r_rot = tk.rot;
+ }
- if (r_scale)
+ if (r_scale) {
*r_scale = tk.scale;
+ }
return OK;
}
Variant Animation::value_track_interpolate(int p_track, float p_time) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant());
@@ -1900,7 +1768,6 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
Variant res = _interpolate(vt->values, p_time, (vt->update_mode == UPDATE_CONTINUOUS || vt->update_mode == UPDATE_CAPTURE) ? vt->interpolation : INTERPOLATION_NEAREST, vt->loop_wrap, &ok);
if (ok) {
-
return res;
}
@@ -1908,9 +1775,9 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
}
void Animation::_value_track_get_key_indices_in_range(const ValueTrack *vt, float from_time, float to_time, List<int> *p_indices) const {
-
- if (from_time != length && to_time == length)
+ if (from_time != length && to_time == length) {
to_time = length * 1.001; //include a little more if at the end
+ }
int to = _find(vt->values, to_time);
if (to >= 0 && from_time == to_time && vt->values[to].time == from_time) {
@@ -1921,29 +1788,30 @@ void Animation::_value_track_get_key_indices_in_range(const ValueTrack *vt, floa
// can't really send the events == time, will be sent in the next frame.
// if event>=len then it will probably never be requested by the anim player.
- if (to >= 0 && vt->values[to].time >= to_time)
+ if (to >= 0 && vt->values[to].time >= to_time) {
to--;
+ }
- if (to < 0)
+ if (to < 0) {
return; // not bother
+ }
int from = _find(vt->values, from_time);
// position in the right first event.+
- if (from < 0 || vt->values[from].time < from_time)
+ if (from < 0 || vt->values[from].time < from_time) {
from++;
+ }
int max = vt->values.size();
for (int i = from; i <= to; i++) {
-
ERR_CONTINUE(i < 0 || i >= max); // shouldn't happen
p_indices->push_back(i);
}
}
void Animation::value_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_VALUE);
@@ -1953,11 +1821,11 @@ void Animation::value_track_get_key_indices(int p_track, float p_time, float p_d
float from_time = p_time - p_delta;
float to_time = p_time;
- if (from_time > to_time)
+ if (from_time > to_time) {
SWAP(from_time, to_time);
+ }
if (loop) {
-
from_time = Math::fposmod(from_time, length);
to_time = Math::fposmod(to_time, length);
@@ -1968,23 +1836,25 @@ void Animation::value_track_get_key_indices(int p_track, float p_time, float p_d
return;
}
} else {
-
- if (from_time < 0)
+ if (from_time < 0) {
from_time = 0;
- if (from_time > length)
+ }
+ if (from_time > length) {
from_time = length;
+ }
- if (to_time < 0)
+ if (to_time < 0) {
to_time = 0;
- if (to_time > length)
+ }
+ if (to_time > length) {
to_time = length;
+ }
}
_value_track_get_key_indices_in_range(vt, from_time, to_time, p_indices);
}
void Animation::value_track_set_update_mode(int p_track, UpdateMode p_mode) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_VALUE);
@@ -1995,7 +1865,6 @@ void Animation::value_track_set_update_mode(int p_track, UpdateMode p_mode) {
}
Animation::UpdateMode Animation::value_track_get_update_mode(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), UPDATE_CONTINUOUS);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_VALUE, UPDATE_CONTINUOUS);
@@ -2006,97 +1875,93 @@ Animation::UpdateMode Animation::value_track_get_update_mode(int p_track) const
template <class T>
void Animation::_track_get_key_indices_in_range(const Vector<T> &p_array, float from_time, float to_time, List<int> *p_indices) const {
-
- if (from_time != length && to_time == length)
+ if (from_time != length && to_time == length) {
to_time = length * 1.01; //include a little more if at the end
+ }
int to = _find(p_array, to_time);
// can't really send the events == time, will be sent in the next frame.
// if event>=len then it will probably never be requested by the anim player.
- if (to >= 0 && p_array[to].time >= to_time)
+ if (to >= 0 && p_array[to].time >= to_time) {
to--;
+ }
- if (to < 0)
+ if (to < 0) {
return; // not bother
+ }
int from = _find(p_array, from_time);
// position in the right first event.+
- if (from < 0 || p_array[from].time < from_time)
+ if (from < 0 || p_array[from].time < from_time) {
from++;
+ }
int max = p_array.size();
for (int i = from; i <= to; i++) {
-
ERR_CONTINUE(i < 0 || i >= max); // shouldn't happen
p_indices->push_back(i);
}
}
void Animation::track_get_key_indices_in_range(int p_track, float p_time, float p_delta, List<int> *p_indices) const {
-
ERR_FAIL_INDEX(p_track, tracks.size());
const Track *t = tracks[p_track];
float from_time = p_time - p_delta;
float to_time = p_time;
- if (from_time > to_time)
+ if (from_time > to_time) {
SWAP(from_time, to_time);
+ }
if (loop) {
-
- if (from_time > length || from_time < 0)
+ if (from_time > length || from_time < 0) {
from_time = Math::fposmod(from_time, length);
+ }
- if (to_time > length || to_time < 0)
+ if (to_time > length || to_time < 0) {
to_time = Math::fposmod(to_time, length);
+ }
if (from_time > to_time) {
// handle loop by splitting
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
const TransformTrack *tt = static_cast<const TransformTrack *>(t);
_track_get_key_indices_in_range(tt->transforms, from_time, length, p_indices);
_track_get_key_indices_in_range(tt->transforms, 0, to_time, p_indices);
} break;
case TYPE_VALUE: {
-
const ValueTrack *vt = static_cast<const ValueTrack *>(t);
_track_get_key_indices_in_range(vt->values, from_time, length, p_indices);
_track_get_key_indices_in_range(vt->values, 0, to_time, p_indices);
} break;
case TYPE_METHOD: {
-
const MethodTrack *mt = static_cast<const MethodTrack *>(t);
_track_get_key_indices_in_range(mt->methods, from_time, length, p_indices);
_track_get_key_indices_in_range(mt->methods, 0, to_time, p_indices);
} break;
case TYPE_BEZIER: {
-
const BezierTrack *bz = static_cast<const BezierTrack *>(t);
_track_get_key_indices_in_range(bz->values, from_time, length, p_indices);
_track_get_key_indices_in_range(bz->values, 0, to_time, p_indices);
} break;
case TYPE_AUDIO: {
-
const AudioTrack *ad = static_cast<const AudioTrack *>(t);
_track_get_key_indices_in_range(ad->values, from_time, length, p_indices);
_track_get_key_indices_in_range(ad->values, 0, to_time, p_indices);
} break;
case TYPE_ANIMATION: {
-
const AnimationTrack *an = static_cast<const AnimationTrack *>(t);
_track_get_key_indices_in_range(an->values, from_time, length, p_indices);
_track_get_key_indices_in_range(an->values, 0, to_time, p_indices);
@@ -2106,52 +1971,48 @@ void Animation::track_get_key_indices_in_range(int p_track, float p_time, float
return;
}
} else {
-
- if (from_time < 0)
+ if (from_time < 0) {
from_time = 0;
- if (from_time > length)
+ }
+ if (from_time > length) {
from_time = length;
+ }
- if (to_time < 0)
+ if (to_time < 0) {
to_time = 0;
- if (to_time > length)
+ }
+ if (to_time > length) {
to_time = length;
+ }
}
switch (t->type) {
-
case TYPE_TRANSFORM: {
-
const TransformTrack *tt = static_cast<const TransformTrack *>(t);
_track_get_key_indices_in_range(tt->transforms, from_time, to_time, p_indices);
} break;
case TYPE_VALUE: {
-
const ValueTrack *vt = static_cast<const ValueTrack *>(t);
_track_get_key_indices_in_range(vt->values, from_time, to_time, p_indices);
} break;
case TYPE_METHOD: {
-
const MethodTrack *mt = static_cast<const MethodTrack *>(t);
_track_get_key_indices_in_range(mt->methods, from_time, to_time, p_indices);
} break;
case TYPE_BEZIER: {
-
const BezierTrack *bz = static_cast<const BezierTrack *>(t);
_track_get_key_indices_in_range(bz->values, from_time, to_time, p_indices);
} break;
case TYPE_AUDIO: {
-
const AudioTrack *ad = static_cast<const AudioTrack *>(t);
_track_get_key_indices_in_range(ad->values, from_time, to_time, p_indices);
} break;
case TYPE_ANIMATION: {
-
const AnimationTrack *an = static_cast<const AnimationTrack *>(t);
_track_get_key_indices_in_range(an->values, from_time, to_time, p_indices);
@@ -2160,38 +2021,39 @@ void Animation::track_get_key_indices_in_range(int p_track, float p_time, float
}
void Animation::_method_track_get_key_indices_in_range(const MethodTrack *mt, float from_time, float to_time, List<int> *p_indices) const {
-
- if (from_time != length && to_time == length)
+ if (from_time != length && to_time == length) {
to_time = length * 1.01; //include a little more if at the end
+ }
int to = _find(mt->methods, to_time);
// can't really send the events == time, will be sent in the next frame.
// if event>=len then it will probably never be requested by the anim player.
- if (to >= 0 && mt->methods[to].time >= to_time)
+ if (to >= 0 && mt->methods[to].time >= to_time) {
to--;
+ }
- if (to < 0)
+ if (to < 0) {
return; // not bother
+ }
int from = _find(mt->methods, from_time);
// position in the right first event.+
- if (from < 0 || mt->methods[from].time < from_time)
+ if (from < 0 || mt->methods[from].time < from_time) {
from++;
+ }
int max = mt->methods.size();
for (int i = from; i <= to; i++) {
-
ERR_CONTINUE(i < 0 || i >= max); // shouldn't happen
p_indices->push_back(i);
}
}
void Animation::method_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_METHOD);
@@ -2201,16 +2063,18 @@ void Animation::method_track_get_key_indices(int p_track, float p_time, float p_
float from_time = p_time - p_delta;
float to_time = p_time;
- if (from_time > to_time)
+ if (from_time > to_time) {
SWAP(from_time, to_time);
+ }
if (loop) {
-
- if (from_time > length || from_time < 0)
+ if (from_time > length || from_time < 0) {
from_time = Math::fposmod(from_time, length);
+ }
- if (to_time > length || to_time < 0)
+ if (to_time > length || to_time < 0) {
to_time = Math::fposmod(to_time, length);
+ }
if (from_time > to_time) {
// handle loop by splitting
@@ -2219,22 +2083,25 @@ void Animation::method_track_get_key_indices(int p_track, float p_time, float p_
return;
}
} else {
-
- if (from_time < 0)
+ if (from_time < 0) {
from_time = 0;
- if (from_time > length)
+ }
+ if (from_time > length) {
from_time = length;
+ }
- if (to_time < 0)
+ if (to_time < 0) {
to_time = 0;
- if (to_time > length)
+ }
+ if (to_time > length) {
to_time = length;
+ }
}
_method_track_get_key_indices_in_range(mt, from_time, to_time, p_indices);
}
-Vector<Variant> Animation::method_track_get_params(int p_track, int p_key_idx) const {
+Vector<Variant> Animation::method_track_get_params(int p_track, int p_key_idx) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), Vector<Variant>());
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_METHOD, Vector<Variant>());
@@ -2247,8 +2114,8 @@ Vector<Variant> Animation::method_track_get_params(int p_track, int p_key_idx) c
return mk.params;
}
-StringName Animation::method_track_get_name(int p_track, int p_key_idx) const {
+StringName Animation::method_track_get_name(int p_track, int p_key_idx) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), StringName());
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_METHOD, StringName());
@@ -2261,7 +2128,6 @@ StringName Animation::method_track_get_name(int p_track, int p_key_idx) const {
}
int Animation::bezier_track_insert_key(int p_track, float p_time, float p_value, const Vector2 &p_in_handle, const Vector2 &p_out_handle) {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_BEZIER, -1);
@@ -2288,7 +2154,6 @@ int Animation::bezier_track_insert_key(int p_track, float p_time, float p_value,
}
void Animation::bezier_track_set_key_value(int p_track, int p_index, float p_value) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_BEZIER);
@@ -2302,7 +2167,6 @@ void Animation::bezier_track_set_key_value(int p_track, int p_index, float p_val
}
void Animation::bezier_track_set_key_in_handle(int p_track, int p_index, const Vector2 &p_handle) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_BEZIER);
@@ -2317,8 +2181,8 @@ void Animation::bezier_track_set_key_in_handle(int p_track, int p_index, const V
}
emit_changed();
}
-void Animation::bezier_track_set_key_out_handle(int p_track, int p_index, const Vector2 &p_handle) {
+void Animation::bezier_track_set_key_out_handle(int p_track, int p_index, const Vector2 &p_handle) {
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_BEZIER);
@@ -2333,8 +2197,8 @@ void Animation::bezier_track_set_key_out_handle(int p_track, int p_index, const
}
emit_changed();
}
-float Animation::bezier_track_get_key_value(int p_track, int p_index) const {
+float Animation::bezier_track_get_key_value(int p_track, int p_index) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_BEZIER, 0);
@@ -2345,8 +2209,8 @@ float Animation::bezier_track_get_key_value(int p_track, int p_index) const {
return bt->values[p_index].value.value;
}
-Vector2 Animation::bezier_track_get_key_in_handle(int p_track, int p_index) const {
+Vector2 Animation::bezier_track_get_key_in_handle(int p_track, int p_index) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), Vector2());
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_BEZIER, Vector2());
@@ -2357,8 +2221,8 @@ Vector2 Animation::bezier_track_get_key_in_handle(int p_track, int p_index) cons
return bt->values[p_index].value.in_handle;
}
-Vector2 Animation::bezier_track_get_key_out_handle(int p_track, int p_index) const {
+Vector2 Animation::bezier_track_get_key_out_handle(int p_track, int p_index) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), Vector2());
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_BEZIER, Vector2());
@@ -2428,7 +2292,6 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
//narrow high and low as much as possible
for (int i = 0; i < iterations; i++) {
-
middle = (low + high) / 2;
Vector2 interp = _bezier_interp(middle, start, start_out, end_in, end);
@@ -2449,7 +2312,6 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
}
int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_stream, float p_start_offset, float p_end_offset) {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_AUDIO, -1);
@@ -2460,11 +2322,13 @@ int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_st
k.time = p_time;
k.value.stream = p_stream;
k.value.start_offset = p_start_offset;
- if (k.value.start_offset < 0)
+ if (k.value.start_offset < 0) {
k.value.start_offset = 0;
+ }
k.value.end_offset = p_end_offset;
- if (k.value.end_offset < 0)
+ if (k.value.end_offset < 0) {
k.value.end_offset = 0;
+ }
int key = _insert(p_time, at->values, k);
@@ -2474,7 +2338,6 @@ int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_st
}
void Animation::audio_track_set_key_stream(int p_track, int p_key, const RES &p_stream) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_AUDIO);
@@ -2489,7 +2352,6 @@ void Animation::audio_track_set_key_stream(int p_track, int p_key, const RES &p_
}
void Animation::audio_track_set_key_start_offset(int p_track, int p_key, float p_offset) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_AUDIO);
@@ -2498,8 +2360,9 @@ void Animation::audio_track_set_key_start_offset(int p_track, int p_key, float p
ERR_FAIL_INDEX(p_key, at->values.size());
- if (p_offset < 0)
+ if (p_offset < 0) {
p_offset = 0;
+ }
at->values.write[p_key].value.start_offset = p_offset;
@@ -2507,7 +2370,6 @@ void Animation::audio_track_set_key_start_offset(int p_track, int p_key, float p
}
void Animation::audio_track_set_key_end_offset(int p_track, int p_key, float p_offset) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_AUDIO);
@@ -2516,8 +2378,9 @@ void Animation::audio_track_set_key_end_offset(int p_track, int p_key, float p_o
ERR_FAIL_INDEX(p_key, at->values.size());
- if (p_offset < 0)
+ if (p_offset < 0) {
p_offset = 0;
+ }
at->values.write[p_key].value.end_offset = p_offset;
@@ -2525,7 +2388,6 @@ void Animation::audio_track_set_key_end_offset(int p_track, int p_key, float p_o
}
RES Animation::audio_track_get_key_stream(int p_track, int p_key) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), RES());
const Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_AUDIO, RES());
@@ -2536,8 +2398,8 @@ RES Animation::audio_track_get_key_stream(int p_track, int p_key) const {
return at->values[p_key].value.stream;
}
-float Animation::audio_track_get_key_start_offset(int p_track, int p_key) const {
+float Animation::audio_track_get_key_start_offset(int p_track, int p_key) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
const Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_AUDIO, 0);
@@ -2548,8 +2410,8 @@ float Animation::audio_track_get_key_start_offset(int p_track, int p_key) const
return at->values[p_key].value.start_offset;
}
-float Animation::audio_track_get_key_end_offset(int p_track, int p_key) const {
+float Animation::audio_track_get_key_end_offset(int p_track, int p_key) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
const Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_AUDIO, 0);
@@ -2564,7 +2426,6 @@ float Animation::audio_track_get_key_end_offset(int p_track, int p_key) const {
//
int Animation::animation_track_insert_key(int p_track, float p_time, const StringName &p_animation) {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_ANIMATION, -1);
@@ -2583,7 +2444,6 @@ int Animation::animation_track_insert_key(int p_track, float p_time, const Strin
}
void Animation::animation_track_set_key_animation(int p_track, int p_key, const StringName &p_animation) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_ANIMATION);
@@ -2598,7 +2458,6 @@ void Animation::animation_track_set_key_animation(int p_track, int p_key, const
}
StringName Animation::animation_track_get_key_animation(int p_track, int p_key) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), StringName());
const Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_ANIMATION, StringName());
@@ -2611,57 +2470,49 @@ StringName Animation::animation_track_get_key_animation(int p_track, int p_key)
}
void Animation::set_length(float p_length) {
-
if (p_length < ANIM_MIN_LENGTH) {
p_length = ANIM_MIN_LENGTH;
}
length = p_length;
emit_changed();
}
-float Animation::get_length() const {
+float Animation::get_length() const {
return length;
}
void Animation::set_loop(bool p_enabled) {
-
loop = p_enabled;
emit_changed();
}
-bool Animation::has_loop() const {
+bool Animation::has_loop() const {
return loop;
}
void Animation::track_set_imported(int p_track, bool p_imported) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
tracks[p_track]->imported = p_imported;
}
bool Animation::track_is_imported(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), false);
return tracks[p_track]->imported;
}
void Animation::track_set_enabled(int p_track, bool p_enabled) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
tracks[p_track]->enabled = p_enabled;
emit_changed();
}
bool Animation::track_is_enabled(int p_track) const {
-
ERR_FAIL_INDEX_V(p_track, tracks.size(), false);
return tracks[p_track]->enabled;
}
void Animation::track_move_up(int p_track) {
-
if (p_track >= 0 && p_track < (tracks.size() - 1)) {
-
SWAP(tracks.write[p_track], tracks.write[p_track + 1]);
}
@@ -2670,9 +2521,7 @@ void Animation::track_move_up(int p_track) {
}
void Animation::track_move_down(int p_track) {
-
if (p_track > 0 && p_track < tracks.size()) {
-
SWAP(tracks.write[p_track], tracks.write[p_track - 1]);
}
@@ -2681,11 +2530,11 @@ void Animation::track_move_down(int p_track) {
}
void Animation::track_move_to(int p_track, int p_to_index) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
ERR_FAIL_INDEX(p_to_index, tracks.size() + 1);
- if (p_track == p_to_index || p_track == p_to_index - 1)
+ if (p_track == p_to_index || p_track == p_to_index - 1) {
return;
+ }
Track *track = tracks.get(p_track);
tracks.remove(p_track);
@@ -2697,11 +2546,11 @@ void Animation::track_move_to(int p_track, int p_to_index) {
}
void Animation::track_swap(int p_track, int p_with_track) {
-
ERR_FAIL_INDEX(p_track, tracks.size());
ERR_FAIL_INDEX(p_with_track, tracks.size());
- if (p_track == p_with_track)
+ if (p_track == p_with_track) {
return;
+ }
SWAP(tracks.write[p_track], tracks.write[p_with_track]);
emit_changed();
@@ -2709,13 +2558,11 @@ void Animation::track_swap(int p_track, int p_with_track) {
}
void Animation::set_step(float p_step) {
-
step = p_step;
emit_changed();
}
float Animation::get_step() const {
-
return step;
}
@@ -2737,7 +2584,6 @@ void Animation::copy_track(int p_track, Ref<Animation> p_to_animation) {
}
void Animation::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_track", "type", "at_position"), &Animation::add_track, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("remove_track", "track_idx"), &Animation::remove_track);
ClassDB::bind_method(D_METHOD("get_track_count"), &Animation::get_track_count);
@@ -2847,9 +2693,9 @@ void Animation::_bind_methods() {
}
void Animation::clear() {
-
- for (int i = 0; i < tracks.size(); i++)
+ for (int i = 0; i < tracks.size(); i++) {
memdelete(tracks[i]);
+ }
tracks.clear();
loop = false;
length = 1;
@@ -2858,7 +2704,6 @@ void Animation::clear() {
}
bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err, float p_alowed_angular_err, float p_max_optimizable_angle, const Vector3 &p_norm) {
-
real_t c = (t1.time - t0.time) / (t2.time - t0.time);
real_t t[3] = { -1, -1, -1 };
@@ -2876,7 +2721,6 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
} else {
-
Vector3 pd = (v2 - v0);
float d0 = pd.dot(v0);
float d1 = pd.dot(v1);
@@ -2886,14 +2730,15 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
Vector3 s[2] = { v0, v2 };
- real_t d = Geometry::get_closest_point_to_segment(v1, s).distance_to(v1);
+ real_t d = Geometry3D::get_closest_point_to_segment(v1, s).distance_to(v1);
if (d > pd.length() * p_alowed_linear_err) {
return false; //beyond allowed error for colinearity
}
- if (p_norm != Vector3() && Math::acos(pd.normalized().dot(p_norm)) > p_alowed_angular_err)
+ if (p_norm != Vector3() && Math::acos(pd.normalized().dot(p_norm)) > p_alowed_angular_err) {
return false;
+ }
t[0] = (d1 - d0) / (d2 - d0);
}
@@ -2908,12 +2753,11 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
//localize both to rotation from q0
if (q0.is_equal_approx(q2)) {
-
- if (!q0.is_equal_approx(q1))
+ if (!q0.is_equal_approx(q1)) {
return false;
+ }
} else {
-
Quat r02 = (q0.inverse() * q2).normalized();
Quat r01 = (q0.inverse() * q1).normalized();
@@ -2923,8 +2767,9 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
r02.get_axis_angle(v02, a02);
r01.get_axis_angle(v01, a01);
- if (Math::abs(a02) > p_max_optimizable_angle)
+ if (Math::abs(a02) > p_max_optimizable_angle) {
return false;
+ }
if (v01.dot(v02) < 0) {
//make sure both rotations go the same way to compare
@@ -2944,8 +2789,9 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
real_t tr = a01 / a02;
- if (tr < 0 || tr > 1)
+ if (tr < 0 || tr > 1) {
return false; //rotating too much or too less
+ }
t[1] = tr;
}
@@ -2965,7 +2811,6 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
} else {
-
Vector3 pd = (v2 - v0);
float d0 = pd.dot(v0);
float d1 = pd.dot(v1);
@@ -2975,7 +2820,7 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
Vector3 s[2] = { v0, v2 };
- real_t d = Geometry::get_closest_point_to_segment(v1, s).distance_to(v1);
+ real_t d = Geometry3D::get_closest_point_to_segment(v1, s).distance_to(v1);
if (d > pd.length() * p_alowed_linear_err) {
return false; //beyond allowed error for colinearity
@@ -2987,10 +2832,8 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
bool erase = false;
if (t[0] == -1 && t[1] == -1 && t[2] == -1) {
-
erase = true;
} else {
-
erase = true;
real_t lt = -1;
for (int j = 0; j < 3; j++) {
@@ -2999,8 +2842,9 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
lt = t[j]; //official t
//validate rest
for (int k = j + 1; k < 3; k++) {
- if (t[k] == -1)
+ if (t[k] == -1) {
continue;
+ }
if (Math::abs(lt - t[k]) > p_alowed_linear_err) {
erase = false;
@@ -3014,7 +2858,6 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
ERR_FAIL_COND_V(lt == -1, false);
if (erase) {
-
if (Math::abs(lt - c) > p_alowed_linear_err) {
//todo, evaluate changing the transition if this fails?
//this could be done as a second pass and would be
@@ -3028,7 +2871,6 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
}
void Animation::_transform_track_optimize(int p_idx, float p_allowed_linear_err, float p_allowed_angular_err, float p_max_optimizable_angle) {
-
ERR_FAIL_INDEX(p_idx, tracks.size());
ERR_FAIL_COND(tracks[p_idx]->type != TYPE_TRANSFORM);
TransformTrack *tt = static_cast<TransformTrack *>(tracks[p_idx]);
@@ -3038,7 +2880,6 @@ void Animation::_transform_track_optimize(int p_idx, float p_allowed_linear_err,
Vector3 norm;
for (int i = 1; i < tt->transforms.size() - 1; i++) {
-
TKey<TransformKey> &t0 = tt->transforms.write[i - 1];
TKey<TransformKey> &t1 = tt->transforms.write[i];
TKey<TransformKey> &t2 = tt->transforms.write[i + 1];
@@ -3054,7 +2895,6 @@ void Animation::_transform_track_optimize(int p_idx, float p_allowed_linear_err,
}
if (erase) {
-
if (!prev_erased) {
first_erased = t1;
prev_erased = true;
@@ -3071,23 +2911,21 @@ void Animation::_transform_track_optimize(int p_idx, float p_allowed_linear_err,
}
void Animation::optimize(float p_allowed_linear_err, float p_allowed_angular_err, float p_max_optimizable_angle) {
-
for (int i = 0; i < tracks.size(); i++) {
-
- if (tracks[i]->type == TYPE_TRANSFORM)
+ if (tracks[i]->type == TYPE_TRANSFORM) {
_transform_track_optimize(i, p_allowed_linear_err, p_allowed_angular_err, p_max_optimizable_angle);
+ }
}
}
Animation::Animation() {
-
step = 0.1;
loop = false;
length = 1;
}
Animation::~Animation() {
-
- for (int i = 0; i < tracks.size(); i++)
+ for (int i = 0; i < tracks.size(); i++) {
memdelete(tracks[i]);
+ }
}
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index e4e5177a8c..722a400fd6 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -34,7 +34,6 @@
#include "core/resource.h"
class Animation : public Resource {
-
GDCLASS(Animation, Resource);
RES_BASE_EXTENSION("anim");
@@ -64,7 +63,6 @@ public:
private:
struct Track {
-
TrackType type;
InterpolationType interpolation;
bool loop_wrap;
@@ -81,7 +79,6 @@ private:
};
struct Key {
-
float transition;
float time; // time in secs
Key() {
@@ -93,12 +90,10 @@ private:
// transform key holds either Vector3 or Quaternion
template <class T>
struct TKey : public Key {
-
T value;
};
struct TransformKey {
-
Vector3 loc;
Quat rot;
Vector3 scale;
@@ -107,7 +102,6 @@ private:
/* TRANSFORM TRACK */
struct TransformTrack : public Track {
-
Vector<TKey<TransformKey>> transforms;
TransformTrack() { type = TYPE_TRANSFORM; }
@@ -116,7 +110,6 @@ private:
/* PROPERTY VALUE TRACK */
struct ValueTrack : public Track {
-
UpdateMode update_mode;
bool update_on_seek;
Vector<TKey<Variant>> values;
@@ -130,13 +123,11 @@ private:
/* METHOD TRACK */
struct MethodKey : public Key {
-
StringName method;
Vector<Variant> params;
};
struct MethodTrack : public Track {
-
Vector<MethodKey> methods;
MethodTrack() { type = TYPE_METHOD; }
};
@@ -150,7 +141,6 @@ private:
};
struct BezierTrack : public Track {
-
Vector<TKey<BezierKey>> values;
BezierTrack() {
@@ -171,7 +161,6 @@ private:
};
struct AudioTrack : public Track {
-
Vector<TKey<AudioKey>> values;
AudioTrack() {
@@ -182,7 +171,6 @@ private:
/* AUDIO TRACK */
struct AnimationTrack : public Track {
-
Vector<TKey<StringName>> values;
AnimationTrack() {
@@ -246,25 +234,21 @@ private:
}
Vector<int> _value_track_get_key_indices(int p_track, float p_time, float p_delta) const {
-
List<int> idxs;
value_track_get_key_indices(p_track, p_time, p_delta, &idxs);
Vector<int> idxr;
for (List<int>::Element *E = idxs.front(); E; E = E->next()) {
-
idxr.push_back(E->get());
}
return idxr;
}
Vector<int> _method_track_get_key_indices(int p_track, float p_time, float p_delta) const {
-
List<int> idxs;
method_track_get_key_indices(p_track, p_time, p_delta, &idxs);
Vector<int> idxr;
for (List<int>::Element *E = idxs.front(); E; E = E->next()) {
-
idxr.push_back(E->get());
}
return idxr;
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index fdf5e2c2d0..f02e7987a9 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -34,7 +34,6 @@
#include "core/os/file_access.h"
void AudioStreamPlaybackSample::start(float p_from_pos) {
-
if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) {
//no seeking in IMA_ADPCM
for (int i = 0; i < 2; i++) {
@@ -57,28 +56,25 @@ void AudioStreamPlaybackSample::start(float p_from_pos) {
}
void AudioStreamPlaybackSample::stop() {
-
active = false;
}
bool AudioStreamPlaybackSample::is_playing() const {
-
return active;
}
int AudioStreamPlaybackSample::get_loop_count() const {
-
return 0;
}
float AudioStreamPlaybackSample::get_playback_position() const {
-
return float(offset >> MIX_FRAC_BITS) / base->mix_rate;
}
-void AudioStreamPlaybackSample::seek(float p_time) {
- if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM)
+void AudioStreamPlaybackSample::seek(float p_time) {
+ if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) {
return; //no seeking in ima-adpcm
+ }
float max = base->get_length();
if (p_time < 0) {
@@ -92,22 +88,20 @@ void AudioStreamPlaybackSample::seek(float p_time) {
template <class Depth, bool is_stereo, bool is_ima_adpcm>
void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm) {
-
// this function will be compiled branchless by any decent compiler
int32_t final, final_r, next, next_r;
while (amount) {
amount--;
int64_t pos = offset >> MIX_FRAC_BITS;
- if (is_stereo && !is_ima_adpcm)
+ if (is_stereo && !is_ima_adpcm) {
pos <<= 1;
+ }
if (is_ima_adpcm) {
-
int64_t sample_pos = pos + ima_adpcm[0].window_ofs;
while (sample_pos > ima_adpcm[0].last_nibble) {
-
static const int16_t _ima_adpcm_step_table[89] = {
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
@@ -126,7 +120,6 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
};
for (int i = 0; i < (is_stereo ? 2 : 1); i++) {
-
int16_t nibble, diff, step;
ima_adpcm[i].last_nibble++;
@@ -138,30 +131,36 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
step = _ima_adpcm_step_table[ima_adpcm[i].step_index];
ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble];
- if (ima_adpcm[i].step_index < 0)
+ if (ima_adpcm[i].step_index < 0) {
ima_adpcm[i].step_index = 0;
- if (ima_adpcm[i].step_index > 88)
+ }
+ if (ima_adpcm[i].step_index > 88) {
ima_adpcm[i].step_index = 88;
+ }
diff = step >> 3;
- if (nibble & 1)
+ if (nibble & 1) {
diff += step >> 2;
- if (nibble & 2)
+ }
+ if (nibble & 2) {
diff += step >> 1;
- if (nibble & 4)
+ }
+ if (nibble & 4) {
diff += step;
- if (nibble & 8)
+ }
+ if (nibble & 8) {
diff = -diff;
+ }
ima_adpcm[i].predictor += diff;
- if (ima_adpcm[i].predictor < -0x8000)
+ if (ima_adpcm[i].predictor < -0x8000) {
ima_adpcm[i].predictor = -0x8000;
- else if (ima_adpcm[i].predictor > 0x7FFF)
+ } else if (ima_adpcm[i].predictor > 0x7FFF) {
ima_adpcm[i].predictor = 0x7FFF;
+ }
/* store loop if there */
if (ima_adpcm[i].last_nibble == ima_adpcm[i].loop_pos) {
-
ima_adpcm[i].loop_step_index = ima_adpcm[i].step_index;
ima_adpcm[i].loop_predictor = ima_adpcm[i].predictor;
}
@@ -177,17 +176,18 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
} else {
final = p_src[pos];
- if (is_stereo)
+ if (is_stereo) {
final_r = p_src[pos + 1];
+ }
if (sizeof(Depth) == 1) { /* conditions will not exist anymore when compiled! */
final <<= 8;
- if (is_stereo)
+ if (is_stereo) {
final_r <<= 8;
+ }
}
if (is_stereo) {
-
next = p_src[pos + 2];
next_r = p_src[pos + 3];
} else {
@@ -196,15 +196,17 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
if (sizeof(Depth) == 1) {
next <<= 8;
- if (is_stereo)
+ if (is_stereo) {
next_r <<= 8;
+ }
}
int32_t frac = int64_t(offset & MIX_FRAC_MASK);
final = final + ((next - final) * frac >> MIX_FRAC_BITS);
- if (is_stereo)
+ if (is_stereo) {
final_r = final_r + ((next_r - final_r) * frac >> MIX_FRAC_BITS);
+ }
}
if (!is_stereo) {
@@ -220,7 +222,6 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
}
void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
-
if (!base->data || !active) {
for (int i = 0; i < p_frames; i++) {
p_buffer[i] = AudioFrame(0, 0);
@@ -279,7 +280,6 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
AudioFrame *dst_buff = p_buffer;
if (format == AudioStreamSample::FORMAT_IMA_ADPCM) {
-
if (loop_format != AudioStreamSample::LOOP_DISABLED) {
ima_adpcm[0].loop_pos = loop_begin_fp >> MIX_FRAC_BITS;
ima_adpcm[1].loop_pos = loop_begin_fp >> MIX_FRAC_BITS;
@@ -288,7 +288,6 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
}
while (todo > 0) {
-
int64_t limit = 0;
int32_t target = 0, aux = 0;
@@ -311,7 +310,6 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
} else {
/* check for sample not reaching beginning */
if (offset < 0) {
-
active = false;
break;
}
@@ -343,7 +341,6 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
} else {
/* no loop, check for end of sample */
if (offset >= length_fp) {
-
active = false;
break;
}
@@ -369,24 +366,26 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
switch (base->format) {
case AudioStreamSample::FORMAT_8_BITS: {
-
- if (is_stereo)
+ if (is_stereo) {
do_resample<int8_t, true, false>((int8_t *)data, dst_buff, offset, increment, target, ima_adpcm);
- else
+ } else {
do_resample<int8_t, false, false>((int8_t *)data, dst_buff, offset, increment, target, ima_adpcm);
+ }
} break;
case AudioStreamSample::FORMAT_16_BITS: {
- if (is_stereo)
+ if (is_stereo) {
do_resample<int16_t, true, false>((int16_t *)data, dst_buff, offset, increment, target, ima_adpcm);
- else
+ } else {
do_resample<int16_t, false, false>((int16_t *)data, dst_buff, offset, increment, target, ima_adpcm);
+ }
} break;
case AudioStreamSample::FORMAT_IMA_ADPCM: {
- if (is_stereo)
+ if (is_stereo) {
do_resample<int8_t, true, true>((int8_t *)data, dst_buff, offset, increment, target, ima_adpcm);
- else
+ } else {
do_resample<int8_t, false, true>((int8_t *)data, dst_buff, offset, increment, target, ima_adpcm);
+ }
} break;
}
@@ -404,7 +403,6 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in
}
AudioStreamPlaybackSample::AudioStreamPlaybackSample() {
-
active = false;
offset = 0;
sign = 1;
@@ -413,62 +411,55 @@ AudioStreamPlaybackSample::AudioStreamPlaybackSample() {
/////////////////////
void AudioStreamSample::set_format(Format p_format) {
-
format = p_format;
}
AudioStreamSample::Format AudioStreamSample::get_format() const {
-
return format;
}
void AudioStreamSample::set_loop_mode(LoopMode p_loop_mode) {
-
loop_mode = p_loop_mode;
}
-AudioStreamSample::LoopMode AudioStreamSample::get_loop_mode() const {
+AudioStreamSample::LoopMode AudioStreamSample::get_loop_mode() const {
return loop_mode;
}
void AudioStreamSample::set_loop_begin(int p_frame) {
-
loop_begin = p_frame;
}
-int AudioStreamSample::get_loop_begin() const {
+int AudioStreamSample::get_loop_begin() const {
return loop_begin;
}
void AudioStreamSample::set_loop_end(int p_frame) {
-
loop_end = p_frame;
}
-int AudioStreamSample::get_loop_end() const {
+int AudioStreamSample::get_loop_end() const {
return loop_end;
}
void AudioStreamSample::set_mix_rate(int p_hz) {
-
ERR_FAIL_COND(p_hz == 0);
mix_rate = p_hz;
}
-int AudioStreamSample::get_mix_rate() const {
+int AudioStreamSample::get_mix_rate() const {
return mix_rate;
}
-void AudioStreamSample::set_stereo(bool p_enable) {
+void AudioStreamSample::set_stereo(bool p_enable) {
stereo = p_enable;
}
-bool AudioStreamSample::is_stereo() const {
+bool AudioStreamSample::is_stereo() const {
return stereo;
}
float AudioStreamSample::get_length() const {
-
int len = data_bytes;
switch (format) {
case AudioStreamSample::FORMAT_8_BITS:
@@ -490,7 +481,6 @@ float AudioStreamSample::get_length() const {
}
void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) {
-
AudioServer::get_singleton()->lock();
if (data) {
memfree(data);
@@ -500,7 +490,6 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) {
int datalen = p_data.size();
if (datalen) {
-
const uint8_t *r = p_data.ptr();
int alloc_len = datalen + DATA_PAD * 2;
data = memalloc(alloc_len); //alloc with some padding for interpolation
@@ -512,14 +501,13 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) {
AudioServer::get_singleton()->unlock();
}
-Vector<uint8_t> AudioStreamSample::get_data() const {
+Vector<uint8_t> AudioStreamSample::get_data() const {
Vector<uint8_t> pv;
if (data) {
pv.resize(data_bytes);
{
-
uint8_t *w = pv.ptrw();
uint8_t *dataptr = (uint8_t *)data;
copymem(w, dataptr + DATA_PAD, data_bytes);
@@ -610,7 +598,6 @@ Error AudioStreamSample::save_to_wav(const String &p_path) {
}
Ref<AudioStreamPlayback> AudioStreamSample::instance_playback() {
-
Ref<AudioStreamPlaybackSample> sample;
sample.instance();
sample->base = Ref<AudioStreamSample>(this);
@@ -618,12 +605,10 @@ Ref<AudioStreamPlayback> AudioStreamSample::instance_playback() {
}
String AudioStreamSample::get_stream_name() const {
-
return "";
}
void AudioStreamSample::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamSample::set_data);
ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamSample::get_data);
diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h
index 0b46bc1c75..2bd358117c 100644
--- a/scene/resources/audio_stream_sample.h
+++ b/scene/resources/audio_stream_sample.h
@@ -36,7 +36,6 @@
class AudioStreamSample;
class AudioStreamPlaybackSample : public AudioStreamPlayback {
-
GDCLASS(AudioStreamPlaybackSample, AudioStreamPlayback);
enum {
MIX_FRAC_BITS = 13,
@@ -45,7 +44,6 @@ class AudioStreamPlaybackSample : public AudioStreamPlayback {
};
struct IMA_ADPCM_State {
-
int16_t step_index;
int32_t predictor;
/* values at loop point */
diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp
index d45f36dfd1..10f0de8ff8 100644
--- a/scene/resources/bit_map.cpp
+++ b/scene/resources/bit_map.cpp
@@ -33,7 +33,6 @@
#include "core/io/image_loader.h"
void BitMap::create(const Size2 &p_size) {
-
ERR_FAIL_COND(p_size.width < 1);
ERR_FAIL_COND(p_size.height < 1);
@@ -44,7 +43,6 @@ void BitMap::create(const Size2 &p_size) {
}
void BitMap::create_from_image_alpha(const Ref<Image> &p_image, float p_threshold) {
-
ERR_FAIL_COND(p_image.is_null() || p_image->empty());
Ref<Image> img = p_image->duplicate();
img->convert(Image::FORMAT_LA8);
@@ -56,7 +54,6 @@ void BitMap::create_from_image_alpha(const Ref<Image> &p_image, float p_threshol
uint8_t *w = bitmask.ptrw();
for (int i = 0; i < width * height; i++) {
-
int bbyte = i / 8;
int bbit = i % 8;
if (r[i * 2 + 1] / 255.0 > p_threshold) {
@@ -66,24 +63,22 @@ void BitMap::create_from_image_alpha(const Ref<Image> &p_image, float p_threshol
}
void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) {
-
Rect2i current = Rect2i(0, 0, width, height).clip(p_rect);
uint8_t *data = bitmask.ptrw();
for (int i = current.position.x; i < current.position.x + current.size.x; i++) {
-
for (int j = current.position.y; j < current.position.y + current.size.y; j++) {
-
int ofs = width * j + i;
int bbyte = ofs / 8;
int bbit = ofs % 8;
uint8_t b = data[bbyte];
- if (p_value)
+ if (p_value) {
b |= (1 << bbit);
- else
+ } else {
b &= ~(1 << bbit);
+ }
data[bbyte] = b;
}
@@ -91,7 +86,6 @@ void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) {
}
int BitMap::get_true_bit_count() const {
-
int ds = bitmask.size();
const uint8_t *d = bitmask.ptr();
int c = 0;
@@ -99,7 +93,6 @@ int BitMap::get_true_bit_count() const {
//fast, almost branchless version
for (int i = 0; i < ds; i++) {
-
c += (d[i] & (1 << 7)) >> 7;
c += (d[i] & (1 << 6)) >> 6;
c += (d[i] & (1 << 5)) >> 5;
@@ -114,7 +107,6 @@ int BitMap::get_true_bit_count() const {
}
void BitMap::set_bit(const Point2 &p_pos, bool p_value) {
-
int x = p_pos.x;
int y = p_pos.y;
@@ -127,16 +119,16 @@ void BitMap::set_bit(const Point2 &p_pos, bool p_value) {
uint8_t b = bitmask[bbyte];
- if (p_value)
+ if (p_value) {
b |= (1 << bbit);
- else
+ } else {
b &= ~(1 << bbit);
+ }
bitmask.write[bbyte] = b;
}
bool BitMap::get_bit(const Point2 &p_pos) const {
-
int x = Math::fast_ftoi(p_pos.x);
int y = Math::fast_ftoi(p_pos.y);
ERR_FAIL_INDEX_V(x, width, false);
@@ -150,12 +142,10 @@ bool BitMap::get_bit(const Point2 &p_pos) const {
}
Size2 BitMap::get_size() const {
-
return Size2(width, height);
}
void BitMap::_set_data(const Dictionary &p_d) {
-
ERR_FAIL_COND(!p_d.has("size"));
ERR_FAIL_COND(!p_d.has("data"));
@@ -164,7 +154,6 @@ void BitMap::_set_data(const Dictionary &p_d) {
}
Dictionary BitMap::_get_data() const {
-
Dictionary d;
d["size"] = get_size();
d["data"] = bitmask;
@@ -172,7 +161,6 @@ Dictionary BitMap::_get_data() const {
}
Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start) const {
-
int stepx = 0;
int stepy = 0;
int prevx = 0;
@@ -209,7 +197,6 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
}
switch (sv) {
-
case 1:
case 5:
case 13:
@@ -354,8 +341,9 @@ static float perpendicular_distance(const Vector2 &i, const Vector2 &start, cons
}
static Vector<Vector2> rdp(const Vector<Vector2> &v, float optimization) {
- if (v.size() < 3)
+ if (v.size() < 3) {
return v;
+ }
int index = -1;
float dist = 0;
@@ -368,7 +356,6 @@ static Vector<Vector2> rdp(const Vector<Vector2> &v, float optimization) {
}
}
if (dist > optimization) {
-
Vector<Vector2> left, right;
left.resize(index);
for (int i = 0; i < index; i++) {
@@ -424,7 +411,6 @@ struct FillBitsStackEntry {
};
static void fill_bits(const BitMap *p_src, Ref<BitMap> &p_map, const Point2i &p_pos, const Rect2i &rect) {
-
// Using a custom stack to work iteratively to avoid stack overflow on big bitmaps
Vector<FillBitsStackEntry> stack;
// Tracking size since we won't be shrinking the stack vector
@@ -453,15 +439,17 @@ static void fill_bits(const BitMap *p_src, Ref<BitMap> &p_map, const Point2i &p_
continue;
}
- if (i < rect.position.x || i >= rect.position.x + rect.size.x)
+ if (i < rect.position.x || i >= rect.position.x + rect.size.x) {
continue;
- if (j < rect.position.y || j >= rect.position.y + rect.size.y)
+ }
+ if (j < rect.position.y || j >= rect.position.y + rect.size.y) {
continue;
+ }
- if (p_map->get_bit(Vector2(i, j)))
+ if (p_map->get_bit(Vector2(i, j))) {
continue;
- else if (p_src->get_bit(Vector2(i, j))) {
+ } else if (p_src->get_bit(Vector2(i, j))) {
p_map->set_bit(Vector2(i, j), true);
FillBitsStackEntry se = { pos, i, j };
@@ -494,7 +482,6 @@ static void fill_bits(const BitMap *p_src, Ref<BitMap> &p_map, const Point2i &p_
}
Vector<Vector<Vector2>> BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon) const {
-
Rect2i r = Rect2i(0, 0, width, height).clip(p_rect);
print_verbose("BitMap: Rect: " + r);
@@ -507,7 +494,6 @@ Vector<Vector<Vector2>> BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, flo
for (int i = r.position.y; i < r.position.y + r.size.height; i++) {
for (int j = r.position.x; j < r.position.x + r.size.width; j++) {
if (!fill->get_bit(Point2(j, i)) && get_bit(Point2(j, i))) {
-
fill_bits(this, fill, Point2i(j, i), r);
Vector<Vector2> polygon = _march_square(r, Point2i(j, i));
@@ -529,7 +515,6 @@ Vector<Vector<Vector2>> BitMap::clip_opaque_to_polygons(const Rect2 &p_rect, flo
}
void BitMap::grow_mask(int p_pixels, const Rect2 &p_rect) {
-
if (p_pixels == 0) {
return;
}
@@ -546,35 +531,38 @@ void BitMap::grow_mask(int p_pixels, const Rect2 &p_rect) {
for (int i = r.position.y; i < r.position.y + r.size.height; i++) {
for (int j = r.position.x; j < r.position.x + r.size.width; j++) {
- if (bit_value == get_bit(Point2(j, i)))
+ if (bit_value == get_bit(Point2(j, i))) {
continue;
+ }
bool found = false;
for (int y = i - p_pixels; y <= i + p_pixels; y++) {
for (int x = j - p_pixels; x <= j + p_pixels; x++) {
-
bool outside = false;
if ((x < p_rect.position.x) || (x >= p_rect.position.x + p_rect.size.x) || (y < p_rect.position.y) || (y >= p_rect.position.y + p_rect.size.y)) {
// outside of rectangle counts as bit not set
- if (!bit_value)
+ if (!bit_value) {
outside = true;
- else
+ } else {
continue;
+ }
}
float d = Point2(j, i).distance_to(Point2(x, y)) - CMP_EPSILON;
- if (d > p_pixels)
+ if (d > p_pixels) {
continue;
+ }
if (outside || (bit_value == copy->get_bit(Point2(x, y)))) {
found = true;
break;
}
}
- if (found)
+ if (found) {
break;
+ }
}
if (found) {
@@ -585,12 +573,10 @@ void BitMap::grow_mask(int p_pixels, const Rect2 &p_rect) {
}
void BitMap::shrink_mask(int p_pixels, const Rect2 &p_rect) {
-
grow_mask(-p_pixels, p_rect);
}
Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) const {
-
Vector<Vector<Vector2>> result = clip_opaque_to_polygons(p_rect, p_epsilon);
// Convert result to bindable types
@@ -598,7 +584,6 @@ Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) con
Array result_array;
result_array.resize(result.size());
for (int i = 0; i < result.size(); i++) {
-
const Vector<Vector2> &polygon = result[i];
PackedVector2Array polygon_array;
@@ -618,7 +603,6 @@ Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) con
}
void BitMap::resize(const Size2 &p_new_size) {
-
Ref<BitMap> new_bitmap;
new_bitmap.instance();
new_bitmap->create(p_new_size);
@@ -636,7 +620,6 @@ void BitMap::resize(const Size2 &p_new_size) {
}
Ref<Image> BitMap::convert_to_image() const {
-
Ref<Image> image;
image.instance();
image->create(width, height, false, Image::FORMAT_L8);
@@ -649,8 +632,8 @@ Ref<Image> BitMap::convert_to_image() const {
return image;
}
-void BitMap::blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap) {
+void BitMap::blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap) {
int x = p_pos.x;
int y = p_pos.y;
int w = p_bitmap->get_size().width;
@@ -660,10 +643,12 @@ void BitMap::blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap) {
for (int j = 0; j < h; j++) {
int px = x + i;
int py = y + j;
- if (px < 0 || px >= width)
+ if (px < 0 || px >= width) {
continue;
- if (py < 0 || py >= height)
+ }
+ if (py < 0 || py >= height) {
continue;
+ }
if (p_bitmap->get_bit(Vector2(i, j))) {
set_bit(Vector2(x, y), true);
}
@@ -672,7 +657,6 @@ void BitMap::blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap) {
}
void BitMap::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create", "size"), &BitMap::create);
ClassDB::bind_method(D_METHOD("create_from_image_alpha", "image", "threshold"), &BitMap::create_from_image_alpha, DEFVAL(0.1));
@@ -694,7 +678,6 @@ void BitMap::_bind_methods() {
}
BitMap::BitMap() {
-
width = 0;
height = 0;
}
diff --git a/scene/resources/bit_map.h b/scene/resources/bit_map.h
index 05313a0cff..59f3b4dc3c 100644
--- a/scene/resources/bit_map.h
+++ b/scene/resources/bit_map.h
@@ -36,7 +36,6 @@
#include "core/resource.h"
class BitMap : public Resource {
-
GDCLASS(BitMap, Resource);
OBJ_SAVE_TYPE(BitMap);
diff --git a/scene/resources/box_shape_3d.cpp b/scene/resources/box_shape_3d.cpp
index 64c821a011..69339faf76 100644
--- a/scene/resources/box_shape_3d.cpp
+++ b/scene/resources/box_shape_3d.cpp
@@ -32,7 +32,6 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> BoxShape3D::get_debug_mesh_lines() {
-
Vector<Vector3> lines;
AABB aabb;
aabb.position = -get_extents();
@@ -53,13 +52,11 @@ real_t BoxShape3D::get_enclosing_radius() const {
}
void BoxShape3D::_update_shape() {
-
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), extents);
Shape3D::_update_shape();
}
void BoxShape3D::set_extents(const Vector3 &p_extents) {
-
extents = p_extents;
_update_shape();
notify_change_to_owners();
@@ -67,12 +64,10 @@ void BoxShape3D::set_extents(const Vector3 &p_extents) {
}
Vector3 BoxShape3D::get_extents() const {
-
return extents;
}
void BoxShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &BoxShape3D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &BoxShape3D::get_extents);
@@ -81,6 +76,5 @@ void BoxShape3D::_bind_methods() {
BoxShape3D::BoxShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_BOX)) {
-
set_extents(Vector3(1, 1, 1));
}
diff --git a/scene/resources/box_shape_3d.h b/scene/resources/box_shape_3d.h
index a93fd8d33a..e00b523815 100644
--- a/scene/resources/box_shape_3d.h
+++ b/scene/resources/box_shape_3d.h
@@ -34,7 +34,6 @@
#include "scene/resources/shape_3d.h"
class BoxShape3D : public Shape3D {
-
GDCLASS(BoxShape3D, Shape3D);
Vector3 extents;
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 5a3282478c..e519970f38 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -30,61 +30,56 @@
#include "capsule_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
Vector<Vector2> CapsuleShape2D::_get_points() const {
-
Vector<Vector2> points;
for (int i = 0; i < 24; i++) {
Vector2 ofs = Vector2(0, (i > 6 && i <= 18) ? -get_height() * 0.5 : get_height() * 0.5);
points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() + ofs);
- if (i == 6 || i == 18)
+ if (i == 6 || i == 18) {
points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() - ofs);
+ }
}
return points;
}
bool CapsuleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
- return Geometry::is_point_in_polygon(p_point, _get_points());
+ return Geometry2D::is_point_in_polygon(p_point, _get_points());
}
void CapsuleShape2D::_update_shape() {
-
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), Vector2(radius, height));
emit_changed();
}
void CapsuleShape2D::set_radius(real_t p_radius) {
-
radius = p_radius;
_update_shape();
}
real_t CapsuleShape2D::get_radius() const {
-
return radius;
}
void CapsuleShape2D::set_height(real_t p_height) {
-
height = p_height;
- if (height < 0)
+ if (height < 0) {
height = 0;
+ }
_update_shape();
}
real_t CapsuleShape2D::get_height() const {
-
return height;
}
void CapsuleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
Vector<Vector2> points = _get_points();
Vector<Color> col;
col.push_back(p_color);
@@ -92,7 +87,6 @@ void CapsuleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
}
Rect2 CapsuleShape2D::get_rect() const {
-
Vector2 he = Point2(get_radius(), get_radius() + get_height() * 0.5);
Rect2 rect;
rect.position = -he;
@@ -105,7 +99,6 @@ real_t CapsuleShape2D::get_enclosing_radius() const {
}
void CapsuleShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CapsuleShape2D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &CapsuleShape2D::get_radius);
@@ -118,7 +111,6 @@ void CapsuleShape2D::_bind_methods() {
CapsuleShape2D::CapsuleShape2D() :
Shape2D(PhysicsServer2D::get_singleton()->capsule_shape_create()) {
-
radius = 10;
height = 20;
_update_shape();
diff --git a/scene/resources/capsule_shape_3d.cpp b/scene/resources/capsule_shape_3d.cpp
index da3ffcb306..28fc0d470c 100644
--- a/scene/resources/capsule_shape_3d.cpp
+++ b/scene/resources/capsule_shape_3d.cpp
@@ -32,7 +32,6 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() {
-
float radius = get_radius();
float height = get_height();
@@ -40,7 +39,6 @@ Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() {
Vector3 d(0, height * 0.5, 0);
for (int i = 0; i < 360; i++) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
@@ -53,7 +51,6 @@ Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() {
points.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 90 == 0) {
-
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(a.x, 0, a.y) - d);
}
@@ -74,7 +71,6 @@ real_t CapsuleShape3D::get_enclosing_radius() const {
}
void CapsuleShape3D::_update_shape() {
-
Dictionary d;
d["radius"] = radius;
d["height"] = height;
@@ -83,7 +79,6 @@ void CapsuleShape3D::_update_shape() {
}
void CapsuleShape3D::set_radius(float p_radius) {
-
radius = p_radius;
_update_shape();
notify_change_to_owners();
@@ -91,12 +86,10 @@ void CapsuleShape3D::set_radius(float p_radius) {
}
float CapsuleShape3D::get_radius() const {
-
return radius;
}
void CapsuleShape3D::set_height(float p_height) {
-
height = p_height;
_update_shape();
notify_change_to_owners();
@@ -104,12 +97,10 @@ void CapsuleShape3D::set_height(float p_height) {
}
float CapsuleShape3D::get_height() const {
-
return height;
}
void CapsuleShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CapsuleShape3D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &CapsuleShape3D::get_radius);
ClassDB::bind_method(D_METHOD("set_height", "height"), &CapsuleShape3D::set_height);
@@ -121,7 +112,6 @@ void CapsuleShape3D::_bind_methods() {
CapsuleShape3D::CapsuleShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CAPSULE)) {
-
radius = 1.0;
height = 1.0;
_update_shape();
diff --git a/scene/resources/capsule_shape_3d.h b/scene/resources/capsule_shape_3d.h
index dca7a6c983..5892f97709 100644
--- a/scene/resources/capsule_shape_3d.h
+++ b/scene/resources/capsule_shape_3d.h
@@ -34,7 +34,6 @@
#include "scene/resources/shape_3d.h"
class CapsuleShape3D : public Shape3D {
-
GDCLASS(CapsuleShape3D, Shape3D);
float radius;
float height;
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index afb7597280..dc1bf3b185 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -34,29 +34,24 @@
#include "servers/rendering_server.h"
bool CircleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
return p_point.length() < get_radius() + p_tolerance;
}
void CircleShape2D::_update_shape() {
-
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), radius);
emit_changed();
}
void CircleShape2D::set_radius(real_t p_radius) {
-
radius = p_radius;
_update_shape();
}
real_t CircleShape2D::get_radius() const {
-
return radius;
}
void CircleShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CircleShape2D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &CircleShape2D::get_radius);
@@ -75,10 +70,8 @@ real_t CircleShape2D::get_enclosing_radius() const {
}
void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
Vector<Vector2> points;
for (int i = 0; i < 24; i++) {
-
points.push_back(Vector2(Math::cos(i * Math_PI * 2 / 24.0), Math::sin(i * Math_PI * 2 / 24.0)) * get_radius());
}
@@ -89,7 +82,6 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
CircleShape2D::CircleShape2D() :
Shape2D(PhysicsServer2D::get_singleton()->circle_shape_create()) {
-
radius = 10;
_update_shape();
}
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index c8fec3b72d..eecf8afa8f 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -30,43 +30,43 @@
#include "concave_polygon_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
Vector<Vector2> s = get_segments();
int len = s.size();
- if (len == 0 || (len % 2) == 1)
+ if (len == 0 || (len % 2) == 1) {
return false;
+ }
const Vector2 *r = s.ptr();
for (int i = 0; i < len; i += 2) {
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, &r[i]);
- if (p_point.distance_to(closest) < p_tolerance)
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, &r[i]);
+ if (p_point.distance_to(closest) < p_tolerance) {
return true;
+ }
}
return false;
}
void ConcavePolygonShape2D::set_segments(const Vector<Vector2> &p_segments) {
-
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), p_segments);
emit_changed();
}
Vector<Vector2> ConcavePolygonShape2D::get_segments() const {
-
return PhysicsServer2D::get_singleton()->shape_get_data(get_rid());
}
void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
Vector<Vector2> s = get_segments();
int len = s.size();
- if (len == 0 || (len % 2) == 1)
+ if (len == 0 || (len % 2) == 1) {
return;
+ }
const Vector2 *r = s.ptr();
for (int i = 0; i < len; i += 2) {
@@ -75,20 +75,21 @@ void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
}
Rect2 ConcavePolygonShape2D::get_rect() const {
-
Vector<Vector2> s = get_segments();
int len = s.size();
- if (len == 0)
+ if (len == 0) {
return Rect2();
+ }
Rect2 rect;
const Vector2 *r = s.ptr();
for (int i = 0; i < len; i++) {
- if (i == 0)
+ if (i == 0) {
rect.position = r[i];
- else
+ } else {
rect.expand_to(r[i]);
+ }
}
return rect;
@@ -105,7 +106,6 @@ real_t ConcavePolygonShape2D::get_enclosing_radius() const {
}
void ConcavePolygonShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_segments", "segments"), &ConcavePolygonShape2D::set_segments);
ClassDB::bind_method(D_METHOD("get_segments"), &ConcavePolygonShape2D::get_segments);
diff --git a/scene/resources/concave_polygon_shape_3d.cpp b/scene/resources/concave_polygon_shape_3d.cpp
index 42e06a49b6..7315945c03 100644
--- a/scene/resources/concave_polygon_shape_3d.cpp
+++ b/scene/resources/concave_polygon_shape_3d.cpp
@@ -33,7 +33,6 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> ConcavePolygonShape3D::get_debug_mesh_lines() {
-
Set<DrawEdge> edges;
Vector<Vector3> data = get_faces();
@@ -43,9 +42,7 @@ Vector<Vector3> ConcavePolygonShape3D::get_debug_mesh_lines() {
const Vector3 *r = data.ptr();
for (int i = 0; i < datalen; i += 3) {
-
for (int j = 0; j < 3; j++) {
-
DrawEdge de(r[i + j], r[i + ((j + 1) % 3)]);
edges.insert(de);
}
@@ -55,7 +52,6 @@ Vector<Vector3> ConcavePolygonShape3D::get_debug_mesh_lines() {
points.resize(edges.size() * 2);
int idx = 0;
for (Set<DrawEdge>::Element *E = edges.front(); E; E = E->next()) {
-
points.write[idx + 0] = E->get().a;
points.write[idx + 1] = E->get().b;
idx += 2;
@@ -79,18 +75,15 @@ void ConcavePolygonShape3D::_update_shape() {
}
void ConcavePolygonShape3D::set_faces(const Vector<Vector3> &p_faces) {
-
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), p_faces);
notify_change_to_owners();
}
Vector<Vector3> ConcavePolygonShape3D::get_faces() const {
-
return PhysicsServer3D::get_singleton()->shape_get_data(get_shape());
}
void ConcavePolygonShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_faces", "faces"), &ConcavePolygonShape3D::set_faces);
ClassDB::bind_method(D_METHOD("get_faces"), &ConcavePolygonShape3D::get_faces);
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_faces", "get_faces");
@@ -98,6 +91,5 @@ void ConcavePolygonShape3D::_bind_methods() {
ConcavePolygonShape3D::ConcavePolygonShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON)) {
-
//set_planes(Vector3(1,1,1));
}
diff --git a/scene/resources/concave_polygon_shape_3d.h b/scene/resources/concave_polygon_shape_3d.h
index b4e96c662f..c268ed9f37 100644
--- a/scene/resources/concave_polygon_shape_3d.h
+++ b/scene/resources/concave_polygon_shape_3d.h
@@ -34,18 +34,17 @@
#include "scene/resources/shape_3d.h"
class ConcavePolygonShape3D : public Shape3D {
-
GDCLASS(ConcavePolygonShape3D, Shape3D);
struct DrawEdge {
-
Vector3 a;
Vector3 b;
bool operator<(const DrawEdge &p_edge) const {
- if (a == p_edge.a)
+ if (a == p_edge.a) {
return b < p_edge.b;
- else
+ } else {
return a < p_edge.a;
+ }
}
DrawEdge(const Vector3 &p_a = Vector3(), const Vector3 &p_b = Vector3()) {
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 6b1ddec507..2b7531c630 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -30,19 +30,17 @@
#include "convex_polygon_shape_2d.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
bool ConvexPolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
- return Geometry::is_point_in_polygon(p_point, points);
+ return Geometry2D::is_point_in_polygon(p_point, points);
}
void ConvexPolygonShape2D::_update_shape() {
-
Vector<Vector2> final_points = points;
- if (Geometry::is_polygon_clockwise(final_points)) { //needs to be counter clockwise
+ if (Geometry2D::is_polygon_clockwise(final_points)) { //needs to be counter clockwise
final_points.invert();
}
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), final_points);
@@ -50,26 +48,22 @@ void ConvexPolygonShape2D::_update_shape() {
}
void ConvexPolygonShape2D::set_point_cloud(const Vector<Vector2> &p_points) {
-
- Vector<Point2> hull = Geometry::convex_hull_2d(p_points);
+ Vector<Point2> hull = Geometry2D::convex_hull(p_points);
ERR_FAIL_COND(hull.size() < 3);
set_points(hull);
}
void ConvexPolygonShape2D::set_points(const Vector<Vector2> &p_points) {
-
points = p_points;
_update_shape();
}
Vector<Vector2> ConvexPolygonShape2D::get_points() const {
-
return points;
}
void ConvexPolygonShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_point_cloud", "point_cloud"), &ConvexPolygonShape2D::set_point_cloud);
ClassDB::bind_method(D_METHOD("set_points", "points"), &ConvexPolygonShape2D::set_points);
ClassDB::bind_method(D_METHOD("get_points"), &ConvexPolygonShape2D::get_points);
@@ -78,20 +72,19 @@ void ConvexPolygonShape2D::_bind_methods() {
}
void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
Vector<Color> col;
col.push_back(p_color);
RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
Rect2 ConvexPolygonShape2D::get_rect() const {
-
Rect2 rect;
for (int i = 0; i < points.size(); i++) {
- if (i == 0)
+ if (i == 0) {
rect.position = points[i];
- else
+ } else {
rect.expand_to(points[i]);
+ }
}
return rect;
diff --git a/scene/resources/convex_polygon_shape_3d.cpp b/scene/resources/convex_polygon_shape_3d.cpp
index ec9ab68015..affeb05a8f 100644
--- a/scene/resources/convex_polygon_shape_3d.cpp
+++ b/scene/resources/convex_polygon_shape_3d.cpp
@@ -33,13 +33,11 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> ConvexPolygonShape3D::get_debug_mesh_lines() {
-
Vector<Vector3> points = get_points();
if (points.size() > 3) {
-
Vector<Vector3> varr = Variant(points);
- Geometry::MeshData md;
+ Geometry3D::MeshData md;
Error err = QuickHull::build(varr, md);
if (err == OK) {
Vector<Vector3> lines;
@@ -66,25 +64,21 @@ real_t ConvexPolygonShape3D::get_enclosing_radius() const {
}
void ConvexPolygonShape3D::_update_shape() {
-
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), points);
Shape3D::_update_shape();
}
void ConvexPolygonShape3D::set_points(const Vector<Vector3> &p_points) {
-
points = p_points;
_update_shape();
notify_change_to_owners();
}
Vector<Vector3> ConvexPolygonShape3D::get_points() const {
-
return points;
}
void ConvexPolygonShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_points", "points"), &ConvexPolygonShape3D::set_points);
ClassDB::bind_method(D_METHOD("get_points"), &ConvexPolygonShape3D::get_points);
diff --git a/scene/resources/convex_polygon_shape_3d.h b/scene/resources/convex_polygon_shape_3d.h
index 51e4c8eb0b..0e3dde47a5 100644
--- a/scene/resources/convex_polygon_shape_3d.h
+++ b/scene/resources/convex_polygon_shape_3d.h
@@ -34,7 +34,6 @@
#include "scene/resources/shape_3d.h"
class ConvexPolygonShape3D : public Shape3D {
-
GDCLASS(ConvexPolygonShape3D, Shape3D);
Vector<Vector3> points;
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index ae705a47e8..de076670cf 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -58,10 +58,11 @@ int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, T
// Add a point and preserve order
// Curve bounds is in 0..1
- if (p_pos.x > MAX_X)
+ if (p_pos.x > MAX_X) {
p_pos.x = MAX_X;
- else if (p_pos.x < MIN_X)
+ } else if (p_pos.x < MIN_X) {
p_pos.x = MIN_X;
+ }
int ret = -1;
@@ -83,7 +84,6 @@ int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, T
}
} else {
-
int i = get_index(p_pos.x);
if (i == 0 && p_pos.x < _points[0].pos.x) {
@@ -106,7 +106,6 @@ int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, T
}
int Curve::get_index(real_t offset) const {
-
// Lower-bound float binary search
int imin = 0;
@@ -130,13 +129,13 @@ int Curve::get_index(real_t offset) const {
}
// Will happen if the offset is out of bounds
- if (offset > _points[imax].pos.x)
+ if (offset > _points[imax].pos.x) {
return imax;
+ }
return imin;
}
void Curve::clean_dupes() {
-
bool dirty = false;
for (int i = 1; i < _points.size(); ++i) {
@@ -148,8 +147,9 @@ void Curve::clean_dupes() {
}
}
- if (dirty)
+ if (dirty) {
mark_dirty();
+ }
}
void Curve::set_point_left_tangent(int i, real_t tangent) {
@@ -237,8 +237,9 @@ int Curve::set_point_offset(int p_index, float offset) {
_points.write[i].right_tangent = p.right_tangent;
_points.write[i].left_mode = p.left_mode;
_points.write[i].right_mode = p.right_mode;
- if (p_index != i)
+ if (p_index != i) {
update_auto_tangents(p_index);
+ }
update_auto_tangents(i);
return i;
}
@@ -254,7 +255,6 @@ Curve::Point Curve::get_point(int p_index) const {
}
void Curve::update_auto_tangents(int i) {
-
Point &p = _points.write[i];
if (i > 0) {
@@ -305,26 +305,29 @@ void Curve::set_max_value(float p_max) {
}
real_t Curve::interpolate(real_t offset) const {
- if (_points.size() == 0)
+ if (_points.size() == 0) {
return 0;
- if (_points.size() == 1)
+ }
+ if (_points.size() == 1) {
return _points[0].pos.y;
+ }
int i = get_index(offset);
- if (i == _points.size() - 1)
+ if (i == _points.size() - 1) {
return _points[i].pos.y;
+ }
real_t local = offset - _points[i].pos.x;
- if (i == 0 && local <= 0)
+ if (i == 0 && local <= 0) {
return _points[0].pos.y;
+ }
return interpolate_local_nocheck(i, local);
}
real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const {
-
const Point a = _points[index];
const Point b = _points[index + 1];
@@ -344,8 +347,9 @@ real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const {
// Control points are chosen at equal distances
real_t d = b.pos.x - a.pos.x;
- if (Math::abs(d) <= CMP_EPSILON)
+ if (Math::abs(d) <= CMP_EPSILON) {
return b.pos.y;
+ }
local_offset /= d;
d /= 3.0;
real_t yac = a.pos.y + d * a.right_tangent;
@@ -362,13 +366,11 @@ void Curve::mark_dirty() {
}
Array Curve::get_data() const {
-
Array output;
const unsigned int ELEMS = 5;
output.resize(_points.size() * ELEMS);
for (int j = 0; j < _points.size(); ++j) {
-
const Point p = _points[j];
int i = j * ELEMS;
@@ -406,7 +408,6 @@ void Curve::set_data(Array input) {
_points.resize(input.size() / ELEMS);
for (int j = 0; j < _points.size(); ++j) {
-
Point &p = _points.write[j];
int i = j * ELEMS;
@@ -457,8 +458,9 @@ real_t Curve::interpolate_baked(real_t offset) {
// Special cases if the cache is too small
if (_baked_cache.size() == 0) {
- if (_points.size() == 0)
+ if (_points.size() == 0) {
return 0;
+ }
return _points[0].pos.y;
} else if (_baked_cache.size() == 1) {
return _baked_cache[0];
@@ -486,7 +488,6 @@ real_t Curve::interpolate_baked(real_t offset) {
void Curve::ensure_default_setup(float p_min, float p_max) {
if (_points.size() == 0 && _min_value == 0 && _max_value == 1) {
-
add_point(Vector2(0, 1));
add_point(Vector2(1, 1));
set_min_value(p_min);
@@ -495,7 +496,6 @@ void Curve::ensure_default_setup(float p_min, float p_max) {
}
void Curve::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_point_count"), &Curve::get_point_count);
ClassDB::bind_method(D_METHOD("add_point", "position", "left_tangent", "right_tangent", "left_mode", "right_mode"), &Curve::add_point, DEFVAL(0), DEFVAL(0), DEFVAL(TANGENT_FREE), DEFVAL(TANGENT_FREE));
ClassDB::bind_method(D_METHOD("remove_point", "index"), &Curve::remove_point);
@@ -537,54 +537,51 @@ void Curve::_bind_methods() {
}
int Curve2D::get_point_count() const {
-
return points.size();
}
-void Curve2D::add_point(const Vector2 &p_pos, const Vector2 &p_in, const Vector2 &p_out, int p_atpos) {
+void Curve2D::add_point(const Vector2 &p_pos, const Vector2 &p_in, const Vector2 &p_out, int p_atpos) {
Point n;
n.pos = p_pos;
n.in = p_in;
n.out = p_out;
- if (p_atpos >= 0 && p_atpos < points.size())
+ if (p_atpos >= 0 && p_atpos < points.size()) {
points.insert(p_atpos, n);
- else
+ } else {
points.push_back(n);
+ }
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
void Curve2D::set_point_position(int p_index, const Vector2 &p_pos) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].pos = p_pos;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-Vector2 Curve2D::get_point_position(int p_index) const {
+Vector2 Curve2D::get_point_position(int p_index) const {
ERR_FAIL_INDEX_V(p_index, points.size(), Vector2());
return points[p_index].pos;
}
void Curve2D::set_point_in(int p_index, const Vector2 &p_in) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].in = p_in;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-Vector2 Curve2D::get_point_in(int p_index) const {
+Vector2 Curve2D::get_point_in(int p_index) const {
ERR_FAIL_INDEX_V(p_index, points.size(), Vector2());
return points[p_index].in;
}
void Curve2D::set_point_out(int p_index, const Vector2 &p_out) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].out = p_out;
@@ -593,13 +590,11 @@ void Curve2D::set_point_out(int p_index, const Vector2 &p_out) {
}
Vector2 Curve2D::get_point_out(int p_index) const {
-
ERR_FAIL_INDEX_V(p_index, points.size(), Vector2());
return points[p_index].out;
}
void Curve2D::remove_point(int p_index) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.remove(p_index);
baked_cache_dirty = true;
@@ -615,14 +610,14 @@ void Curve2D::clear_points() {
}
Vector2 Curve2D::interpolate(int p_index, float p_offset) const {
-
int pc = points.size();
ERR_FAIL_COND_V(pc == 0, Vector2());
- if (p_index >= pc - 1)
+ if (p_index >= pc - 1) {
return points[pc - 1].pos;
- else if (p_index < 0)
+ } else if (p_index < 0) {
return points[0].pos;
+ }
Vector2 p0 = points[p_index].pos;
Vector2 p1 = p0 + points[p_index].out;
@@ -633,17 +628,16 @@ Vector2 Curve2D::interpolate(int p_index, float p_offset) const {
}
Vector2 Curve2D::interpolatef(real_t p_findex) const {
-
- if (p_findex < 0)
+ if (p_findex < 0) {
p_findex = 0;
- else if (p_findex >= points.size())
+ } else if (p_findex >= points.size()) {
p_findex = points.size();
+ }
return interpolate((int)p_findex, Math::fmod(p_findex, (real_t)1.0));
}
void Curve2D::_bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, float p_tol) const {
-
float mp = p_begin + (p_end - p_begin) * 0.5;
Vector2 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
Vector2 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b);
@@ -654,7 +648,6 @@ void Curve2D::_bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float
float dp = na.dot(nb);
if (dp < Math::cos(Math::deg2rad(p_tol))) {
-
r_bake[mp] = mid;
}
@@ -665,9 +658,9 @@ void Curve2D::_bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float
}
void Curve2D::_bake() const {
-
- if (!baked_cache_dirty)
+ if (!baked_cache_dirty) {
return;
+ }
baked_max_ofs = 0;
baked_cache_dirty = false;
@@ -678,7 +671,6 @@ void Curve2D::_bake() const {
}
if (points.size() == 1) {
-
baked_point_cache.resize(1);
baked_point_cache.set(0, points[0].pos);
return;
@@ -690,15 +682,14 @@ void Curve2D::_bake() const {
pointlist.push_back(pos); //start always from origin
for (int i = 0; i < points.size() - 1; i++) {
-
float step = 0.1; // at least 10 substeps ought to be enough?
float p = 0;
while (p < 1.0) {
-
float np = p + step;
- if (np > 1.0)
+ if (np > 1.0) {
np = 1.0;
+ }
Vector2 npp = _bezier_interp(np, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
float d = pos.distance_to(npp);
@@ -713,14 +704,14 @@ void Curve2D::_bake() const {
float mid = low + (hi - low) * 0.5;
for (int j = 0; j < iterations; j++) {
-
npp = _bezier_interp(mid, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
d = pos.distance_to(npp);
- if (bake_interval < d)
+ if (bake_interval < d) {
hi = mid;
- else
+ } else {
low = mid;
+ }
mid = low + (hi - low) * 0.5;
}
@@ -728,7 +719,6 @@ void Curve2D::_bake() const {
p = mid;
pointlist.push_back(pos);
} else {
-
p = np;
}
}
@@ -745,38 +735,41 @@ void Curve2D::_bake() const {
int idx = 0;
for (List<Vector2>::Element *E = pointlist.front(); E; E = E->next()) {
-
w[idx] = E->get();
idx++;
}
}
float Curve2D::get_baked_length() const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
return baked_max_ofs;
}
-Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
- if (baked_cache_dirty)
+Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_point_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, Vector2(), "No points in Curve2D.");
- if (pc == 1)
+ if (pc == 1) {
return baked_point_cache.get(0);
+ }
int bpc = baked_point_cache.size();
const Vector2 *r = baked_point_cache.ptr();
- if (p_offset < 0)
+ if (p_offset < 0) {
return r[0];
- if (p_offset >= baked_max_ofs)
+ }
+ if (p_offset >= baked_max_ofs) {
return r[bpc - 1];
+ }
int idx = Math::floor((double)p_offset / (double)bake_interval);
float frac = Math::fmod(p_offset, (float)bake_interval);
@@ -784,14 +777,14 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
if (idx >= bpc - 1) {
return r[bpc - 1];
} else if (idx == bpc - 2) {
- if (frac > 0)
+ if (frac > 0) {
frac /= Math::fmod(baked_max_ofs, bake_interval);
+ }
} else {
frac /= bake_interval;
}
if (p_cubic) {
-
Vector2 pre = idx > 0 ? r[idx - 1] : r[idx];
Vector2 post = (idx < (bpc - 2)) ? r[idx + 2] : r[idx + 1];
return r[idx].cubic_interpolate(r[idx + 1], pre, post, frac);
@@ -801,37 +794,37 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
}
PackedVector2Array Curve2D::get_baked_points() const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
return baked_point_cache;
}
void Curve2D::set_bake_interval(float p_tolerance) {
-
bake_interval = p_tolerance;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
float Curve2D::get_bake_interval() const {
-
return bake_interval;
}
Vector2 Curve2D::get_closest_point(const Vector2 &p_to_point) const {
// Brute force method
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_point_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, Vector2(), "No points in Curve2D.");
- if (pc == 1)
+ if (pc == 1) {
return baked_point_cache.get(0);
+ }
const Vector2 *r = baked_point_cache.ptr();
@@ -859,15 +852,17 @@ Vector2 Curve2D::get_closest_point(const Vector2 &p_to_point) const {
float Curve2D::get_closest_offset(const Vector2 &p_to_point) const {
// Brute force method
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_point_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, 0.0f, "No points in Curve2D.");
- if (pc == 1)
+ if (pc == 1) {
return 0.0f;
+ }
const Vector2 *r = baked_point_cache.ptr();
@@ -896,7 +891,6 @@ float Curve2D::get_closest_offset(const Vector2 &p_to_point) const {
}
Dictionary Curve2D::_get_data() const {
-
Dictionary dc;
PackedVector2Array d;
@@ -904,7 +898,6 @@ Dictionary Curve2D::_get_data() const {
Vector2 *w = d.ptrw();
for (int i = 0; i < points.size(); i++) {
-
w[i * 3 + 0] = points[i].in;
w[i * 3 + 1] = points[i].out;
w[i * 3 + 2] = points[i].pos;
@@ -914,8 +907,8 @@ Dictionary Curve2D::_get_data() const {
return dc;
}
-void Curve2D::_set_data(const Dictionary &p_data) {
+void Curve2D::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("points"));
PackedVector2Array rp = p_data["points"];
@@ -925,7 +918,6 @@ void Curve2D::_set_data(const Dictionary &p_data) {
const Vector2 *r = rp.ptr();
for (int i = 0; i < points.size(); i++) {
-
points.write[i].in = r[i * 3 + 0];
points.write[i].out = r[i * 3 + 1];
points.write[i].pos = r[i * 3 + 2];
@@ -935,7 +927,6 @@ void Curve2D::_set_data(const Dictionary &p_data) {
}
PackedVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) const {
-
PackedVector2Array tess;
if (points.size() == 0) {
@@ -947,7 +938,6 @@ PackedVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) cons
int pc = 1;
for (int i = 0; i < points.size() - 1; i++) {
-
_bake_segment2d(midpoints.write[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance);
pc++;
pc += midpoints[i].size();
@@ -959,9 +949,7 @@ PackedVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) cons
int pidx = 0;
for (int i = 0; i < points.size() - 1; i++) {
-
for (Map<float, Vector2>::Element *E = midpoints[i].front(); E; E = E->next()) {
-
pidx++;
bpw[pidx] = E->get();
}
@@ -974,7 +962,6 @@ PackedVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) cons
}
void Curve2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_point_count"), &Curve2D::get_point_count);
ClassDB::bind_method(D_METHOD("add_point", "position", "in", "out", "at_position"), &Curve2D::add_point, DEFVAL(Vector2()), DEFVAL(Vector2()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_point_position", "idx", "position"), &Curve2D::set_point_position);
@@ -1022,67 +1009,64 @@ Curve2D::Curve2D() {
/***********************************************************************************/
int Curve3D::get_point_count() const {
-
return points.size();
}
-void Curve3D::add_point(const Vector3 &p_pos, const Vector3 &p_in, const Vector3 &p_out, int p_atpos) {
+void Curve3D::add_point(const Vector3 &p_pos, const Vector3 &p_in, const Vector3 &p_out, int p_atpos) {
Point n;
n.pos = p_pos;
n.in = p_in;
n.out = p_out;
- if (p_atpos >= 0 && p_atpos < points.size())
+ if (p_atpos >= 0 && p_atpos < points.size()) {
points.insert(p_atpos, n);
- else
+ } else {
points.push_back(n);
+ }
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-void Curve3D::set_point_position(int p_index, const Vector3 &p_pos) {
+void Curve3D::set_point_position(int p_index, const Vector3 &p_pos) {
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].pos = p_pos;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-Vector3 Curve3D::get_point_position(int p_index) const {
+Vector3 Curve3D::get_point_position(int p_index) const {
ERR_FAIL_INDEX_V(p_index, points.size(), Vector3());
return points[p_index].pos;
}
void Curve3D::set_point_tilt(int p_index, float p_tilt) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].tilt = p_tilt;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-float Curve3D::get_point_tilt(int p_index) const {
+float Curve3D::get_point_tilt(int p_index) const {
ERR_FAIL_INDEX_V(p_index, points.size(), 0);
return points[p_index].tilt;
}
void Curve3D::set_point_in(int p_index, const Vector3 &p_in) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].in = p_in;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-Vector3 Curve3D::get_point_in(int p_index) const {
+Vector3 Curve3D::get_point_in(int p_index) const {
ERR_FAIL_INDEX_V(p_index, points.size(), Vector3());
return points[p_index].in;
}
void Curve3D::set_point_out(int p_index, const Vector3 &p_out) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.write[p_index].out = p_out;
@@ -1091,13 +1075,11 @@ void Curve3D::set_point_out(int p_index, const Vector3 &p_out) {
}
Vector3 Curve3D::get_point_out(int p_index) const {
-
ERR_FAIL_INDEX_V(p_index, points.size(), Vector3());
return points[p_index].out;
}
void Curve3D::remove_point(int p_index) {
-
ERR_FAIL_INDEX(p_index, points.size());
points.remove(p_index);
baked_cache_dirty = true;
@@ -1105,7 +1087,6 @@ void Curve3D::remove_point(int p_index) {
}
void Curve3D::clear_points() {
-
if (!points.empty()) {
points.clear();
baked_cache_dirty = true;
@@ -1114,14 +1095,14 @@ void Curve3D::clear_points() {
}
Vector3 Curve3D::interpolate(int p_index, float p_offset) const {
-
int pc = points.size();
ERR_FAIL_COND_V(pc == 0, Vector3());
- if (p_index >= pc - 1)
+ if (p_index >= pc - 1) {
return points[pc - 1].pos;
- else if (p_index < 0)
+ } else if (p_index < 0) {
return points[0].pos;
+ }
Vector3 p0 = points[p_index].pos;
Vector3 p1 = p0 + points[p_index].out;
@@ -1132,17 +1113,16 @@ Vector3 Curve3D::interpolate(int p_index, float p_offset) const {
}
Vector3 Curve3D::interpolatef(real_t p_findex) const {
-
- if (p_findex < 0)
+ if (p_findex < 0) {
p_findex = 0;
- else if (p_findex >= points.size())
+ } else if (p_findex >= points.size()) {
p_findex = points.size();
+ }
return interpolate((int)p_findex, Math::fmod(p_findex, (real_t)1.0));
}
void Curve3D::_bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, float p_tol) const {
-
float mp = p_begin + (p_end - p_begin) * 0.5;
Vector3 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
Vector3 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b);
@@ -1153,7 +1133,6 @@ void Curve3D::_bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float
float dp = na.dot(nb);
if (dp < Math::cos(Math::deg2rad(p_tol))) {
-
r_bake[mp] = mid;
}
if (p_depth < p_max_depth) {
@@ -1163,9 +1142,9 @@ void Curve3D::_bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float
}
void Curve3D::_bake() const {
-
- if (!baked_cache_dirty)
+ if (!baked_cache_dirty) {
return;
+ }
baked_max_ofs = 0;
baked_cache_dirty = false;
@@ -1178,18 +1157,17 @@ void Curve3D::_bake() const {
}
if (points.size() == 1) {
-
baked_point_cache.resize(1);
baked_point_cache.set(0, points[0].pos);
baked_tilt_cache.resize(1);
baked_tilt_cache.set(0, points[0].tilt);
if (up_vector_enabled) {
-
baked_up_vector_cache.resize(1);
baked_up_vector_cache.set(0, Vector3(0, 1, 0));
- } else
+ } else {
baked_up_vector_cache.resize(0);
+ }
return;
}
@@ -1199,15 +1177,14 @@ void Curve3D::_bake() const {
pointlist.push_back(Plane(pos, points[0].tilt));
for (int i = 0; i < points.size() - 1; i++) {
-
float step = 0.1; // at least 10 substeps ought to be enough?
float p = 0;
while (p < 1.0) {
-
float np = p + step;
- if (np > 1.0)
+ if (np > 1.0) {
np = 1.0;
+ }
Vector3 npp = _bezier_interp(np, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
float d = pos.distance_to(npp);
@@ -1222,14 +1199,14 @@ void Curve3D::_bake() const {
float mid = low + (hi - low) * 0.5;
for (int j = 0; j < iterations; j++) {
-
npp = _bezier_interp(mid, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
d = pos.distance_to(npp);
- if (bake_interval < d)
+ if (bake_interval < d) {
hi = mid;
- else
+ } else {
low = mid;
+ }
mid = low + (hi - low) * 0.5;
}
@@ -1240,7 +1217,6 @@ void Curve3D::_bake() const {
post.d = Math::lerp(points[i].tilt, points[i + 1].tilt, mid);
pointlist.push_back(post);
} else {
-
p = np;
}
}
@@ -1272,7 +1248,6 @@ void Curve3D::_bake() const {
Vector3 prev_forward = Vector3(0, 0, 1);
for (List<Plane>::Element *E = pointlist.front(); E; E = E->next()) {
-
w[idx] = E->get().normal;
wt[idx] = E->get().d;
@@ -1296,8 +1271,9 @@ void Curve3D::_bake() const {
up = forward.cross(sideways).normalized();
}
- if (idx == 1)
+ if (idx == 1) {
up_write[0] = up;
+ }
up_write[idx] = up;
@@ -1310,31 +1286,35 @@ void Curve3D::_bake() const {
}
float Curve3D::get_baked_length() const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
return baked_max_ofs;
}
-Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
- if (baked_cache_dirty)
+Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_point_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, Vector3(), "No points in Curve3D.");
- if (pc == 1)
+ if (pc == 1) {
return baked_point_cache.get(0);
+ }
int bpc = baked_point_cache.size();
const Vector3 *r = baked_point_cache.ptr();
- if (p_offset < 0)
+ if (p_offset < 0) {
return r[0];
- if (p_offset >= baked_max_ofs)
+ }
+ if (p_offset >= baked_max_ofs) {
return r[bpc - 1];
+ }
int idx = Math::floor((double)p_offset / (double)bake_interval);
float frac = Math::fmod(p_offset, bake_interval);
@@ -1342,14 +1322,14 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
if (idx >= bpc - 1) {
return r[bpc - 1];
} else if (idx == bpc - 2) {
- if (frac > 0)
+ if (frac > 0) {
frac /= Math::fmod(baked_max_ofs, bake_interval);
+ }
} else {
frac /= bake_interval;
}
if (p_cubic) {
-
Vector3 pre = idx > 0 ? r[idx - 1] : r[idx];
Vector3 post = (idx < (bpc - 2)) ? r[idx + 2] : r[idx + 1];
return r[idx].cubic_interpolate(r[idx + 1], pre, post, frac);
@@ -1359,24 +1339,27 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
}
float Curve3D::interpolate_baked_tilt(float p_offset) const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_tilt_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, 0, "No tilts in Curve3D.");
- if (pc == 1)
+ if (pc == 1) {
return baked_tilt_cache.get(0);
+ }
int bpc = baked_tilt_cache.size();
const real_t *r = baked_tilt_cache.ptr();
- if (p_offset < 0)
+ if (p_offset < 0) {
return r[0];
- if (p_offset >= baked_max_ofs)
+ }
+ if (p_offset >= baked_max_ofs) {
return r[bpc - 1];
+ }
int idx = Math::floor((double)p_offset / (double)bake_interval);
float frac = Math::fmod(p_offset, bake_interval);
@@ -1384,8 +1367,9 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const {
if (idx >= bpc - 1) {
return r[bpc - 1];
} else if (idx == bpc - 2) {
- if (frac > 0)
+ if (frac > 0) {
frac /= Math::fmod(baked_max_ofs, bake_interval);
+ }
} else {
frac /= bake_interval;
}
@@ -1394,17 +1378,18 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const {
}
Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt) const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
// curve may not have baked up vectors
int count = baked_up_vector_cache.size();
ERR_FAIL_COND_V_MSG(count == 0, Vector3(0, 1, 0), "No up vectors in Curve3D.");
- if (count == 1)
+ if (count == 1) {
return baked_up_vector_cache.get(0);
+ }
const Vector3 *r = baked_up_vector_cache.ptr();
const Vector3 *rp = baked_point_cache.ptr();
@@ -1415,8 +1400,9 @@ Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt)
int idx = Math::floor((double)offset / (double)bake_interval);
float frac = Math::fmod(offset, bake_interval) / bake_interval;
- if (idx == count - 1)
+ if (idx == count - 1) {
return p_apply_tilt ? r[idx].rotated((rp[idx] - rp[idx - 1]).normalized(), rt[idx]) : r[idx];
+ }
Vector3 forward = (rp[idx + 1] - rp[idx]).normalized();
Vector3 up = r[idx];
@@ -1429,34 +1415,35 @@ Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt)
Vector3 axis = up.cross(up1);
- if (axis.length_squared() < CMP_EPSILON2)
+ if (axis.length_squared() < CMP_EPSILON2) {
axis = forward;
- else
+ } else {
axis.normalize();
+ }
return up.rotated(axis, up.angle_to(up1) * frac);
}
PackedVector3Array Curve3D::get_baked_points() const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
return baked_point_cache;
}
PackedFloat32Array Curve3D::get_baked_tilts() const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
return baked_tilt_cache;
}
PackedVector3Array Curve3D::get_baked_up_vectors() const {
-
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
return baked_up_vector_cache;
}
@@ -1464,15 +1451,17 @@ PackedVector3Array Curve3D::get_baked_up_vectors() const {
Vector3 Curve3D::get_closest_point(const Vector3 &p_to_point) const {
// Brute force method
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_point_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, Vector3(), "No points in Curve3D.");
- if (pc == 1)
+ if (pc == 1) {
return baked_point_cache.get(0);
+ }
const Vector3 *r = baked_point_cache.ptr();
@@ -1500,15 +1489,17 @@ Vector3 Curve3D::get_closest_point(const Vector3 &p_to_point) const {
float Curve3D::get_closest_offset(const Vector3 &p_to_point) const {
// Brute force method
- if (baked_cache_dirty)
+ if (baked_cache_dirty) {
_bake();
+ }
//validate//
int pc = baked_point_cache.size();
ERR_FAIL_COND_V_MSG(pc == 0, 0.0f, "No points in Curve3D.");
- if (pc == 1)
+ if (pc == 1) {
return 0.0f;
+ }
const Vector3 *r = baked_point_cache.ptr();
@@ -1537,31 +1528,26 @@ float Curve3D::get_closest_offset(const Vector3 &p_to_point) const {
}
void Curve3D::set_bake_interval(float p_tolerance) {
-
bake_interval = p_tolerance;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
float Curve3D::get_bake_interval() const {
-
return bake_interval;
}
void Curve3D::set_up_vector_enabled(bool p_enable) {
-
up_vector_enabled = p_enable;
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
bool Curve3D::is_up_vector_enabled() const {
-
return up_vector_enabled;
}
Dictionary Curve3D::_get_data() const {
-
Dictionary dc;
PackedVector3Array d;
@@ -1572,7 +1558,6 @@ Dictionary Curve3D::_get_data() const {
real_t *wt = t.ptrw();
for (int i = 0; i < points.size(); i++) {
-
w[i * 3 + 0] = points[i].in;
w[i * 3 + 1] = points[i].out;
w[i * 3 + 2] = points[i].pos;
@@ -1584,8 +1569,8 @@ Dictionary Curve3D::_get_data() const {
return dc;
}
-void Curve3D::_set_data(const Dictionary &p_data) {
+void Curve3D::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("points"));
ERR_FAIL_COND(!p_data.has("tilts"));
@@ -1598,7 +1583,6 @@ void Curve3D::_set_data(const Dictionary &p_data) {
const real_t *rt = rtl.ptr();
for (int i = 0; i < points.size(); i++) {
-
points.write[i].in = r[i * 3 + 0];
points.write[i].out = r[i * 3 + 1];
points.write[i].pos = r[i * 3 + 2];
@@ -1609,7 +1593,6 @@ void Curve3D::_set_data(const Dictionary &p_data) {
}
PackedVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) const {
-
PackedVector3Array tess;
if (points.size() == 0) {
@@ -1621,7 +1604,6 @@ PackedVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) cons
int pc = 1;
for (int i = 0; i < points.size() - 1; i++) {
-
_bake_segment3d(midpoints.write[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance);
pc++;
pc += midpoints[i].size();
@@ -1633,9 +1615,7 @@ PackedVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) cons
int pidx = 0;
for (int i = 0; i < points.size() - 1; i++) {
-
for (Map<float, Vector3>::Element *E = midpoints[i].front(); E; E = E->next()) {
-
pidx++;
bpw[pidx] = E->get();
}
@@ -1648,7 +1628,6 @@ PackedVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) cons
}
void Curve3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_point_count"), &Curve3D::get_point_count);
ClassDB::bind_method(D_METHOD("add_point", "position", "in", "out", "at_position"), &Curve3D::add_point, DEFVAL(Vector3()), DEFVAL(Vector3()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("set_point_position", "idx", "position"), &Curve3D::set_point_position);
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 7dcbf1ceff..57ddaf897d 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -68,7 +68,6 @@ public:
real_t p_right = 0,
TangentMode p_left_mode = TANGENT_FREE,
TangentMode p_right_mode = TANGENT_FREE) {
-
pos = p_pos;
left_tangent = p_left;
right_tangent = p_right;
@@ -149,11 +148,9 @@ private:
VARIANT_ENUM_CAST(Curve::TangentMode)
class Curve2D : public Resource {
-
GDCLASS(Curve2D, Resource);
struct Point {
-
Vector2 in;
Vector2 out;
Vector2 pos;
@@ -162,7 +159,6 @@ class Curve2D : public Resource {
Vector<Point> points;
struct BakedPoint {
-
float ofs;
Vector2 point;
};
@@ -212,11 +208,9 @@ public:
};
class Curve3D : public Resource {
-
GDCLASS(Curve3D, Resource);
struct Point {
-
Vector3 in;
Vector3 out;
Vector3 pos;
@@ -228,7 +222,6 @@ class Curve3D : public Resource {
Vector<Point> points;
struct BakedPoint {
-
float ofs;
Vector3 point;
};
diff --git a/scene/resources/cylinder_shape_3d.cpp b/scene/resources/cylinder_shape_3d.cpp
index 19f0542818..44786d6025 100644
--- a/scene/resources/cylinder_shape_3d.cpp
+++ b/scene/resources/cylinder_shape_3d.cpp
@@ -32,7 +32,6 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() {
-
float radius = get_radius();
float height = get_height();
@@ -40,7 +39,6 @@ Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() {
Vector3 d(0, height * 0.5, 0);
for (int i = 0; i < 360; i++) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
@@ -53,7 +51,6 @@ Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() {
points.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 90 == 0) {
-
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(a.x, 0, a.y) - d);
}
@@ -67,7 +64,6 @@ real_t CylinderShape3D::get_enclosing_radius() const {
}
void CylinderShape3D::_update_shape() {
-
Dictionary d;
d["radius"] = radius;
d["height"] = height;
@@ -76,7 +72,6 @@ void CylinderShape3D::_update_shape() {
}
void CylinderShape3D::set_radius(float p_radius) {
-
radius = p_radius;
_update_shape();
notify_change_to_owners();
@@ -84,12 +79,10 @@ void CylinderShape3D::set_radius(float p_radius) {
}
float CylinderShape3D::get_radius() const {
-
return radius;
}
void CylinderShape3D::set_height(float p_height) {
-
height = p_height;
_update_shape();
notify_change_to_owners();
@@ -97,12 +90,10 @@ void CylinderShape3D::set_height(float p_height) {
}
float CylinderShape3D::get_height() const {
-
return height;
}
void CylinderShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CylinderShape3D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &CylinderShape3D::get_radius);
ClassDB::bind_method(D_METHOD("set_height", "height"), &CylinderShape3D::set_height);
@@ -114,7 +105,6 @@ void CylinderShape3D::_bind_methods() {
CylinderShape3D::CylinderShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CYLINDER)) {
-
radius = 1.0;
height = 2.0;
_update_shape();
diff --git a/scene/resources/cylinder_shape_3d.h b/scene/resources/cylinder_shape_3d.h
index 7b37f733e0..23d206cbab 100644
--- a/scene/resources/cylinder_shape_3d.h
+++ b/scene/resources/cylinder_shape_3d.h
@@ -34,7 +34,6 @@
#include "scene/resources/shape_3d.h"
class CylinderShape3D : public Shape3D {
-
GDCLASS(CylinderShape3D, Shape3D);
float radius;
float height;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index a1e8bf51bd..fd5c861eb5 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -45,29 +45,16 @@ static float scale = 1;
template <class T>
static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
-
Ref<ImageTexture> texture;
if (tex_cache->has(p_src)) {
texture = (*tex_cache)[p_src];
} else {
-
texture = Ref<ImageTexture>(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
-
- if (scale > 1) {
- Size2 orig_size = Size2(img->get_width(), img->get_height());
-
- img->convert(Image::FORMAT_RGBA8);
- img->expand_x2_hq2x();
- if (scale != 2.0) {
- img->resize(orig_size.x * scale, orig_size.y * scale);
- }
- } else if (scale < 1) {
- Size2 orig_size = Size2(img->get_width(), img->get_height());
- img->convert(Image::FORMAT_RGBA8);
- img->resize(orig_size.x * scale, orig_size.y * scale);
- }
+ const Size2 orig_size = Size2(img->get_width(), img->get_height());
+ img->convert(Image::FORMAT_RGBA8);
+ img->resize(orig_size.x * scale, orig_size.y * scale);
texture->create_from_image(img);
(*tex_cache)[p_src] = texture;
@@ -89,7 +76,6 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, fl
}
static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox, float p_left, float p_top, float p_right, float p_botton) {
-
p_sbox->set_expand_margin_size(MARGIN_LEFT, p_left * scale);
p_sbox->set_expand_margin_size(MARGIN_TOP, p_top * scale);
p_sbox->set_expand_margin_size(MARGIN_RIGHT, p_right * scale);
@@ -99,29 +85,17 @@ static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox, float p_left,
template <class T>
static Ref<Texture2D> make_icon(T p_src) {
-
Ref<ImageTexture> texture(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
- if (scale > 1) {
- Size2 orig_size = Size2(img->get_width(), img->get_height());
-
- img->convert(Image::FORMAT_RGBA8);
- img->expand_x2_hq2x();
- if (scale != 2.0) {
- img->resize(orig_size.x * scale, orig_size.y * scale);
- }
- } else if (scale < 1) {
- Size2 orig_size = Size2(img->get_width(), img->get_height());
- img->convert(Image::FORMAT_RGBA8);
- img->resize(orig_size.x * scale, orig_size.y * scale);
- }
+ const Size2 orig_size = Size2(img->get_width(), img->get_height());
+ img->convert(Image::FORMAT_RGBA8);
+ img->resize(orig_size.x * scale, orig_size.y * scale);
texture->create_from_image(img);
return texture;
}
static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_charcount, const int *p_char_rects, int p_kerning_count, const int *p_kernings, int p_w, int p_h, const unsigned char *p_img) {
-
Ref<BitmapFont> font(memnew(BitmapFont));
Ref<Image> image = memnew(Image(p_img));
@@ -131,7 +105,6 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_charcount, co
font->add_texture(tex);
for (int i = 0; i < p_charcount; i++) {
-
const int *c = &p_char_rects[i * 8];
int chr = c[0];
@@ -147,7 +120,6 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_charcount, co
}
for (int i = 0; i < p_kerning_count; i++) {
-
font->add_kerning_pair(p_kernings[i * 3 + 0], p_kernings[i * 3 + 1], p_kernings[i * 3 + 2]);
}
@@ -158,7 +130,6 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_charcount, co
}
static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1) {
-
Ref<StyleBox> style(memnew(StyleBoxEmpty));
style->set_default_margin(MARGIN_LEFT, p_margin_left * scale);
@@ -170,7 +141,6 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margi
}
void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture2D> &default_icon, Ref<StyleBox> &default_style, float p_scale) {
-
scale = p_scale;
tex_cache = memnew(TexCacheMap);
@@ -711,7 +681,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_color_disabled", "TabContainer", control_font_color_disabled);
theme->set_constant("side_margin", "TabContainer", 8 * scale);
- theme->set_constant("hseparation", "TabContainer", 4 * scale);
+ theme->set_constant("icon_separation", "TabContainer", 4 * scale);
// Tabs
@@ -756,7 +726,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// FileDialog
theme->set_icon("folder", "FileDialog", make_icon(icon_folder_png));
+ theme->set_icon("file", "FileDialog", make_icon(icon_file_png));
theme->set_color("folder_icon_modulate", "FileDialog", Color(1, 1, 1));
+ theme->set_color("file_icon_modulate", "FileDialog", Color(1, 1, 1));
theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
// ColorPicker
@@ -779,8 +751,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// TooltipPanel
Ref<StyleBoxTexture> style_tt = make_stylebox(tooltip_bg_png, 4, 4, 4, 4);
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++) {
style_tt->set_expand_margin_size((Margin)i, 4 * scale);
+ }
theme->set_stylebox("panel", "TooltipPanel", style_tt);
@@ -867,7 +840,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
}
void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
-
Ref<Theme> t;
t.instance();
@@ -891,7 +863,6 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
}
void clear_default_theme() {
-
Theme::set_project_default(nullptr);
Theme::set_default(nullptr);
Theme::set_default_icon(nullptr);
diff --git a/scene/resources/default_theme/icon_file.png b/scene/resources/default_theme/icon_file.png
new file mode 100644
index 0000000000..bb4c361a8d
--- /dev/null
+++ b/scene/resources/default_theme/icon_file.png
Binary files differ
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 0a4e557451..edcdb90db9 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -150,6 +150,10 @@ static const unsigned char icon_color_pick_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0xaa, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x9d, 0x8e, 0x35, 0x82, 0x2, 0x41, 0x10, 0x45, 0x3b, 0xda, 0x3d, 0xca, 0xba, 0x44, 0x2b, 0x70, 0x9, 0xdc, 0xe1, 0x20, 0xe8, 0x91, 0x90, 0x78, 0x6e, 0x40, 0x4c, 0x82, 0x74, 0xff, 0xc2, 0x9d, 0x18, 0xa7, 0x6, 0x77, 0x7b, 0x23, 0x2d, 0xaf, 0x4c, 0xdc, 0xc, 0xbd, 0x65, 0x1e, 0x84, 0x80, 0x19, 0x55, 0x34, 0x60, 0x3e, 0xd0, 0xea, 0x17, 0x3d, 0x4a, 0xc8, 0x80, 0x1a, 0x60, 0xc2, 0x4f, 0xfd, 0x30, 0xe0, 0x1b, 0x2d, 0x16, 0xab, 0xa7, 0x2c, 0xe, 0x41, 0x68, 0xa5, 0xb9, 0xca, 0x91, 0x16, 0x2e, 0x54, 0xe0, 0x59, 0x54, 0x91, 0xfe, 0xa3, 0x3a, 0xff, 0xce, 0xab, 0x5b, 0xf, 0xa0, 0x4, 0x8f, 0x7b, 0x4c, 0xd3, 0x1b, 0xca, 0x32, 0xcc, 0x55, 0x7a, 0xf4, 0x76, 0x42, 0x2b, 0x97, 0x3e, 0xae, 0xfa, 0xdd, 0xd2, 0xd2, 0x8e, 0x72, 0xe1, 0x83, 0xaf, 0x9f, 0xa9, 0x28, 0x7d, 0x5b, 0xe2, 0x2a, 0xd, 0xc3, 0xa2, 0x78, 0xfe, 0x7d, 0x51, 0xfc, 0x0, 0x8a, 0x41, 0xcb, 0x3d, 0xb2, 0xae, 0x1c, 0xd3, 0xc, 0xa5, 0x30, 0x81, 0xc6, 0xda, 0x29, 0x8e, 0x83, 0x34, 0x25, 0x29, 0x4a, 0x46, 0x71, 0x1f, 0x33, 0xbe, 0x51, 0x89, 0xaf, 0x78, 0xe3, 0x97, 0x7e, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
+static const unsigned char icon_file_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x2, 0x3, 0x0, 0x0, 0x0, 0x62, 0x9d, 0x17, 0xf2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xe, 0xc3, 0x0, 0x0, 0xe, 0xc3, 0x1, 0xc7, 0x6f, 0xa8, 0x64, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x0, 0x0, 0x0, 0x9, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0x42, 0xf, 0xc7, 0x49, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x88, 0x95, 0xf0, 0xc6, 0x2a, 0x0, 0x0, 0x0, 0x21, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x0, 0x1, 0xae, 0x55, 0x2d, 0x20, 0xa2, 0x13, 0x44, 0x74, 0x39, 0x80, 0x88, 0x9, 0x40, 0xa2, 0x1, 0xc4, 0x5d, 0xb5, 0x80, 0x68, 0x2, 0x4, 0x0, 0x95, 0x34, 0x18, 0xe4, 0x5e, 0x46, 0xf7, 0x27, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
+};
+
static const unsigned char icon_folder_png[] = {
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x2e, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0xa0, 0x6, 0x78, 0x70, 0xf4, 0xc1, 0x7f, 0x24, 0x78, 0x18, 0x53, 0xc1, 0x7f, 0x54, 0x48, 0x50, 0xc1, 0x43, 0x1b, 0xbc, 0xa, 0x50, 0xad, 0x23, 0xa4, 0xe0, 0xff, 0x70, 0x52, 0x70, 0x18, 0x97, 0xf4, 0xfd, 0x43, 0xd4, 0x88, 0x4a, 0x0, 0x5a, 0xcb, 0x18, 0xab, 0x5e, 0xd9, 0x1a, 0x53, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 442151de36..3d99556a10 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -46,7 +46,6 @@ bool DynamicFontData::CacheID::operator<(CacheID right) const {
}
Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cache_id) {
-
if (size_cache.has(p_cache_id)) {
return Ref<DynamicFontAtSize>(size_cache[p_cache_id]);
}
@@ -65,13 +64,11 @@ Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cach
}
void DynamicFontData::set_font_ptr(const uint8_t *p_font_mem, int p_font_mem_size) {
-
font_mem = p_font_mem;
font_mem_size = p_font_mem_size;
}
void DynamicFontData::set_font_path(const String &p_path) {
-
font_path = p_path;
}
@@ -80,7 +77,6 @@ String DynamicFontData::get_font_path() const {
}
void DynamicFontData::set_force_autohinter(bool p_force) {
-
force_autohinter = p_force;
}
@@ -103,7 +99,6 @@ void DynamicFontData::_bind_methods() {
}
DynamicFontData::DynamicFontData() {
-
antialiased = true;
force_autohinter = false;
hinting = DynamicFontData::HINTING_NORMAL;
@@ -118,7 +113,6 @@ DynamicFontData::~DynamicFontData() {
HashMap<String, Vector<uint8_t>> DynamicFontAtSize::_fontdata;
Error DynamicFontAtSize::_load() {
-
int error = FT_Init_FreeType(&library);
ERR_FAIL_COND_V_MSG(error != 0, ERR_CANT_CREATE, "Error initializing FreeType.");
@@ -127,11 +121,9 @@ Error DynamicFontAtSize::_load() {
if (OS::get_singleton()->get_name() == "Android" && font->font_mem == nullptr && font->font_path != String()) {
// cache font only once for each font->font_path
if (_fontdata.has(font->font_path)) {
-
font->set_font_ptr(_fontdata[font->font_path].ptr(), _fontdata[font->font_path].size());
} else {
-
FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ);
if (!f) {
FT_Done_FreeType(library);
@@ -149,7 +141,6 @@ Error DynamicFontAtSize::_load() {
}
if (font->font_mem == nullptr && font->font_path != String()) {
-
FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ);
if (!f) {
FT_Done_FreeType(library);
@@ -170,7 +161,6 @@ Error DynamicFontAtSize::_load() {
fargs.stream = &stream;
error = FT_Open_Face(library, &fargs, 0, &face);
} else if (font->font_mem) {
-
memset(&stream, 0, sizeof(FT_StreamRec));
stream.base = (unsigned char *)font->font_mem;
stream.size = font->font_mem_size;
@@ -192,12 +182,10 @@ Error DynamicFontAtSize::_load() {
//error = FT_New_Face( library, src_path.utf8().get_data(),0,&face );
if (error == FT_Err_Unknown_File_Format) {
-
FT_Done_FreeType(library);
ERR_FAIL_V_MSG(ERR_FILE_CANT_OPEN, "Unknown font format.");
} else if (error) {
-
FT_Done_FreeType(library);
ERR_FAIL_V_MSG(ERR_FILE_CANT_OPEN, "Error loading font.");
}
@@ -232,26 +220,22 @@ Error DynamicFontAtSize::_load() {
float DynamicFontAtSize::font_oversampling = 1.0;
float DynamicFontAtSize::get_height() const {
-
return ascent + descent;
}
float DynamicFontAtSize::get_ascent() const {
-
return ascent;
}
-float DynamicFontAtSize::get_descent() const {
+float DynamicFontAtSize::get_descent() const {
return descent;
}
float DynamicFontAtSize::get_underline_position() const {
-
return underline_position;
}
float DynamicFontAtSize::get_underline_thickness() const {
-
return underline_thickness;
}
@@ -260,20 +244,20 @@ const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFon
ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(nullptr, nullptr)));
if (!chr->found) {
-
//not found, try in fallbacks
for (int i = 0; i < p_fallbacks.size(); i++) {
-
DynamicFontAtSize *fb = const_cast<DynamicFontAtSize *>(p_fallbacks[i].ptr());
- if (!fb->valid)
+ if (!fb->valid) {
continue;
+ }
fb->_update_char(p_char);
const Character *fallback_chr = fb->char_map.getptr(p_char);
ERR_CONTINUE(!fallback_chr);
- if (!fallback_chr->found)
+ if (!fallback_chr->found) {
continue;
+ }
return Pair<const Character *, DynamicFontAtSize *>(fallback_chr, fb);
}
@@ -288,9 +272,9 @@ const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFon
}
Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const {
-
- if (!valid)
+ if (!valid) {
return Size2(1, 1);
+ }
const_cast<DynamicFontAtSize *>(this)->_update_char(p_char);
Pair<const Character *, DynamicFontAtSize *> char_pair_with_font = _find_char_with_font(p_char, p_fallbacks);
@@ -307,9 +291,9 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V
}
float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only, bool p_outline) const {
-
- if (!valid)
+ if (!valid) {
return 0;
+ }
const_cast<DynamicFontAtSize *>(this)->_update_char(p_char);
@@ -358,20 +342,20 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
}
unsigned long DynamicFontAtSize::_ft_stream_io(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) {
-
FileAccess *f = (FileAccess *)stream->descriptor.pointer;
if (f->get_position() != offset) {
f->seek(offset);
}
- if (count == 0)
+ if (count == 0) {
return 0;
+ }
return f->get_buffer(buffer, count);
}
-void DynamicFontAtSize::_ft_stream_close(FT_Stream stream) {
+void DynamicFontAtSize::_ft_stream_close(FT_Stream stream) {
FileAccess *f = (FileAccess *)stream->descriptor.pointer;
f->close();
memdelete(f);
@@ -397,27 +381,27 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp
int mh = p_height;
for (int i = 0; i < textures.size(); i++) {
-
const CharTexture &ct = textures[i];
- if (ct.texture->get_format() != p_image_format)
+ if (ct.texture->get_format() != p_image_format) {
continue;
+ }
- if (mw > ct.texture_size || mh > ct.texture_size) //too big for this texture
+ if (mw > ct.texture_size || mh > ct.texture_size) { //too big for this texture
continue;
+ }
ret.y = 0x7FFFFFFF;
ret.x = 0;
for (int j = 0; j < ct.texture_size - mw; j++) {
-
int max_y = 0;
for (int k = j; k < j + mw; k++) {
-
int y = ct.offsets[k];
- if (y > max_y)
+ if (y > max_y) {
max_y = y;
+ }
}
if (max_y < ret.y) {
@@ -426,8 +410,9 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp
}
}
- if (ret.y == 0x7FFFFFFF || ret.y + mh > ct.texture_size)
+ if (ret.y == 0x7FFFFFFF || ret.y + mh > ct.texture_size) {
continue; //fail, could not fit it here
+ }
ret.index = i;
break;
@@ -439,10 +424,12 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp
ret.y = 0;
int texsize = MAX(id.size * oversampling * 8, 256);
- if (mw > texsize)
+ if (mw > texsize) {
texsize = mw; //special case, adapt to it?
- if (mh > texsize)
+ }
+ if (mh > texsize) {
texsize = mh; //special case, adapt to it?
+ }
texsize = next_power_of_2(texsize);
@@ -461,8 +448,9 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp
}
}
tex.offsets.resize(texsize);
- for (int i = 0; i < texsize; i++) //zero offsets
+ for (int i = 0; i < texsize; i++) { //zero offsets
tex.offsets.write[i] = 0;
+ }
textures.push_back(tex);
ret.index = textures.size() - 1;
@@ -496,7 +484,6 @@ DynamicFontAtSize::Character DynamicFontAtSize::_bitmap_to_character(FT_Bitmap b
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
-
int ofs = ((i + tex_pos.y + rect_margin) * tex.texture_size + j + tex_pos.x + rect_margin) * color_size;
ERR_FAIL_COND_V(ofs >= tex.imgdata.size(), Character::not_found());
switch (bitmap.pixel_mode) {
@@ -528,7 +515,6 @@ DynamicFontAtSize::Character DynamicFontAtSize::_bitmap_to_character(FT_Bitmap b
//blit to image and texture
{
-
Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, require_format, tex.imgdata));
if (tex.texture.is_null()) {
@@ -562,23 +548,28 @@ DynamicFontAtSize::Character DynamicFontAtSize::_bitmap_to_character(FT_Bitmap b
DynamicFontAtSize::Character DynamicFontAtSize::_make_outline_char(CharType p_char) {
Character ret = Character::not_found();
- if (FT_Load_Char(face, p_char, FT_LOAD_NO_BITMAP | (font->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0)) != 0)
+ if (FT_Load_Char(face, p_char, FT_LOAD_NO_BITMAP | (font->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0)) != 0) {
return ret;
+ }
FT_Stroker stroker;
- if (FT_Stroker_New(library, &stroker) != 0)
+ if (FT_Stroker_New(library, &stroker) != 0) {
return ret;
+ }
FT_Stroker_Set(stroker, (int)(id.outline_size * oversampling * 64.0), FT_STROKER_LINECAP_BUTT, FT_STROKER_LINEJOIN_ROUND, 0);
FT_Glyph glyph;
FT_BitmapGlyph glyph_bitmap;
- if (FT_Get_Glyph(face->glyph, &glyph) != 0)
+ if (FT_Get_Glyph(face->glyph, &glyph) != 0) {
goto cleanup_stroker;
- if (FT_Glyph_Stroke(&glyph, stroker, 1) != 0)
+ }
+ if (FT_Glyph_Stroke(&glyph, stroker, 1) != 0) {
goto cleanup_glyph;
- if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1) != 0)
+ }
+ if (FT_Glyph_To_Bitmap(&glyph, font->antialiased ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO, nullptr, 1) != 0) {
goto cleanup_glyph;
+ }
glyph_bitmap = (FT_BitmapGlyph)glyph;
ret = _bitmap_to_character(glyph_bitmap->bitmap, glyph_bitmap->top, glyph_bitmap->left, glyph->advance.x / 65536.0);
@@ -591,9 +582,9 @@ cleanup_stroker:
}
void DynamicFontAtSize::_update_char(CharType p_char) {
-
- if (char_map.has(p_char))
+ if (char_map.has(p_char)) {
return;
+ }
_THREAD_SAFE_METHOD_
@@ -630,16 +621,18 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
character = _make_outline_char(p_char);
} else {
error = FT_Render_Glyph(face->glyph, font->antialiased ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO);
- if (!error)
+ if (!error) {
character = _bitmap_to_character(slot->bitmap, slot->bitmap_top, slot->bitmap_left, slot->advance.x / 64.0);
+ }
}
char_map[p_char] = character;
}
void DynamicFontAtSize::update_oversampling() {
- if (oversampling == font_oversampling || !valid)
+ if (oversampling == font_oversampling || !valid) {
return;
+ }
FT_Done_FreeType(library);
textures.clear();
@@ -650,7 +643,6 @@ void DynamicFontAtSize::update_oversampling() {
}
DynamicFontAtSize::DynamicFontAtSize() {
-
valid = false;
rect_margin = 1;
ascent = 1;
@@ -661,7 +653,6 @@ DynamicFontAtSize::DynamicFontAtSize() {
}
DynamicFontAtSize::~DynamicFontAtSize() {
-
if (valid) {
FT_Done_FreeType(library);
}
@@ -672,7 +663,6 @@ DynamicFontAtSize::~DynamicFontAtSize() {
/////////////////////////
void DynamicFont::_reload_cache() {
-
ERR_FAIL_COND(cache_id.size < 1);
if (!data.is_valid()) {
data_at_size.unref();
@@ -694,8 +684,9 @@ void DynamicFont::_reload_cache() {
for (int i = 0; i < fallbacks.size(); i++) {
fallback_data_at_size.write[i] = fallbacks.write[i]->_get_dynamic_font_at_size(cache_id);
- if (outline_cache_id.outline_size > 0)
+ if (outline_cache_id.outline_size > 0) {
fallback_outline_data_at_size.write[i] = fallbacks.write[i]->_get_dynamic_font_at_size(outline_cache_id);
+ }
}
emit_changed();
@@ -703,7 +694,6 @@ void DynamicFont::_reload_cache() {
}
void DynamicFont::set_font_data(const Ref<DynamicFontData> &p_data) {
-
data = p_data;
_reload_cache();
@@ -712,27 +702,26 @@ void DynamicFont::set_font_data(const Ref<DynamicFontData> &p_data) {
}
Ref<DynamicFontData> DynamicFont::get_font_data() const {
-
return data;
}
void DynamicFont::set_size(int p_size) {
-
- if (cache_id.size == p_size)
+ if (cache_id.size == p_size) {
return;
+ }
cache_id.size = p_size;
outline_cache_id.size = p_size;
_reload_cache();
}
int DynamicFont::get_size() const {
-
return cache_id.size;
}
void DynamicFont::set_outline_size(int p_size) {
- if (outline_cache_id.outline_size == p_size)
+ if (outline_cache_id.outline_size == p_size) {
return;
+ }
ERR_FAIL_COND(p_size < 0 || p_size > UINT8_MAX);
outline_cache_id.outline_size = p_size;
_reload_cache();
@@ -755,31 +744,28 @@ Color DynamicFont::get_outline_color() const {
}
bool DynamicFontData::is_antialiased() const {
-
return antialiased;
}
void DynamicFontData::set_antialiased(bool p_antialiased) {
-
- if (antialiased == p_antialiased)
+ if (antialiased == p_antialiased) {
return;
+ }
antialiased = p_antialiased;
}
DynamicFontData::Hinting DynamicFontData::get_hinting() const {
-
return hinting;
}
void DynamicFontData::set_hinting(Hinting p_hinting) {
-
- if (hinting == p_hinting)
+ if (hinting == p_hinting) {
return;
+ }
hinting = p_hinting;
}
int DynamicFont::get_spacing(int p_type) const {
-
if (p_type == SPACING_TOP) {
return spacing_top;
} else if (p_type == SPACING_BOTTOM) {
@@ -794,7 +780,6 @@ int DynamicFont::get_spacing(int p_type) const {
}
void DynamicFont::set_spacing(int p_type, int p_value) {
-
if (p_type == SPACING_TOP) {
spacing_top = p_value;
} else if (p_type == SPACING_BOTTOM) {
@@ -810,61 +795,61 @@ void DynamicFont::set_spacing(int p_type, int p_value) {
}
float DynamicFont::get_height() const {
-
- if (!data_at_size.is_valid())
+ if (!data_at_size.is_valid()) {
return 1;
+ }
return data_at_size->get_height() + spacing_top + spacing_bottom;
}
float DynamicFont::get_ascent() const {
-
- if (!data_at_size.is_valid())
+ if (!data_at_size.is_valid()) {
return 1;
+ }
return data_at_size->get_ascent() + spacing_top;
}
float DynamicFont::get_descent() const {
-
- if (!data_at_size.is_valid())
+ if (!data_at_size.is_valid()) {
return 1;
+ }
return data_at_size->get_descent() + spacing_bottom;
}
float DynamicFont::get_underline_position() const {
-
- if (!data_at_size.is_valid())
+ if (!data_at_size.is_valid()) {
return 2;
+ }
return data_at_size->get_underline_position();
}
float DynamicFont::get_underline_thickness() const {
-
- if (!data_at_size.is_valid())
+ if (!data_at_size.is_valid()) {
return 1;
+ }
return data_at_size->get_underline_thickness();
}
Size2 DynamicFont::get_char_size(CharType p_char, CharType p_next) const {
-
- if (!data_at_size.is_valid())
+ if (!data_at_size.is_valid()) {
return Size2(1, 1);
+ }
Size2 ret = data_at_size->get_char_size(p_char, p_next, fallback_data_at_size);
- if (p_char == ' ')
+ if (p_char == ' ') {
ret.width += spacing_space + spacing_char;
- else if (p_next)
+ } else if (p_next) {
ret.width += spacing_char;
+ }
return ret;
}
bool DynamicFont::is_distance_field_hint() const {
-
return false;
}
@@ -875,8 +860,9 @@ bool DynamicFont::has_outline() const {
float DynamicFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, bool p_outline) const {
const Ref<DynamicFontAtSize> &font_at_size = p_outline && outline_cache_id.outline_size > 0 ? outline_data_at_size : data_at_size;
- if (!font_at_size.is_valid())
+ if (!font_at_size.is_valid()) {
return 0;
+ }
const Vector<Ref<DynamicFontAtSize>> &fallbacks = p_outline && outline_cache_id.outline_size > 0 ? fallback_outline_data_at_size : fallback_data_at_size;
Color color = p_outline && outline_cache_id.outline_size > 0 ? p_modulate * outline_color : p_modulate;
@@ -887,7 +873,6 @@ float DynamicFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_
}
void DynamicFont::set_fallback(int p_idx, const Ref<DynamicFontData> &p_data) {
-
ERR_FAIL_COND(p_data.is_null());
ERR_FAIL_INDEX(p_idx, fallbacks.size());
fallbacks.write[p_idx] = p_data;
@@ -895,12 +880,12 @@ void DynamicFont::set_fallback(int p_idx, const Ref<DynamicFontData> &p_data) {
}
void DynamicFont::add_fallback(const Ref<DynamicFontData> &p_data) {
-
ERR_FAIL_COND(p_data.is_null());
fallbacks.push_back(p_data);
fallback_data_at_size.push_back(fallbacks.write[fallbacks.size() - 1]->_get_dynamic_font_at_size(cache_id)); //const..
- if (outline_cache_id.outline_size > 0)
+ if (outline_cache_id.outline_size > 0) {
fallback_outline_data_at_size.push_back(fallbacks.write[fallbacks.size() - 1]->_get_dynamic_font_at_size(outline_cache_id));
+ }
_change_notify();
emit_changed();
@@ -910,14 +895,14 @@ void DynamicFont::add_fallback(const Ref<DynamicFontData> &p_data) {
int DynamicFont::get_fallback_count() const {
return fallbacks.size();
}
-Ref<DynamicFontData> DynamicFont::get_fallback(int p_idx) const {
+Ref<DynamicFontData> DynamicFont::get_fallback(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, fallbacks.size(), Ref<DynamicFontData>());
return fallbacks[p_idx];
}
-void DynamicFont::remove_fallback(int p_idx) {
+void DynamicFont::remove_fallback(int p_idx) {
ERR_FAIL_INDEX(p_idx, fallbacks.size());
fallbacks.remove(p_idx);
fallback_data_at_size.remove(p_idx);
@@ -926,7 +911,6 @@ void DynamicFont::remove_fallback(int p_idx) {
}
bool DynamicFont::_set(const StringName &p_name, const Variant &p_value) {
-
String str = p_name;
if (str.begins_with("fallback/")) {
int idx = str.get_slicec('/', 1).to_int();
@@ -952,7 +936,6 @@ bool DynamicFont::_set(const StringName &p_name, const Variant &p_value) {
}
bool DynamicFont::_get(const StringName &p_name, Variant &r_ret) const {
-
String str = p_name;
if (str.begins_with("fallback/")) {
int idx = str.get_slicec('/', 1).to_int();
@@ -968,8 +951,8 @@ bool DynamicFont::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void DynamicFont::_get_property_list(List<PropertyInfo> *p_list) const {
+void DynamicFont::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < fallbacks.size(); i++) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "fallback/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "DynamicFontData"));
}
@@ -978,7 +961,6 @@ void DynamicFont::_get_property_list(List<PropertyInfo> *p_list) const {
}
void DynamicFont::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_font_data", "data"), &DynamicFont::set_font_data);
ClassDB::bind_method(D_METHOD("get_font_data"), &DynamicFont::get_font_data);
@@ -1024,7 +1006,6 @@ SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = nullptr;
DynamicFont::DynamicFont() :
font_list(this) {
-
valid = false;
cache_id.size = 16;
outline_cache_id.size = 16;
@@ -1053,14 +1034,12 @@ void DynamicFont::finish_dynamic_fonts() {
}
void DynamicFont::update_oversampling() {
-
Vector<Ref<DynamicFont>> changed;
{
MutexLock lock(dynamic_font_mutex);
SelfList<DynamicFont> *E = dynamic_fonts->first();
while (E) {
-
if (E->self()->data_at_size.is_valid()) {
E->self()->data_at_size->update_oversampling();
@@ -1093,36 +1072,35 @@ void DynamicFont::update_oversampling() {
/////////////////////////
RES ResourceFormatLoaderDynamicFont::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)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
Ref<DynamicFontData> dfont;
dfont.instance();
dfont->set_font_path(p_path);
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return dfont;
}
void ResourceFormatLoaderDynamicFont::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("ttf");
p_extensions->push_back("otf");
}
bool ResourceFormatLoaderDynamicFont::handles_type(const String &p_type) const {
-
return (p_type == "DynamicFontData");
}
String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "ttf" || el == "otf")
+ if (el == "ttf" || el == "otf") {
return "DynamicFontData";
+ }
return "";
}
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index 2fa1951d27..08ad20a92d 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -47,7 +47,6 @@ class DynamicFontAtSize;
class DynamicFont;
class DynamicFontData : public Resource {
-
GDCLASS(DynamicFontData, Resource);
public:
@@ -109,7 +108,6 @@ public:
VARIANT_ENUM_CAST(DynamicFontData::Hinting);
class DynamicFontAtSize : public Reference {
-
GDCLASS(DynamicFontAtSize, Reference);
_THREAD_SAFE_CLASS_
@@ -130,7 +128,6 @@ class DynamicFontAtSize : public Reference {
bool valid;
struct CharTexture {
-
Vector<uint8_t> imgdata;
int texture_size;
Vector<int> offsets;
@@ -140,7 +137,6 @@ class DynamicFontAtSize : public Reference {
Vector<CharTexture> textures;
struct Character {
-
bool found;
int texture_idx;
Rect2 rect;
@@ -206,7 +202,6 @@ public:
///////////////
class DynamicFont : public Font {
-
GDCLASS(DynamicFont, Font);
public:
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 02ea5b24b8..80ee0c148d 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -34,60 +34,57 @@
#include "texture.h"
RID Environment::get_rid() const {
-
return environment;
}
void Environment::set_background(BGMode p_bg) {
-
bg_mode = p_bg;
RS::get_singleton()->environment_set_background(environment, RS::EnvironmentBG(p_bg));
_change_notify();
}
void Environment::set_sky(const Ref<Sky> &p_sky) {
-
bg_sky = p_sky;
RID sb_rid;
- if (bg_sky.is_valid())
+ if (bg_sky.is_valid()) {
sb_rid = bg_sky->get_rid();
+ }
RS::get_singleton()->environment_set_sky(environment, sb_rid);
}
void Environment::set_sky_custom_fov(float p_scale) {
-
bg_sky_custom_fov = p_scale;
RS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale);
}
-void Environment::set_bg_color(const Color &p_color) {
+void Environment::set_bg_color(const Color &p_color) {
bg_color = p_color;
RS::get_singleton()->environment_set_bg_color(environment, p_color);
}
-void Environment::set_bg_energy(float p_energy) {
+void Environment::set_bg_energy(float p_energy) {
bg_energy = p_energy;
RS::get_singleton()->environment_set_bg_energy(environment, p_energy);
}
-void Environment::set_canvas_max_layer(int p_max_layer) {
+void Environment::set_canvas_max_layer(int p_max_layer) {
bg_canvas_max_layer = p_max_layer;
RS::get_singleton()->environment_set_canvas_max_layer(environment, p_max_layer);
}
-void Environment::set_ambient_light_color(const Color &p_color) {
+void Environment::set_ambient_light_color(const Color &p_color) {
ambient_color = p_color;
RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
-void Environment::set_ambient_light_energy(float p_energy) {
+void Environment::set_ambient_light_energy(float p_energy) {
ambient_energy = p_energy;
RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
-void Environment::set_ambient_light_sky_contribution(float p_energy) {
+void Environment::set_ambient_light_sky_contribution(float p_energy) {
ambient_sky_contribution = p_energy;
RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
@@ -108,25 +105,25 @@ void Environment::set_ambient_source(AmbientSource p_source) {
Environment::AmbientSource Environment::get_ambient_source() const {
return ambient_source;
}
+
void Environment::set_reflection_source(ReflectionSource p_source) {
reflection_source = p_source;
RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
+
Environment::ReflectionSource Environment::get_reflection_source() const {
return reflection_source;
}
Environment::BGMode Environment::get_background() const {
-
return bg_mode;
}
-Ref<Sky> Environment::get_sky() const {
+Ref<Sky> Environment::get_sky() const {
return bg_sky;
}
float Environment::get_sky_custom_fov() const {
-
return bg_sky_custom_fov;
}
@@ -136,176 +133,157 @@ void Environment::set_sky_rotation(const Vector3 &p_rotation) {
}
Vector3 Environment::get_sky_rotation() const {
-
return sky_rotation;
}
Color Environment::get_bg_color() const {
-
return bg_color;
}
-float Environment::get_bg_energy() const {
+float Environment::get_bg_energy() const {
return bg_energy;
}
-int Environment::get_canvas_max_layer() const {
+int Environment::get_canvas_max_layer() const {
return bg_canvas_max_layer;
}
-Color Environment::get_ambient_light_color() const {
+Color Environment::get_ambient_light_color() const {
return ambient_color;
}
-float Environment::get_ambient_light_energy() const {
+float Environment::get_ambient_light_energy() const {
return ambient_energy;
}
-float Environment::get_ambient_light_sky_contribution() const {
+float Environment::get_ambient_light_sky_contribution() const {
return ambient_sky_contribution;
}
-int Environment::get_camera_feed_id(void) const {
+int Environment::get_camera_feed_id() const {
return camera_feed_id;
}
void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
-
tone_mapper = p_tone_mapper;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
Environment::ToneMapper Environment::get_tonemapper() const {
-
return tone_mapper;
}
void Environment::set_tonemap_exposure(float p_exposure) {
-
tonemap_exposure = p_exposure;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
float Environment::get_tonemap_exposure() const {
-
return tonemap_exposure;
}
void Environment::set_tonemap_white(float p_white) {
-
tonemap_white = p_white;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
-float Environment::get_tonemap_white() const {
+float Environment::get_tonemap_white() const {
return tonemap_white;
}
void Environment::set_tonemap_auto_exposure(bool p_enabled) {
-
tonemap_auto_exposure = p_enabled;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
_change_notify();
}
-bool Environment::get_tonemap_auto_exposure() const {
+bool Environment::get_tonemap_auto_exposure() const {
return tonemap_auto_exposure;
}
void Environment::set_tonemap_auto_exposure_max(float p_auto_exposure_max) {
-
tonemap_auto_exposure_max = p_auto_exposure_max;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
-float Environment::get_tonemap_auto_exposure_max() const {
+float Environment::get_tonemap_auto_exposure_max() const {
return tonemap_auto_exposure_max;
}
void Environment::set_tonemap_auto_exposure_min(float p_auto_exposure_min) {
-
tonemap_auto_exposure_min = p_auto_exposure_min;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
-float Environment::get_tonemap_auto_exposure_min() const {
+float Environment::get_tonemap_auto_exposure_min() const {
return tonemap_auto_exposure_min;
}
void Environment::set_tonemap_auto_exposure_speed(float p_auto_exposure_speed) {
-
tonemap_auto_exposure_speed = p_auto_exposure_speed;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
-float Environment::get_tonemap_auto_exposure_speed() const {
+float Environment::get_tonemap_auto_exposure_speed() const {
return tonemap_auto_exposure_speed;
}
void Environment::set_tonemap_auto_exposure_grey(float p_auto_exposure_grey) {
-
tonemap_auto_exposure_grey = p_auto_exposure_grey;
RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
}
-float Environment::get_tonemap_auto_exposure_grey() const {
+float Environment::get_tonemap_auto_exposure_grey() const {
return tonemap_auto_exposure_grey;
}
void Environment::set_adjustment_enable(bool p_enable) {
-
adjustment_enabled = p_enable;
RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
_change_notify();
}
bool Environment::is_adjustment_enabled() const {
-
return adjustment_enabled;
}
void Environment::set_adjustment_brightness(float p_brightness) {
-
adjustment_brightness = p_brightness;
RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
}
-float Environment::get_adjustment_brightness() const {
+float Environment::get_adjustment_brightness() const {
return adjustment_brightness;
}
void Environment::set_adjustment_contrast(float p_contrast) {
-
adjustment_contrast = p_contrast;
RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
}
-float Environment::get_adjustment_contrast() const {
+float Environment::get_adjustment_contrast() const {
return adjustment_contrast;
}
void Environment::set_adjustment_saturation(float p_saturation) {
-
adjustment_saturation = p_saturation;
RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
}
-float Environment::get_adjustment_saturation() const {
+float Environment::get_adjustment_saturation() const {
return adjustment_saturation;
}
void Environment::set_adjustment_color_correction(const Ref<Texture2D> &p_ramp) {
-
adjustment_color_correction = p_ramp;
RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
}
-Ref<Texture2D> Environment::get_adjustment_color_correction() const {
+Ref<Texture2D> Environment::get_adjustment_color_correction() const {
return adjustment_color_correction;
}
void Environment::_validate_property(PropertyInfo &property) const {
-
if (property.name == "sky" || property.name == "sky_custom_fov" || property.name == "sky_rotation" || property.name == "ambient_light/sky_contribution") {
if (bg_mode != BG_SKY && ambient_source != AMBIENT_SOURCE_SKY && reflection_source != REFLECTION_SOURCE_SKY) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
@@ -387,409 +365,364 @@ void Environment::_validate_property(PropertyInfo &property) const {
}
void Environment::set_ssr_enabled(bool p_enable) {
-
ssr_enabled = p_enable;
RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance);
_change_notify();
}
bool Environment::is_ssr_enabled() const {
-
return ssr_enabled;
}
void Environment::set_ssr_max_steps(int p_steps) {
-
ssr_max_steps = p_steps;
RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance);
}
-int Environment::get_ssr_max_steps() const {
+int Environment::get_ssr_max_steps() const {
return ssr_max_steps;
}
void Environment::set_ssr_fade_in(float p_fade_in) {
-
ssr_fade_in = p_fade_in;
RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance);
}
-float Environment::get_ssr_fade_in() const {
+float Environment::get_ssr_fade_in() const {
return ssr_fade_in;
}
void Environment::set_ssr_fade_out(float p_fade_out) {
-
ssr_fade_out = p_fade_out;
RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance);
}
-float Environment::get_ssr_fade_out() const {
+float Environment::get_ssr_fade_out() const {
return ssr_fade_out;
}
void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) {
-
ssr_depth_tolerance = p_depth_tolerance;
RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance);
}
-float Environment::get_ssr_depth_tolerance() const {
+float Environment::get_ssr_depth_tolerance() const {
return ssr_depth_tolerance;
}
void Environment::set_ssao_enabled(bool p_enable) {
-
ssao_enabled = p_enable;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
_change_notify();
}
bool Environment::is_ssao_enabled() const {
-
return ssao_enabled;
}
void Environment::set_ssao_radius(float p_radius) {
-
ssao_radius = p_radius;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
-float Environment::get_ssao_radius() const {
+float Environment::get_ssao_radius() const {
return ssao_radius;
}
void Environment::set_ssao_intensity(float p_intensity) {
-
ssao_intensity = p_intensity;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_intensity() const {
-
return ssao_intensity;
}
void Environment::set_ssao_bias(float p_bias) {
-
ssao_bias = p_bias;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
-float Environment::get_ssao_bias() const {
+float Environment::get_ssao_bias() const {
return ssao_bias;
}
void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) {
-
ssao_direct_light_affect = p_direct_light_affect;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
-float Environment::get_ssao_direct_light_affect() const {
+float Environment::get_ssao_direct_light_affect() const {
return ssao_direct_light_affect;
}
void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) {
-
ssao_ao_channel_affect = p_ao_channel_affect;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
-float Environment::get_ssao_ao_channel_affect() const {
+float Environment::get_ssao_ao_channel_affect() const {
return ssao_ao_channel_affect;
}
void Environment::set_ao_color(const Color &p_color) {
-
ao_color = p_color;
RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color);
}
Color Environment::get_ao_color() const {
-
return ao_color;
}
void Environment::set_ssao_blur(SSAOBlur p_blur) {
-
ssao_blur = p_blur;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
-Environment::SSAOBlur Environment::get_ssao_blur() const {
+Environment::SSAOBlur Environment::get_ssao_blur() const {
return ssao_blur;
}
void Environment::set_ssao_edge_sharpness(float p_edge_sharpness) {
-
ssao_edge_sharpness = p_edge_sharpness;
RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
}
float Environment::get_ssao_edge_sharpness() const {
-
return ssao_edge_sharpness;
}
void Environment::set_glow_enabled(bool p_enabled) {
-
glow_enabled = p_enabled;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
_change_notify();
}
bool Environment::is_glow_enabled() const {
-
return glow_enabled;
}
void Environment::set_glow_level(int p_level, bool p_enabled) {
-
ERR_FAIL_INDEX(p_level, RS::MAX_GLOW_LEVELS);
- if (p_enabled)
+ if (p_enabled) {
glow_levels |= (1 << p_level);
- else
+ } else {
glow_levels &= ~(1 << p_level);
+ }
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-bool Environment::is_glow_level_enabled(int p_level) const {
+bool Environment::is_glow_level_enabled(int p_level) const {
ERR_FAIL_INDEX_V(p_level, RS::MAX_GLOW_LEVELS, false);
return glow_levels & (1 << p_level);
}
void Environment::set_glow_intensity(float p_intensity) {
-
glow_intensity = p_intensity;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_intensity() const {
+float Environment::get_glow_intensity() const {
return glow_intensity;
}
void Environment::set_glow_strength(float p_strength) {
-
glow_strength = p_strength;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_strength() const {
+float Environment::get_glow_strength() const {
return glow_strength;
}
void Environment::set_glow_mix(float p_mix) {
-
glow_mix = p_mix;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_mix() const {
+float Environment::get_glow_mix() const {
return glow_mix;
}
void Environment::set_glow_bloom(float p_threshold) {
-
glow_bloom = p_threshold;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_bloom() const {
+float Environment::get_glow_bloom() const {
return glow_bloom;
}
void Environment::set_glow_blend_mode(GlowBlendMode p_mode) {
-
glow_blend_mode = p_mode;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
_change_notify();
}
-Environment::GlowBlendMode Environment::get_glow_blend_mode() const {
+Environment::GlowBlendMode Environment::get_glow_blend_mode() const {
return glow_blend_mode;
}
void Environment::set_glow_hdr_bleed_threshold(float p_threshold) {
-
glow_hdr_bleed_threshold = p_threshold;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_hdr_bleed_threshold() const {
+float Environment::get_glow_hdr_bleed_threshold() const {
return glow_hdr_bleed_threshold;
}
void Environment::set_glow_hdr_luminance_cap(float p_amount) {
-
glow_hdr_luminance_cap = p_amount;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_hdr_luminance_cap() const {
+float Environment::get_glow_hdr_luminance_cap() const {
return glow_hdr_luminance_cap;
}
void Environment::set_glow_hdr_bleed_scale(float p_scale) {
-
glow_hdr_bleed_scale = p_scale;
RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap);
}
-float Environment::get_glow_hdr_bleed_scale() const {
+float Environment::get_glow_hdr_bleed_scale() const {
return glow_hdr_bleed_scale;
}
void Environment::set_fog_enabled(bool p_enabled) {
-
fog_enabled = p_enabled;
RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
_change_notify();
}
bool Environment::is_fog_enabled() const {
-
return fog_enabled;
}
void Environment::set_fog_color(const Color &p_color) {
-
fog_color = p_color;
RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
}
-Color Environment::get_fog_color() const {
+Color Environment::get_fog_color() const {
return fog_color;
}
void Environment::set_fog_sun_color(const Color &p_color) {
-
fog_sun_color = p_color;
RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
}
-Color Environment::get_fog_sun_color() const {
+Color Environment::get_fog_sun_color() const {
return fog_sun_color;
}
void Environment::set_fog_sun_amount(float p_amount) {
-
fog_sun_amount = p_amount;
RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
}
-float Environment::get_fog_sun_amount() const {
+float Environment::get_fog_sun_amount() const {
return fog_sun_amount;
}
void Environment::set_fog_depth_enabled(bool p_enabled) {
-
fog_depth_enabled = p_enabled;
RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
-bool Environment::is_fog_depth_enabled() const {
+bool Environment::is_fog_depth_enabled() const {
return fog_depth_enabled;
}
void Environment::set_fog_depth_begin(float p_distance) {
-
fog_depth_begin = p_distance;
RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
-float Environment::get_fog_depth_begin() const {
+float Environment::get_fog_depth_begin() const {
return fog_depth_begin;
}
void Environment::set_fog_depth_end(float p_distance) {
-
fog_depth_end = p_distance;
RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
float Environment::get_fog_depth_end() const {
-
return fog_depth_end;
}
void Environment::set_fog_depth_curve(float p_curve) {
-
fog_depth_curve = p_curve;
RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
-float Environment::get_fog_depth_curve() const {
+float Environment::get_fog_depth_curve() const {
return fog_depth_curve;
}
void Environment::set_fog_transmit_enabled(bool p_enabled) {
-
fog_transmit_enabled = p_enabled;
RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
-bool Environment::is_fog_transmit_enabled() const {
+bool Environment::is_fog_transmit_enabled() const {
return fog_transmit_enabled;
}
void Environment::set_fog_transmit_curve(float p_curve) {
-
fog_transmit_curve = p_curve;
RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
}
-float Environment::get_fog_transmit_curve() const {
+float Environment::get_fog_transmit_curve() const {
return fog_transmit_curve;
}
void Environment::set_fog_height_enabled(bool p_enabled) {
-
fog_height_enabled = p_enabled;
RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
-bool Environment::is_fog_height_enabled() const {
+bool Environment::is_fog_height_enabled() const {
return fog_height_enabled;
}
void Environment::set_fog_height_min(float p_distance) {
-
fog_height_min = p_distance;
RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
-float Environment::get_fog_height_min() const {
+float Environment::get_fog_height_min() const {
return fog_height_min;
}
void Environment::set_fog_height_max(float p_distance) {
-
fog_height_max = p_distance;
RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
-float Environment::get_fog_height_max() const {
+float Environment::get_fog_height_max() const {
return fog_height_max;
}
void Environment::set_fog_height_curve(float p_distance) {
-
fog_height_curve = p_distance;
RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
}
-float Environment::get_fog_height_curve() const {
+float Environment::get_fog_height_curve() const {
return fog_height_curve;
}
@@ -813,7 +746,6 @@ bool Environment::_set(const StringName &p_name, const Variant &p_value) {
#endif
void Environment::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background);
ClassDB::bind_method(D_METHOD("set_sky", "sky"), &Environment::set_sky);
ClassDB::bind_method(D_METHOD("set_sky_custom_fov", "scale"), &Environment::set_sky_custom_fov);
@@ -1117,12 +1049,7 @@ void Environment::_bind_methods() {
BIND_ENUM_CONSTANT(SSAO_BLUR_3x3);
}
-Environment::Environment() :
- bg_mode(BG_CLEAR_COLOR),
- tone_mapper(TONE_MAPPER_LINEAR),
- ssao_blur(SSAO_BLUR_3x3),
- glow_blend_mode(GLOW_BLEND_MODE_ADDITIVE) {
-
+Environment::Environment() {
environment = RS::get_singleton()->environment_create();
bg_mode = BG_CLEAR_COLOR;
@@ -1204,84 +1131,72 @@ Environment::Environment() :
}
Environment::~Environment() {
-
RS::get_singleton()->free(environment);
}
//////////////////////
void CameraEffects::set_dof_blur_far_enabled(bool p_enable) {
-
dof_blur_far_enabled = p_enable;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
bool CameraEffects::is_dof_blur_far_enabled() const {
-
return dof_blur_far_enabled;
}
void CameraEffects::set_dof_blur_far_distance(float p_distance) {
-
dof_blur_far_distance = p_distance;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
-float CameraEffects::get_dof_blur_far_distance() const {
+float CameraEffects::get_dof_blur_far_distance() const {
return dof_blur_far_distance;
}
void CameraEffects::set_dof_blur_far_transition(float p_distance) {
-
dof_blur_far_transition = p_distance;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
-float CameraEffects::get_dof_blur_far_transition() const {
+float CameraEffects::get_dof_blur_far_transition() const {
return dof_blur_far_transition;
}
void CameraEffects::set_dof_blur_near_enabled(bool p_enable) {
-
dof_blur_near_enabled = p_enable;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
_change_notify();
}
bool CameraEffects::is_dof_blur_near_enabled() const {
-
return dof_blur_near_enabled;
}
void CameraEffects::set_dof_blur_near_distance(float p_distance) {
-
dof_blur_near_distance = p_distance;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_near_distance() const {
-
return dof_blur_near_distance;
}
void CameraEffects::set_dof_blur_near_transition(float p_distance) {
-
dof_blur_near_transition = p_distance;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
float CameraEffects::get_dof_blur_near_transition() const {
-
return dof_blur_near_transition;
}
void CameraEffects::set_dof_blur_amount(float p_amount) {
-
dof_blur_amount = p_amount;
RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount);
}
-float CameraEffects::get_dof_blur_amount() const {
+float CameraEffects::get_dof_blur_amount() const {
return dof_blur_amount;
}
@@ -1308,7 +1223,6 @@ RID CameraEffects::get_rid() const {
}
void CameraEffects::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_dof_blur_far_enabled", "enabled"), &CameraEffects::set_dof_blur_far_enabled);
ClassDB::bind_method(D_METHOD("is_dof_blur_far_enabled"), &CameraEffects::is_dof_blur_far_enabled);
@@ -1350,7 +1264,6 @@ void CameraEffects::_bind_methods() {
}
CameraEffects::CameraEffects() {
-
camera_effects = RS::get_singleton()->camera_effects_create();
dof_blur_far_enabled = false;
@@ -1368,6 +1281,5 @@ CameraEffects::CameraEffects() {
}
CameraEffects::~CameraEffects() {
-
RS::get_singleton()->free(camera_effects);
}
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 02434bc592..b8caa59aab 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -37,7 +37,6 @@
#include "servers/rendering_server.h"
class Environment : public Resource {
-
GDCLASS(Environment, Resource);
public:
@@ -90,7 +89,7 @@ public:
private:
RID environment;
- BGMode bg_mode;
+ BGMode bg_mode = BG_CLEAR_COLOR;
Ref<Sky> bg_sky;
float bg_sky_custom_fov;
Vector3 sky_rotation;
@@ -105,7 +104,7 @@ private:
AmbientSource ambient_source;
ReflectionSource reflection_source;
- ToneMapper tone_mapper;
+ ToneMapper tone_mapper = TONE_MAPPER_LINEAR;
float tonemap_exposure;
float tonemap_white;
bool tonemap_auto_exposure;
@@ -132,7 +131,7 @@ private:
float ssao_bias;
float ssao_direct_light_affect;
float ssao_ao_channel_affect;
- SSAOBlur ssao_blur;
+ SSAOBlur ssao_blur = SSAO_BLUR_3x3;
float ssao_edge_sharpness;
bool glow_enabled;
@@ -141,7 +140,7 @@ private:
float glow_strength;
float glow_mix;
float glow_bloom;
- GlowBlendMode glow_blend_mode;
+ GlowBlendMode glow_blend_mode = GLOW_BLEND_MODE_ADDITIVE;
float glow_hdr_bleed_threshold;
float glow_hdr_bleed_scale;
float glow_hdr_luminance_cap;
@@ -200,7 +199,7 @@ public:
Color get_ambient_light_color() const;
float get_ambient_light_energy() const;
float get_ambient_light_sky_contribution() const;
- int get_camera_feed_id(void) const;
+ int get_camera_feed_id() const;
void set_tonemapper(ToneMapper p_tone_mapper);
ToneMapper get_tonemapper() const;
@@ -369,7 +368,6 @@ VARIANT_ENUM_CAST(Environment::GlowBlendMode)
VARIANT_ENUM_CAST(Environment::SSAOBlur)
class CameraEffects : public Resource {
-
GDCLASS(CameraEffects, Resource);
private:
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 51c2ff389a..ccab88a153 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -65,11 +65,11 @@ void Font::draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, co
int chars_drawn = 0;
bool with_outline = has_outline();
for (int i = 0; i < p_text.length(); i++) {
-
int width = get_char_size(p_text[i]).width;
- if (p_clip_w >= 0 && (ofs.x + width) > p_clip_w)
+ if (p_clip_w >= 0 && (ofs.x + width) > p_clip_w) {
break; //clip
+ }
ofs.x += draw_char(p_canvas_item, p_pos + ofs, p_text[i], p_text[i + 1], with_outline ? p_outline_modulate : p_modulate, with_outline);
++chars_drawn;
@@ -84,17 +84,16 @@ void Font::draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, co
}
void Font::update_changes() {
-
emit_changed();
}
void Font::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "string", "modulate", "clip_w", "outline_modulate"), &Font::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(-1), DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("get_ascent"), &Font::get_ascent);
ClassDB::bind_method(D_METHOD("get_descent"), &Font::get_descent);
ClassDB::bind_method(D_METHOD("get_height"), &Font::get_height);
ClassDB::bind_method(D_METHOD("is_distance_field_hint"), &Font::is_distance_field_hint);
+ ClassDB::bind_method(D_METHOD("get_char_size", "char", "next"), &Font::get_char_size, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_string_size", "string"), &Font::get_string_size);
ClassDB::bind_method(D_METHOD("get_wordwrap_string_size", "string", "width"), &Font::get_wordwrap_string_size);
ClassDB::bind_method(D_METHOD("has_outline"), &Font::has_outline);
@@ -108,30 +107,27 @@ Font::Font() {
/////////////////////////////////////////////////////////////////
void BitmapFont::_set_chars(const Vector<int> &p_chars) {
-
int len = p_chars.size();
//char 1 charsize 1 texture, 4 rect, 2 align, advance 1
ERR_FAIL_COND(len % 9);
- if (!len)
+ if (!len) {
return; //none to do
+ }
int chars = len / 9;
const int *r = p_chars.ptr();
for (int i = 0; i < chars; i++) {
-
const int *data = &r[i * 9];
add_char(data[0], data[1], Rect2(data[2], data[3], data[4], data[5]), Size2(data[6], data[7]), data[8]);
}
}
Vector<int> BitmapFont::_get_chars() const {
-
Vector<int> chars;
const CharType *key = nullptr;
while ((key = char_map.next(key))) {
-
const Character *c = char_map.getptr(*key);
ERR_FAIL_COND_V(!c, Vector<int>());
chars.push_back(*key);
@@ -150,26 +146,23 @@ Vector<int> BitmapFont::_get_chars() const {
}
void BitmapFont::_set_kernings(const Vector<int> &p_kernings) {
-
int len = p_kernings.size();
ERR_FAIL_COND(len % 3);
- if (!len)
+ if (!len) {
return;
+ }
const int *r = p_kernings.ptr();
for (int i = 0; i < len / 3; i++) {
-
const int *data = &r[i * 3];
add_kerning_pair(data[0], data[1], data[2]);
}
}
Vector<int> BitmapFont::_get_kernings() const {
-
Vector<int> kernings;
for (Map<KerningPairKey, int>::Element *E = kerning_map.front(); E; E = E->next()) {
-
kernings.push_back(E->key().A);
kernings.push_back(E->key().B);
kernings.push_back(E->get());
@@ -179,7 +172,6 @@ Vector<int> BitmapFont::_get_kernings() const {
}
void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
-
textures.clear();
for (int i = 0; i < p_textures.size(); i++) {
Ref<Texture2D> tex = p_textures[i];
@@ -189,10 +181,10 @@ void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
}
Vector<Variant> BitmapFont::_get_textures() const {
-
Vector<Variant> rtextures;
- for (int i = 0; i < textures.size(); i++)
+ for (int i = 0; i < textures.size(); i++) {
rtextures.push_back(textures[i]);
+ }
return rtextures;
}
@@ -207,7 +199,6 @@ Error BitmapFont::create_from_fnt(const String &p_file) {
clear();
while (true) {
-
String line = f->get_line();
int delimiter = line.find(" ");
@@ -215,59 +206,62 @@ Error BitmapFont::create_from_fnt(const String &p_file) {
int pos = delimiter + 1;
Map<String, String> keys;
- while (pos < line.size() && line[pos] == ' ')
+ while (pos < line.size() && line[pos] == ' ') {
pos++;
+ }
while (pos < line.size()) {
-
int eq = line.find("=", pos);
- if (eq == -1)
+ if (eq == -1) {
break;
+ }
String key = line.substr(pos, eq - pos);
int end = -1;
String value;
if (line[eq + 1] == '"') {
end = line.find("\"", eq + 2);
- if (end == -1)
+ if (end == -1) {
break;
+ }
value = line.substr(eq + 2, end - 1 - eq - 1);
pos = end + 1;
} else {
end = line.find(" ", eq + 1);
- if (end == -1)
+ if (end == -1) {
end = line.size();
+ }
value = line.substr(eq + 1, end - eq);
pos = end;
}
- while (pos < line.size() && line[pos] == ' ')
+ while (pos < line.size() && line[pos] == ' ') {
pos++;
+ }
keys[key] = value;
}
if (type == "info") {
-
- if (keys.has("face"))
+ if (keys.has("face")) {
set_name(keys["face"]);
+ }
/*
if (keys.has("size"))
font->set_height(keys["size"].to_int());
*/
} else if (type == "common") {
-
- if (keys.has("lineHeight"))
+ if (keys.has("lineHeight")) {
set_height(keys["lineHeight"].to_int());
- if (keys.has("base"))
+ }
+ if (keys.has("base")) {
set_ascent(keys["base"].to_int());
+ }
} else if (type == "page") {
-
if (keys.has("file")) {
-
String base_dir = p_file.get_base_dir();
String file = base_dir.plus_file(keys["file"]);
Ref<Texture2D> tex = ResourceLoader::load(file);
@@ -278,55 +272,66 @@ Error BitmapFont::create_from_fnt(const String &p_file) {
}
}
} else if (type == "char") {
-
CharType idx = 0;
- if (keys.has("id"))
+ if (keys.has("id")) {
idx = keys["id"].to_int();
+ }
Rect2 rect;
- if (keys.has("x"))
+ if (keys.has("x")) {
rect.position.x = keys["x"].to_int();
- if (keys.has("y"))
+ }
+ if (keys.has("y")) {
rect.position.y = keys["y"].to_int();
- if (keys.has("width"))
+ }
+ if (keys.has("width")) {
rect.size.width = keys["width"].to_int();
- if (keys.has("height"))
+ }
+ if (keys.has("height")) {
rect.size.height = keys["height"].to_int();
+ }
Point2 ofs;
- if (keys.has("xoffset"))
+ if (keys.has("xoffset")) {
ofs.x = keys["xoffset"].to_int();
- if (keys.has("yoffset"))
+ }
+ if (keys.has("yoffset")) {
ofs.y = keys["yoffset"].to_int();
+ }
int texture = 0;
- if (keys.has("page"))
+ if (keys.has("page")) {
texture = keys["page"].to_int();
+ }
int advance = -1;
- if (keys.has("xadvance"))
+ if (keys.has("xadvance")) {
advance = keys["xadvance"].to_int();
+ }
add_char(idx, texture, rect, ofs, advance);
} else if (type == "kerning") {
-
CharType first = 0, second = 0;
int k = 0;
- if (keys.has("first"))
+ if (keys.has("first")) {
first = keys["first"].to_int();
- if (keys.has("second"))
+ }
+ if (keys.has("second")) {
second = keys["second"].to_int();
- if (keys.has("amount"))
+ }
+ if (keys.has("amount")) {
k = keys["amount"].to_int();
+ }
add_kerning_pair(first, second, -k);
}
- if (f->eof_reached())
+ if (f->eof_reached()) {
break;
+ }
}
memdelete(f);
@@ -335,67 +340,57 @@ Error BitmapFont::create_from_fnt(const String &p_file) {
}
void BitmapFont::set_height(float p_height) {
-
height = p_height;
}
-float BitmapFont::get_height() const {
+float BitmapFont::get_height() const {
return height;
}
void BitmapFont::set_ascent(float p_ascent) {
-
ascent = p_ascent;
}
-float BitmapFont::get_ascent() const {
+float BitmapFont::get_ascent() const {
return ascent;
}
-float BitmapFont::get_descent() const {
+float BitmapFont::get_descent() const {
return height - ascent;
}
float BitmapFont::get_underline_position() const {
-
return 2;
}
float BitmapFont::get_underline_thickness() const {
-
return 1;
}
void BitmapFont::add_texture(const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_COND_MSG(p_texture.is_null(), "It's not a reference to a valid Texture object.");
textures.push_back(p_texture);
}
int BitmapFont::get_texture_count() const {
-
return textures.size();
};
Ref<Texture2D> BitmapFont::get_texture(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture2D>());
return textures[p_idx];
};
int BitmapFont::get_character_count() const {
-
return char_map.size();
};
Vector<CharType> BitmapFont::get_char_keys() const {
-
Vector<CharType> chars;
chars.resize(char_map.size());
const CharType *ct = nullptr;
int count = 0;
while ((ct = char_map.next(ct))) {
-
chars.write[count++] = *ct;
};
@@ -403,7 +398,6 @@ Vector<CharType> BitmapFont::get_char_keys() const {
};
BitmapFont::Character BitmapFont::get_character(CharType p_char) const {
-
if (!char_map.has(p_char)) {
ERR_FAIL_V(Character());
};
@@ -412,9 +406,9 @@ BitmapFont::Character BitmapFont::get_character(CharType p_char) const {
};
void BitmapFont::add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance) {
-
- if (p_advance < 0)
+ if (p_advance < 0) {
p_advance = p_rect.size.width;
+ }
Character c;
c.rect = p_rect;
@@ -427,22 +421,18 @@ void BitmapFont::add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rec
}
void BitmapFont::add_kerning_pair(CharType p_A, CharType p_B, int p_kerning) {
-
KerningPairKey kpk;
kpk.A = p_A;
kpk.B = p_B;
if (p_kerning == 0 && kerning_map.has(kpk)) {
-
kerning_map.erase(kpk);
} else {
-
kerning_map[kpk] = p_kerning;
}
}
Vector<BitmapFont::KerningPairKey> BitmapFont::get_kerning_pair_keys() const {
-
Vector<BitmapFont::KerningPairKey> ret;
ret.resize(kerning_map.size());
int i = 0;
@@ -455,31 +445,28 @@ Vector<BitmapFont::KerningPairKey> BitmapFont::get_kerning_pair_keys() const {
}
int BitmapFont::get_kerning_pair(CharType p_A, CharType p_B) const {
-
KerningPairKey kpk;
kpk.A = p_A;
kpk.B = p_B;
const Map<KerningPairKey, int>::Element *E = kerning_map.find(kpk);
- if (E)
+ if (E) {
return E->get();
+ }
return 0;
}
void BitmapFont::set_distance_field_hint(bool p_distance_field) {
-
distance_field_hint = p_distance_field;
emit_changed();
}
bool BitmapFont::is_distance_field_hint() const {
-
return distance_field_hint;
}
void BitmapFont::clear() {
-
height = 1;
ascent = 0;
char_map.clear();
@@ -489,16 +476,15 @@ void BitmapFont::clear() {
}
Size2 Font::get_string_size(const String &p_string) const {
-
float w = 0;
int l = p_string.length();
- if (l == 0)
+ if (l == 0) {
return Size2(0, get_height());
+ }
const CharType *sptr = &p_string[0];
for (int i = 0; i < l; i++) {
-
w += get_char_size(sptr[i], sptr[i + 1]).width;
}
@@ -506,12 +492,12 @@ Size2 Font::get_string_size(const String &p_string) const {
}
Size2 Font::get_wordwrap_string_size(const String &p_string, float p_width) const {
-
ERR_FAIL_COND_V(p_width <= 0, Vector2(0, get_height()));
int l = p_string.length();
- if (l == 0)
+ if (l == 0) {
return Size2(p_width, get_height());
+ }
float line_w = 0;
float h = 0;
@@ -537,7 +523,6 @@ Size2 Font::get_wordwrap_string_size(const String &p_string, float p_width) cons
}
void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
-
for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != nullptr; fallback_child = fallback_child->get_fallback()) {
ERR_FAIL_COND_MSG(fallback_child == this, "Can't set as fallback one of its parents to prevent crashes due to recursive loop.");
}
@@ -546,17 +531,16 @@ void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
}
Ref<BitmapFont> BitmapFont::get_fallback() const {
-
return fallback;
}
float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, bool p_outline) const {
-
const Character *c = char_map.getptr(p_char);
if (!c) {
- if (fallback.is_valid())
+ if (fallback.is_valid()) {
return fallback->draw_char(p_canvas_item, p_pos, p_char, p_next, p_modulate, p_outline);
+ }
return 0;
}
@@ -573,26 +557,24 @@ float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_c
}
Size2 BitmapFont::get_char_size(CharType p_char, CharType p_next) const {
-
const Character *c = char_map.getptr(p_char);
if (!c) {
- if (fallback.is_valid())
+ if (fallback.is_valid()) {
return fallback->get_char_size(p_char, p_next);
+ }
return Size2();
}
Size2 ret(c->advance, c->rect.size.y);
if (p_next) {
-
KerningPairKey kpk;
kpk.A = p_char;
kpk.B = p_next;
const Map<KerningPairKey, int>::Element *E = kerning_map.find(kpk);
if (E) {
-
ret.width -= E->get();
}
}
@@ -601,7 +583,6 @@ Size2 BitmapFont::get_char_size(CharType p_char, CharType p_next) const {
}
void BitmapFont::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create_from_fnt", "path"), &BitmapFont::create_from_fnt);
ClassDB::bind_method(D_METHOD("set_height", "px"), &BitmapFont::set_height);
@@ -616,8 +597,6 @@ void BitmapFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_count"), &BitmapFont::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture", "idx"), &BitmapFont::get_texture);
- ClassDB::bind_method(D_METHOD("get_char_size", "char", "next"), &BitmapFont::get_char_size, DEFVAL(0));
-
ClassDB::bind_method(D_METHOD("set_distance_field_hint", "enable"), &BitmapFont::set_distance_field_hint);
ClassDB::bind_method(D_METHOD("clear"), &BitmapFont::clear);
@@ -645,21 +624,19 @@ void BitmapFont::_bind_methods() {
}
BitmapFont::BitmapFont() {
-
clear();
}
BitmapFont::~BitmapFont() {
-
clear();
}
////////////
RES ResourceFormatLoaderBMFont::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)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
Ref<BitmapFont> font;
font.instance();
@@ -667,8 +644,9 @@ RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_origi
Error err = font->create_from_fnt(p_path);
if (err) {
- if (r_error)
+ if (r_error) {
*r_error = err;
+ }
return RES();
}
@@ -676,19 +654,17 @@ RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_origi
}
void ResourceFormatLoaderBMFont::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("fnt");
}
bool ResourceFormatLoaderBMFont::handles_type(const String &p_type) const {
-
return (p_type == "BitmapFont");
}
String ResourceFormatLoaderBMFont::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "fnt")
+ if (el == "fnt") {
return "BitmapFont";
+ }
return "";
}
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 54b1eaa1b9..14312308bb 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -36,7 +36,6 @@
#include "scene/resources/texture.h"
class Font : public Resource {
-
GDCLASS(Font, Resource);
protected:
@@ -106,7 +105,6 @@ public:
};
class BitmapFont : public Font {
-
GDCLASS(BitmapFont, Font);
RES_BASE_EXTENSION("font");
@@ -114,7 +112,6 @@ class BitmapFont : public Font {
public:
struct Character {
-
int texture_idx;
Rect2 rect;
float v_align;
@@ -128,7 +125,6 @@ public:
};
struct KerningPairKey {
-
union {
struct {
uint32_t A, B;
diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp
index 7bce04beaf..d271c906ff 100644
--- a/scene/resources/gradient.cpp
+++ b/scene/resources/gradient.cpp
@@ -52,7 +52,6 @@ Gradient::~Gradient() {
}
void Gradient::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_point", "offset", "color"), &Gradient::add_point);
ClassDB::bind_method(D_METHOD("remove_point", "offset"), &Gradient::remove_point);
@@ -104,8 +103,9 @@ void Gradient::set_offsets(const Vector<float> &p_offsets) {
}
void Gradient::set_colors(const Vector<Color> &p_colors) {
- if (points.size() < p_colors.size())
+ if (points.size() < p_colors.size()) {
is_sorted = false;
+ }
points.resize(p_colors.size());
for (int i = 0; i < points.size(); i++) {
points.write[i].color = p_colors[i];
@@ -118,7 +118,6 @@ Vector<Gradient::Point> &Gradient::get_points() {
}
void Gradient::add_point(float p_offset, const Color &p_color) {
-
Point p;
p.offset = p_offset;
p.color = p_color;
@@ -129,7 +128,6 @@ void Gradient::add_point(float p_offset, const Color &p_color) {
}
void Gradient::remove_point(int p_index) {
-
ERR_FAIL_INDEX(p_index, points.size());
ERR_FAIL_COND(points.size() <= 2);
points.remove(p_index);
@@ -143,10 +141,10 @@ void Gradient::set_points(Vector<Gradient::Point> &p_points) {
}
void Gradient::set_offset(int pos, const float offset) {
-
ERR_FAIL_COND(pos < 0);
- if (points.size() <= pos)
+ if (points.size() <= pos) {
points.resize(pos + 1);
+ }
points.write[pos].offset = offset;
is_sorted = false;
emit_signal(CoreStringNames::get_singleton()->changed);
diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h
index 573749ea7e..d40dcc8d44 100644
--- a/scene/resources/gradient.h
+++ b/scene/resources/gradient.h
@@ -39,7 +39,6 @@ class Gradient : public Resource {
public:
struct Point {
-
float offset;
Color color;
bool operator<(const Point &p_ponit) const {
@@ -77,9 +76,9 @@ public:
Vector<Color> get_colors() const;
_FORCE_INLINE_ Color get_color_at_offset(float p_offset) {
-
- if (points.empty())
+ if (points.empty()) {
return Color(0, 0, 0, 1);
+ }
if (!is_sorted) {
points.sort();
@@ -92,8 +91,9 @@ public:
int middle = 0;
#ifdef DEBUG_ENABLED
- if (low > high)
+ if (low > high) {
ERR_PRINT("low > high, this may be a bug");
+ }
#endif
while (low <= high) {
@@ -114,10 +114,12 @@ public:
}
int first = middle;
int second = middle + 1;
- if (second >= points.size())
+ if (second >= points.size()) {
return points[points.size() - 1].color;
- if (first < 0)
+ }
+ if (first < 0) {
return points[0].color;
+ }
const Point &pointFirst = points[first];
const Point &pointSecond = points[second];
return pointFirst.color.lerp(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset));
diff --git a/scene/resources/height_map_shape_3d.cpp b/scene/resources/height_map_shape_3d.cpp
index 33b6063299..e112c6b436 100644
--- a/scene/resources/height_map_shape_3d.cpp
+++ b/scene/resources/height_map_shape_3d.cpp
@@ -35,7 +35,6 @@ Vector<Vector3> HeightMapShape3D::get_debug_mesh_lines() {
Vector<Vector3> points;
if ((map_width != 0) && (map_depth != 0)) {
-
// This will be slow for large maps...
// also we'll have to figure out how well bullet centers this shape...
@@ -81,7 +80,6 @@ real_t HeightMapShape3D::get_enclosing_radius() const {
}
void HeightMapShape3D::_update_shape() {
-
Dictionary d;
d["width"] = map_width;
d["depth"] = map_depth;
@@ -161,11 +159,13 @@ void HeightMapShape3D::set_map_data(PackedFloat32Array p_new) {
min_height = val;
max_height = val;
} else {
- if (min_height > val)
+ if (min_height > val) {
min_height = val;
+ }
- if (max_height < val)
+ if (max_height < val) {
max_height = val;
+ }
}
}
@@ -193,7 +193,6 @@ void HeightMapShape3D::_bind_methods() {
HeightMapShape3D::HeightMapShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_HEIGHTMAP)) {
-
map_width = 2;
map_depth = 2;
map_data.resize(map_width * map_depth);
diff --git a/scene/resources/line_shape_2d.cpp b/scene/resources/line_shape_2d.cpp
index 71d4f79e48..58653c5f4a 100644
--- a/scene/resources/line_shape_2d.cpp
+++ b/scene/resources/line_shape_2d.cpp
@@ -30,25 +30,25 @@
#include "line_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
Vector2 point = get_distance() * get_normal();
Vector2 l[2][2] = { { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 }, { point, point + get_normal() * 30 } };
for (int i = 0; i < 2; i++) {
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, l[i]);
- if (p_point.distance_to(closest) < p_tolerance)
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, l[i]);
+ if (p_point.distance_to(closest) < p_tolerance) {
return true;
+ }
}
return false;
}
void LineShape2D::_update_shape() {
-
Array arr;
arr.push_back(normal);
arr.push_back(distance);
@@ -57,28 +57,24 @@ void LineShape2D::_update_shape() {
}
void LineShape2D::set_normal(const Vector2 &p_normal) {
-
normal = p_normal;
_update_shape();
}
void LineShape2D::set_distance(real_t p_distance) {
-
distance = p_distance;
_update_shape();
}
Vector2 LineShape2D::get_normal() const {
-
return normal;
}
-real_t LineShape2D::get_distance() const {
+real_t LineShape2D::get_distance() const {
return distance;
}
void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
Vector2 point = get_distance() * get_normal();
Vector2 l1[2] = { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 };
@@ -86,8 +82,8 @@ void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector2 l2[2] = { point, point + get_normal() * 30 };
RS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3);
}
-Rect2 LineShape2D::get_rect() const {
+Rect2 LineShape2D::get_rect() const {
Vector2 point = get_distance() * get_normal();
Vector2 l1[2] = { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 };
@@ -105,7 +101,6 @@ real_t LineShape2D::get_enclosing_radius() const {
}
void LineShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_normal", "normal"), &LineShape2D::set_normal);
ClassDB::bind_method(D_METHOD("get_normal"), &LineShape2D::get_normal);
@@ -118,7 +113,6 @@ void LineShape2D::_bind_methods() {
LineShape2D::LineShape2D() :
Shape2D(PhysicsServer2D::get_singleton()->line_shape_create()) {
-
normal = Vector2(0, 1);
distance = 0;
_update_shape();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index e3bed171b0..1e95a35726 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -39,28 +39,27 @@
#include "scene/scene_string_names.h"
void Material::set_next_pass(const Ref<Material> &p_pass) {
-
for (Ref<Material> pass_child = p_pass; pass_child != nullptr; pass_child = pass_child->get_next_pass()) {
ERR_FAIL_COND_MSG(pass_child == this, "Can't set as next_pass one of its parents to prevent crashes due to recursive loop.");
}
- if (next_pass == p_pass)
+ if (next_pass == p_pass) {
return;
+ }
next_pass = p_pass;
RID next_pass_rid;
- if (next_pass.is_valid())
+ if (next_pass.is_valid()) {
next_pass_rid = next_pass->get_rid();
+ }
RS::get_singleton()->material_set_next_pass(material, next_pass_rid);
}
Ref<Material> Material::get_next_pass() const {
-
return next_pass;
}
void Material::set_render_priority(int p_priority) {
-
ERR_FAIL_COND(p_priority < RENDER_PRIORITY_MIN);
ERR_FAIL_COND(p_priority > RENDER_PRIORITY_MAX);
render_priority = p_priority;
@@ -68,23 +67,20 @@ void Material::set_render_priority(int p_priority) {
}
int Material::get_render_priority() const {
-
return render_priority;
}
RID Material::get_rid() const {
-
return material;
}
-void Material::_validate_property(PropertyInfo &property) const {
+void Material::_validate_property(PropertyInfo &property) const {
if (!_can_do_next_pass() && property.name == "next_pass") {
property.usage = 0;
}
}
void Material::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass"), &Material::set_next_pass);
ClassDB::bind_method(D_METHOD("get_next_pass"), &Material::get_next_pass);
@@ -99,22 +95,18 @@ void Material::_bind_methods() {
}
Material::Material() {
-
material = RenderingServer::get_singleton()->material_create();
render_priority = 0;
}
Material::~Material() {
-
RenderingServer::get_singleton()->free(material);
}
///////////////////////////////////
bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
-
if (shader.is_valid()) {
-
StringName pr = shader->remap_param(p_name);
if (!pr) {
String n = p_name;
@@ -135,9 +127,7 @@ bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
}
bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
-
if (shader.is_valid()) {
-
StringName pr = shader->remap_param(p_name);
if (!pr) {
String n = p_name;
@@ -159,16 +149,13 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
}
void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
-
if (!shader.is_null()) {
-
shader->get_param_list(p_list);
}
}
bool ShaderMaterial::property_can_revert(const String &p_name) {
if (shader.is_valid()) {
-
StringName pr = shader->remap_param(p_name);
if (pr) {
Variant default_value = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
@@ -192,7 +179,6 @@ Variant ShaderMaterial::property_get_revert(const String &p_name) {
}
void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
-
// Only connect/disconnect the signal when running in the editor.
// This can be a slow operation, and `_change_notify()` (which is called by `_shader_changed()`)
// does nothing in non-editor builds anyway. See GH-34741 for details.
@@ -217,17 +203,14 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
}
Ref<Shader> ShaderMaterial::get_shader() const {
-
return shader;
}
void ShaderMaterial::set_shader_param(const StringName &p_param, const Variant &p_value) {
-
RS::get_singleton()->material_set_param(_get_material(), p_param, p_value);
}
Variant ShaderMaterial::get_shader_param(const StringName &p_param) const {
-
return RS::get_singleton()->material_get_param(_get_material(), p_param);
}
@@ -236,7 +219,6 @@ void ShaderMaterial::_shader_changed() {
}
void ShaderMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shader", "shader"), &ShaderMaterial::set_shader);
ClassDB::bind_method(D_METHOD("get_shader"), &ShaderMaterial::get_shader);
ClassDB::bind_method(D_METHOD("set_shader_param", "param", "value"), &ShaderMaterial::set_shader_param);
@@ -248,7 +230,6 @@ void ShaderMaterial::_bind_methods() {
}
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
-
#ifdef TOOLS_ENABLED
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", 0) ? "'" : "\"";
#else
@@ -257,7 +238,6 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
String f = p_function.operator String();
if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
-
if (shader.is_valid()) {
List<PropertyInfo> pl;
shader->get_param_list(&pl);
@@ -270,15 +250,15 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
}
bool ShaderMaterial::_can_do_next_pass() const {
-
return shader.is_valid() && shader->get_mode() == Shader::MODE_SPATIAL;
}
Shader::Mode ShaderMaterial::get_shader_mode() const {
- if (shader.is_valid())
+ if (shader.is_valid()) {
return shader->get_mode();
- else
+ } else {
return Shader::MODE_SPATIAL;
+ }
}
ShaderMaterial::ShaderMaterial() {
@@ -295,7 +275,6 @@ Map<BaseMaterial3D::MaterialKey, BaseMaterial3D::ShaderData> BaseMaterial3D::sha
BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = nullptr;
void BaseMaterial3D::init_shaders() {
-
dirty_materials = memnew(SelfList<BaseMaterial3D>::List);
shader_names = memnew(ShaderNames);
@@ -375,7 +354,6 @@ void BaseMaterial3D::init_shaders() {
Ref<StandardMaterial3D> BaseMaterial3D::materials_for_2d[BaseMaterial3D::MAX_MATERIALS_FOR_2D];
void BaseMaterial3D::finish_shaders() {
-
for (int i = 0; i < MAX_MATERIALS_FOR_2D; i++) {
materials_for_2d[i].unref();
}
@@ -387,12 +365,12 @@ void BaseMaterial3D::finish_shaders() {
}
void BaseMaterial3D::_update_shader() {
-
dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
- if (mk == current_key)
+ if (mk == current_key) {
return; //no update required in the end
+ }
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -406,7 +384,6 @@ void BaseMaterial3D::_update_shader() {
current_key = mk;
if (shader_map.has(mk)) {
-
RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
shader_map[mk].users++;
return;
@@ -606,7 +583,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_EMISSION]) {
-
code += "uniform sampler2D texture_emission : hint_black_albedo," + texfilter_str + ";\n";
code += "uniform vec4 emission : hint_color;\n";
code += "uniform float emission_energy;\n";
@@ -649,13 +625,11 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_SUBSURFACE_SCATTERING]) {
-
code += "uniform float subsurface_scattering_strength : hint_range(0,1);\n";
code += "uniform sampler2D texture_subsurface_scattering : hint_white," + texfilter_str + ";\n";
}
if (features[FEATURE_SUBSURFACE_TRANSMITTANCE]) {
-
code += "uniform vec4 transmittance_color : hint_color;\n";
code += "uniform float transmittance_depth;\n";
code += "uniform sampler2D texture_subsurface_transmittance : hint_white," + texfilter_str + ";\n";
@@ -664,7 +638,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_BACKLIGHT]) {
-
code += "uniform vec4 backlight : hint_color;\n";
code += "uniform sampler2D texture_backlight : hint_black," + texfilter_str + ";\n";
}
@@ -702,18 +675,15 @@ void BaseMaterial3D::_update_shader() {
code += "void vertex() {\n";
if (flags[FLAG_SRGB_VERTEX_COLOR]) {
-
code += "\tif (!OUTPUT_IS_SRGB) {\n";
code += "\t\tCOLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) );\n";
code += "\t}\n";
}
if (flags[FLAG_USE_POINT_SIZE]) {
-
code += "\tPOINT_SIZE=point_size;\n";
}
if (shading_mode == SHADING_MODE_PER_VERTEX) {
-
code += "\tROUGHNESS=roughness;\n";
}
@@ -723,10 +693,8 @@ void BaseMaterial3D::_update_shader() {
switch (billboard_mode) {
case BILLBOARD_DISABLED: {
-
} break;
case BILLBOARD_ENABLED: {
-
code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],CAMERA_MATRIX[1],CAMERA_MATRIX[2],WORLD_MATRIX[3]);\n";
if (flags[FLAG_BILLBOARD_KEEP_SCALE]) {
@@ -734,7 +702,6 @@ void BaseMaterial3D::_update_shader() {
}
} break;
case BILLBOARD_FIXED_Y: {
-
code += "\tMODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],WORLD_MATRIX[1],vec4(normalize(cross(CAMERA_MATRIX[0].xyz,WORLD_MATRIX[1].xyz)), 0.0),WORLD_MATRIX[3]);\n";
if (flags[FLAG_BILLBOARD_KEEP_SCALE]) {
@@ -744,7 +711,6 @@ void BaseMaterial3D::_update_shader() {
}
} break;
case BILLBOARD_PARTICLES: {
-
//make billboard
code += "\tmat4 mat_world = mat4(normalize(CAMERA_MATRIX[0])*length(WORLD_MATRIX[0]),normalize(CAMERA_MATRIX[1])*length(WORLD_MATRIX[0]),normalize(CAMERA_MATRIX[2])*length(WORLD_MATRIX[2]),WORLD_MATRIX[3]);\n";
//rotate by rotation
@@ -768,7 +734,6 @@ void BaseMaterial3D::_update_shader() {
}
if (flags[FLAG_FIXED_SIZE]) {
-
code += "\tif (PROJECTION_MATRIX[3][3] != 0.0) {\n";
//orthogonal matrix, try to do about the same
//with viewport size
@@ -803,7 +768,6 @@ void BaseMaterial3D::_update_shader() {
}
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
-
code += "\tuv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));\n";
code += "\tuv1_power_normal/=dot(uv1_power_normal,vec3(1.0));\n";
code += "\tuv1_triplanar_pos = VERTEX * uv1_scale + uv1_offset;\n";
@@ -811,7 +775,6 @@ void BaseMaterial3D::_update_shader() {
}
if (flags[FLAG_UV2_USE_TRIPLANAR]) {
-
code += "\tuv2_power_normal=pow(abs(NORMAL), vec3(uv2_blend_sharpness));\n";
code += "\tuv2_power_normal/=dot(uv2_power_normal,vec3(1.0));\n";
code += "\tuv2_triplanar_pos = VERTEX * uv2_scale + uv2_offset;\n";
@@ -992,7 +955,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_REFRACTION]) {
-
if (features[FEATURE_NORMAL_MAPPING]) {
code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) );\n";
} else {
@@ -1023,7 +985,6 @@ void BaseMaterial3D::_update_shader() {
if (distance_fade != DISTANCE_FADE_DISABLED) {
if ((distance_fade == DISTANCE_FADE_OBJECT_DITHER || distance_fade == DISTANCE_FADE_PIXEL_DITHER)) {
-
if (!RenderingServer::get_singleton()->is_low_end()) {
code += "\t{\n";
if (distance_fade == DISTANCE_FADE_OBJECT_DITHER) {
@@ -1097,7 +1058,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_AMBIENT_OCCLUSION]) {
-
if (!orm) {
if (flags[FLAG_AO_ON_UV2]) {
if (flags[FLAG_UV2_USE_TRIPLANAR]) {
@@ -1120,7 +1080,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_SUBSURFACE_SCATTERING]) {
-
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
code += "\tfloat sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_triplanar_pos).r;\n";
} else {
@@ -1130,7 +1089,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_SUBSURFACE_TRANSMITTANCE]) {
-
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
code += "\tvec4 trans_color_tex = triplanar_texture(texture_subsurface_transmittance,uv1_power_normal,uv1_triplanar_pos);\n";
} else {
@@ -1153,7 +1111,6 @@ void BaseMaterial3D::_update_shader() {
}
if (features[FEATURE_DETAIL]) {
-
bool triplanar = (flags[FLAG_UV1_USE_TRIPLANAR] && detail_uv == DETAIL_UV_1) || (flags[FLAG_UV2_USE_TRIPLANAR] && detail_uv == DETAIL_UV_2);
if (triplanar) {
@@ -1168,7 +1125,6 @@ void BaseMaterial3D::_update_shader() {
}
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
-
code += "\tvec4 detail_mask_tex = triplanar_texture(texture_detail_mask,uv1_power_normal,uv1_triplanar_pos);\n";
} else {
code += "\tvec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n";
@@ -1208,17 +1164,14 @@ void BaseMaterial3D::_update_shader() {
}
void BaseMaterial3D::flush_changes() {
-
MutexLock lock(material_mutex);
while (dirty_materials->first()) {
-
dirty_materials->first()->self()->_update_shader();
}
}
void BaseMaterial3D::_queue_shader_change() {
-
MutexLock lock(material_mutex);
if (!element.in_list()) {
@@ -1227,167 +1180,144 @@ void BaseMaterial3D::_queue_shader_change() {
}
bool BaseMaterial3D::_is_shader_dirty() const {
-
MutexLock lock(material_mutex);
return element.in_list();
}
-void BaseMaterial3D::set_albedo(const Color &p_albedo) {
+void BaseMaterial3D::set_albedo(const Color &p_albedo) {
albedo = p_albedo;
RS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo);
}
Color BaseMaterial3D::get_albedo() const {
-
return albedo;
}
void BaseMaterial3D::set_specular(float p_specular) {
-
specular = p_specular;
RS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular);
}
float BaseMaterial3D::get_specular() const {
-
return specular;
}
void BaseMaterial3D::set_roughness(float p_roughness) {
-
roughness = p_roughness;
RS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness);
}
float BaseMaterial3D::get_roughness() const {
-
return roughness;
}
void BaseMaterial3D::set_metallic(float p_metallic) {
-
metallic = p_metallic;
RS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic);
}
float BaseMaterial3D::get_metallic() const {
-
return metallic;
}
void BaseMaterial3D::set_emission(const Color &p_emission) {
-
emission = p_emission;
RS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission);
}
-Color BaseMaterial3D::get_emission() const {
+Color BaseMaterial3D::get_emission() const {
return emission;
}
void BaseMaterial3D::set_emission_energy(float p_emission_energy) {
-
emission_energy = p_emission_energy;
RS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy);
}
-float BaseMaterial3D::get_emission_energy() const {
+float BaseMaterial3D::get_emission_energy() const {
return emission_energy;
}
void BaseMaterial3D::set_normal_scale(float p_normal_scale) {
-
normal_scale = p_normal_scale;
RS::get_singleton()->material_set_param(_get_material(), shader_names->normal_scale, p_normal_scale);
}
-float BaseMaterial3D::get_normal_scale() const {
+float BaseMaterial3D::get_normal_scale() const {
return normal_scale;
}
void BaseMaterial3D::set_rim(float p_rim) {
-
rim = p_rim;
RS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim);
}
-float BaseMaterial3D::get_rim() const {
+float BaseMaterial3D::get_rim() const {
return rim;
}
void BaseMaterial3D::set_rim_tint(float p_rim_tint) {
-
rim_tint = p_rim_tint;
RS::get_singleton()->material_set_param(_get_material(), shader_names->rim_tint, p_rim_tint);
}
-float BaseMaterial3D::get_rim_tint() const {
+float BaseMaterial3D::get_rim_tint() const {
return rim_tint;
}
void BaseMaterial3D::set_ao_light_affect(float p_ao_light_affect) {
-
ao_light_affect = p_ao_light_affect;
RS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect);
}
-float BaseMaterial3D::get_ao_light_affect() const {
+float BaseMaterial3D::get_ao_light_affect() const {
return ao_light_affect;
}
void BaseMaterial3D::set_clearcoat(float p_clearcoat) {
-
clearcoat = p_clearcoat;
RS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat);
}
float BaseMaterial3D::get_clearcoat() const {
-
return clearcoat;
}
void BaseMaterial3D::set_clearcoat_gloss(float p_clearcoat_gloss) {
-
clearcoat_gloss = p_clearcoat_gloss;
RS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat_gloss, p_clearcoat_gloss);
}
float BaseMaterial3D::get_clearcoat_gloss() const {
-
return clearcoat_gloss;
}
void BaseMaterial3D::set_anisotropy(float p_anisotropy) {
-
anisotropy = p_anisotropy;
RS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy);
}
-float BaseMaterial3D::get_anisotropy() const {
+float BaseMaterial3D::get_anisotropy() const {
return anisotropy;
}
void BaseMaterial3D::set_heightmap_scale(float p_heightmap_scale) {
-
heightmap_scale = p_heightmap_scale;
RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_scale, p_heightmap_scale);
}
float BaseMaterial3D::get_heightmap_scale() const {
-
return heightmap_scale;
}
void BaseMaterial3D::set_subsurface_scattering_strength(float p_subsurface_scattering_strength) {
-
subsurface_scattering_strength = p_subsurface_scattering_strength;
RS::get_singleton()->material_set_param(_get_material(), shader_names->subsurface_scattering_strength, subsurface_scattering_strength);
}
float BaseMaterial3D::get_subsurface_scattering_strength() const {
-
return subsurface_scattering_strength;
}
@@ -1404,6 +1334,7 @@ void BaseMaterial3D::set_transmittance_depth(float p_depth) {
transmittance_depth = p_depth;
RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_depth, p_depth);
}
+
float BaseMaterial3D::get_transmittance_depth() const {
return transmittance_depth;
}
@@ -1412,6 +1343,7 @@ void BaseMaterial3D::set_transmittance_curve(float p_curve) {
transmittance_curve = p_curve;
RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_curve, p_curve);
}
+
float BaseMaterial3D::get_transmittance_curve() const {
return transmittance_curve;
}
@@ -1420,70 +1352,65 @@ void BaseMaterial3D::set_transmittance_boost(float p_boost) {
transmittance_boost = p_boost;
RS::get_singleton()->material_set_param(_get_material(), shader_names->transmittance_boost, p_boost);
}
+
float BaseMaterial3D::get_transmittance_boost() const {
return transmittance_boost;
}
void BaseMaterial3D::set_backlight(const Color &p_backlight) {
-
backlight = p_backlight;
RS::get_singleton()->material_set_param(_get_material(), shader_names->backlight, backlight);
}
Color BaseMaterial3D::get_backlight() const {
-
return backlight;
}
void BaseMaterial3D::set_refraction(float p_refraction) {
-
refraction = p_refraction;
RS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction);
}
float BaseMaterial3D::get_refraction() const {
-
return refraction;
}
void BaseMaterial3D::set_detail_uv(DetailUV p_detail_uv) {
-
- if (detail_uv == p_detail_uv)
+ if (detail_uv == p_detail_uv) {
return;
+ }
detail_uv = p_detail_uv;
_queue_shader_change();
}
-BaseMaterial3D::DetailUV BaseMaterial3D::get_detail_uv() const {
+BaseMaterial3D::DetailUV BaseMaterial3D::get_detail_uv() const {
return detail_uv;
}
void BaseMaterial3D::set_blend_mode(BlendMode p_mode) {
-
- if (blend_mode == p_mode)
+ if (blend_mode == p_mode) {
return;
+ }
blend_mode = p_mode;
_queue_shader_change();
}
-BaseMaterial3D::BlendMode BaseMaterial3D::get_blend_mode() const {
+BaseMaterial3D::BlendMode BaseMaterial3D::get_blend_mode() const {
return blend_mode;
}
void BaseMaterial3D::set_detail_blend_mode(BlendMode p_mode) {
-
detail_blend_mode = p_mode;
_queue_shader_change();
}
-BaseMaterial3D::BlendMode BaseMaterial3D::get_detail_blend_mode() const {
+BaseMaterial3D::BlendMode BaseMaterial3D::get_detail_blend_mode() const {
return detail_blend_mode;
}
void BaseMaterial3D::set_transparency(Transparency p_transparency) {
-
if (transparency == p_transparency) {
return;
}
@@ -1498,7 +1425,6 @@ BaseMaterial3D::Transparency BaseMaterial3D::get_transparency() const {
}
void BaseMaterial3D::set_shading_mode(ShadingMode p_shading_mode) {
-
if (shading_mode == p_shading_mode) {
return;
}
@@ -1513,63 +1439,63 @@ BaseMaterial3D::ShadingMode BaseMaterial3D::get_shading_mode() const {
}
void BaseMaterial3D::set_depth_draw_mode(DepthDrawMode p_mode) {
-
- if (depth_draw_mode == p_mode)
+ if (depth_draw_mode == p_mode) {
return;
+ }
depth_draw_mode = p_mode;
_queue_shader_change();
}
-BaseMaterial3D::DepthDrawMode BaseMaterial3D::get_depth_draw_mode() const {
+BaseMaterial3D::DepthDrawMode BaseMaterial3D::get_depth_draw_mode() const {
return depth_draw_mode;
}
void BaseMaterial3D::set_cull_mode(CullMode p_mode) {
-
- if (cull_mode == p_mode)
+ if (cull_mode == p_mode) {
return;
+ }
cull_mode = p_mode;
_queue_shader_change();
}
-BaseMaterial3D::CullMode BaseMaterial3D::get_cull_mode() const {
+BaseMaterial3D::CullMode BaseMaterial3D::get_cull_mode() const {
return cull_mode;
}
void BaseMaterial3D::set_diffuse_mode(DiffuseMode p_mode) {
-
- if (diffuse_mode == p_mode)
+ if (diffuse_mode == p_mode) {
return;
+ }
diffuse_mode = p_mode;
_queue_shader_change();
}
-BaseMaterial3D::DiffuseMode BaseMaterial3D::get_diffuse_mode() const {
+BaseMaterial3D::DiffuseMode BaseMaterial3D::get_diffuse_mode() const {
return diffuse_mode;
}
void BaseMaterial3D::set_specular_mode(SpecularMode p_mode) {
-
- if (specular_mode == p_mode)
+ if (specular_mode == p_mode) {
return;
+ }
specular_mode = p_mode;
_queue_shader_change();
}
-BaseMaterial3D::SpecularMode BaseMaterial3D::get_specular_mode() const {
+BaseMaterial3D::SpecularMode BaseMaterial3D::get_specular_mode() const {
return specular_mode;
}
void BaseMaterial3D::set_flag(Flags p_flag, bool p_enabled) {
-
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
- if (flags[p_flag] == p_enabled)
+ if (flags[p_flag] == p_enabled) {
return;
+ }
flags[p_flag] = p_enabled;
if (p_flag == FLAG_USE_SHADOW_TO_OPACITY || p_flag == FLAG_USE_TEXTURE_REPEAT || p_flag == FLAG_SUBSURFACE_MODE_SKIN) {
@@ -1579,16 +1505,15 @@ void BaseMaterial3D::set_flag(Flags p_flag, bool p_enabled) {
}
bool BaseMaterial3D::get_flag(Flags p_flag) const {
-
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
void BaseMaterial3D::set_feature(Feature p_feature, bool p_enabled) {
-
ERR_FAIL_INDEX(p_feature, FEATURE_MAX);
- if (features[p_feature] == p_enabled)
+ if (features[p_feature] == p_enabled) {
return;
+ }
features[p_feature] = p_enabled;
_change_notify();
@@ -1596,13 +1521,11 @@ void BaseMaterial3D::set_feature(Feature p_feature, bool p_enabled) {
}
bool BaseMaterial3D::get_feature(Feature p_feature) const {
-
ERR_FAIL_INDEX_V(p_feature, FEATURE_MAX, false);
return features[p_feature];
}
void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_INDEX(p_param, TEXTURE_MAX);
textures[p_param] = p_texture;
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
@@ -1612,7 +1535,6 @@ void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_t
}
Ref<Texture2D> BaseMaterial3D::get_texture(TextureParam p_param) const {
-
ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref<Texture2D>());
return textures[p_param];
}
@@ -1620,8 +1542,9 @@ Ref<Texture2D> BaseMaterial3D::get_texture(TextureParam p_param) const {
Ref<Texture2D> BaseMaterial3D::get_texture_by_name(StringName p_name) const {
for (int i = 0; i < (int)BaseMaterial3D::TEXTURE_MAX; i++) {
TextureParam param = TextureParam(i);
- if (p_name == shader_names->texture_names[param])
+ if (p_name == shader_names->texture_names[param]) {
return textures[param];
+ }
}
return Ref<Texture2D>();
}
@@ -1695,7 +1618,6 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
}
if (orm) {
-
if (property.name == "shading_mode") {
property.hint_string = "Unshaded,PerPixel"; //vertex not supported in ORM mode, since no individual roughness.
}
@@ -1710,9 +1632,7 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
}
if (shading_mode != SHADING_MODE_PER_PIXEL) {
-
if (shading_mode != SHADING_MODE_PER_VERTEX) {
-
//these may still work per vertex
if (property.name.begins_with("ao")) {
property.usage = 0;
@@ -1761,176 +1681,148 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
}
void BaseMaterial3D::set_point_size(float p_point_size) {
-
point_size = p_point_size;
RS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size);
}
float BaseMaterial3D::get_point_size() const {
-
return point_size;
}
void BaseMaterial3D::set_uv1_scale(const Vector3 &p_scale) {
-
uv1_scale = p_scale;
RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale);
}
Vector3 BaseMaterial3D::get_uv1_scale() const {
-
return uv1_scale;
}
void BaseMaterial3D::set_uv1_offset(const Vector3 &p_offset) {
-
uv1_offset = p_offset;
RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset);
}
-Vector3 BaseMaterial3D::get_uv1_offset() const {
+Vector3 BaseMaterial3D::get_uv1_offset() const {
return uv1_offset;
}
void BaseMaterial3D::set_uv1_triplanar_blend_sharpness(float p_sharpness) {
-
uv1_triplanar_sharpness = p_sharpness;
RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness);
}
float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const {
-
return uv1_triplanar_sharpness;
}
void BaseMaterial3D::set_uv2_scale(const Vector3 &p_scale) {
-
uv2_scale = p_scale;
RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale);
}
Vector3 BaseMaterial3D::get_uv2_scale() const {
-
return uv2_scale;
}
void BaseMaterial3D::set_uv2_offset(const Vector3 &p_offset) {
-
uv2_offset = p_offset;
RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset);
}
Vector3 BaseMaterial3D::get_uv2_offset() const {
-
return uv2_offset;
}
void BaseMaterial3D::set_uv2_triplanar_blend_sharpness(float p_sharpness) {
-
uv2_triplanar_sharpness = p_sharpness;
RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness);
}
float BaseMaterial3D::get_uv2_triplanar_blend_sharpness() const {
-
return uv2_triplanar_sharpness;
}
void BaseMaterial3D::set_billboard_mode(BillboardMode p_mode) {
-
billboard_mode = p_mode;
_queue_shader_change();
_change_notify();
}
BaseMaterial3D::BillboardMode BaseMaterial3D::get_billboard_mode() const {
-
return billboard_mode;
}
void BaseMaterial3D::set_particles_anim_h_frames(int p_frames) {
-
particles_anim_h_frames = p_frames;
RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
}
int BaseMaterial3D::get_particles_anim_h_frames() const {
-
return particles_anim_h_frames;
}
-void BaseMaterial3D::set_particles_anim_v_frames(int p_frames) {
+void BaseMaterial3D::set_particles_anim_v_frames(int p_frames) {
particles_anim_v_frames = p_frames;
RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
}
int BaseMaterial3D::get_particles_anim_v_frames() const {
-
return particles_anim_v_frames;
}
void BaseMaterial3D::set_particles_anim_loop(bool p_loop) {
-
particles_anim_loop = p_loop;
RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop);
}
bool BaseMaterial3D::get_particles_anim_loop() const {
-
return particles_anim_loop;
}
void BaseMaterial3D::set_heightmap_deep_parallax(bool p_enable) {
-
deep_parallax = p_enable;
_queue_shader_change();
_change_notify();
}
bool BaseMaterial3D::is_heightmap_deep_parallax_enabled() const {
-
return deep_parallax;
}
void BaseMaterial3D::set_heightmap_deep_parallax_min_layers(int p_layer) {
-
deep_parallax_min_layers = p_layer;
RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_min_layers, p_layer);
}
-int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const {
+int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const {
return deep_parallax_min_layers;
}
void BaseMaterial3D::set_heightmap_deep_parallax_max_layers(int p_layer) {
-
deep_parallax_max_layers = p_layer;
RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_max_layers, p_layer);
}
-int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const {
+int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const {
return deep_parallax_max_layers;
}
void BaseMaterial3D::set_heightmap_deep_parallax_flip_tangent(bool p_flip) {
-
heightmap_parallax_flip_tangent = p_flip;
RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1));
}
bool BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent() const {
-
return heightmap_parallax_flip_tangent;
}
void BaseMaterial3D::set_heightmap_deep_parallax_flip_binormal(bool p_flip) {
-
heightmap_parallax_flip_binormal = p_flip;
RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1));
}
bool BaseMaterial3D::get_heightmap_deep_parallax_flip_binormal() const {
-
return heightmap_parallax_flip_binormal;
}
@@ -1950,7 +1842,6 @@ void BaseMaterial3D::set_alpha_scissor_threshold(float p_threshold) {
}
float BaseMaterial3D::get_alpha_scissor_threshold() const {
-
return alpha_scissor_threshold;
}
@@ -1960,7 +1851,6 @@ void BaseMaterial3D::set_grow(float p_grow) {
}
float BaseMaterial3D::get_grow() const {
-
return grow;
}
@@ -1987,7 +1877,6 @@ BaseMaterial3D::TextureChannel BaseMaterial3D::get_metallic_texture_channel() co
}
void BaseMaterial3D::set_roughness_texture_channel(TextureChannel p_channel) {
-
ERR_FAIL_INDEX(p_channel, 5);
roughness_texture_channel = p_channel;
_queue_shader_change();
@@ -1998,7 +1887,6 @@ BaseMaterial3D::TextureChannel BaseMaterial3D::get_roughness_texture_channel() c
}
void BaseMaterial3D::set_ao_texture_channel(TextureChannel p_channel) {
-
ERR_FAIL_INDEX(p_channel, 5);
ao_texture_channel = p_channel;
RS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel));
@@ -2009,7 +1897,6 @@ BaseMaterial3D::TextureChannel BaseMaterial3D::get_ao_texture_channel() const {
}
void BaseMaterial3D::set_refraction_texture_channel(TextureChannel p_channel) {
-
ERR_FAIL_INDEX(p_channel, 5);
refraction_texture_channel = p_channel;
RS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel));
@@ -2020,22 +1907,28 @@ BaseMaterial3D::TextureChannel BaseMaterial3D::get_refraction_texture_channel()
}
RID BaseMaterial3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y) {
-
int version = 0;
- if (p_shaded)
+ if (p_shaded) {
version = 1;
- if (p_transparent)
+ }
+ if (p_transparent) {
version |= 2;
- if (p_cut_alpha)
+ }
+ if (p_cut_alpha) {
version |= 4;
- if (p_opaque_prepass)
+ }
+ if (p_opaque_prepass) {
version |= 8;
- if (p_double_sided)
+ }
+ if (p_double_sided) {
version |= 16;
- if (p_billboard)
+ }
+ if (p_billboard) {
version |= 32;
- if (p_billboard_y)
+ }
+ if (p_billboard_y) {
version |= 64;
+ }
if (materials_for_2d[version].is_valid()) {
return materials_for_2d[version]->get_rid();
@@ -2066,85 +1959,74 @@ void BaseMaterial3D::set_on_top_of_alpha() {
}
void BaseMaterial3D::set_proximity_fade(bool p_enable) {
-
proximity_fade_enabled = p_enable;
_queue_shader_change();
_change_notify();
}
bool BaseMaterial3D::is_proximity_fade_enabled() const {
-
return proximity_fade_enabled;
}
void BaseMaterial3D::set_proximity_fade_distance(float p_distance) {
-
proximity_fade_distance = p_distance;
RS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance);
}
-float BaseMaterial3D::get_proximity_fade_distance() const {
+float BaseMaterial3D::get_proximity_fade_distance() const {
return proximity_fade_distance;
}
void BaseMaterial3D::set_distance_fade(DistanceFadeMode p_mode) {
-
distance_fade = p_mode;
_queue_shader_change();
_change_notify();
}
-BaseMaterial3D::DistanceFadeMode BaseMaterial3D::get_distance_fade() const {
+BaseMaterial3D::DistanceFadeMode BaseMaterial3D::get_distance_fade() const {
return distance_fade;
}
void BaseMaterial3D::set_distance_fade_max_distance(float p_distance) {
-
distance_fade_max_distance = p_distance;
RS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance);
}
-float BaseMaterial3D::get_distance_fade_max_distance() const {
+float BaseMaterial3D::get_distance_fade_max_distance() const {
return distance_fade_max_distance;
}
void BaseMaterial3D::set_distance_fade_min_distance(float p_distance) {
-
distance_fade_min_distance = p_distance;
RS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance);
}
float BaseMaterial3D::get_distance_fade_min_distance() const {
-
return distance_fade_min_distance;
}
void BaseMaterial3D::set_emission_operator(EmissionOperator p_op) {
-
- if (emission_op == p_op)
+ if (emission_op == p_op) {
return;
+ }
emission_op = p_op;
_queue_shader_change();
}
BaseMaterial3D::EmissionOperator BaseMaterial3D::get_emission_operator() const {
-
return emission_op;
}
RID BaseMaterial3D::get_shader_rid() const {
-
ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
return shader_map[current_key].shader;
}
Shader::Mode BaseMaterial3D::get_shader_mode() const {
-
return Shader::MODE_SPATIAL;
}
void BaseMaterial3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &BaseMaterial3D::set_albedo);
ClassDB::bind_method(D_METHOD("get_albedo"), &BaseMaterial3D::get_albedo);
@@ -2622,7 +2504,6 @@ void BaseMaterial3D::_bind_methods() {
BaseMaterial3D::BaseMaterial3D(bool p_orm) :
element(this) {
-
orm = p_orm;
// Initialize to the same values as the shader
transparency = TRANSPARENCY_DISABLED;
@@ -2690,7 +2571,7 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
depth_draw_mode = DEPTH_DRAW_OPAQUE_ONLY;
cull_mode = CULL_BACK;
for (int i = 0; i < FLAG_MAX; i++) {
- flags[i] = 0;
+ flags[i] = false;
}
flags[FLAG_USE_TEXTURE_REPEAT] = true;
@@ -2709,7 +2590,6 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
}
BaseMaterial3D::~BaseMaterial3D() {
-
MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 241357ba9b..433e3d304e 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -39,7 +39,6 @@
#include "servers/rendering_server.h"
class Material : public Resource {
-
GDCLASS(Material, Resource);
RES_BASE_EXTENSION("material")
OBJ_SAVE_TYPE(Material);
@@ -74,7 +73,6 @@ public:
};
class ShaderMaterial : public Material {
-
GDCLASS(ShaderMaterial, Material);
Ref<Shader> shader;
@@ -109,7 +107,6 @@ public:
class StandardMaterial3D;
class BaseMaterial3D : public Material {
-
GDCLASS(BaseMaterial3D, Material);
public:
@@ -269,7 +266,6 @@ public:
private:
union MaterialKey {
-
struct {
uint64_t feature_mask : FEATURE_MAX;
uint64_t detail_uv : 1;
@@ -316,7 +312,6 @@ private:
MaterialKey current_key;
_FORCE_INLINE_ MaterialKey _compute_key() const {
-
MaterialKey mk;
mk.key0 = 0;
mk.key1 = 0;
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 6548c65cd7..10f0a040d0 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -40,28 +40,27 @@
Mesh::ConvexDecompositionFunc Mesh::convex_composition_function = nullptr;
Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
-
- if (triangle_mesh.is_valid())
+ if (triangle_mesh.is_valid()) {
return triangle_mesh;
+ }
int facecount = 0;
for (int i = 0; i < get_surface_count(); i++) {
-
- if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES)
+ if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES) {
continue;
+ }
if (surface_get_format(i) & ARRAY_FORMAT_INDEX) {
-
facecount += surface_get_array_index_len(i);
} else {
-
facecount += surface_get_array_len(i);
}
}
- if (facecount == 0 || (facecount % 3) != 0)
+ if (facecount == 0 || (facecount % 3) != 0) {
return triangle_mesh;
+ }
Vector<Vector3> faces;
faces.resize(facecount);
@@ -70,9 +69,9 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
int widx = 0;
for (int i = 0; i < get_surface_count(); i++) {
-
- if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES)
+ if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES) {
continue;
+ }
Array a = surface_get_arrays(i);
ERR_FAIL_COND_V(a.empty(), Ref<TriangleMesh>());
@@ -82,7 +81,6 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
const Vector3 *vr = vertices.ptr();
if (surface_get_format(i) & ARRAY_FORMAT_INDEX) {
-
int ic = surface_get_array_index_len(i);
Vector<int> indices = a[ARRAY_INDEX];
const int *ir = indices.ptr();
@@ -93,9 +91,9 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
}
} else {
-
- for (int j = 0; j < vc; j++)
+ for (int j = 0; j < vc; j++) {
facesw[widx++] = vr[j];
+ }
}
}
@@ -106,15 +104,15 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
}
void Mesh::generate_debug_mesh_lines(Vector<Vector3> &r_lines) {
-
if (debug_lines.size() > 0) {
r_lines = debug_lines;
return;
}
Ref<TriangleMesh> tm = generate_triangle_mesh();
- if (tm.is_null())
+ if (tm.is_null()) {
return;
+ }
Vector<int> triangle_indices;
tm->get_indices(&triangle_indices);
@@ -141,10 +139,12 @@ void Mesh::generate_debug_mesh_lines(Vector<Vector3> &r_lines) {
r_lines = debug_lines;
}
+
void Mesh::generate_debug_mesh_indices(Vector<Vector3> &r_points) {
Ref<TriangleMesh> tm = generate_triangle_mesh();
- if (tm.is_null())
+ if (tm.is_null()) {
return;
+ }
Vector<Vector3> vertices = tm->get_vertices();
@@ -161,10 +161,10 @@ bool Mesh::surface_is_softbody_friendly(int p_idx) const {
}
Vector<Face3> Mesh::get_faces() const {
-
Ref<TriangleMesh> tm = generate_triangle_mesh();
- if (tm.is_valid())
+ if (tm.is_valid()) {
return tm->get_faces();
+ }
return Vector<Face3>();
/*
for (int i=0;i<surfaces.size();i++) {
@@ -227,11 +227,9 @@ Vector<Face3> Mesh::get_faces() const {
}
Ref<Shape3D> Mesh::create_convex_shape() const {
-
Vector<Vector3> vertices;
for (int i = 0; i < get_surface_count(); i++) {
-
Array a = surface_get_arrays(i);
ERR_FAIL_COND_V(a.empty(), Ref<ConvexPolygonShape3D>());
Vector<Vector3> v = a[ARRAY_VERTEX];
@@ -244,16 +242,15 @@ Ref<Shape3D> Mesh::create_convex_shape() const {
}
Ref<Shape3D> Mesh::create_trimesh_shape() const {
-
Vector<Face3> faces = get_faces();
- if (faces.size() == 0)
+ if (faces.size() == 0) {
return Ref<Shape3D>();
+ }
Vector<Vector3> face_points;
face_points.resize(faces.size() * 3);
for (int i = 0; i < face_points.size(); i += 3) {
-
Face3 f = faces.get(i / 3);
face_points.set(i, f.vertex[0]);
face_points.set(i + 1, f.vertex[1]);
@@ -266,13 +263,12 @@ Ref<Shape3D> Mesh::create_trimesh_shape() const {
}
Ref<Mesh> Mesh::create_outline(float p_margin) const {
-
Array arrays;
int index_accum = 0;
for (int i = 0; i < get_surface_count(); i++) {
-
- if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES)
+ if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES) {
continue;
+ }
Array a = surface_get_arrays(i);
ERR_FAIL_COND_V(a.empty(), Ref<ArrayMesh>());
@@ -282,10 +278,8 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
Vector<Vector3> v = a[ARRAY_VERTEX];
index_accum += v.size();
} else {
-
int vcount = 0;
for (int j = 0; j < arrays.size(); j++) {
-
if (arrays[j].get_type() == Variant::NIL || a[j].get_type() == Variant::NIL) {
//mismatch, do not use
arrays[j] = Variant();
@@ -293,14 +287,13 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
}
switch (j) {
-
case ARRAY_VERTEX:
case ARRAY_NORMAL: {
-
Vector<Vector3> dst = arrays[j];
Vector<Vector3> src = a[j];
- if (j == ARRAY_VERTEX)
+ if (j == ARRAY_VERTEX) {
vcount = src.size();
+ }
if (dst.size() == 0 || src.size() == 0) {
arrays[j] = Variant();
continue;
@@ -311,7 +304,6 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
case ARRAY_TANGENT:
case ARRAY_BONES:
case ARRAY_WEIGHTS: {
-
Vector<real_t> dst = arrays[j];
Vector<real_t> src = a[j];
if (dst.size() == 0 || src.size() == 0) {
@@ -391,7 +383,6 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
//fill normals with triangle normals
for (int i = 0; i < vc; i += 3) {
-
Vector3 t[3];
if (has_indices) {
@@ -407,14 +398,14 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
Vector3 n = Plane(t[0], t[1], t[2]).normal;
for (int j = 0; j < 3; j++) {
-
Map<Vector3, Vector3>::Element *E = normal_accum.find(t[j]);
if (!E) {
normal_accum[t[j]] = n;
} else {
float d = n.dot(E->get());
- if (d < 1.0)
+ if (d < 1.0) {
E->get() += n * (1.0 - d);
+ }
//E->get()+=n;
}
}
@@ -430,7 +421,6 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
int vc2 = vertices.size();
for (int i = 0; i < vc2; i++) {
-
Vector3 t = r[i];
Map<Vector3, Vector3>::Element *E = normal_accum.find(t);
@@ -443,13 +433,11 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
arrays[ARRAY_VERTEX] = vertices;
if (!has_indices) {
-
Vector<int> new_indices;
new_indices.resize(vertices.size());
int *iw = new_indices.ptrw();
for (int j = 0; j < vc2; j += 3) {
-
iw[j] = j;
iw[j + 1] = j + 2;
iw[j + 2] = j + 1;
@@ -458,9 +446,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
arrays[ARRAY_INDEX] = new_indices;
} else {
-
for (int j = 0; j < vc; j += 3) {
-
SWAP(ir[j + 1], ir[j + 2]);
}
arrays[ARRAY_INDEX] = indices;
@@ -481,7 +467,6 @@ Size2i Mesh::get_lightmap_size_hint() const {
}
void Mesh::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_lightmap_size_hint", "size"), &Mesh::set_lightmap_size_hint);
ClassDB::bind_method(D_METHOD("get_lightmap_size_hint"), &Mesh::get_lightmap_size_hint);
ClassDB::bind_method(D_METHOD("get_aabb"), &Mesh::get_aabb);
@@ -542,7 +527,6 @@ void Mesh::clear_cache() const {
}
Vector<Ref<Shape3D>> Mesh::convex_decompose() const {
-
ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape3D>>());
const Vector<Face3> faces = get_faces();
@@ -582,7 +566,6 @@ Mesh::Mesh() {
}
static Vector<uint8_t> _fix_array_compatibility(const Vector<uint8_t> &p_src, uint32_t p_format, uint32_t p_elements) {
-
bool vertex_16bit = p_format & ((1 << (Mesh::ARRAY_VERTEX + Mesh::ARRAY_COMPRESS_BASE)));
bool has_bones = (p_format & Mesh::ARRAY_FORMAT_BONES);
bool bone_8 = has_bones && !(p_format & (Mesh::ARRAY_COMPRESS_INDEX << 2));
@@ -607,7 +590,6 @@ static Vector<uint8_t> _fix_array_compatibility(const Vector<uint8_t> &p_src, ui
const uint8_t *r = p_src.ptr();
for (uint32_t i = 0; i < p_elements; i++) {
-
uint32_t remaining = src_stride;
const uint8_t *src = (const uint8_t *)(r + src_stride * i);
uint8_t *dst = (uint8_t *)(w + dst_stride * i);
@@ -642,7 +624,6 @@ static Vector<uint8_t> _fix_array_compatibility(const Vector<uint8_t> &p_src, ui
}
if (has_bones) {
-
remaining -= bone_8 ? 4 : 8;
remaining -= weight_32 ? 16 : 8;
}
@@ -652,12 +633,10 @@ static Vector<uint8_t> _fix_array_compatibility(const Vector<uint8_t> &p_src, ui
}
if (has_bones) {
-
dst += remaining;
src += remaining;
if (bone_8) {
-
const uint8_t *src_bones = (const uint8_t *)src;
uint16_t *dst_bones = (uint16_t *)dst;
@@ -678,7 +657,6 @@ static Vector<uint8_t> _fix_array_compatibility(const Vector<uint8_t> &p_src, ui
dst += 8;
if (weight_32) {
-
const float *src_weights = (const float *)src;
uint16_t *dst_weights = (uint16_t *)dst;
@@ -700,43 +678,43 @@ static Vector<uint8_t> _fix_array_compatibility(const Vector<uint8_t> &p_src, ui
}
bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
-
String sname = p_name;
if (p_name == "blend_shape/names") {
-
Vector<String> sk = p_value;
int sz = sk.size();
const String *r = sk.ptr();
- for (int i = 0; i < sz; i++)
+ for (int i = 0; i < sz; i++) {
add_blend_shape(r[i]);
+ }
return true;
}
if (p_name == "blend_shape/mode") {
-
set_blend_shape_mode(BlendShapeMode(int(p_value)));
return true;
}
if (sname.begins_with("surface_")) {
-
int sl = sname.find("/");
- if (sl == -1)
+ if (sl == -1) {
return false;
+ }
int idx = sname.substr(8, sl - 8).to_int() - 1;
String what = sname.get_slicec('/', 1);
- if (what == "material")
+ if (what == "material") {
surface_set_material(idx, p_value);
- else if (what == "name")
+ } else if (what == "name") {
surface_set_name(idx, p_value);
+ }
return true;
}
#ifndef DISABLE_DEPRECATED
// Kept for compatibility from 3.x to 4.0.
- if (!sname.begins_with("surfaces"))
+ if (!sname.begins_with("surfaces")) {
return false;
+ }
WARN_DEPRECATED_MSG("Mesh uses old surface format, which is deprecated (and loads slower). Consider re-importing or re-saving the scene.");
@@ -744,7 +722,6 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
String what = sname.get_slicec('/', 2);
if (idx == surfaces.size()) {
-
//create
Dictionary d = p_value;
ERR_FAIL_COND_V(!d.has("primitive"), false);
@@ -759,8 +736,9 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
//older format (3.x)
Vector<uint8_t> array_data = d["array_data"];
Vector<uint8_t> array_index_data;
- if (d.has("array_index_data"))
+ if (d.has("array_index_data")) {
array_index_data = d["array_index_data"];
+ }
ERR_FAIL_COND_V(!d.has("format"), false);
uint32_t format = d["format"];
@@ -785,8 +763,9 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
array_data = _fix_array_compatibility(array_data, format, vertex_count);
int index_count = 0;
- if (d.has("index_count"))
+ if (d.has("index_count")) {
index_count = d["index_count"];
+ }
Vector<Vector<uint8_t>> blend_shapes;
@@ -824,7 +803,6 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
}
if (d.has("material")) {
-
surface_set_material(idx, d["material"]);
}
if (d.has("name")) {
@@ -839,7 +817,6 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
}
Array ArrayMesh::_get_surfaces() const {
-
if (mesh.is_null()) {
return Array();
}
@@ -908,7 +885,6 @@ void ArrayMesh::_create_if_empty() const {
}
void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
-
Vector<RS::SurfaceData> surface_data;
Vector<Ref<Material>> surface_materials;
Vector<String> surface_names;
@@ -1031,34 +1007,34 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
}
bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (_is_generated())
+ if (_is_generated()) {
return false;
+ }
String sname = p_name;
if (p_name == "blend_shape/names") {
-
Vector<String> sk;
- for (int i = 0; i < blend_shapes.size(); i++)
+ for (int i = 0; i < blend_shapes.size(); i++) {
sk.push_back(blend_shapes[i]);
+ }
r_ret = sk;
return true;
} else if (p_name == "blend_shape/mode") {
-
r_ret = get_blend_shape_mode();
return true;
} else if (sname.begins_with("surface_")) {
-
int sl = sname.find("/");
- if (sl == -1)
+ if (sl == -1) {
return false;
+ }
int idx = sname.substr(8, sl - 8).to_int() - 1;
String what = sname.get_slicec('/', 1);
- if (what == "material")
+ if (what == "material") {
r_ret = surface_get_material(idx);
- else if (what == "name")
+ } else if (what == "name") {
r_ret = surface_get_name(idx);
+ }
return true;
}
@@ -1066,9 +1042,9 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const {
}
void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const {
-
- if (_is_generated())
+ if (_is_generated()) {
return;
+ }
if (blend_shapes.size()) {
p_list->push_back(PropertyInfo(Variant::PACKED_STRING_ARRAY, "blend_shape/names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
@@ -1076,7 +1052,6 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const {
}
for (int i = 0; i < surfaces.size(); i++) {
-
p_list->push_back(PropertyInfo(Variant::STRING, "surface_" + itos(i + 1) + "/name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
if (surfaces[i].is_2d) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial", PROPERTY_USAGE_EDITOR));
@@ -1087,23 +1062,21 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const {
}
void ArrayMesh::_recompute_aabb() {
-
// regenerate AABB
aabb = AABB();
for (int i = 0; i < surfaces.size(); i++) {
-
- if (i == 0)
+ if (i == 0) {
aabb = surfaces[i].aabb;
- else
+ } else {
aabb.merge_with(surfaces[i].aabb);
+ }
}
}
#ifndef _MSC_VER
#warning need to add binding to add_surface using future MeshSurfaceData object
#endif
void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<RS::SurfaceData::LOD> &p_lods) {
-
_create_if_empty();
Surface s;
@@ -1137,7 +1110,6 @@ void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const
}
void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_flags) {
-
ERR_FAIL_COND(p_arrays.size() != ARRAY_MAX);
RS::SurfaceData surface;
@@ -1157,36 +1129,32 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array &
}
Array ArrayMesh::surface_get_arrays(int p_surface) const {
-
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface);
}
-Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const {
+Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
return RenderingServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface);
}
+
Dictionary ArrayMesh::surface_get_lods(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Dictionary());
return RenderingServer::get_singleton()->mesh_surface_get_lods(mesh, p_surface);
}
int ArrayMesh::get_surface_count() const {
-
return surfaces.size();
}
void ArrayMesh::add_blend_shape(const StringName &p_name) {
-
ERR_FAIL_COND_MSG(surfaces.size(), "Can't add a shape key count if surfaces are already created.");
StringName name = p_name;
if (blend_shapes.find(name) != -1) {
-
int count = 2;
do {
-
name = String(p_name) + " " + itos(count);
count++;
} while (blend_shapes.find(name) != -1);
@@ -1197,22 +1165,21 @@ void ArrayMesh::add_blend_shape(const StringName &p_name) {
}
int ArrayMesh::get_blend_shape_count() const {
-
return blend_shapes.size();
}
+
StringName ArrayMesh::get_blend_shape_name(int p_index) const {
ERR_FAIL_INDEX_V(p_index, blend_shapes.size(), StringName());
return blend_shapes[p_index];
}
-void ArrayMesh::clear_blend_shapes() {
+void ArrayMesh::clear_blend_shapes() {
ERR_FAIL_COND_MSG(surfaces.size(), "Can't set shape key count if surfaces are already created.");
blend_shapes.clear();
}
void ArrayMesh::set_blend_shape_mode(BlendShapeMode p_mode) {
-
blend_shape_mode = p_mode;
if (mesh.is_valid()) {
RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)p_mode);
@@ -1220,39 +1187,34 @@ void ArrayMesh::set_blend_shape_mode(BlendShapeMode p_mode) {
}
ArrayMesh::BlendShapeMode ArrayMesh::get_blend_shape_mode() const {
-
return blend_shape_mode;
}
int ArrayMesh::surface_get_array_len(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, surfaces.size(), -1);
return surfaces[p_idx].array_length;
}
int ArrayMesh::surface_get_array_index_len(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, surfaces.size(), -1);
return surfaces[p_idx].index_array_length;
}
uint32_t ArrayMesh::surface_get_format(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, surfaces.size(), 0);
return surfaces[p_idx].format;
}
ArrayMesh::PrimitiveType ArrayMesh::surface_get_primitive_type(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, surfaces.size(), PRIMITIVE_LINES);
return surfaces[p_idx].primitive;
}
void ArrayMesh::surface_set_material(int p_idx, const Ref<Material> &p_material) {
-
ERR_FAIL_INDEX(p_idx, surfaces.size());
- if (surfaces[p_idx].material == p_material)
+ if (surfaces[p_idx].material == p_material) {
return;
+ }
surfaces.write[p_idx].material = p_material;
RenderingServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null() ? RID() : p_material->get_rid());
@@ -1270,7 +1232,6 @@ int ArrayMesh::surface_find_by_name(const String &p_name) const {
}
void ArrayMesh::surface_set_name(int p_idx, const String &p_name) {
-
ERR_FAIL_INDEX(p_idx, surfaces.size());
surfaces.write[p_idx].name = p_name;
@@ -1278,20 +1239,17 @@ void ArrayMesh::surface_set_name(int p_idx, const String &p_name) {
}
String ArrayMesh::surface_get_name(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, surfaces.size(), String());
return surfaces[p_idx].name;
}
void ArrayMesh::surface_update_region(int p_surface, int p_offset, const Vector<uint8_t> &p_data) {
-
ERR_FAIL_INDEX(p_surface, surfaces.size());
RS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data);
emit_changed();
}
void ArrayMesh::surface_set_custom_aabb(int p_idx, const AABB &p_aabb) {
-
ERR_FAIL_INDEX(p_idx, surfaces.size());
surfaces.write[p_idx].aabb = p_aabb;
// set custom aabb too?
@@ -1299,18 +1257,16 @@ void ArrayMesh::surface_set_custom_aabb(int p_idx, const AABB &p_aabb) {
}
Ref<Material> ArrayMesh::surface_get_material(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, surfaces.size(), Ref<Material>());
return surfaces[p_idx].material;
}
RID ArrayMesh::get_rid() const {
-
_create_if_empty();
return mesh;
}
-AABB ArrayMesh::get_aabb() const {
+AABB ArrayMesh::get_aabb() const {
return aabb;
}
@@ -1324,7 +1280,6 @@ void ArrayMesh::clear_surfaces() {
}
void ArrayMesh::set_custom_aabb(const AABB &p_custom) {
-
_create_if_empty();
custom_aabb = p_custom;
RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
@@ -1332,18 +1287,15 @@ void ArrayMesh::set_custom_aabb(const AABB &p_custom) {
}
AABB ArrayMesh::get_custom_aabb() const {
-
return custom_aabb;
}
void ArrayMesh::regen_normalmaps() {
-
if (surfaces.size() == 0) {
return;
}
Vector<Ref<SurfaceTool>> surfs;
for (int i = 0; i < get_surface_count(); i++) {
-
Ref<SurfaceTool> st = memnew(SurfaceTool);
st->create_from(Ref<ArrayMesh>(this), i);
surfs.push_back(st);
@@ -1352,7 +1304,6 @@ void ArrayMesh::regen_normalmaps() {
clear_surfaces();
for (int i = 0; i < surfs.size(); i++) {
-
surfs.write[i]->generate_tangents();
surfs.write[i]->commit(Ref<ArrayMesh>(this));
}
@@ -1362,7 +1313,6 @@ void ArrayMesh::regen_normalmaps() {
bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y, int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache);
struct ArrayMeshLightmapSurface {
-
Ref<Material> material;
Vector<SurfaceTool::Vertex> vertices;
Mesh::PrimitiveType primitive;
@@ -1377,7 +1327,6 @@ Error ArrayMesh::lightmap_unwrap(const Transform &p_base_transform, float p_texe
}
Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache, const Transform &p_base_transform, float p_texel_size) {
-
ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes.");
@@ -1422,7 +1371,6 @@ Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cach
uv_indices.resize(vertex_ofs + vc);
for (int j = 0; j < vc; j++) {
-
Vector3 v = transform.xform(r[j]);
Vector3 n = normal_basis.xform(rn[j]).normalized();
@@ -1439,10 +1387,10 @@ Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cach
int ic = rindices.size();
if (ic == 0) {
-
for (int j = 0; j < vc / 3; j++) {
- if (Face3(r[j * 3 + 0], r[j * 3 + 1], r[j * 3 + 2]).is_degenerate())
+ if (Face3(r[j * 3 + 0], r[j * 3 + 1], r[j * 3 + 2]).is_degenerate()) {
continue;
+ }
indices.push_back(vertex_ofs + j * 3 + 0);
indices.push_back(vertex_ofs + j * 3 + 1);
@@ -1453,8 +1401,9 @@ Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cach
const int *ri = rindices.ptr();
for (int j = 0; j < ic / 3; j++) {
- if (Face3(r[ri[j * 3 + 0]], r[ri[j * 3 + 1]], r[ri[j * 3 + 2]]).is_degenerate())
+ if (Face3(r[ri[j * 3 + 0]], r[ri[j * 3 + 1]], r[ri[j * 3 + 2]]).is_degenerate()) {
continue;
+ }
indices.push_back(vertex_ofs + ri[j * 3 + 0]);
indices.push_back(vertex_ofs + ri[j * 3 + 1]);
indices.push_back(vertex_ofs + ri[j * 3 + 2]);
@@ -1497,7 +1446,6 @@ Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cach
print_verbose("Mesh: Gen indices: " + itos(gen_index_count));
//go through all indices
for (int i = 0; i < gen_index_count; i += 3) {
-
ERR_FAIL_INDEX_V(gen_vertices[gen_indices[i + 0]], uv_indices.size(), ERR_BUG);
ERR_FAIL_INDEX_V(gen_vertices[gen_indices[i + 1]], uv_indices.size(), ERR_BUG);
ERR_FAIL_INDEX_V(gen_vertices[gen_indices[i + 2]], uv_indices.size(), ERR_BUG);
@@ -1507,7 +1455,6 @@ Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cach
int surface = uv_indices[gen_vertices[gen_indices[i + 0]]].first;
for (int j = 0; j < 3; j++) {
-
SurfaceTool::Vertex v = lightmap_surfaces[surface].vertices[uv_indices[gen_vertices[gen_indices[i + j]]].second];
if (lightmap_surfaces[surface].format & ARRAY_FORMAT_COLOR) {
@@ -1559,7 +1506,6 @@ Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cach
}
void ArrayMesh::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_blend_shape", "name"), &ArrayMesh::add_blend_shape);
ClassDB::bind_method(D_METHOD("get_blend_shape_count"), &ArrayMesh::get_blend_shape_count);
ClassDB::bind_method(D_METHOD("get_blend_shape_name", "index"), &ArrayMesh::get_blend_shape_name);
@@ -1634,14 +1580,12 @@ void ArrayMesh::reload_from_file() {
}
ArrayMesh::ArrayMesh() {
-
//mesh is now created on demand
//mesh = RenderingServer::get_singleton()->mesh_create();
blend_shape_mode = BLEND_SHAPE_MODE_RELATIVE;
}
ArrayMesh::~ArrayMesh() {
-
if (mesh.is_valid()) {
RenderingServer::get_singleton()->free(mesh);
}
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 80cd57846b..44e4e78322 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -152,7 +152,6 @@ public:
};
class ArrayMesh : public Mesh {
-
GDCLASS(ArrayMesh, Mesh);
RES_BASE_EXTENSION("mesh");
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index 76d96786bc..a5c360f123 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -31,7 +31,6 @@
#include "mesh_data_tool.h"
void MeshDataTool::clear() {
-
vertices.clear();
edges.clear();
faces.clear();
@@ -40,7 +39,6 @@ void MeshDataTool::clear() {
}
Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surface) {
-
ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface) != Mesh::PRIMITIVE_TRIANGLES, ERR_INVALID_PARAMETER);
@@ -59,51 +57,61 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
const Vector3 *vr = varray.ptr();
const Vector3 *nr = nullptr;
- if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL) {
nr = arrays[Mesh::ARRAY_NORMAL].operator Vector<Vector3>().ptr();
+ }
const real_t *ta = nullptr;
- if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL) {
ta = arrays[Mesh::ARRAY_TANGENT].operator Vector<real_t>().ptr();
+ }
const Vector2 *uv = nullptr;
- if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL) {
uv = arrays[Mesh::ARRAY_TEX_UV].operator Vector<Vector2>().ptr();
+ }
const Vector2 *uv2 = nullptr;
- if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL) {
uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator Vector<Vector2>().ptr();
+ }
const Color *col = nullptr;
- if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL) {
col = arrays[Mesh::ARRAY_COLOR].operator Vector<Color>().ptr();
+ }
const int *bo = nullptr;
- if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL) {
bo = arrays[Mesh::ARRAY_BONES].operator Vector<int>().ptr();
+ }
const real_t *we = nullptr;
- if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL)
+ if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL) {
we = arrays[Mesh::ARRAY_WEIGHTS].operator Vector<real_t>().ptr();
+ }
vertices.resize(vcount);
for (int i = 0; i < vcount; i++) {
-
Vertex v;
v.vertex = vr[i];
- if (nr)
+ if (nr) {
v.normal = nr[i];
- if (ta)
+ }
+ if (ta) {
v.tangent = Plane(ta[i * 4 + 0], ta[i * 4 + 1], ta[i * 4 + 2], ta[i * 4 + 3]);
- if (uv)
+ }
+ if (uv) {
v.uv = uv[i];
- if (uv2)
+ }
+ if (uv2) {
v.uv2 = uv2[i];
- if (col)
+ }
+ if (col) {
v.color = col[i];
+ }
if (we) {
-
v.weights.push_back(we[i * 4 + 0]);
v.weights.push_back(we[i * 4 + 1]);
v.weights.push_back(we[i * 4 + 2]);
@@ -111,7 +119,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
}
if (bo) {
-
v.bones.push_back(bo[i * 4 + 0]);
v.bones.push_back(bo[i * 4 + 1]);
v.bones.push_back(bo[i * 4 + 2]);
@@ -124,14 +131,14 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
Vector<int> indices;
if (arrays[Mesh::ARRAY_INDEX].get_type() != Variant::NIL) {
-
indices = arrays[Mesh::ARRAY_INDEX];
} else {
//make code simpler
indices.resize(vcount);
int *iw = indices.ptrw();
- for (int i = 0; i < vcount; i++)
+ for (int i = 0; i < vcount; i++) {
iw[i] = i;
+ }
}
int icount = indices.size();
@@ -140,14 +147,12 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
Map<Point2i, int> edge_indices;
for (int i = 0; i < icount; i += 3) {
-
Vertex *v[3] = { &vertices.write[r[i + 0]], &vertices.write[r[i + 1]], &vertices.write[r[i + 2]] };
int fidx = faces.size();
Face face;
for (int j = 0; j < 3; j++) {
-
face.v[j] = r[i + j];
Point2i edge(r[i + j], r[i + (j + 1) % 3]);
@@ -180,7 +185,6 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
}
Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
-
ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
Array arr;
arr.resize(Mesh::ARRAY_MAX);
@@ -198,7 +202,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
Vector<int> in;
{
-
v.resize(vcount);
Vector3 *vr = v.ptrw();
@@ -245,27 +248,29 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
}
for (int i = 0; i < vcount; i++) {
-
const Vertex &vtx = vertices[i];
vr[i] = vtx.vertex;
- if (nr)
+ if (nr) {
nr[i] = vtx.normal;
+ }
if (ta) {
ta[i * 4 + 0] = vtx.tangent.normal.x;
ta[i * 4 + 1] = vtx.tangent.normal.y;
ta[i * 4 + 2] = vtx.tangent.normal.z;
ta[i * 4 + 3] = vtx.tangent.d;
}
- if (uv)
+ if (uv) {
uv[i] = vtx.uv;
- if (uv2)
+ }
+ if (uv2) {
uv2[i] = vtx.uv2;
- if (col)
+ }
+ if (col) {
col[i] = vtx.color;
+ }
if (we) {
-
we[i * 4 + 0] = vtx.weights[0];
we[i * 4 + 1] = vtx.weights[1];
we[i * 4 + 2] = vtx.weights[2];
@@ -273,7 +278,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
}
if (bo) {
-
bo[i * 4 + 0] = vtx.bones[0];
bo[i * 4 + 1] = vtx.bones[1];
bo[i * 4 + 2] = vtx.bones[2];
@@ -285,7 +289,6 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
in.resize(fc * 3);
int *iw = in.ptrw();
for (int i = 0; i < fc; i++) {
-
iw[i * 3 + 0] = faces[i].v[0];
iw[i * 3 + 1] = faces[i].v[1];
iw[i * 3 + 2] = faces[i].v[2];
@@ -294,20 +297,27 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
arr[Mesh::ARRAY_VERTEX] = v;
arr[Mesh::ARRAY_INDEX] = in;
- if (n.size())
+ if (n.size()) {
arr[Mesh::ARRAY_NORMAL] = n;
- if (c.size())
+ }
+ if (c.size()) {
arr[Mesh::ARRAY_COLOR] = c;
- if (u.size())
+ }
+ if (u.size()) {
arr[Mesh::ARRAY_TEX_UV] = u;
- if (u2.size())
+ }
+ if (u2.size()) {
arr[Mesh::ARRAY_TEX_UV2] = u2;
- if (t.size())
+ }
+ if (t.size()) {
arr[Mesh::ARRAY_TANGENT] = t;
- if (b.size())
+ }
+ if (b.size()) {
arr[Mesh::ARRAY_BONES] = b;
- if (w.size())
+ }
+ if (w.size()) {
arr[Mesh::ARRAY_WEIGHTS] = w;
+ }
Ref<ArrayMesh> ncmesh = p_mesh;
int sc = ncmesh->get_surface_count();
@@ -318,111 +328,102 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) {
}
int MeshDataTool::get_format() const {
-
return format;
}
int MeshDataTool::get_vertex_count() const {
-
return vertices.size();
}
-int MeshDataTool::get_edge_count() const {
+int MeshDataTool::get_edge_count() const {
return edges.size();
}
-int MeshDataTool::get_face_count() const {
+int MeshDataTool::get_face_count() const {
return faces.size();
}
Vector3 MeshDataTool::get_vertex(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
return vertices[p_idx].vertex;
}
-void MeshDataTool::set_vertex(int p_idx, const Vector3 &p_vertex) {
+void MeshDataTool::set_vertex(int p_idx, const Vector3 &p_vertex) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].vertex = p_vertex;
}
Vector3 MeshDataTool::get_vertex_normal(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
return vertices[p_idx].normal;
}
-void MeshDataTool::set_vertex_normal(int p_idx, const Vector3 &p_normal) {
+void MeshDataTool::set_vertex_normal(int p_idx, const Vector3 &p_normal) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].normal = p_normal;
format |= Mesh::ARRAY_FORMAT_NORMAL;
}
Plane MeshDataTool::get_vertex_tangent(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Plane());
return vertices[p_idx].tangent;
}
-void MeshDataTool::set_vertex_tangent(int p_idx, const Plane &p_tangent) {
+void MeshDataTool::set_vertex_tangent(int p_idx, const Plane &p_tangent) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].tangent = p_tangent;
format |= Mesh::ARRAY_FORMAT_TANGENT;
}
Vector2 MeshDataTool::get_vertex_uv(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
return vertices[p_idx].uv;
}
-void MeshDataTool::set_vertex_uv(int p_idx, const Vector2 &p_uv) {
+void MeshDataTool::set_vertex_uv(int p_idx, const Vector2 &p_uv) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].uv = p_uv;
format |= Mesh::ARRAY_FORMAT_TEX_UV;
}
Vector2 MeshDataTool::get_vertex_uv2(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
return vertices[p_idx].uv2;
}
-void MeshDataTool::set_vertex_uv2(int p_idx, const Vector2 &p_uv2) {
+void MeshDataTool::set_vertex_uv2(int p_idx, const Vector2 &p_uv2) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].uv2 = p_uv2;
format |= Mesh::ARRAY_FORMAT_TEX_UV2;
}
Color MeshDataTool::get_vertex_color(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Color());
return vertices[p_idx].color;
}
-void MeshDataTool::set_vertex_color(int p_idx, const Color &p_color) {
+void MeshDataTool::set_vertex_color(int p_idx, const Color &p_color) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].color = p_color;
format |= Mesh::ARRAY_FORMAT_COLOR;
}
Vector<int> MeshDataTool::get_vertex_bones(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
return vertices[p_idx].bones;
}
-void MeshDataTool::set_vertex_bones(int p_idx, const Vector<int> &p_bones) {
+void MeshDataTool::set_vertex_bones(int p_idx, const Vector<int> &p_bones) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].bones = p_bones;
format |= Mesh::ARRAY_FORMAT_BONES;
}
Vector<float> MeshDataTool::get_vertex_weights(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<float>());
return vertices[p_idx].weights;
}
+
void MeshDataTool::set_vertex_weights(int p_idx, const Vector<float> &p_weights) {
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].weights = p_weights;
@@ -430,75 +431,69 @@ void MeshDataTool::set_vertex_weights(int p_idx, const Vector<float> &p_weights)
}
Variant MeshDataTool::get_vertex_meta(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Variant());
return vertices[p_idx].meta;
}
void MeshDataTool::set_vertex_meta(int p_idx, const Variant &p_meta) {
-
ERR_FAIL_INDEX(p_idx, vertices.size());
vertices.write[p_idx].meta = p_meta;
}
Vector<int> MeshDataTool::get_vertex_edges(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
return vertices[p_idx].edges;
}
-Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const {
+Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
return vertices[p_idx].faces;
}
int MeshDataTool::get_edge_vertex(int p_edge, int p_vertex) const {
-
ERR_FAIL_INDEX_V(p_edge, edges.size(), -1);
ERR_FAIL_INDEX_V(p_vertex, 2, -1);
return edges[p_edge].vertex[p_vertex];
}
-Vector<int> MeshDataTool::get_edge_faces(int p_edge) const {
+Vector<int> MeshDataTool::get_edge_faces(int p_edge) const {
ERR_FAIL_INDEX_V(p_edge, edges.size(), Vector<int>());
return edges[p_edge].faces;
}
-Variant MeshDataTool::get_edge_meta(int p_idx) const {
+Variant MeshDataTool::get_edge_meta(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, edges.size(), Variant());
return edges[p_idx].meta;
}
-void MeshDataTool::set_edge_meta(int p_idx, const Variant &p_meta) {
+void MeshDataTool::set_edge_meta(int p_idx, const Variant &p_meta) {
ERR_FAIL_INDEX(p_idx, edges.size());
edges.write[p_idx].meta = p_meta;
}
int MeshDataTool::get_face_vertex(int p_face, int p_vertex) const {
-
ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
ERR_FAIL_INDEX_V(p_vertex, 3, -1);
return faces[p_face].v[p_vertex];
}
-int MeshDataTool::get_face_edge(int p_face, int p_vertex) const {
+int MeshDataTool::get_face_edge(int p_face, int p_vertex) const {
ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
ERR_FAIL_INDEX_V(p_vertex, 3, -1);
return faces[p_face].edges[p_vertex];
}
-Variant MeshDataTool::get_face_meta(int p_face) const {
+Variant MeshDataTool::get_face_meta(int p_face) const {
ERR_FAIL_INDEX_V(p_face, faces.size(), Variant());
return faces[p_face].meta;
}
-void MeshDataTool::set_face_meta(int p_face, const Variant &p_meta) {
+void MeshDataTool::set_face_meta(int p_face, const Variant &p_meta) {
ERR_FAIL_INDEX(p_face, faces.size());
faces.write[p_face].meta = p_meta;
}
Vector3 MeshDataTool::get_face_normal(int p_face) const {
-
ERR_FAIL_INDEX_V(p_face, faces.size(), Vector3());
Vector3 v0 = vertices[faces[p_face].v[0]].vertex;
Vector3 v1 = vertices[faces[p_face].v[1]].vertex;
@@ -508,17 +503,14 @@ Vector3 MeshDataTool::get_face_normal(int p_face) const {
}
Ref<Material> MeshDataTool::get_material() const {
-
return material;
}
void MeshDataTool::set_material(const Ref<Material> &p_material) {
-
material = p_material;
}
void MeshDataTool::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("clear"), &MeshDataTool::clear);
ClassDB::bind_method(D_METHOD("create_from_surface", "mesh", "surface"), &MeshDataTool::create_from_surface);
ClassDB::bind_method(D_METHOD("commit_to_surface", "mesh"), &MeshDataTool::commit_to_surface);
@@ -578,6 +570,5 @@ void MeshDataTool::_bind_methods() {
}
MeshDataTool::MeshDataTool() {
-
clear();
}
diff --git a/scene/resources/mesh_data_tool.h b/scene/resources/mesh_data_tool.h
index 5ac2c7e702..bf9f0dd25f 100644
--- a/scene/resources/mesh_data_tool.h
+++ b/scene/resources/mesh_data_tool.h
@@ -34,7 +34,6 @@
#include "scene/resources/mesh.h"
class MeshDataTool : public Reference {
-
GDCLASS(MeshDataTool, Reference);
int format;
@@ -55,7 +54,6 @@ class MeshDataTool : public Reference {
Vector<Vertex> vertices;
struct Edge {
-
int vertex[2];
Vector<int> faces;
Variant meta;
@@ -64,7 +62,6 @@ class MeshDataTool : public Reference {
Vector<Edge> edges;
struct Face {
-
int v[3];
int edges[3];
Variant meta;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index fffd192348..09b0d4b038 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -31,20 +31,19 @@
#include "mesh_library.h"
bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name.begins_with("item/")) {
-
int idx = name.get_slicec('/', 1).to_int();
String what = name.get_slicec('/', 2);
- if (!item_map.has(idx))
+ if (!item_map.has(idx)) {
create_item(idx);
+ }
- if (what == "name")
+ if (what == "name") {
set_item_name(idx, p_value);
- else if (what == "mesh")
+ } else if (what == "mesh") {
set_item_mesh(idx, p_value);
- else if (what == "shape") {
+ } else if (what == "shape") {
Vector<ShapeData> shapes;
ShapeData sd;
sd.shape = p_value;
@@ -52,14 +51,15 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
set_item_shapes(idx, shapes);
} else if (what == "shapes") {
_set_item_shapes(idx, p_value);
- } else if (what == "preview")
+ } else if (what == "preview") {
set_item_preview(idx, p_value);
- else if (what == "navmesh")
+ } else if (what == "navmesh") {
set_item_navmesh(idx, p_value);
- else if (what == "navmesh_transform")
+ } else if (what == "navmesh_transform") {
set_item_navmesh_transform(idx, p_value);
- else
+ } else {
return false;
+ }
return true;
}
@@ -68,34 +68,32 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
}
bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
int idx = name.get_slicec('/', 1).to_int();
ERR_FAIL_COND_V(!item_map.has(idx), false);
String what = name.get_slicec('/', 2);
- if (what == "name")
+ if (what == "name") {
r_ret = get_item_name(idx);
- else if (what == "mesh")
+ } else if (what == "mesh") {
r_ret = get_item_mesh(idx);
- else if (what == "shapes")
+ } else if (what == "shapes") {
r_ret = _get_item_shapes(idx);
- else if (what == "navmesh")
+ } else if (what == "navmesh") {
r_ret = get_item_navmesh(idx);
- else if (what == "navmesh_transform")
+ } else if (what == "navmesh_transform") {
r_ret = get_item_navmesh_transform(idx);
- else if (what == "preview")
+ } else if (what == "preview") {
r_ret = get_item_preview(idx);
- else
+ } else {
return false;
+ }
return true;
}
void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
-
for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
-
String name = "item/" + itos(E->key()) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, name + "name"));
p_list->push_back(PropertyInfo(Variant::OBJECT, name + "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"));
@@ -108,7 +106,6 @@ void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
}
void MeshLibrary::create_item(int p_item) {
-
ERR_FAIL_COND(p_item < 0);
ERR_FAIL_COND(item_map.has(p_item));
item_map[p_item] = Item();
@@ -116,7 +113,6 @@ void MeshLibrary::create_item(int p_item) {
}
void MeshLibrary::set_item_name(int p_item, const String &p_name) {
-
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].name = p_name;
emit_changed();
@@ -124,7 +120,6 @@ void MeshLibrary::set_item_name(int p_item, const String &p_name) {
}
void MeshLibrary::set_item_mesh(int p_item, const Ref<Mesh> &p_mesh) {
-
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].mesh = p_mesh;
notify_change_to_owners();
@@ -133,7 +128,6 @@ void MeshLibrary::set_item_mesh(int p_item, const Ref<Mesh> &p_mesh) {
}
void MeshLibrary::set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes) {
-
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].shapes = p_shapes;
_change_notify();
@@ -143,7 +137,6 @@ void MeshLibrary::set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes)
}
void MeshLibrary::set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh) {
-
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].navmesh = p_navmesh;
_change_notify();
@@ -153,7 +146,6 @@ void MeshLibrary::set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navm
}
void MeshLibrary::set_item_navmesh_transform(int p_item, const Transform &p_transform) {
-
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].navmesh_transform = p_transform;
notify_change_to_owners();
@@ -162,7 +154,6 @@ void MeshLibrary::set_item_navmesh_transform(int p_item, const Transform &p_tran
}
void MeshLibrary::set_item_preview(int p_item, const Ref<Texture2D> &p_preview) {
-
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].preview = p_preview;
emit_changed();
@@ -170,47 +161,40 @@ void MeshLibrary::set_item_preview(int p_item, const Ref<Texture2D> &p_preview)
}
String MeshLibrary::get_item_name(int p_item) const {
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), "", "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].name;
}
Ref<Mesh> MeshLibrary::get_item_mesh(int p_item) const {
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Mesh>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].mesh;
}
Vector<MeshLibrary::ShapeData> MeshLibrary::get_item_shapes(int p_item) const {
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Vector<ShapeData>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].shapes;
}
Ref<NavigationMesh> MeshLibrary::get_item_navmesh(int p_item) const {
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<NavigationMesh>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].navmesh;
}
Transform MeshLibrary::get_item_navmesh_transform(int p_item) const {
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Transform(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].navmesh_transform;
}
Ref<Texture2D> MeshLibrary::get_item_preview(int p_item) const {
-
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture2D>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].preview;
}
bool MeshLibrary::has_item(int p_item) const {
-
return item_map.has(p_item);
}
-void MeshLibrary::remove_item(int p_item) {
+void MeshLibrary::remove_item(int p_item) {
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map.erase(p_item);
notify_change_to_owners();
@@ -219,7 +203,6 @@ void MeshLibrary::remove_item(int p_item) {
}
void MeshLibrary::clear() {
-
item_map.clear();
notify_change_to_owners();
_change_notify();
@@ -227,12 +210,10 @@ void MeshLibrary::clear() {
}
Vector<int> MeshLibrary::get_item_list() const {
-
Vector<int> ret;
ret.resize(item_map.size());
int idx = 0;
for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
-
ret.write[idx++] = E->key();
}
@@ -240,25 +221,23 @@ Vector<int> MeshLibrary::get_item_list() const {
}
int MeshLibrary::find_item_by_name(const String &p_name) const {
-
for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
-
- if (E->get().name == p_name)
+ if (E->get().name == p_name) {
return E->key();
+ }
}
return -1;
}
int MeshLibrary::get_last_unused_item_id() const {
-
- if (!item_map.size())
+ if (!item_map.size()) {
return 0;
- else
+ } else {
return item_map.back()->key() + 1;
+ }
}
void MeshLibrary::_set_item_shapes(int p_item, const Array &p_shapes) {
-
ERR_FAIL_COND(p_shapes.size() & 1);
Vector<ShapeData> shapes;
for (int i = 0; i < p_shapes.size(); i += 2) {
@@ -275,7 +254,6 @@ void MeshLibrary::_set_item_shapes(int p_item, const Array &p_shapes) {
}
Array MeshLibrary::_get_item_shapes(int p_item) const {
-
Vector<ShapeData> shapes = get_item_shapes(p_item);
Array ret;
for (int i = 0; i < shapes.size(); i++) {
@@ -287,7 +265,6 @@ Array MeshLibrary::_get_item_shapes(int p_item) const {
}
void MeshLibrary::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create_item", "id"), &MeshLibrary::create_item);
ClassDB::bind_method(D_METHOD("set_item_name", "id", "name"), &MeshLibrary::set_item_name);
ClassDB::bind_method(D_METHOD("set_item_mesh", "id", "mesh"), &MeshLibrary::set_item_mesh);
@@ -311,5 +288,6 @@ void MeshLibrary::_bind_methods() {
MeshLibrary::MeshLibrary() {
}
+
MeshLibrary::~MeshLibrary() {
}
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 55001f2545..7b78398669 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -38,7 +38,6 @@
#include "shape_3d.h"
class MeshLibrary : public Resource {
-
GDCLASS(MeshLibrary, Resource);
RES_BASE_EXTENSION("meshlib");
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index ce561bfaaf..f71cf383e5 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -36,19 +36,20 @@
// Kept for compatibility from 3.x to 4.0.
void MultiMesh::_set_transform_array(const Vector<Vector3> &p_array) {
- if (transform_format != TRANSFORM_3D)
+ if (transform_format != TRANSFORM_3D) {
return;
+ }
const Vector<Vector3> &xforms = p_array;
int len = xforms.size();
ERR_FAIL_COND((len / 4) != instance_count);
- if (len == 0)
+ if (len == 0) {
return;
+ }
const Vector3 *r = xforms.ptr();
for (int i = 0; i < len / 4; i++) {
-
Transform t;
t.basis[0] = r[i * 4 + 0];
t.basis[1] = r[i * 4 + 1];
@@ -60,12 +61,13 @@ void MultiMesh::_set_transform_array(const Vector<Vector3> &p_array) {
}
Vector<Vector3> MultiMesh::_get_transform_array() const {
-
- if (transform_format != TRANSFORM_3D)
+ if (transform_format != TRANSFORM_3D) {
return Vector<Vector3>();
+ }
- if (instance_count == 0)
+ if (instance_count == 0) {
return Vector<Vector3>();
+ }
Vector<Vector3> xforms;
xforms.resize(instance_count * 4);
@@ -73,7 +75,6 @@ Vector<Vector3> MultiMesh::_get_transform_array() const {
Vector3 *w = xforms.ptrw();
for (int i = 0; i < instance_count; i++) {
-
Transform t = get_instance_transform(i);
w[i * 4 + 0] = t.basis[0];
w[i * 4 + 1] = t.basis[1];
@@ -85,20 +86,20 @@ Vector<Vector3> MultiMesh::_get_transform_array() const {
}
void MultiMesh::_set_transform_2d_array(const Vector<Vector2> &p_array) {
-
- if (transform_format != TRANSFORM_2D)
+ if (transform_format != TRANSFORM_2D) {
return;
+ }
const Vector<Vector2> &xforms = p_array;
int len = xforms.size();
ERR_FAIL_COND((len / 3) != instance_count);
- if (len == 0)
+ if (len == 0) {
return;
+ }
const Vector2 *r = xforms.ptr();
for (int i = 0; i < len / 3; i++) {
-
Transform2D t;
t.elements[0] = r[i * 3 + 0];
t.elements[1] = r[i * 3 + 1];
@@ -109,12 +110,13 @@ void MultiMesh::_set_transform_2d_array(const Vector<Vector2> &p_array) {
}
Vector<Vector2> MultiMesh::_get_transform_2d_array() const {
-
- if (transform_format != TRANSFORM_2D)
+ if (transform_format != TRANSFORM_2D) {
return Vector<Vector2>();
+ }
- if (instance_count == 0)
+ if (instance_count == 0) {
return Vector<Vector2>();
+ }
Vector<Vector2> xforms;
xforms.resize(instance_count * 3);
@@ -122,7 +124,6 @@ Vector<Vector2> MultiMesh::_get_transform_2d_array() const {
Vector2 *w = xforms.ptrw();
for (int i = 0; i < instance_count; i++) {
-
Transform2D t = get_instance_transform_2d(i);
w[i * 3 + 0] = t.elements[0];
w[i * 3 + 1] = t.elements[1];
@@ -133,31 +134,29 @@ Vector<Vector2> MultiMesh::_get_transform_2d_array() const {
}
void MultiMesh::_set_color_array(const Vector<Color> &p_array) {
-
const Vector<Color> &colors = p_array;
int len = colors.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
ERR_FAIL_COND(len != instance_count);
const Color *r = colors.ptr();
for (int i = 0; i < len; i++) {
-
set_instance_color(i, r[i]);
}
}
Vector<Color> MultiMesh::_get_color_array() const {
-
- if (instance_count == 0 || !use_colors)
+ if (instance_count == 0 || !use_colors) {
return Vector<Color>();
+ }
Vector<Color> colors;
colors.resize(instance_count);
for (int i = 0; i < instance_count; i++) {
-
colors.set(i, get_instance_color(i));
}
@@ -165,31 +164,29 @@ Vector<Color> MultiMesh::_get_color_array() const {
}
void MultiMesh::_set_custom_data_array(const Vector<Color> &p_array) {
-
const Vector<Color> &custom_datas = p_array;
int len = custom_datas.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
ERR_FAIL_COND(len != instance_count);
const Color *r = custom_datas.ptr();
for (int i = 0; i < len; i++) {
-
set_instance_custom_data(i, r[i]);
}
}
Vector<Color> MultiMesh::_get_custom_data_array() const {
-
- if (instance_count == 0 || !use_custom_data)
+ if (instance_count == 0 || !use_custom_data) {
return Vector<Color>();
+ }
Vector<Color> custom_datas;
custom_datas.resize(instance_count);
for (int i = 0; i < instance_count; i++) {
-
custom_datas.set(i, get_instance_custom_data(i));
}
@@ -206,16 +203,15 @@ Vector<float> MultiMesh::get_buffer() const {
}
void MultiMesh::set_mesh(const Ref<Mesh> &p_mesh) {
-
mesh = p_mesh;
- if (!mesh.is_null())
+ if (!mesh.is_null()) {
RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
- else
+ } else {
RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, RID());
+ }
}
Ref<Mesh> MultiMesh::get_mesh() const {
-
return mesh;
}
@@ -224,8 +220,8 @@ void MultiMesh::set_instance_count(int p_count) {
RenderingServer::get_singleton()->multimesh_allocate(multimesh, p_count, RS::MultimeshTransformFormat(transform_format), use_colors, use_custom_data);
instance_count = p_count;
}
-int MultiMesh::get_instance_count() const {
+int MultiMesh::get_instance_count() const {
return instance_count;
}
@@ -235,56 +231,48 @@ void MultiMesh::set_visible_instance_count(int p_count) {
RenderingServer::get_singleton()->multimesh_set_visible_instances(multimesh, p_count);
visible_instance_count = p_count;
}
-int MultiMesh::get_visible_instance_count() const {
+int MultiMesh::get_visible_instance_count() const {
return visible_instance_count;
}
void MultiMesh::set_instance_transform(int p_instance, const Transform &p_transform) {
-
RenderingServer::get_singleton()->multimesh_instance_set_transform(multimesh, p_instance, p_transform);
}
void MultiMesh::set_instance_transform_2d(int p_instance, const Transform2D &p_transform) {
-
RenderingServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform);
}
Transform MultiMesh::get_instance_transform(int p_instance) const {
-
return RenderingServer::get_singleton()->multimesh_instance_get_transform(multimesh, p_instance);
}
Transform2D MultiMesh::get_instance_transform_2d(int p_instance) const {
-
return RenderingServer::get_singleton()->multimesh_instance_get_transform_2d(multimesh, p_instance);
}
void MultiMesh::set_instance_color(int p_instance, const Color &p_color) {
-
RenderingServer::get_singleton()->multimesh_instance_set_color(multimesh, p_instance, p_color);
}
-Color MultiMesh::get_instance_color(int p_instance) const {
+Color MultiMesh::get_instance_color(int p_instance) const {
return RenderingServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance);
}
void MultiMesh::set_instance_custom_data(int p_instance, const Color &p_custom_data) {
-
RenderingServer::get_singleton()->multimesh_instance_set_custom_data(multimesh, p_instance, p_custom_data);
}
-Color MultiMesh::get_instance_custom_data(int p_instance) const {
+Color MultiMesh::get_instance_custom_data(int p_instance) const {
return RenderingServer::get_singleton()->multimesh_instance_get_custom_data(multimesh, p_instance);
}
AABB MultiMesh::get_aabb() const {
-
return RenderingServer::get_singleton()->multimesh_get_aabb(multimesh);
}
RID MultiMesh::get_rid() const {
-
return multimesh;
}
@@ -307,17 +295,15 @@ bool MultiMesh::is_using_custom_data() const {
}
void MultiMesh::set_transform_format(TransformFormat p_transform_format) {
-
ERR_FAIL_COND(instance_count > 0);
transform_format = p_transform_format;
}
-MultiMesh::TransformFormat MultiMesh::get_transform_format() const {
+MultiMesh::TransformFormat MultiMesh::get_transform_format() const {
return transform_format;
}
void MultiMesh::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MultiMesh::set_mesh);
ClassDB::bind_method(D_METHOD("get_mesh"), &MultiMesh::get_mesh);
ClassDB::bind_method(D_METHOD("set_use_colors", "enable"), &MultiMesh::set_use_colors);
@@ -374,7 +360,6 @@ void MultiMesh::_bind_methods() {
}
MultiMesh::MultiMesh() {
-
multimesh = RenderingServer::get_singleton()->multimesh_create();
use_colors = false;
use_custom_data = false;
@@ -384,6 +369,5 @@ MultiMesh::MultiMesh() {
}
MultiMesh::~MultiMesh() {
-
RenderingServer::get_singleton()->free(multimesh);
}
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index c1e52bc981..8478789d41 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -35,7 +35,6 @@
#include "servers/rendering_server.h"
class MultiMesh : public Resource {
-
GDCLASS(MultiMesh, Resource);
RES_BASE_EXTENSION("multimesh");
diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp
index e0aff2182e..e815da5d45 100644
--- a/scene/resources/navigation_mesh.cpp
+++ b/scene/resources/navigation_mesh.cpp
@@ -31,19 +31,19 @@
#include "navigation_mesh.h"
void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
-
vertices = Vector<Vector3>();
clear_polygons();
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
-
- if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
+ }
Array arr = p_mesh->surface_get_arrays(i);
Vector<Vector3> varr = arr[Mesh::ARRAY_VERTEX];
Vector<int> iarr = arr[Mesh::ARRAY_INDEX];
- if (varr.size() == 0 || iarr.size() == 0)
+ if (varr.size() == 0 || iarr.size() == 0) {
continue;
+ }
int from = vertices.size();
vertices.append_array(varr);
@@ -82,27 +82,24 @@ int NavigationMesh::get_parsed_geometry_type() const {
}
void NavigationMesh::set_collision_mask(uint32_t p_mask) {
-
collision_mask = p_mask;
}
uint32_t NavigationMesh::get_collision_mask() const {
-
return collision_mask;
}
void NavigationMesh::set_collision_mask_bit(int p_bit, bool p_value) {
-
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
bool NavigationMesh::get_collision_mask_bit(int p_bit) const {
-
return get_collision_mask() & (1 << p_bit);
}
@@ -253,18 +250,15 @@ bool NavigationMesh::get_filter_walkable_low_height_spans() const {
}
void NavigationMesh::set_vertices(const Vector<Vector3> &p_vertices) {
-
vertices = p_vertices;
_change_notify();
}
Vector<Vector3> NavigationMesh::get_vertices() const {
-
return vertices;
}
void NavigationMesh::_set_polygons(const Array &p_array) {
-
polygons.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
polygons.write[i].indices = p_array[i];
@@ -273,7 +267,6 @@ void NavigationMesh::_set_polygons(const Array &p_array) {
}
Array NavigationMesh::_get_polygons() const {
-
Array ret;
ret.resize(polygons.size());
for (int i = 0; i < ret.size(); i++) {
@@ -284,30 +277,29 @@ Array NavigationMesh::_get_polygons() const {
}
void NavigationMesh::add_polygon(const Vector<int> &p_polygon) {
-
Polygon polygon;
polygon.indices = p_polygon;
polygons.push_back(polygon);
_change_notify();
}
-int NavigationMesh::get_polygon_count() const {
+int NavigationMesh::get_polygon_count() const {
return polygons.size();
}
-Vector<int> NavigationMesh::get_polygon(int p_idx) {
+Vector<int> NavigationMesh::get_polygon(int p_idx) {
ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>());
return polygons[p_idx].indices;
}
-void NavigationMesh::clear_polygons() {
+void NavigationMesh::clear_polygons() {
polygons.clear();
}
Ref<Mesh> NavigationMesh::get_debug_mesh() {
-
- if (debug_mesh.is_valid())
+ if (debug_mesh.is_valid()) {
return debug_mesh;
+ }
Vector<Vector3> vertices = get_vertices();
const Vector3 *vr = vertices.ptr();
@@ -334,26 +326,23 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
int tidx = 0;
for (List<Face3>::Element *E = faces.front(); E; E = E->next()) {
-
const Face3 &f = E->get();
for (int j = 0; j < 3; j++) {
-
tw[tidx++] = f.vertex[j];
_EdgeKey ek;
ek.from = f.vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
ek.to = f.vertex[(j + 1) % 3].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON));
- if (ek.from < ek.to)
+ if (ek.from < ek.to) {
SWAP(ek.from, ek.to);
+ }
Map<_EdgeKey, bool>::Element *F = edge_map.find(ek);
if (F) {
-
F->get() = false;
} else {
-
edge_map[ek] = true;
}
}
@@ -362,7 +351,6 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
List<Vector3> lines;
for (Map<_EdgeKey, bool>::Element *E = edge_map.front(); E; E = E->next()) {
-
if (E->get()) {
lines.push_back(E->key().from);
lines.push_back(E->key().to);
diff --git a/scene/resources/navigation_mesh.h b/scene/resources/navigation_mesh.h
index cc3ac6e3fd..6b9d1964f5 100644
--- a/scene/resources/navigation_mesh.h
+++ b/scene/resources/navigation_mesh.h
@@ -36,7 +36,6 @@
class Mesh;
class NavigationMesh : public Resource {
-
GDCLASS(NavigationMesh, Resource);
Vector<Vector3> vertices;
@@ -47,7 +46,6 @@ class NavigationMesh : public Resource {
Ref<ArrayMesh> debug_mesh;
struct _EdgeKey {
-
Vector3 from;
Vector3 to;
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 633771506e..cb201bc539 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -42,12 +42,10 @@
#define PACKED_SCENE_VERSION 2
bool SceneState::can_instance() const {
-
return nodes.size() > 0;
}
Node *SceneState::instance(GenEditState p_edit_state) const {
-
// nodes where instancing failed (because something is missing)
List<Node *> stray_instances;
@@ -66,13 +64,15 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
const StringName *snames = nullptr;
int sname_count = names.size();
- if (sname_count)
+ if (sname_count) {
snames = &names[0];
+ }
const Variant *props = nullptr;
int prop_count = variants.size();
- if (prop_count)
+ if (prop_count) {
props = &variants[0];
+ }
//Vector<Variant> properties;
@@ -85,22 +85,22 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
Map<Ref<Resource>, Ref<Resource>> resources_local_to_scene;
for (int i = 0; i < nc; i++) {
-
const NodeData &n = nd[i];
Node *parent = nullptr;
if (i > 0) {
-
ERR_FAIL_COND_V_MSG(n.parent == -1, nullptr, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name]));
NODE_FROM_ID(nparent, n.parent);
#ifdef DEBUG_ENABLED
if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
-
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
}
#endif
parent = nparent;
+ } else {
+ // i == 0 is root node. Confirm that it doesn't have a parent defined.
+ ERR_FAIL_COND_V_MSG(n.parent != -1, nullptr, vformat("Invalid scene: root node %s cannot specify a parent node.", snames[n.name]));
}
Node *node = nullptr;
@@ -118,10 +118,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
} else if (n.instance >= 0) {
//instance a scene into this node
if (n.instance & FLAG_INSTANCE_IS_PLACEHOLDER) {
-
String path = props[n.instance & FLAG_MASK];
if (disable_placeholders) {
-
Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene");
ERR_FAIL_COND_V(!sdata.is_valid(), nullptr);
node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE);
@@ -187,11 +185,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
//properties
int nprop_count = n.properties.size();
if (nprop_count) {
-
const NodeData::Property *nprops = &n.properties[0];
for (int j = 0; j < nprop_count; j++) {
-
bool valid;
ERR_FAIL_INDEX_V(nprops[j].name, sname_count, nullptr);
ERR_FAIL_INDEX_V(nprops[j].value, prop_count, nullptr);
@@ -213,7 +209,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
node->set(E->get().first, E->get().second);
}
} else {
-
Variant value = props[nprops[j].value];
if (value.get_type() == Variant::OBJECT) {
@@ -221,13 +216,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
Ref<Resource> res = value;
if (res.is_valid()) {
if (res->is_local_to_scene()) {
-
Map<Ref<Resource>, Ref<Resource>>::Element *E = resources_local_to_scene.find(res);
if (E) {
value = E->get();
} else {
-
Node *base = i == 0 ? node : ret_nodes[0];
if (p_edit_state == GEN_EDIT_STATE_MAIN) {
@@ -259,7 +252,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
//groups
for (int j = 0; j < n.groups.size(); j++) {
-
ERR_FAIL_INDEX_V(n.groups[j], sname_count, nullptr);
node->add_to_group(snames[n.groups[j]], true);
}
@@ -269,8 +261,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
if (i > 0) {
if (parent) {
parent->_add_child_nocheck(node, snames[n.name]);
- if (n.index >= 0 && n.index < parent->get_child_count() - 1)
+ if (n.index >= 0 && n.index < parent->get_child_count() - 1) {
parent->move_child(node, n.index);
+ }
} else {
//it may be possible that an instanced scene has changed
//and the node has nowhere to go anymore
@@ -287,10 +280,10 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
if (n.owner >= 0) {
-
NODE_FROM_ID(owner, n.owner);
- if (owner)
+ if (owner) {
node->_set_owner_nocheck(owner);
+ }
}
}
@@ -303,7 +296,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
for (Map<Ref<Resource>, Ref<Resource>>::Element *E = resources_local_to_scene.front(); E; E = E->next()) {
-
E->get()->setup_local_to_scene();
}
@@ -313,7 +305,6 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
const ConnectionData *cdata = connections.ptr();
for (int i = 0; i < cc; i++) {
-
const ConnectionData &c = cdata[i];
//ERR_FAIL_INDEX_V( c.from, nc, nullptr );
//ERR_FAIL_INDEX_V( c.to, nc, nullptr );
@@ -321,14 +312,16 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
NODE_FROM_ID(cfrom, c.from);
NODE_FROM_ID(cto, c.to);
- if (!cfrom || !cto)
+ if (!cfrom || !cto) {
continue;
+ }
Vector<Variant> binds;
if (c.binds.size()) {
binds.resize(c.binds.size());
- for (int j = 0; j < c.binds.size(); j++)
+ for (int j = 0; j < c.binds.size(); j++) {
binds.write[j] = props[c.binds[j]];
+ }
}
cfrom->connect(snames[c.signal], Callable(cto, snames[c.method]), binds, CONNECT_PERSIST | c.flags);
@@ -353,9 +346,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map) {
-
- if (name_map.has(p_string))
+ if (name_map.has(p_string)) {
return name_map[p_string];
+ }
int idx = name_map.size();
name_map[p_string] = idx;
@@ -363,9 +356,9 @@ static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map
}
static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map) {
-
- if (variant_map.has(p_variant))
+ if (variant_map.has(p_variant)) {
return variant_map[p_variant];
+ }
int idx = variant_map.size();
variant_map[p_variant] = idx;
@@ -373,20 +366,21 @@ static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, Varia
}
Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) {
-
// this function handles all the work related to properly packing scenes, be it
// instanced or inherited.
// given the complexity of this process, an attempt will be made to properly
// document it. if you fail to understand something, please ask!
//discard nodes that do not belong to be processed
- if (p_node != p_owner && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
+ if (p_node != p_owner && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner())) {
return OK;
+ }
// save the child instanced scenes that are chosen as editable, so they can be restored
// upon load back
- if (p_node != p_owner && p_node->get_filename() != String() && p_owner->is_editable_instance(p_node))
+ if (p_node != p_owner && p_node->get_filename() != String() && p_owner->is_editable_instance(p_node)) {
editable_instances.push_back(p_owner->get_path_to(p_node));
+ }
NodeData nd;
@@ -418,9 +412,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
Node *n = p_node;
while (n) {
-
if (n == p_owner) {
-
Ref<SceneState> state = n->get_scene_inherited_state();
if (state.is_valid()) {
int node = state->find_node_by_path(n->get_path_to(p_node));
@@ -435,7 +427,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
if (p_node->get_filename() != String() && p_node->get_owner() == p_owner && instanced_by_owner) {
-
if (p_node->get_scene_instance_load_placeholder()) {
//it's a placeholder, use the placeholder path
nd.instance = _vm_get_variant(p_node->get_filename(), variant_map);
@@ -479,7 +470,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
StringName type = p_node->get_class();
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
-
if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -530,17 +520,16 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
if (exists) {
-
//check if already exists and did not change
if (value.get_type() == Variant::FLOAT && original.get_type() == Variant::FLOAT) {
//this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error
float a = value;
float b = original;
- if (Math::is_equal_approx(a, b))
+ if (Math::is_equal_approx(a, b)) {
continue;
+ }
} else if (bool(Variant::evaluate(Variant::OP_EQUAL, value, original))) {
-
continue;
}
}
@@ -552,7 +541,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
} else {
-
if (isdefault) {
//it's the default value, no point in saving it
continue;
@@ -573,8 +561,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
for (List<Node::GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
Node::GroupInfo &gi = E->get();
- if (!gi.persistent)
+ if (!gi.persistent) {
continue;
+ }
/*
if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
continue; //group was instanced, don't add here
@@ -590,8 +579,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
}
- if (skip)
+ if (skip) {
continue;
+ }
nd.groups.push_back(_nm_get_string(gi.name, name_map));
}
@@ -608,7 +598,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
//part of saved scene
nd.owner = 0;
} else {
-
nd.owner = -1;
}
@@ -637,14 +626,12 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
int parent_node = NO_PARENT_SAVED;
if (save_node) {
-
//don't save the node if nothing and subscene
node_map[p_node] = idx;
//ok validate parent node
if (p_parent_idx == NO_PARENT_SAVED) {
-
int sidx;
if (nodepath_map.has(p_node->get_parent())) {
sidx = nodepath_map[p_node->get_parent()];
@@ -663,20 +650,20 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *c = p_node->get_child(i);
Error err = _parse_node(p_owner, c, parent_node, name_map, variant_map, node_map, nodepath_map);
- if (err)
+ if (err) {
return err;
+ }
}
return OK;
}
Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher, VariantComparator> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) {
-
- if (p_node != p_owner && p_node->get_owner() && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
+ if (p_node != p_owner && p_node->get_owner() && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner())) {
return OK;
+ }
List<MethodInfo> _signals;
p_node->get_signal_list(&_signals);
@@ -686,18 +673,17 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
//NodeData &nd = nodes[node_map[p_node]];
for (List<MethodInfo>::Element *E = _signals.front(); E; E = E->next()) {
-
List<Node::Connection> conns;
p_node->get_signal_connection_list(E->get().name, &conns);
conns.sort();
for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) {
-
const Node::Connection &c = F->get();
- if (!(c.flags & CONNECT_PERSIST)) //only persistent connections get saved
+ if (!(c.flags & CONNECT_PERSIST)) { //only persistent connections get saved
continue;
+ }
// only connections that originate or end into main saved scene are saved
// everything else is discarded
@@ -721,16 +707,15 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
//go through ownership chain to see if this exists
while (common_parent) {
-
Ref<SceneState> ps;
- if (common_parent == p_owner)
+ if (common_parent == p_owner) {
ps = common_parent->get_scene_inherited_state();
- else
+ } else {
ps = common_parent->get_scene_instance_state();
+ }
if (ps.is_valid()) {
-
NodePath signal_from = common_parent->get_path_to(p_node);
NodePath signal_to = common_parent->get_path_to(target);
@@ -740,10 +725,11 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
}
}
- if (common_parent == p_owner)
+ if (common_parent == p_owner) {
break;
- else
+ } else {
common_parent = common_parent->get_owner();
+ }
}
if (exists) { //already exists (comes from instance or inheritance), so don't save
@@ -756,9 +742,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
bool exists2 = false;
while (nl) {
-
if (nl == p_owner) {
-
Ref<SceneState> state = nl->get_scene_inherited_state();
if (state.is_valid()) {
int from_node = state->find_node_by_path(nl->get_path_to(p_node));
@@ -835,7 +819,6 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
cd.signal = _nm_get_string(c.signal.get_name(), name_map);
cd.flags = c.flags;
for (int i = 0; i < c.binds.size(); i++) {
-
cd.binds.push_back(_vm_get_variant(c.binds[i], variant_map));
}
connections.push_back(cd);
@@ -843,11 +826,11 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
}
for (int i = 0; i < p_node->get_child_count(); i++) {
-
Node *c = p_node->get_child(i);
Error err = _parse_connections(p_owner, c, name_map, variant_map, node_map, nodepath_map);
- if (err)
+ if (err) {
return err;
+ }
}
return OK;
@@ -870,7 +853,6 @@ Error SceneState::pack(Node *p_scene) {
String path = scene->get_scene_inherited_state()->get_path();
Ref<PackedScene> instance = ResourceLoader::load(path);
if (instance.is_valid()) {
-
base_scene_idx = _vm_get_variant(instance, variant_map);
}
}
@@ -891,21 +873,18 @@ Error SceneState::pack(Node *p_scene) {
names.resize(name_map.size());
for (Map<StringName, int>::Element *E = name_map.front(); E; E = E->next()) {
-
names.write[E->get()] = E->key();
}
variants.resize(variant_map.size());
const Variant *K = nullptr;
while ((K = variant_map.next(K))) {
-
int idx = variant_map[*K];
variants.write[idx] = *K;
}
node_paths.resize(nodepath_map.size());
for (Map<Node *, int>::Element *E = nodepath_map.front(); E; E = E->next()) {
-
node_paths.write[E->get()] = scene->get_path_to(E->key());
}
@@ -913,17 +892,14 @@ Error SceneState::pack(Node *p_scene) {
}
void SceneState::set_path(const String &p_path) {
-
path = p_path;
}
String SceneState::get_path() const {
-
return path;
}
void SceneState::clear() {
-
names.clear();
variants.clear();
nodes.clear();
@@ -935,9 +911,7 @@ void SceneState::clear() {
}
Ref<SceneState> SceneState::_get_base_scene_state() const {
-
if (base_scene_idx >= 0) {
-
Ref<PackedScene> ps = variants[base_scene_idx];
if (ps.is_valid()) {
return ps->get_state();
@@ -948,7 +922,6 @@ Ref<SceneState> SceneState::_get_base_scene_state() const {
}
int SceneState::find_node_by_path(const NodePath &p_node) const {
-
if (!node_path_cache.has(p_node)) {
if (_get_base_scene_state().is_valid()) {
int idx = _get_base_scene_state()->find_node_by_path(p_node);
@@ -980,7 +953,6 @@ int SceneState::find_node_by_path(const NodePath &p_node) const {
}
int SceneState::_find_base_scene_node_remap_key(int p_idx) const {
-
for (Map<int, int>::Element *E = base_scene_node_remap.front(); E; E = E->next()) {
if (E->value() == p_idx) {
return E->key();
@@ -990,7 +962,6 @@ int SceneState::_find_base_scene_node_remap_key(int p_idx) const {
}
Variant SceneState::get_property_value(int p_node, const StringName &p_property, bool &found) const {
-
found = false;
ERR_FAIL_COND_V(p_node < 0, Variant());
@@ -1019,14 +990,14 @@ Variant SceneState::get_property_value(int p_node, const StringName &p_property,
}
bool SceneState::is_node_in_group(int p_node, const StringName &p_group) const {
-
ERR_FAIL_COND_V(p_node < 0, false);
if (p_node < nodes.size()) {
const StringName *namep = names.ptr();
for (int i = 0; i < nodes[p_node].groups.size(); i++) {
- if (namep[nodes[p_node].groups[i]] == p_group)
+ if (namep[nodes[p_node].groups[i]] == p_group) {
return true;
+ }
}
}
@@ -1040,17 +1011,14 @@ bool SceneState::is_node_in_group(int p_node, const StringName &p_group) const {
bool SceneState::disable_placeholders = false;
void SceneState::set_disable_placeholders(bool p_disable) {
-
disable_placeholders = p_disable;
}
bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_node, const StringName &p_to_method) const {
-
ERR_FAIL_COND_V(p_node < 0, false);
ERR_FAIL_COND_V(p_to_node < 0, false);
if (p_node < nodes.size() && p_to_node < nodes.size()) {
-
int signal_idx = -1;
int method_idx = -1;
for (int i = 0; i < names.size(); i++) {
@@ -1065,9 +1033,7 @@ bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_
//signal and method strings are stored..
for (int i = 0; i < connections.size(); i++) {
-
if (connections[i].from == p_node && connections[i].to == p_to_node && connections[i].signal == signal_idx && connections[i].method == method_idx) {
-
return true;
}
}
@@ -1082,7 +1048,6 @@ bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_
}
void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
-
ERR_FAIL_COND(!p_dictionary.has("names"));
ERR_FAIL_COND(!p_dictionary.has("variants"));
ERR_FAIL_COND(!p_dictionary.has("node_count"));
@@ -1092,8 +1057,9 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
//ERR_FAIL_COND( !p_dictionary.has("path"));
int version = 1;
- if (p_dictionary.has("version"))
+ if (p_dictionary.has("version")) {
version = p_dictionary["version"];
+ }
ERR_FAIL_COND_MSG(version > PACKED_SCENE_VERSION, "Save format version too new.");
@@ -1107,12 +1073,12 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
Vector<String> snames = p_dictionary["names"];
if (snames.size()) {
-
int namecount = snames.size();
names.resize(namecount);
const String *r = snames.ptr();
- for (int i = 0; i < names.size(); i++)
+ for (int i = 0; i < names.size(); i++) {
names.write[i] = r[i];
+ }
}
Array svariants = p_dictionary["variants"];
@@ -1121,7 +1087,6 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
int varcount = svariants.size();
variants.resize(varcount);
for (int i = 0; i < varcount; i++) {
-
variants.write[i] = svariants[i];
}
@@ -1145,13 +1110,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
nd.instance = r[idx++];
nd.properties.resize(r[idx++]);
for (int j = 0; j < nd.properties.size(); j++) {
-
nd.properties.write[j].name = r[idx++];
nd.properties.write[j].value = r[idx++];
}
nd.groups.resize(r[idx++]);
for (int j = 0; j < nd.groups.size(); j++) {
-
nd.groups.write[j] = r[idx++];
}
}
@@ -1171,7 +1134,6 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
cd.binds.resize(r[idx++]);
for (int j = 0; j < cd.binds.size(); j++) {
-
cd.binds.write[j] = r[idx++];
}
}
@@ -1204,16 +1166,15 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
}
Dictionary SceneState::get_bundled_scene() const {
-
Vector<String> rnames;
rnames.resize(names.size());
if (names.size()) {
-
String *r = rnames.ptrw();
- for (int i = 0; i < names.size(); i++)
+ for (int i = 0; i < names.size(); i++) {
r[i] = names[i];
+ }
}
Dictionary d;
@@ -1224,7 +1185,6 @@ Dictionary SceneState::get_bundled_scene() const {
d["node_count"] = nodes.size();
for (int i = 0; i < nodes.size(); i++) {
-
const NodeData &nd = nodes[i];
rnodes.push_back(nd.parent);
rnodes.push_back(nd.owner);
@@ -1237,13 +1197,11 @@ Dictionary SceneState::get_bundled_scene() const {
rnodes.push_back(nd.instance);
rnodes.push_back(nd.properties.size());
for (int j = 0; j < nd.properties.size(); j++) {
-
rnodes.push_back(nd.properties[j].name);
rnodes.push_back(nd.properties[j].value);
}
rnodes.push_back(nd.groups.size());
for (int j = 0; j < nd.groups.size(); j++) {
-
rnodes.push_back(nd.groups[j]);
}
}
@@ -1254,7 +1212,6 @@ Dictionary SceneState::get_bundled_scene() const {
d["conn_count"] = connections.size();
for (int i = 0; i < connections.size(); i++) {
-
const ConnectionData &cd = connections[i];
rconns.push_back(cd.from);
rconns.push_back(cd.to);
@@ -1262,8 +1219,9 @@ Dictionary SceneState::get_bundled_scene() const {
rconns.push_back(cd.method);
rconns.push_back(cd.flags);
rconns.push_back(cd.binds.size());
- for (int j = 0; j < cd.binds.size(); j++)
+ for (int j = 0; j < cd.binds.size(); j++) {
rconns.push_back(cd.binds[j]);
+ }
}
d["conns"] = rconns;
@@ -1291,20 +1249,18 @@ Dictionary SceneState::get_bundled_scene() const {
}
int SceneState::get_node_count() const {
-
return nodes.size();
}
StringName SceneState::get_node_type(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName());
- if (nodes[p_idx].type == TYPE_INSTANCED)
+ if (nodes[p_idx].type == TYPE_INSTANCED) {
return StringName();
+ }
return names[nodes[p_idx].type];
}
StringName SceneState::get_node_name(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName());
return names[nodes[p_idx].name];
}
@@ -1315,7 +1271,6 @@ int SceneState::get_node_index(int p_idx) const {
}
bool SceneState::is_node_instance_placeholder(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), false);
return nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER);
@@ -1325,12 +1280,12 @@ Ref<PackedScene> SceneState::get_node_instance(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), Ref<PackedScene>());
if (nodes[p_idx].instance >= 0) {
- if (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)
+ if (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER) {
return Ref<PackedScene>();
- else
+ } else {
return variants[nodes[p_idx].instance & FLAG_MASK];
+ }
} else if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) {
-
if (base_scene_idx >= 0) {
return variants[base_scene_idx];
}
@@ -1340,7 +1295,6 @@ Ref<PackedScene> SceneState::get_node_instance(int p_idx) const {
}
String SceneState::get_node_instance_placeholder(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), String());
if (nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)) {
@@ -1360,7 +1314,6 @@ Vector<StringName> SceneState::get_node_groups(int p_idx) const {
}
NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath());
if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) {
@@ -1376,7 +1329,6 @@ NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const {
int nidx = p_idx;
while (true) {
if (nodes[nidx].parent == NO_PARENT_SAVED || nodes[nidx].parent < 0) {
-
sub_path.insert(0, ".");
break;
}
@@ -1405,15 +1357,16 @@ NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const {
}
int SceneState::get_node_property_count(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), -1);
return nodes[p_idx].properties.size();
}
+
StringName SceneState::get_node_property_name(int p_idx, int p_prop) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName());
ERR_FAIL_INDEX_V(p_prop, nodes[p_idx].properties.size(), StringName());
return names[nodes[p_idx].properties[p_prop].name];
}
+
Variant SceneState::get_node_property_value(int p_idx, int p_prop) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), Variant());
ERR_FAIL_INDEX_V(p_prop, nodes[p_idx].properties.size(), Variant());
@@ -1422,10 +1375,10 @@ Variant SceneState::get_node_property_value(int p_idx, int p_prop) const {
}
NodePath SceneState::get_node_owner_path(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath());
- if (nodes[p_idx].owner < 0 || nodes[p_idx].owner == NO_PARENT_SAVED)
+ if (nodes[p_idx].owner < 0 || nodes[p_idx].owner == NO_PARENT_SAVED) {
return NodePath(); //root likely
+ }
if (nodes[p_idx].owner & FLAG_ID_IS_PATH) {
return node_paths[nodes[p_idx].owner & FLAG_MASK];
} else {
@@ -1434,11 +1387,10 @@ NodePath SceneState::get_node_owner_path(int p_idx) const {
}
int SceneState::get_connection_count() const {
-
return connections.size();
}
-NodePath SceneState::get_connection_source(int p_idx) const {
+NodePath SceneState::get_connection_source(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, connections.size(), NodePath());
if (connections[p_idx].from & FLAG_ID_IS_PATH) {
return node_paths[connections[p_idx].from & FLAG_MASK];
@@ -1448,12 +1400,11 @@ NodePath SceneState::get_connection_source(int p_idx) const {
}
StringName SceneState::get_connection_signal(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, connections.size(), StringName());
return names[connections[p_idx].signal];
}
-NodePath SceneState::get_connection_target(int p_idx) const {
+NodePath SceneState::get_connection_target(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, connections.size(), NodePath());
if (connections[p_idx].to & FLAG_ID_IS_PATH) {
return node_paths[connections[p_idx].to & FLAG_MASK];
@@ -1461,20 +1412,18 @@ NodePath SceneState::get_connection_target(int p_idx) const {
return get_node_path(connections[p_idx].to & FLAG_MASK);
}
}
-StringName SceneState::get_connection_method(int p_idx) const {
+StringName SceneState::get_connection_method(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, connections.size(), StringName());
return names[connections[p_idx].method];
}
int SceneState::get_connection_flags(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, connections.size(), -1);
return connections[p_idx].flags;
}
Array SceneState::get_connection_binds(int p_idx) const {
-
ERR_FAIL_INDEX_V(p_idx, connections.size(), Array());
Array binds;
for (int i = 0; i < connections[p_idx].binds.size(); i++) {
@@ -1484,7 +1433,6 @@ Array SceneState::get_connection_binds(int p_idx) const {
}
bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) {
-
// this method cannot be const because of this
Ref<SceneState> ss = this;
@@ -1525,37 +1473,35 @@ bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p
Vector<NodePath> SceneState::get_editable_instances() const {
return editable_instances;
}
+
//add
int SceneState::add_name(const StringName &p_name) {
-
names.push_back(p_name);
return names.size() - 1;
}
int SceneState::find_name(const StringName &p_name) const {
-
for (int i = 0; i < names.size(); i++) {
- if (names[i] == p_name)
+ if (names[i] == p_name) {
return i;
+ }
}
return -1;
}
int SceneState::add_value(const Variant &p_value) {
-
variants.push_back(p_value);
return variants.size() - 1;
}
int SceneState::add_node_path(const NodePath &p_path) {
-
node_paths.push_back(p_path);
return (node_paths.size() - 1) | FLAG_ID_IS_PATH;
}
-int SceneState::add_node(int p_parent, int p_owner, int p_type, int p_name, int p_instance, int p_index) {
+int SceneState::add_node(int p_parent, int p_owner, int p_type, int p_name, int p_instance, int p_index) {
NodeData nd;
nd.parent = p_parent;
nd.owner = p_owner;
@@ -1568,8 +1514,8 @@ int SceneState::add_node(int p_parent, int p_owner, int p_type, int p_name, int
return nodes.size() - 1;
}
-void SceneState::add_node_property(int p_node, int p_name, int p_value) {
+void SceneState::add_node_property(int p_node, int p_name, int p_value) {
ERR_FAIL_INDEX(p_node, nodes.size());
ERR_FAIL_INDEX(p_name, names.size());
ERR_FAIL_INDEX(p_value, variants.size());
@@ -1579,19 +1525,19 @@ void SceneState::add_node_property(int p_node, int p_name, int p_value) {
prop.value = p_value;
nodes.write[p_node].properties.push_back(prop);
}
-void SceneState::add_node_group(int p_node, int p_group) {
+void SceneState::add_node_group(int p_node, int p_group) {
ERR_FAIL_INDEX(p_node, nodes.size());
ERR_FAIL_INDEX(p_group, names.size());
nodes.write[p_node].groups.push_back(p_group);
}
-void SceneState::set_base_scene(int p_idx) {
+void SceneState::set_base_scene(int p_idx) {
ERR_FAIL_INDEX(p_idx, variants.size());
base_scene_idx = p_idx;
}
-void SceneState::add_connection(int p_from, int p_to, int p_signal, int p_method, int p_flags, const Vector<int> &p_binds) {
+void SceneState::add_connection(int p_from, int p_to, int p_signal, int p_method, int p_flags, const Vector<int> &p_binds) {
ERR_FAIL_INDEX(p_signal, names.size());
ERR_FAIL_INDEX(p_method, names.size());
@@ -1607,24 +1553,23 @@ void SceneState::add_connection(int p_from, int p_to, int p_signal, int p_method
c.binds = p_binds;
connections.push_back(c);
}
-void SceneState::add_editable_instance(const NodePath &p_path) {
+void SceneState::add_editable_instance(const NodePath &p_path) {
editable_instances.push_back(p_path);
}
Vector<String> SceneState::_get_node_groups(int p_idx) const {
-
Vector<StringName> groups = get_node_groups(p_idx);
Vector<String> ret;
- for (int i = 0; i < groups.size(); i++)
+ for (int i = 0; i < groups.size(); i++) {
ret.push_back(groups[i]);
+ }
return ret;
}
void SceneState::_bind_methods() {
-
//unbuild API
ClassDB::bind_method(D_METHOD("get_node_count"), &SceneState::get_node_count);
@@ -1654,7 +1599,6 @@ void SceneState::_bind_methods() {
}
SceneState::SceneState() {
-
base_scene_idx = -1;
last_modified_time = 0;
}
@@ -1662,46 +1606,42 @@ SceneState::SceneState() {
////////////////
void PackedScene::_set_bundled_scene(const Dictionary &p_scene) {
-
state->set_bundled_scene(p_scene);
}
Dictionary PackedScene::_get_bundled_scene() const {
-
return state->get_bundled_scene();
}
Error PackedScene::pack(Node *p_scene) {
-
return state->pack(p_scene);
}
void PackedScene::clear() {
-
state->clear();
}
bool PackedScene::can_instance() const {
-
return state->can_instance();
}
Node *PackedScene::instance(GenEditState p_edit_state) const {
-
#ifndef TOOLS_ENABLED
ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, nullptr, "Edit state is only for editors, does not work without tools compiled.");
#endif
Node *s = state->instance((SceneState::GenEditState)p_edit_state);
- if (!s)
+ if (!s) {
return nullptr;
+ }
if (p_edit_state != GEN_EDIT_STATE_DISABLED) {
s->set_scene_instance_state(state);
}
- if (get_path() != "" && get_path().find("::") == -1)
+ if (get_path() != "" && get_path().find("::") == -1) {
s->set_filename(get_path());
+ }
s->notification(Node::NOTIFICATION_INSTANCED);
@@ -1709,7 +1649,6 @@ Node *PackedScene::instance(GenEditState p_edit_state) const {
}
void PackedScene::replace_state(Ref<SceneState> p_by) {
-
state = p_by;
state->set_path(get_path());
#ifdef TOOLS_ENABLED
@@ -1718,7 +1657,6 @@ void PackedScene::replace_state(Ref<SceneState> p_by) {
}
void PackedScene::recreate_state() {
-
state = Ref<SceneState>(memnew(SceneState));
state->set_path(get_path());
#ifdef TOOLS_ENABLED
@@ -1727,18 +1665,15 @@ void PackedScene::recreate_state() {
}
Ref<SceneState> PackedScene::get_state() {
-
return state;
}
void PackedScene::set_path(const String &p_path, bool p_take_over) {
-
state->set_path(p_path);
Resource::set_path(p_path, p_take_over);
}
void PackedScene::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("pack", "path"), &PackedScene::pack);
ClassDB::bind_method(D_METHOD("instance", "edit_state"), &PackedScene::instance, DEFVAL(GEN_EDIT_STATE_DISABLED));
ClassDB::bind_method(D_METHOD("can_instance"), &PackedScene::can_instance);
@@ -1754,6 +1689,5 @@ void PackedScene::_bind_methods() {
}
PackedScene::PackedScene() {
-
state = Ref<SceneState>(memnew(SceneState));
}
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index c5873a0792..898d5ff11f 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -35,7 +35,6 @@
#include "scene/main/node.h"
class SceneState : public Reference {
-
GDCLASS(SceneState, Reference);
Vector<StringName> names;
@@ -54,7 +53,6 @@ class SceneState : public Reference {
};
struct NodeData {
-
int parent;
int owner;
int type;
@@ -63,7 +61,6 @@ class SceneState : public Reference {
int index;
struct Property {
-
int name;
int value;
};
@@ -81,7 +78,6 @@ class SceneState : public Reference {
Vector<NodeData> nodes;
struct ConnectionData {
-
int from;
int to;
int signal;
@@ -195,7 +191,6 @@ public:
VARIANT_ENUM_CAST(SceneState::GenEditState)
class PackedScene : public Resource {
-
GDCLASS(PackedScene, Resource);
RES_BASE_EXTENSION("scn");
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index 1a28e2586d..fc92a721db 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -36,7 +36,6 @@ Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMate
ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = nullptr;
void ParticlesMaterial::init_shaders() {
-
dirty_materials = memnew(SelfList<ParticlesMaterial>::List);
shader_names = memnew(ShaderNames);
@@ -102,7 +101,6 @@ void ParticlesMaterial::init_shaders() {
}
void ParticlesMaterial::finish_shaders() {
-
memdelete(dirty_materials);
dirty_materials = nullptr;
@@ -110,12 +108,12 @@ void ParticlesMaterial::finish_shaders() {
}
void ParticlesMaterial::_update_shader() {
-
dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
- if (mk.key == current_key.key)
+ if (mk.key == current_key.key) {
return; //no update required in the end
+ }
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -129,7 +127,6 @@ void ParticlesMaterial::_update_shader() {
current_key = mk;
if (shader_map.has(mk)) {
-
RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader);
shader_map[mk].users++;
return;
@@ -201,33 +198,46 @@ void ParticlesMaterial::_update_shader() {
code += "uniform vec3 gravity;\n";
- if (color_ramp.is_valid())
+ if (color_ramp.is_valid()) {
code += "uniform sampler2D color_ramp;\n";
+ }
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
code += "uniform sampler2D linear_velocity_texture;\n";
- if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
+ }
+ if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid()) {
code += "uniform sampler2D orbit_velocity_texture;\n";
- if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
+ }
+ if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) {
code += "uniform sampler2D angular_velocity_texture;\n";
- if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
+ }
+ if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid()) {
code += "uniform sampler2D linear_accel_texture;\n";
- if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
+ }
+ if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid()) {
code += "uniform sampler2D radial_accel_texture;\n";
- if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
+ }
+ if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid()) {
code += "uniform sampler2D tangent_accel_texture;\n";
- if (tex_parameters[PARAM_DAMPING].is_valid())
+ }
+ if (tex_parameters[PARAM_DAMPING].is_valid()) {
code += "uniform sampler2D damping_texture;\n";
- if (tex_parameters[PARAM_ANGLE].is_valid())
+ }
+ if (tex_parameters[PARAM_ANGLE].is_valid()) {
code += "uniform sampler2D angle_texture;\n";
- if (tex_parameters[PARAM_SCALE].is_valid())
+ }
+ if (tex_parameters[PARAM_SCALE].is_valid()) {
code += "uniform sampler2D scale_texture;\n";
- if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
+ }
+ if (tex_parameters[PARAM_HUE_VARIATION].is_valid()) {
code += "uniform sampler2D hue_variation_texture;\n";
- if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
+ }
+ if (tex_parameters[PARAM_ANIM_SPEED].is_valid()) {
code += "uniform sampler2D anim_speed_texture;\n";
- if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
+ }
+ if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) {
code += "uniform sampler2D anim_offset_texture;\n";
+ }
if (trail_size_modifier.is_valid()) {
code += "uniform sampler2D trail_size_modifier;\n";
@@ -289,25 +299,27 @@ void ParticlesMaterial::_update_shader() {
code += " }\n\n";
code += " if (RESTART || restart) {\n";
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
code += " float tex_linear_velocity = textureLod(linear_velocity_texture, vec2(0.0, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_linear_velocity = 0.0;\n";
+ }
- if (tex_parameters[PARAM_ANGLE].is_valid())
+ if (tex_parameters[PARAM_ANGLE].is_valid()) {
code += " float tex_angle = textureLod(angle_texture, vec2(0.0, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_angle = 0.0;\n";
+ }
- if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
+ if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) {
code += " float tex_anim_offset = textureLod(anim_offset_texture, vec2(0.0, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_anim_offset = 0.0;\n";
+ }
code += " float spread_rad = spread * degree_to_rad;\n";
if (flags[FLAG_DISABLE_Z]) {
-
code += " float angle1_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad;\n";
code += " angle1_rad += direction.x != 0.0 ? atan(direction.y, direction.x) : sign(direction.y) * (pi / 2.0);\n";
code += " vec3 rot = vec3(cos(angle1_rad), sin(angle1_rad), 0.0);\n";
@@ -352,7 +364,6 @@ void ParticlesMaterial::_update_shader() {
if (emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) {
if (flags[FLAG_DISABLE_Z]) {
-
code += " mat2 rotm;";
code += " rotm[0] = texelFetch(emission_texture_normal, emission_tex_ofs, 0).xy;\n";
code += " rotm[1] = rotm[0].yx * vec2(1.0, -1.0);\n";
@@ -380,58 +391,67 @@ void ParticlesMaterial::_update_shader() {
code += " } else {\n";
code += " CUSTOM.y += DELTA / LIFETIME;\n";
- if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid())
+ if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) {
code += " float tex_linear_velocity = textureLod(linear_velocity_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_linear_velocity = 0.0;\n";
+ }
if (flags[FLAG_DISABLE_Z]) {
-
- if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid())
+ if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid()) {
code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_orbit_velocity = 0.0;\n";
+ }
}
- if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid())
+ if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) {
code += " float tex_angular_velocity = textureLod(angular_velocity_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_angular_velocity = 0.0;\n";
+ }
- if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid())
+ if (tex_parameters[PARAM_LINEAR_ACCEL].is_valid()) {
code += " float tex_linear_accel = textureLod(linear_accel_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_linear_accel = 0.0;\n";
+ }
- if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid())
+ if (tex_parameters[PARAM_RADIAL_ACCEL].is_valid()) {
code += " float tex_radial_accel = textureLod(radial_accel_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_radial_accel = 0.0;\n";
+ }
- if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid())
+ if (tex_parameters[PARAM_TANGENTIAL_ACCEL].is_valid()) {
code += " float tex_tangent_accel = textureLod(tangent_accel_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_tangent_accel = 0.0;\n";
+ }
- if (tex_parameters[PARAM_DAMPING].is_valid())
+ if (tex_parameters[PARAM_DAMPING].is_valid()) {
code += " float tex_damping = textureLod(damping_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_damping = 0.0;\n";
+ }
- if (tex_parameters[PARAM_ANGLE].is_valid())
+ if (tex_parameters[PARAM_ANGLE].is_valid()) {
code += " float tex_angle = textureLod(angle_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_angle = 0.0;\n";
+ }
- if (tex_parameters[PARAM_ANIM_SPEED].is_valid())
+ if (tex_parameters[PARAM_ANIM_SPEED].is_valid()) {
code += " float tex_anim_speed = textureLod(anim_speed_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_anim_speed = 0.0;\n";
+ }
- if (tex_parameters[PARAM_ANIM_OFFSET].is_valid())
+ if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) {
code += " float tex_anim_offset = textureLod(anim_offset_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_anim_offset = 0.0;\n";
+ }
code += " vec3 force = gravity;\n";
code += " vec3 pos = TRANSFORM[3].xyz;\n";
@@ -456,7 +476,6 @@ void ParticlesMaterial::_update_shader() {
code += " VELOCITY += force * DELTA;\n";
code += " // orbit velocity\n";
if (flags[FLAG_DISABLE_Z]) {
-
code += " float orbit_amount = (orbit_velocity + tex_orbit_velocity) * mix(1.0, rand_from_seed(alt_seed), orbit_velocity_random);\n";
code += " if (orbit_amount != 0.0) {\n";
code += " float ang = orbit_amount * DELTA * pi * 2.0;\n";
@@ -486,15 +505,17 @@ void ParticlesMaterial::_update_shader() {
code += " }\n";
// apply color
// apply hue rotation
- if (tex_parameters[PARAM_SCALE].is_valid())
+ if (tex_parameters[PARAM_SCALE].is_valid()) {
code += " float tex_scale = textureLod(scale_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_scale = 1.0;\n";
+ }
- if (tex_parameters[PARAM_HUE_VARIATION].is_valid())
+ if (tex_parameters[PARAM_HUE_VARIATION].is_valid()) {
code += " float tex_hue_variation = textureLod(hue_variation_texture, vec2(CUSTOM.y, 0.0), 0.0).r;\n";
- else
+ } else {
code += " float tex_hue_variation = 0.0;\n";
+ }
code += " float hue_rot_angle = (hue_variation + tex_hue_variation) * pi * 2.0 * mix(1.0, hue_rot_rand * 2.0 - 1.0, hue_variation_random);\n";
code += " float hue_rot_c = cos(hue_rot_angle);\n";
@@ -527,7 +548,6 @@ void ParticlesMaterial::_update_shader() {
code += "\n";
if (flags[FLAG_DISABLE_Z]) {
-
if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
code += " if (length(VELOCITY) > 0.0) {\n";
code += " TRANSFORM[1].xyz = normalize(VELOCITY);\n";
@@ -603,17 +623,14 @@ void ParticlesMaterial::_update_shader() {
}
void ParticlesMaterial::flush_changes() {
-
MutexLock lock(material_mutex);
while (dirty_materials->first()) {
-
dirty_materials->first()->self()->_update_shader();
}
}
void ParticlesMaterial::_queue_shader_change() {
-
MutexLock lock(material_mutex);
if (!element.in_list()) {
@@ -622,46 +639,39 @@ void ParticlesMaterial::_queue_shader_change() {
}
bool ParticlesMaterial::_is_shader_dirty() const {
-
MutexLock lock(material_mutex);
return element.in_list();
}
void ParticlesMaterial::set_direction(Vector3 p_direction) {
-
direction = p_direction;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->direction, direction);
}
Vector3 ParticlesMaterial::get_direction() const {
-
return direction;
}
void ParticlesMaterial::set_spread(float p_spread) {
-
spread = p_spread;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread);
}
float ParticlesMaterial::get_spread() const {
-
return spread;
}
void ParticlesMaterial::set_flatness(float p_flatness) {
-
flatness = p_flatness;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness);
}
-float ParticlesMaterial::get_flatness() const {
+float ParticlesMaterial::get_flatness() const {
return flatness;
}
void ParticlesMaterial::set_param(Parameter p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
parameters[p_param] = p_value;
@@ -707,15 +717,14 @@ void ParticlesMaterial::set_param(Parameter p_param, float p_value) {
break; // Can't happen, but silences warning
}
}
-float ParticlesMaterial::get_param(Parameter p_param) const {
+float ParticlesMaterial::get_param(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return parameters[p_param];
}
void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
randomness[p_param] = p_value;
@@ -761,24 +770,23 @@ void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) {
break; // Can't happen, but silences warning
}
}
-float ParticlesMaterial::get_param_randomness(Parameter p_param) const {
+float ParticlesMaterial::get_param_randomness(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return randomness[p_param];
}
static void _adjust_curve_range(const Ref<Texture2D> &p_texture, float p_min, float p_max) {
-
Ref<CurveTexture> curve_tex = p_texture;
- if (!curve_tex.is_valid())
+ if (!curve_tex.is_valid()) {
return;
+ }
curve_tex->ensure_default_setup(p_min, p_max);
}
void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_INDEX(p_param, PARAM_MAX);
tex_parameters[p_param] = p_texture;
@@ -836,26 +844,23 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D
_queue_shader_change();
}
-Ref<Texture2D> ParticlesMaterial::get_param_texture(Parameter p_param) const {
+Ref<Texture2D> ParticlesMaterial::get_param_texture(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture2D>());
return tex_parameters[p_param];
}
void ParticlesMaterial::set_color(const Color &p_color) {
-
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color);
color = p_color;
}
Color ParticlesMaterial::get_color() const {
-
return color;
}
void ParticlesMaterial::set_color_ramp(const Ref<Texture2D> &p_texture) {
-
color_ramp = p_texture;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture);
_queue_shader_change();
@@ -863,7 +868,6 @@ void ParticlesMaterial::set_color_ramp(const Ref<Texture2D> &p_texture) {
}
Ref<Texture2D> ParticlesMaterial::get_color_ramp() const {
-
return color_ramp;
}
@@ -889,87 +893,74 @@ void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) {
}
void ParticlesMaterial::set_emission_sphere_radius(float p_radius) {
-
emission_sphere_radius = p_radius;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius);
}
void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) {
-
emission_box_extents = p_extents;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents);
}
void ParticlesMaterial::set_emission_point_texture(const Ref<Texture2D> &p_points) {
-
emission_point_texture = p_points;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points);
}
void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture2D> &p_normals) {
-
emission_normal_texture = p_normals;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals);
}
void ParticlesMaterial::set_emission_color_texture(const Ref<Texture2D> &p_colors) {
-
emission_color_texture = p_colors;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors);
_queue_shader_change();
}
void ParticlesMaterial::set_emission_point_count(int p_count) {
-
emission_point_count = p_count;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count);
}
ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const {
-
return emission_shape;
}
float ParticlesMaterial::get_emission_sphere_radius() const {
-
return emission_sphere_radius;
}
-Vector3 ParticlesMaterial::get_emission_box_extents() const {
+Vector3 ParticlesMaterial::get_emission_box_extents() const {
return emission_box_extents;
}
-Ref<Texture2D> ParticlesMaterial::get_emission_point_texture() const {
+Ref<Texture2D> ParticlesMaterial::get_emission_point_texture() const {
return emission_point_texture;
}
-Ref<Texture2D> ParticlesMaterial::get_emission_normal_texture() const {
+Ref<Texture2D> ParticlesMaterial::get_emission_normal_texture() const {
return emission_normal_texture;
}
Ref<Texture2D> ParticlesMaterial::get_emission_color_texture() const {
-
return emission_color_texture;
}
int ParticlesMaterial::get_emission_point_count() const {
-
return emission_point_count;
}
void ParticlesMaterial::set_trail_divisor(int p_divisor) {
-
trail_divisor = p_divisor;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor);
}
int ParticlesMaterial::get_trail_divisor() const {
-
return trail_divisor;
}
void ParticlesMaterial::set_trail_size_modifier(const Ref<CurveTexture> &p_trail_size_modifier) {
-
trail_size_modifier = p_trail_size_modifier;
Ref<CurveTexture> curve = trail_size_modifier;
@@ -982,24 +973,20 @@ void ParticlesMaterial::set_trail_size_modifier(const Ref<CurveTexture> &p_trail
}
Ref<CurveTexture> ParticlesMaterial::get_trail_size_modifier() const {
-
return trail_size_modifier;
}
void ParticlesMaterial::set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier) {
-
trail_color_modifier = p_trail_color_modifier;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier);
_queue_shader_change();
}
Ref<GradientTexture> ParticlesMaterial::get_trail_color_modifier() const {
-
return trail_color_modifier;
}
void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) {
-
gravity = p_gravity;
Vector3 gset = gravity;
if (gset == Vector3()) {
@@ -1009,29 +996,24 @@ void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) {
}
Vector3 ParticlesMaterial::get_gravity() const {
-
return gravity;
}
void ParticlesMaterial::set_lifetime_randomness(float p_lifetime) {
-
lifetime_randomness = p_lifetime;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->lifetime_randomness, lifetime_randomness);
}
float ParticlesMaterial::get_lifetime_randomness() const {
-
return lifetime_randomness;
}
RID ParticlesMaterial::get_shader_rid() const {
-
ERR_FAIL_COND_V(!shader_map.has(current_key), RID());
return shader_map[current_key].shader;
}
void ParticlesMaterial::_validate_property(PropertyInfo &property) const {
-
if (property.name == "color" && color_ramp.is_valid()) {
property.usage = 0;
}
@@ -1062,12 +1044,10 @@ void ParticlesMaterial::_validate_property(PropertyInfo &property) const {
}
Shader::Mode ParticlesMaterial::get_shader_mode() const {
-
return Shader::MODE_PARTICLES;
}
void ParticlesMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_direction", "degrees"), &ParticlesMaterial::set_direction);
ClassDB::bind_method(D_METHOD("get_direction"), &ParticlesMaterial::get_direction);
@@ -1235,7 +1215,6 @@ void ParticlesMaterial::_bind_methods() {
ParticlesMaterial::ParticlesMaterial() :
element(this) {
-
set_direction(Vector3(1, 0, 0));
set_spread(45);
set_flatness(0);
@@ -1276,7 +1255,6 @@ ParticlesMaterial::ParticlesMaterial() :
}
ParticlesMaterial::~ParticlesMaterial() {
-
MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index c6c8316995..a1a4c38842 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -35,7 +35,6 @@
#define PARTICLES_MATERIAL_H
class ParticlesMaterial : public Material {
-
GDCLASS(ParticlesMaterial, Material);
public:
@@ -74,7 +73,6 @@ public:
private:
union MaterialKey {
-
struct {
uint32_t texture_mask : 16;
uint32_t texture_color : 1;
@@ -103,7 +101,6 @@ private:
MaterialKey current_key;
_FORCE_INLINE_ MaterialKey _compute_key() const {
-
MaterialKey mk;
mk.key = 0;
for (int i = 0; i < PARAM_MAX; i++) {
diff --git a/scene/resources/physics_material.cpp b/scene/resources/physics_material.cpp
index 8ac0191452..2a5cd1101a 100644
--- a/scene/resources/physics_material.cpp
+++ b/scene/resources/physics_material.cpp
@@ -31,7 +31,6 @@
#include "physics_material.h"
void PhysicsMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_friction", "friction"), &PhysicsMaterial::set_friction);
ClassDB::bind_method(D_METHOD("get_friction"), &PhysicsMaterial::get_friction);
@@ -69,9 +68,3 @@ void PhysicsMaterial::set_absorbent(bool p_val) {
absorbent = p_val;
emit_changed();
}
-
-PhysicsMaterial::PhysicsMaterial() :
- friction(1),
- rough(false),
- bounce(0),
- absorbent(false) {}
diff --git a/scene/resources/physics_material.h b/scene/resources/physics_material.h
index f4a77d9854..34aa7066df 100644
--- a/scene/resources/physics_material.h
+++ b/scene/resources/physics_material.h
@@ -28,22 +28,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef physics_material_override_H
-#define physics_material_override_H
+#ifndef PHYSICS_MATERIAL_H
+#define PHYSICS_MATERIAL_H
#include "core/resource.h"
#include "servers/physics_server_3d.h"
class PhysicsMaterial : public Resource {
-
GDCLASS(PhysicsMaterial, Resource);
OBJ_SAVE_TYPE(PhysicsMaterial);
RES_BASE_EXTENSION("phymat");
- real_t friction;
- bool rough;
- real_t bounce;
- bool absorbent;
+ real_t friction = 1;
+ bool rough = false;
+ real_t bounce = 0;
+ bool absorbent = false;
protected:
static void _bind_methods();
@@ -69,7 +68,7 @@ public:
return absorbent ? -bounce : bounce;
}
- PhysicsMaterial();
+ PhysicsMaterial() {}
};
-#endif // physics_material_override_H
+#endif // PHYSICS_MATERIAL_H
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index c3daedf918..df98d4cfd4 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -29,20 +29,18 @@
/*************************************************************************/
#include "polygon_path_finder.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
-
int crosses = 0;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
- if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, p_point, outside_point, nullptr)) {
crosses++;
}
}
@@ -51,7 +49,6 @@ bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
}
void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int> &p_connections) {
-
ERR_FAIL_COND(p_connections.size() & 1);
points.clear();
@@ -64,7 +61,6 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int>
bounds = Rect2();
for (int i = 0; i < p_points.size(); i++) {
-
points.write[i].pos = p_points[i];
points.write[i].penalty = 0;
@@ -84,7 +80,6 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int>
//insert edges (which are also connetions)
for (int i = 0; i < p_connections.size(); i += 2) {
-
Edge e(p_connections[i], p_connections[i + 1]);
ERR_FAIL_INDEX(e.points[0], point_count);
ERR_FAIL_INDEX(e.points[1], point_count);
@@ -96,30 +91,30 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int>
//fill the remaining connections based on visibility
for (int i = 0; i < point_count; i++) {
-
for (int j = i + 1; j < point_count; j++) {
-
- if (edges.has(Edge(i, j)))
+ if (edges.has(Edge(i, j))) {
continue; //if in edge ignore
+ }
Vector2 from = points[i].pos;
Vector2 to = points[j].pos;
- if (!_is_point_inside(from * 0.5 + to * 0.5)) //connection between points in inside space
+ if (!_is_point_inside(from * 0.5 + to * 0.5)) { //connection between points in inside space
continue;
+ }
bool valid = true;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
- if (e.points[0] == i || e.points[1] == i || e.points[0] == j || e.points[1] == j)
+ if (e.points[0] == i || e.points[1] == i || e.points[0] == j || e.points[1] == j) {
continue;
+ }
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
- if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, from, to, nullptr)) {
valid = false;
break;
}
@@ -134,7 +129,6 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int>
}
Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector2 &p_to) {
-
Vector<Vector2> path;
Vector2 from = p_from;
@@ -143,19 +137,17 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
Edge ignore_to_edge(-1, -1);
if (!_is_point_inside(from)) {
-
float closest_dist = 1e20;
Vector2 closest_point;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(from, seg);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(from, seg);
float d = from.distance_squared_to(closest);
if (d < closest_dist) {
@@ -173,14 +165,13 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
Vector2 closest_point;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(to, seg);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(to, seg);
float d = to.distance_squared_to(closest);
if (d < closest_dist) {
@@ -195,28 +186,27 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
//test direct connection
{
-
bool can_see_eachother = true;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
- if (e.points[0] == ignore_from_edge.points[0] && e.points[1] == ignore_from_edge.points[1])
+ if (e.points[0] == ignore_from_edge.points[0] && e.points[1] == ignore_from_edge.points[1]) {
continue;
- if (e.points[0] == ignore_to_edge.points[0] && e.points[1] == ignore_to_edge.points[1])
+ }
+ if (e.points[0] == ignore_to_edge.points[0] && e.points[1] == ignore_to_edge.points[1]) {
continue;
+ }
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
- if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, from, to, nullptr)) {
can_see_eachother = false;
break;
}
}
if (can_see_eachother) {
-
path.push_back(from);
path.push_back(to);
return path;
@@ -237,7 +227,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
points.write[bidx].penalty = 0;
for (int i = 0; i < points.size() - 2; i++) {
-
bool valid_a = true;
bool valid_b = true;
points.write[i].prev = -1;
@@ -252,43 +241,40 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
}
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
- if (e.points[0] == i || e.points[1] == i)
+ if (e.points[0] == i || e.points[1] == i) {
continue;
+ }
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
if (valid_a) {
-
if (e.points[0] != ignore_from_edge.points[1] &&
e.points[1] != ignore_from_edge.points[1] &&
e.points[0] != ignore_from_edge.points[0] &&
e.points[1] != ignore_from_edge.points[0]) {
-
- if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, from, points[i].pos, nullptr)) {
valid_a = false;
}
}
}
if (valid_b) {
-
if (e.points[0] != ignore_to_edge.points[1] &&
e.points[1] != ignore_to_edge.points[1] &&
e.points[0] != ignore_to_edge.points[0] &&
e.points[1] != ignore_to_edge.points[0]) {
-
- if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, nullptr)) {
+ if (Geometry2D::segment_intersects_segment(a, b, to, points[i].pos, nullptr)) {
valid_b = false;
}
}
}
- if (!valid_a && !valid_b)
+ if (!valid_a && !valid_b) {
break;
+ }
}
if (valid_a) {
@@ -308,7 +294,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
points.write[aidx].distance = 0;
points.write[aidx].prev = aidx;
for (Set<int>::Element *E = points[aidx].connections.front(); E; E = E->next()) {
-
open_list.insert(E->get());
points.write[E->get()].distance = from.distance_to(points[E->get()].pos);
points.write[E->get()].prev = aidx;
@@ -317,7 +302,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
bool found_route = false;
while (true) {
-
if (open_list.size() == 0) {
printf("open list empty\n");
break;
@@ -329,14 +313,12 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
//this could be faster (cache previous results)
for (Set<int>::Element *E = open_list.front(); E; E = E->next()) {
-
const Point &p = points[E->get()];
float cost = p.distance;
cost += p.pos.distance_to(to);
cost += p.penalty;
if (cost < least_cost) {
-
least_cost_point = E->get();
least_cost = cost;
}
@@ -346,7 +328,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
//open the neighbours for search
for (Set<int>::Element *E = np.connections.front(); E; E = E->next()) {
-
Point &p = points.write[E->get()];
float distance = np.pos.distance_to(p.pos) + np.distance;
@@ -354,7 +335,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
//oh this was visited already, can we win the cost?
if (p.distance > distance) {
-
p.prev = least_cost_point; //reasign previous
p.distance = distance;
}
@@ -373,8 +353,9 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
}
}
- if (found_route)
+ if (found_route) {
break;
+ }
open_list.erase(least_cost_point);
}
@@ -391,7 +372,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
}
for (int i = 0; i < points.size() - 2; i++) {
-
points.write[i].connections.erase(aidx);
points.write[i].connections.erase(bidx);
points.write[i].prev = -1;
@@ -409,7 +389,6 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
}
void PolygonPathFinder::_set_data(const Dictionary &p_data) {
-
ERR_FAIL_COND(!p_data.has("points"));
ERR_FAIL_COND(!p_data.has("connections"));
ERR_FAIL_COND(!p_data.has("segments"));
@@ -419,8 +398,9 @@ void PolygonPathFinder::_set_data(const Dictionary &p_data) {
Array c = p_data["connections"];
ERR_FAIL_COND(c.size() != p.size());
- if (c.size())
+ if (c.size()) {
return;
+ }
int pc = p.size();
points.resize(pc + 2);
@@ -432,13 +412,11 @@ void PolygonPathFinder::_set_data(const Dictionary &p_data) {
const int *cr = con.ptr();
int cc = con.size();
for (int j = 0; j < cc; j++) {
-
points.write[i].connections.insert(cr[j]);
}
}
if (p_data.has("penalties")) {
-
Vector<float> penalties = p_data["penalties"];
if (penalties.size() == pc) {
const float *pr2 = penalties.ptr();
@@ -453,7 +431,6 @@ void PolygonPathFinder::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(sc & 1);
const int *sr = segs.ptr();
for (int i = 0; i < sc; i += 2) {
-
Edge e(sr[i], sr[i + 1]);
edges.insert(e);
}
@@ -461,7 +438,6 @@ void PolygonPathFinder::_set_data(const Dictionary &p_data) {
}
Dictionary PolygonPathFinder::_get_data() const {
-
Dictionary d;
Vector<Vector2> p;
Vector<int> ind;
@@ -491,7 +467,6 @@ Dictionary PolygonPathFinder::_get_data() const {
}
}
{
-
int *iw = ind.ptrw();
int idx = 0;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
@@ -510,24 +485,21 @@ Dictionary PolygonPathFinder::_get_data() const {
}
bool PolygonPathFinder::is_point_inside(const Vector2 &p_point) const {
-
return _is_point_inside(p_point);
}
Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
-
float closest_dist = 1e20;
Vector2 closest_point;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
const Edge &e = E->get();
Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
};
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, seg);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, seg);
float d = p_point.distance_squared_to(closest);
if (d < closest_dist) {
@@ -542,7 +514,6 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
}
Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2 &p_from, const Vector2 &p_to) const {
-
Vector<Vector2> inters;
for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
@@ -550,7 +521,7 @@ Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2 &p_from, cons
Vector2 b = points[E->get().points[1]].pos;
Vector2 res;
- if (Geometry::segment_intersects_segment_2d(a, b, p_from, p_to, &res)) {
+ if (Geometry2D::segment_intersects_segment(a, b, p_from, p_to, &res)) {
inters.push_back(res);
}
}
@@ -559,24 +530,20 @@ Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2 &p_from, cons
}
Rect2 PolygonPathFinder::get_bounds() const {
-
return bounds;
}
void PolygonPathFinder::set_point_penalty(int p_point, float p_penalty) {
-
ERR_FAIL_INDEX(p_point, points.size() - 2);
points.write[p_point].penalty = p_penalty;
}
float PolygonPathFinder::get_point_penalty(int p_point) const {
-
ERR_FAIL_INDEX_V(p_point, points.size() - 2, 0);
return points[p_point].penalty;
}
void PolygonPathFinder::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("setup", "points", "connections"), &PolygonPathFinder::setup);
ClassDB::bind_method(D_METHOD("find_path", "from", "to"), &PolygonPathFinder::find_path);
ClassDB::bind_method(D_METHOD("get_intersections", "from", "to"), &PolygonPathFinder::get_intersections);
diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h
index 2ef5c89e2a..baee4dc20d 100644
--- a/scene/resources/polygon_path_finder.h
+++ b/scene/resources/polygon_path_finder.h
@@ -34,7 +34,6 @@
#include "core/resource.h"
class PolygonPathFinder : public Resource {
-
GDCLASS(PolygonPathFinder, Resource);
struct Point {
@@ -46,19 +45,17 @@ class PolygonPathFinder : public Resource {
};
struct Edge {
-
int points[2];
_FORCE_INLINE_ bool operator<(const Edge &p_edge) const {
-
- if (points[0] == p_edge.points[0])
+ if (points[0] == p_edge.points[0]) {
return points[1] < p_edge.points[1];
- else
+ } else {
return points[0] < p_edge.points[0];
+ }
}
Edge(int a = 0, int b = 0) {
-
if (a > b) {
SWAP(a, b);
}
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 46e8575018..8d9c5f07b2 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -35,7 +35,6 @@
PrimitiveMesh
*/
void PrimitiveMesh::_update() const {
-
Array arr;
arr.resize(RS::ARRAY_MAX);
_create_mesh_array(arr);
@@ -47,13 +46,13 @@ void PrimitiveMesh::_update() const {
int pc = points.size();
ERR_FAIL_COND(pc == 0);
{
-
const Vector3 *r = points.ptr();
for (int i = 0; i < pc; i++) {
- if (i == 0)
+ if (i == 0) {
aabb.position = r[i];
- else
+ } else {
aabb.expand_to(r[i]);
+ }
}
}
@@ -63,7 +62,6 @@ void PrimitiveMesh::_update() const {
Vector<Vector3> normals = arr[RS::ARRAY_NORMAL];
if (normals.size() && indices.size()) {
-
{
int nc = normals.size();
Vector3 *w = normals.ptrw();
@@ -99,9 +97,9 @@ void PrimitiveMesh::_update() const {
}
void PrimitiveMesh::_request_update() {
-
- if (pending_request)
+ if (pending_request) {
return;
+ }
_update();
}
@@ -142,8 +140,8 @@ Array PrimitiveMesh::surface_get_arrays(int p_surface) const {
Dictionary PrimitiveMesh::surface_get_lods(int p_surface) const {
return Dictionary(); //not really supported
}
-Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const {
+Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const {
return Array(); //not really supported
}
@@ -206,7 +204,7 @@ void PrimitiveMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_flip_faces", "flip_faces"), &PrimitiveMesh::set_flip_faces);
ClassDB::bind_method(D_METHOD("get_flip_faces"), &PrimitiveMesh::get_flip_faces);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D"), "set_material", "get_material");
ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces");
}
@@ -230,14 +228,12 @@ Array PrimitiveMesh::get_mesh_arrays() const {
}
void PrimitiveMesh::set_custom_aabb(const AABB &p_custom) {
-
custom_aabb = p_custom;
RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
emit_changed();
}
AABB PrimitiveMesh::get_custom_aabb() const {
-
return custom_aabb;
}
@@ -251,7 +247,6 @@ bool PrimitiveMesh::get_flip_faces() const {
}
PrimitiveMesh::PrimitiveMesh() {
-
flip_faces = false;
// defaults
mesh = RenderingServer::get_singleton()->mesh_create();
@@ -1382,7 +1377,6 @@ void QuadMesh::_create_mesh_array(Array &p_arr) const {
};
for (int i = 0; i < 6; i++) {
-
int j = indices[i];
faces.set(i, quad_faces[j]);
normals.set(i, Vector3(0, 0, 1));
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 5f17680c9e..3cffa44e3a 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -42,7 +42,6 @@
This class is set apart that it assumes a single surface is always generated for our mesh.
*/
class PrimitiveMesh : public Mesh {
-
GDCLASS(PrimitiveMesh, Mesh);
private:
@@ -134,7 +133,6 @@ public:
Similar to test cube but with subdivision support and different texture coordinates
*/
class CubeMesh : public PrimitiveMesh {
-
GDCLASS(CubeMesh, PrimitiveMesh);
private:
@@ -168,7 +166,6 @@ public:
*/
class CylinderMesh : public PrimitiveMesh {
-
GDCLASS(CylinderMesh, PrimitiveMesh);
private:
@@ -205,7 +202,6 @@ public:
Similar to quadmesh but with tessellation support
*/
class PlaneMesh : public PrimitiveMesh {
-
GDCLASS(PlaneMesh, PrimitiveMesh);
private:
@@ -234,7 +230,6 @@ public:
A prism shapen, handy for ramps, triangles, etc.
*/
class PrismMesh : public PrimitiveMesh {
-
GDCLASS(PrismMesh, PrimitiveMesh);
private:
@@ -272,7 +267,6 @@ public:
*/
class QuadMesh : public PrimitiveMesh {
-
GDCLASS(QuadMesh, PrimitiveMesh);
private:
@@ -293,7 +287,6 @@ public:
A sphere..
*/
class SphereMesh : public PrimitiveMesh {
-
GDCLASS(SphereMesh, PrimitiveMesh);
private:
@@ -331,7 +324,6 @@ public:
*/
class PointMesh : public PrimitiveMesh {
-
GDCLASS(PointMesh, PrimitiveMesh)
protected:
diff --git a/scene/resources/ray_shape_2d.cpp b/scene/resources/ray_shape_2d.cpp
new file mode 100644
index 0000000000..67c4f84749
--- /dev/null
+++ b/scene/resources/ray_shape_2d.cpp
@@ -0,0 +1,105 @@
+/*************************************************************************/
+/* ray_shape_2d.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 "ray_shape_2d.h"
+
+#include "servers/physics_server_2d.h"
+#include "servers/rendering_server.h"
+
+void RayShape2D::_update_shape() {
+ Dictionary d;
+ d["length"] = length;
+ d["slips_on_slope"] = slips_on_slope;
+ PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d);
+ emit_changed();
+}
+
+void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
+ Vector2 tip = Vector2(0, get_length());
+ RS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
+ Vector<Vector2> pts;
+ float tsize = 4;
+ pts.push_back(tip + Vector2(0, tsize));
+ pts.push_back(tip + Vector2(Math_SQRT12 * tsize, 0));
+ pts.push_back(tip + Vector2(-Math_SQRT12 * tsize, 0));
+ Vector<Color> cols;
+ for (int i = 0; i < 3; i++) {
+ cols.push_back(p_color);
+ }
+ RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
+}
+
+Rect2 RayShape2D::get_rect() const {
+ Rect2 rect;
+ rect.position = Vector2();
+ rect.expand_to(Vector2(0, length));
+ rect = rect.grow(Math_SQRT12 * 4);
+ return rect;
+}
+
+real_t RayShape2D::get_enclosing_radius() const {
+ return length;
+}
+
+void RayShape2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &RayShape2D::get_length);
+
+ ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
+ ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
+
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length"), "set_length", "get_length");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
+}
+
+void RayShape2D::set_length(real_t p_length) {
+ length = p_length;
+ _update_shape();
+}
+
+real_t RayShape2D::get_length() const {
+ return length;
+}
+
+void RayShape2D::set_slips_on_slope(bool p_active) {
+ slips_on_slope = p_active;
+ _update_shape();
+}
+
+bool RayShape2D::get_slips_on_slope() const {
+ return slips_on_slope;
+}
+
+RayShape2D::RayShape2D() :
+ Shape2D(PhysicsServer2D::get_singleton()->ray_shape_create()) {
+ length = 20;
+ slips_on_slope = false;
+ _update_shape();
+}
diff --git a/core/math/disjoint_set.cpp b/scene/resources/ray_shape_2d.h
index a508151ad3..9a209d2907 100644
--- a/core/math/disjoint_set.cpp
+++ b/scene/resources/ray_shape_2d.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* disjoint_set.cpp */
+/* ray_shape_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,4 +28,34 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "disjoint_set.h"
+#ifndef RAY_SHAPE_2D_H
+#define RAY_SHAPE_2D_H
+
+#include "scene/resources/shape_2d.h"
+
+class RayShape2D : public Shape2D {
+ GDCLASS(RayShape2D, Shape2D);
+
+ real_t length;
+ bool slips_on_slope;
+
+ void _update_shape();
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_length(real_t p_length);
+ real_t get_length() const;
+
+ void set_slips_on_slope(bool p_active);
+ bool get_slips_on_slope() const;
+
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
+ virtual Rect2 get_rect() const;
+ virtual real_t get_enclosing_radius() const;
+
+ RayShape2D();
+};
+
+#endif // RAY_SHAPE_2D_H
diff --git a/scene/resources/ray_shape_3d.cpp b/scene/resources/ray_shape_3d.cpp
index 0211c55f46..17205a500a 100644
--- a/scene/resources/ray_shape_3d.cpp
+++ b/scene/resources/ray_shape_3d.cpp
@@ -33,7 +33,6 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> RayShape3D::get_debug_mesh_lines() {
-
Vector<Vector3> points;
points.push_back(Vector3());
points.push_back(Vector3(0, 0, get_length()));
@@ -46,7 +45,6 @@ real_t RayShape3D::get_enclosing_radius() const {
}
void RayShape3D::_update_shape() {
-
Dictionary d;
d["length"] = length;
d["slips_on_slope"] = slips_on_slope;
@@ -55,7 +53,6 @@ void RayShape3D::_update_shape() {
}
void RayShape3D::set_length(float p_length) {
-
length = p_length;
_update_shape();
notify_change_to_owners();
@@ -63,12 +60,10 @@ void RayShape3D::set_length(float p_length) {
}
float RayShape3D::get_length() const {
-
return length;
}
void RayShape3D::set_slips_on_slope(bool p_active) {
-
slips_on_slope = p_active;
_update_shape();
notify_change_to_owners();
@@ -80,7 +75,6 @@ bool RayShape3D::get_slips_on_slope() const {
}
void RayShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape3D::set_length);
ClassDB::bind_method(D_METHOD("get_length"), &RayShape3D::get_length);
@@ -93,7 +87,6 @@ void RayShape3D::_bind_methods() {
RayShape3D::RayShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_RAY)) {
-
length = 1.0;
slips_on_slope = false;
diff --git a/scene/resources/ray_shape_3d.h b/scene/resources/ray_shape_3d.h
index 83bb71cca3..ef849d2dee 100644
--- a/scene/resources/ray_shape_3d.h
+++ b/scene/resources/ray_shape_3d.h
@@ -33,7 +33,6 @@
#include "scene/resources/shape_3d.h"
class RayShape3D : public Shape3D {
-
GDCLASS(RayShape3D, Shape3D);
float length;
bool slips_on_slope;
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp
index 19e72a65b0..949fddf2e7 100644
--- a/scene/resources/rectangle_shape_2d.cpp
+++ b/scene/resources/rectangle_shape_2d.cpp
@@ -33,29 +33,24 @@
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
void RectangleShape2D::_update_shape() {
-
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), extents);
emit_changed();
}
void RectangleShape2D::set_extents(const Vector2 &p_extents) {
-
extents = p_extents;
_update_shape();
}
Vector2 RectangleShape2D::get_extents() const {
-
return extents;
}
void RectangleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
RenderingServer::get_singleton()->canvas_item_add_rect(p_to_rid, Rect2(-extents, extents * 2.0), p_color);
}
Rect2 RectangleShape2D::get_rect() const {
-
return Rect2(-extents, extents * 2.0);
}
@@ -64,7 +59,6 @@ real_t RectangleShape2D::get_enclosing_radius() const {
}
void RectangleShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &RectangleShape2D::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &RectangleShape2D::get_extents);
@@ -73,7 +67,6 @@ void RectangleShape2D::_bind_methods() {
RectangleShape2D::RectangleShape2D() :
Shape2D(PhysicsServer2D::get_singleton()->rectangle_shape_create()) {
-
extents = Vector2(10, 10);
_update_shape();
}
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 41146036f6..93db8b725f 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -46,17 +46,14 @@
///
void ResourceLoaderText::set_local_path(const String &p_local_path) {
-
res_path = p_local_path;
}
Ref<Resource> ResourceLoaderText::get_resource() {
-
return resource;
}
Error ResourceLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
-
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
if (token.type != VariantParser::TK_NUMBER) {
@@ -86,7 +83,6 @@ Error ResourceLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, Varia
}
Error ResourceLoaderText::_parse_ext_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
-
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
if (token.type != VariantParser::TK_NUMBER) {
@@ -110,7 +106,6 @@ Error ResourceLoaderText::_parse_ext_resource_dummy(DummyReadData *p_data, Varia
}
Error ResourceLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
-
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
if (token.type != VariantParser::TK_NUMBER) {
@@ -123,11 +118,9 @@ Error ResourceLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, R
if (use_nocache) {
r_res = int_resources[index];
} else {
-
String path = local_path + "::" + itos(index);
if (!ignore_resource_parsing) {
-
if (!ResourceCache::has(path)) {
r_err_str = "Can't load cached sub-resource: " + path;
return ERR_PARSE_ERROR;
@@ -149,7 +142,6 @@ Error ResourceLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, R
}
Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
-
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
if (token.type != VariantParser::TK_NUMBER) {
@@ -160,7 +152,6 @@ Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, R
int id = token.value;
if (!ignore_resource_parsing) {
-
if (!ext_resources.has(id)) {
r_err_str = "Can't load cached ext-resource #" + itos(id);
return ERR_PARSE_ERROR;
@@ -172,10 +163,8 @@ Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, R
if (ext_resources[id].cache.is_valid()) {
r_res = ext_resources[id].cache;
} else if (use_sub_threads) {
-
RES res = ResourceLoader::load_threaded_get(path);
if (res.is_null()) {
-
if (ResourceLoader::get_abort_on_missing_resources()) {
error = ERR_FILE_CORRUPT;
error_text = "[ext_resource] referenced nonexistent resource at: " + path;
@@ -212,9 +201,7 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
packed_scene.instance();
while (true) {
-
if (next_tag.name == "node") {
-
int parent = -1;
int owner = -1;
int type = -1;
@@ -240,7 +227,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
if (next_tag.fields.has("instance")) {
-
instance = packed_scene->get_state()->add_value(next_tag.fields["instance"]);
if (packed_scene->get_state()->get_node_count() == 0 && parent == -1) {
@@ -250,7 +236,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
if (next_tag.fields.has("instance_placeholder")) {
-
String path = next_tag.fields["instance_placeholder"];
int path_v = packed_scene->get_state()->add_value(path);
@@ -268,8 +253,9 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
if (next_tag.fields.has("owner")) {
owner = packed_scene->get_state()->add_node_path(next_tag.fields["owner"]);
} else {
- if (parent != -1 && !(type == SceneState::TYPE_INSTANCED && instance == -1))
+ if (parent != -1 && !(type == SceneState::TYPE_INSTANCED && instance == -1)) {
owner = 0; //if no owner, owner is root
+ }
}
if (next_tag.fields.has("index")) {
@@ -279,7 +265,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
int node_id = packed_scene->get_state()->add_node(parent, owner, type, name, instance, index);
if (next_tag.fields.has("groups")) {
-
Array groups = next_tag.fields["groups"];
for (int i = 0; i < groups.size(); i++) {
packed_scene->get_state()->add_node_group(node_id, packed_scene->get_state()->add_name(groups[i]));
@@ -287,7 +272,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
while (true) {
-
String assign;
Variant value;
@@ -313,7 +297,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
}
} else if (next_tag.name == "connection") {
-
if (!next_tag.fields.has("from")) {
error = ERR_FILE_CORRUPT;
error_text = "missing 'from' field from connection tag";
@@ -378,7 +361,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
}
} else if (next_tag.name == "editable") {
-
if (!next_tag.fields.has("path")) {
error = ERR_FILE_CORRUPT;
error_text = "missing 'path' field from connection tag";
@@ -402,7 +384,6 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
}
} else {
-
error = ERR_FILE_CORRUPT;
_printerr();
return Ref<PackedScene>();
@@ -411,9 +392,9 @@ Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourcePars
}
Error ResourceLoaderText::load() {
-
- if (error != OK)
+ if (error != OK) {
return error;
+ }
while (true) {
if (next_tag.name != "ext_resource") {
@@ -459,7 +440,6 @@ Error ResourceLoaderText::load() {
er.type = type;
if (use_sub_threads) {
-
Error err = ResourceLoader::load_threaded_request(path, type, use_sub_threads, local_path);
if (err != OK) {
@@ -477,7 +457,6 @@ Error ResourceLoaderText::load() {
RES res = ResourceLoader::load(path, type);
if (res.is_null()) {
-
if (ResourceLoader::get_abort_on_missing_resources()) {
error = ERR_FILE_CORRUPT;
error_text = "[ext_resource] referenced nonexistent resource at: " + path;
@@ -487,7 +466,6 @@ Error ResourceLoaderText::load() {
ResourceLoader::notify_dependency_error(local_path, path, type);
}
} else {
-
#ifdef TOOLS_ENABLED
//remember ID for saving
res->set_id_for_path(local_path, index);
@@ -544,7 +522,6 @@ Error ResourceLoaderText::load() {
Object *obj = ClassDB::instance(type);
if (!obj) {
-
error_text += "Can't create sub resource of type: " + type;
_printerr();
error = ERR_FILE_CORRUPT;
@@ -553,7 +530,6 @@ Error ResourceLoaderText::load() {
Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
-
error_text += "Can't create sub resource of type, because not a resource: " + type;
_printerr();
error = ERR_FILE_CORRUPT;
@@ -570,7 +546,6 @@ Error ResourceLoaderText::load() {
resource_current++;
while (true) {
-
String assign;
Variant value;
@@ -587,7 +562,6 @@ Error ResourceLoaderText::load() {
}
//it's assignment
} else if (next_tag.name != String()) {
-
error = OK;
break;
} else {
@@ -609,7 +583,6 @@ Error ResourceLoaderText::load() {
}
if (is_scene) {
-
error_text += "found the 'resource' tag on a scene file!";
_printerr();
error = ERR_FILE_CORRUPT;
@@ -618,7 +591,6 @@ Error ResourceLoaderText::load() {
Object *obj = ClassDB::instance(res_type);
if (!obj) {
-
error_text += "Can't create sub resource of type: " + res_type;
_printerr();
error = ERR_FILE_CORRUPT;
@@ -627,7 +599,6 @@ Error ResourceLoaderText::load() {
Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
-
error_text += "Can't create sub resource of type, because not a resource: " + res_type;
_printerr();
error = ERR_FILE_CORRUPT;
@@ -639,7 +610,6 @@ Error ResourceLoaderText::load() {
resource_current++;
while (true) {
-
String assign;
Variant value;
@@ -664,7 +634,6 @@ Error ResourceLoaderText::load() {
resource->set(assign, value);
//it's assignment
} else if (next_tag.name != String()) {
-
error = ERR_FILE_CORRUPT;
error_text = "Extra tag found when parsing main resource file";
_printerr();
@@ -683,9 +652,7 @@ Error ResourceLoaderText::load() {
//for scene files
if (next_tag.name == "node") {
-
if (!is_scene) {
-
error_text += "found the 'node' tag on a resource file!";
_printerr();
error = ERR_FILE_CORRUPT;
@@ -694,8 +661,9 @@ Error ResourceLoaderText::load() {
Ref<PackedScene> packed_scene = _parse_node_tag(rp);
- if (!packed_scene.is_valid())
+ if (!packed_scene.is_valid()) {
return error;
+ }
error = OK;
//get it here
@@ -720,21 +688,18 @@ Error ResourceLoaderText::load() {
}
int ResourceLoaderText::get_stage() const {
-
return resource_current;
}
-int ResourceLoaderText::get_stage_count() const {
+int ResourceLoaderText::get_stage_count() const {
return resources_total; //+ext_resources;
}
void ResourceLoaderText::set_translation_remapped(bool p_remapped) {
-
translation_remapped = p_remapped;
}
ResourceLoaderText::ResourceLoaderText() {
-
use_nocache = false;
resources_total = 0;
@@ -749,18 +714,15 @@ ResourceLoaderText::ResourceLoaderText() {
}
ResourceLoaderText::~ResourceLoaderText() {
-
memdelete(f);
}
void ResourceLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types) {
-
open(p_f);
ignore_resource_parsing = true;
ERR_FAIL_COND(error != OK);
while (next_tag.name == "ext_resource") {
-
if (!next_tag.fields.has("type")) {
error = ERR_FILE_CORRUPT;
error_text = "Missing 'type' in external resource tag";
@@ -801,7 +763,6 @@ void ResourceLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_depen
}
Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map) {
-
open(p_f, true);
ERR_FAIL_COND_V(error != OK, error);
ignore_resource_parsing = true;
@@ -814,7 +775,6 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p
uint64_t tag_end = f->get_position();
while (true) {
-
Error err = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (err != OK) {
@@ -826,17 +786,15 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p
}
if (next_tag.name != "ext_resource") {
-
//nothing was done
- if (!fw)
+ if (!fw) {
return OK;
+ }
break;
} else {
-
if (!fw) {
-
fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);
if (is_scene) {
fw->store_line("[gd_scene load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
@@ -903,7 +861,6 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p
}
void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
-
error = OK;
lines = 1;
@@ -918,7 +875,6 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
Error err = VariantParser::parse_tag(&stream, lines, error_text, tag);
if (err) {
-
error = err;
_printerr();
return;
@@ -961,7 +917,6 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
}
if (!p_skip_first_tag) {
-
err = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (err) {
@@ -978,7 +933,6 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
}
static void bs_save_unicode_string(FileAccess *f, const String &p_string, bool p_bit_on_len = false) {
-
CharString utf8 = p_string.utf8();
if (p_bit_on_len) {
f->store_32((utf8.length() + 1) | 0x80000000);
@@ -989,9 +943,9 @@ static void bs_save_unicode_string(FileAccess *f, const String &p_string, bool p
}
Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) {
-
- if (error)
+ if (error) {
return error;
+ }
FileAccessRef wf = FileAccess::open(p_path, FileAccess::WRITE);
if (!wf) {
@@ -1011,8 +965,9 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
bs_save_unicode_string(wf.f, is_scene ? "PackedScene" : resource_type);
wf->store_64(0); //offset to import metadata, this is no longer used
- for (int i = 0; i < 14; i++)
+ for (int i = 0; i < 14; i++) {
wf->store_32(0); // reserved
+ }
wf->store_32(0); //string table size, will not be in use
size_t ext_res_count_pos = wf->get_position();
@@ -1028,7 +983,6 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
rp.userdata = &dummy_read;
while (next_tag.name == "ext_resource") {
-
if (!next_tag.fields.has("path")) {
error = ERR_FILE_CORRUPT;
error_text = "Missing 'path' in external resource tag";
@@ -1092,7 +1046,6 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
Vector<size_t> local_pointers_pos;
while (next_tag.name == "sub_resource" || next_tag.name == "resource") {
-
String type;
int id = -1;
bool main_res;
@@ -1134,7 +1087,6 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
int prop_count = 0;
while (true) {
-
String assign;
Variant value;
@@ -1151,14 +1103,12 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
}
if (assign != String()) {
-
Map<StringName, int> empty_string_map; //unused
bs_save_unicode_string(wf2, assign, true);
ResourceFormatSaverBinaryInstance::write_variant(wf2, value, dummy_read.resource_set, dummy_read.external_resources, empty_string_map);
prop_count++;
} else if (next_tag.name != String()) {
-
error = OK;
break;
} else {
@@ -1178,7 +1128,6 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
//this is a node, must save one more!
if (!is_scene) {
-
error_text += "found the 'node' tag on a resource file!";
_printerr();
error = ERR_FILE_CORRUPT;
@@ -1187,8 +1136,9 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
Ref<PackedScene> packed_scene = _parse_node_tag(rp);
- if (!packed_scene.is_valid())
+ if (!packed_scene.is_valid()) {
return error;
+ }
error = OK;
//get it here
@@ -1207,9 +1157,9 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
int prop_count = 0;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
+ }
String name = E->get().name;
Variant value = packed_scene->get(name);
@@ -1253,7 +1203,6 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path)
}
String ResourceLoaderText::recognize(FileAccess *p_f) {
-
error = OK;
lines = 1;
@@ -1280,11 +1229,13 @@ String ResourceLoaderText::recognize(FileAccess *p_f) {
}
}
- if (tag.name == "gd_scene")
+ if (tag.name == "gd_scene") {
return "PackedScene";
+ }
- if (tag.name != "gd_resource")
+ if (tag.name != "gd_resource") {
return "";
+ }
if (!tag.fields.has("type")) {
error_text = "Missing 'type' field in 'gd_resource' tag";
@@ -1298,9 +1249,9 @@ String ResourceLoaderText::recognize(FileAccess *p_f) {
/////////////////////
RES ResourceFormatLoaderText::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)
+ if (r_error) {
*r_error = ERR_CANT_OPEN;
+ }
Error err;
@@ -1329,41 +1280,39 @@ RES ResourceFormatLoaderText::load(const String &p_path, const String &p_origina
}
void ResourceFormatLoaderText::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
-
if (p_type == "") {
get_recognized_extensions(p_extensions);
return;
}
- if (p_type == "PackedScene")
+ if (p_type == "PackedScene") {
p_extensions->push_back("tscn");
- else
+ } else {
p_extensions->push_back("tres");
+ }
}
void ResourceFormatLoaderText::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("tscn");
p_extensions->push_back("tres");
}
bool ResourceFormatLoaderText::handles_type(const String &p_type) const {
-
return true;
}
-String ResourceFormatLoaderText::get_resource_type(const String &p_path) const {
+String ResourceFormatLoaderText::get_resource_type(const String &p_path) const {
String ext = p_path.get_extension().to_lower();
- if (ext == "tscn")
+ if (ext == "tscn") {
return "PackedScene";
- else if (ext != "tres")
+ } else if (ext != "tres") {
return String();
+ }
//for anyhting else must test..
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
-
return ""; //could not rwead
}
@@ -1376,10 +1325,8 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const {
}
void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
-
ERR_FAIL();
}
@@ -1391,10 +1338,8 @@ void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<Strin
}
Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
-
ERR_FAIL_V(ERR_CANT_OPEN);
}
@@ -1408,7 +1353,6 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const
ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = nullptr;
Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, const String &p_dst_path) {
-
Error err;
FileAccess *f = FileAccess::open(p_src_path, FileAccess::READ, &err);
@@ -1435,18 +1379,14 @@ Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path,
/*****************************************************************************************************/
String ResourceFormatSaverTextInstance::_write_resources(void *ud, const RES &p_resource) {
-
ResourceFormatSaverTextInstance *rsi = (ResourceFormatSaverTextInstance *)ud;
return rsi->_write_resource(p_resource);
}
String ResourceFormatSaverTextInstance::_write_resource(const RES &res) {
-
if (external_resources.has(res)) {
-
return "ExtResource( " + itos(external_resources[res]) + " )";
} else {
-
if (internal_resources.has(res)) {
return "SubResource( " + itos(internal_resources[res]) + " )";
} else if (res->get_path().length() && res->get_path().find("::") == -1) {
@@ -1464,14 +1404,13 @@ String ResourceFormatSaverTextInstance::_write_resource(const RES &res) {
}
void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, bool p_main) {
-
switch (p_variant.get_type()) {
case Variant::OBJECT: {
-
RES res = p_variant;
- if (res.is_null() || external_resources.has(res))
+ if (res.is_null() || external_resources.has(res)) {
return;
+ }
if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) {
if (res->get_path() == local_path) {
@@ -1483,8 +1422,9 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
return;
}
- if (resource_set.has(res))
+ if (resource_set.has(res)) {
return;
+ }
List<PropertyInfo> property_list;
@@ -1494,11 +1434,9 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
List<PropertyInfo>::Element *I = property_list.front();
while (I) {
-
PropertyInfo pi = I->get();
if (pi.usage & PROPERTY_USAGE_STORAGE) {
-
Variant v = res->get(I->get().name);
if (pi.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
@@ -1524,23 +1462,19 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
} break;
case Variant::ARRAY: {
-
Array varray = p_variant;
int len = varray.size();
for (int i = 0; i < len; i++) {
-
const Variant &v = varray.get(i);
_find_resources(v);
}
} break;
case Variant::DICTIONARY: {
-
Dictionary d = p_variant;
List<Variant> keys;
d.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
Variant v = d[E->get()];
_find_resources(v);
}
@@ -1551,7 +1485,6 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
}
Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
if (p_path.ends_with(".tscn")) {
packed_scene = p_resource;
}
@@ -1577,8 +1510,9 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
if (packed_scene.is_valid()) {
//add instances to external resources if saving a packed scene
for (int i = 0; i < packed_scene->get_state()->get_node_count(); i++) {
- if (packed_scene->get_state()->is_node_instance_placeholder(i))
+ if (packed_scene->get_state()->is_node_instance_placeholder(i)) {
continue;
+ }
Ref<PackedScene> instance = packed_scene->get_state()->get_node_instance(i);
if (instance.is_valid() && !external_resources.has(instance)) {
@@ -1590,8 +1524,9 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
{
String title = packed_scene.is_valid() ? "[gd_scene " : "[gd_resource ";
- if (packed_scene.is_null())
+ if (packed_scene.is_null()) {
title += "type=\"" + p_resource->get_class() + "\" ";
+ }
int load_steps = saved_resources.size() + external_resources.size();
/*
if (packed_scene.is_valid()) {
@@ -1648,7 +1583,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
Vector<ResourceSort> sorted_er;
for (Map<RES, int>::Element *E = external_resources.front(); E; E = E->next()) {
-
ResourceSort rs;
rs.resource = E->key();
rs.index = E->get();
@@ -1663,16 +1597,15 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
f->store_string("[ext_resource path=\"" + p + "\" type=\"" + sorted_er[i].resource->get_save_class() + "\" id=" + itos(sorted_er[i].index) + "]\n"); //bundled
}
- if (external_resources.size())
+ if (external_resources.size()) {
f->store_line(String()); //separate
+ }
Set<int> used_indices;
for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
-
RES res = E->get();
if (E->next() && (res->get_path() == "" || res->get_path().find("::") != -1)) {
-
if (res->get_subindex() != 0) {
if (used_indices.has(res->get_subindex())) {
res->set_subindex(0); //repeated
@@ -1684,13 +1617,13 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
-
RES res = E->get();
ERR_CONTINUE(!resource_set.has(res));
bool main = (E->next() == nullptr);
- if (main && packed_scene.is_valid())
+ if (main && packed_scene.is_valid()) {
break; //save as a scene
+ }
if (main) {
f->store_line("[resource]");
@@ -1723,12 +1656,11 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
res->get_property_list(&property_list);
//property_list.sort();
for (List<PropertyInfo>::Element *PE = property_list.front(); PE; PE = PE->next()) {
-
- if (skip_editor && PE->get().name.begins_with("__editor"))
+ if (skip_editor && PE->get().name.begins_with("__editor")) {
continue;
+ }
if (PE->get().usage & PROPERTY_USAGE_STORAGE) {
-
String name = PE->get().name;
Variant value;
if (PE->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
@@ -1747,8 +1679,9 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
continue;
}
- if (PE->get().type == Variant::OBJECT && value.is_zero() && !(PE->get().usage & PROPERTY_USAGE_STORE_IF_NULL))
+ if (PE->get().type == Variant::OBJECT && value.is_zero() && !(PE->get().usage & PROPERTY_USAGE_STORE_IF_NULL)) {
continue;
+ }
String vars;
VariantWriter::write_to_string(value, vars, _write_resources, this);
@@ -1756,15 +1689,15 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
}
- if (E->next())
+ if (E->next()) {
f->store_line(String());
+ }
}
if (packed_scene.is_valid()) {
//if this is a scene, save nodes and connections!
Ref<SceneState> state = packed_scene->get_state();
for (int i = 0; i < state->get_node_count(); i++) {
-
StringName type = state->get_node_type(i);
StringName name = state->get_node_name(i);
int index = state->get_node_index(i);
@@ -1802,7 +1735,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
f->store_string(header);
if (instance_placeholder != String()) {
-
String vars;
f->store_string(" instance_placeholder=");
VariantWriter::write_to_string(instance_placeholder, vars, _write_resources, this);
@@ -1810,7 +1742,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
if (instance.is_valid()) {
-
String vars;
f->store_string(" instance=");
VariantWriter::write_to_string(instance, vars, _write_resources, this);
@@ -1820,19 +1751,18 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
f->store_line("]");
for (int j = 0; j < state->get_node_property_count(i); j++) {
-
String vars;
VariantWriter::write_to_string(state->get_node_property_value(i, j), vars, _write_resources, this);
f->store_string(String(state->get_node_property_name(i, j)).property_name_encode() + " = " + vars + "\n");
}
- if (i < state->get_node_count() - 1)
+ if (i < state->get_node_count() - 1) {
f->store_line(String());
+ }
}
for (int i = 0; i < state->get_connection_count(); i++) {
-
String connstr = "[connection";
connstr += " signal=\"" + String(state->get_connection_signal(i)) + "\"";
connstr += " from=\"" + String(state->get_connection_source(i).simplified()) + "\"";
@@ -1872,7 +1802,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}
Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
if (p_path.ends_with(".sct") && p_resource->get_class() != "PackedScene") {
return ERR_FILE_UNRECOGNIZED;
}
@@ -1882,15 +1811,15 @@ Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource,
}
bool ResourceFormatSaverText::recognize(const RES &p_resource) const {
-
return true; // all recognized!
}
-void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->get_class() == "PackedScene")
+void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
+ if (p_resource->get_class() == "PackedScene") {
p_extensions->push_back("tscn"); //text scene
- else
+ } else {
p_extensions->push_back("tres"); //text resource
+ }
}
ResourceFormatSaverText *ResourceFormatSaverText::singleton = nullptr;
diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h
index b9a6db5f36..cf522c9364 100644
--- a/scene/resources/resource_format_text.h
+++ b/scene/resources/resource_format_text.h
@@ -38,7 +38,6 @@
#include "scene/resources/packed_scene.h"
class ResourceLoaderText {
-
bool translation_remapped;
String local_path;
String res_path;
@@ -92,7 +91,6 @@ class ResourceLoaderText {
};
struct DummyReadData {
-
Map<RES, int> external_resources;
Map<int, RES> rev_external_resources;
Set<RES> resource_set;
@@ -150,7 +148,6 @@ public:
};
class ResourceFormatSaverTextInstance {
-
String local_path;
Ref<PackedScene> packed_scene;
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index 814c349784..b1001203a1 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -30,18 +30,17 @@
#include "segment_shape_2d.h"
+#include "core/math/geometry_2d.h"
#include "servers/physics_server_2d.h"
#include "servers/rendering_server.h"
bool SegmentShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
-
Vector2 l[2] = { a, b };
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, l);
+ Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, l);
return p_point.distance_to(closest) < p_tolerance;
}
void SegmentShape2D::_update_shape() {
-
Rect2 r;
r.position = a;
r.size = b;
@@ -50,32 +49,28 @@ void SegmentShape2D::_update_shape() {
}
void SegmentShape2D::set_a(const Vector2 &p_a) {
-
a = p_a;
_update_shape();
}
-Vector2 SegmentShape2D::get_a() const {
+Vector2 SegmentShape2D::get_a() const {
return a;
}
void SegmentShape2D::set_b(const Vector2 &p_b) {
-
b = p_b;
_update_shape();
}
-Vector2 SegmentShape2D::get_b() const {
+Vector2 SegmentShape2D::get_b() const {
return b;
}
void SegmentShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
RenderingServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3);
}
Rect2 SegmentShape2D::get_rect() const {
-
Rect2 rect;
rect.position = a;
rect.expand_to(b);
@@ -87,7 +82,6 @@ real_t SegmentShape2D::get_enclosing_radius() const {
}
void SegmentShape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_a", "a"), &SegmentShape2D::set_a);
ClassDB::bind_method(D_METHOD("get_a"), &SegmentShape2D::get_a);
@@ -100,88 +94,7 @@ void SegmentShape2D::_bind_methods() {
SegmentShape2D::SegmentShape2D() :
Shape2D(PhysicsServer2D::get_singleton()->segment_shape_create()) {
-
a = Vector2();
b = Vector2(0, 10);
_update_shape();
}
-
-////////////////////////////////////////////////////////////
-
-void RayShape2D::_update_shape() {
-
- Dictionary d;
- d["length"] = length;
- d["slips_on_slope"] = slips_on_slope;
- PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d);
- emit_changed();
-}
-
-void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-
- Vector2 tip = Vector2(0, get_length());
- RS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
- Vector<Vector2> pts;
- float tsize = 4;
- pts.push_back(tip + Vector2(0, tsize));
- pts.push_back(tip + Vector2(Math_SQRT12 * tsize, 0));
- pts.push_back(tip + Vector2(-Math_SQRT12 * tsize, 0));
- Vector<Color> cols;
- for (int i = 0; i < 3; i++)
- cols.push_back(p_color);
-
- RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
-}
-
-Rect2 RayShape2D::get_rect() const {
-
- Rect2 rect;
- rect.position = Vector2();
- rect.expand_to(Vector2(0, length));
- rect = rect.grow(Math_SQRT12 * 4);
- return rect;
-}
-
-real_t RayShape2D::get_enclosing_radius() const {
- return length;
-}
-
-void RayShape2D::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_length", "length"), &RayShape2D::set_length);
- ClassDB::bind_method(D_METHOD("get_length"), &RayShape2D::get_length);
-
- ClassDB::bind_method(D_METHOD("set_slips_on_slope", "active"), &RayShape2D::set_slips_on_slope);
- ClassDB::bind_method(D_METHOD("get_slips_on_slope"), &RayShape2D::get_slips_on_slope);
-
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "length"), "set_length", "get_length");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "slips_on_slope"), "set_slips_on_slope", "get_slips_on_slope");
-}
-
-void RayShape2D::set_length(real_t p_length) {
-
- length = p_length;
- _update_shape();
-}
-real_t RayShape2D::get_length() const {
-
- return length;
-}
-
-void RayShape2D::set_slips_on_slope(bool p_active) {
-
- slips_on_slope = p_active;
- _update_shape();
-}
-
-bool RayShape2D::get_slips_on_slope() const {
- return slips_on_slope;
-}
-
-RayShape2D::RayShape2D() :
- Shape2D(PhysicsServer2D::get_singleton()->ray_shape_create()) {
-
- length = 20;
- slips_on_slope = false;
- _update_shape();
-}
diff --git a/scene/resources/segment_shape_2d.h b/scene/resources/segment_shape_2d.h
index ca10c24f07..39c297b040 100644
--- a/scene/resources/segment_shape_2d.h
+++ b/scene/resources/segment_shape_2d.h
@@ -60,29 +60,4 @@ public:
SegmentShape2D();
};
-class RayShape2D : public Shape2D {
- GDCLASS(RayShape2D, Shape2D);
-
- real_t length;
- bool slips_on_slope;
-
- void _update_shape();
-
-protected:
- static void _bind_methods();
-
-public:
- void set_length(real_t p_length);
- real_t get_length() const;
-
- void set_slips_on_slope(bool p_active);
- bool get_slips_on_slope() const;
-
- virtual void draw(const RID &p_to_rid, const Color &p_color);
- virtual Rect2 get_rect() const;
- virtual real_t get_enclosing_radius() const;
-
- RayShape2D();
-};
-
#endif // SEGMENT_SHAPE_2D_H
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 1ac2f7c3c9..4249542567 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -36,12 +36,10 @@
#include "texture.h"
Shader::Mode Shader::get_mode() const {
-
return mode;
}
void Shader::set_code(const String &p_code) {
-
String type = ShaderLanguage::get_shader_type(p_code);
if (type == "canvas_item") {
@@ -61,13 +59,11 @@ void Shader::set_code(const String &p_code) {
}
String Shader::get_code() const {
-
_update_shader();
return RenderingServer::get_singleton()->shader_get_code(shader);
}
void Shader::get_param_list(List<PropertyInfo> *p_params) const {
-
_update_shader();
List<PropertyInfo> local;
@@ -76,7 +72,6 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const {
params_cache_dirty = false;
for (List<PropertyInfo>::Element *E = local.front(); E; E = E->next()) {
-
PropertyInfo pi = E->get();
if (default_textures.has(pi.name)) { //do not show default textures
continue;
@@ -84,24 +79,22 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const {
pi.name = "shader_param/" + pi.name;
params_cache[pi.name] = E->get().name;
if (p_params) {
-
//small little hack
- if (pi.type == Variant::_RID)
+ if (pi.type == Variant::_RID) {
pi.type = Variant::OBJECT;
+ }
p_params->push_back(pi);
}
}
}
RID Shader::get_rid() const {
-
_update_shader();
return shader;
}
void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture2D> &p_texture) {
-
if (p_texture.is_valid()) {
default_textures[p_param] = p_texture;
RS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid());
@@ -114,17 +107,15 @@ void Shader::set_default_texture_param(const StringName &p_param, const Ref<Text
}
Ref<Texture2D> Shader::get_default_texture_param(const StringName &p_param) const {
-
- if (default_textures.has(p_param))
+ if (default_textures.has(p_param)) {
return default_textures[p_param];
- else
+ } else {
return Ref<Texture2D>();
+ }
}
void Shader::get_default_texture_param_list(List<StringName> *r_textures) const {
-
for (const Map<StringName, Ref<Texture2D>>::Element *E = default_textures.front(); E; E = E->next()) {
-
r_textures->push_back(E->key());
}
}
@@ -134,15 +125,13 @@ bool Shader::is_text_shader() const {
}
bool Shader::has_param(const StringName &p_param) const {
-
- return params_cache.has(p_param);
+ return params_cache.has("shader_param/" + p_param);
}
void Shader::_update_shader() const {
}
void Shader::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_mode"), &Shader::get_mode);
ClassDB::bind_method(D_METHOD("set_code", "code"), &Shader::set_code);
@@ -164,22 +153,21 @@ void Shader::_bind_methods() {
}
Shader::Shader() {
-
mode = MODE_SPATIAL;
shader = RenderingServer::get_singleton()->shader_create();
params_cache_dirty = true;
}
Shader::~Shader() {
-
RenderingServer::get_singleton()->free(shader);
}
+
////////////
RES ResourceFormatLoaderShader::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)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
Ref<Shader> shader;
shader.instance();
@@ -191,32 +179,30 @@ RES ResourceFormatLoaderShader::load(const String &p_path, const String &p_origi
shader->set_code(str);
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return shader;
}
void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("shader");
}
bool ResourceFormatLoaderShader::handles_type(const String &p_type) const {
-
return (p_type == "Shader");
}
String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
-
String el = p_path.get_extension().to_lower();
- if (el == "shader")
+ if (el == "shader") {
return "Shader";
+ }
return "";
}
Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<Shader> shader = p_resource;
ERR_FAIL_COND_V(shader.is_null(), ERR_INVALID_PARAMETER);
@@ -239,14 +225,13 @@ Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resourc
}
void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (const Shader *shader = Object::cast_to<Shader>(*p_resource)) {
if (shader->is_text_shader()) {
p_extensions->push_back("shader");
}
}
}
-bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
+bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
return p_resource->get_class_name() == "Shader"; //only shader, not inherited
}
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 75c38bd561..2cdc2ec93f 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -37,7 +37,6 @@
#include "scene/resources/texture.h"
class Shader : public Resource {
-
GDCLASS(Shader, Resource);
OBJ_SAVE_TYPE(Shader);
@@ -83,12 +82,14 @@ public:
virtual bool is_text_shader() const;
_FORCE_INLINE_ StringName remap_param(const StringName &p_param) const {
- if (params_cache_dirty)
+ if (params_cache_dirty) {
get_param_list(nullptr);
+ }
const Map<StringName, StringName>::Element *E = params_cache.find(p_param);
- if (E)
+ if (E) {
return E->get();
+ }
return StringName();
}
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index 4fe585053a..94cecc76eb 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -31,23 +31,19 @@
#include "shape_2d.h"
#include "servers/physics_server_2d.h"
RID Shape2D::get_rid() const {
-
return shape;
}
void Shape2D::set_custom_solver_bias(real_t p_bias) {
-
custom_bias = p_bias;
PhysicsServer2D::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias);
}
real_t Shape2D::get_custom_solver_bias() const {
-
return custom_bias;
}
bool Shape2D::collide_with_motion(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion) {
-
ERR_FAIL_COND_V(p_shape.is_null(), false);
int r;
return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, nullptr, 0, r);
@@ -60,14 +56,14 @@ bool Shape2D::collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_sh
}
Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion) {
-
ERR_FAIL_COND_V(p_shape.is_null(), Array());
const int max_contacts = 16;
Vector2 result[max_contacts * 2];
int contacts = 0;
- if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts))
+ if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts)) {
return Array();
+ }
Array results;
results.resize(contacts * 2);
@@ -77,15 +73,16 @@ Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_x
return results;
}
-Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform) {
+Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform) {
ERR_FAIL_COND_V(p_shape.is_null(), Array());
const int max_contacts = 16;
Vector2 result[max_contacts * 2];
int contacts = 0;
- if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts))
+ if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts)) {
return Array();
+ }
Array results;
results.resize(contacts * 2);
@@ -97,13 +94,13 @@ Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const
}
void Shape2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_custom_solver_bias", "bias"), &Shape2D::set_custom_solver_bias);
ClassDB::bind_method(D_METHOD("get_custom_solver_bias"), &Shape2D::get_custom_solver_bias);
ClassDB::bind_method(D_METHOD("collide", "local_xform", "with_shape", "shape_xform"), &Shape2D::collide);
ClassDB::bind_method(D_METHOD("collide_with_motion", "local_xform", "local_motion", "with_shape", "shape_xform", "shape_motion"), &Shape2D::collide_with_motion);
ClassDB::bind_method(D_METHOD("collide_and_get_contacts", "local_xform", "with_shape", "shape_xform"), &Shape2D::collide_and_get_contacts);
ClassDB::bind_method(D_METHOD("collide_with_motion_and_get_contacts", "local_xform", "local_motion", "with_shape", "shape_xform", "shape_motion"), &Shape2D::collide_with_motion_and_get_contacts);
+ ClassDB::bind_method(D_METHOD("draw", "canvas_item", "color"), &Shape2D::draw);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "custom_solver_bias", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_custom_solver_bias", "get_custom_solver_bias");
}
@@ -114,6 +111,5 @@ Shape2D::Shape2D(const RID &p_rid) {
}
Shape2D::~Shape2D() {
-
PhysicsServer2D::get_singleton()->free(shape);
}
diff --git a/scene/resources/shape_3d.cpp b/scene/resources/shape_3d.cpp
index f4a5d91e52..59766f4f1f 100644
--- a/scene/resources/shape_3d.cpp
+++ b/scene/resources/shape_3d.cpp
@@ -36,11 +36,9 @@
#include "servers/physics_server_3d.h"
void Shape3D::add_vertices_to_array(Vector<Vector3> &array, const Transform &p_xform) {
-
Vector<Vector3> toadd = get_debug_mesh_lines();
if (toadd.size()) {
-
int base = array.size();
array.resize(base + toadd.size());
Vector3 *w = array.ptrw();
@@ -60,9 +58,9 @@ void Shape3D::set_margin(real_t p_margin) {
}
Ref<ArrayMesh> Shape3D::get_debug_mesh() {
-
- if (debug_mesh_cache.is_valid())
+ if (debug_mesh_cache.is_valid()) {
return debug_mesh_cache;
+ }
Vector<Vector3> lines = get_debug_mesh_lines();
@@ -73,7 +71,6 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() {
Vector<Vector3> array;
array.resize(lines.size());
{
-
Vector3 *w = array.ptrw();
for (int i = 0; i < lines.size(); i++) {
w[i] = lines[i];
@@ -102,26 +99,19 @@ void Shape3D::_update_shape() {
}
void Shape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Shape3D::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &Shape3D::get_margin);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "margin", PROPERTY_HINT_RANGE, "0.001,10,0.001"), "set_margin", "get_margin");
}
-Shape3D::Shape3D() :
- margin(0.04) {
-
- ERR_PRINT("Constructor must not be called!");
+Shape3D::Shape3D() {
+ ERR_PRINT("Default constructor must not be called!");
}
Shape3D::Shape3D(RID p_shape) :
- margin(0.04) {
-
- shape = p_shape;
-}
+ shape(p_shape) {}
Shape3D::~Shape3D() {
-
PhysicsServer3D::get_singleton()->free(shape);
}
diff --git a/scene/resources/shape_3d.h b/scene/resources/shape_3d.h
index e7a516412d..a83b2ed009 100644
--- a/scene/resources/shape_3d.h
+++ b/scene/resources/shape_3d.h
@@ -36,12 +36,11 @@
class ArrayMesh;
class Shape3D : public Resource {
-
GDCLASS(Shape3D, Resource);
OBJ_SAVE_TYPE(Shape3D);
RES_BASE_EXTENSION("shape");
RID shape;
- real_t margin;
+ real_t margin = 0.04;
Ref<ArrayMesh> debug_mesh_cache;
diff --git a/scene/resources/skin.cpp b/scene/resources/skin.cpp
index df0620b6c4..e88841a531 100644
--- a/scene/resources/skin.cpp
+++ b/scene/resources/skin.cpp
@@ -46,7 +46,6 @@ void Skin::add_bind(int p_bone, const Transform &p_pose) {
}
void Skin::add_named_bind(const String &p_name, const Transform &p_pose) {
-
uint32_t index = bind_count;
set_bind_count(bind_count + 1);
set_bind_name(index, p_name);
@@ -105,7 +104,6 @@ bool Skin::_set(const StringName &p_name, const Variant &p_value) {
}
bool Skin::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name == "bind_count") {
r_ret = get_bind_count();
@@ -126,6 +124,7 @@ bool Skin::_get(const StringName &p_name, Variant &r_ret) const {
}
return false;
}
+
void Skin::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "bind_count", PROPERTY_HINT_RANGE, "0,16384,1,or_greater"));
for (int i = 0; i < get_bind_count(); i++) {
@@ -136,7 +135,6 @@ void Skin::_get_property_list(List<PropertyInfo> *p_list) const {
}
void Skin::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_bind_count", "bind_count"), &Skin::set_bind_count);
ClassDB::bind_method(D_METHOD("get_bind_count"), &Skin::get_bind_count);
diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp
index cbe86b16b2..54b6cde8bd 100644
--- a/scene/resources/sky.cpp
+++ b/scene/resources/sky.cpp
@@ -43,7 +43,6 @@ void Sky::set_radiance_size(RadianceSize p_size) {
}
Sky::RadianceSize Sky::get_radiance_size() const {
-
return radiance_size;
}
@@ -59,8 +58,9 @@ Sky::ProcessMode Sky::get_process_mode() const {
void Sky::set_material(const Ref<Material> &p_material) {
sky_material = p_material;
RID material_rid;
- if (sky_material.is_valid())
+ if (sky_material.is_valid()) {
material_rid = sky_material->get_rid();
+ }
RS::get_singleton()->sky_set_material(sky, material_rid);
}
@@ -69,12 +69,10 @@ Ref<Material> Sky::get_material() const {
}
RID Sky::get_rid() const {
-
return sky;
}
void Sky::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radiance_size", "size"), &Sky::set_radiance_size);
ClassDB::bind_method(D_METHOD("get_radiance_size"), &Sky::get_radiance_size);
@@ -108,6 +106,5 @@ Sky::Sky() {
}
Sky::~Sky() {
-
RS::get_singleton()->free(sky);
} \ No newline at end of file
diff --git a/scene/resources/sky_material.cpp b/scene/resources/sky_material.cpp
index a0b6ab1e30..69e8e0b5bd 100644
--- a/scene/resources/sky_material.cpp
+++ b/scene/resources/sky_material.cpp
@@ -31,103 +31,92 @@
#include "sky_material.h"
void ProceduralSkyMaterial::set_sky_top_color(const Color &p_sky_top) {
-
sky_top_color = p_sky_top;
RS::get_singleton()->material_set_param(_get_material(), "sky_top_color", sky_top_color.to_linear());
}
Color ProceduralSkyMaterial::get_sky_top_color() const {
-
return sky_top_color;
}
void ProceduralSkyMaterial::set_sky_horizon_color(const Color &p_sky_horizon) {
-
sky_horizon_color = p_sky_horizon;
RS::get_singleton()->material_set_param(_get_material(), "sky_horizon_color", sky_horizon_color.to_linear());
}
-Color ProceduralSkyMaterial::get_sky_horizon_color() const {
+Color ProceduralSkyMaterial::get_sky_horizon_color() const {
return sky_horizon_color;
}
void ProceduralSkyMaterial::set_sky_curve(float p_curve) {
-
sky_curve = p_curve;
RS::get_singleton()->material_set_param(_get_material(), "sky_curve", sky_curve);
}
-float ProceduralSkyMaterial::get_sky_curve() const {
+float ProceduralSkyMaterial::get_sky_curve() const {
return sky_curve;
}
void ProceduralSkyMaterial::set_sky_energy(float p_energy) {
-
sky_energy = p_energy;
RS::get_singleton()->material_set_param(_get_material(), "sky_energy", sky_energy);
}
-float ProceduralSkyMaterial::get_sky_energy() const {
+float ProceduralSkyMaterial::get_sky_energy() const {
return sky_energy;
}
void ProceduralSkyMaterial::set_ground_bottom_color(const Color &p_ground_bottom) {
-
ground_bottom_color = p_ground_bottom;
RS::get_singleton()->material_set_param(_get_material(), "ground_bottom_color", ground_bottom_color.to_linear());
}
-Color ProceduralSkyMaterial::get_ground_bottom_color() const {
+Color ProceduralSkyMaterial::get_ground_bottom_color() const {
return ground_bottom_color;
}
void ProceduralSkyMaterial::set_ground_horizon_color(const Color &p_ground_horizon) {
-
ground_horizon_color = p_ground_horizon;
RS::get_singleton()->material_set_param(_get_material(), "ground_horizon_color", ground_horizon_color.to_linear());
}
-Color ProceduralSkyMaterial::get_ground_horizon_color() const {
+Color ProceduralSkyMaterial::get_ground_horizon_color() const {
return ground_horizon_color;
}
void ProceduralSkyMaterial::set_ground_curve(float p_curve) {
-
ground_curve = p_curve;
RS::get_singleton()->material_set_param(_get_material(), "ground_curve", ground_curve);
}
-float ProceduralSkyMaterial::get_ground_curve() const {
+float ProceduralSkyMaterial::get_ground_curve() const {
return ground_curve;
}
void ProceduralSkyMaterial::set_ground_energy(float p_energy) {
-
ground_energy = p_energy;
RS::get_singleton()->material_set_param(_get_material(), "ground_energy", ground_energy);
}
-float ProceduralSkyMaterial::get_ground_energy() const {
+float ProceduralSkyMaterial::get_ground_energy() const {
return ground_energy;
}
void ProceduralSkyMaterial::set_sun_angle_max(float p_angle) {
-
sun_angle_max = p_angle;
RS::get_singleton()->material_set_param(_get_material(), "sun_angle_max", Math::deg2rad(sun_angle_max));
}
-float ProceduralSkyMaterial::get_sun_angle_max() const {
+float ProceduralSkyMaterial::get_sun_angle_max() const {
return sun_angle_max;
}
void ProceduralSkyMaterial::set_sun_curve(float p_curve) {
-
sun_curve = p_curve;
RS::get_singleton()->material_set_param(_get_material(), "sun_curve", sun_curve);
}
-float ProceduralSkyMaterial::get_sun_curve() const {
+float ProceduralSkyMaterial::get_sun_curve() const {
return sun_curve;
}
@@ -136,17 +125,14 @@ bool ProceduralSkyMaterial::_can_do_next_pass() const {
}
Shader::Mode ProceduralSkyMaterial::get_shader_mode() const {
-
return Shader::MODE_SKY;
}
RID ProceduralSkyMaterial::get_shader_rid() const {
-
return shader;
}
void ProceduralSkyMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_sky_top_color", "color"), &ProceduralSkyMaterial::set_sky_top_color);
ClassDB::bind_method(D_METHOD("get_sky_top_color"), &ProceduralSkyMaterial::get_sky_top_color);
@@ -195,7 +181,6 @@ void ProceduralSkyMaterial::_bind_methods() {
}
ProceduralSkyMaterial::ProceduralSkyMaterial() {
-
String code = "shader_type sky;\n\n";
code += "uniform vec4 sky_top_color : hint_color = vec4(0.35, 0.46, 0.71, 1.0);\n";
@@ -285,13 +270,11 @@ ProceduralSkyMaterial::~ProceduralSkyMaterial() {
/* PanoramaSkyMaterial */
void PanoramaSkyMaterial::set_panorama(const Ref<Texture2D> &p_panorama) {
-
panorama = p_panorama;
RS::get_singleton()->material_set_param(_get_material(), "source_panorama", panorama);
}
Ref<Texture2D> PanoramaSkyMaterial::get_panorama() const {
-
return panorama;
}
@@ -300,17 +283,14 @@ bool PanoramaSkyMaterial::_can_do_next_pass() const {
}
Shader::Mode PanoramaSkyMaterial::get_shader_mode() const {
-
return Shader::MODE_SKY;
}
RID PanoramaSkyMaterial::get_shader_rid() const {
-
return shader;
}
void PanoramaSkyMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_panorama", "texture"), &PanoramaSkyMaterial::set_panorama);
ClassDB::bind_method(D_METHOD("get_panorama"), &PanoramaSkyMaterial::get_panorama);
@@ -336,124 +316,122 @@ PanoramaSkyMaterial::~PanoramaSkyMaterial() {
RS::get_singleton()->free(shader);
RS::get_singleton()->material_set_shader(_get_material(), RID());
}
+
//////////////////////////////////
/* PhysicalSkyMaterial */
void PhysicalSkyMaterial::set_rayleigh_coefficient(float p_rayleigh) {
-
rayleigh = p_rayleigh;
RS::get_singleton()->material_set_param(_get_material(), "rayleigh", rayleigh);
}
-float PhysicalSkyMaterial::get_rayleigh_coefficient() const {
+float PhysicalSkyMaterial::get_rayleigh_coefficient() const {
return rayleigh;
}
void PhysicalSkyMaterial::set_rayleigh_color(Color p_rayleigh_color) {
-
rayleigh_color = p_rayleigh_color;
RS::get_singleton()->material_set_param(_get_material(), "rayleigh_color", rayleigh_color);
}
-Color PhysicalSkyMaterial::get_rayleigh_color() const {
+Color PhysicalSkyMaterial::get_rayleigh_color() const {
return rayleigh_color;
}
void PhysicalSkyMaterial::set_mie_coefficient(float p_mie) {
-
mie = p_mie;
RS::get_singleton()->material_set_param(_get_material(), "mie", mie);
}
-float PhysicalSkyMaterial::get_mie_coefficient() const {
+float PhysicalSkyMaterial::get_mie_coefficient() const {
return mie;
}
void PhysicalSkyMaterial::set_mie_eccentricity(float p_eccentricity) {
-
mie_eccentricity = p_eccentricity;
RS::get_singleton()->material_set_param(_get_material(), "mie_eccentricity", mie_eccentricity);
}
-float PhysicalSkyMaterial::get_mie_eccentricity() const {
+float PhysicalSkyMaterial::get_mie_eccentricity() const {
return mie_eccentricity;
}
void PhysicalSkyMaterial::set_mie_color(Color p_mie_color) {
-
mie_color = p_mie_color;
RS::get_singleton()->material_set_param(_get_material(), "mie_color", mie_color);
}
+
Color PhysicalSkyMaterial::get_mie_color() const {
return mie_color;
}
void PhysicalSkyMaterial::set_turbidity(float p_turbidity) {
-
turbidity = p_turbidity;
RS::get_singleton()->material_set_param(_get_material(), "turbidity", turbidity);
}
-float PhysicalSkyMaterial::get_turbidity() const {
+float PhysicalSkyMaterial::get_turbidity() const {
return turbidity;
}
void PhysicalSkyMaterial::set_sun_disk_scale(float p_sun_disk_scale) {
-
sun_disk_scale = p_sun_disk_scale;
RS::get_singleton()->material_set_param(_get_material(), "sun_disk_scale", sun_disk_scale);
}
-float PhysicalSkyMaterial::get_sun_disk_scale() const {
+float PhysicalSkyMaterial::get_sun_disk_scale() const {
return sun_disk_scale;
}
void PhysicalSkyMaterial::set_ground_color(Color p_ground_color) {
-
ground_color = p_ground_color;
RS::get_singleton()->material_set_param(_get_material(), "ground_color", ground_color);
}
-Color PhysicalSkyMaterial::get_ground_color() const {
+Color PhysicalSkyMaterial::get_ground_color() const {
return ground_color;
}
void PhysicalSkyMaterial::set_exposure(float p_exposure) {
-
exposure = p_exposure;
RS::get_singleton()->material_set_param(_get_material(), "exposure", exposure);
}
-float PhysicalSkyMaterial::get_exposure() const {
+float PhysicalSkyMaterial::get_exposure() const {
return exposure;
}
void PhysicalSkyMaterial::set_dither_strength(float p_dither_strength) {
-
dither_strength = p_dither_strength;
RS::get_singleton()->material_set_param(_get_material(), "dither_strength", dither_strength);
}
-float PhysicalSkyMaterial::get_dither_strength() const {
+float PhysicalSkyMaterial::get_dither_strength() const {
return dither_strength;
}
+void PhysicalSkyMaterial::set_night_sky(const Ref<Texture2D> &p_night_sky) {
+ night_sky = p_night_sky;
+ RS::get_singleton()->material_set_param(_get_material(), "night_sky", night_sky);
+}
+
+Ref<Texture2D> PhysicalSkyMaterial::get_night_sky() const {
+ return night_sky;
+}
+
bool PhysicalSkyMaterial::_can_do_next_pass() const {
return false;
}
Shader::Mode PhysicalSkyMaterial::get_shader_mode() const {
-
return Shader::MODE_SKY;
}
RID PhysicalSkyMaterial::get_shader_rid() const {
-
return shader;
}
void PhysicalSkyMaterial::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_rayleigh_coefficient", "rayleigh"), &PhysicalSkyMaterial::set_rayleigh_coefficient);
ClassDB::bind_method(D_METHOD("get_rayleigh_coefficient"), &PhysicalSkyMaterial::get_rayleigh_coefficient);
@@ -484,6 +462,9 @@ void PhysicalSkyMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_dither_strength", "strength"), &PhysicalSkyMaterial::set_dither_strength);
ClassDB::bind_method(D_METHOD("get_dither_strength"), &PhysicalSkyMaterial::get_dither_strength);
+ ClassDB::bind_method(D_METHOD("set_night_sky", "night_sky"), &PhysicalSkyMaterial::set_night_sky);
+ ClassDB::bind_method(D_METHOD("get_night_sky"), &PhysicalSkyMaterial::get_night_sky);
+
ADD_GROUP("Rayleigh", "rayleigh_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rayleigh_coefficient", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_rayleigh_coefficient", "get_rayleigh_coefficient");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "rayleigh_color"), "set_rayleigh_color", "get_rayleigh_color");
@@ -498,6 +479,7 @@ void PhysicalSkyMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_color"), "set_ground_color", "get_ground_color");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "exposure", PROPERTY_HINT_RANGE, "0,128,0.01"), "set_exposure", "get_exposure");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dither_strength", PROPERTY_HINT_RANGE, "0,10,0.01"), "set_dither_strength", "get_dither_strength");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "night_sky", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_night_sky", "get_night_sky");
}
PhysicalSkyMaterial::PhysicalSkyMaterial() {
@@ -515,6 +497,8 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() {
code += "uniform float exposure : hint_range(0, 128) = 0.1;\n";
code += "uniform float dither_strength : hint_range(0, 10) = 1.0;\n\n";
+ code += "uniform sampler2D night_sky : hint_black;";
+
code += "const float PI = 3.141592653589793238462643383279502884197169;\n";
code += "const vec3 UP = vec3( 0.0, 1.0, 0.0 );\n\n";
@@ -578,7 +562,7 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() {
code += "\tfloat sunAngularDiameterCos2 = cos(LIGHT0_SIZE * sun_disk_scale*0.5);\n";
code += "\tfloat sundisk = smoothstep(sunAngularDiameterCos, sunAngularDiameterCos2, cos_theta);\n";
code += "\tvec3 L0 = (sun_energy * 1900.0 * extinction) * sundisk * LIGHT0_COLOR;\n";
- code += "\t// Note: Add nightime here: L0 += night_sky * extinction\n\n";
+ code += "\tL0 += texture(night_sky, SKY_COORDS).xyz * extinction;\n\n";
code += "\tvec3 color = (Lin + L0) * 0.04;\n";
code += "\tCOLOR = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade))));\n";
diff --git a/scene/resources/sky_material.h b/scene/resources/sky_material.h
index 9bd9d7ec8b..e470137d9e 100644
--- a/scene/resources/sky_material.h
+++ b/scene/resources/sky_material.h
@@ -35,7 +35,6 @@
#define SKY_MATERIAL_H
class ProceduralSkyMaterial : public Material {
-
GDCLASS(ProceduralSkyMaterial, Material);
private:
@@ -140,6 +139,7 @@ private:
Color ground_color;
float exposure;
float dither_strength;
+ Ref<Texture2D> night_sky;
protected:
static void _bind_methods();
@@ -176,6 +176,9 @@ public:
void set_dither_strength(float p_dither_strength);
float get_dither_strength() const;
+ void set_night_sky(const Ref<Texture2D> &p_night_sky);
+ Ref<Texture2D> get_night_sky() const;
+
virtual Shader::Mode get_shader_mode() const;
RID get_shader_rid() const;
diff --git a/scene/resources/sphere_shape_3d.cpp b/scene/resources/sphere_shape_3d.cpp
index 153db4c291..d24998ff18 100644
--- a/scene/resources/sphere_shape_3d.cpp
+++ b/scene/resources/sphere_shape_3d.cpp
@@ -32,13 +32,11 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> SphereShape3D::get_debug_mesh_lines() {
-
float r = get_radius();
Vector<Vector3> points;
for (int i = 0; i <= 360; i++) {
-
float ra = Math::deg2rad((float)i);
float rb = Math::deg2rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
@@ -60,13 +58,11 @@ real_t SphereShape3D::get_enclosing_radius() const {
}
void SphereShape3D::_update_shape() {
-
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), radius);
Shape3D::_update_shape();
}
void SphereShape3D::set_radius(float p_radius) {
-
radius = p_radius;
_update_shape();
notify_change_to_owners();
@@ -74,12 +70,10 @@ void SphereShape3D::set_radius(float p_radius) {
}
float SphereShape3D::get_radius() const {
-
return radius;
}
void SphereShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_radius", "radius"), &SphereShape3D::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &SphereShape3D::get_radius);
@@ -88,6 +82,5 @@ void SphereShape3D::_bind_methods() {
SphereShape3D::SphereShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_SPHERE)) {
-
set_radius(1.0);
}
diff --git a/scene/resources/sphere_shape_3d.h b/scene/resources/sphere_shape_3d.h
index 3ed50cfe83..ee31bb615c 100644
--- a/scene/resources/sphere_shape_3d.h
+++ b/scene/resources/sphere_shape_3d.h
@@ -34,7 +34,6 @@
#include "scene/resources/shape_3d.h"
class SphereShape3D : public Shape3D {
-
GDCLASS(SphereShape3D, Shape3D);
float radius;
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 56fb5d441f..eb65f10ec9 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -35,32 +35,30 @@
#include <limits.h>
bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
-
return true;
}
void StyleBox::set_default_margin(Margin p_margin, float p_value) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
margin[p_margin] = p_value;
emit_changed();
}
-float StyleBox::get_default_margin(Margin p_margin) const {
+float StyleBox::get_default_margin(Margin p_margin) const {
ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0);
return margin[p_margin];
}
float StyleBox::get_margin(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0);
- if (margin[p_margin] < 0)
+ if (margin[p_margin] < 0) {
return get_style_margin(p_margin);
- else
+ } else {
return margin[p_margin];
+ }
}
CanvasItem *StyleBox::get_current_item_drawn() const {
@@ -68,17 +66,14 @@ CanvasItem *StyleBox::get_current_item_drawn() const {
}
Size2 StyleBox::get_minimum_size() const {
-
return Size2(get_margin(MARGIN_LEFT) + get_margin(MARGIN_RIGHT), get_margin(MARGIN_TOP) + get_margin(MARGIN_BOTTOM));
}
Point2 StyleBox::get_offset() const {
-
return Point2(get_margin(MARGIN_LEFT), get_margin(MARGIN_TOP));
}
Size2 StyleBox::get_center_size() const {
-
return Size2();
}
@@ -87,7 +82,6 @@ Rect2 StyleBox::get_draw_rect(const Rect2 &p_rect) const {
}
void StyleBox::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("test_mask", "point", "rect"), &StyleBox::test_mask);
ClassDB::bind_method(D_METHOD("set_default_margin", "margin", "offset"), &StyleBox::set_default_margin);
@@ -112,17 +106,15 @@ void StyleBox::_bind_methods() {
}
StyleBox::StyleBox() {
-
for (int i = 0; i < 4; i++) {
-
margin[i] = -1;
}
}
void StyleBoxTexture::set_texture(Ref<Texture2D> p_texture) {
-
- if (texture == p_texture)
+ if (texture == p_texture) {
return;
+ }
texture = p_texture;
if (p_texture.is_null()) {
region_rect = Rect2(0, 0, 0, 0);
@@ -135,25 +127,22 @@ void StyleBoxTexture::set_texture(Ref<Texture2D> p_texture) {
}
Ref<Texture2D> StyleBoxTexture::get_texture() const {
-
return texture;
}
void StyleBoxTexture::set_normal_map(Ref<Texture2D> p_normal_map) {
-
- if (normal_map == p_normal_map)
+ if (normal_map == p_normal_map) {
return;
+ }
normal_map = p_normal_map;
emit_changed();
}
Ref<Texture2D> StyleBoxTexture::get_normal_map() const {
-
return normal_map;
}
void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
-
ERR_FAIL_INDEX((int)p_margin, 4);
margin[p_margin] = p_size;
@@ -166,15 +155,14 @@ void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
};
_change_notify(margin_prop[p_margin]);
}
-float StyleBoxTexture::get_margin_size(Margin p_margin) const {
+float StyleBoxTexture::get_margin_size(Margin p_margin) const {
ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0);
return margin[p_margin];
}
float StyleBoxTexture::get_style_margin(Margin p_margin) const {
-
ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0);
return margin[p_margin];
@@ -185,8 +173,9 @@ Rect2 StyleBoxTexture::get_draw_rect(const Rect2 &p_rect) const {
}
void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
- if (texture.is_null())
+ if (texture.is_null()) {
return;
+ }
Rect2 rect = p_rect;
Rect2 src_rect = region_rect;
@@ -199,33 +188,31 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
rect.size.y += expand_margin[MARGIN_TOP] + expand_margin[MARGIN_BOTTOM];
RID normal_rid;
- if (normal_map.is_valid())
+ if (normal_map.is_valid()) {
normal_rid = normal_map->get_rid();
+ }
RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid);
}
void StyleBoxTexture::set_draw_center(bool p_enabled) {
-
draw_center = p_enabled;
emit_changed();
}
bool StyleBoxTexture::is_draw_center_enabled() const {
-
return draw_center;
}
Size2 StyleBoxTexture::get_center_size() const {
-
- if (texture.is_null())
+ if (texture.is_null()) {
return Size2();
+ }
return region_rect.size - get_minimum_size();
}
void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_size) {
-
ERR_FAIL_INDEX((int)p_expand_margin, 4);
expand_margin[p_expand_margin] = p_size;
emit_changed();
@@ -241,70 +228,62 @@ void StyleBoxTexture::set_expand_margin_size_individual(float p_left, float p_to
void StyleBoxTexture::set_expand_margin_size_all(float p_expand_margin_size) {
for (int i = 0; i < 4; i++) {
-
expand_margin[i] = p_expand_margin_size;
}
emit_changed();
}
float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const {
-
ERR_FAIL_INDEX_V((int)p_expand_margin, 4, 0);
return expand_margin[p_expand_margin];
}
void StyleBoxTexture::set_region_rect(const Rect2 &p_region_rect) {
-
- if (region_rect == p_region_rect)
+ if (region_rect == p_region_rect) {
return;
+ }
region_rect = p_region_rect;
emit_changed();
}
Rect2 StyleBoxTexture::get_region_rect() const {
-
return region_rect;
}
void StyleBoxTexture::set_h_axis_stretch_mode(AxisStretchMode p_mode) {
-
ERR_FAIL_INDEX((int)p_mode, 3);
axis_h = p_mode;
emit_changed();
}
StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_h_axis_stretch_mode() const {
-
return axis_h;
}
void StyleBoxTexture::set_v_axis_stretch_mode(AxisStretchMode p_mode) {
-
ERR_FAIL_INDEX((int)p_mode, 3);
axis_v = p_mode;
emit_changed();
}
StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_v_axis_stretch_mode() const {
-
return axis_v;
}
void StyleBoxTexture::set_modulate(const Color &p_modulate) {
- if (modulate == p_modulate)
+ if (modulate == p_modulate) {
return;
+ }
modulate = p_modulate;
emit_changed();
}
Color StyleBoxTexture::get_modulate() const {
-
return modulate;
}
void StyleBoxTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &StyleBoxTexture::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &StyleBoxTexture::get_texture);
@@ -362,7 +341,6 @@ void StyleBoxTexture::_bind_methods() {
}
StyleBoxTexture::StyleBoxTexture() {
-
for (int i = 0; i < 4; i++) {
margin[i] = 0;
expand_margin[i] = 0;
@@ -373,29 +351,27 @@ StyleBoxTexture::StyleBoxTexture() {
axis_h = AXIS_STRETCH_MODE_STRETCH;
axis_v = AXIS_STRETCH_MODE_STRETCH;
}
+
StyleBoxTexture::~StyleBoxTexture() {
}
////////////////
void StyleBoxFlat::set_bg_color(const Color &p_color) {
-
bg_color = p_color;
emit_changed();
}
Color StyleBoxFlat::get_bg_color() const {
-
return bg_color;
}
void StyleBoxFlat::set_border_color(const Color &p_color) {
-
border_color = p_color;
emit_changed();
}
-Color StyleBoxFlat::get_border_color() const {
+Color StyleBoxFlat::get_border_color() const {
return border_color;
}
@@ -406,8 +382,8 @@ void StyleBoxFlat::set_border_width_all(int p_size) {
border_width[3] = p_size;
emit_changed();
}
-int StyleBoxFlat::get_border_width_min() const {
+int StyleBoxFlat::get_border_width_min() const {
return MIN(MIN(border_width[0], border_width[1]), MIN(border_width[2], border_width[3]));
}
@@ -423,23 +399,22 @@ int StyleBoxFlat::get_border_width(Margin p_margin) const {
}
void StyleBoxFlat::set_border_blend(bool p_blend) {
-
blend_border = p_blend;
emit_changed();
}
-bool StyleBoxFlat::get_border_blend() const {
+bool StyleBoxFlat::get_border_blend() const {
return blend_border;
}
void StyleBoxFlat::set_corner_radius_all(int radius) {
-
for (int i = 0; i < 4; i++) {
corner_radius[i] = radius;
}
emit_changed();
}
+
void StyleBoxFlat::set_corner_radius_individual(const int radius_top_left, const int radius_top_right, const int radius_botton_right, const int radius_bottom_left) {
corner_radius[0] = radius_top_left;
corner_radius[1] = radius_top_right;
@@ -448,6 +423,7 @@ void StyleBoxFlat::set_corner_radius_individual(const int radius_top_left, const
emit_changed();
}
+
int StyleBoxFlat::get_corner_radius_min() const {
int smallest = corner_radius[0];
for (int i = 1; i < 4; i++) {
@@ -459,19 +435,17 @@ int StyleBoxFlat::get_corner_radius_min() const {
}
void StyleBoxFlat::set_corner_radius(const Corner p_corner, const int radius) {
-
ERR_FAIL_INDEX((int)p_corner, 4);
corner_radius[p_corner] = radius;
emit_changed();
}
-int StyleBoxFlat::get_corner_radius(const Corner p_corner) const {
+int StyleBoxFlat::get_corner_radius(const Corner p_corner) const {
ERR_FAIL_INDEX_V((int)p_corner, 4, 0);
return corner_radius[p_corner];
}
void StyleBoxFlat::set_expand_margin_size(Margin p_expand_margin, float p_size) {
-
ERR_FAIL_INDEX((int)p_expand_margin, 4);
expand_margin[p_expand_margin] = p_size;
emit_changed();
@@ -487,54 +461,49 @@ void StyleBoxFlat::set_expand_margin_size_individual(float p_left, float p_top,
void StyleBoxFlat::set_expand_margin_size_all(float p_expand_margin_size) {
for (int i = 0; i < 4; i++) {
-
expand_margin[i] = p_expand_margin_size;
}
emit_changed();
}
float StyleBoxFlat::get_expand_margin_size(Margin p_expand_margin) const {
-
ERR_FAIL_INDEX_V((int)p_expand_margin, 4, 0.0);
return expand_margin[p_expand_margin];
}
-void StyleBoxFlat::set_draw_center(bool p_enabled) {
+void StyleBoxFlat::set_draw_center(bool p_enabled) {
draw_center = p_enabled;
emit_changed();
}
-bool StyleBoxFlat::is_draw_center_enabled() const {
+bool StyleBoxFlat::is_draw_center_enabled() const {
return draw_center;
}
void StyleBoxFlat::set_shadow_color(const Color &p_color) {
-
shadow_color = p_color;
emit_changed();
}
-Color StyleBoxFlat::get_shadow_color() const {
+Color StyleBoxFlat::get_shadow_color() const {
return shadow_color;
}
void StyleBoxFlat::set_shadow_size(const int &p_size) {
-
shadow_size = p_size;
emit_changed();
}
-int StyleBoxFlat::get_shadow_size() const {
+int StyleBoxFlat::get_shadow_size() const {
return shadow_size;
}
void StyleBoxFlat::set_shadow_offset(const Point2 &p_offset) {
-
shadow_offset = p_offset;
emit_changed();
}
-Point2 StyleBoxFlat::get_shadow_offset() const {
+Point2 StyleBoxFlat::get_shadow_offset() const {
return shadow_offset;
}
@@ -542,6 +511,7 @@ void StyleBoxFlat::set_anti_aliased(const bool &p_anti_aliased) {
anti_aliased = p_anti_aliased;
emit_changed();
}
+
bool StyleBoxFlat::is_anti_aliased() const {
return anti_aliased;
}
@@ -550,6 +520,7 @@ void StyleBoxFlat::set_aa_size(const int &p_aa_size) {
aa_size = CLAMP(p_aa_size, 1, 5);
emit_changed();
}
+
int StyleBoxFlat::get_aa_size() const {
return aa_size;
}
@@ -558,12 +529,12 @@ void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) {
corner_detail = CLAMP(p_corner_detail, 1, 20);
emit_changed();
}
+
int StyleBoxFlat::get_corner_detail() const {
return corner_detail;
}
Size2 StyleBoxFlat::get_center_size() const {
-
return Size2();
}
@@ -593,7 +564,6 @@ inline void set_inner_corner_radius(const Rect2 style_rect, const Rect2 inner_re
inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color> &colors, const Rect2 &style_rect, const int corner_radius[4],
const Rect2 &ring_rect, const Rect2 &inner_rect, const Color &inner_color, const Color &outer_color, const int corner_detail, const bool fill_center = false) {
-
int vert_offset = verts.size();
if (!vert_offset) {
vert_offset = 0;
@@ -705,7 +675,6 @@ Rect2 StyleBoxFlat::get_draw_rect(const Rect2 &p_rect) const {
}
void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
-
//PREPARATIONS
bool draw_border = (border_width[0] > 0) || (border_width[1] > 0) || (border_width[2] > 0) || (border_width[3] > 0);
bool draw_shadow = (shadow_size > 0);
@@ -861,8 +830,8 @@ float StyleBoxFlat::get_style_margin(Margin p_margin) const {
ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0);
return border_width[p_margin];
}
-void StyleBoxFlat::_bind_methods() {
+void StyleBoxFlat::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &StyleBoxFlat::set_bg_color);
ClassDB::bind_method(D_METHOD("get_bg_color"), &StyleBoxFlat::get_bg_color);
@@ -950,7 +919,6 @@ void StyleBoxFlat::_bind_methods() {
}
StyleBoxFlat::StyleBoxFlat() {
-
bg_color = Color(0.6, 0.6, 0.6);
shadow_color = Color(0, 0, 0, 0.6);
border_color = Color(0.8, 0.8, 0.8);
@@ -979,6 +947,7 @@ StyleBoxFlat::StyleBoxFlat() {
corner_radius[2] = 0;
corner_radius[3] = 0;
}
+
StyleBoxFlat::~StyleBoxFlat() {
}
@@ -986,6 +955,7 @@ void StyleBoxLine::set_color(const Color &p_color) {
color = p_color;
emit_changed();
}
+
Color StyleBoxLine::get_color() const {
return color;
}
@@ -994,6 +964,7 @@ void StyleBoxLine::set_thickness(int p_thickness) {
thickness = p_thickness;
emit_changed();
}
+
int StyleBoxLine::get_thickness() const {
return thickness;
}
@@ -1002,6 +973,7 @@ void StyleBoxLine::set_vertical(bool p_vertical) {
vertical = p_vertical;
emit_changed();
}
+
bool StyleBoxLine::is_vertical() const {
return vertical;
}
@@ -1010,6 +982,7 @@ void StyleBoxLine::set_grow_end(float p_grow_end) {
grow_end = p_grow_end;
emit_changed();
}
+
float StyleBoxLine::get_grow_end() const {
return grow_end;
}
@@ -1018,12 +991,12 @@ void StyleBoxLine::set_grow_begin(float p_grow_begin) {
grow_begin = p_grow_begin;
emit_changed();
}
+
float StyleBoxLine::get_grow_begin() const {
return grow_begin;
}
void StyleBoxLine::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_color", "color"), &StyleBoxLine::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &StyleBoxLine::get_color);
ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &StyleBoxLine::set_thickness);
@@ -1041,10 +1014,12 @@ void StyleBoxLine::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "thickness", PROPERTY_HINT_RANGE, "0,10"), "set_thickness", "get_thickness");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertical"), "set_vertical", "is_vertical");
}
+
float StyleBoxLine::get_style_margin(Margin p_margin) const {
ERR_FAIL_INDEX_V((int)p_margin, 4, thickness);
return thickness;
}
+
Size2 StyleBoxLine::get_center_size() const {
return Size2();
}
@@ -1073,4 +1048,5 @@ StyleBoxLine::StyleBoxLine() {
color = Color(0.0, 0.0, 0.0);
vertical = false;
}
+
StyleBoxLine::~StyleBoxLine() {}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index f19b93d00d..99adbe589a 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -38,7 +38,6 @@
class CanvasItem;
class StyleBox : public Resource {
-
GDCLASS(StyleBox, Resource);
RES_BASE_EXTENSION("stylebox");
OBJ_SAVE_TYPE(StyleBox);
@@ -68,7 +67,6 @@ public:
};
class StyleBoxEmpty : public StyleBox {
-
GDCLASS(StyleBoxEmpty, StyleBox);
virtual float get_style_margin(Margin p_margin) const { return 0; }
@@ -78,7 +76,6 @@ public:
};
class StyleBoxTexture : public StyleBox {
-
GDCLASS(StyleBoxTexture, StyleBox);
public:
@@ -144,7 +141,6 @@ public:
VARIANT_ENUM_CAST(StyleBoxTexture::AxisStretchMode)
class StyleBoxFlat : public StyleBox {
-
GDCLASS(StyleBoxFlat, StyleBox);
Color bg_color;
@@ -238,7 +234,6 @@ public:
// just used to draw lines.
class StyleBoxLine : public StyleBox {
-
GDCLASS(StyleBoxLine, StyleBox);
Color color;
int thickness;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 4b392e23b7..1a2dcc84bb 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -36,43 +36,50 @@
#define EQ_VERTEX_DIST 0.00001
bool SurfaceTool::Vertex::operator==(const Vertex &p_vertex) const {
-
- if (vertex != p_vertex.vertex)
+ if (vertex != p_vertex.vertex) {
return false;
+ }
- if (uv != p_vertex.uv)
+ if (uv != p_vertex.uv) {
return false;
+ }
- if (uv2 != p_vertex.uv2)
+ if (uv2 != p_vertex.uv2) {
return false;
+ }
- if (normal != p_vertex.normal)
+ if (normal != p_vertex.normal) {
return false;
+ }
- if (binormal != p_vertex.binormal)
+ if (binormal != p_vertex.binormal) {
return false;
+ }
- if (color != p_vertex.color)
+ if (color != p_vertex.color) {
return false;
+ }
- if (bones.size() != p_vertex.bones.size())
+ if (bones.size() != p_vertex.bones.size()) {
return false;
+ }
for (int i = 0; i < bones.size(); i++) {
- if (bones[i] != p_vertex.bones[i])
+ if (bones[i] != p_vertex.bones[i]) {
return false;
+ }
}
for (int i = 0; i < weights.size(); i++) {
- if (weights[i] != p_vertex.weights[i])
+ if (weights[i] != p_vertex.weights[i]) {
return false;
+ }
}
return true;
}
uint32_t SurfaceTool::VertexHasher::hash(const Vertex &p_vtx) {
-
uint32_t h = hash_djb2_buffer((const uint8_t *)&p_vtx.vertex, sizeof(real_t) * 3);
h = hash_djb2_buffer((const uint8_t *)&p_vtx.normal, sizeof(real_t) * 3, h);
h = hash_djb2_buffer((const uint8_t *)&p_vtx.binormal, sizeof(real_t) * 3, h);
@@ -86,7 +93,6 @@ uint32_t SurfaceTool::VertexHasher::hash(const Vertex &p_vtx) {
}
void SurfaceTool::begin(Mesh::PrimitiveType p_primitive) {
-
clear();
primitive = p_primitive;
@@ -95,7 +101,6 @@ void SurfaceTool::begin(Mesh::PrimitiveType p_primitive) {
}
void SurfaceTool::add_vertex(const Vector3 &p_vertex) {
-
ERR_FAIL_COND(!begun);
Vertex vtx;
@@ -159,8 +164,8 @@ void SurfaceTool::add_vertex(const Vector3 &p_vertex) {
format |= Mesh::ARRAY_FORMAT_VERTEX;
}
-void SurfaceTool::add_color(Color p_color) {
+void SurfaceTool::add_color(Color p_color) {
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_COLOR));
@@ -168,8 +173,8 @@ void SurfaceTool::add_color(Color p_color) {
format |= Mesh::ARRAY_FORMAT_COLOR;
last_color = p_color;
}
-void SurfaceTool::add_normal(const Vector3 &p_normal) {
+void SurfaceTool::add_normal(const Vector3 &p_normal) {
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_NORMAL));
@@ -179,7 +184,6 @@ void SurfaceTool::add_normal(const Vector3 &p_normal) {
}
void SurfaceTool::add_tangent(const Plane &p_tangent) {
-
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_TANGENT));
@@ -188,7 +192,6 @@ void SurfaceTool::add_tangent(const Plane &p_tangent) {
}
void SurfaceTool::add_uv(const Vector2 &p_uv) {
-
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_TEX_UV));
@@ -197,7 +200,6 @@ void SurfaceTool::add_uv(const Vector2 &p_uv) {
}
void SurfaceTool::add_uv2(const Vector2 &p_uv2) {
-
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_TEX_UV2));
@@ -206,7 +208,6 @@ void SurfaceTool::add_uv2(const Vector2 &p_uv2) {
}
void SurfaceTool::add_bones(const Vector<int> &p_bones) {
-
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_BONES));
@@ -215,7 +216,6 @@ void SurfaceTool::add_bones(const Vector<int> &p_bones) {
}
void SurfaceTool::add_weights(const Vector<float> &p_weights) {
-
ERR_FAIL_COND(!begun);
ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_WEIGHTS));
@@ -224,12 +224,10 @@ void SurfaceTool::add_weights(const Vector<float> &p_weights) {
}
void SurfaceTool::add_smooth_group(bool p_smooth) {
-
ERR_FAIL_COND(!begun);
if (index_array.size()) {
smooth_groups[index_array.size()] = p_smooth;
} else {
-
smooth_groups[vertex_array.size()] = p_smooth;
}
}
@@ -264,7 +262,6 @@ void SurfaceTool::add_triangle_fan(const Vector<Vector3> &p_vertices, const Vect
}
void SurfaceTool::add_index(int p_index) {
-
ERR_FAIL_COND(!begun);
format |= Mesh::ARRAY_FORMAT_INDEX;
@@ -272,29 +269,25 @@ void SurfaceTool::add_index(int p_index) {
}
Array SurfaceTool::commit_to_arrays() {
-
int varr_len = vertex_array.size();
Array a;
a.resize(Mesh::ARRAY_MAX);
for (int i = 0; i < Mesh::ARRAY_MAX; i++) {
-
- if (!(format & (1 << i)))
+ if (!(format & (1 << i))) {
continue; //not in format
+ }
switch (i) {
-
case Mesh::ARRAY_VERTEX:
case Mesh::ARRAY_NORMAL: {
-
Vector<Vector3> array;
array.resize(varr_len);
Vector3 *w = array.ptrw();
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx++) {
-
const Vertex &v = E->get();
switch (i) {
@@ -313,18 +306,15 @@ Array SurfaceTool::commit_to_arrays() {
case Mesh::ARRAY_TEX_UV:
case Mesh::ARRAY_TEX_UV2: {
-
Vector<Vector2> array;
array.resize(varr_len);
Vector2 *w = array.ptrw();
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx++) {
-
const Vertex &v = E->get();
switch (i) {
-
case Mesh::ARRAY_TEX_UV: {
w[idx] = v.uv;
} break;
@@ -337,14 +327,12 @@ Array SurfaceTool::commit_to_arrays() {
a[i] = array;
} break;
case Mesh::ARRAY_TANGENT: {
-
Vector<float> array;
array.resize(varr_len * 4);
float *w = array.ptrw();
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx += 4) {
-
const Vertex &v = E->get();
w[idx + 0] = v.tangent.x;
@@ -360,14 +348,12 @@ Array SurfaceTool::commit_to_arrays() {
} break;
case Mesh::ARRAY_COLOR: {
-
Vector<Color> array;
array.resize(varr_len);
Color *w = array.ptrw();
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx++) {
-
const Vertex &v = E->get();
w[idx] = v.color;
}
@@ -375,14 +361,12 @@ Array SurfaceTool::commit_to_arrays() {
a[i] = array;
} break;
case Mesh::ARRAY_BONES: {
-
Vector<int> array;
array.resize(varr_len * 4);
int *w = array.ptrw();
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx += 4) {
-
const Vertex &v = E->get();
ERR_CONTINUE(v.bones.size() != 4);
@@ -396,19 +380,16 @@ Array SurfaceTool::commit_to_arrays() {
} break;
case Mesh::ARRAY_WEIGHTS: {
-
Vector<float> array;
array.resize(varr_len * 4);
float *w = array.ptrw();
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx += 4) {
-
const Vertex &v = E->get();
ERR_CONTINUE(v.weights.size() != 4);
for (int j = 0; j < 4; j++) {
-
w[idx + j] = v.weights[j];
}
}
@@ -417,7 +398,6 @@ Array SurfaceTool::commit_to_arrays() {
} break;
case Mesh::ARRAY_INDEX: {
-
ERR_CONTINUE(index_array.size() == 0);
Vector<int> array;
@@ -426,7 +406,6 @@ Array SurfaceTool::commit_to_arrays() {
int idx = 0;
for (List<int>::Element *E = index_array.front(); E; E = E->next(), idx++) {
-
w[idx] = E->get();
}
@@ -442,17 +421,18 @@ Array SurfaceTool::commit_to_arrays() {
}
Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint32_t p_flags) {
-
Ref<ArrayMesh> mesh;
- if (p_existing.is_valid())
+ if (p_existing.is_valid()) {
mesh = p_existing;
- else
+ } else {
mesh.instance();
+ }
int varr_len = vertex_array.size();
- if (varr_len == 0)
+ if (varr_len == 0) {
return mesh;
+ }
int surface = mesh->get_surface_count();
@@ -460,22 +440,22 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint32_t p_
mesh->add_surface_from_arrays(primitive, a, Array(), Dictionary(), p_flags);
- if (material.is_valid())
+ if (material.is_valid()) {
mesh->surface_set_material(surface, material);
+ }
return mesh;
}
void SurfaceTool::index() {
-
- if (index_array.size())
+ if (index_array.size()) {
return; //already indexed
+ }
HashMap<Vertex, int, VertexHasher> indices;
List<Vertex> new_vertices;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next()) {
-
int *idxptr = indices.getptr(E->get());
int idx;
if (!idxptr) {
@@ -496,19 +476,17 @@ void SurfaceTool::index() {
}
void SurfaceTool::deindex() {
-
- if (index_array.size() == 0)
+ if (index_array.size() == 0) {
return; //nothing to deindex
+ }
Vector<Vertex> varr;
varr.resize(vertex_array.size());
int idx = 0;
for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next()) {
-
varr.write[idx++] = E->get();
}
vertex_array.clear();
for (List<int>::Element *E = index_array.front(); E; E = E->next()) {
-
ERR_FAIL_INDEX(E->get(), varr.size());
vertex_array.push_back(varr[E->get()]);
}
@@ -517,14 +495,12 @@ void SurfaceTool::deindex() {
}
void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
-
Array arr = p_existing->surface_get_arrays(p_surface);
ERR_FAIL_COND(arr.size() != RS::ARRAY_MAX);
_create_list_from_arrays(arr, r_vertex, r_index, lformat);
}
Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_arrays(const Array &p_arrays) {
-
Vector<SurfaceTool::Vertex> ret;
Vector<Vector3> varr = p_arrays[RS::ARRAY_VERTEX];
@@ -537,8 +513,9 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
Vector<float> warr = p_arrays[RS::ARRAY_WEIGHTS];
int vc = varr.size();
- if (vc == 0)
+ if (vc == 0) {
return ret;
+ }
int lformat = 0;
if (varr.size()) {
@@ -568,21 +545,26 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
for (int i = 0; i < vc; i++) {
Vertex v;
- if (lformat & RS::ARRAY_FORMAT_VERTEX)
+ if (lformat & RS::ARRAY_FORMAT_VERTEX) {
v.vertex = varr[i];
- if (lformat & RS::ARRAY_FORMAT_NORMAL)
+ }
+ if (lformat & RS::ARRAY_FORMAT_NORMAL) {
v.normal = narr[i];
+ }
if (lformat & RS::ARRAY_FORMAT_TANGENT) {
Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
v.tangent = p.normal;
v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
}
- if (lformat & RS::ARRAY_FORMAT_COLOR)
+ if (lformat & RS::ARRAY_FORMAT_COLOR) {
v.color = carr[i];
- if (lformat & RS::ARRAY_FORMAT_TEX_UV)
+ }
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV) {
v.uv = uvarr[i];
- if (lformat & RS::ARRAY_FORMAT_TEX_UV2)
+ }
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV2) {
v.uv2 = uv2arr[i];
+ }
if (lformat & RS::ARRAY_FORMAT_BONES) {
Vector<int> b;
b.resize(4);
@@ -609,7 +591,6 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array
}
void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
-
Vector<Vector3> varr = arr[RS::ARRAY_VERTEX];
Vector<Vector3> narr = arr[RS::ARRAY_NORMAL];
Vector<float> tarr = arr[RS::ARRAY_TANGENT];
@@ -620,8 +601,9 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
Vector<float> warr = arr[RS::ARRAY_WEIGHTS];
int vc = varr.size();
- if (vc == 0)
+ if (vc == 0) {
return;
+ }
lformat = 0;
if (varr.size()) {
@@ -651,21 +633,26 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
for (int i = 0; i < vc; i++) {
Vertex v;
- if (lformat & RS::ARRAY_FORMAT_VERTEX)
+ if (lformat & RS::ARRAY_FORMAT_VERTEX) {
v.vertex = varr[i];
- if (lformat & RS::ARRAY_FORMAT_NORMAL)
+ }
+ if (lformat & RS::ARRAY_FORMAT_NORMAL) {
v.normal = narr[i];
+ }
if (lformat & RS::ARRAY_FORMAT_TANGENT) {
Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
v.tangent = p.normal;
v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
}
- if (lformat & RS::ARRAY_FORMAT_COLOR)
+ if (lformat & RS::ARRAY_FORMAT_COLOR) {
v.color = carr[i];
- if (lformat & RS::ARRAY_FORMAT_TEX_UV)
+ }
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV) {
v.uv = uvarr[i];
- if (lformat & RS::ARRAY_FORMAT_TEX_UV2)
+ }
+ if (lformat & RS::ARRAY_FORMAT_TEX_UV2) {
v.uv2 = uv2arr[i];
+ }
if (lformat & RS::ARRAY_FORMAT_BONES) {
Vector<int> b;
b.resize(4);
@@ -693,7 +680,6 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
Vector<int> idx = arr[RS::ARRAY_INDEX];
int is = idx.size();
if (is) {
-
lformat |= RS::ARRAY_FORMAT_INDEX;
const int *iarr = idx.ptr();
for (int i = 0; i < is; i++) {
@@ -703,14 +689,12 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li
}
void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) {
-
clear();
primitive = Mesh::PRIMITIVE_TRIANGLES;
_create_list_from_arrays(p_arrays, &vertex_array, &index_array, format);
}
void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) {
-
clear();
primitive = p_existing->surface_get_primitive_type(p_surface);
_create_list(p_existing, p_surface, &vertex_array, &index_array, format);
@@ -738,7 +722,6 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur
}
void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform) {
-
if (vertex_array.size() == 0) {
primitive = p_existing->surface_get_primitive_type(p_surface);
format = 0;
@@ -752,7 +735,6 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const
int vfrom = vertex_array.size();
for (List<Vertex>::Element *E = nvertices.front(); E; E = E->next()) {
-
Vertex v = E->get();
v.vertex = p_xform.xform(v.vertex);
if (nformat & RS::ARRAY_FORMAT_NORMAL) {
@@ -767,7 +749,6 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const
}
for (List<int>::Element *E = nindices.front(); E; E = E->next()) {
-
int dst_index = E->get() + vfrom;
index_array.push_back(dst_index);
}
@@ -785,7 +766,6 @@ struct TangentGenerationContextUserData {
} // namespace
int SurfaceTool::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
-
TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
if (triangle_data.indices.size() > 0) {
@@ -794,12 +774,12 @@ int SurfaceTool::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
return triangle_data.vertices.size() / 3;
}
}
-int SurfaceTool::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
+int SurfaceTool::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
return 3; //always 3
}
-void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
+void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
Vector3 v;
if (triangle_data.indices.size() > 0) {
@@ -817,7 +797,6 @@ void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvP
}
void SurfaceTool::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
-
TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
Vector3 v;
if (triangle_data.indices.size() > 0) {
@@ -833,8 +812,8 @@ void SurfaceTool::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNor
fvNormOut[1] = v.y;
fvNormOut[2] = v.z;
}
-void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
+void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
Vector2 v;
if (triangle_data.indices.size() > 0) {
@@ -852,7 +831,6 @@ void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvT
void SurfaceTool::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) {
-
TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData);
Vertex *vtx = nullptr;
if (triangle_data.indices.size() > 0) {
@@ -871,7 +849,6 @@ void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, cons
}
void SurfaceTool::generate_tangents() {
-
ERR_FAIL_COND(!(format & Mesh::ARRAY_FORMAT_TEX_UV));
ERR_FAIL_COND(!(format & Mesh::ARRAY_FORMAT_NORMAL));
@@ -909,7 +886,6 @@ void SurfaceTool::generate_tangents() {
}
void SurfaceTool::generate_normals(bool p_flip) {
-
ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES);
bool was_indexed = index_array.size();
@@ -920,12 +896,12 @@ void SurfaceTool::generate_normals(bool p_flip) {
int count = 0;
bool smooth = false;
- if (smooth_groups.has(0))
+ if (smooth_groups.has(0)) {
smooth = smooth_groups[0];
+ }
List<Vertex>::Element *B = vertex_array.front();
for (List<Vertex>::Element *E = B; E;) {
-
List<Vertex>::Element *v[3];
v[0] = E;
v[1] = v[0]->next();
@@ -935,15 +911,14 @@ void SurfaceTool::generate_normals(bool p_flip) {
E = v[2]->next();
Vector3 normal;
- if (!p_flip)
+ if (!p_flip) {
normal = Plane(v[0]->get().vertex, v[1]->get().vertex, v[2]->get().vertex).normal;
- else
+ } else {
normal = Plane(v[2]->get().vertex, v[1]->get().vertex, v[0]->get().vertex).normal;
+ }
if (smooth) {
-
for (int i = 0; i < 3; i++) {
-
Vector3 *lv = vertex_hash.getptr(v[i]->get());
if (!lv) {
vertex_hash.set(v[i]->get(), normal);
@@ -952,20 +927,15 @@ void SurfaceTool::generate_normals(bool p_flip) {
}
}
} else {
-
for (int i = 0; i < 3; i++) {
-
v[i]->get().normal = normal;
}
}
count += 3;
if (smooth_groups.has(count) || !E) {
-
if (vertex_hash.size()) {
-
while (B != E) {
-
Vector3 *lv = vertex_hash.getptr(B->get());
if (lv) {
B->get().normal = lv->normalized();
@@ -994,12 +964,10 @@ void SurfaceTool::generate_normals(bool p_flip) {
}
void SurfaceTool::set_material(const Ref<Material> &p_material) {
-
material = p_material;
}
void SurfaceTool::clear() {
-
begun = false;
primitive = Mesh::PRIMITIVE_LINES;
format = 0;
@@ -1012,7 +980,6 @@ void SurfaceTool::clear() {
}
void SurfaceTool::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("begin", "primitive"), &SurfaceTool::begin);
ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &SurfaceTool::add_vertex);
@@ -1046,7 +1013,6 @@ void SurfaceTool::_bind_methods() {
}
SurfaceTool::SurfaceTool() {
-
first = false;
begun = false;
primitive = Mesh::PRIMITIVE_LINES;
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index 89034f656d..d7b255e695 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -36,12 +36,10 @@
#include "thirdparty/misc/mikktspace.h"
class SurfaceTool : public Reference {
-
GDCLASS(SurfaceTool, Reference);
public:
struct Vertex {
-
Vector3 vertex;
Color color;
Vector3 normal; // normal, binormal, tangent
diff --git a/scene/resources/text_file.cpp b/scene/resources/text_file.cpp
index e291dcb67e..e3bd5ce0ae 100644
--- a/scene/resources/text_file.cpp
+++ b/scene/resources/text_file.cpp
@@ -49,7 +49,6 @@ void TextFile::reload_from_file() {
}
Error TextFile::load_text(const String &p_path) {
-
Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
diff --git a/scene/resources/text_file.h b/scene/resources/text_file.h
index 666c088d04..356b070ea0 100644
--- a/scene/resources/text_file.h
+++ b/scene/resources/text_file.h
@@ -35,7 +35,6 @@
#include "core/io/resource_saver.h"
class TextFile : public Resource {
-
GDCLASS(TextFile, Resource);
private:
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index b212bba826..331cffed5d 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -39,7 +39,6 @@
#include "servers/camera/camera_feed.h"
Size2 Texture2D::get_size() const {
-
return Size2(get_width(), get_height());
}
@@ -48,28 +47,24 @@ bool Texture2D::is_pixel_opaque(int p_x, int p_y) const {
}
void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
-
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
}
bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
-
r_rect = p_rect;
r_src_rect = p_src_rect;
@@ -77,7 +72,6 @@ bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Re
}
void Texture2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_width"), &Texture2D::get_width);
ClassDB::bind_method(D_METHOD("get_height"), &Texture2D::get_height);
ClassDB::bind_method(D_METHOD("get_size"), &Texture2D::get_size);
@@ -96,10 +90,10 @@ Texture2D::Texture2D() {
/////////////////////
void ImageTexture::reload_from_file() {
-
String path = ResourceLoader::path_remap(get_path());
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
Ref<Image> img;
img.instance();
@@ -114,43 +108,42 @@ void ImageTexture::reload_from_file() {
}
bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {
-
- if (p_name == "image")
+ if (p_name == "image") {
create_from_image(p_value);
- else if (p_name == "size") {
+ } else if (p_name == "size") {
Size2 s = p_value;
w = s.width;
h = s.height;
RenderingServer::get_singleton()->texture_set_size_override(texture, w, h);
- } else
+ } else {
return false;
+ }
return true;
}
bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (p_name == "image")
+ if (p_name == "image") {
r_ret = get_data();
- else if (p_name == "size")
+ } else if (p_name == "size") {
r_ret = Size2(w, h);
- else
+ } else {
return false;
+ }
return true;
}
void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
-
p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, ""));
}
void ImageTexture::_reload_hook(const RID &p_hook) {
-
String path = get_path();
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
Ref<Image> img;
img.instance();
@@ -166,7 +159,6 @@ void ImageTexture::_reload_hook(const RID &p_hook) {
}
void ImageTexture::create_from_image(const Ref<Image> &p_image) {
-
ERR_FAIL_COND(p_image.is_null());
w = p_image->get_width();
h = p_image->get_height();
@@ -186,12 +178,10 @@ void ImageTexture::create_from_image(const Ref<Image> &p_image) {
}
Image::Format ImageTexture::get_format() const {
-
return format;
}
void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) {
-
ERR_FAIL_COND(p_image.is_null());
ERR_FAIL_COND(texture.is_null());
ERR_FAIL_COND(p_image->get_width() != w || p_image->get_height() != h);
@@ -212,12 +202,10 @@ void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) {
}
void ImageTexture::_resource_path_changed() {
-
String path = get_path();
}
Ref<Image> ImageTexture::get_data() const {
-
if (image_stored) {
return RenderingServer::get_singleton()->texture_2d_get(texture);
} else {
@@ -226,17 +214,14 @@ Ref<Image> ImageTexture::get_data() const {
}
int ImageTexture::get_width() const {
-
return w;
}
int ImageTexture::get_height() const {
-
return h;
}
RID ImageTexture::get_rid() const {
-
if (texture.is_null()) {
//we are in trouble, create something temporary
texture = RenderingServer::get_singleton()->texture_2d_placeholder_create();
@@ -245,37 +230,37 @@ RID ImageTexture::get_rid() const {
}
bool ImageTexture::has_alpha() const {
-
return (format == Image::FORMAT_LA8 || format == Image::FORMAT_RGBA8);
}
void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
- if ((w | h) == 0)
+ if ((w | h) == 0) {
return;
+ }
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
- if ((w | h) == 0)
+void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+ if ((w | h) == 0) {
return;
+ }
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
- if ((w | h) == 0)
+void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+ if ((w | h) == 0) {
return;
+ }
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
}
bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
-
if (!alpha_cache.is_valid()) {
Ref<Image> img = get_data();
if (img.is_valid()) {
@@ -290,7 +275,6 @@ bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
}
if (alpha_cache.is_valid()) {
-
int aw = int(alpha_cache->get_size().width);
int ah = int(alpha_cache->get_size().height);
if (aw == 0 || ah == 0) {
@@ -310,17 +294,17 @@ bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
}
void ImageTexture::set_size_override(const Size2 &p_size) {
-
Size2 s = p_size;
- if (s.x != 0)
+ if (s.x != 0) {
w = s.x;
- if (s.y != 0)
+ }
+ if (s.y != 0) {
h = s.y;
+ }
RenderingServer::get_singleton()->texture_set_size_override(texture, w, h);
}
void ImageTexture::set_path(const String &p_path, bool p_take_over) {
-
if (texture.is_valid()) {
RenderingServer::get_singleton()->texture_set_path(texture, p_path);
}
@@ -329,7 +313,6 @@ void ImageTexture::set_path(const String &p_path, bool p_take_over) {
}
void ImageTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create_from_image", "image"), &ImageTexture::create_from_image);
ClassDB::bind_method(D_METHOD("get_format"), &ImageTexture::get_format);
@@ -339,7 +322,6 @@ void ImageTexture::_bind_methods() {
}
ImageTexture::ImageTexture() {
-
w = h = 0;
image_stored = false;
mipmaps = false;
@@ -347,7 +329,6 @@ ImageTexture::ImageTexture() {
}
ImageTexture::~ImageTexture() {
-
if (texture.is_valid()) {
RenderingServer::get_singleton()->free(texture);
}
@@ -356,7 +337,6 @@ ImageTexture::~ImageTexture() {
//////////////////////////////////////////
Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit) {
-
uint32_t data_format = f->get_32();
uint32_t w = f->get_16();
uint32_t h = f->get_16();
@@ -376,7 +356,6 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
bool first = true;
for (uint32_t i = 0; i < mipmaps + 1; i++) {
-
uint32_t size = f->get_32();
if (p_size_limit > 0 && i < (mipmaps - 1) && (sw > p_size_limit || sh > p_size_limit)) {
@@ -444,7 +423,6 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
int ofs = 0;
for (int i = 0; i < mipmap_images.size(); i++) {
-
Vector<uint8_t> id = mipmap_images[i]->get_data();
int len = id.size();
const uint8_t *r = id.ptr();
@@ -458,7 +436,6 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
}
} else if (data_format == DATA_FORMAT_IMAGE) {
-
int size = Image::get_image_data_size(w, h, format, mipmaps ? true : false);
for (uint32_t i = 0; i < mipmaps + 1; i++) {
@@ -493,7 +470,6 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
}
void StreamTexture2D::set_path(const String &p_path, bool p_take_over) {
-
if (texture.is_valid()) {
RenderingServer::get_singleton()->texture_set_path(texture, p_path);
}
@@ -502,7 +478,6 @@ void StreamTexture2D::set_path(const String &p_path, bool p_take_over) {
}
void StreamTexture2D::_requested_3d(void *p_ud) {
-
StreamTexture2D *st = (StreamTexture2D *)p_ud;
Ref<StreamTexture2D> stex(st);
ERR_FAIL_COND(!request_3d_callback);
@@ -510,7 +485,6 @@ void StreamTexture2D::_requested_3d(void *p_ud) {
}
void StreamTexture2D::_requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel) {
-
StreamTexture2D *st = (StreamTexture2D *)p_ud;
Ref<StreamTexture2D> stex(st);
ERR_FAIL_COND(!request_roughness_callback);
@@ -518,7 +492,6 @@ void StreamTexture2D::_requested_roughness(void *p_ud, const String &p_normal_pa
}
void StreamTexture2D::_requested_normal(void *p_ud) {
-
StreamTexture2D *st = (StreamTexture2D *)p_ud;
Ref<StreamTexture2D> stex(st);
ERR_FAIL_COND(!request_normal_callback);
@@ -530,12 +503,10 @@ StreamTexture2D::TextureFormatRoughnessRequestCallback StreamTexture2D::request_
StreamTexture2D::TextureFormatRequestCallback StreamTexture2D::request_normal_callback = nullptr;
Image::Format StreamTexture2D::get_format() const {
-
return format;
}
Error StreamTexture2D::_load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, bool &r_request_3d, bool &r_request_normal, bool &r_request_roughness, int &mipmap_limit, int p_size_limit) {
-
alpha_cache.unref();
ERR_FAIL_COND_V(image.is_null(), ERR_INVALID_PARAMETER);
@@ -596,7 +567,6 @@ Error StreamTexture2D::_load_data(const String &p_path, int &tw, int &th, int &t
}
Error StreamTexture2D::load(const String &p_path) {
-
int lw, lh, lwc, lhc;
Ref<Image> image;
image.instance();
@@ -607,8 +577,9 @@ Error StreamTexture2D::load(const String &p_path) {
int mipmap_limit;
Error err = _load_data(p_path, lw, lh, lwc, lhc, image, request_3d, request_normal, request_roughness, mipmap_limit);
- if (err)
+ if (err) {
return err;
+ }
if (texture.is_valid()) {
RID new_texture = RS::get_singleton()->texture_2d_create(image);
@@ -661,21 +632,20 @@ Error StreamTexture2D::load(const String &p_path) {
emit_changed();
return OK;
}
-String StreamTexture2D::get_load_path() const {
+String StreamTexture2D::get_load_path() const {
return path_to_file;
}
int StreamTexture2D::get_width() const {
-
return w;
}
-int StreamTexture2D::get_height() const {
+int StreamTexture2D::get_height() const {
return h;
}
-RID StreamTexture2D::get_rid() const {
+RID StreamTexture2D::get_rid() const {
if (!texture.is_valid()) {
texture = RS::get_singleton()->texture_2d_placeholder_create();
}
@@ -683,37 +653,37 @@ RID StreamTexture2D::get_rid() const {
}
void StreamTexture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
- if ((w | h) == 0)
+ if ((w | h) == 0) {
return;
+ }
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void StreamTexture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
- if ((w | h) == 0)
+void StreamTexture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+ if ((w | h) == 0) {
return;
+ }
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void StreamTexture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
- if ((w | h) == 0)
+void StreamTexture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+ if ((w | h) == 0) {
return;
+ }
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
}
bool StreamTexture2D::has_alpha() const {
-
return false;
}
Ref<Image> StreamTexture2D::get_data() const {
-
if (texture.is_valid()) {
return RS::get_singleton()->texture_2d_get(texture);
} else {
@@ -722,7 +692,6 @@ Ref<Image> StreamTexture2D::get_data() const {
}
bool StreamTexture2D::is_pixel_opaque(int p_x, int p_y) const {
-
if (!alpha_cache.is_valid()) {
Ref<Image> img = get_data();
if (img.is_valid()) {
@@ -738,7 +707,6 @@ bool StreamTexture2D::is_pixel_opaque(int p_x, int p_y) const {
}
if (alpha_cache.is_valid()) {
-
int aw = int(alpha_cache->get_size().width);
int ah = int(alpha_cache->get_size().height);
if (aw == 0 || ah == 0) {
@@ -758,15 +726,16 @@ bool StreamTexture2D::is_pixel_opaque(int p_x, int p_y) const {
}
void StreamTexture2D::reload_from_file() {
-
String path = get_path();
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
path = ResourceLoader::path_remap(path); //remap for translation
path = ResourceLoader::import_remap(path); //remap for import
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
load(path);
}
@@ -775,7 +744,6 @@ void StreamTexture2D::_validate_property(PropertyInfo &property) const {
}
void StreamTexture2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("load", "path"), &StreamTexture2D::load);
ClassDB::bind_method(D_METHOD("get_load_path"), &StreamTexture2D::get_load_path);
@@ -783,140 +751,137 @@ void StreamTexture2D::_bind_methods() {
}
StreamTexture2D::StreamTexture2D() {
-
format = Image::FORMAT_MAX;
w = 0;
h = 0;
}
StreamTexture2D::~StreamTexture2D() {
-
if (texture.is_valid()) {
RS::get_singleton()->free(texture);
}
}
RES ResourceFormatLoaderStreamTexture2D::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) {
-
Ref<StreamTexture2D> st;
st.instance();
Error err = st->load(p_path);
- if (r_error)
+ if (r_error) {
*r_error = err;
- if (err != OK)
+ }
+ if (err != OK) {
return RES();
+ }
return st;
}
void ResourceFormatLoaderStreamTexture2D::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("stex");
}
+
bool ResourceFormatLoaderStreamTexture2D::handles_type(const String &p_type) const {
return p_type == "StreamTexture2D";
}
-String ResourceFormatLoaderStreamTexture2D::get_resource_type(const String &p_path) const {
- if (p_path.get_extension().to_lower() == "stex")
+String ResourceFormatLoaderStreamTexture2D::get_resource_type(const String &p_path) const {
+ if (p_path.get_extension().to_lower() == "stex") {
return "StreamTexture2D";
+ }
return "";
}
//////////////////////////////////////////
int AtlasTexture::get_width() const {
-
if (region.size.width == 0) {
- if (atlas.is_valid())
+ if (atlas.is_valid()) {
return atlas->get_width();
+ }
return 1;
} else {
return region.size.width + margin.size.width;
}
}
-int AtlasTexture::get_height() const {
+int AtlasTexture::get_height() const {
if (region.size.height == 0) {
- if (atlas.is_valid())
+ if (atlas.is_valid()) {
return atlas->get_height();
+ }
return 1;
} else {
return region.size.height + margin.size.height;
}
}
-RID AtlasTexture::get_rid() const {
- if (atlas.is_valid())
+RID AtlasTexture::get_rid() const {
+ if (atlas.is_valid()) {
return atlas->get_rid();
+ }
return RID();
}
bool AtlasTexture::has_alpha() const {
-
- if (atlas.is_valid())
+ if (atlas.is_valid()) {
return atlas->has_alpha();
+ }
return false;
}
void AtlasTexture::set_atlas(const Ref<Texture2D> &p_atlas) {
-
ERR_FAIL_COND(p_atlas == this);
- if (atlas == p_atlas)
+ if (atlas == p_atlas) {
return;
+ }
atlas = p_atlas;
emit_changed();
_change_notify("atlas");
}
-Ref<Texture2D> AtlasTexture::get_atlas() const {
+Ref<Texture2D> AtlasTexture::get_atlas() const {
return atlas;
}
void AtlasTexture::set_region(const Rect2 &p_region) {
-
- if (region == p_region)
+ if (region == p_region) {
return;
+ }
region = p_region;
emit_changed();
_change_notify("region");
}
Rect2 AtlasTexture::get_region() const {
-
return region;
}
void AtlasTexture::set_margin(const Rect2 &p_margin) {
-
- if (margin == p_margin)
+ if (margin == p_margin) {
return;
+ }
margin = p_margin;
emit_changed();
_change_notify("margin");
}
Rect2 AtlasTexture::get_margin() const {
-
return margin;
}
void AtlasTexture::set_filter_clip(const bool p_enable) {
-
filter_clip = p_enable;
emit_changed();
_change_notify("filter_clip");
}
bool AtlasTexture::has_filter_clip() const {
-
return filter_clip;
}
void AtlasTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_atlas", "atlas"), &AtlasTexture::set_atlas);
ClassDB::bind_method(D_METHOD("get_atlas"), &AtlasTexture::get_atlas);
@@ -936,9 +901,9 @@ void AtlasTexture::_bind_methods() {
}
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
- if (!atlas.is_valid())
+ if (!atlas.is_valid()) {
return;
+ }
Rect2 rc = region;
@@ -956,9 +921,9 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
}
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
- if (!atlas.is_valid())
+ if (!atlas.is_valid()) {
return;
+ }
Rect2 rc = region;
@@ -977,11 +942,12 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
}
-void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
//this might not necessarily work well if using a rect, needs to be fixed properly
- if (!atlas.is_valid())
+ if (!atlas.is_valid()) {
return;
+ }
Rect2 dr;
Rect2 src_c;
@@ -993,9 +959,9 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
}
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
-
- if (!atlas.is_valid())
+ if (!atlas.is_valid()) {
return false;
+ }
Rect2 rc = region;
@@ -1007,8 +973,9 @@ bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect,
src.position += (rc.position - margin.position);
Rect2 src_c = rc.clip(src);
- if (src_c.size == Size2())
+ if (src_c.size == Size2()) {
return false;
+ }
Vector2 ofs = (src_c.position - src.position);
if (scale.x < 0) {
@@ -1029,18 +996,20 @@ bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect,
}
bool AtlasTexture::is_pixel_opaque(int p_x, int p_y) const {
-
- if (!atlas.is_valid())
+ if (!atlas.is_valid()) {
return true;
+ }
int x = p_x + region.position.x - margin.position.x;
int y = p_y + region.position.y - margin.position.y;
// margin edge may outside of atlas
- if (x < 0 || x >= atlas->get_width())
+ if (x < 0 || x >= atlas->get_width()) {
return false;
- if (y < 0 || y >= atlas->get_height())
+ }
+ if (y < 0 || y >= atlas->get_height()) {
return false;
+ }
return atlas->is_pixel_opaque(x, y);
}
@@ -1054,9 +1023,11 @@ AtlasTexture::AtlasTexture() {
int MeshTexture::get_width() const {
return size.width;
}
+
int MeshTexture::get_height() const {
return size.height;
}
+
RID MeshTexture::get_rid() const {
return RID();
}
@@ -1068,6 +1039,7 @@ bool MeshTexture::has_alpha() const {
void MeshTexture::set_mesh(const Ref<Mesh> &p_mesh) {
mesh = p_mesh;
}
+
Ref<Mesh> MeshTexture::get_mesh() const {
return mesh;
}
@@ -1077,7 +1049,6 @@ void MeshTexture::set_image_size(const Size2 &p_size) {
}
Size2 MeshTexture::get_image_size() const {
-
return size;
}
@@ -1090,7 +1061,6 @@ Ref<Texture2D> MeshTexture::get_base_texture() const {
}
void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1104,6 +1074,7 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
+
void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
@@ -1127,8 +1098,8 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile,
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
-void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1151,6 +1122,7 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
+
bool MeshTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
r_rect = p_rect;
r_src_rect = p_src_rect;
@@ -1180,30 +1152,28 @@ MeshTexture::MeshTexture() {
//////////////////////////////////////////
int LargeTexture::get_width() const {
-
return size.width;
}
-int LargeTexture::get_height() const {
+int LargeTexture::get_height() const {
return size.height;
}
-RID LargeTexture::get_rid() const {
+RID LargeTexture::get_rid() const {
return RID();
}
bool LargeTexture::has_alpha() const {
-
for (int i = 0; i < pieces.size(); i++) {
- if (pieces[i].texture->has_alpha())
+ if (pieces[i].texture->has_alpha()) {
return true;
+ }
}
return false;
}
int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_COND_V(p_texture.is_null(), -1);
Piece p;
p.offset = p_offset;
@@ -1214,13 +1184,11 @@ int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture2D> &p_text
}
void LargeTexture::set_piece_offset(int p_idx, const Point2 &p_offset) {
-
ERR_FAIL_INDEX(p_idx, pieces.size());
pieces.write[p_idx].offset = p_offset;
};
void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_COND(p_texture == this);
ERR_FAIL_COND(p_texture.is_null());
ERR_FAIL_INDEX(p_idx, pieces.size());
@@ -1228,17 +1196,15 @@ void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture2D> &p_texture)
};
void LargeTexture::set_size(const Size2 &p_size) {
-
size = p_size;
}
-void LargeTexture::clear() {
+void LargeTexture::clear() {
pieces.clear();
size = Size2i();
}
Array LargeTexture::_get_data() const {
-
Array arr;
for (int i = 0; i < pieces.size(); i++) {
arr.push_back(pieces[i].offset);
@@ -1247,8 +1213,8 @@ Array LargeTexture::_get_data() const {
arr.push_back(Size2(size));
return arr;
}
-void LargeTexture::_set_data(const Array &p_array) {
+void LargeTexture::_set_data(const Array &p_array) {
ERR_FAIL_COND(p_array.size() < 1);
ERR_FAIL_COND(!(p_array.size() & 1));
clear();
@@ -1259,24 +1225,22 @@ void LargeTexture::_set_data(const Array &p_array) {
}
int LargeTexture::get_piece_count() const {
-
return pieces.size();
}
-Vector2 LargeTexture::get_piece_offset(int p_idx) const {
+Vector2 LargeTexture::get_piece_offset(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, pieces.size(), Vector2());
return pieces[p_idx].offset;
}
-Ref<Texture2D> LargeTexture::get_piece_texture(int p_idx) const {
+Ref<Texture2D> LargeTexture::get_piece_texture(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture2D>());
return pieces[p_idx].texture;
}
-Ref<Image> LargeTexture::to_image() const {
+Ref<Image> LargeTexture::to_image() const {
Ref<Image> img = memnew(Image(this->get_width(), this->get_height(), false, Image::FORMAT_RGBA8));
for (int i = 0; i < pieces.size(); i++) {
-
Ref<Image> src_img = pieces[i].texture->get_data();
img->blit_rect(src_img, Rect2(0, 0, src_img->get_width(), src_img->get_height()), pieces[i].offset);
}
@@ -1285,7 +1249,6 @@ Ref<Image> LargeTexture::to_image() const {
}
void LargeTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("add_piece", "ofs", "texture"), &LargeTexture::add_piece);
ClassDB::bind_method(D_METHOD("set_piece_offset", "idx", "ofs"), &LargeTexture::set_piece_offset);
ClassDB::bind_method(D_METHOD("set_piece_texture", "idx", "texture"), &LargeTexture::set_piece_texture);
@@ -1303,42 +1266,40 @@ void LargeTexture::_bind_methods() {
}
void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
for (int i = 0; i < pieces.size(); i++) {
-
// TODO
pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
}
void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
-
//tiling not supported for this
- if (size.x == 0 || size.y == 0)
+ if (size.x == 0 || size.y == 0) {
return;
+ }
Size2 scale = p_rect.size / size;
for (int i = 0; i < pieces.size(); i++) {
-
// TODO
pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
}
}
-void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
//tiling not supported for this
- if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0)
+ if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0) {
return;
+ }
Size2 scale = p_rect.size / p_src_rect.size;
for (int i = 0; i < pieces.size(); i++) {
-
// TODO
Rect2 rect(pieces[i].offset, pieces[i].texture->get_size());
- if (!p_src_rect.intersects(rect))
+ if (!p_src_rect.intersects(rect)) {
continue;
+ }
Rect2 local = p_src_rect.clip(rect);
Rect2 target = local;
target.size *= scale;
@@ -1349,12 +1310,11 @@ void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
}
bool LargeTexture::is_pixel_opaque(int p_x, int p_y) const {
-
for (int i = 0; i < pieces.size(); i++) {
-
// TODO
- if (!pieces[i].texture.is_valid())
+ if (!pieces[i].texture.is_valid()) {
continue;
+ }
Rect2 rect(pieces[i].offset, pieces[i].texture->get_size());
if (rect.has_point(Point2(p_x, p_y))) {
@@ -1371,7 +1331,6 @@ LargeTexture::LargeTexture() {
///////////////////
void CurveTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_width", "width"), &CurveTexture::set_width);
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &CurveTexture::set_curve);
@@ -1384,14 +1343,12 @@ void CurveTexture::_bind_methods() {
}
void CurveTexture::set_width(int p_width) {
-
ERR_FAIL_COND(p_width < 32 || p_width > 4096);
_width = p_width;
_update();
}
int CurveTexture::get_width() const {
-
return _width;
}
@@ -1421,7 +1378,6 @@ void CurveTexture::set_curve(Ref<Curve> p_curve) {
}
void CurveTexture::_update() {
-
Vector<uint8_t> data;
data.resize(_width * sizeof(float));
@@ -1457,12 +1413,10 @@ void CurveTexture::_update() {
}
Ref<Curve> CurveTexture::get_curve() const {
-
return _curve;
}
RID CurveTexture::get_rid() const {
-
if (!_texture.is_valid()) {
_texture = RS::get_singleton()->texture_2d_placeholder_create();
}
@@ -1472,11 +1426,13 @@ RID CurveTexture::get_rid() const {
CurveTexture::CurveTexture() {
_width = 2048;
}
+
CurveTexture::~CurveTexture() {
if (_texture.is_valid()) {
RS::get_singleton()->free(_texture);
}
}
+
//////////////////
//setter and getter names for property serialization
@@ -1499,7 +1455,6 @@ GradientTexture::~GradientTexture() {
}
void GradientTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_gradient", "gradient"), &GradientTexture::set_gradient);
ClassDB::bind_method(D_METHOD("get_gradient"), &GradientTexture::get_gradient);
@@ -1512,8 +1467,9 @@ void GradientTexture::_bind_methods() {
}
void GradientTexture::set_gradient(Ref<Gradient> p_gradient) {
- if (p_gradient == gradient)
+ if (p_gradient == gradient) {
return;
+ }
if (gradient.is_valid()) {
gradient->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture::_update));
}
@@ -1530,20 +1486,20 @@ Ref<Gradient> GradientTexture::get_gradient() const {
}
void GradientTexture::_queue_update() {
-
- if (update_pending)
+ if (update_pending) {
return;
+ }
update_pending = true;
call_deferred("_update");
}
void GradientTexture::_update() {
-
update_pending = false;
- if (gradient.is_null())
+ if (gradient.is_null()) {
return;
+ }
Vector<uint8_t> data;
data.resize(width * 4);
@@ -1552,7 +1508,6 @@ void GradientTexture::_update() {
Gradient &g = **gradient;
for (int i = 0; i < width; i++) {
-
float ofs = float(i) / (width - 1);
Color color = g.get_color_at_offset(ofs);
@@ -1576,12 +1531,11 @@ void GradientTexture::_update() {
}
void GradientTexture::set_width(int p_width) {
-
width = p_width;
_queue_update();
}
-int GradientTexture::get_width() const {
+int GradientTexture::get_width() const {
return width;
}
@@ -1595,7 +1549,6 @@ Ref<Image> GradientTexture::get_data() const {
//////////////////////////////////////
void ProxyTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_base", "base"), &ProxyTexture::set_base);
ClassDB::bind_method(D_METHOD("get_base"), &ProxyTexture::get_base);
@@ -1603,7 +1556,6 @@ void ProxyTexture::_bind_methods() {
}
void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_COND(p_texture == this);
base = p_texture;
@@ -1621,24 +1573,24 @@ void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) {
}
Ref<Texture2D> ProxyTexture::get_base() const {
-
return base;
}
int ProxyTexture::get_width() const {
-
- if (base.is_valid())
+ if (base.is_valid()) {
return base->get_width();
+ }
return 1;
}
-int ProxyTexture::get_height() const {
- if (base.is_valid())
+int ProxyTexture::get_height() const {
+ if (base.is_valid()) {
return base->get_height();
+ }
return 1;
}
-RID ProxyTexture::get_rid() const {
+RID ProxyTexture::get_rid() const {
if (proxy.is_null()) {
proxy_ph = RS::get_singleton()->texture_2d_placeholder_create();
proxy = RS::get_singleton()->texture_proxy_create(proxy_ph);
@@ -1647,19 +1599,17 @@ RID ProxyTexture::get_rid() const {
}
bool ProxyTexture::has_alpha() const {
-
- if (base.is_valid())
+ if (base.is_valid()) {
return base->has_alpha();
+ }
return false;
}
ProxyTexture::ProxyTexture() {
-
//proxy = RS::get_singleton()->texture_create();
}
ProxyTexture::~ProxyTexture() {
-
if (proxy_ph.is_valid()) {
RS::get_singleton()->free(proxy_ph);
}
@@ -1667,10 +1617,10 @@ ProxyTexture::~ProxyTexture() {
RS::get_singleton()->free(proxy);
}
}
+
//////////////////////////////////////////////
void AnimatedTexture::_update_proxy() {
-
RWLockRead r(rw_lock);
float delta;
@@ -1726,6 +1676,7 @@ void AnimatedTexture::set_frames(int p_frames) {
frame_count = p_frames;
}
+
int AnimatedTexture::get_frames() const {
return frame_count;
}
@@ -1737,6 +1688,7 @@ void AnimatedTexture::set_current_frame(int p_frame) {
current_frame = p_frame;
}
+
int AnimatedTexture::get_current_frame() const {
return current_frame;
}
@@ -1745,6 +1697,7 @@ void AnimatedTexture::set_pause(bool p_pause) {
RWLockWrite r(rw_lock);
pause = p_pause;
}
+
bool AnimatedTexture::get_pause() const {
return pause;
}
@@ -1753,12 +1706,12 @@ void AnimatedTexture::set_oneshot(bool p_oneshot) {
RWLockWrite r(rw_lock);
oneshot = p_oneshot;
}
+
bool AnimatedTexture::get_oneshot() const {
return oneshot;
}
void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_COND(p_texture == this);
ERR_FAIL_INDEX(p_frame, MAX_FRAMES);
@@ -1766,6 +1719,7 @@ void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture2D> &p_tex
frames[p_frame].texture = p_texture;
}
+
Ref<Texture2D> AnimatedTexture::get_frame_texture(int p_frame) const {
ERR_FAIL_INDEX_V(p_frame, MAX_FRAMES, Ref<Texture2D>());
@@ -1781,6 +1735,7 @@ void AnimatedTexture::set_frame_delay(int p_frame, float p_delay_sec) {
frames[p_frame].delay_sec = p_delay_sec;
}
+
float AnimatedTexture::get_frame_delay(int p_frame) const {
ERR_FAIL_INDEX_V(p_frame, MAX_FRAMES, 0);
@@ -1794,6 +1749,7 @@ void AnimatedTexture::set_fps(float p_fps) {
fps = p_fps;
}
+
float AnimatedTexture::get_fps() const {
return fps;
}
@@ -1807,6 +1763,7 @@ int AnimatedTexture::get_width() const {
return frames[current_frame].texture->get_width();
}
+
int AnimatedTexture::get_height() const {
RWLockRead r(rw_lock);
@@ -1816,12 +1773,12 @@ int AnimatedTexture::get_height() const {
return frames[current_frame].texture->get_height();
}
+
RID AnimatedTexture::get_rid() const {
return proxy;
}
bool AnimatedTexture::has_alpha() const {
-
RWLockRead r(rw_lock);
if (!frames[current_frame].texture.is_valid()) {
@@ -1832,7 +1789,6 @@ bool AnimatedTexture::has_alpha() const {
}
Ref<Image> AnimatedTexture::get_data() const {
-
RWLockRead r(rw_lock);
if (!frames[current_frame].texture.is_valid()) {
@@ -1843,7 +1799,6 @@ Ref<Image> AnimatedTexture::get_data() const {
}
bool AnimatedTexture::is_pixel_opaque(int p_x, int p_y) const {
-
RWLockRead r(rw_lock);
if (frames[current_frame].texture.is_valid()) {
@@ -1853,7 +1808,6 @@ bool AnimatedTexture::is_pixel_opaque(int p_x, int p_y) const {
}
void AnimatedTexture::_validate_property(PropertyInfo &property) const {
-
String prop = property.name;
if (prop.begins_with("frame_")) {
int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int();
@@ -1928,10 +1882,10 @@ AnimatedTexture::~AnimatedTexture() {
memdelete(rw_lock);
}
}
+
///////////////////////////////
void TextureLayered::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_format"), &TextureLayered::get_format);
ClassDB::bind_method(D_METHOD("get_layered_type"), &TextureLayered::get_layered_type);
ClassDB::bind_method(D_METHOD("get_width"), &TextureLayered::get_width);
@@ -1990,7 +1944,6 @@ Array ImageTextureLayered::_get_images() const {
}
Error ImageTextureLayered::create_from_images(Vector<Ref<Image>> p_images) {
-
int new_layers = p_images.size();
ERR_FAIL_COND_V(new_layers == 0, ERR_INVALID_PARAMETER);
if (layered_type == LAYERED_TYPE_CUBEMAP) {
@@ -2065,7 +2018,6 @@ void ImageTextureLayered::set_path(const String &p_path, bool p_take_over) {
}
void ImageTextureLayered::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create_from_images", "images"), &ImageTextureLayered::_create_from_images);
ClassDB::bind_method(D_METHOD("update_layer", "image", "layer"), &ImageTextureLayered::update_layer);
@@ -2092,7 +2044,6 @@ ImageTextureLayered::~ImageTextureLayered() {
///////////////////////////////////////////
void StreamTextureLayered::set_path(const String &p_path, bool p_take_over) {
-
if (texture.is_valid()) {
RenderingServer::get_singleton()->texture_set_path(texture, p_path);
}
@@ -2101,12 +2052,10 @@ void StreamTextureLayered::set_path(const String &p_path, bool p_take_over) {
}
Image::Format StreamTextureLayered::get_format() const {
-
return format;
}
Error StreamTextureLayered::_load_data(const String &p_path, Vector<Ref<Image>> &images, int &mipmap_limit, int p_size_limit) {
-
ERR_FAIL_COND_V(images.size() != 0, ERR_INVALID_PARAMETER);
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
@@ -2151,14 +2100,14 @@ Error StreamTextureLayered::_load_data(const String &p_path, Vector<Ref<Image>>
}
Error StreamTextureLayered::load(const String &p_path) {
-
Vector<Ref<Image>> images;
int mipmap_limit;
Error err = _load_data(p_path, images, mipmap_limit);
- if (err)
+ if (err) {
return err;
+ }
if (texture.is_valid()) {
RID new_texture = RS::get_singleton()->texture_2d_layered_create(images, RS::TextureLayeredType(layered_type));
@@ -2184,34 +2133,32 @@ Error StreamTextureLayered::load(const String &p_path) {
emit_changed();
return OK;
}
-String StreamTextureLayered::get_load_path() const {
+String StreamTextureLayered::get_load_path() const {
return path_to_file;
}
int StreamTextureLayered::get_width() const {
-
return w;
}
-int StreamTextureLayered::get_height() const {
+int StreamTextureLayered::get_height() const {
return h;
}
-int StreamTextureLayered::get_layers() const {
+int StreamTextureLayered::get_layers() const {
return layers;
}
+
bool StreamTextureLayered::has_mipmaps() const {
return mipmaps;
}
TextureLayered::LayeredType StreamTextureLayered::get_layered_type() const {
-
return layered_type;
}
RID StreamTextureLayered::get_rid() const {
-
if (!texture.is_valid()) {
texture = RS::get_singleton()->texture_2d_layered_placeholder_create(RS::TextureLayeredType(layered_type));
}
@@ -2219,7 +2166,6 @@ RID StreamTextureLayered::get_rid() const {
}
Ref<Image> StreamTextureLayered::get_layer_data(int p_layer) const {
-
if (texture.is_valid()) {
return RS::get_singleton()->texture_2d_layer_get(texture, p_layer);
} else {
@@ -2228,15 +2174,16 @@ Ref<Image> StreamTextureLayered::get_layer_data(int p_layer) const {
}
void StreamTextureLayered::reload_from_file() {
-
String path = get_path();
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
path = ResourceLoader::path_remap(path); //remap for translation
path = ResourceLoader::import_remap(path); //remap for import
- if (!path.is_resource_file())
+ if (!path.is_resource_file()) {
return;
+ }
load(path);
}
@@ -2245,7 +2192,6 @@ void StreamTextureLayered::_validate_property(PropertyInfo &property) const {
}
void StreamTextureLayered::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("load", "path"), &StreamTextureLayered::load);
ClassDB::bind_method(D_METHOD("get_load_path"), &StreamTextureLayered::get_load_path);
@@ -2253,7 +2199,6 @@ void StreamTextureLayered::_bind_methods() {
}
StreamTextureLayered::StreamTextureLayered(LayeredType p_type) {
-
layered_type = p_type;
format = Image::FORMAT_MAX;
w = 0;
@@ -2263,7 +2208,6 @@ StreamTextureLayered::StreamTextureLayered(LayeredType p_type) {
}
StreamTextureLayered::~StreamTextureLayered() {
-
if (texture.is_valid()) {
RS::get_singleton()->free(texture);
}
@@ -2272,7 +2216,6 @@ StreamTextureLayered::~StreamTextureLayered() {
/////////////////////////////////////////////////
RES ResourceFormatLoaderStreamTextureLayered::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) {
-
Ref<StreamTextureLayered> st;
if (p_path.get_extension().to_lower() == "stexarray") {
Ref<StreamTexture2DArray> s;
@@ -2293,31 +2236,36 @@ RES ResourceFormatLoaderStreamTextureLayered::load(const String &p_path, const S
return RES();
}
Error err = st->load(p_path);
- if (r_error)
+ if (r_error) {
*r_error = err;
- if (err != OK)
+ }
+ if (err != OK) {
return RES();
+ }
return st;
}
void ResourceFormatLoaderStreamTextureLayered::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("stexarray");
p_extensions->push_back("scube");
p_extensions->push_back("scubearray");
}
+
bool ResourceFormatLoaderStreamTextureLayered::handles_type(const String &p_type) const {
return p_type == "StreamTexture2DArray" || p_type == "StreamCubemap" || p_type == "StreamCubemapArray";
}
-String ResourceFormatLoaderStreamTextureLayered::get_resource_type(const String &p_path) const {
- if (p_path.get_extension().to_lower() == "stexarray")
+String ResourceFormatLoaderStreamTextureLayered::get_resource_type(const String &p_path) const {
+ if (p_path.get_extension().to_lower() == "stexarray") {
return "StreamTexture2DArray";
- if (p_path.get_extension().to_lower() == "scube")
+ }
+ if (p_path.get_extension().to_lower() == "scube") {
return "StreamCubemap";
- if (p_path.get_extension().to_lower() == "scubearray")
+ }
+ if (p_path.get_extension().to_lower() == "scubearray") {
return "StreamCubemapArray";
+ }
return "";
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 5d4131ec4c..005f899512 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -51,7 +51,6 @@ public:
};
class Texture2D : public Texture {
-
GDCLASS(Texture2D, Texture);
OBJ_SAVE_TYPE(Texture2D); // Saves derived classes with common type so they can be interchanged.
@@ -81,7 +80,6 @@ public:
class BitMap;
class ImageTexture : public Texture2D {
-
GDCLASS(ImageTexture, Texture2D);
RES_BASE_EXTENSION("tex");
@@ -133,7 +131,6 @@ public:
};
class StreamTexture2D : public Texture2D {
-
GDCLASS(StreamTexture2D, Texture2D);
public:
@@ -220,7 +217,6 @@ public:
};
class AtlasTexture : public Texture2D {
-
GDCLASS(AtlasTexture, Texture2D);
RES_BASE_EXTENSION("atlastex");
@@ -264,7 +260,6 @@ public:
class Mesh;
class MeshTexture : public Texture2D {
-
GDCLASS(MeshTexture, Texture2D);
RES_BASE_EXTENSION("meshtex");
@@ -302,13 +297,11 @@ public:
};
class LargeTexture : public Texture2D {
-
GDCLASS(LargeTexture, Texture2D);
RES_BASE_EXTENSION("largetex");
protected:
struct Piece {
-
Point2 offset;
Ref<Texture2D> texture;
};
@@ -373,7 +366,6 @@ public:
VARIANT_ENUM_CAST(TextureLayered::LayeredType)
class ImageTextureLayered : public TextureLayered {
-
GDCLASS(ImageTextureLayered, TextureLayered);
LayeredType layered_type;
@@ -413,7 +405,6 @@ public:
};
class Texture2DArray : public ImageTextureLayered {
-
GDCLASS(Texture2DArray, ImageTextureLayered)
public:
Texture2DArray() :
@@ -421,7 +412,6 @@ public:
};
class Cubemap : public ImageTextureLayered {
-
GDCLASS(Cubemap, ImageTextureLayered);
public:
@@ -430,7 +420,6 @@ public:
};
class CubemapArray : public ImageTextureLayered {
-
GDCLASS(CubemapArray, ImageTextureLayered);
public:
@@ -439,7 +428,6 @@ public:
};
class StreamTextureLayered : public TextureLayered {
-
GDCLASS(StreamTextureLayered, TextureLayered);
public:
@@ -498,7 +486,6 @@ public:
};
class StreamTexture2DArray : public StreamTextureLayered {
-
GDCLASS(StreamTexture2DArray, StreamTextureLayered)
public:
StreamTexture2DArray() :
@@ -506,7 +493,6 @@ public:
};
class StreamCubemap : public StreamTextureLayered {
-
GDCLASS(StreamCubemap, StreamTextureLayered);
public:
@@ -515,7 +501,6 @@ public:
};
class StreamCubemapArray : public StreamTextureLayered {
-
GDCLASS(StreamCubemapArray, StreamTextureLayered);
public:
@@ -532,7 +517,6 @@ public:
};
class CurveTexture : public Texture2D {
-
GDCLASS(CurveTexture, Texture2D);
RES_BASE_EXTENSION("curvetex")
@@ -582,7 +566,6 @@ class GradientTexture : public Texture2D {
public:
struct Point {
-
float offset;
Color color;
bool operator<(const Point &p_ponit) const {
@@ -659,7 +642,6 @@ private:
RID proxy;
struct Frame {
-
Ref<Texture2D> texture;
float delay_sec;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 98ebf048dc..6a85d357ff 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -33,12 +33,10 @@
#include "core/print_string.h"
void Theme::_emit_theme_changed() {
-
emit_changed();
}
Vector<String> Theme::_get_icon_list(const String &p_type) const {
-
Vector<String> ilret;
List<StringName> il;
@@ -54,7 +52,6 @@ Vector<String> Theme::_get_icon_list(const String &p_type) const {
}
Vector<String> Theme::_get_stylebox_list(const String &p_type) const {
-
Vector<String> ilret;
List<StringName> il;
@@ -69,8 +66,7 @@ Vector<String> Theme::_get_stylebox_list(const String &p_type) const {
return ilret;
}
-Vector<String> Theme::_get_stylebox_types(void) const {
-
+Vector<String> Theme::_get_stylebox_types() const {
Vector<String> ilret;
List<StringName> il;
@@ -86,7 +82,6 @@ Vector<String> Theme::_get_stylebox_types(void) const {
}
Vector<String> Theme::_get_font_list(const String &p_type) const {
-
Vector<String> ilret;
List<StringName> il;
@@ -102,7 +97,6 @@ Vector<String> Theme::_get_font_list(const String &p_type) const {
}
Vector<String> Theme::_get_color_list(const String &p_type) const {
-
Vector<String> ilret;
List<StringName> il;
@@ -118,7 +112,6 @@ Vector<String> Theme::_get_color_list(const String &p_type) const {
}
Vector<String> Theme::_get_constant_list(const String &p_type) const {
-
Vector<String> ilret;
List<StringName> il;
@@ -134,7 +127,6 @@ Vector<String> Theme::_get_constant_list(const String &p_type) const {
}
Vector<String> Theme::_get_type_list(const String &p_type) const {
-
Vector<String> ilret;
List<StringName> il;
@@ -150,32 +142,26 @@ Vector<String> Theme::_get_type_list(const String &p_type) const {
}
bool Theme::_set(const StringName &p_name, const Variant &p_value) {
-
String sname = p_name;
if (sname.find("/") != -1) {
-
String type = sname.get_slicec('/', 1);
String node_type = sname.get_slicec('/', 0);
String name = sname.get_slicec('/', 2);
if (type == "icons") {
-
set_icon(name, node_type, p_value);
} else if (type == "styles") {
-
set_stylebox(name, node_type, p_value);
} else if (type == "fonts") {
-
set_font(name, node_type, p_value);
} else if (type == "colors") {
-
set_color(name, node_type, p_value);
} else if (type == "constants") {
-
set_constant(name, node_type, p_value);
- } else
+ } else {
return false;
+ }
return true;
}
@@ -184,41 +170,38 @@ bool Theme::_set(const StringName &p_name, const Variant &p_value) {
}
bool Theme::_get(const StringName &p_name, Variant &r_ret) const {
-
String sname = p_name;
if (sname.find("/") != -1) {
-
String type = sname.get_slicec('/', 1);
String node_type = sname.get_slicec('/', 0);
String name = sname.get_slicec('/', 2);
if (type == "icons") {
-
- if (!has_icon(name, node_type))
+ if (!has_icon(name, node_type)) {
r_ret = Ref<Texture2D>();
- else
+ } else {
r_ret = get_icon(name, node_type);
+ }
} else if (type == "styles") {
-
- if (!has_stylebox(name, node_type))
+ if (!has_stylebox(name, node_type)) {
r_ret = Ref<StyleBox>();
- else
+ } else {
r_ret = get_stylebox(name, node_type);
+ }
} else if (type == "fonts") {
-
- if (!has_font(name, node_type))
+ if (!has_font(name, node_type)) {
r_ret = Ref<Font>();
- else
+ } else {
r_ret = get_font(name, node_type);
+ }
} else if (type == "colors") {
-
r_ret = get_color(name, node_type);
} else if (type == "constants") {
-
r_ret = get_constant(name, node_type);
- } else
+ } else {
return false;
+ }
return true;
}
@@ -227,17 +210,14 @@ bool Theme::_get(const StringName &p_name, Variant &r_ret) const {
}
void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
-
List<PropertyInfo> list;
const StringName *key = nullptr;
while ((key = icon_map.next(key))) {
-
const StringName *key2 = nullptr;
while ((key2 = icon_map[*key].next(key2))) {
-
list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
@@ -245,11 +225,9 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
key = nullptr;
while ((key = style_map.next(key))) {
-
const StringName *key2 = nullptr;
while ((key2 = style_map[*key].next(key2))) {
-
list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/styles/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
@@ -257,11 +235,9 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
key = nullptr;
while ((key = font_map.next(key))) {
-
const StringName *key2 = nullptr;
while ((key2 = font_map[*key].next(key2))) {
-
list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/fonts/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
@@ -269,11 +245,9 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
key = nullptr;
while ((key = color_map.next(key))) {
-
const StringName *key2 = nullptr;
while ((key2 = color_map[*key].next(key2))) {
-
list.push_back(PropertyInfo(Variant::COLOR, String() + *key + "/colors/" + *key2));
}
}
@@ -281,11 +255,9 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
key = nullptr;
while ((key = constant_map.next(key))) {
-
const StringName *key2 = nullptr;
while ((key2 = constant_map[*key].next(key2))) {
-
list.push_back(PropertyInfo(Variant::INT, String() + *key + "/constants/" + *key2));
}
}
@@ -297,9 +269,9 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
}
void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
-
- if (default_theme_font == p_default_font)
+ if (default_theme_font == p_default_font) {
return;
+ }
if (default_theme_font.is_valid()) {
default_theme_font->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
@@ -316,7 +288,6 @@ void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
}
Ref<Font> Theme::get_default_theme_font() const {
-
return default_theme_font;
}
@@ -327,40 +298,34 @@ Ref<StyleBox> Theme::default_style;
Ref<Font> Theme::default_font;
Ref<Theme> Theme::get_default() {
-
return default_theme;
}
void Theme::set_default(const Ref<Theme> &p_default) {
-
default_theme = p_default;
}
Ref<Theme> Theme::get_project_default() {
-
return project_default_theme;
}
void Theme::set_project_default(const Ref<Theme> &p_project_default) {
-
project_default_theme = p_project_default;
}
void Theme::set_default_icon(const Ref<Texture2D> &p_icon) {
-
default_icon = p_icon;
}
-void Theme::set_default_style(const Ref<StyleBox> &p_style) {
+void Theme::set_default_style(const Ref<StyleBox> &p_style) {
default_style = p_style;
}
-void Theme::set_default_font(const Ref<Font> &p_font) {
+void Theme::set_default_font(const Ref<Font> &p_font) {
default_font = p_font;
}
void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture2D> &p_icon) {
-
//ERR_FAIL_COND(p_icon.is_null());
bool new_value = !icon_map.has(p_type) || !icon_map[p_type].has(p_name);
@@ -380,10 +345,9 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_type, const R
emit_changed();
}
}
-Ref<Texture2D> Theme::get_icon(const StringName &p_name, const StringName &p_type) const {
+Ref<Texture2D> Theme::get_icon(const StringName &p_name, const StringName &p_type) const {
if (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
-
return icon_map[p_type][p_name];
} else {
return default_icon;
@@ -391,12 +355,10 @@ Ref<Texture2D> Theme::get_icon(const StringName &p_name, const StringName &p_typ
}
bool Theme::has_icon(const StringName &p_name, const StringName &p_type) const {
-
return (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid());
}
void Theme::clear_icon(const StringName &p_name, const StringName &p_type) {
-
ERR_FAIL_COND(!icon_map.has(p_type));
ERR_FAIL_COND(!icon_map[p_type].has(p_name));
@@ -411,16 +373,15 @@ void Theme::clear_icon(const StringName &p_name, const StringName &p_type) {
}
void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
- if (!icon_map.has(p_type))
+ if (!icon_map.has(p_type)) {
return;
+ }
const StringName *key = nullptr;
while ((key = icon_map[p_type].next(key))) {
-
p_list->push_back(*key);
}
}
@@ -458,22 +419,20 @@ void Theme::clear_shader(const StringName &p_name, const StringName &p_type) {
}
void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
- if (!shader_map.has(p_type))
+ if (!shader_map.has(p_type)) {
return;
+ }
const StringName *key = nullptr;
while ((key = shader_map[p_type].next(key))) {
-
p_list->push_back(*key);
}
}
void Theme::set_stylebox(const StringName &p_name, const StringName &p_type, const Ref<StyleBox> &p_style) {
-
//ERR_FAIL_COND(p_style.is_null());
bool new_value = !style_map.has(p_type) || !style_map[p_type].has(p_name);
@@ -488,15 +447,14 @@ void Theme::set_stylebox(const StringName &p_name, const StringName &p_type, con
style_map[p_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED);
}
- if (new_value)
+ if (new_value) {
_change_notify();
+ }
emit_changed();
}
Ref<StyleBox> Theme::get_stylebox(const StringName &p_name, const StringName &p_type) const {
-
if (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) {
-
return style_map[p_type][p_name];
} else {
return default_style;
@@ -504,12 +462,10 @@ Ref<StyleBox> Theme::get_stylebox(const StringName &p_name, const StringName &p_
}
bool Theme::has_stylebox(const StringName &p_name, const StringName &p_type) const {
-
return (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid());
}
void Theme::clear_stylebox(const StringName &p_name, const StringName &p_type) {
-
ERR_FAIL_COND(!style_map.has(p_type));
ERR_FAIL_COND(!style_map[p_type].has(p_name));
@@ -524,16 +480,15 @@ void Theme::clear_stylebox(const StringName &p_name, const StringName &p_type) {
}
void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
- if (!style_map.has(p_type))
+ if (!style_map.has(p_type)) {
return;
+ }
const StringName *key = nullptr;
while ((key = style_map[p_type].next(key))) {
-
p_list->push_back(*key);
}
}
@@ -548,7 +503,6 @@ void Theme::get_stylebox_types(List<StringName> *p_list) const {
}
void Theme::set_font(const StringName &p_name, const StringName &p_type, const Ref<Font> &p_font) {
-
//ERR_FAIL_COND(p_font.is_null());
bool new_value = !font_map.has(p_type) || !font_map[p_type].has(p_name);
@@ -568,23 +522,22 @@ void Theme::set_font(const StringName &p_name, const StringName &p_type, const R
emit_changed();
}
}
-Ref<Font> Theme::get_font(const StringName &p_name, const StringName &p_type) const {
- if (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid())
+Ref<Font> Theme::get_font(const StringName &p_name, const StringName &p_type) const {
+ if (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid()) {
return font_map[p_type][p_name];
- else if (default_theme_font.is_valid())
+ } else if (default_theme_font.is_valid()) {
return default_theme_font;
- else
+ } else {
return default_font;
+ }
}
bool Theme::has_font(const StringName &p_name, const StringName &p_type) const {
-
return (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid());
}
void Theme::clear_font(const StringName &p_name, const StringName &p_type) {
-
ERR_FAIL_COND(!font_map.has(p_type));
ERR_FAIL_COND(!font_map[p_type].has(p_name));
@@ -598,22 +551,20 @@ void Theme::clear_font(const StringName &p_name, const StringName &p_type) {
}
void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
- if (!font_map.has(p_type))
+ if (!font_map.has(p_type)) {
return;
+ }
const StringName *key = nullptr;
while ((key = font_map[p_type].next(key))) {
-
p_list->push_back(*key);
}
}
void Theme::set_color(const StringName &p_name, const StringName &p_type, const Color &p_color) {
-
bool new_value = !color_map.has(p_type) || !color_map[p_type].has(p_name);
color_map[p_type][p_name] = p_color;
@@ -625,20 +576,18 @@ void Theme::set_color(const StringName &p_name, const StringName &p_type, const
}
Color Theme::get_color(const StringName &p_name, const StringName &p_type) const {
-
- if (color_map.has(p_type) && color_map[p_type].has(p_name))
+ if (color_map.has(p_type) && color_map[p_type].has(p_name)) {
return color_map[p_type][p_name];
- else
+ } else {
return Color();
+ }
}
bool Theme::has_color(const StringName &p_name, const StringName &p_type) const {
-
return (color_map.has(p_type) && color_map[p_type].has(p_name));
}
void Theme::clear_color(const StringName &p_name, const StringName &p_type) {
-
ERR_FAIL_COND(!color_map.has(p_type));
ERR_FAIL_COND(!color_map[p_type].has(p_name));
@@ -648,22 +597,20 @@ void Theme::clear_color(const StringName &p_name, const StringName &p_type) {
}
void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
- if (!color_map.has(p_type))
+ if (!color_map.has(p_type)) {
return;
+ }
const StringName *key = nullptr;
while ((key = color_map[p_type].next(key))) {
-
p_list->push_back(*key);
}
}
void Theme::set_constant(const StringName &p_name, const StringName &p_type, int p_constant) {
-
bool new_value = !constant_map.has(p_type) || !constant_map[p_type].has(p_name);
constant_map[p_type][p_name] = p_constant;
@@ -674,21 +621,18 @@ void Theme::set_constant(const StringName &p_name, const StringName &p_type, int
}
int Theme::get_constant(const StringName &p_name, const StringName &p_type) const {
-
- if (constant_map.has(p_type) && constant_map[p_type].has(p_name))
+ if (constant_map.has(p_type) && constant_map[p_type].has(p_name)) {
return constant_map[p_type][p_name];
- else {
+ } else {
return 0;
}
}
bool Theme::has_constant(const StringName &p_name, const StringName &p_type) const {
-
return (constant_map.has(p_type) && constant_map[p_type].has(p_name));
}
void Theme::clear_constant(const StringName &p_name, const StringName &p_type) {
-
ERR_FAIL_COND(!constant_map.has(p_type));
ERR_FAIL_COND(!constant_map[p_type].has(p_name));
@@ -698,22 +642,20 @@ void Theme::clear_constant(const StringName &p_name, const StringName &p_type) {
}
void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
- if (!constant_map.has(p_type))
+ if (!constant_map.has(p_type)) {
return;
+ }
const StringName *key = nullptr;
while ((key = constant_map[p_type].next(key))) {
-
p_list->push_back(*key);
}
}
void Theme::clear() {
-
//these need disconnecting
{
const StringName *K = nullptr;
@@ -766,13 +708,11 @@ void Theme::clear() {
}
void Theme::copy_default_theme() {
-
Ref<Theme> default_theme2 = get_default();
copy_theme(default_theme2);
}
void Theme::copy_theme(const Ref<Theme> &p_other) {
-
if (p_other.is_null()) {
clear();
@@ -821,53 +761,45 @@ void Theme::copy_theme(const Ref<Theme> &p_other) {
}
void Theme::get_type_list(List<StringName> *p_list) const {
-
ERR_FAIL_NULL(p_list);
Set<StringName> types;
const StringName *key = nullptr;
while ((key = icon_map.next(key))) {
-
types.insert(*key);
}
key = nullptr;
while ((key = style_map.next(key))) {
-
types.insert(*key);
}
key = nullptr;
while ((key = font_map.next(key))) {
-
types.insert(*key);
}
key = nullptr;
while ((key = color_map.next(key))) {
-
types.insert(*key);
}
key = nullptr;
while ((key = constant_map.next(key))) {
-
types.insert(*key);
}
for (Set<StringName>::Element *E = types.front(); E; E = E->next()) {
-
p_list->push_back(E->get());
}
}
void Theme::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_icon", "name", "type", "texture"), &Theme::set_icon);
ClassDB::bind_method(D_METHOD("get_icon", "name", "type"), &Theme::get_icon);
ClassDB::bind_method(D_METHOD("has_icon", "name", "type"), &Theme::has_icon);
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index d6d724e3f7..3c72ddd8a2 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -39,7 +39,6 @@
#include "scene/resources/texture.h"
class Theme : public Resource {
-
GDCLASS(Theme, Resource);
RES_BASE_EXTENSION("theme");
@@ -54,7 +53,7 @@ class Theme : public Resource {
Vector<String> _get_icon_list(const String &p_type) const;
Vector<String> _get_stylebox_list(const String &p_type) const;
- Vector<String> _get_stylebox_types(void) const;
+ Vector<String> _get_stylebox_types() const;
Vector<String> _get_font_list(const String &p_type) const;
Vector<String> _get_color_list(const String &p_type) const;
Vector<String> _get_constant_list(const String &p_type) const;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 1b68b7486b..6992360df7 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -29,54 +29,58 @@
/*************************************************************************/
#include "tile_set.h"
+
#include "core/array.h"
#include "core/engine.h"
+#include "core/math/geometry_2d.h"
bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
-
String n = p_name;
int slash = n.find("/");
- if (slash == -1)
+ if (slash == -1) {
return false;
+ }
int id = String::to_int(n.c_str(), slash);
- if (!tile_map.has(id))
+ if (!tile_map.has(id)) {
create_tile(id);
+ }
String what = n.substr(slash + 1, n.length());
- if (what == "name")
+ if (what == "name") {
tile_set_name(id, p_value);
- else if (what == "texture")
+ } else if (what == "texture") {
tile_set_texture(id, p_value);
- else if (what == "normal_map")
+ } else if (what == "normal_map") {
tile_set_normal_map(id, p_value);
- else if (what == "tex_offset")
+ } else if (what == "tex_offset") {
tile_set_texture_offset(id, p_value);
- else if (what == "material")
+ } else if (what == "material") {
tile_set_material(id, p_value);
- else if (what == "modulate")
+ } else if (what == "modulate") {
tile_set_modulate(id, p_value);
- else if (what == "region")
+ } else if (what == "region") {
tile_set_region(id, p_value);
- else if (what == "tile_mode")
+ } else if (what == "tile_mode") {
tile_set_tile_mode(id, (TileMode)((int)p_value));
- else if (what == "is_autotile") {
+ } else if (what == "is_autotile") {
// backward compatibility for Godot 3.0.x
// autotile used to be a bool, it's now an enum
bool is_autotile = p_value;
- if (is_autotile)
+ if (is_autotile) {
tile_set_tile_mode(id, AUTO_TILE);
+ }
} else if (what.left(9) == "autotile/") {
what = what.right(9);
- if (what == "bitmask_mode")
+ if (what == "bitmask_mode") {
autotile_set_bitmask_mode(id, (BitmaskMode)((int)p_value));
- else if (what == "icon_coordinate")
+ } else if (what == "icon_coordinate") {
autotile_set_icon_coordinate(id, p_value);
- else if (what == "tile_size")
+ } else if (what == "tile_size") {
autotile_set_size(id, p_value);
- else if (what == "spacing")
+ } else if (what == "spacing") {
autotile_set_spacing(id, p_value);
- else if (what == "bitmask_flags") {
+ } else if (what == "bitmask_flags") {
tile_map[id].autotile_data.flags.clear();
if (p_value.is_array()) {
Array p = p_value;
@@ -147,7 +151,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
p.pop_front();
}
}
- } else if (what == "shape")
+ } else if (what == "shape") {
if (tile_get_shape_count(id) > 0) {
for (int i = 0; i < tile_get_shape_count(id); i++) {
tile_set_shape(id, i, p_value);
@@ -155,7 +159,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
} else {
tile_set_shape(id, 0, p_value);
}
- else if (what == "shape_offset")
+ } else if (what == "shape_offset") {
if (tile_get_shape_count(id) > 0) {
for (int i = 0; i < tile_get_shape_count(id); i++) {
tile_set_shape_offset(id, i, p_value);
@@ -163,7 +167,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
} else {
tile_set_shape_offset(id, 0, p_value);
}
- else if (what == "shape_transform")
+ } else if (what == "shape_transform") {
if (tile_get_shape_count(id) > 0) {
for (int i = 0; i < tile_get_shape_count(id); i++) {
tile_set_shape_transform(id, i, p_value);
@@ -171,7 +175,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
} else {
tile_set_shape_transform(id, 0, p_value);
}
- else if (what == "shape_one_way")
+ } else if (what == "shape_one_way") {
if (tile_get_shape_count(id) > 0) {
for (int i = 0; i < tile_get_shape_count(id); i++) {
tile_set_shape_one_way(id, i, p_value);
@@ -179,7 +183,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
} else {
tile_set_shape_one_way(id, 0, p_value);
}
- else if (what == "shape_one_way_margin")
+ } else if (what == "shape_one_way_margin") {
if (tile_get_shape_count(id) > 0) {
for (int i = 0; i < tile_get_shape_count(id); i++) {
tile_set_shape_one_way_margin(id, i, p_value);
@@ -187,63 +191,64 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
} else {
tile_set_shape_one_way_margin(id, 0, p_value);
}
- else if (what == "shapes")
+ } else if (what == "shapes") {
_tile_set_shapes(id, p_value);
- else if (what == "occluder")
+ } else if (what == "occluder") {
tile_set_light_occluder(id, p_value);
- else if (what == "occluder_offset")
+ } else if (what == "occluder_offset") {
tile_set_occluder_offset(id, p_value);
- else if (what == "navigation")
+ } else if (what == "navigation") {
tile_set_navigation_polygon(id, p_value);
- else if (what == "navigation_offset")
+ } else if (what == "navigation_offset") {
tile_set_navigation_polygon_offset(id, p_value);
- else if (what == "z_index")
+ } else if (what == "z_index") {
tile_set_z_index(id, p_value);
- else
+ } else {
return false;
+ }
return true;
}
bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
-
String n = p_name;
int slash = n.find("/");
- if (slash == -1)
+ if (slash == -1) {
return false;
+ }
int id = String::to_int(n.c_str(), slash);
ERR_FAIL_COND_V(!tile_map.has(id), false);
String what = n.substr(slash + 1, n.length());
- if (what == "name")
+ if (what == "name") {
r_ret = tile_get_name(id);
- else if (what == "texture")
+ } else if (what == "texture") {
r_ret = tile_get_texture(id);
- else if (what == "normal_map")
+ } else if (what == "normal_map") {
r_ret = tile_get_normal_map(id);
- else if (what == "tex_offset")
+ } else if (what == "tex_offset") {
r_ret = tile_get_texture_offset(id);
- else if (what == "material")
+ } else if (what == "material") {
r_ret = tile_get_material(id);
- else if (what == "modulate")
+ } else if (what == "modulate") {
r_ret = tile_get_modulate(id);
- else if (what == "region")
+ } else if (what == "region") {
r_ret = tile_get_region(id);
- else if (what == "tile_mode")
+ } else if (what == "tile_mode") {
r_ret = tile_get_tile_mode(id);
- else if (what.left(9) == "autotile/") {
+ } else if (what.left(9) == "autotile/") {
what = what.right(9);
- if (what == "bitmask_mode")
+ if (what == "bitmask_mode") {
r_ret = autotile_get_bitmask_mode(id);
- else if (what == "icon_coordinate")
+ } else if (what == "icon_coordinate") {
r_ret = autotile_get_icon_coordinate(id);
- else if (what == "tile_size")
+ } else if (what == "tile_size") {
r_ret = autotile_get_size(id);
- else if (what == "spacing")
+ } else if (what == "spacing") {
r_ret = autotile_get_spacing(id);
- else if (what == "bitmask_flags") {
+ } else if (what == "bitmask_flags") {
Array p;
for (Map<Vector2, uint32_t>::Element *E = tile_map[id].autotile_data.flags.front(); E; E = E->next()) {
p.push_back(E->key());
@@ -291,38 +296,37 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
}
r_ret = p;
}
- } else if (what == "shape")
+ } else if (what == "shape") {
r_ret = tile_get_shape(id, 0);
- else if (what == "shape_offset")
+ } else if (what == "shape_offset") {
r_ret = tile_get_shape_offset(id, 0);
- else if (what == "shape_transform")
+ } else if (what == "shape_transform") {
r_ret = tile_get_shape_transform(id, 0);
- else if (what == "shape_one_way")
+ } else if (what == "shape_one_way") {
r_ret = tile_get_shape_one_way(id, 0);
- else if (what == "shape_one_way_margin")
+ } else if (what == "shape_one_way_margin") {
r_ret = tile_get_shape_one_way_margin(id, 0);
- else if (what == "shapes")
+ } else if (what == "shapes") {
r_ret = _tile_get_shapes(id);
- else if (what == "occluder")
+ } else if (what == "occluder") {
r_ret = tile_get_light_occluder(id);
- else if (what == "occluder_offset")
+ } else if (what == "occluder_offset") {
r_ret = tile_get_occluder_offset(id);
- else if (what == "navigation")
+ } else if (what == "navigation") {
r_ret = tile_get_navigation_polygon(id);
- else if (what == "navigation_offset")
+ } else if (what == "navigation_offset") {
r_ret = tile_get_navigation_polygon_offset(id);
- else if (what == "z_index")
+ } else if (what == "z_index") {
r_ret = tile_get_z_index(id);
- else
+ } else {
return false;
+ }
return true;
}
void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
-
for (Map<int, TileData>::Element *E = tile_map.front(); E; E = E->next()) {
-
int id = E->key();
String pre = itos(id) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, pre + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
@@ -382,13 +386,11 @@ void TileSet::autotile_set_bitmask_mode(int p_id, BitmaskMode p_mode) {
}
TileSet::BitmaskMode TileSet::autotile_get_bitmask_mode(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), BITMASK_2X2);
return tile_map[p_id].autotile_data.bitmask_mode;
}
void TileSet::tile_set_texture(int p_id, const Ref<Texture2D> &p_texture) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].texture = p_texture;
emit_changed();
@@ -396,39 +398,33 @@ void TileSet::tile_set_texture(int p_id, const Ref<Texture2D> &p_texture) {
}
Ref<Texture2D> TileSet::tile_get_texture(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>());
return tile_map[p_id].texture;
}
void TileSet::tile_set_normal_map(int p_id, const Ref<Texture2D> &p_normal_map) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].normal_map = p_normal_map;
emit_changed();
}
Ref<Texture2D> TileSet::tile_get_normal_map(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>());
return tile_map[p_id].normal_map;
}
void TileSet::tile_set_material(int p_id, const Ref<ShaderMaterial> &p_material) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].material = p_material;
emit_changed();
}
Ref<ShaderMaterial> TileSet::tile_get_material(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<ShaderMaterial>());
return tile_map[p_id].material;
}
void TileSet::tile_set_modulate(int p_id, const Color &p_modulate) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].modulate = p_modulate;
emit_changed();
@@ -436,26 +432,22 @@ void TileSet::tile_set_modulate(int p_id, const Color &p_modulate) {
}
Color TileSet::tile_get_modulate(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Color(1, 1, 1));
return tile_map[p_id].modulate;
}
void TileSet::tile_set_texture_offset(int p_id, const Vector2 &p_offset) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].offset = p_offset;
emit_changed();
}
Vector2 TileSet::tile_get_texture_offset(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].offset;
}
void TileSet::tile_set_region(int p_id, const Rect2 &p_region) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].region = p_region;
emit_changed();
@@ -463,7 +455,6 @@ void TileSet::tile_set_region(int p_id, const Rect2 &p_region) {
}
Rect2 TileSet::tile_get_region(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Rect2());
return tile_map[p_id].region;
}
@@ -476,26 +467,22 @@ void TileSet::tile_set_tile_mode(int p_id, TileMode p_tile_mode) {
}
TileSet::TileMode TileSet::tile_get_tile_mode(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), SINGLE_TILE);
return tile_map[p_id].tile_mode;
}
void TileSet::autotile_set_icon_coordinate(int p_id, Vector2 coord) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].autotile_data.icon_coord = coord;
emit_changed();
}
Vector2 TileSet::autotile_get_icon_coordinate(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].autotile_data.icon_coord;
}
void TileSet::autotile_set_spacing(int p_id, int p_spacing) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_spacing < 0);
tile_map[p_id].autotile_data.spacing = p_spacing;
@@ -503,39 +490,33 @@ void TileSet::autotile_set_spacing(int p_id, int p_spacing) {
}
int TileSet::autotile_get_spacing(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 0);
return tile_map[p_id].autotile_data.spacing;
}
void TileSet::autotile_set_size(int p_id, Size2 p_size) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_size.x <= 0 || p_size.y <= 0);
tile_map[p_id].autotile_data.size = p_size;
}
Size2 TileSet::autotile_get_size(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Size2());
return tile_map[p_id].autotile_data.size;
}
void TileSet::autotile_clear_bitmask_map(int p_id) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].autotile_data.flags.clear();
}
void TileSet::autotile_set_subtile_priority(int p_id, const Vector2 &p_coord, int p_priority) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_priority <= 0);
tile_map[p_id].autotile_data.priority_map[p_coord] = p_priority;
}
int TileSet::autotile_get_subtile_priority(int p_id, const Vector2 &p_coord) {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 1);
if (tile_map[p_id].autotile_data.priority_map.has(p_coord)) {
return tile_map[p_id].autotile_data.priority_map[p_coord];
@@ -545,21 +526,18 @@ int TileSet::autotile_get_subtile_priority(int p_id, const Vector2 &p_coord) {
}
const Map<Vector2, int> &TileSet::autotile_get_priority_map(int p_id) const {
-
static Map<Vector2, int> dummy;
ERR_FAIL_COND_V(!tile_map.has(p_id), dummy);
return tile_map[p_id].autotile_data.priority_map;
}
void TileSet::autotile_set_z_index(int p_id, const Vector2 &p_coord, int p_z_index) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].autotile_data.z_index_map[p_coord] = p_z_index;
emit_changed();
}
int TileSet::autotile_get_z_index(int p_id, const Vector2 &p_coord) {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 1);
if (tile_map[p_id].autotile_data.z_index_map.has(p_coord)) {
return tile_map[p_id].autotile_data.z_index_map[p_coord];
@@ -569,25 +547,23 @@ int TileSet::autotile_get_z_index(int p_id, const Vector2 &p_coord) {
}
const Map<Vector2, int> &TileSet::autotile_get_z_index_map(int p_id) const {
-
static Map<Vector2, int> dummy;
ERR_FAIL_COND_V(!tile_map.has(p_id), dummy);
return tile_map[p_id].autotile_data.z_index_map;
}
void TileSet::autotile_set_bitmask(int p_id, Vector2 p_coord, uint32_t p_flag) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
if (p_flag == 0) {
- if (tile_map[p_id].autotile_data.flags.has(p_coord))
+ if (tile_map[p_id].autotile_data.flags.has(p_coord)) {
tile_map[p_id].autotile_data.flags.erase(p_coord);
+ }
} else {
tile_map[p_id].autotile_data.flags[p_coord] = p_flag;
}
}
uint32_t TileSet::autotile_get_bitmask(int p_id, Vector2 p_coord) {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 0);
if (!tile_map[p_id].autotile_data.flags.has(p_coord)) {
return 0;
@@ -596,7 +572,6 @@ uint32_t TileSet::autotile_get_bitmask(int p_id, Vector2 p_coord) {
}
const Map<Vector2, uint32_t> &TileSet::autotile_get_bitmask_map(int p_id) {
-
static Map<Vector2, uint32_t> dummy;
static Map<Vector2, uint32_t> dummy_atlas;
ERR_FAIL_COND_V(!tile_map.has(p_id), dummy);
@@ -611,12 +586,12 @@ const Map<Vector2, uint32_t> &TileSet::autotile_get_bitmask_map(int p_id) {
}
}
return dummy_atlas;
- } else
+ } else {
return tile_map[p_id].autotile_data.flags;
+ }
}
Vector2 TileSet::autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node, const Vector2 &p_tile_location) {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
//First try to forward selection to script
if (p_tilemap_node->get_class_name() == "TileMap") {
@@ -678,7 +653,6 @@ Vector2 TileSet::autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask,
}
Vector2 TileSet::atlastile_get_subtile_by_priority(int p_id, const Node *p_tilemap_node, const Vector2 &p_tile_location) {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
//First try to forward selection to script
if (get_script_instance() != nullptr) {
@@ -708,7 +682,6 @@ Vector2 TileSet::atlastile_get_subtile_by_priority(int p_id, const Node *p_tilem
}
void TileSet::tile_set_name(int p_id, const String &p_name) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].name = p_name;
emit_changed();
@@ -716,19 +689,16 @@ void TileSet::tile_set_name(int p_id, const String &p_name) {
}
String TileSet::tile_get_name(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), String());
return tile_map[p_id].name;
}
void TileSet::tile_clear_shapes(int p_id) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].shapes_data.clear();
}
void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transform2D &p_transform, bool p_one_way, const Vector2 &p_autotile_coord) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ShapeData new_data = ShapeData();
@@ -741,52 +711,51 @@ void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transf
}
int TileSet::tile_get_shape_count(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 0);
return tile_map[p_id].shapes_data.size();
}
void TileSet::tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_shape_id < 0);
- if (p_shape_id >= tile_map[p_id].shapes_data.size())
+ if (p_shape_id >= tile_map[p_id].shapes_data.size()) {
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
+ }
tile_map[p_id].shapes_data.write[p_shape_id].shape = p_shape;
_decompose_convex_shape(p_shape);
emit_changed();
}
Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Shape2D>());
ERR_FAIL_COND_V(p_shape_id < 0, Ref<Shape2D>());
- if (p_shape_id < tile_map[p_id].shapes_data.size())
+ if (p_shape_id < tile_map[p_id].shapes_data.size()) {
return tile_map[p_id].shapes_data[p_shape_id].shape;
+ }
return Ref<Shape2D>();
}
void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_shape_id < 0);
- if (p_shape_id >= tile_map[p_id].shapes_data.size())
+ if (p_shape_id >= tile_map[p_id].shapes_data.size()) {
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
+ }
tile_map[p_id].shapes_data.write[p_shape_id].shape_transform = p_offset;
emit_changed();
}
Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Transform2D());
ERR_FAIL_COND_V(p_shape_id < 0, Transform2D());
- if (p_shape_id < tile_map[p_id].shapes_data.size())
+ if (p_shape_id < tile_map[p_id].shapes_data.size()) {
return tile_map[p_id].shapes_data[p_shape_id].shape_transform;
+ }
return Transform2D();
}
@@ -802,57 +771,55 @@ Vector2 TileSet::tile_get_shape_offset(int p_id, int p_shape_id) const {
}
void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_way) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_shape_id < 0);
- if (p_shape_id >= tile_map[p_id].shapes_data.size())
+ if (p_shape_id >= tile_map[p_id].shapes_data.size()) {
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
+ }
tile_map[p_id].shapes_data.write[p_shape_id].one_way_collision = p_one_way;
emit_changed();
}
bool TileSet::tile_get_shape_one_way(int p_id, int p_shape_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), false);
ERR_FAIL_COND_V(p_shape_id < 0, false);
- if (p_shape_id < tile_map[p_id].shapes_data.size())
+ if (p_shape_id < tile_map[p_id].shapes_data.size()) {
return tile_map[p_id].shapes_data[p_shape_id].one_way_collision;
+ }
return false;
}
void TileSet::tile_set_shape_one_way_margin(int p_id, int p_shape_id, float p_margin) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
ERR_FAIL_COND(p_shape_id < 0);
- if (p_shape_id >= tile_map[p_id].shapes_data.size())
+ if (p_shape_id >= tile_map[p_id].shapes_data.size()) {
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
+ }
tile_map[p_id].shapes_data.write[p_shape_id].one_way_collision_margin = p_margin;
emit_changed();
}
float TileSet::tile_get_shape_one_way_margin(int p_id, int p_shape_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 0);
ERR_FAIL_COND_V(p_shape_id < 0, 0);
- if (p_shape_id < tile_map[p_id].shapes_data.size())
+ if (p_shape_id < tile_map[p_id].shapes_data.size()) {
return tile_map[p_id].shapes_data[p_shape_id].one_way_collision_margin;
+ }
return 0;
}
void TileSet::tile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].occluder = p_light_occluder;
}
Ref<OccluderPolygon2D> TileSet::tile_get_light_occluder(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<OccluderPolygon2D>());
return tile_map[p_id].occluder;
}
@@ -869,7 +836,6 @@ void TileSet::autotile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D>
}
Ref<OccluderPolygon2D> TileSet::autotile_get_light_occluder(int p_id, const Vector2 &p_coord) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<OccluderPolygon2D>());
if (!tile_map[p_id].autotile_data.occluder_map.has(p_coord)) {
@@ -880,38 +846,32 @@ Ref<OccluderPolygon2D> TileSet::autotile_get_light_occluder(int p_id, const Vect
}
void TileSet::tile_set_navigation_polygon_offset(int p_id, const Vector2 &p_offset) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].navigation_polygon_offset = p_offset;
}
Vector2 TileSet::tile_get_navigation_polygon_offset(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].navigation_polygon_offset;
}
void TileSet::tile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].navigation_polygon = p_navigation_polygon;
}
Ref<NavigationPolygon> TileSet::tile_get_navigation_polygon(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<NavigationPolygon>());
return tile_map[p_id].navigation_polygon;
}
const Map<Vector2, Ref<OccluderPolygon2D>> &TileSet::autotile_get_light_oclusion_map(int p_id) const {
-
static Map<Vector2, Ref<OccluderPolygon2D>> dummy;
ERR_FAIL_COND_V(!tile_map.has(p_id), dummy);
return tile_map[p_id].autotile_data.occluder_map;
}
void TileSet::autotile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon, const Vector2 &p_coord) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
if (p_navigation_polygon.is_null()) {
if (tile_map[p_id].autotile_data.navpoly_map.has(p_coord)) {
@@ -923,7 +883,6 @@ void TileSet::autotile_set_navigation_polygon(int p_id, const Ref<NavigationPoly
}
Ref<NavigationPolygon> TileSet::autotile_get_navigation_polygon(int p_id, const Vector2 &p_coord) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<NavigationPolygon>());
if (!tile_map[p_id].autotile_data.navpoly_map.has(p_coord)) {
return Ref<NavigationPolygon>();
@@ -933,26 +892,22 @@ Ref<NavigationPolygon> TileSet::autotile_get_navigation_polygon(int p_id, const
}
const Map<Vector2, Ref<NavigationPolygon>> &TileSet::autotile_get_navigation_map(int p_id) const {
-
static Map<Vector2, Ref<NavigationPolygon>> dummy;
ERR_FAIL_COND_V(!tile_map.has(p_id), dummy);
return tile_map[p_id].autotile_data.navpoly_map;
}
void TileSet::tile_set_occluder_offset(int p_id, const Vector2 &p_offset) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].occluder_offset = p_offset;
}
Vector2 TileSet::tile_get_occluder_offset(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].occluder_offset;
}
void TileSet::tile_set_shapes(int p_id, const Vector<ShapeData> &p_shapes) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].shapes_data = p_shapes;
for (int i = 0; i < p_shapes.size(); i++) {
@@ -962,27 +917,23 @@ void TileSet::tile_set_shapes(int p_id, const Vector<ShapeData> &p_shapes) {
}
Vector<TileSet::ShapeData> TileSet::tile_get_shapes(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Vector<ShapeData>());
return tile_map[p_id].shapes_data;
}
int TileSet::tile_get_z_index(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), 0);
return tile_map[p_id].z_index;
}
void TileSet::tile_set_z_index(int p_id, int p_z_index) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].z_index = p_z_index;
emit_changed();
}
void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
Vector<ShapeData> shapes_data;
Transform2D default_transform = tile_get_shape_transform(p_id, 0);
@@ -993,8 +944,9 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
if (p_shapes[i].get_type() == Variant::OBJECT) {
Ref<Shape2D> shape = p_shapes[i];
- if (shape.is_null())
+ if (shape.is_null()) {
continue;
+ }
s.shape = shape;
s.shape_transform = default_transform;
@@ -1006,30 +958,35 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
if (d.has("shape") && d["shape"].get_type() == Variant::OBJECT) {
s.shape = d["shape"];
_decompose_convex_shape(s.shape);
- } else
+ } else {
continue;
+ }
- if (d.has("shape_transform") && d["shape_transform"].get_type() == Variant::TRANSFORM2D)
+ if (d.has("shape_transform") && d["shape_transform"].get_type() == Variant::TRANSFORM2D) {
s.shape_transform = d["shape_transform"];
- else if (d.has("shape_offset") && d["shape_offset"].get_type() == Variant::VECTOR2)
+ } else if (d.has("shape_offset") && d["shape_offset"].get_type() == Variant::VECTOR2) {
s.shape_transform = Transform2D(0, (Vector2)d["shape_offset"]);
- else
+ } else {
s.shape_transform = default_transform;
+ }
- if (d.has("one_way") && d["one_way"].get_type() == Variant::BOOL)
+ if (d.has("one_way") && d["one_way"].get_type() == Variant::BOOL) {
s.one_way_collision = d["one_way"];
- else
+ } else {
s.one_way_collision = default_one_way;
+ }
- if (d.has("one_way_margin") && d["one_way_margin"].is_num())
+ if (d.has("one_way_margin") && d["one_way_margin"].is_num()) {
s.one_way_collision_margin = d["one_way_margin"];
- else
+ } else {
s.one_way_collision_margin = 1.0;
+ }
- if (d.has("autotile_coord") && d["autotile_coord"].get_type() == Variant::VECTOR2)
+ if (d.has("autotile_coord") && d["autotile_coord"].get_type() == Variant::VECTOR2) {
s.autotile_coord = d["autotile_coord"];
- else
+ } else {
s.autotile_coord = default_autotile_coord;
+ }
} else {
ERR_CONTINUE_MSG(true, "Expected an array of objects or dictionaries for tile_set_shapes.");
@@ -1043,7 +1000,6 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
}
Array TileSet::_tile_get_shapes(int p_id) const {
-
ERR_FAIL_COND_V(!tile_map.has(p_id), Array());
Array arr;
@@ -1062,7 +1018,6 @@ Array TileSet::_tile_get_shapes(int p_id) const {
}
Array TileSet::_get_tiles_ids() const {
-
Array arr;
for (Map<int, TileData>::Element *E = tile_map.front(); E; E = E->next()) {
@@ -1073,12 +1028,14 @@ Array TileSet::_get_tiles_ids() const {
}
void TileSet::_decompose_convex_shape(Ref<Shape2D> p_shape) {
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Ref<ConvexPolygonShape2D> convex = p_shape;
- if (!convex.is_valid())
+ if (!convex.is_valid()) {
return;
- Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(convex->get_points());
+ }
+ Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(convex->get_points());
if (decomp.size() > 1) {
Array sub_shapes;
for (int i = 0; i < decomp.size(); i++) {
@@ -1093,20 +1050,16 @@ void TileSet::_decompose_convex_shape(Ref<Shape2D> p_shape) {
}
void TileSet::get_tile_list(List<int> *p_tiles) const {
-
for (Map<int, TileData>::Element *E = tile_map.front(); E; E = E->next()) {
-
p_tiles->push_back(E->key());
}
}
bool TileSet::has_tile(int p_id) const {
-
return tile_map.has(p_id);
}
bool TileSet::is_tile_bound(int p_drawn_id, int p_neighbor_id) {
-
if (p_drawn_id == p_neighbor_id) {
return true;
} else if (get_script_instance() != nullptr) {
@@ -1121,7 +1074,6 @@ bool TileSet::is_tile_bound(int p_drawn_id, int p_neighbor_id) {
}
void TileSet::remove_tile(int p_id) {
-
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map.erase(p_id);
_change_notify("");
@@ -1129,32 +1081,29 @@ void TileSet::remove_tile(int p_id) {
}
int TileSet::get_last_unused_tile_id() const {
-
- if (tile_map.size())
+ if (tile_map.size()) {
return tile_map.back()->key() + 1;
- else
+ } else {
return 0;
+ }
}
int TileSet::find_tile_by_name(const String &p_name) const {
-
for (Map<int, TileData>::Element *E = tile_map.front(); E; E = E->next()) {
-
- if (p_name == E->get().name)
+ if (p_name == E->get().name) {
return E->key();
+ }
}
return -1;
}
void TileSet::clear() {
-
tile_map.clear();
_change_notify("");
emit_changed();
}
void TileSet::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("create_tile", "id"), &TileSet::create_tile);
ClassDB::bind_method(D_METHOD("autotile_clear_bitmask_map", "id"), &TileSet::autotile_clear_bitmask_map);
ClassDB::bind_method(D_METHOD("autotile_set_icon_coordinate", "id", "coord"), &TileSet::autotile_set_icon_coordinate);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 05b43dfb89..78f34e46ce 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -40,7 +40,6 @@
#include "scene/resources/texture.h"
class TileSet : public Resource {
-
GDCLASS(TileSet, Resource);
public:
@@ -48,13 +47,10 @@ public:
Ref<Shape2D> shape;
Transform2D shape_transform;
Vector2 autotile_coord;
- bool one_way_collision;
- float one_way_collision_margin;
+ bool one_way_collision = false;
+ float one_way_collision_margin = 1.0;
- ShapeData() {
- one_way_collision = false;
- one_way_collision_margin = 1.0;
- }
+ ShapeData() {}
};
enum BitmaskMode {
@@ -92,27 +88,22 @@ public:
};
struct AutotileData {
- BitmaskMode bitmask_mode;
- Size2 size;
- int spacing;
- Vector2 icon_coord;
+ BitmaskMode bitmask_mode = BITMASK_2X2;
+ // Default size to prevent invalid value
+ Size2 size = Size2(64, 64);
+ Vector2 icon_coord = Vector2(0, 0);
+ int spacing = 0;
Map<Vector2, uint32_t> flags;
Map<Vector2, Ref<OccluderPolygon2D>> occluder_map;
Map<Vector2, Ref<NavigationPolygon>> navpoly_map;
Map<Vector2, int> priority_map;
Map<Vector2, int> z_index_map;
- // Default size to prevent invalid value
- explicit AutotileData() :
- bitmask_mode(BITMASK_2X2),
- size(64, 64),
- spacing(0),
- icon_coord(0, 0) {}
+ explicit AutotileData() {}
};
private:
struct TileData {
-
String name;
Ref<Texture2D> texture;
Ref<Texture2D> normal_map;
@@ -124,16 +115,13 @@ private:
Vector2 navigation_polygon_offset;
Ref<NavigationPolygon> navigation_polygon;
Ref<ShaderMaterial> material;
- TileMode tile_mode;
- Color modulate;
+ TileMode tile_mode = SINGLE_TILE;
+ // Default modulate for back-compat
+ Color modulate = Color(1, 1, 1);
AutotileData autotile_data;
- int z_index;
+ int z_index = 0;
- // Default modulate for back-compat
- explicit TileData() :
- tile_mode(SINGLE_TILE),
- modulate(1, 1, 1),
- z_index(0) {}
+ explicit TileData() {}
};
Map<int, TileData> tile_map;
diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h
index a9b96214c3..379ba53a34 100644
--- a/scene/resources/video_stream.h
+++ b/scene/resources/video_stream.h
@@ -34,7 +34,6 @@
#include "scene/resources/texture.h"
class VideoStreamPlayback : public Resource {
-
GDCLASS(VideoStreamPlayback, Resource);
public:
@@ -68,7 +67,6 @@ public:
};
class VideoStream : public Resource {
-
GDCLASS(VideoStream, Resource);
OBJ_SAVE_TYPE(VideoStream); // Saves derived classes with common type so they can be interchanged.
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 5637aaec9a..8236f9a9e3 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -39,12 +39,10 @@ bool VisualShaderNode::is_simple_decl() const {
}
void VisualShaderNode::set_output_port_for_preview(int p_index) {
-
port_preview = p_index;
}
int VisualShaderNode::get_output_port_for_preview() const {
-
return port_preview;
}
@@ -68,6 +66,7 @@ bool VisualShaderNode::is_port_separator(int p_index) const {
Vector<VisualShader::DefaultTextureParam> VisualShaderNode::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const {
return Vector<VisualShader::DefaultTextureParam>();
}
+
String VisualShaderNode::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
return String();
}
@@ -85,7 +84,6 @@ Vector<StringName> VisualShaderNode::get_editable_properties() const {
}
Array VisualShaderNode::get_default_input_values() const {
-
Array ret;
for (Map<int, Variant>::Element *E = default_input_values.front(); E; E = E->next()) {
ret.push_back(E->key());
@@ -93,8 +91,8 @@ Array VisualShaderNode::get_default_input_values() const {
}
return ret;
}
-void VisualShaderNode::set_default_input_values(const Array &p_values) {
+void VisualShaderNode::set_default_input_values(const Array &p_values) {
if (p_values.size() % 2 == 0) {
for (int i = 0; i < p_values.size(); i += 2) {
default_input_values[p_values[i + 0]] = p_values[i + 1];
@@ -113,7 +111,6 @@ String VisualShaderNode::get_input_port_default_hint(int p_port) const {
}
void VisualShaderNode::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_output_port_for_preview", "port"), &VisualShaderNode::set_output_port_for_preview);
ClassDB::bind_method(D_METHOD("get_output_port_for_preview"), &VisualShaderNode::get_output_port_for_preview);
@@ -225,7 +222,6 @@ String VisualShaderNodeCustom::get_output_port_name(int p_port) const {
}
String VisualShaderNodeCustom::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
ERR_FAIL_COND_V(!get_script_instance(), "");
ERR_FAIL_COND_V(!get_script_instance()->has_method("_get_code"), "");
Array input_vars;
@@ -264,7 +260,6 @@ String VisualShaderNodeCustom::generate_global_per_node(Shader::Mode p_mode, Vis
}
void VisualShaderNodeCustom::_bind_methods() {
-
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_name"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_description"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_category"));
@@ -396,6 +391,7 @@ Vector<int> VisualShader::get_node_list(Type p_type) const {
return ret;
}
+
int VisualShader::get_valid_node_id(Type p_type) const {
ERR_FAIL_INDEX_V(p_type, TYPE_MAX, NODE_ID_INVALID);
const Graph *g = &graph[p_type];
@@ -404,8 +400,9 @@ int VisualShader::get_valid_node_id(Type p_type) const {
int VisualShader::find_node_id(Type p_type, const Ref<VisualShaderNode> &p_node) const {
for (const Map<int, Node>::Element *E = graph[p_type].nodes.front(); E; E = E->next()) {
- if (E->get().node == p_node)
+ if (E->get().node == p_node) {
return E->key();
+ }
}
return NODE_ID_INVALID;
@@ -445,7 +442,6 @@ bool VisualShader::is_node_connection(Type p_type, int p_from_node, int p_from_p
const Graph *g = &graph[p_type];
for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) {
-
if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) {
return true;
}
@@ -460,7 +456,6 @@ bool VisualShader::is_nodes_connected_relatively(const Graph *p_graph, int p_nod
const VisualShader::Node &node = p_graph->nodes[p_node];
for (const List<int>::Element *E = node.prev_connected_nodes.front(); E; E = E->next()) {
-
if (E->get() == p_target) {
return true;
}
@@ -474,24 +469,28 @@ bool VisualShader::is_nodes_connected_relatively(const Graph *p_graph, int p_nod
}
bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const {
-
ERR_FAIL_INDEX_V(p_type, TYPE_MAX, false);
const Graph *g = &graph[p_type];
- if (!g->nodes.has(p_from_node))
+ if (!g->nodes.has(p_from_node)) {
return false;
+ }
- if (p_from_node == p_to_node)
+ if (p_from_node == p_to_node) {
return false;
+ }
- if (p_from_port < 0 || p_from_port >= g->nodes[p_from_node].node->get_output_port_count())
+ if (p_from_port < 0 || p_from_port >= g->nodes[p_from_node].node->get_output_port_count()) {
return false;
+ }
- if (!g->nodes.has(p_to_node))
+ if (!g->nodes.has(p_to_node)) {
return false;
+ }
- if (p_to_port < 0 || p_to_port >= g->nodes[p_to_node].node->get_input_port_count())
+ if (p_to_port < 0 || p_to_port >= g->nodes[p_to_node].node->get_input_port_count()) {
return false;
+ }
VisualShaderNode::PortType from_port_type = g->nodes[p_from_node].node->get_output_port_type(p_from_port);
VisualShaderNode::PortType to_port_type = g->nodes[p_to_node].node->get_input_port_type(p_to_port);
@@ -501,14 +500,14 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po
}
for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) {
-
if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) {
return false;
}
}
- if (is_nodes_connected_relatively(g, p_from_node, p_to_node))
+ if (is_nodes_connected_relatively(g, p_from_node, p_to_node)) {
return false;
+ }
return true;
}
@@ -546,7 +545,6 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port,
ERR_FAIL_COND_V_MSG(!is_port_types_compatible(from_port_type, to_port_type), ERR_INVALID_PARAMETER, "Incompatible port types (scalar/vec/bool) with transform.");
for (List<Connection>::Element *E = g->connections.front(); E; E = E->next()) {
-
if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) {
ERR_FAIL_V(ERR_ALREADY_EXISTS);
}
@@ -569,7 +567,6 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por
Graph *g = &graph[p_type];
for (List<Connection>::Element *E = g->connections.front(); E; E = E->next()) {
-
if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) {
g->connections.erase(E);
g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node);
@@ -615,9 +612,7 @@ void VisualShader::set_mode(Mode p_mode) {
flags.clear();
shader_mode = p_mode;
for (int i = 0; i < TYPE_MAX; i++) {
-
for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) {
-
Ref<VisualShaderNodeInput> input = E->get().node;
if (input.is_valid()) {
input->shader_mode = shader_mode;
@@ -630,7 +625,6 @@ void VisualShader::set_mode(Mode p_mode) {
// clear connections since they are no longer valid
for (List<Connection>::Element *E = graph[i].connections.front(); E;) {
-
bool keep = true;
List<Connection>::Element *N = E->next();
@@ -684,7 +678,6 @@ bool VisualShader::is_text_shader() const {
}
String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &default_tex_params) const {
-
Ref<VisualShaderNode> node = get_node(p_type, p_node);
ERR_FAIL_COND_V(!node.is_valid(), String());
ERR_FAIL_COND_V(p_port < 0 || p_port >= node->get_output_port_count(), String());
@@ -703,7 +696,6 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port
for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) {
Ref<VisualShaderNodeGlobalExpression> global_expression = Object::cast_to<VisualShaderNodeGlobalExpression>(E->get().node.ptr());
if (global_expression.is_valid()) {
-
String expr = "";
expr += "// " + global_expression->get_caption() + ":" + itos(index++) + "\n";
expr += global_expression->generate_global(get_mode(), Type(i), -1);
@@ -772,7 +764,6 @@ String VisualShader::validate_port_name(const String &p_name, const List<String>
}
if (name != String()) {
-
String valid_name;
for (int i = 0; i < name.length(); i++) {
@@ -813,13 +804,11 @@ String VisualShader::validate_port_name(const String &p_name, const List<String>
}
String VisualShader::validate_uniform_name(const String &p_name, const Ref<VisualShaderNodeUniform> &p_uniform) const {
-
String name = p_name; //validate name first
while (name.length() && !IS_INITIAL_CHAR(name[0])) {
name = name.substr(1, name.length() - 1);
}
if (name != String()) {
-
String valid_name;
for (int i = 0; i < name.length(); i++) {
@@ -840,7 +829,6 @@ String VisualShader::validate_uniform_name(const String &p_name, const Ref<Visua
int attempt = 1;
while (true) {
-
bool exists = false;
for (int i = 0; i < TYPE_MAX; i++) {
for (const Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) {
@@ -890,7 +878,6 @@ static const char *type_string[VisualShader::TYPE_MAX] = {
"light"
};
bool VisualShader::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name;
if (name == "mode") {
set_mode(Shader::Mode(int(p_value)));
@@ -927,7 +914,6 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) {
String index = name.get_slicec('/', 2);
if (index == "connections") {
-
Vector<int> conns = p_value;
if (conns.size() % 4 == 0) {
for (int i = 0; i < conns.size(); i += 4) {
@@ -964,7 +950,6 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) {
}
bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name;
if (name == "mode") {
r_ret = get_mode();
@@ -993,7 +978,6 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const {
String index = name.get_slicec('/', 2);
if (index == "connections") {
-
Vector<int> conns;
for (const List<Connection>::Element *E = graph[type].connections.front(); E; E = E->next()) {
conns.push_back(E->get().from_node);
@@ -1074,13 +1058,11 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < TYPE_MAX; i++) {
for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) {
-
String prop_name = "nodes/";
prop_name += type_string[i];
prop_name += "/" + itos(E->key());
if (E->key() != NODE_ID_OUTPUT) {
-
p_list->push_back(PropertyInfo(Variant::OBJECT, prop_name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "VisualShaderNode", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE));
}
p_list->push_back(PropertyInfo(Variant::VECTOR2, prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
@@ -1099,7 +1081,6 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
}
Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBuilder &global_code_per_node, Map<Type, StringBuilder> &global_code_per_func, StringBuilder &code, Vector<VisualShader::DefaultTextureParam> &def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &output_connections, int node, Set<int> &processed, bool for_preview, Set<StringName> &r_classes) const {
-
const Ref<VisualShaderNode> vsnode = graph[type].nodes[node].node;
//check inputs recursively first
@@ -1116,8 +1097,9 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
}
Error err = _write_node(type, global_code, global_code_per_node, global_code_per_func, code, def_tex_params, input_connections, output_connections, from_node, processed, for_preview, r_classes);
- if (err)
+ if (err) {
return err;
+ }
}
}
@@ -1181,7 +1163,6 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
inputs[i] = "int(" + src_var + ")";
}
} else {
-
Variant defval = vsnode->get_input_port_default_value(i);
if (defval.get_type() == Variant::FLOAT) {
float val = defval;
@@ -1283,12 +1264,11 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
bool skip_global = input.is_valid() && for_preview;
if (!skip_global) {
-
global_code += vsnode->generate_global(get_mode(), type, node);
String class_name = vsnode->get_class_name();
if (class_name == "VisualShaderNodeCustom") {
- class_name = vsnode->get_script_instance()->get_script()->get_language()->get_global_class_name(vsnode->get_script_instance()->get_script()->get_path());
+ class_name = vsnode->get_script_instance()->get_script()->get_path();
}
if (!r_classes.has(class_name)) {
global_code_per_node += vsnode->generate_global_per_node(get_mode(), type, node);
@@ -1308,8 +1288,9 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
}
void VisualShader::_update_shader() const {
- if (!dirty)
+ if (!dirty) {
return;
+ }
dirty = false;
@@ -1330,11 +1311,8 @@ void VisualShader::_update_shader() const {
//fill render mode enums
int idx = 0;
while (render_mode_enums[idx].string) {
-
if (shader_mode == render_mode_enums[idx].mode) {
-
if (modes.has(render_mode_enums[idx].string)) {
-
int which = modes[render_mode_enums[idx].string];
int count = 0;
for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) {
@@ -1357,7 +1335,6 @@ void VisualShader::_update_shader() const {
//fill render mode flags
for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) {
-
String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i];
if (flags.has(mode)) {
if (render_mode != String()) {
@@ -1369,7 +1346,6 @@ void VisualShader::_update_shader() const {
}
if (render_mode != String()) {
-
global_code += "render_mode " + render_mode + ";\n\n";
}
@@ -1377,7 +1353,6 @@ void VisualShader::_update_shader() const {
String global_expressions;
for (int i = 0, index = 0; i < TYPE_MAX; i++) {
-
if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) {
continue;
}
@@ -1385,7 +1360,6 @@ void VisualShader::_update_shader() const {
for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) {
Ref<VisualShaderNodeGlobalExpression> global_expression = Object::cast_to<VisualShaderNodeGlobalExpression>(E->get().node.ptr());
if (global_expression.is_valid()) {
-
String expr = "";
expr += "// " + global_expression->get_caption() + ":" + itos(index++) + "\n";
expr += global_expression->generate_global(get_mode(), Type(i), -1);
@@ -1397,7 +1371,6 @@ void VisualShader::_update_shader() const {
}
for (int i = 0; i < TYPE_MAX; i++) {
-
if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) {
continue;
}
@@ -1483,7 +1456,6 @@ void VisualShader::rebuild() {
}
void VisualShader::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &VisualShader::set_mode);
ClassDB::bind_method(D_METHOD("add_node", "type", "node", "position", "id"), &VisualShader::add_node);
@@ -1762,26 +1734,25 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = {
};
int VisualShaderNodeInput::get_input_port_count() const {
-
return 0;
}
-VisualShaderNodeInput::PortType VisualShaderNodeInput::get_input_port_type(int p_port) const {
+VisualShaderNodeInput::PortType VisualShaderNodeInput::get_input_port_type(int p_port) const {
return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeInput::get_input_port_name(int p_port) const {
+String VisualShaderNodeInput::get_input_port_name(int p_port) const {
return "";
}
int VisualShaderNodeInput::get_output_port_count() const {
-
return 1;
}
-VisualShaderNodeInput::PortType VisualShaderNodeInput::get_output_port_type(int p_port) const {
+VisualShaderNodeInput::PortType VisualShaderNodeInput::get_output_port_type(int p_port) const {
return get_input_type_by_name(input_name);
}
+
String VisualShaderNodeInput::get_output_port_name(int p_port) const {
return "";
}
@@ -1791,7 +1762,6 @@ String VisualShaderNodeInput::get_caption() const {
}
String VisualShaderNodeInput::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
if (get_output_port_type(0) == PORT_TYPE_SAMPLER) {
return "";
}
@@ -1868,7 +1838,6 @@ String VisualShaderNodeInput::get_input_name() const {
}
String VisualShaderNodeInput::get_input_real_name() const {
-
int idx = 0;
while (ports[idx].mode != Shader::MODE_MAX) {
@@ -1882,7 +1851,6 @@ String VisualShaderNodeInput::get_input_real_name() const {
}
VisualShaderNodeInput::PortType VisualShaderNodeInput::get_input_type_by_name(String p_name) const {
-
int idx = 0;
while (ports[idx].mode != Shader::MODE_MAX) {
@@ -1944,7 +1912,6 @@ String VisualShaderNodeInput::get_input_index_name(int p_index) const {
}
void VisualShaderNodeInput::_validate_property(PropertyInfo &property) const {
-
if (property.name == "input_name") {
String port_list;
@@ -1974,7 +1941,6 @@ Vector<StringName> VisualShaderNodeInput::get_editable_properties() const {
}
void VisualShaderNodeInput::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_input_name", "name"), &VisualShaderNodeInput::set_input_name);
ClassDB::bind_method(D_METHOD("get_input_name"), &VisualShaderNodeInput::get_input_name);
ClassDB::bind_method(D_METHOD("get_input_real_name"), &VisualShaderNodeInput::get_input_real_name);
@@ -1982,6 +1948,7 @@ void VisualShaderNodeInput::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "input_name", PROPERTY_HINT_ENUM, ""), "set_input_name", "get_input_name");
ADD_SIGNAL(MethodInfo("input_type_changed"));
}
+
VisualShaderNodeInput::VisualShaderNodeInput() {
input_name = "[None]";
// changed when set
@@ -2060,7 +2027,6 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = {
};
int VisualShaderNodeOutput::get_input_port_count() const {
-
int idx = 0;
int count = 0;
@@ -2075,7 +2041,6 @@ int VisualShaderNodeOutput::get_input_port_count() const {
}
VisualShaderNodeOutput::PortType VisualShaderNodeOutput::get_input_port_type(int p_port) const {
-
int idx = 0;
int count = 0;
@@ -2093,7 +2058,6 @@ VisualShaderNodeOutput::PortType VisualShaderNodeOutput::get_input_port_type(int
}
String VisualShaderNodeOutput::get_input_port_name(int p_port) const {
-
int idx = 0;
int count = 0;
@@ -2115,18 +2079,18 @@ Variant VisualShaderNodeOutput::get_input_port_default_value(int p_port) const {
}
int VisualShaderNodeOutput::get_output_port_count() const {
-
return 0;
}
+
VisualShaderNodeOutput::PortType VisualShaderNodeOutput::get_output_port_type(int p_port) const {
return PORT_TYPE_SCALAR;
}
+
String VisualShaderNodeOutput::get_output_port_name(int p_port) const {
return String();
}
bool VisualShaderNodeOutput::is_port_separator(int p_index) const {
-
if (shader_mode == Shader::MODE_SPATIAL && shader_type == VisualShader::TYPE_FRAGMENT) {
String name = get_input_port_name(p_index);
return (name == "Normal" || name == "Rim" || name == "Alpha Scissor");
@@ -2139,14 +2103,12 @@ String VisualShaderNodeOutput::get_caption() const {
}
String VisualShaderNodeOutput::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
int idx = 0;
int count = 0;
String code;
while (ports[idx].mode != Shader::MODE_MAX) {
if (ports[idx].mode == shader_mode && ports[idx].shader_type == shader_type) {
-
if (p_input_vars[count] != String()) {
String s = ports[idx].string;
if (s.find(":") != -1) {
@@ -2188,7 +2150,6 @@ VisualShaderNodeUniform::Qualifier VisualShaderNodeUniform::get_qualifier() cons
}
void VisualShaderNodeUniform::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_uniform_name", "name"), &VisualShaderNodeUniform::set_uniform_name);
ClassDB::bind_method(D_METHOD("get_uniform_name"), &VisualShaderNodeUniform::get_uniform_name);
@@ -2218,7 +2179,6 @@ String VisualShaderNodeUniform::_get_qual_str() const {
}
String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const {
-
List<String> keyword_list;
ShaderLanguage::get_keyword_list(&keyword_list);
if (keyword_list.find(uniform_name)) {
@@ -2256,9 +2216,9 @@ Vector2 VisualShaderNodeGroupBase::get_size() const {
}
void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) {
-
- if (inputs == p_inputs)
+ if (inputs == p_inputs) {
return;
+ }
clear_input_ports();
@@ -2269,7 +2229,6 @@ void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) {
int input_port_count = input_strings.size();
for (int i = 0; i < input_port_count; i++) {
-
Vector<String> arr = input_strings[i].split(",");
ERR_FAIL_COND(arr.size() != 3);
@@ -2289,9 +2248,9 @@ String VisualShaderNodeGroupBase::get_inputs() const {
}
void VisualShaderNodeGroupBase::set_outputs(const String &p_outputs) {
-
- if (outputs == p_outputs)
+ if (outputs == p_outputs) {
return;
+ }
clear_output_ports();
@@ -2302,7 +2261,6 @@ void VisualShaderNodeGroupBase::set_outputs(const String &p_outputs) {
int output_port_count = output_strings.size();
for (int i = 0; i < output_port_count; i++) {
-
Vector<String> arr = output_strings[i].split(",");
ERR_FAIL_COND(arr.size() != 3);
@@ -2339,7 +2297,6 @@ bool VisualShaderNodeGroupBase::is_valid_port_name(const String &p_name) const {
}
void VisualShaderNodeGroupBase::add_input_port(int p_id, int p_type, const String &p_name) {
-
String str = itos(p_id) + "," + itos(p_type) + "," + p_name + ";";
Vector<String> inputs_strings = inputs.split(";", false);
int index = 0;
@@ -2376,7 +2333,6 @@ void VisualShaderNodeGroupBase::add_input_port(int p_id, int p_type, const Strin
}
void VisualShaderNodeGroupBase::remove_input_port(int p_id) {
-
ERR_FAIL_COND(!has_input_port(p_id));
Vector<String> inputs_strings = inputs.split(";", false);
@@ -2409,7 +2365,6 @@ bool VisualShaderNodeGroupBase::has_input_port(int p_id) const {
}
void VisualShaderNodeGroupBase::add_output_port(int p_id, int p_type, const String &p_name) {
-
String str = itos(p_id) + "," + itos(p_type) + "," + p_name + ";";
Vector<String> outputs_strings = outputs.split(";", false);
int index = 0;
@@ -2446,7 +2401,6 @@ void VisualShaderNodeGroupBase::add_output_port(int p_id, int p_type, const Stri
}
void VisualShaderNodeGroupBase::remove_output_port(int p_id) {
-
ERR_FAIL_COND(!has_output_port(p_id));
Vector<String> outputs_strings = outputs.split(";", false);
@@ -2487,12 +2441,12 @@ void VisualShaderNodeGroupBase::clear_output_ports() {
}
void VisualShaderNodeGroupBase::set_input_port_type(int p_id, int p_type) {
-
ERR_FAIL_COND(!has_input_port(p_id));
ERR_FAIL_COND(p_type < 0 || p_type >= PORT_TYPE_MAX);
- if (input_ports[p_id].type == p_type)
+ if (input_ports[p_id].type == p_type) {
return;
+ }
Vector<String> inputs_strings = inputs.split(";", false);
int count = 0;
@@ -2522,12 +2476,12 @@ VisualShaderNodeGroupBase::PortType VisualShaderNodeGroupBase::get_input_port_ty
}
void VisualShaderNodeGroupBase::set_input_port_name(int p_id, const String &p_name) {
-
ERR_FAIL_COND(!has_input_port(p_id));
ERR_FAIL_COND(!is_valid_port_name(p_name));
- if (input_ports[p_id].name == p_name)
+ if (input_ports[p_id].name == p_name) {
return;
+ }
Vector<String> inputs_strings = inputs.split(";", false);
int count = 0;
@@ -2557,12 +2511,12 @@ String VisualShaderNodeGroupBase::get_input_port_name(int p_id) const {
}
void VisualShaderNodeGroupBase::set_output_port_type(int p_id, int p_type) {
-
ERR_FAIL_COND(!has_output_port(p_id));
ERR_FAIL_COND(p_type < 0 || p_type >= PORT_TYPE_MAX);
- if (output_ports[p_id].type == p_type)
+ if (output_ports[p_id].type == p_type) {
return;
+ }
Vector<String> output_strings = outputs.split(";", false);
int count = 0;
@@ -2592,12 +2546,12 @@ VisualShaderNodeGroupBase::PortType VisualShaderNodeGroupBase::get_output_port_t
}
void VisualShaderNodeGroupBase::set_output_port_name(int p_id, const String &p_name) {
-
ERR_FAIL_COND(!has_output_port(p_id));
ERR_FAIL_COND(!is_valid_port_name(p_name));
- if (output_ports[p_id].name == p_name)
+ if (output_ports[p_id].name == p_name) {
return;
+ }
Vector<String> output_strings = outputs.split(";", false);
int count = 0;
@@ -2644,7 +2598,6 @@ Control *VisualShaderNodeGroupBase::get_control(int p_index) {
}
void VisualShaderNodeGroupBase::_apply_port_changes() {
-
Vector<String> inputs_strings = inputs.split(";", false);
Vector<String> outputs_strings = outputs.split(";", false);
@@ -2680,7 +2633,6 @@ bool VisualShaderNodeGroupBase::is_editable() const {
}
void VisualShaderNodeGroupBase::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_size", "size"), &VisualShaderNodeGroupBase::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &VisualShaderNodeGroupBase::get_size);
@@ -2742,7 +2694,6 @@ String VisualShaderNodeExpression::get_expression() const {
}
String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String _expression = expression;
_expression = _expression.insert(0, "\n");
@@ -2842,7 +2793,6 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
}
void VisualShaderNodeExpression::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_expression", "expression"), &VisualShaderNodeExpression::set_expression);
ClassDB::bind_method(D_METHOD("get_expression"), &VisualShaderNodeExpression::get_expression);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 56f8e74d2b..8bd09df512 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -98,7 +98,6 @@ private:
void _queue_update();
union ConnectionKey {
-
struct {
uint64_t node : 32;
uint64_t port : 32;
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 03db8c3ac5..87720cf110 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -65,13 +65,11 @@ String VisualShaderNodeFloatConstant::generate_code(Shader::Mode p_mode, VisualS
}
void VisualShaderNodeFloatConstant::set_constant(float p_value) {
-
constant = p_value;
emit_changed();
}
float VisualShaderNodeFloatConstant::get_constant() const {
-
return constant;
}
@@ -82,7 +80,6 @@ Vector<StringName> VisualShaderNodeFloatConstant::get_editable_properties() cons
}
void VisualShaderNodeFloatConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeFloatConstant::set_constant);
ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeFloatConstant::get_constant);
@@ -143,7 +140,6 @@ Vector<StringName> VisualShaderNodeIntConstant::get_editable_properties() const
}
void VisualShaderNodeIntConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeIntConstant::set_constant);
ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeIntConstant::get_constant);
@@ -204,7 +200,6 @@ Vector<StringName> VisualShaderNodeBooleanConstant::get_editable_properties() co
}
void VisualShaderNodeBooleanConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeBooleanConstant::set_constant);
ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeBooleanConstant::get_constant);
@@ -246,7 +241,6 @@ String VisualShaderNodeColorConstant::get_output_port_name(int p_port) const {
}
String VisualShaderNodeColorConstant::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code;
code += "\t" + p_output_vars[0] + " = " + vformat("vec3(%.6f, %.6f, %.6f)", constant.r, constant.g, constant.b) + ";\n";
code += "\t" + p_output_vars[1] + " = " + vformat("%.6f", constant.a) + ";\n";
@@ -255,13 +249,11 @@ String VisualShaderNodeColorConstant::generate_code(Shader::Mode p_mode, VisualS
}
void VisualShaderNodeColorConstant::set_constant(Color p_value) {
-
constant = p_value;
emit_changed();
}
Color VisualShaderNodeColorConstant::get_constant() const {
-
return constant;
}
@@ -272,7 +264,6 @@ Vector<StringName> VisualShaderNodeColorConstant::get_editable_properties() cons
}
void VisualShaderNodeColorConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeColorConstant::set_constant);
ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeColorConstant::get_constant);
@@ -318,13 +309,11 @@ String VisualShaderNodeVec3Constant::generate_code(Shader::Mode p_mode, VisualSh
}
void VisualShaderNodeVec3Constant::set_constant(Vector3 p_value) {
-
constant = p_value;
emit_changed();
}
Vector3 VisualShaderNodeVec3Constant::get_constant() const {
-
return constant;
}
@@ -335,7 +324,6 @@ Vector<StringName> VisualShaderNodeVec3Constant::get_editable_properties() const
}
void VisualShaderNodeVec3Constant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeVec3Constant::set_constant);
ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeVec3Constant::get_constant);
@@ -388,13 +376,11 @@ String VisualShaderNodeTransformConstant::generate_code(Shader::Mode p_mode, Vis
}
void VisualShaderNodeTransformConstant::set_constant(Transform p_value) {
-
constant = p_value;
emit_changed();
}
Transform VisualShaderNodeTransformConstant::get_constant() const {
-
return constant;
}
@@ -405,7 +391,6 @@ Vector<StringName> VisualShaderNodeTransformConstant::get_editable_properties()
}
void VisualShaderNodeTransformConstant::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_constant", "value"), &VisualShaderNodeTransformConstant::set_constant);
ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeTransformConstant::get_constant);
@@ -426,7 +411,6 @@ int VisualShaderNodeTexture::get_input_port_count() const {
}
VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_input_port_type(int p_port) const {
-
switch (p_port) {
case 0:
return PORT_TYPE_VECTOR;
@@ -440,7 +424,6 @@ VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_input_port_type(i
}
String VisualShaderNodeTexture::get_input_port_name(int p_port) const {
-
switch (p_port) {
case 0:
return "uv";
@@ -458,14 +441,16 @@ int VisualShaderNodeTexture::get_output_port_count() const {
}
VisualShaderNodeTexture::PortType VisualShaderNodeTexture::get_output_port_type(int p_port) const {
- if (p_port == 0 && source == SOURCE_DEPTH)
+ if (p_port == 0 && source == SOURCE_DEPTH) {
return PORT_TYPE_SCALAR;
+ }
return p_port == 0 ? PORT_TYPE_VECTOR : PORT_TYPE_SCALAR;
}
String VisualShaderNodeTexture::get_output_port_name(int p_port) const {
- if (p_port == 0 && source == SOURCE_DEPTH)
+ if (p_port == 0 && source == SOURCE_DEPTH) {
return "depth";
+ }
return p_port == 0 ? "rgb" : "alpha";
}
@@ -477,7 +462,6 @@ String VisualShaderNodeTexture::get_input_port_default_hint(int p_port) const {
}
static String make_unique_id(VisualShader::Type p_type, int p_id, const String &p_name) {
-
static const char *typepf[VisualShader::TYPE_MAX] = { "vtx", "frg", "lgt" };
return p_name + "_" + String(typepf[p_type]) + "_" + itos(p_id);
}
@@ -492,9 +476,7 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeTexture::get_default_t
}
String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
-
if (source == SOURCE_TEXTURE) {
-
String u = "uniform sampler2D " + make_unique_id(p_type, p_id, "tex");
switch (texture_type) {
case TYPE_DATA:
@@ -513,7 +495,6 @@ String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShade
}
String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
if (source == SOURCE_TEXTURE) {
String id = make_unique_id(p_type, p_id, "tex");
String code;
@@ -568,7 +549,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
}
if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) {
-
String code = "\t{\n";
if (p_input_vars[0] == String() || p_for_preview) { // Use UV by default.
@@ -592,7 +572,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
}
if (source == SOURCE_2D_TEXTURE && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) {
-
String code = "\t{\n";
if (p_input_vars[0] == String()) { // Use UV by default.
@@ -616,7 +595,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
}
if (source == SOURCE_2D_NORMAL && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) {
-
String code = "\t{\n";
if (p_input_vars[0] == String()) { // Use UV by default.
@@ -650,7 +628,6 @@ String VisualShaderNodeTexture::generate_code(Shader::Mode p_mode, VisualShader:
}
if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) {
-
String code = "\t{\n";
if (p_input_vars[0] == String()) { // Use UV by default.
@@ -716,13 +693,11 @@ VisualShaderNodeTexture::Source VisualShaderNodeTexture::get_source() const {
}
void VisualShaderNodeTexture::set_texture(Ref<Texture2D> p_value) {
-
texture = p_value;
emit_changed();
}
Ref<Texture2D> VisualShaderNodeTexture::get_texture() const {
-
return texture;
}
@@ -746,7 +721,6 @@ Vector<StringName> VisualShaderNodeTexture::get_editable_properties() const {
}
String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const {
-
if (source == SOURCE_TEXTURE) {
return String(); // all good
}
@@ -756,22 +730,18 @@ String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::T
}
if (source == SOURCE_SCREEN && (p_mode == Shader::MODE_SPATIAL || p_mode == Shader::MODE_CANVAS_ITEM) && p_type == VisualShader::TYPE_FRAGMENT) {
-
return String(); // all good
}
if (source == SOURCE_2D_TEXTURE && p_mode == Shader::MODE_CANVAS_ITEM && p_type == VisualShader::TYPE_FRAGMENT) {
-
return String(); // all good
}
if (source == SOURCE_2D_NORMAL && p_mode == Shader::MODE_CANVAS_ITEM) {
-
return String(); // all good
}
if (source == SOURCE_DEPTH && p_mode == Shader::MODE_SPATIAL && p_type == VisualShader::TYPE_FRAGMENT) {
-
if (get_output_port_for_preview() == 0) { // DEPTH_TEXTURE is not supported in preview(canvas_item) shader
return TTR("Invalid source for preview.");
}
@@ -782,7 +752,6 @@ String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::T
}
void VisualShaderNodeTexture::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeTexture::set_source);
ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeTexture::get_source);
@@ -870,7 +839,6 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubemap::get_default_t
}
String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
-
if (source == SOURCE_TEXTURE) {
String u = "uniform samplerCube " + make_unique_id(p_type, p_id, "cube");
switch (texture_type) {
@@ -889,7 +857,6 @@ String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShade
}
String VisualShaderNodeCubemap::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code;
String id;
if (source == SOURCE_TEXTURE) {
@@ -949,13 +916,11 @@ VisualShaderNodeCubemap::Source VisualShaderNodeCubemap::get_source() const {
}
void VisualShaderNodeCubemap::set_cube_map(Ref<Cubemap> p_value) {
-
cube_map = p_value;
emit_changed();
}
Ref<Cubemap> VisualShaderNodeCubemap::get_cube_map() const {
-
return cube_map;
}
@@ -979,7 +944,6 @@ Vector<StringName> VisualShaderNodeCubemap::get_editable_properties() const {
}
void VisualShaderNodeCubemap::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubemap::set_source);
ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubemap::get_source);
@@ -1038,10 +1002,8 @@ String VisualShaderNodeFloatOp::get_output_port_name(int p_port) const {
}
String VisualShaderNodeFloatOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code = "\t" + p_output_vars[0] + " = ";
switch (op) {
-
case OP_ADD:
code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n";
break;
@@ -1078,13 +1040,11 @@ String VisualShaderNodeFloatOp::generate_code(Shader::Mode p_mode, VisualShader:
}
void VisualShaderNodeFloatOp::set_operator(Operator p_op) {
-
op = p_op;
emit_changed();
}
VisualShaderNodeFloatOp::Operator VisualShaderNodeFloatOp::get_operator() const {
-
return op;
}
@@ -1095,7 +1055,6 @@ Vector<StringName> VisualShaderNodeFloatOp::get_editable_properties() const {
}
void VisualShaderNodeFloatOp::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeFloatOp::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeFloatOp::get_operator);
@@ -1150,10 +1109,8 @@ String VisualShaderNodeIntOp::get_output_port_name(int p_port) const {
}
String VisualShaderNodeIntOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code = "\t" + p_output_vars[0] + " = ";
switch (op) {
-
case OP_ADD:
code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n";
break;
@@ -1181,7 +1138,6 @@ String VisualShaderNodeIntOp::generate_code(Shader::Mode p_mode, VisualShader::T
}
void VisualShaderNodeIntOp::set_operator(Operator p_op) {
-
op = p_op;
emit_changed();
}
@@ -1197,7 +1153,6 @@ Vector<StringName> VisualShaderNodeIntOp::get_editable_properties() const {
}
void VisualShaderNodeIntOp::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeIntOp::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeIntOp::get_operator);
@@ -1249,10 +1204,8 @@ String VisualShaderNodeVectorOp::get_output_port_name(int p_port) const {
}
String VisualShaderNodeVectorOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code = "\t" + p_output_vars[0] + " = ";
switch (op) {
-
case OP_ADD:
code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n";
break;
@@ -1295,13 +1248,11 @@ String VisualShaderNodeVectorOp::generate_code(Shader::Mode p_mode, VisualShader
}
void VisualShaderNodeVectorOp::set_operator(Operator p_op) {
-
op = p_op;
emit_changed();
}
VisualShaderNodeVectorOp::Operator VisualShaderNodeVectorOp::get_operator() const {
-
return op;
}
@@ -1312,7 +1263,6 @@ Vector<StringName> VisualShaderNodeVectorOp::get_editable_properties() const {
}
void VisualShaderNodeVectorOp::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeVectorOp::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeVectorOp::get_operator);
@@ -1369,29 +1319,23 @@ String VisualShaderNodeColorOp::get_output_port_name(int p_port) const {
}
String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code;
static const char *axisn[3] = { "x", "y", "z" };
switch (op) {
case OP_SCREEN: {
-
code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") * (vec3(1.0) - " + p_input_vars[1] + ");\n";
} break;
case OP_DIFFERENCE: {
-
code += "\t" + p_output_vars[0] + " = abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ");\n";
} break;
case OP_DARKEN: {
-
code += "\t" + p_output_vars[0] + " = min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
} break;
case OP_LIGHTEN: {
-
code += "\t" + p_output_vars[0] + " = max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n";
} break;
case OP_OVERLAY: {
-
for (int i = 0; i < 3; i++) {
code += "\t{\n";
code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n";
@@ -1406,16 +1350,13 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
} break;
case OP_DODGE: {
-
code += "\t" + p_output_vars[0] + " = (" + p_input_vars[0] + ") / (vec3(1.0) - " + p_input_vars[1] + ");\n";
} break;
case OP_BURN: {
-
code += "\t" + p_output_vars[0] + " = vec3(1.0) - (vec3(1.0) - " + p_input_vars[0] + ") / (" + p_input_vars[1] + ");\n";
} break;
case OP_SOFT_LIGHT: {
-
for (int i = 0; i < 3; i++) {
code += "\t{\n";
code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n";
@@ -1430,7 +1371,6 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
} break;
case OP_HARD_LIGHT: {
-
for (int i = 0; i < 3; i++) {
code += "\t{\n";
code += "\t\tfloat base = " + p_input_vars[0] + "." + axisn[i] + ";\n";
@@ -1450,7 +1390,6 @@ String VisualShaderNodeColorOp::generate_code(Shader::Mode p_mode, VisualShader:
}
void VisualShaderNodeColorOp::set_operator(Operator p_op) {
-
op = p_op;
switch (op) {
case OP_SCREEN:
@@ -1485,7 +1424,6 @@ void VisualShaderNodeColorOp::set_operator(Operator p_op) {
}
VisualShaderNodeColorOp::Operator VisualShaderNodeColorOp::get_operator() const {
-
return op;
}
@@ -1496,7 +1434,6 @@ Vector<StringName> VisualShaderNodeColorOp::get_editable_properties() const {
}
void VisualShaderNodeColorOp::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeColorOp::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeColorOp::get_operator);
@@ -1550,7 +1487,6 @@ String VisualShaderNodeTransformMult::get_output_port_name(int p_port) const {
}
String VisualShaderNodeTransformMult::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
if (op == OP_AxB) {
return "\t" + p_output_vars[0] + " = " + p_input_vars[0] + " * " + p_input_vars[1] + ";\n";
} else if (op == OP_BxA) {
@@ -1563,13 +1499,11 @@ String VisualShaderNodeTransformMult::generate_code(Shader::Mode p_mode, VisualS
}
void VisualShaderNodeTransformMult::set_operator(Operator p_op) {
-
op = p_op;
emit_changed();
}
VisualShaderNodeTransformMult::Operator VisualShaderNodeTransformMult::get_operator() const {
-
return op;
}
@@ -1580,7 +1514,6 @@ Vector<StringName> VisualShaderNodeTransformMult::get_editable_properties() cons
}
void VisualShaderNodeTransformMult::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeTransformMult::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeTransformMult::get_operator);
@@ -1641,13 +1574,11 @@ String VisualShaderNodeTransformVecMult::generate_code(Shader::Mode p_mode, Visu
}
void VisualShaderNodeTransformVecMult::set_operator(Operator p_op) {
-
op = p_op;
emit_changed();
}
VisualShaderNodeTransformVecMult::Operator VisualShaderNodeTransformVecMult::get_operator() const {
-
return op;
}
@@ -1658,7 +1589,6 @@ Vector<StringName> VisualShaderNodeTransformVecMult::get_editable_properties() c
}
void VisualShaderNodeTransformVecMult::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeTransformVecMult::set_operator);
ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeTransformVecMult::get_operator);
@@ -1707,7 +1637,6 @@ String VisualShaderNodeFloatFunc::get_output_port_name(int p_port) const {
}
String VisualShaderNodeFloatFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *scalar_func_id[FUNC_ONEMINUS + 1] = {
"sin($)",
"cos($)",
@@ -1747,13 +1676,11 @@ String VisualShaderNodeFloatFunc::generate_code(Shader::Mode p_mode, VisualShade
}
void VisualShaderNodeFloatFunc::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeFloatFunc::Function VisualShaderNodeFloatFunc::get_function() const {
-
return func;
}
@@ -1764,7 +1691,6 @@ Vector<StringName> VisualShaderNodeFloatFunc::get_editable_properties() const {
}
void VisualShaderNodeFloatFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeFloatFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeFloatFunc::get_function);
@@ -1878,7 +1804,6 @@ void VisualShaderNodeIntFunc::set_function(Function p_func) {
}
VisualShaderNodeIntFunc::Function VisualShaderNodeIntFunc::get_function() const {
-
return func;
}
@@ -1889,7 +1814,6 @@ Vector<StringName> VisualShaderNodeIntFunc::get_editable_properties() const {
}
void VisualShaderNodeIntFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeIntFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeIntFunc::get_function);
@@ -1937,7 +1861,6 @@ String VisualShaderNodeVectorFunc::get_output_port_name(int p_port) const {
}
String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *vec_func_id[FUNC_ONEMINUS + 1] = {
"normalize($)",
"max(min($, vec3(1.0)), vec3(0.0))",
@@ -2004,7 +1927,6 @@ String VisualShaderNodeVectorFunc::generate_code(Shader::Mode p_mode, VisualShad
}
void VisualShaderNodeVectorFunc::set_function(Function p_func) {
-
func = p_func;
if (func == FUNC_RGB2HSV) {
simple_decl = false;
@@ -2017,7 +1939,6 @@ void VisualShaderNodeVectorFunc::set_function(Function p_func) {
}
VisualShaderNodeVectorFunc::Function VisualShaderNodeVectorFunc::get_function() const {
-
return func;
}
@@ -2028,7 +1949,6 @@ Vector<StringName> VisualShaderNodeVectorFunc::get_editable_properties() const {
}
void VisualShaderNodeVectorFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeVectorFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeVectorFunc::get_function);
@@ -2107,7 +2027,6 @@ String VisualShaderNodeColorFunc::get_output_port_name(int p_port) const {
}
String VisualShaderNodeColorFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code;
switch (func) {
@@ -2135,13 +2054,11 @@ String VisualShaderNodeColorFunc::generate_code(Shader::Mode p_mode, VisualShade
}
void VisualShaderNodeColorFunc::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeColorFunc::Function VisualShaderNodeColorFunc::get_function() const {
-
return func;
}
@@ -2152,7 +2069,6 @@ Vector<StringName> VisualShaderNodeColorFunc::get_editable_properties() const {
}
void VisualShaderNodeColorFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeColorFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeColorFunc::get_function);
@@ -2199,7 +2115,6 @@ String VisualShaderNodeTransformFunc::get_output_port_name(int p_port) const {
}
String VisualShaderNodeTransformFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *funcs[FUNC_TRANSPOSE + 1] = {
"inverse($)",
"transpose($)"
@@ -2211,13 +2126,11 @@ String VisualShaderNodeTransformFunc::generate_code(Shader::Mode p_mode, VisualS
}
void VisualShaderNodeTransformFunc::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeTransformFunc::Function VisualShaderNodeTransformFunc::get_function() const {
-
return func;
}
@@ -2228,7 +2141,6 @@ Vector<StringName> VisualShaderNodeTransformFunc::get_editable_properties() cons
}
void VisualShaderNodeTransformFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeTransformFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeTransformFunc::get_function);
@@ -2389,7 +2301,6 @@ String VisualShaderNodeScalarDerivativeFunc::get_output_port_name(int p_port) co
}
String VisualShaderNodeScalarDerivativeFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *funcs[FUNC_Y + 1] = {
"fwidth($)",
"dFdx($)",
@@ -2402,13 +2313,11 @@ String VisualShaderNodeScalarDerivativeFunc::generate_code(Shader::Mode p_mode,
}
void VisualShaderNodeScalarDerivativeFunc::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeScalarDerivativeFunc::Function VisualShaderNodeScalarDerivativeFunc::get_function() const {
-
return func;
}
@@ -2419,7 +2328,6 @@ Vector<StringName> VisualShaderNodeScalarDerivativeFunc::get_editable_properties
}
void VisualShaderNodeScalarDerivativeFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeScalarDerivativeFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeScalarDerivativeFunc::get_function);
@@ -2466,7 +2374,6 @@ String VisualShaderNodeVectorDerivativeFunc::get_output_port_name(int p_port) co
}
String VisualShaderNodeVectorDerivativeFunc::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *funcs[FUNC_Y + 1] = {
"fwidth($)",
"dFdx($)",
@@ -2479,13 +2386,11 @@ String VisualShaderNodeVectorDerivativeFunc::generate_code(Shader::Mode p_mode,
}
void VisualShaderNodeVectorDerivativeFunc::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeVectorDerivativeFunc::Function VisualShaderNodeVectorDerivativeFunc::get_function() const {
-
return func;
}
@@ -2496,7 +2401,6 @@ Vector<StringName> VisualShaderNodeVectorDerivativeFunc::get_editable_properties
}
void VisualShaderNodeVectorDerivativeFunc::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeVectorDerivativeFunc::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeVectorDerivativeFunc::get_function);
@@ -2527,12 +2431,13 @@ VisualShaderNodeScalarClamp::PortType VisualShaderNodeScalarClamp::get_input_por
}
String VisualShaderNodeScalarClamp::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "min";
- else if (p_port == 2)
+ } else if (p_port == 2) {
return "max";
+ }
return "";
}
@@ -2573,12 +2478,13 @@ VisualShaderNodeVectorClamp::PortType VisualShaderNodeVectorClamp::get_input_por
}
String VisualShaderNodeVectorClamp::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "min";
- else if (p_port == 2)
+ } else if (p_port == 2) {
return "max";
+ }
return "";
}
@@ -2717,10 +2623,11 @@ VisualShaderNodeVectorScalarStep::PortType VisualShaderNodeVectorScalarStep::get
}
String VisualShaderNodeVectorScalarStep::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "edge";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "x";
+ }
return "";
}
@@ -2760,12 +2667,13 @@ VisualShaderNodeScalarSmoothStep::PortType VisualShaderNodeScalarSmoothStep::get
}
String VisualShaderNodeScalarSmoothStep::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "edge0";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "edge1";
- else if (p_port == 2)
+ } else if (p_port == 2) {
return "x";
+ }
return "";
}
@@ -2806,12 +2714,13 @@ VisualShaderNodeVectorSmoothStep::PortType VisualShaderNodeVectorSmoothStep::get
}
String VisualShaderNodeVectorSmoothStep::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "edge0";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "edge1";
- else if (p_port == 2)
+ } else if (p_port == 2) {
return "x";
+ }
return "";
}
@@ -2857,12 +2766,13 @@ VisualShaderNodeVectorScalarSmoothStep::PortType VisualShaderNodeVectorScalarSmo
}
String VisualShaderNodeVectorScalarSmoothStep::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "edge0";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "edge1";
- else if (p_port == 2)
+ } else if (p_port == 2) {
return "x";
+ }
return "";
}
@@ -2943,7 +2853,6 @@ int VisualShaderNodeVectorRefract::get_input_port_count() const {
}
VisualShaderNodeVectorRefract::PortType VisualShaderNodeVectorRefract::get_input_port_type(int p_port) const {
-
if (p_port == 2) {
return PORT_TYPE_SCALAR;
}
@@ -3087,8 +2996,9 @@ int VisualShaderNodeVectorScalarMix::get_input_port_count() const {
}
VisualShaderNodeVectorScalarMix::PortType VisualShaderNodeVectorScalarMix::get_input_port_type(int p_port) const {
- if (p_port == 2)
+ if (p_port == 2) {
return PORT_TYPE_SCALAR;
+ }
return PORT_TYPE_VECTOR;
}
@@ -3165,7 +3075,6 @@ String VisualShaderNodeVectorCompose::generate_code(Shader::Mode p_mode, VisualS
}
VisualShaderNodeVectorCompose::VisualShaderNodeVectorCompose() {
-
set_input_port_default_value(0, 0.0);
set_input_port_default_value(1, 0.0);
set_input_port_default_value(2, 0.0);
@@ -3214,7 +3123,6 @@ String VisualShaderNodeTransformCompose::generate_code(Shader::Mode p_mode, Visu
}
VisualShaderNodeTransformCompose::VisualShaderNodeTransformCompose() {
-
set_input_port_default_value(0, Vector3());
set_input_port_default_value(1, Vector3());
set_input_port_default_value(2, Vector3());
@@ -3647,7 +3555,6 @@ String VisualShaderNodeColorUniform::get_output_port_name(int p_port) const {
}
String VisualShaderNodeColorUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
-
return _get_qual_str() + "uniform vec4 " + get_uniform_name() + " : hint_color;\n";
}
@@ -3777,7 +3684,6 @@ int VisualShaderNodeTextureUniform::get_output_port_count() const {
}
VisualShaderNodeTextureUniform::PortType VisualShaderNodeTextureUniform::get_output_port_type(int p_port) const {
-
switch (p_port) {
case 0:
return PORT_TYPE_VECTOR;
@@ -3791,7 +3697,6 @@ VisualShaderNodeTextureUniform::PortType VisualShaderNodeTextureUniform::get_out
}
String VisualShaderNodeTextureUniform::get_output_port_name(int p_port) const {
-
switch (p_port) {
case 0:
return "rgb";
@@ -3809,16 +3714,18 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu
switch (texture_type) {
case TYPE_DATA:
- if (color_default == COLOR_DEFAULT_BLACK)
+ if (color_default == COLOR_DEFAULT_BLACK) {
code += " : hint_black;\n";
- else
+ } else {
code += ";\n";
+ }
break;
case TYPE_COLOR:
- if (color_default == COLOR_DEFAULT_BLACK)
+ if (color_default == COLOR_DEFAULT_BLACK) {
code += " : hint_black_albedo;\n";
- else
+ } else {
code += " : hint_albedo;\n";
+ }
break;
case TYPE_NORMALMAP:
code += " : hint_normal;\n";
@@ -3832,7 +3739,6 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu
}
String VisualShaderNodeTextureUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String id = get_uniform_name();
String code = "\t{\n";
if (p_input_vars[0] == String()) { // Use UV by default.
@@ -3855,7 +3761,6 @@ String VisualShaderNodeTextureUniform::generate_code(Shader::Mode p_mode, Visual
}
void VisualShaderNodeTextureUniform::set_texture_type(TextureType p_type) {
-
texture_type = p_type;
emit_changed();
}
@@ -3953,7 +3858,6 @@ String VisualShaderNodeTextureUniformTriplanar::get_input_port_name(int p_port)
}
String VisualShaderNodeTextureUniformTriplanar::generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
-
String code;
code += "// TRIPLANAR FUNCTION GLOBAL CODE\n";
@@ -3976,11 +3880,9 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_node(Shader:
}
String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
-
String code;
if (p_type == VisualShader::TYPE_VERTEX) {
-
code += "\t// TRIPLANAR FUNCTION VERTEX CODE\n";
code += "\t\ttriplanar_power_normal = pow(abs(NORMAL), vec3(triplanar_sharpness));\n";
code += "\t\ttriplanar_power_normal /= dot(triplanar_power_normal, vec3(1.0));\n";
@@ -3992,7 +3894,6 @@ String VisualShaderNodeTextureUniformTriplanar::generate_global_per_func(Shader:
}
String VisualShaderNodeTextureUniformTriplanar::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String id = get_uniform_name();
String code = "\t{\n";
@@ -4064,16 +3965,18 @@ String VisualShaderNodeCubemapUniform::generate_global(Shader::Mode p_mode, Visu
switch (texture_type) {
case TYPE_DATA:
- if (color_default == COLOR_DEFAULT_BLACK)
+ if (color_default == COLOR_DEFAULT_BLACK) {
code += " : hint_black;\n";
- else
+ } else {
code += ";\n";
+ }
break;
case TYPE_COLOR:
- if (color_default == COLOR_DEFAULT_BLACK)
+ if (color_default == COLOR_DEFAULT_BLACK) {
code += " : hint_black_albedo;\n";
- else
+ } else {
code += " : hint_albedo;\n";
+ }
break;
case TYPE_NORMALMAP:
code += " : hint_normal;\n";
@@ -4142,7 +4045,6 @@ String VisualShaderNodeIf::get_output_port_name(int p_port) const {
}
String VisualShaderNodeIf::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code;
code += "\tif(abs(" + p_input_vars[0] + " - " + p_input_vars[1] + ") < " + p_input_vars[2] + ")\n"; // abs(a - b) < tolerance eg. a == b
code += "\t{\n";
@@ -4212,7 +4114,6 @@ String VisualShaderNodeSwitch::get_output_port_name(int p_port) const {
}
String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String code;
code += "\tif(" + p_input_vars[0] + ")\n";
code += "\t{\n";
@@ -4308,7 +4209,6 @@ String VisualShaderNodeFresnel::get_output_port_name(int p_port) const {
}
String VisualShaderNodeFresnel::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
String normal;
String view;
if (p_input_vars[0] == String()) {
@@ -4342,42 +4242,34 @@ VisualShaderNodeFresnel::VisualShaderNodeFresnel() {
////////////// Is
String VisualShaderNodeIs::get_caption() const {
-
return "Is";
}
int VisualShaderNodeIs::get_input_port_count() const {
-
return 1;
}
VisualShaderNodeIs::PortType VisualShaderNodeIs::get_input_port_type(int p_port) const {
-
return PORT_TYPE_SCALAR;
}
String VisualShaderNodeIs::get_input_port_name(int p_port) const {
-
return "";
}
int VisualShaderNodeIs::get_output_port_count() const {
-
return 1;
}
VisualShaderNodeIs::PortType VisualShaderNodeIs::get_output_port_type(int p_port) const {
-
return PORT_TYPE_BOOLEAN;
}
String VisualShaderNodeIs::get_output_port_name(int p_port) const {
-
return "";
}
String VisualShaderNodeIs::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *funcs[FUNC_IS_NAN + 1] = {
"isinf($)",
"isnan($)"
@@ -4389,25 +4281,21 @@ String VisualShaderNodeIs::generate_code(Shader::Mode p_mode, VisualShader::Type
}
void VisualShaderNodeIs::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeIs::Function VisualShaderNodeIs::get_function() const {
-
return func;
}
Vector<StringName> VisualShaderNodeIs::get_editable_properties() const {
-
Vector<StringName> props;
props.push_back("function");
return props;
}
void VisualShaderNodeIs::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeIs::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeIs::get_function);
@@ -4418,7 +4306,6 @@ void VisualShaderNodeIs::_bind_methods() {
}
VisualShaderNodeIs::VisualShaderNodeIs() {
-
func = FUNC_IS_INF;
set_input_port_default_value(0, 0.0);
}
@@ -4426,12 +4313,10 @@ VisualShaderNodeIs::VisualShaderNodeIs() {
////////////// Compare
String VisualShaderNodeCompare::get_caption() const {
-
return "Compare";
}
int VisualShaderNodeCompare::get_input_port_count() const {
-
if (ctype == CTYPE_SCALAR && (func == FUNC_EQUAL || func == FUNC_NOT_EQUAL)) {
return 3;
}
@@ -4439,9 +4324,9 @@ int VisualShaderNodeCompare::get_input_port_count() const {
}
VisualShaderNodeCompare::PortType VisualShaderNodeCompare::get_input_port_type(int p_port) const {
-
- if (p_port == 2)
+ if (p_port == 2) {
return PORT_TYPE_SCALAR;
+ }
switch (ctype) {
case CTYPE_SCALAR:
return PORT_TYPE_SCALAR;
@@ -4458,12 +4343,13 @@ VisualShaderNodeCompare::PortType VisualShaderNodeCompare::get_input_port_type(i
}
String VisualShaderNodeCompare::get_input_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "a";
- else if (p_port == 1)
+ } else if (p_port == 1) {
return "b";
- else if (p_port == 2)
+ } else if (p_port == 2) {
return "tolerance";
+ }
return "";
}
@@ -4476,13 +4362,13 @@ VisualShaderNodeCompare::PortType VisualShaderNodeCompare::get_output_port_type(
}
String VisualShaderNodeCompare::get_output_port_name(int p_port) const {
- if (p_port == 0)
+ if (p_port == 0) {
return "result";
+ }
return "";
}
String VisualShaderNodeCompare::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const {
-
if (ctype == CTYPE_BOOLEAN || ctype == CTYPE_TRANSFORM) {
if (func > FUNC_NOT_EQUAL) {
return TTR("Invalid comparison function for that type.");
@@ -4493,7 +4379,6 @@ String VisualShaderNodeCompare::get_warning(Shader::Mode p_mode, VisualShader::T
}
String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
-
static const char *ops[FUNC_LESS_THAN_EQUAL + 1] = {
"==",
"!=",
@@ -4541,14 +4426,16 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader:
break;
case CTYPE_BOOLEAN:
- if (func > FUNC_NOT_EQUAL)
+ if (func > FUNC_NOT_EQUAL) {
return "\t" + p_output_vars[0] + " = false;\n";
+ }
code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n";
break;
case CTYPE_TRANSFORM:
- if (func > FUNC_NOT_EQUAL)
+ if (func > FUNC_NOT_EQUAL) {
return "\t" + p_output_vars[0] + " = false;\n";
+ }
code += "\t" + p_output_vars[0] + " = " + (p_input_vars[0] + " $ " + p_input_vars[1]).replace("$", ops[func]) + ";\n";
break;
@@ -4559,7 +4446,6 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader:
}
void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) {
-
ctype = p_type;
switch (ctype) {
@@ -4593,29 +4479,24 @@ void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) {
}
VisualShaderNodeCompare::ComparisonType VisualShaderNodeCompare::get_comparison_type() const {
-
return ctype;
}
void VisualShaderNodeCompare::set_function(Function p_func) {
-
func = p_func;
emit_changed();
}
VisualShaderNodeCompare::Function VisualShaderNodeCompare::get_function() const {
-
return func;
}
void VisualShaderNodeCompare::set_condition(Condition p_cond) {
-
condition = p_cond;
emit_changed();
}
VisualShaderNodeCompare::Condition VisualShaderNodeCompare::get_condition() const {
-
return condition;
}
@@ -4623,13 +4504,13 @@ Vector<StringName> VisualShaderNodeCompare::get_editable_properties() const {
Vector<StringName> props;
props.push_back("type");
props.push_back("function");
- if (ctype == CTYPE_VECTOR)
+ if (ctype == CTYPE_VECTOR) {
props.push_back("condition");
+ }
return props;
}
void VisualShaderNodeCompare::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_comparison_type", "type"), &VisualShaderNodeCompare::set_comparison_type);
ClassDB::bind_method(D_METHOD("get_comparison_type"), &VisualShaderNodeCompare::get_comparison_type);
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index f2f67d3814..1c753fdb91 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -38,9 +38,7 @@
#include "servers/rendering_server.h"
struct SpatialIndexer2D {
-
struct CellRef {
-
int ref;
_FORCE_INLINE_ int inc() {
@@ -58,7 +56,6 @@ struct SpatialIndexer2D {
};
struct CellKey {
-
union {
struct {
int32_t x;
@@ -74,7 +71,6 @@ struct SpatialIndexer2D {
};
struct CellData {
-
Map<VisibilityNotifier2D *, CellRef> notifiers;
};
@@ -84,7 +80,6 @@ struct SpatialIndexer2D {
Map<VisibilityNotifier2D *, Rect2> notifiers;
struct ViewportData {
-
Map<VisibilityNotifier2D *, uint64_t> notifiers;
Rect2 rect;
};
@@ -96,30 +91,25 @@ struct SpatialIndexer2D {
uint64_t pass;
void _notifier_update_cells(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect, bool p_add) {
-
Point2i begin = p_rect.position;
begin /= cell_size;
Point2i end = p_rect.position + p_rect.size;
end /= cell_size;
for (int i = begin.x; i <= end.x; i++) {
-
for (int j = begin.y; j <= end.y; j++) {
-
CellKey ck;
ck.x = i;
ck.y = j;
Map<CellKey, CellData>::Element *E = cells.find(ck);
if (p_add) {
-
- if (!E)
+ if (!E) {
E = cells.insert(ck, CellData());
+ }
E->get().notifiers[p_notifier].inc();
} else {
-
ERR_CONTINUE(!E);
if (E->get().notifiers[p_notifier].dec() == 0) {
-
E->get().notifiers.erase(p_notifier);
if (E->get().notifiers.empty()) {
cells.erase(E);
@@ -131,7 +121,6 @@ struct SpatialIndexer2D {
}
void _notifier_add(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
-
ERR_FAIL_COND(notifiers.has(p_notifier));
notifiers[p_notifier] = p_rect;
_notifier_update_cells(p_notifier, p_rect, true);
@@ -139,11 +128,11 @@ struct SpatialIndexer2D {
}
void _notifier_update(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
-
Map<VisibilityNotifier2D *, Rect2>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
- if (E->get() == p_rect)
+ if (E->get() == p_rect) {
return;
+ }
_notifier_update_cells(p_notifier, p_rect, true);
_notifier_update_cells(p_notifier, E->get(), false);
@@ -152,7 +141,6 @@ struct SpatialIndexer2D {
}
void _notifier_remove(VisibilityNotifier2D *p_notifier) {
-
Map<VisibilityNotifier2D *, Rect2>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
_notifier_update_cells(p_notifier, E->get(), false);
@@ -160,7 +148,6 @@ struct SpatialIndexer2D {
List<Viewport *> removed;
for (Map<Viewport *, ViewportData>::Element *F = viewports.front(); F; F = F->next()) {
-
Map<VisibilityNotifier2D *, uint64_t>::Element *G = F->get().notifiers.find(p_notifier);
if (G) {
@@ -170,7 +157,6 @@ struct SpatialIndexer2D {
}
while (!removed.empty()) {
-
p_notifier->_exit_viewport(removed.front()->get());
removed.pop_front();
}
@@ -179,7 +165,6 @@ struct SpatialIndexer2D {
}
void _add_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
-
ERR_FAIL_COND(viewports.has(p_viewport));
ViewportData vd;
vd.rect = p_rect;
@@ -188,11 +173,11 @@ struct SpatialIndexer2D {
}
void _update_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
-
Map<Viewport *, ViewportData>::Element *E = viewports.find(p_viewport);
ERR_FAIL_COND(!E);
- if (E->get().rect == p_rect)
+ if (E->get().rect == p_rect) {
return;
+ }
E->get().rect = p_rect;
changed = true;
}
@@ -201,7 +186,6 @@ struct SpatialIndexer2D {
ERR_FAIL_COND(!viewports.has(p_viewport));
List<VisibilityNotifier2D *> removed;
for (Map<VisibilityNotifier2D *, uint64_t>::Element *E = viewports[p_viewport].notifiers.front(); E; E = E->next()) {
-
removed.push_back(E->key());
}
@@ -214,12 +198,11 @@ struct SpatialIndexer2D {
}
void _update() {
-
- if (!changed)
+ if (!changed) {
return;
+ }
for (Map<Viewport *, ViewportData>::Element *E = viewports.front(); E; E = E->next()) {
-
Point2i begin = E->get().rect.position;
begin /= cell_size;
Point2i end = E->get().rect.position + E->get().rect.size;
@@ -231,24 +214,22 @@ struct SpatialIndexer2D {
int visible_cells = (end.x - begin.x) * (end.y - begin.y);
if (visible_cells > 10000) {
-
//well you zoomed out a lot, it's your problem. To avoid freezing in the for loops below, we'll manually check cell by cell
for (Map<CellKey, CellData>::Element *F = cells.front(); F; F = F->next()) {
-
const CellKey &ck = F->key();
- if (ck.x < begin.x || ck.x > end.x)
+ if (ck.x < begin.x || ck.x > end.x) {
continue;
- if (ck.y < begin.y || ck.y > end.y)
+ }
+ if (ck.y < begin.y || ck.y > end.y) {
continue;
+ }
//notifiers in cell
for (Map<VisibilityNotifier2D *, CellRef>::Element *G = F->get().notifiers.front(); G; G = G->next()) {
-
Map<VisibilityNotifier2D *, uint64_t>::Element *H = E->get().notifiers.find(G->key());
if (!H) {
-
H = E->get().notifiers.insert(G->key(), pass);
added.push_back(G->key());
} else {
@@ -258,12 +239,9 @@ struct SpatialIndexer2D {
}
} else {
-
//check cells in grid fashion
for (int i = begin.x; i <= end.x; i++) {
-
for (int j = begin.y; j <= end.y; j++) {
-
CellKey ck;
ck.x = i;
ck.y = j;
@@ -275,10 +253,8 @@ struct SpatialIndexer2D {
//notifiers in cell
for (Map<VisibilityNotifier2D *, CellRef>::Element *G = F->get().notifiers.front(); G; G = G->next()) {
-
Map<VisibilityNotifier2D *, uint64_t>::Element *H = E->get().notifiers.find(G->key());
if (!H) {
-
H = E->get().notifiers.insert(G->key(), pass);
added.push_back(G->key());
} else {
@@ -290,9 +266,9 @@ struct SpatialIndexer2D {
}
for (Map<VisibilityNotifier2D *, uint64_t>::Element *F = E->get().notifiers.front(); F; F = F->next()) {
-
- if (F->get() != pass)
+ if (F->get() != pass) {
removed.push_back(F->key());
+ }
}
while (!added.empty()) {
@@ -311,7 +287,6 @@ struct SpatialIndexer2D {
}
SpatialIndexer2D() {
-
pass = 0;
changed = false;
cell_size = GLOBAL_DEF("world/2d/cell_size", 100);
@@ -319,56 +294,48 @@ struct SpatialIndexer2D {
};
void World2D::_register_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
-
indexer->_add_viewport(p_viewport, p_rect);
}
void World2D::_update_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
-
indexer->_update_viewport(p_viewport, p_rect);
}
-void World2D::_remove_viewport(Viewport *p_viewport) {
+void World2D::_remove_viewport(Viewport *p_viewport) {
indexer->_remove_viewport(p_viewport);
}
void World2D::_register_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
-
indexer->_notifier_add(p_notifier, p_rect);
}
-void World2D::_update_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
+void World2D::_update_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
indexer->_notifier_update(p_notifier, p_rect);
}
-void World2D::_remove_notifier(VisibilityNotifier2D *p_notifier) {
+void World2D::_remove_notifier(VisibilityNotifier2D *p_notifier) {
indexer->_notifier_remove(p_notifier);
}
void World2D::_update() {
-
indexer->_update();
}
RID World2D::get_canvas() {
-
return canvas;
}
RID World2D::get_space() {
-
return space;
}
void World2D::get_viewport_list(List<Viewport *> *r_viewports) {
-
for (Map<Viewport *, SpatialIndexer2D::ViewportData>::Element *E = indexer->viewports.front(); E; E = E->next()) {
r_viewports->push_back(E->key());
}
}
void World2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_canvas"), &World2D::get_canvas);
ClassDB::bind_method(D_METHOD("get_space"), &World2D::get_space);
@@ -380,12 +347,10 @@ void World2D::_bind_methods() {
}
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
-
return PhysicsServer2D::get_singleton()->space_get_direct_state(space);
}
World2D::World2D() {
-
canvas = RenderingServer::get_singleton()->canvas_create();
space = PhysicsServer2D::get_singleton()->space_create();
@@ -401,7 +366,6 @@ World2D::World2D() {
}
World2D::~World2D() {
-
RenderingServer::get_singleton()->free(canvas);
PhysicsServer2D::get_singleton()->free(space);
memdelete(indexer);
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index 88b4c2594c..c330719104 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -40,7 +40,6 @@ class Viewport;
struct SpatialIndexer2D;
class World2D : public Resource {
-
GDCLASS(World2D, Resource);
RID canvas;
diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp
index dee00dd82a..8100f150ef 100644
--- a/scene/resources/world_3d.cpp
+++ b/scene/resources/world_3d.cpp
@@ -37,18 +37,15 @@
#include "scene/scene_string_names.h"
struct SpatialIndexer {
-
Octree<VisibilityNotifier3D> octree;
struct NotifierData {
-
AABB aabb;
OctreeElementID id;
};
Map<VisibilityNotifier3D *, NotifierData> notifiers;
struct CameraData {
-
Map<VisibilityNotifier3D *, uint64_t> notifiers;
};
@@ -65,7 +62,6 @@ struct SpatialIndexer {
uint64_t last_frame;
void _notifier_add(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
-
ERR_FAIL_COND(notifiers.has(p_notifier));
notifiers[p_notifier].aabb = p_rect;
notifiers[p_notifier].id = octree.create(p_notifier, p_rect);
@@ -73,11 +69,11 @@ struct SpatialIndexer {
}
void _notifier_update(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
-
Map<VisibilityNotifier3D *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
- if (E->get().aabb == p_rect)
+ if (E->get().aabb == p_rect) {
return;
+ }
E->get().aabb = p_rect;
octree.move(E->get().id, E->get().aabb);
@@ -85,7 +81,6 @@ struct SpatialIndexer {
}
void _notifier_remove(VisibilityNotifier3D *p_notifier) {
-
Map<VisibilityNotifier3D *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
@@ -94,7 +89,6 @@ struct SpatialIndexer {
List<Camera3D *> removed;
for (Map<Camera3D *, CameraData>::Element *F = cameras.front(); F; F = F->next()) {
-
Map<VisibilityNotifier3D *, uint64_t>::Element *G = F->get().notifiers.find(p_notifier);
if (G) {
@@ -104,7 +98,6 @@ struct SpatialIndexer {
}
while (!removed.empty()) {
-
p_notifier->_exit_camera(removed.front()->get());
removed.pop_front();
}
@@ -113,7 +106,6 @@ struct SpatialIndexer {
}
void _add_camera(Camera3D *p_camera) {
-
ERR_FAIL_COND(cameras.has(p_camera));
CameraData vd;
cameras[p_camera] = vd;
@@ -121,7 +113,6 @@ struct SpatialIndexer {
}
void _update_camera(Camera3D *p_camera) {
-
Map<Camera3D *, CameraData>::Element *E = cameras.find(p_camera);
ERR_FAIL_COND(!E);
changed = true;
@@ -131,7 +122,6 @@ struct SpatialIndexer {
ERR_FAIL_COND(!cameras.has(p_camera));
List<VisibilityNotifier3D *> removed;
for (Map<VisibilityNotifier3D *, uint64_t>::Element *E = cameras[p_camera].notifiers.front(); E; E = E->next()) {
-
removed.push_back(E->key());
}
@@ -144,16 +134,16 @@ struct SpatialIndexer {
}
void _update(uint64_t p_frame) {
-
- if (p_frame == last_frame)
+ if (p_frame == last_frame) {
return;
+ }
last_frame = p_frame;
- if (!changed)
+ if (!changed) {
return;
+ }
for (Map<Camera3D *, CameraData>::Element *E = cameras.front(); E; E = E->next()) {
-
pass++;
Camera3D *c = E->key();
@@ -168,12 +158,10 @@ struct SpatialIndexer {
List<VisibilityNotifier3D *> removed;
for (int i = 0; i < culled; i++) {
-
//notifiers in frustum
Map<VisibilityNotifier3D *, uint64_t>::Element *H = E->get().notifiers.find(ptr[i]);
if (!H) {
-
E->get().notifiers.insert(ptr[i], pass);
added.push_back(ptr[i]);
} else {
@@ -182,9 +170,9 @@ struct SpatialIndexer {
}
for (Map<VisibilityNotifier3D *, uint64_t>::Element *F = E->get().notifiers.front(); F; F = F->next()) {
-
- if (F->get() != pass)
+ if (F->get() != pass) {
removed.push_back(F->key());
+ }
}
while (!added.empty()) {
@@ -202,7 +190,6 @@ struct SpatialIndexer {
}
SpatialIndexer() {
-
pass = 0;
last_frame = 0;
changed = false;
@@ -211,60 +198,52 @@ struct SpatialIndexer {
};
void World3D::_register_camera(Camera3D *p_camera) {
-
#ifndef _3D_DISABLED
indexer->_add_camera(p_camera);
#endif
}
void World3D::_update_camera(Camera3D *p_camera) {
-
#ifndef _3D_DISABLED
indexer->_update_camera(p_camera);
#endif
}
-void World3D::_remove_camera(Camera3D *p_camera) {
+void World3D::_remove_camera(Camera3D *p_camera) {
#ifndef _3D_DISABLED
indexer->_remove_camera(p_camera);
#endif
}
void World3D::_register_notifier(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
-
#ifndef _3D_DISABLED
indexer->_notifier_add(p_notifier, p_rect);
#endif
}
void World3D::_update_notifier(VisibilityNotifier3D *p_notifier, const AABB &p_rect) {
-
#ifndef _3D_DISABLED
indexer->_notifier_update(p_notifier, p_rect);
#endif
}
void World3D::_remove_notifier(VisibilityNotifier3D *p_notifier) {
-
#ifndef _3D_DISABLED
indexer->_notifier_remove(p_notifier);
#endif
}
void World3D::_update(uint64_t p_frame) {
-
#ifndef _3D_DISABLED
indexer->_update(p_frame);
#endif
}
RID World3D::get_space() const {
-
return space;
}
RID World3D::get_scenario() const {
-
return scenario;
}
@@ -274,16 +253,16 @@ void World3D::set_environment(const Ref<Environment> &p_environment) {
}
environment = p_environment;
- if (environment.is_valid())
+ if (environment.is_valid()) {
RS::get_singleton()->scenario_set_environment(scenario, environment->get_rid());
- else
+ } else {
RS::get_singleton()->scenario_set_environment(scenario, RID());
+ }
emit_changed();
}
Ref<Environment> World3D::get_environment() const {
-
return environment;
}
@@ -293,47 +272,43 @@ void World3D::set_fallback_environment(const Ref<Environment> &p_environment) {
}
fallback_environment = p_environment;
- if (fallback_environment.is_valid())
+ if (fallback_environment.is_valid()) {
RS::get_singleton()->scenario_set_fallback_environment(scenario, p_environment->get_rid());
- else
+ } else {
RS::get_singleton()->scenario_set_fallback_environment(scenario, RID());
+ }
emit_changed();
}
Ref<Environment> World3D::get_fallback_environment() const {
-
return fallback_environment;
}
void World3D::set_camera_effects(const Ref<CameraEffects> &p_camera_effects) {
-
camera_effects = p_camera_effects;
- if (camera_effects.is_valid())
+ if (camera_effects.is_valid()) {
RS::get_singleton()->scenario_set_camera_effects(scenario, camera_effects->get_rid());
- else
+ } else {
RS::get_singleton()->scenario_set_camera_effects(scenario, RID());
+ }
}
Ref<CameraEffects> World3D::get_camera_effects() const {
-
return camera_effects;
}
PhysicsDirectSpaceState3D *World3D::get_direct_space_state() {
-
return PhysicsServer3D::get_singleton()->space_get_direct_state(space);
}
void World3D::get_camera_list(List<Camera3D *> *r_cameras) {
-
for (Map<Camera3D *, SpatialIndexer::CameraData>::Element *E = indexer->cameras.front(); E; E = E->next()) {
r_cameras->push_back(E->key());
}
}
void World3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_space"), &World3D::get_space);
ClassDB::bind_method(D_METHOD("get_scenario"), &World3D::get_scenario);
ClassDB::bind_method(D_METHOD("set_environment", "env"), &World3D::set_environment);
@@ -352,7 +327,6 @@ void World3D::_bind_methods() {
}
World3D::World3D() {
-
space = PhysicsServer3D::get_singleton()->space_create();
scenario = RenderingServer::get_singleton()->scenario_create();
@@ -372,7 +346,6 @@ World3D::World3D() {
}
World3D::~World3D() {
-
PhysicsServer3D::get_singleton()->free(space);
RenderingServer::get_singleton()->free(scenario);
diff --git a/scene/resources/world_margin_shape_3d.cpp b/scene/resources/world_margin_shape_3d.cpp
index aa96f8aa68..d613413b33 100644
--- a/scene/resources/world_margin_shape_3d.cpp
+++ b/scene/resources/world_margin_shape_3d.cpp
@@ -33,7 +33,6 @@
#include "servers/physics_server_3d.h"
Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() {
-
Plane p = get_plane();
Vector<Vector3> points;
@@ -62,13 +61,11 @@ Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() {
}
void WorldMarginShape3D::_update_shape() {
-
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), plane);
Shape3D::_update_shape();
}
void WorldMarginShape3D::set_plane(Plane p_plane) {
-
plane = p_plane;
_update_shape();
notify_change_to_owners();
@@ -76,12 +73,10 @@ void WorldMarginShape3D::set_plane(Plane p_plane) {
}
Plane WorldMarginShape3D::get_plane() const {
-
return plane;
}
void WorldMarginShape3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape3D::set_plane);
ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape3D::get_plane);
@@ -90,6 +85,5 @@ void WorldMarginShape3D::_bind_methods() {
WorldMarginShape3D::WorldMarginShape3D() :
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_PLANE)) {
-
set_plane(Plane(0, 1, 0, 0));
}
diff --git a/scene/resources/world_margin_shape_3d.h b/scene/resources/world_margin_shape_3d.h
index 5e0f046628..acb479972b 100644
--- a/scene/resources/world_margin_shape_3d.h
+++ b/scene/resources/world_margin_shape_3d.h
@@ -34,7 +34,6 @@
#include "scene/resources/shape_3d.h"
class WorldMarginShape3D : public Shape3D {
-
GDCLASS(WorldMarginShape3D, Shape3D);
Plane plane;
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index e761354cc9..7cf9a4fedd 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -33,7 +33,6 @@
SceneStringNames *SceneStringNames::singleton = nullptr;
SceneStringNames::SceneStringNames() {
-
_estimate_cost = StaticCString::create("_estimate_cost");
_compute_cost = StaticCString::create("_compute_cost");
@@ -63,6 +62,8 @@ SceneStringNames::SceneStringNames() {
animation_changed = StaticCString::create("animation_changed");
animation_started = StaticCString::create("animation_started");
+ pose_updated = StaticCString::create("pose_updated");
+
mouse_entered = StaticCString::create("mouse_entered");
mouse_exited = StaticCString::create("mouse_exited");
@@ -189,7 +190,6 @@ SceneStringNames::SceneStringNames() {
_default = StaticCString::create("default");
for (int i = 0; i < MAX_MATERIALS; i++) {
-
mesh_materials[i] = "material/" + itos(i);
}
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index c5c98ba9e5..1ae244492e 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -35,7 +35,6 @@
#include "core/string_name.h"
class SceneStringNames {
-
friend void register_scene_types();
friend void unregister_scene_types();
@@ -96,6 +95,8 @@ public:
StringName animation_changed;
StringName animation_started;
+ StringName pose_updated;
+
StringName body_shape_entered;
StringName body_entered;
StringName body_shape_exited;
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp
index ed67e8902a..ff0d2cad65 100644
--- a/servers/audio/audio_driver_dummy.cpp
+++ b/servers/audio/audio_driver_dummy.cpp
@@ -34,17 +34,16 @@
#include "core/project_settings.h"
Error AudioDriverDummy::init() {
-
active = false;
thread_exited = false;
exit_thread = false;
samples_in = nullptr;
- mix_rate = DEFAULT_MIX_RATE;
+ mix_rate = GLOBAL_GET("audio/mix_rate");
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
- int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+ int latency = GLOBAL_GET("audio/output_latency");
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_frames * channels);
@@ -55,15 +54,12 @@ Error AudioDriverDummy::init() {
};
void AudioDriverDummy::thread_func(void *p_udata) {
-
AudioDriverDummy *ad = (AudioDriverDummy *)p_udata;
uint64_t usdelay = (ad->buffer_frames / float(ad->mix_rate)) * 1000000;
while (!ad->exit_thread) {
-
if (ad->active) {
-
ad->lock();
ad->audio_server_process(ad->buffer_frames, ad->samples_in);
@@ -78,38 +74,35 @@ void AudioDriverDummy::thread_func(void *p_udata) {
};
void AudioDriverDummy::start() {
-
active = true;
};
int AudioDriverDummy::get_mix_rate() const {
-
return mix_rate;
};
AudioDriver::SpeakerMode AudioDriverDummy::get_speaker_mode() const {
-
return speaker_mode;
};
void AudioDriverDummy::lock() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
mutex.lock();
};
void AudioDriverDummy::unlock() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
mutex.unlock();
};
void AudioDriverDummy::finish() {
-
- if (!thread)
+ if (!thread) {
return;
+ }
exit_thread = true;
Thread::wait_to_finish(thread);
@@ -121,12 +114,3 @@ void AudioDriverDummy::finish() {
memdelete(thread);
thread = nullptr;
};
-
-AudioDriverDummy::AudioDriverDummy() {
-
- thread = nullptr;
-};
-
-AudioDriverDummy::~AudioDriverDummy(){
-
-};
diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h
index a2cd9b2dc6..84a566e420 100644
--- a/servers/audio/audio_driver_dummy.h
+++ b/servers/audio/audio_driver_dummy.h
@@ -37,8 +37,7 @@
#include "core/os/thread.h"
class AudioDriverDummy : public AudioDriver {
-
- Thread *thread;
+ Thread *thread = nullptr;
Mutex mutex;
int32_t *samples_in;
@@ -68,8 +67,8 @@ public:
virtual void unlock();
virtual void finish();
- AudioDriverDummy();
- ~AudioDriverDummy();
+ AudioDriverDummy() {}
+ ~AudioDriverDummy() {}
};
#endif
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index 3928ba1388..f5eafb7e60 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -31,35 +31,32 @@
#include "audio_filter_sw.h"
void AudioFilterSW::set_mode(Mode p_mode) {
-
mode = p_mode;
}
-void AudioFilterSW::set_cutoff(float p_cutoff) {
+void AudioFilterSW::set_cutoff(float p_cutoff) {
cutoff = p_cutoff;
}
-void AudioFilterSW::set_resonance(float p_resonance) {
+void AudioFilterSW::set_resonance(float p_resonance) {
resonance = p_resonance;
}
void AudioFilterSW::set_gain(float p_gain) {
-
gain = p_gain;
}
void AudioFilterSW::set_sampling_rate(float p_srate) {
-
sampling_rate = p_srate;
}
void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
-
int sr_limit = (sampling_rate / 2) + 512;
double final_cutoff = (cutoff > sr_limit) ? sr_limit : cutoff;
- if (final_cutoff < 1)
+ if (final_cutoff < 1) {
final_cutoff = 1; //don't allow less than this
+ }
double omega = 2.0 * Math_PI * final_cutoff / sampling_rate;
@@ -71,18 +68,19 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
Q = 0.0001;
}
- if (mode == BANDPASS)
+ if (mode == BANDPASS) {
Q *= 2.0;
- else if (mode == PEAK)
+ } else if (mode == PEAK) {
Q *= 3.0;
+ }
double tmpgain = gain;
- if (tmpgain < 0.001)
+ if (tmpgain < 0.001) {
tmpgain = 0.001;
+ }
if (stages > 1) {
-
Q = (Q > 1.0 ? Math::pow(Q, 1.0 / stages) : Q);
tmpgain = Math::pow(tmpgain, 1.0 / (stages + 1));
}
@@ -91,9 +89,7 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
double a0 = 1.0 + alpha;
switch (mode) {
-
case LOWPASS: {
-
p_coeffs->b0 = (1.0 - cos_v) / 2.0;
p_coeffs->b1 = 1.0 - cos_v;
p_coeffs->b2 = (1.0 - cos_v) / 2.0;
@@ -102,7 +98,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
} break;
case HIGHPASS: {
-
p_coeffs->b0 = (1.0 + cos_v) / 2.0;
p_coeffs->b1 = -(1.0 + cos_v);
p_coeffs->b2 = (1.0 + cos_v) / 2.0;
@@ -111,7 +106,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
} break;
case BANDPASS: {
-
p_coeffs->b0 = alpha * sqrt(Q + 1);
p_coeffs->b1 = 0.0;
p_coeffs->b2 = -alpha * sqrt(Q + 1);
@@ -120,7 +114,6 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
} break;
case NOTCH: {
-
p_coeffs->b0 = 1.0;
p_coeffs->b1 = -2.0 * cos_v;
p_coeffs->b2 = 1.0;
@@ -151,10 +144,10 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
} break;
case LOWSHELF: {
-
double tmpq = Math::sqrt(Q);
- if (tmpq <= 0)
+ if (tmpq <= 0) {
tmpq = 0.001;
+ }
double beta = Math::sqrt(tmpgain) / tmpq;
a0 = (tmpgain + 1.0) + (tmpgain - 1.0) * cos_v + beta * sin_v;
@@ -167,8 +160,9 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
} break;
case HIGHSHELF: {
double tmpq = Math::sqrt(Q);
- if (tmpq <= 0)
+ if (tmpq <= 0) {
tmpq = 0.001;
+ }
double beta = Math::sqrt(tmpgain) / tmpq;
a0 = (tmpgain + 1.0) - (tmpgain - 1.0) * cos_v + beta * sin_v;
@@ -203,7 +197,6 @@ void AudioFilterSW::set_stages(int p_stages) { //adjust for multiple stages
/* Fouriertransform kernel to obtain response */
float AudioFilterSW::get_response(float p_freq, Coeffs *p_coeffs) {
-
float freq = p_freq / sampling_rate * Math_PI * 2.0f;
float cx = p_coeffs->b0, cy = 0.0;
@@ -227,7 +220,6 @@ float AudioFilterSW::get_response(float p_freq, Coeffs *p_coeffs) {
}
AudioFilterSW::AudioFilterSW() {
-
sampling_rate = 44100;
resonance = 0.5;
cutoff = 5000;
@@ -237,12 +229,10 @@ AudioFilterSW::AudioFilterSW() {
}
AudioFilterSW::Processor::Processor() {
-
set_filter(nullptr);
}
void AudioFilterSW::Processor::set_filter(AudioFilterSW *p_filter, bool p_clear_history) {
-
if (p_clear_history) {
ha1 = ha2 = hb1 = hb2 = 0;
}
@@ -250,9 +240,9 @@ void AudioFilterSW::Processor::set_filter(AudioFilterSW *p_filter, bool p_clear_
}
void AudioFilterSW::Processor::update_coeffs(int p_interp_buffer_len) {
-
- if (!filter)
+ if (!filter) {
return;
+ }
if (p_interp_buffer_len) { //interpolate
Coeffs old_coeffs = coeffs;
@@ -269,19 +259,17 @@ void AudioFilterSW::Processor::update_coeffs(int p_interp_buffer_len) {
}
void AudioFilterSW::Processor::process(float *p_samples, int p_amount, int p_stride, bool p_interpolate) {
-
- if (!filter)
+ if (!filter) {
return;
+ }
if (p_interpolate) {
for (int i = 0; i < p_amount; i++) {
-
process_one_interp(*p_samples);
p_samples += p_stride;
}
} else {
for (int i = 0; i < p_amount; i++) {
-
process_one(*p_samples);
p_samples += p_stride;
}
diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h
index 61088eec55..a7f570fbb4 100644
--- a/servers/audio/audio_filter_sw.h
+++ b/servers/audio/audio_filter_sw.h
@@ -36,7 +36,6 @@
class AudioFilterSW {
public:
struct Coeffs {
-
float a1, a2;
float b0, b1, b2;
@@ -99,7 +98,6 @@ public:
/* inline methods */
void AudioFilterSW::Processor::process_one(float &p_sample) {
-
float pre = p_sample;
p_sample = (p_sample * coeffs.b0 + hb1 * coeffs.b1 + hb2 * coeffs.b2 + ha1 * coeffs.a1 + ha2 * coeffs.a2);
ha2 = ha1;
@@ -109,7 +107,6 @@ void AudioFilterSW::Processor::process_one(float &p_sample) {
}
void AudioFilterSW::Processor::process_one_interp(float &p_sample) {
-
float pre = p_sample;
p_sample = (p_sample * coeffs.b0 + hb1 * coeffs.b1 + hb2 * coeffs.b2 + ha1 * coeffs.a1 + ha2 * coeffs.a2);
ha2 = ha1;
diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp
index 7097c3934f..7613e70e64 100644
--- a/servers/audio/audio_rb_resampler.cpp
+++ b/servers/audio/audio_rb_resampler.cpp
@@ -34,9 +34,9 @@
#include "servers/audio_server.h"
int AudioRBResampler::get_channel_count() const {
-
- if (!rb)
+ if (!rb) {
return 0;
+ }
return channels;
}
@@ -46,11 +46,9 @@ int AudioRBResampler::get_channel_count() const {
// but it wasn't obvious to integrate that with VideoPlayer
template <int C>
uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_increment) {
-
uint32_t read = offset & MIX_FRAC_MASK;
for (int i = 0; i < p_todo; i++) {
-
offset = (offset + p_increment) & (((1 << (rb_bits + MIX_FRAC_BITS)) - 1));
read += p_increment;
uint32_t pos = offset >> MIX_FRAC_BITS;
@@ -60,7 +58,6 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
// since this is a template with a known compile time value (C), conditionals go away when compiling.
if (C == 1) {
-
float v0 = rb[pos];
float v0n = rb[pos_next];
v0 += (v0n - v0) * frac;
@@ -68,7 +65,6 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
}
if (C == 2) {
-
float v0 = rb[(pos << 1) + 0];
float v1 = rb[(pos << 1) + 1];
float v0n = rb[(pos_next << 1) + 0];
@@ -81,7 +77,6 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
// This will probably never be used, but added anyway
if (C == 4) {
-
float v0 = rb[(pos << 2) + 0];
float v1 = rb[(pos << 2) + 1];
float v0n = rb[(pos_next << 2) + 0];
@@ -92,7 +87,6 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
}
if (C == 6) {
-
float v0 = rb[(pos * 6) + 0];
float v1 = rb[(pos * 6) + 1];
float v0n = rb[(pos_next * 6) + 0];
@@ -108,9 +102,9 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
}
bool AudioRBResampler::mix(AudioFrame *p_dest, int p_frames) {
-
- if (!rb)
+ if (!rb) {
return false;
+ }
int32_t increment = (src_mix_rate * MIX_FRAC_LEN) / target_mix_rate;
int read_space = get_reader_space();
@@ -133,8 +127,9 @@ bool AudioRBResampler::mix(AudioFrame *p_dest, int p_frames) {
break;
}
- if (src_read > read_space)
+ if (src_read > read_space) {
src_read = read_space;
+ }
rb_read_pos = (rb_read_pos + src_read) & rb_mask;
@@ -155,15 +150,15 @@ bool AudioRBResampler::mix(AudioFrame *p_dest, int p_frames) {
}
int AudioRBResampler::get_num_of_ready_frames() {
- if (!is_ready())
+ if (!is_ready()) {
return 0;
+ }
int32_t increment = (src_mix_rate * MIX_FRAC_LEN) / target_mix_rate;
int read_space = get_reader_space();
return (int64_t(read_space) << MIX_FRAC_BITS) / increment;
}
Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_mix_rate, int p_buffer_msec, int p_minbuff_needed) {
-
ERR_FAIL_COND_V(p_channels != 1 && p_channels != 2 && p_channels != 4 && p_channels != 6, ERR_INVALID_PARAMETER);
int desired_rb_bits = nearest_shift(MAX((p_buffer_msec / 1000.0) * p_src_mix_rate, p_minbuff_needed));
@@ -171,14 +166,12 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
bool recreate = !rb;
if (rb && (uint32_t(desired_rb_bits) != rb_bits || channels != uint32_t(p_channels))) {
-
memdelete_arr(rb);
memdelete_arr(read_buf);
recreate = true;
}
if (recreate) {
-
channels = p_channels;
rb_bits = desired_rb_bits;
rb_len = (1 << rb_bits);
@@ -195,7 +188,6 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
//avoid maybe strange noises upon load
for (unsigned int i = 0; i < (rb_len * channels); i++) {
-
rb[i] = 0;
read_buf[i] = 0;
}
@@ -204,9 +196,9 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
}
void AudioRBResampler::clear() {
-
- if (!rb)
+ if (!rb) {
return;
+ }
//should be stopped at this point but just in case
memdelete_arr(rb);
@@ -219,7 +211,6 @@ void AudioRBResampler::clear() {
}
AudioRBResampler::AudioRBResampler() {
-
rb = nullptr;
offset = 0;
read_buf = nullptr;
@@ -236,7 +227,6 @@ AudioRBResampler::AudioRBResampler() {
}
AudioRBResampler::~AudioRBResampler() {
-
if (rb) {
memdelete_arr(rb);
memdelete_arr(read_buf);
diff --git a/servers/audio/audio_rb_resampler.h b/servers/audio/audio_rb_resampler.h
index 40cf3e4cd7..12ec526adb 100644
--- a/servers/audio/audio_rb_resampler.h
+++ b/servers/audio/audio_rb_resampler.h
@@ -36,7 +36,6 @@
#include "servers/audio_server.h"
struct AudioRBResampler {
-
uint32_t rb_bits;
uint32_t rb_len;
uint32_t rb_mask;
@@ -116,31 +115,24 @@ public:
_FORCE_INLINE_ float *get_write_buffer() { return read_buf; }
_FORCE_INLINE_ void write(uint32_t p_frames) {
-
ERR_FAIL_COND(p_frames >= rb_len);
switch (channels) {
case 1: {
-
for (uint32_t i = 0; i < p_frames; i++) {
-
rb[rb_write_pos] = read_buf[i];
rb_write_pos = (rb_write_pos + 1) & rb_mask;
}
} break;
case 2: {
-
for (uint32_t i = 0; i < p_frames; i++) {
-
rb[(rb_write_pos << 1) + 0] = read_buf[(i << 1) + 0];
rb[(rb_write_pos << 1) + 1] = read_buf[(i << 1) + 1];
rb_write_pos = (rb_write_pos + 1) & rb_mask;
}
} break;
case 4: {
-
for (uint32_t i = 0; i < p_frames; i++) {
-
rb[(rb_write_pos << 2) + 0] = read_buf[(i << 2) + 0];
rb[(rb_write_pos << 2) + 1] = read_buf[(i << 2) + 1];
rb[(rb_write_pos << 2) + 2] = read_buf[(i << 2) + 2];
@@ -149,9 +141,7 @@ public:
}
} break;
case 6: {
-
for (uint32_t i = 0; i < p_frames; i++) {
-
rb[(rb_write_pos * 6) + 0] = read_buf[(i * 6) + 0];
rb[(rb_write_pos * 6) + 1] = read_buf[(i * 6) + 1];
rb[(rb_write_pos * 6) + 2] = read_buf[(i * 6) + 2];
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 46e674fd9b..2cc2f5c291 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -36,7 +36,6 @@
//////////////////////////////
void AudioStreamPlaybackResampled::_begin_resample() {
-
//clear cubic interpolation history
internal_buffer[0] = AudioFrame(0.0, 0.0);
internal_buffer[1] = AudioFrame(0.0, 0.0);
@@ -48,14 +47,12 @@ void AudioStreamPlaybackResampled::_begin_resample() {
}
void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) {
-
float target_rate = AudioServer::get_singleton()->get_mix_rate();
float global_rate_scale = AudioServer::get_singleton()->get_global_rate_scale();
uint64_t mix_increment = uint64_t(((get_stream_sampling_rate() * p_rate_scale) / double(target_rate * global_rate_scale)) * double(FP_LEN));
for (int i = 0; i < p_frames; i++) {
-
uint32_t idx = CUBIC_INTERP_HISTORY + uint32_t(mix_offset >> FP_BITS);
//standard cubic interpolation (great quality/performance ratio)
//this used to be moved to a LUT for greater performance, but nowadays CPU speed is generally faster than memory.
@@ -76,7 +73,6 @@ void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale,
mix_offset += mix_increment;
while ((mix_offset >> FP_BITS) >= INTERNAL_BUFFER_LEN) {
-
internal_buffer[0] = internal_buffer[INTERNAL_BUFFER_LEN + 0];
internal_buffer[1] = internal_buffer[INTERNAL_BUFFER_LEN + 1];
internal_buffer[2] = internal_buffer[INTERNAL_BUFFER_LEN + 2];
@@ -97,7 +93,6 @@ void AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale,
////////////////////////////////
void AudioStream::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_length"), &AudioStream::get_length);
}
@@ -116,7 +111,6 @@ Ref<AudioStreamPlayback> AudioStreamMicrophone::instance_playback() {
}
String AudioStreamMicrophone::get_stream_name() const {
-
//if (audio_stream.is_valid()) {
//return "Random: " + audio_stream->get_name();
//}
@@ -134,7 +128,6 @@ AudioStreamMicrophone::AudioStreamMicrophone() {
}
void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_frames) {
-
AudioDriver::get_singleton()->lock();
Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer();
@@ -187,7 +180,6 @@ float AudioStreamPlaybackMicrophone::get_stream_sampling_rate() {
}
void AudioStreamPlaybackMicrophone::start(float p_from_pos) {
-
if (active) {
return;
}
@@ -239,7 +231,6 @@ AudioStreamPlaybackMicrophone::AudioStreamPlaybackMicrophone() {
////////////////////////////////
void AudioStreamRandomPitch::set_audio_stream(const Ref<AudioStream> &p_audio_stream) {
-
audio_stream = p_audio_stream;
if (audio_stream.is_valid()) {
for (Set<AudioStreamPlaybackRandomPitch *>::Element *E = playbacks.front(); E; E = E->next()) {
@@ -249,14 +240,13 @@ void AudioStreamRandomPitch::set_audio_stream(const Ref<AudioStream> &p_audio_st
}
Ref<AudioStream> AudioStreamRandomPitch::get_audio_stream() const {
-
return audio_stream;
}
void AudioStreamRandomPitch::set_random_pitch(float p_pitch) {
-
- if (p_pitch < 1)
+ if (p_pitch < 1) {
p_pitch = 1;
+ }
random_pitch = p_pitch;
}
@@ -267,8 +257,9 @@ float AudioStreamRandomPitch::get_random_pitch() const {
Ref<AudioStreamPlayback> AudioStreamRandomPitch::instance_playback() {
Ref<AudioStreamPlaybackRandomPitch> playback;
playback.instance();
- if (audio_stream.is_valid())
+ if (audio_stream.is_valid()) {
playback->playback = audio_stream->instance_playback();
+ }
playbacks.insert(playback.ptr());
playback->random_pitch = Ref<AudioStreamRandomPitch>((AudioStreamRandomPitch *)this);
@@ -276,7 +267,6 @@ Ref<AudioStreamPlayback> AudioStreamRandomPitch::instance_playback() {
}
String AudioStreamRandomPitch::get_stream_name() const {
-
if (audio_stream.is_valid()) {
return "Random: " + audio_stream->get_name();
}
@@ -292,7 +282,6 @@ float AudioStreamRandomPitch::get_length() const {
}
void AudioStreamRandomPitch::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_audio_stream", "stream"), &AudioStreamRandomPitch::set_audio_stream);
ClassDB::bind_method(D_METHOD("get_audio_stream"), &AudioStreamRandomPitch::get_audio_stream);
@@ -325,6 +314,7 @@ void AudioStreamPlaybackRandomPitch::stop() {
;
}
}
+
bool AudioStreamPlaybackRandomPitch::is_playing() const {
if (playing.is_valid()) {
return playing->is_playing();
@@ -348,6 +338,7 @@ float AudioStreamPlaybackRandomPitch::get_playback_position() const {
return 0;
}
+
void AudioStreamPlaybackRandomPitch::seek(float p_time) {
if (playing.is_valid()) {
playing->seek(p_time);
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index 155b683d7d..fc66fd1ff7 100644
--- a/servers/audio/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -37,7 +37,6 @@
#include "servers/audio_server.h"
class AudioStreamPlayback : public Reference {
-
GDCLASS(AudioStreamPlayback, Reference);
public:
@@ -54,7 +53,6 @@ public:
};
class AudioStreamPlaybackResampled : public AudioStreamPlayback {
-
GDCLASS(AudioStreamPlaybackResampled, AudioStreamPlayback);
enum {
@@ -80,7 +78,6 @@ public:
};
class AudioStream : public Resource {
-
GDCLASS(AudioStream, Resource);
OBJ_SAVE_TYPE(AudioStream); // Saves derived classes with common type so they can be interchanged.
@@ -99,7 +96,6 @@ public:
class AudioStreamPlaybackMicrophone;
class AudioStreamMicrophone : public AudioStream {
-
GDCLASS(AudioStreamMicrophone, AudioStream);
friend class AudioStreamPlaybackMicrophone;
@@ -118,7 +114,6 @@ public:
};
class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
-
GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlaybackResampled);
friend class AudioStreamMicrophone;
@@ -152,7 +147,6 @@ public:
class AudioStreamPlaybackRandomPitch;
class AudioStreamRandomPitch : public AudioStream {
-
GDCLASS(AudioStreamRandomPitch, AudioStream);
friend class AudioStreamPlaybackRandomPitch;
@@ -179,7 +173,6 @@ public:
};
class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {
-
GDCLASS(AudioStreamPlaybackRandomPitch, AudioStreamPlayback);
friend class AudioStreamRandomPitch;
diff --git a/servers/audio/effects/audio_effect_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp
index 8ad2ecc5ce..74fdcbc67a 100644
--- a/servers/audio/effects/audio_effect_amplify.cpp
+++ b/servers/audio/effects/audio_effect_amplify.cpp
@@ -31,7 +31,6 @@
#include "audio_effect_amplify.h"
void AudioEffectAmplifyInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
//multiply volume interpolating to avoid clicks if this changes
float volume_db = base->volume_db;
float vol = Math::db2linear(mix_volume_db);
@@ -58,12 +57,10 @@ void AudioEffectAmplify::set_volume_db(float p_volume) {
}
float AudioEffectAmplify::get_volume_db() const {
-
return volume_db;
}
void AudioEffectAmplify::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_volume_db", "volume"), &AudioEffectAmplify::set_volume_db);
ClassDB::bind_method(D_METHOD("get_volume_db"), &AudioEffectAmplify::get_volume_db);
diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp
index 34c03dca8d..2b530475f0 100644
--- a/servers/audio/effects/audio_effect_chorus.cpp
+++ b/servers/audio/effects/audio_effect_chorus.cpp
@@ -33,11 +33,9 @@
#include "servers/audio_server.h"
void AudioEffectChorusInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
int todo = p_frame_count;
while (todo) {
-
int to_mix = MIN(todo, 256); //can't mix too much
_process_chunk(p_src_frames, p_dst_frames, to_mix);
@@ -50,7 +48,6 @@ void AudioEffectChorusInstance::process(const AudioFrame *p_src_frames, AudioFra
}
void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
//fill ringbuffer
for (int i = 0; i < p_frame_count; i++) {
audio_buffer.write[(buffer_pos + i) & buffer_mask] = p_src_frames[i];
@@ -61,7 +58,6 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
/* process voices */
for (int vc = 0; vc < base->voice_count; vc++) {
-
AudioEffectChorus::Voice &v = base->voice[vc];
double time_to_mix = (float)p_frame_count / mix_rate;
@@ -85,8 +81,9 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
}
//low pass filter
- if (v.cutoff == 0)
+ if (v.cutoff == 0) {
continue;
+ }
float auxlp = expf(-2.0 * Math_PI * v.cutoff / mix_rate);
float c1 = 1.0 - auxlp;
float c2 = auxlp;
@@ -103,7 +100,6 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
vol_modifier.r *= CLAMP(1.0 + v.pan, 0, 1);
for (int i = 0; i < p_frame_count; i++) {
-
/** COMPUTE WAVEFORM **/
float phase = (float)(local_cycles & AudioEffectChorus::CYCLES_MASK) / (float)(1 << AudioEffectChorus::CYCLES_FRAC);
@@ -146,7 +142,6 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
}
Ref<AudioEffectInstance> AudioEffectChorus::instance() {
-
Ref<AudioEffectChorusInstance> ins;
ins.instance();
ins->base = Ref<AudioEffectChorus>(this);
@@ -182,24 +177,21 @@ Ref<AudioEffectInstance> AudioEffectChorus::instance() {
}
void AudioEffectChorus::set_voice_count(int p_voices) {
-
ERR_FAIL_COND(p_voices < 1 || p_voices > MAX_VOICES);
voice_count = p_voices;
}
int AudioEffectChorus::get_voice_count() const {
-
return voice_count;
}
void AudioEffectChorus::set_voice_delay_ms(int p_voice, float p_delay_ms) {
-
ERR_FAIL_INDEX(p_voice, MAX_VOICES);
voice[p_voice].delay = p_delay_ms;
}
-float AudioEffectChorus::get_voice_delay_ms(int p_voice) const {
+float AudioEffectChorus::get_voice_delay_ms(int p_voice) const {
ERR_FAIL_INDEX_V(p_voice, MAX_VOICES, 0);
return voice[p_voice].delay;
}
@@ -209,85 +201,78 @@ void AudioEffectChorus::set_voice_rate_hz(int p_voice, float p_rate_hz) {
voice[p_voice].rate = p_rate_hz;
}
-float AudioEffectChorus::get_voice_rate_hz(int p_voice) const {
+float AudioEffectChorus::get_voice_rate_hz(int p_voice) const {
ERR_FAIL_INDEX_V(p_voice, MAX_VOICES, 0);
return voice[p_voice].rate;
}
void AudioEffectChorus::set_voice_depth_ms(int p_voice, float p_depth_ms) {
-
ERR_FAIL_INDEX(p_voice, MAX_VOICES);
voice[p_voice].depth = p_depth_ms;
}
-float AudioEffectChorus::get_voice_depth_ms(int p_voice) const {
+float AudioEffectChorus::get_voice_depth_ms(int p_voice) const {
ERR_FAIL_INDEX_V(p_voice, MAX_VOICES, 0);
return voice[p_voice].depth;
}
void AudioEffectChorus::set_voice_level_db(int p_voice, float p_level_db) {
-
ERR_FAIL_INDEX(p_voice, MAX_VOICES);
voice[p_voice].level = p_level_db;
}
-float AudioEffectChorus::get_voice_level_db(int p_voice) const {
+float AudioEffectChorus::get_voice_level_db(int p_voice) const {
ERR_FAIL_INDEX_V(p_voice, MAX_VOICES, 0);
return voice[p_voice].level;
}
void AudioEffectChorus::set_voice_cutoff_hz(int p_voice, float p_cutoff_hz) {
-
ERR_FAIL_INDEX(p_voice, MAX_VOICES);
voice[p_voice].cutoff = p_cutoff_hz;
}
-float AudioEffectChorus::get_voice_cutoff_hz(int p_voice) const {
+float AudioEffectChorus::get_voice_cutoff_hz(int p_voice) const {
ERR_FAIL_INDEX_V(p_voice, MAX_VOICES, 0);
return voice[p_voice].cutoff;
}
void AudioEffectChorus::set_voice_pan(int p_voice, float p_pan) {
-
ERR_FAIL_INDEX(p_voice, MAX_VOICES);
voice[p_voice].pan = p_pan;
}
-float AudioEffectChorus::get_voice_pan(int p_voice) const {
+float AudioEffectChorus::get_voice_pan(int p_voice) const {
ERR_FAIL_INDEX_V(p_voice, MAX_VOICES, 0);
return voice[p_voice].pan;
}
void AudioEffectChorus::set_wet(float amount) {
-
wet = amount;
}
-float AudioEffectChorus::get_wet() const {
+float AudioEffectChorus::get_wet() const {
return wet;
}
void AudioEffectChorus::set_dry(float amount) {
-
dry = amount;
}
-float AudioEffectChorus::get_dry() const {
+float AudioEffectChorus::get_dry() const {
return dry;
}
void AudioEffectChorus::_validate_property(PropertyInfo &property) const {
-
if (property.name.begins_with("voice/")) {
int voice_idx = property.name.get_slice("/", 1).to_int();
if (voice_idx > voice_count) {
@@ -297,7 +282,6 @@ void AudioEffectChorus::_validate_property(PropertyInfo &property) const {
}
void AudioEffectChorus::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_voice_count", "voices"), &AudioEffectChorus::set_voice_count);
ClassDB::bind_method(D_METHOD("get_voice_count"), &AudioEffectChorus::get_voice_count);
diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h
index ab5053b919..4d15c518d6 100644
--- a/servers/audio/effects/audio_effect_chorus.h
+++ b/servers/audio/effects/audio_effect_chorus.h
@@ -73,7 +73,6 @@ public:
private:
struct Voice {
-
float delay;
float rate;
float depth;
@@ -82,7 +81,6 @@ private:
float pan;
Voice() {
-
delay = 12.0;
rate = 1;
depth = 0;
diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp
index 8d54bd8e36..4b0b4dabea 100644
--- a/servers/audio/effects/audio_effect_compressor.cpp
+++ b/servers/audio/effects/audio_effect_compressor.cpp
@@ -32,7 +32,6 @@
#include "servers/audio_server.h"
void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float threshold = Math::db2linear(base->threshold);
float sample_rate = AudioServer::get_singleton()->get_mix_rate();
@@ -51,7 +50,6 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi
const AudioFrame *src = p_src_frames;
if (base->sidechain != StringName() && current_channel != -1) {
-
int bus = AudioServer::get_singleton()->thread_find_bus_index(base->sidechain);
if (bus >= 0) {
src = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus, current_channel);
@@ -59,7 +57,6 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi
}
for (int i = 0; i < p_frame_count; i++) {
-
AudioFrame s = src[i];
//convert to positive
s.l = Math::abs(s.l);
@@ -69,11 +66,13 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi
float overdb = 2.08136898f * Math::linear2db(peak / threshold);
- if (overdb < 0.0) //we only care about what goes over to compress
+ if (overdb < 0.0) { //we only care about what goes over to compress
overdb = 0.0;
+ }
- if (overdb - rundb > 5) // diffeence is too large
+ if (overdb - rundb > 5) { // diffeence is too large
averatio = 4;
+ }
if (overdb > rundb) {
rundb = overdb + atcoef * (rundb - overdb);
@@ -104,8 +103,9 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi
gr_meter = grv;
} else {
gr_meter *= gr_meter_decay;
- if (gr_meter > 1)
+ if (gr_meter > 1) {
gr_meter = 1;
+ }
}
p_dst_frames[i] = p_src_frames[i] * grv * makeup * mix + p_src_frames[i] * (1.0 - mix);
@@ -127,76 +127,65 @@ Ref<AudioEffectInstance> AudioEffectCompressor::instance() {
}
void AudioEffectCompressor::set_threshold(float p_threshold) {
-
threshold = p_threshold;
}
float AudioEffectCompressor::get_threshold() const {
-
return threshold;
}
void AudioEffectCompressor::set_ratio(float p_ratio) {
-
ratio = p_ratio;
}
-float AudioEffectCompressor::get_ratio() const {
+float AudioEffectCompressor::get_ratio() const {
return ratio;
}
void AudioEffectCompressor::set_gain(float p_gain) {
-
gain = p_gain;
}
-float AudioEffectCompressor::get_gain() const {
+float AudioEffectCompressor::get_gain() const {
return gain;
}
void AudioEffectCompressor::set_attack_us(float p_attack_us) {
-
attack_us = p_attack_us;
}
-float AudioEffectCompressor::get_attack_us() const {
+float AudioEffectCompressor::get_attack_us() const {
return attack_us;
}
void AudioEffectCompressor::set_release_ms(float p_release_ms) {
-
release_ms = p_release_ms;
}
-float AudioEffectCompressor::get_release_ms() const {
+float AudioEffectCompressor::get_release_ms() const {
return release_ms;
}
void AudioEffectCompressor::set_mix(float p_mix) {
-
mix = p_mix;
}
-float AudioEffectCompressor::get_mix() const {
+float AudioEffectCompressor::get_mix() const {
return mix;
}
void AudioEffectCompressor::set_sidechain(const StringName &p_sidechain) {
-
AudioServer::get_singleton()->lock();
sidechain = p_sidechain;
AudioServer::get_singleton()->unlock();
}
StringName AudioEffectCompressor::get_sidechain() const {
-
return sidechain;
}
void AudioEffectCompressor::_validate_property(PropertyInfo &property) const {
-
if (property.name == "sidechain") {
-
String buses = "";
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
buses += ",";
@@ -208,7 +197,6 @@ void AudioEffectCompressor::_validate_property(PropertyInfo &property) const {
}
void AudioEffectCompressor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_threshold", "threshold"), &AudioEffectCompressor::set_threshold);
ClassDB::bind_method(D_METHOD("get_threshold"), &AudioEffectCompressor::get_threshold);
diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp
index fa57a94977..d6ab14be89 100644
--- a/servers/audio/effects/audio_effect_delay.cpp
+++ b/servers/audio/effects/audio_effect_delay.cpp
@@ -33,11 +33,9 @@
#include "servers/audio_server.h"
void AudioEffectDelayInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
int todo = p_frame_count;
while (todo) {
-
int to_mix = MIN(todo, 256); //can't mix too much
_process_chunk(p_src_frames, p_dst_frames, to_mix);
@@ -50,7 +48,6 @@ void AudioEffectDelayInstance::process(const AudioFrame *p_src_frames, AudioFram
}
void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float main_level_f = base->dry;
float mix_rate = AudioServer::get_singleton()->get_mix_rate();
@@ -87,7 +84,6 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au
AudioFrame *fb_buf = feedback_buffer.ptrw();
for (int i = 0; i < p_frame_count; i++) {
-
rb_buf[ring_buffer_pos & ring_buffer_mask] = src[i];
AudioFrame main_val = src[i] * main_level_f;
@@ -109,8 +105,9 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au
ring_buffer_pos++;
- if ((++feedback_buffer_pos) >= feedback_delay_frames)
+ if ((++feedback_buffer_pos) >= feedback_delay_frames) {
feedback_buffer_pos = 0;
+ }
}
}
@@ -147,125 +144,110 @@ Ref<AudioEffectInstance> AudioEffectDelay::instance() {
}
void AudioEffectDelay::set_dry(float p_dry) {
-
dry = p_dry;
}
float AudioEffectDelay::get_dry() {
-
return dry;
}
void AudioEffectDelay::set_tap1_active(bool p_active) {
-
tap_1_active = p_active;
}
-bool AudioEffectDelay::is_tap1_active() const {
+bool AudioEffectDelay::is_tap1_active() const {
return tap_1_active;
}
void AudioEffectDelay::set_tap1_delay_ms(float p_delay_ms) {
-
tap_1_delay_ms = p_delay_ms;
}
-float AudioEffectDelay::get_tap1_delay_ms() const {
+float AudioEffectDelay::get_tap1_delay_ms() const {
return tap_1_delay_ms;
}
void AudioEffectDelay::set_tap1_level_db(float p_level_db) {
-
tap_1_level = p_level_db;
}
-float AudioEffectDelay::get_tap1_level_db() const {
+float AudioEffectDelay::get_tap1_level_db() const {
return tap_1_level;
}
void AudioEffectDelay::set_tap1_pan(float p_pan) {
-
tap_1_pan = p_pan;
}
-float AudioEffectDelay::get_tap1_pan() const {
+float AudioEffectDelay::get_tap1_pan() const {
return tap_1_pan;
}
void AudioEffectDelay::set_tap2_active(bool p_active) {
-
tap_2_active = p_active;
}
-bool AudioEffectDelay::is_tap2_active() const {
+bool AudioEffectDelay::is_tap2_active() const {
return tap_2_active;
}
void AudioEffectDelay::set_tap2_delay_ms(float p_delay_ms) {
-
tap_2_delay_ms = p_delay_ms;
}
-float AudioEffectDelay::get_tap2_delay_ms() const {
+float AudioEffectDelay::get_tap2_delay_ms() const {
return tap_2_delay_ms;
}
void AudioEffectDelay::set_tap2_level_db(float p_level_db) {
-
tap_2_level = p_level_db;
}
-float AudioEffectDelay::get_tap2_level_db() const {
+float AudioEffectDelay::get_tap2_level_db() const {
return tap_2_level;
}
void AudioEffectDelay::set_tap2_pan(float p_pan) {
-
tap_2_pan = p_pan;
}
-float AudioEffectDelay::get_tap2_pan() const {
+float AudioEffectDelay::get_tap2_pan() const {
return tap_2_pan;
}
void AudioEffectDelay::set_feedback_active(bool p_active) {
-
feedback_active = p_active;
}
-bool AudioEffectDelay::is_feedback_active() const {
+bool AudioEffectDelay::is_feedback_active() const {
return feedback_active;
}
void AudioEffectDelay::set_feedback_delay_ms(float p_delay_ms) {
-
feedback_delay_ms = p_delay_ms;
}
-float AudioEffectDelay::get_feedback_delay_ms() const {
+float AudioEffectDelay::get_feedback_delay_ms() const {
return feedback_delay_ms;
}
void AudioEffectDelay::set_feedback_level_db(float p_level_db) {
-
feedback_level = p_level_db;
}
-float AudioEffectDelay::get_feedback_level_db() const {
+float AudioEffectDelay::get_feedback_level_db() const {
return feedback_level;
}
void AudioEffectDelay::set_feedback_lowpass(float p_lowpass) {
-
feedback_lowpass = p_lowpass;
}
-float AudioEffectDelay::get_feedback_lowpass() const {
+float AudioEffectDelay::get_feedback_lowpass() const {
return feedback_lowpass;
}
void AudioEffectDelay::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_dry", "amount"), &AudioEffectDelay::set_dry);
ClassDB::bind_method(D_METHOD("get_dry"), &AudioEffectDelay::get_dry);
diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp
index bc4fc7ecd6..dc5c2cc16f 100644
--- a/servers/audio/effects/audio_effect_distortion.cpp
+++ b/servers/audio/effects/audio_effect_distortion.cpp
@@ -33,7 +33,6 @@
#include "servers/audio_server.h"
void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
const float *src = (const float *)p_src_frames;
float *dst = (float *)p_dst_frames;
@@ -51,7 +50,6 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi
float lofi_mult = powf(2.0, 2.0 + (1.0 - drive_f) * 14); //goes from 16 to 2 bits
for (int i = 0; i < p_frame_count * 2; i++) {
-
float out = undenormalise(src[i] * lpf_ic + lpf_c * h[i & 1]);
h[i & 1] = out;
float a = out;
@@ -59,28 +57,24 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi
a *= pregain_f;
switch (base->mode) {
-
case AudioEffectDistortion::MODE_CLIP: {
-
a = powf(a, 1.0001 - drive_f);
- if (a > 1.0)
+ if (a > 1.0) {
a = 1.0;
- else if (a < (-1.0))
+ } else if (a < (-1.0)) {
a = -1.0;
+ }
} break;
case AudioEffectDistortion::MODE_ATAN: {
-
a = atanf(a * atan_mult) * atan_div;
} break;
case AudioEffectDistortion::MODE_LOFI: {
-
a = floorf(a * lofi_mult + 0.5) / lofi_mult;
} break;
case AudioEffectDistortion::MODE_OVERDRIVE: {
-
const double x = a * 0.686306;
const double z = 1 + exp(sqrt(fabs(x)) * -0.75);
a = (expf(x) - expf(-x * z)) / (expf(x) + expf(-x));
@@ -109,53 +103,46 @@ Ref<AudioEffectInstance> AudioEffectDistortion::instance() {
}
void AudioEffectDistortion::set_mode(Mode p_mode) {
-
mode = p_mode;
}
AudioEffectDistortion::Mode AudioEffectDistortion::get_mode() const {
-
return mode;
}
void AudioEffectDistortion::set_pre_gain(float p_pre_gain) {
-
pre_gain = p_pre_gain;
}
-float AudioEffectDistortion::get_pre_gain() const {
+float AudioEffectDistortion::get_pre_gain() const {
return pre_gain;
}
void AudioEffectDistortion::set_keep_hf_hz(float p_keep_hf_hz) {
-
keep_hf_hz = p_keep_hf_hz;
}
-float AudioEffectDistortion::get_keep_hf_hz() const {
+float AudioEffectDistortion::get_keep_hf_hz() const {
return keep_hf_hz;
}
void AudioEffectDistortion::set_drive(float p_drive) {
-
drive = p_drive;
}
-float AudioEffectDistortion::get_drive() const {
+float AudioEffectDistortion::get_drive() const {
return drive;
}
void AudioEffectDistortion::set_post_gain(float p_post_gain) {
-
post_gain = p_post_gain;
}
-float AudioEffectDistortion::get_post_gain() const {
+float AudioEffectDistortion::get_post_gain() const {
return post_gain;
}
void AudioEffectDistortion::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &AudioEffectDistortion::set_mode);
ClassDB::bind_method(D_METHOD("get_mode"), &AudioEffectDistortion::get_mode);
diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp
index b315fdc3bb..ed4e7122b5 100644
--- a/servers/audio/effects/audio_effect_eq.cpp
+++ b/servers/audio/effects/audio_effect_eq.cpp
@@ -32,7 +32,6 @@
#include "servers/audio_server.h"
void AudioEffectEQInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
int band_count = bands[0].size();
EQ::BandProcess *proc_l = bands[0].ptrw();
EQ::BandProcess *proc_r = bands[1].ptrw();
@@ -42,12 +41,10 @@ void AudioEffectEQInstance::process(const AudioFrame *p_src_frames, AudioFrame *
}
for (int i = 0; i < p_frame_count; i++) {
-
AudioFrame src = p_src_frames[i];
AudioFrame dst = AudioFrame(0, 0);
for (int j = 0; j < band_count; j++) {
-
float l = src.l;
float r = src.r;
@@ -87,12 +84,12 @@ float AudioEffectEQ::get_band_gain_db(int p_band) const {
return gain[p_band];
}
+
int AudioEffectEQ::get_band_count() const {
return gain.size();
}
bool AudioEffectEQ::_set(const StringName &p_name, const Variant &p_value) {
-
const Map<StringName, int>::Element *E = prop_band_map.find(p_name);
if (E) {
set_band_gain_db(E->get(), p_value);
@@ -103,7 +100,6 @@ bool AudioEffectEQ::_set(const StringName &p_name, const Variant &p_value) {
}
bool AudioEffectEQ::_get(const StringName &p_name, Variant &r_ret) const {
-
const Map<StringName, int>::Element *E = prop_band_map.find(p_name);
if (E) {
r_ret = get_band_gain_db(E->get());
@@ -114,22 +110,18 @@ bool AudioEffectEQ::_get(const StringName &p_name, Variant &r_ret) const {
}
void AudioEffectEQ::_get_property_list(List<PropertyInfo> *p_list) const {
-
for (int i = 0; i < band_names.size(); i++) {
-
p_list->push_back(PropertyInfo(Variant::FLOAT, band_names[i], PROPERTY_HINT_RANGE, "-60,24,0.1"));
}
}
void AudioEffectEQ::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_band_gain_db", "band_idx", "volume_db"), &AudioEffectEQ::set_band_gain_db);
ClassDB::bind_method(D_METHOD("get_band_gain_db", "band_idx"), &AudioEffectEQ::get_band_gain_db);
ClassDB::bind_method(D_METHOD("get_band_count"), &AudioEffectEQ::get_band_count);
}
AudioEffectEQ::AudioEffectEQ(EQ::Preset p_preset) {
-
eq.set_mix_rate(AudioServer::get_singleton()->get_mix_rate());
eq.set_preset_band_mode(p_preset);
gain.resize(eq.get_band_count());
diff --git a/servers/audio/effects/audio_effect_filter.cpp b/servers/audio/effects/audio_effect_filter.cpp
index 18047bc99e..a5135ee1a6 100644
--- a/servers/audio/effects/audio_effect_filter.cpp
+++ b/servers/audio/effects/audio_effect_filter.cpp
@@ -33,16 +33,18 @@
template <int S>
void AudioEffectFilterInstance::_process_filter(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
for (int i = 0; i < p_frame_count; i++) {
float f = p_src_frames[i].l;
filter_process[0][0].process_one(f);
- if (S > 1)
+ if (S > 1) {
filter_process[0][1].process_one(f);
- if (S > 2)
+ }
+ if (S > 2) {
filter_process[0][2].process_one(f);
- if (S > 3)
+ }
+ if (S > 3) {
filter_process[0][3].process_one(f);
+ }
p_dst_frames[i].l = f;
}
@@ -50,19 +52,21 @@ void AudioEffectFilterInstance::_process_filter(const AudioFrame *p_src_frames,
for (int i = 0; i < p_frame_count; i++) {
float f = p_src_frames[i].r;
filter_process[1][0].process_one(f);
- if (S > 1)
+ if (S > 1) {
filter_process[1][1].process_one(f);
- if (S > 2)
+ }
+ if (S > 2) {
filter_process[1][2].process_one(f);
- if (S > 3)
+ }
+ if (S > 3) {
filter_process[1][3].process_one(f);
+ }
p_dst_frames[i].r = f;
}
}
void AudioEffectFilterInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
filter.set_cutoff(base->cutoff);
filter.set_gain(base->gain);
filter.set_resonance(base->resonance);
@@ -89,7 +93,6 @@ void AudioEffectFilterInstance::process(const AudioFrame *p_src_frames, AudioFra
}
AudioEffectFilterInstance::AudioEffectFilterInstance() {
-
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 4; j++) {
filter_process[i][j].set_filter(&filter);
@@ -106,30 +109,26 @@ Ref<AudioEffectInstance> AudioEffectFilter::instance() {
}
void AudioEffectFilter::set_cutoff(float p_freq) {
-
cutoff = p_freq;
}
float AudioEffectFilter::get_cutoff() const {
-
return cutoff;
}
void AudioEffectFilter::set_resonance(float p_amount) {
-
resonance = p_amount;
}
-float AudioEffectFilter::get_resonance() const {
+float AudioEffectFilter::get_resonance() const {
return resonance;
}
void AudioEffectFilter::set_gain(float p_amount) {
-
gain = p_amount;
}
-float AudioEffectFilter::get_gain() const {
+float AudioEffectFilter::get_gain() const {
return gain;
}
@@ -138,12 +137,10 @@ void AudioEffectFilter::set_db(FilterDB p_db) {
}
AudioEffectFilter::FilterDB AudioEffectFilter::get_db() const {
-
return db;
}
void AudioEffectFilter::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_cutoff", "freq"), &AudioEffectFilter::set_cutoff);
ClassDB::bind_method(D_METHOD("get_cutoff"), &AudioEffectFilter::get_cutoff);
@@ -168,7 +165,6 @@ void AudioEffectFilter::_bind_methods() {
}
AudioEffectFilter::AudioEffectFilter(AudioFilterSW::Mode p_mode) {
-
mode = p_mode;
cutoff = 2000;
resonance = 0.5;
diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h
index c439c5a5b5..b11a4e3623 100644
--- a/servers/audio/effects/audio_effect_filter.h
+++ b/servers/audio/effects/audio_effect_filter.h
@@ -99,8 +99,9 @@ class AudioEffectLowPassFilter : public AudioEffectFilter {
GDCLASS(AudioEffectLowPassFilter, AudioEffectFilter);
void _validate_property(PropertyInfo &property) const {
- if (property.name == "gain")
+ if (property.name == "gain") {
property.usage = 0;
+ }
}
public:
@@ -111,8 +112,9 @@ public:
class AudioEffectHighPassFilter : public AudioEffectFilter {
GDCLASS(AudioEffectHighPassFilter, AudioEffectFilter);
void _validate_property(PropertyInfo &property) const {
- if (property.name == "gain")
+ if (property.name == "gain") {
property.usage = 0;
+ }
}
public:
@@ -123,8 +125,9 @@ public:
class AudioEffectBandPassFilter : public AudioEffectFilter {
GDCLASS(AudioEffectBandPassFilter, AudioEffectFilter);
void _validate_property(PropertyInfo &property) const {
- if (property.name == "gain")
+ if (property.name == "gain") {
property.usage = 0;
+ }
}
public:
diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp
index 40a4243168..27f1aaf71f 100644
--- a/servers/audio/effects/audio_effect_limiter.cpp
+++ b/servers/audio/effects/audio_effect_limiter.cpp
@@ -31,7 +31,6 @@
#include "audio_effect_limiter.h"
void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float threshdb = base->threshold;
float ceiling = Math::db2linear(base->ceiling);
float ceildb = base->ceiling;
@@ -42,7 +41,6 @@ void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFr
float scmult = Math::abs((ceildb - sc) / (peakdb - sc));
for (int i = 0; i < p_frame_count; i++) {
-
float spl0 = p_src_frames[i].l;
float spl1 = p_src_frames[i].r;
spl0 = spl0 * makeup;
@@ -78,44 +76,38 @@ Ref<AudioEffectInstance> AudioEffectLimiter::instance() {
}
void AudioEffectLimiter::set_threshold_db(float p_threshold) {
-
threshold = p_threshold;
}
float AudioEffectLimiter::get_threshold_db() const {
-
return threshold;
}
void AudioEffectLimiter::set_ceiling_db(float p_ceiling) {
-
ceiling = p_ceiling;
}
-float AudioEffectLimiter::get_ceiling_db() const {
+float AudioEffectLimiter::get_ceiling_db() const {
return ceiling;
}
void AudioEffectLimiter::set_soft_clip_db(float p_soft_clip) {
-
soft_clip = p_soft_clip;
}
-float AudioEffectLimiter::get_soft_clip_db() const {
+float AudioEffectLimiter::get_soft_clip_db() const {
return soft_clip;
}
void AudioEffectLimiter::set_soft_clip_ratio(float p_soft_clip) {
-
soft_clip_ratio = p_soft_clip;
}
-float AudioEffectLimiter::get_soft_clip_ratio() const {
+float AudioEffectLimiter::get_soft_clip_ratio() const {
return soft_clip_ratio;
}
void AudioEffectLimiter::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_ceiling_db", "ceiling"), &AudioEffectLimiter::set_ceiling_db);
ClassDB::bind_method(D_METHOD("get_ceiling_db"), &AudioEffectLimiter::get_ceiling_db);
diff --git a/servers/audio/effects/audio_effect_panner.cpp b/servers/audio/effects/audio_effect_panner.cpp
index 10724175e5..32b7921d1f 100644
--- a/servers/audio/effects/audio_effect_panner.cpp
+++ b/servers/audio/effects/audio_effect_panner.cpp
@@ -31,12 +31,10 @@
#include "audio_effect_panner.h"
void AudioEffectPannerInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float lvol = CLAMP(1.0 - base->pan, 0, 1);
float rvol = CLAMP(1.0 + base->pan, 0, 1);
for (int i = 0; i < p_frame_count; i++) {
-
p_dst_frames[i].l = p_src_frames[i].l * lvol + p_src_frames[i].r * (1.0 - rvol);
p_dst_frames[i].r = p_src_frames[i].r * rvol + p_src_frames[i].l * (1.0 - lvol);
}
@@ -54,12 +52,10 @@ void AudioEffectPanner::set_pan(float p_cpanume) {
}
float AudioEffectPanner::get_pan() const {
-
return pan;
}
void AudioEffectPanner::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_pan", "cpanume"), &AudioEffectPanner::set_pan);
ClassDB::bind_method(D_METHOD("get_pan"), &AudioEffectPanner::get_pan);
diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp
index 3709b69d45..ffeaa7d25e 100644
--- a/servers/audio/effects/audio_effect_phaser.cpp
+++ b/servers/audio/effects/audio_effect_phaser.cpp
@@ -33,7 +33,6 @@
#include "servers/audio_server.h"
void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float sampling_rate = AudioServer::get_singleton()->get_mix_rate();
float dmin = base->range_min / (sampling_rate / 2.0);
@@ -42,7 +41,6 @@ void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames, AudioFra
float increment = 2.f * Math_PI * (base->rate / sampling_rate);
for (int i = 0; i < p_frame_count; i++) {
-
phase += increment;
while (phase >= Math_PI * 2.f) {
@@ -91,54 +89,46 @@ Ref<AudioEffectInstance> AudioEffectPhaser::instance() {
}
void AudioEffectPhaser::set_range_min_hz(float p_hz) {
-
range_min = p_hz;
}
float AudioEffectPhaser::get_range_min_hz() const {
-
return range_min;
}
void AudioEffectPhaser::set_range_max_hz(float p_hz) {
-
range_max = p_hz;
}
-float AudioEffectPhaser::get_range_max_hz() const {
+float AudioEffectPhaser::get_range_max_hz() const {
return range_max;
}
void AudioEffectPhaser::set_rate_hz(float p_hz) {
-
rate = p_hz;
}
-float AudioEffectPhaser::get_rate_hz() const {
+float AudioEffectPhaser::get_rate_hz() const {
return rate;
}
void AudioEffectPhaser::set_feedback(float p_fbk) {
-
feedback = p_fbk;
}
-float AudioEffectPhaser::get_feedback() const {
+float AudioEffectPhaser::get_feedback() const {
return feedback;
}
void AudioEffectPhaser::set_depth(float p_depth) {
-
depth = p_depth;
}
float AudioEffectPhaser::get_depth() const {
-
return depth;
}
void AudioEffectPhaser::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_range_min_hz", "hz"), &AudioEffectPhaser::set_range_min_hz);
ClassDB::bind_method(D_METHOD("get_range_min_hz"), &AudioEffectPhaser::get_range_min_hz);
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp
index a74ac3c007..fb6b56d984 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.cpp
+++ b/servers/audio/effects/audio_effect_pitch_shift.cpp
@@ -94,7 +94,9 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
freqPerBin = sampleRate/(double)fftFrameSize;
expct = 2.*Math_PI*(double)stepSize/(double)fftFrameSize;
inFifoLatency = fftFrameSize-stepSize;
- if (gRover == 0) gRover = inFifoLatency;
+ if (gRover == 0) { gRover = inFifoLatency;
+
+}
/* initialize our static arrays */
@@ -142,8 +144,10 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
/* map delta phase into +/- Pi interval */
qpd = tmp/Math_PI;
- if (qpd >= 0) qpd += qpd&1;
- else qpd -= qpd&1;
+ if (qpd >= 0) { qpd += qpd&1;
+ } else { qpd -= qpd&1;
+
+}
tmp -= Math_PI*(double)qpd;
/* get deviation from bin frequency from the +/- Pi interval */
@@ -200,7 +204,9 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
}
/* zero negative frequencies */
- for (k = fftFrameSize+2; k < 2*fftFrameSize; k++) gFFTworksp[k] = 0.;
+ for (k = fftFrameSize+2; k < 2*fftFrameSize; k++) { gFFTworksp[k] = 0.;
+
+}
/* do inverse transform */
smbFft(gFFTworksp, fftFrameSize, 1);
@@ -210,13 +216,17 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5;
gOutputAccum[k] += 2.*window*gFFTworksp[2*k]/(fftFrameSize2*osamp);
}
- for (k = 0; k < stepSize; k++) gOutFIFO[k] = gOutputAccum[k];
+ for (k = 0; k < stepSize; k++) { gOutFIFO[k] = gOutputAccum[k];
+
+}
/* shift accumulator */
memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*sizeof(float));
/* move input FIFO */
- for (k = 0; k < inFifoLatency; k++) gInFIFO[k] = gInFIFO[k+stepSize];
+ for (k = 0; k < inFifoLatency; k++) { gInFIFO[k] = gInFIFO[k+stepSize];
+
+}
}
}
@@ -225,6 +235,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
}
+
void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
/*
FFT routine, (C)1996 S.M.Bernsee. Sign = -1 is FFT, 1 is iFFT (inverse)
@@ -244,7 +255,9 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
for (i = 2; i < 2*fftFrameSize-2; i += 2) {
for (bitm = 2, j = 0; bitm < 2*fftFrameSize; bitm <<= 1) {
- if (i & bitm) j++;
+ if (i & bitm) { j++;
+
+}
j <<= 1;
}
if (i < j) {
@@ -280,11 +293,11 @@ void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
}
}
+
/* Godot code again */
/* clang-format on */
void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float sample_rate = AudioServer::get_singleton()->get_mix_rate();
float *in_l = (float *)p_src_frames;
@@ -313,7 +326,6 @@ void AudioEffectPitchShift::set_pitch_scale(float p_pitch_scale) {
}
float AudioEffectPitchShift::get_pitch_scale() const {
-
return pitch_scale;
}
@@ -323,7 +335,6 @@ void AudioEffectPitchShift::set_oversampling(int p_oversampling) {
}
int AudioEffectPitchShift::get_oversampling() const {
-
return oversampling;
}
@@ -337,7 +348,6 @@ AudioEffectPitchShift::FFT_Size AudioEffectPitchShift::get_fft_size() const {
}
void AudioEffectPitchShift::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_pitch_scale", "rate"), &AudioEffectPitchShift::set_pitch_scale);
ClassDB::bind_method(D_METHOD("get_pitch_scale"), &AudioEffectPitchShift::get_pitch_scale);
diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h
index c6528bafa9..48f8e5dc39 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.h
+++ b/servers/audio/effects/audio_effect_pitch_shift.h
@@ -34,7 +34,6 @@
#include "servers/audio/audio_effect.h"
class SMBPitchShift {
-
enum {
MAX_FRAME_LENGTH = 8192
};
diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp
index f2784679b5..79388b2dc7 100644
--- a/servers/audio/effects/audio_effect_record.cpp
+++ b/servers/audio/effects/audio_effect_record.cpp
@@ -101,7 +101,6 @@ void AudioEffectRecordInstance::_io_store_buffer() {
}
void AudioEffectRecordInstance::_thread_callback(void *_instance) {
-
AudioEffectRecordInstance *aeri = reinterpret_cast<AudioEffectRecordInstance *>(_instance);
aeri->_io_thread_process();
@@ -124,7 +123,6 @@ void AudioEffectRecordInstance::init() {
}
void AudioEffectRecordInstance::finish() {
-
#ifdef NO_THREADS
AudioServer::get_singleton()->remove_update_callback(&AudioEffectRecordInstance::_update, this);
#else
@@ -135,7 +133,6 @@ void AudioEffectRecordInstance::finish() {
}
AudioEffectRecordInstance::~AudioEffectRecordInstance() {
-
finish();
}
diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h
index 09101033be..68d968c04b 100644
--- a/servers/audio/effects/audio_effect_record.h
+++ b/servers/audio/effects/audio_effect_record.h
@@ -49,7 +49,7 @@ class AudioEffectRecordInstance : public AudioEffectInstance {
bool is_recording;
Thread *io_thread;
- bool thread_active;
+ bool thread_active = false;
Vector<AudioFrame> ring_buffer;
Vector<float> recording_data;
@@ -71,8 +71,7 @@ public:
virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count);
virtual bool process_silence() const;
- AudioEffectRecordInstance() :
- thread_active(false) {}
+ AudioEffectRecordInstance() {}
~AudioEffectRecordInstance();
};
diff --git a/servers/audio/effects/audio_effect_reverb.cpp b/servers/audio/effects/audio_effect_reverb.cpp
index 6dccb2945b..f6465abfaf 100644
--- a/servers/audio/effects/audio_effect_reverb.cpp
+++ b/servers/audio/effects/audio_effect_reverb.cpp
@@ -31,7 +31,6 @@
#include "audio_effect_reverb.h"
#include "servers/audio_server.h"
void AudioEffectReverbInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
for (int i = 0; i < 2; i++) {
Reverb &r = reverb[i];
@@ -49,7 +48,6 @@ void AudioEffectReverbInstance::process(const AudioFrame *p_src_frames, AudioFra
int offset = 0;
while (todo) {
-
int to_mix = MIN(todo, Reverb::INPUT_BUFFER_MAX_SIZE);
for (int j = 0; j < to_mix; j++) {
@@ -75,7 +73,6 @@ void AudioEffectReverbInstance::process(const AudioFrame *p_src_frames, AudioFra
}
AudioEffectReverbInstance::AudioEffectReverbInstance() {
-
reverb[0].set_mix_rate(AudioServer::get_singleton()->get_mix_rate());
reverb[0].set_extra_spread_base(0);
reverb[1].set_mix_rate(AudioServer::get_singleton()->get_mix_rate());
@@ -90,75 +87,70 @@ Ref<AudioEffectInstance> AudioEffectReverb::instance() {
}
void AudioEffectReverb::set_predelay_msec(float p_msec) {
-
predelay = p_msec;
}
void AudioEffectReverb::set_predelay_feedback(float p_feedback) {
-
predelay_fb = CLAMP(p_feedback, 0, 0.98);
}
-void AudioEffectReverb::set_room_size(float p_size) {
+void AudioEffectReverb::set_room_size(float p_size) {
room_size = p_size;
}
-void AudioEffectReverb::set_damping(float p_damping) {
+void AudioEffectReverb::set_damping(float p_damping) {
damping = p_damping;
}
-void AudioEffectReverb::set_spread(float p_spread) {
+void AudioEffectReverb::set_spread(float p_spread) {
spread = p_spread;
}
void AudioEffectReverb::set_dry(float p_dry) {
-
dry = p_dry;
}
-void AudioEffectReverb::set_wet(float p_wet) {
+void AudioEffectReverb::set_wet(float p_wet) {
wet = p_wet;
}
-void AudioEffectReverb::set_hpf(float p_hpf) {
+void AudioEffectReverb::set_hpf(float p_hpf) {
hpf = p_hpf;
}
float AudioEffectReverb::get_predelay_msec() const {
-
return predelay;
}
-float AudioEffectReverb::get_predelay_feedback() const {
+float AudioEffectReverb::get_predelay_feedback() const {
return predelay_fb;
}
-float AudioEffectReverb::get_room_size() const {
+float AudioEffectReverb::get_room_size() const {
return room_size;
}
-float AudioEffectReverb::get_damping() const {
+float AudioEffectReverb::get_damping() const {
return damping;
}
-float AudioEffectReverb::get_spread() const {
+float AudioEffectReverb::get_spread() const {
return spread;
}
-float AudioEffectReverb::get_dry() const {
+float AudioEffectReverb::get_dry() const {
return dry;
}
-float AudioEffectReverb::get_wet() const {
+float AudioEffectReverb::get_wet() const {
return wet;
}
-float AudioEffectReverb::get_hpf() const {
+float AudioEffectReverb::get_hpf() const {
return hpf;
}
void AudioEffectReverb::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_predelay_msec", "msec"), &AudioEffectReverb::set_predelay_msec);
ClassDB::bind_method(D_METHOD("get_predelay_msec"), &AudioEffectReverb::get_predelay_msec);
diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
index 680ef567fd..e744dbf9b0 100644
--- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
+++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp
@@ -50,8 +50,9 @@ static void smbFft(float *fftBuffer, long fftFrameSize, long sign)
for (i = 2; i < 2 * fftFrameSize - 2; i += 2) {
for (bitm = 2, j = 0; bitm < 2 * fftFrameSize; bitm <<= 1) {
- if (i & bitm)
+ if (i & bitm) {
j++;
+ }
j <<= 1;
}
if (i < j) {
@@ -96,8 +97,8 @@ static void smbFft(float *fftBuffer, long fftFrameSize, long sign)
}
}
}
-void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
+void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
uint64_t time = OS::get_singleton()->get_ticks_usec();
//copy everything over first, since this only really does capture
@@ -149,14 +150,12 @@ void AudioEffectSpectrumAnalyzerInstance::process(const AudioFrame *p_src_frames
}
void AudioEffectSpectrumAnalyzerInstance::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_magnitude_for_frequency_range", "from_hz", "to_hz", "mode"), &AudioEffectSpectrumAnalyzerInstance::get_magnitude_for_frequency_range, DEFVAL(MAGNITUDE_MAX));
BIND_ENUM_CONSTANT(MAGNITUDE_AVERAGE);
BIND_ENUM_CONSTANT(MAGNITUDE_MAX);
}
Vector2 AudioEffectSpectrumAnalyzerInstance::get_magnitude_for_frequency_range(float p_begin, float p_end, MagnitudeMode p_mode) const {
-
if (last_fft_time == 0) {
return Vector2();
}
@@ -197,7 +196,6 @@ Vector2 AudioEffectSpectrumAnalyzerInstance::get_magnitude_for_frequency_range(f
return avg;
} else {
-
Vector2 max;
for (int i = begin_pos; i <= end_pos; i++) {
@@ -210,7 +208,6 @@ Vector2 AudioEffectSpectrumAnalyzerInstance::get_magnitude_for_frequency_range(f
}
Ref<AudioEffectInstance> AudioEffectSpectrumAnalyzer::instance() {
-
Ref<AudioEffectSpectrumAnalyzerInstance> ins;
ins.instance();
ins->base = Ref<AudioEffectSpectrumAnalyzer>(this);
@@ -237,7 +234,6 @@ void AudioEffectSpectrumAnalyzer::set_buffer_length(float p_seconds) {
}
float AudioEffectSpectrumAnalyzer::get_buffer_length() const {
-
return buffer_length;
}
@@ -259,7 +255,6 @@ AudioEffectSpectrumAnalyzer::FFT_Size AudioEffectSpectrumAnalyzer::get_fft_size(
}
void AudioEffectSpectrumAnalyzer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_buffer_length", "seconds"), &AudioEffectSpectrumAnalyzer::set_buffer_length);
ClassDB::bind_method(D_METHOD("get_buffer_length"), &AudioEffectSpectrumAnalyzer::get_buffer_length);
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp
index a10aca02b2..4f9bee83e4 100644
--- a/servers/audio/effects/audio_effect_stereo_enhance.cpp
+++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp
@@ -31,14 +31,12 @@
#include "audio_effect_stereo_enhance.h"
#include "servers/audio_server.h"
void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
-
float intensity = base->pan_pullout;
bool surround_mode = base->surround > 0;
float surround_amount = base->surround;
unsigned int delay_frames = (base->time_pullout / 1000.0) * AudioServer::get_singleton()->get_mix_rate();
for (int i = 0; i < p_frame_count; i++) {
-
float l = p_src_frames[i].l;
float r = p_src_frames[i].r;
@@ -48,7 +46,6 @@ void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, A
r = (center + (r - center) * intensity);
if (surround_mode) {
-
float val = (l + r) / 2.0;
delay_ringbuff[ringbuff_pos & ringbuff_mask] = val;
@@ -58,7 +55,6 @@ void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, A
l += out;
r += -out;
} else {
-
float val = r;
delay_ringbuff[ringbuff_pos & ringbuff_mask] = val;
@@ -75,7 +71,6 @@ void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, A
}
AudioEffectStereoEnhanceInstance::~AudioEffectStereoEnhanceInstance() {
-
memdelete_arr(delay_ringbuff);
}
@@ -108,35 +103,30 @@ Ref<AudioEffectInstance> AudioEffectStereoEnhance::instance() {
}
void AudioEffectStereoEnhance::set_pan_pullout(float p_amount) {
-
pan_pullout = p_amount;
}
float AudioEffectStereoEnhance::get_pan_pullout() const {
-
return pan_pullout;
}
void AudioEffectStereoEnhance::set_time_pullout(float p_amount) {
-
time_pullout = p_amount;
}
-float AudioEffectStereoEnhance::get_time_pullout() const {
+float AudioEffectStereoEnhance::get_time_pullout() const {
return time_pullout;
}
void AudioEffectStereoEnhance::set_surround(float p_amount) {
-
surround = p_amount;
}
-float AudioEffectStereoEnhance::get_surround() const {
+float AudioEffectStereoEnhance::get_surround() const {
return surround;
}
void AudioEffectStereoEnhance::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_pan_pullout", "amount"), &AudioEffectStereoEnhance::set_pan_pullout);
ClassDB::bind_method(D_METHOD("get_pan_pullout"), &AudioEffectStereoEnhance::get_pan_pullout);
diff --git a/servers/audio/effects/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp
index d272a2cdf7..aba04550db 100644
--- a/servers/audio/effects/audio_stream_generator.cpp
+++ b/servers/audio/effects/audio_stream_generator.cpp
@@ -35,21 +35,18 @@ void AudioStreamGenerator::set_mix_rate(float p_mix_rate) {
}
float AudioStreamGenerator::get_mix_rate() const {
-
return mix_rate;
}
void AudioStreamGenerator::set_buffer_length(float p_seconds) {
-
buffer_len = p_seconds;
}
-float AudioStreamGenerator::get_buffer_length() const {
+float AudioStreamGenerator::get_buffer_length() const {
return buffer_len;
}
Ref<AudioStreamPlayback> AudioStreamGenerator::instance_playback() {
-
Ref<AudioStreamGeneratorPlayback> playback;
playback.instance();
playback->generator = this;
@@ -58,8 +55,8 @@ Ref<AudioStreamPlayback> AudioStreamGenerator::instance_playback() {
playback->buffer.clear();
return playback;
}
-String AudioStreamGenerator::get_stream_name() const {
+String AudioStreamGenerator::get_stream_name() const {
return "UserFeed";
}
@@ -99,8 +96,8 @@ bool AudioStreamGeneratorPlayback::push_frame(const Vector2 &p_frame) {
bool AudioStreamGeneratorPlayback::can_push_buffer(int p_frames) const {
return buffer.space_left() >= p_frames;
}
-bool AudioStreamGeneratorPlayback::push_buffer(const PackedVector2Array &p_frames) {
+bool AudioStreamGeneratorPlayback::push_buffer(const PackedVector2Array &p_frames) {
int to_write = p_frames.size();
if (buffer.space_left() < to_write) {
return false;
@@ -115,7 +112,6 @@ bool AudioStreamGeneratorPlayback::push_buffer(const PackedVector2Array &p_frame
AudioFrame buf[2048];
int ofs = 0;
while (to_write) {
-
int w = MIN(to_write, 2048);
for (int i = 0; i < w; i++) {
buf[i] = r[i + ofs];
@@ -143,7 +139,6 @@ void AudioStreamGeneratorPlayback::clear_buffer() {
}
void AudioStreamGeneratorPlayback::_mix_internal(AudioFrame *p_buffer, int p_frames) {
-
int read_amount = buffer.data_left();
if (p_frames < read_amount) {
read_amount = p_frames;
@@ -162,12 +157,12 @@ void AudioStreamGeneratorPlayback::_mix_internal(AudioFrame *p_buffer, int p_fra
mixed += p_frames / generator->get_mix_rate();
}
+
float AudioStreamGeneratorPlayback::get_stream_sampling_rate() {
return generator->get_mix_rate();
}
void AudioStreamGeneratorPlayback::start(float p_from_pos) {
-
if (mixed == 0.0) {
_begin_resample();
}
@@ -179,8 +174,8 @@ void AudioStreamGeneratorPlayback::start(float p_from_pos) {
void AudioStreamGeneratorPlayback::stop() {
active = false;
}
-bool AudioStreamGeneratorPlayback::is_playing() const {
+bool AudioStreamGeneratorPlayback::is_playing() const {
return active; //always playing, can't be stopped
}
@@ -191,6 +186,7 @@ int AudioStreamGeneratorPlayback::get_loop_count() const {
float AudioStreamGeneratorPlayback::get_playback_position() const {
return mixed;
}
+
void AudioStreamGeneratorPlayback::seek(float p_time) {
//no seek possible
}
diff --git a/servers/audio/effects/audio_stream_generator.h b/servers/audio/effects/audio_stream_generator.h
index aee3459e17..763d913684 100644
--- a/servers/audio/effects/audio_stream_generator.h
+++ b/servers/audio/effects/audio_stream_generator.h
@@ -58,7 +58,6 @@ public:
};
class AudioStreamGeneratorPlayback : public AudioStreamPlaybackResampled {
-
GDCLASS(AudioStreamGeneratorPlayback, AudioStreamPlaybackResampled);
friend class AudioStreamGenerator;
RingBuffer<AudioFrame> buffer;
diff --git a/servers/audio/effects/eq.cpp b/servers/audio/effects/eq.cpp
index b90e8a2726..08a6cf55fa 100644
--- a/servers/audio/effects/eq.cpp
+++ b/servers/audio/effects/eq.cpp
@@ -42,48 +42,45 @@ static int solve_quadratic(double a, double b, double c, double *r1, double *r2)
//solves quadractic and returns number of roots
double base = 2 * a;
- if (base == 0.0f)
+ if (base == 0.0f) {
return 0;
+ }
double squared = b * b - 4 * a * c;
- if (squared < 0.0)
+ if (squared < 0.0) {
return 0;
+ }
squared = sqrt(squared);
*r1 = (-b + squared) / base;
*r2 = (-b - squared) / base;
- if (*r1 == *r2)
+ if (*r1 == *r2) {
return 1;
- else
+ } else {
return 2;
+ }
}
EQ::BandProcess::BandProcess() {
-
c1 = c2 = c3 = history.a1 = history.a2 = history.a3 = 0;
history.b1 = history.b2 = history.b3 = 0;
}
void EQ::recalculate_band_coefficients() {
-
#define BAND_LOG(m_f) (log((m_f)) / log(2.))
for (int i = 0; i < band.size(); i++) {
-
double octave_size;
double frq = band[i].freq;
if (i == 0) {
-
octave_size = BAND_LOG(band[1].freq) - BAND_LOG(frq);
} else if (i == (band.size() - 1)) {
-
octave_size = BAND_LOG(frq) - BAND_LOG(band[i - 1].freq);
} else {
-
double next = BAND_LOG(band[i + 1].freq) - BAND_LOG(frq);
double prev = BAND_LOG(frq) - BAND_LOG(band[i - 1].freq);
octave_size = (next + prev) / 2.0;
@@ -118,7 +115,6 @@ void EQ::recalculate_band_coefficients() {
}
void EQ::set_preset_band_mode(Preset p_preset) {
-
band.clear();
#define PUSH_BANDS(m_bands) \
@@ -130,16 +126,13 @@ void EQ::set_preset_band_mode(Preset p_preset) {
}
switch (p_preset) {
-
case PRESET_6_BANDS: {
-
static const double bands[] = { 32, 100, 320, 1e3, 3200, 10e3 };
PUSH_BANDS(6);
} break;
case PRESET_8_BANDS: {
-
static const double bands[] = { 32, 72, 192, 512, 1200, 3000, 7500, 16e3 };
PUSH_BANDS(8);
@@ -153,14 +146,12 @@ void EQ::set_preset_band_mode(Preset p_preset) {
} break;
case PRESET_21_BANDS: {
-
static const double bands[] = { 22, 32, 44, 63, 90, 125, 175, 250, 350, 500, 700, 1e3, 1400, 2e3, 2800, 4e3, 5600, 8e3, 11e3, 16e3, 22e3 };
PUSH_BANDS(21);
} break;
case PRESET_31_BANDS: {
-
static const double bands[] = { 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1e3, 1250, 1600, 2e3, 2500, 3150, 4e3, 5e3, 6300, 8e3, 10e3, 12500, 16e3, 20e3 };
PUSH_BANDS(31);
} break;
@@ -170,19 +161,17 @@ void EQ::set_preset_band_mode(Preset p_preset) {
}
int EQ::get_band_count() const {
-
return band.size();
}
-float EQ::get_band_frequency(int p_band) {
+float EQ::get_band_frequency(int p_band) {
ERR_FAIL_INDEX_V(p_band, band.size(), 0);
return band[p_band].freq;
}
-void EQ::set_bands(const Vector<float> &p_bands) {
+void EQ::set_bands(const Vector<float> &p_bands) {
band.resize(p_bands.size());
for (int i = 0; i < p_bands.size(); i++) {
-
band.write[i].freq = p_bands[i];
}
@@ -190,13 +179,11 @@ void EQ::set_bands(const Vector<float> &p_bands) {
}
void EQ::set_mix_rate(float p_mix_rate) {
-
mix_rate = p_mix_rate;
recalculate_band_coefficients();
}
EQ::BandProcess EQ::get_band_processor(int p_band) const {
-
EQ::BandProcess band_proc;
ERR_FAIL_INDEX_V(p_band, band.size(), band_proc);
diff --git a/servers/audio/effects/eq.h b/servers/audio/effects/eq.h
index 6c002effbf..391a7aa24b 100644
--- a/servers/audio/effects/eq.h
+++ b/servers/audio/effects/eq.h
@@ -52,7 +52,6 @@ public:
};
class BandProcess {
-
friend class EQ;
float c1, c2, c3;
struct History {
@@ -69,7 +68,6 @@ public:
private:
struct Band {
-
float freq;
float c1, c2, c3;
};
@@ -96,7 +94,6 @@ public:
/* Inline Function */
inline void EQ::BandProcess::process_one(float &p_data) {
-
history.a1 = p_data;
history.b1 = c1 * (history.a1 - history.a3) + c3 * history.b2 - c2 * history.b3;
diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp
index ea2174f1d4..7c35d88ced 100644
--- a/servers/audio/effects/reverb.cpp
+++ b/servers/audio/effects/reverb.cpp
@@ -31,7 +31,9 @@
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2006
#include "reverb.h"
+
#include "core/math/math_funcs.h"
+
#include <math.h>
const float Reverb::comb_tunings[MAX_COMBS] = {
@@ -55,24 +57,27 @@ const float Reverb::allpass_tunings[MAX_ALLPASS] = {
};
void Reverb::process(float *p_src, float *p_dst, int p_frames) {
-
- if (p_frames > INPUT_BUFFER_MAX_SIZE)
+ if (p_frames > INPUT_BUFFER_MAX_SIZE) {
p_frames = INPUT_BUFFER_MAX_SIZE;
+ }
int predelay_frames = lrint((params.predelay / 1000.0) * params.mix_rate);
- if (predelay_frames < 10)
+ if (predelay_frames < 10) {
predelay_frames = 10;
- if (predelay_frames >= echo_buffer_size)
+ }
+ if (predelay_frames >= echo_buffer_size) {
predelay_frames = echo_buffer_size - 1;
+ }
for (int i = 0; i < p_frames; i++) {
-
- if (echo_buffer_pos >= echo_buffer_size)
+ if (echo_buffer_pos >= echo_buffer_size) {
echo_buffer_pos = 0;
+ }
int read_pos = echo_buffer_pos - predelay_frames;
- while (read_pos < 0)
+ while (read_pos < 0) {
read_pos += echo_buffer_size;
+ }
float in = undenormalise(echo_buffer[read_pos] * params.predelay_fb + p_src[i]);
@@ -92,7 +97,6 @@ void Reverb::process(float *p_src, float *p_dst, int p_frames) {
float hp_b1 = hpaux;
for (int i = 0; i < p_frames; i++) {
-
float in = input_buffer[i];
input_buffer[i] = in * hp_a1 + hpf_h1 * hp_a2 + hpf_h2 * hp_b1;
hpf_h2 = input_buffer[i];
@@ -101,14 +105,13 @@ void Reverb::process(float *p_src, float *p_dst, int p_frames) {
}
for (int i = 0; i < MAX_COMBS; i++) {
-
Comb &c = comb[i];
int size_limit = c.size - lrintf((float)c.extra_spread_frames * (1.0 - params.extra_spread));
for (int j = 0; j < p_frames; j++) {
-
- if (c.pos >= size_limit) //reset this now just in case
+ if (c.pos >= size_limit) { //reset this now just in case
c.pos = 0;
+ }
float out = undenormalise(c.buffer[c.pos] * c.feedback);
out = out * (1.0 - c.damp) + c.damp_h * c.damp; //lowpass
@@ -155,14 +158,13 @@ void Reverb::process(float *p_src, float *p_dst, int p_frames) {
*/
for (int i = 0; i < MAX_ALLPASS; i++) {
-
AllPass &a = allpass[i];
int size_limit = a.size - lrintf((float)a.extra_spread_frames * (1.0 - params.extra_spread));
for (int j = 0; j < p_frames; j++) {
-
- if (a.pos >= size_limit)
+ if (a.pos >= size_limit) {
a.pos = 0;
+ }
float aux = a.buffer[a.pos];
a.buffer[a.pos] = undenormalise(allpass_feedback * aux + p_dst[j]);
@@ -174,108 +176,102 @@ void Reverb::process(float *p_src, float *p_dst, int p_frames) {
static const float wet_scale = 0.6;
for (int i = 0; i < p_frames; i++) {
-
p_dst[i] = p_dst[i] * params.wet * wet_scale + p_src[i] * params.dry;
}
}
void Reverb::set_room_size(float p_size) {
-
params.room_size = p_size;
update_parameters();
}
-void Reverb::set_damp(float p_damp) {
+void Reverb::set_damp(float p_damp) {
params.damp = p_damp;
update_parameters();
}
-void Reverb::set_wet(float p_wet) {
+void Reverb::set_wet(float p_wet) {
params.wet = p_wet;
}
void Reverb::set_dry(float p_dry) {
-
params.dry = p_dry;
}
void Reverb::set_predelay(float p_predelay) {
-
params.predelay = p_predelay;
}
-void Reverb::set_predelay_feedback(float p_predelay_fb) {
+void Reverb::set_predelay_feedback(float p_predelay_fb) {
params.predelay_fb = p_predelay_fb;
}
void Reverb::set_highpass(float p_frq) {
-
- if (p_frq > 1)
+ if (p_frq > 1) {
p_frq = 1;
- if (p_frq < 0)
+ }
+ if (p_frq < 0) {
p_frq = 0;
+ }
params.hpf = p_frq;
}
void Reverb::set_extra_spread(float p_spread) {
-
params.extra_spread = p_spread;
}
void Reverb::set_mix_rate(float p_mix_rate) {
-
params.mix_rate = p_mix_rate;
configure_buffers();
}
void Reverb::set_extra_spread_base(float p_sec) {
-
params.extra_spread_base = p_sec;
configure_buffers();
}
void Reverb::configure_buffers() {
-
clear_buffers(); //clear if necessary
for (int i = 0; i < MAX_COMBS; i++) {
-
Comb &c = comb[i];
c.extra_spread_frames = lrint(params.extra_spread_base * params.mix_rate);
int len = lrint(comb_tunings[i] * params.mix_rate) + c.extra_spread_frames;
- if (len < 5)
+ if (len < 5) {
len = 5; //may this happen?
+ }
c.buffer = memnew_arr(float, len);
c.pos = 0;
- for (int j = 0; j < len; j++)
+ for (int j = 0; j < len; j++) {
c.buffer[j] = 0;
+ }
c.size = len;
}
for (int i = 0; i < MAX_ALLPASS; i++) {
-
AllPass &a = allpass[i];
a.extra_spread_frames = lrint(params.extra_spread_base * params.mix_rate);
int len = lrint(allpass_tunings[i] * params.mix_rate) + a.extra_spread_frames;
- if (len < 5)
+ if (len < 5) {
len = 5; //may this happen?
+ }
a.buffer = memnew_arr(float, len);
a.pos = 0;
- for (int j = 0; j < len; j++)
+ for (int j = 0; j < len; j++) {
a.buffer[j] = 0;
+ }
a.size = len;
}
echo_buffer_size = (int)(((float)MAX_ECHO_MS / 1000.0) * params.mix_rate + 1.0);
echo_buffer = memnew_arr(float, echo_buffer_size);
for (int i = 0; i < echo_buffer_size; i++) {
-
echo_buffer[i] = 0;
}
@@ -283,19 +279,18 @@ void Reverb::configure_buffers() {
}
void Reverb::update_parameters() {
-
//more freeverb derived constants
static const float room_scale = 0.28f;
static const float room_offset = 0.7f;
for (int i = 0; i < MAX_COMBS; i++) {
-
Comb &c = comb[i];
c.feedback = room_offset + params.room_size * room_scale;
- if (c.feedback < room_offset)
+ if (c.feedback < room_offset) {
c.feedback = room_offset;
- else if (c.feedback > (room_offset + room_scale))
+ } else if (c.feedback > (room_offset + room_scale)) {
c.feedback = (room_offset + room_scale);
+ }
float auxdmp = params.damp / 2.0 + 0.5; //only half the range (0.5 .. 1.0 is enough)
auxdmp *= auxdmp;
@@ -305,29 +300,28 @@ void Reverb::update_parameters() {
}
void Reverb::clear_buffers() {
-
- if (echo_buffer)
+ if (echo_buffer) {
memdelete_arr(echo_buffer);
+ }
for (int i = 0; i < MAX_COMBS; i++) {
-
- if (comb[i].buffer)
+ if (comb[i].buffer) {
memdelete_arr(comb[i].buffer);
+ }
comb[i].buffer = nullptr;
}
for (int i = 0; i < MAX_ALLPASS; i++) {
-
- if (allpass[i].buffer)
+ if (allpass[i].buffer) {
memdelete_arr(allpass[i].buffer);
+ }
allpass[i].buffer = nullptr;
}
}
Reverb::Reverb() {
-
params.room_size = 0.8;
params.damp = 0.5;
params.dry = 1.0;
@@ -338,18 +332,14 @@ Reverb::Reverb() {
params.predelay = 150;
params.predelay_fb = 0.4;
params.hpf = 0;
- hpf_h1 = 0;
- hpf_h2 = 0;
input_buffer = memnew_arr(float, INPUT_BUFFER_MAX_SIZE);
- echo_buffer = nullptr;
configure_buffers();
update_parameters();
}
Reverb::~Reverb() {
-
memdelete_arr(input_buffer);
clear_buffers();
}
diff --git a/servers/audio/effects/reverb.h b/servers/audio/effects/reverb.h
index 92e4aed435..614de0c534 100644
--- a/servers/audio/effects/reverb.h
+++ b/servers/audio/effects/reverb.h
@@ -57,48 +57,35 @@ private:
static const float allpass_tunings[MAX_ALLPASS];
struct Comb {
-
- int size;
- float *buffer;
- float feedback;
- float damp; //lowpass
- float damp_h; //history
- int pos;
- int extra_spread_frames;
-
- Comb() {
- size = 0;
- buffer = 0;
- feedback = 0;
- damp_h = 0;
- pos = 0;
- }
+ int size = 0;
+ float *buffer = nullptr;
+ float feedback = 0;
+ float damp = 0; //lowpass
+ float damp_h = 0; //history
+ int pos = 0;
+ int extra_spread_frames = 0;
+
+ Comb() {}
};
struct AllPass {
-
- int size;
- float *buffer;
- int pos;
- int extra_spread_frames;
- AllPass() {
- size = 0;
- buffer = 0;
- pos = 0;
- }
+ int size = 0;
+ float *buffer = nullptr;
+ int pos = 0;
+ int extra_spread_frames = 0;
+ AllPass() {}
};
Comb comb[MAX_COMBS];
AllPass allpass[MAX_ALLPASS];
float *input_buffer;
- float *echo_buffer;
+ float *echo_buffer = nullptr;
int echo_buffer_size;
int echo_buffer_pos;
- float hpf_h1, hpf_h2;
+ float hpf_h1, hpf_h2 = 0;
struct Parameters {
-
float room_size;
float damp;
float wet;
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 146e70f38d..09d2914e05 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -47,45 +47,41 @@
AudioDriver *AudioDriver::singleton = nullptr;
AudioDriver *AudioDriver::get_singleton() {
-
return singleton;
}
void AudioDriver::set_singleton() {
-
singleton = this;
}
void AudioDriver::audio_server_process(int p_frames, int32_t *p_buffer, bool p_update_mix_time) {
-
- if (p_update_mix_time)
+ if (p_update_mix_time) {
update_mix_time(p_frames);
+ }
- if (AudioServer::get_singleton())
+ if (AudioServer::get_singleton()) {
AudioServer::get_singleton()->_driver_process(p_frames, p_buffer);
+ }
}
void AudioDriver::update_mix_time(int p_frames) {
-
_last_mix_frames = p_frames;
- if (OS::get_singleton())
+ if (OS::get_singleton()) {
_last_mix_time = OS::get_singleton()->get_ticks_usec();
+ }
}
double AudioDriver::get_time_since_last_mix() const {
-
return (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
}
double AudioDriver::get_time_to_next_mix() const {
-
double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
double mix_buffer = _last_mix_frames / (double)get_mix_rate();
return mix_buffer - total;
}
void AudioDriver::input_buffer_init(int driver_buffer_frames) {
-
const int input_buffer_channels = 2;
input_buffer.resize(driver_buffer_frames * input_buffer_channels * 4);
input_position = 0;
@@ -93,7 +89,6 @@ void AudioDriver::input_buffer_init(int driver_buffer_frames) {
}
void AudioDriver::input_buffer_write(int32_t sample) {
-
if ((int)input_position < input_buffer.size()) {
input_buffer.write[input_position++] = sample;
if ((int)input_position >= input_buffer.size()) {
@@ -157,7 +152,6 @@ Array AudioDriver::capture_get_device_list() {
}
AudioDriver::AudioDriver() {
-
_last_mix_time = 0;
_last_mix_frames = 0;
input_position = 0;
@@ -175,7 +169,6 @@ AudioDriver *AudioDriverManager::drivers[MAX_DRIVERS] = {
int AudioDriverManager::driver_count = 1;
void AudioDriverManager::add_driver(AudioDriver *p_driver) {
-
ERR_FAIL_COND(driver_count >= MAX_DRIVERS);
drivers[driver_count - 1] = p_driver;
@@ -184,12 +177,14 @@ void AudioDriverManager::add_driver(AudioDriver *p_driver) {
}
int AudioDriverManager::get_driver_count() {
-
return driver_count;
}
void AudioDriverManager::initialize(int p_driver) {
GLOBAL_DEF_RST("audio/enable_audio_input", false);
+ GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+ GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
+
int failed_driver = -1;
// Check if there is a selected driver
@@ -221,7 +216,6 @@ void AudioDriverManager::initialize(int p_driver) {
}
AudioDriver *AudioDriverManager::get_driver(int p_driver) {
-
ERR_FAIL_INDEX_V(p_driver, driver_count, nullptr);
return drivers[p_driver];
}
@@ -232,7 +226,6 @@ AudioDriver *AudioDriverManager::get_driver(int p_driver) {
//////////////////////////////////////////////
void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
-
int todo = p_frames;
#ifdef DEBUG_ENABLED
@@ -246,7 +239,6 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
}
while (todo) {
-
if (to_mix == 0) {
_mix_step();
}
@@ -261,13 +253,10 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
//master master, send to output
int cs = master->channels.size();
for (int k = 0; k < cs; k++) {
-
if (master->channels[k].active) {
-
const AudioFrame *buf = master->channels[k].buffer.ptr();
for (int j = 0; j < to_copy; j++) {
-
float l = CLAMP(buf[from + j].l, -1.0, 1.0);
int32_t vl = l * ((1 << 20) - 1);
int32_t vl2 = (vl < 0 ? -1 : 1) * (ABS(vl) << 11);
@@ -281,7 +270,6 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
} else {
for (int j = 0; j < to_copy; j++) {
-
p_buffer[(from_buf + j) * (cs * 2) + k * 2 + 0] = 0;
p_buffer[(from_buf + j) * (cs * 2) + k * 2 + 1] = 0;
}
@@ -298,14 +286,12 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
}
void AudioServer::_mix_step() {
-
bool solo_mode = false;
for (int i = 0; i < buses.size(); i++) {
Bus *bus = buses[i];
bus->index_cache = i; //might be moved around by editor, so..
for (int k = 0; k < bus->channels.size(); k++) {
-
bus->channels.write[k].used = false;
}
@@ -314,7 +300,6 @@ void AudioServer::_mix_step() {
solo_mode = true;
bus->soloed = true;
do {
-
if (bus != buses[0]) {
//everything has a send save for master bus
if (!bus_map.has(bus->send)) {
@@ -340,7 +325,6 @@ void AudioServer::_mix_step() {
//make callbacks for mixing the audio
for (Set<CallbackItem>::Element *E = callbacks.front(); E; E = E->next()) {
-
E->get().callback(E->get().userdata);
}
@@ -349,13 +333,11 @@ void AudioServer::_mix_step() {
Bus *bus = buses[i];
for (int k = 0; k < bus->channels.size(); k++) {
-
if (bus->channels[k].active && !bus->channels[k].used) {
//buffer was not used, but it's still active, so it must be cleaned
AudioFrame *buf = bus->channels.write[k].buffer.ptrw();
for (uint32_t j = 0; j < buffer_size; j++) {
-
buf[j] = AudioFrame(0, 0);
}
}
@@ -364,26 +346,26 @@ void AudioServer::_mix_step() {
//process effects
if (!bus->bypass) {
for (int j = 0; j < bus->effects.size(); j++) {
-
- if (!bus->effects[j].enabled)
+ if (!bus->effects[j].enabled) {
continue;
+ }
#ifdef DEBUG_ENABLED
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
#endif
for (int k = 0; k < bus->channels.size(); k++) {
-
- if (!(bus->channels[k].active || bus->channels[k].effect_instances[j]->process_silence()))
+ if (!(bus->channels[k].active || bus->channels[k].effect_instances[j]->process_silence())) {
continue;
+ }
bus->channels.write[k].effect_instances.write[j]->process(bus->channels[k].buffer.ptr(), temp_buffer.write[k].ptrw(), buffer_size);
}
//swap buffers, so internal buffer always has the right data
for (int k = 0; k < bus->channels.size(); k++) {
-
- if (!(buses[i]->channels[k].active || bus->channels[k].effect_instances[j]->process_silence()))
+ if (!(buses[i]->channels[k].active || bus->channels[k].effect_instances[j]->process_silence())) {
continue;
+ }
SWAP(bus->channels.write[k].buffer, temp_buffer.write[k]);
}
@@ -410,9 +392,9 @@ void AudioServer::_mix_step() {
}
for (int k = 0; k < bus->channels.size(); k++) {
-
- if (!bus->channels[k].active)
+ if (!bus->channels[k].active) {
continue;
+ }
AudioFrame *buf = bus->channels.write[k].buffer.ptrw();
@@ -432,7 +414,6 @@ void AudioServer::_mix_step() {
//apply volume and compute peak
for (uint32_t j = 0; j < buffer_size; j++) {
-
buf[j] *= volume;
float l = ABS(buf[j].l);
@@ -474,15 +455,16 @@ void AudioServer::_mix_step() {
}
bool AudioServer::thread_has_channel_mix_buffer(int p_bus, int p_buffer) const {
- if (p_bus < 0 || p_bus >= buses.size())
+ if (p_bus < 0 || p_bus >= buses.size()) {
return false;
- if (p_buffer < 0 || p_buffer >= buses[p_bus]->channels.size())
+ }
+ if (p_buffer < 0 || p_buffer >= buses[p_bus]->channels.size()) {
return false;
+ }
return true;
}
AudioFrame *AudioServer::thread_get_channel_mix_buffer(int p_bus, int p_buffer) {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), nullptr);
ERR_FAIL_INDEX_V(p_buffer, buses[p_bus]->channels.size(), nullptr);
@@ -501,12 +483,10 @@ AudioFrame *AudioServer::thread_get_channel_mix_buffer(int p_bus, int p_buffer)
}
int AudioServer::thread_get_mix_buffer_size() const {
-
return buffer_size;
}
int AudioServer::thread_find_bus_index(const StringName &p_name) {
-
if (bus_map.has(p_name)) {
return bus_map[p_name]->index_cache;
} else {
@@ -515,7 +495,6 @@ int AudioServer::thread_find_bus_index(const StringName &p_name) {
}
void AudioServer::set_bus_count(int p_count) {
-
ERR_FAIL_COND(p_count < 1);
ERR_FAIL_INDEX(p_count, 256);
@@ -534,14 +513,11 @@ void AudioServer::set_bus_count(int p_count) {
buses.resize(p_count);
for (int i = cb; i < buses.size(); i++) {
-
String attempt = "New Bus";
int attempts = 1;
while (true) {
-
bool name_free = true;
for (int j = 0; j < i; j++) {
-
if (buses[j]->name == attempt) {
name_free = false;
break;
@@ -579,7 +555,6 @@ void AudioServer::set_bus_count(int p_count) {
}
void AudioServer::remove_bus(int p_index) {
-
ERR_FAIL_INDEX(p_index, buses.size());
ERR_FAIL_COND(p_index == 0);
@@ -595,25 +570,23 @@ void AudioServer::remove_bus(int p_index) {
}
void AudioServer::add_bus(int p_at_pos) {
-
MARK_EDITED
if (p_at_pos >= buses.size()) {
p_at_pos = -1;
} else if (p_at_pos == 0) {
- if (buses.size() > 1)
+ if (buses.size() > 1) {
p_at_pos = 1;
- else
+ } else {
p_at_pos = -1;
+ }
}
String attempt = "New Bus";
int attempts = 1;
while (true) {
-
bool name_free = true;
for (int j = 0; j < buses.size(); j++) {
-
if (buses[j]->name == attempt) {
name_free = false;
break;
@@ -641,23 +614,24 @@ void AudioServer::add_bus(int p_at_pos) {
bus_map[attempt] = bus;
- if (p_at_pos == -1)
+ if (p_at_pos == -1) {
buses.push_back(bus);
- else
+ } else {
buses.insert(p_at_pos, bus);
+ }
emit_signal("bus_layout_changed");
}
void AudioServer::move_bus(int p_bus, int p_to_pos) {
-
ERR_FAIL_COND(p_bus < 1 || p_bus >= buses.size());
ERR_FAIL_COND(p_to_pos != -1 && (p_to_pos < 1 || p_to_pos > buses.size()));
MARK_EDITED
- if (p_bus == p_to_pos)
+ if (p_bus == p_to_pos) {
return;
+ }
Bus *bus = buses[p_bus];
buses.remove(p_bus);
@@ -674,15 +648,14 @@ void AudioServer::move_bus(int p_bus, int p_to_pos) {
}
int AudioServer::get_bus_count() const {
-
return buses.size();
}
void AudioServer::set_bus_name(int p_bus, const String &p_name) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
- if (p_bus == 0 && p_name != "Master")
+ if (p_bus == 0 && p_name != "Master") {
return; //bus 0 is always master
+ }
MARK_EDITED
@@ -697,10 +670,8 @@ void AudioServer::set_bus_name(int p_bus, const String &p_name) {
int attempts = 1;
while (true) {
-
bool name_free = true;
for (int i = 0; i < buses.size(); i++) {
-
if (buses[i]->name == attempt) {
name_free = false;
break;
@@ -721,8 +692,8 @@ void AudioServer::set_bus_name(int p_bus, const String &p_name) {
emit_signal("bus_layout_changed");
}
-String AudioServer::get_bus_name(int p_bus) const {
+String AudioServer::get_bus_name(int p_bus) const {
ERR_FAIL_INDEX_V(p_bus, buses.size(), String());
return buses[p_bus]->name;
}
@@ -737,27 +708,24 @@ int AudioServer::get_bus_index(const StringName &p_bus_name) const {
}
void AudioServer::set_bus_volume_db(int p_bus, float p_volume_db) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
MARK_EDITED
buses[p_bus]->volume_db = p_volume_db;
}
-float AudioServer::get_bus_volume_db(int p_bus) const {
+float AudioServer::get_bus_volume_db(int p_bus) const {
ERR_FAIL_INDEX_V(p_bus, buses.size(), 0);
return buses[p_bus]->volume_db;
}
int AudioServer::get_bus_channels(int p_bus) const {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), 0);
return buses[p_bus]->channels.size();
}
void AudioServer::set_bus_send(int p_bus, const StringName &p_send) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
MARK_EDITED
@@ -766,13 +734,11 @@ void AudioServer::set_bus_send(int p_bus, const StringName &p_send) {
}
StringName AudioServer::get_bus_send(int p_bus) const {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), StringName());
return buses[p_bus]->send;
}
void AudioServer::set_bus_solo(int p_bus, bool p_enable) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
MARK_EDITED
@@ -781,44 +747,40 @@ void AudioServer::set_bus_solo(int p_bus, bool p_enable) {
}
bool AudioServer::is_bus_solo(int p_bus) const {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), false);
return buses[p_bus]->solo;
}
void AudioServer::set_bus_mute(int p_bus, bool p_enable) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
MARK_EDITED
buses[p_bus]->mute = p_enable;
}
-bool AudioServer::is_bus_mute(int p_bus) const {
+bool AudioServer::is_bus_mute(int p_bus) const {
ERR_FAIL_INDEX_V(p_bus, buses.size(), false);
return buses[p_bus]->mute;
}
void AudioServer::set_bus_bypass_effects(int p_bus, bool p_enable) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
MARK_EDITED
buses[p_bus]->bypass = p_enable;
}
-bool AudioServer::is_bus_bypassing_effects(int p_bus) const {
+bool AudioServer::is_bus_bypassing_effects(int p_bus) const {
ERR_FAIL_INDEX_V(p_bus, buses.size(), false);
return buses[p_bus]->bypass;
}
void AudioServer::_update_bus_effects(int p_bus) {
-
for (int i = 0; i < buses[p_bus]->channels.size(); i++) {
buses.write[p_bus]->channels.write[i].effect_instances.resize(buses[p_bus]->effects.size());
for (int j = 0; j < buses[p_bus]->effects.size(); j++) {
@@ -832,7 +794,6 @@ void AudioServer::_update_bus_effects(int p_bus) {
}
void AudioServer::add_bus_effect(int p_bus, const Ref<AudioEffect> &p_effect, int p_at_pos) {
-
ERR_FAIL_COND(p_effect.is_null());
ERR_FAIL_INDEX(p_bus, buses.size());
@@ -860,7 +821,6 @@ void AudioServer::add_bus_effect(int p_bus, const Ref<AudioEffect> &p_effect, in
}
void AudioServer::remove_bus_effect(int p_bus, int p_effect) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
MARK_EDITED
@@ -874,14 +834,12 @@ void AudioServer::remove_bus_effect(int p_bus, int p_effect) {
}
int AudioServer::get_bus_effect_count(int p_bus) {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), 0);
return buses[p_bus]->effects.size();
}
Ref<AudioEffectInstance> AudioServer::get_bus_effect_instance(int p_bus, int p_effect, int p_channel) {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), Ref<AudioEffectInstance>());
ERR_FAIL_INDEX_V(p_effect, buses[p_bus]->effects.size(), Ref<AudioEffectInstance>());
ERR_FAIL_INDEX_V(p_channel, buses[p_bus]->channels.size(), Ref<AudioEffectInstance>());
@@ -890,7 +848,6 @@ Ref<AudioEffectInstance> AudioServer::get_bus_effect_instance(int p_bus, int p_e
}
Ref<AudioEffect> AudioServer::get_bus_effect(int p_bus, int p_effect) {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), Ref<AudioEffect>());
ERR_FAIL_INDEX_V(p_effect, buses[p_bus]->effects.size(), Ref<AudioEffect>());
@@ -898,7 +855,6 @@ Ref<AudioEffect> AudioServer::get_bus_effect(int p_bus, int p_effect) {
}
void AudioServer::swap_bus_effects(int p_bus, int p_effect, int p_by_effect) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
ERR_FAIL_INDEX(p_effect, buses[p_bus]->effects.size());
ERR_FAIL_INDEX(p_by_effect, buses[p_bus]->effects.size());
@@ -912,7 +868,6 @@ void AudioServer::swap_bus_effects(int p_bus, int p_effect, int p_by_effect) {
}
void AudioServer::set_bus_effect_enabled(int p_bus, int p_effect, bool p_enabled) {
-
ERR_FAIL_INDEX(p_bus, buses.size());
ERR_FAIL_INDEX(p_effect, buses[p_bus]->effects.size());
@@ -920,22 +875,21 @@ void AudioServer::set_bus_effect_enabled(int p_bus, int p_effect, bool p_enabled
buses.write[p_bus]->effects.write[p_effect].enabled = p_enabled;
}
-bool AudioServer::is_bus_effect_enabled(int p_bus, int p_effect) const {
+bool AudioServer::is_bus_effect_enabled(int p_bus, int p_effect) const {
ERR_FAIL_INDEX_V(p_bus, buses.size(), false);
ERR_FAIL_INDEX_V(p_effect, buses[p_bus]->effects.size(), false);
return buses[p_bus]->effects[p_effect].enabled;
}
float AudioServer::get_bus_peak_volume_left_db(int p_bus, int p_channel) const {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), 0);
ERR_FAIL_INDEX_V(p_channel, buses[p_bus]->channels.size(), 0);
return buses[p_bus]->channels[p_channel].peak_volume.l;
}
-float AudioServer::get_bus_peak_volume_right_db(int p_bus, int p_channel) const {
+float AudioServer::get_bus_peak_volume_right_db(int p_bus, int p_channel) const {
ERR_FAIL_INDEX_V(p_bus, buses.size(), 0);
ERR_FAIL_INDEX_V(p_channel, buses[p_bus]->channels.size(), 0);
@@ -943,7 +897,6 @@ float AudioServer::get_bus_peak_volume_right_db(int p_bus, int p_channel) const
}
bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const {
-
ERR_FAIL_INDEX_V(p_bus, buses.size(), false);
ERR_FAIL_INDEX_V(p_channel, buses[p_bus]->channels.size(), false);
@@ -951,11 +904,10 @@ bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const {
}
void AudioServer::set_global_rate_scale(float p_scale) {
-
global_rate_scale = p_scale;
}
-float AudioServer::get_global_rate_scale() const {
+float AudioServer::get_global_rate_scale() const {
return global_rate_scale;
}
@@ -976,7 +928,6 @@ void AudioServer::init_channels_and_buffers() {
}
void AudioServer::init() {
-
channel_disable_threshold_db = GLOBAL_DEF_RST("audio/channel_disable_threshold_db", -60.0);
channel_disable_frames = float(GLOBAL_DEF_RST("audio/channel_disable_time", 2.0)) * get_mix_rate();
ProjectSettings::get_singleton()->set_custom_property_info("audio/channel_disable_time", PropertyInfo(Variant::FLOAT, "audio/channel_disable_time", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater"));
@@ -988,8 +939,9 @@ void AudioServer::init() {
set_bus_count(1);
set_bus_name(0, "Master");
- if (AudioDriver::get_singleton())
+ if (AudioDriver::get_singleton()) {
AudioDriver::get_singleton()->start();
+ }
#ifdef TOOLS_ENABLED
set_edited(false); //avoid editors from thinking this was edited
@@ -1001,35 +953,39 @@ void AudioServer::init() {
void AudioServer::update() {
#ifdef DEBUG_ENABLED
if (EngineDebugger::is_profiling("servers")) {
-
// Driver time includes server time + effects times
// Server time includes effects times
uint64_t driver_time = AudioDriver::get_singleton()->get_profiling_time();
uint64_t server_time = prof_time;
// Subtract the server time from the driver time
- if (driver_time > server_time)
+ if (driver_time > server_time) {
driver_time -= server_time;
+ }
Array values;
for (int i = buses.size() - 1; i >= 0; i--) {
Bus *bus = buses[i];
- if (bus->bypass)
+ if (bus->bypass) {
continue;
+ }
for (int j = 0; j < bus->effects.size(); j++) {
- if (!bus->effects[j].enabled)
+ if (!bus->effects[j].enabled) {
continue;
+ }
values.push_back(String(bus->name) + bus->effects[j].effect->get_name());
values.push_back(USEC_TO_SEC(bus->effects[j].prof_time));
// Subtract the effect time from the driver and server times
- if (driver_time > bus->effects[j].prof_time)
+ if (driver_time > bus->effects[j].prof_time) {
driver_time -= bus->effects[j].prof_time;
- if (server_time > bus->effects[j].prof_time)
+ }
+ if (server_time > bus->effects[j].prof_time) {
server_time -= bus->effects[j].prof_time;
+ }
}
}
@@ -1045,12 +1001,14 @@ void AudioServer::update() {
// Reset profiling times
for (int i = buses.size() - 1; i >= 0; i--) {
Bus *bus = buses[i];
- if (bus->bypass)
+ if (bus->bypass) {
continue;
+ }
for (int j = 0; j < bus->effects.size(); j++) {
- if (!bus->effects[j].enabled)
+ if (!bus->effects[j].enabled) {
continue;
+ }
bus->effects.write[j].prof_time = 0;
}
@@ -1061,13 +1019,11 @@ void AudioServer::update() {
#endif
for (Set<CallbackItem>::Element *E = update_callbacks.front(); E; E = E->next()) {
-
E->get().callback(E->get().userdata);
}
}
void AudioServer::load_default_bus_layout() {
-
String layout_path = ProjectSettings::get_singleton()->get("audio/default_bus_layout");
if (ResourceLoader::exists(layout_path)) {
@@ -1079,7 +1035,6 @@ void AudioServer::load_default_bus_layout() {
}
void AudioServer::finish() {
-
for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
AudioDriverManager::get_driver(i)->finish();
}
@@ -1094,45 +1049,38 @@ void AudioServer::finish() {
/* MISC config */
void AudioServer::lock() {
-
AudioDriver::get_singleton()->lock();
}
-void AudioServer::unlock() {
+void AudioServer::unlock() {
AudioDriver::get_singleton()->unlock();
}
AudioServer::SpeakerMode AudioServer::get_speaker_mode() const {
-
return (AudioServer::SpeakerMode)AudioDriver::get_singleton()->get_speaker_mode();
}
-float AudioServer::get_mix_rate() const {
+float AudioServer::get_mix_rate() const {
return AudioDriver::get_singleton()->get_mix_rate();
}
float AudioServer::read_output_peak_db() const {
-
return 0;
}
AudioServer *AudioServer::get_singleton() {
-
return singleton;
}
double AudioServer::get_output_latency() const {
-
return AudioDriver::get_singleton()->get_latency();
}
double AudioServer::get_time_to_next_mix() const {
-
return AudioDriver::get_singleton()->get_time_to_next_mix();
}
double AudioServer::get_time_since_last_mix() const {
-
return AudioDriver::get_singleton()->get_time_since_last_mix();
}
@@ -1148,7 +1096,6 @@ void AudioServer::add_callback(AudioCallback p_callback, void *p_userdata) {
}
void AudioServer::remove_callback(AudioCallback p_callback, void *p_userdata) {
-
lock();
CallbackItem ci;
ci.callback = p_callback;
@@ -1167,7 +1114,6 @@ void AudioServer::add_update_callback(AudioCallback p_callback, void *p_userdata
}
void AudioServer::remove_update_callback(AudioCallback p_callback, void *p_userdata) {
-
lock();
CallbackItem ci;
ci.callback = p_callback;
@@ -1177,7 +1123,6 @@ void AudioServer::remove_update_callback(AudioCallback p_callback, void *p_userd
}
void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) {
-
ERR_FAIL_COND(p_bus_layout.is_null() || p_bus_layout->buses.size() == 0);
lock();
@@ -1201,11 +1146,9 @@ void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) {
bus->volume_db = p_bus_layout->buses[i].volume_db;
for (int j = 0; j < p_bus_layout->buses[i].effects.size(); j++) {
-
Ref<AudioEffect> fx = p_bus_layout->buses[i].effects[j].effect;
if (fx.is_valid()) {
-
Bus::Effect bfx;
bfx.effect = fx;
bfx.enabled = p_bus_layout->buses[i].effects[j].enabled;
@@ -1229,14 +1172,12 @@ void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) {
}
Ref<AudioBusLayout> AudioServer::generate_bus_layout() const {
-
Ref<AudioBusLayout> state;
state.instance();
state->buses.resize(buses.size());
for (int i = 0; i < buses.size(); i++) {
-
state->buses.write[i].name = buses[i]->name;
state->buses.write[i].send = buses[i]->send;
state->buses.write[i].mute = buses[i]->mute;
@@ -1255,37 +1196,30 @@ Ref<AudioBusLayout> AudioServer::generate_bus_layout() const {
}
Array AudioServer::get_device_list() {
-
return AudioDriver::get_singleton()->get_device_list();
}
String AudioServer::get_device() {
-
return AudioDriver::get_singleton()->get_device();
}
void AudioServer::set_device(String device) {
-
AudioDriver::get_singleton()->set_device(device);
}
Array AudioServer::capture_get_device_list() {
-
return AudioDriver::get_singleton()->capture_get_device_list();
}
String AudioServer::capture_get_device() {
-
return AudioDriver::get_singleton()->capture_get_device();
}
void AudioServer::capture_set_device(const String &p_name) {
-
AudioDriver::get_singleton()->capture_set_device(p_name);
}
void AudioServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_bus_count", "amount"), &AudioServer::set_bus_count);
ClassDB::bind_method(D_METHOD("get_bus_count"), &AudioServer::get_bus_count);
@@ -1364,7 +1298,6 @@ void AudioServer::_bind_methods() {
}
AudioServer::AudioServer() {
-
singleton = this;
mix_frames = 0;
channel_count = 0;
@@ -1378,14 +1311,12 @@ AudioServer::AudioServer() {
}
AudioServer::~AudioServer() {
-
singleton = nullptr;
}
/////////////////////////////////
bool AudioBusLayout::_set(const StringName &p_name, const Variant &p_value) {
-
String s = p_name;
if (s.begins_with("bus/")) {
int index = s.get_slice("/", 1).to_int();
@@ -1438,13 +1369,12 @@ bool AudioBusLayout::_set(const StringName &p_name, const Variant &p_value) {
}
bool AudioBusLayout::_get(const StringName &p_name, Variant &r_ret) const {
-
String s = p_name;
if (s.begins_with("bus/")) {
-
int index = s.get_slice("/", 1).to_int();
- if (index < 0 || index >= buses.size())
+ if (index < 0 || index >= buses.size()) {
return false;
+ }
const Bus &bus = buses[index];
@@ -1489,8 +1419,8 @@ bool AudioBusLayout::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-void AudioBusLayout::_get_property_list(List<PropertyInfo> *p_list) const {
+void AudioBusLayout::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < buses.size(); i++) {
p_list->push_back(PropertyInfo(Variant::STRING, "bus/" + itos(i) + "/name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
p_list->push_back(PropertyInfo(Variant::BOOL, "bus/" + itos(i) + "/solo", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
@@ -1507,7 +1437,6 @@ void AudioBusLayout::_get_property_list(List<PropertyInfo> *p_list) const {
}
AudioBusLayout::AudioBusLayout() {
-
buses.resize(1);
buses.write[0].name = "Master";
}
diff --git a/servers/audio_server.h b/servers/audio_server.h
index f10c2ecdc0..80e244aacd 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -42,7 +42,6 @@ class AudioStream;
class AudioStreamSample;
class AudioDriver {
-
static AudioDriver *singleton;
uint64_t _last_mix_time;
uint64_t _last_mix_frames;
@@ -81,9 +80,6 @@ public:
SPEAKER_SURROUND_71,
};
- static const int DEFAULT_MIX_RATE = 44100;
- static const int DEFAULT_OUTPUT_LATENCY = 15;
-
static AudioDriver *get_singleton();
void set_singleton();
@@ -125,12 +121,14 @@ public:
};
class AudioDriverManager {
-
enum {
MAX_DRIVERS = 10
};
+ static const int DEFAULT_MIX_RATE = 44100;
+ static const int DEFAULT_OUTPUT_LATENCY = 15;
+
static AudioDriver *drivers[MAX_DRIVERS];
static int driver_count;
@@ -146,7 +144,6 @@ public:
class AudioBusLayout;
class AudioServer : public Object {
-
GDCLASS(AudioServer, Object);
public:
@@ -184,7 +181,6 @@ private:
float global_rate_scale;
struct Bus {
-
StringName name;
bool solo;
bool mute;
@@ -237,7 +233,6 @@ private:
void _mix_step();
struct CallbackItem {
-
AudioCallback callback;
void *userdata;
@@ -370,13 +365,11 @@ public:
VARIANT_ENUM_CAST(AudioServer::SpeakerMode)
class AudioBusLayout : public Resource {
-
GDCLASS(AudioBusLayout, Resource);
friend class AudioServer;
struct Bus {
-
StringName name;
bool solo;
bool mute;
diff --git a/servers/display_server.cpp b/servers/display_server.cpp
index ff8b10cbb6..0ea11a2670 100644
--- a/servers/display_server.cpp
+++ b/servers/display_server.cpp
@@ -127,6 +127,7 @@ void DisplayServer::global_menu_clear(const String &p_menu_root) {
void DisplayServer::mouse_set_mode(MouseMode p_mode) {
WARN_PRINT("Mouse is not supported by this display server.");
}
+
DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
return MOUSE_MODE_VISIBLE;
}
@@ -134,12 +135,15 @@ DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
void DisplayServer::mouse_warp_to_position(const Point2i &p_to) {
WARN_PRINT("Mouse warping is not supported by this display server.");
}
+
Point2i DisplayServer::mouse_get_absolute_position() const {
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
}
+
Point2i DisplayServer::mouse_get_position() const {
ERR_FAIL_V_MSG(Point2i(), "Mouse is not supported by this display server.");
}
+
int DisplayServer::mouse_get_button_state() const {
ERR_FAIL_V_MSG(0, "Mouse is not supported by this display server.");
}
@@ -147,6 +151,7 @@ int DisplayServer::mouse_get_button_state() const {
void DisplayServer::clipboard_set(const String &p_text) {
WARN_PRINT("Clipboard is not supported by this display server.");
}
+
String DisplayServer::clipboard_get() const {
ERR_FAIL_V_MSG(String(), "Clipboard is not supported by this display server.");
}
@@ -154,6 +159,7 @@ String DisplayServer::clipboard_get() const {
void DisplayServer::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
WARN_PRINT("Orientation not supported by this display server.");
}
+
DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_screen) const {
return SCREEN_LANDSCAPE;
}
@@ -170,6 +176,7 @@ bool DisplayServer::screen_is_touchscreen(int p_screen) const {
void DisplayServer::screen_set_keep_on(bool p_enable) {
WARN_PRINT("Keeping screen on not supported by this display server.");
}
+
bool DisplayServer::screen_is_kept_on() const {
return false;
}
@@ -177,6 +184,7 @@ bool DisplayServer::screen_is_kept_on() const {
DisplayServer::WindowID DisplayServer::create_sub_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &) {
ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Sub-windows not supported by this display server.");
}
+
void DisplayServer::delete_sub_window(WindowID p_id) {
ERR_FAIL_MSG("Sub-windows not supported by this display server.");
}
@@ -184,6 +192,7 @@ void DisplayServer::delete_sub_window(WindowID p_id) {
void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) {
WARN_PRINT("IME not supported by this display server.");
}
+
void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
WARN_PRINT("IME not supported by this display server.");
}
@@ -191,6 +200,7 @@ void DisplayServer::window_set_ime_position(const Point2i &p_pos, WindowID p_win
Point2i DisplayServer::ime_get_selection() const {
ERR_FAIL_V_MSG(Point2i(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server.");
}
+
String DisplayServer::ime_get_text() const {
ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATEnot supported by this display server.");
}
@@ -198,13 +208,15 @@ String DisplayServer::ime_get_text() const {
void DisplayServer::console_set_visible(bool p_enabled) {
WARN_PRINT("Console window not supported by this display server.");
}
+
bool DisplayServer::is_console_visible() const {
return false;
}
-void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_legth) {
+void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_length, int p_cursor_start, int p_cursor_end) {
WARN_PRINT("Virtual keyboard not supported by this display server.");
}
+
void DisplayServer::virtual_keyboard_hide() {
WARN_PRINT("Virtual keyboard not supported by this display server.");
}
@@ -217,9 +229,11 @@ int DisplayServer::virtual_keyboard_get_height() const {
void DisplayServer::cursor_set_shape(CursorShape p_shape) {
WARN_PRINT("Cursor shape not supported by this display server.");
}
+
DisplayServer::CursorShape DisplayServer::cursor_get_shape() const {
return CURSOR_ARROW;
}
+
void DisplayServer::cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
WARN_PRINT("Custom cursor shape not supported by this display server.");
}
@@ -235,15 +249,19 @@ void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) {
Error DisplayServer::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track, int p_screen) {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "Native video not supported by this display server.");
}
+
bool DisplayServer::native_video_is_playing() const {
return false;
}
+
void DisplayServer::native_video_pause() {
WARN_PRINT("Native video not supported by this display server.");
}
+
void DisplayServer::native_video_unpause() {
WARN_PRINT("Native video not supported by this display server.");
}
+
void DisplayServer::native_video_stop() {
WARN_PRINT("Native video not supported by this display server.");
}
@@ -252,13 +270,29 @@ Error DisplayServer::dialog_show(String p_title, String p_description, Vector<St
WARN_PRINT("Native dialogs not supported by this display server.");
return OK;
}
+
Error DisplayServer::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
WARN_PRINT("Native dialogs not supported by this display server.");
return OK;
}
-DisplayServer::LatinKeyboardVariant DisplayServer::get_latin_keyboard_variant() const {
- return LATIN_KEYBOARD_QWERTY;
+int DisplayServer::keyboard_get_layout_count() const {
+ return 0;
+}
+
+int DisplayServer::keyboard_get_current_layout() const {
+ return -1;
+}
+
+void DisplayServer::keyboard_set_current_layout(int p_index) {
+}
+
+String DisplayServer::keyboard_get_layout_language(int p_index) const {
+ return "";
+}
+
+String DisplayServer::keyboard_get_layout_name(int p_index) const {
+ return "Not supported";
}
void DisplayServer::force_process_and_drop_events() {
@@ -267,9 +301,11 @@ void DisplayServer::force_process_and_drop_events() {
void DisplayServer::release_rendering_thread() {
WARN_PRINT("Rendering thread not supported by this display server.");
}
+
void DisplayServer::make_rendering_thread() {
WARN_PRINT("Rendering thread not supported by this display server.");
}
+
void DisplayServer::swap_buffers() {
WARN_PRINT("Swap buffers not supported by this display server.");
}
@@ -277,6 +313,7 @@ void DisplayServer::swap_buffers() {
void DisplayServer::set_native_icon(const String &p_filename) {
WARN_PRINT("Native icon not supported by this display server.");
}
+
void DisplayServer::set_icon(const Ref<Image> &p_icon) {
WARN_PRINT("Icon not supported by this display server.");
}
@@ -284,6 +321,7 @@ void DisplayServer::set_icon(const Ref<Image> &p_icon) {
void DisplayServer::_set_use_vsync(bool p_enable) {
WARN_PRINT("VSync not supported by this display server.");
}
+
void DisplayServer::vsync_set_enabled(bool p_enable) {
vsync_enabled = p_enable;
if (switch_vsync_function) { //if a function was set, use function
@@ -292,6 +330,7 @@ void DisplayServer::vsync_set_enabled(bool p_enable) {
_set_use_vsync(p_enable);
}
}
+
bool DisplayServer::vsync_is_enabled() const {
return vsync_enabled;
}
@@ -299,6 +338,7 @@ bool DisplayServer::vsync_is_enabled() const {
void DisplayServer::vsync_set_use_via_compositor(bool p_enable) {
WARN_PRINT("VSync via compositor not supported by this display server.");
}
+
bool DisplayServer::vsync_is_using_via_compositor() const {
return false;
}
@@ -307,7 +347,6 @@ void DisplayServer::set_context(Context p_context) {
}
void DisplayServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("has_feature", "feature"), &DisplayServer::has_feature);
ClassDB::bind_method(D_METHOD("get_name"), &DisplayServer::get_name);
@@ -415,7 +454,7 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("console_set_visible", "console_visible"), &DisplayServer::console_set_visible);
ClassDB::bind_method(D_METHOD("is_console_visible"), &DisplayServer::is_console_visible);
- ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position", "max_length"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("virtual_keyboard_show", "existing_text", "position", "max_length", "cursor_start", "cursor_end"), &DisplayServer::virtual_keyboard_show, DEFVAL(Rect2i()), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("virtual_keyboard_hide"), &DisplayServer::virtual_keyboard_hide);
ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height);
@@ -437,7 +476,11 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show);
ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_input_text);
- ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &DisplayServer::get_latin_keyboard_variant);
+ ClassDB::bind_method(D_METHOD("keyboard_get_layout_count"), &DisplayServer::keyboard_get_layout_count);
+ ClassDB::bind_method(D_METHOD("keyboard_get_current_layout"), &DisplayServer::keyboard_get_current_layout);
+ ClassDB::bind_method(D_METHOD("keyboard_set_current_layout", "index"), &DisplayServer::keyboard_set_current_layout);
+ ClassDB::bind_method(D_METHOD("keyboard_get_layout_language", "index"), &DisplayServer::keyboard_get_layout_language);
+ ClassDB::bind_method(D_METHOD("keyboard_get_layout_name", "index"), &DisplayServer::keyboard_get_layout_name);
ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
@@ -519,14 +562,6 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTY);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTZ);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_AZERTY);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QZERTY);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_DVORAK);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_NEO);
- BIND_ENUM_CONSTANT(LATIN_KEYBOARD_COLEMAK);
-
BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER);
BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_EXIT);
BIND_ENUM_CONSTANT(WINDOW_EVENT_FOCUS_IN);
@@ -566,6 +601,7 @@ DisplayServer *DisplayServer::create(int p_index, const String &p_rendering_driv
void DisplayServer::_input_set_mouse_mode(Input::MouseMode p_mode) {
singleton->mouse_set_mode(MouseMode(p_mode));
}
+
Input::MouseMode DisplayServer::_input_get_mouse_mode() {
return Input::MouseMode(singleton->mouse_get_mode());
}
@@ -577,6 +613,7 @@ void DisplayServer::_input_warp(const Vector2 &p_to_pos) {
Input::CursorShape DisplayServer::_input_get_current_cursor_shape() {
return (Input::CursorShape)singleton->cursor_get_shape();
}
+
void DisplayServer::_input_set_custom_mouse_cursor_func(const RES &p_image, Input::CursorShape p_shape, const Vector2 &p_hostspot) {
singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hostspot);
}
@@ -589,5 +626,6 @@ DisplayServer::DisplayServer() {
Input::get_current_cursor_shape_func = _input_get_current_cursor_shape;
Input::set_custom_mouse_cursor_func = _input_set_custom_mouse_cursor_func;
}
+
DisplayServer::~DisplayServer() {
}
diff --git a/servers/display_server.h b/servers/display_server.h
index f6ba26fc6f..166274f8ed 100644
--- a/servers/display_server.h
+++ b/servers/display_server.h
@@ -280,7 +280,7 @@ public:
virtual void console_set_visible(bool p_enabled);
virtual bool is_console_visible() const;
- virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_legth = -1);
+ virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), int p_max_length = -1, int p_cursor_start = -1, int p_cursor_end = -1);
virtual void virtual_keyboard_hide();
// returns height of the currently shown virtual keyboard (0 if keyboard is hidden)
@@ -324,17 +324,11 @@ public:
virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback);
virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback);
- enum LatinKeyboardVariant {
- LATIN_KEYBOARD_QWERTY,
- LATIN_KEYBOARD_QWERTZ,
- LATIN_KEYBOARD_AZERTY,
- LATIN_KEYBOARD_QZERTY,
- LATIN_KEYBOARD_DVORAK,
- LATIN_KEYBOARD_NEO,
- LATIN_KEYBOARD_COLEMAK,
- };
-
- virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
+ virtual int keyboard_get_layout_count() const;
+ virtual int keyboard_get_current_layout() const;
+ virtual void keyboard_set_current_layout(int p_index);
+ virtual String keyboard_get_layout_language(int p_index) const;
+ virtual String keyboard_get_layout_name(int p_index) const;
virtual void process_events() = 0;
@@ -384,6 +378,5 @@ VARIANT_ENUM_CAST(DisplayServer::ScreenOrientation)
VARIANT_ENUM_CAST(DisplayServer::WindowMode)
VARIANT_ENUM_CAST(DisplayServer::WindowFlags)
VARIANT_ENUM_CAST(DisplayServer::CursorShape)
-VARIANT_ENUM_CAST(DisplayServer::LatinKeyboardVariant)
#endif // DISPLAY_SERVER_H
diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp
index 17f2232c72..b20f6865cd 100644
--- a/servers/navigation_server_2d.cpp
+++ b/servers/navigation_server_2d.cpp
@@ -83,21 +83,27 @@ NavigationServer2D *NavigationServer2D::singleton = nullptr;
static RID rid_to_rid(const RID d) {
return d;
}
+
static bool bool_to_bool(const bool d) {
return d;
}
+
static int int_to_int(const int d) {
return d;
}
+
static real_t real_to_real(const real_t d) {
return d;
}
+
static Vector3 v2_to_v3(const Vector2 d) {
return Vector3(d.x, 0.0, d.y);
}
+
static Vector2 v3_to_v2(const Vector3 &d) {
return Vector2(d.x, d.z);
}
+
static Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) {
Vector<Vector2> nd;
nd.resize(d.size());
@@ -106,21 +112,26 @@ static Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) {
}
return nd;
}
+
static Transform trf2_to_trf3(const Transform2D &d) {
Vector3 o(v2_to_v3(d.get_origin()));
Basis b;
b.rotate(Vector3(0, 1, 0), d.get_rotation());
return Transform(b, o);
}
+
static Object *obj_to_obj(Object *d) {
return d;
}
+
static StringName sn_to_sn(StringName &d) {
return d;
}
+
static Variant var_to_var(Variant &d) {
return d;
}
+
static Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) {
if (d.is_valid()) {
return d->get_mesh();
diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp
index 67a4d0e413..8f9b5df589 100644
--- a/servers/navigation_server_3d.cpp
+++ b/servers/navigation_server_3d.cpp
@@ -37,7 +37,6 @@
NavigationServer3D *NavigationServer3D::singleton = nullptr;
void NavigationServer3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer3D::map_create);
ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer3D::map_set_active);
ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer3D::map_is_active);
diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp
index 6ae7c90c89..acbbb7e1e8 100644
--- a/servers/physics_2d/area_2d_sw.cpp
+++ b/servers/physics_2d/area_2d_sw.cpp
@@ -38,6 +38,7 @@ Area2DSW::BodyKey::BodyKey(Body2DSW *p_body, uint32_t p_body_shape, uint32_t p_a
body_shape = p_body_shape;
area_shape = p_area_shape;
}
+
Area2DSW::BodyKey::BodyKey(Area2DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
rid = p_body->get_self();
instance_id = p_body->get_instance_id();
@@ -46,27 +47,28 @@ Area2DSW::BodyKey::BodyKey(Area2DSW *p_body, uint32_t p_body_shape, uint32_t p_a
}
void Area2DSW::_shapes_changed() {
-
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
}
void Area2DSW::set_transform(const Transform2D &p_transform) {
-
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
_set_transform(p_transform);
_set_inv_transform(p_transform.affine_inverse());
}
void Area2DSW::set_space(Space2DSW *p_space) {
-
if (get_space()) {
- if (monitor_query_list.in_list())
+ if (monitor_query_list.in_list()) {
get_space()->area_remove_from_monitor_query_list(&monitor_query_list);
- if (moved_list.in_list())
+ }
+ if (moved_list.in_list()) {
get_space()->area_remove_from_moved_list(&moved_list);
+ }
}
monitored_bodies.clear();
@@ -76,7 +78,6 @@ void Area2DSW::set_space(Space2DSW *p_space) {
}
void Area2DSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
-
if (p_id == monitor_callback_id) {
monitor_callback_method = p_method;
return;
@@ -92,12 +93,12 @@ void Area2DSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
_shape_changed();
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
}
void Area2DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method) {
-
if (p_id == area_monitor_callback_id) {
area_monitor_callback_method = p_method;
return;
@@ -113,21 +114,22 @@ void Area2DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_meth
_shape_changed();
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
}
void Area2DSW::set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode) {
bool do_override = p_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
- if (do_override == (space_override_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED))
+ if (do_override == (space_override_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)) {
return;
+ }
_unregister_shapes();
space_override_mode = p_mode;
_shape_changed();
}
void Area2DSW::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value) {
-
switch (p_param) {
case PhysicsServer2D::AREA_PARAM_GRAVITY:
gravity = p_value;
@@ -157,7 +159,6 @@ void Area2DSW::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &
}
Variant Area2DSW::get_param(PhysicsServer2D::AreaParameter p_param) const {
-
switch (p_param) {
case PhysicsServer2D::AREA_PARAM_GRAVITY:
return gravity;
@@ -181,30 +182,29 @@ Variant Area2DSW::get_param(PhysicsServer2D::AreaParameter p_param) const {
}
void Area2DSW::_queue_monitor_update() {
-
ERR_FAIL_COND(!get_space());
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
get_space()->area_add_to_monitor_query_list(&monitor_query_list);
+ }
}
void Area2DSW::set_monitorable(bool p_monitorable) {
-
- if (monitorable == p_monitorable)
+ if (monitorable == p_monitorable) {
return;
+ }
monitorable = p_monitorable;
_set_static(!monitorable);
}
void Area2DSW::call_queries() {
-
if (monitor_callback_id.is_valid() && !monitored_bodies.empty()) {
-
Variant res[5];
Variant *resptr[5];
- for (int i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++) {
resptr[i] = &res[i];
+ }
Object *obj = ObjectDB::get_instance(monitor_callback_id);
if (!obj) {
@@ -214,9 +214,9 @@ void Area2DSW::call_queries() {
}
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E; E = E->next()) {
-
- if (E->get().state == 0)
+ if (E->get().state == 0) {
continue; //nothing happened
+ }
res[0] = E->get().state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
@@ -232,11 +232,11 @@ void Area2DSW::call_queries() {
monitored_bodies.clear();
if (area_monitor_callback_id.is_valid() && !monitored_areas.empty()) {
-
Variant res[5];
Variant *resptr[5];
- for (int i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++) {
resptr[i] = &res[i];
+ }
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
if (!obj) {
@@ -246,9 +246,9 @@ void Area2DSW::call_queries() {
}
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E; E = E->next()) {
-
- if (E->get().state == 0)
+ if (E->get().state == 0) {
continue; //nothing happened
+ }
res[0] = E->get().state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
@@ -270,7 +270,6 @@ Area2DSW::Area2DSW() :
CollisionObject2DSW(TYPE_AREA),
monitor_query_list(this),
moved_list(this) {
-
_set_static(true); //areas are not active by default
space_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
gravity = 9.80665;
diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h
index ae2a8ff995..f14466f582 100644
--- a/servers/physics_2d/area_2d_sw.h
+++ b/servers/physics_2d/area_2d_sw.h
@@ -41,7 +41,6 @@ class Body2DSW;
class Constraint2DSW;
class Area2DSW : public CollisionObject2DSW {
-
PhysicsServer2D::AreaSpaceOverrideMode space_override_mode;
real_t gravity;
Vector2 gravity_vector;
@@ -63,23 +62,21 @@ class Area2DSW : public CollisionObject2DSW {
SelfList<Area2DSW> moved_list;
struct BodyKey {
-
RID rid;
ObjectID instance_id;
uint32_t body_shape;
uint32_t area_shape;
_FORCE_INLINE_ bool operator<(const BodyKey &p_key) const {
-
if (rid == p_key.rid) {
-
if (body_shape == p_key.body_shape) {
-
return area_shape < p_key.area_shape;
- } else
+ } else {
return body_shape < p_key.body_shape;
- } else
+ }
+ } else {
return rid < p_key.rid;
+ }
}
_FORCE_INLINE_ BodyKey() {}
@@ -88,7 +85,6 @@ class Area2DSW : public CollisionObject2DSW {
};
struct BodyState {
-
int state;
_FORCE_INLINE_ void inc() { state++; }
_FORCE_INLINE_ void dec() { state--; }
@@ -170,33 +166,35 @@ public:
};
void Area2DSW::add_body_to_query(Body2DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
-
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].inc();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
-void Area2DSW::remove_body_from_query(Body2DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
+void Area2DSW::remove_body_from_query(Body2DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].dec();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
void Area2DSW::add_area_to_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
-
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].inc();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
-void Area2DSW::remove_area_from_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
+void Area2DSW::remove_area_from_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].dec();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
#endif // AREA_2D_SW_H
diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp
index 0e70a626c2..d7bceb9f02 100644
--- a/servers/physics_2d/area_pair_2d_sw.cpp
+++ b/servers/physics_2d/area_pair_2d_sw.cpp
@@ -32,7 +32,6 @@
#include "collision_solver_2d_sw.h"
bool AreaPair2DSW::setup(real_t p_step) {
-
bool result = false;
if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) {
@@ -42,20 +41,21 @@ bool AreaPair2DSW::setup(real_t p_step) {
}
if (result != colliding) {
-
if (result) {
-
- if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
body->add_area(area);
- if (area->has_monitor_callback())
+ }
+ if (area->has_monitor_callback()) {
area->add_body_to_query(body, body_shape, area_shape);
+ }
} else {
-
- if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
body->remove_area(area);
- if (area->has_monitor_callback())
+ }
+ if (area->has_monitor_callback()) {
area->remove_body_from_query(body, body_shape, area_shape);
+ }
}
colliding = result;
@@ -68,7 +68,6 @@ void AreaPair2DSW::solve(real_t p_step) {
}
AreaPair2DSW::AreaPair2DSW(Body2DSW *p_body, int p_body_shape, Area2DSW *p_area, int p_area_shape) {
-
body = p_body;
area = p_area;
body_shape = p_body_shape;
@@ -76,18 +75,19 @@ AreaPair2DSW::AreaPair2DSW(Body2DSW *p_body, int p_body_shape, Area2DSW *p_area,
colliding = false;
body->add_constraint(this, 0);
area->add_constraint(this);
- if (p_body->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) //need to be active to process pair
+ if (p_body->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) { //need to be active to process pair
p_body->set_active(true);
+ }
}
AreaPair2DSW::~AreaPair2DSW() {
-
if (colliding) {
-
- if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
body->remove_area(area);
- if (area->has_monitor_callback())
+ }
+ if (area->has_monitor_callback()) {
area->remove_body_from_query(body, body_shape, area_shape);
+ }
}
body->remove_constraint(this);
area->remove_constraint(this);
@@ -96,7 +96,6 @@ AreaPair2DSW::~AreaPair2DSW() {
//////////////////////////////////
bool Area2Pair2DSW::setup(real_t p_step) {
-
bool result = false;
if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) {
result = false;
@@ -105,22 +104,23 @@ bool Area2Pair2DSW::setup(real_t p_step) {
}
if (result != colliding) {
-
if (result) {
-
- if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) {
area_b->add_area_to_query(area_a, shape_a, shape_b);
+ }
- if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) {
area_a->add_area_to_query(area_b, shape_b, shape_a);
+ }
} else {
-
- if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) {
area_b->remove_area_from_query(area_a, shape_a, shape_b);
+ }
- if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) {
area_a->remove_area_from_query(area_b, shape_b, shape_a);
+ }
}
colliding = result;
@@ -133,7 +133,6 @@ void Area2Pair2DSW::solve(real_t p_step) {
}
Area2Pair2DSW::Area2Pair2DSW(Area2DSW *p_area_a, int p_shape_a, Area2DSW *p_area_b, int p_shape_b) {
-
area_a = p_area_a;
area_b = p_area_b;
shape_a = p_shape_a;
@@ -144,14 +143,14 @@ Area2Pair2DSW::Area2Pair2DSW(Area2DSW *p_area_a, int p_shape_a, Area2DSW *p_area
}
Area2Pair2DSW::~Area2Pair2DSW() {
-
if (colliding) {
-
- if (area_b->has_area_monitor_callback())
+ if (area_b->has_area_monitor_callback()) {
area_b->remove_area_from_query(area_a, shape_a, shape_b);
+ }
- if (area_a->has_area_monitor_callback())
+ if (area_a->has_area_monitor_callback()) {
area_a->remove_area_from_query(area_b, shape_b, shape_a);
+ }
}
area_a->remove_constraint(this);
diff --git a/servers/physics_2d/area_pair_2d_sw.h b/servers/physics_2d/area_pair_2d_sw.h
index 78173d98b2..5e8670b464 100644
--- a/servers/physics_2d/area_pair_2d_sw.h
+++ b/servers/physics_2d/area_pair_2d_sw.h
@@ -36,7 +36,6 @@
#include "constraint_2d_sw.h"
class AreaPair2DSW : public Constraint2DSW {
-
Body2DSW *body;
Area2DSW *area;
int body_shape;
@@ -52,7 +51,6 @@ public:
};
class Area2Pair2DSW : public Constraint2DSW {
-
Area2DSW *area_a;
Area2DSW *area_b;
int shape_a;
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 39e28fd002..856bba78f7 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -34,19 +34,16 @@
#include "space_2d_sw.h"
void Body2DSW::_update_inertia() {
-
- if (!user_inertia && get_space() && !inertia_update_list.in_list())
+ if (!user_inertia && get_space() && !inertia_update_list.in_list()) {
get_space()->body_add_to_inertia_update_list(&inertia_update_list);
+ }
}
void Body2DSW::update_inertias() {
-
//update shapes and motions
switch (mode) {
-
case PhysicsServer2D::BODY_MODE_RIGID: {
-
if (user_inertia) {
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
break;
@@ -55,14 +52,12 @@ void Body2DSW::update_inertias() {
real_t total_area = 0;
for (int i = 0; i < get_shape_count(); i++) {
-
total_area += get_shape_aabb(i).get_area();
}
inertia = 0;
for (int i = 0; i < get_shape_count(); i++) {
-
if (is_shape_disabled(i)) {
continue;
}
@@ -80,20 +75,19 @@ void Body2DSW::update_inertias() {
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
- if (mass)
+ if (mass) {
_inv_mass = 1.0 / mass;
- else
+ } else {
_inv_mass = 0;
+ }
} break;
case PhysicsServer2D::BODY_MODE_KINEMATIC:
case PhysicsServer2D::BODY_MODE_STATIC: {
-
_inv_inertia = 0;
_inv_mass = 0;
} break;
case PhysicsServer2D::BODY_MODE_CHARACTER: {
-
_inv_inertia = 0;
_inv_mass = 1.0 / mass;
@@ -105,19 +99,22 @@ void Body2DSW::update_inertias() {
}
void Body2DSW::set_active(bool p_active) {
-
- if (active == p_active)
+ if (active == p_active) {
return;
+ }
active = p_active;
if (!p_active) {
- if (get_space())
+ if (get_space()) {
get_space()->body_remove_from_active_list(&active_list);
+ }
} else {
- if (mode == PhysicsServer2D::BODY_MODE_STATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
return; //static bodies can't become active
- if (get_space())
+ }
+ if (get_space()) {
get_space()->body_add_to_active_list(&active_list);
+ }
//still_time=0;
}
@@ -135,14 +132,11 @@ void Body2DSW::set_active(bool p_active) {
}
void Body2DSW::set_param(PhysicsServer2D::BodyParameter p_param, real_t p_value) {
-
switch (p_param) {
case PhysicsServer2D::BODY_PARAM_BOUNCE: {
-
bounce = p_value;
} break;
case PhysicsServer2D::BODY_PARAM_FRICTION: {
-
friction = p_value;
} break;
case PhysicsServer2D::BODY_PARAM_MASS: {
@@ -165,11 +159,9 @@ void Body2DSW::set_param(PhysicsServer2D::BodyParameter p_param, real_t p_value)
gravity_scale = p_value;
} break;
case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: {
-
linear_damp = p_value;
} break;
case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: {
-
angular_damp = p_value;
} break;
default: {
@@ -178,14 +170,11 @@ void Body2DSW::set_param(PhysicsServer2D::BodyParameter p_param, real_t p_value)
}
real_t Body2DSW::get_param(PhysicsServer2D::BodyParameter p_param) const {
-
switch (p_param) {
case PhysicsServer2D::BODY_PARAM_BOUNCE: {
-
return bounce;
}
case PhysicsServer2D::BODY_PARAM_FRICTION: {
-
return friction;
}
case PhysicsServer2D::BODY_PARAM_MASS: {
@@ -198,11 +187,9 @@ real_t Body2DSW::get_param(PhysicsServer2D::BodyParameter p_param) const {
return gravity_scale;
}
case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: {
-
return linear_damp;
}
case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: {
-
return angular_damp;
}
default: {
@@ -213,7 +200,6 @@ real_t Body2DSW::get_param(PhysicsServer2D::BodyParameter p_param) const {
}
void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
-
PhysicsServer2D::BodyMode prev = mode;
mode = p_mode;
@@ -221,7 +207,6 @@ void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
//CLEAR UP EVERYTHING IN CASE IT NOT WORKS!
case PhysicsServer2D::BODY_MODE_STATIC:
case PhysicsServer2D::BODY_MODE_KINEMATIC: {
-
_set_inv_transform(get_transform().affine_inverse());
_inv_mass = 0;
_inv_inertia = 0;
@@ -234,7 +219,6 @@ void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
}
} break;
case PhysicsServer2D::BODY_MODE_RIGID: {
-
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
_set_static(false);
@@ -242,7 +226,6 @@ void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
} break;
case PhysicsServer2D::BODY_MODE_CHARACTER: {
-
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = 0;
_set_static(false);
@@ -258,24 +241,20 @@ void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) {
_update_queries();
*/
}
-PhysicsServer2D::BodyMode Body2DSW::get_mode() const {
+PhysicsServer2D::BodyMode Body2DSW::get_mode() const {
return mode;
}
void Body2DSW::_shapes_changed() {
-
_update_inertia();
wakeup_neighbours();
}
void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant) {
-
switch (p_state) {
case PhysicsServer2D::BODY_STATE_TRANSFORM: {
-
if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
-
new_transform = p_variant;
//wakeup_neighbours();
set_active(true);
@@ -292,8 +271,9 @@ void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_va
Transform2D t = p_variant;
t.orthonormalize();
new_transform = get_transform(); //used as old to compute motion
- if (t == new_transform)
+ if (t == new_transform) {
break;
+ }
_set_transform(t);
_set_inv_transform(get_transform().inverse());
}
@@ -301,7 +281,6 @@ void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_va
} break;
case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: {
-
/*
if (mode==PhysicsServer2D::BODY_MODE_STATIC)
break;
@@ -321,8 +300,9 @@ void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_va
} break;
case PhysicsServer2D::BODY_STATE_SLEEPING: {
//?
- if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
break;
+ }
bool do_sleep = p_variant;
if (do_sleep) {
linear_velocity = Vector2();
@@ -331,20 +311,22 @@ void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_va
//biased_angular_velocity=Vector3();
set_active(false);
} else {
- if (mode != PhysicsServer2D::BODY_MODE_STATIC)
+ if (mode != PhysicsServer2D::BODY_MODE_STATIC) {
set_active(true);
+ }
}
} break;
case PhysicsServer2D::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant;
- if (mode == PhysicsServer2D::BODY_MODE_RIGID && !active && !can_sleep)
+ if (mode == PhysicsServer2D::BODY_MODE_RIGID && !active && !can_sleep) {
set_active(true);
+ }
} break;
}
}
-Variant Body2DSW::get_state(PhysicsServer2D::BodyState p_state) const {
+Variant Body2DSW::get_state(PhysicsServer2D::BodyState p_state) const {
switch (p_state) {
case PhysicsServer2D::BODY_STATE_TRANSFORM: {
return get_transform();
@@ -367,26 +349,27 @@ Variant Body2DSW::get_state(PhysicsServer2D::BodyState p_state) const {
}
void Body2DSW::set_space(Space2DSW *p_space) {
-
if (get_space()) {
-
wakeup_neighbours();
- if (inertia_update_list.in_list())
+ if (inertia_update_list.in_list()) {
get_space()->body_remove_from_inertia_update_list(&inertia_update_list);
- if (active_list.in_list())
+ }
+ if (active_list.in_list()) {
get_space()->body_remove_from_active_list(&active_list);
- if (direct_state_query_list.in_list())
+ }
+ if (direct_state_query_list.in_list()) {
get_space()->body_remove_from_state_query_list(&direct_state_query_list);
+ }
}
_set_space(p_space);
if (get_space()) {
-
_update_inertia();
- if (active)
+ if (active) {
get_space()->body_add_to_active_list(&active_list);
+ }
/*
_update_queries();
if (is_active()) {
@@ -400,7 +383,6 @@ void Body2DSW::set_space(Space2DSW *p_space) {
}
void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
-
if (p_area->is_gravity_point()) {
if (p_area->get_gravity_distance_scale() > 0) {
Vector2 v = p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin();
@@ -417,9 +399,9 @@ void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
}
void Body2DSW::integrate_forces(real_t p_step) {
-
- if (mode == PhysicsServer2D::BODY_MODE_STATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
return;
+ }
Area2DSW *def_area = get_space()->get_default_area();
// Area2DSW *damp_area = def_area;
@@ -461,15 +443,17 @@ void Body2DSW::integrate_forces(real_t p_step) {
gravity *= gravity_scale;
// If less than 0, override dampenings with that of the Body2D
- if (angular_damp >= 0)
+ if (angular_damp >= 0) {
area_angular_damp = angular_damp;
+ }
/*
else
area_angular_damp=damp_area->get_angular_damp();
*/
- if (linear_damp >= 0)
+ if (linear_damp >= 0) {
area_linear_damp = linear_damp;
+ }
/*
else
area_linear_damp=damp_area->get_linear_damp();
@@ -479,7 +463,6 @@ void Body2DSW::integrate_forces(real_t p_step) {
bool do_motion = false;
if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
-
//compute motion, angular and etc. velocities from prev transform
motion = new_transform.get_origin() - get_transform().get_origin();
linear_velocity = motion / p_step;
@@ -506,13 +489,15 @@ void Body2DSW::integrate_forces(real_t p_step) {
real_t damp = 1.0 - p_step * area_linear_damp;
- if (damp < 0) // reached zero in the given time
+ if (damp < 0) { // reached zero in the given time
damp = 0;
+ }
real_t angular_damp = 1.0 - p_step * area_angular_damp;
- if (angular_damp < 0) // reached zero in the given time
+ if (angular_damp < 0) { // reached zero in the given time
angular_damp = 0;
+ }
linear_velocity *= damp;
angular_velocity *= angular_damp;
@@ -522,7 +507,6 @@ void Body2DSW::integrate_forces(real_t p_step) {
}
if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) {
-
motion = linear_velocity * p_step;
do_motion = true;
}
@@ -544,19 +528,20 @@ void Body2DSW::integrate_forces(real_t p_step) {
}
void Body2DSW::integrate_velocities(real_t p_step) {
-
- if (mode == PhysicsServer2D::BODY_MODE_STATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC) {
return;
+ }
- if (fi_callback)
+ if (fi_callback) {
get_space()->body_add_to_state_query_list(&direct_state_query_list);
+ }
if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
-
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
- if (contacts.size() == 0 && linear_velocity == Vector2() && angular_velocity == 0)
+ if (contacts.size() == 0 && linear_velocity == Vector2() && angular_velocity == 0) {
set_active(false); //stopped moving, deactivate
+ }
return;
}
@@ -569,38 +554,37 @@ void Body2DSW::integrate_velocities(real_t p_step) {
_set_transform(Transform2D(angle, pos), continuous_cd_mode == PhysicsServer2D::CCD_MODE_DISABLED);
_set_inv_transform(get_transform().inverse());
- if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED)
+ if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) {
new_transform = get_transform();
+ }
//_update_inertia_tensor();
}
void Body2DSW::wakeup_neighbours() {
-
for (Map<Constraint2DSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) {
-
const Constraint2DSW *c = E->key();
Body2DSW **n = c->get_body_ptr();
int bc = c->get_body_count();
for (int i = 0; i < bc; i++) {
-
- if (i == E->get())
+ if (i == E->get()) {
continue;
+ }
Body2DSW *b = n[i];
- if (b->mode != PhysicsServer2D::BODY_MODE_RIGID)
+ if (b->mode != PhysicsServer2D::BODY_MODE_RIGID) {
continue;
+ }
- if (!b->is_active())
+ if (!b->is_active()) {
b->set_active(true);
+ }
}
}
}
void Body2DSW::call_queries() {
-
if (fi_callback) {
-
PhysicsDirectBodyState2DSW *dbs = PhysicsDirectBodyState2DSW::singleton;
dbs->body = this;
@@ -609,12 +593,10 @@ void Body2DSW::call_queries() {
Object *obj = ObjectDB::get_instance(fi_callback->id);
if (!obj) {
-
set_force_integration_callback(ObjectID(), StringName());
} else {
Callable::CallError ce;
if (fi_callback->callback_udata.get_type() != Variant::NIL) {
-
obj->call(fi_callback->method, vp, 2, ce);
} else {
@@ -625,36 +607,31 @@ void Body2DSW::call_queries() {
}
bool Body2DSW::sleep_test(real_t p_step) {
-
- if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
return true; //
- else if (mode == PhysicsServer2D::BODY_MODE_CHARACTER)
+ } else if (mode == PhysicsServer2D::BODY_MODE_CHARACTER) {
return !active; // characters and kinematic bodies don't sleep unless asked to sleep
- else if (!can_sleep)
+ } else if (!can_sleep) {
return false;
+ }
if (Math::abs(angular_velocity) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) {
-
still_time += p_step;
return still_time > get_space()->get_body_time_to_sleep();
} else {
-
still_time = 0; //maybe this should be set to 0 on set_active?
return false;
}
}
void Body2DSW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
-
if (fi_callback) {
-
memdelete(fi_callback);
fi_callback = nullptr;
}
if (p_id.is_valid()) {
-
fi_callback = memnew(ForceIntegrationCallback);
fi_callback->id = p_id;
fi_callback->method = p_method;
@@ -667,7 +644,6 @@ Body2DSW::Body2DSW() :
active_list(this),
inertia_update_list(this),
direct_state_query_list(this) {
-
mode = PhysicsServer2D::BODY_MODE_RIGID;
active = true;
angular_velocity = 0;
@@ -701,31 +677,27 @@ Body2DSW::Body2DSW() :
}
Body2DSW::~Body2DSW() {
-
- if (fi_callback)
+ if (fi_callback) {
memdelete(fi_callback);
+ }
}
PhysicsDirectBodyState2DSW *PhysicsDirectBodyState2DSW::singleton = nullptr;
PhysicsDirectSpaceState2D *PhysicsDirectBodyState2DSW::get_space_state() {
-
return body->get_space()->get_direct_state();
}
Variant PhysicsDirectBodyState2DSW::get_contact_collider_shape_metadata(int p_contact_idx) const {
-
ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Variant());
if (!PhysicsServer2DSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) {
-
return Variant();
}
Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider);
int sidx = body->contacts[p_contact_idx].collider_shape;
if (sidx < 0 || sidx >= other->get_shape_count()) {
-
return Variant();
}
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index a36dc3bfe2..2300c9cdee 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -38,7 +38,6 @@
class Constraint2DSW;
class Body2DSW : public CollisionObject2DSW {
-
PhysicsServer2D::BodyMode mode;
Vector2 biased_linear_velocity;
@@ -87,7 +86,6 @@ class Body2DSW : public CollisionObject2DSW {
Map<Constraint2DSW *, int> constraint_map;
struct AreaCMP {
-
Area2DSW *area;
int refCount;
_FORCE_INLINE_ bool operator==(const AreaCMP &p_cmp) const { return area->get_self() == p_cmp.area->get_self(); }
@@ -102,7 +100,6 @@ class Body2DSW : public CollisionObject2DSW {
Vector<AreaCMP> areas;
struct Contact {
-
Vector2 local_pos;
Vector2 local_normal;
real_t depth;
@@ -118,7 +115,6 @@ class Body2DSW : public CollisionObject2DSW {
int contact_count;
struct ForceIntegrationCallback {
-
ObjectID id;
StringName method;
Variant callback_udata;
@@ -150,16 +146,18 @@ public:
int index = areas.find(AreaCMP(p_area));
if (index > -1) {
areas.write[index].refCount -= 1;
- if (areas[index].refCount < 1)
+ if (areas[index].refCount < 1) {
areas.remove(index);
+ }
}
}
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
contacts.resize(p_size);
contact_count = 0;
- if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size)
+ if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size) {
set_active(true);
+ }
}
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
@@ -206,7 +204,6 @@ public:
}
_FORCE_INLINE_ void apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) {
-
linear_velocity += p_impulse * _inv_mass;
angular_velocity += _inv_inertia * p_offset.cross(p_impulse);
}
@@ -216,7 +213,6 @@ public:
}
_FORCE_INLINE_ void apply_bias_impulse(const Vector2 &p_pos, const Vector2 &p_j) {
-
biased_linear_velocity += p_j * _inv_mass;
biased_angular_velocity += _inv_inertia * p_pos.cross(p_j);
}
@@ -225,8 +221,9 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC)
+ if ((!get_space()) || mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
return;
+ }
set_active(true);
}
@@ -250,7 +247,6 @@ public:
}
_FORCE_INLINE_ void add_force(const Vector2 &p_offset, const Vector2 &p_force) {
-
applied_force += p_force;
applied_torque += p_offset.cross(p_force);
}
@@ -278,7 +274,6 @@ public:
void integrate_velocities(real_t p_step);
_FORCE_INLINE_ Vector2 get_motion() const {
-
if (mode > PhysicsServer2D::BODY_MODE_KINEMATIC) {
return new_transform.get_origin() - get_transform().get_origin();
} else if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) {
@@ -299,11 +294,11 @@ public:
//add contact inline
void Body2DSW::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local_normal, real_t p_depth, int p_local_shape, const Vector2 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector2 &p_collider_velocity_at_pos) {
-
int c_max = contacts.size();
- if (c_max == 0)
+ if (c_max == 0) {
return;
+ }
Contact *c = contacts.ptrw();
@@ -312,11 +307,9 @@ void Body2DSW::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local_no
if (contact_count < c_max) {
idx = contact_count++;
} else {
-
real_t least_depth = 1e20;
int least_deep = -1;
for (int i = 0; i < c_max; i++) {
-
if (i == 0 || c[i].depth < least_depth) {
least_deep = i;
least_depth = c[i].depth;
@@ -324,11 +317,11 @@ void Body2DSW::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local_no
}
if (least_deep >= 0 && least_depth < p_depth) {
-
idx = least_deep;
}
- if (idx == -1)
+ if (idx == -1) {
return; //none least deepe than this
+ }
}
c[idx].local_pos = p_local_pos;
@@ -343,7 +336,6 @@ void Body2DSW::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local_no
}
class PhysicsDirectBodyState2DSW : public PhysicsDirectBodyState2D {
-
GDCLASS(PhysicsDirectBodyState2DSW, PhysicsDirectBodyState2D);
public:
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index f38a76cff6..e483ddf1cc 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -36,14 +36,12 @@
#define ACCUMULATE_IMPULSES
void BodyPair2DSW::_add_contact(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_self) {
-
BodyPair2DSW *self = (BodyPair2DSW *)p_self;
self->_contact_added_callback(p_point_A, p_point_B);
}
void BodyPair2DSW::_contact_added_callback(const Vector2 &p_point_A, const Vector2 &p_point_B) {
-
// check if we already have the contact
Vector2 local_A = A->get_inv_transform().basis_xform(p_point_A);
@@ -69,12 +67,10 @@ void BodyPair2DSW::_contact_added_callback(const Vector2 &p_point_A, const Vecto
real_t recycle_radius_2 = space->get_contact_recycle_radius() * space->get_contact_recycle_radius();
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
if (
c.local_A.distance_squared_to(local_A) < (recycle_radius_2) &&
c.local_B.distance_squared_to(local_B) < (recycle_radius_2)) {
-
contact.acc_normal_impulse = c.acc_normal_impulse;
contact.acc_tangent_impulse = c.acc_tangent_impulse;
contact.acc_bias_impulse = c.acc_bias_impulse;
@@ -86,14 +82,12 @@ void BodyPair2DSW::_contact_added_callback(const Vector2 &p_point_A, const Vecto
// figure out if the contact amount must be reduced to fit the new contact
if (new_index == MAX_CONTACTS) {
-
// remove the contact with the minimum depth
int least_deep = -1;
real_t min_depth = 1e10;
for (int i = 0; i <= contact_count; i++) {
-
Contact &c = (i == contact_count) ? contact : contacts[i];
Vector2 global_A = A->get_transform().basis_xform(c.local_A);
Vector2 global_B = B->get_transform().basis_xform(c.local_B) + offset_B;
@@ -102,7 +96,6 @@ void BodyPair2DSW::_contact_added_callback(const Vector2 &p_point_A, const Vecto
real_t depth = axis.dot(c.normal);
if (depth < min_depth) {
-
min_depth = depth;
least_deep = i;
}
@@ -121,20 +114,17 @@ void BodyPair2DSW::_contact_added_callback(const Vector2 &p_point_A, const Vecto
contacts[new_index] = contact;
if (new_index == contact_count) {
-
contact_count++;
}
}
void BodyPair2DSW::_validate_contacts() {
-
//make sure to erase contacts that are no longer valid
real_t max_separation = space->get_contact_max_separation();
real_t max_separation2 = max_separation * max_separation;
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
bool erase = false;
@@ -169,11 +159,11 @@ void BodyPair2DSW::_validate_contacts() {
}
bool BodyPair2DSW::_test_ccd(real_t p_step, Body2DSW *p_A, int p_shape_A, const Transform2D &p_xform_A, Body2DSW *p_B, int p_shape_B, const Transform2D &p_xform_B, bool p_swap_result) {
-
Vector2 motion = p_A->get_linear_velocity() * p_step;
real_t mlen = motion.length();
- if (mlen < CMP_EPSILON)
+ if (mlen < CMP_EPSILON) {
return false;
+ }
Vector2 mnormal = motion / mlen;
@@ -199,8 +189,9 @@ bool BodyPair2DSW::_test_ccd(real_t p_step, Body2DSW *p_A, int p_shape_A, const
Vector2 local_to = from_inv.xform(to);
Vector2 rpos, rnorm;
- if (!p_B->get_shape(p_shape_B)->intersect_segment(local_from, local_to, rpos, rnorm))
+ if (!p_B->get_shape(p_shape_B)->intersect_segment(local_from, local_to, rpos, rnorm)) {
return false;
+ }
//ray hit something
@@ -211,10 +202,11 @@ bool BodyPair2DSW::_test_ccd(real_t p_step, Body2DSW *p_A, int p_shape_A, const
//create a contact
- if (p_swap_result)
+ if (p_swap_result) {
_contact_added_callback(contact_B, contact_A);
- else
+ } else {
_contact_added_callback(contact_A, contact_B);
+ }
return true;
}
@@ -228,7 +220,6 @@ real_t combine_friction(Body2DSW *A, Body2DSW *B) {
}
bool BodyPair2DSW::setup(real_t p_step) {
-
//cannot collide
if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) {
collided = false;
@@ -270,17 +261,18 @@ bool BodyPair2DSW::setup(real_t p_step) {
collided = CollisionSolver2DSW::solve(shape_A_ptr, xform_A, motion_A, shape_B_ptr, xform_B, motion_B, _add_contact, this, &sep_axis);
if (!collided) {
-
//test ccd (currently just a raycast)
if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) {
- if (_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B))
+ if (_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B)) {
collided = true;
+ }
}
if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) {
- if (_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A, true))
+ if (_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A, true)) {
collided = true;
+ }
}
if (!collided) {
@@ -289,22 +281,24 @@ bool BodyPair2DSW::setup(real_t p_step) {
}
}
- if (oneway_disabled)
+ if (oneway_disabled) {
return false;
+ }
//if (!prev_collided) {
{
-
if (A->is_shape_set_as_one_way_collision(shape_A)) {
Vector2 direction = xform_A.get_axis(1).normalized();
bool valid = false;
if (B->get_linear_velocity().dot(direction) >= 0) {
for (int i = 0; i < contact_count; i++) {
Contact &c = contacts[i];
- if (!c.reused)
+ if (!c.reused) {
continue;
- if (c.normal.dot(direction) > 0) //greater (normal inverted)
+ }
+ if (c.normal.dot(direction) > 0) { //greater (normal inverted)
continue;
+ }
valid = true;
break;
@@ -324,10 +318,12 @@ bool BodyPair2DSW::setup(real_t p_step) {
if (A->get_linear_velocity().dot(direction) >= 0) {
for (int i = 0; i < contact_count; i++) {
Contact &c = contacts[i];
- if (!c.reused)
+ if (!c.reused) {
continue;
- if (c.normal.dot(direction) < 0) //less (normal ok)
+ }
+ if (c.normal.dot(direction) < 0) { //less (normal ok)
continue;
+ }
valid = true;
break;
@@ -345,13 +341,13 @@ bool BodyPair2DSW::setup(real_t p_step) {
real_t bias = 0.3;
if (shape_A_ptr->get_custom_bias() || shape_B_ptr->get_custom_bias()) {
-
- if (shape_A_ptr->get_custom_bias() == 0)
+ if (shape_A_ptr->get_custom_bias() == 0) {
bias = shape_B_ptr->get_custom_bias();
- else if (shape_B_ptr->get_custom_bias() == 0)
+ } else if (shape_B_ptr->get_custom_bias() == 0) {
bias = shape_A_ptr->get_custom_bias();
- else
+ } else {
bias = (shape_B_ptr->get_custom_bias() + shape_A_ptr->get_custom_bias()) * 0.5;
+ }
}
cc = 0;
@@ -361,7 +357,6 @@ bool BodyPair2DSW::setup(real_t p_step) {
bool do_process = false;
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
Vector2 global_A = xform_Au.xform(c.local_A);
@@ -388,7 +383,6 @@ bool BodyPair2DSW::setup(real_t p_step) {
c.rB = global_B - offset_B;
if (gather_A | gather_B) {
-
//Vector2 crB( -B->get_angular_velocity() * c.rB.y, B->get_angular_velocity() * c.rB.x );
global_A += offset_A;
@@ -399,7 +393,6 @@ bool BodyPair2DSW::setup(real_t p_step) {
A->add_contact(global_A, -c.normal, depth, shape_A, global_B, shape_B, B->get_instance_id(), B->get_self(), crB + B->get_linear_velocity());
}
if (gather_B) {
-
Vector2 crA(-A->get_angular_velocity() * c.rA.y, A->get_angular_velocity() * c.rA.x);
B->add_contact(global_B, c.normal, depth, shape_B, global_A, shape_A, A->get_instance_id(), A->get_self(), crA + A->get_linear_velocity());
}
@@ -442,7 +435,6 @@ bool BodyPair2DSW::setup(real_t p_step) {
c.bounce = combine_bounce(A, B);
if (c.bounce) {
-
Vector2 crA(-A->get_angular_velocity() * c.rA.y, A->get_angular_velocity() * c.rA.x);
Vector2 crB(-B->get_angular_velocity() * c.rB.y, B->get_angular_velocity() * c.rB.x);
Vector2 dv = B->get_linear_velocity() + crB - A->get_linear_velocity() - crA;
@@ -456,17 +448,17 @@ bool BodyPair2DSW::setup(real_t p_step) {
}
void BodyPair2DSW::solve(real_t p_step) {
-
- if (!collided)
+ if (!collided) {
return;
+ }
for (int i = 0; i < contact_count; ++i) {
-
Contact &c = contacts[i];
cc++;
- if (!c.active)
+ if (!c.active) {
continue;
+ }
// Relative velocity at contact
@@ -512,7 +504,6 @@ void BodyPair2DSW::solve(real_t p_step) {
BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A, Body2DSW *p_B, int p_shape_B) :
Constraint2DSW(_arr, 2) {
-
A = p_A;
B = p_B;
shape_A = p_shape_A;
@@ -526,7 +517,6 @@ BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A, Body2DSW *p_B, int p_sh
}
BodyPair2DSW::~BodyPair2DSW() {
-
A->remove_constraint(this);
B->remove_constraint(this);
}
diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h
index e46ecbc8eb..ea4d55841a 100644
--- a/servers/physics_2d/body_pair_2d_sw.h
+++ b/servers/physics_2d/body_pair_2d_sw.h
@@ -35,7 +35,6 @@
#include "constraint_2d_sw.h"
class BodyPair2DSW : public Constraint2DSW {
-
enum {
MAX_CONTACTS = 2
};
@@ -54,7 +53,6 @@ class BodyPair2DSW : public Constraint2DSW {
Space2DSW *space;
struct Contact {
-
Vector2 position;
Vector2 normal;
Vector2 local_A, local_B;
diff --git a/servers/physics_2d/broad_phase_2d_basic.cpp b/servers/physics_2d/broad_phase_2d_basic.cpp
index 5e3a13f4dd..3bdfc1a973 100644
--- a/servers/physics_2d/broad_phase_2d_basic.cpp
+++ b/servers/physics_2d/broad_phase_2d_basic.cpp
@@ -31,7 +31,6 @@
#include "broad_phase_2d_basic.h"
BroadPhase2DBasic::ID BroadPhase2DBasic::create(CollisionObject2DSW *p_object_, int p_subindex) {
-
current++;
Element e;
@@ -44,76 +43,71 @@ BroadPhase2DBasic::ID BroadPhase2DBasic::create(CollisionObject2DSW *p_object_,
}
void BroadPhase2DBasic::move(ID p_id, const Rect2 &p_aabb) {
-
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get().aabb = p_aabb;
}
-void BroadPhase2DBasic::set_static(ID p_id, bool p_static) {
+void BroadPhase2DBasic::set_static(ID p_id, bool p_static) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get()._static = p_static;
}
-void BroadPhase2DBasic::remove(ID p_id) {
+void BroadPhase2DBasic::remove(ID p_id) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
element_map.erase(E);
}
CollisionObject2DSW *BroadPhase2DBasic::get_object(ID p_id) const {
-
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, nullptr);
return E->get().owner;
}
-bool BroadPhase2DBasic::is_static(ID p_id) const {
+bool BroadPhase2DBasic::is_static(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, false);
return E->get()._static;
}
-int BroadPhase2DBasic::get_subindex(ID p_id) const {
+int BroadPhase2DBasic::get_subindex(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, -1);
return E->get().subindex;
}
int BroadPhase2DBasic::cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices) {
-
int rc = 0;
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
-
const Rect2 aabb = E->get().aabb;
if (aabb.intersects_segment(p_from, p_to)) {
-
p_results[rc] = E->get().owner;
p_result_indices[rc] = E->get().subindex;
rc++;
- if (rc >= p_max_results)
+ if (rc >= p_max_results) {
break;
+ }
}
}
return rc;
}
-int BroadPhase2DBasic::cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhase2DBasic::cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
-
const Rect2 aabb = E->get().aabb;
if (aabb.intersects(p_aabb)) {
-
p_results[rc] = E->get().owner;
p_result_indices[rc] = E->get().subindex;
rc++;
- if (rc >= p_max_results)
+ if (rc >= p_max_results) {
break;
+ }
}
}
@@ -121,28 +115,25 @@ int BroadPhase2DBasic::cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_re
}
void BroadPhase2DBasic::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) {
-
pair_userdata = p_userdata;
pair_callback = p_pair_callback;
}
-void BroadPhase2DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
+void BroadPhase2DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_userdata = p_userdata;
unpair_callback = p_unpair_callback;
}
void BroadPhase2DBasic::update() {
-
// recompute pairs
for (Map<ID, Element>::Element *I = element_map.front(); I; I = I->next()) {
-
for (Map<ID, Element>::Element *J = I->next(); J; J = J->next()) {
-
Element *elem_A = &I->get();
Element *elem_B = &J->get();
- if (elem_A->owner == elem_B->owner)
+ if (elem_A->owner == elem_B->owner) {
continue;
+ }
bool pair_ok = elem_A->aabb.intersects(elem_B->aabb) && (!elem_A->_static || !elem_B->_static);
@@ -151,29 +142,30 @@ void BroadPhase2DBasic::update() {
Map<PairKey, void *>::Element *E = pair_map.find(key);
if (!pair_ok && E) {
- if (unpair_callback)
+ if (unpair_callback) {
unpair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, E->get(), unpair_userdata);
+ }
pair_map.erase(key);
}
if (pair_ok && !E) {
-
void *data = nullptr;
- if (pair_callback)
+ if (pair_callback) {
data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata);
- pair_map.insert(key, data);
+ if (data) {
+ pair_map.insert(key, data);
+ }
+ }
}
}
}
}
BroadPhase2DSW *BroadPhase2DBasic::_create() {
-
return memnew(BroadPhase2DBasic);
}
BroadPhase2DBasic::BroadPhase2DBasic() {
-
current = 1;
unpair_callback = nullptr;
unpair_userdata = nullptr;
diff --git a/servers/physics_2d/broad_phase_2d_basic.h b/servers/physics_2d/broad_phase_2d_basic.h
index 7d02590af9..ec5cfdbf1d 100644
--- a/servers/physics_2d/broad_phase_2d_basic.h
+++ b/servers/physics_2d/broad_phase_2d_basic.h
@@ -34,9 +34,7 @@
#include "core/map.h"
#include "space_2d_sw.h"
class BroadPhase2DBasic : public BroadPhase2DSW {
-
struct Element {
-
CollisionObject2DSW *owner;
bool _static;
Rect2 aabb;
@@ -48,7 +46,6 @@ class BroadPhase2DBasic : public BroadPhase2DSW {
ID current;
struct PairKey {
-
union {
struct {
ID a;
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index 2cb021258a..ae549ed2e4 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -34,13 +34,11 @@
#define LARGE_ELEMENT_FI 1.01239812
void BroadPhase2DHashGrid::_pair_attempt(Element *p_elem, Element *p_with) {
-
Map<Element *, PairData *>::Element *E = p_elem->paired.find(p_with);
ERR_FAIL_COND(p_elem->_static && p_with->_static);
if (!E) {
-
PairData *pd = memnew(PairData);
p_elem->paired[p_with] = pd;
p_with->paired[p_elem] = pd;
@@ -50,7 +48,6 @@ void BroadPhase2DHashGrid::_pair_attempt(Element *p_elem, Element *p_with) {
}
void BroadPhase2DHashGrid::_unpair_attempt(Element *p_elem, Element *p_with) {
-
Map<Element *, PairData *>::Element *E = p_elem->paired.find(p_with);
ERR_FAIL_COND(!E); //this should really be paired..
@@ -58,7 +55,6 @@ void BroadPhase2DHashGrid::_unpair_attempt(Element *p_elem, Element *p_with) {
E->get()->rc--;
if (E->get()->rc == 0) {
-
if (E->get()->colliding) {
//uncollide
if (unpair_callback) {
@@ -73,20 +69,15 @@ void BroadPhase2DHashGrid::_unpair_attempt(Element *p_elem, Element *p_with) {
}
void BroadPhase2DHashGrid::_check_motion(Element *p_elem) {
-
for (Map<Element *, PairData *>::Element *E = p_elem->paired.front(); E; E = E->next()) {
-
bool pairing = p_elem->aabb.intersects(E->key()->aabb);
if (pairing != E->get()->colliding) {
-
if (pairing) {
-
if (pair_callback) {
E->get()->ud = pair_callback(p_elem->owner, p_elem->subindex, E->key()->owner, E->key()->subindex, pair_userdata);
}
} else {
-
if (unpair_callback) {
unpair_callback(p_elem->owner, p_elem->subindex, E->key()->owner, E->key()->subindex, E->get()->ud, unpair_userdata);
}
@@ -98,17 +89,19 @@ void BroadPhase2DHashGrid::_check_motion(Element *p_elem) {
}
void BroadPhase2DHashGrid::_enter_grid(Element *p_elem, const Rect2 &p_rect, bool p_static) {
-
Vector2 sz = (p_rect.size / cell_size * LARGE_ELEMENT_FI); //use magic number to avoid floating point issues
if (sz.width * sz.height > large_object_min_surface) {
//large object, do not use grid, must check against all elements
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
- if (E->key() == p_elem->self)
+ if (E->key() == p_elem->self) {
continue; // do not pair against itself
- if (E->get().owner == p_elem->owner)
+ }
+ if (E->get().owner == p_elem->owner) {
continue;
- if (E->get()._static && p_static)
+ }
+ if (E->get()._static && p_static) {
continue;
+ }
_pair_attempt(p_elem, &E->get());
}
@@ -121,9 +114,7 @@ void BroadPhase2DHashGrid::_enter_grid(Element *p_elem, const Rect2 &p_rect, boo
Point2i to = ((p_rect.position + p_rect.size) / cell_size).floor();
for (int i = from.x; i <= to.x; i++) {
-
for (int j = from.y; j <= to.y; j++) {
-
PosKey pk;
pk.x = i;
pk.y = j;
@@ -132,7 +123,6 @@ void BroadPhase2DHashGrid::_enter_grid(Element *p_elem, const Rect2 &p_rect, boo
PosBin *pb = hash_table[idx];
while (pb) {
-
if (pb->key == pk) {
break;
}
@@ -156,26 +146,23 @@ void BroadPhase2DHashGrid::_enter_grid(Element *p_elem, const Rect2 &p_rect, boo
}
} else {
if (pb->object_set[p_elem].inc() == 1) {
-
entered = true;
}
}
if (entered) {
-
for (Map<Element *, RC>::Element *E = pb->object_set.front(); E; E = E->next()) {
-
- if (E->key()->owner == p_elem->owner)
+ if (E->key()->owner == p_elem->owner) {
continue;
+ }
_pair_attempt(p_elem, E->key());
}
if (!p_static) {
-
for (Map<Element *, RC>::Element *E = pb->static_object_set.front(); E; E = E->next()) {
-
- if (E->key()->owner == p_elem->owner)
+ if (E->key()->owner == p_elem->owner) {
continue;
+ }
_pair_attempt(p_elem, E->key());
}
}
@@ -186,23 +173,23 @@ void BroadPhase2DHashGrid::_enter_grid(Element *p_elem, const Rect2 &p_rect, boo
//pair separatedly with large elements
for (Map<Element *, RC>::Element *E = large_elements.front(); E; E = E->next()) {
-
- if (E->key() == p_elem)
+ if (E->key() == p_elem) {
continue; // do not pair against itself
- if (E->key()->owner == p_elem->owner)
+ }
+ if (E->key()->owner == p_elem->owner) {
continue;
- if (E->key()->_static && p_static)
+ }
+ if (E->key()->_static && p_static) {
continue;
+ }
_pair_attempt(E->key(), p_elem);
}
}
void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool p_static) {
-
Vector2 sz = (p_rect.size / cell_size * LARGE_ELEMENT_FI);
if (sz.width * sz.height > large_object_min_surface) {
-
//unpair all elements, instead of checking all, just check what is already paired, so we at least save from checking static vs static
Map<Element *, PairData *>::Element *E = p_elem->paired.front();
while (E) {
@@ -221,9 +208,7 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
Point2i to = ((p_rect.position + p_rect.size) / cell_size).floor();
for (int i = from.x; i <= to.x; i++) {
-
for (int j = from.y; j <= to.y; j++) {
-
PosKey pk;
pk.x = i;
pk.y = j;
@@ -232,7 +217,6 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
PosBin *pb = hash_table[idx];
while (pb) {
-
if (pb->key == pk) {
break;
}
@@ -246,48 +230,41 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
if (p_static) {
if (pb->static_object_set[p_elem].dec() == 0) {
-
pb->static_object_set.erase(p_elem);
exited = true;
}
} else {
if (pb->object_set[p_elem].dec() == 0) {
-
pb->object_set.erase(p_elem);
exited = true;
}
}
if (exited) {
-
for (Map<Element *, RC>::Element *E = pb->object_set.front(); E; E = E->next()) {
-
- if (E->key()->owner == p_elem->owner)
+ if (E->key()->owner == p_elem->owner) {
continue;
+ }
_unpair_attempt(p_elem, E->key());
}
if (!p_static) {
-
for (Map<Element *, RC>::Element *E = pb->static_object_set.front(); E; E = E->next()) {
-
- if (E->key()->owner == p_elem->owner)
+ if (E->key()->owner == p_elem->owner) {
continue;
+ }
_unpair_attempt(p_elem, E->key());
}
}
}
if (pb->object_set.empty() && pb->static_object_set.empty()) {
-
if (hash_table[idx] == pb) {
hash_table[idx] = pb->next;
} else {
-
PosBin *px = hash_table[idx];
while (px) {
-
if (px->next == pb) {
px->next = pb->next;
break;
@@ -305,12 +282,15 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
}
for (Map<Element *, RC>::Element *E = large_elements.front(); E; E = E->next()) {
- if (E->key() == p_elem)
+ if (E->key() == p_elem) {
continue; // do not pair against itself
- if (E->key()->owner == p_elem->owner)
+ }
+ if (E->key()->owner == p_elem->owner) {
continue;
- if (E->key()->_static && p_static)
+ }
+ if (E->key()->_static && p_static) {
continue;
+ }
//unpair from large elements
_unpair_attempt(p_elem, E->key());
@@ -318,7 +298,6 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
}
BroadPhase2DHashGrid::ID BroadPhase2DHashGrid::create(CollisionObject2DSW *p_object, int p_subindex) {
-
current++;
Element e;
@@ -333,22 +312,20 @@ BroadPhase2DHashGrid::ID BroadPhase2DHashGrid::create(CollisionObject2DSW *p_obj
}
void BroadPhase2DHashGrid::move(ID p_id, const Rect2 &p_aabb) {
-
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
Element &e = E->get();
- if (p_aabb == e.aabb)
+ if (p_aabb == e.aabb) {
return;
+ }
if (p_aabb != Rect2()) {
-
_enter_grid(&e, p_aabb, e._static);
}
if (e.aabb != Rect2()) {
-
_exit_grid(&e, e.aabb, e._static);
}
@@ -358,18 +335,20 @@ void BroadPhase2DHashGrid::move(ID p_id, const Rect2 &p_aabb) {
e.aabb = p_aabb;
}
-void BroadPhase2DHashGrid::set_static(ID p_id, bool p_static) {
+void BroadPhase2DHashGrid::set_static(ID p_id, bool p_static) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
Element &e = E->get();
- if (e._static == p_static)
+ if (e._static == p_static) {
return;
+ }
- if (e.aabb != Rect2())
+ if (e.aabb != Rect2()) {
_exit_grid(&e, e.aabb, e._static);
+ }
e._static = p_static;
@@ -378,33 +357,33 @@ void BroadPhase2DHashGrid::set_static(ID p_id, bool p_static) {
_check_motion(&e);
}
}
-void BroadPhase2DHashGrid::remove(ID p_id) {
+void BroadPhase2DHashGrid::remove(ID p_id) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
Element &e = E->get();
- if (e.aabb != Rect2())
+ if (e.aabb != Rect2()) {
_exit_grid(&e, e.aabb, e._static);
+ }
element_map.erase(p_id);
}
CollisionObject2DSW *BroadPhase2DHashGrid::get_object(ID p_id) const {
-
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, nullptr);
return E->get().owner;
}
-bool BroadPhase2DHashGrid::is_static(ID p_id) const {
+bool BroadPhase2DHashGrid::is_static(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, false);
return E->get()._static;
}
-int BroadPhase2DHashGrid::get_subindex(ID p_id) const {
+int BroadPhase2DHashGrid::get_subindex(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, -1);
return E->get().subindex;
@@ -412,7 +391,6 @@ int BroadPhase2DHashGrid::get_subindex(ID p_id) const {
template <bool use_aabb, bool use_segment>
void BroadPhase2DHashGrid::_cull(const Point2i p_cell, const Rect2 &p_aabb, const Point2 &p_from, const Point2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices, int &index) {
-
PosKey pk;
pk.x = p_cell.x;
pk.y = p_cell.y;
@@ -421,7 +399,6 @@ void BroadPhase2DHashGrid::_cull(const Point2i p_cell, const Rect2 &p_aabb, cons
PosBin *pb = hash_table[idx];
while (pb) {
-
if (pb->key == pk) {
break;
}
@@ -429,23 +406,27 @@ void BroadPhase2DHashGrid::_cull(const Point2i p_cell, const Rect2 &p_aabb, cons
pb = pb->next;
}
- if (!pb)
+ if (!pb) {
return;
+ }
for (Map<Element *, RC>::Element *E = pb->object_set.front(); E; E = E->next()) {
-
- if (index >= p_max_results)
+ if (index >= p_max_results) {
break;
- if (E->key()->pass == pass)
+ }
+ if (E->key()->pass == pass) {
continue;
+ }
E->key()->pass = pass;
- if (use_aabb && !p_aabb.intersects(E->key()->aabb))
+ if (use_aabb && !p_aabb.intersects(E->key()->aabb)) {
continue;
+ }
- if (use_segment && !E->key()->aabb.intersects_segment(p_from, p_to))
+ if (use_segment && !E->key()->aabb.intersects_segment(p_from, p_to)) {
continue;
+ }
p_results[index] = E->key()->owner;
p_result_indices[index] = E->key()->subindex;
@@ -453,18 +434,20 @@ void BroadPhase2DHashGrid::_cull(const Point2i p_cell, const Rect2 &p_aabb, cons
}
for (Map<Element *, RC>::Element *E = pb->static_object_set.front(); E; E = E->next()) {
-
- if (index >= p_max_results)
+ if (index >= p_max_results) {
break;
- if (E->key()->pass == pass)
+ }
+ if (E->key()->pass == pass) {
continue;
+ }
if (use_aabb && !p_aabb.intersects(E->key()->aabb)) {
continue;
}
- if (use_segment && !E->key()->aabb.intersects_segment(p_from, p_to))
+ if (use_segment && !E->key()->aabb.intersects_segment(p_from, p_to)) {
continue;
+ }
E->key()->pass = pass;
p_results[index] = E->key()->owner;
@@ -474,18 +457,20 @@ void BroadPhase2DHashGrid::_cull(const Point2i p_cell, const Rect2 &p_aabb, cons
}
int BroadPhase2DHashGrid::cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices) {
-
pass++;
Vector2 dir = (p_to - p_from);
- if (dir == Vector2())
+ if (dir == Vector2()) {
return 0;
+ }
//avoid divisions by zero
dir.normalize();
- if (dir.x == 0.0)
+ if (dir.x == 0.0) {
dir.x = 0.000001;
- if (dir.y == 0.0)
+ }
+ if (dir.y == 0.0) {
dir.y = 0.000001;
+ }
Vector2 delta = dir.abs();
delta.x = cell_size / delta.x;
@@ -498,15 +483,17 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2 &p_from, const Vector2 &p_t
Vector2 max;
- if (dir.x < 0)
+ if (dir.x < 0) {
max.x = (Math::floor((double)pos.x) * cell_size - p_from.x) / dir.x;
- else
+ } else {
max.x = (Math::floor((double)pos.x + 1) * cell_size - p_from.x) / dir.x;
+ }
- if (dir.y < 0)
+ if (dir.y < 0) {
max.y = (Math::floor((double)pos.y) * cell_size - p_from.y) / dir.y;
- else
+ } else {
max.y = (Math::floor((double)pos.y + 1) * cell_size - p_from.y) / dir.y;
+ }
int cullcount = 0;
_cull<false, true>(pos, Rect2(), p_from, p_to, p_results, p_max_results, p_result_indices, cullcount);
@@ -515,45 +502,44 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2 &p_from, const Vector2 &p_t
bool reached_y = false;
while (true) {
-
if (max.x < max.y) {
-
max.x += delta.x;
pos.x += step.x;
} else {
-
max.y += delta.y;
pos.y += step.y;
}
if (step.x > 0) {
- if (pos.x >= end.x)
+ if (pos.x >= end.x) {
reached_x = true;
+ }
} else if (pos.x <= end.x) {
-
reached_x = true;
}
if (step.y > 0) {
- if (pos.y >= end.y)
+ if (pos.y >= end.y) {
reached_y = true;
+ }
} else if (pos.y <= end.y) {
-
reached_y = true;
}
_cull<false, true>(pos, Rect2(), p_from, p_to, p_results, p_max_results, p_result_indices, cullcount);
- if (reached_x && reached_y)
+ if (reached_x && reached_y) {
break;
+ }
}
for (Map<Element *, RC>::Element *E = large_elements.front(); E; E = E->next()) {
-
- if (cullcount >= p_max_results)
+ if (cullcount >= p_max_results) {
break;
- if (E->key()->pass == pass)
+ }
+ if (E->key()->pass == pass) {
continue;
+ }
E->key()->pass = pass;
@@ -562,8 +548,9 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2 &p_from, const Vector2 &p_t
continue;
*/
- if (!E->key()->aabb.intersects_segment(p_from, p_to))
+ if (!E->key()->aabb.intersects_segment(p_from, p_to)) {
continue;
+ }
p_results[cullcount] = E->key()->owner;
p_result_indices[cullcount] = E->key()->subindex;
@@ -574,7 +561,6 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2 &p_from, const Vector2 &p_t
}
int BroadPhase2DHashGrid::cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices) {
-
pass++;
Point2i from = (p_aabb.position / cell_size).floor();
@@ -582,24 +568,24 @@ int BroadPhase2DHashGrid::cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p
int cullcount = 0;
for (int i = from.x; i <= to.x; i++) {
-
for (int j = from.y; j <= to.y; j++) {
-
_cull<true, false>(Point2i(i, j), p_aabb, Point2(), Point2(), p_results, p_max_results, p_result_indices, cullcount);
}
}
for (Map<Element *, RC>::Element *E = large_elements.front(); E; E = E->next()) {
-
- if (cullcount >= p_max_results)
+ if (cullcount >= p_max_results) {
break;
- if (E->key()->pass == pass)
+ }
+ if (E->key()->pass == pass) {
continue;
+ }
E->key()->pass = pass;
- if (!p_aabb.intersects(E->key()->aabb))
+ if (!p_aabb.intersects(E->key()->aabb)) {
continue;
+ }
/*
if (!E->key()->aabb.intersects_segment(p_from,p_to))
@@ -614,12 +600,11 @@ int BroadPhase2DHashGrid::cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p
}
void BroadPhase2DHashGrid::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) {
-
pair_callback = p_pair_callback;
pair_userdata = p_userdata;
}
-void BroadPhase2DHashGrid::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
+void BroadPhase2DHashGrid::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_callback = p_unpair_callback;
unpair_userdata = p_userdata;
}
@@ -628,12 +613,10 @@ void BroadPhase2DHashGrid::update() {
}
BroadPhase2DSW *BroadPhase2DHashGrid::_create() {
-
return memnew(BroadPhase2DHashGrid);
}
BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
-
hash_table_size = GLOBAL_DEF("physics/2d/bp_hash_table_size", 4096);
ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/bp_hash_table_size", PropertyInfo(Variant::INT, "physics/2d/bp_hash_table_size", PROPERTY_HINT_RANGE, "0,8192,1,or_greater"));
hash_table_size = Math::larger_prime(hash_table_size);
@@ -645,15 +628,15 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512);
ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/large_object_surface_threshold_in_cells", PropertyInfo(Variant::INT, "physics/2d/large_object_surface_threshold_in_cells", PROPERTY_HINT_RANGE, "0,1024,1,or_greater"));
- for (uint32_t i = 0; i < hash_table_size; i++)
+ for (uint32_t i = 0; i < hash_table_size; i++) {
hash_table[i] = nullptr;
+ }
pass = 1;
current = 0;
}
BroadPhase2DHashGrid::~BroadPhase2DHashGrid() {
-
for (uint32_t i = 0; i < hash_table_size; i++) {
while (hash_table[i]) {
PosBin *pb = hash_table[i];
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.h b/servers/physics_2d/broad_phase_2d_hash_grid.h
index dc29d0c619..de1ada0932 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.h
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.h
@@ -35,9 +35,7 @@
#include "core/map.h"
class BroadPhase2DHashGrid : public BroadPhase2DSW {
-
struct PairData {
-
bool colliding;
int rc;
void *ud;
@@ -49,7 +47,6 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW {
};
struct Element {
-
ID self;
CollisionObject2DSW *owner;
bool _static;
@@ -60,7 +57,6 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW {
};
struct RC {
-
int ref;
_FORCE_INLINE_ int inc() {
@@ -85,7 +81,6 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW {
uint64_t pass;
struct PairKey {
-
union {
struct {
ID a;
@@ -126,7 +121,6 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW {
_FORCE_INLINE_ void _cull(const Point2i p_cell, const Rect2 &p_aabb, const Point2 &p_from, const Point2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices, int &index);
struct PosKey {
-
union {
struct {
int32_t x;
@@ -153,7 +147,6 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW {
};
struct PosBin {
-
PosKey key;
Map<Element *, RC> object_set;
Map<Element *, RC> static_object_set;
diff --git a/servers/physics_2d/broad_phase_2d_sw.h b/servers/physics_2d/broad_phase_2d_sw.h
index 5e42c72d83..e4444cd180 100644
--- a/servers/physics_2d/broad_phase_2d_sw.h
+++ b/servers/physics_2d/broad_phase_2d_sw.h
@@ -37,7 +37,6 @@
class CollisionObject2DSW;
class BroadPhase2DSW {
-
public:
typedef BroadPhase2DSW *(*CreateFunction)();
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp
index 0ec293c042..6931d96fe4 100644
--- a/servers/physics_2d/collision_object_2d_sw.cpp
+++ b/servers/physics_2d/collision_object_2d_sw.cpp
@@ -33,7 +33,6 @@
#include "space_2d_sw.h"
void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform, bool p_disabled) {
-
Shape s;
s.shape = p_shape;
s.xform = p_transform;
@@ -53,7 +52,6 @@ void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_tra
}
void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
-
ERR_FAIL_INDEX(p_index, shapes.size());
shapes[p_index].shape->remove_owner(this);
shapes.write[p_index].shape = p_shape;
@@ -68,13 +66,11 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) {
}
void CollisionObject2DSW::set_shape_metadata(int p_index, const Variant &p_metadata) {
-
ERR_FAIL_INDEX(p_index, shapes.size());
shapes.write[p_index].metadata = p_metadata;
}
void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_transform) {
-
ERR_FAIL_INDEX(p_index, shapes.size());
shapes.write[p_index].xform = p_transform;
@@ -91,13 +87,15 @@ void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
ERR_FAIL_INDEX(p_idx, shapes.size());
CollisionObject2DSW::Shape &shape = shapes.write[p_idx];
- if (shape.disabled == p_disabled)
+ if (shape.disabled == p_disabled) {
return;
+ }
shape.disabled = p_disabled;
- if (!space)
+ if (!space) {
return;
+ }
if (p_disabled && shape.bpid != 0) {
space->get_broadphase()->remove(shape.bpid);
@@ -115,10 +113,8 @@ void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) {
}
void CollisionObject2DSW::remove_shape(Shape2DSW *p_shape) {
-
//remove a shape, all the times it appears
for (int i = 0; i < shapes.size(); i++) {
-
if (shapes[i].shape == p_shape) {
remove_shape(i);
i--;
@@ -127,13 +123,12 @@ void CollisionObject2DSW::remove_shape(Shape2DSW *p_shape) {
}
void CollisionObject2DSW::remove_shape(int p_index) {
-
//remove anything from shape to be erased to end, so subindices don't change
ERR_FAIL_INDEX(p_index, shapes.size());
for (int i = p_index; i < shapes.size(); i++) {
-
- if (shapes[i].bpid == 0)
+ if (shapes[i].bpid == 0) {
continue;
+ }
//should never get here with a null owner
space->get_broadphase()->remove(shapes[i].bpid);
shapes.write[i].bpid = 0;
@@ -149,12 +144,14 @@ void CollisionObject2DSW::remove_shape(int p_index) {
}
void CollisionObject2DSW::_set_static(bool p_static) {
- if (_static == p_static)
+ if (_static == p_static) {
return;
+ }
_static = p_static;
- if (!space)
+ if (!space) {
return;
+ }
for (int i = 0; i < get_shape_count(); i++) {
const Shape &s = shapes[i];
if (s.bpid > 0) {
@@ -164,9 +161,7 @@ void CollisionObject2DSW::_set_static(bool p_static) {
}
void CollisionObject2DSW::_unregister_shapes() {
-
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
if (s.bpid > 0) {
space->get_broadphase()->remove(s.bpid);
@@ -176,16 +171,16 @@ void CollisionObject2DSW::_unregister_shapes() {
}
void CollisionObject2DSW::_update_shapes() {
-
- if (!space)
+ if (!space) {
return;
+ }
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
- if (s.disabled)
+ if (s.disabled) {
continue;
+ }
if (s.bpid == 0) {
s.bpid = space->get_broadphase()->create(this, i);
@@ -204,15 +199,15 @@ void CollisionObject2DSW::_update_shapes() {
}
void CollisionObject2DSW::_update_shapes_with_motion(const Vector2 &p_motion) {
-
- if (!space)
+ if (!space) {
return;
+ }
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
- if (s.disabled)
+ if (s.disabled) {
continue;
+ }
if (s.bpid == 0) {
s.bpid = space->get_broadphase()->create(this, i);
@@ -231,13 +226,10 @@ void CollisionObject2DSW::_update_shapes_with_motion(const Vector2 &p_motion) {
}
void CollisionObject2DSW::_set_space(Space2DSW *p_space) {
-
if (space) {
-
space->remove_object(this);
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
if (s.bpid) {
space->get_broadphase()->remove(s.bpid);
@@ -249,21 +241,18 @@ void CollisionObject2DSW::_set_space(Space2DSW *p_space) {
space = p_space;
if (space) {
-
space->add_object(this);
_update_shapes();
}
}
void CollisionObject2DSW::_shape_changed() {
-
_update_shapes();
_shapes_changed();
}
CollisionObject2DSW::CollisionObject2DSW(Type p_type) :
pending_shape_update_list(this) {
-
_static = true;
type = p_type;
space = nullptr;
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index 98105a7c0e..84a2baaa74 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -53,7 +53,6 @@ private:
bool pickable;
struct Shape {
-
Transform2D xform;
Transform2D xform_inv;
BroadPhase2DSW::ID bpid;
@@ -186,7 +185,6 @@ public:
_FORCE_INLINE_ bool is_pickable() const { return pickable; }
_FORCE_INLINE_ bool test_collision_mask(CollisionObject2DSW *p_other) const {
-
return collision_layer & p_other->collision_mask || p_other->collision_layer & collision_mask;
}
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index a954cb3de3..d993754fee 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -30,10 +30,9 @@
#include "collision_solver_2d_sat.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
struct _CollectorCallback2D {
-
CollisionSolver2DSW::CallbackResult callback;
void *userdata;
bool swap;
@@ -42,22 +41,21 @@ struct _CollectorCallback2D {
Vector2 *sep_axis;
_FORCE_INLINE_ void call(const Vector2 &p_point_A, const Vector2 &p_point_B) {
-
/*
if (normal.dot(p_point_A) >= normal.dot(p_point_B))
return;
*/
- if (swap)
+ if (swap) {
callback(p_point_B, p_point_A, userdata);
- else
+ } else {
callback(p_point_A, p_point_B, userdata);
+ }
}
};
typedef void (*GenerateContactsFunc)(const Vector2 *, int, const Vector2 *, int, _CollectorCallback2D *);
_FORCE_INLINE_ static void _generate_contacts_point_point(const Vector2 *p_points_A, int p_point_count_A, const Vector2 *p_points_B, int p_point_count_B, _CollectorCallback2D *p_collector) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 1);
ERR_FAIL_COND(p_point_count_B != 1);
@@ -67,13 +65,12 @@ _FORCE_INLINE_ static void _generate_contacts_point_point(const Vector2 *p_point
}
_FORCE_INLINE_ static void _generate_contacts_point_edge(const Vector2 *p_points_A, int p_point_count_A, const Vector2 *p_points_B, int p_point_count_B, _CollectorCallback2D *p_collector) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 1);
ERR_FAIL_COND(p_point_count_B != 2);
#endif
- Vector2 closest_B = Geometry::get_closest_point_to_segment_uncapped_2d(*p_points_A, p_points_B);
+ Vector2 closest_B = Geometry2D::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B);
p_collector->call(*p_points_A, closest_B);
}
@@ -85,7 +82,6 @@ struct _generate_contacts_Pair {
};
_FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 *p_points_A, int p_point_count_A, const Vector2 *p_points_B, int p_point_count_B, _CollectorCallback2D *p_collector) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 2);
ERR_FAIL_COND(p_point_count_B != 2); // circle is actually a 4x3 matrix
@@ -115,25 +111,25 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 *p_points_
sa.sort(dvec, 4);
for (int i = 1; i <= 2; i++) {
-
if (dvec[i].a) {
Vector2 a = p_points_A[dvec[i].idx];
Vector2 b = n.plane_project(dB, a);
- if (n.dot(a) > n.dot(b) - CMP_EPSILON)
+ if (n.dot(a) > n.dot(b) - CMP_EPSILON) {
continue;
+ }
p_collector->call(a, b);
} else {
Vector2 b = p_points_B[dvec[i].idx];
Vector2 a = n.plane_project(dA, b);
- if (n.dot(a) > n.dot(b) - CMP_EPSILON)
+ if (n.dot(a) > n.dot(b) - CMP_EPSILON) {
continue;
+ }
p_collector->call(a, b);
}
}
}
static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_point_count_A, const Vector2 *p_points_B, int p_point_count_B, _CollectorCallback2D *p_collector) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A < 1);
ERR_FAIL_COND(p_point_count_B < 1);
@@ -165,7 +161,6 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po
points_A = p_points_B;
points_B = p_points_A;
} else {
-
pointcount_B = p_point_count_B;
pointcount_A = p_point_count_A;
points_A = p_points_A;
@@ -182,7 +177,6 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po
template <class ShapeA, class ShapeB, bool castA = false, bool castB = false, bool withMargin = false>
class SeparatorAxisTest2D {
-
const ShapeA *shape_A;
const ShapeB *shape_B;
const Transform2D *transform_A;
@@ -199,7 +193,6 @@ class SeparatorAxisTest2D {
public:
_FORCE_INLINE_ bool test_previous_axis() {
-
if (callback && callback->sep_axis && *callback->sep_axis != Vector2()) {
return test_axis(*callback->sep_axis);
} else {
@@ -211,30 +204,30 @@ public:
}
_FORCE_INLINE_ bool test_cast() {
-
if (castA) {
-
Vector2 na = motion_A.normalized();
- if (!test_axis(na))
+ if (!test_axis(na)) {
return false;
- if (!test_axis(na.tangent()))
+ }
+ if (!test_axis(na.tangent())) {
return false;
+ }
}
if (castB) {
-
Vector2 nb = motion_B.normalized();
- if (!test_axis(nb))
+ if (!test_axis(nb)) {
return false;
- if (!test_axis(nb.tangent()))
+ }
+ if (!test_axis(nb.tangent())) {
return false;
+ }
}
return true;
}
_FORCE_INLINE_ bool test_axis(const Vector2 &p_axis) {
-
Vector2 axis = p_axis;
if (Math::is_zero_approx(axis.x) &&
@@ -245,15 +238,17 @@ public:
real_t min_A, max_A, min_B, max_B;
- if (castA)
+ if (castA) {
shape_A->project_range_cast(motion_A, axis, *transform_A, min_A, max_A);
- else
+ } else {
shape_A->project_range(axis, *transform_A, min_A, max_A);
+ }
- if (castB)
+ if (castB) {
shape_B->project_range_cast(motion_B, axis, *transform_B, min_B, max_B);
- else
+ } else {
shape_B->project_range(axis, *transform_B, min_B, max_B);
+ }
if (withMargin) {
min_A -= margin_A;
@@ -269,8 +264,9 @@ public:
real_t dmax = max_B - (min_A + max_A) * 0.5;
if (dmin > 0.0 || dmax < 0.0) {
- if (callback && callback->sep_axis)
+ if (callback && callback->sep_axis) {
*callback->sep_axis = axis;
+ }
#ifdef DEBUG_ENABLED
best_axis_count++;
#endif
@@ -308,16 +304,17 @@ public:
}
_FORCE_INLINE_ void generate_contacts() {
-
// nothing to do, don't generate
- if (best_axis == Vector2(0.0, 0.0))
+ if (best_axis == Vector2(0.0, 0.0)) {
return;
+ }
if (callback) {
callback->collided = true;
- if (!callback->callback)
+ if (!callback->callback) {
return; //only collide, no callback
+ }
}
static const int max_supports = 2;
@@ -333,7 +330,6 @@ public:
}
if (withMargin) {
-
for (int i = 0; i < support_count_A; i++) {
supports_A[i] += -best_axis * margin_A;
}
@@ -351,7 +347,6 @@ public:
}
if (withMargin) {
-
for (int i = 0; i < support_count_B; i++) {
supports_B[i] += best_axis * margin_B;
}
@@ -360,13 +355,13 @@ public:
callback->normal = best_axis;
_generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback);
- if (callback->sep_axis && *callback->sep_axis != Vector2())
+ if (callback->sep_axis && *callback->sep_axis != Vector2()) {
*callback->sep_axis = Vector2(); //invalidate previous axis (no test)
+ }
}
}
_FORCE_INLINE_ SeparatorAxisTest2D(const ShapeA *p_shape_A, const Transform2D &p_transform_a, const ShapeB *p_shape_B, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_A = Vector2(), const Vector2 &p_motion_B = Vector2(), real_t p_margin_A = 0, real_t p_margin_B = 0) {
-
margin_A = p_margin_A;
margin_B = p_margin_B;
best_depth = 1e15;
@@ -397,35 +392,42 @@ typedef void (*CollisionFunc)(const Shape2DSW *, const Transform2D &, const Shap
template <bool castA, bool castB, bool withMargin>
static void _collision_segment_segment(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW *>(p_a);
const SegmentShape2DSW *segment_B = static_cast<const SegmentShape2DSW *>(p_b);
SeparatorAxisTest2D<SegmentShape2DSW, SegmentShape2DSW, castA, castB, withMargin> separator(segment_A, p_transform_a, segment_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
//this collision is kind of pointless
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
- if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a)))
+ if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a))) {
return;
- if (!separator.test_axis(segment_B->get_xformed_normal(p_transform_b)))
+ }
+ if (!separator.test_axis(segment_B->get_xformed_normal(p_transform_b))) {
return;
+ }
if (withMargin) {
//points grow to circles
- if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.xform(segment_B->get_a())))
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.xform(segment_B->get_a()))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.xform(segment_B->get_b())))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.xform(segment_B->get_b()))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.xform(segment_B->get_a())))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.xform(segment_B->get_a()))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.xform(segment_B->get_b())))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.xform(segment_B->get_b()))) {
return;
+ }
}
separator.generate_contacts();
@@ -433,90 +435,102 @@ static void _collision_segment_segment(const Shape2DSW *p_a, const Transform2D &
template <bool castA, bool castB, bool withMargin>
static void _collision_segment_circle(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW *>(p_a);
const CircleShape2DSW *circle_B = static_cast<const CircleShape2DSW *>(p_b);
SeparatorAxisTest2D<SegmentShape2DSW, CircleShape2DSW, castA, castB, withMargin> separator(segment_A, p_transform_a, circle_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//segment normal
if (!separator.test_axis(
- (p_transform_a.xform(segment_A->get_b()) - p_transform_a.xform(segment_A->get_a())).normalized().tangent()))
+ (p_transform_a.xform(segment_A->get_b()) - p_transform_a.xform(segment_A->get_a())).normalized().tangent())) {
return;
+ }
//endpoint a vs circle
- if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.get_origin()))
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.get_origin())) {
return;
+ }
//endpoint b vs circle
- if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.get_origin()))
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.get_origin())) {
return;
+ }
separator.generate_contacts();
}
template <bool castA, bool castB, bool withMargin>
static void _collision_segment_rectangle(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW *>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW *>(p_b);
SeparatorAxisTest2D<SegmentShape2DSW, RectangleShape2DSW, castA, castB, withMargin> separator(segment_A, p_transform_a, rectangle_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
- if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a)))
+ if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a))) {
return;
+ }
- if (!separator.test_axis(p_transform_b.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
return;
+ }
- if (!separator.test_axis(p_transform_b.elements[1].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[1].normalized())) {
return;
+ }
if (withMargin) {
-
Transform2D inv = p_transform_b.affine_inverse();
Vector2 a = p_transform_a.xform(segment_A->get_a());
Vector2 b = p_transform_a.xform(segment_A->get_b());
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a))) {
return;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b)))
+ }
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b))) {
return;
+ }
if (castA) {
-
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a + p_motion_a)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a + p_motion_a))) {
return;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b + p_motion_a)))
+ }
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b + p_motion_a))) {
return;
+ }
}
if (castB) {
-
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a - p_motion_b)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a - p_motion_b))) {
return;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b - p_motion_b)))
+ }
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b - p_motion_b))) {
return;
+ }
}
if (castA && castB) {
-
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a - p_motion_b + p_motion_a)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, a - p_motion_b + p_motion_a))) {
return;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b - p_motion_b + p_motion_a)))
+ }
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, inv, b - p_motion_b + p_motion_a))) {
return;
+ }
}
}
@@ -525,64 +539,74 @@ static void _collision_segment_rectangle(const Shape2DSW *p_a, const Transform2D
template <bool castA, bool castB, bool withMargin>
static void _collision_segment_capsule(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW *>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW *>(p_b);
SeparatorAxisTest2D<SegmentShape2DSW, CapsuleShape2DSW, castA, castB, withMargin> separator(segment_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
- if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a)))
+ if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a))) {
return;
+ }
- if (!separator.test_axis(p_transform_b.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
return;
+ }
- if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * 0.5)))
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * 0.5))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * -0.5)))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * -0.5))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * 0.5)))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * 0.5))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * -0.5)))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * -0.5))) {
return;
+ }
separator.generate_contacts();
}
template <bool castA, bool castB, bool withMargin>
static void _collision_segment_convex_polygon(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW *>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW *>(p_b);
SeparatorAxisTest2D<SegmentShape2DSW, ConvexPolygonShape2DSW, castA, castB, withMargin> separator(segment_A, p_transform_a, convex_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
- if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a)))
+ if (!separator.test_axis(segment_A->get_xformed_normal(p_transform_a))) {
return;
+ }
for (int i = 0; i < convex_B->get_point_count(); i++) {
-
- if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i)))
+ if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i))) {
return;
+ }
if (withMargin) {
-
- if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.xform(convex_B->get_point(i))))
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), p_transform_b.xform(convex_B->get_point(i)))) {
return;
- if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.xform(convex_B->get_point(i))))
+ }
+ if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), p_transform_b.xform(convex_B->get_point(i)))) {
return;
+ }
}
}
@@ -593,74 +617,79 @@ static void _collision_segment_convex_polygon(const Shape2DSW *p_a, const Transf
template <bool castA, bool castB, bool withMargin>
static void _collision_circle_circle(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW *>(p_a);
const CircleShape2DSW *circle_B = static_cast<const CircleShape2DSW *>(p_b);
SeparatorAxisTest2D<CircleShape2DSW, CircleShape2DSW, castA, castB, withMargin> separator(circle_A, p_transform_a, circle_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
- if (TEST_POINT(p_transform_a.get_origin(), p_transform_b.get_origin()))
+ if (TEST_POINT(p_transform_a.get_origin(), p_transform_b.get_origin())) {
return;
+ }
separator.generate_contacts();
}
template <bool castA, bool castB, bool withMargin>
static void _collision_circle_rectangle(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW *>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW *>(p_b);
SeparatorAxisTest2D<CircleShape2DSW, RectangleShape2DSW, castA, castB, withMargin> separator(circle_A, p_transform_a, rectangle_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
const Vector2 &sphere = p_transform_a.elements[2];
const Vector2 *axis = &p_transform_b.elements[0];
//const Vector2& half_extents = rectangle_B->get_half_extents();
- if (!separator.test_axis(axis[0].normalized()))
+ if (!separator.test_axis(axis[0].normalized())) {
return;
+ }
- if (!separator.test_axis(axis[1].normalized()))
+ if (!separator.test_axis(axis[1].normalized())) {
return;
+ }
Transform2D binv = p_transform_b.affine_inverse();
{
-
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphere)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphere))) {
return;
+ }
}
if (castA) {
-
Vector2 sphereofs = sphere + p_motion_a;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphereofs)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphereofs))) {
return;
+ }
}
if (castB) {
-
Vector2 sphereofs = sphere - p_motion_b;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphereofs)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphereofs))) {
return;
+ }
}
if (castA && castB) {
-
Vector2 sphereofs = sphere - p_motion_b + p_motion_a;
- if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphereofs)))
+ if (!separator.test_axis(rectangle_B->get_circle_axis(p_transform_b, binv, sphereofs))) {
return;
+ }
}
separator.generate_contacts();
@@ -668,53 +697,59 @@ static void _collision_circle_rectangle(const Shape2DSW *p_a, const Transform2D
template <bool castA, bool castB, bool withMargin>
static void _collision_circle_capsule(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW *>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW *>(p_b);
SeparatorAxisTest2D<CircleShape2DSW, CapsuleShape2DSW, castA, castB, withMargin> separator(circle_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//capsule axis
- if (!separator.test_axis(p_transform_b.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
return;
+ }
//capsule endpoints
- if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * 0.5)))
+ if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * 0.5))) {
return;
- if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * -0.5)))
+ }
+ if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * -0.5))) {
return;
+ }
separator.generate_contacts();
}
template <bool castA, bool castB, bool withMargin>
static void _collision_circle_convex_polygon(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW *>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW *>(p_b);
SeparatorAxisTest2D<CircleShape2DSW, ConvexPolygonShape2DSW, castA, castB, withMargin> separator(circle_A, p_transform_a, convex_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//poly faces and poly points vs circle
for (int i = 0; i < convex_B->get_point_count(); i++) {
-
- if (TEST_POINT(p_transform_a.get_origin(), p_transform_b.xform(convex_B->get_point(i))))
+ if (TEST_POINT(p_transform_a.get_origin(), p_transform_b.xform(convex_B->get_point(i)))) {
return;
+ }
- if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i)))
+ if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i))) {
return;
+ }
}
separator.generate_contacts();
@@ -724,42 +759,46 @@ static void _collision_circle_convex_polygon(const Shape2DSW *p_a, const Transfo
template <bool castA, bool castB, bool withMargin>
static void _collision_rectangle_rectangle(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW *>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW *>(p_b);
SeparatorAxisTest2D<RectangleShape2DSW, RectangleShape2DSW, castA, castB, withMargin> separator(rectangle_A, p_transform_a, rectangle_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//box faces A
- if (!separator.test_axis(p_transform_a.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
return;
+ }
- if (!separator.test_axis(p_transform_a.elements[1].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[1].normalized())) {
return;
+ }
//box faces B
- if (!separator.test_axis(p_transform_b.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
return;
+ }
- if (!separator.test_axis(p_transform_b.elements[1].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[1].normalized())) {
return;
+ }
if (withMargin) {
-
Transform2D invA = p_transform_a.affine_inverse();
Transform2D invB = p_transform_b.affine_inverse();
- if (!separator.test_axis(rectangle_A->get_box_axis(p_transform_a, invA, rectangle_B, p_transform_b, invB)))
+ if (!separator.test_axis(rectangle_A->get_box_axis(p_transform_a, invA, rectangle_B, p_transform_b, invB))) {
return;
+ }
if (castA || castB) {
-
Transform2D aofs = p_transform_a;
aofs.elements[2] += p_motion_a;
@@ -770,21 +809,21 @@ static void _collision_rectangle_rectangle(const Shape2DSW *p_a, const Transform
Transform2D bofsinv = bofs.affine_inverse();
if (castA) {
-
- if (!separator.test_axis(rectangle_A->get_box_axis(aofs, aofsinv, rectangle_B, p_transform_b, invB)))
+ if (!separator.test_axis(rectangle_A->get_box_axis(aofs, aofsinv, rectangle_B, p_transform_b, invB))) {
return;
+ }
}
if (castB) {
-
- if (!separator.test_axis(rectangle_A->get_box_axis(p_transform_a, invA, rectangle_B, bofs, bofsinv)))
+ if (!separator.test_axis(rectangle_A->get_box_axis(p_transform_a, invA, rectangle_B, bofs, bofsinv))) {
return;
+ }
}
if (castA && castB) {
-
- if (!separator.test_axis(rectangle_A->get_box_axis(aofs, aofsinv, rectangle_B, bofs, bofsinv)))
+ if (!separator.test_axis(rectangle_A->get_box_axis(aofs, aofsinv, rectangle_B, bofs, bofsinv))) {
return;
+ }
}
}
}
@@ -794,56 +833,62 @@ static void _collision_rectangle_rectangle(const Shape2DSW *p_a, const Transform
template <bool castA, bool castB, bool withMargin>
static void _collision_rectangle_capsule(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW *>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW *>(p_b);
SeparatorAxisTest2D<RectangleShape2DSW, CapsuleShape2DSW, castA, castB, withMargin> separator(rectangle_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//box faces
- if (!separator.test_axis(p_transform_a.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
return;
+ }
- if (!separator.test_axis(p_transform_a.elements[1].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[1].normalized())) {
return;
+ }
//capsule axis
- if (!separator.test_axis(p_transform_b.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
return;
+ }
//box endpoints to capsule circles
Transform2D boxinv = p_transform_a.affine_inverse();
for (int i = 0; i < 2; i++) {
-
{
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * (i == 0 ? 0.5 : -0.5);
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
return;
+ }
}
if (castA) {
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * (i == 0 ? 0.5 : -0.5);
capsule_endpoint -= p_motion_a;
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
return;
+ }
}
if (castB) {
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * (i == 0 ? 0.5 : -0.5);
capsule_endpoint += p_motion_b;
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
return;
+ }
}
if (castA && castB) {
@@ -851,8 +896,9 @@ static void _collision_rectangle_capsule(const Shape2DSW *p_a, const Transform2D
capsule_endpoint -= p_motion_a;
capsule_endpoint += p_motion_b;
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
return;
+ }
}
}
@@ -861,24 +907,27 @@ static void _collision_rectangle_capsule(const Shape2DSW *p_a, const Transform2D
template <bool castA, bool castB, bool withMargin>
static void _collision_rectangle_convex_polygon(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW *>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW *>(p_b);
SeparatorAxisTest2D<RectangleShape2DSW, ConvexPolygonShape2DSW, castA, castB, withMargin> separator(rectangle_A, p_transform_a, convex_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//box faces
- if (!separator.test_axis(p_transform_a.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
return;
+ }
- if (!separator.test_axis(p_transform_a.elements[1].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[1].normalized())) {
return;
+ }
//convex faces
Transform2D boxinv;
@@ -886,28 +935,29 @@ static void _collision_rectangle_convex_polygon(const Shape2DSW *p_a, const Tran
boxinv = p_transform_a.affine_inverse();
}
for (int i = 0; i < convex_B->get_point_count(); i++) {
-
- if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i)))
+ if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i))) {
return;
+ }
if (withMargin) {
//all points vs all points need to be tested if margin exist
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)))))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i))))) {
return;
+ }
if (castA) {
-
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)) - p_motion_a)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)) - p_motion_a))) {
return;
+ }
}
if (castB) {
-
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)) + p_motion_b)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)) + p_motion_b))) {
return;
+ }
}
if (castA && castB) {
-
- if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)) + p_motion_b - p_motion_a)))
+ if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, p_transform_b.xform(convex_B->get_point(i)) + p_motion_b - p_motion_a))) {
return;
+ }
}
}
}
@@ -919,38 +969,40 @@ static void _collision_rectangle_convex_polygon(const Shape2DSW *p_a, const Tran
template <bool castA, bool castB, bool withMargin>
static void _collision_capsule_capsule(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const CapsuleShape2DSW *capsule_A = static_cast<const CapsuleShape2DSW *>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW *>(p_b);
SeparatorAxisTest2D<CapsuleShape2DSW, CapsuleShape2DSW, castA, castB, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//capsule axis
- if (!separator.test_axis(p_transform_b.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
return;
+ }
- if (!separator.test_axis(p_transform_a.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
return;
+ }
//capsule endpoints
for (int i = 0; i < 2; i++) {
-
Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.elements[1] * capsule_A->get_height() * (i == 0 ? 0.5 : -0.5);
for (int j = 0; j < 2; j++) {
-
Vector2 capsule_endpoint_B = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_B->get_height() * (j == 0 ? 0.5 : -0.5);
- if (TEST_POINT(capsule_endpoint_A, capsule_endpoint_B))
+ if (TEST_POINT(capsule_endpoint_A, capsule_endpoint_B)) {
return;
+ }
}
}
@@ -959,38 +1011,40 @@ static void _collision_capsule_capsule(const Shape2DSW *p_a, const Transform2D &
template <bool castA, bool castB, bool withMargin>
static void _collision_capsule_convex_polygon(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const CapsuleShape2DSW *capsule_A = static_cast<const CapsuleShape2DSW *>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW *>(p_b);
SeparatorAxisTest2D<CapsuleShape2DSW, ConvexPolygonShape2DSW, castA, castB, withMargin> separator(capsule_A, p_transform_a, convex_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
//capsule axis
- if (!separator.test_axis(p_transform_a.elements[0].normalized()))
+ if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
return;
+ }
//poly vs capsule
for (int i = 0; i < convex_B->get_point_count(); i++) {
-
Vector2 cpoint = p_transform_b.xform(convex_B->get_point(i));
for (int j = 0; j < 2; j++) {
-
Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.elements[1] * capsule_A->get_height() * (j == 0 ? 0.5 : -0.5);
- if (TEST_POINT(capsule_endpoint_A, cpoint))
+ if (TEST_POINT(capsule_endpoint_A, cpoint)) {
return;
+ }
}
- if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i)))
+ if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i))) {
return;
+ }
}
separator.generate_contacts();
@@ -1000,37 +1054,37 @@ static void _collision_capsule_convex_polygon(const Shape2DSW *p_a, const Transf
template <bool castA, bool castB, bool withMargin>
static void _collision_convex_polygon_convex_polygon(const Shape2DSW *p_a, const Transform2D &p_transform_a, const Shape2DSW *p_b, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_a, const Vector2 &p_motion_b, real_t p_margin_A, real_t p_margin_B) {
-
const ConvexPolygonShape2DSW *convex_A = static_cast<const ConvexPolygonShape2DSW *>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW *>(p_b);
SeparatorAxisTest2D<ConvexPolygonShape2DSW, ConvexPolygonShape2DSW, castA, castB, withMargin> separator(convex_A, p_transform_a, convex_B, p_transform_b, p_collector, p_motion_a, p_motion_b, p_margin_A, p_margin_B);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_cast())
+ if (!separator.test_cast()) {
return;
+ }
for (int i = 0; i < convex_A->get_point_count(); i++) {
-
- if (!separator.test_axis(convex_A->get_xformed_segment_normal(p_transform_a, i)))
+ if (!separator.test_axis(convex_A->get_xformed_segment_normal(p_transform_a, i))) {
return;
+ }
}
for (int i = 0; i < convex_B->get_point_count(); i++) {
-
- if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i)))
+ if (!separator.test_axis(convex_B->get_xformed_segment_normal(p_transform_b, i))) {
return;
+ }
}
if (withMargin) {
-
for (int i = 0; i < convex_A->get_point_count(); i++) {
for (int j = 0; j < convex_B->get_point_count(); j++) {
-
- if (TEST_POINT(p_transform_a.xform(convex_A->get_point(i)), p_transform_b.xform(convex_B->get_point(j))))
+ if (TEST_POINT(p_transform_a.xform(convex_A->get_point(i)), p_transform_b.xform(convex_B->get_point(j)))) {
return;
+ }
}
}
}
@@ -1041,7 +1095,6 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW *p_a, const
////////
bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
-
PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_LINE, false);
@@ -1323,7 +1376,6 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D
collision_func = collision_table_castA_castB_margin[type_A - 2][type_B - 2];
}
} else {
-
if (*motion_A == Vector2() && *motion_B == Vector2()) {
collision_func = collision_table[type_A - 2][type_B - 2];
} else if (*motion_A != Vector2() && *motion_B == Vector2()) {
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index f117dcbfe5..beba709807 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -35,10 +35,10 @@
//#define collision_solver gjk_epa_calculate_penetration
bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
-
const LineShape2DSW *line = static_cast<const LineShape2DSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_LINE)
+ if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_LINE) {
return false;
+ }
Vector2 n = p_transform_A.basis_xform(line->get_normal()).normalized();
Vector2 p = p_transform_A.xform(line->get_normal() * line->get_d());
@@ -52,20 +52,21 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Tr
bool found = false;
for (int i = 0; i < support_count; i++) {
-
supports[i] = p_transform_B.xform(supports[i]);
real_t pd = n.dot(supports[i]);
- if (pd >= d)
+ if (pd >= d) {
continue;
+ }
found = true;
Vector2 support_A = supports[i] - n * (pd - d);
if (p_result_callback) {
- if (p_swap_result)
+ if (p_swap_result) {
p_result_callback(supports[i], support_A, p_userdata);
- else
+ } else {
p_result_callback(support_A, supports[i], p_userdata);
+ }
}
}
@@ -73,10 +74,10 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Tr
}
bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis) {
-
const RayShape2DSW *ray = static_cast<const RayShape2DSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_RAY)
+ if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_RAY) {
return false;
+ }
Vector2 from = p_transform_A.get_origin();
Vector2 to = from + p_transform_A[1] * ray->get_length();
@@ -93,9 +94,9 @@ bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector
Vector2 p, n;
if (!p_shape_B->intersect_segment(from, to, p, n)) {
-
- if (sep_axis)
+ if (sep_axis) {
*sep_axis = p_transform_A[1].normalized();
+ }
return false;
}
@@ -106,16 +107,16 @@ bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector
}
if (p_result_callback) {
- if (p_swap_result)
+ if (p_swap_result) {
p_result_callback(support_B, support_A, p_userdata);
- else
+ } else {
p_result_callback(support_A, support_B, p_userdata);
+ }
}
return true;
}
struct _ConcaveCollisionInfo2D {
-
const Transform2D *transform_A;
const Shape2DSW *shape_A;
const Transform2D *transform_B;
@@ -133,22 +134,22 @@ struct _ConcaveCollisionInfo2D {
};
void CollisionSolver2DSW::concave_callback(void *p_userdata, Shape2DSW *p_convex) {
-
_ConcaveCollisionInfo2D &cinfo = *(_ConcaveCollisionInfo2D *)(p_userdata);
cinfo.aabb_tests++;
- if (!cinfo.result_callback && cinfo.collided)
+ if (!cinfo.result_callback && cinfo.collided) {
return; //already collided and no contacts requested, don't test anymore
+ }
bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, cinfo.motion_A, p_convex, *cinfo.transform_B, cinfo.motion_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, cinfo.sep_axis, cinfo.margin_A, cinfo.margin_B);
- if (!collided)
+ if (!collided) {
return;
+ }
cinfo.collided = true;
cinfo.collisions++;
}
bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
-
const ConcaveShape2DSW *concave_B = static_cast<const ConcaveShape2DSW *>(p_shape_B);
_ConcaveCollisionInfo2D cinfo;
@@ -174,7 +175,6 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A, const Transf
Rect2 local_aabb;
for (int i = 0; i < 2; i++) {
-
Vector2 axis(p_transform_B.elements[i]);
real_t axis_scale = 1.0 / axis.length();
axis *= axis_scale;
@@ -194,7 +194,6 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A, const Transf
}
bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
-
PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
bool concave_A = p_shape_A->is_concave();
@@ -211,7 +210,6 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
}
if (type_A == PhysicsServer2D::SHAPE_LINE) {
-
if (type_B == PhysicsServer2D::SHAPE_LINE || type_B == PhysicsServer2D::SHAPE_RAY) {
return false;
}
@@ -223,9 +221,7 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
}
} else if (type_A == PhysicsServer2D::SHAPE_RAY) {
-
if (type_B == PhysicsServer2D::SHAPE_RAY) {
-
return false; //no ray-ray
}
@@ -236,17 +232,17 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
}
} else if (concave_B) {
-
- if (concave_A)
+ if (concave_A) {
return false;
+ }
- if (!swap)
+ if (!swap) {
return solve_concave(p_shape_A, p_transform_A, p_motion_A, p_shape_B, p_transform_B, p_motion_B, p_result_callback, p_userdata, false, sep_axis, margin_A, margin_B);
- else
+ } else {
return solve_concave(p_shape_B, p_transform_B, p_motion_B, p_shape_A, p_transform_A, p_motion_A, p_result_callback, p_userdata, true, sep_axis, margin_A, margin_B);
+ }
} else {
-
return collision_solver(p_shape_A, p_transform_A, p_motion_A, p_shape_B, p_transform_B, p_motion_B, p_result_callback, p_userdata, false, sep_axis, margin_A, margin_B);
}
}
diff --git a/servers/physics_2d/constraint_2d_sw.h b/servers/physics_2d/constraint_2d_sw.h
index f8eb16214f..d8751f588e 100644
--- a/servers/physics_2d/constraint_2d_sw.h
+++ b/servers/physics_2d/constraint_2d_sw.h
@@ -34,7 +34,6 @@
#include "body_2d_sw.h"
class Constraint2DSW {
-
Body2DSW **_body_ptr;
int _body_count;
uint64_t island_step;
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 4524629d50..81e961e90d 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -56,7 +56,6 @@
*/
static inline real_t k_scalar(Body2DSW *a, Body2DSW *b, const Vector2 &rA, const Vector2 &rB, const Vector2 &n) {
-
real_t value = 0;
{
@@ -66,7 +65,6 @@ static inline real_t k_scalar(Body2DSW *a, Body2DSW *b, const Vector2 &rA, const
}
if (b) {
-
value += b->get_inv_mass();
real_t rcn = rB.cross(n);
value += b->get_inv_inertia() * rcn * rcn;
@@ -78,10 +76,11 @@ static inline real_t k_scalar(Body2DSW *a, Body2DSW *b, const Vector2 &rA, const
static inline Vector2
relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB) {
Vector2 sum = a->get_linear_velocity() - rA.tangent() * a->get_angular_velocity();
- if (b)
+ if (b) {
return (b->get_linear_velocity() - rB.tangent() * b->get_angular_velocity()) - sum;
- else
+ } else {
return -sum;
+ }
}
static inline real_t
@@ -90,7 +89,6 @@ normal_relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB, Vecto
}
bool PinJoint2DSW::setup(real_t p_step) {
-
Space2DSW *space = A->get_space();
ERR_FAIL_COND_V(!space, false);
rA = A->get_transform().basis_xform(anchor_A);
@@ -115,7 +113,6 @@ bool PinJoint2DSW::setup(real_t p_step) {
K[1] = K1[1] + K2[1];
if (B) {
-
Transform2D K3;
K3[0].x = B->get_inv_inertia() * rB.y * rB.y;
K3[1].x = -B->get_inv_inertia() * rB.x * rB.y;
@@ -140,53 +137,53 @@ bool PinJoint2DSW::setup(real_t p_step) {
// apply accumulated impulse
A->apply_impulse(rA, -P);
- if (B)
+ if (B) {
B->apply_impulse(rB, P);
+ }
return true;
}
inline Vector2 custom_cross(const Vector2 &p_vec, real_t p_other) {
-
return Vector2(p_other * p_vec.y, -p_other * p_vec.x);
}
void PinJoint2DSW::solve(real_t p_step) {
-
// compute relative velocity
Vector2 vA = A->get_linear_velocity() - custom_cross(rA, A->get_angular_velocity());
Vector2 rel_vel;
- if (B)
+ if (B) {
rel_vel = B->get_linear_velocity() - custom_cross(rB, B->get_angular_velocity()) - vA;
- else
+ } else {
rel_vel = -vA;
+ }
Vector2 impulse = M.basis_xform(bias - rel_vel - Vector2(softness, softness) * P);
A->apply_impulse(rA, -impulse);
- if (B)
+ if (B) {
B->apply_impulse(rB, impulse);
+ }
P += impulse;
}
void PinJoint2DSW::set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value) {
-
- if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS)
+ if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS) {
softness = p_value;
+ }
}
real_t PinJoint2DSW::get_param(PhysicsServer2D::PinJointParam p_param) const {
-
- if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS)
+ if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS) {
return softness;
+ }
ERR_FAIL_V(0);
}
PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b) :
Joint2DSW(_arr, p_body_b ? 2 : 1) {
-
A = p_body_a;
B = p_body_b;
anchor_A = p_body_a->get_inv_transform().xform(p_pos);
@@ -195,16 +192,18 @@ PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p
softness = 0;
p_body_a->add_constraint(this, 0);
- if (p_body_b)
+ if (p_body_b) {
p_body_b->add_constraint(this, 1);
+ }
}
PinJoint2DSW::~PinJoint2DSW() {
-
- if (A)
+ if (A) {
A->remove_constraint(this);
- if (B)
+ }
+ if (B) {
B->remove_constraint(this);
+ }
}
//////////////////////////////////////////////
@@ -259,7 +258,6 @@ mult_k(const Vector2 &vr, const Vector2 &k1, const Vector2 &k2) {
}
bool GrooveJoint2DSW::setup(real_t p_step) {
-
// calculate endpoints in worldspace
Vector2 ta = A->get_transform().xform(A_groove_1);
Vector2 tb = A->get_transform().xform(A_groove_2);
@@ -311,7 +309,6 @@ bool GrooveJoint2DSW::setup(real_t p_step) {
}
void GrooveJoint2DSW::solve(real_t p_step) {
-
// compute impulse
Vector2 vr = relative_velocity(A, B, rA, rB);
@@ -329,7 +326,6 @@ void GrooveJoint2DSW::solve(real_t p_step) {
GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, Body2DSW *p_body_a, Body2DSW *p_body_b) :
Joint2DSW(_arr, 2) {
-
A = p_body_a;
B = p_body_b;
@@ -343,7 +339,6 @@ GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_
}
GrooveJoint2DSW::~GrooveJoint2DSW() {
-
A->remove_constraint(this);
B->remove_constraint(this);
}
@@ -353,17 +348,17 @@ GrooveJoint2DSW::~GrooveJoint2DSW() {
//////////////////////////////////////////////
bool DampedSpringJoint2DSW::setup(real_t p_step) {
-
rA = A->get_transform().basis_xform(anchor_A);
rB = B->get_transform().basis_xform(anchor_B);
Vector2 delta = (B->get_transform().get_origin() + rB) - (A->get_transform().get_origin() + rA);
real_t dist = delta.length();
- if (dist)
+ if (dist) {
n = delta / dist;
- else
+ } else {
n = Vector2();
+ }
real_t k = k_scalar(A, B, rA, rB, n);
n_mass = 1.0f / k;
@@ -382,7 +377,6 @@ bool DampedSpringJoint2DSW::setup(real_t p_step) {
}
void DampedSpringJoint2DSW::solve(real_t p_step) {
-
// compute relative velocity
real_t vrn = normal_relative_velocity(A, B, rA, rB, n) - target_vrn;
@@ -396,39 +390,29 @@ void DampedSpringJoint2DSW::solve(real_t p_step) {
B->apply_impulse(rB, j);
}
-void DampedSpringJoint2DSW::set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value) {
-
+void DampedSpringJoint2DSW::set_param(PhysicsServer2D::DampedSpringParam p_param, real_t p_value) {
switch (p_param) {
-
- case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: {
-
+ case PhysicsServer2D::DAMPED_SPRING_REST_LENGTH: {
rest_length = p_value;
} break;
- case PhysicsServer2D::DAMPED_STRING_DAMPING: {
-
+ case PhysicsServer2D::DAMPED_SPRING_DAMPING: {
damping = p_value;
} break;
- case PhysicsServer2D::DAMPED_STRING_STIFFNESS: {
-
+ case PhysicsServer2D::DAMPED_SPRING_STIFFNESS: {
stiffness = p_value;
} break;
}
}
-real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedStringParam p_param) const {
-
+real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedSpringParam p_param) const {
switch (p_param) {
-
- case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: {
-
+ case PhysicsServer2D::DAMPED_SPRING_REST_LENGTH: {
return rest_length;
} break;
- case PhysicsServer2D::DAMPED_STRING_DAMPING: {
-
+ case PhysicsServer2D::DAMPED_SPRING_DAMPING: {
return damping;
} break;
- case PhysicsServer2D::DAMPED_STRING_STIFFNESS: {
-
+ case PhysicsServer2D::DAMPED_SPRING_STIFFNESS: {
return stiffness;
} break;
}
@@ -438,7 +422,6 @@ real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedStringParam p_par
DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b) :
Joint2DSW(_arr, 2) {
-
A = p_body_a;
B = p_body_b;
anchor_A = A->get_inv_transform().xform(p_anchor_a);
@@ -453,7 +436,6 @@ DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Ve
}
DampedSpringJoint2DSW::~DampedSpringJoint2DSW() {
-
A->remove_constraint(this);
B->remove_constraint(this);
}
diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h
index a0d25dc70d..3c8aab77c8 100644
--- a/servers/physics_2d/joints_2d_sw.h
+++ b/servers/physics_2d/joints_2d_sw.h
@@ -35,7 +35,6 @@
#include "constraint_2d_sw.h"
class Joint2DSW : public Constraint2DSW {
-
real_t max_force;
real_t bias;
real_t max_bias;
@@ -59,7 +58,6 @@ public:
};
class PinJoint2DSW : public Joint2DSW {
-
union {
struct {
Body2DSW *A;
@@ -91,7 +89,6 @@ public:
};
class GrooveJoint2DSW : public Joint2DSW {
-
union {
struct {
Body2DSW *A;
@@ -126,7 +123,6 @@ public:
};
class DampedSpringJoint2DSW : public Joint2DSW {
-
union {
struct {
Body2DSW *A;
@@ -155,8 +151,8 @@ public:
virtual bool setup(real_t p_step);
virtual void solve(real_t p_step);
- void set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value);
- real_t get_param(PhysicsServer2D::DampedStringParam p_param) const;
+ void set_param(PhysicsServer2D::DampedSpringParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer2D::DampedSpringParam p_param) const;
DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b);
~DampedSpringJoint2DSW();
diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index bc3b468cea..6983225668 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -41,44 +41,33 @@
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
-
Shape2DSW *shape = nullptr;
switch (p_shape) {
-
case SHAPE_LINE: {
-
shape = memnew(LineShape2DSW);
} break;
case SHAPE_RAY: {
-
shape = memnew(RayShape2DSW);
} break;
case SHAPE_SEGMENT: {
-
shape = memnew(SegmentShape2DSW);
} break;
case SHAPE_CIRCLE: {
-
shape = memnew(CircleShape2DSW);
} break;
case SHAPE_RECTANGLE: {
-
shape = memnew(RectangleShape2DSW);
} break;
case SHAPE_CAPSULE: {
-
shape = memnew(CapsuleShape2DSW);
} break;
case SHAPE_CONVEX_POLYGON: {
-
shape = memnew(ConvexPolygonShape2DSW);
} break;
case SHAPE_CONCAVE_POLYGON: {
-
shape = memnew(ConcavePolygonShape2DSW);
} break;
case SHAPE_CUSTOM: {
-
ERR_FAIL_V(RID());
} break;
@@ -91,63 +80,56 @@ RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
}
RID PhysicsServer2DSW::line_shape_create() {
-
return _shape_create(SHAPE_LINE);
}
RID PhysicsServer2DSW::ray_shape_create() {
-
return _shape_create(SHAPE_RAY);
}
-RID PhysicsServer2DSW::segment_shape_create() {
+RID PhysicsServer2DSW::segment_shape_create() {
return _shape_create(SHAPE_SEGMENT);
}
-RID PhysicsServer2DSW::circle_shape_create() {
+RID PhysicsServer2DSW::circle_shape_create() {
return _shape_create(SHAPE_CIRCLE);
}
-RID PhysicsServer2DSW::rectangle_shape_create() {
+RID PhysicsServer2DSW::rectangle_shape_create() {
return _shape_create(SHAPE_RECTANGLE);
}
-RID PhysicsServer2DSW::capsule_shape_create() {
+RID PhysicsServer2DSW::capsule_shape_create() {
return _shape_create(SHAPE_CAPSULE);
}
RID PhysicsServer2DSW::convex_polygon_shape_create() {
-
return _shape_create(SHAPE_CONVEX_POLYGON);
}
-RID PhysicsServer2DSW::concave_polygon_shape_create() {
+RID PhysicsServer2DSW::concave_polygon_shape_create() {
return _shape_create(SHAPE_CONCAVE_POLYGON);
}
void PhysicsServer2DSW::shape_set_data(RID p_shape, const Variant &p_data) {
-
Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
void PhysicsServer2DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
-
Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
PhysicsServer2D::ShapeType PhysicsServer2DSW::shape_get_type(RID p_shape) const {
-
const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const {
-
const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
@@ -155,18 +137,17 @@ Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const {
};
real_t PhysicsServer2DSW::shape_get_custom_solver_bias(RID p_shape) const {
-
const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) {
-
CollCbkData *cbk = (CollCbkData *)p_userdata;
- if (cbk->max == 0)
+ if (cbk->max == 0) {
return;
+ }
if (cbk->valid_dir != Vector2()) {
if (p_point_A.distance_squared_to(p_point_B) > cbk->valid_depth * cbk->valid_depth) {
@@ -194,7 +175,6 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
real_t min_depth = 1e20;
int min_depth_idx = 0;
for (int i = 0; i < cbk->amount; i++) {
-
real_t d = cbk->ptr[i * 2 + 0].distance_squared_to(cbk->ptr[i * 2 + 1]);
if (d < min_depth) {
min_depth = d;
@@ -203,14 +183,14 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
}
real_t d = p_point_A.distance_squared_to(p_point_B);
- if (d < min_depth)
+ if (d < min_depth) {
return;
+ }
cbk->ptr[min_depth_idx * 2 + 0] = p_point_A;
cbk->ptr[min_depth_idx * 2 + 1] = p_point_B;
cbk->passed++;
} else {
-
cbk->ptr[cbk->amount * 2 + 0] = p_point_A;
cbk->ptr[cbk->amount * 2 + 1] = p_point_B;
cbk->amount++;
@@ -219,14 +199,12 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
}
bool PhysicsServer2DSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
-
Shape2DSW *shape_A = shape_owner.getornull(p_shape_A);
ERR_FAIL_COND_V(!shape_A, false);
Shape2DSW *shape_B = shape_owner.getornull(p_shape_B);
ERR_FAIL_COND_V(!shape_B, false);
if (p_result_max == 0) {
-
return CollisionSolver2DSW::solve(shape_A, p_xform_A, p_motion_A, shape_B, p_xform_B, p_motion_B, nullptr, nullptr);
}
@@ -242,7 +220,6 @@ bool PhysicsServer2DSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_
}
RID PhysicsServer2DSW::space_create() {
-
Space2DSW *space = memnew(Space2DSW);
RID id = space_owner.make_rid(space);
space->set_self(id);
@@ -257,17 +234,16 @@ RID PhysicsServer2DSW::space_create() {
};
void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) {
-
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
- if (p_active)
+ if (p_active) {
active_spaces.insert(space);
- else
+ } else {
active_spaces.erase(space);
+ }
}
bool PhysicsServer2DSW::space_is_active(RID p_space) const {
-
const Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
@@ -275,7 +251,6 @@ bool PhysicsServer2DSW::space_is_active(RID p_space) const {
}
void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
-
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -283,35 +258,30 @@ void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, rea
}
real_t PhysicsServer2DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
-
const Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
void PhysicsServer2DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
-
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector2> PhysicsServer2DSW::space_get_contacts(RID p_space) const {
-
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector2>());
return space->get_debug_contacts();
}
int PhysicsServer2DSW::space_get_contact_count(RID p_space) const {
-
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space) {
-
Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, nullptr);
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -320,7 +290,6 @@ PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space
}
RID PhysicsServer2DSW::area_create() {
-
Area2DSW *area = memnew(Area2DSW);
RID rid = area_owner.make_rid(area);
area->set_self(rid);
@@ -328,7 +297,6 @@ RID PhysicsServer2DSW::area_create() {
};
void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -338,26 +306,26 @@ void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) {
ERR_FAIL_COND(!space);
}
- if (area->get_space() == space)
+ if (area->get_space() == space) {
return; //pointless
+ }
area->clear_constraints();
area->set_space(space);
};
RID PhysicsServer2DSW::area_get_space(RID p_area) const {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
Space2DSW *space = area->get_space();
- if (!space)
+ if (!space) {
return RID();
+ }
return space->get_self();
};
void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -365,7 +333,6 @@ void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverri
}
PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_override_mode(RID p_area) const {
-
const Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
@@ -373,7 +340,6 @@ PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_overrid
}
void PhysicsServer2DSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -384,7 +350,6 @@ void PhysicsServer2DSW::area_add_shape(RID p_area, RID p_shape, const Transform2
}
void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -394,8 +359,8 @@ void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
area->set_shape(p_shape_idx, shape);
}
-void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
+void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -403,7 +368,6 @@ void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, co
}
void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape, area->get_shape_count());
@@ -413,14 +377,13 @@ void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_
}
int PhysicsServer2DSW::area_get_shape_count(RID p_area) const {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
-RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
+RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
@@ -429,8 +392,8 @@ RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const {
return shape->get_self();
}
-Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
+Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
@@ -438,7 +401,6 @@ Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_
}
void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -446,16 +408,15 @@ void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) {
}
void PhysicsServer2DSW::area_clear_shapes(RID p_area) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- while (area->get_shape_count())
+ while (area->get_shape_count()) {
area->remove_shape(0);
+ }
}
void PhysicsServer2DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
-
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -464,8 +425,8 @@ void PhysicsServer2DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
-ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const {
+ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -476,7 +437,6 @@ ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const {
}
void PhysicsServer2DSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) {
-
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -485,8 +445,8 @@ void PhysicsServer2DSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id
ERR_FAIL_COND(!area);
area->set_canvas_instance_id(p_id);
}
-ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const {
+ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -497,7 +457,6 @@ ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const {
}
void PhysicsServer2DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
-
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -508,14 +467,12 @@ void PhysicsServer2DSW::area_set_param(RID p_area, AreaParameter p_param, const
};
void PhysicsServer2DSW::area_set_transform(RID p_area, const Transform2D &p_transform) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
Variant PhysicsServer2DSW::area_get_param(RID p_area, AreaParameter p_param) const {
-
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -527,7 +484,6 @@ Variant PhysicsServer2DSW::area_get_param(RID p_area, AreaParameter p_param) con
};
Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
@@ -535,14 +491,12 @@ Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const {
};
void PhysicsServer2DSW::area_set_pickable(RID p_area, bool p_pickable) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_pickable(p_pickable);
}
void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -551,7 +505,6 @@ void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
}
void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -559,7 +512,6 @@ void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
}
void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -567,7 +519,6 @@ void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
}
void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -575,7 +526,6 @@ void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver
}
void PhysicsServer2DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
-
Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -585,7 +535,6 @@ void PhysicsServer2DSW::area_set_area_monitor_callback(RID p_area, Object *p_rec
/* BODY API */
RID PhysicsServer2DSW::body_create() {
-
Body2DSW *body = memnew(Body2DSW);
RID rid = body_owner.make_rid(body);
body->set_self(rid);
@@ -593,7 +542,6 @@ RID PhysicsServer2DSW::body_create() {
}
void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
Space2DSW *space = nullptr;
@@ -602,26 +550,26 @@ void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) {
ERR_FAIL_COND(!space);
}
- if (body->get_space() == space)
+ if (body->get_space() == space) {
return; //pointless
+ }
body->clear_constraint_map();
body->set_space(space);
};
RID PhysicsServer2DSW::body_get_space(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
Space2DSW *space = body->get_space();
- if (!space)
+ if (!space) {
return RID();
+ }
return space->get_self();
};
void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
FLUSH_QUERY_CHECK(body);
@@ -630,7 +578,6 @@ void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) {
};
PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
@@ -638,7 +585,6 @@ PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const {
};
void PhysicsServer2DSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -649,7 +595,6 @@ void PhysicsServer2DSW::body_add_shape(RID p_body, RID p_shape, const Transform2
}
void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -659,8 +604,8 @@ void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
body->set_shape(p_shape_idx, shape);
}
-void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
+void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -668,28 +613,25 @@ void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, co
}
void PhysicsServer2DSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_metadata(p_shape_idx, p_metadata);
}
Variant PhysicsServer2DSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_shape_metadata(p_shape_idx);
}
int PhysicsServer2DSW::body_get_shape_count(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
-RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
+RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -698,8 +640,8 @@ RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const {
return shape->get_self();
}
-Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
+Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform2D());
@@ -707,7 +649,6 @@ Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_
}
void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -715,16 +656,15 @@ void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) {
}
void PhysicsServer2DSW::body_clear_shapes(RID p_body) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- while (body->get_shape_count())
+ while (body->get_shape_count()) {
body->remove_shape(0);
+ }
}
void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
@@ -732,8 +672,8 @@ void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
body->set_shape_as_disabled(p_shape_idx, p_disabled);
}
-void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {
+void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
@@ -743,14 +683,12 @@ void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh
}
void PhysicsServer2DSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection_mode(p_mode);
}
PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_detection_mode(RID p_body) const {
-
const Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED);
@@ -758,7 +696,6 @@ PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_dete
}
void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -766,7 +703,6 @@ void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id
};
ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
@@ -774,7 +710,6 @@ ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const {
};
void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -782,7 +717,6 @@ void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id
};
ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
@@ -790,14 +724,12 @@ ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const {
};
void PhysicsServer2DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
};
uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -805,14 +737,12 @@ uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const {
};
void PhysicsServer2DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
};
uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -820,7 +750,6 @@ uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const {
};
void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -828,7 +757,6 @@ void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, real_t
};
real_t PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -836,7 +764,6 @@ real_t PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) cons
};
void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -844,7 +771,6 @@ void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Vari
};
Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
@@ -852,7 +778,6 @@ Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const {
};
void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_force) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -861,14 +786,12 @@ void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_forc
};
Vector2 PhysicsServer2DSW::body_get_applied_force(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector2());
return body->get_applied_force();
};
void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -877,7 +800,6 @@ void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) {
};
real_t PhysicsServer2DSW::body_get_applied_torque(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -902,7 +824,6 @@ void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
}
void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, const Vector2 &p_impulse) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -921,7 +842,6 @@ void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_forc
};
void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_offset, const Vector2 &p_force) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -938,7 +858,6 @@ void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) {
};
void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -953,7 +872,6 @@ void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
};
void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -962,7 +880,6 @@ void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
};
void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -971,7 +888,6 @@ void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b
};
void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -981,20 +897,17 @@ void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
void PhysicsServer2DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
};
real_t PhysicsServer2DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -1002,35 +915,30 @@ void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit)
};
bool PhysicsServer2DSW::body_is_omitting_force_integration(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
void PhysicsServer2DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
int PhysicsServer2DSW::body_get_max_contacts_reported(RID p_body) const {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void PhysicsServer2DSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_INDEX_V(p_body_shape, body->get_shape_count(), false);
@@ -1039,14 +947,12 @@ bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s
}
void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_pickable(p_pickable);
}
bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -1058,7 +964,6 @@ bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from,
}
int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
-
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -1068,11 +973,11 @@ int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p
}
PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) {
-
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
- if (!body_owner.owns(p_body))
+ if (!body_owner.owns(p_body)) {
return nullptr;
+ }
Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, nullptr);
@@ -1086,7 +991,6 @@ PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) {
/* JOINT API */
void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
-
Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
@@ -1104,7 +1008,6 @@ void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t
}
real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const {
-
const Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, -1);
@@ -1151,7 +1054,6 @@ bool PhysicsServer2DSW::joint_is_disabled_collisions_between_bodies(RID p_joint)
}
RID PhysicsServer2DSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
-
Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
Body2DSW *B = nullptr;
@@ -1168,7 +1070,6 @@ RID PhysicsServer2DSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID
}
RID PhysicsServer2DSW::groove_joint_create(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) {
-
Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
@@ -1182,7 +1083,6 @@ RID PhysicsServer2DSW::groove_joint_create(const Vector2 &p_a_groove1, const Vec
}
RID PhysicsServer2DSW::damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) {
-
Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
@@ -1196,7 +1096,6 @@ RID PhysicsServer2DSW::damped_spring_joint_create(const Vector2 &p_anchor_a, con
}
void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
-
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_PIN);
@@ -1214,8 +1113,7 @@ real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
return pin_joint->get_param(p_param);
}
-void PhysicsServer2DSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) {
-
+void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) {
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_DAMPED_SPRING);
@@ -1224,8 +1122,7 @@ void PhysicsServer2DSW::damped_string_joint_set_param(RID p_joint, DampedStringP
dsj->set_param(p_param, p_value);
}
-real_t PhysicsServer2DSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const {
-
+real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const {
Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_DAMPED_SPRING, 0);
@@ -1235,7 +1132,6 @@ real_t PhysicsServer2DSW::damped_string_joint_get_param(RID p_joint, DampedStrin
}
PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const {
-
Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
@@ -1243,11 +1139,9 @@ PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const
}
void PhysicsServer2DSW::free(RID p_rid) {
-
_update_shapes(); // just in case
if (shape_owner.owns(p_rid)) {
-
Shape2DSW *shape = shape_owner.getornull(p_rid);
while (shape->get_owners().size()) {
@@ -1258,7 +1152,6 @@ void PhysicsServer2DSW::free(RID p_rid) {
shape_owner.free(p_rid);
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
-
Body2DSW *body = body_owner.getornull(p_rid);
/*
@@ -1272,7 +1165,6 @@ void PhysicsServer2DSW::free(RID p_rid) {
body_set_space(p_rid, RID());
while (body->get_shape_count()) {
-
body->remove_shape(0);
}
@@ -1280,7 +1172,6 @@ void PhysicsServer2DSW::free(RID p_rid) {
memdelete(body);
} else if (area_owner.owns(p_rid)) {
-
Area2DSW *area = area_owner.getornull(p_rid);
/*
@@ -1291,14 +1182,12 @@ void PhysicsServer2DSW::free(RID p_rid) {
area->set_space(nullptr);
while (area->get_shape_count()) {
-
area->remove_shape(0);
}
area_owner.free(p_rid);
memdelete(area);
} else if (space_owner.owns(p_rid)) {
-
Space2DSW *space = space_owner.getornull(p_rid);
while (space->get_objects().size()) {
@@ -1311,25 +1200,21 @@ void PhysicsServer2DSW::free(RID p_rid) {
space_owner.free(p_rid);
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
-
Joint2DSW *joint = joint_owner.getornull(p_rid);
joint_owner.free(p_rid);
memdelete(joint);
} else {
-
ERR_FAIL_MSG("Invalid ID.");
}
};
void PhysicsServer2DSW::set_active(bool p_active) {
-
active = p_active;
};
void PhysicsServer2DSW::init() {
-
doing_sync = false;
last_step = 0.001;
iterations = 8; // 8?
@@ -1338,9 +1223,9 @@ void PhysicsServer2DSW::init() {
};
void PhysicsServer2DSW::step(real_t p_step) {
-
- if (!active)
+ if (!active) {
return;
+ }
_update_shapes();
@@ -1352,7 +1237,6 @@ void PhysicsServer2DSW::step(real_t p_step) {
active_objects = 0;
collision_pairs = 0;
for (Set<const Space2DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
stepper->step((Space2DSW *)E->get(), p_step, iterations);
island_count += E->get()->get_island_count();
active_objects += E->get()->get_active_objects();
@@ -1361,21 +1245,19 @@ void PhysicsServer2DSW::step(real_t p_step) {
};
void PhysicsServer2DSW::sync() {
-
doing_sync = true;
};
void PhysicsServer2DSW::flush_queries() {
-
- if (!active)
+ if (!active) {
return;
+ }
flushing_queries = true;
uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
for (Set<const Space2DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
Space2DSW *space = (Space2DSW *)E->get();
space->call_queries();
}
@@ -1383,7 +1265,6 @@ void PhysicsServer2DSW::flush_queries() {
flushing_queries = false;
if (EngineDebugger::is_profiling("servers")) {
-
uint64_t total_time[Space2DSW::ELAPSED_TIME_MAX];
static const char *time_name[Space2DSW::ELAPSED_TIME_MAX] = {
"integrate_forces",
@@ -1398,7 +1279,6 @@ void PhysicsServer2DSW::flush_queries() {
}
for (Set<const Space2DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
for (int i = 0; i < Space2DSW::ELAPSED_TIME_MAX; i++) {
total_time[i] += E->get()->get_elapsed_time(Space2DSW::ElapsedTime(i));
}
@@ -1423,13 +1303,11 @@ void PhysicsServer2DSW::end_sync() {
}
void PhysicsServer2DSW::finish() {
-
memdelete(stepper);
memdelete(direct_state);
};
void PhysicsServer2DSW::_update_shapes() {
-
while (pending_shape_update_list.first()) {
pending_shape_update_list.first()->self()->_shape_changed();
pending_shape_update_list.remove(pending_shape_update_list.first());
@@ -1437,18 +1315,14 @@ void PhysicsServer2DSW::_update_shapes() {
}
int PhysicsServer2DSW::get_process_info(ProcessInfo p_info) {
-
switch (p_info) {
-
case INFO_ACTIVE_OBJECTS: {
-
return active_objects;
} break;
case INFO_COLLISION_PAIRS: {
return collision_pairs;
} break;
case INFO_ISLAND_COUNT: {
-
return island_count;
} break;
}
@@ -1459,7 +1333,6 @@ int PhysicsServer2DSW::get_process_info(ProcessInfo p_info) {
PhysicsServer2DSW *PhysicsServer2DSW::singletonsw = nullptr;
PhysicsServer2DSW::PhysicsServer2DSW() {
-
singletonsw = this;
BroadPhase2DSW::create_func = BroadPhase2DHashGrid::_create;
//BroadPhase2DSW::create_func=BroadPhase2DBasic::_create;
@@ -1471,7 +1344,3 @@ PhysicsServer2DSW::PhysicsServer2DSW() {
using_threads = int(ProjectSettings::get_singleton()->get("physics/2d/thread_model")) == 2;
flushing_queries = false;
};
-
-PhysicsServer2DSW::~PhysicsServer2DSW(){
-
-};
diff --git a/servers/physics_2d/physics_server_2d_sw.h b/servers/physics_2d/physics_server_2d_sw.h
index 918958ffe2..093c775cb5 100644
--- a/servers/physics_2d/physics_server_2d_sw.h
+++ b/servers/physics_2d/physics_server_2d_sw.h
@@ -39,7 +39,6 @@
#include "step_2d_sw.h"
class PhysicsServer2DSW : public PhysicsServer2D {
-
GDCLASS(PhysicsServer2DSW, PhysicsServer2D);
friend class PhysicsDirectSpaceState2DSW;
@@ -79,7 +78,6 @@ class PhysicsServer2DSW : public PhysicsServer2D {
public:
struct CollCbkData {
-
Vector2 valid_dir;
real_t valid_depth;
int max;
@@ -268,8 +266,8 @@ public:
virtual RID damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b = RID());
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value);
virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const;
- virtual void damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value);
- virtual real_t damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const;
+ virtual void damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value);
+ virtual real_t damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const;
virtual JointType joint_get_type(RID p_joint) const;
@@ -290,7 +288,7 @@ public:
int get_process_info(ProcessInfo p_info);
PhysicsServer2DSW();
- ~PhysicsServer2DSW();
+ ~PhysicsServer2DSW() {}
};
#endif
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.cpp b/servers/physics_2d/physics_server_2d_wrap_mt.cpp
index 0a89a76615..49c38c6ce0 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.cpp
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.cpp
@@ -33,25 +33,21 @@
#include "core/os/os.h"
void PhysicsServer2DWrapMT::thread_exit() {
-
exit = true;
}
void PhysicsServer2DWrapMT::thread_step(real_t p_delta) {
-
physics_2d_server->step(p_delta);
step_sem.post();
}
void PhysicsServer2DWrapMT::_thread_callback(void *_instance) {
-
PhysicsServer2DWrapMT *vsmt = reinterpret_cast<PhysicsServer2DWrapMT *>(_instance);
vsmt->thread_loop();
}
void PhysicsServer2DWrapMT::thread_loop() {
-
server_thread = Thread::get_caller_id();
physics_2d_server->init();
@@ -71,57 +67,47 @@ void PhysicsServer2DWrapMT::thread_loop() {
/* EVENT QUEUING */
void PhysicsServer2DWrapMT::step(real_t p_step) {
-
if (create_thread) {
-
command_queue.push(this, &PhysicsServer2DWrapMT::thread_step, p_step);
} else {
-
command_queue.flush_all(); //flush all pending from other threads
physics_2d_server->step(p_step);
}
}
void PhysicsServer2DWrapMT::sync() {
-
if (thread) {
- if (first_frame)
+ if (first_frame) {
first_frame = false;
- else
+ } else {
step_sem.wait(); //must not wait if a step was not issued
+ }
}
physics_2d_server->sync();
}
void PhysicsServer2DWrapMT::flush_queries() {
-
physics_2d_server->flush_queries();
}
void PhysicsServer2DWrapMT::end_sync() {
-
physics_2d_server->end_sync();
}
void PhysicsServer2DWrapMT::init() {
-
if (create_thread) {
-
//OS::get_singleton()->release_rendering_thread();
thread = Thread::create(_thread_callback, this);
while (!step_thread_up) {
OS::get_singleton()->delay_usec(1000);
}
} else {
-
physics_2d_server->init();
}
}
void PhysicsServer2DWrapMT::finish() {
-
if (thread) {
-
command_queue.push(this, &PhysicsServer2DWrapMT::thread_exit);
Thread::wait_to_finish(thread);
memdelete(thread);
@@ -147,7 +133,6 @@ void PhysicsServer2DWrapMT::finish() {
PhysicsServer2DWrapMT::PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
-
physics_2d_server = p_contained;
create_thread = p_create_thread;
thread = nullptr;
@@ -167,7 +152,6 @@ PhysicsServer2DWrapMT::PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool
}
PhysicsServer2DWrapMT::~PhysicsServer2DWrapMT() {
-
memdelete(physics_2d_server);
//finish();
}
diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h
index 7e61927378..bc918b20f4 100644
--- a/servers/physics_2d/physics_server_2d_wrap_mt.h
+++ b/servers/physics_2d/physics_server_2d_wrap_mt.h
@@ -43,7 +43,6 @@
#endif
class PhysicsServer2DWrapMT : public PhysicsServer2D {
-
mutable PhysicsServer2D *physics_2d_server;
mutable CommandQueueMT command_queue;
@@ -95,7 +94,6 @@ public:
//these work well, but should be used from the main thread only
bool shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
return physics_2d_server->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
}
@@ -111,20 +109,17 @@ public:
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
return physics_2d_server->space_get_direct_state(p_space);
}
FUNC2(space_set_debug_contacts, RID, int);
virtual Vector<Vector2> space_get_contacts(RID p_space) const {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), Vector<Vector2>());
return physics_2d_server->space_get_contacts(p_space);
}
virtual int space_get_contact_count(RID p_space) const {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), 0);
return physics_2d_server->space_get_contact_count(p_space);
}
@@ -256,20 +251,17 @@ public:
FUNC2(body_set_pickable, RID, bool);
bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes);
}
int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
return physics_2d_server->body_test_ray_separation(p_body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
}
// this function only works on physics process, errors and returns null otherwise
PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) {
-
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
return physics_2d_server->body_get_direct_state(p_body);
}
@@ -295,8 +287,8 @@ public:
FUNC3(pin_joint_set_param, RID, PinJointParam, real_t);
FUNC2RC(real_t, pin_joint_get_param, RID, PinJointParam);
- FUNC3(damped_string_joint_set_param, RID, DampedStringParam, real_t);
- FUNC2RC(real_t, damped_string_joint_get_param, RID, DampedStringParam);
+ FUNC3(damped_spring_joint_set_param, RID, DampedSpringParam, real_t);
+ FUNC2RC(real_t, damped_spring_joint_get_param, RID, DampedSpringParam);
FUNC1RC(JointType, joint_get_type, RID);
@@ -325,14 +317,14 @@ public:
template <class T>
static PhysicsServer2D *init_server() {
-
int tm = GLOBAL_DEF("physics/2d/thread_model", 1);
- if (tm == 0) // single unsafe
+ if (tm == 0) { // single unsafe
return memnew(T);
- else if (tm == 1) // single safe
+ } else if (tm == 1) { // single safe
return memnew(PhysicsServer2DWrapMT(memnew(T), false));
- else // multi threaded
+ } else { // multi threaded
return memnew(PhysicsServer2DWrapMT(memnew(T), true));
+ }
}
#undef ServerNameWrapMT
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 06096d674a..87e22ef1c9 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -30,7 +30,7 @@
#include "shape_2d_sw.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
#include "core/sort_array.h"
void Shape2DSW::configure(const Rect2 &p_aabb) {
@@ -43,7 +43,6 @@ void Shape2DSW::configure(const Rect2 &p_aabb) {
}
Vector2 Shape2DSW::get_support(const Vector2 &p_normal) const {
-
Vector2 res[2];
int amnt;
get_supports(p_normal, res, amnt);
@@ -51,7 +50,6 @@ Vector2 Shape2DSW::get_support(const Vector2 &p_normal) const {
}
void Shape2DSW::add_owner(ShapeOwner2DSW *p_owner) {
-
Map<ShapeOwner2DSW *, int>::Element *E = owners.find(p_owner);
if (E) {
E->get()++;
@@ -61,7 +59,6 @@ void Shape2DSW::add_owner(ShapeOwner2DSW *p_owner) {
}
void Shape2DSW::remove_owner(ShapeOwner2DSW *p_owner) {
-
Map<ShapeOwner2DSW *, int>::Element *E = owners.find(p_owner);
ERR_FAIL_COND(!E);
E->get()--;
@@ -71,7 +68,6 @@ void Shape2DSW::remove_owner(ShapeOwner2DSW *p_owner) {
}
bool Shape2DSW::is_owner(ShapeOwner2DSW *p_owner) const {
-
return owners.has(p_owner);
}
@@ -80,13 +76,11 @@ const Map<ShapeOwner2DSW *, int> &Shape2DSW::get_owners() const {
}
Shape2DSW::Shape2DSW() {
-
custom_bias = 0;
configured = false;
}
Shape2DSW::~Shape2DSW() {
-
ERR_FAIL_COND(owners.size());
}
@@ -95,23 +89,19 @@ Shape2DSW::~Shape2DSW() {
/*********************************************************/
void LineShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
r_amount = 0;
}
bool LineShape2DSW::contains_point(const Vector2 &p_point) const {
-
return normal.dot(p_point) < d;
}
bool LineShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
Vector2 segment = p_begin - p_end;
real_t den = normal.dot(segment);
//printf("den is %i\n",den);
if (Math::abs(den) <= CMP_EPSILON) {
-
return false;
}
@@ -119,7 +109,6 @@ bool LineShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_e
//printf("dist is %i\n",dist);
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
-
return false;
}
@@ -130,12 +119,10 @@ bool LineShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_e
}
real_t LineShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
return 0;
}
void LineShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::ARRAY);
Array arr = p_data;
ERR_FAIL_COND(arr.size() != 2);
@@ -145,7 +132,6 @@ void LineShape2DSW::set_data(const Variant &p_data) {
}
Variant LineShape2DSW::get_data() const {
-
Array arr;
arr.resize(2);
arr[0] = normal;
@@ -158,32 +144,28 @@ Variant LineShape2DSW::get_data() const {
/*********************************************************/
void RayShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
r_amount = 1;
- if (p_normal.y > 0)
+ if (p_normal.y > 0) {
*r_supports = Vector2(0, length);
- else
+ } else {
*r_supports = Vector2();
+ }
}
bool RayShape2DSW::contains_point(const Vector2 &p_point) const {
-
return false;
}
bool RayShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
return false; //rays can't be intersected
}
real_t RayShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
return 0; //rays are mass-less
}
void RayShape2DSW::set_data(const Variant &p_data) {
-
Dictionary d = p_data;
length = d["length"];
slips_on_slope = d["slips_on_slope"];
@@ -191,7 +173,6 @@ void RayShape2DSW::set_data(const Variant &p_data) {
}
Variant RayShape2DSW::get_data() const {
-
Dictionary d;
d["length"] = length;
d["slips_on_slope"] = slips_on_slope;
@@ -203,7 +184,6 @@ Variant RayShape2DSW::get_data() const {
/*********************************************************/
void SegmentShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
if (Math::abs(p_normal.dot(n)) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
r_supports[0] = a;
r_supports[1] = b;
@@ -212,22 +192,22 @@ void SegmentShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports
}
real_t dp = p_normal.dot(b - a);
- if (dp > 0)
+ if (dp > 0) {
*r_supports = b;
- else
+ } else {
*r_supports = a;
+ }
r_amount = 1;
}
bool SegmentShape2DSW::contains_point(const Vector2 &p_point) const {
-
return false;
}
bool SegmentShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
- if (!Geometry::segment_intersects_segment_2d(p_begin, p_end, a, b, &r_point))
+ if (!Geometry2D::segment_intersects_segment(p_begin, p_end, a, b, &r_point)) {
return false;
+ }
if (n.dot(p_begin) > n.dot(a)) {
r_normal = n;
@@ -239,12 +219,10 @@ bool SegmentShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &
}
real_t SegmentShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
return p_mass * ((a * p_scale).distance_squared_to(b * p_scale)) / 12;
}
void SegmentShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::RECT2);
Rect2 r = p_data;
@@ -255,15 +233,16 @@ void SegmentShape2DSW::set_data(const Variant &p_data) {
Rect2 aabb;
aabb.position = a;
aabb.expand_to(b);
- if (aabb.size.x == 0)
+ if (aabb.size.x == 0) {
aabb.size.x = 0.001;
- if (aabb.size.y == 0)
+ }
+ if (aabb.size.y == 0) {
aabb.size.y = 0.001;
+ }
configure(aabb);
}
Variant SegmentShape2DSW::get_data() const {
-
Rect2 r;
r.position = a;
r.size = b;
@@ -275,18 +254,15 @@ Variant SegmentShape2DSW::get_data() const {
/*********************************************************/
void CircleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
r_amount = 1;
*r_supports = p_normal * radius;
}
bool CircleShape2DSW::contains_point(const Vector2 &p_point) const {
-
return p_point.length_squared() < radius * radius;
}
bool CircleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
Vector2 line_vec = p_end - p_begin;
real_t a, b, c;
@@ -297,8 +273,9 @@ bool CircleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p
real_t sqrtterm = b * b - 4 * a * c;
- if (sqrtterm < 0)
+ if (sqrtterm < 0) {
return false;
+ }
sqrtterm = Math::sqrt(sqrtterm);
real_t res = (-b - sqrtterm) / (2 * a);
@@ -312,21 +289,18 @@ bool CircleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p
}
real_t CircleShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
real_t a = radius * p_scale.x;
real_t b = radius * p_scale.y;
return p_mass * (a * a + b * b) / 4;
}
void CircleShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(!p_data.is_num());
radius = p_data;
configure(Rect2(-radius, -radius, radius * 2, radius * 2));
}
Variant CircleShape2DSW::get_data() const {
-
return radius;
}
@@ -335,14 +309,13 @@ Variant CircleShape2DSW::get_data() const {
/*********************************************************/
void RectangleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
for (int i = 0; i < 2; i++) {
-
Vector2 ag;
ag[i] = 1.0;
real_t dp = ag.dot(p_normal);
- if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)
+ if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
continue;
+ }
real_t sgn = dp > 0 ? 1.0 : -1.0;
@@ -374,18 +347,15 @@ bool RectangleShape2DSW::contains_point(const Vector2 &p_point) const {
}
bool RectangleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
return get_aabb().intersects_segment(p_begin, p_end, &r_point, &r_normal);
}
real_t RectangleShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
Vector2 he2 = half_extents * 2 * p_scale;
return p_mass * he2.dot(he2) / 12.0;
}
void RectangleShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::VECTOR2);
half_extents = p_data;
@@ -393,7 +363,6 @@ void RectangleShape2DSW::set_data(const Variant &p_data) {
}
Variant RectangleShape2DSW::get_data() const {
-
return half_extents;
}
@@ -402,13 +371,11 @@ Variant RectangleShape2DSW::get_data() const {
/*********************************************************/
void CapsuleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
Vector2 n = p_normal;
real_t d = n.y;
if (Math::abs(d) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
-
// make it flat
n.y = 0.0;
n.normalize();
@@ -421,7 +388,6 @@ void CapsuleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports
r_supports[1].y -= height * 0.5;
} else {
-
real_t h = (d > 0) ? height : -height;
n *= radius;
@@ -432,25 +398,23 @@ void CapsuleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports
}
bool CapsuleShape2DSW::contains_point(const Vector2 &p_point) const {
-
Vector2 p = p_point;
p.y = Math::abs(p.y);
p.y -= height * 0.5;
- if (p.y < 0)
+ if (p.y < 0) {
p.y = 0;
+ }
return p.length_squared() < radius * radius;
}
bool CapsuleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
real_t d = 1e10;
Vector2 n = (p_end - p_begin).normalized();
bool collided = false;
//try spheres
for (int i = 0; i < 2; i++) {
-
Vector2 begin = p_begin;
Vector2 end = p_end;
real_t ofs = (i == 0) ? -height * 0.5 : height * 0.5;
@@ -467,8 +431,9 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &
real_t sqrtterm = b * b - 4 * a * c;
- if (sqrtterm < 0)
+ if (sqrtterm < 0) {
continue;
+ }
sqrtterm = Math::sqrt(sqrtterm);
real_t res = (-b - sqrtterm) / (2 * a);
@@ -490,7 +455,6 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &
Vector2 rpos, rnorm;
if (Rect2(Point2(-radius, -height * 0.5), Size2(radius * 2.0, height)).intersects_segment(p_begin, p_end, &rpos, &rnorm)) {
-
real_t pd = n.dot(rpos);
if (pd < d) {
r_point = rpos;
@@ -505,13 +469,11 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &
}
real_t CapsuleShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
Vector2 he2 = Vector2(radius * 2, height + radius * 2) * p_scale;
return p_mass * he2.dot(he2) / 12.0;
}
void CapsuleShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::ARRAY && p_data.get_type() != Variant::VECTOR2);
if (p_data.get_type() == Variant::ARRAY) {
@@ -520,7 +482,6 @@ void CapsuleShape2DSW::set_data(const Variant &p_data) {
height = arr[0];
radius = arr[1];
} else {
-
Point2 p = p_data;
radius = p.x;
height = p.y;
@@ -531,7 +492,6 @@ void CapsuleShape2DSW::set_data(const Variant &p_data) {
}
Variant CapsuleShape2DSW::get_data() const {
-
return Point2(height, radius);
}
@@ -540,12 +500,10 @@ Variant CapsuleShape2DSW::get_data() const {
/*********************************************************/
void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
int support_idx = -1;
real_t d = -1e10;
for (int i = 0; i < point_count; i++) {
-
//test point
real_t ld = p_normal.dot(points[i].pos);
if (ld > d) {
@@ -555,7 +513,6 @@ void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_su
//test segment
if (points[i].normal.dot(p_normal) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) {
-
r_amount = 2;
r_supports[0] = points[i].pos;
r_supports[1] = points[(i + 1) % point_count].pos;
@@ -570,30 +527,27 @@ void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_su
}
bool ConvexPolygonShape2DSW::contains_point(const Vector2 &p_point) const {
-
bool out = false;
bool in = false;
for (int i = 0; i < point_count; i++) {
-
real_t d = points[i].normal.dot(p_point) - points[i].normal.dot(points[i].pos);
- if (d > 0)
+ if (d > 0) {
out = true;
- else
+ } else {
in = true;
+ }
}
return in != out;
}
bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
Vector2 n = (p_end - p_begin).normalized();
real_t d = 1e10;
bool inters = false;
for (int i = 0; i < point_count; i++) {
-
//hmm.. no can do..
/*
if (d.dot(points[i].normal)>=0)
@@ -602,12 +556,12 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vec
Vector2 res;
- if (!Geometry::segment_intersects_segment_2d(p_begin, p_end, points[i].pos, points[(i + 1) % point_count].pos, &res))
+ if (!Geometry2D::segment_intersects_segment(p_begin, p_end, points[i].pos, points[(i + 1) % point_count].pos, &res)) {
continue;
+ }
real_t nd = n.dot(res);
if (nd < d) {
-
d = nd;
r_point = res;
r_normal = points[i].normal;
@@ -616,9 +570,9 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vec
}
if (inters) {
-
- if (n.dot(r_normal) > 0)
+ if (n.dot(r_normal) > 0) {
r_normal = -r_normal;
+ }
}
//return get_aabb().intersects_segment(p_begin,p_end,&r_point,&r_normal);
@@ -626,11 +580,9 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vec
}
real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
-
Rect2 aabb;
aabb.position = points[0].pos * p_scale;
for (int i = 0; i < point_count; i++) {
-
aabb.expand_to(points[i].pos * p_scale);
}
@@ -638,11 +590,11 @@ real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2
}
void ConvexPolygonShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY);
- if (points)
+ if (points) {
memdelete_arr(points);
+ }
points = nullptr;
point_count = 0;
@@ -658,13 +610,11 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) {
}
for (int i = 0; i < point_count; i++) {
-
Vector2 p = points[i].pos;
Vector2 pn = points[(i + 1) % point_count].pos;
points[i].normal = (pn - p).tangent().normalized();
}
} else {
-
Vector<real_t> dvr = p_data;
point_count = dvr.size() / 4;
ERR_FAIL_COND(point_count == 0);
@@ -673,7 +623,6 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) {
const real_t *r = dvr.ptr();
for (int i = 0; i < point_count; i++) {
-
int idx = i << 2;
points[i].pos.x = r[idx + 0];
points[i].pos.y = r[idx + 1];
@@ -685,14 +634,14 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) {
ERR_FAIL_COND(point_count == 0);
Rect2 aabb;
aabb.position = points[0].pos;
- for (int i = 1; i < point_count; i++)
+ for (int i = 1; i < point_count; i++) {
aabb.expand_to(points[i].pos);
+ }
configure(aabb);
}
Variant ConvexPolygonShape2DSW::get_data() const {
-
Vector<Vector2> dvr;
dvr.resize(point_count);
@@ -705,25 +654,22 @@ Variant ConvexPolygonShape2DSW::get_data() const {
}
ConvexPolygonShape2DSW::ConvexPolygonShape2DSW() {
-
points = nullptr;
point_count = 0;
}
ConvexPolygonShape2DSW::~ConvexPolygonShape2DSW() {
-
- if (points)
+ if (points) {
memdelete_arr(points);
+ }
}
//////////////////////////////////////////////////
void ConcavePolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
-
real_t d = -1e10;
int idx = -1;
for (int i = 0; i < points.size(); i++) {
-
real_t ld = p_normal.dot(points[i]);
if (ld > d) {
d = ld;
@@ -737,12 +683,10 @@ void ConcavePolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_s
}
bool ConcavePolygonShape2DSW::contains_point(const Vector2 &p_point) const {
-
return false; //sorry
}
bool ConcavePolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
-
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * bvh_depth);
enum {
@@ -773,34 +717,27 @@ bool ConcavePolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Ve
stack[0] = 0;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &bvh = bvhptr[node];
bool done = false;
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool valid = bvh.aabb.intersects_segment(p_begin, p_end);
if (!valid) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (bvh.left < 0) {
-
const Segment &s = segmentptr[bvh.right];
Vector2 a = pointptr[s.points[0]];
Vector2 b = pointptr[s.points[1]];
Vector2 res;
- if (Geometry::segment_intersects_segment_2d(p_begin, p_end, a, b, &res)) {
-
+ if (Geometry2D::segment_intersects_segment(p_begin, p_end, a, b, &res)) {
real_t nd = n.dot(res);
if (nd < d) {
-
d = nd;
r_point = res;
r_normal = (b - a).tangent().normalized();
@@ -811,54 +748,50 @@ bool ConcavePolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Ve
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
}
continue;
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = bvh.left | TEST_AABB_BIT;
level++;
}
continue;
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = bvh.right | TEST_AABB_BIT;
level++;
}
continue;
case VISIT_DONE_BIT: {
-
if (level == 0) {
done = true;
break;
- } else
+ } else {
level--;
+ }
}
continue;
}
- if (done)
+ if (done) {
break;
+ }
}
if (inters) {
-
- if (n.dot(r_normal) > 0)
+ if (n.dot(r_normal) > 0) {
r_normal = -r_normal;
+ }
}
return inters;
}
int ConcavePolygonShape2DSW::_generate_bvh(BVH *p_bvh, int p_len, int p_depth) {
-
if (p_len == 1) {
-
bvh_depth = MAX(p_depth, bvh_depth);
bvh.push_back(*p_bvh);
return bvh.size() - 1;
@@ -872,12 +805,10 @@ int ConcavePolygonShape2DSW::_generate_bvh(BVH *p_bvh, int p_len, int p_depth) {
}
if (global_aabb.size.x > global_aabb.size.y) {
-
SortArray<BVH, BVH_CompareX> sort;
sort.sort(p_bvh, p_len);
} else {
-
SortArray<BVH, BVH_CompareY> sort;
sort.sort(p_bvh, p_len);
}
@@ -898,13 +829,11 @@ int ConcavePolygonShape2DSW::_generate_bvh(BVH *p_bvh, int p_len, int p_depth) {
}
void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::PACKED_VECTOR2_ARRAY && p_data.get_type() != Variant::PACKED_FLOAT32_ARRAY);
Rect2 aabb;
if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) {
-
Vector<Vector2> p2arr = p_data;
int len = p2arr.size();
ERR_FAIL_COND(len % 2);
@@ -923,7 +852,6 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
Map<Point2, int> pointmap;
for (int i = 0; i < len; i += 2) {
-
Point2 p1 = arr[i];
Point2 p2 = arr[i + 1];
int idx_p1, idx_p2;
@@ -951,7 +879,6 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
points.resize(pointmap.size());
aabb.position = pointmap.front()->key();
for (Map<Point2, int>::Element *E = pointmap.front(); E; E = E->next()) {
-
aabb.expand_to(E->key());
points.write[E->get()] = E->key();
}
@@ -959,7 +886,6 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
Vector<BVH> main_vbh;
main_vbh.resize(segments.size());
for (int i = 0; i < main_vbh.size(); i++) {
-
main_vbh.write[i].aabb.position = points[segments[i].points[0]];
main_vbh.write[i].aabb.expand_to(points[segments[i].points[1]]);
main_vbh.write[i].left = -1;
@@ -974,14 +900,13 @@ void ConcavePolygonShape2DSW::set_data(const Variant &p_data) {
configure(aabb);
}
-Variant ConcavePolygonShape2DSW::get_data() const {
+Variant ConcavePolygonShape2DSW::get_data() const {
Vector<Vector2> rsegments;
int len = segments.size();
rsegments.resize(len * 2);
Vector2 *w = rsegments.ptrw();
for (int i = 0; i < len; i++) {
-
w[(i << 1) + 0] = points[segments[i].points[0]];
w[(i << 1) + 1] = points[segments[i].points[1]];
}
@@ -990,7 +915,6 @@ Variant ConcavePolygonShape2DSW::get_data() const {
}
void ConcavePolygonShape2DSW::cull(const Rect2 &p_local_aabb, Callback p_callback, void *p_userdata) const {
-
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * bvh_depth);
enum {
@@ -1021,22 +945,17 @@ void ConcavePolygonShape2DSW::cull(const Rect2 &p_local_aabb, Callback p_callbac
stack[0] = 0;
while (true) {
-
uint32_t node = stack[level] & NODE_IDX_MASK;
const BVH &bvh = bvhptr[node];
switch (stack[level] >> VISITED_BIT_SHIFT) {
case TEST_AABB_BIT: {
-
bool valid = p_local_aabb.intersects(bvh.aabb);
if (!valid) {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
if (bvh.left < 0) {
-
const Segment &s = segmentptr[bvh.right];
Vector2 a = pointptr[s.points[0]];
Vector2 b = pointptr[s.points[1]];
@@ -1047,32 +966,29 @@ void ConcavePolygonShape2DSW::cull(const Rect2 &p_local_aabb, Callback p_callbac
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
} else {
-
stack[level] = (VISIT_LEFT_BIT << VISITED_BIT_SHIFT) | node;
}
}
}
continue;
case VISIT_LEFT_BIT: {
-
stack[level] = (VISIT_RIGHT_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = bvh.left | TEST_AABB_BIT;
level++;
}
continue;
case VISIT_RIGHT_BIT: {
-
stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node;
stack[level + 1] = bvh.right | TEST_AABB_BIT;
level++;
}
continue;
case VISIT_DONE_BIT: {
-
- if (level == 0)
+ if (level == 0) {
return;
- else
+ } else {
level--;
+ }
}
continue;
}
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index ca001e6dd9..eca284f7a4 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -57,7 +57,6 @@ public:
};
class Shape2DSW {
-
RID self;
Rect2 aabb;
bool configured;
@@ -100,13 +99,12 @@ public:
const Map<ShapeOwner2DSW *, int> &get_owners() const;
_FORCE_INLINE_ void get_supports_transformed_cast(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_xform, Vector2 *r_supports, int &r_amount) const {
-
get_supports(p_xform.basis_xform_inv(p_normal).normalized(), r_supports, r_amount);
- for (int i = 0; i < r_amount; i++)
+ for (int i = 0; i < r_amount; i++) {
r_supports[i] = p_xform.xform(r_supports[i]);
+ }
if (r_amount == 1) {
-
if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
//make line because they are parallel
r_amount = 2;
@@ -117,7 +115,6 @@ public:
}
} else {
-
if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) {
//optimize line and make it larger because they are parallel
if ((r_supports[1] - r_supports[0]).dot(p_cast) > 0) {
@@ -145,7 +142,6 @@ public:
project_range_cast(p_cast, p_normal, p_transform, r_min, r_max); \
} \
_FORCE_INLINE_ void project_range_cast(const Vector2 &p_cast, const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { \
- \
real_t mina, maxa; \
real_t minb, maxb; \
Transform2D ofsb = p_transform; \
@@ -157,7 +153,6 @@ public:
}
class LineShape2DSW : public Shape2DSW {
-
Vector2 normal;
real_t d;
@@ -195,7 +190,6 @@ public:
};
class RayShape2DSW : public Shape2DSW {
-
real_t length;
bool slips_on_slope;
@@ -220,7 +214,6 @@ public:
r_max = p_normal.dot(p_transform.get_origin());
r_min = p_normal.dot(p_transform.xform(Vector2(0, length)));
if (r_max < r_min) {
-
SWAP(r_max, r_min);
}
}
@@ -232,7 +225,6 @@ public:
};
class SegmentShape2DSW : public Shape2DSW {
-
Vector2 a;
Vector2 b;
Vector2 n;
@@ -245,7 +237,6 @@ public:
virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_SEGMENT; }
_FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const {
-
return (p_xform.xform(b) - p_xform.xform(a)).normalized().tangent();
}
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); }
@@ -263,7 +254,6 @@ public:
r_max = p_normal.dot(p_transform.xform(a));
r_min = p_normal.dot(p_transform.xform(b));
if (r_max < r_min) {
-
SWAP(r_max, r_min);
}
}
@@ -279,7 +269,6 @@ public:
};
class CircleShape2DSW : public Shape2DSW {
-
real_t radius;
public:
@@ -313,7 +302,6 @@ public:
};
class RectangleShape2DSW : public Shape2DSW {
-
Vector2 half_extents;
public:
@@ -336,18 +324,18 @@ public:
r_max = -1e20;
r_min = 1e20;
for (int i = 0; i < 4; i++) {
-
real_t d = p_normal.dot(p_transform.xform(Vector2(((i & 1) * 2 - 1) * half_extents.x, ((i >> 1) * 2 - 1) * half_extents.y)));
- if (d > r_max)
+ if (d > r_max) {
r_max = d;
- if (d < r_min)
+ }
+ if (d < r_min) {
r_min = d;
+ }
}
}
_FORCE_INLINE_ Vector2 get_circle_axis(const Transform2D &p_xform, const Transform2D &p_xform_inv, const Vector2 &p_circle) const {
-
Vector2 local_v = p_xform_inv.xform(p_circle);
Vector2 he(
@@ -358,7 +346,6 @@ public:
}
_FORCE_INLINE_ Vector2 get_box_axis(const Transform2D &p_xform, const Transform2D &p_xform_inv, const RectangleShape2DSW *p_B, const Transform2D &p_B_xform, const Transform2D &p_B_xform_inv) const {
-
Vector2 a, b;
{
@@ -387,7 +374,6 @@ public:
};
class CapsuleShape2DSW : public Shape2DSW {
-
real_t radius;
real_t height;
@@ -419,7 +405,6 @@ public:
r_min = p_normal.dot(p_transform.xform(-n));
if (r_max < r_min) {
-
SWAP(r_max, r_min);
}
@@ -430,9 +415,7 @@ public:
};
class ConvexPolygonShape2DSW : public Shape2DSW {
-
struct Point {
-
Vector2 pos;
Vector2 normal; //normal to next segment
};
@@ -445,7 +428,6 @@ public:
_FORCE_INLINE_ const Vector2 &get_point(int p_idx) const { return points[p_idx].pos; }
_FORCE_INLINE_ const Vector2 &get_segment_normal(int p_idx) const { return points[p_idx].normal; }
_FORCE_INLINE_ Vector2 get_xformed_segment_normal(const Transform2D &p_xform, int p_idx) const {
-
Vector2 a = points[p_idx].pos;
p_idx++;
Vector2 b = points[p_idx == point_count ? 0 : p_idx].pos;
@@ -465,7 +447,6 @@ public:
virtual Variant get_data() const;
_FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const {
-
if (!points || point_count <= 0) {
r_min = r_max = 0;
return;
@@ -473,12 +454,13 @@ public:
r_min = r_max = p_normal.dot(p_transform.xform(points[0].pos));
for (int i = 1; i < point_count; i++) {
-
real_t d = p_normal.dot(p_transform.xform(points[i].pos));
- if (d > r_max)
+ if (d > r_max) {
r_max = d;
- if (d < r_min)
+ }
+ if (d < r_min) {
r_min = d;
+ }
}
}
@@ -489,7 +471,6 @@ public:
};
class ConcaveShape2DSW : public Shape2DSW {
-
public:
virtual bool is_concave() const { return true; }
typedef void (*Callback)(void *p_userdata, Shape2DSW *p_convex);
@@ -498,9 +479,7 @@ public:
};
class ConcavePolygonShape2DSW : public ConcaveShape2DSW {
-
struct Segment {
-
int points[2];
};
@@ -508,7 +487,6 @@ class ConcavePolygonShape2DSW : public ConcaveShape2DSW {
Vector<Point2> points;
struct BVH {
-
Rect2 aabb;
int left, right;
};
@@ -517,17 +495,13 @@ class ConcavePolygonShape2DSW : public ConcaveShape2DSW {
int bvh_depth;
struct BVH_CompareX {
-
_FORCE_INLINE_ bool operator()(const BVH &a, const BVH &b) const {
-
return (a.aabb.position.x + a.aabb.size.x * 0.5) < (b.aabb.position.x + b.aabb.size.x * 0.5);
}
};
struct BVH_CompareY {
-
_FORCE_INLINE_ bool operator()(const BVH &a, const BVH &b) const {
-
return (a.aabb.position.y + a.aabb.size.y * 0.5) < (b.aabb.position.y + b.aabb.size.y * 0.5);
}
};
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 6bf6c4e3ad..966dcbd651 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -35,24 +35,25 @@
#include "core/pair.h"
#include "physics_server_2d_sw.h"
_FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
if (!(p_object->get_collision_layer() & p_collision_mask)) {
return false;
}
- if (p_object->get_type() == CollisionObject2DSW::TYPE_AREA && !p_collide_with_areas)
+ if (p_object->get_type() == CollisionObject2DSW::TYPE_AREA && !p_collide_with_areas) {
return false;
+ }
- if (p_object->get_type() == CollisionObject2DSW::TYPE_BODY && !p_collide_with_bodies)
+ if (p_object->get_type() == CollisionObject2DSW::TYPE_BODY && !p_collide_with_bodies) {
return false;
+ }
return true;
}
int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
-
- if (p_result_max <= 0)
+ if (p_result_max <= 0) {
return 0;
+ }
Rect2 aabb;
aabb.position = p_point - Vector2(0.00001, 0.00001);
@@ -63,20 +64,23 @@ int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, S
int cc = 0;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue;
+ }
const CollisionObject2DSW *col_obj = space->intersection_query_results[i];
- if (p_pick_point && !col_obj->is_pickable())
+ if (p_pick_point && !col_obj->is_pickable()) {
continue;
+ }
- if (p_filter_by_canvas && col_obj->get_canvas_instance_id() != p_canvas_instance_id)
+ if (p_filter_by_canvas && col_obj->get_canvas_instance_id() != p_canvas_instance_id) {
continue;
+ }
int shape_idx = space->intersection_query_subindex_results[i];
@@ -84,15 +88,18 @@ int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, S
Vector2 local_point = (col_obj->get_transform() * col_obj->get_shape_transform(shape_idx)).affine_inverse().xform(p_point);
- if (!shape->contains_point(local_point))
+ if (!shape->contains_point(local_point)) {
continue;
+ }
- if (cc >= p_result_max)
+ if (cc >= p_result_max) {
continue;
+ }
r_results[cc].collider_id = col_obj->get_instance_id();
- if (r_results[cc].collider_id.is_valid())
+ if (r_results[cc].collider_id.is_valid()) {
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
+ }
r_results[cc].rid = col_obj->get_self();
r_results[cc].shape = shape_idx;
r_results[cc].metadata = col_obj->get_shape_metadata(shape_idx);
@@ -104,17 +111,14 @@ int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, S
}
int PhysicsDirectSpaceState2DSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) {
-
return _intersect_point_impl(p_point, r_results, p_result_max, p_exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_point);
}
int PhysicsDirectSpaceState2DSW::intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_instance_id, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) {
-
return _intersect_point_impl(p_point, r_results, p_result_max, p_exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_point, true, p_canvas_instance_id);
}
bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
ERR_FAIL_COND_V(space->locked, false);
Vector2 begin, end;
@@ -134,12 +138,13 @@ bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vec
real_t min_d = 1e10;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue;
+ }
const CollisionObject2DSW *col_obj = space->intersection_query_results[i];
@@ -160,14 +165,12 @@ bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vec
Vector2 shape_point, shape_normal;
if (shape->intersect_segment(local_from, local_to, shape_point, shape_normal)) {
-
Transform2D xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
shape_point = xform.xform(shape_point);
real_t ld = normal.dot(shape_point);
if (ld < min_d) {
-
min_d = ld;
res_point = shape_point;
res_normal = inv_xform.basis_xform_inv(shape_normal).normalized();
@@ -178,12 +181,14 @@ bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vec
}
}
- if (!collided)
+ if (!collided) {
return false;
+ }
r_result.collider_id = res_obj->get_instance_id();
- if (r_result.collider_id.is_valid())
+ if (r_result.collider_id.is_valid()) {
r_result.collider = ObjectDB::get_instance(r_result.collider_id);
+ }
r_result.normal = res_normal;
r_result.metadata = res_obj->get_shape_metadata(res_shape);
r_result.position = res_point;
@@ -194,9 +199,9 @@ bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vec
}
int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
- if (p_result_max <= 0)
+ if (p_result_max <= 0) {
return 0;
+ }
Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -209,25 +214,29 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
int cc = 0;
for (int i = 0; i < amount; i++) {
-
- if (cc >= p_result_max)
+ if (cc >= p_result_max) {
break;
+ }
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue;
+ }
const CollisionObject2DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
- if (!CollisionSolver2DSW::solve(shape, p_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), nullptr, nullptr, nullptr, p_margin))
+ if (!CollisionSolver2DSW::solve(shape, p_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), nullptr, nullptr, nullptr, p_margin)) {
continue;
+ }
r_results[cc].collider_id = col_obj->get_instance_id();
- if (r_results[cc].collider_id.is_valid())
+ if (r_results[cc].collider_id.is_valid()) {
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
+ }
r_results[cc].rid = col_obj->get_self();
r_results[cc].shape = shape_idx;
r_results[cc].metadata = col_obj->get_shape_metadata(shape_idx);
@@ -239,7 +248,6 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans
}
bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, false);
@@ -253,12 +261,13 @@ bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transfor
real_t best_unsafe = 1;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue; //ignore excluded
+ }
const CollisionObject2DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
@@ -271,7 +280,6 @@ bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transfor
//test initial overlap
if (CollisionSolver2DSW::solve(shape, p_xform, Vector2(), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, nullptr, p_margin)) {
-
return false;
}
@@ -288,10 +296,8 @@ bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transfor
bool collided = CollisionSolver2DSW::solve(shape, p_xform, p_motion * ofs, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, &sep, p_margin);
if (collided) {
-
hi = ofs;
} else {
-
low = ofs;
}
}
@@ -309,9 +315,9 @@ bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transfor
}
bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
- if (p_result_max <= 0)
- return 0;
+ if (p_result_max <= 0) {
+ return false;
+ }
Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -335,15 +341,16 @@ bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &
PhysicsServer2DSW::CollCbkData *cbkptr = &cbk;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
const CollisionObject2DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
- if (p_exclude.has(col_obj->get_self()))
+ if (p_exclude.has(col_obj->get_self())) {
continue;
+ }
cbk.valid_dir = Vector2();
cbk.valid_depth = 0;
@@ -359,7 +366,6 @@ bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &
}
struct _RestCallbackData2D {
-
const CollisionObject2DSW *object;
const CollisionObject2DSW *best_object;
int local_shape;
@@ -375,24 +381,27 @@ struct _RestCallbackData2D {
};
static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) {
-
_RestCallbackData2D *rd = (_RestCallbackData2D *)p_userdata;
if (rd->valid_dir != Vector2()) {
- if (p_point_A.distance_squared_to(p_point_B) > rd->valid_depth * rd->valid_depth)
+ if (p_point_A.distance_squared_to(p_point_B) > rd->valid_depth * rd->valid_depth) {
return;
- if (rd->valid_dir.dot((p_point_A - p_point_B).normalized()) < Math_PI * 0.25)
+ }
+ if (rd->valid_dir.dot((p_point_A - p_point_B).normalized()) < Math_PI * 0.25) {
return;
+ }
}
Vector2 contact_rel = p_point_B - p_point_A;
real_t len = contact_rel.length();
- if (len < rd->min_allowed_depth)
+ if (len < rd->min_allowed_depth) {
return;
+ }
- if (len <= rd->best_len)
+ if (len <= rd->best_len) {
return;
+ }
rd->best_len = len;
rd->best_contact = p_point_B;
@@ -403,7 +412,6 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
}
bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -420,15 +428,16 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
rcd.min_allowed_depth = space->test_motion_min_contact_depth;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
const CollisionObject2DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
- if (p_exclude.has(col_obj->get_self()))
+ if (p_exclude.has(col_obj->get_self())) {
continue;
+ }
rcd.valid_dir = Vector2();
rcd.valid_depth = 0;
@@ -436,12 +445,14 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
rcd.shape = shape_idx;
rcd.local_shape = 0;
bool sc = CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), _rest_cbk_result, &rcd, nullptr, p_margin);
- if (!sc)
+ if (!sc) {
continue;
+ }
}
- if (rcd.best_len == 0 || !rcd.best_object)
+ if (rcd.best_len == 0 || !rcd.best_object) {
return false;
+ }
r_info->collider_id = rcd.best_object->get_instance_id();
r_info->shape = rcd.best_shape;
@@ -450,7 +461,6 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
r_info->rid = rcd.best_object->get_self();
r_info->metadata = rcd.best_object->get_shape_metadata(rcd.best_shape);
if (rcd.best_object->get_type() == CollisionObject2DSW::TYPE_BODY) {
-
const Body2DSW *body = static_cast<const Body2DSW *>(rcd.best_object);
Vector2 rel_vec = r_info->point - body->get_transform().get_origin();
r_info->linear_velocity = Vector2(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity();
@@ -463,33 +473,30 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
}
PhysicsDirectSpaceState2DSW::PhysicsDirectSpaceState2DSW() {
-
space = nullptr;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body, const Rect2 &p_aabb) {
-
int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results);
for (int i = 0; i < amount; i++) {
-
bool keep = true;
- if (intersection_query_results[i] == p_body)
+ if (intersection_query_results[i] == p_body) {
keep = false;
- else if (intersection_query_results[i]->get_type() == CollisionObject2DSW::TYPE_AREA)
+ } else if (intersection_query_results[i]->get_type() == CollisionObject2DSW::TYPE_AREA) {
keep = false;
- else if ((static_cast<Body2DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0)
+ } else if ((static_cast<Body2DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0) {
keep = false;
- else if (static_cast<Body2DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
+ } else if (static_cast<Body2DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) {
keep = false;
- else if (static_cast<Body2DSW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i]))
+ } else if (static_cast<Body2DSW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i])) {
keep = false;
+ }
if (!keep) {
-
if (i < amount - 1) {
SWAP(intersection_query_results[i], intersection_query_results[amount - 1]);
SWAP(intersection_query_subindex_results[i], intersection_query_subindex_results[amount - 1]);
@@ -504,18 +511,18 @@ int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body, const Rect2 &p_aabb) {
}
int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, PhysicsServer2D::SeparationResult *r_results, int p_result_max, real_t p_margin) {
-
Rect2 body_aabb;
bool shapes_found = false;
for (int i = 0; i < p_body->get_shape_count(); i++) {
-
- if (p_body->is_shape_set_as_disabled(i))
+ if (p_body->is_shape_set_as_disabled(i)) {
continue;
+ }
- if (p_body->get_shape(i)->get_type() != PhysicsServer2D::SHAPE_RAY)
+ if (p_body->get_shape(i)->get_type() != PhysicsServer2D::SHAPE_RAY) {
continue;
+ }
if (!shapes_found) {
body_aabb = p_body->get_shape_aabb(i);
@@ -554,7 +561,6 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk;
do {
-
Vector2 recover_motion;
bool collided = false;
@@ -562,18 +568,19 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
int amount = _cull_aabb_for_body(p_body, body_aabb);
for (int j = 0; j < p_body->get_shape_count(); j++) {
- if (p_body->is_shape_set_as_disabled(j))
+ if (p_body->is_shape_set_as_disabled(j)) {
continue;
+ }
Shape2DSW *body_shape = p_body->get_shape(j);
- if (body_shape->get_type() != PhysicsServer2D::SHAPE_RAY)
+ if (body_shape->get_type() != PhysicsServer2D::SHAPE_RAY) {
continue;
+ }
Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j);
for (int i = 0; i < amount; i++) {
-
const CollisionObject2DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
@@ -631,7 +638,6 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
}
if (ray_index != -1) {
-
PhysicsServer2D::SeparationResult &result = r_results[ray_index];
for (int k = 0; k < cbk.amount; k++) {
@@ -642,7 +648,6 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
float depth = a.distance_to(b);
if (depth > result.collision_depth) {
-
result.collision_depth = depth;
result.collision_point = b;
result.collision_normal = (b - a).normalized();
@@ -688,7 +693,6 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
}
bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
-
//give me back regular physics engine logic
//this is madness
//and most people using this function will think
@@ -705,12 +709,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool shapes_found = false;
for (int i = 0; i < p_body->get_shape_count(); i++) {
-
- if (p_body->is_shape_set_as_disabled(i))
+ if (p_body->is_shape_set_as_disabled(i)) {
continue;
+ }
- if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == PhysicsServer2D::SHAPE_RAY)
+ if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == PhysicsServer2D::SHAPE_RAY) {
continue;
+ }
if (!shapes_found) {
body_aabb = p_body->get_shape_aabb(i);
@@ -748,7 +753,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Vector2 sr[max_results * 2];
do {
-
PhysicsServer2DSW::CollCbkData cbk;
cbk.max = max_results;
cbk.amount = 0;
@@ -765,8 +769,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
int amount = _cull_aabb_for_body(p_body, body_aabb);
for (int j = 0; j < p_body->get_shape_count(); j++) {
- if (p_body->is_shape_set_as_disabled(j))
+ if (p_body->is_shape_set_as_disabled(j)) {
continue;
+ }
Shape2DSW *body_shape = p_body->get_shape(j);
if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) {
@@ -775,7 +780,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j);
for (int i = 0; i < amount; i++) {
-
const CollisionObject2DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
@@ -789,7 +793,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) {
-
cbk.valid_dir = col_obj_shape_xform.get_axis(1).normalized();
float owc_margin = col_obj->get_shape_one_way_collision_margin(shape_idx);
@@ -846,7 +849,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Vector2 recover_motion;
for (int i = 0; i < cbk.amount; i++) {
-
Vector2 a = sr[i * 2 + 0];
Vector2 b = sr[i * 2 + 1];
recover_motion += (b - a) * 0.4;
@@ -879,9 +881,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
int amount = _cull_aabb_for_body(p_body, motion_aabb);
for (int body_shape_idx = 0; body_shape_idx < p_body->get_shape_count(); body_shape_idx++) {
-
- if (p_body->is_shape_set_as_disabled(body_shape_idx))
+ if (p_body->is_shape_set_as_disabled(body_shape_idx)) {
continue;
+ }
Shape2DSW *body_shape = p_body->get_shape(body_shape_idx);
if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) {
@@ -896,7 +898,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
real_t best_unsafe = 1;
for (int i = 0; i < amount; i++) {
-
const CollisionObject2DSW *col_obj = intersection_query_results[i];
int col_shape_idx = intersection_query_subindex_results[i];
Shape2DSW *against_shape = col_obj->get_shape(col_shape_idx);
@@ -911,7 +912,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool excluded = false;
for (int k = 0; k < excluded_shape_pair_count; k++) {
-
if (excluded_shape_pairs[k].local_shape == body_shape && excluded_shape_pairs[k].against_object == col_obj && excluded_shape_pairs[k].against_shape_index == col_shape_idx) {
excluded = true;
break;
@@ -919,7 +919,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
if (excluded) {
-
continue;
}
@@ -931,7 +930,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
//test initial overlap
if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, nullptr, 0)) {
-
if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) {
continue;
}
@@ -953,16 +951,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, &sep, 0);
if (collided) {
-
hi = ofs;
} else {
-
low = ofs;
}
}
if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) {
-
Vector2 cd[2];
PhysicsServer2DSW::CollCbkData cbk;
cbk.max = 1;
@@ -987,7 +982,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
if (stuck) {
-
safe = 0;
unsafe = 0;
best_shape = body_shape_idx; //sadly it's the best
@@ -997,7 +991,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
continue;
}
if (best_safe < safe) {
-
safe = best_safe;
unsafe = best_unsafe;
best_shape = body_shape_idx;
@@ -1011,7 +1004,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
{
-
//it collided, let's get the rest info in unsafe advance
Transform2D ugt = body_transform;
ugt.elements[2] += p_motion * unsafe;
@@ -1027,9 +1019,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
int to_shape = best_shape != -1 ? best_shape + 1 : p_body->get_shape_count();
for (int j = from_shape; j < to_shape; j++) {
-
- if (p_body->is_shape_set_as_disabled(j))
+ if (p_body->is_shape_set_as_disabled(j)) {
continue;
+ }
Transform2D body_shape_xform = ugt * p_body->get_shape_transform(j);
Shape2DSW *body_shape = p_body->get_shape(j);
@@ -1043,7 +1035,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
int amount = _cull_aabb_for_body(p_body, body_aabb);
for (int i = 0; i < amount; i++) {
-
const CollisionObject2DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
@@ -1058,19 +1049,18 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool excluded = false;
for (int k = 0; k < excluded_shape_pair_count; k++) {
-
if (excluded_shape_pairs[k].local_shape == body_shape && excluded_shape_pairs[k].against_object == col_obj && excluded_shape_pairs[k].against_shape_index == shape_idx) {
excluded = true;
break;
}
}
- if (excluded)
+ if (excluded) {
continue;
+ }
Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) {
-
rcd.valid_dir = col_obj_shape_xform.get_axis(1).normalized();
rcd.valid_depth = 10e20;
} else {
@@ -1082,13 +1072,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
rcd.shape = shape_idx;
rcd.local_shape = j;
bool sc = CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), _rest_cbk_result, &rcd, nullptr, p_margin);
- if (!sc)
+ if (!sc) {
continue;
+ }
}
}
if (rcd.best_len != 0) {
-
if (r_result) {
r_result->collider = rcd.best_object->get_self();
r_result->collider_id = rcd.best_object->get_instance_id();
@@ -1112,7 +1102,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
if (!collided && r_result) {
-
r_result->motion = p_motion;
r_result->remainder = Vector2();
r_result->motion += (body_transform.get_origin() - p_from.get_origin());
@@ -1122,11 +1111,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_self) {
+ if (!A->test_collision_mask(B)) {
+ return nullptr;
+ }
CollisionObject2DSW::Type type_A = A->get_type();
CollisionObject2DSW::Type type_B = B->get_type();
if (type_A > type_B) {
-
SWAP(A, B);
SWAP(p_subindex_A, p_subindex_B);
SWAP(type_A, type_B);
@@ -1136,22 +1127,18 @@ void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, Coll
self->collision_pairs++;
if (type_A == CollisionObject2DSW::TYPE_AREA) {
-
Area2DSW *area = static_cast<Area2DSW *>(A);
if (type_B == CollisionObject2DSW::TYPE_AREA) {
-
Area2DSW *area_b = static_cast<Area2DSW *>(B);
Area2Pair2DSW *area2_pair = memnew(Area2Pair2DSW(area_b, p_subindex_B, area, p_subindex_A));
return area2_pair;
} else {
-
Body2DSW *body = static_cast<Body2DSW *>(B);
AreaPair2DSW *area_pair = memnew(AreaPair2DSW(body, p_subindex_B, area, p_subindex_A));
return area_pair;
}
} else {
-
BodyPair2DSW *b = memnew(BodyPair2DSW((Body2DSW *)A, p_subindex_A, (Body2DSW *)B, p_subindex_B));
return b;
}
@@ -1160,6 +1147,9 @@ void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, Coll
}
void Space2DSW::_broadphase_unpair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_data, void *p_self) {
+ if (!p_data) {
+ return;
+ }
Space2DSW *self = (Space2DSW *)p_self;
self->collision_pairs--;
@@ -1168,94 +1158,79 @@ void Space2DSW::_broadphase_unpair(CollisionObject2DSW *A, int p_subindex_A, Col
}
const SelfList<Body2DSW>::List &Space2DSW::get_active_body_list() const {
-
return active_list;
}
-void Space2DSW::body_add_to_active_list(SelfList<Body2DSW> *p_body) {
+void Space2DSW::body_add_to_active_list(SelfList<Body2DSW> *p_body) {
active_list.add(p_body);
}
-void Space2DSW::body_remove_from_active_list(SelfList<Body2DSW> *p_body) {
+void Space2DSW::body_remove_from_active_list(SelfList<Body2DSW> *p_body) {
active_list.remove(p_body);
}
void Space2DSW::body_add_to_inertia_update_list(SelfList<Body2DSW> *p_body) {
-
inertia_update_list.add(p_body);
}
void Space2DSW::body_remove_from_inertia_update_list(SelfList<Body2DSW> *p_body) {
-
inertia_update_list.remove(p_body);
}
BroadPhase2DSW *Space2DSW::get_broadphase() {
-
return broadphase;
}
void Space2DSW::add_object(CollisionObject2DSW *p_object) {
-
ERR_FAIL_COND(objects.has(p_object));
objects.insert(p_object);
}
void Space2DSW::remove_object(CollisionObject2DSW *p_object) {
-
ERR_FAIL_COND(!objects.has(p_object));
objects.erase(p_object);
}
const Set<CollisionObject2DSW *> &Space2DSW::get_objects() const {
-
return objects;
}
void Space2DSW::body_add_to_state_query_list(SelfList<Body2DSW> *p_body) {
-
state_query_list.add(p_body);
}
-void Space2DSW::body_remove_from_state_query_list(SelfList<Body2DSW> *p_body) {
+void Space2DSW::body_remove_from_state_query_list(SelfList<Body2DSW> *p_body) {
state_query_list.remove(p_body);
}
void Space2DSW::area_add_to_monitor_query_list(SelfList<Area2DSW> *p_area) {
-
monitor_query_list.add(p_area);
}
-void Space2DSW::area_remove_from_monitor_query_list(SelfList<Area2DSW> *p_area) {
+void Space2DSW::area_remove_from_monitor_query_list(SelfList<Area2DSW> *p_area) {
monitor_query_list.remove(p_area);
}
void Space2DSW::area_add_to_moved_list(SelfList<Area2DSW> *p_area) {
-
area_moved_list.add(p_area);
}
void Space2DSW::area_remove_from_moved_list(SelfList<Area2DSW> *p_area) {
-
area_moved_list.remove(p_area);
}
const SelfList<Area2DSW>::List &Space2DSW::get_moved_area_list() const {
-
return area_moved_list;
}
void Space2DSW::call_queries() {
-
while (state_query_list.first()) {
-
Body2DSW *b = state_query_list.first()->self();
state_query_list.remove(state_query_list.first());
b->call_queries();
}
while (monitor_query_list.first()) {
-
Area2DSW *a = monitor_query_list.first()->self();
monitor_query_list.remove(monitor_query_list.first());
a->call_queries();
@@ -1263,7 +1238,6 @@ void Space2DSW::call_queries() {
}
void Space2DSW::setup() {
-
contact_debug_count = 0;
while (inertia_update_list.first()) {
@@ -1273,14 +1247,11 @@ void Space2DSW::setup() {
}
void Space2DSW::update() {
-
broadphase->update();
}
void Space2DSW::set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value) {
-
switch (p_param) {
-
case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
contact_recycle_radius = p_value;
break;
@@ -1309,9 +1280,7 @@ void Space2DSW::set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_valu
}
real_t Space2DSW::get_param(PhysicsServer2D::SpaceParameter p_param) const {
-
switch (p_param) {
-
case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
return contact_recycle_radius;
case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
@@ -1333,27 +1302,22 @@ real_t Space2DSW::get_param(PhysicsServer2D::SpaceParameter p_param) const {
}
void Space2DSW::lock() {
-
locked = true;
}
void Space2DSW::unlock() {
-
locked = false;
}
bool Space2DSW::is_locked() const {
-
return locked;
}
PhysicsDirectSpaceState2DSW *Space2DSW::get_direct_state() {
-
return direct_access;
}
Space2DSW::Space2DSW() {
-
collision_pairs = 0;
active_objects = 0;
island_count = 0;
@@ -1380,12 +1344,12 @@ Space2DSW::Space2DSW() {
direct_access = memnew(PhysicsDirectSpaceState2DSW);
direct_access->space = this;
- for (int i = 0; i < ELAPSED_TIME_MAX; i++)
+ for (int i = 0; i < ELAPSED_TIME_MAX; i++) {
elapsed_time[i] = 0;
+ }
}
Space2DSW::~Space2DSW() {
-
memdelete(broadphase);
memdelete(direct_access);
}
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index e87d842ef1..0a96f2f495 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -42,7 +42,6 @@
#include "core/typedefs.h"
class PhysicsDirectSpaceState2DSW : public PhysicsDirectSpaceState2D {
-
GDCLASS(PhysicsDirectSpaceState2DSW, PhysicsDirectSpaceState2D);
int _intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas = false, ObjectID p_canvas_instance_id = ObjectID());
@@ -62,7 +61,6 @@ public:
};
class Space2DSW {
-
public:
enum ElapsedTime {
ELAPSED_TIME_INTEGRATE_FORCES,
@@ -192,8 +190,9 @@ public:
void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); }
_FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.empty(); }
_FORCE_INLINE_ void add_debug_contact(const Vector2 &p_contact) {
- if (contact_debug_count < contact_debug.size())
+ if (contact_debug_count < contact_debug.size()) {
contact_debug.write[contact_debug_count++] = p_contact;
+ }
}
_FORCE_INLINE_ Vector<Vector2> get_debug_contacts() { return contact_debug; }
_FORCE_INLINE_ int get_debug_contact_count() { return contact_debug_count; }
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp
index 6f3bcfec13..c7711bcd1d 100644
--- a/servers/physics_2d/step_2d_sw.cpp
+++ b/servers/physics_2d/step_2d_sw.cpp
@@ -32,33 +32,33 @@
#include "core/os/os.h"
void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constraint2DSW **p_constraint_island) {
-
p_body->set_island_step(_step);
p_body->set_island_next(*p_island);
*p_island = p_body;
for (Map<Constraint2DSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) {
-
Constraint2DSW *c = (Constraint2DSW *)E->key();
- if (c->get_island_step() == _step)
+ if (c->get_island_step() == _step) {
continue; //already processed
+ }
c->set_island_step(_step);
c->set_island_next(*p_constraint_island);
*p_constraint_island = c;
for (int i = 0; i < c->get_body_count(); i++) {
- if (i == E->get())
+ if (i == E->get()) {
continue;
+ }
Body2DSW *b = c->get_body_ptr()[i];
- if (b->get_island_step() == _step || b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC)
+ if (b->get_island_step() == _step || b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) {
continue; //no go
+ }
_populate_island(c->get_body_ptr()[i], p_island, p_constraint_island);
}
}
}
bool Step2DSW::_setup_island(Constraint2DSW *p_island, real_t p_delta) {
-
Constraint2DSW *ci = p_island;
Constraint2DSW *prev_ci = nullptr;
bool removed_root = false;
@@ -83,9 +83,7 @@ bool Step2DSW::_setup_island(Constraint2DSW *p_island, real_t p_delta) {
}
void Step2DSW::_solve_island(Constraint2DSW *p_island, int p_iterations, real_t p_delta) {
-
for (int i = 0; i < p_iterations; i++) {
-
Constraint2DSW *ci = p_island;
while (ci) {
ci->solve(p_delta);
@@ -95,19 +93,18 @@ void Step2DSW::_solve_island(Constraint2DSW *p_island, int p_iterations, real_t
}
void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) {
-
bool can_sleep = true;
Body2DSW *b = p_island;
while (b) {
-
if (b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
}
- if (!b->sleep_test(p_delta))
+ if (!b->sleep_test(p_delta)) {
can_sleep = false;
+ }
b = b->get_island_next();
}
@@ -116,7 +113,6 @@ void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) {
b = p_island;
while (b) {
-
if (b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
@@ -124,15 +120,15 @@ void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) {
bool active = b->is_active();
- if (active == can_sleep)
+ if (active == can_sleep) {
b->set_active(!can_sleep);
+ }
b = b->get_island_next();
}
}
void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
-
p_space->lock(); // can't access space during this
p_space->setup(); //update inertias, etc
@@ -148,7 +144,6 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
const SelfList<Body2DSW> *b = body_list->first();
while (b) {
-
b->self()->integrate_forces(p_delta);
b = b->next();
active_count++;
@@ -174,7 +169,6 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
Body2DSW *body = b->self();
if (body->get_island_step() != _step) {
-
Body2DSW *island = nullptr;
Constraint2DSW *constraint_island = nullptr;
_populate_island(body, &island, &constraint_island);
@@ -197,10 +191,10 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
while (aml.first()) {
for (const Set<Constraint2DSW *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) {
-
Constraint2DSW *c = E->get();
- if (c->get_island_step() == _step)
+ if (c->get_island_step() == _step) {
continue;
+ }
c->set_island_step(_step);
c->set_island_next(nullptr);
c->set_island_list_next(constraint_island_list);
@@ -221,9 +215,7 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
Constraint2DSW *ci = constraint_island_list;
Constraint2DSW *prev_ci = nullptr;
while (ci) {
-
if (_setup_island(ci, p_delta)) {
-
//removed the root from the island graph because it is not to be processed
Constraint2DSW *next = ci->get_island_next();
@@ -238,7 +230,6 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
}
prev_ci = next;
} else {
-
//list is empty, just skip
if (prev_ci) {
prev_ci->set_island_list_next(ci->get_island_list_next());
@@ -282,7 +273,6 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
b = body_list->first();
while (b) {
-
const SelfList<Body2DSW> *n = b->next();
b->self()->integrate_velocities(p_delta);
b = n; // in case it shuts itself down
@@ -293,7 +283,6 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
{
Body2DSW *bi = island_list;
while (bi) {
-
_check_suspend(bi, p_delta);
bi = bi->get_island_list_next();
}
@@ -311,6 +300,5 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
}
Step2DSW::Step2DSW() {
-
_step = 1;
}
diff --git a/servers/physics_2d/step_2d_sw.h b/servers/physics_2d/step_2d_sw.h
index 22d59b729b..c1b2d01fb4 100644
--- a/servers/physics_2d/step_2d_sw.h
+++ b/servers/physics_2d/step_2d_sw.h
@@ -34,7 +34,6 @@
#include "space_2d_sw.h"
class Step2DSW {
-
uint64_t _step;
void _populate_island(Body2DSW *p_body, Body2DSW **p_island, Constraint2DSW **p_constraint_island);
diff --git a/servers/physics_3d/area_3d_sw.cpp b/servers/physics_3d/area_3d_sw.cpp
index 2367b653a5..98237dd91c 100644
--- a/servers/physics_3d/area_3d_sw.cpp
+++ b/servers/physics_3d/area_3d_sw.cpp
@@ -38,6 +38,7 @@ Area3DSW::BodyKey::BodyKey(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_a
body_shape = p_body_shape;
area_shape = p_area_shape;
}
+
Area3DSW::BodyKey::BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
rid = p_body->get_self();
instance_id = p_body->get_instance_id();
@@ -46,27 +47,28 @@ Area3DSW::BodyKey::BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_a
}
void Area3DSW::_shapes_changed() {
-
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
}
void Area3DSW::set_transform(const Transform &p_transform) {
-
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
_set_transform(p_transform);
_set_inv_transform(p_transform.affine_inverse());
}
void Area3DSW::set_space(Space3DSW *p_space) {
-
if (get_space()) {
- if (monitor_query_list.in_list())
+ if (monitor_query_list.in_list()) {
get_space()->area_remove_from_monitor_query_list(&monitor_query_list);
- if (moved_list.in_list())
+ }
+ if (moved_list.in_list()) {
get_space()->area_remove_from_moved_list(&moved_list);
+ }
}
monitored_bodies.clear();
@@ -76,7 +78,6 @@ void Area3DSW::set_space(Space3DSW *p_space) {
}
void Area3DSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
-
if (p_id == monitor_callback_id) {
monitor_callback_method = p_method;
return;
@@ -92,12 +93,12 @@ void Area3DSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) {
_shape_changed();
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
}
void Area3DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method) {
-
if (p_id == area_monitor_callback_id) {
area_monitor_callback_method = p_method;
return;
@@ -113,21 +114,22 @@ void Area3DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_meth
_shape_changed();
- if (!moved_list.in_list() && get_space())
+ if (!moved_list.in_list() && get_space()) {
get_space()->area_add_to_moved_list(&moved_list);
+ }
}
void Area3DSW::set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) {
bool do_override = p_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
- if (do_override == (space_override_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED))
+ if (do_override == (space_override_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)) {
return;
+ }
_unregister_shapes();
space_override_mode = p_mode;
_shape_changed();
}
void Area3DSW::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
-
switch (p_param) {
case PhysicsServer3D::AREA_PARAM_GRAVITY:
gravity = p_value;
@@ -157,7 +159,6 @@ void Area3DSW::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &
}
Variant Area3DSW::get_param(PhysicsServer3D::AreaParameter p_param) const {
-
switch (p_param) {
case PhysicsServer3D::AREA_PARAM_GRAVITY:
return gravity;
@@ -181,30 +182,29 @@ Variant Area3DSW::get_param(PhysicsServer3D::AreaParameter p_param) const {
}
void Area3DSW::_queue_monitor_update() {
-
ERR_FAIL_COND(!get_space());
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
get_space()->area_add_to_monitor_query_list(&monitor_query_list);
+ }
}
void Area3DSW::set_monitorable(bool p_monitorable) {
-
- if (monitorable == p_monitorable)
+ if (monitorable == p_monitorable) {
return;
+ }
monitorable = p_monitorable;
_set_static(!monitorable);
}
void Area3DSW::call_queries() {
-
if (monitor_callback_id.is_valid() && !monitored_bodies.empty()) {
-
Variant res[5];
Variant *resptr[5];
- for (int i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++) {
resptr[i] = &res[i];
+ }
Object *obj = ObjectDB::get_instance(monitor_callback_id);
if (!obj) {
@@ -214,9 +214,9 @@ void Area3DSW::call_queries() {
}
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E; E = E->next()) {
-
- if (E->get().state == 0)
+ if (E->get().state == 0) {
continue; //nothing happened
+ }
res[0] = E->get().state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
@@ -232,11 +232,11 @@ void Area3DSW::call_queries() {
monitored_bodies.clear();
if (area_monitor_callback_id.is_valid() && !monitored_areas.empty()) {
-
Variant res[5];
Variant *resptr[5];
- for (int i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++) {
resptr[i] = &res[i];
+ }
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
if (!obj) {
@@ -246,9 +246,9 @@ void Area3DSW::call_queries() {
}
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E; E = E->next()) {
-
- if (E->get().state == 0)
+ if (E->get().state == 0) {
continue; //nothing happened
+ }
res[0] = E->get().state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED;
res[1] = E->key().rid;
@@ -269,7 +269,6 @@ Area3DSW::Area3DSW() :
CollisionObject3DSW(TYPE_AREA),
monitor_query_list(this),
moved_list(this) {
-
_set_static(true); //areas are never active
space_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
gravity = 9.80665;
diff --git a/servers/physics_3d/area_3d_sw.h b/servers/physics_3d/area_3d_sw.h
index 05e74e63dc..6af3976167 100644
--- a/servers/physics_3d/area_3d_sw.h
+++ b/servers/physics_3d/area_3d_sw.h
@@ -41,7 +41,6 @@ class Body3DSW;
class Constraint3DSW;
class Area3DSW : public CollisionObject3DSW {
-
PhysicsServer3D::AreaSpaceOverrideMode space_override_mode;
real_t gravity;
Vector3 gravity_vector;
@@ -63,23 +62,21 @@ class Area3DSW : public CollisionObject3DSW {
SelfList<Area3DSW> moved_list;
struct BodyKey {
-
RID rid;
ObjectID instance_id;
uint32_t body_shape;
uint32_t area_shape;
_FORCE_INLINE_ bool operator<(const BodyKey &p_key) const {
-
if (rid == p_key.rid) {
-
if (body_shape == p_key.body_shape) {
-
return area_shape < p_key.area_shape;
- } else
+ } else {
return body_shape < p_key.body_shape;
- } else
+ }
+ } else {
return rid < p_key.rid;
+ }
}
_FORCE_INLINE_ BodyKey() {}
@@ -88,7 +85,6 @@ class Area3DSW : public CollisionObject3DSW {
};
struct BodyState {
-
int state;
_FORCE_INLINE_ void inc() { state++; }
_FORCE_INLINE_ void dec() { state--; }
@@ -171,33 +167,35 @@ public:
};
void Area3DSW::add_body_to_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
-
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].inc();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
-void Area3DSW::remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
+void Area3DSW::remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) {
BodyKey bk(p_body, p_body_shape, p_area_shape);
monitored_bodies[bk].dec();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
void Area3DSW::add_area_to_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
-
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].inc();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
-void Area3DSW::remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
+void Area3DSW::remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) {
BodyKey bk(p_area, p_area_shape, p_self_shape);
monitored_areas[bk].dec();
- if (!monitor_query_list.in_list())
+ if (!monitor_query_list.in_list()) {
_queue_monitor_update();
+ }
}
#endif // AREA__SW_H
diff --git a/servers/physics_3d/area_pair_3d_sw.cpp b/servers/physics_3d/area_pair_3d_sw.cpp
index fa2fb2dabb..a5fb20fe2b 100644
--- a/servers/physics_3d/area_pair_3d_sw.cpp
+++ b/servers/physics_3d/area_pair_3d_sw.cpp
@@ -32,7 +32,6 @@
#include "collision_solver_3d_sw.h"
bool AreaPair3DSW::setup(real_t p_step) {
-
bool result = false;
if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) {
@@ -42,20 +41,21 @@ bool AreaPair3DSW::setup(real_t p_step) {
}
if (result != colliding) {
-
if (result) {
-
- if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
body->add_area(area);
- if (area->has_monitor_callback())
+ }
+ if (area->has_monitor_callback()) {
area->add_body_to_query(body, body_shape, area_shape);
+ }
} else {
-
- if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
body->remove_area(area);
- if (area->has_monitor_callback())
+ }
+ if (area->has_monitor_callback()) {
area->remove_body_from_query(body, body_shape, area_shape);
+ }
}
colliding = result;
@@ -68,7 +68,6 @@ void AreaPair3DSW::solve(real_t p_step) {
}
AreaPair3DSW::AreaPair3DSW(Body3DSW *p_body, int p_body_shape, Area3DSW *p_area, int p_area_shape) {
-
body = p_body;
area = p_area;
body_shape = p_body_shape;
@@ -76,18 +75,19 @@ AreaPair3DSW::AreaPair3DSW(Body3DSW *p_body, int p_body_shape, Area3DSW *p_area,
colliding = false;
body->add_constraint(this, 0);
area->add_constraint(this);
- if (p_body->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC)
+ if (p_body->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
p_body->set_active(true);
+ }
}
AreaPair3DSW::~AreaPair3DSW() {
-
if (colliding) {
-
- if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)
+ if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
body->remove_area(area);
- if (area->has_monitor_callback())
+ }
+ if (area->has_monitor_callback()) {
area->remove_body_from_query(body, body_shape, area_shape);
+ }
}
body->remove_constraint(this);
area->remove_constraint(this);
@@ -96,7 +96,6 @@ AreaPair3DSW::~AreaPair3DSW() {
////////////////////////////////////////////////////
bool Area2Pair3DSW::setup(real_t p_step) {
-
bool result = false;
if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) {
result = false;
@@ -105,22 +104,23 @@ bool Area2Pair3DSW::setup(real_t p_step) {
}
if (result != colliding) {
-
if (result) {
-
- if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) {
area_b->add_area_to_query(area_a, shape_a, shape_b);
+ }
- if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) {
area_a->add_area_to_query(area_b, shape_b, shape_a);
+ }
} else {
-
- if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable()) {
area_b->remove_area_from_query(area_a, shape_a, shape_b);
+ }
- if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable()) {
area_a->remove_area_from_query(area_b, shape_b, shape_a);
+ }
}
colliding = result;
@@ -133,7 +133,6 @@ void Area2Pair3DSW::solve(real_t p_step) {
}
Area2Pair3DSW::Area2Pair3DSW(Area3DSW *p_area_a, int p_shape_a, Area3DSW *p_area_b, int p_shape_b) {
-
area_a = p_area_a;
area_b = p_area_b;
shape_a = p_shape_a;
@@ -144,14 +143,14 @@ Area2Pair3DSW::Area2Pair3DSW(Area3DSW *p_area_a, int p_shape_a, Area3DSW *p_area
}
Area2Pair3DSW::~Area2Pair3DSW() {
-
if (colliding) {
-
- if (area_b->has_area_monitor_callback())
+ if (area_b->has_area_monitor_callback()) {
area_b->remove_area_from_query(area_a, shape_a, shape_b);
+ }
- if (area_a->has_area_monitor_callback())
+ if (area_a->has_area_monitor_callback()) {
area_a->remove_area_from_query(area_b, shape_b, shape_a);
+ }
}
area_a->remove_constraint(this);
diff --git a/servers/physics_3d/area_pair_3d_sw.h b/servers/physics_3d/area_pair_3d_sw.h
index 3490f41c26..992d4747b9 100644
--- a/servers/physics_3d/area_pair_3d_sw.h
+++ b/servers/physics_3d/area_pair_3d_sw.h
@@ -36,7 +36,6 @@
#include "constraint_3d_sw.h"
class AreaPair3DSW : public Constraint3DSW {
-
Body3DSW *body;
Area3DSW *area;
int body_shape;
@@ -52,7 +51,6 @@ public:
};
class Area2Pair3DSW : public Constraint3DSW {
-
Area3DSW *area_a;
Area3DSW *area_b;
int shape_a;
diff --git a/servers/physics_3d/body_3d_sw.cpp b/servers/physics_3d/body_3d_sw.cpp
index fea5aed6ad..a3bdc96c9f 100644
--- a/servers/physics_3d/body_3d_sw.cpp
+++ b/servers/physics_3d/body_3d_sw.cpp
@@ -33,13 +33,12 @@
#include "space_3d_sw.h"
void Body3DSW::_update_inertia() {
-
- if (get_space() && !inertia_update_list.in_list())
+ if (get_space() && !inertia_update_list.in_list()) {
get_space()->body_add_to_inertia_update_list(&inertia_update_list);
+ }
}
void Body3DSW::_update_transform_dependant() {
-
center_of_mass = get_transform().basis.xform(center_of_mass_local);
principal_inertia_axes = get_transform().basis * principal_inertia_axes_local;
@@ -52,18 +51,14 @@ void Body3DSW::_update_transform_dependant() {
}
void Body3DSW::update_inertias() {
-
//update shapes and motions
switch (mode) {
-
case PhysicsServer3D::BODY_MODE_RIGID: {
-
//update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet)
real_t total_area = 0;
for (int i = 0; i < get_shape_count(); i++) {
-
total_area += get_shape_area(i);
}
@@ -86,7 +81,6 @@ void Body3DSW::update_inertias() {
inertia_tensor.set_zero();
for (int i = 0; i < get_shape_count(); i++) {
-
if (is_shape_disabled(i)) {
continue;
}
@@ -112,21 +106,20 @@ void Body3DSW::update_inertias() {
principal_inertia_axes_local = inertia_tensor.diagonalize().transposed();
_inv_inertia = inertia_tensor.get_main_diagonal().inverse();
- if (mass)
+ if (mass) {
_inv_mass = 1.0 / mass;
- else
+ } else {
_inv_mass = 0;
+ }
} break;
case PhysicsServer3D::BODY_MODE_KINEMATIC:
case PhysicsServer3D::BODY_MODE_STATIC: {
-
_inv_inertia_tensor.set_zero();
_inv_mass = 0;
} break;
case PhysicsServer3D::BODY_MODE_CHARACTER: {
-
_inv_inertia_tensor.set_zero();
_inv_mass = 1.0 / mass;
@@ -139,19 +132,22 @@ void Body3DSW::update_inertias() {
}
void Body3DSW::set_active(bool p_active) {
-
- if (active == p_active)
+ if (active == p_active) {
return;
+ }
active = p_active;
if (!p_active) {
- if (get_space())
+ if (get_space()) {
get_space()->body_remove_from_active_list(&active_list);
+ }
} else {
- if (mode == PhysicsServer3D::BODY_MODE_STATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
return; //static bodies can't become active
- if (get_space())
+ }
+ if (get_space()) {
get_space()->body_add_to_active_list(&active_list);
+ }
//still_time=0;
}
@@ -169,14 +165,11 @@ void Body3DSW::set_active(bool p_active) {
}
void Body3DSW::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) {
-
switch (p_param) {
case PhysicsServer3D::BODY_PARAM_BOUNCE: {
-
bounce = p_value;
} break;
case PhysicsServer3D::BODY_PARAM_FRICTION: {
-
friction = p_value;
} break;
case PhysicsServer3D::BODY_PARAM_MASS: {
@@ -189,11 +182,9 @@ void Body3DSW::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value)
gravity_scale = p_value;
} break;
case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
-
linear_damp = p_value;
} break;
case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
-
angular_damp = p_value;
} break;
default: {
@@ -202,14 +193,11 @@ void Body3DSW::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value)
}
real_t Body3DSW::get_param(PhysicsServer3D::BodyParameter p_param) const {
-
switch (p_param) {
case PhysicsServer3D::BODY_PARAM_BOUNCE: {
-
return bounce;
} break;
case PhysicsServer3D::BODY_PARAM_FRICTION: {
-
return friction;
} break;
case PhysicsServer3D::BODY_PARAM_MASS: {
@@ -219,11 +207,9 @@ real_t Body3DSW::get_param(PhysicsServer3D::BodyParameter p_param) const {
return gravity_scale;
} break;
case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: {
-
return linear_damp;
} break;
case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: {
-
return angular_damp;
} break;
@@ -235,7 +221,6 @@ real_t Body3DSW::get_param(PhysicsServer3D::BodyParameter p_param) const {
}
void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
-
PhysicsServer3D::BodyMode prev = mode;
mode = p_mode;
@@ -243,7 +228,6 @@ void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
//CLEAR UP EVERYTHING IN CASE IT NOT WORKS!
case PhysicsServer3D::BODY_MODE_STATIC:
case PhysicsServer3D::BODY_MODE_KINEMATIC: {
-
_set_inv_transform(get_transform().affine_inverse());
_inv_mass = 0;
_set_static(p_mode == PhysicsServer3D::BODY_MODE_STATIC);
@@ -257,14 +241,12 @@ void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
} break;
case PhysicsServer3D::BODY_MODE_RIGID: {
-
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_set_static(false);
set_active(true);
} break;
case PhysicsServer3D::BODY_MODE_CHARACTER: {
-
_inv_mass = mass > 0 ? (1.0 / mass) : 0;
_set_static(false);
set_active(true);
@@ -278,21 +260,18 @@ void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) {
_update_queries();
*/
}
-PhysicsServer3D::BodyMode Body3DSW::get_mode() const {
+PhysicsServer3D::BodyMode Body3DSW::get_mode() const {
return mode;
}
void Body3DSW::_shapes_changed() {
-
_update_inertia();
}
void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
-
switch (p_state) {
case PhysicsServer3D::BODY_STATE_TRANSFORM: {
-
if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
new_transform = p_variant;
//wakeup_neighbours();
@@ -311,8 +290,9 @@ void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_va
Transform t = p_variant;
t.orthonormalize();
new_transform = get_transform(); //used as old to compute motion
- if (new_transform == t)
+ if (new_transform == t) {
break;
+ }
_set_transform(t);
_set_inv_transform(get_transform().inverse());
}
@@ -320,7 +300,6 @@ void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_va
} break;
case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: {
-
/*
if (mode==PhysicsServer3D::BODY_MODE_STATIC)
break;
@@ -339,8 +318,9 @@ void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_va
} break;
case PhysicsServer3D::BODY_STATE_SLEEPING: {
//?
- if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
break;
+ }
bool do_sleep = p_variant;
if (do_sleep) {
linear_velocity = Vector3();
@@ -354,14 +334,15 @@ void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_va
} break;
case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant;
- if (mode == PhysicsServer3D::BODY_MODE_RIGID && !active && !can_sleep)
+ if (mode == PhysicsServer3D::BODY_MODE_RIGID && !active && !can_sleep) {
set_active(true);
+ }
} break;
}
}
-Variant Body3DSW::get_state(PhysicsServer3D::BodyState p_state) const {
+Variant Body3DSW::get_state(PhysicsServer3D::BodyState p_state) const {
switch (p_state) {
case PhysicsServer3D::BODY_STATE_TRANSFORM: {
return get_transform();
@@ -384,24 +365,25 @@ Variant Body3DSW::get_state(PhysicsServer3D::BodyState p_state) const {
}
void Body3DSW::set_space(Space3DSW *p_space) {
-
if (get_space()) {
-
- if (inertia_update_list.in_list())
+ if (inertia_update_list.in_list()) {
get_space()->body_remove_from_inertia_update_list(&inertia_update_list);
- if (active_list.in_list())
+ }
+ if (active_list.in_list()) {
get_space()->body_remove_from_active_list(&active_list);
- if (direct_state_query_list.in_list())
+ }
+ if (direct_state_query_list.in_list()) {
get_space()->body_remove_from_state_query_list(&direct_state_query_list);
+ }
}
_set_space(p_space);
if (get_space()) {
-
_update_inertia();
- if (active)
+ if (active) {
get_space()->body_add_to_active_list(&active_list);
+ }
/*
_update_queries();
if (is_active()) {
@@ -415,7 +397,6 @@ void Body3DSW::set_space(Space3DSW *p_space) {
}
void Body3DSW::_compute_area_gravity_and_dampenings(const Area3DSW *p_area) {
-
if (p_area->is_gravity_point()) {
if (p_area->get_gravity_distance_scale() > 0) {
Vector3 v = p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin();
@@ -444,9 +425,9 @@ bool Body3DSW::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
}
void Body3DSW::integrate_forces(real_t p_step) {
-
- if (mode == PhysicsServer3D::BODY_MODE_STATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
return;
+ }
Area3DSW *def_area = get_space()->get_default_area();
// AreaSW *damp_area = def_area;
@@ -491,15 +472,17 @@ void Body3DSW::integrate_forces(real_t p_step) {
gravity *= gravity_scale;
// If less than 0, override dampenings with that of the Body
- if (angular_damp >= 0)
+ if (angular_damp >= 0) {
area_angular_damp = angular_damp;
+ }
/*
else
area_angular_damp=damp_area->get_angular_damp();
*/
- if (linear_damp >= 0)
+ if (linear_damp >= 0) {
area_linear_damp = linear_damp;
+ }
/*
else
area_linear_damp=damp_area->get_linear_damp();
@@ -509,7 +492,6 @@ void Body3DSW::integrate_forces(real_t p_step) {
bool do_motion = false;
if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
-
//compute motion, angular and etc. velocities from prev transform
linear_velocity = (new_transform.origin - get_transform().origin) / p_step;
@@ -535,13 +517,15 @@ void Body3DSW::integrate_forces(real_t p_step) {
real_t damp = 1.0 - p_step * area_linear_damp;
- if (damp < 0) // reached zero in the given time
+ if (damp < 0) { // reached zero in the given time
damp = 0;
+ }
real_t angular_damp = 1.0 - p_step * area_angular_damp;
- if (angular_damp < 0) // reached zero in the given time
+ if (angular_damp < 0) { // reached zero in the given time
angular_damp = 0;
+ }
linear_velocity *= damp;
angular_velocity *= angular_damp;
@@ -574,12 +558,13 @@ void Body3DSW::integrate_forces(real_t p_step) {
}
void Body3DSW::integrate_velocities(real_t p_step) {
-
- if (mode == PhysicsServer3D::BODY_MODE_STATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC) {
return;
+ }
- if (fi_callback)
+ if (fi_callback) {
get_space()->body_add_to_state_query_list(&direct_state_query_list);
+ }
//apply axis lock linear
for (int i = 0; i < 3; i++) {
@@ -598,11 +583,11 @@ void Body3DSW::integrate_velocities(real_t p_step) {
}
if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
-
_set_transform(new_transform, false);
_set_inv_transform(new_transform.affine_inverse());
- if (contacts.size() == 0 && linear_velocity == Vector3() && angular_velocity == Vector3())
+ if (contacts.size() == 0 && linear_velocity == Vector3() && angular_velocity == Vector3()) {
set_active(false); //stopped moving, deactivate
+ }
return;
}
@@ -673,34 +658,33 @@ void BodySW::simulate_motion(const Transform& p_xform,real_t p_step) {
}
+
*/
void Body3DSW::wakeup_neighbours() {
-
for (Map<Constraint3DSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) {
-
const Constraint3DSW *c = E->key();
Body3DSW **n = c->get_body_ptr();
int bc = c->get_body_count();
for (int i = 0; i < bc; i++) {
-
- if (i == E->get())
+ if (i == E->get()) {
continue;
+ }
Body3DSW *b = n[i];
- if (b->mode != PhysicsServer3D::BODY_MODE_RIGID)
+ if (b->mode != PhysicsServer3D::BODY_MODE_RIGID) {
continue;
+ }
- if (!b->is_active())
+ if (!b->is_active()) {
b->set_active(true);
+ }
}
}
}
void Body3DSW::call_queries() {
-
if (fi_callback) {
-
PhysicsDirectBodyState3DSW *dbs = PhysicsDirectBodyState3DSW::singleton;
dbs->body = this;
@@ -708,7 +692,6 @@ void Body3DSW::call_queries() {
Object *obj = ObjectDB::get_instance(fi_callback->id);
if (!obj) {
-
set_force_integration_callback(ObjectID(), StringName());
} else {
const Variant *vp[2] = { &v, &fi_callback->udata };
@@ -721,36 +704,31 @@ void Body3DSW::call_queries() {
}
bool Body3DSW::sleep_test(real_t p_step) {
-
- if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC)
+ if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
return true; //
- else if (mode == PhysicsServer3D::BODY_MODE_CHARACTER)
+ } else if (mode == PhysicsServer3D::BODY_MODE_CHARACTER) {
return !active; // characters don't sleep unless asked to sleep
- else if (!can_sleep)
+ } else if (!can_sleep) {
return false;
+ }
if (Math::abs(angular_velocity.length()) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) {
-
still_time += p_step;
return still_time > get_space()->get_body_time_to_sleep();
} else {
-
still_time = 0; //maybe this should be set to 0 on set_active?
return false;
}
}
void Body3DSW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) {
-
if (fi_callback) {
-
memdelete(fi_callback);
fi_callback = nullptr;
}
if (p_id.is_valid()) {
-
fi_callback = memnew(ForceIntegrationCallback);
fi_callback->id = p_id;
fi_callback->method = p_method;
@@ -764,11 +742,10 @@ void Body3DSW::set_kinematic_margin(real_t p_margin) {
Body3DSW::Body3DSW() :
CollisionObject3DSW(TYPE_BODY),
- locked_axis(0),
+
active_list(this),
inertia_update_list(this),
direct_state_query_list(this) {
-
mode = PhysicsServer3D::BODY_MODE_RIGID;
active = true;
@@ -801,14 +778,13 @@ Body3DSW::Body3DSW() :
}
Body3DSW::~Body3DSW() {
-
- if (fi_callback)
+ if (fi_callback) {
memdelete(fi_callback);
+ }
}
PhysicsDirectBodyState3DSW *PhysicsDirectBodyState3DSW::singleton = nullptr;
PhysicsDirectSpaceState3D *PhysicsDirectBodyState3DSW::get_space_state() {
-
return body->get_space()->get_direct_state();
}
diff --git a/servers/physics_3d/body_3d_sw.h b/servers/physics_3d/body_3d_sw.h
index a67894b64b..483ea58620 100644
--- a/servers/physics_3d/body_3d_sw.h
+++ b/servers/physics_3d/body_3d_sw.h
@@ -38,7 +38,6 @@
class Constraint3DSW;
class Body3DSW : public CollisionObject3DSW {
-
PhysicsServer3D::BodyMode mode;
Vector3 linear_velocity;
@@ -54,7 +53,7 @@ class Body3DSW : public CollisionObject3DSW {
real_t angular_damp;
real_t gravity_scale;
- uint16_t locked_axis;
+ uint16_t locked_axis = 0;
real_t kinematic_safe_margin;
real_t _inv_mass;
@@ -99,7 +98,6 @@ class Body3DSW : public CollisionObject3DSW {
Map<Constraint3DSW *, int> constraint_map;
struct AreaCMP {
-
Area3DSW *area;
int refCount;
_FORCE_INLINE_ bool operator==(const AreaCMP &p_cmp) const { return area->get_self() == p_cmp.area->get_self(); }
@@ -114,7 +112,6 @@ class Body3DSW : public CollisionObject3DSW {
Vector<AreaCMP> areas;
struct Contact {
-
Vector3 local_pos;
Vector3 local_normal;
real_t depth;
@@ -130,7 +127,6 @@ class Body3DSW : public CollisionObject3DSW {
int contact_count;
struct ForceIntegrationCallback {
-
ObjectID id;
StringName method;
Variant udata;
@@ -167,16 +163,18 @@ public:
int index = areas.find(AreaCMP(p_area));
if (index > -1) {
areas.write[index].refCount -= 1;
- if (areas[index].refCount < 1)
+ if (areas[index].refCount < 1) {
areas.remove(index);
+ }
}
}
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
contacts.resize(p_size);
contact_count = 0;
- if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && p_size)
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && p_size) {
set_active(true);
+ }
}
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
@@ -223,18 +221,15 @@ public:
}
_FORCE_INLINE_ void apply_impulse(const Vector3 &p_pos, const Vector3 &p_j) {
-
linear_velocity += p_j * _inv_mass;
angular_velocity += _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j));
}
_FORCE_INLINE_ void apply_torque_impulse(const Vector3 &p_j) {
-
angular_velocity += _inv_inertia_tensor.xform(p_j);
}
_FORCE_INLINE_ void apply_bias_impulse(const Vector3 &p_pos, const Vector3 &p_j, real_t p_max_delta_av = -1.0) {
-
biased_linear_velocity += p_j * _inv_mass;
if (p_max_delta_av != 0.0) {
Vector3 delta_av = _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j));
@@ -246,17 +241,14 @@ public:
}
_FORCE_INLINE_ void apply_bias_torque_impulse(const Vector3 &p_j) {
-
biased_angular_velocity += _inv_inertia_tensor.xform(p_j);
}
_FORCE_INLINE_ void add_central_force(const Vector3 &p_force) {
-
applied_force += p_force;
}
_FORCE_INLINE_ void add_force(const Vector3 &p_force, const Vector3 &p_pos) {
-
applied_force += p_force;
applied_torque += (p_pos - center_of_mass).cross(p_force);
}
@@ -269,8 +261,9 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC)
+ if ((!get_space()) || mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
return;
+ }
set_active(true);
}
@@ -310,12 +303,10 @@ public:
void integrate_velocities(real_t p_step);
_FORCE_INLINE_ Vector3 get_velocity_in_local_point(const Vector3 &rel_pos) const {
-
return linear_velocity + angular_velocity.cross(rel_pos - center_of_mass);
}
_FORCE_INLINE_ real_t compute_impulse_denominator(const Vector3 &p_pos, const Vector3 &p_normal) const {
-
Vector3 r0 = p_pos - get_transform().origin - center_of_mass;
Vector3 c0 = (r0).cross(p_normal);
@@ -326,7 +317,6 @@ public:
}
_FORCE_INLINE_ real_t compute_angular_impulse_denominator(const Vector3 &p_axis) const {
-
return p_axis.dot(_inv_inertia_tensor.xform_inv(p_axis));
}
@@ -343,11 +333,11 @@ public:
//add contact inline
void Body3DSW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos) {
-
int c_max = contacts.size();
- if (c_max == 0)
+ if (c_max == 0) {
return;
+ }
Contact *c = contacts.ptrw();
@@ -356,11 +346,9 @@ void Body3DSW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_no
if (contact_count < c_max) {
idx = contact_count++;
} else {
-
real_t least_depth = 1e20;
int least_deep = -1;
for (int i = 0; i < c_max; i++) {
-
if (i == 0 || c[i].depth < least_depth) {
least_deep = i;
least_depth = c[i].depth;
@@ -368,11 +356,11 @@ void Body3DSW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_no
}
if (least_deep >= 0 && least_depth < p_depth) {
-
idx = least_deep;
}
- if (idx == -1)
+ if (idx == -1) {
return; //none least deepe than this
+ }
}
c[idx].local_pos = p_local_pos;
@@ -387,7 +375,6 @@ void Body3DSW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_no
}
class PhysicsDirectBodyState3DSW : public PhysicsDirectBodyState3D {
-
GDCLASS(PhysicsDirectBodyState3DSW, PhysicsDirectBodyState3D);
public:
diff --git a/servers/physics_3d/body_pair_3d_sw.cpp b/servers/physics_3d/body_pair_3d_sw.cpp
index 245fb3449c..a4f86badbe 100644
--- a/servers/physics_3d/body_pair_3d_sw.cpp
+++ b/servers/physics_3d/body_pair_3d_sw.cpp
@@ -50,13 +50,11 @@
#define MAX_BIAS_ROTATION (Math_PI / 8)
void BodyPair3DSW::_contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
-
BodyPair3DSW *pair = (BodyPair3DSW *)p_userdata;
pair->contact_added_callback(p_point_A, p_point_B);
}
void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B) {
-
// check if we already have the contact
//Vector3 local_A = A->get_inv_transform().xform(p_point_A);
@@ -84,11 +82,9 @@ void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector
real_t contact_recycle_radius = space->get_contact_recycle_radius();
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
if (c.local_A.distance_squared_to(local_A) < (contact_recycle_radius * contact_recycle_radius) &&
c.local_B.distance_squared_to(local_B) < (contact_recycle_radius * contact_recycle_radius)) {
-
contact.acc_normal_impulse = c.acc_normal_impulse;
contact.acc_bias_impulse = c.acc_bias_impulse;
contact.acc_bias_impulse_center_of_mass = c.acc_bias_impulse_center_of_mass;
@@ -101,14 +97,12 @@ void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector
// figure out if the contact amount must be reduced to fit the new contact
if (new_index == MAX_CONTACTS) {
-
// remove the contact with the minimum depth
int least_deep = -1;
real_t min_depth = 1e10;
for (int i = 0; i <= contact_count; i++) {
-
Contact &c = (i == contact_count) ? contact : contacts[i];
Vector3 global_A = A->get_transform().basis.xform(c.local_A);
Vector3 global_B = B->get_transform().basis.xform(c.local_B) + offset_B;
@@ -117,7 +111,6 @@ void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector
real_t depth = axis.dot(c.normal);
if (depth < min_depth) {
-
min_depth = depth;
least_deep = i;
}
@@ -136,18 +129,15 @@ void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector
contacts[new_index] = contact;
if (new_index == contact_count) {
-
contact_count++;
}
}
void BodyPair3DSW::validate_contacts() {
-
//make sure to erase contacts that are no longer valid
real_t contact_max_separation = space->get_contact_max_separation();
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
Vector3 global_A = A->get_transform().basis.xform(c.local_A);
@@ -170,11 +160,11 @@ void BodyPair3DSW::validate_contacts() {
}
bool BodyPair3DSW::_test_ccd(real_t p_step, Body3DSW *p_A, int p_shape_A, const Transform &p_xform_A, Body3DSW *p_B, int p_shape_B, const Transform &p_xform_B) {
-
Vector3 motion = p_A->get_linear_velocity() * p_step;
real_t mlen = motion.length();
- if (mlen < CMP_EPSILON)
+ if (mlen < CMP_EPSILON) {
return false;
+ }
Vector3 mnormal = motion / mlen;
@@ -220,7 +210,6 @@ real_t combine_friction(Body3DSW *A, Body3DSW *B) {
}
bool BodyPair3DSW::setup(real_t p_step) {
-
//cannot collide
if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) {
collided = false;
@@ -251,7 +240,6 @@ bool BodyPair3DSW::setup(real_t p_step) {
this->collided = collided;
if (!collided) {
-
//test ccd (currently just a raycast)
if (A->is_continuous_collision_detection_enabled() && A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC) {
@@ -270,19 +258,18 @@ bool BodyPair3DSW::setup(real_t p_step) {
real_t bias = (real_t)0.3;
if (shape_A_ptr->get_custom_bias() || shape_B_ptr->get_custom_bias()) {
-
- if (shape_A_ptr->get_custom_bias() == 0)
+ if (shape_A_ptr->get_custom_bias() == 0) {
bias = shape_B_ptr->get_custom_bias();
- else if (shape_B_ptr->get_custom_bias() == 0)
+ } else if (shape_B_ptr->get_custom_bias() == 0) {
bias = shape_A_ptr->get_custom_bias();
- else
+ } else {
bias = (shape_B_ptr->get_custom_bias() + shape_A_ptr->get_custom_bias()) * 0.5;
+ }
}
real_t inv_dt = 1.0 / p_step;
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
c.active = false;
@@ -341,7 +328,6 @@ bool BodyPair3DSW::setup(real_t p_step) {
c.bounce = combine_bounce(A, B);
if (c.bounce) {
-
Vector3 crA = A->get_angular_velocity().cross(c.rA);
Vector3 crB = B->get_angular_velocity().cross(c.rB);
Vector3 dv = B->get_linear_velocity() + crB - A->get_linear_velocity() - crA;
@@ -354,15 +340,15 @@ bool BodyPair3DSW::setup(real_t p_step) {
}
void BodyPair3DSW::solve(real_t p_step) {
-
- if (!collided)
+ if (!collided) {
return;
+ }
for (int i = 0; i < contact_count; i++) {
-
Contact &c = contacts[i];
- if (!c.active)
+ if (!c.active) {
continue;
+ }
c.active = false; //try to deactivate, will activate itself if still needed
@@ -375,7 +361,6 @@ void BodyPair3DSW::solve(real_t p_step) {
real_t vbn = dbv.dot(c.normal);
if (Math::abs(-vbn + c.bias) > MIN_VELOCITY) {
-
real_t jbn = (-vbn + c.bias) * c.mass_normal;
real_t jbnOld = c.acc_bias_impulse;
c.acc_bias_impulse = MAX(jbnOld + jbn, 0.0f);
@@ -392,7 +377,6 @@ void BodyPair3DSW::solve(real_t p_step) {
vbn = dbv.dot(c.normal);
if (Math::abs(-vbn + c.bias) > MIN_VELOCITY) {
-
real_t jbn_com = (-vbn + c.bias) / (A->get_inv_mass() + B->get_inv_mass());
real_t jbnOld_com = c.acc_bias_impulse_center_of_mass;
c.acc_bias_impulse_center_of_mass = MAX(jbnOld_com + jbn_com, 0.0f);
@@ -414,7 +398,6 @@ void BodyPair3DSW::solve(real_t p_step) {
real_t vn = dv.dot(c.normal);
if (Math::abs(vn) > MIN_VELOCITY) {
-
real_t jn = -(c.bounce + vn) * c.mass_normal;
real_t jnOld = c.acc_normal_impulse;
c.acc_normal_impulse = MAX(jnOld + jn, 0.0f);
@@ -442,7 +425,6 @@ void BodyPair3DSW::solve(real_t p_step) {
real_t tvl = tv.length();
if (tvl > MIN_VELOCITY) {
-
tv /= tvl;
Vector3 temp1 = A->get_inv_inertia_tensor().xform(c.rA.cross(tv));
@@ -460,7 +442,6 @@ void BodyPair3DSW::solve(real_t p_step) {
real_t jtMax = c.acc_normal_impulse * friction;
if (fi_len > CMP_EPSILON && fi_len > jtMax) {
-
c.acc_tangent_impulse *= jtMax / fi_len;
}
@@ -476,7 +457,6 @@ void BodyPair3DSW::solve(real_t p_step) {
BodyPair3DSW::BodyPair3DSW(Body3DSW *p_A, int p_shape_A, Body3DSW *p_B, int p_shape_B) :
Constraint3DSW(_arr, 2) {
-
A = p_A;
B = p_B;
shape_A = p_shape_A;
@@ -489,7 +469,6 @@ BodyPair3DSW::BodyPair3DSW(Body3DSW *p_A, int p_shape_A, Body3DSW *p_B, int p_sh
}
BodyPair3DSW::~BodyPair3DSW() {
-
A->remove_constraint(this);
B->remove_constraint(this);
}
diff --git a/servers/physics_3d/body_pair_3d_sw.h b/servers/physics_3d/body_pair_3d_sw.h
index 7f4afb9dca..59e36e7ea5 100644
--- a/servers/physics_3d/body_pair_3d_sw.h
+++ b/servers/physics_3d/body_pair_3d_sw.h
@@ -53,7 +53,6 @@ class BodyPair3DSW : public Constraint3DSW {
int shape_B;
struct Contact {
-
Vector3 position;
Vector3 normal;
Vector3 local_A, local_B;
diff --git a/servers/physics_3d/broad_phase_3d_basic.cpp b/servers/physics_3d/broad_phase_3d_basic.cpp
index 08ea219869..f5ea1897a9 100644
--- a/servers/physics_3d/broad_phase_3d_basic.cpp
+++ b/servers/physics_3d/broad_phase_3d_basic.cpp
@@ -33,7 +33,6 @@
#include "core/print_string.h"
BroadPhase3DSW::ID BroadPhase3DBasic::create(CollisionObject3DSW *p_object, int p_subindex) {
-
ERR_FAIL_COND_V(p_object == nullptr, 0);
current++;
@@ -48,27 +47,24 @@ BroadPhase3DSW::ID BroadPhase3DBasic::create(CollisionObject3DSW *p_object, int
}
void BroadPhase3DBasic::move(ID p_id, const AABB &p_aabb) {
-
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get().aabb = p_aabb;
}
-void BroadPhase3DBasic::set_static(ID p_id, bool p_static) {
+void BroadPhase3DBasic::set_static(ID p_id, bool p_static) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
E->get()._static = p_static;
}
-void BroadPhase3DBasic::remove(ID p_id) {
+void BroadPhase3DBasic::remove(ID p_id) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
List<PairKey> to_erase;
//unpair must be done immediately on removal to avoid potential invalid pointers
for (Map<PairKey, void *>::Element *F = pair_map.front(); F; F = F->next()) {
-
if (F->key().a == p_id || F->key().b == p_id) {
-
if (unpair_callback) {
Element *elem_A = &element_map[F->key().a];
Element *elem_B = &element_map[F->key().b];
@@ -78,7 +74,6 @@ void BroadPhase3DBasic::remove(ID p_id) {
}
}
while (to_erase.size()) {
-
pair_map.erase(to_erase.front()->get());
to_erase.pop_front();
}
@@ -86,38 +81,35 @@ void BroadPhase3DBasic::remove(ID p_id) {
}
CollisionObject3DSW *BroadPhase3DBasic::get_object(ID p_id) const {
-
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, nullptr);
return E->get().owner;
}
-bool BroadPhase3DBasic::is_static(ID p_id) const {
+bool BroadPhase3DBasic::is_static(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, false);
return E->get()._static;
}
-int BroadPhase3DBasic::get_subindex(ID p_id) const {
+int BroadPhase3DBasic::get_subindex(ID p_id) const {
const Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND_V(!E, -1);
return E->get().subindex;
}
int BroadPhase3DBasic::cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
-
int rc = 0;
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
-
const AABB aabb = E->get().aabb;
if (aabb.has_point(p_point)) {
-
p_results[rc] = E->get().owner;
p_result_indices[rc] = E->get().subindex;
rc++;
- if (rc >= p_max_results)
+ if (rc >= p_max_results) {
break;
+ }
}
}
@@ -125,38 +117,35 @@ int BroadPhase3DBasic::cull_point(const Vector3 &p_point, CollisionObject3DSW **
}
int BroadPhase3DBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
-
int rc = 0;
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
-
const AABB aabb = E->get().aabb;
if (aabb.intersects_segment(p_from, p_to)) {
-
p_results[rc] = E->get().owner;
p_result_indices[rc] = E->get().subindex;
rc++;
- if (rc >= p_max_results)
+ if (rc >= p_max_results) {
break;
+ }
}
}
return rc;
}
-int BroadPhase3DBasic::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhase3DBasic::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
-
const AABB aabb = E->get().aabb;
if (aabb.intersects(p_aabb)) {
-
p_results[rc] = E->get().owner;
p_result_indices[rc] = E->get().subindex;
rc++;
- if (rc >= p_max_results)
+ if (rc >= p_max_results) {
break;
+ }
}
}
@@ -164,28 +153,25 @@ int BroadPhase3DBasic::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_res
}
void BroadPhase3DBasic::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) {
-
pair_userdata = p_userdata;
pair_callback = p_pair_callback;
}
-void BroadPhase3DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
+void BroadPhase3DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_userdata = p_userdata;
unpair_callback = p_unpair_callback;
}
void BroadPhase3DBasic::update() {
-
// recompute pairs
for (Map<ID, Element>::Element *I = element_map.front(); I; I = I->next()) {
-
for (Map<ID, Element>::Element *J = I->next(); J; J = J->next()) {
-
Element *elem_A = &I->get();
Element *elem_B = &J->get();
- if (elem_A->owner == elem_B->owner)
+ if (elem_A->owner == elem_B->owner) {
continue;
+ }
bool pair_ok = elem_A->aabb.intersects(elem_B->aabb) && (!elem_A->_static || !elem_B->_static);
@@ -194,29 +180,30 @@ void BroadPhase3DBasic::update() {
Map<PairKey, void *>::Element *E = pair_map.find(key);
if (!pair_ok && E) {
- if (unpair_callback)
+ if (unpair_callback) {
unpair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, E->get(), unpair_userdata);
+ }
pair_map.erase(key);
}
if (pair_ok && !E) {
-
void *data = nullptr;
- if (pair_callback)
+ if (pair_callback) {
data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata);
- pair_map.insert(key, data);
+ if (data) {
+ pair_map.insert(key, data);
+ }
+ }
}
}
}
}
BroadPhase3DSW *BroadPhase3DBasic::_create() {
-
return memnew(BroadPhase3DBasic);
}
BroadPhase3DBasic::BroadPhase3DBasic() {
-
current = 1;
unpair_callback = nullptr;
unpair_userdata = nullptr;
diff --git a/servers/physics_3d/broad_phase_3d_basic.h b/servers/physics_3d/broad_phase_3d_basic.h
index 563dda6931..4b644bf818 100644
--- a/servers/physics_3d/broad_phase_3d_basic.h
+++ b/servers/physics_3d/broad_phase_3d_basic.h
@@ -35,9 +35,7 @@
#include "core/map.h"
class BroadPhase3DBasic : public BroadPhase3DSW {
-
struct Element {
-
CollisionObject3DSW *owner;
bool _static;
AABB aabb;
@@ -49,7 +47,6 @@ class BroadPhase3DBasic : public BroadPhase3DSW {
ID current;
struct PairKey {
-
union {
struct {
ID a;
diff --git a/servers/physics_3d/broad_phase_3d_sw.h b/servers/physics_3d/broad_phase_3d_sw.h
index 5950489619..081e75810f 100644
--- a/servers/physics_3d/broad_phase_3d_sw.h
+++ b/servers/physics_3d/broad_phase_3d_sw.h
@@ -37,7 +37,6 @@
class CollisionObject3DSW;
class BroadPhase3DSW {
-
public:
typedef BroadPhase3DSW *(*CreateFunction)();
diff --git a/servers/physics_3d/broad_phase_octree.cpp b/servers/physics_3d/broad_phase_octree.cpp
index 264ab21e1e..1ace1a4fcf 100644
--- a/servers/physics_3d/broad_phase_octree.cpp
+++ b/servers/physics_3d/broad_phase_octree.cpp
@@ -32,81 +32,73 @@
#include "collision_object_3d_sw.h"
BroadPhase3DSW::ID BroadPhaseOctree::create(CollisionObject3DSW *p_object, int p_subindex) {
-
ID oid = octree.create(p_object, AABB(), p_subindex, false, 1 << p_object->get_type(), 0);
return oid;
}
void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) {
-
octree.move(p_id, p_aabb);
}
void BroadPhaseOctree::set_static(ID p_id, bool p_static) {
-
CollisionObject3DSW *it = octree.get(p_id);
octree.set_pairable(p_id, !p_static, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1?
}
-void BroadPhaseOctree::remove(ID p_id) {
+void BroadPhaseOctree::remove(ID p_id) {
octree.erase(p_id);
}
CollisionObject3DSW *BroadPhaseOctree::get_object(ID p_id) const {
-
CollisionObject3DSW *it = octree.get(p_id);
ERR_FAIL_COND_V(!it, nullptr);
return it;
}
-bool BroadPhaseOctree::is_static(ID p_id) const {
+bool BroadPhaseOctree::is_static(ID p_id) const {
return !octree.is_pairable(p_id);
}
-int BroadPhaseOctree::get_subindex(ID p_id) const {
+int BroadPhaseOctree::get_subindex(ID p_id) const {
return octree.get_subindex(p_id);
}
int BroadPhaseOctree::cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
-
return octree.cull_point(p_point, p_results, p_max_results, p_result_indices);
}
int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
-
return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices);
}
int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) {
-
return octree.cull_aabb(p_aabb, p_results, p_max_results, p_result_indices);
}
void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, CollisionObject3DSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObject3DSW *p_object_B, int subindex_B) {
-
BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self);
- if (!bpo->pair_callback)
+ if (!bpo->pair_callback) {
return nullptr;
+ }
return bpo->pair_callback(p_object_A, subindex_A, p_object_B, subindex_B, bpo->pair_userdata);
}
void BroadPhaseOctree::_unpair_callback(void *self, OctreeElementID p_A, CollisionObject3DSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObject3DSW *p_object_B, int subindex_B, void *pairdata) {
-
BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self);
- if (!bpo->unpair_callback)
+ if (!bpo->unpair_callback) {
return;
+ }
bpo->unpair_callback(p_object_A, subindex_A, p_object_B, subindex_B, pairdata, bpo->unpair_userdata);
}
void BroadPhaseOctree::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) {
-
pair_callback = p_pair_callback;
pair_userdata = p_userdata;
}
-void BroadPhaseOctree::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
+void BroadPhaseOctree::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) {
unpair_callback = p_unpair_callback;
unpair_userdata = p_userdata;
}
@@ -116,7 +108,6 @@ void BroadPhaseOctree::update() {
}
BroadPhase3DSW *BroadPhaseOctree::_create() {
-
return memnew(BroadPhaseOctree);
}
diff --git a/servers/physics_3d/broad_phase_octree.h b/servers/physics_3d/broad_phase_octree.h
index 0ad59d8b0c..761a90a051 100644
--- a/servers/physics_3d/broad_phase_octree.h
+++ b/servers/physics_3d/broad_phase_octree.h
@@ -35,7 +35,6 @@
#include "core/math/octree.h"
class BroadPhaseOctree : public BroadPhase3DSW {
-
Octree<CollisionObject3DSW, true> octree;
static void *_pair_callback(void *, OctreeElementID, CollisionObject3DSW *, int, OctreeElementID, CollisionObject3DSW *, int);
diff --git a/servers/physics_3d/collision_object_3d_sw.cpp b/servers/physics_3d/collision_object_3d_sw.cpp
index 24715d211d..e12f0659e2 100644
--- a/servers/physics_3d/collision_object_3d_sw.cpp
+++ b/servers/physics_3d/collision_object_3d_sw.cpp
@@ -33,7 +33,6 @@
#include "space_3d_sw.h"
void CollisionObject3DSW::add_shape(Shape3DSW *p_shape, const Transform &p_transform, bool p_disabled) {
-
Shape s;
s.shape = p_shape;
s.xform = p_transform;
@@ -51,7 +50,6 @@ void CollisionObject3DSW::add_shape(Shape3DSW *p_shape, const Transform &p_trans
}
void CollisionObject3DSW::set_shape(int p_index, Shape3DSW *p_shape) {
-
ERR_FAIL_INDEX(p_index, shapes.size());
shapes[p_index].shape->remove_owner(this);
shapes.write[p_index].shape = p_shape;
@@ -63,8 +61,8 @@ void CollisionObject3DSW::set_shape(int p_index, Shape3DSW *p_shape) {
//_update_shapes();
//_shapes_changed();
}
-void CollisionObject3DSW::set_shape_transform(int p_index, const Transform &p_transform) {
+void CollisionObject3DSW::set_shape_transform(int p_index, const Transform &p_transform) {
ERR_FAIL_INDEX(p_index, shapes.size());
shapes.write[p_index].xform = p_transform;
@@ -84,10 +82,8 @@ void CollisionObject3DSW::set_shape_as_disabled(int p_idx, bool p_enable) {
}
void CollisionObject3DSW::remove_shape(Shape3DSW *p_shape) {
-
//remove a shape, all the times it appears
for (int i = 0; i < shapes.size(); i++) {
-
if (shapes[i].shape == p_shape) {
remove_shape(i);
i--;
@@ -96,13 +92,12 @@ void CollisionObject3DSW::remove_shape(Shape3DSW *p_shape) {
}
void CollisionObject3DSW::remove_shape(int p_index) {
-
//remove anything from shape to be erased to end, so subindices don't change
ERR_FAIL_INDEX(p_index, shapes.size());
for (int i = p_index; i < shapes.size(); i++) {
-
- if (shapes[i].bpid == 0)
+ if (shapes[i].bpid == 0) {
continue;
+ }
//should never get here with a null owner
space->get_broadphase()->remove(shapes[i].bpid);
shapes.write[i].bpid = 0;
@@ -118,12 +113,14 @@ void CollisionObject3DSW::remove_shape(int p_index) {
}
void CollisionObject3DSW::_set_static(bool p_static) {
- if (_static == p_static)
+ if (_static == p_static) {
return;
+ }
_static = p_static;
- if (!space)
+ if (!space) {
return;
+ }
for (int i = 0; i < get_shape_count(); i++) {
const Shape &s = shapes[i];
if (s.bpid > 0) {
@@ -133,9 +130,7 @@ void CollisionObject3DSW::_set_static(bool p_static) {
}
void CollisionObject3DSW::_unregister_shapes() {
-
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
if (s.bpid > 0) {
space->get_broadphase()->remove(s.bpid);
@@ -145,12 +140,11 @@ void CollisionObject3DSW::_unregister_shapes() {
}
void CollisionObject3DSW::_update_shapes() {
-
- if (!space)
+ if (!space) {
return;
+ }
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
if (s.bpid == 0) {
s.bpid = space->get_broadphase()->create(this, i);
@@ -172,12 +166,11 @@ void CollisionObject3DSW::_update_shapes() {
}
void CollisionObject3DSW::_update_shapes_with_motion(const Vector3 &p_motion) {
-
- if (!space)
+ if (!space) {
return;
+ }
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
if (s.bpid == 0) {
s.bpid = space->get_broadphase()->create(this, i);
@@ -196,13 +189,10 @@ void CollisionObject3DSW::_update_shapes_with_motion(const Vector3 &p_motion) {
}
void CollisionObject3DSW::_set_space(Space3DSW *p_space) {
-
if (space) {
-
space->remove_object(this);
for (int i = 0; i < shapes.size(); i++) {
-
Shape &s = shapes.write[i];
if (s.bpid) {
space->get_broadphase()->remove(s.bpid);
@@ -214,21 +204,18 @@ void CollisionObject3DSW::_set_space(Space3DSW *p_space) {
space = p_space;
if (space) {
-
space->add_object(this);
_update_shapes();
}
}
void CollisionObject3DSW::_shape_changed() {
-
_update_shapes();
_shapes_changed();
}
CollisionObject3DSW::CollisionObject3DSW(Type p_type) :
pending_shape_update_list(this) {
-
_static = true;
type = p_type;
space = nullptr;
diff --git a/servers/physics_3d/collision_object_3d_sw.h b/servers/physics_3d/collision_object_3d_sw.h
index 9dd798af26..9506f14402 100644
--- a/servers/physics_3d/collision_object_3d_sw.h
+++ b/servers/physics_3d/collision_object_3d_sw.h
@@ -59,7 +59,6 @@ private:
uint32_t collision_mask;
struct Shape {
-
Transform xform;
Transform xform_inv;
BroadPhase3DSW::ID bpid;
@@ -92,8 +91,9 @@ protected:
#endif
transform = p_transform;
- if (p_update_shapes)
+ if (p_update_shapes) {
_update_shapes();
+ }
}
_FORCE_INLINE_ void _set_inv_transform(const Transform &p_transform) { inv_transform = p_transform; }
void _set_static(bool p_static);
diff --git a/servers/physics_3d/collision_solver_3d_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp
index 5096b080ab..85f55ad66d 100644
--- a/servers/physics_3d/collision_solver_3d_sat.cpp
+++ b/servers/physics_3d/collision_solver_3d_sat.cpp
@@ -29,12 +29,11 @@
/*************************************************************************/
#include "collision_solver_3d_sat.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02
struct _CollectorCallback {
-
CollisionSolver3DSW::CallbackResult callback;
void *userdata;
bool swap;
@@ -43,18 +42,17 @@ struct _CollectorCallback {
Vector3 *prev_axis;
_FORCE_INLINE_ void call(const Vector3 &p_point_A, const Vector3 &p_point_B) {
-
- if (swap)
+ if (swap) {
callback(p_point_B, p_point_A, userdata);
- else
+ } else {
callback(p_point_A, p_point_B, userdata);
+ }
}
};
typedef void (*GenerateContactsFunc)(const Vector3 *, int, const Vector3 *, int, _CollectorCallback *);
static void _generate_contacts_point_point(const Vector3 *p_points_A, int p_point_count_A, const Vector3 *p_points_B, int p_point_count_B, _CollectorCallback *p_callback) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 1);
ERR_FAIL_COND(p_point_count_B != 1);
@@ -64,18 +62,16 @@ static void _generate_contacts_point_point(const Vector3 *p_points_A, int p_poin
}
static void _generate_contacts_point_edge(const Vector3 *p_points_A, int p_point_count_A, const Vector3 *p_points_B, int p_point_count_B, _CollectorCallback *p_callback) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 1);
ERR_FAIL_COND(p_point_count_B != 2);
#endif
- Vector3 closest_B = Geometry::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B);
+ Vector3 closest_B = Geometry3D::get_closest_point_to_segment_uncapped(*p_points_A, p_points_B);
p_callback->call(*p_points_A, closest_B);
}
static void _generate_contacts_point_face(const Vector3 *p_points_A, int p_point_count_A, const Vector3 *p_points_B, int p_point_count_B, _CollectorCallback *p_callback) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 1);
ERR_FAIL_COND(p_point_count_B < 3);
@@ -87,7 +83,6 @@ static void _generate_contacts_point_face(const Vector3 *p_points_A, int p_point
}
static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_count_A, const Vector3 *p_points_B, int p_point_count_B, _CollectorCallback *p_callback) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A != 2);
ERR_FAIL_COND(p_point_count_B != 2); // circle is actually a 4x3 matrix
@@ -99,7 +94,6 @@ static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_
Vector3 c = rel_A.cross(rel_B).cross(rel_B);
if (Math::is_zero_approx(rel_A.dot(c))) {
-
// should handle somehow..
//ERR_PRINT("TODO FIX");
//return;
@@ -123,18 +117,18 @@ static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_
real_t d = (c.dot(p_points_B[0]) - p_points_A[0].dot(c)) / rel_A.dot(c);
- if (d < 0.0)
+ if (d < 0.0) {
d = 0.0;
- else if (d > 1.0)
+ } else if (d > 1.0) {
d = 1.0;
+ }
Vector3 closest_A = p_points_A[0] + rel_A * d;
- Vector3 closest_B = Geometry::get_closest_point_to_segment_uncapped(closest_A, p_points_B);
+ Vector3 closest_B = Geometry3D::get_closest_point_to_segment_uncapped(closest_A, p_points_B);
p_callback->call(closest_A, closest_B);
}
static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_count_A, const Vector3 *p_points_B, int p_point_count_B, _CollectorCallback *p_callback) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A < 2);
ERR_FAIL_COND(p_point_count_B < 3);
@@ -150,7 +144,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
// copy A points to clipbuf_src
for (int i = 0; i < p_point_count_A; i++) {
-
clipbuf_src[i] = p_points_A[i];
}
@@ -158,7 +151,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
// go through all of B points
for (int i = 0; i < p_point_count_B; i++) {
-
int i_n = (i + 1) % p_point_count_B;
Vector3 edge0_B = p_points_B[i];
@@ -172,7 +164,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
int dst_idx = 0;
bool edge = clipbuf_len == 2;
for (int j = 0; j < clipbuf_len; j++) {
-
int j_n = (j + 1) % clipbuf_len;
Vector3 edge0_A = clipbuf_src[j];
@@ -190,7 +181,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
// check for different sides and non coplanar
//if ( (dist0*dist1) < -CMP_EPSILON && !(edge && j)) {
if ((dist0 * dist1) < 0 && !(edge && j)) {
-
// calculate intersection
Vector3 rel = edge1_A - edge0_A;
real_t den = clip.normal.dot(rel);
@@ -211,7 +201,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
//Plane plane_A(p_points_A[0],p_points_A[1],p_points_A[2]);
for (int i = 0; i < clipbuf_len; i++) {
-
real_t d = plane_B.distance_to(clipbuf_src[i]);
/*
if (d>CMP_EPSILON)
@@ -220,15 +209,15 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_
Vector3 closest_B = clipbuf_src[i] - plane_B.normal * d;
- if (p_callback->normal.dot(clipbuf_src[i]) >= p_callback->normal.dot(closest_B))
+ if (p_callback->normal.dot(clipbuf_src[i]) >= p_callback->normal.dot(closest_B)) {
continue;
+ }
p_callback->call(clipbuf_src[i], closest_B);
}
}
static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_point_count_A, const Vector3 *p_points_B, int p_point_count_B, _CollectorCallback *p_callback) {
-
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(p_point_count_A < 1);
ERR_FAIL_COND(p_point_count_B < 1);
@@ -267,7 +256,6 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
points_A = p_points_B;
points_B = p_points_A;
} else {
-
pointcount_B = p_point_count_B;
pointcount_A = p_point_count_A;
points_A = p_points_A;
@@ -284,7 +272,6 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
template <class ShapeA, class ShapeB, bool withMargin = false>
class SeparatorAxisTest {
-
const ShapeA *shape_A;
const ShapeB *shape_B;
const Transform *transform_A;
@@ -298,15 +285,14 @@ class SeparatorAxisTest {
public:
_FORCE_INLINE_ bool test_previous_axis() {
-
- if (callback && callback->prev_axis && *callback->prev_axis != Vector3())
+ if (callback && callback->prev_axis && *callback->prev_axis != Vector3()) {
return test_axis(*callback->prev_axis);
- else
+ } else {
return true;
+ }
}
_FORCE_INLINE_ bool test_axis(const Vector3 &p_axis) {
-
Vector3 axis = p_axis;
if (Math::abs(axis.x) < CMP_EPSILON &&
@@ -361,16 +347,17 @@ public:
}
_FORCE_INLINE_ void generate_contacts() {
-
// nothing to do, don't generate
- if (best_axis == Vector3(0.0, 0.0, 0.0))
+ if (best_axis == Vector3(0.0, 0.0, 0.0)) {
return;
+ }
if (!callback->callback) {
//just was checking intersection?
callback->collided = true;
- if (callback->prev_axis)
+ if (callback->prev_axis) {
*callback->prev_axis = best_axis;
+ }
return;
}
@@ -384,7 +371,6 @@ public:
}
if (withMargin) {
-
for (int i = 0; i < support_count_A; i++) {
supports_A[i] += -best_axis * margin_A;
}
@@ -398,15 +384,15 @@ public:
}
if (withMargin) {
-
for (int i = 0; i < support_count_B; i++) {
supports_B[i] += best_axis * margin_B;
}
}
callback->normal = best_axis;
- if (callback->prev_axis)
+ if (callback->prev_axis) {
*callback->prev_axis = best_axis;
+ }
_generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback);
callback->collided = true;
@@ -430,7 +416,6 @@ typedef void (*CollisionFunc)(const Shape3DSW *, const Transform &, const Shape3
template <bool withMargin>
static void _collision_sphere_sphere(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
const SphereShape3DSW *sphere_B = static_cast<const SphereShape3DSW *>(p_b);
@@ -438,34 +423,36 @@ static void _collision_sphere_sphere(const Shape3DSW *p_a, const Transform &p_tr
// previous axis
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- if (!separator.test_axis((p_transform_a.origin - p_transform_b.origin).normalized()))
+ if (!separator.test_axis((p_transform_a.origin - p_transform_b.origin).normalized())) {
return;
+ }
separator.generate_contacts();
}
template <bool withMargin>
static void _collision_sphere_box(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
const BoxShape3DSW *box_B = static_cast<const BoxShape3DSW *>(p_b);
SeparatorAxisTest<SphereShape3DSW, BoxShape3DSW, withMargin> separator(sphere_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
// test faces
for (int i = 0; i < 3; i++) {
-
Vector3 axis = p_transform_b.basis.get_axis(i).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// calculate closest point to sphere
@@ -481,17 +468,18 @@ static void _collision_sphere_box(const Shape3DSW *p_a, const Transform &p_trans
// use point to test axis
Vector3 point_axis = (p_transform_a.origin - cpoint).normalized();
- if (!separator.test_axis(point_axis))
+ if (!separator.test_axis(point_axis)) {
return;
+ }
// test edges
for (int i = 0; i < 3; i++) {
-
Vector3 axis = point_axis.cross(p_transform_b.basis.get_axis(i)).cross(p_transform_b.basis.get_axis(i)).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
separator.generate_contacts();
@@ -499,14 +487,14 @@ static void _collision_sphere_box(const Shape3DSW *p_a, const Transform &p_trans
template <bool withMargin>
static void _collision_sphere_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b);
SeparatorAxisTest<SphereShape3DSW, CapsuleShape3DSW, withMargin> separator(sphere_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
//capsule sphere 1, sphere
@@ -514,15 +502,17 @@ static void _collision_sphere_capsule(const Shape3DSW *p_a, const Transform &p_t
Vector3 capsule_ball_1 = p_transform_b.origin + capsule_axis;
- if (!separator.test_axis((capsule_ball_1 - p_transform_a.origin).normalized()))
+ if (!separator.test_axis((capsule_ball_1 - p_transform_a.origin).normalized())) {
return;
+ }
//capsule sphere 2, sphere
Vector3 capsule_ball_2 = p_transform_b.origin - capsule_axis;
- if (!separator.test_axis((capsule_ball_2 - p_transform_a.origin).normalized()))
+ if (!separator.test_axis((capsule_ball_2 - p_transform_a.origin).normalized())) {
return;
+ }
//capsule edge, sphere
@@ -530,8 +520,9 @@ static void _collision_sphere_capsule(const Shape3DSW *p_a, const Transform &p_t
Vector3 axis = b2a.cross(capsule_axis).cross(capsule_axis).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
separator.generate_contacts();
}
@@ -542,36 +533,35 @@ static void _collision_sphere_cylinder(const Shape3DSW *p_a, const Transform &p_
template <bool withMargin>
static void _collision_sphere_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
SeparatorAxisTest<SphereShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
// faces of B
for (int i = 0; i < face_count; i++) {
-
Vector3 axis = p_transform_b.xform(faces[i].plane).normal;
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// edges of B
for (int i = 0; i < edge_count; i++) {
-
Vector3 v1 = p_transform_b.xform(vertices[edges[i].a]);
Vector3 v2 = p_transform_b.xform(vertices[edges[i].b]);
Vector3 v3 = p_transform_a.origin;
@@ -581,20 +571,21 @@ static void _collision_sphere_convex_polygon(const Shape3DSW *p_a, const Transfo
Vector3 axis = n1.cross(n2).cross(n1).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// vertices of B
for (int i = 0; i < vertex_count; i++) {
-
Vector3 v1 = p_transform_b.xform(vertices[i]);
Vector3 v2 = p_transform_a.origin;
Vector3 axis = (v2 - v1).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
separator.generate_contacts();
@@ -602,7 +593,6 @@ static void _collision_sphere_convex_polygon(const Shape3DSW *p_a, const Transfo
template <bool withMargin>
static void _collision_sphere_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a);
const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
@@ -614,12 +604,12 @@ static void _collision_sphere_face(const Shape3DSW *p_a, const Transform &p_tran
p_transform_b.xform(face_B->vertex[2]),
};
- if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized()))
+ if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized())) {
return;
+ }
// edges and points of B
for (int i = 0; i < 3; i++) {
-
Vector3 n1 = vertex[i] - p_transform_a.origin;
if (!separator.test_axis(n1.normalized())) {
@@ -640,44 +630,43 @@ static void _collision_sphere_face(const Shape3DSW *p_a, const Transform &p_tran
template <bool withMargin>
static void _collision_box_box(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
const BoxShape3DSW *box_B = static_cast<const BoxShape3DSW *>(p_b);
SeparatorAxisTest<BoxShape3DSW, BoxShape3DSW, withMargin> separator(box_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
// test faces of A
for (int i = 0; i < 3; i++) {
-
Vector3 axis = p_transform_a.basis.get_axis(i).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// test faces of B
for (int i = 0; i < 3; i++) {
-
Vector3 axis = p_transform_b.basis.get_axis(i).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// test combined edges
for (int i = 0; i < 3; i++) {
-
for (int j = 0; j < 3; j++) {
-
Vector3 axis = p_transform_a.basis.get_axis(i).cross(p_transform_b.basis.get_axis(j));
- if (Math::is_zero_approx(axis.length_squared()))
+ if (Math::is_zero_approx(axis.length_squared())) {
continue;
+ }
axis.normalize();
if (!separator.test_axis(axis)) {
@@ -718,18 +707,19 @@ static void _collision_box_box(const Shape3DSW *p_a, const Transform &p_transfor
//now try edges, which become cylinders!
for (int i = 0; i < 3; i++) {
-
//a ->b
Vector3 axis_a = p_transform_a.basis.get_axis(i);
- if (!separator.test_axis(axis_ab.cross(axis_a).cross(axis_a).normalized()))
+ if (!separator.test_axis(axis_ab.cross(axis_a).cross(axis_a).normalized())) {
return;
+ }
//b ->a
Vector3 axis_b = p_transform_b.basis.get_axis(i);
- if (!separator.test_axis(axis_ab.cross(axis_b).cross(axis_b).normalized()))
+ if (!separator.test_axis(axis_ab.cross(axis_b).cross(axis_b).normalized())) {
return;
+ }
}
}
@@ -738,22 +728,22 @@ static void _collision_box_box(const Shape3DSW *p_a, const Transform &p_transfor
template <bool withMargin>
static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b);
SeparatorAxisTest<BoxShape3DSW, CapsuleShape3DSW, withMargin> separator(box_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
// faces of A
for (int i = 0; i < 3; i++) {
-
Vector3 axis = p_transform_a.basis.get_axis(i);
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
Vector3 cyl_axis = p_transform_b.basis.get_axis(2).normalized();
@@ -761,15 +751,16 @@ static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_tran
// edges of A, capsule cylinder
for (int i = 0; i < 3; i++) {
-
// cylinder
Vector3 box_axis = p_transform_a.basis.get_axis(i);
Vector3 axis = box_axis.cross(cyl_axis);
- if (Math::is_zero_approx(axis.length_squared()))
+ if (Math::is_zero_approx(axis.length_squared())) {
continue;
+ }
- if (!separator.test_axis(axis.normalized()))
+ if (!separator.test_axis(axis.normalized())) {
return;
+ }
}
// points of A, capsule cylinder
@@ -783,14 +774,16 @@ static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_tran
he.y *= (j * 2 - 1);
he.z *= (k * 2 - 1);
Vector3 point = p_transform_a.origin;
- for (int l = 0; l < 3; l++)
+ for (int l = 0; l < 3; l++) {
point += p_transform_a.basis.get_axis(l) * he[l];
+ }
//Vector3 axis = (point - cyl_axis * cyl_axis.dot(point)).normalized();
Vector3 axis = Plane(cyl_axis, 0).project(point).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
}
}
@@ -798,7 +791,6 @@ static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_tran
// capsule balls, edges of A
for (int i = 0; i < 2; i++) {
-
Vector3 capsule_axis = p_transform_b.basis.get_axis(2) * (capsule_B->get_height() * 0.5);
Vector3 sphere_pos = p_transform_b.origin + ((i == 0) ? capsule_axis : -capsule_axis);
@@ -814,17 +806,18 @@ static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_tran
// use point to test axis
Vector3 point_axis = (sphere_pos - cpoint).normalized();
- if (!separator.test_axis(point_axis))
+ if (!separator.test_axis(point_axis)) {
return;
+ }
// test edges of A
for (int j = 0; j < 3; j++) {
-
Vector3 axis = point_axis.cross(p_transform_a.basis.get_axis(j)).cross(p_transform_a.basis.get_axis(j)).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
}
@@ -837,63 +830,60 @@ static void _collision_box_cylinder(const Shape3DSW *p_a, const Transform &p_tra
template <bool withMargin>
static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
SeparatorAxisTest<BoxShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(box_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
// faces of A
for (int i = 0; i < 3; i++) {
-
Vector3 axis = p_transform_a.basis.get_axis(i).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// faces of B
for (int i = 0; i < face_count; i++) {
-
Vector3 axis = p_transform_b.xform(faces[i].plane).normal;
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// A<->B edges
for (int i = 0; i < 3; i++) {
-
Vector3 e1 = p_transform_a.basis.get_axis(i);
for (int j = 0; j < edge_count; j++) {
-
Vector3 e2 = p_transform_b.basis.xform(vertices[edges[j].a]) - p_transform_b.basis.xform(vertices[edges[j].b]);
Vector3 axis = e1.cross(e2).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
}
if (withMargin) {
-
// calculate closest points between vertices and box edges
for (int v = 0; v < vertex_count; v++) {
-
Vector3 vtxb = p_transform_b.xform(vertices[v]);
Vector3 ab_vec = vtxb - p_transform_a.origin;
@@ -914,12 +904,12 @@ static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform
//now try edges, which become cylinders!
for (int i = 0; i < 3; i++) {
-
//a ->b
Vector3 axis_a = p_transform_a.basis.get_axis(i);
- if (!separator.test_axis(axis_ab.cross(axis_a).cross(axis_a).normalized()))
+ if (!separator.test_axis(axis_ab.cross(axis_a).cross(axis_a).normalized())) {
return;
+ }
}
}
@@ -932,17 +922,18 @@ static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform
he.y *= (j * 2 - 1);
he.z *= (k * 2 - 1);
Vector3 point = p_transform_a.origin;
- for (int l = 0; l < 3; l++)
+ for (int l = 0; l < 3; l++) {
point += p_transform_a.basis.get_axis(l) * he[l];
+ }
for (int e = 0; e < edge_count; e++) {
-
Vector3 p1 = p_transform_b.xform(vertices[edges[e].a]);
Vector3 p2 = p_transform_b.xform(vertices[edges[e].b]);
Vector3 n = (p2 - p1);
- if (!separator.test_axis((point - p2).cross(n).cross(n).normalized()))
+ if (!separator.test_axis((point - p2).cross(n).cross(n).normalized())) {
return;
+ }
}
}
}
@@ -954,7 +945,6 @@ static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform
template <bool withMargin>
static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a);
const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
@@ -966,38 +956,36 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transfo
p_transform_b.xform(face_B->vertex[2]),
};
- if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized()))
+ if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized())) {
return;
+ }
// faces of A
for (int i = 0; i < 3; i++) {
-
Vector3 axis = p_transform_a.basis.get_axis(i).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// combined edges
for (int i = 0; i < 3; i++) {
-
Vector3 e = vertex[i] - vertex[(i + 1) % 3];
for (int j = 0; j < 3; j++) {
-
Vector3 axis = p_transform_a.basis.get_axis(j);
- if (!separator.test_axis(e.cross(axis).normalized()))
+ if (!separator.test_axis(e.cross(axis).normalized())) {
return;
+ }
}
}
if (withMargin) {
-
// calculate closest points between vertices and box edges
for (int v = 0; v < 3; v++) {
-
Vector3 ab_vec = vertex[v] - p_transform_a.origin;
Vector3 cnormal_a = p_transform_a.basis.xform_inv(ab_vec);
@@ -1017,12 +1005,12 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transfo
//now try edges, which become cylinders!
for (int i = 0; i < 3; i++) {
-
//a ->b
Vector3 axis_a = p_transform_a.basis.get_axis(i);
- if (!separator.test_axis(axis_ab.cross(axis_a).cross(axis_a).normalized()))
+ if (!separator.test_axis(axis_ab.cross(axis_a).cross(axis_a).normalized())) {
return;
+ }
}
}
@@ -1035,18 +1023,19 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transfo
he.y *= (j * 2 - 1);
he.z *= (k * 2 - 1);
Vector3 point = p_transform_a.origin;
- for (int l = 0; l < 3; l++)
+ for (int l = 0; l < 3; l++) {
point += p_transform_a.basis.get_axis(l) * he[l];
+ }
for (int e = 0; e < 3; e++) {
-
Vector3 p1 = vertex[e];
Vector3 p2 = vertex[(e + 1) % 3];
Vector3 n = (p2 - p1);
- if (!separator.test_axis((point - p2).cross(n).cross(n).normalized()))
+ if (!separator.test_axis((point - p2).cross(n).cross(n).normalized())) {
return;
+ }
}
}
}
@@ -1058,14 +1047,14 @@ static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transfo
template <bool withMargin>
static void _collision_capsule_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a);
const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b);
SeparatorAxisTest<CapsuleShape3DSW, CapsuleShape3DSW, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
// some values
@@ -1079,34 +1068,43 @@ static void _collision_capsule_capsule(const Shape3DSW *p_a, const Transform &p_
//balls-balls
- if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_1).normalized()))
+ if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_1).normalized())) {
return;
- if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_2).normalized()))
+ }
+ if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_2).normalized())) {
return;
+ }
- if (!separator.test_axis((capsule_A_ball_2 - capsule_B_ball_1).normalized()))
+ if (!separator.test_axis((capsule_A_ball_2 - capsule_B_ball_1).normalized())) {
return;
- if (!separator.test_axis((capsule_A_ball_2 - capsule_B_ball_2).normalized()))
+ }
+ if (!separator.test_axis((capsule_A_ball_2 - capsule_B_ball_2).normalized())) {
return;
+ }
// edges-balls
- if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_1).cross(capsule_A_axis).cross(capsule_A_axis).normalized()))
+ if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_1).cross(capsule_A_axis).cross(capsule_A_axis).normalized())) {
return;
+ }
- if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_2).cross(capsule_A_axis).cross(capsule_A_axis).normalized()))
+ if (!separator.test_axis((capsule_A_ball_1 - capsule_B_ball_2).cross(capsule_A_axis).cross(capsule_A_axis).normalized())) {
return;
+ }
- if (!separator.test_axis((capsule_B_ball_1 - capsule_A_ball_1).cross(capsule_B_axis).cross(capsule_B_axis).normalized()))
+ if (!separator.test_axis((capsule_B_ball_1 - capsule_A_ball_1).cross(capsule_B_axis).cross(capsule_B_axis).normalized())) {
return;
+ }
- if (!separator.test_axis((capsule_B_ball_1 - capsule_A_ball_2).cross(capsule_B_axis).cross(capsule_B_axis).normalized()))
+ if (!separator.test_axis((capsule_B_ball_1 - capsule_A_ball_2).cross(capsule_B_axis).cross(capsule_B_axis).normalized())) {
return;
+ }
// edges
- if (!separator.test_axis(capsule_A_axis.cross(capsule_B_axis).normalized()))
+ if (!separator.test_axis(capsule_A_axis.cross(capsule_B_axis).normalized())) {
return;
+ }
separator.generate_contacts();
}
@@ -1117,48 +1115,47 @@ static void _collision_capsule_cylinder(const Shape3DSW *p_a, const Transform &p
template <bool withMargin>
static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a);
const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
SeparatorAxisTest<CapsuleShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(capsule_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
// faces of B
for (int i = 0; i < face_count; i++) {
-
Vector3 axis = p_transform_b.xform(faces[i].plane).normal;
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// edges of B, capsule cylinder
for (int i = 0; i < edge_count; i++) {
-
// cylinder
Vector3 edge_axis = p_transform_b.basis.xform(vertices[edges[i].a]) - p_transform_b.basis.xform(vertices[edges[i].b]);
Vector3 axis = edge_axis.cross(p_transform_a.basis.get_axis(2)).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// capsule balls, edges of B
for (int i = 0; i < 2; i++) {
-
// edges of B, capsule cylinder
Vector3 capsule_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5);
@@ -1166,14 +1163,14 @@ static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transf
Vector3 sphere_pos = p_transform_a.origin + ((i == 0) ? capsule_axis : -capsule_axis);
for (int j = 0; j < edge_count; j++) {
-
Vector3 n1 = sphere_pos - p_transform_b.xform(vertices[edges[j].a]);
Vector3 n2 = p_transform_b.basis.xform(vertices[edges[j].a]) - p_transform_b.basis.xform(vertices[edges[j].b]);
Vector3 axis = n1.cross(n2).cross(n2).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
}
@@ -1182,7 +1179,6 @@ static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transf
template <bool withMargin>
static void _collision_capsule_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a);
const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
@@ -1194,41 +1190,44 @@ static void _collision_capsule_face(const Shape3DSW *p_a, const Transform &p_tra
p_transform_b.xform(face_B->vertex[2]),
};
- if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized()))
+ if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized())) {
return;
+ }
// edges of B, capsule cylinder
Vector3 capsule_axis = p_transform_a.basis.get_axis(2) * (capsule_A->get_height() * 0.5);
for (int i = 0; i < 3; i++) {
-
// edge-cylinder
Vector3 edge_axis = vertex[i] - vertex[(i + 1) % 3];
Vector3 axis = edge_axis.cross(capsule_axis).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
- if (!separator.test_axis((p_transform_a.origin - vertex[i]).cross(capsule_axis).cross(capsule_axis).normalized()))
+ if (!separator.test_axis((p_transform_a.origin - vertex[i]).cross(capsule_axis).cross(capsule_axis).normalized())) {
return;
+ }
for (int j = 0; j < 2; j++) {
-
// point-spheres
Vector3 sphere_pos = p_transform_a.origin + ((j == 0) ? capsule_axis : -capsule_axis);
Vector3 n1 = sphere_pos - vertex[i];
- if (!separator.test_axis(n1.normalized()))
+ if (!separator.test_axis(n1.normalized())) {
return;
+ }
Vector3 n2 = edge_axis;
axis = n1.cross(n2).cross(n2);
- if (!separator.test_axis(axis.normalized()))
+ if (!separator.test_axis(axis.normalized())) {
return;
+ }
}
}
@@ -1249,111 +1248,106 @@ static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform &p_tr
template <bool withMargin>
static void _collision_convex_polygon_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const ConvexPolygonShape3DSW *convex_polygon_A = static_cast<const ConvexPolygonShape3DSW *>(p_a);
const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b);
SeparatorAxisTest<ConvexPolygonShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- if (!separator.test_previous_axis())
+ if (!separator.test_previous_axis()) {
return;
+ }
- const Geometry::MeshData &mesh_A = convex_polygon_A->get_mesh();
+ const Geometry3D::MeshData &mesh_A = convex_polygon_A->get_mesh();
- const Geometry::MeshData::Face *faces_A = mesh_A.faces.ptr();
+ const Geometry3D::MeshData::Face *faces_A = mesh_A.faces.ptr();
int face_count_A = mesh_A.faces.size();
- const Geometry::MeshData::Edge *edges_A = mesh_A.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges_A = mesh_A.edges.ptr();
int edge_count_A = mesh_A.edges.size();
const Vector3 *vertices_A = mesh_A.vertices.ptr();
int vertex_count_A = mesh_A.vertices.size();
- const Geometry::MeshData &mesh_B = convex_polygon_B->get_mesh();
+ const Geometry3D::MeshData &mesh_B = convex_polygon_B->get_mesh();
- const Geometry::MeshData::Face *faces_B = mesh_B.faces.ptr();
+ const Geometry3D::MeshData::Face *faces_B = mesh_B.faces.ptr();
int face_count_B = mesh_B.faces.size();
- const Geometry::MeshData::Edge *edges_B = mesh_B.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges_B = mesh_B.edges.ptr();
int edge_count_B = mesh_B.edges.size();
const Vector3 *vertices_B = mesh_B.vertices.ptr();
int vertex_count_B = mesh_B.vertices.size();
// faces of A
for (int i = 0; i < face_count_A; i++) {
-
Vector3 axis = p_transform_a.xform(faces_A[i].plane).normal;
//Vector3 axis = p_transform_a.basis.xform( faces_A[i].plane.normal ).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// faces of B
for (int i = 0; i < face_count_B; i++) {
-
Vector3 axis = p_transform_b.xform(faces_B[i].plane).normal;
//Vector3 axis = p_transform_b.basis.xform( faces_B[i].plane.normal ).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// A<->B edges
for (int i = 0; i < edge_count_A; i++) {
-
Vector3 e1 = p_transform_a.basis.xform(vertices_A[edges_A[i].a]) - p_transform_a.basis.xform(vertices_A[edges_A[i].b]);
for (int j = 0; j < edge_count_B; j++) {
-
Vector3 e2 = p_transform_b.basis.xform(vertices_B[edges_B[j].a]) - p_transform_b.basis.xform(vertices_B[edges_B[j].b]);
Vector3 axis = e1.cross(e2).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
}
if (withMargin) {
-
//vertex-vertex
for (int i = 0; i < vertex_count_A; i++) {
-
Vector3 va = p_transform_a.xform(vertices_A[i]);
for (int j = 0; j < vertex_count_B; j++) {
-
- if (!separator.test_axis((va - p_transform_b.xform(vertices_B[j])).normalized()))
+ if (!separator.test_axis((va - p_transform_b.xform(vertices_B[j])).normalized())) {
return;
+ }
}
}
//edge-vertex (shell)
for (int i = 0; i < edge_count_A; i++) {
-
Vector3 e1 = p_transform_a.basis.xform(vertices_A[edges_A[i].a]);
Vector3 e2 = p_transform_a.basis.xform(vertices_A[edges_A[i].b]);
Vector3 n = (e2 - e1);
for (int j = 0; j < vertex_count_B; j++) {
-
Vector3 e3 = p_transform_b.xform(vertices_B[j]);
- if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized()))
+ if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized())) {
return;
+ }
}
}
for (int i = 0; i < edge_count_B; i++) {
-
Vector3 e1 = p_transform_b.basis.xform(vertices_B[edges_B[i].a]);
Vector3 e2 = p_transform_b.basis.xform(vertices_B[edges_B[i].b]);
Vector3 n = (e2 - e1);
for (int j = 0; j < vertex_count_A; j++) {
-
Vector3 e3 = p_transform_a.xform(vertices_A[j]);
- if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized()))
+ if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized())) {
return;
+ }
}
}
}
@@ -1363,17 +1357,16 @@ static void _collision_convex_polygon_convex_polygon(const Shape3DSW *p_a, const
template <bool withMargin>
static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
-
const ConvexPolygonShape3DSW *convex_polygon_A = static_cast<const ConvexPolygonShape3DSW *>(p_a);
const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b);
SeparatorAxisTest<ConvexPolygonShape3DSW, FaceShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
- const Geometry::MeshData &mesh = convex_polygon_A->get_mesh();
+ const Geometry3D::MeshData &mesh = convex_polygon_A->get_mesh();
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
@@ -1384,77 +1377,73 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
p_transform_b.xform(face_B->vertex[2]),
};
- if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized()))
+ if (!separator.test_axis((vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]).normalized())) {
return;
+ }
// faces of A
for (int i = 0; i < face_count; i++) {
-
//Vector3 axis = p_transform_a.xform( faces[i].plane ).normal;
Vector3 axis = p_transform_a.basis.xform(faces[i].plane.normal).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
// A<->B edges
for (int i = 0; i < edge_count; i++) {
-
Vector3 e1 = p_transform_a.xform(vertices[edges[i].a]) - p_transform_a.xform(vertices[edges[i].b]);
for (int j = 0; j < 3; j++) {
-
Vector3 e2 = vertex[j] - vertex[(j + 1) % 3];
Vector3 axis = e1.cross(e2).normalized();
- if (!separator.test_axis(axis))
+ if (!separator.test_axis(axis)) {
return;
+ }
}
}
if (withMargin) {
-
//vertex-vertex
for (int i = 0; i < vertex_count; i++) {
-
Vector3 va = p_transform_a.xform(vertices[i]);
for (int j = 0; j < 3; j++) {
-
- if (!separator.test_axis((va - vertex[j]).normalized()))
+ if (!separator.test_axis((va - vertex[j]).normalized())) {
return;
+ }
}
}
//edge-vertex (shell)
for (int i = 0; i < edge_count; i++) {
-
Vector3 e1 = p_transform_a.basis.xform(vertices[edges[i].a]);
Vector3 e2 = p_transform_a.basis.xform(vertices[edges[i].b]);
Vector3 n = (e2 - e1);
for (int j = 0; j < 3; j++) {
-
Vector3 e3 = vertex[j];
- if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized()))
+ if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized())) {
return;
+ }
}
}
for (int i = 0; i < 3; i++) {
-
Vector3 e1 = vertex[i];
Vector3 e2 = vertex[(i + 1) % 3];
Vector3 n = (e2 - e1);
for (int j = 0; j < vertex_count; j++) {
-
Vector3 e3 = p_transform_a.xform(vertices[j]);
- if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized()))
+ if (!separator.test_axis((e1 - e3).cross(n).cross(n).normalized())) {
return;
+ }
}
}
}
@@ -1463,7 +1452,6 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
}
bool sat_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) {
-
PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_PLANE, false);
diff --git a/servers/physics_3d/collision_solver_3d_sw.cpp b/servers/physics_3d/collision_solver_3d_sw.cpp
index 5d31e1f546..e2bfaf990d 100644
--- a/servers/physics_3d/collision_solver_3d_sw.cpp
+++ b/servers/physics_3d/collision_solver_3d_sw.cpp
@@ -37,10 +37,10 @@
//#define collision_solver gjk_epa_calculate_penetration
bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
-
const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE)
+ if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
return false;
+ }
Plane p = p_transform_A.xform(plane->get_plane());
static const int max_supports = 16;
@@ -52,19 +52,20 @@ bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const T
bool found = false;
for (int i = 0; i < support_count; i++) {
-
supports[i] = p_transform_B.xform(supports[i]);
- if (p.distance_to(supports[i]) >= 0)
+ if (p.distance_to(supports[i]) >= 0) {
continue;
+ }
found = true;
Vector3 support_A = p.project(supports[i]);
if (p_result_callback) {
- if (p_swap_result)
+ if (p_swap_result) {
p_result_callback(supports[i], support_A, p_userdata);
- else
+ } else {
p_result_callback(support_A, supports[i], p_userdata);
+ }
}
}
@@ -72,7 +73,6 @@ bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const T
}
bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
-
const RayShape3DSW *ray = static_cast<const RayShape3DSW *>(p_shape_A);
Vector3 from = p_transform_A.origin;
@@ -85,8 +85,9 @@ bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform
to = ai.xform(to);
Vector3 p, n;
- if (!p_shape_B->intersect_segment(from, to, p, n))
+ if (!p_shape_B->intersect_segment(from, to, p, n)) {
return false;
+ }
Vector3 support_B = p_transform_B.xform(p);
if (ray->get_slips_on_slope()) {
@@ -95,16 +96,16 @@ bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform
}
if (p_result_callback) {
- if (p_swap_result)
+ if (p_swap_result) {
p_result_callback(support_B, support_A, p_userdata);
- else
+ } else {
p_result_callback(support_A, support_B, p_userdata);
+ }
}
return true;
}
struct _ConcaveCollisionInfo {
-
const Transform *transform_A;
const Shape3DSW *shape_A;
const Transform *transform_B;
@@ -121,20 +122,19 @@ struct _ConcaveCollisionInfo {
};
void CollisionSolver3DSW::concave_callback(void *p_userdata, Shape3DSW *p_convex) {
-
_ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata);
cinfo.aabb_tests++;
bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, nullptr, cinfo.margin_A, cinfo.margin_B);
- if (!collided)
+ if (!collided) {
return;
+ }
cinfo.collided = true;
cinfo.collisions++;
}
bool CollisionSolver3DSW::solve_concave(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A, real_t p_margin_B) {
-
const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B);
_ConcaveCollisionInfo cinfo;
@@ -158,7 +158,6 @@ bool CollisionSolver3DSW::solve_concave(const Shape3DSW *p_shape_A, const Transf
AABB local_aabb;
for (int i = 0; i < 3; i++) {
-
Vector3 axis(p_transform_B.basis.get_axis(i));
real_t axis_scale = 1.0 / axis.length();
axis *= axis_scale;
@@ -180,7 +179,6 @@ bool CollisionSolver3DSW::solve_concave(const Shape3DSW *p_shape_A, const Transf
}
bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) {
-
PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
PhysicsServer3D::ShapeType type_B = p_shape_B->get_type();
bool concave_A = p_shape_A->is_concave();
@@ -195,9 +193,9 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
}
if (type_A == PhysicsServer3D::SHAPE_PLANE) {
-
- if (type_B == PhysicsServer3D::SHAPE_PLANE)
+ if (type_B == PhysicsServer3D::SHAPE_PLANE) {
return false;
+ }
if (type_B == PhysicsServer3D::SHAPE_RAY) {
return false;
}
@@ -209,9 +207,9 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
}
} else if (type_A == PhysicsServer3D::SHAPE_RAY) {
-
- if (type_B == PhysicsServer3D::SHAPE_RAY)
+ if (type_B == PhysicsServer3D::SHAPE_RAY) {
return false;
+ }
if (swap) {
return solve_ray(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
@@ -220,35 +218,35 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
}
} else if (concave_B) {
-
- if (concave_A)
+ if (concave_A) {
return false;
+ }
- if (!swap)
+ if (!swap) {
return solve_concave(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, p_margin_A, p_margin_B);
- else
+ } else {
return solve_concave(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true, p_margin_A, p_margin_B);
+ }
} else {
-
return collision_solver(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, r_sep_axis, p_margin_A, p_margin_B);
}
}
void CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW *p_convex) {
-
_ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata);
cinfo.aabb_tests++;
- if (cinfo.collided)
+ if (cinfo.collided) {
return;
+ }
Vector3 close_A, close_B;
cinfo.collided = !gjk_epa_calculate_distance(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, close_A, close_B);
- if (cinfo.collided)
+ if (cinfo.collided) {
return;
+ }
if (!cinfo.tested || close_A.distance_squared_to(close_B) < cinfo.close_A.distance_squared_to(cinfo.close_B)) {
-
cinfo.close_A = close_A;
cinfo.close_B = close_B;
cinfo.tested = true;
@@ -258,10 +256,10 @@ void CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW
}
bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
-
const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
- if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE)
+ if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
return false;
+ }
Plane p = p_transform_A.xform(plane->get_plane());
static const int max_supports = 16;
@@ -275,14 +273,14 @@ bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const
real_t closest_d = 0;
for (int i = 0; i < support_count; i++) {
-
supports[i] = p_transform_B.xform(supports[i]);
real_t d = p.distance_to(supports[i]);
if (i == 0 || d < closest_d) {
closest = supports[i];
closest_d = d;
- if (d <= 0)
+ if (d <= 0) {
collided = true;
+ }
}
}
@@ -293,12 +291,11 @@ bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const
}
bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) {
-
- if (p_shape_A->is_concave())
+ if (p_shape_A->is_concave()) {
return false;
+ }
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
-
Vector3 a, b;
bool col = solve_distance_plane(p_shape_B, p_transform_B, p_shape_A, p_transform_A, a, b);
r_point_A = b;
@@ -306,9 +303,9 @@ bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Trans
return !col;
} else if (p_shape_B->is_concave()) {
-
- if (p_shape_A->is_concave())
+ if (p_shape_A->is_concave()) {
return false;
+ }
const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B);
@@ -338,7 +335,6 @@ bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Trans
AABB local_aabb;
for (int i = 0; i < 3; i++) {
-
Vector3 axis(p_transform_B.basis.get_axis(i));
real_t axis_scale = ((real_t)1.0) / axis.length();
axis *= axis_scale;
@@ -366,7 +362,6 @@ bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Trans
return !cinfo.collided;
} else {
-
return gjk_epa_calculate_distance(p_shape_A, p_transform_A, p_shape_B, p_transform_B, r_point_A, r_point_B); //should pass sepaxis..
}
}
diff --git a/servers/physics_3d/constraint_3d_sw.h b/servers/physics_3d/constraint_3d_sw.h
index 5e2b00404b..081ddb0382 100644
--- a/servers/physics_3d/constraint_3d_sw.h
+++ b/servers/physics_3d/constraint_3d_sw.h
@@ -34,7 +34,6 @@
#include "body_3d_sw.h"
class Constraint3DSW {
-
Body3DSW **_body_ptr;
int _body_count;
uint64_t island_step;
diff --git a/servers/physics_3d/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp
index db37f261ce..d99a2532f8 100644
--- a/servers/physics_3d/gjk_epa.cpp
+++ b/servers/physics_3d/gjk_epa.cpp
@@ -123,10 +123,12 @@ struct MinkowskiDiff {
_FORCE_INLINE_ Vector3 Support ( const Vector3& d,U index ) const
{
- if ( index )
+ if ( index ) {
return ( Support1 ( d ) );
- else
+ } else {
return ( Support0 ( d ) );
+
+}
}
};
@@ -278,7 +280,9 @@ struct GJK
m_free[m_nfree++] = cs.c[i];
}
}
- if(mask==15) m_status=eStatus::Inside;
+ if(mask==15) { m_status=eStatus::Inside;
+
+}
}
else
{/* Return old simplex */
@@ -307,10 +311,14 @@ struct GJK
Vector3 axis=Vector3(0,0,0);
axis[i]=1;
appendvertice(*m_simplex, axis);
- if(EncloseOrigin()) return(true);
+ if(EncloseOrigin()) { return(true);
+
+}
removevertice(*m_simplex);
appendvertice(*m_simplex,-axis);
- if(EncloseOrigin()) return(true);
+ if(EncloseOrigin()) { return(true);
+
+}
removevertice(*m_simplex);
}
}
@@ -326,10 +334,14 @@ struct GJK
if(p.length_squared()>0)
{
appendvertice(*m_simplex, p);
- if(EncloseOrigin()) return(true);
+ if(EncloseOrigin()) { return(true);
+
+}
removevertice(*m_simplex);
appendvertice(*m_simplex,-p);
- if(EncloseOrigin()) return(true);
+ if(EncloseOrigin()) { return(true);
+
+}
removevertice(*m_simplex);
}
}
@@ -342,10 +354,14 @@ struct GJK
if(n.length_squared()>0)
{
appendvertice(*m_simplex,n);
- if(EncloseOrigin()) return(true);
+ if(EncloseOrigin()) { return(true);
+
+}
removevertice(*m_simplex);
appendvertice(*m_simplex,-n);
- if(EncloseOrigin()) return(true);
+ if(EncloseOrigin()) { return(true);
+
+}
removevertice(*m_simplex);
}
}
@@ -354,8 +370,10 @@ struct GJK
{
if(Math::abs(det( m_simplex->c[0]->w-m_simplex->c[3]->w,
m_simplex->c[1]->w-m_simplex->c[3]->w,
- m_simplex->c[2]->w-m_simplex->c[3]->w))>0)
+ m_simplex->c[2]->w-m_simplex->c[3]->w))>0) {
return(true);
+
+}
}
break;
}
@@ -513,16 +531,16 @@ struct GJK
};
struct sList
{
- sFace* root;
- U count;
- sList() : root(nullptr),count(0) {}
+ sFace* root = nullptr;
+ U count = 0;
+ sList() {}
};
struct sHorizon
{
- sFace* cf;
- sFace* ff;
- U nf;
- sHorizon() : cf(nullptr),ff(nullptr),nf(0) {}
+ sFace* cf = nullptr;
+ sFace* ff = nullptr;
+ U nf = 0;
+ sHorizon() {}
};
struct eStatus { enum _ {
Valid,
@@ -561,15 +579,23 @@ struct GJK
{
face->l[0] = nullptr;
face->l[1] = list.root;
- if(list.root) list.root->l[0]=face;
+ if(list.root) { list.root->l[0]=face;
+
+}
list.root = face;
++list.count;
}
static inline void remove(sList& list,sFace* face)
{
- if(face->l[1]) face->l[1]->l[0]=face->l[0];
- if(face->l[0]) face->l[0]->l[1]=face->l[1];
- if(face==list.root) list.root=face->l[1];
+ if(face->l[1]) { face->l[1]->l[0]=face->l[0];
+
+}
+ if(face->l[0]) { face->l[0]->l[1]=face->l[1];
+
+}
+ if(face==list.root) { list.root=face->l[1];
+
+}
--list.count;
}
@@ -650,7 +676,9 @@ struct GJK
remove(m_hull,best);
append(m_stock,best);
best=findbest();
- if(best->p>=outer.p) outer=*best;
+ if(best->p>=outer.p) { outer=*best;
+
+}
} else { m_status=eStatus::InvalidHull;break; }
} else { m_status=eStatus::AccuraryReached;break; }
} else { m_status=eStatus::OutOfVertices;break; }
@@ -679,10 +707,12 @@ struct GJK
m_status = eStatus::FallBack;
m_normal = -guess;
const real_t nl=m_normal.length();
- if(nl>0)
+ if(nl>0) {
m_normal = m_normal/nl;
- else
+ } else {
m_normal = Vector3(1,0,0);
+
+}
m_depth = 0;
m_result.rank=1;
m_result.c[0]=simplex.c[0];
@@ -716,8 +746,12 @@ struct GJK
if(forced||(face->d>=-EPA_PLANE_EPS))
{
return(face);
- } else m_status=eStatus::NonConvex;
- } else m_status=eStatus::Degenerated;
+ } else { m_status=eStatus::NonConvex;
+
+}
+ } else { m_status=eStatus::Degenerated;
+
+}
remove(m_hull,face);
append(m_stock,face);
return(nullptr);
@@ -758,7 +792,9 @@ struct GJK
if(nf)
{
bind(nf,0,f,e);
- if(horizon.cf) bind(horizon.cf,1,nf,2); else horizon.ff=nf;
+ if(horizon.cf) { bind(horizon.cf,1,nf,2); } else { horizon.ff=nf;
+
+}
horizon.cf=nf;
++horizon.nf;
return(true);
@@ -847,6 +883,7 @@ bool Distance( const Shape3DSW* shape0,
}
}
+
//
bool Penetration( const Shape3DSW* shape0,
const Transform& wtrs0,
@@ -879,7 +916,9 @@ bool Penetration( const Shape3DSW* shape0,
results.normal = -epa.m_normal;
results.distance = -epa.m_depth;
return(true);
- } else results.status=sResults::EPA_Failed;
+ } else { results.status=sResults::EPA_Failed;
+
+}
}
break;
case GJK::eStatus::Failed:
@@ -891,6 +930,7 @@ bool Penetration( const Shape3DSW* shape0,
}
+
/* Symbols cleanup */
#undef GJK_MAX_ITERATIONS
@@ -915,11 +955,9 @@ bool Penetration( const Shape3DSW* shape0,
/* clang-format on */
bool gjk_epa_calculate_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B) {
-
GjkEpa2::sResults res;
if (GjkEpa2::Distance(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_transform_B.origin - p_transform_A.origin, res)) {
-
r_result_A = res.witnesses[0];
r_result_B = res.witnesses[1];
return true;
@@ -929,15 +967,15 @@ bool gjk_epa_calculate_distance(const Shape3DSW *p_shape_A, const Transform &p_t
}
bool gjk_epa_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap) {
-
GjkEpa2::sResults res;
if (GjkEpa2::Penetration(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_transform_B.origin - p_transform_A.origin, res)) {
if (p_result_callback) {
- if (p_swap)
+ if (p_swap) {
p_result_callback(res.witnesses[1], res.witnesses[0], p_userdata);
- else
+ } else {
p_result_callback(res.witnesses[0], res.witnesses[1], p_userdata);
+ }
}
return true;
}
diff --git a/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp b/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp
index 56dd8044e4..9d10ede608 100644
--- a/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp
@@ -52,7 +52,6 @@ Written by: Marcus Hennix
#include "cone_twist_joint_3d_sw.h"
static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
-
if (Math::abs(n.z) > Math_SQRT12) {
// choose p in y-z plane
real_t a = n[1] * n[1] + n[2] * n[2];
@@ -87,7 +86,6 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
ConeTwistJoint3DSW::ConeTwistJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) :
Joint3DSW(_arr, 2) {
-
A = rbA;
B = rbB;
@@ -238,7 +236,6 @@ bool ConeTwistJoint3DSW::setup(real_t p_timestep) {
}
void ConeTwistJoint3DSW::solve(real_t p_timestep) {
-
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
@@ -309,27 +306,21 @@ void ConeTwistJoint3DSW::solve(real_t p_timestep) {
}
void ConeTwistJoint3DSW::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) {
-
switch (p_param) {
case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
-
m_swingSpan1 = p_value;
m_swingSpan2 = p_value;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
-
m_twistSpan = p_value;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
-
m_biasFactor = p_value;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
-
m_limitSoftness = p_value;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
-
m_relaxationFactor = p_value;
} break;
case PhysicsServer3D::CONE_TWIST_MAX:
@@ -338,26 +329,20 @@ void ConeTwistJoint3DSW::set_param(PhysicsServer3D::ConeTwistJointParam p_param,
}
real_t ConeTwistJoint3DSW::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
-
switch (p_param) {
case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
-
return m_swingSpan1;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
-
return m_twistSpan;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
-
return m_biasFactor;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
-
return m_limitSoftness;
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
-
return m_relaxationFactor;
} break;
case PhysicsServer3D::CONE_TWIST_MAX:
diff --git a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
index ae5cffdfa8..423bbc0dfd 100644
--- a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp
@@ -83,8 +83,9 @@ int G6DOFRotationalLimitMotor3DSW::testLimitValue(real_t test_value) {
real_t G6DOFRotationalLimitMotor3DSW::solveAngularLimits(
real_t timeStep, Vector3 &axis, real_t jacDiagABInv,
Body3DSW *body0, Body3DSW *body1) {
- if (!needApplyTorques())
+ if (!needApplyTorques()) {
return 0.0f;
+ }
real_t target_velocity = m_targetVelocity;
real_t maxMotorForce = m_maxMotorForce;
@@ -138,8 +139,9 @@ real_t G6DOFRotationalLimitMotor3DSW::solveAngularLimits(
Vector3 motorImp = clippedMotorImpulse * axis;
body0->apply_torque_impulse(motorImp);
- if (body1)
+ if (body1) {
body1->apply_torque_impulse(-motorImp);
+ }
return clippedMotorImpulse;
}
@@ -155,7 +157,6 @@ real_t G6DOFTranslationalLimitMotor3DSW::solveLinearAxis(
int limit_index,
const Vector3 &axis_normal_on_a,
const Vector3 &anchorPos) {
-
///find relative velocity
// Vector3 rel_pos1 = pointInA - body1->get_transform().origin;
// Vector3 rel_pos2 = pointInB - body2->get_transform().origin;
@@ -303,7 +304,6 @@ bool Generic6DOFJoint3DSW::testAngularLimitMotor(int axis_index) {
}
bool Generic6DOFJoint3DSW::setup(real_t p_timestep) {
-
// Clear accumulated impulses for the next simulation step
m_linearLimits.m_accumulatedImpulse = Vector3(real_t(0.), real_t(0.), real_t(0.));
int i;
@@ -327,10 +327,11 @@ bool Generic6DOFJoint3DSW::setup(real_t p_timestep) {
//linear part
for (i = 0; i < 3; i++) {
if (m_linearLimits.enable_limit[i] && m_linearLimits.isLimited(i)) {
- if (m_useLinearReferenceFrameA)
+ if (m_useLinearReferenceFrameA) {
normalWorld = m_calculatedTransformA.basis.get_axis(i);
- else
+ } else {
normalWorld = m_calculatedTransformB.basis.get_axis(i);
+ }
buildLinearJacobian(
m_jacLinear[i], normalWorld,
@@ -369,10 +370,11 @@ void Generic6DOFJoint3DSW::solve(real_t p_timestep) {
if (m_linearLimits.enable_limit[i] && m_linearLimits.isLimited(i)) {
jacDiagABInv = real_t(1.) / m_jacLinear[i].getDiagonal();
- if (m_useLinearReferenceFrameA)
+ if (m_useLinearReferenceFrameA) {
linear_axis = m_calculatedTransformA.basis.get_axis(i);
- else
+ } else {
linear_axis = m_calculatedTransformB.basis.get_axis(i);
+ }
m_linearLimits.solveLinearAxis(
m_timeStep,
@@ -388,7 +390,6 @@ void Generic6DOFJoint3DSW::solve(real_t p_timestep) {
real_t angularJacDiagABInv;
for (i = 0; i < 3; i++) {
if (m_angularLimits[i].m_enableLimit && m_angularLimits[i].needApplyTorques()) {
-
// get axis
angular_axis = getAxis(i);
@@ -411,7 +412,7 @@ real_t Generic6DOFJoint3DSW::getAngle(int axis_index) const {
return m_calculatedAxisAngleDiff[axis_index];
}
-void Generic6DOFJoint3DSW::calcAnchorPos(void) {
+void Generic6DOFJoint3DSW::calcAnchorPos() {
real_t imA = A->get_inv_mass();
real_t imB = B->get_inv_mass();
real_t weight;
@@ -426,75 +427,60 @@ void Generic6DOFJoint3DSW::calcAnchorPos(void) {
} // Generic6DOFJointSW::calcAnchorPos()
void Generic6DOFJoint3DSW::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
-
ERR_FAIL_INDEX(p_axis, 3);
switch (p_param) {
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
-
m_linearLimits.m_lowerLimit[p_axis] = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
-
m_linearLimits.m_upperLimit[p_axis] = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
-
m_linearLimits.m_limitSoftness[p_axis] = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
-
m_linearLimits.m_restitution[p_axis] = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
-
m_linearLimits.m_damping[p_axis] = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
-
m_angularLimits[p_axis].m_loLimit = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
-
m_angularLimits[p_axis].m_hiLimit = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
-
m_angularLimits[p_axis].m_limitSoftness = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
-
m_angularLimits[p_axis].m_damping = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
-
m_angularLimits[p_axis].m_bounce = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
-
m_angularLimits[p_axis].m_maxLimitForce = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
-
m_angularLimits[p_axis].m_ERP = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
-
m_angularLimits[p_axis].m_targetVelocity = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
-
m_angularLimits[p_axis].m_maxLimitForce = p_value;
} break;
@@ -531,71 +517,57 @@ real_t Generic6DOFJoint3DSW::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6
ERR_FAIL_INDEX_V(p_axis, 3, 0);
switch (p_param) {
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
-
return m_linearLimits.m_lowerLimit[p_axis];
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: {
-
return m_linearLimits.m_upperLimit[p_axis];
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
-
return m_linearLimits.m_limitSoftness[p_axis];
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
-
return m_linearLimits.m_restitution[p_axis];
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
-
return m_linearLimits.m_damping[p_axis];
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: {
-
return m_angularLimits[p_axis].m_loLimit;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: {
-
return m_angularLimits[p_axis].m_hiLimit;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
-
return m_angularLimits[p_axis].m_limitSoftness;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
-
return m_angularLimits[p_axis].m_damping;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
-
return m_angularLimits[p_axis].m_bounce;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
-
return m_angularLimits[p_axis].m_maxLimitForce;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
-
return m_angularLimits[p_axis].m_ERP;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
-
return m_angularLimits[p_axis].m_targetVelocity;
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
-
return m_angularLimits[p_axis].m_maxMotorForce;
} break;
@@ -630,20 +602,16 @@ real_t Generic6DOFJoint3DSW::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6
}
void Generic6DOFJoint3DSW::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) {
-
ERR_FAIL_INDEX(p_axis, 3);
switch (p_flag) {
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
-
m_linearLimits.enable_limit[p_axis] = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
-
m_angularLimits[p_axis].m_enableLimit = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
-
m_angularLimits[p_axis].m_enableMotor = p_value;
} break;
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
@@ -659,20 +627,17 @@ void Generic6DOFJoint3DSW::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOF
break; // Can't happen, but silences warning
}
}
-bool Generic6DOFJoint3DSW::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
+bool Generic6DOFJoint3DSW::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0);
switch (p_flag) {
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: {
-
return m_linearLimits.enable_limit[p_axis];
} break;
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: {
-
return m_angularLimits[p_axis].m_enableLimit;
} break;
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: {
-
return m_angularLimits[p_axis].m_enableMotor;
} break;
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: {
@@ -688,5 +653,5 @@ bool Generic6DOFJoint3DSW::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOF
break; // Can't happen, but silences warning
}
- return 0;
+ return false;
}
diff --git a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h
index f7aa607901..cc1423a1cb 100644
--- a/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h
+++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h
@@ -389,7 +389,7 @@ public:
return B;
}
- virtual void calcAnchorPos(void); // overridable
+ virtual void calcAnchorPos(); // overridable
void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value);
real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const;
diff --git a/servers/physics_3d/joints/hinge_joint_3d_sw.cpp b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
index dea1be5040..a879b4ca7f 100644
--- a/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp
@@ -50,7 +50,6 @@ subject to the following restrictions:
#include "hinge_joint_3d_sw.h"
static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
-
if (Math::abs(n.z) > Math_SQRT12) {
// choose p in y-z plane
real_t a = n[1] * n[1] + n[2] * n[2];
@@ -70,7 +69,6 @@ static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameA, const Transform &frameB) :
Joint3DSW(_arr, 2) {
-
A = rbA;
B = rbB;
@@ -103,7 +101,6 @@ HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &fr
HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB,
const Vector3 &axisInA, const Vector3 &axisInB) :
Joint3DSW(_arr, 2) {
-
A = rbA;
B = rbB;
@@ -158,7 +155,6 @@ HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivo
}
bool HingeJoint3DSW::setup(real_t p_step) {
-
m_appliedImpulse = real_t(0.);
if (!m_angularOnly) {
@@ -254,7 +250,6 @@ bool HingeJoint3DSW::setup(real_t p_step) {
}
void HingeJoint3DSW::solve(real_t p_step) {
-
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
@@ -365,12 +360,14 @@ void HingeJoint3DSW::solve(real_t p_step) {
}
}
}
+
/*
void HingeJointSW::updateRHS(real_t timeStep)
{
(void)timeStep;
}
+
*/
static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
@@ -397,9 +394,7 @@ real_t HingeJoint3DSW::get_hinge_angle() {
}
void HingeJoint3DSW::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) {
-
switch (p_param) {
-
case PhysicsServer3D::HINGE_JOINT_BIAS:
tau = p_value;
break;
@@ -430,9 +425,7 @@ void HingeJoint3DSW::set_param(PhysicsServer3D::HingeJointParam p_param, real_t
}
real_t HingeJoint3DSW::get_param(PhysicsServer3D::HingeJointParam p_param) const {
-
switch (p_param) {
-
case PhysicsServer3D::HINGE_JOINT_BIAS:
return tau;
case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
@@ -457,7 +450,6 @@ real_t HingeJoint3DSW::get_param(PhysicsServer3D::HingeJointParam p_param) const
}
void HingeJoint3DSW::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) {
-
switch (p_flag) {
case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
m_useLimit = p_value;
@@ -469,8 +461,8 @@ void HingeJoint3DSW::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_val
break; // Can't happen, but silences warning
}
}
-bool HingeJoint3DSW::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
+bool HingeJoint3DSW::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
switch (p_flag) {
case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
return m_useLimit;
diff --git a/servers/physics_3d/joints/hinge_joint_3d_sw.h b/servers/physics_3d/joints/hinge_joint_3d_sw.h
index eebead20b8..c5af888eca 100644
--- a/servers/physics_3d/joints/hinge_joint_3d_sw.h
+++ b/servers/physics_3d/joints/hinge_joint_3d_sw.h
@@ -54,7 +54,6 @@ subject to the following restrictions:
*/
class HingeJoint3DSW : public Joint3DSW {
-
union {
struct {
Body3DSW *A;
diff --git a/servers/physics_3d/joints/jacobian_entry_3d_sw.h b/servers/physics_3d/joints/jacobian_entry_3d_sw.h
index 7e605ab173..1737c21b3d 100644
--- a/servers/physics_3d/joints/jacobian_entry_3d_sw.h
+++ b/servers/physics_3d/joints/jacobian_entry_3d_sw.h
@@ -54,7 +54,7 @@ subject to the following restrictions:
class JacobianEntry3DSW {
public:
- JacobianEntry3DSW(){};
+ JacobianEntry3DSW() {}
//constraint between two different rigidbodies
JacobianEntry3DSW(
const Basis &world2A,
diff --git a/servers/physics_3d/joints/pin_joint_3d_sw.cpp b/servers/physics_3d/joints/pin_joint_3d_sw.cpp
index dd6b315152..230904408b 100644
--- a/servers/physics_3d/joints/pin_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/pin_joint_3d_sw.cpp
@@ -50,7 +50,6 @@ subject to the following restrictions:
#include "pin_joint_3d_sw.h"
bool PinJoint3DSW::setup(real_t p_step) {
-
m_appliedImpulse = real_t(0.);
Vector3 normal(0, 0, 0);
@@ -74,7 +73,6 @@ bool PinJoint3DSW::setup(real_t p_step) {
}
void PinJoint3DSW::solve(real_t p_step) {
-
Vector3 pivotAInW = A->get_transform().xform(m_pivotInA);
Vector3 pivotBInW = B->get_transform().xform(m_pivotInB);
@@ -111,10 +109,12 @@ void PinJoint3DSW::solve(real_t p_step) {
real_t impulseClamp = m_impulseClamp;
if (impulseClamp > 0) {
- if (impulse < -impulseClamp)
+ if (impulse < -impulseClamp) {
impulse = -impulseClamp;
- if (impulse > impulseClamp)
+ }
+ if (impulse > impulseClamp) {
impulse = impulseClamp;
+ }
}
m_appliedImpulse += impulse;
@@ -127,7 +127,6 @@ void PinJoint3DSW::solve(real_t p_step) {
}
void PinJoint3DSW::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) {
-
switch (p_param) {
case PhysicsServer3D::PIN_JOINT_BIAS:
m_tau = p_value;
@@ -142,7 +141,6 @@ void PinJoint3DSW::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_va
}
real_t PinJoint3DSW::get_param(PhysicsServer3D::PinJointParam p_param) const {
-
switch (p_param) {
case PhysicsServer3D::PIN_JOINT_BIAS:
return m_tau;
@@ -157,7 +155,6 @@ real_t PinJoint3DSW::get_param(PhysicsServer3D::PinJointParam p_param) const {
PinJoint3DSW::PinJoint3DSW(Body3DSW *p_body_a, const Vector3 &p_pos_a, Body3DSW *p_body_b, const Vector3 &p_pos_b) :
Joint3DSW(_arr, 2) {
-
A = p_body_a;
B = p_body_b;
m_pivotInA = p_pos_a;
diff --git a/servers/physics_3d/joints/pin_joint_3d_sw.h b/servers/physics_3d/joints/pin_joint_3d_sw.h
index 8e81ccf5e0..0181a4455b 100644
--- a/servers/physics_3d/joints/pin_joint_3d_sw.h
+++ b/servers/physics_3d/joints/pin_joint_3d_sw.h
@@ -54,7 +54,6 @@ subject to the following restrictions:
*/
class PinJoint3DSW : public Joint3DSW {
-
union {
struct {
Body3DSW *A;
diff --git a/servers/physics_3d/joints/slider_joint_3d_sw.cpp b/servers/physics_3d/joints/slider_joint_3d_sw.cpp
index b133f3d9ad..5b4609f24e 100644
--- a/servers/physics_3d/joints/slider_joint_3d_sw.cpp
+++ b/servers/physics_3d/joints/slider_joint_3d_sw.cpp
@@ -116,7 +116,6 @@ SliderJoint3DSW::SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &
Joint3DSW(_arr, 2),
m_frameInA(frameInA),
m_frameInB(frameInB) {
-
A = rbA;
B = rbB;
@@ -129,7 +128,6 @@ SliderJoint3DSW::SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &
//-----------------------------------------------------------------------------
bool SliderJoint3DSW::setup(real_t p_step) {
-
//calculate transforms
m_calculatedTransformA = A->get_transform() * m_frameInA;
m_calculatedTransformB = B->get_transform() * m_frameInB;
@@ -182,7 +180,6 @@ bool SliderJoint3DSW::setup(real_t p_step) {
//-----------------------------------------------------------------------------
void SliderJoint3DSW::solve(real_t p_step) {
-
int i;
// linear
Vector3 velA = A->get_velocity_in_local_point(m_relPosA);
@@ -304,7 +301,7 @@ void SliderJoint3DSW::solve(real_t p_step) {
//-----------------------------------------------------------------------------
-void SliderJoint3DSW::calculateTransforms(void) {
+void SliderJoint3DSW::calculateTransforms() {
m_calculatedTransformA = A->get_transform() * m_frameInA;
m_calculatedTransformB = B->get_transform() * m_frameInB;
m_realPivotAInW = m_calculatedTransformA.origin;
@@ -323,7 +320,7 @@ void SliderJoint3DSW::calculateTransforms(void) {
//-----------------------------------------------------------------------------
-void SliderJoint3DSW::testLinLimits(void) {
+void SliderJoint3DSW::testLinLimits() {
m_solveLinLim = false;
m_linPos = m_depth[0];
if (m_lowerLinLimit <= m_upperLinLimit) {
@@ -343,7 +340,7 @@ void SliderJoint3DSW::testLinLimits(void) {
//-----------------------------------------------------------------------------
-void SliderJoint3DSW::testAngLimits(void) {
+void SliderJoint3DSW::testAngLimits() {
m_angDepth = real_t(0.);
m_solveAngLim = false;
if (m_lowerAngLimit <= m_upperAngLimit) {
@@ -363,7 +360,7 @@ void SliderJoint3DSW::testAngLimits(void) {
//-----------------------------------------------------------------------------
-Vector3 SliderJoint3DSW::getAncorInA(void) {
+Vector3 SliderJoint3DSW::getAncorInA() {
Vector3 ancorInA;
ancorInA = m_realPivotAInW + (m_lowerLinLimit + m_upperLinLimit) * real_t(0.5) * m_sliderAxis;
ancorInA = A->get_transform().inverse().xform(ancorInA);
@@ -372,14 +369,13 @@ Vector3 SliderJoint3DSW::getAncorInA(void) {
//-----------------------------------------------------------------------------
-Vector3 SliderJoint3DSW::getAncorInB(void) {
+Vector3 SliderJoint3DSW::getAncorInB() {
Vector3 ancorInB;
ancorInB = m_frameInB.origin;
return ancorInB;
} // SliderJointSW::getAncorInB();
void SliderJoint3DSW::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) {
-
switch (p_param) {
case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER:
m_upperLinLimit = p_value;
@@ -455,7 +451,6 @@ void SliderJoint3DSW::set_param(PhysicsServer3D::SliderJointParam p_param, real_
}
real_t SliderJoint3DSW::get_param(PhysicsServer3D::SliderJointParam p_param) const {
-
switch (p_param) {
case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER:
return m_upperLinLimit;
diff --git a/servers/physics_3d/joints/slider_joint_3d_sw.h b/servers/physics_3d/joints/slider_joint_3d_sw.h
index 18287db9c2..37394a1580 100644
--- a/servers/physics_3d/joints/slider_joint_3d_sw.h
+++ b/servers/physics_3d/joints/slider_joint_3d_sw.h
@@ -230,12 +230,12 @@ public:
bool getSolveAngLimit() { return m_solveAngLim; }
real_t getAngDepth() { return m_angDepth; }
// shared code used by ODE solver
- void calculateTransforms(void);
- void testLinLimits(void);
- void testAngLimits(void);
+ void calculateTransforms();
+ void testLinLimits();
+ void testAngLimits();
// access for PE Solver
- Vector3 getAncorInA(void);
- Vector3 getAncorInB(void);
+ Vector3 getAncorInA();
+ Vector3 getAncorInB();
void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value);
real_t get_param(PhysicsServer3D::SliderJointParam p_param) const;
diff --git a/servers/physics_3d/joints_3d_sw.h b/servers/physics_3d/joints_3d_sw.h
index 0f2d4892a8..6a010ee771 100644
--- a/servers/physics_3d/joints_3d_sw.h
+++ b/servers/physics_3d/joints_3d_sw.h
@@ -35,7 +35,6 @@
#include "constraint_3d_sw.h"
class Joint3DSW : public Constraint3DSW {
-
public:
virtual PhysicsServer3D::JointType get_type() const = 0;
_FORCE_INLINE_ Joint3DSW(Body3DSW **p_body_ptr = nullptr, int p_body_count = 0) :
diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp
index b454dc54af..1c2329f2dc 100644
--- a/servers/physics_3d/physics_server_3d_sw.cpp
+++ b/servers/physics_3d/physics_server_3d_sw.cpp
@@ -44,48 +44,36 @@
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
RID PhysicsServer3DSW::shape_create(ShapeType p_shape) {
-
Shape3DSW *shape = nullptr;
switch (p_shape) {
-
case SHAPE_PLANE: {
-
shape = memnew(PlaneShape3DSW);
} break;
case SHAPE_RAY: {
-
shape = memnew(RayShape3DSW);
} break;
case SHAPE_SPHERE: {
-
shape = memnew(SphereShape3DSW);
} break;
case SHAPE_BOX: {
-
shape = memnew(BoxShape3DSW);
} break;
case SHAPE_CAPSULE: {
-
shape = memnew(CapsuleShape3DSW);
} break;
case SHAPE_CYLINDER: {
-
ERR_FAIL_V_MSG(RID(), "CylinderShape3D is not supported in GodotPhysics3D. Please switch to Bullet in the Project Settings.");
} break;
case SHAPE_CONVEX_POLYGON: {
-
shape = memnew(ConvexPolygonShape3DSW);
} break;
case SHAPE_CONCAVE_POLYGON: {
-
shape = memnew(ConcavePolygonShape3DSW);
} break;
case SHAPE_HEIGHTMAP: {
-
shape = memnew(HeightMapShape3DSW);
} break;
case SHAPE_CUSTOM: {
-
ERR_FAIL_V(RID());
} break;
@@ -98,28 +86,24 @@ RID PhysicsServer3DSW::shape_create(ShapeType p_shape) {
};
void PhysicsServer3DSW::shape_set_data(RID p_shape, const Variant &p_data) {
-
Shape3DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
void PhysicsServer3DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
-
Shape3DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
PhysicsServer3D::ShapeType PhysicsServer3DSW::shape_get_type(RID p_shape) const {
-
const Shape3DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
Variant PhysicsServer3DSW::shape_get_data(RID p_shape) const {
-
const Shape3DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
@@ -134,14 +118,12 @@ real_t PhysicsServer3DSW::shape_get_margin(RID p_shape) const {
}
real_t PhysicsServer3DSW::shape_get_custom_solver_bias(RID p_shape) const {
-
const Shape3DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
RID PhysicsServer3DSW::space_create() {
-
Space3DSW *space = memnew(Space3DSW);
RID id = space_owner.make_rid(space);
space->set_self(id);
@@ -160,17 +142,16 @@ RID PhysicsServer3DSW::space_create() {
};
void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) {
-
Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
- if (p_active)
+ if (p_active) {
active_spaces.insert(space);
- else
+ } else {
active_spaces.erase(space);
+ }
}
bool PhysicsServer3DSW::space_is_active(RID p_space) const {
-
const Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
@@ -178,7 +159,6 @@ bool PhysicsServer3DSW::space_is_active(RID p_space) const {
}
void PhysicsServer3DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
-
Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -186,14 +166,12 @@ void PhysicsServer3DSW::space_set_param(RID p_space, SpaceParameter p_param, rea
}
real_t PhysicsServer3DSW::space_get_param(RID p_space, SpaceParameter p_param) const {
-
const Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space) {
-
Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, nullptr);
ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -202,28 +180,24 @@ PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space
}
void PhysicsServer3DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
-
Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector3> PhysicsServer3DSW::space_get_contacts(RID p_space) const {
-
Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector3>());
return space->get_debug_contacts();
}
int PhysicsServer3DSW::space_get_contact_count(RID p_space) const {
-
Space3DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
RID PhysicsServer3DSW::area_create() {
-
Area3DSW *area = memnew(Area3DSW);
RID rid = area_owner.make_rid(area);
area->set_self(rid);
@@ -231,7 +205,6 @@ RID PhysicsServer3DSW::area_create() {
};
void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -241,26 +214,26 @@ void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) {
ERR_FAIL_COND(!space);
}
- if (area->get_space() == space)
+ if (area->get_space() == space) {
return; //pointless
+ }
area->clear_constraints();
area->set_space(space);
};
RID PhysicsServer3DSW::area_get_space(RID p_area) const {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
Space3DSW *space = area->get_space();
- if (!space)
+ if (!space) {
return RID();
+ }
return space->get_self();
};
void PhysicsServer3DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -268,7 +241,6 @@ void PhysicsServer3DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverri
}
PhysicsServer3D::AreaSpaceOverrideMode PhysicsServer3DSW::area_get_space_override_mode(RID p_area) const {
-
const Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
@@ -276,7 +248,6 @@ PhysicsServer3D::AreaSpaceOverrideMode PhysicsServer3DSW::area_get_space_overrid
}
void PhysicsServer3DSW::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -287,7 +258,6 @@ void PhysicsServer3DSW::area_add_shape(RID p_area, RID p_shape, const Transform
}
void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -299,7 +269,6 @@ void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
}
void PhysicsServer3DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -307,14 +276,13 @@ void PhysicsServer3DSW::area_set_shape_transform(RID p_area, int p_shape_idx, co
}
int PhysicsServer3DSW::area_get_shape_count(RID p_area) const {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
-RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
+RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
@@ -323,8 +291,8 @@ RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const {
return shape->get_self();
}
-Transform PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
+Transform PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
@@ -332,7 +300,6 @@ Transform PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_id
}
void PhysicsServer3DSW::area_remove_shape(RID p_area, int p_shape_idx) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -340,16 +307,15 @@ void PhysicsServer3DSW::area_remove_shape(RID p_area, int p_shape_idx) {
}
void PhysicsServer3DSW::area_clear_shapes(RID p_area) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- while (area->get_shape_count())
+ while (area->get_shape_count()) {
area->remove_shape(0);
+ }
}
void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count());
@@ -358,7 +324,6 @@ void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, boo
}
void PhysicsServer3DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
-
if (space_owner.owns(p_area)) {
Space3DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -367,8 +332,8 @@ void PhysicsServer3DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
-ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const {
+ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space3DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -379,7 +344,6 @@ ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const {
}
void PhysicsServer3DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
-
if (space_owner.owns(p_area)) {
Space3DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -390,14 +354,12 @@ void PhysicsServer3DSW::area_set_param(RID p_area, AreaParameter p_param, const
};
void PhysicsServer3DSW::area_set_transform(RID p_area, const Transform &p_transform) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
Variant PhysicsServer3DSW::area_get_param(RID p_area, AreaParameter p_param) const {
-
if (space_owner.owns(p_area)) {
Space3DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
@@ -409,7 +371,6 @@ Variant PhysicsServer3DSW::area_get_param(RID p_area, AreaParameter p_param) con
};
Transform PhysicsServer3DSW::area_get_transform(RID p_area) const {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
@@ -417,7 +378,6 @@ Transform PhysicsServer3DSW::area_get_transform(RID p_area) const {
};
void PhysicsServer3DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -425,7 +385,6 @@ void PhysicsServer3DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
}
void PhysicsServer3DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -433,7 +392,6 @@ void PhysicsServer3DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
}
void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -442,7 +400,6 @@ void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool p_monitorable) {
}
void PhysicsServer3DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -450,7 +407,6 @@ void PhysicsServer3DSW::area_set_monitor_callback(RID p_area, Object *p_receiver
}
void PhysicsServer3DSW::area_set_ray_pickable(RID p_area, bool p_enable) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -458,7 +414,6 @@ void PhysicsServer3DSW::area_set_ray_pickable(RID p_area, bool p_enable) {
}
bool PhysicsServer3DSW::area_is_ray_pickable(RID p_area) const {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, false);
@@ -466,7 +421,6 @@ bool PhysicsServer3DSW::area_is_ray_pickable(RID p_area) const {
}
void PhysicsServer3DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
-
Area3DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -476,19 +430,19 @@ void PhysicsServer3DSW::area_set_area_monitor_callback(RID p_area, Object *p_rec
/* BODY API */
RID PhysicsServer3DSW::body_create(BodyMode p_mode, bool p_init_sleeping) {
-
Body3DSW *body = memnew(Body3DSW);
- if (p_mode != BODY_MODE_RIGID)
+ if (p_mode != BODY_MODE_RIGID) {
body->set_mode(p_mode);
- if (p_init_sleeping)
+ }
+ if (p_init_sleeping) {
body->set_state(BODY_STATE_SLEEPING, p_init_sleeping);
+ }
RID rid = body_owner.make_rid(body);
body->set_self(rid);
return rid;
};
void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -498,26 +452,26 @@ void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) {
ERR_FAIL_COND(!space);
}
- if (body->get_space() == space)
+ if (body->get_space() == space) {
return; //pointless
+ }
body->clear_constraint_map();
body->set_space(space);
};
RID PhysicsServer3DSW::body_get_space(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
Space3DSW *space = body->get_space();
- if (!space)
+ if (!space) {
return RID();
+ }
return space->get_self();
};
void PhysicsServer3DSW::body_set_mode(RID p_body, BodyMode p_mode) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -525,7 +479,6 @@ void PhysicsServer3DSW::body_set_mode(RID p_body, BodyMode p_mode) {
};
PhysicsServer3D::BodyMode PhysicsServer3DSW::body_get_mode(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
@@ -533,7 +486,6 @@ PhysicsServer3D::BodyMode PhysicsServer3DSW::body_get_mode(RID p_body) const {
};
void PhysicsServer3DSW::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -544,7 +496,6 @@ void PhysicsServer3DSW::body_add_shape(RID p_body, RID p_shape, const Transform
}
void PhysicsServer3DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -554,8 +505,8 @@ void PhysicsServer3DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
body->set_shape(p_shape_idx, shape);
}
-void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
+void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -563,14 +514,13 @@ void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, co
}
int PhysicsServer3DSW::body_get_shape_count(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
-RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
+RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -581,7 +531,6 @@ RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const {
}
void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
@@ -591,7 +540,6 @@ void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
}
Transform PhysicsServer3DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform());
@@ -599,7 +547,6 @@ Transform PhysicsServer3DSW::body_get_shape_transform(RID p_body, int p_shape_id
}
void PhysicsServer3DSW::body_remove_shape(RID p_body, int p_shape_idx) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -607,16 +554,15 @@ void PhysicsServer3DSW::body_remove_shape(RID p_body, int p_shape_idx) {
}
void PhysicsServer3DSW::body_clear_shapes(RID p_body) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- while (body->get_shape_count())
+ while (body->get_shape_count()) {
body->remove_shape(0);
+ }
}
void PhysicsServer3DSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -624,7 +570,6 @@ void PhysicsServer3DSW::body_set_enable_continuous_collision_detection(RID p_bod
}
bool PhysicsServer3DSW::body_is_continuous_collision_detection_enabled(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
@@ -632,7 +577,6 @@ bool PhysicsServer3DSW::body_is_continuous_collision_detection_enabled(RID p_bod
}
void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -641,7 +585,6 @@ void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
}
uint32_t PhysicsServer3DSW::body_get_collision_layer(RID p_body) const {
-
const Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -649,7 +592,6 @@ uint32_t PhysicsServer3DSW::body_get_collision_layer(RID p_body) const {
}
void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -658,7 +600,6 @@ void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
}
uint32_t PhysicsServer3DSW::body_get_collision_mask(RID p_body) const {
-
const Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -666,7 +607,6 @@ uint32_t PhysicsServer3DSW::body_get_collision_mask(RID p_body) const {
}
void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -674,7 +614,6 @@ void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id
};
ObjectID PhysicsServer3DSW::body_get_object_instance_id(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
@@ -682,13 +621,11 @@ ObjectID PhysicsServer3DSW::body_get_object_instance_id(RID p_body) const {
};
void PhysicsServer3DSW::body_set_user_flags(RID p_body, uint32_t p_flags) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
};
uint32_t PhysicsServer3DSW::body_get_user_flags(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -696,7 +633,6 @@ uint32_t PhysicsServer3DSW::body_get_user_flags(RID p_body) const {
};
void PhysicsServer3DSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -704,7 +640,6 @@ void PhysicsServer3DSW::body_set_param(RID p_body, BodyParameter p_param, real_t
};
real_t PhysicsServer3DSW::body_get_param(RID p_body, BodyParameter p_param) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -725,7 +660,6 @@ real_t PhysicsServer3DSW::body_get_kinematic_safe_margin(RID p_body) const {
}
void PhysicsServer3DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -733,7 +667,6 @@ void PhysicsServer3DSW::body_set_state(RID p_body, BodyState p_state, const Vari
};
Variant PhysicsServer3DSW::body_get_state(RID p_body, BodyState p_state) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
@@ -741,7 +674,6 @@ Variant PhysicsServer3DSW::body_get_state(RID p_body, BodyState p_state) const {
};
void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_force) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -750,14 +682,12 @@ void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_forc
};
Vector3 PhysicsServer3DSW::body_get_applied_force(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_force();
};
void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -766,7 +696,6 @@ void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_tor
};
Vector3 PhysicsServer3DSW::body_get_applied_torque(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
@@ -808,7 +737,6 @@ void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_
}
void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -819,7 +747,6 @@ void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, con
};
void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -830,7 +757,6 @@ void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_i
};
void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -845,7 +771,6 @@ void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis
};
void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -854,14 +779,12 @@ void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_l
}
bool PhysicsServer3DSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
-
const Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->is_axis_locked(p_axis);
}
void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -870,7 +793,6 @@ void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) {
};
void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -879,7 +801,6 @@ void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b
};
void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -889,20 +810,17 @@ void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
void PhysicsServer3DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
};
real_t PhysicsServer3DSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void PhysicsServer3DSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -910,49 +828,42 @@ void PhysicsServer3DSW::body_set_omit_force_integration(RID p_body, bool p_omit)
};
bool PhysicsServer3DSW::body_is_omitting_force_integration(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
void PhysicsServer3DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
int PhysicsServer3DSW::body_get_max_contacts_reported(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void PhysicsServer3DSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
void PhysicsServer3DSW::body_set_ray_pickable(RID p_body, bool p_enable) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
bool PhysicsServer3DSW::body_is_ray_pickable(RID p_body) const {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -964,7 +875,6 @@ bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform &p_from, co
}
int PhysicsServer3DSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -976,7 +886,6 @@ int PhysicsServer3DSW::body_test_ray_separation(RID p_body, const Transform &p_t
}
PhysicsDirectBodyState3D *PhysicsServer3DSW::body_get_direct_state(RID p_body) {
-
Body3DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, nullptr);
ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
@@ -988,7 +897,6 @@ PhysicsDirectBodyState3D *PhysicsServer3DSW::body_get_direct_state(RID p_body) {
/* JOINT API */
RID PhysicsServer3DSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
-
Body3DSW *body_A = body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1009,15 +917,14 @@ RID PhysicsServer3DSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A,
}
void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
pin_joint->set_param(p_param, p_value);
}
-real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
@@ -1026,15 +933,14 @@ real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
}
void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
pin_joint->set_pos_a(p_A);
}
-Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
+Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
@@ -1043,15 +949,14 @@ Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const {
}
void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint);
pin_joint->set_pos_b(p_B);
}
-Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
+Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
@@ -1060,7 +965,6 @@ Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const {
}
RID PhysicsServer3DSW::joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B) {
-
Body3DSW *body_A = body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1081,7 +985,6 @@ RID PhysicsServer3DSW::joint_create_hinge(RID p_body_A, const Transform &p_frame
}
RID PhysicsServer3DSW::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
-
Body3DSW *body_A = body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1102,15 +1005,14 @@ RID PhysicsServer3DSW::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_
}
void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
hinge_joint->set_param(p_param, p_value);
}
-real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
+real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
@@ -1119,15 +1021,14 @@ real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_p
}
void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint);
hinge_joint->set_flag(p_flag, p_value);
}
-bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
+bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
@@ -1136,14 +1037,12 @@ bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag)
}
void PhysicsServer3DSW::joint_set_solver_priority(RID p_joint, int p_priority) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
joint->set_priority(p_priority);
}
int PhysicsServer3DSW::joint_get_solver_priority(RID p_joint) const {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
return joint->get_priority();
@@ -1177,14 +1076,12 @@ bool PhysicsServer3DSW::joint_is_disabled_collisions_between_bodies(RID p_joint)
}
PhysicsServer3DSW::JointType PhysicsServer3DSW::joint_get_type(RID p_joint) const {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
return joint->get_type();
}
RID PhysicsServer3DSW::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
-
Body3DSW *body_A = body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1205,15 +1102,14 @@ RID PhysicsServer3DSW::joint_create_slider(RID p_body_A, const Transform &p_loca
}
void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint);
slider_joint->set_param(p_param, p_value);
}
-real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
+real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0);
@@ -1222,7 +1118,6 @@ real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p
}
RID PhysicsServer3DSW::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
-
Body3DSW *body_A = body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1243,15 +1138,14 @@ RID PhysicsServer3DSW::joint_create_cone_twist(RID p_body_A, const Transform &p_
}
void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint);
cone_twist_joint->set_param(p_param, p_value);
}
-real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
+real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0);
@@ -1260,7 +1154,6 @@ real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJoint
}
RID PhysicsServer3DSW::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
-
Body3DSW *body_A = body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
@@ -1281,15 +1174,14 @@ RID PhysicsServer3DSW::joint_create_generic_6dof(RID p_body_A, const Transform &
}
void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
generic_6dof_joint->set_param(p_axis, p_param, p_value);
}
-real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
+real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
@@ -1298,15 +1190,14 @@ real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axi
}
void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
-
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint);
generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
}
-bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
+bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
Joint3DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
@@ -1315,11 +1206,9 @@ bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p
}
void PhysicsServer3DSW::free(RID p_rid) {
-
_update_shapes(); //just in case
if (shape_owner.owns(p_rid)) {
-
Shape3DSW *shape = shape_owner.getornull(p_rid);
while (shape->get_owners().size()) {
@@ -1330,7 +1219,6 @@ void PhysicsServer3DSW::free(RID p_rid) {
shape_owner.free(p_rid);
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
-
Body3DSW *body = body_owner.getornull(p_rid);
/*
@@ -1344,7 +1232,6 @@ void PhysicsServer3DSW::free(RID p_rid) {
body->set_space(nullptr);
while (body->get_shape_count()) {
-
body->remove_shape(0);
}
@@ -1352,7 +1239,6 @@ void PhysicsServer3DSW::free(RID p_rid) {
memdelete(body);
} else if (area_owner.owns(p_rid)) {
-
Area3DSW *area = area_owner.getornull(p_rid);
/*
@@ -1363,14 +1249,12 @@ void PhysicsServer3DSW::free(RID p_rid) {
area->set_space(nullptr);
while (area->get_shape_count()) {
-
area->remove_shape(0);
}
area_owner.free(p_rid);
memdelete(area);
} else if (space_owner.owns(p_rid)) {
-
Space3DSW *space = space_owner.getornull(p_rid);
while (space->get_objects().size()) {
@@ -1385,29 +1269,24 @@ void PhysicsServer3DSW::free(RID p_rid) {
space_owner.free(p_rid);
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
-
Joint3DSW *joint = joint_owner.getornull(p_rid);
for (int i = 0; i < joint->get_body_count(); i++) {
-
joint->get_body_ptr()[i]->remove_constraint(joint);
}
joint_owner.free(p_rid);
memdelete(joint);
} else {
-
ERR_FAIL_MSG("Invalid ID.");
}
};
void PhysicsServer3DSW::set_active(bool p_active) {
-
active = p_active;
};
void PhysicsServer3DSW::init() {
-
doing_sync = true;
last_step = 0.001;
iterations = 8; // 8?
@@ -1416,11 +1295,11 @@ void PhysicsServer3DSW::init() {
};
void PhysicsServer3DSW::step(real_t p_step) {
-
#ifndef _3D_DISABLED
- if (!active)
+ if (!active) {
return;
+ }
_update_shapes();
@@ -1433,7 +1312,6 @@ void PhysicsServer3DSW::step(real_t p_step) {
active_objects = 0;
collision_pairs = 0;
for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
stepper->step((Space3DSW *)E->get(), p_step, iterations);
island_count += E->get()->get_island_count();
active_objects += E->get()->get_active_objects();
@@ -1442,16 +1320,12 @@ void PhysicsServer3DSW::step(real_t p_step) {
#endif
}
-void PhysicsServer3DSW::sync(){
-
-};
-
void PhysicsServer3DSW::flush_queries() {
-
#ifndef _3D_DISABLED
- if (!active)
+ if (!active) {
return;
+ }
doing_sync = true;
@@ -1460,7 +1334,6 @@ void PhysicsServer3DSW::flush_queries() {
uint64_t time_beg = OS::get_singleton()->get_ticks_usec();
for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
Space3DSW *space = (Space3DSW *)E->get();
space->call_queries();
}
@@ -1468,7 +1341,6 @@ void PhysicsServer3DSW::flush_queries() {
flushing_queries = false;
if (EngineDebugger::is_profiling("servers")) {
-
uint64_t total_time[Space3DSW::ELAPSED_TIME_MAX];
static const char *time_name[Space3DSW::ELAPSED_TIME_MAX] = {
"integrate_forces",
@@ -1483,7 +1355,6 @@ void PhysicsServer3DSW::flush_queries() {
}
for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) {
-
for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) {
total_time[i] += E->get()->get_elapsed_time(Space3DSW::ElapsedTime(i));
}
@@ -1505,24 +1376,19 @@ void PhysicsServer3DSW::flush_queries() {
};
void PhysicsServer3DSW::finish() {
-
memdelete(stepper);
memdelete(direct_state);
};
int PhysicsServer3DSW::get_process_info(ProcessInfo p_info) {
-
switch (p_info) {
-
case INFO_ACTIVE_OBJECTS: {
-
return active_objects;
} break;
case INFO_COLLISION_PAIRS: {
return collision_pairs;
} break;
case INFO_ISLAND_COUNT: {
-
return island_count;
} break;
}
@@ -1531,7 +1397,6 @@ int PhysicsServer3DSW::get_process_info(ProcessInfo p_info) {
}
void PhysicsServer3DSW::_update_shapes() {
-
while (pending_shape_update_list.first()) {
pending_shape_update_list.first()->self()->_shape_changed();
pending_shape_update_list.remove(pending_shape_update_list.first());
@@ -1539,18 +1404,17 @@ void PhysicsServer3DSW::_update_shapes() {
}
void PhysicsServer3DSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
-
CollCbkData *cbk = (CollCbkData *)p_userdata;
- if (cbk->max == 0)
+ if (cbk->max == 0) {
return;
+ }
if (cbk->amount == cbk->max) {
//find least deep
real_t min_depth = 1e20;
int min_depth_idx = 0;
for (int i = 0; i < cbk->amount; i++) {
-
real_t d = cbk->ptr[i * 2 + 0].distance_squared_to(cbk->ptr[i * 2 + 1]);
if (d < min_depth) {
min_depth = d;
@@ -1559,13 +1423,13 @@ void PhysicsServer3DSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &
}
real_t d = p_point_A.distance_squared_to(p_point_B);
- if (d < min_depth)
+ if (d < min_depth) {
return;
+ }
cbk->ptr[min_depth_idx * 2 + 0] = p_point_A;
cbk->ptr[min_depth_idx * 2 + 1] = p_point_B;
} else {
-
cbk->ptr[cbk->amount * 2 + 0] = p_point_A;
cbk->ptr[cbk->amount * 2 + 1] = p_point_B;
cbk->amount++;
@@ -1583,7 +1447,3 @@ PhysicsServer3DSW::PhysicsServer3DSW() {
active = true;
flushing_queries = false;
};
-
-PhysicsServer3DSW::~PhysicsServer3DSW(){
-
-};
diff --git a/servers/physics_3d/physics_server_3d_sw.h b/servers/physics_3d/physics_server_3d_sw.h
index 6e79d9eceb..26230ef674 100644
--- a/servers/physics_3d/physics_server_3d_sw.h
+++ b/servers/physics_3d/physics_server_3d_sw.h
@@ -39,7 +39,6 @@
#include "step_3d_sw.h"
class PhysicsServer3DSW : public PhysicsServer3D {
-
GDCLASS(PhysicsServer3DSW, PhysicsServer3D);
friend class PhysicsDirectSpaceState3DSW;
@@ -74,7 +73,6 @@ public:
static PhysicsServer3DSW *singleton;
struct CollCbkData {
-
int max;
int amount;
Vector3 *ptr;
@@ -307,7 +305,7 @@ public:
virtual void soft_body_remove_all_pinned_points(RID p_body) {}
virtual void soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {}
- virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) { return 0; }
+ virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) { return false; }
/* JOINT API */
@@ -367,7 +365,7 @@ public:
virtual void set_active(bool p_active);
virtual void init();
virtual void step(real_t p_step);
- virtual void sync();
+ virtual void sync() {}
virtual void flush_queries();
virtual void finish();
@@ -376,7 +374,7 @@ public:
int get_process_info(ProcessInfo p_info);
PhysicsServer3DSW();
- ~PhysicsServer3DSW();
+ ~PhysicsServer3DSW() {}
};
#endif
diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index 61c32b779a..ca33241d29 100644
--- a/servers/physics_3d/shape_3d_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -30,7 +30,7 @@
#include "shape_3d_sw.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/math/quick_hull.h"
#include "core/sort_array.h"
@@ -48,7 +48,6 @@ void Shape3DSW::configure(const AABB &p_aabb) {
}
Vector3 Shape3DSW::get_support(const Vector3 &p_normal) const {
-
Vector3 res;
int amnt;
get_supports(p_normal, 1, &res, amnt);
@@ -56,7 +55,6 @@ Vector3 Shape3DSW::get_support(const Vector3 &p_normal) const {
}
void Shape3DSW::add_owner(ShapeOwner3DSW *p_owner) {
-
Map<ShapeOwner3DSW *, int>::Element *E = owners.find(p_owner);
if (E) {
E->get()++;
@@ -66,7 +64,6 @@ void Shape3DSW::add_owner(ShapeOwner3DSW *p_owner) {
}
void Shape3DSW::remove_owner(ShapeOwner3DSW *p_owner) {
-
Map<ShapeOwner3DSW *, int>::Element *E = owners.find(p_owner);
ERR_FAIL_COND(!E);
E->get()--;
@@ -76,7 +73,6 @@ void Shape3DSW::remove_owner(ShapeOwner3DSW *p_owner) {
}
bool Shape3DSW::is_owner(ShapeOwner3DSW *p_owner) const {
-
return owners.has(p_owner);
}
@@ -85,48 +81,41 @@ const Map<ShapeOwner3DSW *, int> &Shape3DSW::get_owners() const {
}
Shape3DSW::Shape3DSW() {
-
custom_bias = 0;
configured = false;
}
Shape3DSW::~Shape3DSW() {
-
ERR_FAIL_COND(owners.size());
}
Plane PlaneShape3DSW::get_plane() const {
-
return plane;
}
void PlaneShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
// gibberish, a plane is infinity
r_min = -1e7;
r_max = 1e7;
}
Vector3 PlaneShape3DSW::get_support(const Vector3 &p_normal) const {
-
return p_normal * 1e15;
}
bool PlaneShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
bool inters = plane.intersects_segment(p_begin, p_end, &r_result);
- if (inters)
+ if (inters) {
r_normal = plane.normal;
+ }
return inters;
}
bool PlaneShape3DSW::intersect_point(const Vector3 &p_point) const {
-
return plane.distance_to(p_point) < 0;
}
Vector3 PlaneShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
if (plane.is_point_over(p_point)) {
return plane.project(p_point);
} else {
@@ -135,23 +124,19 @@ Vector3 PlaneShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
}
Vector3 PlaneShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
return Vector3(); //wtf
}
void PlaneShape3DSW::_setup(const Plane &p_plane) {
-
plane = p_plane;
configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2)));
}
void PlaneShape3DSW::set_data(const Variant &p_data) {
-
_setup(p_data);
}
Variant PlaneShape3DSW::get_data() const {
-
return plane;
}
@@ -161,7 +146,6 @@ PlaneShape3DSW::PlaneShape3DSW() {
//
real_t RayShape3DSW::get_length() const {
-
return length;
}
@@ -170,24 +154,21 @@ bool RayShape3DSW::get_slips_on_slope() const {
}
void RayShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
// don't think this will be even used
r_min = 0;
r_max = 1;
}
Vector3 RayShape3DSW::get_support(const Vector3 &p_normal) const {
-
- if (p_normal.z > 0)
+ if (p_normal.z > 0) {
return Vector3(0, 0, length);
- else
+ } else {
return Vector3(0, 0, 0);
+ }
}
void RayShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
-
if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
-
r_amount = 2;
r_supports[0] = Vector3(0, 0, 0);
r_supports[1] = Vector3(0, 0, length);
@@ -201,45 +182,38 @@ void RayShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_s
}
bool RayShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
return false; //simply not possible
}
bool RayShape3DSW::intersect_point(const Vector3 &p_point) const {
-
return false; //simply not possible
}
Vector3 RayShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
Vector3 s[2] = {
Vector3(0, 0, 0),
Vector3(0, 0, length)
};
- return Geometry::get_closest_point_to_segment(p_point, s);
+ return Geometry3D::get_closest_point_to_segment(p_point, s);
}
Vector3 RayShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
return Vector3();
}
void RayShape3DSW::_setup(real_t p_length, bool p_slips_on_slope) {
-
length = p_length;
slips_on_slope = p_slips_on_slope;
configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length)));
}
void RayShape3DSW::set_data(const Variant &p_data) {
-
Dictionary d = p_data;
_setup(d["length"], d["slips_on_slope"]);
}
Variant RayShape3DSW::get_data() const {
-
Dictionary d;
d["length"] = length;
d["slips_on_slope"] = slips_on_slope;
@@ -247,7 +221,6 @@ Variant RayShape3DSW::get_data() const {
}
RayShape3DSW::RayShape3DSW() {
-
length = 1;
slips_on_slope = false;
}
@@ -255,12 +228,10 @@ RayShape3DSW::RayShape3DSW() {
/********** SPHERE *************/
real_t SphereShape3DSW::get_radius() const {
-
return radius;
}
void SphereShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
real_t d = p_normal.dot(p_transform.origin);
// figure out scale at point
@@ -272,66 +243,56 @@ void SphereShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_
}
Vector3 SphereShape3DSW::get_support(const Vector3 &p_normal) const {
-
return p_normal * radius;
}
void SphereShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
-
*r_supports = p_normal * radius;
r_amount = 1;
}
bool SphereShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
- return Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal);
+ return Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal);
}
bool SphereShape3DSW::intersect_point(const Vector3 &p_point) const {
-
return p_point.length() < radius;
}
Vector3 SphereShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
Vector3 p = p_point;
float l = p.length();
- if (l < radius)
+ if (l < radius) {
return p_point;
+ }
return (p / l) * radius;
}
Vector3 SphereShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
real_t s = 0.4 * p_mass * radius * radius;
return Vector3(s, s, s);
}
void SphereShape3DSW::_setup(real_t p_radius) {
-
radius = p_radius;
configure(AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0)));
}
void SphereShape3DSW::set_data(const Variant &p_data) {
-
_setup(p_data);
}
Variant SphereShape3DSW::get_data() const {
-
return radius;
}
SphereShape3DSW::SphereShape3DSW() {
-
radius = 0;
}
/********** BOX *************/
void BoxShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
// no matter the angle, the box is mirrored anyway
Vector3 local_normal = p_transform.basis.xform_inv(p_normal);
@@ -343,7 +304,6 @@ void BoxShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_tra
}
Vector3 BoxShape3DSW::get_support(const Vector3 &p_normal) const {
-
Vector3 point(
(p_normal.x < 0) ? -half_extents.x : half_extents.x,
(p_normal.y < 0) ? -half_extents.y : half_extents.y,
@@ -353,17 +313,14 @@ Vector3 BoxShape3DSW::get_support(const Vector3 &p_normal) const {
}
void BoxShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
-
static const int next[3] = { 1, 2, 0 };
static const int next2[3] = { 2, 0, 1 };
for (int i = 0; i < 3; i++) {
-
Vector3 axis;
axis[i] = 1.0;
real_t dot = p_normal.dot(axis);
if (Math::abs(dot) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
-
//Vector3 axis_b;
bool neg = dot < 0;
@@ -384,7 +341,6 @@ void BoxShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_s
};
for (int j = 0; j < 4; j++) {
-
point[i_n] = sign[j][0] * half_extents[i_n];
point[i_n2] = sign[j][1] * half_extents[i_n2];
r_supports[j] = neg ? -point : point;
@@ -402,12 +358,10 @@ void BoxShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_s
}
for (int i = 0; i < 3; i++) {
-
Vector3 axis;
axis[i] = 1.0;
if (Math::abs(p_normal.dot(axis)) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
-
r_amount = 2;
int i_n = next[i];
@@ -440,24 +394,20 @@ void BoxShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_s
}
bool BoxShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
AABB aabb(-half_extents, half_extents * 2.0);
return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal);
}
bool BoxShape3DSW::intersect_point(const Vector3 &p_point) const {
-
return (Math::abs(p_point.x) < half_extents.x && Math::abs(p_point.y) < half_extents.y && Math::abs(p_point.z) < half_extents.z);
}
Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
int outside = 0;
Vector3 min_point;
for (int i = 0; i < 3; i++) {
-
if (Math::abs(p_point[i]) > half_extents[i]) {
outside++;
if (outside == 1) {
@@ -471,11 +421,13 @@ Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
}
}
- if (!outside)
+ if (!outside) {
return p_point; //it's inside, don't do anything else
+ }
- if (outside == 1) //if only above one plane, this plane clearly wins
+ if (outside == 1) { //if only above one plane, this plane clearly wins
return min_point;
+ }
//check segments
float min_distance = 1e20;
@@ -486,11 +438,10 @@ Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
};
for (int i = 0; i < 3; i++) {
-
s[1] = closest_vertex;
s[1][i] = -s[1][i]; //edge
- Vector3 closest_edge = Geometry::get_closest_point_to_segment(p_point, s);
+ Vector3 closest_edge = Geometry3D::get_closest_point_to_segment(p_point, s);
float d = p_point.distance_to(closest_edge);
if (d < min_distance) {
@@ -503,7 +454,6 @@ Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
}
Vector3 BoxShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
real_t lx = half_extents.x;
real_t ly = half_extents.y;
real_t lz = half_extents.z;
@@ -512,19 +462,16 @@ Vector3 BoxShape3DSW::get_moment_of_inertia(real_t p_mass) const {
}
void BoxShape3DSW::_setup(const Vector3 &p_half_extents) {
-
half_extents = p_half_extents.abs();
configure(AABB(-half_extents, half_extents * 2));
}
void BoxShape3DSW::set_data(const Variant &p_data) {
-
_setup(p_data);
}
Variant BoxShape3DSW::get_data() const {
-
return half_extents;
}
@@ -534,7 +481,6 @@ BoxShape3DSW::BoxShape3DSW() {
/********** CAPSULE *************/
void CapsuleShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
Vector3 n = p_transform.basis.xform_inv(p_normal).normalized();
real_t h = (n.z > 0) ? height : -height;
@@ -546,7 +492,6 @@ void CapsuleShape3DSW::project_range(const Vector3 &p_normal, const Transform &p
}
Vector3 CapsuleShape3DSW::get_support(const Vector3 &p_normal) const {
-
Vector3 n = p_normal;
real_t h = (n.z > 0) ? height : -height;
@@ -557,13 +502,11 @@ Vector3 CapsuleShape3DSW::get_support(const Vector3 &p_normal) const {
}
void CapsuleShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
-
Vector3 n = p_normal;
real_t d = n.z;
if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
-
// make it flat
n.z = 0.0;
n.normalize();
@@ -576,7 +519,6 @@ void CapsuleShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3
r_supports[1].z -= height * 0.5;
} else {
-
real_t h = (d > 0) ? height : -height;
n *= radius;
@@ -587,7 +529,6 @@ void CapsuleShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3
}
bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
Vector3 norm = (p_end - p_begin).normalized();
real_t min_d = 1e20;
@@ -599,7 +540,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
// test against cylinder and spheres :-|
- collided = Geometry::segment_intersects_cylinder(p_begin, p_end, height, radius, &auxres, &auxn);
+ collided = Geometry3D::segment_intersects_cylinder(p_begin, p_end, height, radius, &auxres, &auxn);
if (collided) {
real_t d = norm.dot(auxres);
@@ -611,7 +552,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
}
}
- collided = Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * 0.5), radius, &auxres, &auxn);
+ collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * 0.5), radius, &auxres, &auxn);
if (collided) {
real_t d = norm.dot(auxres);
@@ -623,7 +564,7 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
}
}
- collided = Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * -0.5), radius, &auxres, &auxn);
+ collided = Geometry3D::segment_intersects_sphere(p_begin, p_end, Vector3(0, 0, height * -0.5), radius, &auxres, &auxn);
if (collided) {
real_t d = norm.dot(auxres);
@@ -637,7 +578,6 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
}
if (collision) {
-
r_result = res;
r_normal = n;
}
@@ -645,7 +585,6 @@ bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &
}
bool CapsuleShape3DSW::intersect_point(const Vector3 &p_point) const {
-
if (Math::abs(p_point.z) < height * 0.5) {
return Vector3(p_point.x, p_point.y, 0).length() < radius;
} else {
@@ -656,22 +595,21 @@ bool CapsuleShape3DSW::intersect_point(const Vector3 &p_point) const {
}
Vector3 CapsuleShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
Vector3 s[2] = {
Vector3(0, 0, -height * 0.5),
Vector3(0, 0, height * 0.5),
};
- Vector3 p = Geometry::get_closest_point_to_segment(p_point, s);
+ Vector3 p = Geometry3D::get_closest_point_to_segment(p_point, s);
- if (p.distance_to(p_point) < radius)
+ if (p.distance_to(p_point) < radius) {
return p_point;
+ }
return p + (p_point - p).normalized() * radius;
}
Vector3 CapsuleShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -682,14 +620,12 @@ Vector3 CapsuleShape3DSW::get_moment_of_inertia(real_t p_mass) const {
}
void CapsuleShape3DSW::_setup(real_t p_height, real_t p_radius) {
-
height = p_height;
radius = p_radius;
configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0)));
}
void CapsuleShape3DSW::set_data(const Variant &p_data) {
-
Dictionary d = p_data;
ERR_FAIL_COND(!d.has("radius"));
ERR_FAIL_COND(!d.has("height"));
@@ -697,7 +633,6 @@ void CapsuleShape3DSW::set_data(const Variant &p_data) {
}
Variant CapsuleShape3DSW::get_data() const {
-
Dictionary d;
d["radius"] = radius;
d["height"] = height;
@@ -705,46 +640,45 @@ Variant CapsuleShape3DSW::get_data() const {
}
CapsuleShape3DSW::CapsuleShape3DSW() {
-
height = radius = 0;
}
/********** CONVEX POLYGON *************/
void ConvexPolygonShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
int vertex_count = mesh.vertices.size();
- if (vertex_count == 0)
+ if (vertex_count == 0) {
return;
+ }
const Vector3 *vrts = &mesh.vertices[0];
for (int i = 0; i < vertex_count; i++) {
-
real_t d = p_normal.dot(p_transform.xform(vrts[i]));
- if (i == 0 || d > r_max)
+ if (i == 0 || d > r_max) {
r_max = d;
- if (i == 0 || d < r_min)
+ }
+ if (i == 0 || d < r_min) {
r_min = d;
+ }
}
}
Vector3 ConvexPolygonShape3DSW::get_support(const Vector3 &p_normal) const {
-
Vector3 n = p_normal;
int vert_support_idx = -1;
real_t support_max = 0;
int vertex_count = mesh.vertices.size();
- if (vertex_count == 0)
+ if (vertex_count == 0) {
return Vector3();
+ }
const Vector3 *vrts = &mesh.vertices[0];
for (int i = 0; i < vertex_count; i++) {
-
real_t d = n.dot(vrts[i]);
if (i == 0 || d > support_max) {
@@ -757,11 +691,10 @@ Vector3 ConvexPolygonShape3DSW::get_support(const Vector3 &p_normal) const {
}
void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
-
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int ec = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
@@ -772,7 +705,6 @@ void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Ve
int vtx = 0;
for (int i = 0; i < vc; i++) {
-
real_t d = p_normal.dot(vertices[i]);
if (i == 0 || d > max) {
@@ -782,9 +714,7 @@ void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Ve
}
for (int i = 0; i < fc; i++) {
-
if (faces[i].plane.normal.dot(p_normal) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
-
int ic = faces[i].indices.size();
const int *ind = faces[i].indices.ptr();
@@ -796,12 +726,12 @@ void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Ve
}
}
- if (!valid)
+ if (!valid) {
continue;
+ }
int m = MIN(p_max, ic);
for (int j = 0; j < m; j++) {
-
r_supports[j] = vertices[ind[j]];
}
r_amount = m;
@@ -810,11 +740,9 @@ void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Ve
}
for (int i = 0; i < ec; i++) {
-
real_t dot = (vertices[edges[i].a] - vertices[edges[i].b]).normalized().dot(p_normal);
dot = ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD && (edges[i].a == vtx || edges[i].b == vtx)) {
-
r_amount = 2;
r_supports[0] = vertices[edges[i].a];
r_supports[1] = vertices[edges[i].b];
@@ -827,8 +755,7 @@ void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Ve
}
bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
const Vector3 *vertices = mesh.vertices.ptr();
@@ -838,15 +765,14 @@ bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vec
bool col = false;
for (int i = 0; i < fc; i++) {
-
- if (faces[i].plane.normal.dot(n) > 0)
+ if (faces[i].plane.normal.dot(n) > 0) {
continue; //opposing face
+ }
int ic = faces[i].indices.size();
const int *ind = faces[i].indices.ptr();
for (int j = 1; j < ic - 1; j++) {
-
Face3 f(vertices[ind[0]], vertices[ind[j]], vertices[ind[j + 1]]);
Vector3 result;
if (f.intersects_segment(p_begin, p_end, &result)) {
@@ -867,30 +793,28 @@ bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vec
}
bool ConvexPolygonShape3DSW::intersect_point(const Vector3 &p_point) const {
-
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
for (int i = 0; i < fc; i++) {
-
- if (faces[i].plane.distance_to(p_point) >= 0)
+ if (faces[i].plane.distance_to(p_point) >= 0) {
return false;
+ }
}
return true;
}
Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
- const Geometry::MeshData::Face *faces = mesh.faces.ptr();
+ const Geometry3D::MeshData::Face *faces = mesh.faces.ptr();
int fc = mesh.faces.size();
const Vector3 *vertices = mesh.vertices.ptr();
bool all_inside = true;
for (int i = 0; i < fc; i++) {
-
- if (!faces[i].plane.is_point_over(p_point))
+ if (!faces[i].plane.is_point_over(p_point)) {
continue;
+ }
all_inside = false;
bool is_inside = true;
@@ -898,7 +822,6 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
const int *indices = faces[i].indices.ptr();
for (int j = 0; j < ic; j++) {
-
Vector3 a = vertices[indices[j]];
Vector3 b = vertices[indices[(j + 1) % ic]];
Vector3 n = (a - b).cross(faces[i].plane.normal).normalized();
@@ -921,16 +844,15 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
Vector3 min_point;
//check edges
- const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
+ const Geometry3D::MeshData::Edge *edges = mesh.edges.ptr();
int ec = mesh.edges.size();
for (int i = 0; i < ec; i++) {
-
Vector3 s[2] = {
vertices[edges[i].a],
vertices[edges[i].b]
};
- Vector3 closest = Geometry::get_closest_point_to_segment(p_point, s);
+ Vector3 closest = Geometry3D::get_closest_point_to_segment(p_point, s);
float d = closest.distance_to(p_point);
if (d < min_distance) {
min_distance = d;
@@ -942,7 +864,6 @@ Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) con
}
Vector3 ConvexPolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -953,31 +874,29 @@ Vector3 ConvexPolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
}
void ConvexPolygonShape3DSW::_setup(const Vector<Vector3> &p_vertices) {
-
Error err = QuickHull::build(p_vertices, mesh);
- if (err != OK)
+ if (err != OK) {
ERR_PRINT("Failed to build QuickHull");
+ }
AABB _aabb;
for (int i = 0; i < mesh.vertices.size(); i++) {
-
- if (i == 0)
+ if (i == 0) {
_aabb.position = mesh.vertices[i];
- else
+ } else {
_aabb.expand_to(mesh.vertices[i]);
+ }
}
configure(_aabb);
}
void ConvexPolygonShape3DSW::set_data(const Variant &p_data) {
-
_setup(p_data);
}
Variant ConvexPolygonShape3DSW::get_data() const {
-
return mesh.vertices;
}
@@ -987,27 +906,25 @@ ConvexPolygonShape3DSW::ConvexPolygonShape3DSW() {
/********** FACE POLYGON *************/
void FaceShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
for (int i = 0; i < 3; i++) {
-
Vector3 v = p_transform.xform(vertex[i]);
real_t d = p_normal.dot(v);
- if (i == 0 || d > r_max)
+ if (i == 0 || d > r_max) {
r_max = d;
+ }
- if (i == 0 || d < r_min)
+ if (i == 0 || d < r_min) {
r_min = d;
+ }
}
}
Vector3 FaceShape3DSW::get_support(const Vector3 &p_normal) const {
-
int vert_support_idx = -1;
real_t support_max = 0;
for (int i = 0; i < 3; i++) {
-
real_t d = p_normal.dot(vertex[i]);
if (i == 0 || d > support_max) {
@@ -1020,15 +937,12 @@ Vector3 FaceShape3DSW::get_support(const Vector3 &p_normal) const {
}
void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const {
-
Vector3 n = p_normal;
/** TEST FACE AS SUPPORT **/
if (normal.dot(n) > _FACE_IS_VALID_SUPPORT_THRESHOLD) {
-
r_amount = 3;
for (int i = 0; i < 3; i++) {
-
r_supports[i] = vertex[i];
}
return;
@@ -1040,7 +954,6 @@ void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_
real_t support_max = 0;
for (int i = 0; i < 3; i++) {
-
real_t d = n.dot(vertex[i]);
if (i == 0 || d > support_max) {
@@ -1052,16 +965,15 @@ void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_
/** TEST EDGES AS SUPPORT **/
for (int i = 0; i < 3; i++) {
-
int nx = (i + 1) % 3;
- if (i != vert_support_idx && nx != vert_support_idx)
+ if (i != vert_support_idx && nx != vert_support_idx) {
continue;
+ }
// check if edge is valid as a support
real_t dot = (vertex[i] - vertex[nx]).normalized().dot(n);
dot = ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) {
-
r_amount = 2;
r_supports[0] = vertex[i];
r_supports[1] = vertex[nx];
@@ -1074,8 +986,7 @@ void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_
}
bool FaceShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
- bool c = Geometry::segment_intersects_triangle(p_begin, p_end, vertex[0], vertex[1], vertex[2], &r_result);
+ bool c = Geometry3D::segment_intersects_triangle(p_begin, p_end, vertex[0], vertex[1], vertex[2], &r_result);
if (c) {
r_normal = Plane(vertex[0], vertex[1], vertex[2]).normal;
if (r_normal.dot(p_end - p_begin) > 0) {
@@ -1087,36 +998,29 @@ bool FaceShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_e
}
bool FaceShape3DSW::intersect_point(const Vector3 &p_point) const {
-
return false; //face is flat
}
Vector3 FaceShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
return Face3(vertex[0], vertex[1], vertex[2]).get_closest_point_to(p_point);
}
Vector3 FaceShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
return Vector3(); // Sorry, but i don't think anyone cares, FaceShape!
}
FaceShape3DSW::FaceShape3DSW() {
-
configure(AABB());
}
Vector<Vector3> ConcavePolygonShape3DSW::get_faces() const {
-
Vector<Vector3> rfaces;
rfaces.resize(faces.size() * 3);
for (int i = 0; i < faces.size(); i++) {
-
Face f = faces.get(i);
for (int j = 0; j < 3; j++) {
-
rfaces.set(i * 3 + j, vertices.get(f.indices[j]));
}
}
@@ -1125,7 +1029,6 @@ Vector<Vector3> ConcavePolygonShape3DSW::get_faces() const {
}
void ConcavePolygonShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
int count = vertices.size();
if (count == 0) {
r_min = 0;
@@ -1135,21 +1038,22 @@ void ConcavePolygonShape3DSW::project_range(const Vector3 &p_normal, const Trans
const Vector3 *vptr = vertices.ptr();
for (int i = 0; i < count; i++) {
-
real_t d = p_normal.dot(p_transform.xform(vptr[i]));
- if (i == 0 || d > r_max)
+ if (i == 0 || d > r_max) {
r_max = d;
- if (i == 0 || d < r_min)
+ }
+ if (i == 0 || d < r_min) {
r_min = d;
+ }
}
}
Vector3 ConcavePolygonShape3DSW::get_support(const Vector3 &p_normal) const {
-
int count = vertices.size();
- if (count == 0)
+ if (count == 0) {
return Vector3();
+ }
const Vector3 *vptr = vertices.ptr();
@@ -1159,7 +1063,6 @@ Vector3 ConcavePolygonShape3DSW::get_support(const Vector3 &p_normal) const {
real_t support_max = 0;
for (int i = 0; i < count; i++) {
-
real_t d = n.dot(vptr[i]);
if (i == 0 || d > support_max) {
@@ -1172,7 +1075,6 @@ Vector3 ConcavePolygonShape3DSW::get_support(const Vector3 &p_normal) const {
}
void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_params) const {
-
const BVH *bvh = &p_params->bvh[p_idx];
/*
@@ -1182,12 +1084,10 @@ void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_par
//printf("addr: %p\n",bvh);
if (!bvh->aabb.intersects_segment(p_params->from, p_params->to)) {
-
return;
}
if (bvh->face_index >= 0) {
-
Vector3 res;
Vector3 vertices[3] = {
p_params->vertices[p_params->faces[bvh->face_index].indices[0]],
@@ -1195,18 +1095,16 @@ void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_par
p_params->vertices[p_params->faces[bvh->face_index].indices[2]]
};
- if (Geometry::segment_intersects_triangle(
+ if (Geometry3D::segment_intersects_triangle(
p_params->from,
p_params->to,
vertices[0],
vertices[1],
vertices[2],
&res)) {
-
real_t d = p_params->dir.dot(res) - p_params->dir.dot(p_params->from);
//TODO, seems segmen/triangle intersection is broken :(
if (d > 0 && d < p_params->min_d) {
-
p_params->min_d = d;
p_params->result = res;
p_params->normal = Plane(vertices[0], vertices[1], vertices[2]).normal;
@@ -1215,18 +1113,19 @@ void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_par
}
} else {
-
- if (bvh->left >= 0)
+ if (bvh->left >= 0) {
_cull_segment(bvh->left, p_params);
- if (bvh->right >= 0)
+ }
+ if (bvh->right >= 0) {
_cull_segment(bvh->right, p_params);
+ }
}
}
bool ConcavePolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
-
- if (faces.size() == 0)
+ if (faces.size() == 0) {
return false;
+ }
// unlock data
const Face *fr = faces.ptr();
@@ -1248,35 +1147,30 @@ bool ConcavePolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Ve
_cull_segment(0, &params);
if (params.collisions > 0) {
-
r_result = params.result;
r_normal = params.normal;
return true;
} else {
-
return false;
}
}
bool ConcavePolygonShape3DSW::intersect_point(const Vector3 &p_point) const {
-
return false; //face is flat
}
Vector3 ConcavePolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
return Vector3();
}
void ConcavePolygonShape3DSW::_cull(int p_idx, _CullParams *p_params) const {
-
const BVH *bvh = &p_params->bvh[p_idx];
- if (!p_params->aabb.intersects(bvh->aabb))
+ if (!p_params->aabb.intersects(bvh->aabb)) {
return;
+ }
if (bvh->face_index >= 0) {
-
const Face *f = &p_params->faces[bvh->face_index];
FaceShape3DSW *face = p_params->face;
face->normal = f->normal;
@@ -1286,24 +1180,21 @@ void ConcavePolygonShape3DSW::_cull(int p_idx, _CullParams *p_params) const {
p_params->callback(p_params->userdata, face);
} else {
-
if (bvh->left >= 0) {
-
_cull(bvh->left, p_params);
}
if (bvh->right >= 0) {
-
_cull(bvh->right, p_params);
}
}
}
void ConcavePolygonShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
-
// make matrix local to concave
- if (faces.size() == 0)
+ if (faces.size() == 0) {
return;
+ }
AABB local_aabb = p_local_aabb;
@@ -1328,7 +1219,6 @@ void ConcavePolygonShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback
}
Vector3 ConcavePolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -1339,38 +1229,30 @@ Vector3 ConcavePolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const {
}
struct _VolumeSW_BVH_Element {
-
AABB aabb;
Vector3 center;
int face_index;
};
struct _VolumeSW_BVH_CompareX {
-
_FORCE_INLINE_ bool operator()(const _VolumeSW_BVH_Element &a, const _VolumeSW_BVH_Element &b) const {
-
return a.center.x < b.center.x;
}
};
struct _VolumeSW_BVH_CompareY {
-
_FORCE_INLINE_ bool operator()(const _VolumeSW_BVH_Element &a, const _VolumeSW_BVH_Element &b) const {
-
return a.center.y < b.center.y;
}
};
struct _VolumeSW_BVH_CompareZ {
-
_FORCE_INLINE_ bool operator()(const _VolumeSW_BVH_Element &a, const _VolumeSW_BVH_Element &b) const {
-
return a.center.z < b.center.z;
}
};
struct _VolumeSW_BVH {
-
AABB aabb;
_VolumeSW_BVH *left;
_VolumeSW_BVH *right;
@@ -1379,7 +1261,6 @@ struct _VolumeSW_BVH {
};
_VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_size, int &count) {
-
_VolumeSW_BVH *bvh = memnew(_VolumeSW_BVH);
if (p_size == 1) {
@@ -1391,34 +1272,29 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz
count++;
return bvh;
} else {
-
bvh->face_index = -1;
}
AABB aabb;
for (int i = 0; i < p_size; i++) {
-
- if (i == 0)
+ if (i == 0) {
aabb = p_elements[i].aabb;
- else
+ } else {
aabb.merge_with(p_elements[i].aabb);
+ }
}
bvh->aabb = aabb;
switch (aabb.get_longest_axis_index()) {
-
case 0: {
-
SortArray<_VolumeSW_BVH_Element, _VolumeSW_BVH_CompareX> sort_x;
sort_x.sort(p_elements, p_size);
} break;
case 1: {
-
SortArray<_VolumeSW_BVH_Element, _VolumeSW_BVH_CompareY> sort_y;
sort_y.sort(p_elements, p_size);
} break;
case 2: {
-
SortArray<_VolumeSW_BVH_Element, _VolumeSW_BVH_CompareZ> sort_z;
sort_z.sort(p_elements, p_size);
} break;
@@ -1434,7 +1310,6 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz
}
void ConcavePolygonShape3DSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx) {
-
int idx = p_idx;
p_bvh_array[idx].aabb = p_bvh_tree->aabb;
@@ -1446,7 +1321,6 @@ void ConcavePolygonShape3DSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_ar
_fill_bvh(p_bvh_tree->left, p_bvh_array, p_idx);
} else {
-
p_bvh_array[p_idx].left = -1;
}
@@ -1455,7 +1329,6 @@ void ConcavePolygonShape3DSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_ar
_fill_bvh(p_bvh_tree->right, p_bvh_array, p_idx);
} else {
-
p_bvh_array[p_idx].right = -1;
}
@@ -1463,7 +1336,6 @@ void ConcavePolygonShape3DSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_ar
}
void ConcavePolygonShape3DSW::_setup(Vector<Vector3> p_faces) {
-
int src_face_count = p_faces.size();
if (src_face_count == 0) {
configure(AABB());
@@ -1489,7 +1361,6 @@ void ConcavePolygonShape3DSW::_setup(Vector<Vector3> p_faces) {
AABB _aabb;
for (int i = 0; i < src_face_count; i++) {
-
Face3 face(facesr[i * 3 + 0], facesr[i * 3 + 1], facesr[i * 3 + 2]);
bvh_arrayw[i].aabb = face.get_aabb();
@@ -1502,10 +1373,11 @@ void ConcavePolygonShape3DSW::_setup(Vector<Vector3> p_faces) {
verticesw[i * 3 + 0] = face.vertex[0];
verticesw[i * 3 + 1] = face.vertex[1];
verticesw[i * 3 + 2] = face.vertex[2];
- if (i == 0)
+ if (i == 0) {
_aabb = bvh_arrayw[i].aabb;
- else
+ } else {
_aabb.merge_with(bvh_arrayw[i].aabb);
+ }
}
int count = 0;
@@ -1522,12 +1394,10 @@ void ConcavePolygonShape3DSW::_setup(Vector<Vector3> p_faces) {
}
void ConcavePolygonShape3DSW::set_data(const Variant &p_data) {
-
_setup(p_data);
}
Variant ConcavePolygonShape3DSW::get_data() const {
-
return get_faces();
}
@@ -1537,36 +1407,32 @@ ConcavePolygonShape3DSW::ConcavePolygonShape3DSW() {
/* HEIGHT MAP SHAPE */
Vector<real_t> HeightMapShape3DSW::get_heights() const {
-
return heights;
}
-int HeightMapShape3DSW::get_width() const {
+int HeightMapShape3DSW::get_width() const {
return width;
}
-int HeightMapShape3DSW::get_depth() const {
+int HeightMapShape3DSW::get_depth() const {
return depth;
}
-real_t HeightMapShape3DSW::get_cell_size() const {
+real_t HeightMapShape3DSW::get_cell_size() const {
return cell_size;
}
void HeightMapShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
//not very useful, but not very used either
p_transform.xform(get_aabb()).project_range_in_plane(Plane(p_normal, 0), r_min, r_max);
}
Vector3 HeightMapShape3DSW::get_support(const Vector3 &p_normal) const {
-
//not very useful, but not very used either
return get_aabb().get_support(p_normal);
}
bool HeightMapShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const {
-
return false;
}
@@ -1575,7 +1441,6 @@ bool HeightMapShape3DSW::intersect_point(const Vector3 &p_point) const {
}
Vector3 HeightMapShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
-
return Vector3();
}
@@ -1583,7 +1448,6 @@ void HeightMapShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback, voi
}
Vector3 HeightMapShape3DSW::get_moment_of_inertia(real_t p_mass) const {
-
// use bad AABB approximation
Vector3 extents = get_aabb().size * 0.5;
@@ -1594,7 +1458,6 @@ Vector3 HeightMapShape3DSW::get_moment_of_inertia(real_t p_mass) const {
}
void HeightMapShape3DSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) {
-
heights = p_heights;
width = p_width;
depth = p_depth;
@@ -1605,16 +1468,15 @@ void HeightMapShape3DSW::_setup(Vector<real_t> p_heights, int p_width, int p_dep
AABB aabb;
for (int i = 0; i < depth; i++) {
-
for (int j = 0; j < width; j++) {
-
real_t h = r[i * width + j];
Vector3 pos(j * cell_size, h, i * cell_size);
- if (i == 0 || j == 0)
+ if (i == 0 || j == 0) {
aabb.position = pos;
- else
+ } else {
aabb.expand_to(pos);
+ }
}
}
@@ -1622,7 +1484,6 @@ void HeightMapShape3DSW::_setup(Vector<real_t> p_heights, int p_width, int p_dep
}
void HeightMapShape3DSW::set_data(const Variant &p_data) {
-
ERR_FAIL_COND(p_data.get_type() != Variant::DICTIONARY);
Dictionary d = p_data;
ERR_FAIL_COND(!d.has("width"));
@@ -1643,12 +1504,10 @@ void HeightMapShape3DSW::set_data(const Variant &p_data) {
}
Variant HeightMapShape3DSW::get_data() const {
-
ERR_FAIL_V(Variant());
}
HeightMapShape3DSW::HeightMapShape3DSW() {
-
width = 0;
depth = 0;
cell_size = 0;
diff --git a/servers/physics_3d/shape_3d_sw.h b/servers/physics_3d/shape_3d_sw.h
index dd29ec849b..2a2cd42255 100644
--- a/servers/physics_3d/shape_3d_sw.h
+++ b/servers/physics_3d/shape_3d_sw.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_SW_H
#define SHAPE_SW_H
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "servers/physics_server_3d.h"
/*
@@ -56,7 +56,6 @@ public:
};
class Shape3DSW {
-
RID self;
AABB aabb;
bool configured;
@@ -108,7 +107,6 @@ public:
};
class ConcaveShape3DSW : public Shape3DSW {
-
public:
virtual bool is_concave() const { return true; }
typedef void (*Callback)(void *p_userdata, Shape3DSW *p_convex);
@@ -120,7 +118,6 @@ public:
};
class PlaneShape3DSW : public Shape3DSW {
-
Plane plane;
void _setup(const Plane &p_plane);
@@ -146,7 +143,6 @@ public:
};
class RayShape3DSW : public Shape3DSW {
-
real_t length;
bool slips_on_slope;
@@ -175,7 +171,6 @@ public:
};
class SphereShape3DSW : public Shape3DSW {
-
real_t radius;
void _setup(real_t p_radius);
@@ -203,7 +198,6 @@ public:
};
class BoxShape3DSW : public Shape3DSW {
-
Vector3 half_extents;
void _setup(const Vector3 &p_half_extents);
@@ -229,7 +223,6 @@ public:
};
class CapsuleShape3DSW : public Shape3DSW {
-
real_t height;
real_t radius;
@@ -259,13 +252,12 @@ public:
};
struct ConvexPolygonShape3DSW : public Shape3DSW {
-
- Geometry::MeshData mesh;
+ Geometry3D::MeshData mesh;
void _setup(const Vector<Vector3> &p_vertices);
public:
- const Geometry::MeshData &get_mesh() const { return mesh; }
+ const Geometry3D::MeshData &get_mesh() const { return mesh; }
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
@@ -291,7 +283,6 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
// always a trimesh
struct Face {
-
Vector3 normal;
int indices[3];
};
@@ -300,7 +291,6 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
Vector<Vector3> vertices;
struct BVH {
-
AABB aabb;
int left;
int right;
@@ -311,7 +301,6 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
Vector<BVH> bvh;
struct _CullParams {
-
AABB aabb;
Callback callback;
void *userdata;
@@ -322,7 +311,6 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
};
struct _SegmentCullParams {
-
Vector3 from;
Vector3 to;
const Face *faces;
@@ -366,7 +354,6 @@ public:
};
struct HeightMapShape3DSW : public ConcaveShape3DSW {
-
Vector<real_t> heights;
int width;
int depth;
@@ -403,7 +390,6 @@ public:
//used internally
struct FaceShape3DSW : public Shape3DSW {
-
Vector3 normal; //cache
Vector3 vertex[3];
@@ -427,14 +413,12 @@ struct FaceShape3DSW : public Shape3DSW {
};
struct MotionShape3DSW : public Shape3DSW {
-
Shape3DSW *shape;
Vector3 motion;
virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {
-
Vector3 cast = p_transform.basis.xform(motion);
real_t mina, maxa;
real_t minb, maxb;
@@ -447,7 +431,6 @@ struct MotionShape3DSW : public Shape3DSW {
}
Vector3 get_support(const Vector3 &p_normal) const {
-
Vector3 support = shape->get_support(p_normal);
if (p_normal.dot(motion) > 0) {
support += motion;
diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index 66d17b3182..48f250ba35 100644
--- a/servers/physics_3d/space_3d_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -35,22 +35,22 @@
#include "physics_server_3d_sw.h"
_FORCE_INLINE_ static bool _can_collide_with(CollisionObject3DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
if (!(p_object->get_collision_layer() & p_collision_mask)) {
return false;
}
- if (p_object->get_type() == CollisionObject3DSW::TYPE_AREA && !p_collide_with_areas)
+ if (p_object->get_type() == CollisionObject3DSW::TYPE_AREA && !p_collide_with_areas) {
return false;
+ }
- if (p_object->get_type() == CollisionObject3DSW::TYPE_BODY && !p_collide_with_bodies)
+ if (p_object->get_type() == CollisionObject3DSW::TYPE_BODY && !p_collide_with_bodies) {
return false;
+ }
return true;
}
int PhysicsDirectSpaceState3DSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
ERR_FAIL_COND_V(space->locked, false);
int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
int cc = 0;
@@ -58,17 +58,19 @@ int PhysicsDirectSpaceState3DSW::intersect_point(const Vector3 &p_point, ShapeRe
//Transform ai = p_xform.affine_inverse();
for (int i = 0; i < amount; i++) {
-
- if (cc >= p_result_max)
+ if (cc >= p_result_max) {
break;
+ }
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
//area can't be picked by ray (default)
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue;
+ }
const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
@@ -76,14 +78,16 @@ int PhysicsDirectSpaceState3DSW::intersect_point(const Vector3 &p_point, ShapeRe
Transform inv_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
inv_xform.affine_invert();
- if (!col_obj->get_shape(shape_idx)->intersect_point(inv_xform.xform(p_point)))
+ if (!col_obj->get_shape(shape_idx)->intersect_point(inv_xform.xform(p_point))) {
continue;
+ }
r_results[cc].collider_id = col_obj->get_instance_id();
- if (r_results[cc].collider_id.is_valid())
+ if (r_results[cc].collider_id.is_valid()) {
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
- else
+ } else {
r_results[cc].collider = nullptr;
+ }
r_results[cc].rid = col_obj->get_self();
r_results[cc].shape = shape_idx;
@@ -94,7 +98,6 @@ int PhysicsDirectSpaceState3DSW::intersect_point(const Vector3 &p_point, ShapeRe
}
bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_ray) {
-
ERR_FAIL_COND_V(space->locked, false);
Vector3 begin, end;
@@ -114,15 +117,17 @@ bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vec
real_t min_d = 1e10;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
- if (p_pick_ray && !(space->intersection_query_results[i]->is_ray_pickable()))
+ if (p_pick_ray && !(space->intersection_query_results[i]->is_ray_pickable())) {
continue;
+ }
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue;
+ }
const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
@@ -137,14 +142,12 @@ bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vec
Vector3 shape_point, shape_normal;
if (shape->intersect_segment(local_from, local_to, shape_point, shape_normal)) {
-
Transform xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
shape_point = xform.xform(shape_point);
real_t ld = normal.dot(shape_point);
if (ld < min_d) {
-
min_d = ld;
res_point = shape_point;
res_normal = inv_xform.basis.xform_inv(shape_normal).normalized();
@@ -155,14 +158,16 @@ bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vec
}
}
- if (!collided)
+ if (!collided) {
return false;
+ }
r_result.collider_id = res_obj->get_instance_id();
- if (r_result.collider_id.is_valid())
+ if (r_result.collider_id.is_valid()) {
r_result.collider = ObjectDB::get_instance(r_result.collider_id);
- else
+ } else {
r_result.collider = nullptr;
+ }
r_result.normal = res_normal;
r_result.position = res_point;
r_result.rid = res_obj->get_self();
@@ -172,9 +177,9 @@ bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vec
}
int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
- if (p_result_max <= 0)
+ if (p_result_max <= 0) {
return 0;
+ }
Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -188,30 +193,34 @@ int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Trans
//Transform ai = p_xform.affine_inverse();
for (int i = 0; i < amount; i++) {
-
- if (cc >= p_result_max)
+ if (cc >= p_result_max) {
break;
+ }
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
//area can't be picked by ray (default)
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue;
+ }
const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
- if (!CollisionSolver3DSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), nullptr, nullptr, nullptr, p_margin, 0))
+ if (!CollisionSolver3DSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), nullptr, nullptr, nullptr, p_margin, 0)) {
continue;
+ }
if (r_results) {
r_results[cc].collider_id = col_obj->get_instance_id();
- if (r_results[cc].collider_id.is_valid())
+ if (r_results[cc].collider_id.is_valid()) {
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
- else
+ } else {
r_results[cc].collider = nullptr;
+ }
r_results[cc].rid = col_obj->get_self();
r_results[cc].shape = shape_idx;
}
@@ -223,7 +232,6 @@ int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Trans
}
bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
-
Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, false);
@@ -246,12 +254,13 @@ bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transfor
Vector3 closest_A, closest_B;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
- if (p_exclude.has(space->intersection_query_results[i]->get_self()))
+ if (p_exclude.has(space->intersection_query_results[i]->get_self())) {
continue; //ignore excluded
+ }
const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
@@ -290,10 +299,8 @@ bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transfor
bool collided = !CollisionSolver3DSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, aabb, &sep);
if (collided) {
-
hi = ofs;
} else {
-
point_A = lA;
point_B = lB;
low = ofs;
@@ -329,9 +336,9 @@ bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transfor
}
bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
- if (p_result_max <= 0)
- return 0;
+ if (p_result_max <= 0) {
+ return false;
+ }
Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -353,9 +360,9 @@ bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform &p_
PhysicsServer3DSW::CollCbkData *cbkptr = &cbk;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
@@ -375,7 +382,6 @@ bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform &p_
}
struct _RestCallbackData {
-
const CollisionObject3DSW *object;
const CollisionObject3DSW *best_object;
int shape;
@@ -387,15 +393,16 @@ struct _RestCallbackData {
};
static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
-
_RestCallbackData *rd = (_RestCallbackData *)p_userdata;
Vector3 contact_rel = p_point_B - p_point_A;
real_t len = contact_rel.length();
- if (len < rd->min_allowed_depth)
+ if (len < rd->min_allowed_depth) {
return;
- if (len <= rd->best_len)
+ }
+ if (len <= rd->best_len) {
return;
+ }
rd->best_len = len;
rd->best_contact = p_point_B;
@@ -403,8 +410,8 @@ static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B,
rd->best_object = rd->object;
rd->best_shape = rd->shape;
}
-bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
+bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
@@ -420,25 +427,28 @@ bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shap
rcd.min_allowed_depth = space->test_motion_min_contact_depth;
for (int i = 0; i < amount; i++) {
-
- if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
+ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) {
continue;
+ }
const CollisionObject3DSW *col_obj = space->intersection_query_results[i];
int shape_idx = space->intersection_query_subindex_results[i];
- if (p_exclude.has(col_obj->get_self()))
+ if (p_exclude.has(col_obj->get_self())) {
continue;
+ }
rcd.object = col_obj;
rcd.shape = shape_idx;
bool sc = CollisionSolver3DSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, nullptr, p_margin);
- if (!sc)
+ if (!sc) {
continue;
+ }
}
- if (rcd.best_len == 0 || !rcd.best_object)
+ if (rcd.best_len == 0 || !rcd.best_object) {
return false;
+ }
r_info->collider_id = rcd.best_object->get_instance_id();
r_info->shape = rcd.best_shape;
@@ -446,7 +456,6 @@ bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shap
r_info->point = rcd.best_contact;
r_info->rid = rcd.best_object->get_self();
if (rcd.best_object->get_type() == CollisionObject3DSW::TYPE_BODY) {
-
const Body3DSW *body = static_cast<const Body3DSW *>(rcd.best_object);
r_info->linear_velocity = body->get_linear_velocity() +
(body->get_angular_velocity()).cross(body->get_transform().origin - rcd.best_contact); // * mPos);
@@ -459,7 +468,6 @@ bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shap
}
Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const {
-
CollisionObject3DSW *obj = PhysicsServer3DSW::singleton->area_owner.getornull(p_object);
if (!obj) {
obj = PhysicsServer3DSW::singleton->body_owner.getornull(p_object);
@@ -474,9 +482,9 @@ Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_ob
bool shapes_found = false;
for (int i = 0; i < obj->get_shape_count(); i++) {
-
- if (obj->is_shape_set_as_disabled(i))
+ if (obj->is_shape_set_as_disabled(i)) {
continue;
+ }
Transform shape_xform = obj->get_transform() * obj->get_shape_transform(i);
Shape3DSW *shape = obj->get_shape(i);
@@ -500,33 +508,30 @@ Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_ob
}
PhysicsDirectSpaceState3DSW::PhysicsDirectSpaceState3DSW() {
-
space = nullptr;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Space3DSW::_cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb) {
-
int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results);
for (int i = 0; i < amount; i++) {
-
bool keep = true;
- if (intersection_query_results[i] == p_body)
+ if (intersection_query_results[i] == p_body) {
keep = false;
- else if (intersection_query_results[i]->get_type() == CollisionObject3DSW::TYPE_AREA)
+ } else if (intersection_query_results[i]->get_type() == CollisionObject3DSW::TYPE_AREA) {
keep = false;
- else if ((static_cast<Body3DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0)
+ } else if ((static_cast<Body3DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0) {
keep = false;
- else if (static_cast<Body3DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
+ } else if (static_cast<Body3DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) {
keep = false;
- else if (static_cast<Body3DSW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i]))
+ } else if (static_cast<Body3DSW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i])) {
keep = false;
+ }
if (!keep) {
-
if (i < amount - 1) {
SWAP(intersection_query_results[i], intersection_query_results[amount - 1]);
SWAP(intersection_query_subindex_results[i], intersection_query_subindex_results[amount - 1]);
@@ -541,15 +546,14 @@ int Space3DSW::_cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb) {
}
int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) {
-
AABB body_aabb;
bool shapes_found = false;
for (int i = 0; i < p_body->get_shape_count(); i++) {
-
- if (p_body->is_shape_set_as_disabled(i))
+ if (p_body->is_shape_set_as_disabled(i)) {
continue;
+ }
if (!shapes_found) {
body_aabb = p_body->get_shape_aabb(i);
@@ -587,7 +591,6 @@ int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_tra
CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk;
do {
-
Vector3 recover_motion;
bool collided = false;
@@ -595,18 +598,19 @@ int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_tra
int amount = _cull_aabb_for_body(p_body, body_aabb);
for (int j = 0; j < p_body->get_shape_count(); j++) {
- if (p_body->is_shape_set_as_disabled(j))
+ if (p_body->is_shape_set_as_disabled(j)) {
continue;
+ }
Shape3DSW *body_shape = p_body->get_shape(j);
- if (body_shape->get_type() != PhysicsServer3D::SHAPE_RAY)
+ if (body_shape->get_type() != PhysicsServer3D::SHAPE_RAY) {
continue;
+ }
Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
for (int i = 0; i < amount; i++) {
-
const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
@@ -649,7 +653,6 @@ int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_tra
float depth = a.distance_to(b);
if (depth > result.collision_depth) {
-
result.collision_depth = depth;
result.collision_point = b;
result.collision_normal = (b - a).normalized();
@@ -696,7 +699,6 @@ int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_tra
}
bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
-
//give me back regular physics engine logic
//this is madness
//and most people using this function will think
@@ -712,9 +714,9 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
bool shapes_found = false;
for (int i = 0; i < p_body->get_shape_count(); i++) {
-
- if (p_body->is_shape_set_as_disabled(i))
+ if (p_body->is_shape_set_as_disabled(i)) {
continue;
+ }
if (!shapes_found) {
body_aabb = p_body->get_shape_aabb(i);
@@ -747,7 +749,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
Vector3 sr[max_results * 2];
do {
-
PhysicsServer3DSW::CollCbkData cbk;
cbk.max = max_results;
cbk.amount = 0;
@@ -761,8 +762,9 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
int amount = _cull_aabb_for_body(p_body, body_aabb);
for (int j = 0; j < p_body->get_shape_count(); j++) {
- if (p_body->is_shape_set_as_disabled(j))
+ if (p_body->is_shape_set_as_disabled(j)) {
continue;
+ }
Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
Shape3DSW *body_shape = p_body->get_shape(j);
@@ -771,7 +773,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
}
for (int i = 0; i < amount; i++) {
-
const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
@@ -788,7 +789,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
Vector3 recover_motion;
for (int i = 0; i < cbk.amount; i++) {
-
Vector3 a = sr[i * 2 + 0];
Vector3 b = sr[i * 2 + 1];
recover_motion += (b - a) * 0.4;
@@ -821,9 +821,9 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
int amount = _cull_aabb_for_body(p_body, motion_aabb);
for (int j = 0; j < p_body->get_shape_count(); j++) {
-
- if (p_body->is_shape_set_as_disabled(j))
+ if (p_body->is_shape_set_as_disabled(j)) {
continue;
+ }
Transform body_shape_xform = body_transform * p_body->get_shape_transform(j);
Shape3DSW *body_shape = p_body->get_shape(j);
@@ -843,7 +843,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
real_t best_unsafe = 1;
for (int i = 0; i < amount; i++) {
-
const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
@@ -881,10 +880,8 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
bool collided = !CollisionSolver3DSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep);
if (collided) {
-
hi = ofs;
} else {
-
point_A = lA;
point_B = lB;
low = ofs;
@@ -898,7 +895,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
}
if (stuck) {
-
safe = 0;
unsafe = 0;
best_shape = j; //sadly it's the best
@@ -908,7 +904,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
continue;
}
if (best_safe < safe) {
-
safe = best_safe;
unsafe = best_unsafe;
best_shape = j;
@@ -921,14 +916,12 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
//not collided
collided = false;
if (r_result) {
-
r_result->motion = p_motion;
r_result->remainder = Vector3();
r_result->motion += (body_transform.get_origin() - p_from.get_origin());
}
} else {
-
//it collided, let's get the rest info in unsafe advance
Transform ugt = body_transform;
ugt.origin += p_motion * unsafe;
@@ -947,19 +940,18 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
int amount = _cull_aabb_for_body(p_body, body_aabb);
for (int i = 0; i < amount; i++) {
-
const CollisionObject3DSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i];
rcd.object = col_obj;
rcd.shape = shape_idx;
bool sc = CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, nullptr, p_margin);
- if (!sc)
+ if (!sc) {
continue;
+ }
}
if (rcd.best_len != 0) {
-
if (r_result) {
r_result->collider = rcd.best_object->get_self();
r_result->collider_id = rcd.best_object->get_instance_id();
@@ -982,7 +974,6 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
collided = true;
} else {
if (r_result) {
-
r_result->motion = p_motion;
r_result->remainder = Vector3();
r_result->motion += (body_transform.get_origin() - p_from.get_origin());
@@ -996,11 +987,13 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
}
void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self) {
+ if (!A->test_collision_mask(B)) {
+ return nullptr;
+ }
CollisionObject3DSW::Type type_A = A->get_type();
CollisionObject3DSW::Type type_B = B->get_type();
if (type_A > type_B) {
-
SWAP(A, B);
SWAP(p_subindex_A, p_subindex_B);
SWAP(type_A, type_B);
@@ -1011,21 +1004,17 @@ void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, Coll
self->collision_pairs++;
if (type_A == CollisionObject3DSW::TYPE_AREA) {
-
Area3DSW *area = static_cast<Area3DSW *>(A);
if (type_B == CollisionObject3DSW::TYPE_AREA) {
-
Area3DSW *area_b = static_cast<Area3DSW *>(B);
Area2Pair3DSW *area2_pair = memnew(Area2Pair3DSW(area_b, p_subindex_B, area, p_subindex_A));
return area2_pair;
} else {
-
Body3DSW *body = static_cast<Body3DSW *>(B);
AreaPair3DSW *area_pair = memnew(AreaPair3DSW(body, p_subindex_B, area, p_subindex_A));
return area_pair;
}
} else {
-
BodyPair3DSW *b = memnew(BodyPair3DSW((Body3DSW *)A, p_subindex_A, (Body3DSW *)B, p_subindex_B));
return b;
}
@@ -1034,6 +1023,9 @@ void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, Coll
}
void Space3DSW::_broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_self) {
+ if (!p_data) {
+ return;
+ }
Space3DSW *self = (Space3DSW *)p_self;
self->collision_pairs--;
@@ -1042,94 +1034,79 @@ void Space3DSW::_broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, Col
}
const SelfList<Body3DSW>::List &Space3DSW::get_active_body_list() const {
-
return active_list;
}
-void Space3DSW::body_add_to_active_list(SelfList<Body3DSW> *p_body) {
+void Space3DSW::body_add_to_active_list(SelfList<Body3DSW> *p_body) {
active_list.add(p_body);
}
-void Space3DSW::body_remove_from_active_list(SelfList<Body3DSW> *p_body) {
+void Space3DSW::body_remove_from_active_list(SelfList<Body3DSW> *p_body) {
active_list.remove(p_body);
}
void Space3DSW::body_add_to_inertia_update_list(SelfList<Body3DSW> *p_body) {
-
inertia_update_list.add(p_body);
}
void Space3DSW::body_remove_from_inertia_update_list(SelfList<Body3DSW> *p_body) {
-
inertia_update_list.remove(p_body);
}
BroadPhase3DSW *Space3DSW::get_broadphase() {
-
return broadphase;
}
void Space3DSW::add_object(CollisionObject3DSW *p_object) {
-
ERR_FAIL_COND(objects.has(p_object));
objects.insert(p_object);
}
void Space3DSW::remove_object(CollisionObject3DSW *p_object) {
-
ERR_FAIL_COND(!objects.has(p_object));
objects.erase(p_object);
}
const Set<CollisionObject3DSW *> &Space3DSW::get_objects() const {
-
return objects;
}
void Space3DSW::body_add_to_state_query_list(SelfList<Body3DSW> *p_body) {
-
state_query_list.add(p_body);
}
-void Space3DSW::body_remove_from_state_query_list(SelfList<Body3DSW> *p_body) {
+void Space3DSW::body_remove_from_state_query_list(SelfList<Body3DSW> *p_body) {
state_query_list.remove(p_body);
}
void Space3DSW::area_add_to_monitor_query_list(SelfList<Area3DSW> *p_area) {
-
monitor_query_list.add(p_area);
}
-void Space3DSW::area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area) {
+void Space3DSW::area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area) {
monitor_query_list.remove(p_area);
}
void Space3DSW::area_add_to_moved_list(SelfList<Area3DSW> *p_area) {
-
area_moved_list.add(p_area);
}
void Space3DSW::area_remove_from_moved_list(SelfList<Area3DSW> *p_area) {
-
area_moved_list.remove(p_area);
}
const SelfList<Area3DSW>::List &Space3DSW::get_moved_area_list() const {
-
return area_moved_list;
}
void Space3DSW::call_queries() {
-
while (state_query_list.first()) {
-
Body3DSW *b = state_query_list.first()->self();
state_query_list.remove(state_query_list.first());
b->call_queries();
}
while (monitor_query_list.first()) {
-
Area3DSW *a = monitor_query_list.first()->self();
monitor_query_list.remove(monitor_query_list.first());
a->call_queries();
@@ -1137,7 +1114,6 @@ void Space3DSW::call_queries() {
}
void Space3DSW::setup() {
-
contact_debug_count = 0;
while (inertia_update_list.first()) {
inertia_update_list.first()->self()->update_inertias();
@@ -1146,14 +1122,11 @@ void Space3DSW::setup() {
}
void Space3DSW::update() {
-
broadphase->update();
}
void Space3DSW::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) {
-
switch (p_param) {
-
case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
contact_recycle_radius = p_value;
break;
@@ -1185,9 +1158,7 @@ void Space3DSW::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_valu
}
real_t Space3DSW::get_param(PhysicsServer3D::SpaceParameter p_param) const {
-
switch (p_param) {
-
case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
return contact_recycle_radius;
case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
@@ -1211,27 +1182,22 @@ real_t Space3DSW::get_param(PhysicsServer3D::SpaceParameter p_param) const {
}
void Space3DSW::lock() {
-
locked = true;
}
void Space3DSW::unlock() {
-
locked = false;
}
bool Space3DSW::is_locked() const {
-
return locked;
}
PhysicsDirectSpaceState3DSW *Space3DSW::get_direct_state() {
-
return direct_access;
}
Space3DSW::Space3DSW() {
-
collision_pairs = 0;
active_objects = 0;
island_count = 0;
@@ -1258,12 +1224,12 @@ Space3DSW::Space3DSW() {
direct_access = memnew(PhysicsDirectSpaceState3DSW);
direct_access->space = this;
- for (int i = 0; i < ELAPSED_TIME_MAX; i++)
+ for (int i = 0; i < ELAPSED_TIME_MAX; i++) {
elapsed_time[i] = 0;
+ }
}
Space3DSW::~Space3DSW() {
-
memdelete(broadphase);
memdelete(direct_access);
}
diff --git a/servers/physics_3d/space_3d_sw.h b/servers/physics_3d/space_3d_sw.h
index a0b4379376..f9198e3d40 100644
--- a/servers/physics_3d/space_3d_sw.h
+++ b/servers/physics_3d/space_3d_sw.h
@@ -42,7 +42,6 @@
#include "core/typedefs.h"
class PhysicsDirectSpaceState3DSW : public PhysicsDirectSpaceState3D {
-
GDCLASS(PhysicsDirectSpaceState3DSW, PhysicsDirectSpaceState3D);
public:
@@ -60,7 +59,6 @@ public:
};
class Space3DSW {
-
public:
enum ElapsedTime {
ELAPSED_TIME_INTEGRATE_FORCES,
@@ -187,8 +185,9 @@ public:
void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); }
_FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.empty(); }
_FORCE_INLINE_ void add_debug_contact(const Vector3 &p_contact) {
- if (contact_debug_count < contact_debug.size())
+ if (contact_debug_count < contact_debug.size()) {
contact_debug.write[contact_debug_count++] = p_contact;
+ }
}
_FORCE_INLINE_ Vector<Vector3> get_debug_contacts() { return contact_debug; }
_FORCE_INLINE_ int get_debug_contact_count() { return contact_debug_count; }
diff --git a/servers/physics_3d/step_3d_sw.cpp b/servers/physics_3d/step_3d_sw.cpp
index 1a7d5f8cec..9a2a0073a1 100644
--- a/servers/physics_3d/step_3d_sw.cpp
+++ b/servers/physics_3d/step_3d_sw.cpp
@@ -34,33 +34,33 @@
#include "core/os/os.h"
void Step3DSW::_populate_island(Body3DSW *p_body, Body3DSW **p_island, Constraint3DSW **p_constraint_island) {
-
p_body->set_island_step(_step);
p_body->set_island_next(*p_island);
*p_island = p_body;
for (Map<Constraint3DSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) {
-
Constraint3DSW *c = (Constraint3DSW *)E->key();
- if (c->get_island_step() == _step)
+ if (c->get_island_step() == _step) {
continue; //already processed
+ }
c->set_island_step(_step);
c->set_island_next(*p_constraint_island);
*p_constraint_island = c;
for (int i = 0; i < c->get_body_count(); i++) {
- if (i == E->get())
+ if (i == E->get()) {
continue;
+ }
Body3DSW *b = c->get_body_ptr()[i];
- if (b->get_island_step() == _step || b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC)
+ if (b->get_island_step() == _step || b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
continue; //no go
+ }
_populate_island(c->get_body_ptr()[i], p_island, p_constraint_island);
}
}
}
void Step3DSW::_setup_island(Constraint3DSW *p_island, real_t p_delta) {
-
Constraint3DSW *ci = p_island;
while (ci) {
ci->setup(p_delta);
@@ -70,13 +70,10 @@ void Step3DSW::_setup_island(Constraint3DSW *p_island, real_t p_delta) {
}
void Step3DSW::_solve_island(Constraint3DSW *p_island, int p_iterations, real_t p_delta) {
-
int at_priority = 1;
while (p_island) {
-
for (int i = 0; i < p_iterations; i++) {
-
Constraint3DSW *ci = p_island;
while (ci) {
ci->solve(p_delta);
@@ -97,7 +94,6 @@ void Step3DSW::_solve_island(Constraint3DSW *p_island, int p_iterations, real_t
p_island = ci->get_island_next();
}
} else {
-
prev = ci;
}
@@ -108,19 +104,18 @@ void Step3DSW::_solve_island(Constraint3DSW *p_island, int p_iterations, real_t
}
void Step3DSW::_check_suspend(Body3DSW *p_island, real_t p_delta) {
-
bool can_sleep = true;
Body3DSW *b = p_island;
while (b) {
-
if (b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
}
- if (!b->sleep_test(p_delta))
+ if (!b->sleep_test(p_delta)) {
can_sleep = false;
+ }
b = b->get_island_next();
}
@@ -129,7 +124,6 @@ void Step3DSW::_check_suspend(Body3DSW *p_island, real_t p_delta) {
b = p_island;
while (b) {
-
if (b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) {
b = b->get_island_next();
continue; //ignore for static
@@ -137,15 +131,15 @@ void Step3DSW::_check_suspend(Body3DSW *p_island, real_t p_delta) {
bool active = b->is_active();
- if (active == can_sleep)
+ if (active == can_sleep) {
b->set_active(!can_sleep);
+ }
b = b->get_island_next();
}
}
void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
-
p_space->lock(); // can't access space during this
p_space->setup(); //update inertias, etc
@@ -161,7 +155,6 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
const SelfList<Body3DSW> *b = body_list->first();
while (b) {
-
b->self()->integrate_forces(p_delta);
b = b->next();
active_count++;
@@ -187,7 +180,6 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
Body3DSW *body = b->self();
if (body->get_island_step() != _step) {
-
Body3DSW *island = nullptr;
Constraint3DSW *constraint_island = nullptr;
_populate_island(body, &island, &constraint_island);
@@ -210,10 +202,10 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
while (aml.first()) {
for (const Set<Constraint3DSW *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) {
-
Constraint3DSW *c = E->get();
- if (c->get_island_step() == _step)
+ if (c->get_island_step() == _step) {
continue;
+ }
c->set_island_step(_step);
c->set_island_next(nullptr);
c->set_island_list_next(constraint_island_list);
@@ -233,7 +225,6 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
{
Constraint3DSW *ci = constraint_island_list;
while (ci) {
-
_setup_island(ci, p_delta);
ci = ci->get_island_list_next();
}
@@ -276,7 +267,6 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
{
Body3DSW *bi = island_list;
while (bi) {
-
_check_suspend(bi, p_delta);
bi = bi->get_island_list_next();
}
@@ -294,6 +284,5 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
}
Step3DSW::Step3DSW() {
-
_step = 1;
}
diff --git a/servers/physics_3d/step_3d_sw.h b/servers/physics_3d/step_3d_sw.h
index c735688a9e..9dbb61308f 100644
--- a/servers/physics_3d/step_3d_sw.h
+++ b/servers/physics_3d/step_3d_sw.h
@@ -34,7 +34,6 @@
#include "space_3d_sw.h"
class Step3DSW {
-
uint64_t _step;
void _populate_island(Body3DSW *p_body, Body3DSW **p_island, Constraint3DSW **p_constraint_island);
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 48c51b5350..080b8c61ad 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -37,7 +37,6 @@
PhysicsServer2D *PhysicsServer2D::singleton = nullptr;
void PhysicsDirectBodyState2D::integrate_forces() {
-
real_t step = get_step();
Vector2 lv = get_linear_velocity();
lv += get_total_gravity() * step;
@@ -46,15 +45,17 @@ void PhysicsDirectBodyState2D::integrate_forces() {
float damp = 1.0 - step * get_total_linear_damp();
- if (damp < 0) // reached zero in the given time
+ if (damp < 0) { // reached zero in the given time
damp = 0;
+ }
lv *= damp;
damp = 1.0 - step * get_total_angular_damp();
- if (damp < 0) // reached zero in the given time
+ if (damp < 0) { // reached zero in the given time
damp = 0;
+ }
av *= damp;
@@ -63,19 +64,16 @@ void PhysicsDirectBodyState2D::integrate_forces() {
}
Object *PhysicsDirectBodyState2D::get_contact_collider_object(int p_contact_idx) const {
-
ObjectID objid = get_contact_collider_id(p_contact_idx);
Object *obj = ObjectDB::get_instance(objid);
return obj;
}
PhysicsServer2D *PhysicsServer2D::get_singleton() {
-
return singleton;
}
void PhysicsDirectBodyState2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState2D::get_total_gravity);
ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState2D::get_total_linear_damp);
ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp);
@@ -135,66 +133,58 @@ PhysicsDirectBodyState2D::PhysicsDirectBodyState2D() {}
///////////////////////////////////////////////////////
void PhysicsShapeQueryParameters2D::set_shape(const RES &p_shape) {
-
ERR_FAIL_COND(p_shape.is_null());
shape = p_shape->get_rid();
}
void PhysicsShapeQueryParameters2D::set_shape_rid(const RID &p_shape) {
-
shape = p_shape;
}
RID PhysicsShapeQueryParameters2D::get_shape_rid() const {
-
return shape;
}
void PhysicsShapeQueryParameters2D::set_transform(const Transform2D &p_transform) {
-
transform = p_transform;
}
-Transform2D PhysicsShapeQueryParameters2D::get_transform() const {
+Transform2D PhysicsShapeQueryParameters2D::get_transform() const {
return transform;
}
void PhysicsShapeQueryParameters2D::set_motion(const Vector2 &p_motion) {
-
motion = p_motion;
}
-Vector2 PhysicsShapeQueryParameters2D::get_motion() const {
+Vector2 PhysicsShapeQueryParameters2D::get_motion() const {
return motion;
}
void PhysicsShapeQueryParameters2D::set_margin(float p_margin) {
-
margin = p_margin;
}
-float PhysicsShapeQueryParameters2D::get_margin() const {
+float PhysicsShapeQueryParameters2D::get_margin() const {
return margin;
}
void PhysicsShapeQueryParameters2D::set_collision_mask(int p_collision_mask) {
-
collision_mask = p_collision_mask;
}
-int PhysicsShapeQueryParameters2D::get_collision_mask() const {
+int PhysicsShapeQueryParameters2D::get_collision_mask() const {
return collision_mask;
}
void PhysicsShapeQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) {
-
exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++)
+ for (int i = 0; i < p_exclude.size(); i++) {
exclude.insert(p_exclude[i]);
+ }
}
Vector<RID> PhysicsShapeQueryParameters2D::get_exclude() const {
-
Vector<RID> ret;
ret.resize(exclude.size());
int idx = 0;
@@ -221,7 +211,6 @@ bool PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled() const {
}
void PhysicsShapeQueryParameters2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters2D::set_shape);
ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters2D::set_shape_rid);
ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters2D::get_shape_rid);
@@ -259,7 +248,6 @@ void PhysicsShapeQueryParameters2D::_bind_methods() {
}
PhysicsShapeQueryParameters2D::PhysicsShapeQueryParameters2D() {
-
margin = 0;
collision_mask = 0x7FFFFFFF;
collide_with_bodies = true;
@@ -267,16 +255,17 @@ PhysicsShapeQueryParameters2D::PhysicsShapeQueryParameters2D() {
}
Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
RayResult inters;
Set<RID> exclude;
- for (int i = 0; i < p_exclude.size(); i++)
+ for (int i = 0; i < p_exclude.size(); i++) {
exclude.insert(p_exclude[i]);
+ }
bool res = intersect_ray(p_from, p_to, inters, exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
- if (!res)
+ if (!res) {
return Dictionary();
+ }
Dictionary d;
d["position"] = inters.position;
@@ -291,7 +280,6 @@ Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Vector2 &p_from, cons
}
Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
-
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<ShapeResult> sr;
@@ -300,7 +288,6 @@ Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryPar
Array ret;
ret.resize(rc);
for (int i = 0; i < rc; i++) {
-
Dictionary d;
d["rid"] = sr[i].rid;
d["collider_id"] = sr[i].collider_id;
@@ -314,13 +301,13 @@ Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryPar
}
Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
-
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
float closest_safe, closest_unsafe;
bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
- if (!res)
+ if (!res) {
return Array();
+ }
Array ret;
ret.resize(2);
ret[0] = closest_safe;
@@ -329,27 +316,28 @@ Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParamet
}
Array PhysicsDirectSpaceState2D::_intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) {
-
Set<RID> exclude;
- for (int i = 0; i < p_exclude.size(); i++)
+ for (int i = 0; i < p_exclude.size(); i++) {
exclude.insert(p_exclude[i]);
+ }
Vector<ShapeResult> ret;
ret.resize(p_max_results);
int rc;
- if (p_filter_by_canvas)
+ if (p_filter_by_canvas) {
rc = intersect_point(p_point, ret.ptrw(), ret.size(), exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
- else
+ } else {
rc = intersect_point_on_canvas(p_point, p_canvas_instance_id, ret.ptrw(), ret.size(), exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
+ }
- if (rc == 0)
+ if (rc == 0) {
return Array();
+ }
Array r;
r.resize(rc);
for (int i = 0; i < rc; i++) {
-
Dictionary d;
d["rid"] = ret[i].rid;
d["collider_id"] = ret[i].collider_id;
@@ -362,41 +350,41 @@ Array PhysicsDirectSpaceState2D::_intersect_point_impl(const Vector2 &p_point, i
}
Array PhysicsDirectSpaceState2D::_intersect_point(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
return _intersect_point_impl(p_point, p_max_results, p_exclude, p_layers, p_collide_with_bodies, p_collide_with_areas);
}
Array PhysicsDirectSpaceState2D::_intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
return _intersect_point_impl(p_point, p_max_results, p_exclude, p_layers, p_collide_with_bodies, p_collide_with_areas, true, p_canvas_intance_id);
}
Array PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) {
-
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<Vector2> ret;
ret.resize(p_max_results * 2);
int rc = 0;
bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, ret.ptrw(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
- if (!res)
+ if (!res) {
return Array();
+ }
Array r;
r.resize(rc * 2);
- for (int i = 0; i < rc * 2; i++)
+ for (int i = 0; i < rc * 2; i++) {
r[i] = ret[i];
+ }
return r;
}
-Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
+Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary());
ShapeRestInfo sri;
bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
Dictionary r;
- if (!res)
+ if (!res) {
return r;
+ }
r["point"] = sri.point;
r["normal"] = sri.normal;
@@ -413,7 +401,6 @@ PhysicsDirectSpaceState2D::PhysicsDirectSpaceState2D() {
}
void PhysicsDirectSpaceState2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("intersect_point", "point", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
ClassDB::bind_method(D_METHOD("intersect_point_on_canvas", "point", "canvas_instance_id", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point_on_canvas, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
@@ -424,23 +411,22 @@ void PhysicsDirectSpaceState2D::_bind_methods() {
}
int PhysicsShapeQueryResult2D::get_result_count() const {
-
return result.size();
}
-RID PhysicsShapeQueryResult2D::get_result_rid(int p_idx) const {
+RID PhysicsShapeQueryResult2D::get_result_rid(int p_idx) const {
return result[p_idx].rid;
}
-ObjectID PhysicsShapeQueryResult2D::get_result_object_id(int p_idx) const {
+ObjectID PhysicsShapeQueryResult2D::get_result_object_id(int p_idx) const {
return result[p_idx].collider_id;
}
-Object *PhysicsShapeQueryResult2D::get_result_object(int p_idx) const {
+Object *PhysicsShapeQueryResult2D::get_result_object(int p_idx) const {
return result[p_idx].collider;
}
-int PhysicsShapeQueryResult2D::get_result_object_shape(int p_idx) const {
+int PhysicsShapeQueryResult2D::get_result_object_shape(int p_idx) const {
return result[p_idx].shape;
}
@@ -448,7 +434,6 @@ PhysicsShapeQueryResult2D::PhysicsShapeQueryResult2D() {
}
void PhysicsShapeQueryResult2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult2D::get_result_count);
ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult2D::get_result_rid);
ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult2D::get_result_object_id);
@@ -459,32 +444,30 @@ void PhysicsShapeQueryResult2D::_bind_methods() {
///////////////////////////////
Vector2 PhysicsTestMotionResult2D::get_motion() const {
-
return result.motion;
}
-Vector2 PhysicsTestMotionResult2D::get_motion_remainder() const {
+Vector2 PhysicsTestMotionResult2D::get_motion_remainder() const {
return result.remainder;
}
Vector2 PhysicsTestMotionResult2D::get_collision_point() const {
-
return result.collision_point;
}
-Vector2 PhysicsTestMotionResult2D::get_collision_normal() const {
+Vector2 PhysicsTestMotionResult2D::get_collision_normal() const {
return result.collision_normal;
}
-Vector2 PhysicsTestMotionResult2D::get_collider_velocity() const {
+Vector2 PhysicsTestMotionResult2D::get_collider_velocity() const {
return result.collider_velocity;
}
-ObjectID PhysicsTestMotionResult2D::get_collider_id() const {
+ObjectID PhysicsTestMotionResult2D::get_collider_id() const {
return result.collider_id;
}
-RID PhysicsTestMotionResult2D::get_collider_rid() const {
+RID PhysicsTestMotionResult2D::get_collider_rid() const {
return result.collider;
}
@@ -493,12 +476,10 @@ Object *PhysicsTestMotionResult2D::get_collider() const {
}
int PhysicsTestMotionResult2D::get_collider_shape() const {
-
return result.collider_shape;
}
void PhysicsTestMotionResult2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionResult2D::get_motion);
ClassDB::bind_method(D_METHOD("get_motion_remainder"), &PhysicsTestMotionResult2D::get_motion_remainder);
ClassDB::bind_method(D_METHOD("get_collision_point"), &PhysicsTestMotionResult2D::get_collision_point);
@@ -521,7 +502,6 @@ void PhysicsTestMotionResult2D::_bind_methods() {
}
PhysicsTestMotionResult2D::PhysicsTestMotionResult2D() {
-
colliding = false;
result.collider_shape = 0;
@@ -530,15 +510,14 @@ PhysicsTestMotionResult2D::PhysicsTestMotionResult2D() {
///////////////////////////////////////
bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) {
-
MotionResult *r = nullptr;
- if (p_result.is_valid())
+ if (p_result.is_valid()) {
r = p_result->get_result_ptr();
+ }
return body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r);
}
void PhysicsServer2D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("line_shape_create"), &PhysicsServer2D::line_shape_create);
ClassDB::bind_method(D_METHOD("ray_shape_create"), &PhysicsServer2D::ray_shape_create);
ClassDB::bind_method(D_METHOD("segment_shape_create"), &PhysicsServer2D::segment_shape_create);
@@ -675,8 +654,8 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("groove_joint_create", "groove1_a", "groove2_a", "anchor_b", "body_a", "body_b"), &PhysicsServer2D::groove_joint_create, DEFVAL(RID()), DEFVAL(RID()));
ClassDB::bind_method(D_METHOD("damped_spring_joint_create", "anchor_a", "anchor_b", "body_a", "body_b"), &PhysicsServer2D::damped_spring_joint_create, DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("damped_string_joint_set_param", "joint", "param", "value"), &PhysicsServer2D::damped_string_joint_set_param);
- ClassDB::bind_method(D_METHOD("damped_string_joint_get_param", "joint", "param"), &PhysicsServer2D::damped_string_joint_get_param);
+ ClassDB::bind_method(D_METHOD("damped_spring_joint_set_param", "joint", "param", "value"), &PhysicsServer2D::damped_spring_joint_set_param);
+ ClassDB::bind_method(D_METHOD("damped_spring_joint_get_param", "joint", "param"), &PhysicsServer2D::damped_spring_joint_get_param);
ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer2D::joint_get_type);
@@ -748,9 +727,9 @@ void PhysicsServer2D::_bind_methods() {
BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_BIAS);
BIND_ENUM_CONSTANT(JOINT_PARAM_MAX_FORCE);
- BIND_ENUM_CONSTANT(DAMPED_STRING_REST_LENGTH);
- BIND_ENUM_CONSTANT(DAMPED_STRING_STIFFNESS);
- BIND_ENUM_CONSTANT(DAMPED_STRING_DAMPING);
+ BIND_ENUM_CONSTANT(DAMPED_SPRING_REST_LENGTH);
+ BIND_ENUM_CONSTANT(DAMPED_SPRING_STIFFNESS);
+ BIND_ENUM_CONSTANT(DAMPED_SPRING_DAMPING);
BIND_ENUM_CONSTANT(CCD_MODE_DISABLED);
BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY);
@@ -765,12 +744,10 @@ void PhysicsServer2D::_bind_methods() {
}
PhysicsServer2D::PhysicsServer2D() {
-
singleton = this;
}
PhysicsServer2D::~PhysicsServer2D() {
-
singleton = nullptr;
}
@@ -780,7 +757,6 @@ int PhysicsServer2DManager::default_server_priority = -1;
const String PhysicsServer2DManager::setting_property_name("physics/2d/physics_engine");
void PhysicsServer2DManager::on_servers_changed() {
-
String physics_servers("DEFAULT");
for (int i = get_servers_count() - 1; 0 <= i; --i) {
physics_servers += "," + get_server_name(i);
@@ -789,7 +765,6 @@ void PhysicsServer2DManager::on_servers_changed() {
}
void PhysicsServer2DManager::register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback) {
-
ERR_FAIL_COND(!p_creat_callback);
ERR_FAIL_COND(find_server_id(p_name) != -1);
physics_2d_servers.push_back(ClassInfo(p_name, p_creat_callback));
@@ -797,7 +772,6 @@ void PhysicsServer2DManager::register_server(const String &p_name, CreatePhysics
}
void PhysicsServer2DManager::set_default_server(const String &p_name, int p_priority) {
-
const int id = find_server_id(p_name);
ERR_FAIL_COND(id == -1); // Not found
if (default_server_priority < p_priority) {
@@ -807,7 +781,6 @@ void PhysicsServer2DManager::set_default_server(const String &p_name, int p_prio
}
int PhysicsServer2DManager::find_server_id(const String &p_name) {
-
for (int i = physics_2d_servers.size() - 1; 0 <= i; --i) {
if (p_name == physics_2d_servers[i].name) {
return i;
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index 8c833b390f..549a78aa1f 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -38,7 +38,6 @@
class PhysicsDirectSpaceState2D;
class PhysicsDirectBodyState2D : public Object {
-
GDCLASS(PhysicsDirectBodyState2D, Object);
protected:
@@ -97,7 +96,6 @@ class PhysicsShapeQueryResult2D;
//used for script
class PhysicsShapeQueryParameters2D : public Reference {
-
GDCLASS(PhysicsShapeQueryParameters2D, Reference);
friend class PhysicsDirectSpaceState2D;
RID shape;
@@ -143,7 +141,6 @@ public:
};
class PhysicsDirectSpaceState2D : public Object {
-
GDCLASS(PhysicsDirectSpaceState2D, Object);
Dictionary _intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
@@ -160,7 +157,6 @@ protected:
public:
struct RayResult {
-
Vector2 position;
Vector2 normal;
RID rid;
@@ -173,7 +169,6 @@ public:
virtual bool intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
struct ShapeResult {
-
RID rid;
ObjectID collider_id;
Object *collider;
@@ -191,7 +186,6 @@ public:
virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, float p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
struct ShapeRestInfo {
-
Vector2 point;
Vector2 normal;
RID rid;
@@ -207,7 +201,6 @@ public:
};
class PhysicsShapeQueryResult2D : public Reference {
-
GDCLASS(PhysicsShapeQueryResult2D, Reference);
Vector<PhysicsDirectSpaceState2D::ShapeResult> result;
@@ -230,7 +223,6 @@ public:
class PhysicsTestMotionResult2D;
class PhysicsServer2D : public Object {
-
GDCLASS(PhysicsServer2D, Object);
static PhysicsServer2D *singleton;
@@ -493,7 +485,6 @@ public:
virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) = 0;
struct MotionResult {
-
Vector2 motion;
Vector2 remainder;
@@ -516,7 +507,6 @@ public:
virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0;
struct SeparationResult {
-
float collision_depth;
Vector2 collision_point;
Vector2 collision_normal;
@@ -562,13 +552,13 @@ public:
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) = 0;
virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
- enum DampedStringParam {
- DAMPED_STRING_REST_LENGTH,
- DAMPED_STRING_STIFFNESS,
- DAMPED_STRING_DAMPING
+ enum DampedSpringParam {
+ DAMPED_SPRING_REST_LENGTH,
+ DAMPED_SPRING_STIFFNESS,
+ DAMPED_SPRING_DAMPING
};
- virtual void damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) = 0;
- virtual real_t damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const = 0;
+ virtual void damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) = 0;
+ virtual real_t damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const = 0;
virtual JointType joint_get_type(RID p_joint) const = 0;
@@ -607,7 +597,6 @@ public:
};
class PhysicsTestMotionResult2D : public Reference {
-
GDCLASS(PhysicsTestMotionResult2D, Reference);
PhysicsServer2D::MotionResult result;
@@ -640,11 +629,9 @@ typedef PhysicsServer2D *(*CreatePhysicsServer2DCallback)();
class PhysicsServer2DManager {
struct ClassInfo {
String name;
- CreatePhysicsServer2DCallback create_callback;
+ CreatePhysicsServer2DCallback create_callback = nullptr;
- ClassInfo() :
- name(""),
- create_callback(nullptr) {}
+ ClassInfo() {}
ClassInfo(String p_name, CreatePhysicsServer2DCallback p_create_callback) :
name(p_name),
@@ -691,7 +678,7 @@ VARIANT_ENUM_CAST(PhysicsServer2D::BodyState);
VARIANT_ENUM_CAST(PhysicsServer2D::CCDMode);
VARIANT_ENUM_CAST(PhysicsServer2D::JointParam);
VARIANT_ENUM_CAST(PhysicsServer2D::JointType);
-VARIANT_ENUM_CAST(PhysicsServer2D::DampedStringParam);
+VARIANT_ENUM_CAST(PhysicsServer2D::DampedSpringParam);
//VARIANT_ENUM_CAST( PhysicsServer2D::ObjectType );
VARIANT_ENUM_CAST(PhysicsServer2D::AreaBodyStatus);
VARIANT_ENUM_CAST(PhysicsServer2D::ProcessInfo);
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp
index a5a02fd1bd..2dd8ea3edb 100644
--- a/servers/physics_server_3d.cpp
+++ b/servers/physics_server_3d.cpp
@@ -37,7 +37,6 @@
PhysicsServer3D *PhysicsServer3D::singleton = nullptr;
void PhysicsDirectBodyState3D::integrate_forces() {
-
real_t step = get_step();
Vector3 lv = get_linear_velocity();
lv += get_total_gravity() * step;
@@ -46,13 +45,15 @@ void PhysicsDirectBodyState3D::integrate_forces() {
float linear_damp = 1.0 - step * get_total_linear_damp();
- if (linear_damp < 0) // reached zero in the given time
+ if (linear_damp < 0) { // reached zero in the given time
linear_damp = 0;
+ }
float angular_damp = 1.0 - step * get_total_angular_damp();
- if (angular_damp < 0) // reached zero in the given time
+ if (angular_damp < 0) { // reached zero in the given time
angular_damp = 0;
+ }
lv *= linear_damp;
av *= angular_damp;
@@ -62,19 +63,16 @@ void PhysicsDirectBodyState3D::integrate_forces() {
}
Object *PhysicsDirectBodyState3D::get_contact_collider_object(int p_contact_idx) const {
-
ObjectID objid = get_contact_collider_id(p_contact_idx);
Object *obj = ObjectDB::get_instance(objid);
return obj;
}
PhysicsServer3D *PhysicsServer3D::get_singleton() {
-
return singleton;
}
void PhysicsDirectBodyState3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState3D::get_total_gravity);
ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState3D::get_total_linear_damp);
ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp);
@@ -139,58 +137,50 @@ PhysicsDirectBodyState3D::PhysicsDirectBodyState3D() {}
///////////////////////////////////////////////////////
void PhysicsShapeQueryParameters3D::set_shape(const RES &p_shape) {
-
ERR_FAIL_COND(p_shape.is_null());
shape = p_shape->get_rid();
}
void PhysicsShapeQueryParameters3D::set_shape_rid(const RID &p_shape) {
-
shape = p_shape;
}
RID PhysicsShapeQueryParameters3D::get_shape_rid() const {
-
return shape;
}
void PhysicsShapeQueryParameters3D::set_transform(const Transform &p_transform) {
-
transform = p_transform;
}
-Transform PhysicsShapeQueryParameters3D::get_transform() const {
+Transform PhysicsShapeQueryParameters3D::get_transform() const {
return transform;
}
void PhysicsShapeQueryParameters3D::set_margin(float p_margin) {
-
margin = p_margin;
}
float PhysicsShapeQueryParameters3D::get_margin() const {
-
return margin;
}
void PhysicsShapeQueryParameters3D::set_collision_mask(int p_collision_mask) {
-
collision_mask = p_collision_mask;
}
-int PhysicsShapeQueryParameters3D::get_collision_mask() const {
+int PhysicsShapeQueryParameters3D::get_collision_mask() const {
return collision_mask;
}
void PhysicsShapeQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) {
-
exclude.clear();
- for (int i = 0; i < p_exclude.size(); i++)
+ for (int i = 0; i < p_exclude.size(); i++) {
exclude.insert(p_exclude[i]);
+ }
}
Vector<RID> PhysicsShapeQueryParameters3D::get_exclude() const {
-
Vector<RID> ret;
ret.resize(exclude.size());
int idx = 0;
@@ -217,7 +207,6 @@ bool PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled() const {
}
void PhysicsShapeQueryParameters3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters3D::set_shape);
ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters3D::set_shape_rid);
ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters3D::get_shape_rid);
@@ -251,7 +240,6 @@ void PhysicsShapeQueryParameters3D::_bind_methods() {
}
PhysicsShapeQueryParameters3D::PhysicsShapeQueryParameters3D() {
-
margin = 0;
collision_mask = 0x7FFFFFFF;
collide_with_bodies = true;
@@ -261,16 +249,17 @@ PhysicsShapeQueryParameters3D::PhysicsShapeQueryParameters3D() {
/////////////////////////////////////
Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
-
RayResult inters;
Set<RID> exclude;
- for (int i = 0; i < p_exclude.size(); i++)
+ for (int i = 0; i < p_exclude.size(); i++) {
exclude.insert(p_exclude[i]);
+ }
bool res = intersect_ray(p_from, p_to, inters, exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas);
- if (!res)
+ if (!res) {
return Dictionary();
+ }
Dictionary d;
d["position"] = inters.position;
@@ -284,7 +273,6 @@ Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Vector3 &p_from, cons
}
Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
-
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<ShapeResult> sr;
@@ -293,7 +281,6 @@ Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryPar
Array ret;
ret.resize(rc);
for (int i = 0; i < rc; i++) {
-
Dictionary d;
d["rid"] = sr[i].rid;
d["collider_id"] = sr[i].collider_id;
@@ -306,45 +293,48 @@ Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryPar
}
Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, const Vector3 &p_motion) {
-
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
float closest_safe, closest_unsafe;
bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
- if (!res)
+ if (!res) {
return Array();
+ }
Array ret;
ret.resize(2);
ret[0] = closest_safe;
ret[1] = closest_unsafe;
return ret;
}
-Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
+Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array());
Vector<Vector3> ret;
ret.resize(p_max_results * 2);
int rc = 0;
bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, ret.ptrw(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
- if (!res)
+ if (!res) {
return Array();
+ }
Array r;
r.resize(rc * 2);
- for (int i = 0; i < rc * 2; i++)
+ for (int i = 0; i < rc * 2; i++) {
r[i] = ret[i];
+ }
return r;
}
-Dictionary PhysicsDirectSpaceState3D::_get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
+Dictionary PhysicsDirectSpaceState3D::_get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) {
ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary());
ShapeRestInfo sri;
bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas);
Dictionary r;
- if (!res)
+ if (!res) {
return r;
+ }
r["point"] = sri.point;
r["normal"] = sri.normal;
@@ -360,7 +350,6 @@ PhysicsDirectSpaceState3D::PhysicsDirectSpaceState3D() {
}
void PhysicsDirectSpaceState3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_mask", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState3D::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));
ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState3D::_intersect_shape, DEFVAL(32));
ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState3D::_cast_motion);
@@ -369,23 +358,22 @@ void PhysicsDirectSpaceState3D::_bind_methods() {
}
int PhysicsShapeQueryResult3D::get_result_count() const {
-
return result.size();
}
-RID PhysicsShapeQueryResult3D::get_result_rid(int p_idx) const {
+RID PhysicsShapeQueryResult3D::get_result_rid(int p_idx) const {
return result[p_idx].rid;
}
-ObjectID PhysicsShapeQueryResult3D::get_result_object_id(int p_idx) const {
+ObjectID PhysicsShapeQueryResult3D::get_result_object_id(int p_idx) const {
return result[p_idx].collider_id;
}
-Object *PhysicsShapeQueryResult3D::get_result_object(int p_idx) const {
+Object *PhysicsShapeQueryResult3D::get_result_object(int p_idx) const {
return result[p_idx].collider;
}
-int PhysicsShapeQueryResult3D::get_result_object_shape(int p_idx) const {
+int PhysicsShapeQueryResult3D::get_result_object_shape(int p_idx) const {
return result[p_idx].shape;
}
@@ -393,7 +381,6 @@ PhysicsShapeQueryResult3D::PhysicsShapeQueryResult3D() {
}
void PhysicsShapeQueryResult3D::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult3D::get_result_count);
ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult3D::get_result_rid);
ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult3D::get_result_object_id);
@@ -404,7 +391,6 @@ void PhysicsShapeQueryResult3D::_bind_methods() {
///////////////////////////////////////
void PhysicsServer3D::_bind_methods() {
-
#ifndef _3D_DISABLED
ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer3D::shape_create);
@@ -724,13 +710,11 @@ void PhysicsServer3D::_bind_methods() {
}
PhysicsServer3D::PhysicsServer3D() {
-
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
}
PhysicsServer3D::~PhysicsServer3D() {
-
singleton = nullptr;
}
@@ -740,7 +724,6 @@ int PhysicsServer3DManager::default_server_priority = -1;
const String PhysicsServer3DManager::setting_property_name("physics/3d/physics_engine");
void PhysicsServer3DManager::on_servers_changed() {
-
String physics_servers2("DEFAULT");
for (int i = get_servers_count() - 1; 0 <= i; --i) {
physics_servers2 += "," + get_server_name(i);
@@ -749,7 +732,6 @@ void PhysicsServer3DManager::on_servers_changed() {
}
void PhysicsServer3DManager::register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback) {
-
ERR_FAIL_COND(!p_creat_callback);
ERR_FAIL_COND(find_server_id(p_name) != -1);
physics_servers.push_back(ClassInfo(p_name, p_creat_callback));
@@ -757,7 +739,6 @@ void PhysicsServer3DManager::register_server(const String &p_name, CreatePhysics
}
void PhysicsServer3DManager::set_default_server(const String &p_name, int p_priority) {
-
const int id = find_server_id(p_name);
ERR_FAIL_COND(id == -1); // Not found
if (default_server_priority < p_priority) {
@@ -767,7 +748,6 @@ void PhysicsServer3DManager::set_default_server(const String &p_name, int p_prio
}
int PhysicsServer3DManager::find_server_id(const String &p_name) {
-
for (int i = physics_servers.size() - 1; 0 <= i; --i) {
if (p_name == physics_servers[i].name) {
return i;
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h
index 8ea8b22455..2465b40d3e 100644
--- a/servers/physics_server_3d.h
+++ b/servers/physics_server_3d.h
@@ -37,7 +37,6 @@
class PhysicsDirectSpaceState3D;
class PhysicsDirectBodyState3D : public Object {
-
GDCLASS(PhysicsDirectBodyState3D, Object);
protected:
@@ -98,7 +97,6 @@ public:
class PhysicsShapeQueryResult3D;
class PhysicsShapeQueryParameters3D : public Reference {
-
GDCLASS(PhysicsShapeQueryParameters3D, Reference);
friend class PhysicsDirectSpaceState3D;
@@ -141,7 +139,6 @@ public:
};
class PhysicsDirectSpaceState3D : public Object {
-
GDCLASS(PhysicsDirectSpaceState3D, Object);
private:
@@ -156,7 +153,6 @@ protected:
public:
struct ShapeResult {
-
RID rid;
ObjectID collider_id;
Object *collider;
@@ -166,7 +162,6 @@ public:
virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
struct RayResult {
-
Vector3 position;
Vector3 normal;
RID rid;
@@ -180,7 +175,6 @@ public:
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0;
struct ShapeRestInfo {
-
Vector3 point;
Vector3 normal;
RID rid;
@@ -201,7 +195,6 @@ public:
};
class PhysicsShapeQueryResult3D : public Reference {
-
GDCLASS(PhysicsShapeQueryResult3D, Reference);
Vector<PhysicsDirectSpaceState3D::ShapeResult> result;
@@ -222,7 +215,6 @@ public:
};
class PhysicsServer3D : public Object {
-
GDCLASS(PhysicsServer3D, Object);
static PhysicsServer3D *singleton;
@@ -481,7 +473,6 @@ public:
virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) = 0;
struct MotionResult {
-
Vector3 motion;
Vector3 remainder;
@@ -503,7 +494,6 @@ public:
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0;
struct SeparationResult {
-
float collision_depth;
Vector3 collision_point;
Vector3 collision_normal;
@@ -781,11 +771,9 @@ typedef PhysicsServer3D *(*CreatePhysicsServer3DCallback)();
class PhysicsServer3DManager {
struct ClassInfo {
String name;
- CreatePhysicsServer3DCallback create_callback;
+ CreatePhysicsServer3DCallback create_callback = nullptr;
- ClassInfo() :
- name(""),
- create_callback(nullptr) {}
+ ClassInfo() {}
ClassInfo(String p_name, CreatePhysicsServer3DCallback p_create_callback) :
name(p_name),
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 60217002fb..adca7b8055 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -83,7 +83,6 @@ PhysicsServer2D *_createGodotPhysics2DCallback() {
}
static bool has_server_feature_callback(const String &p_feature) {
-
if (RenderingServer::get_singleton()) {
if (RenderingServer::get_singleton()->has_os_feature(p_feature)) {
return true;
@@ -98,7 +97,6 @@ void preregister_server_types() {
}
void register_server_types() {
-
OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
ClassDB::register_virtual_class<DisplayServer>();
@@ -210,12 +208,10 @@ void register_server_types() {
}
void unregister_server_types() {
-
memdelete(shader_types);
}
void register_server_singletons() {
-
Engine::get_singleton()->add_singleton(Engine::Singleton("DisplayServer", DisplayServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton()));
Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton()));
diff --git a/servers/rendering/rasterizer.cpp b/servers/rendering/rasterizer.cpp
index f62e0a43a6..566a14b655 100644
--- a/servers/rendering/rasterizer.cpp
+++ b/servers/rendering/rasterizer.cpp
@@ -40,6 +40,7 @@ void RasterizerScene::InstanceDependency::instance_notify_changed(bool p_aabb, b
E->key()->dependency_changed(p_aabb, p_dependencies);
}
}
+
void RasterizerScene::InstanceDependency::instance_notify_deleted(RID p_deleted) {
for (Map<InstanceBase *, uint32_t>::Element *E = instances.front(); E; E = E->next()) {
E->key()->dependency_deleted(p_deleted);
@@ -63,7 +64,6 @@ RasterizerScene::InstanceDependency::~InstanceDependency() {
}
Rasterizer *Rasterizer::create() {
-
return _create_func();
}
@@ -72,6 +72,5 @@ RasterizerCanvas *RasterizerCanvas::singleton = nullptr;
RasterizerStorage *RasterizerStorage::base_singleton = nullptr;
RasterizerStorage::RasterizerStorage() {
-
base_singleton = this;
}
diff --git a/servers/rendering/rasterizer.h b/servers/rendering/rasterizer.h
index 48ee6e02d0..026725bf01 100644
--- a/servers/rendering/rasterizer.h
+++ b/servers/rendering/rasterizer.h
@@ -38,7 +38,6 @@
#include "core/self_list.h"
class RasterizerScene {
-
public:
/* SHADOW ATLAS API */
@@ -227,7 +226,6 @@ public:
InstanceBase() :
dependency_item(this) {
-
base_type = RS::INSTANCE_NONE;
cast_shadows = RS::SHADOW_CASTING_SETTING_ON;
receive_shadows = true;
@@ -302,7 +300,6 @@ public:
};
class RasterizerStorage {
-
Color default_clear_color;
public:
@@ -763,7 +760,6 @@ public:
};
struct Light {
-
bool enabled;
Color color;
Transform2D xform;
@@ -818,7 +814,7 @@ public:
item_mask = 1;
scale = 1.0;
energy = 1.0;
- item_shadow_mask = -1;
+ item_shadow_mask = 1;
mode = RS::CANVAS_LIGHT_MODE_ADD;
// texture_cache = nullptr;
next_ptr = nullptr;
@@ -842,7 +838,6 @@ public:
struct Item;
struct TextureBinding {
-
TextureBindingID binding_id;
_FORCE_INLINE_ void create(RS::CanvasItemTextureFilter p_item_filter, RS::CanvasItemTextureRepeat p_item_repeat, RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
@@ -860,8 +855,9 @@ public:
_FORCE_INLINE_ TextureBinding() { binding_id = 0; }
_FORCE_INLINE_ ~TextureBinding() {
- if (binding_id)
+ if (binding_id) {
singleton->free_texture_binding(binding_id);
+ }
}
};
@@ -871,7 +867,6 @@ public:
//also easier to wrap to avoid mistakes
struct Polygon {
-
PolygonID polygon_id;
Rect2 rect_cache;
@@ -890,15 +885,15 @@ public:
_FORCE_INLINE_ Polygon() { polygon_id = 0; }
_FORCE_INLINE_ ~Polygon() {
- if (polygon_id)
+ if (polygon_id) {
singleton->free_polygon(polygon_id);
+ }
}
};
//item
struct Item {
-
//commands are allocated in blocks of 4k to improve performance
//and cache coherence.
//blocks always grow but never shrink.
@@ -912,7 +907,6 @@ public:
};
struct Command {
-
enum Type {
TYPE_RECT,
@@ -932,7 +926,6 @@ public:
};
struct CommandRect : public Command {
-
Rect2 rect;
Color modulate;
Rect2 source;
@@ -948,7 +941,6 @@ public:
};
struct CommandNinePatch : public Command {
-
Rect2 rect;
Rect2 source;
float margin[4];
@@ -965,7 +957,6 @@ public:
};
struct CommandPolygon : public Command {
-
RS::PrimitiveType primitive;
Polygon polygon;
Color specular_shininess;
@@ -976,7 +967,6 @@ public:
};
struct CommandPrimitive : public Command {
-
uint32_t point_count;
Vector2 points[4];
Vector2 uvs[4];
@@ -989,7 +979,6 @@ public:
};
struct CommandMesh : public Command {
-
RID mesh;
Transform2D transform;
Color modulate;
@@ -999,7 +988,6 @@ public:
};
struct CommandMultiMesh : public Command {
-
RID multimesh;
Color specular_shininess;
TextureBinding texture_binding;
@@ -1007,7 +995,6 @@ public:
};
struct CommandParticles : public Command {
-
RID particles;
Color specular_shininess;
TextureBinding texture_binding;
@@ -1015,13 +1002,11 @@ public:
};
struct CommandTransform : public Command {
-
Transform2D xform;
CommandTransform() { type = TYPE_TRANSFORM; }
};
struct CommandClipIgnore : public Command {
-
bool ignore;
CommandClipIgnore() {
type = TYPE_CLIP_IGNORE;
@@ -1071,13 +1056,13 @@ public:
Rect2 global_rect_cache;
const Rect2 &get_rect() const {
- if (custom_rect || (!rect_dirty && !update_when_visible))
+ if (custom_rect || (!rect_dirty && !update_when_visible)) {
return rect;
+ }
//must update rect
if (commands == nullptr) {
-
rect = Rect2();
rect_dirty = false;
return rect;
@@ -1090,29 +1075,24 @@ public:
const Item::Command *c = commands;
while (c) {
-
Rect2 r;
switch (c->type) {
case Item::Command::TYPE_RECT: {
-
const Item::CommandRect *crect = static_cast<const Item::CommandRect *>(c);
r = crect->rect;
} break;
case Item::Command::TYPE_NINEPATCH: {
-
const Item::CommandNinePatch *style = static_cast<const Item::CommandNinePatch *>(c);
r = style->rect;
} break;
case Item::Command::TYPE_POLYGON: {
-
const Item::CommandPolygon *polygon = static_cast<const Item::CommandPolygon *>(c);
r = polygon->polygon.rect_cache;
} break;
case Item::Command::TYPE_PRIMITIVE: {
-
const Item::CommandPrimitive *primitive = static_cast<const Item::CommandPrimitive *>(c);
for (uint32_t j = 0; j < primitive->point_count; j++) {
if (j == 0) {
@@ -1123,7 +1103,6 @@ public:
}
} break;
case Item::Command::TYPE_MESH: {
-
const Item::CommandMesh *mesh = static_cast<const Item::CommandMesh *>(c);
AABB aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, RID());
@@ -1131,7 +1110,6 @@ public:
} break;
case Item::Command::TYPE_MULTIMESH: {
-
const Item::CommandMultiMesh *multimesh = static_cast<const Item::CommandMultiMesh *>(c);
AABB aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh);
@@ -1139,7 +1117,6 @@ public:
} break;
case Item::Command::TYPE_PARTICLES: {
-
const Item::CommandParticles *particles_cmd = static_cast<const Item::CommandParticles *>(c);
if (particles_cmd->particles.is_valid()) {
AABB aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles);
@@ -1148,7 +1125,6 @@ public:
} break;
case Item::Command::TYPE_TRANSFORM: {
-
const Item::CommandTransform *transform = static_cast<const Item::CommandTransform *>(c);
xf = transform->xform;
found_xform = true;
@@ -1231,7 +1207,6 @@ public:
}
struct CustomData {
-
virtual ~CustomData() {}
};
@@ -1293,8 +1268,9 @@ public:
for (int i = 0; i < blocks.size(); i++) {
memfree(blocks[i].memory);
}
- if (copy_back_buffer)
+ if (copy_back_buffer) {
memdelete(copy_back_buffer);
+ }
if (custom_data) {
memdelete(custom_data);
}
@@ -1305,7 +1281,6 @@ public:
virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) = 0;
struct LightOccluderInstance {
-
bool enabled;
RID canvas;
RID polygon;
diff --git a/servers/rendering/rasterizer_rd/light_cluster_builder.cpp b/servers/rendering/rasterizer_rd/light_cluster_builder.cpp
index f75308a975..efb48e6df7 100644
--- a/servers/rendering/rasterizer_rd/light_cluster_builder.cpp
+++ b/servers/rendering/rasterizer_rd/light_cluster_builder.cpp
@@ -45,7 +45,6 @@ void LightClusterBuilder::begin(const Transform &p_view_transform, const CameraM
}
void LightClusterBuilder::bake_cluster() {
-
float slice_depth = (z_near - z_far) / depth;
uint8_t *cluster_dataw = cluster_data.ptrw();
@@ -56,7 +55,6 @@ void LightClusterBuilder::bake_cluster() {
/* Step 1, create cell positions and count them */
for (uint32_t i = 0; i < item_count; i++) {
-
const Item &item = items[i];
int from_slice = Math::floor((z_near - (item.aabb.position.z + item.aabb.size.z)) / slice_depth);
@@ -70,7 +68,6 @@ void LightClusterBuilder::bake_cluster() {
to_slice = MIN((int)depth - 1, to_slice);
for (int j = from_slice; j <= to_slice; j++) {
-
Vector3 min = item.aabb.position;
Vector3 max = item.aabb.position + item.aabb.size;
@@ -126,7 +123,6 @@ void LightClusterBuilder::bake_cluster() {
sort_id_max = nearest_power_of_2_templated(sort_id_max + 1);
sort_ids = (SortID *)memrealloc(sort_ids, sizeof(SortID) * sort_id_max);
if (ids.size()) {
-
ids.resize(sort_id_max);
RD::get_singleton()->free(items_buffer);
items_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * sort_id_max);
@@ -178,7 +174,6 @@ void LightClusterBuilder::bake_cluster() {
}
void LightClusterBuilder::setup(uint32_t p_width, uint32_t p_height, uint32_t p_depth) {
-
if (width == p_width && height == p_height && depth == p_depth) {
return;
}
@@ -208,6 +203,7 @@ void LightClusterBuilder::setup(uint32_t p_width, uint32_t p_height, uint32_t p_
RID LightClusterBuilder::get_cluster_texture() const {
return cluster_texture;
}
+
RID LightClusterBuilder::get_cluster_indices_buffer() const {
return items_buffer;
}
@@ -231,8 +227,8 @@ LightClusterBuilder::LightClusterBuilder() {
items_buffer = RD::get_singleton()->storage_buffer_create(sizeof(uint32_t) * 1024);
item_max = 1024;
}
-LightClusterBuilder::~LightClusterBuilder() {
+LightClusterBuilder::~LightClusterBuilder() {
if (cluster_data.size()) {
RD::get_singleton()->free(cluster_texture);
}
diff --git a/servers/rendering/rasterizer_rd/light_cluster_builder.h b/servers/rendering/rasterizer_rd/light_cluster_builder.h
index 78288dc620..b1da083dad 100644
--- a/servers/rendering/rasterizer_rd/light_cluster_builder.h
+++ b/servers/rendering/rasterizer_rd/light_cluster_builder.h
@@ -170,7 +170,6 @@ public:
_add_item(aabb, ITEM_TYPE_OMNI_LIGHT, light_count);
} break;
case LIGHT_TYPE_SPOT: {
-
float r = ld.radius;
real_t len = Math::tan(Math::deg2rad(ld.spot_aperture)) * r;
@@ -187,7 +186,6 @@ public:
}
_FORCE_INLINE_ void add_reflection_probe(const Transform &p_transform, const Vector3 &p_half_extents) {
-
if (unlikely(refprobe_count == refprobe_max)) {
refprobe_max = nearest_power_of_2_templated(refprobe_max + 1);
refprobes = (OrientedBoxData *)memrealloc(refprobes, sizeof(OrientedBoxData) * refprobe_max);
@@ -233,7 +231,6 @@ public:
}
_FORCE_INLINE_ void add_decal(const Transform &p_transform, const Vector3 &p_half_extents) {
-
if (unlikely(decal_count == decal_max)) {
decal_max = nearest_power_of_2_templated(decal_max + 1);
decals = (OrientedBoxData *)memrealloc(decals, sizeof(OrientedBoxData) * decal_max);
diff --git a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp
index 3505b18c8a..4c477ca5f4 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp
@@ -34,7 +34,6 @@
#include "rasterizer_rd.h"
void RasterizerCanvasRD::_update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4) {
-
p_mat4[0] = p_transform.elements[0][0];
p_mat4[1] = p_transform.elements[0][1];
p_mat4[2] = 0;
@@ -54,7 +53,6 @@ void RasterizerCanvasRD::_update_transform_2d_to_mat4(const Transform2D &p_trans
}
void RasterizerCanvasRD::_update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4) {
-
p_mat2x4[0] = p_transform.elements[0][0];
p_mat2x4[1] = p_transform.elements[1][0];
p_mat2x4[2] = 0;
@@ -67,7 +65,6 @@ void RasterizerCanvasRD::_update_transform_2d_to_mat2x4(const Transform2D &p_tra
}
void RasterizerCanvasRD::_update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3) {
-
p_mat2x3[0] = p_transform.elements[0][0];
p_mat2x3[1] = p_transform.elements[0][1];
p_mat2x3[2] = p_transform.elements[1][0];
@@ -77,7 +74,6 @@ void RasterizerCanvasRD::_update_transform_2d_to_mat2x3(const Transform2D &p_tra
}
void RasterizerCanvasRD::_update_transform_to_mat4(const Transform &p_transform, float *p_mat4) {
-
p_mat4[0] = p_transform.basis.elements[0][0];
p_mat4[1] = p_transform.basis.elements[1][0];
p_mat4[2] = p_transform.basis.elements[2][0];
@@ -97,7 +93,6 @@ void RasterizerCanvasRD::_update_transform_to_mat4(const Transform &p_transform,
}
void RasterizerCanvasRD::_update_specular_shininess(const Color &p_transform, uint32_t *r_ss) {
-
*r_ss = uint32_t(CLAMP(p_transform.a * 255.0, 0, 255)) << 24;
*r_ss |= uint32_t(CLAMP(p_transform.b * 255.0, 0, 255)) << 16;
*r_ss |= uint32_t(CLAMP(p_transform.g * 255.0, 0, 255)) << 8;
@@ -105,7 +100,6 @@ void RasterizerCanvasRD::_update_specular_shininess(const Color &p_transform, ui
}
RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
-
Vector<RD::Uniform> uniform_set;
{ // COLOR TEXTURE
@@ -169,7 +163,6 @@ RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap,
}
RasterizerCanvas::TextureBindingID RasterizerCanvasRD::request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
-
if (p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) {
p_filter = default_samplers.default_filter;
}
@@ -221,7 +214,6 @@ RasterizerCanvas::TextureBindingID RasterizerCanvasRD::request_texture_binding(R
}
void RasterizerCanvasRD::free_texture_binding(TextureBindingID p_binding) {
-
TextureBinding **binding_ptr = bindings.texture_bindings.getptr(p_binding);
ERR_FAIL_COND(!binding_ptr);
TextureBinding *binding = *binding_ptr;
@@ -233,7 +225,6 @@ void RasterizerCanvasRD::free_texture_binding(TextureBindingID p_binding) {
}
void RasterizerCanvasRD::_dispose_bindings() {
-
while (bindings.to_dispose_list.first()) {
TextureBinding *binding = bindings.to_dispose_list.first()->self();
if (binding->uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(binding->uniform_set)) {
@@ -248,7 +239,6 @@ void RasterizerCanvasRD::_dispose_bindings() {
}
RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights) {
-
// Care must be taken to generate array formats
// in ways where they could be reused, so we will
// put single-occuring elements first, and repeated
@@ -384,7 +374,6 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
const float *weight_ptr = p_weights.ptr();
for (uint32_t i = 0; i < vertex_count; i++) {
-
uint16_t *bone16w = (uint16_t *)&uptr[base_offset + i * stride];
uint16_t *weight16w = (uint16_t *)&uptr[base_offset + i * stride + 2];
@@ -450,7 +439,6 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int
}
void RasterizerCanvasRD::free_polygon(PolygonID p_polygon) {
-
PolygonBuffers *pb_ptr = polygon_buffers.polygons.getptr(p_polygon);
ERR_FAIL_COND(!pb_ptr);
@@ -470,7 +458,6 @@ void RasterizerCanvasRD::free_polygon(PolygonID p_polygon) {
}
Size2i RasterizerCanvasRD::_bind_texture_binding(TextureBindingID p_binding, RD::DrawListID p_draw_list, uint32_t &flags) {
-
TextureBinding **texture_binding_ptr = bindings.texture_bindings.getptr(p_binding);
ERR_FAIL_COND_V(!texture_binding_ptr, Size2i());
TextureBinding *texture_binding = *texture_binding_ptr;
@@ -498,7 +485,6 @@ Size2i RasterizerCanvasRD::_bind_texture_binding(TextureBindingID p_binding, RD:
////////////////////
void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_item, RD::FramebufferFormatID p_framebuffer_format, const Transform2D &p_canvas_transform_inverse, Item *&current_clip, Light *p_lights, PipelineVariants *p_pipeline_variants) {
-
//create an empty push constant
PushConstant push_constant;
@@ -541,13 +527,10 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
PipelineLightMode light_mode;
{
-
Light *light = p_lights;
while (light) {
-
if (light->render_index_cache >= 0 && p_item->light_mask & light->item_mask && p_item->z_final >= light->z_min && p_item->z_final <= light->z_max && p_item->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) {
-
uint32_t light_index = light->render_index_cache;
push_constant.lights[light_count >> 2] |= light_index << ((light_count & 3) * 8);
@@ -575,7 +558,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
}
{
-
RID &canvas_item_state = light_count ? state_data->state_uniform_set_with_light : state_data->state_uniform_set;
bool invalid_uniform = canvas_item_state.is_valid() && !RD::get_singleton()->uniform_set_is_valid(canvas_item_state);
@@ -640,7 +622,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
}
{
-
RD::Uniform u_lights;
u_lights.type = RD::UNIFORM_TYPE_TEXTURE;
u_lights.binding = 4;
@@ -652,7 +633,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
//lights
for (uint32_t i = 0; i < state.max_lights_per_item; i++) {
if (i < light_count) {
-
CanvasLight *cl = canvas_light_owner.getornull(light_cache[i]->light_internal);
ERR_CONTINUE(!cl);
@@ -711,7 +691,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
switch (c->type) {
case Item::Command::TYPE_RECT: {
-
const Item::CommandRect *rect = static_cast<const Item::CommandRect *>(c);
//bind pipeline
@@ -811,7 +790,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
} break;
case Item::Command::TYPE_NINEPATCH: {
-
const Item::CommandNinePatch *np = static_cast<const Item::CommandNinePatch *>(c);
//bind pipeline
@@ -839,12 +817,10 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
Rect2 dst_rect(np->rect.position.x, np->rect.position.y, np->rect.size.x, np->rect.size.y);
if (texpixel_size == Size2()) {
-
texpixel_size = Size2(1, 1);
src_rect = Rect2(0, 0, 1, 1);
} else {
-
if (np->source != Rect2()) {
src_rect = Rect2(np->source.position.x * texpixel_size.width, np->source.position.y * texpixel_size.height, np->source.size.x * texpixel_size.width, np->source.size.y * texpixel_size.height);
texpixel_size = Size2(1.0 / np->source.size.width, 1.0 / np->source.size.height);
@@ -889,7 +865,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
} break;
case Item::Command::TYPE_POLYGON: {
-
const Item::CommandPolygon *polygon = static_cast<const Item::CommandPolygon *>(c);
PolygonBuffers *pb = polygon_buffers.polygons.getptr(polygon->polygon.polygon_id);
@@ -945,7 +920,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
} break;
case Item::Command::TYPE_PRIMITIVE: {
-
const Item::CommandPrimitive *primitive = static_cast<const Item::CommandPrimitive *>(c);
//bind pipeline
@@ -1291,23 +1265,18 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
} break;
#endif
case Item::Command::TYPE_TRANSFORM: {
-
const Item::CommandTransform *transform = static_cast<const Item::CommandTransform *>(c);
_update_transform_2d_to_mat2x3(base_transform * transform->xform, push_constant.world);
} break;
case Item::Command::TYPE_CLIP_IGNORE: {
-
const Item::CommandClipIgnore *ci = static_cast<const Item::CommandClipIgnore *>(c);
if (current_clip) {
-
if (ci->ignore != reclip) {
-
if (ci->ignore) {
RD::get_singleton()->draw_list_disable_scissor(p_draw_list);
reclip = true;
} else {
-
RD::get_singleton()->draw_list_enable_scissor(p_draw_list, current_clip->final_clip_rect);
reclip = false;
}
@@ -1327,7 +1296,6 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_
}
void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, RID p_screen_uniform_set) {
-
Item *current_clip = nullptr;
Transform2D canvas_transform_inverse = p_canvas_transform_inverse;
@@ -1357,33 +1325,27 @@ void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count,
PipelineVariants *pipeline_variants = &shader.pipeline_variants;
for (int i = 0; i < p_item_count; i++) {
-
Item *ci = items[i];
if (current_clip != ci->final_clip_owner) {
-
current_clip = ci->final_clip_owner;
//setup clip
if (current_clip) {
-
RD::get_singleton()->draw_list_enable_scissor(draw_list, current_clip->final_clip_rect);
} else {
-
RD::get_singleton()->draw_list_disable_scissor(draw_list);
}
}
if (ci->material != prev_material) {
-
MaterialData *material_data = nullptr;
if (ci->material.is_valid()) {
material_data = (MaterialData *)storage->material_get_data(ci->material, RasterizerStorageRD::SHADER_TYPE_2D);
}
if (material_data) {
-
if (material_data->shader_data->version.is_valid() && material_data->shader_data->valid) {
pipeline_variants = &material_data->shader_data->pipeline_variants;
if (material_data->uniform_set.is_valid()) {
@@ -1406,7 +1368,6 @@ void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count,
}
void RasterizerCanvasRD::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform) {
-
int item_count = 0;
//setup canvas state uniforms if needed
@@ -1447,12 +1408,10 @@ void RasterizerCanvasRD::canvas_render_items(RID p_to_render_target, Item *p_ite
//setup lights if exist
{
-
Light *l = p_light_list;
uint32_t index = 0;
while (l) {
-
if (index == state.max_lights_per_render) {
l->render_index_cache = -1;
l = l->next_ptr;
@@ -1513,7 +1472,6 @@ void RasterizerCanvasRD::canvas_render_items(RID p_to_render_target, Item *p_ite
RID screen_uniform_set;
while (ci) {
-
if (ci->copy_back_buffer) {
backbuffer_copy = true;
@@ -1527,7 +1485,6 @@ void RasterizerCanvasRD::canvas_render_items(RID p_to_render_target, Item *p_ite
if (ci->material.is_valid()) {
MaterialData *md = (MaterialData *)storage->material_get_data(ci->material, RasterizerStorageRD::SHADER_TYPE_2D);
if (md && md->shader_data->valid) {
-
if (md->shader_data->uses_screen_texture) {
if (!material_screen_texture_found) {
backbuffer_copy = true;
@@ -1574,7 +1531,6 @@ void RasterizerCanvasRD::canvas_render_items(RID p_to_render_target, Item *p_ite
}
RID RasterizerCanvasRD::light_create() {
-
CanvasLight canvas_light;
canvas_light.shadow.size = 0;
return canvas_light_owner.make_rid(canvas_light);
@@ -1589,6 +1545,7 @@ void RasterizerCanvasRD::light_set_texture(RID p_rid, RID p_texture) {
cl->texture = p_texture;
}
+
void RasterizerCanvasRD::light_set_use_shadow(RID p_rid, bool p_enable, int p_resolution) {
CanvasLight *cl = canvas_light_owner.getornull(p_rid);
ERR_FAIL_COND(!cl);
@@ -1598,7 +1555,6 @@ void RasterizerCanvasRD::light_set_use_shadow(RID p_rid, bool p_enable, int p_re
}
if (cl->shadow.texture.is_valid()) {
-
RD::get_singleton()->free(cl->shadow.fb);
RD::get_singleton()->free(cl->shadow.depth);
RD::get_singleton()->free(cl->shadow.texture);
@@ -1608,7 +1564,6 @@ void RasterizerCanvasRD::light_set_use_shadow(RID p_rid, bool p_enable, int p_re
}
if (p_enable) {
-
Vector<RID> fb_textures;
{ //texture
@@ -1641,12 +1596,10 @@ void RasterizerCanvasRD::light_set_use_shadow(RID p_rid, bool p_enable, int p_re
}
void RasterizerCanvasRD::light_update_shadow(RID p_rid, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {
-
CanvasLight *cl = canvas_light_owner.getornull(p_rid);
ERR_FAIL_COND(cl->shadow.texture.is_null());
for (int i = 0; i < 4; i++) {
-
//make sure it remains orthogonal, makes easy to read angle later
//light.basis.scale(Vector3(to_light.elements[0].length(),to_light.elements[1].length(),1));
@@ -1691,11 +1644,9 @@ void RasterizerCanvasRD::light_update_shadow(RID p_rid, const Transform2D &p_lig
LightOccluderInstance *instance = p_occluders;
while (instance) {
-
OccluderPolygon *co = occluder_polygon_owner.getornull(instance->occluder);
if (!co || co->index_array.is_null() || !(p_light_mask & instance->light_mask)) {
-
instance = instance->next;
continue;
}
@@ -1717,7 +1668,6 @@ void RasterizerCanvasRD::light_update_shadow(RID p_rid, const Transform2D &p_lig
}
RID RasterizerCanvasRD::occluder_polygon_create() {
-
OccluderPolygon occluder;
occluder.point_count = 0;
occluder.cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
@@ -1725,12 +1675,10 @@ RID RasterizerCanvasRD::occluder_polygon_create() {
}
void RasterizerCanvasRD::occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) {
-
OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
ERR_FAIL_COND(!oc);
if (oc->point_count != p_lines.size() && oc->vertex_array.is_valid()) {
-
RD::get_singleton()->free(oc->vertex_array);
RD::get_singleton()->free(oc->vertex_buffer);
RD::get_singleton()->free(oc->index_array);
@@ -1743,7 +1691,6 @@ void RasterizerCanvasRD::occluder_polygon_set_shape_as_lines(RID p_occluder, con
}
if (p_lines.size()) {
-
Vector<uint8_t> geometry;
Vector<uint8_t> indices;
int lc = p_lines.size();
@@ -1762,7 +1709,6 @@ void RasterizerCanvasRD::occluder_polygon_set_shape_as_lines(RID p_occluder, con
const int POLY_HEIGHT = 16384;
for (int i = 0; i < lc / 2; i++) {
-
vwptr[i * 12 + 0] = lr[i * 2 + 0].x;
vwptr[i * 12 + 1] = lr[i * 2 + 0].y;
vwptr[i * 12 + 2] = POLY_HEIGHT;
@@ -1813,6 +1759,7 @@ void RasterizerCanvasRD::occluder_polygon_set_shape_as_lines(RID p_occluder, con
}
}
}
+
void RasterizerCanvasRD::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder);
ERR_FAIL_COND(!oc);
@@ -1895,12 +1842,10 @@ void RasterizerCanvasRD::ShaderData::set_code(const String &p_code) {
switch (blend_mode) {
case BLEND_MODE_DISABLED: {
-
// nothing to do here, disabled by default
} break;
case BLEND_MODE_MIX: {
-
attachment.enable_blend = true;
attachment.alpha_blend_op = RD::BLEND_OP_ADD;
attachment.color_blend_op = RD::BLEND_OP_ADD;
@@ -1911,7 +1856,6 @@ void RasterizerCanvasRD::ShaderData::set_code(const String &p_code) {
} break;
case BLEND_MODE_ADD: {
-
attachment.enable_blend = true;
attachment.alpha_blend_op = RD::BLEND_OP_ADD;
attachment.color_blend_op = RD::BLEND_OP_ADD;
@@ -1922,7 +1866,6 @@ void RasterizerCanvasRD::ShaderData::set_code(const String &p_code) {
} break;
case BLEND_MODE_SUB: {
-
attachment.enable_blend = true;
attachment.alpha_blend_op = RD::BLEND_OP_SUBTRACT;
attachment.color_blend_op = RD::BLEND_OP_SUBTRACT;
@@ -2014,12 +1957,11 @@ void RasterizerCanvasRD::ShaderData::set_default_texture_param(const StringName
default_texture_params[p_name] = p_texture;
}
}
-void RasterizerCanvasRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
+void RasterizerCanvasRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
Map<int, StringName> order;
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
-
if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
continue;
}
@@ -2031,7 +1973,6 @@ void RasterizerCanvasRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_
}
for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
-
PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
pi.name = E->get();
p_param_list->push_back(pi);
@@ -2039,9 +1980,7 @@ void RasterizerCanvasRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_
}
void RasterizerCanvasRD::ShaderData::get_instance_param_list(List<RasterizerStorage::InstanceShaderParam> *p_param_list) const {
-
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
-
if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
@@ -2066,9 +2005,11 @@ bool RasterizerCanvasRD::ShaderData::is_param_texture(const StringName &p_param)
bool RasterizerCanvasRD::ShaderData::is_animated() const {
return false;
}
+
bool RasterizerCanvasRD::ShaderData::casts_shadows() const {
return false;
}
+
Variant RasterizerCanvasRD::ShaderData::get_default_parameter(const StringName &p_parameter) const {
if (uniforms.has(p_parameter)) {
ShaderLanguage::ShaderNode::Uniform uniform = uniforms[p_parameter];
@@ -2097,8 +2038,8 @@ RasterizerStorageRD::ShaderData *RasterizerCanvasRD::_create_shader_func() {
ShaderData *shader_data = memnew(ShaderData);
return shader_data;
}
-void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) {
+void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) {
RasterizerCanvasRD *canvas_singleton = (RasterizerCanvasRD *)RasterizerCanvas::singleton;
if ((uint32_t)ubo_data.size() != shader_data->ubo_size) {
@@ -2123,7 +2064,6 @@ void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, V
//check whether buffer changed
if (p_uniform_dirty && ubo_data.size()) {
-
update_uniform_buffer(shader_data->uniforms, shader_data->ubo_offsets.ptr(), p_parameters, ubo_data.ptrw(), ubo_data.size(), false);
RD::get_singleton()->buffer_update(uniform_buffer, 0, ubo_data.size(), ubo_data.ptrw());
}
@@ -2142,7 +2082,6 @@ void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, V
}
if (p_textures_dirty && tex_uniform_count) {
-
update_textures(p_parameters, shader_data->default_texture_params, shader_data->texture_uniforms, texture_cache.ptrw(), false);
}
@@ -2201,6 +2140,7 @@ void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, V
uniform_set = RD::get_singleton()->uniform_set_create(uniforms, canvas_singleton->shader.canvas_shader.version_get_shader(shader_data->version, 0), 1);
}
+
RasterizerCanvasRD::MaterialData::~MaterialData() {
if (uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
RD::get_singleton()->free(uniform_set);
@@ -2514,7 +2454,6 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) {
}
bool RasterizerCanvasRD::free(RID p_rid) {
-
if (canvas_light_owner.owns(p_rid)) {
CanvasLight *cl = canvas_light_owner.getornull(p_rid);
ERR_FAIL_COND_V(!cl, false);
@@ -2531,7 +2470,6 @@ bool RasterizerCanvasRD::free(RID p_rid) {
}
RasterizerCanvasRD::~RasterizerCanvasRD() {
-
//canvas state
{
@@ -2547,14 +2485,12 @@ RasterizerCanvasRD::~RasterizerCanvasRD() {
//shadow rendering
{
-
shadow_render.shader.version_free(shadow_render.shader_version);
//this will also automatically clear all pipelines
RD::get_singleton()->free(state.shadow_sampler);
}
//bindings
{
-
free_texture_binding(bindings.default_empty);
//dispose pending
diff --git a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h
index 4d47b3e13b..bfe4e61f47 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h
@@ -40,7 +40,6 @@
#include "servers/rendering/rendering_device.h"
class RasterizerCanvasRD : public RasterizerCanvas {
-
RasterizerStorageRD *storage;
enum ShaderVariant {
@@ -149,7 +148,6 @@ class RasterizerCanvasRD : public RasterizerCanvas {
} shader;
struct ShaderData : public RasterizerStorageRD::ShaderData {
-
enum BlendMode { //used internally
BLEND_MODE_MIX,
BLEND_MODE_ADD,
@@ -313,7 +311,6 @@ class RasterizerCanvasRD : public RasterizerCanvas {
/******************/
struct CanvasLight {
-
RID texture;
struct {
int size;
@@ -333,7 +330,6 @@ class RasterizerCanvasRD : public RasterizerCanvas {
};
struct OccluderPolygon {
-
RS::CanvasOccluderPolygonCullMode cull_mode;
int point_count;
RID vertex_buffer;
@@ -371,7 +367,6 @@ class RasterizerCanvasRD : public RasterizerCanvas {
//state that does not vary across rendering all items
struct ItemStateData : public Item::CustomData {
-
struct LightCache {
uint64_t light_version;
Light *light;
@@ -382,7 +377,6 @@ class RasterizerCanvasRD : public RasterizerCanvas {
RID state_uniform_set_with_light;
RID state_uniform_set;
ItemStateData() {
-
for (int i = 0; i < DEFAULT_MAX_LIGHTS_PER_ITEM; i++) {
light_cache[i].light_version = 0;
light_cache[i].light = nullptr;
@@ -401,7 +395,6 @@ class RasterizerCanvasRD : public RasterizerCanvas {
};
struct State {
-
//state buffer
struct Buffer {
float canvas_transform[16];
@@ -489,7 +482,7 @@ public:
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform);
- void canvas_debug_viewport_shadows(Light *p_lights_with_shadow){};
+ void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {}
void draw_window_margins(int *p_margins, RID *p_margin_textures) {}
diff --git a/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp
index ed25cc4139..303cb7ad42 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp
@@ -51,17 +51,14 @@ static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_ar
}
static _FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array) {
-
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
-
p_array[i * 4 + j] = p_mtx.matrix[i][j];
}
}
}
RID RasterizerEffectsRD::_get_uniform_set_from_image(RID p_image) {
-
if (image_to_uniform_set_cache.has(p_image)) {
RID uniform_set = image_to_uniform_set_cache[p_image];
if (RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
@@ -83,7 +80,6 @@ RID RasterizerEffectsRD::_get_uniform_set_from_image(RID p_image) {
}
RID RasterizerEffectsRD::_get_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps) {
-
if (texture_to_uniform_set_cache.has(p_texture)) {
RID uniform_set = texture_to_uniform_set_cache[p_texture];
if (RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
@@ -107,7 +103,6 @@ RID RasterizerEffectsRD::_get_uniform_set_from_texture(RID p_texture, bool p_use
}
RID RasterizerEffectsRD::_get_compute_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps) {
-
if (texture_to_compute_uniform_set_cache.has(p_texture)) {
RID uniform_set = texture_to_compute_uniform_set_cache[p_texture];
if (RD::get_singleton()->uniform_set_is_valid(uniform_set)) {
@@ -131,7 +126,6 @@ RID RasterizerEffectsRD::_get_compute_uniform_set_from_texture(RID p_texture, bo
}
RID RasterizerEffectsRD::_get_compute_uniform_set_from_texture_pair(RID p_texture1, RID p_texture2, bool p_use_mipmaps) {
-
TexturePair tp;
tp.texture1 = p_texture1;
tp.texture2 = p_texture2;
@@ -169,7 +163,6 @@ RID RasterizerEffectsRD::_get_compute_uniform_set_from_texture_pair(RID p_textur
}
RID RasterizerEffectsRD::_get_compute_uniform_set_from_image_pair(RID p_texture1, RID p_texture2) {
-
TexturePair tp;
tp.texture1 = p_texture1;
tp.texture2 = p_texture2;
@@ -205,7 +198,6 @@ RID RasterizerEffectsRD::_get_compute_uniform_set_from_image_pair(RID p_texture1
}
void RasterizerEffectsRD::copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_uv_rect, RD::DrawListID p_draw_list, bool p_flip_y, bool p_panorama) {
-
zeromem(&copy_to_fb.push_constant, sizeof(CopyToFbPushConstant));
copy_to_fb.push_constant.use_section = true;
@@ -249,7 +241,6 @@ void RasterizerEffectsRD::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_fr
}
void RasterizerEffectsRD::copy_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y, bool p_force_luminance, bool p_all_source, bool p_8_bit_dst) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
if (p_flip_y) {
copy.push_constant.flags |= COPY_FLAG_FLIP_Y;
@@ -283,7 +274,6 @@ void RasterizerEffectsRD::copy_to_rect(RID p_source_rd_texture, RID p_dest_textu
}
void RasterizerEffectsRD::copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, const Size2i &p_panorama_size, float p_lod, bool p_is_array) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
copy.push_constant.section[0] = 0;
@@ -307,7 +297,6 @@ void RasterizerEffectsRD::copy_cubemap_to_panorama(RID p_source_cube, RID p_dest
}
void RasterizerEffectsRD::copy_depth_to_rect_and_linearize(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y, float p_z_near, float p_z_far) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
if (p_flip_y) {
copy.push_constant.flags |= COPY_FLAG_FLIP_Y;
@@ -335,7 +324,6 @@ void RasterizerEffectsRD::copy_depth_to_rect_and_linearize(RID p_source_rd_textu
}
void RasterizerEffectsRD::copy_depth_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
if (p_flip_y) {
copy.push_constant.flags |= COPY_FLAG_FLIP_Y;
@@ -361,7 +349,6 @@ void RasterizerEffectsRD::copy_depth_to_rect(RID p_source_rd_texture, RID p_dest
}
void RasterizerEffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Rect2i &p_region, bool p_8bit_dst) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
uint32_t base_flags = 0;
@@ -397,7 +384,6 @@ void RasterizerEffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture,
}
void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Size2i &p_size, float p_strength, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
CopyMode copy_mode = p_first_pass && p_auto_exposure.is_valid() ? COPY_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE : COPY_MODE_GAUSSIAN_GLOW;
@@ -449,7 +435,6 @@ void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_texture,
}
void RasterizerEffectsRD::screen_space_reflection(RID p_diffuse, RID p_normal, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_roughness, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera) {
-
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
int32_t x_groups = (p_screen_size.width - 1) / 8 + 1;
@@ -478,7 +463,6 @@ void RasterizerEffectsRD::screen_space_reflection(RID p_diffuse, RID p_normal, R
}
{
-
ssr.push_constant.camera_z_far = p_camera.get_z_far();
ssr.push_constant.camera_z_near = p_camera.get_z_near();
ssr.push_constant.orthogonal = p_camera.is_orthogonal();
@@ -518,7 +502,6 @@ void RasterizerEffectsRD::screen_space_reflection(RID p_diffuse, RID p_normal, R
}
if (p_roughness_quality != RS::ENV_SSR_ROUGNESS_QUALITY_DISABLED) {
-
//blurr
RD::get_singleton()->compute_list_add_barrier(compute_list);
@@ -575,7 +558,6 @@ void RasterizerEffectsRD::screen_space_reflection(RID p_diffuse, RID p_normal, R
}
void RasterizerEffectsRD::sub_surface_scattering(RID p_diffuse, RID p_diffuse2, RID p_depth, const CameraMatrix &p_camera, const Size2i &p_screen_size, float p_scale, float p_depth_scale, RenderingServer::SubSurfaceScatteringQuality p_quality) {
-
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
int32_t x_groups = (p_screen_size.width - 1) / 8 + 1;
@@ -622,11 +604,9 @@ void RasterizerEffectsRD::sub_surface_scattering(RID p_diffuse, RID p_diffuse2,
}
void RasterizerEffectsRD::merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection) {
-
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD, Vector<Color>());
if (p_reflection.is_valid()) {
-
if (p_base.is_valid()) {
RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, specular_merge.pipelines[SPECULAR_MERGE_SSR].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer)));
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_base), 2);
@@ -638,7 +618,6 @@ void RasterizerEffectsRD::merge_specular(RID p_dest_framebuffer, RID p_specular,
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_reflection), 1);
} else {
-
if (p_base.is_valid()) {
RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, specular_merge.pipelines[SPECULAR_MERGE_ADD].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer)));
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_base), 2);
@@ -655,7 +634,6 @@ void RasterizerEffectsRD::merge_specular(RID p_dest_framebuffer, RID p_specular,
}
void RasterizerEffectsRD::make_mipmap(RID p_source_rd_texture, RID p_dest_texture, const Size2i &p_size) {
-
zeromem(&copy.push_constant, sizeof(CopyPushConstant));
copy.push_constant.section[0] = 0;
@@ -676,7 +654,6 @@ void RasterizerEffectsRD::make_mipmap(RID p_source_rd_texture, RID p_dest_textur
}
void RasterizerEffectsRD::copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, float p_z_near, float p_z_far, float p_bias, bool p_dp_flip) {
-
CopyToDPPushConstant push_constant;
push_constant.screen_size[0] = p_rect.size.x;
push_constant.screen_size[1] = p_rect.size.y;
@@ -700,7 +677,6 @@ void RasterizerEffectsRD::copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dest
}
void RasterizerEffectsRD::tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings) {
-
zeromem(&tonemap.push_constant, sizeof(TonemapPushConstant));
tonemap.push_constant.use_bcs = p_settings.use_bcs;
@@ -743,7 +719,6 @@ void RasterizerEffectsRD::tonemapper(RID p_source_color, RID p_dst_framebuffer,
}
void RasterizerEffectsRD::luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set) {
-
luminance_reduce.push_constant.source_size[0] = p_source_size.x;
luminance_reduce.push_constant.source_size[1] = p_source_size.y;
luminance_reduce.push_constant.max_luminance = p_max_luminance;
@@ -753,12 +728,10 @@ void RasterizerEffectsRD::luminance_reduction(RID p_source_texture, const Size2i
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
for (int i = 0; i < p_reduce.size(); i++) {
-
if (i == 0) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, luminance_reduce.pipelines[LUMINANCE_REDUCE_READ]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_texture), 0);
} else {
-
RD::get_singleton()->compute_list_add_barrier(compute_list); //needs barrier, wait until previous is done
if (i == p_reduce.size() - 1 && !p_set) {
@@ -788,7 +761,6 @@ void RasterizerEffectsRD::luminance_reduction(RID p_source_texture, const Size2i
}
void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) {
-
bokeh.push_constant.blur_far_active = p_dof_far;
bokeh.push_constant.blur_far_begin = p_dof_far_begin;
bokeh.push_constant.blur_far_end = p_dof_far_begin + p_dof_far_size;
@@ -831,7 +803,6 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
RD::get_singleton()->compute_list_add_barrier(compute_list);
if (p_bokeh_shape == RS::DOF_BOKEH_BOX || p_bokeh_shape == RS::DOF_BOKEH_HEXAGON) {
-
//second pass
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]);
@@ -867,7 +838,6 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
bokeh.push_constant.second_pass = true;
if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) {
-
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture2), 0);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_halfsize_texture1), 1);
} else {
@@ -951,7 +921,6 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con
}
void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness) {
-
//minify first
ssao.minify_push_constant.orthogonal = p_projection.is_orthogonal();
ssao.minify_push_constant.z_near = p_projection.get_z_near();
@@ -967,7 +936,6 @@ void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer,
// Minify the depth buffer.
for (int i = 0; i < depth_mipmaps.size(); i++) {
-
if (i == 0) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_MINIFY_FIRST]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_depth_buffer), 0);
@@ -1051,7 +1019,6 @@ void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer,
ssao.blur_push_constant.axis[1] = 0;
if (p_blur != RS::ENV_SSAO_BLUR_DISABLED) {
-
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[p_half_size ? SSAO_BLUR_PASS_HALF : SSAO_BLUR_PASS]);
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_ao1), 0);
if (p_half_size) {
@@ -1107,7 +1074,6 @@ void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer,
}
void RasterizerEffectsRD::roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve) {
-
roughness_limiter.push_constant.screen_size[0] = p_size.x;
roughness_limiter.push_constant.screen_size[1] = p_size.y;
roughness_limiter.push_constant.curve = p_curve;
@@ -1128,7 +1094,6 @@ void RasterizerEffectsRD::roughness_limit(RID p_source_normal, RID p_roughness,
}
void RasterizerEffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size) {
-
zeromem(&roughness.push_constant, sizeof(CubemapRoughnessPushConstant));
roughness.push_constant.face_id = p_face_id > 9 ? 0 : p_face_id;
@@ -1154,7 +1119,6 @@ void RasterizerEffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_
}
void RasterizerEffectsRD::cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size) {
-
cubemap_downsampler.push_constant.face_size = p_size.x;
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
@@ -1173,7 +1137,6 @@ void RasterizerEffectsRD::cubemap_downsample(RID p_source_cubemap, RID p_dest_cu
}
void RasterizerEffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array) {
-
Vector<RD::Uniform> uniforms;
for (int i = 0; i < p_dest_cubemap.size(); i++) {
RD::Uniform u;
@@ -1203,7 +1166,6 @@ void RasterizerEffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_des
}
void RasterizerEffectsRD::render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_samplers, RID p_lights, RenderPipelineVertexFormatCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, const CameraMatrix &p_camera, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position) {
-
SkyPushConstant sky_push_constant;
zeromem(&sky_push_constant, sizeof(SkyPushConstant));
@@ -1240,7 +1202,6 @@ void RasterizerEffectsRD::render_sky(RD::DrawListID p_list, float p_time, RID p_
}
RasterizerEffectsRD::RasterizerEffectsRD() {
-
{ // Initialize copy
Vector<String> copy_modes;
copy_modes.push_back("\n#define MODE_GAUSSIAN_BLUR\n");
@@ -1492,7 +1453,6 @@ RasterizerEffectsRD::RasterizerEffectsRD() {
blend_additive.attachments.push_back(ba);
for (int i = 0; i < SPECULAR_MERGE_MAX; i++) {
-
RD::PipelineColorBlendState blend_state;
if (i == SPECULAR_MERGE_ADDITIVE_ADD || i == SPECULAR_MERGE_ADDITIVE_SSR) {
blend_state = blend_additive;
diff --git a/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h
index 1b16648ca6..8a55d2d13c 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h
@@ -55,7 +55,6 @@
#include "servers/rendering_server.h"
class RasterizerEffectsRD {
-
enum CopyMode {
COPY_MODE_GAUSSIAN_COPY,
COPY_MODE_GAUSSIAN_COPY_8BIT,
@@ -84,7 +83,6 @@ class RasterizerEffectsRD {
};
struct CopyPushConstant {
-
int32_t section[4];
int32_t target[2];
uint32_t flags;
@@ -121,7 +119,6 @@ class RasterizerEffectsRD {
};
struct CopyToFbPushConstant {
-
float section[4];
float pixel_size[2];
uint32_t flip_y;
@@ -150,7 +147,6 @@ class RasterizerEffectsRD {
};
struct CubemapRoughness {
-
CubemapRoughnessPushConstant push_constant;
CubemapRoughnessShaderRD shader;
RID shader_version;
@@ -214,7 +210,6 @@ class RasterizerEffectsRD {
};
struct LuminanceReduce {
-
LuminanceReducePushConstant push_constant;
LuminanceReduceShaderRD shader;
RID shader_version;
@@ -231,7 +226,6 @@ class RasterizerEffectsRD {
};
struct CoptToDP {
-
CubeToDpShaderRD shader;
RID shader_version;
RID pipeline;
@@ -272,7 +266,6 @@ class RasterizerEffectsRD {
};
struct Bokeh {
-
BokehPushConstant push_constant;
BokehDofShaderRD shader;
RID shader_version;
@@ -333,7 +326,6 @@ class RasterizerEffectsRD {
};
struct SSAO {
-
SSAOMinifyPushConstant minify_push_constant;
SsaoMinifyShaderRD minify_shader;
RID minify_shader_version;
@@ -356,7 +348,6 @@ class RasterizerEffectsRD {
};
struct RoughnessLimiter {
-
RoughnessLimiterPushConstant push_constant;
RoughnessLimiterShaderRD shader;
RID shader_version;
@@ -370,7 +361,6 @@ class RasterizerEffectsRD {
};
struct CubemapDownsampler {
-
CubemapDownsamplerPushConstant push_constant;
CubemapDownsamplerShaderRD shader;
RID shader_version;
@@ -387,7 +377,6 @@ class RasterizerEffectsRD {
};
struct CubemapFilter {
-
CubemapFilterShaderRD shader;
RID shader_version;
RID pipelines[FILTER_MODE_MAX];
@@ -420,7 +409,6 @@ class RasterizerEffectsRD {
*/
struct SpecularMerge {
-
SpecularMergeShaderRD shader;
RID shader_version;
RenderPipelineVertexFormatCacheRD pipelines[SPECULAR_MERGE_MAX];
@@ -434,7 +422,6 @@ class RasterizerEffectsRD {
};
struct ScreenSpaceReflectionPushConstant {
-
float proj_info[4];
int32_t screen_size[2];
@@ -455,7 +442,6 @@ class RasterizerEffectsRD {
};
struct ScreenSpaceReflection {
-
ScreenSpaceReflectionPushConstant push_constant;
ScreenSpaceReflectionShaderRD shader;
RID shader_version;
@@ -464,7 +450,6 @@ class RasterizerEffectsRD {
} ssr;
struct ScreenSpaceReflectionFilterPushConstant {
-
float proj_info[4];
uint32_t orthogonal;
@@ -483,7 +468,6 @@ class RasterizerEffectsRD {
};
struct ScreenSpaceReflectionFilter {
-
ScreenSpaceReflectionFilterPushConstant push_constant;
ScreenSpaceReflectionFilterShaderRD shader;
RID shader_version;
@@ -491,7 +475,6 @@ class RasterizerEffectsRD {
} ssr_filter;
struct ScreenSpaceReflectionScalePushConstant {
-
int32_t screen_size[2];
float camera_z_near;
float camera_z_far;
@@ -502,7 +485,6 @@ class RasterizerEffectsRD {
};
struct ScreenSpaceReflectionScale {
-
ScreenSpaceReflectionScalePushConstant push_constant;
ScreenSpaceReflectionScaleShaderRD shader;
RID shader_version;
@@ -510,7 +492,6 @@ class RasterizerEffectsRD {
} ssr_scale;
struct SubSurfaceScatteringPushConstant {
-
int32_t screen_size[2];
float camera_z_far;
float camera_z_near;
@@ -525,7 +506,6 @@ class RasterizerEffectsRD {
};
struct SubSurfaceScattering {
-
SubSurfaceScatteringPushConstant push_constant;
SubsurfaceScatteringShaderRD shader;
RID shader_version;
@@ -580,7 +560,6 @@ public:
void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal);
struct TonemapSettings {
-
bool use_glow = false;
enum GlowMode {
GLOW_MODE_ADD,
diff --git a/servers/rendering/rasterizer_rd/rasterizer_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_rd.cpp
index 4267a087b6..18cf4fa340 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_rd.cpp
@@ -37,7 +37,6 @@ void RasterizerRD::prepare_for_blitting_render_targets() {
}
void RasterizerRD::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
-
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin_for_screen(p_screen);
for (int i = 0; i < p_amount; i++) {
@@ -90,7 +89,6 @@ void RasterizerRD::begin_frame(double frame_step) {
}
void RasterizerRD::end_frame(bool p_swap_buffers) {
-
#ifndef _MSC_VER
#warning TODO: likely passa bool to swap buffers to avoid display?
#endif
@@ -98,7 +96,6 @@ void RasterizerRD::end_frame(bool p_swap_buffers) {
}
void RasterizerRD::initialize() {
-
{ //create framebuffer copy shader
RenderingDevice::ShaderStageData vert;
vert.shader_stage = RenderingDevice::SHADER_STAGE_VERTEX;
@@ -161,7 +158,6 @@ ThreadWorkPool RasterizerRD::thread_work_pool;
uint64_t RasterizerRD::frame = 1;
void RasterizerRD::finalize() {
-
thread_work_pool.finish();
memdelete(scene);
diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
index b639b4200a..7d351f249a 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
@@ -83,17 +83,14 @@ static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_mtx, float *p_arra
}
static _FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array) {
-
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
-
p_array[i * 4 + j] = p_mtx.matrix[i][j];
}
}
}
static _FORCE_INLINE_ void store_soft_shadow_kernel(const float *p_kernel, float *p_array) {
-
for (int i = 0; i < 128; i++) {
p_array[i] = p_kernel[i];
}
@@ -224,7 +221,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
switch (blend_mode) {
case BLEND_MODE_MIX: {
-
blend_attachment.enable_blend = true;
blend_attachment.alpha_blend_op = RD::BLEND_OP_ADD;
blend_attachment.color_blend_op = RD::BLEND_OP_ADD;
@@ -235,7 +231,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
} break;
case BLEND_MODE_ADD: {
-
blend_attachment.enable_blend = true;
blend_attachment.alpha_blend_op = RD::BLEND_OP_ADD;
blend_attachment.color_blend_op = RD::BLEND_OP_ADD;
@@ -247,7 +242,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
} break;
case BLEND_MODE_SUB: {
-
blend_attachment.enable_blend = true;
blend_attachment.alpha_blend_op = RD::BLEND_OP_SUBTRACT;
blend_attachment.color_blend_op = RD::BLEND_OP_SUBTRACT;
@@ -288,7 +282,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
}
for (int i = 0; i < CULL_VARIANT_MAX; i++) {
-
RD::PolygonCullMode cull_mode_rd_table[CULL_VARIANT_MAX][3] = {
{ RD::POLYGON_CULL_DISABLED, RD::POLYGON_CULL_FRONT, RD::POLYGON_CULL_BACK },
{ RD::POLYGON_CULL_DISABLED, RD::POLYGON_CULL_BACK, RD::POLYGON_CULL_FRONT },
@@ -298,7 +291,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
RD::PolygonCullMode cull_mode_rd = cull_mode_rd_table[i][cull];
for (int j = 0; j < RS::PRIMITIVE_MAX; j++) {
-
RD::RenderPrimitive primitive_rd_table[RS::PRIMITIVE_MAX] = {
RD::RENDER_PRIMITIVE_POINTS,
RD::RENDER_PRIMITIVE_LINES,
@@ -310,7 +302,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
RD::RenderPrimitive primitive_rd = uses_point_size ? RD::RENDER_PRIMITIVE_POINTS : primitive_rd_table[j];
for (int k = 0; k < SHADER_VERSION_MAX; k++) {
-
RD::PipelineRasterizationState raster_state;
raster_state.cull_mode = cull_mode_rd;
raster_state.wireframe = wireframe;
@@ -337,7 +328,6 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) {
continue; // do not use this version (will error if using it is attempted)
}
} else {
-
if (k == SHADER_VERSION_COLOR_PASS || k == SHADER_VERSION_VCT_COLOR_PASS || k == SHADER_VERSION_LIGHTMAP_COLOR_PASS) {
blend_state = blend_state_opaque;
} else if (k == SHADER_VERSION_DEPTH_PASS || k == SHADER_VERSION_DEPTH_PASS_DP) {
@@ -373,11 +363,9 @@ void RasterizerSceneHighEndRD::ShaderData::set_default_texture_param(const Strin
}
void RasterizerSceneHighEndRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
-
Map<int, StringName> order;
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
-
if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
continue;
}
@@ -390,7 +378,6 @@ void RasterizerSceneHighEndRD::ShaderData::get_param_list(List<PropertyInfo> *p_
}
for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
-
PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
pi.name = E->get();
p_param_list->push_back(pi);
@@ -398,9 +385,7 @@ void RasterizerSceneHighEndRD::ShaderData::get_param_list(List<PropertyInfo> *p_
}
void RasterizerSceneHighEndRD::ShaderData::get_instance_param_list(List<RasterizerStorage::InstanceShaderParam> *p_param_list) const {
-
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
-
if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
@@ -429,6 +414,7 @@ bool RasterizerSceneHighEndRD::ShaderData::is_animated() const {
bool RasterizerSceneHighEndRD::ShaderData::casts_shadows() const {
return false;
}
+
Variant RasterizerSceneHighEndRD::ShaderData::get_default_parameter(const StringName &p_parameter) const {
if (uniforms.has(p_parameter)) {
ShaderLanguage::ShaderNode::Uniform uniform = uniforms[p_parameter];
@@ -466,7 +452,6 @@ void RasterizerSceneHighEndRD::MaterialData::set_next_pass(RID p_pass) {
}
void RasterizerSceneHighEndRD::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) {
-
RasterizerSceneHighEndRD *scene_singleton = (RasterizerSceneHighEndRD *)RasterizerSceneHighEndRD::singleton;
if ((uint32_t)ubo_data.size() != shader_data->ubo_size) {
@@ -491,7 +476,6 @@ void RasterizerSceneHighEndRD::MaterialData::update_parameters(const Map<StringN
//check whether buffer changed
if (p_uniform_dirty && ubo_data.size()) {
-
update_uniform_buffer(shader_data->uniforms, shader_data->ubo_offsets.ptr(), p_parameters, ubo_data.ptrw(), ubo_data.size(), false);
RD::get_singleton()->buffer_update(uniform_buffer, 0, ubo_data.size(), ubo_data.ptrw());
}
@@ -510,7 +494,6 @@ void RasterizerSceneHighEndRD::MaterialData::update_parameters(const Map<StringN
}
if (p_textures_dirty && tex_uniform_count) {
-
update_textures(p_parameters, shader_data->default_texture_params, shader_data->texture_uniforms, texture_cache.ptrw(), true);
}
@@ -527,7 +510,6 @@ void RasterizerSceneHighEndRD::MaterialData::update_parameters(const Map<StringN
Vector<RD::Uniform> uniforms;
{
-
if (shader_data->ubo_size) {
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
@@ -572,7 +554,6 @@ RasterizerSceneHighEndRD::RenderBufferDataHighEnd::~RenderBufferDataHighEnd() {
}
void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::ensure_specular() {
-
if (!specular.is_valid()) {
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
@@ -588,7 +569,6 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::ensure_specular() {
specular = RD::get_singleton()->texture_create(tf, RD::TextureView());
if (msaa == RS::VIEWPORT_MSAA_DISABLED) {
-
{
Vector<RID> fb;
fb.push_back(color);
@@ -605,7 +585,6 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::ensure_specular() {
}
} else {
-
tf.samples = texture_samples;
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
specular_msaa = RD::get_singleton()->texture_create(tf, RD::TextureView());
@@ -629,7 +608,6 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::ensure_specular() {
}
void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::clear() {
-
if (color_msaa.is_valid()) {
RD::get_singleton()->free(color_msaa);
color_msaa = RID();
@@ -689,7 +667,6 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_bu
depth = p_depth_buffer;
if (p_msaa == RS::VIEWPORT_MSAA_DISABLED) {
-
{
Vector<RID> fb;
fb.push_back(p_color_buffer);
@@ -704,7 +681,6 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_bu
depth_fb = RD::get_singleton()->framebuffer_create(fb);
}
} else {
-
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
tf.width = p_width;
@@ -785,7 +761,6 @@ void RasterizerSceneHighEndRD::_allocate_normal_texture(RenderBufferDataHighEnd
}
void RasterizerSceneHighEndRD::_allocate_roughness_texture(RenderBufferDataHighEnd *rb) {
-
if (rb->roughness_buffer.is_valid()) {
return;
}
@@ -807,7 +782,6 @@ void RasterizerSceneHighEndRD::_allocate_roughness_texture(RenderBufferDataHighE
rb->roughness_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView());
if (rb->msaa == RS::VIEWPORT_MSAA_DISABLED) {
-
Vector<RID> fb;
fb.push_back(rb->depth);
fb.push_back(rb->normal_buffer);
@@ -840,11 +814,9 @@ bool RasterizerSceneHighEndRD::free(RID p_rid) {
}
void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements, int p_element_count, bool p_for_depth) {
-
uint32_t lightmap_captures_used = 0;
for (int i = 0; i < p_element_count; i++) {
-
const RenderList::Element *e = p_elements[i];
InstanceData &id = scene_state.instances[i];
store_transform(e->instance->transform, id.transform);
@@ -914,7 +886,6 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements,
id.gi_offset |= 0xFFFF0000;
}
} else if (e->instance->lightmap) {
-
int32_t lightmap_index = storage->lightmap_get_array_index(e->instance->lightmap->base);
if (lightmap_index >= 0) {
id.gi_offset = lightmap_index;
@@ -933,7 +904,6 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements,
}
} else if (!e->instance->lightmap_sh.empty()) {
if (lightmap_captures_used < scene_state.max_lightmap_captures) {
-
const Color *src_capture = e->instance->lightmap_sh.ptr();
LightmapCaptureData &lcd = scene_state.lightmap_captures[lightmap_captures_used];
for (int j = 0; j < 9; j++) {
@@ -960,7 +930,6 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements,
/// RENDERING ///
void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_list, RenderingDevice::FramebufferFormatID p_framebuffer_Format, RenderList::Element **p_elements, int p_element_count, bool p_reverse_cull, PassMode p_pass_mode, bool p_no_gi, RID p_radiance_uniform_set, RID p_render_buffers_uniform_set, bool p_force_wireframe, const Vector2 &p_uv_offset) {
-
RD::DrawListID draw_list = p_draw_list;
RD::FramebufferFormatID framebuffer_format = p_framebuffer_Format;
@@ -992,7 +961,6 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
push_constant.bake_uv2_offset[1] = p_uv_offset.y;
for (int i = 0; i < p_element_count; i++) {
-
const RenderList::Element *e = p_elements[i];
MaterialData *material = e->material;
@@ -1156,10 +1124,8 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
RD::get_singleton()->draw_list_draw(draw_list, index_array_rd.is_valid(), instances);
} break;
case RS::INSTANCE_IMMEDIATE: {
-
} break;
case RS::INSTANCE_PARTICLES: {
-
} break;
default: {
ERR_CONTINUE(true); //should be a bug
@@ -1169,7 +1135,6 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l
}
void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, RID p_reflection_probe, bool p_no_fog, const Size2 &p_screen_pixel_size, RID p_shadow_atlas, bool p_flip_y, const Color &p_default_bg_color, float p_znear, float p_zfar, bool p_opaque_render_buffers, bool p_pancake_shadows) {
-
//CameraMatrix projection = p_cam_projection;
//projection.flip_y(); // Vulkan and modern APIs use Y-Down
CameraMatrix correction;
@@ -1214,7 +1179,6 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
scene_state.ubo.time = time;
if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
-
scene_state.ubo.use_ambient_light = true;
scene_state.ubo.ambient_light_color_energy[0] = 1;
scene_state.ubo.ambient_light_color_energy[1] = 1;
@@ -1225,7 +1189,6 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
scene_state.ubo.ssao_enabled = false;
} else if (is_environment(p_environment)) {
-
RS::EnvironmentBG env_bg = environment_get_background(p_environment);
RS::EnvironmentAmbientSource ambient_src = environment_get_ambient_source(p_environment);
@@ -1236,7 +1199,6 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
//ambient
if (ambient_src == RS::ENV_AMBIENT_SOURCE_BG && (env_bg == RS::ENV_BG_CLEAR_COLOR || env_bg == RS::ENV_BG_COLOR)) {
-
Color color = env_bg == RS::ENV_BG_CLEAR_COLOR ? p_default_bg_color : environment_get_bg_color(p_environment);
color = color.to_linear();
@@ -1246,7 +1208,6 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
scene_state.ubo.use_ambient_light = true;
scene_state.ubo.use_ambient_cubemap = false;
} else {
-
float energy = environment_get_ambient_light_energy(p_environment);
Color color = environment_get_ambient_light_color(p_environment);
color = color.to_linear();
@@ -1281,7 +1242,6 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
scene_state.ubo.ao_color[3] = ao_color.a;
} else {
-
if (p_reflection_probe.is_valid() && storage->reflection_probe_is_interior(reflection_probe_instance_get_probe(p_reflection_probe))) {
scene_state.ubo.use_ambient_light = false;
} else {
@@ -1305,7 +1265,6 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
}
void RasterizerSceneHighEndRD::_add_geometry(InstanceBase *p_instance, uint32_t p_surface, RID p_material, PassMode p_pass_mode, uint32_t p_geometry_index) {
-
RID m_src;
m_src = p_instance->material_override.is_valid() ? p_instance->material_override : p_material;
@@ -1337,16 +1296,15 @@ void RasterizerSceneHighEndRD::_add_geometry(InstanceBase *p_instance, uint32_t
_add_geometry_with_material(p_instance, p_surface, material, m_src, p_pass_mode, p_geometry_index);
while (material->next_pass.is_valid()) {
-
material = (MaterialData *)storage->material_get_data(material->next_pass, RasterizerStorageRD::SHADER_TYPE_3D);
- if (!material || !material->shader_data->valid)
+ if (!material || !material->shader_data->valid) {
break;
+ }
_add_geometry_with_material(p_instance, p_surface, material, material->next_pass, p_pass_mode, p_geometry_index);
}
}
void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_instance, uint32_t p_surface, MaterialData *p_material, RID p_material_rid, PassMode p_pass_mode, uint32_t p_geometry_index) {
-
bool has_read_screen_alpha = p_material->shader_data->uses_screen_texture || p_material->shader_data->uses_depth_texture || p_material->shader_data->uses_normal_texture;
bool has_base_alpha = (p_material->shader_data->uses_alpha || has_read_screen_alpha);
bool has_blend_alpha = p_material->shader_data->uses_blend_alpha;
@@ -1369,7 +1327,6 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
}
if (p_pass_mode != PASS_MODE_COLOR && p_pass_mode != PASS_MODE_COLOR_SPECULAR) {
-
if (has_blend_alpha || has_read_screen_alpha || (has_base_alpha && !p_material->shader_data->uses_depth_pre_pass) || p_material->shader_data->depth_draw == ShaderData::DEPTH_DRAW_DISABLED || p_material->shader_data->depth_test == ShaderData::DEPTH_TEST_DISABLED || p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_OFF) {
//conditions in which no depth pass should be processed
return;
@@ -1391,8 +1348,9 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
RenderList::Element *e = (has_alpha || p_material->shader_data->depth_test == ShaderData::DEPTH_TEST_DISABLED) ? render_list.add_alpha_element() : render_list.add_element();
- if (!e)
+ if (!e) {
return;
+ }
e->instance = p_instance;
e->material = p_material;
@@ -1426,7 +1384,6 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta
}
void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, PassMode p_pass_mode, bool p_no_gi) {
-
scene_state.current_shader_index = 0;
scene_state.current_material_index = 0;
scene_state.used_sss = false;
@@ -1439,14 +1396,11 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
//fill list
for (int i = 0; i < p_cull_count; i++) {
-
InstanceBase *inst = p_cull_result[i];
//add geometry for drawing
switch (inst->base_type) {
-
case RS::INSTANCE_MESH: {
-
const RID *materials = nullptr;
uint32_t surface_count;
@@ -1458,7 +1412,6 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
const RID *inst_materials = inst->materials.ptr();
for (uint32_t j = 0; j < surface_count; j++) {
-
RID material = inst_materials[j].is_valid() ? inst_materials[j] : materials[j];
uint32_t surface_index = storage->mesh_surface_get_render_pass_index(inst->base, j, render_pass, &geometry_index);
@@ -1470,7 +1423,6 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
} break;
case RS::INSTANCE_MULTIMESH: {
-
if (storage->multimesh_get_instances_to_draw(inst->base) == 0) {
//not visible, 0 instances
continue;
@@ -1490,7 +1442,6 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
}
for (uint32_t j = 0; j < surface_count; j++) {
-
uint32_t surface_index = storage->mesh_surface_get_multimesh_render_pass_index(mesh, j, render_pass, &geometry_index);
_add_geometry(inst, j, materials[j], p_pass_mode, surface_index);
}
@@ -1537,9 +1488,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i
}
void RasterizerSceneHighEndRD::_setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, RID p_environment) {
-
for (int i = 0; i < p_reflection_probe_cull_count; i++) {
-
RID rpi = p_reflection_probe_cull_result[i];
if (i >= (int)scene_state.max_reflections) {
@@ -1616,7 +1565,6 @@ void RasterizerSceneHighEndRD::_setup_reflections(RID *p_reflection_probe_cull_r
}
void RasterizerSceneHighEndRD::_setup_lightmaps(InstanceBase **p_lightmap_cull_result, int p_lightmap_cull_count, const Transform &p_cam_transform) {
-
uint32_t lightmaps_used = 0;
for (int i = 0; i < p_lightmap_cull_count; i++) {
if (i >= (int)scene_state.max_lightmaps) {
@@ -1636,11 +1584,9 @@ void RasterizerSceneHighEndRD::_setup_lightmaps(InstanceBase **p_lightmap_cull_r
}
void RasterizerSceneHighEndRD::_setup_gi_probes(RID *p_gi_probe_probe_cull_result, int p_gi_probe_probe_cull_count, const Transform &p_camera_transform) {
-
int index = 0;
for (int i = 0; i < p_gi_probe_probe_cull_count; i++) {
-
RID rpi = p_gi_probe_probe_cull_result[i];
if (index >= (int)scene_state.max_gi_probes) {
@@ -1691,13 +1637,11 @@ void RasterizerSceneHighEndRD::_setup_gi_probes(RID *p_gi_probe_probe_cull_resul
}
void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform, RID p_shadow_atlas, bool p_using_shadows) {
-
uint32_t light_count = 0;
scene_state.ubo.directional_light_count = 0;
sky_scene_state.directional_light_count = 0;
for (int i = 0; i < p_light_cull_count; i++) {
-
RID li = p_light_cull_result[i];
RID base = light_instance_get_base_light(li);
@@ -1705,9 +1649,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
RS::LightType type = storage->light_get_type(base);
switch (type) {
-
case RS::LIGHT_DIRECTIONAL: {
-
if (scene_state.ubo.directional_light_count >= scene_state.max_directional_lights) {
continue;
}
@@ -1759,7 +1701,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
light_data.shadow_color4[3] = 1.0;
} else {
-
light_data.shadow_color1[0] = shadow_col.r;
light_data.shadow_color1[1] = shadow_col.g;
light_data.shadow_color1[2] = shadow_col.b;
@@ -1791,7 +1732,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
}
if (light_data.shadow_enabled) {
-
RS::LightDirectionalShadowMode smode = storage->light_directional_get_shadow_mode(base);
int limit = smode == RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL ? 0 : (smode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS ? 1 : 3);
@@ -1854,7 +1794,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
// Copy to SkyDirectionalLightData
if (sky_scene_state.directional_light_count < sky_scene_state.max_directional_lights) {
-
SkyDirectionalLightData &sky_light_data = sky_scene_state.directional_lights[sky_scene_state.directional_light_count];
Vector3 world_direction = light_transform.basis.xform(Vector3(0, 0, 1)).normalized();
@@ -1878,7 +1817,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
} break;
case RS::LIGHT_SPOT:
case RS::LIGHT_OMNI: {
-
if (light_count >= scene_state.max_lights) {
continue;
}
@@ -1934,7 +1872,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
Rect2 rect = storage->decal_atlas_get_texture_rect(projector);
if (type == RS::LIGHT_SPOT) {
-
light_data.projector_rect[0] = rect.position.x;
light_data.projector_rect[1] = rect.position.y + rect.size.height; //flip because shadow is flipped
light_data.projector_rect[2] = rect.size.width;
@@ -1987,14 +1924,12 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
light_data.soft_shadow_scale = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_BLUR);
if (type == RS::LIGHT_OMNI) {
-
light_data.atlas_rect[3] *= 0.5; //one paraboloid on top of another
Transform proj = (p_camera_inverse_transform * light_transform).inverse();
store_transform(proj, light_data.shadow_matrix);
if (size > 0.0) {
-
light_data.soft_shadow_size = size;
} else {
light_data.soft_shadow_size = 0.0;
@@ -2002,7 +1937,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
}
} else if (type == RS::LIGHT_SPOT) {
-
Transform modelview = (p_camera_inverse_transform * light_transform).inverse();
CameraMatrix bias;
bias.set_light_bias();
@@ -2046,7 +1980,6 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig
}
void RasterizerSceneHighEndRD::_setup_decals(const RID *p_decal_instances, int p_decal_count, const Transform &p_camera_inverse_xform) {
-
Transform uv_xform;
uv_xform.basis.scale(Vector3(2.0, 1.0, 2.0));
uv_xform.origin = Vector3(-1.0, 0.0, -1.0);
@@ -2054,7 +1987,6 @@ void RasterizerSceneHighEndRD::_setup_decals(const RID *p_decal_instances, int p
p_decal_count = MIN((uint32_t)p_decal_count, scene_state.max_decals);
int idx = 0;
for (int i = 0; i < p_decal_count; i++) {
-
RID di = p_decal_instances[i];
RID decal = decal_instance_get_base(di);
@@ -2102,7 +2034,6 @@ void RasterizerSceneHighEndRD::_setup_decals(const RID *p_decal_instances, int p
dd.albedo_rect[2] = rect.size.x;
dd.albedo_rect[3] = rect.size.y;
} else {
-
if (!emission_tex.is_valid()) {
continue; //no albedo, no emission, no decal.
}
@@ -2179,7 +2110,6 @@ void RasterizerSceneHighEndRD::_setup_decals(const RID *p_decal_instances, int p
}
void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID *p_gi_probe_cull_result, int p_gi_probe_cull_count, RID *p_decal_cull_result, int p_decal_cull_count, InstanceBase **p_lightmap_cull_result, int p_lightmap_cull_count, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, const Color &p_default_bg_color) {
-
RenderBufferDataHighEnd *render_buffer = nullptr;
if (p_render_buffer.is_valid()) {
render_buffer = (RenderBufferDataHighEnd *)render_buffers_get_data(p_render_buffer);
@@ -2228,7 +2158,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
bool using_ssr = false;
if (render_buffer) {
-
screen_pixel_size.width = 1.0 / render_buffer->width;
screen_pixel_size.height = 1.0 / render_buffer->height;
screen_size.x = render_buffer->width;
@@ -2350,7 +2279,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
keep_color = true;
} break;
case RS::ENV_BG_CAMERA_FEED: {
-
} break;
default: {
}
@@ -2359,7 +2287,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
if (draw_sky || environment_get_reflection_source(p_environment) == RS::ENV_REFLECTION_SOURCE_SKY || environment_get_ambient_source(p_environment) == RS::ENV_AMBIENT_SOURCE_SKY) {
RID sky = environment_get_sky(p_environment);
if (sky.is_valid()) {
-
RENDER_TIMESTAMP("Setup Sky");
CameraMatrix projection = p_cam_projection;
if (p_reflection_probe.is_valid()) {
@@ -2377,7 +2304,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
}
}
} else {
-
clear_color = p_default_bg_color;
}
@@ -2438,7 +2364,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
bool can_continue_depth = !scene_state.used_depth_texture && !using_ssr && !using_sss;
{
-
bool will_continue_color = (can_continue_color || draw_sky || debug_giprobes);
bool will_continue_depth = (can_continue_depth || draw_sky || debug_giprobes);
@@ -2494,7 +2419,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
}
if (render_buffer && !can_continue_color && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
-
RD::get_singleton()->texture_resolve_multisample(render_buffer->color_msaa, render_buffer->color, true);
if (using_separate_specular) {
RD::get_singleton()->texture_resolve_multisample(render_buffer->specular_msaa, render_buffer->specular, true);
@@ -2502,12 +2426,10 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
}
if (render_buffer && !can_continue_depth && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
-
RD::get_singleton()->texture_resolve_multisample(render_buffer->depth_msaa, render_buffer->depth, true);
}
if (using_separate_specular) {
-
if (using_sss) {
RENDER_TIMESTAMP("Sub Surface Scattering");
_process_sss(p_render_buffer, p_cam_projection);
@@ -2538,13 +2460,11 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
}
if (render_buffer && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
-
RD::get_singleton()->texture_resolve_multisample(render_buffer->color_msaa, render_buffer->color, true);
}
}
void RasterizerSceneHighEndRD::_render_shadow(RID p_framebuffer, InstanceBase **p_cull_result, int p_cull_count, const CameraMatrix &p_projection, const Transform &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake) {
-
RENDER_TIMESTAMP("Setup Rendering Shadow");
_update_render_base_uniform_set();
@@ -2678,7 +2598,6 @@ void RasterizerSceneHighEndRD::_render_uv2(InstanceBase **p_cull_result, int p_c
}
void RasterizerSceneHighEndRD::_base_uniforms_changed() {
-
if (!render_base_uniform_set.is_null() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
RD::get_singleton()->free(render_base_uniform_set);
}
@@ -2686,9 +2605,7 @@ void RasterizerSceneHighEndRD::_base_uniforms_changed() {
}
void RasterizerSceneHighEndRD::_update_render_base_uniform_set() {
-
if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != storage->lightmap_array_get_version())) {
-
if (render_base_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) {
RD::get_singleton()->free(render_base_uniform_set);
}
@@ -2782,7 +2699,6 @@ void RasterizerSceneHighEndRD::_update_render_base_uniform_set() {
}
for (int i = 0; i < slot_count; i++) {
-
RID probe = gi_probe_get_slots()[i];
if (gi_probe_is_anisotropic()) {
@@ -2892,7 +2808,6 @@ void RasterizerSceneHighEndRD::_update_render_base_uniform_set() {
}
void RasterizerSceneHighEndRD::_setup_view_dependant_uniform_set(RID p_shadow_atlas, RID p_reflection_atlas) {
-
if (view_dependant_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(view_dependant_uniform_set)) {
RD::get_singleton()->free(view_dependant_uniform_set);
}
@@ -2902,7 +2817,6 @@ void RasterizerSceneHighEndRD::_setup_view_dependant_uniform_set(RID p_shadow_at
Vector<RD::Uniform> uniforms;
{
-
RID ref_texture = p_reflection_atlas.is_valid() ? reflection_atlas_get_texture(p_reflection_atlas) : RID();
RD::Uniform u;
u.binding = 0;
@@ -2934,7 +2848,6 @@ void RasterizerSceneHighEndRD::_setup_view_dependant_uniform_set(RID p_shadow_at
}
void RasterizerSceneHighEndRD::_render_buffers_clear_uniform_set(RenderBufferDataHighEnd *rb) {
-
if (!rb->uniform_set.is_null() && RD::get_singleton()->uniform_set_is_valid(rb->uniform_set)) {
RD::get_singleton()->free(rb->uniform_set);
}
@@ -2942,7 +2855,6 @@ void RasterizerSceneHighEndRD::_render_buffers_clear_uniform_set(RenderBufferDat
}
void RasterizerSceneHighEndRD::_render_buffers_uniform_set_changed(RID p_render_buffers) {
-
RenderBufferDataHighEnd *rb = (RenderBufferDataHighEnd *)render_buffers_get_data(p_render_buffers);
_render_buffers_clear_uniform_set(rb);
@@ -2961,11 +2873,9 @@ RID RasterizerSceneHighEndRD::_render_buffers_get_normal_texture(RID p_render_bu
}
void RasterizerSceneHighEndRD::_update_render_buffers_uniform_set(RID p_render_buffers) {
-
RenderBufferDataHighEnd *rb = (RenderBufferDataHighEnd *)render_buffers_get_data(p_render_buffers);
if (rb->uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(rb->uniform_set)) {
-
Vector<RD::Uniform> uniforms;
{
RD::Uniform u;
@@ -3120,7 +3030,6 @@ RasterizerSceneHighEndRD::RasterizerSceneHighEndRD(RasterizerStorageRD *p_storag
}
{
-
defines += "\n#define MATERIAL_UNIFORM_SET " + itos(MATERIAL_UNIFORM_SET) + "\n";
}
@@ -3294,7 +3203,6 @@ RasterizerSceneHighEndRD::RasterizerSceneHighEndRD(RasterizerStorageRD *p_storag
render_pass = 0;
{
-
scene_state.max_instances = render_list.max_elements;
scene_state.instances = memnew_arr(InstanceData, scene_state.max_instances);
scene_state.instance_buffer = RD::get_singleton()->storage_buffer_create(sizeof(InstanceData) * scene_state.max_instances);
@@ -3314,7 +3222,6 @@ RasterizerSceneHighEndRD::RasterizerSceneHighEndRD(RasterizerStorageRD *p_storag
}
{
-
overdraw_material_shader = storage->shader_create();
storage->shader_set_code(overdraw_material_shader, "shader_type spatial;\nrender_mode blend_add,unshaded;\n void fragment() { ALBEDO=vec3(0.4,0.8,0.8); ALPHA=0.2; }");
overdraw_material = storage->material_create();
@@ -3338,7 +3245,6 @@ RasterizerSceneHighEndRD::RasterizerSceneHighEndRD(RasterizerStorageRD *p_storag
default_vec4_xform_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, default_shader_rd, TRANSFORMS_UNIFORM_SET);
}
{
-
RD::SamplerState sampler;
sampler.mag_filter = RD::SAMPLER_FILTER_LINEAR;
sampler.min_filter = RD::SAMPLER_FILTER_LINEAR;
diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h
index e8736a0e53..8438a4f730 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h
@@ -38,7 +38,6 @@
#include "servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl.gen.h"
class RasterizerSceneHighEndRD : public RasterizerSceneRD {
-
enum {
SCENE_UNIFORM_SET = 0,
RADIANCE_UNIFORM_SET = 1,
@@ -75,7 +74,6 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
/* Material */
struct ShaderData : public RasterizerStorageRD::ShaderData {
-
enum BlendMode { //used internally
BLEND_MODE_MIX,
BLEND_MODE_ADD,
@@ -288,7 +286,6 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
};
struct DirectionalLightData {
-
float direction[3];
float energy;
float color[3];
@@ -489,7 +486,6 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
/* Render List */
struct RenderList {
-
int max_elements;
struct Element {
@@ -520,7 +516,6 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
int alpha_element_count;
void clear() {
-
element_count = 0;
alpha_element_count = 0;
}
@@ -528,14 +523,12 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
//should eventually be replaced by radix
struct SortByKey {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
return A->sort_key < B->sort_key;
}
};
void sort_by_key(bool p_alpha) {
-
SortArray<Element *, SortByKey> sorter;
if (p_alpha) {
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
@@ -545,7 +538,6 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
}
struct SortByDepth {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
return A->instance->depth < B->instance->depth;
}
@@ -562,7 +554,6 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
}
struct SortByReverseDepthAndPriority {
-
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
uint32_t layer_A = uint32_t(A->priority);
uint32_t layer_B = uint32_t(B->priority);
@@ -585,17 +576,17 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
}
_FORCE_INLINE_ Element *add_element() {
-
- if (element_count + alpha_element_count >= max_elements)
+ if (element_count + alpha_element_count >= max_elements) {
return nullptr;
+ }
elements[element_count] = &base_elements[element_count];
return elements[element_count++];
}
_FORCE_INLINE_ Element *add_alpha_element() {
-
- if (element_count + alpha_element_count >= max_elements)
+ if (element_count + alpha_element_count >= max_elements) {
return nullptr;
+ }
int idx = max_elements - alpha_element_count - 1;
elements[idx] = &base_elements[idx];
alpha_element_count++;
@@ -603,17 +594,16 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
}
void init() {
-
element_count = 0;
alpha_element_count = 0;
elements = memnew_arr(Element *, max_elements);
base_elements = memnew_arr(Element, max_elements);
- for (int i = 0; i < max_elements; i++)
+ for (int i = 0; i < max_elements; i++) {
elements[i] = &base_elements[i]; // assign elements
+ }
}
RenderList() {
-
max_elements = 0;
}
diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
index 02221d1536..689552be2f 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
@@ -49,7 +49,6 @@ void get_vogel_disk(float *r_kernel, int p_sample_count) {
}
void RasterizerSceneRD::_clear_reflection_data(ReflectionData &rd) {
-
rd.layers.clear();
rd.radiance_base_cubemap = RID();
if (rd.downsampled_radiance_cubemap.is_valid()) {
@@ -152,7 +151,6 @@ void RasterizerSceneRD::_update_reflection_data(ReflectionData &rd, int p_size,
}
void RasterizerSceneRD::_create_reflection_fast_filter(ReflectionData &rd, bool p_use_arrays) {
-
storage->get_effects()->cubemap_downsample(rd.radiance_base_cubemap, rd.downsampled_layer.mipmaps[0].view, rd.downsampled_layer.mipmaps[0].size);
for (int i = 1; i < rd.downsampled_layer.mipmaps.size(); i++) {
@@ -174,21 +172,16 @@ void RasterizerSceneRD::_create_reflection_fast_filter(ReflectionData &rd, bool
}
void RasterizerSceneRD::_create_reflection_importance_sample(ReflectionData &rd, bool p_use_arrays, int p_cube_side, int p_base_layer) {
-
if (p_use_arrays) {
-
//render directly to the layers
storage->get_effects()->cubemap_roughness(rd.radiance_base_cubemap, rd.layers[p_base_layer].views[0], p_cube_side, sky_ggx_samples_quality, float(p_base_layer) / (rd.layers.size() - 1.0), rd.layers[p_base_layer].mipmaps[0].size.x);
} else {
-
storage->get_effects()->cubemap_roughness(rd.layers[0].views[p_base_layer - 1], rd.layers[0].views[p_base_layer], p_cube_side, sky_ggx_samples_quality, float(p_base_layer) / (rd.layers[0].mipmaps.size() - 1.0), rd.layers[0].mipmaps[p_base_layer].size.x);
}
}
void RasterizerSceneRD::_update_reflection_mipmaps(ReflectionData &rd) {
-
if (sky_use_cubemap_array) {
-
for (int i = 0; i < rd.layers.size(); i++) {
for (int j = 0; j < rd.layers[i].mipmaps.size() - 1; j++) {
for (int k = 0; k < 6; k++) {
@@ -267,14 +260,12 @@ void RasterizerSceneRD::sky_set_material(RID p_sky, RID p_material) {
}
Ref<Image> RasterizerSceneRD::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) {
-
Sky *sky = sky_owner.getornull(p_sky);
ERR_FAIL_COND_V(!sky, Ref<Image>());
_update_dirty_skys();
if (sky->radiance.is_valid()) {
-
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
tf.width = p_size.width;
@@ -305,11 +296,9 @@ Ref<Image> RasterizerSceneRD::sky_bake_panorama(RID p_sky, float p_energy, bool
}
void RasterizerSceneRD::_update_dirty_skys() {
-
Sky *sky = dirty_sky_list;
while (sky) {
-
bool texture_set_dirty = false;
//update sky configuration if texture is missing
@@ -421,7 +410,6 @@ RID RasterizerSceneRD::sky_get_radiance_uniform_set_rd(RID p_sky, RID p_shader,
ERR_FAIL_COND_V(!sky, RID());
if (sky->uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(sky->uniform_set)) {
-
sky->uniform_set = RID();
if (sky->radiance.is_valid()) {
Vector<RD::Uniform> uniforms;
@@ -441,7 +429,6 @@ RID RasterizerSceneRD::sky_get_radiance_uniform_set_rd(RID p_sky, RID p_shader,
}
RID RasterizerSceneRD::_get_sky_textures(Sky *p_sky, SkyTextureSetVersion p_version) {
-
if (p_sky->texture_uniform_sets[p_version].is_valid() && RD::get_singleton()->uniform_set_is_valid(p_sky->texture_uniform_sets[p_version])) {
return p_sky->texture_uniform_sets[p_version];
}
@@ -508,7 +495,6 @@ RID RasterizerSceneRD::sky_get_material(RID p_sky) const {
}
void RasterizerSceneRD::_draw_sky(bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform) {
-
ERR_FAIL_COND(!is_environment(p_environment));
Sky *sky = sky_owner.getornull(environment_get_sky(p_environment));
@@ -545,7 +531,6 @@ void RasterizerSceneRD::_draw_sky(bool p_can_continue_color, bool p_can_continue
CameraMatrix camera;
if (custom_fov) {
-
float near_plane = p_projection.get_z_near();
float far_plane = p_projection.get_z_far();
float aspect = p_projection.get_aspect();
@@ -594,7 +579,6 @@ void RasterizerSceneRD::_draw_sky(bool p_can_continue_color, bool p_can_continue
}
void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position, const Size2i p_screen_size) {
-
ERR_FAIL_COND(!is_environment(p_environment));
Sky *sky = sky_owner.getornull(environment_get_sky(p_environment));
@@ -652,26 +636,22 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position,
}
if (shader_data->uses_time && time - sky->prev_time > 0.00001) {
-
sky->prev_time = time;
sky->reflection.dirty = true;
RenderingServerRaster::redraw_request();
}
if (material != sky->prev_material) {
-
sky->prev_material = material;
sky->reflection.dirty = true;
}
if (material->uniform_set_updated) {
-
material->uniform_set_updated = false;
sky->reflection.dirty = true;
}
if (!p_position.is_equal_approx(sky->prev_position) && shader_data->uses_position) {
-
sky->prev_position = p_position;
sky->reflection.dirty = true;
}
@@ -704,7 +684,6 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position,
}
if (light_data_dirty || sky_scene_state.light_uniform_set.is_null()) {
-
RD::get_singleton()->buffer_update(sky_scene_state.directional_light_buffer, 0, sizeof(SkyDirectionalLightData) * sky_scene_state.max_directional_lights, sky_scene_state.directional_lights, true);
if (sky_scene_state.light_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sky_scene_state.light_uniform_set)) {
@@ -732,7 +711,6 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position,
}
void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform) {
-
ERR_FAIL_COND(!is_environment(p_environment));
Sky *sky = sky_owner.getornull(environment_get_sky(p_environment));
@@ -764,7 +742,6 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro
// Update radiance cubemap
if (sky->reflection.dirty) {
-
static const Vector3 view_normals[6] = {
Vector3(+1, 0, 0),
Vector3(-1, 0, 0),
@@ -945,7 +922,6 @@ void RasterizerSceneRD::SkyShaderData::set_code(const String &p_code) {
//update pipelines
for (int i = 0; i < SKY_VERSION_MAX; i++) {
-
RD::PipelineDepthStencilState depth_stencil_state;
depth_stencil_state.enable_depth_test = true;
depth_stencil_state.depth_compare_operator = RD::COMPARE_OP_LESS_OR_EQUAL;
@@ -966,11 +942,9 @@ void RasterizerSceneRD::SkyShaderData::set_default_texture_param(const StringNam
}
void RasterizerSceneRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_param_list) const {
-
Map<int, StringName> order;
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
-
if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
@@ -983,7 +957,6 @@ void RasterizerSceneRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_para
}
for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) {
-
PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]);
pi.name = E->get();
p_param_list->push_back(pi);
@@ -991,9 +964,7 @@ void RasterizerSceneRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_para
}
void RasterizerSceneRD::SkyShaderData::get_instance_param_list(List<RasterizerStorage::InstanceShaderParam> *p_param_list) const {
-
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) {
-
if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue;
}
@@ -1051,7 +1022,6 @@ RasterizerStorageRD::ShaderData *RasterizerSceneRD::_create_sky_shader_func() {
}
void RasterizerSceneRD::SkyMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) {
-
RasterizerSceneRD *scene_singleton = (RasterizerSceneRD *)RasterizerSceneRD::singleton;
uniform_set_updated = true;
@@ -1078,7 +1048,6 @@ void RasterizerSceneRD::SkyMaterialData::update_parameters(const Map<StringName,
//check whether buffer changed
if (p_uniform_dirty && ubo_data.size()) {
-
update_uniform_buffer(shader_data->uniforms, shader_data->ubo_offsets.ptr(), p_parameters, ubo_data.ptrw(), ubo_data.size(), false);
RD::get_singleton()->buffer_update(uniform_buffer, 0, ubo_data.size(), ubo_data.ptrw());
}
@@ -1097,7 +1066,6 @@ void RasterizerSceneRD::SkyMaterialData::update_parameters(const Map<StringName,
}
if (p_textures_dirty && tex_uniform_count) {
-
update_textures(p_parameters, shader_data->default_texture_params, shader_data->texture_uniforms, texture_cache.ptrw(), true);
}
@@ -1114,7 +1082,6 @@ void RasterizerSceneRD::SkyMaterialData::update_parameters(const Map<StringName,
Vector<RD::Uniform> uniforms;
{
-
if (shader_data->ubo_size) {
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_UNIFORM_BUFFER;
@@ -1155,7 +1122,6 @@ RasterizerStorageRD::MaterialData *RasterizerSceneRD::_create_sky_material_func(
}
RID RasterizerSceneRD::environment_create() {
-
return environment_owner.make_rid(Environent());
}
@@ -1164,36 +1130,43 @@ void RasterizerSceneRD::environment_set_background(RID p_env, RS::EnvironmentBG
ERR_FAIL_COND(!env);
env->background = p_bg;
}
+
void RasterizerSceneRD::environment_set_sky(RID p_env, RID p_sky) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->sky = p_sky;
}
+
void RasterizerSceneRD::environment_set_sky_custom_fov(RID p_env, float p_scale) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->sky_custom_fov = p_scale;
}
+
void RasterizerSceneRD::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->sky_orientation = p_orientation;
}
+
void RasterizerSceneRD::environment_set_bg_color(RID p_env, const Color &p_color) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->bg_color = p_color;
}
+
void RasterizerSceneRD::environment_set_bg_energy(RID p_env, float p_energy) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->bg_energy = p_energy;
}
+
void RasterizerSceneRD::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->canvas_max_layer = p_max_layer;
}
+
void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -1210,56 +1183,67 @@ RS::EnvironmentBG RasterizerSceneRD::environment_get_background(RID p_env) const
ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX);
return env->background;
}
+
RID RasterizerSceneRD::environment_get_sky(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, RID());
return env->sky;
}
+
float RasterizerSceneRD::environment_get_sky_custom_fov(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->sky_custom_fov;
}
+
Basis RasterizerSceneRD::environment_get_sky_orientation(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, Basis());
return env->sky_orientation;
}
+
Color RasterizerSceneRD::environment_get_bg_color(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->bg_color;
}
+
float RasterizerSceneRD::environment_get_bg_energy(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->bg_energy;
}
+
int RasterizerSceneRD::environment_get_canvas_max_layer(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->canvas_max_layer;
}
+
Color RasterizerSceneRD::environment_get_ambient_light_color(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, Color());
return env->ambient_light;
}
+
RS::EnvironmentAmbientSource RasterizerSceneRD::environment_get_ambient_source(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG);
return env->ambient_source;
}
+
float RasterizerSceneRD::environment_get_ambient_light_energy(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->ambient_light_energy;
}
+
float RasterizerSceneRD::environment_get_ambient_sky_contribution(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, 0);
return env->ambient_sky_contribution;
}
+
RS::EnvironmentReflectionSource RasterizerSceneRD::environment_get_reflection_source(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED);
@@ -1289,7 +1273,6 @@ void RasterizerSceneRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMa
}
void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {
-
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
env->glow_enabled = p_enable;
@@ -1309,7 +1292,6 @@ void RasterizerSceneRD::environment_glow_set_use_bicubic_upscale(bool p_enable)
}
void RasterizerSceneRD::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) {
-
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -1329,7 +1311,6 @@ RS::EnvironmentSSRRoughnessQuality RasterizerSceneRD::environment_get_ssr_roughn
}
void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {
-
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND(!env);
@@ -1348,7 +1329,6 @@ void RasterizerSceneRD::environment_set_ssao_quality(RS::EnvironmentSSAOQuality
}
bool RasterizerSceneRD::environment_is_ssao_enabled(RID p_env) const {
-
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, false);
return env->ssao_enabled;
@@ -1359,6 +1339,7 @@ float RasterizerSceneRD::environment_get_ssao_ao_affect(RID p_env) const {
ERR_FAIL_COND_V(!env, false);
return env->ssao_ao_channel_affect;
}
+
float RasterizerSceneRD::environment_get_ssao_light_affect(RID p_env) const {
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, false);
@@ -1366,7 +1347,6 @@ float RasterizerSceneRD::environment_get_ssao_light_affect(RID p_env) const {
}
bool RasterizerSceneRD::environment_is_ssr_enabled(RID p_env) const {
-
Environent *env = environment_owner.getornull(p_env);
ERR_FAIL_COND_V(!env, false);
return env->ssr_enabled;
@@ -1416,7 +1396,6 @@ Ref<Image> RasterizerSceneRD::environment_bake_panorama(RID p_env, bool p_bake_i
////////////////////////////////////////////////////////////
RID RasterizerSceneRD::reflection_atlas_create() {
-
ReflectionAtlas ra;
ra.count = GLOBAL_GET("rendering/quality/reflection_atlas/reflection_count");
ra.size = GLOBAL_GET("rendering/quality/reflection_atlas/reflection_size");
@@ -1425,7 +1404,6 @@ RID RasterizerSceneRD::reflection_atlas_create() {
}
void RasterizerSceneRD::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
-
ReflectionAtlas *ra = reflection_atlas_owner.getornull(p_ref_atlas);
ERR_FAIL_COND(!ra);
@@ -1472,7 +1450,6 @@ void RasterizerSceneRD::reflection_probe_instance_set_transform(RID p_instance,
}
void RasterizerSceneRD::reflection_probe_release_atlas_index(RID p_instance) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND(!rpi);
@@ -1488,7 +1465,6 @@ void RasterizerSceneRD::reflection_probe_release_atlas_index(RID p_instance) {
}
bool RasterizerSceneRD::reflection_probe_instance_needs_redraw(RID p_instance) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
@@ -1508,7 +1484,6 @@ bool RasterizerSceneRD::reflection_probe_instance_needs_redraw(RID p_instance) {
}
bool RasterizerSceneRD::reflection_probe_instance_has_reflection(RID p_instance) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
@@ -1516,7 +1491,6 @@ bool RasterizerSceneRD::reflection_probe_instance_has_reflection(RID p_instance)
}
bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
-
ReflectionAtlas *atlas = reflection_atlas_owner.getornull(p_reflection_atlas);
ERR_FAIL_COND_V(!atlas, false);
@@ -1561,7 +1535,6 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R
atlas->reflection = RD::get_singleton()->texture_create(tf, RD::TextureView());
}
{
-
RD::TextureFormat tf;
tf.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_D32_SFLOAT, RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ? RD::DATA_FORMAT_D32_SFLOAT : RD::DATA_FORMAT_X8_D24_UNORM_PACK32;
tf.width = atlas->size;
@@ -1617,7 +1590,6 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R
}
bool RasterizerSceneRD::reflection_probe_instance_postprocess_step(RID p_instance) {
-
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!rpi, false);
ERR_FAIL_COND_V(!rpi->rendering, false);
@@ -1695,19 +1667,18 @@ RID RasterizerSceneRD::reflection_probe_instance_get_depth_framebuffer(RID p_ins
///////////////////////////////////////////////////////////
RID RasterizerSceneRD::shadow_atlas_create() {
-
return shadow_atlas_owner.make_rid(ShadowAtlas());
}
void RasterizerSceneRD::shadow_atlas_set_size(RID p_atlas, int p_size) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(p_size < 0);
p_size = next_power_of_2(p_size);
- if (p_size == shadow_atlas->size)
+ if (p_size == shadow_atlas->size) {
return;
+ }
// erasing atlas
if (shadow_atlas->depth.is_valid()) {
@@ -1733,7 +1704,6 @@ void RasterizerSceneRD::shadow_atlas_set_size(RID p_atlas, int p_size) {
shadow_atlas->size = p_size;
if (shadow_atlas->size) {
-
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R32_SFLOAT;
tf.width = shadow_atlas->size;
@@ -1745,7 +1715,6 @@ void RasterizerSceneRD::shadow_atlas_set_size(RID p_atlas, int p_size) {
}
void RasterizerSceneRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_INDEX(p_quadrant, 4);
@@ -1760,12 +1729,12 @@ void RasterizerSceneRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p
//obtain the number that will be x*x
- if (shadow_atlas->quadrants[p_quadrant].subdivision == subdiv)
+ if (shadow_atlas->quadrants[p_quadrant].subdivision == subdiv) {
return;
+ }
//erase all data from quadrant
for (int i = 0; i < shadow_atlas->quadrants[p_quadrant].shadows.size(); i++) {
-
if (shadow_atlas->quadrants[p_quadrant].shadows[i].owner.is_valid()) {
shadow_atlas->shadow_owners.erase(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
LightInstance *li = light_instance_owner.getornull(shadow_atlas->quadrants[p_quadrant].shadows[i].owner);
@@ -1808,9 +1777,7 @@ void RasterizerSceneRD::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p
}
bool RasterizerSceneRD::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_in_quadrants, int p_quadrant_count, int p_current_subdiv, uint64_t p_tick, int &r_quadrant, int &r_shadow) {
-
for (int i = p_quadrant_count - 1; i >= 0; i--) {
-
int qidx = p_in_quadrants[i];
if (shadow_atlas->quadrants[qidx].subdivision == (uint32_t)p_current_subdiv) {
@@ -1835,10 +1802,10 @@ bool RasterizerSceneRD::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int
ERR_CONTINUE(!sli);
if (sli->last_scene_pass != scene_pass) {
-
//was just allocated, don't kill it so soon, wait a bit..
- if (p_tick - sarr[j].alloc_tick < shadow_atlas_realloc_tolerance_msec)
+ if (p_tick - sarr[j].alloc_tick < shadow_atlas_realloc_tolerance_msec) {
continue;
+ }
if (found_used_idx == -1 || sli->last_scene_pass < min_pass) {
found_used_idx = j;
@@ -1847,8 +1814,9 @@ bool RasterizerSceneRD::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int
}
}
- if (found_free_idx == -1 && found_used_idx == -1)
+ if (found_free_idx == -1 && found_used_idx == -1) {
continue; //nothing found
+ }
if (found_free_idx == -1 && found_used_idx != -1) {
found_free_idx = found_used_idx;
@@ -1864,7 +1832,6 @@ bool RasterizerSceneRD::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int
}
bool RasterizerSceneRD::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas);
ERR_FAIL_COND_V(!shadow_atlas, false);
@@ -1887,13 +1854,15 @@ bool RasterizerSceneRD::shadow_atlas_update_light(RID p_atlas, RID p_light_intan
for (int i = 0; i < 4; i++) {
int q = shadow_atlas->size_order[i];
int sd = shadow_atlas->quadrants[q].subdivision;
- if (sd == 0)
+ if (sd == 0) {
continue; //unused
+ }
int max_fit = quad_size / sd;
- if (best_size != -1 && max_fit > best_size)
+ if (best_size != -1 && max_fit > best_size) {
break; //too large
+ }
valid_quadrants[valid_quadrant_count++] = q;
best_subdiv = sd;
@@ -1998,7 +1967,6 @@ bool RasterizerSceneRD::shadow_atlas_update_light(RID p_atlas, RID p_light_intan
}
void RasterizerSceneRD::directional_shadow_atlas_set_size(int p_size) {
-
p_size = nearest_power_of_2_templated(p_size);
if (directional_shadow.size == p_size) {
@@ -2013,7 +1981,6 @@ void RasterizerSceneRD::directional_shadow_atlas_set_size(int p_size) {
}
if (p_size > 0) {
-
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R32_SFLOAT;
tf.width = p_size;
@@ -2027,13 +1994,11 @@ void RasterizerSceneRD::directional_shadow_atlas_set_size(int p_size) {
}
void RasterizerSceneRD::set_directional_shadow_count(int p_count) {
-
directional_shadow.light_count = p_count;
directional_shadow.current_light = 0;
}
static Rect2i _get_directional_shadow_rect(int p_size, int p_shadow_count, int p_shadow_index) {
-
int split_h = 1;
int split_v = 1;
@@ -2056,7 +2021,6 @@ static Rect2i _get_directional_shadow_rect(int p_size, int p_shadow_count, int p
}
int RasterizerSceneRD::get_directional_light_shadow_size(RID p_light_intance) {
-
ERR_FAIL_COND_V(directional_shadow.light_count == 0, 0);
Rect2i r = _get_directional_shadow_rect(directional_shadow.size, directional_shadow.light_count, 0);
@@ -2081,18 +2045,15 @@ int RasterizerSceneRD::get_directional_light_shadow_size(RID p_light_intance) {
//////////////////////////////////////////////////
RID RasterizerSceneRD::camera_effects_create() {
-
return camera_effects_owner.make_rid(CameraEffects());
}
void RasterizerSceneRD::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {
-
dof_blur_quality = p_quality;
dof_blur_use_jitter = p_use_jitter;
}
void RasterizerSceneRD::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {
-
dof_blur_bokeh_shape = p_shape;
}
@@ -2112,7 +2073,6 @@ void RasterizerSceneRD::camera_effects_set_dof_blur(RID p_camera_effects, bool p
}
void RasterizerSceneRD::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {
-
CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects);
ERR_FAIL_COND(!camfx);
@@ -2121,7 +2081,6 @@ void RasterizerSceneRD::camera_effects_set_custom_exposure(RID p_camera_effects,
}
RID RasterizerSceneRD::light_instance_create(RID p_light) {
-
RID li = light_instance_owner.make_rid(LightInstance());
LightInstance *light_instance = light_instance_owner.getornull(li);
@@ -2134,7 +2093,6 @@ RID RasterizerSceneRD::light_instance_create(RID p_light) {
}
void RasterizerSceneRD::light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -2142,7 +2100,6 @@ void RasterizerSceneRD::light_instance_set_transform(RID p_light_instance, const
}
void RasterizerSceneRD::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -2163,7 +2120,6 @@ void RasterizerSceneRD::light_instance_set_shadow_transform(RID p_light_instance
}
void RasterizerSceneRD::light_instance_mark_visible(RID p_light_instance) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND(!light_instance);
@@ -2171,9 +2127,7 @@ void RasterizerSceneRD::light_instance_mark_visible(RID p_light_instance) {
}
RasterizerSceneRD::ShadowCubemap *RasterizerSceneRD::_get_shadow_cubemap(int p_size) {
-
if (!shadow_cubemaps.has(p_size)) {
-
ShadowCubemap sc;
{
RD::TextureFormat tf;
@@ -2200,9 +2154,7 @@ RasterizerSceneRD::ShadowCubemap *RasterizerSceneRD::_get_shadow_cubemap(int p_s
}
RasterizerSceneRD::ShadowMap *RasterizerSceneRD::_get_shadow_map(const Size2i &p_size) {
-
if (!shadow_maps.has(p_size)) {
-
ShadowMap sm;
{
RD::TextureFormat tf;
@@ -2262,7 +2214,6 @@ RID RasterizerSceneRD::gi_probe_instance_create(RID p_base) {
}
void RasterizerSceneRD::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {
-
GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe);
ERR_FAIL_COND(!gi_probe);
@@ -2278,7 +2229,6 @@ bool RasterizerSceneRD::gi_probe_needs_update(RID p_probe) const {
}
void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, int p_dynamic_object_count, InstanceBase **p_dynamic_objects) {
-
GIProbeInstance *gi_probe = gi_probe_instance_owner.getornull(p_probe);
ERR_FAIL_COND(!gi_probe);
@@ -2530,7 +2480,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
dmap.depth = RD::get_singleton()->texture_create(dtf, RD::TextureView());
if (gi_probe->dynamic_maps.size() == 0) {
-
dtf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
dtf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
dmap.albedo = RD::get_singleton()->texture_create(dtf, RD::TextureView());
@@ -2638,7 +2587,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
}
if (write) {
-
{
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_IMAGE;
@@ -2671,7 +2619,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
}
if (plot) {
-
{
RD::Uniform u;
u.type = RD::UNIFORM_TYPE_IMAGE;
@@ -2725,7 +2672,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
uint32_t light_count = 0;
if (p_update_light_instances || p_dynamic_object_count > 0) {
-
light_count = MIN(gi_probe_max_lights, (uint32_t)p_light_instances.size());
{
@@ -2805,9 +2751,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
int wg_limit_x = RD::get_singleton()->limit_get(RD::LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_X);
for (int pass = 0; pass < passes; pass++) {
-
if (p_update_light_instances) {
-
for (int i = 0; i < gi_probe->mipmaps.size(); i++) {
if (i == 0) {
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[pass == 0 ? GI_PROBE_SHADER_VERSION_COMPUTE_LIGHT : GI_PROBE_SHADER_VERSION_COMPUTE_SECOND_BOUNCE]);
@@ -2843,7 +2787,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, giprobe_lighting_shader_version_pipelines[GI_PROBE_SHADER_VERSION_WRITE_TEXTURE]);
for (int i = 0; i < gi_probe->mipmaps.size(); i++) {
-
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, gi_probe->mipmaps[i].write_uniform_set, 0);
push_constant.cell_offset = gi_probe->mipmaps[i].cell_offset;
@@ -2867,7 +2810,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
gi_probe->has_dynamic_object_data = false; //clear until dynamic object data is used again
if (p_dynamic_object_count && gi_probe->dynamic_maps.size()) {
-
Vector3i octree_size = storage->gi_probe_get_octree_size(gi_probe->probe);
int multiplier = gi_probe->dynamic_maps[0].size / MAX(MAX(octree_size.x, octree_size.y), octree_size.z);
@@ -2882,7 +2824,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
//this could probably be better parallelized in compute..
for (int i = 0; i < p_dynamic_object_count; i++) {
-
InstanceBase *instance = p_dynamic_objects[i];
//not used, so clear
instance->depth_layer = 0;
@@ -2911,7 +2852,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
//print_line("aabb: " + aabb);
for (int j = 0; j < 6; j++) {
-
//if (j != 0 && j != 3) {
// continue;
//}
@@ -3000,7 +2940,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
//print_line("rect: " + itos(i) + ": " + rect);
for (int k = 1; k < gi_probe->dynamic_maps.size(); k++) {
-
// enlarge the rect if needed so all pixels fit when downscaled,
// this ensures downsampling is smooth and optimal because no pixels are left behind
@@ -3098,7 +3037,6 @@ void RasterizerSceneRD::_debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_lis
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
-
push_constant.projection[i * 4 + j] = transform.matrix[i][j];
}
}
@@ -3161,7 +3099,6 @@ void RasterizerSceneRD::_debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_lis
}
const Vector<RID> &RasterizerSceneRD::gi_probe_get_slots() const {
-
return gi_probe_slots;
}
@@ -3200,7 +3137,6 @@ void RasterizerSceneRD::_allocate_blur_textures(RenderBuffers *rb) {
int base_height = rb->height;
for (uint32_t i = 0; i < mipmaps_required; i++) {
-
RenderBuffers::Blur::Mipmap mm;
mm.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), rb->blur[0].texture, 0, i);
@@ -3210,7 +3146,6 @@ void RasterizerSceneRD::_allocate_blur_textures(RenderBuffers *rb) {
rb->blur[0].mipmaps.push_back(mm);
if (i > 0) {
-
mm.texture = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), rb->blur[1].texture, 0, i - 1);
rb->blur[1].mipmaps.push_back(mm);
@@ -3255,7 +3190,6 @@ void RasterizerSceneRD::_allocate_luminance_textures(RenderBuffers *rb) {
}
void RasterizerSceneRD::_free_render_buffer_data(RenderBuffers *rb) {
-
if (rb->texture.is_valid()) {
RD::get_singleton()->free(rb->texture);
rb->texture = RID();
@@ -3321,7 +3255,6 @@ void RasterizerSceneRD::_free_render_buffer_data(RenderBuffers *rb) {
}
void RasterizerSceneRD::_process_sss(RID p_render_buffers, const CameraMatrix &p_camera) {
-
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(!rb);
@@ -3341,7 +3274,6 @@ void RasterizerSceneRD::_process_sss(RID p_render_buffers, const CameraMatrix &p
}
void RasterizerSceneRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_buffer, RID p_roughness_buffer, RID p_specular_buffer, RID p_metallic, const Color &p_metallic_mask, RID p_environment, const CameraMatrix &p_projection, bool p_use_additive) {
-
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(!rb);
@@ -3395,7 +3327,6 @@ void RasterizerSceneRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffe
}
void RasterizerSceneRD::_process_ssao(RID p_render_buffers, RID p_environment, RID p_normal_buffer, const CameraMatrix &p_projection) {
-
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(!rb);
@@ -3463,7 +3394,6 @@ void RasterizerSceneRD::_process_ssao(RID p_render_buffers, RID p_environment, R
}
void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_buffers, RID p_environment, RID p_camera_effects, const CameraMatrix &p_projection) {
-
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND(!rb);
@@ -3474,7 +3404,6 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
bool can_use_effects = rb->width >= 8 && rb->height >= 8;
if (can_use_effects && camfx && (camfx->dof_blur_near_enabled || camfx->dof_blur_far_enabled) && camfx->dof_blur_amount > 0.0) {
-
if (rb->blur[0].texture.is_null()) {
_allocate_blur_textures(rb);
_render_buffers_uniform_set_changed(p_render_buffers);
@@ -3485,7 +3414,6 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
}
if (can_use_effects && env && env->auto_exposure) {
-
if (rb->luminance.current.is_null()) {
_allocate_luminance_textures(rb);
_render_buffers_uniform_set_changed(p_render_buffers);
@@ -3506,7 +3434,6 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
int glow_mask = 0;
if (can_use_effects && env && env->glow_enabled) {
-
/* see that blur textures are allocated */
if (rb->blur[0].texture.is_null()) {
@@ -3516,7 +3443,6 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) {
if (env->glow_levels & (1 << i)) {
-
if (i >= rb->blur[1].mipmaps.size()) {
max_glow_level = rb->blur[1].mipmaps.size() - 1;
glow_mask |= 1 << max_glow_level;
@@ -3529,7 +3455,6 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
}
for (int i = 0; i < (max_glow_level + 1); i++) {
-
int vp_w = rb->blur[1].mipmaps[i].width;
int vp_h = rb->blur[1].mipmaps[i].height;
@@ -3556,7 +3481,6 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu
tonemap.exposure_texture = rb->luminance.current;
tonemap.auto_exposure_grey = env->auto_exp_scale;
} else {
-
tonemap.exposure_texture = storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_WHITE);
}
@@ -3651,7 +3575,6 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s
}
RID RasterizerSceneRD::render_buffers_get_back_buffer_texture(RID p_render_buffers) {
-
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
ERR_FAIL_COND_V(!rb, RID());
if (!rb->blur[0].texture.is_valid()) {
@@ -3668,7 +3591,6 @@ RID RasterizerSceneRD::render_buffers_get_ao_texture(RID p_render_buffers) {
}
void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa) {
-
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
rb->width = p_width;
rb->height = p_height;
@@ -3723,7 +3645,6 @@ void RasterizerSceneRD::sub_surface_scattering_set_scale(float p_scale, float p_
}
void RasterizerSceneRD::shadows_quality_set(RS::ShadowQuality p_quality) {
-
ERR_FAIL_INDEX_MSG(p_quality, RS::SHADOW_QUALITY_MAX, "Shadow quality too high, please see RenderingServer's ShadowQuality enum");
if (shadows_quality != p_quality) {
@@ -3764,7 +3685,6 @@ void RasterizerSceneRD::shadows_quality_set(RS::ShadowQuality p_quality) {
}
void RasterizerSceneRD::directional_shadow_quality_set(RS::ShadowQuality p_quality) {
-
ERR_FAIL_INDEX_MSG(p_quality, RS::SHADOW_QUALITY_MAX, "Shadow quality too high, please see RenderingServer's ShadowQuality enum");
if (directional_shadow_quality != p_quality) {
@@ -3819,7 +3739,6 @@ RasterizerSceneRD::RenderBufferData *RasterizerSceneRD::render_buffers_get_data(
}
void RasterizerSceneRD::render_scene(RID p_render_buffers, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID *p_gi_probe_cull_result, int p_gi_probe_cull_count, RID *p_decal_cull_result, int p_decal_cull_count, InstanceBase **p_lightmap_cull_result, int p_lightmap_cull_count, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
-
Color clear_color;
if (p_render_buffers.is_valid()) {
RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers);
@@ -3840,7 +3759,6 @@ void RasterizerSceneRD::render_scene(RID p_render_buffers, const Transform &p_ca
}
void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_light);
ERR_FAIL_COND(!light_instance);
@@ -3882,7 +3800,6 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
atlas_rect.size.height = light_instance->directional_rect.size.y;
if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) {
-
atlas_rect.size.width /= 2;
atlas_rect.size.height /= 2;
@@ -3896,11 +3813,9 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
}
} else if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) {
-
atlas_rect.size.height /= 2;
if (p_pass == 0) {
-
} else {
atlas_rect.position.y += atlas_rect.size.height;
}
@@ -3953,9 +3868,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
normal_bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS);
if (storage->light_get_type(light_instance->light) == RS::LIGHT_OMNI) {
-
if (storage->light_omni_get_shadow_mode(light_instance->light) == RS::LIGHT_OMNI_SHADOW_CUBE) {
-
ShadowCubemap *cubemap = _get_shadow_cubemap(shadow_size / 2);
render_fb = cubemap->side_fb[p_pass];
@@ -3967,7 +3880,6 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
finalize_cubemap = p_pass == 5;
} else {
-
light_projection = light_instance->shadow_transform[0].camera;
light_transform = light_instance->shadow_transform[0].transform;
@@ -3983,7 +3895,6 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
}
} else if (storage->light_get_type(light_instance->light) == RS::LIGHT_SPOT) {
-
light_projection = light_instance->shadow_transform[0].camera;
light_transform = light_instance->shadow_transform[0].transform;
@@ -4024,12 +3935,10 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas
}
void RasterizerSceneRD::render_material(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID p_framebuffer, const Rect2i &p_region) {
-
_render_material(p_cam_transform, p_cam_projection, p_cam_ortogonal, p_cull_result, p_cull_count, p_framebuffer, p_region);
}
bool RasterizerSceneRD::free(RID p_rid) {
-
if (render_buffers_owner.owns(p_rid)) {
RenderBuffers *rb = render_buffers_owner.getornull(p_rid);
_free_render_buffer_data(rb);
@@ -4101,7 +4010,6 @@ bool RasterizerSceneRD::free(RID p_rid) {
sky_owner.free(p_rid);
} else if (light_instance_owner.owns(p_rid)) {
-
LightInstance *light_instance = light_instance_owner.getornull(p_rid);
//remove from shadow atlases..
@@ -4119,7 +4027,6 @@ bool RasterizerSceneRD::free(RID p_rid) {
light_instance_owner.free(p_rid);
} else if (shadow_atlas_owner.owns(p_rid)) {
-
shadow_atlas_set_size(p_rid, 0);
shadow_atlas_owner.free(p_rid);
@@ -4157,7 +4064,6 @@ float RasterizerSceneRD::screen_space_roughness_limiter_get_curve() const {
}
TypedArray<Image> RasterizerSceneRD::bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) {
-
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
tf.width = p_image_size.width; // Always 64x64
@@ -4262,7 +4168,6 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
uint32_t textures_per_stage = RD::get_singleton()->limit_get(RD::LIMIT_MAX_TEXTURES_PER_SHADER_STAGE);
{
-
//kinda complicated to compute the amount of slots, we try to use as many as we can
gi_probe_max_lights = 32;
@@ -4317,7 +4222,6 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
}
{
-
String defines;
if (gi_probe_use_anisotropy) {
defines += "\n#define USE_ANISOTROPY\n";
diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
index 5aaa15f441..781dbd50cc 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
@@ -52,7 +52,6 @@ protected:
// Skys need less info from Directional Lights than the normal shaders
struct SkyDirectionalLightData {
-
float direction[3];
float energy;
float color[3];
@@ -62,7 +61,6 @@ protected:
};
struct SkySceneState {
-
SkyDirectionalLightData *directional_lights;
SkyDirectionalLightData *last_frame_directional_lights;
uint32_t max_directional_lights;
@@ -74,7 +72,6 @@ protected:
} sky_scene_state;
struct RenderBufferData {
-
virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) = 0;
virtual ~RenderBufferData() {}
};
@@ -112,7 +109,6 @@ private:
RasterizerStorageRD *storage;
struct ReflectionData {
-
struct Layer {
struct Mipmap {
RID framebuffers[6];
@@ -287,7 +283,6 @@ private:
/* REFLECTION ATLAS */
struct ReflectionAtlas {
-
int count = 0;
int size = 0;
@@ -309,7 +304,6 @@ private:
/* REFLECTION PROBE INSTANCE */
struct ReflectionProbeInstance {
-
RID probe;
int atlas_index = -1;
RID atlas;
@@ -331,7 +325,6 @@ private:
/* REFLECTION PROBE INSTANCE */
struct DecalInstance {
-
RID decal;
Transform transform;
};
@@ -341,7 +334,6 @@ private:
/* GIPROBE INSTANCE */
struct GIProbeLight {
-
uint32_t type;
float energy;
float radius;
@@ -358,7 +350,6 @@ private:
};
struct GIProbePushConstant {
-
int32_t limits[3];
uint32_t stack_size;
@@ -374,7 +365,6 @@ private:
};
struct GIProbeDynamicPushConstant {
-
int32_t limits[3];
uint32_t light_count;
int32_t x_dir[3];
@@ -396,7 +386,6 @@ private:
};
struct GIProbeInstance {
-
RID probe;
RID texture;
RID anisotropy[2]; //only if anisotropy is used
@@ -496,7 +485,6 @@ private:
/* SHADOW ATLAS */
struct ShadowAtlas {
-
enum {
QUADRANT_SHIFT = 27,
SHADOW_INDEX_MASK = (1 << QUADRANT_SHIFT) - 1,
@@ -504,7 +492,6 @@ private:
};
struct Quadrant {
-
uint32_t subdivision;
struct Shadow {
@@ -568,7 +555,6 @@ private:
/* SHADOW CUBEMAPS */
struct ShadowCubemap {
-
RID cubemap;
RID side_fb[6];
};
@@ -589,9 +575,7 @@ private:
/* LIGHT INSTANCE */
struct LightInstance {
-
struct ShadowTransform {
-
CameraMatrix camera;
Transform transform;
float farplane;
@@ -638,7 +622,6 @@ private:
/* ENVIRONMENT */
struct Environent {
-
// BG
RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR;
RID sky;
@@ -711,7 +694,6 @@ private:
/* CAMERA EFFECTS */
struct CameraEffects {
-
bool dof_blur_far_enabled = false;
float dof_blur_far_distance = 10;
float dof_blur_far_transition = 5;
@@ -738,7 +720,6 @@ private:
/* RENDER BUFFERS */
struct RenderBuffers {
-
RenderBufferData *data = nullptr;
int width = 0, height = 0;
RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED;
@@ -767,7 +748,6 @@ private:
Blur blur[2]; //the second one starts from the first mipmap
struct Luminance {
-
Vector<RID> reduce;
RID current;
} luminance;
@@ -928,7 +908,6 @@ public:
}
_FORCE_INLINE_ Rect2 light_instance_get_shadow_atlas_rect(RID p_light_instance, RID p_shadow_atlas) {
-
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
LightInstance *li = light_instance_owner.getornull(p_light_instance);
uint32_t key = shadow_atlas->shadow_owners[li->self];
@@ -955,13 +934,11 @@ public:
}
_FORCE_INLINE_ CameraMatrix light_instance_get_shadow_camera(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].camera;
}
_FORCE_INLINE_ float light_instance_get_shadow_texel_size(RID p_light_instance, RID p_shadow_atlas) {
-
#ifdef DEBUG_ENABLED
LightInstance *li = light_instance_owner.getornull(p_light_instance);
ERR_FAIL_COND_V(!li->shadow_atlases.has(p_shadow_atlas), 0);
@@ -984,46 +961,38 @@ public:
_FORCE_INLINE_ Transform
light_instance_get_shadow_transform(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].transform;
}
_FORCE_INLINE_ float light_instance_get_shadow_bias_scale(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].bias_scale;
}
_FORCE_INLINE_ float light_instance_get_shadow_range(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].farplane;
}
_FORCE_INLINE_ float light_instance_get_shadow_range_begin(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].range_begin;
}
_FORCE_INLINE_ Vector2 light_instance_get_shadow_uv_scale(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].uv_scale;
}
_FORCE_INLINE_ Rect2 light_instance_get_directional_shadow_atlas_rect(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].atlas_rect;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_split(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].split;
}
_FORCE_INLINE_ float light_instance_get_directional_shadow_texel_size(RID p_light_instance, int p_index) {
-
LightInstance *li = light_instance_owner.getornull(p_light_instance);
return li->shadow_transform[p_index].shadow_texel_size;
}
diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp
index 0203293a76..a5151d1ff8 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp
+++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp
@@ -36,7 +36,6 @@
#include "servers/rendering/shader_language.h"
Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format) {
-
Ref<Image> image = p_image->duplicate();
switch (p_image->get_format()) {
@@ -403,7 +402,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima
} break; //etc2
case Image::FORMAT_ETC2_R11S: {
-
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_EAC_R11_SNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
r_format.format = RD::DATA_FORMAT_EAC_R11_SNORM_BLOCK;
} else {
@@ -481,7 +479,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
} break;
case Image::FORMAT_ETC2_RGB8A1: {
-
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
r_format.format = RD::DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK;
r_format.format_srgb = RD::DATA_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK;
@@ -498,7 +495,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
} break;
case Image::FORMAT_ETC2_RA_AS_RG: {
-
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
r_format.format = RD::DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK;
r_format.format_srgb = RD::DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK;
@@ -609,7 +605,6 @@ RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) {
}
RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) {
-
ERR_FAIL_COND_V(p_layers.size() == 0, RID());
ERR_FAIL_COND_V(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6, RID());
@@ -718,8 +713,8 @@ RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_l
return texture_owner.make_rid(texture);
}
-RID RasterizerStorageRD::texture_3d_create(const Vector<Ref<Image>> &p_slices) {
+RID RasterizerStorageRD::texture_3d_create(const Vector<Ref<Image>> &p_slices) {
return RID();
}
@@ -747,7 +742,6 @@ RID RasterizerStorageRD::texture_proxy_create(RID p_base) {
}
void RasterizerStorageRD::_texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate) {
-
ERR_FAIL_COND(p_image.is_null() || p_image->empty());
Texture *tex = texture_owner.getornull(p_texture);
@@ -772,14 +766,15 @@ void RasterizerStorageRD::_texture_2d_update(RID p_texture, const Ref<Image> &p_
void RasterizerStorageRD::texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer) {
_texture_2d_update(p_texture, p_image, p_layer, true);
}
+
void RasterizerStorageRD::texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer) {
_texture_2d_update(p_texture, p_image, p_layer, false);
}
+
void RasterizerStorageRD::texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) {
}
void RasterizerStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
-
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(!tex->is_proxy);
@@ -820,7 +815,6 @@ void RasterizerStorageRD::texture_proxy_update(RID p_texture, RID p_proxy_to) {
//these two APIs can be used together or in combination with the others.
RID RasterizerStorageRD::texture_2d_placeholder_create() {
-
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
@@ -835,8 +829,8 @@ RID RasterizerStorageRD::texture_2d_placeholder_create() {
return texture_2d_create(image);
}
-RID RasterizerStorageRD::texture_2d_layered_placeholder_create(RS::TextureLayeredType p_layered_type) {
+RID RasterizerStorageRD::texture_2d_layered_placeholder_create(RS::TextureLayeredType p_layered_type) {
//this could be better optimized to reuse an existing image , done this way
//for now to get it working
Ref<Image> image;
@@ -861,13 +855,12 @@ RID RasterizerStorageRD::texture_2d_layered_placeholder_create(RS::TextureLayere
return texture_2d_layered_create(images, p_layered_type);
}
-RID RasterizerStorageRD::texture_3d_placeholder_create() {
+RID RasterizerStorageRD::texture_3d_placeholder_create() {
return RID();
}
Ref<Image> RasterizerStorageRD::texture_2d_get(RID p_texture) const {
-
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!tex, Ref<Image>());
@@ -894,17 +887,16 @@ Ref<Image> RasterizerStorageRD::texture_2d_get(RID p_texture) const {
return image;
}
-Ref<Image> RasterizerStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) const {
+Ref<Image> RasterizerStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) const {
return Ref<Image>();
}
-Ref<Image> RasterizerStorageRD::texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const {
+Ref<Image> RasterizerStorageRD::texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const {
return Ref<Image>();
}
void RasterizerStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
-
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
ERR_FAIL_COND(tex->proxy_to.is_valid()); //cant replace proxy
@@ -943,6 +935,7 @@ void RasterizerStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
decal_atlas.dirty = true; //mark it dirty since it was most likely modified
}
}
+
void RasterizerStorageRD::texture_set_size_override(RID p_texture, int p_width, int p_height) {
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
@@ -956,6 +949,7 @@ void RasterizerStorageRD::texture_set_path(RID p_texture, const String &p_path)
ERR_FAIL_COND(!tex);
tex->path = p_path;
}
+
String RasterizerStorageRD::texture_get_path(RID p_texture) const {
return String();
}
@@ -966,23 +960,27 @@ void RasterizerStorageRD::texture_set_detect_3d_callback(RID p_texture, RS::Text
tex->detect_3d_callback_ud = p_userdata;
tex->detect_3d_callback = p_callback;
}
+
void RasterizerStorageRD::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_normal_callback_ud = p_userdata;
tex->detect_normal_callback = p_callback;
}
+
void RasterizerStorageRD::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {
Texture *tex = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!tex);
tex->detect_roughness_callback_ud = p_userdata;
tex->detect_roughness_callback = p_callback;
}
+
void RasterizerStorageRD::texture_debug_usage(List<RS::TextureInfo> *r_info) {
}
void RasterizerStorageRD::texture_set_proxy(RID p_proxy, RID p_base) {
}
+
void RasterizerStorageRD::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {
}
@@ -993,7 +991,6 @@ Size2 RasterizerStorageRD::texture_size_with_proxy(RID p_proxy) {
/* SHADER API */
RID RasterizerStorageRD::shader_create() {
-
Shader shader;
shader.data = nullptr;
shader.type = SHADER_TYPE_MAX;
@@ -1009,16 +1006,17 @@ void RasterizerStorageRD::shader_set_code(RID p_shader, const String &p_code) {
String mode_string = ShaderLanguage::get_shader_type(p_code);
ShaderType new_type;
- if (mode_string == "canvas_item")
+ if (mode_string == "canvas_item") {
new_type = SHADER_TYPE_2D;
- else if (mode_string == "particles")
+ } else if (mode_string == "particles") {
new_type = SHADER_TYPE_PARTICLES;
- else if (mode_string == "spatial")
+ } else if (mode_string == "spatial") {
new_type = SHADER_TYPE_3D;
- else if (mode_string == "sky")
+ } else if (mode_string == "sky") {
new_type = SHADER_TYPE_SKY;
- else
+ } else {
new_type = SHADER_TYPE_MAX;
+ }
if (new_type != shader->type) {
if (shader->data) {
@@ -1027,7 +1025,6 @@ void RasterizerStorageRD::shader_set_code(RID p_shader, const String &p_code) {
}
for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) {
-
Material *material = E->get();
material->shader_type = new_type;
if (material->data) {
@@ -1072,8 +1069,8 @@ String RasterizerStorageRD::shader_get_code(RID p_shader) const {
ERR_FAIL_COND_V(!shader, String());
return shader->code;
}
-void RasterizerStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
+void RasterizerStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
if (shader->data) {
@@ -1082,7 +1079,6 @@ void RasterizerStorageRD::shader_get_param_list(RID p_shader, List<PropertyInfo>
}
void RasterizerStorageRD::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
-
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND(!shader);
@@ -1107,6 +1103,7 @@ RID RasterizerStorageRD::shader_get_default_texture_param(RID p_shader, const St
return RID();
}
+
Variant RasterizerStorageRD::shader_get_param_default(RID p_shader, const StringName &p_param) const {
Shader *shader = shader_owner.getornull(p_shader);
ERR_FAIL_COND_V(!shader, Variant());
@@ -1115,6 +1112,7 @@ Variant RasterizerStorageRD::shader_get_param_default(RID p_shader, const String
}
return Variant();
}
+
void RasterizerStorageRD::shader_set_data_request_function(ShaderType p_shader_type, ShaderDataRequestFunction p_function) {
ERR_FAIL_INDEX(p_shader_type, SHADER_TYPE_MAX);
shader_data_request_func[p_shader_type] = p_function;
@@ -1123,7 +1121,6 @@ void RasterizerStorageRD::shader_set_data_request_function(ShaderType p_shader_t
/* COMMON MATERIAL API */
RID RasterizerStorageRD::material_create() {
-
Material material;
material.data = nullptr;
material.shader = nullptr;
@@ -1154,7 +1151,6 @@ void RasterizerStorageRD::_material_queue_update(Material *material, bool p_unif
}
void RasterizerStorageRD::material_set_shader(RID p_material, RID p_shader) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1196,7 +1192,6 @@ void RasterizerStorageRD::material_set_shader(RID p_material, RID p_shader) {
}
void RasterizerStorageRD::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1239,6 +1234,7 @@ void RasterizerStorageRD::material_set_next_pass(RID p_material, RID p_next_mate
material->instance_dependency.instance_notify_changed(false, true);
}
+
void RasterizerStorageRD::material_set_render_priority(RID p_material, int priority) {
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
@@ -1260,6 +1256,7 @@ bool RasterizerStorageRD::material_is_animated(RID p_material) {
}
return false; //by default nothing is animated
}
+
bool RasterizerStorageRD::material_casts_shadows(RID p_material) {
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND_V(!material, true);
@@ -1274,7 +1271,6 @@ bool RasterizerStorageRD::material_casts_shadows(RID p_material) {
}
void RasterizerStorageRD::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) {
-
Material *material = material_owner.getornull(p_material);
ERR_FAIL_COND(!material);
if (material->shader && material->shader->data) {
@@ -1303,14 +1299,12 @@ void RasterizerStorageRD::material_set_data_request_function(ShaderType p_shader
_FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataType type, const Variant &value, uint8_t *data, bool p_linear_color) {
switch (type) {
case ShaderLanguage::TYPE_BOOL: {
-
bool v = value;
uint32_t *gui = (uint32_t *)data;
*gui = v ? 1 : 0;
} break;
case ShaderLanguage::TYPE_BVEC2: {
-
int v = value;
uint32_t *gui = (uint32_t *)data;
gui[0] = v & 1 ? 1 : 0;
@@ -1318,7 +1312,6 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} break;
case ShaderLanguage::TYPE_BVEC3: {
-
int v = value;
uint32_t *gui = (uint32_t *)data;
gui[0] = (v & 1) ? 1 : 0;
@@ -1327,7 +1320,6 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} break;
case ShaderLanguage::TYPE_BVEC4: {
-
int v = value;
uint32_t *gui = (uint32_t *)data;
gui[0] = (v & 1) ? 1 : 0;
@@ -1337,14 +1329,12 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} break;
case ShaderLanguage::TYPE_INT: {
-
int v = value;
int32_t *gui = (int32_t *)data;
gui[0] = v;
} break;
case ShaderLanguage::TYPE_IVEC2: {
-
Vector<int> iv = value;
int s = iv.size();
int32_t *gui = (int32_t *)data;
@@ -1352,15 +1342,15 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
const int *r = iv.ptr();
for (int i = 0; i < 2; i++) {
- if (i < s)
+ if (i < s) {
gui[i] = r[i];
- else
+ } else {
gui[i] = 0;
+ }
}
} break;
case ShaderLanguage::TYPE_IVEC3: {
-
Vector<int> iv = value;
int s = iv.size();
int32_t *gui = (int32_t *)data;
@@ -1368,14 +1358,14 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
const int *r = iv.ptr();
for (int i = 0; i < 3; i++) {
- if (i < s)
+ if (i < s) {
gui[i] = r[i];
- else
+ } else {
gui[i] = 0;
+ }
}
} break;
case ShaderLanguage::TYPE_IVEC4: {
-
Vector<int> iv = value;
int s = iv.size();
int32_t *gui = (int32_t *)data;
@@ -1383,21 +1373,20 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
const int *r = iv.ptr();
for (int i = 0; i < 4; i++) {
- if (i < s)
+ if (i < s) {
gui[i] = r[i];
- else
+ } else {
gui[i] = 0;
+ }
}
} break;
case ShaderLanguage::TYPE_UINT: {
-
int v = value;
uint32_t *gui = (uint32_t *)data;
gui[0] = v;
} break;
case ShaderLanguage::TYPE_UVEC2: {
-
Vector<int> iv = value;
int s = iv.size();
uint32_t *gui = (uint32_t *)data;
@@ -1405,10 +1394,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
const int *r = iv.ptr();
for (int i = 0; i < 2; i++) {
- if (i < s)
+ if (i < s) {
gui[i] = r[i];
- else
+ } else {
gui[i] = 0;
+ }
}
} break;
case ShaderLanguage::TYPE_UVEC3: {
@@ -1419,10 +1409,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
const int *r = iv.ptr();
for (int i = 0; i < 3; i++) {
- if (i < s)
+ if (i < s) {
gui[i] = r[i];
- else
+ } else {
gui[i] = 0;
+ }
}
} break;
@@ -1434,10 +1425,11 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
const int *r = iv.ptr();
for (int i = 0; i < 4; i++) {
- if (i < s)
+ if (i < s) {
gui[i] = r[i];
- else
+ } else {
gui[i] = 0;
+ }
}
} break;
case ShaderLanguage::TYPE_FLOAT: {
@@ -1462,7 +1454,6 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} break;
case ShaderLanguage::TYPE_VEC4: {
-
float *gui = (float *)data;
if (value.get_type() == Variant::COLOR) {
@@ -1514,7 +1505,6 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
-
Basis v = value;
float *gui = (float *)data;
@@ -1532,7 +1522,6 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
gui[11] = 0;
} break;
case ShaderLanguage::TYPE_MAT4: {
-
Transform v = value;
float *gui = (float *)data;
@@ -1559,22 +1548,18 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
}
_FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, const Vector<ShaderLanguage::ConstantNode::Value> &value, uint8_t *data) {
-
switch (type) {
case ShaderLanguage::TYPE_BOOL: {
-
uint32_t *gui = (uint32_t *)data;
*gui = value[0].boolean ? 1 : 0;
} break;
case ShaderLanguage::TYPE_BVEC2: {
-
uint32_t *gui = (uint32_t *)data;
gui[0] = value[0].boolean ? 1 : 0;
gui[1] = value[1].boolean ? 1 : 0;
} break;
case ShaderLanguage::TYPE_BVEC3: {
-
uint32_t *gui = (uint32_t *)data;
gui[0] = value[0].boolean ? 1 : 0;
gui[1] = value[1].boolean ? 1 : 0;
@@ -1582,7 +1567,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_BVEC4: {
-
uint32_t *gui = (uint32_t *)data;
gui[0] = value[0].boolean ? 1 : 0;
gui[1] = value[1].boolean ? 1 : 0;
@@ -1591,13 +1575,11 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_INT: {
-
int32_t *gui = (int32_t *)data;
gui[0] = value[0].sint;
} break;
case ShaderLanguage::TYPE_IVEC2: {
-
int32_t *gui = (int32_t *)data;
for (int i = 0; i < 2; i++) {
@@ -1606,7 +1588,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_IVEC3: {
-
int32_t *gui = (int32_t *)data;
for (int i = 0; i < 3; i++) {
@@ -1615,7 +1596,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_IVEC4: {
-
int32_t *gui = (int32_t *)data;
for (int i = 0; i < 4; i++) {
@@ -1624,13 +1604,11 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_UINT: {
-
uint32_t *gui = (uint32_t *)data;
gui[0] = value[0].uint;
} break;
case ShaderLanguage::TYPE_UVEC2: {
-
int32_t *gui = (int32_t *)data;
for (int i = 0; i < 2; i++) {
@@ -1653,13 +1631,11 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
}
} break;
case ShaderLanguage::TYPE_FLOAT: {
-
float *gui = (float *)data;
gui[0] = value[0].real;
} break;
case ShaderLanguage::TYPE_VEC2: {
-
float *gui = (float *)data;
for (int i = 0; i < 2; i++) {
@@ -1668,7 +1644,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_VEC3: {
-
float *gui = (float *)data;
for (int i = 0; i < 3; i++) {
@@ -1677,7 +1652,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
} break;
case ShaderLanguage::TYPE_VEC4: {
-
float *gui = (float *)data;
for (int i = 0; i < 4; i++) {
@@ -1698,7 +1672,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
-
float *gui = (float *)data;
gui[0] = value[0].real;
@@ -1715,7 +1688,6 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
gui[11] = 0;
} break;
case ShaderLanguage::TYPE_MAT4: {
-
float *gui = (float *)data;
for (int i = 0; i < 16; i++) {
@@ -1728,9 +1700,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
}
_FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type, uint8_t *data) {
-
switch (type) {
-
case ShaderLanguage::TYPE_BOOL:
case ShaderLanguage::TYPE_INT:
case ShaderLanguage::TYPE_UINT:
@@ -1751,15 +1721,12 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type,
case ShaderLanguage::TYPE_IVEC4:
case ShaderLanguage::TYPE_UVEC4:
case ShaderLanguage::TYPE_VEC4: {
-
zeromem(data, 16);
} break;
case ShaderLanguage::TYPE_MAT2: {
-
zeromem(data, 32);
} break;
case ShaderLanguage::TYPE_MAT3: {
-
zeromem(data, 48);
} break;
case ShaderLanguage::TYPE_MAT4: {
@@ -1772,13 +1739,12 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type,
}
void RasterizerStorageRD::MaterialData::update_uniform_buffer(const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Map<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color) {
-
bool uses_global_buffer = false;
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = p_uniforms.front(); E; E = E->next()) {
-
- if (E->get().order < 0)
+ if (E->get().order < 0) {
continue; // texture, does not go here
+ }
if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue; //instance uniforms don't appear in the bufferr
@@ -1866,7 +1832,6 @@ RasterizerStorageRD::MaterialData::~MaterialData() {
}
void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Variant> &p_parameters, const Map<StringName, RID> &p_default_textures, const Vector<ShaderCompilerRD::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color) {
-
RasterizerStorageRD *singleton = (RasterizerStorageRD *)RasterizerStorage::base_singleton;
#ifdef TOOLS_ENABLED
Texture *roughness_detect_texture = nullptr;
@@ -1878,13 +1843,11 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
global_textures_pass++;
for (int i = 0; i < p_texture_uniforms.size(); i++) {
-
const StringName &uniform_name = p_texture_uniforms[i].name;
RID texture;
if (p_texture_uniforms[i].global) {
-
RasterizerStorageRD *rs = base_singleton;
uses_global_textures = true;
@@ -1895,7 +1858,6 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!.");
} else {
-
Map<StringName, uint64_t>::Element *E = used_global_textures.find(uniform_name);
if (!E) {
E = used_global_textures.insert(uniform_name, global_textures_pass);
@@ -1912,7 +1874,6 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
}
} else {
if (!texture.is_valid()) {
-
const Map<StringName, Variant>::Element *V = p_parameters.find(uniform_name);
if (V) {
texture = V->get();
@@ -1922,7 +1883,6 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
if (!texture.is_valid()) {
const Map<StringName, RID>::Element *W = p_default_textures.find(uniform_name);
if (W) {
-
texture = W->get();
}
}
@@ -1953,7 +1913,6 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va
Texture *tex = singleton->texture_owner.getornull(texture);
if (tex) {
-
rd_texture = (srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
#ifdef TOOLS_ENABLED
if (tex->detect_3d_callback && p_use_linear_color) {
@@ -2045,16 +2004,15 @@ void RasterizerStorageRD::_update_queued_materials() {
}
material_update_list = nullptr;
}
+
/* MESH API */
RID RasterizerStorageRD::mesh_create() {
-
return mesh_owner.make_rid(Mesh());
}
/// Returns stride
void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -2065,17 +2023,12 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
#ifdef DEBUG_ENABLED
//do a validation, to catch errors first
{
-
uint32_t stride = 0;
for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) {
-
if ((p_surface.format & (1 << i))) {
-
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_surface.format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
stride += sizeof(float) * 2;
} else {
@@ -2084,7 +2037,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
} break;
case RS::ARRAY_NORMAL: {
-
if (p_surface.format & RS::ARRAY_COMPRESS_NORMAL) {
stride += sizeof(int8_t) * 4;
} else {
@@ -2093,7 +2045,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
} break;
case RS::ARRAY_TANGENT: {
-
if (p_surface.format & RS::ARRAY_COMPRESS_TANGENT) {
stride += sizeof(int8_t) * 4;
} else {
@@ -2102,7 +2053,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
} break;
case RS::ARRAY_COLOR: {
-
if (p_surface.format & RS::ARRAY_COMPRESS_COLOR) {
stride += sizeof(int8_t) * 4;
} else {
@@ -2111,7 +2061,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
} break;
case RS::ARRAY_TEX_UV: {
-
if (p_surface.format & RS::ARRAY_COMPRESS_TEX_UV) {
stride += sizeof(int16_t) * 2;
} else {
@@ -2120,7 +2069,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
} break;
case RS::ARRAY_TEX_UV2: {
-
if (p_surface.format & RS::ARRAY_COMPRESS_TEX_UV2) {
stride += sizeof(int16_t) * 2;
} else {
@@ -2165,7 +2113,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
s->lod_count = p_surface.lods.size();
for (int i = 0; i < p_surface.lods.size(); i++) {
-
uint32_t indices = p_surface.lods[i].index_data.size() / (is_index_16 ? 2 : 4);
s->lods[i].index_buffer = RD::get_singleton()->index_buffer_create(indices, is_index_16 ? RD::INDEX_BUFFER_FORMAT_UINT16 : RD::INDEX_BUFFER_FORMAT_UINT32, p_surface.lods[i].index_data);
s->lods[i].index_array = RD::get_singleton()->index_array_create(s->lods[i].index_buffer, 0, indices);
@@ -2178,7 +2125,6 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_
s->bone_aabbs = p_surface.bone_aabbs; //only really useful for returning them.
for (int i = 0; i < p_surface.blend_shapes.size(); i++) {
-
if (p_surface.blend_shapes[i].size() != p_surface.vertex_data.size()) {
memdelete(s);
ERR_FAIL_COND(p_surface.blend_shapes[i].size() != p_surface.vertex_data.size());
@@ -2223,6 +2169,7 @@ void RasterizerStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMo
mesh->blend_shape_mode = p_mode;
}
+
RS::BlendShapeMode RasterizerStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED);
@@ -2249,6 +2196,7 @@ void RasterizerStorageRD::mesh_surface_set_material(RID p_mesh, int p_surface, R
mesh->instance_dependency.instance_notify_changed(false, true);
mesh->material_cache.clear();
}
+
RID RasterizerStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) const {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, RID());
@@ -2258,7 +2206,6 @@ RID RasterizerStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) co
}
RS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, RS::SurfaceData());
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData());
@@ -2304,6 +2251,7 @@ void RasterizerStorageRD::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
ERR_FAIL_COND(!mesh);
mesh->custom_aabb = p_aabb;
}
+
AABB RasterizerStorageRD::mesh_get_custom_aabb(RID p_mesh) const {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND_V(!mesh, AABB());
@@ -2327,10 +2275,8 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
AABB aabb;
for (uint32_t i = 0; i < mesh->surface_count; i++) {
-
AABB laabb;
if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->bone_aabbs.size()) {
-
int bs = mesh->surfaces[i]->bone_aabbs.size();
const AABB *skbones = mesh->surfaces[i]->bone_aabbs.ptr();
@@ -2342,9 +2288,9 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
if (skeleton->use_2d) {
for (int j = 0; j < bs; j++) {
-
- if (skbones[0].size == Vector3())
+ if (skbones[0].size == Vector3()) {
continue; //bone is unused
+ }
const float *dataptr = baseptr + j * 8;
@@ -2369,9 +2315,9 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
}
} else {
for (int j = 0; j < bs; j++) {
-
- if (skbones[0].size == Vector3())
+ if (skbones[0].size == Vector3()) {
continue; //bone is unused
+ }
const float *dataptr = baseptr + j * 12;
@@ -2404,7 +2350,6 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
laabb = mesh->surfaces[i]->aabb;
}
} else {
-
laabb = mesh->surfaces[i]->aabb;
}
@@ -2419,7 +2364,6 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
}
void RasterizerStorageRD::mesh_clear(RID p_mesh) {
-
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
for (uint32_t i = 0; i < mesh->surface_count; i++) {
@@ -2473,7 +2417,6 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
uint32_t stride = 0;
for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) {
-
RD::VertexAttribute vd;
RID buffer;
vd.location = i;
@@ -2482,9 +2425,7 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
// Not supplied by surface, use default value
buffer = mesh_default_rd_buffers[i];
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT;
} break;
@@ -2492,25 +2433,20 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT;
} break;
case RS::ARRAY_TANGENT: {
-
vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
} break;
case RS::ARRAY_COLOR: {
-
vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
} break;
case RS::ARRAY_TEX_UV: {
-
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
} break;
case RS::ARRAY_TEX_UV2: {
-
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
} break;
case RS::ARRAY_BONES: {
-
//assumed weights too
vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT;
} break;
@@ -2523,9 +2459,7 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
buffer = s->vertex_buffer;
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (s->format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
vd.format = RD::DATA_FORMAT_R32G32_SFLOAT;
stride += sizeof(float) * 2;
@@ -2536,7 +2470,6 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
} break;
case RS::ARRAY_NORMAL: {
-
if (s->format & RS::ARRAY_COMPRESS_NORMAL) {
vd.format = RD::DATA_FORMAT_R8G8B8A8_SNORM;
stride += sizeof(int8_t) * 4;
@@ -2547,7 +2480,6 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
} break;
case RS::ARRAY_TANGENT: {
-
if (s->format & RS::ARRAY_COMPRESS_TANGENT) {
vd.format = RD::DATA_FORMAT_R8G8B8A8_SNORM;
stride += sizeof(int8_t) * 4;
@@ -2558,7 +2490,6 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
} break;
case RS::ARRAY_COLOR: {
-
if (s->format & RS::ARRAY_COMPRESS_COLOR) {
vd.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
stride += sizeof(int8_t) * 4;
@@ -2569,7 +2500,6 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
} break;
case RS::ARRAY_TEX_UV: {
-
if (s->format & RS::ARRAY_COMPRESS_TEX_UV) {
vd.format = RD::DATA_FORMAT_R16G16_SFLOAT;
stride += sizeof(int16_t) * 2;
@@ -2580,7 +2510,6 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
} break;
case RS::ARRAY_TEX_UV2: {
-
if (s->format & RS::ARRAY_COMPRESS_TEX_UV2) {
vd.format = RD::DATA_FORMAT_R16G16_SFLOAT;
stride += sizeof(int16_t) * 2;
@@ -2625,12 +2554,10 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su
////////////////// MULTIMESH
RID RasterizerStorageRD::multimesh_create() {
-
return multimesh_owner.make_rid(MultiMesh());
}
void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
@@ -2666,7 +2593,6 @@ void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, R
multimesh->visible_instances = MIN(multimesh->visible_instances, multimesh->instances);
if (multimesh->instances) {
-
multimesh->buffer = RD::get_singleton()->storage_buffer_create(multimesh->instances * multimesh->stride_cache * 4);
}
}
@@ -2721,7 +2647,6 @@ void RasterizerStorageRD::_multimesh_make_local(MultiMesh *multimesh) const {
if (multimesh->buffer_set) {
Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer);
{
-
const uint8_t *r = buffer.ptr();
copymem(w, r, buffer.size());
}
@@ -2732,13 +2657,12 @@ void RasterizerStorageRD::_multimesh_make_local(MultiMesh *multimesh) const {
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
multimesh->data_cache_dirty_regions = memnew_arr(bool, data_cache_dirty_region_count);
for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
- multimesh->data_cache_dirty_regions[i] = 0;
+ multimesh->data_cache_dirty_regions[i] = false;
}
multimesh->data_cache_used_dirty_regions = 0;
}
void RasterizerStorageRD::_multimesh_mark_dirty(MultiMesh *multimesh, int p_index, bool p_aabb) {
-
uint32_t region_index = p_index / MULTIMESH_DIRTY_REGION_SIZE;
#ifdef DEBUG_ENABLED
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
@@ -2784,7 +2708,6 @@ void RasterizerStorageRD::_multimesh_mark_all_dirty(MultiMesh *multimesh, bool p
}
void RasterizerStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p_data, int p_instances) {
-
ERR_FAIL_COND(multimesh->mesh.is_null());
AABB aabb;
AABB mesh_aabb = mesh_get_aabb(multimesh->mesh);
@@ -2793,7 +2716,6 @@ void RasterizerStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const
Transform t;
if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
-
t.basis.elements[0][0] = data[0];
t.basis.elements[0][1] = data[1];
t.basis.elements[0][2] = data[2];
@@ -2808,7 +2730,6 @@ void RasterizerStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const
t.origin.z = data[11];
} else {
-
t.basis.elements[0].x = data[0];
t.basis.elements[1].x = data[1];
t.origin.x = data[3];
@@ -2829,7 +2750,6 @@ void RasterizerStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const
}
void RasterizerStorageRD::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
@@ -2860,7 +2780,6 @@ void RasterizerStorageRD::multimesh_instance_set_transform(RID p_multimesh, int
}
void RasterizerStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
@@ -2885,8 +2804,8 @@ void RasterizerStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, i
_multimesh_mark_dirty(multimesh, p_index, true);
}
-void RasterizerStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
+void RasterizerStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_INDEX(p_index, multimesh->instances);
@@ -2907,6 +2826,7 @@ void RasterizerStorageRD::multimesh_instance_set_color(RID p_multimesh, int p_in
_multimesh_mark_dirty(multimesh, p_index, false);
}
+
void RasterizerStorageRD::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
@@ -2930,7 +2850,6 @@ void RasterizerStorageRD::multimesh_instance_set_custom_data(RID p_multimesh, in
}
RID RasterizerStorageRD::multimesh_get_mesh(RID p_multimesh) const {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, RID());
@@ -2938,7 +2857,6 @@ RID RasterizerStorageRD::multimesh_get_mesh(RID p_multimesh) const {
}
Transform RasterizerStorageRD::multimesh_instance_get_transform(RID p_multimesh, int p_index) const {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform());
@@ -2968,8 +2886,8 @@ Transform RasterizerStorageRD::multimesh_instance_get_transform(RID p_multimesh,
return t;
}
-Transform2D RasterizerStorageRD::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
+Transform2D RasterizerStorageRD::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Transform2D());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D());
@@ -2993,8 +2911,8 @@ Transform2D RasterizerStorageRD::multimesh_instance_get_transform_2d(RID p_multi
return t;
}
-Color RasterizerStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
+Color RasterizerStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_index) const {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
@@ -3016,8 +2934,8 @@ Color RasterizerStorageRD::multimesh_instance_get_color(RID p_multimesh, int p_i
return c;
}
-Color RasterizerStorageRD::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
+Color RasterizerStorageRD::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, Color());
ERR_FAIL_INDEX_V(p_index, multimesh->instances, Color());
@@ -3097,7 +3015,6 @@ Vector<float> RasterizerStorageRD::multimesh_get_buffer(RID p_multimesh) const {
}
void RasterizerStorageRD::multimesh_set_visible_instances(RID p_multimesh, int p_visible) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(p_visible < -1 || p_visible > multimesh->instances);
@@ -3112,6 +3029,7 @@ void RasterizerStorageRD::multimesh_set_visible_instances(RID p_multimesh, int p
multimesh->visible_instances = p_visible;
}
+
int RasterizerStorageRD::multimesh_get_visible_instances(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND_V(!multimesh, 0);
@@ -3128,9 +3046,7 @@ AABB RasterizerStorageRD::multimesh_get_aabb(RID p_multimesh) const {
}
void RasterizerStorageRD::_update_dirty_multimeshes() {
-
while (multimesh_dirty_list) {
-
MultiMesh *multimesh = multimesh_dirty_list;
if (multimesh->data_cache.size()) { //may have been cleared, so only process if it exists
@@ -3139,7 +3055,6 @@ void RasterizerStorageRD::_update_dirty_multimeshes() {
uint32_t visible_instances = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
if (multimesh->data_cache_used_dirty_regions) {
-
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
uint32_t visible_region_count = (visible_instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
@@ -3188,12 +3103,10 @@ void RasterizerStorageRD::_update_dirty_multimeshes() {
/* SKELETON API */
RID RasterizerStorageRD::skeleton_create() {
-
return skeleton_owner.make_rid(Skeleton());
}
void RasterizerStorageRD::_skeleton_make_dirty(Skeleton *skeleton) {
-
if (!skeleton->dirty) {
skeleton->dirty = true;
skeleton->dirty_list = skeleton_dirty_list;
@@ -3202,13 +3115,13 @@ void RasterizerStorageRD::_skeleton_make_dirty(Skeleton *skeleton) {
}
void RasterizerStorageRD::skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
ERR_FAIL_COND(p_bones < 0);
- if (skeleton->size == p_bones && skeleton->use_2d == p_2d_skeleton)
+ if (skeleton->size == p_bones && skeleton->use_2d == p_2d_skeleton) {
return;
+ }
skeleton->size = p_bones;
skeleton->use_2d = p_2d_skeleton;
@@ -3221,7 +3134,6 @@ void RasterizerStorageRD::skeleton_allocate(RID p_skeleton, int p_bones, bool p_
}
if (skeleton->size) {
-
skeleton->data.resize(skeleton->size * (skeleton->use_2d ? 8 : 12));
skeleton->buffer = RD::get_singleton()->storage_buffer_create(skeleton->data.size() * sizeof(float));
zeromem(skeleton->data.ptrw(), skeleton->data.size() * sizeof(float));
@@ -3229,8 +3141,8 @@ void RasterizerStorageRD::skeleton_allocate(RID p_skeleton, int p_bones, bool p_
_skeleton_make_dirty(skeleton);
}
}
-int RasterizerStorageRD::skeleton_get_bone_count(RID p_skeleton) const {
+int RasterizerStorageRD::skeleton_get_bone_count(RID p_skeleton) const {
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND_V(!skeleton, 0);
@@ -3238,7 +3150,6 @@ int RasterizerStorageRD::skeleton_get_bone_count(RID p_skeleton) const {
}
void RasterizerStorageRD::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -3264,7 +3175,6 @@ void RasterizerStorageRD::skeleton_bone_set_transform(RID p_skeleton, int p_bone
}
Transform RasterizerStorageRD::skeleton_bone_get_transform(RID p_skeleton, int p_bone) const {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND_V(!skeleton, Transform());
@@ -3290,8 +3200,8 @@ Transform RasterizerStorageRD::skeleton_bone_get_transform(RID p_skeleton, int p
return t;
}
-void RasterizerStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
+void RasterizerStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -3311,8 +3221,8 @@ void RasterizerStorageRD::skeleton_bone_set_transform_2d(RID p_skeleton, int p_b
_skeleton_make_dirty(skeleton);
}
-Transform2D RasterizerStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const {
+Transform2D RasterizerStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const {
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND_V(!skeleton, Transform2D());
@@ -3333,7 +3243,6 @@ Transform2D RasterizerStorageRD::skeleton_bone_get_transform_2d(RID p_skeleton,
}
void RasterizerStorageRD::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton->use_2d);
@@ -3342,13 +3251,10 @@ void RasterizerStorageRD::skeleton_set_base_transform_2d(RID p_skeleton, const T
}
void RasterizerStorageRD::_update_dirty_skeletons() {
-
while (skeleton_dirty_list) {
-
Skeleton *skeleton = skeleton_dirty_list;
if (skeleton->size) {
-
RD::get_singleton()->buffer_update(skeleton->buffer, 0, skeleton->data.size() * sizeof(float), skeleton->data.ptr(), false);
}
@@ -3366,7 +3272,6 @@ void RasterizerStorageRD::_update_dirty_skeletons() {
/* LIGHT */
RID RasterizerStorageRD::light_create(RS::LightType p_type) {
-
Light light;
light.type = p_type;
@@ -3390,14 +3295,13 @@ RID RasterizerStorageRD::light_create(RS::LightType p_type) {
}
void RasterizerStorageRD::light_set_color(RID p_light, const Color &p_color) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
light->color = p_color;
}
-void RasterizerStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
+void RasterizerStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX);
@@ -3412,7 +3316,6 @@ void RasterizerStorageRD::light_set_param(RID p_light, RS::LightParam p_param, f
case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
case RS::LIGHT_PARAM_SHADOW_PANCAKE_SIZE:
case RS::LIGHT_PARAM_SHADOW_BIAS: {
-
light->version++;
light->instance_dependency.instance_notify_changed(true, false);
} break;
@@ -3422,8 +3325,8 @@ void RasterizerStorageRD::light_set_param(RID p_light, RS::LightParam p_param, f
light->param[p_param] = p_value;
}
-void RasterizerStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
+void RasterizerStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
light->shadow = p_enabled;
@@ -3433,14 +3336,12 @@ void RasterizerStorageRD::light_set_shadow(RID p_light, bool p_enabled) {
}
void RasterizerStorageRD::light_set_shadow_color(RID p_light, const Color &p_color) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
light->shadow_color = p_color;
}
void RasterizerStorageRD::light_set_projector(RID p_light, RID p_texture) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3460,14 +3361,13 @@ void RasterizerStorageRD::light_set_projector(RID p_light, RID p_texture) {
}
void RasterizerStorageRD::light_set_negative(RID p_light, bool p_enable) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
light->negative = p_enable;
}
-void RasterizerStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
+void RasterizerStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3478,7 +3378,6 @@ void RasterizerStorageRD::light_set_cull_mask(RID p_light, uint32_t p_mask) {
}
void RasterizerStorageRD::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3497,8 +3396,8 @@ void RasterizerStorageRD::light_set_use_gi(RID p_light, bool p_enabled) {
light->version++;
light->instance_dependency.instance_notify_changed(true, false);
}
-void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
+void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3509,7 +3408,6 @@ void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniS
}
RS::LightOmniShadowMode RasterizerStorageRD::light_omni_get_shadow_mode(RID p_light) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE);
@@ -3517,7 +3415,6 @@ RS::LightOmniShadowMode RasterizerStorageRD::light_omni_get_shadow_mode(RID p_li
}
void RasterizerStorageRD::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3527,7 +3424,6 @@ void RasterizerStorageRD::light_directional_set_shadow_mode(RID p_light, RS::Lig
}
void RasterizerStorageRD::light_directional_set_blend_splits(RID p_light, bool p_enable) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3537,7 +3433,6 @@ void RasterizerStorageRD::light_directional_set_blend_splits(RID p_light, bool p
}
bool RasterizerStorageRD::light_directional_get_blend_splits(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, false);
@@ -3545,7 +3440,6 @@ bool RasterizerStorageRD::light_directional_get_blend_splits(RID p_light) const
}
RS::LightDirectionalShadowMode RasterizerStorageRD::light_directional_get_shadow_mode(RID p_light) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL);
@@ -3553,7 +3447,6 @@ RS::LightDirectionalShadowMode RasterizerStorageRD::light_directional_get_shadow
}
void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) {
-
Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND(!light);
@@ -3561,7 +3454,6 @@ void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_li
}
RS::LightDirectionalShadowDepthRangeMode RasterizerStorageRD::light_directional_get_shadow_depth_range_mode(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
@@ -3576,7 +3468,6 @@ bool RasterizerStorageRD::light_get_use_gi(RID p_light) {
}
uint64_t RasterizerStorageRD::light_get_version(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, 0);
@@ -3584,25 +3475,20 @@ uint64_t RasterizerStorageRD::light_get_version(RID p_light) const {
}
AABB RasterizerStorageRD::light_get_aabb(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, AABB());
switch (light->type) {
-
case RS::LIGHT_SPOT: {
-
float len = light->param[RS::LIGHT_PARAM_RANGE];
float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
};
case RS::LIGHT_OMNI: {
-
float r = light->param[RS::LIGHT_PARAM_RANGE];
return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
};
case RS::LIGHT_DIRECTIONAL: {
-
return AABB();
};
}
@@ -3613,12 +3499,10 @@ AABB RasterizerStorageRD::light_get_aabb(RID p_light) const {
/* REFLECTION PROBE */
RID RasterizerStorageRD::reflection_probe_create() {
-
return reflection_probe_owner.make_rid(ReflectionProbe());
}
void RasterizerStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3627,7 +3511,6 @@ void RasterizerStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::Refl
}
void RasterizerStorageRD::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3635,7 +3518,6 @@ void RasterizerStorageRD::reflection_probe_set_intensity(RID p_probe, float p_in
}
void RasterizerStorageRD::reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3643,7 +3525,6 @@ void RasterizerStorageRD::reflection_probe_set_interior_ambient(RID p_probe, con
}
void RasterizerStorageRD::reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3651,7 +3532,6 @@ void RasterizerStorageRD::reflection_probe_set_interior_ambient_energy(RID p_pro
}
void RasterizerStorageRD::reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3659,7 +3539,6 @@ void RasterizerStorageRD::reflection_probe_set_interior_ambient_probe_contributi
}
void RasterizerStorageRD::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3667,16 +3546,16 @@ void RasterizerStorageRD::reflection_probe_set_max_distance(RID p_probe, float p
reflection_probe->instance_dependency.instance_notify_changed(true, false);
}
-void RasterizerStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
+void RasterizerStorageRD::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->extents = p_extents;
reflection_probe->instance_dependency.instance_notify_changed(true, false);
}
-void RasterizerStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
+void RasterizerStorageRD::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3685,15 +3564,14 @@ void RasterizerStorageRD::reflection_probe_set_origin_offset(RID p_probe, const
}
void RasterizerStorageRD::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->interior = p_enable;
reflection_probe->instance_dependency.instance_notify_changed(true, false);
}
-void RasterizerStorageRD::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
+void RasterizerStorageRD::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3701,15 +3579,14 @@ void RasterizerStorageRD::reflection_probe_set_enable_box_projection(RID p_probe
}
void RasterizerStorageRD::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
reflection_probe->enable_shadows = p_enable;
reflection_probe->instance_dependency.instance_notify_changed(true, false);
}
-void RasterizerStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
+void RasterizerStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
@@ -3718,7 +3595,6 @@ void RasterizerStorageRD::reflection_probe_set_cull_mask(RID p_probe, uint32_t p
}
void RasterizerStorageRD::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
-
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!reflection_probe);
ERR_FAIL_COND(p_resolution < 32);
@@ -3736,8 +3612,8 @@ AABB RasterizerStorageRD::reflection_probe_get_aabb(RID p_probe) const {
return aabb;
}
-RS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
+RS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_mode(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
@@ -3745,7 +3621,6 @@ RS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_m
}
uint32_t RasterizerStorageRD::reflection_probe_get_cull_mask(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -3753,14 +3628,13 @@ uint32_t RasterizerStorageRD::reflection_probe_get_cull_mask(RID p_probe) const
}
Vector3 RasterizerStorageRD::reflection_probe_get_extents(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
return reflection_probe->extents;
}
-Vector3 RasterizerStorageRD::reflection_probe_get_origin_offset(RID p_probe) const {
+Vector3 RasterizerStorageRD::reflection_probe_get_origin_offset(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Vector3());
@@ -3768,7 +3642,6 @@ Vector3 RasterizerStorageRD::reflection_probe_get_origin_offset(RID p_probe) con
}
bool RasterizerStorageRD::reflection_probe_renders_shadows(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
@@ -3776,7 +3649,6 @@ bool RasterizerStorageRD::reflection_probe_renders_shadows(RID p_probe) const {
}
float RasterizerStorageRD::reflection_probe_get_origin_max_distance(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -3784,7 +3656,6 @@ float RasterizerStorageRD::reflection_probe_get_origin_max_distance(RID p_probe)
}
int RasterizerStorageRD::reflection_probe_get_resolution(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -3792,21 +3663,20 @@ int RasterizerStorageRD::reflection_probe_get_resolution(RID p_probe) const {
}
float RasterizerStorageRD::reflection_probe_get_intensity(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->intensity;
}
-bool RasterizerStorageRD::reflection_probe_is_interior(RID p_probe) const {
+bool RasterizerStorageRD::reflection_probe_is_interior(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
return reflection_probe->interior;
}
-bool RasterizerStorageRD::reflection_probe_is_box_projection(RID p_probe) const {
+bool RasterizerStorageRD::reflection_probe_is_box_projection(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, false);
@@ -3814,21 +3684,20 @@ bool RasterizerStorageRD::reflection_probe_is_box_projection(RID p_probe) const
}
Color RasterizerStorageRD::reflection_probe_get_interior_ambient(RID p_probe) const {
-
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, Color());
return reflection_probe->interior_ambient;
}
-float RasterizerStorageRD::reflection_probe_get_interior_ambient_energy(RID p_probe) const {
+float RasterizerStorageRD::reflection_probe_get_interior_ambient_energy(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
return reflection_probe->interior_ambient_energy;
}
-float RasterizerStorageRD::reflection_probe_get_interior_ambient_probe_contribution(RID p_probe) const {
+float RasterizerStorageRD::reflection_probe_get_interior_ambient_probe_contribution(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
ERR_FAIL_COND_V(!reflection_probe, 0);
@@ -3845,6 +3714,7 @@ void RasterizerStorageRD::decal_set_extents(RID p_decal, const Vector3 &p_extent
decal->extents = p_extents;
decal->instance_dependency.instance_notify_changed(true, false);
}
+
void RasterizerStorageRD::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) {
Decal *decal = decal_owner.getornull(p_decal);
ERR_FAIL_COND(!decal);
@@ -3868,6 +3738,7 @@ void RasterizerStorageRD::decal_set_texture(RID p_decal, RS::DecalTexture p_type
decal->instance_dependency.instance_notify_changed(false, true);
}
+
void RasterizerStorageRD::decal_set_emission_energy(RID p_decal, float p_energy) {
Decal *decal = decal_owner.getornull(p_decal);
ERR_FAIL_COND(!decal);
@@ -3885,6 +3756,7 @@ void RasterizerStorageRD::decal_set_modulate(RID p_decal, const Color &p_modulat
ERR_FAIL_COND(!decal);
decal->modulate = p_modulate;
}
+
void RasterizerStorageRD::decal_set_cull_mask(RID p_decal, uint32_t p_layers) {
Decal *decal = decal_owner.getornull(p_decal);
ERR_FAIL_COND(!decal);
@@ -3893,7 +3765,6 @@ void RasterizerStorageRD::decal_set_cull_mask(RID p_decal, uint32_t p_layers) {
}
void RasterizerStorageRD::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) {
-
Decal *decal = decal_owner.getornull(p_decal);
ERR_FAIL_COND(!decal);
decal->distance_fade = p_enabled;
@@ -3902,7 +3773,6 @@ void RasterizerStorageRD::decal_set_distance_fade(RID p_decal, bool p_enabled, f
}
void RasterizerStorageRD::decal_set_fade(RID p_decal, float p_above, float p_below) {
-
Decal *decal = decal_owner.getornull(p_decal);
ERR_FAIL_COND(!decal);
decal->upper_fade = p_above;
@@ -3910,7 +3780,6 @@ void RasterizerStorageRD::decal_set_fade(RID p_decal, float p_above, float p_bel
}
void RasterizerStorageRD::decal_set_normal_fade(RID p_decal, float p_fade) {
-
Decal *decal = decal_owner.getornull(p_decal);
ERR_FAIL_COND(!decal);
decal->normal_fade = p_fade;
@@ -3924,7 +3793,6 @@ AABB RasterizerStorageRD::decal_get_aabb(RID p_decal) const {
}
RID RasterizerStorageRD::gi_probe_create() {
-
return gi_probe_owner.make_rid(GIProbe());
}
@@ -4066,6 +3934,7 @@ Vector3i RasterizerStorageRD::gi_probe_get_octree_size(RID p_gi_probe) const {
ERR_FAIL_COND_V(!gi_probe, Vector3i());
return gi_probe->octree_size;
}
+
Vector<uint8_t> RasterizerStorageRD::gi_probe_get_octree_cells(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, Vector<uint8_t>());
@@ -4075,6 +3944,7 @@ Vector<uint8_t> RasterizerStorageRD::gi_probe_get_octree_cells(RID p_gi_probe) c
}
return Vector<uint8_t>();
}
+
Vector<uint8_t> RasterizerStorageRD::gi_probe_get_data_cells(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, Vector<uint8_t>());
@@ -4084,6 +3954,7 @@ Vector<uint8_t> RasterizerStorageRD::gi_probe_get_data_cells(RID p_gi_probe) con
}
return Vector<uint8_t>();
}
+
Vector<uint8_t> RasterizerStorageRD::gi_probe_get_distance_field(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, Vector<uint8_t>());
@@ -4093,12 +3964,14 @@ Vector<uint8_t> RasterizerStorageRD::gi_probe_get_distance_field(RID p_gi_probe)
}
return Vector<uint8_t>();
}
+
Vector<int> RasterizerStorageRD::gi_probe_get_level_counts(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, Vector<int>());
return gi_probe->level_counts;
}
+
Transform RasterizerStorageRD::gi_probe_get_to_cell_xform(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, Transform());
@@ -4113,6 +3986,7 @@ void RasterizerStorageRD::gi_probe_set_dynamic_range(RID p_gi_probe, float p_ran
gi_probe->dynamic_range = p_range;
gi_probe->version++;
}
+
float RasterizerStorageRD::gi_probe_get_dynamic_range(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, 0);
@@ -4127,6 +4001,7 @@ void RasterizerStorageRD::gi_probe_set_propagation(RID p_gi_probe, float p_range
gi_probe->propagation = p_range;
gi_probe->version++;
}
+
float RasterizerStorageRD::gi_probe_get_propagation(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, 0);
@@ -4139,6 +4014,7 @@ void RasterizerStorageRD::gi_probe_set_energy(RID p_gi_probe, float p_energy) {
gi_probe->energy = p_energy;
}
+
float RasterizerStorageRD::gi_probe_get_energy(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, 0);
@@ -4151,6 +4027,7 @@ void RasterizerStorageRD::gi_probe_set_ao(RID p_gi_probe, float p_ao) {
gi_probe->ao = p_ao;
}
+
float RasterizerStorageRD::gi_probe_get_ao(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, 0);
@@ -4158,7 +4035,6 @@ float RasterizerStorageRD::gi_probe_get_ao(RID p_gi_probe) const {
}
void RasterizerStorageRD::gi_probe_set_ao_size(RID p_gi_probe, float p_strength) {
-
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND(!gi_probe);
@@ -4177,6 +4053,7 @@ void RasterizerStorageRD::gi_probe_set_bias(RID p_gi_probe, float p_bias) {
gi_probe->bias = p_bias;
}
+
float RasterizerStorageRD::gi_probe_get_bias(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, 0);
@@ -4189,6 +4066,7 @@ void RasterizerStorageRD::gi_probe_set_normal_bias(RID p_gi_probe, float p_norma
gi_probe->normal_bias = p_normal_bias;
}
+
float RasterizerStorageRD::gi_probe_get_normal_bias(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, 0);
@@ -4196,7 +4074,6 @@ float RasterizerStorageRD::gi_probe_get_normal_bias(RID p_gi_probe) const {
}
void RasterizerStorageRD::gi_probe_set_anisotropy_strength(RID p_gi_probe, float p_strength) {
-
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND(!gi_probe);
@@ -4249,13 +4126,12 @@ uint32_t RasterizerStorageRD::gi_probe_get_data_version(RID p_gi_probe) {
}
RID RasterizerStorageRD::gi_probe_get_octree_buffer(RID p_gi_probe) const {
-
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, RID());
return gi_probe->octree_buffer;
}
-RID RasterizerStorageRD::gi_probe_get_data_buffer(RID p_gi_probe) const {
+RID RasterizerStorageRD::gi_probe_get_data_buffer(RID p_gi_probe) const {
GIProbe *gi_probe = gi_probe_owner.getornull(p_gi_probe);
ERR_FAIL_COND_V(!gi_probe, RID());
return gi_probe->data_buffer;
@@ -4267,6 +4143,7 @@ RID RasterizerStorageRD::gi_probe_get_sdf_texture(RID p_gi_probe) {
return gi_probe->sdf_texture;
}
+
/* LIGHTMAP API */
RID RasterizerStorageRD::lightmap_create() {
@@ -4274,7 +4151,6 @@ RID RasterizerStorageRD::lightmap_create() {
}
void RasterizerStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) {
-
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND(!lm);
@@ -4294,7 +4170,6 @@ void RasterizerStorageRD::lightmap_set_textures(RID p_lightmap, RID p_light, boo
RID default_2d_array = default_rd_textures[DEFAULT_RD_TEXTURE_2D_ARRAY_WHITE];
if (!t) {
-
if (using_lightmap_array) {
if (lm->array_index >= 0) {
lightmap_textures.write[lm->array_index] = default_2d_array;
@@ -4330,14 +4205,12 @@ void RasterizerStorageRD::lightmap_set_probe_bounds(RID p_lightmap, const AABB &
}
void RasterizerStorageRD::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) {
-
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND(!lm);
lm->interior = p_interior;
}
void RasterizerStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) {
-
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND(!lm);
@@ -4354,22 +4227,24 @@ void RasterizerStorageRD::lightmap_set_probe_capture_data(RID p_lightmap, const
}
PackedVector3Array RasterizerStorageRD::lightmap_get_probe_capture_points(RID p_lightmap) const {
-
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedVector3Array());
return lm->points;
}
+
PackedColorArray RasterizerStorageRD::lightmap_get_probe_capture_sh(RID p_lightmap) const {
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedColorArray());
return lm->point_sh;
}
+
PackedInt32Array RasterizerStorageRD::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const {
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedInt32Array());
return lm->tetrahedra;
}
+
PackedInt32Array RasterizerStorageRD::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const {
Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND_V(!lm, PackedInt32Array());
@@ -4397,7 +4272,6 @@ void RasterizerStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p
const Lightmap::BSP *bsp = (const Lightmap::BSP *)lm->bsp_tree.ptr();
int32_t node = 0;
while (node >= 0) {
-
if (Plane(bsp[node].plane[0], bsp[node].plane[1], bsp[node].plane[2], bsp[node].plane[3]).is_point_over(p_point)) {
#ifdef DEBUG_ENABLED
ERR_FAIL_COND(bsp[node].over >= 0 && bsp[node].over < node);
@@ -4421,7 +4295,7 @@ void RasterizerStorageRD::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p
uint32_t *tetrahedron = (uint32_t *)&lm->tetrahedra[node * 4];
Vector3 points[4] = { lm->points[tetrahedron[0]], lm->points[tetrahedron[1]], lm->points[tetrahedron[2]], lm->points[tetrahedron[3]] };
const Color *sh_colors[4]{ &lm->point_sh[tetrahedron[0] * 9], &lm->point_sh[tetrahedron[1] * 9], &lm->point_sh[tetrahedron[2] * 9], &lm->point_sh[tetrahedron[3] * 9] };
- Color barycentric = Geometry::tetrahedron_get_barycentric_coords(points[0], points[1], points[2], points[3], p_point);
+ Color barycentric = Geometry3D::tetrahedron_get_barycentric_coords(points[0], points[1], points[2], points[3], p_point);
for (int i = 0; i < 4; i++) {
float c = CLAMP(barycentric[i], 0.0, 1.0);
@@ -4436,6 +4310,7 @@ bool RasterizerStorageRD::lightmap_is_interior(RID p_lightmap) const {
ERR_FAIL_COND_V(!lm, false);
return lm->interior;
}
+
AABB RasterizerStorageRD::lightmap_get_aabb(RID p_lightmap) const {
const Lightmap *lm = lightmap_owner.getornull(p_lightmap);
ERR_FAIL_COND_V(!lm, AABB());
@@ -4445,7 +4320,6 @@ AABB RasterizerStorageRD::lightmap_get_aabb(RID p_lightmap) const {
/* RENDER TARGET API */
void RasterizerStorageRD::_clear_render_target(RenderTarget *rt) {
-
//free in reverse dependency order
if (rt->framebuffer.is_valid()) {
RD::get_singleton()->free(rt->framebuffer);
@@ -4474,7 +4348,6 @@ void RasterizerStorageRD::_clear_render_target(RenderTarget *rt) {
}
void RasterizerStorageRD::_update_render_target(RenderTarget *rt) {
-
if (rt->texture.is_null()) {
//create a placeholder until updated
rt->texture = texture_2d_placeholder_create();
@@ -4579,7 +4452,6 @@ void RasterizerStorageRD::_create_render_target_backbuffer(RenderTarget *rt) {
//create mipmaps
for (uint32_t i = 1; i < mipmaps_required; i++) {
-
RenderTarget::BackbufferMipmap mm;
{
mm.mipmap = RD::get_singleton()->texture_create_shared_from_slice(RD::TextureView(), rt->backbuffer, 0, i);
@@ -4643,14 +4515,12 @@ void RasterizerStorageRD::render_target_set_flag(RID p_render_target, RenderTarg
}
bool RasterizerStorageRD::render_target_was_used(RID p_render_target) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND_V(!rt, false);
return rt->was_used;
}
void RasterizerStorageRD::render_target_set_as_unused(RID p_render_target) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
rt->was_used = false;
@@ -4669,12 +4539,14 @@ RID RasterizerStorageRD::render_target_get_rd_framebuffer(RID p_render_target) {
return rt->framebuffer;
}
+
RID RasterizerStorageRD::render_target_get_rd_texture(RID p_render_target) {
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
return rt->color;
}
+
void RasterizerStorageRD::render_target_request_clear(RID p_render_target, const Color &p_clear_color) {
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
@@ -4689,21 +4561,18 @@ bool RasterizerStorageRD::render_target_is_clear_requested(RID p_render_target)
}
Color RasterizerStorageRD::render_target_get_clear_request_color(RID p_render_target) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND_V(!rt, Color());
return rt->clear_color;
}
void RasterizerStorageRD::render_target_disable_clear_request(RID p_render_target) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
rt->clear_requested = false;
}
void RasterizerStorageRD::render_target_do_clear_request(RID p_render_target) {
-
RenderTarget *rt = render_target_owner.getornull(p_render_target);
ERR_FAIL_COND(!rt);
if (!rt->clear_requested) {
@@ -4778,7 +4647,6 @@ void RasterizerStorageRD::base_update_dependency(RID p_base, RasterizerScene::In
Mesh *mesh = mesh_owner.getornull(p_base);
p_instance->update_dependency(&mesh->instance_dependency);
} else if (multimesh_owner.owns(p_base)) {
-
MultiMesh *multimesh = multimesh_owner.getornull(p_base);
p_instance->update_dependency(&multimesh->instance_dependency);
if (multimesh->mesh.is_valid()) {
@@ -4803,7 +4671,6 @@ void RasterizerStorageRD::base_update_dependency(RID p_base, RasterizerScene::In
}
void RasterizerStorageRD::skeleton_update_dependency(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {
-
Skeleton *skeleton = skeleton_owner.getornull(p_skeleton);
ERR_FAIL_COND(!skeleton);
@@ -4811,7 +4678,6 @@ void RasterizerStorageRD::skeleton_update_dependency(RID p_skeleton, RasterizerS
}
RS::InstanceType RasterizerStorageRD::get_base_type(RID p_rid) const {
-
if (mesh_owner.owns(p_rid)) {
return RS::INSTANCE_MESH;
}
@@ -4896,7 +4762,7 @@ void RasterizerStorageRD::_update_decal_atlas() {
Vector<DecalAtlas::SortItem> itemsv;
itemsv.resize(decal_atlas.textures.size());
int base_size = 8;
- const RID *K = NULL;
+ const RID *K = nullptr;
int idx = 0;
while ((K = decal_atlas.textures.next(K))) {
@@ -4926,7 +4792,6 @@ void RasterizerStorageRD::_update_decal_atlas() {
int atlas_height = 0;
while (true) {
-
Vector<int> v_offsetsv;
v_offsetsv.resize(base_size);
@@ -4991,7 +4856,6 @@ void RasterizerStorageRD::_update_decal_atlas() {
t->uv_rect.size /= Size2(decal_atlas.size);
}
} else {
-
//use border as size, so it at least has enough mipmaps
decal_atlas.size.width = border;
decal_atlas.size.height = border;
@@ -5043,14 +4907,13 @@ void RasterizerStorageRD::_update_decal_atlas() {
Color clear_color(0, 0, 0, 0);
if (decal_atlas.textures.size()) {
-
if (i == 0) {
Vector<Color> cc;
cc.push_back(clear_color);
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(mm.fb, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, cc);
- const RID *K = NULL;
+ const RID *K = nullptr;
while ((K = decal_atlas.textures.next(K))) {
DecalAtlas::Texture *t = decal_atlas.textures.getptr(*K);
Texture *src_tex = texture_owner.getornull(*K);
@@ -5061,7 +4924,6 @@ void RasterizerStorageRD::_update_decal_atlas() {
prev_texture = mm.texture;
} else {
-
effects.copy_to_fb_rect(prev_texture, mm.fb, Rect2i(Point2i(), mm.size));
prev_texture = mm.texture;
}
@@ -5072,7 +4934,6 @@ void RasterizerStorageRD::_update_decal_atlas() {
}
int32_t RasterizerStorageRD::_global_variable_allocate(uint32_t p_elements) {
-
int32_t idx = 0;
while (idx + p_elements <= global_variables.buffer_size) {
if (global_variables.buffer_usage[idx].elements == 0) {
@@ -5099,10 +4960,8 @@ int32_t RasterizerStorageRD::_global_variable_allocate(uint32_t p_elements) {
}
void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS::GlobalVariableType p_type, const Variant &p_value) {
-
switch (p_type) {
case RS::GLOBAL_VAR_TYPE_BOOL: {
-
GlobalVariables::Value &bv = global_variables.buffer_values[p_index];
bool b = p_value;
bv.x = b ? 1.0 : 0.0;
@@ -5281,7 +5140,6 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS::
} break;
case RS::GLOBAL_VAR_TYPE_MAT3: {
-
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Basis v = p_value;
bv[0].x = v.elements[0][0];
@@ -5301,7 +5159,6 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS::
} break;
case RS::GLOBAL_VAR_TYPE_MAT4: {
-
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Vector<float> m2 = p_value;
@@ -5331,7 +5188,6 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS::
} break;
case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
-
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Transform2D v = p_value;
bv[0].x = v.elements[0][0];
@@ -5351,7 +5207,6 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS::
} break;
case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
-
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Transform v = p_value;
bv[0].x = v.basis.elements[0][0];
@@ -5382,7 +5237,6 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS::
}
void RasterizerStorageRD::_global_variable_mark_buffer_dirty(int32_t p_index, int32_t p_elements) {
-
int32_t prev_chunk = -1;
for (int32_t i = 0; i < p_elements; i++) {
@@ -5399,7 +5253,6 @@ void RasterizerStorageRD::_global_variable_mark_buffer_dirty(int32_t p_index, in
}
void RasterizerStorageRD::global_variable_add(const StringName &p_name, RS::GlobalVariableType p_type, const Variant &p_value) {
-
ERR_FAIL_COND(global_variables.variables.has(p_name));
GlobalVariables::Variable gv;
gv.type = p_type;
@@ -5410,7 +5263,6 @@ void RasterizerStorageRD::global_variable_add(const StringName &p_name, RS::Glob
//is texture
global_variables.must_update_texture_materials = true; //normally ther are no
} else {
-
gv.buffer_elements = 1;
if (p_type == RS::GLOBAL_VAR_TYPE_COLOR || p_type == RS::GLOBAL_VAR_TYPE_MAT2) {
//color needs to elements to store srgb and linear
@@ -5453,13 +5305,13 @@ void RasterizerStorageRD::global_variable_remove(const StringName &p_name) {
global_variables.variables.erase(p_name);
}
-Vector<StringName> RasterizerStorageRD::global_variable_get_list() const {
+Vector<StringName> RasterizerStorageRD::global_variable_get_list() const {
if (!Engine::get_singleton()->is_editor_hint()) {
ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance.");
}
- const StringName *K = NULL;
+ const StringName *K = nullptr;
Vector<StringName> names;
while ((K = global_variables.variables.next(K))) {
names.push_back(*K);
@@ -5487,6 +5339,7 @@ void RasterizerStorageRD::global_variable_set(const StringName &p_name, const Va
}
}
}
+
void RasterizerStorageRD::global_variable_set_override(const StringName &p_name, const Variant &p_value) {
if (!global_variables.variables.has(p_name)) {
return; //variable may not exist
@@ -5516,7 +5369,6 @@ void RasterizerStorageRD::global_variable_set_override(const StringName &p_name,
}
Variant RasterizerStorageRD::global_variable_get(const StringName &p_name) const {
-
if (!Engine::get_singleton()->is_editor_hint()) {
ERR_FAIL_V_MSG(Variant(), "This function should never be used outside the editor, it can severely damage performance.");
}
@@ -5529,7 +5381,6 @@ Variant RasterizerStorageRD::global_variable_get(const StringName &p_name) const
}
RS::GlobalVariableType RasterizerStorageRD::global_variable_get_type_internal(const StringName &p_name) const {
-
if (!global_variables.variables.has(p_name)) {
return RS::GLOBAL_VAR_TYPE_MAX;
}
@@ -5546,7 +5397,6 @@ RS::GlobalVariableType RasterizerStorageRD::global_variable_get_type(const Strin
}
void RasterizerStorageRD::global_variables_load_settings(bool p_load_textures) {
-
List<PropertyInfo> settings;
ProjectSettings::get_singleton()->get_property_list(&settings);
@@ -5652,8 +5502,8 @@ void RasterizerStorageRD::global_variables_instance_free(RID p_instance) {
}
global_variables.instance_buffer_pos.erase(p_instance);
}
-void RasterizerStorageRD::global_variables_instance_update(RID p_instance, int p_index, const Variant &p_value) {
+void RasterizerStorageRD::global_variables_instance_update(RID p_instance, int p_index, const Variant &p_value) {
if (!global_variables.instance_buffer_pos.has(p_instance)) {
return; //just not allocated, ignore
}
@@ -5697,7 +5547,6 @@ void RasterizerStorageRD::global_variables_instance_update(RID p_instance, int p
}
void RasterizerStorageRD::_update_global_variables() {
-
if (global_variables.buffer_dirty_region_count > 0) {
uint32_t total_regions = global_variables.buffer_size / GlobalVariables::BUFFER_DIRTY_REGION_SIZE;
if (total_regions / global_variables.buffer_dirty_region_count <= 4) {
@@ -5709,7 +5558,6 @@ void RasterizerStorageRD::_update_global_variables() {
for (uint32_t i = 0; i < total_regions; i++) {
if (global_variables.buffer_dirty_regions[i]) {
-
RD::get_singleton()->buffer_update(global_variables.buffer, i * region_byte_size, region_byte_size, global_variables.buffer_values);
global_variables.buffer_dirty_regions[i] = false;
@@ -5757,7 +5605,6 @@ void RasterizerStorageRD::update_dirty_resources() {
}
bool RasterizerStorageRD::has_os_feature(const String &p_feature) const {
-
if (p_feature == "rgtc" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC5_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
return true;
}
@@ -5780,8 +5627,8 @@ bool RasterizerStorageRD::has_os_feature(const String &p_feature) const {
return false;
}
-bool RasterizerStorageRD::free(RID p_rid) {
+bool RasterizerStorageRD::free(RID p_rid) {
if (texture_owner.owns(p_rid)) {
Texture *t = texture_owner.getornull(p_rid);
@@ -5878,7 +5725,6 @@ bool RasterizerStorageRD::free(RID p_rid) {
lightmap_owner.free(p_rid);
} else if (light_owner.owns(p_rid)) {
-
light_set_projector(p_rid, RID()); //clear projector
// delete the texture
Light *light = light_owner.getornull(p_rid);
@@ -5919,6 +5765,7 @@ void RasterizerStorageRD::capture_timestamp(const String &p_name) {
uint32_t RasterizerStorageRD::get_captured_timestamps_count() const {
return RD::get_singleton()->get_captured_timestamps_count();
}
+
uint64_t RasterizerStorageRD::get_captured_timestamps_frame() const {
return RD::get_singleton()->get_captured_timestamps_frame();
}
@@ -5926,9 +5773,11 @@ uint64_t RasterizerStorageRD::get_captured_timestamps_frame() const {
uint64_t RasterizerStorageRD::get_captured_timestamp_gpu_time(uint32_t p_index) const {
return RD::get_singleton()->get_captured_timestamp_gpu_time(p_index);
}
+
uint64_t RasterizerStorageRD::get_captured_timestamp_cpu_time(uint32_t p_index) const {
return RD::get_singleton()->get_captured_timestamp_cpu_time(p_index);
}
+
String RasterizerStorageRD::get_captured_timestamp_name(uint32_t p_index) const {
return RD::get_singleton()->get_captured_timestamp_name(p_index);
}
@@ -5936,7 +5785,6 @@ String RasterizerStorageRD::get_captured_timestamp_name(uint32_t p_index) const
RasterizerStorageRD *RasterizerStorageRD::base_singleton = nullptr;
RasterizerStorageRD::RasterizerStorageRD() {
-
base_singleton = this;
for (int i = 0; i < SHADER_TYPE_MAX; i++) {
@@ -6151,7 +5999,6 @@ RasterizerStorageRD::RasterizerStorageRD() {
sampler_state.max_lod = 0;
} break;
case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: {
-
sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
sampler_state.max_lod = 0;
@@ -6187,7 +6034,6 @@ RasterizerStorageRD::RasterizerStorageRD() {
}
switch (j) {
case RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: {
-
sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
@@ -6210,10 +6056,8 @@ RasterizerStorageRD::RasterizerStorageRD() {
//default rd buffers
{
-
Vector<uint8_t> buffer;
{
-
buffer.resize(sizeof(float) * 3);
{
uint8_t *w = buffer.ptrw();
@@ -6323,7 +6167,6 @@ RasterizerStorageRD::RasterizerStorageRD() {
using_lightmap_array = true; // high end
if (using_lightmap_array) {
-
uint32_t textures_per_stage = RD::get_singleton()->limit_get(RD::LIMIT_MAX_TEXTURES_PER_SHADER_STAGE);
if (textures_per_stage <= 256) {
@@ -6341,7 +6184,6 @@ RasterizerStorageRD::RasterizerStorageRD() {
}
RasterizerStorageRD::~RasterizerStorageRD() {
-
memdelete_arr(global_variables.buffer_values);
memdelete_arr(global_variables.buffer_usage);
memdelete_arr(global_variables.buffer_dirty_regions);
diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h
index 94b373247f..fe9377192e 100644
--- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h
+++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h
@@ -64,7 +64,6 @@ public:
typedef ShaderData *(*ShaderDataRequestFunction)();
struct MaterialData {
-
void update_uniform_buffer(const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Map<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color);
void update_textures(const Map<StringName, Variant> &p_parameters, const Map<StringName, RID> &p_default_textures, const Vector<ShaderCompilerRD::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color);
@@ -111,7 +110,6 @@ public:
private:
/* TEXTURE API */
struct Texture {
-
enum Type {
TYPE_2D,
TYPE_LAYERED,
@@ -190,7 +188,6 @@ private:
struct DecalAtlas {
struct Texture {
-
int panorama_to_dp_users;
int users;
Rect2 uv_rect;
@@ -274,7 +271,6 @@ private:
/* Mesh */
struct Mesh {
-
struct Surface {
RS::PrimitiveType primitive = RS::PRIMITIVE_POINTS;
uint32_t format = 0;
@@ -416,7 +412,6 @@ private:
/* LIGHT */
struct Light {
-
RS::LightType type;
float param[RS::LIGHT_PARAM_MAX];
Color color = Color(1, 1, 1, 1);
@@ -441,7 +436,6 @@ private:
/* REFLECTION PROBE */
struct ReflectionProbe {
-
RS::ReflectionProbeUpdateMode update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE;
int resolution = 256;
float intensity = 1.0;
@@ -464,7 +458,6 @@ private:
/* DECAL */
struct Decal {
-
Vector3 extents = Vector3(1, 1, 1);
RID textures[RS::DECAL_TEXTURE_MAX];
float emission_energy = 1.0;
@@ -486,7 +479,6 @@ private:
/* GI PROBE */
struct GIProbe {
-
RID octree_buffer;
RID data_buffer;
RID sdf_texture;
@@ -530,7 +522,6 @@ private:
/* REFLECTION PROBE */
struct Lightmap {
-
RID light_texture;
bool uses_spherical_harmonics = false;
bool interior = false;
@@ -564,7 +555,6 @@ private:
/* RENDER TARGET */
struct RenderTarget {
-
Size2i size;
RID framebuffer;
RID color;
@@ -605,7 +595,6 @@ private:
/* GLOBAL SHADER VARIABLES */
struct GlobalVariables {
-
enum {
BUFFER_DIRTY_REGION_SIZE = 1024
};
@@ -1074,7 +1063,6 @@ public:
AABB light_get_aabb(RID p_light) const;
_FORCE_INLINE_ float light_get_param(RID p_light, RS::LightParam p_param) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, 0);
@@ -1082,7 +1070,6 @@ public:
}
_FORCE_INLINE_ RID light_get_projector(RID p_light) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, RID());
@@ -1090,7 +1077,6 @@ public:
}
_FORCE_INLINE_ Color light_get_color(RID p_light) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, Color());
@@ -1098,7 +1084,6 @@ public:
}
_FORCE_INLINE_ Color light_get_shadow_color(RID p_light) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, Color());
@@ -1106,7 +1091,6 @@ public:
}
_FORCE_INLINE_ uint32_t light_get_cull_mask(RID p_light) {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, 0);
@@ -1114,7 +1098,6 @@ public:
}
_FORCE_INLINE_ bool light_has_shadow(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
@@ -1122,7 +1105,6 @@ public:
}
_FORCE_INLINE_ bool light_is_negative(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL);
@@ -1130,7 +1112,6 @@ public:
}
_FORCE_INLINE_ float light_get_transmittance_bias(RID p_light) const {
-
const Light *light = light_owner.getornull(p_light);
ERR_FAIL_COND_V(!light, 0.0);
diff --git a/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp
index 5838936f35..5cc3da8d4e 100644
--- a/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp
+++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp
@@ -32,7 +32,6 @@
#include "core/os/memory.h"
RID RenderPipelineVertexFormatCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe) {
-
RD::PipelineMultisampleState multisample_state_version = multisample_state;
multisample_state_version.sample_count = RD::get_singleton()->framebuffer_format_get_texture_samples(p_framebuffer_format_id);
@@ -51,7 +50,6 @@ RID RenderPipelineVertexFormatCacheRD::_generate_version(RD::VertexFormatID p_ve
}
void RenderPipelineVertexFormatCacheRD::_clear() {
-
if (versions) {
for (uint32_t i = 0; i < version_count; i++) {
//shader may be gone, so this may not be valid
diff --git a/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h
index a8bfdb5a26..cf15e79586 100644
--- a/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h
+++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h
@@ -35,7 +35,6 @@
#include "servers/rendering/rendering_device.h"
class RenderPipelineVertexFormatCacheRD {
-
SpinLock spin_lock;
RID shader;
diff --git a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
index 2ef29e97ff..32321164a1 100644
--- a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
+++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp
@@ -38,7 +38,6 @@
#define SL ShaderLanguage
static String _mktab(int p_level) {
-
String tb;
for (int i = 0; i < p_level; i++) {
tb += "\t";
@@ -48,7 +47,6 @@ static String _mktab(int p_level) {
}
static String _typestr(SL::DataType p_type) {
-
String type = ShaderLanguage::get_datatype_name(p_type);
if (ShaderLanguage::is_sampler_type(p_type)) {
type = type.replace("sampler", "texture"); //we use textures instead of samplers
@@ -57,9 +55,7 @@ static String _typestr(SL::DataType p_type) {
}
static int _get_datatype_size(SL::DataType p_type) {
-
switch (p_type) {
-
case SL::TYPE_VOID:
return 0;
case SL::TYPE_BOOL:
@@ -134,9 +130,7 @@ static int _get_datatype_size(SL::DataType p_type) {
}
static int _get_datatype_alignment(SL::DataType p_type) {
-
switch (p_type) {
-
case SL::TYPE_VOID:
return 0;
case SL::TYPE_BOOL:
@@ -208,8 +202,8 @@ static int _get_datatype_alignment(SL::DataType p_type) {
ERR_FAIL_V(0);
}
-static String _interpstr(SL::DataInterpolation p_interp) {
+static String _interpstr(SL::DataInterpolation p_interp) {
switch (p_interp) {
case SL::INTERPOLATION_FLAT:
return "flat ";
@@ -220,7 +214,6 @@ static String _interpstr(SL::DataInterpolation p_interp) {
}
static String _prestr(SL::DataPrecision p_pres) {
-
switch (p_pres) {
case SL::PRECISION_LOWP:
return "lowp ";
@@ -235,7 +228,6 @@ static String _prestr(SL::DataPrecision p_pres) {
}
static String _qualstr(SL::ArgumentQualifier p_qual) {
-
switch (p_qual) {
case SL::ARGUMENT_QUALIFIER_IN:
return "";
@@ -248,18 +240,15 @@ static String _qualstr(SL::ArgumentQualifier p_qual) {
}
static String _opstr(SL::Operator p_op) {
-
return SL::get_operator_text(p_op);
}
static String _mkid(const String &p_id) {
-
String id = "m_" + p_id.replace("__", "_dus_");
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
static String f2sp0(float p_float) {
-
String num = rtoss(p_float);
if (num.find(".") == -1 && num.find("e") == -1) {
num += ".0";
@@ -268,18 +257,17 @@ static String f2sp0(float p_float) {
}
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
-
switch (p_type) {
case SL::TYPE_BOOL:
return p_values[0].boolean ? "true" : "false";
case SL::TYPE_BVEC2:
case SL::TYPE_BVEC3:
case SL::TYPE_BVEC4: {
-
String text = "bvec" + itos(p_type - SL::TYPE_BOOL + 1) + "(";
for (int i = 0; i < p_values.size(); i++) {
- if (i > 0)
+ if (i > 0) {
text += ",";
+ }
text += p_values[i].boolean ? "true" : "false";
}
@@ -292,11 +280,11 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_IVEC2:
case SL::TYPE_IVEC3:
case SL::TYPE_IVEC4: {
-
String text = "ivec" + itos(p_type - SL::TYPE_INT + 1) + "(";
for (int i = 0; i < p_values.size(); i++) {
- if (i > 0)
+ if (i > 0) {
text += ",";
+ }
text += itos(p_values[i].sint);
}
@@ -309,11 +297,11 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_UVEC2:
case SL::TYPE_UVEC3:
case SL::TYPE_UVEC4: {
-
String text = "uvec" + itos(p_type - SL::TYPE_UINT + 1) + "(";
for (int i = 0; i < p_values.size(); i++) {
- if (i > 0)
+ if (i > 0) {
text += ",";
+ }
text += itos(p_values[i].uint) + "u";
}
@@ -325,11 +313,11 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_VEC2:
case SL::TYPE_VEC3:
case SL::TYPE_VEC4: {
-
String text = "vec" + itos(p_type - SL::TYPE_FLOAT + 1) + "(";
for (int i = 0; i < p_values.size(); i++) {
- if (i > 0)
+ if (i > 0) {
text += ",";
+ }
text += f2sp0(p_values[i].real);
}
@@ -340,11 +328,11 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
case SL::TYPE_MAT2:
case SL::TYPE_MAT3:
case SL::TYPE_MAT4: {
-
String text = "mat" + itos(p_type - SL::TYPE_MAT2 + 2) + "(";
for (int i = 0; i < p_values.size(); i++) {
- if (i > 0)
+ if (i > 0) {
text += ",";
+ }
text += f2sp0(p_values[i].real);
}
@@ -370,7 +358,6 @@ String ShaderCompilerRD::_get_sampler_name(ShaderLanguage::TextureFilter p_filte
}
void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, String &r_to_add, Set<StringName> &added) {
-
int fidx = -1;
for (int i = 0; i < p_node->functions.size(); i++) {
@@ -383,7 +370,6 @@ void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const S
ERR_FAIL_COND(fidx == -1);
for (Set<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) {
-
if (added.has(E->get())) {
continue; //was added already
}
@@ -410,9 +396,9 @@ void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const S
header = _typestr(fnode->return_type) + " " + _mkid(fnode->name) + "(";
}
for (int i = 0; i < fnode->arguments.size(); i++) {
-
- if (i > 0)
+ if (i > 0) {
header += ", ";
+ }
if (fnode->arguments[i].type == SL::TYPE_STRUCT) {
header += _qualstr(fnode->arguments[i].qualifier) + _mkid(fnode->arguments[i].type_str) + " " + _mkid(fnode->arguments[i].name);
} else {
@@ -493,20 +479,15 @@ static String _get_global_variable_from_type_and_index(const String &p_buffer, c
}
}
-String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning) {
-
+String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) {
String code;
switch (p_node->type) {
-
case SL::Node::TYPE_SHADER: {
-
SL::ShaderNode *pnode = (SL::ShaderNode *)p_node;
for (int i = 0; i < pnode->render_modes.size(); i++) {
-
if (p_default_actions.render_mode_defines.has(pnode->render_modes[i]) && !used_rmode_defines.has(pnode->render_modes[i])) {
-
r_gen_code.defines.push_back(p_default_actions.render_mode_defines[pnode->render_modes[i]]);
used_rmode_defines.insert(pnode->render_modes[i]);
}
@@ -524,7 +505,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
// structs
for (int i = 0; i < pnode->vstructs.size(); i++) {
-
SL::StructNode *st = pnode->vstructs[i].shader_struct;
String struct_code;
@@ -560,11 +540,9 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
int max_uniforms = 0;
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
-
if (SL::is_sampler_type(E->get().type)) {
max_texture_uniforms++;
} else {
-
if (E->get().scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) {
continue; //instances are indexed directly, dont need index uniforms
}
@@ -584,7 +562,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
bool uses_uniforms = false;
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
-
String ucode;
if (E->get().scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) {
@@ -626,7 +603,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
r_gen_code.texture_uniforms.write[E->get().texture_order] = texture;
} else {
if (!uses_uniforms) {
-
r_gen_code.defines.push_back(String("#define USE_MATERIAL_UNIFORMS\n"));
uses_uniforms = true;
}
@@ -652,7 +628,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
// add up
int offset = 0;
for (int i = 0; i < uniform_sizes.size(); i++) {
-
int align = offset % uniform_alignments[i];
if (align != 0) {
@@ -672,9 +647,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
#else
// add up
for (int i = 0; i < uniform_sizes.size(); i++) {
-
if (i > 0) {
-
int align = uniform_sizes[i - 1] % uniform_alignments[i];
if (align != 0) {
uniform_sizes[i - 1] += uniform_alignments[i] - align;
@@ -686,7 +659,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
//offset
r_gen_code.uniform_offsets.resize(uniform_sizes.size());
for (int i = 0; i < uniform_sizes.size(); i++) {
-
if (i > 0)
r_gen_code.uniform_offsets[i] = uniform_sizes[i - 1];
else
@@ -712,7 +684,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
uint32_t index = p_default_actions.base_varying_index;
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
-
String vcode;
String interp_mode = _interpstr(E->get().interpolation);
vcode += _prestr(E->get().precision);
@@ -764,7 +735,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
Set<StringName> added_fragment; //share for light
for (int i = 0; i < pnode->functions.size(); i++) {
-
SL::FunctionNode *fnode = pnode->functions[i].function;
function = fnode;
@@ -772,19 +742,16 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
current_func_name = fnode->name;
if (fnode->name == vertex_name) {
-
_dump_function_deps(pnode, fnode->name, function_code, r_gen_code.vertex_global, added_vtx);
r_gen_code.vertex = function_code[vertex_name];
}
if (fnode->name == fragment_name) {
-
_dump_function_deps(pnode, fnode->name, function_code, r_gen_code.fragment_global, added_fragment);
r_gen_code.fragment = function_code[fragment_name];
}
if (fnode->name == light_name) {
-
_dump_function_deps(pnode, fnode->name, function_code, r_gen_code.fragment_global, added_fragment);
r_gen_code.light = function_code[light_name];
}
@@ -794,10 +761,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
//code+=dump_node_code(pnode->body,p_level);
} break;
case SL::Node::TYPE_STRUCT: {
-
} break;
case SL::Node::TYPE_FUNCTION: {
-
} break;
case SL::Node::TYPE_BLOCK: {
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
@@ -808,7 +773,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
}
for (int i = 0; i < bnode->statements.size(); i++) {
-
String scode = _dump_node_code(bnode->statements[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->single_statement) {
@@ -870,9 +834,9 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
used_flag_pointers.insert(vnode->name);
}
- if (p_default_actions.renames.has(vnode->name))
+ if (p_default_actions.renames.has(vnode->name)) {
code = p_default_actions.renames[vnode->name];
- else {
+ } else {
if (shader->uniforms.has(vnode->name)) {
//its a uniform!
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[vnode->name];
@@ -930,7 +894,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
code += ")";
} break;
case SL::Node::TYPE_ARRAY_DECLARATION: {
-
SL::ArrayDeclarationNode *adnode = (SL::ArrayDeclarationNode *)p_node;
String declaration;
if (adnode->is_const) {
@@ -996,14 +959,15 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
used_flag_pointers.insert(anode->name);
}
- if (p_default_actions.renames.has(anode->name))
+ if (p_default_actions.renames.has(anode->name)) {
code = p_default_actions.renames[anode->name];
- else
+ } else {
code = _mkid(anode->name);
+ }
if (anode->call_expression != nullptr) {
code += ".";
- code += _dump_node_code(anode->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ code += _dump_node_code(anode->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning, false);
}
if (anode->index_expression != nullptr) {
@@ -1031,7 +995,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
SL::OperatorNode *onode = (SL::OperatorNode *)p_node;
switch (onode->op) {
-
case SL::OP_ASSIGN:
case SL::OP_ASSIGN_ADD:
case SL::OP_ASSIGN_SUB:
@@ -1059,7 +1022,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
case SL::OP_CALL:
case SL::OP_STRUCT:
case SL::OP_CONSTRUCT: {
-
ERR_FAIL_COND_V(onode->arguments[0]->type != SL::Node::TYPE_VARIABLE, String());
SL::VariableNode *vnode = (SL::VariableNode *)onode->arguments[0];
@@ -1070,7 +1032,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
} else if (onode->op == SL::OP_CONSTRUCT) {
code += String(vnode->name);
} else {
-
if (internal_functions.has(vnode->name)) {
code += vnode->name;
is_texture_func = texture_functions.has(vnode->name);
@@ -1084,11 +1045,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
code += "(";
for (int i = 1; i < onode->arguments.size(); i++) {
- if (i > 1)
+ if (i > 1) {
code += ", ";
+ }
String node_code = _dump_node_code(onode->arguments[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
if (is_texture_func && i == 1 && onode->arguments[i]->type == SL::Node::TYPE_VARIABLE) {
-
//need to map from texture to sampler in order to sample
const SL::VariableNode *varnode = static_cast<const SL::VariableNode *>(onode->arguments[i]);
@@ -1134,7 +1095,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
code += ")";
} break;
case SL::OP_INDEX: {
-
code += _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += "[";
code += _dump_node_code(onode->arguments[1], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
@@ -1142,7 +1102,6 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
} break;
case SL::OP_SELECT_IF: {
-
code += "(";
code += _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
code += "?";
@@ -1154,8 +1113,13 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
} break;
default: {
-
- code = "(" + _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + _opstr(onode->op) + _dump_node_code(onode->arguments[1], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")";
+ if (p_use_scope) {
+ code += "(";
+ }
+ code += _dump_node_code(onode->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + _opstr(onode->op) + _dump_node_code(onode->arguments[1], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
+ if (p_use_scope) {
+ code += ")";
+ }
break;
}
}
@@ -1164,37 +1128,29 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
case SL::Node::TYPE_CONTROL_FLOW: {
SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node;
if (cfnode->flow_op == SL::FLOW_OP_IF) {
-
code += _mktab(p_level) + "if (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
if (cfnode->blocks.size() == 2) {
-
code += _mktab(p_level) + "else\n";
code += _dump_node_code(cfnode->blocks[1], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
}
} else if (cfnode->flow_op == SL::FLOW_OP_SWITCH) {
-
code += _mktab(p_level) + "switch (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cfnode->flow_op == SL::FLOW_OP_CASE) {
-
code += _mktab(p_level) + "case " + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ":\n";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cfnode->flow_op == SL::FLOW_OP_DEFAULT) {
-
code += _mktab(p_level) + "default:\n";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cfnode->flow_op == SL::FLOW_OP_DO) {
-
code += _mktab(p_level) + "do";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
code += _mktab(p_level) + "while (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ");";
} else if (cfnode->flow_op == SL::FLOW_OP_WHILE) {
-
code += _mktab(p_level) + "while (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cfnode->flow_op == SL::FLOW_OP_FOR) {
-
String left = _dump_node_code(cfnode->blocks[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
String middle = _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
String right = _dump_node_code(cfnode->expressions[1], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
@@ -1202,14 +1158,12 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
code += _dump_node_code(cfnode->blocks[1], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
} else if (cfnode->flow_op == SL::FLOW_OP_RETURN) {
-
if (cfnode->expressions.size()) {
code = "return " + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ";";
} else {
code = "return;";
}
} else if (cfnode->flow_op == SL::FLOW_OP_DISCARD) {
-
if (p_actions.usage_flag_pointers.has("DISCARD") && !used_flag_pointers.has("DISCARD")) {
*p_actions.usage_flag_pointers["DISCARD"] = true;
used_flag_pointers.insert("DISCARD");
@@ -1217,10 +1171,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge
code = "discard;";
} else if (cfnode->flow_op == SL::FLOW_OP_CONTINUE) {
-
code = "continue;";
} else if (cfnode->flow_op == SL::FLOW_OP_BREAK) {
-
code = "break;";
}
@@ -1246,11 +1198,9 @@ ShaderLanguage::DataType ShaderCompilerRD::_get_variable_type(const StringName &
}
Error ShaderCompilerRD::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
-
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types(), _get_variable_type);
if (err != OK) {
-
Vector<String> shader = p_code.split("\n");
for (int i = 0; i < shader.size(); i++) {
print_line(itos(i + 1) + " " + shader[i]);
diff --git a/servers/rendering/rasterizer_rd/shader_compiler_rd.h b/servers/rendering/rasterizer_rd/shader_compiler_rd.h
index 16d53197a7..ce94fb743f 100644
--- a/servers/rendering/rasterizer_rd/shader_compiler_rd.h
+++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.h
@@ -39,7 +39,6 @@
class ShaderCompilerRD {
public:
struct IdentifierActions {
-
Map<StringName, Pair<int *, int>> render_mode_values;
Map<StringName, bool *> render_mode_flags;
Map<StringName, bool *> usage_flag_pointers;
@@ -49,7 +48,6 @@ public:
};
struct GeneratedCode {
-
Vector<String> defines;
struct Texture {
StringName name;
@@ -77,7 +75,6 @@ public:
};
struct DefaultIdentifierActions {
-
Map<StringName, String> renames;
Map<StringName, String> render_mode_defines;
Map<StringName, String> usage_defines;
@@ -99,7 +96,7 @@ private:
String _get_sampler_name(ShaderLanguage::TextureFilter p_filter, ShaderLanguage::TextureRepeat p_repeat);
void _dump_function_deps(const ShaderLanguage::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, String &r_to_add, Set<StringName> &added);
- String _dump_node_code(const ShaderLanguage::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning);
+ String _dump_node_code(const ShaderLanguage::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_scope = true);
const ShaderLanguage::ShaderNode *shader;
const ShaderLanguage::FunctionNode *function;
diff --git a/servers/rendering/rasterizer_rd/shader_rd.cpp b/servers/rendering/rasterizer_rd/shader_rd.cpp
index d60a58813e..8c57651263 100644
--- a/servers/rendering/rasterizer_rd/shader_rd.cpp
+++ b/servers/rendering/rasterizer_rd/shader_rd.cpp
@@ -35,7 +35,6 @@
#include "servers/rendering/rendering_device.h"
void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, const char *p_compute_code, const char *p_name) {
-
name = p_name;
//split vertex and shader code (thank you, shader compiler programmers from you know what company).
if (p_vertex_code) {
@@ -64,7 +63,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
vertex_code1 = code.ascii();
} else {
-
vertex_code1 = code.substr(0, cpos).ascii();
String code2 = code.substr(cpos + globals_tag.length(), code.length());
@@ -72,7 +70,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
vertex_code2 = code2.ascii();
} else {
-
vertex_code2 = code2.substr(0, cpos).ascii();
vertex_code3 = code2.substr(cpos + code_tag.length(), code2.length()).ascii();
}
@@ -106,7 +103,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
fragment_code1 = code.ascii();
} else {
-
fragment_code1 = code.substr(0, cpos).ascii();
//print_line("CODE1:\n"+String(fragment_code1.get_data()));
@@ -116,7 +112,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
fragment_code2 = code2.ascii();
} else {
-
fragment_code2 = code2.substr(0, cpos).ascii();
//print_line("CODE2:\n"+String(fragment_code2.get_data()));
@@ -126,7 +121,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
fragment_code3 = code3.ascii();
} else {
-
fragment_code3 = code3.substr(0, cpos).ascii();
//print_line("CODE3:\n"+String(fragment_code3.get_data()));
fragment_code4 = code3.substr(cpos + code_tag.length(), code3.length()).ascii();
@@ -165,7 +159,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
compute_code1 = code.ascii();
} else {
-
compute_code1 = code.substr(0, cpos).ascii();
String code2 = code.substr(cpos + globals_tag.length(), code.length());
@@ -173,7 +166,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
if (cpos == -1) {
compute_code2 = code2.ascii();
} else {
-
compute_code2 = code2.substr(0, cpos).ascii();
compute_code3 = code2.substr(cpos + code_tag.length(), code2.length()).ascii();
}
@@ -183,7 +175,6 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con
}
RID ShaderRD::version_create() {
-
//initialize() was never called
ERR_FAIL_COND_V(variant_defines.size() == 0, RID());
@@ -208,7 +199,6 @@ void ShaderRD::_clear_version(Version *p_version) {
}
void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
-
Vector<RD::ShaderStageData> stages;
String error;
@@ -250,7 +240,6 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
if (stage.spir_v.size() == 0) {
build_ok = false;
} else {
-
stage.shader_stage = RD::SHADER_STAGE_VERTEX;
stages.push_back(stage);
}
@@ -295,7 +284,6 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
if (stage.spir_v.size() == 0) {
build_ok = false;
} else {
-
stage.shader_stage = RD::SHADER_STAGE_FRAGMENT;
stages.push_back(stage);
}
@@ -336,7 +324,6 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
if (stage.spir_v.size() == 0) {
build_ok = false;
} else {
-
stage.shader_stage = RD::SHADER_STAGE_COMPUTE;
stages.push_back(stage);
}
@@ -361,7 +348,6 @@ void ShaderRD::_compile_variant(uint32_t p_variant, Version *p_version) {
}
void ShaderRD::_compile_version(Version *p_version) {
-
_clear_version(p_version);
p_version->valid = false;
@@ -373,7 +359,6 @@ void ShaderRD::_compile_version(Version *p_version) {
RasterizerRD::thread_work_pool.do_work(variant_defines.size(), this, &ShaderRD::_compile_variant, p_version);
#else
for (int i = 0; i < variant_defines.size(); i++) {
-
_compile_variant(i, p_version);
}
#endif
@@ -402,7 +387,6 @@ void ShaderRD::_compile_version(Version *p_version) {
}
void ShaderRD::version_set_code(RID p_version, const String &p_uniforms, const String &p_vertex_globals, const String &p_vertex_code, const String &p_fragment_globals, const String &p_fragment_light, const String &p_fragment_code, const Vector<String> &p_custom_defines) {
-
ERR_FAIL_COND(is_compute);
Version *version = version_owner.getornull(p_version);
@@ -427,7 +411,6 @@ void ShaderRD::version_set_code(RID p_version, const String &p_uniforms, const S
}
void ShaderRD::version_set_compute_code(RID p_version, const String &p_uniforms, const String &p_compute_globals, const String &p_compute_code, const Vector<String> &p_custom_defines) {
-
ERR_FAIL_COND(!is_compute);
Version *version = version_owner.getornull(p_version);
@@ -460,7 +443,6 @@ bool ShaderRD::version_is_valid(RID p_version) {
}
bool ShaderRD::version_free(RID p_version) {
-
if (version_owner.owns(p_version)) {
Version *version = version_owner.getornull(p_version);
_clear_version(version);
@@ -477,7 +459,6 @@ void ShaderRD::initialize(const Vector<String> &p_variant_defines, const String
ERR_FAIL_COND(p_variant_defines.size() == 0);
general_defines = p_general_defines.utf8();
for (int i = 0; i < p_variant_defines.size(); i++) {
-
variant_defines.push_back(p_variant_defines[i].utf8());
}
}
diff --git a/servers/rendering/rasterizer_rd/shader_rd.h b/servers/rendering/rasterizer_rd/shader_rd.h
index 6635b08cc8..d9bb068ba6 100644
--- a/servers/rendering/rasterizer_rd/shader_rd.h
+++ b/servers/rendering/rasterizer_rd/shader_rd.h
@@ -43,7 +43,6 @@
*/
class ShaderRD {
-
//versions
CharString general_defines;
Vector<CharString> variant_defines;
diff --git a/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl b/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl
index 7153fe6b17..63f086a83d 100644
--- a/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
@@ -8,7 +7,6 @@ VERSION_DEFINES
#define BLOCK_SIZE 8
layout(local_size_x = BLOCK_SIZE, local_size_y = BLOCK_SIZE, local_size_z = 1) in;
-/* clang-format on */
#ifdef MODE_GEN_BLUR_SIZE
layout(rgba16f, set = 0, binding = 0) uniform restrict image2D color_image;
@@ -69,7 +67,6 @@ float get_depth_at_pos(vec2 uv) {
}
float get_blur_size(float depth) {
-
if (params.blur_near_active && depth < params.blur_near_begin) {
return -(1.0 - smoothstep(params.blur_near_end, params.blur_near_begin, depth)) * params.blur_size - DEPTH_GAP; //near blur is negative
}
@@ -95,7 +92,6 @@ float hash12n(vec2 p) {
#if defined(MODE_BOKEH_BOX) || defined(MODE_BOKEH_HEXAGONAL)
vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) {
-
dir *= pixel_size;
vec4 color = texture(color_texture, uv);
@@ -109,7 +105,6 @@ vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) {
}
for (int i = -params.blur_steps; i <= params.blur_steps; i++) {
-
if (i == 0) {
continue;
}
@@ -141,7 +136,6 @@ vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) {
#endif
void main() {
-
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThan(pos, params.size))) { //too large, do nothing
@@ -218,7 +212,6 @@ void main() {
float radius = params.blur_scale;
for (float ang = 0.0; radius < params.blur_size; ang += GOLDEN_ANGLE) {
-
vec2 suv = uv + vec2(cos(ang), sin(ang)) * pixel_size * radius;
vec4 sample_color = texture(color_texture, suv);
float sample_size = abs(sample_color.a);
diff --git a/servers/rendering/rasterizer_rd/shaders/canvas.glsl b/servers/rendering/rasterizer_rd/shaders/canvas.glsl
index 28135fce31..e33b3face9 100644
--- a/servers/rendering/rasterizer_rd/shaders/canvas.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/canvas.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
@@ -7,7 +6,6 @@ VERSION_DEFINES
#ifdef USE_ATTRIBUTES
layout(location = 0) in vec2 vertex_attrib;
-/* clang-format on */
layout(location = 3) in vec4 color_attrib;
layout(location = 4) in vec2 uv_attrib;
@@ -40,7 +38,6 @@ VERTEX_SHADER_GLOBALS
/* clang-format on */
void main() {
-
vec4 instance_custom = vec4(0.0);
#ifdef USE_PRIMITIVE
@@ -88,7 +85,6 @@ void main() {
#if 0
if (draw_data.flags & FLAGS_INSTANCING_ENABLED) {
-
uint offset = draw_data.flags & FLAGS_INSTANCING_STRIDE_MASK;
offset *= gl_InstanceIndex;
mat4 instance_xform = mat4(
@@ -149,7 +145,6 @@ VERTEX_SHADER_CODE
color_interp = color;
if (bool(draw_data.flags & FLAGS_USE_PIXEL_SNAP)) {
-
vertex = floor(vertex + 0.5);
// precision issue on some hardware creates artifacts within texture
// offset uv by a small amount to avoid
@@ -160,7 +155,6 @@ VERTEX_SHADER_CODE
#if 0
if (bool(draw_data.flags & FLAGS_USE_SKELETON) && bone_weights != vec4(0.0)) { //must be a valid bone
//skeleton transform
-
ivec4 bone_indicesi = ivec4(bone_indices);
uvec2 tex_ofs = bone_indicesi.x * 2;
@@ -211,8 +205,7 @@ VERTEX_SHADER_CODE
#endif
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
@@ -221,7 +214,6 @@ VERSION_DEFINES
#include "canvas_uniforms_inc.glsl"
layout(location = 0) in vec2 uv_interp;
-/* clang-format on */
layout(location = 1) in vec4 color_interp;
layout(location = 2) in vec2 vertex_interp;
@@ -258,7 +250,6 @@ vec4 light_compute(
vec2 screen_uv,
vec2 uv,
vec4 color) {
-
vec4 light = vec4(0.0);
/* clang-format off */
LIGHT_SHADER_CODE
@@ -271,7 +262,6 @@ LIGHT_SHADER_CODE
#ifdef USE_NINEPATCH
float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, float margin_begin, float margin_end, int np_repeat, inout int draw_center) {
-
float tex_size = 1.0 / tex_pixel_size;
if (pixel < margin_begin) {
@@ -313,7 +303,6 @@ float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, flo
#endif
void main() {
-
vec4 color = color_interp;
vec2 uv = uv_interp;
vec2 vertex = vertex_interp;
@@ -335,7 +324,6 @@ void main() {
#endif
if (bool(draw_data.flags & FLAGS_CLIP_RECT_UV)) {
-
uv = clamp(uv, draw_data.src_rect.xy, draw_data.src_rect.xy + abs(draw_data.src_rect.zw));
}
@@ -348,7 +336,6 @@ void main() {
vec3 normal;
#if defined(NORMAL_USED)
-
bool normal_used = true;
#else
bool normal_used = false;
@@ -458,7 +445,6 @@ FRAGMENT_SHADER_CODE
light_color.rgb *= light_base_color.rgb * light_base_color.a;
if (normal_used) {
-
vec3 light_pos = vec3(light_array.data[light_base].position, light_array.data[light_base].height);
vec3 pos = light_vertex;
vec3 light_vec = normalize(light_pos - pos);
@@ -490,7 +476,6 @@ FRAGMENT_SHADER_CODE
}
if (bool(light_array.data[light_base].flags & LIGHT_FLAGS_HAS_SHADOW)) {
-
vec2 shadow_pos = (vec4(shadow_vertex, 0.0, 1.0) * mat4(light_array.data[light_base].shadow_matrix[0], light_array.data[light_base].shadow_matrix[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0))).xy; //multiply inverse given its transposed. Optimizer removes useless operations.
vec2 pos_norm = normalize(shadow_pos);
diff --git a/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl b/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl
index 7b30cc8fe9..99e70a1976 100644
--- a/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl
@@ -1,13 +1,10 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
layout(location = 0) in highp vec3 vertex;
-/* clang-format on */
layout(push_constant, binding = 0, std430) uniform Constants {
-
mat4 projection;
mat2x4 modelview;
vec2 direction;
@@ -18,23 +15,19 @@ constants;
layout(location = 0) out highp float depth;
void main() {
-
highp vec4 vtx = vec4(vertex, 1.0) * mat4(constants.modelview[0], constants.modelview[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
depth = dot(constants.direction, vtx.xy);
gl_Position = constants.projection * vtx;
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
layout(location = 0) in highp float depth;
-/* clang-format on */
layout(location = 0) out highp float distance_buf;
void main() {
-
distance_buf = depth;
}
diff --git a/servers/rendering/rasterizer_rd/shaders/copy.glsl b/servers/rendering/rasterizer_rd/shaders/copy.glsl
index 075ee2af22..eb39c28fa9 100644
--- a/servers/rendering/rasterizer_rd/shaders/copy.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/copy.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
#define FLAG_HORIZONTAL (1 << 0)
#define FLAG_USE_BLUR_SECTION (1 << 1)
@@ -60,7 +58,6 @@ layout(rgba32f, set = 3, binding = 0) uniform restrict writeonly image2D dest_bu
#endif
void main() {
-
// Pixel being shaded
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThanEqual(pos, params.section.zw))) { //too large, do nothing
@@ -84,7 +81,6 @@ void main() {
//Simpler blur uses SIGMA2 for the gaussian kernel for a stronger effect
if (bool(params.flags & FLAG_HORIZONTAL)) {
-
ivec2 base_pos = (pos + params.section.xy) << 1;
vec4 color = texelFetch(source_color, base_pos + ivec2(0, 0), 0) * 0.214607;
color += texelFetch(source_color, base_pos + ivec2(1, 0), 0) * 0.189879;
@@ -95,7 +91,6 @@ void main() {
color += texelFetch(source_color, base_pos + ivec2(-3, 0), 0) * 0.071303;
imageStore(dest_buffer, pos + params.target, color);
} else {
-
ivec2 base_pos = (pos + params.section.xy);
vec4 color = texelFetch(source_color, base_pos + ivec2(0, 0), 0) * 0.38774;
color += texelFetch(source_color, base_pos + ivec2(0, 1), 0) * 0.24477;
@@ -121,7 +116,6 @@ void main() {
vec4 color = vec4(0.0);
if (bool(params.flags & FLAG_HORIZONTAL)) {
-
ivec2 base_pos = (pos + params.section.xy) << 1;
ivec2 section_begin = params.section.xy << 1;
ivec2 section_end = section_begin + (params.section.zw << 1);
@@ -135,7 +129,6 @@ void main() {
GLOW_ADD(ivec2(-3, 0), 0.106595);
color *= params.glow_strength;
} else {
-
ivec2 base_pos = pos + params.section.xy;
ivec2 section_begin = params.section.xy;
ivec2 section_end = section_begin + params.section.zw;
diff --git a/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl b/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl
index 07f8d09743..b1cfe1e91e 100644
--- a/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
VERSION_DEFINES
layout(location = 0) out vec2 uv_interp;
-/* clang-format on */
layout(push_constant, binding = 1, std430) uniform Params {
vec4 section;
@@ -20,7 +18,6 @@ layout(push_constant, binding = 1, std430) uniform Params {
params;
void main() {
-
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
uv_interp = base_arr[gl_VertexIndex];
@@ -36,8 +33,7 @@ void main() {
}
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
@@ -52,18 +48,16 @@ layout(push_constant, binding = 1, std430) uniform Params {
bool force_luminance;
bool alpha_to_zero;
uint pad[2];
-} params;
-
+}
+params;
layout(location = 0) in vec2 uv_interp;
-/* clang-format on */
layout(set = 0, binding = 0) uniform sampler2D source_color;
layout(location = 0) out vec4 frag_color;
void main() {
-
vec2 uv = uv_interp;
#ifdef MODE_PANORAMA_TO_DP
@@ -83,8 +77,9 @@ void main() {
vec2 st = vec2(atan(normal.x, normal.z), acos(normal.y));
- if (st.x < 0.0)
+ if (st.x < 0.0) {
st.x += M_PI * 2.0;
+ }
uv = st / vec2(M_PI * 2.0, M_PI);
diff --git a/servers/rendering/rasterizer_rd/shaders/cube_to_dp.glsl b/servers/rendering/rasterizer_rd/shaders/cube_to_dp.glsl
index 02ebe1a53b..54d67db6c6 100644
--- a/servers/rendering/rasterizer_rd/shaders/cube_to_dp.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cube_to_dp.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
layout(set = 0, binding = 0) uniform samplerCube source_cube;
@@ -23,7 +21,6 @@ params;
layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D depth_buffer;
void main() {
-
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThan(pos, params.screen_size))) { //too large, do nothing
return;
diff --git a/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl
index 9f3ecf6053..7f269b7af3 100644
--- a/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl
@@ -18,8 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
-/* clang-format off */
-[compute]
+#[compute]
#version 450
@@ -28,7 +27,6 @@ VERSION_DEFINES
#define BLOCK_SIZE 8
layout(local_size_x = BLOCK_SIZE, local_size_y = BLOCK_SIZE, local_size_z = 1) in;
-/* clang-format on */
layout(set = 0, binding = 0) uniform samplerCube source_cubemap;
@@ -46,26 +44,31 @@ void get_dir_0(out vec3 dir, in float u, in float v) {
dir[1] = v;
dir[2] = -u;
}
+
void get_dir_1(out vec3 dir, in float u, in float v) {
dir[0] = -1.0;
dir[1] = v;
dir[2] = u;
}
+
void get_dir_2(out vec3 dir, in float u, in float v) {
dir[0] = u;
dir[1] = 1.0;
dir[2] = -v;
}
+
void get_dir_3(out vec3 dir, in float u, in float v) {
dir[0] = u;
dir[1] = -1.0;
dir[2] = v;
}
+
void get_dir_4(out vec3 dir, in float u, in float v) {
dir[0] = u;
dir[1] = v;
dir[2] = 1.0;
}
+
void get_dir_5(out vec3 dir, in float u, in float v) {
dir[0] = -u;
dir[1] = v;
diff --git a/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl
index 193d0a8a3c..987545fb76 100644
--- a/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl
@@ -18,8 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
-/* clang-format off */
-[compute]
+#[compute]
#version 450
@@ -28,7 +27,6 @@ VERSION_DEFINES
#define GROUP_SIZE 64
layout(local_size_x = GROUP_SIZE, local_size_y = 1, local_size_z = 1) in;
-/* clang-format on */
layout(set = 0, binding = 0) uniform samplerCube source_cubemap;
layout(rgba16f, set = 2, binding = 0) uniform restrict writeonly imageCube dest_cubemap0;
diff --git a/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl
index e85996fa1a..5cbb00baa4 100644
--- a/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
@@ -8,7 +7,6 @@ VERSION_DEFINES
#define GROUP_SIZE 8
layout(local_size_x = GROUP_SIZE, local_size_y = GROUP_SIZE, local_size_z = 1) in;
-/* clang-format on */
layout(set = 0, binding = 0) uniform samplerCube source_cube;
@@ -119,10 +117,8 @@ void main() {
//vec4 color = color_interp;
if (params.use_direct_write) {
-
imageStore(dest_cubemap, ivec3(id), vec4(texture(source_cube, N).rgb, 1.0));
} else {
-
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
for (uint sampleNum = 0u; sampleNum < params.sample_count; sampleNum++) {
@@ -135,7 +131,6 @@ void main() {
float ndotl = clamp(dot(N, L), 0.0, 1.0);
if (ndotl > 0.0) {
-
sum.rgb += textureLod(source_cube, L, 0.0).rgb * ndotl;
sum.a += ndotl;
}
diff --git a/servers/rendering/rasterizer_rd/shaders/giprobe.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe.glsl
index fd09f96a57..ea4237a45e 100644
--- a/servers/rendering/rasterizer_rd/shaders/giprobe.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
@@ -10,7 +9,6 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
#else
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
#endif
-/* clang-format on */
#ifndef MODE_DYNAMIC
@@ -47,7 +45,6 @@ cell_data;
#if defined(MODE_COMPUTE_LIGHT) || defined(MODE_DYNAMIC_LIGHTING)
struct Light {
-
uint type;
float energy;
float radius;
@@ -191,7 +188,6 @@ layout(r16ui, set = 0, binding = 13) uniform restrict writeonly uimage3D aniso_n
#if defined(MODE_COMPUTE_LIGHT) || defined(MODE_DYNAMIC_LIGHTING)
float raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
-
vec3 cell_size = 1.0 / vec3(params.limits);
float occlusion = 1.0;
while (distance > 0.5) { //use this to avoid precision errors
@@ -213,14 +209,11 @@ float raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
}
bool compute_light_vector(uint light, vec3 pos, out float attenuation, out vec3 light_pos) {
-
if (lights.data[light].type == LIGHT_TYPE_DIRECTIONAL) {
-
light_pos = pos - lights.data[light].direction * length(vec3(params.limits));
attenuation = 1.0;
} else {
-
light_pos = lights.data[light].position;
float distance = length(pos - light_pos);
if (distance >= lights.data[light].radius) {
@@ -230,7 +223,6 @@ bool compute_light_vector(uint light, vec3 pos, out float attenuation, out vec3
attenuation = pow(clamp(1.0 - distance / lights.data[light].radius, 0.0001, 1.0), lights.data[light].attenuation);
if (lights.data[light].type == LIGHT_TYPE_SPOT) {
-
vec3 rel = normalize(pos - light_pos);
float angle = acos(dot(rel, lights.data[light].direction));
if (angle > lights.data[light].spot_angle_radians) {
@@ -246,7 +238,6 @@ bool compute_light_vector(uint light, vec3 pos, out float attenuation, out vec3
}
float get_normal_advance(vec3 p_normal) {
-
vec3 normal = p_normal;
vec3 unorm = abs(normal);
@@ -269,7 +260,6 @@ float get_normal_advance(vec3 p_normal) {
}
void clip_segment(vec4 plane, vec3 begin, inout vec3 end) {
-
vec3 segment = begin - end;
float den = dot(plane.xyz, segment);
@@ -302,7 +292,6 @@ bool compute_light_at_pos(uint index, vec3 pos, vec3 normal, inout vec3 light, i
}
if (lights.data[index].has_shadow) {
-
float distance_adv = get_normal_advance(light_dir);
vec3 to = pos;
@@ -352,7 +341,6 @@ bool compute_light_at_pos(uint index, vec3 pos, vec3 normal, inout vec3 light, i
#endif // MODE COMPUTE LIGHT
void main() {
-
#ifndef MODE_DYNAMIC
uint cell_index = gl_GlobalInvocationID.x;
@@ -383,7 +371,6 @@ void main() {
#endif
for (uint i = 0; i < params.light_count; i++) {
-
vec3 light;
vec3 light_dir;
if (!compute_light_at_pos(i, pos, normal.xyz, light, light_dir)) {
@@ -394,7 +381,6 @@ void main() {
#ifdef MODE_ANISOTROPIC
for (uint j = 0; j < 6; j++) {
-
accum[j] += max(0.0, dot(accum_dirs[j], -light_dir)) * light;
}
#else
@@ -461,7 +447,6 @@ void main() {
#endif
if (length(normal.xyz) > 0.2) {
-
vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
vec3 tangent = normalize(cross(v0, normal.xyz));
vec3 bitangent = normalize(cross(tangent, normal.xyz));
@@ -481,11 +466,9 @@ void main() {
float tan_half_angle = 0.577;
for (int i = 0; i < MAX_CONE_DIRS; i++) {
-
vec3 direction = normal_mat * cone_dirs[i];
vec4 color = vec4(0.0);
{
-
float dist = 1.5;
float max_distance = length(vec3(params.limits));
vec3 cell_size = 1.0 / vec3(params.limits);
@@ -519,7 +502,6 @@ void main() {
color *= cone_weights[i] * vec4(albedo.rgb, 1.0) * params.dynamic_range; //restore range
#ifdef MODE_ANISOTROPIC
for (uint j = 0; j < 6; j++) {
-
accum[j] += max(0.0, dot(accum_dirs[j], direction)) * color.rgb;
}
#else
@@ -594,7 +576,6 @@ void main() {
#ifdef MODE_WRITE_TEXTURE
{
-
#ifdef MODE_ANISOTROPIC
vec3 accum_total = vec3(0.0);
accum_total += outputs.data[cell_index * 6 + 0].rgb;
@@ -665,7 +646,6 @@ void main() {
vec3 accum = vec3(0.0);
for (uint i = 0; i < params.light_count; i++) {
-
vec3 light;
vec3 light_dir;
if (!compute_light_at_pos(i, vec3(pos) * params.pos_multiplier, normal, light, light_dir)) {
diff --git a/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl
index c0fcb9a8c4..515cc35507 100644
--- a/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
@@ -11,7 +10,6 @@ struct CellData {
uint emission; //rgb normalized with e as multiplier
uint normal; //RGB normal encoded
};
-/* clang-format on */
layout(set = 0, binding = 1, std140) buffer CellDataBuffer {
CellData data[];
@@ -28,7 +26,6 @@ layout(set = 0, binding = 5) uniform texture3D aniso_neg_tex;
#endif
layout(push_constant, binding = 0, std430) uniform Params {
-
mat4 projection;
uint cell_offset;
float dynamic_range;
@@ -42,7 +39,6 @@ params;
layout(location = 0) out vec4 color_interp;
void main() {
-
const vec3 cube_triangles[36] = vec3[](
vec3(-1.0f, -1.0f, -1.0f),
vec3(-1.0f, -1.0f, 1.0f),
@@ -172,19 +168,16 @@ void main() {
#endif
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
VERSION_DEFINES
layout(location = 0) in vec4 color_interp;
-/* clang-format on */
layout(location = 0) out vec4 frag_color;
void main() {
-
frag_color = color_interp;
#ifdef MODE_DEBUG_LIGHT_FULL
diff --git a/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl
index d089236723..5b3dec0ee7 100644
--- a/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 4, local_size_y = 4, local_size_z = 4) in;
-/* clang-format on */
#define MAX_DISTANCE 100000
@@ -45,7 +43,6 @@ layout(push_constant, binding = 0, std430) uniform Params {
params;
void main() {
-
vec3 pos = vec3(gl_GlobalInvocationID);
float closest_dist = 100000.0;
@@ -71,19 +68,17 @@ void main() {
#if 0
layout(push_constant, binding = 0, std430) uniform Params {
-
ivec3 limits;
uint stack_size;
-} params;
+}
+params;
float distance_to_aabb(ivec3 pos, ivec3 aabb_pos, ivec3 aabb_size) {
-
vec3 delta = vec3(max(ivec3(0), max(aabb_pos - pos, pos - (aabb_pos + aabb_size - ivec3(1)))));
return length(delta);
}
void main() {
-
ivec3 pos = ivec3(gl_GlobalInvocationID);
uint stack[10] = uint[](0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -107,7 +102,6 @@ void main() {
int stack_pos = 0;
while (true) {
-
uint index = stack_indices[stack_pos] >> 24;
if (index == 8) {
diff --git a/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl
index c832223b1e..9c794f1bcc 100644
--- a/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
-/* clang-format on */
#define NO_CHILDREN 0xFFFFFFFF
#define GREY_VEC vec3(0.33333, 0.33333, 0.33333)
@@ -84,24 +82,20 @@ output;
#ifdef MODE_COMPUTE_LIGHT
uint raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
-
uint result = NO_CHILDREN;
ivec3 size = ivec3(max(max(params.limits.x, params.limits.y), params.limits.z));
while (distance > -distance_adv) { //use this to avoid precision errors
-
uint cell = 0;
ivec3 pos = ivec3(from);
if (all(greaterThanEqual(pos, ivec3(0))) && all(lessThan(pos, size))) {
-
ivec3 ofs = ivec3(0);
ivec3 half_size = size / 2;
for (int i = 0; i < params.stack_size - 1; i++) {
-
bvec3 greater = greaterThanEqual(pos, ofs + half_size);
ofs += mix(ivec3(0), half_size, greater);
@@ -118,8 +112,9 @@ uint raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
}
cell = cell_children.data[cell].children[child];
- if (cell == NO_CHILDREN)
+ if (cell == NO_CHILDREN) {
break;
+ }
half_size >>= ivec3(1);
}
@@ -137,14 +132,10 @@ uint raymarch(float distance, float distance_adv, vec3 from, vec3 direction) {
}
bool compute_light_vector(uint light, uint cell, vec3 pos, out float attenuation, out vec3 light_pos) {
-
if (lights.data[light].type == LIGHT_TYPE_DIRECTIONAL) {
-
light_pos = pos - lights.data[light].direction * length(vec3(params.limits));
attenuation = 1.0;
-
} else {
-
light_pos = lights.data[light].position;
float distance = length(pos - light_pos);
if (distance >= lights.data[light].radius) {
@@ -154,7 +145,6 @@ bool compute_light_vector(uint light, uint cell, vec3 pos, out float attenuation
attenuation = pow(clamp(1.0 - distance / lights.data[light].radius, 0.0001, 1.0), lights.data[light].attenuation);
if (lights.data[light].type == LIGHT_TYPE_SPOT) {
-
vec3 rel = normalize(pos - light_pos);
float angle = acos(dot(rel, lights.data[light].direction));
if (angle > lights.data[light].spot_angle_radians) {
@@ -170,7 +160,6 @@ bool compute_light_vector(uint light, uint cell, vec3 pos, out float attenuation
}
float get_normal_advance(vec3 p_normal) {
-
vec3 normal = p_normal;
vec3 unorm = abs(normal);
@@ -195,7 +184,6 @@ float get_normal_advance(vec3 p_normal) {
#endif
void main() {
-
uint cell_index = gl_GlobalInvocationID.x;
if (cell_index >= params.cell_count) {
return;
@@ -220,7 +208,6 @@ void main() {
#endif
for (uint i = 0; i < params.light_count; i++) {
-
float attenuation;
vec3 light_pos;
@@ -237,7 +224,6 @@ void main() {
}
if (lights.data[i].has_shadow) {
-
float distance_adv = get_normal_advance(light_dir);
distance += distance_adv - mod(distance, distance_adv); //make it reach the center of the box always
diff --git a/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl b/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl
index 4bf5b7e7f1..8a11c35b78 100644
--- a/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
@@ -8,7 +7,6 @@ VERSION_DEFINES
#define BLOCK_SIZE 8
layout(local_size_x = BLOCK_SIZE, local_size_y = BLOCK_SIZE, local_size_z = 1) in;
-/* clang-format on */
shared float tmp_data[BLOCK_SIZE * BLOCK_SIZE];
@@ -40,12 +38,10 @@ layout(push_constant, binding = 1, std430) uniform Params {
params;
void main() {
-
uint t = gl_LocalInvocationID.y * BLOCK_SIZE + gl_LocalInvocationID.x;
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
if (any(lessThan(pos, params.source_size))) {
-
#ifdef READ_TEXTURE
vec3 v = texelFetch(source_texture, pos, 0).rgb;
tmp_data[t] = max(v.r, max(v.g, v.b));
@@ -69,7 +65,6 @@ void main() {
barrier();
size >>= 1;
-
} while (size >= 1);
if (t == 0) {
diff --git a/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl b/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl
index 3637b1abb2..464895928a 100644
--- a/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
layout(set = 0, binding = 0) uniform sampler2D source_normal;
layout(r8, set = 1, binding = 0) uniform restrict writeonly image2D dest_roughness;
@@ -21,7 +19,6 @@ params;
#define HALF_PI 1.5707963267948966
void main() {
-
// Pixel being shaded
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThan(pos, params.screen_size))) { //too large, do nothing
@@ -53,14 +50,14 @@ void main() {
float kappa = (3.0f * r - r * r2) / (1.0f - r2);
float variance = 0.25f / kappa;
limit = sqrt(min(2.0f * variance, threshold * threshold));
-//*/
+ */
/*
//Formula based on probability distribution graph
float width = acos(max(0.0,r)); // convert to angle (width)
float roughness = pow(width,1.7)*0.854492; //approximate (crappy) formula to convert to roughness
limit = min(sqrt(roughness), threshold); //convert to perceptual roughness and apply threshold
-//*/
+ */
limit = min(sqrt(pow(acos(max(0.0, r)) / HALF_PI, params.curve)), threshold); //convert to perceptual roughness and apply threshold
diff --git a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
index 90e37b3ec4..9f42b0f814 100644
--- a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
@@ -1,5 +1,4 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
@@ -10,7 +9,6 @@ VERSION_DEFINES
/* INPUT ATTRIBS */
layout(location = 0) in vec3 vertex_attrib;
-/* clang-format on */
layout(location = 1) in vec3 normal_attrib;
#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
layout(location = 2) in vec4 tangent_attrib;
@@ -62,8 +60,6 @@ VERTEX_SHADER_GLOBALS
/* clang-format on */
-// FIXME: This triggers a Mesa bug that breaks rendering, so disabled for now.
-// See GH-13450 and https://bugs.freedesktop.org/show_bug.cgi?id=100316
invariant gl_Position;
layout(location = 7) flat out uint instance_index;
@@ -75,7 +71,6 @@ layout(location = 8) out float dp_clip;
#endif
void main() {
-
instance_index = draw_call.instance_index;
vec4 instance_custom = vec4(0.0);
#if defined(COLOR_USED)
@@ -273,8 +268,7 @@ VERTEX_SHADER_CODE
#endif
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
@@ -285,7 +279,6 @@ VERSION_DEFINES
/* Varyings */
layout(location = 0) in vec3 vertex_interp;
-/* clang-format on */
layout(location = 1) in vec3 normal_interp;
#if defined(COLOR_USED)
@@ -693,7 +686,6 @@ float quick_hash(vec2 pos) {
}
float sample_directional_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) {
-
vec2 pos = coord.xy;
float depth = coord.z;
@@ -720,7 +712,6 @@ float sample_directional_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, ve
}
float sample_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) {
-
vec2 pos = coord.xy;
float depth = coord.z;
@@ -747,7 +738,6 @@ float sample_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) {
}
float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex_scale) {
-
//find blocker
float blocker_count = 0.0;
float blocker_average = 0.0;
@@ -761,7 +751,6 @@ float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex
}
for (uint i = 0; i < scene_data.directional_penumbra_shadow_samples; i++) {
-
vec2 suv = pssm_coord.xy + (disk_rotation * scene_data.directional_penumbra_shadow_kernel[i].xy) * tex_scale;
float d = textureLod(sampler2D(shadow, material_samplers[SAMPLER_LINEAR_CLAMP]), suv, 0.0).r;
if (d < pssm_coord.z) {
@@ -771,7 +760,6 @@ float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex
}
if (blocker_count > 0.0) {
-
//blockers found, do soft shadow
blocker_average /= blocker_count;
float penumbra = (pssm_coord.z - blocker_average) / blocker_average;
@@ -829,7 +817,6 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
float size_A = 0.0;
if (lights.data[idx].size > 0.0) {
-
float t = lights.data[idx].size / max(0.001, light_length);
size_A = max(0.0, 1.0 - 1 / sqrt(1 + t * t));
}
@@ -883,7 +870,6 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
bitangent *= lights.data[idx].soft_shadow_size * lights.data[idx].soft_shadow_scale;
for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) {
-
vec2 disk = disk_rotation * scene_data.penumbra_shadow_kernel[i].xy;
vec3 pos = splane.xyz + tangent * disk.x + bitangent * disk.y;
@@ -892,11 +878,9 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
vec4 uv_rect = lights.data[idx].atlas_rect;
if (pos.z >= 0.0) {
-
pos.z += 1.0;
uv_rect.y += uv_rect.w;
} else {
-
pos.z = 1.0 - pos.z;
}
@@ -913,7 +897,6 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
}
if (blocker_count > 0.0) {
-
//blockers found, do soft shadow
blocker_average /= blocker_count;
float penumbra = (z_norm - blocker_average) / blocker_average;
@@ -924,7 +907,6 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
shadow = 0.0;
for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) {
-
vec2 disk = disk_rotation * scene_data.penumbra_shadow_kernel[i].xy;
vec3 pos = splane.xyz + tangent * disk.x + bitangent * disk.y;
@@ -932,11 +914,9 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
vec4 uv_rect = lights.data[idx].atlas_rect;
if (pos.z >= 0.0) {
-
pos.z += 1.0;
uv_rect.y += uv_rect.w;
} else {
-
pos.z = 1.0 - pos.z;
}
@@ -954,12 +934,10 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
shadow = 1.0;
}
} else {
-
splane.xyz = normalize(splane.xyz);
vec4 clamp_rect = lights.data[idx].atlas_rect;
if (splane.z >= 0.0) {
-
splane.z += 1.0;
clamp_rect.y += clamp_rect.w;
@@ -979,7 +957,6 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
#ifdef LIGHT_TRANSMITTANCE_USED
{
-
vec4 clamp_rect = lights.data[idx].atlas_rect;
//redo shadowmapping, but shrink the model a bit to avoid arctifacts
@@ -989,11 +966,9 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
splane = normalize(splane.xyz);
if (splane.z >= 0.0) {
-
splane.z += 1.0;
} else {
-
splane.z = 1.0 - splane.z;
}
@@ -1011,19 +986,16 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
vec3 no_shadow = vec3(1.0);
if (lights.data[idx].projector_rect != vec4(0.0)) {
-
vec3 local_v = (lights.data[idx].shadow_matrix * vec4(vertex, 1.0)).xyz;
local_v = normalize(local_v);
vec4 atlas_rect = lights.data[idx].projector_rect;
if (local_v.z >= 0.0) {
-
local_v.z += 1.0;
atlas_rect.y += atlas_rect.w;
} else {
-
local_v.z = 1.0 - local_v.z;
}
@@ -1038,10 +1010,8 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
local_v_ddx = normalize(local_v_ddx);
if (local_v_ddx.z >= 0.0) {
-
local_v_ddx.z += 1.0;
} else {
-
local_v_ddx.z = 1.0 - local_v_ddx.z;
}
@@ -1054,10 +1024,8 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
local_v_ddy = normalize(local_v_ddy);
if (local_v_ddy.z >= 0.0) {
-
local_v_ddy.z += 1.0;
} else {
-
local_v_ddy.z = 1.0 - local_v_ddy.z;
}
@@ -1145,7 +1113,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
float size_A = 0.0;
if (lights.data[idx].size > 0.0) {
-
float t = lights.data[idx].size / max(0.001, light_length);
size_A = max(0.0, 1.0 - 1 / sqrt(1 + t * t));
}
@@ -1202,7 +1169,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
float uv_size = lights.data[idx].soft_shadow_size * z_norm * lights.data[idx].soft_shadow_scale;
vec2 clamp_max = lights.data[idx].atlas_rect.xy + lights.data[idx].atlas_rect.zw;
for (uint i = 0; i < scene_data.penumbra_shadow_samples; i++) {
-
vec2 suv = shadow_uv + (disk_rotation * scene_data.penumbra_shadow_kernel[i].xy) * uv_size;
suv = clamp(suv, lights.data[idx].atlas_rect.xy, clamp_max);
float d = textureLod(sampler2D(shadow_atlas, material_samplers[SAMPLER_LINEAR_CLAMP]), suv, 0.0).r;
@@ -1213,7 +1179,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
}
if (blocker_count > 0.0) {
-
//blockers found, do soft shadow
blocker_average /= blocker_count;
float penumbra = (z_norm - blocker_average) / blocker_average;
@@ -1243,7 +1208,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
vec3 no_shadow = vec3(1.0);
if (lights.data[idx].projector_rect != vec4(0.0)) {
-
splane = (lights.data[idx].shadow_matrix * vec4(vertex, 1.0));
splane /= splane.w;
@@ -1266,7 +1230,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
#ifdef LIGHT_TRANSMITTANCE_USED
{
-
splane = (lights.data[idx].shadow_matrix * vec4(vertex - normalize(normal_interp) * lights.data[idx].transmittance_bias, 1.0));
splane /= splane.w;
splane.xy = splane.xy * lights.data[idx].atlas_rect.zw + lights.data[idx].atlas_rect.xy;
@@ -1310,7 +1273,6 @@ void light_process_spot(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
}
void reflection_process(uint ref_index, vec3 vertex, vec3 normal, float roughness, vec3 ambient_light, vec3 specular_light, inout vec4 ambient_accum, inout vec4 reflection_accum) {
-
vec3 box_extents = reflections.data[ref_index].box_extents;
vec3 local_pos = (reflections.data[ref_index].local_matrix * vec4(vertex, 1.0)).xyz;
@@ -1377,7 +1339,6 @@ void reflection_process(uint ref_index, vec3 vertex, vec3 normal, float roughnes
ambient_out.rgb *= ambient_out.a;
ambient_accum += ambient_out;
} else {
-
vec4 ambient_out;
ambient_out.a = blend;
ambient_out.rgb = reflections.data[ref_index].ambient.rgb;
@@ -1394,7 +1355,6 @@ void reflection_process(uint ref_index, vec3 vertex, vec3 normal, float roughnes
//standard voxel cone trace
vec4 voxel_cone_trace(texture3D probe, vec3 cell_size, vec3 pos, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
-
float dist = p_bias;
vec4 color = vec4(0.0);
@@ -1421,7 +1381,6 @@ vec4 voxel_cone_trace(texture3D probe, vec3 cell_size, vec3 pos, vec3 direction,
#ifdef GI_PROBE_USE_ANISOTROPY
vec4 voxel_cone_trace_anisotropic_45_degrees(texture3D probe, texture3D aniso_pos, texture3D aniso_neg, vec3 normal, vec3 cell_size, vec3 pos, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
-
float dist = p_bias;
vec4 color = vec4(0.0);
float radius = max(0.5, tan_half_angle * dist);
@@ -1453,7 +1412,6 @@ vec4 voxel_cone_trace_anisotropic_45_degrees(texture3D probe, texture3D aniso_po
#else
vec4 voxel_cone_trace_45_degrees(texture3D probe, vec3 cell_size, vec3 pos, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
-
float dist = p_bias;
vec4 color = vec4(0.0);
float radius = max(0.5, tan_half_angle * dist);
@@ -1485,7 +1443,6 @@ vec4 voxel_cone_trace_45_degrees(texture3D probe, vec3 cell_size, vec3 pos, vec3
//standard voxel cone trace
vec4 voxel_cone_trace_anisotropic(texture3D probe, texture3D aniso_pos, texture3D aniso_neg, vec3 normal, vec3 cell_size, vec3 pos, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
-
float dist = p_bias;
vec4 color = vec4(0.0);
@@ -1516,7 +1473,6 @@ vec4 voxel_cone_trace_anisotropic(texture3D probe, texture3D aniso_pos, texture3
#endif
void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3 normal_xform, float roughness, vec3 ambient, vec3 environment, inout vec4 out_spec, inout vec4 out_diff) {
-
position = (gi_probes.data[index].xform * vec4(position, 1.0)).xyz;
ref_vec = normalize((gi_probes.data[index].xform * vec4(ref_vec, 0.0)).xyz);
normal = normalize((gi_probes.data[index].xform * vec4(normal, 0.0)).xyz);
@@ -1577,7 +1533,6 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3
vec3 light = vec3(0.0);
for (int i = 0; i < MAX_CONE_DIRS; i++) {
-
vec3 dir = normalize((gi_probes.data[index].xform * vec4(normal_xform * cone_dirs[i], 0.0)).xyz);
#if defined(GI_PROBE_HIGH_QUALITY) || defined(GI_PROBE_LOW_QUALITY)
@@ -1609,7 +1564,6 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3
light *= gi_probes.data[index].dynamic_range;
if (gi_probes.data[index].ambient_occlusion > 0.001) {
-
float size = 1.0 + gi_probes.data[index].ambient_occlusion_size * 7.0;
float taps, blend;
@@ -1650,7 +1604,6 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3
#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED)
void main() {
-
#ifdef MODE_DUAL_PARABOLOID
if (dp_clip > 0.0)
@@ -1802,7 +1755,6 @@ FRAGMENT_SHADER_CODE
//do outside for performance and avoiding arctifacts
for (uint i = 0; i < decal_count; i++) {
-
uint decal_index = cluster_data.indices[decal_pointer + i];
if (!bool(decals.data[decal_index].mask & instances.data[instance_index].layer_mask)) {
continue; //not masked
@@ -1831,7 +1783,6 @@ FRAGMENT_SHADER_CODE
albedo = mix(albedo, decal_albedo.rgb, decal_albedo.a * decals.data[decal_index].albedo_mix);
if (decals.data[decal_index].normal_rect != vec4(0.0)) {
-
vec3 decal_normal = textureGrad(sampler2D(decal_atlas, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), uv_local.xz * decals.data[decal_index].normal_rect.zw + decals.data[decal_index].normal_rect.xy, ddx * decals.data[decal_index].normal_rect.zw, ddy * decals.data[decal_index].normal_rect.zw).xyz;
decal_normal.xy = decal_normal.xy * vec2(2.0, -2.0) - vec2(1.0, -1.0); //users prefer flipped y normal maps in most authoring software
decal_normal.z = sqrt(max(0.0, 1.0 - dot(decal_normal.xy, decal_normal.xy)));
@@ -1842,7 +1793,6 @@ FRAGMENT_SHADER_CODE
}
if (decals.data[decal_index].orm_rect != vec4(0.0)) {
-
vec3 decal_orm = textureGrad(sampler2D(decal_atlas, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), uv_local.xz * decals.data[decal_index].orm_rect.zw + decals.data[decal_index].orm_rect.xy, ddx * decals.data[decal_index].orm_rect.zw, ddy * decals.data[decal_index].orm_rect.zw).xyz;
#if defined(AO_USED)
ao = mix(ao, decal_orm.r, decal_albedo.a);
@@ -1876,7 +1826,6 @@ FRAGMENT_SHADER_CODE
}
if (scene_data.use_reflection_cubemap) {
-
vec3 ref_vec = reflect(-view, normal);
ref_vec = scene_data.radiance_inverse_xform * ref_vec;
#ifdef USE_RADIANCE_CUBEMAP_ARRAY
@@ -1896,7 +1845,6 @@ FRAGMENT_SHADER_CODE
#ifndef USE_LIGHTMAP
//lightmap overrides everything
if (scene_data.use_ambient_light) {
-
ambient_light = scene_data.ambient_light_color_energy.rgb;
if (scene_data.use_ambient_cubemap) {
@@ -1977,7 +1925,6 @@ FRAGMENT_SHADER_CODE
}
} else {
-
ambient_light += textureLod(sampler2DArray(lightmap_textures[ofs], material_samplers[SAMPLER_LINEAR_CLAMP]), uvw, 0.0).rgb;
}
}
@@ -2027,7 +1974,6 @@ FRAGMENT_SHADER_CODE
uint reflection_probe_pointer = cluster_cell.z & CLUSTER_POINTER_MASK;
for (uint i = 0; i < reflection_probe_count; i++) {
-
uint ref_index = cluster_data.indices[reflection_probe_pointer + i];
reflection_process(ref_index, vertex, normal, roughness, ambient_light, specular_light, ambient_accum, reflection_accum);
}
@@ -2044,7 +1990,6 @@ FRAGMENT_SHADER_CODE
}
{
-
#if defined(DIFFUSE_TOON)
//simplify for toon, as
specular_light *= specular * metallic * albedo * 2.0;
@@ -2069,7 +2014,6 @@ FRAGMENT_SHADER_CODE
{ //directional light
for (uint i = 0; i < scene_data.directional_light_count; i++) {
-
if (!bool(directional_lights.data[i].mask & instances.data[instance_index].layer_mask)) {
continue; //not masked
}
@@ -2129,7 +2073,6 @@ FRAGMENT_SHADER_CODE
}
#endif
} else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) {
-
vec4 v = vec4(vertex, 1.0);
BIAS_FUNC(v, 1)
@@ -2162,7 +2105,6 @@ FRAGMENT_SHADER_CODE
}
#endif
} else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) {
-
vec4 v = vec4(vertex, 1.0);
BIAS_FUNC(v, 2)
@@ -2196,7 +2138,6 @@ FRAGMENT_SHADER_CODE
#endif
} else {
-
vec4 v = vec4(vertex, 1.0);
BIAS_FUNC(v, 3)
@@ -2232,7 +2173,6 @@ FRAGMENT_SHADER_CODE
}
if (directional_lights.data[i].blend_splits) {
-
vec3 shadow_color_blend = vec3(0.0);
float pssm_blend;
float shadow2;
@@ -2342,7 +2282,6 @@ FRAGMENT_SHADER_CODE
uint omni_light_pointer = cluster_cell.x & CLUSTER_POINTER_MASK;
for (uint i = 0; i < omni_light_count; i++) {
-
uint light_index = cluster_data.indices[omni_light_pointer + i];
if (!bool(lights.data[light_index].mask & instances.data[instance_index].layer_mask)) {
@@ -2381,7 +2320,6 @@ FRAGMENT_SHADER_CODE
uint spot_light_pointer = cluster_cell.y & CLUSTER_POINTER_MASK;
for (uint i = 0; i < spot_light_count; i++) {
-
uint light_index = cluster_data.indices[spot_light_pointer + i];
if (!bool(lights.data[light_index].mask & instances.data[instance_index].layer_mask)) {
diff --git a/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl
index 89706b74d6..1cac12406a 100644
--- a/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl
@@ -28,7 +28,6 @@ layout(set = 0, binding = 1) uniform sampler material_samplers[12];
layout(set = 0, binding = 2) uniform sampler shadow_sampler;
layout(set = 0, binding = 3, std140) uniform SceneData {
-
mat4 projection_matrix;
mat4 inv_projection_matrix;
@@ -118,6 +117,7 @@ layout(set = 0, binding = 3, std140) uniform SceneData {
float fog_height_curve;
#endif
}
+
scene_data;
#define INSTANCE_FLAGS_USE_LIGHTMAP_CAPTURE (1 << 8)
@@ -176,7 +176,6 @@ layout(set = 0, binding = 5, std430) restrict readonly buffer Lights {
lights;
struct ReflectionData {
-
vec3 box_extents;
float index;
vec3 box_offset;
diff --git a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl
index 11a0d85c58..084f28d932 100644
--- a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl
@@ -1,16 +1,11 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
-
-
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
-
layout(rgba16f, set = 0, binding = 0) uniform restrict readonly image2D source_diffuse;
layout(r32f, set = 0, binding = 1) uniform restrict readonly image2D source_depth;
layout(rgba16f, set = 1, binding = 0) uniform restrict writeonly image2D ssr_image;
@@ -24,7 +19,6 @@ layout(set = 3, binding = 1) uniform sampler2D source_roughness;
#endif
layout(push_constant, binding = 2, std430) uniform Params {
-
vec4 proj_info;
ivec2 screen_size;
@@ -64,7 +58,6 @@ vec3 reconstructCSPosition(vec2 S, float z) {
}
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_GlobalInvocationID.xy);
@@ -156,7 +149,6 @@ void main() {
float steps_taken = 0.0;
for (int i = 0; i < params.num_steps; i++) {
-
pos += line_advance;
z += z_advance;
w += w_advance;
@@ -187,7 +179,6 @@ void main() {
}
if (found) {
-
float margin_blend = 1.0;
vec2 margin = vec2((params.screen_size.x + params.screen_size.y) * 0.5 * 0.05); // make a uniform margin
@@ -220,7 +211,6 @@ void main() {
float roughness = texelFetch(source_roughness, ssC << 1, 0).r;
if (roughness > 0.001) {
-
float cone_angle = min(roughness, 0.999) * M_PI * 0.5;
float cone_len = length(final_pos - line_begin);
float op_len = 2.0 * tan(cone_angle) * cone_len; // opposite side of iso triangle
diff --git a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl
index 8571d9d6d1..a5afe74cb2 100644
--- a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl
@@ -1,16 +1,11 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
-
-
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
-
layout(rgba16f, set = 0, binding = 0) uniform restrict readonly image2D source_ssr;
layout(r8, set = 0, binding = 1) uniform restrict readonly image2D source_radius;
layout(rgba8, set = 1, binding = 0) uniform restrict readonly image2D source_normal;
@@ -22,7 +17,6 @@ layout(r8, set = 2, binding = 1) uniform restrict writeonly image2D dest_radius;
layout(r32f, set = 3, binding = 0) uniform restrict readonly image2D source_depth;
layout(push_constant, binding = 2, std430) uniform Params {
-
vec4 proj_info;
bool orthogonal;
@@ -58,7 +52,6 @@ const float gauss_table[GAUSS_TABLE_SIZE + 1] = float[](
);
float gauss_weight(float p_val) {
-
float idxf;
float c = modf(max(0.0, p_val * float(GAUSS_TABLE_SIZE)), idxf);
int idx = int(idxf);
@@ -80,7 +73,6 @@ vec3 reconstructCSPosition(vec2 S, float z) {
}
void do_filter(inout vec4 accum, inout float accum_radius, inout float divisor, ivec2 texcoord, ivec2 increment, vec3 p_pos, vec3 normal, float p_limit_radius) {
-
for (int i = 1; i < params.steps; i++) {
float d = float(i * params.increment);
ivec2 tc = texcoord + increment * i;
@@ -104,7 +96,6 @@ void do_filter(inout vec4 accum, inout float accum_radius, inout float divisor,
}
if (d < radius) {
-
float w = gauss_weight(d / radius);
accum += imageLoad(source_ssr, tc) * w;
#ifndef VERTICAL_PASS
@@ -116,7 +107,6 @@ void do_filter(inout vec4 accum, inout float accum_radius, inout float divisor,
}
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_GlobalInvocationID.xy);
diff --git a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl
index f2c3230679..218605a962 100644
--- a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl
@@ -1,15 +1,11 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
-
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
-
layout(set = 0, binding = 0) uniform sampler2D source_ssr;
layout(set = 1, binding = 0) uniform sampler2D source_depth;
layout(set = 1, binding = 1) uniform sampler2D source_normal;
@@ -18,7 +14,6 @@ layout(r32f, set = 3, binding = 0) uniform restrict writeonly image2D dest_depth
layout(rgba8, set = 3, binding = 1) uniform restrict writeonly image2D dest_normal;
layout(push_constant, binding = 1, std430) uniform Params {
-
ivec2 screen_size;
float camera_z_near;
float camera_z_far;
@@ -30,7 +25,6 @@ layout(push_constant, binding = 1, std430) uniform Params {
params;
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_GlobalInvocationID.xy);
@@ -45,13 +39,11 @@ void main() {
vec3 normal;
if (params.filtered) {
-
color = vec4(0.0);
depth = 0.0;
normal = vec3(0.0);
for (int i = 0; i < 4; i++) {
-
ivec2 ofs = ssC << 1;
if (bool(i & 1)) {
ofs.x += 1;
@@ -75,7 +67,6 @@ void main() {
color /= 4.0;
depth /= 4.0;
normal = normalize(normal / 4.0) * 0.5 + 0.5;
-
} else {
color = texelFetch(source_ssr, ssC << 1, 0);
depth = texelFetch(source_depth, ssC << 1, 0).r;
diff --git a/servers/rendering/rasterizer_rd/shaders/sky.glsl b/servers/rendering/rasterizer_rd/shaders/sky.glsl
index 536077980d..9c59be6841 100644
--- a/servers/rendering/rasterizer_rd/shaders/sky.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/sky.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
VERSION_DEFINES
layout(location = 0) out vec2 uv_interp;
-/* clang-format on */
layout(push_constant, binding = 1, std430) uniform Params {
mat3 orientation;
@@ -17,14 +15,12 @@ layout(push_constant, binding = 1, std430) uniform Params {
params;
void main() {
-
vec2 base_arr[4] = vec2[](vec2(-1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0), vec2(1.0, -1.0));
uv_interp = base_arr[gl_VertexIndex];
gl_Position = vec4(uv_interp, 1.0, 1.0);
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
@@ -33,7 +29,6 @@ VERSION_DEFINES
#define M_PI 3.14159265359
layout(location = 0) in vec2 uv_interp;
-/* clang-format on */
layout(push_constant, binding = 1, std430) uniform Params {
mat3 orientation;
@@ -109,6 +104,7 @@ struct DirectionalLightData {
layout(set = 3, binding = 0, std140) uniform DirectionalLights {
DirectionalLightData data[MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS];
}
+
directional_lights;
/* clang-format off */
@@ -120,7 +116,6 @@ FRAGMENT_SHADER_GLOBALS
layout(location = 0) out vec4 frag_color;
void main() {
-
vec3 cube_normal;
cube_normal.z = -1.0;
cube_normal.x = (cube_normal.z * (-uv_interp.x - params.proj.x)) / params.proj.y;
diff --git a/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
index b24f7dccc7..0b8f406213 100644
--- a/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl
@@ -1,30 +1,25 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
VERSION_DEFINES
layout(location = 0) out vec2 uv_interp;
-/* clang-format on */
void main() {
-
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
uv_interp = base_arr[gl_VertexIndex];
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
VERSION_DEFINES
layout(location = 0) in vec2 uv_interp;
-/* clang-format on */
layout(set = 0, binding = 0) uniform sampler2D specular;
@@ -43,7 +38,6 @@ layout(set = 2, binding = 0) uniform sampler2D diffuse;
layout(location = 0) out vec4 frag_color;
void main() {
-
frag_color.rgb = texture(specular, uv_interp).rgb;
frag_color.a = 0.0;
#ifdef MODE_SSR
diff --git a/servers/rendering/rasterizer_rd/shaders/ssao.glsl b/servers/rendering/rasterizer_rd/shaders/ssao.glsl
index 0175e26b85..346338181a 100644
--- a/servers/rendering/rasterizer_rd/shaders/ssao.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/ssao.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
#define TWO_PI 6.283185307179586476925286766559
@@ -49,7 +47,6 @@ const int ROTATIONS[] = int[](
29, 21, 19, 27, 31, 29, 21, 18, 17, 29,
31, 31, 23, 18, 25, 26, 25, 23, 19, 34,
19, 27, 21, 25, 39, 29, 17, 21, 27);
-/* clang-format on */
//#define NUM_SPIRAL_TURNS (7)
const int NUM_SPIRAL_TURNS = ROTATIONS[NUM_SAMPLES - 1];
diff --git a/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl b/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl
index 877e5d50fe..3e63e3cb59 100644
--- a/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
layout(set = 0, binding = 0) uniform sampler2D source_ssao;
layout(set = 1, binding = 0) uniform sampler2D source_depth;
@@ -46,7 +44,6 @@ const float gaussian[R + 1] =
//float[](0.111220, 0.107798, 0.098151, 0.083953, 0.067458, 0.050920, 0.036108); // stddev = 3.0
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThanEqual(ssC, params.screen_size))) { //too large, do nothing
@@ -122,7 +119,6 @@ void main() {
// We already handled the zero case above. This loop should be unrolled and the static branch optimized out,
// so the IF statement has no runtime cost
if (r != 0) {
-
ivec2 ppos = ssC + params.axis * (r * params.filter_scale);
float value = texelFetch(source_ssao, clamp(ppos, ivec2(0), clamp_limit), 0).r;
ivec2 rpos = clamp(ppos, ivec2(0), clamp_limit);
diff --git a/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl b/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl
index 8728154347..263fca386f 100644
--- a/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl
@@ -1,12 +1,10 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
layout(push_constant, binding = 1, std430) uniform Params {
vec2 pixel_size;
@@ -26,7 +24,6 @@ layout(r32f, set = 0, binding = 0) uniform restrict readonly image2D source_imag
layout(r32f, set = 1, binding = 0) uniform restrict writeonly image2D dest_image;
void main() {
-
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThan(pos, params.source_size >> 1))) { //too large, do nothing
diff --git a/servers/rendering/rasterizer_rd/shaders/subsurface_scattering.glsl b/servers/rendering/rasterizer_rd/shaders/subsurface_scattering.glsl
index 4cb486a499..88a953562f 100644
--- a/servers/rendering/rasterizer_rd/shaders/subsurface_scattering.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/subsurface_scattering.glsl
@@ -1,16 +1,11 @@
-/* clang-format off */
-[compute]
+#[compute]
#version 450
VERSION_DEFINES
-
-
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-/* clang-format on */
-
#ifdef USE_25_SAMPLES
const int kernel_size = 13;
@@ -93,7 +88,6 @@ const vec4 skin_kernel[kernel_size] = vec4[](
#endif //USE_11_SAMPLES
layout(push_constant, binding = 1, std430) uniform Params {
-
ivec2 screen_size;
float camera_z_far;
float camera_z_near;
@@ -113,7 +107,6 @@ layout(rgba16f, set = 1, binding = 0) uniform restrict writeonly image2D dest_im
layout(set = 2, binding = 0) uniform sampler2D source_depth;
void do_filter(inout vec3 color_accum, inout vec3 divisor, vec2 uv, vec2 step, bool p_skin) {
-
// Accumulate the other samples:
for (int i = 1; i < kernel_size; i++) {
// Fetch color and depth for current sample:
@@ -138,7 +131,6 @@ void do_filter(inout vec3 color_accum, inout vec3 divisor, vec2 uv, vec2 step, b
}
void main() {
-
// Pixel being shaded
ivec2 ssC = ivec2(gl_GlobalInvocationID.xy);
@@ -153,7 +145,6 @@ void main() {
float strength = abs(base_color.a);
if (strength > 0.0) {
-
vec2 dir = params.vertical ? vec2(0.0, 1.0) : vec2(1.0, 0.0);
// Fetch linear depth of current pixel:
diff --git a/servers/rendering/rasterizer_rd/shaders/tonemap.glsl b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
index a142d263e2..b7c46a7d0e 100644
--- a/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
@@ -1,29 +1,24 @@
-/* clang-format off */
-[vertex]
+#[vertex]
#version 450
VERSION_DEFINES
layout(location = 0) out vec2 uv_interp;
-/* clang-format on */
void main() {
-
vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0));
uv_interp = base_arr[gl_VertexIndex];
gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0);
}
-/* clang-format off */
-[fragment]
+#[fragment]
#version 450
VERSION_DEFINES
layout(location = 0) in vec2 uv_interp;
-/* clang-format on */
layout(set = 0, binding = 0) uniform sampler2D source_color;
layout(set = 1, binding = 0) uniform sampler2D source_auto_exposure;
@@ -260,7 +255,6 @@ vec3 apply_color_correction(vec3 color, sampler3D correction_tex) {
}
vec3 do_fxaa(vec3 color, float exposure, vec2 uv_interp) {
-
const float FXAA_REDUCE_MIN = (1.0 / 128.0);
const float FXAA_REDUCE_MUL = (1.0 / 8.0);
const float FXAA_SPAN_MAX = 8.0;
@@ -298,10 +292,11 @@ vec3 do_fxaa(vec3 color, float exposure, vec2 uv_interp) {
textureLod(source_color, uv_interp + dir * 0.5, 0.0).xyz * exposure);
float lumaB = dot(rgbB, luma);
- if ((lumaB < lumaMin) || (lumaB > lumaMax))
+ if ((lumaB < lumaMin) || (lumaB > lumaMax)) {
return rgbA;
- else
+ } else {
return rgbB;
+ }
}
void main() {
@@ -320,7 +315,6 @@ void main() {
// Early Tonemap & SRGB Conversion
if (params.use_glow && params.glow_mode == GLOW_MODE_MIX) {
-
vec3 glow = gather_glow(source_glow, uv_interp);
color.rgb = mix(color.rgb, glow, params.glow_intensity);
}
@@ -335,7 +329,6 @@ void main() {
// Glow
if (params.use_glow && params.glow_mode != GLOW_MODE_MIX) {
-
vec3 glow = gather_glow(source_glow, uv_interp) * params.glow_intensity;
// high dynamic range -> SRGB
diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp
index aeac6f2eff..55b65d2747 100644
--- a/servers/rendering/rendering_device.cpp
+++ b/servers/rendering/rendering_device.cpp
@@ -44,6 +44,7 @@ RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = nullptr;
void RenderingDevice::shader_set_compile_function(ShaderCompileFunction p_function) {
compile_function = p_function;
}
+
void RenderingDevice::shader_set_cache_function(ShaderCacheFunction p_function) {
cache_function = p_function;
}
@@ -62,7 +63,6 @@ Vector<uint8_t> RenderingDevice::shader_compile_from_source(ShaderStage p_stage,
}
RID RenderingDevice::_texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data) {
-
ERR_FAIL_COND_V(p_format.is_null(), RID());
ERR_FAIL_COND_V(p_view.is_null(), RID());
Vector<Vector<uint8_t>> data;
@@ -87,7 +87,6 @@ RID RenderingDevice::_texture_create_shared_from_slice(const Ref<RDTextureView>
}
RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments) {
-
Vector<AttachmentFormat> attachments;
attachments.resize(p_attachments.size());
@@ -100,7 +99,6 @@ RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create
}
RID RenderingDevice::_framebuffer_create(const Array &p_textures, FramebufferFormatID p_format_check) {
-
Vector<RID> textures = Variant(p_textures);
return framebuffer_create(textures, p_format_check);
}
@@ -112,7 +110,6 @@ RID RenderingDevice::_sampler_create(const Ref<RDSamplerState> &p_state) {
}
RenderingDevice::VertexFormatID RenderingDevice::_vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats) {
-
Vector<VertexAttribute> descriptions;
descriptions.resize(p_vertex_formats.size());
@@ -125,7 +122,6 @@ RenderingDevice::VertexFormatID RenderingDevice::_vertex_format_create(const Typ
}
RID RenderingDevice::_vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers) {
-
Vector<RID> buffers = Variant(p_src_buffers);
return vertex_array_create(p_vertex_count, p_vertex_format, buffers);
@@ -168,7 +164,6 @@ RID RenderingDevice::shader_create_from_bytecode(const Ref<RDShaderBytecode> &p_
}
RID RenderingDevice::_uniform_set_create(const Array &p_uniforms, RID p_shader, uint32_t p_shader_set) {
-
Vector<Uniform> uniforms;
uniforms.resize(p_uniforms.size());
for (int i = 0; i < p_uniforms.size(); i++) {
@@ -180,12 +175,10 @@ RID RenderingDevice::_uniform_set_create(const Array &p_uniforms, RID p_shader,
}
Error RenderingDevice::_buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, bool p_sync_with_draw) {
-
return buffer_update(p_buffer, p_offset, p_size, p_data.ptr(), p_sync_with_draw);
}
RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags) {
-
PipelineRasterizationState rasterization_state;
if (p_rasterization_state.is_valid()) {
rasterization_state = p_rasterization_state->base;
@@ -220,7 +213,6 @@ RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p
}
Vector<int64_t> RenderingDevice::_draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region) {
-
Vector<DrawListID> splits;
splits.resize(p_splits);
draw_list_begin_split(p_framebuffer, p_splits, splits.ptrw(), p_initial_color_action, p_final_color_action, p_initial_depth_action, p_final_depth_action, p_clear_color_values, p_clear_depth, p_clear_stencil, p_region);
@@ -245,7 +237,6 @@ void RenderingDevice::_compute_list_set_push_constant(ComputeListID p_list, cons
}
void RenderingDevice::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("texture_create", "format", "view", "data"), &RenderingDevice::_texture_create, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("texture_create_shared", "view", "with_texture"), &RenderingDevice::_texture_create_shared);
ClassDB::bind_method(D_METHOD("texture_create_shared_from_slice", "view", "with_texture", "layer", "mipmap", "slice_type"), &RenderingDevice::_texture_create_shared_from_slice, DEFVAL(TEXTURE_SLICE_2D));
diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h
index c7d0a1cdd2..ee39ee11ed 100644
--- a/servers/rendering/rendering_device.h
+++ b/servers/rendering/rendering_device.h
@@ -786,7 +786,6 @@ public:
};
struct PipelineDepthStencilState {
-
bool enable_depth_test;
bool enable_depth_write;
CompareOperator depth_compare_operator;
@@ -830,7 +829,6 @@ public:
};
struct PipelineColorBlendState {
-
bool enable_logic_op;
LogicOperation logic_op;
struct Attachment {
@@ -871,7 +869,6 @@ public:
static PipelineColorBlendState create_blend(int p_attachments = 1) {
PipelineColorBlendState bs;
for (int i = 0; i < p_attachments; i++) {
-
Attachment ba;
ba.enable_blend = true;
ba.src_color_blend_factor = BLEND_FACTOR_SRC_ALPHA;
diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp
index 91076a538e..0400cebfdc 100644
--- a/servers/rendering/rendering_device_binds.cpp
+++ b/servers/rendering/rendering_device_binds.cpp
@@ -31,7 +31,6 @@
#include "rendering_device_binds.h"
Error RDShaderFile::parse_versions_from_text(const String &p_text, const String p_defines, OpenIncludeFunction p_include_func, void *p_include_func_userdata) {
-
Vector<String> lines = p_text.split("\n");
bool reading_versions = false;
@@ -42,7 +41,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
"fragment",
"tesselation_control",
"tesselation_evaluation",
- "compute"
+ "compute",
};
String stage_code[RD::SHADER_STAGE_MAX];
int stages_found = 0;
@@ -56,14 +55,11 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
{
String ls = line.strip_edges();
- if (ls.begins_with("#[")) { //workaround for clang format
- ls = ls.replace_first("#[", "[");
- }
- if (ls.begins_with("[") && ls.ends_with("]")) {
- String section = ls.substr(1, ls.length() - 2).strip_edges();
+ if (ls.begins_with("#[") && ls.ends_with("]")) {
+ String section = ls.substr(2, ls.length() - 3).strip_edges();
if (section == "versions") {
if (stages_found) {
- base_error = "Invalid shader file, [version] must be the first section found.";
+ base_error = "Invalid shader file, #[versions] must be the first section found.";
break;
}
reading_versions = true;
@@ -103,23 +99,27 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
if (reading_versions) {
String l = line.strip_edges();
if (l != "") {
-
- int eqpos = l.find("=");
- if (eqpos == -1) {
- base_error = "Version syntax is version=\"<defines with C escaping>\".";
+ if (l.find("=") == -1) {
+ base_error = "Missing `=` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`.";
+ break;
+ }
+ if (l.find(";") == -1) {
+ // We don't require a semicolon per se, but it's needed for clang-format to handle things properly.
+ base_error = "Missing `;` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`.";
break;
}
- String version = l.get_slice("=", 0).strip_edges();
+ Vector<String> slices = l.get_slice(";", 0).split("=");
+ String version = slices[0].strip_edges();
if (!version.is_valid_identifier()) {
base_error = "Version names must be valid identifiers, found '" + version + "' instead.";
break;
}
- String define = l.get_slice("=", 1).strip_edges();
+ String define = slices[1].strip_edges();
if (!define.begins_with("\"") || !define.ends_with("\"")) {
base_error = "Version text must be quoted using \"\", instead found '" + define + "'.";
break;
}
- define = "\n" + define.substr(1, define.length() - 2).c_unescape() + "\n"; //add newline before and after jsut in case
+ define = "\n" + define.substr(1, define.length() - 2).c_unescape() + "\n"; // Add newline before and after just in case.
version_texts[version] = define + "\n" + p_defines;
}
@@ -149,7 +149,6 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
base_error = "#include used, but no include function provided.";
}
} else {
-
stage_code[stage] += line + "\n";
}
}
@@ -160,7 +159,6 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
shader_file.instance();
if (base_error == "") {
-
if (stage_found[RD::SHADER_STAGE_COMPUTE] && stages_found > 1) {
ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "When writing compute shaders, [compute] mustbe the only stage present.");
}
@@ -174,7 +172,6 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
/* STEP 2, Compile the versions, add to shader file */
for (Map<StringName, String>::Element *E = version_texts.front(); E; E = E->next()) {
-
Ref<RDShaderBytecode> bytecode;
bytecode.instance();
diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h
index fe8d554594..319c6d9fde 100644
--- a/servers/rendering/rendering_device_binds.h
+++ b/servers/rendering/rendering_device_binds.h
@@ -153,7 +153,6 @@ public:
protected:
static void _bind_methods() {
-
RD_BIND(Variant::INT, RDSamplerState, mag_filter);
RD_BIND(Variant::INT, RDSamplerState, min_filter);
RD_BIND(Variant::INT, RDSamplerState, mip_filter);
@@ -569,7 +568,6 @@ public:
RD_SETGET(bool, write_a)
void set_as_mix() {
-
base = RD::PipelineColorBlendState::Attachment();
base.enable_blend = true;
base.src_color_blend_factor = RD::BLEND_FACTOR_SRC_ALPHA;
@@ -580,7 +578,6 @@ public:
protected:
static void _bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_as_mix"), &RDPipelineColorBlendStateAttachment::set_as_mix);
RD_BIND(Variant::BOOL, RDPipelineColorBlendStateAttachment, enable_blend);
diff --git a/servers/rendering/rendering_server_canvas.cpp b/servers/rendering/rendering_server_canvas.cpp
index 5d6dcfd2c1..5c0741bb3b 100644
--- a/servers/rendering/rendering_server_canvas.cpp
+++ b/servers/rendering/rendering_server_canvas.cpp
@@ -29,6 +29,8 @@
/*************************************************************************/
#include "rendering_server_canvas.h"
+
+#include "core/math/geometry_2d.h"
#include "rendering_server_globals.h"
#include "rendering_server_raster.h"
#include "rendering_server_viewport.h"
@@ -36,7 +38,6 @@
static const int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1;
void RenderingServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
-
RENDER_TIMESTAMP("Cull CanvasItem Tree");
memset(z_list, 0, z_range * sizeof(RasterizerCanvas::Item *));
@@ -53,8 +54,9 @@ void RenderingServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Can
RasterizerCanvas::Item *list_end = nullptr;
for (int i = 0; i < z_range; i++) {
- if (!z_list[i])
+ if (!z_list[i]) {
continue;
+ }
if (!list) {
list = z_list[i];
list_end = z_last_list[i];
@@ -83,8 +85,9 @@ void _collect_ysort_children(RenderingServerCanvas::Item *p_canvas_item, Transfo
r_index++;
- if (child_items[i]->sort_y)
+ if (child_items[i]->sort_y) {
_collect_ysort_children(child_items[i], p_transform * child_items[i]->xform, child_items[i]->use_parent_material ? p_material_owner : child_items[i], r_items, r_index);
+ }
}
}
}
@@ -97,14 +100,13 @@ void _mark_ysort_dirty(RenderingServerCanvas::Item *ysort_owner, RID_PtrOwner<Re
}
void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {
-
Item *ci = p_canvas_item;
- if (!ci->visible)
+ if (!ci->visible) {
return;
+ }
if (ci->children_order_dirty) {
-
ci->child_items.sort_custom<ItemIndexSort>();
ci->children_order_dirty = false;
}
@@ -114,17 +116,18 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
Rect2 global_rect = xform.xform(rect);
global_rect.position += p_clip_rect.position;
- if (ci->use_parent_material && p_material_owner)
+ if (ci->use_parent_material && p_material_owner) {
ci->material_owner = p_material_owner;
- else {
+ } else {
p_material_owner = ci;
ci->material_owner = nullptr;
}
Color modulate(ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g, ci->modulate.b * p_modulate.b, ci->modulate.a * p_modulate.a);
- if (modulate.a < 0.007)
+ if (modulate.a < 0.007) {
return;
+ }
int child_item_count = ci->child_items.size();
Item **child_items = ci->child_items.ptrw();
@@ -142,7 +145,6 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
}
if (ci->sort_y) {
-
if (ci->ysort_children_count == -1) {
ci->ysort_children_count = 0;
_collect_ysort_children(ci, Transform2D(), p_material_owner, nullptr, ci->ysort_children_count);
@@ -158,15 +160,16 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
sorter.sort(child_items, child_item_count);
}
- if (ci->z_relative)
+ if (ci->z_relative) {
p_z = CLAMP(p_z + ci->z_index, RS::CANVAS_ITEM_Z_MIN, RS::CANVAS_ITEM_Z_MAX);
- else
+ } else {
p_z = ci->z_index;
+ }
for (int i = 0; i < child_item_count; i++) {
-
- if (!child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y))
+ if (!child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y)) {
continue;
+ }
if (ci->sort_y) {
_cull_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner);
} else {
@@ -175,7 +178,6 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
}
if (ci->copy_back_buffer) {
-
ci->copy_back_buffer->screen_rect = xform.xform(ci->copy_back_buffer->rect).clip(p_clip_rect);
}
@@ -208,9 +210,9 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
}
for (int i = 0; i < child_item_count; i++) {
-
- if (child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y))
+ if (child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y)) {
continue;
+ }
if (ci->sort_y) {
_cull_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner);
} else {
@@ -220,17 +222,15 @@ void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transfo
}
void RenderingServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) {
-
- if (!p_masked_lights)
+ if (!p_masked_lights) {
return;
+ }
RasterizerCanvas::Item *ci = p_canvas_item;
while (ci) {
-
RasterizerCanvas::Light *light = p_masked_lights;
while (light) {
-
if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) {
ci->light_masked = true;
}
@@ -243,11 +243,9 @@ void RenderingServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::
}
void RenderingServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
-
RENDER_TIMESTAMP(">Render Canvas");
if (p_canvas->children_order_dirty) {
-
p_canvas->child_items.sort();
p_canvas->children_order_dirty = false;
}
@@ -264,29 +262,24 @@ void RenderingServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas,
}
if (!has_mirror) {
-
_render_canvas_item_tree(p_render_target, ci, l, nullptr, p_transform, p_clip_rect, p_canvas->modulate, p_lights);
} else {
//used for parallaxlayer mirroring
for (int i = 0; i < l; i++) {
-
const Canvas::ChildItem &ci2 = p_canvas->child_items[i];
_render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights);
//mirroring (useful for scrolling backgrounds)
if (ci2.mirror.x != 0) {
-
Transform2D xform2 = p_transform * Transform2D(0, Vector2(ci2.mirror.x, 0));
_render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
}
if (ci2.mirror.y != 0) {
-
Transform2D xform2 = p_transform * Transform2D(0, Vector2(0, ci2.mirror.y));
_render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
}
if (ci2.mirror.y != 0 && ci2.mirror.x != 0) {
-
Transform2D xform2 = p_transform * Transform2D(0, ci2.mirror);
_render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
}
@@ -297,7 +290,6 @@ void RenderingServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas,
}
RID RenderingServerCanvas::canvas_create() {
-
Canvas *canvas = memnew(Canvas);
ERR_FAIL_COND_V(!canvas, RID());
RID rid = canvas_owner.make_rid(canvas);
@@ -306,7 +298,6 @@ RID RenderingServerCanvas::canvas_create() {
}
void RenderingServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) {
-
Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
Item *canvas_item = canvas_item_owner.getornull(p_item);
@@ -316,8 +307,8 @@ void RenderingServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item,
ERR_FAIL_COND(idx == -1);
canvas->child_items.write[idx].mirror = p_mirroring;
}
-void RenderingServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
+void RenderingServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
canvas->modulate = p_color;
@@ -328,7 +319,6 @@ void RenderingServerCanvas::canvas_set_disable_scale(bool p_disable) {
}
void RenderingServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
-
Canvas *canvas = canvas_owner.getornull(p_canvas);
ERR_FAIL_COND(!canvas);
@@ -337,7 +327,6 @@ void RenderingServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float
}
RID RenderingServerCanvas::canvas_item_create() {
-
Item *canvas_item = memnew(Item);
ERR_FAIL_COND_V(!canvas_item, RID());
@@ -345,18 +334,14 @@ RID RenderingServerCanvas::canvas_item_create() {
}
void RenderingServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
if (canvas_item->parent.is_valid()) {
-
if (canvas_owner.owns(canvas_item->parent)) {
-
Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
canvas->erase_item(canvas_item);
} else if (canvas_item_owner.owns(canvas_item->parent)) {
-
Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
@@ -370,14 +355,12 @@ void RenderingServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
if (p_parent.is_valid()) {
if (canvas_owner.owns(p_parent)) {
-
Canvas *canvas = canvas_owner.getornull(p_parent);
Canvas::ChildItem ci;
ci.item = canvas_item;
canvas->child_items.push_back(ci);
canvas->children_order_dirty = true;
} else if (canvas_item_owner.owns(p_parent)) {
-
Item *item_owner = canvas_item_owner.getornull(p_parent);
item_owner->child_items.push_back(canvas_item);
item_owner->children_order_dirty = true;
@@ -387,15 +370,14 @@ void RenderingServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
}
} else {
-
ERR_FAIL_MSG("Invalid parent.");
}
}
canvas_item->parent = p_parent;
}
-void RenderingServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) {
+void RenderingServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -403,8 +385,8 @@ void RenderingServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible)
_mark_ysort_dirty(canvas_item, canvas_item_owner);
}
-void RenderingServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
+void RenderingServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -412,43 +394,42 @@ void RenderingServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) {
}
void RenderingServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->xform = p_transform;
}
-void RenderingServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) {
+void RenderingServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clip = p_clip;
}
-void RenderingServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->distance_field = p_enable;
}
-void RenderingServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
+void RenderingServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->custom_rect = p_custom_rect;
canvas_item->rect = p_rect;
}
-void RenderingServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) {
+void RenderingServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->modulate = p_color;
}
-void RenderingServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
+void RenderingServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -456,7 +437,6 @@ void RenderingServerCanvas::canvas_item_set_self_modulate(RID p_item, const Colo
}
void RenderingServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -464,7 +444,6 @@ void RenderingServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool
}
void RenderingServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_update) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -472,28 +451,24 @@ void RenderingServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool
}
void RenderingServerCanvas::canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->texture_filter = p_filter;
}
void RenderingServerCanvas::canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->texture_repeat = p_repeat;
}
void RenderingServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
Item::CommandPrimitive *line = canvas_item->alloc_command<Item::CommandPrimitive>();
ERR_FAIL_COND(!line);
if (p_width > 1.001) {
-
Vector2 t = (p_from - p_to).tangent().normalized();
line->points[0] = p_from + t * p_width;
line->points[1] = p_from - t * p_width;
@@ -512,7 +487,6 @@ void RenderingServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_fro
}
void RenderingServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
-
ERR_FAIL_COND(p_points.size() < 2);
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -604,7 +578,6 @@ void RenderingServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Po
}
void RenderingServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) {
-
ERR_FAIL_COND(p_points.size() < 2);
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -625,7 +598,6 @@ void RenderingServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<P
}
void RenderingServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -636,7 +608,6 @@ void RenderingServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect
}
void RenderingServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -674,7 +645,6 @@ void RenderingServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_p
}
void RenderingServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -690,12 +660,10 @@ void RenderingServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2
}
if (p_rect.size.x < 0) {
-
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->rect.size.x = -rect->rect.size.x;
}
if (p_rect.size.y < 0) {
-
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->rect.size.y = -rect->rect.size.y;
}
@@ -708,7 +676,6 @@ void RenderingServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2
}
void RenderingServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -722,22 +689,18 @@ void RenderingServerCanvas::canvas_item_add_texture_rect_region(RID p_item, cons
rect->flags = RasterizerCanvas::CANVAS_RECT_REGION;
if (p_rect.size.x < 0) {
-
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->rect.size.x = -rect->rect.size.x;
}
if (p_src_rect.size.x < 0) {
-
rect->flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->source.size.x = -rect->source.size.x;
}
if (p_rect.size.y < 0) {
-
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->rect.size.y = -rect->rect.size.y;
}
if (p_src_rect.size.y < 0) {
-
rect->flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->source.size.y = -rect->source.size.y;
}
@@ -753,7 +716,6 @@ void RenderingServerCanvas::canvas_item_add_texture_rect_region(RID p_item, cons
}
void RenderingServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode, RS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -772,8 +734,8 @@ void RenderingServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &
style->axis_x = p_x_axis_mode;
style->axis_y = p_y_axis_mode;
}
-void RenderingServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
uint32_t pc = p_points.size();
ERR_FAIL_COND(pc == 0 || pc > 4);
@@ -804,7 +766,6 @@ void RenderingServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<P
}
void RenderingServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
#ifdef DEBUG_ENABLED
@@ -815,7 +776,7 @@ void RenderingServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Poi
ERR_FAIL_COND(color_size != 0 && color_size != 1 && color_size != pointcount);
ERR_FAIL_COND(uv_size != 0 && (uv_size != pointcount));
#endif
- Vector<int> indices = Geometry::triangulate_polygon(p_points);
+ Vector<int> indices = Geometry2D::triangulate_polygon(p_points);
ERR_FAIL_COND_MSG(indices.empty(), "Invalid polygon data, triangulation failed.");
Item::CommandPolygon *polygon = canvas_item->alloc_command<Item::CommandPolygon>();
@@ -827,7 +788,6 @@ void RenderingServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Poi
}
void RenderingServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -850,7 +810,6 @@ void RenderingServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vec
}
void RenderingServerCanvas::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -860,7 +819,6 @@ void RenderingServerCanvas::canvas_item_add_set_transform(RID p_item, const Tran
}
void RenderingServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -872,8 +830,8 @@ void RenderingServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh,
m->transform = p_transform;
m->modulate = p_modulate;
}
-void RenderingServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
+void RenderingServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -888,7 +846,6 @@ void RenderingServerCanvas::canvas_item_add_particles(RID p_item, RID p_particle
}
void RenderingServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -900,7 +857,6 @@ void RenderingServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RI
}
void RenderingServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -908,8 +864,8 @@ void RenderingServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignor
ERR_FAIL_COND(!ci);
ci->ignore = p_ignore;
}
-void RenderingServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -917,8 +873,8 @@ void RenderingServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool
_mark_ysort_dirty(canvas_item, canvas_item_owner);
}
-void RenderingServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) {
+void RenderingServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) {
ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN || p_z > RS::CANVAS_ITEM_Z_MAX);
Item *canvas_item = canvas_item_owner.getornull(p_item);
@@ -926,8 +882,8 @@ void RenderingServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) {
canvas_item->z_index = p_z;
}
-void RenderingServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
+void RenderingServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -935,7 +891,6 @@ void RenderingServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item,
}
void RenderingServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -943,7 +898,6 @@ void RenderingServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skelet
}
void RenderingServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
if (bool(canvas_item->copy_back_buffer != nullptr) != p_enable) {
@@ -962,14 +916,13 @@ void RenderingServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool
}
void RenderingServerCanvas::canvas_item_clear(RID p_item) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
canvas_item->clear();
}
-void RenderingServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
+void RenderingServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -989,7 +942,6 @@ void RenderingServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index)
}
void RenderingServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -997,7 +949,6 @@ void RenderingServerCanvas::canvas_item_set_material(RID p_item, RID p_material)
}
void RenderingServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
-
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -1005,57 +956,54 @@ void RenderingServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool
}
RID RenderingServerCanvas::canvas_light_create() {
-
RasterizerCanvas::Light *clight = memnew(RasterizerCanvas::Light);
clight->light_internal = RSG::canvas_render->light_create();
return canvas_light_owner.make_rid(clight);
}
-void RenderingServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
+void RenderingServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
if (clight->canvas.is_valid()) {
-
Canvas *canvas = canvas_owner.getornull(clight->canvas);
canvas->lights.erase(clight);
}
- if (!canvas_owner.owns(p_canvas))
+ if (!canvas_owner.owns(p_canvas)) {
p_canvas = RID();
+ }
clight->canvas = p_canvas;
if (clight->canvas.is_valid()) {
-
Canvas *canvas = canvas_owner.getornull(clight->canvas);
canvas->lights.insert(clight);
}
}
void RenderingServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) {
-
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->enabled = p_enabled;
}
-void RenderingServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
+void RenderingServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->scale = p_scale;
}
-void RenderingServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
+void RenderingServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->xform = p_transform;
}
-void RenderingServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
+void RenderingServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1063,66 +1011,66 @@ void RenderingServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture)
clight->version++;
RSG::canvas_render->light_set_texture(clight->light_internal, p_texture);
}
-void RenderingServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
+void RenderingServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->texture_offset = p_offset;
}
-void RenderingServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
+void RenderingServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->color = p_color;
}
-void RenderingServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
+void RenderingServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->height = p_height;
}
-void RenderingServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
+void RenderingServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->energy = p_energy;
}
-void RenderingServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
+void RenderingServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->z_min = p_min_z;
clight->z_max = p_max_z;
}
-void RenderingServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
+void RenderingServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->layer_max = p_max_layer;
clight->layer_min = p_min_layer;
}
-void RenderingServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
+void RenderingServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->item_mask = p_mask;
}
-void RenderingServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
+void RenderingServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->item_shadow_mask = p_mask;
}
-void RenderingServerCanvas::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
+void RenderingServerCanvas::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1130,7 +1078,6 @@ void RenderingServerCanvas::canvas_light_set_mode(RID p_light, RS::CanvasLightMo
}
void RenderingServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
-
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1143,15 +1090,15 @@ void RenderingServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_
}
void RenderingServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size) {
-
ERR_FAIL_COND(p_size < 32 || p_size > 16384);
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
int new_size = next_power_of_2(p_size);
- if (new_size == clight->shadow_buffer_size)
+ if (new_size == clight->shadow_buffer_size) {
return;
+ }
clight->shadow_buffer_size = next_power_of_2(p_size);
clight->version++;
@@ -1160,14 +1107,13 @@ void RenderingServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int
}
void RenderingServerCanvas::canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter) {
-
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_filter = p_filter;
}
-void RenderingServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
+void RenderingServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
@@ -1175,49 +1121,46 @@ void RenderingServerCanvas::canvas_light_set_shadow_color(RID p_light, const Col
}
void RenderingServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
-
RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
ERR_FAIL_COND(!clight);
clight->shadow_smooth = p_smooth;
}
RID RenderingServerCanvas::canvas_light_occluder_create() {
-
RasterizerCanvas::LightOccluderInstance *occluder = memnew(RasterizerCanvas::LightOccluderInstance);
return canvas_light_occluder_owner.make_rid(occluder);
}
-void RenderingServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
+void RenderingServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
if (occluder->canvas.is_valid()) {
-
Canvas *canvas = canvas_owner.getornull(occluder->canvas);
canvas->occluders.erase(occluder);
}
- if (!canvas_owner.owns(p_canvas))
+ if (!canvas_owner.owns(p_canvas)) {
p_canvas = RID();
+ }
occluder->canvas = p_canvas;
if (occluder->canvas.is_valid()) {
-
Canvas *canvas = canvas_owner.getornull(occluder->canvas);
canvas->occluders.insert(occluder);
}
}
-void RenderingServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
+void RenderingServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->enabled = p_enabled;
}
-void RenderingServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
+void RenderingServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1244,15 +1187,15 @@ void RenderingServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RI
}
}
}
-void RenderingServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
+void RenderingServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
occluder->xform = p_xform;
}
-void RenderingServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
+void RenderingServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
ERR_FAIL_COND(!occluder);
@@ -1260,13 +1203,12 @@ void RenderingServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder,
}
RID RenderingServerCanvas::canvas_occluder_polygon_create() {
-
LightOccluderPolygon *occluder_poly = memnew(LightOccluderPolygon);
occluder_poly->occluder = RSG::canvas_render->occluder_polygon_create();
return canvas_light_occluder_polygon_owner.make_rid(occluder_poly);
}
-void RenderingServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
+void RenderingServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) {
if (p_shape.size() < 3) {
canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, p_shape);
return;
@@ -1285,7 +1227,6 @@ void RenderingServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_pol
max--;
}
for (int i = 0; i < max; i++) {
-
Vector2 a = r[i];
Vector2 b = r[(i + 1) % (lc / 2)];
w[i * 2 + 0] = a;
@@ -1295,8 +1236,8 @@ void RenderingServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_pol
canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, lines);
}
-void RenderingServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape) {
+void RenderingServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape) {
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
ERR_FAIL_COND(p_shape.size() & 1);
@@ -1306,10 +1247,11 @@ void RenderingServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occ
{
const Vector2 *r = p_shape.ptr();
for (int i = 0; i < lc; i++) {
- if (i == 0)
+ if (i == 0) {
occluder_poly->aabb.position = r[i];
- else
+ } else {
occluder_poly->aabb.expand_to(r[i]);
+ }
}
}
@@ -1320,7 +1262,6 @@ void RenderingServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occ
}
void RenderingServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode) {
-
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
ERR_FAIL_COND(!occluder_poly);
occluder_poly->cull_mode = p_mode;
@@ -1331,14 +1272,11 @@ void RenderingServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder
}
bool RenderingServerCanvas::free(RID p_rid) {
-
if (canvas_owner.owns(p_rid)) {
-
Canvas *canvas = canvas_owner.getornull(p_rid);
ERR_FAIL_COND_V(!canvas, false);
while (canvas->viewports.size()) {
-
RenderingServerViewport::Viewport *vp = RSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get());
ERR_FAIL_COND_V(!vp, true);
@@ -1350,17 +1288,14 @@ bool RenderingServerCanvas::free(RID p_rid) {
}
for (int i = 0; i < canvas->child_items.size(); i++) {
-
canvas->child_items[i].item->parent = RID();
}
for (Set<RasterizerCanvas::Light *>::Element *E = canvas->lights.front(); E; E = E->next()) {
-
E->get()->canvas = RID();
}
for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = canvas->occluders.front(); E; E = E->next()) {
-
E->get()->canvas = RID();
}
@@ -1369,18 +1304,14 @@ bool RenderingServerCanvas::free(RID p_rid) {
memdelete(canvas);
} else if (canvas_item_owner.owns(p_rid)) {
-
Item *canvas_item = canvas_item_owner.getornull(p_rid);
ERR_FAIL_COND_V(!canvas_item, true);
if (canvas_item->parent.is_valid()) {
-
if (canvas_owner.owns(canvas_item->parent)) {
-
Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
canvas->erase_item(canvas_item);
} else if (canvas_item_owner.owns(canvas_item->parent)) {
-
Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
item_owner->child_items.erase(canvas_item);
@@ -1391,7 +1322,6 @@ bool RenderingServerCanvas::free(RID p_rid) {
}
for (int i = 0; i < canvas_item->child_items.size(); i++) {
-
canvas_item->child_items[i]->parent = RID();
}
@@ -1406,14 +1336,14 @@ bool RenderingServerCanvas::free(RID p_rid) {
memdelete(canvas_item);
} else if (canvas_light_owner.owns(p_rid)) {
-
RasterizerCanvas::Light *canvas_light = canvas_light_owner.getornull(p_rid);
ERR_FAIL_COND_V(!canvas_light, true);
if (canvas_light->canvas.is_valid()) {
Canvas *canvas = canvas_owner.getornull(canvas_light->canvas);
- if (canvas)
+ if (canvas) {
canvas->lights.erase(canvas_light);
+ }
}
RSG::canvas_render->free(canvas_light->light_internal);
@@ -1422,12 +1352,10 @@ bool RenderingServerCanvas::free(RID p_rid) {
memdelete(canvas_light);
} else if (canvas_light_occluder_owner.owns(p_rid)) {
-
RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_rid);
ERR_FAIL_COND_V(!occluder, true);
if (occluder->polygon.is_valid()) {
-
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(occluder->polygon);
if (occluder_poly) {
occluder_poly->owners.erase(occluder);
@@ -1435,7 +1363,6 @@ bool RenderingServerCanvas::free(RID p_rid) {
}
if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) {
-
Canvas *canvas = canvas_owner.getornull(occluder->canvas);
canvas->occluders.erase(occluder);
}
@@ -1444,13 +1371,11 @@ bool RenderingServerCanvas::free(RID p_rid) {
memdelete(occluder);
} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
-
LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
ERR_FAIL_COND_V(!occluder_poly, true);
RSG::canvas_render->free(occluder_poly->occluder);
while (occluder_poly->owners.size()) {
-
occluder_poly->owners.front()->get()->polygon = RID();
occluder_poly->owners.erase(occluder_poly->owners.front());
}
@@ -1465,7 +1390,6 @@ bool RenderingServerCanvas::free(RID p_rid) {
}
RenderingServerCanvas::RenderingServerCanvas() {
-
z_list = (RasterizerCanvas::Item **)memalloc(z_range * sizeof(RasterizerCanvas::Item *));
z_last_list = (RasterizerCanvas::Item **)memalloc(z_range * sizeof(RasterizerCanvas::Item *));
@@ -1473,7 +1397,6 @@ RenderingServerCanvas::RenderingServerCanvas() {
}
RenderingServerCanvas::~RenderingServerCanvas() {
-
memfree(z_list);
memfree(z_last_list);
}
diff --git a/servers/rendering/rendering_server_canvas.h b/servers/rendering/rendering_server_canvas.h
index 9da11462db..59c0d1fa52 100644
--- a/servers/rendering/rendering_server_canvas.h
+++ b/servers/rendering/rendering_server_canvas.h
@@ -37,7 +37,6 @@
class RenderingServerCanvas {
public:
struct Item : public RasterizerCanvas::Item {
-
RID parent; // canvas it belongs to
List<Item *>::Element *E;
int z_index;
@@ -76,26 +75,22 @@ public:
};
struct ItemIndexSort {
-
_FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const {
-
return p_left->index < p_right->index;
}
};
struct ItemPtrSort {
-
_FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const {
-
- if (Math::is_equal_approx(p_left->ysort_pos.y, p_right->ysort_pos.y))
+ if (Math::is_equal_approx(p_left->ysort_pos.y, p_right->ysort_pos.y)) {
return p_left->ysort_pos.x < p_right->ysort_pos.x;
+ }
return p_left->ysort_pos.y < p_right->ysort_pos.y;
}
};
struct LightOccluderPolygon {
-
bool active;
Rect2 aabb;
RS::CanvasOccluderPolygonCullMode cull_mode;
@@ -113,10 +108,8 @@ public:
RID_PtrOwner<RasterizerCanvas::LightOccluderInstance> canvas_light_occluder_owner;
struct Canvas : public RenderingServerViewport::CanvasBase {
-
Set<RID> viewports;
struct ChildItem {
-
Point2 mirror;
Item *item;
bool operator<(const ChildItem &p_item) const {
@@ -136,15 +129,17 @@ public:
int find_item(Item *p_item) {
for (int i = 0; i < child_items.size(); i++) {
- if (child_items[i].item == p_item)
+ if (child_items[i].item == p_item) {
return i;
+ }
}
return -1;
}
void erase_item(Item *p_item) {
int idx = find_item(p_item);
- if (idx >= 0)
+ if (idx >= 0) {
child_items.remove(idx);
+ }
}
Canvas() {
diff --git a/servers/rendering/rendering_server_raster.cpp b/servers/rendering/rendering_server_raster.cpp
index c6f3273339..d30160702b 100644
--- a/servers/rendering/rendering_server_raster.cpp
+++ b/servers/rendering/rendering_server_raster.cpp
@@ -45,7 +45,6 @@ int RenderingServerRaster::changes = 0;
/* BLACK BARS */
void RenderingServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
-
black_margin[MARGIN_LEFT] = p_left;
black_margin[MARGIN_TOP] = p_top;
black_margin[MARGIN_RIGHT] = p_right;
@@ -53,7 +52,6 @@ void RenderingServerRaster::black_bars_set_margins(int p_left, int p_top, int p_
}
void RenderingServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
-
black_image[MARGIN_LEFT] = p_left;
black_image[MARGIN_TOP] = p_top;
black_image[MARGIN_RIGHT] = p_right;
@@ -61,30 +59,32 @@ void RenderingServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_r
}
void RenderingServerRaster::_draw_margins() {
-
RSG::canvas_render->draw_window_margins(black_margin, black_image);
};
/* FREE */
void RenderingServerRaster::free(RID p_rid) {
-
- if (RSG::storage->free(p_rid))
+ if (RSG::storage->free(p_rid)) {
return;
- if (RSG::canvas->free(p_rid))
+ }
+ if (RSG::canvas->free(p_rid)) {
return;
- if (RSG::viewport->free(p_rid))
+ }
+ if (RSG::viewport->free(p_rid)) {
return;
- if (RSG::scene->free(p_rid))
+ }
+ if (RSG::scene->free(p_rid)) {
return;
- if (RSG::scene_render->free(p_rid))
+ }
+ if (RSG::scene_render->free(p_rid)) {
return;
+ }
}
/* EVENT QUEUING */
void RenderingServerRaster::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) {
-
ERR_FAIL_NULL(p_where);
FrameDrawnCallbacks fdc;
fdc.object = p_where->get_instance_id();
@@ -95,7 +95,6 @@ void RenderingServerRaster::request_frame_drawn_callback(Object *p_where, const
}
void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
-
//needs to be done before changes is reset to 0, to not force the editor to redraw
RS::get_singleton()->emit_signal("frame_pre_draw");
@@ -117,7 +116,6 @@ void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
RSG::rasterizer->end_frame(p_swap_buffers);
while (frame_drawn_callbacks.front()) {
-
Object *obj = ObjectDB::get_instance(frame_drawn_callbacks.front()->get().object);
if (obj) {
Callable::CallError ce;
@@ -163,18 +161,19 @@ void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) {
frame_profile_frame = RSG::storage->get_captured_timestamps_frame();
}
+
void RenderingServerRaster::sync() {
}
-bool RenderingServerRaster::has_changed() const {
+bool RenderingServerRaster::has_changed() const {
return changes > 0;
}
-void RenderingServerRaster::init() {
+void RenderingServerRaster::init() {
RSG::rasterizer->initialize();
}
-void RenderingServerRaster::finish() {
+void RenderingServerRaster::finish() {
if (test_cube.is_valid()) {
free(test_cube);
}
@@ -185,17 +184,14 @@ void RenderingServerRaster::finish() {
/* STATUS INFORMATION */
int RenderingServerRaster::get_render_info(RenderInfo p_info) {
-
return RSG::storage->get_render_info(p_info);
}
String RenderingServerRaster::get_video_adapter_name() const {
-
return RSG::storage->get_video_adapter_name();
}
String RenderingServerRaster::get_video_adapter_vendor() const {
-
return RSG::storage->get_video_adapter_vendor();
}
@@ -214,16 +210,15 @@ Vector<RenderingServer::FrameProfileArea> RenderingServerRaster::get_frame_profi
/* TESTING */
void RenderingServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
-
redraw_request();
RSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter);
}
+
void RenderingServerRaster::set_default_clear_color(const Color &p_color) {
RSG::viewport->set_default_clear_color(p_color);
}
bool RenderingServerRaster::has_feature(Features p_feature) const {
-
return false;
}
@@ -235,12 +230,10 @@ RID RenderingServerRaster::get_test_cube() {
}
bool RenderingServerRaster::has_os_feature(const String &p_feature) const {
-
return RSG::storage->has_os_feature(p_feature);
}
void RenderingServerRaster::set_debug_generate_wireframes(bool p_generate) {
-
RSG::storage->set_debug_generate_wireframes(p_generate);
}
@@ -255,8 +248,8 @@ bool RenderingServerRaster::is_low_end() const {
//return RSG::rasterizer->is_low_end();
return false;
}
-RenderingServerRaster::RenderingServerRaster() {
+RenderingServerRaster::RenderingServerRaster() {
RSG::canvas = memnew(RenderingServerCanvas);
RSG::viewport = memnew(RenderingServerViewport);
RSG::scene = memnew(RenderingServerScene);
@@ -274,7 +267,6 @@ RenderingServerRaster::RenderingServerRaster() {
}
RenderingServerRaster::~RenderingServerRaster() {
-
memdelete(RSG::canvas);
memdelete(RSG::viewport);
memdelete(RSG::rasterizer);
diff --git a/servers/rendering/rendering_server_raster.h b/servers/rendering/rendering_server_raster.h
index 5dd146861d..8a3c55118d 100644
--- a/servers/rendering/rendering_server_raster.h
+++ b/servers/rendering/rendering_server_raster.h
@@ -40,7 +40,6 @@
#include "servers/rendering_server.h"
class RenderingServerRaster : public RenderingServer {
-
enum {
MAX_INSTANCE_CULL = 8192,
@@ -61,7 +60,6 @@ class RenderingServerRaster : public RenderingServer {
RID black_image[4];
struct FrameDrawnCallbacks {
-
ObjectID object;
StringName method;
Variant param;
diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp
index 95334ee102..7b8504036e 100644
--- a/servers/rendering/rendering_server_scene.cpp
+++ b/servers/rendering/rendering_server_scene.cpp
@@ -39,13 +39,11 @@
/* CAMERA API */
RID RenderingServerScene::camera_create() {
-
Camera *camera = memnew(Camera);
return camera_owner.make_rid(camera);
}
void RenderingServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::PERSPECTIVE;
@@ -55,7 +53,6 @@ void RenderingServerScene::camera_set_perspective(RID p_camera, float p_fovy_deg
}
void RenderingServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->type = Camera::ORTHOGONAL;
@@ -75,14 +72,12 @@ void RenderingServerScene::camera_set_frustum(RID p_camera, float p_size, Vector
}
void RenderingServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->transform = p_transform.orthonormalized();
}
void RenderingServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
@@ -90,21 +85,18 @@ void RenderingServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers)
}
void RenderingServerScene::camera_set_environment(RID p_camera, RID p_env) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->env = p_env;
}
void RenderingServerScene::camera_set_camera_effects(RID p_camera, RID p_fx) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->effects = p_fx;
}
void RenderingServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
-
Camera *camera = camera_owner.getornull(p_camera);
ERR_FAIL_COND(!camera);
camera->vaspect = p_enable;
@@ -113,7 +105,6 @@ void RenderingServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_e
/* SCENARIO API */
void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) {
-
//RenderingServerScene *self = (RenderingServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -124,7 +115,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
}
if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -135,14 +125,12 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
List<InstanceLightData::PairInfo>::Element *E = light->geometries.push_back(pinfo);
if (geom->can_cast_shadows) {
-
light->shadow_dirty = true;
}
geom->lighting_dirty = true;
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -156,7 +144,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_DECAL && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -170,7 +157,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_LIGHTMAP && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -186,7 +172,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
}
} else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -206,15 +191,14 @@ void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instan
return E; //this element should make freeing faster
} else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
return gi_probe->lights.insert(A);
}
return nullptr;
}
-void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
+void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
//RenderingServerScene *self = (RenderingServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -225,7 +209,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
}
if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -240,7 +223,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->lighting_dirty = true;
} else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -251,7 +233,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->reflection_dirty = true;
} else if (B->base_type == RS::INSTANCE_DECAL && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -262,7 +243,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->decal_dirty = true;
} else if (B->base_type == RS::INSTANCE_LIGHTMAP && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
if (udata) { //only for dynamic geometries
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -275,7 +255,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
}
} else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -291,7 +270,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
geom->gi_probes_dirty = true;
} else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
Set<Instance *>::Element *E = reinterpret_cast<Set<Instance *>::Element *>(udata);
@@ -300,7 +278,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Insta
}
RID RenderingServerScene::scenario_create() {
-
Scenario *scenario = memnew(Scenario);
ERR_FAIL_COND_V(!scenario, RID());
RID scenario_rid = scenario_owner.make_rid(scenario);
@@ -319,35 +296,30 @@ RID RenderingServerScene::scenario_create() {
}
void RenderingServerScene::scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->debug = p_debug_mode;
}
void RenderingServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->environment = p_environment;
}
void RenderingServerScene::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->camera_effects = p_camera_effects;
}
void RenderingServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
scenario->fallback_environment = p_environment;
}
void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
RSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count);
@@ -356,20 +328,21 @@ void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, in
/* INSTANCING API */
void RenderingServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies) {
-
- if (p_update_aabb)
+ if (p_update_aabb) {
p_instance->update_aabb = true;
- if (p_update_dependencies)
+ }
+ if (p_update_dependencies) {
p_instance->update_dependencies = true;
+ }
- if (p_instance->update_item.in_list())
+ if (p_instance->update_item.in_list()) {
return;
+ }
_instance_update_list.add(&p_instance->update_item);
}
RID RenderingServerScene::instance_create() {
-
Instance *instance = memnew(Instance);
ERR_FAIL_COND_V(!instance, RID());
@@ -380,7 +353,6 @@ RID RenderingServerScene::instance_create() {
}
void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -396,7 +368,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
switch (instance->base_type) {
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
#ifdef DEBUG_ENABLED
if (light->geometries.size()) {
@@ -410,7 +381,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
RSG::scene_render->free(light->instance);
} break;
case RS::INSTANCE_REFLECTION_PROBE: {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
RSG::scene_render->free(reflection_probe->instance);
if (reflection_probe->update_list.in_list()) {
@@ -418,13 +388,11 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
}
} break;
case RS::INSTANCE_DECAL: {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(instance->base_data);
RSG::scene_render->free(decal->instance);
} break;
case RS::INSTANCE_LIGHTMAP: {
-
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(instance->base_data);
//erase dependencies, since no longer a lightmap
while (lightmap_data->users.front()) {
@@ -432,7 +400,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
}
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
#ifdef DEBUG_ENABLED
if (gi_probe->geometries.size()) {
@@ -468,13 +435,11 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
instance->base = RID();
if (p_base.is_valid()) {
-
instance->base_type = RSG::storage->get_base_type(p_base);
ERR_FAIL_COND(instance->base_type == RS::INSTANCE_NONE);
switch (instance->base_type) {
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = memnew(InstanceLightData);
if (scenario && RSG::storage->light_get_type(p_base) == RS::LIGHT_DIRECTIONAL) {
@@ -489,7 +454,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
case RS::INSTANCE_MULTIMESH:
case RS::INSTANCE_IMMEDIATE:
case RS::INSTANCE_PARTICLES: {
-
InstanceGeometryData *geom = memnew(InstanceGeometryData);
instance->base_data = geom;
if (instance->base_type == RS::INSTANCE_MESH) {
@@ -497,7 +461,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
}
} break;
case RS::INSTANCE_REFLECTION_PROBE: {
-
InstanceReflectionProbeData *reflection_probe = memnew(InstanceReflectionProbeData);
reflection_probe->owner = instance;
instance->base_data = reflection_probe;
@@ -505,7 +468,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
reflection_probe->instance = RSG::scene_render->reflection_probe_instance_create(p_base);
} break;
case RS::INSTANCE_DECAL: {
-
InstanceDecalData *decal = memnew(InstanceDecalData);
decal->owner = instance;
instance->base_data = decal;
@@ -513,13 +475,11 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
decal->instance = RSG::scene_render->decal_instance_create(p_base);
} break;
case RS::INSTANCE_LIGHTMAP: {
-
InstanceLightmapData *lightmap_data = memnew(InstanceLightmapData);
instance->base_data = lightmap_data;
//lightmap_data->instance = RSG::scene_render->lightmap_data_instance_create(p_base);
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = memnew(InstanceGIProbeData);
instance->base_data = gi_probe;
gi_probe->owner = instance;
@@ -543,13 +503,12 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
_instance_queue_update(instance, true, true);
}
-void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
+void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
if (instance->scenario) {
-
instance->scenario->instances.remove(&instance->scenario_item);
if (instance->octree_id) {
@@ -558,9 +517,7 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
switch (instance->base_type) {
-
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
#ifdef DEBUG_ENABLED
if (light->geometries.size()) {
@@ -578,7 +535,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
#ifdef DEBUG_ENABLED
@@ -604,7 +560,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
if (p_scenario.is_valid()) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND(!scenario);
@@ -613,9 +568,7 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
scenario->instances.add(&instance->scenario_item);
switch (instance->base_type) {
-
case RS::INSTANCE_LIGHT: {
-
InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data);
if (RSG::storage->light_get_type(instance->base) == RS::LIGHT_DIRECTIONAL) {
@@ -623,7 +576,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
}
} break;
case RS::INSTANCE_GI_PROBE: {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data);
if (!gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
@@ -636,20 +588,21 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
_instance_queue_update(instance, true, true);
}
}
-void RenderingServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
+void RenderingServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->layer_mask = p_mask;
}
-void RenderingServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
+void RenderingServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
- if (instance->transform == p_transform)
+ if (instance->transform == p_transform) {
return; //must be checked to avoid worst evil
+ }
#ifdef DEBUG_ENABLED
@@ -667,15 +620,15 @@ void RenderingServerScene::instance_set_transform(RID p_instance, const Transfor
instance->transform = p_transform;
_instance_queue_update(instance, true);
}
-void RenderingServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
+void RenderingServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->object_id = p_id;
}
-void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
+void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -688,7 +641,6 @@ void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p
}
void RenderingServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -705,12 +657,12 @@ void RenderingServerScene::instance_set_surface_material(RID p_instance, int p_s
}
void RenderingServerScene::instance_set_visible(RID p_instance, bool p_visible) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
- if (instance->visible == p_visible)
+ if (instance->visible == p_visible) {
return;
+ }
instance->visible = p_visible;
@@ -749,25 +701,24 @@ void RenderingServerScene::instance_set_visible(RID p_instance, bool p_visible)
}
}
}
+
inline bool is_geometry_instance(RenderingServer::InstanceType p_type) {
return p_type == RS::INSTANCE_MESH || p_type == RS::INSTANCE_MULTIMESH || p_type == RS::INSTANCE_PARTICLES || p_type == RS::INSTANCE_IMMEDIATE;
}
void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
if (p_aabb != AABB()) {
-
// Set custom AABB
- if (instance->custom_aabb == nullptr)
+ if (instance->custom_aabb == nullptr) {
instance->custom_aabb = memnew(AABB);
+ }
*instance->custom_aabb = p_aabb;
} else {
-
// Clear custom AABB
if (instance->custom_aabb != nullptr) {
memdelete(instance->custom_aabb);
@@ -775,17 +726,18 @@ void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb)
}
}
- if (instance->scenario)
+ if (instance->scenario) {
_instance_queue_update(instance, true, false);
+ }
}
void RenderingServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
- if (instance->skeleton == p_skeleton)
+ if (instance->skeleton == p_skeleton) {
return;
+ }
instance->skeleton = p_skeleton;
@@ -808,7 +760,6 @@ void RenderingServerScene::instance_set_extra_visibility_margin(RID p_instance,
}
Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
-
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
@@ -820,19 +771,19 @@ Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, R
culled = scenario->octree.cull_aabb(p_aabb, cull, 1024);
for (int i = 0; i < culled; i++) {
-
Instance *instance = cull[i];
ERR_CONTINUE(!instance);
- if (instance->object_id.is_null())
+ if (instance->object_id.is_null()) {
continue;
+ }
instances.push_back(instance->object_id);
}
return instances;
}
-Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
+Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
@@ -845,16 +796,17 @@ Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from,
for (int i = 0; i < culled; i++) {
Instance *instance = cull[i];
ERR_CONTINUE(!instance);
- if (instance->object_id.is_null())
+ if (instance->object_id.is_null()) {
continue;
+ }
instances.push_back(instance->object_id);
}
return instances;
}
-Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
+Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.getornull(p_scenario);
ERR_FAIL_COND_V(!scenario, instances);
@@ -866,11 +818,11 @@ Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane>
culled = scenario->octree.cull_convex(p_convex, cull, 1024);
for (int i = 0; i < culled; i++) {
-
Instance *instance = cull[i];
ERR_CONTINUE(!instance);
- if (instance->object_id.is_null())
+ if (instance->object_id.is_null()) {
continue;
+ }
instances.push_back(instance->object_id);
}
@@ -879,21 +831,17 @@ Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane>
}
void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
//ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK));
switch (p_flags) {
-
case RS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
-
instance->baked_light = p_enabled;
} break;
case RS::INSTANCE_FLAG_USE_DYNAMIC_GI: {
-
if (p_enabled == instance->dynamic_gi) {
//bye, redundant
return;
@@ -911,7 +859,6 @@ void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::Instan
} break;
case RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: {
-
instance->redraw_if_visible = p_enabled;
} break;
@@ -919,16 +866,16 @@ void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::Instan
}
}
}
-void RenderingServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
+void RenderingServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
instance->cast_shadows = p_shadow_casting_setting;
_instance_queue_update(instance, false, true);
}
-void RenderingServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
+void RenderingServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -938,11 +885,11 @@ void RenderingServerScene::instance_geometry_set_material_override(RID p_instanc
void RenderingServerScene::instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) {
}
+
void RenderingServerScene::instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) {
}
void RenderingServerScene::instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -965,7 +912,6 @@ void RenderingServerScene::instance_geometry_set_lightmap(RID p_instance, RID p_
}
void RenderingServerScene::instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) {
-
Instance *instance = instance_owner.getornull(p_instance);
ERR_FAIL_COND(!instance);
@@ -987,7 +933,6 @@ void RenderingServerScene::instance_geometry_set_shader_parameter(RID p_instance
}
Variant RenderingServerScene::instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const {
-
const Instance *instance = const_cast<RenderingServerScene *>(this)->instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
@@ -998,7 +943,6 @@ Variant RenderingServerScene::instance_geometry_get_shader_parameter(RID p_insta
}
Variant RenderingServerScene::instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const {
-
const Instance *instance = const_cast<RenderingServerScene *>(this)->instance_owner.getornull(p_instance);
ERR_FAIL_COND_V(!instance, Variant());
@@ -1026,11 +970,9 @@ void RenderingServerScene::instance_geometry_get_shader_parameter_list(RID p_ins
}
void RenderingServerScene::_update_instance(Instance *p_instance) {
-
p_instance->version++;
if (p_instance->base_type == RS::INSTANCE_LIGHT) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
RSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform);
@@ -1038,7 +980,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
RSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform);
@@ -1046,21 +987,18 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if (p_instance->base_type == RS::INSTANCE_DECAL) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(p_instance->base_data);
RSG::scene_render->decal_instance_set_transform(decal->instance, p_instance->transform);
}
if (p_instance->base_type == RS::INSTANCE_GI_PROBE) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(p_instance->base_data);
RSG::scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform);
}
if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
-
RSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
}
@@ -1069,7 +1007,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
-
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
//make sure lights are updated if it casts shadow
@@ -1092,7 +1029,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
if (p_instance->base_type == RS::INSTANCE_LIGHTMAP) {
-
//if this moved, update the captured objects
InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(p_instance->base_data);
//erase dependencies, since no longer a lightmap
@@ -1112,18 +1048,15 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
p_instance->transformed_aabb = new_aabb;
if (!p_instance->scenario) {
-
return;
}
if (p_instance->octree_id == 0) {
-
uint32_t base_type = 1 << p_instance->base_type;
uint32_t pairable_mask = 0;
bool pairable = false;
if (p_instance->base_type == RS::INSTANCE_LIGHT || p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE || p_instance->base_type == RS::INSTANCE_DECAL || p_instance->base_type == RS::INSTANCE_LIGHTMAP) {
-
pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK : 0;
pairable = true;
}
@@ -1138,7 +1071,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
p_instance->octree_id = p_instance->scenario->octree.create(p_instance, new_aabb, 0, pairable, base_type, pairable_mask);
} else {
-
/*
if (new_aabb==p_instance->data.transformed_aabb)
return;
@@ -1149,71 +1081,64 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
}
void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
-
AABB new_aabb;
ERR_FAIL_COND(p_instance->base_type != RS::INSTANCE_NONE && !p_instance->base.is_valid());
switch (p_instance->base_type) {
case RenderingServer::INSTANCE_NONE: {
-
// do nothing
} break;
case RenderingServer::INSTANCE_MESH: {
-
- if (p_instance->custom_aabb)
+ if (p_instance->custom_aabb) {
new_aabb = *p_instance->custom_aabb;
- else
+ } else {
new_aabb = RSG::storage->mesh_get_aabb(p_instance->base, p_instance->skeleton);
+ }
} break;
case RenderingServer::INSTANCE_MULTIMESH: {
-
- if (p_instance->custom_aabb)
+ if (p_instance->custom_aabb) {
new_aabb = *p_instance->custom_aabb;
- else
+ } else {
new_aabb = RSG::storage->multimesh_get_aabb(p_instance->base);
+ }
} break;
case RenderingServer::INSTANCE_IMMEDIATE: {
-
- if (p_instance->custom_aabb)
+ if (p_instance->custom_aabb) {
new_aabb = *p_instance->custom_aabb;
- else
+ } else {
new_aabb = RSG::storage->immediate_get_aabb(p_instance->base);
+ }
} break;
case RenderingServer::INSTANCE_PARTICLES: {
-
- if (p_instance->custom_aabb)
+ if (p_instance->custom_aabb) {
new_aabb = *p_instance->custom_aabb;
- else
+ } else {
new_aabb = RSG::storage->particles_get_aabb(p_instance->base);
+ }
} break;
case RenderingServer::INSTANCE_LIGHT: {
-
new_aabb = RSG::storage->light_get_aabb(p_instance->base);
} break;
case RenderingServer::INSTANCE_REFLECTION_PROBE: {
-
new_aabb = RSG::storage->reflection_probe_get_aabb(p_instance->base);
} break;
case RenderingServer::INSTANCE_DECAL: {
-
new_aabb = RSG::storage->decal_get_aabb(p_instance->base);
} break;
case RenderingServer::INSTANCE_GI_PROBE: {
-
new_aabb = RSG::storage->gi_probe_get_bounds(p_instance->base);
} break;
case RenderingServer::INSTANCE_LIGHTMAP: {
-
new_aabb = RSG::storage->lightmap_get_aabb(p_instance->base);
} break;
@@ -1222,14 +1147,14 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
}
// <Zylann> This is why I didn't re-use Instance::aabb to implement custom AABBs
- if (p_instance->extra_margin)
+ if (p_instance->extra_margin) {
new_aabb.grow_by(p_instance->extra_margin);
+ }
p_instance->aabb = new_aabb;
}
void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instance) {
-
bool first_set = p_instance->lightmap_sh.size() == 0;
p_instance->lightmap_sh.resize(9); //using SH
p_instance->lightmap_target_sh.resize(9); //using SH
@@ -1299,7 +1224,6 @@ void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instan
if (accum_blend > 0.0) {
for (int j = 0; j < 9; j++) {
-
instance_sh[j] = accum_sh[j] / accum_blend;
if (first_set) {
p_instance->lightmap_sh.write[j] = instance_sh[j];
@@ -1309,7 +1233,6 @@ void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instan
}
bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, bool p_cam_vaspect, RID p_shadow_atlas, Scenario *p_scenario) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
Transform light_transform = p_instance->transform;
@@ -1318,9 +1241,7 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
bool animated_material_found = false;
switch (RSG::storage->light_get_type(p_instance->base)) {
-
case RS::LIGHT_DIRECTIONAL: {
-
real_t max_distance = p_cam_projection.get_z_far();
real_t shadow_max = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
if (shadow_max > 0 && !p_cam_orthogonal) { //its impractical (and leads to unwanted behaviors) to set max distance in orthogonal camera
@@ -1345,7 +1266,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t z_min = 1e20;
for (int i = 0; i < cull_count; i++) {
-
Instance *instance = instance_shadow_cull_result[i];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
continue;
@@ -1408,7 +1328,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t min_distance_bias_scale = pancake_size > 0 ? distances[1] / 10.0 : 0;
for (int i = 0; i < splits; i++) {
-
RENDER_TIMESTAMP("Culling Directional Light split" + itos(i));
// setup a camera matrix for that range!
@@ -1417,12 +1336,10 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t aspect = p_cam_projection.get_aspect();
if (p_cam_orthogonal) {
-
Vector2 vp_he = p_cam_projection.get_viewport_half_extents();
camera_matrix.set_orthogonal(vp_he.y * 2.0, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false);
} else {
-
real_t fov = p_cam_projection.get_fov(); //this is actually yfov, because set aspect tries to keep it
camera_matrix.set_perspective(fov, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], true);
}
@@ -1459,25 +1376,30 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
//used for culling
for (int j = 0; j < 8; j++) {
-
real_t d_x = x_vec.dot(endpoints[j]);
real_t d_y = y_vec.dot(endpoints[j]);
real_t d_z = z_vec.dot(endpoints[j]);
- if (j == 0 || d_x < x_min)
+ if (j == 0 || d_x < x_min) {
x_min = d_x;
- if (j == 0 || d_x > x_max)
+ }
+ if (j == 0 || d_x > x_max) {
x_max = d_x;
+ }
- if (j == 0 || d_y < y_min)
+ if (j == 0 || d_y < y_min) {
y_min = d_y;
- if (j == 0 || d_y > y_max)
+ }
+ if (j == 0 || d_y > y_max) {
y_max = d_y;
+ }
- if (j == 0 || d_z < z_min)
+ if (j == 0 || d_z < z_min) {
z_min = d_z;
- if (j == 0 || d_z > z_max)
+ }
+ if (j == 0 || d_z > z_max) {
z_max = d_z;
+ }
}
real_t radius = 0;
@@ -1488,7 +1410,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
//camera viewport stuff
for (int j = 0; j < 8; j++) {
-
center += endpoints[j];
}
center /= 8.0;
@@ -1496,10 +1417,10 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
//center=x_vec*(x_max-x_min)*0.5 + y_vec*(y_max-y_min)*0.5 + z_vec*(z_max-z_min)*0.5;
for (int j = 0; j < 8; j++) {
-
real_t d = center.distance_to(endpoints[j]);
- if (d > radius)
+ if (d > radius) {
radius = d;
+ }
}
radius *= texture_size / (texture_size - 2.0); //add a texel by each side
@@ -1513,11 +1434,9 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
z_min_cam = z_vec.dot(center) - radius;
{
-
float soft_shadow_angle = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SIZE);
if (soft_shadow_angle > 0.0 && pancake_size > 0.0) {
-
float z_range = (z_vec.dot(center) + radius + pancake_size) - z_min_cam;
soft_shadow_expand = Math::tan(Math::deg2rad(soft_shadow_angle)) * z_range;
@@ -1570,7 +1489,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t cull_max = 0;
for (int j = 0; j < cull_count; j++) {
-
real_t min, max;
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
@@ -1597,14 +1515,12 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
}
if (aspect != 1.0) {
-
// if the aspect is different, then the radius will become larger.
// if this happens, then bias needs to be adjusted too, as depth will increase
// to do this, compare the depth of one that would have resulted from a square frustum
CameraMatrix camera_matrix_square;
if (p_cam_orthogonal) {
-
Vector2 vp_he = camera_matrix.get_viewport_half_extents();
if (p_cam_vaspect) {
camera_matrix_square.set_orthogonal(vp_he.x * 2.0, 1.0, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], true);
@@ -1627,13 +1543,13 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t z_max_square = 0;
for (int j = 0; j < 8; j++) {
-
center_square += endpoints_square[j];
real_t d_z = z_vec.dot(endpoints_square[j]);
- if (j == 0 || d_z > z_max_square)
+ if (j == 0 || d_z > z_max_square) {
z_max_square = d_z;
+ }
}
if (cull_max > z_max_square) {
@@ -1645,10 +1561,10 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
real_t radius_square = 0;
for (int j = 0; j < 8; j++) {
-
real_t d = center_square.distance_to(endpoints_square[j]);
- if (d > radius_square)
+ if (d > radius_square) {
radius_square = d;
+ }
}
radius_square *= texture_size / (texture_size - 2.0); //add a texel by each side
@@ -1667,7 +1583,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
}
{
-
CameraMatrix ortho_camera;
real_t half_x = (x_max_cam - x_min_cam) * 0.5;
real_t half_y = (y_max_cam - y_min_cam) * 0.5;
@@ -1694,13 +1609,10 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
} break;
case RS::LIGHT_OMNI: {
-
RS::LightOmniShadowMode shadow_mode = RSG::storage->light_omni_get_shadow_mode(p_instance->base);
if (shadow_mode == RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !RSG::scene_render->light_instances_can_render_shadow_cube()) {
-
for (int i = 0; i < 2; i++) {
-
//using this one ensures that raster deferred will have it
RENDER_TIMESTAMP("Culling Shadow Paraboloid" + itos(i));
@@ -1720,7 +1632,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
Plane near_plane(light_transform.origin, light_transform.basis.get_axis(2) * z);
for (int j = 0; j < cull_count; j++) {
-
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
@@ -1746,7 +1657,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
cm.set_perspective(90, 1, 0.01, radius);
for (int i = 0; i < 6; i++) {
-
RENDER_TIMESTAMP("Culling Shadow Cube side" + itos(i));
//using this one ensures that raster deferred will have it
@@ -1775,7 +1685,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
Plane near_plane(xform.origin, -xform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
-
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
@@ -1800,7 +1709,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
} break;
case RS::LIGHT_SPOT: {
-
RENDER_TIMESTAMP("Culling Spot Light");
real_t radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE);
@@ -1814,7 +1722,6 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c
Plane near_plane(light_transform.origin, -light_transform.basis.get_axis(2));
for (int j = 0; j < cull_count; j++) {
-
Instance *instance = instance_shadow_cull_result[j];
if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
cull_count--;
@@ -1851,7 +1758,6 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
switch (camera->type) {
case Camera::ORTHOGONAL: {
-
camera_matrix.set_orthogonal(
camera->size,
p_viewport_size.width / (float)p_viewport_size.height,
@@ -1861,7 +1767,6 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
ortho = true;
} break;
case Camera::PERSPECTIVE: {
-
camera_matrix.set_perspective(
camera->fov,
p_viewport_size.width / (float)p_viewport_size.height,
@@ -1872,7 +1777,6 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
} break;
case Camera::FRUSTUM: {
-
camera_matrix.set_frustum(
camera->size,
p_viewport_size.width / (float)p_viewport_size.height,
@@ -2018,7 +1922,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
float lightmap_probe_update_speed = RSG::storage->lightmap_get_probe_capture_update_speed() * RSG::rasterizer->get_frame_delta_time();
for (int i = 0; i < instance_cull_count; i++) {
-
Instance *ins = instance_cull_result[i];
bool keep = false;
@@ -2026,9 +1929,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
if ((camera_layer_mask & ins->layer_mask) == 0) {
//failure
} else if (ins->base_type == RS::INSTANCE_LIGHT && ins->visible) {
-
if (light_cull_count < MAX_LIGHTS_CULLED) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
if (!light->geometries.empty()) {
@@ -2043,9 +1944,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
}
} else if (ins->base_type == RS::INSTANCE_REFLECTION_PROBE && ins->visible) {
-
if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);
if (p_reflection_probe != reflection_probe->instance) {
@@ -2071,9 +1970,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
}
} else if (ins->base_type == RS::INSTANCE_DECAL && ins->visible) {
-
if (decal_cull_count < MAX_DECALS_CULLED) {
-
InstanceDecalData *decal = static_cast<InstanceDecalData *>(ins->base_data);
if (!decal->geometries.empty()) {
@@ -2084,7 +1981,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
} else if (ins->base_type == RS::INSTANCE_GI_PROBE && ins->visible) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(ins->base_data);
if (!gi_probe->update_element.in_list()) {
gi_probe_update_list.add(&gi_probe->update_element);
@@ -2095,14 +1991,12 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
gi_probe_cull_count++;
}
} else if (ins->base_type == RS::INSTANCE_LIGHTMAP && ins->visible) {
-
if (lightmap_cull_count < MAX_LIGHTMAPS_CULLED) {
lightmap_cull_result[lightmap_cull_count] = ins;
lightmap_cull_count++;
}
} else if (((1 << ins->base_type) & RS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
-
keep = true;
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
@@ -2129,7 +2023,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
ins->light_instances.resize(geom->lighting.size());
for (List<Instance *>::Element *E = geom->lighting.front(); E; E = E->next()) {
-
InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
ins->light_instances.write[l++] = light->instance;
@@ -2144,7 +2037,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
ins->reflection_probe_instances.resize(geom->reflection_probes.size());
for (List<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->get()->base_data);
ins->reflection_probe_instances.write[l++] = reflection_probe->instance;
@@ -2159,7 +2051,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
ins->gi_probe_instances.resize(geom->gi_probes.size());
for (List<Instance *>::Element *E = geom->gi_probes.front(); E; E = E->next()) {
-
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(E->get()->base_data);
ins->gi_probe_instances.write[l++] = gi_probe->probe_instance;
@@ -2187,7 +2078,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
i--;
ins->last_render_pass = 0; // make invalid
} else {
-
ins->last_render_pass = render_pass;
}
ins->last_frame_pass = frame_number;
@@ -2200,18 +2090,17 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
// directional lights
{
-
Instance **lights_with_shadow = (Instance **)alloca(sizeof(Instance *) * scenario->directional_lights.size());
int directional_shadow_count = 0;
for (List<Instance *>::Element *E = scenario->directional_lights.front(); E; E = E->next()) {
-
if (light_cull_count + directional_light_count >= MAX_LIGHTS_CULLED) {
break;
}
- if (!E->get()->visible)
+ if (!E->get()->visible) {
continue;
+ }
InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data);
@@ -2229,7 +2118,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
RSG::scene_render->set_directional_shadow_count(directional_shadow_count);
for (int i = 0; i < directional_shadow_count; i++) {
-
RENDER_TIMESTAMP(">Rendering Directional Light " + itos(i));
_light_instance_update_shadow(lights_with_shadow[i], p_cam_transform, p_cam_projection, p_cam_orthogonal, p_cam_vaspect, p_shadow_atlas, scenario);
@@ -2243,11 +2131,11 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
//SortArray<Instance*,_InstanceLightsort> sorter;
//sorter.sort(light_cull_result,light_cull_count);
for (int i = 0; i < light_cull_count; i++) {
-
Instance *ins = light_cull_result[i];
- if (!p_shadow_atlas.is_valid() || !RSG::storage->light_has_shadow(ins->base))
+ if (!p_shadow_atlas.is_valid() || !RSG::storage->light_has_shadow(ins->base)) {
continue;
+ }
InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
@@ -2263,9 +2151,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
Vector2 vp_half_extents = p_cam_projection.get_viewport_half_extents();
switch (RSG::storage->light_get_type(ins->base)) {
-
case RS::LIGHT_OMNI: {
-
float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE);
//get two points parallel to near plane
@@ -2289,7 +2175,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
coverage = screen_diameter / (vp_half_extents.x + vp_half_extents.y);
} break;
case RS::LIGHT_SPOT: {
-
float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE);
float angle = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_SPOT_ANGLE);
@@ -2342,18 +2227,18 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
}
void RenderingServerScene::_render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
-
Scenario *scenario = scenario_owner.getornull(p_scenario);
/* ENVIRONMENT */
RID environment;
- if (p_force_environment.is_valid()) //camera has more environment priority
+ if (p_force_environment.is_valid()) { //camera has more environment priority
environment = p_force_environment;
- else if (scenario->environment.is_valid())
+ } else if (scenario->environment.is_valid()) {
environment = scenario->environment;
- else
+ } else {
environment = scenario->fallback_environment;
+ }
RID camera_effects;
if (p_force_camera_effects.is_valid()) {
@@ -2368,23 +2253,22 @@ void RenderingServerScene::_render_scene(RID p_render_buffers, const Transform p
}
void RenderingServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) {
-
#ifndef _3D_DISABLED
Scenario *scenario = scenario_owner.getornull(p_scenario);
RID environment;
- if (scenario->environment.is_valid())
+ if (scenario->environment.is_valid()) {
environment = scenario->environment;
- else
+ } else {
environment = scenario->fallback_environment;
+ }
RENDER_TIMESTAMP("Render Empty Scene ");
RSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, nullptr, 0, nullptr, 0, nullptr, 0, nullptr, 0, nullptr, 0, nullptr, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0);
#endif
}
bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) {
-
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
Scenario *scenario = p_instance->scenario;
ERR_FAIL_COND_V(!scenario, true);
@@ -2392,14 +2276,12 @@ bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, i
RenderingServerRaster::redraw_request(); //update, so it updates in editor
if (p_step == 0) {
-
if (!RSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) {
return true; //all full
}
}
if (p_step >= 0 && p_step < 6) {
-
static const Vector3 view_normals[6] = {
Vector3(+1, 0, 0),
Vector3(-1, 0, 0),
@@ -2439,7 +2321,6 @@ bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, i
bool use_shadows = RSG::storage->reflection_probe_renders_shadows(p_instance->base);
if (use_shadows) {
-
shadow_atlas = scenario->reflection_probe_shadow_atlas;
}
@@ -2457,7 +2338,6 @@ bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, i
}
void RenderingServerScene::render_probes() {
-
/* REFLECTION PROBES */
SelfList<InstanceReflectionProbeData> *ref_probe = reflection_probe_render_list.first();
@@ -2465,15 +2345,14 @@ void RenderingServerScene::render_probes() {
bool busy = false;
while (ref_probe) {
-
SelfList<InstanceReflectionProbeData> *next = ref_probe->next();
RID base = ref_probe->self()->owner->base;
switch (RSG::storage->reflection_probe_get_update_mode(base)) {
-
case RS::REFLECTION_PROBE_UPDATE_ONCE: {
- if (busy) //already rendering something
+ if (busy) { //already rendering something
break;
+ }
bool done = _render_reflection_probe_step(ref_probe->self()->owner, ref_probe->self()->render_step);
if (done) {
@@ -2485,7 +2364,6 @@ void RenderingServerScene::render_probes() {
busy = true; //do not render another one of this kind
} break;
case RS::REFLECTION_PROBE_UPDATE_ALWAYS: {
-
int step = 0;
bool done = false;
while (!done) {
@@ -2509,7 +2387,6 @@ void RenderingServerScene::render_probes() {
}
while (gi_probe) {
-
SelfList<InstanceGIProbeData> *next = gi_probe->next();
InstanceGIProbeData *probe = gi_probe->self();
@@ -2520,7 +2397,6 @@ void RenderingServerScene::render_probes() {
bool cache_dirty = false;
int cache_count = 0;
{
-
int light_cache_size = probe->light_cache.size();
const InstanceGIProbeData::LightCache *caches = probe->light_cache.ptr();
const RID *instance_caches = probe->light_instances.ptr();
@@ -2537,7 +2413,6 @@ void RenderingServerScene::render_probes() {
} else if (idx >= light_cache_size) {
cache_dirty = true;
} else {
-
const InstanceGIProbeData::LightCache *cache = &caches[idx];
if (
@@ -2560,7 +2435,6 @@ void RenderingServerScene::render_probes() {
}
for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) {
-
Instance *instance = E->get();
InstanceLightData *instance_light = (InstanceLightData *)instance->base_data;
if (!instance->visible) {
@@ -2571,7 +2445,6 @@ void RenderingServerScene::render_probes() {
} else if (idx >= light_cache_size) {
cache_dirty = true;
} else {
-
const InstanceGIProbeData::LightCache *cache = &caches[idx];
if (
@@ -2678,7 +2551,6 @@ void RenderingServerScene::render_probes() {
ins->gi_probe_instances.resize(geom->gi_probes.size());
for (List<Instance *>::Element *F = geom->gi_probes.front(); F; F = F->next()) {
-
InstanceGIProbeData *gi_probe2 = static_cast<InstanceGIProbeData *>(F->get()->base_data);
ins->gi_probe_instances.write[l++] = gi_probe2->probe_instance;
@@ -2700,7 +2572,6 @@ void RenderingServerScene::render_probes() {
}
void RenderingServerScene::_update_instance_shader_parameters_from_material(Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &isparams, const Map<StringName, RasterizerScene::InstanceBase::InstanceShaderParameter> &existing_isparams, RID p_material) {
-
List<RasterizerStorage::InstanceShaderParam> plist;
RSG::storage->material_get_instance_shader_parameters(p_material, &plist);
for (List<RasterizerStorage::InstanceShaderParam>::Element *E = plist.front(); E; E = E->next()) {
@@ -2729,13 +2600,11 @@ void RenderingServerScene::_update_instance_shader_parameters_from_material(Map<
}
void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
-
if (p_instance->update_aabb) {
_update_instance_aabb(p_instance);
}
if (p_instance->update_dependencies) {
-
p_instance->instance_increase_version();
if (p_instance->base.is_valid()) {
@@ -2762,7 +2631,6 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
}
if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) {
-
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
bool can_cast_shadows = true;
@@ -2780,7 +2648,6 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
is_animated = RSG::storage->material_is_animated(p_instance->material_override);
_update_instance_shader_parameters_from_material(isparams, p_instance->instance_shader_parameters, p_instance->material_override);
} else {
-
if (p_instance->base_type == RS::INSTANCE_MESH) {
RID mesh = p_instance->base;
@@ -2788,13 +2655,11 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
bool cast_shadows = false;
for (int i = 0; i < p_instance->materials.size(); i++) {
-
RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : RSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
-
if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
@@ -2817,19 +2682,16 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
} else if (p_instance->base_type == RS::INSTANCE_MULTIMESH) {
RID mesh = RSG::storage->multimesh_get_mesh(p_instance->base);
if (mesh.is_valid()) {
-
bool cast_shadows = false;
int sc = RSG::storage->mesh_get_surface_count(mesh);
for (int i = 0; i < sc; i++) {
-
RID mat = RSG::storage->mesh_surface_get_material(mesh, i);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
-
if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
@@ -2850,7 +2712,6 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
RSG::storage->base_update_dependency(mesh, p_instance);
}
} else if (p_instance->base_type == RS::INSTANCE_IMMEDIATE) {
-
RID mat = RSG::storage->immediate_get_material(p_instance->base);
if (!(!mat.is_valid() || RSG::storage->material_casts_shadows(mat))) {
@@ -2870,26 +2731,23 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
}
} else if (p_instance->base_type == RS::INSTANCE_PARTICLES) {
-
bool cast_shadows = false;
int dp = RSG::storage->particles_get_draw_passes(p_instance->base);
for (int i = 0; i < dp; i++) {
-
RID mesh = RSG::storage->particles_get_draw_pass_mesh(p_instance->base, i);
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
continue;
+ }
int sc = RSG::storage->mesh_get_surface_count(mesh);
for (int j = 0; j < sc; j++) {
-
RID mat = RSG::storage->mesh_surface_get_material(mesh, j);
if (!mat.is_valid()) {
cast_shadows = true;
} else {
-
if (RSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
@@ -2956,26 +2814,21 @@ void RenderingServerScene::_update_dirty_instance(Instance *p_instance) {
}
void RenderingServerScene::update_dirty_instances() {
-
RSG::storage->update_dirty_resources();
while (_instance_update_list.first()) {
-
_update_dirty_instance(_instance_update_list.first()->self());
}
}
bool RenderingServerScene::free(RID p_rid) {
-
if (camera_owner.owns(p_rid)) {
-
Camera *camera = camera_owner.getornull(p_rid);
camera_owner.free(p_rid);
memdelete(camera);
} else if (scenario_owner.owns(p_rid)) {
-
Scenario *scenario = scenario_owner.getornull(p_rid);
while (scenario->instances.first()) {
@@ -3021,7 +2874,6 @@ TypedArray<Image> RenderingServerScene::bake_render_uv2(RID p_base, const Vector
RenderingServerScene *RenderingServerScene::singleton = nullptr;
RenderingServerScene::RenderingServerScene() {
-
render_pass = 1;
singleton = this;
}
diff --git a/servers/rendering/rendering_server_scene.h b/servers/rendering/rendering_server_scene.h
index df9e650ac7..f2e2918f21 100644
--- a/servers/rendering/rendering_server_scene.h
+++ b/servers/rendering/rendering_server_scene.h
@@ -33,7 +33,6 @@
#include "servers/rendering/rasterizer.h"
-#include "core/math/geometry.h"
#include "core/math/octree.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
@@ -62,7 +61,6 @@ public:
/* CAMERA API */
struct Camera {
-
enum Type {
PERSPECTIVE,
ORTHOGONAL,
@@ -81,7 +79,6 @@ public:
Transform transform;
Camera() {
-
visible_layers = 0xFFFFFFFF;
fov = 75;
type = PERSPECTIVE;
@@ -110,7 +107,6 @@ public:
struct Instance;
struct Scenario {
-
RS::ScenarioDebugMode debug;
RID self;
@@ -144,12 +140,10 @@ public:
/* INSTANCING API */
struct InstanceBaseData {
-
virtual ~InstanceBaseData() {}
};
struct Instance : RasterizerScene::InstanceBase {
-
RID self;
//scenario stuff
OctreeElementID octree_id;
@@ -198,7 +192,6 @@ public:
Instance() :
scenario_item(this),
update_item(this) {
-
octree_id = 0;
scenario = nullptr;
@@ -223,11 +216,12 @@ public:
}
~Instance() {
-
- if (base_data)
+ if (base_data) {
memdelete(base_data);
- if (custom_aabb)
+ }
+ if (custom_aabb) {
memdelete(custom_aabb);
+ }
}
};
@@ -235,7 +229,6 @@ public:
void _instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies = false);
struct InstanceGeometryData : public InstanceBaseData {
-
List<Instance *> lighting;
bool lighting_dirty;
bool can_cast_shadows;
@@ -253,7 +246,6 @@ public:
List<Instance *> lightmap_captures;
InstanceGeometryData() {
-
lighting_dirty = false;
reflection_dirty = true;
can_cast_shadows = true;
@@ -264,7 +256,6 @@ public:
};
struct InstanceReflectionProbeData : public InstanceBaseData {
-
Instance *owner;
struct PairInfo {
@@ -281,14 +272,12 @@ public:
InstanceReflectionProbeData() :
update_list(this) {
-
reflection_dirty = true;
render_step = -1;
}
};
struct InstanceDecalData : public InstanceBaseData {
-
Instance *owner;
RID instance;
@@ -305,7 +294,6 @@ public:
SelfList<InstanceReflectionProbeData>::List reflection_probe_render_list;
struct InstanceLightData : public InstanceBaseData {
-
struct PairInfo {
List<Instance *>::Element *L; //light iterator in geometry
Instance *geometry;
@@ -322,7 +310,6 @@ public:
Instance *baked_light;
InstanceLightData() {
-
shadow_dirty = true;
D = nullptr;
last_version = 0;
@@ -331,7 +318,6 @@ public:
};
struct InstanceGIProbeData : public InstanceBaseData {
-
Instance *owner;
struct PairInfo {
@@ -345,7 +331,6 @@ public:
Set<Instance *> lights;
struct LightCache {
-
RS::LightType type;
Transform transform;
Color color;
@@ -378,7 +363,6 @@ public:
SelfList<InstanceGIProbeData>::List gi_probe_update_list;
struct InstanceLightmapData : public InstanceBaseData {
-
struct PairInfo {
List<Instance *>::Element *L; //iterator in geometry
Instance *geometry;
diff --git a/servers/rendering/rendering_server_viewport.cpp b/servers/rendering/rendering_server_viewport.cpp
index 6fb8f6ca63..48be6ca13b 100644
--- a/servers/rendering/rendering_server_viewport.cpp
+++ b/servers/rendering/rendering_server_viewport.cpp
@@ -36,7 +36,6 @@
#include "rendering_server_scene.h"
static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_viewport, RenderingServerCanvas::Canvas *p_canvas, RenderingServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) {
-
Transform2D xf = p_viewport->global_transform;
float scale = 1.0;
@@ -63,7 +62,6 @@ static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_vi
}
void RenderingServerViewport::_draw_3d(Viewport *p_viewport, XRInterface::Eyes p_eye) {
-
RENDER_TIMESTAMP(">Begin Rendering 3D Scene");
Ref<XRInterface> xr_interface;
@@ -80,7 +78,6 @@ void RenderingServerViewport::_draw_3d(Viewport *p_viewport, XRInterface::Eyes p
}
void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::Eyes p_eye) {
-
if (p_viewport->measure_render_time) {
String rt_id = "vp_begin_" + itos(p_viewport->self.get_id());
RSG::storage->capture_timestamp(rt_id);
@@ -95,7 +92,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
Color bgcolor = RSG::storage->get_default_clear_color();
if (!p_viewport->hide_canvas && !p_viewport->disable_environment && RSG::scene->scenario_owner.owns(p_viewport->scenario)) {
-
RenderingServerScene::Scenario *scenario = RSG::scene->scenario_owner.getornull(p_viewport->scenario);
ERR_FAIL_COND(!scenario);
if (RSG::scene_render->is_environment(scenario->environment)) {
@@ -143,7 +139,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
RENDER_TIMESTAMP("Cull Canvas Lights");
for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
-
RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
@@ -151,7 +146,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
//find lights in canvas
for (Set<RasterizerCanvas::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) {
-
RasterizerCanvas::Light *cl = F->get();
if (cl->enabled && cl->texture.is_valid()) {
//not super efficient..
@@ -163,7 +157,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
cl->xform_cache = xf * cl->xform;
if (clip_rect.intersects_transformed(cl->xform_cache, cl->rect_cache)) {
-
cl->filter_next_ptr = lights;
lights = cl;
// cl->texture_cache = nullptr;
@@ -173,7 +166,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
cl->light_shader_xform = cl->xform * scale;
//cl->light_shader_pos = cl->xform_cache[2];
if (cl->use_shadow) {
-
cl->shadows_next_ptr = lights_with_shadow;
if (lights_with_shadow == nullptr) {
shadow_rect = cl->xform_cache.xform(cl->rect_cache);
@@ -209,17 +201,15 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
//make list of occluders
for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
-
RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas);
Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size);
for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
-
- if (!F->get()->enabled)
+ if (!F->get()->enabled) {
continue;
+ }
F->get()->xform_cache = xf * F->get()->xform;
if (shadow_rect.intersects_transformed(F->get()->xform_cache, F->get()->aabb_cache)) {
-
F->get()->next = occluders;
occluders = F->get();
}
@@ -229,7 +219,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
RasterizerCanvas::Light *light = lights_with_shadow;
while (light) {
-
RENDER_TIMESTAMP("Render Shadow");
RSG::canvas_render->light_update_shadow(light->light_internal, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders);
@@ -250,7 +239,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
}
for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) {
-
RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get()->canvas);
Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size);
@@ -304,7 +292,6 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::
}
void RenderingServerViewport::draw_viewports() {
-
timestamp_vp_map.clear();
// get our xr interface in case we need it
@@ -335,8 +322,9 @@ void RenderingServerViewport::draw_viewports() {
Viewport *vp = active_viewports[i];
- if (vp->update_mode == RS::VIEWPORT_UPDATE_DISABLED)
+ if (vp->update_mode == RS::VIEWPORT_UPDATE_DISABLED) {
continue;
+ }
if (!vp->render_target.is_valid()) {
continue;
@@ -368,7 +356,6 @@ void RenderingServerViewport::draw_viewports() {
}
for (int i = 0; i < active_viewports.size(); i++) {
-
Viewport *vp = active_viewports[i];
if (vp->last_pass != draw_viewports_pass) {
@@ -470,7 +457,6 @@ void RenderingServerViewport::draw_viewports() {
}
RID RenderingServerViewport::viewport_create() {
-
Viewport *viewport = memnew(Viewport);
RID rid = viewport_owner.make_rid(viewport);
@@ -493,7 +479,6 @@ void RenderingServerViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr)
}
void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
-
ERR_FAIL_COND(p_width < 0 && p_height < 0);
Viewport *viewport = viewport_owner.getornull(p_viewport);
@@ -512,7 +497,6 @@ void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int
}
void RenderingServerViewport::viewport_set_active(RID p_viewport, bool p_active) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -525,7 +509,6 @@ void RenderingServerViewport::viewport_set_active(RID p_viewport, bool p_active)
}
void RenderingServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -533,7 +516,6 @@ void RenderingServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p
}
void RenderingServerViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -541,7 +523,6 @@ void RenderingServerViewport::viewport_set_clear_mode(RID p_viewport, RS::Viewpo
}
void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -549,7 +530,6 @@ void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Re
// If using GLES2 we can optimize this operation by rendering directly to system_fbo
// instead of rendering to fbo and copying to system_fbo after
if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
-
RSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y);
RSG::storage->render_target_set_position(viewport->render_target, p_rect.position.x, p_rect.position.y);
}
@@ -557,10 +537,8 @@ void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Re
viewport->viewport_to_screen_rect = p_rect;
viewport->viewport_to_screen = p_screen;
} else {
-
// if render_direct_to_screen was used, reset size and position
if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
-
RSG::storage->render_target_set_position(viewport->render_target, 0, 0);
RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y);
}
@@ -574,12 +552,12 @@ void RenderingServerViewport::viewport_set_render_direct_to_screen(RID p_viewpor
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
- if (p_enable == viewport->viewport_render_direct_to_screen)
+ if (p_enable == viewport->viewport_render_direct_to_screen) {
return;
+ }
// if disabled, reset render_target size and position
if (!p_enable) {
-
RSG::storage->render_target_set_position(viewport->render_target, 0, 0);
RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y);
}
@@ -589,14 +567,12 @@ void RenderingServerViewport::viewport_set_render_direct_to_screen(RID p_viewpor
// if attached to screen already, setup screen size and position, this needs to happen after setting flag to avoid an unnecessary buffer allocation
if (RSG::rasterizer->is_low_end() && viewport->viewport_to_screen_rect != Rect2() && p_enable) {
-
RSG::storage->render_target_set_size(viewport->render_target, viewport->viewport_to_screen_rect.size.x, viewport->viewport_to_screen_rect.size.y);
RSG::storage->render_target_set_position(viewport->render_target, viewport->viewport_to_screen_rect.position.x, viewport->viewport_to_screen_rect.position.y);
}
}
void RenderingServerViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -604,7 +580,6 @@ void RenderingServerViewport::viewport_set_update_mode(RID p_viewport, RS::Viewp
}
RID RenderingServerViewport::viewport_get_texture(RID p_viewport) const {
-
const Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND_V(!viewport, RID());
@@ -612,21 +587,20 @@ RID RenderingServerViewport::viewport_get_texture(RID p_viewport) const {
}
void RenderingServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->hide_scenario = p_hide;
}
-void RenderingServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) {
+void RenderingServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->hide_canvas = p_hide;
}
-void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
+void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -634,21 +608,20 @@ void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, b
}
void RenderingServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->camera = p_camera;
}
-void RenderingServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
+void RenderingServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->scenario = p_scenario;
}
-void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
+void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -664,7 +637,6 @@ void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canva
}
void RenderingServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -674,16 +646,16 @@ void RenderingServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canva
viewport->canvas_map.erase(p_canvas);
canvas->viewports.erase(p_viewport);
}
-void RenderingServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
+void RenderingServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
viewport->canvas_map[p_canvas].transform = p_offset;
}
-void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
+void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -692,14 +664,13 @@ void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport
}
void RenderingServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
viewport->global_transform = p_transform;
}
-void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
+void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) {
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -709,7 +680,6 @@ void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p
}
void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -719,7 +689,6 @@ void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int
}
void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -727,7 +696,6 @@ void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID
}
void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -754,18 +722,17 @@ void RenderingServerViewport::viewport_set_screen_space_aa(RID p_viewport, RS::V
}
int RenderingServerViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfo p_info) {
-
ERR_FAIL_INDEX_V(p_info, RS::VIEWPORT_RENDER_INFO_MAX, -1);
Viewport *viewport = viewport_owner.getornull(p_viewport);
- if (!viewport)
+ if (!viewport) {
return 0; //there should be a lock here..
+ }
return viewport->render_info[p_info];
}
void RenderingServerViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -773,7 +740,6 @@ void RenderingServerViewport::viewport_set_debug_draw(RID p_viewport, RS::Viewpo
}
void RenderingServerViewport::viewport_set_measure_render_time(RID p_viewport, bool p_enable) {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND(!viewport);
@@ -781,7 +747,6 @@ void RenderingServerViewport::viewport_set_measure_render_time(RID p_viewport, b
}
float RenderingServerViewport::viewport_get_measured_render_time_cpu(RID p_viewport) const {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND_V(!viewport, 0);
@@ -789,7 +754,6 @@ float RenderingServerViewport::viewport_get_measured_render_time_cpu(RID p_viewp
}
float RenderingServerViewport::viewport_get_measured_render_time_gpu(RID p_viewport) const {
-
Viewport *viewport = viewport_owner.getornull(p_viewport);
ERR_FAIL_COND_V(!viewport, 0);
@@ -797,9 +761,7 @@ float RenderingServerViewport::viewport_get_measured_render_time_gpu(RID p_viewp
}
bool RenderingServerViewport::free(RID p_rid) {
-
if (viewport_owner.owns(p_rid)) {
-
Viewport *viewport = viewport_owner.getornull(p_rid);
RSG::storage->free(viewport->render_target);
@@ -825,7 +787,6 @@ bool RenderingServerViewport::free(RID p_rid) {
}
void RenderingServerViewport::handle_timestamp(String p_timestamp, uint64_t p_cpu_time, uint64_t p_gpu_time) {
-
RID *vp = timestamp_vp_map.getptr(p_timestamp);
if (!vp) {
return;
diff --git a/servers/rendering/rendering_server_viewport.h b/servers/rendering/rendering_server_viewport.h
index fcba7886c5..0b90646e4f 100644
--- a/servers/rendering/rendering_server_viewport.h
+++ b/servers/rendering/rendering_server_viewport.h
@@ -43,7 +43,6 @@ public:
};
struct Viewport {
-
RID self;
RID parent;
@@ -89,12 +88,12 @@ public:
bool transparent_bg;
struct CanvasKey {
-
int64_t stacking;
RID canvas;
bool operator<(const CanvasKey &p_canvas) const {
- if (stacking == p_canvas.stacking)
+ if (stacking == p_canvas.stacking) {
return canvas < p_canvas.canvas;
+ }
return stacking < p_canvas.stacking;
}
CanvasKey() {
@@ -109,7 +108,6 @@ public:
};
struct CanvasData {
-
CanvasBase *canvas;
Transform2D transform;
int layer;
@@ -154,12 +152,10 @@ public:
struct ViewportSort {
_FORCE_INLINE_ bool operator()(const Viewport *p_left, const Viewport *p_right) const {
-
bool left_to_screen = p_left->viewport_to_screen_rect.size != Size2();
bool right_to_screen = p_right->viewport_to_screen_rect.size != Size2();
if (left_to_screen == right_to_screen) {
-
return p_right->parent == p_left->self;
}
return (right_to_screen ? 0 : 1) < (left_to_screen ? 0 : 1);
diff --git a/servers/rendering/rendering_server_wrap_mt.cpp b/servers/rendering/rendering_server_wrap_mt.cpp
index a7a166bec6..9aa6593cbe 100644
--- a/servers/rendering/rendering_server_wrap_mt.cpp
+++ b/servers/rendering/rendering_server_wrap_mt.cpp
@@ -34,32 +34,26 @@
#include "servers/display_server.h"
void RenderingServerWrapMT::thread_exit() {
-
exit = true;
}
void RenderingServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) {
-
if (!atomic_decrement(&draw_pending)) {
-
rendering_server->draw(p_swap_buffers, frame_step);
}
}
void RenderingServerWrapMT::thread_flush() {
-
atomic_decrement(&draw_pending);
}
void RenderingServerWrapMT::_thread_callback(void *_instance) {
-
RenderingServerWrapMT *vsmt = reinterpret_cast<RenderingServerWrapMT *>(_instance);
vsmt->thread_loop();
}
void RenderingServerWrapMT::thread_loop() {
-
server_thread = Thread::get_caller_id();
DisplayServer::get_singleton()->make_rendering_thread();
@@ -81,33 +75,25 @@ void RenderingServerWrapMT::thread_loop() {
/* EVENT QUEUING */
void RenderingServerWrapMT::sync() {
-
if (create_thread) {
-
atomic_increment(&draw_pending);
command_queue.push_and_sync(this, &RenderingServerWrapMT::thread_flush);
} else {
-
command_queue.flush_all(); //flush all pending from other threads
}
}
void RenderingServerWrapMT::draw(bool p_swap_buffers, double frame_step) {
-
if (create_thread) {
-
atomic_increment(&draw_pending);
command_queue.push(this, &RenderingServerWrapMT::thread_draw, p_swap_buffers, frame_step);
} else {
-
rendering_server->draw(p_swap_buffers, frame_step);
}
}
void RenderingServerWrapMT::init() {
-
if (create_thread) {
-
print_verbose("RenderingServerWrapMT: Creating render thread");
DisplayServer::get_singleton()->release_rendering_thread();
if (create_thread) {
@@ -119,13 +105,11 @@ void RenderingServerWrapMT::init() {
}
print_verbose("RenderingServerWrapMT: Finished render thread");
} else {
-
rendering_server->init();
}
}
void RenderingServerWrapMT::finish() {
-
sky_free_cached_ids();
shader_free_cached_ids();
material_free_cached_ids();
@@ -152,7 +136,6 @@ void RenderingServerWrapMT::finish() {
canvas_occluder_polygon_free_cached_ids();
if (thread) {
-
command_queue.push(this, &RenderingServerWrapMT::thread_exit);
Thread::wait_to_finish(thread);
memdelete(thread);
@@ -164,7 +147,6 @@ void RenderingServerWrapMT::finish() {
}
void RenderingServerWrapMT::set_use_vsync_callback(bool p_enable) {
-
singleton_mt->call_set_use_vsync(p_enable);
}
@@ -172,7 +154,6 @@ RenderingServerWrapMT *RenderingServerWrapMT::singleton_mt = nullptr;
RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread) :
command_queue(p_create_thread) {
-
singleton_mt = this;
DisplayServer::switch_vsync_function = set_use_vsync_callback; //as this goes to another thread, make sure it goes properly
@@ -191,7 +172,6 @@ RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool
}
RenderingServerWrapMT::~RenderingServerWrapMT() {
-
memdelete(rendering_server);
//finish();
}
diff --git a/servers/rendering/rendering_server_wrap_mt.h b/servers/rendering/rendering_server_wrap_mt.h
index 6580b71508..a746aa52b2 100644
--- a/servers/rendering/rendering_server_wrap_mt.h
+++ b/servers/rendering/rendering_server_wrap_mt.h
@@ -36,7 +36,6 @@
#include "servers/rendering_server.h"
class RenderingServerWrapMT : public RenderingServer {
-
// the real visual server
mutable RenderingServer *rendering_server;
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index e3725043d9..2ec65b7ea8 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -34,22 +34,18 @@
#include "servers/rendering_server.h"
static bool _is_text_char(CharType c) {
-
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
static bool _is_number(CharType c) {
-
return (c >= '0' && c <= '9');
}
static bool _is_hex(CharType c) {
-
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
String ShaderLanguage::get_operator_text(Operator p_op) {
-
static const char *op_names[OP_MAX] = { "==",
"!=",
"<",
@@ -226,7 +222,6 @@ const char *ShaderLanguage::token_names[TK_MAX] = {
};
String ShaderLanguage::get_token_text(Token p_token) {
-
String name = token_names[p_token.type];
if (p_token.type == TK_INT_CONSTANT || p_token.type == TK_REAL_CONSTANT) {
name += "(" + rtos(p_token.constant) + ")";
@@ -240,7 +235,6 @@ String ShaderLanguage::get_token_text(Token p_token) {
}
ShaderLanguage::Token ShaderLanguage::_make_token(TokenType p_type, const StringName &p_text) {
-
Token tk;
tk.type = p_type;
tk.text = p_text;
@@ -340,13 +334,11 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = {
};
ShaderLanguage::Token ShaderLanguage::_get_token() {
-
#define GETCHAR(m_idx) (((char_idx + m_idx) < code.length()) ? code[char_idx + m_idx] : CharType(0))
while (true) {
char_idx++;
switch (GETCHAR(-1)) {
-
case 0:
return _make_token(TK_EOF);
case 0xFFFF:
@@ -359,7 +351,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
tk_line++;
continue;
case '/': {
-
switch (GETCHAR(0)) {
case '*': { // block comment
@@ -407,7 +398,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
continue; //a comment, continue to next token
} break;
case '=': {
-
if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_EQUAL);
@@ -496,7 +486,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_OP_BIT_AND);
} break;
case '|': {
-
if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_BIT_OR);
@@ -508,7 +497,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} break;
case '*': {
-
if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_MUL);
@@ -516,12 +504,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_OP_MUL);
} break;
case '+': {
-
if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_ADD);
} else if (GETCHAR(0) == '+') {
-
char_idx++;
return _make_token(TK_OP_INCREMENT);
}
@@ -529,12 +515,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_OP_ADD);
} break;
case '-': {
-
if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_SUB);
} else if (GETCHAR(0) == '-') {
-
char_idx++;
return _make_token(TK_OP_DECREMENT);
}
@@ -542,7 +526,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_OP_SUB);
} break;
case '%': {
-
if (GETCHAR(0) == '=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_MOD);
@@ -551,7 +534,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_OP_MOD);
} break;
default: {
-
char_idx--; //go back one, since we have no idea what this is
if (_is_number(GETCHAR(0)) || (GETCHAR(0) == '.' && _is_number(GETCHAR(1)))) {
@@ -567,32 +549,38 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
while (true) {
if (GETCHAR(i) == '.') {
- if (period_found || exponent_found || hexa_found || float_suffix_found)
+ if (period_found || exponent_found || hexa_found || float_suffix_found) {
return _make_token(TK_ERROR, "Invalid numeric constant");
+ }
period_found = true;
} else if (GETCHAR(i) == 'x') {
- if (hexa_found || str.length() != 1 || str[0] != '0')
+ if (hexa_found || str.length() != 1 || str[0] != '0') {
return _make_token(TK_ERROR, "Invalid numeric constant");
+ }
hexa_found = true;
} else if (GETCHAR(i) == 'e') {
- if (hexa_found || exponent_found || float_suffix_found)
+ if (hexa_found || exponent_found || float_suffix_found) {
return _make_token(TK_ERROR, "Invalid numeric constant");
+ }
exponent_found = true;
} else if (GETCHAR(i) == 'f') {
- if (hexa_found || exponent_found)
+ if (hexa_found || exponent_found) {
return _make_token(TK_ERROR, "Invalid numeric constant");
+ }
float_suffix_found = true;
} else if (_is_number(GETCHAR(i))) {
- if (float_suffix_found)
+ if (float_suffix_found) {
return _make_token(TK_ERROR, "Invalid numeric constant");
+ }
} else if (hexa_found && _is_hex(GETCHAR(i))) {
-
} else if ((GETCHAR(i) == '-' || GETCHAR(i) == '+') && exponent_found) {
- if (sign_found)
+ if (sign_found) {
return _make_token(TK_ERROR, "Invalid numeric constant");
+ }
sign_found = true;
- } else
+ } else {
break;
+ }
str += CharType(GETCHAR(i));
i++;
@@ -648,10 +636,11 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
char_idx += str.length();
Token tk;
- if (period_found || exponent_found || float_suffix_found)
+ if (period_found || exponent_found || float_suffix_found) {
tk.type = TK_REAL_CONSTANT;
- else
+ } else {
tk.type = TK_INT_CONSTANT;
+ }
if (hexa_found) {
tk.constant = (double)str.hex_to_int64(true);
@@ -674,7 +663,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
String str;
while (_is_text_char(GETCHAR(0))) {
-
str += CharType(GETCHAR(0));
char_idx++;
}
@@ -684,9 +672,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
int idx = 0;
while (keyword_list[idx].text) {
-
if (str == keyword_list[idx].text) {
-
return _make_token(keyword_list[idx].token);
}
idx++;
@@ -697,10 +683,11 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_IDENTIFIER, str);
}
- if (GETCHAR(0) > 32)
+ if (GETCHAR(0) > 32) {
return _make_token(TK_ERROR, "Tokenizer: Unknown character #" + itos(GETCHAR(0)) + ": '" + String::chr(GETCHAR(0)) + "'");
- else
+ } else {
return _make_token(TK_ERROR, "Tokenizer: Unknown character #" + itos(GETCHAR(0)));
+ }
} break;
}
@@ -712,7 +699,6 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
}
String ShaderLanguage::token_debug(const String &p_code) {
-
clear();
code = p_code;
@@ -721,7 +707,6 @@ String ShaderLanguage::token_debug(const String &p_code) {
Token tk = _get_token();
while (tk.type != TK_EOF && tk.type != TK_ERROR) {
-
output += itos(tk_line) + ": " + get_token_text(tk) + "\n";
tk = _get_token();
}
@@ -754,7 +739,6 @@ bool ShaderLanguage::is_token_variable_datatype(TokenType p_type) {
}
bool ShaderLanguage::is_token_datatype(TokenType p_type) {
-
return (
p_type == TK_TYPE_VOID ||
p_type == TK_TYPE_BOOL ||
@@ -790,27 +774,24 @@ bool ShaderLanguage::is_token_datatype(TokenType p_type) {
}
ShaderLanguage::DataType ShaderLanguage::get_token_datatype(TokenType p_type) {
-
return DataType(p_type - TK_TYPE_VOID);
}
bool ShaderLanguage::is_token_interpolation(TokenType p_type) {
-
return (
p_type == TK_INTERPOLATION_FLAT ||
p_type == TK_INTERPOLATION_SMOOTH);
}
ShaderLanguage::DataInterpolation ShaderLanguage::get_token_interpolation(TokenType p_type) {
-
- if (p_type == TK_INTERPOLATION_FLAT)
+ if (p_type == TK_INTERPOLATION_FLAT) {
return INTERPOLATION_FLAT;
- else
+ } else {
return INTERPOLATION_SMOOTH;
+ }
}
bool ShaderLanguage::is_token_precision(TokenType p_type) {
-
return (
p_type == TK_PRECISION_LOW ||
p_type == TK_PRECISION_MID ||
@@ -818,13 +799,13 @@ bool ShaderLanguage::is_token_precision(TokenType p_type) {
}
ShaderLanguage::DataPrecision ShaderLanguage::get_token_precision(TokenType p_type) {
-
- if (p_type == TK_PRECISION_LOW)
+ if (p_type == TK_PRECISION_LOW) {
return PRECISION_LOWP;
- else if (p_type == TK_PRECISION_HIGH)
+ } else if (p_type == TK_PRECISION_HIGH) {
return PRECISION_HIGHP;
- else
+ } else {
return PRECISION_MEDIUMP;
+ }
}
String ShaderLanguage::get_precision_name(DataPrecision p_type) {
@@ -842,9 +823,7 @@ String ShaderLanguage::get_precision_name(DataPrecision p_type) {
}
String ShaderLanguage::get_datatype_name(DataType p_type) {
-
switch (p_type) {
-
case TYPE_VOID:
return "void";
case TYPE_BOOL:
@@ -917,12 +896,10 @@ String ShaderLanguage::get_datatype_name(DataType p_type) {
}
bool ShaderLanguage::is_token_nonvoid_datatype(TokenType p_type) {
-
return is_token_datatype(p_type) && p_type != TK_TYPE_VOID;
}
void ShaderLanguage::clear() {
-
current_function = StringName();
completion_type = COMPLETION_NONE;
@@ -944,9 +921,7 @@ void ShaderLanguage::clear() {
}
bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_reassign, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type, IdentifierType *r_type, bool *r_is_const, int *r_array_size, StringName *r_struct_name) {
-
if (p_builtin_types.has(p_identifier)) {
-
if (r_data_type) {
*r_data_type = p_builtin_types[p_identifier].type;
}
@@ -963,7 +938,6 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
FunctionNode *function = nullptr;
while (p_block) {
-
if (p_block->variables.has(p_identifier)) {
if (r_data_type) {
*r_data_type = p_block->variables[p_identifier].type;
@@ -1050,9 +1024,9 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
}
for (int i = 0; i < shader->functions.size(); i++) {
-
- if (!shader->functions[i].callable)
+ if (!shader->functions[i].callable) {
continue;
+ }
if (shader->functions[i].name == p_identifier) {
if (r_data_type) {
@@ -1069,7 +1043,6 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea
}
bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type) {
-
bool valid = false;
DataType ret_type = TYPE_VOID;
@@ -1102,7 +1075,6 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
} break;
case OP_NOT: {
-
DataType na = p_op->arguments[0]->get_datatype();
valid = na == TYPE_BOOL;
ret_type = TYPE_BOOL;
@@ -1241,7 +1213,6 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
case OP_ASSIGN_SHIFT_RIGHT:
case OP_SHIFT_LEFT:
case OP_SHIFT_RIGHT: {
-
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
@@ -1303,7 +1274,6 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
case OP_ASSIGN_SUB:
case OP_ASSIGN_MUL:
case OP_ASSIGN_DIV: {
-
DataType na = p_op->arguments[0]->get_datatype();
DataType nb = p_op->arguments[1]->get_datatype();
@@ -1363,7 +1333,6 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
case OP_BIT_AND:
case OP_BIT_OR:
case OP_BIT_XOR: {
-
/*
* The bitwise operators and (&), exclusive-or (^), and inclusive-or (|). The operands must be of type
* signed or unsigned integers or integer vectors. The operands cannot be vectors of differing size. If
@@ -1443,8 +1412,9 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type
}
}
- if (r_ret_type)
+ if (r_ret_type) {
*r_ret_type = ret_type;
+ }
return valid;
}
@@ -2170,7 +2140,6 @@ const ShaderLanguage::BuiltinFuncOutArgs ShaderLanguage::builtin_func_out_args[]
};
bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str) {
-
ERR_FAIL_COND_V(p_func->op != OP_CALL && p_func->op != OP_CONSTRUCT, false);
Vector<DataType> args;
@@ -2196,18 +2165,15 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
int idx = 0;
while (builtin_func_defs[idx].name) {
-
if (completion_class != builtin_func_defs[idx].tag) {
idx++;
continue;
}
if (name == builtin_func_defs[idx].name) {
-
failed_builtin = true;
bool fail = false;
for (int i = 0; i < argcount; i++) {
-
if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) {
//all good, but needs implicit conversion later
} else if (args[i] != builtin_func_defs[idx].args[i]) {
@@ -2226,20 +2192,18 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
}
}
- if (!fail && argcount < 4 && builtin_func_defs[idx].args[argcount] != TYPE_VOID)
+ if (!fail && argcount < 4 && builtin_func_defs[idx].args[argcount] != TYPE_VOID) {
fail = true; //make sure the number of arguments matches
+ }
if (!fail) {
-
//make sure its not an out argument used in the wrong way
int outarg_idx = 0;
while (builtin_func_out_args[outarg_idx].name) {
-
if (String(name) == builtin_func_out_args[outarg_idx].name) {
int arg_idx = builtin_func_out_args[outarg_idx].argument;
if (arg_idx < argcount) {
-
if (p_func->arguments[arg_idx + 1]->type != Node::TYPE_VARIABLE && p_func->arguments[arg_idx + 1]->type != Node::TYPE_MEMBER && p_func->arguments[arg_idx + 1]->type != Node::TYPE_ARRAY) {
_set_error("Argument " + itos(arg_idx + 1) + " of function '" + String(name) + "' is not a variable, array or member.");
return false;
@@ -2327,7 +2291,6 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
}
//implicitly convert values if possible
for (int i = 0; i < argcount; i++) {
-
if (get_scalar_type(args[i]) != args[i] || args[i] == builtin_func_defs[idx].args[i] || p_func->arguments[i + 1]->type != Node::TYPE_CONSTANT) {
//can't do implicit conversion here
continue;
@@ -2344,8 +2307,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
p_func->arguments.write[i + 1] = conversion;
}
- if (r_ret_type)
+ if (r_ret_type) {
*r_ret_type = builtin_func_defs[idx].rettype;
+ }
return true;
}
@@ -2356,7 +2320,6 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
}
if (unsupported_builtin) {
-
String arglist = "";
for (int i = 0; i < argcount; i++) {
if (i > 0) {
@@ -2373,8 +2336,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
if (failed_builtin) {
String err = "Invalid arguments for built-in function: " + String(name) + "(";
for (int i = 0; i < argcount; i++) {
- if (i > 0)
+ if (i > 0) {
err += ",";
+ }
if (p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && p_func->arguments[i + 1]->get_datatype() == TYPE_INT && static_cast<ConstantNode *>(p_func->arguments[i + 1])->values[0].sint < 0) {
err += "-";
@@ -2392,7 +2356,6 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
BlockNode *block = p_block;
while (block) {
-
if (block->parent_function) {
exclude_function = block->parent_function->name;
}
@@ -2405,9 +2368,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
}
for (int i = 0; i < shader->functions.size(); i++) {
-
- if (name != shader->functions[i].name)
+ if (name != shader->functions[i].name) {
continue;
+ }
if (!shader->functions[i].callable) {
_set_error("Function '" + String(name) + " can't be called from source code.");
@@ -2416,8 +2379,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
FunctionNode *pfunc = shader->functions[i].function;
- if (pfunc->arguments.size() != args.size())
+ if (pfunc->arguments.size() != args.size()) {
continue;
+ }
bool fail = false;
@@ -2435,10 +2399,8 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin
}
if (!fail) {
-
//implicitly convert values if possible
for (int k = 0; k < args.size(); k++) {
-
if (get_scalar_type(args[k]) != args[k] || args[k] == pfunc->arguments[k].type || p_func->arguments[k + 1]->type != Node::TYPE_CONSTANT) {
//can't do implicit conversion here
continue;
@@ -2482,7 +2444,6 @@ bool ShaderLanguage::_compare_datatypes_in_nodes(Node *a, Node *b) const {
}
bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg) {
-
TkPos pos = _get_tkpos();
Token tk = _get_token();
@@ -2493,16 +2454,13 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Map<Str
_set_tkpos(pos);
while (true) {
-
if (r_complete_arg) {
pos = _get_tkpos();
tk = _get_token();
if (tk.type == TK_CURSOR) {
-
*r_complete_arg = p_func->arguments.size() - 1;
} else {
-
_set_tkpos(pos);
}
}
@@ -2510,7 +2468,6 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Map<Str
Node *arg = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!arg) {
-
return false;
}
@@ -2519,7 +2476,6 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Map<Str
tk = _get_token();
if (tk.type == TK_PARENTHESIS_CLOSE) {
-
return true;
} else if (tk.type != TK_COMMA) {
// something is broken
@@ -2532,7 +2488,6 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Map<Str
}
bool ShaderLanguage::is_token_operator(TokenType p_type) {
-
return (p_type == TK_OP_EQUAL ||
p_type == TK_OP_NOT_EQUAL ||
p_type == TK_OP_LESS ||
@@ -2571,7 +2526,6 @@ bool ShaderLanguage::is_token_operator(TokenType p_type) {
}
bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value) {
-
if (p_constant->datatype == p_to_type) {
if (p_value) {
for (int i = 0; i < p_constant->values.size(); i++) {
@@ -2580,13 +2534,11 @@ bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_ty
}
return true;
} else if (p_constant->datatype == TYPE_INT && p_to_type == TYPE_FLOAT) {
-
if (p_value) {
p_value->real = p_constant->values[0].sint;
}
return true;
} else if (p_constant->datatype == TYPE_UINT && p_to_type == TYPE_FLOAT) {
-
if (p_value) {
p_value->real = p_constant->values[0].uint;
}
@@ -2600,7 +2552,6 @@ bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_ty
}
return true;
} else if (p_constant->datatype == TYPE_UINT && p_to_type == TYPE_INT) {
-
if (p_constant->values[0].uint > 0x7FFFFFFF) {
return false;
}
@@ -2608,17 +2559,16 @@ bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_ty
p_value->sint = p_constant->values[0].uint;
}
return true;
- } else
+ } else {
return false;
+ }
}
bool ShaderLanguage::is_scalar_type(DataType p_type) {
-
return p_type == TYPE_BOOL || p_type == TYPE_INT || p_type == TYPE_UINT || p_type == TYPE_FLOAT;
}
bool ShaderLanguage::is_sampler_type(DataType p_type) {
-
return p_type == TYPE_SAMPLER2D ||
p_type == TYPE_ISAMPLER2D ||
p_type == TYPE_USAMPLER2D ||
@@ -2725,7 +2675,6 @@ Variant ShaderLanguage::constant_value_to_variant(const Vector<ShaderLanguage::C
case ShaderLanguage::TYPE_USAMPLER3D:
case ShaderLanguage::TYPE_SAMPLERCUBE:
case ShaderLanguage::TYPE_SAMPLERCUBEARRAY: {
-
// Texture types, likely not relevant here.
break;
}
@@ -2780,7 +2729,6 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform
case ShaderLanguage::TYPE_UVEC2:
case ShaderLanguage::TYPE_UVEC3:
case ShaderLanguage::TYPE_UVEC4: {
-
pi.type = Variant::PACKED_INT32_ARRAY;
} break;
case ShaderLanguage::TYPE_FLOAT: {
@@ -2816,7 +2764,6 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform
case ShaderLanguage::TYPE_SAMPLER2D:
case ShaderLanguage::TYPE_ISAMPLER2D:
case ShaderLanguage::TYPE_USAMPLER2D: {
-
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture2D";
@@ -2824,7 +2771,6 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY: {
-
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureLayered";
@@ -2838,7 +2784,6 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE:
case ShaderLanguage::TYPE_SAMPLERCUBEARRAY: {
-
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureLayered";
@@ -2904,13 +2849,11 @@ uint32_t ShaderLanguage::get_type_size(DataType p_type) {
}
void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
-
Set<String> kws;
int idx = 0;
while (keyword_list[idx].text) {
-
kws.insert(keyword_list[idx].text);
idx++;
}
@@ -2918,7 +2861,6 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
idx = 0;
while (builtin_func_defs[idx].name) {
-
kws.insert(builtin_func_defs[idx].name);
idx++;
@@ -2930,13 +2872,11 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
}
void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
-
Set<String> kws;
int idx = 0;
while (builtin_func_defs[idx].name) {
-
kws.insert(builtin_func_defs[idx].name);
idx++;
@@ -2948,7 +2888,6 @@ void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
}
ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
-
static const DataType scalar_types[] = {
TYPE_VOID,
TYPE_BOOL,
@@ -3011,7 +2950,6 @@ int ShaderLanguage::get_cardinality(DataType p_type) {
}
bool ShaderLanguage::_get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier) {
-
identifier = StringName();
TkPos pos = { 0, 0 };
@@ -3025,7 +2963,6 @@ bool ShaderLanguage::_get_completable_identifier(BlockNode *p_block, CompletionT
}
if (tk.type == TK_CURSOR) {
-
completion_type = p_type;
completion_line = tk_line;
completion_block = p_block;
@@ -3068,9 +3005,7 @@ bool ShaderLanguage::_is_operator_assign(Operator p_op) const {
}
bool ShaderLanguage::_validate_assign(Node *p_node, const Map<StringName, BuiltInInfo> &p_builtin_types, String *r_message) {
-
if (p_node->type == Node::TYPE_OPERATOR) {
-
OperatorNode *op = static_cast<OperatorNode *>(p_node);
if (op->op == OP_INDEX) {
@@ -3081,42 +3016,45 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const Map<StringName, BuiltI
return _validate_assign(op->arguments[1], p_builtin_types, r_message);
} else if (op->op == OP_CALL) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Assignment to function.");
+ }
return false;
}
} else if (p_node->type == Node::TYPE_MEMBER) {
-
MemberNode *member = static_cast<MemberNode *>(p_node);
if (member->has_swizzling_duplicates) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Swizzling assignment contains duplicates.");
+ }
return false;
}
return _validate_assign(member->owner, p_builtin_types, r_message);
} else if (p_node->type == Node::TYPE_VARIABLE) {
-
VariableNode *var = static_cast<VariableNode *>(p_node);
if (shader->uniforms.has(var->name)) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Assignment to uniform.");
+ }
return false;
}
if (shader->varyings.has(var->name) && current_function != String("vertex")) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Varyings can only be assigned in vertex function.");
+ }
return false;
}
if (shader->constants.has(var->name) || var->is_const) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Constants cannot be modified.");
+ }
return false;
}
@@ -3124,33 +3062,34 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const Map<StringName, BuiltI
return true;
}
} else if (p_node->type == Node::TYPE_ARRAY) {
-
ArrayNode *arr = static_cast<ArrayNode *>(p_node);
if (arr->is_const) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Constants cannot be modified.");
+ }
return false;
}
if (shader->varyings.has(arr->name) && current_function != String("vertex")) {
- if (r_message)
+ if (r_message) {
*r_message = RTR("Varyings can only be assigned in vertex function.");
+ }
return false;
}
return true;
}
- if (r_message)
+ if (r_message) {
*r_message = "Assignment to constant expression.";
+ }
return false;
}
bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringName p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat) {
for (int i = 0; shader->functions.size(); i++) {
if (shader->functions[i].name == p_name) {
-
ERR_FAIL_INDEX_V(p_argument, shader->functions[i].function->arguments.size(), false);
FunctionNode::Argument *arg = &shader->functions[i].function->arguments.write[p_argument];
if (arg->tex_builtin_check) {
@@ -3161,12 +3100,10 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringNam
if (arg->tex_argument_filter == p_filter && arg->tex_argument_repeat == p_repeat) {
return true;
} else {
-
_set_error("Sampler argument #" + itos(p_argument) + " of function '" + String(p_name) + "' called more than once using textures that differ in either filter or repeat setting.");
return false;
}
} else {
-
arg->tex_argument_check = true;
arg->tex_argument_filter = p_filter;
arg->tex_argument_repeat = p_repeat;
@@ -3183,10 +3120,10 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringNam
}
ERR_FAIL_V(false); //bug? function not found
}
+
bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringName p_name, int p_argument, const StringName &p_builtin) {
for (int i = 0; shader->functions.size(); i++) {
if (shader->functions[i].name == p_name) {
-
ERR_FAIL_INDEX_V(p_argument, shader->functions[i].function->arguments.size(), false);
FunctionNode::Argument *arg = &shader->functions[i].function->arguments.write[p_argument];
if (arg->tex_argument_check) {
@@ -3201,7 +3138,6 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa
return false;
}
} else {
-
arg->tex_builtin_check = true;
arg->tex_builtin = p_builtin;
@@ -3220,13 +3156,11 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa
}
ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types) {
-
Vector<Expression> expression;
//Vector<TokenType> operators;
while (true) {
-
Node *expr = nullptr;
TkPos prepos = _get_tkpos();
Token tk = _get_token();
@@ -3238,19 +3172,18 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
//handle subexpression
expr = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!expr)
+ if (!expr) {
return nullptr;
+ }
tk = _get_token();
if (tk.type != TK_PARENTHESIS_CLOSE) {
-
_set_error("Expected ')' in expression");
return nullptr;
}
} else if (tk.type == TK_REAL_CONSTANT) {
-
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
v.real = tk.constant;
@@ -3259,7 +3192,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = constant;
} else if (tk.type == TK_INT_CONSTANT) {
-
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
v.sint = tk.constant;
@@ -3268,7 +3200,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = constant;
} else if (tk.type == TK_TRUE) {
-
//handle true constant
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
@@ -3278,7 +3209,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = constant;
} else if (tk.type == TK_FALSE) {
-
//handle false constant
ConstantNode *constant = alloc_node<ConstantNode>();
ConstantNode::Value v;
@@ -3288,7 +3218,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = constant;
} else if (tk.type == TK_TYPE_VOID) {
-
//make sure void is not used in expression
_set_error("Void value not allowed in Expression");
return nullptr;
@@ -3299,7 +3228,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
func->op = OP_CONSTRUCT;
if (is_token_precision(tk.type)) {
-
func->return_precision_cache = get_token_precision(tk.type);
tk = _get_token();
}
@@ -3326,8 +3254,9 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
completion_argument = carg;
}
- if (!ok)
+ if (!ok) {
return nullptr;
+ }
if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) {
_set_error("No matching constructor found for: '" + String(funcname->name) + "'");
@@ -3337,7 +3266,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = _reduce_expression(p_block, func);
} else if (tk.type == TK_IDENTIFIER) {
-
_set_tkpos(prepos);
StringName identifier;
@@ -3354,7 +3282,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
tk = _get_token();
if (tk.type == TK_PARENTHESIS_OPEN) {
-
if (struct_init) { //a struct constructor
const StringName &name = identifier;
@@ -3371,7 +3298,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
Node *nexpr;
if (pstruct->members[i]->array_size != 0) {
-
DataType type = pstruct->members[i]->get_datatype();
String struct_name = pstruct->members[i]->struct_name;
int array_size = pstruct->members[i]->array_size;
@@ -3387,7 +3313,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
if (tk.type == TK_CURLY_BRACKET_OPEN) {
auto_size = true;
} else {
-
if (shader->structs.has(tk.text)) {
type2 = TYPE_STRUCT;
struct_name2 = tk.text;
@@ -3470,7 +3395,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
if (tk.type == TK_PARENTHESIS_OPEN || auto_size) { // initialization
while (true) {
-
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!n) {
return nullptr;
@@ -3492,10 +3416,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
an->initializer.push_back(n);
break;
} else {
- if (auto_size)
+ if (auto_size) {
_set_error("Expected '}' or ','");
- else
+ } else {
_set_error("Expected ')' or ','");
+ }
return nullptr;
}
}
@@ -3590,8 +3515,9 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
completion_argument = carg;
}
- if (!ok)
+ if (!ok) {
return nullptr;
+ }
if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) {
_set_error("No matching function found for: '" + String(funcname->name) + "'");
@@ -3604,14 +3530,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
FunctionNode *call_function = shader->functions[function_index].function;
if (call_function) {
-
//get current base function
FunctionNode *base_function = nullptr;
{
BlockNode *b = p_block;
while (b) {
-
if (b->parent_function) {
base_function = b->parent_function;
break;
@@ -3733,7 +3657,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
return nullptr;
}
} else {
-
if (!_find_identifier(p_block, false, p_builtin_types, identifier, &data_type, &ident_type, &is_const, &array_size, &struct_name)) {
_set_error("Unknown identifier in expression: " + String(identifier));
return nullptr;
@@ -3761,14 +3684,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
p_block->block_tag = SubClassTag::TAG_ARRAY;
call_expression = _parse_and_reduce_expression(p_block, p_builtin_types);
p_block->block_tag = SubClassTag::TAG_GLOBAL;
- if (!call_expression)
+ if (!call_expression) {
return nullptr;
+ }
data_type = call_expression->get_datatype();
} else { // indexing
index_expression = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!index_expression)
+ if (!index_expression) {
return nullptr;
+ }
if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) {
_set_error("Only integer expressions are allowed for indexing");
@@ -3805,7 +3730,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expr = arrname;
} else {
-
VariableNode *varname = alloc_node<VariableNode>();
varname->name = identifier;
varname->datatype_cache = data_type;
@@ -3817,7 +3741,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
} else if (tk.type == TK_OP_ADD) {
continue; //this one does nothing
} else if (tk.type == TK_OP_SUB || tk.type == TK_OP_NOT || tk.type == TK_OP_BIT_INVERT || tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) {
-
Expression e;
e.is_op = true;
@@ -3862,9 +3785,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
if (tk.type == TK_CURSOR) {
//do nothing
} else if (tk.type == TK_IDENTIFIER) {
-
} else if (tk.type == TK_PERIOD) {
-
DataType dt = expr->get_datatype();
String st = expr->get_datatype_name();
@@ -3919,7 +3840,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
case TYPE_IVEC2:
case TYPE_UVEC2:
case TYPE_VEC2: {
-
int l = ident.length();
if (l == 1) {
member_type = DataType(dt - 1);
@@ -3936,7 +3856,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
const CharType *c = ident.ptr();
for (int i = 0; i < l; i++) {
-
switch (c[i]) {
case 'r':
case 'g':
@@ -3985,7 +3904,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
case TYPE_IVEC3:
case TYPE_UVEC3:
case TYPE_VEC3: {
-
int l = ident.length();
if (l == 1) {
member_type = DataType(dt - 2);
@@ -4002,7 +3920,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
const CharType *c = ident.ptr();
for (int i = 0; i < l; i++) {
-
switch (c[i]) {
case 'r':
case 'g':
@@ -4054,7 +3971,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
case TYPE_IVEC4:
case TYPE_UVEC4:
case TYPE_VEC4: {
-
int l = ident.length();
if (l == 1) {
member_type = DataType(dt - 3);
@@ -4071,7 +3987,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
const CharType *c = ident.ptr();
for (int i = 0; i < l; i++) {
-
switch (c[i]) {
case 'r':
case 'g':
@@ -4150,16 +4065,15 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
mn->has_swizzling_duplicates = repeated;
if (array_size > 0) {
-
tk = _get_token();
if (tk.type == TK_PERIOD) {
_set_error("Nested array length() is not yet implemented");
return nullptr;
} else if (tk.type == TK_BRACKET_OPEN) {
-
Node *index_expression = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!index_expression)
+ if (!index_expression) {
return nullptr;
+ }
if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) {
_set_error("Only integer expressions are allowed for indexing");
@@ -4205,10 +4119,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
*/
} else if (tk.type == TK_BRACKET_OPEN) {
-
Node *index = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!index)
+ if (!index) {
return nullptr;
+ }
if (index->get_datatype() != TYPE_INT && index->get_datatype() != TYPE_UINT) {
_set_error("Only integer datatypes are allowed for indexing");
@@ -4338,7 +4252,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
} else if (tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) {
-
OperatorNode *op = alloc_node<OperatorNode>();
op->op = tk.type == TK_OP_DECREMENT ? OP_POST_DECREMENT : OP_POST_INCREMENT;
op->arguments.push_back(expr);
@@ -4354,7 +4267,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
expr = op;
} else {
-
_set_tkpos(pos2);
break;
}
@@ -4369,12 +4281,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
tk = _get_token();
if (is_token_operator(tk.type)) {
-
Expression o;
o.is_op = true;
switch (tk.type) {
-
case TK_OP_EQUAL:
o.op = OP_EQUAL;
break;
@@ -4485,16 +4395,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
/* Reduce the set set of expressions and place them in an operator tree, respecting precedence */
while (expression.size() > 1) {
-
int next_op = -1;
int min_priority = 0xFFFFF;
bool is_unary = false;
bool is_ternary = false;
for (int i = 0; i < expression.size(); i++) {
-
if (!expression[i].is_op) {
-
continue;
}
@@ -4638,10 +4545,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
// OK! create operator..
// OK! create operator..
if (is_unary) {
-
int expr_pos = next_op;
while (expression[expr_pos].is_op) {
-
expr_pos++;
if (expr_pos == expression.size()) {
//can happen..
@@ -4652,11 +4557,9 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
//consecutively do unary operators
for (int i = expr_pos - 1; i >= next_op; i--) {
-
OperatorNode *op = alloc_node<OperatorNode>();
op->op = expression[i].op;
if ((op->op == OP_INCREMENT || op->op == OP_DECREMENT) && !_validate_assign(expression[i + 1].node, p_builtin_types)) {
-
_set_error("Can't use increment/decrement operator in constant expression.");
return nullptr;
}
@@ -4666,11 +4569,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expression.write[i].node = op;
if (!_validate_operator(op, &op->return_cache)) {
-
String at;
for (int j = 0; j < op->arguments.size(); j++) {
- if (j > 0)
+ if (j > 0) {
at += " and ";
+ }
at += get_datatype_name(op->arguments[j]->get_datatype());
}
_set_error("Invalid arguments to unary operator '" + get_operator_text(op->op) + "' :" + at);
@@ -4680,7 +4583,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
} else if (is_ternary) {
-
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
@@ -4700,11 +4602,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expression.write[next_op - 1].is_op = false;
expression.write[next_op - 1].node = op;
if (!_validate_operator(op, &op->return_cache)) {
-
String at;
for (int i = 0; i < op->arguments.size(); i++) {
- if (i > 0)
+ if (i > 0) {
at += " and ";
+ }
at += get_datatype_name(op->arguments[i]->get_datatype());
}
_set_error("Invalid argument to ternary ?: operator: " + at);
@@ -4716,7 +4618,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
} else {
-
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
@@ -4726,16 +4627,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
op->op = expression[next_op].op;
if (expression[next_op - 1].is_op) {
-
_set_error("Parser bug...");
ERR_FAIL_V(nullptr);
}
if (_is_operator_assign(op->op)) {
-
String assign_message;
if (!_validate_assign(expression[next_op - 1].node, p_builtin_types, &assign_message)) {
-
_set_error(assign_message);
return nullptr;
}
@@ -4757,11 +4655,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
//replace all 3 nodes by this operator and make it an expression
if (!_validate_operator(op, &op->return_cache)) {
-
String at;
for (int i = 0; i < op->arguments.size(); i++) {
- if (i > 0)
+ if (i > 0) {
at += " and ";
+ }
if (op->arguments[i]->get_datatype() == TYPE_STRUCT) {
at += op->arguments[i]->get_datatype_name();
} else {
@@ -4781,15 +4679,14 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node) {
-
- if (p_node->type != Node::TYPE_OPERATOR)
+ if (p_node->type != Node::TYPE_OPERATOR) {
return p_node;
+ }
//for now only reduce simple constructors
OperatorNode *op = static_cast<OperatorNode *>(p_node);
if (op->op == OP_CONSTRUCT) {
-
ERR_FAIL_COND_V(op->arguments[0]->type != Node::TYPE_VARIABLE, p_node);
DataType type = op->get_datatype();
@@ -4799,7 +4696,6 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
Vector<ConstantNode::Value> values;
for (int i = 1; i < op->arguments.size(); i++) {
-
op->arguments.write[i] = _reduce_expression(p_block, op->arguments[i]);
if (op->arguments[i]->type == Node::TYPE_CONSTANT) {
ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[i]);
@@ -4809,7 +4705,6 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
values.push_back(cn->values[j]);
}
} else if (get_scalar_type(cn->datatype) == cn->datatype) {
-
ConstantNode::Value v;
if (!convert_constant(cn, base, &v)) {
return p_node;
@@ -4853,10 +4748,8 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
cn->values = values;
return cn;
} else if (op->op == OP_NEGATE) {
-
op->arguments.write[0] = _reduce_expression(p_block, op->arguments[0]);
if (op->arguments[0]->type == Node::TYPE_CONSTANT) {
-
ConstantNode *cn = static_cast<ConstantNode *>(op->arguments[0]);
DataType base = get_scalar_type(cn->datatype);
@@ -4864,7 +4757,6 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
Vector<ConstantNode::Value> values;
for (int i = 0; i < cn->values.size(); i++) {
-
ConstantNode::Value nv;
switch (base) {
case TYPE_BOOL: {
@@ -4896,10 +4788,10 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
}
ShaderLanguage::Node *ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types) {
-
ShaderLanguage::Node *expr = _parse_expression(p_block, p_builtin_types);
- if (!expr) //errored
+ if (!expr) { //errored
return nullptr;
+ }
expr = _reduce_expression(p_block, expr);
@@ -4907,9 +4799,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_
}
Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, bool p_just_one, bool p_can_break, bool p_can_continue) {
-
while (true) {
-
TkPos pos = _get_tkpos();
Token tk = _get_token();
@@ -4985,7 +4875,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
Node *vardecl = nullptr;
while (true) {
-
if (tk.type != TK_IDENTIFIER) {
_set_error("Expected identifier after type");
return ERR_PARSE_ERROR;
@@ -5038,7 +4927,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
if (tk.type == TK_BRACKET_CLOSE) {
unknown_size = true;
} else {
-
if (tk.type != TK_INT_CONSTANT || ((int)tk.constant) <= 0) {
_set_error("Expected integer constant > 0 or ']'");
return ERR_PARSE_ERROR;
@@ -5058,7 +4946,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
tk = _get_token();
if (tk.type == TK_OP_ASSIGN) {
-
if (RenderingServer::get_singleton()->is_low_end()) {
_set_error("Array initialization is supported only on high-end platform!");
return ERR_PARSE_ERROR;
@@ -5067,7 +4954,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
tk = _get_token();
if (tk.type != TK_CURLY_BRACKET_OPEN) {
-
if (unknown_size) {
_set_error("Expected '{'");
return ERR_PARSE_ERROR;
@@ -5196,7 +5082,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
if (tk.type == TK_PARENTHESIS_OPEN || curly) { // initialization
while (true) {
-
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
if (!n) {
return ERR_PARSE_ERROR;
@@ -5223,10 +5108,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
decl.initializer.push_back(n);
break;
} else {
- if (curly)
+ if (curly) {
_set_error("Expected '}' or ','");
- else
+ } else {
_set_error("Expected ')' or ','");
+ }
return ERR_PARSE_ERROR;
}
}
@@ -5252,7 +5138,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
node->declarations.push_back(decl);
} else if (tk.type == TK_OP_ASSIGN) {
-
VariableDeclarationNode *node = alloc_node<VariableDeclarationNode>();
if (is_struct) {
node->struct_name = struct_name;
@@ -5270,8 +5155,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
//variable created with assignment! must parse an expression
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!n)
+ if (!n) {
return ERR_PARSE_ERROR;
+ }
if (node->is_const && n->type == Node::TYPE_OPERATOR && ((OperatorNode *)n)->op == OP_CALL) {
_set_error("Expected constant expression after '='");
return ERR_PARSE_ERROR;
@@ -5343,8 +5229,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
ControlFlowNode *cf = alloc_node<ControlFlowNode>();
cf->flow_op = FLOW_OP_IF;
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!n)
+ if (!n) {
return ERR_PARSE_ERROR;
+ }
if (n->get_datatype() != TYPE_BOOL) {
_set_error("Expected boolean expression");
@@ -5364,13 +5251,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(cf);
Error err = _parse_block(block, p_builtin_types, true, p_can_break, p_can_continue);
- if (err)
+ if (err) {
return err;
+ }
pos = _get_tkpos();
tk = _get_token();
if (tk.type == TK_CF_ELSE) {
-
block = alloc_node<BlockNode>();
block->parent_block = p_block;
cf->blocks.push_back(block);
@@ -5380,7 +5267,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
_set_tkpos(pos); //rollback
}
} else if (tk.type == TK_CF_SWITCH) {
-
if (RenderingServer::get_singleton()->is_low_end()) {
_set_error("\"switch\" operator is supported only on high-end platform!");
return ERR_PARSE_ERROR;
@@ -5395,8 +5281,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
ControlFlowNode *cf = alloc_node<ControlFlowNode>();
cf->flow_op = FLOW_OP_SWITCH;
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!n)
+ if (!n) {
return ERR_PARSE_ERROR;
+ }
if (n->get_datatype() != TYPE_INT) {
_set_error("Expected integer expression");
return ERR_PARSE_ERROR;
@@ -5523,13 +5410,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(cf);
Error err = _parse_block(case_block, p_builtin_types, false, true, false);
- if (err)
+ if (err) {
return err;
+ }
return OK;
} else if (tk.type == TK_CF_DEFAULT) {
-
if (p_block && p_block->block_type == BlockNode::BLOCK_TYPE_CASE) {
_set_tkpos(pos);
return OK;
@@ -5557,8 +5444,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(cf);
Error err = _parse_block(default_block, p_builtin_types, false, true, false);
- if (err)
+ if (err) {
return err;
+ }
return OK;
@@ -5569,13 +5457,13 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
BlockNode *do_block = nullptr;
if (is_do) {
-
do_block = alloc_node<BlockNode>();
do_block->parent_block = p_block;
Error err = _parse_block(do_block, p_builtin_types, true, true, true);
- if (err)
+ if (err) {
return err;
+ }
tk = _get_token();
if (tk.type != TK_CF_WHILE) {
@@ -5597,8 +5485,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
cf->flow_op = FLOW_OP_WHILE;
}
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!n)
+ if (!n) {
return ERR_PARSE_ERROR;
+ }
tk = _get_token();
if (tk.type != TK_PARENTHESIS_CLOSE) {
@@ -5613,10 +5502,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(cf);
Error err = _parse_block(block, p_builtin_types, true, true, true);
- if (err)
+ if (err) {
return err;
+ }
} else {
-
cf->expressions.push_back(n);
cf->blocks.push_back(do_block);
p_block->statements.push_back(cf);
@@ -5648,8 +5537,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
Node *n = _parse_and_reduce_expression(init_block, p_builtin_types);
- if (!n)
+ if (!n) {
return ERR_PARSE_ERROR;
+ }
if (n->get_datatype() != TYPE_BOOL) {
_set_error("Middle expression is expected to be boolean.");
@@ -5665,8 +5555,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
cf->expressions.push_back(n);
n = _parse_and_reduce_expression(init_block, p_builtin_types);
- if (!n)
+ if (!n) {
return ERR_PARSE_ERROR;
+ }
cf->expressions.push_back(n);
@@ -5682,11 +5573,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(cf);
Error err = _parse_block(block, p_builtin_types, true, true, true);
- if (err)
+ if (err) {
return err;
+ }
} else if (tk.type == TK_CF_RETURN) {
-
//check return type
BlockNode *b = p_block;
while (b && !b->parent_function) {
@@ -5712,8 +5603,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
} else {
_set_tkpos(pos); //rollback, wants expression
Node *expr = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!expr)
+ if (!expr) {
return ERR_PARSE_ERROR;
+ }
if (b->parent_function->return_type != expr->get_datatype()) {
_set_error("Expected return expression of type '" + get_datatype_name(b->parent_function->return_type) + "'");
@@ -5739,7 +5631,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
block = block->parent_block;
}
} else if (tk.type == TK_CF_DISCARD) {
-
//check return type
BlockNode *b = p_block;
while (b && !b->parent_function) {
@@ -5767,7 +5658,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(flow);
} else if (tk.type == TK_CF_BREAK) {
-
if (!p_can_break) {
//all is good
_set_error("Breaking is not allowed here");
@@ -5794,7 +5684,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
} else if (tk.type == TK_CF_CONTINUE) {
-
if (!p_can_continue) {
//all is good
_set_error("Continuing is not allowed here");
@@ -5813,12 +5702,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->statements.push_back(flow);
} else {
-
//nothing else, so expression
_set_tkpos(pos); //rollback
Node *expr = _parse_and_reduce_expression(p_block, p_builtin_types);
- if (!expr)
+ if (!expr) {
return ERR_PARSE_ERROR;
+ }
p_block->statements.push_back(expr);
tk = _get_token();
@@ -5828,15 +5717,15 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
}
}
- if (p_just_one)
+ if (p_just_one) {
break;
+ }
}
return OK;
}
String ShaderLanguage::_get_shader_type_list(const Set<String> &p_shader_types) const {
-
// Return a list of shader types as an human-readable string
String valid_types;
for (const Set<String>::Element *E = p_shader_types.front(); E; E = E->next()) {
@@ -5892,7 +5781,6 @@ Error ShaderLanguage::_validate_datatype(DataType p_type) {
}
Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types) {
-
Token tk = _get_token();
if (tk.type != TK_SHADER_TYPE) {
@@ -5930,12 +5818,9 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL;
while (tk.type != TK_EOF) {
-
switch (tk.type) {
case TK_RENDER_MODE: {
-
while (true) {
-
StringName mode;
_get_completable_identifier(nullptr, COMPLETION_RENDER_MODE, mode);
@@ -6097,7 +5982,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
} break;
case TK_GLOBAL: {
-
tk = _get_token();
if (tk.type != TK_UNIFORM) {
_set_error("Expected 'uniform' after 'global'");
@@ -6119,7 +6003,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
[[fallthrough]];
case TK_UNIFORM:
case TK_VARYING: {
-
bool uniform = tk.type == TK_UNIFORM;
DataPrecision precision = PRECISION_DEFAULT;
DataInterpolation interpolation = INTERPOLATION_SMOOTH;
@@ -6173,7 +6056,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
}
if (uniform) {
-
if (uniform_scope == ShaderNode::Uniform::SCOPE_GLOBAL) {
//validate global uniform
DataType gvtype = global_var_get_type_func(name);
@@ -6253,7 +6135,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
}
uniform2.hint = ShaderNode::Uniform::HINT_COLOR;
} else if (tk.type == TK_HINT_RANGE) {
-
uniform2.hint = ShaderNode::Uniform::HINT_RANGE;
if (type != TYPE_FLOAT && type != TYPE_INT) {
_set_error("Range hint is for float and int only");
@@ -6332,7 +6213,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
} else if (tk.type == TK_HINT_INSTANCE_INDEX) {
-
if (custom_instance_index != -1) {
_set_error("Can only specify 'instance_index' once.");
return ERR_PARSE_ERROR;
@@ -6414,10 +6294,10 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
//reset scope for next uniform
if (tk.type == TK_OP_ASSIGN) {
-
Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>());
- if (!expr)
+ if (!expr) {
return ERR_PARSE_ERROR;
+ }
if (expr->type != Node::TYPE_CONSTANT) {
_set_error("Expected constant expression after '='");
return ERR_PARSE_ERROR;
@@ -6443,7 +6323,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
} else {
-
ShaderNode::Varying varying;
varying.type = type;
varying.precision = precision;
@@ -6509,7 +6388,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
is_struct = true;
struct_name = tk.text;
} else {
-
if (!is_token_datatype(tk.type)) {
_set_error("Expected constant, function, uniform or varying");
return ERR_PARSE_ERROR;
@@ -6569,7 +6447,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
constant.initializer = nullptr;
if (tk.type == TK_OP_ASSIGN) {
-
if (!is_constant) {
_set_error("Expected 'const' keyword before constant definition");
return ERR_PARSE_ERROR;
@@ -6577,8 +6454,9 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
//variable created with assignment! must parse an expression
Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>());
- if (!expr)
+ if (!expr) {
return ERR_PARSE_ERROR;
+ }
if (expr->type == Node::TYPE_OPERATOR && ((OperatorNode *)expr)->op == OP_CALL) {
_set_error("Expected constant expression after '='");
return ERR_PARSE_ERROR;
@@ -6813,11 +6691,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
current_function = name;
Error err = _parse_block(func_node->body, builtin_types);
- if (err)
+ if (err) {
return err;
+ }
if (func_node->return_type != DataType::TYPE_VOID) {
-
BlockNode *block = func_node->body;
if (_find_last_flow_op_in_block(block, FlowOperation::FLOW_OP_RETURN) != OK) {
_set_error("Expected at least one return statement in a non-void function.");
@@ -6835,7 +6713,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
}
bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) {
-
if (p_functions.has("vertex")) {
if (p_functions["vertex"].built_ins.has(p_name)) {
return true;
@@ -6855,7 +6732,6 @@ bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionI
}
Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op) {
-
bool found = false;
for (int i = p_flow->blocks.size() - 1; i >= 0; i--) {
@@ -6874,11 +6750,9 @@ Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOper
}
Error ShaderLanguage::_find_last_flow_op_in_block(BlockNode *p_block, FlowOperation p_op) {
-
bool found = false;
for (int i = p_block->statements.size() - 1; i >= 0; i--) {
-
if (p_block->statements[i]->type == Node::TYPE_CONTROL_FLOW) {
ControlFlowNode *flow = (ControlFlowNode *)p_block->statements[i];
if (flow->flow_op == p_op) {
@@ -6907,7 +6781,6 @@ Error ShaderLanguage::_find_last_flow_op_in_block(BlockNode *p_block, FlowOperat
// skips over whitespace and /* */ and // comments
static int _get_first_ident_pos(const String &p_code) {
-
int idx = 0;
#define GETCHAR(m_idx) (((idx + m_idx) < p_code.length()) ? p_code[idx + m_idx] : CharType(0))
@@ -6916,8 +6789,9 @@ static int _get_first_ident_pos(const String &p_code) {
if (GETCHAR(0) == '/' && GETCHAR(1) == '/') {
idx += 2;
while (true) {
- if (GETCHAR(0) == 0)
+ if (GETCHAR(0) == 0) {
return 0;
+ }
if (GETCHAR(0) == '\n') {
idx++;
break; // loop
@@ -6927,8 +6801,9 @@ static int _get_first_ident_pos(const String &p_code) {
} else if (GETCHAR(0) == '/' && GETCHAR(1) == '*') {
idx += 2;
while (true) {
- if (GETCHAR(0) == 0)
+ if (GETCHAR(0) == 0) {
return 0;
+ }
if (GETCHAR(0) == '*' && GETCHAR(1) == '/') {
idx += 2;
break; // loop
@@ -6953,13 +6828,11 @@ static int _get_first_ident_pos(const String &p_code) {
}
String ShaderLanguage::get_shader_type(const String &p_code) {
-
bool reading_type = false;
String cur_identifier;
for (int i = _get_first_ident_pos(p_code); i < p_code.length(); i++) {
-
if (p_code[i] == ';') {
break;
@@ -6981,14 +6854,14 @@ String ShaderLanguage::get_shader_type(const String &p_code) {
}
}
- if (reading_type)
+ if (reading_type) {
return cur_identifier;
+ }
return String();
}
Error ShaderLanguage::compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, GlobalVariableGetTypeFunc p_global_variable_type_func) {
-
clear();
code = p_code;
@@ -7006,7 +6879,6 @@ Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Functi
}
Error ShaderLanguage::complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, GlobalVariableGetTypeFunc p_global_variable_type_func, List<ScriptCodeCompletionOption> *r_options, String &r_call_hint) {
-
clear();
code = p_code;
@@ -7018,7 +6890,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
_parse_shader(p_functions, p_render_modes, p_shader_types);
switch (completion_type) {
-
case COMPLETION_NONE: {
//do nothing
return OK;
@@ -7032,7 +6903,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
return OK;
} break;
case COMPLETION_STRUCT: {
-
if (shader->structs.has(completion_struct)) {
StructNode *node = shader->structs[completion_struct].shader_struct;
for (int i = 0; i < node->members.size(); i++) {
@@ -7044,7 +6914,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
return OK;
} break;
case COMPLETION_MAIN_FUNCTION: {
-
for (const Map<StringName, FunctionInfo>::Element *E = p_functions.front(); E; E = E->next()) {
ScriptCodeCompletionOption option(E->key(), ScriptCodeCompletionOption::KIND_FUNCTION);
r_options->push_back(option);
@@ -7054,7 +6923,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
} break;
case COMPLETION_IDENTIFIER:
case COMPLETION_FUNCTION_CALL: {
-
bool comp_ident = completion_type == COMPLETION_IDENTIFIER;
Map<String, ScriptCodeCompletionOption::Kind> matches;
StringName skip_function;
@@ -7064,7 +6932,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
while (block) {
if (comp_ident) {
for (const Map<StringName, BlockNode::Variable>::Element *E = block->variables.front(); E; E = E->next()) {
-
if (E->get().line < completion_line) {
matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE);
}
@@ -7112,8 +6979,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
for (int i = 0; i < shader->functions.size(); i++) {
- if (!shader->functions[i].callable || shader->functions[i].name == skip_function)
+ if (!shader->functions[i].callable || shader->functions[i].name == skip_function) {
continue;
+ }
matches.insert(String(shader->functions[i].name), ScriptCodeCompletionOption::KIND_FUNCTION);
}
@@ -7156,12 +7024,11 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
return OK;
} break;
case COMPLETION_CALL_ARGUMENTS: {
-
for (int i = 0; i < shader->functions.size(); i++) {
- if (!shader->functions[i].callable)
+ if (!shader->functions[i].callable) {
continue;
+ }
if (shader->functions[i].name == completion_function) {
-
String calltip;
calltip += get_datatype_name(shader->functions[i].function->return_type);
@@ -7170,11 +7037,11 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
calltip += "(";
for (int j = 0; j < shader->functions[i].function->arguments.size(); j++) {
-
- if (j > 0)
+ if (j > 0) {
calltip += ", ";
- else
+ } else {
calltip += " ";
+ }
if (j == completion_argument) {
calltip += CharType(0xFFFF);
@@ -7197,8 +7064,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
}
- if (shader->functions[i].function->arguments.size())
+ if (shader->functions[i].function->arguments.size()) {
calltip += " ";
+ }
calltip += ")";
r_call_hint = calltip;
@@ -7212,7 +7080,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
bool low_end = RenderingServer::get_singleton()->is_low_end();
while (builtin_func_defs[idx].name) {
-
if (low_end && builtin_func_defs[idx].high_end) {
idx++;
continue;
@@ -7229,14 +7096,14 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
if (completion_function == builtin_func_defs[idx].name) {
-
if (builtin_func_defs[idx].tag != completion_class) {
idx++;
continue;
}
- if (calltip.length())
+ if (calltip.length()) {
calltip += "\n";
+ }
calltip += get_datatype_name(builtin_func_defs[idx].rettype);
calltip += " ";
@@ -7245,14 +7112,15 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
bool found_arg = false;
for (int i = 0; i < 4; i++) {
-
- if (builtin_func_defs[idx].args[i] == TYPE_VOID)
+ if (builtin_func_defs[idx].args[i] == TYPE_VOID) {
break;
+ }
- if (i > 0)
+ if (i > 0) {
calltip += ", ";
- else
+ } else {
calltip += " ";
+ }
if (i == completion_argument) {
calltip += CharType(0xFFFF);
@@ -7271,8 +7139,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
found_arg = true;
}
- if (found_arg)
+ if (found_arg) {
calltip += " ";
+ }
calltip += ")";
}
idx++;
@@ -7284,7 +7153,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
} break;
case COMPLETION_INDEX: {
-
const char colv[4] = { 'r', 'g', 'b', 'a' };
const char coordv[4] = { 'x', 'y', 'z', 'w' };
const char coordt[4] = { 's', 't', 'p', 'q' };
@@ -7303,7 +7171,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
case TYPE_IVEC3:
case TYPE_UVEC3:
case TYPE_VEC3: {
-
limit = 3;
} break;
@@ -7311,7 +7178,6 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
case TYPE_IVEC4:
case TYPE_UVEC4:
case TYPE_VEC4: {
-
limit = 4;
} break;
@@ -7341,27 +7207,22 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct
}
String ShaderLanguage::get_error_text() {
-
return error_str;
}
int ShaderLanguage::get_error_line() {
-
return error_line;
}
ShaderLanguage::ShaderNode *ShaderLanguage::get_shader() {
-
return shader;
}
ShaderLanguage::ShaderLanguage() {
-
nodes = nullptr;
completion_class = TAG_GLOBAL;
}
ShaderLanguage::~ShaderLanguage() {
-
clear();
}
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index 314e4a5fba..020a5e3e6f 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -40,7 +40,6 @@
#include "core/variant.h"
class ShaderLanguage {
-
public:
enum TokenType {
TK_EMPTY,
@@ -328,7 +327,7 @@ public:
};
struct Node {
- Node *next;
+ Node *next = nullptr;
enum Type {
TYPE_SHADER,
@@ -352,7 +351,6 @@ public:
virtual String get_datatype_name() const { return ""; }
Node(Type t) :
- next(nullptr),
type(t) {}
virtual ~Node() {}
};
@@ -368,41 +366,35 @@ public:
Node *nodes;
struct OperatorNode : public Node {
- DataType return_cache;
- DataPrecision return_precision_cache;
- Operator op;
+ DataType return_cache = TYPE_VOID;
+ DataPrecision return_precision_cache = PRECISION_DEFAULT;
+ Operator op = OP_EQUAL;
StringName struct_name;
Vector<Node *> arguments;
virtual DataType get_datatype() const { return return_cache; }
virtual String get_datatype_name() const { return String(struct_name); }
OperatorNode() :
- Node(TYPE_OPERATOR),
- return_cache(TYPE_VOID),
- return_precision_cache(PRECISION_DEFAULT),
- op(OP_EQUAL),
- struct_name("") {}
+ Node(TYPE_OPERATOR) {}
};
struct VariableNode : public Node {
- DataType datatype_cache;
+ DataType datatype_cache = TYPE_VOID;
StringName name;
StringName struct_name;
virtual DataType get_datatype() const { return datatype_cache; }
virtual String get_datatype_name() const { return String(struct_name); }
- bool is_const;
+ bool is_const = false;
VariableNode() :
- Node(TYPE_VARIABLE),
- datatype_cache(TYPE_VOID),
- is_const(false) {}
+ Node(TYPE_VARIABLE) {}
};
struct VariableDeclarationNode : public Node {
- DataPrecision precision;
- DataType datatype;
+ DataPrecision precision = PRECISION_DEFAULT;
+ DataType datatype = TYPE_VOID;
String struct_name;
- bool is_const;
+ bool is_const = false;
struct Declaration {
StringName name;
@@ -413,47 +405,38 @@ public:
virtual DataType get_datatype() const { return datatype; }
VariableDeclarationNode() :
- Node(TYPE_VARIABLE_DECLARATION),
- precision(PRECISION_DEFAULT),
- datatype(TYPE_VOID),
- is_const(false) {}
+ Node(TYPE_VARIABLE_DECLARATION) {}
};
struct ArrayNode : public Node {
- DataType datatype_cache;
+ DataType datatype_cache = TYPE_VOID;
StringName struct_name;
StringName name;
- Node *index_expression;
- Node *call_expression;
- bool is_const;
+ Node *index_expression = nullptr;
+ Node *call_expression = nullptr;
+ bool is_const = false;
virtual DataType get_datatype() const { return datatype_cache; }
virtual String get_datatype_name() const { return String(struct_name); }
ArrayNode() :
- Node(TYPE_ARRAY),
- datatype_cache(TYPE_VOID),
- index_expression(nullptr),
- call_expression(nullptr),
- is_const(false) {}
+ Node(TYPE_ARRAY) {}
};
struct ArrayConstructNode : public Node {
- DataType datatype;
+ DataType datatype = TYPE_VOID;
String struct_name;
Vector<Node *> initializer;
ArrayConstructNode() :
- Node(TYPE_ARRAY_CONSTRUCT),
- datatype(TYPE_VOID) {
- }
+ Node(TYPE_ARRAY_CONSTRUCT) {}
};
struct ArrayDeclarationNode : public Node {
- DataPrecision precision;
- DataType datatype;
+ DataPrecision precision = PRECISION_DEFAULT;
+ DataType datatype = TYPE_VOID;
String struct_name;
- bool is_const;
+ bool is_const = false;
struct Declaration {
StringName name;
@@ -465,14 +448,11 @@ public:
virtual DataType get_datatype() const { return datatype; }
ArrayDeclarationNode() :
- Node(TYPE_ARRAY_DECLARATION),
- precision(PRECISION_DEFAULT),
- datatype(TYPE_VOID),
- is_const(false) {}
+ Node(TYPE_ARRAY_DECLARATION) {}
};
struct ConstantNode : public Node {
- DataType datatype;
+ DataType datatype = TYPE_VOID;
union Value {
bool boolean;
@@ -485,15 +465,14 @@ public:
virtual DataType get_datatype() const { return datatype; }
ConstantNode() :
- Node(TYPE_CONSTANT),
- datatype(TYPE_VOID) {}
+ Node(TYPE_CONSTANT) {}
};
struct FunctionNode;
struct BlockNode : public Node {
- FunctionNode *parent_function;
- BlockNode *parent_block;
+ FunctionNode *parent_function = nullptr;
+ BlockNode *parent_block = nullptr;
enum BlockType {
BLOCK_TYPE_STANDART,
@@ -503,8 +482,8 @@ public:
BLOCK_TYPE_DEFAULT,
};
- int block_type;
- SubClassTag block_tag;
+ int block_type = BLOCK_TYPE_STANDART;
+ SubClassTag block_tag = SubClassTag::TAG_GLOBAL;
struct Variable {
DataType type;
@@ -517,63 +496,48 @@ public:
Map<StringName, Variable> variables;
List<Node *> statements;
- bool single_statement;
+ bool single_statement = false;
BlockNode() :
- Node(TYPE_BLOCK),
- parent_function(nullptr),
- parent_block(nullptr),
- block_type(BLOCK_TYPE_STANDART),
- block_tag(SubClassTag::TAG_GLOBAL),
- single_statement(false) {}
+ Node(TYPE_BLOCK) {}
};
struct ControlFlowNode : public Node {
- FlowOperation flow_op;
+ FlowOperation flow_op = FLOW_OP_IF;
Vector<Node *> expressions;
Vector<BlockNode *> blocks;
ControlFlowNode() :
- Node(TYPE_CONTROL_FLOW),
- flow_op(FLOW_OP_IF) {}
+ Node(TYPE_CONTROL_FLOW) {}
};
struct MemberNode : public Node {
- DataType basetype;
- bool basetype_const;
+ DataType basetype = TYPE_VOID;
+ bool basetype_const = false;
StringName base_struct_name;
DataPrecision precision;
- DataType datatype;
- int array_size;
+ DataType datatype = TYPE_VOID;
+ int array_size = 0;
StringName struct_name;
StringName name;
- Node *owner;
- Node *index_expression;
- bool has_swizzling_duplicates;
+ Node *owner = nullptr;
+ Node *index_expression = nullptr;
+ bool has_swizzling_duplicates = false;
virtual DataType get_datatype() const { return datatype; }
virtual String get_datatype_name() const { return String(struct_name); }
MemberNode() :
- Node(TYPE_MEMBER),
- basetype(TYPE_VOID),
- basetype_const(false),
- datatype(TYPE_VOID),
- array_size(0),
- owner(nullptr),
- index_expression(nullptr),
- has_swizzling_duplicates(false) {}
+ Node(TYPE_MEMBER) {}
};
struct StructNode : public Node {
-
List<MemberNode *> members;
StructNode() :
Node(TYPE_STRUCT) {}
};
struct FunctionNode : public Node {
-
struct Argument {
ArgumentQualifier qualifier;
StringName name;
@@ -591,23 +555,18 @@ public:
};
StringName name;
- DataType return_type;
+ DataType return_type = TYPE_VOID;
StringName return_struct_name;
- DataPrecision return_precision;
+ DataPrecision return_precision = PRECISION_DEFAULT;
Vector<Argument> arguments;
- BlockNode *body;
- bool can_discard;
+ BlockNode *body = nullptr;
+ bool can_discard = false;
FunctionNode() :
- Node(TYPE_FUNCTION),
- return_type(TYPE_VOID),
- return_precision(PRECISION_DEFAULT),
- body(nullptr),
- can_discard(false) {}
+ Node(TYPE_FUNCTION) {}
};
struct ShaderNode : public Node {
-
struct Constant {
StringName name;
DataType type;
@@ -629,16 +588,12 @@ public:
};
struct Varying {
- DataType type;
- DataInterpolation interpolation;
- DataPrecision precision;
- int array_size;
+ DataType type = TYPE_VOID;
+ DataInterpolation interpolation = INTERPOLATION_FLAT;
+ DataPrecision precision = PRECISION_DEFAULT;
+ int array_size = 0;
- Varying() :
- type(TYPE_VOID),
- interpolation(INTERPOLATION_FLAT),
- precision(PRECISION_DEFAULT),
- array_size(0) {}
+ Varying() {}
};
struct Uniform {
@@ -667,28 +622,19 @@ public:
SCOPE_GLOBAL,
};
- int order;
- int texture_order;
- DataType type;
- DataPrecision precision;
+ int order = 0;
+ int texture_order = 0;
+ DataType type = TYPE_VOID;
+ DataPrecision precision = PRECISION_DEFAULT;
Vector<ConstantNode::Value> default_value;
- Scope scope;
- Hint hint;
- TextureFilter filter;
- TextureRepeat repeat;
+ Scope scope = SCOPE_LOCAL;
+ Hint hint = HINT_NONE;
+ TextureFilter filter = FILTER_DEFAULT;
+ TextureRepeat repeat = REPEAT_DEFAULT;
float hint_range[3];
- int instance_index;
-
- Uniform() :
- order(0),
- texture_order(0),
- type(TYPE_VOID),
- precision(PRECISION_DEFAULT),
- scope(SCOPE_LOCAL),
- hint(HINT_NONE),
- filter(FILTER_DEFAULT),
- repeat(REPEAT_DEFAULT),
- instance_index(0) {
+ int instance_index = 0;
+
+ Uniform() {
hint_range[0] = 0.0f;
hint_range[1] = 1.0f;
hint_range[2] = 0.001f;
@@ -768,12 +714,10 @@ public:
static void get_builtin_funcs(List<String> *r_keywords);
struct BuiltInInfo {
- DataType type;
- bool constant;
+ DataType type = TYPE_VOID;
+ bool constant = false;
- BuiltInInfo() :
- type(TYPE_VOID),
- constant(false) {}
+ BuiltInInfo() {}
BuiltInInfo(DataType p_type, bool p_constant = false) :
type(p_type),
@@ -826,8 +770,9 @@ private:
}
void _set_error(const String &p_str) {
- if (error_set)
+ if (error_set) {
return;
+ }
error_line = tk_line;
error_set = true;
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index 78bbd73db4..2601efa9e2 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -31,12 +31,10 @@
#include "shader_types.h"
const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(RS::ShaderMode p_mode) {
-
return shader_modes[p_mode].functions;
}
const Vector<StringName> &ShaderTypes::get_modes(RS::ShaderMode p_mode) {
-
return shader_modes[p_mode].modes;
}
@@ -47,7 +45,6 @@ const Set<String> &ShaderTypes::get_types() {
ShaderTypes *ShaderTypes::singleton = nullptr;
static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) {
-
return ShaderLanguage::BuiltInInfo(p_type, true);
}
diff --git a/servers/rendering/shader_types.h b/servers/rendering/shader_types.h
index 499a761265..7d8057a5c6 100644
--- a/servers/rendering/shader_types.h
+++ b/servers/rendering/shader_types.h
@@ -36,9 +36,7 @@
#include "shader_language.h"
class ShaderTypes {
-
struct Type {
-
Map<StringName, ShaderLanguage::FunctionInfo> functions;
Vector<StringName> modes;
};
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 3dac846357..7edab1418d 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -37,27 +37,24 @@ RenderingServer *RenderingServer::singleton = nullptr;
RenderingServer *(*RenderingServer::create_func)() = nullptr;
RenderingServer *RenderingServer::get_singleton() {
-
return singleton;
}
RenderingServer *RenderingServer::create() {
-
ERR_FAIL_COND_V(singleton, nullptr);
- if (create_func)
+ if (create_func) {
return create_func();
+ }
return nullptr;
}
Array RenderingServer::_texture_debug_usage_bind() {
-
List<TextureInfo> list;
texture_debug_usage(&list);
Array arr;
for (const List<TextureInfo>::Element *E = list.front(); E; E = E->next()) {
-
Dictionary dict;
dict["texture"] = E->get().texture;
dict["width"] = E->get().width;
@@ -72,7 +69,6 @@ Array RenderingServer::_texture_debug_usage_bind() {
}
Array RenderingServer::_shader_get_param_list_bind(RID p_shader) const {
-
List<PropertyInfo> l;
shader_get_param_list(p_shader, &l);
return convert_property_list(&l);
@@ -88,19 +84,16 @@ static Array to_array(const Vector<ObjectID> &ids) {
}
Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const {
-
Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario);
return to_array(ids);
}
Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
-
Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario);
return to_array(ids);
}
Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const {
-
Vector<Plane> planes;
for (int i = 0; i < p_convex.size(); ++i) {
Variant v = p_convex[i];
@@ -113,7 +106,6 @@ Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_
}
RID RenderingServer::get_test_texture() {
-
if (test_texture.is_valid()) {
return test_texture;
};
@@ -127,20 +119,16 @@ RID RenderingServer::get_test_texture() {
uint8_t *w = test_data.ptrw();
for (int x = 0; x < TEST_TEXTURE_SIZE; x++) {
-
for (int y = 0; y < TEST_TEXTURE_SIZE; y++) {
-
Color c;
int r = 255 - (x + y) / 2;
if ((x % (TEST_TEXTURE_SIZE / 8)) < 2 || (y % (TEST_TEXTURE_SIZE / 8)) < 2) {
-
c.r = y;
c.g = r;
c.b = x;
} else {
-
c.r = r;
c.g = x;
c.b = y;
@@ -161,17 +149,18 @@ RID RenderingServer::get_test_texture() {
}
void RenderingServer::_free_internal_rids() {
-
- if (test_texture.is_valid())
+ if (test_texture.is_valid()) {
free(test_texture);
- if (white_texture.is_valid())
+ }
+ if (white_texture.is_valid()) {
free(white_texture);
- if (test_material.is_valid())
+ }
+ if (test_material.is_valid()) {
free(test_material);
+ }
}
RID RenderingServer::_make_test_cube() {
-
Vector<Vector3> vertices;
Vector<Vector3> normals;
Vector<float> tangents;
@@ -187,24 +176,22 @@ RID RenderingServer::_make_test_cube() {
uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0));
for (int i = 0; i < 6; i++) {
-
Vector3 face_points[4];
Vector3 normal_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)
+ if (i < 3) {
face_points[j][(i + k) % 3] = v[k];
- else
+ } else {
face_points[3 - j][(i + k) % 3] = -v[k];
+ }
}
normal_points[j] = Vector3();
normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
@@ -231,8 +218,9 @@ RID RenderingServer::_make_test_cube() {
Vector<int> indices;
indices.resize(vertices.size());
- for (int i = 0; i < vertices.size(); i++)
+ for (int i = 0; i < vertices.size(); i++) {
indices.set(i, i);
+ }
d[RenderingServer::ARRAY_INDEX] = indices;
mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d);
@@ -253,7 +241,6 @@ RID RenderingServer::_make_test_cube() {
}
RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
-
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -267,7 +254,6 @@ RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
double zr1 = Math::cos(lat1);
for (int j = p_lons; j >= 1; j--) {
-
double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
@@ -310,16 +296,17 @@ RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
}
RID RenderingServer::get_white_texture() {
-
- if (white_texture.is_valid())
+ if (white_texture.is_valid()) {
return white_texture;
+ }
Vector<uint8_t> wt;
wt.resize(16 * 3);
{
uint8_t *w = wt.ptrw();
- for (int i = 0; i < 16 * 3; i++)
+ for (int i = 0; i < 16 * 3; i++) {
w[i] = 255;
+ }
}
Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt));
white_texture = texture_2d_create(white);
@@ -330,7 +317,6 @@ RID RenderingServer::get_white_texture() {
#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) {
-
uint8_t *vw = r_vertex_array.ptrw();
uint8_t *iw = nullptr;
@@ -341,16 +327,13 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
int max_bone = 0;
for (int ai = 0; ai < RS::ARRAY_MAX; ai++) {
-
- if (!(p_format & (1 << ai))) // no array
+ if (!(p_format & (1 << ai))) { // no array
continue;
+ }
switch (ai) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) {
-
Vector<Vector2> array = p_arrays[ai];
ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
@@ -361,16 +344,13 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
{
for (int i = 0; i < p_vertex_array_len; i++) {
-
float vector[2] = { src[i].x, src[i].y };
copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(float) * 2);
if (i == 0) {
-
aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
} else {
-
aabb.expand_to(src[i]);
}
}
@@ -389,16 +369,13 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
{
for (int i = 0; i < p_vertex_array_len; i++) {
-
float vector[3] = { src[i].x, src[i].y, src[i].z };
copymem(&vw[p_offsets[ai] + i * p_stride], vector, sizeof(float) * 3);
if (i == 0) {
-
aabb = AABB(src[i], SMALL_VEC3);
} else {
-
aabb.expand_to(src[i]);
}
}
@@ -409,7 +386,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} break;
case RS::ARRAY_NORMAL: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER);
Vector<Vector3> array = p_arrays[ai];
@@ -420,9 +396,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
// setting vertices means regenerating the AABB
if (p_format & ARRAY_COMPRESS_NORMAL) {
-
for (int i = 0; i < p_vertex_array_len; i++) {
-
int8_t vector[4] = {
(int8_t)CLAMP(src[i].x * 127, -128, 127),
(int8_t)CLAMP(src[i].y * 127, -128, 127),
@@ -435,7 +409,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} else {
for (int i = 0; i < p_vertex_array_len; i++) {
-
float vector[3] = { src[i].x, src[i].y, src[i].z };
copymem(&vw[p_offsets[ai] + i * p_stride], vector, 3 * 4);
}
@@ -444,7 +417,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} break;
case RS::ARRAY_TANGENT: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
Vector<real_t> array = p_arrays[ai];
@@ -454,7 +426,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const real_t *src = array.ptr();
if (p_format & ARRAY_COMPRESS_TANGENT) {
-
for (int i = 0; i < p_vertex_array_len; i++) {
int8_t xyzw[4] = {
(int8_t)CLAMP(src[i * 4 + 0] * 127, -128, 127),
@@ -468,7 +439,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} else {
for (int i = 0; i < p_vertex_array_len; i++) {
-
float xyzw[4] = {
src[i * 4 + 0],
src[i * 4 + 1],
@@ -482,7 +452,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} break;
case RS::ARRAY_COLOR: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER);
Vector<Color> array = p_arrays[ai];
@@ -492,29 +461,23 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const Color *src = array.ptr();
if (p_format & ARRAY_COMPRESS_COLOR) {
-
for (int i = 0; i < p_vertex_array_len; i++) {
-
uint8_t colors[4];
for (int j = 0; j < 4; j++) {
-
colors[j] = CLAMP(int((src[i][j]) * 255.0), 0, 255);
}
copymem(&vw[p_offsets[ai] + i * p_stride], colors, 4);
}
} else {
-
for (int i = 0; i < p_vertex_array_len; i++) {
-
copymem(&vw[p_offsets[ai] + i * p_stride], &src[i], 4 * 4);
}
}
} break;
case RS::ARRAY_TEX_UV: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
Vector<Vector2> array = p_arrays[ai];
@@ -524,16 +487,13 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const Vector2 *src = array.ptr();
if (p_format & ARRAY_COMPRESS_TEX_UV) {
-
for (int i = 0; i < p_vertex_array_len; i++) {
-
uint16_t uv[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 2);
}
} else {
for (int i = 0; i < p_vertex_array_len; i++) {
-
float uv[2] = { src[i].x, src[i].y };
copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 4);
@@ -543,7 +503,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} break;
case RS::ARRAY_TEX_UV2: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER);
Vector<Vector2> array = p_arrays[ai];
@@ -553,16 +512,13 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const Vector2 *src = array.ptr();
if (p_format & ARRAY_COMPRESS_TEX_UV2) {
-
for (int i = 0; i < p_vertex_array_len; i++) {
-
uint16_t uv[2] = { Math::make_half_float(src[i].x), Math::make_half_float(src[i].y) };
copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 2);
}
} else {
for (int i = 0; i < p_vertex_array_len; i++) {
-
float uv[2] = { src[i].x, src[i].y };
copymem(&vw[p_offsets[ai] + i * p_stride], uv, 2 * 4);
@@ -570,7 +526,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
}
} break;
case RS::ARRAY_WEIGHTS: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
Vector<real_t> array = p_arrays[ai];
@@ -580,9 +535,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const real_t *src = array.ptr();
{
-
for (int i = 0; i < p_vertex_array_len; i++) {
-
uint16_t data[RS::ARRAY_WEIGHTS_SIZE];
for (int j = 0; j < RS::ARRAY_WEIGHTS_SIZE; j++) {
data[j] = CLAMP(src[i * RS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535);
@@ -594,7 +547,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} break;
case RS::ARRAY_BONES: {
-
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER);
Vector<int> array = p_arrays[ai];
@@ -604,7 +556,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const int *src = array.ptr();
for (int i = 0; i < p_vertex_array_len; i++) {
-
uint16_t data[RS::ARRAY_WEIGHTS_SIZE];
for (int j = 0; j < RS::ARRAY_WEIGHTS_SIZE; j++) {
data[j] = src[i * RS::ARRAY_WEIGHTS_SIZE + j];
@@ -616,7 +567,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
} break;
case RS::ARRAY_INDEX: {
-
ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA);
ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA);
ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER);
@@ -630,7 +580,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const int *src = indices.ptr();
for (int i = 0; i < p_index_array_len; i++) {
-
if (p_vertex_array_len < (1 << 16)) {
uint16_t v = src[i];
@@ -669,7 +618,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
bool any_valid = false;
if (vertices.size() && bones.size() == vertices.size() * 4 && weights.size() == bones.size()) {
-
int vs = vertices.size();
const Vector3 *rv = vertices.ptr();
const int *rb = bones.ptr();
@@ -678,14 +626,13 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
AABB *bptr = r_bone_aabb.ptrw();
for (int i = 0; i < vs; i++) {
-
Vector3 v = rv[i];
for (int j = 0; j < 4; j++) {
-
int idx = rb[i * 4 + j];
float w = rw[i * 4 + j];
- if (w == 0)
+ if (w == 0) {
continue; //break;
+ }
ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA);
if (bptr[idx].size.x < 0) {
@@ -700,7 +647,6 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
}
if (!any_valid && first) {
-
r_bone_aabb.clear();
}
}
@@ -719,22 +665,19 @@ uint32_t RenderingServer::mesh_surface_get_format_stride(uint32_t p_format, int
}
uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const {
-
int total_elem_size = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
r_offsets[i] = 0; //reset
- if (!(p_format & (1 << i))) // no array
+ if (!(p_format & (1 << i))) { // no array
continue;
+ }
int elem_size = 0;
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
elem_size = 2;
} else {
@@ -751,7 +694,6 @@ uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_forma
} break;
case RS::ARRAY_NORMAL: {
-
if (p_format & ARRAY_COMPRESS_NORMAL) {
elem_size = sizeof(uint32_t);
} else {
@@ -769,7 +711,6 @@ uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_forma
} break;
case RS::ARRAY_COLOR: {
-
if (p_format & ARRAY_COMPRESS_COLOR) {
elem_size = sizeof(uint32_t);
} else {
@@ -794,24 +735,20 @@ uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_forma
} break;
case RS::ARRAY_WEIGHTS: {
-
elem_size = sizeof(uint16_t) * 4;
} break;
case RS::ARRAY_BONES: {
-
elem_size = sizeof(uint16_t) * 4;
} break;
case RS::ARRAY_INDEX: {
-
if (p_index_len <= 0) {
ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
break;
}
/* determine whether using 16 or 32 bits indices */
if (p_vertex_len >= (1 << 16)) {
-
elem_size = 4;
} else {
@@ -832,7 +769,6 @@ uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_forma
}
Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) {
-
ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER);
@@ -843,14 +779,13 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
int array_len = 0;
for (int i = 0; i < p_arrays.size(); i++) {
-
- if (p_arrays[i].get_type() == Variant::NIL)
+ if (p_arrays[i].get_type() == Variant::NIL) {
continue;
+ }
format |= (1 << i);
if (i == RS::ARRAY_VERTEX) {
-
Variant var = p_arrays[i];
switch (var.get_type()) {
case Variant::PACKED_VECTOR2_ARRAY: {
@@ -867,7 +802,6 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
array_len = PackedVector3Array(p_arrays[i]).size();
ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA);
} else if (i == RS::ARRAY_INDEX) {
-
index_array_len = PackedInt32Array(p_arrays[i]).size();
}
}
@@ -877,13 +811,12 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
if (p_blend_shapes.size()) {
//validate format for morphs
for (int i = 0; i < p_blend_shapes.size(); i++) {
-
uint32_t bsformat = 0;
Array arr = p_blend_shapes[i];
for (int j = 0; j < arr.size(); j++) {
-
- if (arr[j].get_type() != Variant::NIL)
+ if (arr[j].get_type() != Variant::NIL) {
bsformat |= (1 << j);
+ }
}
ERR_FAIL_COND_V((bsformat) != (format & (RS::ARRAY_FORMAT_INDEX - 1)), ERR_INVALID_PARAMETER);
@@ -895,18 +828,16 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
int total_elem_size = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
offsets[i] = 0; //reset
- if (!(format & (1 << i))) // no array
+ if (!(format & (1 << i))) { // no array
continue;
+ }
int elem_size = 0;
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
Variant arr = p_arrays[0];
if (arr.get_type() == Variant::PACKED_VECTOR2_ARRAY) {
elem_size = 2;
@@ -924,7 +855,6 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
} break;
case RS::ARRAY_NORMAL: {
-
if (p_compress_format & ARRAY_COMPRESS_NORMAL) {
elem_size = sizeof(uint32_t);
} else {
@@ -942,7 +872,6 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
} break;
case RS::ARRAY_COLOR: {
-
if (p_compress_format & ARRAY_COMPRESS_COLOR) {
elem_size = sizeof(uint32_t);
} else {
@@ -967,24 +896,20 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
} break;
case RS::ARRAY_WEIGHTS: {
-
elem_size = sizeof(uint16_t) * 4;
} break;
case RS::ARRAY_BONES: {
-
elem_size = sizeof(uint16_t) * 4;
} break;
case RS::ARRAY_INDEX: {
-
if (index_array_len <= 0) {
ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
break;
}
/* determine whether using 16 or 32 bits indices */
if (array_len >= (1 << 16)) {
-
elem_size = 4;
} else {
@@ -1024,7 +949,6 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
Vector<Vector<uint8_t>> blend_shape_data;
for (int i = 0; i < p_blend_shapes.size(); i++) {
-
Vector<uint8_t> vertex_array_shape;
vertex_array_shape.resize(array_size);
Vector<uint8_t> noindex;
@@ -1038,7 +962,6 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
}
Vector<SurfaceData::LOD> lods;
if (index_array_len) {
-
List<Variant> keys;
p_lods.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
@@ -1093,7 +1016,6 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa
}
void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) {
-
SurfaceData sd;
Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format);
if (err != OK) {
@@ -1103,24 +1025,21 @@ void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_p
}
Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p_vertex_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len) const {
-
uint32_t offsets[ARRAY_MAX];
int total_elem_size = 0;
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
offsets[i] = 0; //reset
- if (!(p_format & (1 << i))) // no array
+ if (!(p_format & (1 << i))) { // no array
continue;
+ }
int elem_size = 0;
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
elem_size = 2;
} else {
@@ -1133,7 +1052,6 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
} break;
case RS::ARRAY_NORMAL: {
-
if (p_format & ARRAY_COMPRESS_NORMAL) {
elem_size = sizeof(uint32_t);
} else {
@@ -1151,7 +1069,6 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
} break;
case RS::ARRAY_COLOR: {
-
if (p_format & ARRAY_COMPRESS_COLOR) {
elem_size = sizeof(uint32_t);
} else {
@@ -1176,24 +1093,20 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
} break;
case RS::ARRAY_WEIGHTS: {
-
elem_size = sizeof(uint16_t) * 4;
} break;
case RS::ARRAY_BONES: {
-
elem_size = sizeof(uint16_t) * 4;
} break;
case RS::ARRAY_INDEX: {
-
if (p_index_len <= 0) {
ERR_PRINT("index_array_len==NO_INDEX_ARRAY");
break;
}
/* determine whether using 16 or 32 bits indices */
if (p_vertex_len >= (1 << 16)) {
-
elem_size = 4;
} else {
@@ -1217,25 +1130,20 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
const uint8_t *r = p_vertex_data.ptr();
for (int i = 0; i < RS::ARRAY_MAX; i++) {
-
- if (!(p_format & (1 << i)))
+ if (!(p_format & (1 << i))) {
continue;
+ }
switch (i) {
-
case RS::ARRAY_VERTEX: {
-
if (p_format & ARRAY_FLAG_USE_2D_VERTICES) {
-
Vector<Vector2> arr_2d;
arr_2d.resize(p_vertex_len);
{
-
Vector2 *w = arr_2d.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector2(v[0], v[1]);
}
@@ -1243,16 +1151,13 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
ret[i] = arr_2d;
} else {
-
Vector<Vector3> arr_3d;
arr_3d.resize(p_vertex_len);
{
-
Vector3 *w = arr_3d.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector3(v[0], v[1], v[2]);
}
@@ -1267,12 +1172,10 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
arr.resize(p_vertex_len);
if (p_format & ARRAY_COMPRESS_NORMAL) {
-
Vector3 *w = arr.ptrw();
const float multiplier = 1.f / 127.f;
for (int j = 0; j < p_vertex_len; j++) {
-
const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector3(float(v[0]) * multiplier, float(v[1]) * multiplier, float(v[2]) * multiplier);
}
@@ -1280,7 +1183,6 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector3 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector3(v[0], v[1], v[2]);
}
@@ -1297,14 +1199,12 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
float *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const int8_t *v = (const int8_t *)&r[j * total_elem_size + offsets[i]];
for (int k = 0; k < 4; k++) {
w[j * 4 + k] = float(v[k] / 127.0);
}
}
} else {
-
float *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
@@ -1319,16 +1219,13 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
} break;
case RS::ARRAY_COLOR: {
-
Vector<Color> arr;
arr.resize(p_vertex_len);
if (p_format & ARRAY_COMPRESS_COLOR) {
-
Color *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const uint8_t *v = (const uint8_t *)&r[j * total_elem_size + offsets[i]];
w[j] = Color(float(v[0] / 255.0), float(v[1] / 255.0), float(v[2] / 255.0), float(v[3] / 255.0));
}
@@ -1336,7 +1233,6 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Color *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
w[j] = Color(v[0], v[1], v[2], v[3]);
}
@@ -1345,25 +1241,20 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
ret[i] = arr;
} break;
case RS::ARRAY_TEX_UV: {
-
Vector<Vector2> arr;
arr.resize(p_vertex_len);
if (p_format & ARRAY_COMPRESS_TEX_UV) {
-
Vector2 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
}
} else {
-
Vector2 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector2(v[0], v[1]);
}
@@ -1377,20 +1268,16 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
arr.resize(p_vertex_len);
if (p_format & ARRAY_COMPRESS_TEX_UV2) {
-
Vector2 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector2(Math::halfptr_to_float(&v[0]), Math::halfptr_to_float(&v[1]));
}
} else {
-
Vector2 *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const float *v = (const float *)&r[j * total_elem_size + offsets[i]];
w[j] = Vector2(v[0], v[1]);
}
@@ -1400,14 +1287,12 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
} break;
case RS::ARRAY_WEIGHTS: {
-
Vector<float> arr;
arr.resize(p_vertex_len * 4);
{
float *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
for (int k = 0; k < 4; k++) {
w[j * 4 + k] = float(v[k] / 65535.0);
@@ -1419,14 +1304,12 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
} break;
case RS::ARRAY_BONES: {
-
Vector<int> arr;
arr.resize(p_vertex_len * 4);
int *w = arr.ptrw();
for (int j = 0; j < p_vertex_len; j++) {
-
const uint16_t *v = (const uint16_t *)&r[j * total_elem_size + offsets[i]];
for (int k = 0; k < 4; k++) {
w[j * 4 + k] = v[k];
@@ -1444,16 +1327,13 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector<int> arr;
arr.resize(p_index_len);
if (p_vertex_len < (1 << 16)) {
-
int *w = arr.ptrw();
for (int j = 0; j < p_index_len; j++) {
-
const uint16_t *v = (const uint16_t *)&ir[j * 2];
w[j] = *v;
}
} else {
-
int *w = arr.ptrw();
for (int j = 0; j < p_index_len; j++) {
@@ -1473,13 +1353,11 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
}
Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
-
SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
return mesh_create_arrays_from_surface_data(sd);
}
Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const {
-
SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary());
@@ -1514,7 +1392,6 @@ Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) con
}
Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
-
SurfaceData sd = mesh_get_surface(p_mesh, p_surface);
ERR_FAIL_COND_V(sd.vertex_count == 0, Array());
@@ -1541,7 +1418,6 @@ Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_sur
}
Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const {
-
Vector<uint8_t> vertex_data = p_data.vertex_data;
ERR_FAIL_COND_V(vertex_data.size() == 0, Array());
@@ -1567,7 +1443,6 @@ Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_su
#endif
ShaderLanguage::DataType RenderingServer::global_variable_type_get_shader_datatype(GlobalVariableType p_type) {
-
switch (p_type) {
case RS::GLOBAL_VAR_TYPE_BOOL:
return ShaderLanguage::TYPE_BOOL;
@@ -1631,7 +1506,6 @@ ShaderLanguage::DataType RenderingServer::global_variable_type_get_shader_dataty
}
void RenderingServer::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync);
ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0));
@@ -2021,6 +1895,10 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature);
ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes);
+ ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &RenderingServer::is_render_loop_enabled);
+ ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &RenderingServer::set_render_loop_enabled);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");
+
BIND_CONSTANT(NO_INDEX_ARRAY);
BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
BIND_CONSTANT(CANVAS_ITEM_Z_MIN);
@@ -2363,27 +2241,22 @@ void RenderingServer::_bind_methods() {
}
void RenderingServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) {
-
ERR_FAIL_COND(p_margins.size() != 4);
//canvas_item_add_style_box(p_item,p_rect,p_source,p_texture,Vector2(p_margins[0],p_margins[1]),Vector2(p_margins[2],p_margins[3]),true,p_modulate);
}
void RenderingServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
-
camera_set_orthogonal(p_camera, p_size, p_z_near, p_z_far);
}
-void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) {
-
+void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data) {
Vector<Vector3> vertices;
Vector<Vector3> normals;
for (int i = 0; i < p_mesh_data.faces.size(); i++) {
-
- const Geometry::MeshData::Face &f = p_mesh_data.faces[i];
+ const Geometry3D::MeshData::Face &f = p_mesh_data.faces[i];
for (int j = 2; j < f.indices.size(); j++) {
-
#define _ADD_VERTEX(m_idx) \
vertices.push_back(p_mesh_data.vertices[f.indices[m_idx]]); \
normals.push_back(f.plane.normal);
@@ -2402,8 +2275,7 @@ void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry
}
void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) {
-
- Geometry::MeshData mdata = Geometry::build_convex_mesh(p_planes);
+ Geometry3D::MeshData mdata = Geometry3D::build_convex_mesh(p_planes);
mesh_add_surface_from_mesh_data(p_mesh, mdata);
}
@@ -2412,15 +2284,21 @@ void RenderingServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vert
}
RID RenderingServer::instance_create2(RID p_base, RID p_scenario) {
-
RID instance = instance_create();
instance_set_base(instance, p_base);
instance_set_scenario(instance, p_scenario);
return instance;
}
-RenderingServer::RenderingServer() {
+bool RenderingServer::is_render_loop_enabled() const {
+ return render_loop_enabled;
+}
+
+void RenderingServer::set_render_loop_enabled(bool p_enabled) {
+ render_loop_enabled = p_enabled;
+}
+RenderingServer::RenderingServer() {
//ERR_FAIL_COND(singleton);
singleton = this;
@@ -2520,6 +2398,5 @@ RenderingServer::RenderingServer() {
}
RenderingServer::~RenderingServer() {
-
singleton = nullptr;
}
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index d426f205d0..56a8325630 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -32,7 +32,7 @@
#define RENDERING_SERVER_H
#include "core/image.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_3d.h"
#include "core/math/transform_2d.h"
#include "core/object.h"
#include "core/rid.h"
@@ -42,12 +42,12 @@
#include "servers/rendering/shader_language.h"
class RenderingServer : public Object {
-
GDCLASS(RenderingServer, Object);
static RenderingServer *singleton;
int mm_policy;
+ bool render_loop_enabled = true;
void _camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
void _canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate = Color(1, 1, 1));
@@ -244,7 +244,6 @@ public:
};
struct SurfaceData {
-
PrimitiveType primitive = PRIMITIVE_MAX;
uint32_t format = 0;
@@ -1210,7 +1209,7 @@ public:
virtual RID make_sphere_mesh(int p_lats, int p_lons, float p_radius);
- virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data);
+ virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data);
virtual void mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes);
virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
@@ -1231,6 +1230,9 @@ public:
virtual bool is_low_end() const = 0;
+ bool is_render_loop_enabled() const;
+ void set_render_loop_enabled(bool p_enabled);
+
RenderingServer();
virtual ~RenderingServer();
};
diff --git a/servers/xr/xr_interface.cpp b/servers/xr/xr_interface.cpp
index c1233ae810..e9858416ec 100644
--- a/servers/xr/xr_interface.cpp
+++ b/servers/xr/xr_interface.cpp
@@ -122,7 +122,7 @@ XRInterface::XRInterface() {
tracking_state = XR_UNKNOWN_TRACKING;
};
-XRInterface::~XRInterface(){};
+XRInterface::~XRInterface() {}
// optional render to external texture which enhances performance on those platforms that require us to submit our end result into special textures.
unsigned int XRInterface::get_external_texture_for_eye(XRInterface::Eyes p_eye) {
@@ -134,9 +134,9 @@ bool XRInterface::get_anchor_detection_is_enabled() const {
return false;
};
-void XRInterface::set_anchor_detection_is_enabled(bool p_enable){
+void XRInterface::set_anchor_detection_is_enabled(bool p_enable) {
// don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc.
-};
+}
int XRInterface::get_camera_feed_id() {
// don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc.
diff --git a/servers/xr/xr_positional_tracker.cpp b/servers/xr/xr_positional_tracker.cpp
index 20853c9027..ad5cee92ea 100644
--- a/servers/xr/xr_positional_tracker.cpp
+++ b/servers/xr/xr_positional_tracker.cpp
@@ -232,7 +232,3 @@ XRPositionalTracker::XRPositionalTracker() {
hand = TRACKER_HAND_UNKNOWN;
rumble = 0.0;
};
-
-XRPositionalTracker::~XRPositionalTracker(){
-
-};
diff --git a/servers/xr/xr_positional_tracker.h b/servers/xr/xr_positional_tracker.h
index d9d1f909e9..515359e9b1 100644
--- a/servers/xr/xr_positional_tracker.h
+++ b/servers/xr/xr_positional_tracker.h
@@ -96,7 +96,7 @@ public:
Transform get_transform(bool p_adjust_by_reference_frame) const;
XRPositionalTracker();
- ~XRPositionalTracker();
+ ~XRPositionalTracker() {}
};
VARIANT_ENUM_CAST(XRPositionalTracker::TrackerHand);
diff --git a/servers/xr_server.cpp b/servers/xr_server.cpp
index a93b99025f..09800443b7 100644
--- a/servers/xr_server.cpp
+++ b/servers/xr_server.cpp
@@ -152,7 +152,6 @@ void XRServer::add_interface(const Ref<XRInterface> &p_interface) {
ERR_FAIL_COND(p_interface.is_null());
for (int i = 0; i < interfaces.size(); i++) {
-
if (interfaces[i] == p_interface) {
ERR_PRINT("Interface was already added");
return;
@@ -168,9 +167,7 @@ void XRServer::remove_interface(const Ref<XRInterface> &p_interface) {
int idx = -1;
for (int i = 0; i < interfaces.size(); i++) {
-
if (interfaces[i] == p_interface) {
-
idx = i;
break;
};
@@ -197,9 +194,7 @@ Ref<XRInterface> XRServer::get_interface(int p_index) const {
Ref<XRInterface> XRServer::find_interface(const String &p_name) const {
int idx = -1;
for (int i = 0; i < interfaces.size(); i++) {
-
if (interfaces[i]->get_name() == p_name) {
-
idx = i;
break;
};
@@ -277,9 +272,7 @@ void XRServer::remove_tracker(XRPositionalTracker *p_tracker) {
int idx = -1;
for (int i = 0; i < trackers.size(); i++) {
-
if (trackers[i] == p_tracker) {
-
idx = i;
break;
};
diff --git a/thirdparty/README.md b/thirdparty/README.md
index c000133fe7..c69ca17fd0 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -184,15 +184,13 @@ Patches in the `patches` directory should be re-applied after updates.
## jpeg-compressor
- Upstream: https://github.com/richgel999/jpeg-compressor
-- Version: 2.00 (1eb17d558b9d3b7442d256642a5745974e9eeb1e, 2020)
+- Version: 2.00 (aeb7d3b463aa8228b87a28013c15ee50a7e6fcf3, 2020)
- License: Public domain
Files extracted from upstream source:
- `jpgd*.{c,h}`
-Patches in the `patches` directory should be re-applied after updates.
-
## libogg
@@ -386,7 +384,7 @@ Collection of single-file libraries used in Godot components.
* License: Apache 2.0
- `r128.h`
* Upstream: https://github.com/fahickman/r128
- * Version: 1.4.3 (2019)
+ * Version: git (423f693617faafd01de21e92818add4208eb8bd1, 2020)
* License: Public Domain
- `smaz.{c,h}`
* Upstream: https://github.com/antirez/smaz
@@ -448,12 +446,32 @@ Files extracted from the upstream source:
## oidn
- Upstream: https://github.com/OpenImageDenoise/oidn
-- Version: TBD
+- Version: 1.1.0 (c58c5216db05ceef4cde5a096862f2eeffd14c06, 2019)
- License: Apache 2.0
Files extracted from upstream source:
-- TBD
+common/* (except tasking.* and CMakeLists.txt)
+core/*
+include/OpenImageDenoise/* (except version.h.in)
+LICENSE.txt
+mkl-dnn/include/*
+mkl-dnn/src/* (except CMakeLists.txt)
+weights/rtlightmap_hdr.tza
+scripts/resource_to_cpp.py
+
+Modified files:
+Modifications are marked with `// -- GODOT start --` and `// -- GODOT end --`.
+Patch files are provided in `oidn/patches/`.
+
+core/autoencoder.cpp
+core/autoencoder.h
+core/common.h
+core/device.cpp
+core/device.h
+core/transfer_function.cpp
+
+scripts/resource_to_cpp.py (used in modules/denoise/resource_to_cpp.py)
## opus
@@ -618,7 +636,7 @@ File extracted from upstream release tarball:
## xatlas
- Upstream: https://github.com/jpcy/xatlas
-- Version: git (e12ea82, 2019)
+- Version: git (470576d3516f7e6d8b4554e7c941194a935969fd, 2020)
- License: MIT
Files extracted from upstream source:
diff --git a/thirdparty/jpeg-compressor/patches/fix-msvc-sse2-detection.patch b/thirdparty/jpeg-compressor/patches/fix-msvc-sse2-detection.patch
deleted file mode 100644
index 830b03b0c0..0000000000
--- a/thirdparty/jpeg-compressor/patches/fix-msvc-sse2-detection.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From ae74fa2fcdef8ec44b925a649f66e8cbefce8315 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <rverschelde@gmail.com>
-Date: Thu, 7 May 2020 12:14:09 +0200
-Subject: [PATCH] Fix detection of SSE2 with Visual Studio
-
-The previous code assumed that SSE2 is available when building with
-Visual Studio, but that's not accurate on ARM with UWP.
-
-SSE2 could also be enabled on x86 if `_M_IX86_FP == 2`, but it requires
-checking first that it's not actually set to 2 for AVX, AVX2 or AVX512
-(see https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019),
-so I left it out for this quick fix.
----
- jpgd.cpp | 16 +++++++---------
- 1 file changed, 7 insertions(+), 9 deletions(-)
-
-diff --git a/jpgd.cpp b/jpgd.cpp
-index 91e66ad..db1f3b4 100644
---- a/jpgd.cpp
-+++ b/jpgd.cpp
-@@ -37,16 +37,14 @@
-
- #ifndef JPGD_USE_SSE2
-
-- #if defined(__GNUC__)
--
-- #if (defined(__x86_64__) || defined(_M_X64))
-- #if defined(__SSE2__)
-- #define JPGD_USE_SSE2 (1)
-- #endif
-+ #if defined(__GNUC__)
-+ #if defined(__SSE2__)
-+ #define JPGD_USE_SSE2 (1)
-+ #endif
-+ #elif defined(_MSC_VER)
-+ #if defined(_M_X64)
-+ #define JPGD_USE_SSE2 (1)
- #endif
--
-- #else
-- #define JPGD_USE_SSE2 (1)
- #endif
-
- #endif
diff --git a/thirdparty/jpeg-compressor/patches/fix-msvc2017-build.patch b/thirdparty/jpeg-compressor/patches/fix-msvc2017-build.patch
deleted file mode 100644
index 7b338de084..0000000000
--- a/thirdparty/jpeg-compressor/patches/fix-msvc2017-build.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff --git a/thirdparty/jpeg-compressor/jpgd.cpp b/thirdparty/jpeg-compressor/jpgd.cpp
-index a0c494db61..257d0b7574 100644
---- a/thirdparty/jpeg-compressor/jpgd.cpp
-+++ b/thirdparty/jpeg-compressor/jpgd.cpp
-@@ -2126,7 +2126,7 @@ namespace jpgd {
-
- int jpeg_decoder::decode_next_mcu_row()
- {
-- if (setjmp(m_jmp_state))
-+ if (::setjmp(m_jmp_state))
- return JPGD_FAILED;
-
- const bool chroma_y_filtering = ((m_flags & cFlagBoxChromaFiltering) == 0) && ((m_scan_type == JPGD_YH2V2) || (m_scan_type == JPGD_YH1V2));
-@@ -3042,7 +3042,7 @@ namespace jpgd {
-
- jpeg_decoder::jpeg_decoder(jpeg_decoder_stream* pStream, uint32_t flags)
- {
-- if (setjmp(m_jmp_state))
-+ if (::setjmp(m_jmp_state))
- return;
- decode_init(pStream, flags);
- }
-@@ -3055,7 +3055,7 @@ namespace jpgd {
- if (m_error_code)
- return JPGD_FAILED;
-
-- if (setjmp(m_jmp_state))
-+ if (::setjmp(m_jmp_state))
- return JPGD_FAILED;
-
- decode_start();
diff --git a/thirdparty/misc/cubemap_coeffs.h b/thirdparty/misc/cubemap_coeffs.h
index 1db03ce7c4..15e4e1664b 100644
--- a/thirdparty/misc/cubemap_coeffs.h
+++ b/thirdparty/misc/cubemap_coeffs.h
@@ -21,8 +21,8 @@
#ifndef CUBEMAP_COEFFS_H
#define CUBEMAP_COEFFS_H
-const float low_quality_coeffs[7][5][6][4] = { { { { 0.0002037563, 0.0045063655, -0.0016408688, 0.00012037493 }, { -9.1834951e-05, -0.008947532, -8.1524405e-05, -3.9080094e-05 }, { -2.6038267e-05, -6.8409667e-05, 7.2175702e-05, 0.25492775 }, { -9.9426044e-05, 0.0025427756, -0.00074437925, 1.1773191e-05 }, { -3.2668211e-05, 0.0026930659, -4.824934e-05, -0.0006835048 }, { -0.0002864144, -0.0032220854, 0.0021558286, -0.00014573736 } }, { { 0.00030683201, 0.0026819548, -0.00060011756, -0.0067169226 }, { -0.0030993251, 0.0098575575, 0.0022416671, -8.9075401e-05 }, { 0.00052405626, 0.00057860515, 0.00011654518, -0.048018609 }, { 0.00010850967, -0.0088443512, -0.0018168095, 8.6633128e-05 }, { 0.003333989, -0.0050956447, -8.0414612e-05, 0.0049721239 }, { -4.0961436e-05, -8.5486984e-05, 0.0058683066, 2.2978359e-05 } }, { { 0.99999993, 0.99998625, 0.99999847, 0.99997743 }, { 0.99999519, 0.99991138, 0.99999748, 1 }, { 0.99999986, 0.99999983, 0.99999999, 0.96576708 }, { 0.99999999, 0.99995765, 0.99999807, 1 }, { 0.99999444, 0.99998339, 1, 0.99998741 }, { 0.99999996, 0.99999481, 0.99998046, 0.99999999 } }, { { -0.32267524, -0.65409377, -1.4666488, 0.87153305 }, { -1.264365, 0.89880861, -1.2245906, -0.88501403 }, { -0.31118682, -0.086150323, -0.58811532, 1.1317711 }, { -1.2193493, 1.250379, -1.0871569, -0.12694096 }, { -0.4012249, -0.47436307, -0.59661001, 2.7313005 }, { -1.3109856, 0.60929855, 0.55672643, -0.39880018 } }, { { 0.93273157, 0.59530745, 1.1994788, 0.19102276 }, { 1.2272239, 0.23245736, 1.2577607, 2.5491008 }, { 1.1210098, 0.83074953, 1.3049282, -0.001940633 }, { 1.5839111, 0.10520816, 1.150458, 2.3251789 }, { 0.688692, 0.59807498, 1.3374877, 0.095746692 }, { 1.3054173, 0.36604721, 0.065870226, 1.6496907 } } }, { { { 0.10348445, -4.6771514e-07, -0.011513131, 8.8921052e-05 }, { -0.042152043, 0.013143535, 0.00029120107, 0.036661611 }, { -0.04516036, 0.011438473, -0.0099289792, -0.011707897 }, { -0.034779497, 0.0090981166, -5.4202726e-05, 0.038592793 }, { -0.0071967376, -0.0056614418, -0.012278945, 0.0056867462 }, { -0.037678514, 0.011570177, 0.00029044557, 0.038583909 } }, { { 0.048320869, 1.4603673e-05, 0.0092672368, 0.00033289199 }, { 0.0071001761, -0.0090106091, -0.0027305905, -0.00221479 }, { -0.0027204116, 0.00017921587, 0.015296357, -0.00010306185 }, { 0.0079350203, -0.014772431, -1.2410913e-05, -0.0062296897 }, { 0.025087691, 0.00086046427, 0.015034685, -0.00078224706 }, { 0.00074587265, -0.014602074, 0.00027338224, -0.012848552 } }, { { 0.99345662, 1, 0.99989078, 0.99999994 }, { 0.99908598, 0.99987302, 0.99999623, 0.99932528 }, { 0.99897605, 0.99993456, 0.9998337, 0.99993145 }, { 0.99936351, 0.99984949, 1, 0.9992356 }, { 0.99965935, 0.9999836, 0.99981158, 0.99998352 }, { 0.99928963, 0.99982644, 0.99999992, 0.99917276 } }, { { 3.6882765, 0.15963861, 0.55983965, 0.4075649 }, { 2.1169304, 0.56463157, 0.52957047, 2.0117964 }, { 3.1080461, 0.09682931, 0.42125986, 0.089254784 }, { 1.4247315, 0.48411378, -0.17039102, 1.7431674 }, { 4.0339531, 0.14046159, 0.89848909, 0.011661811 }, { 1.9787852, 0.61750145, 0.63514194, 1.9359003 } }, { { 0.030848793, 1.4472743, 1.4356825, 1.4078009 }, { 0.37639678, 1.0793106, 1.1945413, 0.43983395 }, { 0.27451605, 1.5256415, 1.016769, 1.4850575 }, { 0.54580883, 1.1332879, 3.1331784, 0.60772955 }, { 0.11785158, 1.3928946, 0.94998805, 1.0377182 }, { 0.2842108, 1.0026911, 1.9064553, 0.27147854 } } }, { { { -0.096789259, 0.10326967, 0.0011799959, -0.03077328 }, { 0.08342021, 0.033260738, -0.00045864451, -0.021450568 }, { -0.093369441, -0.05807574, -0.033745214, 0.023817208 }, { 0.056747754, 0.031140512, 0.00019362509, -0.023727797 }, { -0.084538386, -0.040545412, -0.0076838784, 0.03424599 }, { 0.074312056, 0.027619787, 0.0015509082, -0.031043528 } }, { { -0.0085160473, -0.012179292, 0.0049910118, 0.020224799 }, { 0.022559343, -0.016273333, -0.0069382139, 0.00058083224 }, { -0.001115062, 0.035002846, -0.0038974773, -0.039378629 }, { 0.0014921617, -0.00058523872, -0.0011606685, 0.02807528 }, { -0.021454809, 0.052957852, -0.0022083677, -0.027956663 }, { -0.016486487, -0.0040233682, 0.00029949558, 0.021924605 } }, { { 0.99526846, 0.99457883, 0.99998685, 0.99932175 }, { 0.99625908, 0.99931422, 0.99997583, 0.99976974 }, { 0.99563091, 0.99769836, 0.99942287, 0.99894047 }, { 0.99838743, 0.99951485, 0.99999931, 0.99932416 }, { 0.99618922, 0.99777329, 0.99996804, 0.99902234 }, { 0.99709875, 0.9996104, 0.99999875, 0.99927754 } }, { { 3.0342011, 4.8022834, 1.3814123, 1.5280754 }, { 2.9043837, 1.7325954, 1.422223, 2.0569263 }, { 3.0358722, 5.3331504, 1.5680146, 1.6079289 }, { 3.2062833, 1.5368069, 1.0484709, 1.5399477 }, { 2.4471653, 4.0916696, 1.5060688, 1.5807009 }, { 2.6932695, 1.5161537, 1.3991175, 1.6301918 } }, { { 0.50787578, 0.17735471, 1.4006765, 1.0878482 }, { 0.69514518, 1.6765187, 1.2224869, 1.3461327 }, { 0.71381288, 0.17509216, 1.2712934, 0.94575821 }, { 1.1817337, 1.796984, 1.8671538, 1.5708691 }, { 0.55621228, 0.38291359, 1.4128781, 0.82625349 }, { 0.72441647, 1.005794, 1.5522327, 1.6032524 } } }, { { { -0.00041301094, -0.095882618, 0.26932618, -0.25137214 }, { 0.13737415, -0.12694293, -0.0090389663, 0.07227623 }, { -0.005236407, -0.0072961249, 0.27776083, -0.19536433 }, { 0.12781899, -0.042881667, -0.095979169, 0.088937396 }, { 0.037496084, -0.090547583, 0.22112334, -0.21930294 }, { 0.13353408, -0.084346121, -0.011365728, 0.043459312 } }, { { -0.05799135, -0.048612281, 0.02422989, 0.015536268 }, { -0.083144241, 0.039381032, 0.018705957, 0.029297922 }, { 0.026364989, -0.041927591, 0.036718516, 0.0050376168 }, { -0.11562256, 0.043521976, -0.014481644, 0.01529188 }, { -0.047859898, -0.057779647, -0.053171395, -0.0063193506 }, { -0.028781196, 0.041145059, -0.00018523142, 0.053524246 } }, { { 0.998317, 0.99420489, 0.96274416, 0.96776581 }, { 0.98702349, 0.99112796, 0.99978417, 0.99695425 }, { 0.99963867, 0.99909401, 0.95994827, 0.9807178 }, { 0.98503489, 0.99813175, 0.99527799, 0.99591983 }, { 0.99815003, 0.99421459, 0.97379529, 0.97563635 }, { 0.99062621, 0.99558667, 0.99993539, 0.99762039 } }, { { 2.3221943, 2.5383575, 4.3177232, 4.2016467 }, { 3.1936529, 3.0443024, 2.548962, 2.7636456 }, { 2.5923827, 2.3497949, 4.2471014, 4.1975975 }, { 3.3748785, 3.2836577, 2.9220414, 2.7175317 }, { 2.3290083, 2.5560991, 4.3572168, 4.4372585 }, { 3.1512055, 3.2863613, 2.4475378, 2.3620003 } }, { { 0.62833231, 0.52378061, 0.55845033, 0.64883444 }, { 0.76905594, 1.1017801, 1.8714048, 1.5664383 }, { 1.5283278, 1.2423369, 0.62247385, 1.0341956 }, { 0.77484548, 1.6866409, 1.0307399, 1.4224643 }, { 0.85627405, 0.72516079, 0.70094339, 0.7547877 }, { 1.202842, 1.7650605, 1.5938526, 0.97031337 } } }, { { { -0.078108035, -0.049518839, 0.26950139, -0.51522828 }, { 0.43015518, -0.045354216, 0.094550359, -0.2395012 }, { -0.079900522, -0.082582235, 0.24464909, -0.5234896 }, { 0.38422945, -0.023833644, 0.07334288, -0.22827313 }, { -0.075370379, -0.05156594, 0.19883182, -0.45064193 }, { 0.46285395, 0.021899343, 0.10155287, -0.25974773 } }, { { 0.068681419, -0.32175988, 0.15143274, -0.0066205388 }, { -0.17060226, 0.31051319, -0.080511981, -0.1593209 }, { 0.08167251, -0.32517768, 0.10937023, -0.06941926 }, { -0.14580685, 0.32474959, -0.081718057, -0.11068378 }, { 0.053961394, -0.29322836, 0.10408839, -0.02243046 }, { -0.030598471, 0.34332821, -0.091528353, -0.16299796 } }, { { 0.99457629, 0.9455255, 0.95101899, 0.85702741 }, { 0.88648824, 0.94948647, 0.99225906, 0.95773484 }, { 0.99345131, 0.94204015, 0.96342357, 0.84919939 }, { 0.9116513, 0.94549969, 0.99395321, 0.96728511 }, { 0.99569447, 0.95465076, 0.97449039, 0.89242295 }, { 0.88590629, 0.93896015, 0.99061071, 0.95182077 } }, { { 3.6380949, 4.1749529, 4.1351439, 4.8389883 }, { 5.256362, 4.2027959, 3.6096892, 3.9848645 }, { 3.5689427, 3.8620869, 4.0023981, 4.8268584 }, { 5.1128497, 4.468934, 3.5851596, 4.047485 }, { 3.7014988, 4.1310058, 4.2446872, 5.3049323 }, { 4.8659881, 4.3133002, 3.4582876, 3.8863853 } }, { { 1.6276316, 0.7747672, 1.0485958, 0.73900224 }, { 0.72010795, 0.65403093, 1.3179681, 0.65610074 }, { 1.5881174, 0.55108527, 1.0509725, 0.72153362 }, { 1.1389053, 1.0905142, 1.6661598, 0.9987548 }, { 1.977914, 0.83001686, 1.0571479, 0.80249183 }, { 0.94107069, 0.80840873, 0.95379751, 0.50386367 } } }, { { { 0.015525428, -0.48038019, -0.021799698, 0.43629156 }, { 0.045681247, -0.55039024, -0.54573329, 0.57817853 }, { -0.045869129, -0.42209953, -0.14040829, 0.37787106 }, { 0.66327604, -0.70070311, -0.55261635, 0.63446196 }, { 0.015397585, -0.43515767, -0.021927897, 0.4203714 }, { 0.85681772, -0.65394729, -0.67557236, 0.60104142 } }, { { -0.31503888, -0.26745648, 0.26817896, 0.26548747 }, { -0.93282124, -0.033621213, 0.68374802, -0.10858524 }, { -0.21723689, -0.17935495, 0.38521982, 0.2578335 }, { -0.39913153, 0.23555359, 0.59589456, -0.19075103 }, { -0.28851798, -0.24142459, 0.28279261, 0.24766617 }, { -0.29435977, -0.25850549, 0.57790878, -0.200546 } }, { { 0.94895177, 0.83528552, 0.96312243, 0.85974768 }, { 0.35743218, 0.8342303, 0.48442112, 0.80865248 }, { 0.97504059, 0.88863029, 0.9120807, 0.88923301 }, { 0.63305523, 0.67344611, 0.58268761, 0.74904744 }, { 0.95735066, 0.86738225, 0.9589304, 0.87289711 }, { 0.42333878, 0.71100482, 0.45784651, 0.77364753 } }, { { 5.3641275, 5.2550422, 5.3103777, 5.2851215 }, { 5.2657045, 6.2095784, 6.9549598, 4.9205516 }, { 5.163385, 5.3141038, 4.9907618, 5.3583852 }, { 6.1257061, 6.1102338, 6.9549598, 5.3129951 }, { 5.3138838, 5.3257842, 5.3133783, 5.2687156 }, { 5.8915091, 6.153324, 6.9549598, 4.9568971 } }, { { 3.1221918, 1.1882615, 2.6991784, 1.1185048 }, { -0.2322432, -0.16590163, 0.088416958, 0.057399579 }, { 3.4395383, 1.5836276, 2.6242352, 1.2873336 }, { -0.23767634, -0.79425452, 0.20477899, 0.40461516 }, { 2.2521751, 1.1933374, 2.3309484, 1.0185309 }, { -0.099258385, -0.2173726, 0.0736866, 0.15470436 } } }, { { { 0.066050217, -0.33053278, -0.13771479, 0.33278465 }, { 0.00084467977, -0.50077778, -0.30083482, 0.6494273 }, { 0.24880159, -0.30354993, -0.15417892, 0.38203296 }, { -0.073325098, -0.4778777, 0.10779844, 0.66683723 }, { 0.15703809, -0.36335455, -0.15657631, 0.35926503 }, { 0.26127617, -0.29524368, -0.14490804, 0.65461301 } }, { { -0.57970022, -0.33939622, 0.72169742, 0.320959 }, { -0.38698206, -0.12730306, 0.65810895, 0.026509232 }, { -0.6199708, -0.34745658, 0.68683659, 0.34547285 }, { -0.3613378, -0.14006845, 0.65917895, 0.038446867 }, { -0.57778101, -0.35057776, 0.57837882, 0.36488991 }, { -0.50051482, -0.019174387, 0.50816239, 0.02682636 } }, { { 0.8121484, 0.88065787, 0.67837119, 0.88670158 }, { 0.92208686, 0.85616327, 0.69021085, -0.75996148 }, { 0.74413303, 0.88720424, 0.71027063, 0.85714604 }, { 0.92954743, 0.86718726, 0.74421946, -0.74421095 }, { 0.80094204, 0.86317363, 0.8006009, 0.85894353 }, { 0.82536033, 0.95522956, 0.8489833, -0.75548802 } }, { { 5.7725061, 5.1565901, 5.6224483, 5.0847054 }, { 5.7717118, 6.4180057, 6.9797014, -0.03290957 }, { 5.7847117, 5.2015529, 5.614561, 5.2019388 }, { 6.2613999, 6.5807982, 6.9797014, -0.032764603 }, { 5.823775, 5.2332343, 5.826694, 5.197143 }, { 6.3463188, 5.8174311, 6.9797014, -0.032766769 } }, { { 2.96787, 1.3557735, 2.0749129, 1.3066609 }, { -0.92782801, 0.0079162579, -0.33479446, 2.699659e-05 }, { 2.1997063, 3.1083252, 2.6810949, 1.8276262 }, { -0.48654719, -0.10954189, -0.32175132, 5.490092e-05 }, { 3.1970446, 1.787085, 3.062849, 1.6274811 }, { -0.78882801, -0.34050184, -0.59962127, 3.6554198e-05 } } } };
+const float low_quality_coeffs[7][5][6][4] = { { { { 0.0002037563f, 0.0045063655f, -0.0016408688f, 0.00012037493f }, { -9.1834951e-05f, -0.008947532f, -8.1524405e-05f, -3.9080094e-05f }, { -2.6038267e-05f, -6.8409667e-05f, 7.2175702e-05f, 0.25492775f }, { -9.9426044e-05f, 0.0025427756f, -0.00074437925f, 1.1773191e-05f }, { -3.2668211e-05f, 0.0026930659f, -4.824934e-05f, -0.0006835048f }, { -0.0002864144f, -0.0032220854f, 0.0021558286f, -0.00014573736f } }, { { 0.00030683201f, 0.0026819548f, -0.00060011756f, -0.0067169226f }, { -0.0030993251f, 0.0098575575f, 0.0022416671f, -8.9075401e-05f }, { 0.00052405626f, 0.00057860515f, 0.00011654518f, -0.048018609f }, { 0.00010850967f, -0.0088443512f, -0.0018168095f, 8.6633128e-05f }, { 0.003333989f, -0.0050956447f, -8.0414612e-05f, 0.0049721239f }, { -4.0961436e-05f, -8.5486984e-05f, 0.0058683066f, 2.2978359e-05f } }, { { 0.99999993f, 0.99998625f, 0.99999847f, 0.99997743f }, { 0.99999519f, 0.99991138f, 0.99999748f, 1.0f }, { 0.99999986f, 0.99999983f, 0.99999999f, 0.96576708f }, { 0.99999999f, 0.99995765f, 0.99999807f, 1.0f }, { 0.99999444f, 0.99998339f, 1.0f, 0.99998741f }, { 0.99999996f, 0.99999481f, 0.99998046f, 0.99999999f } }, { { -0.32267524f, -0.65409377f, -1.4666488f, 0.87153305f }, { -1.264365f, 0.89880861f, -1.2245906f, -0.88501403f }, { -0.31118682f, -0.086150323f, -0.58811532f, 1.1317711f }, { -1.2193493f, 1.250379f, -1.0871569f, -0.12694096f }, { -0.4012249f, -0.47436307f, -0.59661001f, 2.7313005f }, { -1.3109856f, 0.60929855f, 0.55672643f, -0.39880018f } }, { { 0.93273157f, 0.59530745f, 1.1994788f, 0.19102276f }, { 1.2272239f, 0.23245736f, 1.2577607f, 2.5491008f }, { 1.1210098f, 0.83074953f, 1.3049282f, -0.001940633f }, { 1.5839111f, 0.10520816f, 1.150458f, 2.3251789f }, { 0.688692f, 0.59807498f, 1.3374877f, 0.095746692f }, { 1.3054173f, 0.36604721f, 0.065870226f, 1.6496907f } } }, { { { 0.10348445f, -4.6771514e-07f, -0.011513131f, 8.8921052e-05f }, { -0.042152043f, 0.013143535f, 0.00029120107f, 0.036661611f }, { -0.04516036f, 0.011438473f, -0.0099289792f, -0.011707897f }, { -0.034779497f, 0.0090981166f, -5.4202726e-05f, 0.038592793f }, { -0.0071967376f, -0.0056614418f, -0.012278945f, 0.0056867462f }, { -0.037678514f, 0.011570177f, 0.00029044557f, 0.038583909f } }, { { 0.048320869f, 1.4603673e-05f, 0.0092672368f, 0.00033289199f }, { 0.0071001761f, -0.0090106091f, -0.0027305905f, -0.00221479f }, { -0.0027204116f, 0.00017921587f, 0.015296357f, -0.00010306185f }, { 0.0079350203f, -0.014772431f, -1.2410913e-05f, -0.0062296897f }, { 0.025087691f, 0.00086046427f, 0.015034685f, -0.00078224706f }, { 0.00074587265f, -0.014602074f, 0.00027338224f, -0.012848552f } }, { { 0.99345662f, 1.0f, 0.99989078f, 0.99999994f }, { 0.99908598f, 0.99987302f, 0.99999623f, 0.99932528f }, { 0.99897605f, 0.99993456f, 0.9998337f, 0.99993145f }, { 0.99936351f, 0.99984949f, 1.0f, 0.9992356f }, { 0.99965935f, 0.9999836f, 0.99981158f, 0.99998352f }, { 0.99928963f, 0.99982644f, 0.99999992f, 0.99917276f } }, { { 3.6882765f, 0.15963861f, 0.55983965f, 0.4075649f }, { 2.1169304f, 0.56463157f, 0.52957047f, 2.0117964f }, { 3.1080461f, 0.09682931f, 0.42125986f, 0.089254784f }, { 1.4247315f, 0.48411378f, -0.17039102f, 1.7431674f }, { 4.0339531f, 0.14046159f, 0.89848909f, 0.011661811f }, { 1.9787852f, 0.61750145f, 0.63514194f, 1.9359003f } }, { { 0.030848793f, 1.4472743f, 1.4356825f, 1.4078009f }, { 0.37639678f, 1.0793106f, 1.1945413f, 0.43983395f }, { 0.27451605f, 1.5256415f, 1.016769f, 1.4850575f }, { 0.54580883f, 1.1332879f, 3.1331784f, 0.60772955f }, { 0.11785158f, 1.3928946f, 0.94998805f, 1.0377182f }, { 0.2842108f, 1.0026911f, 1.9064553f, 0.27147854f } } }, { { { -0.096789259f, 0.10326967f, 0.0011799959f, -0.03077328f }, { 0.08342021f, 0.033260738f, -0.00045864451f, -0.021450568f }, { -0.093369441f, -0.05807574f, -0.033745214f, 0.023817208f }, { 0.056747754f, 0.031140512f, 0.00019362509f, -0.023727797f }, { -0.084538386f, -0.040545412f, -0.0076838784f, 0.03424599f }, { 0.074312056f, 0.027619787f, 0.0015509082f, -0.031043528f } }, { { -0.0085160473f, -0.012179292f, 0.0049910118f, 0.020224799f }, { 0.022559343f, -0.016273333f, -0.0069382139f, 0.00058083224f }, { -0.001115062f, 0.035002846f, -0.0038974773f, -0.039378629f }, { 0.0014921617f, -0.00058523872f, -0.0011606685f, 0.02807528f }, { -0.021454809f, 0.052957852f, -0.0022083677f, -0.027956663f }, { -0.016486487f, -0.0040233682f, 0.00029949558f, 0.021924605f } }, { { 0.99526846f, 0.99457883f, 0.99998685f, 0.99932175f }, { 0.99625908f, 0.99931422f, 0.99997583f, 0.99976974f }, { 0.99563091f, 0.99769836f, 0.99942287f, 0.99894047f }, { 0.99838743f, 0.99951485f, 0.99999931f, 0.99932416f }, { 0.99618922f, 0.99777329f, 0.99996804f, 0.99902234f }, { 0.99709875f, 0.9996104f, 0.99999875f, 0.99927754f } }, { { 3.0342011f, 4.8022834f, 1.3814123f, 1.5280754f }, { 2.9043837f, 1.7325954f, 1.422223f, 2.0569263f }, { 3.0358722f, 5.3331504f, 1.5680146f, 1.6079289f }, { 3.2062833f, 1.5368069f, 1.0484709f, 1.5399477f }, { 2.4471653f, 4.0916696f, 1.5060688f, 1.5807009f }, { 2.6932695f, 1.5161537f, 1.3991175f, 1.6301918f } }, { { 0.50787578f, 0.17735471f, 1.4006765f, 1.0878482f }, { 0.69514518f, 1.6765187f, 1.2224869f, 1.3461327f }, { 0.71381288f, 0.17509216f, 1.2712934f, 0.94575821f }, { 1.1817337f, 1.796984f, 1.8671538f, 1.5708691f }, { 0.55621228f, 0.38291359f, 1.4128781f, 0.82625349f }, { 0.72441647f, 1.005794f, 1.5522327f, 1.6032524f } } }, { { { -0.00041301094f, -0.095882618f, 0.26932618f, -0.25137214f }, { 0.13737415f, -0.12694293f, -0.0090389663f, 0.07227623f }, { -0.005236407f, -0.0072961249f, 0.27776083f, -0.19536433f }, { 0.12781899f, -0.042881667f, -0.095979169f, 0.088937396f }, { 0.037496084f, -0.090547583f, 0.22112334f, -0.21930294f }, { 0.13353408f, -0.084346121f, -0.011365728f, 0.043459312f } }, { { -0.05799135f, -0.048612281f, 0.02422989f, 0.015536268f }, { -0.083144241f, 0.039381032f, 0.018705957f, 0.029297922f }, { 0.026364989f, -0.041927591f, 0.036718516f, 0.0050376168f }, { -0.11562256f, 0.043521976f, -0.014481644f, 0.01529188f }, { -0.047859898f, -0.057779647f, -0.053171395f, -0.0063193506f }, { -0.028781196f, 0.041145059f, -0.00018523142f, 0.053524246f } }, { { 0.998317f, 0.99420489f, 0.96274416f, 0.96776581f }, { 0.98702349f, 0.99112796f, 0.99978417f, 0.99695425f }, { 0.99963867f, 0.99909401f, 0.95994827f, 0.9807178f }, { 0.98503489f, 0.99813175f, 0.99527799f, 0.99591983f }, { 0.99815003f, 0.99421459f, 0.97379529f, 0.97563635f }, { 0.99062621f, 0.99558667f, 0.99993539f, 0.99762039f } }, { { 2.3221943f, 2.5383575f, 4.3177232f, 4.2016467f }, { 3.1936529f, 3.0443024f, 2.548962f, 2.7636456f }, { 2.5923827f, 2.3497949f, 4.2471014f, 4.1975975f }, { 3.3748785f, 3.2836577f, 2.9220414f, 2.7175317f }, { 2.3290083f, 2.5560991f, 4.3572168f, 4.4372585f }, { 3.1512055f, 3.2863613f, 2.4475378f, 2.3620003f } }, { { 0.62833231f, 0.52378061f, 0.55845033f, 0.64883444f }, { 0.76905594f, 1.1017801f, 1.8714048f, 1.5664383f }, { 1.5283278f, 1.2423369f, 0.62247385f, 1.0341956f }, { 0.77484548f, 1.6866409f, 1.0307399f, 1.4224643f }, { 0.85627405f, 0.72516079f, 0.70094339f, 0.7547877f }, { 1.202842f, 1.7650605f, 1.5938526f, 0.97031337f } } }, { { { -0.078108035f, -0.049518839f, 0.26950139f, -0.51522828f }, { 0.43015518f, -0.045354216f, 0.094550359f, -0.2395012f }, { -0.079900522f, -0.082582235f, 0.24464909f, -0.5234896f }, { 0.38422945f, -0.023833644f, 0.07334288f, -0.22827313f }, { -0.075370379f, -0.05156594f, 0.19883182f, -0.45064193f }, { 0.46285395f, 0.021899343f, 0.10155287f, -0.25974773f } }, { { 0.068681419f, -0.32175988f, 0.15143274f, -0.0066205388f }, { -0.17060226f, 0.31051319f, -0.080511981f, -0.1593209f }, { 0.08167251f, -0.32517768f, 0.10937023f, -0.06941926f }, { -0.14580685f, 0.32474959f, -0.081718057f, -0.11068378f }, { 0.053961394f, -0.29322836f, 0.10408839f, -0.02243046f }, { -0.030598471f, 0.34332821f, -0.091528353f, -0.16299796f } }, { { 0.99457629f, 0.9455255f, 0.95101899f, 0.85702741f }, { 0.88648824f, 0.94948647f, 0.99225906f, 0.95773484f }, { 0.99345131f, 0.94204015f, 0.96342357f, 0.84919939f }, { 0.9116513f, 0.94549969f, 0.99395321f, 0.96728511f }, { 0.99569447f, 0.95465076f, 0.97449039f, 0.89242295f }, { 0.88590629f, 0.93896015f, 0.99061071f, 0.95182077f } }, { { 3.6380949f, 4.1749529f, 4.1351439f, 4.8389883f }, { 5.256362f, 4.2027959f, 3.6096892f, 3.9848645f }, { 3.5689427f, 3.8620869f, 4.0023981f, 4.8268584f }, { 5.1128497f, 4.468934f, 3.5851596f, 4.047485f }, { 3.7014988f, 4.1310058f, 4.2446872f, 5.3049323f }, { 4.8659881f, 4.3133002f, 3.4582876f, 3.8863853f } }, { { 1.6276316f, 0.7747672f, 1.0485958f, 0.73900224f }, { 0.72010795f, 0.65403093f, 1.3179681f, 0.65610074f }, { 1.5881174f, 0.55108527f, 1.0509725f, 0.72153362f }, { 1.1389053f, 1.0905142f, 1.6661598f, 0.9987548f }, { 1.977914f, 0.83001686f, 1.0571479f, 0.80249183f }, { 0.94107069f, 0.80840873f, 0.95379751f, 0.50386367f } } }, { { { 0.015525428f, -0.48038019f, -0.021799698f, 0.43629156f }, { 0.045681247f, -0.55039024f, -0.54573329f, 0.57817853f }, { -0.045869129f, -0.42209953f, -0.14040829f, 0.37787106f }, { 0.66327604f, -0.70070311f, -0.55261635f, 0.63446196f }, { 0.015397585f, -0.43515767f, -0.021927897f, 0.4203714f }, { 0.85681772f, -0.65394729f, -0.67557236f, 0.60104142f } }, { { -0.31503888f, -0.26745648f, 0.26817896f, 0.26548747f }, { -0.93282124f, -0.033621213f, 0.68374802f, -0.10858524f }, { -0.21723689f, -0.17935495f, 0.38521982f, 0.2578335f }, { -0.39913153f, 0.23555359f, 0.59589456f, -0.19075103f }, { -0.28851798f, -0.24142459f, 0.28279261f, 0.24766617f }, { -0.29435977f, -0.25850549f, 0.57790878f, -0.200546f } }, { { 0.94895177f, 0.83528552f, 0.96312243f, 0.85974768f }, { 0.35743218f, 0.8342303f, 0.48442112f, 0.80865248f }, { 0.97504059f, 0.88863029f, 0.9120807f, 0.88923301f }, { 0.63305523f, 0.67344611f, 0.58268761f, 0.74904744f }, { 0.95735066f, 0.86738225f, 0.9589304f, 0.87289711f }, { 0.42333878f, 0.71100482f, 0.45784651f, 0.77364753f } }, { { 5.3641275f, 5.2550422f, 5.3103777f, 5.2851215f }, { 5.2657045f, 6.2095784f, 6.9549598f, 4.9205516f }, { 5.163385f, 5.3141038f, 4.9907618f, 5.3583852f }, { 6.1257061f, 6.1102338f, 6.9549598f, 5.3129951f }, { 5.3138838f, 5.3257842f, 5.3133783f, 5.2687156f }, { 5.8915091f, 6.153324f, 6.9549598f, 4.9568971f } }, { { 3.1221918f, 1.1882615f, 2.6991784f, 1.1185048f }, { -0.2322432f, -0.16590163f, 0.088416958f, 0.057399579f }, { 3.4395383f, 1.5836276f, 2.6242352f, 1.2873336f }, { -0.23767634f, -0.79425452f, 0.20477899f, 0.40461516f }, { 2.2521751f, 1.1933374f, 2.3309484f, 1.0185309f }, { -0.099258385f, -0.2173726f, 0.0736866f, 0.15470436f } } }, { { { 0.066050217f, -0.33053278f, -0.13771479f, 0.33278465f }, { 0.00084467977f, -0.50077778f, -0.30083482f, 0.6494273f }, { 0.24880159f, -0.30354993f, -0.15417892f, 0.38203296f }, { -0.073325098f, -0.4778777f, 0.10779844f, 0.66683723f }, { 0.15703809f, -0.36335455f, -0.15657631f, 0.35926503f }, { 0.26127617f, -0.29524368f, -0.14490804f, 0.65461301f } }, { { -0.57970022f, -0.33939622f, 0.72169742f, 0.320959f }, { -0.38698206f, -0.12730306f, 0.65810895f, 0.026509232f }, { -0.6199708f, -0.34745658f, 0.68683659f, 0.34547285f }, { -0.3613378f, -0.14006845f, 0.65917895f, 0.038446867f }, { -0.57778101f, -0.35057776f, 0.57837882f, 0.36488991f }, { -0.50051482f, -0.019174387f, 0.50816239f, 0.02682636f } }, { { 0.8121484f, 0.88065787f, 0.67837119f, 0.88670158f }, { 0.92208686f, 0.85616327f, 0.69021085f, -0.75996148f }, { 0.74413303f, 0.88720424f, 0.71027063f, 0.85714604f }, { 0.92954743f, 0.86718726f, 0.74421946f, -0.74421095f }, { 0.80094204f, 0.86317363f, 0.8006009f, 0.85894353f }, { 0.82536033f, 0.95522956f, 0.8489833f, -0.75548802f } }, { { 5.7725061f, 5.1565901f, 5.6224483f, 5.0847054f }, { 5.7717118f, 6.4180057f, 6.9797014f, -0.03290957f }, { 5.7847117f, 5.2015529f, 5.614561f, 5.2019388f }, { 6.2613999f, 6.5807982f, 6.9797014f, -0.032764603f }, { 5.823775f, 5.2332343f, 5.826694f, 5.197143f }, { 6.3463188f, 5.8174311f, 6.9797014f, -0.032766769f } }, { { 2.96787f, 1.3557735f, 2.0749129f, 1.3066609f }, { -0.92782801f, 0.0079162579f, -0.33479446f, 2.699659e-05f }, { 2.1997063f, 3.1083252f, 2.6810949f, 1.8276262f }, { -0.48654719f, -0.10954189f, -0.32175132f, 5.490092e-05f }, { 3.1970446f, 1.787085f, 3.062849f, 1.6274811f }, { -0.78882801f, -0.34050184f, -0.59962127f, 3.6554198e-05f } } } };
-const float high_quality_coeffs[7][5][3][24][4] = { { { { { -4.8355339e-06, -4.4902569e-05, -9.2632249e-05, -0.00053773136 }, { 0.0040143823, -0.00060900339, -0.0095301923, -0.0053956011 }, { -0.0005923892, -3.6901978e-05, -5.6694857e-06, -0.00017018564 }, { 0.0012441402, 0.02236187, 0.022751769, 0.0062788948 }, { 0.00013810055, -2.2709815e-05, 0.0054849671, -1.6599195e-05 }, { -0.020320408, -0.017066319, -0.017457746, 0.022910628 }, { 0.00024171724, 9.7419073e-05, -0.00047804272, -0.00010093683 }, { 7.6988167e-05, 1.8551597e-05, -5.7692813e-05, -3.332362e-05 }, { -0.00062766208, 2.713742e-05, 0.00026511682, 2.3841873e-05 }, { -0.00043656844, 0.0028645469, 0.0049817085, 0.0080221478 }, { -3.3210444e-05, -8.0852386e-05, -2.2111492e-06, -8.4430827e-05 }, { 0.010967284, 0.018811225, 0.017569463, -0.0046944996 }, { -0.00018391248, -0.00010462174, -0.00017726, -0.00018490133 }, { 0.00012591989, 0.015965386, 0.015964059, -0.0078018431 }, { -0.006125333, -8.2224165e-05, -0.00020500151, -0.00025207244 }, { -0.00016320041, -0.0001279242, 0.00014038799, 8.1359421e-05 }, { -0.00064341098, -0.0011265496, -0.0011634792, -0.00081607159 }, { 0.00089294825, 0.0061923653, 0.0052662392, -0.00058227469 }, { -2.4001308e-05, -1.3534224e-05, -1.4720478e-05, -2.5120827e-05 }, { 0.00029964918, -0.0045658543, -0.0045581938, 0.0017106208 }, { 7.5790173e-05, -1.8265415e-05, 1.5918205e-05, 5.8524021e-05 }, { 0.0011669872, -0.00017571882, -0.00017190275, -0.0023833977 }, { 0.0033487264, -0.0066535821, -0.0066413786, -0.0032332601 }, { -3.6468807e-05, -0.00068145131, -9.8190714e-05, -8.7169435e-05 } }, { { -0.0010440653, -8.9750644e-05, 4.971182e-05, 0.0044618878 }, { 0.0078333883, -0.00090884312, -0.00046920549, -0.002465051 }, { -0.0058778609, 0.0026554895, -0.00031880506, -0.00010649091 }, { -0.0015095448, 0.0094026506, 0.009492703, 0.0024572848 }, { 0.0047331786, 0.00070722401, 0.0028798817, -0.00039779892 }, { -0.0089878107, -0.0095474878, -0.0097187652, 0.008765907 }, { -4.0435321e-05, -0.00061813281, -0.0060490143, 0.0016259965 }, { -0.00014720558, -1.0601876e-05, 0.00014757138, 0.00016227641 }, { -0.010428289, -0.00031812813, -0.0016172213, -0.00012022134 }, { 0.0040517131, 0.0072972763, 0.0060433905, 0.0025041645 }, { 0.00014090924, 0.00027612853, 0.00015961665, 0.0002605418 }, { -0.00020653783, -0.00048482867, -0.00058472338, 0.00026413759 }, { 0.00056712638, 0.00026385353, 0.00035484947, 0.00033212447 }, { -0.00094663094, 0.0029891757, 0.0029887838, -0.0026583585 }, { -0.0017400246, 0.00042350567, 0.00086128207, 0.00039863587 }, { 0.00059604848, 0.00027495434, -0.00059956434, -4.4981673e-05 }, { -0.010211343, -0.0080580409, -0.0085333216, 0.0023258717 }, { 0.00042832593, 0.0056750222, 0.0048059635, -0.0092168281 }, { 3.0214612e-05, 4.540924e-06, 1.7239937e-05, 2.783598e-05 }, { 0.00029393335, -4.5128636e-05, -4.3089017e-05, 0.00030682556 }, { -4.7077735e-05, -1.3596835e-05, -0.0015338149, -7.4957991e-05 }, { -0.00097136844, 0.00018564298, 0.00021815754, 0.0015095577 }, { 0.00043929849, -0.0014691094, -0.0014671742, -0.00029365954 }, { 8.8554045e-05, 0.0062500772, 0.0001495049, 0.00021007601 } }, { { 0.0020307077, 0.0020947445, 0.0017438295, 0.0084822342 }, { -0.0069727503, -0.0010131005, 0.0055261321, -0.0020442588 }, { 0.00031035611, 0.00010839441, 3.7359209e-06, 4.3112837e-05 }, { 9.1207794e-05, 0.0050148169, 0.0051071455, 0.0033679057 }, { -0.00090101737, -0.00053793176, -0.0025829621, 0.0003241927 }, { -0.0019244714, -0.0033690472, -0.0035193497, 0.0027653636 }, { -0.00065476293, -0.00017787403, 0.00040383136, -0.00018123957 }, { -0.00030640434, -0.00018961553, -0.00011036218, -0.00015793049 }, { 0.001110592, -0.00021252645, 0.00015849587, -3.7758317e-05 }, { 0.00077967828, -0.0051765235, -0.0078505592, -0.010796339 }, { -1.2024951e-05, 6.48806e-05, -3.9409005e-05, 7.4639306e-05 }, { -0.00017352424, -0.00037802595, -0.00045639468, 0.00016843169 }, { -4.2866244e-05, -4.3730932e-06, 7.3574276e-05, 5.6076779e-05 }, { 0.00024802387, 0.0018053101, 0.0018042994, -0.0016700716 }, { 0.0082698262, -0.00014605077, 0.0004377682, 8.1585074e-05 }, { -4.494343e-06, 0.00019781519, -0.00058910268, -0.00027360572 }, { 0.0013016934, 0.0021020456, 0.0022718598, -0.0059377824 }, { 0.002185371, -0.0080788056, -0.0071952836, 0.0039688918 }, { 0.00013048617, 0.0001738124, 0.00012978924, 0.00013813358 }, { 0.00032386518, 0.00023046021, 0.00023064714, 0.00033762343 }, { 0.00023643771, 0.00019652953, 0.0013083597, 0.00024739959 }, { -0.0063957036, -0.0055319023, -0.0054742301, -0.0037204932 }, { -0.0005510683, -0.0007715413, -0.00077385934, -0.001009415 }, { 0.00017904616, -0.00096137522, 0.00030252599, -2.2478138e-05 } } }, { { { -0.00038948583, -0.00040817153, -0.00041280315, -0.0010985631 }, { 0.0025695337, 0.00042904308, 0.0054649973, -0.0055079106 }, { 0.00052050672, 2.2618679e-05, 0.00024058975, -0.00012632201 }, { -0.013468886, 0.0079396715, 0.0079402246, 0.026283756 }, { -7.922122e-05, -3.4761763e-06, -0.0041716347, 0.0001478739 }, { 0.023716381, -0.016415262, -0.015296927, -0.021050827 }, { 3.7654391e-05, 0.00012765816, -0.0001337099, 0.00051483398 }, { 0.00015671907, 0.00010686796, 2.1421097e-05, -2.2281569e-05 }, { 3.1779413e-06, 0.00010449913, -0.00018303614, 7.5382489e-05 }, { -0.00020526765, -0.0011333575, -0.0050720108, 0.0051482782 }, { 4.0450357e-05, 1.0808158e-05, -2.3316095e-05, 9.7767333e-06 }, { -0.019107229, 0.010907324, 0.0048969594, 0.017851514 }, { 7.4048796e-05, -7.041835e-06, 8.0226174e-05, 5.1714105e-05 }, { -0.016564627, 0.0023486944, 0.0023601429, 0.016005248 }, { -0.004528284, 3.6291049e-05, 2.4229636e-05, 0.0024853948 }, { 5.6882054e-05, 6.8805135e-05, 0.00013119897, 0.00010339801 }, { 0.00021183341, 0.0008203137, -7.204401e-05, 0.00062599728 }, { -0.00099314707, 0.0030198762, -0.0038989955, 0.00055571214 }, { -7.4247984e-05, -8.3993373e-05, -5.9133252e-05, -7.7411989e-05 }, { 0.0054296732, -0.00057858871, -0.00058417754, -0.005072911 }, { -0.00019259782, -0.00018772532, -4.2959783e-05, -0.0001827295 }, { -0.00029351865, 0.00013736372, 0.00016666048, 0.00020873447 }, { 0.0069341659, 0.0027612928, 0.0027538377, -0.0061770317 }, { 4.2584714e-05, -0.00037063589, -9.0693123e-06, 0.00011845784 } }, { { 0.0028834168, 0.0031807308, 0.0031352582, 0.01064051 }, { 0.0049297987, -4.2149356e-05, -0.0014926841, -0.0002300371 }, { 0.0020396303, -0.00066042794, -6.4359283e-05, 0.00017835163 }, { -0.0025767816, 0.0025148152, 0.0025224779, 0.0043006543 }, { -0.00042084416, -0.00013534305, 0.002453623, -4.0707749e-05 }, { -0.0001803055, -0.0010450606, -0.00084380806, 0.00014843677 }, { -0.0064067107, 0.00011012652, -0.0022552747, -0.00080508294 }, { -0.00017778763, -4.296789e-05, 0.00015343883, 0.00025036711 }, { 0.002825978, -0.00031945362, -0.00031987612, -0.00021117763 }, { 0.00032791249, -0.00049524542, 0.0049368722, -0.0017186408 }, { -0.0001685943, -0.00016766033, -0.0001755097, -0.00017067307 }, { 0.00023939157, -0.00011793706, -6.0620575e-05, -0.0002706595 }, { -2.9718673e-05, 3.5950879e-05, 1.839844e-05, -2.8718148e-05 }, { -0.0017260981, 0.00012145435, 0.0001236679, 0.0018292155 }, { 0.0036086706, 0.0001026898, -2.5518889e-05, -0.00019830236 }, { -0.00031546808, -0.00042107458, -0.00059963868, -0.00061472497 }, { -0.0074719522, 0.0015719596, -0.0033624165, -0.0092664101 }, { -0.0011285776, 0.0018601435, 0.00052060704, -1.5554679e-05 }, { 4.9853171e-05, 7.3650922e-05, 3.4080107e-05, 5.4255445e-05 }, { 0.00015102779, -2.58105e-05, -2.5851018e-05, -4.5185316e-05 }, { 0.0002057452, 0.00019037765, 0.0040052198, 0.00020046579 }, { 0.0027727314, 0.0040749211, 0.0036050794, 0.0034635222 }, { 0.00042503689, 0.00056027382, 0.00056052971, -8.2485044e-05 }, { -5.6309634e-05, 0.0019722025, 6.4267434e-05, -0.00020376412 } }, { { 0.0051607661, 0.0047835358, 0.0047658352, 0.0054281814 }, { -0.0040939561, 0.0012119183, -0.0023408179, -0.00055891234 }, { -0.0031939804, -0.0015954053, -0.00018570689, 0.00028849431 }, { -0.0075625096, 0.0033878734, 0.0033797415, 0.010242674 }, { -0.002293562, 0.00024245282, 0.0019455622, 0.0039550747 }, { 0.0090386754, -0.0086947671, -0.0082684939, -0.0075613346 }, { -0.00085735117, 3.4822634e-05, -0.0024653972, -0.00090964985 }, { -0.00013750587, -0.00010089501, 6.3555498e-05, 0.0002758494 }, { 0.0060496328, -0.00032664426, 0.0005979723, -0.00018819024 }, { 0.00072724184, 0.00082242885, 0.0045668772, -0.0054557456 }, { -9.6167811e-05, 7.9856612e-05, 0.00015672473, 8.0901183e-05 }, { 0.00038859448, -0.00025360755, -0.00017624981, -0.00049125519 }, { -8.8277361e-05, 2.4159527e-05, -0.00016014627, -2.7854246e-05 }, { -0.0037308647, 0.00041434141, 0.0004167221, 0.0037190244 }, { 0.00050696744, -4.6752715e-05, 0.00033183668, -0.0025882828 }, { -0.00015915702, -0.0002325901, -0.00036157415, -0.00016391937 }, { 0.00012320153, 0.0026711886, 0.0018414591, -0.0058215223 }, { -0.0029409983, -0.00015460743, 0.0031951665, 0.0074654329 }, { 9.9084813e-05, 9.1785865e-05, 5.9300007e-05, 0.00010463304 }, { 0.00024773341, -2.5723276e-05, -2.5709769e-05, -0.00015357475 }, { 0.000416633, 0.00028749584, -0.0038632071, 0.00039869488 }, { 0.00018344152, 3.0811778e-05, -0.00010240082, 0.00059301197 }, { 0.0019217461, 0.00034404024, 0.00034318823, -0.0015867375 }, { -0.00011928879, 0.001178769, -5.8655983e-05, -0.00028461439 } } }, { { { 0.99999992, 0.99999992, 0.99999991, 0.99999925 }, { 0.99998864, 0.99999972, 0.99993965, 0.99997027 }, { 0.99999969, 1, 0.99999997, 0.99999998 }, { 0.99990852, 0.99971841, 0.99970961, 0.9996348 }, { 0.99999999, 1, 0.99997626, 0.99999999 }, { 0.99951219, 0.9997196, 0.99973058, 0.99951587 }, { 0.99999997, 0.99999999, 0.99999988, 0.99999986 }, { 0.99999998, 0.99999999, 1, 1 }, { 0.9999998, 0.99999999, 0.99999995, 1 }, { 0.99999988, 0.99999525, 0.99997473, 0.99995457 }, { 1, 1, 1, 1 }, { 0.99975729, 0.99976356, 0.99983365, 0.99982963 }, { 0.99999998, 0.99999999, 0.99999998, 0.99999998 }, { 0.99986279, 0.99986979, 0.99986978, 0.99984147 }, { 0.99997099, 1, 0.99999998, 0.99999688 }, { 0.99999999, 0.99999999, 0.99999998, 0.99999999 }, { 0.99999977, 0.99999903, 0.99999932, 0.99999947 }, { 0.99999911, 0.99997627, 0.99997853, 0.99999968 }, { 1, 1, 1, 1 }, { 0.99998521, 0.99998941, 0.99998944, 0.99998567 }, { 0.99999998, 0.99999998, 1, 0.99999998 }, { 0.99999928, 0.99999998, 0.99999997, 0.99999714 }, { 0.99997035, 0.99997405, 0.99997415, 0.99997569 }, { 1, 0.9999997, 1, 0.99999999 } }, { { 0.00015966941, 0.00014262676, 0.00020165066, 0.00021618914 }, { 2.8140907e-06, -0.00020325872, 0.00017736728, 6.0386679e-05 }, { -0.0003187876, 5.8862288e-05, 6.2281085e-05, 1.7339908e-05 }, { -2.6587911e-05, -0.00011609007, -0.00011725093, -7.6114852e-05 }, { 0.00013665042, 5.2703844e-06, -0.00031293536, 3.8693931e-05 }, { -9.8143069e-05, -0.00012816332, -0.00012926252, -0.00010623032 }, { 0.00032342312, -1.9200091e-06, -0.00010691485, 6.3541059e-05 }, { -8.0643542e-06, 9.7622933e-06, 2.9924822e-05, -1.988333e-05 }, { 0.00025318464, 1.2588649e-05, 1.4665927e-05, 9.3294806e-06 }, { 2.6875391e-06, -2.4928123e-05, 2.251878e-05, 0.00011026808 }, { 1.767638e-05, 1.0309044e-05, 2.4765648e-05, 1.4397941e-05 }, { 6.9000935e-06, 1.0637078e-05, 1.087637e-05, 6.3065784e-06 }, { 5.532953e-05, 1.6231463e-05, 4.9564371e-05, 3.6623041e-05 }, { -1.6958729e-05, -3.1627491e-05, -3.1524511e-05, -2.9954116e-05 }, { 8.9045086e-05, 2.1005026e-05, 1.3016463e-05, 8.7863053e-05 }, { -2.75035e-05, -3.0440427e-05, -3.5356286e-05, 5.9609261e-06 }, { 0.0001586274, 4.0711165e-05, 3.1563135e-05, 0.0001385483 }, { 8.5548316e-06, 7.4531928e-05, -3.7017413e-05, 2.6874037e-05 }, { -1.3750655e-05, -8.2756032e-06, -2.7214983e-07, -1.4830115e-05 }, { -7.0798362e-07, -3.3187173e-07, -3.3266762e-07, -5.7113855e-07 }, { 4.3615512e-05, -4.4076433e-06, 8.9239586e-06, 3.7278531e-05 }, { -7.7366773e-06, 4.610399e-06, 4.3762687e-06, -5.64067e-06 }, { -3.2666125e-06, -1.0773146e-05, -1.0861965e-05, -1.3327232e-06 }, { -9.1178305e-06, 0.00030171207, -1.5395234e-05, -2.0695425e-07 } }, { { 0.00017159464, 0.00014699558, 0.00018752678, 0.0002227926 }, { -4.6524822e-05, -0.00010460271, 0.00034735325, 0.00010082238 }, { -6.8269006e-05, 1.4343751e-05, 7.7283393e-06, 2.5347136e-05 }, { -6.6149546e-05, -7.1168993e-05, -7.0621016e-05, -0.00015246746 }, { 7.12022e-05, 3.8790461e-05, -0.00023994449, 6.6792921e-05 }, { -0.00014735813, -0.00012658353, -0.00012162488, -0.00012106777 }, { 0.00015161388, -1.4439153e-05, -3.7629923e-06, 8.3140788e-06 }, { 4.0175416e-05, 2.5380268e-05, -2.2894421e-06, 4.6374378e-06 }, { 0.00028906023, 1.7695243e-05, 5.3790587e-06, 1.631859e-05 }, { 1.8890685e-05, -1.6898275e-05, 2.1007663e-05, 6.5179363e-05 }, { -3.9142595e-06, 2.5745488e-05, 1.0803197e-05, 2.7099749e-05 }, { 9.4245546e-06, 1.0010075e-05, 9.058324e-06, 9.8703427e-06 }, { -2.3441863e-06, 2.5490323e-05, -1.0097654e-05, 4.0554798e-05 }, { -4.1443921e-05, -1.996316e-05, -2.0000841e-05, -4.7495655e-05 }, { 0.00012591695, 5.6179903e-05, -1.8415869e-05, -3.8697972e-05 }, { 2.6719505e-05, 2.4195362e-06, 2.4287424e-05, 3.4703059e-05 }, { 7.3804931e-05, 4.9784871e-05, 3.1159931e-06, 0.00015857197 }, { -0.00010634331, -1.6427658e-05, -7.4874306e-05, -6.2620255e-05 }, { -4.2561214e-06, -1.6123179e-05, -1.5507273e-05, -1.2909924e-05 }, { -1.2210463e-06, 1.1546399e-06, 1.1413892e-06, -1.3465856e-06 }, { 3.4909884e-05, -1.2677793e-05, 0.00011543701, 2.413091e-05 }, { -2.1953323e-05, -4.6244252e-06, -3.5624435e-06, 4.2293671e-06 }, { -1.1392936e-05, -4.3970369e-06, -4.4264864e-06, -1.208518e-05 }, { -4.4002617e-05, 0.00020912348, -3.9617824e-05, -4.1725112e-05 } } }, { { { -0.32504349, -0.32502096, -0.32501094, -0.32423576 }, { -0.65602876, -0.65622598, -0.65567173, -0.65525128 }, { -1.4666488, -1.4666488, -1.4666488, -1.4666488 }, { 0.87168363, 0.87181364, 0.87181792, 0.8718169 }, { -1.264365, -1.264365, -1.264365, -1.264365 }, { 0.89917968, 0.89916889, 0.89916525, 0.89927374 }, { -1.2245906, -1.2245906, -1.2245906, -1.2245906 }, { -0.8885678, -0.88856217, -0.88856327, -0.88855044 }, { -0.31799095, -0.31916566, -0.31907669, -0.31918911 }, { -0.08987958, -0.090342401, -0.090004674, -0.090222398 }, { -0.59425693, -0.59433999, -0.59429118, -0.59433553 }, { 1.1317575, 1.1317475, 1.1317412, 1.1317494 }, { -1.2193493, -1.2193493, -1.2193493, -1.2193493 }, { 1.2506981, 1.250675, 1.250675, 1.2506569 }, { -1.08782, -1.0877793, -1.0878022, -1.0878025 }, { -0.13925598, -0.13932948, -0.13919658, -0.13913403 }, { -0.40394684, -0.4042314, -0.40436178, -0.40402218 }, { -0.47762966, -0.47745572, -0.47767784, -0.47713093 }, { -0.60177181, -0.60176862, -0.60177347, -0.60177079 }, { 2.7311956, 2.7311911, 2.7311911, 2.731191 }, { -1.3109856, -1.3109856, -1.3109856, -1.3109856 }, { 0.60942644, 0.60941369, 0.6094123, 0.60944198 }, { 0.55675448, 0.55672275, 0.55672303, 0.5567542 }, { -0.40637059, -0.4057945, -0.40635768, -0.40636681 } }, { { -0.0016154222, -0.0015930079, -0.0015828998, -0.00087447165 }, { -0.0011262472, -0.001324462, -0.00094895016, -0.00062188189 }, { 0, 0, 0, 0 }, { 9.7616744e-05, 0.00010718899, 0.00010718606, 0.00012665246 }, { 0, 0, 0, 0 }, { 0.00013476236, 6.982272e-05, 6.8208505e-05, 0.00014604742 }, { 0, 0, 0, 0 }, { -0.0031089951, -0.0031071196, -0.0031207245, -0.0031097054 }, { -0.0027808116, -0.0035049857, -0.0034100135, -0.0035192661 }, { -0.0018291474, -0.0019603285, -0.0018919656, -0.0019656229 }, { -0.0034301741, -0.0034912573, -0.0034474395, -0.0034893985 }, { -6.156701e-06, -9.8568527e-06, -1.2383692e-05, -9.9984205e-06 }, { 0, 0, 0, 0 }, { 0.00011838153, 0.00011008679, 0.00011008878, 0.00010536608 }, { -0.0006246638, -0.00058479459, -0.00061327452, -0.00061085433 }, { -0.0059197749, -0.0059778169, -0.0059586015, -0.0058798299 }, { -0.0013246996, -0.0016061786, -0.0016081246, -0.0014374546 }, { -0.001593227, -0.0014706843, -0.0015974008, -0.001341579 }, { -0.0027930604, -0.0027920013, -0.0027939865, -0.0027928528 }, { -1.8908723e-06, -4.266382e-06, -4.2210172e-06, -5.0155215e-06 }, { 0, 0, 0, 0 }, { 0.00018508026, 0.00019774537, 0.00019744661, 0.00019538593 }, { 2.3243747e-05, 1.7291398e-05, 1.7309712e-05, 2.9261396e-05 }, { -0.0041402471, -0.0037085946, -0.0041294876, -0.0041316136 } }, { { -0.0018899732, -0.0018719182, -0.0018661076, -0.0012234594 }, { -0.0012968123, -0.0012971446, -0.00093522854, -0.00066475268 }, { 0, 0, 0, 0 }, { 9.1054464e-05, 0.00014124217, 0.00014156806, 0.00012014953 }, { 0, 0, 0, 0 }, { 0.00017026995, 0.00010528413, 0.00010537941, 0.00015698848 }, { 0, 0, 0, 0 }, { -0.0025812972, -0.0025835894, -0.0025789321, -0.002554949 }, { -0.0035568863, -0.0042988014, -0.0042155548, -0.004312546 }, { -0.0024184575, -0.0025111277, -0.0024654994, -0.0023980076 }, { -0.0036993386, -0.0037113013, -0.0036987284, -0.0037094875 }, { -5.074861e-06, -1.1367399e-05, -1.4819989e-05, -9.2705899e-06 }, { 0, 0, 0, 0 }, { 0.00012570403, 0.00012150272, 0.00012149179, 0.00010579599 }, { -0.00062162762, -0.00058131015, -0.00060837583, -0.00060795256 }, { -0.00775735, -0.0077198081, -0.0078365948, -0.0077749317 }, { -0.0015325554, -0.0017125784, -0.001703195, -0.0015662859 }, { -0.0018130784, -0.00177106, -0.001858095, -0.0015845058 }, { -0.003668417, -0.0036659688, -0.0036693421, -0.0036680526 }, { -9.5804016e-06, -9.6276607e-06, -9.630607e-06, -1.2159056e-05 }, { 0, 0, 0, 0 }, { 0.00017930618, 0.00020084683, 0.00020150104, 0.00020810787 }, { 2.3869269e-05, 1.1024793e-05, 1.1041937e-05, 1.6467357e-05 }, { -0.004690782, -0.0044656761, -0.0046782065, -0.0046921455 } } }, { { { 0.23047932, 0.23043226, 0.23041471, 0.22922185 }, { 0.14990977, 0.15703656, 0.15110771, 0.15149153 }, { 0.30629171, 0.30426701, 0.30400037, 0.30403889 }, { 0.03476576, 0.036188528, 0.036216719, 0.037322097 }, { 0.31066251, 0.31090363, 0.31041565, 0.31057779 }, { 0.04875259, 0.046468595, 0.046486323, 0.046584523 }, { 0.31745458, 0.31874472, 0.32086369, 0.31880207 }, { 0.64054942, 0.64062862, 0.64051973, 0.64059059 }, { 0.27309038, 0.27480819, 0.27477284, 0.27486762 }, { 0.196647, 0.19687982, 0.19607604, 0.1957915 }, { 0.32867362, 0.32858008, 0.32856702, 0.328555 }, { -0.0026873031, -0.0042393446, -0.0057894907, -0.0041858859 }, { 0.40254624, 0.4024247, 0.4025598, 0.40243731 }, { 0.019362807, 0.018146218, 0.018146051, 0.019656613 }, { 0.29328089, 0.29403937, 0.29435036, 0.29403094 }, { 0.57111506, 0.57118505, 0.57099608, 0.57099266 }, { 0.16966612, 0.16993739, 0.17069399, 0.16991136 }, { 0.14989055, 0.1489484, 0.14995985, 0.15015916 }, { 0.33606014, 0.33606294, 0.33606393, 0.33605429 }, { 0.015421206, 0.015180692, 0.01518037, 0.015431139 }, { 0.33165237, 0.33185282, 0.33162592, 0.33166981 }, { 0.078137018, 0.078153855, 0.078165152, 0.078332343 }, { 0.002896946, 0.0026038621, 0.0026029604, 0.0022081151 }, { 0.41064398, 0.40987685, 0.41065341, 0.41059166 } }, { { -0.0024316111, -0.0024732789, -0.0024922144, -0.0035874346 }, { 0.0013306961, 0.004171802, 0.0027660627, 0.0023671465 }, { 0.0034411091, 0.0020878413, 0.0020874456, 0.0022028237 }, { -0.0032873976, -0.0021351911, -0.0021071363, -0.0028424534 }, { 0.0017995208, 0.0022319618, 0.0039270256, 0.0021249365 }, { -0.0019590835, -0.0012526895, -0.0012347747, -0.0021069943 }, { 0.0012319531, 0.002255621, 0.0030193583, 0.0020970822 }, { 0.0015144077, 0.0015110104, 0.0014803089, 0.0015340007 }, { -0.0036679996, -0.0028160114, -0.0028586497, -0.0027953731 }, { -0.005445786, -0.0052624873, -0.0054843188, -0.0053271749 }, { 0.00067154572, 0.0007530775, 0.00067974516, 0.00074462315 }, { -0.0035626119, -0.0034186877, -0.0038720517, -0.0040088745 }, { 0.003455851, 0.0035040061, 0.0034671486, 0.0035069881 }, { -0.0047789747, -0.0047994804, -0.0047996451, -0.0044008337 }, { 0.0032403482, 0.0033627856, 0.003429619, 0.0031153117 }, { -0.005027022, -0.0049812, -0.0049604573, -0.0050556194 }, { -0.0020728991, -0.0014784158, -0.001216894, -0.0019213729 }, { -0.00013808007, -0.00067270623, -0.00024001574, -0.00030691077 }, { 0.0004367104, 0.00043390709, 0.00043548166, 0.00043425516 }, { -0.00082746467, -0.00088151411, -0.00088152334, -0.0008043643 }, { 0.0030277712, 0.003133577, 0.0028529862, 0.0030362271 }, { -0.0058721937, -0.0059816331, -0.0059799345, -0.0058882832 }, { -0.0057032562, -0.0057401855, -0.0057416619, -0.0062417688 }, { -0.0014357888, -0.0020782049, -0.0014346823, -0.0014513767 } }, { { -0.0027051235, -0.0027087245, -0.0027052303, -0.0033594951 }, { 0.0028036195, 0.0030416572, 0.0014306948, 0.0017897371 }, { 0.0031113166, 0.0026432303, 0.0025937824, 0.0025394463 }, { -0.0036032904, -0.003447065, -0.0034344406, -0.0024163572 }, { 0.0023912799, 0.0025281229, 0.0038665087, 0.0024214034 }, { -0.0023543827, -0.0024294943, -0.0024539784, -0.0027742617 }, { 0.0020903896, 0.0026617586, 0.003395249, 0.0026261065 }, { 0.0019031008, 0.0019405475, 0.0019426085, 0.0019404325 }, { -0.0040413326, -0.0030964835, -0.0031020735, -0.0030826754 }, { -0.0064568993, -0.0062342438, -0.0064704698, -0.0065636744 }, { 0.0010788406, 0.0010092051, 0.0010264121, 0.00099891228 }, { -0.0040759201, -0.0059224283, -0.0066809927, -0.0049099348 }, { 0.0042962009, 0.0041909175, 0.0043195236, 0.0041900138 }, { -0.0062728983, -0.0070256154, -0.007025641, -0.0061758746 }, { 0.0036210401, 0.0039723998, 0.0042232048, 0.0042757707 }, { -0.0058693852, -0.0058583303, -0.0058544016, -0.005887725 }, { -0.0023099876, -0.0021136245, -0.0017298078, -0.0022483337 }, { -0.00017851962, -0.00014956209, 8.5676316e-05, -0.00024971669 }, { 0.0003734781, 0.00037078986, 0.00037364181, 0.00037070594 }, { -0.00030648905, -0.00038230535, -0.00038223043, -0.00028623253 }, { 0.0032871423, 0.0034163052, 0.0028276655, 0.0032991918 }, { -0.0061331695, -0.0063319797, -0.0063340119, -0.0064390374 }, { -0.0062172888, -0.0059787106, -0.0059793294, -0.0060406701 }, { -0.0018276142, -0.0022170788, -0.0018293949, -0.0018222824 } } } }, { { { { 0.13218089, -0.11654637, -0.11622196, -0.044208736 }, { 0.0074579257, 0.0038503609, 0.0013201096, 4.0415784e-05 }, { -0.025474487, -0.01209255, -0.016535858, 0.012704547 }, { -0.0016894103, -0.0081312144, -0.0033264609, 0.0011923269 }, { -0.068044876, 0.018276873, -0.074833897, 0.01308348 }, { 0.02665691, 0.013515118, 0.026440814, -0.0077037816 }, { 0.0023286096, -0.0025782652, 0.0021644694, -0.0042955294 }, { 0.051356261, -0.031058382, -0.085382962, -0.033103269 }, { -0.081609229, 0.0035270199, -0.015722417, 0.048773789 }, { 0.0023928418, -0.001243811, 0.011910492, -0.011621478 }, { -0.028953904, -0.029335777, -0.0057891432, 0.013874136 }, { -0.012473582, 0.001772629, -0.013983442, 0.014846792 }, { -0.016111661, 0.0018902323, 0.025910586, 0.042848276 }, { 0.026200626, 0.024007879, 0.0017667146, -0.016394032 }, { -0.0067006429, -0.0017968936, 0.009028659, 0.0044060413 }, { 0.019280611, 0.0449581, -0.042852227, -0.066012332 }, { -0.014451123, -0.047772741, -0.047475406, 0.098434178 }, { -0.0028954635, 0.010521833, -0.015741597, -0.00091666191 }, { 0.0020291956, -0.057966746, -0.04525094, 0.032711614 }, { 0.020563445, -0.0078684621, -0.015282237, -0.0019830466 }, { -0.019504171, 0.071338511, 0.0033729474, -0.0095772339 }, { 0.013056103, 0.018719519, 0.0096002937, -0.028774366 }, { -0.00038728577, -0.0010662982, -0.0014333502, 0.00059135695 }, { 0.073844752, -0.05666013, -0.1007151, -0.030440738 } }, { { 0.00017766639, -9.2398532e-05, -3.9442682e-05, -3.9559848e-05 }, { -0.0043956477, 0.00044042277, -0.00047491077, 9.4171117e-05 }, { -0.0042095545, -0.00910753, -0.0014295282, 0.0042595844 }, { 0.00070989004, -0.0009623012, 0.00084162653, -0.00015925965 }, { -0.0017587638, 0.0033199811, -0.00025544613, 0.00083644978 }, { 0.0051797987, 0.0015691893, -0.002324397, 0.0050776381 }, { 0.003911779, 0.00072639703, 2.102924e-05, -0.0029529332 }, { 0.0050240476, -0.00041452319, 3.1730448e-06, -0.0072697591 }, { -1.5023048e-05, 0.00032491246, -9.2151952e-05, 0.0035851726 }, { 0.0030984373, 0.0016428856, 0.0032974124, -0.0036034289 }, { -0.00044578206, -0.0035916409, 0.0028146658, 0.0068013321 }, { 0.00025716711, -0.0024772152, 0.0029660992, -0.0008783244 }, { -0.005543602, -0.00046453249, 0.006815884, 0.0069207512 }, { -0.0033541738, -0.0015140333, -0.004071746, -0.0020908789 }, { 0.0027932918, -0.0012517158, -0.0033509184, -0.001271572 }, { 0.0043481525, -0.00088858735, -0.0081538059, 0.00027985077 }, { 7.4017523e-05, -7.0080388e-05, -7.1766386e-05, 0.00020468758 }, { 0.00044507396, 0.010179106, -0.0048087449, 0.0013487105 }, { 0.00082148695, -0.00042640153, -0.0024255173, 0.0044486011 }, { -0.00026383509, -0.0031871528, -0.008203704, -0.00053957093 }, { -0.0002996462, 0.00070789605, 7.9300612e-05, -0.00024002209 }, { 0.0013722116, 0.0049176054, 0.0029283062, -0.000849108 }, { 0.00026545039, 0.0011783443, 0.00072103548, -0.0007355776 }, { 0.002192273, -0.00294318, 1.5452606e-05, -0.0020953993 } }, { { 2.4074136e-05, -2.4931598e-05, -1.0893587e-05, 1.080951e-05 }, { -0.0061635883, -0.0042963493, -0.00177783, -0.00080292808 }, { 0.0047868795, -0.0050472436, 0.0082439123, -0.0090979713 }, { 0.0017221077, 0.0067285193, 0.0031011872, -0.0019932567 }, { 0.0010926271, -0.0012170693, 0.00012875612, 0.00016441623 }, { -0.0048786273, -0.0041225634, -0.005591426, 0.0043469593 }, { -0.0070664098, -0.0012625813, -0.00022220241, -0.0026120468 }, { -0.0026689917, 0.00030860545, 1.9297947e-05, 0.001274799 }, { 0.0026769559, 0.00016106032, 0.00013829246, -0.0017239107 }, { -0.0042495789, 0.0010270326, -0.00078224804, -0.0019210019 }, { 0.0072385804, 0.0086418476, 0.0061428272, -0.0027142827 }, { 0.0019768127, -0.00057957046, 0.0047464783, -0.004599565 }, { 0.0093618867, -0.0010476542, -0.0038681572, -0.0065219521 }, { -0.0076406673, -0.0036729355, -0.0068804827, 0.0077571478 }, { 0.0012706397, -0.00042567505, -0.002521821, 6.0288127e-05 }, { -0.002041411, 0.000430125, 0.0073620925, 0.0021579456 }, { 0.00012145466, 4.1276616e-05, 4.2449608e-05, 9.8351262e-05 }, { 0.0014376278, -0.007439719, 0.0039006971, 0.00051135138 }, { -7.1665367e-05, 0.00023856335, 0.00015274881, -0.0096946274 }, { -0.00076804256, 0.0040182915, 0.012603411, -0.00059669891 }, { -0.00010641981, -0.00052355992, 0.00057481361, 0.00016456343 }, { -0.0027623375, -0.0036761364, -0.010480297, 0.0066006902 }, { 0.00049081404, 0.00077264749, 0.0021355718, -0.00029188425 }, { 0.00028566818, 0.00097678458, 0.00089022281, -0.00013760767 } } }, { { { -0.0098123577, 0.11017117, 0.11245143, -0.01173447 }, { 0.0036188505, -0.0025878518, -0.00043343726, -0.0038813197 }, { 0.013109746, -0.016775181, -0.0011093308, 0.00083465721 }, { -0.0042515898, -0.0028159364, 0.00027829209, -0.002907578 }, { -0.0081027554, -0.0019330574, 0.061872524, -0.037539524 }, { -0.012923735, 0.021011524, 0.002680406, 0.0034369108 }, { 0.0027819214, 0.0028657905, -0.0034177203, -0.0037322329 }, { -0.0036178174, 0.065792163, 0.13263475, 0.0055427994 }, { 0.027832309, -0.083372016, -0.058757582, 0.016164879 }, { -0.0082343898, 0.011782416, 0.011496052, -0.0027847616 }, { 0.0012516658, -0.014686832, -0.025073035, -0.020700577 }, { 0.0055718234, -0.011543219, -0.012867689, -0.0049474286 }, { 0.028869265, -0.035431559, 0.024976635, -0.01063055 }, { -0.0010657662, 0.014977146, 0.027109, 0.01612865 }, { -0.0021697493, 0.0044220507, 0.0055654161, -0.0032373397 }, { -0.018500666, -0.01979267, -0.0068480612, 0.03908391 }, { 0.063306878, 0.01934691, 0.019254616, -0.099824471 }, { 7.0580666e-05, -0.0015082457, -0.0056893693, 0.00022726294 }, { 0.0077067654, -0.014018834, -0.021406454, -0.0076589993 }, { -0.0013072394, 2.6765854e-05, 0.0028400803, 0.0037431063 }, { -0.025369581, -0.064039908, -0.020594137, -0.086807367 }, { -0.033639351, 0.010434758, 0.00082983507, 0.013145885 }, { 0.00029373395, 7.8193614e-05, 0.00048496415, 0.00062972215 }, { -0.0041597628, 0.024283117, -0.030148407, 0.011456515 } }, { { -1.3484857e-05, -3.7204145e-05, -1.5660577e-05, -2.4497955e-05 }, { -0.0068070249, 0.0041035892, 0.0034647689, 0.0035918321 }, { -0.0053613309, 0.0080593503, 0.0028507084, -0.0023104987 }, { 0.0048581064, 0.0039720065, -0.0019058129, 0.0047295789 }, { -0.00030675956, -0.0007787587, -0.00025201217, 0.00020777843 }, { -0.00026433336, -0.0093672701, -0.0053201627, -0.0059632173 }, { -0.0063062815, 0.0011995204, 0.0001870407, 0.0028197877 }, { -0.00053247524, -0.00066138217, -1.4959372e-05, -0.00036023628 }, { 0.00027591427, 0.00011309835, 2.2453632e-05, -0.00075736359 }, { 0.0015654886, 0.0018114616, -0.0004503446, -8.5866048e-05 }, { 0.003501393, 0.0037179893, 0.008328543, 0.013411108 }, { -0.0035136609, -0.0015054003, 0.0011903964, 0.0022551358 }, { -0.0083723767, 0.0061303554, -0.008056962, 0.0035035183 }, { -0.0023715655, -0.0070468331, -0.010219655, -0.0057856465 }, { -0.0011406634, -0.00021204595, -0.001693195, 0.0011051597 }, { 0.0011643412, 0.00037557194, 0.0048567739, -0.00063996433 }, { -3.1728174e-05, -2.9073903e-06, -3.0243209e-06, 2.579239e-05 }, { 0.00053152589, 0.0029635352, 0.0040743289, -0.00051381046 }, { -0.0017253584, 0.00012081524, 0.00012243664, -0.00063598215 }, { 0.0026711847, -0.0020733972, -0.0027860744, 0.0017065643 }, { 5.7762902e-05, 0.00092043577, -0.0035278882, 0.0007846087 }, { 0.0056127705, -0.0051893669, -0.0027072408, -0.0025630045 }, { -0.00059289151, -0.0004168408, -8.8118696e-05, -0.00073538101 }, { 0.0003388606, -0.00094234652, 3.013109e-05, -0.0010532484 } }, { { -2.9013996e-05, 6.1983083e-05, 2.8401438e-05, -3.4901557e-05 }, { 0.0045230474, -0.0021369843, -0.00422706, -0.0018918027 }, { 0.00017586142, 0.005389053, 0.0071352982, -0.0018278685 }, { -0.0012135723, -0.0035970727, 0.00078957165, -0.0017065397 }, { -0.00067051937, -1.9501585e-05, 4.1968766e-05, -0.0010958091 }, { -0.0015277626, -0.0039952533, -0.00049631478, 0.0018042745 }, { 0.0039376754, -0.00097834328, 6.5894634e-06, -0.0044189106 }, { -0.00067623039, 0.0004690807, 1.4532105e-07, 0.0032984829 }, { 0.0020787449, -0.0016586579, -0.00062367064, 0.0021545362 }, { 0.0016427801, 2.6710288e-05, 0.0016011535, -0.00077649869 }, { 0.0039999622, -0.0014968097, -0.0025647576, 0.0022783424 }, { 0.001558454, -0.00083803058, 0.0018955692, 0.0010432376 }, { 0.010555722, -0.010395022, 0.0050354965, -0.0016177699 }, { 0.00011370745, -0.009328355, -0.0063009522, 0.0024377458 }, { -0.00024433189, 0.00052920244, -0.0013213352, -0.0013503982 }, { -0.0057620093, 0.00095391746, -0.0034768563, 0.00093990705 }, { 0.00012108024, 4.1007202e-05, 4.2193381e-05, -0.00011043617 }, { 0.0038593696, -0.00074282979, -0.0093457897, 0.00027311164 }, { 0.0021514797, -7.8742315e-05, -0.0018813077, -0.0017625098 }, { 0.0038491118, 0.00022570776, -0.0061331041, 0.00014956617 }, { -0.00014676603, -0.00025053931, 0.003376287, -0.00014730695 }, { 0.0016439646, 0.0060569792, 0.00063058918, -0.0034810156 }, { 0.00011722835, 0.00032237223, -0.0012556553, -0.0006887808 }, { 0.00060814722, 0.0003708376, -0.00056515636, -0.00016801817 } } }, { { { 0.99117704, 0.98705585, 0.98683693, 0.9989534 }, { 0.99996564, 0.99998924, 0.99999903, 0.99999247 }, { 0.99958951, 0.99978616, 0.99986266, 0.99991895 }, { 0.99998953, 0.99996298, 0.99999443, 0.99999506 }, { 0.99764936, 0.9998311, 0.99527468, 0.99920949 }, { 0.9995611, 0.99968788, 0.99964679, 0.99996442 }, { 0.99999342, 0.99999257, 0.99999182, 0.99998381 }, { 0.99867384, 0.99734987, 0.98748052, 0.99943657 }, { 0.99627571, 0.99651225, 0.99814846, 0.99867903 }, { 0.99996323, 0.99992981, 0.99986298, 0.99992859 }, { 0.99957996, 0.99946171, 0.99966886, 0.99968945 }, { 0.99990668, 0.9999318, 0.99981943, 0.99987754 }, { 0.99945334, 0.99937032, 0.99935219, 0.99902503 }, { 0.99965614, 0.99959957, 0.99963092, 0.99973552 }, { 0.9999752, 0.99998861, 0.99994375, 0.99998505 }, { 0.99964293, 0.99879278, 0.99905795, 0.99705307 }, { 0.99788947, 0.99867085, 0.99868681, 0.99012413 }, { 0.99999581, 0.99994351, 0.99985991, 0.99999955 }, { 0.99996824, 0.99822008, 0.99874627, 0.99943549 }, { 0.9997877, 0.99996904, 0.99987919, 0.99999103 }, { 0.99948785, 0.99539425, 0.99978223, 0.99617908 }, { 0.99934875, 0.99977032, 0.99995357, 0.99949949 }, { 0.99999988, 0.99999943, 0.99999886, 0.99999963 }, { 0.99726107, 0.99809817, 0.99445842, 0.99947091 } }, { { -2.3481737e-05, -6.7307406e-06, -2.8605869e-06, -2.0372001e-06 }, { 6.6885689e-05, 4.5630281e-06, 3.5788218e-05, 1.0842484e-05 }, { -4.9278613e-05, -2.4660601e-05, 3.1625301e-06, 0.00019708279 }, { 1.2439158e-05, 3.0347865e-05, 8.6153947e-06, 1.0887256e-05 }, { -0.00012454598, -6.513709e-05, -3.5853483e-06, -3.4708286e-06 }, { -0.00013746339, 0.00013516333, 8.4535039e-05, 5.693766e-05 }, { -2.3674091e-05, -3.4690053e-06, 5.3812265e-07, -1.7613197e-05 }, { -0.00025790043, 3.0475251e-05, 2.1174795e-06, -0.00023630753 }, { -8.8624748e-06, 7.9175589e-06, -2.4258477e-07, -0.00017288313 }, { 4.0061469e-05, 0.00069846663, -0.00060299476, -0.00015396968 }, { 5.0667108e-06, 2.306363e-05, 0.00028636884, 3.6246633e-05 }, { 0.00032740524, -0.00037985037, -0.00014841039, -0.00012676016 }, { 8.7000758e-05, 0.00018530207, 1.7669124e-05, -0.00023199594 }, { 9.2332094e-05, 0.00013487652, 0.00034587506, -3.8853378e-05 }, { 6.9809868e-05, -0.00015411544, 0.0013505166, 1.4531796e-06 }, { -6.3782301e-05, 4.8545135e-05, -0.00027083794, 4.5129465e-05 }, { 3.0912438e-06, -3.2982361e-06, -3.3551612e-06, -1.7781589e-05 }, { 9.872609e-06, -2.9944213e-05, -4.5592652e-05, 1.5950681e-05 }, { 1.4767773e-05, -2.2486726e-05, -0.00010613341, -0.00015794394 }, { 2.4386215e-05, -1.1610334e-05, -4.4456294e-05, -5.0215596e-06 }, { -4.2741558e-06, 8.7714242e-06, -6.6343322e-05, 6.7010735e-05 }, { 0.00016489767, -3.3636771e-05, 5.1610504e-05, 5.2803593e-06 }, { 1.1649256e-05, 2.1169993e-05, 1.9755999e-05, 1.3389438e-05 }, { -0.00015815197, -0.00014316145, 2.6536218e-06, -4.6846396e-05 } }, { { -3.5109783e-06, -9.8530632e-06, -4.5020804e-06, 6.9233235e-08 }, { 9.9938991e-06, -2.0914089e-06, 3.5717699e-05, 3.2813664e-06 }, { 0.00012938219, 1.111062e-05, 8.0858608e-05, 0.00018147439 }, { 4.8657525e-06, 8.6580257e-06, 3.6742927e-06, 3.5828406e-06 }, { 6.9905696e-05, 2.0985073e-05, 6.8866215e-06, -4.2552499e-05 }, { 0.00012100208, 9.7821801e-05, 0.00013576456, 6.3686234e-05 }, { 1.954525e-06, -1.0727343e-06, 5.2332444e-07, -5.4034988e-06 }, { 0.00013699813, -2.226833e-05, 1.4994043e-06, 1.7110377e-05 }, { 0.0001678261, -0.00013844113, -3.4281745e-05, 5.3854072e-05 }, { -1.3018868e-05, 0.00022176303, 0.00016983401, 0.00038109805 }, { 0.00019016068, 0.00023448876, 2.643329e-05, 4.6842203e-05 }, { -1.2492528e-05, -0.00059486605, 0.00012427061, 8.1876965e-05 }, { 8.400564e-05, -0.00029859163, -4.884214e-05, 0.0002631806 }, { 0.00019907281, 0.00014046808, 0.00015482448, 4.0461099e-05 }, { -0.00024349239, 0.00081298441, 0.00084294728, 7.9617963e-05 }, { -6.0040835e-05, 3.2352918e-07, 0.00024295599, 0.00011067283 }, { -6.0027092e-06, 1.1975092e-06, 1.2248893e-06, -2.1293392e-05 }, { 1.4478736e-05, 6.8326918e-05, -7.8693614e-06, 9.2888155e-06 }, { -1.6982828e-05, 1.2094341e-05, -3.1693808e-05, 0.00028574477 }, { 3.4480942e-05, 2.6556008e-05, 0.00016193956, -1.8966503e-06 }, { -5.7726961e-06, 2.1091148e-05, 5.8963955e-05, -1.0834372e-05 }, { 0.0001214393, 1.4174882e-05, 0.0001371836, 0.00021757165 }, { 1.0140226e-05, 6.1641031e-06, 1.0590727e-05, 1.0893212e-05 }, { -1.7442656e-05, 4.2353331e-05, 7.4324714e-05, -1.9484775e-06 } } }, { { { 3.7217719, 3.6900797, 3.6899881, 3.6670816 }, { 0.067826319, 0.16468028, 0.083129199, 0.1336756 }, { 0.66338737, 0.23883566, 0.093361469, 0.10095622 }, { 0.27185537, 0.20781392, 0.32216624, 0.29876595 }, { 2.0776462, 2.0006156, 2.0243138, 2.080345 }, { 0.57695783, 0.18015147, -0.11440889, 0.14229144 }, { 0.63833683, 0.41431062, 0.44752994, 0.47594414 }, { 1.7890608, 1.962584, 1.9322155, 1.6588331 }, { 3.0538128, 3.108267, 3.1001573, 2.9593433 }, { -0.28383051, -0.27708376, -0.042513902, -0.085181891 }, { 0.3873435, 0.41697884, 0.39625427, 0.33250735 }, { -0.33498881, -0.40206929, -0.028905862, -0.48179632 }, { 1.1875033, 1.3535177, 1.2526197, 1.3337495 }, { 0.42579488, 0.24951727, 0.18976118, 0.20605317 }, { -0.53212666, -0.3861028, -0.75685995, -0.23411882 }, { 1.6910165, 1.686815, 1.5906473, 1.6528217 }, { 4.0570657, 4.0349492, 4.0350332, 4.0498099 }, { -0.017225465, -0.032503897, 0.46003211, 0.21602109 }, { 1.1196901, 1.00885, 0.91675568, 0.99635794 }, { -0.093891275, 0.0809352, -0.13783332, 0.27130678 }, { 1.9925136, 1.9829394, 1.8820721, 1.9542026 }, { 0.84563763, 0.48476746, 0.37907152, 0.70267878 }, { 0.37054708, 0.4228574, 0.6329822, 0.26197064 }, { 1.9618393, 1.8405969, 1.9440918, 1.901629 } }, { { -5.6047186e-06, 6.0454847e-06, 2.8365975e-06, 6.0894367e-06 }, { -0.00069876506, -0.00029642785, -0.00059516082, -0.00025400441 }, { -0.00020850504, -0.00012959593, -0.00032902532, -0.00058117893 }, { -0.00037901964, -0.00038062016, -0.00023777964, -0.00033714679 }, { -5.9894351e-05, -9.820791e-05, -5.9867157e-06, -6.258549e-06 }, { -0.00035424038, -8.7146215e-05, 3.0398362e-05, -0.00061406521 }, { 0.00014971442, 4.5936211e-05, -5.6259869e-06, 0.00013567035 }, { -0.00016180211, 3.1840487e-06, 3.8979157e-07, -0.00017131994 }, { -1.9877193e-05, 2.5768261e-05, 9.0577543e-06, -0.00013927462 }, { -0.0012323564, -0.00042892846, 7.2082106e-05, 0.00010999853 }, { -0.00034618449, -0.00017058897, -0.00016535057, -0.00096982024 }, { -0.00028039653, -7.155747e-05, -0.00075796707, 0.00062756458 }, { 6.6596276e-05, -7.9730809e-05, -8.0686754e-05, -2.9532397e-05 }, { -0.00084106867, -0.00036762453, 0.00012523548, -0.00052789663 }, { 7.6718268e-05, -0.0010042005, -0.00042802983, -0.0011951304 }, { -3.6972258e-05, 2.1447505e-06, -0.00035448623, -1.0620008e-05 }, { 2.8326169e-05, 2.2049468e-05, 2.2640575e-05, 1.7574827e-05 }, { -0.00014318496, -0.0004811524, -0.00049293303, -0.00067646484 }, { -2.7469144e-05, -5.9653763e-06, -1.3998899e-05, -0.00018475323 }, { -0.00017314302, -0.00010954727, -0.00040004932, 3.31106e-05 }, { -3.6093435e-06, -1.6125243e-05, -4.9195648e-05, 1.5586886e-05 }, { 0.0002059631, -0.0004024722, -0.00047984678, -9.8485329e-05 }, { -0.00094100913, -0.00073046048, -0.00052500163, -0.00068196784 }, { -2.2820197e-05, -5.9454557e-05, -6.2505468e-06, -2.6569804e-05 } }, { { 2.6015883e-05, 8.5398335e-06, 3.8473185e-06, 9.1409625e-06 }, { -0.00041459247, -0.0001855224, -0.00030529542, -0.00016322166 }, { -8.8427847e-05, -0.0002302048, -0.00038072959, -0.00076801295 }, { -0.00027717792, -0.00028594346, -0.00017910208, -0.00027291164 }, { 2.8409311e-05, -3.8005817e-05, -4.2266878e-06, -1.4520383e-05 }, { -0.0001088827, -0.00021924377, 3.9307406e-05, -0.00032488556 }, { 0.00027997916, 3.5103699e-05, -5.7448764e-06, 0.00010259251 }, { -4.7807894e-06, -2.9470863e-05, 2.6656233e-07, -0.00014346393 }, { 0.00015527098, -6.8528726e-05, -1.1206714e-05, 2.3422595e-05 }, { -0.0012763247, -0.00051503472, 0.00058055106, -0.00068688488 }, { -6.1232076e-06, -1.7073841e-05, -0.00033533389, -0.00078769935 }, { -0.00044113485, -0.00027577451, -0.0012008622, 0.00013071136 }, { 1.834948e-05, -0.00015615102, -0.00016449385, 3.6685217e-05 }, { -0.00063618257, -0.00032641968, -5.0281118e-05, -0.00041378992 }, { -0.0010181884, -0.0003871932, -0.00050061147, -0.0018967455 }, { -5.7650067e-05, -5.1145774e-06, -0.00017409773, 1.9512036e-05 }, { 1.5838743e-05, 2.503655e-05, 2.5679098e-05, 2.0053218e-05 }, { -0.00018055811, -0.00044345237, -7.9049557e-05, -0.00095669161 }, { -4.98611e-05, -1.1320605e-06, 3.7756645e-06, -8.7299215e-05 }, { -0.00011794063, -0.00015778552, -0.00036514881, 4.7288704e-05 }, { -5.1753817e-06, -1.5040527e-06, -2.836739e-05, -9.4945229e-06 }, { 0.00016873335, -0.00031983601, -0.00052281245, 0.00019034815 }, { -0.0011988594, -0.0010684975, -0.00057577023, -0.0009143845 }, { 5.0336006e-05, -1.356148e-05, 1.5582694e-05, -2.0666272e-05 } } }, { { { 0.012207721, 0.0044164612, 0.0022704542, 0.0042008503 }, { 0.29516302, 0.139976, 0.35038027, 0.13748343 }, { 0.1462123, 0.12114907, 0.28473665, 0.45762717 }, { 0.17976664, 0.19141553, 0.1209483, 0.16393769 }, { 0.044254492, 0.11383095, 0.0062726904, 0.023550537 }, { 0.14785458, 0.10151341, 0.045717467, 0.42243971 }, { -0.24205201, -0.033590842, 0.0032064617, -0.093924041 }, { 0.10866955, 0.016299431, 0.00081631108, 0.15856447 }, { 0.10108337, 0.057931152, 0.024463589, 0.21514346 }, { 0.47967783, 0.75472932, 0.5653649, 0.64752457 }, { 0.30082544, 0.15124922, 0.23567284, 0.47161499 }, { 0.54286166, 0.61049777, 0.61641378, 0.51181399 }, { 0.39328762, 0.25557559, 0.25875912, 0.22436901 }, { 0.45699569, 0.16989563, 0.2429263, 0.3924359 }, { 0.92996797, 1.1024806, 0.78045387, 1.2298879 }, { 0.19029829, -0.022675055, 0.28113642, 0.034941166 }, { 0.013203939, 0.013034069, 0.013414649, 0.011688038 }, { 0.076026927, 0.13838472, 0.29961655, 0.31531564 }, { 0.089182386, 0.010401684, 0.029374547, 0.22995838 }, { 0.052198894, 0.039866726, 0.11570972, -0.013818992 }, { 0.0062380932, 0.01788119, -0.20765047, 0.013339281 }, { 0.12436441, 0.17318651, 0.21554136, 0.18600144 }, { 0.38005287, 0.32135548, 0.28632777, 0.29211902 }, { 0.03798742, 0.0450845, 0.010912505, 0.039060104 } }, { { 0.00077914246, 0.00011130803, 8.1110229e-05, -0.00035312557 }, { 0.00051711901, 0.00029701387, 0.00040733345, 0.00034149723 }, { 0.00063893978, -0.00013702086, 0.00030866699, -0.00020070677 }, { 7.5899443e-05, 9.7456273e-05, -4.5352178e-05, 7.6172703e-06 }, { 0.00066250814, -0.00073033349, 0.00015225542, -0.0010197351 }, { 0.00040931533, -0.00043022747, 0.00093333285, 0.0002579685 }, { -0.00067488578, -0.0003706974, -0.00044487256, -0.00056555959 }, { 0.00075838366, -0.0021903789, -0.0026744174, -0.00047135202 }, { -0.00081050821, -0.0010297809, -0.00099480849, -0.00074914246 }, { 0.00063637392, 5.248783e-05, 0.00044645091, 0.00018028446 }, { 0.00067430392, 0.0004762628, -0.00032736685, 0.00041933609 }, { 6.2324555e-05, -1.6709531e-06, 0.00057418116, -0.0010360999 }, { -0.00038256183, -0.0010104012, -0.00045533693, -1.3888404e-05 }, { 0.00068274628, 0.00068411875, -0.00091273333, 0.00016211145 }, { -0.00039440715, 0.00027665323, -0.00035895503, 0.00013423207 }, { -0.00061939017, 0.00012140102, 0.00024178233, 0.00064755788 }, { -0.00052441128, -0.00050994483, -0.00051126044, 0.00066320373 }, { 0.00085915332, 0.0013567332, -0.00014328466, 0.00056098523 }, { -0.0012682676, 0.0029139719, 0.0019812291, -0.00053863027 }, { 0.0021895869, 0.00062956835, 0.0018161156, 0.00011699452 }, { -0.0010337306, 0.00016880497, -0.0014942346, -0.0034402453 }, { -0.0025336946, -0.00019468865, -0.00018045349, -5.4312149e-05 }, { 0.00021491979, 4.7651714e-05, -0.00044921151, 0.00046742044 }, { 0.0019408125, 0.00044842687, 0.0026003265, -0.00090116109 } }, { { -0.0006591255, 0.00022873584, 0.00026313866, -0.00060151354 }, { 0.00027198127, 0.00034252944, 0.00033246896, 0.00035232159 }, { -0.00034460639, -5.9085725e-05, 7.836454e-05, -0.00018946388 }, { 0.00018790551, 0.0001918358, 9.7031467e-05, 0.00015259869 }, { -0.0023033429, -0.0012945186, -0.00080964072, -0.00030432514 }, { -0.001359781, 0.00055828912, -0.00041912301, 0.00019263336 }, { -0.00042789448, -0.00018313775, -0.00030217124, -0.00028437496 }, { -0.0018340159, 0.00030654336, -0.00010781402, -0.0011985455 }, { -0.002103478, 0.00029492518, -0.00042283946, -0.001472689 }, { 0.00064558079, 0.00049703204, -0.00018932594, -0.00038268301 }, { -0.00097813334, -0.00057838807, 0.00079268109, 0.00039650774 }, { -0.00017335252, 0.00074363734, 0.0008194423, -0.00065923207 }, { -0.00075344545, -0.00026114262, -0.00054658657, -0.0013814943 }, { -0.00028279346, 0.00055730283, 0.00048990213, -0.00022186466 }, { 0.00013438509, -0.0001962818, -0.00036195953, 0.00042669461 }, { -0.00089003585, -0.0011600794, -0.0012554286, -0.0012892408 }, { -0.00067007058, -0.0010597247, -0.0010590421, 0.00044132516 }, { 0.0011626727, 0.001261033, -0.00072912018, 0.00076332442 }, { -0.001204702, -0.00011230019, 0.00036178615, -0.0017559004 }, { 0.00096282849, 0.001025959, 0.0011696947, 0.00046633555 }, { -0.00082328571, -0.00075771669, -0.0011629302, 0.00073458863 }, { -0.0016869269, -0.00035239862, -0.0004024204, -0.0016276971 }, { 0.00029053123, 0.00013409355, -0.00049087974, 0.00061969429 }, { -0.0013198997, -0.0018615784, -0.0025724061, -0.0015563017 } } } }, { { { { -0.072246889, -0.043157285, 0.043289306, 0.095998047 }, { 0.12597079, 0.24289541, -0.10930005, -0.24150539 }, { 0.031889347, -0.036238337, -0.014521983, -0.018963885 }, { -0.044155351, -0.0077170425, -0.043781059, 0.047982339 }, { 0.093995001, -0.0079510758, -0.04688882, -0.11125523 }, { 0.01700754, -0.0034361033, 0.055252382, -0.053119426 }, { -0.0014957087, -0.00063057103, 0.037930463, 0.017656646 }, { -0.017388477, -0.084085888, -0.067726647, 0.061397079 }, { -0.070625168, -0.061293011, -0.077366932, 0.11518646 }, { -0.14771316, -0.12543895, 0.052150789, 0.10530462 }, { -0.03609139, 0.001131616, -0.039549928, 0.03805765 }, { 0.064364205, 0.066758929, 0.045537002, -0.05510954 }, { 0.049051369, 0.098312455, -0.01079726, -0.11202623 }, { 0.033012208, -0.0013996988, -0.0049458824, -0.028981527 }, { 0.008617177, -0.00017670863, -0.0052380282, -0.0023438457 }, { -0.05901498, -0.050754807, -0.00011829844, 0.037297411 }, { -0.056264446, -0.03645315, -0.066412698, 0.019549244 }, { -0.11401603, -0.11856524, 0.12275022, 0.11635143 }, { -0.0011999881, -0.0016334327, -0.0056868938, 0.013393766 }, { 0.054526972, 0.033632235, 0.062591094, -0.0025531074 }, { 0.073041316, 0.073735243, -0.06935254, -0.11214186 }, { 0.034872822, -0.015473423, 0.037359975, -0.026829465 }, { -0.015137592, -0.0064462553, 0.011771178, 0.0025042048 }, { -0.038708904, -0.033968131, -0.044070885, 0.024422773 } }, { { -0.047895007, -0.016535938, 0.04855533, 0.018341613 }, { 0.004310087, 0.01519838, -0.0033290683, -0.013597406 }, { 0.0015859181, 0.016869623, -0.019279963, -0.01426933 }, { -0.0061048976, 0.031131561, 0.018085381, -0.017927117 }, { 0.052590378, 0.0066156852, -0.0025756141, -0.037241705 }, { 0.0083512619, 0.0046235666, 0.024122126, -0.013443654 }, { 0.0010672274, 0.00053123301, -0.0016276029, -0.04221993 }, { -0.0048754166, -0.021474788, -0.0039993317, 0.011831691 }, { -0.054685347, -0.050242732, -0.007606251, 0.043061893 }, { -7.5644942e-05, 0.00086632318, 0.0001960729, 0.0013264286 }, { 0.0042413724, -0.0057181522, 0.0065940983, -0.0078263328 }, { 0.0031260881, -0.0013520907, 0.025073658, -0.010841673 }, { 0.038353769, 0.06620308, -0.0072105562, -0.079188681 }, { 0.003099559, -0.0022927921, 0.021982683, -0.018991144 }, { 0.012285675, 0.0091834074, -0.0041874571, -0.032253924 }, { -0.014563556, 0.009843969, -0.010490279, 0.012979866 }, { -0.005492286, 0.064109426, -0.034795617, -0.020395732 }, { -0.023364141, -0.059336321, 0.080710391, 0.038948527 }, { 0.0028384819, 0.001822471, 0.0012903958, 0.012781079 }, { -0.004510518, -0.0020008272, 0.0017752876, 0.0077607089 }, { 0.032279653, 0.0041906079, -0.034682371, 0.0061335907 }, { -0.0082992317, -0.025250117, -0.017026845, -0.028345042 }, { -0.013132125, -0.026688493, -0.0014827793, -0.003236826 }, { 0.01650781, 0.002313574, -0.012897922, 0.026077933 } }, { { 0.062668058, 0.0081578851, 0.018952049, -0.012267283 }, { 0.0008567722, 0.0033246009, -0.0037620102, -0.0096317368 }, { -0.0083012273, 0.01184624, -0.01209373, 0.020208536 }, { 0.013862003, 0.019166381, 0.013235471, -0.026788736 }, { -0.021904217, -0.051018749, 0.0020330268, 0.006626371 }, { -0.015856131, 0.0028024655, -0.032825412, -0.018920906 }, { 0.0020870233, 0.0011616727, -0.0032704368, -0.027327141 }, { 0.01934969, 0.002427195, 0.049925128, -0.0061414889 }, { 0.013158375, 0.022248445, 0.040266734, -0.017583455 }, { 1.9024812e-05, 0.00071602053, 0.0012622199, 0.0018791611 }, { -0.0011857767, 0.0023417924, 0.026237548, -0.014687892 }, { -0.041419782, 0.024942194, -0.029143101, 0.036590943 }, { -0.015470651, -0.035208671, -0.038530514, 0.037434376 }, { -0.0029356279, 0.0023358079, 0.017641055, 0.0038203652 }, { -0.0030449623, -0.010187444, 0.0066142145, 0.0037433206 }, { 0.0080034603, 0.011463159, -0.0058129532, 0.011831147 }, { -0.0091743137, 0.045949289, 0.022412137, -0.0067531419 }, { 0.00069946656, -0.0068974782, 0.0091806954, 0.0022160793 }, { -0.0027530077, 0.00089797627, 0.0066153093, -0.010355635 }, { -0.019399018, -0.0085762573, 0.0208003, -0.027739023 }, { -0.014354809, -0.011971089, -0.0031124986, 0.044710091 }, { -0.011411144, 0.0073253411, -0.0087561348, -0.014838738 }, { 0.018837992, 0.00231775, -0.013982978, -0.0020044658 }, { 0.0012069362, 0.0012202952, 0.029106153, 0.00062793994 } } }, { { { 0.054154158, -0.11603661, -0.025631275, 0.054671866 }, { -0.2359715, 0.093194255, 0.21874866, -0.08378526 }, { 0.0089903397, 0.0087113885, -0.015445726, 0.011142042 }, { -0.0055372249, -0.0041494086, -0.033355186, -0.010136823 }, { -0.015010227, -0.0077144008, 0.13058394, -0.016779666 }, { -0.015855009, 0.014090685, 0.026549575, 0.025677527 }, { -0.00065423811, -0.0011506403, 0.028628751, 0.0086359197 }, { -0.010571292, 0.035861454, -0.025871285, -0.024827688 }, { 0.00010603924, 0.011433504, -0.052819957, -0.020208661 }, { 0.12243361, -0.14574398, -0.10091072, 0.054524772 }, { -0.014659734, -0.02291001, 0.010102434, -0.0099333349 }, { -0.0079939087, 0.023468399, 0.044548395, 0.04568814 }, { -0.048188816, 0.016469102, 0.084818672, -0.040634065 }, { 0.015089138, 0.025396216, 0.017000121, 0.010820807 }, { -0.0098155552, -0.00080001495, 0.0020122754, -0.00046896909 }, { -0.0018906417, -0.03909342, -0.020339049, -0.024007559 }, { -0.0012744487, -0.027829333, -0.05202457, -0.024366779 }, { 0.10406956, -0.092281421, -0.050420166, 0.10716663 }, { -0.0049603976, -0.0055370076, -0.0016910106, 0.012172389 }, { -0.0026486448, 0.038673757, -0.0016176887, 0.052692494 }, { -0.03722357, 0.055455783, 0.067738953, -0.0087990582 }, { -0.0026491637, 0.017275247, 0.010687117, 0.020312052 }, { -0.0016032469, 0.0090272843, -0.0079027514, -0.0050039898 }, { -0.0073653412, -0.033150577, 0.0082912493, -0.021457881 } }, { { -0.0059001999, 0.033600833, 0.066374213, -0.018058548 }, { -0.0037864945, -0.0064946131, 0.0018627774, 0.0044899139 }, { 0.0048961861, -0.0034770968, -0.0002311598, -0.0053935761 }, { 0.0090090757, 0.012149811, 0.0029969663, 0.0049403543 }, { -0.042874682, -0.0083455851, -0.0064437344, 0.0010579362 }, { 0.011866873, -0.017157526, -0.014724976, 0.0054373752 }, { -0.0006329516, -0.00024834697, 0.0015416168, -0.014246989 }, { 0.031530357, -0.052715858, -0.0063186617, -0.0070200141 }, { -0.0082273844, 0.053856605, 0.0096812384, 0.01684635 }, { -0.00017150577, 0.00097354737, 0.0013944706, 0.00085166684 }, { -0.013604545, 0.0089329355, -0.013809086, 0.0025044469 }, { -0.020284731, 0.0004724419, -0.045697697, -0.01844702 }, { 0.017874081, -0.0040537465, -0.023316716, -0.026344708 }, { 0.0092557469, -0.014456327, -0.0092919835, 0.0091758924 }, { 0.016058873, 0.0019220807, 0.0031692823, 0.0024577167 }, { -0.021184352, 0.021287579, -0.0048442696, 0.0095799112 }, { 0.035229915, -0.054291919, -0.013871324, 0.035585241 }, { 0.001275203, 0.011513119, 0.020184769, -0.0061701639 }, { 0.011353237, 0.0052697685, 0.0047637419, -0.020278005 }, { 0.0068266296, -0.01173749, 0.037482577, -0.0083236299 }, { 0.025699221, -0.03651135, -0.032342446, -0.0059784486 }, { 0.0029540635, -0.0021598269, 0.0028168477, 0.0044577193 }, { 0.0038274002, -0.0050806333, 0.007628551, 0.0027461742 }, { 0.0056567464, 0.006846664, -0.031161558, -0.0040832656 } }, { { 0.025668431, 0.0093723617, 7.4324163e-05, -0.023051436 }, { -0.010148124, 0.0018159908, 0.0072269566, 0.00082671261 }, { 0.0069741056, 0.023493533, 0.028507618, -0.026874125 }, { 0.0083316277, -0.024891629, 0.013623217, 0.0038373532 }, { -0.020992516, 0.070912136, -0.0014634877, -0.015680371 }, { 0.02178962, -0.003772636, -0.024578501, -0.047467019 }, { 0.0028586275, 0.0033445767, 0.0049576063, -0.017365739 }, { 0.0075721122, 0.010652219, -0.024031886, -0.0001146548 }, { 0.016381176, -0.044765924, -0.038036229, -0.014041395 }, { -0.00082564842, 0.00033107944, 0.00073792054, 0.0005712734 }, { 0.0080934887, 0.014534447, -0.0071347609, 0.0085413493 }, { -0.018211778, 0.0064443848, 0.017393403, 0.011490985 }, { -0.071531366, 0.030059694, 0.049103287, 0.0074609412 }, { 0.00770209, -0.017999995, -0.040048679, -0.0029073853 }, { 0.020442166, 0.0019454488, -0.019644905, 0.021793285 }, { 0.035171271, 0.0080192155, -0.023151504, 0.014168348 }, { -0.048901887, -0.0039613606, 0.0021703807, 0.030275152 }, { 0.044666116, -0.029756153, -0.015570779, 0.034470632 }, { -0.0078700362, 0.0037551741, 0.0003070052, -0.0031237403 }, { 0.015288427, -0.01284757, -0.0075319169, 0.026981487 }, { -0.0093872483, 0.013517073, -0.030221944, 0.058356065 }, { 0.0042326205, -0.016381154, 0.021475001, 0.01008732 }, { 0.0034929117, 0.020531314, -0.0085114063, 0.004821913 }, { 0.014314413, 0.01127037, -0.017197896, 0.0046932185 } } }, { { { 0.99591552, 0.99230689, 0.99873374, 0.99387895 }, { 0.96356049, 0.96556546, 0.96964041, 0.96677566 }, { 0.99945097, 0.99930521, 0.99977525, 0.99975808 }, { 0.99900933, 0.99996161, 0.99848418, 0.99879675 }, { 0.99545951, 0.99993863, 0.99032786, 0.9936502 }, { 0.99972964, 0.99989482, 0.99811938, 0.99825798 }, { 0.99999867, 0.99999914, 0.9988702, 0.99980681 }, { 0.99979292, 0.99581299, 0.99736843, 0.99780458 }, { 0.99750292, 0.99805433, 0.99560254, 0.9931383 }, { 0.98142286, 0.98133774, 0.99352772, 0.9929441 }, { 0.99924096, 0.99973689, 0.99916652, 0.99922617 }, { 0.99789446, 0.9974931, 0.99796885, 0.99743448 }, { 0.9976331, 0.99501931, 0.9963379, 0.99287411 }, { 0.99934104, 0.99967648, 0.99984325, 0.99952138 }, { 0.9999147, 0.99999966, 0.99998426, 0.99999714 }, { 0.99825531, 0.99794572, 0.99979313, 0.99901579 }, { 0.99841509, 0.99894779, 0.99643504, 0.99951192 }, { 0.98801309, 0.98864879, 0.99115599, 0.98740957 }, { 0.99998698, 0.99998334, 0.9999824, 0.99983621 }, { 0.99850879, 0.99868574, 0.99803794, 0.99860752 }, { 0.99663402, 0.99573479, 0.99528974, 0.99365325 }, { 0.99938825, 0.99973103, 0.99924472, 0.99943364 }, { 0.99988413, 0.99993848, 0.99989949, 0.99998434 }, { 0.99922338, 0.99887297, 0.998994, 0.9994714 } }, { { -0.0050599833, 0.003362263, 0.0035202243, -0.00056864904 }, { -0.0014675187, -0.0029154981, -0.00077796172, -0.0027392627 }, { -0.0010916411, 0.00078232803, 0.0014339533, -0.0020166729 }, { 0.011183745, 0.008298699, 0.011631254, 0.00030693508 }, { -0.0012964861, -0.00028098882, 0.00098513135, -0.0052243577 }, { 0.0091119501, 0.002780703, 0.011045274, 0.00334383 }, { 4.1103001e-05, 5.5767744e-05, 0.0030605577, 0.0022152241 }, { 0.00085375099, 0.0026952672, 0.0071937971, 0.0056504112 }, { -0.003773118, 0.0047936307, -4.5743022e-05, -0.0038357994 }, { 2.3815581e-05, 0.0002468657, 0.00013492048, -0.00018410816 }, { 0.0070959632, -0.00205589, 0.0056417297, 0.0030702073 }, { 0.010671769, 0.0074346008, 0.0012867659, 0.0075437523 }, { -0.0013037272, -0.0058374269, 0.0025899757, -0.0071565118 }, { 0.0030041304, 0.0018011397, 0.0093160386, 0.0082062863 }, { 0.0053156934, 0.0036543193, 0.0048724246, 0.0035118324 }, { -0.0053866158, 0.0024053442, 0.00052459148, 0.0090970513 }, { 0.011239324, -0.0010327051, -0.00097551594, 0.0044180668 }, { -0.0024379533, -0.0088232426, -0.012355568, -0.0031875953 }, { 0.0026244123, 0.0011858999, 0.0028110843, -0.001005442 }, { 0.0059514328, 0.0018892606, 0.0050231625, 0.0046700575 }, { 0.00050741664, 0.0096547476, -0.00079618251, 0.0024532112 }, { 0.0058717468, -0.0017457656, 0.0080261577, -0.00048009588 }, { 0.0025457914, 0.0016788968, 0.0013982313, 0.00073909928 }, { 0.0075035778, 0.011234409, 0.0079271096, 0.006672353 } }, { { 0.0095152396, 0.0011785006, -0.00081996856, 0.0018904938 }, { -0.0025430397, -0.0010236291, -0.0020168276, -0.0021827861 }, { 0.0036295778, 0.005406882, 0.0040788276, -0.0057729163 }, { -0.00029952998, 0.0024548208, 0.0088548836, 0.0019084209 }, { 0.0034184324, -0.0088925589, 0.00023040452, 0.00017437939 }, { 0.0037804595, 0.012156355, 0.0041276361, 0.012721488 }, { 7.4846461e-05, 0.00010580108, 0.013483417, 0.0024239851 }, { 0.00026411032, -0.00059353627, 0.0093564271, 0.0061507538 }, { 0.0016065383, -0.0027764641, 0.0013620195, 0.0010062065 }, { 9.7127925e-05, 0.00017275393, 1.0814607e-05, -0.00022627793 }, { 0.0048710612, -0.00014794569, 0.0082832436, -0.00072595412 }, { -0.0027392579, 0.0066783951, 0.00087397132, 0.001567366 }, { -0.003378151, 0.0025916338, -0.0025553201, 0.0030152022 }, { 0.0096818399, 0.0012695523, 0.0072489949, 0.016881099 }, { 0.0022796191, 0.0051693266, 0.0023373397, -0.0041448561 }, { -0.0002074582, 0.0035962454, -0.0007460719, 0.0025086317 }, { 0.0035784996, 0.003162753, 0.0022592918, 0.00024595998 }, { -0.0051294944, -0.0041428868, -0.0027597, -0.0039539398 }, { 0.0022410392, 0.00031263884, 0.0016376751, -0.0022787113 }, { 0.0025647038, 0.0074733037, 0.0051722028, 0.0024463612 }, { 0.0011787227, 0.0071159753, 0.0017217143, 0.0062717989 }, { 0.0046836737, 0.0038976423, 0.00062832002, 0.0027638154 }, { 0.0014142926, 0.0024903802, 0.0015757227, 0.0011628587 }, { 0.0016928585, 0.0043828548, 0.001653268, 0.011450696 } } }, { { { 2.8886078, 2.8900127, 2.7925705, 2.7895874 }, { 4.5455217, 4.5284714, 4.7042338, 4.6915273 }, { 0.96672505, 0.99303664, 0.98927606, 1.0351588 }, { 1.2743756, 1.2525364, 0.99649566, 0.94572778 }, { 2.6910679, 2.6922168, 2.8503404, 2.8246076 }, { 1.256075, 1.2325025, 1.5911826, 1.6091223 }, { 1.3601759, 1.3606869, 1.2793533, 1.240925 }, { 2.0291828, 2.0506809, 1.7341658, 1.6555689 }, { 2.6663531, 2.6921882, 3.1290975, 3.11849 }, { 5.3676887, 5.3663279, 5.3848664, 5.3852162 }, { 1.0586431, 1.0865889, 0.8196623, 0.8076665 }, { 1.6967251, 1.7305944, 1.5450413, 1.6347879 }, { 3.0908857, 3.0706775, 3.2974343, 3.3053965 }, { 1.2172073, 1.3839086, 1.5086796, 1.4295506 }, { 0.97676668, 1.0856738, 0.98747912, 1.0385491 }, { 1.5662275, 1.4603538, 1.784278, 1.6575438 }, { 2.1085757, 2.2092885, 2.1410448, 2.1518347 }, { 4.0214776, 4.006424, 3.7686967, 3.7771354 }, { 1.2089239, 1.2116036, 1.1244311, 1.0901017 }, { 1.1827246, 1.1472796, 1.7516784, 1.7833976 }, { 2.2113439, 2.197512, 2.2692963, 2.2787751 }, { 0.98819531, 1.057833, 1.3587301, 1.3890421 }, { 1.208957, 1.2247867, 1.2301205, 1.2325178 }, { 1.0499613, 1.1319197, 1.4067885, 1.3209087 } }, { { -0.002860931, -0.0033581281, -0.0047612075, -0.0030481839 }, { -0.0017370907, -0.0065700936, -0.0011051926, -0.0046915938 }, { -0.0006126207, 0.0010791181, -0.022876686, -0.015937275 }, { -0.010040922, -0.016433531, -0.0044976975, -0.029838315 }, { 0.00056888968, -0.0093450028, -0.00041549218, -0.0069079656 }, { -0.029781683, -0.019722587, 0.019472312, 0.0016798037 }, { -0.0015128736, -0.0012250172, -0.0091568262, -0.0091368119 }, { 0.0010846814, 0.0017189068, 0.012975603, -0.0051530971 }, { -0.026042808, -0.0090684857, -0.0021498742, -0.0032938309 }, { -0.0012792901, -0.0010431731, -0.0021366737, -0.0025526365 }, { -0.03218779, -0.013848893, -0.021872476, -0.029443623 }, { 0.008300061, 0.011951182, -0.011139414, 0.0098292843 }, { -0.0065854884, -0.020955083, -9.3843515e-05, -0.0078425688 }, { -0.054726229, -0.0073673428, -0.019267231, -0.03383648 }, { -0.049769726, 0.0065482059, -0.010189395, -0.0050480393 }, { 0.022565943, -0.020311569, 0.0091512717, -0.015600752 }, { -0.014418429, 0.0060070592, -0.0055296743, -0.003361885 }, { 8.8146509e-05, -0.0082609252, 0.0036746024, 0.0040108321 }, { 0.0010230427, 4.8153189e-06, 0.0052893378, -0.0096303521 }, { 0.0032909351, -0.010982824, 0.003880027, 0.0097699095 }, { -0.006528317, -0.012608887, -0.0057088008, -0.003867806 }, { -0.046599771, -0.024701737, -0.001078321, -0.0041018649 }, { -0.021680777, -0.021120711, 0.0055144734, -0.0031337995 }, { -0.030559213, 0.0089872726, -0.011166202, -0.0077587071 } }, { { -0.0059548858, -0.0040070313, -0.0062572119, -0.0047711065 }, { -0.0031938803, -0.005431389, -0.0026376521, -0.0046119366 }, { 0.0064917253, 0.013030824, -0.027850471, -0.011824849 }, { -0.032644485, -0.025045016, -0.0034396539, -0.039827623 }, { -0.007691681, -0.014095643, -0.0008171964, -0.0051336386 }, { -0.035626586, -0.021424668, 0.00035790929, 0.0099705685 }, { -0.0019006762, -0.0014887089, -0.0050782898, -0.0096835564 }, { -0.00087496879, 0.0052586834, 0.017041675, -0.00046753956 }, { -0.022489507, -0.0084834888, 0.0017184219, -0.0023910992 }, { -0.0010618265, -0.00085888729, -0.0020035777, -0.0024245283 }, { -0.029245834, -0.038977066, -0.013385246, -0.030312138 }, { -0.0028497869, 0.014205986, -0.0125692, 0.0037959624 }, { -0.0086377959, -0.019175965, -0.007684309, -0.005037677 }, { -0.063945685, -0.0060751259, -0.0057457302, -0.019079575 }, { -0.043745147, 0.013651906, -0.034067394, 0.0012111497 }, { 0.0086647574, -0.019171418, 0.020745219, -0.0055629951 }, { -0.024541273, 0.0072112135, -0.0078821942, -0.0085072621 }, { -0.0018227939, -0.0021153099, 0.008577002, 0.0043865151 }, { -0.013984752, -0.012209334, 0.00023638151, -0.0085025952 }, { -0.0099800075, -0.0095390578, 0.0081328135, 0.012673433 }, { -0.0099975551, -0.0028467616, -0.010712056, -0.0045012212 }, { -0.011329139, -0.0084709831, -0.0070232966, 0.0015504012 }, { -0.015334801, -0.0075637633, -0.01107439, -0.0094188163 }, { -0.017505269, -0.00013701888, -0.033955823, -0.034192649 } } }, { { { 0.16413327, 0.084074422, 0.10646123, 0.18806073 }, { 0.039511019, 0.058967072, 0.035166958, 0.052296507 }, { 0.26970995, 0.21576211, 0.2954278, 0.29870678 }, { 0.40442043, 0.38744132, 0.14502571, 0.24076804 }, { 0.22655046, 0.20912486, 0.015295019, 0.16442957 }, { 0.69235319, 0.6080183, 0.36756076, 0.23314717 }, { 0.085565328, 0.075535626, 0.22162979, 0.33140596 }, { 0.16109547, 0.11961895, 0.26619212, 0.25941009 }, { 0.27077686, 0.23481238, 0.063446408, 0.11614487 }, { 0.026116057, 0.027491327, 0.030421883, 0.039965345 }, { 0.33922592, 0.38039792, 0.27167385, 0.31510976 }, { 0.32744968, 0.22567102, 0.23116584, 0.18867836 }, { 0.29783431, 0.28054079, 0.26752139, 0.23889932 }, { 0.61721263, 0.60602797, 0.51283622, 0.47601102 }, { 0.51383952, 0.53111455, 0.44519064, 0.42875877 }, { 0.3485879, 0.35374178, 0.53292055, 0.53995494 }, { 0.4366997, 0.35554257, 0.14878367, 0.22083288 }, { 0.12855375, 0.16718264, 0.17583661, 0.11125895 }, { 0.35898096, 0.37222307, 0.35439108, 0.35956111 }, { 0.16773044, 0.25668894, 0.23246756, 0.1506316 }, { 0.36172813, 0.26938211, 0.20069185, 0.1714591 }, { 0.3998571, 0.23607244, 0.34121623, 0.29126696 }, { 0.31471307, 0.29500525, 0.39451396, 0.40013999 }, { 0.29554399, 0.28083636, 0.47190649, 0.47892938 } }, { { 0.01419653, -0.061214452, -0.032506906, 0.0078227125 }, { -0.015799432, 0.0136148, -0.0090824684, 0.013638505 }, { 0.023848919, 0.022034707, 0.022812846, 0.022790329 }, { -0.0026324255, -0.0053566952, 0.00027470228, 0.050203583 }, { 0.0035659857, -0.02015272, -0.039043616, 0.054511651 }, { 0.0052075445, 0.0051043119, -0.011801097, -0.0074336577 }, { 0.020735195, 0.01811747, 0.00808952, 0.01140964 }, { -0.0073139049, 0.011075347, 0.0057685988, 0.010251582 }, { 0.024813488, -0.01629986, -0.012536791, -0.01110061 }, { -0.014508648, -0.021444084, -0.023836972, -0.014258253 }, { 0.0079687141, -0.00092011446, 0.060249601, 0.033199468 }, { -0.020822483, -0.013924875, -0.005068391, -0.016928794 }, { -0.030059, -0.013887475, -0.045329289, -0.04449219 }, { 0.007264541, 0.0015213919, -0.0066322618, -0.0036449174 }, { 0.0057175046, 0.0012159867, -0.00054271896, 0.0020625484 }, { 0.0027083179, -0.0012554897, -0.0044854592, -0.0045242423 }, { -0.017906563, -0.028301884, -0.010139427, 0.0035851304 }, { -0.020245794, 0.01149232, 0.011320484, -0.013561794 }, { 0.0068048997, 0.011957759, 0.0046962412, -0.0015476541 }, { -0.0022514613, 0.019996868, 0.0051520398, -0.023405604 }, { 0.0055213198, 0.0070384134, 0.024405643, -0.02050399 }, { 0.039987541, 0.021127504, -0.012323503, -0.0041538161 }, { 0.0072321478, 0.0053097351, 0.0039966161, 0.013617175 }, { 0.030470642, 0.0044694115, -0.0024591651, -0.0027274707 } }, { { -0.040500402, -0.039657034, -0.017497359, -0.017857145 }, { -0.0015646885, -0.020957371, -0.0057356498, -0.0060587007 }, { 0.0070388709, -0.013205178, -0.00033412934, 0.02192306 }, { -0.0042317723, 0.020620857, -0.012309167, 0.065948811 }, { -0.016686589, 0.013616667, 0.030139062, -0.019023551 }, { 0.015181564, 0.008673659, -0.0014559576, -0.025916054 }, { 0.031630671, 0.027030197, -0.026982415, 0.025214731 }, { -0.003845127, -0.00062884599, -0.029488655, -0.0051457939 }, { -0.0032476351, 0.0021153707, -0.033110808, -0.033629213 }, { -0.0064637077, -0.010805748, -0.014982403, -0.0084641529 }, { 0.0087766042, 0.017780238, 0.026838871, 0.032580257 }, { 0.0010700985, -0.037414784, -0.0053773565, 0.0040969752 }, { -0.02637392, -0.050236074, -0.048422986, -0.069357813 }, { -0.0089483588, 0.0026259727, 0.0040142797, -0.010752754 }, { -0.0025658872, 0.0071106029, 0.015467367, 0.0012536589 }, { -0.0037247444, -0.0036991733, -0.015429566, -0.016148852 }, { -0.024788221, -0.045938054, -0.028679471, 0.011593494 }, { -0.032699114, -0.036800967, -0.033870575, -0.031842203 }, { 0.018156047, 0.02457546, 0.0209432, 0.015057433 }, { 0.0043152638, 0.025831372, -0.019608349, -0.026614397 }, { -0.0057047815, -0.013831909, 0.027613211, -0.043616864 }, { 0.014124478, -0.010786326, 0.010775415, -0.023241344 }, { 0.018337827, 0.0048735321, 0.018371717, 0.022106807 }, { 0.013619207, 0.022051384, 0.0082720974, -0.0030262071 } } } }, { { { { 0.083322661, 0.079807165, 0.03660117, -0.051657142 }, { -0.099216074, -0.0080141573, 0.10637241, 0.0367403 }, { 0.20813681, -0.0001361621, -0.20762563, -0.085913357 }, { -0.22091149, 0.10003156, -0.16122219, 0.31542901 }, { 0.16226908, 0.02665194, -0.012123307, -0.16559939 }, { -0.14025496, 0.025804505, 0.076174345, 0.20548591 }, { 0.0035713609, -0.0092551928, -0.099937652, 0.0038879391 }, { 0.12405732, -0.0053373497, -0.030865175, -0.060934551 }, { -0.0060175826, -0.026583926, -0.075326797, -0.0063155886 }, { 0.036389362, 0.054175433, 0.06490927, -0.038784258 }, { 0.30604876, -0.030813476, 0.011402956, -0.21074796 }, { -0.31769497, 0.046793931, -0.038212559, 0.21137297 }, { 0.12952945, 0.20720126, 0.08525845, -0.14568109 }, { -0.09735197, -0.17799099, -0.12256082, 0.038889119 }, { 0.002114572, 0.026037779, -0.0036772795, 0.13478173 }, { 0.094577863, 0.0057382415, -0.087017736, -0.059444148 }, { 0.054953104, 0.071323301, 0.097417831, 8.3254475e-05 }, { -0.11005534, 0.027214076, 0.0059378205, 0.02443999 }, { 0.27096654, 0.1864966, 0.034810947, -0.25886676 }, { -0.35626794, 0.037256657, -0.17795321, 0.52988269 }, { 0.14913899, -0.0086988732, -0.028760192, -0.21779266 }, { -0.16010301, -0.17699785, 0.017269826, 0.17878541 }, { -0.0049504093, -0.02387924, -0.04034852, -0.060461173 }, { 0.10405347, 0.0072745723, -0.10244372, -0.072981984 } }, { { 0.019363393, 5.327311e-05, 0.0075925373, 0.0019542034 }, { -0.051707557, 0.06554253, 0.0050626046, -0.0061857803 }, { 0.022891698, 0.014872273, -0.020436928, 0.0069081531 }, { -0.044566611, 0.019854557, 0.023600607, -0.0055387351 }, { 0.02283957, -0.067086756, 0.088865856, -0.033915007 }, { 0.0020254431, -0.16422426, 0.032495902, 0.012460808 }, { -0.017316175, 0.023440087, 0.011459595, 0.0043887872 }, { 0.027714908, -0.06907548, 0.013578806, -0.009848884 }, { 0.0044782488, 0.0079432606, 0.010143137, 0.023589488 }, { 0.014325082, 0.0075465848, -0.0079373813, -0.0056032635 }, { 0.025123579, 0.01904807, -0.0092328848, -0.019002052 }, { -0.02633985, -0.019560519, -0.065544737, 0.0073352606 }, { 0.044308433, -0.0032233834, 0.01324206, -0.00047128106 }, { -0.076577611, -0.021853603, -0.020190543, 0.0026420865 }, { -0.0029799448, -0.0083566545, 0.14896601, 0.0078617095 }, { 0.021033237, -0.08234711, -0.020642328, -0.0089829962 }, { 0.043793881, 0.0096494147, 0.035831274, -0.01294602 }, { -0.014064874, 0.066144489, 0.0143429, 0.015113964 }, { 0.043111732, 0.0029232804, -0.016912145, 0.012142059 }, { 0.0014186333, -0.0078590166, 0.065781153, -0.038375123 }, { 0.02255714, -0.030191796, -0.078373164, -0.0017593196 }, { -0.033878798, 0.016266579, 0.013539653, 0.043519216 }, { 0.019046482, 0.0080403173, -0.0010755939, 0.03305222 }, { 0.023206448, -0.054323067, -0.035173093, -0.010873592 } }, { { 0.014068291, -0.026418786, 0.016375695, 0.0048801469 }, { 0.024404214, 0.0073572002, -0.027247654, 0.00093849398 }, { 0.012741523, -0.012913063, 0.0054881373, -0.021780769 }, { -0.020497215, 0.057437717, 0.0031122704, 0.014713732 }, { 0.012765254, -0.052846334, 0.048042201, 0.0016578534 }, { 0.031245254, -0.0469321, -0.057199738, 0.012436479 }, { -0.0022837759, 0.0068501747, 0.010541107, -0.0005227683 }, { -0.0187059, 0.0025631581, -0.0082184266, 0.0026294483 }, { 0.0053899388, -0.0199458, 0.0023448066, 0.016215236 }, { 0.021117204, 0.010868775, -0.016412681, -0.016399297 }, { -0.0026199223, -0.011436548, 0.0031355049, 0.011933919 }, { 0.017940023, 0.090292392, -0.061029038, 0.016388845 }, { 0.0074493061, -0.045849358, -0.082612855, 0.025851315 }, { 0.061276666, -0.024654813, 0.035447334, -0.025952766 }, { -0.0068267167, -0.02207426, 0.003724368, 0.0070458116 }, { 0.021714649, -0.017552721, -0.037105408, 0.024398534 }, { 0.0092901891, -0.021559075, 0.009034776, -0.016574279 }, { -0.017218595, -0.041930302, 0.003369899, 0.017959363 }, { -0.0022510875, 0.028106616, -0.042936548, -0.041948028 }, { -0.017145551, -0.032331654, 0.021486923, -0.020295391 }, { -0.023196465, -0.088353584, 0.010086154, 0.018689553 }, { -0.024508386, -0.00058959302, -0.02867958, 0.019018994 }, { 0.0088748911, 0.012528454, -0.016636351, 0.0078166115 }, { 0.00066772723, 0.001693912, 0.032066885, 0.016951148 } } }, { { { 0.015200105, 0.071414961, -0.020616434, 0.0063982643 }, { -0.084578144, -0.12318522, -0.035470756, 0.057833574 }, { 0.19487946, 0.44043059, 0.10981527, -0.31907303 }, { -0.17774238, -0.30460726, -0.53133003, 0.31186606 }, { -0.1172677, 0.3183613, 0.10375266, -0.066515168 }, { 0.054176263, -0.12382077, -0.033807438, 0.039809238 }, { -5.3634009e-05, 0.004084452, 0.005103199, -0.060697866 }, { 0.06093199, 0.060355274, 0.049176467, -0.060579228 }, { 0.054611799, 9.0520863e-05, -0.048891261, -0.047609349 }, { -0.036428706, 0.06336736, 0.0020843807, 0.033254378 }, { 0.26975732, 0.51328693, 0.29976157, 0.049031141 }, { -0.28383516, -0.48219276, -0.27898799, -0.033028759 }, { -0.078976834, 0.14077934, 0.098587186, 0.051336328 }, { 0.076281206, -0.074223398, -0.053178835, -0.099578331 }, { -0.056377095, -0.00066113896, -0.11597726, 0.058805777 }, { -0.0027130032, 0.12007881, 0.0081935835, -0.10415807 }, { -0.019349408, 0.06206561, -0.0079099126, 0.079363093 }, { -0.059959607, -0.0591041, -0.047505451, -0.0031496967 }, { -0.11419194, 0.20904287, 0.53960104, 0.10467592 }, { -0.21312862, -0.34770872, -0.54593093, 0.23230512 }, { -0.073229448, 0.12913, 0.27728133, -0.050627706 }, { 0.082312471, -0.24529296, -0.12381516, 0.05577292 }, { 0.03015389, -0.0015805638, 0.024306632, -0.080697961 }, { 0.061367564, 0.056058289, 0.041197211, -0.015551356 } }, { { -0.029269776, -0.030251548, 0.01352869, 0.0084860712 }, { 0.053983187, 0.047657625, -0.026379004, 0.022474039 }, { 0.011898439, 0.045120742, -0.024430477, -0.081318878 }, { -0.0012641508, -0.018495044, -0.030127865, -0.0088483264 }, { 0.040728292, 0.010691761, -0.023566342, 0.028045232 }, { 0.014593998, 0.0047006468, -0.049032498, -0.011446808 }, { 0.00045433705, -0.0030610749, -0.010359449, -0.0026455857 }, { -0.0026794352, -0.032142744, 0.010153936, -0.0034586152 }, { 0.0097198782, 0.0051005644, 0.03482872, -0.0043676475 }, { -0.0012381415, -0.025746274, -0.0081178021, 0.0041481596 }, { -0.01598781, 0.0048815642, 0.06313106, -0.0062291669 }, { 0.072970618, -0.041153529, -0.007457013, 0.059776924 }, { 0.0024768493, 0.0093018711, 0.024827984, 0.043842172 }, { -0.012927661, -0.023256709, -0.0035951539, -0.069710027 }, { 0.0064149713, 0.0019783425, 0.010135188, 0.019449636 }, { -0.0071551675, 0.015761815, 0.0086309278, 0.038854386 }, { 0.020978109, -0.0056696814, 0.0025526797, -0.017352926 }, { -0.010711116, -0.0097050903, 0.0022304504, -0.0039308489 }, { 0.036904234, 0.025927127, 0.028330671, 0.051193417 }, { -0.00076391153, -0.077528792, -0.029763477, 0.0033945843 }, { -0.01775202, 0.034507636, 0.065392848, -0.017840909 }, { -0.019567742, -0.019880035, 0.055214211, -0.02206159 }, { 0.01110111, 0.0022938832, -0.011417507, 0.017692635 }, { 0.050208493, -0.028178909, 0.0065276591, -0.0056267473 } }, { { 0.0065622702, -0.0012303136, -0.0081183663, 0.00079383048 }, { 0.030775912, 0.052260356, -0.019758331, -0.020044147 }, { 0.019016537, -0.043070451, 0.035298744, -0.040592775 }, { 0.010468089, 0.00057085185, 0.0081761984, 0.0033382478 }, { 0.047189462, -0.052695409, 0.021849623, 0.033585939 }, { 0.0012065616, -0.050287476, -0.065085924, -0.039012886 }, { -0.012294892, 0.006839242, 0.0051165438, -2.0711078e-05 }, { -0.03292822, 0.015299577, 0.0029119931, 0.0073040242 }, { -0.0086784873, 0.0085910164, -0.0059378411, -0.010259049 }, { -0.014191355, -0.011172486, -0.01299927, 0.015386671 }, { 0.040453224, -0.041489173, 0.015047889, 0.064340197 }, { -0.020000046, 0.058477092, -0.0018150465, 0.048536972 }, { -0.006105982, 0.03437044, 0.0087640339, 0.032868283 }, { -0.027120362, 0.016579996, -0.01708524, 0.011178424 }, { 0.030535528, 0.0058718219, -0.031240404, 0.024241052 }, { 0.003729958, -0.055735848, -0.0055392842, 0.03447519 }, { -0.04084502, -0.01227488, 0.0062970198, -0.021996031 }, { 0.053671675, -0.067787009, 0.0053426012, -0.0080796738 }, { -0.021911856, 0.038395527, -0.07713235, 0.024805484 }, { -0.0034319194, 0.0052741327, 0.026402991, 0.0012916612 }, { -0.033119652, -0.0046506889, 0.045613946, -0.050230593 }, { -0.0054612035, -0.033482221, 0.084267507, -0.0224334 }, { -0.0063348693, -0.0074524817, -0.0029629355, 0.035493958 }, { -0.0073519185, 0.045139911, 0.0022901735, -0.041385515 } } }, { { { 0.99640669, 0.99424882, 0.99911727, 0.99864438 }, { 0.99146493, 0.99235134, 0.99369348, 0.99764995 }, { 0.95848895, 0.89778665, 0.9720248, 0.943828 }, { 0.95896077, 0.9472107, 0.83168251, 0.89623886 }, { 0.97975356, 0.94759472, 0.99452924, 0.98394744 }, { 0.98863213, 0.99196902, 0.99652121, 0.97785007 }, { 0.99999362, 0.99994883, 0.99498061, 0.99814861 }, { 0.99040248, 0.99816269, 0.99831309, 0.99630173 }, { 0.99848953, 0.99964658, 0.9959596, 0.99884607 }, { 0.9986735, 0.99651874, 0.99788899, 0.99869411 }, { 0.91299789, 0.85766372, 0.953946, 0.97631002 }, { 0.90471405, 0.87481454, 0.959534, 0.97684726 }, { 0.9884254, 0.96811612, 0.9914694, 0.98799879 }, { 0.99232241, 0.98122887, 0.99103524, 0.99426948 }, { 0.99840731, 0.99966074, 0.99324506, 0.98912879 }, { 0.99551377, 0.99274778, 0.99617307, 0.9927827 }, { 0.99830144, 0.99552039, 0.99521214, 0.99684577 }, { 0.99211525, 0.9978808, 0.99885333, 0.99969634 }, { 0.95579147, 0.95995838, 0.84120087, 0.96022443 }, { 0.90975235, 0.9368621, 0.81871367, 0.8156339 }, { 0.98610091, 0.99158952, 0.96035822, 0.97468107 }, { 0.98366238, 0.9531543, 0.99215501, 0.98230604 }, { 0.99953301, 0.9997136, 0.99888998, 0.99490315 }, { 0.99267663, 0.998401, 0.99388534, 0.99721201 } }, { { -0.0021537732, 0.010607958, -0.0066166595, -0.0027390442 }, { -0.0069401807, 0.0053215201, 0.0062121114, 0.013403291 }, { -0.0035740125, -0.021839368, 0.00042431197, -0.029478899 }, { -0.007886159, -0.0087705321, -0.010570968, 0.0040635318 }, { -0.0021772698, 0.00025306776, -0.0092725896, -0.0075657706 }, { -0.010438319, -0.0072866821, 0.009272756, 0.0043932916 }, { -0.00058203184, 0.0081284104, 0.027749999, 0.0035426599 }, { -0.003604276, -0.012244348, 0.0072177908, 0.0026686264 }, { 0.011192179, 0.0069527119, 0.017278396, -0.0053058312 }, { -0.020276487, -0.0063228657, 0.013968347, -0.0021534789 }, { -0.0037534313, 0.00061399133, -0.02126817, 0.0085256452 }, { 0.015620795, -0.022637876, 0.00069280338, 0.0054369037 }, { 0.0095244184, -0.0026896982, -0.0057963534, 0.0067237437 }, { -0.0085689961, -0.004816024, -0.00088793436, -0.0034021999 }, { 0.015428153, 0.019777562, -0.011217833, 0.0095744159 }, { -0.003802304, 0.0022643577, 0.0054254827, 0.025560756 }, { -0.0053298651, 0.021621993, -0.01864184, 0.019120967 }, { 0.015380344, -0.0027384467, 0.0010235928, 0.0062792725 }, { -0.001166873, -0.0049586656, -0.014850883, 0.00057841904 }, { 0.0032865456, -0.033386196, 0.0032068954, 0.02854738 }, { 0.010308266, -0.000233004, -0.020287643, 0.0044441043 }, { -0.0040523345, 0.0050367711, 0.01627907, -0.010032412 }, { 0.0073463987, 0.00073274858, 0.002814661, 0.030221018 }, { 0.0057509063, -0.011441338, 0.01894259, 0.0077856453 } }, { { -0.0053054924, 0.0037677068, 0.0066263851, 0.0011220287 }, { -0.02212139, 0.013769097, -0.0013834097, 0.014152363 }, { -0.0008493126, 0.021473024, -0.0039313241, -0.017764981 }, { -0.00081897848, -0.0074161164, 0.0038179092, -0.0035760615 }, { 0.014045643, 0.015317904, 0.0045966739, 0.0075917156 }, { 0.0035574126, -0.00017773424, -0.0010937491, -0.0017762282 }, { 0.0072018344, 0.012586227, 0.0138702, -0.0085424173 }, { -0.0055783456, -0.019909385, 0.01190919, -0.0065821489 }, { 1.7402026e-05, 0.0094513341, 0.015333305, -0.0072158969 }, { -0.0063049905, 0.0021776758, 0.014376378, 0.0072426401 }, { -0.0078049673, 0.028764242, -0.0024169449, 0.0077604105 }, { 0.00047536469, 0.029806623, 0.0017798261, 0.00087410198 }, { -0.0030498401, 0.0044874501, 0.0020382571, -0.0011101062 }, { -0.0057084397, -0.0013428994, -0.001024136, 0.0066188614 }, { 0.039201052, 0.015120258, -0.0082642793, 0.0051985023 }, { -0.0091203243, 0.020790215, 0.0025270937, 0.020092044 }, { -0.0029830063, 0.006602841, -0.00833601, 0.044852353 }, { 0.025206353, -0.0038915173, 0.00045914851, 0.0037840538 }, { 0.0014814254, -0.011573911, 0.046232337, -0.015228958 }, { -0.0071984443, 0.0090004063, 0.022942838, 0.016019787 }, { 0.0050929336, 0.0060892107, -0.0061771339, 0.0047850766 }, { -0.011634853, 0.0010276548, 0.022396644, -0.0021248711 }, { -0.012943002, 0.0016430074, 0.02034928, 0.024289705 }, { 0.0051047037, 0.010052556, 0.0020923265, -0.019043181 } } }, { { { 2.1627647, 2.1788232, 1.9290264, 1.8457806 }, { 2.526488, 2.3020441, 2.538915, 2.03484 }, { 3.9987521, 4.3952121, 3.906821, 4.1693278 }, { 4.0400466, 4.1069844, 5.2512999, 5.4283264 }, { 3.0141968, 3.3306035, 3.2224806, 3.2473051 }, { 2.9840674, 3.1294685, 3.2964833, 3.2929246 }, { 1.8346741, 1.8637353, 2.3037966, 2.0860888 }, { 2.691236, 2.6068079, 1.9349032, 2.1632935 }, { 1.9231956, 1.7251627, 2.1609654, 2.1155629 }, { 2.165771, 2.1908952, 1.777038, 2.0223741 }, { 4.5166991, 4.8674508, 3.918546, 3.378087 }, { 4.4502295, 4.5429338, 3.9552598, 3.3580272 }, { 3.0973598, 3.3953852, 2.2704362, 2.6488177 }, { 3.2110537, 3.3104376, 2.515002, 2.3267785 }, { 1.8303675, 1.7094345, 3.1787979, 2.5960104 }, { 2.4391795, 2.8730077, 2.3730261, 2.1545299 }, { 2.2130903, 2.1899209, 2.4997355, 1.9058674 }, { 2.6472893, 2.5455636, 2.1164596, 1.8341163 }, { 3.9428283, 4.0433678, 4.5430063, 4.2482776 }, { 4.1941673, 4.28852, 4.64044, 4.6644567 }, { 3.0873642, 2.649364, 3.6026133, 3.2426354 }, { 3.2415154, 3.5406745, 3.2976852, 3.3100246 }, { 1.8400289, 1.8404692, 1.889289, 2.0125184 }, { 2.7063995, 2.7229173, 2.6289878, 2.4313709 } }, { { -0.015335928, -0.043382119, -0.0054163805, -0.028249934 }, { -0.017200109, 0.0027582413, -0.079612821, -0.0013966663 }, { -0.027233584, -0.018783395, -0.01183278, -0.020918937 }, { -0.0036358348, -0.015712206, -0.0089146421, -0.0057117233 }, { 0.020392865, 0.017743746, -0.068597326, -0.030425581 }, { -0.041123673, -0.020767538, -0.0087941887, -0.0065248183 }, { -0.0055478408, -0.00082196865, 0.0088521402, -0.045916836 }, { -0.010506485, 0.0078523247, -0.030002306, -0.0015085765 }, { 0.01894068, -0.012424968, -0.034837214, -0.045009941 }, { -0.045299587, 0.02630478, -0.017175711, -0.043601235 }, { -0.046003661, -0.020588165, 0.034398873, -0.054653787 }, { -0.0042534368, 0.01325834, -0.0036369576, -0.079162988 }, { -0.028728556, 0.0051289128, 0.012104313, 0.010686997 }, { -0.066337767, 0.00059928728, -0.080303668, 0.011318772 }, { -0.031879871, 0.0011317962, -0.050259029, 0.0031596552 }, { -0.090121238, -0.011196084, -0.072456123, -0.00079731072 }, { -0.024243475, 0.021401076, -0.018209385, -0.0083196072 }, { -0.079888701, 0.0032806631, -0.12762259, -0.04652308 }, { 0.031806075, -0.034165157, -0.015255921, -0.049164663 }, { -0.0012051123, 0.030788487, 0.022291919, 0.0025694519 }, { 0.035836509, 0.0055365388, 0.026704836, 0.0001547235 }, { -0.012129747, -0.0094322145, -0.040637935, -0.12125388 }, { -0.027044986, 0.04531553, -0.033484589, -0.0059927923 }, { 0.0067188802, -0.051166351, -0.048822794, -0.025926988 } }, { { 0.022049053, 0.021265778, -0.040370641, -0.036232952 }, { -0.0058098424, -0.0042264198, -0.077428509, -0.04241654 }, { -0.0026825379, -0.029453318, -0.016181275, -0.028320229 }, { -0.012541692, -0.01345735, 0.00037814888, -0.0046052489 }, { -0.026527394, 0.020033638, -0.025683861, -0.084207169 }, { -0.0010459945, -0.036745215, -0.039772051, 0.024810839 }, { 0.012134618, 0.0068515798, -0.035286972, 0.043129595 }, { -0.077093357, -0.026872688, 0.032800133, -0.090326706 }, { 0.13930909, 0.0081274014, -0.08349188, -0.012200005 }, { -0.091693797, -0.012567011, -0.069736822, -0.0061444184 }, { -0.053061301, 0.003642159, 0.0052515175, -0.036957472 }, { 0.0043493933, -0.013069332, -0.014708126, -0.032765039 }, { -0.016116105, -0.022907609, -0.043503106, -0.013266465 }, { -0.072759977, -0.077354585, 0.0043827591, -0.013821612 }, { -0.032399073, -0.045305037, -0.021840791, 0.073996542 }, { -0.057239255, -0.056581235, -0.038880927, 0.044102943 }, { -0.026951489, -0.088667645, -0.013659704, 0.033527579 }, { 0.034815442, -0.028634059, -0.036666529, 0.011546036 }, { 0.026688447, -0.0081892129, -0.031138092, -0.041739155 }, { 0.0015665701, -0.012701682, 0.0013533943, -0.002849785 }, { 0.032994636, 0.008802974, 0.019032649, 0.0039042621 }, { -0.044544917, 0.0093201326, -0.017968915, 0.01936344 }, { -0.034794535, 0.043032983, -0.051072531, -0.040148303 }, { -0.0030398597, -0.027112065, -0.064007483, -0.01798277 } } }, { { { 0.22040906, 0.24911942, 0.41660708, 0.23632869 }, { 0.25894466, 0.1416669, 0.41902981, 0.35717608 }, { 0.26918091, 0.14566759, 0.2147652, 0.15769391 }, { 0.22500921, 0.12113361, 0.11151768, 0.12348609 }, { 0.25699055, 0.056819107, 0.3859882, 0.4585378 }, { 0.7304995, 0.20719358, 0.44455636, 0.42226989 }, { 0.43602897, 0.51049581, 0.41978824, 0.62521039 }, { 0.42004119, 0.52912054, 0.33314238, 0.38257921 }, { 0.55092562, 0.43085653, 0.31149977, 0.34391138 }, { 0.40391149, 0.48820255, 0.13569806, 0.36060266 }, { 0.13647907, 0.12061002, 0.20668806, 0.30221394 }, { 0.15583476, 0.13133696, 0.22775202, 0.35653823 }, { 0.56336195, 0.25684627, 0.11118383, 0.23109245 }, { 0.45430401, 0.42843367, 0.25496534, 0.097473509 }, { 0.3420223, 0.39418925, 0.26458947, 0.30588082 }, { 0.51345558, 0.3612731, 0.41151773, 0.25269512 }, { 0.29195176, 0.42659964, 0.47971993, 0.32714756 }, { 0.49222777, 0.28477645, 0.74993827, 0.43781271 }, { 0.098434481, 0.31164923, 0.14486345, 0.11466693 }, { 0.070833248, 0.20569754, 0.10233576, 0.047352701 }, { 0.51050902, 0.15597643, 0.1417112, 0.35581415 }, { 0.48261165, 0.14592221, 0.62554576, 0.5209765 }, { 0.33562628, 0.39920067, 0.28183433, 0.297464 }, { 0.366851, 0.59278666, 0.59095922, 0.48385165 } }, { { 0.13792051, 0.072076744, 0.094800532, 0.026318377 }, { 0.13607414, -0.061382542, 0.061800151, -0.020060553 }, { 0.028096406, 0.069282616, 0.010195109, -0.010461141 }, { 0.018651237, 0.02642439, 0.0077552848, -0.051151646 }, { 0.098299803, -0.0085081153, -0.011764584, 0.087405711 }, { 0.064082346, -0.04626424, -0.071480607, 0.064447268 }, { 0.022766233, 0.0167542, -0.021285286, -0.071637286 }, { -0.0202445, 0.011692601, 0.048325551, 0.0097755172 }, { -0.027775183, 0.016463115, 0.060050391, -0.034226107 }, { 0.019412547, 0.059977501, -0.0041737169, 0.031539317 }, { 0.013192979, 0.036015595, -0.049943198, 0.014112312 }, { -0.013272349, 0.035821037, -0.060503687, 0.095316821 }, { 0.038338785, -0.059038809, -0.044954172, -0.00051347307 }, { -0.039594082, 0.018205882, 0.13413799, 0.012292954 }, { 0.015177594, -0.0082493854, 0.00029420179, 0.010356248 }, { 0.100271, -0.13623174, 0.1121235, 0.068902399 }, { 0.025189636, 0.0014918434, 0.0088847718, -0.053714493 }, { 0.06487698, -0.097217547, -0.069537353, 0.032490984 }, { -0.030729608, 0.048956315, 0.016036034, 0.022485239 }, { 0.049839618, 0.01148525, -0.021032427, -0.019665817 }, { -0.0037762817, -0.030422275, -0.062343207, 0.057994884 }, { 0.014035184, -0.021387762, -0.080846143, -0.020681511 }, { -0.03594567, 0.026862531, 0.078975557, -0.034056659 }, { -0.014490672, 0.026128902, 0.045617611, 0.090192953 } }, { { 0.011904288, -0.014624471, 0.042023114, 0.019592867 }, { 0.032705848, 0.00038558691, 0.031901745, 0.027208951 }, { -0.044369719, -0.039761364, -0.013366816, -0.019308126 }, { -0.019051023, -0.00015767269, -0.082968285, -0.035266053 }, { -0.004775162, 0.010889271, 0.0089521094, 0.027037104 }, { 0.005616143, -0.00099668486, 0.0068716426, -0.12649184 }, { 0.018531199, 0.023881776, -0.053798787, -0.041912909 }, { -0.0036187094, 0.11590788, 0.025140733, 0.022280209 }, { -0.02994342, -0.026293799, -0.017204658, 0.044901944 }, { 0.079892089, 0.10816526, 0.14667807, 0.027301352 }, { -0.045296738, -0.066748968, -0.0099354431, -0.070369692 }, { -0.08357374, -0.043311901, 0.013163375, -0.0881777 }, { -0.065923811, -0.10382274, 0.090440302, -0.013617198 }, { -0.092578587, -0.010178017, -0.01416593, 0.0432333 }, { 0.055172515, 0.10021805, -0.0062782668, -0.11791805 }, { -0.039684132, -0.08934283, 0.020686084, -0.0013788117 }, { 0.064624676, 0.051773746, 0.0045383964, -0.037696971 }, { -0.066296373, 0.020570689, -0.017742721, -0.022651449 }, { -0.0061572447, -0.094510525, -0.094775804, -0.038022514 }, { 0.0055683313, 0.039513342, -0.096815654, -0.0065483011 }, { -0.03311602, -0.018395457, 0.0028464434, -0.088048272 }, { -0.073106109, -0.055187863, -0.093209932, -0.10155137 }, { 0.042841842, -0.005778703, 0.074069607, -0.025841052 }, { -0.018569637, 0.063144303, 0.02291584, 0.005525742 } } } }, { { { { -0.20809663, -0.18346453, -0.072140694, -0.0078104407 }, { -0.19490097, 0.25712922, 0.37640771, 0.11563399 }, { 0.26894915, -0.33477877, -0.093739129, -0.55078405 }, { -0.65794103, 0.09211629, -0.19166986, 0.5574327 }, { 0.45579532, 0.23202083, 0.19626303, -0.64130523 }, { -0.018763975, -0.24981569, -0.32514026, -0.11121342 }, { 0.22376238, 0.09515938, 0.071728264, -0.02790747 }, { -0.3053338, 0.34023365, 0.099862481, 0.26163964 }, { -0.21722968, -0.094881958, -0.086364431, -0.0081863581 }, { -0.16090709, 0.23527698, 0.28947119, 0.11309742 }, { 0.26447184, -0.33536416, -0.096418234, -0.26201294 }, { -0.56343769, -0.041662822, -0.24873841, 0.67122901 }, { 0.35362642, 0.2577592, 0.2009013, -0.74233681 }, { -0.047956299, -0.54973418, -0.4958485, -0.12453303 }, { 0.06917425, 0.080509853, 0.0090863722, -0.023518805 }, { -0.27000602, 0.083167162, 0.12715558, 0.12397839 }, { -0.11376964, -0.079199259, 0.019676685, -0.0094352472 }, { -0.19185851, 0.22193112, 0.28110877, -0.06422845 }, { 0.084091992, -0.16151548, 0.091400556, -0.28257376 }, { -0.53821376, 0.21718328, -0.2234907, 0.52302804 }, { 0.71322306, 0.042728493, 0.13229522, -0.61892094 }, { 0.15270046, -0.26304886, -0.33110633, -0.052728951 }, { 0.072398971, 0.25829764, 0.25881687, -0.020942042 }, { -0.26788161, 0.055822039, 0.33817103, 0.42061402 } }, { { 0.088248648, 0.091306255, 0.020476927, 0.0030144802 }, { 0.0087376707, 0.043816157, 0.0022807168, 0.016745414 }, { -0.13412414, 0.12686539, 0.060531476, 0.044582027 }, { 0.019204757, -0.0070891897, 0.091194602, 0.065258927 }, { -0.10429513, -0.027665602, -0.064350626, 0.0053147478 }, { 0.069218141, -0.035018324, -0.088257571, 0.019279642 }, { -0.073137338, 0.040764456, -0.022352804, 0.031743288 }, { 0.040325697, -0.12840825, -0.009582113, 0.034509657 }, { 0.081971224, -0.0035223125, -0.051728499, 0.0038899717 }, { 0.050968435, 0.022254651, 0.18781134, -0.032392139 }, { 0.024342518, 0.13929014, -0.019175435, -0.0011608234 }, { -0.0021942487, -0.01251222, 0.024263454, -0.063179344 }, { -0.13071776, -0.059221747, -0.034153238, 0.036561209 }, { 0.054124093, 0.070495803, 0.081441614, 0.051900357 }, { 0.027480327, 0.028940343, -0.01469313, 0.032388411 }, { -0.039696828, -0.0069393798, -0.011361641, 0.035031025 }, { -0.039730763, 0.0085971581, -0.0077461932, -0.040735188 }, { 0.10893368, 0.00014757217, 0.025489178, -0.11388774 }, { -0.0013816669, 0.0031148929, 0.10281666, -0.019860642 }, { -0.065093128, -0.11495815, 0.041783056, -0.091373461 }, { -0.044985581, 0.0012713031, -0.16078032, 0.17303747 }, { -0.038132358, -0.02995975, -0.037612782, 0.012575173 }, { 0.0042976619, 0.027014275, 0.017518808, 0.030405184 }, { -0.0015298607, 0.029297664, -0.1034349, 0.023450502 } }, { { 0.028785558, -0.028708377, -0.010459636, 2.8360915e-05 }, { 0.091634877, 0.021214811, 0.12282079, 0.080617943 }, { -0.29287977, 0.045481846, 0.014712563, 0.057317576 }, { -0.10728772, 0.03268482, 0.015167285, -0.011256231 }, { 0.09337321, 0.037150859, 0.052549202, -0.042671474 }, { -0.0041288689, -0.024299997, -0.11357403, -0.022045772 }, { -0.041469935, -0.0071353646, -0.0086607538, 0.008536762 }, { 0.033629272, -0.0070042955, -0.037864853, -0.0055907778 }, { 0.016404597, -0.0055321059, -0.020989839, -0.013771265 }, { 0.042552435, 0.04428518, 0.0030587466, 0.044894182 }, { -0.027600219, 0.026831779, 0.051120849, -0.032184808 }, { 0.13870554, 0.15273282, 0.049260112, 0.043371121 }, { -0.018453269, -0.18061413, 0.24805649, -0.031741165 }, { -0.085137374, 0.025935867, 0.015978067, 0.067726486 }, { 0.072393868, 0.0050430488, 0.0016664585, 0.0072097064 }, { 0.033840162, 0.082225764, -0.079387016, 0.033165625 }, { 0.033170766, 0.0012231618, -0.066984982, 0.051671704 }, { 0.017894231, -0.012267532, 0.045536123, -0.07327109 }, { 0.0073109731, -0.063797898, -0.13446413, 0.1408986 }, { -0.045702456, -0.1647051, -0.14336468, 0.054543693 }, { 0.0042448876, -0.13234456, 0.092181719, -0.10440841 }, { -0.060020212, -0.011098469, -0.030257182, -0.030922037 }, { -0.018118661, 0.00067983745, -0.0061776598, -0.031721273 }, { -0.019885189, 0.094157888, 0.014017961, -0.051373389 } } }, { { { 0.12415319, -0.13611564, -0.029441661, -0.14143497 }, { -0.26074418, 0.011913326, -0.033328425, 0.43248793 }, { 0.19336432, 0.37269586, 0.36803538, -0.51720719 }, { -0.15185913, -0.47431781, -0.6593667, 0.23163184 }, { 0.18276216, 0.19248743, 0.65453332, 0.54748087 }, { 0.17751443, -0.0020337696, 0.08506463, -0.40147769 }, { -0.11370932, 0.11523476, -0.010573025, 0.082295392 }, { -0.13666335, -0.32747478, -0.16897386, 0.15359006 }, { 0.11716326, -0.12259922, 0.0033396256, -0.13240653 }, { -0.27776876, -0.10222241, -0.039920479, 0.35499708 }, { 0.090003723, 0.3313923, 0.1871549, 0.003163675 }, { -0.51626118, -0.76341562, -0.56326874, 0.20153559 }, { -0.34172723, 0.26975563, 0.67520079, -0.1252004 }, { 0.45758078, -0.19142179, 0.064180031, -0.48748431 }, { -0.12800789, 0.1399912, 0.0077954775, 0.14379741 }, { -0.13042104, -0.45670817, -0.18831095, 0.0032738639 }, { 0.12446807, -0.11504524, -0.027331682, 0.03861758 }, { -0.31337986, -0.11842668, 0.033415325, 0.45344231 }, { 0.11463107, 0.077427841, 0.060880794, -0.069619455 }, { -0.37772106, -0.59628905, -0.65426572, 0.065297039 }, { 0.29532991, 0.75920243, 0.53294265, -0.15002562 }, { 0.3618333, 0.10488387, 0.36007528, -0.30963565 }, { -0.13738196, 0.20795596, 0.029274703, 0.18017599 }, { -0.10290023, -0.48517535, -0.33278584, 0.56477854 } }, { { -0.0047891472, 0.024629901, 0.015256654, -0.0084462001 }, { 0.056227746, -0.048057782, -0.15671312, 0.06418471 }, { -0.070093217, -0.018057199, 0.062026545, -0.051053726 }, { -0.0091221476, 0.0020547295, -0.087729813, -0.10164738 }, { 0.098917091, -0.066835916, 0.083151519, 0.006342544 }, { 0.0013540606, 0.038719082, 0.036333261, -0.053178668 }, { 0.0083787438, 0.0028359378, 0.0089872852, 0.031308249 }, { 0.014379686, -0.079563474, -0.079160006, -0.016352226 }, { 0.0091376645, -0.016678006, -0.044636785, -0.0011035265 }, { 0.0099146109, 0.027589302, -0.09494437, 0.07451767 }, { 0.017453983, 0.080674871, 0.06341808, 0.048820473 }, { 0.02794057, 0.058230195, -0.010793601, 0.091813872 }, { -0.049633232, -0.1142016, 0.036984283, 0.0034294865 }, { 0.047712957, 0.10161366, 0.13774722, 0.039503136 }, { 0.014194782, -0.014555183, -0.00053182909, 0.0019143477 }, { 0.0014900262, 0.0056176356, -0.034517871, -0.0010707988 }, { 0.013287784, -0.0073967933, -0.019271341, 0.016354896 }, { -0.10345626, 0.023536634, 0.027943639, -0.015686972 }, { -0.025193395, -0.10224801, 0.078686884, -0.048574399 }, { 0.15797878, -0.0012322757, -0.036096649, -0.23983963 }, { -0.10455507, -0.056368102, -0.06570944, 0.29104616 }, { 0.05155239, -0.040940824, -0.038367594, 0.058174485 }, { 0.010471732, -0.066952904, -0.047763843, -0.021124742 }, { -0.033555686, 0.0049111983, -0.026592789, 0.014438586 } }, { { -0.0048440946, 0.025915095, -0.018325403, 0.022133613 }, { 0.059240081, -0.031272176, -0.12967647, -0.17957913 }, { 0.0574837, 0.067005152, 0.024644254, 0.10786296 }, { 0.067084865, 0.008513386, 0.04077659, 0.10587924 }, { 0.026332643, 0.1072618, -0.098375042, -0.001724609 }, { -0.021386362, -0.0020174921, 0.16800158, 0.081359882 }, { -0.018204146, -0.026432136, -0.0068153455, -0.029997667 }, { -0.043221501, -0.016869967, -0.067406967, -0.024965804 }, { -0.0033879999, 0.031310818, -0.010853802, 0.00088944004 }, { -0.068991006, 0.087874253, -0.15737392, -0.088870044 }, { 0.061763806, -0.00072874343, -0.009915009, -0.0178225 }, { -0.07340717, 0.080339271, -0.0027124572, -0.13078641 }, { -0.023682834, 0.16512313, -0.15784472, 0.047978827 }, { 0.0063250439, -0.09953777, 0.094180888, 0.010565041 }, { 0.010047311, -0.042999009, -0.012483998, -0.016966759 }, { -0.048612679, 0.051708319, 0.015059148, 0.0036776472 }, { -0.011737015, -0.0027276603, 0.026535075, -0.065453876 }, { 0.056388137, 0.061461073, -0.12726984, -0.025578248 }, { 0.0016833003, 0.10878558, 0.13254828, -0.017098914 }, { -0.031606282, -0.072245098, 0.12724789, -0.21852899 }, { -0.062502612, -0.073402771, -0.049624729, 0.069066032 }, { -0.075837195, -0.10297347, -0.07249237, -0.11538062 }, { -0.015644005, 0.039474396, 0.074415075, -0.038881161 }, { -0.040175911, 0.034030267, 0.03947059, 0.014167463 } } }, { { { 0.97019677, 0.97355703, 0.99695983, 0.98991674 }, { 0.94552952, 0.96630359, 0.92585444, 0.89419404 }, { 0.9435447, 0.86545998, 0.92507456, 0.65508294 }, { 0.73759908, 0.87552111, 0.72697883, 0.79725496 }, { 0.87111918, 0.95347518, 0.73011435, 0.53758004 }, { 0.9839393, 0.96829127, 0.94183216, 0.90909143 }, { 0.96798791, 0.98876976, 0.99736817, 0.99621717 }, { 0.9423876, 0.88147679, 0.98054848, 0.95286662 }, { 0.96906348, 0.98791034, 0.99625801, 0.99116169 }, { 0.94707625, 0.9665378, 0.9563539, 0.9280011 }, { 0.96018435, 0.88187869, 0.97758711, 0.96505917 }, { 0.64499021, 0.64456248, 0.78794513, 0.71332673 }, { 0.87073007, 0.92778882, 0.70974824, 0.65822558 }, { 0.88787388, 0.81311133, 0.86603417, 0.86420517 }, { 0.98935782, 0.98687417, 0.99992833, 0.98932764 }, { 0.95398485, 0.88572054, 0.97384313, 0.99227952 }, { 0.98567955, 0.99019799, 0.99943274, 0.99920952 }, { 0.93004482, 0.96784384, 0.95909399, 0.88896838 }, { 0.98984254, 0.98382807, 0.99395144, 0.95671584 }, { 0.75342733, 0.77283296, 0.72248756, 0.84981055 }, { 0.63568318, 0.6494505, 0.83574524, 0.77099234 }, { 0.91965169, 0.95906448, 0.87218942, 0.94939213 }, { 0.98786871, 0.94341754, 0.96548269, 0.98341143 }, { 0.95794101, 0.87263324, 0.8802806, 0.71000638 } }, { { -0.0064390277, 0.051629953, -0.011423447, 0.032337826 }, { 0.055030538, 0.061305324, -0.016012659, 0.083766345 }, { 0.052467122, 0.018425134, -0.00054737782, 0.048038459 }, { 0.076436505, 0.016815709, -0.024174832, -0.00829119 }, { 0.057903371, 0.068822104, -0.0064003131, 0.00010695928 }, { 0.067104151, 0.067284611, 0.0074295447, 0.024215238 }, { 0.073380541, 0.01486405, 0.01523157, 0.012966612 }, { -0.0002536971, 0.010628632, 0.00045031869, 0.041891438 }, { 0.055922922, 0.0090823157, 0.011101162, 0.033807592 }, { -0.040264953, 0.022318628, -0.013682045, -0.016112502 }, { -0.034286564, 4.7089727e-05, -0.013030079, -0.012231424 }, { 0.027756308, 0.084041595, 0.018308393, 0.11564334 }, { 0.0026690817, 0.058149333, -0.013682964, 0.052975934 }, { -0.03852481, 0.063493354, 0.059460027, 0.047740976 }, { 0.026410264, -0.0073902435, 0.022353771, 0.012987341 }, { 0.035217135, -0.0023455309, -0.0055505614, 0.010102857 }, { 0.00075590283, 0.038624793, -0.0040614962, 0.070039437 }, { -0.02318411, 0.04527054, 0.013119286, 0.025335215 }, { 0.021268391, 0.044855911, 0.012622905, 0.04827088 }, { -0.0046678346, -0.01934799, 0.018393432, 0.09750434 }, { 0.12480373, 0.059151139, 0.055196092, 0.26701338 }, { -0.0096669036, 0.065624767, 0.016918517, 0.028425135 }, { 0.026488514, -0.0037618693, 0.0077028717, 0.041713399 }, { 0.018628451, 0.033145064, 0.029067918, -0.000924258 } }, { { -0.043525781, 0.028119778, -0.011653105, -0.020930158 }, { -0.028099186, 0.017594088, -0.099226445, 0.10408808 }, { 0.11750066, -0.0010629746, 0.018381448, 0.096538552 }, { 0.0010069446, 0.013799541, 0.1325137, 0.020820734 }, { -0.053571928, -0.0066793785, 0.14596488, -0.03272949 }, { 0.028507895, 0.015474376, -0.025411653, 0.037264272 }, { 0.033698911, 0.018088387, 0.0038898537, 0.03163178 }, { 0.0057766828, 0.015879322, 0.012557033, 0.071771631 }, { -0.0044521866, 0.0083963511, -0.0020426175, 0.023784146 }, { -0.011508765, 0.0075020051, 0.0018808294, 0.040843424 }, { 0.0085150894, 0.0056891711, 0.010134672, 0.046224768 }, { 0.040825446, 0.10099754, 0.021853299, 0.024507528 }, { -0.0055958303, -0.0060958, 0.1115321, -0.021701014 }, { 0.010487817, -0.010033143, -0.031203025, 0.054265436 }, { 0.0040500672, 0.0053935875, 0.018233022, 0.018797311 }, { 0.064057639, 0.014318185, 0.0199119, 0.014366235 }, { 0.02411682, 0.045454692, 0.0030084434, 0.019464939 }, { 0.012500289, 0.027734846, 0.0025097372, 0.047343669 }, { 0.037625829, -0.00064472688, 0.0557556, 0.04785655 }, { 0.0020433437, 0.019929208, 0.087936103, -0.036738471 }, { 0.020811556, 0.0915387, 0.055445303, -0.065132763 }, { 0.03911814, 0.043721622, 0.0074336204, -0.031370424 }, { 0.014072509, -0.014795458, 0.010517063, 0.022409628 }, { -0.0054107234, 0.055313602, 0.053556404, 0.048574319 } } }, { { { 3.4224197, 3.3162336, 3.1136621, 3.3189801 }, { 4.0715355, 3.5614196, 4.1797877, 4.0959601 }, { 4.3979407, 4.1858272, 4.3116447, 4.5467451 }, { 4.4920032, 4.0716439, 4.6107962, 4.5268016 }, { 5.6570832, 4.9036495, 4.7373547, 4.7259419 }, { 3.3277827, 3.6015237, 4.226646, 3.7939772 }, { 3.4893058, 3.3260638, 3.0626103, 3.1798705 }, { 3.6423735, 4.1092281, 3.3264203, 3.7325301 }, { 3.4756581, 3.2550256, 3.224671, 3.4093307 }, { 3.8511362, 3.4821381, 4.3232597, 3.7357164 }, { 3.6688024, 4.0797971, 3.4140927, 3.6881261 }, { 4.5298469, 4.7472506, 4.4046473, 4.7279944 }, { 4.1614448, 4.1242955, 4.6741969, 5.0037875 }, { 4.3148703, 4.3815566, 4.1976536, 3.9032858 }, { 3.2640506, 3.3214728, 2.9463564, 3.3562068 }, { 3.6729325, 3.9218642, 3.4550701, 3.4833871 }, { 3.435975, 3.3079446, 3.3432341, 3.3632985 }, { 3.8404619, 3.4716915, 3.858149, 3.8677391 }, { 3.3181827, 3.8403872, 4.0363918, 3.9604287 }, { 5.0916792, 5.2773748, 4.5404255, 4.377031 }, { 4.6514614, 4.7569957, 4.1233238, 4.4022582 }, { 3.6884833, 3.6283543, 4.1874612, 4.2963913 }, { 3.456705, 3.6250566, 3.5292789, 3.1420033 }, { 3.5986317, 4.0596074, 4.0696874, 4.5327067 } }, { { -0.12592901, -0.14780788, -0.11051274, -0.18767653 }, { -0.020435093, 0.0055221209, -0.021183195, -0.15159792 }, { 0.022498629, -0.025100789, -0.30939177, 0.016420202 }, { 0.21296442, -0.042976575, 0.082118132, 0.14574735 }, { -0.13608022, 0.16141834, -0.015091164, 0.044951541 }, { -0.08235774, -0.10333151, 0.089785432, -0.036620639 }, { -0.17664465, -0.015842477, -0.083075331, -0.15660828 }, { -0.11292423, -0.072894494, -0.068901923, -0.2283674 }, { -0.19063437, -0.071954393, 0.091375283, -0.26993547 }, { 0.042798331, -0.06495575, 0.050221766, 0.024602586 }, { -0.026228614, 0.0049810367, 0.046584088, -0.13067577 }, { 0.072779737, -0.023369437, -0.030275791, 0.19591126 }, { -0.018649072, 0.029208952, 0.012033439, 0.00094798196 }, { -0.094599446, 0.0070746366, -0.0007115864, -0.040175552 }, { -0.027599009, -0.068747365, 0.19480498, -0.19423733 }, { -0.076671551, 0.0075475135, 0.019853903, -0.012984601 }, { 0.064371855, -0.24044027, -0.043765356, 0.0016424127 }, { -0.076744435, 0.035881398, 0.12967612, 0.081825243 }, { -0.15224256, 0.032665115, -0.027927205, 0.076091133 }, { -0.0057973613, -0.14914213, -0.047678749, -0.037214457 }, { 0.10060085, -0.099197666, -0.22704457, -0.0020812401 }, { -0.070664558, -0.13179176, -0.014217065, -0.030410253 }, { -0.12286487, -0.046623366, -0.10695394, -0.0081383175 }, { -0.14561788, 0.02765909, 0.10439783, 0.033139041 } }, { { 0.0063171031, -0.0047223477, -0.056312039, -0.065065766 }, { -0.0059575982, -0.062348475, 0.069540315, -0.090331962 }, { 0.10218203, 0.050383376, -0.0089914697, -0.037837343 }, { -0.0037657879, 0.18278082, 0.079014627, -0.052587294 }, { -0.33929282, 0.018522098, 0.0078923893, 0.042545349 }, { 0.027294929, -0.086490439, -0.0057363347, -0.035932082 }, { -0.061716003, -0.14470599, 0.033117786, -0.08112808 }, { 0.16414856, 0.082471596, -0.058497326, 0.050552718 }, { -0.07627083, -0.0064181717, -0.031179581, -0.075705068 }, { -0.057808009, -0.00074561624, -0.23990956, 0.018671772 }, { 0.1677602, 0.10757253, 0.028015134, -0.23923178 }, { 0.078827365, 0.068682485, 0.056277532, -0.069749241 }, { 0.079502977, 0.05526585, 0.0089767144, -0.15319341 }, { -0.038594242, -0.055488998, -0.043132461, 0.054313031 }, { 0.12890592, -0.082639555, 0.22520491, -0.026781096 }, { -0.071292391, 0.064592881, -0.050368563, -0.072488866 }, { 0.092998671, 0.12152394, 0.033318795, -0.039691417 }, { -0.0049706273, -0.0014175115, -0.11634604, 0.15219284 }, { -0.012414906, 0.035583927, -0.072463074, -0.058394705 }, { -0.071558898, -0.00093653835, 0.013149622, 0.01495775 }, { -0.057103279, 0.013702583, -0.020242751, 0.04649072 }, { -0.083398977, -0.20123674, 0.062758815, -0.043671819 }, { 0.084479675, 0.17868517, -0.021185269, 0.15711776 }, { 0.11862504, 0.079985297, 0.063556911, 0.14639069 } } }, { { { 0.48018566, 0.17712962, 0.45065949, 0.76214707 }, { 0.37788335, 0.385421, 0.24766167, 0.3647243 }, { 0.45095873, 0.2634498, 0.37824131, 0.10713483 }, { 0.18808611, 0.27852978, 0.23671202, 0.23174978 }, { 0.39404781, -0.7399413, 0.28511918, 0.026007027 }, { 0.46587668, 0.46802177, 0.36697974, 0.23706778 }, { 0.48925391, 0.42086488, 0.49570155, 0.45137287 }, { 0.30655255, 0.35196398, 0.23019387, 0.50586011 }, { 0.45798975, 0.34137244, 0.33289763, 0.54218519 }, { 0.42271216, 0.38700914, 0.48791862, 0.15025833 }, { 0.7282781, 0.37956244, 0.25156645, 0.51632504 }, { 0.084933462, 0.15576738, 0.16469359, 0.29684651 }, { 0.34570877, 0.34912791, 0.26663435, 0.11188061 }, { 0.48552914, 0.19012867, 0.12677402, 0.1234341 }, { 0.2190939, 0.41431469, 0.64823269, 0.51846746 }, { 0.49289149, 0.29829354, 0.29090992, 0.36465152 }, { 0.50568056, 0.64150077, 0.40217634, 0.53523743 }, { 0.24945735, 0.47058801, 0.29099852, 0.25452114 }, { 0.49039753, 0.26327736, 0.39431507, 0.50632023 }, { 0.19678915, 0.031547614, 0.22295107, 0.26300048 }, { 0.12409997, 0.11506147, 0.19327618, 0.2174585 }, { 0.15319333, 0.39177705, 0.38498586, 0.25972804 }, { 0.69027161, 0.37279682, 0.31143504, 0.23440833 }, { 0.39682066, 0.3156927, 0.36369313, 0.14308402 } }, { { 0.15030994, 0.15410005, 0.0072554408, -0.22242826 }, { -0.032421729, 0.22531436, 0.22185899, -0.022703209 }, { 0.070341052, 0.30237173, 0.047916387, 0.03629681 }, { -0.024283222, 0.075614195, 0.013940033, -0.016841468 }, { 0.077729482, 0.19455394, -0.02162282, -0.018761003 }, { -0.22986895, 0.18914992, 0.14483608, 0.11173921 }, { 0.14132894, -0.0081864768, -0.11405791, 0.031777789 }, { 0.38775389, 0.0085565642, -0.057167843, 0.09784167 }, { 0.079102739, 0.030530894, 0.041954967, 0.02957611 }, { 0.076915126, 0.18656729, 0.044218872, 0.22478833 }, { 0.017173879, 0.11961351, -0.085099523, 0.22720323 }, { 0.030466202, 0.095221887, -0.042982583, -0.069264747 }, { 0.041170442, -0.090598444, -0.021082598, -0.028016784 }, { -0.082581617, -0.023712106, 0.32427665, 0.1010696 }, { 0.19197752, 0.10900527, -0.0053794951, 0.068553764 }, { 0.18674269, 0.028895321, -0.053421028, 0.063918058 }, { 0.044090722, -0.054247791, 0.05585954, -0.13406746 }, { 0.08358642, -0.032301886, 0.010371619, 0.099505528 }, { 0.16467816, 0.044994571, -0.0045949279, 0.0626774 }, { 0.12942209, 0.092097891, 0.019866495, 0.10340014 }, { 0.037094903, 0.13829877, 0.15116473, -0.048632499 }, { 0.10749044, 0.14329542, -0.061272024, -0.1536028 }, { 0.097716907, 0.044246181, 0.056664419, 0.15804873 }, { 0.031819999, 0.10132976, 0.079198524, 0.017871462 } }, { { 0.056219172, 0.08683492, -0.061488015, 0.065746152 }, { 0.088983664, 0.19773741, -0.096766599, 0.16352101 }, { -0.0097043787, -0.040925999, 0.097458334, 0.032319634 }, { -0.024873518, 0.057873123, -0.0059256291, -0.057498398 }, { -0.13355098, 0.39190863, 0.017449142, -0.0076009344 }, { 0.10319658, 0.22069551, -0.098795717, 0.10603434 }, { 0.090765308, 0.13803326, -0.070647945, 0.14557561 }, { -0.068457348, 0.058955208, -0.050501105, 0.02914144 }, { 0.10363866, 0.060231993, 0.027681685, 0.079659088 }, { 0.01269983, 0.11977996, -0.049648315, 0.089882363 }, { -0.072877286, 0.019348792, 0.13977764, 0.055396044 }, { 0.028834456, -0.1084196, -0.0043985215, -0.072640844 }, { -0.040232522, 0.051835989, -0.02198193, 0.016421295 }, { -0.087848469, -0.04621504, 0.099259188, -0.0025909067 }, { 0.3000131, 0.10526775, 0.016890366, 0.12892588 }, { -0.021028821, -0.024429075, 0.088067677, -0.084594075 }, { 0.086861805, -0.045902006, 0.0058222123, -0.0075466204 }, { 0.14411905, 0.036488937, 0.05091815, 0.16385101 }, { 0.1576814, 0.043890956, -0.064244298, -0.087234754 }, { -0.071100004, 0.16782304, -0.10860149, -0.1601076 }, { 0.032634641, -0.0025068263, -0.093802703, -0.076176546 }, { 0.1121451, 0.15584236, 0.070074778, 0.083736091 }, { 0.16981897, -0.078106227, 0.12480295, -0.0056807652 }, { -0.20300117, -0.017467249, 0.035504155, 0.056546123 } } } }, { { { { 0.014994926, 0.3118252, 0.12179235, -0.2013765 }, { -0.2622824, 0.28086607, 0.018805882, 0.72058929 }, { -0.0081002049, -0.28176506, -0.592214, -0.15032918 }, { 0.18913426, -0.24000825, 0.0020279072, -0.54749128 }, { 0.010237954, 0.76905205, 0.80173664, -0.016024595 }, { -0.53448318, 0.31204229, -0.16183732, 0.76857439 }, { -0.57639279, -0.63719194, -0.71354849, 0.56346054 }, { 0.49443258, 0.15067585, 0.31864726, -0.30570933 }, { -0.20756322, 0.2544828, -0.005298245, 0.0073796841 }, { -0.61822672, 0.21508574, 0.6362534, 0.30433278 }, { -0.0050327191, -0.278054, -0.3460806, 0.29967778 }, { 0.33983098, -0.11715664, -0.21761592, -0.068273894 }, { 0.5550354, 0.44369709, 0.64019993, -0.026032291 }, { -0.72587268, -0.33528197, -0.33592445, 0.53027141 }, { -0.47623191, -0.61767624, -0.61525655, 0.37823554 }, { 0.82869964, 0.219401, -0.018181789, -0.56937955 }, { -0.051792934, 0.3461701, 0.20915925, 0.078166496 }, { -0.26705611, 0.14439061, 0.0055054648, 0.463243 }, { -0.0019649711, -0.34119962, -0.29306531, -0.040223173 }, { 0.29285811, -0.32824753, -0.24768208, -0.29676955 }, { 0.87604898, 0.25374435, 0.2341931, -0.77851996 }, { -0.80404697, 0.011122158, 0.18899178, 0.55592668 }, { -0.78397618, -0.53690406, -0.59931185, 0.62348293 }, { 0.54613799, 0.080819658, 0.12590931, -0.60614071 } }, { { -0.12307869, -0.20242175, 0.21530167, -0.15608553 }, { 0.00052208688, 0.09998365, -0.067550225, -0.14009319 }, { 0.12621699, -0.089024022, 0.022656689, 0.18947331 }, { 0.34838897, -0.04936051, 0.25527451, -0.18942819 }, { 0.013210249, -0.043957685, -0.19088103, -0.034189573 }, { -0.0027790938, -0.026595097, 0.087083287, -0.12513839 }, { -0.038231564, 0.013328425, -0.0091503894, -0.005743873 }, { 0.17205702, -0.14956835, -0.0088915291, 0.18720588 }, { -0.049670195, 0.39532325, 0.080260299, 0.01811245 }, { 0.043555003, -0.30289197, -0.50878196, 0.27306166 }, { 0.02555972, -0.0068359476, 0.061097702, -0.43822038 }, { -0.10926471, 0.1870906, 0.12419548, 0.1245213 }, { -0.012443149, 0.040036941, 0.18601483, 0.02310445 }, { -0.10442982, 0.057455632, 0.13475314, -0.0019859122 }, { -0.068181593, -0.0033655904, 0.01922998, -0.020393828 }, { -0.10660626, 0.0020812455, 0.081209707, 0.077131932 }, { 0.088733212, -0.10430986, 0.45554817, -0.17113078 }, { 0.0046831409, 0.13247549, -0.1077727, 0.15382275 }, { 0.022346595, 0.022924261, -0.35016323, 0.2437608 }, { 0.029795657, 0.23046877, -0.020493651, -0.33214749 }, { -0.016101582, 0.042296203, 0.046779444, 0.037412394 }, { -0.02214903, -0.025218605, 0.14797485, -0.051723623 }, { 0.021321783, 0.010405115, 0.0075476201, 0.0082410917 }, { 0.040559796, 0.027927916, -0.012812736, -0.0096642379 } }, { { -0.055647079, 0.017595207, 0.34495838, -0.03055759 }, { -0.058415094, 0.027416036, 0.18568916, 0.13044498 }, { 0.01482217, -0.17300703, 0.027540135, -0.2744944 }, { 0.25558424, -0.15324455, -0.29751197, -0.11422984 }, { -0.068936732, -0.11425403, 0.094767025, -0.0020892558 }, { 0.040887892, 0.031622148, -0.095292456, -0.02460001 }, { -0.0026237665, 0.017734103, 0.01213911, 0.0056586962 }, { -0.052138375, 0.052245567, 0.04608449, -0.043004468 }, { -0.17693366, 0.0021023738, 0.13167397, -0.14062006 }, { -0.20900333, 0.0057695127, 0.13057243, 0.046715668 }, { -0.020569928, -0.08439655, -0.09683347, 0.038139385 }, { 0.18196242, 0.44461908, -0.11388512, -0.12413082 }, { 0.072801844, -0.0017236427, -0.0026756083, 0.049805114 }, { -0.092195952, -0.0076195172, -0.22763849, -0.11320887 }, { 0.016234922, 0.007258942, 0.078535592, -0.084829275 }, { -0.15320003, 0.057490618, -0.16065455, -0.17063675 }, { -0.012856124, 0.024818957, 0.097529739, 0.11569844 }, { -0.11141243, 0.26677735, 0.1319403, -0.15699502 }, { -0.021128161, -0.12370585, 0.056198856, -0.1836225 }, { -0.01871806, 0.025525037, 0.063822152, 0.066517944 }, { -0.013759301, 0.11401068, -0.04701374, -0.021321516 }, { 0.032714649, -3.161284e-06, 0.026930697, 0.00019593482 }, { 0.10575127, 0.016956425, 0.016873291, 0.0049304377 }, { -0.11938883, 0.31242334, 0.29347156, -0.19514533 } } }, { { { -0.17374661, -0.028781395, -0.25993234, 0.27242277 }, { -0.13675759, -0.62291002, -0.80742781, 0.54260546 }, { 0.16876581, -0.052588487, 0.22415557, -0.59669887 }, { 0.1769234, 0.64210979, 0.81157479, -0.2718564 }, { -0.99873125, -0.013258174, 0.58939675, 0.99930085 }, { -0.30883355, -0.71116337, -0.76218623, 0.096388818 }, { 0.65749012, -0.54533843, -0.57508599, -0.70359398 }, { -0.27406769, 0.61006308, 0.1873512, 0.2563151 }, { -0.78453523, -0.13585943, -0.048534939, 0.02085237 }, { 0.40938527, -0.76981396, -0.42506866, 0.22362984 }, { 0.29003079, -0.20624421, 0.1151133, -0.50558933 }, { 0.0070051806, 0.20763719, 0.59485798, -0.61562639 }, { -0.4371111, 0.48314196, 0.72981069, 0.99889301 }, { 0.58257878, -0.8603979, -0.94188892, -0.83140889 }, { 0.71858167, -0.49534538, -0.63421799, -0.84488463 }, { 0.016158248, 0.65330502, 0.82883727, -0.127372 }, { -0.50292264, -0.14848746, -0.20836533, 0.2471481 }, { -0.15815031, -0.63472031, -0.79826416, 0.15325573 }, { -0.010424343, -0.022843894, 0.099730136, -0.26040744 }, { 0.15069433, 0.31188588, 0.63836617, -0.25234477 }, { -0.36946506, 0.92093529, 0.96548808, 0.62354203 }, { -0.57070465, -0.99847512, -0.47855156, -0.079970605 }, { 0.077467525, -0.71134336, -0.67172579, -0.66364974 }, { -0.27299386, 0.89512951, 0.61598356, 0.49577277 } }, { { 0.070458859, -0.28774455, 0.21287043, -0.094689772 }, { 0.0029548085, -0.31404605, -0.039280892, -0.3652277 }, { -0.033729607, 0.041215792, 0.065844258, -0.21509418 }, { 0.39270582, 0.067526811, 0.15655351, 0.053346856 }, { 0.052704394, -0.087801294, 0.18655104, 0.056114808 }, { -0.074582751, -0.055177669, -0.22165519, 0.13272162 }, { -0.027850171, 0.0029849066, -0.0062314784, -0.010484316 }, { 0.20753796, -0.0087111988, -0.13875075, -0.06137521 }, { 0.089744421, 0.07271039, 0.099417029, -0.22157272 }, { -0.013209094, 0.048633419, -0.26528065, -0.15253703 }, { 0.052922007, 0.24859103, 0.14406684, 0.13857649 }, { 0.00096142813, 0.32643367, 0.17939549, -0.39761314 }, { 0.013505803, -0.036986517, -0.12729111, 0.15459921 }, { -0.00049722057, -0.047063275, -0.0018666598, 0.1067114 }, { -0.074221027, -0.00927958, -0.029535811, -0.024240068 }, { -0.12387933, 0.06626829, 0.16422781, 0.077740779 }, { 0.14560404, -0.082132455, 0.027268021, 0.18857832 }, { 0.10470732, -0.29519533, -0.23666419, 0.10917064 }, { 0.042550279, 0.02436036, -0.31865644, -0.024987356 }, { -0.030434576, 0.082115299, 0.17770796, 0.020944092 }, { -0.17365377, 0.13807361, 0.12476029, 0.072738061 }, { -0.11503962, -0.04022554, 0.028018434, -0.070211356 }, { -0.043677907, 0.0053361863, 0.0039019898, 0.0027489647 }, { 0.27060899, -0.0016552279, 0.14166067, -0.25461265 } }, { { 0.014703402, 0.094752279, -0.32162049, 0.082335322 }, { -0.31539882, 0.44394592, 0.44316202, -0.031456167 }, { -0.024148679, 0.082370612, -0.0031744796, 0.098610537 }, { 0.46130367, -0.19989896, -0.56118891, 0.11979937 }, { 0.11784636, 0.079971516, -0.16977121, 0.014922099 }, { 0.018367216, -0.076519762, 0.13801492, 0.039682415 }, { -0.0027614728, 0.0010389006, -0.023126227, 0.0027068473 }, { 0.22249856, -0.071302328, 0.23721977, 0.10734273 }, { 0.41478408, -0.36611101, 0.18031261, -0.11176768 }, { 0.15800457, 0.23829725, -0.0016193556, 0.2112867 }, { -0.14793833, -0.15378785, 0.0082778301, 0.27105519 }, { -0.064743588, 0.44794816, -0.12599819, 0.4310022 }, { 0.092725214, 0.033947737, 0.19969884, 0.0072363359 }, { -0.074190657, 0.005985921, 0.300818, -0.090919095 }, { 0.024238118, -0.010955859, -0.068086841, -0.021137349 }, { 0.12196721, -0.19977338, -0.64428422, -0.30808722 }, { 0.46567096, -0.042072501, -0.1778338, 0.34294059 }, { -0.32528695, 0.25699981, 0.49346557, -0.20743316 }, { 0.10422458, 0.049488574, 0.49098274, -0.34871439 }, { 0.16431875, -0.050748897, -0.18464312, -0.61695364 }, { -0.1753479, 0.033238479, -0.046267845, -0.012339883 }, { -0.16098841, 0.080519992, -0.11793031, 0.036790025 }, { 0.017193144, -0.0029212372, -0.0044153187, -0.0057094316 }, { 0.23481771, -0.1556448, -0.18775429, -0.013697353 } } }, { { { 0.98467622, 0.94970347, 0.95791534, 0.9408684 }, { 0.95525144, 0.73013516, 0.58966657, 0.43166004 }, { 0.98562289, 0.95804118, 0.77397471, 0.78825859 }, { 0.96588112, 0.72807352, 0.58424502, 0.79142113 }, { -0.049305848, 0.63904864, 0.099145551, -0.03377918 }, { 0.78673348, 0.62998117, 0.62680207, 0.63245759 }, { 0.48526085, 0.544603, 0.40015579, 0.43297544 }, { 0.82487776, 0.77789448, 0.92917353, 0.91697567 }, { 0.58431326, 0.95748667, 0.99880743, 0.99975533 }, { 0.67096902, 0.60093643, 0.64381538, 0.92594344 }, { 0.95700408, 0.93816272, 0.93111608, 0.80905665 }, { 0.94046044, 0.97116483, 0.77381347, 0.78507504 }, { 0.7077214, 0.7547892, 0.23983411, -0.039180128 }, { 0.3656649, 0.38379871, -0.00015338393, 0.16604667 }, { 0.50679735, 0.6108265, 0.46821675, 0.37829596 }, { 0.55946029, 0.72460731, 0.55919425, 0.81214734 }, { 0.86277825, 0.92634645, 0.95542467, 0.96581976 }, { 0.95061533, 0.75913205, 0.60228234, 0.87287949 }, { 0.99994373, 0.93971324, 0.95087677, 0.96466059 }, { 0.9442062, 0.89161694, 0.72879505, 0.92100486 }, { 0.30989313, 0.29579046, 0.11395771, 0.071428407 }, { 0.16674735, -0.054071458, 0.85747916, 0.82737551 }, { 0.61593841, 0.45356879, 0.43544204, 0.41332561 }, { 0.79196443, 0.43841915, 0.77763172, 0.62193473 } }, { { 0.028699614, 0.071974788, -0.028868668, 0.030119772 }, { -0.16988515, -0.35713152, 0.36877151, 0.37172103 }, { 0.024472009, 0.10373643, 0.052160621, -0.12998364 }, { 0.051999909, -0.1688679, 0.05813266, -0.11063347 }, { 0.026373007, 0.067310776, 0.34433164, 0.0017481699 }, { -0.017659611, -0.10215276, -0.23736187, 0.12678732 }, { -0.0019097928, 0.02067204, -0.030447136, -0.0093192388 }, { 0.10615435, 0.11124023, 0.04473958, 0.14369936 }, { 0.14791062, -0.034502091, 0.041456555, 0.06737059 }, { 0.22389399, 0.2668048, 0.25742349, 0.03724758 }, { 0.0046009946, 0.066632032, 0.097957775, 0.22969631 }, { 0.043253167, -0.013638494, 0.071328387, -0.19249903 }, { -0.023561087, 0.011490741, 0.19824644, -0.04133258 }, { -0.057507532, -0.039265903, 0.060469313, 0.37300659 }, { 0.027051207, -0.0086784396, -0.0055877341, -0.0315352 }, { 0.15724931, 0.0099485187, 0.22462997, 0.14112999 }, { 0.13909905, 0.026199511, -0.12430815, -0.076900423 }, { -0.022327596, -0.1975812, 0.49862652, -0.096026553 }, { 0.076782007, 0.041598482, 0.0033451155, 0.039947963 }, { 0.005353589, 0.070993946, 0.0068174778, -0.17805261 }, { -0.059912765, -0.17027417, -0.060069718, 0.1561139 }, { 0.017122435, 0.048532637, -0.05315926, 0.066962855 }, { 0.058014377, 0.021874362, 0.017248667, -0.0069413843 }, { 0.099274028, 0.040622241, 0.040435904, 0.14191123 } }, { { -0.13453832, 0.071519908, -0.1597656, -0.030758273 }, { -0.13511715, 0.32373425, 0.35851035, -0.18685481 }, { 0.021440457, 0.034442875, 0.14324368, 0.15754565 }, { -0.061440371, 0.16837735, 0.47887644, -0.036265812 }, { 0.55060811, 0.14095672, 0.13077418, 0.25515565 }, { -0.084599968, -0.084002143, 0.1542308, 0.044223437 }, { 0.0017727822, 0.025149715, -0.025479364, -0.0023658361 }, { 0.1619123, 0.069159159, -0.016343512, 0.026108175 }, { 0.3296525, 0.029456656, 0.039715069, 0.015958704 }, { -0.093419591, 0.37051381, -0.063182977, -0.017764112 }, { 0.11962535, 0.062511772, -0.070445145, 0.27768911 }, { 0.07458833, -0.16218828, 0.064111239, 0.43889373 }, { -0.0326486, -0.03666828, -0.17597139, 0.34213144 }, { 0.061334301, -0.0099525239, 0.21497301, 0.0074569296 }, { -0.016749445, 0.00054557189, 0.040331287, 0.066200794 }, { 0.20620866, 0.25268529, 0.46594276, 0.059651923 }, { 0.15170896, 0.041438057, 0.021708506, -0.15049245 }, { -0.14317538, 0.13548996, 0.37297491, 0.13718874 }, { 0.053339004, 0.015014013, -0.10418356, -0.13598877 }, { -0.02227412, 0.045548464, 0.21534467, -0.23828118 }, { -0.055326885, 0.11851609, 0.28938409, 0.041373996 }, { -0.1219532, 0.57338554, -0.094571555, 0.025008596 }, { 0.070380772, 0.016993506, 0.018073937, -0.015404818 }, { 0.17033841, 0.12449473, 0.10847869, -0.11141982 } } }, { { { 4.409738, 4.5071479, 5.4761817, 5.3214091 }, { 5.3741435, 4.6270256, 5.4786338, 5.323679 }, { 4.305776, 4.4890731, 4.6894257, 4.6068436 }, { 5.4930574, 4.9116386, 5.4097636, 4.9225404 }, { 5.1861828, 5.5144226, 5.1307797, 5.0804212 }, { 6.1194597, 6.0655136, 5.7369562, 6.1076578 }, { 6.9549598, 6.9281578, 6.9549598, 6.9549598 }, { 4.5030565, 4.5849566, 4.4830953, 4.4904323 }, { 5.3629211, 5.5524848, 4.5719135, 4.9103175 }, { 4.8906163, 5.3972226, 4.8806206, 5.1834202 }, { 4.5047396, 4.5984947, 4.7039612, 4.3422371 }, { 4.5956963, 5.6294962, 4.46025, 4.4827131 }, { 5.8454206, 6.000743, 5.4594428, 4.9952614 }, { 6.09642, 6.3979283, 4.9784963, 5.6878449 }, { 6.9549598, 6.9752898, 6.9549598, 6.9549598 }, { 6.2053562, 4.9984547, 5.3887395, 4.6221036 }, { 4.5265196, 4.3684629, 5.5819288, 5.4957366 }, { 5.2220057, 4.6118907, 5.5046208, 4.9190037 }, { 4.3408178, 4.4980303, 5.4937404, 5.6154153 }, { 4.4802186, 4.4666194, 4.8546878, 5.1764252 }, { 5.7384024, 5.9048089, 5.4636107, 5.0807017 }, { 5.1013817, 5.2237041, 6.0338955, 5.8869417 }, { 6.9414339, 6.9549598, 6.9549598, 6.9549598 }, { 4.3368412, 4.9692663, 4.7090567, 4.9023075 } }, { { 0.0093525884, -0.33796029, -0.4366682, -0.18161326 }, { -0.34446047, 0.10854359, -0.61563912, -0.16514117 }, { 0.055849315, 0.093045585, 0.36722184, 0.085665647 }, { -0.21881508, -0.036846235, -0.25226403, -0.012790033 }, { -0.14697546, -0.026656628, 0.2559775, 0.026279081 }, { 0.073189287, -0.074472165, -0.15439557, 0.020907645 }, { 0, -0.015078298, 0, 0 }, { 0.027540893, -0.30876053, -0.15680794, -0.18470107 }, { -0.072547269, -0.019227086, -0.26735769, -0.1362069 }, { 0.36907279, -0.28005156, 0.01966203, -0.10277819 }, { -0.26755862, 0.066747173, 0.60834173, -0.23356165 }, { -0.12357338, -0.41742338, 0.081840746, -0.14596222 }, { -0.068599762, -0.004402392, -0.17192993, -0.15797464 }, { -0.072923207, -0.02555551, -0.21075071, 0.047272919 }, { 0, 0.0115085, 0, 0 }, { 0.32527558, 0.066048741, -0.28639187, 0.45171914 }, { -0.158086, -0.049098981, -0.17226122, -0.50289857 }, { -0.39456648, 0.031970902, -0.74883626, 0.20536003 }, { 0.22864705, -0.0095988927, -0.1155595, -0.06240073 }, { 0.12336497, -0.34128076, 0.34341316, 0.083678547 }, { -0.032718317, 0.076359349, -0.30099369, -0.016865529 }, { -0.23491753, -0.17228011, -0.044893186, -0.057411459 }, { -0.0077848677, 0, 0, 0 }, { -0.18713605, -0.11612415, 0.30907006, 0.064707406 } }, { { -0.20768494, -0.15642062, -0.079474216, -0.020948121 }, { -0.18767308, -0.013722599, 0.15827086, -0.27421942 }, { -0.11484158, -0.29325715, 0.24426149, 0.34598577 }, { -0.095599056, 0.16784413, 0.23369965, 0.15036114 }, { 0.058496274, -0.064565923, -0.076598803, -0.11988702 }, { -0.03406356, -0.010863931, -0.036116475, 0.0077051595 }, { 0, -0.015078298, 0, 0 }, { -0.21271534, 0.31678528, 0.084310434, -0.039787477 }, { 0.057420352, -0.60894321, -0.14275706, -0.29178151 }, { -0.21477227, 0.091254596, -0.053659362, -0.13299553 }, { -0.24972574, 0.22261101, -0.59415755, -0.13299464 }, { -0.406027, 0.15018847, 0.33281927, 0.28006105 }, { -0.033198856, 0.013081228, 0.0098634494, -0.18858267 }, { -0.16914457, -0.014917022, -0.15618156, 0.038961385 }, { 0, 0.0115085, 0, 0 }, { 0.047340338, -0.052961301, 0.30193278, 0.38564757 }, { -0.2009302, -0.15247105, -0.32333852, 0.22878398 }, { -0.22934017, 0.022888443, 0.30911154, -0.12420416 }, { 0.21191356, -0.33281926, -0.13523708, -0.038546557 }, { 0.28507859, -0.012777666, 0.16285544, -0.12612215 }, { -0.057034227, 0.01719448, -0.037892291, -0.13064036 }, { -0.075888865, 0.041589292, 0.0089100653, -0.10775402 }, { 0.0075560462, 0, 0, 0 }, { -0.18120766, 0.16485298, 0.58949587, 0.072313493 } } }, { { { 0.60381773, 0.64633179, 0.92301353, 0.23720177 }, { 1.1128727, 0.42172315, 1.6605811, 0.22066721 }, { 0.55829912, 0.7107351, 0.47437673, 0.53646626 }, { 0.75684406, 0.65607146, 1.5264507, 0.12817954 }, { -0.25070514, 0.30263175, -0.21070678, -0.2264813 }, { -0.24745858, -0.26801252, 0.2750925, 0.055035565 }, { -0.018769156, -0.066023008, 0.10111114, 0.0089232736 }, { 0.41152465, 0.52508091, 0.4161358, 0.39058287 }, { 0.90919582, 1.2448772, 0.61547497, 0.51303689 }, { 0.2973136, 1.2348603, 0.24154398, 0.76087607 }, { 0.23369317, 0.68368068, 0.81024353, 0.35451079 }, { 0.69272073, 0.47014545, 0.61401877, 0.43768641 }, { -0.44449894, -0.10123077, -0.19173956, -0.15811184 }, { -0.089717, -0.068601549, -0.16704813, -0.29761406 }, { 0.0055968308, -0.089855929, -0.087150641, 0.2244144 }, { 0.38902787, 0.62620686, 1.3314901, 0.26038797 }, { 0.16776511, 0.32722251, 0.71914611, 0.53556119 }, { 0.63106992, 0.46256454, 1.785895, 0.17339911 }, { 0.72516261, 0.44941094, 0.81174974, 0.61247129 }, { 0.56877815, 0.20989179, 0.7607991, 0.017998645 }, { 0.016372087, 0.26062407, -0.32771461, -0.075930098 }, { -0.11957223, -0.22579003, -0.42587945, -0.0015549589 }, { 0.0049992009, 0.053511694, 0.00053268274, 0.022778575 }, { 0.19356675, 0.5564623, 0.74981777, 0.28733119 } }, { { 0.017029304, 0.22690356, 0.25927682, -0.048136042 }, { 0.52936856, -0.26082526, 0.12568074, -0.046727529 }, { 0.08949554, -0.019090555, 0.31477592, -0.067513409 }, { 0.056302335, -0.011819435, -0.063621104, 0.27092306 }, { 0.053971592, -0.17913246, -0.14991651, -0.044263405 }, { 0.29037749, -0.040498369, -0.33600753, 0.16250066 }, { -0.067102844, -0.17843768, 0.033172168, 0.13638573 }, { 0.057127881, -0.044468822, 0.33005778, 0.34775491 }, { -0.14300931, 0.022121077, -0.045281831, -0.065216583 }, { 0.084931489, 0.06688461, 0.15758114, -0.091330485 }, { -0.014274888, 0.29139103, 0.089163749, -0.18005467 }, { -0.2191522, -0.1333803, -0.31948964, -0.28536602 }, { 0.20298891, -0.0031882515, -0.15749696, -0.014977715 }, { -0.14016857, -0.17278064, 0.01369474, 0.10971499 }, { 0.018219806, 0.080447764, 0.0056022696, -0.043028475 }, { -0.076556403, -0.13038184, -0.23788273, 0.5849635 }, { 0.1038427, 0.18199702, 0.35294355, -0.0023601311 }, { 0.22294845, -0.37427713, 0.2907529, 0.26234219 }, { 0.40809306, 0.12982813, 0.42857338, 0.14064303 }, { 0.4265028, 0.18710053, 0.15310514, 0.067551813 }, { -0.18986488, -0.029676062, -0.087045959, -0.14788626 }, { -0.07865478, 0.011558295, -0.018262356, 0.38992629 }, { 0.22297641, 0.072192947, 0.064119712, 0.12862555 }, { -0.069262467, -0.14990585, 0.31342655, -0.15002022 } }, { { 0.25288162, -0.096551539, 0.051695506, 0.20925392 }, { 0.23093904, 0.096712594, 0.19826434, 0.32530694 }, { 0.14114785, 0.071010138, -0.17642029, 0.092260082 }, { 0.39001648, -0.17666595, 0.088397252, 0.1462816 }, { 0.12484597, 0.066920676, -0.16116194, 0.21758387 }, { 0.15625272, -0.00043631439, -0.07868976, -0.19261141 }, { -0.0142415, 0.06356153, 0.026276923, -0.024546668 }, { 0.097089221, 0.085426402, 0.11936115, 0.012042542 }, { 0.52509109, -0.22465399, -0.11490612, 0.023562122 }, { -0.12418278, 0.11985465, 0.087804943, 0.25283464 }, { 0.10716753, -0.036426901, 0.2469409, -0.095816257 }, { -0.095364501, 0.14001518, -0.068636804, -0.082487255 }, { 0.074490355, 0.25323233, 0.17863748, 0.12482145 }, { -0.019616587, -0.0053326518, 0.047558858, 0.066104462 }, { 0.12647102, 0.25712368, 0.12306783, -0.050252261 }, { -0.13375041, 0.17825067, 0.026649645, -0.33338076 }, { 0.16384463, -0.022241979, 0.17817325, 0.6808721 }, { 0.42075944, -0.024292721, -0.11323318, 0.45027063 }, { -0.023953485, 0.25719992, 0.28680108, 0.33600529 }, { 0.013445546, 0.22504275, 0.17408162, 0.52860686 }, { -0.098839039, -0.27017244, 0.10293505, -0.012472685 }, { 0.074267375, -0.0056418849, 0.17632358, 0.21754089 }, { 0.1491061, 0.017927571, -0.0217757, -0.0039381966 }, { 0.067239102, -0.74624136, 0.12992555, -0.058866581 } } } }, { { { { 0.1270204, 0.7650174, 0.55252173, 0.05956498 }, { -0.36870832, 0.31227245, 0.52167466, 0.4282174 }, { -0.036761861, -0.5477415, -0.76091563, -0.37583127 }, { 0.17129434, -0.14281209, -0.40463148, -0.56367877 }, { 0.07429238, 0.45420144, 0.41919765, 0.019225986 }, { -0.44125436, -0.05567539, 0.080551064, 0.54444995 }, { -0.36600455, -0.55359309, -0.3290331, 0.33946169 }, { 0.65253747, 0.015186649, 0.0665303, -0.64649501 }, { 0.05392469, 0.54355001, 0.7539307, -0.41089455 }, { -0.29264863, 0.49684721, 0.39184208, 0.47737193 }, { 0.10885354, -0.80803227, -0.7443769, -0.3736688 }, { 0.1939378, -0.079590275, -0.42241709, -0.75536039 }, { 0.44776697, 0.44884546, 0.427965, 0.3297221 }, { -0.34595785, 0.27723463, 0.12245317, 0.43884357 }, { 0.18467758, -0.55582608, -0.99421464, -0.0096027817 }, { 0.6672057, -0.038103784, -0.048616141, -0.68508055 }, { -0.016615937, 0.62001729, 0.50530563, -0.22211425 }, { -0.16823123, 0.31934529, 0.47092187, 0.4884373 }, { 0.03194189, -0.5624624, -0.44688229, 0.223814 }, { 0.17828041, -0.080017082, -0.44239439, -0.46726625 }, { 0.19895649, 0.82568772, 0.47859751, 0.064443297 }, { -0.47464217, 0.011895223, 0.01123465, -0.010697203 }, { -0.17670677, -0.66931423, -0.5814681, -0.01325001 }, { 0.65193874, -0.010713062, -0.007915928, -0.65520853 } }, { { -0.01027431, -0.0019056004, 0.0020213958, 0.0064495753 }, { 0.0058416688, 0.0051314639, 0.021497114, 0.005870592 }, { -0.00035518612, -0.00087553938, -0.0029318969, 0.0087577986 }, { -0.0048770476, -0.015949665, -0.034816051, -0.006104917 }, { 0.0015371362, -0.0012591621, 0.01241148, 0.00096621463 }, { 0.0032416133, 0.021025709, 0.0036344622, 0.0015436078 }, { -0.0093946276, 0.0046564763, 0.028177476, -0.01022744 }, { 0.00014675555, 0.030031482, -0.0092302407, -0.001999398 }, { -0.049980321, 0.024752279, 0.016684689, -0.0045230976 }, { 0.0067493834, 0.014071508, 0.0079316435, 0.034593704 }, { 0.01971715, -0.0037227013, -0.013430278, -0.024257585 }, { -0.004342319, 0.024001878, -0.013356442, -0.022792018 }, { -0.0051709665, -0.017029547, 0.040567567, 0.0052520812 }, { 0.0090399102, 0.0079604733, 0.00018765016, -0.0092868977 }, { -0.020304032, 0.0056590257, -0.0045373063, -0.018653318 }, { -9.9636934e-05, 0.002001886, 0.0046843544, 0.0055608043 }, { 0.0018025744, -0.0025962216, 0.0068285574, -0.014851062 }, { 0.00041645221, 0.0054738242, 0.0076769026, -0.013419208 }, { 0.0038347099, -0.0042555066, -0.0066470075, 0.0039146778 }, { -0.009084153, 0.024461537, 0.0034578066, -0.0054827001 }, { 0.0033463477, 0.0045594748, 0.00037604935, -0.01571513 }, { -0.012589588, 0.029678359, -0.019924871, -0.004708459 }, { -0.0002642682, -0.0051057336, -0.0042867302, -0.00041141781 }, { -0.00086487068, -0.0025170841, 0.0030062196, -0.0030385417 } }, { { -0.01027431, -0.0019056004, 0.0020213958, 0.0064495753 }, { 0.0058416688, 0.0051314639, 0.021497114, 0.005870592 }, { -0.00035518612, -0.00087553938, -0.0029318969, 0.0087577986 }, { -0.0048770476, -0.015949665, -0.034816051, -0.006104917 }, { 0.0015371362, -0.0012591621, 0.01241148, 0.00096621463 }, { 0.0032416133, 0.021025709, 0.0036344622, 0.0015436078 }, { -0.0093946276, 0.0046564763, 0.028177476, -0.01022744 }, { 0.00014675555, 0.030031482, -0.0092302407, -0.001999398 }, { -0.049980321, 0.024752279, 0.016684689, -0.0045230976 }, { 0.0067493834, 0.014071508, 0.0079316435, 0.034593704 }, { 0.01971715, -0.0037227013, -0.013430278, -0.024257585 }, { -0.004342319, 0.024001878, -0.013356442, -0.022792018 }, { -0.0051709665, -0.017029547, 0.040567567, 0.0052520812 }, { 0.0090399102, 0.0079604733, 0.00018765016, -0.0092868977 }, { -0.020304032, 0.0056590257, -0.0045373063, -0.018653318 }, { -9.9636934e-05, 0.002001886, 0.0046843544, 0.0055608043 }, { 0.0018025744, -0.0025962216, 0.0068285574, -0.014851062 }, { 0.00041645221, 0.0054738242, 0.0076769026, -0.013419208 }, { 0.0038347099, -0.0042555066, -0.0066470075, 0.0039146778 }, { -0.009084153, 0.024461537, 0.0034578066, -0.0054827001 }, { 0.0033463477, 0.0045594748, 0.00037604935, -0.01571513 }, { -0.012589588, 0.029678359, -0.019924871, -0.004708459 }, { -0.0002642682, -0.0051057336, -0.0042867302, -0.00041141781 }, { -0.00086487068, -0.0025170841, 0.0030062196, -0.0030385417 } } }, { { { -0.68772793, 0.19029367, -0.17427646, 0.60300616 }, { -0.29980532, -0.22397537, -0.4071009, 0.36277983 }, { 0.75628069, -0.13426242, 0.13645381, -0.74653491 }, { 0.14891408, -0.13497977, 0.36807879, -0.39814386 }, { -0.20608987, -0.076497863, -0.19510375, 0.34604256 }, { -0.02421123, -0.4588774, -0.64965351, 0.083039161 }, { 0.51918764, -0.30614677, -0.25791921, -0.40837612 }, { 0.028860181, 0.63152733, 0.5876224, -0.033139773 }, { -0.63418144, 0.046874151, 0.24431924, 0.71662556 }, { -0.29088451, -0.21455586, -0.73980807, 0.65038559 }, { 0.78663226, 0.00020858525, 0.40361403, -0.75720144 }, { 0.1998276, 0.54590973, 0.1773378, -0.35464319 }, { -0.40236144, 0.31362578, -0.34406026, 0.38120073 }, { -0.27845549, -0.46862161, -0.47141499, 0.095899189 }, { 0.6004921, 0.28051621, -0.011378178, -0.98141078 }, { 0.032724674, 0.66798127, 0.66430425, -0.05209965 }, { -0.59603974, -0.083198329, 0.34616224, 0.42082916 }, { -0.14262632, -0.21418442, -0.37504914, 0.32676687 }, { 0.58204273, 0.0067537174, -0.35923481, -0.40792038 }, { 0.15607366, 0.17215007, 0.34414936, -0.33566945 }, { -0.44862333, 0.004919013, 0.0076768115, 0.41897935 }, { -0.022062848, -0.39695079, -0.0062786656, 0.042925103 }, { 0.65953535, -0.15521993, 0.011867978, -0.57721165 }, { 0.031305912, 0.65627006, 0.66779002, -0.029815636 } }, { { 0.011457792, -0.011774949, -0.012205337, 0.0048139052 }, { -0.024024566, 0.018313023, -0.023210623, -0.0046351547 }, { 0.0039133571, 0.0046801024, -0.020590099, -0.0018568631 }, { -0.015369931, -0.0092621276, -0.026149742, 0.0010335971 }, { 0.032555144, -0.01336897, -0.022733265, -0.027997469 }, { -0.028161537, -0.00073877629, -0.023989631, 0.0055660453 }, { -0.012966193, 0.003944376, 0.025685982, -0.0017458044 }, { 0.00015626641, -0.009524206, 0.0083025026, -0.00049753811 }, { -0.02358661, 0.006370149, 0.00087066462, -0.00054248544 }, { -0.0024571244, -0.023218369, -0.010895303, -0.0095647684 }, { 0.0069970393, -0.00093403301, -0.0081922371, -0.00026359768 }, { 0.0065921354, 0.028846533, -0.045676337, 0.006070217 }, { 0.0045248423, -0.0084676847, 0.028756195, 0.020612871 }, { 0.0037691244, -0.0069385161, -0.00029501448, -0.0017839033 }, { -0.0048675353, -0.011930456, 0.0044251285, -0.00016323616 }, { -0.0012291164, -0.0019575288, 0.0078250029, -0.0011151155 }, { 0.00503333, -0.0094538968, 0.0092375183, 0.018207648 }, { 0.0080615812, -0.0073583459, -0.0166794, 0.016416158 }, { 0.002192959, -0.01153759, -0.0048668362, -0.0071123281 }, { -0.010116143, -0.010224552, 0.010897731, 0.00093792816 }, { 0.017199359, -0.0087516179, 0.0021169251, -0.020946959 }, { -0.01570063, 0.020087246, 0.014492818, -0.016014018 }, { 0.0023484072, 0.0015070243, -0.00045616273, -0.001211882 }, { 0.0018090492, -0.0012261901, 0.0012809284, 0.00096488905 } }, { { 0.011457792, -0.011774949, -0.012205337, 0.0048139052 }, { -0.024024566, 0.018313023, -0.023210623, -0.0046351547 }, { 0.0039133571, 0.0046801024, -0.020590099, -0.0018568631 }, { -0.015369931, -0.0092621276, -0.026149742, 0.0010335971 }, { 0.032555144, -0.01336897, -0.022733265, -0.027997469 }, { -0.028161537, -0.00073877629, -0.023989631, 0.0055660453 }, { -0.012966193, 0.003944376, 0.025685982, -0.0017458044 }, { 0.00015626641, -0.009524206, 0.0083025026, -0.00049753811 }, { -0.02358661, 0.006370149, 0.00087066462, -0.00054248544 }, { -0.0024571244, -0.023218369, -0.010895303, -0.0095647684 }, { 0.0069970393, -0.00093403301, -0.0081922371, -0.00026359768 }, { 0.0065921354, 0.028846533, -0.045676337, 0.006070217 }, { 0.0045248423, -0.0084676847, 0.028756195, 0.020612871 }, { 0.0037691244, -0.0069385161, -0.00029501448, -0.0017839033 }, { -0.0048675353, -0.011930456, 0.0044251285, -0.00016323616 }, { -0.0012291164, -0.0019575288, 0.0078250029, -0.0011151155 }, { 0.00503333, -0.0094538968, 0.0092375183, 0.018207648 }, { 0.0080615812, -0.0073583459, -0.0166794, 0.016416158 }, { 0.002192959, -0.01153759, -0.0048668362, -0.0071123281 }, { -0.010116143, -0.010224552, 0.010897731, 0.00093792816 }, { 0.017199359, -0.0087516179, 0.0021169251, -0.020946959 }, { -0.01570063, 0.020087246, 0.014492818, -0.016014018 }, { 0.0023484072, 0.0015070243, -0.00045616273, -0.001211882 }, { 0.0018090492, -0.0012261901, 0.0012809284, 0.00096488905 } } }, { { { 0.71476997, 0.61525336, 0.81507512, 0.79550964 }, { 0.87986984, 0.9232123, 0.74974956, 0.82765975 }, { 0.65321366, 0.82580437, 0.63434042, 0.54903231 }, { 0.97390084, 0.98050251, 0.83713283, 0.72370416 }, { 0.97570877, 0.88760866, 0.88668363, 0.9380218 }, { 0.89705541, 0.88675351, 0.75595095, 0.83467284 }, { 0.77232433, 0.77447327, 0.9084134, 0.84734569 }, { -0.75720667, -0.77520488, -0.80639546, -0.76219811 }, { 0.77130152, 0.83806694, 0.60983327, 0.56357207 }, { 0.91090229, 0.84089752, 0.54694041, 0.59085922 }, { 0.60775044, 0.58913818, 0.53197627, 0.53574024 }, { 0.96044628, 0.83405513, 0.88888419, 0.55105253 }, { 0.79850486, 0.83676557, 0.83574428, 0.86369517 }, { 0.89597751, 0.83876978, 0.87336884, 0.8934314 }, { 0.77801249, 0.78253947, 0.10680725, 0.19167855 }, { -0.74415432, -0.74320194, -0.74587957, -0.72660186 }, { 0.802783, 0.78016447, 0.79046691, 0.87952719 }, { 0.97537479, 0.92311625, 0.79848027, 0.80910594 }, { 0.8125306, 0.82679528, 0.81929639, 0.88516002 }, { 0.97152309, 0.98181547, 0.82815966, 0.81791703 }, { 0.87129411, 0.56410602, 0.87800085, 0.905706 }, { 0.87990229, 0.91776281, 0.99991718, 0.99902102 }, { 0.73060786, 0.72658464, 0.81348263, 0.81648708 }, { -0.75762512, -0.75445002, -0.74430762, -0.75485946 } }, { { 0.018332644, 0.0084005452, -0.0018937689, -0.0035491975 }, { 0.0016556654, 0.0049261013, -0.021796869, 0.0025973591 }, { -0.0019671758, 0.00051947074, 0.0071261223, 0.0056689139 }, { 0.00041901024, -0.0023903288, -0.0035639711, -0.0036673013 }, { 0.009963464, 0.00099195429, -0.0042516892, 0.0092605531 }, { 0.0034813664, 0.0028575465, -0.016343415, -0.0014475905 }, { 0.0053571039, 0.0051116063, 0.016171091, -0.00052744238 }, { 0.00013272575, -0.0095491849, 0.0070156475, 0.0017057538 }, { 0.028067438, -0.0086835729, -0.0087852674, 0.0035321054 }, { 0.0025007808, -0.0075654884, -0.012551417, -0.0068823899 }, { -0.00017607308, 0.002636122, -0.011272055, -0.010314896 }, { 0.010646599, 0.00042804331, 0.013900837, -0.01279076 }, { 0.0059898286, 0.012331371, -0.0073125296, 0.016248603 }, { 0.031579315, -0.0057840222, -0.00018304192, 0.005171422 }, { 0.010928513, 0.0092660887, 0.030404621, 0.0053167707 }, { -0.00014899672, -0.0035246494, 0.0075862845, -0.005861723 }, { 0.0067791918, 0.0021224495, -0.0071755505, -0.010370936 }, { 0.0015352958, -0.0025785166, -0.0092688001, 0.003966373 }, { 0.0036915074, -0.002306452, -0.005736452, -0.0033594125 }, { 0.0065128512, 0.006188005, 0.00088322638, -0.0016227066 }, { 0.0092720771, -0.0046684631, -7.3769604e-05, 0.013807013 }, { -0.0031421984, 0.010622679, 0.00041591214, 0.0032786075 }, { -0.0021421613, -0.0041675589, -0.0029529994, -0.00085350449 }, { -0.00069204344, -0.0010785124, 0.00097549628, 0.0025280456 } }, { { 0.018332644, 0.0084005452, -0.0018937689, -0.0035491975 }, { 0.0016556654, 0.0049261013, -0.021796869, 0.0025973591 }, { -0.0019671758, 0.00051947074, 0.0071261223, 0.0056689139 }, { 0.00041901024, -0.0023903288, -0.0035639711, -0.0036673013 }, { 0.009963464, 0.00099195429, -0.0042516892, 0.0092605531 }, { 0.0034813664, 0.0028575465, -0.016343415, -0.0014475905 }, { 0.0053571039, 0.0051116063, 0.016171091, -0.00052744238 }, { 0.00013272575, -0.0095491849, 0.0070156475, 0.0017057538 }, { 0.028067438, -0.0086835729, -0.0087852674, 0.0035321054 }, { 0.0025007808, -0.0075654884, -0.012551417, -0.0068823899 }, { -0.00017607308, 0.002636122, -0.011272055, -0.010314896 }, { 0.010646599, 0.00042804331, 0.013900837, -0.01279076 }, { 0.0059898286, 0.012331371, -0.0073125296, 0.016248603 }, { 0.031579315, -0.0057840222, -0.00018304192, 0.005171422 }, { 0.010928513, 0.0092660887, 0.030404621, 0.0053167707 }, { -0.00014899672, -0.0035246494, 0.0075862845, -0.005861723 }, { 0.0067791918, 0.0021224495, -0.0071755505, -0.010370936 }, { 0.0015352958, -0.0025785166, -0.0092688001, 0.003966373 }, { 0.0036915074, -0.002306452, -0.005736452, -0.0033594125 }, { 0.0065128512, 0.006188005, 0.00088322638, -0.0016227066 }, { 0.0092720771, -0.0046684631, -7.3769604e-05, 0.013807013 }, { -0.0031421984, 0.010622679, 0.00041591214, 0.0032786075 }, { -0.0021421613, -0.0041675589, -0.0029529994, -0.00085350449 }, { -0.00069204344, -0.0010785124, 0.00097549628, 0.0025280456 } } }, { { { 5.3792285, 5.1960477, 5.5112916, 5.6615254 }, { 5.0489877, 5.2428834, 5.1752035, 5.1109826 }, { 5.5205204, 5.7511938, 5.0202917, 4.9168865 }, { 4.9522523, 4.8880256, 5.1015936, 5.2858816 }, { 5.7256502, 5.7919759, 5.645241, 5.6035708 }, { 6.4076931, 6.4822111, 6.2642633, 6.3925959 }, { 6.9797014, 6.981436, 7.0028674, 6.9976464 }, { -0.03290957, -0.03290957, -0.03290957, -0.03290957 }, { 5.4977854, 5.7684965, 5.3463095, 4.8810492 }, { 4.9869047, 5.4896416, 4.9647805, 4.884877 }, { 5.3141219, 5.3357788, 4.7695434, 4.8709631 }, { 5.2056063, 5.407802, 5.2123857, 4.9428208 }, { 6.2188218, 6.17756, 6.2751008, 6.3672109 }, { 6.9105856, 6.7986798, 6.5712335, 6.5907061 }, { 6.9797014, 6.9797014, 5.6859993, 5.5642483 }, { -0.032764603, -0.032764603, -0.032764603, -0.032764603 }, { 5.7724142, 6.0929556, 5.99581, 5.9265164 }, { 4.9363192, 4.9823732, 5.1732995, 5.2475265 }, { 5.8365191, 5.9972902, 5.9778441, 5.9270668 }, { 4.8706768, 5.0194503, 5.155585, 5.2188041 }, { 6.1569904, 6.0563989, 6.0989699, 6.2139837 }, { 5.8727399, 5.8948086, 5.5734095, 5.5536103 }, { 6.9797014, 6.9797014, 6.9797014, 6.9797014 }, { -0.032766769, -0.032766769, -0.032766769, -0.032766769 } }, { { 0.0011802354, -0.006546101, -0.02103972, 0.0008654047 }, { -0.015460534, 0.017874544, 0.0029121134, 0.023511773 }, { -0.040909245, 0.011927691, 0.011991588, 0.01677931 }, { -0.015633544, -0.0042321141, 0.026623034, 0.0080414514 }, { 0.012614382, 0.0065080145, 0.035716738, -0.0080665814 }, { -0.0057849744, -0.017478461, -0.031219642, 0.00016446523 }, { 0, 0.00032235028, 0, 0 }, { 0, 0, 0, 0 }, { -0.068586697, -0.024228236, -0.012857221, -0.039493706 }, { -0.018078201, -0.015140979, 0.00072119173, -0.051249859 }, { -0.054228277, 0.0097895101, 0.0019832646, -0.011715411 }, { -0.042326208, -0.010160072, 0.037088052, -0.031848667 }, { 0.00067130897, -0.013966717, -0.017268559, -0.0074614576 }, { 0.070515961, 0.012848107, -0.0008396517, 0.0049006506 }, { 0, 0, -0.063014256, -0.0085124986 }, { 0, 0, 0, 0 }, { -0.040302299, 0.0048936307, 0.0064406394, 0.0034044871 }, { -0.010453589, 0.0035820836, -0.017384391, -0.038199947 }, { -0.044968611, -0.0088322127, 0.020303819, 0.0058131005 }, { -0.0056838535, 0.010211409, -0.010999927, -0.027621859 }, { 0.0064753811, -0.0059341242, -0.014902755, 0.0082868118 }, { -0.0013222735, 0.0028492181, -0.023523273, -0.02576271 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }, { { 0.0011802354, -0.006546101, -0.02103972, 0.00086540469 }, { -0.015460534, 0.017874544, 0.0029121134, 0.023511773 }, { -0.040909245, 0.011927691, 0.011991588, 0.01677931 }, { -0.015633544, -0.0042321141, 0.026623034, 0.0080414514 }, { 0.012614382, 0.0065080145, 0.035716738, -0.0080665814 }, { -0.0057849744, -0.017478461, -0.031219642, 0.00016446523 }, { 0, 0.00032235028, 0, 0 }, { 0, 0, 0, 0 }, { -0.068586697, -0.024228236, -0.012857221, -0.039493706 }, { -0.018078201, -0.015140979, 0.00072119173, -0.051249859 }, { -0.054228277, 0.0097895101, 0.0019832646, -0.011715411 }, { -0.042326208, -0.010160072, 0.037088052, -0.031848667 }, { 0.00067130897, -0.013966717, -0.017268559, -0.0074614576 }, { 0.070515961, 0.012848107, -0.0008396517, 0.0049006506 }, { 0, 0, -0.063014256, -0.0085124986 }, { 0, 0, 0, 0 }, { -0.040302299, 0.0048936307, 0.0064406394, 0.0034044871 }, { -0.010453589, 0.0035820836, -0.017384391, -0.038199947 }, { -0.044968611, -0.0088322127, 0.020303819, 0.0058131005 }, { -0.0056838535, 0.010211409, -0.010999927, -0.027621859 }, { 0.0064753811, -0.0059341242, -0.014902755, 0.0082868118 }, { -0.0013222735, 0.0028492181, -0.023523273, -0.02576271 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } } }, { { { 0.72189984, 0.22069996, 0.71952927, 0.77725949 }, { 0.4054405, 0.20582059, 0.2747016, 0.37612563 }, { 0.58887422, 0.27441131, 0.19468101, 0.21480554 }, { 0.46814145, 0.34317, 0.46068212, 0.13962064 }, { -0.18134132, -0.26668789, -0.60984999, -0.67879259 }, { -0.47870351, -0.34453227, 0.32494779, 0.10292971 }, { 0.087252967, 0.066950358, 0.31813819, 0.071094818 }, { -0.0031436256, 0.038245091, -0.0076651913, -0.015389479 }, { 1.2668531, 1.2894974, 0.40584018, 0.51755806 }, { 1.3207257, 1.3403747, 0.54924634, 0.40282713 }, { 0.78581828, 0.56379328, 0.27901993, 0.56429306 }, { 0.8748226, 1.0271253, 1.0085726, 0.3888545 }, { -0.22577636, -0.32895071, -0.2846317, -0.11679531 }, { 0.26477285, 0.3179447, -0.063393238, 0.024059773 }, { -0.15463395, -0.22721468, -0.20680404, -0.15700788 }, { 0.012107106, -0.0061245949, -0.024224367, 0.005040693 }, { 0.97943693, 0.64840429, 0.45106998, 0.40771935 }, { 0.49907853, 0.1562184, 0.34338458, 0.39710628 }, { 0.95047709, 0.53336107, 0.38318275, 0.44919148 }, { 0.41892697, 0.069965886, 0.45831656, 0.38821529 }, { -0.20216736, -0.43209441, -0.57684857, -0.40189427 }, { -0.63992377, -0.40683032, -0.59207903, -0.57251716 }, { -0.047117438, -0.1880015, -0.12265155, 0.00059988607 }, { -0.011836442, -0.010049497, -0.0026152072, 0.016137736 } }, { { 0.092068993, 0.0045466749, 0.0054574031, 0.02582156 }, { 0.022115456, -0.015664041, -0.022004653, 0.041431654 }, { 0.029951298, -0.0004408542, 0.0087496069, 0.017850027 }, { 0.029086373, 0.022116039, 0.044010315, 0.001644876 }, { 0.016256387, 0.0083249367, 0.019570849, -0.0021276222 }, { 0.0079070076, -0.024696939, 0.044311101, 0.023671132 }, { -0.0081796119, -0.0024995551, 0.033501743, -0.031958988 }, { 0.0065005403, -0.076642001, 0.015736477, 0.030966939 }, { 0.029110717, 0.039154477, -0.074376619, 0.025532063 }, { -0.10980761, 0.0038346834, 0.014449171, -0.030702653 }, { -0.00068350423, -0.037251569, -0.008409224, -0.026322878 }, { 0.035406012, 0.064176275, 0.031437854, -0.0344642 }, { 0.037145809, -0.024909212, 0.041030386, 0.035216105 }, { -0.093276646, -0.013904083, -0.019536023, -0.023834405 }, { 0.042751846, -0.03620164, 0.081115921, 0.018379967 }, { -0.023909625, 0.012833691, 0.048086442, -0.0097340268 }, { 0.039552712, -0.00026806514, 0.011646753, 0.0065939486 }, { 0.058985248, 0.020165701, 0.0076721521, 0.033274221 }, { 0.052889871, 0.0042520093, 0.016490396, 0.009287973 }, { 0.044305975, -0.0016263469, 0.041390177, 0.033541355 }, { 0.014595133, -0.004801042, -0.0049517302, 0.015714264 }, { 0.00075086205, 0.0080838736, -0.037611057, -0.030488441 }, { 0.0019178075, -0.0082517768, -0.002525773, 0.0043993022 }, { 0.023774971, 0.020335611, 0.0056643868, -0.032100338 } }, { { 0.092068993, 0.0045466749, 0.0054574031, 0.02582156 }, { 0.022115456, -0.015664041, -0.022004653, 0.041431654 }, { 0.029951298, -0.0004408542, 0.0087496069, 0.017850027 }, { 0.029086373, 0.022116039, 0.044010315, 0.001644876 }, { 0.016256387, 0.0083249367, 0.019570849, -0.0021276222 }, { 0.0079070076, -0.024696939, 0.044311101, 0.023671132 }, { -0.0081796119, -0.0024995551, 0.033501743, -0.031958988 }, { 0.0065005403, -0.076642001, 0.015736477, 0.030966939 }, { 0.029110717, 0.039154477, -0.074376619, 0.025532063 }, { -0.10980761, 0.0038346834, 0.014449171, -0.030702653 }, { -0.00068350423, -0.037251569, -0.008409224, -0.026322878 }, { 0.035406012, 0.064176275, 0.031437854, -0.0344642 }, { 0.037145809, -0.024909212, 0.041030386, 0.035216105 }, { -0.093276646, -0.013904083, -0.019536023, -0.023834405 }, { 0.042751846, -0.03620164, 0.081115921, 0.018379967 }, { -0.023909625, 0.012833691, 0.048086442, -0.0097340268 }, { 0.039552712, -0.00026806514, 0.011646753, 0.0065939486 }, { 0.058985248, 0.020165701, 0.0076721521, 0.033274221 }, { 0.052889871, 0.0042520093, 0.016490396, 0.009287973 }, { 0.044305975, -0.0016263469, 0.041390177, 0.033541355 }, { 0.014595133, -0.004801042, -0.0049517303, 0.015714264 }, { 0.00075086205, 0.0080838736, -0.037611057, -0.030488441 }, { 0.0019178075, -0.0082517768, -0.002525773, 0.0043993022 }, { 0.023774971, 0.020335611, 0.0056643868, -0.032100338 } } } } };
+const float high_quality_coeffs[7][5][3][24][4] = { { { { { -4.8355339e-06f, -4.4902569e-05f, -9.2632249e-05f, -0.00053773136f }, { 0.0040143823f, -0.00060900339f, -0.0095301923f, -0.0053956011f }, { -0.0005923892f, -3.6901978e-05f, -5.6694857e-06f, -0.00017018564f }, { 0.0012441402f, 0.02236187f, 0.022751769f, 0.0062788948f }, { 0.00013810055f, -2.2709815e-05f, 0.0054849671f, -1.6599195e-05f }, { -0.020320408f, -0.017066319f, -0.017457746f, 0.022910628f }, { 0.00024171724f, 9.7419073e-05f, -0.00047804272f, -0.00010093683f }, { 7.6988167e-05f, 1.8551597e-05f, -5.7692813e-05f, -3.332362e-05f }, { -0.00062766208f, 2.713742e-05f, 0.00026511682f, 2.3841873e-05f }, { -0.00043656844f, 0.0028645469f, 0.0049817085f, 0.0080221478f }, { -3.3210444e-05f, -8.0852386e-05f, -2.2111492e-06f, -8.4430827e-05f }, { 0.010967284f, 0.018811225f, 0.017569463f, -0.0046944996f }, { -0.00018391248f, -0.00010462174f, -0.00017726f, -0.00018490133f }, { 0.00012591989f, 0.015965386f, 0.015964059f, -0.0078018431f }, { -0.006125333f, -8.2224165e-05f, -0.00020500151f, -0.00025207244f }, { -0.00016320041f, -0.0001279242f, 0.00014038799f, 8.1359421e-05f }, { -0.00064341098f, -0.0011265496f, -0.0011634792f, -0.00081607159f }, { 0.00089294825f, 0.0061923653f, 0.0052662392f, -0.00058227469f }, { -2.4001308e-05f, -1.3534224e-05f, -1.4720478e-05f, -2.5120827e-05f }, { 0.00029964918f, -0.0045658543f, -0.0045581938f, 0.0017106208f }, { 7.5790173e-05f, -1.8265415e-05f, 1.5918205e-05f, 5.8524021e-05f }, { 0.0011669872f, -0.00017571882f, -0.00017190275f, -0.0023833977f }, { 0.0033487264f, -0.0066535821f, -0.0066413786f, -0.0032332601f }, { -3.6468807e-05f, -0.00068145131f, -9.8190714e-05f, -8.7169435e-05f } }, { { -0.0010440653f, -8.9750644e-05f, 4.971182e-05f, 0.0044618878f }, { 0.0078333883f, -0.00090884312f, -0.00046920549f, -0.002465051f }, { -0.0058778609f, 0.0026554895f, -0.00031880506f, -0.00010649091f }, { -0.0015095448f, 0.0094026506f, 0.009492703f, 0.0024572848f }, { 0.0047331786f, 0.00070722401f, 0.0028798817f, -0.00039779892f }, { -0.0089878107f, -0.0095474878f, -0.0097187652f, 0.008765907f }, { -4.0435321e-05f, -0.00061813281f, -0.0060490143f, 0.0016259965f }, { -0.00014720558f, -1.0601876e-05f, 0.00014757138f, 0.00016227641f }, { -0.010428289f, -0.00031812813f, -0.0016172213f, -0.00012022134f }, { 0.0040517131f, 0.0072972763f, 0.0060433905f, 0.0025041645f }, { 0.00014090924f, 0.00027612853f, 0.00015961665f, 0.0002605418f }, { -0.00020653783f, -0.00048482867f, -0.00058472338f, 0.00026413759f }, { 0.00056712638f, 0.00026385353f, 0.00035484947f, 0.00033212447f }, { -0.00094663094f, 0.0029891757f, 0.0029887838f, -0.0026583585f }, { -0.0017400246f, 0.00042350567f, 0.00086128207f, 0.00039863587f }, { 0.00059604848f, 0.00027495434f, -0.00059956434f, -4.4981673e-05f }, { -0.010211343f, -0.0080580409f, -0.0085333216f, 0.0023258717f }, { 0.00042832593f, 0.0056750222f, 0.0048059635f, -0.0092168281f }, { 3.0214612e-05f, 4.540924e-06f, 1.7239937e-05f, 2.783598e-05f }, { 0.00029393335f, -4.5128636e-05f, -4.3089017e-05f, 0.00030682556f }, { -4.7077735e-05f, -1.3596835e-05f, -0.0015338149f, -7.4957991e-05f }, { -0.00097136844f, 0.00018564298f, 0.00021815754f, 0.0015095577f }, { 0.00043929849f, -0.0014691094f, -0.0014671742f, -0.00029365954f }, { 8.8554045e-05f, 0.0062500772f, 0.0001495049f, 0.00021007601f } }, { { 0.0020307077f, 0.0020947445f, 0.0017438295f, 0.0084822342f }, { -0.0069727503f, -0.0010131005f, 0.0055261321f, -0.0020442588f }, { 0.00031035611f, 0.00010839441f, 3.7359209e-06f, 4.3112837e-05f }, { 9.1207794e-05f, 0.0050148169f, 0.0051071455f, 0.0033679057f }, { -0.00090101737f, -0.00053793176f, -0.0025829621f, 0.0003241927f }, { -0.0019244714f, -0.0033690472f, -0.0035193497f, 0.0027653636f }, { -0.00065476293f, -0.00017787403f, 0.00040383136f, -0.00018123957f }, { -0.00030640434f, -0.00018961553f, -0.00011036218f, -0.00015793049f }, { 0.001110592f, -0.00021252645f, 0.00015849587f, -3.7758317e-05f }, { 0.00077967828f, -0.0051765235f, -0.0078505592f, -0.010796339f }, { -1.2024951e-05f, 6.48806e-05f, -3.9409005e-05f, 7.4639306e-05f }, { -0.00017352424f, -0.00037802595f, -0.00045639468f, 0.00016843169f }, { -4.2866244e-05f, -4.3730932e-06f, 7.3574276e-05f, 5.6076779e-05f }, { 0.00024802387f, 0.0018053101f, 0.0018042994f, -0.0016700716f }, { 0.0082698262f, -0.00014605077f, 0.0004377682f, 8.1585074e-05f }, { -4.494343e-06f, 0.00019781519f, -0.00058910268f, -0.00027360572f }, { 0.0013016934f, 0.0021020456f, 0.0022718598f, -0.0059377824f }, { 0.002185371f, -0.0080788056f, -0.0071952836f, 0.0039688918f }, { 0.00013048617f, 0.0001738124f, 0.00012978924f, 0.00013813358f }, { 0.00032386518f, 0.00023046021f, 0.00023064714f, 0.00033762343f }, { 0.00023643771f, 0.00019652953f, 0.0013083597f, 0.00024739959f }, { -0.0063957036f, -0.0055319023f, -0.0054742301f, -0.0037204932f }, { -0.0005510683f, -0.0007715413f, -0.00077385934f, -0.001009415f }, { 0.00017904616f, -0.00096137522f, 0.00030252599f, -2.2478138e-05f } } }, { { { -0.00038948583f, -0.00040817153f, -0.00041280315f, -0.0010985631f }, { 0.0025695337f, 0.00042904308f, 0.0054649973f, -0.0055079106f }, { 0.00052050672f, 2.2618679e-05f, 0.00024058975f, -0.00012632201f }, { -0.013468886f, 0.0079396715f, 0.0079402246f, 0.026283756f }, { -7.922122e-05f, -3.4761763e-06f, -0.0041716347f, 0.0001478739f }, { 0.023716381f, -0.016415262f, -0.015296927f, -0.021050827f }, { 3.7654391e-05f, 0.00012765816f, -0.0001337099f, 0.00051483398f }, { 0.00015671907f, 0.00010686796f, 2.1421097e-05f, -2.2281569e-05f }, { 3.1779413e-06f, 0.00010449913f, -0.00018303614f, 7.5382489e-05f }, { -0.00020526765f, -0.0011333575f, -0.0050720108f, 0.0051482782f }, { 4.0450357e-05f, 1.0808158e-05f, -2.3316095e-05f, 9.7767333e-06f }, { -0.019107229f, 0.010907324f, 0.0048969594f, 0.017851514f }, { 7.4048796e-05f, -7.041835e-06f, 8.0226174e-05f, 5.1714105e-05f }, { -0.016564627f, 0.0023486944f, 0.0023601429f, 0.016005248f }, { -0.004528284f, 3.6291049e-05f, 2.4229636e-05f, 0.0024853948f }, { 5.6882054e-05f, 6.8805135e-05f, 0.00013119897f, 0.00010339801f }, { 0.00021183341f, 0.0008203137f, -7.204401e-05f, 0.00062599728f }, { -0.00099314707f, 0.0030198762f, -0.0038989955f, 0.00055571214f }, { -7.4247984e-05f, -8.3993373e-05f, -5.9133252e-05f, -7.7411989e-05f }, { 0.0054296732f, -0.00057858871f, -0.00058417754f, -0.005072911f }, { -0.00019259782f, -0.00018772532f, -4.2959783e-05f, -0.0001827295f }, { -0.00029351865f, 0.00013736372f, 0.00016666048f, 0.00020873447f }, { 0.0069341659f, 0.0027612928f, 0.0027538377f, -0.0061770317f }, { 4.2584714e-05f, -0.00037063589f, -9.0693123e-06f, 0.00011845784f } }, { { 0.0028834168f, 0.0031807308f, 0.0031352582f, 0.01064051f }, { 0.0049297987f, -4.2149356e-05f, -0.0014926841f, -0.0002300371f }, { 0.0020396303f, -0.00066042794f, -6.4359283e-05f, 0.00017835163f }, { -0.0025767816f, 0.0025148152f, 0.0025224779f, 0.0043006543f }, { -0.00042084416f, -0.00013534305f, 0.002453623f, -4.0707749e-05f }, { -0.0001803055f, -0.0010450606f, -0.00084380806f, 0.00014843677f }, { -0.0064067107f, 0.00011012652f, -0.0022552747f, -0.00080508294f }, { -0.00017778763f, -4.296789e-05f, 0.00015343883f, 0.00025036711f }, { 0.002825978f, -0.00031945362f, -0.00031987612f, -0.00021117763f }, { 0.00032791249f, -0.00049524542f, 0.0049368722f, -0.0017186408f }, { -0.0001685943f, -0.00016766033f, -0.0001755097f, -0.00017067307f }, { 0.00023939157f, -0.00011793706f, -6.0620575e-05f, -0.0002706595f }, { -2.9718673e-05f, 3.5950879e-05f, 1.839844e-05f, -2.8718148e-05f }, { -0.0017260981f, 0.00012145435f, 0.0001236679f, 0.0018292155f }, { 0.0036086706f, 0.0001026898f, -2.5518889e-05f, -0.00019830236f }, { -0.00031546808f, -0.00042107458f, -0.00059963868f, -0.00061472497f }, { -0.0074719522f, 0.0015719596f, -0.0033624165f, -0.0092664101f }, { -0.0011285776f, 0.0018601435f, 0.00052060704f, -1.5554679e-05f }, { 4.9853171e-05f, 7.3650922e-05f, 3.4080107e-05f, 5.4255445e-05f }, { 0.00015102779f, -2.58105e-05f, -2.5851018e-05f, -4.5185316e-05f }, { 0.0002057452f, 0.00019037765f, 0.0040052198f, 0.00020046579f }, { 0.0027727314f, 0.0040749211f, 0.0036050794f, 0.0034635222f }, { 0.00042503689f, 0.00056027382f, 0.00056052971f, -8.2485044e-05f }, { -5.6309634e-05f, 0.0019722025f, 6.4267434e-05f, -0.00020376412f } }, { { 0.0051607661f, 0.0047835358f, 0.0047658352f, 0.0054281814f }, { -0.0040939561f, 0.0012119183f, -0.0023408179f, -0.00055891234f }, { -0.0031939804f, -0.0015954053f, -0.00018570689f, 0.00028849431f }, { -0.0075625096f, 0.0033878734f, 0.0033797415f, 0.010242674f }, { -0.002293562f, 0.00024245282f, 0.0019455622f, 0.0039550747f }, { 0.0090386754f, -0.0086947671f, -0.0082684939f, -0.0075613346f }, { -0.00085735117f, 3.4822634e-05f, -0.0024653972f, -0.00090964985f }, { -0.00013750587f, -0.00010089501f, 6.3555498e-05f, 0.0002758494f }, { 0.0060496328f, -0.00032664426f, 0.0005979723f, -0.00018819024f }, { 0.00072724184f, 0.00082242885f, 0.0045668772f, -0.0054557456f }, { -9.6167811e-05f, 7.9856612e-05f, 0.00015672473f, 8.0901183e-05f }, { 0.00038859448f, -0.00025360755f, -0.00017624981f, -0.00049125519f }, { -8.8277361e-05f, 2.4159527e-05f, -0.00016014627f, -2.7854246e-05f }, { -0.0037308647f, 0.00041434141f, 0.0004167221f, 0.0037190244f }, { 0.00050696744f, -4.6752715e-05f, 0.00033183668f, -0.0025882828f }, { -0.00015915702f, -0.0002325901f, -0.00036157415f, -0.00016391937f }, { 0.00012320153f, 0.0026711886f, 0.0018414591f, -0.0058215223f }, { -0.0029409983f, -0.00015460743f, 0.0031951665f, 0.0074654329f }, { 9.9084813e-05f, 9.1785865e-05f, 5.9300007e-05f, 0.00010463304f }, { 0.00024773341f, -2.5723276e-05f, -2.5709769e-05f, -0.00015357475f }, { 0.000416633f, 0.00028749584f, -0.0038632071f, 0.00039869488f }, { 0.00018344152f, 3.0811778e-05f, -0.00010240082f, 0.00059301197f }, { 0.0019217461f, 0.00034404024f, 0.00034318823f, -0.0015867375f }, { -0.00011928879f, 0.001178769f, -5.8655983e-05f, -0.00028461439f } } }, { { { 0.99999992f, 0.99999992f, 0.99999991f, 0.99999925f }, { 0.99998864f, 0.99999972f, 0.99993965f, 0.99997027f }, { 0.99999969f, 1.0f, 0.99999997f, 0.99999998f }, { 0.99990852f, 0.99971841f, 0.99970961f, 0.9996348f }, { 0.99999999f, 1.0f, 0.99997626f, 0.99999999f }, { 0.99951219f, 0.9997196f, 0.99973058f, 0.99951587f }, { 0.99999997f, 0.99999999f, 0.99999988f, 0.99999986f }, { 0.99999998f, 0.99999999f, 1.0f, 1.0f }, { 0.9999998f, 0.99999999f, 0.99999995f, 1.0f }, { 0.99999988f, 0.99999525f, 0.99997473f, 0.99995457f }, { 1.0f, 1.0f, 1.0f, 1.0f }, { 0.99975729f, 0.99976356f, 0.99983365f, 0.99982963f }, { 0.99999998f, 0.99999999f, 0.99999998f, 0.99999998f }, { 0.99986279f, 0.99986979f, 0.99986978f, 0.99984147f }, { 0.99997099f, 1.0f, 0.99999998f, 0.99999688f }, { 0.99999999f, 0.99999999f, 0.99999998f, 0.99999999f }, { 0.99999977f, 0.99999903f, 0.99999932f, 0.99999947f }, { 0.99999911f, 0.99997627f, 0.99997853f, 0.99999968f }, { 1.0f, 1.0f, 1.0f, 1.0f }, { 0.99998521f, 0.99998941f, 0.99998944f, 0.99998567f }, { 0.99999998f, 0.99999998f, 1.0f, 0.99999998f }, { 0.99999928f, 0.99999998f, 0.99999997f, 0.99999714f }, { 0.99997035f, 0.99997405f, 0.99997415f, 0.99997569f }, { 1.0f, 0.9999997f, 1.0f, 0.99999999f } }, { { 0.00015966941f, 0.00014262676f, 0.00020165066f, 0.00021618914f }, { 2.8140907e-06f, -0.00020325872f, 0.00017736728f, 6.0386679e-05f }, { -0.0003187876f, 5.8862288e-05f, 6.2281085e-05f, 1.7339908e-05f }, { -2.6587911e-05f, -0.00011609007f, -0.00011725093f, -7.6114852e-05f }, { 0.00013665042f, 5.2703844e-06f, -0.00031293536f, 3.8693931e-05f }, { -9.8143069e-05f, -0.00012816332f, -0.00012926252f, -0.00010623032f }, { 0.00032342312f, -1.9200091e-06f, -0.00010691485f, 6.3541059e-05f }, { -8.0643542e-06f, 9.7622933e-06f, 2.9924822e-05f, -1.988333e-05f }, { 0.00025318464f, 1.2588649e-05f, 1.4665927e-05f, 9.3294806e-06f }, { 2.6875391e-06f, -2.4928123e-05f, 2.251878e-05f, 0.00011026808f }, { 1.767638e-05f, 1.0309044e-05f, 2.4765648e-05f, 1.4397941e-05f }, { 6.9000935e-06f, 1.0637078e-05f, 1.087637e-05f, 6.3065784e-06f }, { 5.532953e-05f, 1.6231463e-05f, 4.9564371e-05f, 3.6623041e-05f }, { -1.6958729e-05f, -3.1627491e-05f, -3.1524511e-05f, -2.9954116e-05f }, { 8.9045086e-05f, 2.1005026e-05f, 1.3016463e-05f, 8.7863053e-05f }, { -2.75035e-05f, -3.0440427e-05f, -3.5356286e-05f, 5.9609261e-06f }, { 0.0001586274f, 4.0711165e-05f, 3.1563135e-05f, 0.0001385483f }, { 8.5548316e-06f, 7.4531928e-05f, -3.7017413e-05f, 2.6874037e-05f }, { -1.3750655e-05f, -8.2756032e-06f, -2.7214983e-07f, -1.4830115e-05f }, { -7.0798362e-07f, -3.3187173e-07f, -3.3266762e-07f, -5.7113855e-07f }, { 4.3615512e-05f, -4.4076433e-06f, 8.9239586e-06f, 3.7278531e-05f }, { -7.7366773e-06f, 4.610399e-06f, 4.3762687e-06f, -5.64067e-06f }, { -3.2666125e-06f, -1.0773146e-05f, -1.0861965e-05f, -1.3327232e-06f }, { -9.1178305e-06f, 0.00030171207f, -1.5395234e-05f, -2.0695425e-07f } }, { { 0.00017159464f, 0.00014699558f, 0.00018752678f, 0.0002227926f }, { -4.6524822e-05f, -0.00010460271f, 0.00034735325f, 0.00010082238f }, { -6.8269006e-05f, 1.4343751e-05f, 7.7283393e-06f, 2.5347136e-05f }, { -6.6149546e-05f, -7.1168993e-05f, -7.0621016e-05f, -0.00015246746f }, { 7.12022e-05f, 3.8790461e-05f, -0.00023994449f, 6.6792921e-05f }, { -0.00014735813f, -0.00012658353f, -0.00012162488f, -0.00012106777f }, { 0.00015161388f, -1.4439153e-05f, -3.7629923e-06f, 8.3140788e-06f }, { 4.0175416e-05f, 2.5380268e-05f, -2.2894421e-06f, 4.6374378e-06f }, { 0.00028906023f, 1.7695243e-05f, 5.3790587e-06f, 1.631859e-05f }, { 1.8890685e-05f, -1.6898275e-05f, 2.1007663e-05f, 6.5179363e-05f }, { -3.9142595e-06f, 2.5745488e-05f, 1.0803197e-05f, 2.7099749e-05f }, { 9.4245546e-06f, 1.0010075e-05f, 9.058324e-06f, 9.8703427e-06f }, { -2.3441863e-06f, 2.5490323e-05f, -1.0097654e-05f, 4.0554798e-05f }, { -4.1443921e-05f, -1.996316e-05f, -2.0000841e-05f, -4.7495655e-05f }, { 0.00012591695f, 5.6179903e-05f, -1.8415869e-05f, -3.8697972e-05f }, { 2.6719505e-05f, 2.4195362e-06f, 2.4287424e-05f, 3.4703059e-05f }, { 7.3804931e-05f, 4.9784871e-05f, 3.1159931e-06f, 0.00015857197f }, { -0.00010634331f, -1.6427658e-05f, -7.4874306e-05f, -6.2620255e-05f }, { -4.2561214e-06f, -1.6123179e-05f, -1.5507273e-05f, -1.2909924e-05f }, { -1.2210463e-06f, 1.1546399e-06f, 1.1413892e-06f, -1.3465856e-06f }, { 3.4909884e-05f, -1.2677793e-05f, 0.00011543701f, 2.413091e-05f }, { -2.1953323e-05f, -4.6244252e-06f, -3.5624435e-06f, 4.2293671e-06f }, { -1.1392936e-05f, -4.3970369e-06f, -4.4264864e-06f, -1.208518e-05f }, { -4.4002617e-05f, 0.00020912348f, -3.9617824e-05f, -4.1725112e-05f } } }, { { { -0.32504349f, -0.32502096f, -0.32501094f, -0.32423576f }, { -0.65602876f, -0.65622598f, -0.65567173f, -0.65525128f }, { -1.4666488f, -1.4666488f, -1.4666488f, -1.4666488f }, { 0.87168363f, 0.87181364f, 0.87181792f, 0.8718169f }, { -1.264365f, -1.264365f, -1.264365f, -1.264365f }, { 0.89917968f, 0.89916889f, 0.89916525f, 0.89927374f }, { -1.2245906f, -1.2245906f, -1.2245906f, -1.2245906f }, { -0.8885678f, -0.88856217f, -0.88856327f, -0.88855044f }, { -0.31799095f, -0.31916566f, -0.31907669f, -0.31918911f }, { -0.08987958f, -0.090342401f, -0.090004674f, -0.090222398f }, { -0.59425693f, -0.59433999f, -0.59429118f, -0.59433553f }, { 1.1317575f, 1.1317475f, 1.1317412f, 1.1317494f }, { -1.2193493f, -1.2193493f, -1.2193493f, -1.2193493f }, { 1.2506981f, 1.250675f, 1.250675f, 1.2506569f }, { -1.08782f, -1.0877793f, -1.0878022f, -1.0878025f }, { -0.13925598f, -0.13932948f, -0.13919658f, -0.13913403f }, { -0.40394684f, -0.4042314f, -0.40436178f, -0.40402218f }, { -0.47762966f, -0.47745572f, -0.47767784f, -0.47713093f }, { -0.60177181f, -0.60176862f, -0.60177347f, -0.60177079f }, { 2.7311956f, 2.7311911f, 2.7311911f, 2.731191f }, { -1.3109856f, -1.3109856f, -1.3109856f, -1.3109856f }, { 0.60942644f, 0.60941369f, 0.6094123f, 0.60944198f }, { 0.55675448f, 0.55672275f, 0.55672303f, 0.5567542f }, { -0.40637059f, -0.4057945f, -0.40635768f, -0.40636681f } }, { { -0.0016154222f, -0.0015930079f, -0.0015828998f, -0.00087447165f }, { -0.0011262472f, -0.001324462f, -0.00094895016f, -0.00062188189f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 9.7616744e-05f, 0.00010718899f, 0.00010718606f, 0.00012665246f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.00013476236f, 6.982272e-05f, 6.8208505e-05f, 0.00014604742f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { -0.0031089951f, -0.0031071196f, -0.0031207245f, -0.0031097054f }, { -0.0027808116f, -0.0035049857f, -0.0034100135f, -0.0035192661f }, { -0.0018291474f, -0.0019603285f, -0.0018919656f, -0.0019656229f }, { -0.0034301741f, -0.0034912573f, -0.0034474395f, -0.0034893985f }, { -6.156701e-06f, -9.8568527e-06f, -1.2383692e-05f, -9.9984205e-06f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.00011838153f, 0.00011008679f, 0.00011008878f, 0.00010536608f }, { -0.0006246638f, -0.00058479459f, -0.00061327452f, -0.00061085433f }, { -0.0059197749f, -0.0059778169f, -0.0059586015f, -0.0058798299f }, { -0.0013246996f, -0.0016061786f, -0.0016081246f, -0.0014374546f }, { -0.001593227f, -0.0014706843f, -0.0015974008f, -0.001341579f }, { -0.0027930604f, -0.0027920013f, -0.0027939865f, -0.0027928528f }, { -1.8908723e-06f, -4.266382e-06f, -4.2210172e-06f, -5.0155215e-06f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.00018508026f, 0.00019774537f, 0.00019744661f, 0.00019538593f }, { 2.3243747e-05f, 1.7291398e-05f, 1.7309712e-05f, 2.9261396e-05f }, { -0.0041402471f, -0.0037085946f, -0.0041294876f, -0.0041316136f } }, { { -0.0018899732f, -0.0018719182f, -0.0018661076f, -0.0012234594f }, { -0.0012968123f, -0.0012971446f, -0.00093522854f, -0.00066475268f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 9.1054464e-05f, 0.00014124217f, 0.00014156806f, 0.00012014953f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.00017026995f, 0.00010528413f, 0.00010537941f, 0.00015698848f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { -0.0025812972f, -0.0025835894f, -0.0025789321f, -0.002554949f }, { -0.0035568863f, -0.0042988014f, -0.0042155548f, -0.004312546f }, { -0.0024184575f, -0.0025111277f, -0.0024654994f, -0.0023980076f }, { -0.0036993386f, -0.0037113013f, -0.0036987284f, -0.0037094875f }, { -5.074861e-06f, -1.1367399e-05f, -1.4819989e-05f, -9.2705899e-06f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.00012570403f, 0.00012150272f, 0.00012149179f, 0.00010579599f }, { -0.00062162762f, -0.00058131015f, -0.00060837583f, -0.00060795256f }, { -0.00775735f, -0.0077198081f, -0.0078365948f, -0.0077749317f }, { -0.0015325554f, -0.0017125784f, -0.001703195f, -0.0015662859f }, { -0.0018130784f, -0.00177106f, -0.001858095f, -0.0015845058f }, { -0.003668417f, -0.0036659688f, -0.0036693421f, -0.0036680526f }, { -9.5804016e-06f, -9.6276607e-06f, -9.630607e-06f, -1.2159056e-05f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.00017930618f, 0.00020084683f, 0.00020150104f, 0.00020810787f }, { 2.3869269e-05f, 1.1024793e-05f, 1.1041937e-05f, 1.6467357e-05f }, { -0.004690782f, -0.0044656761f, -0.0046782065f, -0.0046921455f } } }, { { { 0.23047932f, 0.23043226f, 0.23041471f, 0.22922185f }, { 0.14990977f, 0.15703656f, 0.15110771f, 0.15149153f }, { 0.30629171f, 0.30426701f, 0.30400037f, 0.30403889f }, { 0.03476576f, 0.036188528f, 0.036216719f, 0.037322097f }, { 0.31066251f, 0.31090363f, 0.31041565f, 0.31057779f }, { 0.04875259f, 0.046468595f, 0.046486323f, 0.046584523f }, { 0.31745458f, 0.31874472f, 0.32086369f, 0.31880207f }, { 0.64054942f, 0.64062862f, 0.64051973f, 0.64059059f }, { 0.27309038f, 0.27480819f, 0.27477284f, 0.27486762f }, { 0.196647f, 0.19687982f, 0.19607604f, 0.1957915f }, { 0.32867362f, 0.32858008f, 0.32856702f, 0.328555f }, { -0.0026873031f, -0.0042393446f, -0.0057894907f, -0.0041858859f }, { 0.40254624f, 0.4024247f, 0.4025598f, 0.40243731f }, { 0.019362807f, 0.018146218f, 0.018146051f, 0.019656613f }, { 0.29328089f, 0.29403937f, 0.29435036f, 0.29403094f }, { 0.57111506f, 0.57118505f, 0.57099608f, 0.57099266f }, { 0.16966612f, 0.16993739f, 0.17069399f, 0.16991136f }, { 0.14989055f, 0.1489484f, 0.14995985f, 0.15015916f }, { 0.33606014f, 0.33606294f, 0.33606393f, 0.33605429f }, { 0.015421206f, 0.015180692f, 0.01518037f, 0.015431139f }, { 0.33165237f, 0.33185282f, 0.33162592f, 0.33166981f }, { 0.078137018f, 0.078153855f, 0.078165152f, 0.078332343f }, { 0.002896946f, 0.0026038621f, 0.0026029604f, 0.0022081151f }, { 0.41064398f, 0.40987685f, 0.41065341f, 0.41059166f } }, { { -0.0024316111f, -0.0024732789f, -0.0024922144f, -0.0035874346f }, { 0.0013306961f, 0.004171802f, 0.0027660627f, 0.0023671465f }, { 0.0034411091f, 0.0020878413f, 0.0020874456f, 0.0022028237f }, { -0.0032873976f, -0.0021351911f, -0.0021071363f, -0.0028424534f }, { 0.0017995208f, 0.0022319618f, 0.0039270256f, 0.0021249365f }, { -0.0019590835f, -0.0012526895f, -0.0012347747f, -0.0021069943f }, { 0.0012319531f, 0.002255621f, 0.0030193583f, 0.0020970822f }, { 0.0015144077f, 0.0015110104f, 0.0014803089f, 0.0015340007f }, { -0.0036679996f, -0.0028160114f, -0.0028586497f, -0.0027953731f }, { -0.005445786f, -0.0052624873f, -0.0054843188f, -0.0053271749f }, { 0.00067154572f, 0.0007530775f, 0.00067974516f, 0.00074462315f }, { -0.0035626119f, -0.0034186877f, -0.0038720517f, -0.0040088745f }, { 0.003455851f, 0.0035040061f, 0.0034671486f, 0.0035069881f }, { -0.0047789747f, -0.0047994804f, -0.0047996451f, -0.0044008337f }, { 0.0032403482f, 0.0033627856f, 0.003429619f, 0.0031153117f }, { -0.005027022f, -0.0049812f, -0.0049604573f, -0.0050556194f }, { -0.0020728991f, -0.0014784158f, -0.001216894f, -0.0019213729f }, { -0.00013808007f, -0.00067270623f, -0.00024001574f, -0.00030691077f }, { 0.0004367104f, 0.00043390709f, 0.00043548166f, 0.00043425516f }, { -0.00082746467f, -0.00088151411f, -0.00088152334f, -0.0008043643f }, { 0.0030277712f, 0.003133577f, 0.0028529862f, 0.0030362271f }, { -0.0058721937f, -0.0059816331f, -0.0059799345f, -0.0058882832f }, { -0.0057032562f, -0.0057401855f, -0.0057416619f, -0.0062417688f }, { -0.0014357888f, -0.0020782049f, -0.0014346823f, -0.0014513767f } }, { { -0.0027051235f, -0.0027087245f, -0.0027052303f, -0.0033594951f }, { 0.0028036195f, 0.0030416572f, 0.0014306948f, 0.0017897371f }, { 0.0031113166f, 0.0026432303f, 0.0025937824f, 0.0025394463f }, { -0.0036032904f, -0.003447065f, -0.0034344406f, -0.0024163572f }, { 0.0023912799f, 0.0025281229f, 0.0038665087f, 0.0024214034f }, { -0.0023543827f, -0.0024294943f, -0.0024539784f, -0.0027742617f }, { 0.0020903896f, 0.0026617586f, 0.003395249f, 0.0026261065f }, { 0.0019031008f, 0.0019405475f, 0.0019426085f, 0.0019404325f }, { -0.0040413326f, -0.0030964835f, -0.0031020735f, -0.0030826754f }, { -0.0064568993f, -0.0062342438f, -0.0064704698f, -0.0065636744f }, { 0.0010788406f, 0.0010092051f, 0.0010264121f, 0.00099891228f }, { -0.0040759201f, -0.0059224283f, -0.0066809927f, -0.0049099348f }, { 0.0042962009f, 0.0041909175f, 0.0043195236f, 0.0041900138f }, { -0.0062728983f, -0.0070256154f, -0.007025641f, -0.0061758746f }, { 0.0036210401f, 0.0039723998f, 0.0042232048f, 0.0042757707f }, { -0.0058693852f, -0.0058583303f, -0.0058544016f, -0.005887725f }, { -0.0023099876f, -0.0021136245f, -0.0017298078f, -0.0022483337f }, { -0.00017851962f, -0.00014956209f, 8.5676316e-05f, -0.00024971669f }, { 0.0003734781f, 0.00037078986f, 0.00037364181f, 0.00037070594f }, { -0.00030648905f, -0.00038230535f, -0.00038223043f, -0.00028623253f }, { 0.0032871423f, 0.0034163052f, 0.0028276655f, 0.0032991918f }, { -0.0061331695f, -0.0063319797f, -0.0063340119f, -0.0064390374f }, { -0.0062172888f, -0.0059787106f, -0.0059793294f, -0.0060406701f }, { -0.0018276142f, -0.0022170788f, -0.0018293949f, -0.0018222824f } } } }, { { { { 0.13218089f, -0.11654637f, -0.11622196f, -0.044208736f }, { 0.0074579257f, 0.0038503609f, 0.0013201096f, 4.0415784e-05f }, { -0.025474487f, -0.01209255f, -0.016535858f, 0.012704547f }, { -0.0016894103f, -0.0081312144f, -0.0033264609f, 0.0011923269f }, { -0.068044876f, 0.018276873f, -0.074833897f, 0.01308348f }, { 0.02665691f, 0.013515118f, 0.026440814f, -0.0077037816f }, { 0.0023286096f, -0.0025782652f, 0.0021644694f, -0.0042955294f }, { 0.051356261f, -0.031058382f, -0.085382962f, -0.033103269f }, { -0.081609229f, 0.0035270199f, -0.015722417f, 0.048773789f }, { 0.0023928418f, -0.001243811f, 0.011910492f, -0.011621478f }, { -0.028953904f, -0.029335777f, -0.0057891432f, 0.013874136f }, { -0.012473582f, 0.001772629f, -0.013983442f, 0.014846792f }, { -0.016111661f, 0.0018902323f, 0.025910586f, 0.042848276f }, { 0.026200626f, 0.024007879f, 0.0017667146f, -0.016394032f }, { -0.0067006429f, -0.0017968936f, 0.009028659f, 0.0044060413f }, { 0.019280611f, 0.0449581f, -0.042852227f, -0.066012332f }, { -0.014451123f, -0.047772741f, -0.047475406f, 0.098434178f }, { -0.0028954635f, 0.010521833f, -0.015741597f, -0.00091666191f }, { 0.0020291956f, -0.057966746f, -0.04525094f, 0.032711614f }, { 0.020563445f, -0.0078684621f, -0.015282237f, -0.0019830466f }, { -0.019504171f, 0.071338511f, 0.0033729474f, -0.0095772339f }, { 0.013056103f, 0.018719519f, 0.0096002937f, -0.028774366f }, { -0.00038728577f, -0.0010662982f, -0.0014333502f, 0.00059135695f }, { 0.073844752f, -0.05666013f, -0.1007151f, -0.030440738f } }, { { 0.00017766639f, -9.2398532e-05f, -3.9442682e-05f, -3.9559848e-05f }, { -0.0043956477f, 0.00044042277f, -0.00047491077f, 9.4171117e-05f }, { -0.0042095545f, -0.00910753f, -0.0014295282f, 0.0042595844f }, { 0.00070989004f, -0.0009623012f, 0.00084162653f, -0.00015925965f }, { -0.0017587638f, 0.0033199811f, -0.00025544613f, 0.00083644978f }, { 0.0051797987f, 0.0015691893f, -0.002324397f, 0.0050776381f }, { 0.003911779f, 0.00072639703f, 2.102924e-05f, -0.0029529332f }, { 0.0050240476f, -0.00041452319f, 3.1730448e-06f, -0.0072697591f }, { -1.5023048e-05f, 0.00032491246f, -9.2151952e-05f, 0.0035851726f }, { 0.0030984373f, 0.0016428856f, 0.0032974124f, -0.0036034289f }, { -0.00044578206f, -0.0035916409f, 0.0028146658f, 0.0068013321f }, { 0.00025716711f, -0.0024772152f, 0.0029660992f, -0.0008783244f }, { -0.005543602f, -0.00046453249f, 0.006815884f, 0.0069207512f }, { -0.0033541738f, -0.0015140333f, -0.004071746f, -0.0020908789f }, { 0.0027932918f, -0.0012517158f, -0.0033509184f, -0.001271572f }, { 0.0043481525f, -0.00088858735f, -0.0081538059f, 0.00027985077f }, { 7.4017523e-05f, -7.0080388e-05f, -7.1766386e-05f, 0.00020468758f }, { 0.00044507396f, 0.010179106f, -0.0048087449f, 0.0013487105f }, { 0.00082148695f, -0.00042640153f, -0.0024255173f, 0.0044486011f }, { -0.00026383509f, -0.0031871528f, -0.008203704f, -0.00053957093f }, { -0.0002996462f, 0.00070789605f, 7.9300612e-05f, -0.00024002209f }, { 0.0013722116f, 0.0049176054f, 0.0029283062f, -0.000849108f }, { 0.00026545039f, 0.0011783443f, 0.00072103548f, -0.0007355776f }, { 0.002192273f, -0.00294318f, 1.5452606e-05f, -0.0020953993f } }, { { 2.4074136e-05f, -2.4931598e-05f, -1.0893587e-05f, 1.080951e-05f }, { -0.0061635883f, -0.0042963493f, -0.00177783f, -0.00080292808f }, { 0.0047868795f, -0.0050472436f, 0.0082439123f, -0.0090979713f }, { 0.0017221077f, 0.0067285193f, 0.0031011872f, -0.0019932567f }, { 0.0010926271f, -0.0012170693f, 0.00012875612f, 0.00016441623f }, { -0.0048786273f, -0.0041225634f, -0.005591426f, 0.0043469593f }, { -0.0070664098f, -0.0012625813f, -0.00022220241f, -0.0026120468f }, { -0.0026689917f, 0.00030860545f, 1.9297947e-05f, 0.001274799f }, { 0.0026769559f, 0.00016106032f, 0.00013829246f, -0.0017239107f }, { -0.0042495789f, 0.0010270326f, -0.00078224804f, -0.0019210019f }, { 0.0072385804f, 0.0086418476f, 0.0061428272f, -0.0027142827f }, { 0.0019768127f, -0.00057957046f, 0.0047464783f, -0.004599565f }, { 0.0093618867f, -0.0010476542f, -0.0038681572f, -0.0065219521f }, { -0.0076406673f, -0.0036729355f, -0.0068804827f, 0.0077571478f }, { 0.0012706397f, -0.00042567505f, -0.002521821f, 6.0288127e-05f }, { -0.002041411f, 0.000430125f, 0.0073620925f, 0.0021579456f }, { 0.00012145466f, 4.1276616e-05f, 4.2449608e-05f, 9.8351262e-05f }, { 0.0014376278f, -0.007439719f, 0.0039006971f, 0.00051135138f }, { -7.1665367e-05f, 0.00023856335f, 0.00015274881f, -0.0096946274f }, { -0.00076804256f, 0.0040182915f, 0.012603411f, -0.00059669891f }, { -0.00010641981f, -0.00052355992f, 0.00057481361f, 0.00016456343f }, { -0.0027623375f, -0.0036761364f, -0.010480297f, 0.0066006902f }, { 0.00049081404f, 0.00077264749f, 0.0021355718f, -0.00029188425f }, { 0.00028566818f, 0.00097678458f, 0.00089022281f, -0.00013760767f } } }, { { { -0.0098123577f, 0.11017117f, 0.11245143f, -0.01173447f }, { 0.0036188505f, -0.0025878518f, -0.00043343726f, -0.0038813197f }, { 0.013109746f, -0.016775181f, -0.0011093308f, 0.00083465721f }, { -0.0042515898f, -0.0028159364f, 0.00027829209f, -0.002907578f }, { -0.0081027554f, -0.0019330574f, 0.061872524f, -0.037539524f }, { -0.012923735f, 0.021011524f, 0.002680406f, 0.0034369108f }, { 0.0027819214f, 0.0028657905f, -0.0034177203f, -0.0037322329f }, { -0.0036178174f, 0.065792163f, 0.13263475f, 0.0055427994f }, { 0.027832309f, -0.083372016f, -0.058757582f, 0.016164879f }, { -0.0082343898f, 0.011782416f, 0.011496052f, -0.0027847616f }, { 0.0012516658f, -0.014686832f, -0.025073035f, -0.020700577f }, { 0.0055718234f, -0.011543219f, -0.012867689f, -0.0049474286f }, { 0.028869265f, -0.035431559f, 0.024976635f, -0.01063055f }, { -0.0010657662f, 0.014977146f, 0.027109f, 0.01612865f }, { -0.0021697493f, 0.0044220507f, 0.0055654161f, -0.0032373397f }, { -0.018500666f, -0.01979267f, -0.0068480612f, 0.03908391f }, { 0.063306878f, 0.01934691f, 0.019254616f, -0.099824471f }, { 7.0580666e-05f, -0.0015082457f, -0.0056893693f, 0.00022726294f }, { 0.0077067654f, -0.014018834f, -0.021406454f, -0.0076589993f }, { -0.0013072394f, 2.6765854e-05f, 0.0028400803f, 0.0037431063f }, { -0.025369581f, -0.064039908f, -0.020594137f, -0.086807367f }, { -0.033639351f, 0.010434758f, 0.00082983507f, 0.013145885f }, { 0.00029373395f, 7.8193614e-05f, 0.00048496415f, 0.00062972215f }, { -0.0041597628f, 0.024283117f, -0.030148407f, 0.011456515f } }, { { -1.3484857e-05f, -3.7204145e-05f, -1.5660577e-05f, -2.4497955e-05f }, { -0.0068070249f, 0.0041035892f, 0.0034647689f, 0.0035918321f }, { -0.0053613309f, 0.0080593503f, 0.0028507084f, -0.0023104987f }, { 0.0048581064f, 0.0039720065f, -0.0019058129f, 0.0047295789f }, { -0.00030675956f, -0.0007787587f, -0.00025201217f, 0.00020777843f }, { -0.00026433336f, -0.0093672701f, -0.0053201627f, -0.0059632173f }, { -0.0063062815f, 0.0011995204f, 0.0001870407f, 0.0028197877f }, { -0.00053247524f, -0.00066138217f, -1.4959372e-05f, -0.00036023628f }, { 0.00027591427f, 0.00011309835f, 2.2453632e-05f, -0.00075736359f }, { 0.0015654886f, 0.0018114616f, -0.0004503446f, -8.5866048e-05f }, { 0.003501393f, 0.0037179893f, 0.008328543f, 0.013411108f }, { -0.0035136609f, -0.0015054003f, 0.0011903964f, 0.0022551358f }, { -0.0083723767f, 0.0061303554f, -0.008056962f, 0.0035035183f }, { -0.0023715655f, -0.0070468331f, -0.010219655f, -0.0057856465f }, { -0.0011406634f, -0.00021204595f, -0.001693195f, 0.0011051597f }, { 0.0011643412f, 0.00037557194f, 0.0048567739f, -0.00063996433f }, { -3.1728174e-05f, -2.9073903e-06f, -3.0243209e-06f, 2.579239e-05f }, { 0.00053152589f, 0.0029635352f, 0.0040743289f, -0.00051381046f }, { -0.0017253584f, 0.00012081524f, 0.00012243664f, -0.00063598215f }, { 0.0026711847f, -0.0020733972f, -0.0027860744f, 0.0017065643f }, { 5.7762902e-05f, 0.00092043577f, -0.0035278882f, 0.0007846087f }, { 0.0056127705f, -0.0051893669f, -0.0027072408f, -0.0025630045f }, { -0.00059289151f, -0.0004168408f, -8.8118696e-05f, -0.00073538101f }, { 0.0003388606f, -0.00094234652f, 3.013109e-05f, -0.0010532484f } }, { { -2.9013996e-05f, 6.1983083e-05f, 2.8401438e-05f, -3.4901557e-05f }, { 0.0045230474f, -0.0021369843f, -0.00422706f, -0.0018918027f }, { 0.00017586142f, 0.005389053f, 0.0071352982f, -0.0018278685f }, { -0.0012135723f, -0.0035970727f, 0.00078957165f, -0.0017065397f }, { -0.00067051937f, -1.9501585e-05f, 4.1968766e-05f, -0.0010958091f }, { -0.0015277626f, -0.0039952533f, -0.00049631478f, 0.0018042745f }, { 0.0039376754f, -0.00097834328f, 6.5894634e-06f, -0.0044189106f }, { -0.00067623039f, 0.0004690807f, 1.4532105e-07f, 0.0032984829f }, { 0.0020787449f, -0.0016586579f, -0.00062367064f, 0.0021545362f }, { 0.0016427801f, 2.6710288e-05f, 0.0016011535f, -0.00077649869f }, { 0.0039999622f, -0.0014968097f, -0.0025647576f, 0.0022783424f }, { 0.001558454f, -0.00083803058f, 0.0018955692f, 0.0010432376f }, { 0.010555722f, -0.010395022f, 0.0050354965f, -0.0016177699f }, { 0.00011370745f, -0.009328355f, -0.0063009522f, 0.0024377458f }, { -0.00024433189f, 0.00052920244f, -0.0013213352f, -0.0013503982f }, { -0.0057620093f, 0.00095391746f, -0.0034768563f, 0.00093990705f }, { 0.00012108024f, 4.1007202e-05f, 4.2193381e-05f, -0.00011043617f }, { 0.0038593696f, -0.00074282979f, -0.0093457897f, 0.00027311164f }, { 0.0021514797f, -7.8742315e-05f, -0.0018813077f, -0.0017625098f }, { 0.0038491118f, 0.00022570776f, -0.0061331041f, 0.00014956617f }, { -0.00014676603f, -0.00025053931f, 0.003376287f, -0.00014730695f }, { 0.0016439646f, 0.0060569792f, 0.00063058918f, -0.0034810156f }, { 0.00011722835f, 0.00032237223f, -0.0012556553f, -0.0006887808f }, { 0.00060814722f, 0.0003708376f, -0.00056515636f, -0.00016801817f } } }, { { { 0.99117704f, 0.98705585f, 0.98683693f, 0.9989534f }, { 0.99996564f, 0.99998924f, 0.99999903f, 0.99999247f }, { 0.99958951f, 0.99978616f, 0.99986266f, 0.99991895f }, { 0.99998953f, 0.99996298f, 0.99999443f, 0.99999506f }, { 0.99764936f, 0.9998311f, 0.99527468f, 0.99920949f }, { 0.9995611f, 0.99968788f, 0.99964679f, 0.99996442f }, { 0.99999342f, 0.99999257f, 0.99999182f, 0.99998381f }, { 0.99867384f, 0.99734987f, 0.98748052f, 0.99943657f }, { 0.99627571f, 0.99651225f, 0.99814846f, 0.99867903f }, { 0.99996323f, 0.99992981f, 0.99986298f, 0.99992859f }, { 0.99957996f, 0.99946171f, 0.99966886f, 0.99968945f }, { 0.99990668f, 0.9999318f, 0.99981943f, 0.99987754f }, { 0.99945334f, 0.99937032f, 0.99935219f, 0.99902503f }, { 0.99965614f, 0.99959957f, 0.99963092f, 0.99973552f }, { 0.9999752f, 0.99998861f, 0.99994375f, 0.99998505f }, { 0.99964293f, 0.99879278f, 0.99905795f, 0.99705307f }, { 0.99788947f, 0.99867085f, 0.99868681f, 0.99012413f }, { 0.99999581f, 0.99994351f, 0.99985991f, 0.99999955f }, { 0.99996824f, 0.99822008f, 0.99874627f, 0.99943549f }, { 0.9997877f, 0.99996904f, 0.99987919f, 0.99999103f }, { 0.99948785f, 0.99539425f, 0.99978223f, 0.99617908f }, { 0.99934875f, 0.99977032f, 0.99995357f, 0.99949949f }, { 0.99999988f, 0.99999943f, 0.99999886f, 0.99999963f }, { 0.99726107f, 0.99809817f, 0.99445842f, 0.99947091f } }, { { -2.3481737e-05f, -6.7307406e-06f, -2.8605869e-06f, -2.0372001e-06f }, { 6.6885689e-05f, 4.5630281e-06f, 3.5788218e-05f, 1.0842484e-05f }, { -4.9278613e-05f, -2.4660601e-05f, 3.1625301e-06f, 0.00019708279f }, { 1.2439158e-05f, 3.0347865e-05f, 8.6153947e-06f, 1.0887256e-05f }, { -0.00012454598f, -6.513709e-05f, -3.5853483e-06f, -3.4708286e-06f }, { -0.00013746339f, 0.00013516333f, 8.4535039e-05f, 5.693766e-05f }, { -2.3674091e-05f, -3.4690053e-06f, 5.3812265e-07f, -1.7613197e-05f }, { -0.00025790043f, 3.0475251e-05f, 2.1174795e-06f, -0.00023630753f }, { -8.8624748e-06f, 7.9175589e-06f, -2.4258477e-07f, -0.00017288313f }, { 4.0061469e-05f, 0.00069846663f, -0.00060299476f, -0.00015396968f }, { 5.0667108e-06f, 2.306363e-05f, 0.00028636884f, 3.6246633e-05f }, { 0.00032740524f, -0.00037985037f, -0.00014841039f, -0.00012676016f }, { 8.7000758e-05f, 0.00018530207f, 1.7669124e-05f, -0.00023199594f }, { 9.2332094e-05f, 0.00013487652f, 0.00034587506f, -3.8853378e-05f }, { 6.9809868e-05f, -0.00015411544f, 0.0013505166f, 1.4531796e-06f }, { -6.3782301e-05f, 4.8545135e-05f, -0.00027083794f, 4.5129465e-05f }, { 3.0912438e-06f, -3.2982361e-06f, -3.3551612e-06f, -1.7781589e-05f }, { 9.872609e-06f, -2.9944213e-05f, -4.5592652e-05f, 1.5950681e-05f }, { 1.4767773e-05f, -2.2486726e-05f, -0.00010613341f, -0.00015794394f }, { 2.4386215e-05f, -1.1610334e-05f, -4.4456294e-05f, -5.0215596e-06f }, { -4.2741558e-06f, 8.7714242e-06f, -6.6343322e-05f, 6.7010735e-05f }, { 0.00016489767f, -3.3636771e-05f, 5.1610504e-05f, 5.2803593e-06f }, { 1.1649256e-05f, 2.1169993e-05f, 1.9755999e-05f, 1.3389438e-05f }, { -0.00015815197f, -0.00014316145f, 2.6536218e-06f, -4.6846396e-05f } }, { { -3.5109783e-06f, -9.8530632e-06f, -4.5020804e-06f, 6.9233235e-08f }, { 9.9938991e-06f, -2.0914089e-06f, 3.5717699e-05f, 3.2813664e-06f }, { 0.00012938219f, 1.111062e-05f, 8.0858608e-05f, 0.00018147439f }, { 4.8657525e-06f, 8.6580257e-06f, 3.6742927e-06f, 3.5828406e-06f }, { 6.9905696e-05f, 2.0985073e-05f, 6.8866215e-06f, -4.2552499e-05f }, { 0.00012100208f, 9.7821801e-05f, 0.00013576456f, 6.3686234e-05f }, { 1.954525e-06f, -1.0727343e-06f, 5.2332444e-07f, -5.4034988e-06f }, { 0.00013699813f, -2.226833e-05f, 1.4994043e-06f, 1.7110377e-05f }, { 0.0001678261f, -0.00013844113f, -3.4281745e-05f, 5.3854072e-05f }, { -1.3018868e-05f, 0.00022176303f, 0.00016983401f, 0.00038109805f }, { 0.00019016068f, 0.00023448876f, 2.643329e-05f, 4.6842203e-05f }, { -1.2492528e-05f, -0.00059486605f, 0.00012427061f, 8.1876965e-05f }, { 8.400564e-05f, -0.00029859163f, -4.884214e-05f, 0.0002631806f }, { 0.00019907281f, 0.00014046808f, 0.00015482448f, 4.0461099e-05f }, { -0.00024349239f, 0.00081298441f, 0.00084294728f, 7.9617963e-05f }, { -6.0040835e-05f, 3.2352918e-07f, 0.00024295599f, 0.00011067283f }, { -6.0027092e-06f, 1.1975092e-06f, 1.2248893e-06f, -2.1293392e-05f }, { 1.4478736e-05f, 6.8326918e-05f, -7.8693614e-06f, 9.2888155e-06f }, { -1.6982828e-05f, 1.2094341e-05f, -3.1693808e-05f, 0.00028574477f }, { 3.4480942e-05f, 2.6556008e-05f, 0.00016193956f, -1.8966503e-06f }, { -5.7726961e-06f, 2.1091148e-05f, 5.8963955e-05f, -1.0834372e-05f }, { 0.0001214393f, 1.4174882e-05f, 0.0001371836f, 0.00021757165f }, { 1.0140226e-05f, 6.1641031e-06f, 1.0590727e-05f, 1.0893212e-05f }, { -1.7442656e-05f, 4.2353331e-05f, 7.4324714e-05f, -1.9484775e-06f } } }, { { { 3.7217719f, 3.6900797f, 3.6899881f, 3.6670816f }, { 0.067826319f, 0.16468028f, 0.083129199f, 0.1336756f }, { 0.66338737f, 0.23883566f, 0.093361469f, 0.10095622f }, { 0.27185537f, 0.20781392f, 0.32216624f, 0.29876595f }, { 2.0776462f, 2.0006156f, 2.0243138f, 2.080345f }, { 0.57695783f, 0.18015147f, -0.11440889f, 0.14229144f }, { 0.63833683f, 0.41431062f, 0.44752994f, 0.47594414f }, { 1.7890608f, 1.962584f, 1.9322155f, 1.6588331f }, { 3.0538128f, 3.108267f, 3.1001573f, 2.9593433f }, { -0.28383051f, -0.27708376f, -0.042513902f, -0.085181891f }, { 0.3873435f, 0.41697884f, 0.39625427f, 0.33250735f }, { -0.33498881f, -0.40206929f, -0.028905862f, -0.48179632f }, { 1.1875033f, 1.3535177f, 1.2526197f, 1.3337495f }, { 0.42579488f, 0.24951727f, 0.18976118f, 0.20605317f }, { -0.53212666f, -0.3861028f, -0.75685995f, -0.23411882f }, { 1.6910165f, 1.686815f, 1.5906473f, 1.6528217f }, { 4.0570657f, 4.0349492f, 4.0350332f, 4.0498099f }, { -0.017225465f, -0.032503897f, 0.46003211f, 0.21602109f }, { 1.1196901f, 1.00885f, 0.91675568f, 0.99635794f }, { -0.093891275f, 0.0809352f, -0.13783332f, 0.27130678f }, { 1.9925136f, 1.9829394f, 1.8820721f, 1.9542026f }, { 0.84563763f, 0.48476746f, 0.37907152f, 0.70267878f }, { 0.37054708f, 0.4228574f, 0.6329822f, 0.26197064f }, { 1.9618393f, 1.8405969f, 1.9440918f, 1.901629f } }, { { -5.6047186e-06f, 6.0454847e-06f, 2.8365975e-06f, 6.0894367e-06f }, { -0.00069876506f, -0.00029642785f, -0.00059516082f, -0.00025400441f }, { -0.00020850504f, -0.00012959593f, -0.00032902532f, -0.00058117893f }, { -0.00037901964f, -0.00038062016f, -0.00023777964f, -0.00033714679f }, { -5.9894351e-05f, -9.820791e-05f, -5.9867157e-06f, -6.258549e-06f }, { -0.00035424038f, -8.7146215e-05f, 3.0398362e-05f, -0.00061406521f }, { 0.00014971442f, 4.5936211e-05f, -5.6259869e-06f, 0.00013567035f }, { -0.00016180211f, 3.1840487e-06f, 3.8979157e-07f, -0.00017131994f }, { -1.9877193e-05f, 2.5768261e-05f, 9.0577543e-06f, -0.00013927462f }, { -0.0012323564f, -0.00042892846f, 7.2082106e-05f, 0.00010999853f }, { -0.00034618449f, -0.00017058897f, -0.00016535057f, -0.00096982024f }, { -0.00028039653f, -7.155747e-05f, -0.00075796707f, 0.00062756458f }, { 6.6596276e-05f, -7.9730809e-05f, -8.0686754e-05f, -2.9532397e-05f }, { -0.00084106867f, -0.00036762453f, 0.00012523548f, -0.00052789663f }, { 7.6718268e-05f, -0.0010042005f, -0.00042802983f, -0.0011951304f }, { -3.6972258e-05f, 2.1447505e-06f, -0.00035448623f, -1.0620008e-05f }, { 2.8326169e-05f, 2.2049468e-05f, 2.2640575e-05f, 1.7574827e-05f }, { -0.00014318496f, -0.0004811524f, -0.00049293303f, -0.00067646484f }, { -2.7469144e-05f, -5.9653763e-06f, -1.3998899e-05f, -0.00018475323f }, { -0.00017314302f, -0.00010954727f, -0.00040004932f, 3.31106e-05f }, { -3.6093435e-06f, -1.6125243e-05f, -4.9195648e-05f, 1.5586886e-05f }, { 0.0002059631f, -0.0004024722f, -0.00047984678f, -9.8485329e-05f }, { -0.00094100913f, -0.00073046048f, -0.00052500163f, -0.00068196784f }, { -2.2820197e-05f, -5.9454557e-05f, -6.2505468e-06f, -2.6569804e-05f } }, { { 2.6015883e-05f, 8.5398335e-06f, 3.8473185e-06f, 9.1409625e-06f }, { -0.00041459247f, -0.0001855224f, -0.00030529542f, -0.00016322166f }, { -8.8427847e-05f, -0.0002302048f, -0.00038072959f, -0.00076801295f }, { -0.00027717792f, -0.00028594346f, -0.00017910208f, -0.00027291164f }, { 2.8409311e-05f, -3.8005817e-05f, -4.2266878e-06f, -1.4520383e-05f }, { -0.0001088827f, -0.00021924377f, 3.9307406e-05f, -0.00032488556f }, { 0.00027997916f, 3.5103699e-05f, -5.7448764e-06f, 0.00010259251f }, { -4.7807894e-06f, -2.9470863e-05f, 2.6656233e-07f, -0.00014346393f }, { 0.00015527098f, -6.8528726e-05f, -1.1206714e-05f, 2.3422595e-05f }, { -0.0012763247f, -0.00051503472f, 0.00058055106f, -0.00068688488f }, { -6.1232076e-06f, -1.7073841e-05f, -0.00033533389f, -0.00078769935f }, { -0.00044113485f, -0.00027577451f, -0.0012008622f, 0.00013071136f }, { 1.834948e-05f, -0.00015615102f, -0.00016449385f, 3.6685217e-05f }, { -0.00063618257f, -0.00032641968f, -5.0281118e-05f, -0.00041378992f }, { -0.0010181884f, -0.0003871932f, -0.00050061147f, -0.0018967455f }, { -5.7650067e-05f, -5.1145774e-06f, -0.00017409773f, 1.9512036e-05f }, { 1.5838743e-05f, 2.503655e-05f, 2.5679098e-05f, 2.0053218e-05f }, { -0.00018055811f, -0.00044345237f, -7.9049557e-05f, -0.00095669161f }, { -4.98611e-05f, -1.1320605e-06f, 3.7756645e-06f, -8.7299215e-05f }, { -0.00011794063f, -0.00015778552f, -0.00036514881f, 4.7288704e-05f }, { -5.1753817e-06f, -1.5040527e-06f, -2.836739e-05f, -9.4945229e-06f }, { 0.00016873335f, -0.00031983601f, -0.00052281245f, 0.00019034815f }, { -0.0011988594f, -0.0010684975f, -0.00057577023f, -0.0009143845f }, { 5.0336006e-05f, -1.356148e-05f, 1.5582694e-05f, -2.0666272e-05f } } }, { { { 0.012207721f, 0.0044164612f, 0.0022704542f, 0.0042008503f }, { 0.29516302f, 0.139976f, 0.35038027f, 0.13748343f }, { 0.1462123f, 0.12114907f, 0.28473665f, 0.45762717f }, { 0.17976664f, 0.19141553f, 0.1209483f, 0.16393769f }, { 0.044254492f, 0.11383095f, 0.0062726904f, 0.023550537f }, { 0.14785458f, 0.10151341f, 0.045717467f, 0.42243971f }, { -0.24205201f, -0.033590842f, 0.0032064617f, -0.093924041f }, { 0.10866955f, 0.016299431f, 0.00081631108f, 0.15856447f }, { 0.10108337f, 0.057931152f, 0.024463589f, 0.21514346f }, { 0.47967783f, 0.75472932f, 0.5653649f, 0.64752457f }, { 0.30082544f, 0.15124922f, 0.23567284f, 0.47161499f }, { 0.54286166f, 0.61049777f, 0.61641378f, 0.51181399f }, { 0.39328762f, 0.25557559f, 0.25875912f, 0.22436901f }, { 0.45699569f, 0.16989563f, 0.2429263f, 0.3924359f }, { 0.92996797f, 1.1024806f, 0.78045387f, 1.2298879f }, { 0.19029829f, -0.022675055f, 0.28113642f, 0.034941166f }, { 0.013203939f, 0.013034069f, 0.013414649f, 0.011688038f }, { 0.076026927f, 0.13838472f, 0.29961655f, 0.31531564f }, { 0.089182386f, 0.010401684f, 0.029374547f, 0.22995838f }, { 0.052198894f, 0.039866726f, 0.11570972f, -0.013818992f }, { 0.0062380932f, 0.01788119f, -0.20765047f, 0.013339281f }, { 0.12436441f, 0.17318651f, 0.21554136f, 0.18600144f }, { 0.38005287f, 0.32135548f, 0.28632777f, 0.29211902f }, { 0.03798742f, 0.0450845f, 0.010912505f, 0.039060104f } }, { { 0.00077914246f, 0.00011130803f, 8.1110229e-05f, -0.00035312557f }, { 0.00051711901f, 0.00029701387f, 0.00040733345f, 0.00034149723f }, { 0.00063893978f, -0.00013702086f, 0.00030866699f, -0.00020070677f }, { 7.5899443e-05f, 9.7456273e-05f, -4.5352178e-05f, 7.6172703e-06f }, { 0.00066250814f, -0.00073033349f, 0.00015225542f, -0.0010197351f }, { 0.00040931533f, -0.00043022747f, 0.00093333285f, 0.0002579685f }, { -0.00067488578f, -0.0003706974f, -0.00044487256f, -0.00056555959f }, { 0.00075838366f, -0.0021903789f, -0.0026744174f, -0.00047135202f }, { -0.00081050821f, -0.0010297809f, -0.00099480849f, -0.00074914246f }, { 0.00063637392f, 5.248783e-05f, 0.00044645091f, 0.00018028446f }, { 0.00067430392f, 0.0004762628f, -0.00032736685f, 0.00041933609f }, { 6.2324555e-05f, -1.6709531e-06f, 0.00057418116f, -0.0010360999f }, { -0.00038256183f, -0.0010104012f, -0.00045533693f, -1.3888404e-05f }, { 0.00068274628f, 0.00068411875f, -0.00091273333f, 0.00016211145f }, { -0.00039440715f, 0.00027665323f, -0.00035895503f, 0.00013423207f }, { -0.00061939017f, 0.00012140102f, 0.00024178233f, 0.00064755788f }, { -0.00052441128f, -0.00050994483f, -0.00051126044f, 0.00066320373f }, { 0.00085915332f, 0.0013567332f, -0.00014328466f, 0.00056098523f }, { -0.0012682676f, 0.0029139719f, 0.0019812291f, -0.00053863027f }, { 0.0021895869f, 0.00062956835f, 0.0018161156f, 0.00011699452f }, { -0.0010337306f, 0.00016880497f, -0.0014942346f, -0.0034402453f }, { -0.0025336946f, -0.00019468865f, -0.00018045349f, -5.4312149e-05f }, { 0.00021491979f, 4.7651714e-05f, -0.00044921151f, 0.00046742044f }, { 0.0019408125f, 0.00044842687f, 0.0026003265f, -0.00090116109f } }, { { -0.0006591255f, 0.00022873584f, 0.00026313866f, -0.00060151354f }, { 0.00027198127f, 0.00034252944f, 0.00033246896f, 0.00035232159f }, { -0.00034460639f, -5.9085725e-05f, 7.836454e-05f, -0.00018946388f }, { 0.00018790551f, 0.0001918358f, 9.7031467e-05f, 0.00015259869f }, { -0.0023033429f, -0.0012945186f, -0.00080964072f, -0.00030432514f }, { -0.001359781f, 0.00055828912f, -0.00041912301f, 0.00019263336f }, { -0.00042789448f, -0.00018313775f, -0.00030217124f, -0.00028437496f }, { -0.0018340159f, 0.00030654336f, -0.00010781402f, -0.0011985455f }, { -0.002103478f, 0.00029492518f, -0.00042283946f, -0.001472689f }, { 0.00064558079f, 0.00049703204f, -0.00018932594f, -0.00038268301f }, { -0.00097813334f, -0.00057838807f, 0.00079268109f, 0.00039650774f }, { -0.00017335252f, 0.00074363734f, 0.0008194423f, -0.00065923207f }, { -0.00075344545f, -0.00026114262f, -0.00054658657f, -0.0013814943f }, { -0.00028279346f, 0.00055730283f, 0.00048990213f, -0.00022186466f }, { 0.00013438509f, -0.0001962818f, -0.00036195953f, 0.00042669461f }, { -0.00089003585f, -0.0011600794f, -0.0012554286f, -0.0012892408f }, { -0.00067007058f, -0.0010597247f, -0.0010590421f, 0.00044132516f }, { 0.0011626727f, 0.001261033f, -0.00072912018f, 0.00076332442f }, { -0.001204702f, -0.00011230019f, 0.00036178615f, -0.0017559004f }, { 0.00096282849f, 0.001025959f, 0.0011696947f, 0.00046633555f }, { -0.00082328571f, -0.00075771669f, -0.0011629302f, 0.00073458863f }, { -0.0016869269f, -0.00035239862f, -0.0004024204f, -0.0016276971f }, { 0.00029053123f, 0.00013409355f, -0.00049087974f, 0.00061969429f }, { -0.0013198997f, -0.0018615784f, -0.0025724061f, -0.0015563017f } } } }, { { { { -0.072246889f, -0.043157285f, 0.043289306f, 0.095998047f }, { 0.12597079f, 0.24289541f, -0.10930005f, -0.24150539f }, { 0.031889347f, -0.036238337f, -0.014521983f, -0.018963885f }, { -0.044155351f, -0.0077170425f, -0.043781059f, 0.047982339f }, { 0.093995001f, -0.0079510758f, -0.04688882f, -0.11125523f }, { 0.01700754f, -0.0034361033f, 0.055252382f, -0.053119426f }, { -0.0014957087f, -0.00063057103f, 0.037930463f, 0.017656646f }, { -0.017388477f, -0.084085888f, -0.067726647f, 0.061397079f }, { -0.070625168f, -0.061293011f, -0.077366932f, 0.11518646f }, { -0.14771316f, -0.12543895f, 0.052150789f, 0.10530462f }, { -0.03609139f, 0.001131616f, -0.039549928f, 0.03805765f }, { 0.064364205f, 0.066758929f, 0.045537002f, -0.05510954f }, { 0.049051369f, 0.098312455f, -0.01079726f, -0.11202623f }, { 0.033012208f, -0.0013996988f, -0.0049458824f, -0.028981527f }, { 0.008617177f, -0.00017670863f, -0.0052380282f, -0.0023438457f }, { -0.05901498f, -0.050754807f, -0.00011829844f, 0.037297411f }, { -0.056264446f, -0.03645315f, -0.066412698f, 0.019549244f }, { -0.11401603f, -0.11856524f, 0.12275022f, 0.11635143f }, { -0.0011999881f, -0.0016334327f, -0.0056868938f, 0.013393766f }, { 0.054526972f, 0.033632235f, 0.062591094f, -0.0025531074f }, { 0.073041316f, 0.073735243f, -0.06935254f, -0.11214186f }, { 0.034872822f, -0.015473423f, 0.037359975f, -0.026829465f }, { -0.015137592f, -0.0064462553f, 0.011771178f, 0.0025042048f }, { -0.038708904f, -0.033968131f, -0.044070885f, 0.024422773f } }, { { -0.047895007f, -0.016535938f, 0.04855533f, 0.018341613f }, { 0.004310087f, 0.01519838f, -0.0033290683f, -0.013597406f }, { 0.0015859181f, 0.016869623f, -0.019279963f, -0.01426933f }, { -0.0061048976f, 0.031131561f, 0.018085381f, -0.017927117f }, { 0.052590378f, 0.0066156852f, -0.0025756141f, -0.037241705f }, { 0.0083512619f, 0.0046235666f, 0.024122126f, -0.013443654f }, { 0.0010672274f, 0.00053123301f, -0.0016276029f, -0.04221993f }, { -0.0048754166f, -0.021474788f, -0.0039993317f, 0.011831691f }, { -0.054685347f, -0.050242732f, -0.007606251f, 0.043061893f }, { -7.5644942e-05f, 0.00086632318f, 0.0001960729f, 0.0013264286f }, { 0.0042413724f, -0.0057181522f, 0.0065940983f, -0.0078263328f }, { 0.0031260881f, -0.0013520907f, 0.025073658f, -0.010841673f }, { 0.038353769f, 0.06620308f, -0.0072105562f, -0.079188681f }, { 0.003099559f, -0.0022927921f, 0.021982683f, -0.018991144f }, { 0.012285675f, 0.0091834074f, -0.0041874571f, -0.032253924f }, { -0.014563556f, 0.009843969f, -0.010490279f, 0.012979866f }, { -0.005492286f, 0.064109426f, -0.034795617f, -0.020395732f }, { -0.023364141f, -0.059336321f, 0.080710391f, 0.038948527f }, { 0.0028384819f, 0.001822471f, 0.0012903958f, 0.012781079f }, { -0.004510518f, -0.0020008272f, 0.0017752876f, 0.0077607089f }, { 0.032279653f, 0.0041906079f, -0.034682371f, 0.0061335907f }, { -0.0082992317f, -0.025250117f, -0.017026845f, -0.028345042f }, { -0.013132125f, -0.026688493f, -0.0014827793f, -0.003236826f }, { 0.01650781f, 0.002313574f, -0.012897922f, 0.026077933f } }, { { 0.062668058f, 0.0081578851f, 0.018952049f, -0.012267283f }, { 0.0008567722f, 0.0033246009f, -0.0037620102f, -0.0096317368f }, { -0.0083012273f, 0.01184624f, -0.01209373f, 0.020208536f }, { 0.013862003f, 0.019166381f, 0.013235471f, -0.026788736f }, { -0.021904217f, -0.051018749f, 0.0020330268f, 0.006626371f }, { -0.015856131f, 0.0028024655f, -0.032825412f, -0.018920906f }, { 0.0020870233f, 0.0011616727f, -0.0032704368f, -0.027327141f }, { 0.01934969f, 0.002427195f, 0.049925128f, -0.0061414889f }, { 0.013158375f, 0.022248445f, 0.040266734f, -0.017583455f }, { 1.9024812e-05f, 0.00071602053f, 0.0012622199f, 0.0018791611f }, { -0.0011857767f, 0.0023417924f, 0.026237548f, -0.014687892f }, { -0.041419782f, 0.024942194f, -0.029143101f, 0.036590943f }, { -0.015470651f, -0.035208671f, -0.038530514f, 0.037434376f }, { -0.0029356279f, 0.0023358079f, 0.017641055f, 0.0038203652f }, { -0.0030449623f, -0.010187444f, 0.0066142145f, 0.0037433206f }, { 0.0080034603f, 0.011463159f, -0.0058129532f, 0.011831147f }, { -0.0091743137f, 0.045949289f, 0.022412137f, -0.0067531419f }, { 0.00069946656f, -0.0068974782f, 0.0091806954f, 0.0022160793f }, { -0.0027530077f, 0.00089797627f, 0.0066153093f, -0.010355635f }, { -0.019399018f, -0.0085762573f, 0.0208003f, -0.027739023f }, { -0.014354809f, -0.011971089f, -0.0031124986f, 0.044710091f }, { -0.011411144f, 0.0073253411f, -0.0087561348f, -0.014838738f }, { 0.018837992f, 0.00231775f, -0.013982978f, -0.0020044658f }, { 0.0012069362f, 0.0012202952f, 0.029106153f, 0.00062793994f } } }, { { { 0.054154158f, -0.11603661f, -0.025631275f, 0.054671866f }, { -0.2359715f, 0.093194255f, 0.21874866f, -0.08378526f }, { 0.0089903397f, 0.0087113885f, -0.015445726f, 0.011142042f }, { -0.0055372249f, -0.0041494086f, -0.033355186f, -0.010136823f }, { -0.015010227f, -0.0077144008f, 0.13058394f, -0.016779666f }, { -0.015855009f, 0.014090685f, 0.026549575f, 0.025677527f }, { -0.00065423811f, -0.0011506403f, 0.028628751f, 0.0086359197f }, { -0.010571292f, 0.035861454f, -0.025871285f, -0.024827688f }, { 0.00010603924f, 0.011433504f, -0.052819957f, -0.020208661f }, { 0.12243361f, -0.14574398f, -0.10091072f, 0.054524772f }, { -0.014659734f, -0.02291001f, 0.010102434f, -0.0099333349f }, { -0.0079939087f, 0.023468399f, 0.044548395f, 0.04568814f }, { -0.048188816f, 0.016469102f, 0.084818672f, -0.040634065f }, { 0.015089138f, 0.025396216f, 0.017000121f, 0.010820807f }, { -0.0098155552f, -0.00080001495f, 0.0020122754f, -0.00046896909f }, { -0.0018906417f, -0.03909342f, -0.020339049f, -0.024007559f }, { -0.0012744487f, -0.027829333f, -0.05202457f, -0.024366779f }, { 0.10406956f, -0.092281421f, -0.050420166f, 0.10716663f }, { -0.0049603976f, -0.0055370076f, -0.0016910106f, 0.012172389f }, { -0.0026486448f, 0.038673757f, -0.0016176887f, 0.052692494f }, { -0.03722357f, 0.055455783f, 0.067738953f, -0.0087990582f }, { -0.0026491637f, 0.017275247f, 0.010687117f, 0.020312052f }, { -0.0016032469f, 0.0090272843f, -0.0079027514f, -0.0050039898f }, { -0.0073653412f, -0.033150577f, 0.0082912493f, -0.021457881f } }, { { -0.0059001999f, 0.033600833f, 0.066374213f, -0.018058548f }, { -0.0037864945f, -0.0064946131f, 0.0018627774f, 0.0044899139f }, { 0.0048961861f, -0.0034770968f, -0.0002311598f, -0.0053935761f }, { 0.0090090757f, 0.012149811f, 0.0029969663f, 0.0049403543f }, { -0.042874682f, -0.0083455851f, -0.0064437344f, 0.0010579362f }, { 0.011866873f, -0.017157526f, -0.014724976f, 0.0054373752f }, { -0.0006329516f, -0.00024834697f, 0.0015416168f, -0.014246989f }, { 0.031530357f, -0.052715858f, -0.0063186617f, -0.0070200141f }, { -0.0082273844f, 0.053856605f, 0.0096812384f, 0.01684635f }, { -0.00017150577f, 0.00097354737f, 0.0013944706f, 0.00085166684f }, { -0.013604545f, 0.0089329355f, -0.013809086f, 0.0025044469f }, { -0.020284731f, 0.0004724419f, -0.045697697f, -0.01844702f }, { 0.017874081f, -0.0040537465f, -0.023316716f, -0.026344708f }, { 0.0092557469f, -0.014456327f, -0.0092919835f, 0.0091758924f }, { 0.016058873f, 0.0019220807f, 0.0031692823f, 0.0024577167f }, { -0.021184352f, 0.021287579f, -0.0048442696f, 0.0095799112f }, { 0.035229915f, -0.054291919f, -0.013871324f, 0.035585241f }, { 0.001275203f, 0.011513119f, 0.020184769f, -0.0061701639f }, { 0.011353237f, 0.0052697685f, 0.0047637419f, -0.020278005f }, { 0.0068266296f, -0.01173749f, 0.037482577f, -0.0083236299f }, { 0.025699221f, -0.03651135f, -0.032342446f, -0.0059784486f }, { 0.0029540635f, -0.0021598269f, 0.0028168477f, 0.0044577193f }, { 0.0038274002f, -0.0050806333f, 0.007628551f, 0.0027461742f }, { 0.0056567464f, 0.006846664f, -0.031161558f, -0.0040832656f } }, { { 0.025668431f, 0.0093723617f, 7.4324163e-05f, -0.023051436f }, { -0.010148124f, 0.0018159908f, 0.0072269566f, 0.00082671261f }, { 0.0069741056f, 0.023493533f, 0.028507618f, -0.026874125f }, { 0.0083316277f, -0.024891629f, 0.013623217f, 0.0038373532f }, { -0.020992516f, 0.070912136f, -0.0014634877f, -0.015680371f }, { 0.02178962f, -0.003772636f, -0.024578501f, -0.047467019f }, { 0.0028586275f, 0.0033445767f, 0.0049576063f, -0.017365739f }, { 0.0075721122f, 0.010652219f, -0.024031886f, -0.0001146548f }, { 0.016381176f, -0.044765924f, -0.038036229f, -0.014041395f }, { -0.00082564842f, 0.00033107944f, 0.00073792054f, 0.0005712734f }, { 0.0080934887f, 0.014534447f, -0.0071347609f, 0.0085413493f }, { -0.018211778f, 0.0064443848f, 0.017393403f, 0.011490985f }, { -0.071531366f, 0.030059694f, 0.049103287f, 0.0074609412f }, { 0.00770209f, -0.017999995f, -0.040048679f, -0.0029073853f }, { 0.020442166f, 0.0019454488f, -0.019644905f, 0.021793285f }, { 0.035171271f, 0.0080192155f, -0.023151504f, 0.014168348f }, { -0.048901887f, -0.0039613606f, 0.0021703807f, 0.030275152f }, { 0.044666116f, -0.029756153f, -0.015570779f, 0.034470632f }, { -0.0078700362f, 0.0037551741f, 0.0003070052f, -0.0031237403f }, { 0.015288427f, -0.01284757f, -0.0075319169f, 0.026981487f }, { -0.0093872483f, 0.013517073f, -0.030221944f, 0.058356065f }, { 0.0042326205f, -0.016381154f, 0.021475001f, 0.01008732f }, { 0.0034929117f, 0.020531314f, -0.0085114063f, 0.004821913f }, { 0.014314413f, 0.01127037f, -0.017197896f, 0.0046932185f } } }, { { { 0.99591552f, 0.99230689f, 0.99873374f, 0.99387895f }, { 0.96356049f, 0.96556546f, 0.96964041f, 0.96677566f }, { 0.99945097f, 0.99930521f, 0.99977525f, 0.99975808f }, { 0.99900933f, 0.99996161f, 0.99848418f, 0.99879675f }, { 0.99545951f, 0.99993863f, 0.99032786f, 0.9936502f }, { 0.99972964f, 0.99989482f, 0.99811938f, 0.99825798f }, { 0.99999867f, 0.99999914f, 0.9988702f, 0.99980681f }, { 0.99979292f, 0.99581299f, 0.99736843f, 0.99780458f }, { 0.99750292f, 0.99805433f, 0.99560254f, 0.9931383f }, { 0.98142286f, 0.98133774f, 0.99352772f, 0.9929441f }, { 0.99924096f, 0.99973689f, 0.99916652f, 0.99922617f }, { 0.99789446f, 0.9974931f, 0.99796885f, 0.99743448f }, { 0.9976331f, 0.99501931f, 0.9963379f, 0.99287411f }, { 0.99934104f, 0.99967648f, 0.99984325f, 0.99952138f }, { 0.9999147f, 0.99999966f, 0.99998426f, 0.99999714f }, { 0.99825531f, 0.99794572f, 0.99979313f, 0.99901579f }, { 0.99841509f, 0.99894779f, 0.99643504f, 0.99951192f }, { 0.98801309f, 0.98864879f, 0.99115599f, 0.98740957f }, { 0.99998698f, 0.99998334f, 0.9999824f, 0.99983621f }, { 0.99850879f, 0.99868574f, 0.99803794f, 0.99860752f }, { 0.99663402f, 0.99573479f, 0.99528974f, 0.99365325f }, { 0.99938825f, 0.99973103f, 0.99924472f, 0.99943364f }, { 0.99988413f, 0.99993848f, 0.99989949f, 0.99998434f }, { 0.99922338f, 0.99887297f, 0.998994f, 0.9994714f } }, { { -0.0050599833f, 0.003362263f, 0.0035202243f, -0.00056864904f }, { -0.0014675187f, -0.0029154981f, -0.00077796172f, -0.0027392627f }, { -0.0010916411f, 0.00078232803f, 0.0014339533f, -0.0020166729f }, { 0.011183745f, 0.008298699f, 0.011631254f, 0.00030693508f }, { -0.0012964861f, -0.00028098882f, 0.00098513135f, -0.0052243577f }, { 0.0091119501f, 0.002780703f, 0.011045274f, 0.00334383f }, { 4.1103001e-05f, 5.5767744e-05f, 0.0030605577f, 0.0022152241f }, { 0.00085375099f, 0.0026952672f, 0.0071937971f, 0.0056504112f }, { -0.003773118f, 0.0047936307f, -4.5743022e-05f, -0.0038357994f }, { 2.3815581e-05f, 0.0002468657f, 0.00013492048f, -0.00018410816f }, { 0.0070959632f, -0.00205589f, 0.0056417297f, 0.0030702073f }, { 0.010671769f, 0.0074346008f, 0.0012867659f, 0.0075437523f }, { -0.0013037272f, -0.0058374269f, 0.0025899757f, -0.0071565118f }, { 0.0030041304f, 0.0018011397f, 0.0093160386f, 0.0082062863f }, { 0.0053156934f, 0.0036543193f, 0.0048724246f, 0.0035118324f }, { -0.0053866158f, 0.0024053442f, 0.00052459148f, 0.0090970513f }, { 0.011239324f, -0.0010327051f, -0.00097551594f, 0.0044180668f }, { -0.0024379533f, -0.0088232426f, -0.012355568f, -0.0031875953f }, { 0.0026244123f, 0.0011858999f, 0.0028110843f, -0.001005442f }, { 0.0059514328f, 0.0018892606f, 0.0050231625f, 0.0046700575f }, { 0.00050741664f, 0.0096547476f, -0.00079618251f, 0.0024532112f }, { 0.0058717468f, -0.0017457656f, 0.0080261577f, -0.00048009588f }, { 0.0025457914f, 0.0016788968f, 0.0013982313f, 0.00073909928f }, { 0.0075035778f, 0.011234409f, 0.0079271096f, 0.006672353f } }, { { 0.0095152396f, 0.0011785006f, -0.00081996856f, 0.0018904938f }, { -0.0025430397f, -0.0010236291f, -0.0020168276f, -0.0021827861f }, { 0.0036295778f, 0.005406882f, 0.0040788276f, -0.0057729163f }, { -0.00029952998f, 0.0024548208f, 0.0088548836f, 0.0019084209f }, { 0.0034184324f, -0.0088925589f, 0.00023040452f, 0.00017437939f }, { 0.0037804595f, 0.012156355f, 0.0041276361f, 0.012721488f }, { 7.4846461e-05f, 0.00010580108f, 0.013483417f, 0.0024239851f }, { 0.00026411032f, -0.00059353627f, 0.0093564271f, 0.0061507538f }, { 0.0016065383f, -0.0027764641f, 0.0013620195f, 0.0010062065f }, { 9.7127925e-05f, 0.00017275393f, 1.0814607e-05f, -0.00022627793f }, { 0.0048710612f, -0.00014794569f, 0.0082832436f, -0.00072595412f }, { -0.0027392579f, 0.0066783951f, 0.00087397132f, 0.001567366f }, { -0.003378151f, 0.0025916338f, -0.0025553201f, 0.0030152022f }, { 0.0096818399f, 0.0012695523f, 0.0072489949f, 0.016881099f }, { 0.0022796191f, 0.0051693266f, 0.0023373397f, -0.0041448561f }, { -0.0002074582f, 0.0035962454f, -0.0007460719f, 0.0025086317f }, { 0.0035784996f, 0.003162753f, 0.0022592918f, 0.00024595998f }, { -0.0051294944f, -0.0041428868f, -0.0027597f, -0.0039539398f }, { 0.0022410392f, 0.00031263884f, 0.0016376751f, -0.0022787113f }, { 0.0025647038f, 0.0074733037f, 0.0051722028f, 0.0024463612f }, { 0.0011787227f, 0.0071159753f, 0.0017217143f, 0.0062717989f }, { 0.0046836737f, 0.0038976423f, 0.00062832002f, 0.0027638154f }, { 0.0014142926f, 0.0024903802f, 0.0015757227f, 0.0011628587f }, { 0.0016928585f, 0.0043828548f, 0.001653268f, 0.011450696f } } }, { { { 2.8886078f, 2.8900127f, 2.7925705f, 2.7895874f }, { 4.5455217f, 4.5284714f, 4.7042338f, 4.6915273f }, { 0.96672505f, 0.99303664f, 0.98927606f, 1.0351588f }, { 1.2743756f, 1.2525364f, 0.99649566f, 0.94572778f }, { 2.6910679f, 2.6922168f, 2.8503404f, 2.8246076f }, { 1.256075f, 1.2325025f, 1.5911826f, 1.6091223f }, { 1.3601759f, 1.3606869f, 1.2793533f, 1.240925f }, { 2.0291828f, 2.0506809f, 1.7341658f, 1.6555689f }, { 2.6663531f, 2.6921882f, 3.1290975f, 3.11849f }, { 5.3676887f, 5.3663279f, 5.3848664f, 5.3852162f }, { 1.0586431f, 1.0865889f, 0.8196623f, 0.8076665f }, { 1.6967251f, 1.7305944f, 1.5450413f, 1.6347879f }, { 3.0908857f, 3.0706775f, 3.2974343f, 3.3053965f }, { 1.2172073f, 1.3839086f, 1.5086796f, 1.4295506f }, { 0.97676668f, 1.0856738f, 0.98747912f, 1.0385491f }, { 1.5662275f, 1.4603538f, 1.784278f, 1.6575438f }, { 2.1085757f, 2.2092885f, 2.1410448f, 2.1518347f }, { 4.0214776f, 4.006424f, 3.7686967f, 3.7771354f }, { 1.2089239f, 1.2116036f, 1.1244311f, 1.0901017f }, { 1.1827246f, 1.1472796f, 1.7516784f, 1.7833976f }, { 2.2113439f, 2.197512f, 2.2692963f, 2.2787751f }, { 0.98819531f, 1.057833f, 1.3587301f, 1.3890421f }, { 1.208957f, 1.2247867f, 1.2301205f, 1.2325178f }, { 1.0499613f, 1.1319197f, 1.4067885f, 1.3209087f } }, { { -0.002860931f, -0.0033581281f, -0.0047612075f, -0.0030481839f }, { -0.0017370907f, -0.0065700936f, -0.0011051926f, -0.0046915938f }, { -0.0006126207f, 0.0010791181f, -0.022876686f, -0.015937275f }, { -0.010040922f, -0.016433531f, -0.0044976975f, -0.029838315f }, { 0.00056888968f, -0.0093450028f, -0.00041549218f, -0.0069079656f }, { -0.029781683f, -0.019722587f, 0.019472312f, 0.0016798037f }, { -0.0015128736f, -0.0012250172f, -0.0091568262f, -0.0091368119f }, { 0.0010846814f, 0.0017189068f, 0.012975603f, -0.0051530971f }, { -0.026042808f, -0.0090684857f, -0.0021498742f, -0.0032938309f }, { -0.0012792901f, -0.0010431731f, -0.0021366737f, -0.0025526365f }, { -0.03218779f, -0.013848893f, -0.021872476f, -0.029443623f }, { 0.008300061f, 0.011951182f, -0.011139414f, 0.0098292843f }, { -0.0065854884f, -0.020955083f, -9.3843515e-05f, -0.0078425688f }, { -0.054726229f, -0.0073673428f, -0.019267231f, -0.03383648f }, { -0.049769726f, 0.0065482059f, -0.010189395f, -0.0050480393f }, { 0.022565943f, -0.020311569f, 0.0091512717f, -0.015600752f }, { -0.014418429f, 0.0060070592f, -0.0055296743f, -0.003361885f }, { 8.8146509e-05f, -0.0082609252f, 0.0036746024f, 0.0040108321f }, { 0.0010230427f, 4.8153189e-06f, 0.0052893378f, -0.0096303521f }, { 0.0032909351f, -0.010982824f, 0.003880027f, 0.0097699095f }, { -0.006528317f, -0.012608887f, -0.0057088008f, -0.003867806f }, { -0.046599771f, -0.024701737f, -0.001078321f, -0.0041018649f }, { -0.021680777f, -0.021120711f, 0.0055144734f, -0.0031337995f }, { -0.030559213f, 0.0089872726f, -0.011166202f, -0.0077587071f } }, { { -0.0059548858f, -0.0040070313f, -0.0062572119f, -0.0047711065f }, { -0.0031938803f, -0.005431389f, -0.0026376521f, -0.0046119366f }, { 0.0064917253f, 0.013030824f, -0.027850471f, -0.011824849f }, { -0.032644485f, -0.025045016f, -0.0034396539f, -0.039827623f }, { -0.007691681f, -0.014095643f, -0.0008171964f, -0.0051336386f }, { -0.035626586f, -0.021424668f, 0.00035790929f, 0.0099705685f }, { -0.0019006762f, -0.0014887089f, -0.0050782898f, -0.0096835564f }, { -0.00087496879f, 0.0052586834f, 0.017041675f, -0.00046753956f }, { -0.022489507f, -0.0084834888f, 0.0017184219f, -0.0023910992f }, { -0.0010618265f, -0.00085888729f, -0.0020035777f, -0.0024245283f }, { -0.029245834f, -0.038977066f, -0.013385246f, -0.030312138f }, { -0.0028497869f, 0.014205986f, -0.0125692f, 0.0037959624f }, { -0.0086377959f, -0.019175965f, -0.007684309f, -0.005037677f }, { -0.063945685f, -0.0060751259f, -0.0057457302f, -0.019079575f }, { -0.043745147f, 0.013651906f, -0.034067394f, 0.0012111497f }, { 0.0086647574f, -0.019171418f, 0.020745219f, -0.0055629951f }, { -0.024541273f, 0.0072112135f, -0.0078821942f, -0.0085072621f }, { -0.0018227939f, -0.0021153099f, 0.008577002f, 0.0043865151f }, { -0.013984752f, -0.012209334f, 0.00023638151f, -0.0085025952f }, { -0.0099800075f, -0.0095390578f, 0.0081328135f, 0.012673433f }, { -0.0099975551f, -0.0028467616f, -0.010712056f, -0.0045012212f }, { -0.011329139f, -0.0084709831f, -0.0070232966f, 0.0015504012f }, { -0.015334801f, -0.0075637633f, -0.01107439f, -0.0094188163f }, { -0.017505269f, -0.00013701888f, -0.033955823f, -0.034192649f } } }, { { { 0.16413327f, 0.084074422f, 0.10646123f, 0.18806073f }, { 0.039511019f, 0.058967072f, 0.035166958f, 0.052296507f }, { 0.26970995f, 0.21576211f, 0.2954278f, 0.29870678f }, { 0.40442043f, 0.38744132f, 0.14502571f, 0.24076804f }, { 0.22655046f, 0.20912486f, 0.015295019f, 0.16442957f }, { 0.69235319f, 0.6080183f, 0.36756076f, 0.23314717f }, { 0.085565328f, 0.075535626f, 0.22162979f, 0.33140596f }, { 0.16109547f, 0.11961895f, 0.26619212f, 0.25941009f }, { 0.27077686f, 0.23481238f, 0.063446408f, 0.11614487f }, { 0.026116057f, 0.027491327f, 0.030421883f, 0.039965345f }, { 0.33922592f, 0.38039792f, 0.27167385f, 0.31510976f }, { 0.32744968f, 0.22567102f, 0.23116584f, 0.18867836f }, { 0.29783431f, 0.28054079f, 0.26752139f, 0.23889932f }, { 0.61721263f, 0.60602797f, 0.51283622f, 0.47601102f }, { 0.51383952f, 0.53111455f, 0.44519064f, 0.42875877f }, { 0.3485879f, 0.35374178f, 0.53292055f, 0.53995494f }, { 0.4366997f, 0.35554257f, 0.14878367f, 0.22083288f }, { 0.12855375f, 0.16718264f, 0.17583661f, 0.11125895f }, { 0.35898096f, 0.37222307f, 0.35439108f, 0.35956111f }, { 0.16773044f, 0.25668894f, 0.23246756f, 0.1506316f }, { 0.36172813f, 0.26938211f, 0.20069185f, 0.1714591f }, { 0.3998571f, 0.23607244f, 0.34121623f, 0.29126696f }, { 0.31471307f, 0.29500525f, 0.39451396f, 0.40013999f }, { 0.29554399f, 0.28083636f, 0.47190649f, 0.47892938f } }, { { 0.01419653f, -0.061214452f, -0.032506906f, 0.0078227125f }, { -0.015799432f, 0.0136148f, -0.0090824684f, 0.013638505f }, { 0.023848919f, 0.022034707f, 0.022812846f, 0.022790329f }, { -0.0026324255f, -0.0053566952f, 0.00027470228f, 0.050203583f }, { 0.0035659857f, -0.02015272f, -0.039043616f, 0.054511651f }, { 0.0052075445f, 0.0051043119f, -0.011801097f, -0.0074336577f }, { 0.020735195f, 0.01811747f, 0.00808952f, 0.01140964f }, { -0.0073139049f, 0.011075347f, 0.0057685988f, 0.010251582f }, { 0.024813488f, -0.01629986f, -0.012536791f, -0.01110061f }, { -0.014508648f, -0.021444084f, -0.023836972f, -0.014258253f }, { 0.0079687141f, -0.00092011446f, 0.060249601f, 0.033199468f }, { -0.020822483f, -0.013924875f, -0.005068391f, -0.016928794f }, { -0.030059f, -0.013887475f, -0.045329289f, -0.04449219f }, { 0.007264541f, 0.0015213919f, -0.0066322618f, -0.0036449174f }, { 0.0057175046f, 0.0012159867f, -0.00054271896f, 0.0020625484f }, { 0.0027083179f, -0.0012554897f, -0.0044854592f, -0.0045242423f }, { -0.017906563f, -0.028301884f, -0.010139427f, 0.0035851304f }, { -0.020245794f, 0.01149232f, 0.011320484f, -0.013561794f }, { 0.0068048997f, 0.011957759f, 0.0046962412f, -0.0015476541f }, { -0.0022514613f, 0.019996868f, 0.0051520398f, -0.023405604f }, { 0.0055213198f, 0.0070384134f, 0.024405643f, -0.02050399f }, { 0.039987541f, 0.021127504f, -0.012323503f, -0.0041538161f }, { 0.0072321478f, 0.0053097351f, 0.0039966161f, 0.013617175f }, { 0.030470642f, 0.0044694115f, -0.0024591651f, -0.0027274707f } }, { { -0.040500402f, -0.039657034f, -0.017497359f, -0.017857145f }, { -0.0015646885f, -0.020957371f, -0.0057356498f, -0.0060587007f }, { 0.0070388709f, -0.013205178f, -0.00033412934f, 0.02192306f }, { -0.0042317723f, 0.020620857f, -0.012309167f, 0.065948811f }, { -0.016686589f, 0.013616667f, 0.030139062f, -0.019023551f }, { 0.015181564f, 0.008673659f, -0.0014559576f, -0.025916054f }, { 0.031630671f, 0.027030197f, -0.026982415f, 0.025214731f }, { -0.003845127f, -0.00062884599f, -0.029488655f, -0.0051457939f }, { -0.0032476351f, 0.0021153707f, -0.033110808f, -0.033629213f }, { -0.0064637077f, -0.010805748f, -0.014982403f, -0.0084641529f }, { 0.0087766042f, 0.017780238f, 0.026838871f, 0.032580257f }, { 0.0010700985f, -0.037414784f, -0.0053773565f, 0.0040969752f }, { -0.02637392f, -0.050236074f, -0.048422986f, -0.069357813f }, { -0.0089483588f, 0.0026259727f, 0.0040142797f, -0.010752754f }, { -0.0025658872f, 0.0071106029f, 0.015467367f, 0.0012536589f }, { -0.0037247444f, -0.0036991733f, -0.015429566f, -0.016148852f }, { -0.024788221f, -0.045938054f, -0.028679471f, 0.011593494f }, { -0.032699114f, -0.036800967f, -0.033870575f, -0.031842203f }, { 0.018156047f, 0.02457546f, 0.0209432f, 0.015057433f }, { 0.0043152638f, 0.025831372f, -0.019608349f, -0.026614397f }, { -0.0057047815f, -0.013831909f, 0.027613211f, -0.043616864f }, { 0.014124478f, -0.010786326f, 0.010775415f, -0.023241344f }, { 0.018337827f, 0.0048735321f, 0.018371717f, 0.022106807f }, { 0.013619207f, 0.022051384f, 0.0082720974f, -0.0030262071f } } } }, { { { { 0.083322661f, 0.079807165f, 0.03660117f, -0.051657142f }, { -0.099216074f, -0.0080141573f, 0.10637241f, 0.0367403f }, { 0.20813681f, -0.0001361621f, -0.20762563f, -0.085913357f }, { -0.22091149f, 0.10003156f, -0.16122219f, 0.31542901f }, { 0.16226908f, 0.02665194f, -0.012123307f, -0.16559939f }, { -0.14025496f, 0.025804505f, 0.076174345f, 0.20548591f }, { 0.0035713609f, -0.0092551928f, -0.099937652f, 0.0038879391f }, { 0.12405732f, -0.0053373497f, -0.030865175f, -0.060934551f }, { -0.0060175826f, -0.026583926f, -0.075326797f, -0.0063155886f }, { 0.036389362f, 0.054175433f, 0.06490927f, -0.038784258f }, { 0.30604876f, -0.030813476f, 0.011402956f, -0.21074796f }, { -0.31769497f, 0.046793931f, -0.038212559f, 0.21137297f }, { 0.12952945f, 0.20720126f, 0.08525845f, -0.14568109f }, { -0.09735197f, -0.17799099f, -0.12256082f, 0.038889119f }, { 0.002114572f, 0.026037779f, -0.0036772795f, 0.13478173f }, { 0.094577863f, 0.0057382415f, -0.087017736f, -0.059444148f }, { 0.054953104f, 0.071323301f, 0.097417831f, 8.3254475e-05f }, { -0.11005534f, 0.027214076f, 0.0059378205f, 0.02443999f }, { 0.27096654f, 0.1864966f, 0.034810947f, -0.25886676f }, { -0.35626794f, 0.037256657f, -0.17795321f, 0.52988269f }, { 0.14913899f, -0.0086988732f, -0.028760192f, -0.21779266f }, { -0.16010301f, -0.17699785f, 0.017269826f, 0.17878541f }, { -0.0049504093f, -0.02387924f, -0.04034852f, -0.060461173f }, { 0.10405347f, 0.0072745723f, -0.10244372f, -0.072981984f } }, { { 0.019363393f, 5.327311e-05f, 0.0075925373f, 0.0019542034f }, { -0.051707557f, 0.06554253f, 0.0050626046f, -0.0061857803f }, { 0.022891698f, 0.014872273f, -0.020436928f, 0.0069081531f }, { -0.044566611f, 0.019854557f, 0.023600607f, -0.0055387351f }, { 0.02283957f, -0.067086756f, 0.088865856f, -0.033915007f }, { 0.0020254431f, -0.16422426f, 0.032495902f, 0.012460808f }, { -0.017316175f, 0.023440087f, 0.011459595f, 0.0043887872f }, { 0.027714908f, -0.06907548f, 0.013578806f, -0.009848884f }, { 0.0044782488f, 0.0079432606f, 0.010143137f, 0.023589488f }, { 0.014325082f, 0.0075465848f, -0.0079373813f, -0.0056032635f }, { 0.025123579f, 0.01904807f, -0.0092328848f, -0.019002052f }, { -0.02633985f, -0.019560519f, -0.065544737f, 0.0073352606f }, { 0.044308433f, -0.0032233834f, 0.01324206f, -0.00047128106f }, { -0.076577611f, -0.021853603f, -0.020190543f, 0.0026420865f }, { -0.0029799448f, -0.0083566545f, 0.14896601f, 0.0078617095f }, { 0.021033237f, -0.08234711f, -0.020642328f, -0.0089829962f }, { 0.043793881f, 0.0096494147f, 0.035831274f, -0.01294602f }, { -0.014064874f, 0.066144489f, 0.0143429f, 0.015113964f }, { 0.043111732f, 0.0029232804f, -0.016912145f, 0.012142059f }, { 0.0014186333f, -0.0078590166f, 0.065781153f, -0.038375123f }, { 0.02255714f, -0.030191796f, -0.078373164f, -0.0017593196f }, { -0.033878798f, 0.016266579f, 0.013539653f, 0.043519216f }, { 0.019046482f, 0.0080403173f, -0.0010755939f, 0.03305222f }, { 0.023206448f, -0.054323067f, -0.035173093f, -0.010873592f } }, { { 0.014068291f, -0.026418786f, 0.016375695f, 0.0048801469f }, { 0.024404214f, 0.0073572002f, -0.027247654f, 0.00093849398f }, { 0.012741523f, -0.012913063f, 0.0054881373f, -0.021780769f }, { -0.020497215f, 0.057437717f, 0.0031122704f, 0.014713732f }, { 0.012765254f, -0.052846334f, 0.048042201f, 0.0016578534f }, { 0.031245254f, -0.0469321f, -0.057199738f, 0.012436479f }, { -0.0022837759f, 0.0068501747f, 0.010541107f, -0.0005227683f }, { -0.0187059f, 0.0025631581f, -0.0082184266f, 0.0026294483f }, { 0.0053899388f, -0.0199458f, 0.0023448066f, 0.016215236f }, { 0.021117204f, 0.010868775f, -0.016412681f, -0.016399297f }, { -0.0026199223f, -0.011436548f, 0.0031355049f, 0.011933919f }, { 0.017940023f, 0.090292392f, -0.061029038f, 0.016388845f }, { 0.0074493061f, -0.045849358f, -0.082612855f, 0.025851315f }, { 0.061276666f, -0.024654813f, 0.035447334f, -0.025952766f }, { -0.0068267167f, -0.02207426f, 0.003724368f, 0.0070458116f }, { 0.021714649f, -0.017552721f, -0.037105408f, 0.024398534f }, { 0.0092901891f, -0.021559075f, 0.009034776f, -0.016574279f }, { -0.017218595f, -0.041930302f, 0.003369899f, 0.017959363f }, { -0.0022510875f, 0.028106616f, -0.042936548f, -0.041948028f }, { -0.017145551f, -0.032331654f, 0.021486923f, -0.020295391f }, { -0.023196465f, -0.088353584f, 0.010086154f, 0.018689553f }, { -0.024508386f, -0.00058959302f, -0.02867958f, 0.019018994f }, { 0.0088748911f, 0.012528454f, -0.016636351f, 0.0078166115f }, { 0.00066772723f, 0.001693912f, 0.032066885f, 0.016951148f } } }, { { { 0.015200105f, 0.071414961f, -0.020616434f, 0.0063982643f }, { -0.084578144f, -0.12318522f, -0.035470756f, 0.057833574f }, { 0.19487946f, 0.44043059f, 0.10981527f, -0.31907303f }, { -0.17774238f, -0.30460726f, -0.53133003f, 0.31186606f }, { -0.1172677f, 0.3183613f, 0.10375266f, -0.066515168f }, { 0.054176263f, -0.12382077f, -0.033807438f, 0.039809238f }, { -5.3634009e-05f, 0.004084452f, 0.005103199f, -0.060697866f }, { 0.06093199f, 0.060355274f, 0.049176467f, -0.060579228f }, { 0.054611799f, 9.0520863e-05f, -0.048891261f, -0.047609349f }, { -0.036428706f, 0.06336736f, 0.0020843807f, 0.033254378f }, { 0.26975732f, 0.51328693f, 0.29976157f, 0.049031141f }, { -0.28383516f, -0.48219276f, -0.27898799f, -0.033028759f }, { -0.078976834f, 0.14077934f, 0.098587186f, 0.051336328f }, { 0.076281206f, -0.074223398f, -0.053178835f, -0.099578331f }, { -0.056377095f, -0.00066113896f, -0.11597726f, 0.058805777f }, { -0.0027130032f, 0.12007881f, 0.0081935835f, -0.10415807f }, { -0.019349408f, 0.06206561f, -0.0079099126f, 0.079363093f }, { -0.059959607f, -0.0591041f, -0.047505451f, -0.0031496967f }, { -0.11419194f, 0.20904287f, 0.53960104f, 0.10467592f }, { -0.21312862f, -0.34770872f, -0.54593093f, 0.23230512f }, { -0.073229448f, 0.12913f, 0.27728133f, -0.050627706f }, { 0.082312471f, -0.24529296f, -0.12381516f, 0.05577292f }, { 0.03015389f, -0.0015805638f, 0.024306632f, -0.080697961f }, { 0.061367564f, 0.056058289f, 0.041197211f, -0.015551356f } }, { { -0.029269776f, -0.030251548f, 0.01352869f, 0.0084860712f }, { 0.053983187f, 0.047657625f, -0.026379004f, 0.022474039f }, { 0.011898439f, 0.045120742f, -0.024430477f, -0.081318878f }, { -0.0012641508f, -0.018495044f, -0.030127865f, -0.0088483264f }, { 0.040728292f, 0.010691761f, -0.023566342f, 0.028045232f }, { 0.014593998f, 0.0047006468f, -0.049032498f, -0.011446808f }, { 0.00045433705f, -0.0030610749f, -0.010359449f, -0.0026455857f }, { -0.0026794352f, -0.032142744f, 0.010153936f, -0.0034586152f }, { 0.0097198782f, 0.0051005644f, 0.03482872f, -0.0043676475f }, { -0.0012381415f, -0.025746274f, -0.0081178021f, 0.0041481596f }, { -0.01598781f, 0.0048815642f, 0.06313106f, -0.0062291669f }, { 0.072970618f, -0.041153529f, -0.007457013f, 0.059776924f }, { 0.0024768493f, 0.0093018711f, 0.024827984f, 0.043842172f }, { -0.012927661f, -0.023256709f, -0.0035951539f, -0.069710027f }, { 0.0064149713f, 0.0019783425f, 0.010135188f, 0.019449636f }, { -0.0071551675f, 0.015761815f, 0.0086309278f, 0.038854386f }, { 0.020978109f, -0.0056696814f, 0.0025526797f, -0.017352926f }, { -0.010711116f, -0.0097050903f, 0.0022304504f, -0.0039308489f }, { 0.036904234f, 0.025927127f, 0.028330671f, 0.051193417f }, { -0.00076391153f, -0.077528792f, -0.029763477f, 0.0033945843f }, { -0.01775202f, 0.034507636f, 0.065392848f, -0.017840909f }, { -0.019567742f, -0.019880035f, 0.055214211f, -0.02206159f }, { 0.01110111f, 0.0022938832f, -0.011417507f, 0.017692635f }, { 0.050208493f, -0.028178909f, 0.0065276591f, -0.0056267473f } }, { { 0.0065622702f, -0.0012303136f, -0.0081183663f, 0.00079383048f }, { 0.030775912f, 0.052260356f, -0.019758331f, -0.020044147f }, { 0.019016537f, -0.043070451f, 0.035298744f, -0.040592775f }, { 0.010468089f, 0.00057085185f, 0.0081761984f, 0.0033382478f }, { 0.047189462f, -0.052695409f, 0.021849623f, 0.033585939f }, { 0.0012065616f, -0.050287476f, -0.065085924f, -0.039012886f }, { -0.012294892f, 0.006839242f, 0.0051165438f, -2.0711078e-05f }, { -0.03292822f, 0.015299577f, 0.0029119931f, 0.0073040242f }, { -0.0086784873f, 0.0085910164f, -0.0059378411f, -0.010259049f }, { -0.014191355f, -0.011172486f, -0.01299927f, 0.015386671f }, { 0.040453224f, -0.041489173f, 0.015047889f, 0.064340197f }, { -0.020000046f, 0.058477092f, -0.0018150465f, 0.048536972f }, { -0.006105982f, 0.03437044f, 0.0087640339f, 0.032868283f }, { -0.027120362f, 0.016579996f, -0.01708524f, 0.011178424f }, { 0.030535528f, 0.0058718219f, -0.031240404f, 0.024241052f }, { 0.003729958f, -0.055735848f, -0.0055392842f, 0.03447519f }, { -0.04084502f, -0.01227488f, 0.0062970198f, -0.021996031f }, { 0.053671675f, -0.067787009f, 0.0053426012f, -0.0080796738f }, { -0.021911856f, 0.038395527f, -0.07713235f, 0.024805484f }, { -0.0034319194f, 0.0052741327f, 0.026402991f, 0.0012916612f }, { -0.033119652f, -0.0046506889f, 0.045613946f, -0.050230593f }, { -0.0054612035f, -0.033482221f, 0.084267507f, -0.0224334f }, { -0.0063348693f, -0.0074524817f, -0.0029629355f, 0.035493958f }, { -0.0073519185f, 0.045139911f, 0.0022901735f, -0.041385515f } } }, { { { 0.99640669f, 0.99424882f, 0.99911727f, 0.99864438f }, { 0.99146493f, 0.99235134f, 0.99369348f, 0.99764995f }, { 0.95848895f, 0.89778665f, 0.9720248f, 0.943828f }, { 0.95896077f, 0.9472107f, 0.83168251f, 0.89623886f }, { 0.97975356f, 0.94759472f, 0.99452924f, 0.98394744f }, { 0.98863213f, 0.99196902f, 0.99652121f, 0.97785007f }, { 0.99999362f, 0.99994883f, 0.99498061f, 0.99814861f }, { 0.99040248f, 0.99816269f, 0.99831309f, 0.99630173f }, { 0.99848953f, 0.99964658f, 0.9959596f, 0.99884607f }, { 0.9986735f, 0.99651874f, 0.99788899f, 0.99869411f }, { 0.91299789f, 0.85766372f, 0.953946f, 0.97631002f }, { 0.90471405f, 0.87481454f, 0.959534f, 0.97684726f }, { 0.9884254f, 0.96811612f, 0.9914694f, 0.98799879f }, { 0.99232241f, 0.98122887f, 0.99103524f, 0.99426948f }, { 0.99840731f, 0.99966074f, 0.99324506f, 0.98912879f }, { 0.99551377f, 0.99274778f, 0.99617307f, 0.9927827f }, { 0.99830144f, 0.99552039f, 0.99521214f, 0.99684577f }, { 0.99211525f, 0.9978808f, 0.99885333f, 0.99969634f }, { 0.95579147f, 0.95995838f, 0.84120087f, 0.96022443f }, { 0.90975235f, 0.9368621f, 0.81871367f, 0.8156339f }, { 0.98610091f, 0.99158952f, 0.96035822f, 0.97468107f }, { 0.98366238f, 0.9531543f, 0.99215501f, 0.98230604f }, { 0.99953301f, 0.9997136f, 0.99888998f, 0.99490315f }, { 0.99267663f, 0.998401f, 0.99388534f, 0.99721201f } }, { { -0.0021537732f, 0.010607958f, -0.0066166595f, -0.0027390442f }, { -0.0069401807f, 0.0053215201f, 0.0062121114f, 0.013403291f }, { -0.0035740125f, -0.021839368f, 0.00042431197f, -0.029478899f }, { -0.007886159f, -0.0087705321f, -0.010570968f, 0.0040635318f }, { -0.0021772698f, 0.00025306776f, -0.0092725896f, -0.0075657706f }, { -0.010438319f, -0.0072866821f, 0.009272756f, 0.0043932916f }, { -0.00058203184f, 0.0081284104f, 0.027749999f, 0.0035426599f }, { -0.003604276f, -0.012244348f, 0.0072177908f, 0.0026686264f }, { 0.011192179f, 0.0069527119f, 0.017278396f, -0.0053058312f }, { -0.020276487f, -0.0063228657f, 0.013968347f, -0.0021534789f }, { -0.0037534313f, 0.00061399133f, -0.02126817f, 0.0085256452f }, { 0.015620795f, -0.022637876f, 0.00069280338f, 0.0054369037f }, { 0.0095244184f, -0.0026896982f, -0.0057963534f, 0.0067237437f }, { -0.0085689961f, -0.004816024f, -0.00088793436f, -0.0034021999f }, { 0.015428153f, 0.019777562f, -0.011217833f, 0.0095744159f }, { -0.003802304f, 0.0022643577f, 0.0054254827f, 0.025560756f }, { -0.0053298651f, 0.021621993f, -0.01864184f, 0.019120967f }, { 0.015380344f, -0.0027384467f, 0.0010235928f, 0.0062792725f }, { -0.001166873f, -0.0049586656f, -0.014850883f, 0.00057841904f }, { 0.0032865456f, -0.033386196f, 0.0032068954f, 0.02854738f }, { 0.010308266f, -0.000233004f, -0.020287643f, 0.0044441043f }, { -0.0040523345f, 0.0050367711f, 0.01627907f, -0.010032412f }, { 0.0073463987f, 0.00073274858f, 0.002814661f, 0.030221018f }, { 0.0057509063f, -0.011441338f, 0.01894259f, 0.0077856453f } }, { { -0.0053054924f, 0.0037677068f, 0.0066263851f, 0.0011220287f }, { -0.02212139f, 0.013769097f, -0.0013834097f, 0.014152363f }, { -0.0008493126f, 0.021473024f, -0.0039313241f, -0.017764981f }, { -0.00081897848f, -0.0074161164f, 0.0038179092f, -0.0035760615f }, { 0.014045643f, 0.015317904f, 0.0045966739f, 0.0075917156f }, { 0.0035574126f, -0.00017773424f, -0.0010937491f, -0.0017762282f }, { 0.0072018344f, 0.012586227f, 0.0138702f, -0.0085424173f }, { -0.0055783456f, -0.019909385f, 0.01190919f, -0.0065821489f }, { 1.7402026e-05f, 0.0094513341f, 0.015333305f, -0.0072158969f }, { -0.0063049905f, 0.0021776758f, 0.014376378f, 0.0072426401f }, { -0.0078049673f, 0.028764242f, -0.0024169449f, 0.0077604105f }, { 0.00047536469f, 0.029806623f, 0.0017798261f, 0.00087410198f }, { -0.0030498401f, 0.0044874501f, 0.0020382571f, -0.0011101062f }, { -0.0057084397f, -0.0013428994f, -0.001024136f, 0.0066188614f }, { 0.039201052f, 0.015120258f, -0.0082642793f, 0.0051985023f }, { -0.0091203243f, 0.020790215f, 0.0025270937f, 0.020092044f }, { -0.0029830063f, 0.006602841f, -0.00833601f, 0.044852353f }, { 0.025206353f, -0.0038915173f, 0.00045914851f, 0.0037840538f }, { 0.0014814254f, -0.011573911f, 0.046232337f, -0.015228958f }, { -0.0071984443f, 0.0090004063f, 0.022942838f, 0.016019787f }, { 0.0050929336f, 0.0060892107f, -0.0061771339f, 0.0047850766f }, { -0.011634853f, 0.0010276548f, 0.022396644f, -0.0021248711f }, { -0.012943002f, 0.0016430074f, 0.02034928f, 0.024289705f }, { 0.0051047037f, 0.010052556f, 0.0020923265f, -0.019043181f } } }, { { { 2.1627647f, 2.1788232f, 1.9290264f, 1.8457806f }, { 2.526488f, 2.3020441f, 2.538915f, 2.03484f }, { 3.9987521f, 4.3952121f, 3.906821f, 4.1693278f }, { 4.0400466f, 4.1069844f, 5.2512999f, 5.4283264f }, { 3.0141968f, 3.3306035f, 3.2224806f, 3.2473051f }, { 2.9840674f, 3.1294685f, 3.2964833f, 3.2929246f }, { 1.8346741f, 1.8637353f, 2.3037966f, 2.0860888f }, { 2.691236f, 2.6068079f, 1.9349032f, 2.1632935f }, { 1.9231956f, 1.7251627f, 2.1609654f, 2.1155629f }, { 2.165771f, 2.1908952f, 1.777038f, 2.0223741f }, { 4.5166991f, 4.8674508f, 3.918546f, 3.378087f }, { 4.4502295f, 4.5429338f, 3.9552598f, 3.3580272f }, { 3.0973598f, 3.3953852f, 2.2704362f, 2.6488177f }, { 3.2110537f, 3.3104376f, 2.515002f, 2.3267785f }, { 1.8303675f, 1.7094345f, 3.1787979f, 2.5960104f }, { 2.4391795f, 2.8730077f, 2.3730261f, 2.1545299f }, { 2.2130903f, 2.1899209f, 2.4997355f, 1.9058674f }, { 2.6472893f, 2.5455636f, 2.1164596f, 1.8341163f }, { 3.9428283f, 4.0433678f, 4.5430063f, 4.2482776f }, { 4.1941673f, 4.28852f, 4.64044f, 4.6644567f }, { 3.0873642f, 2.649364f, 3.6026133f, 3.2426354f }, { 3.2415154f, 3.5406745f, 3.2976852f, 3.3100246f }, { 1.8400289f, 1.8404692f, 1.889289f, 2.0125184f }, { 2.7063995f, 2.7229173f, 2.6289878f, 2.4313709f } }, { { -0.015335928f, -0.043382119f, -0.0054163805f, -0.028249934f }, { -0.017200109f, 0.0027582413f, -0.079612821f, -0.0013966663f }, { -0.027233584f, -0.018783395f, -0.01183278f, -0.020918937f }, { -0.0036358348f, -0.015712206f, -0.0089146421f, -0.0057117233f }, { 0.020392865f, 0.017743746f, -0.068597326f, -0.030425581f }, { -0.041123673f, -0.020767538f, -0.0087941887f, -0.0065248183f }, { -0.0055478408f, -0.00082196865f, 0.0088521402f, -0.045916836f }, { -0.010506485f, 0.0078523247f, -0.030002306f, -0.0015085765f }, { 0.01894068f, -0.012424968f, -0.034837214f, -0.045009941f }, { -0.045299587f, 0.02630478f, -0.017175711f, -0.043601235f }, { -0.046003661f, -0.020588165f, 0.034398873f, -0.054653787f }, { -0.0042534368f, 0.01325834f, -0.0036369576f, -0.079162988f }, { -0.028728556f, 0.0051289128f, 0.012104313f, 0.010686997f }, { -0.066337767f, 0.00059928728f, -0.080303668f, 0.011318772f }, { -0.031879871f, 0.0011317962f, -0.050259029f, 0.0031596552f }, { -0.090121238f, -0.011196084f, -0.072456123f, -0.00079731072f }, { -0.024243475f, 0.021401076f, -0.018209385f, -0.0083196072f }, { -0.079888701f, 0.0032806631f, -0.12762259f, -0.04652308f }, { 0.031806075f, -0.034165157f, -0.015255921f, -0.049164663f }, { -0.0012051123f, 0.030788487f, 0.022291919f, 0.0025694519f }, { 0.035836509f, 0.0055365388f, 0.026704836f, 0.0001547235f }, { -0.012129747f, -0.0094322145f, -0.040637935f, -0.12125388f }, { -0.027044986f, 0.04531553f, -0.033484589f, -0.0059927923f }, { 0.0067188802f, -0.051166351f, -0.048822794f, -0.025926988f } }, { { 0.022049053f, 0.021265778f, -0.040370641f, -0.036232952f }, { -0.0058098424f, -0.0042264198f, -0.077428509f, -0.04241654f }, { -0.0026825379f, -0.029453318f, -0.016181275f, -0.028320229f }, { -0.012541692f, -0.01345735f, 0.00037814888f, -0.0046052489f }, { -0.026527394f, 0.020033638f, -0.025683861f, -0.084207169f }, { -0.0010459945f, -0.036745215f, -0.039772051f, 0.024810839f }, { 0.012134618f, 0.0068515798f, -0.035286972f, 0.043129595f }, { -0.077093357f, -0.026872688f, 0.032800133f, -0.090326706f }, { 0.13930909f, 0.0081274014f, -0.08349188f, -0.012200005f }, { -0.091693797f, -0.012567011f, -0.069736822f, -0.0061444184f }, { -0.053061301f, 0.003642159f, 0.0052515175f, -0.036957472f }, { 0.0043493933f, -0.013069332f, -0.014708126f, -0.032765039f }, { -0.016116105f, -0.022907609f, -0.043503106f, -0.013266465f }, { -0.072759977f, -0.077354585f, 0.0043827591f, -0.013821612f }, { -0.032399073f, -0.045305037f, -0.021840791f, 0.073996542f }, { -0.057239255f, -0.056581235f, -0.038880927f, 0.044102943f }, { -0.026951489f, -0.088667645f, -0.013659704f, 0.033527579f }, { 0.034815442f, -0.028634059f, -0.036666529f, 0.011546036f }, { 0.026688447f, -0.0081892129f, -0.031138092f, -0.041739155f }, { 0.0015665701f, -0.012701682f, 0.0013533943f, -0.002849785f }, { 0.032994636f, 0.008802974f, 0.019032649f, 0.0039042621f }, { -0.044544917f, 0.0093201326f, -0.017968915f, 0.01936344f }, { -0.034794535f, 0.043032983f, -0.051072531f, -0.040148303f }, { -0.0030398597f, -0.027112065f, -0.064007483f, -0.01798277f } } }, { { { 0.22040906f, 0.24911942f, 0.41660708f, 0.23632869f }, { 0.25894466f, 0.1416669f, 0.41902981f, 0.35717608f }, { 0.26918091f, 0.14566759f, 0.2147652f, 0.15769391f }, { 0.22500921f, 0.12113361f, 0.11151768f, 0.12348609f }, { 0.25699055f, 0.056819107f, 0.3859882f, 0.4585378f }, { 0.7304995f, 0.20719358f, 0.44455636f, 0.42226989f }, { 0.43602897f, 0.51049581f, 0.41978824f, 0.62521039f }, { 0.42004119f, 0.52912054f, 0.33314238f, 0.38257921f }, { 0.55092562f, 0.43085653f, 0.31149977f, 0.34391138f }, { 0.40391149f, 0.48820255f, 0.13569806f, 0.36060266f }, { 0.13647907f, 0.12061002f, 0.20668806f, 0.30221394f }, { 0.15583476f, 0.13133696f, 0.22775202f, 0.35653823f }, { 0.56336195f, 0.25684627f, 0.11118383f, 0.23109245f }, { 0.45430401f, 0.42843367f, 0.25496534f, 0.097473509f }, { 0.3420223f, 0.39418925f, 0.26458947f, 0.30588082f }, { 0.51345558f, 0.3612731f, 0.41151773f, 0.25269512f }, { 0.29195176f, 0.42659964f, 0.47971993f, 0.32714756f }, { 0.49222777f, 0.28477645f, 0.74993827f, 0.43781271f }, { 0.098434481f, 0.31164923f, 0.14486345f, 0.11466693f }, { 0.070833248f, 0.20569754f, 0.10233576f, 0.047352701f }, { 0.51050902f, 0.15597643f, 0.1417112f, 0.35581415f }, { 0.48261165f, 0.14592221f, 0.62554576f, 0.5209765f }, { 0.33562628f, 0.39920067f, 0.28183433f, 0.297464f }, { 0.366851f, 0.59278666f, 0.59095922f, 0.48385165f } }, { { 0.13792051f, 0.072076744f, 0.094800532f, 0.026318377f }, { 0.13607414f, -0.061382542f, 0.061800151f, -0.020060553f }, { 0.028096406f, 0.069282616f, 0.010195109f, -0.010461141f }, { 0.018651237f, 0.02642439f, 0.0077552848f, -0.051151646f }, { 0.098299803f, -0.0085081153f, -0.011764584f, 0.087405711f }, { 0.064082346f, -0.04626424f, -0.071480607f, 0.064447268f }, { 0.022766233f, 0.0167542f, -0.021285286f, -0.071637286f }, { -0.0202445f, 0.011692601f, 0.048325551f, 0.0097755172f }, { -0.027775183f, 0.016463115f, 0.060050391f, -0.034226107f }, { 0.019412547f, 0.059977501f, -0.0041737169f, 0.031539317f }, { 0.013192979f, 0.036015595f, -0.049943198f, 0.014112312f }, { -0.013272349f, 0.035821037f, -0.060503687f, 0.095316821f }, { 0.038338785f, -0.059038809f, -0.044954172f, -0.00051347307f }, { -0.039594082f, 0.018205882f, 0.13413799f, 0.012292954f }, { 0.015177594f, -0.0082493854f, 0.00029420179f, 0.010356248f }, { 0.100271f, -0.13623174f, 0.1121235f, 0.068902399f }, { 0.025189636f, 0.0014918434f, 0.0088847718f, -0.053714493f }, { 0.06487698f, -0.097217547f, -0.069537353f, 0.032490984f }, { -0.030729608f, 0.048956315f, 0.016036034f, 0.022485239f }, { 0.049839618f, 0.01148525f, -0.021032427f, -0.019665817f }, { -0.0037762817f, -0.030422275f, -0.062343207f, 0.057994884f }, { 0.014035184f, -0.021387762f, -0.080846143f, -0.020681511f }, { -0.03594567f, 0.026862531f, 0.078975557f, -0.034056659f }, { -0.014490672f, 0.026128902f, 0.045617611f, 0.090192953f } }, { { 0.011904288f, -0.014624471f, 0.042023114f, 0.019592867f }, { 0.032705848f, 0.00038558691f, 0.031901745f, 0.027208951f }, { -0.044369719f, -0.039761364f, -0.013366816f, -0.019308126f }, { -0.019051023f, -0.00015767269f, -0.082968285f, -0.035266053f }, { -0.004775162f, 0.010889271f, 0.0089521094f, 0.027037104f }, { 0.005616143f, -0.00099668486f, 0.0068716426f, -0.12649184f }, { 0.018531199f, 0.023881776f, -0.053798787f, -0.041912909f }, { -0.0036187094f, 0.11590788f, 0.025140733f, 0.022280209f }, { -0.02994342f, -0.026293799f, -0.017204658f, 0.044901944f }, { 0.079892089f, 0.10816526f, 0.14667807f, 0.027301352f }, { -0.045296738f, -0.066748968f, -0.0099354431f, -0.070369692f }, { -0.08357374f, -0.043311901f, 0.013163375f, -0.0881777f }, { -0.065923811f, -0.10382274f, 0.090440302f, -0.013617198f }, { -0.092578587f, -0.010178017f, -0.01416593f, 0.0432333f }, { 0.055172515f, 0.10021805f, -0.0062782668f, -0.11791805f }, { -0.039684132f, -0.08934283f, 0.020686084f, -0.0013788117f }, { 0.064624676f, 0.051773746f, 0.0045383964f, -0.037696971f }, { -0.066296373f, 0.020570689f, -0.017742721f, -0.022651449f }, { -0.0061572447f, -0.094510525f, -0.094775804f, -0.038022514f }, { 0.0055683313f, 0.039513342f, -0.096815654f, -0.0065483011f }, { -0.03311602f, -0.018395457f, 0.0028464434f, -0.088048272f }, { -0.073106109f, -0.055187863f, -0.093209932f, -0.10155137f }, { 0.042841842f, -0.005778703f, 0.074069607f, -0.025841052f }, { -0.018569637f, 0.063144303f, 0.02291584f, 0.005525742f } } } }, { { { { -0.20809663f, -0.18346453f, -0.072140694f, -0.0078104407f }, { -0.19490097f, 0.25712922f, 0.37640771f, 0.11563399f }, { 0.26894915f, -0.33477877f, -0.093739129f, -0.55078405f }, { -0.65794103f, 0.09211629f, -0.19166986f, 0.5574327f }, { 0.45579532f, 0.23202083f, 0.19626303f, -0.64130523f }, { -0.018763975f, -0.24981569f, -0.32514026f, -0.11121342f }, { 0.22376238f, 0.09515938f, 0.071728264f, -0.02790747f }, { -0.3053338f, 0.34023365f, 0.099862481f, 0.26163964f }, { -0.21722968f, -0.094881958f, -0.086364431f, -0.0081863581f }, { -0.16090709f, 0.23527698f, 0.28947119f, 0.11309742f }, { 0.26447184f, -0.33536416f, -0.096418234f, -0.26201294f }, { -0.56343769f, -0.041662822f, -0.24873841f, 0.67122901f }, { 0.35362642f, 0.2577592f, 0.2009013f, -0.74233681f }, { -0.047956299f, -0.54973418f, -0.4958485f, -0.12453303f }, { 0.06917425f, 0.080509853f, 0.0090863722f, -0.023518805f }, { -0.27000602f, 0.083167162f, 0.12715558f, 0.12397839f }, { -0.11376964f, -0.079199259f, 0.019676685f, -0.0094352472f }, { -0.19185851f, 0.22193112f, 0.28110877f, -0.06422845f }, { 0.084091992f, -0.16151548f, 0.091400556f, -0.28257376f }, { -0.53821376f, 0.21718328f, -0.2234907f, 0.52302804f }, { 0.71322306f, 0.042728493f, 0.13229522f, -0.61892094f }, { 0.15270046f, -0.26304886f, -0.33110633f, -0.052728951f }, { 0.072398971f, 0.25829764f, 0.25881687f, -0.020942042f }, { -0.26788161f, 0.055822039f, 0.33817103f, 0.42061402f } }, { { 0.088248648f, 0.091306255f, 0.020476927f, 0.0030144802f }, { 0.0087376707f, 0.043816157f, 0.0022807168f, 0.016745414f }, { -0.13412414f, 0.12686539f, 0.060531476f, 0.044582027f }, { 0.019204757f, -0.0070891897f, 0.091194602f, 0.065258927f }, { -0.10429513f, -0.027665602f, -0.064350626f, 0.0053147478f }, { 0.069218141f, -0.035018324f, -0.088257571f, 0.019279642f }, { -0.073137338f, 0.040764456f, -0.022352804f, 0.031743288f }, { 0.040325697f, -0.12840825f, -0.009582113f, 0.034509657f }, { 0.081971224f, -0.0035223125f, -0.051728499f, 0.0038899717f }, { 0.050968435f, 0.022254651f, 0.18781134f, -0.032392139f }, { 0.024342518f, 0.13929014f, -0.019175435f, -0.0011608234f }, { -0.0021942487f, -0.01251222f, 0.024263454f, -0.063179344f }, { -0.13071776f, -0.059221747f, -0.034153238f, 0.036561209f }, { 0.054124093f, 0.070495803f, 0.081441614f, 0.051900357f }, { 0.027480327f, 0.028940343f, -0.01469313f, 0.032388411f }, { -0.039696828f, -0.0069393798f, -0.011361641f, 0.035031025f }, { -0.039730763f, 0.0085971581f, -0.0077461932f, -0.040735188f }, { 0.10893368f, 0.00014757217f, 0.025489178f, -0.11388774f }, { -0.0013816669f, 0.0031148929f, 0.10281666f, -0.019860642f }, { -0.065093128f, -0.11495815f, 0.041783056f, -0.091373461f }, { -0.044985581f, 0.0012713031f, -0.16078032f, 0.17303747f }, { -0.038132358f, -0.02995975f, -0.037612782f, 0.012575173f }, { 0.0042976619f, 0.027014275f, 0.017518808f, 0.030405184f }, { -0.0015298607f, 0.029297664f, -0.1034349f, 0.023450502f } }, { { 0.028785558f, -0.028708377f, -0.010459636f, 2.8360915e-05f }, { 0.091634877f, 0.021214811f, 0.12282079f, 0.080617943f }, { -0.29287977f, 0.045481846f, 0.014712563f, 0.057317576f }, { -0.10728772f, 0.03268482f, 0.015167285f, -0.011256231f }, { 0.09337321f, 0.037150859f, 0.052549202f, -0.042671474f }, { -0.0041288689f, -0.024299997f, -0.11357403f, -0.022045772f }, { -0.041469935f, -0.0071353646f, -0.0086607538f, 0.008536762f }, { 0.033629272f, -0.0070042955f, -0.037864853f, -0.0055907778f }, { 0.016404597f, -0.0055321059f, -0.020989839f, -0.013771265f }, { 0.042552435f, 0.04428518f, 0.0030587466f, 0.044894182f }, { -0.027600219f, 0.026831779f, 0.051120849f, -0.032184808f }, { 0.13870554f, 0.15273282f, 0.049260112f, 0.043371121f }, { -0.018453269f, -0.18061413f, 0.24805649f, -0.031741165f }, { -0.085137374f, 0.025935867f, 0.015978067f, 0.067726486f }, { 0.072393868f, 0.0050430488f, 0.0016664585f, 0.0072097064f }, { 0.033840162f, 0.082225764f, -0.079387016f, 0.033165625f }, { 0.033170766f, 0.0012231618f, -0.066984982f, 0.051671704f }, { 0.017894231f, -0.012267532f, 0.045536123f, -0.07327109f }, { 0.0073109731f, -0.063797898f, -0.13446413f, 0.1408986f }, { -0.045702456f, -0.1647051f, -0.14336468f, 0.054543693f }, { 0.0042448876f, -0.13234456f, 0.092181719f, -0.10440841f }, { -0.060020212f, -0.011098469f, -0.030257182f, -0.030922037f }, { -0.018118661f, 0.00067983745f, -0.0061776598f, -0.031721273f }, { -0.019885189f, 0.094157888f, 0.014017961f, -0.051373389f } } }, { { { 0.12415319f, -0.13611564f, -0.029441661f, -0.14143497f }, { -0.26074418f, 0.011913326f, -0.033328425f, 0.43248793f }, { 0.19336432f, 0.37269586f, 0.36803538f, -0.51720719f }, { -0.15185913f, -0.47431781f, -0.6593667f, 0.23163184f }, { 0.18276216f, 0.19248743f, 0.65453332f, 0.54748087f }, { 0.17751443f, -0.0020337696f, 0.08506463f, -0.40147769f }, { -0.11370932f, 0.11523476f, -0.010573025f, 0.082295392f }, { -0.13666335f, -0.32747478f, -0.16897386f, 0.15359006f }, { 0.11716326f, -0.12259922f, 0.0033396256f, -0.13240653f }, { -0.27776876f, -0.10222241f, -0.039920479f, 0.35499708f }, { 0.090003723f, 0.3313923f, 0.1871549f, 0.003163675f }, { -0.51626118f, -0.76341562f, -0.56326874f, 0.20153559f }, { -0.34172723f, 0.26975563f, 0.67520079f, -0.1252004f }, { 0.45758078f, -0.19142179f, 0.064180031f, -0.48748431f }, { -0.12800789f, 0.1399912f, 0.0077954775f, 0.14379741f }, { -0.13042104f, -0.45670817f, -0.18831095f, 0.0032738639f }, { 0.12446807f, -0.11504524f, -0.027331682f, 0.03861758f }, { -0.31337986f, -0.11842668f, 0.033415325f, 0.45344231f }, { 0.11463107f, 0.077427841f, 0.060880794f, -0.069619455f }, { -0.37772106f, -0.59628905f, -0.65426572f, 0.065297039f }, { 0.29532991f, 0.75920243f, 0.53294265f, -0.15002562f }, { 0.3618333f, 0.10488387f, 0.36007528f, -0.30963565f }, { -0.13738196f, 0.20795596f, 0.029274703f, 0.18017599f }, { -0.10290023f, -0.48517535f, -0.33278584f, 0.56477854f } }, { { -0.0047891472f, 0.024629901f, 0.015256654f, -0.0084462001f }, { 0.056227746f, -0.048057782f, -0.15671312f, 0.06418471f }, { -0.070093217f, -0.018057199f, 0.062026545f, -0.051053726f }, { -0.0091221476f, 0.0020547295f, -0.087729813f, -0.10164738f }, { 0.098917091f, -0.066835916f, 0.083151519f, 0.006342544f }, { 0.0013540606f, 0.038719082f, 0.036333261f, -0.053178668f }, { 0.0083787438f, 0.0028359378f, 0.0089872852f, 0.031308249f }, { 0.014379686f, -0.079563474f, -0.079160006f, -0.016352226f }, { 0.0091376645f, -0.016678006f, -0.044636785f, -0.0011035265f }, { 0.0099146109f, 0.027589302f, -0.09494437f, 0.07451767f }, { 0.017453983f, 0.080674871f, 0.06341808f, 0.048820473f }, { 0.02794057f, 0.058230195f, -0.010793601f, 0.091813872f }, { -0.049633232f, -0.1142016f, 0.036984283f, 0.0034294865f }, { 0.047712957f, 0.10161366f, 0.13774722f, 0.039503136f }, { 0.014194782f, -0.014555183f, -0.00053182909f, 0.0019143477f }, { 0.0014900262f, 0.0056176356f, -0.034517871f, -0.0010707988f }, { 0.013287784f, -0.0073967933f, -0.019271341f, 0.016354896f }, { -0.10345626f, 0.023536634f, 0.027943639f, -0.015686972f }, { -0.025193395f, -0.10224801f, 0.078686884f, -0.048574399f }, { 0.15797878f, -0.0012322757f, -0.036096649f, -0.23983963f }, { -0.10455507f, -0.056368102f, -0.06570944f, 0.29104616f }, { 0.05155239f, -0.040940824f, -0.038367594f, 0.058174485f }, { 0.010471732f, -0.066952904f, -0.047763843f, -0.021124742f }, { -0.033555686f, 0.0049111983f, -0.026592789f, 0.014438586f } }, { { -0.0048440946f, 0.025915095f, -0.018325403f, 0.022133613f }, { 0.059240081f, -0.031272176f, -0.12967647f, -0.17957913f }, { 0.0574837f, 0.067005152f, 0.024644254f, 0.10786296f }, { 0.067084865f, 0.008513386f, 0.04077659f, 0.10587924f }, { 0.026332643f, 0.1072618f, -0.098375042f, -0.001724609f }, { -0.021386362f, -0.0020174921f, 0.16800158f, 0.081359882f }, { -0.018204146f, -0.026432136f, -0.0068153455f, -0.029997667f }, { -0.043221501f, -0.016869967f, -0.067406967f, -0.024965804f }, { -0.0033879999f, 0.031310818f, -0.010853802f, 0.00088944004f }, { -0.068991006f, 0.087874253f, -0.15737392f, -0.088870044f }, { 0.061763806f, -0.00072874343f, -0.009915009f, -0.0178225f }, { -0.07340717f, 0.080339271f, -0.0027124572f, -0.13078641f }, { -0.023682834f, 0.16512313f, -0.15784472f, 0.047978827f }, { 0.0063250439f, -0.09953777f, 0.094180888f, 0.010565041f }, { 0.010047311f, -0.042999009f, -0.012483998f, -0.016966759f }, { -0.048612679f, 0.051708319f, 0.015059148f, 0.0036776472f }, { -0.011737015f, -0.0027276603f, 0.026535075f, -0.065453876f }, { 0.056388137f, 0.061461073f, -0.12726984f, -0.025578248f }, { 0.0016833003f, 0.10878558f, 0.13254828f, -0.017098914f }, { -0.031606282f, -0.072245098f, 0.12724789f, -0.21852899f }, { -0.062502612f, -0.073402771f, -0.049624729f, 0.069066032f }, { -0.075837195f, -0.10297347f, -0.07249237f, -0.11538062f }, { -0.015644005f, 0.039474396f, 0.074415075f, -0.038881161f }, { -0.040175911f, 0.034030267f, 0.03947059f, 0.014167463f } } }, { { { 0.97019677f, 0.97355703f, 0.99695983f, 0.98991674f }, { 0.94552952f, 0.96630359f, 0.92585444f, 0.89419404f }, { 0.9435447f, 0.86545998f, 0.92507456f, 0.65508294f }, { 0.73759908f, 0.87552111f, 0.72697883f, 0.79725496f }, { 0.87111918f, 0.95347518f, 0.73011435f, 0.53758004f }, { 0.9839393f, 0.96829127f, 0.94183216f, 0.90909143f }, { 0.96798791f, 0.98876976f, 0.99736817f, 0.99621717f }, { 0.9423876f, 0.88147679f, 0.98054848f, 0.95286662f }, { 0.96906348f, 0.98791034f, 0.99625801f, 0.99116169f }, { 0.94707625f, 0.9665378f, 0.9563539f, 0.9280011f }, { 0.96018435f, 0.88187869f, 0.97758711f, 0.96505917f }, { 0.64499021f, 0.64456248f, 0.78794513f, 0.71332673f }, { 0.87073007f, 0.92778882f, 0.70974824f, 0.65822558f }, { 0.88787388f, 0.81311133f, 0.86603417f, 0.86420517f }, { 0.98935782f, 0.98687417f, 0.99992833f, 0.98932764f }, { 0.95398485f, 0.88572054f, 0.97384313f, 0.99227952f }, { 0.98567955f, 0.99019799f, 0.99943274f, 0.99920952f }, { 0.93004482f, 0.96784384f, 0.95909399f, 0.88896838f }, { 0.98984254f, 0.98382807f, 0.99395144f, 0.95671584f }, { 0.75342733f, 0.77283296f, 0.72248756f, 0.84981055f }, { 0.63568318f, 0.6494505f, 0.83574524f, 0.77099234f }, { 0.91965169f, 0.95906448f, 0.87218942f, 0.94939213f }, { 0.98786871f, 0.94341754f, 0.96548269f, 0.98341143f }, { 0.95794101f, 0.87263324f, 0.8802806f, 0.71000638f } }, { { -0.0064390277f, 0.051629953f, -0.011423447f, 0.032337826f }, { 0.055030538f, 0.061305324f, -0.016012659f, 0.083766345f }, { 0.052467122f, 0.018425134f, -0.00054737782f, 0.048038459f }, { 0.076436505f, 0.016815709f, -0.024174832f, -0.00829119f }, { 0.057903371f, 0.068822104f, -0.0064003131f, 0.00010695928f }, { 0.067104151f, 0.067284611f, 0.0074295447f, 0.024215238f }, { 0.073380541f, 0.01486405f, 0.01523157f, 0.012966612f }, { -0.0002536971f, 0.010628632f, 0.00045031869f, 0.041891438f }, { 0.055922922f, 0.0090823157f, 0.011101162f, 0.033807592f }, { -0.040264953f, 0.022318628f, -0.013682045f, -0.016112502f }, { -0.034286564f, 4.7089727e-05f, -0.013030079f, -0.012231424f }, { 0.027756308f, 0.084041595f, 0.018308393f, 0.11564334f }, { 0.0026690817f, 0.058149333f, -0.013682964f, 0.052975934f }, { -0.03852481f, 0.063493354f, 0.059460027f, 0.047740976f }, { 0.026410264f, -0.0073902435f, 0.022353771f, 0.012987341f }, { 0.035217135f, -0.0023455309f, -0.0055505614f, 0.010102857f }, { 0.00075590283f, 0.038624793f, -0.0040614962f, 0.070039437f }, { -0.02318411f, 0.04527054f, 0.013119286f, 0.025335215f }, { 0.021268391f, 0.044855911f, 0.012622905f, 0.04827088f }, { -0.0046678346f, -0.01934799f, 0.018393432f, 0.09750434f }, { 0.12480373f, 0.059151139f, 0.055196092f, 0.26701338f }, { -0.0096669036f, 0.065624767f, 0.016918517f, 0.028425135f }, { 0.026488514f, -0.0037618693f, 0.0077028717f, 0.041713399f }, { 0.018628451f, 0.033145064f, 0.029067918f, -0.000924258f } }, { { -0.043525781f, 0.028119778f, -0.011653105f, -0.020930158f }, { -0.028099186f, 0.017594088f, -0.099226445f, 0.10408808f }, { 0.11750066f, -0.0010629746f, 0.018381448f, 0.096538552f }, { 0.0010069446f, 0.013799541f, 0.1325137f, 0.020820734f }, { -0.053571928f, -0.0066793785f, 0.14596488f, -0.03272949f }, { 0.028507895f, 0.015474376f, -0.025411653f, 0.037264272f }, { 0.033698911f, 0.018088387f, 0.0038898537f, 0.03163178f }, { 0.0057766828f, 0.015879322f, 0.012557033f, 0.071771631f }, { -0.0044521866f, 0.0083963511f, -0.0020426175f, 0.023784146f }, { -0.011508765f, 0.0075020051f, 0.0018808294f, 0.040843424f }, { 0.0085150894f, 0.0056891711f, 0.010134672f, 0.046224768f }, { 0.040825446f, 0.10099754f, 0.021853299f, 0.024507528f }, { -0.0055958303f, -0.0060958f, 0.1115321f, -0.021701014f }, { 0.010487817f, -0.010033143f, -0.031203025f, 0.054265436f }, { 0.0040500672f, 0.0053935875f, 0.018233022f, 0.018797311f }, { 0.064057639f, 0.014318185f, 0.0199119f, 0.014366235f }, { 0.02411682f, 0.045454692f, 0.0030084434f, 0.019464939f }, { 0.012500289f, 0.027734846f, 0.0025097372f, 0.047343669f }, { 0.037625829f, -0.00064472688f, 0.0557556f, 0.04785655f }, { 0.0020433437f, 0.019929208f, 0.087936103f, -0.036738471f }, { 0.020811556f, 0.0915387f, 0.055445303f, -0.065132763f }, { 0.03911814f, 0.043721622f, 0.0074336204f, -0.031370424f }, { 0.014072509f, -0.014795458f, 0.010517063f, 0.022409628f }, { -0.0054107234f, 0.055313602f, 0.053556404f, 0.048574319f } } }, { { { 3.4224197f, 3.3162336f, 3.1136621f, 3.3189801f }, { 4.0715355f, 3.5614196f, 4.1797877f, 4.0959601f }, { 4.3979407f, 4.1858272f, 4.3116447f, 4.5467451f }, { 4.4920032f, 4.0716439f, 4.6107962f, 4.5268016f }, { 5.6570832f, 4.9036495f, 4.7373547f, 4.7259419f }, { 3.3277827f, 3.6015237f, 4.226646f, 3.7939772f }, { 3.4893058f, 3.3260638f, 3.0626103f, 3.1798705f }, { 3.6423735f, 4.1092281f, 3.3264203f, 3.7325301f }, { 3.4756581f, 3.2550256f, 3.224671f, 3.4093307f }, { 3.8511362f, 3.4821381f, 4.3232597f, 3.7357164f }, { 3.6688024f, 4.0797971f, 3.4140927f, 3.6881261f }, { 4.5298469f, 4.7472506f, 4.4046473f, 4.7279944f }, { 4.1614448f, 4.1242955f, 4.6741969f, 5.0037875f }, { 4.3148703f, 4.3815566f, 4.1976536f, 3.9032858f }, { 3.2640506f, 3.3214728f, 2.9463564f, 3.3562068f }, { 3.6729325f, 3.9218642f, 3.4550701f, 3.4833871f }, { 3.435975f, 3.3079446f, 3.3432341f, 3.3632985f }, { 3.8404619f, 3.4716915f, 3.858149f, 3.8677391f }, { 3.3181827f, 3.8403872f, 4.0363918f, 3.9604287f }, { 5.0916792f, 5.2773748f, 4.5404255f, 4.377031f }, { 4.6514614f, 4.7569957f, 4.1233238f, 4.4022582f }, { 3.6884833f, 3.6283543f, 4.1874612f, 4.2963913f }, { 3.456705f, 3.6250566f, 3.5292789f, 3.1420033f }, { 3.5986317f, 4.0596074f, 4.0696874f, 4.5327067f } }, { { -0.12592901f, -0.14780788f, -0.11051274f, -0.18767653f }, { -0.020435093f, 0.0055221209f, -0.021183195f, -0.15159792f }, { 0.022498629f, -0.025100789f, -0.30939177f, 0.016420202f }, { 0.21296442f, -0.042976575f, 0.082118132f, 0.14574735f }, { -0.13608022f, 0.16141834f, -0.015091164f, 0.044951541f }, { -0.08235774f, -0.10333151f, 0.089785432f, -0.036620639f }, { -0.17664465f, -0.015842477f, -0.083075331f, -0.15660828f }, { -0.11292423f, -0.072894494f, -0.068901923f, -0.2283674f }, { -0.19063437f, -0.071954393f, 0.091375283f, -0.26993547f }, { 0.042798331f, -0.06495575f, 0.050221766f, 0.024602586f }, { -0.026228614f, 0.0049810367f, 0.046584088f, -0.13067577f }, { 0.072779737f, -0.023369437f, -0.030275791f, 0.19591126f }, { -0.018649072f, 0.029208952f, 0.012033439f, 0.00094798196f }, { -0.094599446f, 0.0070746366f, -0.0007115864f, -0.040175552f }, { -0.027599009f, -0.068747365f, 0.19480498f, -0.19423733f }, { -0.076671551f, 0.0075475135f, 0.019853903f, -0.012984601f }, { 0.064371855f, -0.24044027f, -0.043765356f, 0.0016424127f }, { -0.076744435f, 0.035881398f, 0.12967612f, 0.081825243f }, { -0.15224256f, 0.032665115f, -0.027927205f, 0.076091133f }, { -0.0057973613f, -0.14914213f, -0.047678749f, -0.037214457f }, { 0.10060085f, -0.099197666f, -0.22704457f, -0.0020812401f }, { -0.070664558f, -0.13179176f, -0.014217065f, -0.030410253f }, { -0.12286487f, -0.046623366f, -0.10695394f, -0.0081383175f }, { -0.14561788f, 0.02765909f, 0.10439783f, 0.033139041f } }, { { 0.0063171031f, -0.0047223477f, -0.056312039f, -0.065065766f }, { -0.0059575982f, -0.062348475f, 0.069540315f, -0.090331962f }, { 0.10218203f, 0.050383376f, -0.0089914697f, -0.037837343f }, { -0.0037657879f, 0.18278082f, 0.079014627f, -0.052587294f }, { -0.33929282f, 0.018522098f, 0.0078923893f, 0.042545349f }, { 0.027294929f, -0.086490439f, -0.0057363347f, -0.035932082f }, { -0.061716003f, -0.14470599f, 0.033117786f, -0.08112808f }, { 0.16414856f, 0.082471596f, -0.058497326f, 0.050552718f }, { -0.07627083f, -0.0064181717f, -0.031179581f, -0.075705068f }, { -0.057808009f, -0.00074561624f, -0.23990956f, 0.018671772f }, { 0.1677602f, 0.10757253f, 0.028015134f, -0.23923178f }, { 0.078827365f, 0.068682485f, 0.056277532f, -0.069749241f }, { 0.079502977f, 0.05526585f, 0.0089767144f, -0.15319341f }, { -0.038594242f, -0.055488998f, -0.043132461f, 0.054313031f }, { 0.12890592f, -0.082639555f, 0.22520491f, -0.026781096f }, { -0.071292391f, 0.064592881f, -0.050368563f, -0.072488866f }, { 0.092998671f, 0.12152394f, 0.033318795f, -0.039691417f }, { -0.0049706273f, -0.0014175115f, -0.11634604f, 0.15219284f }, { -0.012414906f, 0.035583927f, -0.072463074f, -0.058394705f }, { -0.071558898f, -0.00093653835f, 0.013149622f, 0.01495775f }, { -0.057103279f, 0.013702583f, -0.020242751f, 0.04649072f }, { -0.083398977f, -0.20123674f, 0.062758815f, -0.043671819f }, { 0.084479675f, 0.17868517f, -0.021185269f, 0.15711776f }, { 0.11862504f, 0.079985297f, 0.063556911f, 0.14639069f } } }, { { { 0.48018566f, 0.17712962f, 0.45065949f, 0.76214707f }, { 0.37788335f, 0.385421f, 0.24766167f, 0.3647243f }, { 0.45095873f, 0.2634498f, 0.37824131f, 0.10713483f }, { 0.18808611f, 0.27852978f, 0.23671202f, 0.23174978f }, { 0.39404781f, -0.7399413f, 0.28511918f, 0.026007027f }, { 0.46587668f, 0.46802177f, 0.36697974f, 0.23706778f }, { 0.48925391f, 0.42086488f, 0.49570155f, 0.45137287f }, { 0.30655255f, 0.35196398f, 0.23019387f, 0.50586011f }, { 0.45798975f, 0.34137244f, 0.33289763f, 0.54218519f }, { 0.42271216f, 0.38700914f, 0.48791862f, 0.15025833f }, { 0.7282781f, 0.37956244f, 0.25156645f, 0.51632504f }, { 0.084933462f, 0.15576738f, 0.16469359f, 0.29684651f }, { 0.34570877f, 0.34912791f, 0.26663435f, 0.11188061f }, { 0.48552914f, 0.19012867f, 0.12677402f, 0.1234341f }, { 0.2190939f, 0.41431469f, 0.64823269f, 0.51846746f }, { 0.49289149f, 0.29829354f, 0.29090992f, 0.36465152f }, { 0.50568056f, 0.64150077f, 0.40217634f, 0.53523743f }, { 0.24945735f, 0.47058801f, 0.29099852f, 0.25452114f }, { 0.49039753f, 0.26327736f, 0.39431507f, 0.50632023f }, { 0.19678915f, 0.031547614f, 0.22295107f, 0.26300048f }, { 0.12409997f, 0.11506147f, 0.19327618f, 0.2174585f }, { 0.15319333f, 0.39177705f, 0.38498586f, 0.25972804f }, { 0.69027161f, 0.37279682f, 0.31143504f, 0.23440833f }, { 0.39682066f, 0.3156927f, 0.36369313f, 0.14308402f } }, { { 0.15030994f, 0.15410005f, 0.0072554408f, -0.22242826f }, { -0.032421729f, 0.22531436f, 0.22185899f, -0.022703209f }, { 0.070341052f, 0.30237173f, 0.047916387f, 0.03629681f }, { -0.024283222f, 0.075614195f, 0.013940033f, -0.016841468f }, { 0.077729482f, 0.19455394f, -0.02162282f, -0.018761003f }, { -0.22986895f, 0.18914992f, 0.14483608f, 0.11173921f }, { 0.14132894f, -0.0081864768f, -0.11405791f, 0.031777789f }, { 0.38775389f, 0.0085565642f, -0.057167843f, 0.09784167f }, { 0.079102739f, 0.030530894f, 0.041954967f, 0.02957611f }, { 0.076915126f, 0.18656729f, 0.044218872f, 0.22478833f }, { 0.017173879f, 0.11961351f, -0.085099523f, 0.22720323f }, { 0.030466202f, 0.095221887f, -0.042982583f, -0.069264747f }, { 0.041170442f, -0.090598444f, -0.021082598f, -0.028016784f }, { -0.082581617f, -0.023712106f, 0.32427665f, 0.1010696f }, { 0.19197752f, 0.10900527f, -0.0053794951f, 0.068553764f }, { 0.18674269f, 0.028895321f, -0.053421028f, 0.063918058f }, { 0.044090722f, -0.054247791f, 0.05585954f, -0.13406746f }, { 0.08358642f, -0.032301886f, 0.010371619f, 0.099505528f }, { 0.16467816f, 0.044994571f, -0.0045949279f, 0.0626774f }, { 0.12942209f, 0.092097891f, 0.019866495f, 0.10340014f }, { 0.037094903f, 0.13829877f, 0.15116473f, -0.048632499f }, { 0.10749044f, 0.14329542f, -0.061272024f, -0.1536028f }, { 0.097716907f, 0.044246181f, 0.056664419f, 0.15804873f }, { 0.031819999f, 0.10132976f, 0.079198524f, 0.017871462f } }, { { 0.056219172f, 0.08683492f, -0.061488015f, 0.065746152f }, { 0.088983664f, 0.19773741f, -0.096766599f, 0.16352101f }, { -0.0097043787f, -0.040925999f, 0.097458334f, 0.032319634f }, { -0.024873518f, 0.057873123f, -0.0059256291f, -0.057498398f }, { -0.13355098f, 0.39190863f, 0.017449142f, -0.0076009344f }, { 0.10319658f, 0.22069551f, -0.098795717f, 0.10603434f }, { 0.090765308f, 0.13803326f, -0.070647945f, 0.14557561f }, { -0.068457348f, 0.058955208f, -0.050501105f, 0.02914144f }, { 0.10363866f, 0.060231993f, 0.027681685f, 0.079659088f }, { 0.01269983f, 0.11977996f, -0.049648315f, 0.089882363f }, { -0.072877286f, 0.019348792f, 0.13977764f, 0.055396044f }, { 0.028834456f, -0.1084196f, -0.0043985215f, -0.072640844f }, { -0.040232522f, 0.051835989f, -0.02198193f, 0.016421295f }, { -0.087848469f, -0.04621504f, 0.099259188f, -0.0025909067f }, { 0.3000131f, 0.10526775f, 0.016890366f, 0.12892588f }, { -0.021028821f, -0.024429075f, 0.088067677f, -0.084594075f }, { 0.086861805f, -0.045902006f, 0.0058222123f, -0.0075466204f }, { 0.14411905f, 0.036488937f, 0.05091815f, 0.16385101f }, { 0.1576814f, 0.043890956f, -0.064244298f, -0.087234754f }, { -0.071100004f, 0.16782304f, -0.10860149f, -0.1601076f }, { 0.032634641f, -0.0025068263f, -0.093802703f, -0.076176546f }, { 0.1121451f, 0.15584236f, 0.070074778f, 0.083736091f }, { 0.16981897f, -0.078106227f, 0.12480295f, -0.0056807652f }, { -0.20300117f, -0.017467249f, 0.035504155f, 0.056546123f } } } }, { { { { 0.014994926f, 0.3118252f, 0.12179235f, -0.2013765f }, { -0.2622824f, 0.28086607f, 0.018805882f, 0.72058929f }, { -0.0081002049f, -0.28176506f, -0.592214f, -0.15032918f }, { 0.18913426f, -0.24000825f, 0.0020279072f, -0.54749128f }, { 0.010237954f, 0.76905205f, 0.80173664f, -0.016024595f }, { -0.53448318f, 0.31204229f, -0.16183732f, 0.76857439f }, { -0.57639279f, -0.63719194f, -0.71354849f, 0.56346054f }, { 0.49443258f, 0.15067585f, 0.31864726f, -0.30570933f }, { -0.20756322f, 0.2544828f, -0.005298245f, 0.0073796841f }, { -0.61822672f, 0.21508574f, 0.6362534f, 0.30433278f }, { -0.0050327191f, -0.278054f, -0.3460806f, 0.29967778f }, { 0.33983098f, -0.11715664f, -0.21761592f, -0.068273894f }, { 0.5550354f, 0.44369709f, 0.64019993f, -0.026032291f }, { -0.72587268f, -0.33528197f, -0.33592445f, 0.53027141f }, { -0.47623191f, -0.61767624f, -0.61525655f, 0.37823554f }, { 0.82869964f, 0.219401f, -0.018181789f, -0.56937955f }, { -0.051792934f, 0.3461701f, 0.20915925f, 0.078166496f }, { -0.26705611f, 0.14439061f, 0.0055054648f, 0.463243f }, { -0.0019649711f, -0.34119962f, -0.29306531f, -0.040223173f }, { 0.29285811f, -0.32824753f, -0.24768208f, -0.29676955f }, { 0.87604898f, 0.25374435f, 0.2341931f, -0.77851996f }, { -0.80404697f, 0.011122158f, 0.18899178f, 0.55592668f }, { -0.78397618f, -0.53690406f, -0.59931185f, 0.62348293f }, { 0.54613799f, 0.080819658f, 0.12590931f, -0.60614071f } }, { { -0.12307869f, -0.20242175f, 0.21530167f, -0.15608553f }, { 0.00052208688f, 0.09998365f, -0.067550225f, -0.14009319f }, { 0.12621699f, -0.089024022f, 0.022656689f, 0.18947331f }, { 0.34838897f, -0.04936051f, 0.25527451f, -0.18942819f }, { 0.013210249f, -0.043957685f, -0.19088103f, -0.034189573f }, { -0.0027790938f, -0.026595097f, 0.087083287f, -0.12513839f }, { -0.038231564f, 0.013328425f, -0.0091503894f, -0.005743873f }, { 0.17205702f, -0.14956835f, -0.0088915291f, 0.18720588f }, { -0.049670195f, 0.39532325f, 0.080260299f, 0.01811245f }, { 0.043555003f, -0.30289197f, -0.50878196f, 0.27306166f }, { 0.02555972f, -0.0068359476f, 0.061097702f, -0.43822038f }, { -0.10926471f, 0.1870906f, 0.12419548f, 0.1245213f }, { -0.012443149f, 0.040036941f, 0.18601483f, 0.02310445f }, { -0.10442982f, 0.057455632f, 0.13475314f, -0.0019859122f }, { -0.068181593f, -0.0033655904f, 0.01922998f, -0.020393828f }, { -0.10660626f, 0.0020812455f, 0.081209707f, 0.077131932f }, { 0.088733212f, -0.10430986f, 0.45554817f, -0.17113078f }, { 0.0046831409f, 0.13247549f, -0.1077727f, 0.15382275f }, { 0.022346595f, 0.022924261f, -0.35016323f, 0.2437608f }, { 0.029795657f, 0.23046877f, -0.020493651f, -0.33214749f }, { -0.016101582f, 0.042296203f, 0.046779444f, 0.037412394f }, { -0.02214903f, -0.025218605f, 0.14797485f, -0.051723623f }, { 0.021321783f, 0.010405115f, 0.0075476201f, 0.0082410917f }, { 0.040559796f, 0.027927916f, -0.012812736f, -0.0096642379f } }, { { -0.055647079f, 0.017595207f, 0.34495838f, -0.03055759f }, { -0.058415094f, 0.027416036f, 0.18568916f, 0.13044498f }, { 0.01482217f, -0.17300703f, 0.027540135f, -0.2744944f }, { 0.25558424f, -0.15324455f, -0.29751197f, -0.11422984f }, { -0.068936732f, -0.11425403f, 0.094767025f, -0.0020892558f }, { 0.040887892f, 0.031622148f, -0.095292456f, -0.02460001f }, { -0.0026237665f, 0.017734103f, 0.01213911f, 0.0056586962f }, { -0.052138375f, 0.052245567f, 0.04608449f, -0.043004468f }, { -0.17693366f, 0.0021023738f, 0.13167397f, -0.14062006f }, { -0.20900333f, 0.0057695127f, 0.13057243f, 0.046715668f }, { -0.020569928f, -0.08439655f, -0.09683347f, 0.038139385f }, { 0.18196242f, 0.44461908f, -0.11388512f, -0.12413082f }, { 0.072801844f, -0.0017236427f, -0.0026756083f, 0.049805114f }, { -0.092195952f, -0.0076195172f, -0.22763849f, -0.11320887f }, { 0.016234922f, 0.007258942f, 0.078535592f, -0.084829275f }, { -0.15320003f, 0.057490618f, -0.16065455f, -0.17063675f }, { -0.012856124f, 0.024818957f, 0.097529739f, 0.11569844f }, { -0.11141243f, 0.26677735f, 0.1319403f, -0.15699502f }, { -0.021128161f, -0.12370585f, 0.056198856f, -0.1836225f }, { -0.01871806f, 0.025525037f, 0.063822152f, 0.066517944f }, { -0.013759301f, 0.11401068f, -0.04701374f, -0.021321516f }, { 0.032714649f, -3.161284e-06f, 0.026930697f, 0.00019593482f }, { 0.10575127f, 0.016956425f, 0.016873291f, 0.0049304377f }, { -0.11938883f, 0.31242334f, 0.29347156f, -0.19514533f } } }, { { { -0.17374661f, -0.028781395f, -0.25993234f, 0.27242277f }, { -0.13675759f, -0.62291002f, -0.80742781f, 0.54260546f }, { 0.16876581f, -0.052588487f, 0.22415557f, -0.59669887f }, { 0.1769234f, 0.64210979f, 0.81157479f, -0.2718564f }, { -0.99873125f, -0.013258174f, 0.58939675f, 0.99930085f }, { -0.30883355f, -0.71116337f, -0.76218623f, 0.096388818f }, { 0.65749012f, -0.54533843f, -0.57508599f, -0.70359398f }, { -0.27406769f, 0.61006308f, 0.1873512f, 0.2563151f }, { -0.78453523f, -0.13585943f, -0.048534939f, 0.02085237f }, { 0.40938527f, -0.76981396f, -0.42506866f, 0.22362984f }, { 0.29003079f, -0.20624421f, 0.1151133f, -0.50558933f }, { 0.0070051806f, 0.20763719f, 0.59485798f, -0.61562639f }, { -0.4371111f, 0.48314196f, 0.72981069f, 0.99889301f }, { 0.58257878f, -0.8603979f, -0.94188892f, -0.83140889f }, { 0.71858167f, -0.49534538f, -0.63421799f, -0.84488463f }, { 0.016158248f, 0.65330502f, 0.82883727f, -0.127372f }, { -0.50292264f, -0.14848746f, -0.20836533f, 0.2471481f }, { -0.15815031f, -0.63472031f, -0.79826416f, 0.15325573f }, { -0.010424343f, -0.022843894f, 0.099730136f, -0.26040744f }, { 0.15069433f, 0.31188588f, 0.63836617f, -0.25234477f }, { -0.36946506f, 0.92093529f, 0.96548808f, 0.62354203f }, { -0.57070465f, -0.99847512f, -0.47855156f, -0.079970605f }, { 0.077467525f, -0.71134336f, -0.67172579f, -0.66364974f }, { -0.27299386f, 0.89512951f, 0.61598356f, 0.49577277f } }, { { 0.070458859f, -0.28774455f, 0.21287043f, -0.094689772f }, { 0.0029548085f, -0.31404605f, -0.039280892f, -0.3652277f }, { -0.033729607f, 0.041215792f, 0.065844258f, -0.21509418f }, { 0.39270582f, 0.067526811f, 0.15655351f, 0.053346856f }, { 0.052704394f, -0.087801294f, 0.18655104f, 0.056114808f }, { -0.074582751f, -0.055177669f, -0.22165519f, 0.13272162f }, { -0.027850171f, 0.0029849066f, -0.0062314784f, -0.010484316f }, { 0.20753796f, -0.0087111988f, -0.13875075f, -0.06137521f }, { 0.089744421f, 0.07271039f, 0.099417029f, -0.22157272f }, { -0.013209094f, 0.048633419f, -0.26528065f, -0.15253703f }, { 0.052922007f, 0.24859103f, 0.14406684f, 0.13857649f }, { 0.00096142813f, 0.32643367f, 0.17939549f, -0.39761314f }, { 0.013505803f, -0.036986517f, -0.12729111f, 0.15459921f }, { -0.00049722057f, -0.047063275f, -0.0018666598f, 0.1067114f }, { -0.074221027f, -0.00927958f, -0.029535811f, -0.024240068f }, { -0.12387933f, 0.06626829f, 0.16422781f, 0.077740779f }, { 0.14560404f, -0.082132455f, 0.027268021f, 0.18857832f }, { 0.10470732f, -0.29519533f, -0.23666419f, 0.10917064f }, { 0.042550279f, 0.02436036f, -0.31865644f, -0.024987356f }, { -0.030434576f, 0.082115299f, 0.17770796f, 0.020944092f }, { -0.17365377f, 0.13807361f, 0.12476029f, 0.072738061f }, { -0.11503962f, -0.04022554f, 0.028018434f, -0.070211356f }, { -0.043677907f, 0.0053361863f, 0.0039019898f, 0.0027489647f }, { 0.27060899f, -0.0016552279f, 0.14166067f, -0.25461265f } }, { { 0.014703402f, 0.094752279f, -0.32162049f, 0.082335322f }, { -0.31539882f, 0.44394592f, 0.44316202f, -0.031456167f }, { -0.024148679f, 0.082370612f, -0.0031744796f, 0.098610537f }, { 0.46130367f, -0.19989896f, -0.56118891f, 0.11979937f }, { 0.11784636f, 0.079971516f, -0.16977121f, 0.014922099f }, { 0.018367216f, -0.076519762f, 0.13801492f, 0.039682415f }, { -0.0027614728f, 0.0010389006f, -0.023126227f, 0.0027068473f }, { 0.22249856f, -0.071302328f, 0.23721977f, 0.10734273f }, { 0.41478408f, -0.36611101f, 0.18031261f, -0.11176768f }, { 0.15800457f, 0.23829725f, -0.0016193556f, 0.2112867f }, { -0.14793833f, -0.15378785f, 0.0082778301f, 0.27105519f }, { -0.064743588f, 0.44794816f, -0.12599819f, 0.4310022f }, { 0.092725214f, 0.033947737f, 0.19969884f, 0.0072363359f }, { -0.074190657f, 0.005985921f, 0.300818f, -0.090919095f }, { 0.024238118f, -0.010955859f, -0.068086841f, -0.021137349f }, { 0.12196721f, -0.19977338f, -0.64428422f, -0.30808722f }, { 0.46567096f, -0.042072501f, -0.1778338f, 0.34294059f }, { -0.32528695f, 0.25699981f, 0.49346557f, -0.20743316f }, { 0.10422458f, 0.049488574f, 0.49098274f, -0.34871439f }, { 0.16431875f, -0.050748897f, -0.18464312f, -0.61695364f }, { -0.1753479f, 0.033238479f, -0.046267845f, -0.012339883f }, { -0.16098841f, 0.080519992f, -0.11793031f, 0.036790025f }, { 0.017193144f, -0.0029212372f, -0.0044153187f, -0.0057094316f }, { 0.23481771f, -0.1556448f, -0.18775429f, -0.013697353f } } }, { { { 0.98467622f, 0.94970347f, 0.95791534f, 0.9408684f }, { 0.95525144f, 0.73013516f, 0.58966657f, 0.43166004f }, { 0.98562289f, 0.95804118f, 0.77397471f, 0.78825859f }, { 0.96588112f, 0.72807352f, 0.58424502f, 0.79142113f }, { -0.049305848f, 0.63904864f, 0.099145551f, -0.03377918f }, { 0.78673348f, 0.62998117f, 0.62680207f, 0.63245759f }, { 0.48526085f, 0.544603f, 0.40015579f, 0.43297544f }, { 0.82487776f, 0.77789448f, 0.92917353f, 0.91697567f }, { 0.58431326f, 0.95748667f, 0.99880743f, 0.99975533f }, { 0.67096902f, 0.60093643f, 0.64381538f, 0.92594344f }, { 0.95700408f, 0.93816272f, 0.93111608f, 0.80905665f }, { 0.94046044f, 0.97116483f, 0.77381347f, 0.78507504f }, { 0.7077214f, 0.7547892f, 0.23983411f, -0.039180128f }, { 0.3656649f, 0.38379871f, -0.00015338393f, 0.16604667f }, { 0.50679735f, 0.6108265f, 0.46821675f, 0.37829596f }, { 0.55946029f, 0.72460731f, 0.55919425f, 0.81214734f }, { 0.86277825f, 0.92634645f, 0.95542467f, 0.96581976f }, { 0.95061533f, 0.75913205f, 0.60228234f, 0.87287949f }, { 0.99994373f, 0.93971324f, 0.95087677f, 0.96466059f }, { 0.9442062f, 0.89161694f, 0.72879505f, 0.92100486f }, { 0.30989313f, 0.29579046f, 0.11395771f, 0.071428407f }, { 0.16674735f, -0.054071458f, 0.85747916f, 0.82737551f }, { 0.61593841f, 0.45356879f, 0.43544204f, 0.41332561f }, { 0.79196443f, 0.43841915f, 0.77763172f, 0.62193473f } }, { { 0.028699614f, 0.071974788f, -0.028868668f, 0.030119772f }, { -0.16988515f, -0.35713152f, 0.36877151f, 0.37172103f }, { 0.024472009f, 0.10373643f, 0.052160621f, -0.12998364f }, { 0.051999909f, -0.1688679f, 0.05813266f, -0.11063347f }, { 0.026373007f, 0.067310776f, 0.34433164f, 0.0017481699f }, { -0.017659611f, -0.10215276f, -0.23736187f, 0.12678732f }, { -0.0019097928f, 0.02067204f, -0.030447136f, -0.0093192388f }, { 0.10615435f, 0.11124023f, 0.04473958f, 0.14369936f }, { 0.14791062f, -0.034502091f, 0.041456555f, 0.06737059f }, { 0.22389399f, 0.2668048f, 0.25742349f, 0.03724758f }, { 0.0046009946f, 0.066632032f, 0.097957775f, 0.22969631f }, { 0.043253167f, -0.013638494f, 0.071328387f, -0.19249903f }, { -0.023561087f, 0.011490741f, 0.19824644f, -0.04133258f }, { -0.057507532f, -0.039265903f, 0.060469313f, 0.37300659f }, { 0.027051207f, -0.0086784396f, -0.0055877341f, -0.0315352f }, { 0.15724931f, 0.0099485187f, 0.22462997f, 0.14112999f }, { 0.13909905f, 0.026199511f, -0.12430815f, -0.076900423f }, { -0.022327596f, -0.1975812f, 0.49862652f, -0.096026553f }, { 0.076782007f, 0.041598482f, 0.0033451155f, 0.039947963f }, { 0.005353589f, 0.070993946f, 0.0068174778f, -0.17805261f }, { -0.059912765f, -0.17027417f, -0.060069718f, 0.1561139f }, { 0.017122435f, 0.048532637f, -0.05315926f, 0.066962855f }, { 0.058014377f, 0.021874362f, 0.017248667f, -0.0069413843f }, { 0.099274028f, 0.040622241f, 0.040435904f, 0.14191123f } }, { { -0.13453832f, 0.071519908f, -0.1597656f, -0.030758273f }, { -0.13511715f, 0.32373425f, 0.35851035f, -0.18685481f }, { 0.021440457f, 0.034442875f, 0.14324368f, 0.15754565f }, { -0.061440371f, 0.16837735f, 0.47887644f, -0.036265812f }, { 0.55060811f, 0.14095672f, 0.13077418f, 0.25515565f }, { -0.084599968f, -0.084002143f, 0.1542308f, 0.044223437f }, { 0.0017727822f, 0.025149715f, -0.025479364f, -0.0023658361f }, { 0.1619123f, 0.069159159f, -0.016343512f, 0.026108175f }, { 0.3296525f, 0.029456656f, 0.039715069f, 0.015958704f }, { -0.093419591f, 0.37051381f, -0.063182977f, -0.017764112f }, { 0.11962535f, 0.062511772f, -0.070445145f, 0.27768911f }, { 0.07458833f, -0.16218828f, 0.064111239f, 0.43889373f }, { -0.0326486f, -0.03666828f, -0.17597139f, 0.34213144f }, { 0.061334301f, -0.0099525239f, 0.21497301f, 0.0074569296f }, { -0.016749445f, 0.00054557189f, 0.040331287f, 0.066200794f }, { 0.20620866f, 0.25268529f, 0.46594276f, 0.059651923f }, { 0.15170896f, 0.041438057f, 0.021708506f, -0.15049245f }, { -0.14317538f, 0.13548996f, 0.37297491f, 0.13718874f }, { 0.053339004f, 0.015014013f, -0.10418356f, -0.13598877f }, { -0.02227412f, 0.045548464f, 0.21534467f, -0.23828118f }, { -0.055326885f, 0.11851609f, 0.28938409f, 0.041373996f }, { -0.1219532f, 0.57338554f, -0.094571555f, 0.025008596f }, { 0.070380772f, 0.016993506f, 0.018073937f, -0.015404818f }, { 0.17033841f, 0.12449473f, 0.10847869f, -0.11141982f } } }, { { { 4.409738f, 4.5071479f, 5.4761817f, 5.3214091f }, { 5.3741435f, 4.6270256f, 5.4786338f, 5.323679f }, { 4.305776f, 4.4890731f, 4.6894257f, 4.6068436f }, { 5.4930574f, 4.9116386f, 5.4097636f, 4.9225404f }, { 5.1861828f, 5.5144226f, 5.1307797f, 5.0804212f }, { 6.1194597f, 6.0655136f, 5.7369562f, 6.1076578f }, { 6.9549598f, 6.9281578f, 6.9549598f, 6.9549598f }, { 4.5030565f, 4.5849566f, 4.4830953f, 4.4904323f }, { 5.3629211f, 5.5524848f, 4.5719135f, 4.9103175f }, { 4.8906163f, 5.3972226f, 4.8806206f, 5.1834202f }, { 4.5047396f, 4.5984947f, 4.7039612f, 4.3422371f }, { 4.5956963f, 5.6294962f, 4.46025f, 4.4827131f }, { 5.8454206f, 6.000743f, 5.4594428f, 4.9952614f }, { 6.09642f, 6.3979283f, 4.9784963f, 5.6878449f }, { 6.9549598f, 6.9752898f, 6.9549598f, 6.9549598f }, { 6.2053562f, 4.9984547f, 5.3887395f, 4.6221036f }, { 4.5265196f, 4.3684629f, 5.5819288f, 5.4957366f }, { 5.2220057f, 4.6118907f, 5.5046208f, 4.9190037f }, { 4.3408178f, 4.4980303f, 5.4937404f, 5.6154153f }, { 4.4802186f, 4.4666194f, 4.8546878f, 5.1764252f }, { 5.7384024f, 5.9048089f, 5.4636107f, 5.0807017f }, { 5.1013817f, 5.2237041f, 6.0338955f, 5.8869417f }, { 6.9414339f, 6.9549598f, 6.9549598f, 6.9549598f }, { 4.3368412f, 4.9692663f, 4.7090567f, 4.9023075f } }, { { 0.0093525884f, -0.33796029f, -0.4366682f, -0.18161326f }, { -0.34446047f, 0.10854359f, -0.61563912f, -0.16514117f }, { 0.055849315f, 0.093045585f, 0.36722184f, 0.085665647f }, { -0.21881508f, -0.036846235f, -0.25226403f, -0.012790033f }, { -0.14697546f, -0.026656628f, 0.2559775f, 0.026279081f }, { 0.073189287f, -0.074472165f, -0.15439557f, 0.020907645f }, { 0.0f, -0.015078298f, 0.0f, 0.0f }, { 0.027540893f, -0.30876053f, -0.15680794f, -0.18470107f }, { -0.072547269f, -0.019227086f, -0.26735769f, -0.1362069f }, { 0.36907279f, -0.28005156f, 0.01966203f, -0.10277819f }, { -0.26755862f, 0.066747173f, 0.60834173f, -0.23356165f }, { -0.12357338f, -0.41742338f, 0.081840746f, -0.14596222f }, { -0.068599762f, -0.004402392f, -0.17192993f, -0.15797464f }, { -0.072923207f, -0.02555551f, -0.21075071f, 0.047272919f }, { 0.0f, 0.0115085f, 0.0f, 0.0f }, { 0.32527558f, 0.066048741f, -0.28639187f, 0.45171914f }, { -0.158086f, -0.049098981f, -0.17226122f, -0.50289857f }, { -0.39456648f, 0.031970902f, -0.74883626f, 0.20536003f }, { 0.22864705f, -0.0095988927f, -0.1155595f, -0.06240073f }, { 0.12336497f, -0.34128076f, 0.34341316f, 0.083678547f }, { -0.032718317f, 0.076359349f, -0.30099369f, -0.016865529f }, { -0.23491753f, -0.17228011f, -0.044893186f, -0.057411459f }, { -0.0077848677f, 0.0f, 0.0f, 0.0f }, { -0.18713605f, -0.11612415f, 0.30907006f, 0.064707406f } }, { { -0.20768494f, -0.15642062f, -0.079474216f, -0.020948121f }, { -0.18767308f, -0.013722599f, 0.15827086f, -0.27421942f }, { -0.11484158f, -0.29325715f, 0.24426149f, 0.34598577f }, { -0.095599056f, 0.16784413f, 0.23369965f, 0.15036114f }, { 0.058496274f, -0.064565923f, -0.076598803f, -0.11988702f }, { -0.03406356f, -0.010863931f, -0.036116475f, 0.0077051595f }, { 0.0f, -0.015078298f, 0.0f, 0.0f }, { -0.21271534f, 0.31678528f, 0.084310434f, -0.039787477f }, { 0.057420352f, -0.60894321f, -0.14275706f, -0.29178151f }, { -0.21477227f, 0.091254596f, -0.053659362f, -0.13299553f }, { -0.24972574f, 0.22261101f, -0.59415755f, -0.13299464f }, { -0.406027f, 0.15018847f, 0.33281927f, 0.28006105f }, { -0.033198856f, 0.013081228f, 0.0098634494f, -0.18858267f }, { -0.16914457f, -0.014917022f, -0.15618156f, 0.038961385f }, { 0.0f, 0.0115085f, 0.0f, 0.0f }, { 0.047340338f, -0.052961301f, 0.30193278f, 0.38564757f }, { -0.2009302f, -0.15247105f, -0.32333852f, 0.22878398f }, { -0.22934017f, 0.022888443f, 0.30911154f, -0.12420416f }, { 0.21191356f, -0.33281926f, -0.13523708f, -0.038546557f }, { 0.28507859f, -0.012777666f, 0.16285544f, -0.12612215f }, { -0.057034227f, 0.01719448f, -0.037892291f, -0.13064036f }, { -0.075888865f, 0.041589292f, 0.0089100653f, -0.10775402f }, { 0.0075560462f, 0.0f, 0.0f, 0.0f }, { -0.18120766f, 0.16485298f, 0.58949587f, 0.072313493f } } }, { { { 0.60381773f, 0.64633179f, 0.92301353f, 0.23720177f }, { 1.1128727f, 0.42172315f, 1.6605811f, 0.22066721f }, { 0.55829912f, 0.7107351f, 0.47437673f, 0.53646626f }, { 0.75684406f, 0.65607146f, 1.5264507f, 0.12817954f }, { -0.25070514f, 0.30263175f, -0.21070678f, -0.2264813f }, { -0.24745858f, -0.26801252f, 0.2750925f, 0.055035565f }, { -0.018769156f, -0.066023008f, 0.10111114f, 0.0089232736f }, { 0.41152465f, 0.52508091f, 0.4161358f, 0.39058287f }, { 0.90919582f, 1.2448772f, 0.61547497f, 0.51303689f }, { 0.2973136f, 1.2348603f, 0.24154398f, 0.76087607f }, { 0.23369317f, 0.68368068f, 0.81024353f, 0.35451079f }, { 0.69272073f, 0.47014545f, 0.61401877f, 0.43768641f }, { -0.44449894f, -0.10123077f, -0.19173956f, -0.15811184f }, { -0.089717f, -0.068601549f, -0.16704813f, -0.29761406f }, { 0.0055968308f, -0.089855929f, -0.087150641f, 0.2244144f }, { 0.38902787f, 0.62620686f, 1.3314901f, 0.26038797f }, { 0.16776511f, 0.32722251f, 0.71914611f, 0.53556119f }, { 0.63106992f, 0.46256454f, 1.785895f, 0.17339911f }, { 0.72516261f, 0.44941094f, 0.81174974f, 0.61247129f }, { 0.56877815f, 0.20989179f, 0.7607991f, 0.017998645f }, { 0.016372087f, 0.26062407f, -0.32771461f, -0.075930098f }, { -0.11957223f, -0.22579003f, -0.42587945f, -0.0015549589f }, { 0.0049992009f, 0.053511694f, 0.00053268274f, 0.022778575f }, { 0.19356675f, 0.5564623f, 0.74981777f, 0.28733119f } }, { { 0.017029304f, 0.22690356f, 0.25927682f, -0.048136042f }, { 0.52936856f, -0.26082526f, 0.12568074f, -0.046727529f }, { 0.08949554f, -0.019090555f, 0.31477592f, -0.067513409f }, { 0.056302335f, -0.011819435f, -0.063621104f, 0.27092306f }, { 0.053971592f, -0.17913246f, -0.14991651f, -0.044263405f }, { 0.29037749f, -0.040498369f, -0.33600753f, 0.16250066f }, { -0.067102844f, -0.17843768f, 0.033172168f, 0.13638573f }, { 0.057127881f, -0.044468822f, 0.33005778f, 0.34775491f }, { -0.14300931f, 0.022121077f, -0.045281831f, -0.065216583f }, { 0.084931489f, 0.06688461f, 0.15758114f, -0.091330485f }, { -0.014274888f, 0.29139103f, 0.089163749f, -0.18005467f }, { -0.2191522f, -0.1333803f, -0.31948964f, -0.28536602f }, { 0.20298891f, -0.0031882515f, -0.15749696f, -0.014977715f }, { -0.14016857f, -0.17278064f, 0.01369474f, 0.10971499f }, { 0.018219806f, 0.080447764f, 0.0056022696f, -0.043028475f }, { -0.076556403f, -0.13038184f, -0.23788273f, 0.5849635f }, { 0.1038427f, 0.18199702f, 0.35294355f, -0.0023601311f }, { 0.22294845f, -0.37427713f, 0.2907529f, 0.26234219f }, { 0.40809306f, 0.12982813f, 0.42857338f, 0.14064303f }, { 0.4265028f, 0.18710053f, 0.15310514f, 0.067551813f }, { -0.18986488f, -0.029676062f, -0.087045959f, -0.14788626f }, { -0.07865478f, 0.011558295f, -0.018262356f, 0.38992629f }, { 0.22297641f, 0.072192947f, 0.064119712f, 0.12862555f }, { -0.069262467f, -0.14990585f, 0.31342655f, -0.15002022f } }, { { 0.25288162f, -0.096551539f, 0.051695506f, 0.20925392f }, { 0.23093904f, 0.096712594f, 0.19826434f, 0.32530694f }, { 0.14114785f, 0.071010138f, -0.17642029f, 0.092260082f }, { 0.39001648f, -0.17666595f, 0.088397252f, 0.1462816f }, { 0.12484597f, 0.066920676f, -0.16116194f, 0.21758387f }, { 0.15625272f, -0.00043631439f, -0.07868976f, -0.19261141f }, { -0.0142415f, 0.06356153f, 0.026276923f, -0.024546668f }, { 0.097089221f, 0.085426402f, 0.11936115f, 0.012042542f }, { 0.52509109f, -0.22465399f, -0.11490612f, 0.023562122f }, { -0.12418278f, 0.11985465f, 0.087804943f, 0.25283464f }, { 0.10716753f, -0.036426901f, 0.2469409f, -0.095816257f }, { -0.095364501f, 0.14001518f, -0.068636804f, -0.082487255f }, { 0.074490355f, 0.25323233f, 0.17863748f, 0.12482145f }, { -0.019616587f, -0.0053326518f, 0.047558858f, 0.066104462f }, { 0.12647102f, 0.25712368f, 0.12306783f, -0.050252261f }, { -0.13375041f, 0.17825067f, 0.026649645f, -0.33338076f }, { 0.16384463f, -0.022241979f, 0.17817325f, 0.6808721f }, { 0.42075944f, -0.024292721f, -0.11323318f, 0.45027063f }, { -0.023953485f, 0.25719992f, 0.28680108f, 0.33600529f }, { 0.013445546f, 0.22504275f, 0.17408162f, 0.52860686f }, { -0.098839039f, -0.27017244f, 0.10293505f, -0.012472685f }, { 0.074267375f, -0.0056418849f, 0.17632358f, 0.21754089f }, { 0.1491061f, 0.017927571f, -0.0217757f, -0.0039381966f }, { 0.067239102f, -0.74624136f, 0.12992555f, -0.058866581f } } } }, { { { { 0.1270204f, 0.7650174f, 0.55252173f, 0.05956498f }, { -0.36870832f, 0.31227245f, 0.52167466f, 0.4282174f }, { -0.036761861f, -0.5477415f, -0.76091563f, -0.37583127f }, { 0.17129434f, -0.14281209f, -0.40463148f, -0.56367877f }, { 0.07429238f, 0.45420144f, 0.41919765f, 0.019225986f }, { -0.44125436f, -0.05567539f, 0.080551064f, 0.54444995f }, { -0.36600455f, -0.55359309f, -0.3290331f, 0.33946169f }, { 0.65253747f, 0.015186649f, 0.0665303f, -0.64649501f }, { 0.05392469f, 0.54355001f, 0.7539307f, -0.41089455f }, { -0.29264863f, 0.49684721f, 0.39184208f, 0.47737193f }, { 0.10885354f, -0.80803227f, -0.7443769f, -0.3736688f }, { 0.1939378f, -0.079590275f, -0.42241709f, -0.75536039f }, { 0.44776697f, 0.44884546f, 0.427965f, 0.3297221f }, { -0.34595785f, 0.27723463f, 0.12245317f, 0.43884357f }, { 0.18467758f, -0.55582608f, -0.99421464f, -0.0096027817f }, { 0.6672057f, -0.038103784f, -0.048616141f, -0.68508055f }, { -0.016615937f, 0.62001729f, 0.50530563f, -0.22211425f }, { -0.16823123f, 0.31934529f, 0.47092187f, 0.4884373f }, { 0.03194189f, -0.5624624f, -0.44688229f, 0.223814f }, { 0.17828041f, -0.080017082f, -0.44239439f, -0.46726625f }, { 0.19895649f, 0.82568772f, 0.47859751f, 0.064443297f }, { -0.47464217f, 0.011895223f, 0.01123465f, -0.010697203f }, { -0.17670677f, -0.66931423f, -0.5814681f, -0.01325001f }, { 0.65193874f, -0.010713062f, -0.007915928f, -0.65520853f } }, { { -0.01027431f, -0.0019056004f, 0.0020213958f, 0.0064495753f }, { 0.0058416688f, 0.0051314639f, 0.021497114f, 0.005870592f }, { -0.00035518612f, -0.00087553938f, -0.0029318969f, 0.0087577986f }, { -0.0048770476f, -0.015949665f, -0.034816051f, -0.006104917f }, { 0.0015371362f, -0.0012591621f, 0.01241148f, 0.00096621463f }, { 0.0032416133f, 0.021025709f, 0.0036344622f, 0.0015436078f }, { -0.0093946276f, 0.0046564763f, 0.028177476f, -0.01022744f }, { 0.00014675555f, 0.030031482f, -0.0092302407f, -0.001999398f }, { -0.049980321f, 0.024752279f, 0.016684689f, -0.0045230976f }, { 0.0067493834f, 0.014071508f, 0.0079316435f, 0.034593704f }, { 0.01971715f, -0.0037227013f, -0.013430278f, -0.024257585f }, { -0.004342319f, 0.024001878f, -0.013356442f, -0.022792018f }, { -0.0051709665f, -0.017029547f, 0.040567567f, 0.0052520812f }, { 0.0090399102f, 0.0079604733f, 0.00018765016f, -0.0092868977f }, { -0.020304032f, 0.0056590257f, -0.0045373063f, -0.018653318f }, { -9.9636934e-05f, 0.002001886f, 0.0046843544f, 0.0055608043f }, { 0.0018025744f, -0.0025962216f, 0.0068285574f, -0.014851062f }, { 0.00041645221f, 0.0054738242f, 0.0076769026f, -0.013419208f }, { 0.0038347099f, -0.0042555066f, -0.0066470075f, 0.0039146778f }, { -0.009084153f, 0.024461537f, 0.0034578066f, -0.0054827001f }, { 0.0033463477f, 0.0045594748f, 0.00037604935f, -0.01571513f }, { -0.012589588f, 0.029678359f, -0.019924871f, -0.004708459f }, { -0.0002642682f, -0.0051057336f, -0.0042867302f, -0.00041141781f }, { -0.00086487068f, -0.0025170841f, 0.0030062196f, -0.0030385417f } }, { { -0.01027431f, -0.0019056004f, 0.0020213958f, 0.0064495753f }, { 0.0058416688f, 0.0051314639f, 0.021497114f, 0.005870592f }, { -0.00035518612f, -0.00087553938f, -0.0029318969f, 0.0087577986f }, { -0.0048770476f, -0.015949665f, -0.034816051f, -0.006104917f }, { 0.0015371362f, -0.0012591621f, 0.01241148f, 0.00096621463f }, { 0.0032416133f, 0.021025709f, 0.0036344622f, 0.0015436078f }, { -0.0093946276f, 0.0046564763f, 0.028177476f, -0.01022744f }, { 0.00014675555f, 0.030031482f, -0.0092302407f, -0.001999398f }, { -0.049980321f, 0.024752279f, 0.016684689f, -0.0045230976f }, { 0.0067493834f, 0.014071508f, 0.0079316435f, 0.034593704f }, { 0.01971715f, -0.0037227013f, -0.013430278f, -0.024257585f }, { -0.004342319f, 0.024001878f, -0.013356442f, -0.022792018f }, { -0.0051709665f, -0.017029547f, 0.040567567f, 0.0052520812f }, { 0.0090399102f, 0.0079604733f, 0.00018765016f, -0.0092868977f }, { -0.020304032f, 0.0056590257f, -0.0045373063f, -0.018653318f }, { -9.9636934e-05f, 0.002001886f, 0.0046843544f, 0.0055608043f }, { 0.0018025744f, -0.0025962216f, 0.0068285574f, -0.014851062f }, { 0.00041645221f, 0.0054738242f, 0.0076769026f, -0.013419208f }, { 0.0038347099f, -0.0042555066f, -0.0066470075f, 0.0039146778f }, { -0.009084153f, 0.024461537f, 0.0034578066f, -0.0054827001f }, { 0.0033463477f, 0.0045594748f, 0.00037604935f, -0.01571513f }, { -0.012589588f, 0.029678359f, -0.019924871f, -0.004708459f }, { -0.0002642682f, -0.0051057336f, -0.0042867302f, -0.00041141781f }, { -0.00086487068f, -0.0025170841f, 0.0030062196f, -0.0030385417f } } }, { { { -0.68772793f, 0.19029367f, -0.17427646f, 0.60300616f }, { -0.29980532f, -0.22397537f, -0.4071009f, 0.36277983f }, { 0.75628069f, -0.13426242f, 0.13645381f, -0.74653491f }, { 0.14891408f, -0.13497977f, 0.36807879f, -0.39814386f }, { -0.20608987f, -0.076497863f, -0.19510375f, 0.34604256f }, { -0.02421123f, -0.4588774f, -0.64965351f, 0.083039161f }, { 0.51918764f, -0.30614677f, -0.25791921f, -0.40837612f }, { 0.028860181f, 0.63152733f, 0.5876224f, -0.033139773f }, { -0.63418144f, 0.046874151f, 0.24431924f, 0.71662556f }, { -0.29088451f, -0.21455586f, -0.73980807f, 0.65038559f }, { 0.78663226f, 0.00020858525f, 0.40361403f, -0.75720144f }, { 0.1998276f, 0.54590973f, 0.1773378f, -0.35464319f }, { -0.40236144f, 0.31362578f, -0.34406026f, 0.38120073f }, { -0.27845549f, -0.46862161f, -0.47141499f, 0.095899189f }, { 0.6004921f, 0.28051621f, -0.011378178f, -0.98141078f }, { 0.032724674f, 0.66798127f, 0.66430425f, -0.05209965f }, { -0.59603974f, -0.083198329f, 0.34616224f, 0.42082916f }, { -0.14262632f, -0.21418442f, -0.37504914f, 0.32676687f }, { 0.58204273f, 0.0067537174f, -0.35923481f, -0.40792038f }, { 0.15607366f, 0.17215007f, 0.34414936f, -0.33566945f }, { -0.44862333f, 0.004919013f, 0.0076768115f, 0.41897935f }, { -0.022062848f, -0.39695079f, -0.0062786656f, 0.042925103f }, { 0.65953535f, -0.15521993f, 0.011867978f, -0.57721165f }, { 0.031305912f, 0.65627006f, 0.66779002f, -0.029815636f } }, { { 0.011457792f, -0.011774949f, -0.012205337f, 0.0048139052f }, { -0.024024566f, 0.018313023f, -0.023210623f, -0.0046351547f }, { 0.0039133571f, 0.0046801024f, -0.020590099f, -0.0018568631f }, { -0.015369931f, -0.0092621276f, -0.026149742f, 0.0010335971f }, { 0.032555144f, -0.01336897f, -0.022733265f, -0.027997469f }, { -0.028161537f, -0.00073877629f, -0.023989631f, 0.0055660453f }, { -0.012966193f, 0.003944376f, 0.025685982f, -0.0017458044f }, { 0.00015626641f, -0.009524206f, 0.0083025026f, -0.00049753811f }, { -0.02358661f, 0.006370149f, 0.00087066462f, -0.00054248544f }, { -0.0024571244f, -0.023218369f, -0.010895303f, -0.0095647684f }, { 0.0069970393f, -0.00093403301f, -0.0081922371f, -0.00026359768f }, { 0.0065921354f, 0.028846533f, -0.045676337f, 0.006070217f }, { 0.0045248423f, -0.0084676847f, 0.028756195f, 0.020612871f }, { 0.0037691244f, -0.0069385161f, -0.00029501448f, -0.0017839033f }, { -0.0048675353f, -0.011930456f, 0.0044251285f, -0.00016323616f }, { -0.0012291164f, -0.0019575288f, 0.0078250029f, -0.0011151155f }, { 0.00503333f, -0.0094538968f, 0.0092375183f, 0.018207648f }, { 0.0080615812f, -0.0073583459f, -0.0166794f, 0.016416158f }, { 0.002192959f, -0.01153759f, -0.0048668362f, -0.0071123281f }, { -0.010116143f, -0.010224552f, 0.010897731f, 0.00093792816f }, { 0.017199359f, -0.0087516179f, 0.0021169251f, -0.020946959f }, { -0.01570063f, 0.020087246f, 0.014492818f, -0.016014018f }, { 0.0023484072f, 0.0015070243f, -0.00045616273f, -0.001211882f }, { 0.0018090492f, -0.0012261901f, 0.0012809284f, 0.00096488905f } }, { { 0.011457792f, -0.011774949f, -0.012205337f, 0.0048139052f }, { -0.024024566f, 0.018313023f, -0.023210623f, -0.0046351547f }, { 0.0039133571f, 0.0046801024f, -0.020590099f, -0.0018568631f }, { -0.015369931f, -0.0092621276f, -0.026149742f, 0.0010335971f }, { 0.032555144f, -0.01336897f, -0.022733265f, -0.027997469f }, { -0.028161537f, -0.00073877629f, -0.023989631f, 0.0055660453f }, { -0.012966193f, 0.003944376f, 0.025685982f, -0.0017458044f }, { 0.00015626641f, -0.009524206f, 0.0083025026f, -0.00049753811f }, { -0.02358661f, 0.006370149f, 0.00087066462f, -0.00054248544f }, { -0.0024571244f, -0.023218369f, -0.010895303f, -0.0095647684f }, { 0.0069970393f, -0.00093403301f, -0.0081922371f, -0.00026359768f }, { 0.0065921354f, 0.028846533f, -0.045676337f, 0.006070217f }, { 0.0045248423f, -0.0084676847f, 0.028756195f, 0.020612871f }, { 0.0037691244f, -0.0069385161f, -0.00029501448f, -0.0017839033f }, { -0.0048675353f, -0.011930456f, 0.0044251285f, -0.00016323616f }, { -0.0012291164f, -0.0019575288f, 0.0078250029f, -0.0011151155f }, { 0.00503333f, -0.0094538968f, 0.0092375183f, 0.018207648f }, { 0.0080615812f, -0.0073583459f, -0.0166794f, 0.016416158f }, { 0.002192959f, -0.01153759f, -0.0048668362f, -0.0071123281f }, { -0.010116143f, -0.010224552f, 0.010897731f, 0.00093792816f }, { 0.017199359f, -0.0087516179f, 0.0021169251f, -0.020946959f }, { -0.01570063f, 0.020087246f, 0.014492818f, -0.016014018f }, { 0.0023484072f, 0.0015070243f, -0.00045616273f, -0.001211882f }, { 0.0018090492f, -0.0012261901f, 0.0012809284f, 0.00096488905f } } }, { { { 0.71476997f, 0.61525336f, 0.81507512f, 0.79550964f }, { 0.87986984f, 0.9232123f, 0.74974956f, 0.82765975f }, { 0.65321366f, 0.82580437f, 0.63434042f, 0.54903231f }, { 0.97390084f, 0.98050251f, 0.83713283f, 0.72370416f }, { 0.97570877f, 0.88760866f, 0.88668363f, 0.9380218f }, { 0.89705541f, 0.88675351f, 0.75595095f, 0.83467284f }, { 0.77232433f, 0.77447327f, 0.9084134f, 0.84734569f }, { -0.75720667f, -0.77520488f, -0.80639546f, -0.76219811f }, { 0.77130152f, 0.83806694f, 0.60983327f, 0.56357207f }, { 0.91090229f, 0.84089752f, 0.54694041f, 0.59085922f }, { 0.60775044f, 0.58913818f, 0.53197627f, 0.53574024f }, { 0.96044628f, 0.83405513f, 0.88888419f, 0.55105253f }, { 0.79850486f, 0.83676557f, 0.83574428f, 0.86369517f }, { 0.89597751f, 0.83876978f, 0.87336884f, 0.8934314f }, { 0.77801249f, 0.78253947f, 0.10680725f, 0.19167855f }, { -0.74415432f, -0.74320194f, -0.74587957f, -0.72660186f }, { 0.802783f, 0.78016447f, 0.79046691f, 0.87952719f }, { 0.97537479f, 0.92311625f, 0.79848027f, 0.80910594f }, { 0.8125306f, 0.82679528f, 0.81929639f, 0.88516002f }, { 0.97152309f, 0.98181547f, 0.82815966f, 0.81791703f }, { 0.87129411f, 0.56410602f, 0.87800085f, 0.905706f }, { 0.87990229f, 0.91776281f, 0.99991718f, 0.99902102f }, { 0.73060786f, 0.72658464f, 0.81348263f, 0.81648708f }, { -0.75762512f, -0.75445002f, -0.74430762f, -0.75485946f } }, { { 0.018332644f, 0.0084005452f, -0.0018937689f, -0.0035491975f }, { 0.0016556654f, 0.0049261013f, -0.021796869f, 0.0025973591f }, { -0.0019671758f, 0.00051947074f, 0.0071261223f, 0.0056689139f }, { 0.00041901024f, -0.0023903288f, -0.0035639711f, -0.0036673013f }, { 0.009963464f, 0.00099195429f, -0.0042516892f, 0.0092605531f }, { 0.0034813664f, 0.0028575465f, -0.016343415f, -0.0014475905f }, { 0.0053571039f, 0.0051116063f, 0.016171091f, -0.00052744238f }, { 0.00013272575f, -0.0095491849f, 0.0070156475f, 0.0017057538f }, { 0.028067438f, -0.0086835729f, -0.0087852674f, 0.0035321054f }, { 0.0025007808f, -0.0075654884f, -0.012551417f, -0.0068823899f }, { -0.00017607308f, 0.002636122f, -0.011272055f, -0.010314896f }, { 0.010646599f, 0.00042804331f, 0.013900837f, -0.01279076f }, { 0.0059898286f, 0.012331371f, -0.0073125296f, 0.016248603f }, { 0.031579315f, -0.0057840222f, -0.00018304192f, 0.005171422f }, { 0.010928513f, 0.0092660887f, 0.030404621f, 0.0053167707f }, { -0.00014899672f, -0.0035246494f, 0.0075862845f, -0.005861723f }, { 0.0067791918f, 0.0021224495f, -0.0071755505f, -0.010370936f }, { 0.0015352958f, -0.0025785166f, -0.0092688001f, 0.003966373f }, { 0.0036915074f, -0.002306452f, -0.005736452f, -0.0033594125f }, { 0.0065128512f, 0.006188005f, 0.00088322638f, -0.0016227066f }, { 0.0092720771f, -0.0046684631f, -7.3769604e-05f, 0.013807013f }, { -0.0031421984f, 0.010622679f, 0.00041591214f, 0.0032786075f }, { -0.0021421613f, -0.0041675589f, -0.0029529994f, -0.00085350449f }, { -0.00069204344f, -0.0010785124f, 0.00097549628f, 0.0025280456f } }, { { 0.018332644f, 0.0084005452f, -0.0018937689f, -0.0035491975f }, { 0.0016556654f, 0.0049261013f, -0.021796869f, 0.0025973591f }, { -0.0019671758f, 0.00051947074f, 0.0071261223f, 0.0056689139f }, { 0.00041901024f, -0.0023903288f, -0.0035639711f, -0.0036673013f }, { 0.009963464f, 0.00099195429f, -0.0042516892f, 0.0092605531f }, { 0.0034813664f, 0.0028575465f, -0.016343415f, -0.0014475905f }, { 0.0053571039f, 0.0051116063f, 0.016171091f, -0.00052744238f }, { 0.00013272575f, -0.0095491849f, 0.0070156475f, 0.0017057538f }, { 0.028067438f, -0.0086835729f, -0.0087852674f, 0.0035321054f }, { 0.0025007808f, -0.0075654884f, -0.012551417f, -0.0068823899f }, { -0.00017607308f, 0.002636122f, -0.011272055f, -0.010314896f }, { 0.010646599f, 0.00042804331f, 0.013900837f, -0.01279076f }, { 0.0059898286f, 0.012331371f, -0.0073125296f, 0.016248603f }, { 0.031579315f, -0.0057840222f, -0.00018304192f, 0.005171422f }, { 0.010928513f, 0.0092660887f, 0.030404621f, 0.0053167707f }, { -0.00014899672f, -0.0035246494f, 0.0075862845f, -0.005861723f }, { 0.0067791918f, 0.0021224495f, -0.0071755505f, -0.010370936f }, { 0.0015352958f, -0.0025785166f, -0.0092688001f, 0.003966373f }, { 0.0036915074f, -0.002306452f, -0.005736452f, -0.0033594125f }, { 0.0065128512f, 0.006188005f, 0.00088322638f, -0.0016227066f }, { 0.0092720771f, -0.0046684631f, -7.3769604e-05f, 0.013807013f }, { -0.0031421984f, 0.010622679f, 0.00041591214f, 0.0032786075f }, { -0.0021421613f, -0.0041675589f, -0.0029529994f, -0.00085350449f }, { -0.00069204344f, -0.0010785124f, 0.00097549628f, 0.0025280456f } } }, { { { 5.3792285f, 5.1960477f, 5.5112916f, 5.6615254f }, { 5.0489877f, 5.2428834f, 5.1752035f, 5.1109826f }, { 5.5205204f, 5.7511938f, 5.0202917f, 4.9168865f }, { 4.9522523f, 4.8880256f, 5.1015936f, 5.2858816f }, { 5.7256502f, 5.7919759f, 5.645241f, 5.6035708f }, { 6.4076931f, 6.4822111f, 6.2642633f, 6.3925959f }, { 6.9797014f, 6.981436f, 7.0028674f, 6.9976464f }, { -0.03290957f, -0.03290957f, -0.03290957f, -0.03290957f }, { 5.4977854f, 5.7684965f, 5.3463095f, 4.8810492f }, { 4.9869047f, 5.4896416f, 4.9647805f, 4.884877f }, { 5.3141219f, 5.3357788f, 4.7695434f, 4.8709631f }, { 5.2056063f, 5.407802f, 5.2123857f, 4.9428208f }, { 6.2188218f, 6.17756f, 6.2751008f, 6.3672109f }, { 6.9105856f, 6.7986798f, 6.5712335f, 6.5907061f }, { 6.9797014f, 6.9797014f, 5.6859993f, 5.5642483f }, { -0.032764603f, -0.032764603f, -0.032764603f, -0.032764603f }, { 5.7724142f, 6.0929556f, 5.99581f, 5.9265164f }, { 4.9363192f, 4.9823732f, 5.1732995f, 5.2475265f }, { 5.8365191f, 5.9972902f, 5.9778441f, 5.9270668f }, { 4.8706768f, 5.0194503f, 5.155585f, 5.2188041f }, { 6.1569904f, 6.0563989f, 6.0989699f, 6.2139837f }, { 5.8727399f, 5.8948086f, 5.5734095f, 5.5536103f }, { 6.9797014f, 6.9797014f, 6.9797014f, 6.9797014f }, { -0.032766769f, -0.032766769f, -0.032766769f, -0.032766769f } }, { { 0.0011802354f, -0.006546101f, -0.02103972f, 0.0008654047f }, { -0.015460534f, 0.017874544f, 0.0029121134f, 0.023511773f }, { -0.040909245f, 0.011927691f, 0.011991588f, 0.01677931f }, { -0.015633544f, -0.0042321141f, 0.026623034f, 0.0080414514f }, { 0.012614382f, 0.0065080145f, 0.035716738f, -0.0080665814f }, { -0.0057849744f, -0.017478461f, -0.031219642f, 0.00016446523f }, { 0.0f, 0.00032235028f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { -0.068586697f, -0.024228236f, -0.012857221f, -0.039493706f }, { -0.018078201f, -0.015140979f, 0.00072119173f, -0.051249859f }, { -0.054228277f, 0.0097895101f, 0.0019832646f, -0.011715411f }, { -0.042326208f, -0.010160072f, 0.037088052f, -0.031848667f }, { 0.00067130897f, -0.013966717f, -0.017268559f, -0.0074614576f }, { 0.070515961f, 0.012848107f, -0.0008396517f, 0.0049006506f }, { 0.0f, 0.0f, -0.063014256f, -0.0085124986f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { -0.040302299f, 0.0048936307f, 0.0064406394f, 0.0034044871f }, { -0.010453589f, 0.0035820836f, -0.017384391f, -0.038199947f }, { -0.044968611f, -0.0088322127f, 0.020303819f, 0.0058131005f }, { -0.0056838535f, 0.010211409f, -0.010999927f, -0.027621859f }, { 0.0064753811f, -0.0059341242f, -0.014902755f, 0.0082868118f }, { -0.0013222735f, 0.0028492181f, -0.023523273f, -0.02576271f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f } }, { { 0.0011802354f, -0.006546101f, -0.02103972f, 0.00086540469f }, { -0.015460534f, 0.017874544f, 0.0029121134f, 0.023511773f }, { -0.040909245f, 0.011927691f, 0.011991588f, 0.01677931f }, { -0.015633544f, -0.0042321141f, 0.026623034f, 0.0080414514f }, { 0.012614382f, 0.0065080145f, 0.035716738f, -0.0080665814f }, { -0.0057849744f, -0.017478461f, -0.031219642f, 0.00016446523f }, { 0.0f, 0.00032235028f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { -0.068586697f, -0.024228236f, -0.012857221f, -0.039493706f }, { -0.018078201f, -0.015140979f, 0.00072119173f, -0.051249859f }, { -0.054228277f, 0.0097895101f, 0.0019832646f, -0.011715411f }, { -0.042326208f, -0.010160072f, 0.037088052f, -0.031848667f }, { 0.00067130897f, -0.013966717f, -0.017268559f, -0.0074614576f }, { 0.070515961f, 0.012848107f, -0.0008396517f, 0.0049006506f }, { 0.0f, 0.0f, -0.063014256f, -0.0085124986f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { -0.040302299f, 0.0048936307f, 0.0064406394f, 0.0034044871f }, { -0.010453589f, 0.0035820836f, -0.017384391f, -0.038199947f }, { -0.044968611f, -0.0088322127f, 0.020303819f, 0.0058131005f }, { -0.0056838535f, 0.010211409f, -0.010999927f, -0.027621859f }, { 0.0064753811f, -0.0059341242f, -0.014902755f, 0.0082868118f }, { -0.0013222735f, 0.0028492181f, -0.023523273f, -0.02576271f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f } } }, { { { 0.72189984f, 0.22069996f, 0.71952927f, 0.77725949f }, { 0.4054405f, 0.20582059f, 0.2747016f, 0.37612563f }, { 0.58887422f, 0.27441131f, 0.19468101f, 0.21480554f }, { 0.46814145f, 0.34317f, 0.46068212f, 0.13962064f }, { -0.18134132f, -0.26668789f, -0.60984999f, -0.67879259f }, { -0.47870351f, -0.34453227f, 0.32494779f, 0.10292971f }, { 0.087252967f, 0.066950358f, 0.31813819f, 0.071094818f }, { -0.0031436256f, 0.038245091f, -0.0076651913f, -0.015389479f }, { 1.2668531f, 1.2894974f, 0.40584018f, 0.51755806f }, { 1.3207257f, 1.3403747f, 0.54924634f, 0.40282713f }, { 0.78581828f, 0.56379328f, 0.27901993f, 0.56429306f }, { 0.8748226f, 1.0271253f, 1.0085726f, 0.3888545f }, { -0.22577636f, -0.32895071f, -0.2846317f, -0.11679531f }, { 0.26477285f, 0.3179447f, -0.063393238f, 0.024059773f }, { -0.15463395f, -0.22721468f, -0.20680404f, -0.15700788f }, { 0.012107106f, -0.0061245949f, -0.024224367f, 0.005040693f }, { 0.97943693f, 0.64840429f, 0.45106998f, 0.40771935f }, { 0.49907853f, 0.1562184f, 0.34338458f, 0.39710628f }, { 0.95047709f, 0.53336107f, 0.38318275f, 0.44919148f }, { 0.41892697f, 0.069965886f, 0.45831656f, 0.38821529f }, { -0.20216736f, -0.43209441f, -0.57684857f, -0.40189427f }, { -0.63992377f, -0.40683032f, -0.59207903f, -0.57251716f }, { -0.047117438f, -0.1880015f, -0.12265155f, 0.00059988607f }, { -0.011836442f, -0.010049497f, -0.0026152072f, 0.016137736f } }, { { 0.092068993f, 0.0045466749f, 0.0054574031f, 0.02582156f }, { 0.022115456f, -0.015664041f, -0.022004653f, 0.041431654f }, { 0.029951298f, -0.0004408542f, 0.0087496069f, 0.017850027f }, { 0.029086373f, 0.022116039f, 0.044010315f, 0.001644876f }, { 0.016256387f, 0.0083249367f, 0.019570849f, -0.0021276222f }, { 0.0079070076f, -0.024696939f, 0.044311101f, 0.023671132f }, { -0.0081796119f, -0.0024995551f, 0.033501743f, -0.031958988f }, { 0.0065005403f, -0.076642001f, 0.015736477f, 0.030966939f }, { 0.029110717f, 0.039154477f, -0.074376619f, 0.025532063f }, { -0.10980761f, 0.0038346834f, 0.014449171f, -0.030702653f }, { -0.00068350423f, -0.037251569f, -0.008409224f, -0.026322878f }, { 0.035406012f, 0.064176275f, 0.031437854f, -0.0344642f }, { 0.037145809f, -0.024909212f, 0.041030386f, 0.035216105f }, { -0.093276646f, -0.013904083f, -0.019536023f, -0.023834405f }, { 0.042751846f, -0.03620164f, 0.081115921f, 0.018379967f }, { -0.023909625f, 0.012833691f, 0.048086442f, -0.0097340268f }, { 0.039552712f, -0.00026806514f, 0.011646753f, 0.0065939486f }, { 0.058985248f, 0.020165701f, 0.0076721521f, 0.033274221f }, { 0.052889871f, 0.0042520093f, 0.016490396f, 0.009287973f }, { 0.044305975f, -0.0016263469f, 0.041390177f, 0.033541355f }, { 0.014595133f, -0.004801042f, -0.0049517302f, 0.015714264f }, { 0.00075086205f, 0.0080838736f, -0.037611057f, -0.030488441f }, { 0.0019178075f, -0.0082517768f, -0.002525773f, 0.0043993022f }, { 0.023774971f, 0.020335611f, 0.0056643868f, -0.032100338f } }, { { 0.092068993f, 0.0045466749f, 0.0054574031f, 0.02582156f }, { 0.022115456f, -0.015664041f, -0.022004653f, 0.041431654f }, { 0.029951298f, -0.0004408542f, 0.0087496069f, 0.017850027f }, { 0.029086373f, 0.022116039f, 0.044010315f, 0.001644876f }, { 0.016256387f, 0.0083249367f, 0.019570849f, -0.0021276222f }, { 0.0079070076f, -0.024696939f, 0.044311101f, 0.023671132f }, { -0.0081796119f, -0.0024995551f, 0.033501743f, -0.031958988f }, { 0.0065005403f, -0.076642001f, 0.015736477f, 0.030966939f }, { 0.029110717f, 0.039154477f, -0.074376619f, 0.025532063f }, { -0.10980761f, 0.0038346834f, 0.014449171f, -0.030702653f }, { -0.00068350423f, -0.037251569f, -0.008409224f, -0.026322878f }, { 0.035406012f, 0.064176275f, 0.031437854f, -0.0344642f }, { 0.037145809f, -0.024909212f, 0.041030386f, 0.035216105f }, { -0.093276646f, -0.013904083f, -0.019536023f, -0.023834405f }, { 0.042751846f, -0.03620164f, 0.081115921f, 0.018379967f }, { -0.023909625f, 0.012833691f, 0.048086442f, -0.0097340268f }, { 0.039552712f, -0.00026806514f, 0.011646753f, 0.0065939486f }, { 0.058985248f, 0.020165701f, 0.0076721521f, 0.033274221f }, { 0.052889871f, 0.0042520093f, 0.016490396f, 0.009287973f }, { 0.044305975f, -0.0016263469f, 0.041390177f, 0.033541355f }, { 0.014595133f, -0.004801042f, -0.0049517303f, 0.015714264f }, { 0.00075086205f, 0.0080838736f, -0.037611057f, -0.030488441f }, { 0.0019178075f, -0.0082517768f, -0.002525773f, 0.0043993022f }, { 0.023774971f, 0.020335611f, 0.0056643868f, -0.032100338f } } } } };
#endif
diff --git a/thirdparty/misc/hq2x.cpp b/thirdparty/misc/hq2x.cpp
deleted file mode 100644
index 9c089ba85c..0000000000
--- a/thirdparty/misc/hq2x.cpp
+++ /dev/null
@@ -1,2636 +0,0 @@
-/*
- * Copyright 2016 Bruno Ribeiro
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "hq2x.h"
-
-#include "core/math/math_funcs.h"
-
-static const uint32_t AMASK = 0xFF000000;
-static const uint32_t YMASK = 0x00FF0000;
-static const uint32_t UMASK = 0x0000FF00;
-static const uint32_t VMASK = 0x000000FF;
-
-_FORCE_INLINE_ static uint32_t ARGBtoAYUV(
- uint32_t value )
-{
- uint32_t A, R, G, B, Y, U, V;
-//todo big endian check
- A = value >> 24;
- R = (value >> 16) & 0xFF;
- G = (value >> 8) & 0xFF;
- B = value & 0xFF;
-
- Y = Math::fast_ftoi( 0.299 * R + 0.587 * G + 0.114 * B);
- U = Math::fast_ftoi(-0.169 * R - 0.331 * G + 0.5 * B) + 128;
- V = Math::fast_ftoi( 0.5 * R - 0.419 * G - 0.081 * B) + 128;
- return (A << 24) + (Y << 16) + (U << 8) + V;
-}
-
-
-/*
- * Use this function for sharper images (good for cartoon style, used by DOSBOX)
- */
-
-_FORCE_INLINE_ static bool isDifferent(
- uint32_t color1,
- uint32_t color2,
- uint32_t trY,
- uint32_t trU,
- uint32_t trV,
- uint32_t trA )
-{
- color1 = ARGBtoAYUV(color1);
- color2 = ARGBtoAYUV(color2);
-
- uint32_t value;
-
- value = ((color1 & YMASK) - (color2 & YMASK));
- value = (value ^ (value >> 31)) - (value >> 31);
- if (value > trY) return true;
-
- value = ((color1 & UMASK) - (color2 & UMASK));
- value = (value ^ (value >> 31)) - (value >> 31);
- if (value > trU) return true;
-
- value = ((color1 & VMASK) - (color2 & VMASK));
- value = (value ^ (value >> 31)) - (value >> 31);
- if (value > trV) return true;
-
- value = ((color1 & AMASK) - (color2 & AMASK));
- value = (value ^ (value >> 31)) - (value >> 31);
- if (value > trA) return true;
-
- return false;
-
-}
-
-
-
-#define MASK_RB 0x00FF00FF
-#define MASK_G 0x0000FF00
-#define MASK_A 0xFF000000
-
-
-/**
- * @brief Mixes two colors using the given weights.
- */
-#define HQX_MIX_2(C0,C1,W0,W1) \
- ((((C0 & MASK_RB) * W0 + (C1 & MASK_RB) * W1) / (W0 + W1)) & MASK_RB) | \
- ((((C0 & MASK_G) * W0 + (C1 & MASK_G) * W1) / (W0 + W1)) & MASK_G) | \
- ((((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1) / (W0 + W1)) << 8) & MASK_A)
-
-/**
- * @brief Mixes three colors using the given weights.
- */
-#define HQX_MIX_3(C0,C1,C2,W0,W1,W2) \
- ((((C0 & MASK_RB) * W0 + (C1 & MASK_RB) * W1 + (C2 & MASK_RB) * W2) / (W0 + W1 + W2)) & MASK_RB) | \
- ((((C0 & MASK_G) * W0 + (C1 & MASK_G) * W1 + (C2 & MASK_G) * W2) / (W0 + W1 + W2)) & MASK_G) | \
- ((((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1 + ((C2 & MASK_A) >> 8) * W2) / (W0 + W1 + W2)) << 8) & MASK_A)
-
-
-#define MIX_00_4 *output = w[4];
-#define MIX_00_MIX_00_4_0_3_1 *output = HQX_MIX_2(w[4],w[0],3U,1U);
-#define MIX_00_4_3_3_1 *output = HQX_MIX_2(w[4],w[3],3U,1U);
-#define MIX_00_4_1_3_1 *output = HQX_MIX_2(w[4],w[1],3U,1U);
-#define MIX_00_3_1_1_1 *output = HQX_MIX_2(w[3],w[1],1U,1U);
-#define MIX_00_4_3_1_2_1_1 *output = HQX_MIX_3(w[4],w[3],w[1],2U,1U,1U);
-#define MIX_00_4_3_1_2_7_7 *output = HQX_MIX_3(w[4],w[3],w[1],2U,7U,7U);
-#define MIX_00_4_0_1_2_1_1 *output = HQX_MIX_3(w[4],w[0],w[1],2U,1U,1U);
-#define MIX_00_4_0_3_2_1_1 *output = HQX_MIX_3(w[4],w[0],w[3],2U,1U,1U);
-#define MIX_00_4_1_3_5_2_1 *output = HQX_MIX_3(w[4],w[1],w[3],5U,2U,1U);
-#define MIX_00_4_3_1_5_2_1 *output = HQX_MIX_3(w[4],w[3],w[1],5U,2U,1U);
-#define MIX_00_4_3_1_6_1_1 *output = HQX_MIX_3(w[4],w[3],w[1],6U,1U,1U);
-#define MIX_00_4_3_1_2_3_3 *output = HQX_MIX_3(w[4],w[3],w[1],2U,3U,3U);
-#define MIX_00_MIX_00_4_0_3_10 *output = HQX_MIX_3(w[4],w[3],w[1],14U,1U,1U);
-
-#define MIX_01_4 *(output + 1) = w[4];
-#define MIX_01_4_2_3_1 *(output + 1) = HQX_MIX_2(w[4],w[2],3U,1U);
-#define MIX_01_4_1_3_1 *(output + 1) = HQX_MIX_2(w[4],w[1],3U,1U);
-#define MIX_01_1_4_3_1 *(output + 1) = HQX_MIX_2(w[1],w[4],3U,1U);
-#define MIX_01_4_5_3_1 *(output + 1) = HQX_MIX_2(w[4],w[5],3U,1U);
-#define MIX_01_4_1_7_1 *(output + 1) = HQX_MIX_2(w[4],w[1],7U,1U);
-#define MIX_01_4_1_5_2_1_1 *(output + 1) = HQX_MIX_3(w[4],w[1],w[5],2U,1U,1U);
-#define MIX_01_4_2_5_2_1_1 *(output + 1) = HQX_MIX_3(w[4],w[2],w[5],2U,1U,1U);
-#define MIX_01_4_2_1_2_1_1 *(output + 1) = HQX_MIX_3(w[4],w[2],w[1],2U,1U,1U);
-#define MIX_01_4_5_1_5_2_1 *(output + 1) = HQX_MIX_3(w[4],w[5],w[1],5U,2U,1U);
-#define MIX_01_4_1_5_5_2_1 *(output + 1) = HQX_MIX_3(w[4],w[1],w[5],5U,2U,1U);
-#define MIX_01_4_1_5_6_1_1 *(output + 1) = HQX_MIX_3(w[4],w[1],w[5],6U,1U,1U);
-#define MIX_01_4_1_5_2_3_3 *(output + 1) = HQX_MIX_3(w[4],w[1],w[5],2U,3U,3U);
-#define MIX_01_4_2_3_10 *(output + 1) = HQX_MIX_3(w[4],w[1],w[5],14U,1U,1U);
-
-#define MIX_02_4 *(output + 2) = w[4];
-#define MIX_02_4_2_3_1 *(output + 2) = HQX_MIX_2(w[4],w[2],3U,1U);
-#define MIX_02_4_1_3_1 *(output + 2) = HQX_MIX_2(w[4],w[1],3U,1U);
-#define MIX_02_4_5_3_1 *(output + 2) = HQX_MIX_2(w[4],w[5],3U,1U);
-#define MIX_02_4_1_5_2_1_1 *(output + 2) = HQX_MIX_3(w[4],w[1],w[5],2U,1U,1U);
-#define MIX_02_4_1_5_2_7_7 *(output + 2) = HQX_MIX_3(w[4],w[1],w[5],2U,7U,7U);
-#define MIX_02_1_5_1_1 *(output + 2) = HQX_MIX_2(w[1],w[5],1U,1U);
-
-#define MIX_10_4 *(output + lineSize) = w[4];
-#define MIX_10_4_6_3_1 *(output + lineSize) = HQX_MIX_2(w[4],w[6],3U,1U);
-#define MIX_10_4_7_3_1 *(output + lineSize) = HQX_MIX_2(w[4],w[7],3U,1U);
-#define MIX_10_4_3_3_1 *(output + lineSize) = HQX_MIX_2(w[4],w[3],3U,1U);
-#define MIX_10_4_7_3_2_1_1 *(output + lineSize) = HQX_MIX_3(w[4],w[7],w[3],2U,1U,1U);
-#define MIX_10_4_6_3_2_1_1 *(output + lineSize) = HQX_MIX_3(w[4],w[6],w[3],2U,1U,1U);
-#define MIX_10_4_6_7_2_1_1 *(output + lineSize) = HQX_MIX_3(w[4],w[6],w[7],2U,1U,1U);
-#define MIX_10_4_3_7_5_2_1 *(output + lineSize) = HQX_MIX_3(w[4],w[3],w[7],5U,2U,1U);
-#define MIX_10_4_7_3_5_2_1 *(output + lineSize) = HQX_MIX_3(w[4],w[7],w[3],5U,2U,1U);
-#define MIX_10_4_7_3_6_1_1 *(output + lineSize) = HQX_MIX_3(w[4],w[7],w[3],6U,1U,1U);
-#define MIX_10_4_7_3_2_3_3 *(output + lineSize) = HQX_MIX_3(w[4],w[7],w[3],2U,3U,3U);
-#define MIX_10_4_6_3_10 *(output + lineSize) = HQX_MIX_3(w[4],w[7],w[3],14U,1U,1U);
-#define MIX_10_4_3_7_1 *(output + lineSize) = HQX_MIX_2(w[4],w[3],7U,1U);
-#define MIX_10_3_4_3_1 *(output + lineSize) = HQX_MIX_2(w[3],w[4],3U,1U);
-
-#define MIX_11_4 *(output + lineSize + 1) = w[4];
-#define MIX_11_4_8_3_1 *(output + lineSize + 1) = HQX_MIX_2(w[4],w[8],3U,1U);
-#define MIX_11_4_5_3_1 *(output + lineSize + 1) = HQX_MIX_2(w[4],w[5],3U,1U);
-#define MIX_11_4_7_3_1 *(output + lineSize + 1) = HQX_MIX_2(w[4],w[7],3U,1U);
-#define MIX_11_4_5_7_2_1_1 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[5],w[7],2U,1U,1U);
-#define MIX_11_4_8_7_2_1_1 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[8],w[7],2U,1U,1U);
-#define MIX_11_4_8_5_2_1_1 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[8],w[5],2U,1U,1U);
-#define MIX_11_4_7_5_5_2_1 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[7],w[5],5U,2U,1U);
-#define MIX_11_4_5_7_5_2_1 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[5],w[7],5U,2U,1U);
-#define MIX_11_4_5_7_6_1_1 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[5],w[7],6U,1U,1U);
-#define MIX_11_4_5_7_2_3_3 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[5],w[7],2U,3U,3U);
-#define MIX_11_4_8_3_10 *(output + lineSize + 1) = HQX_MIX_3(w[4],w[5],w[7],14U,1U,1U);
-
-#define MIX_12_4 *(output + lineSize + 2) = w[4];
-#define MIX_12_4_5_3_1 *(output + lineSize + 2) = HQX_MIX_2(w[4],w[5],3U,1U);
-#define MIX_12_4_5_7_1 *(output + lineSize + 2) = HQX_MIX_2(w[4],w[5],7U,1U);
-#define MIX_12_5_4_3_1 *(output + lineSize + 2) = HQX_MIX_2(w[5],w[4],3U,1U);
-
-#define MIX_20_4 *(output + lineSize + lineSize) = w[4];
-#define MIX_20_4_6_3_1 *(output + lineSize + lineSize) = HQX_MIX_2(w[4],w[6],3U,1U);
-#define MIX_20_4_7_3_1 *(output + lineSize + lineSize) = HQX_MIX_2(w[4],w[7],3U,1U);
-#define MIX_20_4_3_3_1 *(output + lineSize + lineSize) = HQX_MIX_2(w[4],w[3],3U,1U);
-#define MIX_20_4_7_3_2_1_1 *(output + lineSize + lineSize) = HQX_MIX_3(w[4],w[7],w[3],2U,1U,1U);
-#define MIX_20_4_7_3_2_7_7 *(output + lineSize + lineSize) = HQX_MIX_3(w[4],w[7],w[3],2U,7U,7U);
-#define MIX_20_7_3_1_1 *(output + lineSize + lineSize) = HQX_MIX_2(w[7],w[3],1U,1U);
-
-#define MIX_21_4 *(output + lineSize + lineSize + 1) = w[4];
-#define MIX_21_4_7_3_1 *(output + lineSize + lineSize + 1) = HQX_MIX_2(w[4],w[7],3U,1U);
-#define MIX_21_4_7_7_1 *(output + lineSize + lineSize + 1) = HQX_MIX_2(w[4],w[7],7U,1U);
-#define MIX_21_7_4_3_1 *(output + lineSize + lineSize + 1) = HQX_MIX_2(w[7],w[4],3U,1U);
-
-#define MIX_22_4 *(output + lineSize + lineSize + 2) = w[4];
-#define MIX_22_4_8_3_1 *(output + lineSize + lineSize + 2) = HQX_MIX_2(w[4],w[8],3U,1U);
-#define MIX_22_4_7_3_1 *(output + lineSize + lineSize + 2) = HQX_MIX_2(w[4],w[7],3U,1U);
-#define MIX_22_4_5_3_1 *(output + lineSize + lineSize + 2) = HQX_MIX_2(w[4],w[5],3U,1U);
-#define MIX_22_4_5_7_2_1_1 *(output + lineSize + lineSize + 2) = HQX_MIX_3(w[4],w[5],w[7],2U,1U,1U);
-#define MIX_22_4_5_7_2_7_7 *(output + lineSize + lineSize + 2) = HQX_MIX_3(w[4],w[5],w[7],2U,7U,7U);
-#define MIX_22_5_7_1_1 *(output + lineSize + lineSize + 2) = HQX_MIX_2(w[5],w[7],1U,1U);
-
-
-
-uint32_t *hq2x_resize(
- const uint32_t *image,
- uint32_t width,
- uint32_t height,
- uint32_t *output,
- uint32_t trY,
- uint32_t trU,
- uint32_t trV,
- uint32_t trA,
- bool wrapX,
- bool wrapY )
-{
- int lineSize = width * 2;
-
- int previous, next;
- uint32_t w[9];
-
- trY <<= 16;
- trU <<= 8;
- trA <<= 24;
-
- // iterates between the lines
- for (uint32_t row = 0; row < height; row++)
- {
- /*
- * Note: this function uses a 3x3 sliding window over the original image.
- *
- * +----+----+----+
- * | | | |
- * | w0 | w1 | w2 |
- * +----+----+----+
- * | | | |
- * | w3 | w4 | w5 |
- * +----+----+----+
- * | | | |
- * | w6 | w7 | w8 |
- * +----+----+----+
- */
-
- // adjusts the previous and next line pointers
- if (row > 0)
- previous = -width;
- else
- {
- if (wrapY)
- previous = width * (height - 1);
- else
- previous = 0;
- }
- if (row < height - 1)
- next = width;
- else
- {
- if (wrapY)
- next = -(width * (height - 1));
- else
- next = 0;
- }
-
- // iterates between the columns
- for (uint32_t col = 0; col < width; col++)
- {
- w[1] = *(image + previous);
- w[4] = *image;
- w[7] = *(image + next);
-
- if (col > 0)
- {
- w[0] = *(image + previous - 1);
- w[3] = *(image - 1);
- w[6] = *(image + next - 1);
- }
- else
- {
- if (wrapX)
- {
- w[0] = *(image + previous + width - 1);
- w[3] = *(image + width - 1);
- w[6] = *(image + next + width - 1);
- }
- else
- {
- w[0] = w[1];
- w[3] = w[4];
- w[6] = w[7];
- }
- }
-
- if (col < width - 1)
- {
- w[2] = *(image + previous + 1);
- w[5] = *(image + 1);
- w[8] = *(image + next + 1);
- }
- else
- {
- if (wrapX)
- {
- w[2] = *(image + previous - width + 1);
- w[5] = *(image - width + 1);
- w[8] = *(image + next - width + 1);
- }
- else
- {
- w[2] = w[1];
- w[5] = w[4];
- w[8] = w[7];
- }
- }
-
- int pattern = 0;
-
- // computes the pattern to be used considering the neighbor pixels
- for (int k = 0, flag = 1; k < 9; k++)
- {
- // ignores the central pixel
- if (k == 4) continue;
-
- if (w[k] != w[4])
- if (isDifferent(w[4], w[k], trY, trU, trV, trA)) pattern |= flag;
- flag <<= 1;
- }
-
- switch (pattern)
- {
- case 0:
- case 1:
- case 4:
- case 32:
- case 128:
- case 5:
- case 132:
- case 160:
- case 33:
- case 129:
- case 36:
- case 133:
- case 164:
- case 161:
- case 37:
- case 165:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 2:
- case 34:
- case 130:
- case 162:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 16:
- case 17:
- case 48:
- case 49:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 64:
- case 65:
- case 68:
- case 69:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 8:
- case 12:
- case 136:
- case 140:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 3:
- case 35:
- case 131:
- case 163:
- MIX_00_4_3_3_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 6:
- case 38:
- case 134:
- case 166:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_5_3_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 20:
- case 21:
- case 52:
- case 53:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 144:
- case 145:
- case 176:
- case 177:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_7_3_1
- break;
- case 192:
- case 193:
- case 196:
- case 197:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_5_3_1
- break;
- case 96:
- case 97:
- case 100:
- case 101:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_8_5_2_1_1
- break;
- case 40:
- case 44:
- case 168:
- case 172:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_5_7_2_1_1
- break;
- case 9:
- case 13:
- case 137:
- case 141:
- MIX_00_4_1_3_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 18:
- case 50:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_7_3_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 80:
- case 81:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 72:
- case 76:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 10:
- case 138:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 66:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 24:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 7:
- case 39:
- case 135:
- MIX_00_4_3_3_1
- MIX_01_4_5_3_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 148:
- case 149:
- case 180:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_7_3_1
- break;
- case 224:
- case 228:
- case 225:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_5_3_1
- break;
- case 41:
- case 169:
- case 45:
- MIX_00_4_1_3_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_5_7_2_1_1
- break;
- case 22:
- case 54:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_7_3_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 208:
- case 209:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 104:
- case 108:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 11:
- case 139:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 19:
- case 51:
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_00_4_3_3_1
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_00_4_1_3_5_2_1
- MIX_01_4_1_5_2_3_3
- }
- MIX_10_4_7_3_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 146:
- case 178:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- MIX_11_4_7_3_1
- }
- else
- {
- MIX_01_4_1_5_2_3_3
- MIX_11_4_5_7_5_2_1
- }
- MIX_10_4_7_3_2_1_1
- break;
- case 84:
- case 85:
- MIX_00_4_3_1_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_01_4_1_3_1
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_01_4_5_1_5_2_1
- MIX_11_4_5_7_2_3_3
- }
- MIX_10_4_6_3_2_1_1
- break;
- case 112:
- case 113:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_10_4_3_3_1
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_10_4_7_3_5_2_1
- MIX_11_4_5_7_2_3_3
- }
- break;
- case 200:
- case 204:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- MIX_11_4_5_3_1
- }
- else
- {
- MIX_10_4_7_3_2_3_3
- MIX_11_4_7_5_5_2_1
- }
- break;
- case 73:
- case 77:
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_00_4_1_3_1
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_00_4_3_1_5_2_1
- MIX_10_4_7_3_2_3_3
- }
- MIX_01_4_1_5_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 42:
- case 170:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- MIX_10_4_7_3_1
- }
- else
- {
- MIX_00_4_3_1_2_3_3
- MIX_10_4_3_7_5_2_1
- }
- MIX_01_4_2_5_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 14:
- case 142:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- MIX_01_4_5_3_1
- }
- else
- {
- MIX_00_4_3_1_2_3_3
- MIX_01_4_1_5_5_2_1
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 67:
- MIX_00_4_3_3_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 70:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_5_3_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 28:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 152:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 194:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_5_3_1
- break;
- case 98:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_8_5_2_1_1
- break;
- case 56:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 25:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 26:
- case 31:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 82:
- case 214:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 88:
- case 248:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 74:
- case 107:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 27:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_3_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 86:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_3_2_1_1
- MIX_11_4_8_3_1
- break;
- case 216:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 106:
- MIX_00_MIX_00_4_0_3_1
- MIX_01_4_2_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 30:
- MIX_00_MIX_00_4_0_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 210:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_2_3_1
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 120:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_3_1
- break;
- case 75:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_3_1
- MIX_11_4_8_5_2_1_1
- break;
- case 29:
- MIX_00_4_1_3_1
- MIX_01_4_1_3_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 198:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_5_3_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_5_3_1
- break;
- case 184:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_7_3_1
- break;
- case 99:
- MIX_00_4_3_3_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_8_5_2_1_1
- break;
- case 57:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 71:
- MIX_00_4_3_3_1
- MIX_01_4_5_3_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 156:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 226:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_5_3_1
- break;
- case 60:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 195:
- MIX_00_4_3_3_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_5_3_1
- break;
- case 102:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_5_3_1
- MIX_10_4_3_3_1
- MIX_11_4_8_5_2_1_1
- break;
- case 153:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 58:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 83:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 92:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 202:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- MIX_01_4_2_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- MIX_11_4_5_3_1
- break;
- case 78:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 154:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 114:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 89:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 90:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 55:
- case 23:
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_00_4_3_3_1
- MIX_01_4
- }
- else
- {
- MIX_00_4_1_3_5_2_1
- MIX_01_4_1_5_2_3_3
- }
- MIX_10_4_7_3_2_1_1
- MIX_11_4_8_7_2_1_1
- break;
- case 182:
- case 150:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- MIX_11_4_7_3_1
- }
- else
- {
- MIX_01_4_1_5_2_3_3
- MIX_11_4_5_7_5_2_1
- }
- MIX_10_4_7_3_2_1_1
- break;
- case 213:
- case 212:
- MIX_00_4_3_1_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_01_4_1_3_1
- MIX_11_4
- }
- else
- {
- MIX_01_4_5_1_5_2_1
- MIX_11_4_5_7_2_3_3
- }
- MIX_10_4_6_3_2_1_1
- break;
- case 241:
- case 240:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_10_4_3_3_1
- MIX_11_4
- }
- else
- {
- MIX_10_4_7_3_5_2_1
- MIX_11_4_5_7_2_3_3
- }
- break;
- case 236:
- case 232:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- MIX_11_4_5_3_1
- }
- else
- {
- MIX_10_4_7_3_2_3_3
- MIX_11_4_7_5_5_2_1
- }
- break;
- case 109:
- case 105:
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_00_4_1_3_1
- MIX_10_4
- }
- else
- {
- MIX_00_4_3_1_5_2_1
- MIX_10_4_7_3_2_3_3
- }
- MIX_01_4_1_5_2_1_1
- MIX_11_4_8_5_2_1_1
- break;
- case 171:
- case 43:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- MIX_10_4_7_3_1
- }
- else
- {
- MIX_00_4_3_1_2_3_3
- MIX_10_4_3_7_5_2_1
- }
- MIX_01_4_2_5_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 143:
- case 15:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- MIX_01_4_5_3_1
- }
- else
- {
- MIX_00_4_3_1_2_3_3
- MIX_01_4_1_5_5_2_1
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 124:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_3_1
- break;
- case 203:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_5_2_1_1
- MIX_10_4_6_3_1
- MIX_11_4_5_3_1
- break;
- case 62:
- MIX_00_MIX_00_4_0_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 211:
- MIX_00_4_3_3_1
- MIX_01_4_2_3_1
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 118:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_3_3_1
- MIX_11_4_8_3_1
- break;
- case 217:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_6_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 110:
- MIX_00_MIX_00_4_0_3_1
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 155:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_3_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 188:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_1
- MIX_11_4_7_3_1
- break;
- case 185:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_7_3_1
- break;
- case 61:
- MIX_00_4_1_3_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 157:
- MIX_00_4_1_3_1
- MIX_01_4_1_3_1
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 103:
- MIX_00_4_3_3_1
- MIX_01_4_5_3_1
- MIX_10_4_3_3_1
- MIX_11_4_8_5_2_1_1
- break;
- case 227:
- MIX_00_4_3_3_1
- MIX_01_4_2_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_5_3_1
- break;
- case 230:
- MIX_00_4_0_3_2_1_1
- MIX_01_4_5_3_1
- MIX_10_4_3_3_1
- MIX_11_4_5_3_1
- break;
- case 199:
- MIX_00_4_3_3_1
- MIX_01_4_5_3_1
- MIX_10_4_6_3_2_1_1
- MIX_11_4_5_3_1
- break;
- case 220:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 158:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 234:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- MIX_01_4_2_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_5_3_1
- break;
- case 242:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 59:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 121:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 87:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 79:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 122:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 94:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 218:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 91:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 229:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_3_3_1
- MIX_11_4_5_3_1
- break;
- case 167:
- MIX_00_4_3_3_1
- MIX_01_4_5_3_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_5_7_2_1_1
- break;
- case 173:
- MIX_00_4_1_3_1
- MIX_01_4_1_5_2_1_1
- MIX_10_4_7_3_1
- MIX_11_4_5_7_2_1_1
- break;
- case 181:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_2_1_1
- MIX_11_4_7_3_1
- break;
- case 186:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_7_3_1
- MIX_11_4_7_3_1
- break;
- case 115:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 93:
- MIX_00_4_1_3_1
- MIX_01_4_1_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 206:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- MIX_11_4_5_3_1
- break;
- case 205:
- case 201:
- MIX_00_4_1_3_1
- MIX_01_4_1_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4_6_3_1
- }
- else
- {
- MIX_10_4_7_3_6_1_1
- }
- MIX_11_4_5_3_1
- break;
- case 174:
- case 46:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_MIX_00_4_0_3_1
- }
- else
- {
- MIX_00_4_3_1_6_1_1
- }
- MIX_01_4_5_3_1
- MIX_10_4_7_3_1
- MIX_11_4_5_7_2_1_1
- break;
- case 179:
- case 147:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4_2_3_1
- }
- else
- {
- MIX_01_4_1_5_6_1_1
- }
- MIX_10_4_7_3_2_1_1
- MIX_11_4_7_3_1
- break;
- case 117:
- case 116:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4_8_3_1
- }
- else
- {
- MIX_11_4_5_7_6_1_1
- }
- break;
- case 189:
- MIX_00_4_1_3_1
- MIX_01_4_1_3_1
- MIX_10_4_7_3_1
- MIX_11_4_7_3_1
- break;
- case 231:
- MIX_00_4_3_3_1
- MIX_01_4_5_3_1
- MIX_10_4_3_3_1
- MIX_11_4_5_3_1
- break;
- case 126:
- MIX_00_MIX_00_4_0_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_3_1
- break;
- case 219:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_3_1
- MIX_10_4_6_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 125:
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_00_4_1_3_1
- MIX_10_4
- }
- else
- {
- MIX_00_4_3_1_5_2_1
- MIX_10_4_7_3_2_3_3
- }
- MIX_01_4_1_3_1
- MIX_11_4_8_3_1
- break;
- case 221:
- MIX_00_4_1_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_01_4_1_3_1
- MIX_11_4
- }
- else
- {
- MIX_01_4_5_1_5_2_1
- MIX_11_4_5_7_2_3_3
- }
- MIX_10_4_6_3_1
- break;
- case 207:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- MIX_01_4_5_3_1
- }
- else
- {
- MIX_00_4_3_1_2_3_3
- MIX_01_4_1_5_5_2_1
- }
- MIX_10_4_6_3_1
- MIX_11_4_5_3_1
- break;
- case 238:
- MIX_00_MIX_00_4_0_3_1
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- MIX_11_4_5_3_1
- }
- else
- {
- MIX_10_4_7_3_2_3_3
- MIX_11_4_7_5_5_2_1
- }
- break;
- case 190:
- MIX_00_MIX_00_4_0_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- MIX_11_4_7_3_1
- }
- else
- {
- MIX_01_4_1_5_2_3_3
- MIX_11_4_5_7_5_2_1
- }
- MIX_10_4_7_3_1
- break;
- case 187:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- MIX_10_4_7_3_1
- }
- else
- {
- MIX_00_4_3_1_2_3_3
- MIX_10_4_3_7_5_2_1
- }
- MIX_01_4_2_3_1
- MIX_11_4_7_3_1
- break;
- case 243:
- MIX_00_4_3_3_1
- MIX_01_4_2_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_10_4_3_3_1
- MIX_11_4
- }
- else
- {
- MIX_10_4_7_3_5_2_1
- MIX_11_4_5_7_2_3_3
- }
- break;
- case 119:
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_00_4_3_3_1
- MIX_01_4
- }
- else
- {
- MIX_00_4_1_3_5_2_1
- MIX_01_4_1_5_2_3_3
- }
- MIX_10_4_3_3_1
- MIX_11_4_8_3_1
- break;
- case 237:
- case 233:
- MIX_00_4_1_3_1
- MIX_01_4_1_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_6_3_10
- }
- MIX_11_4_5_3_1
- break;
- case 175:
- case 47:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_MIX_00_4_0_3_10
- }
- MIX_01_4_5_3_1
- MIX_10_4_7_3_1
- MIX_11_4_5_7_2_1_1
- break;
- case 183:
- case 151:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_2_3_10
- }
- MIX_10_4_7_3_2_1_1
- MIX_11_4_7_3_1
- break;
- case 245:
- case 244:
- MIX_00_4_3_1_2_1_1
- MIX_01_4_1_3_1
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_8_3_10
- }
- break;
- case 250:
- MIX_00_MIX_00_4_0_3_1
- MIX_01_4_2_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 123:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_3_1
- break;
- case 95:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_3_1
- MIX_11_4_8_3_1
- break;
- case 222:
- MIX_00_MIX_00_4_0_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_6_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 252:
- MIX_00_4_0_1_2_1_1
- MIX_01_4_1_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_8_3_10
- }
- break;
- case 249:
- MIX_00_4_1_3_1
- MIX_01_4_2_1_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_6_3_10
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 235:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_5_2_1_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_6_3_10
- }
- MIX_11_4_5_3_1
- break;
- case 111:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_MIX_00_4_0_3_10
- }
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_5_2_1_1
- break;
- case 63:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_MIX_00_4_0_3_10
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_7_3_1
- MIX_11_4_8_7_2_1_1
- break;
- case 159:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_2_3_10
- }
- MIX_10_4_6_7_2_1_1
- MIX_11_4_7_3_1
- break;
- case 215:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_2_3_10
- }
- MIX_10_4_6_3_2_1_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 246:
- MIX_00_4_0_3_2_1_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_8_3_10
- }
- break;
- case 254:
- MIX_00_MIX_00_4_0_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_8_3_10
- }
- break;
- case 253:
- MIX_00_4_1_3_1
- MIX_01_4_1_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_6_3_10
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_8_3_10
- }
- break;
- case 251:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- MIX_01_4_2_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_6_3_10
- }
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 239:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_MIX_00_4_0_3_10
- }
- MIX_01_4_5_3_1
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_6_3_10
- }
- MIX_11_4_5_3_1
- break;
- case 127:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_MIX_00_4_0_3_10
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_1_5_2_1_1
- }
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- {
- MIX_10_4
- }
- else
- {
- MIX_10_4_7_3_2_1_1
- }
- MIX_11_4_8_3_1
- break;
- case 191:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_MIX_00_4_0_3_10
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_2_3_10
- }
- MIX_10_4_7_3_1
- MIX_11_4_7_3_1
- break;
- case 223:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- {
- MIX_00_4
- }
- else
- {
- MIX_00_4_3_1_2_1_1
- }
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_2_3_10
- }
- MIX_10_4_6_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_5_7_2_1_1
- }
- break;
- case 247:
- MIX_00_4_3_3_1
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- {
- MIX_01_4
- }
- else
- {
- MIX_01_4_2_3_10
- }
- MIX_10_4_3_3_1
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- {
- MIX_11_4
- }
- else
- {
- MIX_11_4_8_3_10
- }
- break;
- case 255:
- if (isDifferent(w[3], w[1], trY, trU, trV, trA))
- MIX_00_4
- else
- MIX_00_MIX_00_4_0_3_10
-
- if (isDifferent(w[1], w[5], trY, trU, trV, trA))
- MIX_01_4
- else
- MIX_01_4_2_3_10
-
- if (isDifferent(w[7], w[3], trY, trU, trV, trA))
- MIX_10_4
- else
- MIX_10_4_6_3_10
-
- if (isDifferent(w[5], w[7], trY, trU, trV, trA))
- MIX_11_4
- else
- MIX_11_4_8_3_10
- break;
- }
- image++;
- output += 2;
- }
- output += lineSize;
- }
-
- return output;
-}
diff --git a/thirdparty/misc/hq2x.h b/thirdparty/misc/hq2x.h
deleted file mode 100644
index bebd917950..0000000000
--- a/thirdparty/misc/hq2x.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef HQ2X_H
-#define HQ2X_H
-
-#include "core/typedefs.h"
-
-
-uint32_t *hq2x_resize(
- const uint32_t *image,
- uint32_t width,
- uint32_t height,
- uint32_t *output,
- uint32_t trY = 0x30,
- uint32_t trU = 0x07,
- uint32_t trV = 0x06,
- uint32_t trA = 0x50,
- bool wrapX = false,
- bool wrapY = false );
-
-#endif // HQ2X_H
diff --git a/thirdparty/misc/r128.h b/thirdparty/misc/r128.h
index be7cd3024d..1f7aab78fb 100644
--- a/thirdparty/misc/r128.h
+++ b/thirdparty/misc/r128.h
@@ -665,7 +665,7 @@ static int r128__clz64(R128_U64 x)
// 32*32->64
static R128_U64 r128__umul64(R128_U32 a, R128_U32 b)
{
-# if defined(_M_IX86) && !defined(R128_STDC_ONLY)
+# if defined(_M_IX86) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
return __emulu(a, b);
# elif defined(_M_ARM) && !defined(R128_STDC_ONLY)
return _arm_umull(a, b);
@@ -680,7 +680,7 @@ static R128_U32 r128__udiv64(R128_U32 nlo, R128_U32 nhi, R128_U32 d, R128_U32 *r
# if defined(_M_IX86) && (_MSC_VER >= 1920) && !defined(R128_STDC_ONLY)
unsigned __int64 n = ((unsigned __int64)nhi << 32) | nlo;
return _udiv64(n, d, rem);
-# elif defined(_M_IX86) && !defined(R128_STDC_ONLY)
+# elif defined(_M_IX86) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
__asm {
mov eax, nlo
mov edx, nhi
@@ -795,7 +795,7 @@ static void r128__umul128(R128 *dst, R128_U64 a, R128_U64 b)
}
// 128/64->64
-#if defined(_M_X64) && (_MSC_VER < 1920) && !defined(R128_STDC_ONLY)
+#if defined(_M_X64) && (_MSC_VER < 1920) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
// MSVC x64 provides neither inline assembly nor (pre-2019) a div intrinsic, so we do fake
// "inline assembly" to avoid long division or outline assembly.
#pragma code_seg(".text")
@@ -810,7 +810,7 @@ static const r128__udiv128Proc r128__udiv128 = (r128__udiv128Proc)(void*)r128__u
#else
static R128_U64 r128__udiv128(R128_U64 nlo, R128_U64 nhi, R128_U64 d, R128_U64 *rem)
{
-#if defined(_M_X64) && !defined(R128_STDC_ONLY)
+#if defined(_M_X64) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
return _udiv128(nhi, nlo, d, rem);
#elif defined(__x86_64__) && !defined(R128_STDC_ONLY)
R128_U64 q, r;
@@ -1602,7 +1602,7 @@ void r128Shl(R128 *dst, const R128 *src, int amount)
R128_ASSERT(dst != NULL);
R128_ASSERT(src != NULL);
-#if defined(_M_IX86) && !defined(R128_STDC_ONLY)
+#if defined(_M_IX86) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
__asm {
// load src
mov edx, dword ptr[src]
@@ -1664,7 +1664,7 @@ void r128Shr(R128 *dst, const R128 *src, int amount)
R128_ASSERT(dst != NULL);
R128_ASSERT(src != NULL);
-#if defined(_M_IX86) && !defined(R128_STDC_ONLY)
+#if defined(_M_IX86) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
__asm {
// load src
mov edx, dword ptr[src]
@@ -1726,7 +1726,7 @@ void r128Sar(R128 *dst, const R128 *src, int amount)
R128_ASSERT(dst != NULL);
R128_ASSERT(src != NULL);
-#if defined(_M_IX86) && !defined(R128_STDC_ONLY)
+#if defined(_M_IX86) && !defined(R128_STDC_ONLY) && !defined(__MINGW32__)
__asm {
// load src
mov edx, dword ptr[src]
diff --git a/thirdparty/oidn/common/platform.h b/thirdparty/oidn/common/platform.h
index 205ac8981d..9373b617b5 100644
--- a/thirdparty/oidn/common/platform.h
+++ b/thirdparty/oidn/common/platform.h
@@ -19,7 +19,7 @@
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
- #include <Windows.h>
+ #include <windows.h>
#elif defined(__APPLE__)
#include <sys/sysctl.h>
#endif
diff --git a/thirdparty/oidn/core/autoencoder.cpp b/thirdparty/oidn/core/autoencoder.cpp
index 8ae2421fa6..d8da684cb8 100644
--- a/thirdparty/oidn/core/autoencoder.cpp
+++ b/thirdparty/oidn/core/autoencoder.cpp
@@ -90,12 +90,19 @@ namespace oidn {
if (!dirty)
return;
- {
+ // -- GODOT start --
+ //device->executeTask([&]()
+ //{
+ // GODOT end --
+
if (mayiuse(avx512_common))
net = buildNet<16>();
else
net = buildNet<8>();
- }
+
+ // GODOT start --
+ //});
+ // GODOT end --
dirty = false;
}
@@ -107,8 +114,10 @@ namespace oidn {
if (!net)
return;
-
- {
+ // -- GODOT start --
+ //device->executeTask([&]()
+ //{
+ // -- GODOT end --
Progress progress;
progress.func = progressFunc;
progress.userPtr = progressUserPtr;
@@ -154,7 +163,9 @@ namespace oidn {
tileIndex++;
}
}
- }
+ // -- GODOT start --
+ //});
+ // -- GODOT end --
}
void AutoencoderFilter::computeTileSize()
@@ -462,8 +473,11 @@ namespace oidn {
return std::make_shared<GammaTransferFunction>();
}
+// -- GODOT start --
// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
#if 0
+// -- GODOT end --
+
// --------------------------------------------------------------------------
// RTFilter
// --------------------------------------------------------------------------
@@ -491,7 +505,9 @@ namespace oidn {
weightData.hdr_alb = weights::rt_hdr_alb;
weightData.hdr_alb_nrm = weights::rt_hdr_alb_nrm;
}
+// -- GODOT start --
#endif
+// -- GODOT end --
// --------------------------------------------------------------------------
// RTLightmapFilter
diff --git a/thirdparty/oidn/core/autoencoder.h b/thirdparty/oidn/core/autoencoder.h
index 97432f2bbd..98b610844e 100644
--- a/thirdparty/oidn/core/autoencoder.h
+++ b/thirdparty/oidn/core/autoencoder.h
@@ -93,14 +93,18 @@ namespace oidn {
// RTFilter - Generic ray tracing denoiser
// --------------------------------------------------------------------------
+// -- GODOT start --
// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
#if 0
+// -- GODOT end --
class RTFilter : public AutoencoderFilter
{
public:
explicit RTFilter(const Ref<Device>& device);
};
+// -- GODOT start --
#endif
+// -- GODOT end --
// --------------------------------------------------------------------------
// RTLightmapFilter - Ray traced lightmap denoiser
diff --git a/thirdparty/oidn/core/common.h b/thirdparty/oidn/core/common.h
index 6c87f377bc..a35dd908b4 100644
--- a/thirdparty/oidn/core/common.h
+++ b/thirdparty/oidn/core/common.h
@@ -27,6 +27,9 @@
#include "common/ref.h"
#include "common/exception.h"
#include "common/thread.h"
+// -- GODOT start --
+//#include "common/tasking.h"
+// -- GODOT end --
#include "math.h"
namespace oidn {
diff --git a/thirdparty/oidn/core/device.cpp b/thirdparty/oidn/core/device.cpp
index 0812624bb5..3cd658b9c8 100644
--- a/thirdparty/oidn/core/device.cpp
+++ b/thirdparty/oidn/core/device.cpp
@@ -29,6 +29,9 @@ namespace oidn {
Device::~Device()
{
+ // -- GODOT start --
+ //observer.reset();
+ // -- GODOT end --
}
void Device::setError(Device* device, Error code, const std::string& message)
@@ -140,10 +143,29 @@ namespace oidn {
if (isCommitted())
throw Exception(Error::InvalidOperation, "device can be committed only once");
+ // -- GODOT start --
+ #if 0
+ // -- GODOT end --
+ // Get the optimal thread affinities
+ if (setAffinity)
+ {
+ affinity = std::make_shared<ThreadAffinity>(1, verbose); // one thread per core
+ if (affinity->getNumThreads() == 0)
+ affinity.reset();
+ }
+
// Create the task arena
- const int maxNumThreads = 1; //affinity ? affinity->getNumThreads() : tbb::this_task_arena::max_concurrency();
+ const int maxNumThreads = affinity ? affinity->getNumThreads() : tbb::this_task_arena::max_concurrency();
numThreads = (numThreads > 0) ? min(numThreads, maxNumThreads) : maxNumThreads;
-
+ arena = std::make_shared<tbb::task_arena>(numThreads);
+
+ // Automatically set the thread affinities
+ if (affinity)
+ observer = std::make_shared<PinningObserver>(affinity, *arena);
+ // -- GODOT start --
+ #endif
+ numThreads = 1;
+ // -- GODOT end --
dirty = false;
if (isVerbose())
@@ -177,12 +199,17 @@ namespace oidn {
Ref<Filter> filter;
+// -- GODOT start --
// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
#if 0
+// -- GODOT end --
if (type == "RT")
filter = makeRef<RTFilter>(Ref<Device>(this));
+// -- GODOT start --
+// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
#endif
- if (type == "RTLightmap")
+ if (type == "RTLightmap")
+// -- GODOT end --
filter = makeRef<RTLightmapFilter>(Ref<Device>(this));
else
throw Exception(Error::InvalidArgument, "unknown filter type");
@@ -199,6 +226,12 @@ namespace oidn {
std::cout << " Build : " << getBuildName() << std::endl;
std::cout << " Platform: " << getPlatformName() << std::endl;
+// -- GODOT start --
+// std::cout << " Tasking :";
+// std::cout << " TBB" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR;
+// std::cout << " TBB_header_interface_" << TBB_INTERFACE_VERSION << " TBB_lib_interface_" << tbb::TBB_runtime_interface_version();
+// std::cout << std::endl;
+// -- GODOT end --
std::cout << std::endl;
}
diff --git a/thirdparty/oidn/core/device.h b/thirdparty/oidn/core/device.h
index 93a83eb731..d9cfd8541a 100644
--- a/thirdparty/oidn/core/device.h
+++ b/thirdparty/oidn/core/device.h
@@ -41,6 +41,13 @@ namespace oidn {
ErrorFunction errorFunc = nullptr;
void* errorUserPtr = nullptr;
+// -- GODOT start --
+// // Tasking
+// std::shared_ptr<tbb::task_arena> arena;
+// std::shared_ptr<PinningObserver> observer;
+// std::shared_ptr<ThreadAffinity> affinity;
+// -- GODOT end --
+
// Parameters
int numThreads = 0; // autodetect by default
bool setAffinity = true;
@@ -61,6 +68,20 @@ namespace oidn {
void commit();
+// -- GODOT start --
+// template<typename F>
+// void executeTask(F& f)
+// {
+// arena->execute(f);
+// }
+
+// template<typename F>
+// void executeTask(const F& f)
+// {
+// arena->execute(f);
+// }
+// -- GODOT end --
+
Ref<Buffer> newBuffer(size_t byteSize);
Ref<Buffer> newBuffer(void* ptr, size_t byteSize);
Ref<Filter> newFilter(const std::string& type);
@@ -69,7 +90,10 @@ namespace oidn {
__forceinline std::mutex& getMutex() { return mutex; }
private:
- bool isCommitted() const { return false; }
+// -- GODOT start --
+ //bool isCommitted() const { return bool(arena); }
+ bool isCommitted() const { return false; }
+// -- GODOT end --
void checkCommitted();
void print();
diff --git a/thirdparty/oidn/core/network.cpp b/thirdparty/oidn/core/network.cpp
index 4da32073cd..ed8328c954 100644
--- a/thirdparty/oidn/core/network.cpp
+++ b/thirdparty/oidn/core/network.cpp
@@ -14,10 +14,12 @@
// limitations under the License. //
// ======================================================================== //
-#include "network.h"
#include "upsample.h"
#include "weights_reorder.h"
+#include "network.h"
+// -- GODOT start --
#include <cstring>
+// -- GODOT end --
namespace oidn {
diff --git a/thirdparty/oidn/core/transfer_function.cpp b/thirdparty/oidn/core/transfer_function.cpp
index a33e3c84bc..487f0a9f75 100644
--- a/thirdparty/oidn/core/transfer_function.cpp
+++ b/thirdparty/oidn/core/transfer_function.cpp
@@ -24,9 +24,12 @@ namespace oidn {
float AutoexposureNode::autoexposure(const Image& color)
{
assert(color.format == Format::Float3);
- return 1.0f;
+// -- GODOT start --
+// We don't want to mess with TTB and we don't use autoexposure, so we disable this code
+#if 0
+// -- GODOT end --
- /*constexpr float key = 0.18f;
+ constexpr float key = 0.18f;
constexpr float eps = 1e-8f;
constexpr int K = 16; // downsampling amount
@@ -89,7 +92,11 @@ namespace oidn {
tbb::static_partitioner()
);
- return (sum.second > 0) ? (key / exp2(sum.first / float(sum.second))) : 1.f;*/
+ return (sum.second > 0) ? (key / exp2(sum.first / float(sum.second))) : 1.f;
+// -- GODOT start --
+#endif
+ return 1.0;
+// -- GODOT end --
}
} // namespace oidn
diff --git a/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp b/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp
index 597c63e3f8..78cdedbae4 100644
--- a/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp
+++ b/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp
@@ -131,7 +131,7 @@ struct rnn_weights_reorder_t : public cpu_primitive_t {
return status::success;
}
- format_tag_t itag_;
+ format_tag_t itag_ = mkldnn_format_tag_undef;
private:
void init_scratchpad() {
diff --git a/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp b/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp
index 5177275452..057cc3c4c7 100644
--- a/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp
+++ b/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp
@@ -96,9 +96,9 @@ struct simple_concat_t: public cpu_primitive_t {
return status::success;
}
- int perm_[MKLDNN_MAX_NDIMS];
- int iperm_[MKLDNN_MAX_NDIMS];
- dims_t blocks_;
+ int perm_[MKLDNN_MAX_NDIMS] {};
+ int iperm_[MKLDNN_MAX_NDIMS] {};
+ dims_t blocks_ {};
dim_t nelems_to_concat(const memory_desc_wrapper &data_d) const {
const int ndims = data_d.ndims();
diff --git a/thirdparty/oidn/patches/godot-changes-c58c5216.patch b/thirdparty/oidn/patches/godot-changes-c58c5216.patch
new file mode 100644
index 0000000000..6a54703064
--- /dev/null
+++ b/thirdparty/oidn/patches/godot-changes-c58c5216.patch
@@ -0,0 +1,307 @@
+diff --git a/common/platform.h b/common/platform.h
+index be14bc7..9373b61 100644
+--- a/common/platform.h
++++ b/common/platform.h
+@@ -19,7 +19,7 @@
+ #if defined(_WIN32)
+ #define WIN32_LEAN_AND_MEAN
+ #define NOMINMAX
+- #include <Windows.h>
++ #include <windows.h>
+ #elif defined(__APPLE__)
+ #include <sys/sysctl.h>
+ #endif
+@@ -129,4 +129,3 @@ namespace oidn {
+ std::string getBuildName();
+
+ } // namespace oidn
+-
+diff --git a/core/autoencoder.cpp b/core/autoencoder.cpp
+index d6915e6..d8da684 100644
+--- a/core/autoencoder.cpp
++++ b/core/autoencoder.cpp
+@@ -90,13 +90,19 @@ namespace oidn {
+ if (!dirty)
+ return;
+
+- device->executeTask([&]()
+- {
++ // -- GODOT start --
++ //device->executeTask([&]()
++ //{
++ // GODOT end --
++
+ if (mayiuse(avx512_common))
+ net = buildNet<16>();
+ else
+ net = buildNet<8>();
+- });
++
++ // GODOT start --
++ //});
++ // GODOT end --
+
+ dirty = false;
+ }
+@@ -108,9 +114,10 @@ namespace oidn {
+
+ if (!net)
+ return;
+-
+- device->executeTask([&]()
+- {
++ // -- GODOT start --
++ //device->executeTask([&]()
++ //{
++ // -- GODOT end --
+ Progress progress;
+ progress.func = progressFunc;
+ progress.userPtr = progressUserPtr;
+@@ -156,7 +163,9 @@ namespace oidn {
+ tileIndex++;
+ }
+ }
+- });
++ // -- GODOT start --
++ //});
++ // -- GODOT end --
+ }
+
+ void AutoencoderFilter::computeTileSize()
+@@ -464,6 +473,11 @@ namespace oidn {
+ return std::make_shared<GammaTransferFunction>();
+ }
+
++// -- GODOT start --
++// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
++#if 0
++// -- GODOT end --
++
+ // --------------------------------------------------------------------------
+ // RTFilter
+ // --------------------------------------------------------------------------
+@@ -491,6 +505,9 @@ namespace oidn {
+ weightData.hdr_alb = weights::rt_hdr_alb;
+ weightData.hdr_alb_nrm = weights::rt_hdr_alb_nrm;
+ }
++// -- GODOT start --
++#endif
++// -- GODOT end --
+
+ // --------------------------------------------------------------------------
+ // RTLightmapFilter
+diff --git a/core/autoencoder.h b/core/autoencoder.h
+index c199052..98b6108 100644
+--- a/core/autoencoder.h
++++ b/core/autoencoder.h
+@@ -93,11 +93,18 @@ namespace oidn {
+ // RTFilter - Generic ray tracing denoiser
+ // --------------------------------------------------------------------------
+
++// -- GODOT start --
++// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
++#if 0
++// -- GODOT end --
+ class RTFilter : public AutoencoderFilter
+ {
+ public:
+ explicit RTFilter(const Ref<Device>& device);
+ };
++// -- GODOT start --
++#endif
++// -- GODOT end --
+
+ // --------------------------------------------------------------------------
+ // RTLightmapFilter - Ray traced lightmap denoiser
+diff --git a/core/common.h b/core/common.h
+index a3a7e8a..a35dd90 100644
+--- a/core/common.h
++++ b/core/common.h
+@@ -27,7 +27,9 @@
+ #include "common/ref.h"
+ #include "common/exception.h"
+ #include "common/thread.h"
+-#include "common/tasking.h"
++// -- GODOT start --
++//#include "common/tasking.h"
++// -- GODOT end --
+ #include "math.h"
+
+ namespace oidn {
+diff --git a/core/device.cpp b/core/device.cpp
+index c455695..3cd658b 100644
+--- a/core/device.cpp
++++ b/core/device.cpp
+@@ -29,7 +29,9 @@ namespace oidn {
+
+ Device::~Device()
+ {
+- observer.reset();
++ // -- GODOT start --
++ //observer.reset();
++ // -- GODOT end --
+ }
+
+ void Device::setError(Device* device, Error code, const std::string& message)
+@@ -141,6 +143,9 @@ namespace oidn {
+ if (isCommitted())
+ throw Exception(Error::InvalidOperation, "device can be committed only once");
+
++ // -- GODOT start --
++ #if 0
++ // -- GODOT end --
+ // Get the optimal thread affinities
+ if (setAffinity)
+ {
+@@ -157,7 +162,10 @@ namespace oidn {
+ // Automatically set the thread affinities
+ if (affinity)
+ observer = std::make_shared<PinningObserver>(affinity, *arena);
+-
++ // -- GODOT start --
++ #endif
++ numThreads = 1;
++ // -- GODOT end --
+ dirty = false;
+
+ if (isVerbose())
+@@ -191,9 +199,17 @@ namespace oidn {
+
+ Ref<Filter> filter;
+
++// -- GODOT start --
++// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
++#if 0
++// -- GODOT end --
+ if (type == "RT")
+ filter = makeRef<RTFilter>(Ref<Device>(this));
+- else if (type == "RTLightmap")
++// -- GODOT start --
++// Godot doesn't need Raytracing filters. Removing them saves space in the weights files.
++#endif
++ if (type == "RTLightmap")
++// -- GODOT end --
+ filter = makeRef<RTLightmapFilter>(Ref<Device>(this));
+ else
+ throw Exception(Error::InvalidArgument, "unknown filter type");
+@@ -210,11 +226,12 @@ namespace oidn {
+ std::cout << " Build : " << getBuildName() << std::endl;
+ std::cout << " Platform: " << getPlatformName() << std::endl;
+
+- std::cout << " Tasking :";
+- std::cout << " TBB" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR;
+- std::cout << " TBB_header_interface_" << TBB_INTERFACE_VERSION << " TBB_lib_interface_" << tbb::TBB_runtime_interface_version();
+- std::cout << std::endl;
+-
++// -- GODOT start --
++// std::cout << " Tasking :";
++// std::cout << " TBB" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR;
++// std::cout << " TBB_header_interface_" << TBB_INTERFACE_VERSION << " TBB_lib_interface_" << tbb::TBB_runtime_interface_version();
++// std::cout << std::endl;
++// -- GODOT end --
+ std::cout << std::endl;
+ }
+
+diff --git a/core/device.h b/core/device.h
+index c2df714..d9cfd85 100644
+--- a/core/device.h
++++ b/core/device.h
+@@ -41,10 +41,12 @@ namespace oidn {
+ ErrorFunction errorFunc = nullptr;
+ void* errorUserPtr = nullptr;
+
+- // Tasking
+- std::shared_ptr<tbb::task_arena> arena;
+- std::shared_ptr<PinningObserver> observer;
+- std::shared_ptr<ThreadAffinity> affinity;
++// -- GODOT start --
++// // Tasking
++// std::shared_ptr<tbb::task_arena> arena;
++// std::shared_ptr<PinningObserver> observer;
++// std::shared_ptr<ThreadAffinity> affinity;
++// -- GODOT end --
+
+ // Parameters
+ int numThreads = 0; // autodetect by default
+@@ -66,17 +68,19 @@ namespace oidn {
+
+ void commit();
+
+- template<typename F>
+- void executeTask(F& f)
+- {
+- arena->execute(f);
+- }
++// -- GODOT start --
++// template<typename F>
++// void executeTask(F& f)
++// {
++// arena->execute(f);
++// }
+
+- template<typename F>
+- void executeTask(const F& f)
+- {
+- arena->execute(f);
+- }
++// template<typename F>
++// void executeTask(const F& f)
++// {
++// arena->execute(f);
++// }
++// -- GODOT end --
+
+ Ref<Buffer> newBuffer(size_t byteSize);
+ Ref<Buffer> newBuffer(void* ptr, size_t byteSize);
+@@ -86,7 +90,10 @@ namespace oidn {
+ __forceinline std::mutex& getMutex() { return mutex; }
+
+ private:
+- bool isCommitted() const { return bool(arena); }
++// -- GODOT start --
++ //bool isCommitted() const { return bool(arena); }
++ bool isCommitted() const { return false; }
++// -- GODOT end --
+ void checkCommitted();
+
+ void print();
+diff --git a/core/network.cpp b/core/network.cpp
+index 8c2de09..ed8328c 100644
+--- a/core/network.cpp
++++ b/core/network.cpp
+@@ -17,6 +17,9 @@
+ #include "upsample.h"
+ #include "weights_reorder.h"
+ #include "network.h"
++// -- GODOT start --
++#include <cstring>
++// -- GODOT end --
+
+ namespace oidn {
+
+diff --git a/core/transfer_function.cpp b/core/transfer_function.cpp
+index 601f814..487f0a9 100644
+--- a/core/transfer_function.cpp
++++ b/core/transfer_function.cpp
+@@ -24,6 +24,10 @@ namespace oidn {
+ float AutoexposureNode::autoexposure(const Image& color)
+ {
+ assert(color.format == Format::Float3);
++// -- GODOT start --
++// We don't want to mess with TTB and we don't use autoexposure, so we disable this code
++#if 0
++// -- GODOT end --
+
+ constexpr float key = 0.18f;
+ constexpr float eps = 1e-8f;
+@@ -89,6 +93,10 @@ namespace oidn {
+ );
+
+ return (sum.second > 0) ? (key / exp2(sum.first / float(sum.second))) : 1.f;
++// -- GODOT start --
++#endif
++ return 1.0;
++// -- GODOT end --
+ }
+
+ } // namespace oidn
diff --git a/thirdparty/oidn/patches/mkl-dnn-fix-vs2017-build.patch b/thirdparty/oidn/patches/mkl-dnn-fix-vs2017-build.patch
new file mode 100644
index 0000000000..50d94ebffa
--- /dev/null
+++ b/thirdparty/oidn/patches/mkl-dnn-fix-vs2017-build.patch
@@ -0,0 +1,45 @@
+Rediffed by @akien-mga to match oidn 1.1.0 source.
+
+From 1e42e6db81e1a5270ecc0191c5385ce7e7d978e9 Mon Sep 17 00:00:00 2001
+From: Jeremy Wong <jmw@netvigator.com>
+Date: Wed, 11 Sep 2019 04:46:53 +0800
+Subject: [PATCH] src: initialize members in some structures to prevent compile
+ errors with VS2017
+
+addresses "error C3615: constexpr function '...' cannot result in a constant expression" with VS2017
+---
+ src/cpu/rnn/rnn_reorders.hpp | 2 +-
+ src/cpu/simple_concat.hpp | 6 +++---
+ src/cpu/simple_sum.hpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp b/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp
+index 597c63e3f8..ae1551390a 100644
+--- a/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp
++++ b/thirdparty/oidn/mkl-dnn/src/cpu/rnn/rnn_reorders.hpp
+@@ -131,7 +131,7 @@ struct rnn_weights_reorder_t : public cpu_primitive_t {
+ return status::success;
+ }
+
+- format_tag_t itag_;
++ format_tag_t itag_ = mkldnn_format_tag_undef;
+
+ private:
+ void init_scratchpad() {
+diff --git a/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp b/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp
+index 5177275452..057cc3c4c7 100644
+--- a/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp
++++ b/thirdparty/oidn/mkl-dnn/src/cpu/simple_concat.hpp
+@@ -96,9 +96,9 @@ struct simple_concat_t: public cpu_primitive_t {
+ return status::success;
+ }
+
+- int perm_[MKLDNN_MAX_NDIMS];
+- int iperm_[MKLDNN_MAX_NDIMS];
+- dims_t blocks_;
++ int perm_[MKLDNN_MAX_NDIMS] {};
++ int iperm_[MKLDNN_MAX_NDIMS] {};
++ dims_t blocks_ {};
+
+ dim_t nelems_to_concat(const memory_desc_wrapper &data_d) const {
+ const int ndims = data_d.ndims();
diff --git a/thirdparty/oidn/weights/LICENSE.txt b/thirdparty/oidn/weights/LICENSE.txt
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/thirdparty/oidn/weights/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/thirdparty/xatlas/LICENSE b/thirdparty/xatlas/LICENSE
index 9e61e15fb7..7af8b33238 100644
--- a/thirdparty/xatlas/LICENSE
+++ b/thirdparty/xatlas/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2018-2019 Jonathan Young
+Copyright (c) 2018-2020 Jonathan Young
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/thirdparty/xatlas/xatlas.cpp b/thirdparty/xatlas/xatlas.cpp
index b1cbeb980f..43aec33a9f 100644
--- a/thirdparty/xatlas/xatlas.cpp
+++ b/thirdparty/xatlas/xatlas.cpp
@@ -1,7 +1,7 @@
/*
MIT License
-Copyright (c) 2018-2019 Jonathan Young
+Copyright (c) 2018-2020 Jonathan Young
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -33,19 +33,19 @@ https://github.com/brandonpelfrey/Fast-BVH
MIT License
Copyright (c) 2012 Brandon Pelfrey
*/
-#include <assert.h>
-#include <float.h> // FLT_MAX
-#include <limits.h>
-#include <math.h>
#include <atomic>
#include <condition_variable>
#include <mutex>
#include <thread>
+#include <assert.h>
+#include <float.h> // FLT_MAX
+#include <limits.h>
+#include <math.h>
#define __STDC_LIMIT_MACROS
-#include "xatlas.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include "xatlas.h"
#ifndef XA_DEBUG
#ifdef NDEBUG
@@ -70,10 +70,7 @@ Copyright (c) 2012 Brandon Pelfrey
#define XA_XSTR(x) XA_STR(x)
#ifndef XA_ASSERT
-#define XA_ASSERT(exp) \
- if (!(exp)) { \
- XA_PRINT_WARNING("\rASSERT: %s %s %d\n", XA_XSTR(exp), __FILE__, __LINE__); \
- }
+#define XA_ASSERT(exp) if (!(exp)) { XA_PRINT_WARNING("\rASSERT: %s %s %d\n", XA_XSTR(exp), __FILE__, __LINE__); }
#endif
#ifndef XA_DEBUG_ASSERT
@@ -81,20 +78,20 @@ Copyright (c) 2012 Brandon Pelfrey
#endif
#ifndef XA_PRINT
-#define XA_PRINT(...) \
+#define XA_PRINT(...) \
if (xatlas::internal::s_print && xatlas::internal::s_printVerbose) \
xatlas::internal::s_print(__VA_ARGS__);
#endif
#ifndef XA_PRINT_WARNING
-#define XA_PRINT_WARNING(...) \
+#define XA_PRINT_WARNING(...) \
if (xatlas::internal::s_print) \
xatlas::internal::s_print(__VA_ARGS__);
#endif
#define XA_ALLOC(tag, type) (type *)internal::Realloc(nullptr, sizeof(type), tag, __FILE__, __LINE__)
-#define XA_ALLOC_ARRAY(tag, type, num) (type *)internal::Realloc(nullptr, sizeof(type) * num, tag, __FILE__, __LINE__)
-#define XA_REALLOC(tag, ptr, type, num) (type *)internal::Realloc(ptr, sizeof(type) * num, tag, __FILE__, __LINE__)
+#define XA_ALLOC_ARRAY(tag, type, num) (type *)internal::Realloc(nullptr, sizeof(type) * (num), tag, __FILE__, __LINE__)
+#define XA_REALLOC(tag, ptr, type, num) (type *)internal::Realloc(ptr, sizeof(type) * (num), tag, __FILE__, __LINE__)
#define XA_REALLOC_SIZE(tag, ptr, size) (uint8_t *)internal::Realloc(ptr, size, tag, __FILE__, __LINE__)
#define XA_FREE(ptr) internal::Realloc(ptr, 0, internal::MemTag::Default, __FILE__, __LINE__)
#define XA_NEW(tag, type) new (XA_ALLOC(tag, type)) type()
@@ -125,11 +122,12 @@ Copyright (c) 2012 Brandon Pelfrey
#define XA_DEBUG_HEAP 0
#define XA_DEBUG_SINGLE_CHART 0
+#define XA_DEBUG_ALL_CHARTS_INVALID 0
#define XA_DEBUG_EXPORT_ATLAS_IMAGES 0
#define XA_DEBUG_EXPORT_ATLAS_IMAGES_PER_CHART 0 // Export an atlas image after each chart is added.
#define XA_DEBUG_EXPORT_BOUNDARY_GRID 0
#define XA_DEBUG_EXPORT_TGA (XA_DEBUG_EXPORT_ATLAS_IMAGES || XA_DEBUG_EXPORT_BOUNDARY_GRID)
-#define XA_DEBUG_EXPORT_OBJ_SOURCE_MESHES 0
+#define XA_DEBUG_EXPORT_OBJ_FACE_GROUPS 0
#define XA_DEBUG_EXPORT_OBJ_CHART_GROUPS 0
#define XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS 0
#define XA_DEBUG_EXPORT_OBJ_CHARTS 0
@@ -139,13 +137,19 @@ Copyright (c) 2012 Brandon Pelfrey
#define XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION 0
#define XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS 0
-#define XA_DEBUG_EXPORT_OBJ (0 || XA_DEBUG_EXPORT_OBJ_SOURCE_MESHES || XA_DEBUG_EXPORT_OBJ_CHART_GROUPS || XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS || XA_DEBUG_EXPORT_OBJ_CHARTS || XA_DEBUG_EXPORT_OBJ_BEFORE_FIX_TJUNCTION || XA_DEBUG_EXPORT_OBJ_CLOSE_HOLES_ERROR || XA_DEBUG_EXPORT_OBJ_CHARTS_AFTER_PARAMETERIZATION || XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION || XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS)
+#define XA_DEBUG_EXPORT_OBJ (0 \
+ || XA_DEBUG_EXPORT_OBJ_FACE_GROUPS \
+ || XA_DEBUG_EXPORT_OBJ_CHART_GROUPS \
+ || XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS \
+ || XA_DEBUG_EXPORT_OBJ_CHARTS \
+ || XA_DEBUG_EXPORT_OBJ_BEFORE_FIX_TJUNCTION \
+ || XA_DEBUG_EXPORT_OBJ_CLOSE_HOLES_ERROR \
+ || XA_DEBUG_EXPORT_OBJ_CHARTS_AFTER_PARAMETERIZATION \
+ || XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION \
+ || XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS)
#ifdef _MSC_VER
-#define XA_FOPEN(_file, _filename, _mode) \
- { \
- if (fopen_s(&_file, _filename, _mode) != 0) _file = NULL; \
- }
+#define XA_FOPEN(_file, _filename, _mode) { if (fopen_s(&_file, _filename, _mode) != 0) _file = NULL; }
#define XA_SPRINTF(_buffer, _size, _format, ...) sprintf_s(_buffer, _size, _format, __VA_ARGS__)
#else
#define XA_FOPEN(_file, _filename, _mode) _file = fopen(_filename, _mode)
@@ -160,12 +164,90 @@ static FreeFunc s_free = free;
static PrintFunc s_print = printf;
static bool s_printVerbose = false;
-struct MemTag {
- enum {
+#if XA_PROFILE
+#define XA_PROFILE_START(var) const clock_t var##Start = clock();
+#define XA_PROFILE_END(var) internal::s_profile.var += clock() - var##Start;
+#define XA_PROFILE_PRINT_AND_RESET(label, var) XA_PRINT("%s%.2f seconds (%g ms)\n", label, internal::clockToSeconds(internal::s_profile.var), internal::clockToMs(internal::s_profile.var)); internal::s_profile.var = 0;
+#define XA_PROFILE_ALLOC 0
+
+struct ProfileData
+{
+#if XA_PROFILE_ALLOC
+ std::atomic<clock_t> alloc;
+#endif
+ clock_t addMeshReal;
+ clock_t addMeshCopyData;
+ std::atomic<clock_t> addMeshThread;
+ std::atomic<clock_t> addMeshCreateColocals;
+ clock_t computeChartsReal;
+ std::atomic<clock_t> computeChartsThread;
+ std::atomic<clock_t> createFaceGroups;
+ std::atomic<clock_t> extractInvalidMeshGeometry;
+ std::atomic<clock_t> chartGroupComputeChartsReal;
+ std::atomic<clock_t> chartGroupComputeChartsThread;
+ std::atomic<clock_t> createChartGroupMesh;
+ std::atomic<clock_t> createChartGroupMeshColocals;
+ std::atomic<clock_t> createChartGroupMeshBoundaries;
+ std::atomic<clock_t> buildAtlas;
+ std::atomic<clock_t> buildAtlasInit;
+ std::atomic<clock_t> planarCharts;
+ std::atomic<clock_t> clusteredCharts;
+ std::atomic<clock_t> clusteredChartsPlaceSeeds;
+ std::atomic<clock_t> clusteredChartsPlaceSeedsBoundaryIntersection;
+ std::atomic<clock_t> clusteredChartsRelocateSeeds;
+ std::atomic<clock_t> clusteredChartsReset;
+ std::atomic<clock_t> clusteredChartsGrow;
+ std::atomic<clock_t> clusteredChartsGrowBoundaryIntersection;
+ std::atomic<clock_t> clusteredChartsMerge;
+ std::atomic<clock_t> clusteredChartsFillHoles;
+ std::atomic<clock_t> copyChartFaces;
+ clock_t parameterizeChartsReal;
+ std::atomic<clock_t> parameterizeChartsThread;
+ std::atomic<clock_t> createChartMesh;
+ std::atomic<clock_t> fixChartMeshTJunctions;
+ std::atomic<clock_t> closeChartMeshHoles;
+ std::atomic<clock_t> parameterizeChartsOrthogonal;
+ std::atomic<clock_t> parameterizeChartsLSCM;
+ std::atomic<clock_t> parameterizeChartsRecompute;
+ std::atomic<clock_t> parameterizeChartsPiecewise;
+ std::atomic<clock_t> parameterizeChartsPiecewiseBoundaryIntersection;
+ std::atomic<clock_t> parameterizeChartsEvaluateQuality;
+ clock_t packCharts;
+ clock_t packChartsAddCharts;
+ std::atomic<clock_t> packChartsAddChartsThread;
+ std::atomic<clock_t> packChartsAddChartsRestoreTexcoords;
+ clock_t packChartsRasterize;
+ clock_t packChartsDilate;
+ clock_t packChartsFindLocation;
+ clock_t packChartsBlit;
+ clock_t buildOutputMeshes;
+};
+
+static ProfileData s_profile;
+
+static double clockToMs(clock_t c)
+{
+ return c * 1000.0 / CLOCKS_PER_SEC;
+}
+
+static double clockToSeconds(clock_t c)
+{
+ return c / (double)CLOCKS_PER_SEC;
+}
+#else
+#define XA_PROFILE_START(var)
+#define XA_PROFILE_END(var)
+#define XA_PROFILE_PRINT_AND_RESET(label, var)
+#define XA_PROFILE_ALLOC 0
+#endif
+
+struct MemTag
+{
+ enum
+ {
Default,
BitImage,
BVH,
- FullVector,
Matrix,
Mesh,
MeshBoundaries,
@@ -175,6 +257,7 @@ struct MemTag {
MeshNormals,
MeshPositions,
MeshTexcoords,
+ OpenNL,
SegmentAtlasChartCandidates,
SegmentAtlasChartFaces,
SegmentAtlasMeshData,
@@ -184,7 +267,8 @@ struct MemTag {
};
#if XA_DEBUG_HEAP
-struct AllocHeader {
+struct AllocHeader
+{
size_t size;
const char *file;
int line;
@@ -197,10 +281,11 @@ struct AllocHeader {
static std::mutex s_allocMutex;
static AllocHeader *s_allocRoot = nullptr;
static size_t s_allocTotalCount = 0, s_allocTotalSize = 0, s_allocPeakSize = 0, s_allocCount[MemTag::Count] = { 0 }, s_allocTotalTagSize[MemTag::Count] = { 0 }, s_allocPeakTagSize[MemTag::Count] = { 0 };
-static uint32_t s_allocId = 0;
+static uint32_t s_allocId =0 ;
static constexpr uint32_t kAllocRedzone = 0x12345678;
-static void *Realloc(void *ptr, size_t size, int tag, const char *file, int line) {
+static void *Realloc(void *ptr, size_t size, int tag, const char *file, int line)
+{
std::unique_lock<std::mutex> lock(s_allocMutex);
if (!size && !ptr)
return nullptr;
@@ -261,7 +346,8 @@ static void *Realloc(void *ptr, size_t size, int tag, const char *file, int line
return newPtr + sizeof(AllocHeader);
}
-static void ReportLeaks() {
+static void ReportLeaks()
+{
printf("Checking for memory leaks...\n");
bool anyLeaks = false;
AllocHeader *header = s_allocRoot;
@@ -289,14 +375,14 @@ static void ReportLeaks() {
s_allocTotalTagSize[i] = s_allocPeakTagSize[i] = 0;
}
-static void PrintMemoryUsage() {
+static void PrintMemoryUsage()
+{
XA_PRINT("Total allocations: %zu\n", s_allocTotalCount);
XA_PRINT("Memory usage: %0.2fMB current, %0.2fMB peak\n", internal::s_allocTotalSize / 1024.0f / 1024.0f, internal::s_allocPeakSize / 1024.0f / 1024.0f);
static const char *labels[] = { // Sync with MemTag
"Default",
"BitImage",
"BVH",
- "FullVector",
"Matrix",
"Mesh",
"MeshBoundaries",
@@ -306,6 +392,7 @@ static void PrintMemoryUsage() {
"MeshNormals",
"MeshPositions",
"MeshTexcoords",
+ "OpenNL",
"SegmentAtlasChartCandidates",
"SegmentAtlasChartFaces",
"SegmentAtlasMeshData",
@@ -318,158 +405,116 @@ static void PrintMemoryUsage() {
#define XA_PRINT_MEM_USAGE internal::PrintMemoryUsage();
#else
-static void *Realloc(void *ptr, size_t size, int /*tag*/, const char * /*file*/, int /*line*/) {
+static void *Realloc(void *ptr, size_t size, int /*tag*/, const char * /*file*/, int /*line*/)
+{
if (size == 0 && !ptr)
return nullptr;
if (size == 0 && s_free) {
s_free(ptr);
return nullptr;
}
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_START(alloc)
+#endif
void *mem = s_realloc(ptr, size);
- if (size > 0) {
- XA_DEBUG_ASSERT(mem);
- }
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_END(alloc)
+#endif
+ XA_DEBUG_ASSERT(size <= 0 || (size > 0 && mem));
return mem;
}
#define XA_PRINT_MEM_USAGE
#endif
-#if XA_PROFILE
-#define XA_PROFILE_START(var) const clock_t var##Start = clock();
-#define XA_PROFILE_END(var) internal::s_profile.var += clock() - var##Start;
-#define XA_PROFILE_PRINT_AND_RESET(label, var) \
- XA_PRINT("%s%.2f seconds (%g ms)\n", label, internal::clockToSeconds(internal::s_profile.var), internal::clockToMs(internal::s_profile.var)); \
- internal::s_profile.var = 0;
-
-struct ProfileData {
- clock_t addMeshReal;
- clock_t addMeshCopyData;
- std::atomic<clock_t> addMeshThread;
- std::atomic<clock_t> addMeshCreateColocals;
- std::atomic<clock_t> addMeshCreateFaceGroups;
- std::atomic<clock_t> addMeshCreateChartGroupsReal;
- std::atomic<clock_t> addMeshCreateChartGroupsThread;
- clock_t computeChartsReal;
- std::atomic<clock_t> computeChartsThread;
- std::atomic<clock_t> buildAtlas;
- std::atomic<clock_t> buildAtlasInit;
- std::atomic<clock_t> buildAtlasPlaceSeeds;
- std::atomic<clock_t> buildAtlasRelocateSeeds;
- std::atomic<clock_t> buildAtlasResetCharts;
- std::atomic<clock_t> buildAtlasGrowCharts;
- std::atomic<clock_t> buildAtlasMergeCharts;
- std::atomic<clock_t> buildAtlasFillHoles;
- std::atomic<clock_t> createChartMeshesReal;
- std::atomic<clock_t> createChartMeshesThread;
- std::atomic<clock_t> fixChartMeshTJunctions;
- std::atomic<clock_t> closeChartMeshHoles;
- clock_t parameterizeChartsReal;
- std::atomic<clock_t> parameterizeChartsThread;
- std::atomic<clock_t> parameterizeChartsOrthogonal;
- std::atomic<clock_t> parameterizeChartsLSCM;
- std::atomic<clock_t> parameterizeChartsEvaluateQuality;
- clock_t packCharts;
- clock_t packChartsAddCharts;
- std::atomic<clock_t> packChartsAddChartsThread;
- std::atomic<clock_t> packChartsAddChartsRestoreTexcoords;
- clock_t packChartsRasterize;
- clock_t packChartsDilate;
- clock_t packChartsFindLocation;
- clock_t packChartsBlit;
- clock_t buildOutputMeshes;
-};
-
-static ProfileData s_profile;
-
-static double clockToMs(clock_t c) {
- return c * 1000.0 / CLOCKS_PER_SEC;
-}
-
-static double clockToSeconds(clock_t c) {
- return c / (double)CLOCKS_PER_SEC;
-}
-#else
-#define XA_PROFILE_START(var)
-#define XA_PROFILE_END(var)
-#define XA_PROFILE_PRINT_AND_RESET(label, var)
-#endif
-
static constexpr float kPi = 3.14159265358979323846f;
static constexpr float kPi2 = 6.28318530717958647692f;
-static constexpr float kPi4 = 12.56637061435917295384f;
static constexpr float kEpsilon = 0.0001f;
static constexpr float kAreaEpsilon = FLT_EPSILON;
static constexpr float kNormalEpsilon = 0.001f;
-static int align(int x, int a) {
+static int align(int x, int a)
+{
return (x + a - 1) & ~(a - 1);
}
template <typename T>
-static T max(const T &a, const T &b) {
+static T max(const T &a, const T &b)
+{
return a > b ? a : b;
}
template <typename T>
-static T min(const T &a, const T &b) {
+static T min(const T &a, const T &b)
+{
return a < b ? a : b;
}
template <typename T>
-static T max3(const T &a, const T &b, const T &c) {
+static T max3(const T &a, const T &b, const T &c)
+{
return max(a, max(b, c));
}
/// Return the maximum of the three arguments.
template <typename T>
-static T min3(const T &a, const T &b, const T &c) {
+static T min3(const T &a, const T &b, const T &c)
+{
return min(a, min(b, c));
}
/// Clamp between two values.
template <typename T>
-static T clamp(const T &x, const T &a, const T &b) {
+static T clamp(const T &x, const T &a, const T &b)
+{
return min(max(x, a), b);
}
template <typename T>
-static void swap(T &a, T &b) {
+static void swap(T &a, T &b)
+{
T temp = a;
a = b;
b = temp;
}
-union FloatUint32 {
+union FloatUint32
+{
float f;
uint32_t u;
};
-static bool isFinite(float f) {
+static bool isFinite(float f)
+{
FloatUint32 fu;
fu.f = f;
return fu.u != 0x7F800000u && fu.u != 0x7F800001u;
}
-static bool isNan(float f) {
+static bool isNan(float f)
+{
return f != f;
}
// Robust floating point comparisons:
// http://realtimecollisiondetection.net/blog/?p=89
-static bool equal(const float f0, const float f1, const float epsilon) {
+static bool equal(const float f0, const float f1, const float epsilon)
+{
//return fabs(f0-f1) <= epsilon;
return fabs(f0 - f1) <= epsilon * max3(1.0f, fabsf(f0), fabsf(f1));
}
-static int ftoi_ceil(float val) {
+static int ftoi_ceil(float val)
+{
return (int)ceilf(val);
}
-static bool isZero(const float f, const float epsilon) {
+static bool isZero(const float f, const float epsilon)
+{
return fabs(f) <= epsilon;
}
-static float square(float f) {
+static float square(float f)
+{
return f * f;
}
@@ -479,8 +524,9 @@ static float square(float f) {
* @note isPowerOfTwo(x) == true -> nextPowerOfTwo(x) == x
* @note nextPowerOfTwo(x) = 2 << log2(x-1)
*/
-static uint32_t nextPowerOfTwo(uint32_t x) {
- XA_DEBUG_ASSERT(x != 0);
+static uint32_t nextPowerOfTwo(uint32_t x)
+{
+ XA_DEBUG_ASSERT( x != 0 );
// On modern CPUs this is supposed to be as fast as using the bsr instruction.
x--;
x |= x >> 1;
@@ -491,59 +537,38 @@ static uint32_t nextPowerOfTwo(uint32_t x) {
return x + 1;
}
-static uint32_t sdbmHash(const void *data_in, uint32_t size, uint32_t h = 5381) {
- const uint8_t *data = (const uint8_t *)data_in;
- uint32_t i = 0;
- while (i < size) {
- h = (h << 16) + (h << 6) - h + (uint32_t)data[i++];
- }
- return h;
-}
-
-template <typename T>
-static uint32_t hash(const T &t, uint32_t h = 5381) {
- return sdbmHash(&t, sizeof(T), h);
-}
-
-// Functors for hash table:
-template <typename Key>
-struct Hash {
- uint32_t operator()(const Key &k) const { return hash(k); }
-};
-
-template <typename Key>
-struct Equal {
- bool operator()(const Key &k0, const Key &k1) const { return k0 == k1; }
-};
-
-class Vector2 {
+class Vector2
+{
public:
Vector2() {}
- explicit Vector2(float f) :
- x(f), y(f) {}
- Vector2(float x, float y) :
- x(x), y(y) {}
+ explicit Vector2(float f) : x(f), y(f) {}
+ Vector2(float x, float y): x(x), y(y) {}
- Vector2 operator-() const {
+ Vector2 operator-() const
+ {
return Vector2(-x, -y);
}
- void operator+=(const Vector2 &v) {
+ void operator+=(const Vector2 &v)
+ {
x += v.x;
y += v.y;
}
- void operator-=(const Vector2 &v) {
+ void operator-=(const Vector2 &v)
+ {
x -= v.x;
y -= v.y;
}
- void operator*=(float s) {
+ void operator*=(float s)
+ {
x *= s;
y *= s;
}
- void operator*=(const Vector2 &v) {
+ void operator*=(const Vector2 &v)
+ {
x *= v.x;
y *= v.y;
}
@@ -551,11 +576,13 @@ public:
float x, y;
};
-static bool operator==(const Vector2 &a, const Vector2 &b) {
+static bool operator==(const Vector2 &a, const Vector2 &b)
+{
return a.x == b.x && a.y == b.y;
}
-static bool operator!=(const Vector2 &a, const Vector2 &b) {
+static bool operator!=(const Vector2 &a, const Vector2 &b)
+{
return a.x != b.x || a.y != b.y;
}
@@ -564,33 +591,40 @@ static bool operator!=(const Vector2 &a, const Vector2 &b) {
return Vector2(a.x + b.x, a.y + b.y);
}*/
-static Vector2 operator-(const Vector2 &a, const Vector2 &b) {
+static Vector2 operator-(const Vector2 &a, const Vector2 &b)
+{
return Vector2(a.x - b.x, a.y - b.y);
}
-static Vector2 operator*(const Vector2 &v, float s) {
+static Vector2 operator*(const Vector2 &v, float s)
+{
return Vector2(v.x * s, v.y * s);
}
-static float dot(const Vector2 &a, const Vector2 &b) {
+static float dot(const Vector2 &a, const Vector2 &b)
+{
return a.x * b.x + a.y * b.y;
}
-static float lengthSquared(const Vector2 &v) {
+static float lengthSquared(const Vector2 &v)
+{
return v.x * v.x + v.y * v.y;
}
-static float length(const Vector2 &v) {
+static float length(const Vector2 &v)
+{
return sqrtf(lengthSquared(v));
}
#if XA_DEBUG
-static bool isNormalized(const Vector2 &v, float epsilon = kNormalEpsilon) {
+static bool isNormalized(const Vector2 &v, float epsilon = kNormalEpsilon)
+{
return equal(length(v), 1, epsilon);
}
#endif
-static Vector2 normalize(const Vector2 &v, float epsilon) {
+static Vector2 normalize(const Vector2 &v, float epsilon)
+{
float l = length(v);
XA_DEBUG_ASSERT(!isZero(l, epsilon));
XA_UNUSED(epsilon);
@@ -599,30 +633,36 @@ static Vector2 normalize(const Vector2 &v, float epsilon) {
return n;
}
-static Vector2 normalizeSafe(const Vector2 &v, const Vector2 &fallback, float epsilon) {
+static Vector2 normalizeSafe(const Vector2 &v, const Vector2 &fallback, float epsilon)
+{
float l = length(v);
if (isZero(l, epsilon))
return fallback;
return v * (1.0f / l);
}
-static bool equal(const Vector2 &v1, const Vector2 &v2, float epsilon) {
+static bool equal(const Vector2 &v1, const Vector2 &v2, float epsilon)
+{
return equal(v1.x, v2.x, epsilon) && equal(v1.y, v2.y, epsilon);
}
-static Vector2 min(const Vector2 &a, const Vector2 &b) {
+static Vector2 min(const Vector2 &a, const Vector2 &b)
+{
return Vector2(min(a.x, b.x), min(a.y, b.y));
}
-static Vector2 max(const Vector2 &a, const Vector2 &b) {
+static Vector2 max(const Vector2 &a, const Vector2 &b)
+{
return Vector2(max(a.x, b.x), max(a.y, b.y));
}
-static bool isFinite(const Vector2 &v) {
+static bool isFinite(const Vector2 &v)
+{
return isFinite(v.x) && isFinite(v.y);
}
-static float triangleArea(const Vector2 &a, const Vector2 &b, const Vector2 &c) {
+static float triangleArea(const Vector2 &a, const Vector2 &b, const Vector2 &c)
+{
// IC: While it may be appealing to use the following expression:
//return (c.x * a.y + a.x * b.y + b.x * c.y - b.x * a.y - c.x * b.y - a.x * c.y) * 0.5f;
// That's actually a terrible idea. Small triangles far from the origin can end up producing fairly large floating point
@@ -636,7 +676,8 @@ static float triangleArea(const Vector2 &a, const Vector2 &b, const Vector2 &c)
return (v0.x * v1.y - v0.y * v1.x) * 0.5f;
}
-static bool linesIntersect(const Vector2 &a1, const Vector2 &a2, const Vector2 &b1, const Vector2 &b2, float epsilon) {
+static bool linesIntersect(const Vector2 &a1, const Vector2 &a2, const Vector2 &b1, const Vector2 &b2, float epsilon)
+{
const Vector2 v0 = a2 - a1;
const Vector2 v1 = b2 - b1;
const float denom = -v1.x * v0.y + v0.x * v1.y;
@@ -644,70 +685,76 @@ static bool linesIntersect(const Vector2 &a1, const Vector2 &a2, const Vector2 &
return false;
const float s = (-v0.y * (a1.x - b1.x) + v0.x * (a1.y - b1.y)) / denom;
if (s > epsilon && s < 1.0f - epsilon) {
- const float t = (v1.x * (a1.y - b1.y) - v1.y * (a1.x - b1.x)) / denom;
+ const float t = ( v1.x * (a1.y - b1.y) - v1.y * (a1.x - b1.x)) / denom;
return t > epsilon && t < 1.0f - epsilon;
}
return false;
}
-struct Vector2i {
+struct Vector2i
+{
Vector2i() {}
- Vector2i(int32_t x, int32_t y) :
- x(x), y(y) {}
+ Vector2i(int32_t x, int32_t y) : x(x), y(y) {}
int32_t x, y;
};
-class Vector3 {
+class Vector3
+{
public:
Vector3() {}
- explicit Vector3(float f) :
- x(f), y(f), z(f) {}
- Vector3(float x, float y, float z) :
- x(x), y(y), z(z) {}
- Vector3(const Vector2 &v, float z) :
- x(v.x), y(v.y), z(z) {}
-
- Vector2 xy() const {
+ explicit Vector3(float f) : x(f), y(f), z(f) {}
+ Vector3(float x, float y, float z) : x(x), y(y), z(z) {}
+ Vector3(const Vector2 &v, float z) : x(v.x), y(v.y), z(z) {}
+
+ Vector2 xy() const
+ {
return Vector2(x, y);
}
- Vector3 operator-() const {
+ Vector3 operator-() const
+ {
return Vector3(-x, -y, -z);
}
- void operator+=(const Vector3 &v) {
+ void operator+=(const Vector3 &v)
+ {
x += v.x;
y += v.y;
z += v.z;
}
- void operator-=(const Vector3 &v) {
+ void operator-=(const Vector3 &v)
+ {
x -= v.x;
y -= v.y;
z -= v.z;
}
- void operator*=(float s) {
+ void operator*=(float s)
+ {
x *= s;
y *= s;
z *= s;
}
- void operator/=(float s) {
+ void operator/=(float s)
+ {
float is = 1.0f / s;
x *= is;
y *= is;
z *= is;
}
- void operator*=(const Vector3 &v) {
+ void operator*=(const Vector3 &v)
+ {
x *= v.x;
y *= v.y;
z *= v.z;
}
- void operator/=(const Vector3 &v) {
+ void operator/=(const Vector3 &v)
+ {
x /= v.x;
y /= v.y;
z /= v.z;
@@ -716,43 +763,53 @@ public:
float x, y, z;
};
-static Vector3 operator+(const Vector3 &a, const Vector3 &b) {
+static Vector3 operator+(const Vector3 &a, const Vector3 &b)
+{
return Vector3(a.x + b.x, a.y + b.y, a.z + b.z);
}
-static Vector3 operator-(const Vector3 &a, const Vector3 &b) {
+static Vector3 operator-(const Vector3 &a, const Vector3 &b)
+{
return Vector3(a.x - b.x, a.y - b.y, a.z - b.z);
}
-static Vector3 cross(const Vector3 &a, const Vector3 &b) {
+static Vector3 cross(const Vector3 &a, const Vector3 &b)
+{
return Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
}
-static Vector3 operator*(const Vector3 &v, float s) {
+static Vector3 operator*(const Vector3 &v, float s)
+{
return Vector3(v.x * s, v.y * s, v.z * s);
}
-static Vector3 operator/(const Vector3 &v, float s) {
+static Vector3 operator/(const Vector3 &v, float s)
+{
return v * (1.0f / s);
}
-static float dot(const Vector3 &a, const Vector3 &b) {
+static float dot(const Vector3 &a, const Vector3 &b)
+{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
-static float lengthSquared(const Vector3 &v) {
+static float lengthSquared(const Vector3 &v)
+{
return v.x * v.x + v.y * v.y + v.z * v.z;
}
-static float length(const Vector3 &v) {
+static float length(const Vector3 &v)
+{
return sqrtf(lengthSquared(v));
}
-static bool isNormalized(const Vector3 &v, float epsilon = kNormalEpsilon) {
+static bool isNormalized(const Vector3 &v, float epsilon = kNormalEpsilon)
+{
return equal(length(v), 1, epsilon);
}
-static Vector3 normalize(const Vector3 &v, float epsilon) {
+static Vector3 normalize(const Vector3 &v, float epsilon)
+{
float l = length(v);
XA_DEBUG_ASSERT(!isZero(l, epsilon));
XA_UNUSED(epsilon);
@@ -761,7 +818,8 @@ static Vector3 normalize(const Vector3 &v, float epsilon) {
return n;
}
-static Vector3 normalizeSafe(const Vector3 &v, const Vector3 &fallback, float epsilon) {
+static Vector3 normalizeSafe(const Vector3 &v, const Vector3 &fallback, float epsilon)
+{
float l = length(v);
if (isZero(l, epsilon)) {
return fallback;
@@ -769,59 +827,80 @@ static Vector3 normalizeSafe(const Vector3 &v, const Vector3 &fallback, float ep
return v * (1.0f / l);
}
-static bool equal(const Vector3 &v0, const Vector3 &v1, float epsilon) {
+static bool equal(const Vector3 &v0, const Vector3 &v1, float epsilon)
+{
return fabs(v0.x - v1.x) <= epsilon && fabs(v0.y - v1.y) <= epsilon && fabs(v0.z - v1.z) <= epsilon;
}
-static Vector3 min(const Vector3 &a, const Vector3 &b) {
+static Vector3 min(const Vector3 &a, const Vector3 &b)
+{
return Vector3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
}
-static Vector3 max(const Vector3 &a, const Vector3 &b) {
+static Vector3 max(const Vector3 &a, const Vector3 &b)
+{
return Vector3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
}
#if XA_DEBUG
-bool isFinite(const Vector3 &v) {
+bool isFinite(const Vector3 &v)
+{
return isFinite(v.x) && isFinite(v.y) && isFinite(v.z);
}
#endif
-struct Extents2 {
+struct Extents2
+{
Vector2 min, max;
- void reset() {
+ Extents2() {}
+
+ Extents2(Vector2 p1, Vector2 p2)
+ {
+ min = xatlas::internal::min(p1, p2);
+ max = xatlas::internal::max(p1, p2);
+ }
+
+ void reset()
+ {
min.x = min.y = FLT_MAX;
max.x = max.y = -FLT_MAX;
}
- void add(Vector2 p) {
+ void add(Vector2 p)
+ {
min = xatlas::internal::min(min, p);
max = xatlas::internal::max(max, p);
}
- Vector2 midpoint() const {
+ Vector2 midpoint() const
+ {
return Vector2(min.x + (max.x - min.x) * 0.5f, min.y + (max.y - min.y) * 0.5f);
}
- static bool intersect(Extents2 e1, Extents2 e2) {
+ static bool intersect(const Extents2 &e1, const Extents2 &e2)
+ {
return e1.min.x <= e2.max.x && e1.max.x >= e2.min.x && e1.min.y <= e2.max.y && e1.max.y >= e2.min.y;
}
};
-struct Plane {
+struct Plane
+{
Plane() = default;
-
- Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3) {
+
+ Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3)
+ {
normal = cross(p2 - p1, p3 - p1);
dist = dot(normal, p1);
}
- float distance(const Vector3 &p) const {
+ float distance(const Vector3 &p) const
+ {
return dot(normal, p) - dist;
}
- void normalize() {
+ void normalize()
+ {
const float len = length(normal);
if (len > 0.0f) {
const float il = 1.0f / len;
@@ -834,7 +913,8 @@ struct Plane {
float dist;
};
-static bool lineIntersectsPoint(const Vector3 &point, const Vector3 &lineStart, const Vector3 &lineEnd, float *t, float epsilon) {
+static bool lineIntersectsPoint(const Vector3 &point, const Vector3 &lineStart, const Vector3 &lineEnd, float *t, float epsilon)
+{
float tt;
if (!t)
t = &tt;
@@ -851,19 +931,22 @@ static bool lineIntersectsPoint(const Vector3 &point, const Vector3 &lineStart,
return *t > kEpsilon && *t < 1.0f - kEpsilon;
}
-static bool sameSide(const Vector3 &p1, const Vector3 &p2, const Vector3 &a, const Vector3 &b) {
+static bool sameSide(const Vector3 &p1, const Vector3 &p2, const Vector3 &a, const Vector3 &b)
+{
const Vector3 &ab = b - a;
return dot(cross(ab, p1 - a), cross(ab, p2 - a)) >= 0.0f;
}
// http://blackpawn.com/texts/pointinpoly/default.html
-static bool pointInTriangle(const Vector3 &p, const Vector3 &a, const Vector3 &b, const Vector3 &c) {
+static bool pointInTriangle(const Vector3 &p, const Vector3 &a, const Vector3 &b, const Vector3 &c)
+{
return sameSide(p, a, b, c) && sameSide(p, b, a, c) && sameSide(p, c, a, b);
}
#if XA_CLOSE_HOLES_CHECK_EDGE_INTERSECTION
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
-static bool rayIntersectsTriangle(const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 *tri, float *t) {
+static bool rayIntersectsTriangle(const Vector3 &rayOrigin, const Vector3 &rayDir, const Vector3 *tri, float *t)
+{
*t = 0.0f;
const Vector3 &edge1 = tri[1] - tri[0];
const Vector3 &edge2 = tri[2] - tri[0];
@@ -890,47 +973,50 @@ static bool rayIntersectsTriangle(const Vector3 &rayOrigin, const Vector3 &rayDi
#endif
// From Fast-BVH
-struct AABB {
- AABB() :
- min(FLT_MAX, FLT_MAX, FLT_MAX), max(-FLT_MAX, -FLT_MAX, -FLT_MAX) {}
- AABB(const Vector3 &min, const Vector3 &max) :
- min(min), max(max) {}
- AABB(const Vector3 &p, float radius = 0.0f) :
- min(p), max(p) {
- if (radius > 0.0f) expand(radius);
- }
+struct AABB
+{
+ AABB() : min(FLT_MAX, FLT_MAX, FLT_MAX), max(-FLT_MAX, -FLT_MAX, -FLT_MAX) {}
+ AABB(const Vector3 &min, const Vector3 &max) : min(min), max(max) { }
+ AABB(const Vector3 &p, float radius = 0.0f) : min(p), max(p) { if (radius > 0.0f) expand(radius); }
- bool intersect(const AABB &other) const {
+ bool intersect(const AABB &other) const
+ {
return min.x <= other.max.x && max.x >= other.min.x && min.y <= other.max.y && max.y >= other.min.y && min.z <= other.max.z && max.z >= other.min.z;
}
- void expandToInclude(const Vector3 &p) {
+ void expandToInclude(const Vector3 &p)
+ {
min = internal::min(min, p);
max = internal::max(max, p);
}
- void expandToInclude(const AABB &aabb) {
+ void expandToInclude(const AABB &aabb)
+ {
min = internal::min(min, aabb.min);
max = internal::max(max, aabb.max);
}
- void expand(float amount) {
+ void expand(float amount)
+ {
min -= Vector3(amount);
max += Vector3(amount);
}
- Vector3 centroid() const {
+ Vector3 centroid() const
+ {
return min + (max - min) * 0.5f;
}
- uint32_t maxDimension() const {
+ uint32_t maxDimension() const
+ {
const Vector3 extent = max - min;
uint32_t result = 0;
if (extent.y > extent.x) {
result = 1;
if (extent.z > extent.y)
result = 2;
- } else if (extent.z > extent.x)
+ }
+ else if(extent.z > extent.x)
result = 2;
return result;
}
@@ -938,9 +1024,10 @@ struct AABB {
Vector3 min, max;
};
-struct ArrayBase {
- ArrayBase(uint32_t elementSize, int memTag = MemTag::Default) :
- buffer(nullptr), elementSize(elementSize), size(0), capacity(0) {
+struct ArrayBase
+{
+ ArrayBase(uint32_t elementSize, int memTag = MemTag::Default) : buffer(nullptr), elementSize(elementSize), size(0), capacity(0)
+ {
#if XA_DEBUG_HEAP
this->memTag = memTag;
#else
@@ -948,26 +1035,31 @@ struct ArrayBase {
#endif
}
- ~ArrayBase() {
+ ~ArrayBase()
+ {
XA_FREE(buffer);
}
- XA_INLINE void clear() {
+ XA_INLINE void clear()
+ {
size = 0;
}
- void copyFrom(const uint8_t *data, uint32_t length) {
+ void copyFrom(const uint8_t *data, uint32_t length)
+ {
resize(length, true);
memcpy(buffer, data, length * elementSize);
}
- void copyTo(ArrayBase &other) const {
+ void copyTo(ArrayBase &other) const
+ {
XA_DEBUG_ASSERT(elementSize == other.elementSize);
other.resize(size, true);
memcpy(other.buffer, buffer, size * elementSize);
}
- void destroy() {
+ void destroy()
+ {
size = 0;
XA_FREE(buffer);
buffer = nullptr;
@@ -976,7 +1068,8 @@ struct ArrayBase {
}
// Insert the given element at the given index shifting all the elements up.
- void insertAt(uint32_t index, const uint8_t *value) {
+ void insertAt(uint32_t index, const uint8_t *value)
+ {
XA_DEBUG_ASSERT(index >= 0 && index <= size);
resize(size + 1, false);
if (index < size - 1)
@@ -984,7 +1077,8 @@ struct ArrayBase {
memcpy(&buffer[index * elementSize], value, elementSize);
}
- void moveTo(ArrayBase &other) {
+ void moveTo(ArrayBase &other)
+ {
XA_DEBUG_ASSERT(elementSize == other.elementSize);
other.destroy();
other.buffer = buffer;
@@ -998,18 +1092,21 @@ struct ArrayBase {
elementSize = size = capacity = 0;
}
- void pop_back() {
+ void pop_back()
+ {
XA_DEBUG_ASSERT(size > 0);
resize(size - 1, false);
}
- void push_back(const uint8_t *value) {
+ void push_back(const uint8_t *value)
+ {
XA_DEBUG_ASSERT(value < buffer || value >= buffer + size);
resize(size + 1, false);
memcpy(&buffer[(size - 1) * elementSize], value, elementSize);
}
- void push_back(const ArrayBase &other) {
+ void push_back(const ArrayBase &other)
+ {
XA_DEBUG_ASSERT(elementSize == other.elementSize);
if (other.size == 0)
return;
@@ -1019,19 +1116,31 @@ struct ArrayBase {
}
// Remove the element at the given index. This is an expensive operation!
- void removeAt(uint32_t index) {
+ void removeAt(uint32_t index)
+ {
XA_DEBUG_ASSERT(index >= 0 && index < size);
if (size != 1)
memmove(buffer + elementSize * index, buffer + elementSize * (index + 1), elementSize * (size - 1 - index));
size--;
}
- void reserve(uint32_t desiredSize) {
+ // Element at index is swapped with the last element, then the array length is decremented.
+ void removeAtFast(uint32_t index)
+ {
+ XA_DEBUG_ASSERT(index >= 0 && index < size);
+ if (size != 1 && index != size - 1)
+ memcpy(buffer + elementSize * index, buffer + elementSize * (size - 1), elementSize);
+ size--;
+ }
+
+ void reserve(uint32_t desiredSize)
+ {
if (desiredSize > capacity)
setArrayCapacity(desiredSize);
}
- void resize(uint32_t newSize, bool exact) {
+ void resize(uint32_t newSize, bool exact)
+ {
size = newSize;
if (size > capacity) {
// First allocation is always exact. Otherwise, following allocations grow array to 150% of desired size.
@@ -1044,7 +1153,8 @@ struct ArrayBase {
}
}
- void setArrayCapacity(uint32_t newCapacity) {
+ void setArrayCapacity(uint32_t newCapacity)
+ {
XA_DEBUG_ASSERT(newCapacity >= size);
if (newCapacity == 0) {
// free the buffer.
@@ -1064,8 +1174,9 @@ struct ArrayBase {
}
#if XA_DEBUG_HEAP
- void setMemTag(int memTag) {
- this->memTag = memTag;
+ void setMemTag(int _memTag)
+ {
+ this->memTag = _memTag;
}
#endif
@@ -1078,25 +1189,28 @@ struct ArrayBase {
#endif
};
-template <typename T>
-class Array {
+template<typename T>
+class Array
+{
public:
- Array(int memTag = MemTag::Default) :
- m_base(sizeof(T), memTag) {}
- Array(const Array &) = delete;
+ Array(int memTag = MemTag::Default) : m_base(sizeof(T), memTag) {}
+ Array(const Array&) = delete;
Array &operator=(const Array &) = delete;
- XA_INLINE const T &operator[](uint32_t index) const {
+ XA_INLINE const T &operator[](uint32_t index) const
+ {
XA_DEBUG_ASSERT(index < m_base.size);
return ((const T *)m_base.buffer)[index];
}
- XA_INLINE T &operator[](uint32_t index) {
+ XA_INLINE T &operator[](uint32_t index)
+ {
XA_DEBUG_ASSERT(index < m_base.size);
return ((T *)m_base.buffer)[index];
}
- XA_INLINE const T &back() const {
+ XA_INLINE const T &back() const
+ {
XA_DEBUG_ASSERT(!isEmpty());
return ((const T *)m_base.buffer)[m_base.size - 1];
}
@@ -1104,7 +1218,8 @@ public:
XA_INLINE T *begin() { return (T *)m_base.buffer; }
XA_INLINE void clear() { m_base.clear(); }
- bool contains(const T &value) const {
+ bool contains(const T &value) const
+ {
for (uint32_t i = 0; i < m_base.size; i++) {
if (((const T *)m_base.buffer)[i] == value)
return true;
@@ -1116,6 +1231,7 @@ public:
void copyTo(Array &other) const { m_base.copyTo(other.m_base); }
XA_INLINE const T *data() const { return (const T *)m_base.buffer; }
XA_INLINE T *data() { return (T *)m_base.buffer; }
+ void destroy() { m_base.destroy(); }
XA_INLINE T *end() { return (T *)m_base.buffer + m_base.size; }
XA_INLINE bool isEmpty() const { return m_base.size == 0; }
void insertAt(uint32_t index, const T &value) { m_base.insertAt(index, (const uint8_t *)&value); }
@@ -1124,25 +1240,34 @@ public:
void push_back(const Array &other) { m_base.push_back(other.m_base); }
void pop_back() { m_base.pop_back(); }
void removeAt(uint32_t index) { m_base.removeAt(index); }
+ void removeAtFast(uint32_t index) { m_base.removeAtFast(index); }
void reserve(uint32_t desiredSize) { m_base.reserve(desiredSize); }
void resize(uint32_t newSize) { m_base.resize(newSize, true); }
- void runCtors() {
+ void runCtors()
+ {
for (uint32_t i = 0; i < m_base.size; i++)
new (&((T *)m_base.buffer)[i]) T;
}
- void runDtors() {
+ void runDtors()
+ {
for (uint32_t i = 0; i < m_base.size; i++)
((T *)m_base.buffer)[i].~T();
}
- void setAll(const T &value) {
+ void fill(const T &value)
+ {
auto buffer = (T *)m_base.buffer;
for (uint32_t i = 0; i < m_base.size; i++)
buffer[i] = value;
}
+ void fillBytes(uint8_t value)
+ {
+ memset(m_base.buffer, (int)value, m_base.size * m_base.elementSize);
+ }
+
#if XA_DEBUG_HEAP
void setMemTag(int memTag) { m_base.setMemTag(memTag); }
#endif
@@ -1154,47 +1279,35 @@ private:
ArrayBase m_base;
};
-template <typename T>
-struct ArrayView {
- ArrayView(Array<T> &a) :
- data(a.data()), length(a.size()) {}
- ArrayView(T *data, uint32_t length) :
- data(data), length(length) {}
- ArrayView &operator=(Array<T> &a) {
- data = a.data();
- length = a.size();
- return *this;
- }
- XA_INLINE const T &operator[](uint32_t index) const {
- XA_DEBUG_ASSERT(index < length);
- return data[index];
- }
+template<typename T>
+struct ArrayView
+{
+ ArrayView() : data(nullptr), length(0) {}
+ ArrayView(Array<T> &a) : data(a.data()), length(a.size()) {}
+ ArrayView(T *data, uint32_t length) : data(data), length(length) {}
+ ArrayView &operator=(Array<T> &a) { data = a.data(); length = a.size(); return *this; }
+ XA_INLINE const T &operator[](uint32_t index) const { XA_DEBUG_ASSERT(index < length); return data[index]; }
T *data;
uint32_t length;
};
-template <typename T>
-struct ConstArrayView {
- ConstArrayView(const Array<T> &a) :
- data(a.data()), length(a.size()) {}
- ConstArrayView(const T *data, uint32_t length) :
- data(data), length(length) {}
- ConstArrayView &operator=(const Array<T> &a) {
- data = a.data();
- length = a.size();
- return *this;
- }
- XA_INLINE const T &operator[](uint32_t index) const {
- XA_DEBUG_ASSERT(index < length);
- return data[index];
- }
+template<typename T>
+struct ConstArrayView
+{
+ ConstArrayView() : data(nullptr), length(0) {}
+ ConstArrayView(const Array<T> &a) : data(a.data()), length(a.size()) {}
+ ConstArrayView(const T *data, uint32_t length) : data(data), length(length) {}
+ ConstArrayView &operator=(const Array<T> &a) { data = a.data(); length = a.size(); return *this; }
+ XA_INLINE const T &operator[](uint32_t index) const { XA_DEBUG_ASSERT(index < length); return data[index]; }
const T *data;
uint32_t length;
};
/// Basis class to compute tangent space basis, ortogonalizations and to transform vectors from one space to another.
-struct Basis {
- XA_NODISCARD static Vector3 computeTangent(const Vector3 &normal) {
+struct Basis
+{
+ XA_NODISCARD static Vector3 computeTangent(const Vector3 &normal)
+ {
XA_ASSERT(isNormalized(normal));
// Choose minimum axis.
Vector3 tangent;
@@ -1210,7 +1323,8 @@ struct Basis {
return tangent;
}
- XA_NODISCARD static Vector3 computeBitangent(const Vector3 &normal, const Vector3 &tangent) {
+ XA_NODISCARD static Vector3 computeBitangent(const Vector3 &normal, const Vector3 &tangent)
+ {
return cross(normal, tangent);
}
@@ -1220,31 +1334,42 @@ struct Basis {
};
// Simple bit array.
-class BitArray {
+class BitArray
+{
public:
- BitArray() :
- m_size(0) {}
+ BitArray() : m_size(0) {}
- BitArray(uint32_t sz) {
+ BitArray(uint32_t sz)
+ {
resize(sz);
}
- void resize(uint32_t new_size) {
+ void resize(uint32_t new_size)
+ {
m_size = new_size;
m_wordArray.resize((m_size + 31) >> 5);
}
- bool get(uint32_t index) const {
+ bool get(uint32_t index) const
+ {
XA_DEBUG_ASSERT(index < m_size);
return (m_wordArray[index >> 5] & (1 << (index & 31))) != 0;
}
- void set(uint32_t index) {
+ void set(uint32_t index)
+ {
XA_DEBUG_ASSERT(index < m_size);
m_wordArray[index >> 5] |= (1 << (index & 31));
}
- void zeroOutMemory() {
+ void unset(uint32_t index)
+ {
+ XA_DEBUG_ASSERT(index < m_size);
+ m_wordArray[index >> 5] &= ~(1 << (index & 31));
+ }
+
+ void zeroOutMemory()
+ {
m_wordArray.zeroOutMemory();
}
@@ -1253,13 +1378,13 @@ private:
Array<uint32_t> m_wordArray;
};
-class BitImage {
+class BitImage
+{
public:
- BitImage() :
- m_width(0), m_height(0), m_rowStride(0), m_data(MemTag::BitImage) {}
+ BitImage() : m_width(0), m_height(0), m_rowStride(0), m_data(MemTag::BitImage) {}
- BitImage(uint32_t w, uint32_t h) :
- m_width(w), m_height(h), m_data(MemTag::BitImage) {
+ BitImage(uint32_t w, uint32_t h) : m_width(w), m_height(h), m_data(MemTag::BitImage)
+ {
m_rowStride = (m_width + 63) >> 6;
m_data.resize(m_rowStride * m_height);
m_data.zeroOutMemory();
@@ -1270,14 +1395,16 @@ public:
uint32_t width() const { return m_width; }
uint32_t height() const { return m_height; }
- void copyTo(BitImage &other) {
+ void copyTo(BitImage &other)
+ {
other.m_width = m_width;
other.m_height = m_height;
other.m_rowStride = m_rowStride;
m_data.copyTo(other.m_data);
}
- void resize(uint32_t w, uint32_t h, bool discard) {
+ void resize(uint32_t w, uint32_t h, bool discard)
+ {
const uint32_t rowStride = (w + 63) >> 6;
if (discard) {
m_data.resize(rowStride * h);
@@ -1301,24 +1428,28 @@ public:
m_rowStride = rowStride;
}
- bool get(uint32_t x, uint32_t y) const {
+ bool get(uint32_t x, uint32_t y) const
+ {
XA_DEBUG_ASSERT(x < m_width && y < m_height);
const uint32_t index = (x >> 6) + y * m_rowStride;
return (m_data[index] & (UINT64_C(1) << (uint64_t(x) & UINT64_C(63)))) != 0;
}
- void set(uint32_t x, uint32_t y) {
+ void set(uint32_t x, uint32_t y)
+ {
XA_DEBUG_ASSERT(x < m_width && y < m_height);
const uint32_t index = (x >> 6) + y * m_rowStride;
m_data[index] |= UINT64_C(1) << (uint64_t(x) & UINT64_C(63));
XA_DEBUG_ASSERT(get(x, y));
}
- void zeroOutMemory() {
+ void zeroOutMemory()
+ {
m_data.zeroOutMemory();
}
- bool canBlit(const BitImage &image, uint32_t offsetX, uint32_t offsetY) const {
+ bool canBlit(const BitImage &image, uint32_t offsetX, uint32_t offsetY) const
+ {
for (uint32_t y = 0; y < image.m_height; y++) {
const uint32_t thisY = y + offsetY;
if (thisY >= m_height)
@@ -1342,7 +1473,8 @@ public:
return true;
}
- void dilate(uint32_t padding) {
+ void dilate(uint32_t padding)
+ {
BitImage tmp(m_width, m_height);
for (uint32_t p = 0; p < padding; p++) {
tmp.zeroOutMemory();
@@ -1379,10 +1511,11 @@ private:
};
// From Fast-BVH
-class BVH {
+class BVH
+{
public:
- BVH(const Array<AABB> &objectAabbs, uint32_t leafSize = 4) :
- m_objectIds(MemTag::BVH), m_nodes(MemTag::BVH) {
+ BVH(const Array<AABB> &objectAabbs, uint32_t leafSize = 4) : m_objectIds(MemTag::BVH), m_nodes(MemTag::BVH)
+ {
m_objectAabbs = &objectAabbs;
if (m_objectAabbs->isEmpty())
return;
@@ -1402,7 +1535,7 @@ public:
Node node;
m_nodes.reserve(objectAabbs.size() * 2);
uint32_t nNodes = 0;
- while (stackptr > 0) {
+ while(stackptr > 0) {
// Pop the next item off of the stack
const BuildEntry &bnode = todo[--stackptr];
const uint32_t start = bnode.start;
@@ -1415,7 +1548,7 @@ public:
// Calculate the bounding box for this node
AABB bb(objectAabbs[m_objectIds[start]]);
AABB bc(objectAabbs[m_objectIds[start]].centroid());
- for (uint32_t p = start + 1; p < end; ++p) {
+ for(uint32_t p = start + 1; p < end; ++p) {
bb.expandToInclude(objectAabbs[m_objectIds[p]]);
bc.expandToInclude(objectAabbs[m_objectIds[p]].centroid());
}
@@ -1431,7 +1564,7 @@ public:
m_nodes[bnode.parent].rightOffset--;
// When this is the second touch, this is the right child.
// The right child sets up the offset for the flat tree.
- if (m_nodes[bnode.parent].rightOffset == kTouchedTwice)
+ if (m_nodes[bnode.parent].rightOffset == kTouchedTwice )
m_nodes[bnode.parent].rightOffset = nNodes - 1 - bnode.parent;
}
// If this is a leaf, no need to subdivide.
@@ -1466,20 +1599,21 @@ public:
}
}
- void query(const AABB &queryAabb, Array<uint32_t> &result) const {
+ void query(const AABB &queryAabb, Array<uint32_t> &result) const
+ {
result.clear();
// Working set
uint32_t todo[64];
int32_t stackptr = 0;
// "Push" on the root node to the working set
todo[stackptr] = 0;
- while (stackptr >= 0) {
+ while(stackptr >= 0) {
// Pop off the next node to work on.
const int ni = todo[stackptr--];
const Node &node = m_nodes[ni];
// Is leaf -> Intersect
if (node.rightOffset == 0) {
- for (uint32_t o = 0; o < node.nPrims; ++o) {
+ for(uint32_t o = 0; o < node.nPrims; ++o) {
const uint32_t obj = node.start + o;
if (queryAabb.intersect((*m_objectAabbs)[m_objectIds[obj]]))
result.push_back(m_objectIds[obj]);
@@ -1496,12 +1630,14 @@ public:
}
private:
- struct BuildEntry {
+ struct BuildEntry
+ {
uint32_t parent; // If non-zero then this is the index of the parent. (used in offsets)
uint32_t start, end; // The range of objects in the object list covered by this node.
};
- struct Node {
+ struct Node
+ {
AABB aabb;
uint32_t start, nPrims, rightOffset;
};
@@ -1511,8 +1647,10 @@ private:
Array<Node> m_nodes;
};
-struct Fit {
- static bool computeBasis(const Vector3 *points, uint32_t pointsCount, Basis *basis) {
+struct Fit
+{
+ static bool computeBasis(const Vector3 *points, uint32_t pointsCount, Basis *basis)
+ {
if (computeLeastSquaresNormal(points, pointsCount, &basis->normal)) {
basis->tangent = Basis::computeTangent(basis->normal);
basis->bitangent = Basis::computeBitangent(basis->normal, basis->tangent);
@@ -1526,7 +1664,8 @@ private:
// Fast, and accurate to within a few degrees.
// Returns None if the points do not span a plane.
// https://www.ilikebigbits.com/2015_03_04_plane_from_points.html
- static bool computeLeastSquaresNormal(const Vector3 *points, uint32_t pointsCount, Vector3 *normal) {
+ static bool computeLeastSquaresNormal(const Vector3 *points, uint32_t pointsCount, Vector3 *normal)
+ {
XA_DEBUG_ASSERT(pointsCount >= 3);
if (pointsCount == 3) {
*normal = normalize(cross(points[2] - points[0], points[1] - points[0]), kEpsilon);
@@ -1591,7 +1730,7 @@ private:
// Pick path with best conditioning:
Vector3 dir(0.0f);
if (det_max == det_x)
- dir = Vector3(det_x, xz * yz - xy * zz, xy * yz - xz * yy);
+ dir = Vector3(det_x,xz * yz - xy * zz,xy * yz - xz * yy);
else if (det_max == det_y)
dir = Vector3(xz * yz - xy * zz, det_y, xy * xz - yz * xx);
else if (det_max == det_z)
@@ -1604,7 +1743,8 @@ private:
return isNormalized(*normal);
}
- static bool computeEigen(const Vector3 *points, uint32_t pointsCount, Basis *basis) {
+ static bool computeEigen(const Vector3 *points, uint32_t pointsCount, Basis *basis)
+ {
float matrix[6];
computeCovariance(pointsCount, points, matrix);
if (matrix[0] == 0 && matrix[3] == 0 && matrix[5] == 0)
@@ -1619,7 +1759,8 @@ private:
return true;
}
- static Vector3 computeCentroid(int n, const Vector3 *points) {
+ static Vector3 computeCentroid(int n, const Vector3 * points)
+ {
Vector3 centroid(0.0f);
for (int i = 0; i < n; i++) {
centroid += points[i];
@@ -1628,7 +1769,8 @@ private:
return centroid;
}
- static Vector3 computeCovariance(int n, const Vector3 *points, float *covariance) {
+ static Vector3 computeCovariance(int n, const Vector3 * points, float * covariance)
+ {
// compute the centroid
Vector3 centroid = computeCentroid(n, points);
// compute covariance matrix
@@ -1650,7 +1792,8 @@ private:
// Tridiagonal solver from Charles Bloom.
// Householder transforms followed by QL decomposition.
// Seems to be based on the code from Numerical Recipes in C.
- static bool eigenSolveSymmetric3(const float matrix[6], float eigenValues[3], Vector3 eigenVectors[3]) {
+ static bool eigenSolveSymmetric3(const float matrix[6], float eigenValues[3], Vector3 eigenVectors[3])
+ {
XA_DEBUG_ASSERT(matrix != nullptr && eigenValues != nullptr && eigenVectors != nullptr);
float subd[3];
float diag[3];
@@ -1675,7 +1818,7 @@ private:
// eigenvectors are the columns; make them the rows :
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- (&eigenVectors[j].x)[i] = (float)work[i][j];
+ (&eigenVectors[j].x)[i] = (float) work[i][j];
}
}
// shuffle to sort by singular value :
@@ -1697,7 +1840,8 @@ private:
}
private:
- static void EigenSolver3_Tridiagonal(float mat[3][3], float *diag, float *subd) {
+ static void EigenSolver3_Tridiagonal(float mat[3][3], float *diag, float *subd)
+ {
// Householder reduction T = Q^t M Q
// Input:
// mat, symmetric 3x3 matrix M
@@ -1749,7 +1893,8 @@ private:
}
}
- static bool EigenSolver3_QLAlgorithm(float mat[3][3], float *diag, float *subd) {
+ static bool EigenSolver3_QLAlgorithm(float mat[3][3], float *diag, float *subd)
+ {
// QL iteration with implicit shifting to reduce matrix from tridiagonal
// to diagonal
const int maxiter = 32;
@@ -1759,21 +1904,21 @@ private:
int m;
for (m = ell; m <= 1; m++) {
float dd = fabsf(diag[m]) + fabsf(diag[m + 1]);
- if (fabsf(subd[m]) + dd == dd)
+ if ( fabsf(subd[m]) + dd == dd )
break;
}
- if (m == ell)
+ if ( m == ell )
break;
float g = (diag[ell + 1] - diag[ell]) / (2 * subd[ell]);
float r = sqrtf(g * g + 1);
- if (g < 0)
+ if ( g < 0 )
g = diag[m] - diag[ell] + subd[ell] / (g - r);
else
g = diag[m] - diag[ell] + subd[ell] / (g + r);
float s = 1, c = 1, p = 0;
for (int i = m - 1; i >= ell; i--) {
float f = s * subd[i], b = c * subd[i];
- if (fabsf(f) >= fabsf(g)) {
+ if ( fabsf(f) >= fabsf(g) ) {
c = g / f;
r = sqrtf(c * c + 1);
subd[i + 1] = f * r;
@@ -1799,7 +1944,7 @@ private:
subd[ell] = g;
subd[m] = 0;
}
- if (iter == maxiter)
+ if ( iter == maxiter )
// should not get here under normal circumstances
return false;
}
@@ -1807,50 +1952,77 @@ private:
}
};
-/// Fixed size vector class.
-class FullVector {
-public:
- FullVector(uint32_t dim) :
- m_array(MemTag::FullVector) { m_array.resize(dim); }
- FullVector(const FullVector &v) :
- m_array(MemTag::FullVector) { v.m_array.copyTo(m_array); }
- FullVector &operator=(const FullVector &v) = delete;
- XA_INLINE uint32_t dimension() const { return m_array.size(); }
- XA_INLINE const float &operator[](uint32_t index) const { return m_array[index]; }
- XA_INLINE float &operator[](uint32_t index) { return m_array[index]; }
-
- void fill(float f) {
- const uint32_t dim = dimension();
- for (uint32_t i = 0; i < dim; i++)
- m_array[i] = f;
+static uint32_t sdbmHash(const void *data_in, uint32_t size, uint32_t h = 5381)
+{
+ const uint8_t *data = (const uint8_t *) data_in;
+ uint32_t i = 0;
+ while (i < size) {
+ h = (h << 16) + (h << 6) - h + (uint32_t ) data[i++];
}
+ return h;
+}
-private:
- Array<float> m_array;
+template <typename T>
+static uint32_t hash(const T &t, uint32_t h = 5381)
+{
+ return sdbmHash(&t, sizeof(T), h);
+}
+
+template <typename Key>
+struct Hash
+{
+ uint32_t operator()(const Key &k) const { return hash(k); }
};
-template <typename Key, typename H = Hash<Key>, typename E = Equal<Key>>
-class HashMap {
+template <typename Key>
+struct PassthroughHash
+{
+ uint32_t operator()(const Key &k) const { return (uint32_t)k; }
+};
+
+template <typename Key>
+struct Equal
+{
+ bool operator()(const Key &k0, const Key &k1) const { return k0 == k1; }
+};
+
+template<typename Key, typename H = Hash<Key>, typename E = Equal<Key> >
+class HashMap
+{
public:
- HashMap(int memTag, uint32_t size) :
- m_memTag(memTag), m_size(size), m_numSlots(0), m_slots(nullptr), m_keys(memTag), m_next(memTag) {
+ HashMap(int memTag, uint32_t size) : m_memTag(memTag), m_size(size), m_numSlots(0), m_slots(nullptr), m_keys(memTag), m_next(memTag)
+ {
}
- ~HashMap() {
+ ~HashMap()
+ {
if (m_slots)
XA_FREE(m_slots);
}
- void add(const Key &key) {
+ void destroy()
+ {
+ if (m_slots) {
+ XA_FREE(m_slots);
+ m_slots = nullptr;
+ }
+ m_keys.destroy();
+ m_next.destroy();
+ }
+
+ uint32_t add(const Key &key)
+ {
if (!m_slots)
alloc();
const uint32_t hash = computeHash(key);
m_keys.push_back(key);
m_next.push_back(m_slots[hash]);
m_slots[hash] = m_next.size() - 1;
+ return m_keys.size() - 1;
}
- uint32_t get(const Key &key) const {
+ uint32_t get(const Key &key) const
+ {
if (!m_slots)
return UINT32_MAX;
const uint32_t hash = computeHash(key);
@@ -1864,7 +2036,8 @@ public:
return UINT32_MAX;
}
- uint32_t getNext(uint32_t current) const {
+ uint32_t getNext(uint32_t current) const
+ {
uint32_t i = m_next[current];
E equal;
while (i != UINT32_MAX) {
@@ -1876,7 +2049,8 @@ public:
}
private:
- void alloc() {
+ void alloc()
+ {
XA_DEBUG_ASSERT(m_size > 0);
m_numSlots = nextPowerOfTwo(m_size);
auto minNumSlots = uint32_t(m_size * 1.3);
@@ -1889,7 +2063,8 @@ private:
m_next.reserve(m_size);
}
- uint32_t computeHash(const Key &key) const {
+ uint32_t computeHash(const Key &key) const
+ {
H hash;
return hash(key) & (m_numSlots - 1);
}
@@ -1902,8 +2077,9 @@ private:
Array<uint32_t> m_next;
};
-template <typename T>
-static void insertionSort(T *data, uint32_t length) {
+template<typename T>
+static void insertionSort(T *data, uint32_t length)
+{
for (int32_t i = 1; i < (int32_t)length; i++) {
T x = data[i];
int32_t j = i - 1;
@@ -1915,18 +2091,21 @@ static void insertionSort(T *data, uint32_t length) {
}
}
-class KISSRng {
+class KISSRng
+{
public:
KISSRng() { reset(); }
- void reset() {
+ void reset()
+ {
x = 123456789;
y = 362436000;
z = 521288629;
c = 7654321;
}
- uint32_t getRange(uint32_t range) {
+ uint32_t getRange(uint32_t range)
+ {
if (range == 0)
return 0;
x = 69069 * x + 12345;
@@ -1935,7 +2114,7 @@ public:
y ^= (y << 5);
uint64_t t = 698769069ULL * z + c;
c = (t >> 32);
- return (x + y + (z = (uint32_t)t)) % range;
+ return (x + y + (z = (uint32_t)t)) % (range + 1);
}
private:
@@ -1945,76 +2124,70 @@ private:
// Based on Pierre Terdiman's and Michael Herf's source code.
// http://www.codercorner.com/RadixSortRevisited.htm
// http://www.stereopsis.com/radix.html
-class RadixSort {
+class RadixSort
+{
public:
- RadixSort() :
- m_size(0), m_ranks(nullptr), m_ranks2(nullptr), m_validRanks(false) {}
-
- ~RadixSort() {
- // Release everything
- XA_FREE(m_ranks2);
- XA_FREE(m_ranks);
- }
-
- RadixSort &sort(const float *input, uint32_t count) {
- if (input == nullptr || count == 0) return *this;
- // Resize lists if needed
- if (count != m_size) {
- if (count > m_size) {
- m_ranks2 = XA_REALLOC(MemTag::Default, m_ranks2, uint32_t, count);
- m_ranks = XA_REALLOC(MemTag::Default, m_ranks, uint32_t, count);
- }
- m_size = count;
- m_validRanks = false;
+ void sort(const float *input, uint32_t count)
+ {
+ if (input == nullptr || count == 0) {
+ m_buffer1.clear();
+ m_buffer2.clear();
+ m_ranks = m_buffer1.data();
+ m_ranks2 = m_buffer2.data();
+ return;
}
- if (count < 32) {
+ // Resize lists if needed
+ m_buffer1.resize(count);
+ m_buffer2.resize(count);
+ m_ranks = m_buffer1.data();
+ m_ranks2 = m_buffer2.data();
+ m_validRanks = false;
+ if (count < 32)
insertionSort(input, count);
- } else {
+ else {
// @@ Avoid touching the input multiple times.
for (uint32_t i = 0; i < count; i++) {
- FloatFlip((uint32_t &)input[i]);
+ floatFlip((uint32_t &)input[i]);
}
radixSort<uint32_t>((const uint32_t *)input, count);
for (uint32_t i = 0; i < count; i++) {
- IFloatFlip((uint32_t &)input[i]);
+ ifloatFlip((uint32_t &)input[i]);
}
}
- return *this;
}
- RadixSort &sort(const Array<float> &input) {
- return sort(input.data(), input.size());
+ void sort(const Array<float> &input)
+ {
+ sort(input.data(), input.size());
}
// Access to results. m_ranks is a list of indices in sorted order, i.e. in the order you may further process your data
- const uint32_t *ranks() const {
- XA_DEBUG_ASSERT(m_validRanks);
- return m_ranks;
- }
-
- uint32_t *ranks() {
+ const uint32_t *ranks() const
+ {
XA_DEBUG_ASSERT(m_validRanks);
return m_ranks;
}
private:
- uint32_t m_size;
- uint32_t *m_ranks;
- uint32_t *m_ranks2;
+ uint32_t *m_ranks, *m_ranks2;
+ Array<uint32_t> m_buffer1, m_buffer2;
bool m_validRanks;
- void FloatFlip(uint32_t &f) {
+ void floatFlip(uint32_t &f)
+ {
int32_t mask = (int32_t(f) >> 31) | 0x80000000; // Warren Hunt, Manchor Ko.
f ^= mask;
}
- void IFloatFlip(uint32_t &f) {
+ void ifloatFlip(uint32_t &f)
+ {
uint32_t mask = ((f >> 31) - 1) | 0x80000000; // Michael Herf.
f ^= mask;
}
- template <typename T>
- void createHistograms(const T *buffer, uint32_t count, uint32_t *histogram) {
+ template<typename T>
+ void createHistograms(const T *buffer, uint32_t count, uint32_t *histogram)
+ {
const uint32_t bucketCount = sizeof(T); // (8 * sizeof(T)) / log2(radix)
// Init bucket pointers.
uint32_t *h[bucketCount];
@@ -2022,10 +2195,10 @@ private:
h[i] = histogram + 256 * i;
}
// Clear histograms.
- memset(histogram, 0, 256 * bucketCount * sizeof(uint32_t));
+ memset(histogram, 0, 256 * bucketCount * sizeof(uint32_t ));
// @@ Add support for signed integers.
// Build histograms.
- const uint8_t *p = (const uint8_t *)buffer; // @@ Does this break aliasing rules?
+ const uint8_t *p = (const uint8_t *)buffer; // @@ Does this break aliasing rules?
const uint8_t *pe = p + count * sizeof(T);
while (p != pe) {
h[0][*p++]++, h[1][*p++]++, h[2][*p++]++, h[3][*p++]++;
@@ -2041,7 +2214,8 @@ private:
}
template <typename T>
- void insertionSort(const T *input, uint32_t count) {
+ void insertionSort(const T *input, uint32_t count)
+ {
if (!m_validRanks) {
m_ranks[0] = 0;
for (uint32_t i = 1; i != count; ++i) {
@@ -2072,7 +2246,8 @@ private:
}
template <typename T>
- void radixSort(const T *input, uint32_t count) {
+ void radixSort(const T *input, uint32_t count)
+ {
const uint32_t P = sizeof(T); // pass count
// Allocate histograms & offsets on the stack
uint32_t histogram[256 * P];
@@ -2090,8 +2265,7 @@ private:
}
// Create offsets
link[0] = m_ranks2;
- for (uint32_t i = 1; i < 256; i++)
- link[i] = link[i - 1] + h[i - 1];
+ for (uint32_t i = 1; i < 256; i++) link[i] = link[i - 1] + h[i - 1];
// Perform Radix Sort
if (!m_validRanks) {
for (uint32_t i = 0; i < count; i++) {
@@ -2109,30 +2283,33 @@ private:
}
// All values were equal, generate linear ranks.
if (!m_validRanks) {
- for (uint32_t i = 0; i < count; i++) {
+ for (uint32_t i = 0; i < count; i++)
m_ranks[i] = i;
- }
m_validRanks = true;
}
}
};
// Wrapping this in a class allows temporary arrays to be re-used.
-class BoundingBox2D {
+class BoundingBox2D
+{
public:
Vector2 majorAxis, minorAxis, minCorner, maxCorner;
- void clear() {
+ void clear()
+ {
m_boundaryVertices.clear();
}
- void appendBoundaryVertex(Vector2 v) {
+ void appendBoundaryVertex(Vector2 v)
+ {
m_boundaryVertices.push_back(v);
}
// This should compute convex hull and use rotating calipers to find the best box. Currently it uses a brute force method.
// If vertices is null or vertexCount is 0, the boundary vertices are used.
- void compute(const Vector2 *vertices = nullptr, uint32_t vertexCount = 0) {
+ void compute(const Vector2 *vertices = nullptr, uint32_t vertexCount = 0)
+ {
if (!vertices || vertexCount == 0) {
vertices = m_boundaryVertices.data();
vertexCount = m_boundaryVertices.size();
@@ -2180,13 +2357,13 @@ public:
private:
// Compute the convex hull using Graham Scan.
- void convexHull(const Vector2 *input, uint32_t inputCount, Array<Vector2> &output, float epsilon) {
+ void convexHull(const Vector2 *input, uint32_t inputCount, Array<Vector2> &output, float epsilon)
+ {
m_coords.resize(inputCount);
for (uint32_t i = 0; i < inputCount; i++)
m_coords[i] = input[i].x;
- RadixSort radix;
- radix.sort(m_coords);
- const uint32_t *ranks = radix.ranks();
+ m_radix.sort(m_coords);
+ const uint32_t *ranks = m_radix.ranks();
m_top.clear();
m_bottom.clear();
m_top.reserve(inputCount);
@@ -2210,7 +2387,7 @@ private:
XA_DEBUG_ASSERT(m_top.size() >= 2);
output.push_back(m_top[0]);
output.push_back(m_top[1]);
- for (uint32_t i = 2; i < m_top.size();) {
+ for (uint32_t i = 2; i < m_top.size(); ) {
Vector2 a = output[output.size() - 2];
Vector2 b = output[output.size() - 1];
Vector2 c = m_top[i];
@@ -2226,7 +2403,7 @@ private:
XA_DEBUG_ASSERT(m_bottom.size() >= 2);
output.push_back(m_bottom[1]);
// Filter bottom list.
- for (uint32_t i = 2; i < m_bottom.size();) {
+ for (uint32_t i = 2; i < m_bottom.size(); ) {
Vector2 a = output[output.size() - 2];
Vector2 b = output[output.size() - 1];
Vector2 c = m_bottom[i];
@@ -2246,51 +2423,49 @@ private:
Array<Vector2> m_boundaryVertices;
Array<float> m_coords;
Array<Vector2> m_top, m_bottom, m_hull;
+ RadixSort m_radix;
};
-static uint32_t meshEdgeFace(uint32_t edge) {
- return edge / 3;
-}
-static uint32_t meshEdgeIndex0(uint32_t edge) {
- return edge;
-}
+static uint32_t meshEdgeFace(uint32_t edge) { return edge / 3; }
+static uint32_t meshEdgeIndex0(uint32_t edge) { return edge; }
-static uint32_t meshEdgeIndex1(uint32_t edge) {
+static uint32_t meshEdgeIndex1(uint32_t edge)
+{
const uint32_t faceFirstEdge = edge / 3 * 3;
return faceFirstEdge + (edge - faceFirstEdge + 1) % 3;
}
-struct MeshFlags {
- enum {
- HasFaceGroups = 1 << 0,
- HasIgnoredFaces = 1 << 1,
- HasNormals = 1 << 2
+struct MeshFlags
+{
+ enum
+ {
+ HasIgnoredFaces = 1<<0,
+ HasNormals = 1<<1
};
};
class Mesh;
static void meshGetBoundaryLoops(const Mesh &mesh, Array<uint32_t> &boundaryLoops);
-class Mesh {
+class Mesh
+{
public:
- Mesh(float epsilon, uint32_t approxVertexCount, uint32_t approxFaceCount, uint32_t flags = 0, uint32_t id = UINT32_MAX) :
- m_epsilon(epsilon), m_flags(flags), m_id(id), m_faceIgnore(MemTag::Mesh), m_ignoredFaceCount(0), m_indices(MemTag::MeshIndices), m_positions(MemTag::MeshPositions), m_normals(MemTag::MeshNormals), m_texcoords(MemTag::MeshTexcoords), m_faceGroups(MemTag::Mesh), m_faceGroupFirstFace(MemTag::Mesh), m_faceGroupNextFace(MemTag::Mesh), m_faceGroupFaceCounts(MemTag::Mesh), m_colocalVertexCount(0), m_nextColocalVertex(MemTag::MeshColocals), m_boundaryEdges(MemTag::MeshBoundaries), m_oppositeEdges(MemTag::MeshBoundaries), m_nextBoundaryEdges(MemTag::MeshBoundaries), m_edgeMap(MemTag::MeshEdgeMap, approxFaceCount * 3) {
+ Mesh(float epsilon, uint32_t approxVertexCount, uint32_t approxFaceCount, uint32_t flags = 0, uint32_t id = UINT32_MAX) : m_epsilon(epsilon), m_flags(flags), m_id(id), m_faceIgnore(MemTag::Mesh), m_indices(MemTag::MeshIndices), m_positions(MemTag::MeshPositions), m_normals(MemTag::MeshNormals), m_texcoords(MemTag::MeshTexcoords), m_nextColocalVertex(MemTag::MeshColocals), m_boundaryEdges(MemTag::MeshBoundaries), m_oppositeEdges(MemTag::MeshBoundaries), m_nextBoundaryEdges(MemTag::MeshBoundaries), m_edgeMap(MemTag::MeshEdgeMap, approxFaceCount * 3)
+ {
m_indices.reserve(approxFaceCount * 3);
m_positions.reserve(approxVertexCount);
m_texcoords.reserve(approxVertexCount);
- if (m_flags & MeshFlags::HasFaceGroups)
- m_faceGroups.reserve(approxFaceCount);
if (m_flags & MeshFlags::HasIgnoredFaces)
m_faceIgnore.reserve(approxFaceCount);
if (m_flags & MeshFlags::HasNormals)
m_normals.reserve(approxVertexCount);
}
- static constexpr uint16_t kInvalidFaceGroup = UINT16_MAX;
uint32_t flags() const { return m_flags; }
uint32_t id() const { return m_id; }
- void addVertex(const Vector3 &pos, const Vector3 &normal = Vector3(0.0f), const Vector2 &texcoord = Vector2(0.0f)) {
+ void addVertex(const Vector3 &pos, const Vector3 &normal = Vector3(0.0f), const Vector2 &texcoord = Vector2(0.0f))
+ {
XA_DEBUG_ASSERT(isFinite(pos));
m_positions.push_back(pos);
if (m_flags & MeshFlags::HasNormals)
@@ -2298,47 +2473,45 @@ public:
m_texcoords.push_back(texcoord);
}
- struct AddFaceResult {
- enum Enum {
+ struct AddFaceResult
+ {
+ enum Enum
+ {
OK,
DuplicateEdge = 1
};
};
- AddFaceResult::Enum addFace(uint32_t v0, uint32_t v1, uint32_t v2, bool ignore = false, bool hashEdge = true) {
+ AddFaceResult::Enum addFace(uint32_t v0, uint32_t v1, uint32_t v2, bool ignore = false)
+ {
uint32_t indexArray[3];
indexArray[0] = v0;
indexArray[1] = v1;
indexArray[2] = v2;
- return addFace(indexArray, ignore, hashEdge);
+ return addFace(indexArray, ignore);
}
- AddFaceResult::Enum addFace(const uint32_t *indices, bool ignore = false, bool hashEdge = true) {
+ AddFaceResult::Enum addFace(const uint32_t *indices, bool ignore = false)
+ {
AddFaceResult::Enum result = AddFaceResult::OK;
- if (m_flags & MeshFlags::HasFaceGroups)
- m_faceGroups.push_back(kInvalidFaceGroup);
- if (m_flags & MeshFlags::HasIgnoredFaces) {
+ if (m_flags & MeshFlags::HasIgnoredFaces)
m_faceIgnore.push_back(ignore);
- if (ignore)
- m_ignoredFaceCount++;
- }
const uint32_t firstIndex = m_indices.size();
for (uint32_t i = 0; i < 3; i++)
m_indices.push_back(indices[i]);
- if (hashEdge) {
- for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex0 = m_indices[firstIndex + i];
- const uint32_t vertex1 = m_indices[firstIndex + (i + 1) % 3];
- const EdgeKey key(vertex0, vertex1);
- if (m_edgeMap.get(key) != UINT32_MAX)
- result = AddFaceResult::DuplicateEdge;
- m_edgeMap.add(key);
- }
+ for (uint32_t i = 0; i < 3; i++) {
+ const uint32_t vertex0 = m_indices[firstIndex + i];
+ const uint32_t vertex1 = m_indices[firstIndex + (i + 1) % 3];
+ const EdgeKey key(vertex0, vertex1);
+ if (m_edgeMap.get(key) != UINT32_MAX)
+ result = AddFaceResult::DuplicateEdge;
+ m_edgeMap.add(key);
}
return result;
}
- void createColocals() {
+ void createColocals()
+ {
const uint32_t vertexCount = m_positions.size();
Array<AABB> aabbs(MemTag::BVH);
aabbs.resize(vertexCount);
@@ -2347,10 +2520,8 @@ public:
BVH bvh(aabbs);
Array<uint32_t> colocals(MemTag::MeshColocals);
Array<uint32_t> potential(MemTag::MeshColocals);
- m_colocalVertexCount = 0;
m_nextColocalVertex.resize(vertexCount);
- for (uint32_t i = 0; i < vertexCount; i++)
- m_nextColocalVertex[i] = UINT32_MAX;
+ m_nextColocalVertex.fillBytes(0xff);
for (uint32_t i = 0; i < vertexCount; i++) {
if (m_nextColocalVertex[i] != UINT32_MAX)
continue; // Already linked.
@@ -2366,9 +2537,8 @@ public:
if (colocals.size() == 1) {
// No colocals for this vertex.
m_nextColocalVertex[i] = i;
- continue;
+ continue;
}
- m_colocalVertexCount += colocals.size();
// Link in ascending order.
insertionSort(colocals.data(), colocals.size());
for (uint32_t j = 0; j < colocals.size(); j++)
@@ -2377,98 +2547,8 @@ public:
}
}
- // Check if the face duplicates any edges of any face already in the group.
- bool faceDuplicatesGroupEdge(uint16_t group, uint32_t face) const {
- for (FaceEdgeIterator edgeIt(this, face); !edgeIt.isDone(); edgeIt.advance()) {
- for (ColocalEdgeIterator colocalEdgeIt(this, edgeIt.vertex0(), edgeIt.vertex1()); !colocalEdgeIt.isDone(); colocalEdgeIt.advance()) {
- if (m_faceGroups[meshEdgeFace(colocalEdgeIt.edge())] == group)
- return true;
- }
- }
- return false;
- }
-
- void createFaceGroups() {
- uint32_t firstUnassignedFace = 0;
- uint16_t group = 0;
- Array<uint32_t> growFaces;
- const uint32_t n = faceCount();
- m_faceGroupNextFace.resize(n);
- for (;;) {
- // Find an unassigned face.
- uint32_t face = UINT32_MAX;
- for (uint32_t f = firstUnassignedFace; f < n; f++) {
- if (m_faceGroups[f] == kInvalidFaceGroup && !isFaceIgnored(f)) {
- face = f;
- firstUnassignedFace = f + 1;
- break;
- }
- }
- if (face == UINT32_MAX)
- break; // All faces assigned to a group (except ignored faces).
- m_faceGroups[face] = group;
- m_faceGroupNextFace[face] = UINT32_MAX;
- m_faceGroupFirstFace.push_back(face);
- growFaces.clear();
- growFaces.push_back(face);
- uint32_t prevFace = face, groupFaceCount = 1;
- // Find faces connected to the face and assign them to the same group as the face, unless they are already assigned to another group.
- for (;;) {
- if (growFaces.isEmpty())
- break;
- const uint32_t f = growFaces.back();
- growFaces.pop_back();
- for (FaceEdgeIterator edgeIt(this, f); !edgeIt.isDone(); edgeIt.advance()) {
- // Iterate opposite edges. There may be more than one - non-manifold geometry can have duplicate edges.
- // Prioritize the one with exact vertex match, not just colocal.
- // If *any* of the opposite edges are already assigned to this group, don't do anything.
- bool alreadyAssignedToThisGroup = false;
- uint32_t bestConnectedFace = UINT32_MAX;
- for (ColocalEdgeIterator oppositeEdgeIt(this, edgeIt.vertex1(), edgeIt.vertex0()); !oppositeEdgeIt.isDone(); oppositeEdgeIt.advance()) {
- const uint32_t oppositeEdge = oppositeEdgeIt.edge();
- const uint32_t oppositeFace = meshEdgeFace(oppositeEdge);
- if (isFaceIgnored(oppositeFace))
- continue; // Don't add ignored faces to group.
- if (m_faceGroups[oppositeFace] == group) {
- alreadyAssignedToThisGroup = true;
- break;
- }
- if (m_faceGroups[oppositeFace] != kInvalidFaceGroup)
- continue; // Connected face is already assigned to another group.
- if (faceDuplicatesGroupEdge(group, oppositeFace))
- continue; // Don't want duplicate edges in a group.
- const uint32_t oppositeVertex0 = m_indices[meshEdgeIndex0(oppositeEdge)];
- const uint32_t oppositeVertex1 = m_indices[meshEdgeIndex1(oppositeEdge)];
- if (bestConnectedFace == UINT32_MAX || (oppositeVertex0 == edgeIt.vertex1() && oppositeVertex1 == edgeIt.vertex0()))
- bestConnectedFace = oppositeFace;
-#if 0
- else {
- // Choose the opposite face with the smallest dihedral angle.
- const float d1 = 1.0f - dot(computeFaceNormal(f), computeFaceNormal(bestConnectedFace));
- const float d2 = 1.0f - dot(computeFaceNormal(f), computeFaceNormal(oppositeFace));
- if (d2 < d1)
- bestConnectedFace = oppositeFace;
- }
-#endif
- }
- if (!alreadyAssignedToThisGroup && bestConnectedFace != UINT32_MAX) {
- m_faceGroups[bestConnectedFace] = group;
- m_faceGroupNextFace[bestConnectedFace] = UINT32_MAX;
- if (prevFace != UINT32_MAX)
- m_faceGroupNextFace[prevFace] = bestConnectedFace;
- prevFace = bestConnectedFace;
- groupFaceCount++;
- growFaces.push_back(bestConnectedFace);
- }
- }
- }
- m_faceGroupFaceCounts.push_back(groupFaceCount);
- group++;
- XA_ASSERT(group < kInvalidFaceGroup);
- }
- }
-
- void createBoundaries() {
+ void createBoundaries()
+ {
const uint32_t edgeCount = m_indices.size();
const uint32_t vertexCount = m_positions.size();
m_oppositeEdges.resize(edgeCount);
@@ -2498,7 +2578,8 @@ public:
}
}
- void linkBoundaries() {
+ void linkBoundaries()
+ {
const uint32_t edgeCount = m_indices.size();
HashMap<uint32_t> vertexToEdgeMap(MemTag::Mesh, edgeCount); // Edge is index / 2
for (uint32_t i = 0; i < edgeCount; i++) {
@@ -2591,7 +2672,8 @@ public:
}
/// Find edge, test all colocals.
- uint32_t findEdge(uint32_t vertex0, uint32_t vertex1) const {
+ uint32_t findEdge(uint32_t vertex0, uint32_t vertex1) const
+ {
uint32_t result = UINT32_MAX;
if (m_nextColocalVertex.isEmpty()) {
EdgeKey key(vertex0, vertex1);
@@ -2629,8 +2711,18 @@ public:
return result;
}
+ // Edge map can be destroyed when no longer used to reduce memory usage. It's used by:
+ // * Mesh::createBoundaries()
+ // * Mesh::ColocalEdgeIterator (used by MeshFaceGroups)
+ // * meshCloseHole()
+ void destroyEdgeMap()
+ {
+ m_edgeMap.destroy();
+ }
+
#if XA_DEBUG_EXPORT_OBJ
- void writeObjVertices(FILE *file) const {
+ void writeObjVertices(FILE *file) const
+ {
for (uint32_t i = 0; i < m_positions.size(); i++)
fprintf(file, "v %g %g %g\n", m_positions[i].x, m_positions[i].y, m_positions[i].z);
if (m_flags & MeshFlags::HasNormals) {
@@ -2641,15 +2733,17 @@ public:
fprintf(file, "vt %g %g\n", m_texcoords[i].x, m_texcoords[i].y);
}
- void writeObjFace(FILE *file, uint32_t face) const {
+ void writeObjFace(FILE *file, uint32_t face, uint32_t offset = 0) const
+ {
fprintf(file, "f ");
for (uint32_t j = 0; j < 3; j++) {
- const uint32_t index = m_indices[face * 3 + j] + 1; // 1-indexed
+ const uint32_t index = m_indices[face * 3 + j] + 1 + offset; // 1-indexed
fprintf(file, "%d/%d/%d%c", index, index, index, j == 2 ? '\n' : ' ');
}
}
- void writeObjBoundaryEges(FILE *file) const {
+ void writeObjBoundaryEges(FILE *file) const
+ {
if (m_oppositeEdges.isEmpty())
return; // Boundaries haven't been created.
fprintf(file, "o boundary_edges\n");
@@ -2660,7 +2754,8 @@ public:
}
}
- void writeObjLinkedBoundaries(FILE *file) const {
+ void writeObjLinkedBoundaries(FILE *file) const
+ {
if (m_oppositeEdges.isEmpty() || m_nextBoundaryEdges.isEmpty())
return; // Boundaries haven't been created and/or linked.
Array<uint32_t> boundaryLoops;
@@ -2682,7 +2777,8 @@ public:
}
}
- void writeObjFile(const char *filename) const {
+ void writeObjFile(const char *filename) const
+ {
FILE *file;
XA_FOPEN(file, filename, "w");
if (!file)
@@ -2698,7 +2794,8 @@ public:
}
#endif
- float computeSurfaceArea() const {
+ float computeSurfaceArea() const
+ {
float area = 0;
for (uint32_t f = 0; f < faceCount(); f++)
area += computeFaceArea(f);
@@ -2706,21 +2803,25 @@ public:
return area;
}
- float computeParametricArea() const {
+ // Returned value is always positive, even if some triangles are flipped.
+ float computeParametricArea() const
+ {
float area = 0;
for (uint32_t f = 0; f < faceCount(); f++)
- area += computeFaceParametricArea(f);
- return fabsf(area); // May be negative, depends on texcoord winding.
+ area += fabsf(computeFaceParametricArea(f)); // May be negative, depends on texcoord winding.
+ return area;
}
- float computeFaceArea(uint32_t face) const {
+ float computeFaceArea(uint32_t face) const
+ {
const Vector3 &p0 = m_positions[m_indices[face * 3 + 0]];
const Vector3 &p1 = m_positions[m_indices[face * 3 + 1]];
const Vector3 &p2 = m_positions[m_indices[face * 3 + 2]];
return length(cross(p1 - p0, p2 - p0)) * 0.5f;
}
- Vector3 computeFaceCentroid(uint32_t face) const {
+ Vector3 computeFaceCentroid(uint32_t face) const
+ {
Vector3 sum(0.0f);
for (uint32_t i = 0; i < 3; i++)
sum += m_positions[m_indices[face * 3 + i]];
@@ -2729,7 +2830,8 @@ public:
// Average of the edge midpoints weighted by the edge length.
// I want a point inside the triangle, but closer to the cirumcenter.
- Vector3 computeFaceCenter(uint32_t face) const {
+ Vector3 computeFaceCenter(uint32_t face) const
+ {
const Vector3 &p0 = m_positions[m_indices[face * 3 + 0]];
const Vector3 &p1 = m_positions[m_indices[face * 3 + 1]];
const Vector3 &p2 = m_positions[m_indices[face * 3 + 2]];
@@ -2742,7 +2844,8 @@ public:
return m0 + m1 + m2;
}
- Vector3 computeFaceNormal(uint32_t face) const {
+ Vector3 computeFaceNormal(uint32_t face) const
+ {
const Vector3 &p0 = m_positions[m_indices[face * 3 + 0]];
const Vector3 &p1 = m_positions[m_indices[face * 3 + 1]];
const Vector3 &p2 = m_positions[m_indices[face * 3 + 2]];
@@ -2752,15 +2855,17 @@ public:
return normalizeSafe(normalAreaScaled, Vector3(0, 0, 1), 0.0f);
}
- float computeFaceParametricArea(uint32_t face) const {
+ float computeFaceParametricArea(uint32_t face) const
+ {
const Vector2 &t0 = m_texcoords[m_indices[face * 3 + 0]];
const Vector2 &t1 = m_texcoords[m_indices[face * 3 + 1]];
const Vector2 &t2 = m_texcoords[m_indices[face * 3 + 2]];
return triangleArea(t0, t1, t2);
}
-
+
// @@ This is not exactly accurate, we should compare the texture coordinates...
- bool isSeam(uint32_t edge) const {
+ bool isSeam(uint32_t edge) const
+ {
const uint32_t oppositeEdge = m_oppositeEdges[edge];
if (oppositeEdge == UINT32_MAX)
return false; // boundary edge
@@ -2771,7 +2876,8 @@ public:
return m_indices[e0] != m_indices[oe1] || m_indices[e1] != m_indices[oe0];
}
- bool isTextureSeam(uint32_t edge) const {
+ bool isTextureSeam(uint32_t edge) const
+ {
const uint32_t oppositeEdge = m_oppositeEdges[edge];
if (oppositeEdge == UINT32_MAX)
return false; // boundary edge
@@ -2782,7 +2888,8 @@ public:
return m_texcoords[m_indices[e0]] != m_texcoords[m_indices[oe1]] || m_texcoords[m_indices[e1]] != m_texcoords[m_indices[oe0]];
}
- uint32_t firstColocal(uint32_t vertex) const {
+ uint32_t firstColocal(uint32_t vertex) const
+ {
for (ColocalVertexIterator it(this, vertex); !it.isDone(); it.advance()) {
if (it.vertex() < vertex)
vertex = it.vertex();
@@ -2790,7 +2897,8 @@ public:
return vertex;
}
- bool areColocal(uint32_t vertex0, uint32_t vertex1) const {
+ bool areColocal(uint32_t vertex0, uint32_t vertex1) const
+ {
if (vertex0 == vertex1)
return true;
if (m_nextColocalVertex.isEmpty())
@@ -2808,60 +2916,32 @@ public:
XA_INLINE bool isBoundaryEdge(uint32_t edge) const { return m_oppositeEdges[edge] == UINT32_MAX; }
XA_INLINE const Array<uint32_t> &boundaryEdges() const { return m_boundaryEdges; }
XA_INLINE bool isBoundaryVertex(uint32_t vertex) const { return m_isBoundaryVertex.get(vertex); }
- XA_INLINE uint32_t colocalVertexCount() const { return m_colocalVertexCount; }
XA_INLINE uint32_t vertexCount() const { return m_positions.size(); }
XA_INLINE uint32_t vertexAt(uint32_t i) const { return m_indices[i]; }
XA_INLINE const Vector3 &position(uint32_t vertex) const { return m_positions[vertex]; }
- XA_INLINE const Vector3 &normal(uint32_t vertex) const {
- XA_DEBUG_ASSERT(m_flags & MeshFlags::HasNormals);
- return m_normals[vertex];
- }
+ XA_INLINE const Vector3 *positions() const { return m_positions.data(); }
+ XA_INLINE const Vector3 &normal(uint32_t vertex) const { XA_DEBUG_ASSERT(m_flags & MeshFlags::HasNormals); return m_normals[vertex]; }
XA_INLINE const Vector2 &texcoord(uint32_t vertex) const { return m_texcoords[vertex]; }
XA_INLINE Vector2 &texcoord(uint32_t vertex) { return m_texcoords[vertex]; }
XA_INLINE const Vector2 *texcoords() const { return m_texcoords.data(); }
XA_INLINE Vector2 *texcoords() { return m_texcoords.data(); }
- XA_INLINE uint32_t ignoredFaceCount() const { return m_ignoredFaceCount; }
XA_INLINE uint32_t faceCount() const { return m_indices.size() / 3; }
- XA_INLINE uint16_t faceGroupAt(uint32_t face) const {
- XA_DEBUG_ASSERT(m_flags & MeshFlags::HasFaceGroups);
- return m_faceGroups[face];
- }
- XA_INLINE uint32_t faceGroupCount() const {
- XA_DEBUG_ASSERT(m_flags & MeshFlags::HasFaceGroups);
- return m_faceGroupFaceCounts.size();
- }
- XA_INLINE uint32_t faceGroupNextFace(uint32_t face) const {
- XA_DEBUG_ASSERT(m_flags & MeshFlags::HasFaceGroups);
- return m_faceGroupNextFace[face];
- }
- XA_INLINE uint32_t faceGroupFaceCount(uint32_t group) const {
- XA_DEBUG_ASSERT(m_flags & MeshFlags::HasFaceGroups);
- return m_faceGroupFaceCounts[group];
- }
XA_INLINE const uint32_t *indices() const { return m_indices.data(); }
XA_INLINE uint32_t indexCount() const { return m_indices.size(); }
+ XA_INLINE bool isFaceIgnored(uint32_t face) const { return (m_flags & MeshFlags::HasIgnoredFaces) && m_faceIgnore[face]; }
private:
- bool isFaceIgnored(uint32_t face) const { return (m_flags & MeshFlags::HasIgnoredFaces) && m_faceIgnore[face]; }
float m_epsilon;
uint32_t m_flags;
uint32_t m_id;
Array<bool> m_faceIgnore;
- uint32_t m_ignoredFaceCount;
Array<uint32_t> m_indices;
Array<Vector3> m_positions;
Array<Vector3> m_normals;
Array<Vector2> m_texcoords;
- // Populated by createFaceGroups
- Array<uint16_t> m_faceGroups;
- Array<uint32_t> m_faceGroupFirstFace;
- Array<uint32_t> m_faceGroupNextFace; // In: face. Out: the next face in the same group.
- Array<uint32_t> m_faceGroupFaceCounts; // In: face group. Out: number of faces in the group.
-
// Populated by createColocals
- uint32_t m_colocalVertexCount;
Array<uint32_t> m_nextColocalVertex; // In: vertex index. Out: the vertex index of the next colocal position.
// Populated by createBoundaries
@@ -2872,45 +2952,48 @@ private:
// Populated by linkBoundaries
Array<uint32_t> m_nextBoundaryEdges; // The index of the next boundary edge. UINT32_MAX if the edge is not a boundary edge.
- struct EdgeKey {
- EdgeKey() {}
- EdgeKey(const EdgeKey &k) :
- v0(k.v0), v1(k.v1) {}
- EdgeKey(uint32_t v0, uint32_t v1) :
- v0(v0), v1(v1) {}
+ struct EdgeKey
+ {
+ EdgeKey(const EdgeKey &k) : v0(k.v0), v1(k.v1) {}
+ EdgeKey(uint32_t v0, uint32_t v1) : v0(v0), v1(v1) {}
bool operator==(const EdgeKey &k) const { return v0 == k.v0 && v1 == k.v1; }
uint32_t v0;
uint32_t v1;
};
- struct EdgeHash {
+ struct EdgeHash
+ {
uint32_t operator()(const EdgeKey &k) const { return k.v0 * 32768u + k.v1; }
};
HashMap<EdgeKey, EdgeHash> m_edgeMap;
public:
- class BoundaryLoopEdgeIterator {
+ class BoundaryLoopEdgeIterator
+ {
public:
- BoundaryLoopEdgeIterator(const Mesh *mesh, uint32_t edge) :
- m_mesh(mesh), m_first(UINT32_MAX), m_current(edge) {}
+ BoundaryLoopEdgeIterator(const Mesh *mesh, uint32_t edge) : m_mesh(mesh), m_first(UINT32_MAX), m_current(edge) {}
- void advance() {
+ void advance()
+ {
if (m_first == UINT32_MAX)
m_first = m_current;
m_current = m_mesh->m_nextBoundaryEdges[m_current];
}
- bool isDone() const {
+ bool isDone() const
+ {
return m_first == m_current || m_current == UINT32_MAX;
}
- uint32_t edge() const {
+ uint32_t edge() const
+ {
return m_current;
}
- uint32_t nextEdge() const {
+ uint32_t nextEdge() const
+ {
return m_mesh->m_nextBoundaryEdges[m_current];
}
@@ -2920,27 +3003,31 @@ public:
uint32_t m_current;
};
- class ColocalVertexIterator {
+ class ColocalVertexIterator
+ {
public:
- ColocalVertexIterator(const Mesh *mesh, uint32_t v) :
- m_mesh(mesh), m_first(UINT32_MAX), m_current(v) {}
+ ColocalVertexIterator(const Mesh *mesh, uint32_t v) : m_mesh(mesh), m_first(UINT32_MAX), m_current(v) {}
- void advance() {
+ void advance()
+ {
if (m_first == UINT32_MAX)
m_first = m_current;
if (!m_mesh->m_nextColocalVertex.isEmpty())
m_current = m_mesh->m_nextColocalVertex[m_current];
}
- bool isDone() const {
+ bool isDone() const
+ {
return m_first == m_current;
}
- uint32_t vertex() const {
+ uint32_t vertex() const
+ {
return m_current;
}
- const Vector3 *pos() const {
+ const Vector3 *pos() const
+ {
return &m_mesh->m_positions[m_current];
}
@@ -2950,33 +3037,39 @@ public:
uint32_t m_current;
};
- class ColocalEdgeIterator {
+ class ColocalEdgeIterator
+ {
public:
- ColocalEdgeIterator(const Mesh *mesh, uint32_t vertex0, uint32_t vertex1) :
- m_mesh(mesh), m_vertex0It(mesh, vertex0), m_vertex1It(mesh, vertex1), m_vertex1(vertex1) {
+ ColocalEdgeIterator(const Mesh *mesh, uint32_t vertex0, uint32_t vertex1) : m_mesh(mesh), m_vertex0It(mesh, vertex0), m_vertex1It(mesh, vertex1), m_vertex1(vertex1)
+ {
do {
if (!resetElement()) {
advanceVertex1();
- } else {
+ }
+ else {
break;
}
} while (!isDone());
}
- void advance() {
+ void advance()
+ {
advanceElement();
}
- bool isDone() const {
+ bool isDone() const
+ {
return m_vertex0It.isDone() && m_vertex1It.isDone() && m_edge == UINT32_MAX;
}
- uint32_t edge() const {
+ uint32_t edge() const
+ {
return m_edge;
}
private:
- bool resetElement() {
+ bool resetElement()
+ {
m_edge = m_mesh->m_edgeMap.get(Mesh::EdgeKey(m_vertex0It.vertex(), m_vertex1It.vertex()));
while (m_edge != UINT32_MAX) {
if (!isIgnoredFace())
@@ -2989,7 +3082,8 @@ public:
return true;
}
- void advanceElement() {
+ void advanceElement()
+ {
for (;;) {
m_edge = m_mesh->m_edgeMap.getNext(m_edge);
if (m_edge == UINT32_MAX)
@@ -3001,15 +3095,17 @@ public:
advanceVertex1();
}
- void advanceVertex1() {
+ void advanceVertex1()
+ {
auto successful = false;
- while (!successful) {
+ while (!successful) {
m_vertex1It.advance();
if (m_vertex1It.isDone()) {
if (!m_vertex0It.isDone()) {
m_vertex0It.advance();
m_vertex1It = ColocalVertexIterator(m_mesh, m_vertex1);
- } else {
+ }
+ else {
return;
}
}
@@ -3017,7 +3113,8 @@ public:
}
}
- bool isIgnoredFace() const {
+ bool isIgnoredFace() const
+ {
return m_mesh->m_faceIgnore[meshEdgeFace(m_edge)];
}
@@ -3027,21 +3124,24 @@ public:
uint32_t m_edge;
};
- class FaceEdgeIterator {
+ class FaceEdgeIterator
+ {
public:
- FaceEdgeIterator(const Mesh *mesh, uint32_t face) :
- m_mesh(mesh), m_face(face), m_relativeEdge(0) {
+ FaceEdgeIterator (const Mesh *mesh, uint32_t face) : m_mesh(mesh), m_face(face), m_relativeEdge(0)
+ {
m_edge = m_face * 3;
}
- void advance() {
+ void advance()
+ {
if (m_relativeEdge < 3) {
m_edge++;
m_relativeEdge++;
}
}
- bool isDone() const {
+ bool isDone() const
+ {
return m_relativeEdge == 3;
}
@@ -3052,8 +3152,9 @@ public:
uint32_t relativeEdge() const { return m_relativeEdge; }
uint32_t face() const { return m_face; }
uint32_t oppositeEdge() const { return m_mesh->m_oppositeEdges[m_edge]; }
-
- uint32_t oppositeFace() const {
+
+ uint32_t oppositeFace() const
+ {
const uint32_t oedge = m_mesh->m_oppositeEdges[m_edge];
if (oedge == UINT32_MAX)
return UINT32_MAX;
@@ -3075,36 +3176,164 @@ public:
uint32_t m_edge;
uint32_t m_relativeEdge;
};
+};
+
+struct MeshFaceGroups
+{
+ typedef uint32_t Handle;
+ static constexpr Handle kInvalid = UINT32_MAX;
+
+ MeshFaceGroups(const Mesh *mesh) : m_mesh(mesh), m_groups(MemTag::Mesh), m_firstFace(MemTag::Mesh), m_nextFace(MemTag::Mesh), m_faceCount(MemTag::Mesh) {}
+ XA_INLINE Handle groupAt(uint32_t face) const { return m_groups[face]; }
+ XA_INLINE uint32_t groupCount() const { return m_faceCount.size(); }
+ XA_INLINE uint32_t nextFace(uint32_t face) const { return m_nextFace[face]; }
+ XA_INLINE uint32_t faceCount(uint32_t group) const { return m_faceCount[group]; }
+
+ void compute()
+ {
+ m_groups.resize(m_mesh->faceCount());
+ m_groups.fillBytes(0xff); // Set all faces to kInvalid
+ uint32_t firstUnassignedFace = 0;
+ Handle group = 0;
+ Array<uint32_t> growFaces;
+ const uint32_t n = m_mesh->faceCount();
+ m_nextFace.resize(n);
+ for (;;) {
+ // Find an unassigned face.
+ uint32_t face = UINT32_MAX;
+ for (uint32_t f = firstUnassignedFace; f < n; f++) {
+ if (m_groups[f] == kInvalid && !m_mesh->isFaceIgnored(f)) {
+ face = f;
+ firstUnassignedFace = f + 1;
+ break;
+ }
+ }
+ if (face == UINT32_MAX)
+ break; // All faces assigned to a group (except ignored faces).
+ m_groups[face] = group;
+ m_nextFace[face] = UINT32_MAX;
+ m_firstFace.push_back(face);
+ growFaces.clear();
+ growFaces.push_back(face);
+ uint32_t prevFace = face, groupFaceCount = 1;
+ // Find faces connected to the face and assign them to the same group as the face, unless they are already assigned to another group.
+ for (;;) {
+ if (growFaces.isEmpty())
+ break;
+ const uint32_t f = growFaces.back();
+ growFaces.pop_back();
+ for (Mesh::FaceEdgeIterator edgeIt(m_mesh, f); !edgeIt.isDone(); edgeIt.advance()) {
+ // Iterate opposite edges. There may be more than one - non-manifold geometry can have duplicate edges.
+ // Prioritize the one with exact vertex match, not just colocal.
+ // If *any* of the opposite edges are already assigned to this group, don't do anything.
+ bool alreadyAssignedToThisGroup = false;
+ uint32_t bestConnectedFace = UINT32_MAX;
+ for (Mesh::ColocalEdgeIterator oppositeEdgeIt(m_mesh, edgeIt.vertex1(), edgeIt.vertex0()); !oppositeEdgeIt.isDone(); oppositeEdgeIt.advance()) {
+ const uint32_t oppositeEdge = oppositeEdgeIt.edge();
+ const uint32_t oppositeFace = meshEdgeFace(oppositeEdge);
+#if 0
+ // Reject opposite face if dihedral angle >= 90 degrees.
+ {
+ Vector3 a = m_mesh->computeFaceNormal(f);
+ Vector3 b = m_mesh->computeFaceNormal(oppositeFace);
+ if (dot(a, b) <= 0.0f)
+ continue;
+ }
+#endif
+ if (m_mesh->isFaceIgnored(oppositeFace))
+ continue; // Don't add ignored faces to group.
+ if (m_groups[oppositeFace] == group) {
+ alreadyAssignedToThisGroup = true;
+ break;
+ }
+ if (m_groups[oppositeFace] != kInvalid)
+ continue; // Connected face is already assigned to another group.
+ if (faceDuplicatesGroupEdge(group, oppositeFace))
+ continue; // Don't want duplicate edges in a group.
+ const uint32_t oppositeVertex0 = m_mesh->vertexAt(meshEdgeIndex0(oppositeEdge));
+ const uint32_t oppositeVertex1 = m_mesh->vertexAt(meshEdgeIndex1(oppositeEdge));
+ if (bestConnectedFace == UINT32_MAX || (oppositeVertex0 == edgeIt.vertex1() && oppositeVertex1 == edgeIt.vertex0()))
+ bestConnectedFace = oppositeFace;
+#if 0
+ else {
+ // Choose the opposite face with the smallest dihedral angle.
+ const float d1 = 1.0f - dot(computeFaceNormal(f), computeFaceNormal(bestConnectedFace));
+ const float d2 = 1.0f - dot(computeFaceNormal(f), computeFaceNormal(oppositeFace));
+ if (d2 < d1)
+ bestConnectedFace = oppositeFace;
+ }
+#endif
+ }
+ if (!alreadyAssignedToThisGroup && bestConnectedFace != UINT32_MAX) {
+ m_groups[bestConnectedFace] = group;
+ m_nextFace[bestConnectedFace] = UINT32_MAX;
+ if (prevFace != UINT32_MAX)
+ m_nextFace[prevFace] = bestConnectedFace;
+ prevFace = bestConnectedFace;
+ groupFaceCount++;
+ growFaces.push_back(bestConnectedFace);
+ }
+ }
+ }
+ m_faceCount.push_back(groupFaceCount);
+ group++;
+ XA_ASSERT(group < kInvalid);
+ }
+ }
- class GroupFaceIterator {
+ class Iterator
+ {
public:
- GroupFaceIterator(const Mesh *mesh, uint32_t group) :
- m_mesh(mesh) {
- XA_DEBUG_ASSERT(group != UINT32_MAX);
- m_current = mesh->m_faceGroupFirstFace[group];
+ Iterator(const MeshFaceGroups *meshFaceGroups, Handle group) : m_meshFaceGroups(meshFaceGroups)
+ {
+ XA_DEBUG_ASSERT(group != kInvalid);
+ m_current = m_meshFaceGroups->m_firstFace[group];
}
- void advance() {
- m_current = m_mesh->m_faceGroupNextFace[m_current];
+ void advance()
+ {
+ m_current = m_meshFaceGroups->m_nextFace[m_current];
}
- bool isDone() const {
+ bool isDone() const
+ {
return m_current == UINT32_MAX;
}
- uint32_t face() const {
+ uint32_t face() const
+ {
return m_current;
}
private:
- const Mesh *m_mesh;
+ const MeshFaceGroups *m_meshFaceGroups;
uint32_t m_current;
};
+
+private:
+ // Check if the face duplicates any edges of any face already in the group.
+ bool faceDuplicatesGroupEdge(Handle group, uint32_t face) const
+ {
+ for (Mesh::FaceEdgeIterator edgeIt(m_mesh, face); !edgeIt.isDone(); edgeIt.advance()) {
+ for (Mesh::ColocalEdgeIterator colocalEdgeIt(m_mesh, edgeIt.vertex0(), edgeIt.vertex1()); !colocalEdgeIt.isDone(); colocalEdgeIt.advance()) {
+ if (m_groups[meshEdgeFace(colocalEdgeIt.edge())] == group)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ const Mesh *m_mesh;
+ Array<Handle> m_groups;
+ Array<uint32_t> m_firstFace;
+ Array<uint32_t> m_nextFace; // In: face. Out: the next face in the same group.
+ Array<uint32_t> m_faceCount; // In: face group. Out: number of faces in the group.
};
-constexpr uint16_t Mesh::kInvalidFaceGroup;
+constexpr MeshFaceGroups::Handle MeshFaceGroups::kInvalid;
-static bool meshCloseHole(Mesh *mesh, const Array<uint32_t> &holeVertices, const Vector3 &normal) {
+static bool meshCloseHole(Mesh *mesh, const Array<uint32_t> &holeVertices, const Vector3 &normal)
+{
#if XA_CLOSE_HOLES_CHECK_EDGE_INTERSECTION
const uint32_t faceCount = mesh->faceCount();
#endif
@@ -3230,7 +3459,8 @@ static bool meshCloseHole(Mesh *mesh, const Array<uint32_t> &holeVertices, const
return true;
}
-static bool meshCloseHoles(Mesh *mesh, const Array<uint32_t> &boundaryLoops, const Vector3 &normal, uint32_t *holeCount, Array<uint32_t> *holeFaceCounts) {
+static bool meshCloseHoles(Mesh *mesh, const Array<uint32_t> &boundaryLoops, const Vector3 &normal, uint32_t *holeCount, Array<uint32_t> *holeFaceCounts)
+{
if (holeFaceCounts)
holeFaceCounts->clear();
// Compute lengths.
@@ -3286,7 +3516,8 @@ static bool meshCloseHoles(Mesh *mesh, const Array<uint32_t> &boundaryLoops, con
return result;
}
-static bool meshIsPlanar(const Mesh &mesh) {
+static bool meshIsPlanar(const Mesh &mesh)
+{
const Vector3 p1 = mesh.position(mesh.vertexAt(0));
const Vector3 p2 = mesh.position(mesh.vertexAt(1));
const Vector3 p3 = mesh.position(mesh.vertexAt(2));
@@ -3312,12 +3543,14 @@ Fixing T-junctions.
- Split edge.
*/
-struct SplitEdge {
+struct SplitEdge
+{
uint32_t edge;
float t;
uint32_t vertex;
- bool operator<(const SplitEdge &other) const {
+ bool operator<(const SplitEdge &other) const
+ {
if (edge < other.edge)
return true;
else if (edge == other.edge) {
@@ -3329,7 +3562,8 @@ struct SplitEdge {
};
// Returns nullptr if there were no t-junctions to fix.
-static Mesh *meshFixTJunctions(const Mesh &inputMesh, bool *duplicatedEdge, bool *failed, uint32_t *fixedTJunctionsCount) {
+static Mesh *meshFixTJunctions(const Mesh &inputMesh, bool *duplicatedEdge, bool *failed, uint32_t *fixedTJunctionsCount)
+{
if (duplicatedEdge)
*duplicatedEdge = false;
if (failed)
@@ -3404,7 +3638,8 @@ static Mesh *meshFixTJunctions(const Mesh &inputMesh, bool *duplicatedEdge, bool
}
// boundaryLoops are the first edges for each boundary loop.
-static void meshGetBoundaryLoops(const Mesh &mesh, Array<uint32_t> &boundaryLoops) {
+static void meshGetBoundaryLoops(const Mesh &mesh, Array<uint32_t> &boundaryLoops)
+{
const uint32_t edgeCount = mesh.edgeCount();
BitArray bitFlags(edgeCount);
bitFlags.zeroOutMemory();
@@ -3419,23 +3654,26 @@ static void meshGetBoundaryLoops(const Mesh &mesh, Array<uint32_t> &boundaryLoop
}
}
-struct Progress {
- Progress(ProgressCategory::Enum category, ProgressFunc func, void *userData, uint32_t maxValue) :
- value(0), cancel(false), m_category(category), m_func(func), m_userData(userData), m_maxValue(maxValue), m_progress(0) {
+struct Progress
+{
+ Progress(ProgressCategory::Enum category, ProgressFunc func, void *userData, uint32_t maxValue) : value(0), cancel(false), m_category(category), m_func(func), m_userData(userData), m_maxValue(maxValue), m_progress(0)
+ {
if (m_func) {
if (!m_func(category, 0, userData))
cancel = true;
}
}
- ~Progress() {
+ ~Progress()
+ {
if (m_func) {
if (!m_func(m_category, 100, m_userData))
cancel = true;
}
}
- void update() {
+ void update()
+ {
if (!m_func)
return;
m_mutex.lock();
@@ -3448,7 +3686,8 @@ struct Progress {
m_mutex.unlock();
}
- void setMaxValue(uint32_t maxValue) {
+ void setMaxValue(uint32_t maxValue)
+ {
m_mutex.lock();
m_maxValue = maxValue;
m_mutex.unlock();
@@ -3466,31 +3705,32 @@ private:
std::mutex m_mutex;
};
-struct Spinlock {
- void lock() {
- while (m_lock.test_and_set(std::memory_order_acquire)) {
- }
- }
+struct Spinlock
+{
+ void lock() { while(m_lock.test_and_set(std::memory_order_acquire)) {} }
void unlock() { m_lock.clear(std::memory_order_release); }
private:
std::atomic_flag m_lock = ATOMIC_FLAG_INIT;
};
-struct TaskGroupHandle {
+struct TaskGroupHandle
+{
uint32_t value = UINT32_MAX;
};
-struct Task {
+struct Task
+{
void (*func)(void *userData);
void *userData;
};
#if XA_MULTITHREADED
-class TaskScheduler {
+class TaskScheduler
+{
public:
- TaskScheduler() :
- m_shutdown(false) {
+ TaskScheduler() : m_shutdown(false)
+ {
m_threadIndex = 0;
// Max with current task scheduler usage is 1 per thread + 1 deep nesting, but allow for some slop.
m_maxGroups = std::thread::hardware_concurrency() * 4;
@@ -3508,7 +3748,8 @@ public:
}
}
- ~TaskScheduler() {
+ ~TaskScheduler()
+ {
m_shutdown = true;
for (uint32_t i = 0; i < m_workers.size(); i++) {
Worker &worker = m_workers[i];
@@ -3526,11 +3767,13 @@ public:
XA_FREE(m_groups);
}
- uint32_t threadCount() const {
+ uint32_t threadCount() const
+ {
return max(1u, std::thread::hardware_concurrency()); // Including the main thread.
}
- TaskGroupHandle createTaskGroup(uint32_t reserveSize = 0) {
+ TaskGroupHandle createTaskGroup(uint32_t reserveSize = 0)
+ {
// Claim the first free group.
for (uint32_t i = 0; i < m_maxGroups; i++) {
TaskGroup &group = m_groups[i];
@@ -3552,7 +3795,8 @@ public:
return handle;
}
- void run(TaskGroupHandle handle, Task task) {
+ void run(TaskGroupHandle handle, const Task &task)
+ {
XA_DEBUG_ASSERT(handle.value != UINT32_MAX);
TaskGroup &group = m_groups[handle.value];
group.queueLock.lock();
@@ -3566,7 +3810,8 @@ public:
}
}
- void wait(TaskGroupHandle *handle) {
+ void wait(TaskGroupHandle *handle)
+ {
if (handle->value == UINT32_MAX) {
XA_DEBUG_ASSERT(false);
return;
@@ -3594,7 +3839,8 @@ public:
static uint32_t currentThreadIndex() { return m_threadIndex; }
private:
- struct TaskGroup {
+ struct TaskGroup
+ {
std::atomic<bool> free;
Array<Task> queue; // Items are never removed. queueHead is incremented to pop items.
uint32_t queueHead = 0;
@@ -3602,7 +3848,8 @@ private:
std::atomic<uint32_t> ref; // Increment when a task is enqueued, decrement when a task finishes.
};
- struct Worker {
+ struct Worker
+ {
std::thread *thread = nullptr;
std::mutex mutex;
std::condition_variable cv;
@@ -3610,16 +3857,17 @@ private:
};
TaskGroup *m_groups;
- uint32_t m_maxGroups;
Array<Worker> m_workers;
std::atomic<bool> m_shutdown;
+ uint32_t m_maxGroups;
static thread_local uint32_t m_threadIndex;
- static void workerThread(TaskScheduler *scheduler, Worker *worker, uint32_t threadIndex) {
+ static void workerThread(TaskScheduler *scheduler, Worker *worker, uint32_t threadIndex)
+ {
m_threadIndex = threadIndex;
std::unique_lock<std::mutex> lock(worker->mutex);
for (;;) {
- worker->cv.wait(lock, [=] { return worker->wakeup.load(); });
+ worker->cv.wait(lock, [=]{ return worker->wakeup.load(); });
worker->wakeup = false;
for (;;) {
if (scheduler->m_shutdown)
@@ -3650,18 +3898,22 @@ private:
thread_local uint32_t TaskScheduler::m_threadIndex;
#else
-class TaskScheduler {
+class TaskScheduler
+{
public:
- ~TaskScheduler() {
+ ~TaskScheduler()
+ {
for (uint32_t i = 0; i < m_groups.size(); i++)
destroyGroup({ i });
}
- uint32_t threadCount() const {
+ uint32_t threadCount() const
+ {
return 1;
}
- TaskGroupHandle createTaskGroup(uint32_t reserveSize = 0) {
+ TaskGroupHandle createTaskGroup(uint32_t reserveSize = 0)
+ {
TaskGroup *group = XA_NEW(MemTag::Default, TaskGroup);
group->queue.reserve(reserveSize);
m_groups.push_back(group);
@@ -3670,11 +3922,13 @@ public:
return handle;
}
- void run(TaskGroupHandle handle, Task task) {
+ void run(TaskGroupHandle handle, Task task)
+ {
m_groups[handle.value]->queue.push_back(task);
}
- void wait(TaskGroupHandle *handle) {
+ void wait(TaskGroupHandle *handle)
+ {
if (handle->value == UINT32_MAX) {
XA_DEBUG_ASSERT(false);
return;
@@ -3690,7 +3944,8 @@ public:
static uint32_t currentThreadIndex() { return 0; }
private:
- void destroyGroup(TaskGroupHandle handle) {
+ void destroyGroup(TaskGroupHandle handle)
+ {
TaskGroup *group = m_groups[handle.value];
if (group) {
group->~TaskGroup();
@@ -3699,7 +3954,8 @@ private:
}
}
- struct TaskGroup {
+ struct TaskGroup
+ {
Array<Task> queue;
};
@@ -3712,7 +3968,8 @@ const uint8_t TGA_TYPE_RGB = 2;
const uint8_t TGA_ORIGIN_UPPER = 0x20;
#pragma pack(push, 1)
-struct TgaHeader {
+struct TgaHeader
+{
uint8_t id_length;
uint8_t colormap_type;
uint8_t image_type;
@@ -3729,7 +3986,8 @@ struct TgaHeader {
};
#pragma pack(pop)
-static void WriteTga(const char *filename, const uint8_t *data, uint32_t width, uint32_t height) {
+static void WriteTga(const char *filename, const uint8_t *data, uint32_t width, uint32_t height)
+{
XA_DEBUG_ASSERT(sizeof(TgaHeader) == TgaHeader::Size);
FILE *f;
XA_FOPEN(f, filename, "wb");
@@ -3754,10 +4012,12 @@ static void WriteTga(const char *filename, const uint8_t *data, uint32_t width,
}
#endif
-template <typename T>
-class ThreadLocal {
+template<typename T>
+class ThreadLocal
+{
public:
- ThreadLocal() {
+ ThreadLocal()
+ {
#if XA_MULTITHREADED
const uint32_t n = std::thread::hardware_concurrency();
#else
@@ -3768,7 +4028,8 @@ public:
new (&m_array[i]) T;
}
- ~ThreadLocal() {
+ ~ThreadLocal()
+ {
#if XA_MULTITHREADED
const uint32_t n = std::thread::hardware_concurrency();
#else
@@ -3779,7 +4040,8 @@ public:
XA_FREE(m_array);
}
- T &get() const {
+ T &get() const
+ {
return m_array[TaskScheduler::currentThreadIndex()];
}
@@ -3787,9 +4049,11 @@ private:
T *m_array;
};
-class UniformGrid2 {
+class UniformGrid2
+{
public:
- void reset(const Vector2 *positions, const uint32_t *indices = nullptr, uint32_t reserveEdgeCount = 0) {
+ void reset(const Vector2 *positions, const uint32_t *indices = nullptr, uint32_t reserveEdgeCount = 0)
+ {
m_edges.clear();
if (reserveEdgeCount > 0)
m_edges.reserve(reserveEdgeCount);
@@ -3798,14 +4062,16 @@ public:
m_cellDataOffsets.clear();
}
- void append(uint32_t edge) {
+ void append(uint32_t edge)
+ {
XA_DEBUG_ASSERT(m_cellDataOffsets.isEmpty());
m_edges.push_back(edge);
}
- bool intersect(Vector2 v1, Vector2 v2, float epsilon) {
+ bool intersect(Vector2 v1, Vector2 v2, float epsilon)
+ {
const uint32_t edgeCount = m_edges.size();
- bool bruteForce = edgeCount <= 64;
+ bool bruteForce = edgeCount <= 20;
if (!bruteForce && m_cellDataOffsets.isEmpty())
bruteForce = !createGrid();
if (bruteForce) {
@@ -3829,37 +4095,80 @@ public:
return false;
}
- bool intersectSelf(float epsilon) {
- const uint32_t edgeCount = m_edges.size();
- bool bruteForce = edgeCount <= 64;
+ // If edges is empty, checks for intersection with all edges in the grid.
+ bool intersect(float epsilon, ConstArrayView<uint32_t> edges = ConstArrayView<uint32_t>(), ConstArrayView<uint32_t> ignoreEdges = ConstArrayView<uint32_t>())
+ {
+ bool bruteForce = m_edges.size() <= 20;
if (!bruteForce && m_cellDataOffsets.isEmpty())
bruteForce = !createGrid();
- for (uint32_t i = 0; i < edgeCount; i++) {
- const uint32_t edge1 = m_edges[i];
+ const uint32_t *edges1, *edges2 = nullptr;
+ uint32_t edges1Count, edges2Count = 0;
+ if (edges.length == 0) {
+ edges1 = m_edges.data();
+ edges1Count = m_edges.size();
+ } else {
+ edges1 = edges.data;
+ edges1Count = edges.length;
+ }
+ if (bruteForce) {
+ edges2 = m_edges.data();
+ edges2Count = m_edges.size();
+ }
+ for (uint32_t i = 0; i < edges1Count; i++) {
+ const uint32_t edge1 = edges1[i];
+ const uint32_t edge1Vertex[2] = { vertexAt(meshEdgeIndex0(edge1)), vertexAt(meshEdgeIndex1(edge1)) };
+ const Vector2 &edge1Position1 = m_positions[edge1Vertex[0]];
+ const Vector2 &edge1Position2 = m_positions[edge1Vertex[1]];
+ const Extents2 edge1Extents(edge1Position1, edge1Position2);
+ uint32_t j = 0;
if (bruteForce) {
- for (uint32_t j = 0; j < edgeCount; j++) {
- const uint32_t edge2 = m_edges[j];
- if (edgesIntersect(edge1, edge2, epsilon))
- return true;
+ // If checking against self, test each edge pair only once.
+ if (edges.length == 0) {
+ j = i + 1;
+ if (j == edges1Count)
+ break;
}
} else {
computePotentialEdges(edgePosition0(edge1), edgePosition1(edge1));
- uint32_t prevEdge = UINT32_MAX;
- for (uint32_t j = 0; j < m_potentialEdges.size(); j++) {
- const uint32_t edge2 = m_potentialEdges[j];
- if (edge2 == prevEdge)
- continue;
- if (edgesIntersect(edge1, edge2, epsilon))
- return true;
- prevEdge = edge2;
+ edges2 = m_potentialEdges.data();
+ edges2Count = m_potentialEdges.size();
+ }
+ uint32_t prevEdge = UINT32_MAX; // Handle potential edges duplicates.
+ for (; j < edges2Count; j++) {
+ const uint32_t edge2 = edges2[j];
+ if (edge1 == edge2)
+ continue;
+ if (edge2 == prevEdge)
+ continue;
+ prevEdge = edge2;
+ // Check if edge2 is ignored.
+ bool ignore = false;
+ for (uint32_t k = 0; k < ignoreEdges.length; k++) {
+ if (edge2 == ignoreEdges[k]) {
+ ignore = true;
+ break;
+ }
}
+ if (ignore)
+ continue;
+ const uint32_t edge2Vertex[2] = { vertexAt(meshEdgeIndex0(edge2)), vertexAt(meshEdgeIndex1(edge2)) };
+ // Ignore connected edges, since they can't intersect (only overlap), and may be detected as false positives.
+ if (edge1Vertex[0] == edge2Vertex[0] || edge1Vertex[0] == edge2Vertex[1] || edge1Vertex[1] == edge2Vertex[0] || edge1Vertex[1] == edge2Vertex[1])
+ continue;
+ const Vector2 &edge2Position1 = m_positions[edge2Vertex[0]];
+ const Vector2 &edge2Position2 = m_positions[edge2Vertex[1]];
+ if (!Extents2::intersect(edge1Extents, Extents2(edge2Position1, edge2Position2)))
+ continue;
+ if (linesIntersect(edge1Position1, edge1Position2, edge2Position1, edge2Position2, epsilon))
+ return true;
}
}
return false;
}
#if XA_DEBUG_EXPORT_BOUNDARY_GRID
- void debugExport(const char *filename) {
+ void debugExport(const char *filename)
+ {
Array<uint8_t> image;
image.resize(m_gridWidth * m_gridHeight * 3);
for (uint32_t y = 0; y < m_gridHeight; y++) {
@@ -3881,7 +4190,8 @@ public:
#endif
private:
- bool createGrid() {
+ bool createGrid()
+ {
// Compute edge extents. Min will be the grid origin.
const uint32_t edgeCount = m_edges.size();
Extents2 edgeExtents;
@@ -3933,7 +4243,8 @@ private:
return true;
}
- void computePotentialEdges(Vector2 p1, Vector2 p2) {
+ void computePotentialEdges(Vector2 p1, Vector2 p2)
+ {
m_potentialEdges.clear();
traverse(p1, p2);
for (uint32_t j = 0; j < m_traversedCellOffsets.size(); j++) {
@@ -3951,7 +4262,8 @@ private:
}
// "A Fast Voxel Traversal Algorithm for Ray Tracing"
- void traverse(Vector2 p1, Vector2 p2) {
+ void traverse(Vector2 p1, Vector2 p2)
+ {
const Vector2 dir = p2 - p1;
const Vector2 normal = normalizeSafe(dir, Vector2(0.0f), kEpsilon);
const int stepX = dir.x >= 0 ? 1 : -1;
@@ -3972,12 +4284,14 @@ private:
if (normal.x > kEpsilon || normal.x < -kEpsilon) {
tMaxX = (distToNextCellX * stepX) / normal.x;
tDeltaX = (m_cellSize * stepX) / normal.x;
- } else
+ }
+ else
tMaxX = tDeltaX = FLT_MAX;
if (normal.y > kEpsilon || normal.y < -kEpsilon) {
tMaxY = (distToNextCellY * stepY) / normal.y;
tDeltaY = (m_cellSize * stepY) / normal.y;
- } else
+ }
+ else
tMaxY = tDeltaY = FLT_MAX;
m_traversedCellOffsets.clear();
m_traversedCellOffsets.push_back(firstCell[0] + firstCell[1] * m_gridWidth);
@@ -3992,11 +4306,11 @@ private:
}
if (currentCell[0] >= m_gridWidth || currentCell[1] >= m_gridHeight)
break;
- if (stepX == 0 && currentCell[0] < lastCell[0])
+ if (stepX == -1 && currentCell[0] < lastCell[0])
break;
if (stepX == 1 && currentCell[0] > lastCell[0])
break;
- if (stepY == 0 && currentCell[1] < lastCell[1])
+ if (stepY == -1 && currentCell[1] < lastCell[1])
break;
if (stepY == 1 && currentCell[1] > lastCell[1])
break;
@@ -4004,34 +4318,28 @@ private:
}
}
- bool edgesIntersect(uint32_t edge1, uint32_t edge2, float epsilon) const {
- if (edge1 == edge2)
- return false;
- const uint32_t ai[2] = { vertexAt(meshEdgeIndex0(edge1)), vertexAt(meshEdgeIndex1(edge1)) };
- const uint32_t bi[2] = { vertexAt(meshEdgeIndex0(edge2)), vertexAt(meshEdgeIndex1(edge2)) };
- // Ignore connected edges, since they can't intersect (only overlap), and may be detected as false positives.
- if (ai[0] == bi[0] || ai[0] == bi[1] || ai[1] == bi[0] || ai[1] == bi[1])
- return false;
- return linesIntersect(m_positions[ai[0]], m_positions[ai[1]], m_positions[bi[0]], m_positions[bi[1]], epsilon);
- }
-
- uint32_t cellX(float x) const {
+ uint32_t cellX(float x) const
+ {
return min((uint32_t)max(0.0f, (x - m_gridOrigin.x) / m_cellSize), m_gridWidth - 1u);
}
- uint32_t cellY(float y) const {
+ uint32_t cellY(float y) const
+ {
return min((uint32_t)max(0.0f, (y - m_gridOrigin.y) / m_cellSize), m_gridHeight - 1u);
}
- Vector2 edgePosition0(uint32_t edge) const {
+ Vector2 edgePosition0(uint32_t edge) const
+ {
return m_positions[vertexAt(meshEdgeIndex0(edge))];
}
- Vector2 edgePosition1(uint32_t edge) const {
+ Vector2 edgePosition1(uint32_t edge) const
+ {
return m_positions[vertexAt(meshEdgeIndex1(edge))];
}
- uint32_t vertexAt(uint32_t index) const {
+ uint32_t vertexAt(uint32_t index) const
+ {
return m_indices ? m_indices[index] : index;
}
@@ -4047,29 +4355,835 @@ private:
Array<uint32_t> m_traversedCellOffsets;
};
-struct UvMeshChart {
+struct UvMeshChart
+{
Array<uint32_t> faces;
Array<uint32_t> indices;
uint32_t material;
};
-struct UvMesh {
+struct UvMesh
+{
UvMeshDecl decl;
Array<uint32_t> indices;
Array<UvMeshChart *> charts;
Array<uint32_t> vertexToChartMap;
};
-struct UvMeshInstance {
+struct UvMeshInstance
+{
UvMesh *mesh;
Array<Vector2> texcoords;
bool rotateCharts;
};
+/*
+ * Copyright (c) 2004-2010, Bruno Levy
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the ALICE Project-Team nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * If you modify this software, you should include a notice giving the
+ * name of the person performing the modification, the date of modification,
+ * and the reason for such modification.
+ *
+ * Contact: Bruno Levy
+ *
+ * levy@loria.fr
+ *
+ * ALICE Project
+ * LORIA, INRIA Lorraine,
+ * Campus Scientifique, BP 239
+ * 54506 VANDOEUVRE LES NANCY CEDEX
+ * FRANCE
+ */
+namespace opennl {
+#define NL_NEW(T) XA_ALLOC(MemTag::OpenNL, T)
+#define NL_NEW_ARRAY(T,NB) XA_ALLOC_ARRAY(MemTag::OpenNL, T, NB)
+#define NL_RENEW_ARRAY(T,x,NB) XA_REALLOC(MemTag::OpenNL, x, T, NB)
+#define NL_DELETE(x) XA_FREE(x); x = nullptr
+#define NL_DELETE_ARRAY(x) XA_FREE(x); x = nullptr
+#define NL_CLEAR(x, T) memset(x, 0, sizeof(T));
+#define NL_CLEAR_ARRAY(T,x,NB) memset(x, 0, (size_t)(NB)*sizeof(T))
+#define NL_NEW_VECTOR(dim) XA_ALLOC_ARRAY(MemTag::OpenNL, double, dim)
+#define NL_DELETE_VECTOR(ptr) XA_FREE(ptr)
+
+struct NLMatrixStruct;
+typedef NLMatrixStruct * NLMatrix;
+typedef void (*NLDestroyMatrixFunc)(NLMatrix M);
+typedef void (*NLMultMatrixVectorFunc)(NLMatrix M, const double* x, double* y);
+
+#define NL_MATRIX_SPARSE_DYNAMIC 0x1001
+#define NL_MATRIX_CRS 0x1002
+#define NL_MATRIX_OTHER 0x1006
+
+struct NLMatrixStruct
+{
+ uint32_t m;
+ uint32_t n;
+ uint32_t type;
+ NLDestroyMatrixFunc destroy_func;
+ NLMultMatrixVectorFunc mult_func;
+};
+
+/* Dynamic arrays for sparse row/columns */
+
+struct NLCoeff
+{
+ uint32_t index;
+ double value;
+};
+
+struct NLRowColumn
+{
+ uint32_t size;
+ uint32_t capacity;
+ NLCoeff* coeff;
+};
+
+/* Compressed Row Storage */
+
+struct NLCRSMatrix
+{
+ uint32_t m;
+ uint32_t n;
+ uint32_t type;
+ NLDestroyMatrixFunc destroy_func;
+ NLMultMatrixVectorFunc mult_func;
+ double* val;
+ uint32_t* rowptr;
+ uint32_t* colind;
+ uint32_t nslices;
+ uint32_t* sliceptr;
+};
+
+/* SparseMatrix data structure */
+
+struct NLSparseMatrix
+{
+ uint32_t m;
+ uint32_t n;
+ uint32_t type;
+ NLDestroyMatrixFunc destroy_func;
+ NLMultMatrixVectorFunc mult_func;
+ uint32_t diag_size;
+ uint32_t diag_capacity;
+ NLRowColumn* row;
+ NLRowColumn* column;
+ double* diag;
+ uint32_t row_capacity;
+ uint32_t column_capacity;
+};
+
+/* NLContext data structure */
+
+struct NLBufferBinding
+{
+ void* base_address;
+ uint32_t stride;
+};
+
+#define NL_BUFFER_ITEM(B,i) *(double*)((void*)((char*)((B).base_address)+((i)*(B).stride)))
+
+struct NLContext
+{
+ NLBufferBinding *variable_buffer;
+ double *variable_value;
+ bool *variable_is_locked;
+ uint32_t *variable_index;
+ uint32_t n;
+ NLMatrix M;
+ NLMatrix P;
+ NLMatrix B;
+ NLRowColumn af;
+ NLRowColumn al;
+ double *x;
+ double *b;
+ uint32_t nb_variables;
+ uint32_t nb_systems;
+ uint32_t current_row;
+ uint32_t max_iterations;
+ bool max_iterations_defined;
+ double threshold;
+ double omega;
+ uint32_t used_iterations;
+ double error;
+};
+
+static void nlDeleteMatrix(NLMatrix M)
+{
+ if (!M)
+ return;
+ M->destroy_func(M);
+ NL_DELETE(M);
+}
+
+static void nlMultMatrixVector(NLMatrix M, const double* x, double* y)
+{
+ M->mult_func(M, x, y);
+}
+
+static void nlRowColumnConstruct(NLRowColumn* c)
+{
+ c->size = 0;
+ c->capacity = 0;
+ c->coeff = nullptr;
+}
+
+static void nlRowColumnDestroy(NLRowColumn* c)
+{
+ NL_DELETE_ARRAY(c->coeff);
+ c->size = 0;
+ c->capacity = 0;
+}
+
+static void nlRowColumnGrow(NLRowColumn* c)
+{
+ if (c->capacity != 0) {
+ c->capacity = 2 * c->capacity;
+ c->coeff = NL_RENEW_ARRAY(NLCoeff, c->coeff, c->capacity);
+ } else {
+ c->capacity = 4;
+ c->coeff = NL_NEW_ARRAY(NLCoeff, c->capacity);
+ NL_CLEAR_ARRAY(NLCoeff, c->coeff, c->capacity);
+ }
+}
+
+static void nlRowColumnAdd(NLRowColumn* c, uint32_t index, double value)
+{
+ for (uint32_t i = 0; i < c->size; i++) {
+ if (c->coeff[i].index == index) {
+ c->coeff[i].value += value;
+ return;
+ }
+ }
+ if (c->size == c->capacity)
+ nlRowColumnGrow(c);
+ c->coeff[c->size].index = index;
+ c->coeff[c->size].value = value;
+ c->size++;
+}
+
+/* Does not check whether the index already exists */
+static void nlRowColumnAppend(NLRowColumn* c, uint32_t index, double value)
+{
+ if (c->size == c->capacity)
+ nlRowColumnGrow(c);
+ c->coeff[c->size].index = index;
+ c->coeff[c->size].value = value;
+ c->size++;
+}
+
+static void nlRowColumnZero(NLRowColumn* c)
+{
+ c->size = 0;
+}
+
+static void nlRowColumnClear(NLRowColumn* c)
+{
+ c->size = 0;
+ c->capacity = 0;
+ NL_DELETE_ARRAY(c->coeff);
+}
+
+static int nlCoeffCompare(const void* p1, const void* p2)
+{
+ return (((NLCoeff*)(p2))->index < ((NLCoeff*)(p1))->index);
+}
+
+static void nlRowColumnSort(NLRowColumn* c)
+{
+ qsort(c->coeff, c->size, sizeof(NLCoeff), nlCoeffCompare);
+}
+
+/* CRSMatrix data structure */
+
+static void nlCRSMatrixDestroy(NLCRSMatrix* M)
+{
+ NL_DELETE_ARRAY(M->val);
+ NL_DELETE_ARRAY(M->rowptr);
+ NL_DELETE_ARRAY(M->colind);
+ NL_DELETE_ARRAY(M->sliceptr);
+ M->m = 0;
+ M->n = 0;
+ M->nslices = 0;
+}
+
+static void nlCRSMatrixMultSlice(NLCRSMatrix* M, const double* x, double* y, uint32_t Ibegin, uint32_t Iend)
+{
+ for (uint32_t i = Ibegin; i < Iend; ++i) {
+ double sum = 0.0;
+ for (uint32_t j = M->rowptr[i]; j < M->rowptr[i + 1]; ++j)
+ sum += M->val[j] * x[M->colind[j]];
+ y[i] = sum;
+ }
+}
+
+static void nlCRSMatrixMult(NLCRSMatrix* M, const double* x, double* y)
+{
+ int nslices = (int)(M->nslices);
+ for (int slice = 0; slice < nslices; ++slice)
+ nlCRSMatrixMultSlice(M, x, y, M->sliceptr[slice], M->sliceptr[slice + 1]);
+}
+
+static void nlCRSMatrixConstruct(NLCRSMatrix* M, uint32_t m, uint32_t n, uint32_t nnz, uint32_t nslices)
+{
+ M->m = m;
+ M->n = n;
+ M->type = NL_MATRIX_CRS;
+ M->destroy_func = (NLDestroyMatrixFunc)nlCRSMatrixDestroy;
+ M->mult_func = (NLMultMatrixVectorFunc)nlCRSMatrixMult;
+ M->nslices = nslices;
+ M->val = NL_NEW_ARRAY(double, nnz);
+ NL_CLEAR_ARRAY(double, M->val, nnz);
+ M->rowptr = NL_NEW_ARRAY(uint32_t, m + 1);
+ NL_CLEAR_ARRAY(uint32_t, M->rowptr, m + 1);
+ M->colind = NL_NEW_ARRAY(uint32_t, nnz);
+ NL_CLEAR_ARRAY(uint32_t, M->colind, nnz);
+ M->sliceptr = NL_NEW_ARRAY(uint32_t, nslices + 1);
+ NL_CLEAR_ARRAY(uint32_t, M->sliceptr, nslices + 1);
+}
+
+/* SparseMatrix data structure */
+
+static void nlSparseMatrixDestroyRowColumns(NLSparseMatrix* M)
+{
+ for (uint32_t i = 0; i < M->m; i++)
+ nlRowColumnDestroy(&(M->row[i]));
+ NL_DELETE_ARRAY(M->row);
+}
+
+static void nlSparseMatrixDestroy(NLSparseMatrix* M)
+{
+ XA_DEBUG_ASSERT(M->type == NL_MATRIX_SPARSE_DYNAMIC);
+ nlSparseMatrixDestroyRowColumns(M);
+ NL_DELETE_ARRAY(M->diag);
+}
+
+static void nlSparseMatrixAdd(NLSparseMatrix* M, uint32_t i, uint32_t j, double value)
+{
+ XA_DEBUG_ASSERT(i >= 0 && i <= M->m - 1);
+ XA_DEBUG_ASSERT(j >= 0 && j <= M->n - 1);
+ if (i == j)
+ M->diag[i] += value;
+ nlRowColumnAdd(&(M->row[i]), j, value);
+}
+
+/* Returns the number of non-zero coefficients */
+static uint32_t nlSparseMatrixNNZ(NLSparseMatrix* M)
+{
+ uint32_t nnz = 0;
+ for (uint32_t i = 0; i < M->m; i++)
+ nnz += M->row[i].size;
+ return nnz;
+}
+
+static void nlSparseMatrixSort(NLSparseMatrix* M)
+{
+ for (uint32_t i = 0; i < M->m; i++)
+ nlRowColumnSort(&(M->row[i]));
+}
+
+/* SparseMatrix x Vector routines, internal helper routines */
+
+static void nlSparseMatrix_mult_rows(NLSparseMatrix* A, const double* x, double* y)
+{
+ /*
+ * Note: OpenMP does not like unsigned ints
+ * (causes some floating point exceptions),
+ * therefore I use here signed ints for all
+ * indices.
+ */
+ int m = (int)(A->m);
+ NLCoeff* c = nullptr;
+ NLRowColumn* Ri = nullptr;
+ for (int i = 0; i < m; i++) {
+ Ri = &(A->row[i]);
+ y[i] = 0;
+ for (int ij = 0; ij < (int)(Ri->size); ij++) {
+ c = &(Ri->coeff[ij]);
+ y[i] += c->value * x[c->index];
+ }
+ }
+}
+
+static void nlSparseMatrixMult(NLSparseMatrix* A, const double* x, double* y)
+{
+ XA_DEBUG_ASSERT(A->type == NL_MATRIX_SPARSE_DYNAMIC);
+ nlSparseMatrix_mult_rows(A, x, y);
+}
+
+static void nlSparseMatrixConstruct(NLSparseMatrix* M, uint32_t m, uint32_t n)
+{
+ M->m = m;
+ M->n = n;
+ M->type = NL_MATRIX_SPARSE_DYNAMIC;
+ M->destroy_func = (NLDestroyMatrixFunc)nlSparseMatrixDestroy;
+ M->mult_func = (NLMultMatrixVectorFunc)nlSparseMatrixMult;
+ M->row = NL_NEW_ARRAY(NLRowColumn, m);
+ NL_CLEAR_ARRAY(NLRowColumn, M->row, m);
+ M->row_capacity = m;
+ for (uint32_t i = 0; i < n; i++)
+ nlRowColumnConstruct(&(M->row[i]));
+ M->row_capacity = 0;
+ M->column = nullptr;
+ M->column_capacity = 0;
+ M->diag_size = min(m, n);
+ M->diag_capacity = M->diag_size;
+ M->diag = NL_NEW_ARRAY(double, M->diag_size);
+ NL_CLEAR_ARRAY(double, M->diag, M->diag_size);
+}
+
+static NLMatrix nlCRSMatrixNewFromSparseMatrix(NLSparseMatrix* M)
+{
+ uint32_t nnz = nlSparseMatrixNNZ(M);
+ uint32_t nslices = 8; /* TODO: get number of cores */
+ uint32_t slice, cur_bound, cur_NNZ, cur_row;
+ uint32_t k;
+ uint32_t slice_size = nnz / nslices;
+ NLCRSMatrix* CRS = NL_NEW(NLCRSMatrix);
+ NL_CLEAR(CRS, NLCRSMatrix);
+ nlCRSMatrixConstruct(CRS, M->m, M->n, nnz, nslices);
+ nlSparseMatrixSort(M);
+ /* Convert matrix to CRS format */
+ k = 0;
+ for (uint32_t i = 0; i < M->m; ++i) {
+ NLRowColumn* Ri = &(M->row[i]);
+ CRS->rowptr[i] = k;
+ for (uint32_t ij = 0; ij < Ri->size; ij++) {
+ NLCoeff* c = &(Ri->coeff[ij]);
+ CRS->val[k] = c->value;
+ CRS->colind[k] = c->index;
+ ++k;
+ }
+ }
+ CRS->rowptr[M->m] = k;
+ /* Create "slices" to be used by parallel sparse matrix vector product */
+ if (CRS->sliceptr) {
+ cur_bound = slice_size;
+ cur_NNZ = 0;
+ cur_row = 0;
+ CRS->sliceptr[0] = 0;
+ for (slice = 1; slice < nslices; ++slice) {
+ while (cur_NNZ < cur_bound && cur_row < M->m) {
+ ++cur_row;
+ cur_NNZ += CRS->rowptr[cur_row + 1] - CRS->rowptr[cur_row];
+ }
+ CRS->sliceptr[slice] = cur_row;
+ cur_bound += slice_size;
+ }
+ CRS->sliceptr[nslices] = M->m;
+ }
+ return (NLMatrix)CRS;
+}
+
+static void nlMatrixCompress(NLMatrix* M)
+{
+ NLMatrix CRS = nullptr;
+ if ((*M)->type != NL_MATRIX_SPARSE_DYNAMIC)
+ return;
+ CRS = nlCRSMatrixNewFromSparseMatrix((NLSparseMatrix*)*M);
+ nlDeleteMatrix(*M);
+ *M = CRS;
+}
+
+static NLContext *nlNewContext()
+{
+ NLContext* result = NL_NEW(NLContext);
+ NL_CLEAR(result, NLContext);
+ result->max_iterations = 100;
+ result->threshold = 1e-6;
+ result->omega = 1.5;
+ result->nb_systems = 1;
+ return result;
+}
+
+static void nlDeleteContext(NLContext *context)
+{
+ nlDeleteMatrix(context->M);
+ context->M = nullptr;
+ nlDeleteMatrix(context->P);
+ context->P = nullptr;
+ nlDeleteMatrix(context->B);
+ context->B = nullptr;
+ nlRowColumnDestroy(&context->af);
+ nlRowColumnDestroy(&context->al);
+ NL_DELETE_ARRAY(context->variable_value);
+ NL_DELETE_ARRAY(context->variable_buffer);
+ NL_DELETE_ARRAY(context->variable_is_locked);
+ NL_DELETE_ARRAY(context->variable_index);
+ NL_DELETE_ARRAY(context->x);
+ NL_DELETE_ARRAY(context->b);
+ NL_DELETE(context);
+}
+
+static double ddot(int n, const double *x, const double *y)
+{
+ double sum = 0.0;
+ for (int i = 0; i < n; i++)
+ sum += x[i] * y[i];
+ return sum;
+}
+
+static void daxpy(int n, double a, const double *x, double *y)
+{
+ for (int i = 0; i < n; i++)
+ y[i] = a * x[i] + y[i];
+}
+
+static void dscal(int n, double a, double *x)
+{
+ for (int i = 0; i < n; i++)
+ x[i] *= a;
+}
+
+/*
+ * The implementation of the solvers is inspired by
+ * the lsolver library, by Christian Badura, available from:
+ * http://www.mathematik.uni-freiburg.de
+ * /IAM/Research/projectskr/lin_solver/
+ *
+ * About the Conjugate Gradient, details can be found in:
+ * Ashby, Manteuffel, Saylor
+ * A taxononmy for conjugate gradient methods
+ * SIAM J Numer Anal 27, 1542-1568 (1990)
+ *
+ * This version is completely abstract, the same code can be used for
+ * CPU/GPU, dense matrix / sparse matrix etc...
+ * Abstraction is realized through:
+ * - Abstract matrix interface (NLMatrix), that can implement different
+ * versions of matrix x vector product (CPU/GPU, sparse/dense ...)
+ */
+
+static uint32_t nlSolveSystem_PRE_CG(NLMatrix M, NLMatrix P, double* b, double* x, double eps, uint32_t max_iter, double *sq_bnorm, double *sq_rnorm)
+{
+ int N = (int)M->n;
+ double* r = NL_NEW_VECTOR(N);
+ double* d = NL_NEW_VECTOR(N);
+ double* h = NL_NEW_VECTOR(N);
+ double *Ad = h;
+ uint32_t its = 0;
+ double rh, alpha, beta;
+ double b_square = ddot(N, b, b);
+ double err = eps * eps*b_square;
+ double curr_err;
+ nlMultMatrixVector(M, x, r);
+ daxpy(N, -1., b, r);
+ nlMultMatrixVector(P, r, d);
+ memcpy(h, d, N * sizeof(double));
+ rh = ddot(N, r, h);
+ curr_err = ddot(N, r, r);
+ while (curr_err > err && its < max_iter) {
+ nlMultMatrixVector(M, d, Ad);
+ alpha = rh / ddot(N, d, Ad);
+ daxpy(N, -alpha, d, x);
+ daxpy(N, -alpha, Ad, r);
+ nlMultMatrixVector(P, r, h);
+ beta = 1. / rh;
+ rh = ddot(N, r, h);
+ beta *= rh;
+ dscal(N, beta, d);
+ daxpy(N, 1., h, d);
+ ++its;
+ curr_err = ddot(N, r, r);
+ }
+ NL_DELETE_VECTOR(r);
+ NL_DELETE_VECTOR(d);
+ NL_DELETE_VECTOR(h);
+ *sq_bnorm = b_square;
+ *sq_rnorm = curr_err;
+ return its;
+}
+
+static uint32_t nlSolveSystemIterative(NLContext *context, NLMatrix M, NLMatrix P, double* b_in, double* x_in, double eps, uint32_t max_iter)
+{
+ uint32_t result = 0;
+ double rnorm = 0.0;
+ double bnorm = 0.0;
+ double* b = b_in;
+ double* x = x_in;
+ XA_DEBUG_ASSERT(M->m == M->n);
+ double sq_bnorm, sq_rnorm;
+ result = nlSolveSystem_PRE_CG(M, P, b, x, eps, max_iter, &sq_bnorm, &sq_rnorm);
+ /* Get residual norm and rhs norm */
+ bnorm = sqrt(sq_bnorm);
+ rnorm = sqrt(sq_rnorm);
+ if (bnorm == 0.0)
+ context->error = rnorm;
+ else
+ context->error = rnorm / bnorm;
+ context->used_iterations = result;
+ return result;
+}
+
+static bool nlSolveIterative(NLContext *context)
+{
+ double* b = context->b;
+ double* x = context->x;
+ uint32_t n = context->n;
+ NLMatrix M = context->M;
+ NLMatrix P = context->P;
+ for (uint32_t k = 0; k < context->nb_systems; ++k) {
+ nlSolveSystemIterative(context, M, P, b, x, context->threshold, context->max_iterations);
+ b += n;
+ x += n;
+ }
+ return true;
+}
+
+struct NLJacobiPreconditioner
+{
+ uint32_t m;
+ uint32_t n;
+ uint32_t type;
+ NLDestroyMatrixFunc destroy_func;
+ NLMultMatrixVectorFunc mult_func;
+ double* diag_inv;
+};
+
+static void nlJacobiPreconditionerDestroy(NLJacobiPreconditioner* M)
+{
+ NL_DELETE_ARRAY(M->diag_inv);
+}
+
+static void nlJacobiPreconditionerMult(NLJacobiPreconditioner* M, const double* x, double* y)
+{
+ for (uint32_t i = 0; i < M->n; ++i)
+ y[i] = x[i] * M->diag_inv[i];
+}
+
+static NLMatrix nlNewJacobiPreconditioner(NLMatrix M_in)
+{
+ NLSparseMatrix* M = nullptr;
+ NLJacobiPreconditioner* result = nullptr;
+ XA_DEBUG_ASSERT(M_in->type == NL_MATRIX_SPARSE_DYNAMIC);
+ XA_DEBUG_ASSERT(M_in->m == M_in->n);
+ M = (NLSparseMatrix*)M_in;
+ result = NL_NEW(NLJacobiPreconditioner);
+ NL_CLEAR(result, NLJacobiPreconditioner);
+ result->m = M->m;
+ result->n = M->n;
+ result->type = NL_MATRIX_OTHER;
+ result->destroy_func = (NLDestroyMatrixFunc)nlJacobiPreconditionerDestroy;
+ result->mult_func = (NLMultMatrixVectorFunc)nlJacobiPreconditionerMult;
+ result->diag_inv = NL_NEW_ARRAY(double, M->n);
+ NL_CLEAR_ARRAY(double, result->diag_inv, M->n);
+ for (uint32_t i = 0; i < M->n; ++i)
+ result->diag_inv[i] = (M->diag[i] == 0.0) ? 1.0 : 1.0 / M->diag[i];
+ return (NLMatrix)result;
+}
+
+#define NL_NB_VARIABLES 0x101
+#define NL_MAX_ITERATIONS 0x103
+
+static void nlSolverParameteri(NLContext *context, uint32_t pname, int param)
+{
+ if (pname == NL_NB_VARIABLES) {
+ XA_DEBUG_ASSERT(param > 0);
+ context->nb_variables = (uint32_t)param;
+ } else if (pname == NL_MAX_ITERATIONS) {
+ XA_DEBUG_ASSERT(param > 0);
+ context->max_iterations = (uint32_t)param;
+ context->max_iterations_defined = true;
+ }
+}
+
+static void nlSetVariable(NLContext *context, uint32_t index, double value)
+{
+ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1);
+ NL_BUFFER_ITEM(context->variable_buffer[0], index) = value;
+}
+
+static double nlGetVariable(NLContext *context, uint32_t index)
+{
+ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1);
+ return NL_BUFFER_ITEM(context->variable_buffer[0], index);
+}
+
+static void nlLockVariable(NLContext *context, uint32_t index)
+{
+ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1);
+ context->variable_is_locked[index] = true;
+}
+
+static void nlVariablesToVector(NLContext *context)
+{
+ uint32_t n = context->n;
+ XA_DEBUG_ASSERT(context->x);
+ for (uint32_t k = 0; k < context->nb_systems; ++k) {
+ for (uint32_t i = 0; i < context->nb_variables; ++i) {
+ if (!context->variable_is_locked[i]) {
+ uint32_t index = context->variable_index[i];
+ XA_DEBUG_ASSERT(index < context->n);
+ double value = NL_BUFFER_ITEM(context->variable_buffer[k], i);
+ context->x[index + k * n] = value;
+ }
+ }
+ }
+}
+
+static void nlVectorToVariables(NLContext *context)
+{
+ uint32_t n = context->n;
+ XA_DEBUG_ASSERT(context->x);
+ for (uint32_t k = 0; k < context->nb_systems; ++k) {
+ for (uint32_t i = 0; i < context->nb_variables; ++i) {
+ if (!context->variable_is_locked[i]) {
+ uint32_t index = context->variable_index[i];
+ XA_DEBUG_ASSERT(index < context->n);
+ double value = context->x[index + k * n];
+ NL_BUFFER_ITEM(context->variable_buffer[k], i) = value;
+ }
+ }
+ }
+}
+
+static void nlCoefficient(NLContext *context, uint32_t index, double value)
+{
+ XA_DEBUG_ASSERT(index >= 0 && index <= context->nb_variables - 1);
+ if (context->variable_is_locked[index]) {
+ /*
+ * Note: in al, indices are NLvariable indices,
+ * within [0..nb_variables-1]
+ */
+ nlRowColumnAppend(&(context->al), index, value);
+ } else {
+ /*
+ * Note: in af, indices are system indices,
+ * within [0..n-1]
+ */
+ nlRowColumnAppend(&(context->af), context->variable_index[index], value);
+ }
+}
+
+#define NL_SYSTEM 0x0
+#define NL_MATRIX 0x1
+#define NL_ROW 0x2
+
+static void nlBegin(NLContext *context, uint32_t prim)
+{
+ if (prim == NL_SYSTEM) {
+ XA_DEBUG_ASSERT(context->nb_variables > 0);
+ context->variable_buffer = NL_NEW_ARRAY(NLBufferBinding, context->nb_systems);
+ NL_CLEAR_ARRAY(NLBufferBinding, context->variable_buffer, context->nb_systems);
+ context->variable_value = NL_NEW_ARRAY(double, context->nb_variables * context->nb_systems);
+ NL_CLEAR_ARRAY(double, context->variable_value, context->nb_variables * context->nb_systems);
+ for (uint32_t k = 0; k < context->nb_systems; ++k) {
+ context->variable_buffer[k].base_address =
+ context->variable_value +
+ k * context->nb_variables;
+ context->variable_buffer[k].stride = sizeof(double);
+ }
+ context->variable_is_locked = NL_NEW_ARRAY(bool, context->nb_variables);
+ NL_CLEAR_ARRAY(bool, context->variable_is_locked, context->nb_variables);
+ context->variable_index = NL_NEW_ARRAY(uint32_t, context->nb_variables);
+ NL_CLEAR_ARRAY(uint32_t, context->variable_index, context->nb_variables);
+ } else if (prim == NL_MATRIX) {
+ if (context->M)
+ return;
+ uint32_t n = 0;
+ for (uint32_t i = 0; i < context->nb_variables; i++) {
+ if (!context->variable_is_locked[i]) {
+ context->variable_index[i] = n;
+ n++;
+ } else
+ context->variable_index[i] = (uint32_t)~0;
+ }
+ context->n = n;
+ if (!context->max_iterations_defined)
+ context->max_iterations = n * 5;
+ context->M = (NLMatrix)(NL_NEW(NLSparseMatrix));
+ NL_CLEAR(context->M, NLSparseMatrix);
+ nlSparseMatrixConstruct((NLSparseMatrix*)(context->M), n, n);
+ context->x = NL_NEW_ARRAY(double, n*context->nb_systems);
+ NL_CLEAR_ARRAY(double, context->x, n*context->nb_systems);
+ context->b = NL_NEW_ARRAY(double, n*context->nb_systems);
+ NL_CLEAR_ARRAY(double, context->b, n*context->nb_systems);
+ nlVariablesToVector(context);
+ nlRowColumnConstruct(&context->af);
+ nlRowColumnConstruct(&context->al);
+ context->current_row = 0;
+ } else if (prim == NL_ROW) {
+ nlRowColumnZero(&context->af);
+ nlRowColumnZero(&context->al);
+ }
+}
+
+static void nlEnd(NLContext *context, uint32_t prim)
+{
+ if (prim == NL_MATRIX) {
+ nlRowColumnClear(&context->af);
+ nlRowColumnClear(&context->al);
+ } else if (prim == NL_ROW) {
+ NLRowColumn* af = &context->af;
+ NLRowColumn* al = &context->al;
+ NLSparseMatrix* M = (NLSparseMatrix*)context->M;
+ double* b = context->b;
+ uint32_t nf = af->size;
+ uint32_t nl = al->size;
+ uint32_t n = context->n;
+ double S;
+ /*
+ * least_squares : we want to solve
+ * A'A x = A'b
+ */
+ for (uint32_t i = 0; i < nf; i++) {
+ for (uint32_t j = 0; j < nf; j++) {
+ nlSparseMatrixAdd(M, af->coeff[i].index, af->coeff[j].index, af->coeff[i].value * af->coeff[j].value);
+ }
+ }
+ for (uint32_t k = 0; k < context->nb_systems; ++k) {
+ S = 0.0;
+ for (uint32_t jj = 0; jj < nl; ++jj) {
+ uint32_t j = al->coeff[jj].index;
+ S += al->coeff[jj].value * NL_BUFFER_ITEM(context->variable_buffer[k], j);
+ }
+ for (uint32_t jj = 0; jj < nf; jj++)
+ b[k*n + af->coeff[jj].index] -= af->coeff[jj].value * S;
+ }
+ context->current_row++;
+ }
+}
+
+static bool nlSolve(NLContext *context)
+{
+ nlDeleteMatrix(context->P);
+ context->P = nlNewJacobiPreconditioner(context->M);
+ nlMatrixCompress(&context->M);
+ bool result = nlSolveIterative(context);
+ nlVectorToVariables(context);
+ return result;
+}
+} // namespace opennl
+
namespace raster {
-class ClippedTriangle {
+class ClippedTriangle
+{
public:
- ClippedTriangle(const Vector2 &a, const Vector2 &b, const Vector2 &c) {
+ ClippedTriangle(const Vector2 &a, const Vector2 &b, const Vector2 &c)
+ {
m_numVertices = 3;
m_activeVertexBuffer = 0;
m_verticesA[0] = a;
@@ -4077,21 +5191,23 @@ public:
m_verticesA[2] = c;
m_vertexBuffers[0] = m_verticesA;
m_vertexBuffers[1] = m_verticesB;
+ m_area = 0;
}
- void clipHorizontalPlane(float offset, float clipdirection) {
- Vector2 *v = m_vertexBuffers[m_activeVertexBuffer];
+ void clipHorizontalPlane(float offset, float clipdirection)
+ {
+ Vector2 *v = m_vertexBuffers[m_activeVertexBuffer];
m_activeVertexBuffer ^= 1;
Vector2 *v2 = m_vertexBuffers[m_activeVertexBuffer];
v[m_numVertices] = v[0];
- float dy2, dy1 = offset - v[0].y;
- int dy2in, dy1in = clipdirection * dy1 >= 0;
- uint32_t p = 0;
+ float dy2, dy1 = offset - v[0].y;
+ int dy2in, dy1in = clipdirection * dy1 >= 0;
+ uint32_t p = 0;
for (uint32_t k = 0; k < m_numVertices; k++) {
- dy2 = offset - v[k + 1].y;
+ dy2 = offset - v[k + 1].y;
dy2in = clipdirection * dy2 >= 0;
if (dy1in) v2[p++] = v[k];
- if (dy1in + dy2in == 1) { // not both in/out
+ if ( dy1in + dy2in == 1 ) { // not both in/out
float dx = v[k + 1].x - v[k].x;
float dy = v[k + 1].y - v[k].y;
v2[p++] = Vector2(v[k].x + dy1 * (dx / dy), offset);
@@ -4102,19 +5218,20 @@ public:
m_numVertices = p;
}
- void clipVerticalPlane(float offset, float clipdirection) {
- Vector2 *v = m_vertexBuffers[m_activeVertexBuffer];
+ void clipVerticalPlane(float offset, float clipdirection)
+ {
+ Vector2 *v = m_vertexBuffers[m_activeVertexBuffer];
m_activeVertexBuffer ^= 1;
Vector2 *v2 = m_vertexBuffers[m_activeVertexBuffer];
v[m_numVertices] = v[0];
- float dx2, dx1 = offset - v[0].x;
- int dx2in, dx1in = clipdirection * dx1 >= 0;
- uint32_t p = 0;
+ float dx2, dx1 = offset - v[0].x;
+ int dx2in, dx1in = clipdirection * dx1 >= 0;
+ uint32_t p = 0;
for (uint32_t k = 0; k < m_numVertices; k++) {
dx2 = offset - v[k + 1].x;
dx2in = clipdirection * dx2 >= 0;
if (dx1in) v2[p++] = v[k];
- if (dx1in + dx2in == 1) { // not both in/out
+ if ( dx1in + dx2in == 1 ) { // not both in/out
float dx = v[k + 1].x - v[k].x;
float dy = v[k + 1].y - v[k].y;
v2[p++] = Vector2(offset, v[k].y + dx1 * (dy / dx));
@@ -4125,8 +5242,9 @@ public:
m_numVertices = p;
}
- void computeArea() {
- Vector2 *v = m_vertexBuffers[m_activeVertexBuffer];
+ void computeArea()
+ {
+ Vector2 *v = m_vertexBuffers[m_activeVertexBuffer];
v[m_numVertices] = v[0];
m_area = 0;
float centroidx = 0, centroidy = 0;
@@ -4140,7 +5258,8 @@ public:
m_area = 0.5f * fabsf(m_area);
}
- void clipAABox(float x0, float y0, float x1, float y1) {
+ void clipAABox(float x0, float y0, float x1, float y1)
+ {
clipVerticalPlane(x0, -1);
clipHorizontalPlane(y0, -1);
clipVerticalPlane(x1, 1);
@@ -4148,7 +5267,8 @@ public:
computeArea();
}
- float area() const {
+ float area() const
+ {
return m_area;
}
@@ -4165,12 +5285,10 @@ private:
typedef bool (*SamplingCallback)(void *param, int x, int y);
/// A triangle for rasterization.
-struct Triangle {
- Triangle(const Vector2 &v0, const Vector2 &v1, const Vector2 &v2) {
- // Init vertices.
- this->v1 = v0;
- this->v2 = v2;
- this->v3 = v1;
+struct Triangle
+{
+ Triangle(const Vector2 &_v0, const Vector2 &_v1, const Vector2 &_v2) : v1(_v0), v2(_v2), v3(_v1)
+ {
// make sure every triangle is front facing.
flipBackface();
// Compute deltas.
@@ -4178,7 +5296,8 @@ struct Triangle {
computeUnitInwardNormals();
}
- bool isValid() {
+ bool isValid()
+ {
const Vector2 e0 = v3 - v1;
const Vector2 e1 = v2 - v1;
const float area = e0.y * e1.x - e1.y * e0.x;
@@ -4186,17 +5305,18 @@ struct Triangle {
}
// extents has to be multiple of BK_SIZE!!
- bool drawAA(const Vector2 &extents, SamplingCallback cb, void *param) {
- const float PX_INSIDE = 1.0f / sqrtf(2.0f);
- const float PX_OUTSIDE = -1.0f / sqrtf(2.0f);
+ bool drawAA(const Vector2 &extents, SamplingCallback cb, void *param)
+ {
+ const float PX_INSIDE = 1.0f/sqrtf(2.0f);
+ const float PX_OUTSIDE = -1.0f/sqrtf(2.0f);
const float BK_SIZE = 8;
- const float BK_INSIDE = sqrtf(BK_SIZE * BK_SIZE / 2.0f);
- const float BK_OUTSIDE = -sqrtf(BK_SIZE * BK_SIZE / 2.0f);
+ const float BK_INSIDE = sqrtf(BK_SIZE*BK_SIZE/2.0f);
+ const float BK_OUTSIDE = -sqrtf(BK_SIZE*BK_SIZE/2.0f);
// Bounding rectangle
float minx = floorf(max(min3(v1.x, v2.x, v3.x), 0.0f));
float miny = floorf(max(min3(v1.y, v2.y, v3.y), 0.0f));
- float maxx = ceilf(min(max3(v1.x, v2.x, v3.x), extents.x - 1.0f));
- float maxy = ceilf(min(max3(v1.y, v2.y, v3.y), extents.y - 1.0f));
+ float maxx = ceilf( min(max3(v1.x, v2.x, v3.x), extents.x - 1.0f));
+ float maxy = ceilf( min(max3(v1.y, v2.y, v3.y), extents.y - 1.0f));
// There's no reason to align the blocks to the viewport, instead we align them to the origin of the triangle bounds.
minx = floorf(minx);
miny = floorf(miny);
@@ -4221,9 +5341,9 @@ struct Triangle {
float bC = C2 + n2.x * xc + n2.y * yc;
float cC = C3 + n3.x * xc + n3.y * yc;
// Skip block when outside an edge
- if ((aC <= BK_OUTSIDE) || (bC <= BK_OUTSIDE) || (cC <= BK_OUTSIDE)) continue;
+ if ( (aC <= BK_OUTSIDE) || (bC <= BK_OUTSIDE) || (cC <= BK_OUTSIDE) ) continue;
// Accept whole block when totally covered
- if ((aC >= BK_INSIDE) && (bC >= BK_INSIDE) && (cC >= BK_INSIDE)) {
+ if ( (aC >= BK_INSIDE) && (bC >= BK_INSIDE) && (cC >= BK_INSIDE) ) {
for (float y = y0; y < y0 + BK_SIZE; y++) {
for (float x = x0; x < x0 + BK_SIZE; x++) {
if (!cb(param, (int)x, (int)y))
@@ -4266,9 +5386,10 @@ struct Triangle {
}
private:
- void flipBackface() {
+ void flipBackface()
+ {
// check if triangle is backfacing, if so, swap two vertices
- if (((v3.x - v1.x) * (v2.y - v1.y) - (v3.y - v1.y) * (v2.x - v1.x)) < 0) {
+ if ( ((v3.x - v1.x) * (v2.y - v1.y) - (v3.y - v1.y) * (v2.x - v1.x)) < 0 ) {
Vector2 hv = v1;
v1 = v2;
v2 = hv; // swap pos
@@ -4276,7 +5397,8 @@ private:
}
// compute unit inward normals for each edge.
- void computeUnitInwardNormals() {
+ void computeUnitInwardNormals()
+ {
n1 = v1 - v2;
n1 = Vector2(-n1.y, n1.x);
n1 = n1 * (1.0f / sqrtf(dot(n1, n1)));
@@ -4294,7 +5416,8 @@ private:
};
// Process the given triangle. Returns false if rasterization was interrupted by the callback.
-static bool drawTriangle(const Vector2 &extents, const Vector2 v[3], SamplingCallback cb, void *param) {
+static bool drawTriangle(const Vector2 &extents, const Vector2 v[3], SamplingCallback cb, void *param)
+{
Triangle tri(v[0], v[1], v[2]);
// @@ It would be nice to have a conservative drawing mode that enlarges the triangle extents by one texel and is able to handle degenerate triangles.
// @@ Maybe the simplest thing to do would be raster triangle edges.
@@ -4305,251 +5428,26 @@ static bool drawTriangle(const Vector2 &extents, const Vector2 v[3], SamplingCal
} // namespace raster
-// Full and sparse vector and matrix classes. BLAS subset.
-// Pseudo-BLAS interface.
-namespace sparse {
-
-/**
-* Sparse matrix class. The matrix is assumed to be sparse and to have
-* very few non-zero elements, for this reason it's stored in indexed
-* format. To multiply column vectors efficiently, the matrix stores
-* the elements in indexed-column order, there is a list of indexed
-* elements for each row of the matrix. As with the FullVector the
-* dimension of the matrix is constant.
-**/
-class Matrix {
-public:
- // An element of the sparse array.
- struct Coefficient {
- uint32_t x; // column
- float v; // value
- };
-
- Matrix(uint32_t d) :
- m_width(d), m_array(MemTag::Matrix) {
- m_array.resize(d);
- m_array.runCtors();
-#if XA_DEBUG_HEAP
- for (uint32_t i = 0; i < d; i++)
- m_array[i].setMemTag(MemTag::Matrix);
-#endif
- }
-
- Matrix(uint32_t w, uint32_t h) :
- m_width(w), m_array(MemTag::Matrix) {
- m_array.resize(h);
- m_array.runCtors();
-#if XA_DEBUG_HEAP
- for (uint32_t i = 0; i < h; i++)
- m_array[i].setMemTag(MemTag::Matrix);
-#endif
- }
-
- ~Matrix() {
- m_array.runDtors();
- }
-
- Matrix(const Matrix &m) = delete;
- Matrix &operator=(const Matrix &m) = delete;
- uint32_t width() const { return m_width; }
- uint32_t height() const { return m_array.size(); }
- bool isSquare() const { return width() == height(); }
-
- // x is column, y is row
- float getCoefficient(uint32_t x, uint32_t y) const {
- XA_DEBUG_ASSERT(x < width());
- XA_DEBUG_ASSERT(y < height());
- const uint32_t count = m_array[y].size();
- for (uint32_t i = 0; i < count; i++) {
- if (m_array[y][i].x == x) return m_array[y][i].v;
- }
- return 0.0f;
- }
-
- void setCoefficient(uint32_t x, uint32_t y, float f) {
- XA_DEBUG_ASSERT(x < width());
- XA_DEBUG_ASSERT(y < height());
- const uint32_t count = m_array[y].size();
- for (uint32_t i = 0; i < count; i++) {
- if (m_array[y][i].x == x) {
- m_array[y][i].v = f;
- return;
- }
- }
- if (f != 0.0f) {
- Coefficient c = { x, f };
- m_array[y].push_back(c);
- }
- }
-
- float dotRow(uint32_t y, const FullVector &v) const {
- XA_DEBUG_ASSERT(y < height());
- const uint32_t count = m_array[y].size();
- float sum = 0;
- for (uint32_t i = 0; i < count; i++) {
- sum += m_array[y][i].v * v[m_array[y][i].x];
- }
- return sum;
- }
-
- void madRow(uint32_t y, float alpha, FullVector &v) const {
- XA_DEBUG_ASSERT(y < height());
- const uint32_t count = m_array[y].size();
- for (uint32_t i = 0; i < count; i++) {
- v[m_array[y][i].x] += alpha * m_array[y][i].v;
- }
- }
-
- void clearRow(uint32_t y) {
- XA_DEBUG_ASSERT(y < height());
- m_array[y].clear();
- }
-
- const Array<Coefficient> &getRow(uint32_t y) const { return m_array[y]; }
-
-private:
- /// Number of columns.
- const uint32_t m_width;
-
- /// Array of matrix elements.
- Array<Array<Coefficient>> m_array;
-};
-
-// y = a * x + y
-static void saxpy(float a, const FullVector &x, FullVector &y) {
- XA_DEBUG_ASSERT(x.dimension() == y.dimension());
- const uint32_t dim = x.dimension();
- for (uint32_t i = 0; i < dim; i++) {
- y[i] += a * x[i];
- }
-}
-
-static void copy(const FullVector &x, FullVector &y) {
- XA_DEBUG_ASSERT(x.dimension() == y.dimension());
- const uint32_t dim = x.dimension();
- for (uint32_t i = 0; i < dim; i++) {
- y[i] = x[i];
- }
-}
-
-static void scal(float a, FullVector &x) {
- const uint32_t dim = x.dimension();
- for (uint32_t i = 0; i < dim; i++) {
- x[i] *= a;
- }
-}
-
-static float dot(const FullVector &x, const FullVector &y) {
- XA_DEBUG_ASSERT(x.dimension() == y.dimension());
- const uint32_t dim = x.dimension();
- float sum = 0;
- for (uint32_t i = 0; i < dim; i++) {
- sum += x[i] * y[i];
- }
- return sum;
-}
-
-// y = M * x
-static void mult(const Matrix &M, const FullVector &x, FullVector &y) {
- uint32_t w = M.width();
- uint32_t h = M.height();
- XA_DEBUG_ASSERT(w == x.dimension());
- XA_UNUSED(w);
- XA_DEBUG_ASSERT(h == y.dimension());
- for (uint32_t i = 0; i < h; i++)
- y[i] = M.dotRow(i, x);
-}
-
-// y = alpha*A*x + beta*y
-static void sgemv(float alpha, const Matrix &A, const FullVector &x, float beta, FullVector &y) {
- const uint32_t w = A.width();
- const uint32_t h = A.height();
- XA_DEBUG_ASSERT(w == x.dimension());
- XA_DEBUG_ASSERT(h == y.dimension());
- XA_UNUSED(w);
- XA_UNUSED(h);
- for (uint32_t i = 0; i < h; i++)
- y[i] = alpha * A.dotRow(i, x) + beta * y[i];
-}
-
-// dot y-row of A by x-column of B
-static float dotRowColumn(int y, const Matrix &A, int x, const Matrix &B) {
- const Array<Matrix::Coefficient> &row = A.getRow(y);
- const uint32_t count = row.size();
- float sum = 0.0f;
- for (uint32_t i = 0; i < count; i++) {
- const Matrix::Coefficient &c = row[i];
- sum += c.v * B.getCoefficient(x, c.x);
- }
- return sum;
-}
-
-static void transpose(const Matrix &A, Matrix &B) {
- XA_DEBUG_ASSERT(A.width() == B.height());
- XA_DEBUG_ASSERT(B.width() == A.height());
- const uint32_t w = A.width();
- for (uint32_t x = 0; x < w; x++) {
- B.clearRow(x);
- }
- const uint32_t h = A.height();
- for (uint32_t y = 0; y < h; y++) {
- const Array<Matrix::Coefficient> &row = A.getRow(y);
- const uint32_t count = row.size();
- for (uint32_t i = 0; i < count; i++) {
- const Matrix::Coefficient &c = row[i];
- XA_DEBUG_ASSERT(c.x < w);
- B.setCoefficient(y, c.x, c.v);
- }
- }
-}
-
-static void sgemm(float alpha, const Matrix &A, const Matrix &B, float beta, Matrix &C) {
- const uint32_t w = C.width();
- const uint32_t h = C.height();
-#if XA_DEBUG
- const uint32_t aw = A.width();
- const uint32_t ah = A.height();
- const uint32_t bw = B.width();
- const uint32_t bh = B.height();
- XA_DEBUG_ASSERT(aw == bh);
- XA_DEBUG_ASSERT(bw == ah);
- XA_DEBUG_ASSERT(w == bw);
- XA_DEBUG_ASSERT(h == ah);
-#endif
- for (uint32_t y = 0; y < h; y++) {
- for (uint32_t x = 0; x < w; x++) {
- float c = beta * C.getCoefficient(x, y);
- // dot y-row of A by x-column of B.
- c += alpha * dotRowColumn(y, A, x, B);
- C.setCoefficient(x, y, c);
- }
- }
-}
-
-// C = A * B
-static void mult(const Matrix &A, const Matrix &B, Matrix &C) {
- sgemm(1.0f, A, B, 0.0f, C);
-}
-
-} // namespace sparse
-
namespace segment {
// - Insertion is o(n)
// - Smallest element goes at the end, so that popping it is o(1).
-struct CostQueue {
- CostQueue(uint32_t size = UINT32_MAX) :
- m_maxSize(size), m_pairs(MemTag::SegmentAtlasChartCandidates) {}
+struct CostQueue
+{
+ CostQueue(uint32_t size = UINT32_MAX) : m_maxSize(size), m_pairs(MemTag::SegmentAtlasChartCandidates) {}
- float peekCost() const {
+ float peekCost() const
+ {
return m_pairs.back().cost;
}
- uint32_t peekFace() const {
+ uint32_t peekFace() const
+ {
return m_pairs.back().face;
}
- void push(float cost, uint32_t face) {
+ void push(float cost, uint32_t face)
+ {
const Pair p = { cost, face };
if (m_pairs.isEmpty() || cost < peekCost())
m_pairs.push_back(p);
@@ -4566,25 +5464,29 @@ struct CostQueue {
}
}
- uint32_t pop() {
+ uint32_t pop()
+ {
XA_DEBUG_ASSERT(!m_pairs.isEmpty());
uint32_t f = m_pairs.back().face;
m_pairs.pop_back();
return f;
}
- XA_INLINE void clear() {
+ XA_INLINE void clear()
+ {
m_pairs.clear();
}
- XA_INLINE uint32_t count() const {
+ XA_INLINE uint32_t count() const
+ {
return m_pairs.size();
}
private:
const uint32_t m_maxSize;
- struct Pair {
+ struct Pair
+ {
float cost;
uint32_t face;
};
@@ -4592,86 +5494,92 @@ private:
Array<Pair> m_pairs;
};
-struct Chart {
- Chart() :
- faces(MemTag::SegmentAtlasChartFaces) {}
-
- int id = -1;
- Basis basis; // Best fit normal.
- float area = 0.0f;
- float boundaryLength = 0.0f;
- Vector3 centroidSum = Vector3(0.0f); // Sum of chart face centroids.
- Vector3 centroid = Vector3(0.0f); // Average centroid of chart faces.
- Array<uint32_t> seeds;
- Array<uint32_t> faces;
- Array<uint32_t> failedPlanarRegions;
- CostQueue candidates;
-};
-
-struct Atlas {
- Atlas() :
- m_edgeLengths(MemTag::SegmentAtlasMeshData), m_faceAreas(MemTag::SegmentAtlasMeshData), m_faceNormals(MemTag::SegmentAtlasMeshData), m_texcoords(MemTag::SegmentAtlasMeshData), m_bestTriangles(10), m_nextPlanarRegionFace(MemTag::SegmentAtlasPlanarRegions), m_facePlanarRegionId(MemTag::SegmentAtlasPlanarRegions) {}
-
- ~Atlas() {
- const uint32_t chartCount = m_charts.size();
- for (uint32_t i = 0; i < chartCount; i++) {
- m_charts[i]->~Chart();
- XA_FREE(m_charts[i]);
- }
- }
+struct AtlasData
+{
+ ChartOptions options;
+ const Mesh *mesh = nullptr;
+ Array<float> edgeDihedralAngles;
+ Array<float> edgeLengths;
+ Array<float> faceAreas;
+ Array<Vector3> faceNormals;
+ BitArray isFaceInChart;
- uint32_t facesLeft() const { return m_facesLeft; }
- uint32_t chartCount() const { return m_charts.size(); }
- const Array<uint32_t> &chartFaces(uint32_t i) const { return m_charts[i]->faces; }
- const Basis &chartBasis(uint32_t chartIndex) const { return m_charts[chartIndex]->basis; }
+ AtlasData() : edgeDihedralAngles(MemTag::SegmentAtlasMeshData), edgeLengths(MemTag::SegmentAtlasMeshData), faceAreas(MemTag::SegmentAtlasMeshData), faceNormals(MemTag::SegmentAtlasMeshData) {}
- void reset(uint32_t meshId, uint32_t chartGroupId, const Mesh *mesh, const ChartOptions &options) {
- XA_UNUSED(meshId);
- XA_UNUSED(chartGroupId);
- XA_PROFILE_START(buildAtlasInit)
- m_mesh = mesh;
- const uint32_t faceCount = m_mesh->faceCount();
- m_facesLeft = faceCount;
- m_options = options;
- m_rand.reset();
- const uint32_t chartCount = m_charts.size();
- for (uint32_t i = 0; i < chartCount; i++) {
- m_charts[i]->~Chart();
- XA_FREE(m_charts[i]);
- }
- m_charts.clear();
- m_faceCharts.resize(faceCount);
- m_faceCharts.setAll(-1);
- m_texcoords.resize(faceCount * 3);
- // Precompute edge lengths and face areas.
- const uint32_t edgeCount = m_mesh->edgeCount();
- m_edgeLengths.resize(edgeCount);
- m_faceAreas.resize(faceCount);
- m_faceNormals.resize(faceCount);
+ void compute()
+ {
+ const uint32_t faceCount = mesh->faceCount();
+ const uint32_t edgeCount = mesh->edgeCount();
+ edgeDihedralAngles.resize(edgeCount);
+ edgeLengths.resize(edgeCount);
+ faceAreas.resize(faceCount);
+ faceNormals.resize(faceCount);
+ isFaceInChart.resize(faceCount);
+ isFaceInChart.zeroOutMemory();
for (uint32_t f = 0; f < faceCount; f++) {
for (uint32_t i = 0; i < 3; i++) {
const uint32_t edge = f * 3 + i;
- const Vector3 &p0 = mesh->position(m_mesh->vertexAt(meshEdgeIndex0(edge)));
- const Vector3 &p1 = mesh->position(m_mesh->vertexAt(meshEdgeIndex1(edge)));
- m_edgeLengths[edge] = length(p1 - p0);
- XA_DEBUG_ASSERT(m_edgeLengths[edge] > 0.0f);
+ const Vector3 &p0 = mesh->position(mesh->vertexAt(meshEdgeIndex0(edge)));
+ const Vector3 &p1 = mesh->position(mesh->vertexAt(meshEdgeIndex1(edge)));
+ edgeLengths[edge] = length(p1 - p0);
+ XA_DEBUG_ASSERT(edgeLengths[edge] > 0.0f);
+ }
+ faceAreas[f] = mesh->computeFaceArea(f);
+ XA_DEBUG_ASSERT(faceAreas[f] > 0.0f);
+ faceNormals[f] = mesh->computeFaceNormal(f);
+ }
+ for (uint32_t face = 0; face < faceCount; face++) {
+ for (uint32_t i = 0; i < 3; i++) {
+ const uint32_t edge = face * 3 + i;
+ const uint32_t oedge = mesh->oppositeEdge(edge);
+ if (oedge == UINT32_MAX)
+ edgeDihedralAngles[edge] = FLT_MAX;
+ else {
+ const uint32_t oface = meshEdgeFace(oedge);
+ edgeDihedralAngles[edge] = edgeDihedralAngles[oedge] = dot(faceNormals[face], faceNormals[oface]);
+ }
}
- m_faceAreas[f] = m_mesh->computeFaceArea(f);
- XA_DEBUG_ASSERT(m_faceAreas[f] > 0.0f);
- m_faceNormals[f] = m_mesh->computeFaceNormal(f);
}
+ }
+};
+
+#if XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS
+static uint32_t s_planarRegionsCurrentRegion;
+static uint32_t s_planarRegionsCurrentVertex;
+#endif
+
+struct PlanarCharts
+{
+ PlanarCharts(AtlasData &data) : m_data(data), m_nextRegionFace(MemTag::SegmentAtlasPlanarRegions), m_faceToRegionId(MemTag::SegmentAtlasPlanarRegions) {}
+ const Basis &chartBasis(uint32_t chartIndex) const { return m_chartBasis[chartIndex]; }
+ uint32_t chartCount() const { return m_charts.size(); }
+
+ ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const
+ {
+ const Chart &chart = m_charts[chartIndex];
+ return ConstArrayView<uint32_t>(&m_chartFaces[chart.firstFace], chart.faceCount);
+ }
+
+ uint32_t regionIdFromFace(uint32_t face) const { return m_faceToRegionId[face]; }
+ uint32_t nextRegionFace(uint32_t face) const { return m_nextRegionFace[face]; }
+ float regionArea(uint32_t region) const { return m_regionAreas[region]; }
+
+ void compute()
+ {
+ const uint32_t faceCount = m_data.mesh->faceCount();
// Precompute regions of coplanar incident faces.
- m_nextPlanarRegionFace.resize(faceCount);
- m_facePlanarRegionId.resize(faceCount);
+ m_regionFirstFace.clear();
+ m_nextRegionFace.resize(faceCount);
+ m_faceToRegionId.resize(faceCount);
for (uint32_t f = 0; f < faceCount; f++) {
- m_nextPlanarRegionFace[f] = f;
- m_facePlanarRegionId[f] = UINT32_MAX;
+ m_nextRegionFace[f] = f;
+ m_faceToRegionId[f] = UINT32_MAX;
}
Array<uint32_t> faceStack;
faceStack.reserve(min(faceCount, 16u));
- uint32_t planarRegionCount = 0;
+ uint32_t regionCount = 0;
for (uint32_t f = 0; f < faceCount; f++) {
- if (m_nextPlanarRegionFace[f] != f)
+ if (m_nextRegionFace[f] != f)
continue; // Already assigned.
faceStack.clear();
faceStack.push_back(f);
@@ -4679,48 +5587,207 @@ struct Atlas {
if (faceStack.isEmpty())
break;
const uint32_t face = faceStack.back();
- m_facePlanarRegionId[face] = planarRegionCount;
+ m_faceToRegionId[face] = regionCount;
faceStack.pop_back();
- for (Mesh::FaceEdgeIterator it(m_mesh, face); !it.isDone(); it.advance()) {
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, face); !it.isDone(); it.advance()) {
const uint32_t oface = it.oppositeFace();
if (it.isBoundary())
continue;
- if (m_nextPlanarRegionFace[oface] != oface)
+ if (m_nextRegionFace[oface] != oface)
continue; // Already assigned.
- if (!equal(dot(m_faceNormals[face], m_faceNormals[oface]), 1.0f, kEpsilon))
+ if (!equal(dot(m_data.faceNormals[face], m_data.faceNormals[oface]), 1.0f, kEpsilon))
continue; // Not coplanar.
- const uint32_t next = m_nextPlanarRegionFace[face];
- m_nextPlanarRegionFace[face] = oface;
- m_nextPlanarRegionFace[oface] = next;
- m_facePlanarRegionId[oface] = planarRegionCount;
+ const uint32_t next = m_nextRegionFace[face];
+ m_nextRegionFace[face] = oface;
+ m_nextRegionFace[oface] = next;
+ m_faceToRegionId[oface] = regionCount;
faceStack.push_back(oface);
}
}
- planarRegionCount++;
+ m_regionFirstFace.push_back(f);
+ regionCount++;
}
#if XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS
- char filename[256];
- XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_planar_regions.obj", meshId, chartGroupId);
- FILE *file;
- XA_FOPEN(file, filename, "w");
- if (file) {
- m_mesh->writeObjVertices(file);
- fprintf(file, "s off\n");
- for (uint32_t i = 0; i < planarRegionCount; i++) {
- fprintf(file, "o region%u\n", i);
- for (uint32_t j = 0; j < faceCount; j++) {
- if (m_facePlanarRegionId[j] == i)
- m_mesh->writeObjFace(file, j);
+ static std::mutex s_mutex;
+ {
+ std::lock_guard<std::mutex> lock(s_mutex);
+ FILE *file;
+ XA_FOPEN(file, "debug_mesh_planar_regions.obj", s_planarRegionsCurrentRegion == 0 ? "w" : "a");
+ if (file) {
+ m_data.mesh->writeObjVertices(file);
+ fprintf(file, "s off\n");
+ for (uint32_t i = 0; i < regionCount; i++) {
+ fprintf(file, "o region%u\n", s_planarRegionsCurrentRegion);
+ for (uint32_t j = 0; j < faceCount; j++) {
+ if (m_faceToRegionId[j] == i)
+ m_data.mesh->writeObjFace(file, j, s_planarRegionsCurrentVertex);
+ }
+ s_planarRegionsCurrentRegion++;
}
+ s_planarRegionsCurrentVertex += m_data.mesh->vertexCount();
+ fclose(file);
}
- fclose(file);
}
#endif
- XA_PROFILE_END(buildAtlasInit)
+ // Precompute planar region areas.
+ m_regionAreas.resize(regionCount);
+ m_regionAreas.zeroOutMemory();
+ for (uint32_t f = 0; f < faceCount; f++)
+ m_regionAreas[m_faceToRegionId[f]] += m_data.faceAreas[f];
+ // Create charts from suitable planar regions.
+ // The dihedral angle of all boundary edges must be >= 90 degrees.
+ m_charts.clear();
+ m_chartFaces.clear();
+ for (uint32_t region = 0; region < regionCount; region++) {
+ const uint32_t firstRegionFace = m_regionFirstFace[region];
+ uint32_t face = firstRegionFace;
+ bool createChart = true;
+ do {
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, face); !it.isDone(); it.advance()) {
+ if (it.isBoundary())
+ continue; // Ignore mesh boundary edges.
+ const uint32_t oface = it.oppositeFace();
+ if (m_faceToRegionId[oface] == region)
+ continue; // Ignore internal edges.
+ const float angle = m_data.edgeDihedralAngles[it.edge()];
+ if (angle > 0.0f && angle < FLT_MAX) { // FLT_MAX on boundaries.
+ createChart = false;
+ break;
+ }
+ }
+ if (!createChart)
+ break;
+ face = m_nextRegionFace[face];
+ }
+ while (face != firstRegionFace);
+ // Create a chart.
+ if (createChart) {
+ Chart chart;
+ chart.firstFace = m_chartFaces.size();
+ chart.faceCount = 0;
+ face = firstRegionFace;
+ do {
+ m_data.isFaceInChart.set(face);
+ m_chartFaces.push_back(face);
+ chart.faceCount++;
+ face = m_nextRegionFace[face];
+ }
+ while (face != firstRegionFace);
+ m_charts.push_back(chart);
+ }
+ }
+ // Compute basis for each chart using the first face normal (all faces have the same normal).
+ m_chartBasis.resize(m_charts.size());
+ for (uint32_t c = 0; c < m_charts.size(); c++)
+ {
+ const uint32_t face = m_chartFaces[m_charts[c].firstFace];
+ Basis &basis = m_chartBasis[c];
+ basis.normal = m_data.faceNormals[face];
+ basis.tangent = Basis::computeTangent(basis.normal);
+ basis.bitangent = Basis::computeBitangent(basis.normal, basis.tangent);
+ }
+ }
+
+private:
+ struct Chart
+ {
+ uint32_t firstFace, faceCount;
+ };
+
+ AtlasData &m_data;
+ Array<uint32_t> m_regionFirstFace;
+ Array<uint32_t> m_nextRegionFace;
+ Array<uint32_t> m_faceToRegionId;
+ Array<float> m_regionAreas;
+ Array<Chart> m_charts;
+ Array<uint32_t> m_chartFaces;
+ Array<Basis> m_chartBasis;
+};
+
+struct ClusteredCharts
+{
+ ClusteredCharts(AtlasData &data, const PlanarCharts &planarCharts) : m_data(data), m_planarCharts(planarCharts), m_texcoords(MemTag::SegmentAtlasMeshData), m_bestTriangles(10), m_placingSeeds(false) {}
+
+ ~ClusteredCharts()
+ {
+ const uint32_t chartCount = m_charts.size();
+ for (uint32_t i = 0; i < chartCount; i++) {
+ m_charts[i]->~Chart();
+ XA_FREE(m_charts[i]);
+ }
}
- void placeSeeds(float threshold) {
- XA_PROFILE_START(buildAtlasPlaceSeeds)
+ uint32_t chartCount() const { return m_charts.size(); }
+ ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const { return m_charts[chartIndex]->faces; }
+ const Basis &chartBasis(uint32_t chartIndex) const { return m_charts[chartIndex]->basis; }
+
+ void compute()
+ {
+ const uint32_t faceCount = m_data.mesh->faceCount();
+ m_facesLeft = 0;
+ for (uint32_t i = 0; i < faceCount; i++) {
+ if (!m_data.isFaceInChart.get(i))
+ m_facesLeft++;
+ }
+ const uint32_t chartCount = m_charts.size();
+ for (uint32_t i = 0; i < chartCount; i++) {
+ m_charts[i]->~Chart();
+ XA_FREE(m_charts[i]);
+ }
+ m_charts.clear();
+ m_faceCharts.resize(faceCount);
+ m_faceCharts.fill(-1);
+ m_texcoords.resize(faceCount * 3);
+ if (m_facesLeft == 0)
+ return;
+ // Create initial charts greedely.
+ placeSeeds(m_data.options.maxCost * 0.5f);
+ if (m_data.options.maxIterations == 0) {
+ XA_DEBUG_ASSERT(m_facesLeft == 0);
+ return;
+ }
+ relocateSeeds();
+ resetCharts();
+ // Restart process growing charts in parallel.
+ uint32_t iteration = 0;
+ for (;;) {
+ growCharts(m_data.options.maxCost);
+ // When charts cannot grow more: fill holes, merge charts, relocate seeds and start new iteration.
+ fillHoles(m_data.options.maxCost * 0.5f);
+#if XA_MERGE_CHARTS
+ mergeCharts();
+#endif
+ if (++iteration == m_data.options.maxIterations)
+ break;
+ if (!relocateSeeds())
+ break;
+ resetCharts();
+ }
+ // Make sure no holes are left!
+ XA_DEBUG_ASSERT(m_facesLeft == 0);
+ }
+
+private:
+ struct Chart
+ {
+ Chart() : faces(MemTag::SegmentAtlasChartFaces) {}
+
+ int id = -1;
+ Basis basis; // Best fit normal.
+ float area = 0.0f;
+ float boundaryLength = 0.0f;
+ Vector3 centroidSum = Vector3(0.0f); // Sum of chart face centroids.
+ Vector3 centroid = Vector3(0.0f); // Average centroid of chart faces.
+ Array<uint32_t> faces;
+ Array<uint32_t> failedPlanarRegions;
+ CostQueue candidates;
+ uint32_t seed;
+ };
+
+ void placeSeeds(float threshold)
+ {
+ XA_PROFILE_START(clusteredChartsPlaceSeeds)
+ m_placingSeeds = true;
// Instead of using a predefiened number of seeds:
// - Add seeds one by one, growing chart until a certain treshold.
// - Undo charts and restart growing process.
@@ -4728,13 +5795,15 @@ struct Atlas {
// - those points can be found using a simple flood filling algorithm.
// - how do we weight the probabilities?
while (m_facesLeft > 0)
- createRandomChart(threshold);
- XA_PROFILE_END(buildAtlasPlaceSeeds)
+ createChart(threshold);
+ m_placingSeeds = false;
+ XA_PROFILE_END(clusteredChartsPlaceSeeds)
}
// Returns true if any of the charts can grow more.
- void growCharts(float threshold) {
- XA_PROFILE_START(buildAtlasGrowCharts)
+ void growCharts(float threshold)
+ {
+ XA_PROFILE_START(clusteredChartsGrow)
for (;;) {
if (m_facesLeft == 0)
break;
@@ -4752,7 +5821,7 @@ struct Atlas {
break;
cost = chart->candidates.peekCost();
face = chart->candidates.peekFace();
- if (m_faceCharts[face] == -1)
+ if (!m_data.isFaceInChart.get(face))
break;
else {
// Face belongs to another chart. Pop from queue so the next best candidate can be retrieved.
@@ -4774,21 +5843,28 @@ struct Atlas {
Chart *chart = m_charts[bestChart];
chart->candidates.pop(); // Pop the selected candidate from the queue.
if (!addFaceToChart(chart, bestFace))
- chart->failedPlanarRegions.push_back(m_facePlanarRegionId[bestFace]);
+ chart->failedPlanarRegions.push_back(m_planarCharts.regionIdFromFace(bestFace));
}
- XA_PROFILE_END(buildAtlasGrowCharts)
+ XA_PROFILE_END(clusteredChartsGrow)
}
- void resetCharts() {
- XA_PROFILE_START(buildAtlasResetCharts)
- const uint32_t faceCount = m_mesh->faceCount();
- for (uint32_t i = 0; i < faceCount; i++)
+ void resetCharts()
+ {
+ XA_PROFILE_START(clusteredChartsReset)
+ const uint32_t faceCount = m_data.mesh->faceCount();
+ for (uint32_t i = 0; i < faceCount; i++) {
+ if (m_faceCharts[i] != -1)
+ m_data.isFaceInChart.unset(i);
m_faceCharts[i] = -1;
- m_facesLeft = faceCount;
+ }
+ m_facesLeft = 0;
+ for (uint32_t i = 0; i < faceCount; i++) {
+ if (!m_data.isFaceInChart.get(i))
+ m_facesLeft++;
+ }
const uint32_t chartCount = m_charts.size();
for (uint32_t i = 0; i < chartCount; i++) {
Chart *chart = m_charts[i];
- const uint32_t seed = chart->seeds.back();
chart->area = 0.0f;
chart->boundaryLength = 0.0f;
chart->basis.normal = Vector3(0.0f);
@@ -4799,13 +5875,14 @@ struct Atlas {
chart->faces.clear();
chart->candidates.clear();
chart->failedPlanarRegions.clear();
- addFaceToChart(chart, seed);
+ addFaceToChart(chart, chart->seed);
}
- XA_PROFILE_END(buildAtlasResetCharts)
+ XA_PROFILE_END(clusteredChartsReset)
}
- bool relocateSeeds() {
- XA_PROFILE_START(buildAtlasRelocateSeeds)
+ bool relocateSeeds()
+ {
+ XA_PROFILE_START(clusteredChartsRelocateSeeds)
bool anySeedChanged = false;
const uint32_t chartCount = m_charts.size();
for (uint32_t i = 0; i < chartCount; i++) {
@@ -4813,20 +5890,22 @@ struct Atlas {
anySeedChanged = true;
}
}
- XA_PROFILE_END(buildAtlasRelocateSeeds)
+ XA_PROFILE_END(clusteredChartsRelocateSeeds)
return anySeedChanged;
}
- void fillHoles(float threshold) {
- XA_PROFILE_START(buildAtlasFillHoles)
+ void fillHoles(float threshold)
+ {
+ XA_PROFILE_START(clusteredChartsFillHoles)
while (m_facesLeft > 0)
- createRandomChart(threshold);
- XA_PROFILE_END(buildAtlasFillHoles)
+ createChart(threshold);
+ XA_PROFILE_END(clusteredChartsFillHoles)
}
#if XA_MERGE_CHARTS
- void mergeCharts() {
- XA_PROFILE_START(buildAtlasMergeCharts)
+ void mergeCharts()
+ {
+ XA_PROFILE_START(clusteredChartsMerge)
const uint32_t chartCount = m_charts.size();
// Merge charts progressively until there's none left to merge.
for (;;) {
@@ -4845,13 +5924,15 @@ struct Atlas {
const uint32_t faceCount = chart->faces.size();
for (uint32_t i = 0; i < faceCount; i++) {
const uint32_t f = chart->faces[i];
- for (Mesh::FaceEdgeIterator it(m_mesh, f); !it.isDone(); it.advance()) {
- const float l = m_edgeLengths[it.edge()];
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, f); !it.isDone(); it.advance()) {
+ const float l = m_data.edgeLengths[it.edge()];
if (it.isBoundary()) {
externalBoundaryLength += l;
} else {
const int neighborChart = m_faceCharts[it.oppositeFace()];
- if (m_charts[neighborChart] != chart) {
+ if (neighborChart == -1)
+ externalBoundaryLength += l;
+ else if (m_charts[neighborChart] != chart) {
if ((it.isSeam() && (isNormalSeam(it.edge()) || it.isTextureSeam()))) {
externalBoundaryLength += l;
} else {
@@ -4876,14 +5957,14 @@ struct Atlas {
if (dot(chart2->basis.normal, chart->basis.normal) < XA_MERGE_CHARTS_MIN_NORMAL_DEVIATION)
continue;
// Obey max chart area and boundary length.
- if (m_options.maxChartArea > 0.0f && chart->area + chart2->area > m_options.maxChartArea)
+ if (m_data.options.maxChartArea > 0.0f && chart->area + chart2->area > m_data.options.maxChartArea)
continue;
- if (m_options.maxBoundaryLength > 0.0f && chart->boundaryLength + chart2->boundaryLength - m_sharedBoundaryLengthsNoSeams[cc] > m_options.maxBoundaryLength)
+ if (m_data.options.maxBoundaryLength > 0.0f && chart->boundaryLength + chart2->boundaryLength - m_sharedBoundaryLengthsNoSeams[cc] > m_data.options.maxBoundaryLength)
continue;
// Merge if chart2 has a single face.
// chart1 must have more than 1 face.
// chart2 area must be <= 10% of chart1 area.
- if (m_sharedBoundaryLengthsNoSeams[cc] > 0.0f && chart->faces.size() > 1 && chart2->faces.size() == 1 && chart2->area <= chart->area * 0.1f)
+ if (m_sharedBoundaryLengthsNoSeams[cc] > 0.0f && chart->faces.size() > 1 && chart2->faces.size() == 1 && chart2->area <= chart->area * 0.1f)
goto merge;
// Merge if chart2 has two faces (probably a quad), and chart1 bounds at least 2 of its edges.
if (chart2->faces.size() == 2 && m_sharedBoundaryEdgeCountNoSeams[cc] >= 2)
@@ -4891,8 +5972,8 @@ struct Atlas {
// Merge if chart2 is wholely inside chart1, ignoring seams.
if (m_sharedBoundaryLengthsNoSeams[cc] > 0.0f && equal(m_sharedBoundaryLengthsNoSeams[cc], chart2->boundaryLength, kEpsilon))
goto merge;
- if (m_sharedBoundaryLengths[cc] > 0.2f * max(0.0f, chart->boundaryLength - externalBoundaryLength) ||
- m_sharedBoundaryLengths[cc] > 0.75f * chart2->boundaryLength)
+ if (m_sharedBoundaryLengths[cc] > 0.2f * max(0.0f, chart->boundaryLength - externalBoundaryLength) ||
+ m_sharedBoundaryLengths[cc] > 0.75f * chart2->boundaryLength)
goto merge;
continue;
merge:
@@ -4925,55 +6006,64 @@ struct Atlas {
c++;
}
}
- XA_PROFILE_END(buildAtlasMergeCharts)
+ XA_PROFILE_END(clusteredChartsMerge)
}
#endif
private:
- void createRandomChart(float threshold) {
+ void createChart(float threshold)
+ {
Chart *chart = XA_NEW(MemTag::Default, Chart);
chart->id = (int)m_charts.size();
m_charts.push_back(chart);
- // Pick random face that is not used by any chart yet.
- uint32_t face = m_rand.getRange(m_mesh->faceCount() - 1);
- while (m_faceCharts[face] != -1) {
- if (++face >= m_mesh->faceCount())
- face = 0;
- }
- chart->seeds.push_back(face);
- addFaceToChart(chart, face);
+ // Pick a face not used by any chart yet, belonging to the largest planar region.
+ chart->seed = 0;
+ float largestArea = 0.0f;
+ for (uint32_t f = 0; f < m_data.mesh->faceCount(); f++) {
+ if (m_data.isFaceInChart.get(f))
+ continue;
+ const float area = m_planarCharts.regionArea(m_planarCharts.regionIdFromFace(f));
+ if (area > largestArea) {
+ largestArea = area;
+ chart->seed = f;
+ }
+ }
+ addFaceToChart(chart, chart->seed);
// Grow the chart as much as possible within the given threshold.
for (;;) {
if (chart->candidates.count() == 0 || chart->candidates.peekCost() > threshold)
break;
const uint32_t f = chart->candidates.pop();
- if (m_faceCharts[f] != -1)
+ if (m_data.isFaceInChart.get(f))
continue;
if (!addFaceToChart(chart, f)) {
- chart->failedPlanarRegions.push_back(m_facePlanarRegionId[f]);
+ chart->failedPlanarRegions.push_back(m_planarCharts.regionIdFromFace(f));
continue;
}
}
}
- bool isChartBoundaryEdge(const Chart *chart, uint32_t edge) const {
- const uint32_t oppositeEdge = m_mesh->oppositeEdge(edge);
+ bool isChartBoundaryEdge(const Chart *chart, uint32_t edge) const
+ {
+ const uint32_t oppositeEdge = m_data.mesh->oppositeEdge(edge);
const uint32_t oppositeFace = meshEdgeFace(oppositeEdge);
return oppositeEdge == UINT32_MAX || m_faceCharts[oppositeFace] != chart->id;
}
- bool computeChartBasis(Chart *chart, Basis *basis) {
+ bool computeChartBasis(Chart *chart, Basis *basis)
+ {
const uint32_t faceCount = chart->faces.size();
m_tempPoints.resize(chart->faces.size() * 3);
for (uint32_t i = 0; i < faceCount; i++) {
const uint32_t f = chart->faces[i];
for (uint32_t j = 0; j < 3; j++)
- m_tempPoints[i * 3 + j] = m_mesh->position(m_mesh->vertexAt(f * 3 + j));
+ m_tempPoints[i * 3 + j] = m_data.mesh->position(m_data.mesh->vertexAt(f * 3 + j));
}
return Fit::computeBasis(m_tempPoints.data(), m_tempPoints.size(), basis);
}
- bool isFaceFlipped(uint32_t face) const {
+ bool isFaceFlipped(uint32_t face) const
+ {
const Vector2 &v1 = m_texcoords[face * 3 + 0];
const Vector2 &v2 = m_texcoords[face * 3 + 1];
const Vector2 &v3 = m_texcoords[face * 3 + 2];
@@ -4981,20 +6071,22 @@ private:
return parametricArea < 0.0f;
}
- void parameterizeChart(const Chart *chart) {
+ void parameterizeChart(const Chart *chart)
+ {
const uint32_t faceCount = chart->faces.size();
for (uint32_t i = 0; i < faceCount; i++) {
const uint32_t face = chart->faces[i];
for (uint32_t j = 0; j < 3; j++) {
const uint32_t offset = face * 3 + j;
- const Vector3 &pos = m_mesh->position(m_mesh->vertexAt(offset));
+ const Vector3 &pos = m_data.mesh->position(m_data.mesh->vertexAt(offset));
m_texcoords[offset] = Vector2(dot(chart->basis.tangent, pos), dot(chart->basis.bitangent, pos));
}
}
}
// m_faceCharts for the chart faces must be set to the chart ID. Needed to compute boundary edges.
- bool isChartParameterizationValid(const Chart *chart) {
+ bool isChartParameterizationValid(const Chart *chart)
+ {
const uint32_t faceCount = chart->faces.size();
// Check for flipped faces in the parameterization. OK if all are flipped.
uint32_t flippedFaceCount = 0;
@@ -5005,6 +6097,8 @@ private:
if (flippedFaceCount != 0 && flippedFaceCount != faceCount)
return false;
// Check for boundary intersection in the parameterization.
+ XA_PROFILE_START(clusteredChartsPlaceSeedsBoundaryIntersection)
+ XA_PROFILE_START(clusteredChartsGrowBoundaryIntersection)
m_boundaryGrid.reset(m_texcoords.data());
for (uint32_t i = 0; i < faceCount; i++) {
const uint32_t f = chart->faces[i];
@@ -5014,22 +6108,30 @@ private:
m_boundaryGrid.append(edge);
}
}
- if (m_boundaryGrid.intersectSelf(m_mesh->epsilon()))
+ const bool intersection = m_boundaryGrid.intersect(m_data.mesh->epsilon());
+#if XA_PROFILE
+ if (m_placingSeeds)
+ XA_PROFILE_END(clusteredChartsPlaceSeedsBoundaryIntersection)
+ else
+ XA_PROFILE_END(clusteredChartsGrowBoundaryIntersection)
+#endif
+ if (intersection)
return false;
return true;
}
- bool addFaceToChart(Chart *chart, uint32_t face) {
- XA_DEBUG_ASSERT(m_faceCharts[face] == -1);
+ bool addFaceToChart(Chart *chart, uint32_t face)
+ {
+ XA_DEBUG_ASSERT(!m_data.isFaceInChart.get(face));
const uint32_t oldFaceCount = chart->faces.size();
const bool firstFace = oldFaceCount == 0;
// Append the face and any coplanar connected faces to the chart faces array.
chart->faces.push_back(face);
- uint32_t coplanarFace = m_nextPlanarRegionFace[face];
- while (coplanarFace != face) {
- XA_DEBUG_ASSERT(m_faceCharts[coplanarFace] == -1);
+ uint32_t coplanarFace = m_planarCharts.nextRegionFace(face);
+ while (coplanarFace != face) {
+ XA_DEBUG_ASSERT(!m_data.isFaceInChart.get(coplanarFace));
chart->faces.push_back(coplanarFace);
- coplanarFace = m_nextPlanarRegionFace[coplanarFace];
+ coplanarFace = m_planarCharts.nextRegionFace(coplanarFace);
}
const uint32_t faceCount = chart->faces.size();
// Compute basis.
@@ -5037,8 +6139,8 @@ private:
if (firstFace) {
// Use the first face normal.
// Use any edge as the tangent vector.
- basis.normal = m_faceNormals[face];
- basis.tangent = normalize(m_mesh->position(m_mesh->vertexAt(face * 3 + 0)) - m_mesh->position(m_mesh->vertexAt(face * 3 + 1)), 0);
+ basis.normal = m_data.faceNormals[face];
+ basis.tangent = normalize(m_data.mesh->position(m_data.mesh->vertexAt(face * 3 + 0)) - m_data.mesh->position(m_data.mesh->vertexAt(face * 3 + 1)), kEpsilon);
basis.bitangent = cross(basis.normal, basis.tangent);
} else {
// Use best fit normal.
@@ -5046,7 +6148,7 @@ private:
chart->faces.resize(oldFaceCount);
return false;
}
- if (dot(basis.normal, m_faceNormals[face]) < 0.0f) // Flip normal if oriented in the wrong direction.
+ if (dot(basis.normal, m_data.faceNormals[face]) < 0.0f) // Flip normal if oriented in the wrong direction.
basis.normal = -basis.normal;
}
if (!firstFace) {
@@ -5069,7 +6171,8 @@ private:
const uint32_t f = chart->faces[i];
m_faceCharts[f] = chart->id;
m_facesLeft--;
- chart->centroidSum += m_mesh->computeFaceCenter(f);
+ m_data.isFaceInChart.set(f);
+ chart->centroidSum += m_data.mesh->computeFaceCenter(f);
}
chart->centroid = chart->centroidSum / float(chart->faces.size());
// Refresh candidates.
@@ -5079,15 +6182,15 @@ private:
const uint32_t f = chart->faces[i];
for (uint32_t j = 0; j < 3; j++) {
const uint32_t edge = f * 3 + j;
- const uint32_t oedge = m_mesh->oppositeEdge(edge);
+ const uint32_t oedge = m_data.mesh->oppositeEdge(edge);
if (oedge == UINT32_MAX)
continue; // Boundary edge.
const uint32_t oface = meshEdgeFace(oedge);
- if (m_faceCharts[oface] != -1)
+ if (m_data.isFaceInChart.get(oface))
continue; // Face belongs to another chart.
- if (chart->failedPlanarRegions.contains(m_facePlanarRegionId[oface]))
+ if (chart->failedPlanarRegions.contains(m_planarCharts.regionIdFromFace(oface)))
continue; // Failed to add this faces planar region to the chart before.
- const float cost = evaluateCost(chart, oface);
+ const float cost = computeCost(chart, oface);
if (cost < FLT_MAX)
chart->candidates.push(cost, oface);
}
@@ -5096,76 +6199,62 @@ private:
}
// Returns true if the seed has changed.
- bool relocateSeed(Chart *chart) {
+ bool relocateSeed(Chart *chart)
+ {
// Find the first N triangles that fit the proxy best.
const uint32_t faceCount = chart->faces.size();
m_bestTriangles.clear();
for (uint32_t i = 0; i < faceCount; i++) {
- const float cost = evaluateProxyFitMetric(chart, chart->faces[i]);
+ const float cost = computeNormalDeviationMetric(chart, chart->faces[i]);
m_bestTriangles.push(cost, chart->faces[i]);
}
- // Of those, choose the least central triangle.
- uint32_t leastCentral = 0;
- float maxDistance = -1;
+ // Of those, choose the most central triangle.
+ uint32_t mostCentral = 0;
+ float minDistance = FLT_MAX;
for (;;) {
if (m_bestTriangles.count() == 0)
break;
const uint32_t face = m_bestTriangles.pop();
- Vector3 faceCentroid = m_mesh->computeFaceCenter(face);
+ Vector3 faceCentroid = m_data.mesh->computeFaceCenter(face);
const float distance = length(chart->centroid - faceCentroid);
- if (distance > maxDistance) {
- maxDistance = distance;
- leastCentral = face;
- }
- }
- XA_DEBUG_ASSERT(maxDistance >= 0);
- // In order to prevent k-means cyles we record all the previously chosen seeds.
- for (uint32_t i = 0; i < chart->seeds.size(); i++) {
- // Treat seeds belong to the same planar region as equal.
- if (chart->seeds[i] == leastCentral || m_facePlanarRegionId[chart->seeds[i]] == m_facePlanarRegionId[leastCentral]) {
- // Move new seed to the end of the seed array.
- uint32_t last = chart->seeds.size() - 1;
- swap(chart->seeds[i], chart->seeds[last]);
- return false;
+ if (distance < minDistance) {
+ minDistance = distance;
+ mostCentral = face;
}
}
- // Append new seed.
- chart->seeds.push_back(leastCentral);
+ XA_DEBUG_ASSERT(minDistance < FLT_MAX);
+ if (mostCentral == chart->seed)
+ return false;
+ chart->seed = mostCentral;
return true;
}
- // Evaluate combined metric.
- float evaluateCost(Chart *chart, uint32_t face) const {
- if (dot(m_faceNormals[face], chart->basis.normal) <= 0.26f) // ~75 degrees
- return FLT_MAX;
+ // Cost is combined metrics * weights.
+ float computeCost(Chart *chart, uint32_t face) const
+ {
// Estimate boundary length and area:
- float newChartArea = 0.0f, newBoundaryLength = 0.0f;
- if (m_options.maxChartArea > 0.0f || m_options.roundnessMetricWeight > 0.0f)
- newChartArea = computeArea(chart, face);
- if (m_options.maxBoundaryLength > 0.0f || m_options.roundnessMetricWeight > 0.0f)
- newBoundaryLength = computeBoundaryLength(chart, face);
+ const float newChartArea = computeArea(chart, face);
+ const float newBoundaryLength = computeBoundaryLength(chart, face);
// Enforce limits strictly:
- if (m_options.maxChartArea > 0.0f && newChartArea > m_options.maxChartArea)
+ if (m_data.options.maxChartArea > 0.0f && newChartArea > m_data.options.maxChartArea)
return FLT_MAX;
- if (m_options.maxBoundaryLength > 0.0f && newBoundaryLength > m_options.maxBoundaryLength)
+ if (m_data.options.maxBoundaryLength > 0.0f && newBoundaryLength > m_data.options.maxBoundaryLength)
return FLT_MAX;
+ // Compute metrics.
float cost = 0.0f;
- if (m_options.normalSeamMetricWeight > 0.0f) {
- // Penalize faces that cross seams, reward faces that close seams or reach boundaries.
- // Make sure normal seams are fully respected:
- const float N = evaluateNormalSeamMetric(chart, face);
- if (m_options.normalSeamMetricWeight >= 1000.0f && N > 0.0f)
- return FLT_MAX;
- cost += m_options.normalSeamMetricWeight * N;
- }
- if (m_options.proxyFitMetricWeight > 0.0f)
- cost += m_options.proxyFitMetricWeight * evaluateProxyFitMetric(chart, face);
- if (m_options.roundnessMetricWeight > 0.0f)
- cost += m_options.roundnessMetricWeight * evaluateRoundnessMetric(chart, newBoundaryLength, newChartArea);
- if (m_options.straightnessMetricWeight > 0.0f)
- cost += m_options.straightnessMetricWeight * evaluateStraightnessMetric(chart, face);
- if (m_options.textureSeamMetricWeight > 0.0f)
- cost += m_options.textureSeamMetricWeight * evaluateTextureSeamMetric(chart, face);
+ const float normalDeviation = computeNormalDeviationMetric(chart, face);
+ if (normalDeviation >= 0.707f) // ~75 degrees
+ return FLT_MAX;
+ cost += m_data.options.normalDeviationWeight * normalDeviation;
+ // Penalize faces that cross seams, reward faces that close seams or reach boundaries.
+ // Make sure normal seams are fully respected:
+ const float normalSeam = computeNormalSeamMetric(chart, face);
+ if (m_data.options.normalSeamWeight >= 1000.0f && normalSeam > 0.0f)
+ return FLT_MAX;
+ cost += m_data.options.normalSeamWeight * normalSeam;
+ cost += m_data.options.roundnessWeight * computeRoundnessMetric(chart, newBoundaryLength, newChartArea);
+ cost += m_data.options.straightnessWeight * computeStraightnessMetric(chart, face);
+ cost += m_data.options.textureSeamWeight * computeTextureSeamMetric(chart, face);
//float R = evaluateCompletenessMetric(chart, face);
//float D = evaluateDihedralAngleMetric(chart, face);
// @@ Add a metric based on local dihedral angle.
@@ -5176,100 +6265,108 @@ private:
}
// Returns a value in [0-1].
- float evaluateProxyFitMetric(Chart *chart, uint32_t face) const {
+ // 0 if face normal is coplanar to the chart's best fit normal.
+ // 1 if face normal is perpendicular.
+ float computeNormalDeviationMetric(Chart *chart, uint32_t face) const
+ {
// All faces in coplanar regions have the same normal, can use any face.
- const Vector3 faceNormal = m_faceNormals[face];
+ const Vector3 faceNormal = m_data.faceNormals[face];
// Use plane fitting metric for now:
- return 1 - dot(faceNormal, chart->basis.normal); // @@ normal deviations should be weighted by face area
+ return min(1.0f - dot(faceNormal, chart->basis.normal), 1.0f); // @@ normal deviations should be weighted by face area
}
- float evaluateRoundnessMetric(Chart *chart, float newBoundaryLength, float newChartArea) const {
- const float roundness = square(chart->boundaryLength) / chart->area;
- const float newBoundaryLengthSq = square(newBoundaryLength);
- const float newRoundness = newBoundaryLengthSq / newChartArea;
- if (newRoundness > roundness)
- return newBoundaryLengthSq / (newChartArea * kPi4);
- // Offer no impedance to faces that improve roundness.
- return 0;
+ float computeRoundnessMetric(Chart *chart, float newBoundaryLength, float newChartArea) const
+ {
+ const float oldRoundness = square(chart->boundaryLength) / chart->area;
+ const float newRoundness = square(newBoundaryLength) / newChartArea;
+ return 1.0f - oldRoundness / newRoundness;
}
- float evaluateStraightnessMetric(Chart *chart, uint32_t firstFace) const {
- float l_out = 0.0f, l_in = 0.0f;
- const uint32_t planarRegionId = m_facePlanarRegionId[firstFace];
+ float computeStraightnessMetric(Chart *chart, uint32_t firstFace) const
+ {
+ float l_out = 0.0f; // Length of firstFace planar region boundary that doesn't border the chart.
+ float l_in = 0.0f; // Length that does border the chart.
+ const uint32_t planarRegionId = m_planarCharts.regionIdFromFace(firstFace);
uint32_t face = firstFace;
- for (;;) {
- for (Mesh::FaceEdgeIterator it(m_mesh, face); !it.isDone(); it.advance()) {
- const float l = m_edgeLengths[it.edge()];
+ for (;;) {
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, face); !it.isDone(); it.advance()) {
+ const float l = m_data.edgeLengths[it.edge()];
if (it.isBoundary()) {
l_out += l;
- } else if (m_facePlanarRegionId[it.oppositeFace()] != planarRegionId) {
+ } else if (m_planarCharts.regionIdFromFace(it.oppositeFace()) != planarRegionId) {
if (m_faceCharts[it.oppositeFace()] != chart->id)
l_out += l;
else
l_in += l;
}
}
- face = m_nextPlanarRegionFace[face];
+ face = m_planarCharts.nextRegionFace(face);
if (face == firstFace)
break;
}
+#if 1
XA_DEBUG_ASSERT(l_in != 0.0f); // Candidate face must be adjacent to chart. @@ This is not true if the input mesh has zero-length edges.
float ratio = (l_out - l_in) / (l_out + l_in);
return min(ratio, 0.0f); // Only use the straightness metric to close gaps.
+#else
+ return 1.0f - l_in / l_out;
+#endif
}
- bool isNormalSeam(uint32_t edge) const {
- const uint32_t oppositeEdge = m_mesh->oppositeEdge(edge);
+ bool isNormalSeam(uint32_t edge) const
+ {
+ const uint32_t oppositeEdge = m_data.mesh->oppositeEdge(edge);
if (oppositeEdge == UINT32_MAX)
return false; // boundary edge
- if (m_mesh->flags() & MeshFlags::HasNormals) {
- const uint32_t v0 = m_mesh->vertexAt(meshEdgeIndex0(edge));
- const uint32_t v1 = m_mesh->vertexAt(meshEdgeIndex1(edge));
- const uint32_t ov0 = m_mesh->vertexAt(meshEdgeIndex0(oppositeEdge));
- const uint32_t ov1 = m_mesh->vertexAt(meshEdgeIndex1(oppositeEdge));
+ if (m_data.mesh->flags() & MeshFlags::HasNormals) {
+ const uint32_t v0 = m_data.mesh->vertexAt(meshEdgeIndex0(edge));
+ const uint32_t v1 = m_data.mesh->vertexAt(meshEdgeIndex1(edge));
+ const uint32_t ov0 = m_data.mesh->vertexAt(meshEdgeIndex0(oppositeEdge));
+ const uint32_t ov1 = m_data.mesh->vertexAt(meshEdgeIndex1(oppositeEdge));
if (v0 == ov1 && v1 == ov0)
return false;
- return !equal(m_mesh->normal(v0), m_mesh->normal(ov1), kNormalEpsilon) || !equal(m_mesh->normal(v1), m_mesh->normal(ov0), kNormalEpsilon);
+ return !equal(m_data.mesh->normal(v0), m_data.mesh->normal(ov1), kNormalEpsilon) || !equal(m_data.mesh->normal(v1), m_data.mesh->normal(ov0), kNormalEpsilon);
}
const uint32_t f0 = meshEdgeFace(edge);
const uint32_t f1 = meshEdgeFace(oppositeEdge);
- if (m_facePlanarRegionId[f0] == m_facePlanarRegionId[f1])
+ if (m_planarCharts.regionIdFromFace(f0) == m_planarCharts.regionIdFromFace(f1))
return false;
- return !equal(m_faceNormals[f0], m_faceNormals[f1], kNormalEpsilon);
+ return !equal(m_data.faceNormals[f0], m_data.faceNormals[f1], kNormalEpsilon);
}
- float evaluateNormalSeamMetric(Chart *chart, uint32_t firstFace) const {
+ float computeNormalSeamMetric(Chart *chart, uint32_t firstFace) const
+ {
float seamFactor = 0.0f, totalLength = 0.0f;
uint32_t face = firstFace;
- for (;;) {
- for (Mesh::FaceEdgeIterator it(m_mesh, face); !it.isDone(); it.advance()) {
+ for (;;) {
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, face); !it.isDone(); it.advance()) {
if (it.isBoundary())
continue;
if (m_faceCharts[it.oppositeFace()] != chart->id)
continue;
- float l = m_edgeLengths[it.edge()];
+ float l = m_data.edgeLengths[it.edge()];
totalLength += l;
if (!it.isSeam())
continue;
// Make sure it's a normal seam.
if (isNormalSeam(it.edge())) {
float d;
- if (m_mesh->flags() & MeshFlags::HasNormals) {
- const Vector3 &n0 = m_mesh->normal(it.vertex0());
- const Vector3 &n1 = m_mesh->normal(it.vertex1());
- const Vector3 &on0 = m_mesh->normal(m_mesh->vertexAt(meshEdgeIndex0(it.oppositeEdge())));
- const Vector3 &on1 = m_mesh->normal(m_mesh->vertexAt(meshEdgeIndex1(it.oppositeEdge())));
+ if (m_data.mesh->flags() & MeshFlags::HasNormals) {
+ const Vector3 &n0 = m_data.mesh->normal(it.vertex0());
+ const Vector3 &n1 = m_data.mesh->normal(it.vertex1());
+ const Vector3 &on0 = m_data.mesh->normal(m_data.mesh->vertexAt(meshEdgeIndex0(it.oppositeEdge())));
+ const Vector3 &on1 = m_data.mesh->normal(m_data.mesh->vertexAt(meshEdgeIndex1(it.oppositeEdge())));
const float d0 = clamp(dot(n0, on1), 0.0f, 1.0f);
const float d1 = clamp(dot(n1, on0), 0.0f, 1.0f);
d = (d0 + d1) * 0.5f;
} else {
- d = clamp(dot(m_faceNormals[face], m_faceNormals[meshEdgeFace(it.oppositeEdge())]), 0.0f, 1.0f);
+ d = clamp(dot(m_data.faceNormals[face], m_data.faceNormals[meshEdgeFace(it.oppositeEdge())]), 0.0f, 1.0f);
}
l *= 1 - d;
seamFactor += l;
}
}
- face = m_nextPlanarRegionFace[face];
+ face = m_planarCharts.nextRegionFace(face);
if (face == firstFace)
break;
}
@@ -5278,16 +6375,17 @@ private:
return seamFactor / totalLength;
}
- float evaluateTextureSeamMetric(Chart *chart, uint32_t firstFace) const {
+ float computeTextureSeamMetric(Chart *chart, uint32_t firstFace) const
+ {
float seamLength = 0.0f, totalLength = 0.0f;
uint32_t face = firstFace;
- for (;;) {
- for (Mesh::FaceEdgeIterator it(m_mesh, face); !it.isDone(); it.advance()) {
+ for (;;) {
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, face); !it.isDone(); it.advance()) {
if (it.isBoundary())
continue;
if (m_faceCharts[it.oppositeFace()] != chart->id)
continue;
- float l = m_edgeLengths[it.edge()];
+ float l = m_data.edgeLengths[it.edge()];
totalLength += l;
if (!it.isSeam())
continue;
@@ -5295,7 +6393,7 @@ private:
if (it.isTextureSeam())
seamLength += l;
}
- face = m_nextPlanarRegionFace[face];
+ face = m_planarCharts.nextRegionFace(face);
if (face == firstFace)
break;
}
@@ -5304,43 +6402,46 @@ private:
return seamLength / totalLength;
}
- float computeArea(Chart *chart, uint32_t firstFace) const {
+ float computeArea(Chart *chart, uint32_t firstFace) const
+ {
float area = chart->area;
uint32_t face = firstFace;
- for (;;) {
- area += m_faceAreas[face];
- face = m_nextPlanarRegionFace[face];
+ for (;;) {
+ area += m_data.faceAreas[face];
+ face = m_planarCharts.nextRegionFace(face);
if (face == firstFace)
break;
}
return area;
}
- float computeBoundaryLength(Chart *chart, uint32_t firstFace) const {
+ float computeBoundaryLength(Chart *chart, uint32_t firstFace) const
+ {
float boundaryLength = chart->boundaryLength;
// Add new edges, subtract edges shared with the chart.
- const uint32_t planarRegionId = m_facePlanarRegionId[firstFace];
+ const uint32_t planarRegionId = m_planarCharts.regionIdFromFace(firstFace);
uint32_t face = firstFace;
- for (;;) {
- for (Mesh::FaceEdgeIterator it(m_mesh, face); !it.isDone(); it.advance()) {
- const float edgeLength = m_edgeLengths[it.edge()];
+ for (;;) {
+ for (Mesh::FaceEdgeIterator it(m_data.mesh, face); !it.isDone(); it.advance()) {
+ const float edgeLength = m_data.edgeLengths[it.edge()];
if (it.isBoundary()) {
boundaryLength += edgeLength;
- } else if (m_facePlanarRegionId[it.oppositeFace()] != planarRegionId) {
+ } else if (m_planarCharts.regionIdFromFace(it.oppositeFace()) != planarRegionId) {
if (m_faceCharts[it.oppositeFace()] != chart->id)
boundaryLength += edgeLength;
else
boundaryLength -= edgeLength;
}
}
- face = m_nextPlanarRegionFace[face];
+ face = m_planarCharts.nextRegionFace(face);
if (face == firstFace)
break;
}
- return max(0.0f, boundaryLength); // @@ Hack!
+ return max(0.0f, boundaryLength); // @@ Hack!
}
- bool mergeChart(Chart *owner, Chart *chart, float sharedBoundaryLength) {
+ bool mergeChart(Chart *owner, Chart *chart, float sharedBoundaryLength)
+ {
const uint32_t oldOwnerFaceCount = owner->faces.size();
const uint32_t chartFaceCount = chart->faces.size();
owner->faces.push_back(chart->faces);
@@ -5356,7 +6457,7 @@ private:
m_faceCharts[chart->faces[i]] = chart->id;
return false;
}
- if (dot(basis.normal, m_faceNormals[owner->faces[0]]) < 0.0f) // Flip normal if oriented in the wrong direction.
+ if (dot(basis.normal, m_data.faceNormals[owner->faces[0]]) < 0.0f) // Flip normal if oriented in the wrong direction.
basis.normal = -basis.normal;
// Compute orthogonal parameterization and check that it is valid.
parameterizeChart(owner);
@@ -5379,19 +6480,14 @@ private:
return true;
}
- const Mesh *m_mesh;
- Array<float> m_edgeLengths;
- Array<float> m_faceAreas;
- Array<Vector3> m_faceNormals;
+private:
+ AtlasData &m_data;
+ const PlanarCharts &m_planarCharts;
Array<Vector2> m_texcoords;
uint32_t m_facesLeft;
Array<int> m_faceCharts;
Array<Chart *> m_charts;
CostQueue m_bestTriangles;
- KISSRng m_rand;
- ChartOptions m_options;
- Array<uint32_t> m_nextPlanarRegionFace;
- Array<uint32_t> m_facePlanarRegionId;
Array<Vector3> m_tempPoints;
UniformGrid2 m_boundaryGrid;
#if XA_MERGE_CHARTS
@@ -5400,226 +6496,66 @@ private:
Array<float> m_sharedBoundaryLengthsNoSeams;
Array<uint32_t> m_sharedBoundaryEdgeCountNoSeams;
#endif
+ bool m_placingSeeds;
};
-} // namespace segment
-
-namespace param {
+struct Atlas
+{
+ Atlas() : m_planarCharts(m_data), m_clusteredCharts(m_data, m_planarCharts) {}
-class JacobiPreconditioner {
-public:
- JacobiPreconditioner(const sparse::Matrix &M, bool symmetric) :
- m_inverseDiagonal(M.width()) {
- XA_ASSERT(M.isSquare());
- for (uint32_t x = 0; x < M.width(); x++) {
- float elem = M.getCoefficient(x, x);
- //XA_DEBUG_ASSERT( elem != 0.0f ); // This can be zero in the presence of zero area triangles.
- if (symmetric) {
- m_inverseDiagonal[x] = (elem != 0) ? 1.0f / sqrtf(fabsf(elem)) : 1.0f;
- } else {
- m_inverseDiagonal[x] = (elem != 0) ? 1.0f / elem : 1.0f;
- }
- }
+ uint32_t chartCount() const
+ {
+ return m_planarCharts.chartCount() + m_clusteredCharts.chartCount();
}
- void apply(const FullVector &x, FullVector &y) const {
- XA_DEBUG_ASSERT(x.dimension() == m_inverseDiagonal.dimension());
- XA_DEBUG_ASSERT(y.dimension() == m_inverseDiagonal.dimension());
- // @@ Wrap vector component-wise product into a separate function.
- const uint32_t D = x.dimension();
- for (uint32_t i = 0; i < D; i++) {
- y[i] = m_inverseDiagonal[i] * x[i];
- }
+ ConstArrayView<uint32_t> chartFaces(uint32_t chartIndex) const
+ {
+ if (chartIndex < m_planarCharts.chartCount())
+ return m_planarCharts.chartFaces(chartIndex);
+ chartIndex -= m_planarCharts.chartCount();
+ return m_clusteredCharts.chartFaces(chartIndex);
}
-private:
- FullVector m_inverseDiagonal;
-};
-
-// Linear solvers.
-class Solver {
-public:
- // Solve the symmetric system: At·A·x = At·b
- static bool LeastSquaresSolver(const sparse::Matrix &A, const FullVector &b, FullVector &x, float epsilon = 1e-5f) {
- XA_DEBUG_ASSERT(A.width() == x.dimension());
- XA_DEBUG_ASSERT(A.height() == b.dimension());
- XA_DEBUG_ASSERT(A.height() >= A.width()); // @@ If height == width we could solve it directly...
- const uint32_t D = A.width();
- sparse::Matrix At(A.height(), A.width());
- sparse::transpose(A, At);
- FullVector Atb(D);
- sparse::mult(At, b, Atb);
- sparse::Matrix AtA(D);
- sparse::mult(At, A, AtA);
- return SymmetricSolver(AtA, Atb, x, epsilon);
- }
-
- // See section 10.4.3 in: Mesh Parameterization: Theory and Practice, Siggraph Course Notes, August 2007
- static bool LeastSquaresSolver(const sparse::Matrix &A, const FullVector &b, FullVector &x, const uint32_t *lockedParameters, uint32_t lockedCount, float epsilon = 1e-5f) {
- XA_DEBUG_ASSERT(A.width() == x.dimension());
- XA_DEBUG_ASSERT(A.height() == b.dimension());
- XA_DEBUG_ASSERT(A.height() >= A.width() - lockedCount);
- // @@ This is not the most efficient way of building a system with reduced degrees of freedom. It would be faster to do it on the fly.
- const uint32_t D = A.width() - lockedCount;
- XA_DEBUG_ASSERT(D > 0);
- // Compute: b - Al * xl
- FullVector b_Alxl(b);
- for (uint32_t y = 0; y < A.height(); y++) {
- const uint32_t count = A.getRow(y).size();
- for (uint32_t e = 0; e < count; e++) {
- uint32_t column = A.getRow(y)[e].x;
- bool isFree = true;
- for (uint32_t i = 0; i < lockedCount; i++) {
- isFree &= (lockedParameters[i] != column);
- }
- if (!isFree) {
- b_Alxl[y] -= x[column] * A.getRow(y)[e].v;
- }
- }
- }
- // Remove locked columns from A.
- sparse::Matrix Af(D, A.height());
- for (uint32_t y = 0; y < A.height(); y++) {
- const uint32_t count = A.getRow(y).size();
- for (uint32_t e = 0; e < count; e++) {
- uint32_t column = A.getRow(y)[e].x;
- uint32_t ix = column;
- bool isFree = true;
- for (uint32_t i = 0; i < lockedCount; i++) {
- isFree &= (lockedParameters[i] != column);
- if (column > lockedParameters[i]) ix--; // shift columns
- }
- if (isFree) {
- Af.setCoefficient(ix, y, A.getRow(y)[e].v);
- }
- }
- }
- // Remove elements from x
- FullVector xf(D);
- for (uint32_t i = 0, j = 0; i < A.width(); i++) {
- bool isFree = true;
- for (uint32_t l = 0; l < lockedCount; l++) {
- isFree &= (lockedParameters[l] != i);
- }
- if (isFree) {
- xf[j++] = x[i];
- }
- }
- // Solve reduced system.
- bool result = LeastSquaresSolver(Af, b_Alxl, xf, epsilon);
- // Copy results back to x.
- for (uint32_t i = 0, j = 0; i < A.width(); i++) {
- bool isFree = true;
- for (uint32_t l = 0; l < lockedCount; l++) {
- isFree &= (lockedParameters[l] != i);
- }
- if (isFree) {
- x[i] = xf[j++];
- }
- }
- return result;
+ const Basis &chartBasis(uint32_t chartIndex) const
+ {
+ if (chartIndex < m_planarCharts.chartCount())
+ return m_planarCharts.chartBasis(chartIndex);
+ chartIndex -= m_planarCharts.chartCount();
+ return m_clusteredCharts.chartBasis(chartIndex);
}
-private:
- /**
- * Compute the solution of the sparse linear system Ab=x using the Conjugate
- * Gradient method.
- *
- * Solving sparse linear systems:
- * (1) A·x = b
- *
- * The conjugate gradient algorithm solves (1) only in the case that A is
- * symmetric and positive definite. It is based on the idea of minimizing the
- * function
- *
- * (2) f(x) = 1/2·x·A·x - b·x
- *
- * This function is minimized when its gradient
- *
- * (3) df = A·x - b
- *
- * is zero, which is equivalent to (1). The minimization is carried out by
- * generating a succession of search directions p.k and improved minimizers x.k.
- * At each stage a quantity alfa.k is found that minimizes f(x.k + alfa.k·p.k),
- * and x.k+1 is set equal to the new point x.k + alfa.k·p.k. The p.k and x.k are
- * built up in such a way that x.k+1 is also the minimizer of f over the whole
- * vector space of directions already taken, {p.1, p.2, . . . , p.k}. After N
- * iterations you arrive at the minimizer over the entire vector space, i.e., the
- * solution to (1).
- *
- * For a really good explanation of the method see:
- *
- * "An Introduction to the Conjugate Gradient Method Without the Agonizing Pain",
- * Jonhathan Richard Shewchuk.
- *
- **/
- // Conjugate gradient with preconditioner.
- static bool ConjugateGradientSolver(const JacobiPreconditioner &preconditioner, const sparse::Matrix &A, const FullVector &b, FullVector &x, float epsilon) {
- XA_DEBUG_ASSERT(A.isSquare());
- XA_DEBUG_ASSERT(A.width() == b.dimension());
- XA_DEBUG_ASSERT(A.width() == x.dimension());
- int i = 0;
- const int D = A.width();
- const int i_max = 4 * D; // Convergence should be linear, but in some cases, it's not.
- FullVector r(D); // residual
- FullVector p(D); // search direction
- FullVector q(D); //
- FullVector s(D); // preconditioned
- float delta_0;
- float delta_old;
- float delta_new;
- float alpha;
- float beta;
- // r = b - A·x
- sparse::copy(b, r);
- sparse::sgemv(-1, A, x, 1, r);
- // p = M^-1 · r
- preconditioner.apply(r, p);
- delta_new = sparse::dot(r, p);
- delta_0 = delta_new;
- while (i < i_max && delta_new > epsilon * epsilon * delta_0) {
- i++;
- // q = A·p
- sparse::mult(A, p, q);
- // alpha = delta_new / p·q
- const float pdotq = sparse::dot(p, q);
- if (!isFinite(pdotq) || isNan(pdotq))
- alpha = 0.0f;
- else
- alpha = delta_new / pdotq;
- // x = alfa·p + x
- sparse::saxpy(alpha, p, x);
- if ((i & 31) == 0) { // recompute r after 32 steps
- // r = b - A·x
- sparse::copy(b, r);
- sparse::sgemv(-1, A, x, 1, r);
- } else {
- // r = r - alfa·q
- sparse::saxpy(-alpha, q, r);
- }
- // s = M^-1 · r
- preconditioner.apply(r, s);
- delta_old = delta_new;
- delta_new = sparse::dot(r, s);
- beta = delta_new / delta_old;
- // p = s + beta·p
- sparse::scal(beta, p);
- sparse::saxpy(1, s, p);
- }
- return delta_new <= epsilon * epsilon * delta_0;
+ void reset(const Mesh *mesh, const ChartOptions &options)
+ {
+ XA_PROFILE_START(buildAtlasInit)
+ m_data.options = options;
+ m_data.mesh = mesh;
+ m_data.compute();
+ XA_PROFILE_END(buildAtlasInit)
}
- static bool SymmetricSolver(const sparse::Matrix &A, const FullVector &b, FullVector &x, float epsilon = 1e-5f) {
- XA_DEBUG_ASSERT(A.height() == A.width());
- XA_DEBUG_ASSERT(A.height() == b.dimension());
- XA_DEBUG_ASSERT(b.dimension() == x.dimension());
- JacobiPreconditioner jacobi(A, true);
- return ConjugateGradientSolver(jacobi, A, b, x, epsilon);
+ void compute()
+ {
+ XA_PROFILE_START(planarCharts)
+ m_planarCharts.compute();
+ XA_PROFILE_END(planarCharts)
+ XA_PROFILE_START(clusteredCharts)
+ m_clusteredCharts.compute();
+ XA_PROFILE_END(clusteredCharts)
}
+
+private:
+ AtlasData m_data;
+ PlanarCharts m_planarCharts;
+ ClusteredCharts m_clusteredCharts;
};
+} // namespace segment
+
+namespace param {
+
// Fast sweep in 3 directions
-static bool findApproximateDiameterVertices(Mesh *mesh, uint32_t *a, uint32_t *b) {
+static bool findApproximateDiameterVertices(Mesh *mesh, uint32_t *a, uint32_t *b)
+{
XA_DEBUG_ASSERT(a != nullptr);
XA_DEBUG_ASSERT(b != nullptr);
const uint32_t vertexCount = mesh->vertexCount();
@@ -5674,165 +6610,136 @@ static bool findApproximateDiameterVertices(Mesh *mesh, uint32_t *a, uint32_t *b
return true;
}
-// Conformal relations from Brecht Van Lommel (based on ABF):
-
-static float vec_angle_cos(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) {
- Vector3 d1 = v1 - v2;
- Vector3 d2 = v3 - v2;
- return clamp(dot(d1, d2) / (length(d1) * length(d2)), -1.0f, 1.0f);
-}
-
-static float vec_angle(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) {
- float dot = vec_angle_cos(v1, v2, v3);
- return acosf(dot);
-}
-
-static void triangle_angles(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, float *a1, float *a2, float *a3) {
- *a1 = vec_angle(v3, v1, v2);
- *a2 = vec_angle(v1, v2, v3);
- *a3 = kPi - *a2 - *a1;
-}
-
-static void setup_abf_relations(sparse::Matrix &A, int row, int id0, int id1, int id2, const Vector3 &p0, const Vector3 &p1, const Vector3 &p2) {
- // @@ IC: Wouldn't it be more accurate to return cos and compute 1-cos^2?
- // It does indeed seem to be a little bit more robust.
- // @@ Need to revisit this more carefully!
- float a0, a1, a2;
- triangle_angles(p0, p1, p2, &a0, &a1, &a2);
- float s0 = sinf(a0);
- float s1 = sinf(a1);
- float s2 = sinf(a2);
- if (s1 > s0 && s1 > s2) {
- swap(s1, s2);
- swap(s0, s1);
- swap(a1, a2);
- swap(a0, a1);
- swap(id1, id2);
- swap(id0, id1);
- } else if (s0 > s1 && s0 > s2) {
- swap(s0, s2);
- swap(s0, s1);
- swap(a0, a2);
- swap(a0, a1);
- swap(id0, id2);
- swap(id0, id1);
- }
- float c0 = cosf(a0);
- float ratio = (s2 == 0.0f) ? 1.0f : s1 / s2;
- float cosine = c0 * ratio;
- float sine = s0 * ratio;
- // Note : 2*id + 0 --> u
- // 2*id + 1 --> v
- int u0_id = 2 * id0 + 0;
- int v0_id = 2 * id0 + 1;
- int u1_id = 2 * id1 + 0;
- int v1_id = 2 * id1 + 1;
- int u2_id = 2 * id2 + 0;
- int v2_id = 2 * id2 + 1;
- // Real part
- A.setCoefficient(u0_id, 2 * row + 0, cosine - 1.0f);
- A.setCoefficient(v0_id, 2 * row + 0, -sine);
- A.setCoefficient(u1_id, 2 * row + 0, -cosine);
- A.setCoefficient(v1_id, 2 * row + 0, sine);
- A.setCoefficient(u2_id, 2 * row + 0, 1);
- // Imaginary part
- A.setCoefficient(u0_id, 2 * row + 1, sine);
- A.setCoefficient(v0_id, 2 * row + 1, cosine - 1.0f);
- A.setCoefficient(u1_id, 2 * row + 1, -sine);
- A.setCoefficient(v1_id, 2 * row + 1, -cosine);
- A.setCoefficient(v2_id, 2 * row + 1, 1);
-}
-
-static bool computeLeastSquaresConformalMap(Mesh *mesh) {
- // For this to work properly, mesh should not have colocals that have the same
- // attributes, unless you want the vertices to actually have different texcoords.
- const uint32_t vertexCount = mesh->vertexCount();
- const uint32_t D = 2 * vertexCount;
- const uint32_t N = 2 * mesh->faceCount();
- // N is the number of equations (one per triangle)
- // D is the number of variables (one per vertex; there are 2 pinned vertices).
- if (N < D - 4) {
- return false;
- }
- sparse::Matrix A(D, N);
- FullVector b(N);
- FullVector x(D);
- // Fill b:
- b.fill(0.0f);
- // Fill x:
- uint32_t v0, v1;
- if (!findApproximateDiameterVertices(mesh, &v0, &v1)) {
+// From OpenNL LSCM example.
+// Computes the coordinates of the vertices of a triangle in a local 2D orthonormal basis of the triangle's plane.
+static void projectTriangle(Vector3 p0, Vector3 p1, Vector3 p2, Vector2 *z0, Vector2 *z1, Vector2 *z2, float epsilon)
+{
+ Vector3 X = normalize(p1 - p0, epsilon);
+ Vector3 Z = normalize(cross(X, p2 - p0), epsilon);
+ Vector3 Y = cross(Z, X);
+ Vector3 &O = p0;
+ *z0 = Vector2(0, 0);
+ *z1 = Vector2(length(p1 - O), 0);
+ *z2 = Vector2(dot(p2 - O, X), dot(p2 - O, Y));
+}
+
+static bool computeLeastSquaresConformalMap(Mesh *mesh)
+{
+ uint32_t lockedVertex0, lockedVertex1;
+ if (!findApproximateDiameterVertices(mesh, &lockedVertex0, &lockedVertex1)) {
// Mesh has no boundaries.
return false;
}
- if (mesh->texcoord(v0) == mesh->texcoord(v1)) {
- // LSCM expects an existing parameterization.
+ const uint32_t vertexCount = mesh->vertexCount();
+ opennl::NLContext *context = opennl::nlNewContext();
+ opennl::nlSolverParameteri(context, NL_NB_VARIABLES, int(2 * vertexCount));
+ opennl::nlSolverParameteri(context, NL_MAX_ITERATIONS, int(5 * vertexCount));
+ opennl::nlBegin(context, NL_SYSTEM);
+ const Vector2 *texcoords = mesh->texcoords();
+ for (uint32_t i = 0; i < vertexCount; i++) {
+ opennl::nlSetVariable(context, 2 * i, texcoords[i].x);
+ opennl::nlSetVariable(context, 2 * i + 1, texcoords[i].y);
+ if (i == lockedVertex0 || i == lockedVertex1) {
+ opennl::nlLockVariable(context, 2 * i);
+ opennl::nlLockVariable(context, 2 * i + 1);
+ }
+ }
+ opennl::nlBegin(context, NL_MATRIX);
+ const uint32_t faceCount = mesh->faceCount();
+ const Vector3 *positions = mesh->positions();
+ const uint32_t *indices = mesh->indices();
+ for (uint32_t f = 0; f < faceCount; f++) {
+ const uint32_t v0 = indices[f * 3 + 0];
+ const uint32_t v1 = indices[f * 3 + 1];
+ const uint32_t v2 = indices[f * 3 + 2];
+ Vector2 z0, z1, z2;
+ projectTriangle(positions[v0], positions[v1], positions[v2], &z0, &z1, &z2, mesh->epsilon());
+ double a = z1.x - z0.x;
+ double b = z1.y - z0.y;
+ double c = z2.x - z0.x;
+ double d = z2.y - z0.y;
+ XA_DEBUG_ASSERT(b == 0.0);
+ // Note : 2*id + 0 --> u
+ // 2*id + 1 --> v
+ uint32_t u0_id = 2 * v0;
+ uint32_t v0_id = 2 * v0 + 1;
+ uint32_t u1_id = 2 * v1;
+ uint32_t v1_id = 2 * v1 + 1;
+ uint32_t u2_id = 2 * v2;
+ uint32_t v2_id = 2 * v2 + 1;
+ // Note : b = 0
+ // Real part
+ opennl::nlBegin(context, NL_ROW);
+ opennl::nlCoefficient(context, u0_id, -a+c) ;
+ opennl::nlCoefficient(context, v0_id, b-d) ;
+ opennl::nlCoefficient(context, u1_id, -c) ;
+ opennl::nlCoefficient(context, v1_id, d) ;
+ opennl::nlCoefficient(context, u2_id, a);
+ opennl::nlEnd(context, NL_ROW);
+ // Imaginary part
+ opennl::nlBegin(context, NL_ROW);
+ opennl::nlCoefficient(context, u0_id, -b+d);
+ opennl::nlCoefficient(context, v0_id, -a+c);
+ opennl::nlCoefficient(context, u1_id, -d);
+ opennl::nlCoefficient(context, v1_id, -c);
+ opennl::nlCoefficient(context, v2_id, a);
+ opennl::nlEnd(context, NL_ROW);
+ }
+ opennl::nlEnd(context, NL_MATRIX);
+ opennl::nlEnd(context, NL_SYSTEM);
+ if (!opennl::nlSolve(context)) {
+ opennl::nlDeleteContext(context);
return false;
}
- for (uint32_t v = 0; v < vertexCount; v++) {
- // Initial solution.
- x[2 * v + 0] = mesh->texcoord(v).x;
- x[2 * v + 1] = mesh->texcoord(v).y;
- }
- // Fill A:
- const uint32_t faceCount = mesh->faceCount();
- for (uint32_t f = 0, t = 0; f < faceCount; f++) {
- const uint32_t vertex0 = mesh->vertexAt(f * 3 + 0);
- const uint32_t vertex1 = mesh->vertexAt(f * 3 + 1);
- const uint32_t vertex2 = mesh->vertexAt(f * 3 + 2);
- setup_abf_relations(A, t, vertex0, vertex1, vertex2, mesh->position(vertex0), mesh->position(vertex1), mesh->position(vertex2));
- t++;
- }
- const uint32_t lockedParameters[] = {
- 2 * v0 + 0,
- 2 * v0 + 1,
- 2 * v1 + 0,
- 2 * v1 + 1
- };
- // Solve
- Solver::LeastSquaresSolver(A, b, x, lockedParameters, 4, 0.000001f);
- // Map x back to texcoords:
- for (uint32_t v = 0; v < vertexCount; v++) {
- mesh->texcoord(v) = Vector2(x[2 * v + 0], x[2 * v + 1]);
- XA_DEBUG_ASSERT(!isNan(mesh->texcoord(v).x));
- XA_DEBUG_ASSERT(!isNan(mesh->texcoord(v).y));
+ for (uint32_t i = 0; i < vertexCount; i++) {
+ const double u = opennl::nlGetVariable(context, 2 * i);
+ const double v = opennl::nlGetVariable(context, 2 * i + 1);
+ mesh->texcoord(i) = Vector2((float)u, (float)v);
+ XA_DEBUG_ASSERT(!isNan(mesh->texcoord(i).x));
+ XA_DEBUG_ASSERT(!isNan(mesh->texcoord(i).y));
}
+ opennl::nlDeleteContext(context);
return true;
}
#if XA_RECOMPUTE_CHARTS
-struct PiecewiseParam {
- void reset(const Mesh *mesh, uint32_t faceCount) {
+struct PiecewiseParam
+{
+ void reset(const Mesh *mesh, uint32_t faceCount)
+ {
m_mesh = mesh;
m_faceCount = faceCount;
const uint32_t vertexCount = m_mesh->vertexCount();
m_texcoords.resize(vertexCount);
m_patch.reserve(m_faceCount);
- m_faceAssigned.resize(m_faceCount);
- m_faceAssigned.zeroOutMemory();
+ m_candidates.reserve(m_faceCount);
+ m_faceInAnyPatch.resize(m_faceCount);
+ m_faceInAnyPatch.zeroOutMemory();
m_faceInvalid.resize(m_faceCount);
m_faceInPatch.resize(m_faceCount);
m_vertexInPatch.resize(vertexCount);
- m_faceInCandidates.resize(m_faceCount);
+ m_faceToCandidate.resize(m_faceCount);
}
ConstArrayView<uint32_t> chartFaces() const { return m_patch; }
const Vector2 *texcoords() const { return m_texcoords.data(); }
- bool computeChart() {
+ bool computeChart()
+ {
+ // Clear per-patch state.
m_patch.clear();
+ m_candidates.clear();
+ m_faceToCandidate.zeroOutMemory();
m_faceInvalid.zeroOutMemory();
m_faceInPatch.zeroOutMemory();
m_vertexInPatch.zeroOutMemory();
// Add the seed face (first unassigned face) to the patch.
uint32_t seed = UINT32_MAX;
for (uint32_t f = 0; f < m_faceCount; f++) {
- if (m_faceAssigned.get(f))
+ if (m_faceInAnyPatch.get(f))
continue;
seed = f;
- m_patch.push_back(seed);
- m_faceInPatch.set(seed);
- m_faceAssigned.set(seed);
+ // Add all 3 vertices.
Vector2 texcoords[3];
orthoProjectFace(seed, texcoords);
for (uint32_t i = 0; i < 3; i++) {
@@ -5840,95 +6747,104 @@ struct PiecewiseParam {
m_vertexInPatch.set(vertex);
m_texcoords[vertex] = texcoords[i];
}
+ addFaceToPatch(seed);
+ // Initialize the boundary grid.
+ m_boundaryGrid.reset(m_texcoords.data(), m_mesh->indices());
+ for (Mesh::FaceEdgeIterator it(m_mesh, seed); !it.isDone(); it.advance())
+ m_boundaryGrid.append(it.edge());
break;
}
if (seed == UINT32_MAX)
return false;
for (;;) {
- findCandidates();
- if (m_candidates.isEmpty())
- break;
- for (;;) {
- // Find the candidate with the lowest cost.
- float lowestCost = FLT_MAX;
- uint32_t bestCandidate = UINT32_MAX;
- for (uint32_t i = 0; i < m_candidates.size(); i++) {
- const Candidate &candidate = m_candidates[i];
- if (m_faceInvalid.get(candidate.face)) // A candidate face may be invalidated after is was added.
- continue;
- if (candidate.maxCost < lowestCost) {
- lowestCost = candidate.maxCost;
- bestCandidate = i;
- }
+ // Find the candidate with the lowest cost.
+ float lowestCost = FLT_MAX;
+ Candidate *bestCandidate = nullptr;
+ for (uint32_t i = 0; i < m_candidates.size(); i++) {
+ Candidate *candidate = m_candidates[i];
+ if (candidate->maxCost < lowestCost) {
+ lowestCost = candidate->maxCost;
+ bestCandidate = candidate;
}
- if (bestCandidate == UINT32_MAX)
+ }
+ if (!bestCandidate)
+ break;
+ XA_DEBUG_ASSERT(!bestCandidate->prev); // Must be head of linked candidates.
+ // Compute the position by averaging linked candidates (candidates that share the same free vertex).
+ Vector2 position(0.0f);
+ uint32_t n = 0;
+ for (CandidateIterator it(bestCandidate); !it.isDone(); it.advance()) {
+ position += it.current()->position;
+ n++;
+ }
+ position *= 1.0f / (float)n;
+ const uint32_t freeVertex = bestCandidate->vertex;
+ XA_DEBUG_ASSERT(!isNan(position.x));
+ XA_DEBUG_ASSERT(!isNan(position.y));
+ m_texcoords[freeVertex] = position;
+ // Check for flipped faces. This is also done when candidates are first added, but the averaged position of the free vertex is different now, so check again.
+ bool invalid = false;
+ for (CandidateIterator it(bestCandidate); !it.isDone(); it.advance()) {
+ const uint32_t vertex0 = m_mesh->vertexAt(meshEdgeIndex0(it.current()->patchEdge));
+ const uint32_t vertex1 = m_mesh->vertexAt(meshEdgeIndex1(it.current()->patchEdge));
+ const float freeVertexOrient = orientToEdge(m_texcoords[vertex0], m_texcoords[vertex1], position);
+ if ((it.current()->patchVertexOrient < 0.0f && freeVertexOrient < 0.0f) || (it.current()->patchVertexOrient > 0.0f && freeVertexOrient > 0.0f)) {
+ invalid = true;
break;
- // Compute the position by averaging linked candidates (candidates that share the same free vertex).
- Vector2 position(0.0f);
- uint32_t n = 0;
- for (CandidateIterator it(m_candidates, bestCandidate); !it.isDone(); it.advance()) {
- position += it.current().position;
- n++;
}
- position *= 1.0f / (float)n;
- const uint32_t freeVertex = m_candidates[bestCandidate].vertex;
- XA_DEBUG_ASSERT(!isNan(position.x));
- XA_DEBUG_ASSERT(!isNan(position.y));
- m_texcoords[freeVertex] = position;
- // Check for flipped faces. This is also done when candidates are first added, but the averaged position of the free vertex is different now, so check again.
- bool invalid = false;
- for (CandidateIterator it(m_candidates, bestCandidate); !it.isDone(); it.advance()) {
- const uint32_t vertex0 = m_mesh->vertexAt(meshEdgeIndex0(it.current().patchEdge));
- const uint32_t vertex1 = m_mesh->vertexAt(meshEdgeIndex1(it.current().patchEdge));
- const float freeVertexOrient = orientToEdge(m_texcoords[vertex0], m_texcoords[vertex1], position);
- if ((it.current().patchVertexOrient < 0.0f && freeVertexOrient < 0.0f) || (it.current().patchVertexOrient > 0.0f && freeVertexOrient > 0.0f)) {
- invalid = true;
- break;
- }
- }
- // Check for boundary intersection.
- if (!invalid) {
- m_boundaryGrid.reset(m_texcoords.data(), m_mesh->indices());
- // Add edges on the patch boundary to the grid.
- // Temporarily adding candidate faces to the patch makes it simpler to detect which edges are on the boundary.
- const uint32_t oldPatchSize = m_patch.size();
- for (CandidateIterator it(m_candidates, bestCandidate); !it.isDone(); it.advance())
- m_patch.push_back(it.current().face);
- for (uint32_t i = 0; i < m_patch.size(); i++) {
- for (Mesh::FaceEdgeIterator it(m_mesh, m_patch[i]); !it.isDone(); it.advance()) {
- const uint32_t oface = it.oppositeFace();
- if (oface == UINT32_MAX || oface >= m_faceCount || !m_faceInPatch.get(oface))
- m_boundaryGrid.append(it.edge());
- }
+ }
+ // Check for boundary intersection.
+ if (!invalid) {
+ XA_PROFILE_START(parameterizeChartsPiecewiseBoundaryIntersection)
+ // Test candidate edges that would form part of the new patch boundary.
+ // Ignore boundary edges that would become internal if the candidate faces were added to the patch.
+ Array<uint32_t> newBoundaryEdges, ignoreEdges;
+ for (CandidateIterator candidateIt(bestCandidate); !candidateIt.isDone(); candidateIt.advance()) {
+ for (Mesh::FaceEdgeIterator it(m_mesh, candidateIt.current()->face); !it.isDone(); it.advance()) {
+ const uint32_t oface = it.oppositeFace();
+ if (oface == UINT32_MAX || oface >= m_faceCount || !m_faceInPatch.get(oface))
+ newBoundaryEdges.push_back(it.edge());
+ if (oface != UINT32_MAX && oface < m_faceCount && m_faceInPatch.get(oface))
+ ignoreEdges.push_back(it.oppositeEdge());
}
- invalid = m_boundaryGrid.intersectSelf(m_mesh->epsilon());
- m_patch.resize(oldPatchSize);
- }
- if (invalid) {
- // Mark all faces of linked candidates as invalid.
- for (CandidateIterator it(m_candidates, bestCandidate); !it.isDone(); it.advance())
- m_faceInvalid.set(it.current().face);
- continue;
- }
- // Add faces to the patch.
- for (CandidateIterator it(m_candidates, bestCandidate); !it.isDone(); it.advance()) {
- m_patch.push_back(it.current().face);
- m_faceInPatch.set(it.current().face);
- m_faceAssigned.set(it.current().face);
}
+ invalid = m_boundaryGrid.intersect(m_mesh->epsilon(), newBoundaryEdges, ignoreEdges);
+ XA_PROFILE_END(parameterizeChartsPiecewiseBoundaryIntersection)
+ }
+ if (invalid) {
+ // Mark all faces of linked candidates as invalid.
+ for (CandidateIterator it(bestCandidate); !it.isDone(); it.advance())
+ m_faceInvalid.set(it.current()->face);
+ removeLinkedCandidates(bestCandidate);
+ } else {
// Add vertex to the patch.
m_vertexInPatch.set(freeVertex);
+ // Add faces to the patch.
+ for (CandidateIterator it(bestCandidate); !it.isDone(); it.advance())
+ addFaceToPatch(it.current()->face);
// Successfully added candidate face(s) to patch.
- break;
+ removeLinkedCandidates(bestCandidate);
+ // Reset the grid with all edges on the patch boundary.
+ XA_PROFILE_START(parameterizeChartsPiecewiseBoundaryIntersection)
+ m_boundaryGrid.reset(m_texcoords.data(), m_mesh->indices());
+ for (uint32_t i = 0; i < m_patch.size(); i++) {
+ for (Mesh::FaceEdgeIterator it(m_mesh, m_patch[i]); !it.isDone(); it.advance()) {
+ const uint32_t oface = it.oppositeFace();
+ if (oface == UINT32_MAX || oface >= m_faceCount || !m_faceInPatch.get(oface))
+ m_boundaryGrid.append(it.edge());
+ }
+ }
+ XA_PROFILE_END(parameterizeChartsPiecewiseBoundaryIntersection)
}
}
return true;
}
private:
- struct Candidate {
+ struct Candidate
+ {
uint32_t face, vertex;
- uint32_t next; // The next candidate with the same vertex.
+ Candidate *prev, *next; // The previous/next candidate with the same vertex.
Vector2 position;
float cost;
float maxCost; // Of all linked candidates.
@@ -5936,90 +6852,70 @@ private:
float patchVertexOrient;
};
- struct CandidateIterator {
- CandidateIterator(Array<Candidate> &candidates, uint32_t first) :
- m_candidates(candidates), m_current(first) {}
- void advance() {
- if (m_current != UINT32_MAX) m_current = m_candidates[m_current].next;
- }
- bool isDone() const { return m_current == UINT32_MAX; }
- Candidate &current() { return m_candidates[m_current]; }
+ struct CandidateIterator
+ {
+ CandidateIterator(Candidate *head) : m_current(head) { XA_DEBUG_ASSERT(!head->prev); }
+ void advance() { if (m_current != nullptr) { m_current = m_current->next; } }
+ bool isDone() const { return !m_current; }
+ Candidate *current() { return m_current; }
private:
- Array<Candidate> &m_candidates;
- uint32_t m_current;
+ Candidate *m_current;
};
const Mesh *m_mesh;
uint32_t m_faceCount;
Array<Vector2> m_texcoords;
- Array<Candidate> m_candidates;
- BitArray m_faceInCandidates;
- Array<uint32_t> m_patch;
- BitArray m_faceAssigned; // Face is assigned to a previous chart or the current patch.
- BitArray m_faceInPatch, m_vertexInPatch;
+ BitArray m_faceInAnyPatch; // Face is in a previous chart patch or the current patch.
+ Array<Candidate *> m_candidates; // Incident faces to the patch.
+ Array<Candidate *> m_faceToCandidate;
+ Array<uint32_t> m_patch; // The current chart patch.
+ BitArray m_faceInPatch, m_vertexInPatch; // Face/vertex is in the current patch.
BitArray m_faceInvalid; // Face cannot be added to the patch - flipped, cost too high or causes boundary intersection.
UniformGrid2 m_boundaryGrid;
- // Find candidate faces on the patch front.
- void findCandidates() {
- m_candidates.clear();
- m_faceInCandidates.zeroOutMemory();
- for (uint32_t i = 0; i < m_patch.size(); i++) {
- for (Mesh::FaceEdgeIterator it(m_mesh, m_patch[i]); !it.isDone(); it.advance()) {
- const uint32_t oface = it.oppositeFace();
- if (oface == UINT32_MAX || oface >= m_faceCount || m_faceAssigned.get(oface) || m_faceInCandidates.get(oface))
- continue;
- // Found an active edge on the patch front.
- // Find the free vertex (the vertex that isn't on the active edge).
- // Compute the orientation of the other patch face vertex to the active edge.
- uint32_t freeVertex = UINT32_MAX;
- float orient = 0.0f;
- for (uint32_t j = 0; j < 3; j++) {
- const uint32_t vertex = m_mesh->vertexAt(oface * 3 + j);
- if (vertex != it.vertex0() && vertex != it.vertex1()) {
- freeVertex = vertex;
- orient = orientToEdge(m_texcoords[it.vertex0()], m_texcoords[it.vertex1()], m_texcoords[m_mesh->vertexAt(m_patch[i] * 3 + j)]);
- break;
- }
- }
- XA_DEBUG_ASSERT(freeVertex != UINT32_MAX);
- // If the free vertex is already in the patch, the face is enclosed by the patch. Add the face to the patch - don't need to assign texcoords.
- if (m_vertexInPatch.get(freeVertex)) {
- freeVertex = UINT32_MAX;
- m_patch.push_back(oface);
- m_faceAssigned.set(oface);
- continue;
- }
- // Check this here rather than above so faces enclosed by the patch are always added.
- if (m_faceInvalid.get(oface))
- continue;
- addCandidateFace(it.edge(), orient, oface, it.oppositeEdge(), freeVertex);
- }
- }
- // Link candidates that share the same vertex.
- for (uint32_t i = 0; i < m_candidates.size(); i++) {
- if (m_candidates[i].next != UINT32_MAX)
+ void addFaceToPatch(uint32_t face)
+ {
+ XA_DEBUG_ASSERT(!m_faceInPatch.get(face));
+ XA_DEBUG_ASSERT(!m_faceInAnyPatch.get(face));
+ m_patch.push_back(face);
+ m_faceInPatch.set(face);
+ m_faceInAnyPatch.set(face);
+ // Find new candidate faces on the patch incident to the newly added face.
+ for (Mesh::FaceEdgeIterator it(m_mesh, face); !it.isDone(); it.advance()) {
+ const uint32_t oface = it.oppositeFace();
+ if (oface == UINT32_MAX || oface >= m_faceCount || m_faceInAnyPatch.get(oface) || m_faceToCandidate[oface])
continue;
- uint32_t current = i;
- for (uint32_t j = i + 1; j < m_candidates.size(); j++) {
- if (m_candidates[j].vertex == m_candidates[current].vertex) {
- m_candidates[current].next = j;
- current = j;
+ // Found an active edge on the patch front.
+ // Find the free vertex (the vertex that isn't on the active edge).
+ // Compute the orientation of the other patch face vertex to the active edge.
+ uint32_t freeVertex = UINT32_MAX;
+ float orient = 0.0f;
+ for (uint32_t j = 0; j < 3; j++) {
+ const uint32_t vertex = m_mesh->vertexAt(oface * 3 + j);
+ if (vertex != it.vertex0() && vertex != it.vertex1()) {
+ freeVertex = vertex;
+ orient = orientToEdge(m_texcoords[it.vertex0()], m_texcoords[it.vertex1()], m_texcoords[m_mesh->vertexAt(face * 3 + j)]);
+ break;
}
}
- }
- // Set max cost for linked candidates.
- for (uint32_t i = 0; i < m_candidates.size(); i++) {
- float maxCost = 0.0f;
- for (CandidateIterator it(m_candidates, i); !it.isDone(); it.advance())
- maxCost = max(maxCost, it.current().cost);
- for (CandidateIterator it(m_candidates, i); !it.isDone(); it.advance())
- it.current().maxCost = maxCost;
+ XA_DEBUG_ASSERT(freeVertex != UINT32_MAX);
+ // If the free vertex is already in the patch, the face is enclosed by the patch. Add the face to the patch - don't need to assign texcoords.
+ /*if (m_vertexInPatch.get(freeVertex)) {
+ freeVertex = UINT32_MAX;
+ addFaceToPatch(oface, false);
+ continue;
+ }*/
+ // Check this here rather than above so faces enclosed by the patch are always added.
+ if (m_faceInvalid.get(oface))
+ continue;
+ addCandidateFace(it.edge(), orient, oface, it.oppositeEdge(), freeVertex);
}
}
- void addCandidateFace(uint32_t patchEdge, float patchVertexOrient, uint32_t face, uint32_t edge, uint32_t freeVertex) {
+ void addCandidateFace(uint32_t patchEdge, float patchVertexOrient, uint32_t face, uint32_t edge, uint32_t freeVertex)
+ {
+ XA_DEBUG_ASSERT(!m_faceToCandidate[face]);
Vector2 texcoords[3];
orthoProjectFace(face, texcoords);
// Find corresponding vertices between the patch edge and candidate edge.
@@ -6040,8 +6936,9 @@ private:
const Vector2 localEdgeVec = texcoords[localVertex1] - texcoords[localVertex0];
const float len1 = length(patchEdgeVec);
const float len2 = length(localEdgeVec);
+ if (len1 <= 0.0f || len2 <= 0.0f)
+ return; // Zero length edge.
const float scale = len1 / len2;
- XA_ASSERT(scale > 0.0f);
for (uint32_t i = 0; i < 3; i++)
texcoords[i] *= scale;
// Translate to the first vertex on the patch edge.
@@ -6063,6 +6960,8 @@ private:
uv.x = x + texcoords[localVertex0].x;
uv.y = y + texcoords[localVertex0].y;
}
+ if (isNan(texcoords[localFreeVertex].x) || isNan(texcoords[localFreeVertex].y))
+ return;
// Check for local overlap (flipped triangle).
// The patch face vertex that isn't on the active edge and the free vertex should be oriented on opposite sides to the active edge.
const float freeVertexOrient = orientToEdge(m_texcoords[vertex0], m_texcoords[vertex1], texcoords[localFreeVertex]);
@@ -6083,19 +6982,72 @@ private:
}
#endif
// Add the candidate.
- Candidate candidate;
- candidate.face = face;
- candidate.vertex = freeVertex;
- candidate.position = texcoords[localFreeVertex];
- candidate.next = UINT32_MAX;
- candidate.cost = cost;
- candidate.patchEdge = patchEdge;
- candidate.patchVertexOrient = patchVertexOrient;
+ Candidate *candidate = XA_ALLOC(MemTag::Default, Candidate);
+ candidate->face = face;
+ candidate->vertex = freeVertex;
+ candidate->position = texcoords[localFreeVertex];
+ candidate->prev = candidate->next = nullptr;
+ candidate->cost = candidate->maxCost = cost;
+ candidate->patchEdge = patchEdge;
+ candidate->patchVertexOrient = patchVertexOrient;
m_candidates.push_back(candidate);
- m_faceInCandidates.set(face);
+ m_faceToCandidate[face] = candidate;
+ // Link with candidates that share the same vertex. Append to tail.
+ for (uint32_t i = 0; i < m_candidates.size() - 1; i++) {
+ if (m_candidates[i]->vertex == candidate->vertex) {
+ Candidate *tail = m_candidates[i];
+ for (;;) {
+ if (tail->next)
+ tail = tail->next;
+ else
+ break;
+ }
+ candidate->prev = tail;
+ candidate->next = nullptr;
+ tail->next = candidate;
+ break;
+ }
+ }
+ // Set max cost for linked candidates.
+ Candidate *head = linkedCandidateHead(candidate);
+ float maxCost = 0.0f;
+ for (CandidateIterator it(head); !it.isDone(); it.advance())
+ maxCost = max(maxCost, it.current()->cost);
+ for (CandidateIterator it(head); !it.isDone(); it.advance())
+ it.current()->maxCost = maxCost;
+ }
+
+ Candidate *linkedCandidateHead(Candidate *candidate)
+ {
+ Candidate *current = candidate;
+ for (;;) {
+ if (!current->prev)
+ break;
+ current = current->prev;
+ }
+ return current;
}
- void orthoProjectFace(uint32_t face, Vector2 *texcoords) const {
+ void removeLinkedCandidates(Candidate *head)
+ {
+ XA_DEBUG_ASSERT(!head->prev);
+ Candidate *current = head;
+ while (current) {
+ Candidate *next = current->next;
+ m_faceToCandidate[current->face] = nullptr;
+ for (uint32_t i = 0; i < m_candidates.size(); i++) {
+ if (m_candidates[i] == current) {
+ m_candidates.removeAt(i);
+ break;
+ }
+ }
+ XA_FREE(current);
+ current = next;
+ }
+ }
+
+ void orthoProjectFace(uint32_t face, Vector2 *texcoords) const
+ {
const Vector3 normal = m_mesh->computeFaceNormal(face);
const Vector3 tangent = normalize(m_mesh->position(m_mesh->vertexAt(face * 3 + 1)) - m_mesh->position(m_mesh->vertexAt(face * 3 + 0)), kEpsilon);
const Vector3 bitangent = cross(normal, tangent);
@@ -6105,14 +7057,16 @@ private:
}
}
- float parametricArea(const Vector2 *texcoords) const {
+ float parametricArea(const Vector2 *texcoords) const
+ {
const Vector2 &v1 = texcoords[0];
const Vector2 &v2 = texcoords[1];
const Vector2 &v3 = texcoords[2];
return ((v2.x - v1.x) * (v3.y - v1.y) - (v3.x - v1.x) * (v2.y - v1.y)) * 0.5f;
}
- float computeStretch(Vector3 p1, Vector3 p2, Vector3 p3, Vector2 t1, Vector2 t2, Vector2 t3) const {
+ float computeStretch(Vector3 p1, Vector3 p2, Vector3 p3, Vector2 t1, Vector2 t2, Vector2 t3) const
+ {
float parametricArea = ((t2.y - t1.y) * (t3.x - t1.x) - (t3.y - t1.y) * (t2.x - t1.x)) * 0.5f;
if (isZero(parametricArea, kAreaEpsilon))
return FLT_MAX;
@@ -6126,14 +7080,16 @@ private:
}
// Return value is positive if the point is one side of the edge, negative if on the other side.
- float orientToEdge(Vector2 edgeVertex0, Vector2 edgeVertex1, Vector2 point) const {
+ float orientToEdge(Vector2 edgeVertex0, Vector2 edgeVertex1, Vector2 point) const
+ {
return (edgeVertex0.x - point.x) * (edgeVertex1.y - point.y) - (edgeVertex0.y - point.y) * (edgeVertex1.x - point.x);
}
};
#endif
// Estimate quality of existing parameterization.
-struct Quality {
+struct Quality
+{
// computeBoundaryIntersection
bool boundaryIntersection = false;
@@ -6150,13 +7106,14 @@ struct Quality {
float conformalMetric = 0.0f;
float authalicMetric = 0.0f;
- void computeBoundaryIntersection(const Mesh *mesh, UniformGrid2 &boundaryGrid) {
+ void computeBoundaryIntersection(const Mesh *mesh, UniformGrid2 &boundaryGrid)
+ {
const Array<uint32_t> &boundaryEdges = mesh->boundaryEdges();
const uint32_t boundaryEdgeCount = boundaryEdges.size();
boundaryGrid.reset(mesh->texcoords(), mesh->indices(), boundaryEdgeCount);
for (uint32_t i = 0; i < boundaryEdgeCount; i++)
boundaryGrid.append(boundaryEdges[i]);
- boundaryIntersection = boundaryGrid.intersectSelf(mesh->epsilon());
+ boundaryIntersection = boundaryGrid.intersect(mesh->epsilon());
#if XA_DEBUG_EXPORT_BOUNDARY_GRID
static int exportIndex = 0;
char filename[256];
@@ -6166,7 +7123,8 @@ struct Quality {
#endif
}
- void computeFlippedFaces(const Mesh *mesh, uint32_t faceCount, Array<uint32_t> *flippedFaces) {
+ void computeFlippedFaces(const Mesh *mesh, uint32_t faceCount, Array<uint32_t> *flippedFaces)
+ {
totalTriangleCount = flippedTriangleCount = zeroAreaTriangleCount = 0;
if (flippedFaces)
flippedFaces->clear();
@@ -6201,7 +7159,8 @@ struct Quality {
flippedFaces->clear();
flippedTriangleCount = 0;
}
- if (flippedTriangleCount > totalTriangleCount / 2) {
+ if (flippedTriangleCount > totalTriangleCount / 2)
+ {
// If more than half the triangles are flipped, reverse the flipped / not flipped classification.
flippedTriangleCount = totalTriangleCount - flippedTriangleCount;
if (flippedFaces) {
@@ -6223,7 +7182,8 @@ struct Quality {
}
}
- void computeMetrics(const Mesh *mesh, uint32_t faceCount) {
+ void computeMetrics(const Mesh *mesh, uint32_t faceCount)
+ {
totalGeometricArea = totalParametricArea = 0.0f;
stretchMetric = maxStretchMetric = conformalMetric = authalicMetric = 0.0f;
for (uint32_t f = 0; f < faceCount; f++) {
@@ -6254,7 +7214,7 @@ struct Quality {
const float a = dot(Ss, Ss); // E
const float b = dot(Ss, St); // F
const float c = dot(St, St); // G
- // Compute eigen-values of the first fundamental form:
+ // Compute eigen-values of the first fundamental form:
const float sigma1 = sqrtf(0.5f * max(0.0f, a + c - sqrtf(square(a - c) + 4 * square(b)))); // gamma uppercase, min eigenvalue.
const float sigma2 = sqrtf(0.5f * max(0.0f, a + c + sqrtf(square(a - c) + 4 * square(b)))); // gamma lowercase, max eigenvalue.
XA_ASSERT(sigma2 > sigma1 || equal(sigma1, sigma2, kEpsilon));
@@ -6285,62 +7245,59 @@ struct Quality {
if (totalGeometricArea > 0.0f) {
const float normFactor = sqrtf(totalParametricArea / totalGeometricArea);
stretchMetric = sqrtf(stretchMetric / totalGeometricArea) * normFactor;
- maxStretchMetric *= normFactor;
+ maxStretchMetric *= normFactor;
conformalMetric = sqrtf(conformalMetric / totalGeometricArea);
authalicMetric = sqrtf(authalicMetric / totalGeometricArea);
}
}
};
-struct ChartWarningFlags {
- enum Enum {
- CloseHolesFailed = 1 << 1,
- FixTJunctionsDuplicatedEdge = 1 << 2,
- FixTJunctionsFailed = 1 << 3,
- TriangulateDuplicatedEdge = 1 << 4,
+struct ChartWarningFlags
+{
+ enum Enum
+ {
+ CloseHolesFailed = 1<<1,
+ FixTJunctionsDuplicatedEdge = 1<<2,
+ FixTJunctionsFailed = 1<<3,
+ TriangulateDuplicatedEdge = 1<<4,
};
};
-struct ChartCtorBuffers {
+struct ChartCtorBuffers
+{
Array<uint32_t> chartMeshIndices;
Array<uint32_t> unifiedMeshIndices;
Array<uint32_t> boundaryLoops;
};
-/// A chart is a connected set of faces with a certain topology (usually a disk).
-class Chart {
+class Chart
+{
public:
- Chart(ChartCtorBuffers &buffers, const Basis &basis, ConstArrayView<uint32_t> faces, const Mesh *originalMesh, uint32_t meshId, uint32_t chartGroupId, uint32_t chartId) :
- m_basis(basis), m_mesh(nullptr), m_unifiedMesh(nullptr), m_unmodifiedUnifiedMesh(nullptr), m_type(ChartType::LSCM), m_warningFlags(0), m_closedHolesCount(0), m_fixedTJunctionsCount(0) {
- XA_UNUSED(meshId);
+ Chart(ChartCtorBuffers &buffers, const ParameterizeOptions &options, const Basis &basis, ConstArrayView<uint32_t> faces, const Mesh *sourceMesh, uint32_t chartGroupId, uint32_t chartId) : m_basis(basis), m_mesh(nullptr), m_unifiedMesh(nullptr), m_unmodifiedUnifiedMesh(nullptr), m_type(ChartType::LSCM), m_warningFlags(0), m_closedHolesCount(0), m_fixedTJunctionsCount(0), m_isInvalid(false)
+ {
XA_UNUSED(chartGroupId);
XA_UNUSED(chartId);
- m_faceArray.copyFrom(faces.data, faces.length);
- // Copy face indices.
- m_mesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, originalMesh->epsilon(), m_faceArray.size() * 3, m_faceArray.size());
- m_unifiedMesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, originalMesh->epsilon(), m_faceArray.size() * 3, m_faceArray.size());
- Array<uint32_t> &chartMeshIndices = buffers.chartMeshIndices;
- chartMeshIndices.resize(originalMesh->vertexCount());
- chartMeshIndices.setAll(UINT32_MAX);
- Array<uint32_t> &unifiedMeshIndices = buffers.unifiedMeshIndices;
- unifiedMeshIndices.resize(originalMesh->vertexCount());
- unifiedMeshIndices.setAll(UINT32_MAX);
+ m_faceToSourceFaceMap.copyFrom(faces.data, faces.length);
+ const uint32_t approxVertexCount = min(faces.length * 3, sourceMesh->vertexCount());
+ m_mesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, sourceMesh->epsilon(), approxVertexCount, faces.length);
+ m_unifiedMesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, sourceMesh->epsilon(), approxVertexCount, faces.length);
+ HashMap<uint32_t, PassthroughHash<uint32_t>> sourceVertexToUnifiedVertexMap(MemTag::Mesh, approxVertexCount), sourceVertexToChartVertexMap(MemTag::Mesh, approxVertexCount);
// Add vertices.
- const uint32_t faceCount = m_initialFaceCount = m_faceArray.size();
+ const uint32_t faceCount = m_initialFaceCount = faces.length;
for (uint32_t f = 0; f < faceCount; f++) {
for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex = originalMesh->vertexAt(m_faceArray[f] * 3 + i);
- const uint32_t unifiedVertex = originalMesh->firstColocal(vertex);
- if (unifiedMeshIndices[unifiedVertex] == (uint32_t)~0) {
- unifiedMeshIndices[unifiedVertex] = m_unifiedMesh->vertexCount();
- XA_DEBUG_ASSERT(equal(originalMesh->position(vertex), originalMesh->position(unifiedVertex), originalMesh->epsilon()));
- m_unifiedMesh->addVertex(originalMesh->position(vertex));
+ const uint32_t sourceVertex = sourceMesh->vertexAt(m_faceToSourceFaceMap[f] * 3 + i);
+ const uint32_t sourceUnifiedVertex = sourceMesh->firstColocal(sourceVertex);
+ uint32_t unifiedVertex = sourceVertexToUnifiedVertexMap.get(sourceUnifiedVertex);
+ if (unifiedVertex == UINT32_MAX) {
+ unifiedVertex = sourceVertexToUnifiedVertexMap.add(sourceUnifiedVertex);
+ m_unifiedMesh->addVertex(sourceMesh->position(sourceVertex));
}
- if (chartMeshIndices[vertex] == (uint32_t)~0) {
- chartMeshIndices[vertex] = m_mesh->vertexCount();
- m_chartToOriginalMap.push_back(vertex);
- m_chartToUnifiedMap.push_back(unifiedMeshIndices[unifiedVertex]);
- m_mesh->addVertex(originalMesh->position(vertex), Vector3(0.0f), originalMesh->texcoord(vertex));
+ if (sourceVertexToChartVertexMap.get(sourceVertex) == UINT32_MAX) {
+ sourceVertexToChartVertexMap.add(sourceVertex);
+ m_vertexToSourceVertexMap.push_back(sourceVertex);
+ m_chartVertexToUnifiedVertexMap.push_back(unifiedVertex);
+ m_mesh->addVertex(sourceMesh->position(sourceVertex), Vector3(0.0f), sourceMesh->texcoord(sourceVertex));
}
}
}
@@ -6348,9 +7305,12 @@ public:
for (uint32_t f = 0; f < faceCount; f++) {
uint32_t indices[3], unifiedIndices[3];
for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex = originalMesh->vertexAt(m_faceArray[f] * 3 + i);
- indices[i] = chartMeshIndices[vertex];
- unifiedIndices[i] = unifiedMeshIndices[originalMesh->firstColocal(vertex)];
+ const uint32_t sourceVertex = sourceMesh->vertexAt(m_faceToSourceFaceMap[f] * 3 + i);
+ const uint32_t sourceUnifiedVertex = sourceMesh->firstColocal(sourceVertex);
+ indices[i] = sourceVertexToChartVertexMap.get(sourceVertex);
+ XA_DEBUG_ASSERT(indices[i] != UINT32_MAX);
+ unifiedIndices[i] = sourceVertexToUnifiedVertexMap.get(sourceUnifiedVertex);
+ XA_DEBUG_ASSERT(unifiedIndices[i] != UINT32_MAX);
}
Mesh::AddFaceResult::Enum result = m_mesh->addFace(indices);
XA_UNUSED(result);
@@ -6368,15 +7328,18 @@ public:
XA_DEBUG_ASSERT(result == Mesh::AddFaceResult::OK);
}
m_mesh->createBoundaries(); // For AtlasPacker::computeBoundingBox
+ m_mesh->destroyEdgeMap(); // Only needed it for createBoundaries.
m_unifiedMesh->createBoundaries();
- if (meshIsPlanar(*m_unifiedMesh))
+ if (meshIsPlanar(*m_unifiedMesh)) {
m_type = ChartType::Planar;
- else {
- m_unifiedMesh->linkBoundaries();
+ return;
+ }
+ m_unifiedMesh->linkBoundaries();
#if XA_DEBUG_EXPORT_OBJ_BEFORE_FIX_TJUNCTION
- m_unifiedMesh->writeObjFile("debug_before_fix_tjunction.obj");
+ m_unifiedMesh->writeObjFile("debug_before_fix_tjunction.obj");
#endif
- bool duplicatedEdge = false, failed = false;
+ bool duplicatedEdge = false, failed = false;
+ if (options.fixTJunctions) {
XA_PROFILE_START(fixChartMeshTJunctions)
Mesh *fixedUnifiedMesh = meshFixTJunctions(*m_unifiedMesh, &duplicatedEdge, &failed, &m_fixedTJunctionsCount);
XA_PROFILE_END(fixChartMeshTJunctions)
@@ -6391,6 +7354,8 @@ public:
m_unifiedMesh->linkBoundaries();
m_initialFaceCount = m_unifiedMesh->faceCount(); // Fixing t-junctions rewrites faces.
}
+ }
+ if (options.closeHoles) {
// See if there are any holes that need closing.
Array<uint32_t> &boundaryLoops = buffers.boundaryLoops;
meshGetBoundaryLoops(*m_unifiedMesh, boundaryLoops);
@@ -6421,7 +7386,7 @@ public:
#if XA_DEBUG_EXPORT_OBJ_CLOSE_HOLES_ERROR
if (m_warningFlags & ChartWarningFlags::CloseHolesFailed) {
char filename[256];
- XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_chart_%03u_close_holes_error.obj", meshId, chartGroupId, chartId);
+ XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_chart_%03u_close_holes_error.obj", sourceMesh->id(), chartGroupId, chartId);
FILE *file;
XA_FOPEN(file, filename, "w");
if (file) {
@@ -6450,88 +7415,57 @@ public:
}
#if XA_RECOMPUTE_CHARTS
- Chart(ChartCtorBuffers &buffers, const Chart *parent, const Mesh *parentMesh, ConstArrayView<uint32_t> faces, const Vector2 *texcoords, const Mesh *originalMesh, uint32_t meshId, uint32_t chartGroupId, uint32_t chartId) :
- m_mesh(nullptr), m_unifiedMesh(nullptr), m_unmodifiedUnifiedMesh(nullptr), m_type(ChartType::Piecewise), m_warningFlags(0), m_closedHolesCount(0), m_fixedTJunctionsCount(0) {
- XA_UNUSED(meshId);
- XA_UNUSED(chartGroupId);
- XA_UNUSED(chartId);
+ Chart(ChartCtorBuffers &buffers, const Chart *parent, const Mesh *parentMesh, ConstArrayView<uint32_t> faces, const Vector2 *texcoords, const Mesh *sourceMesh) : m_mesh(nullptr), m_unifiedMesh(nullptr), m_unmodifiedUnifiedMesh(nullptr), m_type(ChartType::Piecewise), m_warningFlags(0), m_closedHolesCount(0), m_fixedTJunctionsCount(0), m_isInvalid(false)
+ {
const uint32_t faceCount = m_initialFaceCount = faces.length;
- m_faceArray.resize(faceCount);
+ m_faceToSourceFaceMap.resize(faceCount);
for (uint32_t i = 0; i < faceCount; i++)
- m_faceArray[i] = parent->m_faceArray[faces[i]]; // Map faces to parent chart original mesh.
+ m_faceToSourceFaceMap[i] = parent->m_faceToSourceFaceMap[faces[i]]; // Map faces to parent chart source mesh.
// Copy face indices.
- m_mesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, originalMesh->epsilon(), m_faceArray.size() * 3, m_faceArray.size());
- m_unifiedMesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, originalMesh->epsilon(), m_faceArray.size() * 3, m_faceArray.size());
+ m_mesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, sourceMesh->epsilon(), m_faceToSourceFaceMap.size() * 3, m_faceToSourceFaceMap.size());
Array<uint32_t> &chartMeshIndices = buffers.chartMeshIndices;
- chartMeshIndices.resize(originalMesh->vertexCount());
- chartMeshIndices.setAll(UINT32_MAX);
- Array<uint32_t> &unifiedMeshIndices = buffers.unifiedMeshIndices;
- unifiedMeshIndices.resize(originalMesh->vertexCount());
- unifiedMeshIndices.setAll(UINT32_MAX);
+ chartMeshIndices.resize(sourceMesh->vertexCount());
+ chartMeshIndices.fillBytes(0xff);
// Add vertices.
for (uint32_t f = 0; f < faceCount; f++) {
for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex = originalMesh->vertexAt(m_faceArray[f] * 3 + i);
- const uint32_t unifiedVertex = originalMesh->firstColocal(vertex);
+ const uint32_t vertex = sourceMesh->vertexAt(m_faceToSourceFaceMap[f] * 3 + i);
const uint32_t parentVertex = parentMesh->vertexAt(faces[f] * 3 + i);
- if (unifiedMeshIndices[unifiedVertex] == (uint32_t)~0) {
- unifiedMeshIndices[unifiedVertex] = m_unifiedMesh->vertexCount();
- XA_DEBUG_ASSERT(equal(originalMesh->position(vertex), originalMesh->position(unifiedVertex), originalMesh->epsilon()));
- m_unifiedMesh->addVertex(originalMesh->position(vertex), Vector3(0.0f), texcoords[parentVertex]);
- }
if (chartMeshIndices[vertex] == (uint32_t)~0) {
chartMeshIndices[vertex] = m_mesh->vertexCount();
- m_chartToOriginalMap.push_back(vertex);
- m_chartToUnifiedMap.push_back(unifiedMeshIndices[unifiedVertex]);
- m_mesh->addVertex(originalMesh->position(vertex), Vector3(0.0f), texcoords[parentVertex]);
+ m_vertexToSourceVertexMap.push_back(vertex);
+ m_mesh->addVertex(sourceMesh->position(vertex), Vector3(0.0f), texcoords[parentVertex]);
}
}
}
// Add faces.
for (uint32_t f = 0; f < faceCount; f++) {
- uint32_t indices[3], unifiedIndices[3];
+ uint32_t indices[3];
for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex = originalMesh->vertexAt(m_faceArray[f] * 3 + i);
+ const uint32_t vertex = sourceMesh->vertexAt(m_faceToSourceFaceMap[f] * 3 + i);
indices[i] = chartMeshIndices[vertex];
- unifiedIndices[i] = unifiedMeshIndices[originalMesh->firstColocal(vertex)];
}
Mesh::AddFaceResult::Enum result = m_mesh->addFace(indices);
XA_UNUSED(result);
XA_DEBUG_ASSERT(result == Mesh::AddFaceResult::OK);
-#if XA_DEBUG
- // Unifying colocals may create degenerate edges. e.g. if two triangle vertices are colocal.
- for (int i = 0; i < 3; i++) {
- const uint32_t index1 = unifiedIndices[i];
- const uint32_t index2 = unifiedIndices[(i + 1) % 3];
- XA_DEBUG_ASSERT(index1 != index2);
- }
-#endif
- result = m_unifiedMesh->addFace(unifiedIndices);
- XA_UNUSED(result);
- XA_DEBUG_ASSERT(result == Mesh::AddFaceResult::OK);
}
m_mesh->createBoundaries(); // For AtlasPacker::computeBoundingBox
- m_unifiedMesh->createBoundaries();
- m_unifiedMesh->linkBoundaries();
+ m_mesh->destroyEdgeMap(); // Only needed it for createBoundaries.
+ // Need to store texcoords for backup/restore so packing can be run multiple times.
+ backupTexcoords();
}
#endif
- ~Chart() {
+ ~Chart()
+ {
if (m_mesh) {
m_mesh->~Mesh();
XA_FREE(m_mesh);
}
- if (m_unifiedMesh) {
- m_unifiedMesh->~Mesh();
- XA_FREE(m_unifiedMesh);
- }
- if (m_unmodifiedUnifiedMesh) {
- m_unmodifiedUnifiedMesh->~Mesh();
- XA_FREE(m_unmodifiedUnifiedMesh);
- }
+ destroyUnifiedMesh();
}
- const Basis &basis() const { return m_basis; }
+ bool isInvalid() const { return m_isInvalid; }
ChartType::Enum type() const { return m_type; }
uint32_t warningFlags() const { return m_warningFlags; }
uint32_t closedHolesCount() const { return m_closedHolesCount; }
@@ -6541,45 +7475,71 @@ public:
#if XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION
const Array<uint32_t> &paramFlippedFaces() const { return m_paramFlippedFaces; }
#endif
- uint32_t mapFaceToSourceFace(uint32_t i) const { return m_faceArray[i]; }
+ uint32_t mapFaceToSourceFace(uint32_t i) const { return m_faceToSourceFaceMap[i]; }
+ uint32_t mapChartVertexToSourceVertex(uint32_t i) const { return m_vertexToSourceVertexMap[i]; }
const Mesh *mesh() const { return m_mesh; }
Mesh *mesh() { return m_mesh; }
const Mesh *unifiedMesh() const { return m_unifiedMesh; }
- Mesh *unifiedMesh() { return m_unifiedMesh; }
const Mesh *unmodifiedUnifiedMesh() const { return m_unmodifiedUnifiedMesh; }
- uint32_t mapChartVertexToOriginalVertex(uint32_t i) const { return m_chartToOriginalMap[i]; }
-
- void evaluateOrthoQuality(UniformGrid2 &boundaryGrid) {
- XA_PROFILE_START(parameterizeChartsEvaluateQuality)
- m_quality.computeBoundaryIntersection(m_unifiedMesh, boundaryGrid);
- m_quality.computeFlippedFaces(m_unifiedMesh, m_initialFaceCount, nullptr);
- m_quality.computeMetrics(m_unifiedMesh, m_initialFaceCount);
- XA_PROFILE_END(parameterizeChartsEvaluateQuality)
- // Use orthogonal parameterization if quality is acceptable.
- if (!m_quality.boundaryIntersection && m_quality.totalGeometricArea > 0.0f && m_quality.stretchMetric <= 1.1f && m_quality.maxStretchMetric <= 1.25f)
- m_type = ChartType::Ortho;
- }
-
- void evaluateQuality(UniformGrid2 &boundaryGrid) {
- XA_PROFILE_START(parameterizeChartsEvaluateQuality)
- m_quality.computeBoundaryIntersection(m_unifiedMesh, boundaryGrid);
+
+ void parameterize(const ParameterizeOptions &options, UniformGrid2 &boundaryGrid)
+ {
+ XA_PROFILE_START(parameterizeChartsOrthogonal)
+ {
+ // Project vertices to plane.
+ const uint32_t vertexCount = m_unifiedMesh->vertexCount();
+ for (uint32_t i = 0; i < vertexCount; i++)
+ m_unifiedMesh->texcoord(i) = Vector2(dot(m_basis.tangent, m_unifiedMesh->position(i)), dot(m_basis.bitangent, m_unifiedMesh->position(i)));
+ }
+ XA_PROFILE_END(parameterizeChartsOrthogonal)
+ // Computing charts checks for flipped triangles and boundary intersection. Don't need to do that again here if chart is planar.
+ if (m_type != ChartType::Planar) {
+ XA_PROFILE_START(parameterizeChartsEvaluateQuality)
+ m_quality.computeBoundaryIntersection(m_unifiedMesh, boundaryGrid);
+ m_quality.computeFlippedFaces(m_unifiedMesh, m_initialFaceCount, nullptr);
+ m_quality.computeMetrics(m_unifiedMesh, m_initialFaceCount);
+ XA_PROFILE_END(parameterizeChartsEvaluateQuality)
+ // Use orthogonal parameterization if quality is acceptable.
+ if (!m_quality.boundaryIntersection && m_quality.flippedTriangleCount == 0 && m_quality.totalGeometricArea > 0.0f && m_quality.stretchMetric <= 1.1f && m_quality.maxStretchMetric <= 1.25f)
+ m_type = ChartType::Ortho;
+ }
+ if (m_type == ChartType::LSCM) {
+ XA_PROFILE_START(parameterizeChartsLSCM)
+ if (options.func) {
+ options.func(&m_unifiedMesh->position(0).x, &m_unifiedMesh->texcoord(0).x, m_unifiedMesh->vertexCount(), m_unifiedMesh->indices(), m_unifiedMesh->indexCount());
+ }
+ else
+ computeLeastSquaresConformalMap(m_unifiedMesh);
+ XA_PROFILE_END(parameterizeChartsLSCM)
+ XA_PROFILE_START(parameterizeChartsEvaluateQuality)
+ m_quality.computeBoundaryIntersection(m_unifiedMesh, boundaryGrid);
#if XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION
- m_quality.computeFlippedFaces(m_unifiedMesh, m_initialFaceCount, &m_paramFlippedFaces);
+ m_quality.computeFlippedFaces(m_unifiedMesh, m_initialFaceCount, &m_paramFlippedFaces);
#else
- m_quality.computeFlippedFaces(m_unifiedMesh, m_initialFaceCount, nullptr);
+ m_quality.computeFlippedFaces(m_unifiedMesh, m_initialFaceCount, nullptr);
#endif
- // Don't need to call computeMetrics here, that's only used in evaluateOrthoQuality to determine if quality is acceptable enough to use ortho projection.
- XA_PROFILE_END(parameterizeChartsEvaluateQuality)
- }
-
- // Transfer parameterization from unified mesh to chart mesh.
- void transferParameterization() {
+ // Don't need to call computeMetrics here, that's only used in evaluateOrthoQuality to determine if quality is acceptable enough to use ortho projection.
+ if (m_quality.boundaryIntersection || m_quality.flippedTriangleCount > 0)
+ m_isInvalid = true;
+ XA_PROFILE_END(parameterizeChartsEvaluateQuality)
+ }
+#if XA_DEBUG_ALL_CHARTS_INVALID
+ m_isInvalid = true;
+#endif
+ // Transfer parameterization from unified mesh to chart mesh.
const uint32_t vertexCount = m_mesh->vertexCount();
for (uint32_t v = 0; v < vertexCount; v++)
- m_mesh->texcoord(v) = m_unifiedMesh->texcoord(m_chartToUnifiedMap[v]);
+ m_mesh->texcoord(v) = m_unifiedMesh->texcoord(m_chartVertexToUnifiedVertexMap[v]);
+ // Can destroy unified mesh now.
+ // But not if the parameterization is invalid, the unified mesh will be needed for PiecewiseParameterization.
+ if (!m_isInvalid)
+ destroyUnifiedMesh();
+ // Need to store texcoords for backup/restore so packing can be run multiple times.
+ backupTexcoords();
}
- Vector2 computeParametricBounds() const {
+ Vector2 computeParametricBounds() const
+ {
Vector2 minCorner(FLT_MAX, FLT_MAX);
Vector2 maxCorner(-FLT_MAX, -FLT_MAX);
const uint32_t vertexCount = m_mesh->vertexCount();
@@ -6590,7 +7550,34 @@ public:
return (maxCorner - minCorner) * 0.5f;
}
+ void restoreTexcoords()
+ {
+ memcpy(m_mesh->texcoords(), m_backupTexcoords.data(), m_mesh->vertexCount() * sizeof(Vector2));
+ }
+
private:
+ void backupTexcoords()
+ {
+ m_backupTexcoords.resize(m_mesh->vertexCount());
+ memcpy(m_backupTexcoords.data(), m_mesh->texcoords(), m_mesh->vertexCount() * sizeof(Vector2));
+ }
+
+ void destroyUnifiedMesh()
+ {
+ if (m_unifiedMesh) {
+ m_unifiedMesh->~Mesh();
+ XA_FREE(m_unifiedMesh);
+ m_unifiedMesh = nullptr;
+ }
+ if (m_unmodifiedUnifiedMesh) {
+ m_unmodifiedUnifiedMesh->~Mesh();
+ XA_FREE(m_unmodifiedUnifiedMesh);
+ m_unmodifiedUnifiedMesh = nullptr;
+ }
+ // Don't need this when unified meshes are destroyed.
+ m_chartVertexToUnifiedVertexMap.destroy();
+ }
+
Basis m_basis;
Mesh *m_mesh;
Mesh *m_unifiedMesh;
@@ -6600,467 +7587,511 @@ private:
uint32_t m_initialFaceCount; // Before fixing T-junctions and/or closing holes.
uint32_t m_closedHolesCount, m_fixedTJunctionsCount;
- // List of faces of the original mesh that belong to this chart.
- Array<uint32_t> m_faceArray;
+ // List of faces of the source mesh that belong to this chart.
+ Array<uint32_t> m_faceToSourceFaceMap;
- // Map vertices of the chart mesh to vertices of the original mesh.
- Array<uint32_t> m_chartToOriginalMap;
+ // Map vertices of the chart mesh to vertices of the source mesh.
+ Array<uint32_t> m_vertexToSourceVertexMap;
- Array<uint32_t> m_chartToUnifiedMap;
+ Array<uint32_t> m_chartVertexToUnifiedVertexMap;
+
+ Array<Vector2> m_backupTexcoords;
Quality m_quality;
#if XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION
Array<uint32_t> m_paramFlippedFaces;
#endif
+ bool m_isInvalid;
};
-struct CreateChartTaskArgs {
- const Mesh *mesh;
+struct CreateAndParameterizeChartTaskArgs
+{
const Basis *basis;
+ ThreadLocal<UniformGrid2> *boundaryGrid;
+ Chart *chart; // output
+ Array<Chart *> charts; // output (if more than one chart)
+ ThreadLocal<ChartCtorBuffers> *chartBuffers;
+ const Mesh *mesh;
+ const ParameterizeOptions *options;
+#if XA_RECOMPUTE_CHARTS
+ ThreadLocal<PiecewiseParam> *pp;
+#endif
ConstArrayView<uint32_t> faces;
- uint32_t meshId;
uint32_t chartGroupId;
uint32_t chartId;
- ThreadLocal<ChartCtorBuffers> *chartBuffers;
- Chart **chart;
};
-static void runCreateChartTask(void *userData) {
- XA_PROFILE_START(createChartMeshesThread)
- auto args = (CreateChartTaskArgs *)userData;
- *(args->chart) = XA_NEW_ARGS(MemTag::Default, Chart, args->chartBuffers->get(), *(args->basis), args->faces, args->mesh, args->meshId, args->chartGroupId, args->chartId);
- XA_PROFILE_END(createChartMeshesThread)
-}
-
-struct ParameterizeChartTaskArgs {
- Chart *chart;
- ParameterizeFunc func;
- ThreadLocal<UniformGrid2> *boundaryGrid;
-};
-
-static void runParameterizeChartTask(void *userData) {
- auto args = (ParameterizeChartTaskArgs *)userData;
- Mesh *mesh = args->chart->unifiedMesh();
- XA_PROFILE_START(parameterizeChartsOrthogonal) {
- // Project vertices to plane.
- const uint32_t vertexCount = mesh->vertexCount();
- const Basis &basis = args->chart->basis();
- for (uint32_t i = 0; i < vertexCount; i++)
- mesh->texcoord(i) = Vector2(dot(basis.tangent, mesh->position(i)), dot(basis.bitangent, mesh->position(i)));
- }
- XA_PROFILE_END(parameterizeChartsOrthogonal)
- // Computing charts checks for flipped triangles and boundary intersection. Don't need to do that again here if chart is planar.
- if (args->chart->type() != ChartType::Planar)
- args->chart->evaluateOrthoQuality(args->boundaryGrid->get());
- if (args->chart->type() == ChartType::LSCM) {
- XA_PROFILE_START(parameterizeChartsLSCM)
- if (args->func)
- args->func(&mesh->position(0).x, &mesh->texcoord(0).x, mesh->vertexCount(), mesh->indices(), mesh->indexCount());
- else
- computeLeastSquaresConformalMap(mesh);
- XA_PROFILE_END(parameterizeChartsLSCM)
- args->chart->evaluateQuality(args->boundaryGrid->get());
+static void runCreateAndParameterizeChartTask(void *userData)
+{
+ auto args = (CreateAndParameterizeChartTaskArgs *)userData;
+ XA_PROFILE_START(createChartMesh)
+ args->chart = XA_NEW_ARGS(MemTag::Default, Chart, args->chartBuffers->get(), *args->options, *args->basis, args->faces, args->mesh, args->chartGroupId, args->chartId);
+ XA_PROFILE_END(createChartMesh)
+ args->chart->parameterize(*args->options, args->boundaryGrid->get());
+#if XA_RECOMPUTE_CHARTS
+ if (!args->chart->isInvalid())
+ return;
+ // Recompute charts with invalid parameterizations.
+ XA_PROFILE_START(parameterizeChartsRecompute)
+ Chart *invalidChart = args->chart;
+ // Fixing t-junctions rewrites unified mesh faces, and we need to map faces back to input mesh. So use the unmodified unified mesh.
+ const Mesh *invalidMesh = invalidChart->unmodifiedUnifiedMesh();
+ uint32_t faceCount = 0;
+ if (invalidMesh) {
+ faceCount = invalidMesh->faceCount();
+ } else {
+ invalidMesh = invalidChart->unifiedMesh();
+ faceCount = invalidChart->initialFaceCount(); // Not invalidMesh->faceCount(). Don't want faces added by hole closing.
}
- // Transfer parameterization from unified mesh to chart mesh.
- args->chart->transferParameterization();
-}
-
-// Set of charts corresponding to mesh faces in the same face group.
-class ChartGroup {
-public:
- ChartGroup(uint32_t id, const Mesh *sourceMesh, uint16_t faceGroup) :
- m_sourceId(sourceMesh->id()), m_id(id), m_isVertexMap(faceGroup == Mesh::kInvalidFaceGroup), m_paramAddedChartsCount(0), m_paramDeletedChartsCount(0) {
- // Create new mesh from the source mesh, using faces that belong to this group.
- const uint32_t sourceFaceCount = sourceMesh->faceCount();
- if (!m_isVertexMap) {
- m_faceToSourceFaceMap.reserve(sourceMesh->faceGroupFaceCount(faceGroup));
- for (Mesh::GroupFaceIterator it(sourceMesh, faceGroup); !it.isDone(); it.advance())
- m_faceToSourceFaceMap.push_back(it.face());
- } else {
- for (uint32_t f = 0; f < sourceFaceCount; f++) {
- if (sourceMesh->faceGroupAt(f) == faceGroup)
- m_faceToSourceFaceMap.push_back(f);
+ PiecewiseParam &pp = args->pp->get();
+ pp.reset(invalidMesh, faceCount);
+#if XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS
+ char filename[256];
+ XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_chart_%03u_recomputed.obj", args->mesh->id(), args->chartGroupId, args->chartId);
+ FILE *file;
+ XA_FOPEN(file, filename, "w");
+ uint32_t subChartIndex = 0;
+#endif
+ for (;;) {
+ XA_PROFILE_START(parameterizeChartsPiecewise)
+ const bool facesRemaining = pp.computeChart();
+ XA_PROFILE_END(parameterizeChartsPiecewise)
+ if (!facesRemaining)
+ break;
+ Chart *chart = XA_NEW_ARGS(MemTag::Default, Chart, args->chartBuffers->get(), invalidChart, invalidMesh, pp.chartFaces(), pp.texcoords(), args->mesh);
+ args->charts.push_back(chart);
+#if XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS
+ if (file) {
+ for (uint32_t j = 0; j < invalidMesh->vertexCount(); j++) {
+ fprintf(file, "v %g %g %g\n", invalidMesh->position(j).x, invalidMesh->position(j).y, invalidMesh->position(j).z);
+ fprintf(file, "vt %g %g\n", pp.texcoords()[j].x, pp.texcoords()[j].y);
}
- }
- // Only initial meshes have face groups and ignored faces. The only flag we care about is HasNormals.
- const uint32_t faceCount = m_faceToSourceFaceMap.size();
- XA_DEBUG_ASSERT(faceCount > 0);
- const uint32_t approxVertexCount = faceCount * 3;
- m_mesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, sourceMesh->epsilon(), approxVertexCount, faceCount, sourceMesh->flags() & MeshFlags::HasNormals);
- m_vertexToSourceVertexMap.reserve(approxVertexCount);
- HashMap<uint32_t> sourceVertexToVertexMap(MemTag::Mesh, approxVertexCount);
- for (uint32_t f = 0; f < faceCount; f++) {
- const uint32_t face = m_faceToSourceFaceMap[f];
- for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex = sourceMesh->vertexAt(face * 3 + i);
- if (sourceVertexToVertexMap.get(vertex) == UINT32_MAX) {
- sourceVertexToVertexMap.add(vertex);
- m_vertexToSourceVertexMap.push_back(vertex);
- Vector3 normal(0.0f);
- if (sourceMesh->flags() & MeshFlags::HasNormals)
- normal = sourceMesh->normal(vertex);
- m_mesh->addVertex(sourceMesh->position(vertex), normal, sourceMesh->texcoord(vertex));
+ fprintf(file, "o chart%03u\n", subChartIndex);
+ fprintf(file, "s off\n");
+ for (uint32_t f = 0; f < pp.chartFaces().length; f++) {
+ fprintf(file, "f ");
+ const uint32_t face = pp.chartFaces()[f];
+ for (uint32_t j = 0; j < 3; j++) {
+ const uint32_t index = invalidMesh->vertexCount() * subChartIndex + invalidMesh->vertexAt(face * 3 + j) + 1; // 1-indexed
+ fprintf(file, "%d/%d/%c", index, index, j == 2 ? '\n' : ' ');
}
}
}
- // Add faces.
- for (uint32_t f = 0; f < faceCount; f++) {
- const uint32_t face = m_faceToSourceFaceMap[f];
- uint32_t indices[3];
- for (uint32_t i = 0; i < 3; i++) {
- const uint32_t vertex = sourceMesh->vertexAt(face * 3 + i);
- indices[i] = sourceVertexToVertexMap.get(vertex);
- XA_DEBUG_ASSERT(indices[i] != UINT32_MAX);
- }
- // Don't copy flags, it doesn't matter if a face is ignored after this point. All ignored faces get their own vertex map (m_isVertexMap) ChartGroup.
- // Don't hash edges if m_isVertexMap, they may be degenerate.
- Mesh::AddFaceResult::Enum result = m_mesh->addFace(indices, false, !m_isVertexMap);
- XA_UNUSED(result);
- XA_DEBUG_ASSERT(result == Mesh::AddFaceResult::OK);
- }
- if (!m_isVertexMap) {
- m_mesh->createColocals();
- m_mesh->createBoundaries();
- }
-#if XA_DEBUG_EXPORT_OBJ_CHART_GROUPS
- char filename[256];
- XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u.obj", m_sourceId, m_id);
- m_mesh->writeObjFile(filename);
-#else
- XA_UNUSED(m_id);
+ subChartIndex++;
+#endif
+ }
+#if XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS
+ if (file)
+ fclose(file);
#endif
+ XA_PROFILE_END(parameterizeChartsRecompute)
+#endif // XA_RECOMPUTE_CHARTS
+}
+
+// Set of charts corresponding to mesh faces in the same face group.
+class ChartGroup
+{
+public:
+ ChartGroup(uint32_t id, const Mesh *sourceMesh, const MeshFaceGroups *sourceMeshFaceGroups, MeshFaceGroups::Handle faceGroup) : m_id(id), m_sourceMesh(sourceMesh), m_sourceMeshFaceGroups(sourceMeshFaceGroups), m_faceGroup(faceGroup), m_faceCount(0), m_paramAddedChartsCount(0), m_paramDeletedChartsCount(0)
+ {
}
- ~ChartGroup() {
- m_mesh->~Mesh();
- XA_FREE(m_mesh);
+ ~ChartGroup()
+ {
for (uint32_t i = 0; i < m_charts.size(); i++) {
m_charts[i]->~Chart();
XA_FREE(m_charts[i]);
}
}
+ uint32_t segmentChartCount() const { return m_chartBasis.size(); }
uint32_t chartCount() const { return m_charts.size(); }
Chart *chartAt(uint32_t i) const { return m_charts[i]; }
+ uint32_t faceCount() const { return m_faceCount; }
uint32_t paramAddedChartsCount() const { return m_paramAddedChartsCount; }
uint32_t paramDeletedChartsCount() const { return m_paramDeletedChartsCount; }
- bool isVertexMap() const { return m_isVertexMap; }
- uint32_t mapFaceToSourceFace(uint32_t face) const { return m_faceToSourceFaceMap[face]; }
- uint32_t mapVertexToSourceVertex(uint32_t i) const { return m_vertexToSourceVertexMap[i]; }
- const Mesh *mesh() const { return m_mesh; }
- /*
- Compute charts using a simple segmentation algorithm.
-
- LSCM:
- - identify sharp features using local dihedral angles.
- - identify seed faces farthest from sharp features.
- - grow charts from these seeds.
-
- MCGIM:
- - phase 1: chart growth
- - grow all charts simultaneously using dijkstra search on the dual graph of the mesh.
- - graph edges are weighted based on planarity metric.
- - metric uses distance to global chart normal.
- - terminate when all faces have been assigned.
- - phase 2: seed computation:
- - place new seed of the chart at the most interior face.
- - most interior is evaluated using distance metric only.
-
- - method repeates the two phases, until the location of the seeds does not change.
- - cycles are detected by recording all the previous seeds and chartification terminates.
-
- D-Charts:
-
- - Uniaxial conic metric:
- - N_c = axis of the generalized cone that best fits the chart. (cone can a be cylinder or a plane).
- - omega_c = angle between the face normals and the axis.
- - Fitting error between chart C and tringle t: F(c,t) = (N_c*n_t - cos(omega_c))^2
-
- - Compactness metrics:
- - Roundness:
- - C(c,t) = pi * D(S_c,t)^2 / A_c
- - S_c = chart seed.
- - D(S_c,t) = length of the shortest path inside the chart betwen S_c and t.
- - A_c = chart area.
- - Straightness:
- - P(c,t) = l_out(c,t) / l_in(c,t)
- - l_out(c,t) = lenght of the edges not shared between C and t.
- - l_in(c,t) = lenght of the edges shared between C and t.
-
- - Combined metric:
- - Cost(c,t) = F(c,t)^alpha + C(c,t)^beta + P(c,t)^gamma
- - alpha = 1, beta = 0.7, gamma = 0.5
-
- Our basic approach:
- - Just one iteration of k-means?
- - Avoid dijkstra by greedily growing charts until a threshold is met. Increase threshold and repeat until no faces left.
- - If distortion metric is too high, split chart, add two seeds.
- - If chart size is low, try removing chart.
-
- Postprocess:
- - If topology is not disk:
- - Fill holes, if new faces fit proxy.
- - Find best cut, otherwise.
- - After parameterization:
- - If boundary self-intersects:
- - cut chart along the closest two diametral boundary vertices, repeat parametrization.
- - what if the overlap is on an appendix? How do we find that out and cut appropiately?
- - emphasize roundness metrics to prevent those cases.
- - If interior self-overlaps: preserve boundary parameterization and use mean-value map.
- */
- void computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, segment::Atlas &atlas, ThreadLocal<ChartCtorBuffers> *chartBuffers) {
- m_chartOptions = options;
- // This function may be called multiple times, so destroy existing charts.
- for (uint32_t i = 0; i < m_charts.size(); i++) {
- m_charts[i]->~Chart();
- XA_FREE(m_charts[i]);
- }
- m_charts.clear();
+ void computeChartFaces(const ChartOptions &options, segment::Atlas &atlas)
+ {
+ // Create mesh from source mesh, using only the faces in this face group.
+ XA_PROFILE_START(createChartGroupMesh)
+ Mesh *mesh = createMesh();
+ XA_PROFILE_END(createChartGroupMesh)
+ // Segment mesh into charts (arrays of faces).
#if XA_DEBUG_SINGLE_CHART
- Array<uint32_t> chartFaces;
- chartFaces.resize(m_mesh->faceCount());
- for (uint32_t i = 0; i < chartFaces.size(); i++)
- chartFaces[i] = i;
- Chart *chart = XA_NEW_ARGS(MemTag::Default, Chart, m_mesh, chartFaces, m_sourceId, m_id, 0);
- m_charts.push_back(chart);
+ m_chartBasis.resize(1);
+ Fit::computeBasis(&mesh->position(0), mesh->vertexCount(), &m_chartBasis[0]);
+ m_chartFaces.resize(1 + mesh->faceCount());
+ m_chartFaces[0] = mesh->faceCount();
+ for (uint32_t i = 0; i < m_chartFaces.size(); i++)
+ m_chartFaces[i + 1] = i;
#else
XA_PROFILE_START(buildAtlas)
- atlas.reset(m_sourceId, m_id, m_mesh, options);
- buildAtlas(atlas, options);
+ atlas.reset(mesh, options);
+ atlas.compute();
XA_PROFILE_END(buildAtlas)
- const uint32_t chartCount = atlas.chartCount();
- m_charts.resize(chartCount);
- Array<CreateChartTaskArgs> taskArgs;
- taskArgs.resize(chartCount);
- for (uint32_t i = 0; i < chartCount; i++) {
- CreateChartTaskArgs &args = taskArgs[i];
- args.basis = &atlas.chartBasis(i);
- args.faces = atlas.chartFaces(i);
- args.mesh = m_mesh;
- args.meshId = m_sourceId;
- args.chartGroupId = m_id;
- args.chartId = i;
- args.chartBuffers = chartBuffers;
- args.chart = &m_charts[i];
- }
- XA_PROFILE_START(createChartMeshesReal)
- TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(chartCount);
- for (uint32_t i = 0; i < chartCount; i++) {
- Task task;
- task.userData = &taskArgs[i];
- task.func = runCreateChartTask;
- taskScheduler->run(taskGroup, task);
- }
- taskScheduler->wait(&taskGroup);
- XA_PROFILE_END(createChartMeshesReal)
-#endif
#if XA_DEBUG_EXPORT_OBJ_CHARTS
char filename[256];
- XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_charts.obj", m_sourceId, m_id);
+ XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_charts.obj", m_sourceMesh->id(), m_id);
FILE *file;
XA_FOPEN(file, filename, "w");
if (file) {
- m_mesh->writeObjVertices(file);
- for (uint32_t i = 0; i < chartCount; i++) {
+ mesh->writeObjVertices(file);
+ for (uint32_t i = 0; i < atlas.chartCount(); i++) {
fprintf(file, "o chart_%04d\n", i);
fprintf(file, "s off\n");
- const Array<uint32_t> &faces = builder.chartFaces(i);
- for (uint32_t f = 0; f < faces.size(); f++)
- m_mesh->writeObjFace(file, faces[f]);
+ ConstArrayView<uint32_t> faces = atlas.chartFaces(i);
+ for (uint32_t f = 0; f < faces.length; f++)
+ mesh->writeObjFace(file, faces[f]);
}
- m_mesh->writeObjBoundaryEges(file);
- m_mesh->writeObjLinkedBoundaries(file);
+ mesh->writeObjBoundaryEges(file);
+ mesh->writeObjLinkedBoundaries(file);
fclose(file);
}
#endif
+ // Destroy mesh.
+ const uint32_t faceCount = mesh->faceCount();
+ mesh->~Mesh();
+ XA_FREE(mesh);
+ XA_PROFILE_START(copyChartFaces)
+ // Copy basis.
+ const uint32_t chartCount = atlas.chartCount();
+ m_chartBasis.resize(chartCount);
+ for (uint32_t i = 0; i < chartCount; i++)
+ m_chartBasis[i] = atlas.chartBasis(i);
+ // Copy faces from segment::Atlas to m_chartFaces array with <chart 0 face count> <face 0> <face n> <chart 1 face count> etc. encoding.
+ // segment::Atlas faces refer to the chart group mesh. Map them to the input mesh instead.
+ m_chartFaces.resize(chartCount + faceCount);
+ uint32_t offset = 0;
+ for (uint32_t i = 0; i < chartCount; i++) {
+ ConstArrayView<uint32_t> faces = atlas.chartFaces(i);
+ m_chartFaces[offset++] = faces.length;
+ for (uint32_t j = 0; j < faces.length; j++)
+ m_chartFaces[offset++] = m_faceToSourceFaceMap[faces[j]];
+ }
+ XA_PROFILE_END(copyChartFaces)
+#endif
}
#if XA_RECOMPUTE_CHARTS
- void parameterizeCharts(TaskScheduler *taskScheduler, ParameterizeFunc func, ThreadLocal<UniformGrid2> *boundaryGrid, ThreadLocal<ChartCtorBuffers> *chartBuffers, ThreadLocal<PiecewiseParam> *piecewiseParam)
+ void parameterizeCharts(TaskScheduler *taskScheduler, const ParameterizeOptions &options, ThreadLocal<UniformGrid2> *boundaryGrid, ThreadLocal<ChartCtorBuffers> *chartBuffers, ThreadLocal<PiecewiseParam> *piecewiseParam)
#else
- void parameterizeCharts(TaskScheduler *taskScheduler, ParameterizeFunc func, ThreadLocal<UniformGrid2> *boundaryGrid, ThreadLocal<ChartCtorBuffers> * /*chartBuffers*/)
+ void parameterizeCharts(TaskScheduler* taskScheduler, const ParameterizeOptions &options, ThreadLocal<UniformGrid2>* boundaryGrid, ThreadLocal<ChartCtorBuffers>* chartBuffers)
#endif
{
+ // This function may be called multiple times, so destroy existing charts.
+ for (uint32_t i = 0; i < m_charts.size(); i++) {
+ m_charts[i]->~Chart();
+ XA_FREE(m_charts[i]);
+ }
m_paramAddedChartsCount = 0;
- const uint32_t chartCount = m_charts.size();
- Array<ParameterizeChartTaskArgs> taskArgs;
+ const uint32_t chartCount = m_chartBasis.size();
+ Array<CreateAndParameterizeChartTaskArgs> taskArgs;
taskArgs.resize(chartCount);
+ taskArgs.runCtors(); // Has Array member.
TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(chartCount);
+ uint32_t offset = 0;
for (uint32_t i = 0; i < chartCount; i++) {
- ParameterizeChartTaskArgs &args = taskArgs[i];
- args.chart = m_charts[i];
- args.func = func;
+ CreateAndParameterizeChartTaskArgs &args = taskArgs[i];
+ args.basis = &m_chartBasis[i];
args.boundaryGrid = boundaryGrid;
+ args.chart = nullptr;
+ args.chartGroupId = m_id;
+ args.chartId = i;
+ args.chartBuffers = chartBuffers;
+ const uint32_t faceCount = m_chartFaces[offset++];
+ args.faces = ConstArrayView<uint32_t>(&m_chartFaces[offset], faceCount);
+ offset += faceCount;
+ args.mesh = m_sourceMesh;
+ args.options = &options;
+#if XA_RECOMPUTE_CHARTS
+ args.pp = piecewiseParam;
+#endif
Task task;
task.userData = &args;
- task.func = runParameterizeChartTask;
+ task.func = runCreateAndParameterizeChartTask;
taskScheduler->run(taskGroup, task);
}
taskScheduler->wait(&taskGroup);
#if XA_RECOMPUTE_CHARTS
- // Find charts with invalid parameterizations.
- Array<Chart *> invalidCharts;
+ // Count charts. Skip invalid ones and include new ones added by recomputing.
+ uint32_t newChartCount = 0;
for (uint32_t i = 0; i < chartCount; i++) {
- Chart *chart = m_charts[i];
- const Quality &quality = chart->quality();
- if (quality.boundaryIntersection || quality.flippedTriangleCount > 0)
- invalidCharts.push_back(chart);
+ if (taskArgs[i].chart->isInvalid())
+ newChartCount += taskArgs[i].charts.size();
+ else
+ newChartCount++;
}
- if (invalidCharts.isEmpty())
- return;
- // Recompute charts with invalid parameterizations.
- PiecewiseParam &pp = piecewiseParam->get();
- for (uint32_t i = 0; i < invalidCharts.size(); i++) {
- Chart *invalidChart = invalidCharts[i];
- // Fixing t-junctions rewrites unified mesh faces, and we need to map faces back to input mesh. So use the unmodified unified mesh.
- const Mesh *invalidMesh = invalidChart->unmodifiedUnifiedMesh();
- uint32_t faceCount = 0;
- if (invalidMesh) {
- faceCount = invalidMesh->faceCount();
- } else {
- invalidMesh = invalidChart->unifiedMesh();
- faceCount = invalidChart->initialFaceCount(); // Not invalidMesh->faceCount(). Don't want faces added by hole closing.
+ m_charts.resize(newChartCount);
+ // Add valid charts first. Destroy invalid ones.
+ uint32_t current = 0;
+ for (uint32_t i = 0; i < chartCount; i++) {
+ Chart *chart = taskArgs[i].chart;
+ if (chart->isInvalid()) {
+ chart->~Chart();
+ XA_FREE(chart);
+ m_paramDeletedChartsCount++;
+ continue;
}
- pp.reset(invalidMesh, faceCount);
-#if XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS
- char filename[256];
- XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u_recomputed_chart_%03u.obj", m_sourceId, m_id, m_paramAddedChartsCount);
- FILE *file;
- XA_FOPEN(file, filename, "w");
- uint32_t subChartIndex = 0;
-#endif
- for (;;) {
- if (!pp.computeChart())
- break;
- Chart *chart = XA_NEW_ARGS(MemTag::Default, Chart, chartBuffers->get(), invalidChart, invalidMesh, pp.chartFaces(), pp.texcoords(), m_mesh, m_sourceId, m_id, m_charts.size());
- m_charts.push_back(chart);
-#if XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS
- if (file) {
- for (uint32_t j = 0; j < invalidMesh->vertexCount(); j++) {
- fprintf(file, "v %g %g %g\n", invalidMesh->position(j).x, invalidMesh->position(j).y, invalidMesh->position(j).z);
- fprintf(file, "vt %g %g\n", pp.texcoords()[j].x, pp.texcoords()[j].y);
- }
- fprintf(file, "o chart%03u\n", subChartIndex);
- fprintf(file, "s off\n");
- for (uint32_t f = 0; f < pp.chartFaces().length; f++) {
- fprintf(file, "f ");
- const uint32_t face = pp.chartFaces()[f];
- for (uint32_t j = 0; j < 3; j++) {
- const uint32_t index = invalidMesh->vertexCount() * subChartIndex + invalidMesh->vertexAt(face * 3 + j) + 1; // 1-indexed
- fprintf(file, "%d/%d/%c", index, index, j == 2 ? '\n' : ' ');
- }
- }
- }
- subChartIndex++;
-#endif
+ m_charts[current++] = chart;
+ }
+ // Now add new charts.
+ for (uint32_t i = 0; i < chartCount; i++) {
+ CreateAndParameterizeChartTaskArgs &args = taskArgs[i];
+ for (uint32_t j = 0; j < args.charts.size(); j++) {
+ m_charts[current++] = args.charts[j];
m_paramAddedChartsCount++;
}
-#if XA_DEBUG_EXPORT_OBJ_RECOMPUTED_CHARTS
- if (file)
- fclose(file);
-#endif
- }
- // Remove and delete the invalid charts.
- for (uint32_t i = 0; i < invalidCharts.size(); i++) {
- Chart *chart = invalidCharts[i];
- removeChart(chart);
- chart->~Chart();
- XA_FREE(chart);
- m_paramDeletedChartsCount++;
}
+#else // XA_RECOMPUTE_CHARTS
+ m_charts.resize(chartCount);
+ for (uint32_t i = 0; i < chartCount; i++)
+ m_charts[i] = taskArgs[i].chart;
#endif // XA_RECOMPUTE_CHARTS
+ taskArgs.runDtors(); // Has Array member.
}
private:
- void buildAtlas(segment::Atlas &atlas, const ChartOptions &options) {
- if (atlas.facesLeft() == 0)
- return;
- // Create initial charts greedely.
- atlas.placeSeeds(options.maxThreshold * 0.5f);
- if (options.maxIterations == 0) {
- XA_DEBUG_ASSERT(atlas.facesLeft() == 0);
- return;
- }
- atlas.relocateSeeds();
- atlas.resetCharts();
- // Restart process growing charts in parallel.
- uint32_t iteration = 0;
- for (;;) {
- atlas.growCharts(options.maxThreshold);
- // When charts cannot grow more: fill holes, merge charts, relocate seeds and start new iteration.
- atlas.fillHoles(options.maxThreshold * 0.5f);
-#if XA_MERGE_CHARTS
- atlas.mergeCharts();
-#endif
- if (++iteration == options.maxIterations)
- break;
- if (!atlas.relocateSeeds())
- break;
- atlas.resetCharts();
+ Mesh *createMesh()
+ {
+ XA_DEBUG_ASSERT(m_faceGroup != MeshFaceGroups::kInvalid);
+ // Create new mesh from the source mesh, using faces that belong to this group.
+ m_faceToSourceFaceMap.reserve(m_sourceMeshFaceGroups->faceCount(m_faceGroup));
+ for (MeshFaceGroups::Iterator it(m_sourceMeshFaceGroups, m_faceGroup); !it.isDone(); it.advance())
+ m_faceToSourceFaceMap.push_back(it.face());
+ // Only initial meshes has ignored faces. The only flag we care about is HasNormals.
+ const uint32_t faceCount = m_faceCount = m_faceToSourceFaceMap.size();
+ XA_DEBUG_ASSERT(faceCount > 0);
+ const uint32_t approxVertexCount = min(faceCount * 3, m_sourceMesh->vertexCount());
+ Mesh *mesh = XA_NEW_ARGS(MemTag::Mesh, Mesh, m_sourceMesh->epsilon(), approxVertexCount, faceCount, m_sourceMesh->flags() & MeshFlags::HasNormals);
+ HashMap<uint32_t, PassthroughHash<uint32_t>> sourceVertexToVertexMap(MemTag::Mesh, approxVertexCount);
+ for (uint32_t f = 0; f < faceCount; f++) {
+ const uint32_t face = m_faceToSourceFaceMap[f];
+ for (uint32_t i = 0; i < 3; i++) {
+ const uint32_t vertex = m_sourceMesh->vertexAt(face * 3 + i);
+ if (sourceVertexToVertexMap.get(vertex) == UINT32_MAX) {
+ sourceVertexToVertexMap.add(vertex);
+ Vector3 normal(0.0f);
+ if (m_sourceMesh->flags() & MeshFlags::HasNormals)
+ normal = m_sourceMesh->normal(vertex);
+ mesh->addVertex(m_sourceMesh->position(vertex), normal, m_sourceMesh->texcoord(vertex));
+ }
+ }
}
- // Make sure no holes are left!
- XA_DEBUG_ASSERT(atlas.facesLeft() == 0);
- }
-
- void removeChart(const Chart *chart) {
- for (uint32_t i = 0; i < m_charts.size(); i++) {
- if (m_charts[i] == chart) {
- m_charts.removeAt(i);
- return;
+ // Add faces.
+ for (uint32_t f = 0; f < faceCount; f++) {
+ const uint32_t face = m_faceToSourceFaceMap[f];
+ XA_DEBUG_ASSERT(!m_sourceMesh->isFaceIgnored(face));
+ uint32_t indices[3];
+ for (uint32_t i = 0; i < 3; i++) {
+ const uint32_t vertex = m_sourceMesh->vertexAt(face * 3 + i);
+ indices[i] = sourceVertexToVertexMap.get(vertex);
+ XA_DEBUG_ASSERT(indices[i] != UINT32_MAX);
}
+ // Don't copy flags - ignored faces aren't used by chart groups, they are handled by InvalidMeshGeometry.
+ Mesh::AddFaceResult::Enum result = mesh->addFace(indices);
+ XA_UNUSED(result);
+ XA_DEBUG_ASSERT(result == Mesh::AddFaceResult::OK);
}
+ XA_PROFILE_START(createChartGroupMeshColocals)
+ mesh->createColocals();
+ XA_PROFILE_END(createChartGroupMeshColocals)
+ XA_PROFILE_START(createChartGroupMeshBoundaries)
+ mesh->createBoundaries();
+ mesh->destroyEdgeMap(); // Only needed it for createBoundaries.
+ XA_PROFILE_END(createChartGroupMeshBoundaries)
+#if XA_DEBUG_EXPORT_OBJ_CHART_GROUPS
+ char filename[256];
+ XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u_chartgroup_%03u.obj", m_sourceMesh->id(), m_id);
+ mesh->writeObjFile(filename);
+#endif
+ return mesh;
}
- uint32_t m_sourceId, m_id;
- bool m_isVertexMap;
- Mesh *m_mesh;
+ const uint32_t m_id;
+ const Mesh * const m_sourceMesh;
+ const MeshFaceGroups * const m_sourceMeshFaceGroups;
+ const MeshFaceGroups::Handle m_faceGroup;
Array<uint32_t> m_faceToSourceFaceMap; // List of faces of the source mesh that belong to this chart group.
- Array<uint32_t> m_vertexToSourceVertexMap; // Map vertices of the mesh to vertices of the source mesh.
+ Array<Basis> m_chartBasis; // Copied from segment::Atlas.
+ Array<uint32_t> m_chartFaces; // Copied from segment::Atlas. Encoding: <chart 0 face count> <face 0> <face n> <chart 1 face count> etc.
Array<Chart *> m_charts;
- ChartOptions m_chartOptions;
+ uint32_t m_faceCount; // Set by createMesh(). Used for sorting.
uint32_t m_paramAddedChartsCount; // Number of new charts added by recomputing charts with invalid parameterizations.
uint32_t m_paramDeletedChartsCount; // Number of charts with invalid parameterizations that were deleted, after charts were recomputed.
};
-struct CreateChartGroupTaskArgs {
- uint16_t faceGroup;
- uint32_t groupId;
- const Mesh *mesh;
- ChartGroup **chartGroup;
+// References invalid faces and vertices in a mesh.
+struct InvalidMeshGeometry
+{
+ // Invalid faces have the face groups MeshFaceGroups::kInvalid.
+ void extract(const Mesh *mesh, const MeshFaceGroups *meshFaceGroups)
+ {
+ // Copy invalid faces.
+ m_faces.clear();
+ const uint32_t meshFaceCount = mesh->faceCount();
+ for (uint32_t f = 0; f < meshFaceCount; f++) {
+ if (meshFaceGroups->groupAt(f) == MeshFaceGroups::kInvalid)
+ m_faces.push_back(f);
+ }
+ // Create *unique* list of vertices of invalid faces.
+ const uint32_t faceCount = m_faces.size();
+ m_indices.resize(faceCount * 3);
+ const uint32_t approxVertexCount = min(faceCount * 3, mesh->vertexCount());
+ m_vertexToSourceVertexMap.clear();
+ m_vertexToSourceVertexMap.reserve(approxVertexCount);
+ HashMap<uint32_t, PassthroughHash<uint32_t>> sourceVertexToVertexMap(MemTag::Mesh, approxVertexCount);
+ for (uint32_t f = 0; f < faceCount; f++) {
+ const uint32_t face = m_faces[f];
+ for (uint32_t i = 0; i < 3; i++) {
+ const uint32_t vertex = mesh->vertexAt(face * 3 + i);
+ uint32_t newVertex = sourceVertexToVertexMap.get(vertex);
+ if (newVertex == UINT32_MAX) {
+ newVertex = sourceVertexToVertexMap.add(vertex);
+ m_vertexToSourceVertexMap.push_back(vertex);
+ }
+ m_indices[f * 3 + i] = newVertex;
+ }
+ }
+ }
+
+ ConstArrayView<uint32_t> faces() const { return m_faces; }
+ ConstArrayView<uint32_t> indices() const { return m_indices; }
+ ConstArrayView<uint32_t> vertices() const { return m_vertexToSourceVertexMap; }
+
+private:
+ Array<uint32_t> m_faces, m_indices;
+ Array<uint32_t> m_vertexToSourceVertexMap; // Map face vertices to vertices of the source mesh.
};
-static void runCreateChartGroupTask(void *userData) {
- XA_PROFILE_START(addMeshCreateChartGroupsThread)
- auto args = (CreateChartGroupTaskArgs *)userData;
- *(args->chartGroup) = XA_NEW_ARGS(MemTag::Default, ChartGroup, args->groupId, args->mesh, args->faceGroup);
- XA_PROFILE_END(addMeshCreateChartGroupsThread)
+struct ChartGroupComputeChartFacesTaskArgs
+{
+ ThreadLocal<segment::Atlas> *atlas;
+ ChartGroup *chartGroup;
+ const ChartOptions *options;
+ Progress *progress;
+};
+
+static void runChartGroupComputeChartFacesJob(void *userData)
+{
+ auto args = (ChartGroupComputeChartFacesTaskArgs *)userData;
+ if (args->progress->cancel)
+ return;
+ XA_PROFILE_START(chartGroupComputeChartsThread)
+ args->chartGroup->computeChartFaces(*args->options, args->atlas->get());
+ XA_PROFILE_END(chartGroupComputeChartsThread)
}
-struct ComputeChartsTaskArgs {
- TaskScheduler *taskScheduler;
- ChartGroup *chartGroup;
+struct MeshComputeChartFacesTaskArgs
+{
+ Array<ChartGroup *> *chartGroups; // output
+ InvalidMeshGeometry *invalidMeshGeometry; // output
ThreadLocal<segment::Atlas> *atlas;
- ThreadLocal<ChartCtorBuffers> *chartBuffers;
const ChartOptions *options;
Progress *progress;
+ const Mesh *sourceMesh;
+ TaskScheduler *taskScheduler;
};
-static void runComputeChartsJob(void *userData) {
- auto args = (ComputeChartsTaskArgs *)userData;
+#if XA_DEBUG_EXPORT_OBJ_FACE_GROUPS
+static uint32_t s_faceGroupsCurrentVertex = 0;
+#endif
+
+static void runMeshComputeChartFacesJob(void *userData)
+{
+ auto args = (MeshComputeChartFacesTaskArgs *)userData;
if (args->progress->cancel)
return;
XA_PROFILE_START(computeChartsThread)
- args->chartGroup->computeCharts(args->taskScheduler, *args->options, args->atlas->get(), args->chartBuffers);
+ // Create face groups.
+ XA_PROFILE_START(createFaceGroups)
+ MeshFaceGroups *meshFaceGroups = XA_NEW_ARGS(MemTag::Mesh, MeshFaceGroups, args->sourceMesh);
+ meshFaceGroups->compute();
+ const uint32_t chartGroupCount = meshFaceGroups->groupCount();
+ XA_PROFILE_END(createFaceGroups)
+ if (args->progress->cancel)
+ goto cleanup;
+#if XA_DEBUG_EXPORT_OBJ_FACE_GROUPS
+ {
+ static std::mutex s_mutex;
+ std::lock_guard<std::mutex> lock(s_mutex);
+ char filename[256];
+ XA_SPRINTF(filename, sizeof(filename), "debug_face_groups.obj");
+ FILE *file;
+ XA_FOPEN(file, filename, s_faceGroupsCurrentVertex == 0 ? "w" : "a");
+ if (file) {
+ const Mesh *mesh = args->sourceMesh;
+ mesh->writeObjVertices(file);
+ // groups
+ uint32_t numGroups = 0;
+ for (uint32_t i = 0; i < mesh->faceCount(); i++) {
+ if (meshFaceGroups->groupAt(i) != MeshFaceGroups::kInvalid)
+ numGroups = max(numGroups, meshFaceGroups->groupAt(i) + 1);
+ }
+ for (uint32_t i = 0; i < numGroups; i++) {
+ fprintf(file, "o mesh_%03u_group_%04d\n", mesh->id(), i);
+ fprintf(file, "s off\n");
+ for (uint32_t f = 0; f < mesh->faceCount(); f++) {
+ if (meshFaceGroups->groupAt(f) == i)
+ mesh->writeObjFace(file, f, s_faceGroupsCurrentVertex);
+ }
+ }
+ fprintf(file, "o mesh_%03u_group_ignored\n", mesh->id());
+ fprintf(file, "s off\n");
+ for (uint32_t f = 0; f < mesh->faceCount(); f++) {
+ if (meshFaceGroups->groupAt(f) == MeshFaceGroups::kInvalid)
+ mesh->writeObjFace(file, f, s_faceGroupsCurrentVertex);
+ }
+ mesh->writeObjBoundaryEges(file);
+ s_faceGroupsCurrentVertex += mesh->vertexCount();
+ fclose(file);
+ }
+ }
+#endif
+ // Create a chart group for each face group.
+ args->chartGroups->resize(chartGroupCount);
+ for (uint32_t i = 0; i < chartGroupCount; i++)
+ (*args->chartGroups)[i] = XA_NEW_ARGS(MemTag::Default, ChartGroup, i, args->sourceMesh, meshFaceGroups, MeshFaceGroups::Handle(i));
+ // Extract invalid geometry via the invalid face group (MeshFaceGroups::kInvalid).
+ XA_PROFILE_START(extractInvalidMeshGeometry)
+ args->invalidMeshGeometry->extract(args->sourceMesh, meshFaceGroups);
+ XA_PROFILE_END(extractInvalidMeshGeometry)
+ // One task for each chart group - compute chart faces.
+ {
+ XA_PROFILE_START(chartGroupComputeChartsReal)
+ Array<ChartGroupComputeChartFacesTaskArgs> taskArgs;
+ taskArgs.resize(chartGroupCount);
+ for (uint32_t i = 0; i < chartGroupCount; i++) {
+ taskArgs[i].atlas = args->atlas;
+ taskArgs[i].chartGroup = (*args->chartGroups)[i];
+ taskArgs[i].options = args->options;
+ taskArgs[i].progress = args->progress;
+ }
+ TaskGroupHandle taskGroup = args->taskScheduler->createTaskGroup(chartGroupCount);
+ for (uint32_t i = 0; i < chartGroupCount; i++) {
+ Task task;
+ task.userData = &taskArgs[i];
+ task.func = runChartGroupComputeChartFacesJob;
+ args->taskScheduler->run(taskGroup, task);
+ }
+ args->taskScheduler->wait(&taskGroup);
+ XA_PROFILE_END(chartGroupComputeChartsReal)
+ }
XA_PROFILE_END(computeChartsThread)
args->progress->value++;
args->progress->update();
+cleanup:
+ if (meshFaceGroups) {
+ meshFaceGroups->~MeshFaceGroups();
+ XA_FREE(meshFaceGroups);
+ }
}
-struct ParameterizeChartsTaskArgs {
+struct ParameterizeChartsTaskArgs
+{
TaskScheduler *taskScheduler;
ChartGroup *chartGroup;
- ParameterizeFunc func;
+ const ParameterizeOptions *options;
ThreadLocal<UniformGrid2> *boundaryGrid;
ThreadLocal<ChartCtorBuffers> *chartBuffers;
#if XA_RECOMPUTE_CHARTS
@@ -7069,15 +8100,16 @@ struct ParameterizeChartsTaskArgs {
Progress *progress;
};
-static void runParameterizeChartsJob(void *userData) {
+static void runParameterizeChartsJob(void *userData)
+{
auto args = (ParameterizeChartsTaskArgs *)userData;
if (args->progress->cancel)
return;
XA_PROFILE_START(parameterizeChartsThread)
#if XA_RECOMPUTE_CHARTS
- args->chartGroup->parameterizeCharts(args->taskScheduler, args->func, args->boundaryGrid, args->chartBuffers, args->piecewiseParam);
+ args->chartGroup->parameterizeCharts(args->taskScheduler, *args->options, args->boundaryGrid, args->chartBuffers, args->piecewiseParam);
#else
- args->chartGroup->parameterizeCharts(args->taskScheduler, args->func, args->boundaryGrid, args->chartBuffers);
+ args->chartGroup->parameterizeCharts(args->taskScheduler, *args->options, args->boundaryGrid, args->chartBuffers);
#endif
XA_PROFILE_END(parameterizeChartsThread)
args->progress->value++;
@@ -7085,137 +8117,86 @@ static void runParameterizeChartsJob(void *userData) {
}
/// An atlas is a set of chart groups.
-class Atlas {
+class Atlas
+{
public:
- Atlas() :
- m_meshCount(0), m_chartsComputed(false), m_chartsParameterized(false) {}
+ Atlas() : m_chartsComputed(false), m_chartsParameterized(false) {}
- ~Atlas() {
- for (uint32_t i = 0; i < m_chartGroups.size(); i++) {
- m_chartGroups[i]->~ChartGroup();
- XA_FREE(m_chartGroups[i]);
+ ~Atlas()
+ {
+ for (uint32_t i = 0; i < m_meshChartGroups.size(); i++) {
+ for (uint32_t j = 0; j < m_meshChartGroups[i].size(); j++) {
+ m_meshChartGroups[i][j]->~ChartGroup();
+ XA_FREE(m_meshChartGroups[i][j]);
+ }
}
+ m_meshChartGroups.runDtors();
+ m_invalidMeshGeometry.runDtors();
}
+ uint32_t meshCount() const { return m_meshes.size(); }
+ const InvalidMeshGeometry &invalidMeshGeometry(uint32_t meshIndex) const { return m_invalidMeshGeometry[meshIndex]; }
bool chartsComputed() const { return m_chartsComputed; }
bool chartsParameterized() const { return m_chartsParameterized; }
- uint32_t chartGroupCount() const { return m_chartGroups.size(); }
- const ChartGroup *chartGroupAt(uint32_t index) const { return m_chartGroups[index]; }
-
- uint32_t chartGroupCount(uint32_t mesh) const {
- uint32_t count = 0;
- for (uint32_t i = 0; i < m_chartGroups.size(); i++) {
- if (m_chartGroupSourceMeshes[i] == mesh)
- count++;
- }
- return count;
- }
-
- const ChartGroup *chartGroupAt(uint32_t mesh, uint32_t group) const {
- for (uint32_t c = 0; c < m_chartGroups.size(); c++) {
- if (m_chartGroupSourceMeshes[c] != mesh)
- continue;
- if (group == 0)
- return m_chartGroups[c];
- group--;
- }
- return nullptr;
- }
+ uint32_t chartGroupCount(uint32_t mesh) const { return m_meshChartGroups[mesh].size(); }
+ const ChartGroup *chartGroupAt(uint32_t mesh, uint32_t group) const { return m_meshChartGroups[mesh][group]; }
- // This function is thread safe.
- void addMesh(TaskScheduler *taskScheduler, const Mesh *mesh) {
- // Create one chart group per face group.
- // If there's any ignored faces in the mesh, create an extra face group for that (vertex map).
- // Chart group creation is slow since it copies a chunk of the source mesh, so use tasks.
- Array<ChartGroup *> chartGroups;
- chartGroups.resize(mesh->faceGroupCount() + (mesh->ignoredFaceCount() > 0 ? 1 : 0));
- Array<CreateChartGroupTaskArgs> taskArgs;
- taskArgs.resize(chartGroups.size());
- for (uint32_t g = 0; g < chartGroups.size(); g++) {
- CreateChartGroupTaskArgs &args = taskArgs[g];
- args.chartGroup = &chartGroups[g];
- args.faceGroup = uint16_t(g < mesh->faceGroupCount() ? g : Mesh::kInvalidFaceGroup);
- args.groupId = g;
- args.mesh = mesh;
- }
- TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(chartGroups.size());
- for (uint32_t g = 0; g < chartGroups.size(); g++) {
- Task task;
- task.userData = &taskArgs[g];
- task.func = runCreateChartGroupTask;
- taskScheduler->run(taskGroup, task);
- }
- taskScheduler->wait(&taskGroup);
- // Thread-safe append.
- m_addMeshMutex.lock();
- for (uint32_t g = 0; g < chartGroups.size(); g++) {
- m_chartGroups.push_back(chartGroups[g]);
- m_chartGroupSourceMeshes.push_back(mesh->id());
- }
- m_meshCount++;
- m_addMeshMutex.unlock();
- }
-
- // Chart id/index is determined by depth-first hierarchy of mesh -> chart group -> chart.
- // For chart index to be consistent here, chart groups needs to sorted by mesh index. Since addMesh is called by multithreaded tasks, order is indeterminate, so chart groups need to be explicitly sorted after all meshes are added.
- void sortChartGroups() {
- Array<ChartGroup *> oldChartGroups;
- oldChartGroups.resize(m_chartGroups.size());
- memcpy(oldChartGroups.data(), m_chartGroups.data(), sizeof(ChartGroup *) * m_chartGroups.size());
- Array<uint32_t> oldChartGroupSourceMeshes;
- oldChartGroupSourceMeshes.resize(m_chartGroupSourceMeshes.size());
- memcpy(oldChartGroupSourceMeshes.data(), m_chartGroupSourceMeshes.data(), sizeof(uint32_t) * m_chartGroupSourceMeshes.size());
- uint32_t current = 0;
- for (uint32_t i = 0; i < m_meshCount; i++) {
- for (uint32_t j = 0; j < oldChartGroups.size(); j++) {
- if (oldChartGroupSourceMeshes[j] == i) {
- m_chartGroups[current] = oldChartGroups[j];
- m_chartGroupSourceMeshes[current] = oldChartGroupSourceMeshes[j];
- current++;
- }
- }
- }
+ void addMesh(const Mesh *mesh)
+ {
+ m_meshes.push_back(mesh);
}
- bool computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, ProgressFunc progressFunc, void *progressUserData) {
+ bool computeCharts(TaskScheduler *taskScheduler, const ChartOptions &options, ProgressFunc progressFunc, void *progressUserData)
+ {
+#if XA_DEBUG_EXPORT_OBJ_PLANAR_REGIONS
+ segment::s_planarRegionsCurrentRegion = segment::s_planarRegionsCurrentVertex = 0;
+#endif
m_chartsComputed = false;
m_chartsParameterized = false;
- // Ignore vertex maps.
- uint32_t chartGroupCount = 0;
- for (uint32_t i = 0; i < m_chartGroups.size(); i++) {
- if (!m_chartGroups[i]->isVertexMap())
- chartGroupCount++;
+ // Clear chart groups, since this function may be called multiple times.
+ if (!m_meshChartGroups.isEmpty()) {
+ for (uint32_t i = 0; i < m_meshChartGroups.size(); i++) {
+ for (uint32_t j = 0; j < m_meshChartGroups[i].size(); j++) {
+ m_meshChartGroups[i][j]->~ChartGroup();
+ XA_FREE(m_meshChartGroups[i][j]);
+ }
+ m_meshChartGroups[i].clear();
+ }
+ XA_ASSERT(m_meshChartGroups.size() == m_meshes.size()); // The number of meshes shouldn't have changed.
}
- Progress progress(ProgressCategory::ComputeCharts, progressFunc, progressUserData, chartGroupCount);
+ m_meshChartGroups.resize(m_meshes.size());
+ m_meshChartGroups.runCtors();
+ m_invalidMeshGeometry.resize(m_meshes.size());
+ m_invalidMeshGeometry.runCtors();
+ // One task per mesh.
+ const uint32_t meshCount = m_meshes.size();
+ Progress progress(ProgressCategory::ComputeCharts, progressFunc, progressUserData, meshCount);
ThreadLocal<segment::Atlas> atlas;
- ThreadLocal<ChartCtorBuffers> chartBuffers;
- Array<ComputeChartsTaskArgs> taskArgs;
- taskArgs.reserve(chartGroupCount);
- for (uint32_t i = 0; i < m_chartGroups.size(); i++) {
- if (!m_chartGroups[i]->isVertexMap()) {
- ComputeChartsTaskArgs args;
- args.taskScheduler = taskScheduler;
- args.chartGroup = m_chartGroups[i];
- args.atlas = &atlas;
- args.chartBuffers = &chartBuffers;
- args.options = &options;
- args.progress = &progress;
- taskArgs.push_back(args);
- }
- }
- // Sort chart groups by mesh indexCount.
- m_chartGroupsRadix = RadixSort();
- Array<float> chartGroupSortData;
- chartGroupSortData.resize(chartGroupCount);
- for (uint32_t i = 0; i < chartGroupCount; i++)
- chartGroupSortData[i] = (float)taskArgs[i].chartGroup->mesh()->indexCount();
- m_chartGroupsRadix.sort(chartGroupSortData);
- // Larger chart group meshes are added first to reduce the chance of thread starvation.
- TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(chartGroupCount);
- for (uint32_t i = 0; i < chartGroupCount; i++) {
+ Array<MeshComputeChartFacesTaskArgs> taskArgs;
+ taskArgs.resize(meshCount);
+ for (uint32_t i = 0; i < meshCount; i++) {
+ MeshComputeChartFacesTaskArgs &args = taskArgs[i];
+ args.atlas = &atlas;
+ args.chartGroups = &m_meshChartGroups[i];
+ args.invalidMeshGeometry = &m_invalidMeshGeometry[i];
+ args.options = &options;
+ args.progress = &progress;
+ args.sourceMesh = m_meshes[i];
+ args.taskScheduler = taskScheduler;
+ }
+ // Sort meshes by indexCount.
+ Array<float> meshSortData;
+ meshSortData.resize(meshCount);
+ for (uint32_t i = 0; i < meshCount; i++)
+ meshSortData[i] = (float)m_meshes[i]->indexCount();
+ RadixSort meshSort;
+ meshSort.sort(meshSortData);
+ // Larger meshes are added first to reduce the chance of thread starvation.
+ TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(meshCount);
+ for (uint32_t i = 0; i < meshCount; i++) {
Task task;
- task.userData = &taskArgs[m_chartGroupsRadix.ranks()[chartGroupCount - i - 1]];
- task.func = runComputeChartsJob;
+ task.userData = &taskArgs[meshSort.ranks()[meshCount - i - 1]];
+ task.func = runMeshComputeChartFacesJob;
taskScheduler->run(taskGroup, task);
}
taskScheduler->wait(&taskGroup);
@@ -7225,14 +8206,12 @@ public:
return true;
}
- bool parameterizeCharts(TaskScheduler *taskScheduler, ParameterizeFunc func, ProgressFunc progressFunc, void *progressUserData) {
+ bool parameterizeCharts(TaskScheduler *taskScheduler, const ParameterizeOptions &options, ProgressFunc progressFunc, void *progressUserData)
+ {
m_chartsParameterized = false;
- // Ignore vertex maps.
uint32_t chartGroupCount = 0;
- for (uint32_t i = 0; i < m_chartGroups.size(); i++) {
- if (!m_chartGroups[i]->isVertexMap())
- chartGroupCount++;
- }
+ for (uint32_t i = 0; i < m_meshChartGroups.size(); i++)
+ chartGroupCount += m_meshChartGroups[i].size();
Progress progress(ProgressCategory::ParameterizeCharts, progressFunc, progressUserData, chartGroupCount);
ThreadLocal<UniformGrid2> boundaryGrid; // For Quality boundary intersection.
ThreadLocal<ChartCtorBuffers> chartBuffers;
@@ -7240,27 +8219,45 @@ public:
ThreadLocal<PiecewiseParam> piecewiseParam;
#endif
Array<ParameterizeChartsTaskArgs> taskArgs;
- taskArgs.reserve(chartGroupCount);
- for (uint32_t i = 0; i < m_chartGroups.size(); i++) {
- if (!m_chartGroups[i]->isVertexMap()) {
- ParameterizeChartsTaskArgs args;
- args.taskScheduler = taskScheduler;
- args.chartGroup = m_chartGroups[i];
- args.func = func;
- args.boundaryGrid = &boundaryGrid;
- args.chartBuffers = &chartBuffers;
+ taskArgs.resize(chartGroupCount);
+ {
+ uint32_t k = 0;
+ for (uint32_t i = 0; i < m_meshChartGroups.size(); i++) {
+ const uint32_t count = m_meshChartGroups[i].size();
+ for (uint32_t j = 0; j < count; j++) {
+ ParameterizeChartsTaskArgs &args = taskArgs[k];
+ args.taskScheduler = taskScheduler;
+ args.chartGroup = m_meshChartGroups[i][j];
+ args.options = &options;
+ args.boundaryGrid = &boundaryGrid;
+ args.chartBuffers = &chartBuffers;
#if XA_RECOMPUTE_CHARTS
- args.piecewiseParam = &piecewiseParam;
+ args.piecewiseParam = &piecewiseParam;
#endif
- args.progress = &progress;
- taskArgs.push_back(args);
+ args.progress = &progress;
+ k++;
+ }
}
}
- // Larger chart group meshes are added first to reduce the chance of thread starvation.
+ // Sort chart groups by face count.
+ Array<float> chartGroupSortData;
+ chartGroupSortData.resize(chartGroupCount);
+ {
+ uint32_t k = 0;
+ for (uint32_t i = 0; i < m_meshChartGroups.size(); i++) {
+ const uint32_t count = m_meshChartGroups[i].size();
+ for (uint32_t j = 0; j < count; j++) {
+ chartGroupSortData[k++] = (float)m_meshChartGroups[i][j]->faceCount();
+ }
+ }
+ }
+ RadixSort chartGroupSort;
+ chartGroupSort.sort(chartGroupSortData);
+ // Larger chart groups are added first to reduce the chance of thread starvation.
TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(chartGroupCount);
for (uint32_t i = 0; i < chartGroupCount; i++) {
Task task;
- task.userData = &taskArgs[m_chartGroupsRadix.ranks()[chartGroupCount - i - 1]];
+ task.userData = &taskArgs[chartGroupSort.ranks()[chartGroupCount - i - 1]];
task.func = runParameterizeChartsJob;
taskScheduler->run(taskGroup, task);
}
@@ -7272,28 +8269,28 @@ public:
}
private:
- std::mutex m_addMeshMutex;
- uint32_t m_meshCount;
+ Array<const Mesh *> m_meshes;
+ Array<InvalidMeshGeometry> m_invalidMeshGeometry; // 1 per mesh.
+ Array<Array<ChartGroup *> > m_meshChartGroups;
bool m_chartsComputed;
bool m_chartsParameterized;
- Array<ChartGroup *> m_chartGroups;
- RadixSort m_chartGroupsRadix; // By mesh indexCount.
- Array<uint32_t> m_chartGroupSourceMeshes;
};
} // namespace param
namespace pack {
-class AtlasImage {
+class AtlasImage
+{
public:
- AtlasImage(uint32_t width, uint32_t height) :
- m_width(width), m_height(height) {
+ AtlasImage(uint32_t width, uint32_t height) : m_width(width), m_height(height)
+ {
m_data.resize(m_width * m_height);
memset(m_data.data(), 0, sizeof(uint32_t) * m_data.size());
}
- void resize(uint32_t width, uint32_t height) {
+ void resize(uint32_t width, uint32_t height)
+ {
Array<uint32_t> data;
data.resize(width * height);
memset(data.data(), 0, sizeof(uint32_t) * data.size());
@@ -7304,7 +8301,8 @@ public:
data.moveTo(m_data);
}
- void addChart(uint32_t chartIndex, const BitImage *image, const BitImage *imageBilinear, const BitImage *imagePadding, int atlas_w, int atlas_h, int offset_x, int offset_y) {
+ void addChart(uint32_t chartIndex, const BitImage *image, const BitImage *imageBilinear, const BitImage *imagePadding, int atlas_w, int atlas_h, int offset_x, int offset_y)
+ {
const int w = image->width();
const int h = image->height();
for (int y = 0; y < h; y++) {
@@ -7330,13 +8328,15 @@ public:
}
}
- void copyTo(uint32_t *dest, uint32_t destWidth, uint32_t destHeight, int padding) const {
+ void copyTo(uint32_t *dest, uint32_t destWidth, uint32_t destHeight, int padding) const
+ {
for (uint32_t y = 0; y < destHeight; y++)
memcpy(&dest[y * destWidth], &m_data[padding + (y + padding) * m_width], destWidth * sizeof(uint32_t));
}
#if XA_DEBUG_EXPORT_ATLAS_IMAGES
- void writeTga(const char *filename, uint32_t width, uint32_t height) const {
+ void writeTga(const char *filename, uint32_t width, uint32_t height) const
+ {
Array<uint8_t> image;
image.resize(width * height * 3);
for (uint32_t y = 0; y < height; y++) {
@@ -7378,7 +8378,8 @@ private:
Array<uint32_t> m_data;
};
-struct Chart {
+struct Chart
+{
int32_t atlasIndex;
uint32_t material;
uint32_t indexCount;
@@ -7400,18 +8401,20 @@ struct Chart {
uint32_t uniqueVertexCount() const { return uniqueVertices.isEmpty() ? vertexCount : uniqueVertices.size(); }
};
-struct AddChartTaskArgs {
+struct AddChartTaskArgs
+{
ThreadLocal<BoundingBox2D> *boundingBox;
param::Chart *paramChart;
Chart *chart; // out
};
-static void runAddChartTask(void *userData) {
+static void runAddChartTask(void *userData)
+{
XA_PROFILE_START(packChartsAddChartsThread)
auto args = (AddChartTaskArgs *)userData;
param::Chart *paramChart = args->paramChart;
XA_PROFILE_START(packChartsAddChartsRestoreTexcoords)
- paramChart->transferParameterization();
+ paramChart->restoreTexcoords();
XA_PROFILE_END(packChartsAddChartsRestoreTexcoords)
Mesh *mesh = paramChart->mesh();
Chart *chart = args->chart = XA_NEW(MemTag::Default, Chart);
@@ -7445,8 +8448,10 @@ static void runAddChartTask(void *userData) {
XA_PROFILE_END(packChartsAddChartsThread)
}
-struct Atlas {
- ~Atlas() {
+struct Atlas
+{
+ ~Atlas()
+ {
for (uint32_t i = 0; i < m_atlasImages.size(); i++) {
m_atlasImages[i]->~AtlasImage();
XA_FREE(m_atlasImages[i]);
@@ -7470,15 +8475,16 @@ struct Atlas {
const Array<AtlasImage *> &getImages() const { return m_atlasImages; }
float getUtilization(uint32_t atlas) const { return m_utilization[atlas]; }
- void addCharts(TaskScheduler *taskScheduler, param::Atlas *paramAtlas) {
+ void addCharts(TaskScheduler *taskScheduler, param::Atlas *paramAtlas)
+ {
// Count charts.
uint32_t chartCount = 0;
- const uint32_t chartGroupsCount = paramAtlas->chartGroupCount();
- for (uint32_t i = 0; i < chartGroupsCount; i++) {
- const param::ChartGroup *chartGroup = paramAtlas->chartGroupAt(i);
- if (chartGroup->isVertexMap())
- continue;
- chartCount += chartGroup->chartCount();
+ for (uint32_t i = 0; i < paramAtlas->meshCount(); i++) {
+ const uint32_t chartGroupsCount = paramAtlas->chartGroupCount(i);
+ for (uint32_t j = 0; j < chartGroupsCount; j++) {
+ const param::ChartGroup *chartGroup = paramAtlas->chartGroupAt(i, j);
+ chartCount += chartGroup->chartCount();
+ }
}
if (chartCount == 0)
return;
@@ -7488,20 +8494,21 @@ struct Atlas {
TaskGroupHandle taskGroup = taskScheduler->createTaskGroup(chartCount);
uint32_t chartIndex = 0;
ThreadLocal<BoundingBox2D> boundingBox;
- for (uint32_t i = 0; i < chartGroupsCount; i++) {
- const param::ChartGroup *chartGroup = paramAtlas->chartGroupAt(i);
- if (chartGroup->isVertexMap())
- continue;
- const uint32_t count = chartGroup->chartCount();
- for (uint32_t j = 0; j < count; j++) {
- AddChartTaskArgs &args = taskArgs[chartIndex];
- args.boundingBox = &boundingBox;
- args.paramChart = chartGroup->chartAt(j);
- Task task;
- task.userData = &taskArgs[chartIndex];
- task.func = runAddChartTask;
- taskScheduler->run(taskGroup, task);
- chartIndex++;
+ for (uint32_t i = 0; i < paramAtlas->meshCount(); i++) {
+ const uint32_t chartGroupsCount = paramAtlas->chartGroupCount(i);
+ for (uint32_t j = 0; j < chartGroupsCount; j++) {
+ const param::ChartGroup *chartGroup = paramAtlas->chartGroupAt(i, j);
+ const uint32_t count = chartGroup->chartCount();
+ for (uint32_t k = 0; k < count; k++) {
+ AddChartTaskArgs &args = taskArgs[chartIndex];
+ args.boundingBox = &boundingBox;
+ args.paramChart = chartGroup->chartAt(k);
+ Task task;
+ task.userData = &taskArgs[chartIndex];
+ task.func = runAddChartTask;
+ taskScheduler->run(taskGroup, task);
+ chartIndex++;
+ }
}
}
taskScheduler->wait(&taskGroup);
@@ -7511,7 +8518,8 @@ struct Atlas {
m_charts[i] = taskArgs[i].chart;
}
- void addUvMeshCharts(UvMeshInstance *mesh) {
+ void addUvMeshCharts(UvMeshInstance *mesh)
+ {
BitArray vertexUsed(mesh->texcoords.size());
BoundingBox2D boundingBox;
for (uint32_t c = 0; c < mesh->mesh->charts.size(); c++) {
@@ -7572,7 +8580,8 @@ struct Atlas {
}
// Pack charts in the smallest possible rectangle.
- bool packCharts(const PackOptions &options, ProgressFunc progressFunc, void *progressUserData) {
+ bool packCharts(const PackOptions &options, ProgressFunc progressFunc, void *progressUserData)
+ {
if (progressFunc) {
if (!progressFunc(ProgressCategory::PackCharts, 0, progressUserData))
return false;
@@ -7699,7 +8708,6 @@ struct Atlas {
maxChartPerimeter = max(maxChartPerimeter, chartOrderArray[c]);
}
// Sort charts by perimeter.
- m_radix = RadixSort();
m_radix.sort(chartOrderArray);
const uint32_t *ranks = m_radix.ranks();
// Divide chart perimeter range into buckets.
@@ -7807,7 +8815,8 @@ struct Atlas {
int best_x = 0, best_y = 0;
int best_cw = 0, best_ch = 0;
int best_r = 0;
- for (;;) {
+ for (;;)
+ {
bool firstChartInBitImage = false;
XA_UNUSED(firstChartInBitImage);
if (currentAtlas + 1 > m_bitImages.size()) {
@@ -7840,7 +8849,8 @@ struct Atlas {
if (best_x + best_cw > atlasSizes[currentAtlas].x || best_y + best_ch > atlasSizes[currentAtlas].y) {
for (uint32_t j = 0; j < chartStartPositions.size(); j++)
chartStartPositions[j] = Vector2i(0, 0);
- } else {
+ }
+ else {
chartStartPositions[currentAtlas] = Vector2i(best_x, best_y);
}
}
@@ -7892,10 +8902,8 @@ struct Atlas {
}
texcoord.x = best_x + t.x;
texcoord.y = best_y + t.y;
- if (!options.blockAlign) {
- texcoord.x -= (float)options.padding;
- texcoord.y -= (float)options.padding;
- }
+ texcoord.x -= (float)options.padding;
+ texcoord.y -= (float)options.padding;
XA_ASSERT(texcoord.x >= 0 && texcoord.y >= 0);
XA_ASSERT(isFinite(texcoord.x) && isFinite(texcoord.y));
}
@@ -7908,21 +8916,12 @@ struct Atlas {
}
}
}
- if (options.blockAlign) {
- if (maxResolution == 0) {
- m_width = max(0, atlasSizes[0].x);
- m_height = max(0, atlasSizes[0].y);
- } else {
- m_width = m_height = maxResolution;
- }
+ // Remove padding from outer edges.
+ if (maxResolution == 0) {
+ m_width = max(0, atlasSizes[0].x - (int)options.padding * 2);
+ m_height = max(0, atlasSizes[0].y - (int)options.padding * 2);
} else {
- // Remove padding from outer edges.
- if (maxResolution == 0) {
- m_width = max(0, atlasSizes[0].x - (int)options.padding * 2);
- m_height = max(0, atlasSizes[0].y - (int)options.padding * 2);
- } else {
- m_width = m_height = maxResolution - (int)options.padding * 2;
- }
+ m_width = m_height = maxResolution - (int)options.padding * 2;
}
XA_PRINT(" %dx%d resolution\n", m_width, m_height);
m_utilization.resize(m_bitImages.size());
@@ -7939,7 +8938,8 @@ struct Atlas {
}
if (m_utilization.size() > 1) {
XA_PRINT(" %u: %f%% utilization\n", i, m_utilization[i] * 100.0f);
- } else {
+ }
+ else {
XA_PRINT(" %f%% utilization\n", m_utilization[i] * 100.0f);
}
}
@@ -7962,14 +8962,16 @@ private:
// is occupied at this point. At the end we have many small charts and a large atlas with sparse holes. Finding those holes randomly is slow. A better approach would be to
// start stacking large charts as if they were tetris pieces. Once charts get small try to place them randomly. It may be interesting to try a intermediate strategy, first try
// along one axis and then try exhaustively along that axis.
- bool findChartLocation(const Vector2i &startPosition, bool bruteForce, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, bool blockAligned, uint32_t maxResolution, bool allowRotate) {
+ bool findChartLocation(const Vector2i &startPosition, bool bruteForce, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, bool blockAligned, uint32_t maxResolution, bool allowRotate)
+ {
const int attempts = 4096;
if (bruteForce || attempts >= w * h)
return findChartLocation_bruteForce(startPosition, atlasBitImage, chartBitImage, chartBitImageRotated, w, h, best_x, best_y, best_w, best_h, best_r, blockAligned, maxResolution, allowRotate);
return findChartLocation_random(atlasBitImage, chartBitImage, chartBitImageRotated, w, h, best_x, best_y, best_w, best_h, best_r, attempts, blockAligned, maxResolution, allowRotate);
}
- bool findChartLocation_bruteForce(const Vector2i &startPosition, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, bool blockAligned, uint32_t maxResolution, bool allowRotate) {
+ bool findChartLocation_bruteForce(const Vector2i &startPosition, const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, bool blockAligned, uint32_t maxResolution, bool allowRotate)
+ {
const int stepSize = blockAligned ? 4 : 1;
int best_metric = INT_MAX;
// Try two different orientations.
@@ -8014,7 +9016,8 @@ private:
return best_metric != INT_MAX;
}
- bool findChartLocation_random(const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, int minTrialCount, bool blockAligned, uint32_t maxResolution, bool allowRotate) {
+ bool findChartLocation_random(const BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int w, int h, int *best_x, int *best_y, int *best_w, int *best_h, int *best_r, int minTrialCount, bool blockAligned, uint32_t maxResolution, bool allowRotate)
+ {
bool result = false;
const int BLOCK_SIZE = 4;
int best_metric = INT_MAX;
@@ -8069,7 +9072,8 @@ private:
return result;
}
- void addChart(BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int atlas_w, int atlas_h, int offset_x, int offset_y, int r) {
+ void addChart(BitImage *atlasBitImage, const BitImage *chartBitImage, const BitImage *chartBitImageRotated, int atlas_w, int atlas_h, int offset_x, int offset_y, int r)
+ {
XA_DEBUG_ASSERT(r == 0 || r == 1);
const BitImage *image = r == 0 ? chartBitImage : chartBitImageRotated;
const int w = image->width();
@@ -8092,7 +9096,8 @@ private:
}
}
- void bilinearExpand(const Chart *chart, BitImage *source, BitImage *dest, BitImage *destRotated, UniformGrid2 &boundaryEdgeGrid) const {
+ void bilinearExpand(const Chart *chart, BitImage *source, BitImage *dest, BitImage *destRotated, UniformGrid2 &boundaryEdgeGrid) const
+ {
boundaryEdgeGrid.reset(chart->vertices, chart->indices);
if (chart->boundaryEdges) {
const uint32_t edgeCount = chart->boundaryEdges->size();
@@ -8147,11 +9152,13 @@ private:
}
}
- struct DrawTriangleCallbackArgs {
+ struct DrawTriangleCallbackArgs
+ {
BitImage *chartBitImage, *chartBitImageRotated;
};
- static bool drawTriangleCallback(void *param, int x, int y) {
+ static bool drawTriangleCallback(void *param, int x, int y)
+ {
auto args = (DrawTriangleCallbackArgs *)param;
args->chartBitImage->set(x, y);
if (args->chartBitImageRotated)
@@ -8173,48 +9180,52 @@ private:
} // namespace pack
} // namespace internal
-struct Context {
+struct Context
+{
Atlas atlas;
- uint32_t meshCount = 0;
internal::Progress *addMeshProgress = nullptr;
internal::TaskGroupHandle addMeshTaskGroup;
internal::param::Atlas paramAtlas;
ProgressFunc progressFunc = nullptr;
void *progressUserData = nullptr;
internal::TaskScheduler *taskScheduler;
+ internal::Array<internal::Mesh *> meshes;
internal::Array<internal::UvMesh *> uvMeshes;
internal::Array<internal::UvMeshInstance *> uvMeshInstances;
};
-Atlas *Create() {
+Atlas *Create()
+{
Context *ctx = XA_NEW(internal::MemTag::Default, Context);
memset(&ctx->atlas, 0, sizeof(Atlas));
ctx->taskScheduler = XA_NEW(internal::MemTag::Default, internal::TaskScheduler);
return &ctx->atlas;
}
-static void DestroyOutputMeshes(Context *ctx) {
+static void DestroyOutputMeshes(Context *ctx)
+{
if (!ctx->atlas.meshes)
return;
for (int i = 0; i < (int)ctx->atlas.meshCount; i++) {
Mesh &mesh = ctx->atlas.meshes[i];
- for (uint32_t j = 0; j < mesh.chartCount; j++) {
- if (mesh.chartArray[j].faceArray)
- XA_FREE(mesh.chartArray[j].faceArray);
- }
- if (mesh.chartArray)
+ if (mesh.chartArray) {
+ for (uint32_t j = 0; j < mesh.chartCount; j++) {
+ if (mesh.chartArray[j].faceArray)
+ XA_FREE(mesh.chartArray[j].faceArray);
+ }
XA_FREE(mesh.chartArray);
+ }
if (mesh.vertexArray)
XA_FREE(mesh.vertexArray);
if (mesh.indexArray)
XA_FREE(mesh.indexArray);
}
- if (ctx->atlas.meshes)
- XA_FREE(ctx->atlas.meshes);
+ XA_FREE(ctx->atlas.meshes);
ctx->atlas.meshes = nullptr;
}
-void Destroy(Atlas *atlas) {
+void Destroy(Atlas *atlas)
+{
XA_DEBUG_ASSERT(atlas);
Context *ctx = (Context *)atlas;
if (atlas->utilization)
@@ -8228,6 +9239,11 @@ void Destroy(Atlas *atlas) {
}
ctx->taskScheduler->~TaskScheduler();
XA_FREE(ctx->taskScheduler);
+ for (uint32_t i = 0; i < ctx->meshes.size(); i++) {
+ internal::Mesh *mesh = ctx->meshes[i];
+ mesh->~Mesh();
+ XA_FREE(mesh);
+ }
for (uint32_t i = 0; i < ctx->uvMeshes.size(); i++) {
internal::UvMesh *mesh = ctx->uvMeshes[i];
for (uint32_t j = 0; j < mesh->charts.size(); j++) {
@@ -8249,12 +9265,14 @@ void Destroy(Atlas *atlas) {
#endif
}
-struct AddMeshTaskArgs {
+struct AddMeshTaskArgs
+{
Context *ctx;
internal::Mesh *mesh;
};
-static void runAddMeshTask(void *userData) {
+static void runAddMeshTask(void *userData)
+{
XA_PROFILE_START(addMeshThread)
auto args = (AddMeshTaskArgs *)userData; // Responsible for freeing this.
internal::Mesh *mesh = args->mesh;
@@ -8268,87 +9286,45 @@ static void runAddMeshTask(void *userData) {
}
if (progress->cancel)
goto cleanup;
- {
- XA_PROFILE_START(addMeshCreateFaceGroups)
- mesh->createFaceGroups();
- XA_PROFILE_END(addMeshCreateFaceGroups)
- }
- if (progress->cancel)
- goto cleanup;
-#if XA_DEBUG_EXPORT_OBJ_SOURCE_MESHES
- char filename[256];
- XA_SPRINTF(filename, sizeof(filename), "debug_mesh_%03u.obj", mesh->id());
- FILE *file;
- XA_FOPEN(file, filename, "w");
- if (file) {
- mesh->writeObjVertices(file);
- // groups
- uint32_t numGroups = 0;
- for (uint32_t i = 0; i < mesh->faceCount(); i++) {
- if (mesh->faceGroupAt(i) != Mesh::kInvalidFaceGroup)
- numGroups = internal::max(numGroups, mesh->faceGroupAt(i) + 1);
- }
- for (uint32_t i = 0; i < numGroups; i++) {
- fprintf(file, "o group_%04d\n", i);
- fprintf(file, "s off\n");
- for (uint32_t f = 0; f < mesh->faceCount(); f++) {
- if (mesh->faceGroupAt(f) == i)
- mesh->writeObjFace(file, f);
- }
- }
- fprintf(file, "o group_ignored\n");
- fprintf(file, "s off\n");
- for (uint32_t f = 0; f < mesh->faceCount(); f++) {
- if (mesh->faceGroupAt(f) == Mesh::kInvalidFaceGroup)
- mesh->writeObjFace(file, f);
- }
- mesh->writeObjBoundaryEges(file);
- fclose(file);
- }
-#endif
- {
- XA_PROFILE_START(addMeshCreateChartGroupsReal)
- args->ctx->paramAtlas.addMesh(args->ctx->taskScheduler, mesh); // addMesh is thread safe
- XA_PROFILE_END(addMeshCreateChartGroupsReal)
- }
- if (progress->cancel)
- goto cleanup;
progress->value++;
progress->update();
cleanup:
- mesh->~Mesh();
- XA_FREE(mesh);
args->~AddMeshTaskArgs();
XA_FREE(args);
XA_PROFILE_END(addMeshThread)
}
-static internal::Vector3 DecodePosition(const MeshDecl &meshDecl, uint32_t index) {
+static internal::Vector3 DecodePosition(const MeshDecl &meshDecl, uint32_t index)
+{
XA_DEBUG_ASSERT(meshDecl.vertexPositionData);
XA_DEBUG_ASSERT(meshDecl.vertexPositionStride > 0);
return *((const internal::Vector3 *)&((const uint8_t *)meshDecl.vertexPositionData)[meshDecl.vertexPositionStride * index]);
}
-static internal::Vector3 DecodeNormal(const MeshDecl &meshDecl, uint32_t index) {
+static internal::Vector3 DecodeNormal(const MeshDecl &meshDecl, uint32_t index)
+{
XA_DEBUG_ASSERT(meshDecl.vertexNormalData);
XA_DEBUG_ASSERT(meshDecl.vertexNormalStride > 0);
return *((const internal::Vector3 *)&((const uint8_t *)meshDecl.vertexNormalData)[meshDecl.vertexNormalStride * index]);
}
-static internal::Vector2 DecodeUv(const MeshDecl &meshDecl, uint32_t index) {
+static internal::Vector2 DecodeUv(const MeshDecl &meshDecl, uint32_t index)
+{
XA_DEBUG_ASSERT(meshDecl.vertexUvData);
XA_DEBUG_ASSERT(meshDecl.vertexUvStride > 0);
return *((const internal::Vector2 *)&((const uint8_t *)meshDecl.vertexUvData)[meshDecl.vertexUvStride * index]);
}
-static uint32_t DecodeIndex(IndexFormat::Enum format, const void *indexData, int32_t offset, uint32_t i) {
+static uint32_t DecodeIndex(IndexFormat::Enum format, const void *indexData, int32_t offset, uint32_t i)
+{
XA_DEBUG_ASSERT(indexData);
if (format == IndexFormat::UInt16)
return uint16_t((int32_t)((const uint16_t *)indexData)[i] + offset);
return uint32_t((int32_t)((const uint32_t *)indexData)[i] + offset);
}
-AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountHint) {
+AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountHint)
+{
XA_DEBUG_ASSERT(atlas);
if (!atlas) {
XA_PRINT_WARNING("AddMesh: atlas is null.\n");
@@ -8360,19 +9336,20 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
return AddMeshError::Error;
}
#if XA_PROFILE
- if (ctx->meshCount == 0)
+ if (ctx->meshes.isEmpty())
internal::s_profile.addMeshReal = clock();
#endif
// Don't know how many times AddMesh will be called, so progress needs to adjusted each time.
if (!ctx->addMeshProgress) {
ctx->addMeshProgress = XA_NEW_ARGS(internal::MemTag::Default, internal::Progress, ProgressCategory::AddMesh, ctx->progressFunc, ctx->progressUserData, 1);
- } else {
- ctx->addMeshProgress->setMaxValue(internal::max(ctx->meshCount + 1, meshCountHint));
+ }
+ else {
+ ctx->addMeshProgress->setMaxValue(internal::max(ctx->meshes.size() + 1, meshCountHint));
}
XA_PROFILE_START(addMeshCopyData)
const bool hasIndices = meshDecl.indexCount > 0;
const uint32_t indexCount = hasIndices ? meshDecl.indexCount : meshDecl.vertexCount;
- XA_PRINT("Adding mesh %d: %u vertices, %u triangles\n", ctx->meshCount, meshDecl.vertexCount, indexCount / 3);
+ XA_PRINT("Adding mesh %d: %u vertices, %u triangles\n", ctx->meshes.size(), meshDecl.vertexCount, indexCount / 3);
// Expecting triangle faces.
if ((indexCount % 3) != 0)
return AddMeshError::InvalidIndexCount;
@@ -8384,10 +9361,10 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
return AddMeshError::IndexOutOfRange;
}
}
- uint32_t meshFlags = internal::MeshFlags::HasFaceGroups | internal::MeshFlags::HasIgnoredFaces;
+ uint32_t meshFlags = internal::MeshFlags::HasIgnoredFaces;
if (meshDecl.vertexNormalData)
meshFlags |= internal::MeshFlags::HasNormals;
- internal::Mesh *mesh = XA_NEW_ARGS(internal::MemTag::Mesh, internal::Mesh, meshDecl.epsilon, meshDecl.vertexCount, indexCount / 3, meshFlags, ctx->meshCount);
+ internal::Mesh *mesh = XA_NEW_ARGS(internal::MemTag::Mesh, internal::Mesh, meshDecl.epsilon, meshDecl.vertexCount, indexCount / 3, meshFlags, ctx->meshes.size());
for (uint32_t i = 0; i < meshDecl.vertexCount; i++) {
internal::Vector3 normal(0.0f);
internal::Vector2 texcoord(0.0f);
@@ -8397,6 +9374,8 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
texcoord = DecodeUv(meshDecl, i);
mesh->addVertex(DecodePosition(meshDecl, i), normal, texcoord);
}
+ const uint32_t kMaxWarnings = 50;
+ uint32_t warningCount = 0;
for (uint32_t i = 0; i < indexCount / 3; i++) {
uint32_t tri[3];
for (int j = 0; j < 3; j++)
@@ -8408,14 +9387,16 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
const uint32_t index2 = tri[(j + 1) % 3];
if (index1 == index2) {
ignore = true;
- XA_PRINT(" Degenerate edge: index %d, index %d\n", index1, index2);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" Degenerate edge: index %d, index %d\n", index1, index2);
break;
}
const internal::Vector3 &pos1 = mesh->position(index1);
const internal::Vector3 &pos2 = mesh->position(index2);
if (internal::length(pos2 - pos1) <= 0.0f) {
ignore = true;
- XA_PRINT(" Zero length edge: index %d position (%g %g %g), index %d position (%g %g %g)\n", index1, pos1.x, pos1.y, pos1.z, index2, pos2.x, pos2.y, pos2.z);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" Zero length edge: index %d position (%g %g %g), index %d position (%g %g %g)\n", index1, pos1.x, pos1.y, pos1.z, index2, pos2.x, pos2.y, pos2.z);
break;
}
}
@@ -8424,14 +9405,16 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
for (int j = 0; j < 3; j++) {
const internal::Vector3 &pos = mesh->position(tri[j]);
if (internal::isNan(pos.x) || internal::isNan(pos.y) || internal::isNan(pos.z)) {
- XA_PRINT(" NAN position in face: %d\n", i);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" NAN position in face: %d\n", i);
ignore = true;
break;
}
if (meshDecl.vertexNormalData) {
const internal::Vector3 &normal = mesh->normal(tri[j]);
if (internal::isNan(normal.x) || internal::isNan(normal.y) || internal::isNan(normal.z)) {
- XA_PRINT(" NAN normal in face: %d\n", i);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" NAN normal in face: %d\n", i);
ignore = true;
break;
}
@@ -8439,7 +9422,8 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
if (meshDecl.vertexUvData) {
const internal::Vector2 &uv = mesh->texcoord(tri[j]);
if (internal::isNan(uv.x) || internal::isNan(uv.y)) {
- XA_PRINT(" NAN texture coordinate in face: %d\n", i);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" NAN texture coordinate in face: %d\n", i);
ignore = true;
break;
}
@@ -8455,20 +9439,26 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
area = internal::length(internal::cross(b - a, c - a)) * 0.5f;
if (area <= internal::kAreaEpsilon) {
ignore = true;
- XA_PRINT(" Zero area face: %d, indices (%d %d %d), area is %f\n", i, tri[0], tri[1], tri[2], area);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" Zero area face: %d, indices (%d %d %d), area is %f\n", i, tri[0], tri[1], tri[2], area);
}
}
if (!ignore) {
if (internal::equal(a, b, meshDecl.epsilon) || internal::equal(a, c, meshDecl.epsilon) || internal::equal(b, c, meshDecl.epsilon)) {
ignore = true;
- XA_PRINT(" Degenerate face: %d, area is %f\n", i, area);
+ if (++warningCount <= kMaxWarnings)
+ XA_PRINT(" Degenerate face: %d, area is %f\n", i, area);
}
}
if (meshDecl.faceIgnoreData && meshDecl.faceIgnoreData[i])
ignore = true;
mesh->addFace(tri[0], tri[1], tri[2], ignore);
}
+ if (warningCount > kMaxWarnings)
+ XA_PRINT(" %u additional warnings truncated\n", warningCount - kMaxWarnings);
XA_PROFILE_END(addMeshCopyData)
+ ctx->meshes.push_back(mesh);
+ ctx->paramAtlas.addMesh(mesh);
if (ctx->addMeshTaskGroup.value == UINT32_MAX)
ctx->addMeshTaskGroup = ctx->taskScheduler->createTaskGroup();
AddMeshTaskArgs *taskArgs = XA_NEW(internal::MemTag::Default, AddMeshTaskArgs); // The task frees this.
@@ -8478,11 +9468,11 @@ AddMeshError::Enum AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t mesh
task.userData = taskArgs;
task.func = runAddMeshTask;
ctx->taskScheduler->run(ctx->addMeshTaskGroup, task);
- ctx->meshCount++;
return AddMeshError::Success;
}
-void AddMeshJoin(Atlas *atlas) {
+void AddMeshJoin(Atlas *atlas)
+{
XA_DEBUG_ASSERT(atlas);
if (!atlas) {
XA_PRINT_WARNING("AddMeshJoin: atlas is null.\n");
@@ -8495,41 +9485,43 @@ void AddMeshJoin(Atlas *atlas) {
ctx->addMeshProgress->~Progress();
XA_FREE(ctx->addMeshProgress);
ctx->addMeshProgress = nullptr;
- ctx->paramAtlas.sortChartGroups();
#if XA_PROFILE
- XA_PRINT("Added %u meshes\n", ctx->meshCount);
+ XA_PRINT("Added %u meshes\n", ctx->meshes.size());
internal::s_profile.addMeshReal = clock() - internal::s_profile.addMeshReal;
#endif
XA_PROFILE_PRINT_AND_RESET(" Total (real): ", addMeshReal)
XA_PROFILE_PRINT_AND_RESET(" Copy data: ", addMeshCopyData)
XA_PROFILE_PRINT_AND_RESET(" Total (thread): ", addMeshThread)
XA_PROFILE_PRINT_AND_RESET(" Create colocals: ", addMeshCreateColocals)
- XA_PROFILE_PRINT_AND_RESET(" Create face groups: ", addMeshCreateFaceGroups)
- XA_PROFILE_PRINT_AND_RESET(" Create chart groups (real): ", addMeshCreateChartGroupsReal)
- XA_PROFILE_PRINT_AND_RESET(" Create chart groups (thread): ", addMeshCreateChartGroupsThread)
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_PRINT_AND_RESET(" Alloc: ", alloc)
+#endif
XA_PRINT_MEM_USAGE
+#if XA_DEBUG_EXPORT_OBJ_FACE_GROUPS
+ internal::param::s_faceGroupsCurrentVertex = 0;
+#endif
}
-struct EdgeKey {
+struct EdgeKey
+{
EdgeKey() {}
- EdgeKey(const EdgeKey &k) :
- v0(k.v0), v1(k.v1) {}
- EdgeKey(uint32_t v0, uint32_t v1) :
- v0(v0), v1(v1) {}
+ EdgeKey(const EdgeKey &k) : v0(k.v0), v1(k.v1) {}
+ EdgeKey(uint32_t v0, uint32_t v1) : v0(v0), v1(v1) {}
bool operator==(const EdgeKey &k) const { return v0 == k.v0 && v1 == k.v1; }
uint32_t v0;
uint32_t v1;
};
-AddMeshError::Enum AddUvMesh(Atlas *atlas, const UvMeshDecl &decl) {
+AddMeshError::Enum AddUvMesh(Atlas *atlas, const UvMeshDecl &decl)
+{
XA_DEBUG_ASSERT(atlas);
if (!atlas) {
XA_PRINT_WARNING("AddUvMesh: atlas is null.\n");
return AddMeshError::Error;
}
Context *ctx = (Context *)atlas;
- if (ctx->meshCount > 0) {
+ if (!ctx->meshes.isEmpty()) {
XA_PRINT_WARNING("AddUvMesh: Meshes and UV meshes cannot be added to the same atlas.\n");
return AddMeshError::Error;
}
@@ -8632,7 +9624,8 @@ AddMeshError::Enum AddUvMesh(Atlas *atlas, const UvMeshDecl &decl) {
return AddMeshError::Success;
}
-void ComputeCharts(Atlas *atlas, ChartOptions chartOptions) {
+void ComputeCharts(Atlas *atlas, ChartOptions options)
+{
if (!atlas) {
XA_PRINT_WARNING("ComputeCharts: atlas is null.\n");
return;
@@ -8643,69 +9636,66 @@ void ComputeCharts(Atlas *atlas, ChartOptions chartOptions) {
return;
}
AddMeshJoin(atlas);
- if (ctx->meshCount == 0) {
+ if (ctx->meshes.isEmpty()) {
XA_PRINT_WARNING("ComputeCharts: No meshes. Call AddMesh first.\n");
return;
}
XA_PRINT("Computing charts\n");
- uint32_t chartCount = 0, chartsWithHolesCount = 0, holesCount = 0, chartsWithTJunctionsCount = 0, tJunctionsCount = 0;
XA_PROFILE_START(computeChartsReal)
- if (!ctx->paramAtlas.computeCharts(ctx->taskScheduler, chartOptions, ctx->progressFunc, ctx->progressUserData)) {
+ if (!ctx->paramAtlas.computeCharts(ctx->taskScheduler, options, ctx->progressFunc, ctx->progressUserData)) {
XA_PRINT(" Cancelled by user\n");
return;
}
XA_PROFILE_END(computeChartsReal)
- // Count charts and print warnings.
- for (uint32_t i = 0; i < ctx->meshCount; i++) {
+ // Count charts.
+ uint32_t chartCount = 0;
+ const uint32_t meshCount = ctx->meshes.size();
+ for (uint32_t i = 0; i < meshCount; i++) {
for (uint32_t j = 0; j < ctx->paramAtlas.chartGroupCount(i); j++) {
const internal::param::ChartGroup *chartGroup = ctx->paramAtlas.chartGroupAt(i, j);
- if (chartGroup->isVertexMap())
- continue;
- for (uint32_t k = 0; k < chartGroup->chartCount(); k++) {
- const internal::param::Chart *chart = chartGroup->chartAt(k);
-#if XA_PRINT_CHART_WARNINGS
- if (chart->warningFlags() & internal::param::ChartWarningFlags::CloseHolesFailed)
- XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): failed to close holes\n", chartCount, i, j, k);
- if (chart->warningFlags() & internal::param::ChartWarningFlags::FixTJunctionsDuplicatedEdge)
- XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): fixing t-junctions created non-manifold geometry\n", chartCount, i, j, k);
- if (chart->warningFlags() & internal::param::ChartWarningFlags::FixTJunctionsFailed)
- XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): fixing t-junctions failed\n", chartCount, i, j, k);
- if (chart->warningFlags() & internal::param::ChartWarningFlags::TriangulateDuplicatedEdge)
- XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): triangulation created non-manifold geometry\n", chartCount, i, j, k);
-#endif
- holesCount += chart->closedHolesCount();
- if (chart->closedHolesCount() > 0)
- chartsWithHolesCount++;
- tJunctionsCount += chart->fixedTJunctionsCount();
- if (chart->fixedTJunctionsCount() > 0)
- chartsWithTJunctionsCount++;
- chartCount++;
- }
+ chartCount += chartGroup->segmentChartCount();
}
}
- if (holesCount > 0)
- XA_PRINT(" Closed %u holes in %u charts\n", holesCount, chartsWithHolesCount);
- if (tJunctionsCount > 0)
- XA_PRINT(" Fixed %u t-junctions in %u charts\n", tJunctionsCount, chartsWithTJunctionsCount);
XA_PRINT(" %u charts\n", chartCount);
+#if XA_PROFILE
+ XA_PRINT(" Chart groups\n");
+ uint32_t chartGroupCount = 0;
+ for (uint32_t i = 0; i < meshCount; i++) {
+ XA_PRINT(" Mesh %u: %u chart groups\n", i, ctx->paramAtlas.chartGroupCount(i));
+ chartGroupCount += ctx->paramAtlas.chartGroupCount(i);
+ }
+ XA_PRINT(" %u total\n", chartGroupCount);
+#endif
XA_PROFILE_PRINT_AND_RESET(" Total (real): ", computeChartsReal)
XA_PROFILE_PRINT_AND_RESET(" Total (thread): ", computeChartsThread)
- XA_PROFILE_PRINT_AND_RESET(" Build atlas: ", buildAtlas)
- XA_PROFILE_PRINT_AND_RESET(" Init: ", buildAtlasInit)
- XA_PROFILE_PRINT_AND_RESET(" Place seeds: ", buildAtlasPlaceSeeds)
- XA_PROFILE_PRINT_AND_RESET(" Relocate seeds: ", buildAtlasRelocateSeeds)
- XA_PROFILE_PRINT_AND_RESET(" Reset charts: ", buildAtlasResetCharts)
- XA_PROFILE_PRINT_AND_RESET(" Grow charts: ", buildAtlasGrowCharts)
- XA_PROFILE_PRINT_AND_RESET(" Merge charts: ", buildAtlasMergeCharts)
- XA_PROFILE_PRINT_AND_RESET(" Fill holes: ", buildAtlasFillHoles)
- XA_PROFILE_PRINT_AND_RESET(" Create chart meshes (real): ", createChartMeshesReal)
- XA_PROFILE_PRINT_AND_RESET(" Create chart meshes (thread): ", createChartMeshesThread)
- XA_PROFILE_PRINT_AND_RESET(" Fix t-junctions: ", fixChartMeshTJunctions)
- XA_PROFILE_PRINT_AND_RESET(" Close holes: ", closeChartMeshHoles)
+ XA_PROFILE_PRINT_AND_RESET(" Create face groups: ", createFaceGroups)
+ XA_PROFILE_PRINT_AND_RESET(" Extract invalid mesh geometry: ", extractInvalidMeshGeometry)
+ XA_PROFILE_PRINT_AND_RESET(" Chart group compute charts (real): ", chartGroupComputeChartsReal)
+ XA_PROFILE_PRINT_AND_RESET(" Chart group compute charts (thread): ", chartGroupComputeChartsThread)
+ XA_PROFILE_PRINT_AND_RESET(" Create chart group mesh: ", createChartGroupMesh)
+ XA_PROFILE_PRINT_AND_RESET(" Create colocals: ", createChartGroupMeshColocals)
+ XA_PROFILE_PRINT_AND_RESET(" Create boundaries: ", createChartGroupMeshBoundaries)
+ XA_PROFILE_PRINT_AND_RESET(" Build atlas: ", buildAtlas)
+ XA_PROFILE_PRINT_AND_RESET(" Init: ", buildAtlasInit)
+ XA_PROFILE_PRINT_AND_RESET(" Planar charts: ", planarCharts)
+ XA_PROFILE_PRINT_AND_RESET(" Clustered charts: ", clusteredCharts)
+ XA_PROFILE_PRINT_AND_RESET(" Place seeds: ", clusteredChartsPlaceSeeds)
+ XA_PROFILE_PRINT_AND_RESET(" Boundary intersection: ", clusteredChartsPlaceSeedsBoundaryIntersection)
+ XA_PROFILE_PRINT_AND_RESET(" Relocate seeds: ", clusteredChartsRelocateSeeds)
+ XA_PROFILE_PRINT_AND_RESET(" Reset: ", clusteredChartsReset)
+ XA_PROFILE_PRINT_AND_RESET(" Grow: ", clusteredChartsGrow)
+ XA_PROFILE_PRINT_AND_RESET(" Boundary intersection: ", clusteredChartsGrowBoundaryIntersection)
+ XA_PROFILE_PRINT_AND_RESET(" Merge: ", clusteredChartsMerge)
+ XA_PROFILE_PRINT_AND_RESET(" Fill holes: ", clusteredChartsFillHoles)
+ XA_PROFILE_PRINT_AND_RESET(" Copy chart faces: ", copyChartFaces)
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_PRINT_AND_RESET(" Alloc: ", alloc)
+#endif
XA_PRINT_MEM_USAGE
}
-void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
+void ParameterizeCharts(Atlas *atlas, ParameterizeOptions options)
+{
if (!atlas) {
XA_PRINT_WARNING("ParameterizeCharts: atlas is null.\n");
return;
@@ -8734,19 +9724,34 @@ void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
DestroyOutputMeshes(ctx);
XA_PRINT("Parameterizing charts\n");
XA_PROFILE_START(parameterizeChartsReal)
- if (!ctx->paramAtlas.parameterizeCharts(ctx->taskScheduler, func, ctx->progressFunc, ctx->progressUserData)) {
+ if (!ctx->paramAtlas.parameterizeCharts(ctx->taskScheduler, options, ctx->progressFunc, ctx->progressUserData)) {
XA_PRINT(" Cancelled by user\n");
- return;
+ return;
}
XA_PROFILE_END(parameterizeChartsReal)
- uint32_t chartCount = 0, orthoChartsCount = 0, planarChartsCount = 0, lscmChartsCount = 0, piecewiseChartsCount = 0, chartsAddedCount = 0, chartsDeletedCount = 0;
- for (uint32_t i = 0; i < ctx->meshCount; i++) {
+ const uint32_t meshCount = ctx->meshes.size();
+ uint32_t chartCount = 0, chartsWithHolesCount = 0, holesCount = 0, chartsWithTJunctionsCount = 0, tJunctionsCount = 0, orthoChartsCount = 0, planarChartsCount = 0, lscmChartsCount = 0, piecewiseChartsCount = 0, chartsAddedCount = 0, chartsDeletedCount = 0;
+ for (uint32_t i = 0; i < meshCount; i++) {
for (uint32_t j = 0; j < ctx->paramAtlas.chartGroupCount(i); j++) {
const internal::param::ChartGroup *chartGroup = ctx->paramAtlas.chartGroupAt(i, j);
- if (chartGroup->isVertexMap())
- continue;
for (uint32_t k = 0; k < chartGroup->chartCount(); k++) {
const internal::param::Chart *chart = chartGroup->chartAt(k);
+#if XA_PRINT_CHART_WARNINGS
+ if (chart->warningFlags() & internal::param::ChartWarningFlags::CloseHolesFailed)
+ XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): failed to close holes\n", chartCount, i, j, k);
+ if (chart->warningFlags() & internal::param::ChartWarningFlags::FixTJunctionsDuplicatedEdge)
+ XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): fixing t-junctions created non-manifold geometry\n", chartCount, i, j, k);
+ if (chart->warningFlags() & internal::param::ChartWarningFlags::FixTJunctionsFailed)
+ XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): fixing t-junctions failed\n", chartCount, i, j, k);
+ if (chart->warningFlags() & internal::param::ChartWarningFlags::TriangulateDuplicatedEdge)
+ XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u): triangulation created non-manifold geometry\n", chartCount, i, j, k);
+#endif
+ holesCount += chart->closedHolesCount();
+ if (chart->closedHolesCount() > 0)
+ chartsWithHolesCount++;
+ tJunctionsCount += chart->fixedTJunctionsCount();
+ if (chart->fixedTJunctionsCount() > 0)
+ chartsWithTJunctionsCount++;
if (chart->type() == ChartType::Planar)
planarChartsCount++;
else if (chart->type() == ChartType::Ortho)
@@ -8761,19 +9766,21 @@ void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
chartsDeletedCount += chartGroup->paramDeletedChartsCount();
}
}
+ if (holesCount > 0)
+ XA_PRINT(" %u holes closed in %u charts\n", holesCount, chartsWithHolesCount);
+ if (tJunctionsCount > 0)
+ XA_PRINT(" %u t-junctions fixed in %u charts\n", tJunctionsCount, chartsWithTJunctionsCount);
XA_PRINT(" %u planar charts, %u ortho charts, %u LSCM charts, %u piecewise charts\n", planarChartsCount, orthoChartsCount, lscmChartsCount, piecewiseChartsCount);
if (chartsDeletedCount > 0) {
XA_PRINT(" %u charts with invalid parameterizations replaced with %u new charts\n", chartsDeletedCount, chartsAddedCount);
XA_PRINT(" %u charts\n", chartCount);
}
uint32_t chartIndex = 0, invalidParamCount = 0;
- for (uint32_t i = 0; i < ctx->meshCount; i++) {
+ for (uint32_t i = 0; i < meshCount; i++) {
for (uint32_t j = 0; j < ctx->paramAtlas.chartGroupCount(i); j++) {
const internal::param::ChartGroup *chartGroup = ctx->paramAtlas.chartGroupAt(i, j);
- if (chartGroup->isVertexMap())
- continue;
for (uint32_t k = 0; k < chartGroup->chartCount(); k++) {
- const internal::param::Chart *chart = chartGroup->chartAt(k);
+ internal::param::Chart *chart = chartGroup->chartAt(k);
const internal::param::Quality &quality = chart->quality();
#if XA_DEBUG_EXPORT_OBJ_CHARTS_AFTER_PARAMETERIZATION
{
@@ -8782,7 +9789,6 @@ void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
chart->unifiedMesh()->writeObjFile(filename);
}
#endif
- bool invalid = false;
const char *type = "LSCM";
if (chart->type() == ChartType::Planar)
type = "planar";
@@ -8790,18 +9796,15 @@ void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
type = "ortho";
else if (chart->type() == ChartType::Piecewise)
type = "piecewise";
- if (quality.boundaryIntersection) {
- invalid = true;
- XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u) (%s): invalid parameterization, self-intersecting boundary.\n", chartIndex, i, j, k, type);
- }
- if (quality.flippedTriangleCount > 0) {
- invalid = true;
- XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u) (%s): invalid parameterization, %u / %u flipped triangles.\n", chartIndex, i, j, k, type, quality.flippedTriangleCount, quality.totalTriangleCount);
- }
- if (invalid)
+ if (chart->isInvalid()) {
+ if (quality.boundaryIntersection) {
+ XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u) (%s): invalid parameterization, self-intersecting boundary.\n", chartIndex, i, j, k, type);
+ }
+ if (quality.flippedTriangleCount > 0) {
+ XA_PRINT_WARNING(" Chart %u (mesh %u, group %u, id %u) (%s): invalid parameterization, %u / %u flipped triangles.\n", chartIndex, i, j, k, type, quality.flippedTriangleCount, quality.totalTriangleCount);
+ }
invalidParamCount++;
#if XA_DEBUG_EXPORT_OBJ_INVALID_PARAMETERIZATION
- if (invalid) {
char filename[256];
XA_SPRINTF(filename, sizeof(filename), "debug_chart_%03u_invalid_parameterization.obj", chartIndex);
const internal::Mesh *mesh = chart->unifiedMesh();
@@ -8822,8 +9825,8 @@ void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
mesh->writeObjLinkedBoundaries(file);
fclose(file);
}
- }
#endif
+ }
chartIndex++;
}
}
@@ -8832,20 +9835,30 @@ void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func) {
XA_PRINT_WARNING(" %u charts with invalid parameterizations\n", invalidParamCount);
XA_PROFILE_PRINT_AND_RESET(" Total (real): ", parameterizeChartsReal)
XA_PROFILE_PRINT_AND_RESET(" Total (thread): ", parameterizeChartsThread)
+ XA_PROFILE_PRINT_AND_RESET(" Create chart mesh: ", createChartMesh)
+ XA_PROFILE_PRINT_AND_RESET(" Fix t-junctions: ", fixChartMeshTJunctions)
+ XA_PROFILE_PRINT_AND_RESET(" Close holes: ", closeChartMeshHoles)
XA_PROFILE_PRINT_AND_RESET(" Orthogonal: ", parameterizeChartsOrthogonal)
XA_PROFILE_PRINT_AND_RESET(" LSCM: ", parameterizeChartsLSCM)
+ XA_PROFILE_PRINT_AND_RESET(" Recompute: ", parameterizeChartsRecompute)
+ XA_PROFILE_PRINT_AND_RESET(" Piecewise: ", parameterizeChartsPiecewise)
+ XA_PROFILE_PRINT_AND_RESET(" Boundary intersection: ", parameterizeChartsPiecewiseBoundaryIntersection)
XA_PROFILE_PRINT_AND_RESET(" Evaluate quality: ", parameterizeChartsEvaluateQuality)
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_PRINT_AND_RESET(" Alloc: ", alloc)
+#endif
XA_PRINT_MEM_USAGE
}
-void PackCharts(Atlas *atlas, PackOptions packOptions) {
+void PackCharts(Atlas *atlas, PackOptions packOptions)
+{
// Validate arguments and context state.
if (!atlas) {
XA_PRINT_WARNING("PackCharts: atlas is null.\n");
return;
}
Context *ctx = (Context *)atlas;
- if (ctx->meshCount == 0 && ctx->uvMeshInstances.isEmpty()) {
+ if (ctx->meshes.isEmpty() && ctx->uvMeshInstances.isEmpty()) {
XA_PRINT_WARNING("PackCharts: No meshes. Call AddMesh or AddUvMesh first.\n");
return;
}
@@ -8880,7 +9893,8 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) {
if (!ctx->uvMeshInstances.isEmpty()) {
for (uint32_t i = 0; i < ctx->uvMeshInstances.size(); i++)
packAtlas.addUvMeshCharts(ctx->uvMeshInstances[i]);
- } else
+ }
+ else
packAtlas.addCharts(ctx->taskScheduler, &ctx->paramAtlas);
XA_PROFILE_END(packChartsAddCharts)
XA_PROFILE_START(packCharts)
@@ -8901,7 +9915,7 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) {
if (packOptions.createImage) {
atlas->image = XA_ALLOC_ARRAY(internal::MemTag::Default, uint32_t, atlas->atlasCount * atlas->width * atlas->height);
for (uint32_t i = 0; i < atlas->atlasCount; i++)
- packAtlas.getImages()[i]->copyTo(&atlas->image[atlas->width * atlas->height * i], atlas->width, atlas->height, packOptions.blockAlign ? 0 : packOptions.padding);
+ packAtlas.getImages()[i]->copyTo(&atlas->image[atlas->width * atlas->height * i], atlas->width, atlas->height, packOptions.padding);
}
XA_PROFILE_PRINT_AND_RESET(" Total: ", packCharts)
XA_PROFILE_PRINT_AND_RESET(" Add charts (real): ", packChartsAddCharts)
@@ -8911,6 +9925,9 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) {
XA_PROFILE_PRINT_AND_RESET(" Dilate (padding): ", packChartsDilate)
XA_PROFILE_PRINT_AND_RESET(" Find location: ", packChartsFindLocation)
XA_PROFILE_PRINT_AND_RESET(" Blit: ", packChartsBlit)
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_PRINT_AND_RESET(" Alloc: ", alloc)
+#endif
XA_PRINT_MEM_USAGE
XA_PRINT("Building output meshes\n");
XA_PROFILE_START(buildOutputMeshes)
@@ -8920,91 +9937,92 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) {
return;
}
if (ctx->uvMeshInstances.isEmpty())
- atlas->meshCount = ctx->meshCount;
+ atlas->meshCount = ctx->meshes.size();
else
atlas->meshCount = ctx->uvMeshInstances.size();
atlas->meshes = XA_ALLOC_ARRAY(internal::MemTag::Default, Mesh, atlas->meshCount);
memset(atlas->meshes, 0, sizeof(Mesh) * atlas->meshCount);
if (ctx->uvMeshInstances.isEmpty()) {
uint32_t chartIndex = 0;
- for (uint32_t i = 0; i < ctx->meshCount; i++) {
+ for (uint32_t i = 0; i < atlas->meshCount; i++) {
Mesh &outputMesh = atlas->meshes[i];
- // Count and alloc arrays. Ignore vertex mapped chart groups in Mesh::chartCount, since they're ignored faces.
+ // Count and alloc arrays.
+ const internal::param::InvalidMeshGeometry &invalid = ctx->paramAtlas.invalidMeshGeometry(i);
+ outputMesh.vertexCount += invalid.vertices().length;
+ outputMesh.indexCount += invalid.faces().length * 3;
for (uint32_t cg = 0; cg < ctx->paramAtlas.chartGroupCount(i); cg++) {
const internal::param::ChartGroup *chartGroup = ctx->paramAtlas.chartGroupAt(i, cg);
- if (chartGroup->isVertexMap()) {
- outputMesh.vertexCount += chartGroup->mesh()->vertexCount();
- outputMesh.indexCount += chartGroup->mesh()->faceCount() * 3;
- } else {
- for (uint32_t c = 0; c < chartGroup->chartCount(); c++) {
- const internal::param::Chart *chart = chartGroup->chartAt(c);
- outputMesh.vertexCount += chart->mesh()->vertexCount();
- outputMesh.indexCount += chart->mesh()->faceCount() * 3;
- outputMesh.chartCount++;
- }
+ for (uint32_t c = 0; c < chartGroup->chartCount(); c++) {
+ const internal::param::Chart *chart = chartGroup->chartAt(c);
+ outputMesh.vertexCount += chart->mesh()->vertexCount();
+ outputMesh.indexCount += chart->mesh()->faceCount() * 3;
+ outputMesh.chartCount++;
}
}
outputMesh.vertexArray = XA_ALLOC_ARRAY(internal::MemTag::Default, Vertex, outputMesh.vertexCount);
outputMesh.indexArray = XA_ALLOC_ARRAY(internal::MemTag::Default, uint32_t, outputMesh.indexCount);
outputMesh.chartArray = XA_ALLOC_ARRAY(internal::MemTag::Default, Chart, outputMesh.chartCount);
- XA_PRINT(" mesh %u: %u vertices, %u triangles, %u charts\n", i, outputMesh.vertexCount, outputMesh.indexCount / 3, outputMesh.chartCount);
+ XA_PRINT(" Mesh %u: %u vertices, %u triangles, %u charts\n", i, outputMesh.vertexCount, outputMesh.indexCount / 3, outputMesh.chartCount);
// Copy mesh data.
- uint32_t firstVertex = 0, meshChartIndex = 0;
+ uint32_t firstVertex = 0;
+ {
+ const internal::param::InvalidMeshGeometry &mesh = ctx->paramAtlas.invalidMeshGeometry(i);
+ internal::ConstArrayView<uint32_t> faces = mesh.faces();
+ internal::ConstArrayView<uint32_t> indices = mesh.indices();
+ internal::ConstArrayView<uint32_t> vertices = mesh.vertices();
+ // Vertices.
+ for (uint32_t v = 0; v < vertices.length; v++) {
+ Vertex &vertex = outputMesh.vertexArray[v];
+ vertex.atlasIndex = -1;
+ vertex.chartIndex = -1;
+ vertex.uv[0] = vertex.uv[1] = 0.0f;
+ vertex.xref = vertices[v];
+ }
+ // Indices.
+ for (uint32_t f = 0; f < faces.length; f++) {
+ const uint32_t indexOffset = faces[f] * 3;
+ for (uint32_t j = 0; j < 3; j++)
+ outputMesh.indexArray[indexOffset + j] = indices[f * 3 + j];
+ }
+ firstVertex = vertices.length;
+ }
+ uint32_t meshChartIndex = 0;
for (uint32_t cg = 0; cg < ctx->paramAtlas.chartGroupCount(i); cg++) {
const internal::param::ChartGroup *chartGroup = ctx->paramAtlas.chartGroupAt(i, cg);
- if (chartGroup->isVertexMap()) {
- const internal::Mesh *mesh = chartGroup->mesh();
+ for (uint32_t c = 0; c < chartGroup->chartCount(); c++) {
+ const internal::param::Chart *chart = chartGroup->chartAt(c);
+ const internal::Mesh *mesh = chart->mesh();
// Vertices.
for (uint32_t v = 0; v < mesh->vertexCount(); v++) {
Vertex &vertex = outputMesh.vertexArray[firstVertex + v];
- vertex.atlasIndex = -1;
- vertex.chartIndex = -1;
- vertex.uv[0] = vertex.uv[1] = 0.0f;
- vertex.xref = chartGroup->mapVertexToSourceVertex(v);
+ vertex.atlasIndex = packAtlas.getChart(chartIndex)->atlasIndex;
+ XA_DEBUG_ASSERT(vertex.atlasIndex >= 0);
+ vertex.chartIndex = (int32_t)chartIndex;
+ const internal::Vector2 &uv = mesh->texcoord(v);
+ vertex.uv[0] = internal::max(0.0f, uv.x);
+ vertex.uv[1] = internal::max(0.0f, uv.y);
+ vertex.xref = chart->mapChartVertexToSourceVertex(v);
}
// Indices.
for (uint32_t f = 0; f < mesh->faceCount(); f++) {
- const uint32_t indexOffset = chartGroup->mapFaceToSourceFace(f) * 3;
+ const uint32_t indexOffset = chart->mapFaceToSourceFace(f) * 3;
for (uint32_t j = 0; j < 3; j++)
outputMesh.indexArray[indexOffset + j] = firstVertex + mesh->vertexAt(f * 3 + j);
}
+ // Charts.
+ Chart *outputChart = &outputMesh.chartArray[meshChartIndex];
+ const int32_t atlasIndex = packAtlas.getChart(chartIndex)->atlasIndex;
+ XA_DEBUG_ASSERT(atlasIndex >= 0);
+ outputChart->atlasIndex = (uint32_t)atlasIndex;
+ outputChart->type = chart->isInvalid() ? ChartType::Invalid : chart->type();
+ outputChart->faceCount = mesh->faceCount();
+ outputChart->faceArray = XA_ALLOC_ARRAY(internal::MemTag::Default, uint32_t, outputChart->faceCount);
+ for (uint32_t f = 0; f < outputChart->faceCount; f++)
+ outputChart->faceArray[f] = chart->mapFaceToSourceFace(f);
+ outputChart->material = 0;
+ meshChartIndex++;
+ chartIndex++;
firstVertex += mesh->vertexCount();
- } else {
- for (uint32_t c = 0; c < chartGroup->chartCount(); c++) {
- const internal::param::Chart *chart = chartGroup->chartAt(c);
- const internal::Mesh *mesh = chart->mesh();
- // Vertices.
- for (uint32_t v = 0; v < mesh->vertexCount(); v++) {
- Vertex &vertex = outputMesh.vertexArray[firstVertex + v];
- vertex.atlasIndex = packAtlas.getChart(chartIndex)->atlasIndex;
- XA_DEBUG_ASSERT(vertex.atlasIndex >= 0);
- vertex.chartIndex = (int32_t)chartIndex;
- const internal::Vector2 &uv = mesh->texcoord(v);
- vertex.uv[0] = internal::max(0.0f, uv.x);
- vertex.uv[1] = internal::max(0.0f, uv.y);
- vertex.xref = chartGroup->mapVertexToSourceVertex(chart->mapChartVertexToOriginalVertex(v));
- }
- // Indices.
- for (uint32_t f = 0; f < mesh->faceCount(); f++) {
- const uint32_t indexOffset = chartGroup->mapFaceToSourceFace(chart->mapFaceToSourceFace(f)) * 3;
- for (uint32_t j = 0; j < 3; j++)
- outputMesh.indexArray[indexOffset + j] = firstVertex + mesh->vertexAt(f * 3 + j);
- }
- // Charts.
- Chart *outputChart = &outputMesh.chartArray[meshChartIndex];
- const int32_t atlasIndex = packAtlas.getChart(chartIndex)->atlasIndex;
- XA_DEBUG_ASSERT(atlasIndex >= 0);
- outputChart->atlasIndex = (uint32_t)atlasIndex;
- outputChart->type = chart->type();
- outputChart->faceCount = mesh->faceCount();
- outputChart->faceArray = XA_ALLOC_ARRAY(internal::MemTag::Default, uint32_t, outputChart->faceCount);
- for (uint32_t f = 0; f < outputChart->faceCount; f++)
- outputChart->faceArray[f] = chartGroup->mapFaceToSourceFace(chart->mapFaceToSourceFace(f));
- outputChart->material = 0;
- meshChartIndex++;
- chartIndex++;
- firstVertex += mesh->vertexCount();
- }
}
}
XA_DEBUG_ASSERT(outputMesh.vertexCount == firstVertex);
@@ -9078,10 +10096,14 @@ void PackCharts(Atlas *atlas, PackOptions packOptions) {
ctx->progressFunc(ProgressCategory::BuildOutputMeshes, 100, ctx->progressUserData);
XA_PROFILE_END(buildOutputMeshes)
XA_PROFILE_PRINT_AND_RESET(" Total: ", buildOutputMeshes)
+#if XA_PROFILE_ALLOC
+ XA_PROFILE_PRINT_AND_RESET(" Alloc: ", alloc)
+#endif
XA_PRINT_MEM_USAGE
}
-void Generate(Atlas *atlas, ChartOptions chartOptions, ParameterizeFunc paramFunc, PackOptions packOptions) {
+void Generate(Atlas *atlas, ChartOptions chartOptions, ParameterizeOptions parameterizeOptions, PackOptions packOptions)
+{
if (!atlas) {
XA_PRINT_WARNING("Generate: atlas is null.\n");
return;
@@ -9091,16 +10113,17 @@ void Generate(Atlas *atlas, ChartOptions chartOptions, ParameterizeFunc paramFun
XA_PRINT_WARNING("Generate: This function should not be called with UV meshes.\n");
return;
}
- if (ctx->meshCount == 0) {
+ if (ctx->meshes.isEmpty()) {
XA_PRINT_WARNING("Generate: No meshes. Call AddMesh first.\n");
return;
}
ComputeCharts(atlas, chartOptions);
- ParameterizeCharts(atlas, paramFunc);
+ ParameterizeCharts(atlas, parameterizeOptions);
PackCharts(atlas, packOptions);
}
-void SetProgressCallback(Atlas *atlas, ProgressFunc progressFunc, void *progressUserData) {
+void SetProgressCallback(Atlas *atlas, ProgressFunc progressFunc, void *progressUserData)
+{
if (!atlas) {
XA_PRINT_WARNING("SetProgressCallback: atlas is null.\n");
return;
@@ -9110,17 +10133,20 @@ void SetProgressCallback(Atlas *atlas, ProgressFunc progressFunc, void *progress
ctx->progressUserData = progressUserData;
}
-void SetAlloc(ReallocFunc reallocFunc, FreeFunc freeFunc) {
+void SetAlloc(ReallocFunc reallocFunc, FreeFunc freeFunc)
+{
internal::s_realloc = reallocFunc;
internal::s_free = freeFunc;
}
-void SetPrint(PrintFunc print, bool verbose) {
+void SetPrint(PrintFunc print, bool verbose)
+{
internal::s_print = print;
internal::s_printVerbose = verbose;
}
-const char *StringForEnum(AddMeshError::Enum error) {
+const char *StringForEnum(AddMeshError::Enum error)
+{
if (error == AddMeshError::Error)
return "Unspecified error";
if (error == AddMeshError::IndexOutOfRange)
@@ -9130,7 +10156,8 @@ const char *StringForEnum(AddMeshError::Enum error) {
return "Success";
}
-const char *StringForEnum(ProgressCategory::Enum category) {
+const char *StringForEnum(ProgressCategory::Enum category)
+{
if (category == ProgressCategory::AddMesh)
return "Adding mesh(es)";
if (category == ProgressCategory::ComputeCharts)
diff --git a/thirdparty/xatlas/xatlas.h b/thirdparty/xatlas/xatlas.h
index e59f493287..cc47f4837e 100644
--- a/thirdparty/xatlas/xatlas.h
+++ b/thirdparty/xatlas/xatlas.h
@@ -1,7 +1,7 @@
/*
MIT License
-Copyright (c) 2018-2019 Jonathan Young
+Copyright (c) 2018-2020 Jonathan Young
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -42,18 +42,19 @@ struct ChartType
Planar,
Ortho,
LSCM,
- Piecewise
+ Piecewise,
+ Invalid
};
};
// A group of connected faces, belonging to a single atlas.
struct Chart
{
- uint32_t atlasIndex; // Sub-atlas index.
uint32_t *faceArray;
+ uint32_t atlasIndex; // Sub-atlas index.
uint32_t faceCount;
- uint32_t material;
ChartType::Enum type;
+ uint32_t material;
};
// Output vertex.
@@ -69,10 +70,10 @@ struct Vertex
struct Mesh
{
Chart *chartArray;
- uint32_t chartCount;
uint32_t *indexArray;
- uint32_t indexCount;
Vertex *vertexArray;
+ uint32_t chartCount;
+ uint32_t indexCount;
uint32_t vertexCount;
};
@@ -84,15 +85,15 @@ static const uint32_t kImageIsPaddingBit = 0x20000000;
// Empty on creation. Populated after charts are packed.
struct Atlas
{
+ uint32_t *image;
+ Mesh *meshes; // The output meshes, corresponding to each AddMesh call.
uint32_t width; // Atlas width in texels.
uint32_t height; // Atlas height in texels.
uint32_t atlasCount; // Number of sub-atlases. Equal to 0 unless PackOptions resolution is changed from default (0).
uint32_t chartCount; // Total number of charts in all meshes.
uint32_t meshCount; // Number of output meshes. Equal to the number of times AddMesh was called.
- Mesh *meshes; // The output meshes, corresponding to each AddMesh call.
float *utilization; // Normalized atlas texel utilization array. E.g. a value of 0.8 means 20% empty space. atlasCount in length.
float texelsPerUnit; // Equal to PackOptions texelsPerUnit if texelsPerUnit > 0, otherwise an estimated value to match PackOptions resolution.
- uint32_t *image;
};
// Create an empty atlas.
@@ -112,22 +113,23 @@ struct IndexFormat
// Input mesh declaration.
struct MeshDecl
{
- uint32_t vertexCount = 0;
const void *vertexPositionData = nullptr;
- uint32_t vertexPositionStride = 0;
const void *vertexNormalData = nullptr; // optional
- uint32_t vertexNormalStride = 0; // optional
const void *vertexUvData = nullptr; // optional. The input UVs are provided as a hint to the chart generator.
- uint32_t vertexUvStride = 0; // optional
- uint32_t indexCount = 0;
const void *indexData = nullptr; // optional
- int32_t indexOffset = 0; // optional. Add this offset to all indices.
- IndexFormat::Enum indexFormat = IndexFormat::UInt16;
// Optional. indexCount / 3 (triangle count) in length.
// Don't atlas faces set to true. Ignored faces still exist in the output meshes, Vertex uv is set to (0, 0) and Vertex atlasIndex to -1.
const bool *faceIgnoreData = nullptr;
+ uint32_t vertexCount = 0;
+ uint32_t vertexPositionStride = 0;
+ uint32_t vertexNormalStride = 0; // optional
+ uint32_t vertexUvStride = 0; // optional
+ uint32_t indexCount = 0;
+ int32_t indexOffset = 0; // optional. Add this offset to all indices.
+ IndexFormat::Enum indexFormat = IndexFormat::UInt16;
+
// Vertex positions within epsilon distance of each other are considered colocal.
float epsilon = 1.192092896e-07F;
};
@@ -151,14 +153,14 @@ void AddMeshJoin(Atlas *atlas);
struct UvMeshDecl
{
+ const void *vertexUvData = nullptr;
+ const void *indexData = nullptr; // optional
+ const uint32_t *faceMaterialData = nullptr; // Optional. Faces with different materials won't be assigned to the same chart. Must be indexCount / 3 in length.
uint32_t vertexCount = 0;
uint32_t vertexStride = 0;
- const void *vertexUvData = nullptr;
uint32_t indexCount = 0;
- const void *indexData = nullptr; // optional
int32_t indexOffset = 0; // optional. Add this offset to all indices.
IndexFormat::Enum indexFormat = IndexFormat::UInt16;
- const uint32_t *faceMaterialData = nullptr; // Optional. Faces with different materials won't be assigned to the same chart. Must be indexCount / 3 in length.
bool rotateCharts = true;
};
@@ -170,24 +172,31 @@ struct ChartOptions
float maxBoundaryLength = 0.0f; // Don't grow charts to have a longer boundary than this. 0 means no limit.
// Weights determine chart growth. Higher weights mean higher cost for that metric.
- float proxyFitMetricWeight = 2.0f; // Angle between face and average chart normal.
- float roundnessMetricWeight = 0.01f;
- float straightnessMetricWeight = 6.0f;
- float normalSeamMetricWeight = 4.0f; // If > 1000, normal seams are fully respected.
- float textureSeamMetricWeight = 0.5f;
+ float normalDeviationWeight = 2.0f; // Angle between face and average chart normal.
+ float roundnessWeight = 0.01f;
+ float straightnessWeight = 6.0f;
+ float normalSeamWeight = 4.0f; // If > 1000, normal seams are fully respected.
+ float textureSeamWeight = 0.5f;
- float maxThreshold = 2.0f; // If total of all metrics * weights > maxThreshold, don't grow chart. Lower values result in more charts.
+ float maxCost = 2.0f; // If total of all metrics * weights > maxCost, don't grow chart. Lower values result in more charts.
uint32_t maxIterations = 1; // Number of iterations of the chart growing and seeding phases. Higher values result in better charts.
};
// Call after all AddMesh calls. Can be called multiple times to recompute charts with different options.
-void ComputeCharts(Atlas *atlas, ChartOptions chartOptions = ChartOptions());
+void ComputeCharts(Atlas *atlas, ChartOptions options = ChartOptions());
// Custom parameterization function. texcoords initial values are an orthogonal parameterization.
typedef void (*ParameterizeFunc)(const float *positions, float *texcoords, uint32_t vertexCount, const uint32_t *indices, uint32_t indexCount);
+struct ParameterizeOptions
+{
+ ParameterizeFunc func = nullptr;
+ bool closeHoles = true; // If the custom parameterization function works with multiple boundaries, this can be set to false to improve performance.
+ bool fixTJunctions = true; // If meshes don't have T-junctions, this can be set to false to improve performance.
+};
+
// Call after ComputeCharts. Can be called multiple times to re-parameterize charts with a different ParameterizeFunc.
-void ParameterizeCharts(Atlas *atlas, ParameterizeFunc func = nullptr);
+void ParameterizeCharts(Atlas *atlas, ParameterizeOptions options = ParameterizeOptions());
struct PackOptions
{
@@ -224,7 +233,7 @@ struct PackOptions
void PackCharts(Atlas *atlas, PackOptions packOptions = PackOptions());
// Equivalent to calling ComputeCharts, ParameterizeCharts and PackCharts in sequence. Can be called multiple times to regenerate with different options.
-void Generate(Atlas *atlas, ChartOptions chartOptions = ChartOptions(), ParameterizeFunc paramFunc = nullptr, PackOptions packOptions = PackOptions());
+void Generate(Atlas *atlas, ChartOptions chartOptions = ChartOptions(), ParameterizeOptions parameterizeOptions = ParameterizeOptions(), PackOptions packOptions = PackOptions());
// Progress tracking.
struct ProgressCategory